{"text": "%% LyX 2.2.4 created this file.  For more info, see http://www.lyx.org/.\r\n%% Do not edit unless you really know what you are doing.\r\n\\documentclass[12pt, a4paper]{article}\r\n\\usepackage{geometry}\r\n\\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=3cm,rmargin=3cm}\r\n\\usepackage{float}\r\n\\usepackage{amsmath}\r\n\\usepackage{amsfonts}\r\n\\usepackage{graphicx}\r\n\\PassOptionsToPackage{normalem}{ulem}\r\n\\usepackage{ulem}\r\n\\usepackage{url}\r\n\\usepackage{hyperref}\r\n\r\n\\makeatletter\r\n\\usepackage{colortbl}\r\n\\date{}\r\n\r\n\\@ifundefined{showcaptionsetup}{}{%\r\n \\PassOptionsToPackage{caption=false}{subfig}}\r\n\\usepackage{subfig}\r\n\\makeatother\r\n\r\n\\begin{document}\r\n\r\n\\title{\\Large 16-833: Robot Localization and Mapping, Spring 2021\\\\\r\n\\textbf{\\Large Homework 3 - Linear and Nonlinear\\\\ SLAM Solvers}}\r\n\\maketitle\r\n\\begin{flushright}\r\n\\textbf{\\uline{Due: Wednesday April 7, 11:59pm, 2021}}\r\n\\par\\end{flushright}\r\n\r\n\\def \\ans{0} %0: hide, 1: show\r\n\r\nYour homework should be submitted as a\\textbf{ typeset PDF file} along\r\nwith a\\textbf{ }folder\\textbf{ }including\\textbf{ code} \\textbf{only\r\n(no data)}. The PDF must be submitted on \\textbf{Gradescope}, and\r\ncode submitted on \\textbf{Canvas}. If you have questions, post them\r\non Piazza or come to office hours. Please do not post solutions or\r\ncodes on Piazza. This homework must be done \\textbf{individually},\r\nand plagiarism will be taken seriously. You are free to discuss and\r\ntroubleshoot with others, but the code and writeup must be your own.\r\nNote that you should list the name and Andrew ID of each student you\r\nhave discussed with on the first page of your PDF file.\r\n\r\n\\global\\long\\def\\argmin{\\operatornamewithlimits{arg\\, min}}\r\n\\global\\long\\def\\argmax{\\operatornamewithlimits{arg\\, max}}\r\n\r\n\\section{2D Linear SLAM}\r\n\r\nIn this problem you will implement your own 2D linear SLAM solver\r\nin \\textbf{$\\mathtt{linear.py}$}. Data are provided in \\textbf{$\\mathtt{2d\\_linear.npz}, ~\\mathtt{2d\\_linear\\_loop.npz}$} with loaders. Everything you need to\r\nknow to complete this problem was covered in class, so please refer to your\r\nnotes and lecture slides for guidance.\r\n\r\nWe will be using the least squares formulation of the SLAM problem,\r\nwhich was presented in class:\r\n\r\n\\begin{eqnarray}\r\nx^{*} & = & \\argmin_{x}\\Sigma\\left\\Vert h_{i}\\left(x\\right)-z_{i}\\right\\Vert _{\\mathbf{\\Sigma}_{i}}^{2}\\nonumber \\\\\r\n &  & \\vdots \\label{eq:linear}\\\\\r\n & \\approx & \\argmin_{x}\\left\\Vert \\mathbf{A}x-b\\right\\Vert ^{2}\\nonumber,\r\n\\end{eqnarray}\r\nwhere $z_{i}$ is the $i$-th measurement, $h_{i}\\left(x\\right)$\r\nis the corresponding prediction function, and $\\left\\Vert a\\right\\Vert _{\\mathbf{\\Sigma}}^{2}$\r\ndenotes the squared Mahalanobis distance: $a^{T}\\boldsymbol{\\Sigma}^{-1}a$. \r\n\r\nIn this problem, the state vector $x$ is comprised of the trajectory of\r\nrobot positions and the landmark positions. Both positions\r\nare simply $(x,y)$ coordinates. For a sanity check, we visualize the ground truth trajectory and landmarks in the beginning.\r\n\r\nThere are two types of measurements:\r\nodometry and landmark measurements. Odometry measurements give a relative\r\n$(\\Delta x,\\Delta y)$ displacement from the previous position to\r\nthe next position (in global frame). Landmark measurements also give\r\na relative displacement $(\\Delta x,\\Delta y)$ from the robot position\r\nto the landmark (also in global frame).\r\n\r\n\\subsection{Measurement function (10 points)}\r\nGiven robot poses $\\mathbf{r}^t = [r_x^t, r_y^t]^\\top$ and $\\mathbf{r}^{t+1} = [r_x^{t+1}, r_y^{t+1}]^\\top$ at time $t$ and $t+1$ , write out the measurement function and its Jacobian. (5 points)\r\n\\begin{align*}\r\nh_o(\\mathbf{r}^t,~ \\mathbf{r}^{t+1}):&~ \\mathbb{R}^4 \\to \\mathbb{R}^{2}, \\\\\r\nH_o(\\mathbf{r}^t,~ \\mathbf{r}^{t+1}):&~ \\mathbb{R}^4 \\to \\mathbb{R}^{2\\times 4}.\r\n\\end{align*}\r\n\r\nSimilarly, given the robot pose $\\mathbf{r}^t = [r_x^t,~ r_y^t]^\\top$ at time $t$ and the $k$-th landmark $\\mathbf{l}^{k} = [l_x^{k},~ l_y^{k}]^\\top$. (5 points)\r\n\\begin{align*}\r\n    h_l(\\mathbf{r}^t, \\mathbf{l}^{k}):&~ \\mathbb{R}^4 \\to \\mathbb{R}^{2}, \\\\\r\n    H_l(\\mathbf{r}^t, \\mathbf{l}^{k}):&~ \\mathbb{R}^4 \\to \\mathbb{R}^{2\\times 4}.\r\n\\end{align*}\r\n    \r\n\\subsection{Build a linear system (15 points)}\r\nUse the derivation above, please complete the function \\textbf{$\\mathtt{create\\_linear\\_system}$} \r\nto construct the linear system as described in Eq.~\\ref{eq:linear}. (15 points)\r\n\r\n\\begin{itemize}\r\n\\item Note in this setup, you will be filling the blocks in the large linear system that is aimed at batch optimizing the large state vector stacking all the robot and landmark positions. Please carefully select indices for both measurements and states when you fill in Jacobians. \r\n\\item Use $\\mathtt{int}$ to convert $\\mathtt{observation[:, 0]}$ and $\\mathtt{obsevation[:, 1]}$ into pose and landmark indices respectively.\r\n\\item In addition, you will have to add a prior to the first robot pose, otherwise the system will be underconstrained and the state will be subject to an arbitrary global transformation.\r\n\\item Please refer to the function document for detailed instructions.\r\n\\end{itemize}\r\n\r\n\\subsection{Solvers (20 points)}\r\nGiven the data and the linear system, you are now ready to solve the 2D linear SLAM problem. You are required to implement 5 solvers to solve $Ax = b$ where $A$ is a sparse non-square matrix.\r\n\r\n\\begin{enumerate}\r\n \\item $\\mathtt{pinv}$: Use pseudo inverse to solve the system. You may only use \\\\ $\\mathtt{scipy.sparse.linalg.inv}$ and matrix multiplication in this function. Return $x$ and a placeholder None. (5 \r\n points)\r\n \\item $\\mathtt{lu}$: Use LU factorization (Cholesky is one variant of LU) to solve the system. You may use $\\mathtt{scipy.sparse.linalg.splu}$ to factorize the relevant matrices, and use the resulting $\\mathtt{SuperLU}$'s $\\mathtt{solve}$ method to obtain the final result. Specify ordering $\\mathtt{permc\\_spec}$ with $\\mathtt{NATURAL}$ in $\\mathtt{splu}$. Return both $x$ and $U$. (5 points)\r\n \\item $\\mathtt{qr}$: Use QR factorization to solve the system. You may use $\\mathtt{sparseqr.rz}$ to obtain $\\mathtt{z, R, E, rank}$ from $A, b$, where $R, z$ are the factors used for efficiently solving $||Ax - b||^2 = ||Rx - z||^2 + ||e||^2$ (for details please check the lecture note \\textit{Sparse Least Squares}).\r\n You may then use $\\mathtt{scipy.sparse.linalg.spsolve\\_triangular}$ to get the solution. Specify ordering $\\mathtt{permc\\_spec}$ with $\\mathtt{NATURAL}$ in $\\mathtt{rz}$. You may NOT directly use $\\mathtt{sparseqr.solve}$. Return both $x$ and $R$. (10 points)\r\n\\end{enumerate}\r\n\r\nWe provide you with a default solver for sanity check. After obtaining the state vector $x$, You may decode the state to trajectory and landmarks, and visualize your results using functions $\\mathtt{devectorize\\_state}$ and $\\mathtt{plot\\_traj\\_and\\_landmarks}$. Check if they match the ground truth before you proceed to the next step. \r\n\r\n\\subsection{Exploit sparsity (30 points + 10 points)}\r\nNow we want to exploit sparsity in the linear system in QR and LU factorizations. \r\n\\begin{enumerate}\r\n    \\item $\\mathtt{lu\\_cholmod}$. Change the ordering from the default $\\mathtt{NATURAL}$ to $\\mathtt{COLAMD}$ (Column approximate minimum degree permutation) and return $x$, $U$. (5 points)\r\n    \\item (Bonus) Instead of LU's built-in solver, write your own forward/backward substitution to compute $x$. Note because of reordering (permutation), you need to manipulate both rows and columns. Please check \\href{https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.SuperLU.html#scipy.sparse.linalg.SuperLU}{online documents} for more details. (10 points)\r\n    \\item $\\mathtt{qr\\_cholmod}$. Change the ordering from the default $\\mathtt{NATURAL}$ to $\\mathtt{COLAMD}$ (Column approximate minimum degree permutation) and return $x$, $R$. Note now you have to use $E$ from $\\mathtt{sparseqr.rz}$. \\\\$\\mathtt{sparseqr.permutation\\_vector\\_to\\_matrix}$ can be useful for permutation. (5 points)\r\n    \\item Now proceed with $\\mathtt{2d\\_linear.npz}$, visualize the trajectory and landmarks, and report the efficiency of your method in terms of run time. Attach the visualization and analysis of corresponding factor for $\\mathtt{qr, qr\\_colamd, lu, lu\\_colamd}$. What are your observations and their potential reasons (general comparison between QR, LU, and their reordered version)? (10 points)\r\n    \\item Similarly, process $\\mathtt{2d\\_linear\\_loop.npz}$. Are there differences in efficiency comparing to $\\mathtt{2d\\_linear.npz}$? Write down your observations and reasoning. (10 points)\r\n\\end{enumerate}\r\n\r\n\r\n\\section{2D Nonlinear SLAM}\r\n\r\nNow you are going to extend the linear SLAM to a nonlinear version in \\textbf{$\\mathtt{nonlinear.py}$}.\r\n\r\nThe problem set-up is exactly the same as in the linear problem, except\r\nwe introduce a nonlinear measurement function that returns a bearing\r\nangle $\\theta$ and range $d$ (in robot's body frame, notice\r\nwe assume that this robot always perfectly facing the $x$-direction\r\nof the global frame), which together describe the vector from the\r\nrobot to the landmark:\r\n\r\n\\begin{alignat}{2}\r\nh_{l}\\left(\\mathbf{r}^t, \\mathbf{l}^{k}\\right) & = &  & \\left[\\begin{array}{c}\r\n\\mathrm{atan2}\\left(l_{y}^k-r_{y}^t,l_{x}^k-r_{x}^t\\right)\\\\\r\n\\left(\\left(l_{x}^k-r_{x}^t\\right)^{2}+\\left(l_{y}^k-r_{y}^t\\right)^{2}\\right)^{\\frac{1}{2}}\r\n\\end{array}\\right]=\\left[\\begin{array}{c}\r\n\\theta\\\\\r\nd\r\n\\end{array}\\right].\\label{eq:nonlin_meas}\r\n\\end{alignat}\r\n\r\n\\subsection{Measurement function (10 points)}\r\nIn your nonlinear algorithm, you'll need to predict measurements\r\nbased on the current state estimate. \r\n\\begin{enumerate}\r\n\\item Fill in the functions $\\mathtt{odometry\\_estimation}$, $\\mathtt{bearing\\_range\\_estimation}$\r\nand \\textbf{$\\mathtt{meas\\_landmark}$} with corresponding measurement\r\nfunctions. The odometry measurement function is the same linear function\r\nwe used in the linear SLAM algorithm, while the landmark measurement\r\nfunction is the new nonlinear function introduced in Eq. \\ref{eq:nonlin_meas}. Please carefully check indices and offsets in the state vector.\r\n(5 points)\r\n\r\n\\item Derive the jacobian of the nonlinear landmark function in your\r\nwriteup\r\n$$\r\nH_l(\\mathbf{r}^t, \\mathbf{l}^{k}):~ \\mathbb{R}^4 \\to \\mathbb{R}^{2\\times 4},\r\n$$\r\nand implement the function\\textbf{ $\\mathtt{compute\\_meas\\_obs\\_jacobian}$}\r\nto calculate the jacobian at the provided linearization point. (5\r\npoints)\r\n\\end{enumerate}\r\n\r\n\\subsection{Build a linear system (15 points)}\r\nUse the derivation above, implement \\textbf{$\\mathtt{create\\_linear\\_system}$}, now in $\\mathtt{nonlinear.py}$, to generate the linear system $A$ and $b$ at the current linearization point. (15 points)\r\nIn addition to the notes for the linear case, please remember to \r\n\\begin{itemize}\r\n    \\item Use the provided initialization of $x$ as the linearization point.\r\n    \\item Error per observation is the \\emph{difference} of measurements and estimates because of linearization.\r\n    \\item Use $\\mathtt{warp2pi}$ to normalize the difference of angles.\r\n\\end{itemize}\r\n\r\n\\subsection{Solver (10 points)}\r\nProcess $\\mathtt{2d\\_nonlinear.npz}$. Select one solver you have implemented, and visualize the trajectory and landmarks before and after optimization. Briefly summarize the differences between the optimization process of the linear and the non-linear SLAM problems. (10 points)\r\n\r\n\\section{Code Submission}\r\nInstructions:\r\n\\begin{itemize}\r\n    \\item Use $\\mathtt{conda}$ to create an environment and run $\\mathtt{./install\\_deps.sh}$ to install dependencies. If you encounter failures, please install SuiteSparse to your system (usually already installed), see \\href{https://github.com/yig/PySPQR#dependencies}{dependencies for sparseqr}.\r\n    \\item Read documents and source code for the packages ($\\mathtt{scipy.sparse.linalg}$ and $\\mathtt{sparseqr}$). It is a good exercise to learn to use libraries you are not familiar with.\r\n    \\item Use command line arguments. For instance, you can run\\\\\r\n    {\\sffamily python~linear.py~../data/2d\\_linear.npz~--method~pinv~qr~qr\\_colamd~lu~lu\\_colamd}\r\n    \\\\\r\n    to check the results of all methods altogether on the $\\mathtt{2d\\_linear}$ case.\r\n\r\n\\end{itemize}\r\nPlease upload your code to canvas excluding the $\\mathtt{data}$ folder.\r\n\\end{document}\r\n", "meta": {"hexsha": "43163b6c503eb99e79eac9892eb83b11f8139702", "size": 12271, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "16833_HW3_SOLVERS/problem_set/tex/writeup_16833_HW3_SOLVERS.tex", "max_stars_repo_name": "Kerou-Z/16833_SLAM", "max_stars_repo_head_hexsha": "39c961d353a24f37711d2800ed98d738eabb5d3e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "16833_HW3_SOLVERS/problem_set/tex/writeup_16833_HW3_SOLVERS.tex", "max_issues_repo_name": "Kerou-Z/16833_SLAM", "max_issues_repo_head_hexsha": "39c961d353a24f37711d2800ed98d738eabb5d3e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "16833_HW3_SOLVERS/problem_set/tex/writeup_16833_HW3_SOLVERS.tex", "max_forks_repo_name": "Kerou-Z/16833_SLAM", "max_forks_repo_head_hexsha": "39c961d353a24f37711d2800ed98d738eabb5d3e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2022-01-18T21:57:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T06:30:55.000Z", "avg_line_length": 63.2525773196, "max_line_length": 399, "alphanum_fraction": 0.7324586423, "num_tokens": 3472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4499293265826503}}
{"text": "\\documentclass{article}\n\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{authblk}          % For 2+ authors\n\\usepackage{mathtools}        % an improvement that incorporates amsmath.\n\\usepackage{comment}\n\\usepackage[ruled,noline]{algorithm2e}\n\\usepackage{url}              % Used for linkable URLs.\n\\usepackage{pgfplots}\n\\usepackage{changepage}       % Used to adjust the margins for wide tables.\n\n\\pgfplotsset{compat=1.16}\n% Empty Square Brackets are used to mean empty intervals.\n\\newcommand{\\esb}{[\\,]}\n\n\\begin{document}\n\\title{Partition Maps}\n\\author{Leonid Rozenberg\\thanks{leonidr@gmail.com}}\n\\date{}                             % Supress printing the date under the title.\n\\maketitle\n\n\\begin{abstract}\n  A partition map is a data structure to represent functions where we\n  privilege merging,\n  generating new functions,\n  above other operations.\n  I motivate the use of partition maps in lieu of other data structures\n  and describe challenges in implementing the necessary logic.\n\\end{abstract}\n\n\\section{Introduction}\n\nA mathematician can think of a partition map as a way to represent a function\n($f : D \\rightarrow R$), an association, a map.\nA programmer can think of it as a way to track, non-scalar\nstate\\footnote{I will mix the two nomenclatures and ways of thinking\nas domain and range are particularly succinct and useful terms.}.\n\nThere are many data structures that one can use to represent functions,\nor state,\nsuch as arrays, association lists, trees, hash tables and variants of these.\nThe deciding factor of which implementation to use depends upon the stored\ndata and desired access pattern.\nMost data structures privilege value setting and getting;\naccessing and mutating the value associated with any key in the domain.\nA partition map, is a different technique,\nwhere we prioritize \\emph{merging} above other access patterns.\n\nAs a running motivating example,\nlet $D$ be the positive integers up to $100$,\nand consider the functions\n\n\\begin{minipage}{.5\\linewidth}\n\\begin{displaymath}\n  f_{1}(x) = \\left\\{\n        \\begin{array}{c c}\n          1 & x \\in [10,80] \\\\\n          0 & \\text{otherwise,} \\\\ %x \\in [1,9] \\cup [91,100] \\\\\n        \\end{array}\n     \\right.\n\\end{displaymath}\n\\end{minipage}%\n\\begin{minipage}{.5\\linewidth}\n\\begin{displaymath}\n  f_{2}(x) = \\left\\{\n        \\begin{array}{c c}\n          1 & x \\in [20,90] \\\\\n          0 & \\text{otherwise.} \\\\ %x \\in [1,9] \\cup [91,100] \\\\\n        \\end{array}\n     \\right.\n\\end{displaymath}\n\\end{minipage}\nMerging takes two functions and computes a new\none\nsuch as\n\\begin{displaymath}\n  g(x) = f_{1}(x)+f_{2}(x) = \\left\\{\n        \\begin{array}{c c}\n          0 & x \\in [1,9] \\cup [91,100] \\\\\n          1 & x \\in [10,19] \\cup [81,90] \\\\\n          2 & x \\in [20,80]. \\\\\n        \\end{array}\n     \\right.\n\\end{displaymath}\n\nThe range, $R$, is specified by each function.\nIt may vary, but for our purposes I want to emphasize that it is smaller\nthan the domain.\nLastly,\nwe are not concerned with composition,\ncases such as $g(x)=f_{j}(f_{i}(x))$.\n\nBriefly, as a point of comparison,\nconsider the storage and merging costs for various data\nstructures that could be used to model $f_{1}, f_{2}$ and then create $g$.\nAn array, where we use one array position for each element in the domain,\nwould require $O(|D|)$ storage and $O(|D|)$ evaluations for merging.\nThis is the naive case.\nWe can have similar performance using other data-structures\n(lists, trees and hash-tables) following the naive approach,\none value per domain element,\nbut with the extra overhead of pointer management.\n\nA couple of the conditions,\npresent in the example,\nshould highlight what is inefficient about the naive solution.\n%These conditions are the ones that partition maps aims to address.\n\\begin{enumerate}\n  \\item The size of the range ($R$) is much smaller than the domain ($D$).\n    For $f_{1}$ or $f_{2}$ we have 2 elements vs $100$,\n    and for $g$ the case is $3$ vs $100$.\n    The specific relation of the two values is not as important as emphasizing\n    that we want to create bounds proportional to $|R|$ as opposed to $|D|$.\n\n  \\item Traditionally,\n    when programmers are concerned with excessive or redundant evaluations,\n    they will use memoization.\n    In this case it is dubious that it will improve the situation as\n    performing the calculation\n    is so simple that it might be cheaper than looking up the result.\n    Thus, the merging operation is \\emph{simple}\\footnote{\n      These terms are unfortunately left imprecise at the moment as making\n      them precise is part of the ongoing effort.}.\n\n  \\item The merging operation is \\emph{bounded}\\footnote{Ibid.},\n    it does not grow the size of the range excessively.\n    An example of a function that grows excessively would be $h(x) = x + f_{1}$.\n    If we know that all \\emph{future} merging operations are also bounded,\n    we are even more motivated to merge in $O(|R|)$ time.\n\n  \\item The domain is fixed.\n    We know the full state for which we want to keep track of values and it\n    does not change.\n    Many algorithms that we might use instead assume,\n    \\emph{a priori} that the user does not know the full domain,\n    consequently concerning themselves with how it might grow or shrink.\n\n\\end{enumerate}\n\nUsually,\nwe think about such problems by allocating space sufficient for our domain\nand then operate on each element therein.\nBut if we know that the range is much smaller,\nit will not grow much in size,\nand the domain is known ahead of time,\ncan we do better?\nSpecifically,\ncan we operate over the range elements,\nand add extra bookkeeping operations to track the domain elements,\nthat will make the resulting code faster?\n\nFor each function that we specify,\nworking backwards,\nthe values in the range specify a partition of the domain.\nFor example,\nfor $g$, $S_{0} = [1,9]\\cup [91,100], S_{1} = [10,19] \\cup [81,90], S_{2} = [20,80]$\nand $S_{0} \\cup S_{1} \\cup S_{2} = D = [1,100]$.\nI will refer to this as the partition \\emph{implied} by a function.\n\nFor the functional language enthusiast, the \\emph{merge} that I\ndescribe is commonly thought of as a \\emph{map2}; a higher order function that\ntakes another function $m$ that is applied to each element of two other\nstructures,\nwhere the arguments to $m$,\nare chosen based on the internals of the data structures.\nI eschew that name to emphasize that something different,\nsomething dependent on the domain elements,\nwill occur when we merge.\nMoreover, \\emph{map} will have a slightly different interpretation.\nWhen we \\emph{map},\nwe consider all of the unique elements of the range and\napply a function to each of these values,\nwith two caveats: the transform does not take a domain element as an\nargument and we store only the unique elements of the resulting range.\nSimilarly, when we merge we will again ignore the domain elements when computing\nthe new value,\nkeep track of only the unique resulting values,\nbut also take elements from the two ranges such that their respective domain sets\nhave an intersection.\n\n\\section{Example applications}\n\nIt is important to stress that these conditions are unique to the problem that\nI encountered and may not be present in other scenarios.\nTo give more motivation for this method it might be worthwhile to consider\npotential applications.\n\n\\subsection{Histograms}\n\nThe functions that I used as my motivating examples might seem like toy\nexamples without actual use.\nIn practice,\nfunctions that are only a little bit more complicated,\ncan arise when a user wants to track an empirical distribution with a histogram.\nOr even simpler uses such as frequency tables.\nOne of the most common first steps in the construction of such tables is to\ndecide the number of classes or bins;\nhow to partition the domain.\nWhat if that was a question that was largely determined empirically?\n\nThis approach could have positive benefits in systems that want to integrate\nstatistics from different observations, via such histograms.\nDistributed systems come to mind.\nFor example, different routers might keep a map of packet size to latency\n(or other metric).\nBut the domain space,\npacket size,\ncould have a clustering effect\nwhere packets that have nearly the same size\n(eg. 100 or 105 bytes),\nhave the same outcome.\nOr a large threshold effect,\nif a packet is larger than 1kb then it's metric is twice the value of\nthose below.\nIn both cases,\na partition map would provide a sparser representation,\nand potentially simpler merging logic for aggregating algorithms.\n\n\\subsection{Columnar Store}\n\nAs another example consider merging columns of discrete values,\nin a table,\nsuch as a credit calculation.\nThere are several columns all indexed by the same primary key UserId.\n\\begin{center}\n\\begin{tabular}{|r|l|l|l|l|}\n\\hline\n  UserId & Education   & Income Bracket & Age Group & Credit \\\\\n\\hline\n  1      & High School & $<10k$       & $< 20$  & Bad    \\\\\n  2      & High School & $<10k$       & $< 20$  & Bad    \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  103    & High School & $<10k$       & 20-30   & Bad    \\\\\n  104    & High School & $<10k$       & 20-30   & Bad    \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  206    & High School & $10k-50k$    & 20-30   & Bad    \\\\\n  %\\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  %706    & Bachelors   & $<10k$       & 20-30   & Bad    \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  1506   & Bachelors   & $50k-100k$   & 20-30   & Ok     \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  %6506   & Bachelors   & $>100k$      & 30-40   & Ok \\\\\n  %\\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  11986  & Bachelors   & $>200k$      & 30-40   & Good \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  252321 & Doctorate   & $50k-100k$   & 20-30   & Ok \\\\\n  \\ldots & \\ldots      & \\dots        & \\ldots  & \\ldots \\\\\n  \\hline\n\\end{tabular}\n\\end{center}\nIn this example, all of the inputs to our merge function\n(eg. Education can be one of ``High School'', ``Bachelors''\nor ``Doctorate'').\nand the output (Credit can be either Good, Medium or Bad)\nare discrete.\nIf the individual datums are stored independently (eg. we have not\nalready allocated the full table to store the data and result) a\npartition map approach might be warranted.\n\n\\subsection{Original motivation}\n\nMy objective,\nwhen developing partition maps,\nwas to compute a likelihood function,\na probability for a large set of genetic variants.\nThe likelihood function was computed via a sequence of multiple recursions,\nin a dynamic programming approach.\n\n\\begin{align}\n  M_{lkn} &= e_{lkn}(t_{MM}M_{l-1,k,n} + t_{IM}I_{l-1,k,n} + t_{DM}D_{l-1,k,n})\n  \\nonumber \\\\\n  I_{lkn} &= \\frac{1}{4}(t_{MI}M_{l-1,k,n} + t_{II}I_{l-1,k,n}) \\nonumber \\\\\n  D_{lkn} &= t_{MD}M_{l,k,n} + t_{DD}D_{l,k,n} \\nonumber\n\\end{align}\n\nThe genetic variants (the state/domain space indexed by $n$),\nwere similar in many instances and the functions were\nbounded by their numerical accuracy.\nThe calculations were also simple,\na cross product of probabilities ($M, I, D$) and weights ($t_{MM}, t_{IM}, t_{DM} \\ldots$).\nThe application had to perform this calculation several million times\nper sample.\nThis was a big computational bottleneck\nand performing this computation via partition maps\nreduced the running time to less than 5\\% of the naive approach.\n\n\n\\section{Related approaches}\n\nBefore describing the implementation it would be helpful to quickly survey the\nliterature of related data structures;\nto contrast how they do not meet the requirements and\nfor inspiration.\nThe common refrain is that they will make an undesired trade-off,\nwhere they favor look-ups versus merging.\n\n\\subsection{Bidirectional maps}\n\nA bidirectional map\\footnote{\\url{https://en.wikipedia.org/wiki/Bidirectional_map}},\ncan be thought of as set whose elements are pairs that represent the association,\ncoupled with lookup and alteration methods so that the set (maps) is (are) preserved\nregardless of which side is used as a key.\nFor our purposes, naively, they would require storing an element of the domain.\nNon-naively, if one side was to represent a set of the implied partition,\nwe are still willing to discard the convenience of look-ups for fast merges.\n\n\\subsection{Fast Mergeable Integer Maps}\n\nOkasaki's classic description\\cite{Okasaki1998} of Patricia trees highlights how\nwe can maximize the information contained within keys to build efficient data\nstructures.\nUnfortunately, for our purposes, this technique has a slightly different\ninterpretation of \\emph{merging},\ncombining disparate sets of keys and values that preserve fast lookup.\nWe intent to merge two cases where values for all the keys are already known.\n\nOne could imagine mapping every set within a partition to a unique, large,\ninteger by representing it as a bit vector (a bit per element), and then\nutilizing Patricia tree's as described in this work.\nThe large key sizes ($O(|D|)$ bits),\npose a substantial problem as the bit-twiddling necessary for look-ups is\nlimited to a programs word size which might be a relatively small portion\nof $|D|$.\nFurthermore, the original fast lookup guarantees provided by the integers are\nnow swamped by this bigger size.\nLastly, this method, like the others described, does not utilize our previous\nknowledge of a fixed domain.\n\nOne potential way to rescue this work would be an effective,\npossibly probabilistic,\nhash of sets in a partition to integers.\n\n\\subsection{DIET}\n\nDiscrete Interval Encoding Trees\\cite{Erwig1993},\ndescribe an efficient representation for sets of types that are easily\ntransformed into integers.\nThe use of intervals to represent sets is an affirmation of my approach.\nSadly, it is far from straightforward to figure out how to adapt these\nsets to represent maps,\nthey will break the adjacency of nearby intervals.\nFinally,\nwhile traversing the leaf nodes of a tree is not difficult,\nconstructing trees in that order can lead to pathological cases.\nAt the end of the day,\nI am not certain that trees provide the right storage organization for our use\ncase.\n\n\\subsection{Mergeable Interval Map}\n\nThe Mergeable Interval Map\\cite{Bonichon2010} cleverly extends Okasaki's\ntechnique to ranges of integers, in the style of DIETs.\nThis work is probably closest in spirit to the\ndata structure that I intent to describe but the focus on retrieval,\neven if optimized for arbitrary intervals,\nis not the trade-off that I seek.\n\n\\section{A non-naive implementation}\n\nA non-naive solution seeks smaller costs than one value per domain element.\nArrays are not amenable to such approaches\nbecause the association between domain and range is implicit;\neach position in the array is associated with an element from the domain\nbased on some enumeration.\nWhat is stored in each position is then the appropriate element in the range.\n\nAn association list is a linked list where each node contains a key and a value.\nThey allow us $O(|R|)$ storage since we can store just one value per node.\nThe problem then turns into how to represent and order the keys,\nthe sets of a partition of $D$ implied by $f$.\nFor the moment,\nlet us assume that we have such a representation,\n$S_{i}$, and order.\nFor $f_{1}$, $S_{1} = [10,80]$ and $S_{2} = [1,9]\\cup[81,100]$.\nThere is a simple algorithm (Alg.\\ref{Alm1}) to merge two association lists.\nTraverse both lists looking for intersections between the sets.\nIf an intersection between the keys exists,\nmerge the two values and then insert that,\nkeyed by the intersection,\ninto an association list accumulator.\n\n\\begin{algorithm}[H]\n  \\SetKwProg{Fn}{Function}{\\string:}{}\n  \\newcommand{\\forcond}{$i=0$ \\KwTo $n$}\n  \\SetKwFunction{Merge}{Merge1}%\n  \\SetKwFunction{Insert}{InsertIntoList}%\n  \\DontPrintSemicolon\n  \\Fn(){\\Merge{$L_{1}, L_{2}, f$}}{\n    \\KwData{Two association lists, $L_{1}, L_{2}$, and the merge function, $f$.}\n    \\KwResult{$L$ merged association list.}\n    % Unlike square brackets this looks fine without an extra space.\n    $L \\leftarrow \\{\\} $\\;\n    \\ForEach{$S_{1},v_{1} \\in L_{1}$}{\n      $R \\leftarrow S_{1}$\\tcp*[r]{Remaining}\n      \\ForEach{$S_{2},v_{2} \\in L2$ \\textup{and} $R \\neq \\emptyset$}{\n        \\lnlset{inter}{inter}$I \\leftarrow R \\cap S_{2}$\\;\n        \\lnlset{diff}{diff}$R \\leftarrow R \\backslash S_{2}$\\;\n        \\uIf{$I \\neq \\emptyset$}{\n          \\Insert{$I,v,L$}\\;\n        }\n      }\n    }\n    Sort $L$ by keys, the sets\n    \\Return{$L$}\n  }\n  \\Fn(){\\Insert{$I, v, L$}}{\n    \\KwData{A set $I$, the key of value $v$ and $L$, a list to insert into.}\n    \\KwResult{Modifies $L$, the lead pointer does not change.}\n    \\ForEach{$S_{i},v_{i} \\in L$}{\n      \\uIf{$v_{i} = v$}{\n        $S_{i} \\leftarrow S_{i} \\cup I$\\tcp*[r]{Modify the set}\n        \\Return\n      }\n    }\n    Append $(I,v)$ to end of $L$.\\;\n  }\n\\caption{Merging Two Association Lists.\\label{Alm1}}\n\\end{algorithm}\n\nThe rub is in how we insert the new keyed value into the accumulator.\nOne sensible strategy would be to prepend (cons) each set-value pair to the\nfront of the accumulator after we find an intersection.\nWhile this is the fastest approach it does not bind the growth of the\nassociation list.\nIn order to enforce that the association list contains only unique values\nwe have to traverse the entire accumulator.\nIf $L_{1}$ and $L_{2}$ have $m, n$ elements respectively,\nand consider the worst case that the function creates no duplicate values,\nthis leads to a pretty disappointing $O(n^{2}m^{2})$ running time.\nThis running time also excludes the set intersection and difference\noperations (labeled lines \\ref{inter} and \\ref{diff} in the algorithm),\nas if they were not expensive.\n\nBut they are expensive.\nOne initially suitable approach to representing the $S_{i}$ would be\nto use a bit vector.\nThis is a common, well understood, data-structure,\nespecially as the algorithms to compute set intersection and difference require\nsimple bitwise logic operators.\nThe problem is that this bit vector would still require $|D|$ bits,\nand $O(|D|)$ operations.\n\nThe solution that I propose is to use pairs to represent the sequential,\ninclusive intervals that cover each $S_{i}$ stored in \\emph{ascending} order.\nThe intervals partition the set $[1,|D|]$,\nrepresenting the domain,\nusing the same representation as the one if storing $D$ in an array.\n\nFor example\\footnote{I am using square brackets ([]) to denote\nintervals (and pairs) and curly brackets (\\{\\}) to denote lists.\nThis is counter to many common functional programming languages,\nbut it reinforces the mathematical notation.\nUsing parentheses for intervals would be confusing as I explicitly want to\nuse inclusive intervals.},\nfor $f_{1}$, $S_{0} = \\{[1,9],[81,100]\\}$ and $S_{1} = \\{[10,80]\\}$\nand for $g$, $S_{0} = \\{[1,9], [91,100]\\}$,\n$S_{1} = \\{ [10,19], [81,90]\\}$,\nand $S_{2} = \\{[20,80] \\}$\nThis approaches main advantage is that it allows us to escape from $O(|D|)$\nas each $S_{i}$ is bounded by $|R|$.\n\nUsing intervals has other advantages over bit vectors.\nComputing the intersection and difference requires a straight-forward\nbut large case analysis of the ways that two intervals can\nintersect (Algorithm \\ref{Alm2}),\nthat needs simple integer comparison.\nBecause our key elements are discrete we know our borders exactly.\n\n\\begin{algorithm}[H]\n  \\DontPrintSemicolon\n  \\SetKwProg{Fn}{Function}{\\string:}{}\n  \\newcommand{\\forcond}{$i=0$ \\KwTo $n$}\n  \\SetKwFunction{Iiad}{IntervalIntersectionDifference}\n  \\Fn(){\\Iiad{$I_{1}, I_{2}$}}{\n    \\KwData{Two intervals $I_{1} = [s_{1},e_{1}]$ and $I_{2}=[s_{2},e_{2}]$\n      of non-negative integers that are non-empty,\n      $s_{1} \\leq e_{1}$ and\n      $s_{2} \\leq e_{2}$.}\n    \\KwResult{A quintuple of potentially empty ($\\esb$)\n      intervals: the intersection,\n      the part of $I_{1}$ that come before the intersection\\footnote{Even though\n      the intersection may be empty (such as the first case) $I_{1}$ or $I_{2}$\n      may still be before it in the sense that they are before the midpoint.\n      The same interpretation applies to the parts that come after an\n      intersection (such as the last case).},\n      the part of $I_{2}$ that come before the intersection,\n      the part of $I_{1}$ that come after the intersection,\n      and the part of $I_{2}$ that come after the intersection.\n      }\n      \\uIf{$s_{2} < s_{1}$}{\n        \\uIf{$e_{2} < s_{1}$}{\n          \\Return $\\esb,\\esb,I_{2},I_{1},\\esb$\n        }\\uElseIf{$e_{2} < e_{1}$}{\n          \\Return $[s_{1}, e_{2}],\\esb,[s_{2},s_{1} - 1], [e_{2} + 1, e_{1}], \\esb$\n        }\\uElseIf{$e_{2} = e_{1}$}{\n          \\Return $I_{1},\\esb, [s_{2}, s_{1} - 1], \\esb,\\esb$\n        }\\uElse(\\tcp*[h]{$e_{2} > e_{1}$}){\n          \\Return $I_{1}, \\esb, [s_{2}, s_{1} - 1],\\esb, [e_{1} + 1, e_{2}]$\n        }\n      }\n      \\uElseIf(\\,\\tcp*[h]{$e_{2} \\geq s_{1}$}){$s_{2} = s_{1}$}{\n        \\uIf{$e_{2} < e_{1}$}{\n          \\Return $[s_{1}, e_{2}], \\esb,\\esb, [e_{2} + 1, e_{1}],\\esb$\n        }\\uElseIf{$e_{2} = e_{1}$}{\n          \\Return $ I_{1},\\esb,\\esb,\\esb,\\esb$\n        }\\uElse(\\tcp*[h]{$e_{2} > e_{1}$}){\n          \\Return $I_{1},\\esb,\\esb,\\esb,[e_{1} + 1, e_{2}]$\n        }\n      }\n      \\uElseIf(\\,\\tcp*[h]{$e_{2} > s_{1}$}){$s_{1} < s_{2}$ \\textup{and} $s_{2} < e_{1}$}{\n        \\uIf{$e_{2} < e_{1}$}{\n          \\Return $I_{2},[s_{1}, s_{2}-1],\\esb,[e_{2}+1, e_{1}],\\esb$\n        }\\uElseIf{$e_{2} = e_{1}$}{\n          \\Return $I_{2}, [s_{1}, s_{2}-1],\\esb,\\esb,\\esb$\n        }\\uElse($ e_{2} > e_{1} $){\n          \\Return $[s_{2}, e_{1}], [s_{1}, s_{2}-1],\\esb,\\esb, [e_{1} + 1, e_{2}]$\n        }\n      }\n      \\uElseIf(\\,\\tcp*[h]{$ e_{2} \\geq e_{1}$}){$e_{1} = s_{2}$}{\n        \\uIf{$e_{2} = e_{1}$}{\n          \\Return $I_{2}, [s_{1}, s_{2} - 1], \\esb,\\esb,\\esb$\n        } \\uElse(\\tcp*[h]{$e_{2} > e_{1}$}){\n          \\Return $[s_{2}, e_{1}], [s_{1}, s_{2} - 1], \\esb,\\esb,[e_{1} + 1, e_{2}]$\n        }\n      }\n      \\uElse(\\tcp*[h]{$e_{1} < s_{2}$}){\n        \\Return $\\esb,I_{1},\\esb,\\esb,I_{2}$\n      }\n\n  }\n\\caption{Interval Intersection and Difference.\\label{Alm2}}\n\\end{algorithm}\n\n% Reconsider this page break if we can have a nicer position for the algorithm\n\\pagebreak\n\nThe interval intersection-difference operation is then coupled with a fold\nover the two lists that contain the entire set.\n\n\\begin{algorithm}[H]\n  \\SetKwProg{Fn}{Function}{\\string:}{}\n  \\newcommand{\\forcond}{$i=0$ \\KwTo $n$}\n  \\SetKwFunction{Iad}{IntersectionAndDifference}%\n  \\SetKwFunction{Iiad}{IntervalIntersectionDifference}%\n  \\DontPrintSemicolon\n  \\Fn(){\\Iad{$S_{1}, S_{2}$}}{\n    \\KwData{Two lists of \\emph{ascending} intervals $S_{1}, S_{2}$.}\n    \\KwResult{A list of intersecting interval $S_{i}$, and two lists of the\n      set differences for each input lists $S_{d1}\n      %(\\forall x \\in S_{1} \\wedge \\notin S_{2})\n      , S_{d2}$.}\n    $S_{i} \\leftarrow \\{ \\} $\\;\n    $S_{d1} \\leftarrow \\{ \\} $\\;\n    $S_{d2} \\leftarrow \\{ \\} $\\;\n    \\While{$S_{1} \\neq \\{ \\}$ \\textup{and} $S_{2} \\neq \\{ \\} $}{\n      $I_{1} \\leftarrow $ pop first element of $S_{1}$\\;\n      $I_{2} \\leftarrow $ pop first element of $S_{2}$\\;\n      $I, B_{1}, B_{2}, A_{1}, A_{2} \\leftarrow$ \\Iiad{$I_{1}, I_{2}$}\\;\n      \\lIf{$I \\neq \\esb$}{ Append $I$ to end of $S_{i}$}\n      \\lIf{$B_{1} \\neq \\esb$}{ Append $B_{1}$ to end of $S_{d1}$}\n      \\lIf{$B_{2} \\neq \\esb$}{ Append $B_{2}$ to end of $S_{d2}$}\n      \\lIf{$A_{1} \\neq \\esb$}{ Prepend $A_{1}$ to front of $S_{1}$}\n      \\lIf{$A_{2} \\neq \\esb$}{ Prepend $A_{2}$ to front of $S_{2}$}\n    }\n    \\lIf{$S_{1} \\neq \\{ \\}$}{Append $S_{1}$ to end of $S_{d1}$}\n    \\lIf{$S_{2} \\neq \\{ \\}$}{Append $S_{2}$ to end of $S_{d2}$}\n    \\Return $S_{i}, S_{d1}, S_{d2}$\n  }\n\\caption{Set Intersection and Difference.\\label{Alm3}}\n\\end{algorithm}\n\nUnfortunately,\nI do not have way to think about the running time of Algorithm \\ref{Alm3}\nthat is satisfactory.\nOn the one hand,\nwe can think about about the running time in terms of the lengths of the\ninterval lists.\nIn this case,\nit easy to construct pathological cases that have running time\n$O(|S_{1}||S_{2}|)$\nsuch as\n$S_{1} = \\{[1,1],[3,3],\\ldots\\}$ and $S_{2}=\\{[2,2],[4,4],\\ldots\\}$.\nOn the other hand,\none can think about the size of $D$ that is represented by each $S_{i}$,\nin this case,\nthe performance of the algorithm would depend upon the implied partitions.\nIn other words, it would be highly domain dependent.\n\nIn practice this algorithm may be sufficient and has an advantage\nover using bit vectors.\nSince the intervals are ascending,\nevery call to\n\\emph{IntervalIntersectionDifference}\nthe size of $S_{1}$ and $S_{2}$ (which could represent $|D|$),\nshrinks by either $I,B_{1},$ or $B_{2}$.\nWhich, if one considers the first three return\nvalues in Algorithm \\ref{Alm2},\nalways contains one non empty interval.\n\nWith this representation of sets it is easier to build a more efficient\nalgorithm to merge two association lists.\nIn this case we will,\nonce again,\nadd the constraints that the sets are ascending.\nSince our set representation consists of a list of intervals,\nby ascending,\nwe mean that the lowest element, of the lowest interval,\nof each set\nare ascending.\nTherefore we would represent $f_{1}$ as\n$\\{ \\{[1,9],[81,100]\\} \\rightarrow 0,\n\\{[10,80]\\} \\rightarrow 1 \\}$\nand $g = \\{\\{[1,9], [91,100]\\} \\rightarrow 0,\n\\{ [10,19], [81,90]\\} \\rightarrow 1,\n\\{[20,80] \\} \\rightarrow 2 \\}$.\n\n\\begin{algorithm}[H]\n  \\SetKwProg{Fn}{Function}{\\string:}{}\n  \\newcommand{\\forcond}{$i=0$ \\KwTo $n$}\n  \\SetKwFunction{Merge}{Merge2}%\n  \\SetKwFunction{Moate}{MergeOrAddToEnd}%\n  \\SetKwFunction{Iad}{IntersectionAndDifference}%\n  \\SetKwFunction{Insert}{InsertIntoAscending}%\n  \\DontPrintSemicolon\n  \\Fn(){\\Merge{$L_{1}, L_{2}, f$}}{\n    \\KwData{Two association lists, $L_{1}, L_{2}$, and the merge function, $f$.\n      The association lists consist of lists of intervals,\n      sets ($S_{i}$),\n      as the keys and arbitrary values.}\n    \\KwResult{$L$ merged association list.}\n    % Unlike square brackets this looks fine without an extra space.\n    $L \\leftarrow \\{\\} $\\;\n\n    \\While{$L_{1} \\neq \\{ \\}$ \\textup{and} $L_{2} \\neq \\{ \\} $}{\n      $S_{1}, v_{1} \\leftarrow $ pop first element of $L_{1}$\\;\n      $S_{2}, v_{2} \\leftarrow $ pop first element of $L_{2}$\\;\n      $S_{i}, S_{d1}, S_{d2} \\leftarrow$ \\Iad{$S_{1}, S_{2}$}\\;\n      $v_{n} \\leftarrow f(v_{1}, v_{2})$\\;\n      \\Moate{$S_{i}, v_{n}, L$}\\;\n      \\lIf{$S_{d1} \\neq \\{\\}$}{ \\Insert{$S_{d1},v_{1}$,$L_{1}$}}\n      \\lIf{$S_{d2} \\neq \\{\\}$}{ \\Insert{$S_{d2},v_{2}$,$L_{2}$}}\n    }\n    \\Return{$L$}\n  }\n  \\Fn(){\\Moate{$S,v,L$}}{\n    \\KwData{A set $S$, value $v$ and an association list $L$.}\n    \\KwResult{Modifies $L$, the lead pointer is unchanged.}\n    \\ForEach{$S_{i},v_{i} \\in L$}{\n      \\uIf{$v_{i} = v$}{\n        Traverse the interval lists $S_{i}$ and $S$, ordering and merging intervals.\\;\n        \\Return\n      }\n    }\n    Append $(I,v)$ to end of $L$.\\;\n  }\n  \\Fn(){\\Insert{$S,v,L$}}{\n    \\KwData{A set $S$, value $v$ and an association list $L$. Assume that $v$ does not equal any value in $L$.}\n    \\KwResult{Returns $L$.}\n    \\ForEach{$S_{i},v_{i} \\in L$}{\n      \\uIf{$S < S_{i}$ \\textup{and} $i=0$}{\n        Insert $(S,v)$ before $(S_{i},v_{i})$ and \\Return{pointer to $(S,v)$}\\;\n      } \\uElseIf{$S < S_{i}$}{\n        Insert $(S,v)$ before $(S_{i},v_{i})$ and \\Return{L}\\;\n      }\n    }\n    Append $(I,v)$ to end of $L$ and \\Return{L}.\\;\n  }\n\n\\caption{Merging Two Association Lists.\\label{Alm4}}\n\\end{algorithm}\n\nIn this version, \\emph{MergeOrAddToEnd} must maintain the property that the\nsets store their intervals in ascending order.\nThis requires walking two ascending lists of intervals,\ntalking the lower element and merging if the intervals are adjacent\n(eg. $s_{i} = e_{j}$).\nSimilarly, \\emph{InsertIntoAscending} is important to make sure that each\ncall to \\emph{IntersectionAndDifference} is aligned;\nthe start of the lowest intervals in $S_{1}$ and $S_{2}$ are equal.\nThis is the invariant that allows us to avoid nested loops over the two lists\nand process them in tandem instead.\n\nThe ascending property of the sets guarantees that the call to\n\\emph{IntersectionAndDifference} always returns a non-empty intersection.\nIn the pathological cases we can construct partitions so that\nneither $S_{d1}$ nor $S_{d2}$ are empty,\nconsequently there are at most $mn$ calls to $f$.\nFurthermore,\nin the pathological case where each call to $f$ generates a unique value,\nwe will continue to walk an increasingly longer list with every call to\n\\emph{MergeOrAddToEnd},\nrecreating the $O(m^{2}n^{2})$ running time of Algorithm \\ref{Alm1}.\n\nAre the faster set intersection and difference calculations,\nwhich should not be understated,\nthe only benefit?\nConsider the running time of the ideal case,\nwhere we merge two lists with identical partitioning.\nIt is easy to see that in this case,\nAlgorithm \\ref{Alm1},\nstill checks for intersections $m^{2}$ times,\nwhile Algorithm \\ref{Alm4} only $m$ times.\nA final appeal of this approach is that it feels pretty natural,\nit is how I think most human ``computers'' would solve this problem.\n\nThere are many aspects that affect Algorithm \\ref{Alm4}'s running time besides\nthe number of calls to $f$.\nFor example\nwith this approach,\nas opposed to the first approach with bit vectors,\nhow we order the domain matters in terms of computational speed.\nIt is important to avoid potentially pathological cases that might\npartition the domain, such as the even and odds example.\nWe want our domain to have clusters of value,\nso that they represent big intervals.\nIf we revisit the merging columns example,\nwe want to know that successive rows will have the same values for\nmultiple attributes.\n\nAnother practical aspect are the allocations necessary to support this\nalgorithm.\nIn the naive case we can explicitly define the space necessary by the size\nof $D$ and the number of merges that we may perform.\nIn this case we are repeatedly allocating lists of pairs of integers to keep\ntrack of the partitions.\n\nAt the moment, the only convincing way to think about Algorithm \\ref{Alm4} as\nopposed to using arrays to store data is to benchmark.\nThis is constructive as it demonstrates how many different trade-offs a\ndeveloper has to take into account.\n\n\n\\section{Implementation, Benchmarks and Details}\n\nA standalone library implementing partition maps in OCaml\\cite{ocaml-manual}\nis available at \\url{https://github.com/rleonid/partition_map}.\nThe library also contains benchmarking applications to allow an interested\nprogrammer to see if partition maps are a good fit for a computation.\n\n\\subsection{Benchmarks}\n\nTo analyze the performance of Algorithm \\ref{Alm4} versus a naive solution\nusing arrays,\nI created a hypothetical scenario where we merge functions\nsimilar to $f_{1}$ and $f_{2}$ that we defined previously.\nFor the benchmarks we test domain sizes of 100, 500, 1000 and 5000.\n%In the naive case we allocate arrys of integers of those sizes and for\n%partition maps we construct partition maps for their representation.\nFor the first two domain sizes we tested merging 100, 500, 1000 and 5000\nstates/functions and for the last two domain sizes we also tested merging\n250, 750 and 2500 states.\n\nTo constrain the size of the range for each state I choose the number of\nunique values $v$, from a Poisson distribution ($\\lambda=1.5$\n)\\footnote{\nTechnically,\nI drew the number of values greater than or equal to 1 from a Poisson,\nsince one could sample 0 from a Poisson distribution,\nwhich would not make sense.\nI chose the Poisson distribution because it provides a simple way to\ndraw a small integer and this procedure in aggregate generates simple functions\nlike $f_{1}$, $f_{2}$ and $g$.\nOne can interpret this to mean that on average there will be $2.5$ values\nper domain.\nI could have used a more complicated form for function generation but I\nthought that would further obscure the benchmark.}.\nAfterwards, I again sample from a Poisson distribution ($\\lambda=2.5$) to\ndetermine the number of intervals, $i$.\nFinally, I assign the values in $[1,v]$ to the $i$ intervals by randomly\nchoosing a starting value in $[1,v]$\nsequentially (wrapping back to $1$ after $v$)\nassigning values.\nFor example,\nfor a domain size of 1000 some sample functions (represented as partition maps)\nare:\n$\\{\\{[1,496]\\}\\rightarrow0, \\{[497,745]\\} \\rightarrow 1, \\{[746,1000]\\} \\rightarrow 2\\}$,\n$\\{\\{[1,886],[937,978]\\}\\rightarrow 1 \\{[887,936],[979,1000]\\} \\rightarrow 0 \\}$,\nand\n$\\{\\{[1,481],[538,987]\\}\\rightarrow 0, \\{[482,537],[988,1000]\\}\\rightarrow 1\\}$.\nThe merging operation consists of adding the two states,\nfor the above three we get:\n$\\{ \\{[1,481]\\}\\rightarrow1,\n    \\{[482,496],[538,745],[887,936],[979,987]\\}\\rightarrow2,\n    \\{[497,537],[746,886],[937,978],[988,1000]\\}\\rightarrow3 \\}$.\nWe do not time the allocation, calculation or deallocation of the\nintermediate states.\nLastly,\nthe times are normalized so that 100 merges of an array of size 100, takes time 1.\n\n\n\\begin{figure}[!ht]\n  \\caption{Comparing Arrays vs Partition Map, $E[|R|] = 2.5$.}\n\\begin{adjustwidth}{-0.5in}{}\n\\begin{center}\n\\begin{tabular}{rl}\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                    ylabel=Time\n                  , title={Domain Size = 100}\n                  , width=7cm\n                  , height=7cm\n                  , ymin=0.5\n                  , ymax=1e5\n                  %, ytick={0,1,10,100,1000,10000}\n                  , xtick=data\n                  , xticklabels={100,500,1000, 5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 1.00)\n  (500, 5.00)\n  (1000, 9.96)\n  (5000, 51.84)\n};\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 4.51)\n  (500, 43.95)\n  (1000, 104.99)\n  (5000, 803.01)\n};\n\\legend{Array, Partition Map}\n\\end{loglogaxis}\n\\end{tikzpicture}\n&\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                  %, ylabel=Time\n                    title={Domain Size = 500}\n                  , width=7cm\n                  , height=7cm\n                  , ymin=0.5\n                  , ymax=1e5\n                  %, ytick={0,1,10,100,1000,10000}\n                  , xtick=data\n                  , xticklabels={100,500,1000, 5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 4.91)\n  (500, 24.48)\n  (1000, 49.83)\n  (5000, 252.94)\n};\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 6.13)\n  (500, 102.19)\n  (1000, 309.29)\n  (5000, 4157.19)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n\\\\ %\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                    ylabel=Time\n                  , title={Domain Size = 1000}\n                  , width=7cm\n                  , height=7cm\n                  , ymin=0.5\n                  , ymax=1e5\n                  , xtick=data\n                  , xticklabels={100,,500,,1000,2500,5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100,\t9.94)\n  (250,\t24.43)\n  (500,\t46.49)\n  (750,\t70.56)\n  (1000, 93.67)\n  (2500, 233.43)\n  (5000, 464.53)\n};\n\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 9.46)\n  (250, 33.31)\n  (500, 115.74)\n  (750, 208.37)\n  (1000, 436.95)\n  (2500, 2362.05)\n  (5000, 6484.38)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n&\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                  %, ylabel=Time\n                    title={Domain Size = 5000}\n                  , width=7cm\n                  , height=7cm\n                  , ymin=0.5\n                  , ymax=1e5\n                  , xtick=data\n                  , xticklabels={100,,500,,1000,2500,5000}\n                  , xticklabel style={anchor=north,font=\\small}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100,\t46.90)\n  (250,\t115.44)\n  (500,\t233.01)\n  (750,\t347.75)\n  (1000,\t460.53)\n  (2500,\t1152.19)\n  (5000,\t2303.18)\n};\n\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 5.29)\n  (250, 38.36)\n  (500, 129.29)\n  (750, 365.72)\n  (1000, 566.07)\n  (2500, 4009.40)\n  (5000, 16318.09)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n\n\\end{tabular}\n\\end{center}\n\\end{adjustwidth}\n\\end{figure}\n\nThe immediate take away is that in only a limited set of scenarios do\npartition maps outperform the naive approach.\nBut there are a couple points to consider.\nFirst, the array sizes that we are comparing against are relatively small\nand in all cases the entire data set, including the domains to merge,\ncan fit onto a CPU-cache.\nTherefore determining the two values to add is pretty fast and difficult for\npartition maps to compete against.\n\nSecond,\nnotice that for a given domain size,\nthe time increases proportional to the number of merges, as expected.\nBut the time also increases as the domain increase: the curve rises.\nPartition maps do not exhibit the same behavior,\nrather their curve tilts!\nConsequently, for a small number of merges partition maps will be faster\nthan arrays.\n\nRegardless,\nthe reader is probably disappointed;\nshe was promised an interesting data-structure but in only a limited\ncase does it actually prove to be useful.\nFortunately, not everything is lost.\nHere is another benchmark where we lower the expected size of the range\nto 1.5.\nThe take-away message is that the complexity of the computation matters;\nif it is simple, then partition maps can help.\n\n\\begin{figure}[!ht]\n  \\caption{Comparing Arrays vs Partition Map, $E[|R|] = 1.5$.}\n\\begin{adjustwidth}{-0.5in}{}\n\\begin{center}\n\\begin{tabular}{rl}\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                    ylabel=Time\n                  , width=7cm\n                  , height=7cm\n                  , title={Domain Size = 100}\n                  , ymin=0.1\n                  , ymax=1e4\n                  %, ytick={0,1,10,100,1000,10000}\n                  , xtick=data\n                  , xticklabels={100,500,1000,5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 1.000000)\n  (500, 5.301532)\n  (1000, 10.727934)\n  (5000, 54.528427)\n};\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 0.384605)\n  (500, 7.720924)\n  (1000, 21.098390)\n  (5000, 202.140966)\n};\n\\legend{Array, Partition Map}\n\\end{loglogaxis}\n\\end{tikzpicture}\n&\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                  %, ylabel=Time\n                    width=7cm\n                  , height=7cm\n                  , title={Domain Size = 500}\n                  , ymin=0.1\n                  , ymax=1e4\n                  %, ytick={0,1,10,100,1000,10000}\n                  , xtick=data\n                  , xticklabels={100,500,1000, 5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 5.169652)\n  (500, 25.593588)\n  (1000, 52.150701)\n  (5000, 263.246755)\n};\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 0.476895)\n  (500, 12.223261)\n  (1000, 39.914200)\n  (5000, 555.920561)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n\\\\ %\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                    ylabel=Time\n                  , width=7cm\n                  , height=7cm\n                  , title={Domain Size = 1000}\n                  , ymin=0.1\n                  , ymax=1e4\n                  , xtick=data\n                  , xticklabels={100,,500,,1000,,5000}\n                  , xticklabel style={anchor=north}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 13.491563)\n  (250, 26.161475)\n  (500, 51.429387)\n  (750, 78.238188)\n  (1000, 103.226765)\n  (2500, 254.535955)\n  (5000, 505.253505)\n};\n\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 0.385644)\n  (250, 2.876038)\n  (500, 14.275182)\n  (750, 23.910306)\n  (1000, 39.036604)\n  (2500, 256.074766)\n  (5000, 803.758567)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n&\n\\begin{tikzpicture}\n\\begin{loglogaxis}[% xlabel=Merges\n                  %, ylabel=Time\n                    title={Domain Size = 5000}\n                  , width=7cm\n                  , height=7cm\n                  , ymin=0.1\n                  , ymax=1e4\n                  , xtick=data\n                  , xticklabels={100,,500,,1000,,5000}\n                  , xticklabel style={anchor=north,font=\\small}\n                  ]\n\\addplot[color=red,mark=x] coordinates {\n  (100, 49.960021)\n  (250, 124.778946)\n  (500, 249.161604)\n  (750, 372.529984)\n  (1000, 493.225208)\n  (2500, 1237.998442)\n  (5000, 2472.004413)\n};\n\n\\addplot[color=blue,mark=x] coordinates {\n  (100, 0.667445)\n  (250, 2.420820)\n  (500, 11.919003)\n  (750, 29.504543)\n  (1000, 50.034917)\n  (2500, 347.868899)\n  (5000, 1419.972482)\n};\n\\end{loglogaxis}\n\\end{tikzpicture}\n\n\\end{tabular}\n\\end{center}\n\\end{adjustwidth}\n\\end{figure}\n\n\nLastly, observe that there is a slight kink in the partition maps\nperformance trend\\footnote{The reason why I included 250 and 750 merges.}.\nI am not certain of the exact cause\nas I have not figured out an adequate model of this running time.\nI think that it represents something like a phase transition;\nat some point the relationship of\nlength of the list storing the interval and values,\nversus the length of the intervals becomes more and then less\nfavorable for the operation.\nI only highlight it because I have seen this odd behavior before and to\nemphasize that a better understanding of Algorithm \\ref{Alm4} is needed.\n\n\\subsection{Details}\n\\subsubsection{Interval representation}\n\nGiven that the domain is limited.\nIt is probable that for reasonable problems,\nit is much smaller than the set of representable integers ($2^{32}$ or $2^{64}$).\nFurthermore,\none of the big practical burdens of this algorithm is the storage of the intervals\nas pairs.\nCreating a pair requires extra allocations, or a pointer to the data.\n\nOne implementation shortcut that I use is to pack the interval into one integer,\nwhere the start value occupies the upper half of the bits,\nand the end occupies the lower.\nIn the 64-bit case, store $I = [s,e]$ as  $s \\cdot 2^{32}+e$.\nAside from less allocations,\nthis also makes comparing intervals much faster\nand a better version of Algorithm \\ref{Alm2} can be implemented that\ntakes only one comparison to see if two intervals are equal.\n\n\\section{Conclusion and open questions}\n\nThis is still a work in progress,\nand I am do not think that the current method and implementation is the best\none possible.\nA big motivation for publishing and exposing this work is to gather feedback.\nI have tried my best to find connections to other approaches,\nand perhaps this technique is well understood and studied under a different name.\nI have also not been successful in providing proofs of various claims,\nnor even improve their somewhat unsatisfactory worst case\nperformance.%\\footnote{$O(m^{2}n^{2})$ can easily be worse than $O(|D|)$ especially because\n%of modern hardware configurations.}.\n\nNone-the-less, I have found this technique useful and wanted to reach out to a\nbroader community.\nI will close by describing what I see to be the interesting problems remaining.\nI have divided the problems into a practical and theoretical categories.\n\n\\subsection{Practical}\n\\subsubsection{Is there a fully implicit form of partition maps?}\n\nThe methods describe here use nested lists to represent the final association,\nand the implementation is in OCaml,\na functional garbage-collected language.\nThe cost of managing the pointers for our data-structure,\nis handled by the garbage-collector\\footnote{\n  In my use case the program spends around 25\\% of the running time in the GC.},\nand perhaps a hand-tuned solution might do better.\nBut such a solution would rely upon carefully managing space for\nthe sets of the partition and values (or pointers to them).\nThis leads to an important question of whether the entire arrangement may be\nencoded in an implicit form.\nThis approach could alleviate the current implementations cache-unfriendliness.\n\nIn our custom implementation of intervals, we encoded the start and end\nwithin a single integer because the size of the domain was much smaller\nthan what is ultimately representable by even half a 32bit word.\nBut this leaves open the question of whether we can encode even more state\ninto a given word.\n\n\\subsubsection{SIMD}\n\nIf a good implicit representation is possible where essentially arrays of\nintegers are used to represent the sets of a partition and pointers to values.\nThe operations that merge more than one partition map could be bottlenecked\nat comparing integers,\nin this case SIMD operations could be helpful.\n\nThis would be particularly useful to functions that merge more than 2\npartition maps.\n\n\\subsection{Theoretical}\n\n\\subsubsection{Define simple and bounded}\n\nThe current work leaves these terms,\nused to describe when one might use partition maps,\nloosely defined,\nand gives examples as opposed to practical guidance.\nConsequently,\nthe cost of evaluating the merge operation $f$ does not permeate\nthe run time analysis,\nof the total partition map merge.\n\n\\subsubsection{Do we have to traverse the whole accumulator?}\n\nWhat techniques can we leverage to make adding to the accumulator\nfaster than traversing the entire list.\nAt the moment we are only asking for an equality test.\nBut if we were to ask for a comparator could we use that to arrange the values,\nand the sets that they point at,\nto preserve fast merging yet provide faster ways to detect duplicate elements\nof the range and then preserve boundedness.\n\n\\subsubsection{Hashing sets within a partition?}\n\nDoes there exist a way to efficiently hash a set within a partition?\nThe current work uses an association list to store data, but being able to\nhash a set would open up the possibility of using hash table like\nor Patricia tree like data structures (as previously\ndescribed\\cite{Okasaki1998}).\nFor most purposes,\nwe can expect that $|D|<2^{64}$,\nso a 64-bit word size would be sufficient.\nBut we want two properties for this function.\nFirst, efficient computation,\nwe do not have the resources for a cryptographic secure hash,\nas we would be competing against integer comparisons.\nAnd second,\nan ability to preserve intersections and set-difference operations.\nThis last request,\nseems particularly daunting,\nso perhaps this approach is dubious.\n\n\\section{Acknowledgments}\n\nThis research was initiated and performed while the author was employed by\nMount Sinai and previously supported by the Parker Institute for Cancer\nImmunotherapy.\nThe author is indebted to helpful discussions with Sebastian Mondet.\n\n\\clearpage\n\n\\bibliographystyle{plain}\n\\bibliography{note}\n\n\\end{document}\n", "meta": {"hexsha": "9082a77e04f2651c07af5879be36a8fe299d045c", "size": 46475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "write/note.tex", "max_stars_repo_name": "rleonid/partition_map", "max_stars_repo_head_hexsha": "aec81ebfe7ffe26fbc28aad643c6c534d1aa5997", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-04-10T11:17:28.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-11T10:34:59.000Z", "max_issues_repo_path": "write/note.tex", "max_issues_repo_name": "rleonid/partition_map", "max_issues_repo_head_hexsha": "aec81ebfe7ffe26fbc28aad643c6c534d1aa5997", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "write/note.tex", "max_forks_repo_name": "rleonid/partition_map", "max_forks_repo_head_hexsha": "aec81ebfe7ffe26fbc28aad643c6c534d1aa5997", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.8152969894, "max_line_length": 111, "alphanum_fraction": 0.6826896181, "num_tokens": 13261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4499293265826503}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath,amssymb}\n\\usepackage{listings}\n\\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white\n\\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue\n\\definecolor{mylilas}{RGB}{170,55,241}\n\n\\begin{document}\n\n\\title{Exercice 1 - Simplex implementation}\n\\author{Gleisson de Assis}\n\\maketitle{}\n\n\\lstset{language=Matlab,%\n    %basicstyle=\\color{red},\n    breaklines=true,%\n    morekeywords={matlab2tikz},\n    keywordstyle=\\color{blue},%\n    morekeywords=[2]{1}, keywordstyle=[2]{\\color{black}},\n    identifierstyle=\\color{black},%\n    stringstyle=\\color{mylilas},\n    commentstyle=\\color{mygreen},%\n    showstringspaces=false,%without this there will be a symbol in the places where there is a space\n    numbers=left,%\n    numberstyle={\\tiny \\color{black}},% size of the numbers\n    numbersep=9pt, % this defines how far the numbers are from the text\n    %emph=[1]{for,end,break},emphstyle=[1]\\color{red}, %some words to emphasise\n    %emph=[2]{word1,word2}, emphstyle=[2]{style},\n}\n\n\\section{Introduction}\nThis work solves the following problem:\n\n\\begin{equation*}\n\\begin{array}{ll@{}ll}\n\\text{minimize}  & z = 2x_{1} - 10x_{2} + x_{3} + 4x_{4} &\\\\\n\\text{subject to}& 3x_{1} + 6x_{2}  3x_{4} \\leq 100\\\\\n                 & 10_{4} + x_{2} + 6x_{3} \\geq 50\\\\\n                 & -3x_{1} + x_{2} + 6x_{3} \\geq 30\\\\\n                 & x \\geq 0\n\\end{array}\n\\end{equation*}\n\n\\subsection{How it works}\nThis problem is solved by running simplex2 implementation without specifying a\nfeasible base. The function simplex2 calls simplex1 in order to find a feasible base,\nafter that using the found base the function is called again solving\nproblem.\n\n\\subsection{Results}\n\nThe optimum result for this problem is:\n\n\\begin{equation*}\n\\begin{array}{ll@{}ll}\n\\text z = -119.0278 &\\\\\n\\text x = [0, 14.1667, 2.6389, 5.0000] &\\\\\n\\end{array}\n\\end{equation*}\n\n\\subsection{Input parameters}\n\nThe simplxe2 implementation was configured as follows:\n\n\\lstinputlisting{simplex2_test.m}\n\n\\section{Source Code}\n\\section*{simplex1.m}\n\\lstinputlisting{simplex1.m}\n\n\\section*{simplex2.m}\n\\lstinputlisting{simplex2.m}\n\n\\end{document}\n", "meta": {"hexsha": "ca7c1deeead4233bc4610d0455132e029f13bcbc", "size": 2166, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercise1/exercise1.tex", "max_stars_repo_name": "gleissonassis/201801-otimizacao-multiobjetivo", "max_stars_repo_head_hexsha": "d46e0e695c5f51654867f174e0078992e2146e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercise1/exercise1.tex", "max_issues_repo_name": "gleissonassis/201801-otimizacao-multiobjetivo", "max_issues_repo_head_hexsha": "d46e0e695c5f51654867f174e0078992e2146e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercise1/exercise1.tex", "max_forks_repo_name": "gleissonassis/201801-otimizacao-multiobjetivo", "max_forks_repo_head_hexsha": "d46e0e695c5f51654867f174e0078992e2146e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.88, "max_line_length": 100, "alphanum_fraction": 0.6929824561, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241911813151, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.4499293252891544}}
{"text": "% conclusion\n%\n% CONCLUSION: Limitations of the study, Questions for further research.\n%\n%----------------------------------------------------------------------------------------\n%\tPACKAGES AND OTHER DOCUMENT CONFIGURATIONS\n%----------------------------------------------------------------------------------------\n% none\n\n\\section{Conclusion}\n\\subsection{Model Validation}\nThe reliability of the chosen model, prediction rule, and prediction error rate from the training data is examined by now applying the prediction rule to the validation data set (i.e. the remaining 20\\% of data). As I will show, the new prediction error rate is about the same as that for the model-building data set, and gives a reliable indication of the predictive ability of the fitted logistic regression model and the chosen prediction rule. If the new and unseen data had lead to a considerably higher prediction error rate, then the fitted logistic regression model and the chosen prediction rule would not predict new observations well. \\par\n\n\\pagebreak\nIn my Prostate Cancer logistics model, the fitted logistic regression function (Eqn. 7) based on the model-building data set:\n\n\\[\n\\hat{\\pi}=[ 1+ exp(-2.6867 + 1.0577X_1 + 1.5502X_2)]^{-1}\n\\]\n\nwas used to calculate estimated probabilities \\(\\hat{\\pi}_h\\) for the validation data set. The chosen prediction rule (Eqn. 14):\n\n\\[\n\t\\textrm{Predict 1 if } \\hat{\\pi}_h \\geq 0.20\\textrm{; predict 0 if } \\hat{\\pi}_h < 0.20\n\\]\n\nwas then applied to these estimated probabilities. The percent prediction error rates are summarized in Figure 16 and Table 3 below:\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[scale=0.9]{confusion_matrix_final}\n\t\\caption{Confusion Matrix - Validation Data}\n\\end{figure}\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{ |c|c||c| }\n \t\\multicolumn{2}{c}{\\underline{Disease Status}} \\\\\n \t\\hline\n \tWith High Grade Cancer&Without High Grade Cancer&Total\\\\\n \t28.6\\%&7.1\\%&14.3\\%\\\\\n \t\\hline\n\t\\end{tabular}\n \t\\caption{Percent Prediction Error Rates - Validation Data}\n\\end{table}\n\nNote that the total prediction error rate of 14.3\\% is approximately equal to, or very similar to, the 15.8\\% error rate based on the model-building data set. Therefore the latter is a reliable indicator of the predictive capability of the fitted logistic regression model and the chosen prediction rule. The accuracy is seen to be 85.7\\%.\n\n\\subsection{Final Remarks}\nThe primary purpose of this study was to assess the strength of the association between each of the predictor variables with the response variable, the predictable nature of PSA Level, and the probability of a man having been diagnosed with high grade prostate cancer over low grade. We can now examine the odds ratios of the fitted model (Eqn. 7) to help address these questions. \\par\nThe interpretation for multiple logistic regression is that the estimated odds ratio for the predictor variable \\(X_k\\) assumes that all other predictor variables are held constant. In view of the fitted model (Eqn. 7) the estimated coefficients are: \\(\\hat{\\beta}_0 = -2.6867\\), \\(\\hat{\\beta}_1 = 1.0577\\), and \\(\\hat{\\beta}_2 = 1.5502\\).\nTherefore we can see, for instance, that the odds of a man being diagnosed with high grade prostate cancer increase by about 5.8\\% for each additional score of PSA Level, for a given Cancer Volume. This means each unit increase of PSA Level increases the odds of said diagnosis by 5.8\\%. Similarly, the odds of a man being diagnosed with high grade prostate cancer increase by  55.0\\% for each unit increase in cancer volume. \\par \nThus, these calculated odds ratios suggest that Cancer Volume has a significantly larger association to the outcome (a diagnosis of high grade prostate cancer) than PSA Level. However, PSA Level proved more significant than all other predictors in my analysis of \\S4.2, was used to achieve 85.7\\% accuracy against validation data in \\S5.1, and is both a cost-effective and noninvasive screening procedure for prostate cancer grade classification. \\par\nLastly, because this study is observational by nature (all 97 selected men were predetermined to have been diagnosed with prostate cancer), we must be careful about the scope of inferences we draw. Since the data are observational, the result cannot be used as proof that high grade patients test with higher PSA Level; the possibility of confounding variables cannot be excluded. Furthermore, since the individuals were not said be be drawn at random from the population of men about to undergo radical prostectomies, inference to a broader population is not justified.\n", "meta": {"hexsha": "38eb5e998c7677367680d03d9ea083380e658487", "size": 4580, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/sections/conclusion.tex", "max_stars_repo_name": "josiwala/prostate-cancer", "max_stars_repo_head_hexsha": "4920f3f3066bac5ceab241f724ff1cda8eda559b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/sections/conclusion.tex", "max_issues_repo_name": "josiwala/prostate-cancer", "max_issues_repo_head_hexsha": "4920f3f3066bac5ceab241f724ff1cda8eda559b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/sections/conclusion.tex", "max_forks_repo_name": "josiwala/prostate-cancer", "max_forks_repo_head_hexsha": "4920f3f3066bac5ceab241f724ff1cda8eda559b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.2727272727, "max_line_length": 650, "alphanum_fraction": 0.7465065502, "num_tokens": 1070, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4499293190359492}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{comment}\n \n\\usepackage[noend]{algpseudocode}\n\\usepackage{algorithm}\n\\usepackage{float}\n\\usepackage{graphicx}\n\\usepackage[margin=.75in]{geometry} \n\\usepackage{amsmath,amsthm,amssymb}\n\\usepackage{dsfont}\n\\usepackage{amsthm}\n\\usepackage{mathtools,amssymb}\n\\usepackage{wrapfig,caption,subcaption}\n\\allowdisplaybreaks\n\n\\newtheorem*{definition}{Definition}\n\\newtheorem*{question}{Question}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n \n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Rgz}{\\mathbb{R}_{\\ge 0}}\n\n\\newcommand{\\ip}[2]{\\left\\langle{#1},{#2}\\right\\rangle}\n\\newcommand{\\norm}[1]{\\left\\lVert{#1}\\right\\rVert}\n\\newcommand{\\sizeof}[1]{\\left\\lvert{#1}\\right\\rvert}\n\n\\newcommand{\\woloss}{without loss of generality }\n\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\cone}{cone}\n\\DeclareMathOperator*{\\hull}{hull}\n\\DeclareMathOperator*{\\indif}{indif}\n\n\\newcommand{\\1}[1]{\\mathds{1}[{#1}]}\n\\renewcommand{\\P}[1]{\\mathds{P}\\left[{#1}\\right]}\n\\newcommand{\\E}[1]{\\mathds{E}\\left[{#1}\\right]}\n\\newcommand{\\Var}[1]{\\mathrm{Var}[{#1}]}\n\n\\newcommand{\\unit}{\\mathds{1}}\n\\newcommand{\\lo}{\\succ}\n\n% \\renewcommand{\\thesubsection}{\\thesection.\\alph{subsection}}\n% \\renewcommand\\thesubsection{\\ \\ (\\alph{subsection})}\n\n\n\\begin{document}\n\n% \\renewcommand{\\qedsymbol}{\\filledbox}\n \n\\title{\n  Dimensional Preferences: Combinatorics and Voting\n}\n\\author{\n  Clay Thomas \\\\\n  claytont@princeton.edu\n\\and\n  Yufei Zheng\\\\\n  yufei@cs.princeton.edu\n}\n\n\\maketitle\n\\begin{abstract}\n  Restricted classes of total orders\n  are a common tool used to model the preferences of rational agents.\n  We introduce a new class of ordinal preferences called \n  $d$-dimensional preferences.\n  In part I of this paper,\n  we prove a sequence of results about $d$-dimensional preferences,\n  demonstrating how an underlying set of outcomes in $\\Rgz^d$\n  can give a natural structure to the set of possible preferences.\n\n  We are particularly successful when studying $2$-dimensional preferences.\n  In part II of this paper, we apply our theory to the subject of\n  \\emph{voting schemes} for $2$-dimensional preferences.\n  We show that very good voting schemes exist for these preferences.\n  Specifically, we give a incentive compatible voting scheme satisfying\n  independence of irrelevant alternatives which always selects a Condorcet\n  winner.\n\n  % The study of voting rules often restricts attention to\n  % well-behaved classes of possible preferences of voters.\n  % We define a new class: $2$-dimensional preferences,\n  % for which very good voting rules are possible.\n  % We argue that $2$-dimensional preferences are in some ways\n  % more natural and expressive than more traditional classes\n  % such as single-peaked preferences.\n  % Furthermore, we give an almost-complete combinatorial classification\n  % of $2$-dimensional preferences, and provide some additional\n  % results about the natural extension of $d$-dimensional preferences.\n\\end{abstract}\n\n\\section{Introduction}\n\n  In this project, we study \\emph{ordinal preferences}, i.e. preferences which\n  prefer certain outcomes over others, but do not have a quantitative notion of\n  the quality of the outcome. Formally, these are simply total orders.\n  As computer scientists, our first instinct is to make no assumptions,\n  e.g. to assume preferences can be any of the $m!$ distinct total orders\n  on $m$ outcomes.\n  However, this typically does not correspond to reality: the preferences of an\n  agent are typically \\emph{caused by something}, i.e. there is an underlying\n  structure explaining the preferences. This is one way to model the idea the\n  preferences are \\emph{correlated}.\n\n  Consider the following motivating example.\n  Suppose there are $m$ school, and each has two attributes\n  which we assume are objective across all preferences:\n  quality of STEM education and quality of liberal arts education.\n  We can model each school as a point $x\\in \\Rgz^2$, where the first coordinate\n  gives STEM quality and second coordinate gives liberal arts quality.\n  Then it is possible that the school preferences of students\n  actually boil down to a simple preference over STEM and liberal arts,\n  which we can model as a \\emph{weighted sum} over the two attributes.\n  For example, a student who prefers $30\\%$ STEM and $70\\%$ liberal arts\n  would ``score'' a school $x = (x_1, x_2)$ via the sum\n  $0.3 x_1 + 0.7 x_2$, and that student prefers school $x$ over school $y$\n  if $0.3 x_1 + 0.7 x_2 > 0.3 y_1 + 0.7 y_2$.\n\n  Social choice theory, the study of \\emph{voting schemes},\n  has found much theoretical success in studying restricted classes of preferences.\n  Restricting preferences is a way around various impossibility theorems of\n  social choice theory, which state that certain ``good'' voting schemes do not\n  exist in general. In this project, we investigate the structure of preferences\n  which arise from ``weighted sum'' scoring, and apply these results to provide\n  good voting schemes for this restricted class of preferences.\n\n  \\subsection{Outline and highlights of results}\n    We formalize this notion for any number of attributes $d$,\n    and call the resulting preference model $d$-dimensional preferences.\n    We setup a framework for studying $d$-dimensional preferences,\n    identifying the correct geometric objects to use when reasoning about them.\n    These objects give interesting geometric explanations for concepts such as\n    opinion and agreement.\n    Using these tools, we are able to prove a general impossibility result,\n    theorem~\\ref{thrm:noBigCycles}, which shows\n    a qualitative way in which preferences get more complicated as $d$ increases.\n\n    When $d=2$, we achieve a good handle on the combinatorial structure of\n    $2$-dimensional preferences, including\n    a tight upper bound on the maximal number of\n    distinct linear preferences corresponding\n    $2$-dimensional preferences (theorem~\\ref{thrm:maxNumberTwoD}).\n    We find that $d=2$ represents a very nice point in the trade-off\n    between expressibility and complexity, with enough preferences to be\n    realistic while still having strong structure.\n\n    Next, we turn to study the social choice theory of $2$-dimensional\n    preferences\\footnote{\n      We have tried to add sufficient references so that Part II is readable\n      without studying Part I in detail, and just occasionally glancing back for\n      the lemmas needed.\n      Propositions~\\ref{prop:conesAgreement} and~\\ref{prop:compEqualizerAngle}\n      are the most important for section~\\ref{sec:voting}.\n    }. We compare and contrast $2$-dimensional preferences with \n    \\emph{single-peaked preferences}, the\n    classic restricted class used in social choice theory.\n    Each model different phenomenon, but we argue that $2$-dimensional\n    preferences are more expressive in some ways, and certainly more natural in\n    some cases. We find that many positive results which holds for\n    single-peaked preferences hold for $2$-dimensional preferences.\n    In particular, we consider the voting scheme which takes \n    preference weight vectors $a_1,a_2,\\ldots,a_n$ as inputs,\n    and outputs the favorite outcome of the median-angled (from the positive $x$\n    axis) vector $u$.\n    It turns out that this mechanism\n    satisfies essentially all of the basic desirable properties for a voting scheme.\n\n\n\n\n\n\n\n\n\\clearpage\n%============================================================\n%============================================================\n\\part{The Combinatorics of $d$-Dimensional Preferences}\n\n\\section{Definition of $d$-dimensional preferences}\n  \\begin{wrapfigure}{r}{0.25\\textwidth}\n    \\vspace{-0.6in}\n    \\begin{center}\n      \\includegraphics[width=0.2\\textwidth]{figures/def2DPref}\n    \\end{center}\n    \\ \\caption{\n      The ``level sets'' of the preference $>_a$,\n      which ranks outcomes according to distance from the origin along\n      direction $a$.\n    }\n  \\end{wrapfigure}\n  Let $\\{x_1,\\ldots,x_m\\} = X\\subseteq \\Rgz^d$ be any set of\n  $m$ distinct points with nonnegative coordinates.\n  We call $X$ the set of \\emph{outcomes}.\n  Given any $a\\in \\Rgz^d$, which we call a \\emph{preference weight},\n  define a order $>_a$ on $X$ as follows:\n  $x_i >_a x_j$ if and only if $\\ip{a}{x_i} > \\ip{a}{x_j}$.\n  Let $R(X)$ denote the set of total orders on $X$.\n  Define\n  \\begin{align*}\n    P_d(X) = \\{ \\succ \\in R(X) | \\exists a\\in\\Rgz^d: x \\succ y \\iff x >_a y\\}\n  \\end{align*}\n  Note that we consider only total orders, in particular,\n  ties are not allowed.\n  % This maybe could use a footnote:\n  % \\footnote{\n  %   This is largely without loss of generality.\n  %   For a given $x,y$ pair, the set of $a$ for which\n  %   $\\ip{a}{x} = \\ip{a}{y}$ has measure zero.\n  % }\n\n  Some first observations:\n  \\begin{itemize}\n    \\item If $d=1$, then $|P(X)| = 1$, i.e. preferences are completely\n      determined by the underlying set $X$.\n    \\item If $d=n$, then every linear preference on $X$ can occur in $P(X)$.\n      \\begin{proof}\n        Let $X = \\{e_i\\}$ simply be the standard basis vectors.\n        To induce an ordering $i_1, i_2, \\ldots, i_n$, just create a preference\n        vector $a$ which gives weight $1/k$ to coordinate $i_k$.\n      \\end{proof}\n  \\end{itemize}\n  The above hints that there should be some sort of continuum between $d=1$\n  and $d=n$ of how complex a preference set $P_d(X)$ can be.\n  We will find that $d=2$ is a particular sweet spot between expressibility and\n  simplicity.\n  A core piece of intuition to keep in mind for this paper is that\n  a collection of $d$-dimensional preferences is really a $d-1$ dimensional space:\n  preferences $>_a$ are invariant under $\\|a\\|$, so without loss of generality\n  we can take all preferences to lie on the unit sphere.\n  In particular, $2$-dimensional preferences are a well-behaved one dimensional\n  space.\n\n\\section{Lemmas}\n  In this section, we set up the tools needed to reason about \n  $d$-dimensional preferences.\n\n  \\subsection{Lemmas based on the structure of $X$}\n    These first few lemmas relate geometric properties of $X$ to\n    limitations on the structure of $>_a$ for a specific, fixed $a$.\n\n    The most simple way $X$ gives structure to preferences is if\n    one outcome is better in all attributes.\n    \\begin{definition}\n      Let $x,y\\in X\\subseteq \\Rgz^d$.\n      We say $x$ \\emph{dominates} $y$, denoted $x\\gg y$,\n      if $x[k] > y[k]$ for each $k=1,\\ldots,d$.\n    \\end{definition}\n    \\begin{proposition}\n      If $x \\gg y$, then $x >_a y$ for any nonzero $a\\in \\Rgz^d$.\n    \\end{proposition}\n    \\begin{proof}\n      Simply observe $a_i x_i \\ge a_i y_i$ for each $i=1,\\ldots, d$.\n      Because $a\\ne 0$, there is also some $i$ where $a_i x_i > a_i y_i$.\n    \\end{proof}\n\n    When comparing different outcomes, a useful tool is\n    the familiar geometric notion of a convex hull.\n    Intuitively, if a preference weight does not like any of a set of options,\n    it will not like any outcome in the hull of those options either.\n    Thus, a point ``dominated by the hull'' of a set of options\n    (as in figure~\\ref{fig:domHull}) cannot be preferred to all those options.\n    \\begin{definition}\n      For points $x_1,\\ldots,x_n \\in \\R^d$, let $\\hull(x_1,\\ldots,x_n)\n      = \\{u_1x_1 + \\ldots + u_nx_n | 0\\le u_i\\le 1, \\sum_{i=1}^n u_i = 1\\}$\n      denote the convex hull of $x_1,\\ldots,x_n$.\n    \\end{definition}\n    \\begin{lemma}\\label{lem:agreementHull}\n      Let $z,x_1,\\ldots,x_k \\in \\Rgz^d$ and $a\\in \\Rgz^d \\setminus \\{0\\}$.\n      If $z >_a x_i$ for $i=1,\\ldots,k$, then $z >_a w$\n      for any $w\\in \\hull(x_1,\\ldots,x_k)$.\n    \\end{lemma}\n    \\begin{proof}\n      We have $\\ip{a}{z} > \\ip{a}{x_i}$ for each $i=1,\\ldots,k$.\n      If $w = u_1x_1+ \\ldots + u_nx_n$ and $\\sum_i u_i =1$, then\n      $\\ip{a}{w} = u_1\\ip{a}{x_1}+\\ldots+u_n\\ip{a}{x_n}\n      < u_1\\ip{a}{z} + \\ldots + u_n\\ip{a}{z} = \\ip{a}{z}$.\n    \\end{proof}\n\n    \\begin{proposition}\\label{prop:domHull}\n      Let $z,x_1,\\ldots,x_k \\in \\Rgz^d$.\n      Suppose that there exists $w\\in \\hull(x_1,\\ldots,x_k)$\n      such that $w \\gg z$.\n      Then no $a$ satisfies $z >_a x_i$ for each $i=1,\\ldots, k$.\n      % Suppose that there exists $w\\in \\hull(x_1,\\ldots,x_k)$\n      %     such that $z \\gg w$.\n      %     Then no $a$ satisfies $x_i >_a z$ for each $i=1,\\ldots, k$.\n    \\end{proposition}\n    \\begin{proof}\n      For contradiction, suppose such an $a$ exists.\n      Then $z >_a w$ as well. However, because $w \\gg z$,\n      this is a contradiction.\n    \\end{proof}\n    Note that lemma~\\ref{lem:agreementHull} and proposition~\\ref{prop:domHull}\n    both hold when you reverse all the inequalities in their statements,\n    via the same arguments.\n\n    \\begin{figure}[t]\n      \\centering\n      \\begin{subfigure}[t]{0.3\\textwidth}\n        \\includegraphics[width=0.9\\textwidth]{figures/defDom}\n        \\caption{$x_1$ dominates $x_2$ ($x_1 \\gg x_2$)}\n        \\label{fig:gull}\n      \\end{subfigure}\n      ~\n      \\begin{subfigure}[t]{0.3\\textwidth}\n        \\includegraphics[width=0.9\\textwidth]{figures/defHull}\n        \\caption{The convex $\\hull$}\n        \\label{fig:tiger}\n      \\end{subfigure}\n      ~\n      \\begin{subfigure}[t]{0.3\\textwidth}\n        \\includegraphics[width=0.9\\textwidth]{figures/propDomHull}\n        \\caption{Proposition~\\ref{prop:domHull}}\n        \\label{fig:domHull}\n      \\end{subfigure}\n\n      \\caption{}\\label{fig:animals}\n    \\end{figure}\n\n  \\subsection{Lemma relating different preference vectors}\n    \\begin{wrapfigure}{r}{0.25\\textwidth}\n      \\vspace{-1.1in}\n      \\begin{center}\n        \\includegraphics[width=0.28\\textwidth]{figures/defCone}\n      \\end{center}\n      \\caption{The convex cone}\n      \\vspace{-1in}\n    \\end{wrapfigure}\n\n    % This next group of lemmas relates different different preference vectors.\n    % They will be very useful for our results about voting schemes.\n\n    When comparing different preference weights, a useful tool is\n    the familiar geometric notion of a convex cone.\n    Intuitively, if a set of weights agree about a certain preference,\n    so does every weight in their cone.\n    \\begin{definition}\n      For any vectors $a_1,\\ldots, a_k \\in \\Rgz^d$, define\n      \\[ \\cone(a_1,\\ldots,a_k) = \\{ u_1a_1 + \\ldots + u_ka_k | u_i\\ge 0 \\forall j\\} \\]\n    \\end{definition}\n    \\begin{proposition}\\label{prop:conesAgreement}\n      Suppose that for preference weights $a_1,\\ldots, a_k$,\n      we have $x >_{a_1} y, \\ldots, x >_{a_k} y$.\n      Then for any nonzero $b\\in \\cone(a_1,\\ldots, a_k)$,\n      $x >_b y$ as well.\n    \\end{proposition}\n    \\begin{proof}\n      Let $b = u_1a_1+ \\ldots + u_ka_k$.\n      We get $\\ip{b}{x} = u_1\\ip{a_1}{x} + \\ldots + u_k\\ip{a_k}{x}\n      > u_1\\ip{a_1}{y} + \\ldots + u_k\\ip{a_k}{y} = \\ip{b}{y}$,\n      as desired.\n    \\end{proof}\n\n  \\subsection{Lemmas for $2$ dimensional preferences}\n\n    This section turns to our main focus: $2$ dimensional preferences.\n    Given two points $x,y$ in our set of outcomes $X$, we give a simple\n    classification of which preference weight prefer $x$ and which prefer $y$.\n    To do so, we introduce the notion of a weight ``indifferent between $x$ and $y$''.\n    \\begin{lemma}\n      Let $x,y\\in \\Rgz^2$ be distinct points where neither \n      $x$ nor $y$ dominates the other.\n      There exists a unique unit vector $b\\in\\Rgz^2$ such that\n      $\\ip{b}{x} = \\ip{b}{y}$.\n    \\end{lemma}\n    \\begin{proof}\n      Without loss of generality let $x_1 < y_1$, $x_2 > y_2$\n      (if either of these are equalities, the standard basis vectors\n      $e_1$ or $e_2$ will do).\n      There exists exactly one unit vector $b$ in $\\Rgz^2$ such that\n      $b_1 / b_2 = (x_2 - y_2) / (y_1 - x_1)$.\n      It's easy to check that this is a necessary and sufficient \n      condition for having $\\ip{b}{x} = \\ip{b}{y}$.\n    \\end{proof}\n    \\begin{definition}\n      For $x,y\\in \\Rgz^2$ where neither dominates the other,\n      let the ``indifferent vector of $x$ and $y$'',\n      denoted $\\indif(x,y)$, be the unit vector $b\\in\\Rgz^2$ such \n      that $\\ip{b}{x} = \\ip{b}{y}$.\n    \\end{definition}\n\n    \\begin{wrapfigure}{r}{0.3\\textwidth}\n      \\vspace{-0.4in}\n      \\begin{center}\n        \\includegraphics[width=0.26\\textwidth]{figures/clmAngle}\n      \\end{center}\n      \\caption{\n        Proposition~\\ref{prop:compEqualizerAngle}. $b=\\indif(x,y)$.\n        Preferences above $b$ (those with higher angle) all prefer $x$,\n        and those below $b$ (those with lower angle) all prefer $y$\n      }\n      \\vspace{-0.7in}\n    \\end{wrapfigure}\n\n    This next lemma says that the indifference vector of $x$ and $y$ divides \n    the space of preferences into two halves: one that prefers $x$, one that\n    prefers $y$. This division is given by another very natural ordering,\n    this one for preference weights. The following definition has an obvious\n    interpretation by considering $\\theta(a)$ to be the angle of $a$ from the\n    positive $x$ axis, but we use an equivalent algebraic definition to simply\n    our proofs.\n    Of course, feel free to ignore this definition, and just use the more\n    natural interpretation of $\\theta(\\cdot)$ as a function which gives the angle.\n\n    \\begin{definition}\n      We say $a$ has a larger angle than $b$, denoted $\\theta(a) > \\theta(b)$,\n      if $a_2 / a_1 > b_2 / b_1$.\n      % If one of those quotients is not defined,\n      % $\\theta(a) > \\theta(b)$ if $a_1 = 0$ and $b_1 \\ne 0$.\n      % (  $a \\times b = a_1 b_2 - a_2 b_1 < 0$.  )\n    \\end{definition}\n    % To see that this definition is equivalent to the natural analogue about the\n    % angle from the positive $x$ axis, just consider the ``slopes'' of the\n    % vectors $a$ and $b$. Our definition of $\\theta(a) > \\theta(b)$\n    % means $a_2 / a_1 > b_2 / b_1$ (in all but some edge cases).\n\n    \\begin{proposition} \\label{prop:compEqualizerAngle}\n      Consider any pair of points $x, y \\in \\Rgz^2$, \n      where $x_1 < y_1$ and $x_2 > y_2$, \n      and let $b = \\indif(x,y)$.\n      Then for any preference weight vector $a \\in \\R_{\\geq 0}^2$,\n      \\begin{enumerate}\n        \\item \\label{clm:angle1} $\\theta(a) > \\theta(b)$ if and only if $x >_a y$.\n        \\item \\label{clm:angle2} $\\theta(a) < \\theta(b)$ if and only if $y >_a x$.\n      \\end{enumerate}\n    \\end{proposition}\n    \\begin{proof}\n      Except for the edge case where one vector is a\n      multiple of the other, the two items are exactly the same statement.\n      We prove the first one:\n      \\begin{align*}\n        x >_a y\n        & \\iff a_1 x_1 + a_2 x_2 > a_1 y_1 + a_2 y_2\n        \\\\ & \\iff \\frac{a_2}{a_1} > \\frac{y_1 - x_1}{x_2 - y_2} \n          = \\frac{b_2}{b_1}\n        \\\\ & \\iff 0 > a_1 b_2 - a_2 b_1\n        \\\\ & \\iff \\theta(a) > \\theta(b)\n      \\end{align*}\n    \\end{proof}\n\n    % For completeness, we prove the following simple result:\n    % \\begin{proposition}\n    %   If $\\theta(a) < \\theta(u) < \\theta(b)$, then $u\\in \\cone(a,b)$.\n    % \\end{proposition}\n\n\\clearpage % NOTE: maybe not\n\\section{Bounding the number of $2$-dimensional preferences}\n\n  \\begin{wrapfigure}{r}{0.3\\textwidth}\n    \\begin{center}\n      \\includegraphics[width=0.28\\textwidth]{figures/lemSlopes}\n    \\end{center}\n    \\caption{\n      Theorem~\\ref{thrm:maxNumberTwoD}.\n      Indifference vectors $b$ and $b'$ divide preference weight into three\n      regions, which each have the same preferences for $x$ vs. $y$\n      and $x'$ vs. $y'$.\n    }\n  \\end{wrapfigure}\n\n  We are able to obtain a tight upper bound on the number of distinct linear\n  preferences which arise from a given two-dimensional outcome set $X$.\n  In particular, note that $|P_2(X)|$ is much less than $m!$, the total number\n  of linear orders on $X$.\n  \\begin{theorem} \\label{thrm:maxNumberTwoD}\n    Let $X\\subseteq \\Rgz^2$ with $|X| = m$. We have\n    \\[ \\sizeof{P_2(X)} \\leq \\binom{m}{2} + 1 \\]\n  \\end{theorem}\n  \\begin{proof}\n    Consider the following set of preference weights:\n    \\[ B = \\{ \\indif(x,y) | x,y\\in X\\text{ and neither dominates the other} \\} \\]\n\n    Consider the different regions of $\\Rgz^2$ separated by elements of $B$.\n    That is, consider the equivalence classes of the relation $\\sim$\n    on $\\Rgz^2\\setminus B$, where $a \\sim a'$\n    means that $\\forall b\\in B: \\theta(a) < \\theta(b) \\iff \\theta(a') < \\theta(b)$.\n    We claim that if $a\\sim a'$, then $x >_a y \\iff x >_{a'} y$ for all $x,y\\in X$.\n    Proof: If $x \\gg y$ or $y \\gg x$, the order between $x$ and $y$ fixed for\n    any $a$. Otherwise, $\\indif(x,y)\\in B$, so\n    by proposition~\\ref{prop:compEqualizerAngle}, this means\n    $x >_a y \\iff x >_{a'} y$.\n\n    Thus, the mapping from $\\Rgz^2 \\to R(X)$ given by $a\\mapsto (>_a)$ is constant\n    on equivalence classes of $\\sim$. This map is surjective by definition.\n    Furthermore, $a,a'$ in distinct equivalence classes of $\\sim$\n    give distinct preferences $>_a, >_{a'}\\in R(X)$, again by\n    proposition~\\ref{prop:compEqualizerAngle}, because $a$ and $a'$ are on a\n    different side of some $b\\in B$ under the $\\theta$ order.\n    Thus, there is a bijection between equivalence classes of $\\sim$ and\n    preferences in $P_2(X)$.\n\n    Note that $|D|\\le {m \\choose 2}$, so $\\sim$ divides the $\\Rgz^2$ into at most\n    ${m \\choose 2}+1$ regions based on the $\\theta$ order.\n    Thus $\\sizeof{P_2(X)} \\leq \\binom{m}{2} + 1$, as desired.\n  \\end{proof}\n\n  Furthermore, this upper bound is tight.\n  Notice that the proof of the upper bound gives a simple condition for the\n  upper bound to be tight: no point of $X$ should dominate another,\n  and every pair of points $x,y\\in X$ should give a distinct indifference\n  vector $\\indif(x,y)$.\n  To construct such an $X$ with $m$ outcomes, consider\n  $X' = \\{ (i,m + 1 - i) | i=1,\\ldots,m \\}$, and randomly perturb each point a\n  bit such that all $\\indif(x,y)$ vectors are distinct\\footnote{\n    If you want to get really abstract and fancy, let\n    $\\alpha_1,\\ldots, \\alpha_n$ be real numbers which are\n    algebraically independent over $\\mathbb Q$, and such that\n    $|\\alpha_i| < 1/3$. Then the points $\\{(i,m + 1 - i + \\alpha_i)\\}_{i=1}^m$\n    cannot possibly yield a repeated indifference vector, by\n    algebraic considerations.\n  }.\n\n\\section{Impossibility Results}\n\n  \\subsection{Large preference cycles are impossible in any dimension}\n    The following preference set may be important in high dimension.\n    We call it $k$-{\\sc Cycle}:\n    % \\begin{align*}\n    %   1 > 2 > 3 > 4 \\\\\n    %   2 > 3 > 4 > 1 \\\\\n    %   3 > 4 > 1 > 2 \\\\\n    %   4 > 1 > 2 > 3 \\\\\n    % \\end{align*}\n    \\begin{align*}\n      \\begin{array}{ccccccccccccccccccccccccccccccccccccccccc}\n      1 &>& 2 &>& 3 &>&\\ldots &>& k-2 &>& k-1 &>& k \\\\\n      2 &>& 3 &>& 4 &>& \\ldots &>& k-1 &>& k &>& 1 \\\\\n      3 &>& 4 &>& 5 &>& \\ldots &>& k &>& 1 &>& 2 \\\\\n        &&    &&    &&   \\vdots \\\\\n      k-1&>&k&>& 1 &>&\\ldots &>& k-4 &>& k-3 &>& k-2\\\\\n      k &>& 1 &>& 2 &>& \\ldots &>& k-3 &>& k-2 &>& k-1 \\\\\n      \\end{array}\n    \\end{align*}\n    \\begin{theorem}\\label{thrm:noBigCycles}\n      $(d+1)$-{\\sc Cycle} is not $d$-dimensional for any $d$.\n    \\end{theorem}\n    \\begin{proof}\n      Suppose for contradiction there existed\n      $a_1,\\ldots,a_{d+1}\\in\\Rgz^{d}$ such that $>_{a_i}$ yielded the $i$th line of\n      $(d+1)$-{\\sc Cycle} (in particular, the line whose favorite point is $i$).\n      The vectors $\\{a_i\\}$ cannot be linearly independent.\n      Thus, there exists a linear combination of vectors\n      $u_1 a_1 + \\ldots + u_{d+1} a_{d+1} = 0$.\n      Let $S = \\{a_i | u_i > 0\\}$ and let $T = \\{a_i | u_i < 0\\}$.\n      Note that, because every coordinate of each $a_i$ is nonnegative\n      (and no $a_i$ is zero) neither $S$ nor $T$ are empty.\n      We have\n      \\[ \\sum_{a_i \\in S} u_i a_i = \\sum_{a_i \\in T} -u_i a_i \\]\n      Denote this above vector by $b$, and note that \n      $b\\in\\Rgz^{d} \\setminus \\{0\\}$ and $b\\in \\cone(S) \\cap \\cone(T)$.\n\n      We claim that $b$ satisfies the following:\n      \\[ 1 >_b 2 >_b 3 >_b \\ldots >_b d >_b d+1 >_b 1 \\]\n      Proof: For each pair $i > i+1$,\n      observe that the inequality is satisfied for all the vectors $a_i$ except\n      for one of them (namely, $a_{i+1}$ which ranks $i+1$ highest).\n      Thus, for either $S$ or $T$, every vector $a_i$ in the set has the opinion\n      $i >_{a_i} i+1$. Thus, every vector in the cone of that set\n      has the opinion $i > i+1$ as well, by proposition~\\ref{prop:conesAgreement}.\n      In particular, $i >_b i+1$.\n      Of course, the above argument works for the pair $d+>1$ as well.\n\n      Thus, transitivity gives us $1>_b 1$, a contradiction.\n    \\end{proof}\n    This is one of our few results which work for any dimension.\n    We'll see that $3$-{Cycle} being impossible for $2$ dimensional preferences\n    is a necessary condition for many of the nice properties of $2$ dimensional\n    preferences (especially theorem~\\ref{thrm:2DCondorcet}).\n    Intuitively, it is possible that ``cyclic disagreements'' are a core issue for\n    different applications with ordinal preferences (we consider voting here, but\n    other cases include matching or resource allocation).\n    The impossibility of the $d+1$ cycle in $d$ dimensions gives a\n    very nice example of preference sets getting more complicated as\n    dimension increases.\n\n\n  \\subsection{Combinatorial impossibilities for $2$ dimensional preferences}\n\n    \\begin{proposition}\\label{prop:noAllBestWorst}\n      Let $P = P_2(X)$ be any set of $2$ dimensional preferences,\n      where $|X| \\ge 3$.\n      It is not possible for every $x\\in X$ to be both the\n      favorite and least favorite outcome of some preference in $P$.\n    \\end{proposition}\n    \\begin{proof}\n      If any point dominates another, then the dominated point cannot be favorite.\n      Thus we may assume that no point in $X$ is dominated\n      by any other point. Pick two points $x \\ne y$ such that $x$ has the largest\n      first coordinate (i.e. $x_1$) among all of $X$, and $y$ has the highest second\n      coordinate (i.e. $y_2$).\n      Consider figure~\\ref{fig:noAllBestWorst}.\n      Any remaining point $z\\ne x,y$ must lie in region $1$ or $2$, as all other\n      regions either violate the assumption that $x_1 > z_1$ and $y_2 > z_2$\n      or cause one point to dominate another.\n      If $z$ lies in region $1$, it can never be the favorite, by\n      proposition~\\ref{prop:domHull}, because it is dominated by some point in\n      $\\hull(x,y)$.\n      If $z$ lies in region $2$, it can never be the least favorite, this time\n      by the opposite but completely analogous version of \n      proposition~\\ref{prop:domHull}, because $z$ dominates a point in $\\hull(x,y)$.\n      For the corner case where $z\\in\\hull(x,y)$, observe that $z$ is\n      \\emph{always} the middle option among $x$ and $y$.\n    \\end{proof}\n\n    \\begin{wrapfigure}{r}{0.2\\textwidth}\n      \\begin{center}\n        \\includegraphics[width=0.2\\textwidth]{figures/noBestWorst}\n      \\end{center}\n      \\caption{Proposition~\\ref{prop:noAllBestWorst}}\n      \\label{fig:noAllBestWorst}\n    \\end{wrapfigure}\n\n    This proposition, combined with Theorem~\\ref{thrm:noBigCycles}, gives a\n    complete combinatorial classification of two dimensional preferences on\n    exactly three outcomes. Consider all preferences on three outcomes,\n    organized with the two copies of $3$-{\\sc Cycle} in different columns.\n    \\begin{align*}\n      1 > 2 > 3 && 1 > 3 > 2 \\\\\n      2 > 3 > 1 && 3 > 2 > 1 \\\\\n      3 > 1 > 2 && 2 > 1 > 3 \\\\\n    \\end{align*}\n    In order to make our preference set $2$ dimensional, we need to exclude one\n    preference from each cycle.\n    By relabeling, we can without loss of generality assume that the\n    preference with $1 > 2 > 3$ is not in $P$, and consider removing a\n    preference from the other cycle.\n    If $1 > 3 > 2$ or $2 > 1 > 3$ are removed from $P$, then $P$ will not\n    violate proposition~\\ref{prop:noAllBestWorst}\\footnote{\n      We will see later in section~\\ref{sec:singleVsTwoD}\n      that these preference sets are $2$ dimensional. Up to relabeling, they are\n      {\\sc BadCompromise} and {\\sc GoodCompromise}, respectively.\n    }.\n    If we only remove $3 > 2 > 1$, then every outcome is some preference's\n    favorite and some other preference's least favorite\\footnote{\n      This gives {\\sc Sandwich} from section~\\ref{sec:singleVsTwoD}.\n    }.\n    So this $P$ is not two dimensional.\n\n    % \\begin{theorem}\n    %   A set of preferences $P$ on exactly three outcomes is $2$ dimensional if\n    %   and only if it does not contain $3$-{\\sc Cycle} or {\\sc Sandwich} \n    %   (up to relabeling).\n    % \\end{theorem}\n    % \\begin{proof}\n    %   We have seen that $3$-{\\sc Cycle} and {\\sc Sandwich} are not $2$\n    %   dimensional.\n    %   Thus, it suffices to show that for any set of preferences which does not\n    %   contain a $3$-{\\sc Cycle}, the only way for the preference set to\n    %   fail to be $2$ dimensional is if it contains {\\sc Sandwich}.\n\n    %   The following lists all preference on three outcomes, organized by column\n    %   into the two copies of $3$-{\\sc Cycle} they form.\n    %   \\begin{align*}\n    %     1 > 2 > 3 && 1 > 3 > 2 \\\\\n    %     2 > 3 > 1 && 3 > 2 > 1 \\\\\n    %     3 > 1 > 2 && 2 > 1 > 3 \\\\\n    %   \\end{align*}\n    %   At least one element from each of these cycles must not be present in $P$.\n    %   By relabeling, we can without loss of generality assume that the\n    %   preference with $1 > 2 > 3$ is not in $P$.\n    %   Now, we simply need to look at three cases based on which element of the\n    %   other cycle is not in $P$.\n    %   \\begin{itemize}\n    %     \\item Suppose $1 > 3 > 2$ is not in $P$.\n    %       Up to relabeling, all the remaining preferences form a copy of\n    %       {\\sc BadCompromise}, where $1$ is the point which is never a voter's\n    %       favorite.\n    %     \\item Suppose $3 > 2 > 1$ is not in $P$.\n    %       In this case, the remaining preferences form a copy of {\\sc Sandwich},\n    %       where $3$ is the outcome which is always either favorite or least\n    %       favorite.\n    %     \\item Suppose $2 > 1 > 3$ is not in $P$.\n    %       Up to relabeling, all the remaining preferences form a copy of\n    %       {\\sc GoodCompromise}, where $2$ is the point which is never a voter's\n    %       least favorite.\n    %   \\end{itemize}\n    % \\end{proof}\n\n  % \\subsection{A necessary algorithmic condition for $2$ dimensional preferences}\n  %   ((WE BELIEVE THAT THE MATERIAL ABOUT SLOPES MAY PROVIDE A MORE GENERAL\n  %   COMBINATORIAL CLASSIFICATION OF 2D PREFS. SHOW SOME NECESSARY CONDITIONS WE\n  %   CAN PROVE. CONJECTURE THAT A RELATED THING IS AN IFF))\n\n  %   algorithm:\n\n  %   consider all pairs x,y. If one never exceeds the other, drop it.\n\n  %   For all pairs of tuples, define (x,y) >*> (x',y') if whenever x>y,\n  %   we have x'>y'.\n\n  %   I THINK the digraph on such tuples should connected and acyclic if it's two\n  %   dimensional.\n\n  %   Optimization:\n  %   Pick an arbitrary remaining pair x,y and add the ordered tuple (x,y)\n  %   to a set. For all other x',y', add two tuples: (x',y') and (y',x').\n  %   If the component containing (x,y) is acyclic, you're good.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\clearpage\n%============================================================\n%============================================================\n\\part{Voting With $2$ Dimensional Preferences}\n\n\\section{Definitions}\n  \\subsection{Voting}\n    Consider a set of preferences $P$ (i.e. linear orders) on a\n    set of outcomes $M$.\n    We follow the convention that $m$ is the number of outcomes and $n$\n    is the number of voters.\n    We have the following definitions:\n    \\begin{itemize}\n      \\item A \\emph{social welfare function on $P$}\n        is a function $F : P^n \\to P$\n      \\item A \\emph{social choice function on $P$}\n        is a function $f : P^n \\to M$. We also call such an $f$ a \n        \\emph{voting scheme} or a \\emph{voting rule}.\n      \\item A welfare function $F$ is \\emph{unanimous} if,\n        for any $\\succ\\ \\in P$, we have $F(\\succ,\\ldots,\\succ) =\\ \\succ$\n      % \\item A choice function $f$ is \\emph{unanimous} if,\n      %   whenever there exists a fixed $a$ with $a \\succ_i b$ for all \n      %   $i=1,\\ldots, n$ and $b\\in M\\setminus \\{a\\}$,\n      %   we have $f(\\succ_1,\\ldots,\\succ_n) = a$.\n      %   I'm not sure if this is a standard notion.\n      \\item A welfare function $F$ is a \\emph{dictatorship} if\n        there exists an $i$ such that $F(\\succ_1,\\ldots,\\succ_n) = \\succ_i$\n      \\item A choice function $f$ is a \\emph{dictatorship} if\n        there exists an $i$ such that $f(\\succ_1,\\ldots,\\succ_n) = a_i$,\n        where $a_i$ is the favorite outcome of $\\succ_i$\n      \\item A welfare function $F$ satisfies \\emph{independence of\n        irrelevant alternatives} (IIA) if, whenever $a\\succ_i b \\iff a\\succ_i' b$\n        and $\\succ = F(\\succ_1,\\ldots,\\succ_n),\n        \\succ' = F(\\succ'_1,\\ldots,\\succ'_n)$,\n        we get $a\\succ b \\iff a\\succ' b$. \\\\\n        That is, if no voter changes their opinion between $a$ and $b$,\n        the group preference between $a$ and $b$ does not change.\n      \\item A choice function $f$ is \\emph{incentive compatible} if,\n        for any $\\succ_1,\\ldots,\\succ_n, i, \\succ_i'$, we have \\\\\n        $f(\\succ_1,\\ldots,\\succ_i,\\ldots,\\succ_n) \n        \\succeq_i f(\\succ_1,\\ldots,\\succ_i',\\ldots,\\succ_n)$ \\\\\n        That is, no voter can get an outcome he strictly prefers by giving a\n        false input to $f$.\n      \\item A collection of preferences $\\succ_1,\\ldots,\\succ_n$,\n        has a Condorcet winner $x \\in M$ if, for any other $y\\in M$,\n        we have $x \\succ_i y$ for more than half of the indices\n        $i=1,\\ldots,n$\n    \\end{itemize}\n\n    Let $R(M)$ denote the set of all linear orders on $M$.\n    Recall that when $P = R(M)$, there are many known impossibility results,\n    the two most famous of which are:\n\n    \\begin{theorem}[Arrow's Impossibility Theorem \\cite{AgtBookMechDesignInto}]\n      If $|M| \\ge 3$, then\n      every unanimous social welfare function on $R(M)$\n      which satisfies independence of irrelevant alternatives is a dictatorship.\n    \\end{theorem}\n\n    \\begin{theorem}[Gibbard Satterthwaite \\cite{AgtBookMechDesignInto}]\n      If $|M| \\ge 3$, then\n      every surjective, incentive compatible social choice function on $R(M)$\n      is a dictatorship.\n    \\end{theorem}\n\n  \\subsection{Single-peaked preferences}\n    Our main point of contrast will be the well-understood class of\n    \\emph{single peaked} preferences.\n\n    Let $S\\subseteq [0,1]$ be a finite set of $m$ points in the unit interval.\n    We call $S$ the set of \\emph{outcomes}.\n    Let $R(S)$ denote the set of linear orders on $S$.\n    A preference $\\succ \\in R(S)$ is called \\emph{single peaked} if\n    there exists an outcome $p\\in S$ (called the ``peak'' of $\\succ$)\n    such that $x < y < p \\implies x \\prec y$ and $p < y < x \\implies x \\prec y$.\n    In other words, the preference has a favorite outcome,\n    and its opinion strictly decreases as you move farther away from the favorite.\n    Note that no assumption is made about outcomes on different sides of the peak.\n    Define\n\n    \\begin{align*}\n      P_{sp}(S) = \\{ \\succ \\in R(S) | \\succ \\text{is single peaked }\\} && \\ \n    \\end{align*}\n    \\begin{wrapfigure}{r}{0.3\\textwidth}\n      \\vspace{-0.75in}\n      \\begin{center}\n        \\includegraphics[width=0.3\\textwidth]{figures/defSP}\n      \\end{center}\n      \\caption{All single peaked preferences on $3$ outcomes}\n      \\label{fig:singlePeakedThree}\n    \\end{wrapfigure}\n\n    Single-peaked preferences are studied because the order structure on $S$\n    gives a natural voting mechanism: poll voters asking for their favorite\n    outcome, i.e. their peak, and output the median peak.\n    It is know that this voting scheme satisfies independence of irrelevant\n    alternatives (so Arrow's theorem does not hold\n    \\cite{AgtBookMechDesignInto}) and that this voting scheme is incentive\n    compatible (so Gibbard Satterthwaite does not hold \\cite{AgtBookNoMoney}).\n    As we will see, a voting scheme inspired by this will perform well for\n    $2$-dimensional preferences, achieving the same positive results as\n    single-peaked preferences.\n\n\\section{Single-peaked verses $2$-dimensional preferences}\n  \\label{sec:singleVsTwoD}\n\n  % TODO: at end, put this at start of whichever page makes the most sense\n\n  When there are exactly three outcomes, $2$-dimensional\n  preferences have strictly more expressive power than\n  single-peaked preferences.\n  \\begin{proposition}\n    Every single-peaked preference set on $m=3$ outcomes\n    is a $2$-dimensional preference set. In particular,\n    up to relabeling it is a subset of $P_2(X)$, for\n    $X = \\{ (3,0), (2,2), (0,3) \\}$.\n  \\end{proposition}\n  \\begin{proof}\n    Without loss of generality, relabel the outcomes\n    of the single peaked preferences as $S = \\{1,2,3\\}$.\n    The resulting preferences, as shown in figure~\\ref{fig:singlePeakedThree},\n    are given by {\\sc GoodCompromise}.\n  \\end{proof}\n  Furthermore, {\\sc BadCompromise} gives an example of a preference set\n  which is $2$-dimensional, but not single-peaked:\n  \\begin{proposition} \\label{prop:noLeastFavorite}\n    In a single peaked set of preferences, it is not possible\n    for every outcome to be the lowest ranked outcome of some preference.\n  \\end{proposition}\n  \\begin{proof}\n    The median outcome (via the standard order on $[0,1]$)\n    cannot be the lowest ranked.\n  \\end{proof}\n\n  \\begin{figure}[h]\n    \\centering\n    \\begin{subfigure}[t]{0.45\\textwidth}\n      \\begin{minipage}{0.55\\textwidth}\n        \\includegraphics[width=0.9\\textwidth]{figures/exGoodComp}\n      \\end{minipage}\\hfill\n      \\begin{minipage}{0.45\\textwidth}\n        \\begin{align*}\n          1 > 2 > 3 \\\\\n          2 > 1 > 3 \\\\\n          2 > 3 > 1 \\\\\n          3 > 2 > 1 \\\\\n        \\end{align*}\n      \\end{minipage}\n      \\caption{{\\sc GoodCompromise}}\n      \\label{fig:gull}\n    \\end{subfigure}\n    \\quad \\quad \\quad\n    \\begin{subfigure}[t]{0.45\\textwidth}\n      \\begin{minipage}{0.55\\textwidth}\n        \\includegraphics[width=0.9\\textwidth]{figures/exBadComp}\n      \\end{minipage}\\hfill\n      \\begin{minipage}{0.45\\textwidth}\n        \\begin{align*}\n          1 > 2 > 3 \\\\\n          1 > 3 > 2 \\\\\n          3 > 1 > 2 \\\\\n          3 > 2 > 1 \\\\\n        \\end{align*}\n      \\end{minipage}\n      \\caption{\\textsc{BadCompromise}}\n      \\label{fig:gull}\n    \\end{subfigure}\n  \\end{figure}\n\n  When $m>3$, neither single-peaked nor $2$-dimensional preferences\n  are a subset of the other. One way to see this is to simply\n  count the number of single-peaked preferences, and see that it\n  grows much faster with $m$ than $2$-dimensional preferences\n  (recall that we showed in theorem~\\ref{thrm:maxNumberTwoD}\n  that the maximal size of a $2$-dimensional\n  preference set is $O(m^2)$).\n  \\begin{proposition}\n    The number of single-peaked preferences for any set $S$ of $m$ outcomes\n    is at least $2^{\\Omega(m)}$\n  \\end{proposition}\n  \\begin{proof}\n    Choose the median outcome of $S$ to be the peak.\n    Given a subset $T\\subseteq [m-1]$ of size $|T| = \\lfloor m/2\\rfloor$,\n    we can associate a\n    unique single-peaked preference as follows:\n    treat the preference as an array of outcomes, ranked highest to lowest.\n    Put the median of $S$ at index $0$.\n    Let the outcomes to the left of the median occupy the indices corresponding\n    to set $T$, and let those to the right occupy the other indices.\n    There are ${m-1 \\choose \\lfloor m/2\\rfloor } \\ge 2^{\\Omega(m)}$ such\n    subsets $T$.\n  \\end{proof}\n\n  \\begin{wrapfigure}{r}{0.2\\textwidth}\n    \\centering\n    {\\textsc{FlipFlop}}\n    \\begin{align*}\n      1 > 2 > 3 > 4 \\\\\n      1 > 2 > 4 > 3 \\\\\n      2 > 1 > 3 > 4 \\\\\n      2 > 1 > 4 > 3 \\\\\n    \\end{align*}\n    \\vspace{-1in}\n  \\end{wrapfigure}\n\n  A cleaner, more constructive way to see this is the following proposition\n  \\begin{proposition}\n    The preference set {\\sc FlipFlop} is single-peaked, but not\n    $2$-dimensional.\n  \\end{proposition}\n  \\begin{proof}\n    To obtain a single-peaked representation, order the outcomes\n    from left to right as follows: $3,1,2,4$.\n    All preferences will then be possible with peak $1$ or $2$.\n\n    Now we show that {\\sc FlipFlop} is not $2$-dimensional.\n    Note that neither $1$ nor $2$ can dominate the other,\n    and the same holds for $3$ and $4$.\n    So let $a=\\indif(1,2)$ and $b=\\indif(3,4)$.\n    % Suppose $\\theta(a) < \\theta(b)$ (the other case is symmetric).\n    Without knowing the outcome space $X\\subseteq \\Rgz^2$,\n    we can't tell which side of $a$ corresponds to $1 > 2$\n    verses $2 > 1$ (same with $b$).\n    However, we do know that at least one of the following implications should\n    hold for any preference $>$ over $X$:\n    \\begin{align*}\n      1 > 2 \\implies 3 > 4\n      && 1 > 2 \\implies 4 > 3 &&\n      2 > 1 \\implies 3 > 4\n      && 2 > 1 \\implies 4 > 3\n    \\end{align*}\n    For example, if $\\theta(a) < \\theta(b)$ and preference weights with smaller\n    angle than $a$ (resp. $b$) favor $1 > 2$ (resp. $3 > 4$),\n    then $1 > 2 \\implies 3 > 4$.\n\n    However, none of these implications are satisfied by the entire preference\n    set {\\sc FlipFlop}. Thus {\\sc FlipFlop} cannot be $2$-dimensional.\n  \\end{proof}\n\n  When considering restricted domains of preference, it is perhaps more\n  important to consider which preference sets \\emph{do not} fall into that\n  domain. Indeed, if too many preferences are possible, then the impossibility\n  results which hold for arbitrary preferences will apply.\n\n  As we've directly shown, $3$-{\\sc Cycle} is not $2$ dimensional.\n  This is already a good sign: $3$-{\\sc Cycle} is a classic example of the\n  so-called Condorcet paradox. Despite each preference being a linear order,\n  the majority of voters favor $1$ over $2$, $2$ over $3$, and $3$ over $1$.\n  That is, ``collective preference'' is cyclic.\n  Indeed, $3$-{\\sc Cycle} is a preference set with no Condorcet winner,\n  and is often used as a basic counterexample for the existence of good voting\n  schemes. The fact that cycle is impossible already seems like good news for\n  voting schemes on two dimensional preferences.\n\n  Here's another case:\n  \\begin{proposition}\n    {\\sc Sandwich} is neither single-peaked nor $2$ dimensional\n  \\end{proposition}\n  \\begin{proof}\n    {\\sc Sandwich} is not single-peaked by proposition~\\ref{prop:noLeastFavorite}.\n    It's not $2$-dimensional by proposition~\\ref{prop:noAllBestWorst}.\n  \\end{proof}\n\n  \\begin{figure}[H]\n    \\begin{minipage}{0.15\\textwidth}\n      \\centering\n      {\\textsc{Reverse}}\n      \\begin{align*}\n        1 > 2 > 3 > 4 \\\\\n        4 > 3 > 2 > 1 \\\\\n      \\end{align*}\n    \\end{minipage}\\hfill\n    \\begin{minipage}{0.15\\textwidth}\n      \\centering\n      {$3$-\\textsc{Cycle}}\n      \\begin{align*}\n        1 > 2 > 3 \\\\\n        2 > 3 > 1 \\\\\n        3 > 1 > 2 \\\\\n      \\end{align*}\n    \\end{minipage}\\hfill\n    \\begin{minipage}{0.15\\textwidth}\n      \\centering\n      {\\textsc{Sandwich}}\n      \\begin{align*}\n        1 > 2 > 3 \\\\\n        1 > 3 > 2 \\\\\n        3 > 2 > 1 \\\\\n        2 > 3 > 1 \\\\\n      \\end{align*}\n    \\end{minipage}\\hfill\n    \\begin{minipage}{0.55\\textwidth}\n      \\centering\n      \\begin{tabular}{ r | l }\n        $2$-dimensional & {\\sc BadCompromise} \\\\\n        single peaked & {\\sc FlipFlop}, {\\sc NoRep} \\\\\n        both & {\\sc Reverse}, {\\sc GoodCompromise} \\\\\n        neither & $3$-{\\sc Cycle}, {\\sc Sandwich} \\\\\n      \\end{tabular}\n    \\end{minipage}\\hfill\n  \\end{figure}\n\n  The above discussion gives a fairly clear picture of the relationship between\n  $2$-dimensional and single-peaked preferences.\n  While single peaked and $2$-dimensional model noticeably different causes of\n  preferences, we argue that $2$-dimensional preferences are in some sense more\n  natural. The rest of this section gives some non-formal justification\n  for this highly subjective statement.\n\n  In the ``school ranking'' example given in the introduction, the preference of\n  students is determined by a single underlying attribute of the student:\n  their preference for STEM vs liberal arts.\n  In contrast, single-peaked preferences allow voters to have arbitrary\n  preferences about outcomes on either side of their peak.\n  Two voters with the same peak could have very different preference sets:\n  one could like all the points below the peak before any above the peak,\n  while the other could simply rank options by distance (for example,\n  usual real number distance) from the peak.\n  These two voters seem incompatible within the same underlying situation:\n  one has a sort of ``hard budget'' at its peak, while the other just\n  wants to get close to his favorite.\n  A common motivation given for single-peaked preferences is that of political\n  policy (with the familiar ``left and right'' manifest literally).\n  But why would a voter's favorite policy be the most liberal one which he does\n  not hate? This corresponds to the voter who prefers all outcomes right of his\n  peak to all those left of his peak.\n\n  Admitedly, for $m \\gg 3$, the size of single-peaked preference sets can be\n  much larger than that of $2$-dimensional preferences.\n  However, we believe that single-peaked preferences still miss certain well\n  motivated preference sets, without gaining much essential.\n  Indeed, the ordinal preference set {\\sc BadCompromise} models the intuitive\n  idea of a bad compromise very well: the ``compromise'' outcome $2$ is\n  no voter's favorite\\footnote{\n    Indeed, our voting scheme given in section~\\ref{sec:voting} will never\n    select outcome $2$ in this case!\n  }. However, single-peaked preferences such as {\\sc FlipFlop} have no obvious\n  interpretation, except for the voters making arbitrary decisions about\n  outcomes on different sides of their peak.\n\n\\section{Value restriction verses $2$-dimensional preferences}\n  \\label{sec:VRvsTwoD}\n\n  \\begin{figure}[H]\n    \\begin{minipage}{0.15\\textwidth}\n      \\centering\n      {\\textsc{MixedCompromise}}\n      \\begin{align*}\n        4 > 3 > 2 > 1 \\\\\n        1 > 2 > 3 > 4 \\\\\n        2 > 1 > 4 > 3 \\\\\n      \\end{align*}\n    \\end{minipage}\\hfill\n    \\begin{minipage}{0.15\\textwidth}\n      {\\textsc{NoRep}}\n      \\begin{align*}\n        3 > 2 > 1 > 4 \\\\\n        1 > 2 > 3 > 4 \\\\\n        2 > 1 > 4 > 3 \\\\\n      \\end{align*}\n      \\centering\n    \\end{minipage}\\hfill\n    \\begin{minipage}{0.15\\textwidth}\n      \\centering\n    \\end{minipage}\\hfill\n  \\end{figure}\n\n  With a slightly technical set of points, you can realize\n  {\\sc MixedCompromise} as a 2D, but neither single peaked nor single caved.\n  It isn't single caved, because each of outcome $1,2,3$ is some voter's\n  favorite among those three, and it's not single peaked, because among $2,3,4$\n  each outcome is some voter's least favorite.\n\n  We denote VR12 as the ``mixed union'' of single peaked and single troughed.\n\n\\section{Single-crossing verses $2$-dimensional preferences}\n  \\label{sec:crossVsTwoD}\n\n  Single-crossing preferences are almost equivalent to $2$-dimensional\n  preferences. ((EXPLAIN ORDERING, VOTER REPRESENTATION))\n\n  Here's a key example. The preference set {\\sc NoRep} is single peaked, with\n  outcomes ordered $3,2,1,4$ from left to right.\n  C.f. {\\sc MixedCompromise}. Furthermore, the ``majority\n  rule'' preference over {\\sc NoRep} is $2>1>3>4$, that is, with a single\n  voter for each preference of {\\sc NoRep}, the majority of voters agree with\n  each of the above preferences (and their transitive closure).\n  \\begin{proposition}\n    {\\sc NoRep} is not $2$-dimensional\n  \\end{proposition}\n  \\begin{proof}\n    Suppose for contradiction that the first preference is given by vector $a$,\n    the second by $b$, and the third by $c$.\n    Consider the $\\theta$ ordering relation between $a$, $b$, and $c$.\n    Observe the following:\n    \\begin{itemize}\n      \\item $a$ cannot be between $b$ and $c$, because $1 >_b 3$, $1 >_c 3$ \n        (and $2 >_b 3$, $2 >_c 3$).\n      \\item $b$ cannot be between $a$ and $c$, because $2 >_a 1$, $2 >_c 1$.\n      \\item $c$ cannot be between $a$ and $b$, because $3 >_a 4$, $3 >_b 4$.\n    \\end{itemize}\n  \\end{proof}\n\n\n\n\\section{Voting for $2$-dimensional preferences}\n  \\label{sec:voting}\n\n  Suppose the set of outcomes $X$ is known.\n  Taking inspiration from single-peaked preferences, we define the following\n  mechanism for voting:\n\n  \\begin{algorithm}\n    \\caption{Median-angle voting scheme}\n    Poll the preference weight $a_i\\in\\Rgz^d$ from each voter $i$ \\\\\n    Reorder the list $a_i$ by the $\\theta$ order, so \n      $\\theta(a_i) < \\theta(a_{i+1})$ \\\\\n    Return the favorite outcome of the median-angled preference weight\n  \\end{algorithm}\n\n  \\begin{figure}[h]\n    \\centering\n    \\begin{subfigure}[t]{0.3\\textwidth}\n      \\includegraphics[width=0.9\\textwidth]{figures/defMedianAngle}\n      \\caption{The median-angled preference vector}\n      \\label{fig:gull}\n    \\end{subfigure}\n    ~\n    \\begin{subfigure}[t]{0.3\\textwidth}\n      \\includegraphics[width=0.9\\textwidth]{figures/thrmIncentiveComp}\n      \\caption{Theorem~\\ref{thrm:2DincentiveCompat}}\n      \\label{fig:tiger}\n    \\end{subfigure}\n    ~\n    \\begin{subfigure}[t]{0.3\\textwidth}\n      \\includegraphics[width=0.9\\textwidth]{figures/thrmIIA}\n      \\caption{Theorems~\\ref{thrm:2DIIA} and~\\ref{thrm:2DCondorcet}}\n      \\label{fig:domHull}\n    \\end{subfigure}\n\n    \\caption{}\\label{fig:animals}\n  \\end{figure}\n\n  Intuitively, this seems like a promising voting scheme.\n  Preferences are more similar when angles are closer,\n  and preference angle gives a continuum between one extreme and the other.\n  Thus, the median voter is a natural choice to represent the population.\n  It turns out that the framework developed in Part I of this paper gives\n  simple proofs of many desirable properties for this voting rule.\n  These properties essentially tell us that $2$-dimensional preferences are at\n  least as well-behaved as single-peaked preferences.\n\n  Our first result states that a voter cannot strategically manipulate the\n  median-angle voting scheme, i.e. the Gibbard Satterthwaite theorem does not\n  hold for $2$-dimensional preferences.\n  \\begin{theorem}\\label{thrm:2DincentiveCompat}\n    Let the number of voters $n$ be odd.\n    The median-angle voting rule for $2$-dimensional preferences\n    is incentive compatible.\n  \\end{theorem}\n  \\begin{proof}\n    Consider any voter $i$ and suppose the voters true preferences \n    are given by weights $a_1,\\ldots,a_n$.\n    Let $u$ denote the median-angled preference vector chosen when all\n    agents report their true preference.\n    Suppose $\\theta(a_i) < \\theta(u)$ (the other case is symmetric).\n    The only way in which $i$ can change the median-angled preference vector\n    by misreporting his value for $a_i$\n    is to \\emph{increase} its angle, say to some $\\nu$.\n    Note that because $\\theta(a_i) < \\theta(u) < \\theta(\\nu)$,\n    we have $u \\in \\cone(a_i, \\nu)$.\n    % Consider any pair $x,y$ such that $x >_{a_i} y$ and $x >_\\nu y$,\n    % I.e. the manipulated median-angled preference weight agrees with voter $i$.\n\n    For the sake of contradiction, assume $i$ could profit from this\n    manipulation, i.e. he could get an outcome he favored chosen by $\\nu$.\n    Let $y$ be the outcome selected by $u$, and let $x$ be selected by $\\nu$.\n    We have $x >_\\nu y$ and $x >_{a_i} y$.\n    By proposition~\\ref{prop:conesAgreement}, we get $x >_u y$ as well.\n    However, this contradicts the assumption that $u$ selects $y$,\n    and completes our proof.\n  \\end{proof}\n\n  We also define the median-angle social welfare function in the obvious way: if\n  the median-angled preference vector is $u$,\n  return the linear order $(>_u) \\in P_2(X)$\n  Given this definition, we see that median-angled voting satisfies independence\n  of irrelevant alternatives, and thus Arrow's impossibility theorem does not\n  hold for $2$-dimensional preferences.\n\n  \\begin{theorem}\\label{thrm:2DIIA}\n    The median-angle social welfare function satisfies independence of irrelevant\n    alternatives.\n  \\end{theorem}\n  \\begin{proof}\n    Consider any pair of outcomes $x,y$. If either dominates the other, the\n    IIA axiom becomes easy to verify.\n    So suppose neither dominates the other, without loss of generality take\n    $x_1 < y_1$, $x_2 > y_2$, and let $b = \\indif(x,y)$.\n\n    Suppose $\\{a_i\\}$ and $\\{a_i'\\}$ are collections of preference weights such\n    that $x>_{a_i} y \\iff x>_{a_i'} y$ for each $i$.\n    By proposition \\ref{prop:compEqualizerAngle},\n    this means that $\\theta(a_i) > \\theta(b) \\iff \\theta(a_i') > \\theta(b)$.\n    Let $u$ denote the median-angled vector among $\\{a_i\\}$,\n    and $u'$ for $\\{a_i'\\}$.\n    Because each pair $a_i, a_i'$ lies on the same side of $b$,\n    we must have $u$ and $u'$ on the same side of $b$ as well.\n    Thus, $x >_u y \\iff x >_{u'} y$, as desired.\n  \\end{proof}\n\n  The next theorem justifies median-angle voting as \\emph{the} natural\n  voting scheme for $2$-dimensional preferences, using the notion of a Condorcet\n  winner.\n  \\begin{theorem}\\label{thrm:2DCondorcet}\n    Among an odd number of $2$-dimensional preferences,\n    there is always a Condorcet winner, which is selected\n    by the median angle voting scheme\n  \\end{theorem}\n  \\begin{proof}\n    Let $u$ be the median-angled preference vector, and let\n    $x$ be the favorite outcome of $u$.\n    Given some outcome $y\\ne x$, if $y \\ll x$, then\n    $y$ is never preferred to $x$.\n    So suppose neither $x$ nor $y$ dominate each other, and let\n    $b = \\indif(x,y)$.\n    Let $S$ be the set of preference weights $a$ such that $x>_a y$.\n    By proposition~\\ref{prop:compEqualizerAngle}, $S$ either consists of all vectors\n    $a$ with $\\theta(a) > \\theta(b)$ or all $a$ with $\\theta(a) < \\theta(b)$.\n    Because $x >_u y$,\n    the median angled preference weight $u$ must lie in $S$.\n    Thus, more than half of all the input preference weights must lie in $S$.\n    Thus, more than half of the input preferences agree that $x > y$.\n    Because $y$ was arbitrary, this means $x$ is the Condorcet winner.\n  \\end{proof}\n\n  We note the following important consequence of the previous theorem:\n  if preferences are known to lie in $P_2(X)$ for some $X$,\n  but no details about $X$ are known, then a voting protocol can simply\n  ask voters for their list of preferences and look for the Condorcet\n  winner (note that there is at most one Condorcet winner).\n  While it is not immediate that this rule is incentive compatible\\footnote{\n    This is because it's possible for a manipulative agent to report a\n    preference list which is not two dimensional with respect to the set $X$.\n    It's possible for such a manipulator to cause there to be no Condorcet\n    winner (for example, the preference $1 > 2 > 3$ and $2 > 3 > 1$\n    are certainly two dimensional, so the manipulator could report $3 > 1 > 2$\n    and create $3$-{\\sc Cycle}).\n    We conjecture that a single manipulator cannot \\emph{change} the Condorcet\n    winner, i.e. the manipulated preference set cannot have a Condorcet winner\n    different than the original one, but proving this result requires a bit more\n    thought.\n  } this still gives a good voting rule for honest agents with two dimensional\n  preferences.\n  % Moreover, it hints that when agents act approximately via a weighted\n  % sum of two attributes, it is more likely that there is a Condorcet winner.\n  % ((NOTE: CONTEMPLATE THE FOLLOWING HOLE IN THE ABOVE LOGIC:\n  % WHAT IF AN AGENT STRATEGICALLY REPORTS A PREFERENCE THAT IS NOT TWO\n  % DIMENSIONAL FOR THE UNDERLYING SET X. FOR ONE, THE AGENT MY FORCE THE\n  % PROCEDURE TO FAIL BECAUSE IT WON'T HAVE A CONDORCET WINNER. BUT AD HOC \n  % WE DON'T KNOW HE CAN'T MANIPULATE THE CONDORCET WINNER))\n\n  \\bibliography{weightedPref}{}\n  \\bibliographystyle{alpha}\n\\end{document}\n", "meta": {"hexsha": "e6fe8c7d75befb89efbf97ad2b9f8867d57152dd", "size": 55875, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/voting.tex", "max_stars_repo_name": "ClathomasPrime/linear-prefs", "max_stars_repo_head_hexsha": "e700589a82667ca0f307459816e4f5b211fbd7d2", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/voting.tex", "max_issues_repo_name": "ClathomasPrime/linear-prefs", "max_issues_repo_head_hexsha": "e700589a82667ca0f307459816e4f5b211fbd7d2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/voting.tex", "max_forks_repo_name": "ClathomasPrime/linear-prefs", "max_forks_repo_head_hexsha": "e700589a82667ca0f307459816e4f5b211fbd7d2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.4486780715, "max_line_length": 86, "alphanum_fraction": 0.6621565996, "num_tokens": 16793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.4497767165493473}}
{"text": "%\\documentclass[10pt]{beamer} % aspect ratio 4:3, 128 mm by 96 mm\n\\documentclass[10pt,aspectratio=169]{beamer} % aspect ratio 16:9\n\\graphicspath{{../../figures/}}\n%\\includeonlyframes{framezero,frameone,frametwo,framethree}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Packages\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\usepackage{appendixnumberbeamer}\n\\usepackage{booktabs}\n\\usepackage[scale=2]{ccicons}\n\\usepackage{pgfplots}\n\\usepackage{xspace}\n\\usepackage{amsmath}\n\\usepackage{totcount}\n\\usepackage{tikz}\n%\\usepackage{comment}\n%\\usetikzlibrary{external} % speedup compilation\n%\\tikzexternalize % activate!\n%\\usetikzlibrary{shapes,arrows}  \n\n%\\usepackage{bibentry}\n%\\nobibliography*\n\\usepackage{caption}%\n\\captionsetup[figure]{labelformat=empty}%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Metropolis theme custom modification file\n\\input{metropolis_mods.tex}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Custom commands\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% matrix command \n\\newcommand{\\matr}[1]{\\mathbf{#1}} % bold upright (Elsevier, Springer)\n%\\newcommand{\\matr}[1]{#1}          % pure math version\n%\\newcommand{\\matr}[1]{\\bm{#1}}     % ISO complying version\n% vector command \n\\newcommand{\\vect}[1]{\\mathbf{#1}} % bold upright (Elsevier, Springer)\n% derivative upright command\n\\DeclareRobustCommand*{\\drv}{\\mathop{}\\!\\mathrm{d}}\n% \n\\newcommand{\\themename}{\\textbf{\\textsc{metropolis}}\\xspace}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%  Title page options\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \\date{\\today}\n\\date{}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% option 1\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\title{Elastic constants identification of composite laminates by using Lamb wave dispersion curves and optimization methods}\n\\subtitle{Lamb-opt}\n\\author{\\textbf{Paweł Kudela}\\\\Maciej Radzieński \\\\Tomasz Wandowski \\\\Piotr Fiborek}\n% logo align to Institute \n\\institute{Institute of Fluid Flow Machinery\\\\Polish Academy of Sciences \\\\ \\vspace{-1.5cm}\\flushright \\includegraphics[width=4cm]{../images/logo/logo_eng_40mm.eps}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% option 2 - authors in one line\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\t\\title{Elastic constants identification of composite laminates by using Lamb wave dispersion curves and optimization methods}\n%\t\\subtitle{Lamb-opt}\n%\t\\author{\\textbf{Paweł Kudela}\\textsuperscript{2}, Maciej Radzieński\\textsuperscript{2}, Wiesław Ostachowicz\\textsuperscript{2}, Zhibo Yang\\textsuperscript{1} }\n%\t% logo align to Institute \n%\t\\institute{\\textsuperscript{1}Xi'an Jiaotong University \\\\ \\textsuperscript{2}Institute of Fluid Flow Machinery\\\\ \\hspace*{1pt} Polish Academy of Sciences \\\\ \\vspace{-1.5cm}\\flushright \\includegraphics[width=4cm]{../images/logo/logo_eng_40mm.eps}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% option 3 - multilogo vertical\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\title{Elastic constants identification of composite laminates by using Lamb wave dispersion curves and optimization methods}\n%\\subtitle{Lamb-opt}\n%\t\\author{\\textbf{Paweł Kudela}\\inst{1}, Maciej Radzieński\\inst{1}, Wiesław Ostachowicz\\inst{1}, Zhibo Yang\\inst{2} }\n%\t% logo under Institute \n%\t\\institute%\n%\t{ \n%\t\t\\inst{1}%\n%\t\tInstitute of Fluid Flow Machinery\\\\ \\hspace*{1pt} Polish Academy of Sciences \\\\ \\includegraphics[height=0.85cm]{../images/logo/logo_eng_40mm.eps} \\\\\n%\t\t\\and\n%\t\t\\inst{2}%\n%\t    Xi'an Jiaotong University \\\\ \\includegraphics[height=0.85cm]{../images/logo/logo_box.eps}\n%    }\n% end od option 3\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% option 4 - 3 Institutes and logos horizontal centered\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\title{Elastic constants identification of composite laminates by using Lamb wave dispersion curves and optimization methods}\n%\\subtitle{Lamb-opt }\n%\\author{\\textbf{Paweł Kudela}\\textsuperscript{1}, Maciej Radzieński\\textsuperscript{1}, Marco Miniaci\\textsuperscript{2}, Zhibo Yang\\textsuperscript{3} }\n%\n%\\institute{ \n%\\begin{columns}[T,onlytextwidth]\n%\t\\column{0.39\\textwidth}\n%\t\\begin{center}\n%\t\t\\textsuperscript{1}Institute of Fluid Flow Machinery\\\\ \\hspace*{3pt}Polish Academy of Sciences\n%\t\\end{center}\n%\t\\column{0.3\\textwidth}\n%\t\\begin{center}\n%\t\t\\textsuperscript{2}Zurich University\n%\t\\end{center}\n%\t\\column{0.3\\textwidth}\n%\t\\begin{center}\n%\t\t\\textsuperscript{3}Xi'an Jiaotong University\n%\t\\end{center}\n%\\end{columns}\n%\\vspace{6pt}\n%% logos \n%\\begin{columns}[b,onlytextwidth]\n%\t\\column{0.39\\textwidth}\n%\t\t\\centering \n%\t\t\\includegraphics[width=\\mywidth,height=0.85cm,keepaspectratio]{../images/logo/logo_eng_40mm.eps}\n%\t\\column{0.3\\textwidth}\n%\t\t\\centering \n%\t\t\\includegraphics[width=\\mywidth,height=0.85cm,keepaspectratio]{../images/logo/logo_box.eps}\n%\t\\column{0.3\\textwidth}\n%\t\t\\centering \n%\t\t\\includegraphics[width=\\mywidth,height=0.85cm,keepaspectratio]{../images/logo/logo_box2.eps}\n%\\end{columns}\n%}\n%\\makeatletter\n%\\setbeamertemplate{title page}{\n%\t\\begin{minipage}[b][\\paperheight]{\\textwidth}\n%\t\t\\centering  % <-- Center here\n%\t\t\\ifx\\inserttitlegraphic\\@empty\\else\\usebeamertemplate*{title graphic}\\fi\n%\t\t\\vfill%\n%\t\t\\ifx\\inserttitle\\@empty\\else\\usebeamertemplate*{title}\\fi\n%\t\t\\ifx\\insertsubtitle\\@empty\\else\\usebeamertemplate*{subtitle}\\fi\n%\t\t\\usebeamertemplate*{title separator}\n%\t\t\\ifx\\beamer@shortauthor\\@empty\\else\\usebeamertemplate*{author}\\fi\n%\t\t\\ifx\\insertdate\\@empty\\else\\usebeamertemplate*{date}\\fi\n%\t\t\\ifx\\insertinstitute\\@empty\\else\\usebeamertemplate*{institute}\\fi\n%\t\t\\vfill\n%\t\t\\vspace*{1mm}\n%\t\\end{minipage}\n%}\n%\n%\\setbeamertemplate{title}{\n%\t%  \\raggedright%  % <-- Comment here\n%\t\\linespread{1.0}%\n%\t\\inserttitle%\n%\t\\par%\n%\t\\vspace*{0.5em}\n%}\n%\\setbeamertemplate{subtitle}{\n%\t%  \\raggedright%  % <-- Comment here\n%\t\\insertsubtitle%\n%\t\\par%\n%\t\\vspace*{0.5em}\n%}\n%\\makeatother\n% end of option 4\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% option 5 - 2 Institutes and logos horizontal centered\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\title{Elastic constants identification of composite laminates by using Lamb wave dispersion curves and optimization methods}\n%\\subtitle{Lamb-opt }\n%\\author{\\textbf{Paweł Kudela}\\textsuperscript{1}, Maciej Radzieński\\textsuperscript{1}, Marco Miniaci\\textsuperscript{2}}\n%\n%\\institute{ \n%\t\\begin{columns}[T,onlytextwidth]\n%\t\t\\column{0.5\\textwidth}\n%\t\t\t\\centering\n%\t\t\t\\textsuperscript{1}Institute of Fluid Flow Machinery\\\\ \\hspace*{3pt}Polish Academy of Sciences\n%\t\t\\column{0.5\\textwidth}\n%\t\t\t\\centering\n%\t\t\t\\textsuperscript{2}Zurich University\n%\t\\end{columns}\n%\t\\vspace{6pt}\n%\t% logos \n%\t\\begin{columns}[b,onlytextwidth]\n%\t\t\\column{0.5\\textwidth}\n%\t\t\\centering \n%\t\t\\includegraphics[width=\\mywidth,height=0.85cm,keepaspectratio]{../images/logo/logo_eng_40mm.eps}\n%\t\t\\column{0.5\\textwidth}\n%\t\t\\centering \n%\t\t\\includegraphics[width=\\mywidth,height=0.85cm,keepaspectratio]{../images/logo/logo_box.eps}\n%\t\\end{columns}\n%}\n%\\makeatletter\n%\\setbeamertemplate{title page}{\n%\t\\begin{minipage}[b][\\paperheight]{\\textwidth}\n%\t\t\\centering  % <-- Center here\n%\t\t\\ifx\\inserttitlegraphic\\@empty\\else\\usebeamertemplate*{title graphic}\\fi\n%\t\t\\vfill%\n%\t\t\\ifx\\inserttitle\\@empty\\else\\usebeamertemplate*{title}\\fi\n%\t\t\\ifx\\insertsubtitle\\@empty\\else\\usebeamertemplate*{subtitle}\\fi\n%\t\t\\usebeamertemplate*{title separator}\n%\t\t\\ifx\\beamer@shortauthor\\@empty\\else\\usebeamertemplate*{author}\\fi\n%\t\t\\ifx\\insertdate\\@empty\\else\\usebeamertemplate*{date}\\fi\n%\t\t\\ifx\\insertinstitute\\@empty\\else\\usebeamertemplate*{institute}\\fi\n%\t\t\\vfill\n%\t\t\\vspace*{1mm}\n%\t\\end{minipage}\n%}\n%\n%\\setbeamertemplate{title}{\n%\t%  \\raggedright%  % <-- Comment here\n%\t\\linespread{1.0}%\n%\t\\inserttitle%\n%\t\\par%\n%\t\\vspace*{0.5em}\n%}\n%\\setbeamertemplate{subtitle}{\n%\t%  \\raggedright%  % <-- Comment here\n%\t\\insertsubtitle%\n%\t\\par%\n%\t\\vspace*{0.5em}\n%}\n%\\makeatother\n% end of option 5\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%  End of title page options\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% logo option - alternative manual insertion by modification of coordinates in \\put()\n%\\titlegraphic{%\n%\t%\\vspace{\\logoadheight}\n%\t\\begin{picture}(0,0)\n%\t\\put(305,-185){\\makebox(0,0)[rb]{\\includegraphics[width=4cm]{../images/logo/logo_eng_40mm.eps}}}\n%\t\\end{picture}}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\AtBeginDocument{%\n\t% 16:9 setup\n\t%correcting caption placement and figure widths\n\t\\def\\myindenta{0.26\\textwidth}\n\t\\def\\myindentb{0.05\\textwidth}\n\t\\def\\myindentc{0.23\\textwidth}\n\t\\def\\mywidtha{0.4\\textwidth} \n\t\\def\\mywidthb{0.65\\textwidth}\n\t\\def\\mywidthc{0.8\\textwidth} \n\t\n\t% 4:3 setup\n%\t\\def\\myindenta{0.26\\textwidth} \n%\t\\def\\myindentb{0.05\\textwidth}\n%\t\\def\\myindentc{0.12\\textwidth} \n%\t\\def\\mywidtha{0.5\\textwidth}  \n%\t\\def\\mywidthb{0.86\\textwidth}\n%\t\\def\\mywidthc{\\textwidth}\n}%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\maketitle\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% SLIDES\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Table of contents}\n  \\setbeamertemplate{section in toc}[sections numbered]\n  \\tableofcontents[hideallsubsections]\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Introduction}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[fragile,label=framezero]{Metropolis}\n\n  The \\themename theme is a Beamer theme with minimal visual noise\n  inspired by the \\href{https://github.com/hsrmbeamertheme/hsrmbeamertheme}{\\textsc{hsrm} Beamer\n  Theme} by Benjamin Weiss.\n\n  Enable the theme by loading\n\n  \\begin{verbatim}    \\documentclass{beamer}\n    \\usetheme{metropolis}\\end{verbatim}\n\n  Note, that you have to have Mozilla's \\emph{Fira Sans} font and XeTeX\n  installed to enjoy this wonderful typography.\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[fragile]{Sections}\n  Sections group slides of the same topic\n\n  \\begin{verbatim}    \\section{Elements}\\end{verbatim}\n\n  for which \\themename provides a nice progress indicator \\ldots\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Title formats}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Metropolis titleformats}\n\t\\themename supports 4 different titleformats:\n\t\\begin{itemize}\n\t\t\\item Regular\n\t\t\\item \\textsc{Smallcaps}\n\t\t\\item \\textsc{allsmallcaps}\n\t\t\\item ALLCAPS\n\t\\end{itemize}\n\tThey can either be set at once for every title type or individually.\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{\n   % \\metroset{titleformat frame=smallcaps}\n\\begin{frame}{Small caps}\n\tThis frame uses the \\texttt{smallcaps} titleformat.\n\n\t\\begin{alertblock}{Potential Problems}\n\t\tBe aware, that not every font supports small caps. If for example you typeset your presentation with pdfTeX and the Computer Modern Sans Serif font, every text in smallcaps will be typeset with the Computer Modern Serif font instead.\n\t\\end{alertblock}\n\\end{frame}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{\n%\\metroset{titleformat frame=allsmallcaps}\n\\begin{frame}{All small caps}\n\tThis frame uses the \\texttt{allsmallcaps} titleformat.\n\n\t\\begin{alertblock}{Potential problems}\n\t\tAs this titleformat also uses smallcaps you face the same problems as with the \\texttt{smallcaps} titleformat. Additionally this format can cause some other problems. Please refer to the documentation if you consider using it.\n\n\t\tAs a rule of thumb: Just use it for plaintext-only titles.\n\t\\end{alertblock}\n\\end{frame}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{\n%\\metroset{titleformat frame=allcaps}\n\\begin{frame}{All caps}\n\tThis frame uses the \\texttt{allcaps} titleformat.\n\n\t\\begin{alertblock}{Potential Problems}\n\t\tThis titleformat is not as problematic as the \\texttt{allsmallcaps} format, but basically suffers from the same deficiencies. So please have a look at the documentation if you want to use it.\n\t\\end{alertblock}\n\\end{frame}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Elements}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[fragile]{Typography}\n      \\begin{verbatim}The theme provides sensible defaults to\n\\emph{emphasize} text, \\alert{accent} parts\nor show \\textbf{bold} results.\\end{verbatim}\n\n  \\begin{center}becomes\\end{center}\n\n  The theme provides sensible defaults to \\emph{emphasize} text,\n  \\alert{accent} parts or show \\textbf{bold} results.\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Font feature test}\n  \\begin{itemize}\n    \\item Regular\n    \\item \\textit{Italic}\n    \\item \\textsc{SmallCaps}\n    \\item \\textbf{Bold}\n    \\item \\textbf{\\textit{Bold Italic}}\n    \\item \\textbf{\\textsc{Bold SmallCaps}}\n    \\item \\texttt{Monospace}\n    \\item \\texttt{\\textit{Monospace Italic}}\n    \\item \\texttt{\\textbf{Monospace Bold}}\n    \\item \\texttt{\\textbf{\\textit{Monospace Bold Italic}}}\n  \\end{itemize}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Lists}\n  \\begin{columns}[T,onlytextwidth]\n    \\column{0.33\\textwidth}\n      Items\n      \\begin{itemize}\n        \\item Milk \\item Eggs \\item Potatos\n      \\end{itemize}\n\n    \\column{0.33\\textwidth}\n      Enumerations\n      \\begin{enumerate}\n        \\item First, \\item Second and \\item Last.\n      \\end{enumerate}\n\n    \\column{0.33\\textwidth}\n      Descriptions\n      \\begin{description}\n        \\item[PowerPoint] Meeh. \\item[Beamer] Yeeeha.\n      \\end{description}\n  \\end{columns}\n\\end{frame}\n\\begin{frame}{Animation}\n  \\begin{itemize}[<+- | alert@+>]\n    \\item \\alert<4>{This is\\only<4>{ really} important}\n    \\item Now this\n    \\item And now this\n  \\end{itemize}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t]{SASE dispersion curves: density influence}\n\\vspace{-12pt} % 16:9\n\\begin{columns}[T]\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE2}\n\t\t\\begin{figure}\n\t\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{0}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{15}$^{\\circ}$ }\n\t\t\t}\n\t\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{30}$^{\\circ}$ }\n\t\t\t}\n\t\t    \\only<4>{\n\t\t    \t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t    \t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{45}$^{\\circ}$ }\n\t\t    }\n\t    \t\\only<5>{\n\t    \t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t    \t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{60}$^{\\circ}$ }\n\t    \t}\n    \t\t\\only<6>{\n    \t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n    \t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{75}$^{\\circ}$ }\n    \t\t}\n    \t\t\\only<7->{\n    \t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n    \t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{matrix density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{90}$^{\\circ}$ }\n    \t\t}\n\t\t\t\\label{fig:rhom}\n\t\t\\end{figure}\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE3}\n\t\t\\begin{figure}\n\t\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{0}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{15}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<3>{\n\t\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{30}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<4>{\n\t\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{45}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<5>{\n\t\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{60}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<6>{\n\t\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{75}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\only<7->{\n\t\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{fibre density}\\\\ \\hspace{\\myindentc}on dispersion curves at angle \\textbf{90}$^{\\circ}$}\n\t\t\t}\n\t\t\t\\label{fig:rhof}\n\t\t\\end{figure}\n\\end{columns}\n\t\\only<8>{\n\t\\begin{alertblock}{Remarks}\n\t\t\\textbf{Fibres density} has slightly more influence on dispersion curves than \\textbf{matrix density}.\n\t\\end{alertblock}\n\t}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t]{SASE dispersion curves: Young modulus influence}\n\\vspace{-12pt} % 16:9\n\\begin{columns}[T]\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE4}\n\t\\begin{figure}\n\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{0}$^{\\circ}$}\n\t\t}\n\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{15}$^{\\circ}$ }\n\t\t}\n\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{30}$^{\\circ}$ }\n\t\t}\n\t\t\\only<4>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{45}$^{\\circ}$ }\n\t\t}\n\t\t\\only<5>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{60}$^{\\circ}$ }\n\t\t}\n\t\t\\only<6>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{75}$^{\\circ}$ }\n\t\t}\n\t\t\\only<7->{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{90}$^{\\circ}$ }\n\t\t}\n\t\t\\label{fig:em}\n\t\\end{figure}\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE5}\n\t\\begin{figure}\n\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{0}$^{\\circ}$}\n\t\t}\n\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{15}$^{\\circ}$}\n\t\t}\n\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{30}$^{\\circ}$}\n\t\t}\n\t\t\\only<4>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{45}$^{\\circ}$}\n\t\t}\n\t\t\\only<5>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{60}$^{\\circ}$}\n\t\t}\n\t\t\\only<6>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{75}$^{\\circ}$}\n\t\t}\n\t\t\\only<7->{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Young's modulus}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{90}$^{\\circ}$}\n\t\t}\n\t\t\\label{fig:ef}\n\t\\end{figure}\n\\end{columns}\n\\only<8>{\n\t\\begin{alertblock}{Remarks}\n\t\t\\textbf{Young's modulus of matrix} has much more influence on dispersion curves than \\textbf{Young's modulus of fibres}.\n\t\\end{alertblock}\n}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t,label=framethree]{SASE dispersion curves: Poisson's ratio influence}\n\\vspace{-12pt} % 16:9\n\\begin{columns}[T]\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE6}\n\t\\begin{figure}\n\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{0}$^{\\circ}$}\n\t\t}\n\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{15}$^{\\circ}$ }\n\t\t}\n\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{30}$^{\\circ}$ }\n\t\t}\n\t\t\\only<4>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{45}$^{\\circ}$ }\n\t\t}\n\t\t\\only<5>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{60}$^{\\circ}$ }\n\t\t}\n\t\t\\only<6>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{75}$^{\\circ}$ }\n\t\t}\n\t\t\\only<7->{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of matrix} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{90}$^{\\circ}$ }\n\t\t}\n\t\t\\label{fig:nim}\n\t\\end{figure}\n\t\\column{0.5\\textwidth}\n\t\\newcommand{\\modelname}{SASE7}\n\t\\begin{figure}\n\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{0}$^{\\circ}$}\n\t\t}\n\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{15}$^{\\circ}$}\n\t\t}\n\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{30}$^{\\circ}$}\n\t\t}\n\t\t\\only<4>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{45}$^{\\circ}$}\n\t\t}\n\t\t\\only<5>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{60}$^{\\circ}$}\n\t\t}\n\t\t\\only<6>{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{75}$^{\\circ}$}\n\t\t}\n\t\t\\only<7->{\n\t\t\t\\includegraphics[width=\\mywidthc]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindentc}The influence of \\alert{Poisson's ratio}\\\\ \\hspace{\\myindentc}\\alert{of fibres} on dispersion curves at\\\\ \\hspace{\\myindentc}angle \\textbf{90}$^{\\circ}$}\n\t\t}\n\t\t\\label{fig:nif}\n\t\\end{figure}\n\\end{columns}\n\\only<8>{\n\t\\begin{alertblock}{Remarks}\n\t\t\\textbf{Poisson's ratio of fibres} is the least influential parameter on dispersion curves among investigated parameters.\n\t\\end{alertblock}\n}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t,label=frameone]{SASE dispersion curves: volume fraction influence}\n\\vspace{-12pt} % 16:9\n\\newcommand{\\modelname}{SASE8}\n\t\\begin{figure}\n\t\t\\only<1>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_0_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{0}$^{\\circ}$}\n\t\t}\n\t\t\\only<2>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_15_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{15}$^{\\circ}$ }\n\t\t}\n\t\t\\only<3>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_30_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{30}$^{\\circ}$ }\n\t\t}\n\t\t\\only<4>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_45_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{45}$^{\\circ}$ }\n\t\t}\n\t\t\\only<5>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_60_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{60}$^{\\circ}$ }\n\t\t}\n\t\t\\only<6>{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_75_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{75}$^{\\circ}$ }\n\t\t}\n\t\t\\only<7->{\n\t\t\t\\includegraphics[width=\\mywidtha]{SASE/\\modelname_out/\\modelname_angle_90_param_dispersion_curves.png}\n\t\t\t\\caption{\\hspace{\\myindenta}The influence of \\alert{volume fraction of reinforcing fibres}\\\\ \\hspace{\\myindenta}on dispersion curves at angle \\textbf{90}$^{\\circ}$ }\n\t\t}\n\t\t\\label{fig:vol}\n\t\\end{figure}\n\n\\only<8>{\n\t\\begin{alertblock}{Remarks}\n\t\t\\textbf{Volume fraction} of reinforcing fibres is the most influential parameter on dispersion curves among investigated parameters.\n\t\\end{alertblock}\n}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t,label=frametwo]{Comparison of numerical and experimental dispersion curves}\n\\newcommand{\\modelname}{SASE1}\n\\begin{figure}\n\t\\only<1>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_0_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{0}$^{\\circ}$}\n\t}\n\t\\only<2>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_15_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{15}$^{\\circ}$ }\n\t}\n\t\\only<3>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_30_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{30}$^{\\circ}$ }\n\t}\n\t\\only<4>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_45_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{45}$^{\\circ}$ }\n\t}\n\t\\only<5>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_60_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{60}$^{\\circ}$ }\n\t}\n\t\\only<6>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_75_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{75}$^{\\circ}$ }\n\t}\n\t\\only<7>{\n\t\t\\includegraphics[width=\\mywidthb]{SASE/\\modelname_out/\\modelname_25_angle_90_num_exp_dispersion.png}\n\t\t\\caption{\\hspace{\\myindentb}Comparison of numerical and experimental dispersion curves at angle \\textbf{90}$^{\\circ}$ }\n\t}\n\t\\label{fig:numexp}\n\\end{figure}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Tables}\n  \\begin{table}\n    \\caption{Largest cities in the world (source: Wikipedia)}\n    \\begin{tabular}{lr}\n      \\toprule\n      City & Population\\\\\n      \\midrule\n      Mexico City & 20,116,842\\\\\n      Shanghai & 19,210,000\\\\\n      Peking & 15,796,450\\\\\n      Istanbul & 14,160,467\\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Tables cd}\n\\begin{table}\n\t\\label{tab:mat_prop}\n\t\\renewcommand{\\arraystretch}{1.3}\n\t\\centering \\footnotesize\n\t\\caption{Initial material properties of composite laminate.}\n\t\\begin{tabular}{ccccccc} \n\t\t\\toprule\n\t\t\\multicolumn{3}{c}{\\textbf{Matrix} }\t& \\multicolumn{3}{c}{\\textbf{Fibres} } & \\textbf{Volume fraction}\t \\\\ \n\t\t\\midrule\n\t\t$\\rho_m$ & $E_m$ & $\\nu_m$  & $\\rho_f$ & $E_f$ & $\\nu_f$ & $V$\\\\\n\t\tkg/m\\textsuperscript{3} &GPa& --  & kg/m\\textsuperscript{3}  & GPa& -- & \\%\\\\ \n\t\t\\cmidrule(lr){1-3} \\cmidrule(lr){4-6} \\cmidrule(lr){7-7}\n\t\t1250 &3.43& 0.35& 1900 & 240 & 0.2 & 50\\\\\n\t\t\\bottomrule \n\t\\end{tabular} \n\\end{table}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Blocks}\n  Three different block environments are pre-defined and may be styled with an\n  optional background color.\n\n  \\begin{columns}[T,onlytextwidth]\n    \\column{0.5\\textwidth}\n      \\begin{block}{Default}\n        Block content.\n      \\end{block}\n\n      \\begin{alertblock}{Alert}\n        Block content.\n      \\end{alertblock}\n\n      \\begin{exampleblock}{Example}\n        Block content.\n      \\end{exampleblock}\n\n    \\column{0.5\\textwidth}\n\n     % \\metroset{block=fill}\n\n      \\begin{block}{Default}\n        Block content.\n      \\end{block}\n\n      \\begin{alertblock}{Alert}\n        Block content.\n      \\end{alertblock}\n\n      \\begin{exampleblock}{Example}\n        Block content.\n      \\end{exampleblock}\n\n  \\end{columns}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Math}\nHere is text \\cite{knuth92}\n%\\citetitle{knuth92}\n  \\begin{equation*}\n    e = \\lim_{n\\to \\infty} \\left(1 + \\frac{1}{n}\\right)^n\n  \\end{equation*}\n  \\begin{equation*}\n \t \\begin{aligned}\n  \t\t\\matr{A} & =  k^2\\left(s^2 \\,\\matr{K}_{22} + c^2\\, \\matr{K}_{33} - c s\\, \\matr{K}_{23} - c s\\, \\matr{K}_{32}\\right) \\\\\n  \t\t& + i k\\, \\matr{T}^T\\left(-c\\, \\matr{K}_{13} - s\\, \\matr{K}_{21} + s\\, \\matr{K}_{12} + c\\, \\matr{K}_{31}\\right) \\matr{T} +\\matr{K}_{11},\n  \t\\end{aligned}\n  \\end{equation*}\n \\begin{equation}\n  \\frac{\\drv\\vect{P}_k^-}{\\drv t}=\\vect{F}_x(\\vect{m}_k^-(t),t,\\vect{\\theta})\\vect{P}_k^- +\\vect{P}_k^- \\vect{F}_x^T(\\vect{m}_k^-(t),t,\\vect{\\theta}) + \\Sigma(\\vect{m}_k^-(t),t,\\vect{\\theta})\n \\label{eq:Euler}\n\\end{equation}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Line plots}\nFigure can be integrated by using tikzpicture environment or directly by includegraphics \n  \\begin{figure}\n    \\begin{tikzpicture}\n      \\begin{axis}[\n        mlineplot, % metropolis style\n        width=0.9\\textwidth,\n        height=6cm,\n      ]\n\n        \\addplot {sin(deg(x))};\n        \\addplot+[samples=100] {sin(deg(2*x))};\n\n      \\end{axis}\n    \\end{tikzpicture}\n  \\end{figure}\n\\end{frame}\n\\begin{frame}{Bar charts}\n  \\begin{figure}\n    \\begin{tikzpicture}\n      \\begin{axis}[\n        mbarplot,\n        xlabel={Foo},\n        ylabel={Bar},\n        width=0.9\\textwidth,\n        height=6cm,\n      ]\n\n      \\addplot plot coordinates {(1, 20) (2, 25) (3, 22.4) (4, 12.4)};\n      \\addplot plot coordinates {(1, 18) (2, 24) (3, 23.5) (4, 13.2)};\n      \\addplot plot coordinates {(1, 10) (2, 19) (3, 25) (4, 15.2)};\n\n      \\legend{lorem, ipsum, dolor}\n\n      \\end{axis}\n    \\end{tikzpicture}\n  \\end{figure}\n\\end{frame}\n\\begin{frame}{Quotes}\n  \\begin{quote}\n    Veni, Vidi, Vici\n  \\end{quote}\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{%\n\\setbeamertemplate{frame footer}{My custom footer}\n\\begin{frame}[fragile]{Frame footer}\n    \\themename defines a custom beamer template to add a text to the footer. It can be set via\n    \\begin{verbatim}\\setbeamertemplate{frame footer}{My custom footer}\\end{verbatim}\n    some text \\footnote{footnote text}\n\\end{frame}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{References}\n\n  Some references to showcase [allowframebreaks] \\cite{knuth92,ConcreteMath,Simpson,Er01,greenwade93}\\\\\n  % This is ugly\n%  \\begin{itemize}\n%  \t\\item  \\bibentry{greenwade93}\n%  \t\\item  \\bibentry{Er01}\n%  \\end{itemize}\n \n  \n  Custom manual references using biblio environment and biblioref command \n  \\biblioref{Author 1, Author 2,}{year}{Title of the super paper worthy to mention}{Journal name or publisher}\n\n  \\begin{biblio}{References for this slide only}\n  %\\begin{biblio}{}\n  \t\\biblioref{R. Graham, D. Knuth}{2015}{Concrete mathematics}{publication}\n  \t\\biblioref{P. Kudela}{2016}{title of the second paper}{Mechanical Systems and Signal Processing}\n  \\end{biblio}\n\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Conclusion}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Summary}\n\n  Get the source of this theme and the demo presentation from\n\n  \\begin{center}\\url{github.com/matze/mtheme}\\end{center}\n\n  The theme \\emph{itself} is licensed under a\n  \\href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons\n  Attribution-ShareAlike 4.0 International License}.\n\n  \\begin{center}\\ccbysa\\end{center}\n\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{\\setbeamercolor{palette primary}{fg=black, bg=white}\n\\begin{frame}[standout]\n  Thank you for your attention!\\\\ \\vspace{12pt}\n  Questions?\\\\ \\vspace{12pt}\n  \\url{pk@imp.gda.pl}\n\\end{frame}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% END OF SLIDES\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\appendix\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[fragile]{Backup slides}\n  Sometimes, it is useful to add slides at the end of your presentation to\n  refer to during audience questions.\n\n  The best way to do this is to include the \\verb|appendixnumberbeamer|\n  package in your preamble and call \\verb|\\appendix| before your backup slides.\n\n  \\themename will automatically turn off slide numbering and progress bars for\n  slides in the appendix.\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}[t,allowframebreaks]{References} %% Aligned top\n\n  \\bibliography{demo}\n  \\bibliographystyle{abbrv}\n  %\\bibliographystyle{plain}\n  %\\bibliographystyle{siam}\n\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{document}", "meta": {"hexsha": "ff64c2cde46bdb01357211200ebe69ef6edfb5f0", "size": 38775, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/beamer_presentations/seminar_progress_report_169/seminar_progress_report_169.tex", "max_stars_repo_name": "IFFM-PAS-MISD/lamb-opt", "max_stars_repo_head_hexsha": "81fb823edeb26ed2e92b6296ac65f6659811e447", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-01-15T14:20:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:24:05.000Z", "max_issues_repo_path": "reports/beamer_presentations/seminar_progress_report_169/seminar_progress_report_169.tex", "max_issues_repo_name": "IFFM-PAS-MISD/lamb-opt", "max_issues_repo_head_hexsha": "81fb823edeb26ed2e92b6296ac65f6659811e447", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/beamer_presentations/seminar_progress_report_169/seminar_progress_report_169.tex", "max_forks_repo_name": "IFFM-PAS-MISD/lamb-opt", "max_forks_repo_head_hexsha": "81fb823edeb26ed2e92b6296ac65f6659811e447", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.1312569522, "max_line_length": 249, "alphanum_fraction": 0.672959381, "num_tokens": 12054, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.44977670254847124}}
{"text": "\\section{Implementation and Numerical Results}\n\\label{sec:64results}\n\n\\minitoc[-3mm]{73mm}{5}\n\n\\noindent\nIn this final section of the chapter,\nwe study optimal results of the test scenarios and\nanalyze interpolation errors and optimization results\nfor topology optimization with B-spline surrogates on sparse grids.\n\n\n\n\\subsection{Implementation}\n\\label{sec:641implementation}\n\nIn the following, for simplicity,\nwe combine the two functions to be interpolated,\ni.e., the Cholesky factor\n$\\cholfactor\\colon \\clint{\\*0, \\*1} \\to \\real^{6 \\times 6}$ and\nthe micro-cell density $\\denscell\\colon \\clint{\\*0, \\*1} \\to \\real$,\nto one single objective function\n$\\*\\objfun\\colon \\clint{\\*0, \\*1} \\to \\real^{m+1}$,\nfrom which both functions can be recovered.\n\n\\paragraph{Overview of offline and online phase}\n\nOur method is divided into an offline phase and an online phase,\nboth of which are sketched in \\cref{fig:topoOptPhases}.\nThe offline phase consists of\ngenerating the spatially adaptive sparse grid\n$\\sgset = \\{\\gp{\\*l_k,\\*i_k} \\mid k = 1, \\dotsc, \\ngp\\}$,\nsolving the corresponding micro-problems,\ncomputing the Cholesky factors, and\nhierarchizing the Cholesky factor entries and micro-cell densities\nto obtain the sparse grid interpolant $\\vsgintp$.\nEach optimization iteration of the online phase consists of\nevaluating the interpolant $\\vsgintp$\nfor each micro-cell parameter $\\mcp{j}$ ($j = 1, \\dotsc, M$),\nreconstructing the elasticity tensor $\\etensorcholintp$ from\nthe Cholesky factors $\\cholfactorintp$,%\n\\footnote{%\n  In addition, the partial derivatives\n  $\\partialdiff{} \\etensorcholintp/\\partialdiff{} x_t$\n  ($t = 1, \\dotsc, d$)\n  are evaluated using \\cref{eq:choleskyFactorDerivative}.\n  This is necessary to employ gradient-based optimization.%\n}\nand solving the macro-problem to retrieve the approximated compliance value\n$\\complianceintp(\\mcp{1}, \\dotsc, \\mcp{M})$.\nThe superscript in $\\complianceintp$ indicates that\nwe do not use the exact elasticity tensors $\\etensor$\nto compute the compliance value,\nbut rather the reconstructed and interpolated tensors\n$\\etensorcholintp$.\n\n\\begin{figure}\n  \\tikzset{\n    myCircle/.style={\n      circle,\n      fill=mittelblau!30,\n      draw=mittelblau,\n      inner sep=0.5mm,\n    }\n  }%\n  \\subcaptionbox{%\n    Offline phase (without the actual grid generation).%\n  }[149mm]{%\n    \\begin{tikzpicture}\n      \\node[myCircle] (points) at (0mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\gp{\\*l_1,\\*i_1},\\\\\n            \\dots,\\\\\n            \\gp{\\*l_{\\ngp},\\*i_{\\ngp}}\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (elasticityTensors) at (43mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\etensor(\\gp{\\*l_1,\\*i_1}),\\\\\n            \\dots,\\\\\n            \\etensor(\\gp{\\*l_{\\ngp},\\*i_{\\ngp}})\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (choleskyFactors) at (80mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\cholfactor(\\gp{\\*l_1,\\*i_1}),\\\\\n            \\dots,\\\\\n            \\cholfactor(\\gp{\\*l_{\\ngp},\\*i_{\\ngp}})\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (choleskyInterpolant) at (118mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\cholfactorintp\\colon \\clint{\\*0, \\*1}\\\\\n            {} \\to \\real^{6 \\times 6}\n          \\end{matrix}\n        $%\n      };\n      \\draw[->,draw=C0] (points) -- node[above] {%\n        \\footnotesize{}micro-problem%\n      } (elasticityTensors);\n      \\draw[->,draw=C0] (elasticityTensors) -- node[above] {%\n        \\footnotesize{}%\n        $\n          \\tr{\\cholfactor} \\cholfactor = \\etensor\n        $\\vphantom{p}%\n      } (choleskyFactors);\n      \\draw[->,draw=C0] (choleskyFactors) -- node[above] {%\n        \\footnotesize{}interpolate%\n      } (choleskyInterpolant);\n    \\end{tikzpicture}%\n  }%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    Online phase (one iteration of the optimizer).%\n  }[149mm]{%\n    \\begin{tikzpicture}\n      \\node[myCircle] (points) at (0mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\mcp{1},\\\\\n            \\dots,\\\\\n            \\mcp{M}\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (choleskyFactors) at (34mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\cholfactorintp(\\mcp{1}),\\\\\n            \\dots,\\\\\n            \\cholfactorintp(\\mcp{M})\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (elasticityTensors) at (83mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\etensorcholintp(\\mcp{1}),\\\\\n            \\dots,\\\\\n            \\etensorcholintp(\\mcp{M})\n          \\end{matrix}\n        $%\n      };\n      \\node[myCircle] (complianceValue) at (129.5mm,0mm) {%\n        $\n          \\begin{matrix}\n            \\complianceintp(\\mcp{1},\\\\\n            \\dotsc,\\\\\n            \\mcp{M})\n          \\end{matrix}\n        $%\n      };\n      \\draw[->,draw=C0] (points) -- node[above] {%\n        \\footnotesize{}evaluate\\vphantom{p}%\n      } (choleskyFactors);\n      \\draw[->,draw=C0] (choleskyFactors) -- node[above] {%\n        \\footnotesize{}%\n        $\n          \\etensorcholintp\n          = \\tr{(\\cholfactorintp)} \\cholfactorintp\n        $\\vphantom{p}%\n      } (elasticityTensors);\n      \\draw[->,draw=C0] (elasticityTensors) -- node[above] {%\n        \\footnotesize{}macro-problem%\n      } (complianceValue);\n    \\end{tikzpicture}%\n  }%\n  \\caption[Offline and online phase for topology optimization]{%\n    Offline and online phase for topology optimization.\n    The interpolation of the\n    micro-cell density $\\denscell$ with $\\denscellintp$\n    (see \\cref{sec:622BSplines}) has been omitted for brevity.%\n  }%\n  \\label{fig:topoOptPhases}%\n\\end{figure}\n\n\\paragraph{Generation of spatially adaptive sparse grids}\n\nWe use the classical surplus-based refinement criterion\n(see, e.g., \\cite{Pflueger10Spatially})\nas shown in \\cref{alg:topoOptGridGeneration}\nto generate the spatially adaptive sparse grids.\nThe difference to common surrogate settings is that the objective function\n$\\*f\\colon \\clint{\\*0, \\*1} \\to \\real^{m+1}$ is vector-valued.\nAs the entries of $\\cholfactor$ cannot be evaluated individually,\nthe adaptivity criterion has to consider all entries at once\nto avoid performing unnecessary evaluations.\nWe use the surpluses in the piecewise linear hierarchical basis,\nas their absolute values correlate with the second mixed derivative\nof the objective function due to \\cref{eq:surplusIntegral}.\nThe surpluses are combined using the formula\n$\\beta_k \\ceq \\tr{\\*c} \\vabs{\\vsurplus_{\\*l_k,\\*i_k}}$\n(with entry-wise absolute value) and the\npoints with largest $\\beta_k$ are refined.\n\n\\begin{algorithm}\n  \\begin{algorithmic}[1]\n    \\Function{$\\sgset = \\texttt{offlinePhase}$}{%\n      $\\*\\objfun$, $n$, $b$, $\\*c$, $l_{\\max}$, $\\refinetol$,\n      $\\ngp_{\\mathrm{refine}}$%\n    }\n      \\State{$\\sgset \\gets \\coarseregsgset{n}{d}{b}$}\n      \\Comment{initial regular sparse grid}%\n      \\While{\\True}\n        \\State{$\\ngp \\gets \\setsize{\\sgset}$}\n        \\Comment{number of grid points}%\n        \\State{%\n          Let $(\\vsurplus_{\\*l_{k'},\\*i_{k'}})_{k' = 1, \\dotsc, \\ngp}$\n          satisfy $\n            \\fa{k = 1, \\dotsc, \\ngp}{\n              \\sum_{k'=1}^{\\ngp} \\vsurplus_{\\*l_{k'},\\*i_{k'}}\n              \\bspl{\\*l_{k'},\\*i_{k'}}{1}(\\gp{\\*l_k,\\*i_k})\n              = \\*\\objfun(\\gp{\\*l_k,\\*i_k})\n            }\n          $%\n        }\n        \\ForOneLine{$k = 1, \\dotsc, \\ngp$}{%\n          $\\beta_k \\gets \\tr{\\*c} \\vabs{\\vsurplus_{\\*l_k,\\*i_k}}$%\n        }\n        \\Comment{combine surpluses to a scalar value}%\n        \\State{%\n          $\n            \\liset^\\ast \\gets \\{\n              k = 1, \\dotsc, \\ngp \\mid\n              \\ex{\\gp{\\*l,\\*i} \\notin \\sgset}{\n                \\gp{\\*l_k,\\*i_k} \\to \\gp{\\*l,\\*i}\n              },\\,\n              \\norm[\\infty]{\\*l_k} < l_{\\max},\\,\n              \\abs{\\beta_k} > \\refinetol\n            \\}\n          $%\n        }\n        \\IfOneLine{$\\liset^\\ast = \\emptyset$}{\\Break{}}\n        \\Comment{stop when there are no refinable grid points left}%\n        \\State{%\n          Refine $\\le \\ngp_{\\mathrm{refine}}$ of the points\n          $\\{\\gp{\\*l_k,\\*i_k} \\in \\sgset \\mid k \\in \\liset^\\ast\\}$\n          with largest $\\beta_k$%\n        }\n      \\EndWhile{}\n    \\EndFunction{}\n  \\end{algorithmic}\n  \\caption[%\n    Generation of spatially adaptive sparse grids for topology optimization%\n  ]{%\n    Generation of spatially adaptive sparse grids for topology optimization.\n    Inputs are\n    the objective function $\\*f\\colon \\clint{\\*0, \\*1} \\to \\real^{m+1}$\n    (combination of the Cholesky factor of the elasticity tensor and\n    the micro-cell density),\n    the level $n \\ge d$ and boundary parameter $b \\in \\nat$ of the\n    initial regular sparse grid,\n    the vector $\\*c \\in \\real^{m+1}$ of coefficients with which the\n    absolute values of the entries of the surpluses are combined,\n    the maximal level $l_{\\max} \\in \\nat$,\n    the refinement threshold $\\refinetol \\in \\posreal$, and\n    the number $\\ngp_{\\mathrm{refine}} \\in \\nat$ of points to refine\n    in each iteration.\n    Output is the spatially adaptive sparse grid $\\sgset$.%\n  }%\n  \\label{alg:topoOptGridGeneration}%\n\\end{algorithm}\n\n\\paragraph{Parameter bounds}\n\nIn the micro-cell models presented in \\cref{sec:631models},\nextreme micro-cell parameters near zero or one may cause problems\nwith the resulting elasticity tensors.\nFor instance, many elasticity tensor entries corresponding to\nthe 2D cross model are discontinuous near the lines $x_1 = 1$ or $x_2 = 1$\n\\multicite{Huebner14Mehrdimensionale,Valentin14Hierarchische}.\nThis is due to the fact that the micro-cell is completely filled with material\non these lines,\nindependent of the other micro-cell parameter.\nSimilar issues occur for the other models and the shearing angles.\nHence, we have to restrict the range of the feasible micro-cell parameters,\ni.e., the sparse grid points\n$\\*x = \\gp{\\*l_k,\\*i_k}$ are still defined on the unit hyper-cube\n$\\clint{\\*0, \\*1}$,\nbut the actual micro-cell parameters $\\xscaled$ are retrieved by an\naffine transformation $\\xscaled \\ceq \\*a + (\\*b - \\*a) \\*x$.\nFor the models in \\cref{sec:631models},\nwe restrict the bar widths to $\\clint{0.01, 0.99}$ and\nthe shearing angles to $\\clint{-0.35\\pi, 0.35\\pi}$.\n\n\\paragraph{Software, algorithms, and domain discretization}\n\nThe micro-problems and macro-problems were solved with the\n\\fem software package CFS++ \\cite{Kaltenbacher10Advanced}.%\n\\footnote{%\n  \\url{http://www.lse.uni-erlangen.de/cfs/}%\n}\nThe micro-prob\\-lems were discretized by dividing the micro-cells into\n$128 \\times 128 = \\num{16384}$ elements (models in two dimensions) or\n$16 \\times 16 \\times 16 = \\num{4096}$ elements (models in three dimensions).\nThe macro-domains $\\objdomain$ were discretized using\n32 macro-cells per meter in the 2D cantilever scenario\n(i.e., $64 \\times 32 = \\num{2048}$ cells),\n20 macro-cells per meter in the 3D cantilever scenario\n(i.e., $20 \\times 20 \\times 20 = \\num{8000}$ cells), and\n10 macro-cells per meter in the other scenarios\n(i.e.,\n%$50 \\times 20 + 20 \\times 30 = \\num{1600}$\n\\num{1600} cells for the 2D L-shape and\n%$20 \\times 20 \\times 10 = \\num{4000}$\n\\num{4000} cells for the 3D center-load).\nThe generation of the sparse grids (offline phase) was done via a MATLAB code,\nwhile the evaluation of the interpolants (online phase) was performed\nby the sparse grid toolbox \\sgpp \\cite{Pflueger10Spatially}.%\n\\footnote{%\n  \\url{http://sgpp.sparsegrids.org/}%\n}\nFor the solution of the emerging optimization problems,\na sequential quadratic programming method was employed\n(see \\cref{sec:513gradientBasedConstrained}).\n\n\n\n\\subsection{Error Sources}\n\\label{sec:642errorSources}\n\nThere are multiple sources that contribute to the numerical error\nof our method:\n\n\\begin{enumerate}[label=E\\arabic*.,ref=E\\arabic*,leftmargin=2.7em]\n  \\item\n  \\label{item:topoOptErrorMicro}\n  Discretization of the micro-problem\n  (i.e., the elasticity tensors $\\etensor$ are inaccurate)\n  \n  \\item\n  \\label{item:topoOptErrorInterpolation}\n  Sparse grid interpolation\n  (i.e., $\\etensorintp \\not= \\etensor$)\n  \n  \\item\n  \\label{item:topoOptErrorCholesky}\n  Reconstruction of elasticity tensors with Cholesky factors\n  (i.e., $\\etensorcholintp \\not= \\etensorintp$)\n  \n  \\item\n  \\label{item:topoOptErrorMacro}\n  Discretization of the macro-problem\n  (i.e., the compliance $\\compliance$ is inaccurate)\n  \n  \\item\n  \\label{item:topoOptErrorOptimization}\n  Optimization\n  (i.e., the minimum found by the optimizer is inaccurate or not global)\n  \n  \\item\n  \\label{item:topoOptErrorRounding}\n  Floating-point rounding errors\n  (i.e., arithmetical operations are inaccurate)\n\\end{enumerate}\n\n\\noindent\n\\ref{item:topoOptErrorRounding}-type errors are always present and\nwill not be analyzed in this chapter.\nErrors of type \\ref{item:topoOptErrorMicro} and \\ref{item:topoOptErrorMacro}\nare intrinsic to the homogenization approach\nand will not be discussed here either.\nThe optimization error \\ref{item:topoOptErrorOptimization}\nhas already been discussed in \\cref{sec:542optimization}\nfor explicit test functions.\nTherefore, in the remainder of this chapter,\nwe will focus on the analysis of the errors of types\n\\ref{item:topoOptErrorInterpolation} and \\ref{item:topoOptErrorCholesky},\nsince the interpolation of Cholesky factors is the\nmajor new contribution to this application.\n\n\n\n\\subsection{Interpolation Error}\n\\label{sec:643interpolation}\n\n\\paragraph{Spectral interpolation error measure}\n\nFor the interpolation error \\ref{item:topoOptErrorInterpolation} and\nthe Cholesky factorization error \\ref{item:topoOptErrorCholesky},\nwe cannot simply take the absolute value of the difference\nof the objective function $\\*\\objfun\\colon \\clint{\\*0, \\*1} \\to \\real^{m+1}$\nand its surrogate $\\vsgintp$, since both are vector-valued.\nAs the micro-cell density $\\denscell$\nis not affected by the Cholesky factorization,\nwe consider only the elasticity tensor\n$\\etensor\\colon \\clint{\\*0, \\*1} \\to \\real^{6 \\times 6}$ and\nits surrogate\n$\\etensorcholintp\\colon \\clint{\\*0, \\*1} \\to \\real^{6 \\times 6}$\nobtained by Cholesky factorization.\nTo retrieve a scalar error measure,\nwe use the spectral norm\n\\begin{equation}\n  \\norm[2]{\\etensor(\\*x) - \\etensorcholintp(\\*x)},\\quad\n  \\*x \\in \\clint{\\*0, \\*1},\n\\end{equation}\ni.e., the largest absolute eigenvalue of\n$\\etensor(\\*x) - \\etensorcholintp(\\*x)$.\nHowever, the choice of the norm is arbitrary,\nas all matrix norms on $\\real^{6 \\times 6}$ are equivalent to each other.\n\n\\paragraph{Pointwise spectral interpolation error}\n\n\\Cref{fig:topoOptInterpolationErrorPointwise}\nshows the pointwise spectral interpolation error for the 2D cross model\nand the corresponding spatially adaptive sparse grid\ngenerated with the refinement algorithm as explained in\n\\cref{sec:641implementation}.\nThe above-mentioned discontinuity of elasticity tensor entries\nnear $x_1 = 1$ or $x_2 = 1$\nis most severe near the corners $\\*x \\in \\{(0, 1), (1, 0)\\}$\n(cf.\\ \\cref{fig:cholesky}),\nas some entries vanish if one of the micro-cell bars has zero width.\nHence, most points are placed near these singularity corners.\n\n\\begin{figure}\n  \\subcaptionbox{%\n    $\\norm[2]{\\etensor(\\*x) - \\etensorintp(\\*x)}$%\n    \\label{fig:topoOptInterpolationErrorPointwise_1}%\n  }[63mm]{%\n    \\includegraphics{topoOptInterpolationPointwise_1}%\n  }%\n  \\hspace{3mm}%\n  \\subcaptionbox{%\n    $\\norm[2]{\\etensor(\\*x) - \\etensorcholintp(\\*x)}$%\n    \\label{fig:topoOptInterpolationErrorPointwise_2}%\n  }[63mm]{%\n    \\includegraphics{topoOptInterpolationPointwise_2}%\n  }%\n  \\hfill%\n  \\includegraphics{topoOptInterpolationPointwise_3}%\n  \\caption[Pointwise spectral interpolation error for the 2D cross model]{%\n    Pointwise spectral interpolation error for the 2D cross model and\n    cubic B-splines on\n    $\\ngp = 1320$ spatially adaptive sparse grid points \\emph{(dots)} for\n    the direct elasticity tensor interpolation \\emph{(left)} and\n    the Cholesky factor interpolation \\emph{(right).}%\n  }%\n  \\label{fig:topoOptInterpolationErrorPointwise}%\n\\end{figure}\n\nThe left plot (\\cref{fig:topoOptInterpolationErrorPointwise_1})\nshows the spectral interpolation error\n$\\norm[2]{\\etensor(\\*x) - \\etensorintp(\\*x)}$\nof the direct elasticity tensor interpolant without Cholesky factorization\n(i.e., error \\ref{item:topoOptErrorInterpolation}).\nThe maximum error is \\num{1.2e-3},\nwhich is attained near the critical lines $x_1 = 1$ or $x_2 = 1$.\nNote that the mean error over the whole domain $\\clint{\\*0, \\*1}$\nis only \\num{4.5e-5}.\nIn the right plot (\\cref{fig:topoOptInterpolationErrorPointwise_2}),\nthe picture changes slightly when looking at the spectral interpolation error\n$\\norm[2]{\\etensor(\\*x) - \\etensorcholintp(\\*x)}$\nof the elasticity tensor resulting from Cholesky factorization\n(i.e., errors \\ref{item:topoOptErrorInterpolation} and\n\\ref{item:topoOptErrorCholesky} combined).\nThe maximum error becomes \\num{3.4e-3},\nwhile the mean error increases to \\num{1.1e-4}.\nWe conclude that the Cholesky factorization leads to an increase\nof interpolation errors by only less than half an order of magnitude.\n\n\\paragraph{Convergence of spectral interpolation error}\n\n\\Cref{fig:topoOptInterpolationErrorBasisFunctions_1} shows\nthe convergence of the relative $\\Ltwo$ spectral interpolation errors\n\\begin{equation}\n  \\error^{\\sparse} \\ceq\n  \\frac{\n    \\normLtwoscaled{\n      \\vphantom{\\big(}\n      \\norm[2]{\\etensor({\\cdot}) - \\etensorintp({\\cdot})}\n    }\n  }{\n    \\normLtwoscaled{\n      \\vphantom{\\big(}\n      \\norm[2]{\\etensor({\\cdot})}\n    }\n  }, \\qquad\n  \\error^{\\chol,\\sparse} \\ceq\n  \\frac{\n    \\normLtwoscaled{\n      \\vphantom{\\big(}\n      \\norm[2]{\\etensor({\\cdot}) - \\etensorcholintp({\\cdot})}\n    }\n  }{\n    \\normLtwoscaled{\n      \\vphantom{\\big(}\n      \\norm[2]{\\etensor({\\cdot})}\n    }\n  }\n\\end{equation}\nfor the 2D cross model, i.e.,\nthe relative $\\Ltwo$ error of the functions depicted in\n\\cref{fig:topoOptInterpolationErrorPointwise}.\nRelative errors of \\SI{1}{\\permille} are already obtained\nfor $\\ngp = 200$ grid points.\nUnfortunately, even for higher B-spline degrees $p > 1$,\nthe order of convergence is only quadratic\ndue to the singularities of the elasticity tensor.\nThis slow convergence does not improve for the other\nmicro-cell models as shown in\n\\Cref{fig:topoOptInterpolationErrorBasisFunctions_2}.\nIn fact, the convergence decelerates even more\nas the number of micro-cell parameters increases.\nFor the 2D sheared cross and 3D cross models with three parameters,\nthe spatially adaptive sparse grid with $\\ngp \\approx \\num{10000}$ grid points\nis able to achieve a relative error of around \\SI{3}{\\permille}.\nHowever, for the 2D sheared framed cross and 3D sheared cross models\nwith five parameters, only errors of about \\SI{5}{\\percent} are reached\nfor the same grid size.\n\n\\begin{figure}\n  \\hspace*{5mm}%\n  \\includegraphics{topoOptInterpolation_3}%\n  \\hfill%\n  \\raisebox{0.5mm}{\\includegraphics{topoOptInterpolation_4}}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    $\\error^{\\sparse}$ \\emph{\\textcolor{C0}{(blue)}} and\n    $\\error^{\\chol,\\sparse}$ \\emph{\\textcolor{C1}{(red)}}\n    for the 2D cross model and different degrees.%\n    \\label{fig:topoOptInterpolationErrorBasisFunctions_1}%\n  }[72mm]{%\n    \\includegraphics{topoOptInterpolation_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\error^{\\chol,\\sparse}$\n    for the other models and $p = 3$.%\n    \\label{fig:topoOptInterpolationErrorBasisFunctions_2}%\n  }[72mm]{%\n    \\includegraphics{topoOptInterpolation_2}%\n  }%\n  \\caption[Convergence of relative $L^2$ spectral interpolation errors]{%\n    Convergence of relative $\\Ltwo$ spectral interpolation errors\n    over the increasing number $\\ngp$ of spatially adaptive grid points\n    (i.e., decreasing threshold $\\refinetol$)\n    for the 2D cross model without or with Cholesky factor interpolation\n    and different degrees $p$ \\emph{(left)} and\n    for the other models and cubic degree \\emph{(right)}.%\n  }%\n  \\label{fig:topoOptInterpolationErrorBasisFunctions}%\n\\end{figure}\n\n\n\n\\subsection{Optimal Compliance Values and Structures}\n\\label{sec:644optimization}\n\n\\paragraph{Optimal compliance values for different micro-cell models}\n\nIn the following, we use for each micro-cell model\na specific spatially adaptive sparse grid with around \\num{10000} points.\nThe exact grid sizes and other details about the employed sparse grids\ncan be found in \\cref{tbl:topoOptModels}\n(located in \\cref{chap:a30topoOptDetails}).\nFor hierarchical cubic B-splines ($p = 3$),\n\\cref{tbl:topoOptResultsModels} lists the\ncompliance values $\\compliance(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M})$\nfor each of the four scenarios\nand the corresponding possible micro-cell models,\nwhere $(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M}) \\in (\\real^d)^M$\nis the micro-cell parameter combination that is returned by the optimizer.%\n\\footnote{%\n  Note that this true compliance value differs from the\n  approximated value\n  $\\complianceintp(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M})$,\n  which the optimizer reports as the optimal objective function value.%\n}\nIt is obvious that more complicated micro-cell models\nlead to lower (better) compliance values,\nas they are a generalization of the simple models.\nFor instance, the 2D cross is a special case of\nthe 2D framed cross, the 2D sheared cross, and the 2D sheared framed cross.\nBy choosing the respectively best model for each scenario,\nwe are able to decrease the compliance value\n(and, hence, increase the stability of the resulting structure)\nby \\SI{9.6}{\\percent} in the 2D cantilever scenario,\nby \\SI{7.7}{\\percent} in the 2D L-shape scenario,\nby \\SI{34}{\\percent} in the 3D cantilever scenario, and\nby \\SI{73}{\\percent} in the 3D center-load scenario.\nIn general, this motivates the usage of more complicated micro-cell models,\nwhich cannot be computationally handled with\nconventional full grid interpolation methods.\nConsequently, sparse grids or similar methods have to be used.\n\n\\begin{table}\n  \\setnumberoftableheaderrows{1}%\n  \\begin{tabular}{%\n    >{\\kern\\tabcolsep}=l<{\\kern5mm}*{6}{+c}<{\\kern\\tabcolsep}%\n  }\n    \\toprulec\n    \\headerrow\n    Scenario&       2D-C&   2D-FC&  2D-SC&           2D-SFC& 3D-C&   3D-SC\\\\\n    \\midrulec\n    % id = 650,652,654,656\n    2D cantilever&  74.974& 70.816& \\textbf{67.809}& 68.602& ---&    ---\\\\\n    % id = 651,653,655,657\n    2D L-shape&     183.68& 177.51& \\textbf{169.60}& 174.55& ---&    ---\\\\\n    \\midrulec\n    % id = 658,660\n    3D cantilever&  ---&    ---&    ---&             ---&    247.60& \\textbf{162.59}\\\\\n    % id = 659,661\n    3D center-load& ---&    ---&    ---&             ---&    169.27& \\textbf{46.171}\\\\\n    \\bottomrulec\n  \\end{tabular}\n  \\caption[Optimal compliance values for different micro-cell models]{%\n    Optimal compliance values for the different scenarios\n    and micro-cell models using cubic B-splines\n    (spatially adaptive grids with around \\num{10000} points).\n    %The columns correspond to the micro-cell models\n    %as presented in \\cref{fig:microCell}:\n    %2D cross,\n    %2D framed cross,\n    %2D shared cross,\n    %2D shared framed cross,\n    %3D cross, and\n    %3D sheared cross.\n    The entries highlighted in \\textbf{bold face} indicate the best choice\n    of micro-cell models for a given scenario.\n    %The optimization run of the entry marked as \\emph{italic}\n    %terminated prior to success due to numerical difficulties.\n    More details can be found in \\cref{tbl:topoOptResultsDetailed}.%\n  }%\n  \\label{tbl:topoOptResultsModels}%\n\\end{table}\n\n\\paragraph{Corresponding optimal structures}\n\nThe corresponding optimal structures are shown in\n\\cref{fig:topoOptStructure2DCantilever} for the 2D cantilever scenario\nand, for reasons of space, in \\cref{chap:a30topoOptDetails} in\n\\cref{fig:topoOptStructure2DLShape,fig:topoOptStructure3D}\nfor the other three scenarios.\nOf course, the periodic micro-cell structures cannot be plotted directly,\nas the micro-cells are infinitesimally small.\nTherefore, the figures show for each macro-cell only\none single large micro-cell.\n\n\\begin{figure}\n  \\subcaptionbox{%\n    2D cross%\n  }[72mm]{%\n    % id = 650\n    \\includegraphics{topoOptStructure2D_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    2D framed cross%\n  }[72mm]{%\n    % id = 652\n    \\includegraphics{topoOptStructure2D_3}%\n  }%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    2D sheared cross%\n  }[72mm]{%\n    % id = 654\n    \\includegraphics{topoOptStructure2D_5}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    2D sheared framed cross%\n  }[72mm]{%\n    % id = 656\n    \\includegraphics{topoOptStructure2D_7}%\n  }%\n  \\caption[Optimal structures in the 2D cantilever scenario]{%\n    Topologically optimal structures in the 2D cantilever scenario\n    for different micro-cell models using cubic B-splines\n    (spatially adaptive grids with around \\num{10000} points).\n    The colors indicate the length of the displacement,\n    where dark regions correspond to weak displacements and\n    bright regions to strong displacements.\n    The color map is the same as in\n    \\cref{fig:topoOptStructure2DLShape}.\n    Only bars with widths $\\ge 0.1$ are shown.\n    More details can be found in \\cref{tbl:topoOptResultsDetailed}.%\n  }%\n  \\label{fig:topoOptStructure2DCantilever}%\n\\end{figure}\n\nTwo effects can be seen in the plots of the optimal structures:\nFirst, the simpler models are not able to direct the emerging forces at\narbitrary angles.\nFor example, the 2D framed cross model strongly prefers\nangles of \\ang{45}, which results in structures that are not as stable\nas they could be.\nThe 2D sheared cross and 2D sheared framed cross models\nare considerably more flexible, allowing\ninternal forces to act at almost arbitrary angles.\nSecond, the sheared micro-cell models use the available\nmaterial volume more efficiently than the cross model.\nThis is most striking in the 3D case (see \\cref{fig:topoOptStructure3D}),\nwhere it seems that the sheared cross structures\nuse more volume than the simple cross structures,\nalthough the structures spend exactly the same amount of material volume.\nThe reason is that for the cross model, both bars\nhave to be used in order to connect the macro-cell to its neighbors.\nFor the sheared cross model, a shearing of the vertical bar suffices,\nand we save volume by not using the horizontal bar.\nBoth of these effects explain the significantly lower compliance\nvalues for the sheared micro-cell models.\n\n\\paragraph{Comparison to the direct solution}\n\nB-splines on sparse grids lead to a drastic reduction in computation time.\nSolving the 2D cantilever scenario with the best-placed sheared cross model\nwould take 453 days with\nexact elasticity tensor evaluations (i.e., without surrogates),\nassuming the same number of iterations as for the surrogate tensor case\nand sequential computation of the elasticity tensors.\nThis estimate does not account for approximating the missing derivatives\nof the elasticity tensor.\nIf we incorporate this and use 100 parallel processes,\nwe still need weeks for the solution.\nIn contrast, the computation time using our sparse grid surrogates\nis a matter of minutes or hours at most,\nresulting in speedups of around 200.\nThis is excluding the time for the offline phase,\nwhich is in the range of hours, but which has to be spent only once,\nas the resulting grid can be reused for different scenarios.\n\n\\vspace{2em}\n\n\\paragraph{Optimality-interpolation gaps}\n\n\\begin{figure}\n  \\includegraphics{topoOptOptimalityGap_3}%\n  \\\\[2mm]%\n  \\includegraphics{topoOptOptimalityGap_1}%\n  \\hfill%\n  \\includegraphics{topoOptOptimalityGap_2}%\n  \\caption[Convergence of the optimality-interpolation gap]{%\n    Convergence of the optimality-interpolation gap\n    $\\abs{\\compliance[\\opt,\\ast] - \\complianceintp[\\opt,\\ast]}$\n    for the 2D/3D cantilever scenario\n    and different micro-cell models using cubic B-splines ($p = 3$).\n    The left plot additionally shows\n    $\\compliance[\\opt,\\ast]\n    \\ceq \\compliance(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M})$ and\n    $\\complianceintp[\\opt,\\ast]\n    \\ceq \\complianceintp(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M})$\n    for the 2D cross model.%\n  }%\n  \\label{fig:topoOptOptimalityGap}%\n\\end{figure}\n\n%For a given computed optimal solution\n%$(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M}) \\in (\\real^d)^M$,\nIdeally, we would measure the true optimality gap\n\\begin{equation}\n  \\label{eq:topoOptOptimalityGapTrue}\n  \\compliance(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M}) -\n  \\compliance(\\mcpopt{1}, \\dotsc, \\mcpopt{M}),\n\\end{equation}\ncf.\\ error \\ref{item:topoOptErrorOptimization}.\nUnfortunately, the true optimum\n$(\\mcpopt{1}, \\dotsc, \\mcpopt{M})$ could not be computed:\nApart from the time issue mentioned above,\noscillations in the elasticity tensor evaluation and\nerrors stemming from types\n\\ref{item:topoOptErrorMicro} and \\ref{item:topoOptErrorRounding}\nreliably led to optimizer crashes as it ran into discontinuities,\nwhich are smoothed out when using B-spline surrogates.\nHowever, as in \\cref{fig:topoOptOptimalityGap},\nwe can at least calculate the \\term{optimality-interpolation gap}\n\\begin{equation}\n  \\label{eq:topoOptOptimalityGapPseudo}\n  \\abs{\n    \\compliance(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M}) -\n    \\complianceintp(\\mcpoptappr{1}, \\dotsc, \\mcpoptappr{M})\n  }\n\\end{equation}\nbetween the actual compliance value\n%(i.e., using exact elasticity tensors $\\etensor(\\mcpoptappr{q})$,\n%$q = 1, \\dotsc, M$, for the final solution)\nand the approximated, reported compliance value.\n%(i.e., using the surrogate tensors $\\etensorcholintp(\\mcpoptappr{q})$).\nThis gap does not constitute any kind of bound on the true optimality gap;\nhowever, the idea is that\nas the interpolation error converges to zero,\nthe optimality-interpolation gap should converge to zero, too.\n\n\\pagebreak\n\n\\Cref{fig:topoOptOptimalityGap} (left) shows that for the 2D cross model,\nthe optimizer reports compliance values that are smaller than in reality\n($\\complianceintp[\\opt,\\ast]$ vs. $\\compliance[\\opt,\\ast]$).\nHowever, the difference steadily converges to zero.\nThis is similar for the other micro-cell model as shown in the\nright part of \\cref{fig:topoOptOptimalityGap},\nalthough the convergence is much slower due to the\nhigher number $d$ of micro-cell parameters.\n\n\\paragraph{Optimal compliance values for different B-spline degrees}\n\nFinally, to study the effect of the B-spline degree on the\noptimization performance,\n\\cref{tbl:topoOptResultsDegrees} lists the compliance values\nfor the degrees $p = 1, 3, 5$ and the 2D/3D cross and sheared cross\nmicro-cell models.\nIn the two-dimensional scenarios,\nhigher-order B-splines decrease the compliance value\nby up to \\SI{9}{\\percent}.\nIn the three-dimensional scenarios,\nhigher-order B-splines may perform worse than the piecewise linear\nfunctions ($p = 1$).\n(However, as indicated in \\cref{tbl:topoOptResultsDegrees},\nall optimization runs with piecewise linear functions\nterminated prematurely due to numerical difficulties with the\ndiscontinuous derivatives.)\nIt may be suspected that if we used micro-cell models with\nless prominent discontinuities (i.e., ``smoother'' elasticity tensors),\nthe advantage of higher-order B-splines would be more visible.\nAll in all, the application of topology optimization underlines\nthat good interpolation (and thus a good quality of the surrogate)\nis key to good optimization results.\n\n\\begin{table}\n  \\setnumberoftableheaderrows{2}%\n  \\begin{tabular}{%\n      >{\\kern\\tabcolsep}=l<{\\kern5mm}*{3}{+c}%\n      <{\\kern5mm}*{3}{+c}<{\\kern\\tabcolsep}%\n    }\n    \\toprulec\n    \\headerrow\n    &\n    \\multicolumn{3}{c}{\\hspace*{-12pt}2D/3D cross}&\n    \\multicolumn{3}{c}{\\hspace*{-6pt}2D/3D sheared cross}\\\\\n    \\headerrow\n    Scenario&       $p = 1$&         $p = 3$&         $p = 5$&          $p = 1$&                $p = 3$&         $p = 5$\\\\\n    \\midrulec\n    % id = 690,650,670,694,654,674\n    2D cantilever&  \\emph{82.365}&   \\textbf{74.974}& 76.070&           \\emph{68.889}&          \\textbf{67.809}& 68.018\\\\\n    % id = 691,651,671,695,655,675\n    2D L-shape&     \\emph{193.83}&   \\textbf{183.68}& 183.70&           \\emph{169.85}&          169.60&          \\textbf{169.60}\\\\\n    \\midrulec\n    % id = 698,658,678,700,660,680\n    3D cantilever&  \\emph{249.75}&   247.60&          \\textbf{247.33}&  \\emph{\\textbf{148.72}}& 162.59&          152.34\\\\\n    % id = 699,659,679,701,661,681\n    3D center-load& \\textbf{162.68}& 169.27&          163.94&           \\emph{\\textbf{45.713}}& 46.171&          47.074\\\\\n    \\bottomrulec\n  \\end{tabular}\n  \\caption[Optimal compliance values for different B-spline degrees]{%\n    Optimal compliance values for the different scenarios\n    and B-spline degrees using the 2D/3D cross micro-cell model \\emph{(left)}\n    and the 2D/3D sheared cross micro-cell model \\emph{(right).}\n    The spatially adaptive sparse grids are the same as in\n    \\cref{tbl:topoOptResultsModels}.\n    The entries highlighted in \\textbf{bold face} indicate the best choice\n    of B-spline degree for a given scenario and micro-cell model.\n    Optimization runs of entries marked as \\emph{italic}\n    terminated prior to success due to numerical difficulties.%\n  }%\n  \\label{tbl:topoOptResultsDegrees}%\n\\end{table}\n\n%10197   cross-sisc-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl3\n%10502   framed-cross-sga16-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl3\n%10723   sheared-cross-sisc-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3\n%10694   sheared-framed-cross-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3\n%9207    cross-3d-sga16-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl3\n%15389   sheared-cross-3d-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3\n%\n%\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=626 stats=cross-sisc-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01 optUB=0.99,0.99 optIC=0.2,0.2 problem=thesis-2d-cantilever id=650\n%python3 generate.py --checkpoint-hack=sgpp --default-id=620 stats=cross-sisc-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01 optUB=0.99,0.99 optIC=0.2,0.2 problem=thesis-2d-L id=651\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=framed-cross-sga16-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.01 optUB=0.99,0.99,0.99,0.99 optIC=0.2,0.2,0.2,0.2 id=652\n%python3 generate.py --checkpoint-hack=sgpp --default-id=651 stats=framed-cross-sga16-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.01 optUB=0.99,0.99,0.99,0.99 optIC=0.2,0.2,0.2,0.2 id=653\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=sheared-cross-sisc-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.15 optUB=0.99,0.99,0.85 optIC=0.2,0.2,0.5 id=654\n%python3 generate.py --checkpoint-hack=sgpp --default-id=651 stats=sheared-cross-sisc-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.15 optUB=0.99,0.99,0.85 optIC=0.2,0.2,0.5 id=655\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=sheared-framed-cross-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.01,0.15 optUB=0.99,0.99,0.99,0.99,0.85 optIC=0.2,0.2,0.2,0.2,0.5 id=656\n%python3 generate.py --checkpoint-hack=sgpp --default-id=651 stats=sheared-framed-cross-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.01,0.15 optUB=0.99,0.99,0.99,0.99,0.85 optIC=0.2,0.2,0.2,0.2,0.5 id=657\n%python3 generate.py --checkpoint-hack=sgpp --default-id=634 stats=cross-3d-sga16-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01,0.01 optUB=0.99,0.99,0.99 optIC=0.2,0.2,0.2 problem=thesis-3d-cantilever id=658\n%python3 generate.py --checkpoint-hack=sgpp --default-id=635 stats=cross-3d-sga16-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl3 optLB=0.01,0.01,0.01 optUB=0.99,0.99,0.99 optIC=0.2,0.2,0.2 problem=thesis-3d-centerload id=659\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=sheared-cross-3d-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.15,0.15 optUB=0.99,0.99,0.99,0.85,0.85 optIC=0.2,0.2,0.2,0.5,0.5 id=660\n%python3 generate.py --checkpoint-hack=sgpp --default-id=659 stats=sheared-cross-3d-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 optLB=0.01,0.01,0.01,0.15,0.15 optUB=0.99,0.99,0.99,0.85,0.85 optIC=0.2,0.2,0.2,0.5,0.5 id=661\n%\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-thesis-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=670\n%python3 generate.py --checkpoint-hack=sgpp --default-id=651 stats=cross-thesis-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=671\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-thesis-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=672\n%python3 generate.py --checkpoint-hack=sgpp --default-id=653 stats=framed-cross-thesis-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=673\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-thesis-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=674\n%python3 generate.py --checkpoint-hack=sgpp --default-id=655 stats=sheared-cross-thesis-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=675\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=676\n%python3 generate.py --checkpoint-hack=sgpp --default-id=657 stats=sheared-framed-cross-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=677\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-thesis-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=678\n%python3 generate.py --checkpoint-hack=sgpp --default-id=659 stats=cross-3d-thesis-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl5 bsplineDegree=5 id=679\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=680\n%python3 generate.py --checkpoint-hack=sgpp --default-id=661 stats=sheared-cross-3d-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl5 bsplineDegree=5 id=681\n%\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-thesis-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=690\n%python3 generate.py --checkpoint-hack=sgpp --default-id=651 stats=cross-thesis-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=691\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-thesis-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=692\n%python3 generate.py --checkpoint-hack=sgpp --default-id=653 stats=framed-cross-thesis-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=693\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-thesis-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=694\n%python3 generate.py --checkpoint-hack=sgpp --default-id=655 stats=sheared-cross-thesis-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=695\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=696\n%python3 generate.py --checkpoint-hack=sgpp --default-id=657 stats=sheared-framed-cross-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=697\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-thesis-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=698\n%python3 generate.py --checkpoint-hack=sgpp --default-id=659 stats=cross-3d-thesis-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl1 bsplineDegree=1 id=699\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=700\n%python3 generate.py --checkpoint-hack=sgpp --default-id=661 stats=sheared-cross-3d-thesis-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl1 bsplineDegree=1 id=701\n%\n%\n%\n%\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.215443-lb0.01-ub0.99-cholesky-hier-bspl3 id=720\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.1-lb0.01-ub0.99-cholesky-hier-bspl3 id=721\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.0464159-lb0.01-ub0.99-cholesky-hier-bspl3 id=722\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.0215443-lb0.01-ub0.99-cholesky-hier-bspl3 id=723\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.01-lb0.01-ub0.99-cholesky-hier-bspl3 id=724\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.00464159-lb0.01-ub0.99-cholesky-hier-bspl3 id=725\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.00215443-lb0.01-ub0.99-cholesky-hier-bspl3 id=726\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.001-lb0.01-ub0.99-cholesky-hier-bspl3 id=727\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.000464159-lb0.01-ub0.99-cholesky-hier-bspl3 id=728\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.000215443-lb0.01-ub0.99-cholesky-hier-bspl3 id=729\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol0.0001-lb0.01-ub0.99-cholesky-hier-bspl3 id=730\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol4.64159e-05-lb0.01-ub0.99-cholesky-hier-bspl3 id=731\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol2.15443e-05-lb0.01-ub0.99-cholesky-hier-bspl3 id=732\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol1e-05-lb0.01-ub0.99-cholesky-hier-bspl3 id=733\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol4.64159e-06-lb0.01-ub0.99-cholesky-hier-bspl3 id=734\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol2.15443e-06-lb0.01-ub0.99-cholesky-hier-bspl3 id=735\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol1e-06-lb0.01-ub0.99-cholesky-hier-bspl3 id=736\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol4.64159e-07-lb0.01-ub0.99-cholesky-hier-bspl3 id=737\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol2.15443e-07-lb0.01-ub0.99-cholesky-hier-bspl3 id=738\n%python3 generate.py --checkpoint-hack=sgpp --default-id=650 stats=cross-sisc-conv-tol1e-07-lb0.01-ub0.99-cholesky-hier-bspl3 id=739\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol5.01187-lb0.01-ub0.99-cholesky-hier-bspl3 id=750\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol3.98107-lb0.01-ub0.99-cholesky-hier-bspl3 id=751\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol3.16228-lb0.01-ub0.99-cholesky-hier-bspl3 id=752\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol2.51189-lb0.01-ub0.99-cholesky-hier-bspl3 id=753\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol1.99526-lb0.01-ub0.99-cholesky-hier-bspl3 id=754\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol1.58489-lb0.01-ub0.99-cholesky-hier-bspl3 id=755\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol1.25893-lb0.01-ub0.99-cholesky-hier-bspl3 id=756\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol1-lb0.01-ub0.99-cholesky-hier-bspl3 id=757\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl3 id=758\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol0.630957-lb0.01-ub0.99-cholesky-hier-bspl3 id=759\n%python3 generate.py --checkpoint-hack=sgpp --default-id=652 stats=framed-cross-sga16-conv-tol0.501187-lb0.01-ub0.99-cholesky-hier-bspl3 id=760\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.316228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=770\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.215443-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=771\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.14678-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=772\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.1-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=773\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.0681292-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=774\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.0464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=775\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.0316228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=776\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.0215443-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=777\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.014678-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=778\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.01-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=779\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.00681292-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=780\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.00464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=781\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.00316228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=782\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.00215443-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=783\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.0014678-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=784\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.001-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=785\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.000681292-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=786\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.000464159-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=787\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.000316228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=788\n%python3 generate.py --checkpoint-hack=sgpp --default-id=654 stats=sheared-cross-sisc-conv-tol0.000215443-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=789\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol31.6228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=800\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol25.1189-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=801\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol19.9526-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=802\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol15.8489-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=803\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol12.5893-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=804\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol10-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=805\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol7.94328-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=806\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol6.30957-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=807\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=808\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol3.98107-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=809\n%python3 generate.py --checkpoint-hack=sgpp --default-id=656 stats=sheared-framed-cross-sga16-conv-tol3.16228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=810\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol1.25893-lb0.01-ub0.99-cholesky-hier-bspl3 id=820\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.794328-lb0.01-ub0.99-cholesky-hier-bspl3 id=821\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.630957-lb0.01-ub0.99-cholesky-hier-bspl3 id=822\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.501187-lb0.01-ub0.99-cholesky-hier-bspl3 id=823\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.398107-lb0.01-ub0.99-cholesky-hier-bspl3 id=824\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.316228-lb0.01-ub0.99-cholesky-hier-bspl3 id=825\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.251189-lb0.01-ub0.99-cholesky-hier-bspl3 id=826\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.199526-lb0.01-ub0.99-cholesky-hier-bspl3 id=827\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.158489-lb0.01-ub0.99-cholesky-hier-bspl3 id=828\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.125893-lb0.01-ub0.99-cholesky-hier-bspl3 id=829\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.1-lb0.01-ub0.99-cholesky-hier-bspl3 id=830\n%python3 generate.py --checkpoint-hack=sgpp --default-id=658 stats=cross-3d-sga16-conv-tol0.0794328-lb0.01-ub0.99-cholesky-hier-bspl3 id=831\n%\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol31.6228-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=840\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol25.1189-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=841\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol19.9526-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=842\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol15.8489-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=843\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol12.5893-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=844\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol10-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=845\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol7.94328-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=846\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol6.30957-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=847\n%python3 generate.py --checkpoint-hack=sgpp --default-id=660 stats=sheared-cross-3d-sga16-conv-tol5.01187-lb0.01,0.15-ub0.99,0.85-cholesky-hier-bspl3 id=848\n", "meta": {"hexsha": "ab079b70b51b746fb6bf868e02686cbdbf5e761e", "size": 52443, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/document/64results.tex", "max_stars_repo_name": "valentjn/thesis", "max_stars_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-01-15T19:50:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T20:16:10.000Z", "max_issues_repo_path": "tex/document/64results.tex", "max_issues_repo_name": "valentjn/thesis", "max_issues_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/document/64results.tex", "max_forks_repo_name": "valentjn/thesis", "max_forks_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0267857143, "max_line_length": 248, "alphanum_fraction": 0.7263123772, "num_tokens": 18105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.449776699065667}}
{"text": "\n\n\nUsing the \\code{lm} software is largely a matter of familiarity \nwith the model design language described in Chapter \\ref{chap:language}.  \nComputing the fitted model values and the residuals is \ndone with the \\code{fitted} and \\code{resid}.  These operators take\na model as an input.  To illustrate:\n\\index{P}{lm@\\texttt{lm}}\n\\index{P}{fitted@\\texttt{fitted}}\n\\index{P}{resid@\\texttt{resid}}\n\\index{P}{Modeling!lm@\\texttt{lm}}\n\\index{P}{Modeling!fitted@\\texttt{fitted}}\n\\index{P}{Modeling!resid@\\texttt{resid}}\n\n\\index{C}{residual!computing}\n\\index{C}{fitted model values!computing}\n\\index{C}{fitting!software}\n\\index{C}{regression report!computing}\n\n\n\n\\begin{Schunk}\n\\begin{Sinput}\n> swim = fetchData(\"swim100m.csv\")\n> mod1 = lm(time ~ year + sex, data=swim)\n> coef(mod1)\n\\end{Sinput}\n\\begin{Soutput}\n(Intercept)        year        sexM \n    555.717      -0.251      -9.798 \n\\end{Soutput}\n\\end{Schunk}\n\n\\datasetSwimming\n\nOnce you have constucted the model, you can use \\code{fitted} and\n\\code{resid}: \n\\begin{Schunk}\n\\begin{Sinput}\n> fitted(mod1)\n\\end{Sinput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Soutput}\n   1    2    3    4    5    6    7    8    9   10   11   12 \n66.9 66.1 65.6 65.1 63.6 63.1 62.6 62.1 59.6 59.3 59.1 57.1 \n... for 62 cases altogether ...\n\\end{Soutput}\n\\end{Schunk}\n\n\\subsection{Sums of Squares}\n\n\\index{C}{sum of squares!computing}\n\nComputations can be performed on the fitted model values and the\nresiduals, just like any other quantity:\n\\begin{Schunk}\n\\begin{Sinput}\n> mean(fitted(mod1))\n\\end{Sinput}\n\\begin{Soutput}\nmean \n59.9 \n\\end{Soutput}\n\\begin{Sinput}\n> var(resid(mod1))\n\\end{Sinput}\n\\begin{Soutput}\n var \n15.3 \n\\end{Soutput}\n\\begin{Sinput}\n> sd(resid(mod1))\n\\end{Sinput}\n\\begin{Soutput}\n  sd \n3.92 \n\\end{Soutput}\n\\begin{Sinput}\n> summary(resid(mod1))\n\\end{Sinput}\n\\begin{Soutput}\n   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. \n  -4.70   -2.70   -0.60    0.00    1.28   19.10 \n\\end{Soutput}\n\\end{Schunk}\n\nSums of squares are very important in statistics.  Here's how to\ncalculate them for the response values, the fitted model values, and\nthe residuals:\n\\begin{Schunk}\n\\begin{Sinput}\n> sum(swim$time^2)\n\\end{Sinput}\n\\begin{Soutput}\n[1] 228635\n\\end{Soutput}\n\\begin{Sinput}\n> sum(fitted(mod1)^2)\n\\end{Sinput}\n\\begin{Soutput}\n[1] 227699\n\\end{Soutput}\n\\begin{Sinput}\n> sum(resid(mod1)^2)\n\\end{Sinput}\n\\begin{Soutput}\n[1] 936\n\\end{Soutput}\n\\end{Schunk}\nThe partitioning of variation by models is seen by the way \n\\index{C}{partitioning!sums of squares}\n\\index{C}{sum of squares!partitioning}\nthe sum of squares of the fitted and the residuals add up to the sum of squares of the response:\n\\begin{Schunk}\n\\begin{Sinput}\n> 227699 + 935.8\n\\end{Sinput}\n\\begin{Soutput}\n[1] 228635\n\\end{Soutput}\n\\end{Schunk}\n\nDon't forget the squaring stage of the operation!  The sum of the\nresiduals (without squaring) \nis very different from the sum of squares of the residuals:\n\\begin{Schunk}\n\\begin{Sinput}\n> sum(resid(mod1))\n\\end{Sinput}\n\\begin{Soutput}\n[1] 1.85e-14\n\\end{Soutput}\n\\begin{Sinput}\n> sum(resid(mod1)^2)\n\\end{Sinput}\n\\begin{Soutput}\n[1] 936\n\\end{Soutput}\n\\end{Schunk}\nTake care in reading numbers formatted like \n\\code{1.849e-14}.   The notation stands for $1.849 \\times 10^{-14}$.\nThat number, $0.00000000000001849$, is effectively zero compared to the\nresiduals themselves!\n\\index{C}{scientific notation}\n\\index{C}{zero}\n\n\n\\subsection{Redundancy}\n\n\\index{C}{redundancy!and NA}\n\\index{C}{coefficients!NA (redundancy)}\nThe \\code{lm} operator will automatically detect redundancy and deal\nwith it by leaving the redundant terms out of the model.  \n\nTo see how redundancy is handled, here is an example with a\nconstructed redundant variable in the swimming dataset.  \nThe following statement adds a new variable to the\ndataframe counting how many years after the end of World War II each\nrecord was established:\n\\begin{Schunk}\n\\begin{Sinput}\n> swim$afterwar = swim$year - 1945\n\\end{Sinput}\n\\end{Schunk}\n\nHere is a model that doesn't involve redundancy\n\\begin{Schunk}\n\\begin{Sinput}\n> mod1 = lm( time ~ year + sex, data=swim)\n> coef(mod1)\n\\end{Sinput}\n\\begin{Soutput}\n(Intercept)        year        sexM \n    555.717      -0.251      -9.798 \n\\end{Soutput}\n\\end{Schunk}\n\nWhen the redundant variable is added in, \\code{lm} successfully\ndetects the redundancy and handles it.  This is indicated by a\ncoefficient of NA on the redundant variable.\n\\begin{Schunk}\n\\begin{Sinput}\n> mod2 = lm( time ~ year + sex + afterwar, data=swim)\n> coef(mod2)\n\\end{Sinput}\n\\begin{Soutput}\n(Intercept)        year        sexM    afterwar \n    555.717      -0.251      -9.798          NA \n\\end{Soutput}\n\\end{Schunk}\n\nIn the absence of redundancy, the model coefficients don't depend on\nthe order in which the model terms are specified.  But this is not the\ncase when there is redundancy, since any redundancy is blamed on the\nlater variables.  For instance, here \\VN{afterwar} has been put first\nin the explanatory terms, so \\code{lm} identifies \\VN{year} as the\nredundant variable:\n\\begin{Schunk}\n\\begin{Sinput}\n> mod3 = lm( time ~ afterwar + year + sex, data=swim)\n> coef(mod3)\n\\end{Sinput}\n\\begin{Soutput}\n(Intercept)    afterwar        year        sexM \n     66.620      -0.251          NA      -9.798 \n\\end{Soutput}\n\\end{Schunk}\n\n\\index{C}{redundancy!fitted model values}\nEven though the coefficients are different, the fitted model values\nand the residuals are exactly the same (to within computer round-off)\nregardless of the order of the\nmodel terms.\n\\begin{Schunk}\n\\begin{Sinput}\n> fitted(mod2)\n\\end{Sinput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Soutput}\n   1    2    3    4    5    6    7    8    9   10   11   12 \n66.9 66.1 65.6 65.1 63.6 63.1 62.6 62.1 59.6 59.3 59.1 57.1 \n... for 62 cases altogether ...\n\\end{Soutput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Sinput}\n> fitted(mod3)\n\\end{Sinput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Soutput}\n   1    2    3    4    5    6    7    8    9   10   11   12 \n66.9 66.1 65.6 65.1 63.6 63.1 62.6 62.1 59.6 59.3 59.1 57.1 \n... for 62 cases altogether ...\n\\end{Soutput}\n\\end{Schunk}\n\n\\index{C}{redundancy!in categorical variables}\nNote that whenever you use a categorical variable and an intercept\nterm in a model, there is a redundancy.  This is not shown explicitly.\nFor example, here is a model with no intercept term, and both levels\nof the categorical variable \\VN{sex} show up with coefficients:\n\\begin{Schunk}\n\\begin{Sinput}\n> lm(time ~ sex - 1, data=swim)\n\\end{Sinput}\n\\begin{Soutput}\n...\nsexF  sexM  \n65.2  54.7  \n\\end{Soutput}\n\\end{Schunk}\nIf the intercept term is included (as it is by default unless\n\\code{-1} is used in the model formula), one of the levels is simply\ndropped in the report:\n\\begin{Schunk}\n\\begin{Sinput}\n> lm(time ~ sex, data=swim)\n\\end{Sinput}\n\\begin{Soutput}\n...\n(Intercept)         sexM  \n       65.2        -10.5  \n\\end{Soutput}\n\\end{Schunk}\nRemember that this coefficient report implicitly involves a\nredundancy.  If the software had been designed differently, the report\nmight look like this:\n\\begin{Schunk}\n\\begin{Soutput}\n(Intercept)     sexF      sexM     \n       65.2       NA     -10.5  \n\\end{Soutput}\n\\end{Schunk}\n\n", "meta": {"hexsha": "be28c37a86d515de7522b3c735de8204f0c56a44", "size": 7100, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ComputationalTechnique-Orig/Fitting/computer-fitting.tex", "max_stars_repo_name": "dtkaplan/SM3", "max_stars_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-01T01:28:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T01:28:07.000Z", "max_issues_repo_path": "ComputationalTechnique-Orig/Fitting/computer-fitting.tex", "max_issues_repo_name": "BriannaBarry/SM3", "max_issues_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ComputationalTechnique-Orig/Fitting/computer-fitting.tex", "max_forks_repo_name": "BriannaBarry/SM3", "max_forks_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-02-14T05:22:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-08T12:42:15.000Z", "avg_line_length": 25.4480286738, "max_line_length": 96, "alphanum_fraction": 0.6971830986, "num_tokens": 2437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.449776699065667}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[left=1cm,right=1cm,\n    top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}\n\\usepackage{braket}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage[T2A]{fontenc}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n\\parindent=0.5cm\n\n\\usepackage{hyperref} \n\\usepackage{indentfirst}\n\n\\numberwithin{equation}{section}\n%\\usepackage{showkeys}\n\n\\begin{document}\n\\section*{MSAI Statistics \\& Probability – Week 7 Seminar \\& HW}\\\\\n\n\\textbf{Problem 1:} Let $\\Omega$ be countably infinite. Prove that a.s. convergence is equivalent to convergence in probability.\n\\\\\n\n\\textbf{Problem 2:} Let $\\xi_1,\\,\\xi_2,\\,\\dots$ be independent Bernoulli random variables, $\\xi_k\\sim\\textrm{Bern}(p_k).$ Show that it is necessary and sufficient for $p_n\\rightarrow0$ as $n\\rightarrow\\infty$ for the following things to be true:\n\\begin{enumerate}\n    \\item $\\xi_n\\overset{P}{\\rightarrow}0$ as $n\\rightarrow\\infty$ ($\\xi_n$ converging to zero in probability)\n    \\item $\\xi_n\\overset{L_q}{\\rightarrow}0$ ($q\\geq1$) as $n\\rightarrow\\infty$ ($\\xi_n$ converging to zero in $L_q$ norm with $q\\geq1$. \\textit{I just used $q$ instead of $p$ in $L_p$ norm here to avoid confusion with $p_k$ – the probability of success of a trial in Bernoulli's scheme.})\n\\end{enumerate}\n\\\\\n\n\\textbf{Problem 3:} Let $\\{S_n,~n\\in\\mathbb{Z}_+\\}$ be a simple random walk. Find $P(S_1\\neq0,~S_2\\neq0,~\\dots)$ (the probability of not getting back to zero after $n$ steps for given $n$). Find the limit of this probability as $n\\rightarrow\\infty.$ \\textit{Hint: Stirling's approximation of factorial can be useful here.}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "b68e3bc20f81678c577393a2eed835ea1d3ff6ee", "size": 1694, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week07_convergence/Week07_HW_Theory.tex", "max_stars_repo_name": "girafe-ai/msai-statistics", "max_stars_repo_head_hexsha": "c9de8ca20bbb9f266e06598d376be50c35f00756", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-04-07T05:10:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-07T15:58:35.000Z", "max_issues_repo_path": "week07_convergence/Week07_HW_Theory.tex", "max_issues_repo_name": "girafe-ai/msai-statistics", "max_issues_repo_head_hexsha": "c9de8ca20bbb9f266e06598d376be50c35f00756", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-08T17:08:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-08T17:08:53.000Z", "max_forks_repo_path": "week07_convergence/Week07_HW_Theory.tex", "max_forks_repo_name": "girafe-ai/msai-statistics", "max_forks_repo_head_hexsha": "c9de8ca20bbb9f266e06598d376be50c35f00756", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-03-25T15:23:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T14:28:21.000Z", "avg_line_length": 42.35, "max_line_length": 322, "alphanum_fraction": 0.7367178276, "num_tokens": 560, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.44977669558286265}}
{"text": "\\chapter{Negative Results}\n\\label{sec:negative}\n\nBefore developing the reflexive graph model of λST, I explored two other\nmodelling approaches which turned out, for different reasons, to be unsuited to\nthe task at hand. They are both based on the idea of interpreting size contexts\nas preorder categories, types as functors from a size context category into the\ncategory of sets and terms as natural transformation between such functors. A\nmodel like this would yield a sort of size irrelevance in the form of the\nnaturality of term interpretations: if the interpretation of a term in size\ncontext $Δ$ is natural in $⟦Δ⟧$, then $⟦Δ⟧$ must be essentially irrelevant. In\nthe next two sections, I briefly describe these potential models and why they do\nnot, in fact, model λST. This is in somewhat surprising contrast to the work of\nVeltri and van der Weide \\cite{veltri2019}, who model guarded recursion --\nanother form of type-based termination checking that is quite similar to sized\ntypes -- using essentially the same approach that fails for λST.\n\n\n\\section{Covariant Presheaf Model}\n\\label{sec:negative:covariant}\n\nOur first potential model starts with the observation that size contexts have a\nnatural interpretation as categories. Recall our previous interpretation of size\ncontexts as types:\n\\begin{Align*}\n  ⟦()⟧ &=& ⊤ \\\\\n  ⟦\\ctx{Δ}{n}⟧ &=& \\Sigma_{δ ∈ ⟦Δ⟧} \\Size_{<⟦n⟧(δ)}.\n\\end{Align*}\nWe can extend this interpretation from types to categories: $⟦()⟧$ is the\nterminal category (whose object type is $⊤$) and $⟦\\ctx{Δ}{n}⟧$ is the\nGrothendieck category of the functor $F ∶ ⟦Δ⟧ → \\Cats$ with $F(δ) ≔\n\\Sizes_{<⟦n⟧(δ)}$. ($\\Cats$ is the category of small categories.) Sizes are\nmodelled as functors $⟦n⟧ ∶ ⟦Δ⟧ → \\Sizes$ where $\\Sizes$ is the category of\nsizes ordered by the preorder $≤$; $\\Sizes_{<n}$ is the subcategory of $\\Sizes$\nwhich contains only sizes less than $n$. The objects of $⟦Δ⟧$ are then\ntelescopes of sizes, as before, and an arrow $f ∶ δ → δ′$ in $⟦Δ⟧$ is a proof\nthat the sizes in $δ$ are pointwise less than or equal to the sizes in $δ′$. The\njudgment $Δ ⊢ n < m$ is modelled by a proof that $⟦n⟧(δ) < ⟦m⟧(δ)$ for arbitrary\n$δ ∶ ⟦Δ⟧$.\n\nContinuing the categorical interpretation, we model types in a size context $Δ$\nas functors from $⟦Δ⟧$ to $\\Sets$, the category of sets (or rather, since we work\nin type theory, types). These are \\enquote*{covariant presheaves}, meaning\npresheaves over the opposite category of $⟦Δ⟧$, $\\Op{⟦Δ⟧}$.\n\nOne problem with this approach becomes apparent already at this stage: the type\n$\\Stream{n}$ of sized streams has no natural interpretation as a covariant\nfunctor from $⟦Δ⟧$ to $\\Sets$. We would like to define, as before,\n\\begin{displaymath}\n  ⟦\\Stream{n}⟧(δ) ≔ ℕ_{<⟦n⟧(δ)} → ℕ\n\\end{displaymath}\nbut this is no functor: for $δ ≤ δ′$ we have $⟦n⟧(δ) ≤ ⟦n⟧(δ′)$ by functoriality\nof $⟦n⟧$, but there is no appropriate function from $ℕ_{<⟦n⟧(δ)} → ℕ$ to\n$ℕ_{<⟦n⟧(δ′)} → ℕ$. This is not surprising -- after all, ⟦\\Stream{n}⟧(δ) is\nnaturally contravariant in $δ$.\n\nStill, let us ignore this problem and move on to discover more fundamental\nissues. The other types of λST have more or less natural interpretations:\n\\begin{Align*}\n  ⟦\\Nat{n}⟧(δ) &≔& ℕ_{≤⟦n⟧(δ)} \\\\\n  ⟦T → U⟧(δ) &≔& \\All{δ′ ≥ δ}{⟦T⟧(δ′) → ⟦U⟧(δ′)} \\\\\n  ⟦\\All{n}{T}⟧(δ) &≔& \\All{δ′ ≥ δ}{\\All{m < ⟦n⟧(δ′)}{⟦T⟧(δ′, m)}}.\n\\end{Align*}\nSized natural numbers $\\Nat{n}$ are interpreted as before. The function space $T\n→ U$ is modelled by the exponential of presheaves, which ensures that we can\nalso model abstractions and applications. The exponential is defined using a\nmonotonisation \\enquote*{trick}: the function space $⟦T⟧(δ) → ⟦U⟧(δ)$ would not\nbe functorial due to the negative occurrence of $δ$, but we can force\nfunctoriality by quantifying over $δ′ ≥ δ$. The same approach also allows us to\ninterpret size quantification, where again the natural interpretation without\nmonotonisation would not be functorial.\n\nUnfortunately, while this monotonisation trick works for the exponential, it\ndoes not yield an appropriate model of size quantification. This is not very\nsurprising: in the above interpretation of $\\All{n}{T}$, the size that we\nintroduce in the model, $m$, is not, in general, smaller than $⟦n⟧(δ)$. The\nbound $m < ⟦n⟧(δ′)$ does not actually restrict the domain of $m$ since $δ′ ≥ δ$\nand thus $⟦n⟧(δ′) ≥ ⟦n⟧(δ)$. The reader is invited to check that this prevents\nus from interpreting $\\mathrm{fix}$.\n\n\n\\section{Contravariant Presheaf Model}\n\\label{sec:negative:contravariant}\n\nSeeing that the major problem with the previous model was the need to\nforce-monotonise the interpretation of size quantification, we now consider a\nmodel based on \\emph{contravariant} presheaves (i.e.\\ just presheaves). Size\nquantification is naturally contravariant, so no trickery is necessary to\ninterpret it. Indeed, this approach leads to a more satisfactory interpretation\nof types (sizes, size contexts etc.\\ are modelled as before):\n\\begin{Align*}\n  ⟦\\Stream{n}⟧(δ) &≔& ℕ_{≤⟦n⟧(δ)} → ℕ \\\\\n  ⟦T → U⟧(δ) &≔& \\All{δ′ ≤ δ}{⟦T⟧(δ′) → ⟦U⟧(δ′)} \\\\\n  ⟦\\All{n}{T}⟧(δ) &≔& \\All{m < ⟦n⟧(δ)}{⟦T⟧(δ, m)}.\n\\end{Align*}\n\nWith the switch to contravariant functors, we lose the ability to model sized\nnatural numbers, but gain the ability to model sized streams. As before, the\nfunction space is interpreted as an exponential of presheaves. Size\nquantification does not require monotonisation any more, and indeed this\napproach appears, on the surface, to support natural interpretations of all\nterms including $\\mathrm{fix}$.\\footnote{The above interpretation of size\n  quantification is not quite accurate: to successfully model λST, we would need\n  to restrict it to allow only size-parametric functions, as in the reflexive\n  graph model. However, this is unimportant for the rest of the discussion.}\n\nAlas, the contravariant presheaf approach still fails, this time due to a more\nsubtle problem: the substitution lemma for size substitution in types does not\nhold. This means that in general we have\n\\begin{displaymath}\n  ⟦\\sub{T}{σ}⟧ ≠ \\sub{⟦T⟧}{⟦σ⟧}.\n\\end{displaymath}\n\nTo see why, we first consider the interpretation of substitutions. Recall that\nin the reflexive graph model, a well-typed substitution $σ ∶ Δ ⇒ Ω$ was\ninterpreted as a function between the types $⟦Δ⟧$ and $⟦Ω⟧$. Here, we upgrade\nthis interpretation to a functor between the categories $⟦Δ⟧$ and $⟦Ω⟧$, but the\nunderlying function remains the same. Semantic substitution is composition:\ngiven a type $T$ in size context $Ω$, whose interpretation is a functor from\n$⟦Ω⟧$ to $\\Sizes$, we define\n\\begin{displaymath}\n  \\sub{⟦T⟧}{⟦σ⟧} ≔ ⟦T⟧ ∘ ⟦σ⟧.\n\\end{displaymath}\n\nNow consider the substitution which assigns to the zeroth variable (in an\notherwise empty context) the size $1$:\n\\begin{displaymath}\n  σ ≔ \\Sing(\\ssuc{0}) ∶ () → \\ctx{()}{∞}.\n\\end{displaymath}\nIts interpretation is $⟦σ⟧(()) = ((), 1)$, where $()$ is the sole inhabitant of\nthe unit type. Further, let $T$ be the following type (in the context\n$\\ctx{()}{∞}$) of functions from streams to an arbitrary closed type $U$:\n\\begin{displaymath}\n  T ≔ \\Stream{v_0} → U.\n\\end{displaymath}\nThen we have\n\\begin{align*}\n  ⟦\\sub{T}{σ}⟧(())\n    &= ⟦\\Stream{1} → U⟧(()) \\\\\n    &= \\All{() ≤ ()}{⟦\\Stream{1}⟧(()) → ⟦U⟧(())} \\\\\n    &= \\All{() ≤ ()}{(\\All{k ≤ 1}{ℕ}) → ⟦U⟧(())} \\\\\n    &≅ (\\All{k ≤ 1}{ℕ}) → ⟦U⟧(())\n  \\\\\n  \\sub{⟦T⟧}{⟦σ⟧}(())\n    &= ⟦T⟧(⟦σ⟧(())) \\\\\n    &= ⟦\\Stream{v_0} → U⟧((), 1) \\\\\n    &= \\All{m ≤ 1}{⟦\\Stream{v_0}⟧((), m) → ⟦U⟧((), m)} \\\\\n    &= \\All{m ≤ 1}{(\\All{k ≤ m}{ℕ}) → ⟦U⟧(())}.\n\\end{align*}\nThese two types are not isomorphic, so substitutions do not have the desired\nsemantics.\n", "meta": {"hexsha": "fdbe4fe924cdd1c25f1e20b4479705e1f7642e75", "size": 7627, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/negative.tex", "max_stars_repo_name": "JLimperg/msc-thesis", "max_stars_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-14T01:30:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-14T01:30:46.000Z", "max_issues_repo_path": "include/negative.tex", "max_issues_repo_name": "JLimperg/msc-thesis", "max_issues_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/negative.tex", "max_forks_repo_name": "JLimperg/msc-thesis", "max_forks_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.1776315789, "max_line_length": 81, "alphanum_fraction": 0.6989642061, "num_tokens": 2522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4497766921000585}}
{"text": "\\chapter{Encryption}\\label{chap:encryption}\nIn this chapter, we introduce notations for fundamental moves of the most common Rubik's Cube $C_3$. We then work on constructing a group using states of $C_3$. We explain how the encryption protocol is built using the Rubik's Cube and move on to analyze the possible attacks against this encryption protocol. Finally, we layout some improvements to the encryption protocol.\n\n\\section{The classic Rubik's Cube}\n\\par Recall Figure~\\ref{fig:solved-cube}, $C_3$ has 3 layers where each layer is formed by 9 smaller cubes, so there are $3 \\cdot 9 = 27$ cubes in total. Among those 27 small cubes, 26 small cubes are visible since the center cube is surrounded by them and thus, hidden. If you take apart one Rubik's Cube, you will find that the center cube does not actually exist. In place of the center cube, there is a special structure that holds all other pieces together.\n\\par We can split the 26 small cubes into three different types. As shown in Figure~\\ref{fig:cube-type}, the small cubes in the corners are called ``corner cubes'', which have three visible colored pieces and there are 8 of them in total. The small cubes lie in the middle of each edge are called ``edge cubes'', which have two visible colored pieces and there are 12 of them. Finally, the cubes with a single visible colored piece located at center of each side of the cube are called ``center cubes''. Same as the number of sides a cube has, there are 6 of them.\n% ------------------------------ Draw Examples --------------------------------\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}[b]{0.45\\textwidth}\n        \\centering\n        \\RubikFaceUpAll{Y}\n        \\RubikFaceFrontAll{G}\n        \\RubikFaceRightAll{O}\n        \\ShowCube{5cm}{0.6}{\n            \\DrawRubikCubeRU\n            \\draw[line width=2pt, color=blue, <-] (2.5, 1.5) -- (6, 1.5);\n            \\node at (6, 2) [blue]{\\textbf{\\textsf{Edge Cube}}};\n\n            \\draw[line width=2pt, color=blue, <-] (2, 3.5) -- (2, 4.5);\n            \\node at (2, 5) [blue]{\\textbf{\\textsf{Center Cube}}};\n\n            \\draw[line width=2pt, color=blue, <-] (3.5, 3.8) -- (5, 5.5);\n            \\node at (5, 6) [blue]{\\textbf{\\textsf{Corner Cube}}};\n        }\n        \\setlength{\\abovecaptionskip}{0.7cm}\n        \\caption{Small cube types}\\label{fig:cube-type}\n    \\end{minipage}\n    \\begin{minipage}[b]{0.45\\textwidth}\n        \\centering\n        \\RubikFaceUpAll{Y}\n        \\RubikFaceFrontAll{G}\n        \\RubikFaceRightAll{O}\n        \\ShowCube{5cm}{0.6}{\n            \\DrawRubikCubeRU\n            % Right Face\n            \\draw[line width=2pt, color=blue, <-] (3.5,2) -- (5.5, 2);\n            \\node at (5, 2.5) [blue]{\\textbf{\\textsf{Right}}};\n            % Left Face\n            \\draw[line width=2pt, color=blue, <-] (-0.2,2) -- (-1.3, 2);\n            \\node at (-0.9, 2.5) [blue]{\\textbf{\\textsf{Left}}};\n            % Up Face\n            \\draw[line width=2pt, color=blue, <-] (2, 3.5) -- (2, 5.5);\n            \\node at (1.4, 4.8) [blue]{\\textbf{\\textsf{Up}}};\n            % Down Face\n            \\draw[line width=2pt, color=blue, <-] (2, -0.2) -- (2, -1.5);\n            \\node at (3, -1.1) [blue]{\\textbf{\\textsf{Down}}};\n            % Front Face\n            \\draw[line width=2pt, color=blue, <-] (1.5, 1.5) -- (0, -1);\n            \\node at (-0.5, -1.3) [blue]{\\textbf{\\textsf{Front}}};\n            % Back Face\n            \\draw[line width=2pt, color=blue, <-] (3.2, 4.2) -- (4, 5.5);\n            \\node at (4.6, 4.8) [blue]{\\textbf{\\textsf{Back}}};\n        }\n        \\caption{Rubik's Cube Notation}\\label{fig:cube-notation}\n    \\end{minipage}\n\\end{figure}\n% -----------------------------------------------------------------------------\n\\par In future discussions, we will refer sides of the Rubik's Cube as faces. To distinguish the six faces, we will call them right face, left face, up face, down face, front face and back face as shown in Figure~\\ref{fig:cube-notation}. Following this naming system, we can assign notations to the moves of $C_3$. The most basic move one can do it to rotate a single face of the cube. We use $U$ to denote a clockwise rotation of the up face. That is looking at the up face, turn it $90^\\circ$ clockwise. Similarly, we use letters $R$, $L$, $D$, $F$ and $B$ to denote the clockwise $90^\\circ$ rotation of the corresponding faces. For each of these six moves, there are three possible angles of rotation, which are $90^\\circ$ clockwise, $180^\\circ$ clockwise and $270^\\circ$ clockwise. In total there are $6 \\cdot 3 = 18$ possible moves and we will call these the \\textit{fundamental moves}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}{0.9\\textwidth}\n        \\centering\n        \\RubikCubeSolvedWY\n        \\ShowCube{2cm}{0.5}{\\DrawRubikCubeRU}\n        \\quad\\Rubik{U}\\quad\n        \\RubikRotation{U}\n        \\ShowCube{2cm}{0.5}{\\DrawRubikCubeRU}\n        \\quad\\Rubik{Up}\\quad\n        \\RubikRotation{Up}\n        \\ShowCube{2cm}{0.5}{\\DrawRubikCubeRU}\n        % Add a little space between the two graphs.\n        \\vspace*{10px}\n    \\end{minipage}\n    \\begin{minipage}{0.9\\textwidth}\n        \\centering\n        \\RubikCubeSolvedWY\n        \\ShowCube{2cm}{0.5}{\\DrawRubikCubeRU}\n        \\RubikRotation{U, U}\n        \\quad\n        \\SequenceBraceA{U2}{\\ShowSequence{}{\\Rubik}{\\SequenceLong}}\n        \\quad\n        \\ShowCube{2cm}{0.5}{\\DrawRubikCubeRU}\n    \\end{minipage}\n    \\caption{Rotation example}\\label{fig:cube-rotation-example}\n\\end{figure}\n\\par To represent the clockwise $180^\\circ$ rotation of the corresponding faces, we simply add a number 2 after the capital letters. Therefore, $U2$ represents the move where we face the up face and rotate it $180^\\circ$ clockwise. For the $270^\\circ$ clockwise rotation, which is same as a $90^\\circ$ counterclockwise rotation, we add an apostrophe after the capital letter to denote it. Then $U'$ represents the move where we face the up face and rotate it $90^\\circ$ counterclockwise. All above notations defined are illustrated in Figure~\\ref{fig:cube-rotation-example}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}{0.48\\textwidth}\n        \\centering\n        \\begin{tikzpicture}[scale=0.5]\n            \\draw[thick] (4.5,-0.5) -- (7.5,-0.5) -- (7.5,-9.5) -- (4.5,-9.5) -- cycle;\n            \\draw[thick] (1.5,-3.5) -- (13.5,-3.5) -- (13.5,-6.5) -- (1.5,-6.5) -- cycle;\n            \\draw[thick] (10.5,-3.5) -- (10.5,-6.5);\n            \\node[thick, scale=1.2] at (6,-2) {Up};\n            \\node[thick, scale=1.2] at (3,-5) {Left};\n            \\node[thick, scale=1.2] at (6,-5) {Front};\n            \\node[thick, scale=1.2] at (9,-5) {Right};\n            \\node[thick, scale=1.2] at (12,-5) {Back};\n            \\node[thick, scale=1.2] at (6,-8) {Down};\n        \\end{tikzpicture}\n    \\end{minipage}\n    \\begin{minipage}{0.48\\textwidth}\n        \\centering\n        \\RubikCubeSolvedWY\n        \\RubikRotation{T,F,R,D,B,L,Tp,Fp,Rp,Dp,Bp,Lp}\n        \\ShowCube{7cm}{0.5}{\\DrawRubikCubeF}\n        \\vspace{0.5cm}\n    \\end{minipage}\n    \\begin{minipage}{0.99\\textwidth}\n        \\centering\n        \\RubikRotation{T,F,R,D,B,L,Tp,Fp,Rp,Dp,Bp,Lp}\n        \\ShowSequence{}{\\Rubik}{\\SequenceLong}\n    \\end{minipage}\n    \\caption{A state of the Rubik's Cube}\\label{fig:cube-state-example}\n\\end{figure}\n\\par As we mentioned earlier, we refer each possible shuffling result of the cube as a state. Figure~\\ref{fig:cube-state-example} is one possible state of the cube. The shuffling can be any combination of the fundamental moves applied to a solved cube. Each state of the cube is unique, though infinitely many different shufflings could reach it. Suppose we are at a state $S$ that can be reached by series of fundamental moves $M$. Then if we add ``$R\\,R\\,R\\,R$'' at the end of $M$, we are still at state $S$ since ``$R\\,R\\,R\\,R$'' simply rotates the right face $360^\\circ$ clockwise and does not actually change it. In fact, we can insert any number of ``$R\\,R\\,R\\,R$'' anywhere in $M$. Also, we do not have to always use $R$, any four fundamental moves will rotate one face of the cube by a multiple of $360^\\circ$ and hence do not modify the cube. Thus we have infinitely many ways to reach $S$.\n\\par We now want to show that we can make the set of states of $C_3$ into a group. Let us denote the group as $G_3$ where the group operation is $*$, and each element of $G_3$ is a state. Though arguments below correspond to $C_3$, we can use them to construct group $G_n$ for states of an arbitrary cube $C_n$ in a similar fashion. \n\\par Assume $S_1$ and $S_2$ both represent a state of the classic 3 by 3 by 3 cube, that is $S_1, S_2 \\in G_3$. Assume $S_1$ can be reached by a series of moves $M_1$ applied to the solved cube and similarly $S_2$ can be reached by a series of moves $M_2$ applied to the solved cube. Then $S_1 * S_2$ is the state you could reach to by first applying $M_1$ and then $M_2$ to the solved cube, or equivalently, you can directly apply $M_2$ to $S_1$. Then it is obvious that if we pick a different $M'$ which takes us from the solved cube to $S_1$, $S_1 * S_2$ still gives us the same result. Therefore the operation $*$ is well defined. We now can show a simple proof that $G_3$ is indeed a group under $*$. \\\\\n\\textit{Claim}: $G_3$ is a group under $*$.\n\\begin{proof}[Proof:]\\item\n    \\begin{itemize}\n        \\item Show closure. \\\\\n        Suppose we have $S_1, S_2 \\in G_3$. From above description, we see that $S_1 * S_2$ can be reached by combining two series of moves. Thus $S_1 * S_2$ is indeed a state of the cube. Therefore $G_3$ is closed.\n        \\item Show identity. \\\\\n        The solved cube is the identity and we denote it as $e$. It represents the \"empty\" move. Suppose we have $S \\in G_3$, then $e*S$ means do nothing and move to $S$. Similarly $S*e$ means applying nothing to $S$. Therefore the solved cube is the identity.\n        \\item Show associativity. \\\\\n        Suppose we have $S_1, S_2, S_3 \\in G_3$. Clearly $(S_1 * S_2) * S_3 = S_1 * (S_2 * S_3)$ since the order we apply those moves does not change even if we combine two states together. \n        \\item Show inverse. \\\\\n        Suppose we have $S \\in G_3$ and $S$ can be reached by a series of moves $M$ applied to the solved cube. Each move in $M$ is one of the 18 possible fundamental moves. All fundamental moves have their inverses. For example, $U$ can be reversed by $U'$ and $U2$ can be reversed by $U2$. Thus there must exist a series of moves $M'$ that reverses $M$. We can find $M'$ by inverting of all movements in $M$ in reverse order. That is, the move that was done the last shall be undone first. Applying $M'$ to the solved cube to obtain $S'$ then $S*S' = S'*S = e$.\n    \\end{itemize}\n    Therefore $(G_3, *)$ is a group.\n\\end{proof}\n\n\\section{The design principle}\n\\par ``Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.'' This is one of my favorite quote from Albert Einstein. Let us assume that we now want to secretly pass this quote to someone using the Rubik's Cube. The general idea is, as we mentioned in Chapter~\\ref{chap:introduction}, instead of letting each cubie to hold a color, we use cubies to hold letters. We then need to agree on an order that we put the letters in. As long as we are consistent, we can order the six faces in any way we desire. Once we fill all the faces, we can shuffle the cube to obtain the ciphertext. But before we get started on filling the cube with letters, some pre-processing to the plaintext is essential. We want to remove blanks and punctuations, since their existences in the ciphertext leaks important information about the plaintext. An eavesdropper can count the number of blanks to deduce how many words were encrypted. Afterwards, we also want to make sure all the letters are either capitalized or lower cased. Here we choose to capitalize everything and the processed string looks like the following:\n\\begin{center}\n    \\texttt{DONOTWORRYABOUTYOURDIFFICULTIESINMATHEMATICSI} \\\\\n    \\texttt{CANASSUREYOUMINEARESTILLGREATERALBERTEINSTEIN}\n\\end{center}\nSince we are using the classic Rubik's Cube $C_3$, we can put $3 \\cdot 3 = 9$ letters on each face. At one time, we can use the cube to encrypt at most $9 \\cdot 6 = 54$ letters. Our message is too long to fit, but we can take 54 letters and encrypt them first. Here are the first 54 letters split into chunk of 9:\n\\begin{center}\n    \\textcolor{blue}{\\texttt{DONOTWORR}} \\; \\textcolor{red}{\\texttt{YABOUTYOU}} \\; \\textcolor{blue}{\\texttt{RDIFFICUL}} \\;\n    \\textcolor{red}{\\texttt{TIESINMAT}} \\; \\textcolor{blue}{\\texttt{HEMATICSI}} \\; \\textcolor{red}{\\texttt{CANASSURE}}\n\\end{center}\n\\par Let us agree on the order of filling the letters as the following: up face $\\rightarrow$ front face $\\rightarrow$ right face $\\rightarrow$ down face $\\rightarrow$ back face $\\rightarrow$ left face. The cube with letters filled is displayed in Figure~\\ref{fig:cube-plain-text}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}{0.45\\textwidth}\n        \\centering\n        \\includegraphics[width=6cm]{figures/encryption/cube_plain_text.png}\n        \\caption{Cube with plaintext}\\label{fig:cube-plain-text}\n    \\end{minipage}\n    \\begin{minipage}{0.45\\textwidth}\n        \\centering\n        \\includegraphics[width=6cm]{figures/encryption/cube_cipher_text.png}\n        \\caption{Cube with ciphertext}\\label{fig:cube-cipher-text}\n    \\end{minipage}\n\\end{figure}\nWe then need to determine a sequence of fundamental moves as our encryption key, which we denote as $k$. Suppose we apply ``$R\\,U\\,B2\\,L'\\,D2\\,F\\,R'\\,D\\,B\\,L2\\,$'' to the cube. The shuffled cube is shown as Figure~\\ref{fig:cube-cipher-text}. To obtain the entire ciphertext $c$, which is shown below, we simply read out all the letters the same order we put them in. \n\\begin{center}\n    \\textcolor{blue}{\\texttt{MDIATNNST}} \\; \\textcolor{red}{\\texttt{UAUAUOHIN}} \\; \\textcolor{blue}{\\texttt{CACIFFTSR}} \\; \n    \\textcolor{red}{\\texttt{YWLTIEBRM}} \\; \\textcolor{blue}{\\texttt{EOCOTROID}} \\; \\textcolor{red}{\\texttt{ESIOSUYAR}}\n\\end{center}\n\\par We now send the ciphertext $c$ to the receiver. It is crucial for us to have shared the key secretly with the receiver. We will discuss a method to do so in Chapter~\\ref{chap:exchange}. Upon receiving the ciphertext, the receiver can decrypt the ciphertext by first finding the inverse of the key, which we denote as $k'$. By following the step described in proving the inverses of group $G_3$, we find $k'$ is ``$L2\\,B'\\,D'\\,R\\,F'\\,D2\\,L\\,B2\\,U'\\,R'\\,$''. Then the receiver can fill the cube with the ciphertext and apply $k'$ to the cube.\n\\par Let us take a closer look at what happened during the encryption. We notice that all letters that were in plaintext are present in the ciphertext. However most of them ended up in different locations. If we observe the center of each face, we can find that they all remained in the same places. This is not a coincidence since none of the basic moves changes the center. Therefore among the 54 letters, at most 48 letters can be permuted.\n\n\\section{Brute force attacks}\n\\par Let us consider the brute force attacks against this protocol. There are two relative obvious ways of doing so. From above discussion, we know the ciphertext is just one possible permutation result of 48 letters within the plaintext. Thus if we list out all elements of $S_{48}$, the permutation group on 48 elements, and apply each to the ciphertext, one of the permutations must revert the ciphertext back to the plaintext.\n\\par Though the group $S_{48}$ has $48! \\approx 1.24 \\cdot 10^{61}$ elements, later in this thesis, we will show that not all those permutations are needed to be checked. Even though Rubik's Cube permutes 48 elements, the size of the group $G_3$ is smaller than $S_{48}$, since there are invalid states that cannot be reached by series of fundamental moves. Potentially you can take the cube apart and put it back together to get to a invalid state. We will talk about what states are invalid and why they are invalid in Chapter~\\ref{chap:structure} when we explore more about the group structure.\n\\par The other possible attack is to search the inverse of the encryption key. Without knowing the length of the key we used, the attacker can start with trying out all combination of fundamental moves with length of 1, length of 2 and so on. For each combination the attacker selects, he/she applies it to the cube and observe if the result makes sense. As an example, there are $18^2$ possible keys with length of 2 since every time the attacker can pick one from the 18 fundamental moves. It follows that, in our example, the number of keys the attacker needs to go through is upper bounded by $\\sum_{i=1}^{10}18^i \\approx 3.78 \\cdot 10^{12}$.\n\\par By comparing the two brute force attacks described above, we notice that finding the inverse of the key would be easier for the attacker. It seems that there is a straightforward approach to make this brute force attack infeasible, which is to increase the key length. Instead of using a key with a length of 10 fundamental moves, we can randomly pick a key that is formed by 1000 fundamental moves. Then if we follow above methods, we will find the number of keys the attacker have go through being bounded by $\\sum_{i=1}^{1000}18^i \\approx 1.98 \\cdot 10^{199}$ which is obviously a way larger number. However this approach will not work as expected due the existence of the God Number.\n\n\\section{The God Number}\n\\par We know that mathematicians love the Rubik's Cube as they are amazed by how such a seemingly regularly puzzle can hold so many secrets. Ever since the problem is invented, perhaps the biggest mystery of all is the upper bound for number of fundamental moves to reach to all possible states. The lower bound is proved earlier in 1995 by Michael Reid\\cite{god}. Reid found that the superflip, which keeps all small cubes in their solved locations but flips the orientation of all edge cubes, as displayed in Figure~\\ref{fig:superflip} requires at least 20 fundamental moves. \n\\begin{figure}[ht]\n    \\centering\n    \\RubikCubeSolvedWY\n    \\RubikRotation{\\superflip}\n    \\ShowCube{8cm}{0.7}{\\DrawRubikCubeSF}\n    \\caption{Superflip}\n    \\label{fig:superflip}\n\\end{figure}\nIt took mathematicians about 30 years to prove that this is an upper bond. We formally define the God Number as:\n\\newpage\n\\begin{definition}\\textbf{The God Number} \\\\\n    Let $m(S_1, S_2)$ denote the minimum number of fundamental moves to transform $C_3$ from $S_1$ to $S_2$. Then the God Number is $max\\{m(S_1, S_2) \\;|\\; S_1, S_2 \\in G_3\\}$.\n\\end{definition}\n\\par With about 35 CPU-years of idle computer time donated by Google, a team of researchers essentially solved every position of the Rubik's Cube and showed in 2010 that the God Number is 20\\cite{god}. Another way to express the meaning of the God Number is that any series of fundamental moves with length longer than 20 can be reduced to a series of fundamental moves with length less or equal to 20. Thus, we can not find two states in the Rubik's Cube that are more than 20 fundamental moves away. We can also say that the Rubik's Cube group $G_3$ we defined has a diameter of 20 fundamental moves.\n\\par Therefore, even if we have chosen a key with length of a thousand fundamental moves, the attacker will find the inverse of the key with only searching for keys that having length of 20 fundamental moves or less. That is, the number of keys the attacker has to go through is really bounded by $\\sum_{i=1}^{20}18^i \\approx 1.35 \\cdot 10^{25}$, regardless to the key length we choose. It follows that the key search attack will almost always be easier than the attack on finding inverse of the permutation. It is also worthwhile to note that the God Number for larger cubes is unknown, so we are not able to perform a similar analysis on larger cubes.\n\n\\section{Improvements}\n\\par In this section, we discuss solutions that prevent the key from collapsing and other tweaks to our design to improve the security of our protocol in general. First, let us observe some additional features provided by Rubik's Cubes that we overlooked. \n\\par Suppose we fill a letter E in the right up corner cubie on the front face of the cube as shown in Figure~\\ref{fig:cube-letter}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}{0.49\\textwidth}\n        \\centering\n        \\includegraphics[width=4cm]{figures/encryption/cube_face_letter.png}\n        \\caption{Front face with letter}\\label{fig:cube-letter}\n    \\end{minipage}\n    \\begin{minipage}{0.49\\textwidth}\n        \\centering\n        \\includegraphics[width=4cm]{figures/encryption/cube_face_letter_rotate.png}\n        \\caption{Front face with rotated letter}\\label{fig:cube-letter-rotate}\n    \\end{minipage}\n\\end{figure}\nIf we rotate the front face 90 degrees clockwise, as shown in Figure~\\ref{fig:cube-letter-rotate}, we can find the position of letter \\textbf{E} changes. However, we also notice that the orientation of \\textbf{E} changes. Since anyone who reads English can still recognize those letters even if their direction changed, we omitted this feature while developing the encryption scheme. To benefit from this feature, we can use something that rotates while the cube faces rotate. Therefore, instead of putting the letters, we can put four bits into each cubie, where each corner of the cubie holds one bit. We need to agree on an order of placing those bits, for example: left up corner $\\rightarrow$ right up corner $\\rightarrow$ right down corner $\\rightarrow$ left down corner, so we get a complete cycle here. Assume that we are putting integers from 1 to 36 on one face of the cube in the order, the face will look like what is displayed in Figure~\\ref{fig:bit-order}.\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=4cm]{figures/encryption/bit_order.png}\n    \\caption{Bit ordering}\\label{fig:bit-order}\n\\end{figure}\nWe now can run the above experiment again with input ``1000.'' Following the order we agreed, we put the bits into the left up corner cubie on the front face as shown in Figure~\\ref{fig:cube-bit} and the face after the rotation is displayed in Figure~\\ref{fig:cube-bit-rotate}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{minipage}{0.49\\textwidth}\n        \\centering\n        \\includegraphics[width=4cm]{figures/encryption/cube_face_bit.png}\n        \\caption{Front face with bits}\\label{fig:cube-bit}\n    \\end{minipage}\n    \\begin{minipage}{0.49\\textwidth}\n        \\centering\n        \\includegraphics[width=4cm]{figures/encryption/cube_face_bit_rotate.png}\n        \\caption{Front face with rotated bits}\\label{fig:cube-bit-rotate}\n    \\end{minipage}\n\\end{figure}\nIf we read out the bits the same order we put them in, we get ``0100'', which is different from the original input. Hence using bits helps us benefit from the face rotations of the Rubik's Cube. Though this method does not directly address the key collapsing issue, it gives us more flexibility to modify the encryption protocol. We will make further improvements based on this setting.\n\\par One obvious reason the key would collapse is because some fundamental moves commute with each other. Clearly, each fundamental move commutes with itself regardless of the angle; for example $R$, $R2$ and $R'$ commute with each other. Also, the moves that rotate opposite sides commute with each other. For instance $R$, $R2$ and $R'$ commute with $L$, $L2$ and $L'$. Suppose we find a series of moves within a random key of length 15 as ``$R2\\,L2\\,R2\\,L\\,L\\,$''. Since those moves commute, they are equivalent to ``$R2\\,R2\\,L2\\,L\\,L\\,$''. In words, what this chunk of key does is rotating the right face $360^\\circ$ clockwise and then rotating the left face $360^\\circ$ clockwise, which has precisely no effect on the cube. Thus we can merely remove this chunk from the random key and its length will collapse down from 15 to 10. \n\\par To resolve this issue, we can shift the content to the right by one bit each time before we apply a move to the cube. Each one of the bits will move to the next position following the order they were put in. For example, recall Figure~\\ref{fig:bit-order}, the bit at location of number $n$ will be shifted to the location of number $n + 1$. Notably, the last bit on one face will become the first bit on the face next to it. For instance, the last bit on the up face will become the first bit on the front face.\n\\begin{figure}[ht]\n    \\centering\n    $\\xrightarrow{\\text{fill bits\\;\\;}}$\n    \\begin{minipage}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=3.5cm]{figures/encryption/bit_start.png}\n    \\end{minipage}\n    $\\xrightarrow{\\text{shift bit}}$\n    \\begin{minipage}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=3.5cm]{figures/encryption/bit_shift_one.png}\n    \\end{minipage}\n    \\\\ $\\xrightarrow{\\text{apply }F}$\n    \\begin{minipage}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=3.5cm]{figures/encryption/bit_rotate_one.png}\n    \\end{minipage}\n    $\\xrightarrow{\\text{shift bit}}$\n    \\begin{minipage}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=3.5cm]{figures/encryption/bit_shift_two.png}\n    \\end{minipage}\n    \\\\ $\\xrightarrow{\\text{apply }F'}$\n    \\begin{minipage}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=3.5cm]{figures/encryption/bit_rotate_two.png}\n    \\end{minipage}\n    \\caption{The bit shift method}\\label{fig:bit-shift}\n\\end{figure}\nAs shown in Figure~\\ref{fig:bit-shift}, we put ``1234'' in the right up corner of the front face and apply moves $F$ and $F'$ to the cube. We follow the procedures defined above and shift the bits before applying each move. Though ``1234'' is not a legal input to the Rubik's Cube encryption, we use it to clearly illustrate where each bits travels to. By observing the front face in the last row of Figure~\\ref{fig:bit-shift}, we find the locations of all bits changed, though $F$ and $F'$ cancel each other out. Among the four bits, two bits even moved to other cubies. Therefore, with the shift, the bits travel around even when moves commute and cancel each other out as fundamental moves. We believe this method effectively prevents the key from collapsing. Also, this method addresses the \"fixed center\" issue since the shift affects bits that are held by center cubies.\n\\par To examine the modified encryption protocol, we can try to encrypt my favorite quote from Einstein again with the modified Rubik's Cube encryption. Notice we first need to convert the English letters to their ASCII representations, so each letter will be 8 bits long. Since $C_3$ can hold 216 bits, we can encrypt $\\frac{216}{8} = 27$ letters at once. The first 27 letters are ``\\texttt{DONOTWORRYABOUTYOURDIFFICUL}'' and the following is its binary representation:\n\\begin{center}\n    010001000100111101001110010011110101010001010111010011110101001001010010\n    010110010100000101000010010011110101010101010100010110010100111101010101\n    010100100100010001001001010001100100011001001001010000110101010101001100\n\\end{center}\nWe can use the same key ``$R\\,U\\,B2\\,L'\\,D2\\,F\\,R'\\,D\\,B\\,L2\\,$'' to encrypt the plaintext but this time we will account for the shift before applying each move to the cube. The encrypted ciphertext is:\n\\begin{center}\n    001110100110100110111010011100000010100011101111111010011111101111011101\n    001000011001100011110000001000111111110110000010010100000000011010001000\n    010011101010011010010100110001010100101000000110100110001100011010100001\n\\end{center}\nFrom Figure~\\ref{fig:bit-order}, we see that the center of the cube face goes from the 17th position to the 20th position. We thus can find, in the plaintext, the center of the up face holds $1001$ and this value changed to $0111$ after the encryption. Among the four bits, only one bit actually remained the same. So in this particular example, the shifting bits is effectively helping to change the bits held by the center cubes.\n\\par We can convert the ciphertext back to ``letters''. But since we can no longer guarantee that each chunk of 8 bits still represent a value that is less than or equal to 127, we need to rely on the extended ASCII table as shown in Figure~\\ref{fig:ascii} to convert the ciphertext back to ``letters.'' \n\\begin{figure}\n    \\centering\n    \\includegraphics[width=12cm]{figures/encryption/ascii.png}\n    \\caption{Extended ASCII table}\n    \\label{fig:ascii}\n\\end{figure}\nThe following characters are the results of the conversion: ``:i$\\|$p($\\cap\\uptheta\\surd\\blacksquare$!\\\"{y}$\\equiv$\\#$^2$\\'{e}P\\;\\^{e}N$^a$\\\"{o}$\\dagger$J\\;\\\"{y}$\\vdash$\\'{\\i}.'' As one can notice that while we are using the extended ASCII, many more special characters will be involved. We find that the only common letter that exists in both the ciphertext and the plaintext is the letter N, but the location of it has changed. \n\\par The essence of the shift on the bits is just a permutation. We described the shift as a minimum working example, but we are free to pick any permutation on the 216 bits as long as we can specify it. To add more security, we can select a more complex permutation and secretly share it as part of the key with other trusted parties.\n\n\\section{Encrypt long messages}\n\\par When we first defined the Rubik's Cube encryption, we noticed that we could not use it to encrypt the entire quote, since the Rubik's Cube can only fit a certain amount of the plaintext at once. In real life, we may often need to encrypt messages that are much longer. Thus, we introduce two methods that help us encrypt long messages.\n\\par The first method is designed targeting the Rubik's Cube encryption. We have been using $C_3$ for the encryption, but in Chapter~\\ref{chap:introduction} we mentioned that cubes with larger side length do exist. Hence we can use a Rubik's Cube with greater side length to extend the size of the message we are capable of encrypting. Suppose we instead use a 10 by 10 by 10 Rubik's Cube, denoting as $C_{10}$, we can encrypt $10^2 \\cdot 6 \\cdot 4 = 2400$ bits at once. If we are using ASCII representation of English letters, we can encrypt 300 letters at once. The advantage of using more giant cubes is that we make both brute force attacks we discussed earlier more challenging to succeed. To begin with, when the side length of the Rubik's Cube gets greater, we permute much more bits. For $C_{10}$, we permute 2400 bits, and thus the attacker has to search through group $S_{2400}$ which has $2400!$ elements. For an arbitrarily large cube $C_n$, we permute $24 \\cdot n^2$ bits. It follows that if the attacker wants to search through the permutation group, he/she has to go through $(24 \\cdot n^2)!$ possibilities. Therefore finding the inverse of the permutation will require much more computations as the side length of the cube increases. Besides, more giant cubes have more than just 18 fundamental moves. For example, $C_{10}$ has 180 fundamental moves. Since each time there are much more fundamental moves to select, finding the inverse of the key will get a lot harder too.\n\\par There are also two vulnerabilities of this approach. The first one is that we still cannot encrypt an arbitrarily long message. Once we fix a cube length, say 20, we do not want to change it during the communications. The reason is that, while modifying the size of the cube, we are changing the key space as well. That is the fundamental moves we can select for $C_3$ and $C_{20}$ are obviously different. However, for private key encryptions, we commonly exchange the secret key once before building the secure channel between parties, and we use the same key for all of the following communications. Secondly, we may end up wasting a lot of space when we need to encrypt a relatively short message since the cube size is fixed.\n\\par A more general approach that works for message with arbitrary length $l$ is called the cipher block chaining (CBC) mode, which the is the most commonly used mode of operation. Let us first introduce the operation ``XOR'' is denoted as $\\oplus$ and it is also called ``exclusive or''. It gains the name \"exclusive or\" because it excludes the case when both operands are true.\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|c|c|c|}\n        \\hline Input A & Input B & A $\\oplus$ B \\\\ \\hline\\hline\n        1 & 1 & 0 \\\\ \\hline \n        1 & 0 & 1 \\\\ \\hline\n        0 & 1 & 1 \\\\ \\hline\n        0 & 0 & 0 \\\\ \\hline\n    \\end{tabular}\n    \\caption{XOR truth table}\\label{tab:xor-truth-table}\n\\end{table}\n``XOR'' is a logical operation that outputs true only when inputs differ. We build the truth table for it as shown in Table~\\ref{tab:xor-truth-table}.\n\\par In CBC mode, each block of plaintext is XORed with the previous ciphertext block before being encrypted as shown in Figure~\\ref{fig:cbc-encryption}.\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=14cm]{figures/encryption/CBC_encryption.png}\n    \\caption{CBC mode encryption\\cite{cbc_enc}}\\label{fig:cbc-encryption}\n\\end{figure}\nHence each ciphertext block depends on all plaintext blocks processed up to that point. To make each message unique, we can use an initialization vector to XOR with the first block. Assume in total there are $k$ blocks of plaintexts $(m_0, m_1, ..., m_k)$ needed to be encrypted, the output will be $k$ blocks of ciphertexts $(c_0, c_1, ..., c_k)$.\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=14cm]{figures/encryption/CBC_decryption.png}\n    \\caption{CBC mode decryption\\cite{cbc_dec}}\\label{fig:cbc-decryption}\n\\end{figure}\nGiving all the ciphertexts, to retrieve $m_x$ where $2 \\leq x \\leq k$, we decrypt $c_x$ with the key and then XOR the result with $c_{x-1}$ to get $m_x$ back as shown in Figure~\\ref{fig:cbc-decryption}. The first ciphertext $c_1$ is unique since we need to XOR its decryption result with the initialization vector to recover $m_1$. Though this general approach is easy to manage, it has some potential vulnerabilities such as one bit wrong in the $x_{th}$ ciphertext will generate errors in all blocks after it.\n\\par Finally, for both approaches discussed above, we have to deal with one more issue. In most times, we probably will not have a message that fits perfectly with the encryption scheme we have. Suppose we have a message $m$ with length of 2000 bits and we are using $C_{10}$ to encrypt it. Recall that $C_{10}$ offers 2400 spaces for bits and thus we have 400 spare spaces. We want to agree on a simple padding algorithm so that we do not have to leave some spaces blank. To pad the message $m$, we simply add a one at the end of it and add 399 more zeros to get the desired length. Notice that we have to complete the padding before encrypting the message. After decryption, the receiver simply removes all trailing zeros and removes one extra 1 to retrieve the original plaintext. This padding scheme will work for the CBC mode as well. Assume we are chaining a list of $C_3$ to encrypt $m$, we then need $\\lceil \\frac{2000}{216} \\rceil = 10$ blocks, which offers $216 \\cdot 10 = 2160$ spaces. Similar to above, we have to add a one and 159 more zeros at the end of $m$ to get the desired length. Note that if our message splits up evenly into $k$ blocks, we need to add in the $k+1$th block for just the padding.\n\\par In this chapter, we have designed a symmetric encryption scheme that avoids some apparent shortcomings and can encrypt arbitrarily long messages. In the next chapter, we will analyze our protocol under a more formal framework and see that further improvements are needed.", "meta": {"hexsha": "829f4ee0e8363b0b0ed6291187ed5a96c4bfa7d7", "size": 35500, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/chapters/encryption.tex", "max_stars_repo_name": "Weiqi97/Honor-Thesis", "max_stars_repo_head_hexsha": "eff11dea2fe14a66e787154c9c0bd1ed4b02bd06", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/chapters/encryption.tex", "max_issues_repo_name": "Weiqi97/Honor-Thesis", "max_issues_repo_head_hexsha": "eff11dea2fe14a66e787154c9c0bd1ed4b02bd06", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/chapters/encryption.tex", "max_forks_repo_name": "Weiqi97/Honor-Thesis", "max_forks_repo_head_hexsha": "eff11dea2fe14a66e787154c9c0bd1ed4b02bd06", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 112.3417721519, "max_line_length": 1489, "alphanum_fraction": 0.7233521127, "num_tokens": 9739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4497094064405176}}
{"text": "\\chapter{Co-Word Problems}\\label{chp:coword-problems}\n\nLet $G$ be a group with a finite monoid generating set $S$.\nThen, if we are given two words $u,v \\in S^*$, it is a natural question to ask whether these words represent the same group element.\nThis question is equivalent to asking if the word $w = uv^{-1} \\in S^*$ represents the group identity.\nWe then define the formal language\n\\[\n\t\\WP_S\n\t=\n\t\\left\\{\n\t\tw \\in S^*\n\t\\mid\n\t\t\\overline{w} = 1\n\t\\right\\}\n\\]\nwhich we refer to as the \\emph{word problem} with respect to the generating set $S$.\n\nFor each finite monoid generating set $S$ of $G$, we see that $\\left\\langle S \\mid \\WP_S \\right\\rangle$ is a presentation for $G$.\nThus, the word problem completely describes a group.\nA classification of the word problem is thus one method to characterise the complexity of a group.\n\nThe study of the formal language complexity of group word problems began with \\textcite{anisimov1971} who showed that the word problem is regular if and only if the group is finite.\nThis was extended by \\textcite{muller1983} who showed that a group has a context-free word problem if and only if it is virtually free, in which case, the word problem is deterministic context-free.\nIt was shown by \\textcite{elder2008} that a group has a word problem that is (deterministic) blind multicounter if and only if it is virtually abelian.\nIt was shown by \\textcite{holt2008} that a group has a \\emph{growing context-sensitive} word problem if and only if its word problem can be solved by a certain generalisation of \\emph{Dehn's algorithm}, however, this result does not appear to provide a group-theoretic classification.\n\nAn alternate method of obtaining characterisation of group word problems is to characterise the \\emph{co-word problem} $\\coWP_S = S^* \\setminus \\WP_S$, that is, the formal language\n\\[\n\t\\coWP_S\n\t=\n\t\\left\\{\n\t\tw \\in S^*\n\t\\mid\n\t\t\\overline{w} \\neq 1\n\t\\right\\}.\n\\]\nIt is known that regular and deterministic context-free languages are closed under taking set complements, see \\cite[Theorem~8.4]{rich2007} and \\cite[Theorem~2.42]{sipser2013}, respectively.\nThus, the co-word problem for a group is\n\\begin{itemize}\n\t\\item regular if and only if the group is finite; and\n\t\\item deterministic context-free if and only if the group is virtually free.\n\\end{itemize}\nThe class of groups for which $\\coWP_S$ is context-free was first studied by \\textcite{holt2005}, in particular, they showed that a polycyclic group has a context-free co-word problem if and only if it is virtually abelian.\nThe study of co-context-free groups was later extended by \\textcite{lehnert2007} who showed that Thompson's group $V$ has a context-free co-word problem.\nIt is conjectured \\cite[Conjecture~5]{bleak2016} that a group has a context-free co-word problem if and only if it is a subgroup of Thompson's group $V$.\nHowever, a potential counter-example to such a classification is provided in \\cite{berns-zieve2014}.\n\nIt was shown by \\textcite{holt2006} that the class of \\emph{bounded automata groups} have co-word problems that can be recognised as \\emph{indexed languages}, as defined by \\textcite{aho1968}.\nThe class of bounded automata groups includes important examples such as Grigorchuk's group of intermediate growth, the Gupta-Sidki groups, and many more~\\cite{grigorchuk1980,gupta1983,nekrashevych2005,sidki2000}.\n\nET0L languages form a proper subfamily of the indexed languages (see Corollary~4.1 in~\\cite{culik1974} and Proposition~4.5 in~\\cite{ehrenfeucht1976}).\nFor the specific case of the Grigorchuk group, \\textcite{ciobanu2018} constructed an ET0L grammar for the co-word problem.\nIn this chapter, we generalise this result by showing that the co-word problem for any bounded automata group is ET0L.\nIn particular, for each bounded automata group, we construct a cspd automaton which recognises the language of geodesics.\n\n\\section{Generating Sets}\\label{sec:background-coword-problems}\n\nMany interesting families of formal language are closed under inverse word homomorphism, as defined in \\cref{defn:closed-under-inv-word-hom}.\nFor example, the class of regular, context-free and ET0L languages have this closure property.\n\n\\begin{definition}\\label{defn:closed-under-inv-word-hom}\n\tA family of formal languages $\\mathcal{F}$ is \\emph{closed under inverse word homomorphism}, if for each language $L \\in \\mathcal{F} \\subseteq \\Sigma^*$, and each monoid homomorphism $h \\colon \\Gamma^* \\to \\Sigma^*$ where $\\Gamma$ is an alphabet, the language\n\t$\n\t\th^{-1}(L)\n\t\t=\n\t\t\\{\n\t\t\tw \\in \\Gamma^*\n\t\t\t\\mid\n\t\t\th(w) \\in L\n\t\t\\}\n\t$\n\tlies within $\\mathcal{F}$.\n\\end{definition}\n\nWe then see that the formal language complexity of the co-word problem for a group is well defined in the following sense.\n\n\\begin{lemma}\\label{lem:well-defined-coword}\n\tLet $G$ be a group with a finite monoid generating set $S$.\n\tIf $\\coWP_S \\in \\mathcal{F}$ and $\\mathcal{F}$ is closed under inverse word homomorphism, then $\\coWP_X \\in \\mathcal{F}$ for each finite monoid generating set $X$ of $G$.\n\\end{lemma}\n\n\\begin{proof}\n\tFor each $x \\in X$ we choose a word $w_x \\in S^*$ such that $\\overline{x} = \\overline{w_x}$.\n\tWe then define a monoid homomorphism $h \\colon X^* \\to S^*$ where $h(x) = w_x$ for each $x \\in X$.\n\tWe see that $\\coWP_X = h^{-1}(\\coWP_S)$, and thus $\\coWP_X \\in \\mathcal{F}$ as required.\n\\end{proof}\n\nLet $\\mathcal{F}$ be a family of languages which is closed under inverse word homomorphism.\nThen, a group is co-$\\mathcal{F}$ if its co-word problem lies in the class $\\mathcal{F}$, for any and thus all generating sets.\nIt was shown by \\textcite[Corollary~3.2~on~p.~40]{culik1974} that ET0L languages form a \\emph{full AFL}, one of the defining properties of this being closure with respect to inverse word homomorphism.\nFrom \\cref{lem:well-defined-coword} it is well defined to ask if a group is co-ET0L.\n\n\\section{Bounded Automata Groups}\\label{sec:bounded-automata-groups}\n\nIn this section, we define the class of \\emph{bounded automata groups}.\nEach such group is a group of automorphisms of an infinite rooted tree and can be completely described using finitely many finite-state rewrite automata.\nWe begin by defining rooted trees as follows.\n\nFor $d \\geq 2$, let $\\mathcal{T}_d$ denote the $d$-regular rooted tree, that is, the infinite rooted tree where each vertex has exactly $d$ children.\nWe identify the vertices of $\\mathcal{T}_d$ with words in $\\Sigma^*$ where $\\Sigma = \\{ a_1, a_2, \\ldots, a_d \\}$.\nIn particular, we identify the root with the empty word $\\varepsilon \\in \\Sigma^*$ and we identify the $k$-th child of each vertex $v \\in \\mathrm{V}(\\mathcal{T}_d)$ with the word $v a_k$, see \\cref{fig:tree-vertex-labelling}.\n\n\\begin{figure}[h!t]\n\t\\centering\n\t\\includegraphics{figure/labelledTree}\n\t\\caption{A labelling of the vertices of $\\mathcal{T}_d$.}\n\t\\label{fig:tree-vertex-labelling}\n\\end{figure}\n\nRecall that an automorphism of a graph is a bijective mapping of the vertex set that preserves adjacency, thus an automorphism of $\\mathcal{T}_d$ preserves the root and levels of the tree.\nWe denote the group of automorphisms of $\\mathcal{T}_d$ as $\\mathrm{Aut}(\\mathcal{T}_d)$.\nWe write $\\mathrm{Sym}(\\Sigma)$ for the \\emph{permutation group of $\\Sigma$}.\nAn important observation  is that $\\mathrm{Aut}(\\mathcal{T}_d)$ can be seen as the wreath product $\\mathrm{Aut}(\\mathcal{T}_d) \\wr \\mathrm{Sym}(\\Sigma)$, since any automorphism $\\alpha \\in \\mathrm{Aut}(\\mathcal{T}_d)$ can be written uniquely as $\\alpha = (\\alpha_1, \\alpha_2, \\ldots, \\alpha_d) \\cdot \\sigma$ where each $\\alpha_i \\in \\mathrm{Aut}(\\mathcal{T}_d)$ is an automorphism of the sub-tree with root $a_i$, and $\\sigma \\in \\mathrm{Sym}(\\Sigma)$ is a permutation  of the first level.\n\nLet $\\alpha \\in \\mathrm{Aut}(\\mathcal{T}_d)$ where $\\alpha = (\\alpha_1, \\alpha_2, \\ldots, \\alpha_d) \\cdot \\sigma \\in \\mathrm{Aut}(\\mathcal{T}_d) \\wr \\mathrm{Sym}(\\Sigma)$.\nThen, for any letter $a_i \\in \\Sigma$, the \\emph{restriction of $\\alpha$ to $a_i$}, denoted $\\left.\\alpha\\right\\vert_{a_i} = \\alpha_i$, is the action of $\\alpha$ on the sub-tree with root $a_i$ (which is given by $\\alpha_i$).\nGiven any vertex $w = w_1 w_2 \\cdots w_k \\in \\Sigma^*$ of $\\mathcal{T}_d$, we can define the \\emph{restriction of $\\alpha$ to $w$} recursively as\n\\[\n\t\\left.\\alpha\\right\\vert_w\n\t=\n\t\\left.\n\t\t\\left(\\left.\\alpha\\right\\vert_{w_1w_2\\cdots w_{k-1}}\\right)\n\t\\right\\vert_{w_k}\n\\]\nand thus describe the action of $\\alpha$ on the sub-tree with root $w$.\n\nThe action of each element of a bounded automata group on its associated tree can be described using a certain type of finite-state rewrite automata, which we will refer to as a $\\Sigma$-automaton.\nWe define this class of automata as follows.\n\n\\begin{definition}\\label{defn:sigma-autom}\nA \\emph{$\\Sigma$-automaton}, $(\\Gamma,v)$, is a finite directed graph with a distinguished vertex $v$, called the initial state, and a $(\\Sigma\\times\\Sigma)$-labelling of its edges, such that each vertex has exactly $\\left\\vert\\Sigma\\right\\vert$ outgoing edges; and for each $a \\in \\Sigma$ each vertex has exactly one incoming edge of the form $(a,a')$ and exactly one outgoing edge of the form $(a',a)$.\nThus, the outgoing edges define a permutation of $\\Sigma$.\n\\end{definition}\n\nFrom a $\\Sigma$-automaton, we may then define a tree automorphism as follows.\n\n\\begin{definition}\\label{defn:automata-automorphism}\nLet $(\\Gamma,v)$ be a $\\Sigma$-automaton with $\\Sigma = \\{a_1,\\ldots,a_d\\}$, then we define an automorphism $\\alpha_{(\\Gamma,v)} \\in \\mathrm{Aut}(\\mathcal{T}_d)$ as follows.\nNotice that for each vertex $b_1 b_2 \\cdots b_k \\in \\mathrm{V}\\!\\left(\\mathcal{T}_d\\right) = \\Sigma^*$, there is a unique path in the graph $\\Gamma$ starting from the initial vertex, $v$, of the form\n$\n\t(b_1, b_1')\n\t\\,\n\t(b_2, b_2')\n\t\\,\n\t\\cdots\n\t\\,\n\t(b_k, b_k')\n$.\nWe define $\\alpha_{(\\Gamma,v)}$ such that $\\alpha_{(\\Gamma,v)} (b_1 b_2 \\cdots b_k) = b_1' b_2' \\cdots b_k'$.\nFrom the definition of $\\Sigma$-automata it the follows that $\\alpha_{(\\Gamma,v)}$ is an isomorphism.\n\\end{definition}\n\nWe provide an example of a $\\Sigma$-automaton in \\cref{fig:sigma_autom_grigorchuk}.\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics{figure/grigorchuk}\n\t\\caption{A $\\Sigma$-automaton for the generator $b$ in Grigorchuk's group.}\n\t\\label{fig:sigma_autom_grigorchuk}\n\\end{figure}\n\nAn \\emph{automaton automorphism}, $\\alpha$, of the tree $\\mathcal{T}_d$ is an automorphism for which there exists a $\\Sigma$-automaton, $(\\Gamma,v)$, such that $\\alpha = \\alpha_{(\\Gamma,v)}$.\nWe write $\\mathcal{A}\\!\\left(\\mathcal{T}_d\\right)$ for the set of all automata automorphisms of the tree $\\mathcal{T}_d$.\nThe set $\\mathcal{A}\\!\\left(\\mathcal{T}_d\\right)$ forms a group~\\cite[Proposition~1]{sidki2000}.\nMoreover, a subgroup of $\\mathcal{A}(\\mathcal{T}_d)$ is called an \\emph{automata group}.\n\nAn automorphism $\\alpha \\in \\mathrm{Aut}(\\mathcal{T}_d)$ will be called \\emph{bounded} (originally defined in \\cite{sidki2000}) if there exists a constant $N \\in \\mathbb{N}$ such that for each $k\\in \\mathbb{N}$, there are no more than $N$ vertices $v\\in \\Sigma^*$ with $\\left\\vert v \\right\\vert = k$ (i.e.\\@ at level $k$) such that $\\left.\\alpha\\right\\vert_v \\neq 1$.\nThus, the action of such a bounded automorphism will, on each level, be trivial on all but (up to) $N$ sub-trees.\nThe set of all such automorphisms form a group which we will denote as $\\mathcal{B}(\\mathcal{T}_d)$.\nThe group of all \\emph{bounded automaton automorphisms} is defined as the intersection $\\mathcal{A}(\\mathcal{T}_d) \\cap \\mathcal{B}(\\mathcal{T}_d)$, which we will denote as $\\mathcal{D}(\\mathcal{T}_d)$.\nA subgroup of $\\mathcal{D}(\\mathcal{T}_d)$ is called a  \\emph{bounded automata group}.\n\nA \\emph{finitary automorphism} of $\\mathcal{T}_d$ is an automorphism $\\phi$ such that there exists a constant $k \\in \\mathbb{N}$ for which $\\left. \\phi \\right\\vert_v = 1$ for each $v \\in \\Sigma^*$ with $\\left\\vert v \\right\\vert = k$.\nThus, a finitary automorphism is one that is trivial after some $k$ levels of the tree.\nGiven a finitary automorphism $\\phi$, the smallest $k$ for which this definition holds will be called its \\emph{depth} and will be denoted as $\\mathrm{depth}(\\phi)$.\nWe will denote the group formed by all finitary automorphisms of $\\mathcal{T}_d$ as $\\mathrm{Fin}(\\mathcal{T}_d)$.\nSee \\cref{fig:finitary examples} for examples of the actions of finitary automorphisms on their associated trees (where any unspecified sub-tree is fixed by the action).\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\begin{minipage}[t]{.3\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics{figure/finitaryA}\n\t\\end{minipage}\n\t~\n\t\\begin{minipage}[t]{.3\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics{figure/finitaryB}\n\t\\end{minipage}\n\t\\caption{Examples of finitary automorphisms $a,b\\in\\mathrm{Fin}\\!\\left(\\mathcal{T}_2\\right)$.}\n\t\\label{fig:finitary examples}\n\\end{figure}\n\nLet $\\delta \\in \\mathcal{A}\\!\\left(\\mathcal{T}_d\\right) \\setminus \\mathrm{Fin}\\!\\left(\\mathcal{T}_d\\right)$. We call $\\delta$ a \\emph{directed automaton automorphism} if\n\\begin{equation}\n\t\\label{eq:directed automorphism definition}\n\t\\delta\n\t=\n\t(\\phi_1, \\phi_2, \\ldots, \\phi_{k-1}, \\delta', \\phi_{k+1}, \\ldots, \\phi_d) \\cdot \\sigma\n\t\\in\n\t\\mathrm{Aut}\\!\\left(\\mathcal{T}_d\\right) \\wr \\mathrm{Sym}(\\Sigma)\n\\end{equation}\nwhere each $\\phi_j$ is finitary and $\\delta'$ is also directed automaton (that is, not finitary and can also be written in this form).\nWe call $\\mathrm{dir}(\\delta) = b = a_k \\in \\Sigma$, where $\\delta'=\\delta\\vert_{b}$ is directed automaton, the \\emph{direction} of $\\delta$; and we define the \\emph{spine} of $\\delta$, denoted $\\mathrm{spine}(\\delta) \\in \\Sigma^\\omega$, recursively such that $\\mathrm{spine}(\\delta) = \\mathrm{dir}(\\delta) \\, \\mathrm{spine}(\\delta')$.\nWe denote the set of all directed automaton automorphisms as $\\mathrm{Dir}(\\mathcal{T}_d)$.\nSee \\cref{fig:directed examples} for examples of directed automaton automorphisms (in which $a$ and $b$ are the finitary automorphisms in \\cref{fig:finitary examples}).\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\begin{minipage}[t]{.3\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics{figure/directedX}\n\t\\end{minipage}\n\t~\n\t\\begin{minipage}[t]{.3\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics{figure/directedY}\n\t\\end{minipage}\n\t~\n\t\\begin{minipage}[t]{.3\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics{figure/directedZ}\n\t\\end{minipage}\n\t\\caption{Examples of directed automorphisms $x,y,z \\in \\mathrm{Dir}(\\mathcal{T}_2)$.}\n\t\\label{fig:directed examples}\n\\end{figure}\n\nThe following lemma is essential to prove our main theorem.\n\n\\begin{lemma}[Lemma~3~in~\\cite{holt2006}]\n\t\\label{lemma:spine is eventualy periodic}\n\tThe spine, $\\mathrm{spine}(\\delta) \\in \\Sigma^\\omega$, of a directed automaton automorphism, $\\delta \\in \\mathrm{Dir}(\\mathcal{T}_d)$, is eventually periodic, that is, there exists some $\\iota = \\iota_1 \\iota_2 \\cdots \\iota_s \\in \\Sigma^*$, called the \\emph{initial section}, and\n\t$\\pi = \\pi_1 \\pi_2 \\cdots \\pi_t \\in \\Sigma^*$, called the \\emph{periodic section}, such that $\\mathrm{spine}(\\delta) = \\iota \\, \\pi^\\omega$; and\n\t\\begin{equation}\n\t\t\\label{eq:restrictions along periodic section}\n\t\t\\left.\n\t\t\\delta\n\t\t\\right\\vert_{\\iota \\, \\pi^k \\, \\pi_1 \\pi_2 \\cdots \\pi_j}\n\t\t=\n\t\t\\left.\n\t\t\\delta\n\t\t\\right\\vert_{\\iota \\, \\pi_1 \\pi_2 \\cdots \\pi_j}\n\t\\end{equation}\n\tfor each $k,j \\in \\mathbb{N}$ with $0\\leq j <t$.\n\\end{lemma}\n\n\\begin{proof}\n\tLet $(\\Gamma,v)$ be a $\\Sigma$-automaton such that $\\delta = \\alpha_{(\\Gamma,v)}$.\n\tBy the definition of $\\Sigma$-automata, for any given vertex $w = w_1 w_2 \\cdots w_k \\in \\Sigma^*$ of $\\mathcal{T}_d$ there exists a vertex $v_w \\in \\mathrm{V}(\\Gamma)$ such that $\\delta\\vert_w = \\alpha_{(\\Gamma,v_w)}$.\n\tIn particular, such a vertex $v_w$ can be obtained by following the path with edges labelled\n\t$\n\t(w_1, w_1')\n\t(w_2, w_2')\n\t\\cdots\n\t(w_k, w_k')\n\t$.\n\tThen, since there are only finitely many vertices in $\\Gamma$, the set of all restrictions of $\\delta$ is finite, that is,\n\t\\begin{equation}\\label{eq:finitely many restrictions}\n\t\t\\#\n\t\t\\left\\{\n\t\t\t\\left.\\delta\\right\\vert_w\n\t\t\t=\n\t\t\t\\alpha_{(\\Gamma,v_w)}\n\t\t\\mid\n\t\t\tw \\in \\Sigma^*\n\t\t\\right\\}\n\t\t<\n\t\t\\infty.\n\t\\end{equation}\n\tLet $b = b_1 b_2 b_3 \\cdots = \\mathrm{spine}(\\delta) \\in \\Sigma^\\omega$ denote the spine of $\\delta$.\n\tThen, there exists some $n,m \\in \\mathbb{N}$ with $n < m$ such that\n\t\\begin{equation}\n\t\t\\label{eq:equivalent restrictions}\n\t\t\\delta\\vert_{b_1 b_2 \\cdots b_n}\n\t\t=\n\t\t\\delta\\vert_{b_1 b_2 \\cdots b_n \\cdots b_{m}}\n\t\\end{equation}\n\tas otherwise there would be infinitely many distinct restrictions of the form $\\delta\\vert_{b_1 b_2 \\cdots b_k}$ thus contradicting (\\ref{eq:finitely many restrictions}).\n\tBy the definition of the spine, it follows that\n\t\\[\n\t\\mathrm{spine}\n\t\\left(\n\t\\delta\\vert_{b_1 b_2 \\cdots b_n}\n\t\\right)\n\t=\n\t(b_{n+1}b_{n+2} \\cdots b_m)\n\t\\ \n\t\\mathrm{spine}\n\t\\left(\n\t\\delta\\vert_{b_1 b_2 \\cdots b_n \\cdots b_{m}}\n\t\\right).\n\t\\]\n\tHence, by (\\ref{eq:equivalent restrictions}),\n\t\\[\n\t\\mathrm{spine}\n\t\\left(\n\t\\delta\\vert_{b_1 b_2 \\cdots b_n}\n\t\\right)\n\t=\n\t(b_{n+1}b_{n+2} \\cdots b_m)^\\omega.\n\t\\]\n\tThus,\n\t\\begin{align*}\n\t\t\\mathrm{spine}(\\delta)\n\t\t&=\n\t\t(b_1 b_2 \\cdots b_n)\n\t\t\\ \n\t\t\\mathrm{spine}\n\t\t\\left(\n\t\t\\delta\\vert_{b_1 b_2 \\cdots b_n}\n\t\t\\right)\n\t\t\\\\&=\n\t\t(b_1 b_2 \\cdots b_n)\n\t\t\\ \n\t\t(b_{n+1}b_{n+2} \\cdots b_m)^\\omega.\n\t\\end{align*}\n\tBy taking $\\iota = b_1 b_2 \\cdots b_n$ and $\\pi = b_{n+1} b_{n+2} \\cdots b_m$, we have $\\mathrm{spine}(\\delta) = \\iota\\,\\pi^\\omega$.\n\tMoreover, from (\\ref{eq:equivalent restrictions}), we have equation (\\ref{eq:restrictions along periodic section}) as required.\n\\end{proof}\n\nNotice that each finitary and directed automata automorphism is also bounded, in fact, we have the following proposition which shows that the generators of any given bounded automata group can be written as words in $\\mathrm{Fin}\\!\\left(\\mathcal{T}_d\\right)$ and $\\mathrm{Dir}\\!\\left(\\mathcal{T}_d\\right)$.\n\n\\begin{proposition}[Proposition 16 in \\cite{sidki2000}]\n\t\\label{prop:bounded automata group if directed}\n\tThe group $\\mathcal{D}\\!\\left(\\mathcal{T}_d\\right)$ of bounded automata automorphisms is generated by $\\mathrm{Fin}\\!\\left(\\mathcal{T}_d\\right)$ together with $\\mathrm{Dir}\\!\\left(\\mathcal{T}_d\\right)$.\n\\end{proposition}\n\n\\subsection{Co-Word Problems}\\label{sec:mainthm}\n\nWe may now prove the following characterisation of bounded automata groups.\n\n\\setcounter{theoremx}{3}\n\\TheoremBoundedAutomata\n\nThe idea of the proof is straightforward:\nwe construct a cspd machine that nondeterministically chooses a vertex $v \\in \\mathrm{V}(\\mathcal{T}_d)$, writing its labels on the check-stack and a copy on its pushdown;\nas it reads letters from input, it uses the pushdown to keep track of where the chosen vertex is moved;\nand finally it checks whether the pushdown and the check-stack differ.\nThe full details are as follows.\n\n\n\\begin{proof}\n\t\n\tLet $G \\subseteq \\mathcal{D}(\\mathcal{T}_d)$ be a bounded automata group with finite monoid generating set $X$.\n\tBy \\cref{prop:bounded automata group if directed}, we can define a map\n\t\\[\n\t\\varphi\\colon\n\tX\n\t\\to\n\t\\left(\n\t\\mathrm{Fin}(\\mathcal{T}_d) \\cup \\mathrm{Dir}(\\mathcal{T}_d)\n\t\\right)^*\n\t\\] so that $x$ and $\\varphi(x)$ are equal in $\\mathcal{D}(\\mathcal{T}_d)$ for each $x \\in X$.\n\tLet\n\t\\[\n\tY\n\t=\n\t\\left\\{\n\t\t\\alpha \\in \\mathrm{Fin}(\\mathcal{T}_d) \\cup \\mathrm{Dir}(\\mathcal{T}_d) \n\t\\ \\middle|\\ \n\t\t\\alpha\\text{ or } \\alpha^{-1} \\text{ is a letter in } \\varphi(x) \\text{ for some } x \\in X\n\t\\right\\}\n\t\\] which is a finite generating set for a group which contains $G$ as a subgroup.\n\tConsider the group $H \\subseteq \\mathcal{D}(\\mathcal{T}_d)$ generated by $Y$.\n\tSince ET0L is closed under inverse word homomorphism, it suffices to prove that $\\coWP_Y$ is ET0L, as $\\coWP_X$ is its inverse image under the mapping $X^* \\to Y^*$ induced by  $\\varphi$.\n\tWe construct a cspd machine $\\mathcal{M}$ that recognises $\\coWP_Y$, thus proving that $G$ is co-ET0L.\n\t\n\tLet $\\alpha = \\alpha_1 \\alpha_2 \\cdots \\alpha_n \\in Y^*$ denote an input word given to $\\mathcal{M}$.\n\tThe execution of the cspd will be separated into four stages;\n\t(1) choosing a vertex $v \\in \\Sigma^*$ of $\\mathcal{T}_d$ which witnesses the non-triviality of $\\alpha$ (and placing it on the stacks);\n\t(2a)  reading a finitary automorphism from the input tape;\n\t(2b)  reading a directed automaton automorphism from the input tape; and\n\t(3)  checking that the action of $\\alpha$ on $v$ that it has computed is non-trivial.\n\t\n\tAfter Stage~1, $\\mathcal{M}$ will be in state $q_\\mathrm{comp}$.\n\tFrom here, $\\mathcal{M}$ nondeterministically decides to either read from its input tape, performing either Stage~2a or 2b and returning to state $q_\\mathrm{comp}$; or to finish reading from input by performing Stage~3.\n\t\n\tWe\tset both the check-stack and pushdown alphabets to be $\\Sigma \\cup \\{\\mathfrak{t}\\}$,\n\ti.e., we have $\\Delta=\\Gamma=\\Sigma \\cup \\{\\mathfrak{t}\\}$.\n\tThe letter $\\mathfrak{t}$ will represent the top of the check-stack.\n\t\n\t\\proofsection{Stage 1: choosing a witness $v = v_1 v_2 \\cdots v_m \\in \\Sigma^*$}\n\t\n\tIf $\\alpha$ is non-trivial, then there must exist a vertex $v \\in \\Sigma^*$ such that $\\alpha \\cdot v \\neq v$.\n\tThus, we nondeterministically choose such a witness from $\\mathcal{R} = \\Sigma^* \\mathfrak{t}$ and store it on the check-stack, where the letter $\\mathfrak{t}$ represents the top of the check-stack.\n\t\n\tFrom the start state, $q_0$, $\\mathcal{M}$ will copy the contents of the check-stack onto the pushdown, then enter the state $q_\\mathrm{comp} \\in Q$.\n\tFormally, this will be achieved by adding the transitions (for each $a \\in \\Sigma$):\n\t\\[\n\t(\n\t(q_0,\\varepsilon,(\\mathfrak{b},\\mathfrak{b})),\n\t(q_0,\\mathfrak{t}\\mathfrak{b})\n\t),\\,\n\t(\n\t(q_0,\\varepsilon,(a,\\mathfrak{t})),\n\t(q_0,\\mathfrak{t}a)\n\t),\\,\n\t(\n\t(q_0,\\varepsilon,(\\mathfrak{t},\\mathfrak{t})),\n\t(q_\\mathrm{comp},\\mathfrak{t})\n\t).\n\t\\]\n\t\n\tThis stage concludes with $\\mathcal{M}$ in state $q_{\\mathrm{comp}}$, and the read-head pointing to $(\\mathfrak t, \\mathfrak t)$. \n\tNote that whenever the machine is in state $q_{\\mathrm{comp}}$ and $\\alpha_1 \\alpha_2 \\cdots \\alpha_k$ has been read from input, then the contents of pushdown will represent the permuted vertex $(\\alpha_1 \\alpha_2 \\cdots \\alpha_k) \\cdot v$.\n\tThus, the two stacks are initially the same as no input has been read and thus no group action has been simulated.\n\tIn Stages~2a and 2b, only the height of the check-stack is important, that is, the exact contents of the check-stack will become relevant in Stage~3.\n\t\n\t\\proofsection{Stage~2a: reading a finitary automorphism $\\phi \\in Y\\cap\\mathrm{Fin}(\\mathcal{T}_d)$}\n\t\n\tBy definition, there exists some $k_\\phi = \\mathrm{depth}(\\phi) \\in \\mathbb{N}$ such that $\\left.\\phi\\right\\vert_u = 1$ for each $u \\in \\Sigma^*$ for which $\\vert u \\vert \\geq k_\\phi$.\n\tThus, given a vertex $v = v_1 v_2 \\cdots v_m \\in \\Sigma^*$, we have\n\t\\[\n\t\\phi(v)\n\t=\n\t\\phi(v_1 v_2 \\cdots v_{k_\\phi})\n\t\\ \n\tv_{(k_\\phi+1)}\n\t\\cdots\n\tv_m.\n\t\\]\n\t\n\tGiven that $\\mathcal{M}$ is in state $q_\\mathrm{comp}$ with $\\mathfrak{t} v_1 v_2 \\cdots v_m \\mathfrak{b}$ on its pushdown, we will read $\\phi$ from input, move to state $q_{\\phi,\\varepsilon}$ and pop the $\\mathfrak{t}$;\n\twe will then pop the next $k_\\phi$ (or fewer if $m < k_\\phi$) letters off the pushdown, and as we are popping these letters we visit the sequence of states $q_{\\phi,v_1}$, $q_{\\phi,v_1 v_2}$, \\dots, $q_{\\phi,v_1 v_2 \\cdots v_{k_\\phi}}$.\n\tFrom the final state in this sequence, we then push $\\mathfrak t\\phi(v_1\\cdots v_{k_\\phi})$ onto the pushdown, and return to the state $q_{\\mathrm{comp}}$.\n\t\n\tFormally, for letters $a,b \\in \\Sigma$, $\\phi \\in Y\\cap\\mathrm{Fin}(\\mathcal{T}_d)$, and vertices $u,w\\in\\Sigma^*$ where $ |u|< k_\\phi$ and $ |w|=k_\\phi$, we have the transitions\n\t\\[\n\t(\n\t(q_{\\mathrm{comp}}, \\phi, (\\mathfrak{t},\\mathfrak{t})),\n\t(q_{\\phi,\\varepsilon}, \\varepsilon)\n\t), \\ \n\t(\n\t(q_{\\phi,u}, \\varepsilon, (a,b)),\n\t(q_{\\phi, ub}, \\varepsilon)\n\t),\n\t\\]\n\t\\[\n\t(\n\t(q_{\\phi,  w}, \\varepsilon, (\\varepsilon,\\varepsilon)),\n\t(q_\\mathrm{comp}, \\mathfrak{t}\\phi(w))\n\t)\n\t\\]\n\tfor the case where $m > k_\\phi$, and\n\t\\[\n\t(\n\t(q_{\\phi, u}, \\varepsilon, (\\mathfrak{b},\\mathfrak{b})),\n\t(q_\\mathrm{comp}, \\mathfrak{t}\\phi(u)\\mathfrak{b})\n\t)\n\t\\]\n\tfor the case where $m \\leq k_\\phi$.\n\tNotice that we have finitely many states and transitions  since $Y,$ $\\Sigma$ and each $k_\\phi$ is finite.\n\t\n\t\\proofsection{Stage~2b: reading a directed automorphism $\\delta \\in Y\\cap\\mathrm{Dir}(\\mathcal{T}_d)$}\n\t\n\tBy \\cref{lemma:spine is eventualy periodic}, there exists some $\\iota = \\iota_1 \\iota_2 \\cdots \\iota_s \\in \\Sigma^*$ and $\\pi = \\pi_1 \\pi_2 \\cdots \\pi_t \\in \\Sigma^*$ such that\n\t$\n\t\\mathrm{spine}(\\delta)\n\t=\n\t\\iota \\, \\pi^\\omega\n\t$\n\tand\n\t\\[\n\t\\delta(\\iota\\pi^\\omega)\n\t=\n\tI_1 I_2 \\cdots I_s\n\t\\,\n\t\\left( \\Pi_1 \\Pi_2 \\cdots \\Pi_t \\right)^\\omega\n\t\\]\n\twhere\n\t\\[\n\tI_i\n\t=\n\t\\left. \\delta \\right\\vert_{\\iota_1 \\iota_2 \\cdots \\iota_{i-1}} (\\iota_i)\n\t%\n\t\\qquad\n\t%\n\t\\text{and}\n\t%\n\t\\qquad\n\t%\n\t\\Pi_j\n\t=\n\t\\left. \\delta \\right\\vert_{\\iota \\, \\pi_1 \\pi_2 \\cdots \\pi_{j-1}}\\!(\\pi_j).\n\t\\]\n\t\n\tGiven some vertex $v = v_1 v_2 \\cdots v_m \\in \\Sigma^*$, let $\\ell \\in \\mathbb{N}$ be largest such that $p = v_1 v_2 \\cdots v_\\ell$ is a prefix of the sequence $\\iota\\pi^\\omega = \\mathrm{spine}(\\delta)$.\n\tThen by  definition of directed automorphism, $\\delta' = \\delta\\vert_p$ is directed and $\\phi = \\delta\\vert_a$, where $a = v_{\\ell}$, is finitary.\n\tThen, either $p = \\iota_1 \\iota_2 \\cdots \\iota_\\ell$ and \n\t\\[\n\t\\delta(v)\n\t=\n\t(I_1 I_2 \\cdots I_\\ell)\n\t\\ \n\t\\delta'(a)\n\t\\ \n\t\\phi(v_{\\ell+2} v_{\\ell+3} \\cdots v_m),\n\t\\]\n\tor $p = \\iota\\pi^k\\pi_1\\pi_2\\cdots\\pi_j$, with $\\ell = |\\iota|+k\\cdot|\\pi| + j$, and \n\t\\[\n\t\\delta(v)\n\t=\n\t(I_1 I_2 \\cdots I_s)\n\t\\,\n\t(\\Pi_1 \\Pi_2 \\cdots \\Pi_t)^k\n\t\\,\n\t(\\Pi_1 \\Pi_2 \\cdots \\Pi_j)\n\t\\ \n\t\\delta'(a)\n\t\\ \n\t\\phi( v_{\\ell+2} v_{\\ell+3} \\cdots v_m).\n\t\\]\n\t\n\tHence, from state $q_\\mathrm{comp}$ with $\\mathfrak{t} v_1 v_2 \\cdots v_m \\mathfrak{b}$ on its pushdown, $\\mathcal M$ reads $\\delta$ from input, moves to state $q_{\\delta,\\iota,0}$ and pops the $\\mathfrak{t}$;\n\tit then pops $pa$ off the pushdown, using states to remember the letter $a$ and the part of the prefix to which the final letter of $p$ belongs (i.e.\\@ $\\iota_i$ or $\\pi_j$).\n\tFrom here, $\\mathcal{M}$ performs the finitary automorphism $\\phi$ on the remainder of the pushdown (using the same construction as Stage~2a), then, in a sequence of transitions, pushes $\\mathfrak{t}\\delta(p)\\delta'(a)$ and returns to state $q_\\mathrm{comp}$.\n\tThe key idea here is that, using only the knowledge of the letter $a$, the part of $\\iota$ or $\\pi$ to which the final letter of $p$ belongs, and the height of the check-stack, that $\\mathcal M$ is able to recover $\\delta(p)\\delta'(a)$.\n\t\n\tWe now give the details of the states and transitions involved in this stage of the construction.\n\t\n\tWe have states $q_{\\delta,\\iota,i}$ and $q_{\\delta,\\pi,j}$ with $0 \\leq i \\leq \\vert \\iota \\vert$, $1 \\leq j \\leq \\vert \\pi \\vert$; where $q_{\\delta,\\iota,i}$ represents that the word $\\iota_1 \\iota_2 \\cdots \\iota_i$ has been popped off the pushdown, and $q_{\\delta,\\pi,j}$ represents that a word $\\iota\\pi^k\\pi_1\\pi_2\\cdots \\pi_j$ for some $k \\in \\mathbb{N}$ has been popped of the pushdown.\n\tThus, we begin with the transition\n\t\\[\n\t(\n\t(q_\\mathrm{comp}, \\delta, (\\mathfrak{t},\\mathfrak{t})),\n\t(q_{\\delta,\\iota,0},\\varepsilon)\n\t),\n\t\\]\n\tthen for each $i,j\\in \\mathbb{N}$, $a \\in \\Sigma$ with $0 \\leq i < \\vert \\iota \\vert$ and $1 \\leq j < \\vert \\pi \\vert$, we have transitions\n\t\\begin{align*}\n\t\t(\n\t\t(q_{\\delta,\\iota,i}, \\varepsilon, (a,\\iota_{i+1})),\n\t\t(q_{\\delta,\\iota,(i+1)},\\varepsilon)\n\t\t),&\\ \\ \n\t\t(\n\t\t(q_{\\delta,\\iota,|\\iota|}, \\varepsilon, (a,\\pi_1)),\n\t\t(q_{\\delta,\\pi,1},\\varepsilon)\n\t\t),\n\t\t\\\\\n\t\t(\n\t\t(q_{\\delta,\\pi,j}, \\varepsilon, (a,\\pi_{j+1})),\n\t\t(q_{\\delta,\\pi,(j+1)},\\varepsilon)\n\t\t),&\\ \\ \n\t\t(\n\t\t(q_{\\delta,\\pi,|\\pi|}, \\varepsilon, (a,\\pi_1)),\n\t\t(q_{\\delta,\\pi,1},\\varepsilon)\n\t\t)\n\t\\end{align*}\n\tto consume the prefix $p$.\n\t\n\tAfter this,  $\\mathcal{M}$ will either be at the bottom of its stacks, or its read-head will see a letter on the pushdown that is not the next letter in the spine of $\\delta$.\n\tThus, for each $i,j \\in \\mathbb{N}$ with $0 \\leq i \\leq \\vert \\iota \\vert$ and $1 \\leq j \\leq |\\pi|$ we have states $q_{\\delta,\\iota,i,a}$ and $q_{\\delta,\\pi,j,a}$;\n\tand for each $b \\in \\Sigma$ we have transitions\n\t\\[\n\t(\n\t(q_{\\delta,\\iota,i}, \\varepsilon, (b,a)),\n\t(q_{\\delta,\\iota,i,a},\\varepsilon)\n\t)\n\t\\]\n\twhere $a \\neq \\iota_{i+1}$ when $i < |\\iota|$ and $a \\neq \\pi_1$ otherwise, and\n\t\\[\n\t(\n\t(q_{\\delta,\\pi,j}, \\varepsilon, (b,a)),\n\t(q_{\\delta,\\pi,j,a},\\varepsilon)\n\t)\n\t\\]\n\twhere $a \\neq \\pi_{j+1}$ when $j < |\\pi|$ and $a \\neq \\pi_1$ otherwise.\n\t\n\tHence, after these transitions, $\\mathcal{M}$ has consumed $pa$ from its pushdown and will either be at the bottom of its stacks in some state $q_{\\delta,\\iota,i}$ or $q_{\\delta,\\pi,j}$; or will be in some state $q_{\\delta,\\iota,i,a}$ or $q_{\\delta,\\pi,j,a}$.\n\tNote here that, if $\\mathcal{M}$ is in the state $q_{\\delta,\\iota,i,a}$ or $q_{\\delta,\\pi,j,a}$, then from \\cref{lemma:spine is eventualy periodic} we know $\\delta' = \\delta\\vert_{p}$ is equivalent to $\\delta\\vert_{\\iota_1 \\iota_2\\cdots \\iota_i}$ or $\\delta\\vert_{\\iota \\pi_1 \\pi_2 \\cdots \\pi_j}$, respectively; and further, we know the finitary automorphism $\\phi = \\delta\\vert_{pa} = \\delta'\\vert_a$.\n\t\n\tThus, for each state $q_{\\delta,\\iota,i,a}$ and $q_{\\delta,\\pi,a}$ we will follow a similar construction to Stage~2a, to perform the finitary automorphism $\\phi$ to the remaining letters on the pushdown, then push $\\delta'(a)$ and return to the state $r_{\\delta,\\iota,i}$ or $r_{\\delta,\\pi,j}$, respectively.\n\tFor the case where $\\mathcal{M}$ is at the bottom of its stacks we have transitions\n\t\\[\n\t(\n\t(q_{\\delta,\\iota,i}, \\varepsilon, (\\mathfrak{b},\\mathfrak{b})),\n\t(r_{\\delta,\\iota,i}, \\mathfrak{b})\n\t),\\ \\ \n\t(\n\t(q_{\\delta,\\pi,i}, \\varepsilon, (\\mathfrak{b},\\mathfrak{b})),\n\t(r_{\\delta,\\pi,i}, \\mathfrak{b})\n\t)\n\t\\]\n\twith $0 \\leq i \\leq |\\iota|$, $1 \\leq j \\leq |\\pi|$.\n\t\n\tThus, after following these transitions, $\\mathcal{M}$ is in some state $r_{\\delta,\\iota,i}$ or $r_{\\delta,\\pi,j}$ and all that remains is for $\\mathcal{M}$ to push $\\delta(p)$ with $p = \\iota_1 \\iota_2\\cdots \\iota_i$ or $p = \\iota\\pi^k\\pi_1 \\pi_2\\cdots \\pi_k$, respectively, onto its pushdown.\n\tThus, for each $i,j\\in \\mathbb{N}$ with $0 \\leq i \\leq |\\iota|$ and $1 \\leq j \\leq |\\pi|$, we have transitions\n\t\\[\n\t(\n\t(r_{\\delta,\\pi,i}, \\varepsilon,(\\varepsilon,\\varepsilon)),\n\t(q_\\mathrm{comp}, \\mathfrak{t} I_1 I_2 \\cdots I_i)\n\t),\n\t\\ \\ \n\t(\n\t(r_{\\delta,\\pi,j}, \\varepsilon,(\\varepsilon,\\varepsilon)),\n\t(r_{\\delta,\\pi}, \\Pi_1 \\Pi_2 \\cdots \\Pi_j)\n\t)\n\t\\]\n\twhere from the state $r_{\\delta,\\pi}$, through a sequence of transitions, $\\mathcal{M}$ will push the remaining $I\\Pi^k$ onto the pushdown.\n\tIn particular, we have transitions\n\t\\[\n\t(\n\t(r_{\\delta,\\pi}, \\varepsilon,(\\varepsilon,\\varepsilon)),\n\t(r_{\\delta,\\pi},\\Pi)\n\t),\n\t\\ \\ \n\t(\n\t(r_{\\delta,\\pi}, \\varepsilon,(\\varepsilon,\\varepsilon)),\n\t(q_\\mathrm{comp},\\mathfrak{t}I)\n\t),\n\t\\]\n\tso that $\\mathcal{M}$ can nondeterministically push some number of $\\Pi$'s followed by $\\mathfrak{t}I$  before it finishes this stage of the computation.\n\tWe can assume that the machine pushes the correct number of $\\Pi$'s onto its pushdown as otherwise it will not see $\\mathfrak{t}$ on its check-stack while in state $q_\\mathrm{comp}$ and thus would not be able to continue with its computation, as every subsequent stage (2a,2b,3) of the computation begins with the read-head pointing to $\\mathfrak{t}$ on both stacks.\n\t\n\tOnce again it is clear that this stage of the construction requires only finitely many states and transitions.\n\t\n\t\\proofsection{Stage~3: checking that the action is non-trivial}\n\t\n\tAt the beginning of this stage, the contents of the check-stack represent the chosen witness, $v$, and the contents of the pushdown represent the action of the input word, $\\alpha$, on the witness, i.e., $\\alpha \\cdot v$.\n\t\n\tIn this stage $\\mathcal{M}$  checks if the contents of its check-stack and pushdown differ.\n\tFormally, we have states $q_\\mathrm{accept}$ and  $q_{\\mathrm{check}}$, with $q_\\mathrm{accept}$ accepting;\n\tfor each $a \\in \\Sigma$, we have transitions\n\t\\[\n\t(\n\t(q_\\mathrm{comp}, \\varepsilon, (\\mathfrak{t},\\mathfrak{t})),\n\t(q_\\mathrm{check}, \\varepsilon)\n\t),\n\t\\ \\ \n\t(\n\t(q_\\mathrm{check}, \\varepsilon, (a,a)),\n\t(q_\\mathrm{check}, \\varepsilon)\n\t)\n\t\\]\n\tto pop identical entries of the pushdown; and for each $(a,b) \\in \\Sigma \\times \\Sigma$ with $a \\neq b$ we have a transition\n\t\\[\n\t(\n\t(q_\\mathrm{check},\\varepsilon,(a,b)),\n\t(q_\\mathrm{accept},\\varepsilon)\n\t)\n\t\\]\n\tto accept if the stacks differ by a letter.\n\t\n\tObserve that if the two stacks are identical, then there is no path to the accepting state, $q_\\mathrm{accept}$, and thus $\\mathcal{M}$ will reject.\n\tNotice also that by definition of cspd automata, if $\\mathcal M$ moves into  $q_{\\mathrm{check}}$ before all input has been read, then $\\mathcal{M}$ will not accept, i.e., an accepting state is only effective if all input is consumed.\n\t\n\t\\proofsection{Soundness and Completeness}\n\t\n\tIf $\\alpha$ is non-trivial, then there is a vertex $v \\in \\Sigma^*$ such that $\\alpha \\cdot v \\neq v$, which $\\mathcal{M}$ can nondeterministically choose to write on its check-stack and thus accept $\\alpha$.\n\tIf $\\alpha$ is trivial, then $\\alpha \\cdot v = v$ for each vertex $v \\in \\Sigma^*$, and there is no choice of checking stack for which $\\mathcal{M}$ will accept, so $\\mathcal{M}$ will reject.\n\t\n\tThus, $\\mathcal{M}$ accepts a word if and only if it is in $\\coWP_Y$.\n\\end{proof}\n\n\\section{Open Problems and Concluding Remarks}\n\n\\Cref{thm:bounded automata is ET0L} opens the door to a new characterisation of groups by their co-word problem.\nIn particular, this result is a step towards a characterisation of groups with ET0L co-word problems.\nHowever, it still remains to be shown that there is a group whose co-word problem is ET0L but not context-free.\nIt is conjectured~\\cite[2]{bleak2016} that Grigorchuk's group does not have a context-free co-word problem.\nThus, we ask the following.\n\n\\begin{question}\n\tIs the co-word problem for Grigorchuk's group (or some other bounded automata group) not context-free?\n\\end{question}\n\nIt is then natural to ask if there is a classification of co-ET0L groups.\n", "meta": {"hexsha": "ec8a6a2f7aa0967bfd9d6351cf7443b33a8d6230", "size": 34205, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter/03_CoWord_Problems.tex", "max_stars_repo_name": "alexbishop/phd-thesis", "max_stars_repo_head_hexsha": "06f7d5f3f5fa8e6bdb9aa48796223acd9ba4ae3d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter/03_CoWord_Problems.tex", "max_issues_repo_name": "alexbishop/phd-thesis", "max_issues_repo_head_hexsha": "06f7d5f3f5fa8e6bdb9aa48796223acd9ba4ae3d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter/03_CoWord_Problems.tex", "max_forks_repo_name": "alexbishop/phd-thesis", "max_forks_repo_head_hexsha": "06f7d5f3f5fa8e6bdb9aa48796223acd9ba4ae3d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2050898204, "max_line_length": 489, "alphanum_fraction": 0.6986697851, "num_tokens": 11539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6688802669716106, "lm_q1q2_score": 0.44970940644051743}}
{"text": "\\chapter{Model equations}\\label{chap:model_equations}\n\n\\section{How to navigate this chapter}\n\nThis chapter covers the fluid and associated field equations modelled by {\\fluidity}.\n\n\\begin{center}\n\\begin{tabular}{lccc}\n\\hline\nproblem & underlying equations & boundary conditions & other considerations\\\\\n\\hline\nscalar advection & \\ref{sec:MP-AdvdifEqn-eqns}, \\ref{sec:MP-AdvdifEqn-adv} & \\ref{sec:bc_scalar_dirichlet}, \\ref{sec:bc_scalar_neumann} & × \\\\\nscalar advection-diffusion & \\ref{sec:MP-AdvdifEqn-eqns}, \\ref{sec:MP-AdvdifEqn-diff} & \\ref{sec:bc_scalar_dirichlet}, \\ref{sec:bc_scalar_neumann}, \\ref{sec:bc_scalar_robin} × & ×\\\\\nmomentum equation & \\ref{sec:MP-MomEqn} & \\ref{sec:bc_vector_dirichlet}, \\ref{sec:bc_vector_stress}, \\ref{sec:bc_vector_traction}, \\ref{sec:FS} & \\ref{sec:eqn_extensions} \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nThe material covered in this chapter is dealt with in great detail in \\citet{batchelor1967} and \\citet{landau}. \\cite{cushman1994} is also a useful reference.\n\n\\section{Advection--Diffusion equation}\\label{sec:MP-AdvdifEqn}\n\\index{advection-diffusion equation}\n\n\\subsection{General equation}\\label{sec:MP-AdvdifEqn-eqns}\n\nThe general form the equation that governs the evolution of a scalar field $c$\n(\\eg passive tracer, species concentration, temperature, salinity) is\n\\begin{equation}\\label{eq:general_scalar_eqn}\n\\ppt{c} + \\nabla\\cdot(\\bmu c) = \\nabla\\cdot(\\kaptens\\nabla c) - \\sigma c + F,\n\\end{equation}\nwhere $\\bmu=(u,v,w)^{T}$ is the velocity vector, $\\kaptens$ is the diffusivity (tensor), $\\sigma$ is an absorption coefficient ($-\\sigma c$ is sometimes termed Rayleigh or linear friction) and $F$ represents any source or reaction terms.\n\n\\subsubsection{Advection}\\label{sec:MP-AdvdifEqn-adv}\nThe advection term in \\eqref{eq:general_scalar_eqn}, given by\n\\begin{equation}\\label{eq:scalar_advection}\n\\nabla\\cdot(\\bmu c) = \\bmu\\cdot\\nabla c + (\\nabla\\cdot\\bmu)c,\n\\end{equation}\nexpresses the transport of the scalar quantity $c$ in the flow field $\\bmu$. Note that for an incompressible flow $\\nabla\\cdot\\bmu=0$ (see section \\ref{sec:equation_of_state}) resulting in the second term on the right hand side of \\eqref{eq:scalar_advection} dropping out. However, there may be numerical\nreasons why the discrete velocity field is not exactly divergence free, in which case this term may\nbe included in the discretisation. {\\fluidity} deals with the advection term in the form\n\\begin{equation}\\label{eq:fluidity_scalar_advection}\n\\nabla\\cdot(\\bmu c) + (\\beta-1)(\\nabla\\cdot\\bmu)c,\n\\end{equation}\nso that $\\beta=1$ corresponds to the conservative form of the equation and $\\beta=0$ to the non-conservative.\n\n\\subsubsection{Diffusion}\\label{sec:MP-AdvdifEqn-diff}\nThe diffusion term in \\eqref{eq:general_scalar_eqn}, given by \n\\begin{equation}\\label{eq:scalar_diffusion}\n\\nabla\\cdot(\\kaptens\\nabla c),\n\\end{equation}\nrepresents the mixing of $c$ and may be due to \nmolecular mixing of individual particles via Brownian motion, or mixing via large scale (in comparison to the\nmolecular scale) motion in the flow. For many applications \\eqref{eq:scalar_diffusion} can be written in simpler forms. Often, diffusion is isotropic giving $\\kaptens = \\mathrm{diag}(\\kappa,\\kappa,\\kappa)$ and thus the diffusion term\nmay be written as\n\\begin{equation}\\label{eq:scalar_isotropic_diffusion}\n\\nabla\\cdot(\\kaptens\\nabla c) = \\kappa\\nabla\\cdot\\nabla c = \\kappa\\nabla^2 c = \\kappa\\Delta c.\n\\end{equation}\nIn domains with high aspect ratio dynamics one often uses a smaller value of diffusivity in the `thin'\ndirection. For example, in the atmosphere or ocean we may choose a horizontal (eddy) diffusivity $\\kappa_H$ and a\nvertical (eddy) diffusivity $\\kappa_V$ so that $\\kaptens = \\mathrm{diag}(\\kappa_H,\\kappa_H,\\kappa_V)$ with $\\kappa_V < \\kappa_H$.\nIn this case the diffusion term may be written as\n\\begin{equation}\\label{eq:scalar_anisotropic_diffusion}\n\\nabla\\cdot(\\kaptens\\nabla c) = \\kappa_H \\left(\\pptt[x]{c} + \\pptt[y]{c}\\right) + \\kappa_V \\pptt[z]{c}.\n\\end{equation}\nNote that the second-order terms defined above are often termed Laplacian diffusion.\n\n\n\\subsubsection{Absorption, reaction and source terms}\\label{sec:MP-AdvdifEqn-abs}\n\\index{absorption term}\n\\index{source term}\n\\index{reaction term}\n\nThe absorption term in \\eqref{eq:general_scalar_eqn} \n\\begin{equation}\\label{eq:scalar_absorption}\n-\\sigma c,\n\\end{equation}\nhas the effect of decreasing the magnitude of $c$ (note the minus sign and the fact \nthat $\\sigma$ would typically be positive). It is sometimes termed Rayleigh friction. \n\nThe remaining term in \\eqref{eq:general_scalar_eqn}\n\\begin{equation}\\label{eq:scalar_source}\nF = \\sum_i F_i,\n\\end{equation}\ncan encompasses a number of source and reaction terms. Those terms where $F_i$ are\na given function of time, location or a-priori known fields are termed sources (and sometime\nsinks if they are negative). Those terms which are also functions of other prognostic fields\nare termed reactions and are common when dealing with chemistry or biology.\n\n\\subsection{Scalar boundary conditions} \\label{sec:BCs}\n\n\\index{boundary conditions!scalar}\n\nTo form a well-posed system upon which to attempt a numerical discretisation, the\nset of equations (discussed above) describing the behaviour of the \nsystem must be supplemented with appropriate boundary conditions.\n\n\n\\subsubsection{Dirichlet condition for a scalar field}\\label{sec:bc_scalar_dirichlet}\n\\index{boundary conditions!Dirichlet}\nFor a scalar field, $c$ say, a Dirichlet condition on the boundary\n$\\partial\\Omega$ takes the form\n\\begin{equation*}\nc=\\tilde{c},\\quad \\textrm{on}\\quad \\partial\\Omega.\n\\end{equation*}\n\n\n\\subsubsection{Neumann condition for a scalar field}\\label{sec:bc_scalar_neumann}\n\\index{boundary conditions!Neumann}\n\nTaking the weak form (applying Green's theorem to the diffusion term) of the advection-diffusion equation \\eqref{eq:general_scalar_eqn} leads to a surface integral of the form\n\\begin{equation*}\n\\int_{\\partial\\Omega} \\phi (\\kaptens\\nabla c)\\cdot\\bmn \\;d\\Gamma,\n\\end{equation*}\nwhere $\\phi$ is a test function (see section \\ref{chap:numerical_discretisation}).\nThe Neumann condition is specified by assigning a value to $(\\kaptens\\nabla c)\\cdot\\bmn$, \\eg\n\\begin{equation*}\n(\\kaptens\\nabla c)\\cdot\\bmn = q,\\quad \\textrm{on}\\quad \\partial\\Omega,\n\\end{equation*}\nand substituting in this surface integral to the discretised equation. Note that $q$ is often termed a flux.\n\n\n\\subsubsection{Robin condition for a scalar field}\\label{sec:bc_scalar_robin}\n\\index{boundary conditions!Neumann}\n\nTaking the weak form (applying Green's theorem to the diffusion term) of the advection-diffusion equation \\eqref{eq:general_scalar_eqn} leads to a surface integral of the form\n\\begin{equation*}\n\\int_{\\partial\\Omega} \\phi (\\kaptens\\nabla c)\\cdot\\bmn \\;d\\Gamma,\n\\end{equation*}\nwhere $\\phi$ is a test function (see section \\ref{chap:numerical_discretisation}).\nThe Robin condition is specified by relating the surface diffusive flux $(\\kaptens\\nabla c)\\cdot\\bmn$ to an ambient field value $c_{a}$, with an associated surface transfer coefficient $h$. This is given by the relationship\n\\begin{equation*}\n-(\\kaptens\\nabla c)\\cdot\\bmn = h (c - c_{a}),\\quad \\textrm{on}\\quad \\partial\\Omega,\n\\end{equation*}\nwhere in general $h$ and $c_{a}$ can vary spatially and temporally. This is substituted into the discretised equation to give a surface absorption term given by $hc$ and a surface source given by $-hc_{a}$.\n\n\n\\section{Fluid equations}\\label{sec:MP-MomEqn}\n\n\\index{conservation!equation}\n\\index{momentum equation}\n\nA starting point for describing the physics of a continuum are the conservation equations. Fluid volumes deform in time as the fluid moves. If $\\theta(\\bmx,t)$ is the density of some quantity (\\eg Temperature) associated with the fluid, the time evolution of that quantity in a fluid volume $V(t)$ is \n\\begin{equation}\\label{RTT}\n \\ddt{}\\left[\\int_{V(t)}\\theta(\\bmx,t)\\right]=\n \\int_{V(t)}\\left(\\DDt{\\theta}+\\theta\\nabla\\cdot\\bmu\\right),\n\\end{equation}\nwhich is the Reynolds' Transport theorem. In \\eqref{RTT} $\\bmx=(x,y,z)^T$ and $\\bmu=(u,v,w)^T$ are three-dimensional position and velocity vectors respectively and \n\\begin{equation}\\label{MatDiv}\n \\DDt{}\\equiv\\frac{\\partial}{\\partial{t}}+\\bmu\\cdot\\nabla,\n\\end{equation}\nis the \\textit{material derivative} (NB. it has many other commonly-used names including the total and Lagrangian derivative). \\index{Reynolds Transport theorem}\n\n\\subsection{Mass conservation}\n\\index{conservation!mass}\nSubstituting $\\theta=\\rho$ in to \\eqref{RTT} and noting that matter is neither created nor destroyed gives that the \\lhs\\ of \\eqref{RTT} is zero. Then, as the volume $V(t)$ is arbitrary, it is seen that the mass density satisfies\n\\begin{equation}\\label{mass_conservation}\n \\DDt{\\rho}=-\\rho\\nabla\\cdot\\bmu,\n\\end{equation}\nor equivalently\n\\begin{equation}\\label{mass_conservation_2}\n \\frac{\\partial\\rho}{\\partial{t}}+\\nabla\\cdot(\\rho\\bmu)=0.\n\\end{equation}\nThe quantity $\\rho\\bmu$ is called the \\textit{mass flux} or \\textit{momentum} and \\eqref{mass_conservation_2} is termed the \\textit{equation of continuity}.\n\n\\subsection{Momentum conservation}\n\\index{conservation!momentum}\nThe momentum associated with a unit volume of fluid is given by $\\rho\\bmu$. Initially, consider that the fluid is \\textit{ideal}, that is, viscosity and conductivity are assumed to be unimportant. Then, the rate of change of momentum is given by\n\\begin{equation}\\label{mom_cons_1}\n \\frac{\\partial}{\\partial{t}}(\\rho\\bmu)=\\rho\\frac{\\partial\\bmu}{\\partial{t}}+\\frac{\\partial\\rho}{\\partial{t}}\\bmu.\n\\end{equation}\nUsing the equation of continuity \\eqref{mass_conservation_2} and Euler's\nequation \\citep{batchelor1967} (the force equation for an inviscid fluid) in the form\n\\begin{equation}\\label{mom_cons_2}\n \\frac{\\partial\\bmu}{\\partial{t}}=-\\bmu\\cdot\\nabla\\bmu-\\frac{1}{\\rho}\\nabla{p},\n\\end{equation}\ngives\n\\begin{equation}\\label{mom_cons_3}\n \\frac{\\partial}{\\partial{t}}(\\rho\\bmu)=-\\nabla{p}-\\nabla\\cdot(\\rho\\bmu\\bmu),\n\\end{equation}\nwhere $\\bmu\\bmu$ is a tensor which represents the dyadic product of vectors which, using index notation, can be written as ${u_{i}u_{j}}$. Writing $\\tensor{\\Pi}=p\\mathbf{I}+\\rho\\bmu\\bmu$, \\eqref{mom_cons_3} can be written as\n\\begin{equation}\\label{mom_cons_4}\n \\frac{\\partial}{\\partial{t}}(\\rho\\bmu)+\\nabla\\cdot\\tensor{\\Pi}=0,\n\\end{equation}\nwhere $\\tensor{\\Pi}$ is clearly a symmetric tensor and is termed the \\textit{momentum flux density tensor}.\n\nThe effects of viscosity on the motion of a fluid are now considered. To express the equations of motion governing a viscous fluid, some additional terms are required. The equation of continuity (conservation of mass) is equally valid for any viscous as well as inviscid fluid. However, Euler's equation \\eqref{mom_cons_2} and hence \\eqref{mom_cons_4} require modification.\n\nBy adding $-\\tautens$ to the previously introduced \\textit{momentum flux density tensor}, $\\tensor{\\Pi}$, so that\n\n\\begin{equation}\n \\tensor{\\Pi}=p\\mathbf{I}+\\rho\\bmu\\bmu-\\tautens=-\\sigtens+\\rho\\bmu\\bmu,\n\\end{equation}\n\nwhere $\\sigtens=-p\\mathbf{I}+\\tautens$, the viscous transfer of momentum in the fluid can be taken into account. $\\sigtens$ is called the stress tensor and gives the part of the momentum flux which is not due to direct transfer of momentum with the mass of the fluid. $\\tautens$ is named the deviatoric or viscous stress tensor. These tensors and the forms which they may take are discussed in more detail in section \\ref{sec:equation_of_state}. Thus, the most general form of the momentum equation of a compressible viscous fluid may be written as\n\n\\begin{equation}\\label{viscous_fluids_1}\n \\rho\\left(\\frac{\\partial\\bmu}{\\partial{t}}+\\bmu\\cdot\\nabla\\bmu\\right)=-\\nabla\\cdot\\sigtens+\\rho\\bmF,\n\\end{equation}\n\nwhere $\\bmF$ is a volume force per unit mass (\\eg gravity, astronomical forcing).\n\n% Note: Something needs to be added about the difference between the two forms outlined below within Fluidity i.e. a reference\n% to somewhere in chapter 3 that goes over this.\n\n\\subsubsection{Compressible equations in conservative form}\\label{sec:compressible_conservative}\nUsing the conservation laws outlined above the following point-wise PDE system governing the motion of a compressible fluid is obtained\n\n\\begin{subeqnarray}\n\\frac{\\pp\\rho}{\\pp t} + \\nabla\\cdot(\\rho\\bmu) &=& 0,\\slabel{conmass}\\\\\n\\frac{\\pp}{\\pp t}(\\rho\\bmu) + \\nabla\\cdot(\\rho\\bmu\\bmu-\\sigtens) &=& \\rho\\bmF,\\slabel{conmom}\\\\\n\\frac{\\pp}{\\pp t}(\\rho \\tote) + \\nabla\\cdot(\\rho E\\bmu - \\sigtens\\bmu +\n\\bmq) &=& \\rho\\bmF\\cdot\\bmu,\\slabel{conenergy}\n\\label{conservativesystem}\n\\end{subeqnarray}\nwhere $\\tote\\equiv\\inte+\\modu^2/2$ is the total specific energy (in which $\\inte$ is the internal energy). \\eqref{conmass} is exactly the conservative form of the continuity equation given in \\eqref{mass_conservation_2}, \\eqref{conmom} is equivalent to equation \\eqref{viscous_fluids_1} and \\eqref{conenergy} is obtained from making the substitutions $w=\\inte+p/\\rho$ and $\\tote\\equiv\\inte+\\modu^2/2$ in \\eqref{viscous_fluids_1}.\n\n\\subsubsection{Compressible equations in non-conservative form}\\label{sec:compressible_nonconservative}\nExpanding terms in \\eqref{conservativesystem} yields the\nnon-conservative form of the compressible equations\\footnote{\\eqref{nonconmass}\nis trivial to obtain. \\eqref{nonconmom} makes use of \\eqref{conmass}\nand the divergence of the dyadic product, given by\n\\begin{equation*}\n\\nabla\\cdot(\\bmu\\bmu) = \\bmu\\cdot\\nabla\\bmu + \\bmu\\nabla\\cdot\\bmu,\n\\end{equation*}\nalong with \\eqref{MatDiv}. \\eqref{nonconenergy} makes use of both \\eqref{nonconmass} and \\eqref{nonconmom} and\nnote that substituting for $\\tote\\equiv\\inte+\\modu^2/2$ results in the cancellation of kinetic energy terms.}\n\\begin{subeqnarray}\\label{nonconform}\n\\DDt{\\rho} + \\rho\\nabla\\cdot\\bmu &=& 0,\\slabel{nonconmass}\\\\\n\\rho\\DDt{\\bmu} -\\nabla\\cdot\\sigtens &=& \\rho\\bmF,\\slabel{nonconmom}\\\\\n\\rho\\DDt{\\inte} - \\sigtens\\cdot\\nabla\\bmu + \\nabla\\cdot\\bmq &=&\n0.\\slabel{nonconenergy} \\label{nonconservativesystem}\n\\end{subeqnarray}\nNote that, provided the fields (\\eg density and pressure) vary smoothly, that is, the fields are differentiable functions, equations \\eqref{conservativesystem} and \\eqref{nonconservativesystem} are identical.\n\n\\subsection{Equations of state \\& constitutive relations}\n\\label{sec:equation_of_state}\n\\index{equation of state}\n\nClosure of the conservation equations requires an additional equation describing how the stress tensor is related to density, temperature and any other state variables of relevance. In general, this relationship is dependent of the physical and chemical properties of the material in the domain; hence, this relationship is known as the material model (note that in multi-material simulations a different material model can and must be specified for each material).\n\nIt is convenient to separate the full stress tensor $\\sigtens$ into an isotropic part, the pressure $p$, and a deviatoric part $\\tautens$.  With the convention that compressive stress is negative, the stress tensor is given by $\\sigtens =-p \\bmI + \\tautens$, where $\\bmI$ is the identity matrix. If the stress tensor is separated in this way, the material model comprises two parts: an equation of state\\footnote{Equation of state settings in \\fluidity\\ are described in section~\\ref{sec:ConfigEOS}} $f(p,\\rho,T,\\ldots)=0$ relating density to pressure, temperature, etc., and a constitutive relationship\\footnote{constitutive relationship settings in \\fluidity\\ are described in section (to be written)} $g(\\tautens,\\bmu)=0$.\n\n\\subsubsection{Newtonian fluids}\n\\index{stress}\n\\index{strain}\n\nTwo important classes of fluids are: (i) Newtonian fluids, where deviatoric strain rate $\\left(\\etens\\right)$ is linearly proportional to deviatoric stress ($\\tautens$); and (ii) non-Newtonian fluids, where deviatoric strain rate is non-linearly proportional to the deviatoric stress. At present \\fluidity\\ is only configured to deal with Newtonian fluids.\n\nFor a Newtonian fluid the relation between deviatoric stress and deviatoric strain rate can be expressed as: \n\n\\begin{equation}\n\\tautens = 2\\mu \\etens + \\lambda(\\nabla\\cdot\\bmu)\\bmI,\n\\end{equation}\nwhere \n\\begin{equation}\n \\etens = \\frac{1}{2}(\\nabla\\bmu + (\\nabla\\bmu)^T),\n\\end{equation}\nis the\ndeviatoric strain rate tensor, and $\\bmI$ is the identity matrix. $\\mu$ and\n$\\lambda$ are the two coefficients of viscosity. Physical arguments\nyield the so-called Stokes' relationship $3\\lambda+2\\mu=0$, and\nhence:\n\\begin{equation}\n\\tautens = 2\\mu(\\etens - (\\nabla\\cdot\\bmu)\\bmI/3),\n\\end{equation}\nwhere $\\mu$ is the molecular viscosity. See \\cite{batchelor1967} for further\ndetails.\n\n\\subsubsection{Equation of state for incompressible flow}\n\\label{sec:IncompressibleFlow}\n\\index{equation of state}\n\nIf a material is \\emph{perfectly} incompressible its density cannot change;\nin other words, the material density is independent of pressure and\ntemperature, giving $\\rho = \\rho_0$, where $\\rho_0$ is the reference\ndensity. Note that a flow may contain multiple incompressible materials of\ndifferent densities, in which case $\\rho^k=\\rho_0^k$ applies for each\nindividual material (indexed with the superscript $k$).\n\nAll real materials are compressible to some extent so that changes in\npressure and temperature cause changes in density.  However, in many\nphysical circumstances such changes in material density are sufficiently\nsmall that the assumption of incompressible flow is still valid. If $U/L$ is\nthe order of magnitude of the spatial variation in the velocity field, then\nthe flow field can be considered incompressible if the relative rate of\nchange of density with time is much less than the spatial variation in\nvelocity; \\ie if $\\frac{1}{\\rho}\\DDt{\\rho}\\ll U/L$ then \\cite[][p.167]{batchelor1967}.\n\n\\begin{equation}\\label{eq:divfree}\n\\nabla\\cdot\\mathbf{u}\\approx 0.\n\\end{equation}\n\nThe term incompressible flow is used to describe any such situation where\nchanges in the density of a parcel of material are negligible.  Not all\nparcels in the flow need have the same density; the only requirement is that\nthe density of each parcel remains unchanged.  For example, in the ocean\nwhere salt content and temperature change with depth, the density of\nadjacent parcels changes but any one parcel has a constant density\n\\cite{panton2006}.  In such cases it is often important to account for\nchanges in buoyancy caused by the dependence of density on pressure,\ntemperature and composition $C$ (see, for example,\nsection~\\ref{sec:boussinesq_approximation}).  If the change in $\\rho,p,T,C$\nabout a reference state $\\rho_0,p_0,T_0,C_0$ is small, the dependence of\ndensity on each state variable can be assumed to be linear.  In this case, a\ngeneral equation of state takes the form\n\\index{equation of state!linear}\n\\begin{equation}\n\\rho = \\rho_0(1 - \\alpha(T-T_0) + \\beta(C-C_0) + \\gamma(p-p_0)),\n\\end{equation}\nwhere $\\alpha$ is the thermal expansion coefficient:\n\\begin{equation*}\n\\alpha = -\\frac{1}{\\rho}\\frac{\\pp\\rho}{\\pp T},\n\\end{equation*}\n$\\beta$ is a general compositional contraction coefficient\n\\begin{equation}\n\\beta = \\frac{1}{\\rho}\\frac{\\pp\\rho}{\\pp C},\n\\end{equation}\nand $\\gamma$ is the isothermal compressibility\n\\begin{equation}\n\\gamma = \\frac{1}{\\rho}\\frac{\\pp\\rho}{\\pp p}.\n\\end{equation}\n\nFor ocean modelling applications the most important compositional variation is salinity $S$ (the volume fraction of salt) and the compressibility of water $\\gamma$ is so small that the pressure dependence can be neglected, giving the simple linear equation of state\n\\begin{equation}\n\\rho = \\rho_0(1 - \\alpha(T-T_0) + \\beta(S-S_0)),\n\\end{equation}\nwhere $\\beta$ is the saline contraction coefficient (not to be confused with the beta plane parameters defined in the section \\ref{sec:coriolis}.)\n\n\\subsubsection{Pade equation of state for ocean modelling}\\label{sec:PadeDescription}\n\\index{equation of state!Pade approximation}\n\nWithin \\fluidity it is also possible to relate the density of sea water to the in situ temperature and salinity through the Pad{\\'e} approximation to the equation of state. This approximation offers an accurate and computationally efficient method for calculating the density of seawater and is described by \\citet{mcdougall2003}.\n\n% The Pade approx may not actually be coded for the in situ temp, this needs to be checked.\n\n\\subsection{Forms of the viscous term in the momentum equation} \\label{sec:ViscosityTerms}\n\nIf the modelled fluid is incompressible, or has a homogeneous viscosity, it is possible to simplify the stress term in the momentum equation. The complete form of this term, termed the '\\emph{stress form}', is:\n\\begin{equation}\n\\nabla\\cdot\\sigtens = \\nabla\\cdot\\left(-p \\bmI + \\tautens\\right) = - \\nabla p + \n\\nabla\\cdot\\mu\\left(\\nabla\\bmu + (\\nabla\\bmu)^T - \\frac{2}{3}(\\nabla\\cdot\\bmu)\\bmI \\right)\n\\end{equation}\n\nIf the flow is incompressible, $\\nabla\\cdot\\bmu=0$. It is now possible to simplify the above equation into the '\\emph{partial stress form}':\n\\begin{equation}\n\\nabla\\cdot\\sigtens = - \\nabla p + \n\\nabla\\cdot\\mu\\left(\\nabla\\bmu + (\\nabla\\bmu)^T\\right)\n\\end{equation}\n\nIf the flow is incompressible, and the viscosity is homogeneous:\n\\begin{equation}\n\\nabla\\cdot\\mu\\left(\\nabla\\bmu + (\\nabla\\bmu)^T\\right) = \\frac{\\partial}{\\partial x_j} \\mu \\left(\\frac{\\partial \\bmu_i}{\\partial x_j} + \\frac{\\partial \\bmu_j}{\\partial x_i}\\right) = \\mu \\left(\\frac{\\partial}{\\partial x_j}\\frac{\\partial \\bmu_i}{\\partial x_j} + \\frac{\\partial}{\\partial x_j}\\frac{\\partial \\bmu_j}{\\partial x_i}\\right) = \\mu \\left(\\frac{\\partial}{\\partial x_j}\\frac{\\partial \\bmu_i}{\\partial x_j}\\right) = \\nabla\\cdot\\mu\\nabla\\bmu\n\\end{equation}\nthe stress tensor can then be further simplified to obtain the '\\emph{tensor form}':\n\\begin{equation}\n\\nabla\\cdot\\sigtens = - \\nabla p + \\nabla\\cdot\\mu\\nabla\\bmu\n\\end{equation}\n\nThe appropriate form of the stress tensor must be selected in the options tree as described in \\ref{sec:VelocityOptions}.\n\n\\subsection{Momentum boundary conditions} \\label{sec:BCs-mom}\n\n\\index{boundary conditions!Momentum}\n\nAs with the scalar equations discussed previously in section \\ref{sec:MP-AdvdifEqn}, any well posed problem requires appropriate boundary conditions for the momentum equation. Possible momentum boundary conditions are discussed below.\n\n\\subsubsection{Prescribed Dirichlet condition for momentum --- no-slip as a special case}\\label{sec:bc_vector_dirichlet}\n\\index{boundary conditions!Dirichlet}\n\\index{momentum equation}\n\nThis condition for momentum is set by simply prescribing all three components of\nvelocity. For example, we might specify an inflow boundary where the normal component\nof velocity is non-zero, but the two tangential directions are zero. A special case is\nwhere all three components are zero and this is referred to as no-slip.\n\n\\subsubsection{Prescribed stress condition for momentum --- free-stress as a special case}\\label{sec:bc_vector_stress}\n\\index{boundary conditions!prescribed stress}\n\\index{traction force}\n\\index{momentum equation}\n\\index{free stress}\n\nAs with the scalar equation (see section \\ref{sec:bc_scalar_neumann}), applying Green's theorem to the stress term and the pressure\ngradient in \\eqref{mtm} results in a surface integral of the form\n\\begin{equation}\\label{StressBC}\n\\tautens\\cdot\\bmn - p\\bmn = \\bmT,\\quad \\textrm{on}\\quad \\partial\\Omega,\n\\end{equation}\nwhere $\\bmT$ is an applied `traction' force (actually a force per unit area or stress, it becomes\na force when the surface integral in the weak form is performed). An example of this might be were we set the vertical\ncomponent to zero (in the presence of a free surface) and impose the two tangential directions\n(\\eg a wind stress).\n\n\\index{boundary conditions!free stress}\nThe free-stress condition is the case where we take $\\bmT\\equiv\\vec{0}$.\n\n\\subsubsection{Traction boundary condition for momentum --- free-slip as a special case}\\label{sec:bc_vector_traction}\n\\index{boundary conditions!traction}\n\\index{momentum equation}\n\\index{free slip}\nIn this case the normal component of velocity can be prescribed (\\eg inflow or\nno-flow ($g=0$) through the boundary)\n\\begin{equation}\n\\bmu\\cdot\\bmn = g,\\quad \\textrm{on}\\quad \\partial\\Omega.\n\\label{normal_flow_condition}\n\\end{equation}\nThe remaining two degrees of freedom are imposed by taking the\ntangential component of \\eqref{StressBC} and specifying the tangential component\nof the force $\\bmT_{\\tau}$, \\ie\n\\begin{equation*}\n\\bmtau\\cdot(\\tautens\\cdot\\bmn - p\\bmn) = \\bmtau\\cdot\\tautens\\cdot\\bmn = \\bmT_{\\tau},\\quad \\textrm{on}\\quad \\partial\\Omega,\n\\end{equation*}\nAn example of this might be where a rigid lid is used (so normal component is zero)\nand the tangential components are a prescribed wind stress (in which case we take\nthe two tangential directions to correspond to the available stress or wind velocity\ninformation, \\ie east-west and north-south) or bottom drag. The term\n\\emph{free slip}, is often used for the case\nwhere the tangential components of stress are set to zero.\n\n\\subsubsection{Free surface boundary condition}\\label{sec:FS}\n\\index{free surface}\n\\index{kinematic boundary condition}\nIn the case of a free surface, the normal component of the velocity is related\nto the movement of the free surface through the \\emph{kinematic boundary\ncondition}. The free surface height $\\eta\\equiv\\eta(x,y,t)$ is measured from \nthe initial state of the fluid. The kinematic boundary condition is derived by\nstating that a fluid particle following the flow at the free surface, should\nremain at the free surface. In other words, its trajectory is described by\n$t\\mapsto (x(t), y(t),\\eta(x(t),y(t),t))$. Its vertical velocity, $w$, should\ntherefore satisfy:\n\\begin{equation} \\label{eq:kinematicbc1}\n  \\frac{D\\eta}{Dt}=\\bmu_H \\cdot\\nabla_H \\eta +\n  \\frac{\\partial\\eta}{\\partial t} = w \\quad \\textrm{on}\\quad \\Omega\n\\end{equation}\nwhere $\\nabla_H\\equiv(\\partial/\\partial x,\\partial/\\partial y)^T$, and\n$\\bmu_H$ is the horizontal component of $\\bmu$.\nUsing the fact that the normal vector $\\vec n$ at the free surface is\n$(-\\frac{\\partial \\eta}{\\partial x},-\\frac{\\partial \\eta}{\\partial y}, 1)^T/\n\\|(-\\frac{\\partial \\eta}{\\partial x},-\\frac{\\partial \\eta}{\\partial y}, 1)\\|$,\nthis can be reformulated to\n\\begin{equation}\\label{freesurf3}\n\\frac{\\partial \\eta}{\\partial t}=\\frac{\\bmu \\cdot \\vec n}{\\vec n \\cdot \\vec k},\n\\end{equation}\nwhere $\\vec k=(0,0,1)$ is the vertical normal vector. Note that in spherical\ngeometries $\\vec k$ is the radial unit vector. Since this condition does not\nrestrict the normal velocity, it simply\nprescribes what the free surface movement is, we still need a stress condition\nin all directions, similar to equation $\\eqref{StressBC}$. The tangential\ncomponents can be either free, $\\bmT_\\tau=0$, or given by a wind stress. For the\nnormal component, we get:\n\\begin{equation}\n  \\bmn\\cdot(\\tautens\\cdot\\bmn - p\\bmn) = \\bmn\\cdot\\tautens\\cdot\\bmn - p =\n  -\\patm \\quad \\textrm{on}\\quad \\partial\\Omega.\n  \\label{NormalStressBC}\n\\end{equation}\nIn ocean applications, the deviatoric part of the normal stress condition is\nusually neglected and a simple Dirichlet pressure boundary condition $p=\\patm$\nis applied instead.\n\n\\subsubsection{Wetting and drying}\\label{sec:WD}\n\\index{free surface!Wetting and drying}\nIf wetting and drying occurs, the free surface boundary condition \\ref{freesurf3} needs to be changed to ensure that the water level $\\eta$ does not sink below the bathymetry level $b$:\n\n\\begin{equation}\\label{eq:wd1}\n\\frac{\\partial \\max(\\eta, b+d_0)}{\\partial t}=\\frac{\\bmu \\cdot \\vec n}{\\vec n \\cdot \\vec k},\n\\end{equation}\nwhere $d_0$ is a threshold defining the minimum water depth.\n\nThe details of the wetting and drying algorithm are described in \\cite{Funke2011}.\n\n\\section{Extensions, assumptions and derived equation sets}\\label{sec:eqn_extensions}\n\nIn certain scenarios it is desirable to simplify the equations of sections \\ref{sec:MP-AdvdifEqn} and \\ref {sec:MP-MomEqn} according to various approximations. Such approximations can drastically reduce the complexity of the system under consideration while maintaining much of the important physics. In this section we consider approximate forms and assumptions of the conservation equations that are appropriate to different problems. \n\n\\subsection{Equations in a moving reference frame}\\label{sec:coriolis}\n\\index{Coriolis}\nNewton's second law holds in a fixed inertial reference frame, \\ie\nfixed with respect to the distant stars. \nExamples of systems which one may wish to study with boundaries moving\nwith respect to this fixed inertial frame include translating and spinning tanks\nand the rotating Earth. For these systems it is often convenient to rewrite the \nunderlying equations within the moving frame. Extra terms then need to be considered \nwhich account for the fact that the acceleration of a fluid parcel relative to the \nmoving reference frame is different to the acceleration with respect to the fixed \ninertial frame, and the latter is the one which allows us to invoke Newton's Laws.\nFor useful discussions see \\citep{batchelor1967,cushman1994,gill1982}.\n\n\\begin{figure}\\label{fig:rotating_frame}\n\\centering\n\\includegraphics[width=8.0cm]{misc_images/coordinates.pdf}\n\\caption{Schematic of coordinates in a frame rotating with a sphere. The rotation is about a vector\npointing from South to North pole. A point on the surface of the sphere $\\bmx$ and its perpendicular\ndistance from the axes of rotation $\\bmx_{\\perp}$ are shown. The latitude of $\\bmx$ is given by $\\phi$ \nand the unit vectors $\\bmi$, $\\bmj$ and $\\bmk$ represent a local coordinate axes at a point $\\bmx$ in the rotating\nframe: $\\bmi$ points Eastwards, $\\bmj$ points Northwards and $\\bmk$ points in the radial outwards direction.}\n\\end{figure}\n\nIt is possible to form the equations with respect to a moving reference frame as long as the\nadditional force or acceleration term is included. In the case of a rotating frame that is\njust by replacing the material derivative in the momentum equation by\n\\begin{equation}\n\\DDt{\\bmu} + 2\\bmOmega\\times\\bmu,\n\\end{equation}\nwhere $\\bmOmega$ is the angular velocity vector of the rotating\nsystem.\n\nConsider the Earth with a rotation vector in an inertial reference frame given by \n\\begin{equation}\\label{eq:on_sphere_rotation}\n\\bmOmega=(0,0,\\Omega)^T.\n\\end{equation}\nIn a local rotating frame of reference where the\n$x$-axis is oriented Eastwards,\nthe $y$-axis is oriented Northwards and the $z$-axis is the local upwards direction,\nthe Earth's rotation vector is expressed as\n\\begin{equation*}\n\\bmOmega = \\Omega \\cos \\phi\\; {\\bf j} + \\Omega \\sin \\phi\\; {\\bf k} \\equiv \\Omega (0,\\cos\\phi,\\sin\\phi)^T,\n\\end{equation*}\nwhere $\\phi$ is the latitude.\nThe acceleration terms in the three momentum equations now have the form\n{\\setlength\\arraycolsep{2pt}\n\\begin{eqnarray*}\n&&\\DDt{u} {\\color{red}+} {\\color{red}2\\Omega\\cos\\phi\\; w} - 2\\Omega\\sin\\phi\\; v,\\\\\n&&\\DDt{v} + 2\\Omega\\sin\\phi\\; u,\\\\\n&&\\DDt{w} {\\color{red}-} {\\color{red}2\\Omega\\cos\\phi\\; v}.\n\\end{eqnarray*}}\n\n\\subsubsection{The `traditional' approximation}\n\\index{traditional approximation}\nDefine the Coriolis and reciprocal Coriolis parameters \\citep{cushman1994} respectively by\n\\begin{equation}\\label{eq:coriolis_parameters} \nf=2\\Omega\\sin\\phi,\\quad f^*=2\\Omega\\cos\\phi.\n\\end{equation}\nDue to dimensional considerations it is is usual to\ndrop the $f^*$ term and hence simply assume that \n\\begin{equation}\\label{eq:f_omega}\n\\bmOmega=(0,0,f/2)^T,\n\\end{equation}\nin the local frame of reference, \\ie only to consider the locally vertical\ncomponent of the rotation vector.\nThis approximation, when taken along with the assumption of hydrostatic balance in the\nvertical constitutes what is generally known as the traditional approximation in geophysical fluid\ndynamics.\n\n\n\\subsubsection{The $f$-plane and $\\beta$-plane approximations}\n\\index{Coriolis!f-plane@$f$-plane}\n\\index{Coriolis!b-plane@$\\beta$-plane}\nIf the Coriolis parameter $f$ is approximated by a constant value:\n\\begin{equation}\\label{eq:f-plane}\nf=f_0,\n\\end{equation}\nthis is termed the $f$-plane approximation, \nwhere $f_0 = 2\\Omega\\sin\\phi_0$ at a latitude $\\phi_0$.\nThis is obviously only an applicable approximation in a domain of interest \nthat does not have large extent in latitude. \n\nFor slightly larger domains a more accurate approximation is to use\n\\begin{equation}\\label{eq:beta-plane}\nf = f_0 + \\beta y,\n\\end{equation}\nwhere $y$ is the local coordinate in the Northwards direction.\nTaking $\\phi = \\phi_0 + y/R_E$ and expanding \\eqref{eq:coriolis_parameters} \nin a Taylor series yields\n\\begin{equation*}\nf = f_0 +2\\Omega\\cos\\phi_0\\frac{y}{R_E}+\\ldots,\\quad \\beta = \\frac{2\\Omega}{R_E}\\cos\\phi_0,\n\\end{equation*}\nwhere $R_E\\approx\\unit[6378]{km}$. Typical values of these terms are: \n\\begin{equation*}\n\\Omega = \\frac{2\\pi}{24\\times 60\\times 60} = 7.2722\\times 10^{-5}\\rads[],\n\\end{equation*}\n(NB. a sidereal day should be used to give a more accurate value of $7.2921\\times 10^{-5}\\rads[]$)\nand\n\\begin{center}\\begin{small}\n\\begin{tabular}{c|ccc}\n  &  $\\phi_0 = 30$ & $\\phi_0=45$ & $\\phi_0 = 60$ \\\\  \\hline\n $f_0$  & 7.2722e-05 & 1.0284e-04 & 1.2596e-04 \\\\\n $\\beta$  & 1.9750e-11  &  1.6124e-11  &  1.1402e-11 \\\\\n\\end{tabular}\\end{small}\n\\end{center}\n\n\\subsection{Linear Momentum}\n\\index{linear momentum}\n\nNewton's second law states that the sum of forces applied to a body is equal to the time derivative of linear momentum of the body,\n\\begin{equation}\\label{Newtons2nd}\n \\sum \\vec f = \\d(m\\vec u)/\\d t.\n\\end{equation}\nApplying this law to a control volume\\footnote{The concept of a control volume and how they are defined within fluidity is discussed more in section \\ref{ControlVolumeAdvection}} of fluid and making use of equation \\ref{RTT} leads to the linear momentum equation for a fluid which can be written as\n\\begin{equation}\\label{LinMom}\n \\frac{\\partial}{\\partial t}\\int_{V}\\rho\\vec u \\d V = -\\int_{S} \\vec u \\rho \\vec u\\cdot\\vec n \\d A+\\int_{V}\\vec F\\rho \\d V\n                                                      +\\int_{S} \\sigtens\\cdot\\vec n \\d A,\n\\end{equation}\nwhere $V$ is the control volume, $S$ is the surface of the control volume and $\\vec n$ is the unit normal to the surface of the control volume and $\\vec F$ is a volume force per unit mass. Physically, \\ref{LinMom} states that the sum of all forces applied on the control volume is equal to the sum of the rate of change of momentum inside the control volume and the net flux of momentum through the control surface. More details regarding the derivation and properties of this equation can be found in \\citet{batchelor1967}.\n\n\\subsection{The Boussinesq approximation} \\label{sec:boussinesq_approximation}\n\\index{density!reference}\n\\index{Boussinesq!approximation}\n\nUnder certain conditions, one is able to assume that density does not vary greatly about a mean reference density, that is, the density at a position $\\vec x$ can be written as\n\\begin{equation}\n\\rho(\\bmx,t) = \\rho_0 + \\rho'(\\bmx,t),\n\\end{equation}\nwhere $\\rho'\\ll\\rho_0$. Such an approximation, namely, the Boussinesq\napproximation, involves two steps. The first makes use of \\eqref{eq:divfree} ---\nmass conservation thus becomes volume conservation and sound waves are filtered.\nThe second part of the Boussinesq approximation follows by replacing $\\rho$ by\n$\\rho_0$ in all terms of \\eqref{viscous_fluids_1}, except where density is\nmultiplied by gravity (\\ie in the buoyancy term where full density must be retained --- these are the density variations that drive natural convection). This yields\n\\begin{equation}\n\\rho_0\\DDt{\\bmu} -\\nabla\\cdot\\sigtens = \\rho \\bmg + \\rho_0\\bmF,\n\\end{equation}\nwhere the gravity term has been separated explicitly from the forcing term $\\bmF$ and $\\bmg$ is the gravitational vector (e.g. $\\bmg = -g\\bmk$ in planar problems when gravity points in the negative $z$ direction and $\\bmg = -g\\vec r$ on the sphere).\n\n\\subsubsection{Buoyancy and hydrostacy}\\label{sec:buoyancy_hydrostacy}\n\\index{density!reference}\n\\index{pressure!perturbation}\nIn absence of viscosity the vertical momentum equation can be written as:\n\\begin{equation}\\label{eq:vertmom}\n\\DDt[t]{w} = -\\ppx[z]{p} + \\rho g.\n\\end{equation}\nIf the fluid is in a state of rest, the left hand-side is zero, giving:\n\\begin{equation}\\label{eq:hydrostatic_balance}\n\\ppx[z]{p} = -\\rho g\n\\end{equation}\nThis is known as hydrostatic balance. If the pressure $p_{\\text{top}}$ at the top of the domain\nis given, e.g., an atmospheric pressure or a given ice load, \nthe hydrostatic pressure can be computed as\n\\begin{equation} \\label{eq:hydrostatic_pressure}\n  p(x,y,z) = p_{\\text{top}}(x,y) + \\int_{z=z}^{\\eta(x,y)} \\rho g dz,\n\\end{equation}\nwhere $z=\\eta(x,y)$ denotes the location of the top of the domain, e.g. a free\nsurface. Here, we assume a coordinate system with $x$ and $y$ in the horizontal\nand $z$ in the vertical direction. The integral represents the weight of the\nwater above a point at a given height $z$. For a constant density this simplifies to:\n\\begin{equation}\n  p(x,y,z) = p_{\\text{top}}(x,y) + \\rho g \\left(\\eta(x,y)-z\\right).\n\\end{equation}\n\nIf we consider the general case, that is not in hydrostatic balance and where\nthe density is not constant, but we have a small perturbation density \n$\\rho'$, we may still write:\n\\begin{equation}\n  p(x,y,z) = p_0(z) + p'(x,y,z) = -\\rho_0 g z + p'(x,y,z).\n\\end{equation}\nHere, we have separated the pressure $p_0=-\\rho_0 g z$, due to the weight of a fluid of reference density $\\rho_0$ below a reference level at $z=0$ near the top, from a perturbation pressure $p'$. This\nperturbation pressure still contains the hydrostatic pressure due to the\nperturbation density, and non-hydrostatic parts of the pressure. In the \ncase of a free surface at $z=\\eta$, the additional weight of $\\rho g\\eta$, that\nis not taken into account in $p_0$ is also included in $p'$.\n\nBy construction, the pressure gradient of $p_0$ exactly balances $\\rho_0\\bmg$,\nthe reference density part of the gravity term\n\\begin{equation}\n  \\rho\\bmg=\\rho_0\\bmg+\\rho'\\bmg\n\\end{equation}\nWe can therefore simply replace $p$ by $p'$ in the pressure gradient term, if we\nsubtract $\\rho_0\\bmg$ from the gravity term, to obtain a buoyancy term\n$\\rho'\\bmg$.\n\n\\subsubsection{Combining pressure and free surface}\n\\index{free surface}\nIn many models with a free surface, the $\\rho_0 g\\eta$ part of pressure (known\nin ocean models as barotropic pressure), is subtracted from the pressure as\nwell, \nand treated separately. Since this part still depends on the horizontal\ncoordinates, its 3D gradient does not simply balance with the buoyancy, and a\nhorizontal gradient $\\rho_0g\\nabla_{\\text{H}}\\eta$ remains, which is added as\nan extra term in the momentum equation in such models. \nIn \\fluidity{}\nhowever, we keep this part in the perturbation pressure and it is therefore\nsolved for in conjunction with the non-hydrostatic parts of pressure. \n\nIn this approach, care has to be taken when applying boundary conditions. If a\npressure boundary condition of $p=\\patm$ is enforced at $z=\\eta$, then the\nboundary condition for the perturbation changes to:\n\\begin{equation}\n  p'=p+\\rho_0 z=\\patm+\\rho_0 g\\eta\n  \\quad \\textrm{on}\\quad \\partial\\Omega.\\label{freesurfacepressure}\n\\end{equation}\nIf a normal stress condition is applied, see \\eqref{NormalStressBC}, we similarly get:\n\\begin{equation}\n  -\\bmn\\cdot\\tautens\\cdot\\bmn + p' = \\patm + \\rho_0 g\\eta\n  \\quad \\textrm{on}\\quad \\partial\\Omega.\n  \\label{normalstressfreesurface}\n\\end{equation}\n\n\\subsubsection{The non-hydrostatic Boussinesq equations}\\label{sec:typical_ICOM_equations}\n\\index{Boussinesq!equations}\n\\index{momentum equation}\n\\index{continuity equation}\n\nApplying the approximations outlined in section \\ref{sec:boussinesq_approximation} to (\\ref{viscous_fluids_1}) and (\\ref{mass_conservation_2}), along with scalar transport equations for salinity and temperature (see (\\ref{eq:general_scalar_eqn})) and an appropriate equation of state (see section \\ref{sec:equation_of_state}), the three-dimensional non-hydrostatic Boussinesq equations can be written as\n\n\\begin{subeqnarray}\n\\frac{\\pp\\bmu}{\\pp t} + \\bmu\\cdot\\nabla \\bmu + 2 \\bmOmega \\times \\bmu\n&=& - \\nabla p' + \\rho' \\bmg + \\nabla\\cdot \\tautens + \\bmF,\n\\slabel{mtm}\\\\\n\\nabla\\cdot {\\bmu}&=&0,\\slabel{conty}\\\\\n\\frac{\\pp T}{\\pp t} + \\bmu\\cdot\\nabla  T  &=&\n\\nabla . \\left ( \\kaptens_T  \\nabla T\\right),\\slabel{heat}\\\\\n\\frac{\\pp S}{\\pp t} + \\bmu\\cdot\\nabla  S  &=&\n\\nabla . \\left ( \\kaptens_S  \\nabla S\\right),\\slabel{salt}\\\\\nf(p,\\rho,T,\\ldots)&=&0,\\slabel{state}\n\\label{boussinesq}\n\\end{subeqnarray}\n\nwhere $p'$ is the perturbation pressure (see section \\ref{sec:buoyancy_hydrostacy}),\n$\\rho=\\rho_0+\\rho'$ where $\\rho'(=(\\rho-\\rho_0)/\\rho_0)$ is the perturbation density,\n$T$ is the temperature, $S$ is salinity, and\n$\\tautens,\\kaptens_T,\\kaptens_S$ are the viscosity, thermal diffusivity and saline\ndiffusivity tensors respectively.\nThe rotation vector is $\\bmOmega$, and $\\bmF$ contains additional source terms such as the astronomical tidal forcing. A discussion\nregarding the validity of the Boussinesq approximation is given in \\cite{Gray1976}\n\n\\subsection{Supplementary boundary conditions and body forces}\n\n\\subsubsection{Bulk parameterisations for oceans}\n\\index{boundary conditions!bulk parameterisations}\n\nIn order to simulate real-world ocean scenarios, realistic boundary conditions for the momentum, freshwater and heat fluxes \nmust be applied to the upper ocean surface. \\fluidity can apply such boundary conditions in the form of the bulk formulae of \\citet{large2004},\nCOARE 3.0 \\citep{fairall2003} and \\citet{kara2005} in combination with the ERA-40 reanalysis data \\citep{Uppala2005}.\n\nThree surface kinematic fluxes calculated: heat -- $\\langle w\\theta \\rangle$,\nsalt -- $\\langle ws \\rangle$, and momentum -- $\\langle wu \\rangle$ and $\\langle wv \\rangle$,\nwhich can be related to the surface fluxes of heat $Q$, the\nfreshwater $F$, and the momentum $\\overrightarrow\\tau=\\left(\\tau_u,\\tau_v\\right)$, via:\n\\begin{align}\n\\langle w\\theta \\rangle &= Q\\left(\\rho C_p \\right)^{-1} \\\\\n\\langle ws \\rangle &= F\\left(\\rho^{-1}S_0\\right) \\\\\n\\left(\\langle wu \\rangle, \\langle wv \\rangle\\right) &=\n\\overrightarrow{\\tau}\\rho^{-1} =\n\\left(\\tau_u,\\tau_v\\right)\\rho^{-1}\n\\end{align}\nwhere $\\rho$ is the ocean density, $C_p$ is the heat capacity (4000 Jk$S^{-1}$K$^{-1}$) \nand $S_0$ is a reference ocean salinity, which is the current sea surface salinity. \nThese fluxes are then applied as upper-surface Neumann boundary conditions on\nthe appropriate fields.\n\n\\subsubsection{Co-oscillating boundary tides}\n\\index{boundary conditions!boundary tides}\n\\label{sec:boundary_tide}\n\nBoundary tides can be applied to open ocean domain boundaries through setting a Dirichlet condition on the non-hydrostatic part of the pressure. Co-oscillating tides are forced as cosine waves of specified phase and amplitude along designated boundaries:\n\\begin{equation}\nh=\\sum_{i}A_{i}\\cos(\\sigma_{i} t -\\phi_{i})\n+\\sum_{j}A_{j}\\cos(\\sigma_{j} t -\\phi_{j})\n+\\sum_{k}A_{k}\\cos(\\sigma_{k} t -\\phi_{k}),\n\\label{eq:co-oscillating-tide}\n\\end{equation}\nwhere $h$ is the free surface height (m), $A$ is the amplitude of the tidal \nconstituent (m), $t$ is the time (s), $\\phi$ is the phase of the tidal constituent \n(radians) \\citep{Wells2008}. \n \nThe nature of the co-oscillating tide can take the form of either one fixed cosine wave of constant amplitude \nand phase applied across the entire length of the boundary, or it can be variable as delimited via an \ninterpolation of different amplitudes and phases at a series of points spread along the boundary \\citep{Wells2008}.\nWithin \\fluidity, co-oscillating boundary tides can be applied through \\eg the FES2004 data set (see \\ref{sec:tides_in_the_med}).\n\n\\subsubsection{Astronomical tides}\\label{sec:AST}\n\\index{body forces!astronomical tides}\n\\label{astronomical}\n\nAstronomical forcing can also be applied to a fluid as a body force\\footnote{Note that use of the word body force in this context should not be confused with the application of a body force through the options tree discussed later in \\ref{chap:configuration}. The astronomical forcing is applied separately.}. \nThe astronomical tidal potential is calculated at each node of the finite element mesh using the \nmulti-constituent equilibrium theory of tides equation:\n  \\begin{eqnarray}\n\\eta_{eq}\\left(\\lambda,\\theta,t\\right)&=&\\sin^{2}\\theta\\sum_{i}A_{i}\\cos\\left(\\sigma_{i}t+\\chi_{i}+2\\lambda\\right)\\nonumber\\\\\n&+&\\sin2\\theta\\sum_{j}A_{j}\\cos\\left(\\sigma_{j}t+\\chi_{j}+\\lambda\\right)\\\\\n&+&\\left(3\\sin^{2}\\theta-2\\right)\\sum_{k}A_{k}\\cos\\left(\\sigma_{k}t+\\chi_{k}\\right)\\nonumber,\n\\label{eq:multi-constituent-eq_theory}\n  \\end{eqnarray}\nwhere $\\eta_{eq}$ is the equilibrium tidal potential (m), $\\lambda$ is the east longitude (radians), $\\theta$ is the colatitude\n$[(\\pi/2)-{\\text{latitude}}]$, $\\chi$ is the astronomical argument (radians), $\\sigma$\nis the frequency of the tidal constituent (s$^{\\text{-1}}$), $t$ is universal standard\ntime (s) and $A$ is the equilibrium amplitude of the tidal constituent (m). Subscript\n$i$ represents the semi-diurnal constituents (e.g. M$_{\\text{2}}$), subscript $j$\nthe diurnal constituents (\\eg K$_{\\text{1}}$) and subscript $k$ the long period\nconstituents (\\eg M$_{\\text{f}}$; \\citealp{Wells2008}).   \nThe overall forcing \nis applied as the product of the gradient of the resulting equilibrium tidal potential and the acceleration due \nto gravity (g) \\citep{Mellor1996, Kantha2000, Wells2007}.\nThe multi-constituent equilibrium theory of tides is flexible in that it enables astronomical tides to be forced as \nindividual constituents \n(e.g. M$_{2}$ or S$_{2}$) or as a combination of different constituents (e.g. M$_{2}$ + S$_{2}$) \\citep{Wells2008}.\n\nAs there is no interest in calculating the tide for an exact date, the astronomical argument \nis typically excluded from the multi-constituent theory of tides equation for ICOM applications meaning that all satellites \nstart at 0$^{\\circ}$ latitude \\citep{Wells2008}.\n\nThe astronomical tidal potential can be modified to account for the deformation of the solid Earth\n(the body tide) if desired. The multi-constituent equilibrium theory of tides equation includes the effects of the\nsolid Earth deformation, adding this to the overall free surface height. \nThis is fine\nwhen validating model results against measurements that record the overall elevation of the \nEarth's oceans (e.g. satellite altimeter readings and surface tide gauges). If however, the model\nis validated against measurements that do not include the effects of the Earth's body tide\nsuch as with pelagic pressure gauges, then a correction to the equilibrium tidal potential\nis required. This can be applied as: \n\\begin{equation}\n\\eta=(1+k-h)\\eta_{eq},\n\\label{eq:body-tide}\n\\end{equation}    \nwhere $\\eta$ is the corrected tidal potential, $\\eta_{eq}$ is the uncorrected equilibrium tidal potential\nand $k$ (0.3) and $h$ (0.61) are Love numbers (after \\citealp{Love1909}).\nBoth $k$ and $h$ are dimensionless measures of the elastic behaviour of the solid Earth. $k$ accounts for the enhancement to the\nEarth's gravitational potential brought about by the re-distribution of the Earth's mass whereas $h$\nis a correction for the physical distortion to the Earth's surface \\citep{Pugh1987}.\n\nThe exact values of $k$ and $h$ vary for different tidal constituents and the numbers shown are given\nfor the semi-diurnal M$_{\\text{2}}$ constituent. Typical variations to $k$ and $h$ are less than 0.01 which\ncorresponds to a $<$1\\% change to the equilibrium tidal potential.\nThese errors are sufficiently small that the stated values are a suitable approximation to\nuse in body tide corrections to the majority of tidal constituents.\n\n\\subsection{Shallow water equations}\n\\index{shallow water equations}\nIn many oceanographic simulations, the horizontal lengths scales are much larger\nthan the vertical. It can be shown that this leads to small vertical velocities,\nand in particular small vertical accelerations. Thus, in the vertical momentum\nequation \\eqref{eq:vertmom} the left hand-side can be neglected entirely. This\nmeans we assume the total pressure is given by \\eqref{eq:hydrostatic_pressure},\nthe so-called hydrostatic or shallow water approximation.\n\nAlthough shallow water flows are nearly horizontal, they may still exhibit a\nthree-dimensional structure, due to e.g. bottom friction. In many applications\nhowever, these 3D effects are not important and it is sufficient to only study\nthe depth-averaged flow velocities and free surface elevations\n\\citep{vreugdenhil1994}. The depth-integrated continuity equation can be derived\nby working out the horizontal divergence of the horizontal velocities\nintegrated, vertically, from the bottom $z=b$ to the free surface $z=\\eta$:\n\\begin{equation}\n\\begin{split}\n  \\nabla_H \\cdot \\int_{z=b}^{z=\\eta} \\bmu_H &=\n  \\bmu_H\\big|_{z=\\eta}\\cdot\\nabla_H \\eta\n  -\\bmu_H\\big|_{z=b}\\cdot\\nabla_H b + \\int_{z=b}^{z=\\eta} \\nabla_H\\cdot\\bmu_H \\\\\n  &=\n  \\bmu_H\\big|_{z=\\eta}\\cdot\\nabla_H \\eta\n  -\\bmu_H\\big|_{z=b}\\cdot\\nabla_H b \n  + \\int_{z=b}^{z=\\eta} \\nabla\\cdot\\bmu-\\frac{\\partial w}{\\partial z} \\\\\n  &=\n  \\left[\\bmu_H\\cdot\\nabla_H \\eta + w\\right]_{z=\\eta}\n  -\\left[\\bmu_H\\cdot\\nabla_H b + w\\right]_{z=b} \\\\\n  &=-\\frac{\\partial\\eta}{\\partial t} + 0\n  \\label{eq:swe1_derivation}\n\\end{split}\n\\end{equation}\nHere, we've made use of the divergence-freeness of the flow, and, in the last\nstep, the kinematic boundary condition \\eqref{eq:kinematicbc1} at the free\nsurface and no-normal-flow condition at the bottom.\n\nAfter defining the total water depth $h=\\eta-b$, and the depth-averaged\nvelocity:\n\\begin{equation}\n  \\bar\\bmu = \\frac{\\int_{z=b}^{z=\\eta} \\bmu_H}{h},\n\\end{equation}\nthe depth-averaged shallow water equations (in non-conservative form) are given\nby:\n\\begin{subequations} \\label{eq:swe}\n\\begin{align}\n  \\frac{\\partial\\eta}{\\partial t} + \\nabla\\cdot\\left(h\\bar\\bmu\\right) &=0,\n  \\label{eq:swe1} \\\\\n  \\frac{\\partial\\bar\\bmu}{\\partial t} + \\bar\\bmu\\cdot\\nabla\\bar\\bmu\n  + g\\nabla\\eta + C_D \\frac{\\|\\bar\\bmu\\|\\bar\\bmu}{h} &=0. \\label{eq:swe2}\n\\end{align}\n\\end{subequations}\nNote that because this is now a purely two-dimensional equation, we may drop the\nsubscript $H$ from the gradient operator $\\nabla$. The continuity equation\n\\eqref{eq:swe1} follows directly from \\eqref{eq:swe1_derivation}.\nFor the derivation of the depth-averaged momentum equation \\eqref{eq:swe2} see\ne.g. \\citet{vreugdenhil1994}. The last term in that equation is a quadratic drag term, with\ndimensionless coefficient $C_D$, that represents the bottom friction.\n\n\\subsection{Multi-material simulations}\n\\index{multi-material flow}\nThe ability to differentiate between regions with distinct material properties is of fundamental importance in the modelling of many physical systems. Two different approaches exist for achieving this: the multi-material approach and the multiphase approach. The multi-material approach is implemented within \\fluidity, and the multiphase approach (discussed in the next subsection) is currently under development.\nIn situations where the model can resolve physical mixing of immiscible materials, or where there is no mixing, only one velocity field (and hence one momentum equation) is required to describe the flow of all materials. The \\emph{multi-material} approach, considers all materials to be immiscible materials separated by a sharp interface.\n\nIn a multi-material approach, the various forms of the conservation equations can be solved for multiple material flows if the point-wise mass density $\\rho$ in the equations is defined as the bulk density at each point.  If the flow comprises $n$ materials and the volume fraction of the $i^{th}$ material is denoted $\\phi_i$ then the bulk density is given by:\n\\begin{equation}\n\\rho = \\sum_{i=1}^n \\phi_i\\rho_i\n\\end{equation}\nwhere $\\rho_i$ is the density of each material.  For incompressible materials $\\rho_i = \\rho_{i0}$; for materials whose density is defined by an equation of state (see section~\\ref{sec:equation_of_state}) $\\rho_i = f(p,T,S,\\ldots)$.  Conservation of mass at each point also requires that\n\\begin{equation}\n\\sum_{i=1}^n \\phi_{i} = 1.\n\\end{equation}\n\nIn an $n$-material problem, the multi-material approach requires that $n-1$ advection equations are solved, to describe the transport of the volume fraction of all but one of the materials.  The volume fraction of the remaining material can be derived from the other volume fractions by\n\\begin{equation}\\label{diagnosticvolfrac}\n\\phi_{n} = 1 - \\sum_{i=1}^{n-1}\\phi_{i}. \n\\end{equation}\nThe transport of the $i^{th}$ volume fraction is given by  \n\\begin{equation}\n\\ppt{\\phi_i} + \\bmu\\cdot\\nabla\\phi_i = 0,\n\\end{equation}\nwhere the volume fraction field at time zero must be specified.\n\n\\subsection{Multiphase simulations}\n\\label{sec:multiphase_equations}\n\\index{multiphase flow}\nMultiphase flows are defined by \\cite{prosperettiEtAl2007} to be flows in which two or more phases of matter (solid, liquid, gas, etc) are simultaneously present and are allowed to inter-penetrate. Simple examples include the flow of a fizzy drink which is composed of a liquid and a finite number of gas bubbles, the transportation of solid sediment particles in a river, and the flow of blood cells around the human body.\n\nFurther to the above definition, each phase is classed as either \\textit{continuous} or \\textit{dispersed}, where a continuous phase is a connected liquid or gas substance in which dispersed phases (comprising a finite number of solid particles, liquid droplets and/or gas bubbles) may be immersed \\citep{croweEtAl1998}.\n\nTo enable the mixing and inter-penetration of phases, a separate velocity field (and hence a separate momentum equation) is assigned to each one and solved for. Extra terms are then included to account for inter-phase interactions. Furthermore, the model currently assumes no mass transfer between phases, incompressible flow, and a common pressure field $p$ so that only one continuity equation is used. The form of the governing equations depends on whether we are dealing with incompressible or compressible flow.\n\n\\subsubsection{Incompressible flow}\nFor an incompressible multiphase flow, the continuity equation and momentum equation for phase $i$ (based on the derivation in \\cite{ishii1975}, written in non-conservative form) are:\n\\begin{equation}\n\\sum_{i=1}^N\\nabla\\cdot\\left(\\alpha_i\\mathbf{u}_i\\right) = 0,\n\\end{equation}\n\\begin{equation}\n\\alpha_i\\rho_i\\frac{\\partial \\mathbf{u}_i}{\\partial t} +\n\\alpha_i\\rho_i\\mathbf{u}_i\\cdot\\nabla\\mathbf{u}_i =\n-\\alpha_i\\nabla p + \\alpha_i\\rho_i\\mathbf{g} +\n\\nabla\\cdot\\left(\\alpha_i\\tautens_i\\right) +\n\\mathbf{F}_i,\n\\end{equation}\nwhere $\\mathbf{u}_i$, $\\rho_i$, $\\tautens_i$ and $\\alpha_i$ are the velocity, density, viscous stress tensor and volume fraction of phase $i$ respectively, and $\\mathbf{F}_i$ represents the forces imposed on phase $i$ by the other $N-1$ phases. Details of momentum transfer terms are given in Chapter \\ref{chap:configuration}. For more information about the incompressible multiphase flow model implemented in Fluidity, see the paper by \\cite{Jacobs_etal_2013}.\n\n\\subsubsection{Compressible flow}\nFluidity currently only supports the case where the continuous phase is compressible. All other phases (the dispersed phases) are incompressible. The momentum equation is the same as the one given above, but the continuity equation becomes:\n\\begin{equation}\n\\alpha_1\\frac{\\partial\\rho_1}{\\partial t} + \\nabla\\cdot\\left(\\alpha_1\\rho_1\\mathbf{u}_1\\right) + \\rho_1\\left(\\sum_{i=2}^N\\nabla\\cdot\\left(\\alpha_i\\mathbf{u}_i\\right)\\right) = 0,\n\\end{equation}\nwhere the compressible phase has an index of $i=1$ here.\n\nAn internal energy equation may also need to be solved depending on the equation of state used for the compressible phase. This is given by:\n\\begin{equation}\n\\alpha_i\\rho_i\\frac{\\partial e_i}{\\partial t} + \\alpha_i\\rho_i\\mathbf{u}_i\\cdot\\nabla e_i = -\\alpha_i p\\nabla\\cdot\\mathbf{u}_i + \\nabla\\cdot\\left(\\alpha_i\\frac{k_i}{C_{v,i}}\\nabla e_i\\right) + Q_i\n\\end{equation}\nwhere $e_i$ is the internal energy, $k_i$ is the effective conductivity, $C_{v,i}$ is the specific heat (at constant volume), and $Q_i$ is an inter-phase energy transfer term described in Chapter \\ref{chap:configuration}. Note that, in Fluidity, the pressure term is always neglected in the (incompressible) particle phase's internal energy equation.\n", "meta": {"hexsha": "d748adb319bf620cd2190d9192cf590d97c4856e", "size": 56367, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "software/multifluids_icferst/manual/model_equations.tex", "max_stars_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_stars_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-11T02:39:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-11T03:08:38.000Z", "max_issues_repo_path": "software/multifluids_icferst/manual/model_equations.tex", "max_issues_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_issues_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "software/multifluids_icferst/manual/model_equations.tex", "max_forks_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_forks_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-05-21T22:50:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-28T17:16:31.000Z", "avg_line_length": 60.544575725, "max_line_length": 725, "alphanum_fraction": 0.7623254741, "num_tokens": 16169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.44970939321965014}}
{"text": "\n\n\nCOMPARE THIS TO THE GROUP-WISE MODEL Chapter\n\nEmphasize that covariates are important.  There's no reason to ignore\nthem just because this was common in traditional tests.\n\nDifference between experimental work and field or observational work.\n\nTitle of Fisher's book: ``for experimental workers''\n\n\\subsubsection{Differences Between Means of Two Groups: the Two-Sample t-test}\n\nThe one-way \\ANOVA\\ approach works when comparing the means among\ngroups.  It can be applied to any number of groups: 2 groups, 3\ngroups, 4 groups, and so on.\n\nYou might be surprised to hear that there is a special test, called\nthe \\newword{two-sample t-test} for testing whether the means are\ndifferent between two groups.  I'll illustrate it using the question\nof whether the current population survey data give \nsignificant evidence that wages are different between men and women\n--- two groups.\n\n\\index{P}{summary@\\texttt{summary}!for linear models}\n\\index{P}{Hypothesis Testing!summary@\\texttt{summary}!for linear models}\n\n\nUsing the modeling approach, the calculations are:\n\\begin{Schunk}\n\\begin{Sinput}\n> cps = fetchData(\"cps.csv\")\n> mod3 = lm( wage ~ sex, data=cps)\n> summary(mod3)\n\\end{Sinput}\n\\begin{Soutput}\n...\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept)    7.879      0.322   24.50  < 2e-16 ***\nsexM           2.116      0.437    4.84  1.7e-06 ***\n---\nSignif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 \n\nResidual standard error: 5.03 on 532 degrees of freedom\nMultiple R-squared: 0.0422,\tAdjusted R-squared: 0.0404 \nF-statistic: 23.4 on 1 and 532 DF,  p-value: 1.7e-06 \n\\end{Soutput}\n\\end{Schunk}\nThe p-value is very small, justifying rejection of the null\nhypothesis.  (This conclusion is subject to some legitimate\ncriticism, since no attempt has been made to adjust for covariates\nsuch as \\VN{age} or the level of education.  With a modeling approach,\nyou can add these covariates to the model.  But the t-test and one-way\n\\ANOVA\\ approaches don't allow this to be done.  That's sufficient\nreason not to use them.  For the purpose here, to demonstrate how to\nperform a t-test, I'll continue on without claiming that the use of\nthe method is justified in anything but a formal sense.)\n\nThe streamlined form of the calculation produces the same F and p-value:\n\\begin{Schunk}\n\\begin{Sinput}\n> anova(mod3)\n\\end{Sinput}\n\\begin{Soutput}\nAnalysis of Variance Table\n\nResponse: wage\n           Df Sum Sq Mean Sq F value  Pr(>F)    \nsex         1    594     594    23.4 1.7e-06 ***\nResiduals 532  13483      25                    \n---\nSignif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 \n\\end{Soutput}\n\\end{Schunk}\n\nNow to do this in the form of a t-test.  The command uses the familiar\nmodeling language to identify the response variable (\\VN{wage)} and\nthe explanatory grouping variable (\\VN{sex}).\n\\begin{Schunk}\n\\begin{Sinput}\n> t.test( wage ~ sex, data=cps, var.equal=TRUE)\n\\end{Sinput}\n\\begin{Soutput}\n\tTwo Sample t-test\n\ndata:  wage by sex \nt = -4.84, df = 532, p-value = 1.703e-06\nalternative hypothesis: true difference in means is not equal to 0 \n95 percent confidence interval:\n -2.97 -1.26 \nsample estimates:\nmean in group F mean in group M \n           7.88            9.99 \n\\end{Soutput}\n\\end{Schunk}\nRather than computing F, the t-test computes a statistic called the t\nvalue.  The relationship between the two is simple: $t^2 = F$.  So,\nthe t of $-4.84$ corresponds to F $=23.4$.\nSimilarly, in the t-test there is a quantity called the ``degrees of\nfreedom.''  This corresponds to the degrees of freedom in the\ndenominator in the F test.  The p-values from the t-test and the F\ntest are the same!\n\n\\subsubsection{Technical Note: The Unequal Variance t-test}\n\\label{sec:unequal-variance-t-test}\n\\index{C}{t-test!unequal variance}\n\nActually, the above t-test is not the one that many people would\nperform in this situation.  The full name of the above test is the\n\\newword{equal-variance t-test}. \nI include this section mainly for the\nreader who has been told about the \n\\newworddef{unequal-variance t-test}{unequal variance t-test}.\nThe issue of whether to use an equal-variance test or an unequal\nvariance test is one of the places where the approach taken in this\nbook rubs against conventional pedagogical practice.  \n\nThe term {\\bf equal variance} refers to an extension of the null\nhypothesis: rather than the null hypothesis being that the population\nmeans of the response variable are the same in the two groups, the\nnull is expanded to say also that the population variances are equal.\nThe named argument \\code{var.equal=TRUE} is what specifies this\nadditional assumption to the software.\n\nIf you suspend the assumption that the group variances are equal, the\nappropriate t-test test takes on another form, the \\newword{unequal\n  variance t-test}.  Here it is:\n\\begin{Schunk}\n\\begin{Sinput}\n> t.test( wage ~ sex, data=cps)\n\\end{Sinput}\n\\begin{Soutput}\n\tWelch Two Sample t-test\n\ndata:  wage by sex \nt = -4.89, df = 531, p-value = 1.369e-06\nalternative hypothesis: true difference in means is not equal to 0 \n95 percent confidence interval:\n -2.97 -1.27 \nsample estimates:\nmean in group F mean in group M \n           7.88            9.99 \n\\end{Soutput}\n\\end{Schunk}\nThe results of the unequal variance t-test are somewhat different from\nthose of \\ANOVA\\ or the equal variance t-test. To summarize these \ndifferences:\n\n\\bigskip\n\\centerline{\\begin{tabular}{lccc}\n & & equal var. & unequal var.  \\\\\n &  F-test & t-test & t-test \\\\\\hline\nD.F.& 532 & 532 & 530.5 \\\\\nt & & $-4.84$ & $-4.885$  \\\\\nt$^2$ or F & 23.4 & 23.4 & 23.86 \\\\\np-value & $1.7\\times10^{-6}$  & $1.7\\times10^{-6}$ & $1.369\\times10^{-6}$\\\\\n\\end{tabular}}\n\\bigskip\nThe values provided by the equal and unequal variance t-tests \nare different but very close.  \n\n\\index{C}{t-test!and adjustment}\n\\index{C}{adjustment!and t-test}\n\\index{C}{equal-variance t-test}\n\\index{C}{unequal variance t-test}\n\nWhich test to use?  Many people will argue that the unequal variance\nt-test is the appropriate test to use when you don't have a good\nreason to assume that the variances of the two groups are different.\nThis is reasonable enough if one is trying to choose between the\nequal-variance and the unequal-variance t-test.  But there is an\n``elephant in the room,'' an aspect of the situation that dominates\nthings but that, for some reason, people don't talk about.  This\nelephant is the covariates --- the other explanatory variables \nthat you should be adjusting for.  The t-test approach doesn't provide\nany capability for such adjustment.  Indeed, if you try to add another\nexplanatory variable to the t-test command, you get an error message:\n\\begin{Schunk}\n\\begin{Sinput}\n> t.test( wage ~ sex + educ, data=cps)\n\\end{Sinput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Soutput}\nError in t.test.formula(wage ~ sex + educ, data = cps) : \n  'formula' missing or incorrect\n\\end{Soutput}\n\\end{Schunk}\nThe same applies to trying to do a t-test with a quantitative\nexplanatory variable:\n\\begin{Schunk}\n\\begin{Sinput}\n> t.test( wage ~ educ, data=cps)\n\\end{Sinput}\n\\end{Schunk}\n\\begin{Schunk}\n\\begin{Soutput}\nError in t.test.formula(wage ~ educ, data = cps) : \n  grouping factor must have exactly 2 levels\n\\end{Soutput}\n\\end{Schunk}\n\n\\index{C}{ANOVA!covariates}\n\\index{C}{covariate!ANOVA}\n\nThe \\ANOVA\\ approach easily allows the addition of covariates to the\nmodel.  \n\nIf you find yourself in a situation where there are no covariates and\nyou are comparing two groups with potentially unequal variances, it\nmakes sense to use the unequal variance t-test.  I regard it as a\nspecial-purpose method that should be used only in such special\nsituations.  As it happens, the results you get with the\nequal-variance t-test and the unequal-variance t-test will be very\nclose ... unless the variances of the two groups are hugely different.\nAnd, if the variances are indeed so different, you should be asking\nyourself deeper questions, such as ``Why am I interested in the group\nmean in the first place?  Isn't the difference in variance telling me\nsomething, too?''\n\n\n\\subsubsection{The Grand Mean: the One-Sample t-test}\n\\index{C}{t-test!one-sample}\n\\index{C}{t-test!computing}\n\\index{C}{one-sample t-test}\n\nOccasionally, the question to be asked of a variable is very simple:\nIs there evidence that the overall mean is different from some specified\nvalue.  For example, suppose the government had published figures\nsaying that the mean wage was \\$9.25 per hour \nat the time the current population survey\ndata were collected.  You're interested to know whether the CPS data\nare consistent with this claim.  \n\nThe one-sample t-test is designed to deal with this situation.\n\\begin{Schunk}\n\\begin{Sinput}\n> t.test( cps$wage, mu=9.25)\n\\end{Sinput}\n\\begin{Soutput}\n\tOne Sample t-test\n\ndata:  cps$wage \nt = -1.02, df = 533, p-value = 0.3101\nalternative hypothesis: true mean is not equal to 9.25 \n95 percent confidence interval:\n 8.59 9.46 \nsample estimates:\nmean of x \n     9.02 \n\\end{Soutput}\n\\end{Schunk}\nThe named argument \\code{mu=9.25} specifies the population value of\nthe mean under the null hypothesis.  In this case, the p-value is\nlarge, $0.3101$, so there is no reason to reject the null hypothesis.\n\nThe one-sample t-test is equivalent to the F test applied to a model\nwhere the only explanatory model term is the intercept.  As always,\n$t^2 = F$, so the effective F value from the t-test is $-1.016^2 = 1.032$\n\\begin{Schunk}\n\\begin{Sinput}\n> mod4 = lm( wage - 9.25 ~ 1, data=cps)\n> anova(mod4)\n\\end{Sinput}\n\\begin{Soutput}\nAnalysis of Variance Table\n\nResponse: wage - 9.25\n           Df Sum Sq Mean Sq F value Pr(>F)\nResiduals 533  14077    26.4               \n\\end{Soutput}\n\\end{Schunk}\n> \nThe results are identical to the one-sample t-test. (There is no\nunequal-variance, one-sample t-test for the simple reason that in the\none-sample t-test there are no groups to have difference variances!)\n\nNotice that in forming the model, \nthe null hypothesis parameter, $9.25$ has been subtracted\nfrom the response variable in the modeling statement.  This is\nessential.  Otherwise, the test will be whether the sample mean is\nconsistent with a population value of zero.  Formally, that's a\npossible null hypothesis, but it makes no sense in this situation.\n\nOne important use for the one-sample t-test occurs in situations where \nmeasurements have been made in pairs, for example, before-and-after\nmeasurements.  When used this way, the one-sample t-test is called a\n\\newword{paired t-test}.  The idea is to test the difference within\neach pair to see if it is non-zero.  As you'll see in the next\nchapter, \\ANOVA\\ can also be configured to perform such paired tests\nand, in fact, is able to generalize them to multiple measurements and\nto adjust for covariates.\n\\index{C}{t-test!paired}\n\n\n", "meta": {"hexsha": "1749f244b77232fd930f66bf72e726a0a0310e85", "size": 10775, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ComputationalTechnique-Orig/Introduction/traditional-tests.tex", "max_stars_repo_name": "dtkaplan/SM3", "max_stars_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-01T01:28:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T01:28:07.000Z", "max_issues_repo_path": "ComputationalTechnique-Orig/Introduction/traditional-tests.tex", "max_issues_repo_name": "BriannaBarry/SM3", "max_issues_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ComputationalTechnique-Orig/Introduction/traditional-tests.tex", "max_forks_repo_name": "BriannaBarry/SM3", "max_forks_repo_head_hexsha": "56fef8d4368e7afa7ccce006d8f4acc6cf6c1fd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-02-14T05:22:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-08T12:42:15.000Z", "avg_line_length": 36.2794612795, "max_line_length": 78, "alphanum_fraction": 0.734199536, "num_tokens": 3045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.44966525699025583}}
{"text": "% !TeX root = ../Thermostats.tex\nAs mentioned earlier in section \\ref{cemd} we need an algorithm to artificially keep our system at a desired temperature. Such algorithms are usually called thermostats. Since the beginning of molecular dynamics simulations, various types of thermostats have been proposed. Many rely on random numbers and try to imitate the random collisions between particles of the system and the heat path, while others take on a more deterministic approach. In general, thermostats can be divided into four broad categories: \n\\begin{itemize}\n\\item \\textbf{Stochastic methods:} A system variable (temperature or velocity) is sampled from a desired probability distribution (e.g. Andersen)\n\\item \\textbf{Strong-coupling methods:} A system variable is constrained to the desired value (e.g. Gaussian) \n\\item \\textbf{Weak-coupling methods:} A system variable is driven towards the desired value (e.g. Berendsen) \n\\item \\textbf{Extended system dynamics:} Additional degrees of freedom are added to the system to get the desired phase space density (e.g. Nosé-Hoover) \n\\end{itemize}  \nIn this project we try to compare some of the most common thermostats, which will be described in detail in the following sections. \n\n\\subsection{Gaussian}\\label{th:gaussian}\nThis thermostat rescales the velocities of the particles to match the kinetic energy of the particles to the expected value $K_0$ (derived from the Boltzmann distribution at the desired temperature T). This is achieved by calculating the current kinetic energy $K$ of the system and rescaling the velocities $v$ according to the following formula:\n%: temperaturberechnung in unserer simulation irgendwo definieren und hier referenzieren.\n\\begin{equation}\nv'  = v\\cdot \\sqrt{\\frac{K_0}{K}}\\label{eq:gauss}\n\\end{equation}\nOne should note here that this approach produces a constant kinetic energy, and thus corresponds to an isokinetic rather than to a canonical ensemble. However, many properties of statistical systems become independent of the ensemble as $N$ goes to infinity, so the choice of ensemble becomes irrelevant.  \nFurthermore, the scaling leads to discontinuous velocities. A different formulation of this thermostat is based on the Gaussian principle of least constraint. Here, the equations of motion are altered by adding a friction term in order to keep the temperature fixed. The new equations of motion now have the following form:\n\\begin{align*}\n&  \\dot{q} = v && \\dot{v} = - \\frac{F}{m} - \\zeta v /numberthis \n\\end{align*}\nThe friction constant $\\zeta$ is determined via Lagrangian multipliers in such a way that the total kinetic energy is constant, i.e. \n\\begin{equation}\n\\sum_i \\frac{m_i v_i^2}{2} = \\frac{N_f k T}{2} \n\\end{equation}\nand \n\\begin{equation}\n\\sum_i m_i v_i \\dot{v}_i = 0 \n\\end{equation}\nwhich leads to \n\\begin{equation}\n\\zeta = \\frac{\\sum_i v_i F_i}{\\sum_i m_i v_i^2}\n\\end{equation}\nIn a simulation, this version of the Gaussian thermostat is easier implemented in conjunction with a leapfrog integration algorithm. Since the only difference between velocity verlet and leapfrog integration is the time at which the velocity is evaluated, we used this implementation for the Gaussian thermostat.    \n\\input{./sections/patrick.tex}\n\\subsection{Berendsen}\nThis thermostat proposed by Berendsen et al. \\cite{Berendsen1984} supplements the Hamiltonian of the system with an additional first order equation where the difference between the kinetic energy at a given time $K$ and its target value $K_0$ (modulo the change rate $\\tau$) drive the change in kinetic energy.\n\\begin{equation}\n{dK} = \\frac{(K_0-K)dt}{\\tau} \\label{eq:berendsen}%die formel sieht ziemlich blöd aus finde ich grad - hat jmd eine idee für eine bessere konvention bzgl wunsch und aktueller temperatur?\n\\end{equation}\nThe velocities are then scaled to fit these kinetic energies at every time step (as in \\eqref{eq:gauss}).\n\nOne drawback of this thermostat is that in general it does not sample from a well defined ensemble \\cite{Morishita2000}. Furthermore, it lacks a conserved quantity \\cite{Bussi2007} For these reasons, similar considerations as for the Gaussian thermostat (\\ref{th:gaussian}) apply.\n\\subsection{Bussi--Donadio--Parrinello}\nBussi et al.\\cite{Bussi2007} improved Berendsen's method by switching the target value from equation \\eqref{eq:gauss} to a changing, time dependent stochastic variable and adjusting the temperature over several time steps as Berendsen does (via eq. \\eqref{eq:berendsen}). \n\nTherefore the auxiliary dynamics can be expressed via the following formula:\n\\begin{equation}\ndK = (K_0- K) \\frac{dt}{\\tau} + \\underbrace{2\\sqrt{\\frac{K_0\\cdot K}{N_f}}\\frac{dW}{\\sqrt{\\tau}}}_{\\text{stochastic term}}\n\\end{equation}\nwhere $dW$ corresponds to a Wiener noise --- a random number drawn from a normal distribution with variance $\\sqrt{dt}$ --- and $N_f$ is the number of degrees of freedom. \nWithout the stochastic term the thermostat is equal to the Berendsen thermostat -- with very small $\\tau$ it's a stochastic Gaussian thermostat (sampling kinetic energies from the desired distribution and instantly rescaling velocities accordingly at every time step). For very large $\\tau$ the thermostat does not affect the system. If the system is far from equilibrium the `Berendsen- part' (deterministic part) dominates the behaviour and the system reaches equilibrium quickly. Upon reaching equilibrium it samples from the proper canonical ensemble with the desired fluctuations.\n\nFor this thermostat the choice of the stochastic term is somewhat arbitrary as it only influences the speed of equilibration. In our implementation we chose the term proposed in the paper \\cite{Bussi2007}.\n\\subsection{Nosé--Hoover}\nIn contrast to the previously introduced thermostats, which rely on stochastic changes of the velocities of the particles to control temperature, Nosé devised a deterministic thermostat by altering the Hamiltonian of the system ~\\cite{Nose2002}. His approach was then further improved by Hoover, who eliminated the need for time scaling ~\\cite{Hoover1985}. \nIn the original method proposed by Nosé an additional degree of freedom $s$ is introduced, which serves as a scaling factor for the velocities and can be thought of as the external heat bath of the system.\n\\begin{equation}\nv_i = s\\cdot \\dot{r_i}\n\\end{equation}  \nTwo additional terms associated with $s$ are added to the Hamiltonian of the system, which then reads as follows\n\\begin{equation}\n\\mathcal{H}_{Nose} = \\sum_i \\frac{p_i^2}{2m_i s^2} + \\phi (r) + \\frac{p_s^2}{2Q} + (N_f+1)kT\\ln(s) \n\\end{equation} \nwhere $\\phi(r)$ denotes the classical potential energy of the system, $N_f$ the degrees of freedom, $Q$ is a free choice of parameter corresponding to the time scale of the fluctuations in kinetic energy and $p_s = Q\\dot{s}$ is the conjugate momentum to $s$. The potential energy term $(N_f+1)kT\\ln{s}$ is chosen such that the right canonical ensemble distribution is obtained in a simulation and the kinetic energy term $\\frac{p_s}{2Q}$ is added to get a dynamic equation for the propagation of $s$.   \nThe equations of motion in the modified system can be obtained via the Hamiltonian equations\n\\begin{align*}\n        & \\dot{p} = - \\frac{\\partial \\mathcal{H}}{\\partial q} &&  \\dot{q} = \\frac{\\partial \\mathcal{H}}{\\partial p}\n        && \\dot{p_s} = - \\frac{\\partial \\mathcal{H}}{\\partial s} && \\dot{s} = \\frac{\\partial \\mathcal{H}}{\\partial p_s} \\numberthis \n\\end{align*}\n\nand thus read \n\n\\begin{align*}\n& \\dot{p} = F && \\dot{q} = \\frac{p}{m s^2} \\\\\n& \\dot{p_s} = \\sum_i \\frac{p_i^2}{m s^3} - (N_f+1)\\frac{kT}{s} &&  \\dot{s} = \\frac{p_s}{Q} \\numberthis \n\\end{align*}\n\n\nThese coupled equations can be simplified by reducing the time scale by $s$ - i.e. $dt_{old} = s dt_{new} $, which results in\n\n\n\\begin{align*}\n& \\dot{p} = s F && \\dot{q} = \\frac{p}{m s} \\\\\n& \\dot{p_s} = \\sum_i \\frac{p_i^2}{m s^2} - (N_f+1)\\cdot kT &&  \\dot{s} = \\frac{s p_s}{Q} \\numberthis \n\\end{align*}\n\n\nHoover was able to further simplify the approach by eliminating the variable $s$ and rewriting the equations in terms of $q$, $\\dot{q}$ and $\\ddot{q}$\n\n\\begin{equation}\n\\ddot{q} = \\frac{\\dot{p}}{m s} - \\frac{p}{m s^2}\\dot{s} = \\frac{F}{m} - \\frac{p_s}{Q}\\dot{q} \\equiv \\frac{F}{m} - \\zeta \\dot{q}\n\\end{equation} \n\nThe variable $\\zeta = \\frac{p_s}{Q}$ is introduced to highlight the analogy between this equation of motion and that of a Newtonian motion with a friction term. It evolves in time as\n\n\\begin{equation}\n\\dot{\\zeta} = \\left[\\sum_i m_i \\dot{q}^2_i - (N_f+1)kT\\right]/Q\n\\end{equation}\n\nSince the damping parameter $\\zeta$ is not determined instantaneously, as is the case with e.g. a Gaussian thermostat, but via an equation of motion, the Nosé-Hoover method describes an integral thermostat and therefore leads to both smooth as well as time-reversible and deterministic paths in phase space.  \n\n\\subsection{Nose-Hoover Chains} \\label{NHC}\nWhile the Nosé-Hoover thermostat generates the right canonical distributions for large, ergodic systems, it often fails if the system has more than one constant of motion - for example if the total momentum is conserved, as is the case for systems without external forces. This is due to the fact that the limiting distribution of the Nośe-Hoover thermostat has a gaussian dependence not only on the momenta $p_i$ but also on the conjugate momentum $p_s$ of the 'heat bath', but there is no driving force to ensure the correct fluctuations of $p_s$. Martyna and Klein proposed a method to solve this problem, now known as Nosé-Hoover chains \\cite{Martyna1992}. The idea is to thermostat $p_s$ as well as its thermostat, etc., forming a chain of thermostats, which can be extended to arbitrary length. For a total of $M$ thermostats, the extended equations of motions take the following form:\n\n\\begin{align*}\n& \\dot{q}_i = \\frac{p_i}{m_i} && \\dot{p}_i = F_i - p_i \\frac{p_{s_1}}{Q_1} \\\\\n& \\dot{s}_j = \\frac{p_{s_j}}{Q_j} \\\\\n& \\dot{p}_{s_1} = \\left[ \\sum_{i=1}^N \\frac{p^2_i}{m_i} - (N_f+1)kT\\right] - p_{s_1}\\frac{p_{s_2}}{Q_2} \\\\\n& \\dot{p}_{s_j} = \\left[ \\frac{p^2_{s_{j-1}}}{Q_{j-1}} - kT \\right] - p_{s_j}\\frac{p_{s_{j+1}}}{Q_{j+1}} \\\\\n& \\dot{p}_{s_M} = \\left[ \\frac{p^2_{s_{M-1}}}{Q_{M-1}} - kT\\right] \\numberthis\n\\end{align*}\n\nAs with the original Nosé-Hoover method, the 'masses' $Q_j$ of the thermostats determine the strength of the coupling between successive thermostats and have to be chosen carefully to get good results. However, the choice of mass gets less critical the more thermostats are used in the chain. If the system under investigation has a typical frequency $\\omega$, a good choice of masses is $Q_1 = \\frac{qkT}{\\omega}$ and $Q_j = \\frac{kT}{\\omega}$, which also gives the thermostats an average 'frequency' of $\\omega$ \\cite{Martyna1992}. \n\n\\subsubsection{A short note on the implementation of the Nosé-Hoover thermostats}\nIn the equations of motion of both the Nosé-Hoover thermostat as well as the Nosé-Hoover chains second derivatives of the position coordinates depend on the first derivative, which leads to a problem with the standard velocity-verlet integration scheme used with the other thermostats. One possibility to overcome this problem is the use of an iterative scheme - such as a predictor-corrector method. However, such an approach would lead to the loss of time-reversibility, which is one of the major advantages of the Nośe-Hoover thermostat. For this project we used the explicit time-reversible integrators developed by Martyna \\textit{et al.} via the Liouville formalism and a clever use of the Trotter formulas \\cite{Martyna1996}. For a detailed explanation as well as an example of how to implement this method for a chain of length two, we refer the reader to pages 535-540 of `Understanding Molecular Simulation' by Frenkel and Smit \\cite{FrenkelSmit2002}.   \n\n\n  \n\n", "meta": {"hexsha": "4271e98f4aafac57c0d7b125cc3b6676d41693a4", "size": 11836, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Protokolle/Thermostaten/sections/thermostats.tex", "max_stars_repo_name": "oerpli/ComputationalPhysics", "max_stars_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Protokolle/Thermostaten/sections/thermostats.tex", "max_issues_repo_name": "oerpli/ComputationalPhysics", "max_issues_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Protokolle/Thermostaten/sections/thermostats.tex", "max_forks_repo_name": "oerpli/ComputationalPhysics", "max_forks_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.0163934426, "max_line_length": 964, "alphanum_fraction": 0.7576884082, "num_tokens": 3237, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.44966525699025583}}
{"text": "\\chapter{Laplace Transforms}\r\n\\noindent\r\nLaplace transforms allow us to change differential equations into algebraic equations. We can then solve the algebraic equation and \"undo\" the Laplace transform to find the solution to our differential equation.\r\n\r\n% Definition\r\n\\input{./laplaceTransforms/definition/definition.tex}\r\n% Derivations\r\n\\input{./laplaceTransforms/derivations/derivations.tex}\r\n% Inverse Laplace\r\n\\input{./laplaceTransforms/inverseLaplace/inverseLaplace.tex}\r\n% Solving Differential Equations\r\n\\input{./laplaceTransforms/solvingEquations/solvingEquations.tex}", "meta": {"hexsha": "c8ad1a8f0b6509beb9c8c7b28ba4a81826631f30", "size": 578, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diffEq/laplaceTransforms/laplaceTransforms.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "diffEq/laplaceTransforms/laplaceTransforms.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "diffEq/laplaceTransforms/laplaceTransforms.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1666666667, "max_line_length": 212, "alphanum_fraction": 0.8200692042, "num_tokens": 142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6654105454764746, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4496608961228354}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath, amssymb, latexsym}\n\n\\usepackage{pgfplots}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{tikz}\n\\usepackage{nicefrac}\n\\usepackage{placeins}\n\\pgfplotsset{every axis legend/.append style={\nat={(0,0)},\nanchor=north east}}\n\\usetikzlibrary{shapes,positioning,intersections,quotes}\n\\usetikzlibrary{arrows.meta,\n                bending,\n                intersections,\n                quotes,\n                shapes.geometric}\n                \n\\definecolor{darkgreen}{rgb}{0.0, 0.6, 0.0}\n\\definecolor{darkred}{rgb}{0.7, 0.0, 0.0}\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\\title{Week 15}\n\\begin{document}\n\\pagenumbering{gobble}\n\\maketitle\n\\newpage\n\\pagenumbering{arabic}\n\n\\section*{Anomaly detection}\n\n\\begin{itemize}\n  \\item We can assess whether data points are anomalous by using the dataset as a baseline.\n  \\item if $p(x_{test}) < \\epsilon \\quad$, then flag this as an anomaly\n  \\item if $p(x_{test}) \\geq \\epsilon \\quad$, then this is OK\n  \\item $\\epsilon$ is a threshold probability number that we determine based on how certain we need/want to be.\n\\end{itemize}\n\n\\includegraphics[width=0.5\\textwidth]{resources/anomaly}\n\n\\section*{Applications}\n\\begin{itemize}\n  \\item Fraud detection\n\n        \\begin{itemize}\n          \\item Users have activities connected with them, such as the amount of time spent online, the location of login, and the frequency with which they spend money.\n          \\item Using this information, we can create a model of what regular users do.\n          \\item What is the probability of \"normal\" behavior?\n          \\item Send atypical users' data through the model to identify them. Make a note of everything that appears unusual. Block cards/transactions automatically.\n        \\end{itemize}\n\n  \\item Manufacturing\n\n        \\begin{itemize}\n          \\item Aircraft engine example.\n\n        \\end{itemize}\n\n  \\item Monitoring computers in data center\n\n        \\begin{itemize}\n          \\item If you have many machines in a cluster (x1 = memory use, x2 = number of disk accesses/sec, x3 = CPU load).\n          \\item When you notice an anomalous machine, it is likely that it is soon to fail.\n          \\item Consider replacing parts of it.\n        \\end{itemize}\n\\end{itemize}\n\n\\section*{The Gaussian distribution}\n\n\\begin{itemize}\n  \\item $\\mu$ is mean.\n  \\item $\\sigma^2$ is variance and $\\sigma$ is a standard deviation.\n  \\item probability of x, parameterized by the mean and variance:\n\\end{itemize}\n\n$$p(x; \\mu; \\sigma^2) = \\frac{1}{\\sqrt{2\\pi\\sigma}}exp(-\\frac{(x-\\mu)^2}{2\\sigma^2})$$\n\n~\\\\\n\n\\includegraphics[width=0.5\\textwidth]{resources/gaussian}\n\n\\begin{itemize}\n  \\item Assume we have a data collection of m examples.\n  \\item Given that each example is a real number, we plot the data on the x axis.\n  \\item Given the dataset can you estimate the distribution?\n\\end{itemize}\n\n\\includegraphics[width=0.6\\textwidth]{resources/data_fit}\n\nSeems like a good fit - data suggests a higher likelihood of being in the center and a lower likelihood of being further out.\n\n\\newpage\n\\section*{Anomaly detection}\n\n\\FloatBarrier\n\\begin{algorithm}\n\\caption{Anomaly detection}\\label{euclid}\n\\begin{algorithmic}[1]\n\\State Choose features $x_i$ that you think might be indicative of anomalous examples.\n\\State Fit parameters $\\mu_1, ..., \\mu_n, \\sigma_1^2, ..., \\sigma^n$\n\n$$\\mu_j = \\frac{1}{m} \\sum_{i=1}^mx_j^{(i)}$$\n$$\\sigma_j^2 = \\frac{1}{m} \\sum_{i=1}^m(x_j^{(i)}-\\mu_j)^2$$\n\n\\State Given new example x, compute p(x):\n\n$$p(x)= \\prod_{j=1}^n \\frac{1}{\\sqrt{2\\pi\\sigma_j}}exp(-\\frac{(x_j-\\mu_j)^2}{2\\sigma_j^2})$$\n\n\\end{algorithmic}\n\\end{algorithm}\n\\FloatBarrier\n\n\\section*{Developing and evaluating and anomaly detection system}\n\n\\begin{itemize}\n  \\item You have some labeled data.\n\n        \\begin{itemize}\n          \\item $y=0$ for engines which were non-anomalous.\n          \\item $y=1$ for engines which were anomalous.\n        \\end{itemize}\n\n  \\item Training set is the collection of normal examples.\n  \\item Next define:\n\n        \\begin{itemize}\n          \\item Cross validation set.\n          \\item Test set.\n          \\item For both assume you can include a few examples which have anomalous examples.\n        \\end{itemize}\n\n  \\item In our example we have:\n\n        \\begin{itemize}\n          \\item 10000 good engines.\n          \\item 50 flawed engines.\n        \\end{itemize}\n        \n  \\item Split into:\n\n        \\begin{itemize}\n          \\item Training set: 6000 good engines (y = 0).\n          \\item CV set: 2000 good engines, 10 anomalous.\n          \\item Test set: 2000 good engines, 10 anomalous.\n        \\end{itemize}\n        \n\\end{itemize}\n\n\n~\\\\\nWhat's a good metric to use for evaluation?\n\n\\begin{itemize}\n  \\item Compute fraction of true positives/false positive/false negative/true negative.\n  \\item Compute precision/recall.\n  \\item Compute F1-score.\n\\end{itemize}\n\n\\section*{Multivariate Gaussian distribution}\nIt is a somewhat different approach that can occasionally discover anomalies that normal Gaussian distribution anomaly detection fails to detect.\n\n\\begin{itemize}\n  \\item Assume you can fit a Gaussian distribution to CPU load and memory use.\n  \\item Assume we have an example in the test set that appears to be an anomaly (e.g. x1 = 0.4, x2 = 1.5).\n  \\item Here memory use is high and CPU load is low (if we plot x1 vs. x2 our green example looks miles away from the others).\n  \\item The problem is that if we look at each characteristic individually, they may fall inside acceptable bounds - the difficulty is that we know we shouldn't obtain those types of numbers together, but they're both okay individually.\n\\end{itemize}\n\n\\includegraphics[width=\\textwidth]{resources/mult_gauss}\n\n~\\\\\nWhat are the parameters for this new model?\n\\begin{itemize}\n  \\item $\\mu$ which is an n dimensional vector (where n is number of features)\n  \\item $\\Sigma$ which is an [n x n] matrix - the covariance matrix\n\\end{itemize}\n\n$$p(x; \\mu; \\Sigma) = \\frac{1}{(2\\pi)^{n/2}|\\Sigma|^{1/2}}exp(-\\frac{1}{2}(x-\\mu)^T \\Sigma^{-1}(x-\\mu))$$\n\n~\\\\\\\\\n\\includegraphics[width=\\textwidth]{resources/cov_matrix_sigma}\n\n~\\\\\nVery tall thin distribution, shows a strong positive correlation.\n\n\\subsection*{Gaussian model - summary}\n\n\\begin{itemize}\n  \\item Probably used more often.\n  \\item There is a need to manually create features to capture anomalies where x1 and x2 take unusual combinations of values.\n  \\item So need to make extra features and might not be obvious what they should be.\n  \\item Much cheaper computationally.\n  \\item Scales much better to very large feature vectors.\n  \\item Works well even with a small training set e.g. 50, 100.\n\\end{itemize}\n\n\n\\subsection*{Multivariate gaussian model - summary}\n\n\\begin{itemize}\n  \\item Used less frequently.\n  \\item Can capture feature correlation.\n  \\item So no need to create extra values.\n  \\item Less computationally efficient.\n  \\item Needs for m > n  i.e. number of examples must be greater than number of features.  \n\\end{itemize}\n\n\n\\end{document}", "meta": {"hexsha": "c791535e6704a4af7a98ba8b7a98c24de9a08709", "size": 7071, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/week_15.tex", "max_stars_repo_name": "djeada/Stanford-Machine-Learning", "max_stars_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/week_15.tex", "max_issues_repo_name": "djeada/Stanford-Machine-Learning", "max_issues_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/week_15.tex", "max_forks_repo_name": "djeada/Stanford-Machine-Learning", "max_forks_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1971830986, "max_line_length": 236, "alphanum_fraction": 0.7010323858, "num_tokens": 1951, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.449607293044002}}
{"text": "\\chapter{fMRI model estimation}\n\nModel parameters can be estimated using classical (ReML - Restricted Maximum Likelihood) or Bayesian algorithms. After parameter estimation, the RESULTS button can be used to specify contrasts that will produce Statistical Parametric Maps (SPMs), Effect Size Maps (ESMs) or Posterior Probability Maps (PPMs) and tables of statistics. \n\n\\section{Select SPM.mat}\n\nSelect the SPM.mat file that contains the design specification. SPM will output the results of its analysis into this directory. This includes overwriting the SPM.mat file. When the estimation job is run, no warning will be given that the SPM.mat file will be overwritten. A warning is given at the specification stage. When it comes to estimation, SPM assumes that you've now sorted out your directory structures.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=100mm]{fmri_est/est_method}\n\\end{center}\n\\caption{\\em After starting SPM in fMRI mode, pressing the `Estimate' button, and then double-clicking on the `+fMRI model estimation' text, the SPM graphics window should appear as above. The options under `-fMRI model estimation' can be examined by clicking on them. A single click will bring up some help text in the lower subwindow (not shown in the above graphic). A double-click on options prefixed by a '+' will allow you to specify options at a greater level of detail. Options highlighted with a `$<$-X' are mandatory and must be filled in by the user. Each of the options shown above is described in this chapter. \\label{est}}\n\\end{figure}\n\n\\section{Method}\n\nThere are three possible estimation procedures for fMRI models (1) classical (ReML) estimation of first or second level models, (2) Bayesian estimation of first level models and (3) Bayesian estimation of second level models. Option (2) uses a Variational Bayes (VB) algorithm that is new to SPM5. Option (3) uses the Empirical Bayes algorithm with global shrinkage priors that was also in SPM2. \n\nTo use option (3) you must have already estimated the model using option (1). That is, for second-level models you must run a ReML estimation before running a Bayesian estimation. This is not necessary for option (2). Bayesian estimation of 1st-level models using VB does not require a prior ReML estimation.\n\n\\subsection{Classical}\n\nModel parameters are estimated using Restricted Maximum Likelihood (ReML). This assumes the error correlation structure is the same at each voxel. This correlation can be specified using either an AR(1) or an Independent and Identically Distributed (IID) error model. These options are chosen at the model specification stage. ReML estimation should be applied to spatially smoothed functional images. See \\cite{peb1,peb2} for further details of the ReML estimation scheme. After estimation, specific profiles of parameters are tested using a linear compound or contrast with the T or F statistic. The resulting statistical map constitutes an SPM. The SPM{T}/{F} is then characterised in terms of focal or regional differences by assuming that (under the null hypothesis) the components of the SPM (ie. residual fields) behave as smooth stationary Gaussian fields.\n\nThe rest of this chapter describes the Bayesian estimation options. So, please skip to the next chapter if you are interested only in classical estimation and inference. \n\n\\subsection{Bayesian 1st-level}\n\nModel parameters are estimated using Variational Bayes (VB). This allows you to specify spatial priors for regression coefficients and regularised voxel-wise AR(P) models for fMRI noise processes. The algorithm does not require functional images to be spatially smoothed. Estimation will take about 5 times longer than with the classical approach. This is why VB is not the default estimation option. The VB approach has been described in a number of papers \\cite{vb_fmri_ar,vb2,vb3,will_bayes_srglm}.\n                                                          \nAfter estimation, contrasts are used to find regions with effects larger than a user-specified size eg. 1 per cent of the global mean signal. These effects are assessed statistically using a Posterior Probability Map (PPM) \\cite{karl_posterior}.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=100mm]{fmri_est/bayes_options}\n\\end{center}\n\\caption{\\em After choosing Bayesian 1st-level under `Method' and then double-clicking on the `+Bayesian 1st-level' text, the SPM graphics window should appear as above. Each of the options shown above is described in this chapter. \\label{bayes_options}}\n\\end{figure}\n\n\\subsubsection{Analysis Space}\n\nBecause estimation can be time consuming, an option is provided to analyse selected slices rather than the whole volume.\n\n\\paragraph{Volume}\n\nYou have selected the Volume option. SPM will analyse fMRI time series in all slices of each volume.\n\n\\paragraph{Slices}\n\nEnter Slice Numbers. This can be a single slice or multiple slices. If you select a single slice or only a few slices you must be aware of the interpolation options when, after estimation, displaying the estimated images eg. images of contrasts or AR maps. The default interpolation option may need to be changed to nearest neighbour (NN) (see bottom right hand of graphics window) for your slice maps to be visible.\n\n\\subsubsection{Signal priors}\n\n\\begin{itemize}\n\n\\item{[GMRF] Gaussian Markov Random Field. This spatial prior is the recommended option. Regression coefficients at a given voxel are (softly) constrained to be similar to those at nearby voxels. The strength of this constraint is determined by a spatial precision parameter that is estimated from the data. Different regression coefficients have different spatial precisions allowing each putative experimental effect to have its own spatial regularity. }\n\n\\item{[LORETA] Low Resolution Tomography Prior. This spatial prior is very similar to the GMRF prior and is a standard choice for MEG/EEG source localisation algorithms. It does, however, have undesirable edge effects.}                                                                                                    \n\n\\item{[Global] Global Shrinkage prior. This is not a spatial prior in the sense that regression coefficients are constrained to be similar to neighboring voxels. Instead, the average effect over all voxels (global effect) is assumed to be zero and all regression coefficients are shrunk towards this value in proportion to the prior precision. This is the same prior that is used for Bayesian estimation at the second level (see also \\cite{karl_posterior}), except that here the prior precision is estimated separately for each slice. }\n\n\\item{[Uninformative] A flat prior. Essentially, no prior information is used. If you select this option then VB reduces to Maximum Likelihood (ML) estimation. This option is useful if, for example, you do not wish to use a spatial prior but wish to take advantage of the voxel-wise AR(P) modelling of noise processes. In this case, you would apply the algorithm to images that have been spatially smoothed. For P=0, ML estimation in turn reduces to Ordinary Least Squares (OLS) estimates, and for P$>$0, ML estimation is equivalent to a weighted least squares (WLS) algorithm but where the weights are different at each voxel. This reflects the different noise correlations at each voxel. }\n\n\\end{itemize}\n\n\\subsubsection{AR model order}\n\nAn AR model order of 3 is the default. Cardiac and respiratory artifacts are periodic in nature and therefore require an AR order of at least 2. In previous work, voxel-wise selection of the optimal model order showed that a value of 3 was the highest order required \\cite{vb_fmri_ar}.\n\nHigher model orders have little effect on the estimation time. If you select a model order of zero this corresponds to the assumption that the errors are Independent and Identically Distributed (IID). This AR specification overrides any choices that were made in the model specification stage.\n\nVoxel-wise AR models are fitted separately for each session of data. For each session this therefore produces maps of AR(1), AR(2) etc coefficients in the output directory. \n\n\\subsubsection{Noise priors}\n\nThere are three noise prior options.\n\n\\begin{itemize}\n\n\\item{[GMRF] Gaussian Markov Random Field. This is the default option. This spatial prior is the same as that used for the regression coefficients. Spatial precisions are estimated separately for each AR coefficient eg. the AR(1) coefficient over space, AR(2) over space etc.}\n\n\\item{[LORETA] Low Resolution Tomography Prior. See comments on LORETA priors for regression coefficients.}\n\n\\item{[Tissue-type] This provides an estimation of AR coefficients at each voxel that are biased towards typical values for that tissue type (eg. gray, white, CSF). If you select this option you will need to then select files that contain tissue type maps (see below). These are typically chosen to be Grey Matter, White Matter and CSF images derived from segmentation of registered structural scans.}\n\n\\end{itemize}\n                                                                                                            \nPrevious work has shown that there is significant variation in AR values with tissue type. However, GMRF priors have previously been favoured by Bayesian model comparison \\cite{will_bayes_srglm}.\n\n\\subsubsection{ANOVA}\n\nPerform 1st or 2nd level Analysis of Variance.\n\n\\paragraph{First level}\n\nThis is implemented using Bayesian model comparison as described in \\cite{will_bayes_srglm}. For example, to test for the main effect of a factor two models are compared, one where the levels are represented using different regressors and one using the same regressor. This therefore requires explicit fitting of several models at each voxel and is computationally demanding (requiring several hours of computation). The recommended option is therefore NO.\n\nTo use this option you must have already specified your factorial design during the model specification stage. \n\n\\paragraph{Second level}\n\nThis option tells SPM to automatically generate the simple contrasts that are necessary to produce the contrast images for a second-level (between-subject) ANOVA. Naturally, these contrasts can also be used to characterise simple effects for each subject. \n\nWith the Bayesian estimation option it is recommended that contrasts are computed during the parameter estimation stage (see 'simple contrasts' below). The recommended option here is therefore YES.\n\nTo use this option you must have already specified your factorial design during the model specification stage. \n\nIf you wish to use these contrast images for a second-level analysis then you will need to spatially smooth them to take into account between-subject differences in functional anatomy ie. the fact that one persons V5 may be in a different position than anothers. \n\n\\subsubsection{Simple contrasts}\n\n`Simple' contrasts refers to a contrast that spans one-dimension ie. to assess an effect that is increasing or decreasing.\n\nIf you have a factorial design then the contrasts needed to generate the contrast images for a 2nd-level ANOVA (or to assess these simple effects within-subject) can be specified automatically using the ANOVA-$>$Second level option.\n\nWhen using the Bayesian estimation option it is computationally more efficient to compute the contrasts when the parameters are estimated. This is because estimated parameter vectors have potentially different posterior covariance matrices at different voxels and these matrices are not stored. If you compute contrasts post-hoc these matrices must be recomputed. This uses an approximate reconstruction based on a Taylor series expansion described in \\cite{vb3}. It is therefore recommended to specify as many contrasts as possible prior to parameter estimation.\n\nIf you wish to use these contrast images for a second-level analysis then you will need to spatially smooth them to take into account between-subject differences in functional anatomy ie. the fact that one persons V5 may be in a different position than anothers. \n\n\\paragraph{Simple contrast}\n\n\\subparagraph{Name}\n\nName of contrast eg. `Positive Effect'\n\n\\subparagraph{Contrast vector}\n\nThese contrasts are used to generate PPMs which characterise effect sizes at each voxel. This is different to SPMs in which eg. maps of t-statistics show the ratio of the effect size to effect variability (standard deviation). SPMs are therefore a-dimensional. This is not the case for PPMs as the size of the effect is of primary interest. Some care is therefore needed about the scaling of contrast vectors. For example, if you are interested in the differential effect size averaged over conditions then the contrast $[0.5, 0.5, -0.5, -0.5]$ would be more suitable than the $[1, 1, -1, -1]$ contrast which looks at the differential effect size summed over conditions. \n\n\\subsection{Bayesian 2nd-level}\n\nBayesian estimation of 2nd level models. This option uses the Empirical Bayes algorithm with global shrinkage priors that was previously implemented in SPM2. It is described in detail in \\cite{karl_posterior}.\n\nUse of the global shrinkage prior embodies a prior belief that, on average over all voxels, there is no net experimental effect. Some voxels will respond negatively and some positively with a variability determined by the prior precision. This prior precision can be estimated from the data using Empirical Bayes. \n\n\\section{Output files}\n\nAfter estimation a number of files are written to the output directory. These are\n\n\\begin{itemize}\n\\item{An \\verb!SPM.mat! file containing specification of the design and estimated model parameters}\n\\end{itemize}\n\n\\subsection{Classical 1st-level}\n\nFor classical 1st-level models the following files are also produced\n\n\\begin{itemize}\n\n\\item{Images of estimated regression coefficients  \\verb!beta_000k.img! where $k$ indexes the $k$th regression coefficient.}\n\n\\item{An image of the variance of the error \\verb!ResMS.img!.}\n\n\\item{An image \\verb!mask.img! indicating which voxels were included in the analysis.}\n\n\\item{The image \\verb!RPV.img!, the estimated resels per voxel.}\n\n\\item{If contrasts have been specified SPM also writes \\verb!con_000i.img!  if the $i$th contrast is a t-contrast and the extra sum of squares image \\verb!ess_000i.img! if it is an F-contrast.} \n\n\\end{itemize}\n\nType \\verb!help spm_spm! at the matlab command prompt for further information.\n\n\\subsection{Bayesian 1st-level}\n\nFor Bayesian 1st-level models the following files are also produced\n\n\\begin{itemize}\n\n\\item{Images of estimated regression coefficients  \\verb!Cbeta_000k.img! where $k$ indexes the $k$th regression coefficient. These filenames are prefixed with a `C' indicating that these are the mean values of the `Conditional' or `Posterior' density.}\n\n\\item{Images of error bars/standard deviations on the regression coefficients \\verb!SDbeta_000k.img!.}\n\n\\item{An image of the standard deviation of the error \\verb!Sess1_SDerror.img!.}\n\n\\item{An image \\verb!mask.img! indicating which voxels were included in the analysis.}\n\n\\item{If a non-zero AR model order is specified then SPM also writes images \\verb!Sess1_AR_000p.img! where $p$ indexes the $p$th AR coefficient.}\n\n\\item{If contrasts have been specified SPM also writes \\verb!con_000i.img! and \\verb!con_sd_000i.img! which are the mean and standard deviation of the $i$th pre-defined contrast.} \n\n\\end{itemize}\n\nEach of these images can be inspected using the `Display' button. Type \\verb!help spm_spm_vb! at the matlab command prompt for further information.\n\n\\section{Model comparison}\n\nOnce you have estimated a model you can use SPM's results button to look at the results. You can also extract fMRI data from regions of interest using the ROI button. You can then compare GLMs based on different hemodynamic basis sets using the Bayesian model evidence. \n\nThis is described in \\cite{will_bayes_srglm} and implemented using the command line option `spm\\_vb\\_roi\\_basis'. This requires a VOI filename (created using the ROI button) and an SPM data structure. Type `help spm\\_vb\\_roi\\_basis' at the matlab command prompt for further information. Figure~\\ref{basis} shows an example output from the function indicating that, for the data in this brain region, an informed basis set has the highest model evidence.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=150mm]{fmri_est/basis}\n\\end{center}\n\\caption{\\em This plot shows the model evidence for a number of different hemodynamic basis sets: Inf1 - Canonical HRF, Inf2 - Canonical plus temporal derivative, Inf3 - Canonical plus temporal and dispersion derivatives, F - Fourier, FH - Fourier with a Hanning Window, Gamm3 - 3 Gamma basis functions and FIR - a Finite Impulse Response function. An informed basis set provides the best model of the data for the selected region.  \\label{basis}}\n\\end{figure}\n", "meta": {"hexsha": "e14dd87070379c889a240ec1f6ac953dafbbbba4", "size": 16866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/spm5/man/fmri_est/fmri_est.tex", "max_stars_repo_name": "awangga/braindecoding", "max_stars_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/spm5/man/fmri_est/fmri_est.tex", "max_issues_repo_name": "awangga/braindecoding", "max_issues_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-10-13T13:34:45.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-13T14:23:51.000Z", "max_forks_repo_path": "lib/BDTB-1.2.2/open/spm5/man/fmri_est/fmri_est.tex", "max_forks_repo_name": "awangga/braindecoding", "max_forks_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.7537688442, "max_line_length": 864, "alphanum_fraction": 0.7879165184, "num_tokens": 3663, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4496068067424565}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{pgfplots}\n\\usepackage{fancyhdr}\n\\usepackage{enumitem}\n\\usepackage{tikz}\n\\usepackage{xparse}\n\\usepackage{siunitx}\n\n\\pgfplotsset{width=10cm,compat=1.9}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\lhead{Steven Glasford}\n\\chead{Homework 1.4}\n\\rhead{Page \\thepage}\n\n\\title{Homework 1.4}\n\\author{Steven Glasford}\n\\date{\\parbox{\\linewidth}{\\centering%\n    \\today\\endgraf\\medskip\n    Math-451-M001}}\n\\newcommand{\\rpm}{\\sbox0{$1$}\\sbox2{$\\scriptstyle\\pm$}\n  \\raise\\dimexpr(\\ht0-\\ht2)/2\\relax\\box2 }\n  \n\\newlist{steps}{enumerate}{1}\n\\setlist[steps, 1]{label = Step \\arabic*:}\n\\ExplSyntaxOn\n\\newcommand*{\\prlen}[1]{%\n   % round to 1 digit:\n    \\pgfmathparse{round(10)/10.0}%\n    %\\pgfkeys{/pgf/number format/precision=1}\n    %\\pgfmathresult\n    \\pgfmathprintnumber[fixed, precision=2]{\\pgfmathresult}\n}\n\\ExplSyntaxOff\n\n\n\\begin{document}\n\n\\maketitle\n\nI choose to do problems 3 and 9 from the options of 3, 4, 5 and 9.\n\n\\section{Problem 3}\n\n\\begin{enumerate}[label=\\alph*]\n    \\item \n    \\begin{tikzpicture}\n        \\begin{axis}[\n            axis lines = left,\n            xlabel = Time in $t$ day,\n            ylabel = Price per pig $P(t)$,\n        ]\n        \\addplot [\n            domain=0:15,\n            samples=100,\n            color=red,\n        ]{.65 - .01*x + .00004*x^2};\n        \\addlegendentry{New: $.65-.01t+.00004t^2$}\n        \n        \\addplot[\n            domain=0:15,\n            samples=100,\n            color=blue,\n        ]{.65-.01*x};\n        \\addlegendentry{Old: $.65-.01*x$}\n        \n        \\end{axis}\n    \\end{tikzpicture}\n    The graph above shows the price per pig using both the old linear model (blue) and the newer model (the red line). The red line is more accurate to the actual price per pig in real life. But as is obvious in the graph the values for the old equation are very similar to the more accurate model within the appropriate time domain.\n    \\item\n        \\begin{center}\n            \\begin{tabular}{ |c|c|c| } \n            \\hline \n            Variables & Constants & Assumptions \\\\\n            \\hline\n            $t$ - Time (Days) & $w_0 = 200$ initial weight (pounds) & $w=w_0+5t$ \\\\\n            $f$ - profit (in dollars) &  & $p=.65-.01t+.00004t^2$ \\\\ \n            $w$ - Weight (pounds) && $c=.45t$ \\\\ \n            $p$ - Price per pound && $r=p*w$\\\\\n            $c$ - cost (in dollars) && $f=r-c$\\\\\n            $r$ - Revenue (in dollars) &&\\\\\n            \\hline\n            \\end{tabular}\n        \\end{center}\n        If we want to maximize $f(t)$ then we should try to add all of the assumptions into a single equation, this way all of the assumptions are considered. We will try to use $t$ as the isolating factor. If $$f=r-c$$ \\parbox{\\linewidth}{\\centering% \n            $r=pw$ \\hspace*{3cm} $c=.45t$ \\endgraf \\bigskip \n            $f=pw-.45t$ \\endgraf\\bigskip\n            $p=.65-.01t$ \\hspace*{3cm}\n            $w=w_0+5*t$ \\endgraf \\bigskip\n            $f=(.65-.01t+.00004t^2)(w_0+5t)-.45t$ \\endgraf\\bigskip\n            $w_0=200$ \\endgraf \\bigskip\n            $f=(.65-.01t+.00004t^2)(200+5t)-.45t$ \\endgraf\\bigskip\n        } \n        Which simplifies to:$$f(t)=.0002t^3-.042t^2+.8t+130$$\n        Now we need to take the derivative of $f(t)$ and find where it is equal to zero. $$\\frac{df}{dt}=\\frac{3t^2}{5000}-\\frac{21t}{250}+\\frac{4}{5}$$\n        \n        \\begin{tikzpicture}\n        \\begin{axis}[\n            axis lines = left,\n            xlabel = Time in $t$ day,\n            ylabel = $y$,\n        ]\n        \n        \\addplot[\n            domain=0:20,\n            samples=100,\n            color=blue,\n        ]{(3*x^2-420*x+4000)/5000};\n        \\addlegendentry{$\\frac{df}{dt}$}\n        \\draw[ultra thin] (axis cs:\\pgfkeysvalueof{/pgfplots/xmin},0) -- (axis cs:\\pgfkeysvalueof{/pgfplots/xmax},0);\n        \\end{axis}\n        \n    \\end{tikzpicture}\n    \\endgraf\n    Using the quadratic equation we try to determine the extreme somewhere between 8 and 14, as that point will be a maximum, this is known since the derivative is a quadratic and that point the derivative goes from positive to negative, indicating a maxima. The other root would in turn be a minima.\n    $$\\frac{df}{dt}=0=\\frac{3t^2-420t+4000}{5000}$$ $$t=\\frac{10(21+\\sqrt{321})}{3},\\frac{10(21-\\sqrt{321})}{3}$$\n    $$t \\approx \\pgfmathparse{(10*(21+321^(1/2)))/3}\\pgfmathresult , \\pgfmathparse{(10*(21-321^(1/2)))/3}\\pgfmathresult $$\n    \\textbf{Therefore, the best day to sell your pig is at about 10 days.}\n    \n    \\item \\underline{Sensitivity analysis}\n    \\endgraf\n    $$p(t)=.65-.01t+.00004t^2$$\n    $$f(t)=.0002t^3-.042t^2+.8t+130$$\n    $$y=(.65-.01x+xt^2)(200+5x)-.45x$$\n    $$y=5rx^3-.05x^2+200rx^2+.8x+130=0$$\n    $$\\frac{dy}{dx}=15rx^2+400rx-\\frac{x}{10}+\\frac{4}{5}=0$$\n    $$x=\\frac{-4000r+1+ 10\\sqrt{160000r^2-128r+1/100}}{300r}$$\n    $$\\frac{dx}{dr}=\\frac{-6400r+1+ \\sqrt{16000000r^2-12800r+1}}{300r^2\\sqrt{16000000r^2-12800r+1}}$$\n    \\begin{center}\n            \\begin{tabular}{ |c|c|c| } \n            \\hline \n            r & x & $\\frac{\\Delta x}{\\Delta r} * 100$ \\\\\n            \\hline\n            .00002 & 297.709385518&\n            %\\pgfkeys{/pgf/fpu} \\pgfmathparse{}\\pgfmathresult\n            %\\edef\\tmp{\\pgfmathresult}\n            %\\pgfmathresult\n            %\\pgfkeys{/pgf/fpu=false} &\n            %1/(-6400*.00004+1+sqrt(16000000*.00004^2-128*.00004+1))/(300*.00004^2*sqrt(16000000*.00004^2-12800*.00004+1))\n            %(-6400*r+1+\\sqrt{16000000*r^2-128*r+1})/(300*r^2*\\sqrt{16000000*r^2-12800r+1})\n             \n            \\\\\n            .00003 & 185.997481072  & -1117119044.46\n            %\\pgfmathparse{((-4000*.00003+1+10*(160000*.00003^2-128*.00003+1/100)^(1/2))/(300*.00003)-(-4000*.00002+1+10*(160000*.00002^2-128*.00002+1/100)^(1/2))/(300*.00002))/(.00003-.00002)*100}\\pgfmathresult &\n            \\\\\n            .00004 &129.721576224&-562759048.485\n           % \\pgfmathparse{(-4000*.00004+1+10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004)}\\pgfmathresult &\n           % \\pgfmathparse{(-4000*.00004+1-10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004)}\\pgfmathresult &\n           % \\pgfmathparse{((-4000*.00004+1+10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004)-(-4000*.00003+1+10*(160000*.00003^2-128*.00003+1/100)^(1/2))/(300*.00003))/(.00004-.00003)*100}\\pgfmathresult &\n           % \\pgfmathparse{((-4000*.00004+1-10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004)-(-4000*.00003+1-10*(160000*.00003^2-128*.00003+1/100)^(1/2))/(300*.00003))/(.00004-.00003)*100}\\pgfmathresult\n            \\\\\n            .00005 & 95.4970354689 &-342245407.55\n            %\\pgfmathparse{(-4000*.00005+1+10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005)}\\pgfmathresult &\n           % \\pgfmathparse{(-4000*.00005+1-10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005)}\\pgfmathresult &\n           % \\pgfmathparse{((-4000*.00005+1+10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005)-(-4000*.00004+1+10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004))/(.00005-.00004)*100}\\pgfmathresult&\n           % \\pgfmathparse{((-4000*.00005+1-10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005)-(-4000*.00004+1-10*(160000*.00004^2-128*.00004+1/100)^(1/2))/(300*.00004))/(.00005-.00004)*100}\\pgfmathresult\n            \\\\\n            .00006 &72.1191645491&-233778709.199\n            %\\pgfmathparse{(-4000*.00006+1+10*(160000*.00006^2-128*.00006+1/100)^(1/2))/(300*.00006)}\\pgfmathresult &\n           % \\pgfmathparse{(-4000*.00006+1-10*(160000*.00006^2-128*.00006+1/100)^(1/2))/(300*.00006)}\\pgfmathresult &\n           % \\pgfmathparse{((-4000*.00006+1+10*(160000*.00006^2-128*.00006+1/100)^(1/2))/(300*.00006)-(-4000*.00005+1+10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005))/(.00006-.00005)*100}\\pgfmathresult&\n           % \\pgfmathparse{((-4000*.00006+1-10*(160000*.00006^2-128*.00006+1/100)^(1/2))/(300*.00006)-(-4000*.00005+1-10*(160000*.00005^2-128*.00005+1/100)^(1/2))/(300*.00005))/(.00006-.00005)*100}\\pgfmathresult\n            \\\\\n            \\hline\n            \\end{tabular} \n    \\end{center}\n    \\textbf{Therefore the best sort of sensitivity is somewhere between .00004 and .00005}\n    \n    \n    %% \\pgfmathparse{(10*(21-321^(1/2)))/3}\\pgfmathresult\n    \\item The robustness is fairly good since the values obtained from both the linear and the quadratic models are roughly similar.\n    \n\\end{enumerate}\n\n\\section{Problem 9}\n\n\\begin{enumerate}[label=\\alph*]\n    \\endgraf\n    \\item\\endgraf\\bigskip\n\n    \n        \\begin{steps}\n            \\endgraf\n            \\item \\emph{Ask the Question, determine variables, constants, assumptions}\\endgraf\n            \\begin{center}\n                \\begin{tabular}{ |c|c|c|c| } \n                \\hline \n                Variables & Constants & Assumptions \\\\\n                \\hline\n                $s$ - Subscribers & $i_0 = 1.50$ & $f=sp$\\\\\n                $p$ - Subscription price & $s_0=80000$&$s=s_0-50000(p-p_0)$\\\\\n                $f$ - Profits &&$p\\geq0$\\\\\n                && $s\\geq0$\\\\\n                \n            \\hline\n            \\end{tabular}\n        \\end{center}\n            \\item \\emph{Select the model}\\endgraf\n            One-variable optimization\n            \\item \\emph{Formulate the model} \\endgraf\n            $$f=sp$$\n            $$s=s_0-50000(p-p_0)$$\n            $$f=p(s_0-50000(p-p_0))$$\n            \\parbox{\\linewidth}{\\centering% \n            $s_0=80000$ \\hspace*{3cm} $p_0=1.50$ \\endgraf \\bigskip\n            }\n            $$f=p(80000-50000(p-1.5))$$\n            or simplified\n            $$f=-50000p^2+155000p$$\n            \\item \\emph{Solve the model}\\endgraf\n            Find the extrema for f:\n            $$\\frac{df}{dp}=0=-100000p+155000$$\n            $$p=1.55$$\n            Determine if 1.55 is a max or min:\n            \\begin{tikzpicture}\n                \\begin{axis}[\n                axis lines = left,\n                xlabel = Price per paper,\n            ]\n            \\addplot [\n                domain=0:2,\n                samples=100,\n                color=red,\n            ]{-100000*x+155000};\n            \\addlegendentry{$\\frac{df}{dp}$}\n            \\draw[ultra thin] (axis cs:\\pgfkeysvalueof{/pgfplots/xmin},0) -- (axis cs:\\pgfkeysvalueof{/pgfplots/xmax},0);\n        \\end{axis}\n    \\end{tikzpicture}\n        Since the derivative of $f$ is going from positive to negative at the point 1.55, \\textbf{$p=1.55$ is a Maximum.}\\bigskip\n            \\item \\emph{Answer the question}\\endgraf\n            The best price to sell the newspaper is \\$1.55 for a total of \\$$120125$ per week, and a total of $77500$ subscribers.\n        \\end{steps}\n    \n    %% \\pgfmathparse{(10*(21-321^(1/2)))/3}\\pgfmathresult\n    \n    \\item \\endgraf \\bigskip\n        \\emph{What if the newspaper lost a different number of subscribers, other than 5000?}\n        $$f=p(80000-r*10(p-1.5))$$\n        $$\\frac{df}{dp}=0=-20rp+15r+80000$$\n        $$p=\\frac{80000+15r}{20r}$$\n        replace $p$ in the $f$ equation:\n        $$f=\\frac{80000+15r}{20r}\\left(80000-10r\\left(\\frac{80000+15r}{20r}-1.5\\right)\\right)$$\n        Which doesn't really simplify down to anything worth mentioning.\n        \\begin{center}\n                \\begin{tabular}{ |c|c| } \n                \\hline \n                Lost Subscribers ($r$) & Max Profit \\\\\n                \\hline\n                3000 &\\$130208.33\\\\\n                4000 &\\$122500.00\\\\\n                5000 &\\$120125.00\\\\\n                6000 &\\$120416.67\\\\\n                7000 &\\$122232.14\\\\\n                \n                \n            \\hline\n        \\end{tabular}\n    \\end{center}\n    \\item\n    $$f=\\frac{80000+15r}{20r}\\left(80000-10r\\left(\\frac{80000+15r}{20r}-1.5\\right)\\right)$$\n    $$\\frac{df}{dr}=\\frac{45r^2-1280000000}{8r^2}$$\n    Sensitivity=$\\frac{df}{dr}*\\frac{r}{x}=S(p,n)$\n    $$S(p,n)=\\frac{45n^2-1280000000}{8n^2}\\left(n/\\left(\\left(\\frac{80000+15n}{20n}\\left(80000-10n\\left(\\frac{80000+15n}{20n}-1.5\\right)\\right)\\right)\\right)\\right)$$\n    \\item \\emph{The Newspaper shouldn't need to change its prices.} The price is already near the optimal rate, but the optimal rate is just \\$125 more than the basic, which is basically nothing when considering the amount of profit they received.\n    \n\\end{enumerate}\n\n\n\\end{document}", "meta": {"hexsha": "80f797446ddced39132c651dc8e8917c7d5a26be", "size": 12160, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW1.tex", "max_stars_repo_name": "stevenglasford/MATH451SDSMT", "max_stars_repo_head_hexsha": "c0fa475cb08a40debda6c106e8ddf8b44dab1060", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW1.tex", "max_issues_repo_name": "stevenglasford/MATH451SDSMT", "max_issues_repo_head_hexsha": "c0fa475cb08a40debda6c106e8ddf8b44dab1060", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW1.tex", "max_forks_repo_name": "stevenglasford/MATH451SDSMT", "max_forks_repo_head_hexsha": "c0fa475cb08a40debda6c106e8ddf8b44dab1060", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8708487085, "max_line_length": 333, "alphanum_fraction": 0.5592927632, "num_tokens": 4349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.44960680280017384}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage{amsmath, amssymb}\n\\usepackage{circuitikz}\n\\usepackage{csvsimple}\n\\usepackage{pgfplots}\n\\usepackage{siunitx}\n\n\\title{Analyzing Circuit Resistance with Various Lengths of Nichrome Wire}\n\\date{1 December 2014}\n\\author{Tarik Onalan}\n\n\\def\\mean#1{\\left< #1 \\right>}\n\\def\\abs#1{\\left| #1 \\right|}\n\\numberwithin{equation}{subsection}\n\n\\begin{filecontents}{data.dat}\n    Len  Len_Inv T_1   T_2   T_3   T_4   T_5   Avg   Err   Len_Err\n    12.2 0.0820  0.620 0.621 0.619 0.622 0.622 0.621 0.002 0.05\n    18.6 0.0538  0.406 0.430 0.423 0.422 0.423 0.421 0.017 0.05\n    31.6 0.0316  0.232 0.231 0.229 0.234 0.233 0.232 0.003 0.05\n    42.8 0.0234  0.210 0.208 0.206 0.206 0.208 0.208 0.002 0.05\n    48.6 0.0206  0.182 0.181 0.180 0.179 0.181 0.181 0.002 0.05\n\\end{filecontents}\n\n\\begin{document}\n    \\maketitle\n    \\section{Introduction}\n        \\textbf{How does the length of nichrome wire in a circuit affect the current\n        of the circuit?}\\\\\n        The goal of this lab was to analyze how varying lengths of a resistor, nichrome\n        wire, affected current flow in a circuit. My hypothesis is that as resistor\n        length increases, current flow within the circuit will decrease, as the more\n        resistance there is in a circuit, the lower the current will be. For the experiment,\n        increasing lengths of nichrome wire will be inserted into a circuit; if the\n        current in the circuit decreases as the length of the nichrome wire increases,\n        my hypothesis will be validated. The manipulated and responding variables are\n        the length of the nichrome wire and the current through the circuit, respectively.\n        The controlled variables are the battery used (for power level), the voltage of\n        the battery, the length of the low-resistance wire, the ammeter used, and the\n        sensitivity setting used on the ammeter.\n\n    \\section{Materials}\n        \\begin{itemize}\n            \\item 1 Ammeter\n            \\item 1 Battery\n            \\item 1 Section of Low-Resistance Wire\n            \\item 5 Sections of Nichrome Wire (Varying lengths)\n        \\end{itemize}\n\n    \\section{Procedure}\n        \\begin{enumerate}\n            \\item Set up ammeter with battery and low-resistance wire:\n            \\begin{itemize}\n                \\item Positive terminal of battery connected to positive terminal\n                    of ammeter\n                \\item Negative terminal of battery connected to negative terminal\n                    of ammeter\n                \\item Low-resistance wire attached to one of two terminals, other\n                    terminal reserved for nichrome wire\n                \\begin{itemize}\n                    \\item Note: Use \\SI{1}{\\A} sensitivity instead of \\SI{5}{\\A}\n                        sensitivity\n                \\end{itemize}\n            \\end{itemize}\n            \\item Attach ends of nichrome wire to open terminals of battery and ammeter\n            \\begin{itemize}\n                \\item For simplicity, start with the shortest length of nichrome wire\n            \\end{itemize}\n            \\item Record amperage shown on ammeter\n            \\item Repeat steps 2-3 as necessary for data averaging\n            \\item Repeat steps 2-4 with increasing nichrome wire lengths\n        \\end{enumerate}\n\n    \\section{Diagram}\n        \\begin{circuitikz}\n            \\draw\n                (0,0) to [battery]  (0,4)\n                      to [ammeter]  (4,4) -- (4,0)\n                      to [vR] (0,0)\n                ;\n        \\end{circuitikz}\n\n    \\section{Data}\n        \\begin{tabular}{|c|||c|c|c|c|c||c|}\n            \\hline\n            \\bfseries Length & \\bfseries Trial 1 & \\bfseries Trial 2 & \\bfseries Trial 3 & \\bfseries Trial 4 & \\bfseries Trial 5 & \\bfseries Average\n            \\\\\\hline\n            \\SI{12.2}{\\cm} & \\SI{0.620}{\\A} & \\SI{0.621}{\\A} & \\SI{0.619}{\\A} & \\SI{0.622}{\\A} & \\SI{0.622}{\\A} & \\SI{0.621}{\\A}\n            \\\\\\hline\n            \\SI{18.6}{\\cm} & \\SI{0.406}{\\A} & \\SI{0.430}{\\A} & \\SI{0.423}{\\A} & \\SI{0.422}{\\A} & \\SI{0.423}{\\A} & \\SI{0.421}{\\A}\n            \\\\\\hline\n            \\SI{31.6}{\\cm} & \\SI{0.232}{\\A} & \\SI{0.231}{\\A} & \\SI{0.229}{\\A} & \\SI{0.234}{\\A} & \\SI{0.233}{\\A} & \\SI{0.232}{\\A}\n            \\\\\\hline\n            \\SI{42.8}{\\cm} & \\SI{0.210}{\\A} & \\SI{0.208}{\\A} & \\SI{0.206}{\\A} & \\SI{0.206}{\\A} & \\SI{0.208}{\\A} & \\SI{0.208}{\\A}\n            \\\\\\hline\n            \\SI{48.6}{\\cm} & \\SI{0.182}{\\A} & \\SI{0.181}{\\A} & \\SI{0.180}{\\A} & \\SI{0.179}{\\A} & \\SI{0.181}{\\A} & \\SI{0.181}{\\A}\n            \\\\\\hline\n        \\end{tabular}\n        \\\\\n        \\begin{tabular}{|c|c|}\n            \\hline\n            \\bfseries Length Error & \\bfseries Amperage Error\n            \\\\\\hline\n            0.05 & 0.002\n            \\\\\\hline\n            --- & 0.017\n            \\\\\\hline\n            --- & 0.003\n            \\\\\\hline\n            --- & 0.002\n            \\\\\\hline\n            --- & 0.002\n            \\\\\\hline\n        \\end{tabular}\n        \\\\\n        \\begin{tikzpicture}[trim axis left, trim axis right]\n            \\begin{axis}[\n                scale=1.75,\n                title={Current Relative to Resistor Length},\n                xlabel={Length [\\si{\\cm}]},\n                ylabel={Current [\\si{\\A}]},\n                xmin=0.0, xmax=50.0,\n                ymin=0.0, ymax=0.7,\n                legend pos=north east,\n                ymajorgrids=true,\n                grid style=dashed\n            ]\n                \\addplot[\n                    color=blue,\n                    mark=*,\n                    only marks\n                ] plot [\n                    error bars/.cd,\n                        x dir=both,\n                        y dir=both,\n                        x explicit,\n                        y explicit\n                ] table [\n                    x=Len,\n                    y=Avg,\n                    x error=Len_Err,\n                    y error=Err\n                ]{data.dat};\n\n                \\addplot[\n                    color=red,\n                    mark=none,\n                    domain=0:50\n                ]{6.28197/x^0.926264};\n\n                \\addlegendentry{Average}\n                \\addlegendentry{\\(6.28197x^{-0.926264}\\)}\n            \\end{axis}\n        \\end{tikzpicture}\n        \\\\\n        \\begin{tikzpicture}\n            \\begin{axis}[\n                scale=1.75,\n                title={Current Relative to Inverse of Resistor Length},\n                xlabel={\\(\\frac{1}{Length [\\si{\\cm}]}\\)},\n                ylabel={Current [\\si{\\A}]},\n                xmin=0.0, xmax=0.1,\n                ymin=0.0, ymax=0.7,\n                x dir=reverse,\n                legend pos=north east,\n                ymajorgrids=true,\n                grid style=dashed\n            ]\n                \\addplot[\n                    color=blue,\n                    mark=*,\n                    only marks\n                ] plot [\n                    error bars/.cd,\n                    x dir=both,\n                    y dir=both,\n                    x explicit,\n                    y explicit\n                ] table [\n                    x=Len_Inv,\n                    y=Avg,\n                    y error=Err\n                ]{data.dat};\n\n                \\addplot[\n                    color=red,\n                    mark=none,\n                    domain=0:0.1\n                ]{7.2379*x+0.0265815};\n\n                \\addlegendentry{Average}\n                \\addlegendentry{\\(7.2379x+0.0265815\\)}\n            \\end{axis}\n        \\end{tikzpicture}\n\n        \\section{Calculations}\n            \\centerline{For below calculations, \\(t_{i}=t_{1}\\)}\n            \\subsection{Average}\n                \\begin{equation} \\label{eq:avg}\n                    t_{avg}=\\mean{t_{i}}\n                \\end{equation}\n                \\centerline{where \\(t_{i}\\) is the set of results for wire \\(i\\).\n                Therefore,}\n                \\begin{equation}\n                    t_{avg}=\\mean{[0.620,0.621,0.619,0.622,0.622]}=0.621\n                \\end{equation}\n\n            \\subsection{Error}\n                \\begin{equation} \\label{eq:err}\n                    t_{err}=\\pm\\abs{t_{avg}-t_{E}}\n                \\end{equation}\n                \\centerline{where \\(t_{E}\\) is the element of set \\(t_{i}\\) with\n                the highest deviation from \\(t_{avg}\\). Therefore,}\n                \\begin{equation}\n                    t_{err}=0.621-0.619=\\pm0.002\n                \\end{equation}\n\n        \\section{Conclusion}\n            It can be observed through the data that the current through the example\n            circuit decreased as the length of the nichrome wire increased. When\n            the nichrome wire was \\SI{12.2}{\\cm} long, the average current was\n            \\SI{0.621}{\\A}. However, when the length increased to \\SI{18.6}{\\cm},\n            the current decreased to \\SI{0.421}{\\A} This was to be expected, as we\n            observed through tests with bulbs that as bulbs were added to the circuit,\n            resistance increased, lowering the current of the circuit. In this case,\n            however, bulbs are replaced by nichrome wire, and the number of bulbs\n            is analogous to the length of the wire. The graphs show the inverse\n            relationship between resistor length and current; the best-fit graph\n            is nearly equivalent to an inverse function: \\(y=ax^{-1}\\) and\n            \\(y=6.28197x^{-0.926264}\\). This validates my prediction that current\n            would decrease as resistance increased.\\\\\n            One of the major difficulties with the lab was getting an accurate length\n            for the nichrome wire. As our group used longer lengths of wire, the wire\n            curved more, making accurate measurement of its length more difficult. This\n            is slightly reflected in the graph, with more deviation from the best-fit\n            line as the length of the wire increased.\\\\\n            The goal of this lab is to understand how resistance affects current flow\n            in a circuit. Noting that, the length of nichrome wire in a circuit seems\n            less important. Instead, the effective \\textit{resistance} of the wire\n            seems more important. So instead of using resistors of inconsistent resistance,\n            it would be simpler to use resistors of constant resistance, and simply\n            add more resistors in series to increase the resistance. This would remove\n            the variable of the length of the wire, removing a source of possible error.\n\\end{document}\n", "meta": {"hexsha": "02c53ab45659007506389ee78f8fd166de60bb10", "size": 10501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2014-2015/Physics/Electric_Ciruits/Resistance_Lab.tex", "max_stars_repo_name": "QuantumPhi/school", "max_stars_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2014-2015/Physics/Electric_Ciruits/Resistance_Lab.tex", "max_issues_repo_name": "QuantumPhi/school", "max_issues_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-04-10T07:28:17.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-10T07:30:10.000Z", "max_forks_repo_path": "2014-2015/Physics/Electric_Ciruits/Resistance_Lab.tex", "max_forks_repo_name": "QuantumPhi/school", "max_forks_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6869918699, "max_line_length": 148, "alphanum_fraction": 0.5189029616, "num_tokens": 2861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623216, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4496068028001738}}
{"text": "\\chapter{Conclusions}\\label{conclusionsChapter}\n\nThis thesis describes LeapGesture, which is the hand gesture recognition library dedicated for Leap Motion Controller.\nThis library includes modules for static and dynamic gesture recognition and also fingers recognition.\nDeveloped library provides recognition of all types of action gestures.\nStatic action gestures are supported by static gesture processing module, while the dynamic gesture processing module provides recognition of dynamic action gestures.\nAdditionally, comparison of existing gesture recognition methods, implementation of additional modules enabling the recording and reviewing of gestures, creation of sample gestures database and performation of tests has been conducted.\n%This thesis contains a thorough evaluation of proposed approaches to the gesture recognition.\n\nThe results obtained for the static gesture recognition suggest than those gestures are easy to recognize using the SVM with appropriate pre and postprocessing.\nThe differences between the recognition rates for different feature sets even values reaching up to $13\\%$ show that choosing different feature sets can have a major impact on the performance of recognition.\nAdditionally, it is important not to undermine the influence of the data preprocessing. \nEven the usage of the relatively simple median filter allowed to boost the recognition rate by $6\\%$.\nAlthough, the authors believe that the proposed parameters of processing module work well in many scenarios, there might be some specific cases that need different parameters or different feature sets to achieve good results.\nIt is also worth noting, that this and any another approach will not work properly if during the performance of static gestures, hands and fingers are not correctly detected by the Leap Motion.\nTherefore it is recommended to always choose gestures that have visible and separated fingers from the sensor's perspective.\nFor the proposed approach, recognition rate of $99\\%$ for five classes of gestures and $85\\%$ for ten classes of gestures in the static gesture recognition task were achieved. Satisfactory results of $93\\%$ were also obtained for the task of fingers recognition for $15$ of $32$ classes of fingers arrangements.\n\nWhen it comes to the task of dynamic gesture recognition, Leap Motion might not be the best sensor choice.\nLeap Motion provides great accuracy for static hand and fingers, but the data for dynamically moved hands are usually noisy.\nThe problems arise with short, lost finger tracking or temporal finger occlusions that are hard to detect and cope with on the library-level.\nThe proposed preprocessing module tries to alleviate those negative impacts, but the preprocessed data is still far from ideal.\nNevertheless the proposed approach with Hidden Markov Models allowed to recognize five classes of dynamic gestures with $80\\%$ accuracy.\n\nAs part of the further development of the library, the authors intend to improve the efficiency of dynamic gesture recognition by testing other possible feature sets and to develop methods that will allow to preprocessed data derived from Leap Motion more efficiently. Supporting of parameterized gestures is also envisaged.\n\n", "meta": {"hexsha": "a95fe9dce3389c51b0b517c3a9a4ed8d9b8e24c8", "size": 3226, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/11-conclusions.tex", "max_stars_repo_name": "uiuyuty/vsfh", "max_stars_repo_head_hexsha": "49f83a7bf043f7ae872dd759a0d32336d90cf1b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-03-02T09:30:35.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-11T07:07:57.000Z", "max_issues_repo_path": "thesis/11-conclusions.tex", "max_issues_repo_name": "uiuyuty/vsfh", "max_issues_repo_head_hexsha": "49f83a7bf043f7ae872dd759a0d32336d90cf1b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2016-04-01T21:28:24.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-30T21:39:28.000Z", "max_forks_repo_path": "thesis/11-conclusions.tex", "max_forks_repo_name": "uiuyuty/vsfh", "max_forks_repo_head_hexsha": "49f83a7bf043f7ae872dd759a0d32336d90cf1b4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2015-03-02T18:48:45.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-12T06:44:08.000Z", "avg_line_length": 119.4814814815, "max_line_length": 324, "alphanum_fraction": 0.827650341, "num_tokens": 568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4496067988578912}}
{"text": "\\section{General concepts using 1D DC resistivity inversion}\\label{sec:dc1d}\n{\\em See cpp/py files in the directory \\file{doc/tutorial/code/dc1d}.}\n\\subsection{Smooth inversion}\\label{sec:dc1dsmooth}\n{\\em Example file \\file{dc1dsmooth.cpp}.}\\\\\nIncluded into the GIMLi library are several electromagnetic 1d forward operators.\nFor direct current resistivity there is a semi-analytical solution using infinite sums that are approximated by Ghosh filters. \nThe resulting function calculates the apparent resistivity of any array for a given resistivity and thickness vector.\nThere are two main parameterisation types:\n\\begin{itemize}\n\t\\item a fixed parameterisation where only the parameters are varied \n\t\\item a variable parameterisation where parameters and geometry is varied\n\\end{itemize}\n\nAlthough for 1d problems the latter is the typical one (resistivity and thickness), we start with the first since it is more general for 2d/3d problems and actually easier.\nAccordingly, in the file dc1dmodelling.h/cpp two classes called \\cw{DC1dRhoModelling} and \\cw{DC1dBlockModelling} are defined.\nFor the first we first define a thickness vector and create a mesh using the function \\cw{createMesh1d}.\nThe the forward operator is initialized with the data.\n\n\\begin{lstlisting}[language=C++]\n    RMatrix abmnr; loadMatrixCol( abmnr, dataFile ); //! read data\n    RVector ab2 = abmnr[0], mn2 = abmnr[1], rhoa = abmnr[2]; //! 3 columns\n    RVector thk( nlay-1, max(ab2) / 2 / ( nlay - 1 ) ); //! const. thickn.\n    DC1dRhoModelling f( thk, ab2, mn2 ); //! initialise forward operator\n\\end{lstlisting}\n\nNote that the mesh generation can also be done automatically using another constructor.\nHowever most applications will read or create a mesh from in application and pass it.\n\nBy default, the transformations for data and model are identity transformations.\nWe initialise two logarithmic transformations for the resistivity and the apparent resistivity by \n\\begin{lstlisting}[language=C++]\n    RTransLog transRho;\n    RTransLog transRhoa;\n\\end{lstlisting}\n\nAlternatively, we could set lower/upper bounds for the resistivity using\n\\begin{lstlisting}[language=C++]\n    RTransLogLU transRho( lowerbound, upperbound);\n\\end{lstlisting}\nAppendix \\ref{app:trans} gives an overview on available transformation functions.\n\nNext, the inversion is initialized and a few options are set\n\\begin{lstlisting}[language=C++]\n    RInversion inv( data.rhoa(), f, verbose );\n    inv.setTransData( transRhoa );           //! data transform\n    inv.setTransModel( transRho );           //! model transform\n    inv.setRelativeError( errPerc / 100.0 ); //! constant relative error\n\\end{lstlisting}\n\nA starting model of constant values (median apparent resistivity) is defined\n\\begin{lstlisting}[language=C++]\n    RVector model( nlay, median( data.rhoa() ) ); //! constant vector\n    inv.setModel( model );                        //! starting model\n\\end{lstlisting}\n\nFinally, the inversion is called and the model is retrieved using \\lstinline|model = inv.run();|\n\nA very important parameter is the regularisation parameter $\\lambda$ that controls the strength of the smoothness constraints (which are the default constraint for any 1d/2d/3d mesh).\nWhereas $w^c$ and $w^m$ are dimensionless and 1 by default, $\\lambda$ has, after eq. (\\ref{eq:min}), the reciprocal and squared unit of $m$ and can thus have completely different values for different problems\\footnote{The regularisation parameter has therefore to be treated logarithmically.}.\nHowever, since often the logarithmic transform is used, the default value of $\\lambda=20$ is often a first guess.\nOther values are set by\n\\begin{lstlisting}\n    inv.setLambda( lambda ); //! set regularisation parameter\n\\end{lstlisting}\n\nIn order to optimise $\\lambda$, the L-curve \\citep{guentherruecker06,guentherdiss} can be applied to find a trade-off between data fit and model roughness by setting \\lstinline|inv.setOptimizeLambda(true);|.\nFor synthetic data or field data with well-known errors we can also call \\lstinline|model = inv.runChi1();|, which varies $\\lambda$ from the starting value such that the data are fitted within noise ($\\chi^2=1$).\nWe created a synthetic model with resistivities of 100(soil)-500(unsaturated)-20(saturated)-1000(bedrock) $\\Omega$m and thicknesses of 0.5, 3.5 and 6 meters.\nA Schlumberger sounding with AB/2 spacings from 1.0 to 100\\,m was simulated and 3\\% noise were added.\nData format of the file \\file{sond1-100.dat} is the unified data format\\footnote{See \\url{www.resistivity.net?unidata} for a description.}.\n\n\\begin{figure}[htbp]\n\\includegraphics[width=\\textwidth]{sond1-100-3lambdas}\\\\[-3ex]\n~~~a\\hfill ~~~b \\hfill ~~~c \\hfill ~\n\\caption{Smooth 1d resistivity inversion results for a) $\\lambda=200\\Rightarrow \\chi^2=11.1$/rrms=10.1\\%, b) $\\lambda=20\\Rightarrow \\chi^2=1.2$/rrms=3.3\\%, and c) $\\lambda=2\\Rightarrow \\chi^2=0.6$/rrms=2.4\\%, red-synthetic model, blue-estimated model}\\label{fig:dc1d-3lambda}\n\\end{figure}\n\nFigure~\\ref{fig:dc1d-3lambda} shows the inversion result for the three different regularisation parameters 300, 30 and 3.\nWhereas the first is over-smoothed, the other are much closer at the reality.\nThe rightmost figure over-fits the data ($\\chi^2=0.3<1$) but is still acceptable.\nThe L-curve method yields a value of $\\lambda=2.7$, which is too low.\nHowever, if we apply the $\\chi^2$-optimization we obtain a value of $\\lambda=15.2$ and with it the data are neither over- nor under-fitted.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Block inversion}\\label{sec:dc1dblock}\n{\\em Example file \\file{dc1dblock.cpp} in the directory \\file{doc/tutorial/code/dc1d}.}\\\\\nAlternatively, we might invert for a block model with unknown layer thickness and resistivity.\nWe change the mesh generation accordingly and use the forward operator \\lstinline|DC1dModelling|:\n\\begin{lstlisting}[language=C++]\n    DC1dModelling f( nlay, ab2, mn2 );\n\\end{lstlisting}\n\n\\lstinline|createMesh1DBlock| creates a block model with two regions\\footnote{With a second argument \\lstinline|createMesh1DBlock| can create a block model with thickness and several parameters for a multi-parameter block inversion.}.\nRegion 0 contains the thickness vector and region 1 contains the resistivity vector.\nThere is a region manager as a part of the forward modelling class that administrates the regions.\nWe first define different transformation functions for thickness and resistivity and associate it to the individual regions.\n\\begin{lstlisting}[language=C++]\n    RTransLog transThk;\n    RTransLogLU transRho( lbound, ubound );\n    RTransLog transRhoa;\n    f.region( 0 )->setTransModel( transThk );\n    f.region( 1 )->setTransModel( transRho );\n\\end{lstlisting}\n\nFor block discretisations, the starting model can have a great influence on the results.\nWe choose the median of the apparent resistivities and a constant thickness derived from the current spread as starting values.\n\\begin{lstlisting}[language=C++]\n    double paraDepth = max( ab2 ) / 3;\t\t\n    f.region( 0 )->setStartValue( paraDepth / nlay / 2.0 );\n    f.region( 1 )->setStartValue( median( rhoa ) );\n\\end{lstlisting}\n\nFor block inversion a scheme after \\cite{marquardt}, i.e. a local damping of the changing without interaction of the model parameters and a decreasing regularisation strength is favourable.\n\\begin{lstlisting}[language=C++]\n    inv.setMarquardtScheme( 0.9 ); //! local damping with decreasing lambda\n\\end{lstlisting}\n\nThe latter could also be achieved by \\begin{enumerate}\n\t\\item setting the constraint type to zero (damping) by \\lstinline|inv.setConstraintType(0)|\n\t\\item switching to local regularization by \\lstinline|inv.setLocalRecularization(true)|\n\t\\item defining the lambda decreasing factor by \\lstinline|inv.setLambdaDecrease(0.9)|\n\\end{enumerate}\n\n%The choice of appropriate regularisation parameters is somewhat more complicated since the result strongly depends on the starting model and the preceding models \\citep{guentherdiss}.\n%The latter can be done by \\lstinline|inv.setLambdaDecrease( factor );|\n\nWith the default regularization strength $\\lambda=20$ we obtain a data fit slightly below the error estimate.\nThe model (Fig.~\\ref{fig:dc1dblock-resres}a) clearly shows the four layers (blue) close to the synthetic model (red).\n%Some parameters are overestimated and some are underestimated.\n\n\\begin{figure}[htbp]\n\\centering\\includegraphics[width=0.7\\textwidth]{dc1dblock-resres}\\\\[-3ex]\n~\\hfill a\\hfill ~ \\hfill ~~~~~b \\hfill ~ \\hfill ~ \\hfill ~\n\\caption{a) Block 1d resistivity inversion result (red-synthetic model, blue-estimated model)) and b) resolution matrix}\\label{fig:dc1dblock-resres}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Resolution analysis}\\label{sec:dc1dresolution}\nOne may now be interested in the resolution properties of the individual model parameters.\nThe resolution matrix $\\R^M$ defines the projection of the real model onto the estimated model:\n\\begin{equation}\n\t\\m^{est} = \\R^M \\m^{true} + (\\I - \\R^M) \\m^R + \\S^\\dagger\\D\\n\\quad,\n\\end{equation}\n\\citep{guentherdiss} where $\\S^\\dagger\\D\\n$ represents the generalised inverse applied to the noise.\nNote that $\\m^R$ changes to $\\m^k$ for local regularisation schemes \\citep{friedel03}.\n\n\\citet{guentherdiss} also showed that the model cell resolution (discrete point spread function) can be computed by solving an inverse sub-problem with the corresponding sensitivity distribution instead of the data misfit.\nThis is implemented in the inversion class by the function \\lstinline|modelCellResolution( iModel )| where \\lstinline|iModel| is the number of the model cell.\nThis approach is feasible for bigger higher-dimensional problems and avoids the computation of the whole resolution matrix.\nA computation for representative model cells can thus give insight of the resolution properties of different parts of the model.\n\nFor the block model we successively compute the whole resolution matrix.\n\\begin{lstlisting}\n    RVector resolution( nModel ); //! create single resolution vector\n    RMatrix resM;                 //! create empty matrix \n    for ( size_t iModel = 0; iModel < nModel; iModel++ ) {\n        resolution = inv.modelCellResolution( iModel );\n        resM.push_back( resolution );  //! push back the single vector\n    }\n    save( resM, \"resM\" ); //! save resolution matrix\n\\end{lstlisting}\n\nIn Figure~\\ref{fig:dc1dblock-resres} the model resolution matrix is shown and the diagonal elements are denoted.\nThe diagonal elements show that the resolution decreases with depth.\nThe first resistivity is resolved nearly perfect, whereas the other parameters show deviations from 1.\n$\\rho_2$ is positively connected with $d_2$, i.e. an increase of resistivity can be compensated by an increased resistivity.\nFor $\\rho_3$ and $d_3$ the correlation is negative.\nThese are the well known H- and T-equivalences of thin resistors or conductors, respectively, and show the equivalence of possible models that are able to fit the data within noise.\n%Similarly, we can obtain the resolution kernels also for smooth inversion.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Structural information}\\label{sec:dc1dstruct}\n{\\em Example file \\file{dc1dsmooth-struct.cpp} in the directory \\file{doc/tutorial/code/dc1d}.}\\\\\nAssume we know the ground water table at 4\\,m from a well.\nAlthough we know nothing about the parameters, this structural information should be incorporated into the model.\nWe create a thickness vector of constant 0.5\\,m. \nThe first 8 model cells are located above the water table, so the 8th boundary contains the known information.\nTherefore we set a marker different from zero (default) after creating the mesh\n\\begin{lstlisting}\n    //! variant 1: set mesh (region) marker\n    f.mesh()->boundary( 8 ).setMarker( 1 );\n\\end{lstlisting}\nThis causes the boundary between layer 8 and 9 being disregarded, the corresponding $w^c_8$ is zero and allows for arbitrary jumps in the otherwise smoothed model.\nFigure~\\ref{fig:dc1dsmooth-struct} shows the result, at 4\\,m the resistivity jumps from a few hundreds down to almost 10.\n\n\\begin{figure}[htbp]\n\\centering\\includegraphics[width=0.45\\textwidth]{sond1-100-struct.pdf}\n%\\\\[-3ex]\n%~\\hfill a\\hfill ~ \\hfill ~~~~~b \\hfill ~ \\hfill ~ \\hfill ~\n\\caption{Inversion result with the ground water table at 4\\,m as structural constraint.}\\label{fig:dc1dsmooth-struct}\n\\end{figure}\n\nNote that we can set the weight to zero also directly, either as a property of the inversion\n\\begin{lstlisting}\n    //! variant 2: application of a constraint weight vector to inversion\n    RVector bc( inv.constraintsCount(), 1.0 );\n    bc[ 6 ] = 0.0;\n    inv.setCWeight( bc ); \n\\end{lstlisting}\nor the (only existing) region.\n\\begin{lstlisting}\n    //! variant 3: application of a boundary control vector to region\n    RVector bc( f.regionManager().constraintCount(), 1.0 );\n    bc[ 7 ] = 0.0;\n    f.region( 0 )->setConstraintsWeight( bc );\n\\end{lstlisting}\nOf course, in 2d/3d inverse problems we do not set the weight by hand.\nInstead, we put an additional polygon (2d) or surface (3d) with a marker $\\neq 0$ into the PLC before the mesh generation.\nBy doing so, arbitrary boundaries can be incorporated as known boundaries.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Regions}\\label{sec:dc1dregion}\n{\\em Example file \\file{dc1dsmooth-region.cpp} in the directory \\file{doc/tutorial/code/dc1d}.}\\\\\nIn the latter sections we already used regions.\nA default mesh contains a region with number 0.\nA block mesh contains a region 0 for the thickness values and regions counting up from 1 for the individual parameters.\nHigher dimensional meshes can be created automatically by using region markers, e.g. for specifying different geological units.\n\nIn our case we can divide part above and a part below water level.\nIn 2d or 3d we would, similar to the constraints above, just put a region marker $\\neq 0$ into the PLC and the mesh generator will automatically associate this attribute to all cells in the region.\n\nHere we set the markers of the cells $\\geq8$ to the region marker 1.\n\\begin{lstlisting}\n    Mesh * mesh = f.mesh();\n    mesh->boundary( 8 ).setMarker( 1 );\n    for ( size_t i = 8; i < mesh->cellCount(); i++ ) \n        mesh->cell( i ).setMarker( 1 );\n\\end{lstlisting}\n\nNow we have two regions that are decoupled automatically.\nThe inversion result is identical to the one in Figure~\\ref{fig:dc1dsmooth-struct}.\nHowever we can now define the properties of each region individually.\nFor instance, we might know the resistivities to lie between 80 and 800\\,$\\Omega$m above and between 10 and 100\\,$\\Omega$m below.\nConsequently we define two transformations and apply it to the regions.\n\\begin{lstlisting}\n    RTransLogLU transRho0( 80, 800 );\n    RTransLogLU transRho1( 10, 1000 );\n    f.region( 0 )->setTransModel( transRho0 );\n    f.region( 1 )->setTransModel( transRho1 );\n\\end{lstlisting}\n\nAdditionally we might try to improve the very smooth transition between groundwater and bedrock.\nWe decrease the model control (strength of smoothness) in the lower region by a factor of 10.\n\\begin{lstlisting}\n    f.region( 1 )->setModelControl( 0.1 );\n\\end{lstlisting}\n\nThe result is shown in Figure~\\ref{fig:dc1dsmooth-region}.\nThe resistivity values are much better due to adding information about the valid ranges.\nFurthermore the transition zone in the lower region is clear.\n\\begin{figure}[htbp]\n\\centering\\includegraphics[width=0.45\\textwidth]{sond1-100-region.pdf}\n\\caption{Inversion result using two regions of individual range constraint transformations and regularization strength (model control).}%\n\\label{fig:dc1dsmooth-region}\n\\end{figure}\n", "meta": {"hexsha": "7d8ca843a7ba2b188cfcc08cdd4021e36c16bc6a", "size": 15770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tutorial/concepts.tex", "max_stars_repo_name": "mjziebarth/gimli", "max_stars_repo_head_hexsha": "196ac4d6dd67e0326cccc44a87b367f64051e490", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-07-10T00:56:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-17T12:43:38.000Z", "max_issues_repo_path": "doc/tutorial/concepts.tex", "max_issues_repo_name": "ivek1312/gimli", "max_issues_repo_head_hexsha": "5fafebb7c96dd0e04e2616df402fa27a01609d63", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/tutorial/concepts.tex", "max_forks_repo_name": "ivek1312/gimli", "max_forks_repo_head_hexsha": "5fafebb7c96dd0e04e2616df402fa27a01609d63", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-29T04:28:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T04:28:40.000Z", "avg_line_length": 61.6015625, "max_line_length": 293, "alphanum_fraction": 0.7492073557, "num_tokens": 4055, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.44960679701537065}}
{"text": "\n\\subsection{The Keynesian cross and the Investment Saving (IS) curve}\n\n\\subsubsection{The Keynesian cross}\n\nWe have:\n\n\\(Y=C(Y-T(Y))+I(r)+G+NX(Y)\\)\n\nWhere:\n\n\\begin{itemize}\n\\item \\(Y\\) is output\n\\item \\(C\\) is consumption\n\\item \\(T\\) is taxes\n\\item \\(I\\) is investment\n\\item \\(r\\) is the real interest rate\n\\item \\(G\\) is government spending\n\\item \\(NX\\) is net exports\n\\end{itemize}\n\nThe Keynesian cross plots:\n\n\\(Y\\)\n\nAgainst:\n\n\\(C(Y-T(Y))+I(r)+G+NX(Y)\\)\n\nThis identifies an equilibrium level of output.\n\n\\subsubsection{The IS curve}\n\nThe IS curve plots the equilibrium level of output from the Keynesian cross against the real interest rate.\n\nAs the real interest rate rises, investment and therefore output falls.\n\n\\subsubsection{The slope of the IS curve}\n\nThe slope of the IS curve depends on taxes and net exports.\n\n", "meta": {"hexsha": "cdae96eba17e856eeba2cedd66de4e41f890f40a", "size": 823, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/neoKeynesian/02-02-IS.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/neoKeynesian/02-02-IS.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/neoKeynesian/02-02-IS.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5952380952, "max_line_length": 107, "alphanum_fraction": 0.7168894289, "num_tokens": 220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4496067970153706}}
{"text": "\\documentclass[twoside, 11pt]{article}\n\n\\usepackage{jmlr2e}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{mathtools}\n\n% ensure sufficient marginspace for todos\n\\setlength {\\marginparwidth }{2cm}\n\\usepackage[obeyFinal]{todonotes}\n% \\setuptodonotes{inline}\n\n% define notation for norm and abs that scale nicely.\n% ref: https://tex.stackexchange.com/a/297263\n\\let\\oldnorm\\norm\n\\let\\norm\\undefined\n\\DeclarePairedDelimiter\\norm{\\lVert}{\\rVert}\n\n\\let\\oldabs\\abs\n\\let\\abs\\undefined\n\\DeclarePairedDelimiter\\abs{\\lvert}{\\rvert}\n\n\\DeclarePairedDelimiter\\card{\\lvert}{\\rvert}\n\n\\newcommand{\\xx}[0] {\\mathbb{X}} % decision variable space\n\\newcommand{\\hh}[0] {\\mathbb{H}} % stochastic process for state\n\\newcommand{\\zz}[0] {\\mathbb{Z}} % hidden event space?\n\\newcommand{\\mm}[0] {\\mathbb{M}} % HMM model type space\n\\newcommand{\\TT}[0] {\\mathbb{T}} % time indices\n\\newcommand{\\II}[0] {\\mathbb{I}} % factorial model indices\n\\newcommand{\\traj}[1] {H^{(#1)}}\n\\newcommand{\\state}[2] {H_{#2}^{(#1)}}\n\\newcommand{\\event}[2] {Z_{#2}^{(#1)}}\n\\newcommand{\\eventseq}[1] {Z^{(#1)}}\n\\newcommand{\\reals}[0] {\\mathbb{R}}\n\\newcommand{\\naturals}[0] {\\mathbb{N}}\n\\newcommand{\\events}[0] {\\mathbb{Y}}\n\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\n\\begin{document}\n\n\\author{\\name Reuben Fletcher-Costin}\n\n\\editor{}\n\n\\title{Approximate MAP inference of sparse factorial hidden Markov models through set cover decomposition}\n\n\\maketitle\n\n\\begin{abstract}%\nOur goal is to infer a sparse subset of hidden Markov models (HMMs) that collectively explain a sequence of observations. We define a probabilistic model for a simple form of factorial HMMs and pose a maximum a posteriori (MAP) estimation problem to infer a sparse subset of component HMM, their hidden states, and separate the observations into component signals associated with each component HMM. We show that the MAP estimation problem is equivalent to an exact cover problem, where each component HMM is regarded as a set that covers a portion of the observed signal. This permits a relaxed approximation of the problem to be decomposed as a master set cover problem and auxiliary problem using column generation. Each auxiliary problem can be solved efficiently using dynamic programming by a \"prize-collecting\" modified Viterbi algorithm that recovers a HMM trajectory that incorporates prizes from the master problem for explaining portions of the observed signal.\n\\end{abstract}\n\n% keywords could go here\n\n\\section{Introduction}\n\n\\todo[inline]{why care about HMMs}\n\\todo[inline]{why care about separation problems}\n\\todo[inline]{discuss factorial HMMs}\n\\todo[inline]{discuss alternatives to factorial HMMs}\n\\todo[inline]{intro linear programming decompositions, convex optimisation decompositions}\n\n\\section{Probabilistic model}\n\n\\subsection{Hidden Markov models}\nWe start by assuming a family of hidden Markov models, indexed by $m \\in \\mm$. Each model $m \\in \\mm$ in the family has a finite state space $S_m = \\{s_1, \\ldots, s_{K_m}\\}$ consisting of $K_m \\in \\naturals$ states. The state of the model $m$ at time $t \\in \\TT = \\{ 1, \\ldots, T \\}$ is denoted by the random variable $H_{m, t}$ which takes values in the state space $S_m$. We regard the states as not directly observable and refer to them as hidden (aka latent) states. The hidden states of model $m$ evolve in time independently from other models according to a discrete time first-order Markov process\n\\begin{equation}\nP(H_{m,t+1} \\mid \\{ H_{m^{\\prime},t^{\\prime}} \\}_{m^{\\prime}, t^{\\prime} \\in \\mm \\times \\TT \\setminus \\{m, t\\}} )\n=\nP(H_{m,t+1} \\mid H_{m,t} )\n\\end{equation}\nWe assume that the transition model $P(H_{m,t+1} \\mid H_{m,t} )$ for each $m \\in \\mm$ is stationary, that is, there exists some $K_m$ by $K_m$ stochastic matrix $A^{m}$ with elements $A^{m}_{s^{\\prime}, s}$ such that for all $t \\in \\TT$, $A^{m}_{s^{\\prime}, s} = P(H_{m, t+1}=s^{\\prime} \\mid H_{m,t}=s)$. We write $\\pi_m$ to denote a prior distribution over $H_{m,1}$ at $t=1$. In the simple case where we believe a-priori that the $m$th HMM is present \\footnote{Once we consider a sparse factorial model composed of multiple component HMMs from the family $\\mm$, we may no longer believe a-priori that all or any HMM $m \\in \\mm$ necessarily participates in the factorial model.}, we could write $P(H_{m,1}) = \\pi_m$.\n\nEach hidden Markov model $m$ emits a sequence of signals $Z_{m,1}, \\ldots, Z_{m,T}$, where each $Z_{m,t} \\in \\events$. The space of signals $\\events$ is assumed to be a vector space over $\\reals$. Each signal $Z_{m,t}$ is assumed to be caused solely by the corresponding hidden state $H_{m,t}$:\n\\begin{equation}\nP\\left(Z_{m,t}\n\\mid\n\\{ H_{m^{\\prime},t^{\\prime}} \\}_{m^{\\prime}, t^{\\prime} \\in \\mm \\times \\TT} \\;\n\\{ Z_{m^{\\prime},t^{\\prime}} \\}_{m^{\\prime}, t^{\\prime} \\in \\mm \\times \\TT \\setminus \\{m, t\\}}\n\\right)\n=\nP(Z_{m,t} \\mid H_{m,t} ) .\n\\end{equation}\nWe refer to $P(Z_{m, t} \\mid H_{m,t} )$ as the observation model for the $m$th model. We assume the observation model for each $m \\in \\mm$ is stationary with respect to $t$.\n\n\n\\todo{add a clear graphical model of a single HMM for some $m \\in \\mm$}\n\n\\subsection{Factorial hidden Markov models}\n\nWe consider factorial hidden Markov models consisting of a multiset of component hidden Markov models, where the possible component HMMs are indexed by $i$ over some abstract index set $\\II$. Note that the cardinality of $\\II$ may not be finite. We defer explictly constructing $\\II$ until section \\ref{section:inference}. Let $m(i) \\in \\mm$ denote the component HMM associated with the $i$th index. We represent a given factorial model as the pair $X, M$, where\n\\begin{align}\nX & := (X_i)_{i \\in \\II} \\quad X_i \\in \\{0, 1\\} , \\\\\nM & := (m(i))_{i \\in II} \\quad m(i) \\in \\mm .\n\\end{align}\nWe regard $X$ as a collection of random variables over binary values that address a subset of indices from $\\II$, and $M$ as a collection of random variables over $\\mm$ that associate a particular type of HMM $m(i) \\in \\mm$ to each selected index. Note this representation of factorial models is not unique to permutations of the indices $\\II$.\n\nWe restrict our focus to \\emph{sparse} factorial models where $\\norm{X}_1$ is bounded, that is, where there exists $n \\in \\naturals$ such that $\\sum_{i \\in \\II} \\abs{X_i} \\leq n$. We can further express a preference for sparsity through a choice of prior over $X$.\n\nWe are interested in estimating a factorial hidden Markov model with components $(X_i)_{i \\in \\II}$ that best \"explains\" some given observed data $Y_t \\in \\events$ for $t \\in \\TT$. The standard probabilistic model for a single HMM $m \\in \\mm$ assumes that at each time $t in \\TT$ the output signal $Z_{m,t}$ is directly observable. In contrast, with a factorial HMM the output $Z_{m,t}$ of each component HMM $m$ is not directly observable. Instead, we observe a signal $Y_t$ each $t \\in \\TT$ that aggregates the hidden output signals of all component HMMs:\n\\begin{equation}\nY_t = \\sum_{i \\in \\II} X_i \\event i t ,\n\\end{equation}\nwhere $\\event i t := Z_{m(i), t}$. Note that unlike the definition of the more general factorial hidden Markov model considered by {Ghahramani and Jordan 1997}\\todo{CITE} we assume there is no top-level error term and assume a different dependency structure between $Y$ and $Z$. Error terms can be expressed by $\\event i t$ through the observation models of the component HMMs.\n\n\\todo{add graphical model of this factorial HMM construction using Y X Z M H}\n\n\\section{Inference} \\label{section:inference}\n\n\\todo{rework in terms of index set $\\II$. that will allow multiple copies of a single class of markov model to appear in solution. that's fine, as long as they each pay their way by justifying another copy of the log prior in the objective function}\n\nOur goal is to infer a sparse factorial HMM, represented by $X$ and $M$, that explains a sequence of outputs $Y = (Y_t)_{t \\in \\TT}$. Given the framework of Bayesian inference, this amounts to computing the posterior distribution $P(X, M | Y=y)$ given observed data $y \\in \\events^{\\TT}$. Computing this posterior distribution exactly is computationally challenging as it requires integrating over all the hidden states $\\state i t$ and all outputs $\\event i t$ for all $t \\in \\TT$ and all potential component models $i \\in \\II$. A less useful but more computationally feasible task is to instead compute a maximum a posteriori parameter estimate of the quad $(X, M, H, Z) = (X_i, m(i), \\traj i, Z^{(i)})_{i \\in \\II}$ given the observed data $Y=y$. The elements of the quad define which component models participate in the factorial model ($X$), the type of each component from the family $\\mm$ ($M$), the hidden states of each component ($H$), and the hidden outputs emitted by each component ($Z$).\n\nThis form of MAP estimate is computationally tractable because the probabilities of each component HMM state $(X_i, Z_i)$ are conditionally independent from $(X_j, Z_j)$ $j \\neq i$ given $Z$, allowing conditional probabilities to be calculated independently component by component once some value of $Z$ is fixed. This leads to a tractable decomposition. \\todo{explain in terms of causal graph diagram, markov blankets, d separation}\n\nWe demonstrate the decomposition more formally. Consider the following factorisation of the conditional probability of the variables $X, H, Z$ given the data $Y$:\n\\begin{align}\nP(X, M, H, Z \\mid Y)\n& = P(Y \\mid X, M, H, Z) P(X, M, H, Z) / P(Y) \\label{map1} \\\\\n& \\propto P(Y \\mid X, M, H, Z) P(X, M, H, Z) \\label{map2} \\\\\n& = P(Y \\mid X, Z) P(X, M, H, Z) \\label{map3} \\\\\n& = P(Y \\mid X, Z) P(Z | X, M, H) P(X, M, H) \\label{map4} \\\\\n& = P\\left(Y \\mid X, Z\\right) \\prod_{i \\in \\II} P\\left(\\eventseq i | M_i, \\traj i\\right)^{X_i} P(X, M, H) \\label{map5} \\\\\n& = P\\left(Y = \\sum_{i \\in \\II} X_i \\eventseq i \\mid X, Z \\right)\n\\prod_{i \\in \\II} P\\left(\\eventseq i | M_i, \\traj i\\right)^{X_i} P(X, M, H) \\label{map6}\n\\end{align}\n\\todo{fixup p a given b bar scaling}\nwhere \\ref{map1} uses Bayes' theorem, \\ref{map2} drops the factor $P(Y)$ as it is invariant during maximisation over $(X, H, Z)$, \\ref{map3} applies the conditional independence of $Y$ from $H$ and $M$ given $X$ and $Z$, \\ref{map5} is due to the conditional independence of the component observation models given $Z$, and \\ref{map6} applies the definition of the aggregated observation $Y$ from the component hidden outputs.\n\nTo complete the decomposition of the conditional probability $P(X, M, H, Z \\mid Y)$ in terms the distributions defined by the family of component Markov processes, we need to decide on $P(X, M, H)$, a prior joint distribution over $X$, $M$ and $H$. We assume the prior probabilities of $\\traj m$ and $\\traj {m^{\\prime}}$ are conditionally independent given $X$ for each distinct $m, m^{\\prime} \\in \\mm$. Therefore we have\n\\begin{align}\nP(X, M, H)\n& = \\prod_{i \\in \\II} P(\\traj i \\mid m(i)) P(m(i) \\mid X_i ) P(X) \\\\\n& = \\prod_{i \\in \\II} \\left( \\frac{1}{\\card{\\mm}} P(\\traj i \\mid m(i)) \\right)^{X_i} P(X) \\\\\n\\end{align}\nwhere $P(\\traj i \\mid m(i))$ is the prior probability of the trajectory $\\traj {m(i)} = \\pi_{m(i)}$ as supplied by the component HMM. The $\\frac{1}{\\card{\\mm}}$ factor is due to assuming a uniform prior over $m(i)$ that does not prefer any particular model $m$ of the family $\\mm$. We tentatively define a prior $P(X)$ over the binary sequence $X = \\{X_i\\}_{i \\in \\II} \\in \\{0, 1\\}^{\\card{I}}$ in terms of a prior $P(n)$ over the number of active processes $n := \\norm{X}_1$ that assigns higher prior probability to explanations involving fewer active Markov processes:\n\\begin{align}\nP(X)\n& = P(X \\mid n) P(n) \\\\\n& \\propto \\frac{1}{|\\mm|^n \\; 2^{n+1}}\n\\end{align}\nwhere we have omitted a normalisation constant required so that $\\sum_{X} P(X) = 1$\n\\todo{rework, support nonuniform prior on $\\mm$ as it is easy and probably quite useful in applications}\n\n\\todo{add $M$ into the argmax}\n\nConsider the MAP parameter estimation problem:\n\\begin{equation}\n(X^{\\star}, M^{\\star}, H^{\\star}, Z^{\\star}) = \\argmax_{X, M, H, Z} P\\left(X, M, H, Z \\mid Y\\right)\n\\end{equation}\nSubstituting our decomposition of $P(X, M, H, Z | Y)$ and the definition of our prior $P(X, M, H)$ gives\n\\begin{align*}\n& \\argmax_{X, M, H, Z} P\\left(X, H, Z \\mid Y\\right) \\\\\n= & \\argmax_{X, M, H, Z}\nP\\left(Y = \\sum_{i \\in \\II} X_i \\eventseq i \\mid X, Z \\right)\n\\prod_{i \\in \\mm} P\\left(\\eventseq i | m(i), \\traj i\\right)^{X_i} P(X, M, H) \\\\\n= & \\argmax_{X, M, H, Z} \\prod_{i \\in \\II} P\\left(\\eventseq i | m(i), \\traj i\\right)^{X_i}\n\\prod_{i \\in \\II} P(\\traj i \\mid m(i))^{X_i}\n\\frac{1}{|\\mm|^n \\; 2^{n+1}} \\\\\n & \\mathrm{s.t.} \\sum_{i \\in \\II} X_i \\eventseq i = Y\n\\end{align*}\nwhere $n = \\norm{X}_1$ and the factor for the conditional probability of the observation vector $Y$ is equivalently expressed by the constraining the max to consider only those quads $(X, M, H, Z)$ such that $\\sum_{i \\in \\II} X_i \\eventseq i = Y$.\n\nSince $\\argmax$ is invariant under transformation of the objective function by a monotonic function, by the monotonicity of the logarithm we have\n\\begin{align}\n(X^{\\star}, M^{\\star}, H^{\\star}, Z^{\\star})\n= & \\argmax_{X, M, H, Z} \\sum_{i \\in \\II} X_i C(m(i), \\eventseq i, \\traj i) \\\\\n & \\mathrm{s.t.} \\sum_{i \\in \\II} X_i \\eventseq i = Y ,\n\\end{align}\nwhere $C(m(i), \\eventseq i, \\traj i)$ is defined by\n\\begin{equation*}\nC(m(i), \\eventseq i, \\traj i) =\n\\log P\\left(\\eventseq i | m(i), \\traj i\\right) + \n\\log P(\\traj i \\mid m(i)) -\n\\left ( \\log |\\mm| + \\log 2 \\right) ,\n\\end{equation*}\nand we have dropped terms from the $\\argmax$ that are constant\nwith respect to $(X, M, H, Z)$.\n\n\\todo{explicitly construct the index and show this is a linear program}\n\n\\section{Practical considerations}\n\n{bootstrapping initial feasible solution so there is a dual solution that can be used to set initial prizes}\\todo{elabourate}\n\n{decomposition of MAP estimation problem into master relaxed exact cover problem and auxiliary prize-collecting Viterbi dynamic programming problem allows many complex problem specific details to be handled as part of the dynamic programming}\\todo{elabourate}\n\n{degeneracy / slow convergence of restricted relaxed master linear program}\\todo{investigate and mitigate}\n\n{exactly when is the dual solution used to set prizes well defined -- over which range?}\\todo{investigate}\n\n{efficient search over particular families of HMMs}\\todo{investigate}\n\n{embed into full branch and price regime}\\todo{investigate}\n\n{reducing wasted effort by reusing LP bookkeeping and prior soln to warm-start over successive LP solves}\\todo{investigate}\n\n\\section{Variations}\n\n{maybe hard equality constraint linking Y to Z is not pragmatic. if soften constraint and allow nonzero error $r$ one naive implementation might add factor $k \\exp(-\\frac{\\norm{r}^2}{{\\sigma^2}})$ to unlogged objective function. equivalently when objective is logged, this adds some $- \\norm{r}^2$ term. seems to give some kind of quadratic optimisation problem. can decomposition still work?}\\todo{investigate}\n\n\\section{bibliography}\n\\todo{setup bibtex etc}\n\n\\end{document}\n", "meta": {"hexsha": "b6c24caa5a775dd1b9a84417f62093b3bfa1a6dc", "size": 15059, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/note.tex", "max_stars_repo_name": "fcostin/hmmmix", "max_stars_repo_head_hexsha": "45e4731ab75e994a34aed12c869faa6930869342", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/note.tex", "max_issues_repo_name": "fcostin/hmmmix", "max_issues_repo_head_hexsha": "45e4731ab75e994a34aed12c869faa6930869342", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/note.tex", "max_forks_repo_name": "fcostin/hmmmix", "max_forks_repo_head_hexsha": "45e4731ab75e994a34aed12c869faa6930869342", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.7095238095, "max_line_length": 1000, "alphanum_fraction": 0.7141244439, "num_tokens": 4534, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4496067891308055}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\n\\begin{document}\n\\logo\n\\rulename{Exponential Moving Average Trading Rule} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{Exponential Moving Average (EMA) is a type of moving average similar to simple moving average, but it reduce the lag by applying more weight to recent prices. The weighting applied varies depending on the number of periods use in the moving average.\n                Traders used this more to get a clearer view of the most recent price change of an asset.}\n\n\\section{Equation}\n\\begin{equation}\n    EMA_{\\currenttime} = \\Big(V_{\\currenttime} * \\Big(\\frac{S}{1 + \\lookbacklength}\\Big)\\Big) + EMA_{\\currenttime-1} * \\Big(1-\\frac{S}{1 + \\lookbacklength}\\Big)\n\\end{equation}\n\\\\\n\nwhere: \\\\\n\n$EMA$ is exponentially weighted moving average. \\\\\n\n$V_{\\currenttime}$ is current stock value. \\\\\n\n$\\lookbacklength$ \\ is look back length. \\\\\n\n$S$ is the smoothing factor.\n\n\n\\ruleparameters\n{Window size}{50}{This is the number of time steps over which exponential contributions are sourced.}{$\\lookbacklength$}\n{Smoothing Factor}{2}{Smoothing factor represents the weighting applied to the most recent period’s value.}{$S$}\n\\stoptable\n\n\\keyterms\n\\furtherlinks\n\n\\end{document}", "meta": {"hexsha": "c5028da3e778fb37ed4841dc72f97ee93fb6f880", "size": 1326, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/ExponentialMovingAverage.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/ExponentialMovingAverage.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/ExponentialMovingAverage.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 33.15, "max_line_length": 266, "alphanum_fraction": 0.7518853695, "num_tokens": 356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.4496067794037196}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{geometry}\n\\usepackage[utf8]{inputenc}\n\\usepackage{enumitem}\n\\usepackage{physics}\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1em}\n\\relpenalty=10000\n\\binoppenalty=10000\n\n\\begin{document}\n\\section{Geometry revision}\n\\begin{enumerate}\n  \\item % http://www.pdmi.ras.ru/EIMI/2018/Baltic_way/bw18coord.pdf\n  The points $A$, $B$, $C$, $D$ lie, in this order, on a circle $\\omega$, where $AD$ is a diameter of $\\omega$. Furthermore, $AB = BC = a$ and $CD = c$ for some relatively prime integers $a$ and $c$. Show that if the diameter $d$ of $\\omega$ is also an integer, then either $d$ or $2d$ is a perfect square.\n\n  \\item %IMO SL2018\n  Let $ABCDE$ be a convex pentagon such that $AB = BC = CD$, $\\angle EAB =  \\angle BCD$, and $\\angle EDC = \\angle CBA$. Prove that the perpendiular line from $E$ to $BC$ and the line segments $AC$ and $BD$ are concurrent.\n\n  \\item % http://www.math.olympiaadid.ut.ee/arhiiv/varia/bwtr/bw18tr/bw18tren.pdf\n  The heights of triangle $ABC$ for triangle $A_1B_1C_1$. The heights of triangle $A_1B_1C_1$ form triangle $A_2B_2C_2$. Prove that $ABC \\sim A_2B_2C_2$\n\n  \\item % http://www.math.olympiaadid.ut.ee/arhiiv/varia/bwtr/bw18tr/bw18tren.pdf\n  Vertex $A$ of square $ABCD$ is symmetric to the midpoint of side $CD$ with respect to line $l$. Find the ratio of the areas of the two quadrilaterals on either side of line $l$ which make up the square.\n\n  \\item % http://www.math.olympiaadid.ut.ee/arhiiv/varia/bwtr/bw18tr/bw18tren.pdf\n  Acute triangle $ABC$ has circumcircle $\\omega$. The tangents of $\\omega$ at points $B$ and $C$ intesect at $P$. $D$ and $E$ are the projections of $P$ to lines $AB$ and $AC$ respectively. Prove that the orthocentre of triangle $ADE$ coincides with the midpoint of line $BC$.\n\n  \\item % http://www.pdmi.ras.ru/EIMI/2018/Baltic_way/bw18coord.pdf\n  The bisector of the $\\angle A$ of a triangle $ABC$ intersects $BC$ in a point $D$ and intersects the circumcircle of the triangle $ABC$ in a point $E$. Let $K, L, M$ and $N$ be the midpoints of the segments $AB, BD, CD$ and $AC$, respectively. Let $P$ be the circumcenter of the triangle $EKL$, and $Q$ be the circumcenter of the triangle $EMN$. Prove that $\\angle PEQ = \\angle BAC$.\n\n\\end{enumerate}\n\n\\section{Auxilliary constructions} % http://www.math.olympiaadid.ut.ee/arhiiv/oppemat/eesti/lisakon.pdf\n\\begin{enumerate}[resume]\n  \\item\n  Vertices $A,B,C,D$ of parallelogram are connected to the midpoints of sides $BC,CD,DA,AB$ respectively. The segments intersect at points $K,L,M,N$. Find the ratio of the areas of $KLMN$ and $ABCD$.\n\n  \\item\n  In triangle $ABC$ $\\angle A = 90 ^\\circ$. Let $M$ be the midpoint of $AB$. Perpendicular line to $CM$ through $A$ intersects $AB$ at $P$. Prove that $\\angle AMC = \\angle BMP$.\n\n  \\item\n    Let $ABC$ be an acute triangle and $D$ the projection of $A$ to side $BC$. Point $E$ lies on segment $AD$ and satisfies\n    $$\\frac{AE}{ED}=\\frac{CD}{DB}$$\n    Let $F$ be the projection of point $D$ to $BE$. Prove that $\\angle AFC = 90 ^\\circ$.\n  \\item\n  Points $E$ and $F$ are chosen on the sides $CD$ and $BC$ of square $ABCD$, such that $\\angle AEB = \\angle AEF$. Find $\\angle EAF$.\n  \\item\n  The angle bisectors from points $A$ and $B$ of triangle $ABC$ intersect sides $BC$ and $AC$ at points $D$ and $E$ respectively. Find $\\angle C$, if $AE + BD = AB$\n\n  \\item\n  Let us have a parallelogram $ABCD$. A circle which goes through $A$ intersects segments $AB$, $AC$ and $AD$ at points $M$, $K$ and $N$. Prove that $|AB|\\cdot|AM| + |AD|\\cdot |AN| = |AK|\\cdot|AC|$\n\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "5a8e38ee71afe121aff9092a3dcfbecc70ce236b", "size": 3628, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "17_geometry_revision.tex", "max_stars_repo_name": "ZhaoWanLong/maths-olympiad", "max_stars_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-21T21:57:43.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-21T21:57:43.000Z", "max_issues_repo_path": "17_geometry_revision.tex", "max_issues_repo_name": "ZhaoWanLong/maths-olympiad", "max_issues_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "17_geometry_revision.tex", "max_forks_repo_name": "ZhaoWanLong/maths-olympiad", "max_forks_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-08T07:04:43.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-08T07:04:43.000Z", "avg_line_length": 61.4915254237, "max_line_length": 385, "alphanum_fraction": 0.697629548, "num_tokens": 1227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.44959343210605257}}
{"text": "%!TEX root = ../notes.tex\n\\section{February 15, 2022}\n\n\\subsection{Cyclicity of Groups}\n\\subsubsection{mod odd \\texorpdfstring{$p$}{p}}\n\\recall from last class, we had \\cref{prop:d-roots}:\n\\begin{proposition*}\n    If $p$ is a prime and if $d\\mid p-1$, then the polynomial\n    \\[x^{d-1}\\in (\\ZZ/p\\ZZ)[x]\\] has exactly $d$ roots in the base field $\\FF_p = \\ZZ/p\\ZZ$.\n\\end{proposition*}\n\\begin{corollary}\\label{cor:generators-in-p}\n    $G:=(\\ZZ/p\\ZZ)^\\times$ is cyclic.\n\\end{corollary}\n\\begin{proof}\n    For $d\\mid (p-1)$, we write $\\psi(d)$ for the number of elements of $G$ having order $d$.\n\n    Proposition 2 implies that\\footnote{We throw in Lagrange's theorem, and essentially count the number of solutions to $x^d\\equiv 1$.}\n    \\[\\sum_{c\\mid d}\\psi(c) = d\\qquad(\\psi* i = \\id, \\psi = \\id * \\mu)\\]\n    M\\\"obius inversion gives\n    \\[\\psi(d) = \\sum_{c\\mid d}\\mu(c)\\frac{d}{c}.\\]\n    On the other hand, we have $\\id = \\phi * i\\Rightarrow \\phi = \\mu * \\id$. Thus $\\psi(d) = \\phi(d)$ for all $d\\mid (p-1)$.\n    So in particular, $\\psi(p-1) = \\phi(p-1)\\geq 1$ for any prime $p$.\n\\end{proof}\n\n\\subsubsection{mod odd power \\texorpdfstring{$p^e$}{p\\^e}}\n\\begin{theorem}\\label{thm:generators-in-powers-of-p}\n    Let $p\\in \\ZZ_+$ be an odd prime, and let $e\\geq 1$. Then $U(p^e)$ is cyclic.\n\\end{theorem}\nProof overview:\n\\begin{enumerate}[1.]\n    \\item Pick a primitive root mod $p$. We call it $g$ (for generator).\n    \\item Show that either $g$ or $g + p$ is a primitive root mod $p^2$.\n    \\item Show that if $h$ is any primitive root mod $p^2$, then $h$ is a primitive root mod $p^e$ $\\forall e\\geq 2$.\n\\end{enumerate}\n\\begin{proof}[Proof of \\cref{thm:generators-in-powers-of-p}]\n    ~\\begin{description}\n        \\item[Step 1.] Let $g$ be a primitive root modulo $p$ given by \\cref{cor:generators-in-p}.\n        \\item[Step 2.]  Let $d$ be the order of $g$ mod $p^2$. Since $\\phi(p^2) = p(p-1)$, we have that\n            \\[d\\mid p(p-1)\\qquad\\text{by Lagange}.\\]\n            By definition of $d$,\n            \\begin{align*}\n                g^d\\equiv 1\\mod{p^2}\n                \\intertext{so we also have}\n                g^d\\equiv 1\\mod{p}\n            \\end{align*}\n            Thus $(p-1)\\mid d$ since $g$ has order $p-1$ mod $p$. Altogether, $d$ is either $p-1$ or $p(p-1)$. If $d = p(p-1)$, then we are done with step 2. So we assume the former that $d = p-1$.\n\n            Let $h = g + p$. We know that $h$ is a primitive root mod $p$, so we do the same [yoga] as above and conclude that the order of $h$ mod $p^2$ is either $p-1$ or $p(p-1)$.\n\n            By our new hypothesis,\n            \\[g^{p-1}\\equiv 1\\pmod{p^2}\\]\n            so modulo $p^2$, we have\n            \\begin{align*}\n                h^{p-1} = (g+p)^{p-1} & = g^{p-1} + (p-1)g^{p-2}p + \\cdots + p^{p-1}\n                \\intertext{Modulo $p^2$, the only terms that survive are (expand and all $p^2$ terms die):}\n                                      & \\equiv 1 - pg^{p-2}\\pmod{p^2}\n            \\end{align*}\n            But $p\\nmid g$, so $pg^{p-2}\\not\\equiv 0\\mod{p}$, and hence $h^{p-1}\\not\\equiv 1\\mod{p^2}$. Thus the order of $h$ mod $p^2$ is $p(p-1)$, so $h$ generates $U(p^2)$.\n\n            So we are done with step $2$. If $g$ is a primitive root mod $p$, then either $g$ or $g + p$ is a primitive root mod $p^2$.\n        \\item[Step 3.] We wish to show that a primitive root mod $p^2$ is also a primitive root mod $p^e$ $\\forall e\\geq 2$. We induct on $e$.\n\n            Let $h$ be a primitive root mod $p^e$ for some fixed $e\\geq 2$. Let $d$ be the order of $h$ mod $p^{e+1}$. By Lagange, we have that $d\\mid \\phi(p^{e+1}) = p^e(p-1)$, and from step $2$,\n            \\[\\phi(p^e) = p^{e-1}(p-1)\\mid d\\]\n            Hence $d = p^e(p-1)$ or $p^{e-1}(p-1)$. If it's the former then we are done, so we assume latter.\n\n            We want to show that\n            \\[h^{p^{e-1}(p-1)}\\not\\equiv 1\\mod{p^{e+1}}\\]\n            implying that $d = p^e(p-1)$ after all.\n\n            Since $h$ has order $\\phi(p^e) = p^{e-1}(p-1)$ in $U(p^e)$, we have \\begin{equation}\n                h^{p^{e-2}(p-1)}\\not\\equiv 1\\mod{p^e} \\label{eqn:5.2-1}\\tag{$\\star$}\n            \\end{equation} However,\n            \\begin{equation}\n                h^{p^{e-2}(p-1)}\\equiv 1\\mod{p^{e-1}} \\label{eqn:5.2-2}\\tag{$\\star\\star$}\n            \\end{equation}\n            Combining \\cref{eqn:5.2-1} and \\cref{eqn:5.2-2} yields\n            \\[h^{p^{e-2}(p-1)}=1+kp^{e-1}\\]\n            where $p\\nmid k$. Therefore, we have\n            \\begin{align*}\n                h^{p^{e-1}(p-1)} & = (1+kp^{e-1})^p                                    \\\\\n                                 & = 1 + pkp^{e-1} + \\binom{p}{2}k^2p^{2e-2} + \\cdots\n                \\intertext{Subsequent terms are all divisible by $p^{3e-3}=(p^{e-1})^3$, and hence divisible by $p^{e+1}$ as $e(e-1)\\geq 2+1\\ \\forall e\\geq 2$. Thus\n                }\n                h^{p^{e-1}(p-1)} & = 1 + kp^e + \\frac{1}{2}k^2p^{2e-1}(p-1)\\mod{p^e+1}\n            \\end{align*}\n            $p$ is odd, so\n            \\[\\frac{1}{2}k^2p^{2e-1}(p-1)\\]\n            is divisible by $p^{e+1}$, since $2e-1\\geq e+1$. Thus\n            \\[h^{p^{e-1}(p-1)} \\equiv 1 + kp^e \\mod{p^e+1}\\]\n            Since $p\\nmid k$, we get that $kp^e\\not\\equiv 0$ so\n            \\[h^{p^{e-1}(p-1)} \\not\\equiv 1 \\mod{p^e+1}\\]\n            This proves that $d = p^e(p-1)$, which is to say that $h$ is a primitive root mod $p^{e+1}$.\n    \\end{description}\n    Altogether, we have that $U(p^e)$ is cyclic.\n\\end{proof}\n\n\\subsubsection{mod powers of 2}\n\\begin{theorem}\n    $U(2^e)$ is cyclic iff $e = 1$ or $e = 2$.\n\\end{theorem}\n\\begin{proof}\n    Clearly $U(2)$ and $U(4)$ are cyclic\\footnote{We don't have much choice since there is only one trivial group and one group of order $2$, both cyclic.}.\n\n    We show that $U(2^e)$ is \\emph{not} cyclic for all $e\\geq 3$. Notice: it suffices to show that $U(8)$ is not cyclic, since we can find group homomorphisms down powers of $2$.\n    \\[U(8) = \\{\\overline{1}, \\overline{3}, \\overline{5}, \\overline{7}\\}\\]\n    and $\\overline{1}^2 = \\overline{3}^2 = \\overline{5}^2 = \\overline{7}^2\\mod{8}$.\n\\end{proof}\n\n\\subsection{Classification of all cyclic unit groups}\n\\begin{corollary}\\label{cor:cyclicity-of-unit-groups}\n    $U(m)$ is cyclic if and only if $m = 1, 2, 4, p^e$ or $2p^e$ for some odd prime $p$.\n\\end{corollary}\n\\begin{proof}\n    Recall that a product $G$ of finite cyclic groups $G_1$ and $G_2$ is cyclic iff $(|G_1|, |G_2|) = 1$.\\footnote{Secretly, Chinese Remainder Theorem.} On the other hand, $\\phi(m)$ is even $\\forall m\\geq 3$. So only one of $G_1$ and $G_2$ needs odd power.\n\n    Combined with our structure theorems on $U(p^e)$ for primes $p$, this proves the corollary since these are the only possibilities.\n\\end{proof}", "meta": {"hexsha": "5acc677975be3800a8b2cd64027368d59fe018be", "size": 6722, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-02-15.tex", "max_stars_repo_name": "jchen/math1560-notes", "max_stars_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-02T15:41:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T20:28:48.000Z", "max_issues_repo_path": "lectures/2022-02-15.tex", "max_issues_repo_name": "jchen/math1560-notes", "max_issues_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-02-15.tex", "max_forks_repo_name": "jchen/math1560-notes", "max_forks_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.9661016949, "max_line_length": 256, "alphanum_fraction": 0.5531091937, "num_tokens": 2538, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7490872131147276, "lm_q1q2_score": 0.4495934253821279}}
{"text": "\\section{Using Python to Model the Earth's Atmosphere}\nThis stream Simon was not feeling that well and it felt like his brain was not working, so be wary of errors! You have been warned. also the resolutin (size of an individual cell on the latitude\nlongitude grid) has been decreased to 5 degrees per cell instead of 3 degrees.\n\n\\subsection{Interpolating the Air Density}\nIn order to interpolate (see \\autoref{sec:interpolation}) the air density, we need data. However currently we are just guessing the air density at higher levels, instead of taking real values. \nSo let us change that. For that we are going to use the U.S. Standard Atmosphere, an industry standard measure of the atmosphere on Earth \\cite{usatmosp}. This data was provided in a text \n(\\texttt{TXT}) file which of course needs to be read in order for the data to be used in the model. Here we only care for the density and the temperature at a specific height. So the text file \nonly contains those two columns of the data (and the height in km of course as that is the index of the row, the property that uniquely identifies a row).\n\nWith that in mind, let's get coding and importing the data. We do this in \\autoref{alg:usatmosp}. As one can see we do not specify how to open the file or how to split the read line, as this \nis language specific and not interesting to describe in detail. I refer you to the internet to search for how to open a text file in the language you are working in. Keep in mind in which \nmagnitude you are working and in which magnitude the data is. If you work with $km$ for height and the data is in $m$, you need to account for that somewhere by either transforming the imported \ndata or work in the other magnitude. \n\n\\begin{algorithm}\n    $data \\leftarrow \\text{open text file containing the us standard atmosphere data}$ \\;\n    \\ForEach{$line \\in data$}{\n        Split $line$ into three components, $sh, st$ and $sd$, representing the height, temperature and density respectively \\;\n        $standardHeight.add(sh)$ \\;\n        $standardTemperature.add(st)$ \\;\n        $standardDensity.add(sd)$ \\;\n    }\n\n    $densityProfile \\leftarrow \\texttt{interpolate}(heights, standardHeight, standardDensity)$ \\;\n    $temperatureProfile \\leftarrow \\texttt{interpolate}(heights, standardHeight, standardTemperature)$ \\;\n\n    \\For{$alt \\in [0, nlevels]$}{\n        $\\rho[:, :, alt] \\leftarrow densityProfile[alt]$ \\;\n        $T_a[:, :, alt] \\leftarrow temperatureProfile[alt]$ \\;\n    }\n    \\caption{Loading in the U.S. Standard Atmosphere}\n    \\label{alg:usatmosp}\n\\end{algorithm}\n\nNote that the function \\texttt{interpolate} takes three arguments, the first one being the data points that we want to have values for, the second one is the data points that we know and the \nthird one is the values for the data points that we know. This function may or may not exist in your programming language of choice, which might mean that you have to write it yourself. \nThe formula that we use for interpolation can be found in \\autoref{eq:interpolation}, though you still need to figure out what value you need for $\\lambda$ (see \\autoref{sec:interpolation}). \nThis is left as an exercise for the reader.\n\n\\subsection{Fixing Vertical Motion}\nAnother attempt was made at fixing the vertical motion. The changes are incorporated in \\autoref{alg:advection layer}. Do keep in mind that the low air density in the upper layers messes a lot \nwith the vertical motion. In other words, it kinda works but not really. Another idea to help fix it, is to introduce a variable called $top$ which indicates the highest point that the \natmosphere may have. This value is initialised as $8 \\cdot 10^3$ in meters (so 8 $km$). We then change the definition of $heights$ to: An array of uniform thickness of $\\frac{top}{nlevels} m$.\nWe also added the $\\delta z$ to \\autoref{alg:temperature layer} as that was something that was still missing.\n\nThe current theory why the vertical velocity is not right is that the vertical thermodynamics may be wrong. This will be investigated further and we will report on this in future sections.", "meta": {"hexsha": "95aa9e6febb37acb6fc82fe21cbec71c2c8d0d1c", "size": 4097, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex-docs/streams/Stream7.tex", "max_stars_repo_name": "balintf/claude", "max_stars_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex-docs/streams/Stream7.tex", "max_issues_repo_name": "balintf/claude", "max_issues_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex-docs/streams/Stream7.tex", "max_forks_repo_name": "balintf/claude", "max_forks_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.170212766, "max_line_length": 194, "alphanum_fraction": 0.7559189651, "num_tokens": 969, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4495639309005669}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{cite}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{algorithmic}\n\\usepackage{graphicx}\n\\usepackage{import}\n\\usepackage{textcomp}\n\\usepackage{xcolor}\n\\usepackage{balance}\n\\usepackage{geometry}\n\\geometry{legalpaper,\nportrait,\nmargin=2in,\nlmargin = 2cm,\nrmargin = 2cm,\n}\n\n\\usepackage{multirow} % for tables with complicated header\n\n\\usepackage{booktabs,makecell,tabularx}\n\\renewcommand\\theadfont{\\small}\n\\renewcommand\\theadgape{}\n\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\n\\begin{document}\n\n\\newcommand{\\diag}{\\operatorname{diag}}\n\\newcommand{\\E}{\\operatorname{E}} % expectation\n\\newcommand{\\tr}{\\operatorname{tr}} % trace\n\\newcommand{\\iDFT}{\\operatorname{IDFT}} % \n\\newcommand{\\DFT}{\\operatorname{DFT}} % \n\\newcommand{\\iFFT}{\\operatorname{IFFT}} % \n\\newcommand{\\iSFFT}{\\operatorname{ISFFT}} % \n\\newcommand{\\SFFT}{\\operatorname{SFFT}} % \n\\newcommand{\\FFT}{\\operatorname{FFT}} % \n\\newcommand{\\suma}{\\operatorname{sum}} % \n\n\\title{Full-rate STLC for Four Receive Antennas - Notes }\n\\author{radim.zedka@vut.cz }\n\\date{March 2022}\n\\maketitle\n\n\n% =================================================\n\\section{Problem Description}\n\nFormula (6) in \\cite{b_FullRate_STLC} is given by\n\\begin{equation} \\label{eq_xi_orig}\n    \\xi = \\rho \\frac{\\Big( \\sum_{p=0}^{M-1} \\gamma_{p} \\pm 2\\mathcal{R}\\big\\{ \\epsilon_p\\big\\} \\Big)^2}{4\\sum_{p'=0}^{M-1}\\gamma_{p'}},\n\\end{equation}\n% \\begin{equation} \\label{eq_xi_orig}\n%     \\xi = \\rho \\frac{\\frac{M^2}{M^2}\\Big( \\sum_{p=0}^{M-1} \\gamma_{p} \\pm 2\\mathcal{R}\\big\\{ \\epsilon_p\\big\\} \\Big)^2}{4\\sum_{p'=0}^{M-1}\\gamma_{p'}} = \\rho \\frac{M^2\\Big( \\frac{1}{M}\\sum_{p=0}^{M-1} \\gamma_{p} \\pm 2\\frac{1}{M} \\mathcal{R}\\big\\{ \\epsilon_p\\big\\} \\Big)^2}{4\\sum_{p'=0}^{M-1}\\gamma_{p'}}\\ \\overrightarrow{\\text{for high }M}\\ = \\frac{\\rho}{4} \\sum_{p=0}^{M-1} \\gamma_{p},\n% \\end{equation}\n% \\begin{equation} \\label{eq_xi_orig}\n%     \\lim_{M\\to\\infty} \\xi = \\frac{\\rho}{4} \\sum_{p=0}^{M-1} \\gamma_{p}\n% \\end{equation}\n% \\begin{equation} \\label{eq_xi_orig}\n%     \\lim_{M\\to\\infty} \\frac{1}{M} \\sum_{p=0}^{M-1} \\mathcal{R}\\big\\{ \\epsilon_p\\big\\} = 0 \n% \\end{equation}\nwhere \n\\begin{equation} \\label{eq_gamma_p}\n    \\gamma_p = \\sum_{q=0}^{3} |h_{p,q}|^2,\n\\end{equation}\nand\n\\begin{equation} \\label{eq_epsilon_p}\n    \\epsilon_p = h_{p,0}h_{p,2}^* + h_{p,1}h_{p,3}^*.\n\\end{equation}\nEach complex channel gain $h_{p,q}$ is composed of two i.i.d. normal variables $a_{p,q}, b_{p,q} \\sim \\mathcal{N}(0,1/2)$ which relate to channel gain by $h_{p,q} = a_{p,q} + jb_{p,q}$, where $j = \\sqrt{-1}$.\nFormula \\eqref{eq_gamma_p} then evolves into\n\\begin{equation} \\label{eq_gamma_p_2}\n    \\gamma_p = \\sum_{q=0}^{3} |a_{p,q}|^2 + |b_{p,q}|^2,\n\\end{equation}\nand $\\mathcal{R}\\big\\{ \\epsilon_p\\big\\}$ is expressed as\n\\begin{equation} \\label{eq_epsilon_p_2}\n    \\mathcal{R}\\big\\{ \\epsilon_p\\big\\} = a_{p,0}a_{p,2} + b_{p,0}b_{p,2} + a_{p,1}a_{p,3} + b_{p,1}b_{p,3}.\n\\end{equation}\nFormula \\eqref{eq_xi_orig} may be expanded into purely real-valued form\n\\begin{equation} \\label{eq_xi_2}\n    \\xi = \\frac{\\rho}{4} \\frac{\\Big( \\sum_{p=0}^{M-1} \\sum_{q=0}^{3} |a_{p,q}|^2 + |b_{p,q}|^2 \\pm 2\\mathcal{R}\\big\\{ \\epsilon_p\\big\\} \\Big)^2}{ \\sum_{p'=0}^{M-1} \\sum_{q=0}^{3} |a_{p',q}|^2 + |b_{p',q}|^2}.\n\\end{equation}\nAfter Lemma 1 in \\cite{b_FullRate_STLC} the receiver SNR is calculated via\n\\begin{equation} \\label{eq_xi_Lemma}\n    \\xi =  \\frac{\\rho}{4} \\sum_{p=0}^{M-1} \\sum_{q=0}^{3} |a_{p,q}|^2 + |b_{p,q}|^2 .\n\\end{equation}\n\n% =================================================\n\\section{MATLAB Simulation}\n\nIn MATLAB I created a script which generates the normal-distributed variables $a_{p,q}$ and $b_{p,q}$ in vectors of $10^7$ samples each. This way I calculate the histogram of formula \\eqref{eq_xi_2} and I attempt to approximate it with Gamma distribution with PDF given by\n\\begin{equation}\\label{eq_Gamma_PDF}\n f_{\\Xi}(\\xi) =  \\frac{\\xi^{nM - 1} e^{-\\frac{\\xi m}{2}}}{ (2/m)^{nM} \\cdot \\Gamma(nM)} \\quad \\forall \\quad \\xi \\in \\langle 0, \\infty).\n\\end{equation}\nwhere $n$ is related to the shape parameter and $m$ to the Gamma scale parameter. Please note that for PDF approximations I set $\\rho = 1$.\nAs the error metric of the PDF approximation I used mean-squared-error defined as\n\\begin{equation}\\label{eq_PDF_error_metric}\n J = \\int \\big( f_{\\Xi}(\\xi)' - f_{\\Xi}(\\xi) \\big)^2 d\\xi,\n\\end{equation}\nwhere $f_{\\Xi}(\\xi)'$ is the simulated data histogram and $f_{\\Xi}(\\xi)$ is the approximation.\n\nDiversity gain of systems approximated by Gamma distribution is given by\n\\begin{equation}\\label{eq_DivGain_limit}\n\\kappa = -\\lim_{\\rho \\to \\infty}\\frac{d \\log_{10}(\\bar{\\varepsilon}(\\rho))}{d \\log_{10}(\\rho)} = nM,\n\\end{equation}\nwhere $\\bar{\\varepsilon}(\\rho)$ is the average bit error rate at given $\\rho$ and $n$ is the diversity gain coefficient. Table~\\ref{table:1} then summarizes PDF approximation parameters $n$, $m$ for several values of $M$.\n\n\n\\begin{table}[t]\n\\caption{PDF fitting parameters of \\eqref{eq_xi_2} at given $M$}\n\\label{table:1}\n\\centering\n\\small\n\\begin{tabular} {|c|c|c|c|} \n\\toprule\n\\thead {$M$} & \\thead {$m$ } & \\thead {$n$ } & \\thead {$J$ [dB] }  \\\\\n    \\midrule\n$1$ & $1.530445$ & $0.949676$  & $-41.6985$\\\\ \n$2$ & $1.574221$ & $0.886598$  & $-46.4452$\\\\ \n$4$ & $1.596783$ & $0.847111$  & $-55.8000$\\\\ \n$8$ & $1.600477$ & $0.824861$  & $-58.9625$\\\\ \n$16$ & $1.606456$ & $0.815408$  & $-60.4560$\\\\ \n$32$ & $1.610120$ & $0.811129$  & $-61.2368$\\\\ \n$64$ & $1.608200$ & $0.807196$  & $-63.6193$\\\\ \n$128$ & $1.613510$ & $0.808271$  & $-62.2914$\\\\ \n$256$ & $1.612725$ & $0.807231$  & $-64.0791$\\\\ \n$512$ & $1.610609$ & $0.805685$  & $-66.8909$\\\\ \n    \\bottomrule\n    \\end{tabular}\n\\end{table}\n\nFigures \\ref{fig_PDF_M1} to \\ref{fig_PDF_M512} I present the results for $M = \\{1,32,64,256,512\\}$ where formula \\eqref{eq_xi_2} is fitted by \\eqref{eq_Gamma_PDF} with $m$ and $n$ according to Table~\\ref{table:1}.\n\n\n\\begin{figure}[!h] \\centering\n\\includegraphics[scale=0.8]{images/PDF_M_1.eps}\n\\caption{PDF of \\eqref{eq_xi_2} approximated by \\eqref{eq_Gamma_PDF} for $M=1$. }\n\\label{fig_PDF_M1}\n\\end{figure}\n\n\\begin{figure}[!h] \\centering\n\\includegraphics[scale=0.8]{images/PDF_M_32.eps}\n\\caption{PDF of \\eqref{eq_xi_2} approximated by \\eqref{eq_Gamma_PDF} for $M=32$ . }\n\\label{fig_PDF_M32}\n\\end{figure}\n\n\\begin{figure}[!h] \\centering\n\\includegraphics[scale=0.8]{images/PDF_M_64.eps}\n\\caption{PDF of \\eqref{eq_xi_2} approximated by \\eqref{eq_Gamma_PDF} for $M=64$ . }\n\\label{fig_PDF_M64}\n\\end{figure}\n\n\\begin{figure}[!h] \\centering\n\\includegraphics[scale=0.8]{images/PDF_M_256.eps}\n\\caption{PDF of \\eqref{eq_xi_2} approximated by \\eqref{eq_Gamma_PDF} for $M=256$ . }\n\\label{fig_PDF_M256}\n\\end{figure}\n\n\\begin{figure}[!h] \\centering\n\\includegraphics[scale=0.8]{images/PDF_M_512.eps}\n\\caption{PDF of \\eqref{eq_xi_2} approximated by \\eqref{eq_Gamma_PDF} for $M=512$ . }\n\\label{fig_PDF_M512}\n\\end{figure}\n\n% \\begin{figure}[!h]\n% \\begin{tabular}{ll}\n% \\includegraphics[scale=0.53]{images/PDF_M_32.eps}\n% &\n% \\includegraphics[scale=0.53]{images/PDF_M_64.eps}\n% \\end{tabular}\n% \\caption{PDF of \\eqref{eq_xi_2} and \\eqref{eq_xi_Lemma} with scaled chi-squared PDFs \\eqref{eq_ChiSquared_PDF_scaled} for $M=32$ and $M=64$. }\n% \\label{fig_PDF_1}\n% \\end{figure}\n\n% \\begin{figure}[!h]\n% \\begin{tabular}{ll}\n% \\includegraphics[scale=0.53]{images/PDF_M_256.eps}\n% &\n% \\includegraphics[scale=0.53]{images/PDF_M_512.eps}\n% \\end{tabular}\n% \\caption{PDF of \\eqref{eq_xi_2} and \\eqref{eq_xi_Lemma} with scaled chi-squared PDFs \\eqref{eq_ChiSquared_PDF_scaled} for $M=256$ and $M=512$. }\n% \\label{fig_PDF_2}\n% \\end{figure}\n\n% =================================================\n\\section{Discussion}\n\nMy MATLAB simulation attepts show that \\eqref{eq_xi_2} is close to Gamma distribution with $n = 0.8$ and $m = 1.6$. The diversity gain is for Gamma distribution directly given by $nM$. Parameter $n$ is decreasing with increasing value of $M$ and it is approaching $n \\sim 0.8$.   \nI would be very grateful for your advice.\n\n\n% ======================== References ====================\n\\begin{thebibliography}{00}\n\n\\bibitem{b_FullRate_STLC} S. -chan Lim and J. Joung, “Full-Rate Space–Time Line Code for Four Receive Antennas”, IEEE wireless communications letters, pp. 1-1, 2021.\n\n\\end{thebibliography}\n\n\n\\end{document}", "meta": {"hexsha": "3ea028d4e19c44227dc7703607c647815e7b23c8", "size": 8344, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/Full_rate_STLC_for_Four_Receive_Antennas___Notes.tex", "max_stars_repo_name": "rzedka/QOSTLC-1", "max_stars_repo_head_hexsha": "a0e442ddef84245f11a3a71843c5e4d1af282027", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documentation/Full_rate_STLC_for_Four_Receive_Antennas___Notes.tex", "max_issues_repo_name": "rzedka/QOSTLC-1", "max_issues_repo_head_hexsha": "a0e442ddef84245f11a3a71843c5e4d1af282027", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/Full_rate_STLC_for_Four_Receive_Antennas___Notes.tex", "max_forks_repo_name": "rzedka/QOSTLC-1", "max_forks_repo_head_hexsha": "a0e442ddef84245f11a3a71843c5e4d1af282027", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.72, "max_line_length": 387, "alphanum_fraction": 0.6592761266, "num_tokens": 3298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.449563926370993}}
{"text": "% Chapter Template\n\n\\chapter{Background Information and Theory} % Main chapter title\n\n\\label{Chapter2} % Change X to a consecutive number; for referencing this chapter elsewhere, use \\ref{ChapterX}\n\n%----------------------------------------------------------------------------------------\n%\tSECTION 1\n%----------------------------------------------------------------------------------------\n\n\\section{Machine Learning}\n% \\begin{note}\n%   \\begin{itemize}\n%     \\item Una definición rápida\n%     \\item Clasificación y regresión\n%     \\item Cross-validation\n%     \\item Qué son los datos de train y test, y por qué se hace esa partición\n%     \\item Qué es el sobre-ajuste\n%   \\end{itemize}\n% \\end{note}\n\n\\begin{pre-delivery}\n  % Machine Learning uses statistical and mathematical models to give answers to\n  % problems when there is no known formula of procedure to compute the answer.\n\n  Machine Learning uses statistical and mathematical models to give\n  computational answers based on data to problems when there is no known\n  formula of procedure.\n\n  In the subfield of Supervised Learning, the objective is to predict a numerical\n  or categorical variable in response to some input data, and the way of doing\n  it is to feed the model with lots of different examples for which we already\n  know the correct answer, and we expect the models to be able to predict\n  the correct answer to instances that it hasn't seen before. When it does,\n  we say that the model is able to generalize.\n\n  When a model is trained with some data, there is always a risk of overfitting\n  \\cite{hawkins2004problem}.\n  For a model to overfit means that it adjusts very well to the data that is\n  has seen, but can't predict the correct answer to new, unseen data.\n  % This\n  % happens because it has not only from the relevant information, but also\n  % from the random noise that the data had, and so it can only memorise, but\n  % not generalize.\n  This happens because it has not only fitted the relevant information,\n  but also random noise present in the data sample, and thus it generalizes\n  poorly. In the extreme case of ovefitting, the model tends to memorise the\n  data sample.\n\n  For this reason, when a Machine Learning algorithm is trained the data\n  is split in two subsets, a \\textit{Training  dataset} and a \\textit{Testing\n  dataset}. The training dataset will be used to train the model, while the\n  Testing datasets will be used only to check it. If a model has generalized\n  well, it will achieve a good accuracy score on both the training and the\n  testing dataset, but if it has overfitted it will show good results in the\n  training dataset and bad ones in the testing dataset.\n\n  Many models need some parameters to tune the behaviour of the algorithm. For\n  example, some of them are used to adjust how much a model will fit to the data.\n  We usually call these ``hyperparameters''. The correct value for them is not\n  straightforward, and it is normally chosen with a resampling process called\n  ``cross-validation''\\cite{geisser2017predictive}. This process consists of\n  splitting the training dataset\n  in many subsets and check many possible values for the hyperparameters in order\n  to see which one gets a higher accuracy with unseen data.\n\\end{pre-delivery}\n\n\\section{Some currently used Machine Learning models}\n\n\n% \\begin{note}\n  % \\section{Review de los principales modelos que existen}\n% \\end{note}\n  \\subsection{Decision Tree}\n  \\label{sec:dec-tree}\n  % \\begin{note}\n  %   \\begin{itemize}\n  %     \\item No se basa en productos escalares\n  %     \\item Es extremadamente rápido\n  %     \\item Es más fácil de interpretar que otros modelos\n  %     \\item Es extremadamente inestable\n  %     \\item Cuando se hace un Random Forest, se randommiza un poco, de modo que\n  %     árboles distintos entrenados con los mismos datos pueden ser destintos\n  %     \\item Es un modelo no lineal\n  %   \\end{itemize}\n  % \\end{note}\n  \\begin{pre-delivery}\n    Decision Tree\\cite{breiman2017classification}\\cite{lewis2000introduction}\n    is a predictive model which uses\n    the training data to build\n    a tree where each node splits the data in two sets according to some\n    feature, and the leafs contain the set of instances that belong to some class\n    (in classification problems) or that has a similar numerical response variable\n    (for regression problems).\n\n    To predict the answer to a new instance, it uses the features to ``decide''\n    the nodes to cross until it reaches a leaf. The response given is the\n    most prevailing class in the leaf for classification problems, or the mean\n    of the values of the rest of the instances in the leaf.\n\n    To decide what feature to use to split a node in two subsets, it uses\n    the Gini impurity: it will pick the feature that minimises the sum of\n    the Gini impurity of the two child nodes. Given a node with instances\n    belonging to $k$ classes, if $p_i$ is the proportion of instances that\n    belong to class $i$, the Gini impurity of the node is\n    $1 - \\sum_{i = 1}^k p_i^2$.\n\n    Decision Trees have the advantages that it is easy to interpret the\n    tree produced and that it is very fast to build the tree. The way to avoid\n    overfitting is to limit its growth.\n\n    These models are very unstable. This means that small differences in the\n    training data can produce very different Decision Trees. This property\n    is very useful to build an ensemble of estimators to produce better answers.\n    Random Forest is an algorithm that trains many Decision Trees with some sort\n    of randomization.\n  \\end{pre-delivery}\n  \\subsection{Logistic Regression}\n  \\label{ssec:log-reg}\n  \\begin{pre-delivery}\n    Logistic Regression\\cite{cox1958regression} models the probability that an instance belongs to\n    a class, and predicts the class with a higher probability. To do so it\n    uses the \\textit{logistic sigmoid function}\\cite{han1995influence}, defined by:\n\n    \\begin{equation}\n      \\sigma(a) = \\frac{1}{1 + exp(-a)}\n    \\end{equation}\n\n     Once the vector $w \\in \\reals^d$ has been found, the predicted probability\n     that an instance $\\vx \\in \\reals^d$ belongs to a class is\n     $y(\\vx) = \\sigma(w^\\transp\\vx)$.\n\n     % To find a suitable $w$ it solves an optimization problem of finding $w$\n     % that maximizes the likelihood that each of the instances belongs to the\n     % specified class\n\n     Given\n     $D = \\{\\bm{\\chi}, \\bm{t}\\}$\n     , where\n     $\\bm{\\chi} = \\{\\bm{x}_1, \\ldots \\bm{x}_n\\}$, $\\bm{x}_i \\in \\reals^d$, $\\bm{t} = \\{0, 1\\}^n$\n     it tries to maximize a likelihood function that can be written\n\n     \\begin{equation}\n       p(\\bm{t} | w) = \\prod_{i = 1}^n y_i^{\\bm{t}_i} (1 - y_i)^{1 - \\bm{t}_i}\n     \\end{equation}\n\n     where $y_i = \\sigma(w^\\transp\\vx_i + w_0)$.\n     % , the problem is to find $w \\in \\reals^d$ and $c \\in \\reals$ that minimizes\n\n     % \\begin{equation}\n     %   \\frac{1}{2}w^\\transp w + \\sum_{i = 1}^n log\\left( exp\\left( -y_i(\\vx_i^\\transp w + c) \\right) + 1\\right)\n     % \\end{equation}\n  \\end{pre-delivery}\n  \\subsection{Support Vector Machines}\n  \\label{ssec:svm}\n  % \\begin{note}\n  %   \\begin{itemize}\n  %     \\item Inicialmente pensadas para clasificación en 2 clases\n  %     \\item Pero se puede más clases con \\eng{one-vs-rest} y también hay\n  %     formas de hacer regresión\n  %     \\item Se basa únicamente en el producto escalar de sus entradas\n  %     \\item Intenta separar los datos con un híper-plano\n  %     \\item Actualmente es poco eficiente usarlas porque su coste s cúbico\n  %     con la cantidad de entradas.\n  %     \\item Las fórmulas que quiere optimizar\n  %   \\end{itemize}\n  % \\end{note}\n\n  \\begin{pre-delivery}\n    Support Vector Machine\\cite{Cortes1995} (SVM) is a model that finds in hyperplane that\n    divides the data in two sets. In two-class classification problems, each\n    side of the hyperplane contains the instances of each of the classes.\n    It does so by converting the problem to an optimization one.\n\n    Given some data\n    $D = \\{\\bm{\\chi}, \\bm{y}\\}$\n    , where\n    $\\bm{\\chi} = \\{\\bm{x}_1, \\ldots \\bm{x}_n\\}$, $\\bm{x}_i \\in \\reals^d$, $\\bm{y} = \\{-1, +1\\}^n$\n    , the optimization problem consists on finding $\\bm{\\alpha} \\in \\reals^n$\n    the maximises\n\n\\begin{equation}\n  L = \\sum_{i = 1}^n\\alpha_i -\\frac{1}{2}\\sum_{i = 1}^n\\sum_{j = 1}^n\\alpha_i\\alpha_jy_iy_j\\vx_i^\\transp\\vx_j\n\\end{equation}\n\nsubject to\n\n\\begin{align}\n  0 \\leq \\alpha_i \\leq C; \\forall i\\\\\n  \\sum_{i = 1}^n \\alpha_iy_i = 0\n\\end{align}\n\n% $C$ is an hyperparameter to tune the amount of penalization for miss-classified\n% instances.\n\n$C$ is an hyper-parameter to tune the amount of penalization for missclassified\ninstances or instances located within the margin zone.\n\nIf we compute\n\\begin{equation}\n  w = \\sum_{i = 1}^n\\alpha_iy_i\\vx_i\n\\end{equation}\nand\n\n\\begin{equation}\n  b = y_i - w\\cdot\\vx_i\n\\end{equation}\nfor any $i$ so that $\\alpha_i \\neq 0$, we can compute the class of $\\vx_0$ with\n\n\\begin{equation}\nsign(w\\cdot\\vx_0 + b)\n\\end{equation}\n\nNote that this algorithm just uses the dot product of the input data, not the\ndata itself. This property allows us to use the Kernel Trick with them.\nSee \\ref{sec:kern-trick}\n\n\\end{pre-delivery}\n\n\n\\section{Ensemble Methods}\n\\label{sec:ens-meth}\n  % \\subsection{Bagging}\n    % \\begin{note}\n    %   \\begin{itemize}\n    %     \\item Bagging\n    %     \\begin{itemize}\n    %       \\item Inventado por Leo Breiman (referencia)\n    %       \\item Pretende reducir el sesgo\n    %       \\item Wikipedia dice que pretende reducir la varianza\n    %       \\item Es el boosting el que pretende reducir el sesgo\n    %       \\item Entrenamiento de los estimadores es independiente, se podría\n    %       hacer en paralelo\n    %       \\item Actualmente casi solo se usa con DT, debido a su inestabilidad\n    %     \\end{itemize}\n    %     \\item Bootstrap\n    %     \\begin{itemize}\n    %       \\item Intenta solucionar el problema de que para bagging es bueno\n    %       que los estimadores sean distintos\n    %       \\item Idealmente usaríamos un dataset distinto para cada estimador\n    %       \\item Consiste en hacer un resalmpling con repetición\n    %       \\item Si la cantidad de instancias del original es la misma que la de cada uno\n    %       de los subconjuntos, se espera que la proporción de elementos úncos sea de\n    %       $1 - \\frac{1}{e} \\approx 0.632$.\n    %       \\item Si el conjunto original tiene $n$ elementos, y tu haces un subconjunto\n    %       de tamaño $r$, puedes esperar que la proporción de elementos del original que\n    %       sí tienen presencia en el nuevo sea de $1 - e^{-\\frac{r}{n}}$\n    %     \\end{itemize}\n    %     \\item Random Forest\n    %   \\end{itemize}\n    % \\end{note}\n\n  \\begin{pre-delivery}\n    Ensemble methods\\cite{polikar2006ensemble} are a technique used in Machine\n    Learning to reduce the\n    overall accuracy error of a basic classification or regression model. The\n    idea is that a commimtee of models is expected to learn better than a single\n    one.\n\n    Some ensemble methods are focused on decreasing the error caused by the\n    variance of the model. One example is \\textit{Bagging}\\cite{breiman1996bagging}. Others are focused\n    on decreasing the bias error, like \\textit{Boosting}\\cite{freund1997decision}.\n\n    In Bagging, every model in the ensemble vote with equal weight. Thus, it is\n    important to promote the variance among each of the models, since not doing\n    it would be equivalent to training just one model. Ideally, one would train\n    each of the models with totally different datasets, with no correlation\n    among them. But in practice this is not always possible, because of a\n    limited number of instances to train. One alternative is to use a\n    technique called \\textit{Bootstrap}\\cite{efron1994introduction}. Bootstrap allows to generate\n    many different instances of a dataset by performing a resampling.\n\n    Given a dataset $D$ of size $n$, Bootstrap generates $m$ new datasets\n    $D_i$ of size $n$ by sampling instances from $D$ uniformly and with\n    replacement. This means that some of the instances in $D$ may be repeated\n    in $D_i$, and others may not appear at all. With a large $n$, it is expected\n    that each dataset $D_i$ will contain $63.2 \\% $ of the instances in $D$.\n\n    Theoretically Bagging could be used with any kind of method. However, for\n    most of them Bootstrap is not enough to decorrelate the estimators.\n    In practice, Bagging is mostly used with Decision Tree, given that this\n    method produces very different trees with a small variation in the data.\n    Random Forest\\cite{Breiman2001} is an algorithm that trains many Decision Trees with a\n    Bagging. Instead of building the tree in a deterministic way, in each\n    split it chooses a random subset of features on which to perform the\n    separation. Besides, it lets the estimators overfit, since it has a positive\n    impact in reducing the overall variance of the Forest.\n  \\end{pre-delivery}\n\n\\section{The kernel trick}\n\\label{sec:kern-trick}\n\n\n\n\n% \\begin{note}\n%   \\begin{itemize}\n%     \\item Teorema de Bochner\n%     \\item El kernel RBF\n%     \\begin{itemize}\n%       \\item Su fórmula es \\ldots\n%       \\item Equivalencia entre $\\gamma$ y $\\sigma$\n%       \\item La noción de similitud que tiene\n%       \\item \\Hspace\\ es de dimensionalidad infinita\n%       \\item Permite ajustarse infinitamente a los datos, tuneando el\n%       híper-parámetro\n%       \\item $\\sigma$ más pequeño, más sobreajuste\n%       \\item $\\gamma$ más grande, más sobreajuste\n%     \\end{itemize}\n%   \\end{itemize}\n% \\end{note}\n\n\\begin{pre-delivery}\n  A Kernel\\cite{bergman1970kernel} is a function that equals to the inner product of inputs mapped into\n  some Hilbert Space\n  \\footnote{A Hilbert space is a generalization of the Euclidean Space which contains\n  the structure of an inner product that allows length and angle to be\n  measured.}\n  , i.e:\n  \\begin{equation}\n  \\kernel(x,y) = \\phi(x)\\cdot\\phi(y)\n\\end{equation}\n% A Hilbert space is just a generalization of the Euclidean Space which contains\n% the structure of an inner product that allows length and angle to be measured.\n\nThey are interesting in Machine Learning because we don't need to know the\nexplicit function $\\phi(\\cdot)$. In fact, $\\phi(\\cdot)$ could map the data to\na Hilbert Space with infinite dimensions, and we could still compute\n$\\phi(\\vx)\\cdot\\phi(\\vy)$ through the kernel $\\kernel$\n\nSupport Vector Machines (explained in \\ref{ssec:svm}) can benefit a lot of\nKernel Functions. SVMs solve an\noptimization problem to maximise\n\n\\begin{equation}\n  L = \\sum_{i = 1}^n\\alpha_i -\\frac{1}{2}\\sum_{i = 1}^n\\sum_{j = 1}^n\\alpha_i\\alpha_jy_iy_j\\vx_i^\\transp\\vx_j\n\\end{equation}\n\nin order to find an hyperplane that separates the data points in two classes.\nBut with some problems there may not exist such hyperplane, and so it would\nbe needed to map the data to a different feature space. If we did that, then\nthe function to maximise would be\n\n\\begin{equation}\n  L = \\sum_{i = 1}^n\\alpha_i -\\frac{1}{2}\\sum_{i = 1}^n\\sum_{j = 1}^n\\alpha_i\\alpha_jy_iy_j\\phi(\\vx_i)^\\transp\\phi(\\vx_j)\n\\end{equation}\n\nAs we said previously, SVMs don't work with the data points alone, but just with\ntheir inner products. Thus, a Kernel could be used to define the optimization\nproblem as\n\n\\begin{equation}\n  L = \\sum_{i = 1}^n\\alpha_i -\\frac{1}{2}\\sum_{i = 1}^n\\sum_{j = 1}^n\\alpha_i\\alpha_jy_iy_j\\kernel(\\vx_i, \\vx_j)\n\\end{equation}\n\nThis approach has one big advantage:\n% first, we don't need to explicitly\n% compute $\\phi(\\vx)^\\transp\\phi(\\vy)$, which could have a high cost if the\n% new dimensionality was too big.\nas long as the learning technique relies\nonly on the inner product of the input, the underlying mapping $\\phi(\\cdot)$\ndoes not need to be explicitly calculated and can, in fact, be unknown\\cite{burges1998tutorial}.\n\nKernel functions can be characterised with the Mercer's condition\n\\cite{mercer1909functions}. It says that given a function $\\kernel(\\vx, \\vy)$,\nthere exists a mapping $\\phi(\\cdot)$ so that\n$\\kernel(\\vx, \\vy) = \\phi(\\vx)\\cdot\\phi(\\vy)$\nif and only if for any $g(\\vx)$ such that $\\int g(\\vx)^2 d\\vx$ is finite then\n$\\int \\kernel(\\vx, \\vy)g(\\vx)g(\\vy) \\geq 0$.\n\nThere are many known Kernels. One that is very popular is the Radial Basis\nFunction Kernel\\cite{vert2004primer}, RBF. This kernel is defined as:\n\\begin{equation}\n\\kernel(\\vx,\\vy) = \\semiRbf\n\\end{equation}\nwhere $\\gamma > 0$ is a free parameter. The value of this Kernel decreases with the\neuclidean distance of the parameters, so it can be interpreted as a measure\nof similarity. The feature space of this kernel has infinite number of\ndimensions.\n\nWhen a kernel is used with an SVM, the answer can be computed with\n\n\\begin{equation}\nsign\\left(\\sum_{i = 1}^n \\alpha_iy_i\\kernel(\\vx_i, \\vx)\\right)\n\\end{equation}\nSVMs using the RBF kernel have a huge ability to fit to the data, and is able\nto separate classes for very difficult problems. The problem is that the\noptimization of the function\n\n\\end{pre-delivery}\n  % \\subsection{The RBF kernel}\n\n\\section{Random Fourier Features}\n\n% \\begin{note}\n%   \\begin{itemize}\n%     \\item Teorema de bochner\n%     \\item Tiene que ser un shift invariant kernel\n%     \\item Es más, tiene que ser un positive definite shift-invariant kernel\n%     \\item Converge bounds for ability to approximate\n%     \\item Instead, we propose to factor the kernel function itself\n%     \\item La factorización no depende de los datos\n%     \\item we propose explicitly mapping\n% the data to a low-dimensional Euclidean inner product space using a randomized feature map z :\n% Rd --> RD so that the inner product between a pair of transformed points approximates their kernel\n% evaluation\n% \\item Puesto que los valores están entre -1 y 1, hay un teorema que asegura\n% la convergencia exponencial hacia el kernel real\n%   \\end{itemize}\n% \\end{note}\n\n\\begin{pre-delivery}\n  A kernel function\n  $\\kernel(\\vx, \\vy)$ with $\\vx, \\vy \\in \\reals^d$\n  equals the inner product of inputs mapped with some function $\\phi(\\cdot)$,\n  so that\n  $\\phi(\\vx)^\\transp\\cdot\\phi(\\vy) = \\kernel(\\vx, \\vy)$.\n  But $\\phi(\\cdot)$ could be a mapping to an infinitely-dimensional space, so\n  calculating $\\phi(\\vx)$ is not possible for some kernels.\n\n  Random Fourier Features\\cite{rahimi2008random} provide a way to, given a\n  kernel $\\kernel(\\vx, \\vy)$,\n  explicitly map the data to a\n  low-dimensional Euclidean inner product space using a randomized feature\n  map $z: \\reals^d \\mapsto \\reals^D$ so that the inner product between a pair\n  of transformed points approximates their kernel evaluation, i.e:\n\n  \\begin{equation}\n    \\kernel(\\vx, \\vy) = \\phi(\\vx)^\\transp\\cdot\\phi(\\vy) \\approx z(\\vx)^\\transp\\cdot z(\\vy)\n  \\end{equation}\n\n  To approximate the RBF kernel, it uses the Bochner's Theorem, which says:\n\n\\newtheorem{theorem}{Theorem}\n  \\begin{theorem}\n    \\cite{rudin1962fourier}\n    A continuous kernel $\\kernel(x, y) = \\kernel(x - y)$ on $\\reals^D$  is\n    positive definite if and only if $k(\\delta)$ is the\n    Fourier Transform of a non-negative measure.\n  \\end{theorem}\n\n  % Since RBF is defined as $\\kernel(\\vx, \\vy) = e^{-\\gamma\\norm{\\vx - \\vy}^2}$\n\n  Since it is known that RBF is shift-invariant and positive definite, then\n  its Fourier transform is a proper probability distribution, and so\n\n  \\begin{equation}\n    \\kernel(\\vx - \\vy) = \\int_{\\reals^D} p(w)e^{iw^\\transp (\\vx-\\vy)}\n    = \\int_{\\reals^D} p(w)cos\\left(w^\\transp (\\vx-\\vy)\\right)\n  \\end{equation}\n\n  A random feature can be obtained by picking $w \\sim \\{\\mathcal{N}(0, 2\\gamma)\\}^d$\n  and $b \\sim \\mathcal{U}(0, 2\\pi)$\n  and computing $\\sqrt{2}cos(w^\\transp\\vx + b)$. To generate a lower variance\n  approximation of $\\phi(\\vx)$ with $D$ features we can concatenate $D$ randomly\n  chosen features $(f_1, \\ldots, f_D)$ into a column vector and normalize each\n  component by $\\sqrt{D}$.\n\n  It is guaranteed an exponentially fast convergence in $D$ between\n  $z(\\vx)^\\transp z(\\vy)$ and $\\kernel(\\vx, \\vy)$.\n\n\\end{pre-delivery}\n\n\\section{\\Nys}\n\n\\begin{pre-delivery}\n  The \\Nys\\cite{NIPS2000_1866} method is a general method for low-rank approximations of\n  kernels. It achieves this by subsampling the data on which the kernel\n  is evaluated.\n\n  In kernel methods the data can be represented in a kernel matrix $K$, where\n  $K_{i,j} = \\kernel(\\vx_i, \\vx_j)$. The problem of these methods is their\n  high computational cost associated with the kernel matrix: with non-linear\n  kernels, the cost of training the model is cubic with the number of\n  instances, something unacceptable for large-scale problems.\n\n  The \\Nys\\ method consists on generating an approximation of the kernel matrix of\n  ranq $q$, where $q$ can be a lot smaller than the number of instances, without\n  any significant decrease in the accuracy of the solution. This way, if there\n  are $n$ instances in a dataset, the complexity can be reduced from\n  $\\mathcal{O}(n^3)$ to $\\mathcal{O}(nq^2)$.\n\n  With \\Nys, given a kernel $\\kernel(\\vx, \\vy) = \\phi(\\vx)\\cdot\\phi(\\vy)$, one can\n  construct a mapping $z: \\reals^d \\mapsto \\reals^q$ so that\n  $z(\\vx) \\approx \\phi(\\vx)$. This function defines each component $j$ as\n  $z_j(\\vy) = \\frac{1}{q}\\sum_{i = 1}^q \\kernel(\\vy, \\vx_i)g_i(\\vx_i)$,\n  where $\\vx_1, \\ldots, \\vx_q$ are some chosen instances and\n  $g_i(\\cdot)$ comes from a column from the Singular Value Decomposition\n  of the approximated kernel matrix.\n\\end{pre-delivery}\n", "meta": {"hexsha": "353ce4bb82ea58749948969c71a389958cfc8272", "size": 21421, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Memoria/Chapters/Ch2_background.tex", "max_stars_repo_name": "ribes96/TFG", "max_stars_repo_head_hexsha": "b38ac01da641e40551c1b3fefc1dc3ebd1b8b0a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Memoria/Chapters/Ch2_background.tex", "max_issues_repo_name": "ribes96/TFG", "max_issues_repo_head_hexsha": "b38ac01da641e40551c1b3fefc1dc3ebd1b8b0a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Memoria/Chapters/Ch2_background.tex", "max_forks_repo_name": "ribes96/TFG", "max_forks_repo_head_hexsha": "b38ac01da641e40551c1b3fefc1dc3ebd1b8b0a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.6272912424, "max_line_length": 121, "alphanum_fraction": 0.7053825685, "num_tokens": 6037, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4495639225350022}}
{"text": "\\documentclass[11pt, a4wide]{article}   \t% use \"amsart\" instead of \"article\" for AMSLaTeX format\n\\usepackage{geometry}                \t\t% See geometry.pdf to learn the layout options. There are lots.\n\\geometry{a4paper}                   \t\t% ... or a4paper or a5paper or ... \n\n%Custom commands\n\\newcommand{\\data}{\\text{data}}\n\\newcommand{\\sessions}{s}\n\\newcommand{\\purchases}{p}\n\\newcommand{\\sepu}{\\sessions, \\purchases}\n\\newcommand{\\convr}{R}\n\\newcommand{\\ushi}{\\text{UH}}\n\n%Packages\n\\usepackage{graphicx}\n\\usepackage{amssymb, amsmath}\n\n\\usepackage{a4wide}\n\\usepackage{listings,url}\n\\usepackage[retainorgcmds]{IEEEtrantools}\n\n\\title{A Bayesian Approach to AB Testing [Draft]\\\\{\\small Introducing a Python Engine for Testing}}\n\\author{Hugo Pibernat and Nuria Duran}\n%\\date{}\n\n\\begin{document}\n\\maketitle\n\\section{Introduction}\nThe main goal of our AB-Test is to decide which of two different versions of the same product performs better on a specific set of metrics. In this report we present a Bayesian approach to tackle this objective.\n\nA Bayesian model includes a prior distribution which enables us to provide information about the parameters $KPI_A$ and $KPI_B$ governing our data \\emph{before} observing the data. The information included in the data is taken into account by means of the likelihood function. Combining both the prior and the likelihood function results in a posteriori distribution, a probability distribution of the parameters (the metric of each group, in this case) which will help us to decide which of the version performs better.\n\nThe (joint) posterior probability distribution is defined as follows:\n\n\n\\begin{equation}\nP(\\text{KPI}_A,\\text{KPI}_B|data)\n\\end{equation}\n\nIn order to compute this distribution, we will need the Bayes theorem, which states that\n\n\\begin{equation}\nP(X|Y) = \\frac{P(Y|X)\\cdot P(X)}{P(Y)}\n\\end{equation}\n\n%\\section{Bayesian models}\n\\section{Binomial Variables: Modelling Conversion Rate}\n\nThe history of a user (UH) looks as follows:\n\\begin{equation}\n<0,0,1,0,0,0,1,0,0,1,0,1,1,0,1>\n\\end{equation}\nwhere 0 represents a non-converted visit and 1 represents a converted visit. Hence, \n\\begin{equation}\n\\ushi\\sim Bin(n,\\theta)\n\\end{equation}\nwhere $n\\in \\mathbb{Z}^{+}$ and $\\theta\\in[0,1]$ is the parameter we want to model with the posteriori distribution once given the priori distribution $P(\\theta)$ and the likelihood function. We usually call this parameter Conversion Rate (CR).\n\n\\subsection{Choosing the prior distribution}\nThe prior distribution $P(\\theta)$ enables us to include some knowledge in the final distribution of the KPI that we are modelling. There are several considerations when choosing the prior. However, for the sake of simplicity, in this case we will use the Beta distribution, which has a support of $[0,1]$, exactly the range of values of CR:\n\n\\begin{equation}\nBeta_{\\alpha,\\beta}(\\theta) = \\frac{\\theta^{\\alpha-1}(1-\\theta)^{\\beta-1}}{B(\\alpha,\\beta)}\n\\end{equation}\n\n\nwhere $\\alpha$ and $\\beta$ are the parameters of the distribution and B is the beta function, defined as follows:\n\n\\begin{equation}\nB(\\alpha,\\beta) = \\int_0^1t^{\\alpha-1}(1-t)^{\\beta-1}{B(\\alpha,\\beta)}\n\\end{equation}\n\n\n A particularly useful set of parameters is $\\alpha=\\beta=1$ which results in the uniform distribution. That is, a priori it is considered that all the values a parameter can take are equally likely to be taken.\n\n\n\n\\subsection{Obtaining the posteriori distribution}\n\nTo compute the posteriori distribution, apart from the priori distribution, we need the likelihood function, the probability mass function of the Binomial distribution in our case:\n\\begin{equation}\nP(X=k)=\\binom{n}{k}\\theta^k(1-\\theta)^{n-k}\n\\end{equation}\n\nIn order to compute the posteriori distribution, we will use the Bayes theorem:\n\n\n\\begin{equation}\n\\label{eq:bayesconvr}\nP(\\theta|n,k) = \\frac{P(n,k|\\theta)\\cdot P(\\theta)}{P(n,k)}\n\\end{equation}\n\nWe therefore need to obtain $P(n,k|\\theta)$ and $P(\\theta)$. As it will be seen later, the value of P(n,k) does not actually need to be computed.\n\nFirst, we have\n\\begin{equation}\nP(n,k|\\theta) = \\binom{n}{k}\\theta^k(1-\\theta)^{n-k} \n\\end{equation}\n\n\n\nBack to Equation~\\ref{eq:bayesconvr} we now have that\n\n\\begin{equation}\n\\begin{array}{c}\nP(\\theta|n,k) = \\\\\n\\\\\n=  \\frac{P(n,k|\\theta)\\cdot P(\\theta)}{P(n,k)}  = \\\\\n\\\\\n=  \\frac{\\binom{n}{k}\\theta^k(1-\\theta)^{n-k} \\cdot \\frac{\\theta^{\\alpha-1}(1-\\theta)^{\\beta-1}}{B(\\alpha,\\beta)}}{P(n,k)} = \\\\\n\\\\\n=  \\frac{\\binom{n}{k}}{P(n,k)B(\\alpha,\\beta)} \\cdot \\theta^{k + \\alpha-1}(1-\\theta)^{n-k+\\beta-1}\n\\end{array}\n\\end{equation}\n\nWe can rewrite the previous equation as:\n\\begin{equation}\nP(\\theta|n,k) = \\lambda \\cdot \\theta^{k + \\alpha-1}(1-\\theta)^{n-k+\\beta-1}\n\\end{equation}\n\n\nwhere\n\\begin{equation}\n\\lambda = \\binom{n}{k}\\frac{1}{P(n,k)B(\\alpha,\\beta)} \n\\end{equation}\n\nHence, our posteriori distribution for the $\\theta$ is:\n\n\\begin{equation}\nP(\\theta|n,k) = Beta_{n+\\alpha,n-k+\\beta}(\\theta)\n\\end{equation}\n\nOr, in terms of sessions $\\sessions$, purchases $\\purchases$, and conversion rate $\\convr$:\n\n\\begin{equation}\nP(\\convr|\\sepu) = Beta_{\\sessions+\\alpha,\\sessions-\\purchases+\\beta}(\\theta)\n\\end{equation}\n\n\\subsection{Running an AB-Test on Conversion Rate}\n\nLet's focus now on obtaining the probability that one conversion rate group is higher than the other (although the result is easily generalisable to $n$ test groups). That is:\n\n\\begin{equation}\n\\label{eq:integral-binomial}\nP(\\convr_A > \\convr_B|\\data) = \\iint\\limits_{\\convr_A>\\convr_B} P(\\convr_A,\\convr_B|\\data)\\; d\\convr_A\\; d\\convr_B\n\\end{equation}\n\nwhere $P(\\convr_A,\\convr_B|\\data)$ is the joint distribution of both conversion rates. If we can assume independence of our tests groups\\footnote{Although it is quite difficult that with our sparse social graph any two events are really independent, this is still quite a general assumption in most of our tests.}, then the following holds:\n\n\\begin{equation}\n\\begin{array}{c}\nP(\\convr_A,\\convr_B|\\data) = \\\\\n\\\\\n= P(\\convr_A|\\data_A)\\cdot P(\\convr_B|\\data_B) = \\\\\n\\\\\n= \\frac{P(\\data_A|\\convr_A)P(\\convr_A)}{P(\\data_A)} \\cdot \\frac{P(\\data_B|\\convr_B)P(\\convr_B)}{P(\\data_B)} = \\\\\n\\\\\n= \\frac{P(\\data_A|\\convr_A)P(\\convr_A)P(\\data_B|\\convr_B)P(\\convr_B)}{P(\\data_A)P(\\data_B)}\n\\end{array}\n\\end{equation}\n\nwhere $P(\\data_A|\\convr_A)$, $P(\\convr_A)$, on the one hand, and $P(\\data_B|\\convr_B)$, $P(\\convr_B)$, on the other hand, stand for the \\emph{likelihood function} and the \\emph{prior distribution}, and they can be obtained as explained above. Look in the \\emph{BayesianABTest.py} file for an implementation of this and the other methods explained in this paper. Or run some of the examples in \\emph{examples\\_ABTests.py} to see  the method in action.\n\n\\section{Gaussian Variables: Modelling Attempts per Level}\n\nWhen our data follow a Gaussian Distribution\n\n$$X\\sim N(\\mu,\\sigma^2)$$\n\nthe prior distribution becomes slightly more complicated. In this case we need to obtain a joint distribution of the form:\n\n\\begin{equation}\nP(\\mu,\\sigma^2)\n\\end{equation}\n\nFrom Gelman et al.~[4], we know that it can be described as follows:\n\n\\begin{equation}\nP(\\mu,\\sigma^2) = P(\\sigma^2)P(\\mu|\\sigma^2)\n\\end{equation}\n\nwhere $P(\\sigma^2)$ is an Inverse Gamma Distribution and $P(\\mu|\\sigma^2)$ is also a Gaussian Distribution.\n\nFollowing Gelman's indications we can sample the posteriori distribution and then run the AB-Test using the code from \\emph{BayesianABTest.py}.\n\n\n\\section{Log-Normal Variables: Modelling Spend}\n\nWhen, for instance, we are modelling user spend, data are positive. Therefore, a Gaussian (or Normal) distribution is not appropriate due to its $(-\\infty,+\\infty)$ support.\n\nIn those situations, a Log-Normal distribution might fit our data more accurately. A Log-Normal Distribution is such that if $X$ is distributed log-normally, then $ln(X)$ is distributed normally:\n\n\\begin{equation}\n\\text{if}\\;\\; X\\sim Log-N(\\mu,\\sigma^2) \\text{   then   } ln(X) \\sim N(\\mu,\\sigma^2)\n\\end{equation}\n\nIn a Log-Normal distribution the $\\mu$ and $\\sigma^2$ are not the mean and the variance. The mean, variance, median, and mode from a Log-Normal distribution are computed as follows:\n\n\\begin{itemize}\n\\item Mean: $e^{\\mu+\\frac{\\sigma^2}{2}}$\n\\item Variance: $(e^{\\sigma^2}-1)e^{2\\mu+\\sigma^2}$\n\\item Median: $e^{\\mu}$\n\\item Mode: $e^{\\mu-\\sigma^2}$\n\\end{itemize}\n\nAn examplary code to sample the posteriori distribution can be found in \\emph{BayesianABTest.py}.\n\n\\section{Modelling Spend per Session with a Two-Part Model Approach}\nWhen our data contain a substantial amount of zeroes, a log-normal distribution is not appropriate, as its support is strictly positive. In this situation, we can first model the zeros vs. not zeros with a Binomial distribution, then the non-zeroes with a Log normal distribution, and obtain our final posteriori distribution as the product of these two.\n\nThe following code runs an AB-Test on such a combination of variables: each set of variable values is randomly sampled, and then each random value from the first set is multiplied by one random value from the second set. Look at the file \\emph{BayesianABTest.py} for a possible implementation of this method.\n\n\\section{References}\n\\begin{enumerate}\n\\item Evan Miller. How Not To Run An A/B Test.\nAvailable at: \\url{http://www.evanmiller.org/how-not-to-run-an-ab-test.html}\n\\item Chris Stucchio. \\emph{Analyzing conversion rates with Bayes Rule (Bayesian statistics tutorial)}. Available at: \\url{http://www.chrisstucchio.com/blog/2013/bayesian_analysis_conversion_rates.html}\n\\item Sergey Feldman. \\emph{Rich Relevance, Collection on Bayesian Testing}. Available at: \\url{http://engineering.richrelevance.com/category/bayesian/}\n\\item Gelman,~A. et al. \\emph{Bayesian Data Analysis}, 3rd Edition. CRC Press, 2013.\n\\end{enumerate}\n\n\\end{document}  ", "meta": {"hexsha": "07fedb15972ecf16a22aae46f77b1719d3f2b315", "size": 9802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/bayesianABTests.tex", "max_stars_repo_name": "hugopibernat/BayesianABTestAnalysis", "max_stars_repo_head_hexsha": "026960524f5313f4a734f30fd447a5731be802e0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/bayesianABTests.tex", "max_issues_repo_name": "hugopibernat/BayesianABTestAnalysis", "max_issues_repo_head_hexsha": "026960524f5313f4a734f30fd447a5731be802e0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/bayesianABTests.tex", "max_forks_repo_name": "hugopibernat/BayesianABTestAnalysis", "max_forks_repo_head_hexsha": "026960524f5313f4a734f30fd447a5731be802e0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.3529411765, "max_line_length": 520, "alphanum_fraction": 0.7358702306, "num_tokens": 2852, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.44956392207261364}}
{"text": "\\documentclass[rnaas]{aastex62}\n\n\\pdfoutput=1\n\n\\usepackage{lmodern}\n\\usepackage{microtype}\n\\usepackage{url}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{natbib}\n\\usepackage{multirow}\n\\usepackage{graphicx}\n\\bibliographystyle{aasjournal}\n\n% ------------------ %\n% end of AASTeX mods %\n% ------------------ %\n\n% Projects:\n\\newcommand{\\project}[1]{\\textsf{#1}}\n\\newcommand{\\kepler}{\\project{Kepler}}\n\\newcommand{\\ktwo}{\\project{K2}}\n\n% references to text content\n\\newcommand{\\documentname}{\\textsl{Note}}\n\\newcommand{\\figureref}[1]{\\ref{fig:#1}}\n\\newcommand{\\Figure}[1]{Figure~\\figureref{#1}}\n\\newcommand{\\figurelabel}[1]{\\label{fig:#1}}\n\\renewcommand{\\eqref}[1]{\\ref{eq:#1}}\n\\newcommand{\\Eq}[1]{Equation~(\\eqref{#1})}\n\\newcommand{\\eq}[1]{\\Eq{#1}}\n\\newcommand{\\eqalt}[1]{Equation~\\eqref{#1}}\n\\newcommand{\\eqlabel}[1]{\\label{eq:#1}}\n\n% TODOs\n\\newcommand{\\todo}[3]{{\\color{#2}\\emph{#1}: #3}}\n\\newcommand{\\dfmtodo}[1]{\\todo{DFM}{red}{#1}}\n\\newcommand{\\alltodo}[1]{\\todo{TEAM}{red}{#1}}\n\\newcommand{\\citeme}{{\\color{red}(citation needed)}}\n\n% math\n\\newcommand{\\T}{\\ensuremath{\\mathrm{T}}}\n\\newcommand{\\dd}{\\ensuremath{ \\mathrm{d}}}\n\\newcommand{\\unit}[1]{{\\ensuremath{ \\mathrm{#1}}}}\n\\newcommand{\\bvec}[1]{{\\ensuremath{\\boldsymbol{#1}}}}\n\\newcommand{\\Gaussian}[3]{\\ensuremath{\\frac{1}{|2\\pi #2|^\\frac{1}{2}}\n            \\exp\\left[ -\\frac{1}{2}#1^\\top #2^{-1} #1 \\right]}}\n\n% VECTORS AND MATRICES USED IN THIS PAPER\n\\newcommand{\\Normal}{\\ensuremath{\\mathcal{N}}}\n\\newcommand{\\mA}{\\ensuremath{\\bvec{A}}}\n\\newcommand{\\mC}{\\ensuremath{\\bvec{C}}}\n\\newcommand{\\mS}{\\ensuremath{\\bvec{\\Sigma}}}\n\\newcommand{\\mL}{\\ensuremath{\\bvec{\\Lambda}}}\n\\newcommand{\\vw}{\\ensuremath{\\bvec{w}}}\n\\newcommand{\\vy}{\\ensuremath{\\bvec{y}}}\n\\newcommand{\\vt}{\\ensuremath{\\bvec{\\theta}}}\n\\newcommand{\\vm}{\\ensuremath{\\bvec{\\mu}(\\bvec{\\theta})}}\n\\newcommand{\\vre}{\\ensuremath{\\bvec{r}}}\n\\newcommand{\\vh}{\\ensuremath{\\bvec{h}}}\n\\newcommand{\\vk}{\\ensuremath{\\bvec{k}}}\n\n% typography obsessions\n\\setlength{\\parindent}{3.0ex}\n\n\\begin{document}\\raggedbottom\\sloppy\\sloppypar\\frenchspacing\n\n\\title{%\n    Scalable backpropagation for Gaussian Processes using celerite\n}\n\n\\author[0000-0002-9328-5652]{Daniel Foreman-Mackey}\n\\affil{Center for Computational Astrophysics, Flatiron Institute, New York, NY}\n\n\\keywords{%\nmethods: data analysis ---\nmethods: statistical\n}\n\n\\section{Introduction}\n\nThis research note presents a derivation and implementation of efficient and\nscalable gradient computations using the \\emph{celerite} algorithm for Gaussian\nProcess (GP) modeling.\nThe algorithms are derived in a ``reverse accumulation'' or\n``backpropagation'' framework and they can be easily integrated into existing\nautomatic differentiation frameworks to provide a scalable method for\nevaluating the gradients of the GP likelihood with respect to all input\nparameters.\nThe algorithm derived in this note uses less memory and is more efficient than\nversions using automatic differentiation and the computational cost scales\nlinearly with the number of data points.\n\nGPs \\citep{Rasmussen:2006} are a class of models used\nextensively in the astrophysical literature to model stochastic processes.\nThe applications are broad-ranging and some examples include the time domain\nvariability of astronomical sources \\citep{Brewer:2009, Kelly:2014,\nHaywood:2014, Rajpaul:2015, Foreman-Mackey:2017, Angus:2018}, data-driven\nmodels of light curves or stellar spectra \\citep{Wang:2012, Luger:2016,\nCzekala:2017}, and the cosmic microwave background\n\\citep{Bond:1987,Wandelt:2003}.\nIn all of these applications, the calculation and optimization of the GP\nmarginalized likelihood function (here we follow the notation of\n\\citealt{Foreman-Mackey:2017})\n\\begin{eqnarray}\\eqlabel{loglike}\n\\log \\mathcal{L}(\\bvec{\\theta},\\,\\bvec{\\alpha}) &=&\n    -\\frac{1}{2}\\,\\left[\\bvec{y} - \\bvec{\\mu}_\\bvec{\\theta}\\right]^\\T\\,\n        {K_\\bvec{\\alpha}}^{-1}\\,\\left[\\bvec{y}-\\bvec{\\mu}_\\bvec{\\theta}\\right]\n    -\\frac{1}{2}\\,\\log\\det K_\\bvec{\\alpha} + \\mathrm{constant}\n\\end{eqnarray}\nis generally the computational bottleneck.\nThe details of these models are omitted here (see \\citealt{Rasmussen:2006} and\n\\citealt{Foreman-Mackey:2017} for details), but the key point is that, for a\ndataset with $N$ data points, every evaluation of a GP model requires\ncomputing the log-determinant and multiplying a vector by the inverse of\n%\\footnote{Or, more specifically, a linear operator\n%that can left multiply a vector or a matrix by the inverse of this matrix.}\nthe $N \\times N$ covariance matrix $K_\\bvec{\\alpha}$.\nThe computational cost of these operations scales as $\\mathcal{O}(N^3)$ in the\ngeneral case, but the \\emph{celerite} method was recently introduced in the\nastronomical literature to compute the GP likelihood for a class of\none-dimensional models with $\\mathcal{O}(N)$ scaling\n\\citep{Ambikasaran:2015, Foreman-Mackey:2017}.\n\nThe details of the \\emph{celerite} method can be found in\n\\citet{Foreman-Mackey:2017} and I will not repeat them here.\nThe only difference in notation is that all the matrices in what follows are\nthe ``pre-conditioned'' matrices that are indicated with a tilde by\n\\citet{Foreman-Mackey:2017}.\nThe tilde is not included here for simplicity and to improve the readability\nof the algorithms.\nI will also use the symbol $P$ for the $(N-1) \\times J$ pre-conditioning matrix\nthat was called $\\phi$ by \\citet{Foreman-Mackey:2017}.\nThe Cholesky factorization algorithm derived by \\citet[][their\nEquation~46]{Foreman-Mackey:2017} is as follows:\n\n\\medskip\n\\begin{minipage}{\\linewidth}\n\\textbf{function} \\texttt{celerite\\_factor}($U$, $P$, $\\bvec{d}$, $W$) \\\\\n\\hspace*{2em}\\textsf{\\# At input $\\bvec{d} = \\bvec{a}$ and $W = V$} \\\\\n\\hspace*{2em}$S \\gets$ \\texttt{zeros}($J$, $J$) \\\\\n    \\hspace*{2em}$\\bvec{w}_1 \\gets \\bvec{w}_1 / d_{1}$ \\\\\n\\hspace*{2em}\\textbf{for} $n = 2,\\ldots,N$:\\\\\n\\hspace*{2em}\\hspace*{2em}$S \\gets \\texttt{diag}(\\bvec{p}_{n-1})\\,[\n    S + d_{n-1}\\,{\\bvec{w}_{n-1}}^\\T\\,{\\bvec{w}_{n-1}}\n]\\,\\texttt{diag}(\\bvec{p}_{n-1})$ \\\\\n\\hspace*{2em}\\hspace*{2em}$d_{n} \\gets d_{n} - \\bvec{u}_n\\,S\\,{\\bvec{u}_n}^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bvec{w}_n \\gets \\left[\\bvec{w}_n -\n    \\bvec{u}_n\\,S \\right] / d_{n}$\\\\\n    \\hspace*{2em}\\textbf{return} $\\bvec{d}$, $W$, $S$\n\\end{minipage}\n\\medskip\n\n\\noindent In this algorithm, the \\texttt{zeros}$(J,\\,K)$ function creates a $J\n\\times K$ matrix of zeros, the \\texttt{diag} function creates a diagonal\nmatrix from a vector, and $\\bvec{x}_n$ indicates a row vector made from the\n$n$-th row of the matrix $X$.\nThe computational cost of this algorithm scales as $\\mathcal{O}(N\\,J^2)$.\nUsing this factorization, the log-determinant of $K$ is\n\\begin{eqnarray}\n\\log \\det K &=& \\sum_{n=1}^N \\log d_{n} \\quad.\n\\end{eqnarray}\nSimilarly, \\citet{Foreman-Mackey:2017} derived a $\\mathcal{O}(N\\,J)$ algorithm\nto apply the inverse of $K$ (i.e.\\ compute $Z = K^{-1}\\,Y$) as follows\n(Equations~47 and~48 in \\citealt{Foreman-Mackey:2017}):\n\n\\medskip\n\\begin{minipage}{\\linewidth}\n\\textbf{function} \\texttt{celerite\\_solve}($U$, $P$, $\\bvec{d}$, $W$, $Z$) \\\\\n\\hspace*{2em}\\textsf{\\# At input $Z = Y$} \\\\\n\\hspace*{2em}$F \\gets$ \\texttt{zeros}($J$, $N_\\mathrm{rhs}$) \\\\\n\\hspace*{2em}\\textbf{for} $n = 2,\\ldots,N$:\\\\\n\\hspace*{2em}\\hspace*{2em}$F \\gets \\texttt{diag}(\\bvec{p}_{n-1})\\,[F +\n    {\\bvec{w}_{n-1}}^\\T\\,\\bvec{z}_{n-1}]$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bvec{z}_n \\gets \\bvec{z}_n - \\bvec{u}_n\\,F$\\\\\n\\hspace*{2em}\\textbf{for} $n = 1,\\ldots,N$:\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bvec{z}_n \\gets \\bvec{z}_n / d_{n}$\\\\\n\\hspace*{2em}$G \\gets$ \\texttt{zeros}($J$, $N_\\mathrm{rhs}$) \\\\\n\\hspace*{2em}\\textbf{for} $n = N-1,\\ldots,1$:\\\\\n\\hspace*{2em}\\hspace*{2em}$G \\gets \\texttt{diag}(\\bvec{p}_{n})\\,[G +\n    {\\bvec{u}_{n+1}}^\\T\\,\\bvec{z}_{n+1}]$\\\\\n    \\hspace*{2em}\\hspace*{2em}$\\bvec{z}_n \\gets \\bvec{z}_n - \\bvec{w}_n\\,G$\\\\\n\\hspace*{2em}\\textbf{return} $Z$, $F$, $G$\n\\end{minipage}\n\\medskip\n\n\\noindent The empirical scaling of these algorithms is shown in\n\\Figure{figure}.\n\n\\section{Gradients of GP models using celerite}\n\nIt is standard practice to make inferences using \\Eq{loglike} by optimizing or\nchoosing a prior and sampling with respect to $\\bvec{\\theta}$ and\n$\\bvec{\\alpha}$.\nMany numerical inference methods (like non-linear optimization or Hamiltonian\nMonte Carlo) can benefit from efficient calculation of the gradient of\n\\Eq{loglike} with respect to the parameters.\nThe standard method of computing these gradients uses the identity\n\\citep{Rasmussen:2006}\n\\begin{eqnarray}\\eqlabel{naive-grad}\n\\frac{\\dd \\log \\mathcal{L}}{\\dd \\alpha_k} &=&\n    \\frac{1}{2}\\,\\mathrm{Tr}\\left[\n        \\left[\n        \\bvec{\\tilde{r}}\\,\\bvec{\\tilde{r}}^\\T - {K_\\bvec{\\alpha}^{-1}}\n        \\right]\n        \\,\\frac{\\dd K}{\\dd \\alpha_k}\n    \\right]\n\\end{eqnarray}\nwhere\n\\begin{eqnarray}\n    \\bvec{\\tilde{r}} &=&\n        {K_\\bvec{\\alpha}}^{-1}\\,\\left[\\bvec{y}-\\bvec{\\mu}_\\bvec{\\theta}\\right]\n    \\quad.\n\\end{eqnarray}\nSimilar equations exist for the parameters $\\bvec{\\theta}$.\nEven with a scalable method of applying ${K_\\bvec{\\alpha}}^{-1}$, the\ncomputational cost of \\Eq{naive-grad} scales as $\\mathcal{O}(N^2)$.\nThis scaling is prohibitive when applying the \\emph{celerite} method to large\ndatasets and I have not found a simple analytic method of improving this\nscaling for semi-separable matrices.\nHowever, it was recently demonstrated that substantial computational gains can\nbe made by directly differentiating Cholesky factorization algorithms even in\nthe general case \\citep{Murray:2016}.\n\nFollowing this reasoning and using the notation from an excellent review of\nmatrix gradients \\citep{Giles:2008}, I present the reverse-mode gradients of\nthe \\emph{celerite} method.\nWhile not yet popular within astrophysics, ``reverse accumulation'' of\ngradients (also known as ``backpropagation'') has recently revolutionized the\nfield of machine learning \\citep[see][for example]{LeCun:2015} by enabling the\nnon-linear optimization of models with large numbers of parameters.\nThe review \\citep{Giles:2008} provides a thorough overview of these methods\nand the interested reader is directed to that discussion for details and for\nan explanation of the notation.\n\nUsing the notation from \\citet{Giles:2008}, after some tedious\nalgebra, the reverse accumulation function corresponding to\n\\texttt{celerite\\_factor} is found to be:\n\n\\medskip\n\\begin{minipage}{\\linewidth}\n\\textbf{function} \\texttt{celerite\\_factor\\_rev}($U$, $P$, $\\bvec{d}$, $W$,\n    $S$, $\\bar{S}$, $\\bar{\\bvec{a}}$, $\\bar{V}$) \\\\\n\\hspace*{2em}\\textsf{\\# At input $\\bar{\\bvec{a}} = \\bar{\\bvec{d}}$ and\n    $\\bar{V} = \\bar{W}$}\\\\\n\\hspace*{2em}$\\bar{U} \\gets \\mathrm{zeros}(N,\\,J)$\\\\\n\\hspace*{2em}$\\bar{P} \\gets \\mathrm{zeros}(N-1,\\,J)$\\\\\n\\hspace*{2em}$\\bar{\\bvec{v}}_N \\gets \\bar{\\bvec{v}}_N / d_N$\\\\\n\\hspace*{2em}\\textbf{for} $n = N,\\ldots,2$:\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{a}_n \\gets \\bar{a}_n -\n    \\bvec{w}_n\\,{\\bar{\\bvec{v}}_n}^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{u}}_n \\gets - [\\bar{\\bvec{v}}_n +\n    2\\,\\bar{a}_n\\,\\bvec{u}_n]\\,S$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{S} \\gets \\bar{S} -\n    {\\bvec{u}_n}^\\T\\,[\\bar{\\bvec{v}}_n + \\bar{a}_n\\,\\bvec{u}_n]$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{p}}_{n-1} \\gets \\mathrm{diag}(\\bar{S}\\,S\n    \\,\\mathrm{diag}(\\bvec{p}_{n-1})^{-1} + \\mathrm{diag}(\\bvec{p}_{n-1})^{-1}\\,\n    S\\,\\bar{S})$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{S} \\gets \\mathrm{diag}(\\bvec{p}_{n-1})\\,\n    \\bar{S}\\,\\mathrm{diag}(\\bvec{p}_{n-1})$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{d}_{n-1} \\gets \\bar{d}_{n-1} +\n    \\bvec{w}_{n-1}\\,\\bar{S}\\,{\\bvec{w}_{n-1}}^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{v}}_{n-1} \\gets \\bar{\\bvec{v}}_{n-1}\n    / d_{n-1} + \\bvec{w}_{n-1}\\,[\\bar{S} + \\bar{S}^\\T]$\\\\\n\\hspace*{2em}\\hspace*{2em}$S \\gets \\mathrm{diag}(\\bvec{p}_{n-1})^{-1}\\,S\\,\n    \\mathrm{diag}(\\bvec{p}_{n-1})^{-1}\n    - d_{n-1}\\,{\\bvec{w}_{n-1}}^\\T\\,\\bvec{w}_{n-1}$\\\\\n\\hspace*{2em}$\\bar{a}_1 \\gets \\bar{a}_1 -\n    \\bar{\\bvec{v}}_1\\,{\\bvec{w}_1}^\\T$\\\\\n\\hspace*{2em}\\textbf{return} $\\bar{U}$, $\\bar{P}$, $\\bar{\\bvec{a}}$, $\\bar{V}$\n\\end{minipage}\n\\medskip\n\n\\noindent Similarly, the reverse accumulation function for to\n\\texttt{celerite\\_solve} is:\n\n\\medskip\n\\begin{minipage}{\\linewidth}\n\\textbf{function} \\texttt{celerite\\_solve\\_rev}($U$, $P$, $\\bvec{d}$, $W$,\n    $Z$, $F$, $G$, $\\bar{F}$, $\\bar{G}$, $\\bar{Y}$) \\\\\n\\hspace*{2em}\\textsf{\\# At input $\\bar{Y} = \\bar{Z}$}\\\\\n\\hspace*{2em}$\\bar{U} \\gets \\mathrm{zeros}(N,\\,J)$\\\\\n\\hspace*{2em}$\\bar{P} \\gets \\mathrm{zeros}(N-1,\\,J)$\\\\\n\\hspace*{2em}$\\bar{\\bvec{d}} \\gets \\mathrm{zeros}(N)$\\\\\n\\hspace*{2em}$\\bar{W} \\gets \\mathrm{zeros}(N,\\,J)$\\\\\n\\hspace*{2em}\\textbf{for} $n = 1,\\ldots,N-1$:\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{w}}_n \\gets\n    - \\bar{\\bvec{y}}_n\\,G^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{G} \\gets \\bar{G} - {\\bvec{w}_n}^\\T \\,\n    \\bar{\\bvec{y}}_n$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bvec{z}_n \\gets \\bvec{z}_n + \\bvec{w}_n\\,G$\\\\\n\\hspace*{2em}\\hspace*{2em}$G \\gets \\mathrm{diag}(\\bvec{p}_n)^{-1}\\,G$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{p}}_n \\gets \\mathrm{diag}(\n    \\bar{G}\\,G^\\T)$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{G} \\gets\n    \\mathrm{diag}(\\bvec{p}_n)\\,\\bar{G}$\\\\\n\\hspace*{2em}\\hspace*{2em}$G \\gets G - {\\bvec{u}_{n+1}}^\\T\\,\\bvec{z}_{n+1}$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{u}}_{n+1} \\gets\n    \\bvec{z}_{n+1}\\,\\bar{G}^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{y}}_{n+1} \\gets\n    \\bvec{u}_{n+1}\\,\\bar{G}$\\\\\n\\hspace*{2em}\\textbf{for} $n = 1,\\ldots,N$:\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{y}}_n \\gets \\bar{\\bvec{y}}_n/d_n$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{d}_n \\gets -\n    \\bvec{z}_n\\,{\\bar{\\bvec{y}}_n}^\\T$\\\\\n\\hspace*{2em}\\textbf{for} $n = N,\\ldots,2$:\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{u}}_n \\gets \\bar{\\bvec{u}}_n\n    - \\bar{\\bvec{y}}_n\\,F^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{F} \\gets \\bar{F} - {\\bvec{u}_n}^\\T \\,\n    \\bar{\\bvec{y}}_n$\\\\\n\\hspace*{2em}\\hspace*{2em}$F \\gets \\mathrm{diag}(\\bvec{p}_{n-1})^{-1}\\,F$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{p}}_{n-1} \\gets \\bar{\\bvec{p}}_{n-1} +\n    \\mathrm{diag}(\\bar{F}\\,F^\\T)$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{F} \\gets\n    \\mathrm{diag}(\\bvec{p}_{n-1})\\,\\bar{F}$\\\\\n\\hspace*{2em}\\hspace*{2em}$F \\gets F - {\\bvec{w}_{n-1}}^\\T\\,\\bvec{z}_{n-1}$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{w}}_{n-1} \\gets \\bar{\\bvec{w}}_{n-1} +\n    \\bvec{z}_{n-1}\\,\\bar{F}^\\T$\\\\\n\\hspace*{2em}\\hspace*{2em}$\\bar{\\bvec{y}}_{n-1} \\gets \\bar{\\bvec{y}}_{n-1} +\n    \\bvec{w}_{n-1}\\,\\bar{F}$\\\\\n\\hspace*{2em}\\textbf{return} $\\bar{U}$, $\\bar{P}$, $\\bar{\\bvec{d}}$,\n    $\\bar{W}$, $\\bar{Y}$\n\\end{minipage}\n\\medskip\n\n\\noindent A reference C++ implementation of this algorithm can be found online\n\\citep{Foreman-Mackey:2018} and \\Figure{figure} shows the performance of this\nimplementation.\n\n\\newpage\n\\section{Discussion}\n\nThis research note presents the algorithms needed to efficiently compute\ngradients of GP models applied to large datasets using the \\emph{celerite}\nmethod.\nThese developments increase the performance of inference methods based on\n\\emph{celerite} and improve the convergence properties of non-linear\noptimization routines.\nFurthermore, the derivation of reverse accumulation algorithms for\n\\emph{celerite} allow its integration into popular model building and\nautomatic differentiation libraries like Stan \\citep{Carpenter:2015},\nTensorFlow \\citep{Abadi:2016}, and others.\n\n\\acknowledgments\nIt is a pleasure to thank\nEric Agol,\nSivaram Ambikasaran, and\nVictor Minden\nfor conversations that inspired this work.\nA reference implementation of these algorithms, benchmarks, and tests can be\nfound at \\url{https://github.com/dfm/celerite-grad} and\n\\citet{Foreman-Mackey:2018}.\n\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{figure.pdf}\n\\caption{%\n    The empirical computational scaling of the algorithms presented in this\n    note.\n    \\emph{(top row)}: The cost of computing \\eq{loglike} as a\n    function of the number of data points ($N$; left) and the model complexity\n    ($J$; right).\n    \\emph{(bottom row)}: The cost of computing the gradient of \\eq{loglike}\n    with respect to the vector $\\bvec{a}$ and the matrices $U$, $V$, and $P$.\n    In the left panels, each line corresponds to a different value of $J$ as\n    indicated in the legend (with $J$ increasing from bottom to top).\n    Similarly, in the right panels, the lines correspond to different values\n    of $N$ increasing from bottom to top.\n    In both cases, the theoretical scaling is $\\mathcal{O}(N,J^2)$.\n\\figurelabel{figure}}\n\\end{center}\n\\end{figure}\n\n\n\\bibliography{celerite}\n\n\n\\end{document}\n", "meta": {"hexsha": "dacfe6f3220b4d84a7b6d814c95b53610fa72ea7", "size": 16456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/ms.tex", "max_stars_repo_name": "dfm/celerite-grad", "max_stars_repo_head_hexsha": "5c7e8aa38ba33a37d9a9ef9ea66e54bd24dd119b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-09-27T22:46:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T10:00:55.000Z", "max_issues_repo_path": "paper/ms.tex", "max_issues_repo_name": "dfm/celerite-grad", "max_issues_repo_head_hexsha": "5c7e8aa38ba33a37d9a9ef9ea66e54bd24dd119b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/ms.tex", "max_forks_repo_name": "dfm/celerite-grad", "max_forks_repo_head_hexsha": "5c7e8aa38ba33a37d9a9ef9ea66e54bd24dd119b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-01-26T02:54:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-05-19T15:35:55.000Z", "avg_line_length": 43.419525066, "max_line_length": 80, "alphanum_fraction": 0.6750121536, "num_tokens": 6258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4495639132446604}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\chapter{Free field theories}\n\n\\section{Lagrangian and Hamiltonian formalisms}\n\n\\marginpar{Saturday\\\\ 2020-5-2, \\\\ compiled \\\\ \\today}\n\nThe Lagrangian and Hamiltonian formalism can aid in the description of systems with either a finite of infinite number of degree of freedom. \n\n\\subsection{Classical system with finite DoF: Lagrangian formalism}\n\nThe usual example is a system of particles labelled by the index \\(i\\) with masses \\(m_i\\), positions \\(q_i (t)\\) and velocities \\(\\dot{q}_{i}(t)\\).\n\nIf the forces acting on the particles are \\textbf{conservative}, we can express them in terms of a potential, which we assume not to depend on the velocities nor on time: \\(V(q_{i})\\).\nFrom now on when we write \\(q\\) or \\(\\dot{q}\\) we will mean the full vector of the positions or velocities.\n\nIf this is the case, the motion of the particles is described by Newton's equation: \n%\n\\begin{align}\nm_i \\ddot{q}_{i} = - \\pdv{V}{q_{i}}\n\\,.\n\\end{align}\n\nThis can alternatively be described in terms of a function called the Lagrangian: \n%\n\\begin{align}\nL(q, \\dot{q}, t)\n\\,,\n\\end{align}\n%\nwhich could depend on time, but we usually assume it to be independent of time explicitly, that is, \\(\\partial_{t} L = 0\\) (although the \\emph{total} derivative of the Lagrangian may be nonzero!).\n\nThe condition of the Lagrangian being explicitly time-independent is equivalent to the system of forces being conservative.\n\nThe Lagrangian can be a generic function of the positions and velocities of the particles, but in order to reproduce Newton's law we need it to be in the form \n%\n\\begin{align}\nL = T-V = \\frac{1}{2} m_i \\dot{q}_i^2 - V(q_i)\n\\,,\n\\end{align}\n%\nwhere a sum over the particles is implied in the kinetic energy term.\n\nTypically problems in Lagrangian mechanics are given by fixing the boundary conditions as the initial and final position, as opposed to writing the initial values of position and velocity. \n\nWe want to find the physical trajectory the particle(s) will take corresponding to those initial and final conditions.\\footnote{There can be issues arising from this approach: for instance, the process for finding trajectories may find many equivalent ones, for example in situations with some symmetry or nontrivial topology.\nIn the gravitational two-body problem we can ask what is the stationary action path needed in order to reach the antipodal point to the current one: there are infinite ones, corresponding to the choice of azimuthal angle of the initial velocity.\nHowever, this is not really a problem, since the approach we are about to introduce --- Hamilton's principle of stationary action --- just provides a formulation which eventually yields the same differential equations as the initial value problem; physically the velocity as well as the position of the particles is well determined in the initial moment.}\n\nThis can be accomplished using Hamilton's principle of stationary action. We start by introducing the action: \n%\n\\begin{align}\nS[q(t), t _{\\text{in}}, t _{\\text{fin}}] = \\int_{t _{\\text{in}}}^{t _{\\text{fin}}} L(q(t), \\dot{q}(t)) \\dd{t}\n\\,,\n\\end{align}\n%\nwhich depends on the full \\emph{path} \\(q(t)\\): the integral is computed by evaluating the Lagrangian along it.\nBecause of this the action \\(S\\) is called a \\emph{functional}, since it is a function of a function. The Lagrangian, on the other hand, is  a regular function.\n\nWe then state the following: \n\\begin{claim}\nThe path taken physically by the system satisfies the stationary action principle: \n%\n\\begin{align}\n\\delta S = 0\n\\,.\n\\end{align}\n\nThe variation is the functional derivative of \\(S\\), meant to be a variation in the infinite-dimensional space of possible curves.\n\\end{claim}\n\nThis is not a proven principle, but rather an axiom to be taken, analyzed and confronted with experiment. \n\nThe action principle, as stated, only guarantees that the action should be stationary: it could be a minimum or a maximum.\nThere are considerations to be made about stability: a maximum-action path will solve the equations of motion and thus be physical, but it will be unstable. This is why the principle is often referred to as the minimum-action principle. \n\nLet us calculate what the variation of the action means physically. We start by considering two nearby paths, \\(\\gamma \\) and \\(\\gamma '\\), such that \n%\n\\begin{align}\n\\gamma ' = \\gamma + \\delta_0 \\gamma \n\\,,\n\\end{align}\n%\nso that the coordinates \\(q\\) at a time \\(t\\) are given by \n%\n\\begin{align}\nq_{\\gamma } (t) \n\\qquad \\text{and} \\qquad\nq_{\\gamma '} (t) = q_{\\gamma }(t) + \\delta_0 q_{\\gamma }(t)\n\\,,\n\\end{align}\n%\nand we impose that the variation of the path, \\(\\delta_0 q_{\\gamma } (t)\\), is zero at the initial and final time, so that the boundary conditions are satisfied: \\(\\delta_0 q_{\\gamma }(t _{\\text{in}}) = 0 = \\delta_0 q_{\\gamma }(t _{\\text{fin}})\\).\n\nThe reason for the subscript \\(0\\) for the variation \\(\\delta \\) is that we consider \\emph{synchronous} variations: the difference between the perturbed and unperturbed trajectory, at a \\emph{fixed time}. \nAlso, we take the synchronous variation of the action:\n%\n\\begin{subequations}\n\\begin{align}\n\\delta_0 S [q_{\\gamma }] &= S [q_{\\gamma } + \\delta_0 q_{\\gamma }] - S[q_{\\gamma }]  \\\\\n&= \\int_{t _{\\text{in}}}^{t _{\\text{fin}}} \\delta_0 L (q_{\\gamma }, \\dot{q}_{\\gamma }) \\dd{t}  \\\\\n&= \\int_{t _{\\text{in}}}^{t _{\\text{fin}}} \\qty[ \\pdv{L}{q} \\cdot \\delta_0 q + \\pdv{L}{\\dot{q}} \\cdot \\dot{q}] \\dd{t}  \\\\\n&= \\int_{t _{\\text{in}}}^{t _{\\text{fin}}} \\qty[\\pdv{L}{q}  - \\dv{}{t} \\pdv{L}{\\dot{q}}] \\cdot \\delta_0 q \\dd{t}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nsince, as we are considering synchronous variations, \\(\\delta_0 \\) and \\(\\partial_{t}\\) commute; also we neglected boundary terms in the integration by parts as they are set to zero by the fact that the variation of the path,  \\(\\delta_0 q_{\\gamma }\\), is zero at the boundaries.\n\nSince this must hold for any variation of the path, by the fundamental lemma of the calculus of variation the integrand must vanish: this yields the Euler-Lagrange equations \n%\n\\begin{align}\n\\pdv{L}{q} - \\dv[]{}{t} \\pdv{L}{\\dot{q}} = 0\n\\,.\n\\end{align}\n\nNote that there is \\textbf{gauge freedom} in the choice of Lagrangian: an easy symmetry to see is the scaling one; the Lagrange equations of \\(L\\) and \\(cL\\) for \\(c \\in \\mathbb{R}\\) are the same. \nAlso, the equations for \\(L\\) and \\(L + \\dv*{F}{t}\\) are the same: the action is the integral in time of the Lagrangian, therefore adding a total derivative to it shifts the action by a constant \\(\\eval{\\Delta F}_{\\text{in}}^{\\text{fin}}\\), which vanishes when taking the variation.\n\n\\subsection{Classical system with finite DoF: Hamiltonian formalism}\n\nWe start off by defining the momenta: in component form, they are\n%\n\\begin{align}\np_{i} = \\pdv{L}{\\dot{q}^{i}}\n\\,.\n\\end{align}\n\nAs long as the Lagrangian is well behaved\\footnote{The formal requirement is that the matrix \n%\n\\begin{align}\n\\pdv[2]{L}{\\dot{q}}{\\dot{q}}\n\\,\n\\end{align}\n%\nshould be invertible.}\nwe can move between momenta and velocities, by using the inverse relation \\(\\dot{q} = \\dot{q} (q, p)\\).\n\nThe Hamiltonian is then defined as \n%\n\\begin{align}\nH(q, p) = \\dot{q}(q, p) \\cdot p - L (q, \\dot{q}(q, p))\n\\,,\n\\end{align}\n%\nand this procedure is called a \\emph{Legendre transform}. \nNote that since we assumed the Lagrangian to have no explicit dependence of time the Hamiltonian will not depend on time either. This is tied to the conservation of energy: if the Lagrangian is given by \\(T - V\\) the Hamiltonian is given by \\(T + V\\), and thus represents the total energy of the system. A theorem in Hamiltonian mechanics is \n%\n\\begin{align}\n\\dv{H}{t} = \\pdv{H}{t}\n\\,,\n\\end{align}\n%\nso the variation of the energy in the evolution of the system (total derivative) is equal to the partial derivative of the Hamiltonian with respect to time.\n\nLet us take the functional derivative of the Hamiltonian: using indices for the clarity of the tensorial structure, we find \n%\n\\begin{subequations}\n\\begin{align}\n\\delta H &= \\pdv{H}{p_{i}}  \\delta p_{i} + \\pdv{H}{q^{i}} \\delta q^{i}  \\\\\n&= \\qty[\\dot{q}^{i} + \\pdv{\\dot{q}^{j}}{p_{i}} p_{j} - \\pdv{L}{\\dot{q}^{j}}  \\pdv{\\dot{q}^{j}}{p_{i}}] \\delta p_{i}\n+ \\qty[\\pdv{\\dot{q}^{j}}{q^{i}} p_{j}\n- \\pdv{L}{q^{i}} - \\pdv{L}{\\dot{q}^{j}} \\pdv{\\dot{q}^{j}}{q^{i}}] \\delta q^{i}  \\\\\n&= \\dot{q}^{i} \\delta p_{i} - \\pdv{L}{q^{i}} \\delta q^{i}  \n\\marginnote{Used the fact that \\(p_{i} = \\pdv*{L}{\\dot{q}^{i}}\\).}  \\\\\n&= \\dot{q}^{i} \\delta p_{i} - \\dot{p}_{i} \\delta q^{i} \n\\marginnote{Used the Euler-Lagrange equations.}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nso we can equate the first and last equations to find the coupled equations \n%\n\\boxalign{\n\\begin{align}\n\\dot{q}^{i} = \\pdv{H}{p_{i}} \\qquad \\text{and} \\qquad\n\\dot{p}_{i} = -\\pdv{H}{q^{i}}    \n\\,.\n\\end{align}}\n%\n\nThese are known as \\textbf{Hamilton's equations of motion}, they are an equivalent formulation of Lagrange's ones but they may be more useful in certain contexts such as when performing numerical integration.\n\nIn the Hamiltonian contexts it is useful to define the Poisson bracket. \nIf we define the operator \\(\\nabla\\) as the derivative operator on the \\(2N\\)-dimensional \\(q, p\\) phase space, then the Poisson bracket is defined as \n%\n\\begin{subequations}\n\\begin{align}\n\\qty{f, g} &= \\qty(\\nabla_{i} f) \\mathbb{J}_{ij} \\qty(\\nabla_{j} g)  \\\\\n&= \\pdv{f}{q^{i}} \\pdv{g}{p_{i}}\n- \\pdv{f}{p_{i}} \\pdv{g}{q^{i}}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere we defined the \\emph{symplectic unity} tensor \n%\n\\begin{subequations}\n\\begin{align}\n\\mathbb{J} = \\left[\\begin{array}{cc}\n0 & \\mathbb{1}_{N} \\\\ \n-\\mathbb{1}_{N} & 0 \n\\end{array}\\right]\n\\,.\n\\end{align}\n\\end{subequations}\n\nWith the aid of these, and defining the vector \\(X = \\qty[q, p]^{\\top}\\) we can write Hamilton's equations as \n%\n\\begin{align}\n\\dv{X}{t} = \\qty{X, H}\n\\,,\n\\end{align}\n%\nor, more explicitly, \n%\n\\begin{align}\n\\dot{q} = \\qty{q, H}\n\\qquad \\text{and} \\qquad\n\\dot{p} = \\qty{p, H}\n\\,.\n\\end{align}\n\nThe Poisson brackets between the coordinates in phase space are given by \n%\n\\begin{align}\n\\qty{q^{i}, q^{j}} = 0\n \\qquad\n\\qty{p_{i}, p_{j}} = 0\n\\qquad \n\\qty{q^{i}, p_{j}} = \\delta^{i}_{j}\n\\,.\n\\end{align}\n\nA generic function's variation in time is given by \n%\n\\begin{align}\n\\dv{f}{t} = \\pdv{f}{t} + \\qty{f, H}\n\\,.\n\\end{align}\n\nThere is a clear analogy between the classical Poisson bracket and the commutator in quantum mechanics.\n\n\\end{document}", "meta": {"hexsha": "12bf0cdb1c9f75b7dfc6ff93f985cfaf4ee2fb90", "size": 10434, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/theoretical_physics/apr07.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/theoretical_physics/apr07.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/theoretical_physics/apr07.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 42.4146341463, "max_line_length": 355, "alphanum_fraction": 0.6995399655, "num_tokens": 3210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4495639091774752}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{exercises}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% --------------------------------------------------------------------------------------------\n\\section*{Exercise 4.2 Inconsistent free indices}\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   def deriv (poly):\n\n       \\delta^{a}::Weight(label=\\epsilon).\n\n       bah := @(poly).\n\n       substitute     (bah,$x^{a} -> x^{a} + \\delta^{a}$)\n       distribute     (bah)\n\n       foo := @(bah) - @(poly).\n\n       keep_weight    (foo, $\\epsilon = 1$)\n       substitute     (foo, $\\delta^{a} -> 1$)\n\n       return foo\n\n   # ---------------------------------------------------------------\n\n   poly := c^{a}\n         + c^{a}{}_{b} x^b\n         + c^{a}{}_{b c} x^b x^c.    # cdb (ex-0402.100,poly)\n\n   dpoly = deriv (poly)              # cdb (ex-0402.101,dpoly)\n\n\\end{cadabra}\n\n\\begin{dgroup*}\n   \\Dmath*{  p = \\Cdb*{ex-0402.100} }\n   \\Dmath*{ dp = \\Cdb*{ex-0402.101} }\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "4330e6034ef09bd1b5abf5b783bf012cb05314ae", "size": 1061, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/exercises/ex-0402.tex", "max_stars_repo_name": "leo-brewin/cadabra-tutorial", "max_stars_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2019-12-20T07:49:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T22:55:47.000Z", "max_issues_repo_path": "source/cadabra/exercises/ex-0402.tex", "max_issues_repo_name": "leo-brewin/cadabra-tutorial", "max_issues_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/exercises/ex-0402.tex", "max_forks_repo_name": "leo-brewin/cadabra-tutorial", "max_forks_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-22T13:52:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-22T13:52:19.000Z", "avg_line_length": 23.0652173913, "max_line_length": 94, "alphanum_fraction": 0.4505183789, "num_tokens": 338, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4495639046479015}}
{"text": "\n  \\subsection{House size crowds out investment}\n\n  However, when comparing households on a total wealth basis, i.e.\\ their liquid assets plus expected house liquidation, we can see that house size crowds out investment for households with low liquid wealth. In figure~\\ref{fig:liquidAssetsByEquity}, we can consider a household whose house size is equal to 5 (5 times their yearly net income) and liquid assets are 0, so their total expected wealth is 5. As this household becomes wealthier, they invest all of their liquid assets in the stock market (such that their risky share is 100 percent), up to the point where they start rebalancing their portfolio between the risky and the safe asset. In this region, they are constrained from investing in the stock market by their low liquid wealth, as they surely would like to invest more in the market. This point becomes clearer by comparing the household to an equally wealthy peer with a smaller house.  At the point where the household with house size of 5 has liquid wealth of 1 (1 times their yearly net income), they are investing less into the stock market in absolute terms than an equally wealthy household whose house size is equal to 2 and liquid assets are equal to 4. The total expected wealth of both these households is 6, but the household with the larger house is investing fewer assets in the stock market than the household with the smaller house. As their total wealth increases, however, both households are unconstrained by their house size and end up investing about the same amount into the stock market in absolute terms.\n\n  \\providecommand{\\figName}{}\n  \\renewcommand{\\figName}{liquidAssetsByEquity}\n  \\providecommand{\\figFile}{}\n  \\renewcommand{\\figFile}{\\figName}\n  \\input{\\FigDir/\\figName} % Read in the tex to generate the figure\n\n", "meta": {"hexsha": "81f5d217e502aae169b3268ea1d1d0bfb5ccb27d", "size": 1812, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/Output/NontechSum/results-3.tex", "max_stars_repo_name": "econ-ark/PortfolioChoiceWithRiskyHousing", "max_stars_repo_head_hexsha": "bdd6bc79443c8c22aeb40756858cb6d7c98f52d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-12T21:28:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T21:28:37.000Z", "max_issues_repo_path": "LaTeX/Output/NontechSum/results-3.tex", "max_issues_repo_name": "alanlujan91/PortfolioChoiceWithRiskyHousing", "max_issues_repo_head_hexsha": "bdd6bc79443c8c22aeb40756858cb6d7c98f52d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-09-02T20:55:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T20:55:18.000Z", "max_forks_repo_path": "LaTeX/Output/NontechSum/results-3.tex", "max_forks_repo_name": "alanlujan91/PortfolioChoiceWithRiskyHousing", "max_forks_repo_head_hexsha": "bdd6bc79443c8c22aeb40756858cb6d7c98f52d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-18T08:43:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-05T17:44:55.000Z", "avg_line_length": 151.0, "max_line_length": 1547, "alphanum_fraction": 0.7952538631, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.4495639001183276}}
{"text": "\\documentclass[utf8x,hyperref={pdfpagelabels=false}]{beamer}\n\n\\usepackage[utf8x]{inputenc}\n\\usepackage[OT1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{listings}\n\\usepackage{hyperref}\n\\usepackage{xcolor}\n\\usepackage{tikz}\n\\usetikzlibrary{shapes.arrows}\n%\\logo{\\includegraphics[width=.8in]{UdeM_NoirBleu_logo_Marie_crop}}\n\n\n\\usetheme{Malmoe}  % Now it's a beamer presentation with the lisa theme!\n\\usecolortheme{beaver}\n\\setbeamertemplate{footline}[page number]\n\\setbeamertemplate{navigation symbols}{}\n\n\\lstloadlanguages{Python}\n\n\\definecolor{darkgreen}{RGB}{0,93,21}\n\\definecolor{greenblue}{RGB}{40,110,126}\n\\definecolor{lightgray}{RGB}{246,246,246}\n\\definecolor{bordergray}{RGB}{193,193,193}\n\\definecolor{lightblue}{RGB}{0,114,168}\n\\definecolor{methblue}{RGB}{0,31,108}\n\n\\newcommand{\\superscript}[1]{\\ensuremath{^{\\textrm{#1}}}}\n\n\\mode<presentation>\n\n\\title{Introduction to Theano}\n\\author{%\n\\footnotesize\nArnaud Bergeron \\newline\n(slides adapted by Frédéric Bastien from slides by Ian G.) \\newline\n(further adapted by Arnaud Bergeron)\n}\n\\date{February 26, 2015}\n\n\\lstdefinestyle{theano}{\nlanguage=Python,\nbasicstyle=\\fontfamily{pcr}\\selectfont\\footnotesize,\nkeywordstyle=\\color{darkgreen}\\bfseries,\ncommentstyle=\\color{greenblue}\\itshape,\n%commentstyle=\\color{blue}\\itshape,\nstringstyle=\\color{violet},\nshowstringspaces=false,\ntabsize=4,\nbackgroundcolor=\\color{lightgray},\nframe=single,\nemph={[2]__init__,make_node,perform,infer_shape,c_code,make_thunk,grad,R_op},emphstyle={[2]\\color{methblue}},\nemph={[3]self},emphstyle={[3]\\color{darkgreen}},\nmoredelim=**[is][{\\color{red}}]{`}{`}\n}\n\n% We don't have code till the end of the file.\n\\lstdefinestyle{output}{\nlanguage={},\nbasicstyle=\\ttfamily\\footnotesize,\nbackgroundcolor=\\color{white},\nframe={},\nbreaklines=true,\nemph={[2]},\nemph={[3]},\n}\n\n\\lstset{style=theano}\n\n\\newcommand{\\code}[1]{\\lstinline[emph={[2]}]|#1|}\n\n\\begin{document}\n\n\\begin{frame}[plain]\n \\titlepage\n% \\vspace{-5em}\n% \\includegraphics[width=1in]{../hpcs2011_tutorial/pics/lisabook_logo_text_3.png}\n% \\hfill\n% \\includegraphics[width=.8in]{../hpcs2011_tutorial/pics/UdeM_NoirBleu_logo_Marie_crop}\n\\end{frame}\n\n\\section{Outline}\n\\begin{frame}{High level}\\setcounter{page}{1}\n  \\begin{itemize}\n  \\item Overview of library (3 min)\n  \\item Building expressions (30 min)\n  \\item Compiling and running expressions (30 min)\n  \\item Modifying expressions (25 min)\n  \\item Debugging (30 min)\n  \\item Citing Theano (2 min)\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Overview of Library}\n  Theano is many things\n  \\begin{itemize}\n  \\item Language\n  \\item Compiler\n  \\item Python library\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Overview}\n  Theano language:\n  \\begin{itemize}\n  \\item Operations on scalar, vector, matrix, tensor, and sparse variables\n  \\item Linear algebra\n  \\item Element-wise nonlinearities\n  \\item Convolution\n  \\item Extensible\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Overview}\n  Using Theano:\n  \\begin{itemize}\n  \\item define expression $f(x,y) = x + y$\n\\begin{lstlisting}\n>>> z = x + y\n\\end{lstlisting}\n  \\item compile expression\n\\begin{lstlisting}\n>>> f = theano.function([x, y], z)\n\\end{lstlisting}\n  \\item execute expression\n\\begin{lstlisting}\n>>> f(1, 2)\n3\n\\end{lstlisting}\n  \\end{itemize}\n\\end{frame}\n\n\\section{Building}\n\n\\begin{frame}{Building expressions}\n  \\begin{itemize}\n  \\item Scalars\n  \\item Vectors\n  \\item Matrices\n  \\item Tensors\n  \\item Broadcasting\n  \\item Reduction\n  \\item Dimshuffle\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Scalar math}\n\\begin{lstlisting}\nfrom theano import tensor as T\nx = T.scalar()\ny = T.scalar()\nz = x+y\nw = z*x\na = T.sqrt(w)\nb = T.exp(a)\nc = a ** b\nd = T.log(c)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Vector math}\n\\begin{lstlisting}\nfrom theano import tensor as T\nx = T.vector()\ny = T.vector()\n# Scalar math applied elementwise\na = x * y\n# Vector dot product\nb = T.dot(x, y)\n# Broadcasting\nc = a + b\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Matrix math}\n\\begin{lstlisting}\nfrom theano import tensor as T\nx = T.matrix()\ny = T.matrix()\na = T.vector()\n# Matrix-matrix product\nb = T.dot(x, y)\n# Matrix-vector product\nc = T.dot(x, a)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Tensors}\n   \\begin{itemize}\n    \\item Dimensionality defined by length of ``broadcastable'' argument\n    \\item Can add (or do other elemwise op) on two\n      tensors with same dimensionality\n    \\item Duplicate tensors along broadcastable axes to\n      make size match\n  \\end{itemize}\n\\begin{lstlisting}\nfrom theano import tensor as T\ntensor3 = T.TensorType(\n    broadcastable=(False, False, False),\n    dtype='float32')\nx = tensor3()\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Broadcasting}\n\\begin{tabular}{lcccccccl}\n    &\n    \\begin{tabular}{cc}\n        1 & 2 \\\\\n        3 & 4 \\\\\n        5 & 6 \\\\\n    \\end{tabular} &\n    + &\n    \\begin{tabular}{cc}\n        1 & 2 \\\\\n    \\end{tabular} &\n    = &\n    \\begin{tabular}{cc}\n        1 & 2 \\\\\n        3 & 4 \\\\\n        5 & 6 \\\\\n    \\end{tabular} &\n    + &\n    \\begin{tabular}{cc}\n        1 & 2 \\\\\n        \\color{blue} 1 & \\color{blue} 2 \\\\\n        \\color{blue} 1 & \\color{blue} 2 \\\\\n    \\end{tabular} &\n    \\hspace{-1.3em}\n    \\tikz[baseline={([yshift=-.5ex]current bounding box.center)}]{\n        \\draw [->, very thick] (0,0) -- (0,-1.2);\n    } \\\\[1.5em]\n    shape: & (3, 2) & & (2,) & & (3, 2) & & ({\\color{blue}3}, 2) &\n\\end{tabular}\n\\vfill\n\\begin{itemize}\n    \\item Pad shape with 1s on the left : $(2,) \\equiv (1,2)$\n    \\item Two dimensions are compatible when they have the same length or one of them is broadcastable\n    \\item broadcastable dimensions must have a length of 1\n    \\item Adding tensors of shape (8, 1, 6, 1) and (7, 1, 5) gives a tensor of shape (8, 7, 6, 5)\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Reductions}\n\\begin{lstlisting}\nfrom theano import tensor as T\ntensor3 = T.TensorType(\n    broadcastable=(False, False, False),\n    dtype='float32')\nx = tensor3()\ntotal = x.sum()\nmarginals = x.sum(axis=(0, 2))\nmx = x.max(axis=1)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Dimshuffle}\n\\begin{lstlisting}\nfrom theano import tensor as T\ntensor3 = T.TensorType(\n    broadcastable=(False, False, False),\n    dtype='float32')\nx = tensor3()\ny = x.dimshuffle((2, 1, 0))\na = T.matrix()\nb = a.T\n# Same as b\nc = a.dimshuffle((0, 1))\n# Adding to larger tensor\nd = a.dimshuffle((0, 1, 'x'))\ne = a + d\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Exercices}\nWork through the \"Building Expressions\" section of the ipython notebook.\n\\end{frame}\n\n\\section{Compiling/Running}\n\\begin{frame}{Compiling and running expression}\n  \\begin{itemize}\n  \\item \\code{theano.function}\n  \\item shared variables and updates\n  \\item compilation modes\n  \\item compilation for GPU\n  \\item optimizations\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{\\code{theano.function}}\n\n\\begin{lstlisting}\n>>> from theano import tensor as T\n>>> x = T.scalar()\n>>> y = T.scalar()\n>>> from theano import function\n>>> # first arg is list of symbolic inputs\n>>> # second arg is symbolic output\n>>> f = function([x, y], x + y)\n>>> # Call it with numerical values\n>>> # Get a numerical output\n>>> f(1., 2.)\narray(3.0)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Shared variables}\n  \\begin{itemize}\n  \\item It’s hard to do much with purely functional programming\n  \\item \\emph{shared variables} add just a little bit of imperative programming\n  \\item A \\emph{shared variable} is a buffer that stores a numerical value for a Theano variable\n  \\item Can write to as many shared variables as you want, once each, at the end of the function\n  \\item  Modify outside Theano function with \\code{get_value()} and \\code{set_value()} methods.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Shared variable example}\n\\begin{lstlisting}\n>>> from theano import shared\n>>> x = shared(0.)\n# Can also use a dict for more complex code\n>>> updates = [(x,  x + 1)]\n>>> f = function([], updates=updates)\n>>> f()\n>>> x.get_value()\n1.0\n>>> x.set_value(100.)\n>>> f()\n>>> x.get_value()\n101.0\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Which dict?}\n  \\begin{itemize}\n  \\item Use theano.compat.python2x.OrderedDict\n  \\item Not collections.OrderedDict\n  \\begin{itemize}\n  \\item This isn’t available in older versions of python, and will limit the portability of your code.\n  \\end{itemize}\n  \\item Not \\code{\\{\\}} aka dict\n  \\begin{itemize}\n  \\item The iteration order of this built-in class is not deterministic so if Theano accepted this, the same script could compile different C programs each time you run it.\n  \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Compilation modes}\n  \\begin{itemize}\n  \\item Can compile in different modes to get different kinds of programs\n  \\item Can specify these modes very precisely with arguments to \\code{theano.function()}\n  \\item Can use a few quick presets with environment variable flags\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Example preset compilation modes}\n  \\begin{description}[FAST\\_RUN]\n  \\item[FAST\\_RUN] Default. Spends a lot of time on\ncompilation to get an executable that runs\nfast.\n  \\item[FAST\\_COMPILE] Doesn’t spend much time compiling.\nExecutable usually uses python\ninstead of compiled C code. Runs slow.\n  \\item[DEBUG\\_MODE] Adds lots of checks.\nRaises error messages in situations other modes don't check for.\n  \\end{description}\n\\end{frame}\n\n\\begin{frame}{Compilation for GPU}\n  \\begin{itemize}\n  \\item Theano's current back-end only supports 32 bit on GPU\n  \\item CUDA supports 64 bit, but is slow in gamer card\n  \\item \\code{T.fscalar}, \\code{T.fvector}, \\code{T.fmatrix} are all 32 bit\n  \\item \\code{T.scalar}, \\code{T.vector}, \\code{T.matrix} resolve to 32 or 64 bit depending on theano’s floatX flag\n  \\item floatX is float64 by default, set it to float32\n  \\item Set the device flag to gpu (or a specific gpu, like gpu0)\n  \\item Optional: warn\\_float64=\\{'ignore', 'warn', 'raise', 'pdb'\\}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Optimizations}\n  \\begin{itemize}\n  \\item Theano changes the symbolic expressions\n    you write before converting them to C code\n  \\item It makes them faster\n  \\begin{itemize}\n  \\item $(x+y)+(x+y) \\to 2\\times(x + y)$\n  \\end{itemize}\n  \\item It makes them more stable\n  \\begin{itemize}\n  \\item $\\exp(a)/\\sum{\\exp(a)} \\to \\operatorname{softmax}(a)$\n  \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Optimizations (2)}\nSometimes optimizations discard error checking and produce incorrect output rather than an exception.\n\\begin{lstlisting}\n>>> x = T.scalar()\n>>> f = function([x], x/x)\n>>> f(0.)\narray(1.0)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Exercises}\nWork through the \"Compiling and Running\" section of the ipython notebook.\n\\end{frame}\n\n\\section{Modifying expressions}\n\\begin{frame}{Modifying expressions}\n  \\begin{itemize}\n  \\item The \\code{grad()} method\n  \\item Variable nodes\n  \\item Types\n  \\item Ops\n  \\item Apply nodes\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{The \\code{grad()} method}\n\\begin{lstlisting}\n>>> x = T.scalar('x')\n>>> y = 2. * x\n>>> g = T.grad(y, x)\n>>> from theano.printing import min_informative_str\n# Print the unoptimized graph\n>>> print min_informative_str(g)\nA. Elemwise{mul}\n B. Elemwise{second,no_inplace}\n  C. Elemwise{mul,no_inplace}\n   D. TensorConstant{2.0}\n   E. x\n  F. TensorConstant{1.0}\n <D>\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{The \\code{grad()} method}\n\\begin{lstlisting}\n>>> x = T.scalar('x')\n>>> y = 2. * x\n>>> g = T.grad(y, x)\n>>> from theano.printing import min_informative_str\n# Print the optimized graph\n>>> f = theano.function([x], g)\n>>> theano.printing.debugprint(f)\nDeepCopyOp [@A] ''   0\n |TensorConstant{2.0} [@B]\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Theano variables}\n  \\begin{itemize}\n  \\item A \\emph{variable} is a theano expression.\n  \\item Can come from \\code{T.scalar()}, \\code{T.matrix()}, etc.\n  \\item Can come from doing operations on other variables.\n  \\item Every variable has a type field, identifying its \\emph{type}, such as \\code{TensorType((True, False), 'float32')}\n  \\item Variables can be thought of as nodes in a graph\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Ops}\n  \\begin{itemize}\n  \\item  An Op is any class that describes a function operating on some variables\n  \\item Can call the op on some variables to get a\nnew variable or variables\n  \\item An Op class can supply other forms of\ninformation about the function, such as its\nderivative\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Apply nodes}\n  \\begin{itemize}\n  \\item The Apply class is a specific instance of an application of an Op.\n  \\item Notable fields:\n    \\begin{description}[\\texttt{outputs}]\n    \\item[\\texttt{op}] The Op to be applied\n    \\item[\\texttt{inputs}] The Variables to be used as input\n    \\item[\\texttt{outputs}] The Variables produced\n    \\end{description}\n  \\item The \\code{owner} field on variables identifies the Apply that created it.\n  \\item Variable and Apply instances are nodes and owner/\n    inputs/outputs identify edges in a Theano graph.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Exercises}\nWork through the \"Modifying\" section in the ipython notebook.\n\\end{frame}\n\n\\section{Debugging}\n\\begin{frame}{Debugging}\n  \\begin{itemize}\n  \\item DEBUG\\_MODE\n  \\item Error message\n  \\item \\code{theano.printing.debugprint()}\n  \\item \\code{min_informative_str()}\n  \\item compute\\_test\\_value\n  \\item Accessing the FunctionGraph\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Error message: code}\n\\begin{lstlisting}\nimport numpy as np\nimport theano\nimport theano.tensor as T\nx = T.vector()\ny = T.vector()\nz = x + x\nz = z + y\nf = theano.function([x, y], z)\nf(np.ones((2,)), np.ones((3,)))\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile,allowframebreaks]{Error message}\n\\vspace{1em}\n\\begin{lstlisting}[style=output]\nTraceback (most recent call last):\n  File \"test.py\", line 9, in <module>\n    f(np.ones((2,)), np.ones((3,)))\n  File \"/Users/anakha/Library/Python/2.7/site-packages/theano/compile/function_module.py\", line 606, in __call__\n    storage_map=self.fn.storage_map)\n  File \"/Users/anakha/Library/Python/2.7/site-packages/theano/compile/function_module.py\", line 595, in __call__\n    outputs = self.fn()\nValueError: Input dimension mis-match. (input[0].shape[0] = 3, input[1].shape[0] = 2)\nApply node that caused the error: Elemwise{add,no_inplace}(<TensorType(float64, vector)>, <TensorType(float64, vector)>, <TensorType(float64, vector)>)\nInputs types: [TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector)]\nInputs shapes: [(3,), (2,), (2,)]\nInputs strides: [(8,), (8,), (8,)]\nInputs values: [array([ 1.,  1.,  1.]), array([ 1.,  1.]), array([ 1.,  1.])]\n\nHINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag  'optimizer=fast_compile'. If that does not work, Theano  optimizations can be disabled with 'optimizer=None'.\nHINT: Use the Theano flag 'exception_verbosity=high'  for a debugprint and storage map footprint of this apply node.\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Error message: exception\\_verbosity=high}\n\\begin{lstlisting}[style=output]\nDebugprint of the apply node: \nElemwise{add,no_inplace} [@A] <TensorType(float64, vector)> ''   \n |<TensorType(float64, vector)> [@B] <TensorType(float64, vector)>\n |<TensorType(float64, vector)> [@C] <TensorType(float64, vector)>\n |<TensorType(float64, vector)> [@C] <TensorType(float64, vector)>\n\nStorage map footprint:\n - <TensorType(float64, vector)>, Shape: (3,), ElemSize: 8 Byte(s), TotalSize: 24 Byte(s)\n - <TensorType(float64, vector)>, Shape: (2,), ElemSize: 8 Byte(s), TotalSize: 16 Byte(s)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Error message: optimizer=fast\\_compile}\n\\begin{lstlisting}[style=output]\nBacktrace when the node is created:\n  File \"test.py\", line 7, in <module>\n    z = z + y\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{debugprint}\n\\begin{lstlisting}\n>>> from theano.printing import debugprint\n>>> debugprint(a)\nElemwise{mul,no_inplace} [@A] ''\n |TensorConstant{2.0} [@B]\n |Elemwise{add,no_inplace} [@C] 'z'\n   |<TensorType(float64, scalar)> [@D]\n   |<TensorType(float64, scalar)> [@E]\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{min\\_informative\\_str}\n\\begin{lstlisting}\n>>> x = T.scalar()\n>>> y = T.scalar()\n>>> z = x + y\n>>> z.name = 'z'\n>>> a = 2. * z\n>>> from theano.printing import min_informative_str\n>>> print min_informative_str(a)\nA. Elemwise{mul,no_inplace}\n B. TensorConstant{2.0}\n C. z\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{compute\\_test\\_value}\n\\begin{lstlisting}\n>>> from theano import config\n>>> config.compute_test_value = 'raise'\n>>> x = T.vector()\n>>> import numpy as np\n>>> x.tag.test_value = np.ones((2,))\n>>> y = T.vector()\n>>> y.tag.test_value = np.ones((3,))\n>>> x + y\n...\nValueError: Input dimension mis-match.\n(input[0].shape[0] = 2, input[1].shape[0] = 3)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Accessing a function’s fgraph}\n\\begin{lstlisting}\n>>> x = T.scalar()\n>>> y = x / x\n>>> f = function([x], y)\n>>> debugprint(f.maker.fgraph.outputs[0])\nDeepCopyOp [@A] ''\n |TensorConstant{1.0} [@B]\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Exercises}\nWork through the \"Debugging\" section of the ipython notebook.\n\\end{frame}\n\n\\section*{}\n\\begin{frame}{Citing Theano}\nPlease cite both of the following papers in all work that uses Theano:\n  \\begin{itemize}\n  \\item Bastien, Frédéric, Lamblin, Pascal, Pascanu, Razvan, Bergstra, James, Goodfellow, Ian, Bergeron, Arnaud, Bouchard, Nicolas, and\n     Bengio,Yoshua. Theano: new features and speed improvements. Deep Learning and Unsupervised Feature Learning NIPS 2012\n    Workshop, 2012.\n  \\item Bergstra, James, Breuleux, Olivier, Bastien, Frédéric, Lamblin, Pascal, Pascanu, Razvan, Desjardins, Guillaume, Turian, Joseph, Warde-\n     Farley, David, and Bengio,Yoshua. Theano: a CPU and GPU math expression compiler. In Proceedings of the Python for Scientific\n      Computing Conference (SciPy), June 2010. Oral Presentation.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Example acknowledgments}\nWe would like to thank the developers of Theano \\textbackslash citep\\{bergstra+al:2010-scipy,Bastien-Theano-2012\\}.\nWe would also like to thank NSERC, Compute Canada, and Calcul Québec for providing computational resources.\n\\end{frame}\n\n\n\\begin{frame}\n\\begin{center}\n\\bibliography{strings,strings-short,ml,aigaion-shorter}\n\\Huge\nQuestions?\n\\end{center}\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "dc0c481f0acaa534af2bba130846933e327a063d", "size": 18531, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation.tex", "max_stars_repo_name": "abergeron/ccw_tutorial_theano", "max_stars_repo_head_hexsha": "f92aa8edbb567c9ac09149a382858f841a4a7749", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-03-05T09:11:04.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-30T02:57:36.000Z", "max_issues_repo_path": "presentation.tex", "max_issues_repo_name": "nd1511/ccw_tutorial_theano", "max_issues_repo_head_hexsha": "f92aa8edbb567c9ac09149a382858f841a4a7749", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-03-30T23:03:48.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-31T00:36:51.000Z", "max_forks_repo_path": "presentation.tex", "max_forks_repo_name": "nd1511/ccw_tutorial_theano", "max_forks_repo_head_hexsha": "f92aa8edbb567c9ac09149a382858f841a4a7749", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2015-01-17T18:53:20.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-29T20:25:01.000Z", "avg_line_length": 28.4217791411, "max_line_length": 274, "alphanum_fraction": 0.7023366251, "num_tokens": 5732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4494185013109336}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\n\\title{Modeling with Python and SMAP}\n\\author{Sarah Koehler}\n\\date{April 2015}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Modeling}\nMany say modeling is an art. Let's look at the simplest forms of this art.\n\nLinear Model:\n\\begin{align}\nx(k+1) &= Ax(k) + Bu(k)  \\\\\ny(k) &= Cx(k) + Du(k)\n\\end{align}\n\\noindent Let's assume $y(k) = x(k)$. \n\nIn the most general case, define $x$ to be all physical \\textit{outputs} and $u$ to be all \\textit{controllable inputs}. You can also add an additive $ + Ed(k)$ where $d$ are all \\textit{uncontrollable inputs}. \n\nA form that works well for Temperature dynamics is a bilinear form. Specifically:\n\\begin{align}\nT(k+1) = AT(k) + ...\n\\end{align}\n(TO DO: To be copied from ME 231 write ups)\n\n\\pagebreak\n\\section{Identification Method}\nTwo methods are Least Squares and Lasso. An oversimplified explanation is that Least Squares considers all data streams equally important, while Lasso selects the important streams (i.e. feature selection). Both select the corresponding weight for that stream.\n\nLeast Squares from Python scikit-learn:\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=\\columnwidth]{LeastSquaresPython.pdf}\n\\caption{Documentation on Least Squares}\n\\label{fig:lasso}\n\\end{figure}\n\n\\pagebreak\nLasso from Python scikit-learn:\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=\\columnwidth]{LassoPython.pdf}\n\\caption{Documentation on Lasso}\n\\label{fig:lasso}\n\\end{figure}\n\n\\section{Data Manipulation}\nThis is the most annoying part and it would be great to never ever have to do this again.\n\nTO DO: Copy python code when it's done and/or write the math here.\n\n\\section{Validation}\nCross-validation is important! The model usually fits the day it was identified on.\n\nTO DO: Show some plots of same day verification and cross day verification.\n\n\\section{Matlab code}\n\\begin{verbatim}\n% % Interpolate data\n% interp_start = PDTtoUTC(datenum(2014,9,4,4,0,0));\n% interp_end = PDTtoUTC(datenum(2014,9,4,16,0,0));\ninterp_start = datenum(2014,8,30,10,1,0);\ninterp_end = datenum(2014,8,30,16,0,0);\ninterp_times = (interp_start:1/24/60:interp_end)';\n\n\nfan_interp = interp1(fan_data(:,1),fan_data(:,2),interp_times);\ntemp_interp = interp1(temp_data(:,1),temp_data(:,2),interp_times);\nsupplytemp_interp = interp1(supplytemp_data(:,1),supplytemp_data(:,2),interp_times);\n\n% Solve least squares using quadprog\nN = length(interp_times)-2;\nH = 2*(blkdiag(zeros(2,2),eye(N)));\nf = zeros(N+2,1);\nAeq = [zeros(N,2),-eye(N)];\nbeq = zeros(N,1);\nfor k = 1:N\n   f(k+2) = -2*temp_interp(k+1);\n   Aeq(k,1:2) = [-fan_interp(k)*temp_interp(k),fan_interp(k)*supplytemp_interp(k)];\n   beq(k) = -temp_interp(k);\nend\n\n% options = optimset('Algorithm','interior-point-convex');\n% [x,cost] = quadprog(H,f,[],[],Aeq,beq,[],[],[],options);\n[x,cost] = quadprog(H,f,[],[],Aeq,beq);\n\na = x(1);\nb = x(2);\n\n%% Least Squares via A\\b\nA = Aeq(:,1:2);\nb = zeros(N,1);\nfor k = 1:N\n   b(k) = -temp_interp(k)+temp_interp(k+1);\nend\n\nx = A\\b;\na = x(1);\nb = x(2);\n\n\\end{verbatim}\n\n\\section{Python code}\nAt this point can open up Python code like Arka did and expose the issues we have with its structure.\n\nTO DO: Can also make a list of issues here:\n\\begin{itemize}\n\\item Cannot choose system ID procedure without digging into code\n\\item Need a library of models to choose from? Not everything is linear or bilinear...\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "1b02bbd6bf9f24dbe29938357a90036533353ac6", "size": 3464, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/main.tex", "max_stars_repo_name": "smukoehler/SDB-control", "max_stars_repo_head_hexsha": "50b2f4b3faa47d64d8c92a1b095f8d624c41e7f2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/main.tex", "max_issues_repo_name": "smukoehler/SDB-control", "max_issues_repo_head_hexsha": "50b2f4b3faa47d64d8c92a1b095f8d624c41e7f2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/main.tex", "max_forks_repo_name": "smukoehler/SDB-control", "max_forks_repo_head_hexsha": "50b2f4b3faa47d64d8c92a1b095f8d624c41e7f2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6280991736, "max_line_length": 260, "alphanum_fraction": 0.7208429561, "num_tokens": 1055, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.4494185006638501}}
{"text": "%%==========================\n%% Chapter 4.0: Introduction\n%%==========================\n\n\\documentclass[../dissertation.tex]{subfiles}\n\n\\begin{document}\n% \\setcounter{section}{-1}\n\\section{Introduction}\\label{sec4.0:Intro}\n\nFollowing our deep dive into the properties of the Green's functions, let us take\na brief respite to see where we are in the process of understanding the direct\nmap for the Intermediate Long Wave equation Inverse Scattering Transform. In Section\n\\ref{sec0:DM} we introduced the notion of a Jost Solution, which we now repeat for\nreference: \n\\begin{defn}[Jost solutions]\\label{defn4:jost}\n\tRecall the linear spectral problem \n\t\\begin{align}\\label{eq4:SpecProb}\n\t\tL_\\delta (\\Psi) \n\t\t\t:= \\frac{1}{i} \\frac{\\partial}{\\partial x} \\Psi^+ \n\t\t\t\t- \\zeta \\left(\\Psi^+ - \\Psi^-\\right) = u \\Psi^+,\n\t\\end{align}\n\tThe Jost solutions $M_1$, $M_e$, $N_1$, $N_e$ are solutions to the linear \n\tspectral problem \\eqref{eq4:SpecProb} whose lower boundary values\n\t$M_1^+$, $M_e^+$, $N_1^+$, $N_e^+$ as defined in \\eqref{eq0:bndryvaluedefn}\n\tobey the following asymptotic conditions\n\t\\begin{subequations}\\label{eq4:JostDEasymp}\n\t\t\\begin{align}\n\t\t\t\\lim_{x\\to -\\infty} \n\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\\left( \n\t\t\t\t\t\tM_1^+(x; \\lambda, \\delta) - 1 \n\t\t\t\t\t\\right)\n\t\t\t\t&= \\lim_{x\\to \\infty} \n\t\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\t\\left( \n\t\t\t\t\t\t\tN_1^+(x; \\lambda, \\delta) - 1\n\t\t\t\t\t\t\\right)\n\t\t\t\t= 0 \\\\\n\t\t\t\\lim_{x\\to -\\infty} \n\t\t\t\t\t\\inn{x} \\left( \n\t\t\t\t\t\tM_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\n\t\t\t\t\t\\right)\n\t\t\t\t&= \\lim_{x\\to \\infty} \n\t\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\t\\left( \n\t\t\t\t\t\t\tN_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\n\t\t\t\t\t\t\\right)\n\t\t\t\t= 0\n\t\t\\end{align}.\n\t\\end{subequations}\n\n\tAdditionally, we require the upper boundary values $M_{(\\dotarg)}^-$, $N_{(\\dotarg)}^-$\n\t(where $(\\dotarg)$ represents either the subscript $1$ or $e$) of \n\t$M_{(\\dotarg)}$, $N_{(\\dotarg)}$ to have a decomposition \n\t\\begin{align*}\n\t\tM_1^- - 1 &= M_1^{(1)} + M_1^{(2)} \\qquad &\\text{and}& \\qquad\n\t\t&N_1^- - 1 &= N_1^{(1)} + N_1^{(2)} \\\\\n\t\tM_e^- - e^{i\\lambda x}\\,e^{-2\\delta\\lambda} &= M_e^{(1)} + M_e^{(2)} \\qquad &\\text{and}& \\qquad\n\t\t&N_e^- - e^{i\\lambda x}\\,e^{-2\\delta\\lambda} &= N_e^{(1)} + N_e^{(2)} \\\\\n\t\\end{align*}\n\tsatisfying \n\t\\begin{align*}\n\t\t\\inn{x}^{1+\\upsilon} \\left|M_{(\\dotarg)}^{(1)}(x)\\right| \\lesssim 1 \n\t\t\t\\quad (\\text{for } x \\ll -1), \\qquad \n\t\t\\inn{x}^{1+\\upsilon} \\left|N_{(\\dotarg)}^{(1)}(x)\\right| \\lesssim 1\n\t\t\t\\quad (\\text{for } x \\gg 1),\n\t\\end{align*}\n\tand\n\t\\begin{align*}\n\t\t\\inn{\\dotarg}^\\tau M_{(\\dotarg)}^{(2)}, \n\t\t\t~\\inn{\\dotarg}^\\tau N_{(\\dotarg)}^{(2)} \\in L^2(\\mathbb R)\n\t\\end{align*}\n\tfor any $\\upsilon \\in \\left(0,\\frac{1}{2}\\right)$ and $\\tau \\in [0,1)$.\n\\end{defn}\n\nThe direct scattering map \n$\\mathscr D$ maps $u$ to the reflection coefficient \n$r(\\lambda) := b(\\lambda) / a(\\lambda)$ where $a$ and $b$ are determined by \nthe following formulas involving the boundary value $M_1^+$ of the Jost solution\n$M_1$\n\\begin{subequations}\n\t\\label{eq3:ScatData}\n\t\\begin{align}\n\t\t\\label{eq3:ScatDataA}\n\t\ta(\\lambda) \n\t\t\t&= 1 + i \\alpha(\\lambda) \n\t\t\t\t\\int_{\\mathbb R} \n\t\t\t\t\tu(x) \\, M_1^+(x;\\lambda, \\delta, u) \n\t\t\t\t\\, \\mathrm{d}x \\\\\n\t\t\\label{eq3:ScatDataB}\n\t\tb(\\lambda)\n\t\t\t&= i \\beta(\\lambda) \n\t\t\t\t\\int_{\\mathbb R} \n\t\t\t\t\te^{-i\\lambda x} \\, u(x) \\, M_1^+(x; \\lambda, \\delta, u)\n\t\t\t\t\\, \\mathrm{d}x,\n\t\\end{align}\n\\end{subequations}\nwhere we have written the Jost solutions as functions of $u$ in order to \nexplicitly highlight the dependence of the Jost solutions on the eigenfunction $u$.\nThe goal of this chapter is to both prove that $\\mathscr D$ is well-defined and\nLipschitz continuous for $|\\lambda| > 1$.\n\nAs we see from \\eqref{eq3:ScatData}, proving that $\\mathscr D$ is well defined \nrequires the Jost solutions to exist and be unique. Further, in order to prove \nthat $\\mathscr D$ is Lipschitz continuous, we need to establish that \nthe four maps from $u$ to each of the four Jost solutions $M_1$, $M_e$, $N_1$, \nand $N_e$ are themselves Lipschitz as maps from $B_X(0, c_0)$ to \n$\\inn{\\dotarg}L^\\infty(\\mathbb R)$. As is common practice in the inverse \nscattering world, to prove these desired results we seek to reformulate \n\\eqref{eq4:SpecProb} with asymptotic conditions \\eqref{eq4:JostDEasymp} as a set \nof integral equations that are easier to analyze. This approach is relevant in \nour case given the limited theory about partial differential equations \ninvolving functions analytic in a complex strip and the functions' lower and \nupper boundary values along the corresponding boundary values of the strip.\n\nFollowing our analysis of $G_L$ and $G_R$ in Chapters \\ref{cptr01:GF} and\n\\ref{cptr03:xContin} we are almost now in a position to prove (under the right hypotheses) \nthe equivalence of the Jost solutions and solutions to the following integral\nequations\n\\begin{subequations}\n\t\\label{eq4:JostIE}\n\t\\begin{align}\n\t\t\\label{eq4:JostIEleft}\n\t\t\\begin{pmatrix}\n\t\t\tM_1^+(x; \\zeta, \\delta) \\\\\n\t\t\tM_e^+(x; \\zeta, \\delta)\n\t\t\\end{pmatrix}\n\t\t\t&= \n\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t1 \\\\\n\t\t\t\t\te^{i\\lambda x} \n\t\t\t\t\\end{pmatrix}\n\t\t\t\t+ \\int_{\\mathbb R} G_L(x - x'; \\zeta, \\delta) \n\t\t\t\t\tu(x')\n\t\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t\tM_1^+(x'; \\zeta, \\delta) \\\\\n\t\t\t\t\t\tM_e^+(x'; \\zeta, \\delta) \n\t\t\t\t\t\\end{pmatrix}\n\t\t\t\t\t\\, \\mathrm{d}x' \\\\[0.3\\baselineskip]\n\t\t\\label{eq4:JostIEright}\n\t\t\\begin{pmatrix}\n\t\t\tN_1^+(x; \\zeta, \\delta) \\\\\n\t\t\tN_e^+(x; \\zeta, \\delta)\n\t\t\\end{pmatrix}\n\t\t\t&= \n\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t1 \\\\\n\t\t\t\t\te^{i\\lambda x} \n\t\t\t\t\\end{pmatrix}\n\t\t\t\t+ \\int_{\\mathbb R} G_R(x - x'; \\zeta, \\delta) \n\t\t\t\t\tu(x')\n\t\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t\tN_1^+(x'; \\zeta, \\lambda) \\\\\n\t\t\t\t\t\tN_e^+(x'; \\zeta, \\lambda) \n\t\t\t\t\t\\end{pmatrix}\n\t\t\t\t\t\\, \\mathrm{d}x'.\n\t\\end{align}\n\\end{subequations}\nIn Section \\ref{sec4:equiv} we prove this equivalence.\nWe begin by presenting the framework we use to prove this equivalence, \nfollowed by proving in Subsection \\ref{subsec4:DEtoIE} that Jost solutions solve the \ncorresponding integral equations \\eqref{eq4:JostIE}. We prove solutions to \n\\eqref{eq4:JostIE} are Jost solutions in the following subsection, Section \n\\ref{subsec4:IEtoDE}.\nHowever, for reasons that are made obvious in \nSection \\ref{sec4:equiv}, prior to proving \nthe equivalence of Jost solutions and solutions to \\eqref{eq4:JostIE}, we do need \nseveral results about both the existence of solutions of solutions to \\eqref{eq4:JostIE}\nand the continuity of maps from $u$ to \\eqref{eq4:JostIE} solutions. For this reason, \nwe begin this chapter by studying the \\eqref{eq4:JostIE} solutions in Section \n\\ref{sec4:Exist}, and note that because we prove in Section \\ref{sec4:equiv} the\nequivalence of Jost solutions and the solutions to the integral equations \\eqref{eq4:JostIE},\nthe results proven in Section \\ref{sec4:Exist} about the existence and uniqueness \n\\eqref{eq4:JostIE} solutions applies to Jost solutions.\n\nThe final section of this chapter, Section \\ref{sec4:DM}, is the \n\\textit{rasion d'\\^etre} of this dissertation, in that after \n\\pageref{lastpagePenultimateSection} pages of diligent mathematical exploration, \nwe arrive at our study of the ILW direct scattering map. We begin Section \n\\ref{sec4:DM} by verifying the so-called ``scattering equations'' which are\ninstrumental in the formulation of the ILW inverse scattering map. We then prove \nthat as a map from $B_X(0, c_0)$ to $L_\\lambda^\\infty(\\mathbb R)$ the direct \nscattering map $\\mathscr D$ is well-defined (Theorem \\ref{thm4:Dwelldefined}), \nwhere  $B_X(0, c_0)$ in the space $X$ of radius $c_0$ and $c_0$ is chosen \naccording to our work in Section \\ref{sec4:Exist} to ensure the existence of the\nJost solutions. In the remainder of Section \\ref{sec4:DM}, we turn our attention\ntowards understanding the Lipschitz continuity properties of $\\mathscr D$. Specifically,\nwe prove that as a map from $B_X(0, c_0)$ to \n$L_\\lambda^\\infty\\big((-\\infty,k]\\cap[k, \\infty) \\big)$, the direct scattering map \n$\\mathscr D$ is Lipschitz continous for all $k>0$ (Theorem \\ref{thm4:DlipR}). As\nan almost immediate consequence of our proof of Theorem \\ref{thm4:DlipR}, we \nalso prove Corollary \\ref{cor4:Lip}, which holds that for every \n$u \\in B_X(0,c_0)$ with the property that \n\\[\n\t\\int_{\\mathbb R} u \\, M_1^+(x; \\lambda = 0) \\, \\mathrm{d}x \\ne 0,\n\\]\nthere is a neighborhood $\\mathcal N(u)$ in $B_X(0, c_0)$ about $u$ for which \nthe map $\\mathscr D: \\mathcal N(u) \\to L^\\infty_\\lambda(\\mathbb R)$ is \nLipschitz continuous. \n\n\n\n\nWhile we have not yet found a proof that $\\mathscr D$ is Lipschitz continuous \nuniformly in the parameter $\\lambda$ for all real $\\lambda$ (which is necessary \nas the scattering data are functions of $\\lambda$), we do discuss the regimes \nunder which we are currently able to prove that $\\mathscr D$ is Lipschitz \ncontinuous. \n\nA final remark as we set off on the ultimate leg of our mathematical \nperegrination within this dissertation: \ngiven the $\\delta$-dilation property satisfied by both $G_L$ and $G_R$, throughout \nthe remainder of this Chapter, we again take $\\delta = 1$ noting that the more general \ncase of $\\delta>0$ arbitrary follows from this dilation property and the results\ncontained within this chapter. \n\n\\end{document}", "meta": {"hexsha": "76b0337bb08ad10f07b2f8023df3d415c4187489", "size": 9058, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4-Jost/4.0-Intro.tex", "max_stars_repo_name": "ADGC/ilw-dsm-dissertation", "max_stars_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter4-Jost/4.0-Intro.tex", "max_issues_repo_name": "ADGC/ilw-dsm-dissertation", "max_issues_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4-Jost/4.0-Intro.tex", "max_forks_repo_name": "ADGC/ilw-dsm-dissertation", "max_forks_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5504587156, "max_line_length": 97, "alphanum_fraction": 0.675314639, "num_tokens": 3104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.4494184964123334}}
{"text": "\\chapter{Introduction}\n\n\\section{Financial Contracts}\n\nIn the real world, two parties may create a \\textit{financial contract} to describe a set of payments to be made between them under certain conditions. These contracts can suffer from numerous issues in real world usage; for one thing, the financial world is plagued with jargon, which can make contracts difficult to interpret, and complicated to compose. This can lead to unneeded verbosity, where certain terms may be repeated multiple times in a single contract. Traditional financial contracts can also be difficult to analyse mathematically in terms of potential cost or value, due to their complexity and potential ambiguity - resulting in the appearance of unnoticed errors in contract definitions.\n\n\\section{A Combinator Domain-Specific Language to Represent Contracts}\n\nA hypothetical solution to alleviate some of these issues has been proposed by Simon Peyton Jones, Jean-Marc Eber, and Julian Seward in the paper \\textit{Composing Contracts: An Adventure in Financial Engineering}\\cite{SPJ}. Their proposed solution employs a combinator domain-specific language, which is a type of functional programming language where specific terms, i.e. \\textit{combinators}, can be composed to produce a program. This solution involves using combinators to represent financial contracts. This is possible as these financial contracts can typically be described such that they are composed of smaller contracts - i.e. \\textit{sub-contracts}. These combinators can be as simple as \\texttt{one}, which requires the counter-party to pay a single unit of a given currency to the owner. They can also describe transformations on inner combinators, such as \\texttt{scale}, which multiplies any monetary values in inner combinators by a given value. The contract \\texttt{scale(5, one(GBP))} will therefore require the counter-party to pay the owner \\pounds 5. \\\\\n\nThe definition of financial contracts using a combinator DSL has numerous upsides. For one thing, even with few combinators a contract writer can define a huge variety of financial contracts, thus reducing the amount of jargon required. If any contracts which cannot be represented by the combinator DSL are found, new combinators can easily be added due to their modular nature. Programmatic definition of financial contracts can also cut down on needless repetition, and there is no room for interpretation. Additionally, the use of combinators facilitates mathematical analysis of financial contracts' values, by the composable nature of these values - where each combinator's value is a function of their inner combinators' values. While there is an implementation of an evaluation process for financial contracts written in the DSL, there is no programmatic implementation of these contracts.\n\n\\section{Smart Contracts}\n\nSince the original DSL was first described, cryptocurrencies have proliferated; because of this, it has become popular to represent financial contracts using \\textit{smart contracts}. Smart contracts are programs which can be deployed to a blockchain, and then called at any time to execute some specified code. One specific functionality they provide is the ability to obtain and transfer cryptocurrencies, thus facilitating payments between multiple parties under specified conditions in an automated manner\\cite{Eth}. Writing smart contract representations of financial contracts allows financial institutions to use blockchains between institutions for payment of funds according to these financial contracts, or simply to keep track of existing financial contracts for auditing purposes thanks to the immutability of blockchains. \\\\\n\nWhile existing smart contract languages can provide a strict and unambiguous smart contract representation of a financial contract, i.e. a \\textit{financial smart contract}, there are issues with this manner of implementation. One such issue is that many smart contract languages are exceedingly error-prone, meaning that it is very possible to write a financial smart contract with unintended consequences - in fact, it has been estimated that 45\\% of smart contracts on the Ethereum blockchain (a platform for hosting smart contracts) contain vulnerabilities\\cite{EthSec}. \\\\\n\nTake the smart contract code in listing \\ref{listing:reentrancy}, written in Solidity (a programming language for smart contracts); this code simply transfers funds from the smart contract to the caller, and then decrements a \\textit{balance} representing the funds the caller can withdraw. To the untrained eye (and the Solidity compiler), this code snippet contains no errors; in actuality, it contains one of the most severe kinds of vulnerabilities, allowing a reentrancy attack from a malicious user. A reentrancy attack is where funds are transferred before a function's invocation is finished, allowing the function to be called again before the transfer is complete and the balance is decremented (as transfers can trigger function calls)\\cite{eth-known-attacks}. This can result in the smart contract being drained of all of its funds. This is an example of a severe vulnerability that can be easy to miss when implementing smart contracts in a smart contract language. \\\\\n\n\\begin{lstlisting}[language=Solidity, caption=A Solidity function which is vulnerable to a reentrancy attack$^1$., captionpos=b, label=listing:reentrancy]\nfunction withdrawOneWei() public {\n    msg.sender.call.value(1);\n    balances[msg.sender] = balances[msg.sender] - 1;\n}\n\\end{lstlisting}\n\\stepcounter{footnote}\n\\footnotetext{Solidity syntax highlighting obtained from the \\texttt{solidity-latex-highlighting} package written by Sergei Tikhomirov, used under the MIT license, available at \\url{https://github.com/s-tikhomirov/solidity-latex-highlighting}.}\n\nSmart contracts are also difficult to analyse mathematically in terms of definitive costs, as most smart contract languages are relatively complex (in comparison to the combinator DSL mentioned earlier). Complex functionality like iteration and recursion can make the outcome of program execution difficult to evaluate, and also makes errors relatively easy to introduce and difficult to discover. These features are not required for the representation of financial contracts, as demonstrated by their absence from the aforementioned DSL. Overall, the issues mentioned here make smart contract languages a risky choice when creating financial smart contracts, as it can be easy to allow erroneous behaviour to occur, and difficult to find such errors by analysis.\n\n\\section{Our Contributions}\n\nIn this work, we present several contributions with the aim of improving the ease of implementation and reducing the risk of erroneous behaviour for financial smart contracts: \\\\\n\n\\begin{enumerate}\n    \\item \\textbf{SmartFin}: A combinator DSL for representing financial contracts, derived from the \\textit{original DSL} created by Peyton Jones et al.\\cite{SPJ}, with slight modifications to enable a smart contract implementation. The design of SmartFin is detailed in chapter \\ref{combinator-DSL}.\n    \\item \\textbf{SmartFin Smart Contract Implementation}: An Ethereum-compatible smart contract that can represent any given SmartFin financial contract as a financial smart contract. The implementation of this smart contract is detailed in chapters \\ref{smart-contract-impl} and \\ref{combinators-main}.\n    \\item \\textbf{Web Client}: A web client for managing SmartFin smart contracts. The implementation of the web client is detailed in chapter \\ref{web-client}. The web client implements the following functionality:\n    \\begin{itemize}\n        \\item Composition of SmartFin financial contracts, with syntax verification and detailed error reporting with stack traces.\n        \\item Evaluation of SmartFin financial contracts in a step-by-step manner, to calculate the value that a contract is worth given all required external input (provided by the user) at each required step. The times that all evaluated payments would occur can also be displayed.\n        \\item Deployment of SmartFin financial smart contracts to any compatible blockchain.\n        \\item Monitoring of any deployed SmartFin financial smart contracts state, and displaying this state to a user.\n        \\item Interaction with deployed SmartFin financial smart contracts, allowing users to provide any input that the financial contract requires. \\\\\n    \\end{itemize}\n\\end{enumerate}\n\nWith all of these tools together, a user can define a financial contract in the SmartFin DSL using the web client; this SmartFin financial contract can be evaluated in the web client in a step-by-step manner, or can be passed to the implemented smart contract and deployed to a connected compatible blockchain. The deployed financial smart contract can be monitored and interacted with through the web client, and as such all of the required functionality to use SmartFin financial smart contracts is available in the web client. The implemented smart contract can take any given SmartFin contract definition in its constructor and modify its state so that its behaviour matches the given financial contract's behaviour, by implementing logic for all combinators' semantics. A dependency graph of the contributions implemented is depicted in figure \\ref{fig:contributions-block}. \\\\\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\textwidth]{contributions-block.png}\n    \\caption{A dependency graph of the modules implemented for this project, with their approximate \\textit{Lines of Code} (not including tests).}\n    \\label{fig:contributions-block}\n\\end{figure}\n\n\n\\section{Challenges}\n\n\\subsubsection{SmartFin Smart Contract Implementation}\n\nImplementing the SmartFin combinator DSL in a smart contract is no small feat; while the number of combinators is relatively limited, representing \\textit{any} set of combinators requires a robust generic design when it comes to the implementation of the combinators' semantics and state. Furthermore, this design needed be applicable to \\textit{all} combinators, and some are quite unintuitive to represent programmatically. The representation of SmartFin combinators is described in chapter \\ref{combinators-main}.\n\n\\subsubsection{Ethereum Limitations}\n\nDue to limitations of the Ethereum platform, it is not possible to create a one-to-one representation of a SmartFin contract in smart contract form. Designing solutions to the issues caused by the nature of the Ethereum platform required compromises to be made, and minimising the resulting compromises required designing multiple alternative solutions and evaluating them objectively. Solutions to issues stemming from the Ethereum platform are discussed in chapter \\ref{smart-contract-impl}.\n\n\n\\subsubsection{SmartFin Contract Evaluation}\n\nEvaluating SmartFin financial contracts is not a simple problem, even when approaching it in a step-by-step manner, for a couple of reasons. One issue is that SmartFin contracts deal heavily with time, making time an important factor in the evaluation of SmartFin contracts. Keeping track of distinct periods of time based on the SmartFin contract and user interaction was required for step-by-step analysis, requiring a system of describing these time periods to be designed and implemented. Furthermore, keeping track of the current state while requiring the user to enter data can be quite complex, and the ability for the user to revert to any earlier state of step-by-step evaluation can make this even worse. Additionally, the evaluation process requires backtracking for certain combinators, thus resulting in even more complicated behaviour. The implementation of step-by-step evaluation is described in section \\ref{client-evaluate}.", "meta": {"hexsha": "39edf76006622609876d2e285fb91d534ad63eba", "size": 11749, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/src/introduction.tex", "max_stars_repo_name": "danrobdean/SmartFin", "max_stars_repo_head_hexsha": "7dd6ea1cc279bbeb19f0b8094ff35e1c7d49a87f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/src/introduction.tex", "max_issues_repo_name": "danrobdean/SmartFin", "max_issues_repo_head_hexsha": "7dd6ea1cc279bbeb19f0b8094ff35e1c7d49a87f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-17T15:32:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T15:59:17.000Z", "max_forks_repo_path": "report/src/introduction.tex", "max_forks_repo_name": "danrobdean/SmartFin", "max_forks_repo_head_hexsha": "7dd6ea1cc279bbeb19f0b8094ff35e1c7d49a87f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-13T16:31:30.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-13T16:31:30.000Z", "avg_line_length": 163.1805555556, "max_line_length": 1075, "alphanum_fraction": 0.8145374074, "num_tokens": 2289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4494184879092996}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\n% These are extra packages that you might need for writing the equations:\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{booktabs}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\lstset {language=C++,\n\t\t basicstyle=\\ttfamily,\n         keywordstyle=\\color{blue}\\ttfamily,\n         stringstyle=\\color{red}\\ttfamily,\n         commentstyle=\\color{purple}\\ttfamily,\n         morecomment=[l][\\color{magenta}]{\\#},\n       \t basicstyle=\\tiny}\n\n% You need the following package in order to include figures in your report:\n\\usepackage{graphicx}\n\n% With this package you can set the size of the margins manually:\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\n\n\\begin{document}\n\n% Enter the exercise number, your name and date here:\n\\noindent\\parbox{\\linewidth}{\n \\parbox{.25\\linewidth}{ \\large ICP, Exercise 01 }\\hfill\n \\parbox{.5\\linewidth}{\\begin{center} \\large Beat Hubmann \\end{center}}\\hfill\n \\parbox{.2\\linewidth}{\\begin{flushright} \\large Sep 30, 2018 \\end{flushright}}\n}\n\\noindent\\rule{\\linewidth}{2pt}\n\n\n\\section{Introduction}\n\nSeveral small experiments on a basic congruential random number generator were conducted.\n\n\\section{Algorithm Description}\nThe congruential random number generator employed generates pseudo-random numbers $x_i$ based on the linear recurrence relation $x_{i+1} = (c \\cdot x_i)\\; \\text{mod} \\; p \\: \\text{where} \\: c, p \\in \\mathbb{R} $~.\n\n\\section{Results}\n\n\\subsection{Task 1}\n\n\\subsubsection{Subtask 1.1}\n200 random numbers were generated using $c = 3, \\: p = 31$ and plotted for the square test. As shown in figure~\\ref{fig:1a}, three lines were observed after normalizing the generated numbers with $x_i \\gets \\frac{x_i}{p}$.\n\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[scale=0.9]{figure1a.eps} \n\\end{center}\n\\caption{Square test for congruential random number generator with $c = 3, \\: p = 31$.}\n\\label{fig:1a}\n\\end{figure}\n\n\n\\subsubsection{Subtask 1.2}\nAs in the previous task, 200 random numbers were generated using $c = 3, \\: p = 31$ and plotted for the cube test. As shown in figure~\\ref{fig:1b}, regular patterns can be observed after normalizing the generated numbers with $x_i \\gets \\frac{x_i}{p}$, but identifying planes is somewhat difficult owing to the spacing caused by the short period.\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[scale=0.9]{figure1b.eps} \n\\end{center}\n\\caption{Cube test for congruential random number generator with $c = 3, \\: p = 31$.}\n\\label{fig:1b}\n\\end{figure}\n\n\\subsubsection{Subtask 1.3}\nThe random number generator was modified to run with $c = 2836, \\: p = 127773$ to yield a substantially longer period and improved pseudo-randomness. As evident in figures~\\ref{fig:1c}~and~\\ref{fig:1d}, regular patterns appear much less common.\n\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[scale=0.9]{figure1c.eps} \n\\end{center}\n\\caption{Square test for congruential random number generator with $c = 2836, \\: p = 127773$.}\n\\label{fig:1c}\n\\end{figure}\n\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[scale=0.9]{figure1d.eps} \n\\end{center}\n\\caption{Cube test for congruential random number generator with $c = 2836, \\: p = 127773$.}\n\\label{fig:1d}\n\\end{figure}\n\n\n\n\\subsection{Task 2}\nIn polar coordinates, the angle $\\phi$ can be chosen from a uniform distribution as the setup is invariant to rotation about the centre of the circle. The radius coordinate~$r$ however needs to be transformed $r \\gets \\sqrt{z} \\;, \\; z \\sim \\text{Unif} (0,1) $ as sampling from a uniform distribution would yield too much mass near the centre of the circle. Plotting 200 random numbers generated with $c = 2836, \\: p = 127773$ on a circle with radius $R=1$ and center $(0, 0)$ yields the result shown in figure~\\ref{fig:2}.\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[scale=0.9]{figure2.eps} \n\\end{center}\n\\caption{Output of congruential random number generator with $c = 2836, \\: p = 127773$ plotted on circle with radius $R=1$ and center $(0, 0)$.}\n\\label{fig:2}\n\\end{figure}\n\n\n\n\\subsection{Task 3}\nThe code as submitted with this report was run several times to generate 2000 random numbers distributed over $k=10$ bins.\\\\\nFor $c = 3, \\: p = 31$, the average score was $\\chi^2 = 0.038$ which seems extremely unlikely when comparing to Knuth's table~\\cite{knuth}.\\\\\nFor $c = 2836, \\: p = 127773$, the average score was $\\chi^2 = 6.778$ which is around the $p=40\\%$ mark on Knuth's table~\\cite{knuth}.\\\\\nClearly and as expected, $c = 3, \\: p = 31$ make for a poor result in terms of randomness, whereas $c = 2836, \\: p = 127773$ already achieve quite a respectable score. \n\n\\section{Discussion}\nThe results were in line with the theoretical expectations from class. I personally had issues getting decent plots as I had shied away from Gnuplot until now. Also, my c++ is somewhat rusty and I apologise for my somewhat ugly code.\n\n\\begin{thebibliography}{99}\n\n\n\\bibitem{knuth}\n  Knuth, Ervin D.,\n  \\emph{The art of computer programming}, \n  Addison Wesley, Massachusetts,\n  3rd edition,\n  1997.\n\n\n\\end{thebibliography}\n\n\n\\end{document}", "meta": {"hexsha": "bf41fd7bdb2b66940ca8f170335b9f56317e271c", "size": 5114, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ex01/ex01_report.tex", "max_stars_repo_name": "BeatHubmann/18H-ICP", "max_stars_repo_head_hexsha": "2ad1bcef73f3f43d832031cf45c4909341176ebd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ex01/ex01_report.tex", "max_issues_repo_name": "BeatHubmann/18H-ICP", "max_issues_repo_head_hexsha": "2ad1bcef73f3f43d832031cf45c4909341176ebd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ex01/ex01_report.tex", "max_forks_repo_name": "BeatHubmann/18H-ICP", "max_forks_repo_head_hexsha": "2ad1bcef73f3f43d832031cf45c4909341176ebd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0381679389, "max_line_length": 523, "alphanum_fraction": 0.7301525225, "num_tokens": 1530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704796847396, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.4493866305339037}}
{"text": "\\documentclass{article}\n\n\\title{Complexity Measures}\n\\author{Vladimir Feinberg}\n\n\\input{../defs}\n\n\\begin{document}\n\n\\maketitle\n\nComplexity measures evaluate the expressiveness of a hypothesis class; they are useful to the extent with which they relate sample and generalization error.\n\n\\section{Setup}\n\nWe suppose that our data comes in the form of ordered pairs from $\\mcX\\times \\mcY$. Samples follow a particular distribution $(x, y)\\sim D$. A hypothesis class $\\mcH$ is set of functions $\\mcX\\rightarrow\\mcY$.\n\nA common approach to supervised learning is ERM, where $m$ iid samples from $D$, $S$, are used to find the $h\\in\\mcH$ minimizing a specified loss $\\ell:\\mcY^2\\rightarrow\\R$ over this set. Complexity measures then let us quantify exactly how much loss we can expect when sampling from $D$ again.\n\nWe seek to quantify the generalization gap with the help of our notions of complexity. For a fixed $h\\in \\mcH$:\n\n$$\n\\varepsilon= \\E\\left[\\ell\\pa{h(x), y)}|(x,y)\\sim D\\right]-\\E\\left[\\ell\\pa{h(x), y)}|(x,y)\\sim \\Uniform(S)\\right]\n$$\n\nAnalysis of Rademacher complexity is agnostic to $h,\\ell$; the hypothesis class might as well consist of functions $g:\\mcX\\times\\mcY\\rightarrow\\R$ yielding their composition. VC dimension analysis, however, requires $\\mcY=\\{0, 1\\}$ and $\\ell(a, b)=\\indicator\\{a=b\\}$. VC dimension is still useful for regression problems, by thresholding hypotheses $h\\mapsto \\indicator{h>\\beta}$ for fixed $\\beta$.\\footnote{\\url{https://stats.stackexchange.com/questions/140430}}\n\n\nThus, it is useful to find bounds on $\\varepsilon$, the difference between the generalization loss $\\E\\left[\\ell\\pa{h(x), y)}\\right]$, where $(x,y)\\sim D$, and sample loss, where the loss is the expectation before taken for $(x,y)$ is uniform over $S$.\n\nLet the gap between the generalization and sample error be $\\varepsilon$.\n\n\\section{Complexity Measures}\n\nThe empirical Rademacher complexity $\\hat{R}_S$ assumes a fixed sample $S$ from $D^m$. It relates complexity of a function class $\\mcG$ containing vectorized functions $g\\in \\mcG$ which take elements $z_i=(x_i, y_i)$ in $S$ and return costs through the correlation of $\\mcG$ with noise. Let $\\vsigma\\sim \\Uniform\\pa{\\pm 1}^m$. Rademacher complexity is then the average empirical one.\n$$\n\\hat{R}_S(\\mcG)=\\E_\\vsigma \\sup_g \\frac{1}{m}\\sum_{i=1}^m{g(z) \\sigma_i},\\;\\;\\; R_m(\\mcG)=\\E_S\\hat{R}_S(\\mcG)\n$$\n\nVC dimension accomplishes a similar task for binary classification by rating the complexity of a hypothesis class $\\mcH$. Let hypotheses $\\mcH\\ni h:\\mcX\\rightarrow \\mcY=\\ca{\\pm 1}$ be applied elementwise over a vector of inputs $\\vx$. First we define the growth function $\\Pi_\\mcH:\\N\\rightarrow\\N$, which defines the maximum number of distinctions a hypothesis class can make over all sets of points in the input space:\n$$\n\\Pi_\\mcH(m)=\\max_{\\vx\\in\\mcX^m}\\card{\\set{h(\\vx)}{h\\in\\mcH}}\n$$\nThen the VC dimension of $\\mcH$ is then $\\max\\set{m\\in\\N}{\\Pi_\\mcH(m)=2^m}$.\n\n\\section{Overview of Results}\n\nProofs can be found in a \\nurl{http://ittc.ku.edu/~beckage/ml800/VC_dim.pdf}{cogent write-up} by Prof. Beckage from the University of Kansas.\n\n\\subsection{VC Generalization Bounds}\n\nUpper bound. If $d$ is the VC-dimension of $\\mcH$, then for any $D$ wp $1-\\delta$:\n$$\n\\varepsilon\\le \\tilde{O}\\pa{\\sqrt{\\frac{d-\\log \\delta}{m}}}\n$$\nThe above inequality is random since it depends on $S$, the $D^m$-valued rv. TODO. find source removing tilde?\n\nAgnostic lower bound. We may find a $D$ such that with a fixed nonzero probability (a non-negligible set of candidate samples $S$), the following holds:\n$$\n\\varepsilon\\ge \\Omega\\pa{\\sqrt{\\frac{d}{m}}}\n$$\n\nThe above implies that in the common case of agnostic hypothesis learning, where we do not know distribution $D$, VC-dimension is, \\textit{up to logarithmic factors, asymptotically efficient} in quantifying the generalization gap.\n\nRealizability. Suppose $D$ is realizable wrt $\\mcH$, so that there exists an $f\\in\\mcH$ such that for almost any $(x,y)$ sampled from $D$, $f(x)=y$. Then all statements above hold but with $\\sqrt{\\varepsilon}$ instead of $\\varepsilon$.\n\n\n\\subsection{Growth Function Bounds}\n\nSauer's Lemma implies that VC dimension $d$ bounds the growth function: in a graph of the logarithm of the growth function vs $m$, growth is linear since $\\Pi_\\mcH(n)=n$ for $n\\le d$. Then for $n>d$, growth is at most logarithmic, i.e., $\\log\\Pi_\\mcH=O(\\log m)$. With Massart's Lemma we have wp $1-\\delta$:\n$$\n\\varepsilon\\le O\\pa{\\sqrt{\\frac{\\log\\Pi_\\mcH(m)-\\log\\delta}{m}}}\n$$\nSince the above would be large if $\\log\\Pi_\\mcH(m)\\simeq m$, it is clear why Sauer's Lemma enables the essential relationship between learnability and complexity.\n\n\\subsection{Rademacher bounds}\n\nWith $R_m$ either the empirical or expected Rademacher complexity over the sample for a given $h,\\ell$ we have again wp $1-\\delta$:\n$$\n\\varepsilon\\le 2R_m+O\\pa{\\frac{\\log\\nicefrac{1}{\\delta}}{m}}\n$$\n$R_m$ may be NP-hard to compute, depending on $\\mcH$. This tells us Rademacher complexity could only be a useful improvement over VC-bounds, asymptotically, if we have an efficient approximation for the empirical Rademacher complexity or some knowledge of $D$ as required to compote the true Rademacher complexity.\n\n\\section{Hardness of Learning}\n\nRademacher and Gaussian Complexities: Risk Bounds and Structural Results by Bartlett and Mendelson.\n\n\\end{document}", "meta": {"hexsha": "d42f25d3402e77fccae8d7affd118658981b2d3d", "size": 5357, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "old/statistical-learning/complexity-measures.tex", "max_stars_repo_name": "vlad17/shallow-ml-notes", "max_stars_repo_head_hexsha": "6535ae666b22847303a2ec72012b31ccb4144900", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2017-06-27T18:39:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-22T18:48:49.000Z", "max_issues_repo_path": "old/statistical-learning/complexity-measures.tex", "max_issues_repo_name": "vlad17/shallow-ml-notes", "max_issues_repo_head_hexsha": "6535ae666b22847303a2ec72012b31ccb4144900", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/statistical-learning/complexity-measures.tex", "max_forks_repo_name": "vlad17/shallow-ml-notes", "max_forks_repo_head_hexsha": "6535ae666b22847303a2ec72012b31ccb4144900", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-03-23T10:45:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-07T06:21:43.000Z", "avg_line_length": 60.875, "max_line_length": 463, "alphanum_fraction": 0.7364196379, "num_tokens": 1549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.554470450236115, "lm_q2_score": 0.8104789040926008, "lm_q1q2_score": 0.44938660285909743}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{amsmath}\n\n\n\\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}\n%\\topmargin=0cm\n\\topmargin=-2cm\n\\addtolength{\\textheight}{6.5cm}\n\\addtolength{\\textwidth}{2.0cm}\n%\\setlength{\\leftmargin}{-5cm}\n\\setlength{\\oddsidemargin}{0.0cm}\n\\setlength{\\evensidemargin}{0.0cm}\n\n%misc libraries goes here\n\n\n\\begin{document}\n\n\\section*{Student Information } \n%Write your full name and id number between the colon and newline\n%Put one empty space character after colon and before newline\nFull Name : ERTUĞRUL AYPEK \\\\\nId Number : 2171270 \\\\\n\n% Write your answers below the section tags\n\\section*{Answer 1}\n\\begin{table}[H]\n\\small\n\\centering\n\\caption{ Membership Table for question 1.a }\n\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\t%% specify column number\n\\hline \t\t\t\t\t\t\t%% line draw\n\\textbf{A} & \\textbf{B} & \\textbf{$\\overline{A}$} & \\textbf{$\\overline{B}$} & \\textbf{A $\\cap$ B} & \\textbf{A $\\cup$ $\\overline{B}$} & \\textbf{$\\overline{A}$ $\\cup$ B} & \\textbf{(A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)} & \\textbf{A $\\cap$ B $\\subseteq$ (A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)}\\\\\n\\hline \n \n1 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \\\\ \\hline \n1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 \\\\ \\hline\n0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 \\\\ \\hline\n0 & 0 & 1 & 1 & 0 & 1 & 1 & 1 & 1 \\\\\n\\hline \n\n\\end{tabular}\n\\end{table}\n\nAs shown in the above table, the statement \"(A $\\cap$ B)$\\subseteq$(A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)\" is true.\n\\\\\n\\\\\n\\\\\n \n\\begin{table}[H]\n\\small\n\\centering\n\\caption{ Membership Table for question 1.b }\n\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\t%% specify column number\n\\hline \t\t\t\t\t\t\t%% line draw\n\\textbf{A} & \\textbf{B} & \\textbf{$\\overline{A}$} & \\textbf{$\\overline{B}$} & \\textbf{$\\overline{A}$ $\\cap$ $\\overline{B}$} & \\textbf{A $\\cup$ $\\overline{B}$} & \\textbf{$\\overline{A}$ $\\cup$ B} & \\textbf{(A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)} & \\textbf{$\\overline{A}$ $\\cap$ $\\overline{B}$ $\\subseteq$(A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)}\\\\\n\\hline \n \n1 & 1 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\\\ \\hline \n1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 \\\\ \\hline\n0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 \\\\ \\hline\n0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\\\\n\\hline \n\n\\end{tabular}\n\\end{table}\n\nAs shown in the fifth and eighth columns of above membership table for question 1.b, the statement \"($\\overline{A}$ $\\cap$ $\\overline{B}$)$\\subseteq$(A $\\cup$ $\\overline{B}$) $\\cap$ ($\\overline{A}$ $\\cup$ B)\" is true.\n\n\n\\section*{Answer 2}\nIn order to prove this equation we need to show each side is a subset of the other. \\\\\nProving right side is a subset of the left side:\n\nSince f has an inverse on the domains of $\\textit{A}$x$\\textit{C}$ and $\\textit{B}$x$\\textit{C}$, f is one-to-one and onto on these domains. Which means there must be a unique image for each element of $\\textit{f}$ and likewise $\\textit{f}^{-1}$. This allows us to do followings:  \n\\\\\n\\\\\n$\\textit{f}^{-1}$( ( A $\\cap$ B ) x C) $\\supseteq$ $\\textit{f}^{-1}$ (A x C) $\\cap$ $\\textit{f}^{-1}$ (B x C) \\\\\n$\\textit{f}^{-1}$( ( A $\\cap$ B ) x C) $\\supseteq$ $\\textit{f}^{-1}$ ( ( A x C) $\\cap$ ( B x C ) ) ...(because f has inverse, explained at 2. paragraph) \\\\\n$\\textit{f}^{-1}$( ( A $\\cap$ B ) x C) $\\supseteq$ $\\textit{f}^{-1}$ ( ( A $\\cap$ B ) x C ) ...(by Distributive laws)\n\\\\\n\\\\\n\\\\\n\\\\\n\\\\\nDoing the same to prove left side is a subset of the right side: \\\\\n$\\textit{f}^{-1}$( ( A $\\cap$ B ) x C) $\\subseteq$ $\\textit{f}^{-1}$ (A x C) $\\cap$ $\\textit{f}^{-1}$ (B x C) \\\\\n$\\textit{f}^{-1}$ ( ( A x C) $\\cap$ ( B x C ) ) $\\subseteq$ $\\textit{f}^{-1}$ (A x C) $\\cap$ $\\textit{f}^{-1}$ (B x C) ...(by Distributive laws)\\\\\n$\\textit{f}^{-1}$ (A x C) $\\cap$ $\\textit{f}^{-1}$ (B x C) $\\subseteq$ $\\textit{f}^{-1}$ (A x C) $\\cap$ $\\textit{f}^{-1}$ (B x C)  ...(because f has inverse, explained at 2. paragraph) \\\\\n\\\\\n\\\\\nSo, the equation is true.\n\n\n\n\\section*{Answer 3}\n\n$\\textbf{a.}$\n\\\\\n$\\textit{f(x)}$ = $\\textit{$ln( x^{2} + 5)$}$ is not one-to-one since for x=5 $\\in\\Re$ and for x=-5 $\\in\\Re$ there is the same image $\\textit{ln(30)}$\n\\\\\n\n$\\textit{f(x)}$ = $\\textit{ln( $x^{2}$ + 5)}$ is not onto since there is no element in domain so that $\\textit{$ln( x^{2} + 5)$}$=0 $\\Rightarrow$ ($x^{2}$=-4).\n\\\\ \\\\ \\\\ \\\\\n$\\textbf{b.}$ \n\\\\\n$\\textit{f(x)}$ = $e^{e^{x^{7}}}$ is one-to-one since for an arbitrary a $\\in\\Re$, there is a unique image under f which is $e^{e^{a^{7}}}$ $\\in\\Re$ \\\\\n\n\n$\\textit{f(x)}$ = $e^{e^{x^{7}}}$ is not onto since for $e^{e^{x^{7}}}$ = 0 $\\Rightarrow$ $x^{7}$ = log0, there is no element x $\\in\\Re$. \\\\\n\n\n\\section*{Answer 4}\n$\\textbf{Answer for 4.a}$ \\\\\nThere are three cases to consider: \\\\\n(i)A and B are both finite, \\\\\n(ii)A is infinite and B is finite,\\\\\n(iii) A and B are both countably infinite.\\\\\n\\\\\ncase(i): When A and B are both finite, AxB is also finite and therefore, countable. \\\\\ncsae(ii): Because A is countably infinite, its \telements can be listed in an infinite sequence $a_{1}$, $a_{2}$, ... ,$a_{n}$, ... and because B is finite, its terms can be listed as \t$b_{1}$,$b_{2}$, ... ,$b_{m}$ for some positive integer m. We can list the elements of AxB as ($a_{1}$,$b_{1}$),($a_{1}$,$b_{2}$), ... ,($a_{1}$,$b_{m}$), ... ,($a_{n}$,$b_{1}$),($a_{n}$,$b_{2}$), ..., ($a_{n}$,$b_{m}$), ... \\\\\ncase(iii): Because A and B are both countably infinite, its elements can be listed in an infinite sequence. Their elements can be listed as $a_{1}$, $a_{2}$, ... ,$a_{n}$, ... and $b_{1}$, $b_{2}$, ... ,$b_{n}$, ... respectively. And we can list the elements of AxB by alternating and putting into tuples as ($a_{1}$,$b_{1}$), ($a_{1}$,$b_{2}$),($a_{2}$,$b_{1}$), ($a_{2}$,$b_{2}$), ($a_{1}$,$b_{3}$), ($a_{3}$,$b_{1}$), ($a_{2}$,$b_{3}$), ($a_{3}$,$b_{2}$), ($a_{3}$,$b_{3}$), ... \\\\\n\\\\\n\\\\\n$\\textbf{Answer for 4.b}$ \\\\\nIf A is uncountable and A$\\subseteq$B, then B is uncountable. Suppose A represents all real numbers between (0,1). A is an uncountable set as proved in the textbook p.173-174. And suppose B represents all real numbers between (0,2). B has two parts: (0,1) and (1,2). As we said that the set of all real numbers between (0,1) is uncountable, B has this uncountable part too. So we say that a set with an uncountable subset is uncountable. So, if A is uncountable and A$\\subseteq$B, then B is uncountable.\n\\\\\n\\\\\n\\\\\n$\\textbf{Answer for 4.c}$ \\\\\nIf B is countable and A$\\subseteq$B, then A is countable. Suppose B represents the positive integers such that there is a one-to-one correspondence function f(x)=x from $Z^{+}$ to B. And suppose A represents the positive even integers such that f(k)=t where t=2k k$\\in$ $Z^{+}$. B can be listed as $b_{1}$=1, $b_{2}$=2, $b_{3}$=3, ... , $b_n$=n, ... and A can be listed as $a_{1}$=2, $a_{2}$=4, $a_{3}$=6, ... , $a_n$=2n, ... So we say that any countable subset of a countable set is countable. So, if B is countable and A$\\subseteq$B, then A is countable.\n\n\n\\section*{Answer 5}\n\\textbf{Answer for 5.a} \\\\\nTo prove that we need to find a pair of witnesses C and k.\n\\textbf{Answer for 5.b} \\\\\nTo prove that we need to find a pair of witnesses C and k.\n\\section*{Answer 6}\n\\textbf{Answer for 6.a} \\\\\n($3^{x}$-1)\\textit{mod}($3^{y}$-1)=$3^{\\textit{x mody}}$-1 \\\\\nUsing Theorem 4 in p.241 in textbook to write the left side differently; \\\\\n($3^{x}$-1)\\textit{mod}($3^{y}$-1) = $3^{x}$-1 + $k_{1}$*($3^{y}$-1)\\\\\nUsing Theorem 4 in p.241 in textbook to write the right side differently; \\\\\n$3^{\\textit{x mody}}$-1=$3^{x+k_{2}y}$-1\\\\\n\\\\\n$3^{x}$-1 + $k_{1}$*($3^{y}$-1) = $3^{x+k_{2}y}$-1 \\\\\nThe equation holds when $k_{1}$=0 and $k_{2}$=0. \n\n\n\n\n\n\\textbf{Answer for 6.b} \\\\\n277= 123*2 + 31 \\\\\n123= 31*3 + 30 \\\\\n31= 30*1 + 1 \\\\\n30=1*30 + 0 \\\\\ngcd(277,123)=gcd(123,31)=gcd(31,30)=1 \\\\\n\n\n\n\n\\end{document}\n\n​\n\n", "meta": {"hexsha": "abe14a1928afea478d85c885cfe3ac5adb8f46e6", "size": 7770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CENG223-Discrete Computational Structures/HW2/the2.tex", "max_stars_repo_name": "ertugrulaypekk/METU-Computer-Engineering-Courses", "max_stars_repo_head_hexsha": "e5d06effa63cfa921dcec46cca39fadd501b8013", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-05T11:41:02.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-05T11:41:02.000Z", "max_issues_repo_path": "CENG223-Discrete Computational Structures/HW2/the2.tex", "max_issues_repo_name": "ertugrulaypek/METU-Computer-Engineering", "max_issues_repo_head_hexsha": "ce696b4c4ea78f2fd2e06220eeca622abbc82ce7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CENG223-Discrete Computational Structures/HW2/the2.tex", "max_forks_repo_name": "ertugrulaypek/METU-Computer-Engineering", "max_forks_repo_head_hexsha": "ce696b4c4ea78f2fd2e06220eeca622abbc82ce7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.1744186047, "max_line_length": 556, "alphanum_fraction": 0.590990991, "num_tokens": 3066, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.8397339676722393, "lm_q1q2_score": 0.44934032656580514}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Tuesday\\\\ 2020-9-29, \\\\ compiled \\\\ \\today}\n\nThe procedure for hypothesis testing will look like \n%\n\\begin{align}\n\\mathbb{P}(\\text{hypothesis} | \\text{data})\n= \\frac{\\mathbb{P}(\\text{data} | \\text{hypothesis}) \\mathbb{P}(\\text{hypothesis}) }{\\mathbb{P}(\\text{data})}\n\\,.\n\\end{align}\n\nThe key difference from the frequentist approach is that, while there the parameters have certain fixed values, here we can describe our \\emph{belief} about their values through a probability distribution. \n\nThe things we will want to do can be classified into \n\\begin{enumerate}\n    \\item \\textbf{hypothesis testing}, ``are CMB data consistent with gaussianity?'';\n    \\item \\textbf{parameter estimation}, ``what is the value of the mass of the Sun?'';\n    \\item \\textbf{model selection}, ``is GR the correct theory of gravity?''.\n\\end{enumerate}\n\n\\subsection{Parameter estimation}\n\nWe start with an example: the toss of a coin. \nThe question is: we toss it \\(N\\) times and get \\(R\\) heads. Is it a fair coin?\n\nIf \\(H \\in [0,1]\\) is the probability of getting heads in a single coin flip, then \n%\n\\begin{align}\n\\mathbb{P}(R \\text{ heads} | H, I) \\propto H^{R} (1 - H)^{N-R} \n\\,.\n\\end{align}\n\nHere, \\(I\\) is the other information we have about the coin: the fact that every throw is independent, the fact that there are no outcomes beyond heads or tails. \n\nThis is the \\textbf{likelihood}, what we want to do is to invert the relation, finding a probability density function for \\(H\\) given the data. The probability \\(\\mathbb{P}(\\text{data})\\), also called the \\textbf{evidence}, is not something we need to calculate when doing parameter estimation: we can just write \n%\n\\begin{align}\n\\mathbb{P}(\\text{parameters} | \\text{data}) \\propto \\mathbb{P}(\\text{data} | \\text{parameters}) \\mathbb{P}(\\text{parameters})\n\\,,\n\\end{align}\n%\nsince we are computing probability density functions, which need to be normalized in order to make sense. \nThis is a useful parameter estimation toy problem, since we only have one parameter to estimate. \n\nIn order to use the formula we need a prior, \\(\\mathbb{P}(\\text{hypothesis})\\). This is hard in general, and it depends on the problem. \nWe might want a prior which is peaked around \\num{.5} for a regular coin, if we have no reason to think that it is unfair. \nLet us suppose we have doubts about the honesty of who gave us the coin: then, we might want a noninformative prior, like a flat one. \nLet us suppose we are in this case: \\(\\mathbb{P}(\\text{parameters}) = \\const\\).\n\nSince the prior is flat, the posterior is proportional to the likelihood: \n%\n\\begin{align}\n\\mathbb{P}(H | R \\text{ heads}, I) \\propto \n\\mathbb{P}(R \\text{ heads} | H, I)\n\\propto H^{R} (1 - H)^{N-R}  \n\\,.\n\\end{align}\n\nWe can simulate this experiment! We need a binomial random number generator.\n\n\\todo[inline]{Do the simulation!}\n\nAs \\(N\\) increases, the posterior ``zeroes in'' onto the correct value.\nIf we split the \\(N\\) simulated throws in two, and use the posterior from the first batch as a prior for the second, we get the same result!\n\n% \\todo[inline]{What would be the procedure if we wanted to test the hypothesis ``the coin is fair''?}\n\n\\end{document}\n", "meta": {"hexsha": "28b8922585de7fb30671bef9d2f78c4b7b95c18c", "size": 3225, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/astrostatistics_cosmology/sep29.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/astrostatistics_cosmology/sep29.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/astrostatistics_cosmology/sep29.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 45.4225352113, "max_line_length": 313, "alphanum_fraction": 0.7184496124, "num_tokens": 906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.44925580732671067}}
{"text": "% Created 2021-12-12 Sun 15:49\n% Intended LaTeX compiler: pdflatex\n\\documentclass[11pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\author{Calvin Roth}\n\\date{\\today}\n\\title{}\n\\hypersetup{\n pdfauthor={Calvin Roth},\n pdftitle={},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 27.2 (Org mode 9.5)},\n pdflang={English}}\n\\begin{document}\n\n\\newcommand{\\pr}{$\\mathbb{Pr}$}\n\n\\newcommand{\\ppr}{\\mathbb{P}\\mathbb{r}}\n\n\\section{Setup}\nFix G, a directed erdos-renyi graph, let $Dom_{G}$ be the set of graphs that have the same degree sequence as G. Typically, we will use H to be a member of this set. Additionally, let $p(H)$ be profit vector of H. Throughtout this analysis all parameters are fixed.\n\\pr\n\\textbf{Primary Questions}\n\\begin{enumerate}\n  \\item What is $\\| H + H^{T}\\|$(What norm is the right norm is a good question) \\\\\n  \\item Let q(H) be an altered price vector, where we fix the norms terms. What is the distribution of q(H) \\\\\n  \\item What is probability distribution of these price vectors in the doman H. \\\\\n\\end{enumerate}\n\nWe want to resolve the question of what is $Pr[v(H)_{i} = k]$\n\\begin{align*}\n  \\ppr [v(H)_{i} = ] &= \\ppr [ \\frac{a-c}{2} + \\frac{a-c}{2} \\frac{\\rho}{\\|H+H^{T}} K(H+H^{T}, \\frac{\\rho}{\\|H+H^{T}\\|}) = k ]\\\\\n  &= \\ppr [\\frac{1}{\\|H+H^{T}\\|} K(H^{T}+H, \\frac{\\rho}{\\|H+H^{T}}) = \\underbrace{( \\frac{2}{\\rho(a-c)} [k - \\frac{a-c}{2}] )}_{k'}]\n\\end{align*}\n\n\\subsection{Number of kth neighbors}\nWe will define two generating functions.\n\nThe first will be $g_{0}(z) = \\sum_{k=0} p_{k} z^{k}$ where $p_{k}$ is the probabality of a given node having degree k. We know that $p_{k} \\approx \\frac{e^{-\\lambda} \\lambda^{k}}{k!}$ where $\\lambda = (n-1)p$. Therefore $g_{0}(z) = \\sum_{k=0} \\frac{e^{-\\lambda}\\lambda^{k}}{k!} z^{k} = e^{-\\lambda} e^{z\\lambda}$.\n\nThe next generating function will be of the distribution of the degree size of a neighboring vertices.  We analyzed this in networks class. We will call if $g_{1} = (z)$ and the probability distribution of this neighbor $p_{k}^{(2)}$. We have\n\\begin{align*}\n  g_{1}(z) &= \\sum_{k=0} p_{k}^{(k)} z^{k} \\\\\n       &= \\sum_{k=0} \\frac{k p_{k}}{E[d]} z^{k} \\\\\n       &= \\frac{1}{E[d]} \\sum_{k=0} k p_{k} z^{k} \\\\\n       &= \\frac{1}{E[d]}  z D_{z} \\sum_{k=0} p_{k} z^{k}\\\\\n       &= \\frac{1}{E[d]} z D_{z} (e^{-\\lambda} e^{z\\lambda}) \\\\\n       &= \\frac{z e^{-\\lambda} \\lambda e^{z\\lambda}}{E[d]}\n\\end{align*}\n\nTo see why these are helpful, we will now derive the size of 2 distance neighbors from a node which we will call $d_{2}$.\n\n\\begin{align*}\n  g_{2}(k) &= \\sum p^{(2)}_{m} * z^{m} \\underbrace{P_{2}(k|m)}_{\\text{Distribution of 2 neighbors given starting node had degree m}} \\\\\n           &= \\sum_{m} p^{(2)}_{m} \\left( \\sum_{x_{1} + x_{2} + \\cdots + x_{m} =k } \\prod_{j} Pr[q_{x_{j}}]  \\right) \\\\\n           &= \\sum_{m} p^{(2)}_{m} {(\\sum q_{i} z^{i})}^{m} \\\\\n           &= \\sum_{m} p^{(2)}_{m} (d_{1}(z))^{m} \\\\\n  &= g_{0}(g_{1}(z))\n\\end{align*}\n\nTo make this transition clear, consider what $(\\sum_{i=0}^{\\infty} q_{i} z^{i})(\\sum_{i=0}^{\\infty} q_{i} z^{i})$ organized by terms of z. The term of $z^{k}$ will have coefficient $(q_{0}q_{k} + q_{1}q_{k-1}+\\cdots + q_{k-1}q_{1} + q_{k}q_{0} ) = \\sum_{i+j=k} q_{i}q_{j}$.\n\nFor us this is interesting because $g_{0}(z)$ is completely fixed by the true graph G(or said alternatively is exactly the same for all the H graphs with the same degree sequence) but $g_{1}$ was not fixed directly by H. $d_{1}$ is a random function dependent on the graph it is based on. I'm not sure how this $g_{1}$ correlates with the first degree information which we fixed. Importantly, is the $g_{1}$ functions the same for our graphs vs all erdos-renyi graphs with the same n and p or does this also depend indirectly on the information we fixed. Ideally it is the first case and if so we would have shown that walk sizes are a function of the true graph's information applied to a random variable which if things are nice only depends on n and p.\n\nWe can continue this for higher distance walks. Now we will use $P_{3}(k|m)$ to be the probability that a node has k 3 distance given it has m 2-distance neighbors.  The three step generating function, $g_{3}(z)$, can be expressed as\n\\begin{align*}\n  g_{3}(z) &= \\sum_{k} \\sum_{m} p^{2}_{m}  P_{3} (k|m) z^{k} \\\\\n           &= \\sum_{m} p^{2}_{m} \\sum_{x_{1} + x_{2}+\\cdots x_{m}=k} z^{k} \\prod_{j}^{m} Pr[q_{x_{j}}] \\\\\n           &= \\sum_{m} p^{2}_{m} g_{1} (z)^{m} \\\\\n  &= g_{2} ( g_{1} ( z)) = g_{0} ( g_{1} ( g_{1} ( z)))\n\\end{align*}\n\nIn general, the generating function representing the walks of length $\\ell$ is $g_{0} ( g_{1}^{\\ell-1} ( z))$\n\n\nThese have been very helpful and contains much of this analysis.\nhttps://people.cs.clemson.edu/~isafro/ns14/l15.pdf\nhttps://static.squarespace.com/static/5436e695e4b07f1e91b30155/t/5445263ee4b0d3d410795e1f/1413817918272/random-graphs-with-arbitrary-degree-distributions-and-their-applications.pdf\n\n\\section{Norms}\nCurrently unsure how I can bound the norms more tightly than what was done in the price discrimination paper.\n\\end{document}\n", "meta": {"hexsha": "f5a2c7f200ebed1d4504fd1b5bace5841f1eae6d", "size": 5322, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/pricedis.tex", "max_stars_repo_name": "CalvinRoth/PriceDiscriminationNewtorks", "max_stars_repo_head_hexsha": "747688f958dc6876acd881139fb02666d93b5a4c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/pricedis.tex", "max_issues_repo_name": "CalvinRoth/PriceDiscriminationNewtorks", "max_issues_repo_head_hexsha": "747688f958dc6876acd881139fb02666d93b5a4c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/pricedis.tex", "max_forks_repo_name": "CalvinRoth/PriceDiscriminationNewtorks", "max_forks_repo_head_hexsha": "747688f958dc6876acd881139fb02666d93b5a4c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.4375, "max_line_length": 755, "alphanum_fraction": 0.6503194288, "num_tokens": 1872, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4492557958877292}}
{"text": "\\documentclass{beamer}\n\\usetheme{Warsaw}\n\\usepackage{nhtvslides}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\lstset{language=CAML,\nbasicstyle=\\ttfamily\\footnotesize,\nframe=shadowbox,\nbreaklines=true}\n\\usepackage[utf8]{inputenc}\n\n\\title{Building a physics engine - part 4: broad phase of collision detection}\n\n\\author{Dr. Giuseppe Maggiore}\n\n\\institute{NHTV University of Applied Sciences \\\\ \nBreda, Netherlands}\n\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\begin{frame}{Table of contents}\n\\tableofcontents\n\\end{frame}\n\n\\section{Broad phase of collision detection}\n\\begin{slide}{Broad phase of collision detection}{Increasing performance, in general}{\n\\item What is the fastest instruction?\n\\pause\n\\item The one that is not run!\n}\\end{slide}\n\n\\begin{slide}{Broad phase of collision detection}{Increasing performance, in collision detection}{\n\\item How do we increase performance in a collision detection system?\n\\item Quickly and cheaply exclude pairs of colliders\n\\item Process known as \\textit{collision culling}\n\\begin{itemize}\n\\item We \\textit{ensure lack} of collisions\n\\item \\textit{Presence is ensured} only during narrow phase\n\\end{itemize}\n\\item Akin to frustum/occlusion culling\n}\\end{slide}\n\n\\section{Bounding spheres}\n\\begin{slide}{Collision culling}{Bounding spheres}{\n\\item An obvious choice is bounding spheres\n\\item Identical w.r.t. rotation\n\\item Fast to check against other spheres\n}\\end{slide}\n\n\\begin{slide}{Collision culling}{Intersection of bounding spheres}{\n\\item Two spheres, $\\langle C_0, r_0 \\rangle$ and $\\langle C_1, r_1 \\rangle$\n\\item Intersection when $|C_1 - C_0| \\leq r_1 + r_0$\n\\item Intersection also when $|C_1 - C_0|^2 \\leq (r_1 + r_0)^2$\n}\\end{slide}\n\n\\begin{slide}{Collision culling}{Intersection of bounding spheres}{\n\\item If the spheres are moving, then we can increase their radii by their speed\n\\item Or we can project their relative speed\n\\pause\n\\item $\\sigma = |(V_1 - V_2) \\cdot \\frac{C_1 - C_0}{|C_1 - C_0|}|$\n\\item $|C_1 - C_0| \\leq r_1 + r_0 + \\sigma$\n}\\end{slide}\n\n\\begin{frame}{Moving spheres}\n\\center\n\\includegraphics[height=5cm]{Pics/MovingSpheres.png}\n\\end{frame}\n\n\\section{Space partitioning}\n\\begin{slide}{Space partitioning}{Space partitioning}{\n\\item We can also decompose space in axis-aligned-bounding-boxes (``bins'')\n\\item Even earlier no-collision determination\n\\item This would reduce the number of sphere-to-sphere checks\n}\\end{slide}\n\n\\begin{frame}{SLIDE}\n\\center\n\\includegraphics[height=5cm]{Pics/SpacePartitioning.png}\n\\end{frame}\n\n\\begin{slide}{Space partitioning}{Space partitioning}{\n\\item We can divide space in \\textit{bins}; each bin is an AABB\n\\item Sphere intersection with an AABB bounded by points $L$ and $U$ \n\\item No intersection if $|C_j - L_j| \\leq r_j + \\sigma_j$ or $C_j - U_j| \\leq r_j + \\sigma_j$ for all axes $j = x,y,z$\n}\\end{slide}\n\n\\begin{slide}{Space partitioning}{Space partitioning}{\n\\item When a sphere moves, it only moves to a neighbouring bin; less checks\n\\item We can find the right bin directly with modulus operations (hashing)\n}\\end{slide}\n\n\\section{Bounding boxes}\n\\begin{slide}{Axis aligned bounding boxes}{AABB intersection}{\n\\item A simple and powerful algorithm exists for determining intersection groups of AABBs\n\\item It is particularly fast, especially if the AABBs do not move too much between frames\n}\\end{slide}\n\n\\begin{slide}{Axis aligned bounding boxes}{AABB intersection}{\n\\item Update AABBs (if needed)\n\\item Insertion sort the extremes of each box; one list for every axis (2 for 2D, 3 for 3D, etc.)\n\\begin{itemize}\n\\item After the first frame the list is \\textit{nearly sorted}\n\\item $O(n)$ complexity\n\\end{itemize}\n}\\end{slide}\n\n\\begin{slide}{Axis aligned bounding boxes}{AABB intersection}{\n\\item Run sweep algorithm\n\\begin{itemize}\n\\item Active intervals $= \\emptyset$\n\\item When a beginning value is encountered, add it as intersecting all active intervals; add it to active intervals\n\\item When end value is encountered, remove it from the active intervals\n\\end{itemize}\n\\item Intersections must be confirmed across all axes\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB}{\n\\item An OBB is characterized by a center and three directions (columns of the rotation matrix)\n\\item The vertices are $P = C + \\sigma_0 e_0 U_0 + \\sigma_1 e_1 U_1 + \\sigma_2 e_2 U_2$\n\\begin{itemize}\n\\item $\\sigma_i = 1$ or $\\sigma_i = -1$\n\\item $e_i$ are the half extents\n\\end{itemize}\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item With the separating axis test, it may seem that we need to test $6$ face normals for one, $6$ for the other, and $12^2 = 144$ edge pair cross products\n\\item That's quite a lot!\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item The OBB is symmetric, so many tests are redundant\n\\begin{itemize}\n\\item Three unique face directions\n\\item Three unique edge directions\n\\end{itemize}\n\\item The minimum number of required tests is $3$ face normals for one, $3$ for the other, and $3^2 = 9$ edge pair cross products\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item We project both OBBs onto one of the unique potential separating directions $Q + tD$\n\\item We look for an extremal vertex such that $\\max_P D \\cdot (P - Q)$\n\\item $D \\cdot (P - Q) = D \\cdot (C + \\sigma_0 e_0 U_0 + \\sigma_1 e_1 U_1 + \\sigma_2 e_2 U_2 - Q)$\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item We are maximizing, so we do not try all the $\\sigma_i$ combinations\n\\begin{eqnarray}\nD \\cdot (P - Q) &=& D \\cdot (C + \\sigma_0 e_0 U_0 + \\dots  - Q) \\\\\n&=& D \\cdot (C - Q) + \\sigma_0 e_0 D \\cdot U_0 + \\dots \\\\\n&=& D \\cdot (C - Q) + \\sum_{i=0}^2 |e_i D \\cdot U_i|\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item Maximization results in $\\max_P D \\cdot (P - Q) = \\underbrace{D \\cdot (C - Q)}_{\\gamma} + \\underbrace{\\sum_{i=0}^2 |e_i D \\cdot U_i|}_{r}$\n\\item Minimization results in $\\min_P D \\cdot (P - Q) = D \\cdot (C - Q) - \\sum_{i=0}^2 |e_i D \\cdot U_i|$\n\\item The interval is thus $[\\gamma - r, \\gamma + r]$\n\\item \\textbf{Important:} the separating directions \\textit{must be unit length}, and the edges as well\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT}{\n\\item We project both OBBs onto their intervals $[\\gamma_1 - r_1, \\gamma_1 + r_1]$ and $[\\gamma_2 - r_2, \\gamma_2 + r_2]$\n\\item They intersect when $|\\gamma_2 - \\gamma_1| < r_1 + r_2$\n}\\end{slide}\n\n\\begin{slide}{Oriented bounding boxes}{OBB SAT - final optimization}{\n\\item Some separating directions are taken from the cross product of two edge directions: $D = U_i^1 \\times U_k^2$\n\\item When we plug those directions $D$ in the above formulas, we get $U_i^1 \\times U_k^2 \\cdot U_j^1$\n\\item We can rewrite $U_i^1 \\times U_k^2 \\cdot U_j^1 = U_i^1 \\times U_j^1 \\cdot U_k^2$\n\\item We can cache the products $U_i^1 \\times U_j^1$, so we do not have to recompute them\n}\\end{slide}\n\n\\begin{slide}{Moving objects}{Moving objects}{\n\\item We ignore the angular velocity; does not improve much, and is very complex to handle\n\\item We can enlarge the interval radii by projecting the current relative velocity onto the separating direction\n\\item $s = D \\cdot (V_2 - V_1)$\n}\\end{slide}\n\n\\section{Further optimizations}\n\\begin{slide}{Further optimizations}{Islands}{\n\\item Apply collision response system only to groups of objects in contact\n\\item Flood-fill algorithm\n}\\end{slide}\n\n\\begin{slide}{Further optimizations}{Sparse matrices for collision response}{\n\\item Avoid multiplying lots of zeroes\n\\item Store matrix row as list of \\texttt{int * float} entries\n}\\end{slide}\n\n\\section{Assignment}\n\\begin{slide}{Assignment}{Assignment}{\n\\item Before the end of next week\n\\item Group-work archive/video on Natschool or uploaded somewhere else and linked in your report\n\\item Individual report by each of you on Natschool\n\\item Build a broad phase collision detector that supports a combination of bounding spheres, AABBs, bins, and OBBs\n}\\end{slide}\n\n\\begin{frame}{That's it}\n\\center\n\\fontsize{18pt}{7.2}\\selectfont\nThank you!\n\\end{frame}\n\n\\end{document}\n\n\n\\begin{slide}{SECTION}{SLIDE}{\n\\item i\n}\\end{slide}\n\n\\begin{frame}[fragile]{SLIDE}\n\\begin{lstlisting}\nCODE\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{SLIDE}\n\\center\n%\\includegraphics[height=5cm]{Pics/recursive_multiplier.png}\n\\end{frame}\n", "meta": {"hexsha": "6b719507a8772a9a0d696a6259b742485716a4c3", "size": 8275, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/Lecture 7/Lecture 7.tex", "max_stars_repo_name": "hogeschool/TINWIS01-7", "max_stars_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2015-10-02T23:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T04:08:27.000Z", "max_issues_repo_path": "Slides/Lecture 7/Lecture 7.tex", "max_issues_repo_name": "hogeschool/TINWIS01-7", "max_issues_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-08-16T10:05:36.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-16T10:05:47.000Z", "max_forks_repo_path": "Slides/Lecture 7/Lecture 7.tex", "max_forks_repo_name": "hogeschool/TINWIS01-7", "max_forks_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-25T02:31:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-04T07:48:25.000Z", "avg_line_length": 36.7777777778, "max_line_length": 156, "alphanum_fraction": 0.740060423, "num_tokens": 2483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4492246875101921}}
{"text": "\\documentclass[a4paper,english,notitlepage,longbibliography,showpacs,preprintnumbers,amsmath,amssymb,aps,prx,nofootinbib,12pt,superscriptaddress]{revtex4-1}\n\\usepackage{geometry}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{comment}\n\\usepackage{hyperref}\n\\hypersetup{\n bookmarks=true,                % show bookmarks bar?\n unicode=false,                 % non-Latin characters in Acrobat’s bookmarks\n pdftoolbar=true,               % show Acrobat’s toolbar?\n pdfmenubar=true,               % show Acrobat’s menu?\n pdffitwindow=false,            % window fit to page when opened\n pdfstartview={FitH},           % fits the width of the page to the window\n pdftitle={SFR derivations},    % title\n pdfauthor={Szil{\\'a}rd Szalay},        % author\n pdfsubject={},       % subject of the document\n pdfcreator={pdflatex},         % creator of the document\n pdfproducer={vim},             % producer of the document\n pdfkeywords={SFR} {BCR}, % list of keywords\n pdfnewwindow=true,             % links in new window\n colorlinks=true,               % false: boxed links; true: colored links\n linktoc=page,                  % defines which part of an entry in the table of contents is made into a link\n%%%%%%%%% colored links\n linkcolor=blue,                % color of internal links       (red)\n citecolor=blue,                % color of links to bibliography\n filecolor=magenta,             % color of file links\n urlcolor=blue                  % color of external links\n}\n%%%%%%%%%%%%%%%%%%%%%%%%\n\\usepackage[usenames,dvipsnames]{xcolor}\n\\usepackage[inline]{showlabels}\n\\renewcommand{\\showlabelfont}{\\footnotesize\\ttfamily\\color{OliveGreen}}\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\newcommand{\\ceil}[1]{\\lceil #1 \\rceil}\n\n\n\\begin{document}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{SFR-BCR}\n\n\\noindent Binary variables: $x_1,x_2,\\dots,x_n\\in\\{0,1\\}$,\nand let $X:=\\sum_{i=1}^n x_i$, $2\\leq k\\in\\mathbb{N}$, $l = \\ceil{\\log k}$\n\n\\subsection{SFR-BCR-1,2}\n\\noindent We have the $l+1$ auxiliary variables $y_0,y_1,\\dots,y_{l-1},z\\in\\{0,1\\}$.\n(In the formulas, summations for $i,i' = 1,2,\\dots,n$ and $j,j' = 0,1,\\dots,l-1$ are understood.)\\\\\n\n\\noindent We have the function (See Observation 1. from \\cite{Boros2018QuadratizationsOS}) %% Would a proper citation be needed\n\\begin{equation}\n\\label{eq:Ak}\nA_k(X,y,z) = X - (k-2^l)z - (k+1)(1-z) - \\sum_{j}2^jy_j.\n\\end{equation}\nAfter substituting for X, and collecting the terms, the equation for SFR-BCR-1 becomes\n\\begin{equation}\n\\label{eq:Ak1}\nA_k(X,y,z) = -(1+k) +\\sum_i x_i - \\sum_{j}2^jy_j + (1+2^l)z.\n\\end{equation}\nSimilarly for SFR-BCR-2 we have\n\\begin{equation}\n\\label{eq:Ak2}\nA_{n-k}({n-X},y,z) = -(1-k) +\\sum_i x_i - \\sum_{j}2^jy_j + (1+2^l)z.\n\\end{equation}\nFor the  two cases\n(top/bottom = SFR-BCR-1/SFR-BCR-2),\nby recognizing their similarities we can simplify the equation to\n\\begin{equation}\n\\label{eq:Ak12}\n\\left.\\begin{aligned}\n&A_k(X,y,z) \\\\\n&A_{n-k}({n-X},y,z)\n\\end{aligned}\\right\\}\n= -(1\\pm k) \\pm \\sum_i x_i - \\sum_j 2^jy_j + (1+2^l)z.\n\\end{equation}\nThen the squares are\n\\begin{equation}\n\\label{eq:Ak12sq}\n\\begin{split}\n\\left.\\begin{aligned}\n&A_k(X,y,z)^2 \\\\\n&A_{n-k}({n-X},y,z)^2\n\\end{aligned}\\right\\}\n= (1\\pm k)^2 \\mp2(1\\pm k)\\sum_i x_i +2(1\\pm k)\\sum_j 2^jy_j -2(1\\pm k)(1+2^l)z & \\\\\n+ \\sum_i\\sum_{i'} x_ix_{i'} \\mp2\\sum_i\\sum_j 2^jx_iy_j \\pm2 (1+2^l)\\sum_i zx_i & \\\\\n+ \\sum_j\\sum_{j'} 2^{j+j'}y_jy_{j'} - 2(1+2^l)\\sum_j z 2^jy_j & \\\\\n+ (1+2^l)^2z^2. &\n\\end{split}\n\\end{equation}\nBecause $z\\in\\{0,1\\}$, we have $z^2=z$, so we can join the two terms,\n\\begin{equation}\n-2(1\\pm k)(1+2^l)z + (1+2^l)^2z^2 = (1+2^l)(2^l\\mp2k-1)z,\n\\end{equation}\nso we end up with\n\\begin{equation}\n\\label{eq:alpha12}\n\\begin{split}\n&\\left.\\begin{aligned}\n&A_k(X,y,z)^2 \\\\\n&A_{n-k}({n-X},y,z)^2\n\\end{aligned}\\right\\} = \\\\\n&\\underbrace{(1\\pm k)^2}_{\\alpha}\n+ \\underbrace{\\mp 2(1\\pm k)}_{\\alpha^{b}} \\sum_i x_i\n+ \\sum_j \\underbrace{(1\\pm k)2^{j+1}}_{\\alpha^{b_{a,1}}}y_j\n+ \\underbrace{(1+2^l)(2^l\\mp2k-1)}_{\\alpha^{b_{a,2}}}z \\\\\n&+ \\underbrace{1}_{\\alpha^{bb}} \\sum_{i,i'} x_ix_{i'}\n+ \\sum_{i,j} \\underbrace{\\mp2^{j+1}}_{\\alpha^{bb_{a,1}}}x_iy_j\n+ \\underbrace{\\pm2(1+2^l)}_{\\alpha^{bb_{a,2}}}\\sum_i x_iz \\\\\n&+ \\sum_{j,j'} \\underbrace{2^{j+j'}}_{\\alpha^{b_ab_{a,1}}}y_jy_{j'}\n+ \\sum_j \\underbrace{-(1+2^l)2^{j+1}}_{\\alpha^{b_ab_{a,2}}} y_j z.\n\\end{split}\n\\end{equation}\nThe coefficients are\n\\begin{subequations}\n\\label{eq:BCR12alpha}\n\\begin{align}\n\\alpha &= (1\\pm k)^2, \\\\\n%\n\\alpha^{b} &= \\mp 2(1\\pm k), \\\\\n\\alpha^{b_{a,1}} &= (1\\pm k)2^{j+1}, \\\\\n\\alpha^{b_{a,2}} &= (1+2^l)(2^l\\mp2k-1), \\\\\n%\n\\alpha^{bb} &= 1, \\\\\n\\alpha^{bb_{a,1}} &= \\mp2^{j+1}, \\\\\n\\alpha^{bb_{a,2}} &= \\pm2(1+2^l), \\\\\n\\alpha^{b_ab_{a,1}} &= 2^{j+j'}, \\\\\n\\alpha^{b_ab_{a,2}} &= -(1+2^l)2^{j+1}.\n\\end{align}\n\\end{subequations}\n\n\nDictionary: \\\\\n$l\\mapsto m-1$, ($l+1=m$ auxiliary variables),\\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j}$ ,\n($b_{\\text{a},j}$ would be a better choice, $\\text{a}$ is a label, $j$ is an index, they should be on the same level.\nAlso the indexing of the $\\alpha^{\\dots}$ coefficients could be made more expressive.)\\\\\n$z\\mapsto b_{a_m}$, ($b_{\\text{a},m}$ would be better)\\\\\n$k\\mapsto c$.\\\\\nNote that, in this case, the $j$ indices of the auxiliary bits have to be shifted, since they are ranging from $1$, not $0$.\n(This is not the case in the next subsection.)\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{SFR-BCR-3,4}\nWe have now the $l$ auxiliary variables $y_1,y_2,\\dots,y_{l-1},z\\in\\{0,1\\}$.\n(In the formulas, summations for $i,i' = 1,2,\\dots,n$ and $j,j' = 1,2,\\dots,l-1$ are understood.)\n\nWe have the functions\n\\begin{equation}\n\\label{eq:Akp}\nA'_k(X,y,z) = X - (k-2^l)z - (k+1)(1-z) - \\sum_{j}2^jy_j.\n\\end{equation}\nNote that, compared to \\eqref{eq:Ak},\n the difference is only in the range of index $j$ of the sum in the last term.\nFor the  two cases\n(top/bottom = SFR-BCR-3/SFR-BCR-4),\nafter substituting and collecting the terms,\n\\begin{equation}\n\\label{eq:Akp34}\n\\left.\\begin{aligned}\n&A'_k(X,y,z) \\\\\n&A'_{n-k}({n-X},y,z)\n\\end{aligned}\\right\\}\n= -(1\\pm k) \\pm \\sum_i x_i - \\sum_j 2^jy_j + (1+2^l)z.\n\\end{equation}\n(Again, although not written out explicitly,\nthe difference is in the range of $j$ of the summation, c.f., \\eqref{eq:Ak12})\n\nWe can obtain the $\\alpha^{\\dots}$ coefficients for BCR-3,4\nfrom those of BCR-1,2.\nInstead of taking the squares, $A_k(X,y,z)^2$ and $A_{n-k}(n-X,y,z)^2$,\nfor BCR-3,4 we have to take\n$\\frac12 A'_k(X,y,z)\\bigl(A'_k(X,y,z)-1\\bigr)=\\frac12\\bigl(A'_k(X,y,z)^2-A'_k(X,y,z)\\bigr)$ and\n$\\frac12 A'_{n-k}(n-X,y,z)\\bigl(A'_{n-k}(n-X,y,z)-1\\bigr)=\\frac12\\bigl(A'_{n-k}(n-X,y,z)^2-A'_{n-k}(n-X,y,z)\\bigr)$,\nso, to get the new $\\alpha^{\\dots}$ coefficients,\nwe have to substract the corresponding coefficients of $A'_k(X,y,z)$ and $A'_{n-k}(n-X,y,z)$\n(these can be read off from \\eqref{eq:Akp34})\nfrom the old ones \\eqref{eq:BCR12alpha}, and divide by $2$.\n(And not to forget that the summations for $j$ run over a different range.)\n\n\n\\begin{subequations}\n\\label{eq:BCR34alpha}\n\\begin{align}\n\\alpha &=\\frac12\\Bigl((1\\pm k)^2--(1\\pm k) \\Bigr)= \\frac12(k^2\\pm3k+2), \\\\\n%\n\\alpha^{b} &= \\frac12\\Bigl(\\mp 2(1\\pm k)-\\pm1\\Bigr)= -k\\mp\\frac32, \\\\\n\\alpha^{b_{a,1}} &= \\frac12\\Bigl((1\\pm k)2^{j+1}--2^j\\Bigr)= (3\\pm k)2^{j-1}, \\\\\n\\alpha^{b_{a,2}} &= \\frac12\\Bigl((1+2^l)(2^l\\mp2k-1)-(1+2^l)\\Bigr)= (1+2^l)(2^{l-1}\\mp k-1), \\\\\n%\n\\alpha^{bb} &= \\frac12\\bigl(1\\bigr)= \\frac12, \\\\\n\\alpha^{bb_{a,1}} &= \\frac12\\bigl(\\mp2^{j+1}\\bigr)= \\mp2^j, \\\\\n\\alpha^{bb_{a,2}} &= \\frac12\\bigl(\\pm2(1+2^l)\\bigr)= \\pm(1+2^l), \\\\\n\\alpha^{b_ab_{a,1}} &= \\frac12\\bigl(2^{j+j'}\\bigr)= 2^{j+j'-1}, \\\\\n\\alpha^{b_ab_{a,2}} &= \\frac12\\bigl(-(1+2^l)2^{j+1}\\bigr)= -(1+2^l)2^{j}.\n\\end{align}\n\\end{subequations}\n\nDictionary: \\\\\n$l\\mapsto m$, ($l=m$ auxiliary variables),\\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j},$\n($b_{\\text{a},j}$ would be a better choice, $\\text{a}$ is a label, $j$ is an index, they should be on the same level.\nAlso the indexing of the $\\alpha^{\\dots}$ coefficients could be made more expressive.)\\\\\n$z\\mapsto b_{a_m}$, ($b_{\\text{a},m}$ would be better)\\\\\n$k\\mapsto c$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{SFR-BCR-5}\n\nWe begin with the quadratization of f:\n\\\\(Theorem 6, \\cite{Boros2018boundsPaper})\n\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i=0}^{l-1}\\sum_{j=0}^{l-1}r(il+j)y_iz_j\n  + 2M\\left(1-\\sum_{i=0}^{l-1}y_i\\right)^2 + 2M\\left(1-\\sum_{j=0}^{l-1}z_j\\right)^2\\\\\n  &+ 2M\\left(|x| - \\left(l\\sum_{i=0}^{l-1}iy_i + \\sum_{j=0}^{l-1}jz_j\\right)\\right)^2\n  \\end{split}\n\\end{equation}\n\nAfter rearranging and substituting $|x| = \\sum_ix_i$ we get the equation\n\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i,j=1}^{l-1}r((i-1)l+(j-1))y_iz_j\n  + 2M\\Bigg[\\left(1-\\sum_{i=0}^{l-1}y_i\\right)^2 + \\left(1-\\sum_{j=0}^{l-1}z_j\\right)^2\\\\\n  &+ \\left(\\sum_ix_i - \\left(l\\sum_{i=1}^{l-1}(i-1)y_i + \\sum_{j=1}^{l-1}(j-1)z_j\\right)\\right)^2\\Bigg]\n  \\end{split}\n\\end{equation}\n\nDictionary: \\\\\n$l\\mapsto m + 1$,\\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j},$\\\\\n$z\\mapsto b_{a_{c+i}},$\\\\\n$\\lambda\\mapsto 2M$\\\\\n$r(x)\\mapsto f(x)$\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{SFR-BCR-6}\n\nLets start with the following quadratization of f:\n\\\\(Theorem 10, \\cite{Boros2018QuadratizationsOS})\n\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i=1}^{l-1}\\sum_{j=1}^{l-1}a_{i,j}\\cdot y_i\\cdot z_j + M\n  + M\\cdot(X-Y-1)\\cdot(X-Y+1)\\\\\n  &+ M\\cdot\\sum_{i=1}^{l-2}(1-y_i)\\cdot y_{i+1} + M\\cdot\\sum_{j=1}^{l-2}(1-z_j)\\cdot z_{j+1}\n  \\end{split}\n\\end{equation}\n\nAfter factoring out M\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i,j}^{l-1}a_{ij}y_iz_j + M\\Big(1 + \\Big((X-Y-1)(X-Y+1)\\Big)\\\\\n  &+ \\sum_{i=1}^{l-2}(1-y_i)y_{i+1} + \\sum_{j=1}^{l-2}(1-z_j)z_{j+1}\\Big)\n  \\end{split}\n\\end{equation}\n\n\\noindent \\\\Substituting for X, Y, and m using $\\sum_i w_ix_i$, $l\\left(\\sum_{j=1}^{l-1}y_j\\right) + \\sum_{j=1}^{l-1} z_j$, and $l-1$, respectively, we get\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i,j}^{m}a_{ij}y_iz_j + M\\Big[1 + \\Big(\\sum_i w_ix_i-(m-1)\\sum_{j=1}^{m}y_j + \\sum_{j=1}^{m} z_j-1\\Big)\\\\\n  &\\Big(\\sum_i w_ix_i-(m-1)\\sum_{j=1}^{m}y_j + \\sum_{j=1}^{m} z_j+1\\Big)\n  + \\sum_{i=1}^{m-1}(1-y_i)y_{i+1} + \\sum_{j=1}^{m-1}(1-z_j)z_{j+1}\\Big]\n  \\end{split}\n\\end{equation}\n\nDictionary: \\\\\n$l\\mapsto m + 1$,\\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j},$\\\\\n$z\\mapsto b_{a_{c+i}},$\\\\\n$\\lambda\\mapsto M$\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{SFR-ABCG-2}\n\nWe begin with the following representation of the parity function.\n\\\\(Theorem 4.6, \\cite{Anthony2014})\n\n\\begin{equation}\n  \\prod{(x)} = \\sum_{j=1}^n x_j + 2\\sum_{i=1}^{n-1}(-1)^{i-1}\\left[i - \\sum_{j=1}^{n}x_j\\right]^-\n\\end{equation}\n\n\\noindent Adding $E(l) = l(l-1) + 2\\sum_{i=1}^{n-1}\\left[i-l\\right]^-$ where $l = \\sum_{j=1}^n x_j$, we get the quadratization\n\n\\begin{equation}\n\\begin{split}\n  \\left.\n  g(x,y)\n  \\right.\n  &= 2\\sum_{i<j}x_ix_j + \\sum_{j=1}^n x_j + 4\\sum_{\\substack{i = 1:\\\\ i\\:odd}}^{n-1}y_i\\Big(i - \\sum_{j=1}^n x_j\\Big)\\\\\n  &= \\sum_{i}x_i + 2\\sum_{ij}x_ix_j + 4\\sum_{2i-1}^{n-1}y_i\\Big(2i - 1 - \\sum_{j}x_j\\Big)\n  \\end{split}\n\\end{equation}\n\n\\noindent Dictionary:\\\\\n$x_{i,j}\\mapsto b_{i,j}$,\\\\\n$y_{i}\\mapsto b_{a_i}$\\\\\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{SFR-ABCG-3}\nWe begin with the complement of the previous function from SFR-ABCG-2:\n\\\\(Theorem 4.6, \\cite{Anthony2014})\n\n\\begin{equation}\n  \\overline{\\prod}(x) = 1 - \\sum_{j=1}^n x_j + 2\\sum_{i=1}^{n-1}(-1)^{i}\\left[i - \\sum_{j=1}^{n}x_j\\right]^-\n\\end{equation}\n\n\\noindent Adding $E(l) = l(l-1) + 2\\sum_{i=1}^{n-1}\\left[i-l\\right]^-$ where $l = \\sum_{j=1}^n x_j$, we get the quadratization\n\n\\begin{equation}\n\\begin{split}\n  \\left.\n  g(x,y)'\n  \\right.\n  &= 1 + 2\\sum_{i<j}x_ix_j - \\sum_{i}^n x_i + 4\\sum_{\\substack{i = 2:\\\\ i\\:even}}^{n-1}y_i\\Big(i - \\sum_{j=1}^n x_j\\Big)\\\\\n  &= 1 + 2\\sum_{ij}x_ix_j - \\sum_{i} x_i + 4\\sum_{2i}^{n-1}y_i\\Big(i - \\sum_{j} x_j\\Big)\n  \\end{split}\n\\end{equation}\n\n\\noindent Dictionary:\\\\\n$x_{i,j}\\mapsto b_{i,j}$,\\\\\n$y_{i}\\mapsto b_{a_i}$\\\\\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{SFR-BCR-7}\n\nBeginning with the quadratization of f:\n\\\\(Theorem 9, \\cite{Boros2018boundsPaper})\n\n\\begin{equation}\n  \\begin{split}\n  \\left.\n  g(x,y,z)\n  \\right.\n  &= \\sum_{i=0}^{l-1}\\sum_{j=0}^{l-1}r(il+j)y_iz_j\n  + 2M\\left(1-\\sum_{i=0}^{l-1}y_i\\right)^2 + 2M\\left(1-\\sum_{j=0}^{l-1}z_j\\right)^2\\\\\n  &+ 2M\\left(|x| - \\left(l\\sum_{i=0}^{l-1}iy_i + \\sum_{j=0}^{l-1}jz_j\\right)\\right)^2\n  \\end{split}\n\\end{equation}\n\n\\noindent Finally, we end with the equation\n\\begin{equation}\n  g(x,y) = 1 + 2\\sum_{ij}x_ix_j - \\sum_{i} x_i + 4\\sum_{2i}^{n-1}y_i\\Big(i - \\sum_{j} x_j\\Big)\n\\end{equation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{comment}\n  \\subsection{SFR-BCR-8} THIS WAS JUST SFR-BCR-3/4 FOUND IN THE OTHER PAPER\n\n  Take the quadratization of the exact k-out-of-n function $f_{=k}$:\n  \\\\(Theorem 7, \\cite{Boros2018boundsPaper})\n\n  \\begin{equation}\n  \\begin{split}\n    \\left.\n    G_k(x,y,z)\n    \\right.\n    &= \\frac{1}{2}A_k(x,y,z)(A_k(x,y,z)-1)\\\\\n    &= \\frac{1}{2}\\left(A_k(x,y,z)^2-A_k(x,y,z)\\right)\n  \\end{split}\n  \\end{equation}\n\n  \\noindent Where\n  \\begin{equation}\n    A_k(X,y,z) = |x| - (k-2^l)z - (k+1)(1-z) - \\sum_{j}^{l-1}2^jy_j.\n  \\end{equation}\n\n\n  \\noindent We have $A_k(x,y,z)^2$ from \\eqref{eq:alpha12} and $A_k(x,y,z)$ from \\eqref{eq:Ak1}, thus when we substitute the two equations and collect like terms we end with\n  \\begin{equation}\n  \\begin{split}\n    \\left.\n    G_k(x,y,z)\n    \\right.\n    &=\\underbrace{\\frac{1}{2}(k^2+3k+2)}_{\\alpha}\n    + \\underbrace{-\\frac{1}{2}(2k+3)}_{\\alpha^{b}} \\sum_i x_i\n    + \\sum_j \\underbrace{(k+2)2^{j-1}}_{\\alpha^{b_{a,1}}}y_j\n    + \\underbrace{\\frac{1}{2}(1+2^l)(2^l-2k-2)}_{\\alpha^{b_{a,2}}}z \\\\\n    &+ \\underbrace{\\frac{1}{2}}_{\\alpha^{bb}} \\sum_{i,i'} x_ix_{i'}\n    + \\sum_{i,j} \\underbrace{-2^{j}}_{\\alpha^{bb_{a,1}}}x_iy_j\n    + \\underbrace{(1+2^l)}_{\\alpha^{bb_{a,2}}}\\sum_i x_iz \\\\\n    &+ \\sum_{j,j'} \\underbrace{2^{j+j'-1}}_{\\alpha^{b_ab_{a,1}}}y_jy_{j'}\n    + \\sum_j \\underbrace{-(1+2^l)2^{j}}_{\\alpha^{b_ab_{a,2}}} y_j z\n  \\end{split}\n  \\end{equation}\n\n  The coefficients are\n  \\begin{subequations}\n  \\begin{align}\n  \\alpha &= \\frac{1}{2}(k^2+3k+2), \\\\\n  %\n  \\alpha^{b} &= -\\frac{1}{2}(2k+3), \\\\\n  \\alpha^{b_{a,1}} &= (k+2)2^{j-1}, \\\\\n  \\alpha^{b_{a,2}} &= \\frac{1}{2}(1+2^l)(2^l-2k-2), \\\\\n  %\n  \\alpha^{bb} &= \\frac{1}{2}, \\\\\n  \\alpha^{bb_{a,1}} &= -2^{j}, \\\\\n  \\alpha^{bb_{a,2}} &= (1+2^l), \\\\\n  \\alpha^{b_ab_{a,1}} &= 2^{j+j'-1}, \\\\\n  \\alpha^{b_ab_{a,2}} &= -(1+2^l)2^{j}.\n  \\end{align}\n  \\end{subequations}\n\n  Dictionary: \\\\\n  $l\\mapsto m$,\\\\\n  $x_i\\mapsto b_i$, \\\\\n  $y_j\\mapsto b_{a_j}$,\\\\\n  $z\\mapsto b_{a_m}$,\\\\\n  $k\\mapsto c$.\n\\end{comment}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\subsection{SFR-BCR-8}\n\nTake the quadratization of the at least k-out-of-n function $f_{\\geq k}$:\n\\\\(Theorem 8, \\cite{Boros2018boundsPaper})\n\n\\begin{equation}\n  G_k(x,y,z) = \\frac{1}{2}A_k(x,y,z)(A_k(x,y,z)-1) + (1-z)\n\\end{equation}\n\n\\noindent With our results from SFR-BCR-8 and adding $(1+z)$ we get\\\\\n\\small\n\\begin{equation}\n\\begin{split}\n  \\left.\n  G_k(x,y,z)\n  \\right.\n  &=\\underbrace{\\frac{1}{2}(k^2+3k+4)}_{\\alpha}\n  + \\underbrace{-\\frac{1}{2}(2k+3)}_{\\alpha^{b}} \\sum_i x_i\n  + \\sum_j \\underbrace{(k+2)2^{j-1}}_{\\alpha^{b_{a,1}}}y_j\n  + \\underbrace{\\frac{1}{2}((1+2^l)(2^l-2k-2)-2)}_{\\alpha^{b_{a,2}}}z \\\\\n  &+ \\underbrace{\\frac{1}{2}}_{\\alpha^{bb}} \\sum_{i,i'} x_ix_{i'}\n  + \\sum_{i,j} \\underbrace{-2^{j}}_{\\alpha^{bb_{a,1}}}x_iy_j\n  + \\underbrace{(1+2^l)}_{\\alpha^{bb_{a,2}}}\\sum_i x_iz \\\\\n  &+ \\sum_{j,j'} \\underbrace{2^{j+j'-1}}_{\\alpha^{b_ab_{a,1}}}y_jy_{j'}\n  + \\sum_j \\underbrace{-(1+2^l)2^{j}}_{\\alpha^{b_ab_{a,2}}} y_j z\n\\end{split}\n\\end{equation}\n\\normalsize\nThe coefficients are\n\\begin{subequations}\n\\begin{align}\n\\alpha &= \\frac{1}{2}(k^2+3k+4), \\\\\n%\n\\alpha^{b} &= -\\frac{1}{2}(2k+3), \\\\\n\\alpha^{b_{a,1}} &= (k+2)2^{j-1}, \\\\\n\\alpha^{b_{a,2}} &= \\frac{1}{2}((1+2^l)(2^l-2k-2)-2), \\\\\n%\n\\alpha^{bb} &= \\frac{1}{2}, \\\\\n\\alpha^{bb_{a,1}} &= -2^{j}, \\\\\n\\alpha^{bb_{a,2}} &= (1+2^l), \\\\\n\\alpha^{b_ab_{a,1}} &= 2^{j+j'-1}, \\\\\n\\alpha^{b_ab_{a,2}} &= -(1+2^l)2^{j}.\n\\end{align}\n\\end{subequations}\n\nDictionary: \\\\\n$l\\mapsto m$,\\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j}$,\\\\\n$z\\mapsto b_{a_m}$,\\\\\n$k\\mapsto c$.\n\n\\subsection{SFR-BCR-9}\n\n\\noindent We begin with the equation for the x-symmetric quadratization of $f_k(x)$\n\\\\(Lemma 2 Eqn 7, \\cite{Boros2018QuadratizationsOS})\n\\begin{equation}\n  G(X,y) = \\alpha X^2 + X\\left(\\beta + \\sum_{j=1}^m \\gamma_jy_j\\right) + \\left[\\sum_{1\\leq i < j \\leq m} \\delta_{ij}y_iy_j + \\sum_{j=1}^m \\epsilon_jy_j+\\phi\\right]\n\\end{equation}\n\n\\noindent Using the relationship $X = \\sum_i^nx_i$ and rearranging, we get\n\\begin{equation}\n\\begin{split}\n  \\left.\n  G(X,y)\n  \\right.\n  &= \\alpha\\sum_{i,j}^mx_ix_j + \\sum_i^mx_i\\left(\\beta + \\sum_{j=1}^m \\gamma_jy_j\\right) + \\left[\\sum_{1\\leq i < j \\leq m} \\delta_{ij}y_iy_j + \\sum_{j=1}^m \\epsilon_jy_j+\\phi\\right]\\\\\n  &= \\alpha\\sum_{i,j}^mx_ix_j + \\beta\\sum_i^mx_i + \\sum_{1,j=1}^m \\gamma_jx_iy_j + \\sum_{ij}^m \\delta_{ij}y_iy_j + \\sum_{j=1}^m \\epsilon_jy_j+\\phi\n\\end{split}\n\\end{equation}\n\nDictionary: \\\\\n$x_i\\mapsto b_i$, \\\\\n$y_j\\mapsto b_{a_j}$\\\\\n\n\n\\bibliography{SFRBibliography}\n\n\n\\end{document}\n", "meta": {"hexsha": "340b5c11a731d0af7db29d245993cd85351982da", "size": 17542, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "everything_else/SFR_Derivations/SFR_Derivations.tex", "max_stars_repo_name": "johnjeihokim/Book_About_Quadratization", "max_stars_repo_head_hexsha": "105910e52f30c418fbc07dcb4099f403ad6ffa49", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2019-05-06T13:40:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T21:13:23.000Z", "max_issues_repo_path": "everything_else/SFR_Derivations/SFR_Derivations.tex", "max_issues_repo_name": "johnjeihokim/Book_About_Quadratization", "max_issues_repo_head_hexsha": "105910e52f30c418fbc07dcb4099f403ad6ffa49", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 33, "max_issues_repo_issues_event_min_datetime": "2018-10-31T03:34:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T12:35:11.000Z", "max_forks_repo_path": "everything_else/SFR_Derivations/SFR_Derivations.tex", "max_forks_repo_name": "k-local-quadratization/review", "max_forks_repo_head_hexsha": "96424fa86b2a43b2c13eddc63b4217f523369474", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2019-08-19T14:24:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T03:02:50.000Z", "avg_line_length": 33.2865275142, "max_line_length": 183, "alphanum_fraction": 0.5809485805, "num_tokens": 7499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.44922468751019207}}
{"text": "\\section{Type models and type graphs}\n\\label{sec:transformation_framework:type_models_and_type_graphs}\n\nIn this section, the proposed framework structure is applied to type models and type graphs. First, the general structure and its requirements are discussed. Then the required definitions and theorems are given.\n\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture} \n    \\path\n    (-3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](ME) {$T$}\n    (-4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MA) {$Tm_A$}\n    (-1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MB) {$Tm_B$}\n    (-3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](MAB) {$Tm_{AB}$}\n    \n    (3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](GN) {$N$}\n    (1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GA) {$TG_A$}\n    (4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GB) {$TG_B$}\n    (3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](GAB) {$TG_{AB}$};\n    \n    \\path[]\t\t\n    (ME) [-, black, out=240, in=90] edge node[above] {} (MA)\n    (ME) [-, black, out=300, in=90] edge node[above] {} (MB)\n    \n    (MA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)\n    (MB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)\n    \n    (GN) [-, black, out=240, in=90] edge node[above] {} (GA)\n    (GN) [-, black, out=300, in=90] edge node[above] {} (GB)\n    \n    (GA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)\n    (GB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)\n    \n    (ME) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f$} (GN)\n    (GN) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (ME)\n    \n    (MA) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_A$} (GA)\n    (GA) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MA)\n    \n    (MB) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_B$} (GB)\n    (GB) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MB)\n    \n    (MAB) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f_{A} \\sqcup f_{B}$} (GAB)\n    (GAB) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (MAB)\n    ;\n    \\end{tikzpicture}\n    \\caption{Structure for transforming between type models and type graphs}\n    \\label{fig:transformation_framework:type_models_and_type_graphs:structure_type_models_graphs}\n\\end{figure}\n\n\\cref{fig:transformation_framework:type_models_and_type_graphs:structure_type_models_graphs} shows an alternation of the structure proposed in \\cref{sec:transformation_framework:structure} applied to type models and type graphs. As before, type model $Tm_A$ represents the partially build model which corresponds to type graph $TG_A$ under the transformation function $f_A$. Type model $Tm_B$ represents the next building block to add to this model. It corresponds to type graph $TG_B$ under the bijective transformation function $f_B$.\n\nType models $Tm_A$ and $Tm_B$ are entirely distinct except for a set types $T$, which means $T \\subseteq Type_{Tm_A} \\land T \\subseteq Type_{Tm_B}$. In a similar way, type graphs $TG_A$ and $TG_B$ are entirely distinct except for a set of node types $N$, so $N \\subseteq NT_{TG_A} \\land N \\subseteq NT_{TG_B}$.\n\nType models $Tm_A$ and $Tm_B$ are combined into type model $Tm_{AB}$ using \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_models:combine}. In a similar way type graphs $TG_A$ and $TG_B$ are combined into type graph $TG_{AB}$ using \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_graphs:combine}. \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_models:tmod_combine_merge_correct} and \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_graphs:tg_combine_merge_correct} respectively show that $Tm_{AB}$ and $TG_{AB}$ are valid. Then \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:combination_transformation_function_type_model_type_graph} and \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:combination_transformation_function_type_graph_type_model} can be used to merge the transformation functions $f_A$ and $f_B$ into $f_{A} \\sqcup f_{B}$, where \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:tg_combine_mapping_correct} and \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:tg_combine_mapping_function_correct} show that $f_{A} \\sqcup f_{B}$ is again a valid transformation function transforming $Tm_{AB}$ to $TG_{AB}$. Similarly, \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:tmod_combine_mapping_correct} and \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_transformation_functions:tmod_combine_mapping_function_correct} show that the inverse function of $f_{A} \\sqcup f_{B}$ is again a valid transformation function transforming $TG_{AB}$ to $Tm_{AB}$.\n\n\\input{tex/04_transformation_framework/03_type_models_and_type_graphs/01_combining_type_models.tex}\n\\input{tex/04_transformation_framework/03_type_models_and_type_graphs/02_combining_type_graphs.tex}\n\\input{tex/04_transformation_framework/03_type_models_and_type_graphs/03_combining_transformation_functions.tex}", "meta": {"hexsha": "46446584d0c4ed4891acd83af01d751576b712ff", "size": 5501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/04_transformation_framework/03_type_models_and_type_graphs.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/04_transformation_framework/03_type_models_and_type_graphs.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/04_transformation_framework/03_type_models_and_type_graphs.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.8448275862, "max_line_length": 1871, "alphanum_fraction": 0.7495000909, "num_tokens": 1687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4492246870944335}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%    INSTITUTE OF PHYSICS PUBLISHING                                   %\n%                                                                      %\n%   `Preparing an article for publication in an Institute of Physics   %\n%    Publishing journal using LaTeX'                                   %\n%                                                                      %\n%    LaTeX source code `ioplau2e.tex' used to generate `author         %\n%    guidelines', the documentation explaining and demonstrating use   %\n%    of the Institute of Physics Publishing LaTeX preprint files       %\n%    `iopart.cls, iopart12.clo and iopart10.clo'.                      %\n%                                                                      %\n%    `ioplau2e.tex' itself uses LaTeX with `iopart.cls'                %\n%                                                                      %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%\n% First we have a character check\n%\n% ! exclamation mark    \" double quote  \n% # hash                ` opening quote (grave)\n% & ampersand           ' closing quote (acute)\n% $ dollar              % percent       \n% ( open parenthesis    ) close paren.  \n% - hyphen              = equals sign\n% | vertical bar        ~ tilde         \n% @ at sign             _ underscore\n% { open curly brace    } close curly   \n% [ open square         ] close square bracket\n% + plus sign           ; semi-colon    \n% * asterisk            : colon\n% < open angle bracket  > close angle   \n% , comma               . full stop\n% ? question mark       / forward slash \n% \\ backslash           ^ circumflex\n%\n% ABCDEFGHIJKLMNOPQRSTUVWXYZ \n% abcdefghijklmnopqrstuvwxyz \n% 1234567890\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\documentclass[12pt]{iopart}\n%\\newcommand{\\gguide}{{\\it Preparing graphics for IOP Publishing journals}}\n%Uncomment next line if AMS fonts required\n%\\usepackage{iopams}  \n\\usepackage[thinlines]{easytable}\n\\begin{document}\n\n\\title[Drift velocities in plasmas]{Drift velocities in plasmas}\n\n\\author{John \"Jack\" Brooks}\n\n%\\address{}\n\\ead{jwbrooks0@gmail.com}\n\\vspace{10pt}\n\\begin{indented}\n\\item[]\\today\n\\end{indented}\n\n%\\begin{abstract}\n%\\end{abstract}\n\n%\n% Uncomment for keywords\n%\\vspace{2pc}\n%\\noindent{\\it Keywords}: XXXXXX, YYYYYYYY, ZZZZZZZZZ\n%\n% Uncomment for Submitted to journal title message\n%\\submitto{\\JPA}\n%\n% Uncomment if a separate title page is required\n%\\maketitle\n% \n% For two-column output uncomment the next line and choose [10pt] rather than [12pt] in the \\documentclass declaration\n%\\ioptwocol\n%\n\n\n\n\\section{Motion in a uniform $\\mathbf{B}$ field}\n\nPlasma consists of a collection of positively and negatively charged particles (ions and electrons).  When a uniform magnetic field is applied, $\\mathbf{B}$, the plasma is considered magnetized, and the charged particles (plasma) oscillate around the magnetic field lines.  For this work, we define the unit vector associated with the uniform $\\mathbf{B}$ to be the parallel, $||$, direction, and everything else as being the cross-field, $\\perp$, direction.\n\nThe equation of motion of moving charged particles in a magnetic field is\n\\begin{equation}\n\\label{eq:eom_simple}\nm \\dot{\\mathbf{v}} = q \\mathbf{v} \\times \\mathbf{B}\n\\end{equation}\nWe note that the only non-trivial solution of $\\mathbf{v}$ is the cross-field velocity, $\\mathbf{v}_\\perp$, and therefore we replace $\\mathbf{v}$ with $\\mathbf{v}_\\perp$.  \n\nTo solve for $\\mathbf{v}_\\perp$, we take the time derivative of Eq.~\\ref{eq:eom_simple} and plug Eq.~\\ref{eq:eom_simple} into it.  This provides\n\\begin{equation*}\n\\label{eq:eom_simple_2}\n\\ddot{\\mathbf{v}}_\\perp = \\frac{q^2}{m^2} \\left (\\mathbf{v}_\\perp \\times \\mathbf{B}  \\right) \\times \\mathbf{B}.\n\\end{equation*}\nExpanding the triple product using BAC-CAB triple product rule provides\n\\begin{equation*}\n\\label{eq:eom_simple_3}\n\\ddot{\\mathbf{v}}_\\perp = -\\frac{q^2}{m^2} \\left (B^2 \\mathbf{v}_\\perp - \\left( \\mathbf{B} \\cdot \\mathbf{v}_\\perp \\right) \\mathbf{B} \\right).\n\\end{equation*}\nRecognizing that $\\mathbf{B} \\cdot \\mathbf{v}_\\perp = 0$, this simplifies to \n\\begin{equation*}\n%\\label{eq:eom_simple_3}\n\\ddot{\\mathbf{v}}_\\perp = -\\left(\\frac{qB}{m}\\right)^2 \\mathbf{v}_\\perp \n\\end{equation*}\nand therefore the velocity has the solution\n\\begin{equation}\n\\label{eq:velocity_solved}\n\\mathbf{v}_\\perp = v_\\perp(0) e^{i \\left(qB/m\\right) t}.\n\\end{equation}\n\nIntegrating Eq.~\\ref{eq:velocity_solved}, we can solve for the position to be\n\n\\begin{equation}\n%\\label{eq:eom_simple_3}\n\\mathbf{x}_\\perp = \\frac{v_\\perp(0) m}{|q|B} e^{i \\left(qB/m\\right) t}.\n\\end{equation}\nFrom this equation, we can identify the gryo-radius (the radius of the circle created by the gyrating particle) to be\n\n\\begin{equation}\n%\\label{eq:gyro-radius}\nr_{gyro} = \\frac{v_\\perp m}{|q|B}\n\\end{equation}\nand the gyro-frequency (the frequency of gyration) to be\n\n\\begin{equation}\n%\\label{eq:gyro-radius}\n\\omega_{gyro} = \\frac{qB}{m}.\n\\end{equation}\nThis derivation informs us that the plasma rotates around the magnetic field line and is effectively trapped to the magnetic field without the presence of external forces.  \n\n\n\\section{External forces cause a net drift velocity on the plasma}\n\nWhen an external force is applied to the plasma, it develops an net drift motion (a drift velocity) orthogonal to $\\mathbf{B}$ and the external force.  Example forces include gravity, Coulomb force, kinetic pressure, etc.  \n\nTo calculate the impact of a force on the plasma, we include an unspecified force, $\\mathbf{F}$, to our equation of motion (EoM),\n\\begin{equation*}\n%\\label{eq:eom_simple}\nm \\dot{\\mathbf{v}} = q \\mathbf{v}_\\perp \\times \\mathbf{B} + \\mathbf{F}.\n\\end{equation*}\nIn addition, we ignore gyromotion and focus on steady-state ``drift'' velocities by time-averaging the EoM over a time much larger than a full gyro-rotation.  The EoM therefore simplifies to\n\\begin{equation*}\n%\\label{eq:eom_simple}\n0 = q \\mathbf{v}_\\perp \\times \\mathbf{B} + \\mathbf{F}.\n\\end{equation*}\n\nWe next solve for $\\mathbf{v}_\\perp (\\mathbf{F})$ by multiplying the cross product of $\\mathbf{B}$ throughout, performing the BAC-CAB triple product expansion rule, and recognizing that $\\mathbf{B} \\cdot \\mathbf{v}_\\perp = 0$.  We finally arrive at \n\\begin{equation}\n\\label{eq:drift_velocity_generic}\n\\mathbf{v}_\\perp = \\frac{\\mathbf{F} \\times \\mathbf{B}}{q \\left | B \\right|^2}\n\\end{equation}\n\nMost drift velocities (perhaps all) can be solved as a special case of the generalized velocity, Eq.~\\ref{eq:drift_velocity_generic}, and I personally find it easier to conceptualize each of these drift velocities by considering the force that originally created them.  However, many plasma references prefer a more traditional approach and instead derive them from scratch.  \n\n\n\\section{Specific drift velocities}\n\nNow that we have a generic expression for how forces create a net plasma drift velocity (Eq.~\\ref{eq:drift_velocity_generic}), the next step is to identify common forces and plug them in.  I've done this for you in Table~\\ref{tab:drift_summary} which shows examples of several common forces and their resulting drift velocities.  As an example, the Coulomb force results in the $\\mathbf{E} \\times \\mathbf{B} $ drift that has a net motion that is orthogonal to both $\\mathbf{E}$ and $\\mathbf{B}$.  Because it has no dependence of charge, $q$, and both ions and electrons therefore move in the same direction when exposed to a net electric field.  The other drift velocities, for example the gravitational drift, are dependent on the plasma charge, $q$, and this means that most forces result in ions and electrons traveling in opposite directions.  \n\n\\renewcommand{\\arraystretch}{1.5} %% Increases row height in the table\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|c|c|c|c|}\n\\hline\n\\multicolumn{2}{|c|}{\\textbf{Force}, $\\mathbf{F}$}    & \\multicolumn{2}{c|}{\\textbf{Resulting drift velocity}, $\\mathbf{v}_\\perp$} \\\\ \\hline \n\\textbf{Name}       & \\textbf{Equation} & \\textbf{Name}       & \\textbf{Equation}      \\\\ \\hline\nGravity             & $m\\mathbf{g}$                &      Gravitational drift               &           $\\frac{m \\mathbf{g} \\times \\mathbf{B}}{qB^2}$             \\\\ \\hline\nCoulomb force      & $q\\mathbf{E}$                &       E ``cross'' B drift              &      $\\frac{ \\mathbf{E} \\times \\mathbf{B}}{B^2}$                      \\\\ \\hline\nKinetic pressure    &          $\\frac{ - \\nabla P}{n}$         &        Diamagnetic drift             &     $-\\frac{ \\nabla P \\times \\mathbf{B}}{nqB^2}$                       \\\\ \\hline\nMagnetic dipole restoring force     &   $-\\frac{mv_\\perp^2}{2B} \\nabla B$                &     ``Grad'' B drift                &           $\\frac{m v_\\perp^2}{2qB}\\frac{\\mathbf{B} \\times \\nabla B}{B^2}$             \\\\ \\hline\nCentripetal force          & $\\frac{mv_{||}^2}{\\mathbf{r}}$          &         Curvature drift            &       $ m v_{||}^2 \\frac{\\mathbf{r}\\times\\mathbf{B}}{qB^2r^2}$              \\\\ \\hline\nOscillating E field & $-\\frac{m\\mathbf{B}\\times\\mathbf{\\dot{E}}}{B^2}$      &    Polarization drift                 &  $\\frac{m \\mathbf{\\dot{E}}}{qB^2} $                      \\\\ \\hline\n\\end{tabular}\n\\caption{\\label{tab:drift_summary}List of forces that can act on a plasma and their resulting drift velocity. }\n\\end{table}\n\nSeveral of the other forces are somewhat nuanced and require a little more context.  The diamagnetic drift is due to resulting force from kinetic pressure (i.e. collisions between particles) in the plasma.  The $\\nabla B$ drift is created charged particle gyro-motion around a  non-uniform $\\mathbf{B}$ which results in a restoring magnetic dipole force.  Curvature drift occurs when the magnetic field line is curved and the plasma particle (which is mostly trapped to the field line) is forced to bend along with the field line.  \n\nThe force responsible for the polarization drift is less straight forward.  In this case, the electric field, $\\mathbf{E}$, is changing as a function of time.  The resulting force can be derived from the lorentz Force,\n\n\\begin{equation*}\n\\mathbf{E} = - \\mathbf{v} \\times \\mathbf{B},\n\\end{equation*}\ntaking the time derivative and multiplying my the mass,\n\\begin{equation*}\n\\mathbf{m\\mathbf{\\dot{E}}} = - m\\mathbf{\\dot{v}} \\times \\mathbf{B} = - \\mathbf{F} \\times \\mathbf{B},\n\\end{equation*}\ncrossing both sides with $\\mathbf{B}$ and using the BAC-CAB rule to get \n\\begin{equation}\n\\mathbf{F} = - \\frac{m \\mathbf{B} \\times \\mathbf{\\dot{E}}}{B^2}.\n\\end{equation}\n\nThe drift velocities discussed here are merely the motions that are typically covered by plasma physics textbooks, and more complicated motions exist.  These include those from radiation pressure and more complex collision models.  In addition, higher order corrections to the drift velocities discussed here exist when the various forces are not constant in time and space.  \n\n\\section{Plasma currents}\n\nBecause of the $q$ dependence in most of the drift velocities in Table~\\ref{tab:drift_summary}, ions and electrons move in opposite directions under these forces.  Therefore, these drift velocities also create electrical current in the plasma.  The exception to this is the $\\mathbf{E} \\times \\mathbf{B}$ drift velocity. \n\n\\section*{References}\n\\begin{thebibliography}{widest entry}\n\\bibitem{deBlank} de Blank, H.J., ``Guiding Center Motion'', Personal notes: $https://juser.fz-juelich.de/record/283631/files/DeBlank_BT-1-2.pdf$\n\\end{thebibliography}\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "e162aebc6bf54ff898e9d66362529f5d33a61315", "size": 11532, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Plasma_physics/Drift_velocities/plasma_drift_velocities.tex", "max_stars_repo_name": "jwbrooks0/misc_derivations", "max_stars_repo_head_hexsha": "3f5b1bbf0dc07821de89619dd794166f5cc217f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Plasma_physics/Drift_velocities/plasma_drift_velocities.tex", "max_issues_repo_name": "jwbrooks0/misc_derivations", "max_issues_repo_head_hexsha": "3f5b1bbf0dc07821de89619dd794166f5cc217f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Plasma_physics/Drift_velocities/plasma_drift_velocities.tex", "max_forks_repo_name": "jwbrooks0/misc_derivations", "max_forks_repo_head_hexsha": "3f5b1bbf0dc07821de89619dd794166f5cc217f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.1770334928, "max_line_length": 848, "alphanum_fraction": 0.6601630246, "num_tokens": 3220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949467848392, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.44922468626291584}}
{"text": "%!TEX root=../../../template.tex\n\\subsection{The Lambertian Hypothesis}%\n\\label{sub:methods_lambertian_hypothesis}\n\nAs stated in this chapter's introductory notes, this thesis main body of\nwork revolves around two base assumptions, our hypothesis. The first\none, about the information capturing by the idealised system, was\naddressed in Subsection~\\ref{sub:methods_collection}. The second, more\nphysical in nature, is the subject matter of this section. Our\nhypothesis states that the light absorption between points $A$ and $B$\n(let's call it $A_{AB}$) should be equal to the difference of the\nabsorptions in $A$ and $B$. We can write this, in a \\emph{Lambertian}\nmanner as in Equation~\\ref{eq:lambertian_hypothesis}.\n\n\\begin{equation}\n    \\label{eq:lambertian_hypothesis}\n    I_B = I_A \\cdot \\exp \\bigg[-AB \\cdot \\sum_i \\sigma_{ABi} \\cdot\n    c_{ABi}\\bigg]\n\\end{equation}\n\nThis is to say that the light intensity reaching point $B$ is given by\nthe intensity reaching $A$, exponentially decreased by the absorbers at\ninterval $AB$. The intensities at $A$ and $B$ are written as in\nEquation~\\ref{eq:intensityAtAAndB}.\n\n\\begin{equation}\n    \\begin{aligned}\n        \\label{eq:intensityAtAAndB}\n        I_B = I_0 \\cdot \\exp \\bigg[ -L_B \\cdot \\sum_i \\sigma_{Bi} \\cdot\n        c_{Bi} \\bigg]\\\\\n        I_A = I_0 \\cdot \\exp \\bigg[ -L_A \\cdot \\sum_i \\sigma_{Ai} \\cdot\n        c_{Ai} \\bigg]\n    \\end{aligned}\n\\end{equation}\n\nIf we join all this information in the same expression, the equation is\ntransformed into its final form, presented in\nEquation~\\ref{eq:hypothesis_final_form}.\n\n\\begin{equation}\n    \\small\n    \\label{eq:hypothesis_final_form}\n    I_0 \\cdot \\exp \\bigg[ -L_B \\cdot \\sum_i \\sigma_{Bi} \\cdot\n            c_{Bi} \\bigg] = I_0 \\cdot \\exp \\bigg[ -L_A \\cdot \\sum_i \\sigma_{Ai} \\cdot\n            c_{Ai} \\bigg] \\cdot \\bigg[-AB \\cdot \\sum_i \\sigma_{ABi} \\cdot\n            c_{ABi}\\bigg]\n\\end{equation}\n\nEquation~\\ref{eq:hypothesis_final_form} can be greatly simplified: we\ntake the natural logarithm of both sides and we state that $\\sum_i\n\\sigma_{Xi} \\cdot c_{Xi} = S_i$. These operations result in the\nsimplified form of Equation~\\ref{eq:final_form_simplified}.\n\n\\begin{equation}\n    \\label{eq:final_form_simplified}\n    L_B \\cdot S_B = L_A \\cdot S_A + L_{AB} \\cdot S_{AB}\n\\end{equation}\n\nNow, $L_X \\cdot S_X$ can be thought of as the wavelength dependent light\nabsorption in path $X$. In this case, the wavelength interval is always\nthe same. We can therefore conclude that, theoretically, our\nhypothesis is valid: light absorption between points $A$ and $B$ can be\nexpressed in terms of the absorption on both these points and\ncorresponds to their difference.\n\nAlthough mathematically this seems clear-cut, in the real world things\ncan become more problematic, since we have to deal with the\nimperfections that characterise a real physical system. Noise,\ninstrumental limitations, adverse environmental effects, etc.. The\nexperiment we describe in the next few paragraphs aimed at determining\ntarget trace gas concentration in a set analysis field. This field is\ndimension-wise compatible with those that would be employed in the final\nworking system. This experiment is represented in\nFigure~\\ref{fig:experiment_map}.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{img/png/experimentMap.png}\n    \\caption{Location of observer points for the physical experiment.}\n    \\label{fig:experiment_map}\n\\end{figure}\n\nThe goal of the experiment was to compare passive and active \\gls{DOAS}\nmeasurements performed with a very short time difference between them.\nThe passive measurement would employ the same acquisition strategy as\nthe drone is expected to use. This comparison will be used to test our\nsecond hypothesis.\n\nFinding two appropriate experiment sites proved to be the first\ndifficulty: both telescopes should see sky on the back of the other\ntelescope. Otherwise, the contribution from the terrain's reflection\nwould have to be taken into account and the experiment conditions would\nbe very different from the ones the drone will have. There are not many\nsite pairs that provide this, and most of the ones that exist are\nprivate and authorisations are not easy to obtain. In the end, we\nmanaged to run the experiment in the facilities of \\emph{\\gls{iep}} and\nthe \\emph{Cristo-Rei} sanctuary, near our own base. \n", "meta": {"hexsha": "08e65128672f58bca071013b107da026be14efbb", "size": 4353, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/methods/hyp2/methods_lambertian_hypothesis.tex", "max_stars_repo_name": "ruivalmeida/novathesis", "max_stars_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/methods/hyp2/methods_lambertian_hypothesis.tex", "max_issues_repo_name": "ruivalmeida/novathesis", "max_issues_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/methods/hyp2/methods_lambertian_hypothesis.tex", "max_forks_repo_name": "ruivalmeida/novathesis", "max_forks_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.4183673469, "max_line_length": 85, "alphanum_fraction": 0.753503331, "num_tokens": 1188, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.44922467826969575}}
{"text": "\\startreport{Dense Neural Networks}\n\\reportauthor{Ramesh Subramonian}\n\n\\section{Computational Considerations}\nWe start by describing the dense neural network (DNN) computation. In\nSection~\\ref{the_math}, we will discuss the underyling mathematics. \n\\subsection{Data Structure of DNN}\n\\label{data_struct}\nWe start by presenting the data structure of the DNN\n\\begin{figure}\n\\centering\n% TODO: Following should be auto-generated not hard-coded\n\\verbatiminput{dnn_types.h}\n\\end{figure}\n\nWe now explain each element of the \n\\be\n\\item \\(n\\) --- {\\tt nl}, number of layers. The simplest DNN has 3 layers --- \nan input layer, a hidden layer and an output layer.\n\\item \\(p\\) -- {\\tt npl}, number of neurons per layer. \\(p_l\\) is number of\nneurons in layer \\(l\\), where \\(0 \\leq l < n\\). The network of\nFigure~\\ref{sample_network} would have \\(n = 3, p = \\{3,4,1\\}\\)\n\\item \\(W\\) --- the weights on the edges. \n\\(W_i\\) contains the edges from layer \\(i-1\\) to layer \\(i\\). \nHence, \n\\be\n\\item \\(W_0 = \\bot\\)\n\\item \\(W_i = \\) edges from layer \\(i-1\\) to layer \\(i\\). Note that \n\\(0 < i < n\\)\n\\item \\(W_{i,j} = \\) edges from neuron \\(j\\) of layer \\(i-1\\) to layer \\(i\\).\nNote that \\( 0 \\leq < p_{i-1}\\).\n\\item \\(W_{i,j,k} = \\) edge from neuron \\(j\\) of layer \\(i-1\\) to \nneuron \\(k\\) of layer \\(i\\).\nNote that \\(0 \\leq k < p_i\\).\n\\ee\n\\item \\(b\\) --- the bias of the neurons.\n\\(b_i\\) contains the bias of neurons in layer \\(i\\). \nNote that \\(0 < i < n\\).\nHence, \n\\be\n\\item \\(b_0 = \\bot\\)\n\\item \\(b_i = \\) biases of neurons in layer \\(i\\)\n\\item \\(b_{i,j} = \\) bias of neuron \\(j\\) of layer \\(i\\), \nwhere \\(0 \\leq j < p_i\\)\n\\ee\n\\item \\(z\\) --- the intermediate output of a neuron\n\\(z_i\\) contains the intermediate output of neurons in layer \\(i\\). \nHence, \n\\be\n\\item \\(z_0 = \\bot\\)\n\\item \\(z_i = \\) intermediate output of neurons in layer \\(i\\)\nNote that \\(0 < i < n\\).\n\\item \\(z_{i,j} = \\) intermediate output of neuron \\(j\\) of layer \\(i-1\\) \n\\ee\n\\item \\(a\\) --- the output output of a neuron --- after intermediate output has been\npassed through activation function.\n\\(a_i\\) contains the output of neurons in layer \\(i\\). \nHence, \n\\be\n\\item \\(a_0 = \\bot\\)\n\\item \\(a_i = \\) output of neurons in layer \\(i\\)\nNote that \\(0 < i < n\\).\n\\item \\(a_{i,j} = \\) output of neuron \\(j\\) of layer \\(i-1\\) \n\\ee\nThe observant reader would have noticed that the above description indicates\nthat \\(z, a\\) are 2-dimensional arrays whereas they have been defined as {\\tt\nfloat ***}. This is because the network is evaluated in batches, explained in\nSection~\\ref{batching}\n\\ee\n\n\\subsection{Batching}\nWhat is batching? Assume that we have \\(n\\) instances and a batch size of \\(m <\nn\\). Then, it means that an epoch consists of performing the forward pass \nfor \\(m\\) instances, then the back propagation, then doing the same for the next\n\\(m\\) instances and so on.\n\nThis makes \\(z, a\\) 3-dimensional arrays such that \n\\(a_{i,j, k} = \\) output of neuron \\(j\\) of layer \\(i-1\\) for \\(k^{th}\\)\ninstance.\n\n\\section{The Math}\n\n\\subsection{Dropouts}\nDropouts are explained in \\cite{Srivastava14}.\n\n\\TBC\n\\newpage\n\\bibliographystyle{alpha}\n\\bibliography{../../../DOC/Q_PAPER/ref}\n", "meta": {"hexsha": "f467c4e6a7251cb1b5f3af93e8aaf37012f490b6", "size": 3136, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "RUNTIME/DNN/doc/dnn.tex", "max_stars_repo_name": "subramon/qlu", "max_stars_repo_head_hexsha": "2fb8a2b3636dd11e2dfeae2a6477bd130316da47", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "RUNTIME/DNN/doc/dnn.tex", "max_issues_repo_name": "subramon/qlu", "max_issues_repo_head_hexsha": "2fb8a2b3636dd11e2dfeae2a6477bd130316da47", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-07-29T16:48:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-26T23:47:22.000Z", "max_forks_repo_path": "RUNTIME/DNN/doc/dnn.tex", "max_forks_repo_name": "subramon/qlu", "max_forks_repo_head_hexsha": "2fb8a2b3636dd11e2dfeae2a6477bd130316da47", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-14T22:34:13.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-14T22:34:13.000Z", "avg_line_length": 34.8444444444, "max_line_length": 84, "alphanum_fraction": 0.6610331633, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949442167993, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.44922467406520633}}
{"text": "\\section{Summary and Outlook} \\label{sec:summary}\nBy analyzing the SED of a galaxy, we can infer detailed physical properties\nsuch as its stellar mass, star formation rate, metallicity, and dust content. \nThese properties serve as the building blocks of our understanding of how\ngalaxies form and evolve. \nState-of-the-art SED modeling methods use MCMC sampling to perform Bayesian\nstatistical inference. \nThey derive posterior probability distributions of galaxy properties given\nobservation that accurately estimate uncertainties and parameter degeneracies\nto enable more rigorous statistical analyses. \n%Posteriors also enable marginalization over any nuisance parameters. \nFor the dimensionality of current SED models, deriving a posterior requires \n${\\gtrsim}100,000$ model evaluations and take ${\\gtrsim}10-100$ CPU hours per \ngalaxy. \nUpcoming galaxy surveys, however, will observe \\emph{billions} of galaxies\nusing \\emph{e.g.} DESI, PFS, Rubin observatory, James Webb Space Telescope, and\nthe Roman Space Telescope. \nAnalyzing all of these galaxies with current Bayesian SED models is infeasible\nand would require hundreds of billions of CPU hours.\nEven with recently proposed emulators, which accelerate model evaluations by\nthree to four orders to magnitude, the computation cost of SED modeling would\nremain a major bottleneck for galaxy studies. \n\nWe demonstrate in this work that Amortized Neural Posterior Estimation (ANPE)\nprovides an alternative \\emph{scalable} approach for Bayesian inference in SED\nmodeling.\nANPE is a simulation-based inference method that formulates Bayesian inference\nas a density estimation problem and uses neural density estimators (NDE) to\napproximate the posterior over the full space of observations. \nThe NDE is trained using parameter values drawn from the prior and mock\nobservations simulated with these parameters.  \nOnce trained, a posterior can be obtained from the NDE by providing the\nobservations as the conditional variables without any additional model\nevaluations. \n\nIn this work, we present {\\sc SEDflow}, a galaxy SED modeling method using ANPE\nand PROVABGS, a flexible SED model that uses a compact non-parameteric SFH and\nZH prescriptions and was recently validated in \\cite{hahn2022}.\nFurthermore, we apply {\\sc SEDflow} to optical photometry from the NASA-Sloan\nAtlas as demonstration and validation of our ANPE approach.  \nWe present the following key results from our analysis. \\vspace{2mm}\n\\begin{compactitem}\n    \\item We train {\\sc SEDflow} using a data set of ${\\sim}1$ million SED\n        model parameters and forward model synthetic SEDs.\n        The parameters are drawn from a prior and the forward model is based on\n        the PROVABGS and noise models. \n        We design the ANPE to estimate $p(\\btheta | f_X, \\sigma_X, z)$, where\n        $f_X$, $\\sigma_X$, and $z$ are the photometry, photometric uncertainty,\n        and redshift, respectively. \n        For its architecture, we use a MAF normalizing flow with 15 MADE blocks\n        each with 2 hidden layers and 500 hidden units.\n        Training {\\sc SEDflow} requires roughly 1 day on a single CPU. \n        Once trained, deriving posteriors of galaxy properties for a galaxy\n        takes ${\\sim}1$ second, $10^5\\times$ faster than traditional MCMC sampling. \n    \\item Posteriors derived using {\\sc SEDflow} show excellent agreement with\n        posteriors derived from MCMC sampling. \n        We further validate the accuracy of the posteriors by applying  {\\sc\n        SEDflow} to synthetic observations with known true parameter values.  \n        Based on statistical metrics used in the literature (p-p plot and SBC),\n        we find excellent agreement between the {\\sc SEDflow} and the true\n        posteriors. \n    \\item Lastly, we demonstrate the advantages of {\\sc SEDflow} by applying it\n        to the NASA-Sloan Atlas.\n        Estimating the posterior of ${\\sim}33,000$ galaxies takes $\\sim$12 CPU\n        hours.\n        We make the catalog of posteriors publicly available at\n        \\url{https://changhoonhahn.github.io/SEDflow/}. \n        For each galaxy, the catalog contains posteriors of all 12 PROVABGS\n        SED model parameters as well as the galaxy properties: $M_*$, \n        average SFR over 1Gyr, mass-weighted metallicity, and mass-weighted\n        stellar age. \\vspace{2mm}\n\\end{compactitem}\n\nThis work highlights the advantages of using an ANPE approach to Bayesian SED\nmodeling. \nOur approach can easily be extended beyond this application. \nFor instance, we can include multi-wavelength photometry at ultra-violet or\ninfrared wavelengths. \nWe can also modify \\sedflow~to infer redshift from photometry. \nIn \\sedflow, we include redshift as a conditional variable, since NSA provides\nspectroscopic redshifts. \nHowever, redshift can be included as an inferred variable rather than a\nconditional one. \nThen, we can apply \\sedflow~to infer galaxy properties from photometric data\nsets without redshift measurements while marginalizing over the redshift\nprior. \nIf we do not require spectroscopic redshifts, \\sedflow~can be extended to much\nlarger data sets that span fainter and broader galaxy samples. \nConversely, we can use \\sedflow~to infer more physically motivated photometric \nredshifts, where we marginalize over our understanding of galaxies rather than\nusing templates. \n\nThe ANPE approach to SED modeling can also be extended to galaxy spectra. \nConstructing an ANPE for the full data space of spectra would requires\nestimating a dramatically higher dimensional probability distribution. \nSDSS spectra, for instance, have ${\\sim}3,600$ spectral elements.  \nIn our approach we include the uncertainties of observables as conditional\nvariables, which doubles the curse of dimensionality.\nRecent works, however, have demonstrated that galaxy spectra can be represented\nin a compact low-dimensional space using autoencoders~\\citep[][Melchior \\&\nHahn, in prep.]{portillo2020}.\nIn \\cite{portillo2020}, they demonstrate that SDSS galaxy spectra can be\ncompressed into 7-dimensional latent variable space with little loss of\ninformation. \nSuch spectral compression dramatically reduces the dimensionality of the\nconditional variable space to dimensions that can be tackled by current ANPE\nmethods. \nWe will explore SED modeling of galaxy spectrophotometry using ANPE and\nspectral compression in a following work. \n", "meta": {"hexsha": "de84af37b9504f86162ca9a2242c703e86a42c55", "size": 6380, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/paper/summary.tex", "max_stars_repo_name": "changhoonhahn/SEDflow", "max_stars_repo_head_hexsha": "4561ecfe3a38cc4c25df263d971a87e8a83f88ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2022-03-16T03:11:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T16:01:42.000Z", "max_issues_repo_path": "docs/paper/summary.tex", "max_issues_repo_name": "changhoonhahn/SEDflow", "max_issues_repo_head_hexsha": "4561ecfe3a38cc4c25df263d971a87e8a83f88ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/paper/summary.tex", "max_forks_repo_name": "changhoonhahn/SEDflow", "max_forks_repo_head_hexsha": "4561ecfe3a38cc4c25df263d971a87e8a83f88ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.0, "max_line_length": 84, "alphanum_fraction": 0.7802507837, "num_tokens": 1456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120234, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.44914797425953534}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage{bm}% bold math\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{color}\n\\DeclareMathOperator{\\sgn}{sgn}\n\\renewcommand{\\thefootnote}{\\alph{footnote}}\n\n\\begin{document}\n\n\\subsection{Hessian Diagonalization}\n\nFrequencies and normal modes are obtained from Hessian diagonalization, following the method from {\\color{blue} https://tinyurl.com/4a75skfm}, which in turn uses (V. Barone, JCP, 2005, 122, 014108; V. Barone et al. IJQ. Chem., 2012, 112, 2185). Without projection frequencies and normal modes are just (transformed) eigenvalues and eigenvectors of the Hessian,\n\n\\begin{equation}\n\t\\mathsf{H} = \\begin{pmatrix}\n\t\t\\frac{\\partial^2 E}{\\partial x_1^2} & \\frac{\\partial^2 E}{\\partial x_1y_1} & \n\t\t\\frac{\\partial^2 E}{\\partial x_1z_1} & \\cdots\\\\\n\t\t\\frac{\\partial^2 E}{\\partial y_1x_1} & \\frac{\\partial^2 E}{\\partial y_1^2} & \n\t\t\\frac{\\partial^2 E}{\\partial y_1z_1} & \\cdots\\\\\n\t\t\\vdots & \\vdots & \\vdots & \\ddots\n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nappropriately mass weighted,\n\\begin{equation}\n\t\\mathsf{H}_\\text{w} = \\begin{pmatrix}\n\t\t\\frac{\\mathsf{H}_{11}}{\\sqrt{m_1 m_1}} & \\cdots & \\frac{\\mathsf{H}_{1,3i}}{\\sqrt{m_1 m_i}} & \\cdots \\\\\n\t\t\\vdots & \\vdots & \\vdots & \\ddots\n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nwhich is real symmetric so Hermitian ($\\mathsf{H} \\in \\mathbb{R}^{3N\\times3N}$ for a system of $N$ atoms). The frequencies are then square roots of the eigenvalues i.e. $\\nu_i = \\sqrt{\\lambda_i}$\\footnote{With an appropriate unit conversion.} and the normal modes $\\boldsymbol{s}_i$ where,\n\n\\begin{equation}\n\t\\mathsf{H}_\\text{w} = \\mathsf{S D S}^T \\quad ; \\quad \\mathsf{D} = \\begin{pmatrix}\n\t\t\\lambda_1 & 0  & \\cdots \\\\\n\t\t0 & \\lambda_2 & \\cdots \\\\\n\t\t\\vdots & \\vdots & \\ddots\n\t\\end{pmatrix}\n\t%\n\t\\quad ; \\quad\n\t%\n\t\\mathsf{S} = \\begin{pmatrix}\n\t\t\\uparrow & \\uparrow &  \\\\\n\t\t\\boldsymbol{s}_1 & \\boldsymbol{s}_2 & \\cdots \\\\\n\t\t\\downarrow & \\downarrow & \n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nTo project out translational and rotational motion for a non linear molecule requires a transformation of $\\mathsf{H}_\\text{w}$,\n\n\\begin{equation}\n\t\\mathsf{H}_\\text{w}' = \\mathsf{T}^T \\mathsf{H}_\\text{w} \\mathsf{T} \\qquad ; \\qquad \\mathsf{H}_\\text{w}' = \\begin{pmatrix}\n\t\t\\boldsymbol{0} & \\boldsymbol{0} \\\\\n\t\t\\boldsymbol{0} & \\bar{\\mathsf{H}}_\\text{w}\n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nwhere \n\\begin{equation}\n\t\\mathsf{T} = \\begin{pmatrix}\n\t\t\\uparrow & \\uparrow  & \\\\\n\t\t\\hat{\\boldsymbol{t}}_1 & \\hat{\\boldsymbol{t}}_2 & \\cdots \\\\\n\t\t\\downarrow & \\downarrow & \n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nand the columns of $\\mathsf{M}$ are,\n\n\\begin{equation}\n\t\\boldsymbol{t}_1 = \\begin{bmatrix}\n\t\t(\\hat{\\boldsymbol{e}}_1)_1 \\\\\n\t\t\\vdots \\\\\n\t\t(\\hat{\\boldsymbol{e}}_1)_N \\\\\n\t\\end{bmatrix}\n\t%\n\t\\quad ; \\quad \n\t%\n\t\\boldsymbol{t}_2 = \\begin{bmatrix}\n\t\t(\\hat{\\boldsymbol{e}}_2)_1 \\\\\n\t\t\\vdots \\\\\n\t\t(\\hat{\\boldsymbol{e}}_2)_N \\\\\n\t\\end{bmatrix}\n\t%\n\t\\quad ; \\quad \n\t%\n\t\\boldsymbol{t}_3 = \\begin{bmatrix}\n\t\t(\\hat{\\boldsymbol{e}}_3)_1 \\\\\n\t\t\\vdots \\\\\n\t\t(\\hat{\\boldsymbol{e}}_3)_N \\\\\n\t\\end{bmatrix}\n\\end{equation}\n\\\\\nwhere $\\hat{\\boldsymbol{e}}_k$ is a unit vector in 3D (i.e. $\\hat{\\boldsymbol{e}}_1 = (1, 0, 0)^T$). The rotation vectors are\n\n\\begin{equation}\n\t\\boldsymbol{t}_4 = \\begin{bmatrix}\n\t\t\\boldsymbol{e}_1 \\times \\boldsymbol{r}_1 \\\\\n\t\t\\vdots \\\\\n\t\t\\boldsymbol{e}_1 \\times \\boldsymbol{r}_N \\\\\n\t\\end{bmatrix}\n\t%\n\t\\quad ; \\quad \n\t%\n\t\\boldsymbol{t}_5 = \\begin{bmatrix}\n\t\t\\boldsymbol{e}_2 \\times \\boldsymbol{r}_1 \\\\\n\t\t\\vdots \\\\\n\t\t\\boldsymbol{e}_2 \\times \\boldsymbol{r}_N \\\\\n\t\\end{bmatrix}\n\t%\n\t\\quad ; \\quad \n\t%\n\t\\boldsymbol{t}_6 = \\begin{bmatrix}\n\t\t\\boldsymbol{e}_3 \\times \\boldsymbol{r}_1 \\\\\n\t\t\\vdots \\\\\n\t\t\\boldsymbol{e}_3 \\times \\boldsymbol{r}_N \\\\\n\t\\end{bmatrix}\n\\end{equation}\n\\\\\nwhere $\\boldsymbol{r}_i$ is the vector from the centre of mass of the system to the atom $i$. The remaining $\\boldsymbol{t}_n$ are filled with random vectors that are orthogonal to $\\boldsymbol{t}_1\\text{--}\\boldsymbol{t}_6$, which can be achieved by QR factorisation once the remaining elements of $\\mathsf{T}$ have been seeded with random numbers. Normalisation requires,\n\n\\begin{equation}\n\t\\hat{\\boldsymbol{t}}_i = \\frac{\\mathsf{M}^{1/2}\\boldsymbol{t}_i}{|\\mathsf{M}^{1/2}\\boldsymbol{t}_i|}\t\n\t%\n\t\\qquad ; \\qquad\n\t%\n\t\\mathsf{M} = \\begin{pmatrix}\n\t\tm_1 & 0 & 0 & 0 &\\cdots \\\\\n\t\t0 & m_1 & 0 & 0& \\cdots \\\\\n\t\t0 & 0 & m_1 & 0& \\cdots \\\\\n\t\t0 & 0 & 0 & m_2 & \\cdots \\\\\n\t\t\\vdots & \\vdots & \\vdots & \\vdots & \\ddots\n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nwhere $m_i$ is the mass of atom $i$.\n\n\\vspace{0.4cm}\n\nProjected frequencies are then obtained from the submatrix of $\\mathsf{H}_\\text{w}'$,\n\n\n\\begin{equation}\n\t\\bar{\\mathsf{H}}_\\text{w} = \\mathsf{\\bar{S} \\bar{D}\\bar{S}}^T \n\t%\n\t\\quad ; \\quad\n\t%\n\t\\bar{\\mathsf{S}} = \n\t\\begin{pmatrix}\n\t\t\\uparrow & \\\\\n\t\t\\bar{\\boldsymbol{s}}_7 & \\cdots \\\\\n\t\t\\downarrow &\n\t\\end{pmatrix}\n\t%\n\t\\quad ; \\quad\n\t%\n\t\\bar{\\mathsf{D}} = \n\t\\begin{pmatrix}\n\t\t\\bar{\\lambda}_7 &  0& \\cdots \\\\\n\t\t0 & \\bar{\\lambda}_8 & \\cdots \\\\\n\t\t\\vdots & \\vdots & \\ddots\n\t\\end{pmatrix}\n\\end{equation}\nwith $\\bar{\\nu}_{0\\text{--}6} = 0$ cm${}^{-1}$, while the eigenvectors are,\n\n\\begin{equation}\n\t\\boldsymbol{s}_i = \\mathsf{T}\\boldsymbol{s}_i'\n\t%\n\t\\quad ; \\quad\n\t%\n\t\\mathsf{S}' = \\begin{pmatrix}\n\t\t\\uparrow & \\\\\n\t\t\\boldsymbol{s}_1' & \\cdots\\\\\n\t\t\\downarrow &\n\t\\end{pmatrix}\n    = \n\t\\begin{pmatrix}\n\t\t\\boldsymbol{0} & \\boldsymbol{0} \\\\\n\t\t\\boldsymbol{0} & \\bar{\\mathsf{S}}\n\t\\end{pmatrix}\n\\end{equation}\n\\\\\nwhich correspond to the normal modes in the original coordinates. For a linear molecule the vibrational frequencies are then the $3N-5$ modes, rather than $3N-6$, with $\\mathsf{H}_w'$ contains a different number of non-zero entries.\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "ee2b0735cf5de58f7c05afc0ef5d115dac7228fc", "size": 5637, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "autode/common/hessians.tex", "max_stars_repo_name": "tlestang/autodE", "max_stars_repo_head_hexsha": "56fd4c78e7d7e78c5747428190211ff69dc6d94a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2020-03-13T15:03:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-14T13:41:04.000Z", "max_issues_repo_path": "autode/common/hessians.tex", "max_issues_repo_name": "skphy/autodE", "max_issues_repo_head_hexsha": "fd80995206ac601299d2f78105d0fe4deee8c2cf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 117, "max_issues_repo_issues_event_min_datetime": "2020-06-13T00:11:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T08:54:16.000Z", "max_forks_repo_path": "autode/common/hessians.tex", "max_forks_repo_name": "skphy/autodE", "max_forks_repo_head_hexsha": "fd80995206ac601299d2f78105d0fe4deee8c2cf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26, "max_forks_repo_forks_event_min_datetime": "2020-08-14T04:52:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T13:04:17.000Z", "avg_line_length": 29.359375, "max_line_length": 373, "alphanum_fraction": 0.6503459287, "num_tokens": 2254, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4491194199714217}}
{"text": "\n\\chapter{Proof Sketch}\n\\label{ch:sketch}\n\nThis chapter contains a high-level proof sketch to assist the reader while examining the comprehensive proof of \\TMmodelName{}.\nIt provides simplified versions of key definitions and theorems that cover a wide range of capability-based systems.\nThe use of mechanically manipulable specifications is eschewed in favor of familiar, hand-written mathematics.\nThe proof sketch starts by describing an abstract form of the model structures in \\TMmodelName{}.\nIt then presents the model semantics as state updates along with the potential for data motion.\nPossible system states and information flow that can happen within the system are defined inductively over sequences of these operations.\n\nThe first major theorem presented is the safety property from \\Cref{sect:intro:confinement}.\nThis is accomplished using a simplified structure of systems, the \\term{\\TMaccessGraph}, that reduces complexity to access between objects.\nUsing \\TMaccessGraphs{}, this sketch defines \\term{\\TMdirAcc} and \\term{\\TMpotAcc} as the access that is present in the system and that which maximally can be present in the future. \nFinally, it defines functions that conservatively approximate both direct and potential access over the model operations and uses these functions to demonstrate that the potential permissions for pre-existing objects never increases over the life of the system, a property called \\term{attenuating permissions}.\nBecause \\TMpotAcc{} is attenuating in \\TMmodelName{}, it consequently answers the safety question.\n\nThe confinement test does not examine the entire system, but only the capabilities to be placed in constructed subsystem.\nThe safety property provides an upper bound on permissions, but does not directly yield an upper bound on information flow.\nThe next major theorem demonstrates that potential access can produce a conservative approximation of potential information flow.\nThis proof opens with an inductive definition of what is \\term{\\TMmutated} in the system and defines a simple predicate for deciding what is \\term{\\TMmutable} using access graphs.\nIt then demonstrates that the actual mutation of the system is bounded by potential mutability and shows that potential mutability between existing objects can never increase.\nNext, this sketch introduces the confinement problem as a whole-system post-condition.\nFinally, it introduces a representation of the confinement property using \\TMaccessGraphs{} and demonstrate that if the post-condition is satisfied, the subsystem must be confined.\n\n\\section{System State}\n\n\\begin{figure}\n  \\centering\n    \\[\n    \\begin{array}{rcl}\n      \\NMaccessRights{} & \\equiv & \\{\\NMtx{} , \\NMwr{} , \\NMrd{} , \\NMwk{} \\} \\\\\n      \\NMcaps{} & \\equiv & \\NMrefs{} \\times \\NMaccessRightSet{} \\\\\n      \\NMobjs{}  & : & \\NMidxs{} \\rightarrow \\NMcaps{} \\\\\n      \\NMobjLabels{} & \\equiv & \\{\\NMunborn{} , \\NMalive{} , \\NMdead{}\\} \\\\\n      \\NMobjTypes{} & \\equiv & \\{\\NMactive{} , \\NMpassive{}\\} \\\\\n      \\NMsystemStates{} & : & \\NMrefs{} \\rightarrow \\NMobjs{} \\times \\NMobjLabels{} \\times \\NMobjTypes{}\n    \\end{array}\n    \\]\n  \\caption{Relevant definitions for \\TMsystemStates{}. \\label{fig:sketch:systemState}}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n    \\begin{tikzpicture}[auto]\n      \\matrix[column sep=30mm, row sep=15mm, ampersand replacement=\\&] (diagmatrix) {\n        \\node [objectUnborn] (e)   {\\(e\\)}; \\&\n        \\node [objectAlive] (a)  {\\(a\\)}; \\&\n        \\node [objectAlive] (b)  {\\(b\\)}; \\&\n        \\node [objectDead] (d) {\\(d\\)};\n        \\\\\n        \\node [subjectUnborn] (i)  {\\(i\\)}; \\&\n        \\node [subjectAlive] (f)  {\\(f\\)}; \\&\n        \\node [subjectAlive] (g)  {\\(g\\)}; \\&\n        \\node [subjectDead] (h)   {\\(h\\)};\n        \\\\[-15mm]  %% hack for creating a node for the next matrix.\n        \\node [invisSubject] (Bot) {};\n        \\\\\n      };\n\n      \\begin{scope}[yshift=-30mm] %% this is a hack.\n      \n        \\matrix[column sep=3mm, row sep=2mm, ampersand replacement=\\&]  {\n          \\node [invisObject, minimum size=5mm] (objectLabel) {\\NMpassive}; \\&\n          \\node [invisObject, minimum size=5mm] (subjectLabel)   {\\NMactive}; \\&\n          \n          \\\\\n          \\node [objectUnborn,minimum size=5mm] (unbornObject)  {}; \\&\n          \\node [subjectUnborn,minimum size=5mm] (unbornSubject)  {}; \\&\n          \\node [invisObject,minimum size=5mm] (unbornLabel) {\\NMunborn}; \\&\n          \\node [invisObject,minimum size=5mm] (leftValid) {}; \\&[+8mm]\n          \\node [invisObject,minimum size=5mm] (rightValid) {}; \\&\n          \\node [invisObject,minimum size=5mm] (validLabel) {valid capability};\n          \\\\\n          \\node [objectAlive,minimum size=5mm] (aliveObject)  {}; \\&\n          \\node [subjectAlive,minimum size=5mm] (aliveSubject)  {}; \\&\n          \\node [invisObject,minimum size=5mm] (aliveLabel) {\\NMalive}; \\&\n          \\node [invisObject,minimum size=5mm] (leftInvalid) {}; \\&[+8mm]\n          \\node [invisObject,minimum size=5mm] (rightInvalid) {}; \\&\n          \\node [invisObject,minimum size=5mm] (invalidLabel) {invalid capability};\n          \\\\\n          \\node [objectDead,minimum size=5mm] (deadObject)  {}; \\&\n          \\node [subjectDead,minimum size=5mm] (deadSubject)  {}; \\&\n          \\node [invisObject,minimum size=5mm] (deadLabel) {\\NMdead};\n          \\\\\n        };\n\n      \\end{scope}\n\n      \n      \\draw [capArrow] (a) edge [bend left=15] node[midway,above] {\\(\\{\\NMwk{}\\}\\)} node[very near start,above] {1} (b);\n      \\draw [capArrow] (a) edge [bend right=15] node[midway,below] {\\(\\{\\NMwk{},\\NMrd{}\\}\\)} node[very near start,below] {2} (b);\n      \\draw [capArrowInvalid] (a) edge [bend left=15] node[midway,below] {\\(\\{\\NMwk{},\\NMrd{},\\NMwr{}\\}\\)} node[very near start,below] {1} (e);\n      \n      \\draw [capArrow] (b) edge  node[midway,above,left] {\\(\\{\\NMrd{},\\NMwr{},\\NMtx{}\\}\\)} node[very near start,right] {1} (g);\n      \\draw [capArrowInvalid] (b) edge  node[midway,above] {\\(\\{\\NMrd{},\\NMtx{}\\}\\)} node[very near start,above] {2} (d);\n      \n      \\draw [capArrowInvalid] (e) edge [bend left=15] node[midway,above] {\\(\\{\\NMwk{},\\NMrd{}\\}\\)} node[very near start,above] {1} (a);\n      \n      \\draw [capArrowInvalid] (h) edge  node[pos=0.3,sloped] {\\(\\{\\NMwr{},\\NMtx{}\\}\\)} node[pos=0.05,sloped] {1} (b);\n\n      \\draw [capArrow] (leftValid) edge (rightValid);\n      \\draw [capArrowInvalid] (leftInvalid) edge (rightInvalid);\n    \\end{tikzpicture}\n  \\caption{Example system state. \\label{fig:sketch:exampleState}}\n\\end{figure}\n\n\nThe permission state of a capability-based system at any instant is modeled by a \\term{\\TMsystemState} in \\TMmodelName{}.\nA \\TMsystemState{} is represented as a finite map of finite maps defined in \\Cref{fig:sketch:systemState}.\nEach \\term{\\TMref} is mapped to an \\TMobj{}, \\TMobjLabel{}, and \\TMobjType{}; each \\term{\\TMobj} is a map from an \\TMidx{} to a \\TMcap{}.\nAn \\TMobj{}'s \\term{type} indicates whether it is a process or passive storage.\nAn \\TMobj{}'s \\term{label} captures a section of its life-cycle, which is permitted to transition only from \\NMunborn{} to \\NMalive{} and \\NMalive{} to \\NMdead{}.\n\\Term{\\TMidxs} label the cells within an object, which contain \\TMcaps{}.\nA \\term{\\TMcap} consists of a target \\TMref{} and a set of \\TMaccessRights{}.\n\nThe \\term{\\TMaccessRights} (or permissions) in the system are \\NMrd{}, \\NMwr{}, \\NMwk{}, and \\NMtx{}.\n\\xmakefirstuc{\\TMaccessRights} are checked as part of the preconditions for the semantic \\TMops{} in \\Cref{sect:sketch:semantics}.\nThe \\NMrd{} and \\NMwr{} permissions enable the ability to directly read or write information in the target.\nThe \\NMwk{} permission is a sub-type of the \\NMwk{} permission that authorizes transitive read-only authority.\nThe \\NMtx{} \\TMaccessRight{} authorizes message passing containing both \\TMcaps{} and data along with an optional reply capability.\n\n\\TMmodelName{} does not explicitly represent object data or intra-object computation.\nBecause all possible operation sequences will be analyzed, tracking which data are moving is unnecessary.\nThe model only tracks which objects could be \\emph{modified} by the motion of data.\n\nWhen diagramming a \\TMsystemState{}, the convention herein uses the shape of the \\TMobj{} to indicate the \\TMobjsType{} and style to represent life-cycle.\n\\xmakefirstuc{\\TMactive{}} \\TMobjs{} (processes) are circles and \\TMpassive{} storage \\TMobjs{} are squares.\n\\xmakefirstuc{\\TMobjs{}} with solid borders are \\NMalive{}, objects with dashed borders are \\NMunborn{}, and gray objects are \\NMdead{}.\n\\xmakefirstuc{\\TMcaps{}} are represented as arrows within the graph, each \\TMcap{} is labeled with their \\TMaccessRightSet{} along the arc center.\nFor clarity, \\TMcaps{} that are permitted structurally but which have no semantic interpretation are given a dashed line to differentiate them from semantically relevant \\TMcaps{}.\nThe \\TMidx{} at which each \\TMcap{} is stored is denoted along its arc close to the \\TMobj{}.\nAn example is included in \\Cref{fig:sketch:exampleState}.\n\n\\section{Semantics}\n\\label{sect:sketch:semantics}\n\nThe \\TMsystemState{} evolves by executing a sequence of \\term{\\TMops{}} through which data and \\TMcaps{} may flow.\nEach \\term{\\TMop} is defined in three parts: a precondition, a transformation of system state, and an upper bound on information flow.\n\\Cref{fig:sketch:preconditions} the preconditions that expresses the sanity requirements for each \\TMop{} to ensure safety.\nIn particular, processes can only specify the target of an \\TMop{} by invoking a \\TMcap{} at a specific \\TMidx{}.\nThese preconditions also check this \\TMcap{} for the presence of a necessary \\TMaccessRight{}, capturing an access control decision.\nTherefore, a \\TMsystemState{} transition and potential data flow occur only when the precondition is satisfied.\n\nThe operation state transitions are defined in \\Cref{fig:sketch:operations}.\nThe notation \\FNsingleOp{S}{op}{S'} indicates that executing \\(op\\) in \\TMsystemState{} \\(S\\) results in state \\(S'\\).\nExecuting a sequence of operations is represented by the notation \\(S_0 \\FNopTail{\\NMop_{m-1}}{S_{m-1}} \\FNopHead{\\NMop_m}{S_m}\\).\n\nInformation flow is modeled using the \\NMreadFrom{} and \\NMwroteTo{} functions defined in \\Cref{fig:sketch:flow}.\nDuring a successful operation, data may potentially flow from each of the objects in the \\NMreadFrom{} function to the objects named by \\NMwroteTo{}.\nWhile each operation varies with respect to its target, the model presumes that the \\TMacting{} subject of an \\TMop{} is always in the \\NMreadFrom{} set.\n\nOperations should be considered traces of system execution and do not represent system calls.\nFor example, in real systems, the \\term{\\TMsend{}} \\TMop{} contains a managed rendezvous between the sender and recipient.\nThe \\TMacting{} subject performing a \\TMsend{} \\TMop{} specifies which \\TMcaps{} and data should be transmitted, but the recipient indicates where they should be placed.\nAlso, processes in real systems do not choose, and cannot observe, which new object is allocated; the system selects it on their behalf.\n\n\\Cref{fig:sketch:helperFunctions} defines some commonly used functions, though the following have been omitted for brevity.\n\\NMmkCap{} constructs a new capability.\n\\NMcapTx{} inductively copies capabilities by examination of a list of \\TMidx{} pairs where the source is the first argument and the target is the second.\nEach operation has an \\TMacting{} subject, labeled \\(a\\) in the definitions, and is selected by the \\NMactor{} function.\nThe \\NMremoveCapsByRef{} function removes all capabilities naming a specific reference front the system and is used to sanitize the system before allocating an \\TMobj{}.\nMaps are sets and the notation \\mapsTo{k}{v}{M} indicates that \\(k\\) is mapped to \\(v\\) in map \\(M\\).\nWhen examining a map, an underscore ``\\ident{\\_}'' will indicate that the value is ignored.\nAn asterisk ``\\noident{*}'' used while updating a map leaves the previous value unaltered and map erasure is indicated using epsilon ``\\(\\epsilon\\)'' for the value.\n\nThese figures use many common symbols; the relevant ones are listed here.\n\\xmakefirstuc{\\TMrefs} are often labeled by a single character \\ident{o}, \\ident{a} when it is the reference to the acting object, or \\ident{n} for a new \\TMref{}.\nThe variables \\ident{src} and \\ident{tgt} are also used to denote \\TMrefs{} in appropriate contexts.\nThe \\TMobjs{} themselves are often simply \\ident{obj}, or \\ident{aObj} for the acting object.\nGeneric \\TMidxs{} are labeled \\ident{i}.\nWhen they identify the \\TMcap{} being invoked, they are labeled \\ident{t} as they name the target \\TMobj{}.\nWhen being accessed by the \\TMcap{} at \\ident{t}, they are also labeled \\ident{c}.\nMaps represented as lists of \\TMidx{} pairs are often represented by \\ident{m}, though later sections will use this for mutation.\n\\xmakefirstuc{\\TMsystemStates} are denoted by \\ident{S}, and \\TMaccessGraphs{} denoted by \\ident{I} and \\ident{A}.\n\\ident{P} often denotes a \\TMpotAccAG{} and \\ident{D} ranges over \\TMdirAccAGs{}.\n\n\\msdnote{Leters are updated.}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNhasRight{o}{i}{S}{r} & \\equiv & \\exists \\ident{obj}, \\mapsTo{o}{(\\ident{obj},\\ident{\\_} ,\\ident{\\_})}{S} \\wedge \\\\\n    & & \\exists \\ident{tgt},\\ident{arset}, \\mapsTo{i}{\\FNmkCap{\\ident{tgt}}{\\ident{arset}}}{\\ident{obj}} \\wedge \\\\\n    & & r \\in \\ident{arset} \\\\\n    \\FNisLabel{o}{S}{l} & \\equiv & \\mapsTo{o}{(\\ident{\\_} , l , \\ident{\\_})}{S} \\\\\n    \\FNisUnborn{o}{S} & \\equiv & \\FNisLabel{o}{S}{\\NMunborn} \\\\\n    \\FNisAlive{o}{S} & \\equiv & \\FNisLabel{o}{S}{\\NMalive} \\\\\n    \\FNisAlive{o}{S} & \\equiv & \\FNisLabel{o}{S}{\\NMdead} \\\\\n    \\FNisType{o}{S}{\\ident{typ}} & \\equiv & \\mapsTo{o}{(\\ident{\\_} , \\ident{\\_} , \\ident{typ})}{S} \\\\\n    \\FNisActive{o}{S} & \\equiv & \\FNisType{o}{S}{\\NMactive} \\\\\n    \\FNtargetIsAlive{o}{i}{S} & \\equiv & \\exists \\ident{obj}, \\mapsTo{o}{(\\ident{obj},\\ident{\\_} ,\\ident{\\_})}{S} \\wedge \\\\\n    & & \\exists \\ident{tgt}, \\mapsTo{i}{\\FNmkCap{\\ident{tgt}}{\\ident{\\_}}}{\\ident{obj}} \\wedge \\\\\n    & & \\FNisAlive{\\ident{tgt}}{S} \\\\\n    \\FNpreReqActor{a}{S} & \\equiv & \\FNisAlive{a}{S} \\wedge \\FNisActive{a}{S} \\\\\n    \\FNpreReqCommon{a}{t}{S} & \\equiv & \\FNpreReqActor{a}{S} \\wedge \\FNtargetIsAlive{a}{t}{S} \\\\\n    \\FNobjTarget{o}{t}{S} = \\ident{tgt} & \\iff & \\mapsTo{o}{(\\ident{obj},\\ident{\\_} ,\\ident{\\_})}{S} \\, \\wedge \\mapsTo{t}{\\FNmkCap{\\ident{tgt}}{\\ident{arset}}}{\\ident{obj}} \\\\\n    \\FNhasCap{\\ident{o}}{\\ident{cap}}{S} & \\equiv & \\mapsTo{o}{\\ident{obj}}{S} \\wedge \\exists i, \\mapsTo{i}{\\ident{cap}}{\\ident{obj}} \\\\\n    \\FNreplyCap{obj}{i}{o} & \\equiv & \\ident{obj}[i \\mapsto \\FNmkCap{o}{\\{\\NMtx\\}} ]\n  \\end{array}\n  \\]\n  \\caption{Helper functions. \\label{fig:sketch:helperFunctions}}\n\\end{figure}\n\n%% ident inserted this far.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNpreReq{\\FNread{a}{t}}{S} & \\equiv &  \\FNpreReqCommon{a}{t}{S} \\wedge \\\\\n    & & (\\FNhasRight{a}{t}{S}{\\NMrd} \\vee \\FNhasRight{a}{t}{S}{\\NMwk}) \\\\\n    \\FNpreReq{\\FNwrite{a}{t}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\FNhasRight{a}{t}{S}{\\NMwr} \\\\\n    \\FNpreReq{\\FNfetch{a}{t}{c}{i}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\\\\n    & & (\\FNhasRight{a}{t}{S}{\\NMrd} \\vee \\FNhasRight{a}{t}{S}{\\NMwk}) \\\\\n    \\FNpreReq{\\FNstore{a}{t}{c}{i}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\FNhasRight{a}{t}{S}{\\NMwr} \\\\\n    \\FNpreReq{\\FNrevoke{a}{t}{c}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\FNhasRight{a}{t}{S}{\\NMwr} \\\\\n    \\FNpreReq{\\FNdestroy{a}{t}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\FNhasRight{a}{t}{S}{\\NMwr} \\\\\n    \\FNpreReq{\\FNcreate{a}{n}{m}{\\ident{typ}}}{S} & \\equiv & \\FNpreReqActor{a}{S} \\wedge \\FNisUnborn{n}{S} \\\\\n    \\FNpreReq{\\FNsend{a}{t}{m}{x}}{S} & \\equiv & \\FNpreReqCommon{a}{t}{S} \\wedge \\FNhasRight{a}{t}{S}{\\NMtx} \\\\\n      \\FNweaken{\\FNmkCap{\\ident{tgt}}{\\ident{arset}}} & \\equiv & \\left\\{\n      \\begin{array}{rcl}\n        \\NMwk & | & \\{\\NMwk, \\NMrd\\} \\cap \\ident{arset} \\neq \\emptyset \\\\\n        \\emptyset & | & \\text{otherwise}\n      \\end{array}\n      \\right.\\\\\n  \\end{array}\n  \\]\n  \\caption{Operation preconditions. \\label{fig:sketch:preconditions}}\n\\end{figure}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rclll}\n    \\FNsingleOp{S}{\\FNread{a}{t}}{S'} & \\iff & \\multicolumn{3}{l}{S' = S} \\\\\n    \\FNsingleOp{S}{\\FNwrite{a}{t}}{S'} & \\iff & \\multicolumn{3}{l}{S' = S} \\\\\n    \\FNsingleOp{S}{\\FNfetch{a}{t}{c}{i}}{S'} & \\iff & \\multicolumn{3}{l}{\\mapsTo{a}{\\ident{aObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{t}{\\ident{tCap}}{\\ident{aObj}} \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{tgt} = \\FNobjTarget{a}{t}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{\\ident{tgt}}{\\ident{tObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{c}{\\ident{cap}}{\\ident{aObj}} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{cap'} = \\text{if } \\NMrd \\in \\ident{tCap} \\text{ then } \\ident{cap} \\text{ else } \\FNweaken{\\ident{cap}} \\, \\land} \\\\ \n    & & \\multicolumn{3}{l}{S' = S[\\ident{tgt} \\mapsto (\\ident{tObj}[i \\mapsto \\ident{cap'}],\\noident{*},\\noident{*} ]} \\\\\n    \\FNsingleOp{S}{\\FNstore{a}{t}{c}{i}}{S'} & \\iff & \\multicolumn{3}{l}{\\mapsTo{a}{\\ident{aObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{tgt} = \\FNobjTarget{a}{t}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{\\ident{tgt}}{\\ident{tObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{c}{\\ident{cap}}{\\ident{tObj}} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{S' = S[a \\mapsto (\\ident{aObj}[i \\mapsto \\ident{cap}],\\noident{*},\\noident{*}) ]} \\\\\n    \\FNsingleOp{S}{\\FNrevoke{a}{t}{c}}{S'} & \\iff & \\multicolumn{3}{l}{\\ident{tgt} = \\FNobjTarget{a}{t}{S} \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{\\ident{tgt}}{\\ident{tObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{S' = S[\\ident{tgt} \\mapsto (\\ident{tObj}[c \\mapsto \\epsilon],\\noident{*},\\noident{*}) ]} \\\\\n    \\FNsingleOp{S}{\\FNdestroy{a}{t}}{S'} & \\iff & \\multicolumn{3}{l}{\\ident{tgt} = \\FNobjTarget{a}{t}{S} \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{\\ident{tgt}}{\\ident{tObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{S' = S[\\ident{tgt} \\mapsto (\\noident{*},\\NMdead,\\noident{*})]} \\\\\n    \\FNsingleOp{S}{\\FNcreate{a}{n}{m}{\\ident{typ}}}{S'} & \\iff & \\multicolumn{3}{l}{S_{\\ident{clean}} = \\FNremoveCapsByRef{n}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{a}{\\ident{aObj}}{S_{\\ident{clean}}} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{newObj} = \\FNcapTx{\\ident{aObj}}{\\emptyset}{m} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{S' = S_{\\ident{clean}}[n \\mapsto (\\ident{newObj},\\NMalive,\\ident{typ})]} \\\\\n    \\FNsingleOp{S}{\\FNsend{a}{t}{m}{x}}{S'} & \\iff & \\multicolumn{3}{l}{\\mapsTo{a}{\\ident{aObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{tgt} = \\FNobjTarget{a}{t}{S} \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\mapsTo{\\ident{tgt}}{\\ident{tObj}}{S} \\, \\wedge} \\\\\n    & & \\multicolumn{3}{l}{\\ident{tObj1} = \\FNcapTx{\\ident{aObj}}{\\ident{tObj}}{m} \\, \\wedge} \\\\\n    \n    %% & & \\multicolumn{3}{l}{\n    %%   \\begin{array}{rcl}\n    %%     \\ident{tObj2} & = & \\text{if } x \\\\\n    %%     & & \\text{then } \\ident{tObj1}[x \\mapsto \\FNmkCap{a}{\\{\\NMtx\\}} ]\\\\\n    %%     & & \\text{else } \\ident{tObj1} \n    %%   \\end{array} } \\\\\n\n    & & \\multicolumn{3}{l}{\\ident{tObj2} = \\text{if } x \\text{ then } \\FNreplyCap{\\ident{tObj1}}{x}{a} \\text{ else } \\ident{tObj1} \\, \\land} \\\\ \n    \n    %% & & \\ident{tObj2} & = & \\text{if } x \\\\\n    %% & & & & \\text{then } \\ident{tObj1}[x \\mapsto \\FNmkCap{a}{\\{\\NMtx\\}} ]\\\\\n    %% & & & & \\text{else } \\ident{tObj1} \\\\\n    \n    & & \\multicolumn{3}{l}{S' = S[t \\mapsto (\\ident{tObj2},\\noident{*},\\noident{*})]} \\\\\n    \\textnormal{otherwise} & & \\\\\n    \\FNsingleOp{S}{\\ident{op}}{S'} & \\iff & S = S'\n  \\end{array}\n  \\]\n  \\caption{State transitions. \\label{fig:sketch:operations}}\n\\end{figure}\n\n\\begin{figure}\n  \\FIGflow{}\n  \\caption{Information flow. \\label{fig:sketch:flow}}\n\\end{figure}\n\nThe \\NMread{} and \\NMwrite{} operations model data reads and writes to an object and require the \\NMrd{} and \\NMwr{} access right, respectively.\nBecause non-self data motion is modeled by \\NMreadFrom{} and \\NMwroteTo{}, these operations have no impact on the system state.\n\\NMreadFrom{} contains the capability target for a read operation along with the invoking subject.\n\\NMwroteTo{} contains the capability target for a write operation or the invoking subject.\n\nThe \\NMfetch{} and \\NMstore{} operations model capability motion and have the same predicates and information flow properties as the \\NMread{} and \\NMwrite{} operations.\nThe difference is that \\NMfetch{} and \\NMstore{} operations read or write capabilities instead of data.\nThese operations update the system model by transferring a capability from or to the specified index in the target object.\nThe fetch operation has a special case when the capability contains the \\NMwk{} permission, but not the \\NMrd{} permission.\nIn this case, it is still possible to \\NMfetch{} a capability from the target, but the resulting capability will be \\TMweakened{} using the \\NMweaken{} function.\nA \\TMweakened{} capability has an \\TMaccessRightSet{} of \\{\\NMwk{}\\} only when the target capability has either the \\NMrd{} or \\NMwk{} right.\nThis has the effect of causing the \\NMwk{} \\TMaccessRight{} to enforce transitive read-only access.\n\nThe \\TMrevoke{} operation erases a mapping within an \\TMobj{}.\nBecause this is almost identical to overwriting an existing capability using \\NMstore{}, it requires the \\NMwr{} permission.\nThe \\NMwr{} access right also authorizes the \\TMdestroy{} operation as the \\TMactor{} may already overwrite all data and revoke all capabilities held by the target.\nBoth of these operations modify the target object adding them to the \\NMwroteTo{} set.\n\nThe \\NMcreate{} operation models new object allocation.\nAs allocation is modeled as part of the universal TCB, whether in the kernel or as an application, the \\NMcreate{} operation does not require a capability to perform.\nIt requires only that the object to be allocated is in the \\NMunborn{} state.\nDuring allocation, the allocator specifies the new object's initial data and capabilities, which is encoded using a pairwise map from source index to target index.\nAlthough the operation encodes which object is to be allocated, this is not considered visible to or within the control of the allocator.\nOnce allocated, the allocator receives a capability with total authority of the fresh object.\nThe information flow requirements add the allocated object to the \\NMwroteTo{} set.\n\nThe \\NMsend{} operation models the mechanism of communication and the protection extension mechanism.\nA capability with the \\NMtx{} \\TMaccessRight{} permits its holder to transmit a message containing both capabilities and data to the target, optionally fabricating a reply capability for use with client-server models.\nThe transfer is encoded as with the \\NMcreate{} operation.\nIn real system implementations, the system is expected to implement a rendezvous mechanism allowing the recipient to specified where the data and capabilities will be stored.\nAs \\NMsend{} transfers both data and capabilities, the target object is in the \\NMwroteTo{} set.\n\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNmutated{E}{S_0} & \\equiv & E \\\\\n    \\FNmutated{E}{S_0 \\FNopTail{\\NMop_{m-1}}{S_{m-1}} \\FNopHead{\\NMop_m}{S_m} } & \\equiv \\\\\n    \\multicolumn{3}{c}{\n      \\makebox[10 mm][l]{}\n      \\begin{array}{l}\n        \\text{let } M = \\FNmutated{E}{S_0 \\FNopTail{\\NMop_{m-1}}{S_{m-1}}} \\text{ in}\\\\\n        \\makebox[10 mm][l]{}\n        \\begin{array}{rcl}\n          M & | & \\text{if operation preconditions are not met} \\\\\n          M & | & \\text{if } E \\cap \\FNreadFrom{\\ident{op}}{S_{m-1}} = \\emptyset \\\\\n          M \\cup \\FNwroteTo{\\ident{op}}{S_{m-1}} & | & \\text{ otherwise}\n        \\end{array}\n      \\end{array}\n    }\n  \\end{array}\n  \\]\n  \\caption{Definition of \\NMmutated{}.\\label{fig:sketch:mutation}}\n\\end{figure}\n\nOperation sequences are simply executed sequentially over the system state.\nBecause operation preconditions preclude erroneous transitions, they can be composed automatically.\nTracking information flow through operation sequences is computed by the \\NMmutated{} function in \\Cref{fig:sketch:mutation}.\n\\NMmutated{} considers any subsystem to be self-mutating as a base case.\nFor each operation successfully performed, \\NMmutated{} increases what was \\TMmutated{} by the \\NMwroteTo{} set if the intersection of the \\NMreadFrom{} set and the mutated set are non-empty.\n\n\\section{Access Graphs and Potential Access}\n\n\\TMmodelName{} uses \\term{\\TMaccessGraphs} to reason about nearly all safety and information flow properties.\n\\xmakefirstuc{\\TMaccessGraphs} reduce \\TMsystemStates{} to access relations between \\TMobjs{}, representing multiple \\TMsystemStates{} simultaneously.\nStructurally, an \\term{\\TMaccessGraph} is simply a finite set of \\TMaccessEdges{}, each a triple in \\(\\NMrefs{} \\times \\NMrefs{} \\times \\NMaccessRights{}\\).\nThe access edge denoted \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} indicates that object \\ident{src} holds right \\ident{ar} to object \\ident{tgt}.\nAs the access graph is a set, each edge appears only once, collapsing the amount of redundant information.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{l}\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in \\FNdirAcc{S} \\iff \\\\\n    \\makebox[15 mm][l]{}\n    \\begin{array}{l}\n      \\FNisAlive{\\ident{src}}{S} \\wedge\n      \\exists \\ident{arset}, \\ident{ar} \\in \\ident{arset} \\wedge \\\\\n      \\FNhasCap{\\ident{src}}{\\FNmkCap{\\ident{tgt}}{\\ident{arset}}}{S} \\wedge \\\\\n      \\FNisAlive{\\ident{tgt}}{S})\n    \\end{array}\n  \\end{array}\n\\]\n\\caption{\\xmakefirstuc{\\TMdirAcc} graph. \\label{fig:sketch:dirAcc}}\n\\end{figure}\n\nA \\term{\\TMdirAccAG} is an \\TMaccessGraph{} representing the permission information of a specific \\TMsystemState{}.\nThe \\TMdirAccAG{} of a \\TMsystemState{} does not include \\TMcaps{} held by \\TMunborn{} or \\TMdead{} \\TMobjs{} as these \\TMcaps{} may not be transferred or invoked.\nThe \\TMdirAccAG{} function \\NMdirAcc{} is described by \\Cref{fig:sketch:dirAcc}.\n\n\\begin{figure} \n  \\[\n  \\FNtransfer{A}{B} \\iff\n  \\left\\{\n  \\begin{array}{rcl}\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in A & \\wedge & \\FNaddEq{\\mkEdge{\\ident{src}}{\\ident{src}}{\\ident{ar'}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in A & \\wedge & \\FNaddEq{\\mkEdge{\\ident{tgt}}{\\ident{tgt}}{\\ident{ar'}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in A & \\wedge & \\FNaddEq{\\mkEdge{\\ident{tgt}}{\\ident{tgt}}{\\ident{ar'}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\NMrd} \\in A & \\wedge &  \\mkEdge{\\ident{tgt}}{\\ident{tgt'}}{\\ident{ar}} \\in A  \\wedge \\\\\n    & & \\FNaddEq{\\mkEdge{\\ident{src}}{\\ident{tgt'}}{\\ident{ar}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\NMwr} \\in A & \\wedge & \\mkEdge{\\ident{src}}{\\ident{tgt'}}{\\ident{ar}} \\in A  \\wedge \\\\\n    & & \\FNaddEq{\\mkEdge{\\ident{tgt}}{\\ident{tgt'}}{\\ident{ar}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\NMtx} \\in A & \\wedge &  \\mkEdge{\\ident{src}}{\\ident{tgt'}}{\\ident{ar}} \\in A  \\wedge\\\\\n    & & \\FNaddEq{\\mkEdge{\\ident{tgt}}{\\ident{tgt'}}{\\ident{ar}}}{A}{B}  \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\NMtx} \\in A & \\wedge & \\FNaddEq{\\mkEdge{\\ident{tgt}}{\\ident{src}}{\\NMtx}}{A}{B} \\\\\n    \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\NMwk} \\in A & \\wedge &  \\mkEdge{\\ident{tgt}}{\\ident{tgt'}}{\\ident{ar}} \\in A  \\wedge \\\\\n    & & (\\ident{ar} = \\NMwk \\vee \\ident{ar} = \\NMrd) \\wedge \\\\\n    & & \\FNaddEq{\\mkEdge{\\ident{src}}{\\ident{tgt'}}{\\NMwk}}{A}{B}  \\\\\n  \\end{array}\n  \\right.\n  \\]\n  \\caption{\\NMtransfer{} definition. \\label{fig:sketch:trans}}\n\\end{figure}\n\n\\begin{figure}\n  \\[\n  \\FNpotTransfer{A}{C} \\iff\n  \\left\\{\n  \\begin{array}{l}\n  A = C \\\\\n  \\exists B, \\FNpotTransfer{A}{B} \\wedge \\FNtransfer{B}{C}\n  \\end{array}\n  \\right.\n  \\]\n  \\caption{\\xmakefirstuc{\\TMpotTransfer} definition. \\label{fig:sketch:potTransfer}}\n\\end{figure}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n      \\FNmaximal{P} & \\equiv & \\forall A, \\FNpotTransfer{P}{A} \\Rightarrow P = A \\\\\n      \\FNpotAcc{I}{P} & \\equiv & \\FNpotTransfer{I}{P} \\wedge \\FNmaximal{P}\n  \\end{array}\n  \\]\n  \\caption{\\xmakefirstuc{\\TMmaximal{}} and \\TMpotAcc{} \\label{fig:sketch:maximal}. \\label{fig:sketch:potAcc}}\n\\end{figure}\n\nThe next major goal is to define an upper bound on the worst-case authority present in an access graph that can be used when verifying properties about access and data motion.\nThe definition of worst-case authority is built on \\term{\\TMtransfer{}} in \\Cref{fig:sketch:trans}.\n\\Term{\\TMtransfer} is a micro-operation of permission transfer based on \\TMaccessGraphs{}.\nUnlike the operational semantics which operates at the granularity of whole capabilities, \\TMtransfer{} justifies a single permission transfer.\nIf \\(A\\) and \\(B\\) are access graphs, \\FNtransfer{A}{B} indicates that a permission transfer is possible from \\(A\\) to \\(B\\) through the addition of some edge.\nTwo access graphs related by any, potentially empty, sequence of transfer steps is defined by the \\term{\\TMpotTransfer} relation \\NMpotTransfer{} in \\Cref{fig:sketch:potTransfer}.\n\n\\xmakefirstuc{\\TMaccessGraphs} are related by \\NMtransfer{} based entirely on individual \\TMaccessRights{}.\nThe \\NMrd{} and \\NMwr{} \\TMaccessRight{} authorize edges to be transferred in opposite directions.\nSimilar to the \\NMrd{} case, the \\NMwk{} \\TMaccessRight{} is authorized to transfer a \\NMwk{} edge from a \\NMwk{} or \\NMrd{} edge.\nThe \\NMtx{} \\TMaccessRight{} behaves like the \\NMwr{} permission but includes a second case for constructing a reply.\nTo make \\NMtransfer{} a reflexive relation, two cases exist to permit self-targeting edges.\nThese cases require some other edge to refer to the \\TMobjs{} to prevent the addition of new \\TMrefs{} and keep analysis finite.\n\nIt is possible to construct a least upper bound between any two access graphs which share an initial access graph.\nGiven an initial access graph \\(I\\) and access graphs \\(A\\) and \\(B\\) such that \\FNpotTransfer{I}{A} and \\FNpotTransfer{I}{B}, there must exist an access graph \\(C\\) such that \\FNpotTransfer{A}{C} and \\FNpotTransfer{B}{C}.\n\\xmakefirstuc{\\TMtransfer{}} captures the ability to add a single edge using existing edges as justification.\nTherefore, for any access graph \\(C\\), the underlying justification is not altered by adding edges to \\(C\\).\n\\xmakefirstuc{\\TMtransfer{}} may be transposed with set addition: if \\FNtransfer{C}{D} and \\FNaddEq{x}{D}{E}, then \\FNaddEq{x}{C}{D'} and \\FNtransfer{D'}{E}.\nBecause \\NMtransfer{} and \\NMpotTransfer{} are non-decreasing, they are commutative.\nThe least upper bound is easily computed by set union, and all \\TMtransfers{} performed are still valid.\n\nFrom these definitions, each access graph must have a supremum by \\NMpotTransfer{}.\nThis \\term{\\TMpotAcc} graph is the worst-case approximation of access in an initial \\TMaccessGraph{}.\nDefined by \\NMpotAcc{} in \\Cref{fig:sketch:potAcc}, it is the \\TMaccessGraph{} that is reachable via \\NMpotTransfer{} and is \\NMmaximal{}.\nIf \\(I\\) is an initial access graph, then \\(P\\) is a potential access graph of \\(I\\) if and only if \\FNpotAcc{I}{P}.\nBecause all \\TMaccessGraphs{} have a \\TMmaximal{} access graph and have a least upper bound, any \\TMpotAcc{} graph must be the supremum.\nFrom set union over finite sets, it follows that all potential access graphs of \\(I\\) are unique.\n\n\\begin{figure}\n  \\[\\forall I, \\exists P, \\FNpotAcc{I}{P} \\]\n  \\caption{\\xmakefirstuc{\\TMpotAcc} always exists. \\label{fig:sketch:computePotAcc}}\n\\end{figure}\n\nComputing the \\TMpotAcc{} graph can be performed by induction over the \\term{\\TMcompleteAG}, the graph containing all possible edges given the \\TMrefs{} already present.\nBecause each \\TMtransfer{} adds edges between previously existing objects, it cannot exceed the \\TMcompleteAG{}.\nThe \\TMcompleteAG{} less the initial graph can be used as a work list when considering a new potential edge.\nExhaustively scanning this list for candidate edges, testing them with \\TMtransfer{}, and recursing on the resulting set will eventually produce the \\TMpotAcc{} graph.\nAs the set difference between the \\TMcompleteAG{} and the accumulator is always decreasing, this computation is guaranteed to eventually terminate.\n\\TMpotAcc{} it must always exist, as in \\Cref{fig:sketch:computePotAcc}, because it is computed by a function on \\(I\\).\nTherefore, the remainder of this sketch will use symbol \\NMpotAcc{} as both the computable function and the judgment.\n\n\nAnalysis in the remaining sections relies on the ability to preserve and reorder \\NMtransfer{}s with other approximating functions.\nBecause the family of \\NMtransfer{} functions are themselves additive, they can be transposed without loss of generality.\nThis provides a mechanism for describing different approaches to computing \\TMpotAcc{} with respect to related \\TMaccessGraphs{}.\n\n\\section{Access Approximations}\n\nAll \\TMops{} in \\TMmodelName{} have the potential to overwrite \\TMcaps{} and some delete them outright.\nComputing precise functions between direct and \\TMpotAccAGs{} describing these system states introduces complexity, so \\TMmodelName{} defines the concept of ``conservatively approximating'' functions.\nConservatively approximating functions must be composable so that they remain approximating inductively over multiple operations.\nThey must compose with set addition to permit \\TMtransfers{} to be reordered around them.\nThe graph in \\Cref{fig:sketch:directAccessApprox} illustrates this concept.\n\nTheorems of this sort are difficult to read, but easy to comprehend through illustration.\nIn access relationship graphs, functions are represented as arrows and relations as lines.\nSystem states are represented by squares with shadows and access graphs with circles with shadows.\n\n\\begin{figure}\n\\centering\n  \\FIGdirAccApprox{\\ident{op}}{\\ensuremath{F_{\\NMdirAcc}}}\n  \\begin{tikzpicture}[auto]\n    \\matrix[column sep=3mm, row sep=2mm, ampersand replacement=\\&]  {\n      \\node [system,minimum size=5mm] (sys)  {}; \\&\n      \\node [invisSystem,minimum size=5mm] (sysLabel) {\\TMsystemState}; \\&[+10mm]\n      \\node [invisSystem,minimum size=5mm] (leftRelation) {}; \\&[+8mm]\n      \\node [invisSystem,minimum size=5mm] (rightRelation) {}; \\&\n      \\node [invisSystem,minimum size=5mm] (relation) {relation};\n      \\\\\n      \\node [access,minimum size=5mm] (sysObject)  {}; \\&\n      \\node [invisSystem,minimum size=5mm] (unbornLabel) {\\TMaccessGraph}; \\&[+10mm]\n      \\node [invisSystem,minimum size=5mm] (leftCompRelation) {}; \\&[+8mm]\n      \\node [invisSystem,minimum size=5mm] (rightCompRelation) {}; \\&\n      \\node [invisSystem,minimum size=5mm] (compRelation) {computable relation};\n      \\\\\n    };\n\n    \\draw [rel] (leftRelation) edge (rightRelation);\n    \\draw [compRel] (leftCompRelation) edge (rightCompRelation);\n    \n  \\end{tikzpicture}\n\\caption{\\label{fig:sketch:directAccessApprox}Direct access approximation \\(F_{\\NMdirAcc{}}\\).}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\FIGpotAccApprox{\\ensuremath{F_{\\NMdirAcc}}}{\\ensuremath{F_{\\NMpotAcc}}}\n\\caption{\\label{fig:sketch:potentialAccessApprox}Potential access approximation \\(F_{\\NMpotAcc{}}\\).}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n  \\FIGfullApproxMath{}\n\\caption{\\label{fig:sketch:induction}Safety induction strategy.}\n\\end{figure}\n\nThe simplest approximation is one over \\TMdirAccAGs{}.\nA \\TMdirAcc{} approximation, \\(F_{\\NMdirAcc}\\), is a monotonically non-decreasing function between \\TMdirAccAGs{} indexed by \\TMop{} and initial \\TMsystemState{}.\nA \\TMpotAcc{} approximation is defined similarly over a \\TMdirAcc{} approximation, but with sufficient information to recover the initial \\TMsystemState{}\n\\Cref{fig:sketch:potentialAccessApprox} details the relationships visually.\nFrom these pieces, approximations for a sequence of operations can be assembled as shown in \\Cref{fig:sketch:induction}.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n  \\FNdirAccOp{S}{\\FNread{a}{t}} & \\equiv & \\idFunc \\\\\n  \\FNdirAccOp{S}{\\FNwrite{a}{t}} & \\equiv & \\idFunc \\\\\n  \\FNdirAccOp{S}{\\FNrevoke{a}{t}{i}} & \\equiv & \\idFunc \\\\\n  \\FNdirAccOp{S}{\\FNdestroy{a}{t}} & \\equiv & \\idFunc \\\\\n  \\FNdirAccOp{S}{\\FNfetch{a}{t}{c}{i}} & \\equiv & \\FNedgeTx{S}{\\FNobjTarget{a}{t}{S}}{a}{((c,i))} \\\\\n  \\FNdirAccOp{S}{\\FNstore{a}{t}{c}{i}} & \\equiv & \\FNedgeTx{S}{a}{\\FNobjTarget{a}{t}{S}}{((c,i))} \\\\\n  \\FNdirAccOp{S}{\\FNsend{a}{t}{m}{x}} & \\equiv & \\FNedgeTx{S}{a}{t}{m} \\circ \\FNreply{x}{a}{t} \\\\\n  \\FNdirAccOp{S}{\\FNcreate{a}{n}{m}{\\ident{typ}}} & \\equiv & \\FNedgeTx{S}{a}{n}{m} \\circ \\FNinsert{a}{n}\n  \\end{array}\n  \\]\n  when preconditions are satisfied, otherwise\n  \\[\n  \\FNdirAccOp{S}{\\ident{op}} \\equiv \\idFunc\n  \\]\n  with\n  \\[\n  \\idFunc(A) \\equiv A\n  \\]\n\\caption{\\xmakefirstuc{\\TMdirAccOp}. \\label{fig:sketch:drAccOp}}\n\\end{figure}\n\n\\Cref{fig:sketch:drAccOp} defines \\NMdirAccOp{}, the function approximating \\TMdirAccAGs{} over \\TMops{}.\nApproximations of worst-case authority do not need to consider the elimination of permissions;.\nTherefore, all \\TMops{} whose sole effect is to remove \\TMcaps{} are approximated by an identity function.\nThe other \\TMdirAcc{} approximations correspond directly to the potential additional \\TMaccessRights{} for each \\TMop{}.\n\nThe definition has omitted the simple functions \\NMedgeTx{}, \\NMreply{}, and \\NMinsert{}.\nIf \\mapsTo{a}{aObj}{S} and \\mapsTo{t}{tObj}{S}, then \\FNedgeTx{S}{a}{t}{m} adds \\TMaccessEdges{} corresponding to updating \\(tObj\\) as \\FNcapTx{aObj}{tObj}{m}.\nThat is, it examines \\(S\\) and adds edges to \\(a\\) corresponding to all capabilities in \\(t\\) at the indices in the first position in \\(m\\).\n\\NMreply{} is analogous to \\NMreplyCap{} and adds the edge \\mkEdge{a}{t}{\\NMtx} when \\(x\\) is \\ident{True}.\nThe \\FNinsert{a}{n} function adds the new \\TMobj{} \\(n\\) to the \\TMaccessGraph{} by adding all possible edges between \\(a\\) and \\(n\\).\n\n\\begin{figure}\n  when preconditions are satisfied:\n  \\[\n  \\begin{array}{rclr}\n  \\FNpotAccOpTwo{S}{\\FNcreate{a}{n}{m}{\\ident{typ}}}{P} & \\equiv & \\FNendow{a}{n} &\\\\\n  \\FNpotAccOpTwo{S}{op}{P} & \\equiv & P & \\text{for} \\; \\ident{op} \\neq \\NMcreate\n  \\end{array}\n  \\]\n  when preconditions are not satisfied:\n  \\[\n  \\FNpotAccOp{S}{\\FNcreate{a}{n}{m}{\\ident{typ}}} \\equiv \\idFunc\n  \\]\n  with\n  \\[\n  \\FNendow{a}{n} \\equiv \\NMcompPotAcc{} \\circ \\FNinsert{a}{n}\n  \\]\n\\caption{\\xmakefirstuc{\\TMpotAccOp}. \\label{fig:sketch:potAccOp}}\n\\end{figure}\n\nWith the exception of \\NMcreate{}, the other \\TMops{} are approximated by a function built from \\NMpotTransfer{}.\nThe special case to approximate the \\NMcreate{} operation cannot be modeled using \\NMpotTransfer{} because it adds a new object.\nThe \\NMendow{} function is defined to approximate \\NMcreate{} and is defined in two parts.\nFirst, \\NMendow{} invokes \\NMinsert{}, which adds all possible edges between parent and child.\nHaving accomplished this, it then computes \\NMpotAcc{} covering the all reflexive edges and any transfers that could occur.\n\\Cref{sect:sketch:projections} will discuss the relevance of \\NMendow{} in greater detail.\n\nAs \\TMpotAcc{} is the least upper bound over \\NMpotTransfer{}, each \\NMdirAccOp{} that is captured by \\TMpotTransfer{}, i.e. the non-\\TMallocate{} operations, may be approximated by an identity function over \\TMpotAcc{}.\nBecause the \\NMendow{} function recomputes \\TMpotAcc{}, it must approximate the \\TMcap{} copies during the \\NMcreate{} \\TMop{}.\nThis definition demonstrates that the only access not approximated by \\TMpotAcc{} occurs during object allocation.\n\n\\section{Projections and Safety}\n\\label{sect:sketch:projections}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{l}\n    \\FNprojectionTwo{a}{n}{P}{P'} \\equiv \\\\\n    \\makebox[10 mm][l]{}\n    \\begin{array}{l}\n      \\forall (\\ident{src}, \\ident{tgt}, \\ident{ar}), \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in P' \\iff \n      \\left\\{\n      \\begin{array}{l}\n        \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in P  \\\\\n        \\mkEdge{\\ident{src}}{a}{\\ident{ar}} \\in P \\wedge \\ident{tgt} = n \\\\\n        \\mkEdge{a}{\\ident{tgt}}{\\ident{ar}} \\in P \\wedge \\ident{src} = n \\\\\n        \\ident{src} = a \\in P \\wedge \\ident{tgt} = a \\\\\n        \\ident{src} = n \\in P \\wedge \\ident{tgt} = a \\\\\n        \\ident{src} = a \\in P \\wedge \\ident{tgt} = n \\\\\n        \\ident{src} = n \\in P \\wedge \\ident{tgt} = n \n      \\end{array}\n      \\right.\n    \\end{array}\n  \\end{array}\n  \\]\n  \\caption{Access graph projection. \\label{fig:sketch:projection}}\n\\end{figure}\n\n\n\\TMaccessGraph{} \\TMprojections{} define a mechanism describing how \\TMpotAccOps{} evolve with new objects. \n\\xmakefirstuc{\\TMendow} is the only non-trivial \\TMpotAccOp{}.\nConsider the result of fully connecting a fresh object to an existing one as in the case of \\NMendow{}.\nAny edges held by the original object might come to be be held by the allocated object through transmission.\nAdditionally, some edges originally targeting the allocating object might be added such that they target the fresh object.\nIt is also possible that new self-referential edges may come to exist, along with some other uninteresting corner cases.\nAny \\TMaccessGraph{} related by these properties is called a \\term{\\TMprojection}, using the \\NMprojection{} relation given in \\Cref{fig:sketch:projection}.\n\n\\begin{figure}\n  \\[\n  \\forall P, \\FNmaximal{P} \\Rightarrow \\FNprojectionTwo{a}{n}{P}{P'} \\Rightarrow \\FNendowTwo{a}{n}{P} \\subseteq P'\n  \\]\n  \\caption{Lemma: \\TMprojection{} approximates \\TMendow{}. \\label{fig:sketch:projectionEndow}}\n\\end{figure}\n\nThe lemma in \\Cref{fig:sketch:projectionEndow} states than an \\NMendow{} operation performed on a \\TMmaximal{} \\TMaccessGraph{} must form a \\TMprojection{}.\nThis proof requires a great degree of case analysis, but is conceptually very simple.\nConsider any access edge authorized by a \\TMtransfer{} after a \\TMprojection{}.\nThis edge must contain the child \\TMref{}, either as source or target.\nIf this were not the case, there must exist other edges in the graph prior to \\TMprojection{} which would authorize the new edge without the presence of the child.\nHowever, this graph was assumed to be \\TMmaximal{}, making this impossible.\nTherefore, \\NMendow{} is approximated by a \\TMprojection{} to the fresh object when operating on a \\TMmaximal{} \\TMaccessGraph{}.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{l}\n  \\forall S, P,  \\FNpotAcc{\\FNdirAcc{S}}{P} \\Rightarrow \\\\\n  \\forall E, (\\forall e \\in E, \\neg \\FNisUnborn{e}{S}) \\Rightarrow \\\\\n  \\forall e \\in E \\Rightarrow \\\\\n  \\forall o \\notin E \\Rightarrow \\\\\n  \\forall P', \\FNprojectionTwo{e}{o}{P}{P'} \\Rightarrow\\\\\n  \\FNrestrict{P'}{E} \\subseteq P\n  \\end{array}\n  \\]\n  \\caption{Attenuating authority for capability systems. \\label{fig:sketch:safety}}\n\\end{figure}\n\nFinally, the safety property can be described using \\TMpotAcc{} through \\TMprojection{}.\nThe safety decision is initially determined by \\TMpotAcc{}.\nAs the system is not in a position to know the relationships that new objects will have, it cannot determine what access they may come to hold.\nHowever, the existence of all new objects can be approximated via \\TMprojection{}.\nProjection only adds edges which relate the system to new objects, leaving all existing \\TMpotAcc{} unchanged.\nThe \\FNrestrict{P}{E} operation eliminates all edges in \\(P\\) with both elements not in \\(E\\) and is used to compare pre-existing relationships.\nThe \\TMpotAcc{} of the system is preserved for all existing relationships and remains maximal over the life of the system.\nThis property, stated formally in \\Cref{fig:sketch:projectionEndow}, is called \\term{attenuating authority} and represents a decision to the safety problem for capability-based systems.\n\n\\section{Mutability}\n\nThe definition of the \\term{\\TMconfinementTest} for object-capability systems relies upon a decision over permissions, not over information flow.\nTo reason about security policies expressed using permissions, it must be the case that permissions are representative of information flow.\nSurprisingly, this is not true for most systems \\cite{HRU1976}.\nHowever, this property does hold for object-capability systems satisfying \\TMmodelName{}.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{l}\n    \\FNmutableTwo{E}{A} \\equiv \\\\\n    \\{ m | \\exists e \\in E \\wedge (\n    \\mkEdge{m}{e}{\\NMwk} \\in A \\vee\n    \\mkEdge{m}{e}{\\NMrd} \\in A \\vee\n    \\mkEdge{e}{m}{\\NMwr} \\in A \\vee\n    \\mkEdge{e}{m}{\\NMtx} \\in A )\n    \\}\n    \\end{array}\n  \\]\n  \\caption{Definition of \\TMmutable{}. \\label{fig:sketch:mutable}}\n\\end{figure}\n\n\nThe definition \\NMmutable{} in \\Cref{fig:sketch:mutable} determines the objects where information in a given subsystem might flow.\nIt is computed by induction over the edges of an access graph.\nObjects are \\NMmutable{} by a subsystem in three cases.\nIn the base case, the subsystem is self-mutating and is included in \\NMmutable{}.\nSecond, writing or transmitting data push information out of the subsystem, so any target of a \\NMwr{} or \\NMtx{} edges held by an element of the subsystem is \\NMmutable{}.\nFinally, any object holding \\NMrd{} or \\NMwk{} edges to a member of the subsystem can pull information out of the subsystem.\nBecause \\NMmutable{} is parameterized over any access graph, it is applied to the direct access or potential access of a system to produce respective meaning.\nThe terms \\term{\\TMdirMutability} and \\term{\\TMpotMutability} describe the \\TMmutability{} of \\TMdirAcc{} or \\TMpotAcc{} graphs.\n\n\\Term{\\TMmutable} preserves subset variance with both the subsystem and with the \\TMaccessGraph{}.\nThough not formally presented, these variance properties form the basis for most approximations of \\TMmutability{} in the rest of this sketch.\n\n\\begin{figure}\n  \\[\n  \\FNpotAcc{\\FNdirAcc{S_0}}{P} \\Rightarrow \\FNmutated{E}{S_0 \\FNopTail{\\NMop_m}{S_m} } \\subseteq \\FNmutableTwo{E}{P} \\cap \\FNextant{S_0}\n  \\]\n  where\n  \\[\n  \\FNextant{S} \\equiv \\{o | \\FNisAlive{o}{S} \\wedge \\FNisDead{o}{S} \\}\n  \\]\n  \\caption{Theorem: mutable approximates mutated. \\label{thm:sketch:mutableSubset}}\n\\end{figure}\n\nFor \\NMmutable{} to be meaningful, it must satisfy the theorem in \\Cref{thm:sketch:mutableSubset}.\nThis theorem states that what is \\TMmutated{}\\footnote{Recall \\Cref{fig:sketch:mutation}} by a subsystem over any execution, when restricted to initially \\TMextant{} objects, is conservatively approximated by what is \\TMpotMutable{} from the initial configuration.\nNaively, this would be directly satisfiable by induction.\nAll objects require a \\TMcap{} for data motion.\nThese \\TMcaps{} are conservatively approximated by \\TMdirAcc{}, which in turn is conservatively approximated by \\TMpotAcc{}.\nThe \\TMcreate{} operation is safe because each \\TMprojection{} only extends the allocator's \\TMmutability{} into the child.\n\n\\newcommand{\\nodetiny}[1]{\\small #1}\n\n\\begin{figure}\n\\centering\n    \\begin{tikzpicture}[auto]\n      \\matrix[column sep=10mm, row sep=10mm, ampersand replacement=\\&]{\n        \\node [system]     (S0)                  {\\nodetiny \\(S_0\\)}; \\&\n        \\node [access]     (I0)      {\\nodetiny \\(I_0\\)}; \\&\n        \\node [access]     (I0')     {\\nodetiny \\(I_0'\\)}; \\&\n        \\node [access]     (P0)     {\\nodetiny \\(P_0\\)}; \\&\n        \\node [access]     (P0')    {\\nodetiny \\(P_0'\\)}; \\&[+15mm]\n        \\node [mutable]    (M0)     {\\tiny \\(M_0\\)};\n        \\\\\n        \\node [invisSystem]     (Sd)     {\\nodetiny \\(\\dots\\)}; \\&\n        \\node [invisSystem]     (Id)      {\\nodetiny \\(\\dots\\)}; \\&\n        \\node [invisSystem]     (Id')     {\\nodetiny \\(\\dots\\)}; \\&\n        \\node [invisSystem]     (Pd)     {\\nodetiny \\(\\dots\\)}; \\&\n        \\node [invisSystem]     (Pd')     {\\nodetiny \\(\\dots\\)}; \\&\n        \\node [invisMutable]    (Md)     {\\tiny \\(\\dots\\)};\n        \\\\\n        \\node [system]     (S1)     {\\nodetiny \\(S_{N-1}\\)}; \\&\n        \\node [access]     (I1)      {\\nodetiny \\(I_{N-1}\\)}; \\&\n        \\node [access]     (I1')    {\\nodetiny \\(I_{N-1}'\\)}; \\&\n        \\node [access]     (P1)   {\\nodetiny \\(P_{N-1}\\)}; \\&\n        \\node [access]     (P1')    {\\nodetiny \\(P_{N-1}'\\)}; \\&\n        \\node [mutable]    (M1)      {\\tiny \\(M_{N-1}\\)};\n        \\\\                    \n        \\node [system]     (SN)     {\\nodetiny \\(S_N\\)}; \\&\n        \\node [access]     (IN)     {\\nodetiny \\(I_N\\)}; \\&\n        \\node [access]     (IN')    {\\nodetiny \\(I_N'\\)}; \\&\n        \\node [access]     (PN)    {\\nodetiny \\(P_N\\)}; \\&\n        \\node [access]     (PN')     {\\nodetiny \\(P_N'\\)}; \\&\n        \\node [mutable]    (MN)       {\\tiny \\(M_{N}\\)};\n        \\\\\n      };\n\n      \\draw [compRel] (S0) edge node[midway,above] {\\tiny \\NMdirAcc} (I0);\n      \\draw [rel] (I0) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (I0');\n      \\draw [compRel] (I0') edge node[midway,above] {\\tiny \\(F^g\\)} (P0);\n      \\draw [rel] (P0) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (P0');\n      \\draw [compRel] (P0') edge node[midway,above] {\\tiny \\(\\NMmutable(E)\\)} (M0);\n\n      \\draw [compRel] (S0) edge node[midway,left] {\\tiny \\(\\ident{op}_{1}\\)}  (Sd);\n      \\draw [compRel] (I0') edge node[midway,left] {\\tiny \\(\\NMdirAccOp_{1}\\)} (Id');\n      \\draw [compRel] (P0') edge node[midway,left] {\\tiny \\(F^{p}_{1}\\)} (Pd');\n      \\draw [compRel] (M0) edge node[midway,left] {\\tiny \\(\\FNmutableInd{S_0}{\\ident{op}_1}\\)} (Md);\n\n      \\draw [compRel] (S1) edge node[midway,above] {\\tiny \\NMdirAcc} (I1);\n      \\draw [rel] (I1) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (I1');\n      \\draw [compRel] (I1') edge node[midway,above] {\\tiny \\(F^g\\)} (P1);\n      \\draw [rel] (P1) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (P1');\n      \\draw [compRel] (Sd) edge node[midway,left] {\\tiny \\(\\ident{op}_{N-1}\\)}  (S1);\n      \\draw [compRel] (Id') edge node[midway,left] {\\tiny \\(\\NMdirAccOp_{N-1}\\)} (I1');\n      \\draw [compRel] (Pd') edge node[midway,left] {\\tiny \\(F^{p}_{N-1}\\)} (P1');\n      \\draw [compRel] (P1') edge node[midway,above] {\\tiny \\(\\NMmutable(M_{N-2})\\)} (M1);\n      \\draw [compRel] (Md) edge node[midway,left] {\\tiny \\(\\FNmutableInd{S_{N-1}}{\\ident{op}_{N-1}}\\)} (M1);\n      \n      \\draw [compRel] (SN) edge node[midway,above] {\\tiny \\NMdirAcc} (IN);\n      \\draw [rel] (IN) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (IN');\n      \\draw [compRel] (IN') edge node[midway,above] {\\tiny \\(F^g\\)} (PN);\n      \\draw [rel] (PN) edge node[midway,above] {\\tiny \\(\\subseteq\\)} (PN');\n      \\draw [compRel] (S1) edge node[midway,left] {\\tiny \\(\\ident{op}_N\\)}  (SN);\n      \\draw [compRel] (I1') edge node[midway,left] {\\tiny \\(\\NMdirAccOp_N\\)} (IN');\n      \\draw [compRel] (P1') edge node[midway,left] {\\tiny \\(F^p_N\\)} (PN');\n      \\draw [compRel] (PN') edge node[midway,above] {\\tiny \\(\\NMmutable(M_{N-1})\\)} (MN);\n      \\draw [compRel] (M1) edge node[midway,left] {\\tiny \\(\\FNmutableInd{S_{n}}{\\ident{op}_{n}}\\)} (MN);\n\n      \n    \\end{tikzpicture}\n\\caption{Definition of \\TMmutableInd{}. \\label{fig:sketch:mutableInd}}\n\\end{figure}\n\nThe naive approach is hiding a subtle induction problem.\nIt relies on the safety property for its inductive explanation of why \\NMmutable{} was not exceeded by \\NMmutated{}.\nHowever, the inductive definition of computing \\NMmutable{} does not match the inductive definition of \\NMmutated.\n\\Cref{fig:sketch:mutableInd} defines an inductive definition of \\NMmutable{}, \\NMmutableInd{}, matching the induction of \\NMmutated{}.\nThis inductive specification of what is \\TMmutable{} must always conservatively approximate what is \\TMmutated{}.\nPotential inductive mutability only grows by the newly allocated object exactly when the parent is in the inductively mutable subsystem.\nBy distributing intersection across union, all objects that were not initially \\TMextant{} are excluded from this set.\nTherefore, the static definition of \\NMmutable{} conservatively approximates \\TMmutation{} over the life of the system.\n\n\\section{Subsystem Refinements}\n\nThe definition of subsystems heretofore has been a simple set of object references.\nThis is convenient, as many proofs do not rely upon any information about the form of a subsystem.\nHowever, this general definition is insufficient for the confinement test as real subsystems are necessarily more constrained.\nThis proof sketch defines two additional predicates of subsystems in addition to the confinement test.\n\n\\begin{figure}\n  \\[ \\FNextantSub{S}{E} \\equiv E \\subseteq \\FNextant{S} \\]\n  \\caption{Extant subsystems.\\label{fig:sketch:extant}}\n\\end{figure}\n\nThe semantics do not make any guarantees about the allocation relationships of \\TMunborn{} \\TMobjs{}.\nAny \\TMunborn{} \\TMobj{} might be legally allocated as part of an \\TMallocate{} \\TMop{} and subsequently become the child of any other \\TMobj{}.\nThe inclusion of \\TMunborn{} \\TMobjs{} in a subsystem can inadvertently link two otherwise independent subsystems through an allocation, as is the case in the SW model\\cite{ShapiroWeber2000}.\nRather than make assumptions about where new objects will arise, subsystems are restricted consisting of only \\TMalive{} or \\TMdead{} objects.\nThese subsystems are called \\term{\\TMextantSubs} and are defined in \\Cref{fig:sketch:extant}.\n\n\\begin{figure}\n  \\[\n  \\FNconstrSub{S}{E} \\equiv \\forall \\mapsTo{\\ident{src}}{(\\ident{obj},\\ident{\\_},\\ident{\\_})}{S} , \\mapsTo{i}{\\FNmkCap{\\ident{tgt}}{\\ident{\\_}}}{\\ident{obj}} \\wedge \\ident{tgt} \\in E \\Rightarrow \\ident{src} \\in E\n  \\]\n  \\caption{\\xmakefirstuc{\\TMconstrSubs}. \\label{fig:sketch:constructive}}\n\\end{figure}\n\nSince the \\TMconfinementTest{} is always performed before subsystem construction, the subsystem cannot have yet interacted with the system in any way.\nAdditionally, the constructor is obligated to revoke its authority to the newly fabricated subsystem and must not have passed it on elsewhere.\nThe definition in \\Cref{fig:sketch:constructive} generalizes this concept to extend beyond the trusted constructor, requiring that there must not exist a capability held outside the subsystem that names an element within the subsystem.\nThese subsystems are called \\term{\\TMconstrSubs} as they arise naturally from construction.\n\n\\section{Confinement}\n\\label{sect:sketch:confinement}\n\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNauthorizedSet{C}{E} & \\equiv & \\forall \\FNmkCap{\\ident{tgt}}{\\ident{\\_}} \\in C \\Rightarrow \\ident{tgt} \\notin E \\\\\n    \\FNconfinementTest{S}{E}{C} & \\equiv & \\forall e \\in E , \\mapsTo{e}{\\ident{eObj}}{S} , \\mapsTo{\\ident{\\_}}{\\FNmkCap{\\ident{tgt}}{\\ident{arset}}}{\\ident{eObj}} \\Rightarrow \\\\\n    & & \\FNmkCap{\\ident{tgt}}{\\ident{arset}} \\in C \\vee \\\\\n    & & \\ident{arset} = \\emptyset \\vee \\\\\n    & & \\ident{tgt} \\in E \\vee \\\\\n    & & \\neg \\FNisAlive{\\ident{tgt}}{S} \\vee \\\\\n    & & \\ident{tgt} \\notin E \\wedge \\ident{arset} = \\{\\NMwk\\}\n  \\end{array}\n  \\]\n  \\caption{Confinement predicates.  \\label{fig:sketch:confinementTest}}\n\\end{figure}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNconfinedSub{S}{E}{C} & \\equiv & \\FNauthorizedSet{C}{E} \\wedge \\\\\n    & & \\FNextantSub{S}{E} \\wedge \\\\\n    & & \\FNconstrSub{S}{E} \\wedge \\\\\n    & & \\FNconfinementTest{S}{E}{C}\n  \\end{array}\n  \\]\n  \\caption{Confinement definition.   \\label{fig:sketch:confinedSub}}\n\\end{figure}\n\nA subsystem is confined exactly when all outward information flow is authorized.\nThat is, regardless of the actual structure of the subsystem, all potential outward information flow is derived by \\TMcaps{} in the \\term{\\TMauthorizedSet}.\nThis sketch embeds the confinement test as a post-condition on the system, but it should be noted that this test can be performed by previous conditions and local inspection.\nIn addition to being \\TMextant{} and \\TMconstructive{}, the \\TMauthorizedSet{} of capabilities must not target elements of \\(E\\) and the \\TMconfinementTest{} must pass.\nThe \\TMconfinementTest{} in \\Cref{fig:sketch:confinementTest} is almost a direct transcription of the constructor's confinement test from \\Cref{sect:constructor:constructor}, without the case admitting recursively confined constructors.\nThe complete definition of a confined subsystem is given in \\Cref{fig:sketch:confinedSub}.\n\nTo describe \\TMconfinement{} as a system property, this proof sketch defines how the \\TMauthorizedSet{} of capabilities comes to authorize information flow.\nA \\term{fully authorized subsystem} is one in which all objects hold: 1) fully permissive \\TMcaps{} to all \\TMobjs{} in the \\TMsubsystem{} and 2) all of the authorized set of \\TMcaps{}.\nThe confinement proof proceeds by fixing the subsystem set \\(E\\) before considering subsystems with varied sets of \\TMobjs{}.\nRather than choosing a canonical subsystem, confinement is described using access graphs.\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNfullAuthAG{A}{E}{C} & \\equiv & \\FNcompleteAG{E} \\cup \\\\\n    & & \\FNauthAG{E}{C} \\cup \\\\\n    & & \\FNrestrict{A}{\\FNagNodes{A} - E}\n  \\end{array}\n  \\]\n  with\n  \\[\n  \\begin{array}{rcl}\n    \\FNauthAG{E}{C} & \\equiv & \\{ \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} | \\ident{src} \\in E \\wedge \\FNmkCap{\\ident{src}}{\\ident{arset}} \\in C \\wedge \\ident{ar} \\in \\ident{arset} \\}\\\\\n    \\FNagNodes{A} & \\equiv & \\{ a | \\mkEdge{a}{\\ident{\\_}}{\\ident{\\_}} \\in A \\vee \\mkEdge{\\ident{\\_}}{a}{\\ident{\\_}} \\in A \\} \\\\\n  \\end{array}\n  \\]\n  \\caption{The \\TMfullAuthAG{}. \\label{fig:sketch:fullAuthAG}}\n\\end{figure}\n\nThe \\term{\\TMfullAuthAG} represents all fully authorized subsystems with the same collection of \\TMobjs{} constructed from an initial \\TMsystemState{}.\nGiven an \\TMaccessGraph{}, \\NMfullAuthAG{} in \\Cref{fig:sketch:fullAuthAG} returns an \\TMaccessGraph{} where \\(E\\) is fully connected, all elements of \\(E\\) contain the authorized set of \\TMalive{} objects, and the edges in the original \\TMaccessGraph{} are restricted to elements not in \\(E\\).\nThis last clause, performed by the \\NMrestrict{} function, removes all edges where either the source or target are not elements of an approved set of \\TMrefs{}\n\n\\begin{figure}\n  \\[\n  \\begin{array}{rcl}\n    \\FNagSimplyConfined{E}{P_{\\ident{base}}}{P_{\\ident{conf}}} & \\equiv & P_{\\ident{base}} \\subseteq P_{\\ident{conf}} \\wedge \\\\\n    & & ( \\forall \\mkEdge{\\ident{src}}{\\ident{tgt}}{\\ident{ar}} \\in (P_{\\ident{conf}} - P_{\\ident{base}}), \\ident{src} = \\ident{tgt} \\vee \\\\\n    & & \\ident{ar} = \\NMwk \\wedge \\ident{src} \\in E \\wedge \\ident{tgt} \\notin E )\\\\\n    \\FNagConfined{E}{P_{\\ident{base}}}{P_{\\ident{conf}}} & \\equiv & P_{\\ident{base}} \\subseteq P_{\\ident{conf}} \\wedge \\\\\n    & & (\\forall \\mkEdge{\\ident{src}}{\\ident{tgt}}{ar} \\in (P_{\\ident{conf}} - P_{\\ident{base}}), \\ident{src} = \\ident{tgt} \\vee \\\\\n    & & \\ident{ar} = \\NMwk \\wedge \\FNexFlow{P}{E}{\\ident{src}} \\wedge \\neg \\FNexFlow{P}{E}{\\ident{tgt}})\n    \\\\\n    \\text{with}\\\\\n    \\\\\n    \\FNexFlow{A}{o}{s} & \\equiv & s \\in \\FNmutableTwo{A}{\\{o\\}}\n  \\end{array}\n  \\]\n\\caption{\\xmakefirstuc{\\TMagConfined}. \\label{fig:sketch:agConfined}}\n\\end{figure}\n\nThe \\TMconfinementTest{} is lifted to \\TMaccessGraphs{} as \\NMagSimplyConfined{} in \\Cref{fig:sketch:agConfined}.\nConfinement permits more access than is authorized, but ensures that this access creates no additional information flow.\nFor \\TMaccessGraphs{}, it is stated as a comparison between a \\term{base} \\TMaccessGraph{} and a \\term{confined} \\TMaccessGraph.\nThe base \\TMaccessGraph{} is a subset of the confined \\TMaccessGraph{} and restricts which additional edges are in the confined \\TMaccessGraph{}.\nBy inspection, a \\TMfullAuthAG{} resulting from the \\TMdirAcc{} of a \\TMsystemState{} with a confined subsystem \\(E\\) will satisfy \\NMagSimplyConfined{} over the same parameters.\n\nUnfortunately, computing \\TMpotAcc{} on a simply confined \\TMaccessGraph{} will not preserve \\NMagSimplyConfined{}.\nThe more general predicate \\NMagConfined{} solves this problem.\n\\NMagConfined{} subsumes \\NMagSimplyConfined{} and is also preserved through \\TMpotTransfers{}, and ultimately \\TMpotAcc{}.\nThe definition of \\NMagConfined{} relies on the definition of \\NMexFlow{}, which captures the existence of point-wise mutability.\nWhen the base \\TMaccessGraph{} is the \\TMpotAccAG{} of a \\TMfullAuthAG{}, all authorized information flow has been captured by \\NMmutable{}.\nTherefore, \\NMagConfined{} preserves mutability by restricting which edges may be added to the confined \\TMaccessGraph{}.\nIt requires that all edges not in the base \\TMaccessGraph{} must be \\NMwk{} edges where there exists an information flow from the confined subsystem to the edge source and there are no flows from the confined subsystem to the edge target, or the edge is impotently self-targeting.\nBy case analysis, the mutability of these two \\TMaccessGraphs{} must be identical.\n\n\\begin{figure}[h]\n\\centering\n    \\FIGconfinementLemmaMath{}\n\\caption{Visualization of the confinement lemma \\label{fig:sketch:confinement-lemma}}\n\\end{figure}\n\nThe overall proof of confinement is visually described in \\Cref{fig:sketch:confinement-lemma}.\nThe top row illustrates the computation of the potential mutability of a \\TMsystemState{} with subsystem \\(E\\) confined to authorized set \\(C\\).\nLikewise, the bottom row describes the computation of the potential mutability of the \\TMfullAuthAG{} \\(A\\).\nThese computations are related by the middle row with values that preserve information flow satisfying confinement.\n\nThe relationships between the bottom and middle rows form the majority of the confinement verification.\nThe right-most property has already been described in the description of \\NMagConfined{}.\nGiven, \\FNagConfined{P_{\\ident{base}}}{P_{\\ident{conf}}}, the mutability of \\(P_{\\ident{base}}\\) and \\(P_{\\ident{conf}}\\) are identical.\nThe left-most property can be validated directly from previous theorems.\nFirst, as previously mentioned, \\NMagSimplyConfined{} is subsumed by \\NMagConfined{}.\nSecond, all \\TMaccessEdges{} valid for \\NMtransfer{} in the base are also valid in the confined \\TMaccessGraph{}.\nTherefore, these edges may be added to \\(I\\) to produce a valid \\TMpotTransfer{} to \\(I'\\).\nBy inspection, adding any \\TMaccessEdge{} to both the base and confined access graph preserves \\NMagConfined{}.\nConsequently, \\NMagConfined{} must also hold in this specific case.\n\nOnce the base \\TMaccessGraph{} is \\TMmaximal{}, the middle triangle becomes solvable.\nThe definition of \\NMagConfined{} only permits new \\NMwk{} edges that don't create new information flow.\nIntuitively, \\NMwk{} edges only propagate other \\NMwk{} edges in \\NMtransfer{}.\nWhen initially constrained by \\NMagConfined{}, the \\NMtransfer{} case for \\NMwk{} edges can not violate \\NMagConfined{}.\nTherefore, \\NMagConfined{} with a maximal base \\TMaccessGraph{} must hold while computing the \\TMpotAcc{} of the confined \\TMaccessGraph{}.\n\nHaving discharged the bottom row, the relationship between the top row and the middle row is demonstrated by subset variance.\nSimply choosing \\(I = D \\cup A\\) will satisfy both \\(D \\subseteq I\\) and \\FNagSimplyConfined{E}{A}{I}.\nWith this initial condition, \\NMpotAcc{} preserves subset relationships which are then preserved by \\NMmutable{}.\n\nTherefore, any subsystem \\(E\\) passing the \\TMconfinementTest{} is confined to the \\TMfullAuthAG{}.\nWhen the \\TMconfinementTest{} succeeds, all outward information flow that is possible from the yield at the moment allocation occurs is the sole consequence of the capabilities provided in the authorized set.\n\nThough not formally presented in this sketch, the confinement proof can be extended to cover any set of objects.\nAs \\(E\\) varies, the \\TMmutability{} of two fully authorized access graphs does not change with respect to \\(E\\), provided \\(E\\) does not include additional objects originally extant in the underlying system state.\nTherefore, the choice of \\(E\\) is irrelevant and all possible subsystems are confined.\n\n\n", "meta": {"hexsha": "fd1eafbd8d49064b287c8cf6503b98208c164778", "size": 63433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-sketch.tex", "max_stars_repo_name": "doerrie/dissertation", "max_stars_repo_head_hexsha": "7696128aadd65332194836dd989ee7ce9128ac14", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-20T15:33:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-20T15:33:23.000Z", "max_issues_repo_path": "ch-sketch.tex", "max_issues_repo_name": "doerrie/dissertation", "max_issues_repo_head_hexsha": "7696128aadd65332194836dd989ee7ce9128ac14", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch-sketch.tex", "max_forks_repo_name": "doerrie/dissertation", "max_forks_repo_head_hexsha": "7696128aadd65332194836dd989ee7ce9128ac14", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.5299586777, "max_line_length": 311, "alphanum_fraction": 0.6914697397, "num_tokens": 19182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4491194134876732}}
{"text": "\\subsubsection{Dynamic Stratification} \\label{dyn-strat}\n\nOne of the most important formulations of stratification is that of\n{\\em dynamic} stratification.  \\cite{Przy89d} shows that a program has\na 2-valued well-founded model iff it is dynamically stratified, so\nthat it is the weakest notion of stratification that is consistent\nwith the well-founded semantics.\n%\n%As presented in~\\cite{Przy89d}, dynamic stratification computes strata\n%via operators on \\emph{3-valued interpretations} -- pairs of the form\n%$\\langle Tr;Fa \\rangle$, where $Tr$ and $Fa$ are subsets of the Herbrand\n%base $\\cH_P$ of a normal program $P$.\nAs presented in~\\cite{Przy89d}, dynamic stratification computes strata\nvia operators on interpretations of the form $\\langle Tr;Fa \\rangle$,\nwhere $Tr$ and $Fa$ are subsets of $\\cH_P$.\n%\n%-----------------------------------------------------------------------\n\\begin{definition} \\label{def:dyn-ops}\nFor a normal program $P$, sets $Tr$ and $Fa$ of ground atoms and a\n3-valued interpretation $I$ (sometimes called a pre-interpretation):\n\\begin{description} \\item[$True^P_I(Tr) =$]\n%                $\\{A:val_I(A) \\neq {\\tt t}$\n    $\\{A|A$ is not true in $I$;  and \n                        there is a clause\n                        $B \\leftarrow L_1,...,L_n$\n                in $P$, a grounding substitution $\\theta$ such that\n                $A = B\\theta$ and for every $1 \\leq i \\leq n$ either\n                $L_i\\theta$ is true in $I$, or $L_i\\theta \\in Tr$\\};\n  \\item[$False^P_I(Fa) =$] \n%$\\{A : val_I(A) \\neq {\\tt f}$ \n$\\{A|A$ is not false in $I$; and for every\n    clause $B \\leftarrow L_1,...,L_n$ in $P$ and grounding substitution\n    $\\theta$ such that $A = B\\theta$ there is some $i$ $(1 \\leq i \\leq\n    n)$ such that $L_i\\theta$ is false in $I$ or $L_i\\theta \\in Fa\\}$.\n\\end{description}\n\\end{definition}\n%------------------------------------------------------------------------()     \n%\n\\cite{Przy89d} shows that $True^P_I$ and $False^P_I$ are both\nmonotonic, and defines $\\kcaltrue^P_I$ as the least fixed point of $True^P_I(\\emptyset)$\nand $\\calfalse^P_I$ as the greatest fixed point of\n$False^P_I(\\cH_P)$.\n%\\footnote{Below, we will sometimes omit the program $P$ in\n%  these operators when the context is clear.}.\n%, along with an\n%operator $\\cal I$ that assigns to every interpretation $I$ of $P$ a\n%new interpretation ${\\cal I}(I) = I \\cup \\langle \\cT_I ; \\cF_I \\rangle$.\n%\nIn words, the operator $\\kcaltrue^P_I$ extends the interpretation $I$ to add\nthe new atomic facts that can be derived from $P$ knowing $I$; $\\calfalse^P_I$\nadds the new negations of atomic facts that can be shown false in $P$\nby knowing $I$ (via the uncovering of unfounded sets).  An iterated\nfixed point operator builds up dynamic strata by constructing\nsuccessive partial interpretations as follows.\n%----------------------------------------------------------------------          \n\\begin{definition}[Iterated Fixed Point and Dynamic Strata]\n\\label{def:IFP}\nFor a normal program $P$ let \n\n\\begin{center}\n$  \\begin{array}{rcl}\n          WFM_0 & = & \\langle \\emptyset ; \\emptyset \\rangle;      \\\\\n WFM_{\\alpha+1} & = &       WFM_{\\alpha} \\cup\n                                \\langle \\kcaltrue^P_{WFM_\\alpha};\\calfalse^P_{WFM_\\alpha} \\rangle; \\\\\n     WFM_\\alpha & = & \\bigcup_{\\beta < \\alpha} WFM_\\beta, \\mbox{ for limit ordinal }\\alpha.\n  \\end{array}\n$\n\\end{center}\n\n\\noindent\n  $WFM(P)$ denotes the fixed point interpretation $WFM_\\delta$,\n  where $\\delta$ is the smallest (countable) ordinal such that both\n  sets $\\kcaltrue^P_{WFM_\\delta}$ and $\\calfalse^P_{WFM_\\delta}$ are empty.\n%($\\delta$ exists, and is\n%  a countable ordinal because both $\\kcaltrue_I$ and $\\calfalse^P_I$ are monotonically\n%  increasing).  \n% We refer to $\\delta$ as the {\\em depth} of program $P$.  \nThe {\\em stratum} of atom $A$, is the least ordinal $\\beta$ such that\n   $A \\in WFM_{\\beta}$.\n% (where $A$ may be either in the true or false\n%   component of $WFM_{\\beta}$).\n\\end{definition}\n%------------------------------------------------------------------------()      \n%\n\\cite{Przy89d} shows that %the iterated fixed point \n$WFM(P)$ is in fact the well-founded model and that any undefined\natoms of the well-founded model do not belong to any stratum --\ni.e. they are not added to $WFM_{\\delta}$ for any ordinal\n$\\delta$. Thus, a program is \\emph{dynamically stratified} if every\natom belongs to a stratum.\n\n%------------------------------------------------------------------------\n% taking out fixed-order stuff until we put LPADs in (though maybe we\n% wont even need it then )\n\n%\\input{fixed-order-dynstrat}\n", "meta": {"hexsha": "7118b5a416a4b135240df8011573757b570a16f2", "size": 4603, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/paper/dynstrat.tex", "max_stars_repo_name": "theresasturn/plow", "max_stars_repo_head_hexsha": "0999214f33d71413ed9a029eb9dccbf4e6d35dbb", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-03-26T21:41:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-03T22:22:06.000Z", "max_issues_repo_path": "docs/paper/dynstrat.tex", "max_issues_repo_name": "theresasturn/plow", "max_issues_repo_head_hexsha": "0999214f33d71413ed9a029eb9dccbf4e6d35dbb", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/paper/dynstrat.tex", "max_forks_repo_name": "theresasturn/plow", "max_forks_repo_head_hexsha": "0999214f33d71413ed9a029eb9dccbf4e6d35dbb", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-01-23T15:26:21.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-23T15:26:21.000Z", "avg_line_length": 47.4536082474, "max_line_length": 101, "alphanum_fraction": 0.6224201608, "num_tokens": 1324, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.44911940700392455}}
{"text": "\\documentclass[]{article}\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\n%opening\n\\title{Modeling and Implementing a simple Heat-Convection}\n\\author{Florian Nikos Kitzka}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThe aim of this document is to provide a simple guide how to create and implement a model for a heat-convection problem. The approach is to start from underlying physics to arrive at model-equations and then to explain difficulties arising during implementation. Basic knowledge of Analysis and Linear Algebra as well as some understanding of \nFluid Dynamics is required. Chapters are written quite independent of each other so that the reader\ncan skip parts in which no interest exists. Numerical treatment of Fluid Dynamic is a very challenging and fascinating area. This text tries to transfer the basic ideas but leaves out many details which can be found in more specialized literature.\n\\end{abstract}\n\n\\tableofcontents\n\n\\section{Simulation Target}\nWe consider a room of cubical shape.\\\\\nWe assume all walls except the bottom to allow transfer of air (open walls).\\\\\nThe bottom is assumed to be heated at a constant temperature.\\\\\nOur goal is to simulate how this heat is being transferred through the room over time.\n\n\\includegraphics{setup}\n\n\\section{Creation of Model} \\label{model_creation}\nThere are two main mechanism of heat transfer in nature. One is diffusion the other is advection. We will shortly explain these two mechanisms and how to incorporate this into a model.\\\\\n\\subsection{Heat Diffusion}\nConsider a small volume $V$ with edge length $\\Delta x$. We denote the temperature at the left surface by $T_L$ and at the right surface by $T_R$. Then Fourier's law states the heat-flux through left surface is\n\\begin{equation} \\label{heat_flux_left}\nI(x_0)=-\\lambda\\frac{\\partial T}{\\partial x}(x_0)\n\\end{equation}\nand through right surface is\n\\begin{equation} \\label{heat_flux_right}\nI(x_1)=-\\lambda\\frac{\\partial T}{\\partial x}(x_1)\n\\end{equation}\n$I$ is the amount of heat-energy passing per unit of time through unit of area.\nThe coefficient $\\lambda$ depends on the material and is called thermal conductivity.\nFurthermore each material which is added heat-energy is changing its temperature according to\n\\begin{equation*}\nc_p \\Delta T=\\Delta q\n\\end{equation*}\n$q$ denotes the heat-energy per unit of mass and $c_p$ which is dependent on the material is the specific heat capacity. By using the density $\\rho$ we can rewrite this as\n\\begin{equation} \\label{specific_heat}\nc_p \\Delta T=\\frac{1}{\\rho V} \\Delta Q\n\\end{equation}\nwhere $Q$ denotes the total heat energy added to the volume $V$.\nAnalogous consideration as done in (\\ref{heat_flux_left}) and (\\ref{heat_flux_right}) can be made for all other surfaces. That is, each surface\ncontributes either positive or negative depending on the direction of flux to the internal change of heat energy per unit of time.\nWe can formulate this by\n\\begin{equation*}\n\\Delta Q = A\\Delta t \\sum_{j}-I_{j}(x_{j}+\\Delta x)+I_{j}(x_{j})\n\\end{equation*}\nwhere $A$ denotes the area of a surface, $I_{j}(x_j)$ the heat-flux through surface $S_j$\nand $I_{j}(x_j+\\Delta x)$ the heat-flux through the opposite surface in $V$. Summation is carried out only over the three surfaces which span the volume.\nBy setting $A=V/\\Delta x$ and using equations (\\ref{heat_flux_left}) we obtain\n\\begin{equation*}\n\\rho c_p V\\Delta T = \\lambda A\\Delta t\\sum_{j}\\frac{\\partial T}{\\partial x_j}(x_j+\\Delta x)-\\frac{\\partial T}{\\partial x_j}(x_j)\n\\end{equation*}\nBy using $V/A=\\Delta x$ this equation is equivalent to\n\\begin{equation*}\n\\rho c_p \\frac{\\Delta T}{\\Delta t} = \\frac{\\lambda}{\\Delta x}\\sum_{j}\\frac{\\partial T}{\\partial x_j}(x_j+\\Delta x)-\\frac{\\partial T}{\\partial x_j}(x_j)\n\\end{equation*}\nFinally be letting $\\Delta x\\rightarrow 0$ we find the heat-diffusion equation\n\\begin{equation}\n\\frac{\\partial T}{\\partial t}=\\frac{\\lambda}{\\rho\\alpha}\\Delta T\n\\end{equation}\nNote: here $\\Delta T$ refers to the Laplace operator ($\\Delta T=\\nabla\\cdot\\nabla T$).\n\n\\subsection{Advection}\nAdvection describes the mechanism a physical property to be transported by a bulk movement. In our example the bulk movement is presented by the wind and the physical property is either momentum or heat.\\\\\nWe consider the same volume $V$ as in previous section and denote the physical (scalar) property by $\\phi$. Here $\\phi$ shall be given per unit of mass. In addition we denote by $\\textbf{v}$ the current velocity field. At the left surface let us consider the normal directed velocity component $v_x$. During the interval $\\Delta t$ we have a displacement of mass by\n\\begin{equation} \\label{displacement}\n\\xi_{x}=v_x\\Delta t\n\\end{equation} \nThus the net balance of mass flowing into and out of $V$ through the left and right surface is\n\\begin{equation} \\label{net_flow}\n-\\rho A\\cdot\\xi_{x+\\Delta x} \\cdot \\phi(x+\\Delta x)+\\rho A\\cdot\\xi_{x} \\cdot \\phi(x)\n\\end{equation}\nwhich by using (\\ref{displacement}) becomes\n\\begin{equation*}\n-\\rho A\\cdot  v_{x+\\Delta x}\\cdot\\Delta t \\cdot \\phi(x+\\Delta x)+\\rho A\\cdot  v_{x}\\cdot\\Delta t \\cdot \\phi(x)\n\\end{equation*}\nBy 'adding a zero' we can rewrite this as\n\\begin{align*}\n&-\\rho A\\cdot v_{x+\\Delta x}\\cdot\\Delta t \\cdot \\phi(x+\\Delta x) \\\\ &+\n\\rho A\\cdot v_{x}\\cdot\\Delta t \\cdot \\phi(x+\\Delta x) -\n\\rho A\\cdot v_{x}\\cdot\\Delta t \\cdot \\phi(x+\\Delta x) \\\\ &+\n\\rho A\\cdot v_{x}\\cdot\\Delta t \\cdot \\phi(x)\n\\end{align*}\nFurther by gathering terms\n\\begin{align*}\n&\\rho A\\cdot (v_{x}-v_{x+\\Delta x})\\cdot\\Delta t \\cdot \\phi(x+\\Delta x) +\n\\rho A\\cdot v_{x}\\cdot\\Delta t \\cdot (\\phi(x)-\\phi(x+\\Delta x))\n\\end{align*}\nBy using $A=V/\\Delta x$ we can write this as\n\\begin{align*}\n&\\rho V \\frac{v_{x}-v_{x+\\Delta x}}{\\Delta x}\\cdot\\Delta t \\cdot \\phi(x+\\Delta x) +\n\\rho V v_{x}\\cdot\\Delta t\\frac{\\phi(x)-\\phi(x+\\Delta x)}{\\Delta x}\n\\end{align*}\nBy letting $\\Delta x\\rightarrow 0$ we obtain\n\\begin{equation*}\n-\\rho \\phi(x)\\Delta t\\cdot V\\frac{\\partial v_x}{\\partial x}\n-\\rho v_x\\Delta t\\cdot V \\frac{\\partial \\phi}{\\partial x}(x)\n\\end{equation*}\nThe same consideration can be done in $y$ and $z$ direction and by adding all these net balances we obtain as net change of $\\phi$\n\\begin{equation*}\n\\rho V \\Delta \\phi =\n-\\rho V \\Delta t\\phi(x)\\left(\\frac{\\partial v_x}{\\partial x} \n+\\frac{\\partial v_y}{\\partial y}+\\frac{\\partial v_z}{\\partial z}\\right)\n -\\rho V \\Delta t \\left(v_x \\frac{\\partial \\phi}{\\partial x}+\n v_y \\frac{\\partial \\phi}{\\partial y}+\n +v_z \\frac{\\partial \\phi}{\\partial z}\\right)\n\\end{equation*}\nDividing by $\\rho V \\Delta t$ and letting $\\Delta t\\rightarrow 0$, we obtain\n\\begin{equation} \\label{transp_equation}\n\\frac{\\partial\\phi}{\\partial t}=-\\phi\\nabla\\cdot\\textbf{v} -\\textbf{v}\\cdot\\nabla\\phi\n\\end{equation}\nNote, in very generic contexts one also takes the change of density into account, but here we will assume the density to be a global constant.\nAlso for our needs it will suffice to assume incrompressibility , that is, $\\nabla\\cdot\\textbf{v}=0$. It expresses in essence that all mass flowing into the volume must flow out somewhere else.\n\nWe can now use this equation to express transport of heat-energy. Heat-energy and temperature are \nrelated by $c_p T=u$ where $u$ denotes the inner energy. So what in fact is transported is $u$ and by inserting we get\n\\begin{equation} \\label{transp_heat}\n\\frac{\\partial T}{\\partial t}=-\\textbf{v}\\cdot\\nabla T\n\\end{equation}\nSince the moment applies into all three directions we have to consider as $\\phi$ separately all components of velocity, $v_x, v_y, v_z$. This gives a set of three equation which we can write compactly as\n\\begin{equation}\n\\frac{\\partial\\textbf{v}}{\\partial t}=-\\textbf{v}\\cdot\\nabla\\textbf{v}\n\\end{equation}\n\n\\subsection{Momentum Sources}\nIn reality many forces a acting on our considered volume. For simplicity we restrict our attention buoyancy. This force always arises when\na region of warmer fluid is surrounded by colder fluid. It only applies in vertical direction and\ncan be formulated in terms of an acceleration as\n\\begin{equation}\n\\textbf{F}_{B}=g\\frac{T-T_{A}}{T_{A}}\\textbf{e}_{z}\n\\end{equation}\nHere $g$ denotes the gravity acceleration and $T_A$ the surrounding temperature.\nNote, in our implementation we will assume this $T_A$ is just given by the temperature above\nthe considered grid-point.\n\\subsection{Final Model}\n\nA final very simplified model looks like this\n\\begin{align} \n\\frac{\\partial T}{\\partial t}&=-\\textbf{v}\\cdot \\nabla T + \\frac{k}{\\rho\\alpha}\\Delta T \\label{model_equations} \\\\\n\\frac{\\partial v_{z}}{\\partial t}&=g\\frac{T-T_{A}}{T_{A}}-v_{z}\\frac{\\partial v_{z}}{\\partial z} \\nonumber\n\\end{align}\n\nAlthough we could restrict computation on dimension 1 we will do it for dimension 2 in order to\nget more inside into the techniques used.\n\n\n\\section{Numerical Scheme}\nIn order to solve the model equations (\\ref{model_equations}) numerically we are going to use the so called Finite Difference Method. This requires to lay a fixed grid over our domain (the room) and replace all derivative expressions by discrete approximations.\\\\\nAs we have seen in section \\ref{model_creation}, physical properties like\nheat and momentum are transported by diffusion and advection processes.\\\\\nOur goal is to provide a generic scheme for both processes.\nHereby we are going to consider both processes independent of each other and restrict\nattention to the 1-dimensional case. It will turn out later that this treatment is already\nsufficient for the final implementation.\\\\\nA small remark on our assumed incompressibility condition ($\\nabla\\cdot\\textbf v=0$): Actually after each time-iteration it must be ensured this property to be withhold. Usually this is done by adjusting the pressure ('pressure correction'). But, in order to simplify things we will just skip this part.\n\n\\subsection{Derivative Approximations} \\label{derivate_approx}\nThe main method to obtain approximations for derivatives is by using Taylor expansion.\nWe give a detailed description for one specific derivative expression but leave the remaining for the reader since they are produced in analogy.\\\\\nAlso, for reasons becoming clear later, we restrict our attention to 1-dimensional functions.\nConsider the two Taylor expansions,\n\\begin{equation*}\nu(x+h)=u(x)+u'(x)h+\\frac{1}{2}u''(x)h^2+o(2)\n\\end{equation*}\n\\begin{equation*}\nu(x-h)=u(x)-u'(x)h+\\frac{1}{2}u''(x)h^2+o(2)\n\\end{equation*}\nBy adding both equations we obtain\n\\begin{equation*}\nu(x+h)+u(x-h)=2u(x)+u''(x)h^2\n\\end{equation*}\nBy solving the later for $u''(x)$ we get a second-order approximation for the second derivative\nof $u$.\n\\begin{equation*} \nu''(x)=\\frac{1}{h^2}(u(x+h)+u(x-h)-2u(x)) + o(2)\n\\end{equation*}\n\nFor the numerical treatment we have to consider $u$ discrete in space and time.\nWe define \n\\begin{equation*}\nu_{i}^{n}=u(t_{n}, x_{i})\n\\end{equation*}\nor in case of 2-dimensions\n\\begin{equation*}\nu_{i,j}^{n}=u(t_{n}, x_{i}, y_{j})\n\\end{equation*}\n\nWith this we can now easily list the approximations we are going to use, especially the one\nwe just obtained for second-order derivatives.\n\n\\begin{eqnarray}\n\t\\left[\\frac{\\partial u}{\\partial t}\\right]_{i}^{n} & \\approx \\frac{1}{\\Delta t}(u_{i}^{n+1}-u_{i}^{n}) \\nonumber  \\\\\n\t\\left[\\frac{\\partial u}{\\partial x}\\right]_{i}^{n} & \\approx \\frac{1}{\\Delta x}(u_{i}^{n}-u_{i-1}^{n})  \\label{backward_in_space} \\\\\n\t\\left[\\frac{\\partial u}{\\partial x}\\right]_{i}^{n} & \\approx \\frac{1}{\\Delta x}(u_{i+1}^{n}-u_{i}^{n}) \\label{forward_in_space}  \\\\\n\t\\left[\\frac{\\partial^2 u}{\\partial x^2}\\right]_{i}^{n} & \\approx\n\t\\frac{1}{\\Delta x^2}(u_{i-1}^{n}-2u_{i}^{n}+u_{i+1}^{n}) \\nonumber\n\\end{eqnarray}\n\nFor first derivative we have provided two approximations, (\\ref{forward_in_space}) is called\nforward in space and (\\ref{backward_in_space}) is called backward in space.\n\nNote, we only present a small selection of possible ways to approximate derivatives. In  this text we only focus on so called explicit schemes, but the reader should be made aware that there exists another important category of so called implicit schemes.\n\n\\subsection{Advection Scheme}\n\nIn general advaction processes have the form\n\\begin{equation*}\n\\frac{\\partial u}{\\partial t} = -c \\frac{\\partial u}{\\partial x} + S\n\\end{equation*}\nHere $S$ denotes a possible source term for the property $u$.\\\\\nBy using approximations for derivatives as given in section \\ref{derivate_approx}\nwe can formulate the following scheme:\n\nFor positive velocity ($c\\geq 0$):\n\\begin{equation} \\label{advection_scheme_upwind}\nu_{i}^{n+1}=u_{i}^{n}-c\\frac{\\Delta t}{\\Delta x} (u_{i}^{n}-u_{i-1}^{n}) + S_{i}^{n}\n\\end{equation}\n\nFor negative velocity:\n\\begin{equation} \\label{advection_scheme_downwind}\nu_{i}^{n+1}=u_{i}^{n}-c\\frac{\\Delta t}{\\Delta x} (u_{i+1}^{n}-u_{i-1}^{n}) +S_{i}^{n}\n\\end{equation}\n\nThe reason for splitting the scheme based on the direction of velocity becomes clear in section \\ref{stability}.\n\n\\subsection{Diffusion Scheme}\nDiffusion processes are of the form\n\\begin{equation*}\n\\frac{\\partial u}{\\partial t} = \\alpha \\frac{\\partial^2 u}{\\partial x^2}\n\\end{equation*}\nand again by using derivative approximations from section \\ref{derivate_approx} we\nformulate the following scheme:\n\\begin{equation} \\label{diffusion_scheme}\nu_{i}^{n+1}=u_{i}^ {n}+\\alpha\\frac{\\Delta t}{\\Delta x^{2}} (u_{i-1}^{n}-2u_{i}^{n}+u_{i+1}^{n})\n\\end{equation}\n\n\\subsection{Stability} \\label{stability}\nOne of the most important things with the use of approximation\nschemes is to ensure stability.\nActually one could argue that since we have justified all our derivative approximations by Taylor-expansions we are ready and can blindly implement the discrete equations into \na computer-system. This approach turns out to be too naive.\\\\\nIn general each computation is accompanied with rounding errors. Although these can be very small they can sum-up drastically when we have to repeat calculations in iterations.\nOur scheme has the form \n\\begin{equation} \\label{stability_scheme}\nu_{n+1}=A(u_{n})\n\\end{equation}\nwhere $A$ is some linear function. \\\\\nWe denote by $u_{n}$ the hypothetically calculated value without any rounding errors, and by $\\tilde{u}_{n}$ the actual calculated value. Then we have\n\\begin{equation}\n\\tilde{u}_{n}=u_{n}+\\epsilon_{n}\n\\end{equation}\nwhere $\\epsilon_{n}$ denotes the deviation of step $n$.\nTherefore instead of (\\ref{stability_scheme}) we actually deal with\n\\begin{equation} \\label{deviated_scheme}\nu_{n+1}+\\epsilon_{n+1}=A(u_{n}+\\epsilon_{n})\n\\end{equation}\nAt step $n$ we obtain a deviated solution which we use at step $n+1$.\nThus at step $n+1$, on the one hand we have to deal with pure rounding errors from the current step and on the other hand by the fact that actually we are using the deviated solution $u_{n}+\\epsilon_{n}$ as input.\nSo the very important question arises: How does the $\\epsilon_{n}$'s evolve over time?\\\\\nCombining equations (\\ref{stability_scheme}), (\\ref{deviated_scheme}) and using linearity of $A$ we obtain\n\\begin{equation} \\label{error_scheme}\n\\epsilon_{n+1}=A(\\epsilon_{n})\n\\end{equation}\nThis gives us a direct relation between errors at different steps.\nThe striking idea is to formulate a scheme, that is choose $A$, so that for all $n$\n\\begin{equation} \\label{scheme_error}\n|\\epsilon_{n+1}| \\leq |\\epsilon_{n} |\n\\end{equation}\nNote, if above equation holds, then we can be sure that although we still have to face \nrounding errors, the fact that we use a deviated version $u_{n}+\\epsilon_{n}$ as input does not impact the overall outcome of the iteration.\\\\\nIn order to show a given scheme to fulfill (\\ref{scheme_error}) we use a method invented by John von Neumann.\\\\\nThe idea behind this is to assume the errors can be approximated (or estimated) by a Fourier-expansion\n\\begin{equation} \\label{error_fourier_exp}\n\\epsilon(t,x)=e^{at}\\sum_{k}e^{jkx}\n\\end{equation}\nIn other words, some function which decreases or increases exponentially in time. Our aim is to find a scheme $A$ which enforces $a<0$ in above representation of $\\epsilon(t,x)$.\\\\\n\n\\subsubsection{Diffusion Scheme}\nWe replace $\\epsilon(t,x)$ in equation (\\ref{scheme_error}) by using for $A$ the scheme given in (\\ref{diffusion_scheme}). Since $A$ is linear we can restrict attention to one specific index $k$ in (\\ref{error_fourier_exp}) to obtain\n\\begin{equation*}\ne^{a(t+\\Delta t)}e^{jkx_{i}}=e^{at}e^{jkx_{i}}+\\alpha\\frac{\\Delta t}{\\Delta x^2}\n\\left(e^{at}e^{jk(x_{i}-\\Delta x)} -2e^{at}e^{jkx_{i}}+e^{at}e^{jk(x_{i}+\\Delta x)}\\right)\n\\end{equation*}\nNote the we have used $x_{i-1}=x_{i}-\\Delta x$, $x_{i+1}=x_{i}+\\Delta x$ and $\\epsilon(t_{n+1}, x_{i})=\\epsilon(t_{n}+\\Delta t, x_{i})$.\\\\\nFurther by canceling out factors on both sides we get\n\\begin{equation*}\ne^{a\\Delta t}=1+\\alpha\\frac{\\Delta t}{\\Delta x^2}\n\\left(e^{-jk\\Delta x} -2+e^{jk\\Delta x}\\right)\n\\end{equation*}\nFurther by use of Euler's formula the r.h.s can be combined to get\n\\begin{equation*}\ne^{a\\Delta t}=1+\\alpha\\frac{\\Delta t}{\\Delta x^2}\n\\left(2cos(k\\Delta x) -2\\right)\n\\end{equation*}\nSince the cosinus always has absolute value below $1$, a sufficient condition the l.h.s to be lower than $1$ is $2\\alpha\\frac{\\Delta t}{\\Delta x^2}\\leq\\frac{1}{2}$ or equivalent,\n\\begin{equation} \\label{stability_restr_diffusion}\n\\Delta t\\leq \\frac{1}{4}\\frac{\\Delta x^2}{\\alpha}\n\\end{equation}\nIn other words, in order to ensure our diffusion-scheme to be stable, we have to impose (\\ref{stability_restr_diffusion}) onto our implementation - we cannot choose arbitrary large time steps $\\Delta t$ for a given $\\Delta x$.\n\n\\subsubsection{Advection Scheme}\nThe same steps as above but by using as $A$ the scheme (\\ref{advection_scheme_upwind}) we obtain\n\\begin{equation*}\ne^{at}=1-c\\frac{\\Delta t}{\\Delta x}\\left(1-e^{-jk\\Delta x}\\right)\n\\end{equation*}\nWe can use the triangle inequality to estimate\n\\begin{equation*}\ne^{at}\\leq \\left|1-c\\frac{\\Delta t}{\\Delta x}\\right| + c\\frac{\\Delta t}{\\Delta x}\n\\end{equation*}\nNote, we have used the known identity $|e^{jy}|=1$.\\\\\nFrom the we can conclude the r.h.s to be lower $1$ if $0\\leq c\\Delta t/\\Delta x\\leq 1$ or equivalent\n\\begin{equation} \\label{stability_crit_advect}\n\\Delta t\\leq \\frac{\\Delta x}{c}\n\\end{equation}\nFor the case of $c<0$ above consideration would show scheme (\\ref{advection_scheme_upwind}) to never be stable. But if the same steps as above are applied on scheme (\\ref{advection_scheme_downwind}) instead we find the same stability criterion (\\ref{stability_crit_advect}).\n\n\\subsection{Operator and Term Splitting}\nYou might have wondered that our approximation schemes all were targeted at 1-dimensional problems, but our model is formulated in two dimensions. Moreover\nwe have treated diffusion and advection independent from each other whereas in our\nmodel they interact with each other.\\\\\nAll this is due to an elegant trick referred as Operator and Term Splitting which allows to separate dimensions and transport mechanisms in the implementation. In other words we can implement for each dimension and each\ntransport mechanism a scheme and then combine these schemes with each other.\\\\\n\n\\subsubsection{Dimensional Split}\nLet us use the advection-scheme as explanatory example. Once understanding the idea, the techniques easily can be adapted to other schemes.\nWe can write scheme (\\ref{advection_scheme_upwind}) in an operator form\n\\begin{equation*}\nL_{x} := id - c\\Delta t \\delta_{x}+S\n\\end{equation*}\nHereby $\\delta_{x}$ stands for an operator which takes a function $u$ as argument and \nreturns the approximated first derivative on a given grid, that is\n\\begin{equation*}\n\\delta_{x}(u_{i}) = \\frac{u_{i}-u_{i-1}}{\\Delta x}\n\\end{equation*}\nFurther $id$ denotes the identity operator\n\\begin{equation*}\nid(u_{i})=u_{i}\n\\end{equation*}\n and $S$ a constant operator\n\\begin{equation*}\nS(u_{i})=S_{i}\n\\end{equation*}\nWith this definitions our scheme (\\ref{advection_scheme_upwind}) can be written as\n\\begin{equation*}\nu^{n+1}_{i} = L_{x}(u^{n}_{i})\n\\end{equation*}\nIn analogy we can define the operator $L_{y}$ which applies in $y$-direction\n\\begin{equation*}\nL_{y}:=id - c\\Delta t \\delta_{y}+S\n\\end{equation*}\nand build the composition of both\n\\begin{equation} \\label{L_x_comp_L_y}\nL_{x}\\circ L_{y}=id-c\\Delta t\\delta_{x}-c\\Delta t\\delta_{y}+o(2)\n\\end{equation}\nIn the later we have skipped terms of order $2$ in $\\Delta t$. \\\\\nA general advaction-process in dimension 2 has the form,\n\\begin{equation*}\n\\frac{\\partial u}{\\partial t} = -c_{x}\\frac{\\partial u}{\\partial x}-c_{y} \\frac{\\partial u}{\\partial y}\n\\end{equation*}\nWe can use derivative approximations from section \\ref{derivate_approx} to obtain a scheme in the form\n\\begin{equation} \\label{L_xy_scheme}\nu_{i,j}^{n+1}=u_{i,j}^{n}-c_{x}\\frac{\\Delta t}{\\Delta x}(u_{i,j}^{n}-u_{i-1,j}^{n})\n-c_{y}\\frac{\\Delta t}{\\Delta x}(u_{i,j}^{n}-u_{i,j-1}^{n})\n\\end{equation}\nNow it is an easy task to verify that \n\\begin{equation*}\nL_{x}\\circ L_{y}(u_{i,j})=u_{i,j}^{n}-c_{x}\\frac{\\Delta t}{\\Delta x}(u_{i,j}^{n}-u_{i-1,j}^{n})\n-c_{y}\\frac{\\Delta t}{\\Delta x}(u_{i,j}^{n}-u_{i,j-1}^{n}) +o(2)\n\\end{equation*}\nand by comparing with (\\ref{L_xy_scheme}) to see that the 2-dimensional scheme coincides \nup to order 2 with the composition of the 1-dimensional scheme.\\\\\nTherefore, in our implementation instead of writing the scheme (\\ref{L_xy_scheme}) we will first apply the advection scheme (\\ref{advection_scheme_upwind}) for $x$-direction and on the result we will again apply (\\ref{advection_scheme_upwind}) but for $y$-direction.\n\n\\subsubsection{Term Splitting}\nThe idea of term splitting is quite the same as for dimension splitting. But this times the split is done w.r.t different physical processes, that is diffusion and advection.\\\\\nLike for the advection scheme we can introduce an operator which describes scheme (\\ref{diffusion_scheme})\n\\begin{equation*}\nL_{d}:=id+\\alpha\\Delta t\\delta_{xx}\n\\end{equation*}\nwhereas\n\\begin{equation*}\n\\delta_{xx}(u_{i})=\\frac{u_{i-1}-2u_{i}+u_{i+1}}{\\Delta x^2}\n\\end{equation*}\nWhen we compose $L_{d}$ with $L_{x}$ from previous section we obtain\n\\begin{equation*}\nL_{x}\\circ L_{d}=id-c\\Delta t\\delta_{x}+\\alpha\\Delta t\\delta_{xx}+o(2)\n\\end{equation*}\nA system containing diffusion and advection has in general the form\n\\begin{equation*}\n\\frac{\\partial u}{\\partial t} = -c\\frac{\\partial u}{\\partial x}+\\alpha\\frac{\\partial^2 u}{\\partial x^2}\n\\end{equation*}\nAgain we can use the derivative approximations from section \\ref{derivate_approx} to obtain a scheme\n\\begin{equation} \\label{diff_adv_scheme}\nu_{i}^{n+1}=u_{i}^{n}-c\\Delta t\\delta_{x}(u_{i}^{n})+\\alpha\\Delta t\\delta_{xx}(u_{i}^{n})\n\\end{equation}\nWe observe that the composition $L_{x}\\circ L_{d}$ coincides up to order 2 with above scheme.\\\\\nIn our implementation, instead of writing (\\ref{diff_adv_scheme}), we will first apply $L_{d}$ and on the result $L_{x}$.\n\n\\subsection{Final Scheme}\nIn previous sections we were describing things a little bit more general than they actually are in our specific model. Since buoyancy acts into $z$-direction we have to take into account only the $z$-component of velocity. Due to our specific boundary conditions we actually could model the entire system in 1-dimension but for educational reasons we do it in 2-dimensions.\\\\\nThe final scheme can be written by using above operator expressions as\n\\begin{equation} \\label{final_scheme_expr}\nu_{i,j}^{n+1}=L_{x}\\circ L_{D,y}\\circ L_{D,x}(u_{i,j}^{n})\n\\end{equation}\n$L_{D,x}$, $L_{D,y}$ denote the 1-dimensional diffusion operators applied in $x$-direction resp. $y$-direction.\\\\\nThis is an explicit scheme which becomes very handy to implement in this form as we will see next.\n\n\\section{Implementation}\nThe entire implementation as available at: \\\\ \\url{https://github.com/applied-math-coding/basic-diffusion-transport}.\\\\\nThe code is written in Typescript (by utilizing the package \\cite{lina}) and another version in Python.\nAn online running example can be found here,\\\\\n \\url{https://applied-math-coding.github.io/basic-diffusion-transport/}.\\\\\nIn the following we will give explanations for the Python code by focusing on the important snippets. The Typescript code is similar structured and due to the use of \\cite{lina} operator implementation are quite similar.\\\\\n\nModel parameter are defined in the file 'params.py'.\nWe initialize the temperature and velocity field by using three matrices. Note, the matrices\ninclude the boundaries:\n\\begin{lstlisting}[language=Python]\nT = np.empty((params.n_grid, params.n_grid))\nT.fill(params.T_c)\nv_y = np.zeros((params.n_grid, params.n_grid))\nv_x = np.zeros((params.n_grid, params.n_grid))\n\\end{lstlisting}\n\nWe iterate the application of operators and directly write the result\ninto above matrices:\n\\begin{lstlisting}[language=Python]\ndef simulate():\n  t = 0\n  while t <= params.duration:\n    utils.adjust_boundary(T, v_x, v_y)\n    utils.diffusion_x_op(T, alpha, delta_t, delta_x)\n    utils.diffusion_y_op(T, alpha, delta_t, delta_x)\n    utils.heat_convection_y_op(T, v_y, delta_t, delta_x)\n    utils.mom_convection_y_op(T, v_y, delta_t, delta_x)\n    utils.adjust_boundary(T, v_x, v_y)\n    t = t+delta_t\n\\end{lstlisting}\n\nEach operator is defined in file 'utils.py'.\nThe boundary conditions are ensured by:\n\\begin{lstlisting}[language=Python]\ndef adjust_boundary(T, v_x, v_y):\n  T[0, :] = params.T_h\n  T[-1, :] = T[-2, :]\n  T[:, 0] = T[:, 1]\n  T[:, -1] = T[:, -2]\n  v_y[0, :] = 0\n  v_y[-1, :] = v_y[-2, :]\n  v_y[:, 0] = v_y[:, 1]\n  v_y[:, -1] = v_y[:, -2]\n\\end{lstlisting}\n\nIn order to implement the operators, instead of using loops we are element-wise combining (adding, ...) sub-matrices (slices). The indexes of these sub-matrices are shifted against each other in order to achieve the \nspecific schemes receipt. This way the implementation is quite optimized and moreover resembles the actual scheme's definition:\n\\begin{lstlisting}[language=Python]\ndef diffusion_x_op(T, alpha, delta_t, delta_x):\n  T[1:-1, 1:-1] = T[1:-1, 1:-1] + alpha * delta_t / \\\n  pow(delta_x, 2)\n    * (T[1:-1, 0:-2]-2*T[1:-1, 1:-1]+T[1:-1, 2:])\n\n\ndef diffusion_y_op(T, alpha, delta_t, delta_x):\n  T_cen = T[1:-1, 1:-1]\n  T_down = T[0:-2, 1:-1]\n  T_up = T[2:, 1:-1]\n  T[1:-1, 1:-1] = T_cen + alpha * delta_t / \\\n  pow(delta_x, 2) * (T_down-2*T_cen+T_up)\n\n\ndef heat_convection_y_op(T, v_y, delta_t, delta_x):\n  T_cen = T[1:-1, 1:-1]\n  T_down = T[0:-2, 1:-1]\n  v_y_cen = v_y[1:-1, 1:-1]\n  T[1:-1, 1:-1] = T_cen - delta_t / delta_x * v_y_cen\n    * (T_cen-T_down)\n\n\ndef mom_convection_y_op(T, v_y, delta_t, delta_x):\n  T_cen = T[1:-1, 1:-1]\n  v_y_cen = v_y[1:-1, 1:-1]\n  v_y_down = v_y[0:-2, 1:-1]\n  T_up = T[2:, 1:-1]\n  b = params.g * np.maximum(np.zeros(T_cen.shape),\n  (T_cen-T_up)/T_up)\n  v_y[1:-1, 1:-1] = v_y_cen + delta_t * b - \\\n  delta_t / delta_x * v_y_cen * (v_y_cen-v_y_down)\n\\end{lstlisting}\n\\noindent\nAll code provided in this section is not intended for use in production environments. It is aimed for educational purposes only. For any mistakes the author does not take any responsibilities.\n\\newpage\n\\section{Further Reading}\nThis article intended to give an introduction into all treated areas.\nThere are many good books or online tutorials about numeric of partial\ndifferential equations. Or if you are more specialized on fluid dynamics you will find\nmany good accounts on this field either. Please feel encouraged to clone the entire project from\n\\url{https://github.com/applied-math-coding/basic-diffusion-transport} and to extend or play around.\n\n\\begin{thebibliography}{9}\n\t\\bibitem{lina} \n\tapplied.math.coding\n\t\\url{https://www.npmjs.com/package/@applied.math.coding/lina}\n\\end{thebibliography}\n\n\n\\end{document}", "meta": {"hexsha": "37ea50d6b58f379f895b6fd7571835a90476d1e0", "size": 27540, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/assets/article/advection_diffusion.tex", "max_stars_repo_name": "applied-math-coding/basic-diffusion-transport", "max_stars_repo_head_hexsha": "6e8934e0d598242343481e7d1003ea15b910f57e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-01T07:43:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-01T07:43:19.000Z", "max_issues_repo_path": "src/assets/article/advection_diffusion.tex", "max_issues_repo_name": "applied-math-coding/home", "max_issues_repo_head_hexsha": "6e8934e0d598242343481e7d1003ea15b910f57e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-05-11T12:33:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T03:58:32.000Z", "max_forks_repo_path": "src/assets/article/advection_diffusion.tex", "max_forks_repo_name": "applied-math-coding/basic-diffusion-transport", "max_forks_repo_head_hexsha": "6e8934e0d598242343481e7d1003ea15b910f57e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.166023166, "max_line_length": 375, "alphanum_fraction": 0.7345315904, "num_tokens": 8296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.44909999648344967}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Copyright (c) 2003-2018 by The University of Queensland\n% http://www.uq.edu.au\n%\n% Primary Business: Queensland, Australia\n% Licensed under the Apache License, version 2.0\n% http://www.apache.org/licenses/LICENSE-2.0\n%\n% Development until 2012 by Earth Systems Science Computational Center (ESSCC)\n% Development 2012-2013 by School of Earth Sciences\n% Development from 2014 by Centre for Geoscience Computing (GeoComp)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Example 1: One Dimensional Heat Diffusion in Granite}\n\\label{Sec:1DHDv00}\n\nThe first model consists of two blocks of isotropic material, for instance\ngranite, sitting next to each other (\\autoref{fig:onedgbmodel}).\nInitial temperature in \\textit{Block 1} is \\verb|T1| and in \\textit{Block 2} is\n\\verb|T2|.\nWe assume that the system is insulated.\nWhat would happen to the temperature distribution in each block over time? \nIntuition tells us that heat will be transported from the hotter block to the\ncooler one until both\nblocks have the same temperature.\n\n\\begin{figure}[ht]\n\\centerline{\\includegraphics[width=4.in]{figures/onedheatdiff001}}\n\\caption{Example 1: Temperature differential along a single interface between\ntwo granite blocks.}\n\\label{fig:onedgbmodel}\n\\end{figure}\n\n\\subsection{1D Heat Diffusion Equation}\nWe can model the heat distribution of this problem over time using the one\ndimensional heat diffusion equation\\footnote{A detailed discussion on how the\nheat diffusion equation is derived can be found at\n\\url{\nhttp://online.redwoods.edu/instruct/darnold/DEProj/sp02/AbeRichards/paper.pdf}};\nwhich is defined as:\n\\begin{equation}\n\\rho c_p \\frac{\\partial T}{\\partial t} - \\kappa \\frac{\\partial^{2}\nT}{\\partial x^{2}} = q_H \n\\label{eqn:hd}\n\\end{equation}\nwhere $\\rho$ is the material density, $c_p$ is the specific heat and\n$\\kappa$ is the thermal \nconductivity\\footnote{A list of some common thermal conductivities is available\nfrom Wikipedia\n\\url{http://en.wikipedia.org/wiki/List_of_thermal_conductivities}}. Here we\nassume that these material \nparameters are \\textbf{constant}. \nThe heat source is defined by the right hand side of \\refEq{eqn:hd} as\n$q_{H}$; this can take the form of a constant or a function of time and\nspace. For example $q_{H} = q_{0}e^{-\\gamma t}$ where we have\nthe output of our heat source decaying with time. There are also two partial\nderivatives in \\refEq{eqn:hd}; $\\frac{\\partial T}{\\partial t}$ describes the\nchange in temperature with time while $\\frac{\\partial ^2 T}{\\partial x^2}$ is\nthe spatial change of temperature. As there is only a single spatial dimension\nto our problem, our temperature solution $T$ is only dependent on the time $t$\nand our signed distance from the block-block interface $x$.\n\n\\subsection{PDEs and the General Form}\nIt is possible to solve PDE \\refEq{eqn:hd} analytically and obtain an exact\nsolution to our problem. However, it is not always practical to solve the\nproblem this way. Alternatively, computers can be used to find the solution. To\ndo this, a numerical approach is required to discretise \nthe PDE \\refEq{eqn:hd} across time and space, this reduces the problem to a\nfinite number of equations for a finite number of spatial points and time steps.\nThese parameters together define the model. While discretisation introduces\napproximations and a degree of error, a sufficiently sampled model is generally\naccurate enough to satisfy the accuracy requirements for the final solution.\n\nFirstly, we discretise the PDE \\refEq{eqn:hd} in time. This leaves us with a\nsteady linear PDE which involves spatial derivatives only and needs to be solved\nin each time step to progress in time. \\esc can help us here.\n\nFor time discretisation we use the Backward Euler approximation\nscheme\\footnote{see \\url{http://en.wikipedia.org/wiki/Euler_method}}. It is\nbased on the approximation \n\\begin{equation}\n\\frac{\\partial T(t)}{\\partial t} \\approx \\frac{T(t)-T(t-h)}{h}\n\\label{eqn:beuler}\n\\end{equation}\nfor  $\\frac{\\partial T}{\\partial t}$  at time $t$ \nwhere $h$ is the time step size. This can also be written as;\n\\begin{equation}\n\\frac{\\partial T}{\\partial t}(t^{(n)}) \\approx \\frac{T^{(n)} - T^{(n-1)}}{h}\n\\label{eqn:Tbeuler}\n\\end{equation}\nwhere the upper index $n$ denotes the n\\textsuperscript{th} time step. So one\nhas\n\\begin{equation}\n\\begin{array}{rcl}\nt^{(n)} & = & t^{(n-1)}+h \\\\\nT^{(n)} & = & T(t^{(n-1)}) \\\\ \n\\end{array}\n\\label{eqn:Neuler}\n\\end{equation}\nSubstituting \\refEq{eqn:Tbeuler} into \\refEq{eqn:hd} we get;\n\\begin{equation}\n\\frac{\\rho c_p}{h} (T^{(n)} - T^{(n-1)}) - \\kappa \\frac{\\partial^{2}\nT^{(n)}}{\\partial x^{2}} = q_H \n\\label{eqn:hddisc}\n\\end{equation}\nNotice that we evaluate the spatial derivative term at the current time\n$t^{(n)}$ - therefore the name \\textbf{backward Euler} scheme. Alternatively,\none can evaluate the spatial derivative term at the previous time $t^{(n-1)}$.\nThis approach is called the \\textbf{forward Euler} scheme. This scheme can\nprovide some computational advantages, which\nare not discussed here. However, the \\textbf{forward Euler} scheme has a major\ndisadvantage. Namely, depending on the \nmaterial parameters as well as the domain discretization of the spatial\nderivative term, the time step size $h$ needs to be chosen sufficiently small to\nachieve a stable temperature when progressing in time. Stability is achieved if\nthe temperature does not grow beyond its initial bounds and becomes\nnon-physical. \nThe backward Euler scheme, which we use here, is unconditionally stable meaning\nthat under the assumption of a\nphysically correct problem set-up the temperature approximation remains physical\nfor all time steps. \nThe user needs to keep in mind that the discretisation error introduced by\n\\refEq{eqn:beuler} \nis sufficiently small, thus a good approximation of the true temperature is\ncomputed. It is therefore very important that any results are viewed with\ncaution. For example, one may compare the results for different time and\nspatial step sizes.\n\nTo get the temperature $T^{(n)}$ at time $t^{(n)}$ we need to solve the linear \ndifferential equation \\refEq{eqn:hddisc} which only includes spatial\nderivatives. To solve this problem we want to use \\esc. \n\nIn \\esc any given PDE can be described by the general form. For the purpose of\nthis introduction we illustrate a simpler version of the general form for full\nlinear PDEs which is available in the \\esc user's guide. A simplified form that\nsuits our heat diffusion problem\\footnote{The form in the \\esc users guide which\nuses the Einstein convention is written as \n$-(A_{jl} u_{,l})_{,j}+D u =Y$}\nis described by;\n\\begin{equation}\\label{eqn:commonform nabla}\n-\\nabla\\cdot(A\\cdot\\nabla u) + Du = f\n\\end{equation}\nwhere $A$, $D$ and $f$ are known values and $u$ is the unknown solution. The\nsymbol $\\nabla$ which is called the \\textit{Nabla operator} or \\textit{del\noperator} represents\nthe spatial derivative of its subject - in this case $u$. Lets assume for a\nmoment that we deal with a one-dimensional problem then ;\n\\begin{equation}\n\\nabla = \\frac{\\partial}{\\partial x}\n\\end{equation}\nand we can write \\refEq{eqn:commonform nabla} as;\n\\begin{equation}\\label{eqn:commonform}\n-A\\frac{\\partial^{2}u}{\\partial x^{2}} + Du = f\n\\end{equation}\nif $A$ is constant. To match this simplified general form to our problem\n\\refEq{eqn:hddisc} \nwe rearrange \\refEq{eqn:hddisc};\n\\begin{equation}\n\\frac{\\rho c_p}{h} T^{(n)} - \\kappa \\frac{\\partial^2 T^{(n)}}{\\partial\nx^2} = q_H +  \\frac{\\rho c_p}{h} T^{(n-1)}\n\\label{eqn:hdgenf}\n\\end{equation}\nThe PDE is now in a form that satisfies \\refEq{eqn:commonform nabla} which is\nrequired for \\esc to solve our PDE. This can be done by generating a solution\nfor successive increments in the time nodes $t^{(n)}$ where \n$t^{(0)}=0$ and  $t^{(n)}=t^{(n-1)}+h$ where $h>0$ is the step size and assumed\nto be constant. \nIn the following the upper index ${(n)}$ refers to a value at time $t^{(n)}$.\nFinally, by comparing \\refEq{eqn:hdgenf} with \\refEq{eqn:commonform} one can see\nthat;\n\\begin{equation}\\label{ESCRIPT SET}\nu=T^{(n)}; \nA = \\kappa; D = \\frac{\\rho c _{p}}{h}; f = q _{H} + \\frac{\\rho\nc_p}{h} T^{(n-1)}\n\\end{equation}\n\n\\subsection{Boundary Conditions}\n\\label{SEC BOUNDARY COND}\nWith the PDE sufficiently modified, consideration must now be given to the\nboundary conditions of our model. Typically there are two main types of boundary\nconditions known as \\textbf{Neumann} and \\textbf{Dirichlet} boundary\nconditions\\footnote{More information on Boundary Conditions is available at\nWikipedia \\url{http://en.wikipedia.org/wiki/Boundary_conditions}},\nrespectively. \nA \\textbf{Dirichlet boundary condition} is conceptually simpler and is used to\nprescribe a known value to the unknown solution (in our example the temperature)\non parts of the boundary or on the entire boundary of the region of interest. \nWe discuss the Dirichlet boundary condition in our second example presented in\nSection~\\ref{Sec:1DHDv0}.\n\nHowever, for this example we have made the model assumption that the system is\ninsulated, so we need to add an appropriate boundary condition to prevent\nany loss or inflow of energy at the boundary of our domain. Mathematically this\nis expressed by prescribing\nthe heat flux $\\kappa \\frac{\\partial T}{\\partial x}$  to zero. In our simplified\none dimensional model this is expressed\nin the form;\n\\begin{equation}\n\\kappa \\frac{\\partial T}{\\partial x}  = 0 \n\\end{equation}\nor in a more general case as\n\\begin{equation}\\label{NEUMAN 1}\n\\kappa \\nabla T \\cdot n  = 0 \n\\end{equation}\nwhere $n$  is the outer normal field \\index{outer normal field} at the surface\nof the domain. \nThe $\\cdot$ (dot) refers to the dot product of the vectors $\\nabla T$ and $n$.\nIn fact, the term $\\nabla T \\cdot n$ is the normal derivative of \nthe temperature $T$. Other notations used here are\\footnote{The \\esc notation\nfor the normal\nderivative is $T_{,i} n_i$.};\n\\begin{equation}\n\\nabla T \\cdot n  = \\frac{\\partial T}{\\partial n} \\; .\n\\end{equation}\nA condition of the type \\refEq{NEUMAN 1} defines a \\textbf{Neumann boundary\ncondition} for the PDE. \n\nThe PDE \\refEq{eqn:hdgenf} \nand the Neumann boundary condition~\\ref{eqn:hdgenf} (potentially together with\nthe Dirichlet boundary conditions)  define a \\textbf{boundary value problem}. \nIt is the nature of a boundary value problem to allow making statements about\nthe solution in the\ninterior of the domain from information known on the boundary only. In most\ncases we use the term partial differential equation but in fact it is a\nboundary value problem. \nIt is important to keep in mind that boundary conditions need to be complete and\nconsistent in the sense that \nat any point on the boundary either a Dirichlet or a Neumann boundary condition\nmust be set.\n\nConveniently, \\esc makes a default assumption on the boundary conditions which\nthe user may modify where appropriate. \nFor a problem of the form in~\\refEq{eqn:commonform nabla} the default\ncondition\\footnote{In the \\esc user guide which uses the Einstein convention\nthis is written as \n$n_{j}A_{jl} u_{,l}=0$.} is;\n\\begin{equation}\\label{NEUMAN 2}\n-n\\cdot A \\cdot\\nabla u = 0 \n\\end{equation}\nwhich is used everywhere on the boundary. Again $n$ denotes the outer normal\nfield. \nNotice that the coefficient $A$ is the same as in the \\esc\nPDE~\\ref{eqn:commonform nabla}. \nWith the settings for the coefficients we have already identified in\n\\refEq{ESCRIPT SET} this\ncondition translates into \n\\begin{equation}\\label{NEUMAN 2b}\n\\kappa \\frac{\\partial T}{\\partial x} = 0 \n\\end{equation}\nfor the boundary of the domain. This is identical to the Neumann boundary\ncondition we want to set. \\esc will take care of this condition for us. We\ndiscuss the Dirichlet boundary condition later.\n\n\\subsection{Outline of the Implementation}\n\\label{sec:outline}\nTo solve the heat diffusion equation (\\refEq{eqn:hd}) we write a simple \\pyt\nscript. At this point we assume that you have some basic understanding of the\n\\pyt programming language. If not, there are some pointers and links available\nin Section \\ref{sec:escpybas}. The script (discussed in \\refSec{sec:key}) has\nfour major steps. Firstly, we need to define the domain where we want to \ncalculate the temperature. For our problem this is the joint blocks of granite\nwhich has a rectangular shape. Secondly, we need to define the PDE to solve in\neach time step to get the updated temperature. Thirdly, we need to define the\ncoefficients of the PDE and finally we need to solve the PDE. The last two steps\nneed to be repeated until the final time marker has been reached. The work flow\nis described in \\reffig{fig:wf}.\n% \\begin{enumerate}\n%  \\item create domain\n%  \\item create PDE\n%  \\item while end time not reached:\n% \\begin{enumerate}\n%  \\item set PDE coefficients\n%  \\item solve PDE\n%  \\item update time marker\n% \\end{enumerate}\n% \\item end of calculation\n% \\end{enumerate}\n\n\\begin{figure}[h!]\n \\centering\n   \\includegraphics[width=1in]{figures/workflow.png}\n   \\caption{Workflow for developing an \\esc model and solution}\n   \\label{fig:wf}\n\\end{figure}\n\nIn the terminology of \\pyt, the domain and PDE are represented by\n\\textbf{objects}. The nice feature of an object is that it is defined by its\nusage and features\nrather than its actual representation. So we will create a domain object to\ndescribe the geometry of the two\ngranite blocks. Then we define PDEs and spatially distributed values such as the\ntemperature \non this domain. Similarly, to define a PDE object we use the fact that one needs\nonly to define the coefficients of the PDE and solve the PDE. The PDE object has\nadvanced features, but these are not required in simple cases.\n\n\n\\begin{figure}[htp]\n \\centering\n   \\includegraphics[width=6in]{figures/functionspace.pdf}\n   \\caption{\\esc domain construction overview}\n   \\label{fig:fs}\n\\end{figure}\n\n\\subsection{The Domain Constructor in \\esc}\n\\label{ss:domcon}\nWhilst it is not strictly relevant or necessary, a better understanding of\nhow values are spatially distributed (\\textit{e.g.} Temperature) and how PDE\ncoefficients are interpreted in \\esc can be helpful.\n\nThere are various ways to construct domain objects. The simplest form is a\nrectangular shaped region with a length and height. There is\na ready to use function for this named \\verb rectangle(). Besides the spatial\ndimensions this function requires to specify the number of\nelements or cells to be used along the length and height, see \\reffig{fig:fs}.\nAny spatially distributed value \nand the PDE is represented in discrete form using this element\nrepresentation\\footnote{We use the finite element method (FEM), see\n\\url{http://en.wikipedia.org/wiki/Finite_element_method} for details.}.\nTherefore we will have access to an approximation of the true PDE solution\nonly. \nThe quality of the approximation depends - besides other factors - mainly on the\nnumber of elements being used. In fact, the \napproximation becomes better when more elements are used. However, computational\ncost grows with the number of\nelements being used. It is therefore important that you find the right balance\nbetween the demand in accuracy and acceptable resource usage.\n\nIn general, one can think about a domain object as a composition of nodes and\nelements. \nAs shown in \\reffig{fig:fs}, an element is defined by the nodes that are used to\ndescribe its vertices. \nTo represent spatially distributed values the user can use \nthe values at the nodes, at the elements in the interior of the domain or at the\nelements located on the surface of the domain. \nThe different approach used to represent values is called \\textbf{function\nspace} and is attached to all objects\nin \\esc representing a spatially distributed value such as the solution of\na PDE. The three function spaces we use at the moment are;\n\\begin{enumerate}\n\\item the nodes, called by \\verb|ContinuousFunction(domain)| ;\n\\item the elements/cells, called by \\verb|Function(domain)| ; and\n\\item the boundary, called by \\verb|FunctionOnBoundary(domain)|.\n\\end{enumerate}\nA function space object such as \\verb|ContinuousFunction(domain)| has the method\n\\verb|getX| attached to it. This method returns the\nlocation of the so-called \\textbf{sample points} used to represent values of the\nparticular function space. So the\ncall \\verb|ContinuousFunction(domain).getX()| will return the coordinates of the\nnodes used to describe the domain while\n\\verb|Function(domain).getX()| returns the coordinates of numerical\nintegration points within elements, see \\reffig{fig:fs}. \n\nThis distinction between different representations of spatially distributed\nvalues \nis important in order to be able to vary the degrees of smoothness in a PDE\nproblem. \nThe coefficients of a PDE do not need to be continuous, thus this qualifies as a\n\\verb|Function()| type. \nOn the other hand a temperature distribution must be continuous and needs to be\nrepresented with a \\verb|ContinuousFunction()| function space.\nAn influx may only be defined at the boundary and is therefore a\n\\verb|FunctionOnBoundary()| object.  \n\\esc allows certain transformations of the function spaces. A\n\\verb|ContinuousFunction()| can be transformed into a\n\\verb|FunctionOnBoundary()| or \\verb|Function()|. On the other hand there is\nnot enough information in a \\verb|FunctionOnBoundary()| to transform it to a\n\\verb|ContinuousFunction()|.\nThese transformations, which are called \\textbf{interpolation} are invoked\nautomatically by \\esc if needed.\n\nLater in this introduction we discuss how\nto define specific areas of geometry with different materials which are\nrepresented by different material coefficients such as the\nthermal conductivities $\\kappa$. A very powerful technique to define these types\nof PDE \ncoefficients is tagging. Blocks of materials and boundaries can be named and\nvalues can be defined on subregions based on their names.\nThis is a method for simplifying PDE coefficient and flux definitions. It makes\nscripting much easier and we will discuss this technique in\nSection~\\ref{STEADY-STATE HEAT REFRACTION}.\n\n\n\\subsection{A Clarification for the 1D Case}\n\\label{SEC: 1D CLARIFICATION}\nIt is necessary for clarification that we revisit our general PDE from\n\\refeq{eqn:commonform nabla} for a two dimensional domain. \\esc is inherently\ndesigned to solve problems that are multi-dimensional and so\n\\refEq{eqn:commonform nabla} needs to be read as a higher dimensional problem.\nIn the case of two spatial dimensions the \\textit{Nabla operator} has in fact\ntwo components $\\nabla = (\\frac{\\partial}{\\partial x}, \\frac{\\partial}{\\partial\ny})$. Assuming the coefficient $A$ is constant, the \\refEq{eqn:commonform nabla}\ntakes the following form;\n\\begin{equation}\\label{eqn:commonform2D}\n-A_{00}\\frac{\\partial^{2}u}{\\partial x^{2}} \n-A_{01}\\frac{\\partial^{2}u}{\\partial x\\partial y} \n-A_{10}\\frac{\\partial^{2}u}{\\partial y\\partial x} \n-A_{11}\\frac{\\partial^{2}u}{\\partial y^{2}} \n+ Du = f\n\\end{equation}\nNotice that for the higher dimensional case $A$ becomes a matrix. It is also\nimportant to notice that the usage of the Nabla operator creates\na compact formulation which is also independent from the spatial dimension. \nTo make the general PDE \\refEq{eqn:commonform2D} one dimensional as\nshown in \\refEq{eqn:commonform} we need to set\n\\begin{equation}\nA_{00}=A; A_{01}=A_{10}=A_{11}=0\n\\end{equation}\n\n\n\\subsection{Developing a PDE Solution Script}\n\\label{sec:key}\n\\sslist{example01a.py}\nWe write a simple \\pyt script which uses the \\modescript, \\modfinley and \\modmpl\nmodules. \nBy developing a script for \\esc, the heat diffusion equation can be solved at\nsuccessive time steps for a predefined period using our general form\n\\refEq{eqn:hdgenf}. Firstly it is necessary to import all the\nlibraries\\footnote{The libraries contain predefined scripts that are required to\nsolve certain problems, these can be simple like sine and cosine functions or\nmore complicated like those from our \\esc library.} \nthat we will require.\n\\begin{python}\nfrom esys.escript import *\n# This defines the LinearPDE module as LinearPDE\nfrom esys.escript.linearPDEs import LinearPDE \n# This imports the rectangle domain function from finley.\nfrom esys.finley import Rectangle \n# A useful unit handling package which will make sure all our units\n# match up in the equations under SI.\nfrom esys.escript.unitsSI import * \n\\end{python}\nIt is generally a good idea to import all of the \\modescript library, although\nif the functions and classes required are known they can be specified\nindividually. The function \\verb|LinearPDE| has been imported explicitly for\nease of use later in the script. \\verb|Rectangle| is going to be our type of\ndomain. The module \\verb|unitsSI| provides support for SI unit definitions with\nour variables.\n\nOnce our library dependencies have been established, defining the problem\nspecific variables is the next step. In general the number of variables needed\nwill vary between problems. These variables belong to two categories. They are\neither directly related to the PDE and can be used as inputs into the \\esc\nsolver, or they are script variables used to control internal functions and\niterations in our problem. For this PDE there are a number of constants which\nneed values. Firstly, the domain upon which we wish to solve our problem needs\nto be defined. There are different types of domains in \\modescript which we\ndemonstrate in later tutorials but for our granite blocks, we simply use a\nrectangular domain. \n\nUsing a rectangular domain simplifies our granite blocks (which would in reality\nbe a \\textit{3D} object) into a single dimension. The granite blocks will have a\nlengthways cross section that looks like a rectangle.  As a result we do not\nneed to model the volume of the block due to symmetry. There are four arguments\nwe must consider when we decide to create a rectangular domain, the domain\n\\textit{length}, \\textit{width} and \\textit{step size} in each direction. When\ndefining the size of our problem it will help us determine appropriate values\nfor our model arguments. If we make our dimensions large but our step sizes very\nsmall we increase the accuracy of our solution. Unfortunately we also increase\nthe number of calculations that must be solved per time step. This means more\ncomputational time is required to produce a solution. In this \\textit{1D}\nproblem, the bar is defined as being 1 metre long. An appropriate step size\n\\verb|ndx| would be 1 to 10\\% of the length. Our \\verb|ndy| needs only be 1,\nthis is because our problem stipulates no partial derivatives in the $y$\ndirection.\nThus the temperature does not vary with $y$. Hence, the model parameters can be\ndefined as follows; note we have used the \\verb|unitsSI| convention to make sure\nall our input units are converted to SI.\n\\begin{python}\nmx = 500.*m #meters - model length\nmy = 100.*m #meters - model width\nndx = 50 # mesh steps in x direction \nndy = 1 # mesh steps in y direction\nboundloc = mx/2 # location of boundary between the two blocks\n\\end{python}\nThe material constants and the temperature variables must also be defined. For\nthe granite in the model they are defined as:\n\\begin{python}\n#PDE related\nrho = 2750. *kg/m**3 #kg/m^{3} density of iron\ncp = 790.*J/(kg*K) # J/Kg.K thermal capacity\nrhocp = rho*cp \nkappa = 2.2*W/m/K   # watts/m.Kthermal conductivity\nqH=0 * J/(sec*m**3) # J/(sec.m^{3}) no heat source\nT1=20 * Celsius # initial temperature at Block 1\nT2=2273. * Celsius # base temperature at Block 2\n\\end{python}\nFinally, to control our script we will have to specify our timing controls and\nwhere we would like to save the output from the solver. This is simple enough:\n\\begin{python}\nt=0 * day  # our start time, usually zero\ntend=50 * yr # - time to end simulation\noutputs = 200 # number of time steps required.\nh=(tend-t)/outputs #size of time step\n#user warning statement\nprint(\"Expected Number of time outputs is: \", (tend-t)/h)\ni=0 #loop counter\n\\end{python}\nNow that we know our inputs we will build a domain using the\n\\verb|Rectangle()| function from \\FINLEY. The four arguments allow us to\ndefine our domain \\verb|model| as:\n\\begin{python}\n#generate domain using rectangle\nblocks = Rectangle(l0=mx,l1=my,n0=ndx, n1=ndy)\n\\end{python}\n\\verb|blocks| now describes a domain in the manner of Section \\ref{ss:domcon}.\n\nWith a domain and all the required variables established, it is now possible to\nset up our PDE so that it can be solved by \\esc. The first step is to define the\ntype of PDE that we are trying to solve in each time step. In this example it is\na single linear PDE\\footnote{in contrast to a system of PDEs which we discuss\nlater.}. We also need to state the values of our general form variables.\n\\begin{python}\nmypde=LinearPDE(blocks)\nA=zeros((2,2)))\nA[0,0]=kappa\nmypde.setValue(A=A, D=rhocp/h)\n\\end{python}\nIn many cases it may be possible to decrease the computational time of the\nsolver if the PDE is symmetric. \nSymmetry of a PDE is defined by;\n\\begin{equation}\\label{eqn:symm}\nA_{jl}=A_{lj}\n\\end{equation}\nSymmetry is only dependent on the $A$ coefficient in the general form and the\nother coefficients $D$ as well as the right hand side $Y$. From the above\ndefinition we can see that our PDE is symmetric. The \\verb|LinearPDE| class\nprovides the method \\method{checkSymmetry} to check if the given PDE is\nsymmetric. As our PDE is symmetrical we enable symmetry via;\n\\begin{python}\nmyPDE.setSymmetryOn()\n\\end{python}\nNext we need to establish the initial temperature distribution \\verb|T|. We need\nto \nassign the value \\verb|T1| to all sample points left to the contact interface at\n$x_{0}=\\frac{mx}{2}$\nand the value \\verb|T2| right to the contact interface. \\esc\nprovides the \\verb|whereNegative| function to construct this. More\nspecifically, \\verb|whereNegative| returns the value $1$ at those sample points\nwhere the argument has a negative value. Otherwise zero is returned.\nIf \\verb|x| are the $x_{0}$ \ncoordinates of the sample points used to represent the temperature distribution \nthen \\verb|x[0]-boundloc| gives us a negative value for \nall sample points left to the interface and non-negative value to \nthe right of the interface. So with;\n\\begin{python}\n# ... set initial temperature ....\nT= T1*whereNegative(x[0]-boundloc)+T2*(1-whereNegative(x[0]-boundloc))\n\\end{python}\nwe get the desired temperature distribution. To get the actual sample points\n\\verb|x| we use the \\verb|getX()| method of the function space\n\\verb|Solution(blocks)| which is used to represent the solution of a PDE;\n\\begin{python}\nx=Solution(blocks).getX()\n\\end{python}\nAs \\verb|x| are the sample points for the function space\n\\verb|Solution(blocks)| \nthe initial temperature \\verb|T| is using these sample points for\nrepresentation.\nAlthough \\esc is trying to be forgiving with the choice of sample points and to\nconvert\nwhere necessary the adjustment of the function space is not always possible. So\nit is advisable to make a careful choice on the function space used.  \n\nFinally we initialise an iteration loop to solve our PDE for all the time steps\nwe specified in the variable section. As the right hand side of the general form\nis dependent on the previous values for temperature \\verb T  across the bar this\nmust be updated in the loop. Our output at each time step is \\verb T  the heat\ndistribution and \\verb totT  the total heat in the system.\n\\begin{python}\nwhile t < tend:\n\ti+=1 #increment the counter\n\tt+=h #increment the current time\n\tmypde.setValue(Y=qH+rhocp/h*T) # set variable PDE coefficients\n\tT=mypde.getSolution() #get the PDE solution\n\ttotE = integrate(rhocp*T) #get the total heat (energy) in the system\n\\end{python}\nThe last statement in this script calculates the total energy in the system as\nthe volume integral of $\\rho c_{p} T$ over the block.\nAs the blocks are insulated no energy should be lost or added. \nThe total energy should stay constant for the example discussed here.\n\n\\subsection{Running the Script} \nThe script presented so far is available under \n\\verb|example01a.py|. You can edit this file with your favourite text editor. \nOn most operating systems\\footnote{The \\texttt{run-escript} launcher is not\nsupported under {\\it MS Windows}.} you can use the\n\\program{run-escript} command \nto launch {\\it escript} scripts. For the example script use;\n\\begin{verbatim}\nrun-escript example01a.py\n\\end{verbatim}\nThe program will print a progress report. Alternatively, you can use \nthe python interpreter directly;\n\\begin{verbatim}\npython example01a.py\n\\end{verbatim}\nif the system is configured correctly (please talk to your system\nadministrator).\n\n\\subsection{Plotting the Total Energy} \n\\sslist{example01b.py}\n\n\\esc does not include its own plotting capabilities. However, it is possible to\nuse a variety of free \\pyt packages for visualisation.\nTwo types will be demonstrated in this cookbook;\n\\mpl\\footnote{\\url{http://matplotlib.sourceforge.net/}} and \n\\verb|VTK|\\footnote{\\url{http://www.vtk.org/}}. \nThe \\mpl package is a component of SciPy\\footnote{\\url{http://www.scipy.org}}\nand is good for basic graphs and plots. \nFor more complex visualisation tasks, in particular two and three dimensional\nproblems we recommend the use of more advanced tools. For instance, \\mayavi\n\\footnote{\\url{http://code.enthought.com/projects/mayavi/}}\nwhich is based upon the \\verb|VTK| toolkit. The usage of \\verb|VTK| based \nvisualisation is discussed in Chapter~\\ref{Sec:2DHD} which focuses on a two\ndimensional PDE. \n\nFor our simple granite block problem, we have two plotting tasks. Firstly, we\nare interested in showing the\nbehaviour of the total energy over time and secondly, how the temperature\ndistribution within the block is developing over time.\nLet us start with the first task.\n\nThe idea is to create a record of the time marks and the corresponding total\nenergies observed.\n\\pyt provides the concept of lists for this. Before \nthe time loop is opened we create empty lists for the time marks \\verb|t_list|\nand the total energies \\verb|E_list|. \nAfter the new temperature has been calculated by solving the PDE we append the\nnew time marker and the total energy value for that time\nto the corresponding list using the \\verb|append| method. With these\nmodifications our script looks as follows:\n\\begin{python}\nt_list=[]\nE_list=[]\n# ... start iteration:\nwhile t<tend:\n      t+=h\n      mypde.setValue(Y=qH+rhocp/h*T) # set variable PDE coefficients\n      T=mypde.getSolution() #get the PDE solution\n      totE=integrate(rhocp*T) \n      t_list.append(t)   # add current time mark to record\n      E_list.append(totE) # add current total energy to record\n\\end{python}\nTo plot $t$ over $totE$ we use \\mpl a module contained within \\pylab which needs\nto be loaded before use;\n\\begin{python}\nimport pylab as pl # plotting package.\n\\end{python}\nHere we are not using \\verb|from pylab import *| in order to avoid name\nclashes for function names within \\esc. \n\nThe following statements are added to the script after the time loop has been\ncompleted;\n\\begin{python}\npl.plot(t_list,E_list)\npl.title(\"Total Energy\")\npl.axis([0,max(t_list),0,max(E_list)*1.1])\npl.savefig(\"totE.png\")\n\\end{python}\nThe first statement hands over the time marks and corresponding total energies\nto the plotter.\nThe second statement sets the title for the plot. The third statement\nsets the axis ranges. In most cases these are set appropriately by the plotter.\n \nThe last statement generates the plot and writes the result into the file\n\\verb|totE.png| which can be displayed by (almost) any image viewer. \nAs expected the total energy is constant over time, see\n\\reffig{fig:onedheatout1}.\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[width=4in]{figures/ttblockspyplot150}\n\\caption{Example 1b: Total Energy in the Blocks over Time (in seconds)}\n\\label{fig:onedheatout1} \n\\end{center}\n\\end{figure}\n\\clearpage\n\n\\subsection{Plotting the Temperature Distribution}\n\\label{sec: plot T}\n\\sslist{example01c.py}\nFor plotting the spatial distribution of the temperature we need to modify the\nstrategy we have used for the total energy.\nInstead of producing a final plot at the end we will generate a \npicture at each time step which can be browsed as a slide show or composed into\na movie.\nThe first problem we encounter is that if we produce an image at each time step\nwe need to make sure that the images previously generated are not overwritten.\n\nTo develop an incrementing file name we can use the following convention. It is\nconvenient to put all image files showing the same variable - in our case the\ntemperature distribution - into a separate directory.\nAs part of the \\verb|os| module\\footnote{The \\texttt{os} module provides \na powerful interface to interact with the operating system, see\n\\url{http://docs.python.org/library/os.html}.} \\pyt \nprovides the \\verb|os.path.join| command to build file and directory names in a\nplatform independent way. Assuming that \n\\verb|save_path| is the name of the directory we want to put the results in the\ncommand is; \n\\begin{python}\nimport os\nos.path.join(save_path, \"tempT%03d.png\"%i )\n\\end{python}\nwhere \\verb|i| is the time step counter.\nThere are two arguments to the \\verb|join| command. The \\verb|save_path|\nvariable is a predefined string pointing to the directory we want to save our\ndata, for example a single sub-folder called \\verb|data| would be defined by;\n\\begin{verbatim}\nsave_path = \"data\"\n\\end{verbatim}\nwhile a sub-folder of \\verb|data| called \\verb|example01| would be defined by;\n\\begin{verbatim}\nsave_path = os.path.join(\"data\",\"example01\")\n\\end{verbatim}\nThe second argument of \\verb|join| contains a string which is the file\nname or subdirectory name. We can use the operator \\verb|%| to use the value of\n\\verb|i| as part of our filename. The sub-string \\verb|%03d| indicates that we\nwant to substitute a value into the name; \n\\begin{itemize}\n \\item \\verb 0  means that small numbers should have leading zeroes;\n \\item \\verb 3  means that numbers should be written using at least 3 digits;\nand\n \\item \\verb d  means that the value to substitute will be a decimal integer.\n\\end{itemize}\n\nTo actually substitute the value of \\verb|i| into the name write \\verb|%i| after\nthe string.\nWhen done correctly, the output files from this command will be placed in the\ndirectory defined by \\verb save_path  as;\n\\begin{verbatim}\nblockspyplot001.png\nblockspyplot002.png\nblockspyplot003.png\n...\n\\end{verbatim}\nand so on.\n\nA sub-folder check/constructor is available in \\esc. The command;\n\\begin{verbatim}\nmkDir(save_path)\n\\end{verbatim}\nwill check for the existence of \\verb save_path  and if missing, create the\nrequired directories.\n\nWe start by modifying our solution script.\nPrior to the \\verb|while| loop we need to extract our finite solution\npoints to a data object that is compatible with \\mpl. First we create the node\ncoordinates of the sample points used to represent\nthe temperature as a \\pyt list of tuples or a \\numpy array as requested by the\nplotting function. \nWe need to convert the array \\verb|x| previously set as\n\\verb|Solution(blocks).getX()| into a \\pyt list \nand then to a \\numpy array. The $x_{0}$ component is then extracted via\nan array slice to the variable \\verb|plx|; \n\\begin{python}\nimport numpy as np # array package.\n#convert solution points for plotting\nplx = x.toListOfTuples() \nplx = np.array(plx) # convert to tuple to numpy array\nplx = plx[:,0] # extract x locations\n\\end{python}\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=4in]{figures/blockspyplot001}\n\\includegraphics[width=4in]{figures/blockspyplot050}\n\\includegraphics[width=4in]{figures/blockspyplot200}\n\\caption{Example 1c: Temperature ($T$) distribution in the blocks at time steps\n$1$, $50$ and $200$}\n\\label{fig:onedheatout} \n\\end{center}\n\\end{figure}\n\\clearpage\n\nWe use the same techniques provided by \\mpl as we have used to plot the total\nenergy over time. \nFor each time step we generate a plot of the temperature distribution and save\neach to a file. \nThe following is appended to the end of the \\verb|while| loop and creates one\nfigure of the temperature distribution. We start by converting the solution to a\ntuple and then plotting this against our \\textit{x coordinates} \\verb|plx| we\nhave generated before. We add a title to the diagram before it is rendered into\na file. \nFinally, the figure is saved to a \\verb|*.png| file and cleared for the\nfollowing iteration.\n\\begin{python}\n# ... start iteration:\nwhile t<tend:\n      i+=1\n      t+=h\n      mypde.setValue(Y=qH+rhocp/h*T)\n      T=mypde.getSolution()\n      totE=integrate(rhocp*T)\n      print(\"time step %s at t=%e days completed. total energy = %e.\"%(i,t/day,totE))\n      t_list.append(t)\n      E_list.append(totE)\n\n      #establish figure 1 for temperature vs x plots\n      tempT = T.toListOfTuples()\n      pl.figure(1) #current figure\n      pl.plot(plx,tempT) #plot solution\n      # add title\n      pl.axis([0,mx,T1*.9,T2*1.1])\n      pl.title(\"Temperature across blocks at time %d days\"%(t/day))\n      #save figure to file\n      pl.savefig(os.path.join(save_path,\"tempT\", \"blockspyplot%03d.png\"%i))\n      pl.clf() #clear figure\n\\end{python}  \nSome results are shown in \\reffig{fig:onedheatout}. \n\n\\subsection{Making a Video} \nOur saved plots from the previous section can be cast into a video using the\nfollowing command appended to the end of the script. The \\verb mencoder command\nis not available on every platform, so some users need to use an alternative\nvideo encoder.\n\\begin{python}\n# compile the *.png files to create a *.avi video that shows T change\n# with time. This operation uses Linux mencoder. For other operating \n# systems it is possible to use your favourite video compiler to\n# convert image files to videos.\n\nos.system(\"mencoder mf://\"+save_path+\"/tempT\"+\"/*.png -mf type=png:\\\n           w=800:h=600:fps=25 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o \\\n           example01tempT.avi\")\n\\end{python}\n \n", "meta": {"hexsha": "ec40bcfdcd14b58d77ef7d7abbf9f8ae8790e05d", "size": 37830, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/cookbook/example01.tex", "max_stars_repo_name": "markendr/esys-escript.github.io", "max_stars_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/cookbook/example01.tex", "max_issues_repo_name": "markendr/esys-escript.github.io", "max_issues_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-14T03:07:43.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T03:07:43.000Z", "max_forks_repo_path": "doc/cookbook/example01.tex", "max_forks_repo_name": "markendr/esys-escript.github.io", "max_forks_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.578313253, "max_line_length": 85, "alphanum_fraction": 0.7641554322, "num_tokens": 9898, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526660244837, "lm_q2_score": 0.78793120560257, "lm_q1q2_score": 0.4490046981565101}}
{"text": "\\documentclass{article}\n\\pagestyle{empty}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\setlength{\\oddsidemargin}{0in} \\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{0in} \\setlength{\\textheight}{8.5in}\n\\setlength{\\textwidth}{6.5in}\n\n\\makeatletter\n\\renewcommand*\\env@matrix[1][*\\c@MaxMatrixCols c]{%\n\t\\hskip -\\arraycolsep\n\t\\let\\@ifnextchar\\new@ifnextchar\n\t\\array{#1}}\n\\makeatother\n\n\\begin{document}\n\\begin{flushleft}\n\t\\bfseries{MATH 260, Linear Systems and Matrices, Fall `14}\\\\\n\t\\bfseries{Activity 10:  Introduction to Eigenvalues and Eigenvectors}\\\\\n\t%\\bfseries{Honor Code:} \\hspace{3.5in}\\bfseries{Names:}\\\\\n\\end{flushleft}\n\n\\begin{flushleft}\n\n\\section*{Warm-up:  Matrix Multiplication}\n\nGiven the matrix \n$\\textbf{A}=\n\\begin{bmatrix} \n1 & 1 \\\\ 4&1 \n\\end{bmatrix}$\n and the vectors: \n$\\vec{v}_1=\\begin{bmatrix} 2 \\\\ 2 \\end{bmatrix}$, \n$\\vec{v}_2=\\begin{bmatrix} 1 \\\\ 2 \\end{bmatrix}$,\n$\\vec{v}_3=\\begin{bmatrix} -2 \\\\ 0 \\end{bmatrix}$, \n$\\vec{v}_4=\\begin{bmatrix} -1 \\\\ -4 \\end{bmatrix}$, \n$\\vec{v}_5=\\begin{bmatrix} 1 \\\\ -2 \\end{bmatrix}$.\n\n\\vspace{0.1in}\n\nFind $\\textbf{A}\\vec{v}_i$ for $i=1,...,5$. \n\n\\vspace{2in}\n\n\\newpage\n\n\\section*{Visualizing Eigenvectors}\n\n1) Sketch each $\\vec{v}_i$ and the result of $\\textbf{A}\\vec{v}_i$ from the warm-up in the $xy$-plane. You should have 5 pictures when you are done. Be sure to clearly label which was your initial, and which your resultant vector. \n\n\\vspace{4in}\n\n2) Two of the $v_i$ vectors behaved differently, which ones? Describe how they behaved differently.\n\n\\vspace{1in}\n\n3) For the two vectors that behaved differently, you should be able to write the eigenvector equation: $\\textbf{A}\\vec{v}=\\lambda \\vec{v}$. Find $\\lambda_i$ for each pair of vectors.\n\n\\vspace{.75in}\n\n\\newpage\n\n\\section*{Practice}\n\nLet's practice finding eigenvalues and eigenvectors.\n\n\\vspace{0.1in}\n\n4) For each matrix, take the determinant $|\\textbf{A}- \\lambda \\textbf{I}  | $ then set the resulting polynomial equal to 0 and solve for $\\lambda$. (They should all be factorable, so even the $3 \\times 3$s should not be too hard to do). Once you have found ALL the eigenvalues ($\\lambda$s) find at least one eigenvector for each matrix.\\\\\n\n\\begin{center}\n\n$\\textbf{W}=\\begin{bmatrix}[rr] 1 & 4\\\\-4&11 \\end{bmatrix}$\n\\hspace{0.3in}\n$\\textbf{G}=\\begin{bmatrix}[rrr] 1 & 1 & -2\\\\ -1 & 2 & 1\\\\ 0 & 1 & -1 \\end{bmatrix}$\n\\hspace{0.3in}\n$\\textbf{R}=\\begin{bmatrix}[rrr] 1 & 2 & 3 \\\\ 0 & 4 & 5 \\\\ 0 & 0 & 6 \\end{bmatrix}$\n\n\\end{center}\n\n\\vspace{6in}\n\n5) Go back and look at $\\textbf{R}$.  What do you notice about the eigenvalues you found for \\textbf{R}?  Can you generalize this to a property of certain types of matrices?\n\n\\newpage\n\n\\section*{Some Properties of Eigenvalues}\n\n\\textit{ Note: We will find these for $2 \\times 2$ matrices, but these properties generalize to any $n \\times n$ matrix. }\n\n\\vspace{0.2in}\n\n6) We find eigenvalues by solving: $|\\textbf{A}- \\lambda \\textbf{I}  | =0 $. What happens if $\\lambda = 0 $? What must be true about the matrix \\textbf{A} for \\textbf{A} to have eigenvalues of 0?\n\n\\vspace{1.5in}\n\n7)a) Find $\\textbf{W}^{T}$.\n\n\\vspace{1in}\n\nb) What is the polynomial from $|\\textbf{W}^{T}- \\lambda \\textbf{I}  | $ and how does it compare to the polynomial for $|\\textbf{W}- \\lambda \\textbf{I}  | $?\n\n\\vspace{1in}\n\nc) What can you say about the eigenvalues (and vectors) of $\\textbf{A}$ and $\\textbf{A}^{T}$?\n\n\\vspace{0.75in}\n\n8)a) Find $\\textbf{W}^{-1}$.\n\n\\vspace{1in}\n\nb) What is the polynomial from $|\\textbf{W}^{-1}- \\lambda \\textbf{I}  | $? Set the polynomial equal to 0, and solve for $\\lambda$\n\n\\vspace{1in}\n\nc) Look carefully, how do the eigenvalues of $\\textbf{W}^{-1}$ relate to the eigenvalues of \\textbf{W}?\n\n\\end{flushleft}\n\\end{document}", "meta": {"hexsha": "e1066408cbdf592cb66d693c7a61cff8c8e66948", "size": 3754, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Fall 2014 - Capaldi A/Activities/Activity10_EigenPart1.tex", "max_stars_repo_name": "Pelonza/PB-LinAlg", "max_stars_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Fall 2014 - Capaldi A/Activities/Activity10_EigenPart1.tex", "max_issues_repo_name": "Pelonza/PB-LinAlg", "max_issues_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fall 2014 - Capaldi A/Activities/Activity10_EigenPart1.tex", "max_forks_repo_name": "Pelonza/PB-LinAlg", "max_forks_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0247933884, "max_line_length": 339, "alphanum_fraction": 0.689131593, "num_tokens": 1333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301065, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.4489965788161166}}
{"text": "\\documentclass{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\n\\usepackage[shortlabels]{enumitem}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{mathtools}\n\\usepackage{lmodern}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\\setlength{\\parskip}{0.5em}\n\n\\usepackage{clrscode3e}\n\n\\title{Recursion: A Brief Introduction} \n\\author{Competitive Programming UTEC}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\n\\subsection{Definition}\n\n\\textbf{Recursion} occurs when a thing is defined in terms of itself or its type. This definition is a bit weird and doesn't tell us much, so lets consider the following problem. We want to define a rule set for balanced brackets. How would you define that rule set? Recursion allow us to have a very elegant and simple solution: We say that a sequence $L$ of brackets is balanced if $L = L_1(L_2)$, where $L_1$ and $L_2$ are balanced brackets, or $L$ is empty. By defining balanced brackets with smaller balanced brackets we can simplify how we describe what balanced brackets are. A nice definition of recursion therefore is:\n\n\\begin{center}\n\t\\parbox{0.7\\linewidth}{Recursion (rĭ-kûr’-zhn) \\textit{noun.} If you still don't get it, see \\textbf{recursion}.}\n\\end{center}\n\nRecursion appears in many fields of knowledge such as mathematics, linguistics and computer science. This is due to the fact that it is a very powerful tool, that allows us to abstract concepts that might be hard to define and describe them in a very simple way. In computer science when we talk about recursion we usually refer to problems that can be solved by solving smaller instances of themselves. Now you might be asking: what makes a problem \\textit{smaller} or \\textit{bigger}? Intuitively, we say that a problem is bigger or harder if it takes more time to solve. For example, we can say that going up 5 stairs is harder than going up 3 stairs as we know that the more stairs there are, the longer it is going to take. A more formal definition would be that a problem is said to be smaller if it is fewer iterations away from the base case. This definition will probably make more sense as we further discuss the specifics and terminology of recursion.\n\n\\subsection{Conditions for Recursion}\n\nThere are three conditions that must be fulfilled for recursion to be possible:\n\n\\subsubsection{Recursive Call}\n\nThis is probably the easiest of all the conditions. It is obvious that in order to have a recursive algorithm at some point it must call the same algorithm but with different input, in other words, it must have a \\textit{recursive call}. We can have more than one recursive call, or have the recursive calls inside conditionals, it is all fair game.\n\n\\subsubsection{Base Case}\n\nLets consider the following algorithm:\n\n\\begin{codebox}\n\\Procname{$\\proc{factorial}(n)$}\n\t\\li \\Return  $n * \\proc{factorial}(n - 1)$\n\\end{codebox}\n\nIt is simple to realize that there is one huge mistake in this algorithm: \\textbf{it will never stop running!} This is why we need base cases, as they tell our algorithm when to stop. Formally a base case is a special behaviour inside the recursive algorithm that activates when it receives a specific parameter:\n\n\\begin{codebox}\n\\Procname{$\\proc{factorial}(n)$}\n\\li \\If $n = 0$\n\t\\li \\Then \n\t\t\\Return 1\n\t\\End\n\\li \\Return  $n * \\proc{factorial}(n - 1)$\n\\end{codebox}\n\nIn this example the base case occurs when $n = 0$ and the function returns $1$. In general the base case can be anything that doesn't use recursion. In other words we must calculate the answer for the base case ``manually'' using an iterative approach. It is important to note that just as there can be more than one recursive call, there can also be more than one base case.\n\n\\subsubsection{Convergence}\n\nThis is probably the least intuitive of the three conditions, but it is still very simple to understand. Lets consider the following recursive algorithm:\n\n\\begin{codebox}\n\\Procname{$\\proc{factorial}(n)$}\n\\li \\If $n = 0$\n\t\\li \\Then \n\t\t\\Return 1\n\t\\End\n\\li \\Return $n * \\proc{factorial}(n - 2)$\n\\end{codebox}\n\nAt first sight, it looks like this algorithm has no problems as there is a recursive call and a base case; however, there is a very important detail that has been overlooked. Lets say we call $\\proc{factoria}(3)$, this would call $\\proc{factorial}(1)$, which would call $\\proc{factorial}(-1)$, which would call $\\proc{factorial}(-3)$, and so on. Even though we had a base case, our algorithm \\textbf{never reached it}, meaning it will be stuck in an infinite loop. This is not good. This is why \\textit{convergence} is important, as it ensures that regardless of the parameters we use to call the algorithm, we should reach a base case after a finite number of steps. A corrected version of the algorithm above should consider two base cases, when $n$ reaches $0$ and when $n$ reaches $1$:\n\n\\begin{codebox}\n\\Procname{$\\proc{factorial}(n)$}\n\\li \\If $n \\leq 1$\n\t\\li \\Then \n\t\t\\Return 1\n\t\\End\n\\li \\Return $n * \\proc{factorial}(n - 2)$\n\\end{codebox}\n\n\\section{The Recursion Tree}\n\nLets consider the following algrithm for finding the $n$-th term of the Fibonacci sequence:\n\n\\begin{codebox}\n\\Procname{$\\proc{fibonacci}(n)$}\n\\li \\If $n \\leq 1$\n\t\\li \\Then \n\t\t\\Return n\n\t\\End\n\\li \\Return $\\proc{fibonacci}(n - 1) + \\proc{fibonacci}(n - 2)$\n\\end{codebox}\n\nWhat we are going to do now is build the \\textit{recursion tree} for this algorithm. This is a graphical representation of how the recursive calls behave and interact, and are very usefull to anlayze the algorithms behaviour. In this case, for $n = 4$ the tree would look like this:\n\n\\begin{center}\n\t\\includegraphics[width=0.8\\linewidth]{images/fibtree}\n\\end{center}\n\nEvery node in this tree represents a call to the function $\\proc{fibonacci}$, and the children of a node represents the recursive calls it make. The nodes that have no children are called leaf nodes, and in recursion trees they represent a base case. The first node is called the \\textit{root} and it represents the first call to the algorithm.\n\nJust by looking at this tree try to answer the following questions: Approximately how many nodes the tree will have for $n = 5$? What about for a general values of $n$?\n\n\\section{Complexity}\n\n\\subsection{Recurrence Relations}\n\nBefore we can jump into the algorithmic analysis we need to make a brief stop in the realm of discrete mathematics to understand recurrence relations. A \\textit{difference equation} or \\textit{recurrence relation} is an equation that tells us how different terms of a sequence relate. Lets consider the equation:\n\n$$a_n = 2 a_{n - 1}, a_0 = 1$$\n\nIt is simple to see that this recurrence generates the sequence: $1, 2, 4, 8, 16, \\dots 2^n \\dots$ As you might have realized, this means that $a_n = 2^n$. This can be formally proved using \\textit{mathematical induction}, but right now the intuition of why this is true is more than enough.\n\nThis process of turining a recurrence into a sequence defined only in terms of $n$ is usually called \\textit{solving} the recurrence, we are esentially finding a recursion-free expression for the sequence. This is very usefull as for some large value of $n$ we don't need to solve for all the smaller values, we can just evaluate the expression. Another technique for solving recurrences is building a recursion tree and adding up to the solution. Some of this equations, like the example above, are very intuitive and simple to solve, while others are much more difficult and require advanced techniques.\n\n\\subsection{Time as a Recurrence} \n\nWhen dealing with iterative algorithms, calculating their time complexity was usually a very trivial task, we only needed to count the number of instructions that were going to be executed. This changes bit with recursion as it might be harder to tell how many times a given instruction will be executed, or how many times the recursive function will be called. For this reason, it is fitting that in order to analyze the time complexity of a recursive algorithm we use a recursive function. In general we can express the time complexity of a recursive algorithm as:\n\n$$T(n) = \\sum T(n_i) + T'(n)$$\n\nWhere $n_i$ is the parameter used to call the $i$-th recursive call ans $T'$ is the complexity of all non-recursive steps. Lets consider the previous code for finding factorials. We can see that in that case there is only one recursive call and a multiplication. This means that we can express the complexity of that code as:\n\n$$T(n) = T(n - 1) + O(1)$$\n\nThis is a very straight forward recurrence that solves to $T(n) = O(n)$. Now lets do something a bit harder, lets try to determine the complexity of the algorithm for finding Fibonacci numbers. It is simple to realize that the complexity can be expressed as:\n\n$$T(n) = T(n - 1) + T(n - 2) + O(1)$$\n\nThis recurrence is definitely trickier, so we must find another way of solving it. Lets remember that when we are using \\textit{Big Oh} notation, we only want to find an estimate upper bound for the time complexity, therefore a good idea is to start by looking at the recursion tree and guessing. As in almost every step the number of nodes doubles, it is logical to guess that $T(n) = O(2^n)$. However, how can we prove this? A simple and straight forward way of doing it is by substituting our guess and checking:\n\n$$T(n) = 2^{n - 1} + 2^{n - 2} + O(1)$$\n$$T(n) \\leq 2 * 2^{n - 1} + O(1)$$\n$$T(n) \\leq 2^n + O(1)$$\n$$T(n) = O(2^n)$$\n\nEven though this is not the most formal proof, it is enough to get an idea on how fast our solution will run. Later on, you will learn more advanced techniques for solving recurrences and estimating complexities.\n\nIntuitively we can see that the more recursive calls we have, the bigger our time complexity will be. Therefore we must attempt to always minimize the number of recursive calls. We should also try to minimize the size of the smaller problems we target. However, this might be hard to achieve.\n\n\\subsection{Memory}\n\nOne important aspect to take into consideration when using recursion is that we are going to implicitly use memory of the stack. This happens because in every recursive call we need to store the current state of the algorithm in order to jump to the next function call. The auxiliary memory we will use in our algorithm will therefore be proportional to the height of our recursion tree, that is, the maximum distance between a leaf node and the root.\n\nIf we make too many recursive calls, this can lead to a stack overflow, in other words, we can run out of memory. This is one of the things that we must take into consideration when using recursion, as it can lead to our solution failing when dealing with bigger inputs.\n\n\\section{Strategy and Correctness}\n\nEven though the problems that can be solved using recursion are very different, the solution for most of them follows a very similar pattern. First we find the solution for all the smaller problems we need, then we merge this solutions to find the general solution to the problem. Because of the versatility of recursion, lots of paradigms use it heavily.\n\nTherefore the correctness of our algorithm depends on two things:\n\\begin{enumerate}\n\t\\item \\textbf{Base Case:} All of our base cases must give a correct result to our answer.\n\t\\item \\textbf{Merge:} The way in which we combine smaller solutions ensure that the general solution is also correct.\n\\end{enumerate}\n\nOne of the key advantages of this is that we can now give a lot more importance to the semantic meaning of our algorithms. This is to say that if we can describe what our algorithm does in words, whenever we use recursion in our solution we can assume that the result this yields is correct. For this reason recursion is a very abstraction heavy strategy that requires some practice in order to really get the most of this technique.\n\n\n\\end{document}\n", "meta": {"hexsha": "32a3ace6ae84d42f9ea8d3c047083bedf8dc0163", "size": 11954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2020-I/Lessons/8/recursion.tex", "max_stars_repo_name": "CP-UTEC/theory", "max_stars_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-04-15T05:34:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-03T03:51:55.000Z", "max_issues_repo_path": "2020-I/Lessons/8/recursion.tex", "max_issues_repo_name": "CP-UTEC/theory", "max_issues_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2020-I/Lessons/8/recursion.tex", "max_forks_repo_name": "CP-UTEC/theory", "max_forks_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.5, "max_line_length": 962, "alphanum_fraction": 0.7671072444, "num_tokens": 2967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.4489965674067784}}
{"text": "%%\n% The BIThesis Template for Bachelor Graduation Thesis\n%\n% 北京理工大学毕业设计（论文）第二章节 —— 使用 XeLaTeX 编译\n%\n% Copyright 2020-2022 BITNP\n%\n% This work may be distributed and/or modified under the\n% conditions of the LaTeX Project Public License, either version 1.3\n% of this license or (at your option) any later version.\n% The latest version of this license is in\n%   http://www.latex-project.org/lppl.txt\n% and version 1.3 or later is part of all distributions of LaTeX\n% version 2005/12/01 or later.\n%\n% This work has the LPPL maintenance status `maintained'.\n%\n% The Current Maintainer of this work is Feng Kaiyu.\n%%\n\n\\chapter{另一个章节}\n\n\\section{代码片段}\n\n\\begin{lstlisting}[language=Python, caption={Python Code}, label={lst:pythonfile}]\nimport numpy as np\n\ndef incmatrix(genl1,genl2):\n    m = len(genl1)\n    n = len(genl2)\n    M = None #to become the incidence matrix\n    VT = np.zeros((n*m,1), int)  #dummy variable\n\n    #compute the bitwise xor matrix\n    M1 = bitxormatrix(genl1)\n    M2 = np.triu(bitxormatrix(genl2),1)\n\n    for i in range(m-1):\n        for j in range(i+1, m):\n            [r,c] = np.where(M2 == M1[i,j])\n            for k in range(len(r)):\n                VT[(i)*n + r[k]] = 1;\n                VT[(i)*n + c[k]] = 1;\n                VT[(j)*n + r[k]] = 1;\n                VT[(j)*n + c[k]] = 1;\n\n                if M is None:\n                    M = np.copy(VT)\n                else:\n                    M = np.concatenate((M, VT), 1)\n\n                VT = np.zeros((n*m,1), int)\n\n    return M\n\\end{lstlisting}\n", "meta": {"hexsha": "ff1d7288f987aacc12c59ce90a46e51f61641104", "size": 1521, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "templates/undergraduate-thesis/chapters/2_chapter2.tex", "max_stars_repo_name": "spencerwooo/BIThesis", "max_stars_repo_head_hexsha": "b8993ef453f376cea13194c92a0a9248ff8c7fbf", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2020-01-13T01:37:07.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-19T11:17:21.000Z", "max_issues_repo_path": "templates/undergraduate-thesis/chapters/2_chapter2.tex", "max_issues_repo_name": "spencerwooo/BIThesis", "max_issues_repo_head_hexsha": "b8993ef453f376cea13194c92a0a9248ff8c7fbf", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": 39, "max_issues_repo_issues_event_min_datetime": "2020-03-02T13:39:32.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-28T04:13:03.000Z", "max_forks_repo_path": "templates/undergraduate-thesis/chapters/2_chapter2.tex", "max_forks_repo_name": "spencerwooo/BIThesis", "max_forks_repo_head_hexsha": "b8993ef453f376cea13194c92a0a9248ff8c7fbf", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": 40, "max_forks_repo_forks_event_min_datetime": "2020-01-16T23:02:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-27T04:05:38.000Z", "avg_line_length": 27.1607142857, "max_line_length": 82, "alphanum_fraction": 0.5844838922, "num_tokens": 473, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.44898257089215077}}
{"text": "\\chapter{LPE}\n\n\\section{Introduction}\nThe techniques that are described in the following chapters must be applied to a \\emph{linear process equation}, or LPE for short.\n\n\\section{Requirements}\n\nAn LPE must satisfy the following requirements:\n\n\\begin{itemize}\n\n\\item Given are the definition of a single process \\emph{and} its instantiation.\nThe instantiation must be a closed expression, and otherwise satisfy the usual requirements of \\txs{} of process instantiations.\nThere are no requirements for the channel parameters and data parameters beyond the usual requirements of \\txs{} of process definitions.\n\n\\item The body of the process consists of one or more \\emph{summands}.\nIn this context, a summand must contain exactly the following, in the given order:\n\n\\begin{itemize}\n\n\\item One or more \\emph{channel communications}; that is, channel references followed by the variables that are used to communicate over those channels.\nFor example, \\inlinecode{OUTPUT ? x ? y}, or simply \\inlinecode{OUTPUT}.\n\nChannel communications are combined with \\inlinecode{|}.\nTo give another example, \\inlinecode{INPUT ? x | OUTPUT ? y}.\n\nThe variables that are used to communicate over a channel must be \\emph{fresh}.\n\n\\item A guard, yielding a boolean value.\nThe guard is not always explicitly written if it is semantically equivalent to \\inlinecode{true}.\n\n\\item A sequence operator, \\inlinecode{>->}.\n\n\\item The expression for deadlock (\\inlinecode{STOP}) \\emph{or} a recursive process instantiation.\nThe instantiated process must use the process definition given by the LPE, which satisfies the requirements of a \\txs{} process signature.\nThis includes channel parameters: these must be assigned their current values of the instantiating process.\nThere are no requirements for the values assigned to the data parameters beyond the usual requirements of \\txs{} (such as type compatibility).\n\n\\end{itemize}\n\n\\end{itemize}\n\n\\section{Example}\n\nThe following code snippet gives a valid example of an LPE:\n\n\\begin{lstlisting}\n//Process definition:\nPROCDEF example[A :: Int, B](state, curr, prev :: Int)\n  = A ? i [[state==0]] >-> example[A, B](2, i, prev)\n  + A ? i [[state==1 && i!=prev]] >-> example[A, B](2, i, prev)\n  + A ? i [[state==2 && i==curr]] >-> example[A, B](1, curr, curr)\n  + B >-> STOP\n  ;\n\n//Initialization:\nexample[A, B](0, 0, 0);\n\\end{lstlisting}\n\nThe process only accepts input sequences in which every number is repeated exactly once.\nThe process terminates non-deterministically.\n", "meta": {"hexsha": "acec8db5a48241997fd8ac118b15f7f362b9d36b", "size": 2489, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_tex/lpeopsDoc/lpeDefinition.tex", "max_stars_repo_name": "Sercammus/TxsLpeOps", "max_stars_repo_head_hexsha": "3354f2762cf195e571f4c05040ec500165969359", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_tex/lpeopsDoc/lpeDefinition.tex", "max_issues_repo_name": "Sercammus/TxsLpeOps", "max_issues_repo_head_hexsha": "3354f2762cf195e571f4c05040ec500165969359", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_tex/lpeopsDoc/lpeDefinition.tex", "max_forks_repo_name": "Sercammus/TxsLpeOps", "max_forks_repo_head_hexsha": "3354f2762cf195e571f4c05040ec500165969359", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1451612903, "max_line_length": 152, "alphanum_fraction": 0.7537163519, "num_tokens": 597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4489825667348353}}
{"text": "%% SECTION HEADER /////////////////////////////////////////////////////////////////////////////////////\n\\section{2D Spectral Modelling}\n\\label{sec:2Dmodel}\n\n%% SECTION CONTENT ////////////////////////////////////////////////////////////////////////////////////\n\nAccording to the first-order shear deformation theory~\\cite{reissner1945effect, mindlin1951influence}, the displacement field is expressed as:\n\\begin{eqnarray}\n\t\\left \\{ \\begin{array}{c}\n\t\t\\textbf{u}^e(\\xi,\\eta) \\\\\n\t\t\\textbf{v}^e(\\xi,\\eta) \\\\\n\t\t\\textbf{w}^e(\\xi,\\eta)\n\t\\end{array} \\right\\} = \n\t\\left \\{ \\begin{array}{c}\n\t\t\\textbf{u}_0^e(\\xi,\\eta) + z\\boldsymbol{\\varphi}_x^e(\\xi,\\eta)\\\\\n\t\t\\textbf{v}_0^e(\\xi,\\eta) + z\\boldsymbol{\\varphi}_y^e(\\xi,\\eta)\\\\\n\t\t\\textbf{w}_0^e(\\xi,\\eta) \\\\\n\t\\end{array} \\right\\},\n\\end{eqnarray}\nwhere \\(\\textbf{u}_0^e\\), \\(\\textbf{v}_0^e\\) and \\(\\textbf{w}_0^e\\) are nodal displacements, \\(\\boldsymbol{\\varphi}_x^e\\), \\(\\boldsymbol{\\varphi}_y^e\\) are the rotations of the normal to the mid-plane with respect to the axes \\textit{x} and \\textit{y}, respectively. They are defined as:\n\\begin{eqnarray}\n\t\\left \\{\\begin{array}{c}\n\t\t\\textbf{u}_0^e(\\xi,\\eta) \\\\\n\t\t\\textbf{v}_0^e(\\xi,\\eta) \\\\\n\t\t\\textbf{w}_0^e(\\xi,\\eta) \\\\\n\t\t\\boldsymbol{\\varphi}_x^e(\\xi,\\eta) \\\\\n\t\t\\boldsymbol{\\varphi}_y^e(\\xi,\\eta)\n\t\\end{array} \\right\\}\n\t= \\textbf{N}^e(\\xi,\\eta)\\widehat{\\textbf{d}}^e\n\t= \\sum_{n=1}^q\\sum_{m=1}^p\\textbf{N}_m^e(\\xi)\\textbf{N}_n^e(\\eta)\n\t\\left \\{ \\begin{array}{c}\n\t\t\\widehat{\\textbf{u}}_0^e \\\\\n\t\t\\widehat{\\textbf{v}}_0^e \\\\\n\t\t\\widehat{\\textbf{w}}_0^e \\\\\n\t\t\\widehat{\\boldsymbol{\\varphi}}_x^e \\\\\n\t\t\\widehat{\\boldsymbol{\\varphi}}_y^e\n\t\\end{array} \\right \\},\n\\end{eqnarray}\nwhere $\\widehat{\\textbf{d}}^e$ is a nodal displacements vector of the element $e$.\n\nThe nodal bending strain--displacement relations are given in the form:\n\\begin{eqnarray}\n\t\\boldsymbol{\\epsilon}_b^e =\n\t\\textbf{B}_b^e\\widehat{\\textbf{d}}^e = \n\t\\left [\n\t\\begin{array}{ccccc}\n\t\t\\frac{\\partial N^e}{\\partial x} & 0 & 0 & 0 & 0\\\\\n\t\t0 & \\frac{\\partial N^e}{\\partial y} & 0 & 0 & 0\\\\\n\t\t\\frac{\\partial N^e}{\\partial y} & \\frac{\\partial N^e}{\\partial x} & 0 & 0 & 0\\\\\n\t\t0 & 0 & 0 & -\\frac{\\partial N^e}{\\partial x} & 0\\\\\n\t\t0 & 0 & 0 & 0 & -\\frac{\\partial N^e}{\\partial y}\\\\\n\t\t0 & 0 & 0 & -\\frac{\\partial N^e}{\\partial y} & -\\frac{\\partial N^e}{\\partial x}\n\t\\end{array} \\right]\n\t\\left \\{ \\begin{array}{c}\n\t\t\\widehat{\\textbf{u}}_0^e \\\\\n\t\t\\widehat{\\textbf{v}}_0^e \\\\\n\t\t\\widehat{\\textbf{w}}_0^e \\\\\n\t\t\\widehat{\\boldsymbol{\\varphi}}_x^e \\\\\n\t\t\\widehat{\\boldsymbol{\\varphi}}_y^e\n\t\\end{array} \\right\\}.\n\\end{eqnarray}\n\nThe nodal shear strain--displacement relations are given in the form:\n\\begin{eqnarray}\n\t\\boldsymbol{\\epsilon}_s^e =\n\t\\textbf{B}_s^e\\widehat{\\textbf{d}}^e = \n\t\\left [\n\t\\begin{array}{ccccc}\n\t\t0 & 0 & \\frac{\\partial N^e}{\\partial y} & -1 & 0\\\\\n\t\t0 & 0 & \\frac{\\partial N^e}{\\partial y} & 0 & -1\n\t\\end{array} \\right]\n\t\\left \\{ \\begin{array}{c}\n\t\t\\widehat{\\textbf{u}}_0^e \\\\\n\t\t\\widehat{\\textbf{v}}_0^e \\\\\n\t\t\\widehat{\\textbf{w}}_0^e \\\\\n\t\t\\boldsymbol{\\varphi}_x^e \\\\\n\t\t\\boldsymbol{\\varphi}_y^e\n\t\\end{array} \\right\\}.\n\\end{eqnarray}\n\nThe mass and stiffness matrices for \\ac{2d} elements are defined as:\n\\begin{eqnarray}\n\t\\textbf{M}_{dd}^e & = &\n\t\\left [\n\t\\begin{array}{cc}\n\t\t\\textbf{M}^e & 0\\\\\n\t\t0 & \\textbf{J}^e\n\t\\end{array}\n\t\\right] =\n\t\\int_{\\Omega_e}\\textbf{N}^T\\rho\n\t\\left [\n\t\\begin{array}{ccccc}\n\t\th & 0 & 0 & 0 & 0 \\\\\n\t\t& h & 0 & 0 & 0 \\\\\n\t\t&  & h & 0 & 0\\\\\n\t\t&  &  & \\frac{h^3}{12} & 0\\\\\n\t\tSym. &  &  &  & \\frac{h^3}{12}\n\t\\end{array} \\right]\n\t\\textbf{N} \\diff\\Omega_e,\\\\\n\t\\textbf{K}_{dd}^e & = & \\int_{\\Omega_e}{\\textbf{B}_b^e}^T\n\t\\left[\n\t\\begin{array}{cc}\n\t\t\\textbf{A} & \\textbf{B}\\\\\n\t\t\\textbf{B} & \\textbf{D}\n\t\\end{array} \\right]\n\t\\textbf{B}_b^e \\diff \\Omega_e+\\int_{\\Omega_e}{\\textbf{B}_s^e}^T\\hat{\\textbf{A}}\\textbf{B}_s^e\\diff \\Omega_e,\n\\end{eqnarray}\nwhere \\(h=h_t+h_b\\) is the element thickness, while \\(h_{t(b)}\\) is the distance between mid-plane and top(bottom) surface of the element, and \\(\\Omega_e\\) is the element area:\n\\begin{eqnarray}\n\t\\textbf{A} & = & \\textbf{c}_{ij}\\,(h_t-h_b),\\qquad i,j=1,2,6\\nonumber\\\\\n\t\\textbf{B} & = & 1/2\\, \\textbf{c}_{ij}\\,(h_t^2-h_b^2),\\qquad i,j=1,2,6\\nonumber\\\\\n\t\\textbf{D} & = & 1/3\\, \\textbf{c}_{ij}\\,(h_t^3-h_b^3),\\qquad i,j=1,2,6\\nonumber\\\\\n\t\\hat{\\textbf{A}} & = & 5/4\\, \\textbf{c}_{ij}\\,\\left[h_t-h_b-4/3\\left(h_t^3-h_b^3\\right)/h^2\\right],\\qquad i,j=4,5.\n\\end{eqnarray}\n", "meta": {"hexsha": "fbafce8737e41fde6ff26b507738fca2336d11e7", "size": 4374, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/proposal/Dissertation/Chapters/Chapter4/sec:2Dmodel.tex", "max_stars_repo_name": "pfiborek/model-hc", "max_stars_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/proposal/Dissertation/Chapters/Chapter4/sec:2Dmodel.tex", "max_issues_repo_name": "pfiborek/model-hc", "max_issues_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/proposal/Dissertation/Chapters/Chapter4/sec:2Dmodel.tex", "max_forks_repo_name": "pfiborek/model-hc", "max_forks_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0347826087, "max_line_length": 287, "alphanum_fraction": 0.5866483768, "num_tokens": 1932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.44891266874454183}}
{"text": "\\chapter{Logistic Regression models}\n\\label{ch:Models}\n\nThe Logistic Regression models obtained in the results of this work is shown in tables \\ref{tab:model1} and \\ref{tab:model2}. To clarify, $\\pi(x)$ indicates the probability that a new instance $x$ belongs to the default class, which, in this case, is a student passing the course.\n\n\\begin{table}[htb]\n\\centering\n\\begin{tabular}{cc} \\hline\n\\textbf{Week} & \\textbf{Model} \\\\ \\hline\n1 & $logit[\\pi(x)] = -2.1+0.14*pp_1+0.2*pv_1$ \\\\ \\hline\n2 & $logit[\\pi(x)] =-3.31+0.1*pp_1+0.16*pp_2+0.06*pv_1+0.22*pv_2$ \\\\ \\hline\n3 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-3.5+0.07*pp_1+0.1*pp_2+0.13*pp_3+0.04*pv_1$\\\\$ +0.08*pv_2+0.19*pv_3$\\end{tabular} \\\\ \\hline\n4 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-4.4+0.06*pp_1+0.08*pp_2+0.09*pp_3+0.17*pp_4$\\\\$ +0.02*pv_1+0.01*pv_2+0.08*pv_3+0.25*pv_4$\\end{tabular} \\\\ \\hline\n5 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-4.3+0.05*pp_1+0.05*pp_2+0.06*pp_3+0.1*pp_4$\\\\$ +0.16*pp_5+0.03*pv_1+0.02*pv_2+0.05*pv_3+0.1*pv_4+0.17*pv_5$\\end{tabular} \\\\ \\hline\n6 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-4.63+0.04*pp_1+0.04*pp_2+0.05*pp_3+0.08*pp_4$\\\\$ +0.12*pp_5+0.14*pp_6+0.02*pv_1+0.01*pv_2$\\\\$ +0.03*pv_3+0.07*pv_4+0.11*pv_5+0.11*pv_6$\\end{tabular} \\\\ \\hline\n7 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-4.75+0.04*pp_1+0.03*pp_2+0.04*pp_3+0.06*pp_4$\\\\$ +0.09*pp_5+0.1*pp_6+0.14*pp_7+0.02*pv_1$\\\\$ +0.01*pv_2+0.03*pv_3+0.06*pv_4+0.08*pv_5+0.05*pv_6+0.12*pv_7$\\end{tabular} \\\\ \\hline\n8 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.14+0.06*pp_1+0.02*pp_2+0.04*pp_3+0.04*pp_4$\\\\$ +0.07*pp_5+0.09*pp_6+0.11*pp_7+0.11*pp_8$\\\\$ +0.01*pv_1+0.01*pv_2+0.02*pv_3+0.06*pv_4$\\\\$ +0.06*pv_5-0.03*pv_6+0.03*pv_7+0.24*pv_8$\\end{tabular} \\\\ \\hline\n9 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.29+0.05*pp_1+0.02*pp_2+0.04*pp_3$\\\\$ +0.04*pp_4+0.07*pp_5+0.07*pp_6+0.09*pp_7+0.08*pp_8$\\\\$ +0.1*pp_9+0.0*pv_1+0.01*pv_2+0.0*pv_3+0.06*pv_4$\\\\$ +0.05*pv_5-0.03*pv_6-0.01*pv_7+0.11*pv_8+0.23*pv_9$\\end{tabular} \\\\ \\hline\n10 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.36+0.05*pp_1+0.01*pp_2+0.03*pp_3$\\\\$ +0.04*pp_4+0.06*pp_5+0.06*pp_6+0.08*pp_7+0.07*pp_8$\\\\$ +0.08*pp_9+0.06*pp_{10}+0.0*pv_1+0.02*pv_2$\\\\$ -0.01*pv_3+0.05*pv_4+0.05*pv_5$\\\\$ -0.03*pv_6-0.02*pv_7+0.08*pv_8+0.11*pv_9+0.21*pv_{10}$\\end{tabular} \\\\ \\hline\n11 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.49+0.06*pp_1+0.01*pp_2+0.03*pp_3$\\\\$ +0.04*pp_4+0.07*pp_5+0.05*pp_6+0.08*pp_7+0.05*pp_8$\\\\$ +0.07*pp_9+0.03*pp_{10}+0.08*pp_{11}-0.0*pv_1$\\\\$ +0.01*pv_2-0.01*pv_3+0.05*pv_4+0.04*pv_5-0.03*pv_6$\\\\$ -0.02*pv_7+0.06*pv_8+0.06*pv_9+0.11*pv_{10}+0.25*pv_{11}$\\end{tabular} \\\\ \\hline\n12 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.42+0.06*pp_1+0.01*pp_2+0.02*pp_3$\\\\$ +0.03*pp_4+0.07*pp_5+0.05*pp_6+0.09*pp_7+0.05*pp_8$\\\\$ +0.06*pp_9+0.01*pp_{10}+0.05*pp_{11}+0.08*pp_{12}$\\\\$ -0.01*pv_1+0.01*pv_2-0.01*pv_3+0.06*pv_4$\\\\$ +0.04*pv_5-0.04*pv_6-0.05*pv_7+0.04*pv_8$\\\\$ +0.05*pv_9+0.07*pv_{10}+0.15*pv_{11}+0.22*pv_{12}$\\end{tabular} \\\\ \\hline\n\\end{tabular}\n\\caption{Logistic Regression models (weeks 1-12)}\n\\label{tab:model1}\n\\end{table}\n\n\\begin{table}[htb]\n\\centering\n\\resizebox{12cm}{!}{%\n\\begin{tabular}{cc} \\hline\n\\textbf{Week} & \\textbf{Model} \\\\ \\hline\n13 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.25+0.04*pp_1+0.01*pp_2+0.01*pp_3$\\\\$ +0.02*pp_4+0.06*pp_5+0.04*pp_6+0.06*pp_7+0.04*pp_8$\\\\$ +0.05*pp_9+0.01*pp_{10}+0.04*pp_{11}+0.05*pp_{12}$\\\\$ +0.1*pp_{13}+0.0*pv_1+0.01*pv_2+0.0*pv_3+0.04*pv_4$\\\\$ +0.03*pv_5-0.02*pv_6-0.01*pv_7+0.03*pv_8+0.04*pv_9$\\\\$ +0.06*pv_{10}+0.09*pv_{11}+0.09*pv_{12}+0.14*pv_{13}$\\end{tabular} \\\\ \\hline\n14 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.31+0.04*pp_1+0.02*pp_2+0.01*pp_3$\\\\$ +0.03*pp_4+0.06*pp_5+0.04*pp_6+0.05*pp_7+0.04*pp_8$\\\\$ +0.04*pp_9-0.0*pp_{10}+0.02*pp_{11}+0.03*pp_{12}$\\\\$ +0.07*pp_{13}+0.12*pp_{14}+0.0*pv_1+0.01*pv_2$\\\\$ +0.0*pv_3+0.03*pv_4+0.04*pv_5-0.02*pv_6$\\\\$ -0.02*pv_7+0.03*pv_8+0.04*pv_9+0.05*pv_{10}$\\\\$ +0.08*pv_{11}+0.07*pv_{12}+0.08*pv_{13}+0.12*pv_{14}$\\end{tabular} \\\\ \\hline\n15 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.47+0.04*pp_1+0.01*pp_2+0.01*pp_3$\\\\$ +0.03*pp_4+0.06*pp_5+0.03*pp_6+0.06*pp_7+0.04*pp_8$\\\\$ +0.04*pp_9-0.01*pp_{10}+0.01*pp_{11}+0.02*pp_{12}$\\\\$ +0.05*pp_{13}+0.09*pp_{14}+0.09*pp_{15}+0.01*pv_1$\\\\$ +0.0*pv_2+0.0*pv_3+0.04*pv_4+0.03*pv_5$\\\\$ -0.02*pv_6-0.02*pv_7+0.02*pv_8+0.04*pv_9$\\\\$ +0.05*pv_{10}+0.07*pv_{11}+0.05*pv_{12}$\\\\$ +0.05*pv_{13}+0.08*pv_{14}+0.12*pv_{15}$\\end{tabular} \\\\ \\hline\n16 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.82+0.05*pp_1+0.01*pp_2+0.01*pp_3$\\\\$ +0.04*pp_4+0.07*pp_5+0.04*pp_6+0.06*pp_7+0.05*pp_8$\\\\$ +0.04*pp_9-0.02*pp_{10}+0.0*pp_{11}+0.0*pp_{12}$\\\\$ +0.04*pp_{13}+0.08*pp_{14}+0.08*pp_{15}+0.07*pp_{16}$\\\\$ +0.01*pv_1+0.0*pv_2+0.0*pv_3$\\\\$ +0.06*pv_4+0.05*pv_5-0.05*pv_6$\\\\$ -0.05*pv_7+0.01*pv_8+0.06*pv_9+0.06*pv_{10}$\\\\$ +0.09*pv_{11}+0.05*pv_{12}+0.03*pv_{13}+0.05*pv_{14}$\\\\$ +0.11*pv_{15}+0.11*pv_{16}$\\end{tabular} \\\\ \\hline\n17 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-5.56+0.04*pp_1+0.01*pp_2+0.01*pp_3$\\\\$ +0.03*pp_4+0.05*pp_5+0.03*pp_6+0.05*pp_7+0.04*pp_8$\\\\$ +0.04*pp_9-0.02*pp_{10}+0.01*pp_{11}+0.0*pp_{12}$\\\\$ +0.03*pp_{13}+0.06*pp_{14}+0.06*pp_{15}+0.04*pp_{16}$\\\\$ +0.1*pp_{17}+0.01*pv_1+0.01*pv_2$\\\\$ +0.0*pv_3+0.04*pv_4+0.04*pv_5-0.02*pv_6$\\\\$ -0.02*pv_7+0.02*pv_8+0.04*pv_9+0.05*pv_{10}$\\\\$ +0.07*pv_{11}+0.05*pv_{12}+0.04*pv_{13}+0.04*pv_{14}$\\\\$ +0.07*pv_{15}+0.06*pv_{16}+0.08*pv_{17}$\\end{tabular} \\\\ \\hline\n18 & \\begin{tabular}[c]{@{}c@{}}$logit[\\pi(x)] =-4.62+0.02*pp_1+0.01*pp_2+0.01*pp_3$\\\\$ +0.02*pp_4+0.03*pp_5+0.02*pp_6+0.03*pp_7+0.03*pp_8$\\\\$ +0.03*pp_9+0.01*pp_{10}+0.02*pp_{11}+0.02*pp_{12}$\\\\$ +0.03*pp_{13}+0.04*pp_{14}+0.04*pp_{15}+0.04*pp_{16}$\\\\$ +0.05*pp_{17}+0.06*pp_{18}+0.01*pv_1+0.01*pv_2$\\\\$ +0.01*pv_3+0.02*pv_4+0.02*pv_5+0.01*pv_6$\\\\$ +0.01*pv_7+0.02*pv_8+0.03*pv_9+0.03*pv_{10}$\\\\$ +0.04*pv_{11}+0.03*pv_{12}+0.03*pv_{13}+0.03*pv_{14}$\\\\$ +0.04*pv_{15}+0.04*pv_{16}+0.04*pv_{17}+0.05*pv_{18}$\\end{tabular}\\\\ \\hline\n\\end{tabular}%\n}\n\\caption{Logistic Regression models (weeks 13-18)}\n\\label{tab:model2}\n\\end{table}", "meta": {"hexsha": "651d3b7d7f72c4f094f26c9dd1be10e0bc32e9d0", "size": 6065, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Capitulos/ApendiceC.tex", "max_stars_repo_name": "lieet/Developing-a-web-system-for-predicting-student-success-using-learning-analytics", "max_stars_repo_head_hexsha": "ec277ee70b591c3a9cb3186e7c715b5cf26a42a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Capitulos/ApendiceC.tex", "max_issues_repo_name": "lieet/Developing-a-web-system-for-predicting-student-success-using-learning-analytics", "max_issues_repo_head_hexsha": "ec277ee70b591c3a9cb3186e7c715b5cf26a42a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Capitulos/ApendiceC.tex", "max_forks_repo_name": "lieet/Developing-a-web-system-for-predicting-student-success-using-learning-analytics", "max_forks_repo_head_hexsha": "ec277ee70b591c3a9cb3186e7c715b5cf26a42a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 144.4047619048, "max_line_length": 530, "alphanum_fraction": 0.6105523495, "num_tokens": 3915, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4489126687445417}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{setspace}\n\\usepackage{graphicx}\n\n\n\n\\title{Chapter 5\\\\Differentiation}\n\\author{solutions by Hikari}\n\\date{December 2021}\n\n\\begin{document}\n\n\\newcommand{\\V}{\\mathbf}\n\n\\maketitle\n\n\\paragraph{1.}\n\\[\n\\phi(y)=\\left|\\frac{f(x)-f(y)}{x-y} \\right|\\leq |x-y|\n\\]\n$|x-y|\\to0$ as $y\\to x$, so $\\phi(y)\\to0$ as $y\\to x$, which means $f'(x)=0$. By Theorem 5.11, $f$ is constant.\n\n\\paragraph{2.}\nFor $x_1,x_2\\in(a,b)$ and $x_2>x_1$, there exists $x\\in(x_1,x_2)$ such that $f(x_2)-f(x_1)=(x_2-x_1)f'(x)$, and since $f'(x)>0$,\\; $f(x_2)-f(x_1)>0$. So $f$ is strictly increasing in $(a,b)$, and therefore the inverse function $g$ exists.\n\nLet $x,t\\in(a,b)$, and $y=f(x),\\,u=f(t)$. Then\n\\[\n\\phi(u)=\\frac{g(u)-g(y)}{u-y}=\\frac{t-x}{f(t)-f(x)}=\\frac{1}{\\frac{f(t)-f(x)}{t-x}}\\to\\frac{1}{f'(x)}\n\\]\nwhen $t\\to x$, which means for every $\\varepsilon>0$ there is $\\delta'>0$ such that $|t-x|<\\delta'$ implies $|\\phi(u)-\\frac{1}{f'(x)}|<\\varepsilon$.\\; $f$ is a continuous 1-1 mapping of the compact metric space $[a',b']$ where $a<a'<b'<b$, so $g=f^{-1}$ is a continuous mapping by Theorem 4.17. So for $\\delta'>0$ there is $\\delta>0$ such that $|u-y|<\\delta$ implies $|g(u)-g(y)|=|t-x|<\\delta'$ and therefore $|\\phi(u)-\\frac{1}{f'(x)}|<\\varepsilon$, so\n\\[\ng'(f(x))=g'(y)=\\lim_{u\\to y}\\phi(u)=\\frac{1}{f'(x)}\n\\]\n\n\\paragraph{3.}\nLet $\\varepsilon<\\frac{1}{M}$, then $f'(x)=1+\\varepsilon g'(x)>1-\\frac{1}{M}\\cdot M=0$, so by Exercise 2, $f$ is strictly increasing and therefore one-to-one.\n\n\\paragraph{4.}\nConsider the function\n\\[\nf(x)=C_0x+\\frac{C_1}{2}x^2+\\cdots+\\frac{C_{n-1}}{n}x^n+\\frac{C_n}{n+1}x^{n+1}\n\\]\nwhich is differential. $f(0)=f(1)=0$, so by Theorem 5.10, there is a $x\\in(0,1)$ such that\n\\[\nf'(x)=C_0+C_1x+\\cdots+C_{n-1}x^{n-1}+C_nx^n=0\n\\]\n\n\\paragraph{5.}\nFor every $\\varepsilon>0$, there is a $x_0$ such that $x>x_0$ implies $|f'(x)|<\\varepsilon$, then for $x>x_0$, there is a $x_1\\in(x,x+1)$ such that\n\\[\n|g(x)|=\\left|\\frac{f(x+1)-f(x)}{x+1-x} \\right|=|f'(x_1)|<\\varepsilon\n\\]\nso $g(x)\\to0$ as $x\\to+\\infty$.\n\n\\paragraph{6.}\n\\[\ng'(x)=\\frac{f'(x)}{x}-\\frac{f(x)}{x^2}=\\frac{1}{x}\\left(f'(x)-\\frac{f(x)-f(0)}{x-0} \\right)=\\frac{1}{x}\\left(f'(x)-f'(x_1) \\right)>0\n\\]\nwhere $0<x_1<x$, so $f'(x)>f'(x_1)$. By Theorem 5.11,\\; $g$ is monotonically increasing.\n\n\\paragraph{7.}\n\\[\n\\lim_{t\\to x}\\frac{f(t)}{g(t)}=\\lim_{t\\to x}\\frac{\\frac{f(t)-f(x)}{t-x}}{\\frac{g(t)-g(x)}{t-x}}=\\frac{\\lim_{t\\to x}\\frac{f(t)-f(x)}{t-x}}{\\lim_{t\\to x}\\frac{g(t)-g(x)}{t-x}}=\\frac{f'(x)}{g'(x)}\n\\]\n\n\\paragraph{8.}\n$f'$ is continuous on the compact metric space $[a,b]$, so it is uniformly continuous by Theorem 4.19. For every $\\varepsilon>0$, there is $\\delta>0$ such that $x,y\\in[a,b]$ and $|y-x|<\\delta$ implies $|f'(y)-f'(x)|<\\varepsilon$, then for $x,t\\in[a,b]$ and $0<|t-x|<\\delta$, there is a $p$ between $x$ and $t$ such that\n\\[\n\\left|\\frac{f(t)-f(x)}{t-x}-f'(x) \\right|=\\left|f'(p)-f'(x) \\right|<\\varepsilon\n\\]\nsince $|p-x|<|t-x|<\\delta$. The results hold for vector-valued functions with arbitrary dimension $k$ since for the $i$-th component, we can find $\\delta_i$ such that\n\\[\n\\left|\\frac{f_i(t)-f_i(x)}{t-x}-f_i'(x) \\right|<\\frac{\\varepsilon}{\\sqrt{k}}\n\\]\nwhen $0<|t-x|<\\delta_i$, then for $|t-x|<\\delta=\\min(\\delta_1,\\delta_2,\\cdots,\\delta_k)$, \n\\[\n\\left|\\frac{\\V{f}(t)-\\V{f}(x)}{t-x}-\\V{f}'(x) \\right|<\\sqrt{\\left(\\frac{\\varepsilon}{\\sqrt{k}} \\right)^2\\cdot k}=\\varepsilon\n\\]\n\n\\paragraph{9.}\nFor every $t$ there is a $u\\in(0,t)$ or $(t,0)$ such that\n\\[\n\\frac{f(t)-f(0)}{t-0}=f'(u)\n\\]\nThen\n\\[\n\\lim_{t\\to0}\\frac{f(t)-f(0)}{t-0}=\\lim_{t\\to0}f'(u)=3\n\\]\nsince $u\\to0$ as $t\\to0$. So $f'(0)=3$.\n\n\\paragraph{10.}\nLet $f(x)=f_1(x)+if_2(x)$, then by Theorem 5.13,\n\\[\n\\lim_{x\\to0}\\frac{f(x)}{x}=\\lim_{x\\to0}\\frac{f_1(x)}{x}+\\lim_{x\\to0}\\frac{if_2(x)}{x}=\\lim_{x\\to0}f_1'(x)+\\lim_{x\\to0}if_2'(x)=\\lim_{x\\to0}f(x)=A\n\\]\nSimilarly $\\lim_{x\\to0}\\frac{g(x)}{x}=B$. Therefore,\n\\[\n\\lim_{x\\to0}\\frac{f(x)}{g(x)}=\\left\\{\\lim_{x\\to0}\\frac{f(x)}{x}-A \\right\\}\\cdot\\lim_{x\\to0}\\frac{x}{g(x)}+A\\cdot\\lim_{x\\to0}\\frac{x}{g(x)}=\\{A-A\\}\\cdot\\frac{1}{B}+A\\cdot\\frac{1}{B}=\\frac{A}{B}\n\\]\n\n\\paragraph{11.}\n\\[\nf''(x)=\\frac{f''(x)}{2}+\\frac{f''(x)}{2}=\\frac{1}{2}\\lim_{h\\to0}\\frac{f'(x+h)-f'(x)}{h}+\\frac{1}{2}\\lim_{h\\to0}\\frac{f'(x-h)-f'(x)}{-h}=\\lim_{h\\to0}\\frac{f'(x+h)-f'(x-h)}{2h}\n\\]\n$f''(x)$ exists, so $f'(x)$ exists in a neighborhood of $x$, which means $f(x)$ is differentiable in the neighborhood. Let $A(h)=f(x+h)+f(x-h)-2f(x)$,\\; $B(h)=h^2$, then $A(h)$ is differentiable in a neighborhood of $h=0$ with $A'(h)=f'(x+h)-f'(x-h)$, and $B(h)$ is differentiable in a neighborhood of $h=0$ with $B'(h)=2h$. As $h\\to0$,\\; $A(h)\\to0$ and $B(h)\\to0$, so by Theorem 5.13,\n\\[\n\\lim_{h\\to0}\\frac{f(x+h)+f(x-h)-2f(x)}{h^2}=\\lim_{h\\to0}\\frac{A(h)}{B(h)}=\\lim_{h\\to0}\\frac{A'(h)}{B'(h)}=\\lim_{h\\to0}\\frac{f'(x+h)-f'(x-h)}{2h}=f''(x)\n\\]\nLet $f$ be such that\n\\[\nf(x)=\n\\begin{cases}\n1,\\quad & x>0\\\\\n0,\\quad & x=0\\\\\n-1,\\quad & x<0\n\\end{cases}\n\\]\nthen \n\\[\n\\lim_{h\\to0}\\frac{f(0+h)+f(0-h)-2f(0)}{h^2}=0\n\\]\nwhile $f'(0)$ and $f''(0)$ do not exist.\n\n\\paragraph{12.}\nFor $x>0$,\\; $f(x)=x^3$,\\; $f'(x)=3x^2$,\\; $f''(x)=6x$,\\; $f^{(3)}(x)=6$. For $x<0$,\\; $f(x)=-x^3$,\\; $f'(x)=-3x^2$,\\; $f''(x)=-6x$,\\; $f^{(3)}(x)=-6$. For $x=0$,\n\\[\nf'(0)=\\lim_{t\\to0}\\frac{f(t)-f(0)}{t-0}=\\lim_{t\\to0}f'(p)=\\lim_{p\\to0}\\pm 3p^2=0\n\\]\nwhere $p\\in(0,t)$ or $(t,0)$.\n\\[\nf''(0)=\\lim_{t\\to0}\\frac{f'(t)-f'(0)}{t-0}=\\lim_{t\\to0}f''(q)=\\lim_{q\\to0}\\pm6q=0\n\\]\nwhere $q\\in(0,t)$ or $(t,0)$.\n\\[\nf^{(3)}(0+)=6,\\qquad f^{(3)}(0-)=-6\n\\]\nso $f^{(3)}(0)$ does not exist.\n\n\\paragraph{13.}\n$f$ is a complex function since $x^a$ may be complex for $x<0$. Assume the derivative laws of real functions holds for complex functions.\n\\medskip\n\n(a)\n$f$ is continuous for all $x\\neq0$. At $x=0$,\\; $f$ is continuous if and only if $\\lim_{t\\to0}f(t)=f(0)$. If $a\\leq0$,\\; $\\lim_{t\\to0}f(t)$ does not exist. If $a>0$,\\; $\\lim_{t\\to0}f(t)=0=f(0)$.\n\\medskip\n\n(b)\n\\[\nf'(0)=\\lim_{t\\to0}\\frac{f(t)-f(0)}{t-0}=\\lim_{t\\to0}t^{a-1}\\sin(|x|^{-c})\n\\]\nIf $a\\leq1$, the limit does not exist. If $a>1$, the limit exists and is equal to $0$.\n\\medskip\n\n(c)\nFor $x\\neq0$,\n\\[\nf'(x)=ax^{a-1}\\sin(|x|^{-c})-cx^{a+1}|x|^{-c-2}\\cos(|x|^{-c})\n\\]\nIf $a<1+c$, consider $x>0$ and $|x|^{-c}=2n\\pi$ where $n$ is an integer, then\n\\[\nf'(x)=-cx^{a-c-1}\\to\\infty\n\\]\nas $x\\to0$, so $f'$ is not bounded.\n\nIf $a\\geq 1+c$, then\n\\[\n|f'(x)|\\leq|a||x|^{a-1}+c|x|^{a-c-1}\\leq |a|+c\n\\]\nso $f'$ is bounded.\n\\medskip\n\n(d)\n$f'$ is continuous for all $x\\neq0$. At $x=0$,\\; $f'$ is continuous if and only if $\\lim_{t\\to0}f'(t)=f'(0)=0$.\n\nIf $a\\leq 1+c$, consider $t>0$ and $|t|^{-c}=2n\\pi$ where $n$ is an integer, then\n\\[\n\\lim_{t\\to0}f'(t)=\\lim_{t\\to0}-c\\,t^{a-c-1}=\n\\begin{cases}\n\\infty\\qquad & \\textit{if $a-c-1<0$}\\\\\n-c\\neq0\\qquad & \\textit{if $a-c-1=0$}\n\\end{cases}\n\\]\nso $f'$ is not continuous.\n\nIf $a>1+c$, \n\\[\n\\lim_{t\\to0}|f'(t)|\\leq \\lim_{t\\to0}|a||t|^{a-1}+\\lim_{t\\to0}c|t|^{a-c-1}=0\n\\]\nso $\\lim_{t\\to0}f'(t)=0=f'(0)$.\n\\medskip\n\n(e)\n\\[\nf''(0)=\\lim_{t\\to0}\\frac{f'(t)-f'(0)}{t-0}=\\lim_{t\\to0}a\\,t^{a-2}\\sin(|t|^{-c})-\\lim_{t\\to0}c\\,t^{a}|t|^{-c-2}\\cos(|t|^{-c})\n\\]\n\nIf $a\\leq 2+c$, consider $t>0$, then\n\\[\nf''(0)=\\lim_{t\\to0}t^{a-c-2}\\left(a\\,t^c\\sin(t^{-c})-c\\cos(t^{-c}) \\right)=\\lim_{t\\to0}-c\\,t^{a-c-2}\\cos(t^{-c})\n\\]\nwhich does not exist.\n\nIf $a>2+c$, then\n\\[\n|f''(0)|\\leq \\lim_{t\\to0}|a||t|^{a-2}+\\lim_{t\\to0}c|t|^{a-c-2}=0\n\\]\nso $f''(0)=0$.\n\\medskip\n\n(f)\nFor $x\\neq0$,\n\\begin{equation*}\n    \\begin{split}\n      f''(x) & =\\left(a(a-1)x^{a-2}-c^2x^{a+2}|x|^{-2c-4} \\right)\\sin(|x|^{-c})\\\\  \n      & +\\left(-acx^a|x|^{-c-2}-c(a+1)x^a|x|^{-c-2}-c(-c-2)x^{a+2}|x|^{-c-4} \\right)\\cos(|x|^{-c})\n    \\end{split}\n\\end{equation*}\n\nIf $a<2+2c$, consider $x>0$ and $|x|^{-c}=(2n+\\frac{1}{2})\\pi$ where $n$ is an integer, then\n\\[\nf''(x)=x^{a-2c-2}\\left(a(a-1)x^{2c}-c^2 \\right)\\to\\infty\n\\]\nas $x\\to0$, so $f''$ is not bounded.\n\nIf $a\\geq 2+2c$, then\n\\[\n|f''(x)|\\leq |a(a-1)|+|c^2|+|ac|+|c(a+1)|+|c(c+2)|\n\\]\nso $f''$ is bounded.\n\\medskip\n\n(g)\n$f''$ is continuous for all $x\\neq0$. At $x=0$,\\; $f''$ is continuous if and only if $\\lim_{t\\to0}f''(t)=f''(0)=0$.\n\nIf $a\\leq2+2c$, consider $t>0$ and $|t|^{-c}=(2n+\\frac{1}{2})\\pi$ where $n$ is an integer, then\n\\[\n\\lim_{t\\to0}f''(t)=\\lim_{t\\to0}t^{a-2c-2}\\left(a(a-1)t^{2c}-c^2 \\right)=\\begin{cases}\n\\infty\\qquad & \\textit{if $a-2c-2<0$}\\\\\n-c^2\\neq0\\qquad & \\textit{if $a-2c-2=0$}\n\\end{cases}\n\\]\nso $f''$ is not continuous.\n\nIf $a>2+2c$, \n\\[\n\\lim_{t\\to0}|f''(t)|\\leq \\lim_{t\\to0}\\left(|a(a-1)||t|^{a-2}+|c^2+c-2ac||t|^{a-c-2}+|c^2||t|^{a-2c-2} \\right)=0\n\\]\nso $\\lim_{t\\to0}f''(t)=0=f''(0)$.\n\n\\paragraph{14.}\nIf $f$ is convex, let $x_1,x_2$ be such that $a<x_1<x_2<b$, then by Exercise 4.23, \n\\[\nf'(x_1)=\\lim_{t\\to x_1}\\frac{f(t)-f(x_1)}{t-x_1}\\leq\\frac{f(x_2)-f(x_1)}{x_2-x_1}\\leq\\lim_{t\\to x_2}\\frac{f(t)-f(x_2)}{t-x_2}=f'(x_2)\n\\]\nwhich means $f$ is monotonically increasing.\n\nIf $f$ is monotonically increasing, let $x,y\\in(a,b)$,\\; $0<\\lambda<1$, and $z=\\lambda x+(1-\\lambda)y$. Then by Theorem 5.10,\n\\[\n\\frac{f(z)-f(x)}{z-x}=f(w_1)\\leq f(w_2)=\\frac{f(y)-f(z)}{y-z}\n\\]\nwhere $w_1\\in(x,z)$ and $w_2\\in(z,y)$. Rearranging,\n\\[\n(y-x)f(z)\\leq(y-z)f(x)+(z-x)f(y)\n\\]\n\\[\nf(\\lambda x+(1-\\lambda)y)\\leq \\lambda f(x)+(1-\\lambda)f(y)\n\\]\nwhich means $f$ is convex.\n\n$f''(x)\\geq0$ if and only if $f'(x)$ is monotonically increasing, if and only if $f$ is convex.\n\n\\paragraph{15.}\nFor every $x\\in(a,\\infty)$ and $h>0$, by Taylor's theorem, \n\\[\nf(x+2h)=f(x)+f'(x)\\cdot2h+\\frac{f''(\\xi)}{2}(2h)^2\n\\]\nwhere $\\xi\\in(x,x+2h)$, so\n\\[\nf'(x)=\\frac{1}{2h}\\left[f(x+2h)-f(x) \\right]-hf''(\\xi)\n\\]\n\\[\n|f'(x)|\\leq\\frac{1}{2h}\\left[M_0-(-M_0) \\right]+hM_2=\\frac{M_0}{h}+hM_2\n\\]\nIf $M_0=0$, then $M_1=0$, so $M_1^2\\leq4M_0M_2$ holds. If $M_2=0$, then $M_1$ is a constant, which means $f$ is a linear function, which is bounded only if $f$ is a constant function, which means $f'(x)=0$ and $M_1=0$, so $M_1^2\\leq4M_0M_2$ holds. So assume $M_0,M_2\\neq0$, and let $h=\\sqrt{\\frac{M_0}{M_2}}$, then $|f'(x)|\\leq2\\sqrt{M_0M_2}$ for every $x$, so $M_1\\leq2\\sqrt{M_0M_2}$,\\; $M_1^2\\leq4M_0M_2$.\n\nLet $f$ be such that\n\\[\nf(x)=\\begin{cases}\n2x^2-1\\qquad & (-1<x<0)\\\\\n\\frac{x^2-1}{x^2+1}\\qquad & (0\\leq x<\\infty)\n\\end{cases}\n\\]\nthen\n\\[\nf'(x)=\\begin{cases}\n4x\\qquad & (-1<x<0)\\\\\n\\frac{4x}{(x^2+1)^2}\\qquad & (0<x<\\infty)\n\\end{cases}\n\\]\n\\[\nf''(x)=\\begin{cases}\n4\\qquad & (-1<x<0)\\\\\n\\frac{4(1-3x^2)}{(x^2+1)^3}\\qquad & (0<x<\\infty)\n\\end{cases}\n\\]\n\\[\nf^{(3)}(x)=\\begin{cases}\n0\\qquad & (-1<x<0)\\\\\n\\frac{48x(x^2-1)}{(x^2+1)^4}\\qquad & (0<x<\\infty)\n\\end{cases}\n\\]\n$f'(0+)=f'(0-)=\\lim_{t\\to0}f'(t)=0$, so $f'(0)=0$ by Exercise 9.\\; $f''(0+)=f''(0-)=\\lim_{t\\to0}f''(t)=4$, so $f''(0)=4$ by Exercise 9. So $f$ is twice-differentiable. $f'(x)$ has a root at $x=0$ only, so \n\\[\nM_0=\\max\\left(|f(-1)|,|f(0)|,|f(\\infty)|\\right)=1\n\\]\n$f''(x)$ has a root at $x=\\frac{1}{\\sqrt{3}}$ only, so\n\\[\nM_1=\\max\\left(|f'(-1)|,|f'(0)|,|f'(\\frac{1}{\\sqrt{3}})|,|f'(\\infty)|\\right)=4\n\\]\n$f^{(3)}(x)$ has roots at $-1<x\\leq0$ and $x=1$, so\n\\[\nM_2=\\max\\left(4,|f''(1)|,|f''(\\infty)| \\right)=4\n\\]\nTherefore, $M_1^2=4M_0M_2$\n\nLet $\\V{f}$ be a twice-differentiable vector-valued function on $(a,\\infty)$, and let $M_0,M_1,M_2$ be the least upper bound of $|\\V{f}(x)|,|\\V{f'}(x)|,|\\V{f''}(x)|$. For every $0<\\alpha<M_1$, there is a $x_0$ such that $\\alpha<|\\V{f'}(x_0)|<M_1$.Let $\\V{u}=\\frac{\\V{f'}(x_0)}{|\\V{f'}(x_0)|}$ and $\\phi(x)=\\V{f'}(x)\\cdot\\V{u}$, and let $N_0,N_1,N_2$ be the least upper bound of $|\\phi(x)|,|\\phi'(x)|,|\\phi''(x)|$. We have\n\\[\n\\alpha<|\\V{f'}(x_0)|=|\\phi(x_0)|\\leq N_1\n\\]\n$\\phi(x)$ is a twice differentiable real function, so by the above results,\n\\[\nN_1^2\\leq4N_0N_2\n\\]\nSince $|\\phi(x)|=|\\V{f}(x)\\cdot\\V{u}|\\leq|\\V{f}(x)|\\cdot|\\V{u}|=|\\V{f}(x)|\\leq M_0$, and $|\\phi''(x)|=|\\V{f''}(x)\\cdot\\V{u}|\\leq|\\V{f''}(x)|\\cdot|\\V{u}|=|\\V{f''}(x)|\\leq M_2$, we have\n\\[\nN_0\\leq M_0\\qquad N_2\\leq M_2\n\\]\nSummarizing, we have\n\\[\n\\alpha^2\\leq N_1^2\\leq4N_0N_2\\leq4M_0M_2\n\\]\nfor every $0<\\alpha<M_1$, so\n\\[\nM_1^2\\leq4M_0M_2\n\\]\n\n\\paragraph{16.}\nLet $M_0,M_1,M_2$ be the upper bounds of $|f(x)|,|f'(x)|,|f''(x)|$ on $(a,\\infty)$. Then by Exercise 15,\n\\[\n\\left(\\lim_{a\\to\\infty}M_1 \\right)^2\\leq4\\left(\\lim_{a\\to\\infty}M_0 \\right)\\left(\\lim_{a\\to\\infty}M_2 \\right)=0\n\\]\nso $\\lim_{a\\to\\infty}M_1=0$, which means $f'(x)\\to0$ as $x\\to\\infty$.\n\n\\paragraph{17.}\nBy Taylor's Theorem,\n\\begin{equation*}\n    \\begin{split}\n        f(1) & =f(0)+f'(0)+\\frac{f''(0)}{2}+\\frac{f^{(3)}(s)}{6}\\\\\n        f(-1) & =f(0)-f'(0)+\\frac{f''(0)}{2}-\\frac{f^{(3)}(t)}{6}\n    \\end{split}\n\\end{equation*}\nfor some $s\\in(0,1)$,\\; $t\\in(-1,0)$. Subtracting the two equations, we have\n\\[\nf^{(3)}(s)+f^{(3)}(t)=6\n\\]\nso $f^{(3)}(s)\\geq3$ or $f^{(3)}(t)\\geq3$.\n\n\\paragraph{18.}\nThe relation $f^{(k)}(t)=(t-\\beta)Q^{(k)}(t)+kQ^{(k-1)}(t)$ holds for $k=1$. If it holds for $k=n$, so $f^{(n)}(t)=(t-\\beta)Q^{(n)}(t)+nQ^{(n-1)}(t)$, then\n\\[\nf^{(n+1)}(t)=(t-\\beta)Q^{(n+1)}(t)+Q^{(n)}(t)+nQ^{(n)}(t)=(t-\\beta)Q^{(n+1)}(t)+(n+1)Q^{(n)}(t)\n\\]\nso it holds for $k=n+1$. By induction, the relation holds for all $k\\geq1$. Therefore,\n\\begin{equation*}\n    \\begin{split}\n        P(\\beta) & =\\sum_{k=0}^{n-1}\\frac{f^{(k)}(\\alpha)}{k!}(\\beta-\\alpha)^k\\\\\n        & =f(\\alpha)-\\sum_{k=1}^{n-1}\\frac{Q^{(k)}(\\alpha)}{k!}(\\beta-\\alpha)^{k+1}+\\sum_{k=1}^{n-1}\\frac{Q^{(k-1)}(t)}{(k-1)!}(\\beta-\\alpha)^k\\\\\n        & =f(\\beta)-(\\beta-\\alpha)Q(t)-\\frac{Q^{(n-1)}(\\alpha)}{(n-1)!}(\\beta-\\alpha)^n+Q(t)(\\beta-\\alpha)\\\\\n        & =f(\\beta)-\\frac{Q^{(n-1)}(\\alpha)}{(n-1)!}(\\beta-\\alpha)^n\n    \\end{split}\n\\end{equation*}\nTherefore,\n\\[\nf(\\beta)=P(\\beta)+\\frac{Q^{(n-1)}(\\alpha)}{(n-1)!}(\\beta-\\alpha)^n\n\\]\n\n\\paragraph{19.}\n(a)(b)\n\\begin{equation*}\n    \\begin{split}\n        D_n & =\\frac{f(\\beta_n)-f(0)}{\\beta_n-\\alpha_n}-\\frac{f(\\alpha_n)-f(0)}{\\beta_n-\\alpha_n}\\\\\n        & =\\frac{f(\\beta_n)-f(0)}{\\beta_n-0}\\frac{\\beta_n}{\\beta_n-\\alpha_n}+\\frac{f(\\alpha_n)-f(0)}{\\alpha_n-0}\\frac{-\\alpha_n}{\\beta_n-\\alpha_n}\\\\\n        & =\\left(\\frac{f(\\beta_n)-f(0)}{\\beta_n-0}-\\frac{f(\\alpha_n)-f(0)}{\\alpha_n-0} \\right)\\frac{\\beta_n}{\\beta_n-\\alpha_n}+\\frac{f(\\alpha_n)-f(0)}{\\alpha_n-0}\n    \\end{split}\n\\end{equation*}\n$\\frac{\\beta_n}{\\beta_n-\\alpha_n}$ is bounded by $1$ in (a), and is assumed to be bounded in (b), so\n\\begin{equation*}\n    \\begin{split}\n        \\lim_{n\\to\\infty}D_n & =\\left(\\lim_{\\beta_n\\to0}\\frac{f(\\beta_n)-f(0)}{\\beta_n-0}-\\lim_{\\alpha_n\\to0}\\frac{f(\\alpha_n)-f(0)}{\\alpha_n-0} \\right)\\lim_{n\\to\\infty}\\frac{\\beta_n}{\\beta_n-\\alpha_n}+\\lim_{\\alpha_n\\to0}\\frac{f(\\alpha_n)-f(0)}{\\alpha_n-0}\\\\\n        & = \\left(f'(0)-f'(0) \\right)\\cdot\\lim_{n\\to\\infty}\\frac{\\beta_n}{\\beta_n-\\alpha_n}+f'(0)\\\\\n        & =f'(0)\n    \\end{split}\n\\end{equation*}\n\n(c)\n$f$ is differentiable in $(-1,1)$, so by Theorem 5.10, there is $\\gamma_n\\in(\\alpha_n,\\beta_n)$ such that\n\\[\nD_n=\\frac{f(\\beta_n)-f(\\alpha_n)}{\\beta_n-\\alpha_n}=f'(\\gamma_n)\n\\]\nTherefore,\n\\[\n\\lim_{n\\to\\infty}D_n=\\lim_{\\gamma_n\\to0}f'(\\gamma_n)=f'(0)\n\\]\nsince $\\gamma_n\\to0$ as $n\\to\\infty$, and $f'$ is continuous.\n\\medskip\n\nLet $f$ be such that\n\\[\nf(x)=\\begin{cases}\nx^2\\sin\\frac{1}{x}\\qquad & (x\\neq0)\\\\\n0\\qquad & (x=0)\n\\end{cases}\n\\]\n$f(x)$ is differentiable at $x\\neq0$, and at $x=0$,\n\\[\nf'(0)=\\lim_{x\\to0}\\frac{f(x)-f(0)}{x-0}=\\lim_{x\\to0}x\\sin\\frac{1}{x}=0\n\\]\nso $f'(0)$ exists. Let $\\beta_n=\\frac{1}{2\\pi(n-\\frac{1}{4})}$ and $\\alpha_n=\\frac{1}{2\\pi n}$, then\n\\[\n\\lim_{n\\to\\infty}D_n=\\lim_{n\\to\\infty}\\frac{-\\beta_n^2-0}{\\beta_n-\\alpha_n}=\\lim_{n\\to\\infty}-\\frac{2}{\\pi}\\frac{n}{n-\\frac{1}{4}}=-\\frac{2}{\\pi}\\neq f'(0)\n\\]\n\n\\paragraph{20.}\nLet $\\V{f}$ be a vector-valued function, and let all the other definitions be the same as in Theorem 5.15. Let $\\V{u}$ be a constant vector with $|\\V{u}|=1$, then $\\V{u}\\cdot\\V{f}$ is a real function on which Theorem 5.15 can apply, so there exists a point $x$ between $\\alpha$ and $\\beta$ such that\n\\[\n\\left|\\V{u}\\cdot\\V{f}(\\beta)-\\V{u}\\cdot\\V{P}(\\beta) \\right|=\\left|\\frac{\\V{u}\\cdot\\V{f}^{(n)}(x)}{n!}(\\beta-\\alpha)^n \\right|\\leq\\left|\\frac{\\V{f}^{(n)}(x)}{n!} \\right|(\\beta-\\alpha)^n\n\\]\nLet $\\V{u}=\\frac{\\V{f}(\\beta)-\\V{P}(\\beta)}{|\\V{f}(\\beta)-\\V{P}(\\beta)|}$, then $|\\V{u}\\cdot\\V{f}(\\beta)-\\V{u}\\cdot\\V{P}(\\beta)|=|\\V{f}(\\beta)-\\V{P}(\\beta)|$, so\n\\[\n\\left|\\V{f}(\\beta)-\\V{P}(\\beta) \\right|\\leq\\left|\\frac{\\V{f}^{(n)}(x)}{n!} \\right|(\\beta-\\alpha)^n\n\\]\nwhich is the required inequality.\n\n\\paragraph{21.}\nLet $E$ be a closed subset of ${R}^1$, then by Exercise 2.29,\\; $E^c=\\bigcup_k(a_k,b_k)$ where $a_k$ and $b_k$ can be possibly infinite. Define the function $f$ as\n\\[\nf(x)=\\begin{cases}\ne^{-\\frac{1}{(x-a_k)^2(x-b_k)^2}}\\qquad & x\\in(a_k,b_k)\\subset E^c,\\; a_k\\neq-\\infty,\\; b_k\\neq\\infty\\\\\ne^{-\\frac{1}{(x-a_k)^2}}\\qquad & x\\in(a_k,\\infty)\\subset E^c\\\\\ne^{-\\frac{1}{(x-b_k)^2}}\\qquad & x\\in(-\\infty,b_k)\\subset E^c\\\\\n0\\qquad & x\\in E\n\\end{cases}\n\\]\nThe zero set of $f$ is $E$. It is differentiable of all orders at $x\\neq a_k,b_k$, and at $x=a_k$, \n\\[\nf'(a_k+)=\\lim_{x\\to a_k}\\frac{e^{-\\frac{1}{(x-a_k)^2(x-b_k)^2}}}{x-a_k}=0=f'(a_k-)\n\\]\nso $f'(a_k)$ exists. Continue the process, $f^{(n)}(a_k)$ exists for every $n$. The facts hold similarly for $x=b_k$. Therefore, $f$ has derivatives of all orders on $R^1$.\n\n\\paragraph{22.}\nIf there are two different points $x_1,x_2$ such that $f(x_1)=x_1$ and $f(x_2)=x_2$, then by Theorem 5.10, there is a $t$ between $x_1,x_2$ such that\n\\[\nf'(t)=\\frac{f(x_1)-f(x_2)}{x_1-x_2}=\\frac{x_1-x_2}{x_1-x_2}=1\n\\]\na contradiction, so $f$ has at most one fixed point.\n\\medskip\n\n(b)\n$(1+e^{-t})^{-1}\\neq0$, so $f(t)=t+(1+e^{-t})^{-1}\\neq t$, which means $f$ has no fixed point.\n\\[\nf'(t)=1-\\frac{e^t}{(1+e^t)^2}\n\\]\nwhich lies between $(0,1)$ for all finite $t$.\n\\medskip\n\n(c)\nFor $k\\geq1$,\n\\[\n\\frac{|x_{k+2}-x_{k+1}|}{|x_{k+1}-x_k|}=\\left|\\frac{f(x_{k+1})-f(x_k)}{x_{k+1}-x_k} \\right|=\\left|f'(t_k) \\right|\\leq A\n\\]\nwhere $t_k$ is between $x_{k+1}$ and $x_k$. Therefore,\n\\[\n|x_{n+1}-x_n|\\leq|x_n-x_{n-1}|A\\leq\\cdots\\leq|x_2-x_1|A^{n-1}\n\\]\nLet $N$ be a positive integer, then for $n,m>N$ and $n\\geq m$,\n\\[\n|x_n-x_m|\\leq|x_n-x_{n-1}|+\\cdots+|x_{m+1}-x_m|\\leq |x_2-x_1|(A^{n-2}+\\cdots+A^{m-1})\\leq|x_2-x_1|\\sum_{k=N}^\\infty A^k=|x_2-x_1|\\frac{A^N}{1-A}\n\\]\nwhich tends to $0$ as $N\\to\\infty$, so $\\{x_n\\}$ is a Cauchy sequence, and $x=\\lim_{n\\to\\infty}x_n$ exists.\n\\[\nf(x)=f(\\lim_{n\\to\\infty}x_n)=\\lim_{n\\to\\infty}x_{n+1}=\\lim_{n\\to\\infty}x_n=x\n\\]\nso $x$ is a fixed point of $f$.\n\\medskip\n\n(d)\nThe zig-zag path consists of vertical segments moving from $(x_n,x_n)$ on $y=x$ to $(x_n.x_{n+1})$ on $y=f(x)$, and horizontal segments moving from $(x_n,x_{n+1})$ on $y=f(x)$ to $(x_{n+1},x_{n+1})$ on $y=x$.\n\n\\paragraph{23.}\n$f(x)=x$ has at most three roots, which are $x=\\alpha,\\beta,\\gamma$, and $f(x)<x$ for $x<\\alpha$,\\; $f(x)>x$ for $\\alpha<x<\\beta$,\\; $f(x)<x$ for $\\beta<x<\\gamma$,\\; $f(x)>x$ for $x>\\gamma$.\\; $f'(x)=x^2\\geq0$, so $f(x)$ is monotonically increasing, and is strictly monotonically increasing at $x\\neq0$.\n\\medskip\n\n(a) If $x_n<\\alpha$, then $x_{n+1}=f(x_n)<x_n$, which means $\\{x_n\\}$ is monotonically decreasing if $x_1<\\alpha$. If $\\{x_n\\}$ is bounded and therefore $\\alpha'=\\lim_{n\\to\\infty}x_n$ exists, then \n\\[\nf(\\alpha')=f(\\lim_{n\\to\\infty}x_n)=\\lim_{n\\to\\infty}f(x_n)=\\lim_{n\\to\\infty}x_{n+1}=\\alpha'\n\\]\nwhich means $\\alpha'<\\alpha$ is also a root of $f(x)=x$, a contradiction. Therefore, $x_n\\to-\\infty$ as $n\\to\\infty$.\n\\medskip\n\n(b)\nIf $\\alpha<x_n<\\beta$, then $x_{n+1}=f(x_n)>x_n$, and since $f(x)$ is monotonically increasing, $x_{n+1}=f(x_n)<f(\\beta)=\\beta$. So if $\\alpha<x_1<\\beta$, then $\\{x_n\\}$ is a monotonically increasing sequence bounded above by $\\beta$, which means the limit $\\beta'=\\lim_{n\\to\\infty}x_n$ exists, and since $\\beta'$ is a root of $f(x)=x$,\\; $\\beta'=\\beta$. Similarly, if $\\beta<x_1<\\gamma$, then $\\{x_n\\}$ is a monotonically decreasing sequence bounded below by $\\beta$, so $\\lim_{n\\to\\infty}x_n=\\beta$.\n\\medskip\n\n(c)\nSimilarly with (a), if $x_1>\\gamma$, then $\\{x_n\\}$ is a non-bounded monotonically increasing sequence, so $x_n\\to\\infty$ as $n\\to\\infty$.\n\n\\paragraph{24.}\n\\begin{equation*}\n\\begin{split}\n    f:\\quad & x_{n+1}-\\sqrt{\\alpha}=\\frac{1}{2}\\left(x_n+\\frac{\\alpha}{x_n} \\right)-\\sqrt{\\alpha}=\\frac{1}{2}\\left(1-\\frac{\\sqrt{\\alpha}}{x_n} \\right)\\left(x_n-\\sqrt{\\alpha} \\right)\\\\\n    g:\\quad & x_{n+1}-\\sqrt{\\alpha}=\\frac{\\alpha+x_n}{1+x_n}-\\sqrt{\\alpha}=\\frac{1-\\sqrt{\\alpha}}{1+x_n}(x_n-\\sqrt{\\alpha})\n\\end{split}\n\\end{equation*}\n$\\lim_{x_n\\to\\sqrt{\\alpha}}\\frac{1}{2}\\left(1-\\frac{\\sqrt{\\alpha}}{x_n} \\right)=0$, while $\\lim_{x_n\\to\\sqrt{\\alpha}}\\frac{1-\\sqrt{\\alpha}}{1+x_n}=\\frac{1-\\sqrt{\\alpha}}{1+\\sqrt{\\alpha}}\\neq0$, so $\\{x_n\\}$ obtained by $x_{n+1}=f(x_n)$ converges to $\\sqrt{\\alpha}$ faster than $\\{x_n\\}$ obtained by $x_{n+1}=g(x_n)$.\n\nThe zig-zag paths of $f$ and $g$ when $\\alpha=2$ are shown in Figure \\ref{fig:f}.\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.45\\textwidth]{f.PNG}\\qquad\n    \\includegraphics[width=0.45\\textwidth]{g.PNG}\n    \\caption{The zig-zag paths of $f$ and $g$ in Exercise 24.}\n    \\label{fig:f}\n\\end{figure}\n\n\\paragraph{25.}\n(a)\nThe tangent to the graph of $f$ at $(x_n,f(x_n))$ is $y=f'(x_n)(x-x_n)+f(x_n)$, which intersects with $x$-axis at $\\left(x_n-\\frac{f(x_n)}{f'(x_n)}\\,,\\,0\\right)=(x_{n+1}\\,,\\,0)$.\n\\medskip\n\n(b)\n$x_1>\\xi$. If $x_n>\\xi$, then $f(x_n)>0$, so\n\\[\nx_{n+1}=x_n-\\frac{f(x_n)}{f'(x_n)}<x_n\n\\]\nAlso, by Theorem 5.10, there is $t\\in(\\xi,x_n)$ such that\n\\[\n\\frac{f(x_n)-f(\\xi)}{x_n-\\xi}=f'(t)<f'(x_n)\n\\]\nsince $f'$ is monotonically increasing by $f''(x)>0$. Rearranging, \n\\[\nx_{n+1}=x_n-\\frac{f(x_n)}{f'(x_n)}>\\xi\n\\]\nTherefore, $\\{x_n\\}$ is monotonically decreasing and bounded below by $\\xi$. Let the limit be $\\xi'=\\lim_{n\\to\\infty}x_n$, then since $\\lim_{n\\to\\infty}x_{n+1}=\\lim_{n\\to\\infty}x_n=\\xi'$,\n\\[\n\\xi'=\\xi'-\\frac{f(\\xi')}{f'(\\xi')}\n\\]\nso $f(\\xi')=0$, which means $\\xi'=\\xi$.\n\\medskip\n\n(c)\nBy Taylor's Theorem, there is $t_n\\in(\\xi,x_n)$ such that\n\\[\nf(\\xi)=f(x_n)+f'(x_n)(\\xi-x_n)+\\frac{f''(t_n)}{2}(\\xi-x_n)^2\n\\]\nRearranging,\n\\[\nx_{n+1}-\\xi=x_n-\\frac{f(x_n)}{f'(x_n)}-\\xi=\\frac{f''(t_n)}{2f'(x_n)}(x_n-\\xi^2)\n\\]\n\n(d)\n\\[\nx_{n+1}-\\xi\\leq\\frac{1}{A}\\left[A(x_n-\\xi)\\right]^2\n\\]\nThe inequality holds for $n=1$. If it holds for $n=k$, so\n\\[\n0\\leq x_{k+1}-\\xi\\leq\\frac{1}{A}\\left[A(x_1-\\xi) \\right]^{2^n}\n\\]\nthen $x_{k+2}-\\xi\\geq0$ by (b), and\n\\[\nx_{k+2}-\\xi\\leq A(x_{k+1}-\\xi)^2\\leq\\frac{1}{A}\\left[A(x_1-\\xi)\\right]^{2^{k+1}}\n\\]\nso by induction, the inequality holds for every $n$.\n\nThe algorithms in Exercise 3.16 and 3.18 are Newton's methods applied on $x_n^2-\\alpha$ and $x_n^p-\\alpha$.\n\\medskip\n\n(e)\n$g(x)=x$ is equivalent to $f(x)=0$, so finding a fixed point of $g$ is finding the root of $f(x)$.\n\\[\ng'(x)=1-\\frac{\\left[f'(x) \\right]^2-f(x)f''(x)}{\\left[f'(x) \\right]^2}=\\frac{f(x)f''(x)}{\\left[f'(x) \\right]^2}\\leq\\frac{f(x)M}{\\delta^2}\\to0\n\\]\nas $x\\to\\xi$.\n\\medskip\n\n(f)\n\\[\nx_{n+1}=x_n-\\frac{{x_n}^{\\frac{1}{3}}}{\\frac{1}{3}x_n^{-\\frac{2}{3}}}=-2x_n\n\\]\nso $\\{x_n\\}$ is an alternating sequence such that $\\{|x_n|\\}\\to\\infty$ as $n\\to\\infty$.\n\n\\paragraph{26.}\nLet $x_0=a+\\frac{1}{2A}$. For $a\\leq x\\leq x_0$,\n\\[\n\\left|\\frac{f(x)-f(a)}{x-a} \\right|=\\left|f'(t) \\right|\\leq M_1\n\\]\nwhere $t\\in(a,x)\\in(a,x_0)$. Rearranging,\n\\[\n|f(x)|\\leq M_1(x-a)\\leq M_1(x_0-a)\\leq AM_0(x_0-a)=\\frac{M_0}{2}\n\\]\nsince $M_0$ is the least upper bound of $|f(x)|$, we have $M_0\\leq\\frac{M_0}{2}$, which means $M_0=0$, so $f(x)=0$ on $[a,a+\\frac{1}{2A}]$. Repeat the process for finite steps, we have $f(x)=0$ on $[a,b]$.\n\n\\paragraph{27.}\nLet $f(x)=y_2(x)-y_1(x)$, then $f$ is differentiable on $[a,b]$, and $f(a)=c-c=0$. If the inequality holds, then\n\\[\n|f'(x)|=|y_2'-y_1'|=|\\phi(x,y_2)-\\phi(x,y_1)|\\leq A|y_2-y_1|=A|f(x)|\n\\]\nso by Exercise 26,\\; $f(x)=0$, which means $y_2=y_1$, the solution is unique.\n\nConsider $f(x)$ which is the solution of $y'=\\sqrt{y}$ and $y(0)=0$. Since $y'=\\sqrt{y}\\geq0$, $y$ is monotonically increasing. Let $a$ be the real number such that $f(x)=0$ for $0\\leq x\\leq a$ and $f(x)>0$ for $x>a$. Let $F(x)=\\sqrt{f(x)}$, then $F'(x)=\\frac{f'(x)}{2\\sqrt{f(x)}}=\\frac{1}{2}$, so $F(x)=\\frac{1}{2}(x+c)$, and $f(x)=\\frac{(x+c)^2}{4}$. Since $f(a)=0$, we have $c=-a$. So the solution is \n\\[\nf(x)=\\begin{cases}\n0\\quad & 0\\leq x\\leq a\\\\\n\\frac{(x-a)^2}{4}\\quad & x>a\n\\end{cases}\n\\]\nwhere $a$ can be arbitrary.\n\n\\paragraph{28.}\n\\textit{statement:}\nLet $\\pmb{\\phi}$ be a vector-valued function in $R^k$ defined on a $(k+1)$-cell, given by $a\\leq x\\leq b$,\\; $\\alpha_j\\leq y_j\\leq \\beta_j$. If there is a constant $A$ such that\n\\[\n|\\pmb\\phi(x,\\V{y}_2)-\\pmb\\phi(x,\\V{y}_1) |\\leq A|\\V{y}_2-\\V{y}_1|\n\\]\nthen the initial-value problem\n\\[\n\\V{y}'=\\pmb{\\phi}(x,\\V{y}),\\quad \\V{y}(a)=\\V{c}\n\\]\nhas at most one solution.\n\\medskip\n\n\\textit{proof:}\nThe result in Exercise 26 holds for vector-valued function since by Theorem 5.19,\n\\[\n|\\V{f}(x)-\\V{f}(a)|\\leq|\\V{f}'(t)|(x-a)\\leq M_1(x_0-a)\\leq AM_0(x_0-a)\n\\]\nand the other parts of the proof remain the same as Exercise 26.\n\nLet $\\V{f}=\\V{y}_2(x)-\\V{y}_1(x)$ where $\\V{y}_2,\\,\\V{y}_1$ are the solutions of the initial-value problem, then the proof is the same as Exercise 27, except all the functions are vector-valued. So $\\V{y}_2=\\V{y}_1$, the solution is unique.\n\n\\paragraph{29.}\nLet $\\V{y}=(y_1,\\cdots,y_k)$ and $\\V{g}=(g_1,\\cdots,g_k)$ be vectors in $R^k$. Let $\\pmb\\phi$ be a function form $R^{k+1}$ to $R^k$ defined as \n\\[\n\\pmb\\phi(x,\\V{y})=(y_2,\\cdots,y_k,f(x)-\\V{g}\\cdot\\V{y})\n\\]\nIf $y_j=y^{(j-1)}$ for $1\\leq j\\leq k$, then\n\\[\ny_j'=y^{(j)}=y_{j+1}\\quad\\textit{for $1\\leq j\\leq k-1$}\\]\n\\[y_k'=y^{(k)}=f(x)-\\sum_{j=1}^k g_j(x)y^{j-1}=f(x)-\\sum_{j=1}^k g_j(x)y_j=f(x)-\\V{g}\\cdot\\V{y} \\]\n\\[\ny^{(j-1)}(a)=y_j(a)=c_j\\quad\\textit{for $1\\leq j\\leq k$}\n\\]\nso the initial-value problem given is equivalent to\n\\[\n\\V{y}'=\\pmb\\phi(x,\\V{y}),\\quad \\V{y}(a)=\\V{c}\n\\]\n$g_1,\\cdots,g_k$ are continuous real function on the compact space $[a,b]$, so $|g_j|$ is bounded, which means $|\\V{g}|$ is bounded. Let $|\\V{g}|\\leq M$, and let $A=\\sqrt{1+M^2}$, then\n\\begin{equation*}\n    \\begin{split}\n        |\\pmb\\phi(x,\\V{y}_b)-\\pmb\\phi(x,\\V{y}_a)| & =\\sqrt{\\sum_{j=2}^k(y_{bj}-y_{aj})^2+|\\V{g}\\cdot(\\V{y}_b-\\V{y}_a)|^2}\\\\\n        & \\leq \\sqrt{|\\V{y}_b-\\V{y}_a|^2+|\\V{g}|^2|\\V{y}_b-\\V{y}_a|^2 }\\\\\n        & =\\sqrt{1+|\\V{g}|^2}|\\V{y}_b-\\V{y}_a|\\\\\n        & \\leq A|\\V{y}_b-\\V{y}_a|\n    \\end{split}\n\\end{equation*}\nso by Exercise 28, the solution is unique.\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "b63efdde8181e9e35a4781fc2e04fa964afcdb8b", "size": 26303, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Principles of Mathematical Analysis/Chapter 05/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Principles of Mathematical Analysis/Chapter 05/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Principles of Mathematical Analysis/Chapter 05/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2311046512, "max_line_length": 501, "alphanum_fraction": 0.5748773904, "num_tokens": 12652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7772998663336158, "lm_q1q2_score": 0.44888707016721413}}
{"text": "\\documentclass[revision-guide.tex]{subfiles}\n%% Current Author: BC\n\\setcounter{chapter}{5}\n\\begin{document}\n\\chapter{Waves}\n\\begin{content}\n\\item progressive waves\n\\item longitudinal and transverse waves\n\\item electromagnetic spectrum\n\\item polarisation\n\\item refraction\n\\end{content}\n\n\\section*{Candidates should be able to:}\n\\spec{understand and use the terms displacement, amplitude, intensity, frequency, period, speed and wavelength}\n\nAll waves consist of oscillations. The oscillations could be of particles, for example in a sound wave, or of an electromagnetic field, as in a light wave.\n\nThe following terms are used to describe properties of waves:\n\\begin{itemize}\n\\item \\textbf{displacement}: This is a measurement of the distance and direction away from the equilibrium position.\n\\item \\textbf{amplitude}: The maximum displacement of the oscillation, represented by $A$.\n\\item \\textbf{intensity}: The power of the wave per unit area, represented by $I$. The unit of intensity is $Wm^{-2}$.\n\\item \\textbf{frequency}: The number of oscillations per second, represented by $f$.\n\\item \\textbf{period}: The time taken for one oscillation, represented by $T$.\n\\item \\textbf{speed}: The speed of a wave represented by $v$. This will depend on the medium through which the wave is travelling.\n\\item \\textbf{wavelength}: The distance over which a wave's shape repeats, represented by $\\lambda$.\n\n\\end{itemize}\n\n\\spec{recall and apply $f = \\frac{1}{T}$ to a variety of situations not limited to waves}\n\nThis equation follows from the definition of the frequency and time period of a wave. Remember to use Hertz as the unit for frequency and seconds as the unit for period.\n\n\\spec{recall and use the wave equation $v=f\\lambda$}\n\n$$\\text{speed} = \\frac{\\text{distance travelled}}{\\text{time taken}}$$\n\nFor a wave, the distance travelled in one time period, $T$, is the wavelength, $\\lambda$. Therefore we can write\n\n\\[v = \\frac{\\lambda}{T}\\]\n\nThen, using the equation $f=\\frac{1}{T}$, we can write:\n\n$$v = f\\lambda$$\n\nThis is known as the wave equation and can be applied to all waves. The frequency of the wave generally depends on the source of the wave or how it is produced and the speed depends on the medium through which the wave is travelling.\n\n\\spec{recall that a sound wave is a longitudinal wave which can be described in terms of the displacement of molecules or changes in pressure}\n\nWhen a sound wave travels through a material, the collisions of molecules are parallel to the direction of travel. Energy is transferred through these collisions and the speed of the sound wave will depend on factors such as the density of the material and the temperature.\n\nWhen a sound wave is viewed on an oscilloscope, it looks as though the oscillations are perpendicular to the direction of travel, as in a transverse wave. The y-axis can represent either the displacement of molecules (still in the parallel direction) from their equilibrium position, or the difference in pressure.\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{figs/chapt-6/soundwave.JPG}\n\\caption{Sound wave in air (credit: hyperphysics)}\n\\label{Sound wave in air}\n\\end{figure}\n\n\\spec{recall that light waves are transverse electromagnetic waves, and that all electromagnetic waves travel at the same speed in a vacuum}\n\\spec{recall the major divisions of the electromagnetic spectrum in order of wavelength, and the range of wavelengths of the visible spectrum}\n\nElectromagnetic waves are transverse waves where the oscillations are perpendicular to the direction of travel. In all electromagnetic waves there are actually two waves oscillating perpendicular to each other and to the direction of travel. One is an oscillating magnetic field; the other an oscillation electric field.\n\n\\begin{figure}[h!]\n\\includegraphics[width=9cm]{figs/chapt-6/emwave.png}\n\\centering\n\\caption{oscillations in an electromagnetic wave}\n\\label{emwave}\n\\end{figure}\n\nThe electromagnetic spectrum is the name for the arrangement and classification of electromagnetic waves in order of their wavelengths or frequencies.\n\nThe electromagnetic spectrum is shown below in order of increasing wavelength.\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{figs/chapt-6/emspectrum.jpg}\n\\caption{The electromagnetic spectrum (Credit:miniphysics.com)}\n\\end{figure}\n\nYou can see that the visible light spectrum makes up a small part of the electromagnetic spectrum, with wavelengths between 400 - 700 nm.\n\n\\spec{recall and use that the intensity of a wave is directly proportional to the square of its amplitude}\n\nIf the amplitude of a wave varies sinusoidally, the intensity will vary as sine squared. Therefore the following expression can be used:\n\n$$I \\propto A^2$$\n\n\\spec{use graphs to represent transverse and longitudinal waves, including standing waves}\n\n\\emph{Note: Standing waves will be covered in Chapter 7 on Superposition}\n\nThere are two types of graphs used to represent transverse and longitudinal waves, shown in Figure \\ref{twographs}. You need to be careful as they look similar.\n\nThe first graph plots the motion of one part of the wave with time, for example the motion of one water molecule as a water wave goes by. The x-axis on this graph can give you the time period of the wave.\n\nThe second graph is a snapshot of a section of the wave at one particular instant in time. On this graph the wavelength can be measured from the x-axis.\n\n\\begin{figure}[h]\n    \\begin{center}\n    \\begin{tikzpicture}[domain=0:10,samples=200]\n        \\draw[very thin,color=gray] (-0.1,-1.5) grid (9.9,1.5);\n        \\draw[->] (-0.2,0) -- (10.2,0) node[right] {$t$};\n        \\draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$};\n        \\draw plot (\\x,{1.2*sin(50*pi*\\x)});\n        \\draw[<->] (1.8,-1.5) -- (4,-1.5) node[midway, below] {$T$};\n    \\end{tikzpicture}\n    \\begin{tikzpicture}[domain=0:10,samples=200]\n        \\draw[very thin,color=gray] (-0.1,-1.5) grid (9.9,1.5);\n        \\draw[->] (-0.2,0) -- (10.2,0) node[right] {$x$};\n        \\draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$};\n        \\draw plot (\\x,{1.2*sin(40*pi*\\x)});\n        \\draw[<->] (3.55,1.5) -- (6.5,1.5) node[midway, above] {$\\lambda$};\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption{Two graphs of a wave}\n    \\label{twographs}\n\\end{figure}\n\n\n\n\\spec{explain what is meant by a plane-polarised wave}\n\\spec{recall Malus' Law ($I \\propto \\cos^2\\theta $) and use it to calculate the amplitude and intensity of transmission through a polarising filter}\n\nA plane-polarised wave is one where there is only \\textbf{one} allowed direction of oscillation. This is only applicable to transverse waves where there are multiple allowed modes of oscillation which are all perpendicular to the direction of travel. A longitudinal wave cannot be polarised as there is already only one direction of oscillation - the direction parallel to that of travel. All electromagnetic waves can be polarised.\n\nConsider visible light as an example of a polarised wave. There are 4 ways in which light can be polarised.\n\n\\begin{itemize}\n\\item\\textbf{Transmission}: A polarising filter can be used to polarise light. A filter is made up of chains of molecules that will absorb one direction of oscillation of the light wave, therefore only letting through the perpendicular direction. Note that this 'one' direction is a simplificiation as it encompasses oscillations in both the electric and magnetic fields. The \\emph{axis of transmission} of a filter is the direction of oscillation that the filter will let through.\n\n\\begin{figure}[h]\n\\includegraphics[width=10cm]{figs/chapt-6/polarisedwave.JPG}\n\\centering\n\\caption{diagram showing the operation of a polarising filter (Credit: isaacphysics)}\n\\end{figure}\n\nAs unpolarised light passes through a polaroid filter, its intensity will drop of 50\\% of what it originally was. If light that is already polarised is incident on a filter with a perpendicular axis of transmission, none will pass through. If light that is already polarised is incident on a filter with a parallel axis of transmission, then all of the light will pass through. For cases other than parallel or perpendicular, Malus' Law can be used.\n\nMalus' Law can be used to work out how the intensity of polarised light changes as it passes through a polaroid filter. The angle $\\theta$ is the angle \\emph{between} the direction of polarisation of the incident light and the axis of transmission of the polaroid. If you start with unpolarised light, $\\theta$ is the angle between the two polaroids.\n\nMalus' Law states that the intensity of the transmitted light is proportional to the square of $\\cos\\theta$.\n$$I \\propto \\cos^2\\theta $$\nIf the incident intensity is $I_0$, then we can write Malu's Law as:\n$$I = I_0\\cos^2\\theta$$\n\nNote that if you are dealing with \\emph{amplitude} instead of intensity then you must take the square root to give $\\cos\\theta$.\n\n\\item\\textbf{Reflection}: Light can be partially polarised on reflection from certain non metallic surfaces, such as water. The reflected light will be polarised parallel to the surface. This is why polaroid sunglasses are useful as they can cut out the glare from water or roads.\n\n\\item\\textbf{Refraction}: Light can be partially polarised, often in two perpendicular directions, when passing through some materials, such as calcite. Specific details will always be given to you in a question.\n\n\\item\\textbf{Scattering}: Light from the Sun scatters of molecules in our atmosphere and is partially polarised depending on the direction that you are looking at the sky. Again, specific details will always be provided in a question.\n\n\\end{itemize}\n\n\\spec{recognise and use the expression for refractive index\n\\[ n = \\frac{\\sin{\\theta_1}}{\\sin{\\theta_2}} = \\frac{v_1}{v_2}\\]}\n\nWhen a wave crosses a boundary which involves a change in speed, refraction occurs. This concept should be familiar from GCSE.\n\n%Diagram\n\nFor light, the refractive index of a medium is the ratio of the speed of light in a vacuum, $c$, to the speed of light in the medium, $v$.\n\\[n = \\frac{c}{v}\\]\n\nTherefore the refractive index of a material is always greater than one.\n\nIf a wave now crosses a boundary between material 1 and material 2, with the angle of incidence being $\\theta_1$ and the angle of refraction being $\\theta_2$, the following relationship (Snell's Law) applies:\n\n\\[ \\frac{n_2}{n_1} = \\frac{\\sin{\\theta_1}}{\\sin{\\theta_2}}\\]\n\nAs the refractive index of a material is inversely proportional to the speed of light in that material, we know that\n\n\\[\\frac{n_2}{n_1} = \\frac{v_1}{v_2} \\]\n\nSnell's Law now becomes\n\n\\[ \\frac{n_2}{n_1} = \\frac{\\sin{\\theta_1}}{\\sin{\\theta_2}} =  \\frac{v_1}{v_2}\\]\n\nThis is the most general form of Snell's Law. For the specific case where material 1 is air we can take $n_1 = 1$ as the speed of light in air is so close to the speed of light in a vacuum. Now, replacing $n_2$ with $n$, the equation is:\n\n\\[ n = \\frac{\\sin{\\theta_1}}{\\sin{\\theta_2}} = \\frac{v_1}{v_2}\\]\n\nThis is the equation given in the specification. Be careful as it only applies to the case where material 1 is air and this might not always be the case.\n\n\\spec{derive and recall $\\sin{c} = \\frac{1}{n}$ and use it to solve problems}\n\nIf we take Snell's Law for the case where light is travelling from a material of higher refractive index into a material with lower refractive index, $n_1 > n_2$, we know that the light will bend away from the normal with the angle of refraction, $\\theta_2$ being larger than the angle of incidence, $\\theta_1$. If the angle of incidence is increased until the angle of refraction is $90^{\\circ}$, then the angle of incidence is now called the \\emph{critical angle}, as above this angle, \\emph{total internal reflection} will occur.\n\nNow we can put this into Snell's Law. $\\theta_1$ is now $c$, the critical angle and $\\theta_2$ is now $90^{\\circ}$.\n\n$$\\frac{n_2}{n_1} = \\frac{\\sin{\\theta_1}}{\\sin{\\theta_2}}$$\nThis now becomes:\n$$\\frac{n_2}{n_1} = \\frac{\\sin{c}}{\\sin{90^{\\circ}}}$$\n\nAs $\\sin{90^{\\circ}} = 1$, the most general equation to find the critical angle is:\n$$\\frac{n_2}{n_1} = \\sin{c}$$\nor\n$$\\frac{n_1}{n_2} = \\frac{1}{\\sin{c}}$$\n\nIn the specification, the equation is given for the specific case where material 2 is air, therefore $n_2$ can be taken to be 1. This gives the equation:\n$$\\sin{c} = \\frac{1}{n}$$\n\n\\spec{recall that optical fibres use total internal reflection to transmit signals}\n\\spec{recall that, in general, waves are partially transmitted and partially reflected at an interface between media.}\n\nShould be familiar from GCSE.\n\n\\end{document}\n", "meta": {"hexsha": "262d4f476c5f1749ea9ee69c346a51219c399255", "size": 12572, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6-waves.tex", "max_stars_repo_name": "dhruvrattan/physicsrevision", "max_stars_repo_head_hexsha": "99bf9346cd40ebe6f312f164d731b7010b86534a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2017-03-13T19:37:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-08T21:47:07.000Z", "max_issues_repo_path": "6-waves.tex", "max_issues_repo_name": "dhruvrattan/physicsrevision", "max_issues_repo_head_hexsha": "99bf9346cd40ebe6f312f164d731b7010b86534a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 23, "max_issues_repo_issues_event_min_datetime": "2016-12-19T16:46:07.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-24T08:14:03.000Z", "max_forks_repo_path": "6-waves.tex", "max_forks_repo_name": "dhruvrattan/physicsrevision", "max_forks_repo_head_hexsha": "99bf9346cd40ebe6f312f164d731b7010b86534a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2016-12-19T16:16:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-09T13:48:59.000Z", "avg_line_length": 59.3018867925, "max_line_length": 532, "alphanum_fraction": 0.7521476297, "num_tokens": 3247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4488274449900026}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Chapter 4: EW_and_toda *********************************\n%*******************************************************************************\n\n\\chapter{Einstein--Weyl structures and $SU(\\infty)$--Toda fields} \\label{chap:EW_and_toda}\n\nIn this chapter, we focus on the four dimensional Einstein manifolds that arise from the projective to Einstein correspondence in the case $n=2$. As discussed in Chapter \\ref{chap:intro2}, it is shown in \\cite{DM} that the Einstein manifolds in this subclass have ASD Weyl tensor, and are therefore associated with a twistor space \\cite{penrose}. If they also carry a Killing vector field arising from a symmetry of the underlying projective surface, one can extract solutions of the $SU(\\infty)$--Toda equation via symmetry reduction to Lorentzian Einstein--Weyl structures in $2+1$ dimensions \\cite{JT,Tod_note}.\n\nThe aim of this chapter is to investigate the Einstein--Weyl structures obtainable in this way, resulting in several examples of new, explicit solutions of the Toda equation. We also give an explicit criterion for a vector field that generates a symmetry of a Weyl structure, and prove some results about the Einstein manifold and corresponding twistor space arising from the flat projective surface $\\RP^2$. The content of this chapter is based on some of the work in \\cite{DW} and was done in collaboration with Maciej Dunajski.\n\nIn the case $n=2$ we will write the metric and symplectic form as\n\\begin{eqnarray}\ng =& dz_{A'} \\odot dx^{A'} - (\\Gamma^{C'}_{A'B'}z_{C'}-z_{A'}z_{B'}-\\Rho_{A'B'})dx^{A'} \\odot dx^{B'}, \n \\label{eq:g4} \\\\\n{\\Omega} =& dz_{A'}\\wedge dx^{A'} + \\Rho_{A'B'}dx^{A'} \\wedge dx^{B'}, \\qquad A', B', C'=0, 1. \\label{eq:Omega4}\n\\end{eqnarray}\nwhere we have replaced $\\{\\zeta_i\\}$ with $\\{z_{A'}\\}$ and shifted the indices from $i,j=1,2$ to $A',B'=0,1$. This is helpful for the twistorial calculations because it agrees with the usual notation for two--component spinor indices. Note that a change of projective connection is now given by\n\\be\n\\label{proj_change}\n\\Gamma^{C'}_{A'B'} \\rightarrow \\Gamma^{C'}_{A'B'} + \\delta^{C'}_{A'}\\Upsilon_{B'} + \\delta^{C'}_{B'}\\Upsilon_{A'}, \\qquad z_{A'}\\rightarrow z_{A'} + \\Upsilon_{A'}, \\qquad A',B',C'=0,1.\n\\ee\n\n\\section{Background}\n\\label{sec:background}\n\n\n\n\\subsection{Anti--self--duality, spinors and totally null distributions} \\label{sec:ASD'ty}\nLet $M$ be an oriented four dimensional manifold with a metric\n$g$ of signature $(2, 2)$. The Hodge operator $\\ast$ on the space of two forms is an involution, and induces a decomposition \\cite{AHS}\n\\be \n\\label{split_ad}\n\\Lambda^{2}(T^*M) = \\Lambda_{-}^{2}(T^*M) \\oplus \\Lambda_{+}^{2}(T^*M)\n\\ee\nof two-forms\ninto ASD\nand SD  components, which\nonly depends on the conformal class of $g$. \nThe Riemann tensor of $g$ \ncan be thought of\nas a map $\\mathcal{R}: \\Lambda^{2}(T^*M) \\rightarrow \\Lambda^{2}(T^*M)$ which admits a decomposition   under (\\ref{split_ad}):\n\\be \\label{decomp}\n{\\mathcal R}=\n\\left(\n\\mbox{\n\\begin{tabular}{c|c}\n&\\\\\n$C_++\\frac{R}{12}$&$\\phi$\\\\ &\\\\\n\\cline{1-2}&\\\\\n$\\phi$ & $C_-+\\frac{R}{12}$\\\\&\\\\\n\\end{tabular}\n} \\right).\n\\ee\nHere $C_{\\pm}$ are the SD and ASD parts \nof the Weyl conformal curvature tensor\\footnote{Note this is a different object to the projective Weyl tensor discussed in Chapter \\ref{chap:intro2}.}, $\\phi$ is  the\ntrace-free Ricci curvature, and $R$ is the scalar curvature which acts\nby scalar multiplication. The metric $g$ is Einstein if $\\phi=0$, and the corresponding conformal structure $[g]$ is ASD if $C_+=0$. We will call $g$ \\textit{conformally ASD} if it has ASD Weyl tensor. If both of these conditions are satisfied then the Riemann tensor is also ASD.\n\n\\subsubsection{Two--component spinors}\nThe symmetry group of a metric in signature $(2,2)$ decomposes under the Lie group isomorphism\n\\[\nSO(2,2)\\cong SL(2,\\R) \\times SL(2,\\R)/\\mathbb{Z}_2.\n\\]\nLocally there exist real rank two vector bundles $\\spp, \\spp'$  (spin bundles) over $M$ such that \\cite{penroserindler}\n\\be\n\\label{can_bun_iso}\nT M\\cong {\\spp}\\otimes {\\spp'}\n\\ee\nis a  canonical bundle isomorphism. We will use the usual notation $\\iota^A\\in\\Gamma(\\spp),\\ \\pi^{A'}\\in\\Gamma(\\spp')$, where $A,A'=0,1$. There are unique skew--symmetric sections $\\varepsilon\\in\\Gamma(\\spp\\otimes\\spp)$ and $\\varepsilon'\\in\\Gamma(\\spp'\\otimes\\spp')$, and one can argue that\n\\be \\label{eq:g(UAA'VBB'}\ng_{ab}\\xi^a\\tilde{\\xi}^b=\\varepsilon_{AB}\\varepsilon_{A'B'} \\xi^{AA'}\\tilde{\\xi}^{BB'}\n\\ee\nfor vector fields $\\xi,\\tilde{\\xi}$ on $M$. The bundles $\\spp$ and $\\spp'$ inherit connections from $^{\\bf g}\\nabla$ for which $\\varepsilon,\\varepsilon'$ are parallel.\n\nWe identify $\\spp$ with its dual according to\n\\[\n\\iota_A=\\iota^B\\varepsilon_{BA},\\qquad \\iota^A=\\varepsilon^{AB}\\iota_B,\n\\]\nand similarly for $\\spp'$. Note that the contraction is always over adjacent indices descending to the right, and $\\varepsilon^{AB}\\varepsilon_{CB}=\\delta_C^{\\ A}$. In higher valence spinors, the relative order of primed and unprimed indices is unimportant.\n\nA vector $\\xi\\in \\Gamma(TM)$ is called null if $g(\\xi, \\xi)=0$. For $\\tilde{\\xi}=\\xi$ the right hand side of (\\ref{eq:g(UAA'VBB'}) is just the determinant of $\\xi^{AA'} $ viewed as a matrix, so any null vector is of the form\n$\\xi=\\iota \\otimes \\pi$ where $\\iota$, and $\\pi$ are sections of\n$\\spp$ and $\\spp'$ respectively. The antisymmetry of $\\varepsilon$ means that $\\varepsilon(\\iota,\\iota)=0$ for any section $\\iota\\in\\Gamma(\\spp)$ (and similarly for any $\\pi\\in\\spp'$), so the converse is also true (i.e. any vector that can be written $V=\\iota\\otimes \\pi$ is null).\n\nSince the symplectic structures $\\varepsilon_{AB},\\varepsilon_{A'B'}$ are the unique skew--symmetric two--index spinors up to scale, any spinor of valence $n$ which is skew on a pair of indices can be factorised as the tensor product of a spinor of valence $n-2$ and either $\\varepsilon$ or $\\varepsilon'$. This leads to the decomposition of a two--form $F_{ab}=F_{AA'BB'}=F_{ABA'B'}$ as\n\\[\nF_{ABA'B'} = \\varepsilon_{AB}\\Phi_{A'B'} + \\varepsilon_{A'B'}\\Psi_{AB},\n\\]\nwhere $\\Phi_{A'B'}=\\Phi_{(A'B')}$ and $\\Psi_{AB}=\\Psi_{(AB)}$. One can show using an analogous decomposition of the volume form that $\\Phi_{A'B'}$ and $\\Psi_{AB}$ are the SD and ASD parts of $F_{ab}$ respectively.\n\n\\subsubsection{The nonlinear graviton}\nAny two dimensional distribution on a four--manifold $M$ can be expressed as the kernel of a two--form, and we define a distribution to be (A)SD if the corresponding two--form is (A)SD. Taking any $\\iota^A\\in\\Gamma(\\spp)$, the two--form $\\iota_A\\iota_B\\varepsilon_{A'B'}$ defines an ASD distribution $D_\\beta=\\{\\iota^Aw^{A'},w^{A'}\\in\\Gamma(\\spp')\\}$ which is totally null in the sense that $g(\\xi,\\tilde{\\xi})=0$ for all $\\xi,\\tilde{\\xi}\\in\\Gamma(D)$. We call this a $\\beta$--distribution. Note that it is only defined up to scale, which means that there is an $\\RP^1$ worth of $\\beta$--planes at every point in $M$. Given any $\\pi^{A'}\\in\\Gamma(\\spp')$, one can similarly define a totally null SD distribution called an $\\alpha$--distribution by\n\\be \\label{eq:alpha_dist}\nD_\\alpha = \\{\\iota^A\\pi^{A'},\\iota^{A}\\in\\Gamma(\\spp)\\}=\\mathrm{span}\\{\\pi^{A'}\\mathsf{e}_{AA'}\\},\n\\ee\nwhere $\\{\\mathsf{e}_{AA'}\\}$ is a null tetrad of vector fields.\n\nAn $\\alpha$--surface (respectively $\\beta$--surface) is a two dimensional surface in $M$ which is tangent to an $\\alpha$--($\\beta$--)distribution at every point. A foliation by $\\alpha$--surfaces exists if and only if the corresponding distribution (\\ref{eq:alpha_dist}) is Frobenius integrable. Penrose's nonlinear graviton Theorem \\cite{penrose} states that a \nmaximal, three dimensional family of $\\alpha$--surfaces exists in $M$ if and only if its conformal curvature is ASD, i.e. $C_+=0$. Existence of such a family is equivalent to the distribution (\\ref{eq:alpha_dist}) being integrable for any $\\pi^{A'}$. We can state this condition as integrability of the lift of the distribution (\\ref{eq:alpha_dist}) to $\\spp'$. This is given by\n\\be \\label{eq:twistor_dist}\n\\mathcal{D}=\\mathrm{span}\\{L_A:=\\pi^{A'}\\tilde{\\mathsf{e}}_{AA'}\\},\n\\ee\nwhere the vectors\n\\[\n\\tilde{\\mathsf{e}}_{AA'}=\\mathsf{e}_{AA'} - \\Gamma^{C'}_{AA'B'}\\pi^{B'}\\frac{\\p}{\\p\\pi^{C'}}\n\\]\nare the lifts of the null tetrad $\\{\\mathsf{e}_{AA'}\\}$ to $\\spp'$, and $\\Gamma^{C'}_{AA'B'}$ are the components of the \\textit{spin connection} on $\\spp'$, which is inherited from the Levi--Civita connection of $g$ on $TM$. We call $\\mathcal{D}$ the \\textit{twistor distribution}.\n\nIn fact, Penrose considers four dimensional \\textit{complex} manifolds\\footnote{Note that familiar facts from real geometry such as a unique Levi--Civita connection and the Frobenius theorem carry over to holomorphic geometry. See \\cite{LeBrun83} for details.} $M$ carrying a metric which is \\textit{holomorphic} in the sense that the metric components depend on the coordinates on $M$ and not on their complex conjugates. Then $\\spp,\\spp'$ are complex vector bundles over $M$ and $\\varepsilon,\\varepsilon'$ are holomorphic symplectic forms. A real conformally ASD metric in a given signature can then be obtained by choosing the correct reality conditions. In neutral signature, complex conjugation is a map from $\\spp$ to itself (or from $\\spp'$ to itself) which simply replaces each component of a spinor with its complex conjugate. Thus the reality conditions in neutral signature amount to identifying spinors with their complex conjugates.\n\nThe \\textit{twistor space} $\\mathscr{T}$ of $M$ is then defined as the three dimensional complex manifold comprising the set of all $\\alpha$--surfaces in $M$. Each point $m\\in M$ corresponds to a subset $\\mathscr{L}_m\\subset\\mathscr{T}$ of $\\alpha$--surfaces which pass through $m$. Since an $\\alpha$--surface at $m$ is defined by a $\\pi^{A'}\\in\\spp'|_m$ up to scale, $\\mathscr{L}_m$ is an embedding $\\CP^1\\subset\\mathscr{T}$. The \\textit{correspondence space} $\\mathcal{F}=M\\times\\CP^1$ has local coordinates $(x^a,\\lambda):=(x^a,\\pi_{0'}/\\pi_{1'})$, where $\\pi^{A'}$ parametrises the set of $\\alpha$--surfaces through the point in $M$ with coordinates $x^a$. Note that $\\mathcal{F}$ can be obtained from the primed spin bundle $\\spp'\\rightarrow M$ by projectivising each fibre, and carries a distribution $\\tilde{\\mathcal{D}}=\\mathrm{span}\\{\\tilde{L}_A\\}$ given by the push forward of the twistor distribution $\\mathcal{D}$ to $\\mathcal{F}=\\PP(\\spp')$. We also call $\\tilde{\\mathcal{D}}$ the twistor distribution. Note that $\\mathcal{F}$ has the alternative definition $\\mathcal{F}=\\{(Z,m)\\in \\mathscr{T}\\times M \\ :\\  Z\\in \\mathscr{L}_m\\}$, leading to the double fibration\n\\[\nM\\leftarrow\\mathcal{F}\\rightarrow\\mathscr{T},\n\\]\nwhere the map $\\mathcal{F}\\rightarrow\\mathscr{T}$ is the quotient of $\\mathcal{F}$ by the leaves of the distribution $\\tilde{\\mathcal{D}}$. A twistor function is a function on $\\mathcal{F}$ which is constant along $\\tilde{\\mathcal{D}}$. %We can also define the \\textit{non--projective twistor space} of $M$ as the quotient of $\\spp'$ by the leaves of $\\mathcal{D}$.\n\nThe nonlinear graviton allows us to express an ASD conformal structure in terms of the algebraic geometry of $\\mathscr{T}$. First note that if two points $m_1,m_2\\in M$ are null--separated, then the corresponding curves $\\mathscr{L}_{m_1},\\mathscr{L}_{m_2}$ intersect at a single point. This is because any null geodesic must have a tangent vector field of the form $\\iota^A\\pi^{A'}$ for some sections $\\iota^A\\in\\Gamma(\\spp)$ and $\\pi^{A'}\\in\\Gamma(\\spp')$, and thus the geodesic is contained within the unique $\\alpha$--surface spanned by $\\pi^{A'}\\mathsf{e}_{AA'}$. This unique $\\alpha$--surface corresponds to the point in $\\mathscr{T}$ where the curves $\\mathscr{L}_{m_1},\\mathscr{L}_{m_2}$ meet.\n\nIn order to understand this correspondence at an infinitesimal level and thereby explicitly recover an ASD conformal structure from $\\mathscr{T}$, we need to understand the \\textit{normal bundle} $\\mathbb{N}(\\mathscr{L}_m):=\\cup_{Z\\in \\mathscr{L}_m}\\{T_Z\\mathscr{T}/T_Z\\mathscr{L}_m\\}$ over a $\\CP^1$ embedding $\\mathscr{L}_m$. This is evidently a complex vector bundle, and in fact it is a \\textit{holomorphic} vector bundle, meaning that the total space is a complex manifold and the projection $\\mathbb{N}(\\mathscr{L}_m)\\rightarrow\\mathscr{L}_m$ is holomorphic. It is thus subject to the following theorem due to Birkhoff and Grothendieck (see for example \\cite{complex_mfds} for a proof).\n\\begin{theo}[Birkhoff--Grothendieck]\nAny rank $k$ holomorphic vector bundle over $\\CP^1$ is isomorphic to a direct sum of $k$ complex line bundles $\\mathcal{O}(n_i),1\\leq i\\leq k$, each with first Chern class $n_i$. \n\\end{theo}\n\nThe first Chern class completely classifies complex line bundles topologically. For us, $\\mathcal{O}(n),n\\in\\mathbb{Z}$ will mean a line bundle over $\\CP^1=\\mathcal{U}_0\\cup\\mathcal{U}_1$, where $\\mathcal{U}_i=\\{Z_i\\neq 0\\}\\subset\\CP^1$ for homogeneous coordinates $[Z_0,Z_1]^T$ on $\\CP^1$, with transition functions such that local trivialisations $(\\lambda_i,v_i)\\in\\mathcal{U}_i\\times\\mathbb{C}$ are related on the overlap by $v_1=\\lambda_0^{-n}v_0$, where $\\lambda_0=\\lambda_1^{-1}=Z_1/Z_0$. Note that $\\mathcal{O}(-n)$ is dual to $\\mathcal{O}(n)$, and $\\mathcal{O}(n)$ is the tensor product of $n$ copies of $\\mathcal{O}(1)$. A section of $\\mathcal{O}(n)$ is represented by functions $\\sigma_i(\\lambda_i)$ such that $(\\lambda_0,\\sigma_0(\\lambda_0))$ and $(\\lambda_1,\\sigma_1(\\lambda_1))$ correspond to the same point, i.e.\n\\[\n\\sigma_1(\\lambda_1)=\\lambda_0^{-n}\\sigma_0(\\lambda_0).\n\\]\nIf we expand these as power series in the local coordinates and use the fact that ${\\lambda}_1=\\lambda_0^{-1}$, we find by equating coefficients that they are polynomials of degree at most $n$, making the space of global holomorphic sections $(n+1)$--dimensional for $n\\geq 0$.\n\n%We now define the \\textit{correspondence space} $\\mathcal{F}=M\\times\\CP^1$ with local coordinates $(x^a,\\lambda):=(x^a,\\pi_{0'}/\\pi_{1'})$, where $\\pi^{A'}$ parametrises the set of $\\alpha$--surfaces through the point in $M$ with coordinates $x^a$. Note that $\\mathcal{F}$ can be obtained from the primed spin bundle $\\spp'\\rightarrow M$ by projectivising each fibre. Now consider a holomorphic function on $\\spp'$ which is homogeneous of degree $n$ in the fibres. This corresponds to a section of $\\mathcal{O}(n)$ over the $\\CP^1$ factor of $\\mathcal{F}$. \n\n%The correspondence space has the alternative definition\n%\\[\n%\\mathcal{F}=\\{(Z,p)\\in \\mathscr{T}\\times M \\ :\\  Z\\in L_p\\},\n%\\]\n%leading to the double fibration\n%\\[\n%M\\xleftarrow{r}\\mathcal{F}\\xrightarrow{q}\\mathscr{T}.\n%\\]\n%We are now ready to state the following lemma.\n\n%\\begin{lemma}[\\cite{penrose}]\n%The normal bundle of the holomorphic curves $L_p=q(r^{-1}(p))$ corresponding to points $p\\in M$ can be identified with $\\mathcal{O}(1)\\oplus\\mathcal{O}(1)$.\n%\\end{lemma}\n%\\noindent\n%{\\bf Proof.} The double fibration picture allows us to identify the normal bundle with the quotient $r^*(T_pM)/\\mathrm{span}\\{L_A\\}$. In their homogeneous form the operators $L_A$ have weight one, and the distribution spanned by them is isomorphic to the bundle $\\mathbb{C}^2\\otimes\\mathcal{O}(-1)$. The definition of the normal bundle as a quotient gives the exact sequence\n%\\[\n%0\\rightarrow \\mathbb{C}^2\\otimes\\mathcal{O}(-1)\\rightarrow\\mathbb{C}^4\\rightarrow \\mathbb{N}\\rightarrow 0\n%\\]\n%and thus $\\mathbb{N}=\\mathcal{O}(1)\\oplus\\mathcal{O}(1)$, since the last map is given explicitly by $V^{AA'}\\mapsto V^{AA'}\\pi_{A'}$ in spinor notation.\n%\\mynote{I don't understand this proof. I basically copied it out of Maciej's book. It might be better to just explain it rather than stating it formally as a lemma.}\n%\\koniec\n\nThe nonlinear graviton Theorem can now be stated as follows.\n\\begin{theo}[\\cite{penrose}]\nThere is a one--to--one correspondence between holomorphic ASD conformal structures and three dimensional complex manifolds containing a four parameter family of $\\CP^1$ embeddings with normal bundle $\\mathcal{O}(1)\\oplus\\mathcal{O}(1)$.\n\\end{theo}\n\\noindent\nFrom the results of Kodaira \\cite{Kodaira} we have that a vector at a point $m\\in M$ corresponds to a holomorphic section of the normal bundle $\\mathcal{O}(1)\\oplus\\mathcal{O}(1)$ of the curve $\\mathscr{L}_m$ in $\\mathscr{T}$ (which we know from above belongs to a four dimensional space). Penrose shows that we obtain an ASD conformal structure from $\\mathscr{T}$ by defining a vector to be null if the corresponding holomorphic section of $\\mathcal{O}(1)\\oplus\\mathcal{O}(1)$ has a zero. This is the infinitesimal version of the intersection condition on $\\mathscr{L}_{m_1}$ and $\\mathscr{L}_{m_2}$ above. %Note that the vanishing of such a section is a quadratic condition, since $V^{AA'}\\pi_{A'}$ can be solved for $\\pi_{A'}$ if $\\mathrm{det}(V^{AA'})=0$.\n\n\n\\subsubsection{(Anti--)self--duality in the sense of Calderbank}\nAlthough a $\\beta$--distribution is intrinsically ASD in the sense that it is defined by an ASD two--form, there are two subclasses of $\\beta$--distribution which we shall call \\textit{Calderbank--SD} or \\textit{Calderbank--ASD}. In \\cite{Cal1}, Calderbank associates to any given $\\beta$--distribution a unique connection. When the curvature of this connection is (A)SD, the $\\beta$--distribution is called Calderbank--(A)SD. This has nothing to do with the anti--self-duality of the two--form defining the $\\beta$--distribution; in a sense, a $\\beta$--distribution which is Calderbank--ASD is doubly ASD. See \\cite{Cal1} (also \\cite{West}) for further details.\n\nWe can express Calderbank (anti--)self--duality in twistor language as follows. Let $D_\\beta$ be a $\\beta$--distribution defined by an ASD two--form $\\Sigma_{ab}=\\iota_A\\iota_B\\epsilon_{A'B'}$, and  such that the spinor $\\iota_A$ satisfies\n\\be\n\\label{dm3}\n\\nabla_{A'(A}\\iota_{B)}=\\mathcal{A}_{A'(A}\\iota_{B)}\n\\ee\nwhere $d\\mathcal{A}$ is an (A)SD Maxwell field. Then $D_\\beta$ is Calderbank--(A)SD.\n\n \n\\subsubsection{Local characterisation of the Einstein manifolds $(M,g)$}\n\nA general ASD metric depends, in the real--analytic category, on six arbitrary functions of three variables \\cite{DFK}. Theorem \\ref{thm:DM} gives an explicit subclass of such metrics which are additionally constrained by the following local characterisation.\n\n\\begin{theo}[\\cite{DM}] \\label{thm:DMcharacterisation}\nLet $(M,g)$ be an real ASD Einstein manifold with scalar curvature $24$ admitting a totally null distribution $D_\\beta$ which is Calderbank--ASD and parallel in the sense that $^{\\bf g}\\nabla_{\\xi} \\tilde{\\xi}\\in\\Gamma(D_\\beta)$ for all $\\xi\\in \\Gamma(TM),\\ \\tilde{\\xi}\\in\\Gamma(D_\\beta)$. Then $(M,g)$ is conformally flat, or it is locally isometric to (\\ref{eq:g4}).\n\\end{theo}\n\\noindent\n\nIn our coordinates $D_\\beta$ is the kernel of the two--form $\\Sigma=dx^{0'}\\wedge dx^{1'}$, and can be written as ${D_\\beta}=\\mathrm{span}\\{\\p/\\p z_{0'},\\p/\\p z_{1'}\\}$. We find that\n\\be\n\\label{beta_eq}\n^{\\bf g}\\nabla\\Sigma=6\\mathcal{A}\\otimes \\Sigma,\n\\ee\nwhere $d\\mathcal{A}=\\Omega$, and $\\Omega$ is the symplectic form on $M$. Writing $\\Sigma_{ab}=\\iota_A\\iota_B\\epsilon_{A'B'}$, (\\ref{beta_eq}) implies (\\ref{dm3}) for a rescaling of $\\mathcal{A}$, so it is the anti--self--duality of $\\Omega$ which makes $D$ Calderbank--ASD.\n\nIn Section \\ref{sec:model} we will consider the model case where $M$ is constructed from the flat projective structure on $\\RP^2$. In this case, we can explicitly describe the ASD Maxwell two--form $\\Omega$ in terms of the twistor space of $M$,\nand we will find that $M$ carries a so--called \\textit{pseudo--hyper--Hermitian} structure, in which $\\mathcal{A}$ plays an important role.\n\n\n\n\n\n\n\n\n\n\n\n\n\\subsection{Einstein--Weyl structures}\n\\begin{defi}\nA Weyl Structure $(\\mathcal{W},\\mathscr{D},[h])$ is a conformal equivalence class of metrics $[h]$ on a manifold $\\mathcal{W}$ along with a fixed torsion--free affine connection $\\mathscr{D}$ which preserves any representative $h\\in[h]$ up to conformal class. That is, for some one-form $\\varphi$,\n\\[\n\\mathscr{D}h=\\varphi\\otimes h.\n\\]\n\\end{defi}\nA pair $(h,\\varphi)$ uniquely defines the connection and hence the Weyl structure, so we can alternatively specify a Weyl structure as a triple $(\\mathcal{W},h,\\varphi)$. However, there is an equivalence class of such pairs which define the same Weyl structure. These are related by transformations\n\\be\n\\label{weyl_tr}\nh\\rightarrow \\rho^2h,\\quad\\varphi\\rightarrow\\varphi+2d\\mathrm{ln}(\\rho),\n\\ee\nwhere $\\rho$ is a smooth, non-zero function on $\\mathcal{W}$. \nPhysically, the Weyl condition in Lorentzian signature corresponds to the statement that null geodesics of the conformal structure $[h]$ are also geodesics of the connection $\\mathscr{D}$.\n\nIf additionally the symmetric part of the Ricci tensor of $\\mathscr{D}$ is a scalar multiple of $h$, then $\\mathcal{W}$ is said to carry an Einstein--Weyl structure.\nThis condition is invariant under (\\ref{weyl_tr}). A trivial Einstein--Weyl structure is one whose one--form $\\varphi$ is closed, so that it is locally exact and thus may be set to zero by a change of scale (\\ref{weyl_tr}). Then $\\mathscr{D}$ is the Levi--Civita connection of some representative $h\\in[h]$, and this representative is Einstein.\n\nIn three dimensions, the Einstein--Weyl equations give a set of five non--linear partial differential equations on the pair $(h, \\varphi)$ which are integrable by the twistor transform of Hitchin \\cite{hitchin}.\n\\begin{theo}[\\cite{hitchin}]\nThere is a one--to--one correspondence between three dimensional Einstein--Weyl structures and two dimensional complex manifolds containing a three parameter family of $\\CP^1$ embeddings with normal bundle $\\mathcal{O}(2)$.\n\\end{theo}\n\\noindent The conformal structure $[h]$ is obtained by demanding that a vector on $\\mathcal{W}$ is null if and only if the corresponding section of $\\mathcal{O}(2)$ has a single zero. This condition is equivalent to the quadratic function $\\sigma(\\lambda)$ which represents the section having vanishing discriminant.\n\nHitchin's results can be regarded as a reduction of Penrose's twistor transform for ASD conformal structures by the following theorem of Jones and Tod.\n\\begin{theo}\\cite{JT} \\label{theo_tod1} \\begin{enumerate} \\item Let $(M, g)$ be a neutral signature, conformally ASD four--manifold with a conformal Killing vector $K$. Let\n\\be \n\\label{EWgen}\nh=|K|^{-2}g-|K|^{-4}{\\bf{K}}\\odot{\\bf{K}},\\qquad \\varphi=\\frac{2}{|K|^2}\\star({\\bf{K}}\\wedge d{\\bf{K}}),\n\\ee\nwhere $|K|^2=g(K,K)$, ${\\bf{K}}=g(K, \\cdot)$ and $\\star$ is the Hodge operator defined by $g$. Then $(h, \\varphi)$ is a solution of the Einstein--Weyl equations  on the space of orbits $\\mathcal{W}$ of $K$ in $M$.\n\\item Given an Einstein--Weyl structure $(\\mathcal{W},h,\\varphi)$ there is a one--to--one correspondence between solutions $(\\mathscr{V},\\alpha)$ to the abelian monopole equation\n\\be \\label{eq:monopole_eq}\nd\\mathscr{V}+\\frac{1}{2}\\varphi \\mathscr{V}=\\star_h d\\alpha.\n\\ee\non $\\mathcal{W}$, where $\\mathscr{V}$ is a function and $\\alpha$ is a one--form, and conformally ASD four--metrics\n\\be \\label{eq:monopole_correspondence}\ng=\\mathscr{V}h-\\mathscr{V}^{-1}(dx +\\alpha)^2\n\\ee\nover $\\mathcal{W}$ with an isometry $K=\\p/\\p x$.\n\\end{enumerate}\n\\end{theo}\n\\noindent If a metric with ASD Weyl tensor has more than one conformal symmetry, then distinct Einstein--Weyl structures are obtained on the space of orbits of conformal Killing vectors which are not conjugate with respect to an isometry \\cite{PT}.\n\n\n\n\n\\subsection{The $SU(\\infty)$--Toda equation}\n\nThe $SU(\\infty)$--Toda equation is given by\n\\be\n\\label{md_toda}\nU_{XX}+U_{YY}=\\epsilon(e^U)_{ZZ}, \\quad\\mbox{where}\\quad U=U(X, Y, Z), \\quad\n\\mbox{and}\\;\\;\\epsilon=\\pm 1\n\\ee\nEquation (\\ref{md_toda}) has originally arisen in  the context of complex general relativity \\cite{FP, BF82, Prz}, and then\nin Einstein--Weyl \\cite{ward_toda} and (in Riemannian context, with\n$\\epsilon=-1$) scalar--flat K\\\"ahler geometry \\cite{LeBrun}. It belongs to a class\nof dispersionless systems integrable by the twistor transform \n\\cite{MW, MDbook, ADM}, \nthe method of  hydrodynamic reduction \\cite{F},  and  the Manakov--Santini approach \\cite{MS}. \nThe equation\nis nevertheless not linearisable and most known explicit solutions admit Lie point or other symmetries (there are exceptions - see \n\\cite{c_toda, CT,martina, Sheftel}).\n\n\nThe $SU(\\infty)$--Toda equation is related to a subclass of Einstein--Weyl structures by the following result\nof Tod which improved the earlier result of Przanowski \\cite{Prz}.\n\\begin{theo}\n\\label{th3int}\\cite{Tod_note}\nLet $(\\mathcal{W},h, \\varphi)$ be an Einstein--Weyl structure arising from the first part of Theorem \\ref{theo_tod1}, under the additional assumption that\nthe ASD conformal structure $(M, [g])$ has a representative $g\\in[g]$ which is Einstein with non--zero Ricci scalar. Then \n%\\begin{enumerate}\n%\\item The Einstein--Weyl structure admits a shear--free, twist--free geodesic congruence.\n%\\item\nthere exists $h\\in [h]$, and\ncoordinates $(X, Y, Z)$ on an open set in $\\mathcal{W}$ such that\n(assuming the signature of $h$ is $(2, 1)$ and the one--form $dZ$ corresponds to a time--like vector)\n\\be\n\\label{metric_toda}\nh=e^U(dX^2+dY^2)-dZ^2, \\quad \\varphi =2U_ZdZ\n\\ee\nand the function $U=U(X, Y, Z)$ satisfies the $SU(\\infty)$--Toda equation\n(\\ref{md_toda}) \nwith $\\epsilon=1$.\n%\\end{enumerate}\n\\end{theo}\n\nNote that the assumptions about the signature of $h$ and the timelike character of $dZ$ in the above theorem are satisfied for all the Einstein--Weyl structures that can be obtained from the projective to Einstein correspondence. An invariant procedure for obtaining the coordinate system $(X,Y,Z)$ is discussed in section \\ref{steps_sec}.\n\n%\\mynote{Need to define a congruence and its shear and twist, or modify the statement of Tod's theorem to be independent of the congruence.}\n\n\\subsection{Projective structures on a surface}\nRecall (see, for example, \\cite{BDE}) that a projective structure on a surface can be locally specified by a single second order ordinary differential equation: taking coordinates $(x,y)$ on the surface we find that geodesics on which $\\dot{x}\\neq 0$ can be written as unparametrised curves $y(x)$ such that\n\\be\n\\label{odealice}\ny^{\\prime \\prime} + a_0(x,y)+3a_1(x,y)y^{\\prime}+3a_2(x,y)(y^{\\prime})^2 + a_3(x,y)(y^\\prime)^3=0,\n\\ee\nwhere the coefficients $\\{a_i\\}$ are given by the projectively invariant formulae\n\\[\na_0=\\Gamma^1_{00},\\quad\n3a_1=-\\Gamma^0_{00}+2\\Gamma^1_{01},\\quad\n3a_2=-2\\Gamma^0_{01}+\\Gamma^1_{11},\\quad\na_3=-\\Gamma^0_{11}.\n\\]\n\nHitchin \\cite{hitchin} solves the complexified version of (\\ref{odealice}) by the following twistor transform theorem.\n\\begin{theo}\nThere is a one--to--one correspondence between\n\\begin{itemize}\n\\item equivalence classes under coordinate transformations of complex ordinary differential equations of the form (\\ref{odealice}), where the coefficients $a_i$ are holomorphic functions of $x$ and $y$, and\n\\item complex surfaces containing a two parameter family of $\\CP^1$ embeddings with normal bundle $\\mathcal{O}(1)$.\n\\end{itemize}\n\\end{theo}\n\\noindent In the case of the ordinary differential equation resulting from the flat projective structure on $\\CP^2$, the corresponding twistor space, whose points correspond to projective lines in $\\CP^2$, is the dual projective surface $\\CP_2$, and its $\\CP^1$ embeddings are given by projective lines in $\\CP_2$. In analogy with the nonlinear graviton, we can define the correspondence space $\\mathcal{F}$ such that a point in $\\mathcal{F}$ is given by a point $p\\in\\CP^2$ and a projective line (or equivalently a direction) through $p$. This makes $\\mathcal{F}$ the projectivised tangent bundle $\\PP(T\\CP^2)$, or equivalently $\\PP(T\\CP_2)$.\n\nAs we saw in Chapter \\ref{chap:intro2}, the maximally symmetric projective surface $\\RP^2$ has symmetry group $SL(3,\\R)$. In fact, the possible symmetry groups of projective surfaces are $SL(3, \\R)$, $SL(2,\\R)$, the two dimensional affine group, and $\\R$. A partial classification is given in \\cite{Bryant}.\n\n\\begin{enumerate}\n\\item On {\\bf the flat projective surface} $\\RP^2$ described in Section \\ref{def:RPn}, geodesics $y(x)$ are described in inhomogeneous coordinates $(x,y)=({P^0}/{P^2},{P^1}/{P^2})$ by the ordinary differential equation\n\\[\ny^{\\prime\\prime}=0.\n\\]\n\\item {\\bf The punctured plane $\\R^2\\backslash\\{0\\}$} has symmetry group $SL(2,\\R)$ acting via its fundamental representation. In this case there is a one parameter family of projective structures falling into three distinct equivalence classes. For simplicity we will consider only one of the classes, with geodesics $y(x)$ described by the differential equation\n\\be \\label{eq:submaxODE}\ny^{\\prime\\prime} = -(y-xy^\\prime)^3,\n\\ee\nwhere $(x,y)$ are standard Euclidean coordinates on $\\R^2$.\n\\item {\\bf The two dimensional Lie group of affine transformations on $\\R$}, which we denote $\\mathrm{Aff}(1)$, is generated by the unique non--abelian two dimensional Lie algebra $\\{\\mathfrak{v}_1,\\mathfrak{v}_2\\}$, where we choose a basis such that $[\\mathfrak{v}_1,\\mathfrak{v}_2]=\\mathfrak{v}_1$. We can choose coordinates on $\\mathrm{Aff}$(1) such that these correspond to vector fields\n\\[\n\\frac{\\p}{\\p y},\\quad \\frac{\\p}{\\p x} + y\\frac{\\p}{\\p y},\n\\]\nand using invariance under these vector fields, the geodesic equation can be cast in the form \\cite{FLL}\n\\[\ny^{\\prime\\prime} = e^{-2x}(y^\\prime)^3 + A_1y^\\prime + A_2e^x,\n\\]\nwhere $A_1$ and $A_2$ are constants.\n\\item {\\bf The general projective surface with a symmetry}, after a choice of coordinates such that the symmetry is $\\frac{\\p}{\\p x}$, corresponds to a set of geodesics $y(x)$ which satisfy an ordinary differential equation that can be written uniquely in the form \\cite{FLL}\n\\be \\label{eq:1symode}\ny^{\\prime\\prime} = A(y)(y^\\prime)^3 + B(y)(y^\\prime)^2 + 1.\n\\ee\n\\end{enumerate}\n\n\\noindent Note that each of these classes of projective structures forms a subset of the next, and this can be seen explicitly by some changes of coordinates. For example, the general projective surface with a symmetry is flat when $A(y)=B(y)=0$.\n\n\\subsection{From projective surfaces to $SU(\\infty)$--Toda fields}\nThe whole construction can now be summarised in the following diagram\n\\begin{eqnarray}\n\\label{diagram}\n\\text{Projective structure with symmetry} &\\overset{\\text{Thm}\\;\\ref{thm:DM}}\n{\\longrightarrow}& \\text{ASD Einstein with symmetry}\\nonumber\\\\\n\\downarrow & & \\downarrow \\scriptstyle{\\text{Thm}\\;\\ref{theo_tod1}}\\\\\n\\text{Solution to}\\;SU(\\infty)\\; \\text{Toda} &\\overset{\\text{Thm}\\;\\ref{th3int}}\\longleftarrow&\\text{Einstein--Weyl.}\\nonumber\n\\end{eqnarray}\n%\\be\n%\\label{diagram}\n%A \\xrightarrow{\\text{Theorem}} \\text{ASD Einstein with symmetry}\\xrightarrow{\\t%ext{Theorem}} \\text{Einstein--Weyl} \\xrightarrow{\\text{Theorem}} SU(\\infty)\\; \\%text{Toda}\n%\\ee\nWe now consider each of the above projective structures in turn, constructing the corresponding ASD Einstein manifold $(M,g)$ and discussing some examples of Einstein--Weyl structures and $SU(\\infty)$--Toda fields that can be obtained from them.\n\n\n\\section{The most general case}\n\\label{general}\n\nConsider the most general Einstein--Weyl structure arising from the combination\nof Theorem \\ref{thm:DM} and Theorem \\ref{theo_tod1}. Because of the correspondence (\\ref{eq:kvf_from_pvf}) between symmetries of $(M, g)$ and symmetries of the projective surface $(N, [\\nabla])$, the construction must begin with the general projective surface with at least one symmetry. \n \nBy trial and error, we chose a representative connection for (\\ref{eq:1symode}) such that the metric (\\ref{eq:g4}) had the simplest possible form. The choice of connection we took was\n\\[\n\\Gamma^{0}_{11}=A(y),\\quad \\Gamma^{1}_{00}=-1, \\quad \\Gamma^{1}_{11}=-B(y)\n\\]\nwith all other components vanishing. Note that this choice of connection has a symmetric Ricci tensor, so the Schouten tensor is also symmetric and the symplectic form (\\ref{eq:Omega4}) pulls back to just $dz_{A'}\\wedge dx^{A'}$. Thus we can write the Maxwell potential $\\mathcal{A}$ which is such that $d\\mathcal{A}=\\Omega$ as $\\mathcal{A}=z_{A'}dx^{A'}$. Writing $x^{A'}=(x,y)$, $z_{A'}=(p,q)$, the resulting metric (\\ref{eq:g4}) is\n\\be\n\\label{einstein_1}\ng=(B(y) + p^2 +q)dx^2+2(pq+A(y))dxdy + (-A(y)p+B(y)q+q^2)dy^2 + dxdp +dydq.\n\\ee\nFactoring by $K=\\frac{\\p}{\\p x}$ following the algorithm of Theorem\n\\ref{theo_tod1}, equation (\\ref{EWgen}) gives the following form for the Einstein--Weyl structure.\n\\begin{prop}\n\\label{prop1}\nThe most general  Einstein--Weyl structure arising\nfrom the procedure (\\ref{diagram}) is locally equivalent to\n\\begin{eqnarray}\n\\label{ew_final}\nh&=&\\frac{1}{\\mathscr{V}}\\big((Bq -Ap+ q^2)dy+dq\\big)dy\n-\\Big((pq+A)dy+\\frac{1}{2}dp\\Big)^2, \\label{genh} \\\\\n\\varphi&=&\\mathscr{V}(4dq+2 pdp), \\quad\\mbox{where}\\quad \\mathscr{V}=\n({B}+ p^2+q)^{-1}.\\nonumber\n\\end{eqnarray}\nHere $(p, q, y)$ are local coordinates on $\\mathcal{W}$, $A(y), B(y)$ are arbitrary functions of $y$, and the solution to the monopole equation (\\ref{eq:monopole_eq}) arising from the second part of Theorem \\ref{theo_tod1} is the pair $(\\mathscr{V},\\alpha)$, where\n\\[\n\\alpha=\\mathscr{V}( pq+A)dy+\\frac{\\mathscr{V}}{2}dp.\n\\]\n\\end{prop}\n\n\n\\subsection{Solution to the $SU(\\infty)$--Toda equation}\n\\label{steps_sec}\nThe procedure for extracting the corresponding solution to the $SU(\\infty)$--Toda equation is given in \\cite{Tod_note} \n(see also \\cite{LeBrun} and \\cite{DT}). It involves finding the coordinates $(X,Y,Z)$ that put the metric (\\ref{genh}) in the \nform (\\ref{metric_toda}). Given an ASD Einstein metric $(M, g)$ with a\nKilling vector $K$\n\\begin{enumerate}\n\\item The conformal factor $c:M\\rightarrow \\R^+$  given by\n\\[\nc={|d{\\bf K}+*_g d{\\bf K}|_{g}}^{-1/2}\n\\]\nhas a property that\nthe rescaled self--dual derivative of $K$\n\\[\n\\vartheta\\equiv c^3\\Big(\\frac{1}{2}(d{\\bf K}+*_g d{\\bf K})\\Big)\n\\]\nis parallel with respect to $c^2 g$.\nThe metric $c^2g$ is para--K\\\"ahler with  self--dual \npara--K\\\"ahler form $\\vartheta$, and admits a Killing vector $K$, as\n${\\mathcal L}_K(c)=0$.\n\\item\nDefine a function $Z:M\\rightarrow \\R$ to be the moment map:\n\\be\n\\label{ztilde}\ndZ=K\\hook \\vartheta.\n\\ee\nIt is well defined, as the K\\\"ahler form is Lie--derived along $K$.\n\\item\nConstruct the Einstein--Weyl structure of Theorem \\ref{theo_tod1}\nby factoring $(M, c^2g)$ by $K$. Restrict the metric $h$\nto a surface $Z=Z_0=\\mbox{const}$, and construct isothermal coordinates \n$(X, Y)$ on this surface:\n\\[\n\\gamma\\equiv h|_{Z=Z_0}=e^{U}(dX^2+dY^2), \\quad U=U(X, Y, Z_0).\n\\]\nTo implement this step chose an orthonormal basis of one--forms\nsuch that $\\gamma= {e_1}^2+{e_2}^2$. Now $(X, Y)$ are solutions to the linear\nsystem of first order partial differential equations\n\\[\n(e_1+ie_2)\\wedge (dX+idY)=0.\n\\]\n\\item Extend the coordinates $(X, Y)$ from the surface $Z=Z_0$ to $\\mathcal{W}$. This may\ninvolve a $Z$--dependent affine transformation of $(X, Y)$.\n\\end{enumerate}\nImplementing the Steps 1--4 on MAPLE we find that if $A=0$, and $B=B(y)$ \nis arbitrary, then the $SU(\\infty)$--Toda solution is given implicitly by\n\\begin{eqnarray}\n\\label{toda_implicit1}\n X&=&-\\frac{8\\mathrm{e}^{-2\\int{B(y)dy}}Z^3p}{(Z^2p^2+4)^2},\\quad\nY=\\int{\\mathrm{e}^{-2\\int{B(y)dy}}dy}+\\frac{\\mathrm{e}^{-2\\int{B(y)dy}}(-2Z^4p^2+8Z^2)}{(Z^2p^2+4)^2}.\\nonumber\\\\\nU&=&\\mathrm{ln}\\bigg(\\frac{(Z^2p^2+4)^3}{64Z^2}\\bigg)+4\\int{B(y)dy}.\n\\end{eqnarray}\nWe can check that this is indeed a solution using the fact that the $SU(\\infty)$--Toda equation is equivalent to \n$d\\star_h dU=0$. We have also checked by performing a coordinate transformation of (\\ref{md_toda}) to the coordinates $(y,p,Z)$.\n\nTo simplify the form of (\\ref{toda_implicit1}) set\n\\[\nG=\\int\\exp{\\Big(-2\\int B(y)dy\\Big)}, \\quad T=\\frac{2Z^2}{Z^2p^2+4}.\n\\]\nThen (\\ref{toda_implicit1}) becomes\n\\[\ne^U=\\frac{Z^4}{8T^3 (G')^2}, \\quad Y=G+G'T\\Big(\\frac{4T}{Z^2}-1\\Big), \\quad\nX^2=\\frac{4T^4(G')^2}{Z^2}\\Big(\\frac{2}{T}-\\frac{4}{Z^2} \\Big).\n\\]\nEliminating $(T, y)$ between these three equations gives one relation between $(X, Y, Z)$ and  $U$ which is our implicit solution.\nThe elimination can be carried over explicitly if $G=y^k$ for any integer $k$, or if $G=\\exp{y}$. In the latter case the solution is given by\n\\[\n4Y^2e^U(e^UX^2-Z^2)^3+(2e^{2U}X^4-3e^UX^2Z^2+Z^4+2Z^2)^2=0.\n\\]\n\nWe can also consider the flat projective structure with $A=B=0$, in which case\nthe coordinate $p$ can be eliminated between\n\\[\ne^U=\\bigg(\\frac{(Z^2p^2+4)^3}{64Z^2}\\bigg), \\quad\nX=-\\frac{8Z^3p}{(Z^2p^2+4)^2}\n\\]\nby taking a resultant. This yields\n%\\[\n%\\mathrm{e}^{4U}X^6+3\\mathrm{e}^{3U}X^4Z^2+3\\mathrm{e}^{2U}X^2Z^4+\\mathrm{e}^UZ^%6+Z^4=0.\n%\\]\n\\[\ne^U(e^UX^2-Z^2)^3+Z^4=0.\n\\]\nNote that even the flat projective surface can yield a non--trivial solution to the Toda equation; further discussion can be found in Section \\ref{neat2}.\n\n\n\\subsection{Two monopoles} \\label{sec:monopoles}\nThe Einstein--Weyl structures $(\\mathcal{W},h,\\varphi)$ in (\\ref{genh}) that we have constructed in Proposition \\ref{prop1}\nare special, as they belong to the $SU(\\infty)$--Toda class. %, and so (as shown by Tod \\cite{Tod_toda}) admit a non--null geodesic congruence which has vanishing shear and twist.\nThe general solution to the $SU(\\infty)$--Toda equation depends (in the real analytic category) on \ntwo arbitrary functions of two variables, but the solutions of the form (\\ref{genh}) depend on two functions of one variable. The additional constraints on the solutions can be traced back to the four dimensional ASD conformal structures\nwhich give rise (by the Jones--Tod construction) to (\\ref{genh}).\n%As discussed above, in addition to their being ASD and Einstein they are  characterised \\cite{DM} by a $\\beta$--distribution which is parallel with respect to the Levi--Civita connection and ASD in the sense of Calderbank \\cite{Cal1}. The corresponding $\\beta$--surfaces do not generically intersect with a given $\\alpha$--surface, however if they do intersect then they will intersect in curves (null geodesics) which descend to the Einstein--Weyl structures, and give rise to another (in addition to the Tod shear--free, twist--free) geodesic congruence.\nIn what follows we shall point out how some of the additional structure on $\\mathcal{W}$ arises as a couple of solutions to the abelian monopole equation.\n\nLet us call the solution $(\\mathscr{V},\\alpha)$ arising in Proposition \\ref{prop1} the Einstein monopole, as the resulting conformal class contains an Einstein metric\n(\\ref{einstein_1}). The second solution $(\\mathscr{V}_M, \\alpha_M)$ (which we shall call the Maxwell monopole)\narises\nas a symmetry reduction of the ASD Maxwell potential\n\\[\n{\\mathcal A}=pdx+qdy=-\\mathscr{V}_M {\\bf K}+\\alpha_M,\n\\]\nwhere ${\\bf K}$ is the Killing one--form, and\nwe find\n\\[\n\\mathscr{V}_M=-p\\mathscr{V}, \\quad \\alpha_M=qdy-p\\alpha.\n\\]\n\\mynote{I want to understand and explain this better.}\n\\section{The submaximally symmetric case}\n\\label{neat}\n%\\mynote{Say something about $\\mathrm{Aff}(1)$?}\nChoosing a representative connection from the projective class defined by (\\ref{eq:submaxODE}), we obtain from (\\ref{eq:g4}) an\nEinstein metric\n\\be \\label{eq:submax_einstein}\n\\begin{split}\ng=( p^2- xy^2p-y^3q + 4 y^2 )dx^2 + 2(pq +  x^2yp +  xy^2q - 4 xy)dxdy \\\\\n+ (q^2 - x^3p -  x^2yq + 4 x^2)dy^2 + dxdp + dydq\n\\end{split}\n\\ee\non $M$, again with $z_0=:p,\\,z_1=:q$, having Killing vectors\n\\[\nK_1=x\\frac{\\p}{\\p x} - p\\frac{\\p}{\\p p} - y\\frac{\\p}{\\p y} + q\\frac{\\p}{\\p q},\\quad\nK_2=x\\frac{\\p}{\\p y} - q\\frac{\\p}{\\p p}, \\quad\nK_3=y\\frac{\\p}{\\p x} - p\\frac{\\p}{\\p q}.\n\\]\nThese are lifts of the projective vector fields corresponding to the $\\mathfrak{sl}(2,\\R)$ elements\n\\[\n\\mathfrak{v}_1=\\begin{pmatrix}\\epsilon & 0\\\\\n0 & -\\epsilon\n\\end{pmatrix}\n\\quad\n\\mathfrak{v}_2 = \\begin{pmatrix}0 & 0\\\\\n\\epsilon & 0\n\\end{pmatrix}\n\\quad\n\\mathfrak{v}_3 = \\begin{pmatrix} 0 & \\epsilon\\\\\n0 & 0\n\\end{pmatrix}.\n\\]\n%\\mynote{There is a comment about conjugacy classes to be made here.}\n\nTo obtain an example of a Jones--Tod reduction of (\\ref{eq:submax_einstein}), we factor by $K_3$. Choosing coordinates\n\\[\nr=\\frac{p^2}{ y^2}, \\quad z=2\\ln( y^2), \\quad w=xp+yq,\n\\]\ngives an Einstein--Weyl structure\n\\begin{eqnarray}\n\\label{ew_neat}\nh&=&-dr^2-2drdw-w(w^2+r-5w+4)dz^2+2(r-w+4)dzdw,\\\\\n\\varphi&=&\\frac{1}{r-w+4}dr-\\frac{3w}{r-w+4}dz-\\frac{4}{r-w+4}dw.\\nonumber\n\\end{eqnarray}\nThe solution to the $SU(\\infty)$--Toda equation (\\ref{md_toda}) which determines the Einstein--Weyl structure (\\ref{ew_neat}) is described by an algebraic curve $f(\\mathrm{e}^U,X,Y,Z)=0$ of degree six in $\\mathrm{e}^U$ and degree twelve in the other coordinates. \nThis solution has been found following the Steps 1-4 in Section \\ref{steps_sec}, \nand is given by\n\\be\n\\begin{split}\n64\\mathrm{e}^{6U}X^6(X+Y)^3(X-Y)^3\n-92\\mathrm{e}^{5U}X^4Z^2(X+Y)^3(X-Y)^3 \\\\\n+48\\mathrm{e}^{4U}X^2Z^2(5X^6Z^2-14X^4Y^2Z^2+13X^2Y^2Z^2-4Y^4Z^2+9X^4+27X^2) \\\\\n+8\\mathrm{e}^{3U} Z^4(-20X^6Z^2+48X^4Y^2Z^2-36X^2Y^4Z^2+8Y^6Z^2-81X^4-243X^2Y^2) \\\\\n+3\\mathrm{e}^{2U}Z^4\n(20X^4Z^4-36X^2Y^2Z^4+16Y^4Z^4+108X^2Z^2+216Y^2Z^2+243) \\\\\n+6\\mathrm{e}^UZ^8(-2X^2Z^2+2Y^2Z^2-9) +Z^{12}\\\\ =0.\n\\end{split}\n\\nonumber\n\\ee\n\n\nNote that the  formulae (\\ref{ew_neat}) are independent of the coordinate $z$, and therefore have a symmetry. This was unexpected because there is no other symmetry of $(M,g)$ that commutes with $K_3$. However, it is possible for symmetries to appear in the Einstein--Weyl structure without a corresponding symmetry of the ASD conformal structure. This can be seen from the general formula (\\ref{eq:monopole_correspondence}); the function $\\mathscr{V}$ may depend on the coordinate $z$ so that $g$ depends on $z$ even though $h$ does not. For example, the Gibbons-Hawking metrics \\cite{GH} give a trivial Einstein--Weyl structure with the maximal symmetry group, but the four-metric is in general not so symmetric. Our discovery of this unexpected symmetry motivated a more concrete description of a symmetry of a Weyl structure.\n\n\\begin{defi}\nAn infinitesimal symmetry of a Weyl structure $(\\mathcal{W},\\mathscr{D},[h])$ is a vector field $\\mathcal{K}$ which is both an affine vector field with respect to the connection\\footnote{Recall that an affine vector field of a connection $\\mathscr{D}$ is one which preserves its components, i.e. $\\mathcal{L}_\\mathcal{K}\\Gamma^i_{jk}=0$.} $\\mathscr{D}$ and a conformal Killing vector with respect to the conformal structure $[h]$.\n\\end{defi}\n\n\\begin{prop}\n\\label{ewsymprop}\nGiven an infinitesimal symmetry $\\mathcal{K}$ of a Weyl structure $(\\mathcal{W},\\mathscr{D},[h])$ in dimension $N$, and a representative $h\\in[h]$ such that $\\mathscr{D}h=\\varphi\\otimes h$, there exists a smooth function $f:\\mathcal{W}\\rightarrow \\R$ such that\n\\be\n\\label{EWsym}\n\\mathcal{L}_\\mathcal{K}h=fh,\\qquad\\mathcal{L}_\\mathcal{K}\\varphi=\\frac{1}{N}d[\\mathcal{K}\\hook d(\\mathrm{ln}(\\mathrm{det}(h)))].\n\\ee\n\\end{prop}\n\\noindent\\textbf{Proof.} The first equation follows immediately from the fact that $\\mathcal{K}$ is a conformal Killing vector of $h$. It remains to evaluate the Lie derivative of the one--form $\\varphi$ along the flow of $\\mathcal{K}$ given that $\\mathcal{L}_\\mathcal{K}h=fh$ and $\\mathcal{L}_\\mathcal{K}\\Gamma^i_{jk}=0$, where $\\Gamma^i_{jk}$ are the components of the connection $\\mathscr{D}$. We do this by considering the Lie derivative of $\\mathscr{D}h$:\n\\begin{align*}\n\\mathcal{L}_\\mathcal{K}(\\mathscr{D}_ih_{jk}) &= \\mathcal{L}_\\mathcal{K}(\\p_ih_{jk})-\\mathcal{L}_\\mathcal{K}(\\Gamma^l_{ji}h_{lk}+\\Gamma^l_{ki}h_{jl}) \\\\\n&= \\mathcal{L}_\\mathcal{K}(\\p_ih_{jk}) - f(\\Gamma^l_{ji}h_{lk}+\\Gamma^l_{ki}h_{jl}).\n\\end{align*}\nNow\n\\begin{align*}\n\\mathcal{L}_\\mathcal{K}(\\p_ih_{jk}) &= \\mathcal{K}^l\\p_l\\p_ih_{jk}+(\\p_i\\mathcal{K}^l)\\p_lh_{jk}+(\\p_j\\mathcal{K}^l)\\p_ih_{lk} + (\\p_k\\mathcal{K}^l)\\p_ih_{jl} \\\\\n&= \\p_i[\\mathcal{K}^l\\p_lh_{jk}+(\\p_j\\mathcal{K}^l)h_{lk}+(\\p_k\\mathcal{K}^l)h_{jl}] - (\\p_i\\p_j\\mathcal{K}^l)h_{lk} - (\\p_i\\p_k\\mathcal{K}^l)h_{jl}.\n\\end{align*}\nThe term with square brackets is just\n\\[\n\\p_i(\\mathcal{L}_\\mathcal{K}h_{jk})=\\p_i(fh_{jk})=f\\p_ih_{jk}+\\p_ifh_{jk},\n\\]\nso we have\n\\[\n\\mathcal{L}_\\mathcal{K}(\\mathscr{D}_ih_{jk})=f\\mathscr{D}_ih_{jk}+\\p_ifh_{jk}- (\\p_i\\p_j\\mathcal{K}^l)h_{lk} - (\\p_i\\p_k\\mathcal{K}^l)h_{jl}.\n\\]\nSetting this equal to $\\mathcal{L}_\\mathcal{K}(\\varphi_ih_{jk})=(\\mathcal{L}_\\mathcal{K}\\varphi_i)h_{jk}+f\\varphi_ih_{jk}$ and cancelling $f\\varphi_ih_{jk}$ with $f\\mathscr{D}_ih_{jk}$, we find\n\\begin{eqnarray}\n(\\mathcal{L}_\\mathcal{K}\\varphi_i)h_{jk} &=& \\p_ifh_{jk} - (\\p_i\\p_j\\mathcal{K}^l)h_{lk} - (\\p_i\\p_k\\mathcal{K}^l)h_{jl}\\nonumber \\\\\n\\label{liederivom}\n\\implies\\ \\mathcal{L}_\\mathcal{K}\\varphi_i &=& \\p_if - \\frac{2}{N}\\p_i\\p_j\\mathcal{K}^j.\n\\end{eqnarray}\nFinally, we note that\n\\[\n\\p_i\\p_j\\mathcal{K}^j=\\frac{N}{2}\\p_if-\\frac{1}{2}\\p_i[\\mathcal{K}\\hook d(\\mathrm{ln}(\\mathrm{det}(h))].\n\\]\nThis follows from tracing the expression $\\mathcal{L}_\\mathcal{K}h_{ij}=fh_{ij}$:\n\\be\n\\begin{gathered}\n\\nonumber\n\\mathcal{L}_\\mathcal{K}h_{ij} = \\mathcal{K}^k\\p_kh_{ij} + (\\p_i\\mathcal{K}^k)h_{kj} + (\\p_j\\mathcal{K}^k)h_{ik} = fh_{ij} \\\\\n\\implies \\quad \\mathcal{K}^kh^{ij}\\p_kh_{ij} + 2\\p_k\\mathcal{K}^k = Nf \\\\\n\\implies \\quad 2\\p_i\\p_k\\mathcal{K}^k = N\\p_if -  \\p_i(\\mathcal{K}^kh^{jl}\\p_kh_{jl})\n\\end{gathered}\n\\ee\nand recalling that $h^{jl}\\p_kh_{jl}=\\p_k\\mathrm{ln}(\\mathrm{det}(h))$.\nSubstituting into (\\ref{liederivom}) then yields the result.\n\\begin{flushright}\n$\\square$\n\\par\\end{flushright}\n\nWe can easily verify the invariance of (\\ref{EWsym}) under Weyl transformations. Let $(\\bar{h},\\bar{\\varphi})$ be a new metric and one--form related to the old ones by (\\ref{weyl_tr}). Then\n\\[\n\\mathcal{L}_\\mathcal{K}\\bar{\\varphi}=\\mathcal{L}_\\mathcal{K}\\varphi + 2d[\\mathcal{K}\\hook d\\mathrm{ln}(\\rho)]\n\\]\nfrom (\\ref{weyl_tr}), and from (\\ref{EWsym}) we have\n\\begin{align*}\n\\mathcal{L}_\\mathcal{K}\\bar{\\varphi} & = \\frac{1}{N}d[\\mathcal{K}\\hook d(\\mathrm{ln}(\\rho^{2N}\\mathrm{det}(h)))] \\\\\n& = \\frac{1}{N}d[\\mathcal{K}\\hook d(\\mathrm{ln}(\\mathrm{det}(h)))] + \\frac{2N}{N}d[\\mathcal{K}\\hook d\\mathrm{ln}(\\rho)] \\\\\n& = \\mathcal{L}_\\mathcal{K}\\varphi + 2d[\\mathcal{K}\\hook d\\mathrm{ln}(\\rho)],\n\\end{align*}\nas above. Note that the function $f$ in (\\ref{EWsym}) will change according to\n\\[\n\\bar{f}=f+2\\mathcal{K}\\hook d\\mathrm{ln}\\rho.\n\\]\n\nIn the case of the Weyl structure (\\ref{ew_neat}), the infinitesimal symmetry is\n\\[\n\\mathcal{K}=\\frac{\\p}{\\p z}.\n\\]\nSince we have chosen a scale such that $\\mathcal{K}$ is in fact a Killing vector of $h$, we have that $\\mathcal{K}\\hook d(\\mathrm{ln}(\\mathrm{det}(h))=0$, so the one--form $\\varphi$ is also preserved by $\\mathcal{K}$. This is consistent with the fact that it has no explicit $z$--dependence.\n\\section{The model case}\n\\label{sec:model}\nIn the following section we discuss the four--manifold $(M,g)$ obtained from the maximally symmetric flat \nprojective surface $N=\\RP^2$. In this case, $g$ is not only almost para--K\\\"ahler but in fact para--K\\\"ahler, since the symplectic form $\\Omega$ is parallel with respect to the Levi--Civita connection of $g$. Choosing a representative connection with\n$\\Gamma_{A'B'}^{C'}=0$ gives $g$ as\n\\be\n\\label{special_ein}\ng=dz_{A'}\\odot dx^{A'}+ z_{A'}z_{B'} dx^{A'}\\odot dx^{B'}.\n\\ee\n\nWe begin by discussing the  conformal structure\nof (\\ref{special_ein}), both explicitly and in terms of its twistor space. We then note a pseudo--hyper--Hermiticity property which is unique to the model case, and find some special structure on the twistor space. Finally, we present a classification of the Einstein--Weyl structures which can be obtained from (\\ref{special_ein}) by Jones--Tod factorisation, and exhibit an explicit example of such a factorisation from the twistor perspective, reconstructing the conformal structure on $\\mathcal{W}$ from minitwistor curves.\n\\subsection{Conformal Structure on $M$}\n\\label{model_conf}\nRecall that points $P\\in\\R^3$ and $L\\in\\R_3$ respectively define lines and planes in $\\R^3$ which are preserved by multiplication of $P,L$ by members of $\\R^*$, and that these lines and planes respectively descend to points $[P]$ and lines $[L]$ in $\\RP^2$. In what follows we will drop the square brackets and understand points $[P]\\in\\RP^2$ and lines $[L]\\in\\RP_2$ to be represented by vectors $P\\in\\R^3$ and $L\\in\\R_3$. Let $M\\subset \\RP^2\\times {\\RP_2}$ be the set of non--incident pairs \n$(P, L)$.\n\\begin{prop}\n\\label{prop_cone}\nTwo pairs $(P, L)$ and $(\\tP, \\tL)$ are null--separated\nwith respect to the conformal structure (\\ref{special_ein})\nif there exists\na line which contains the three points $(P, \\tP, L\\cap \\tL)$. \n\\end{prop}\n{\\bf Proof.}\nFirst note that the  null condition of Proposition \\ref{prop_cone}\ndefines a co--dimension one cone in $TN$: \ngenerically there is no line through three given points. To make explicit the condition for such a line to exist, consider two pairs  $(P, L)$ and $(\\tP, \\tL)$ \nof non--incident points and lines. By thinking of $L,\\tL$ as normal vectors to planes in $\\R^3$, we see that $L+t\\tL$ is a plane which intersects $L$ and $tL$ at their intersection, thus defining a line in $\\RP^2$ which intersects the lines $L,\\tL\\subset\\RP^2$ at their intersection.\n\nIf $P,\\tP,L\\cap\\tL$ are co--linear then there exists $t$ such that both $P$ and $\\tP$ lie on $L+t\\tL$, i.e.\n\\be\n\\label{dm1}\nP\\cdot (L+t\\tL)=0,  \\quad\n\\tP\\cdot (L+t\\tL)=0.\n\\ee \nEliminating $t$ from \n(\\ref{dm1}) gives\n\\[\n(P\\cdot L)(\\tP\\cdot \\tL)-(\\tP\\cdot L)(P\\cdot \\tL)=0.\n\\]\nSetting $\\tP=P+dP, \\tL=L+dL$ yields a metric \n$g$  representing the conformal structure\n\\[\ng=\\frac{dP\\cdot dL}{P\\cdot L}-\\frac{1}{(P\\cdot L)^2}(L\\cdot dP)(P\\cdot dL).\n\\]\nWe can use the normalisation $P\\cdot L=1$, so that $P\\cdot dL=-L\\cdot dP$,\nand\n\\be\n\\label{dm_metric}\ng={dP\\cdot dL}+(L\\cdot dP)^2.\n\\ee\nWe take affine coordinates \n\\be\n\\label{DM_parameter}\nP=[x^{A'}, 1],\\quad L=[z_{A'}, 1-x^{A'}z_{A'}]\n\\ee \nwith a normalisation $P\\cdot L=1$ to recover the metric (\\ref{special_ein}).\n\\koniec\n\\subsection{Twistor space of $M$}\n\\label{twist_SSS}\nTo understand $(M,[g])$ from the twistor perspective, we need to move to the complex picture. In what follows, we will view $M$ as the set of non--incident pairs in $\\CP^2\\times\\CP_2$. Let $F_{12}(\\mathbb{C}^3)\\subset \\CP^2\\times {\\CP_2}$ be set of incident pairs \n$(p, l)$, so that $p\\cdot l=0$. Note that, since $l$ and $p$ correspond to planes and lines in $\\mathbb{C}^3$ respectively, and since $p\\cdot l=0$ is the condition for the line $p$ lying in the plane $l$, $F_{12}(\\mathbb{C}^3)$ coincides with the flag manifold of type $(1,2)$ in $\\mathbb{C}^3$, i.e. the collection of one and two dimensional vector subspaces $(p,l)$ in $\\mathbb{C}^3$ such that $p\\subset l$. This is the twistor space of $(M, g)$.\nA $\\CP^1$ embedding corresponding to a point $(P, L)\\in M$\nconsists of all lines $l$ thorough $P$, and all points\n$p=l\\cap L$:\n\\be\n\\label{dm2}\nP\\cdot l=0, \\quad p\\cdot L=0, \\quad p\\cdot l=0.\n\\ee\n\nLet $(P, L)$ and $(\\tP, \\tL)$ be points in $M$. These uniquely define a point $p=L\\cap\\tL\\in\\CP^2$ and line $l\\subset\\CP^2$ such that $P,\\tP\\in l$ given by\n\\[\np=L\\wedge \\tL, \\quad l=P\\wedge \\tP,\n\\]\nwhere $[L\\wedge\\tL]^{\\alpha}=\\epsilon^{\\alpha\\beta\\gamma}L_{\\alpha}\\tL_{\\beta}$ etc.\nThe pair $(p,l)$ lies in $F_{12}$ if $p$ lies on $l$, i.e. if $p\\cdot l=0$, so that $(P, L)$ and $(\\tP, \\tL)$ are null--separated with respect to the conformal structure\n(\\ref{dm1}). Then $(p,l)$ is the intersection of the $\\CP^1$ embeddings corresponding to $(P, L)$ and $(\\tP, \\tL)$. %The contact structure on $F_{12}$ is $(l\\cdot dp-p\\cdot dl)/2=p\\cdot dl$. \\mynote{Contact structure on $F_{12}$?}\n\nWe shall now give an explicit parametrisation of twistor lines, and show how \nthe metric (\\ref{dm_metric}) arises from the Penrose condition \n\\cite{penrose,ward}.\nLet $P\\in \\CP^2$. The corresponding $l\\in \\CP_2$ is represented by some normal vector which is perpendicular to $P$ in $\\mathbb{C}^3$, i.e.\n\\be \\label{eq:l=Pwedgepi}\nl=P\\wedge \\pi, \\quad \\mbox{where}\\quad  \\pi\\sim a\\pi+b P,\n\\ee\nwhere $a\\in \\mathbb{C}^*, b\\in \\mathbb{C}$. Thus $\\pi$ parametrises a projective line $\\CP^1$,\nand by making a choice of $b$ we can take\n$\n\\pi=[\\pi^{0'}, \\pi^{1'}, 0], \n$ where $\\pi^{A'}=[\\pi^{0'}, \\pi^{1'}]\\in \\CP^1$. The constraint $P\\cdot l=0$ now holds.\nTo satisfy the remaining constraints in (\\ref{dm2}) we take\n\\be \\label{eq:p=Lwedgel}\np=L\\wedge l=(L\\cdot\\pi)P-(L\\cdot P)\\pi.\n\\ee\nSubstituting (\\ref{DM_parameter}) gives \nthe corresponding twistor line parametrised by $[\\pi]\\in\\CP^1$ \n\\be\n\\label{sl3curves}\np^{\\alpha}=[(z_{B'} \\pi^{B'})x^{A'}-\\pi^{A'}, z_{B'} \\pi^{B'}], \\quad l_\\alpha=[\\pi_{A'}, -\\pi_{B'} x^{B'}],\n\\ee\nwhere the spinor indices are raised and lowered with $\\epsilon^{AB}$ and its inverse.\n\nWe shall now derive the expression for the conformal structure using the nonlinear graviton prescription described in Section \\ref{sec:ASD'ty}. To compute the normal bundle, let $([l(\\pi, P, L)], \n[p(\\pi, P, L)])$\nbe the twistor line corresponding to a point $m=(P, L)$ in $M$. The vector in the direction of a nearby point $(P+\\delta P,L+\\delta L)$ corresponds to the neighbouring line $([l+\\delta l], [p+\\delta p])$, where from (\\ref{eq:l=Pwedgepi}) and (\\ref{eq:p=Lwedgel}) we have\n\\[\n\\delta l=\\delta P\\wedge \\pi, \\quad\n\\delta p= (\\delta L\\cdot \\pi)P+(L\\cdot\\pi) \\delta P-\\delta (L\\cdot P)\\pi.\n\\]\n\nThe lines  $(l+\\delta l, p+\\delta p)$  and $(l, p)$ define a section of the normal bundle to $(l,p)$, which has a zero if and only if this vector is null. Vanishing of the section is equivalent to intersection of the two lines, and this happens if there exists some $[\\pi]$ such that $l+\\delta l\\sim l$ and $p+\\delta p\\sim p$ (note that the intersection point, if it exists, is unique, since projective lines in $\\CP^2$ cannot meet more than once). We thus find\n\\[\nl+\\delta l\\sim l \\quad \\iff \\quad\\pi\\sim\\delta P=[\\delta x^{0'}, \\delta x^{1'}, 0].\n\\]\nAnd $p+\\delta p\\sim p \\quad \\iff$\n\\[\n0=p\\wedge \\delta p=(L\\cdot \\pi)^2P\\wedge \\delta P-(L\\cdot P)\n(\\delta L\\cdot \\pi)\\pi\\wedge P-(L\\cdot \\pi)\\delta (L\\cdot P)P\\wedge \\pi-\n(L\\cdot P)(L\\cdot \\pi) \\pi\\wedge \\delta P.\n\\]\nSubstituting $\\pi\\sim\\delta P$, we find that all terms on the right hand side are proportional to $P\\wedge \\delta P=[0, 0, x^{B'} dx_{B'}]$, with\n\\[\n(L\\cdot \\delta P)^2-(L\\cdot \\delta P)\\delta(L\\cdot P)+(L\\cdot P)(\\delta L\\cdot \\delta P)=0.\n\\]\nSetting $L\\cdot P=1$ this gives the conformal structure \n(\\ref{dm_metric}).\n%\\mynote{Is it possible to write this in the language of vectors, like we do in the mini--twistor section? To make it about a section of the normal bundle rather than the neighbouring line? I guess you'd divide (\\ref{sl3curves}) by $\\pi^{0'}$ like we do in the minitwistor section.}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Pseudo--hyper--Hermitian structure on $M$}\nA pseudo--hyper--complex structure on a four manifold $M$ is a triple of endomorphisms\n$I_1, I_2, I_3$ of $TM$ which satisfy\n\\[\nI_1^2=-Id, \\quad I_2^2=I_3^2=Id, \\quad I_1I_2I_3=Id,\n\\]\nand such that $c_1I_1+c_2I_2+c_3I_3$ is an integrable complex structure for any point \non the hyperboloid $c_1^2-c_2^2-c_3^2=1$.\nA neutral signature metric $g$ on a pseudo--hyper--complex four--manifold is pseudo--hyper--Hermitian\nif\n\\[\ng(\\xi, \\xi)=g(I_1\\xi, I_1\\xi)=-g(I_2\\xi, I_2\\xi)=-g(I_3\\xi, I_3\\xi)\n\\]\nfor any vector field $\\xi$ on $M$.\n\nGiven a pseudo--hyper--complex structure $(M,\\{I_1,I_2,I_3\\})$ and any vector field $\\xi$ on $M$, the frame $(\\xi,I_1\\xi,I_2\\xi,I_3\\xi)$ defines a conformal structure on $M$. With a natural choice of orientation\nwhich makes the fundamental two--forms of $I_1, I_2, I_3$  self--dual, \nthis conformal structure is ASD.\n\nLet $\\Sigma^{A'B'}$ be a basis of SD two--forms on $M$. The following result is proved in \\cite{D99} (see also \\cite{boyer}) in the Riemannian (i.e. hyper--complex) case.\n\\begin{theo}[\\cite{D99}]\\label{thm:D99}\nA four--manifold $M$ equipped with a neutral signature metric $g$ is pseudo--hyper--Hermitian if there exists a one--form $A$ depending only on $g$ such that\n\\[\nd\\Sigma^{A'B'}+A\\wedge \\Sigma^{A'B'} = 0.\n\\]\n\\end{theo}\n\\noindent In fact, this condition is necessary and sufficient for hyper--Hermiticity \\cite{D99,boyer}. Given some $(M,g)$ which is conformally ASD, it can also be shown (see Lemma 2 in \\cite{D99} and Theorem  7.1 in \\cite{Cal2}) that a lack of vertical $\\p/\\p \\pi$ terms in the twistor distribution (\\ref{eq:twistor_dist}) implies hyper--Hermiticity of $(M,g)$. %\\mynote{This is not clear to me from a brief look at \\cite{D99,Cal2}...}\n\\begin{prop}\n\\label{propHH}\nThe Einstein metric (\\ref{special_ein}) is pseudo--hyper--Hermitian.\n\\end{prop}\n\\noindent\n{\\bf Proof.}\nThe null frame for the 4-metric is\n\\be \\label{eq:null_frame}\ne^{0A'}=dx^{A'}, \\quad e^{1A'}=dz^{A'}+z^{A'}(z_{B'} dx^{B'}), \\quad\\mbox{so that}\\quad\ng=\\varepsilon_{A'B'}\\varepsilon_{AB}e^{AA'}e^{BB'}.\n\\ee\nThus the forms $\\Sigma=dx^{0'}\\wedge dx^{1'}$ and $\\Omega=dz_{A'}\\wedge dx^{A'}$ are ASD. The basis of SD two forms is spanned by\n\\[\ndx\\wedge dq+ q^2 dx\\wedge dy,\\quad\ndx\\wedge dp-dy\\wedge dq+2 pq dx\\wedge dy,\n\\quad\n-dy\\wedge dp+ p^2 dx\\wedge dy\n\\]\nor, in a more compact notation, by\n$\\Sigma^{A'B'}=dx^{(A'}\\wedge dz^{B')}+z^{A'}z^{B'} \\Sigma$.\nWe can verify that\n\\be\n\\label{lie_form}\nd\\Sigma^{A'B'}+2{{\\mathcal{A}}}\\wedge\\Sigma^{A'B'}=0,\n\\ee\nwhere ${{\\mathcal A}}= z_{A'}dx^{A'}$ is such that $d{{\\mathcal{A}}}= \\Omega$,\nso from Theorem \\ref{thm:D99} we have that $M$ carries a hyper--Hermitian structure, and in fact the corresponding ASD Maxwell field $d\\mathcal{A}=\\Omega$ coincides with the one arising from the para--K\\\"ahler structure on $M$ via (\\ref{beta_eq}).\n\nAlternatively, note that the twistor distribution (\\ref{eq:twistor_dist}), having chosen the basis (\\ref{eq:null_frame}), is given by\n\\be\n\\label{tdistribution}\nL_{0}=\\pi^{A'}\\frac{\\p}{\\p x^{A'}}+(z_{B'}\\pi^{B'}) z_{A'}\\frac{\\p}{\\p z_{A'}}, \\quad\nL_{1}=\\pi_{A'}\\cdot\\frac{\\p}{\\p z_{A'}},\n\\ee\nwhich have no vertical terms. We can easily verify that it is Frobenius integrable, as $[L_{0}, L_{1}]=-(\\pi^{A'} z_{A'})L_{1}$. The SD part of the\nspin connection is given in terms of ${\\mathcal A}$ as\n$\\Gamma_{AA'B'C'}=-2{\\mathcal A}_{A(B'}\\varepsilon_{C')A'}$.\n\\koniec\nIn the next section we shall show how to encode\n${\\mathcal A}$ in the twisted--photon Ward bundle over the twistor space\nof $(M, g)$.\n\n\\subsection{A line bundle over the twistor space of $M$}\n%\\mynote{Still not 100 per cent sure I have got this right. Does it matter what $\\mathbb{C}^*$ bundle over $\\mathscr{T}$ we are talking about? What would happen if we instead regarded $\\mathscr{T}$ as $\\PP(T\\CP^2)$, and used our parametrisation (\\ref{sl3curves}) but projectivised the $l$ part instead of the $p$ part?}\nWard \\cite{wardtf} shows that there is a correspondence between ASD Maxwell potentials on $M$ and $\\mathbb{C}^*$ bundles over $\\mathscr{T}$ which are trivial on twistor lines\\footnote{Recall that a principal bundle $\\PP\\rightarrow\\mathscr{T}$ with structure group $G$ is trivial if there exists a map $\\chi:\\PP\\rightarrow\\mathscr{T}\\times G$. Let $\\{\\chi_\\alpha:\\mathcal{U}_\\alpha\\rightarrow\\mathscr{T}\\times G\\}$ be local trivialisations related by transition functions $F_{\\alpha\\beta}=\\chi_\\beta\\circ\\chi^{-1}_\\alpha\\in G$. If $F_{\\alpha\\beta}=f_\\beta f_\\alpha^{-1}$ for some splitting elements $f_\\alpha,f_\\beta\\in G$ on $\\mathcal{U}_\\alpha,\\mathcal{U}_\\beta$ respectively, then there exist $\\tilde{\\chi}_\\alpha=f_\\alpha^{-1}\\circ\\chi_\\alpha$ and $\\tilde{\\chi}_\\beta=f_\\beta^{-1}\\circ\\chi_\\beta$ such that $\\tilde{F}_{\\alpha\\beta}=f_\\beta^{-1}f_\\beta f_\\alpha^{-1}f_\\alpha=Id$, so that the bundle is trivial.}. The purpose of this section is to uncover the $\\mathbb{C}^*$ bundle over $\\mathscr{T}$ corresponding to the ASD Maxwell potential $\\mathcal{A}=z_{A'}dx^{A'}$ on $M$.\n\nThe twistor space $F_{12}$ described in Section \\ref{twist_SSS} can be identified with the projectivised tangent bundle ${\\PP(T\\CP_2)}$ of the minitwistor space of the flat projective structure, since a point $(p,l)$ in $F_{12}\\subset\\CP^2\\times\\CP_2$ consists of a point $l\\in\\CP_2$, and a line $p\\subset\\CP_2$ through $l$ which we can identify with a direction in the tangent space $T_l\\CP_2$. Thus the twistor space of $M$ is the correspondence space (in a twistorial sense) of $\\CP^2$ and its twistor space $\\CP_2$. An obvious $\\mathbb{C}^*$ bundle over ${\\PP(T\\CP_2)}$ is $T\\CP_2$.\n\n\\begin{prop}\nThe $\\mathbb{C}^*$ bundle $T\\CP_2\\rightarrow\\PP(T\\CP_2)=F_{12}$ is trivial on twistor lines, and corresponds via Ward's twisted photon construction to the ASD Maxwell potential $\\mathcal{A}$ on $M$.\n\\end{prop}\n \n\\noindent {\\bf Proof.} There are many open sets needed to cover\n$\\PP(T\\CP_2)$, but it is sufficient to consider two:\n$\\mathcal{U}$, where $(l_1, \\neq 0, p^2\\neq 0)$, and $(l_2/l_1, l_3/l_1, p^3/p^2)$ are coordinates, and $\\widetilde{\\mathcal{U}}$ where\n$(l_1\\neq 0, p^3\\neq 0)$, and  $(l_2/l_1, l_3/l_1, p^2/p^3)$\nare coordinates. Now consider the total\nspace of $T\\CP_2$% (or perhaps it is $T\\CP_2$ tensored with some power of the canonical bundle to make it trivial on twistor lines) \\mynote{by the canonical bundle we mean the bundle of volume forms.}\n, and restrict it to the intersection of (pre--images in\n$T\\CP_2$\nof) $\\mathcal{U}$ and $\\widetilde{\\mathcal{U}}$. The coordinates on $T\\CP_2$ in these\nregion are $(l_2/l_1, l_3/l_1, p^2/p^1, p^3/p^1)$, and the fibre\ncoordinates over $\\tau$ over $\\mathcal{U}$ and $\\tilde{\\tau}$ over \n$\\widetilde{\\mathcal{U}}$ are related by\\footnote{Here we are following Ward \\cite{wardtf},\nand thinking of a $\\mathbb{C}^*$ bundle.}\n\\[\n\\tilde \\tau=\\exp(F)\\tau, \\quad\\mbox{where}\\quad  \nF=\\ln{(p_2/p_3)}.\n\\]\n\nNow we follow the procedure of \\cite{wardtf}: restrict $F$ to a twistor line,\nand split it.\nThe holomorphic splitting is $F=f-\\widetilde{f}$, where\n$f=\\ln{(p_2)}$ is holomorphic in the pre--image of $\\mathcal{U}$ in the correspondence space, and \n$\\widetilde{f}=\\ln{(p_3)}$ is holomorphic in the pre--image of\n$\\widetilde{\\mathcal{U}}$. Note that $F$ is a twistor  function, but \n$f, \\widetilde{f}$ are not. Therefore\n$L_{A}F=0$, where the twistor distribution $L_{A}$\nis given by (\\ref{tdistribution}). This implies that $L_{A}f=L_{A}\\widetilde{f}$. Since each side of this equation is holomorphic on an open subset of $\\CP^1$, and since $\\CP^1$ can be covered with such subsets, both sides are globally holomorphic and therefore linear in $\\pi^{A'}$ by the Liouville theorem. Hence\n\\[\nL_{A}f=L_{A}\\widetilde{f}=\\pi^{A'}\\mathcal{A}_{AA'}\n\\]\nfor some one--form $\\mathcal{A}$ on $M$.\n\nTo construct this one--form recall the parametrisation\nof twistor curves (\\ref{sl3curves}). This gives\n\\[\nf=\\ln{(z_{A'}\\pi^{A'})}, \\quad\\widetilde{f}=\\ln{((z_{A'}\\pi^{A'})x^{1'}-\\pi^{1'})}\n\\]\nand\n\\[\nL_{1}(f)=L_{1}(\\widetilde{f})=0, \\quad\nL_{0}(f)=L_{0}(\\widetilde{f})=\\pi^{A'} z_{A'}.\n\\]\nTherefore ${\\mathcal A}_{1A'}=0, {\\mathcal A}_{0A'}=z_{A'}$\nwhich gives ${\\mathcal A}=z_{A'}dx^{A'}$, and $d{\\mathcal A}$\nis indeed the ASD para--K\\\"ahler structure $\\Omega$.\n\\koniec\n%which I THINK is \n%\\be\n%\\label{ptp}\n%p=[p^1, p^2, p^3], \\quad Z=-\\frac{p^3}{p^2}=\\frac{z^0+X %z^1}{-1+(z^0+X z^1)x^1}.\n%\\ee\n\\subsection{Factoring the model to Einstein--Weyl}\n\\label{neat2}\nAs stated above, we expect distinct Einstein--Weyl structures if we factor $M$ by conformal Killing vectors which are not conjugate with respect to an isometry \\cite{PT}. We can thus classify the Einstein--Weyl structures obtainable from the model by first classifying its symmetries up to conjugation.\n\\begin{prop}\nThe non--trivial Einstein--Weyl structures obtainable from the ASD Einstein metric (\\ref{special_ein}) by the Jones--Tod correspondence consist of a two parameter family, and two additional cases which do not belong to this family.\n\\end{prop}\n\\noindent\n{\\bf Proof. }Since we have an isomorphism between the Lie algebra of projective vector fields on $(N,[\\nabla])$ and the Lie algebra of Killing vectors on $(M,g)$, the problem of classifying the symmetries of (\\ref{special_ein}) is reduced to a classification of the infinitesimal  projective symmetries of $\\RP^2$, i.e. the near--identity elements of $SL(3,\\R)$, up to conjugation.\n\nNon--singular complex matrices are determined up to similarity by their Jordan normal form (JNF). While real matrices do not have such a canonical form, all of the information they contain is determined (up to similarity) by the JNF that they would have if they were considered as complex matrices. Thus we can still discuss the JNF of a real matrix, even if it cannot always be obtained from the real matrix by a real similarity transformation. The possible non--trivial Jordan normal forms of matrices in $SL(3,\\R)$ are shown below.\n\\[\n\\begin{pmatrix}l_1 & 0 & 0\\\\\n0 & l_2 & 0\\\\\n0 & 0 & 1/l_1l_2\n\\end{pmatrix}\n\\quad\n\\begin{pmatrix} l & 0 & 0\\\\\n0 &  l & 0\\\\\n0 & 0 & 1/ l^2\n\\end{pmatrix}\n\\quad\n\\begin{pmatrix} l & 1 & 0\\\\\n0 &  l & 0\\\\\n0 & 0 & 1/ l^2\n\\end{pmatrix}\n\\quad\n\\begin{pmatrix}1 & 1 & 0\\\\\n0 & 1 & 0\\\\\n0 & 0 & 1\n\\end{pmatrix}\n\\quad\n\\begin{pmatrix}1 & 1 & 0\\\\\n0 & 1 & 1\\\\\n0 & 0 & 1\n\\end{pmatrix}\n\\]\n\nIt is possible that two matrices in $SL(3,\\R)$ with the same JNF may be related by a complex similarity transformation, and thus not conjugate in $SL(3,\\R)$. However, if the JNF is a real matrix, then the required similarity transformation just consists of the eigenvectors and generalised eigenvectors of the matrix, which must also be real since they are defined by real linear simultaneous equations. This means we only have to worry about matrices with complex eigenvalues, and since these occur in complex conjugate pairs, they will only be a problem when we have three distinct eigenvalues.\n\nIn this case, we can always make a real similarity transformation such that the matrix is block diagonal, with the real eigenvalue in the bottom right. Then we have limited choice from the $2\\times 2$ matrix in the top left. Let us parametrise such a $2\\times 2$ matrix by $a,\\,b,\\,c,\\,d\\in\\mathbb{R}$ as follows:\n\\[\n\\quad\n\\begin{pmatrix}1+a\\epsilon & b\\epsilon \\\\\nc\\epsilon & 1+d\\epsilon \n\\end{pmatrix}.\n\\]\nThis has characteristic polynomial\n\\[\n\\chi( l)= l^2-(2+\\epsilon(a+d)) l+1+(a+d)\\epsilon+(ad-bc)\\epsilon^2.\n\\]\nEvidently the important degrees of freedom are $a+d$ and $ad-bc$, so we can use these to encode every near--identity element of the class with three distinct eigenvalues. The bottom--right entry will be determined by our choice of $a+d$ and $ad-bc$.\n\nTaking a projective vector field on $\\mathbb{RP}^2$, we can find the corresponding Killing vector of (\\ref{special_ein}) using (\\ref{eq:kvf_from_pvf}), and factor to Einstein--Weyl using (\\ref{EWgen}). We find by explicit calculation that vector fields arising from the second and fourth JNFs above give trivial Einstein--Weyl structures, so restricting to the non--trivial cases we have a two parameter family of Einstein--Weyl structures coming from the first class, and two additional Einstein--Weyl structures coming from the third and fifth, as claimed.\n\\koniec\n\n\n%\\mynote{Give the example corresponding to the mini--twistor factorisation below.}\n\\subsection{An example of the mini--twistor correspondence}\n\\label{mini_twistor}\nBelow we investigate a one parameter subfamily of the two parameter family. We use the holomorphic vector field on \nthe twistor space\n$F_{12}$  (see Section \\ref{twist_SSS})\ncorresponding to the chosen symmetry, and reconstruct the conformal structure $[h]$ on $\\mathcal{W}$ using minitwistor curves \n(in the sense of \\cite{hitchin})\non the space of orbits. Take $a\\in \\mathbb{R}$ and\n\\be\n\\label{modelK}\nK=P^1\\frac{\\partial}{\\partial P^1} - L_1\\frac{\\partial}{\\partial L_1}+aP^2\\frac{\\partial}{\\partial P^2} - aL_2\\frac{\\partial}{\\partial L_2},\n\\ee\n%corresponding to the matrix\n%\\[\n%M=\n%\\begin{pmatrix}1+\\epsilon & 0 & 0\\\\\n%0 & 1+a\\epsilon & 0\\\\\n%0 & 0 & 1\n%\\end{pmatrix}.\n%\\]\n%Note that we have chosen inhomogeneous coordinates, so $M$ need not be in $SL(3)$.\nIn order to preserve the relations\n\\[\np\\cdot L=0,\\quad P\\cdot l=0,\\quad p\\cdot l=0, \n\\]\nthe corresponding holomorphic action on $(p,l)$ must be $p\\mapsto gp$, $l\\mapsto lg^{-1}$, thus the holomorphic vector field $ K_\\mathscr{T}$ on $F_{12}$ is\n\\[\n K_\\mathscr{T}=p^1\\frac{\\partial}{\\partial p^1} - l_1\\frac{\\partial}{\\partial l_1}+ap^2\\frac{\\partial}{\\partial p^2} - al_2\\frac{\\partial}{\\partial l_2}.\n\\]\n\nIn order to factor $F_{12}$ by this vector field, we must find invariant minitwistor coordinates $(Q,R)$. In addition to satisfying $ K_\\mathscr{T}(Q)= K_\\mathscr{T}(R)=0$, they must be homogeneous of degree zero in $(P,L)$. We choose\n\\[\nQ=\\frac{p^1l_1}{p^2l_2},\\quad R=\\frac{(l_1)^a}{l_2(l_3)^{a-1}}.\n\\]\nSubstituting in our parametrisation (\\ref{sl3curves}) and using the freedom to perform a Möbius transformation on $\\pi$, we obtain\n\\begin{align}\n\\label{QR}\nQ &= \\frac{(\\lambda z-r-1)\\lambda}{w\\lambda+\\lambda-\\frac{rw}{z}}\\\\\nR &= \\lambda^a\\Big(-\\lambda-\\frac{w}{z}\\Big)^{1-a},\\nonumber\n\\end{align}\nwhere we have defined $\\lambda=\\pi_{0'}/\\pi_{1'}$, and the Einstein--Weyl coordinates\n\\[\nr=xp,\\quad w=yq, \\quad z=x^aq.\n\\]\nNote these are invariants of the Killing vector (\\ref{modelK}).\n\nNext we wish to use these minitwistor curves to reconstruct the conformal structure of the Einstein--Weyl space. In doing so we follow \\cite{PT}. The tangent vector field to a fixed curve is given by\n\\[\n\\xi_T=\\frac{\\p Q}{\\p \\lambda} \\frac{\\p}{\\p Q} + \\frac{\\p R}{\\p \\lambda} \\frac{\\p}{\\p R},\n\\]\nHence we can write the normal vector field as\n\\begin{align*}\n\\xi_\\mathbb{N} &=dQ\\frac{\\p}{\\p Q} + dR\\frac{\\p}{\\p R} \\enskip \\mathrm{mod}\\, \\xi_T\\\\\n&= \\bigg(\\frac{\\p R}{\\p \\lambda}\\bigg)^{-1}\\bigg(dQ\\frac{\\p R}{\\p \\lambda}-dR\\frac{\\p Q}{\\p \\lambda}\\bigg)\\frac{\\p}{\\p Q},\n\\end{align*}\nwhere\n\\[\ndQ=\\frac{\\p Q}{\\p r}dr + \\frac{\\p Q}{\\p w}dw + \\frac{\\p Q}{\\p z}dz\n\\]\nand similarly for $dR$. Calculating $\\xi_\\mathbb{N}$ using (\\ref{QR}), we find\n\\[\n\\xi_\\mathbb{N}\\propto(\\eta_1\\lambda^2+\\eta_2\\lambda+\\eta_3)\\frac{\\p}{\\p Q},\n\\]\nwhere\n\\begin{align*}\n\\eta_1 &= z^2(w+1)dz-z^3dw, \\\\\n\\eta_2 &= -2zrwdz + z^2(a+2r)dw -z^2dr, \\\\\n\\eta_3 &= rw(1+r)dz - zr(1+r)dw - azwdr.\n\\end{align*}\nThe discriminant of this quadratic in $\\lambda$ then gives a representative $h\\in[h]$ of our conformal structure:\n\\be\n\\begin{split}\nh=4(r^2w+rw^2+rw)dz^2 - 4zw(a(w+1)+r)dzdr + 4zr(r-aw+2w+1)dzdw \\\\\n-z^2dr^2 + 2z^2(2aw+a+2r)dwdr - z^2(a^2+4r(a-1))dw^2.\n\\end{split}\n\\ee\nThis is the same conformal structure that we obtain by Jones-Tod factorisation of the metric (\\ref{special_ein}) by (\\ref{modelK}) using the formula (\\ref{EWgen}).", "meta": {"hexsha": "40660301bb1e7dc4c95e131c1cbefeb47d7417bb", "size": 70473, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter5/EW_and_toda.tex", "max_stars_repo_name": "AliceWaterhouse/thesis", "max_stars_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter5/EW_and_toda.tex", "max_issues_repo_name": "AliceWaterhouse/thesis", "max_issues_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter5/EW_and_toda.tex", "max_forks_repo_name": "AliceWaterhouse/thesis", "max_forks_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.0241312741, "max_line_length": 1175, "alphanum_fraction": 0.7050927305, "num_tokens": 23605, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.44882744143355874}}
{"text": "\\hypertarget{distributions}{%\n\\chapter{Distributions}\\label{distributions}}\n\nIn this chapter we'll see three ways to describe a set of values:\n\n\\begin{itemize}\n\\item\n  A probability mass function (PMF), which represents a set of values\n  and the number of times each one appears in a dataset.\n\\item\n  A cumulative distribution function (CDF), which contains the same\n  information as a PMF in a form that makes it easier to visualize, make\n  comparisons, and perform some computations.\n\\item\n  A kernel density estimate (KDE), which is like a smooth, continuous\n  version of a histogram.\n\\end{itemize}\n\nFor examples, we'll use data from the General Social Survey (GSS) to\nlook at distributions of age and income, and to explore the relationship\nbetween income and education.\n\nBut we'll start with one of the most important ideas in statistics, the\ndistribution.\n\n\\hypertarget{distributions-1}{%\n\\section{Distributions}\\label{distributions-1}}\n\nA distribution is a set of values and their corresponding probabilities.\nFor example, if you roll a six-sided die, there are six possible\noutcomes, the numbers \\passthrough{\\lstinline!1!} through\n\\passthrough{\\lstinline!6!}, and they all have the same probability,\n\\passthrough{\\lstinline!1/6!}.\n\nWe can represent this distribution of outcomes with a table, like this:\n\n\\begin{longtable}[]{@{}ll@{}}\n\\toprule\nValue & Probability\\tabularnewline\n\\midrule\n\\endhead\n1 & 1/6\\tabularnewline\n2 & 1/6\\tabularnewline\n3 & 1/6\\tabularnewline\n4 & 1/6\\tabularnewline\n5 & 1/6\\tabularnewline\n6 & 1/6\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nMore generally, there can be any number of values, the values can be any\ntype, and the probabilities do not have to be equal.\n\nTo represent distributions in Python, we will use a library called\n\\passthrough{\\lstinline!empiricaldist!}, for ``empirical distribution'',\nwhich means it is based on data rather than a mathematical formula.\n\n\\passthrough{\\lstinline!empiricaldist!} provides an object called\n\\passthrough{\\lstinline!Pmf!}, which stands for ``probability mass\nfunction''. A \\passthrough{\\lstinline!Pmf!} object contains a set of\npossible outcomes and their probabilities.\n\nFor example, here's a \\passthrough{\\lstinline!Pmf!} that represents the\noutcome of rolling a six-sided die:\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom empiricaldist import Pmf\n\noutcomes = [1,2,3,4,5,6]\ndie = Pmf(1/6, outcomes)\n\\end{lstlisting}\n\nThe first argument is the probability of each outcome; the second\nargument is the list of outcomes. We can display the result like this.\n\n\\begin{lstlisting}[language=Python,style=source]\ndie\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &     probs \\\\\n\\midrule\n1 &  0.166667 \\\\\n2 &  0.166667 \\\\\n3 &  0.166667 \\\\\n4 &  0.166667 \\\\\n5 &  0.166667 \\\\\n6 &  0.166667 \\\\\n\\bottomrule\n\\end{tabular}\n\nA \\passthrough{\\lstinline!Pmf!} object is a specialized version of a\nPandas \\passthrough{\\lstinline!Series!}, so it provides all of the\nattributes and methods of a \\passthrough{\\lstinline!Series!}, plus some\nadditional methods we'll see soon.\n\n\\hypertarget{the-general-social-survey}{%\n\\section{The General Social Survey}\\label{the-general-social-survey}}\n\nThe examples in this chapter are based on a new dataset, the General\nSocial Survey (GSS). The GSS has run annually since 1972; it surveys a\nrepresentative sample of adult residents of the U.S. and asks questions\nabout demographics, personal history, and beliefs about social and\npolitical issues.\n\nIt is widely used by politicians, policy makers, and researchers,\nincluding me. The GSS dataset contains hundreds of columns; using an\nonline tool call \\href{https://gssdataexplorer.norc.org/}{GSS Explorer}\nI've selected just a few and created a data extract.\n\nLike the NSFG data we used in the previous chapter, the GSS data is\nstored in a fixed-width format, described by a Stata data dictionary.\n\n\\begin{lstlisting}[language=Python,style=source]\ndict_file = 'GSS.dct'\ndata_file = 'GSS.dat.gz'\n\\end{lstlisting}\n\nWe will use the \\passthrough{\\lstinline!statadict!} library to read the\ndata dictionary.\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom statadict import parse_stata_dict\n\nstata_dict = parse_stata_dict(dict_file)\n\\end{lstlisting}\n\nThe data file is compressed, but we can use the\n\\passthrough{\\lstinline!gzip!} library to open it.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport gzip\n\nfp = gzip.open(data_file)\n\\end{lstlisting}\n\nThe result is an object that behaves like a file, so we can pass it as\nan argument to \\passthrough{\\lstinline!read\\_fwf!}:\n\n\\begin{lstlisting}[language=Python,style=source]\nimport pandas as pd\n\ngss = pd.read_fwf(fp, \n                  names=stata_dict.names, \n                  colspecs=stata_dict.colspecs)\ngss.shape\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(64814, 8)\n\\end{lstlisting}\n\nThe result is a \\passthrough{\\lstinline!DataFrame!} with 64818 rows, one\nfor each respondent, and 6 columns, one for each variable. Here are the\nfirst few rows.\n\n\\begin{lstlisting}[language=Python,style=source]\ngss.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lrrrrrrrr}\n\\toprule\n{} &  YEAR &  ID\\_ &  AGE &  EDUC &  SEX &  GUNLAW &  GRASS &  REALINC \\\\\n\\midrule\n0 &  1972 &    1 &   23 &    16 &    2 &       1 &      0 &  18951.0 \\\\\n1 &  1972 &    2 &   70 &    10 &    1 &       1 &      0 &  24366.0 \\\\\n2 &  1972 &    3 &   48 &    12 &    2 &       1 &      0 &  24366.0 \\\\\n3 &  1972 &    4 &   27 &    17 &    2 &       1 &      0 &  30458.0 \\\\\n4 &  1972 &    5 &   61 &    12 &    2 &       1 &      0 &  50763.0 \\\\\n\\bottomrule\n\\end{tabular}\n\nYou can probably guess what the variables are, and I'll explain them as\nwe go along. But if you want more information, you can always read the\ncodebook at\n\\url{https://gssdataexplorer.norc.org/projects/52787/variables/vfilter}.\n\n\\hypertarget{distribution-of-education}{%\n\\section{Distribution of Education}\\label{distribution-of-education}}\n\nTo get started with this dataset, let's look at the distribution of\n\\passthrough{\\lstinline!EDUC!}, which records the number of years of\neducation for each respondent. First I'll select a column from the\n\\passthrough{\\lstinline!DataFrame!} and use\n\\passthrough{\\lstinline!value\\_counts!} to see what values are in it.\n\n\\begin{lstlisting}[language=Python,style=source]\ngss['EDUC'].value_counts().sort_index()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &   EDUC \\\\\n\\midrule\n0  &    165 \\\\\n1  &     47 \\\\\n2  &    152 \\\\\n3  &    257 \\\\\n4  &    319 \\\\\n5  &    402 \\\\\n6  &    828 \\\\\n7  &    879 \\\\\n8  &   2724 \\\\\n9  &   2083 \\\\\n10 &   2880 \\\\\n11 &   3743 \\\\\n12 &  19663 \\\\\n13 &   5360 \\\\\n14 &   7160 \\\\\n15 &   2910 \\\\\n16 &   8355 \\\\\n17 &   1967 \\\\\n18 &   2384 \\\\\n19 &    920 \\\\\n20 &   1439 \\\\\n98 &     73 \\\\\n99 &    104 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe result from \\passthrough{\\lstinline!value\\_counts!} is a set of\npossible values and the number of times each one appears, so it is a\nkind of distribution.\n\nThe values \\passthrough{\\lstinline!98!} and \\passthrough{\\lstinline!99!}\nare special codes for ``Don't know'' and ``No answer''. We'll use\n\\passthrough{\\lstinline!replace!} to replace these codes with\n\\passthrough{\\lstinline!NaN!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport numpy as np\n\neduc = gss['EDUC'].replace([98, 99], np.nan)\n\\end{lstlisting}\n\nWe've already seen one way to visualize a distribution, a histogram.\nHere's the histogram of education level.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport matplotlib.pyplot as plt\n\neduc.hist(grid=False)\nplt.xlabel('Years of education')\nplt.ylabel('Number of respondents')\nplt.title('Histogram of education level');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_36_0.pdf}\n\\end{center}\n\nBased on the histogram, we can see the general shape of the distribution\nand the central tendency -- it looks like the peak is near 12 years of\neducation. But a histogram is not the best way to visualize this\ndistribution.\n\nAn alternative is a \\passthrough{\\lstinline!Pmf!}.\n\\passthrough{\\lstinline!Pmf!} provides a function called\n\\passthrough{\\lstinline!from\\_seq!} that takes any kind of sequence --\nlike a list, tuple, or Pandas \\passthrough{\\lstinline!Series!} -- and\ncomputes the distribution of the values in the sequence.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ = Pmf.from_seq(educ, normalize=False)\ntype(pmf_educ)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\nempiricaldist.empiricaldist.Pmf\n\\end{lstlisting}\n\nThe keyword argument \\passthrough{\\lstinline!normalize=False!} indicates\nthat we don't want to normalize this PMF. I'll explain what that means\nsoon.\n\nHere's what the first few rows look like.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  probs \\\\\n\\midrule\n0.0 &    165 \\\\\n1.0 &     47 \\\\\n2.0 &    152 \\\\\n\\bottomrule\n\\end{tabular}\n\nIn this dataset, there are \\passthrough{\\lstinline!165!} respondents who\nreport that they have had no formal education, and\n\\passthrough{\\lstinline!47!} who have only one year. Here the last few\nrows.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ.tail()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  probs \\\\\n\\midrule\n18.0 &   2384 \\\\\n19.0 &    920 \\\\\n20.0 &   1439 \\\\\n\\bottomrule\n\\end{tabular}\n\nThere are \\passthrough{\\lstinline!1439!} respondents who report that\nthey have 20 or more years of formal education, which probably means\nthey attended college and graduate school.\n\nYou can use the bracket operator to look up a value in a Pmf and get the\ncorresponding count:\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ[20]\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n1439\n\\end{lstlisting}\n\nUsually when we make a PMF, we want to know the \\emph{fraction} of\nrespondents with each value, rather than the counts. We can do that by\nsetting \\passthrough{\\lstinline!normalize=True!}; then we get a\nnormalized PMF, that is, a PMF where the values in the second column add\nup to 1.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ_norm = Pmf.from_seq(educ, normalize=True)\npmf_educ_norm.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &     probs \\\\\n\\midrule\n0.0 &  0.002553 \\\\\n1.0 &  0.000727 \\\\\n2.0 &  0.002352 \\\\\n\\bottomrule\n\\end{tabular}\n\nNow if we use the bracket operator, the result is a fraction. For\nexample, the fraction of people with 12 years of education is about\n30\\%:\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ_norm[16]\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.12926033077030183\n\\end{lstlisting}\n\n\\passthrough{\\lstinline!Pmf!} provides a \\passthrough{\\lstinline!bar!}\nmethod that plots the values and their probabilities as a bar chart.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_educ_norm.bar(label='EDUC')\n\nplt.xlabel('Years of education')\nplt.xticks(range(0, 21, 4))\nplt.ylabel('PMF')\nplt.title('Distribution of years of education')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_50_0.pdf}\n\\end{center}\n\nIn this figure, we can see that the most common value is 12 years, but\nthere are also peaks at 14 and 16, which correspond to two and four\nyears of college.\n\nFor this data, the PMF is probably a better choice than the histogram.\nThe PMF shows all unique values, so we can see where the peaks are.\nBecause the histogram puts values into bins, it obscures some details.\nWith this dataset, and the default number of bins, we couldn't see the\npeaks at 14 and 16 years.\n\nBut PMFs have limitations, too, as we'll see. But first, let's get some\npractice with PMFs.\n\n\\textbf{Exercise:} Let's look at another column in this\n\\passthrough{\\lstinline!DataFrame!}, \\passthrough{\\lstinline!YEAR!},\nwhich represents the year each respondent was interviewed.\n\nMake an unnormalized PMF for \\passthrough{\\lstinline!YEAR!} and display\nthe result. How many respondents were interviewed in 2018?\n\n\\hypertarget{cumulative-distribution-functions}{%\n\\section{Cumulative distribution\nfunctions}\\label{cumulative-distribution-functions}}\n\nNow we'll see another way to represent a distribution, the cumulative\ndistribution function (CDF). \\passthrough{\\lstinline!empiricaldist!}\nprovides a \\passthrough{\\lstinline!Cdf!} object that represents a CDF.\nWe can import it like this:\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom empiricaldist import Cdf\n\\end{lstlisting}\n\nAs an example, suppose we have a sequence of five values:\n\n\\begin{lstlisting}[language=Python,style=source]\nvalues = 1, 2, 2, 3, 5  \n\\end{lstlisting}\n\nHere's the \\passthrough{\\lstinline!Pmf!} of these values.\n\n\\begin{lstlisting}[language=Python,style=source]\nPmf.from_seq(values)\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  probs \\\\\n\\midrule\n1 &    0.2 \\\\\n2 &    0.4 \\\\\n3 &    0.2 \\\\\n5 &    0.2 \\\\\n\\bottomrule\n\\end{tabular}\n\nIf you draw a random value from \\passthrough{\\lstinline!values!}, the\nPMF tells you the chance of getting \\passthrough{\\lstinline!x!}, for any\nvalue of \\passthrough{\\lstinline!x!}. So the probability of the value\n\\passthrough{\\lstinline!1!} is \\passthrough{\\lstinline!1/5!}; the\nprobability of the value \\passthrough{\\lstinline!2!} is\n\\passthrough{\\lstinline!2/5!}; and the probabilities for\n\\passthrough{\\lstinline!3!} and \\passthrough{\\lstinline!5!} are\n\\passthrough{\\lstinline!1/5!} each.\n\nA CDF is similar in the sense that it contains values and their\nprobabilities; the difference is that the probabilities in the CDF are\nthe the cumulative sum of the probabilities in the PMF.\n\nHere's the \\passthrough{\\lstinline!Cdf!} for the same five values.\n\n\\begin{lstlisting}[language=Python,style=source]\nCdf.from_seq(values)\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  probs \\\\\n\\midrule\n1 &    0.2 \\\\\n2 &    0.6 \\\\\n3 &    0.8 \\\\\n5 &    1.0 \\\\\n\\bottomrule\n\\end{tabular}\n\nIf you draw a random value from \\passthrough{\\lstinline!values!},\n\\passthrough{\\lstinline!Cdf!} tells you the chance of getting a value\n\\emph{less than or equal to} \\passthrough{\\lstinline!x!}, for any given\n\\passthrough{\\lstinline!x!}.\n\nSo the \\passthrough{\\lstinline!Cdf!} of \\passthrough{\\lstinline!1!} is\n\\passthrough{\\lstinline!1/5!} because one of the five values in the\nsequence is less than or equal to 1.\n\nThe \\passthrough{\\lstinline!Cdf!} of 2 is \\passthrough{\\lstinline!3/5!}\nbecause three of the five values are less than or equal to 2.\n\nAnd the \\passthrough{\\lstinline!Cdf!} of 5 is\n\\passthrough{\\lstinline!5/5!} because all of the values are less than or\nequal to 5.\n\n\\hypertarget{cdf-of-age}{%\n\\section{CDF of Age}\\label{cdf-of-age}}\n\nNow let's look at a more substantial \\passthrough{\\lstinline!Cdf!}, the\ndistribution of ages for respondents in the General Social Survey.\n\nThe \\href{https://gssdataexplorer.norc.org/variables/53/vshow}{variable\nwe'll use} is \\passthrough{\\lstinline!'AGE'!}. According to the\ncodebook, the range of the values is from \\passthrough{\\lstinline!18!}\nto \\passthrough{\\lstinline!89!}, where \\passthrough{\\lstinline!89!}\nmeans ``89 or older''. The special codes \\passthrough{\\lstinline!98!}\nand \\passthrough{\\lstinline!99!} mean ``Don't know'' and ``Didn't\nanswer''.\n\nI'll use \\passthrough{\\lstinline!replace!} to replace the special codes\nwith \\passthrough{\\lstinline!NaN!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nage = gss['AGE'].replace([98, 99], np.nan)\n\\end{lstlisting}\n\nWe can compute the \\passthrough{\\lstinline!Cdf!} of these values like\nthis:\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_age = Cdf.from_seq(age)\n\\end{lstlisting}\n\n\\passthrough{\\lstinline!Cdf!} provides a method called\n\\passthrough{\\lstinline!plot!} that plots the CDF as a line. Here's what\nit looks like.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_age.plot()\n\nplt.xlabel('Age (years)')\nplt.ylabel('CDF')\nplt.title('Distribution of age');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_68_0.pdf}\n\\end{center}\n\nThe \\(x\\)-axis is the ages, from 18 to 89. The \\(y\\)-axis is the\ncumulative probabilities, from 0 to 1.\n\n\\passthrough{\\lstinline!cdf\\_age!} can be used as a function, so if you\ngive it an age, it returns the corresponding probability (in a NumPy\narray).\n\n\\begin{lstlisting}[language=Python,style=source]\nq = 51\np = cdf_age(q)\np\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\narray(0.63318676)\n\\end{lstlisting}\n\n\\passthrough{\\lstinline!q!} stands for ``quantity'', which is what we\nare looking up. \\passthrough{\\lstinline!p!} stands for probability,\nwhich is the result. In this example, the quantity is age 51, and the\ncorresponding probability is about \\passthrough{\\lstinline!0.63!}. That\nmeans that about 63\\% of the respondents are 51 years old or younger.\n\nThe arrow in the following figure shows how you could read this value\nfrom the CDF, at least approximately.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_age.plot()\n\nx = 17\ndraw_line(p, q, x)\ndraw_arrow_left(p, q, x)\n\nplt.xlabel('Age (years)')\nplt.xlim(x-1, 91)\nplt.ylabel('CDF')\nplt.title('Distribution of age');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_73_0.pdf}\n\\end{center}\n\nThe CDF is an invertible function, which means that if you have a\nprobability, \\passthrough{\\lstinline!p!}, you can look up the\ncorresponding quantity, \\passthrough{\\lstinline!q!}.\n\\passthrough{\\lstinline!Cdf!} provides a method called\n\\passthrough{\\lstinline!inverse!} that computes the inverse of the\ncumulative distribution function.\n\n\\begin{lstlisting}[language=Python,style=source]\np1 = 0.25\nq1 = cdf_age.inverse(p1)\nq1\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\narray(31.)\n\\end{lstlisting}\n\nIn this example, we look up the probability\n\\passthrough{\\lstinline!0.25!} and the result is\n\\passthrough{\\lstinline!31!}.\\\\\nThat means that 25\\% of the respondents are age 31 or less. Another way\nto say the same thing is ``age 31 is the 25th percentile of this\ndistribution''.\n\nIf we look up probability \\passthrough{\\lstinline!0.75!}, it returns\n\\passthrough{\\lstinline!59!}, so 75\\% of the respondents are 59 or\nyounger.\n\n\\begin{lstlisting}[language=Python,style=source]\np2 = 0.75\nq2 = cdf_age.inverse(p2)\nq2\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\narray(59.)\n\\end{lstlisting}\n\nIn the following figure, the arrows show how you could read these values\nfrom the CDF.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_age.plot()\n\nx = 17\ndraw_line(p1, q1, x)\ndraw_arrow_down(p1, q1, 0)\n\ndraw_line(p2, q2, x)\ndraw_arrow_down(p2, q2, 0)\n\nplt.xlabel('Age (years)')\nplt.xlim(x-1, 91)\nplt.ylabel('CDF')\nplt.title('Distribution of age');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_79_0.pdf}\n\\end{center}\n\nThe distance from the 25th to the 75th percentile is called the\n\\textbf{interquartile range}, or IQR. It measures the spread of the\ndistribution, so it is similar to standard deviation or variance.\n\nBecause it is based on percentiles, it doesn't get thrown off by extreme\nvalues or outliers, the way standard deviation does. So IQR is more\n\\textbf{robust} than variance, which means it works well even if there\nare errors in the data or extreme values.\n\n\\textbf{Exercise:} Using \\passthrough{\\lstinline!cdf\\_age!}, compute the\nfraction of the respondents in the GSS dataset that are \\emph{older}\nthan 65.\n\n\\textbf{Exercise:} The distribution of income in almost every country is\nlong-tailed, which means there are a small number of people with very\nhigh incomes. In the GSS dataset, the column\n\\passthrough{\\lstinline!REALINC!} represents total household income,\nconverted to 1986 dollars. We can get a sense of the shape of this\ndistribution by plotting the CDF.\n\nSelect \\passthrough{\\lstinline!REALINC!} from the\n\\passthrough{\\lstinline!gss!} dataset, make a\n\\passthrough{\\lstinline!Cdf!} called\n\\passthrough{\\lstinline!cdf\\_income!}, and plot it. Remember to label\nthe axes!\n\n\\hypertarget{comparing-distributions}{%\n\\section{Comparing distributions}\\label{comparing-distributions}}\n\nSo far we've seen two ways to represent distributions, PMFs and CDFs.\nNow we'll use PMFs and CDFs to compare distributions, and we'll see the\npros and cons of each.\n\nOne way to compare distributions is to plot multiple PMFs on the same\naxes. For example, suppose we want to compare the distribution of age\nfor male and female respondents.\n\nFirst I'll create a Boolean Series that's true for male respondents.\n\n\\begin{lstlisting}[language=Python,style=source]\nmale = (gss['SEX'] == 1)\n\\end{lstlisting}\n\nAnd another that's true for female respondents.\n\n\\begin{lstlisting}[language=Python,style=source]\nfemale = (gss['SEX'] == 2)\n\\end{lstlisting}\n\nNow I can select ages for the male and female respondents.\n\n\\begin{lstlisting}[language=Python,style=source]\nmale_age = age[male]\nfemale_age = age[female]\n\\end{lstlisting}\n\nAnd plot a Pmf for each.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf_male_age = Pmf.from_seq(male_age)\npmf_male_age.plot(label='Male')\n\npmf_female_age = Pmf.from_seq(female_age)\npmf_female_age.plot(label='Female')\n\nplt.xlabel('Age (years)') \nplt.ylabel('PMF')\nplt.title('Distribution of age by sex')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_90_0.pdf}\n\\end{center}\n\nThe plot is pretty noisy. In the range from 40 to 50, it looks like the\nPMF is higher for men. And from 70 to 80, it is higher for women. But\nboth of those differences might be due to random variation.\n\nNow let's do the same thing with CDFs; everything is the same except we\nreplace \\passthrough{\\lstinline!Pmf!} with\n\\passthrough{\\lstinline!Cdf!}.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_male_age = Cdf.from_seq(male_age)\ncdf_male_age.plot(label='Male')\n\ncdf_female_age = Cdf.from_seq(female_age)\ncdf_female_age.plot(label='Female')\n\nplt.xlabel('Age (years)') \nplt.ylabel('CDF')\nplt.title('Distribution of age by sex')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_92_0.pdf}\n\\end{center}\n\nIn general, CDFs are smoother than PMFs. Because they smooth out\nrandomness, we can often get a better view of real differences between\ndistributions. In this case, the lines are close together until age 40;\nafter that, the CDF is higher for men than women. So what does that\nmean?\n\nOne way to interpret the difference is that the fraction of men below a\ngiven age is generally more than the fraction of women below the same\nage. For example, about 79\\% of men are 60 or less, compared to 76\\% of\nwomen.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_male_age(60), cdf_female_age(60)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(array(0.78599958), array(0.75529908))\n\\end{lstlisting}\n\nGoing the other way, we could also compare percentiles. For example, the\nmedian age woman is older than the median age man, by about one year.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_male_age.inverse(0.5), cdf_female_age.inverse(0.5)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(array(43.), array(44.))\n\\end{lstlisting}\n\n\\textbf{Exercise:} What fraction of men are over 80? What fraction of\nwomen?\n\n\\begin{lstlisting}[language=Python,style=source]\n1-cdf_male_age(80), 1-cdf_female_age(80)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(0.0258566323313012, 0.03806458772611254)\n\\end{lstlisting}\n\n\\hypertarget{income}{%\n\\section{Income}\\label{income}}\n\nAs another example, let's look at household income and compare the\ndistribution before and after 1995 (I chose 1995 because it's roughly\nthe midpoint of the survey). The variable\n\\passthrough{\\lstinline!REALINC!} represents household income in 1986\ndollars.\n\nI'll make a Boolean \\passthrough{\\lstinline!Series!} to select\nrespondents interviewed before and after 1995.\n\n\\begin{lstlisting}[language=Python,style=source]\npre95 = (gss['YEAR'] < 1995)\npost95 = (gss['YEAR'] >= 1995)\n\\end{lstlisting}\n\nNow we can plot the PMFs.\n\n\\begin{lstlisting}[language=Python,style=source]\nincome = gss['REALINC'].replace(0, np.nan)\n\nPmf.from_seq(income[pre95]).plot(label='Before 1995')\nPmf.from_seq(income[post95]).plot(label='After 1995')\n\nplt.xlabel('Income (1986 USD)')\nplt.ylabel('PMF')\nplt.title('Distribution of income')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_102_0.pdf}\n\\end{center}\n\nThere are a lot of unique values in this distribution, and none of them\nappear very often. As a result, the PMF is so noisy and we can't really\nsee the shape of the distribution.\n\nIt's also hard to compare the distributions. It looks like there are\nmore people with high incomes after 1995, but it's hard to tell. We can\nget a clearer picture with a CDF.\n\n\\begin{lstlisting}[language=Python,style=source]\nCdf.from_seq(income[pre95]).plot(label='Before 1995')\nCdf.from_seq(income[post95]).plot(label='After 1995')\n\nplt.xlabel('Income (1986 USD)')\nplt.ylabel('CDF')\nplt.title('Distribution of income')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_104_0.pdf}\n\\end{center}\n\nBelow \\$30,000 the CDFs are almost identical; above that, we can see\nthat the post-1995 distribution is shifted to the right. In other words,\nthe fraction of people with high incomes is about the same, but the\nincome of high earners has increased.\n\nIn general, I recommend CDFs for exploratory analysis. They give you a\nclear view of the distribution, without too much noise, and they are\ngood for comparing distributions, especially if you have more than two.\n\n\\textbf{Exercise:} In the previous figure, the dollar amounts are big\nenough that the labels on the \\passthrough{\\lstinline!x!} axis are\ncrowded. Improve the figure by expressing income in 1000s of dollars\n(and update the \\passthrough{\\lstinline!x!} label accordingly).\n\n\\textbf{Exercise:} Let's compare incomes for different levels of\neducation in the GSS dataset\n\nTo do that we'll create Boolean Series to identify respondents with\ndifferent levels of education.\n\n\\begin{itemize}\n\\item\n  In the U.S, 12 years of education usually means the respondent has\n  completed high school (secondary education).\n\\item\n  A respondent with 14 years of education has probably completed an\n  associate degree (two years of college)\n\\item\n  Someone with 16 years has probably completed a bachelor's degree (four\n  years of college or university).\n\\end{itemize}\n\nDefine Boolean \\passthrough{\\lstinline!Series!} named\n\\passthrough{\\lstinline!high!}, \\passthrough{\\lstinline!assc!}, and\n\\passthrough{\\lstinline!bach!} that are true for respondents with\n\n\\begin{itemize}\n\\item\n  12 or fewer years of education,\n\\item\n  13, 14, or 15 years, and\n\\item\n  16 or more.\n\\end{itemize}\n\nCompute and plot the distribution of income for each group. Remember to\nlabel the CDFs, display a legend, and label the axes. Write a few\nsentences that describe and interpret the results.\n\n\\hypertarget{modeling-distributions}{%\n\\section{Modeling distributions}\\label{modeling-distributions}}\n\nSome distributions have names. For example, you might be familiar with\nthe normal distribution, also called the Gaussian distribution or the\nbell curve. And you might have heard of others like the exponential\ndistribution, binomial distribution, or maybe Poisson distribution.\n\nThese ``distributions with names'' are called \\textbf{analytic} because\nthey are described by analytic mathematical functions, as contrasted\nwith empirical distributions, which are based on data.\n\nIt turns out that many things we measure in the world have distributions\nthat are well approximated by analytic distributions, so these\ndistributions are sometimes good models for the real world.\\\\\nIn this context, what I mean by a ``model'' is a simplified description\nof the world that is accurate enough for its intended purpose.\n\nIn this section, we'll compute the CDF of a normal distribution and\ncompare it to an empirical distribution of data. But before we get to\nreal data, we'll start with fake data.\n\nThe following statement uses NumPy's \\passthrough{\\lstinline!random!}\nlibrary to generate 1000 values from a normal distribution with mean\n\\passthrough{\\lstinline!0!} and standard deviation\n\\passthrough{\\lstinline!1!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nnp.random.seed(17)\n\\end{lstlisting}\n\n\\begin{lstlisting}[language=Python,style=source]\nsample = np.random.normal(size=1000)\n\\end{lstlisting}\n\nHere's what the empirical distribution of the sample looks like.\n\n\\begin{lstlisting}[language=Python,style=source]\ncdf_sample = Cdf.from_seq(sample)\ncdf_sample.plot(label='Random sample')\n\nplt.xlabel('x')\nplt.ylabel('CDF')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_112_0.pdf}\n\\end{center}\n\nIf we did not know that this sample was drawn from a normal\ndistribution, and we wanted to check, we could compare the CDF of the\ndata to the CDF of an ideal normal distribution, which we can use the\nSciPy library to compute.\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom scipy.stats import norm\n\nxs = np.linspace(-3, 3)\nys = norm(0, 1).cdf(xs)\n\\end{lstlisting}\n\nFirst we import \\passthrough{\\lstinline!norm!} from\n\\passthrough{\\lstinline!scipy.stats!}, which is a collection of\nfunctions related to statistics.\n\nThen we use \\passthrough{\\lstinline!linspace()!} to create an array of\nequally-spaced points from -3 to 3; those are the\n\\passthrough{\\lstinline!x!} values where we will evaluate the normal\nCDF.\n\nNext, \\passthrough{\\lstinline!norm(0, 1)!} creates an object that\nrepresents a normal distribution with mean \\passthrough{\\lstinline!0!}\nand standard deviation \\passthrough{\\lstinline!1!}.\n\nFinally, \\passthrough{\\lstinline!cdf!} computes the CDF of the normal\ndistribution, evaluated at each of the \\passthrough{\\lstinline!xs!}.\n\nI'll plot the normal CDF with a gray line and then plot the CDF of the\ndata again.\n\n\\begin{lstlisting}[language=Python,style=source]\nplt.plot(xs, ys, color='gray', label='Normal CDF')\ncdf_sample.plot(label='Random sample')\n\nplt.xlabel('x')\nplt.ylabel('CDF')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_116_0.pdf}\n\\end{center}\n\nThe CDF of the random sample agrees with the normal model. And that's\nnot surprising because the data were actually sampled from a normal\ndistribution. When we collect data in the real world, we do not expect\nit to fit a normal distribution as well as this. In the next exercise,\nwe'll try it and see.\n\n\\textbf{Exercise:} Is the normal distribution a good model for the\ndistribution of ages in the U.S. population?\n\nTo answer this question:\n\n\\begin{itemize}\n\\item\n  Compute the mean and standard deviation of ages in the GSS dataset.\n\\item\n  Use \\passthrough{\\lstinline!linspace!} to create an array of equally\n  spaced values between 18 and 89.\n\\item\n  Use \\passthrough{\\lstinline!norm!} to create a normal distribution\n  with the same mean and standard deviation as the data, then use it to\n  compute the normal CDF for each value in the array.\n\\item\n  Plot the normal CDF with a gray line.\n\\item\n  Plot the CDF of the ages in the GSS.\n\\end{itemize}\n\nHow well do the plotted CDFs agree?\n\n\\textbf{Exercise:} In many datasets, the distribution of income is\napproximately \\textbf{lognormal}, which means that the logarithms of the\nincomes fit a normal distribution. We'll see whether that's true for the\nGSS data.\n\n\\begin{itemize}\n\\item\n  Extract \\passthrough{\\lstinline!REALINC!} from\n  \\passthrough{\\lstinline!gss!} and compute its logarithm using\n  \\passthrough{\\lstinline!np.log10()!}. Hint: Replace the value\n  \\passthrough{\\lstinline!0!} with \\passthrough{\\lstinline!NaN!} before\n  computing logarithms.\n\\item\n  Compute the mean and standard deviation of the log-transformed\n  incomes.\n\\item\n  Use \\passthrough{\\lstinline!norm!} to make a normal distribution with\n  the same mean and standard deviation as the log-transformed incomes.\n\\item\n  Plot the CDF of the normal distribution.\n\\item\n  Compute and plot the CDF of the log-transformed incomes.\n\\end{itemize}\n\nHow similar are the CDFs of the log-transformed incomes and the normal\ndistribution?\n\n\\hypertarget{probability-density-functions}{%\n\\section{Probability Density\nFunctions}\\label{probability-density-functions}}\n\nWe have seen two ways to represent distributions, PMFs and CDFs. Now\nwe'll learn another way: a probability density function, or PDF. The\n\\passthrough{\\lstinline!norm!} function, which we used to compute the\nnormal CDF, can also compute the normal PDF:\n\n\\begin{lstlisting}[language=Python,style=source]\nxs = np.linspace(-3, 3)\nys = norm(0,1).pdf(xs)\nplt.plot(xs, ys, color='gray', label='Normal PDF')\n\nplt.xlabel('x')\nplt.ylabel('PDF')\nplt.title('Normal density function')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_121_0.pdf}\n\\end{center}\n\nThe normal PDF is the classic ``bell curve''.\n\nIt is tempting to compare the PMF of the data to the PDF of the normal\ndistribution, but that doesn't work. Let's see what happens if we try:\n\n\\begin{lstlisting}[language=Python,style=source]\nplt.plot(xs, ys, color='gray', label='Normal PDF')\n\npmf_sample = Pmf.from_seq(sample)\npmf_sample.plot(label='Random sample')\n\nplt.xlabel('x')\nplt.ylabel('PDF')\nplt.title('Normal density function')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_123_0.pdf}\n\\end{center}\n\nThe PMF of the sample is a flat line across the bottom. In the random\nsample, every value is unique, so they all have the same probability,\none in 1000.\n\nHowever, we can use the points in the sample to estimate the PDF of the\ndistribution they came from. This process is called \\textbf{kernel\ndensity estimation}, or KDE. It's a way of getting from a PMF, a\nprobability mass function, to a PDF, a probability density function.\n\nTo generate a KDE plot, we'll use the Seaborn library, which I'll import\nas \\passthrough{\\lstinline!sns!}. Seaborn provides\n\\passthrough{\\lstinline!kdeplot!}, which takes the sample, estimates the\nPDF, and plots it.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport seaborn as sns\n\nsns.kdeplot(sample, label='Estimated sample PDF')\n\nplt.xlabel('x')\nplt.ylabel('PDF')\nplt.title('Normal density function')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_125_0.pdf}\n\\end{center}\n\nNow we can compare the KDE plot and the normal PDF.\n\n\\begin{lstlisting}[language=Python,style=source]\nplt.plot(xs, ys, color='gray', label='Normal PDF')\nsns.kdeplot(sample, label='Estimated sample PDF')\n\nplt.xlabel('x')\nplt.ylabel('PDF')\nplt.title('Normal density function')\nplt.legend();\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{08_distributions_files/08_distributions_127_0.pdf}\n\\end{center}\n\nThe KDE plot matches the normal PDF pretty well, although the\ndifferences look bigger when we compare PDFs than they did with the\nCDFs. That means that the PDF is a more sensitive way to look for\ndifferences, but often it is too sensitive.\\\\\nIt's hard to tell whether apparent differences mean anything, or if they\nare just random, as in this case.\n\n\\textbf{Exercise:} In a previous exercise, we asked ``Is the normal\ndistribution a good model for the distribution of ages in the U.S.\npopulation?'' To answer this question, we plotted the CDF of the data\nand compared it to the CDF of a normal distribution with the same mean\nand standard deviation.\n\nNow we'll compare the estimated density of the data with the normal PDF.\n\n\\begin{itemize}\n\\item\n  Again, compute the mean and standard deviation of ages in the GSS\n  dataset.\n\\item\n  Use \\passthrough{\\lstinline!linspace!} to create an array of values\n  between 18 and 89.\n\\item\n  Use \\passthrough{\\lstinline!norm!} to create a normal distribution\n  with the same mean and standard deviation as the data, then use it to\n  compute the normal PDF for each value in the array.\n\\item\n  Plot the normal PDF with a gray line.\n\\item\n  Use \\passthrough{\\lstinline!sns.kdeplot!} to estimate and plot the\n  density of the ages in the GSS.\n\\end{itemize}\n\nNote: Seaborn can't handle NaNs, so use \\passthrough{\\lstinline!dropna!}\nto drop them before calling \\passthrough{\\lstinline!kdeplot!}.\n\nHow well do the PDF and KDE plots agree?\n\n\\textbf{Exercise:} In a previous exercise, we used CDFs to see if the\ndistribution of income fits a lognormal distribution. We can make the\nsame comparison using a PDF and KDE.\n\n\\begin{itemize}\n\\item\n  Again, extract \\passthrough{\\lstinline!REALINC!} from\n  \\passthrough{\\lstinline!gss!} and compute its logarithm using\n  \\passthrough{\\lstinline!np.log10()!}.\n\\item\n  Compute the mean and standard deviation of the log-transformed\n  incomes.\n\\item\n  Use \\passthrough{\\lstinline!norm!} to make a normal distribution with\n  the same mean and standard deviation as the log-transformed incomes.\n\\item\n  Plot the PDF of the normal distribution.\n\\item\n  Use \\passthrough{\\lstinline!sns.kdeplot()!} to estimate and plot the\n  density of the log-transformed incomes.\n\\end{itemize}\n\n\\hypertarget{summary}{%\n\\section{Summary}\\label{summary}}\n\nIn this chapter, we've seen three ways to visualize distributions, PMFs,\nCDFs, and KDE.\n\nIn general, I use CDFs when I am exploring data. That way, I get the\nbest view of what's going on without getting distracted by noise.\n\nThen, if I am presenting results to an audience unfamiliar with CDFs, I\nmight use a PMF if the dataset contains a small number of unique values,\nor KDE if there are many unique values.\n\nAs an example, see my article about the Inspection Paradox at\n\\url{https://towardsdatascience.com/the-inspection-paradox-is-everywhere-2ef1c2e9d709}.\nI wrote it for a general audience, so I use KDE to present and compare\ndistributions.\n\n", "meta": {"hexsha": "c3b5e1d77998ed84dde8b4b8c38d1bbf552344ce", "size": 37874, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "book/08_distributions.tex", "max_stars_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_stars_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2021-05-06T13:57:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T18:21:30.000Z", "max_issues_repo_path": "book/08_distributions.tex", "max_issues_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_issues_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "book/08_distributions.tex", "max_forks_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_forks_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-27T10:41:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T10:41:22.000Z", "avg_line_length": 31.7734899329, "max_line_length": 87, "alphanum_fraction": 0.7577493795, "num_tokens": 10611, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4488274381500589}}
{"text": "%-----------------------------------------------------------------------------\n\\section{Evolution Equations}\n\nThe compressible and low Mach number formulations of the governing\nequations both share the unapproximated continuity and momentum equations\nshown here (where $p = p_0 + \\pi$).\n\\begin{eqnarray}\n\\frac{\\partial(\\rho X_k)}{\\partial t} &=& -\\nabla\\cdot(\\rho X_k\\Ub) + \n\\rho\\omegadot_k,\\label{enth:eq:species}\\\\\n\\frac{\\partial\\Ub}{\\partial t} &=& -\\Ub\\cdot\\nabla\\Ub  - \n  \\frac{1}{\\rho}\\nabla\\pi - \n  \\frac{\\rho-\\rho_0}{\\rho} g\\eb_r,\\label{eq:momentum}\n\\end{eqnarray}\n\nIn the compressible formulation we complete the system with an energy\nequation as well as an equation of state; in the low Mach number\nformulation we can derive a constraint on the velocity by setting\n$p_{EOS} = p(\\rho,h,X_k) = p_0$ and differentiating the equation of\nstate along particle paths.  In this case adding the energy equation\nwould over-constrain the system, but its solution can help us in\nproviding a diagnostic capability for the solution.  We can write the\nenergy equation in terms of internal energy, $e$, or enthalpy, $h$;\nthese two equations are analytically equivalent.\n\\begin{eqnarray}\n\\frac{\\partial(\\rho h)}{\\partial t} + \\nabla\\cdot(\\rho h\\Ub) \n &=& \\frac{Dp}{Dt} + \\rho\\Hnuc \\nonumber \\\\\n%\n\\frac{\\partial(\\rho e)}{\\partial t} + \\nabla\\cdot(\\rho e \\Ub)\n &=& - p\\nabla\\cdot \\Ub + \\rho\\Hnuc \\nonumber \n\\end{eqnarray}\nIn low Mach number combustion, $Dp/Dt = 0,$ which makes the enthalpy\nequation preferable to the internal energy equation because we don't\nneed to evaluate $p \\nabla \\cdot \\Ub.$\n\n\n%-----------------------------------------------------------------------------\n\\section{Derivation of Velocity Constraint}\n\nDifferentiating the equation of state, written in the form, $p =\np(\\rho,T,X_k),$ along particle paths, we can write\n\\begin{equation}\n\\frac{D p}{Dt}  = p_\\rho \\frac{D \\rho}{Dt} + p_T \\frac{D T}{Dt} + \\sum_k p_{X_k} \\frac{D X_k}{Dt}\n\\end{equation}\nThen, by rearranging the terms, we get\n\\begin{equation}\n\\frac{D \\rho}{Dt}  = -\\rho \\nabla \\cdot \\Ub = \n    \\frac{1}{p_\\rho}\n    \\left( \\frac{D p}{Dt} - p_T \\frac{D T}{Dt}\n                          - \\sum_k p_{X_k} {\\omegadot}_k \\right) \\enskip ,\n\\end{equation}\nwith $p_\\rho = \\left.\\partial p/\\partial \\rho\\right|_{X_k,T}$,\n$p_{X_k} = \\left.\\partial p/\\partial X_k \\right|_{T,\\rho,(X_j,j\\ne k)}$,\nand $p_T = \\left.\\partial p/\\partial T\\right|_{\\rho,X_k}$.\n\n\\subsection{Using the Enthalpy Equation}\n\nNow writing $h = h(p,T,X_k)$ and expanding $Dh/Dt$ and using the\nenthalpy evolution equation:\n\\begin{equation}\n\\rho \\frac{D h}{Dt}  = \\rho \\left( h_p \\frac{D p}{Dt} + c_p \\frac{D T}{Dt} + \\sum_k h_{X_k} \\frac{D X_k}{Dt} \\right)\n                     = \\frac{D p}{D t} + \\rho \\Hnuc\n\\end{equation}\nwe can express $DT/Dt$ in terms of \n\\begin{equation}\n\\frac{DT}{Dt} = \\frac{1}{\\rho c_p} \\left( (1 - \\rho h_p) \\frac{D p}{D t}\n- \\sum_k \\rho \\xi_k \\omegadot_k + \\rho \\Hnuc \\right) \\enskip , \\label{eq:dTdt}\n\\end{equation}\nwhere $c_p = \\left.\\partial h/\\partial T\\right|_{p,X_k}$ is the\nspecific heat at constant pressure,\n$\\xi_k = \\left.\\partial h/\\partial X_k \\right|_{p,T}$,\nand $h_p = \\left.\\partial h/\\partial p\\right|_{T,X_k}.$\n\nWe could then write,\n\\begin{eqnarray*}\n\\nabla \\cdot \\Ub &=& \\frac{1}{\\rho p_\\rho} \\left(\n- \\frac{D p}{D t} + \\frac{p_T}{\\rho c_p}\n  \\left( (1 - \\rho h_p) \\frac{D p}{D t} - \\rho \\sum_k \\xi_k \\omegadot_k + \\rho \\Hnuc \\right)\n+ \\sum_k p_{X_k} \\omegadot_k \\right)  \\\\\n                 &=& \\frac{1}{\\rho p_\\rho}\n  \\left( \\frac{p_T}{\\rho c_p}(1  - \\rho h_p) - 1 \\right) \\frac{D p}{D t}\n + \\frac{1}{\\rho p_\\rho} \\left(\n  \\frac{p_T}{\\rho c_p} (\\rho \\Hnuc - \\rho \\sum_k \\xi_k   \\omegadot_k)\n                               + \\sum_k p_{X_k} \\omegadot_k \\right) \\enskip .\n\\end{eqnarray*}\nWhen we derived this expression we explicitly retained the dependence\nof $h$ on $p$, as shown by the presence of the $h_p$ term.\n\nThen, replacing $p$ by $p_0(r)$, $Dp/Dt$ becomes $\\Ub \\cdot\n\\nabla p_0$, and the divergence constraint can be written\n\\begin{equation}\n\\nabla \\cdot \\Ub + \\alpha \\Ub \\cdot \\nabla p_0 =\n\\frac{1}{\\rho p_\\rho} \\left(\n   \\frac{p_T}{\\rho c_p} \\left(\n  - \\sum_k\\rho  \\xi_k \\omegadot_k + \\rho \\Hnuc \\right)\n + \\sum_k p_{X_k} \\omegadot_k \\right)  \\equiv \\tilde{S} \\enskip \\label{eq:full_divu_constraint} ,\n\\end{equation}\nwhere we define\n\\begin{equation}\n\\alpha(\\rho,T) \\equiv - \\left( \\frac{(1 - \\rho h_p )p_T - \\rho c_p}{\\rho^2\n  c_p p_\\rho} \\right) \\enskip . \\label{eq:alphadef}\n\\end{equation}\n\n\\subsection{Using the Energy Equation}\n\nNow writing $e = e(p,T,X_k)$ and expanding $De/Dt$ and using the\nenergy evolution equation:\n\\begin{equation}\n\\rho \\frac{D e}{Dt}  = \\rho \\left( e_p \\frac{D p}{Dt} + e_T \\frac{D T}{Dt} + \\sum_k e_{X_k} \\frac{D X_k}{Dt} \\right)\n                     = -p \\nabla \\cdot \\Ub + \\rho \\Hnuc\n\\end{equation}\nwe can express $DT/Dt$ in terms of \n\\begin{eqnarray*}\n\\frac{DT}{Dt} &=& \\frac{1}{\\rho e_T} \\left(\n                  -p \\nabla \\cdot \\Ub + \\rho \\Hnuc\n                 - \\rho e_p \\frac{D p}{Dt}\n                 - \\rho \\sum_k e_{X_k} \\omegadot_k   \\right)\n\\end{eqnarray*}\nwhere $e_T = \\left.\\partial e/\\partial T\\right|_{p,X_k}$ \nand $e_p = \\left.\\partial e/\\partial p\\right|_{T,X_k}.$\nThen\n\\begin{equation}\n-\\rho \\nabla \\cdot \\Ub = \n    \\frac{1}{p_\\rho} \\left( \\frac{D p}{Dt} \n    - \\frac{p_T}{\\rho e_T} \\left(\n                 -p \\nabla \\cdot \\Ub + \\rho \\Hnuc\n                 - \\rho e_p \\frac{D p}{Dt}\n                 - \\rho \\sum_k e_{X_k} \\omegadot_k   \\right)\n    - \\sum_k p_{X_k} {\\omegadot}_k \\right) \\enskip ,\n\\end{equation}\nwhich leads to \n\\begin{equation}\n\\left(-\\rho -  \\frac{p p_T}{\\rho e_T p_\\rho} \\right) \\nabla \\cdot \\Ub = \n    \\frac{1}{p_\\rho} \\left( (1 + \\frac{e_p p_T}{e_T}) \\frac{D p}{Dt} \n                           - \\frac{p_T}{\\rho e_T} \\left(\n                                        \\rho \\Hnuc\n                                        - \\rho \\sum_k e_{X_k} \\omegadot_k   \\right)\n    - \\sum_k p_{X_k} {\\omegadot}_k \\right) \\enskip ,\n\\end{equation}\nNote that we can replace $p$ by $p_0$ in the coefficient on the\nl.h.s. as well as on the r.h.s.\n\n\n%-----------------------------------------------------------------------------\n\\section{Comparison of Constraints}\n\nIf we set $\\omegadot_k = \\Hnuc = 0$ for simplicity, then the\nconstraint as derived using $h$ can be written\n\\begin{equation}\n\\nabla \\cdot \\Ub\n+ \\left( \\frac{(1 - \\rho h_p )p_T - \\rho c_p}{\\rho^2\n  c_p p_\\rho} \\right) \\frac{D p_0}{D t} = 0\n\\end{equation}\nand the constraint derived using $e$ can be written\n\\begin{equation}\n\\nabla \\cdot \\Ub \n+ \\left( \\frac{\\rho e_T + \\rho e_p p_T}{\\rho^2 e_T p_\\rho + p p_T} \\right) \\frac{D p_0}{D t} = 0\n\\end{equation}\n\nWe note that if we evaluate both constraints for $p = \\rho R T,$ with\n$h = c_p T,$ $e = c_v T,$ $c_p = c_v + R$ and $\\gamma = c_p / c_v,$\nthen both constraints reduce to\n\\begin{equation}\n\\nabla \\cdot \\Ub + \\frac{1}{\\gamma p} \\frac{D p_0}{D t} = 0\n\\end{equation}\n\n\n%-----------------------------------------------------------------------------\n\\section{Enthalpy vs Energy Equation}\n\nThe full enthalpy equation, with no approximations, appears as:\n\\begin{equation}\n\\frac{\\partial(\\rho h)}{\\partial t} = -\\nabla\\cdot(\\rho h\\Ub) + \n  \\frac{Dp}{Dt} + \\rho\\Hnuc \\label{eq:enthalpy}\n\\end{equation}\nHere, $h = e + p/\\rho$ is the specific enthalpy, with $e$ the specific\ninternal energy.  In the low Mach number formulation, we replace $p$\nwith $p_0$ in the $Dp/Dt$ term, however, the definition of enthalpy\nimplicitly contains a pressure.  When calling the equation of state,\nwe take $h$ and $\\rho$ as inputs.  The equation of state is expressed\nin terms of $T$ and $\\rho$, so it iterates until it finds the $h$ that\nwe desire.  This $h$ will be of the form $h = e + p_\\mathrm{EOS}/\\rho$,\nwhere $p_\\mathrm{EOS}$ is the pressure returned from the EOS.  Note that\n$p_\\mathrm{EOS}$ may not be equal to $p_0$---this may be what\ncauses us to drive off of the constraint. \n\nThe mismatch between the pressure implicit in the definition of $h$\nand $p_0$ can be seen by substituting $h = e + p/\\rho$ into the\nenthalpy equation, where we replace $p$ with $p_0$ in the $Dp/Dt$ term:\n\\begin{eqnarray}\n\\frac{\\partial(\\rho h)}{\\partial t} &=& -\\nabla\\cdot(\\rho h\\Ub) + \n  \\frac{Dp_0}{Dt} + \\rho\\Hnuc \\nonumber \\\\\n%\n\\frac{\\partial(\\rho e)}{\\partial t} + \\frac{\\partial p}{\\partial t} &=&\n -\\nabla\\cdot(\\rho e\\Ub) -\\nabla\\cdot(p\\Ub) + \\frac{Dp_0}{Dt} + \\rho\\Hnuc \\nonumber \\\\\n%\n\\frac{\\partial(\\rho e)}{\\partial t} &=&\n -\\nabla\\cdot(\\rho e\\Ub) - p\\nabla\\cdot\\Ub + \\rho\\Hnuc + \n  \\left \\{ \\frac{Dp_0}{Dt} - \\frac{Dp}{Dt} \\right \\} \\nonumber \n\\end{eqnarray}\nHowever, if we solve the evolution equation for $e$ we would\nsubstitute $p_0$ for $p$ in this equation as well.  Thus, we can pose\nthe situation as the following.  If we solve the evolution equation\nfor $h$ then we effectively are solving\n\\begin{equation}\n\\frac{\\partial(\\rho e)}{\\partial t} +\n  \\nabla\\cdot(\\rho e\\Ub) = -p \\; \\nabla\\cdot\\Ub + \\rho\\Hnuc + \n  \\left \\{ \\frac{Dp_0}{Dt} - \\frac{Dp}{Dt} \\right \\} \\nonumber \n\\end{equation}\nbut if we solve the evolution equation for $e$ we are effectively solving\n\\begin{equation}\n\\frac{\\partial(\\rho e)}{\\partial t} +\n  \\nabla\\cdot(\\rho e\\Ub) = p_0 \\nabla\\cdot\\Ub + \\rho\\Hnuc \\nonumber \n\\end{equation}\n\nThe second equation subtracted from the first gives:\n\\begin{equation} \\label{eq:difference between h and e equations}\n  \\frac{D (p_0 - p)}{Dt} - (p_0 - p)  \\nabla \\cdot \\Ub = 0,\n\\end{equation}\nbut this equation is only true, in general, if $p=p_0$.\n\nSuppose we solve the current enthalpy equation, but when we call the\nEOS, we subtract $p_0$ from $\\rho h$ and then call the EOS with $e$\ninstead of $h$.  This is equivalent to:\n\\begin{eqnarray}\n\\frac{\\partial(\\rho h)}{\\partial t} &=& -\\nabla\\cdot(\\rho h\\Ub) +\n  \\frac{Dp_0}{Dt} + \\rho\\Hnuc \\nonumber \\\\\n%\n\\frac{\\partial(\\rho e)}{\\partial t} + \\frac{\\partial p_0}{\\partial t} &=&\n -\\nabla\\cdot(\\rho e\\Ub) -\\nabla\\cdot(p_0 \\Ub) + \\frac{Dp_0}{Dt} + \\rho\\Hnuc \\nonumber \\\\\n%\n\\frac{\\partial(\\rho e)}{\\partial t} &=&\n -\\nabla\\cdot(\\rho e\\Ub) - p_0 \\nabla\\cdot\\Ub + \\rho\\Hnuc  \\nonumber\n\\end{eqnarray}\nwhich is identical to solving the energy equation with $p\\to p_0$.\nThis option is enabled in \\maestro\\ via {\\tt\n  use\\_eos\\_e\\_instead\\_of\\_h = T}.\n\n\n\n\\subsection{Constant $\\gamma$ Gas}\nGoing back to the constant $\\gamma$, ideal gas EOS, we can rewrite the\nenthalpy equation as a pressure evolution equation\n\\begin{eqnarray}\n  \\frac{\\partial\\rho h}{\\partial t} + \\nabla\\cdot\\left(\\rho h\\Ub\\right) &=& \\frac{Dp_0}{Dt} + \\rho H {} \\nonumber\\\\\n  \\frac{\\gamma}{\\gamma-1}\\frac{\\partial p}{\\partial t} + \\frac{\\gamma}{\\gamma-1}\\nabla\\cdot\\left(p\\Ub\\right) &=& \\frac{Dp_0}{Dt} + \\rho H {} \\nonumber\\\\\n  \\frac{Dp}{Dt} &=& -p\\nabla\\cdot\\Ub + \\frac{\\gamma}{\\gamma-1}\\left(\\frac{Dp_0}{Dt}+\\rho H\\right) \\label{eq:H:pressure evolution}.\n\\end{eqnarray}\nSimilarly, we can derive a pressure evolution equation from the energy equation\n\\begin{equation}\n  \\frac{Dp}{Dt} = -p\\nabla\\cdot\\Ub - \\left(\\gamma-1\\right)p_0\\nabla\\cdot\\Ub + \\rho H \\label{eq:e:pressure evolution}\n\\end{equation}\nNow, if we further make the assumption that $p_0$ is constant,\n$Dp_0/Dt = 0$, then the divergence constraint for such a gas reduces\nto\n\\begin{equation}\n\\nabla\\cdot\\Ub = \\frac{\\gamma-1}{\\gamma p_0}\\rho H \\label{eq:div constraint for constant gamma}.\n\\end{equation}\nPlugging this back into either of \\eqref{eq:H:pressure evolution} or\n\\eqref{eq:e:pressure evolution} gives\n\\begin{equation}\n  \\frac{Dp}{Dt} = \\frac{\\gamma-1}{\\gamma}\\left(1-\\frac{p}{p_0}\\right)\\rho H. \\label{eq:pressure evolution constant gamma}\n\\end{equation}\nIf $p_0$ is assumed constant and using \\eqref{eq:div constraint for\n  constant gamma}, the difference between the enthalpy equation and\nthe energy equation, \\eqref{eq:difference between h and e equations},\ncan be rewritten as\n\\[\n-\\frac{Dp}{Dt} - \\frac{\\gamma}{\\gamma-1}\\left(1-\\frac{p}{p_0}\\right)\\rho H = 0,\n\\]\nwhere the equality holds from \\eqref{eq:pressure evolution constant\n  gamma}. In other words, for the constant $\\gamma$ gas we have\n$p=p_0$ as expected.\n\n\n%-----------------------------------------------------------------------------\n\\section{Outstanding Questions}\n\n\\begin{enumerate}\n\\item Why do we want to start with enthalpy instead of internal energy?\n\n   We believe that the original desire stems from our experience with\n   smallscale combustion.  There, stratification is not important and\n   $Dp_0/Dt = 0$, so the enthalpy equation becomes a conservation\n   equation for $(\\rho h)$.\n\n\\item Should we call the EOS with $h$ as is, or call the EOS with $e =\n  h - p_0 / \\rho$?\n\n\\item When we stay on the constraint, i.e. $p_{EOS} = p_0$, then the\n  equations for $e$ and for $h$ are identical.  However, once we are\n  off the constraint, do the terms in the current evolution equation\n  for $h$ serve to drive us back to the constraint?  Recall our\n  current \"volume discrepancy factor\" acts as a source term which\n  modifies the divergence constraint, which effectively modifies both\n  $\\rho$ and $T$ (or $e$ or $h$).  The term in the enthalpy equation\n  only modifies $\\rho.$ Is this relevant and/or useful??  Recall that\n  the current \"volume discrepancy factor\" takes the form of adding to\n  the r.h.s. of the constraint:\n\\begin{equation}\n\\nabla \\cdot(\\beta_0\\Ub) = \\beta_0\\left(S-\\frac{1}{\\overline{\\Gamma_1} p_0}\n       \\frac{\\partial p_0}{\\partial t} - \\frac{f}{\\overline{\\Gamma_1} p_0}\n       \\frac{p_0-p_\\text{EOS}}{\\dt}\\right) \n\\end{equation}\n\n%\\item We substitute $p$ for $p_0$ in two places: 1) in the derivation of the\n%constraint, 2) in the enthalpy evolution equation.   Are these substitutions\n%consistent with each other?  If they are not consistent, which of these \n%substitutions is responsible for filtering the acoustics from the system?\n\n\\item Suppose we corrected the $h$ (or $e$ equation) by using the full\n  $p$ instead of $p_0$?  Would this be more or less consistent (one\n  could imagine doing this as a correction after solving for $\\pi$\n  earlier in the timestep).\n\n%\\item In the EOS, we take $h$ and construct $e$ by subtracting off\n%  $p$---depending on the inputs to the EOS, we treat the `$p$' part of $h$\n%  differently.\n%\n%   if we come into the EOS with $\\rho$, $T$, then we get $p$ and $e$ from\n%   the EOS and compute $h$.\n%\n%   if we come into the EOS with $\\rho$, $h$, then we find a $T$ such that\n%   $e + p(\\rho,T)/\\rho = h$, where $p(\\rho,T)$ is the pressure from the EOS.\n%   It is not necessarily equal to $p_0$.\n%\n%   if we come into the EOS with $\\rho$, $p_0$, then find a $T$ that matches\n%   $p_0$, and then $h = e + p_0/\\rho$.  In this case, there is no mismatch\n%   in the enthalpy equation.\n\n\\item In computing the thermodynamic coefficients in $S$ for the\n  projection, don't we need these to be in terms of $p_0$ instead of\n  $p(h,\\rho)$?\n\n\\end{enumerate}\n\n", "meta": {"hexsha": "6b0cb56d1a75a5c78d262324b55101c768945ed4", "size": 14803, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/enthalpy/enthalpy.tex", "max_stars_repo_name": "sailoridy/MAESTRO", "max_stars_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2017-05-15T15:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-09T08:13:32.000Z", "max_issues_repo_path": "Docs/enthalpy/enthalpy.tex", "max_issues_repo_name": "sailoridy/MAESTRO", "max_issues_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2017-06-14T23:05:00.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-28T16:40:42.000Z", "max_forks_repo_path": "Docs/enthalpy/enthalpy.tex", "max_forks_repo_name": "sailoridy/MAESTRO", "max_forks_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2017-06-14T14:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T07:16:09.000Z", "avg_line_length": 44.056547619, "max_line_length": 152, "alphanum_fraction": 0.6440586368, "num_tokens": 5122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.44882743787711477}}
{"text": "\\documentclass[]{article}\n\n%opening\n\\title{Mobile Weka}\n\\author{Matthew Swartwout \\and James Zhang}\n\\begin{document}\n\\maketitle\n\n\\section{Introduction of Algorithms}\n\\subsection{J48}\nJ48 is an implementation of the C4.5 algorithm. This algorithm builds decision trees to classify inputs. These decision trees check each attribute and calculate how well the data set can be split using that attribute. Once the best attribute for splitting has been decided, this is added as a decision node to the tree. This then moves onto the next feature and adds that node as a child of the tree based on the best split. Once all the splits have been determined, the final decision tree can be used to classify the data.\n \n\\subsection{SVM}\nSVM stands for Support Vector Machine. The basis of this is that there should be a linear function that can separate the data set the best. There are an infinite number of possible functions that can separate the functions. Thus we look for the function that has the largest margin. This can be done by transposing the data into a higher dimensional space, which is often done by using the dot product. Once you've found the function with the highest margin, this can be used to classify the input data.\n\n\\subsection{Naive Bayes}\nNaive Bayes is an classification algorithm based off applying Bayes' theorem and assuming independence between all of the labels. Bayes' theorem says that P(A|B) = P(A)P(B|A)/P(B). The input to Naive Bayes' is our data, which is represented as a vector of n features (x), and we are trying to calculate the probability that these features will result in a given class (C), e.g. P(C|x). This can be rewritten with Bayes' Theorem as P(C)P(x|C)/p(x). Each of these three probabilities can be easily calculated with the provided data set. Doing this over each of the n features included in x and we can obtain the probability that a certain set of features. \n\n\\subsection{RBF Network}\nRBF Network stands for Radial Basis Function Network. This is a type of neural network that can be used for classification tasks. The network is made of three layers: an input layer, a hidden layer with a non-linear activation function, and a linear output layer. The input vector is our vector with n features. This is given to every neuron in the input layer. Each neuron contains one of the vectors from the training set. It then outputs a value between 0 and 1 depending on how similar the two vectors are. Each node in the output layer represents one of the possible classification categories. Each output node compares the outputs from the activation functions and creates a score for that class. Looking at the value of the output nodes, the network can classify the input.\n\n\\section{Data Preprocessing}\n\n\\section{Experimental Results}\n\\subsection{Experiment 1}\n\\begin{tabular}{c | c | c| c | c}\nAlgorithm & Recall & Precision & Correctly Classified & Incorrectly Classified \\\\ \\hline\nJ48 & 1.0 & 0.9375 & 428 & 10 \\\\ \nSVM & 0.0133 & 1.0 & 290 & 148 \\\\\nNaive Bayes & 1.0 & 0.9375 &  428 & 10 \\\\\nRBF Network & 1.0 & 0.9554 & 431 & 7 \\\\\n\\end{tabular}\n\\subsection{Experiment 2}\n\\begin{tabular}{c | c | c| c | c}\nAlgorithm & Recall & Precision & Correctly Classified & Incorrectly Classified \\\\ \\hline\nJ48 & 1.0 & 1.0 & 1355 & 0 \\\\ \nSVM & 0.0 & 0.0 & 456 & 899 \\\\\nNaive Bayes & 0.9652 & 0.7296 & 1234 & 121 \\\\\nRBF Network & 0.9340 & 0.8432 & 1239 & 116 \\\\\n\\end{tabular}\n\\subsection{Experiment 3}\n\\subsubsection{Experiment 1}\n\\begin{tabular}{c | c | c| c | c}\n\tAlgorithm & Recall & Precision & Correctly Classified & Incorrectly Classified \\\\ \\hline\n\tJ48 & 1.0 & 1.0 & 70 & 0 \\\\ \n\tSVM & 1.0 & 1.0 & 70 & 0 \\\\\n\tNaive Bayes & 1.0 & 1.0 & 70 & 0 \\\\\n\tRBF Network & 1.0 & 1.0 & 70 & 0 \\\\\n\\end{tabular}\n\\subsubsection{Experiment 2}\n\\begin{tabular}{c | c | c| c | c}\n\tName & Algorithm & Recall & Precision & Correctly Classified & Incorrectly Classified \\\\ \\hline\n\tMatt & J48 & 1.0 & 1.0 & 101 & 0 \\\\ \n\tMatt & SVM & 0.08 & 1.0 & 29 & 72 \\\\\n\tMatt & Naive Bayes & 1.0 & 1.0 & 101 & 0 \\\\\n\tMatt & RBF Network & 1.0 & 1.0 & 101 & 0 \\\\\n\tJames & J48 & 1.0 & 1.0 & 101 & 0 \\\\ \n\tJames & SVM & 0.08 & 1.0 & 29 & 72 \\\\\n\tJames & Naive Bayes & 1.0 & 1.0 & 101 & 0 \\\\\n\tJames & RBF Network & 1.0 & 1.0 & 101 & 0 \\\\\n\\end{tabular}\n\\section{Simple Results Analysis}\n\n\\section{Project Contributions}\n\\end{document}\n", "meta": {"hexsha": "186b913276c62c359b870458ac47db427ee9ae32", "size": 4329, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projectReport.tex", "max_stars_repo_name": "mwswartwout/MobieWeka", "max_stars_repo_head_hexsha": "b9e90ad56eca8b10522cb1944be992cb9e1c0fd2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projectReport.tex", "max_issues_repo_name": "mwswartwout/MobieWeka", "max_issues_repo_head_hexsha": "b9e90ad56eca8b10522cb1944be992cb9e1c0fd2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projectReport.tex", "max_forks_repo_name": "mwswartwout/MobieWeka", "max_forks_repo_head_hexsha": "b9e90ad56eca8b10522cb1944be992cb9e1c0fd2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.5909090909, "max_line_length": 780, "alphanum_fraction": 0.7232617233, "num_tokens": 1262, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.4488228216431795}}
{"text": "\\subsection{Theoretical prediction of the channel capacity}\n\\label{sec_channcap}\n\nWe now turn our focus to the channel capacity, which is a metric by which we can\nquantify the degree to which cells can measure the environmental state (in this\ncontext, the inducer concentration). The channel capacity is defined as the\nmutual information $I$ between input and output (\\eref{eq_mutual_info}),\nmaximized over all possible input (IPTG) distributions $P(c)$. If used as a\nmetric of how reliably a signaling system can infer the state of the external\nsignal, the channel capacity, when measured in bits, is commonly interpreted as\nthe logarithm of the number of states that the signaling system can properly\nresolve. For example, a signaling system with a channel capacity of $C$ bits is\ninterpreted as being able to resolve $2^C$ states, though channel capacities\nwith fractional values are allowed. We therefore prefer the Bayesian\ninterpretation that the mutual information quantifies the improvement in the\ninference of the input when considering the output compared to just using the\nprior distribution of the input by itself for prediction \\cite{Voliotis2014a,\nBowsher2014}. Under this interpretation a channel capacity of a fractional bit\nstill quantifies an improvement in the ability of the signaling system to infer\nthe value of the extracellular signal compared to having no sensing system at\nall.\n\nComputing the channel capacity implies optimizing over an infinite space of\npossible distributions $P(c)$. For special cases in which the noise is small\ncompared to the dynamic range, approximate analytical equations have been\nderived \\cite{Tkacik2008a}. But given the high cell-to-cell variability that\nour model predicts, the conditions of the so-called small noise approximation\nare not satisfied. We therefore appeal to a numerical solution known as the\nBlahut-Arimoto algorithm \\cite{Blahut1972} (See \\siref{supp_channcap} for\nfurther details). \\fref{fig5_channcap}(A) shows zero-parameter fit predictions\nof the channel capacity as a function of the number of repressors for different\nrepressor-DNA affinities (solid lines). These predictions are contrasted with\nexperimental determinations of the channel capacity as inferred from\nsingle-cell fluorescence intensity distributions taken over 12 different\nconcentrations of inducer. Briefly, from single-cell fluorescence measurements\nwe can approximate the input-output distribution $P(p \\mid c)$. Once these\nconditional distributions are fixed, the task of finding the input distribution\nat channel capacity becomes a computational optimization routine that can be\nundertaken using conjugate gradient or similar algorithms. For the particular\ncase of the channel capacity on a system with a discrete number of inputs and\noutputs the Blahut-Arimoto algorithm is built in such a way that it guarantees\nthe convergence towards the optimal input distribution (See\n\\siref{supp_channcap} for further details). \\fref{fig5_channcap}(B) shows\nexample input-output functions for different values of the channel capacity.\nThis illustrates that having access to no information (zero channel capacity)\nis a consequence of having overlapping input-output functions (lower panel). On\nthe other hand, the more separated the input-output distributions are (upper\npanel) the higher the channel capacity can be.\n\nAll theoretical predictions in \\fref{fig5_channcap}(A) are systematically above\nthe experimental data. Although our theoretical predictions in\n\\fref{fig5_channcap}(A) do not numerically match the experimental inference of\nthe channel capacity, the model does capture interesting qualitative features of\nthe data that are worth highlighting. On one extreme, for cells with no\ntranscription factors, there is no information processing potential as this\nsimple genetic circuit would be constitutively expressed regardless of the\nenvironmental state. As cells increase the transcription factor copy number, the\nchannel capacity increases until it reaches a maximum before falling back down\nat high repressor copy number since the promoter would be permanently repressed.\nThe steepness of the increment in channel capacity as well as the height of the\nmaximum expression is highly dependent on the repressor-DNA affinity. For strong\nbinding sites (blue curve in \\fref{fig5_channcap}(A)) there is a rapid increment\nin the channel capacity, but the maximum value reached is smaller compared to a\nweaker binding site (orange curve in \\fref{fig5_channcap}(A)). In\n\\siref{supp_empirical} we show using the small noise approximation\n\\cite{Tkacik2008, Tkacik2008a} that if the systematic deviation of our\npredictions on the cell-to-cell variability was explained with a multiplicative\nconstant, i.e. all noise predictions can be corrected by multiplying them by a\nsingle constant, we would expect the channel capacity to be off by a constant\nadditive factor. This factor of $\\approx 0.43$ bits can recover the agreement\nbetween the model and the experimental data.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {./fig/main/fig5_channcap.pdf}\n\t\\caption{\\textbf{Comparison of theoretical and experimental channel\n\tcapacity.} (A) Channel capacity as inferred using the Blahut-Arimoto\n\talgorithm \\cite{Blahut1972} for varying number of repressors and\n\trepressor-DNA affinities. All inferences were performed using 12 IPTG\n\tconcentrations as detailed in the Methods. Curves represent zero-parameter\n\tfit predictions made with the maximum entropy distributions as shown in\n\t\\fref{fig4_maxent}. Points represent inferences made from single cell\n\tfluorescence distributions (See \\siref{supp_channcap} for further details).\n\tTheoretical curves were smoothed using a Gaussian kernel to remove\n\tnumerical precision errors. (B) Example input-output functions in opposite\n\tlimits of channel capacity. Lower panel illustrates that zero channel\n\tcapacity indicates that all distributions overlap. Upper panel illustrates\n\tthat as the channel capacity increases, the separation between\n\tdistributions increases as well. Arrows point to the corresponding channel\n\tcapacity computed from the predicted distributions.}\n  \\label{fig5_channcap}\n\\end{figure}\n", "meta": {"hexsha": "8114e3aeb49dea5922940555f48f55b8fdfbe7e2", "size": 6186, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/section_05_channel_capacity.tex", "max_stars_repo_name": "RPGroup-PBoC/chann_cap", "max_stars_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-21T04:06:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-09T07:36:58.000Z", "max_issues_repo_path": "doc/section_05_channel_capacity.tex", "max_issues_repo_name": "RPGroup-PBoC/chann_cap", "max_issues_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/section_05_channel_capacity.tex", "max_forks_repo_name": "RPGroup-PBoC/chann_cap", "max_forks_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-04-29T17:43:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-09T00:20:16.000Z", "avg_line_length": 66.5161290323, "max_line_length": 80, "alphanum_fraction": 0.8220174588, "num_tokens": 1350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.44882281820780456}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{hyperref}\n\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#1}\n\\newcommand{\\hmwkDueDate}{Due on 18th January, 2019}\n\\newcommand{\\hmwkClass}{Advanced Statistical Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n(\\textbf{Acknowledgements} - I would like to thank Aditya Sharma and Junaid Majeed for discussions.)\n\n\\begin{homeworkProblem}[1]\n\t\\textbf{Part (a)}\\\\\n\tGiven that \n\t\\begin{align*}\n\tX &= \\dfrac{\\sum_{i=1}^N X_i}{\\sigma \\sqrt{N}} \\\\\n\t\\ev{X} &= \\dfrac{\\sum_{i=1}^N \\ev{X_i}}{\\sigma \\sqrt{N}} = \\dfrac{\\sum_{i=1}^N 0}{\\sigma \\sqrt{N}} = 0\\\\\n\t\\sqrt{\\ev{X^2}} &= \\dfrac{\\sqrt{\\sum_{i=1}^N \\sum_{j=1}^N \\ev{X_i X_j}}}{\\sigma \\sqrt{N}} \\\\ \n\t&=  \\dfrac{\\sqrt{\\sum_{i=1}^N \\sum_{j=1}^N \\ev{X_i^2} \\delta_{ij}}}{\\sigma \\sqrt{N}} \\impliedby \\qq{independent variables, hence covariance is zero}\\\\\n\t&= \\dfrac{\\sqrt{\\sum_{i=1}^N\\sigma^2 }}{\\sigma \\sqrt{N}}\\\\\n\t\\sigma_X &= \\dfrac{\\sqrt{N \\sigma^2 }}{\\sigma \\sqrt{N}} = 1\n\t\\end{align*}\n\t\n\t\\textbf{Part (b)}\\\\\n\tLet $ x, y - x, 1- y $ be the lengths of the 3 sticks after breaking. Triangle inequality gives us the following conditions on the stick,\n\t\\begin{align*}\n\tx < 1-x \\implies x < \\dfrac{1}{2}\\\\\n\ty - x < x + 1 - y \\implies y -x > \\dfrac{1}{2}\\\\\n\t1-y < y \\implies y > \\dfrac{1}{2}\n\t\\end{align*}\n\tIn the unit square of the $ x-y $ plane, we need to find the intersection of the above regions. The first and last regions have an intersection of are$ \\dfrac{1}{4} $ in the plane, and the second region automatically includes this intersection. Hence the required probability is $ \\dfrac{1}{4}$.\n\t\n\t\n\t\\textbf{Part (c)}\\\\\n\tThe histograms are plotted below,\n\t\\begin{figure}[!h]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{trace_u.png}\n\t\t\\includegraphics[scale=0.5]{d.png}\n\t\t\\caption{L : Trace Distribution, R: Eigenvalue Spacing Distribution for Uniform case}\n\t\\end{figure}\n\n\t\\begin{figure}[!h]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{distr_n.png}\n\t\t\\includegraphics[scale=0.5]{trace_n.png}\n\t\t\\caption{L : Trace Distribution, R: Eigenvalue Spacing Distribution for Normal case}\n\t\\end{figure}\n\n\n\t\\textbf{Part (d)}\\\\\n\tIn our case, in time interval $ dt $, the walker can go left with probability $ \\alpha dt$, right with probability $ \\alpha dt$ and can stay at the same position with probability $ 1 - 2 \\alpha dt $. So then, at position $ i $ and time $ t + dt $,\n\t\\begin{align*}\n\tP(i, t + dt) &= P(i,t) (1 - 2 \\alpha dt) + (P(i+1,t) + P(i-1,t)) \\alpha dt\\\\\n\t\\pdv{P(i, t)}{t} &= - 2 P(i,t) \\alpha   + (P(i+1,t) + P(i-1,t)) \\alpha \\\\\n\t\\end{align*}\n\tWe solve the above equation by writing down the Fourier series. Every step away from $ i $th site will introduce factors of $ e^{jk} $ in the Fourier space,\n\t\\begin{align*}\n\t\\pdv{P(k,t)}{t} &= (-2 \\alpha + e^{jk} + e^{-jk}) P(k,t)\n\t\\end{align*}\n\tWe know that $ P(x,t=0) = \\delta_{x,0} \\implies P(k,t=0) = 1   $ and then the solution to the above equation is,\n\t\\begin{align*}\n\tP(k,t) &= e^{ (-2 \\alpha + e^{jk} + e^{-jk})t}\\\\\n\t&= e^{- 2 \\alpha t} \\sum_{x=-\\infty}^{\\infty } e^{2jkx \\cos k}\\\\\n\tP(k,t)&= e^{- 2 \\alpha t} \\sum_{x=-\\infty}^{\\infty } e^{2jkx} I_x(t)\n\t\\end{align*}\n\tFrom which we can see by inverse Fourier,  $ P(x,t) =  e^{- 2 \\alpha t} I_x(t) $, where $ I_x(t) $ is the Bessel function of the first kind.\t\n\t\n\t\\textbf{Part (e)}\\\\\n\tLet's say the random walker takes $ x $ steps rightward and $ y $ steps leftward. For this walker to be at $ r $ after $ N $ steps, $ x + y = N $ and $ x-y = r $ $ \\implies x = \\dfrac{N+r}{2} $ and $ y = \\dfrac{N - r}{2} $. The probability $ P(r,N) $ is then,\n\t\\begin{align*}\n\tP(r,N) &= {N \\choose r} \\dfrac{1}{2^{x}} \\dfrac{1}{2^{y}} \\\\\n\t&= {N \\choose x} \\dfrac{1}{2^{N}}\n\t\\end{align*} \n\t\n\tFor very large $ N $,\n\t\\begin{align*}\n\t{n \\choose x} = \\dfrac{N!}{x! y!} &= \\dfrac{N!}{\\qty(\\dfrac{N+r}{2})!\\qty(\\dfrac{N-r}{2})!}\\\\\n\t&=\\dfrac{e^{-N} N^N}{(N+r)^{(N+r)/2} (N-r)^{(N-r)/2} 2^{-N} e^{-N}}\\\\\n\t&= \\dfrac{N^N}{(1+r/N)^{(N+r)/2} (1-r/N)^{(N-r)/2} 2^{-N} N^N }\\\\\n\tP(r,N) &= \\dfrac{1}{(1+r/N)^{(N+r)/2} (1-r/N)^{(N-r)/2}}\\\\\n\tP(r,N) &= [{(1+r/N)^{(1+r/N)} (1-r/N)^{(1-r/N)}}]^{-N/2}\n\t\\end{align*}\n\tComparing with the form $ P(r,N) = e^{-N \\phi(r/N)} $, we get,\n\t\\begin{equation*}\n\t\\phi(x) =\\dfrac{ (1+x) \\ln (1+x) + (1 -x ) \\ln (1-x)}{2}\n\t\\end{equation*}\n\t\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[2]\n\t\\textbf{Part (a)}\\\\\n\tFor constant number of particles, \n\t\\begin{equation*}\n\tdU = -PdV + TdS + hdM\n\t\\end{equation*}\n\tThe enthalpy $ E $ is defined as $E = U + PV$,\n\t\\begin{align*}\n\tdE &= dU + PdV + VdP = -PdV + TdS + hdM + PdV + VdP \\\\\n\t&=  TdS + hdM  + VdP\n\t\\end{align*}\n\tThe Helmholtz Potential $ A $ is defined as $A = U - TS$,\n\t\\begin{align*}\n\tdA &= dU - TdS - SdT  = -PdV + TdS + hdM - TdS - SdT  \\\\\n\t&= -PdV + hdM  - SdT \n\t\\end{align*}\n\tThe Gibbs Potential $ G = E - TS $, \n\t\\begin{align*}\n\tdG &=  TdS + hdM  + VdP - TdS - SdT\\\\\n\t&=   hdM  + VdP - SdT\n\t\\end{align*}\n\tAs all the quantities are related by Legendre Transforms, knowledge of one of the quantities is enough to calculate all the others.\n\t\n\t\\textbf{Part (b)}\\\\\n\t$ C_x $ and $ \\kappa_x $ are defined as follows,\n\t\\begin{equation*}\n\tC_x = \\eval{\\dv{Q}{T}}_{x = const.} \\qq{} \\kappa_x = -\\eval{\\dfrac{1}{V}\\dv{V}{P}}_{x = const.}\n\t\\end{equation*}\n\tConsider the following,\n\t\\begin{align*}\n\tC_P = T \\eval{\\dv{S}{T}}_{P = const} = -T \\pdv[2]{G}{T} \\implies \\pdv[2]{G}{T} < 0 \\implies G(T) \\text{ is concave}\\\\\n\tC_V = T \\eval{\\dv{S}{T}}_{V = const} = -T \\pdv[2]{A}{T} \\implies \\pdv[2]{A}{T} < 0 \\implies A(T) \\text{ is concave}\\\\\n\t\\kappa_T = -\\eval{\\dfrac{1}{V}\\dv{V}{P}}_{T = const.} = -\\dfrac{1}{V} \\pdv[2]{G}{P} \\implies \\pdv[2]{G}{P} < 0 \\implies G(P) \\text{ is concave}\\\\\n\t\\kappa_T = -\\eval{\\dfrac{1}{V}\\dv{V}{P}}_{T = const.} = \\dfrac{1}{V} \\dfrac{1}{\\pdv[2]{A}{V} }\\implies \\pdv[2]{A}{V} > 0 \\implies A(V) \\text{ is convex}\\\\\n\t\\end{align*}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[3]\n\tGiven $ S_{Gibbs} = - \\sum_a p_\\alpha \\log p_\\alpha $, which we have to maximize under $ \\sum_\\alpha p_\\alpha = 1 $. We use the method of Lagrange multipliers, $ f(p_\\alpha) = - \\sum_a p_\\alpha \\log p_\\alpha + \\lambda (\\sum_\\alpha p_\\alpha - 1) $,\n\t\\begin{align*}\n\t\\dv{f}{p_\\gamma} &= - \\log p_\\gamma - 1 + \\lambda = 0 \\\\\n\t\\implies \\lambda &= 1 + \\log p_\\gamma \\implies p_\\gamma = constant = \\dfrac{1}{N} \n\t\\end{align*}\n\twhere $ N $ is the number of microstates. Hence, we have shown that the all microstates are equally likely in microcanonical ensemble.\n\t\n\tSimilarly, we proceed to carry out the calculation for canonical ensemble and grand canonical ensemble. In this case, $ f(p_\\alpha) = - \\sum_a p_\\alpha \\log p_\\alpha + \\lambda_1 (\\sum_\\alpha p_\\alpha - 1) +  \\lambda_2 (\\sum_\\alpha p_\\alpha E_\\alpha - \\ev{E}) $,\n\t\\begin{align*}\n\t\\dv{f}{p_\\gamma} &= - \\log p_\\gamma - 1 + \\lambda_1 + \\lambda_2 E_\\gamma = 0\\\\\n\t\\implies p_\\gamma &= \\exp(\\lambda_1 - 1) \\exp(\\lambda_2 E_\\gamma)\n\t\\end{align*}\n\twhich is the expression for probability in the canonical ensemble \\textit{ie}. some normalization times $ \\exp(\\beta E_\\gamma) $.\n\t\n\tFor the grand canonical ensemble, $ f(p_\\alpha) = - \\sum_a p_\\alpha \\log p_\\alpha + \\lambda_1 (\\sum_\\alpha p_\\alpha - 1) +  \\lambda_2 \\qty(\\sum_\\alpha p_\\alpha E_\\alpha - \\ev{E}) +\\lambda_3 (\\sum_\\alpha N_\\alpha p_\\alpha - \\ev{N})$,\n\t\\begin{align*}\n\t\\dv{f}{p_\\gamma} &= - \\log p_\\gamma - 1 + \\lambda_1 + \\lambda_2 E_\\gamma + \\lambda_3 N_\\gamma = 0\\\\\n\t\\implies p_\\gamma &= \\exp(\\lambda_1 - 1) \\exp(\\lambda_2 E_\\gamma + \\lambda_3 N_\\gamma)\n\t\\end{align*}\n\twhich is the expression for probability in the canonical ensemble \\textit{ie}. some normalization times $ \\exp(\\beta E_\\gamma + \\mu N_\\gamma) $.\n\t\n\t\\textbf{Part (b)}\\\\\n\tWe first write down the partition function for a classical ideal gas,\n\t\\begin{align*}\n\tZ &= \\dfrac{1}{h^{3N} N!} \\prod_{i=1}^{N} \\int d^3q_i d^3 p_i \\exp(-\\beta p_i^2/2m)\\\\\n\t&= \\dfrac{1}{h^{3N} N!} \\prod_{i=1}^{N} V \\qty(\\dfrac{2 \\pi m}{\\beta})^{3/2}\\\\\n\t&= \\dfrac{ V^N}{h^{3N} N!} \\qty(\\dfrac{2 \\pi m}{\\beta})^{3N/2}\n\t\\end{align*}\n\t\n\tSo then, the probability is given by,\n\t\\begin{align*}\n\tP(N=N) &= \\sum_{\\epsilon_i} \\dfrac{e^{\\beta \\mu N} e^{-\\beta \\epsilon_i}}{Z}\\\\\n\t&= \\dfrac{e^{\\beta \\mu N}}{e^{\\ev{N}}} \\dfrac{1}{N!} \\qty(\\dfrac{V}{\\lambda^3})^N\\\\\n\t&= \\dfrac{e^{-\\ev{N}} \\ev{N}^N}{N!}\n\t\\end{align*}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[4]\n\t\\begin{align*}\n\tf_\\nu (z ) &= \\dfrac{1}{\\Gamma(\\nu)} \\int_{0}^{\\infty}  \\dd x \\dfrac{x^{\\nu - 1}}{z^{-1} e^x + 1}\\\\\n\t&= \\dfrac{1}{\\Gamma(\\nu)} \\qty[ \\eval{\\dfrac{x^{\\nu}}{\\nu(z^{-1} e^x + 1)}}_{0}^{\\infty} - \\int_{0}^{\\infty}  \\dd x \\dfrac{x^{\\nu}}{\\nu } \\dv{z^{-1} e^x + 1}{x}]\\\\\n\t&= -\\dfrac{1}{\\Gamma(\\nu+1)} \\qty[ \\dd x {x^{\\nu}} \\dv{z^{-1} e^x + 1}{x}]\n \t\\end{align*}\n \tWe change the variables to $ x=  \\ln z + t$ and get,\n \t\\begin{align*}\n \tf_\\nu(z) &\\approx -\\dfrac{1}{\\Gamma(\\nu + 1)} \\int_{-\\infty}^\\infty dt (\\ln z + t )^\\nu \\dv{t} \\qty(\\dfrac{1}{z^{-1} z e^t + 1})\\\\\n \t&\\approx -\\dfrac{1}{\\Gamma(\\nu + 1)} \\int_{-\\infty}^\\infty dt \\sum_m \\dfrac{\\nu!}{m! (\\nu -m)!} t^m ( \\ln z)^{\\nu - m}  \\dv{t} \\qty(\\dfrac{1}{e^t + 1})\\\\\n \t&\\approx \\dfrac{1}{\\Gamma(\\abs{\\nu - m} + 1)} \\int_{-\\infty}^\\infty dt \\sum_m ( \\beta \\mu)^{\\nu - m}  I_m\n \t\\end{align*}\n \t\n \t\\textbf{Part (b)}\\\\\n \t\\begin{align*}\n \tN &= \\dfrac{V}{\\lambda^3} f_{3/2} \\\\\n \t&= \\dfrac{V}{\\lambda^3} \\qty(\\dfrac{(\\beta \\mu)^{3/2}}{\\Gamma(5/2)}  +  \\qty(\\dfrac{(\\beta \\mu)^{-1/2}}{\\Gamma(3/2)} 2 f_2^- (1) ))\\\\\n \t&=\\dfrac{V \\beta^{-3/2}}{(2 \\pi m)^{-3/2}} \\qty(\\dfrac{4\\mu^3/2}{3} + 4 \\mu^{-1/2} \\beta^2 f_2^-(1))\\\\\n \t&= \\dfrac{4V \\mu^{3/2}}{3 \\pi (2 m \\pi)^{3/2}} + \\dfrac{4 V \\mu^{-1/2} \\beta f_2(1)}{\\pi (2 m \\pi )^{3/2}}\n \t\\end{align*}\n \t\n \t\\begin{align*}\n \tE &= \\dfrac{3 V (\\beta)^{-5/2} }{2 \\lambda^3 } f_{5/2}(z)\\\\\n \t&= \\dfrac{3V \\beta^{-5/2}}{2 (2 \\pi m)^{-3/2}} \\qty[\\dfrac{(\\beta \\mu)^{5/2}}{\\Gamma (7/2)} + \\dfrac{(\\beta \\mu)^{1/2}}{\\Gamma (3/2)} (2 f_2^-(1))]\\\\\n \t&= \\dfrac{3V }{2 (2 \\pi m)^{-3/2}} \\qty[\\dfrac{(\\mu)^{5/2}}{\\Gamma (7/2)} + \\dfrac{(\\beta)^{-2} (\\mu)^{1/2}}{\\Gamma (3/2)} (2 f_2^-(1))]\n \t\\end{align*}\n \t\\begin{equation*}\n \tC_V = \\lim\\limits_{T \\rightarrow 0} \\pdv{E}{T} = \\dfrac{3V \\mu^{1/2} (2 \\pi m)^{3/2}}{\\Gamma(3/2)} k_B^2 T\n \t\\end{equation*}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[5]\n\t\\textbf{Part (b)}\\\\\n\tWe are given,\n\t\\begin{equation*}\n\tH_N = \\sum_{i=1}^N \\dfrac{p_i^2}{2m} + \\sum_{i=1}^{N-1} u(x_i - x_{i-1}) +v (x_1) + v(x_N)\n\t\\end{equation*}\n\tOne can write the expression of the partition function as follows,\n\t\\begin{align*}\n\tZ &= \\dfrac{1}{N!} \\prod_{i}^N \\int \\int \\dfrac{\\dd{p_i} \\dd{x_i}}{h} \\exp(-\\beta H_N) \\\\\n\t&= \\dfrac{1}{N!h^N} \\prod_{i}^N \\int  \\dd{p_i} \\exp(-\\beta p_i^2/2m) \\prod_{i} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  )\\\\\n\t&= \\dfrac{1}{N!h^N} \\qty(\\dfrac{2 \\pi m}{\\beta})^{N/2} \\prod_{i} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  )\n\t\\end{align*}\n\tConsider,\n\t\\begin{align*}\n\t\\prod_{i} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  ) &= \\prod_{i \\ne 1} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  + v(x_i) ) \\int_{-\\infty }^\\infty \\dd x_1 e^{-\\beta u(x_2 - x_1) + v(x_1)}\\\\\n\t&= \\prod_{i \\ne 1} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  + v(x_i) ) \\int_{a/2 }^{x_2 -a } \\dd x_1\\\\\n\t&= \\prod_{i \\ne 1} \\int \\dd{x_i} \\exp(-\\beta \\sum_{i=1}^{N-1} u(x_i - x_{i-1})  + v(x_i) ) (x_2 - 1.5 a)\n\t\\end{align*}\n\tWe have done one integral, and we now similarly separate out integrals over the other $ x_i $'s. The constant terms will integrate to zero, while the terms involving $ x_i $'s can be simply integrated as power functions. After $ N $ integrals, one will be left with,\n\t\\begin{align*}\n\t\\int_{(N - a/2 )}^{L  - a/2} \\dd x_N \\dfrac{1}{(N-1)!} \\exp(\\beta u(x_N - x_{N-1}) - \\beta v (x_N)) \\qty(x_N - \\dfrac{N-1}{2}a)^{N-1}\\\\\n\t&= \\int_{(N - a/2 )}^{L  - a/2} \\dd x_N \\dfrac{1}{(N-1)!} \\qty(x_N - (N-0.5)a)^{N-1}\\\\\n\t&=\\dfrac{1}{N!} \\qty(L - \\dfrac{a}{2} - Na + \\dfrac{a}{2})^N\\\\\n\t&= \\dfrac{1}{N!} (L- Na )^N\n\t\\end{align*}\n\tHence, the full partition function of the problem,\n\t$ Z_N = \\dfrac{1}{\\lambda^N N!^2} (L-Na)^N$\n\t\n\tNow that we have the partition function, $ A = -k_B T \\log Z_N $,\n\t\\begin{align*}\n\t\\therefore P &= -\\pdv{A}{L} = \\dfrac{k_B T}{Z_N} \\pdv{Z_N}{L}\\\\\n\t&= \\dfrac{N k_B T}{L- Na}\\\\\n\t&= \\dfrac{n k_B T}{1 - na}\n\t\\end{align*}\n\twhere $ n= \\dfrac{N}{L} $.\t\n\\end{homeworkProblem}\n\n\n\\begin{homeworkProblem}[6]\n\tA $ s $-particle density is defined as,\n\t\\begin{equation*}\n\tf_s (\\forall \\va{p}_i, \\forall \\va{q}_i, t)= \\dfrac{N!}{(N-s)!} \\int \\prod_{i=x+1}^N \\dd V_i \\rho(\\va{p}, \\va{q},t \n\t\\end{equation*}\n\t\n\tNow one needs to use the defined $ s $-particle density with the Hamiltonian of the form,\n\t\\begin{align*}\n\tH &= \\sum_{i=1}^{N} \\qty[\\dfrac{p_i^2}{2m} + U(\\va{q_i})] + \\sum_{i,j = 1}^{N}\\dfrac{1}{2} V(\\va{q}_i - \\va{q}_j)\\\\\n\t&= \\qty[\\sum_{i=1}^{s} \\qty[\\dfrac{p_i^2}{2m} + U(\\va{q_i})] + \\sum_{i,j = 1}^{s}\\dfrac{1}{2} V(\\va{q}_i - \\va{q}_j)] + \\qty[\\sum_{i=s+1}^{N} \\qty[\\dfrac{p_i^2}{2m} + U(\\va{q_i})] + \\sum_{i,j = s+1}^{N}\\dfrac{1}{2} V(\\va{q}_i - \\va{q}_j)] \\\\& \\qq{ }+ \\qty[\\sum_{i= 1}^s \\sum_{j= s+1}^N V (\\va{q}_i - \\va{q}_j)]\\\\\n\t&= H_s + H_{N-s} + H'\n\t\\end{align*}\n\tWe know from Liouville Theorem that,\n\t\\begin{align*}\n\t\\pdv{\\rho_s}{t} &= \\int \\prod_{i=s+1}^{N} \\dd V_i \\pdv{\\rho}{t}\\\\\n\t&= -\\int \\prod_{i=s+1}^{N} \\dd V_i \\pb{\\rho}{H_s + H_{N-s} + H'}\n\t\\end{align*} \n\tWe now note the following,\n\t\\begin{align*}\n\t\\int \\prod_{i=s+1}^{N} \\dd V_i \\pb{\\rho}{H_s} &= \\pb{ \\qty(\\prod_{i=s+1}^N \\dd V_i \\rho)}{ H_s} = \\pb{\\rho_s}{H_s} \\\\\n\t-\\int \\prod_{i=s+1}^{N} \\dd V_i \\pb{\\rho}{H_{N-s}} &= \\int \\prod_{i=s+1}^{N} \\dd V_i \\sum_{i=s+1}^N \\qty[\\pdv{\\rho}{\\va{p}_j} \\pdv{H_{N-s}}{\\va{q}_j} - \\pdv{\\rho}{\\va{q}_j} \\pdv{H_{N-s}}{\\va{p}_j}] \\\\\n\t&= \\int \\prod_{i=s+1}^{N} \\dd V_i \\sum_{i=s+1}^N \\qty[\\pdv{\\rho}{\\va{p}_j} \\qty(\\pdv{U}{\\va{q}_j} + \\sum_{j=s+1}^{N} \\pdv{V}{\\va{q}_j})- \\pdv{\\rho}{\\va{q}_j} \\dfrac{\\va{p}_j}{m}] \\\\\n\t\\int \\prod_{i=s+1}^{N} \\dd V_i \\pb{\\rho}{H_{N-s}} &= \\int \\prod_{i=s+1}^{N} \\dd V_i \\sum_{n=1}^s \\qty[\\pdv{\\rho}{\\va{p}_n} \\qty( \\sum_{j=s+1}^{N} \\pdv{V}{\\va{q}_j})] - \\qty[\\sum_{n=1}^{s} \\pdv{\\rho}{\\va{p}_j} \\sum_{n=1}^s \\pdv{V}{\\va{q}_j}]\n\t\\end{align*}\n\tIn the last expression, we can integrate out the second term. The first term has $ N-s $ equal terms (by symmetry),\n\t\\begin{equation*}\n\t(N-s) \\int \\prod_{i=s+1}^{N} \\dd V_i \\sum_{n=1}^s \\pdv{V}{\\va{q}_n} \\pdv{\\rho}{\\va{p}_n} = (N-s) \\sum_{n=1}^s \\dd V_{s+1} \\pdv{V}{\\va{q}_n} \\vdot \\pdv{\\va{p}_n} \\qty[\\int \\prod_{i=s+2}^{N} \\dd V_i \\rho]\n\t\\end{equation*}\n\t\n\tAdding up the three terms above, we get,\n\t\\begin{equation*}\n\t\\pdv{f_s}{t} - \\pb{H_s}{f_s} = \\sum_{n=1}^{s} \\int \\dd V_{s+1} \\pdv{V(q_n - q_{s+1})}{\\va{q}_n} \\vdot \\pdv{\\va{p}_n} \\qty[\\int \\prod_{i=s+2}^N \\dd V_i \\rho]\n\t\\end{equation*}\n\t\n\t\\textbf{Part (b)}\\\\\n\t\\begin{equation*}\n\t\\dfrac{f_{s+1}}{f_s} = \\dfrac{(N-s)!}{(N-s-1)!} \\rho_1 (x_{s+1})\n\t\\end{equation*}\n\tWe then have, from the BBGKY hierarchy,\n\t\\begin{align*}\n\t\\qty[\\pdv{t} + \\sum_{n=1}^s \\qty(\\dfrac{\\va{p}_n}{m} \\pdv{\\va{q}_n} - \\pdv{U}{\\va{q}_n} \\pdv{\\va{p}_n}) ] f_s &\\approx \\sum_{n=1}^s\\int \\dd V_{s+1} \\pdv{V}{\\va{q_n}} \\pdv{\\va{p}_n} (N-s) f_s \\rho_1 (x_{s+1}) \\\\\n\t&\\approx \\sum_{n=1}^s  \\pdv{\\va{q_n}}\\qty[\\int \\dd V_{s+1} \\rho_1(x_{s+1}) V N] \\pdv{\\va{p}_n} f_s \\\\\n\t\\implies \\qty[\\pdv{t} + \\sum_{n=1}^s \\qty(\\dfrac{\\va{p}_n}{m} \\pdv{\\va{q}_n} - \\pdv{U_{eff}}{\\va{q}_n} \\pdv{\\va{p}_n}) ] &= 0\n\t\\end{align*}\n\twhere $ U_{eff} = U(\\va{q}) + N \\int \\dd V' V(\\va{q} - \\va{q}') f_1(\\va{x'},t) $.\n\\end{homeworkProblem}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "784696a4e54470e087e376379ef95e3005415093", "size": 18706, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem2/stat/assign_1/assign_1.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem2/stat/assign_1/assign_1.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem2/stat/assign_1/assign_1.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5770065076, "max_line_length": 313, "alphanum_fraction": 0.5981503261, "num_tokens": 8220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.826711791935942, "lm_q1q2_score": 0.4487914776077705}}
{"text": "\n\\chapter{SIGNAL EXTRACTION AND SYSTEMATICS}\n\n\\section{Boosted decision trees method} \\label{BDTchaper}\nThe boosted decision trees(BDT)~\\cite{BDTboostPI,TMVAnote} is used in the $\\Hmuhad$ analysis. The $\\Hmuhad$ result which is referred as BDT fit analysis, with this MVA method, improves a factor of two with respect to the $\\mcol$ fit analysis. The BDT algorithm is composed of two parts, the boosting algorithm and the decision tree. The AdaBoost(adaptive boost) is the boosting algorithm used in the $\\Hmuhad$ analysis. \n\nThe decision tree is a simple two dimensional tree structure. The BDT takes in one signal and one background dataset, which are further divided into training and test samples. A set of selected variables are used the training. At the initial node of the tree structure, events are ordered by the value of variables. The node is split into two branches by a binary selection of the variable that gives the best separation between signal and background in each of the branch. The splitting continues until the training reaches the specified limit set for the number of layers or the number of events in the branch, then the last notes are called leaves. Depending on the main population inside each leaf, the leafs are categorized as signal leaves or background leaves. An example of the tree structure is shown in Figure.~\\ref{fig:BDTtreestructure}.  Criteria are needed for the selection of variables at the node or branch. Purity is defined as in Equation.~\\ref{Equ.purityBDT}, in which the superscript s stands for signal events, b for background events and W for the event weight.\n\\begin{align} \\label{Equ.purityBDT}\nP=\\frac{\\sum_{s}W_{s}}{\\sum_{s}W_{s}+\\sum_{b}W_{b}}\n\\end{align}\nThrough the definition of purity, a couple of criteria can be configured. Here the one called Gini, defined in Equation.~\\ref{Equ.BDTGini}, is selected also it is the default one for the BDT in TMVA package. \n\\begin{align}\\label{Equ.BDTGini} \nGini=(\\sum_{i=1}^{n}W_{i})P(1-P)\n\\end{align}\nIn each splitting, the variable value that maximize the criterion in Equation.~\\ref{Equ.BDTtreecriterion} is selected.  \n\n\n\n\\begin{align}\\label{Equ.BDTtreecriterion} \nCriterion=Gini_{n-1}-Gini_{n \\ left}-Gini_{n \\ right}\n\\end{align}\n\n\n\\begin{figure}[!tbp] \n\\centering\n\\includegraphics[width=0.6\\textwidth]{chapter7/BDT_tree_show.pdf}\n\\caption{Tree structure example in BDT}\n\\label{fig:BDTtreestructure}\n\\end{figure}\n\nThe decision tree method is powerful, but the performance can suffer from fluctuations. The selection of two variables with similar selection quality may be affected by a small change in the training sample. One of the solution is introducing the boosting algorithm. The boosting algorithm not only helps stabilize the decision tree training with respect to the small fluctuations, but also enhances the classification. The AdaBoost is one of the boosting algorithms. In AdaBoost, after the first decision tree training, the misclassified events get higher even weights and are taken as inputs into the second tree. Typically the AdaBoost training 1000 to 2000 trees. The misclassified event weights depend on the training error of each decision tree. The training error is calculated as in Equation.~\\ref{Equ.errorBDT},\n\\begin{equation}\\label{Equ.errorBDT} \n\\textrm{error}_{m}=\\frac{\\sum_{i=1}^{N}w_{i}I(y_{i}\\neq T_{m}(x_{i}))}{\\sum_{i=1}^{N}w_{i}} \n\\end{equation}\nin which the superscript m is the tree label and w is the event weight. The $y_{i}$ indicates the i-th event type, 1 for signal and -1 for background. $T_{m}(x_{i})$ indicates the type of the leaf event i with variable x land on, 1 for signal leaf and -1 for background leaf. The variable $I(y_{i}\\neq T_{m}(x_{i}))$ constructs on the variables $y_{i}$ and $T_{m}$ equal 1 if $y_{i}\\neq T_{m}(x_{i})$ or 0 if $y_{i}= T_{m}(x_{i})$. As shown in Equation.~\\ref{Equ.boostingweight}, with the intermediate quantity $\\alpha_{m}$ for the tree m, the weight for event i is updated to its new value. \n\\begin{align}\\label{Equ.boostingweight} \n\\alpha_{m}=&\\beta\\times \\textrm{ln}((1-\\textrm{error}_{m})/\\textrm{error}_{m})\\\\\nw_{i}\\rightarrow &w_{i}\\times e^{\\alpha I(y_{i}\\neq T_{m}(x_{i}))} \n%w_{i}\\rightarrow &w_{i}/\\sum_{i=1}^{N}w_{i}\n\\end{align}\nWhile $\\textrm{error}_{m}$ is required to be less than 0.5 so as the event weights are updated to the right direction. The learning rate parameter $\\beta$ can be used to adjust the step size of each re-weighting. The default value of $\\beta$ is 1. Event weights in each tree is renormalized to keep the summed weights constant. The final score of each event after the boosting and training processes is obtained with Equation.~\\ref{Equ.boostingeventweight}. High score indicates a signal like event while low score indicates a background like event.\n\n\n\\begin{align}\\label{Equ.boostingeventweight} \nT(x)=\\sum_{m=1}^{N_{tree}}\\alpha_{m}T_{m}(x)\n\\end{align}\n\n\n\n\\section{Statistical methods}\n\nPhysics results are extracted with statistical methods. The limit of branching ratio with confident level(CLs) method, significance and best fit branching fraction are mentioned in the analysis.  \n\nThe probability density function(PDF) and likelihood function are the basic functions used. The PDF of a continuous variable x can be interpreted as the likelihood of x at its different values. The PDF holds the property that it is normalized to unity. \n\\begin{align*}\n\\int f(x) dx =1\n\\end{align*}\n\nUsually the PDF of a variable is accompanied with a set of parameters, thus the PDF is usually written in the form $f(data|\\alpha)$, which means the probability density function of the variables in data  given the parameter set $\\alpha$. These parameters can from various sources, for example, from theory estimation, detector response and Monte Carlo simulation. All of the parameters in a model or a system, besides the parameters of interests, the other parameters that have an impact on the results are referred as nuisance parameters.       \n\n\nLikelihood function of the same model $L(data|\\alpha)$ is a function of parameter set $\\alpha$ given data under study. In particle physics, the likelihood function is more often in the form of $L(data|\\mu,\\theta)$, in which the $\\mu$ stands for signal strength modifier and the $\\theta$ stands for a full suite of nuisance parameters. The data in a Likelihood function can be experimental data or pseudo-data which is produced to generate sample distribution. \nTaking the counting experiment as an example, the PDFs and likelihood function in a binned sample can be estimated with poisson distribution. The  PDF is in the form as\n\\begin{align*}\nf(data|u,\\theta)=\\prod_{i}\\frac{(\\mu s_{i}+b_{i})^{n_{i}}}{n_{i}!}e^{-\\mu s_{i}-b_{i}}\n\\end{align*}\nThe $s_{i}$ and $b_{i}$ stand for the expected number signal and background events respectively and both of them are a function of nuisance parameter $\\theta$ as $s_{i}(\\theta)$ and $b_{i}(\\theta)$. The $n_{i}$ represents the number of events observed in bin i. The likelihood function in the numerical form is similar to the PDF but implement the systematic error PDFs $\\rho(\\theta|\\tilde{\\theta})$ if there are systematics considered in the model~\\cite{CMS-NOTE-2011-005}. The form of the likelihood function can be expressed as \n\\begin{align*}\n\\mathcal{L}=\\prod_{i}\\frac{(\\mu s_{i}+b_{i})^{n_{i}}}{n_{i}!}e^{-\\mu s_{i}-b_{i}}\\cdot \\rho(\\tilde{\\theta}|\\theta)\n\\end{align*}\n\nBoth of the PDF and the likelihood function rely on the knowledge of nuisance parameters. Auxiliary measurements or control regions are often used for the scale estimation of systematic uncertainties. Through the observations in different auxiliary measurements, a PDF $p(\\tilde{\\theta}|\\theta)$ which is referred as the posteriors can be measured. Together with $\\pi(\\theta)$ which is referred as a prior, the systematic error PDFs can be constructed under the Bayes' theorem as\n\\begin{align*}\n\\rho(\\theta|\\tilde{\\theta})\\sim p(\\tilde{\\theta}|\\theta)\\cdot \\pi_{\\theta}(\\theta)\n\\end{align*}\nThe systematic error PDFs can be improved and less affected by the choice of prior $\\pi(\\theta)$~\\cite{statistics:school2016} by the auxiliary measurements. \n\nIn the search of lepton flavour violaton Higgs decay, the discovery will be the observation of the Higgs events either decay into $\\mu\\tau$ pairs in 13 TeV search or $e\\tau$ pairs in 8 TeV search. The LFV is forbidden in Standard Model(SM), thus, if taking the SM as a background only model, roughly speaking, a discovery can be claimed if the observation is not compatible with the background only model~\\cite{LHCstaticstics}. To test the compatibility of the observed data with respect to the background only model and further calculate limits on the signal strength modifier of the signal+background hypothesis, the quantity test statistics and the PDFs of the two model under tested are needed.\n\nThe test statistics is a function which can map a set of data into a number. According to the Neyman-Pearson lemma, the likelihood ratios of two models under test give the most powerful test, which is expressed as\n\\begin{align*}\n\\tilde{q}_{\\mu}=-2\\textrm{ln}\\frac{\\mathcal{L}(data|\\mu,\\tilde{\\theta}_{\\mu})}{\\mathcal{L}(data|\\hat{\\mu},\\hat{\\theta})}\n\\end{align*}\nThe $\\mu$ is the given signal strength modifier and $0<\\hat{\\mu}<\\mu$. The $\\tilde{\\theta}$ is referred as conditional maximum likelihood estimator, given the signal strength modifier $\\mu$, while in the denominator, $\\hat{\\mu}$ and $\\hat{\\theta}$ are allowed to flow freely to maximize the likelihood. The PDFs of signal+background model and background only model can be calculated in the following way. The observed $\\theta^{obs}_{\\mu}$ and  $\\theta^{obs}_{0}$ for signal+background and background only model are obtained by maximizing the likelihood function respectively, also the observed $\\tilde{q}_{\\mu}^{obs}$ is calculated give a $\\mu$. The PDFs of signal+background model $f(\\tilde{q}_{\\mu}|\\mu,\\theta^{obs}_{\\mu})$ and background only model $f(\\tilde{q}_{\\mu}|0,\\theta^{obs}_{0})$ are constructed with the MC pseudo-data as shown in Figure.~\\ref{fig:teststatistics}.\n\n\\begin{figure}[!tbp] \n\\centering\n\\includegraphics[width=0.6\\textwidth]{chapter7/Test_statistics.png}\n\\caption{Test statistics distribution of signal+background and background only PDFs and the observed value shown in arrow.}\n\\label{fig:teststatistics}\n\\end{figure}\n \nThe $\\textrm{CL}_{s}$ is defined with two values $p_{\\mu}$ and 1-$p_{b}$. In signal+background model, $p_{\\mu}$ is defined as\n\\begin{align*}\np_{\\mu}=P(\\tilde{q}_{\\mu}\\geq  \\tilde{q}_{\\mu}^{obs}  |\\textrm{signal+background})=\\int^{\\infty}_{\\tilde{q}_{\\mu}^{obs}}f(\\tilde{q}_{\\mu}|\\mu,\\hat{\\theta}_{\\mu}^{obs})d \\tilde{q}_{\\mu}\n\\end{align*}\nIn background only model 1-$p_{b}$ is defined as\n\\begin{align*}\n1-p_{b}=P(\\tilde{q}\\geq  \\tilde{q}_{\\mu}^{obs} | \\textrm{background only})=\\int^{\\infty}_{\\tilde{q}_{0}^{obs}}f(\\tilde{q}_{\\mu}|0,\\hat{\\theta}_{0}^{obs})d \\tilde{q}_{\\mu}\n\\end{align*}\nThe $\\textrm{CL}_{s}$ then is expressed as\n\\begin{align*}\n\\textrm{CL}_{s}=\\frac{p_{\\mu}}{1-p_{b}}\n\\end{align*}\n\nFor a given value of signal strength modifier $\\mu$, $CL_{s}\\leq\\alpha$, then the signal+background is said excluded with $(1-\\alpha)~ \\textrm{CL}_{s}$. Usually $\\alpha$ is picked as 95\\%.\n\nThe expected limit shown in lepton flavour violating Higgs decay is the median 95\\% $CL_{s}$ upper limit with the $\\pm 1 \\sigma$ and $\\pm 2 \\sigma$ bands in the background only model. By generating a large number of background only pseudo-data, the CLs and $\\mu^{95\\%}$ of each toy are calculated. An example of $\\mu^{95\\%}$ distributions is shown in Figure.~\\ref{fig:Signal_strength_example}. As shown in the cumulative distribution of $\\mu^{95\\%}$, the median corresponds to 50\\%,while $\\pm 1 \\sigma$, $\\pm 2 \\sigma$  correspond to range 16\\% to 84\\% and 2.5\\% to 97.5\\% respectively.     \n\\begin{figure}[!tbp] \n\\centering\n\\includegraphics[width=0.4\\textwidth]{chapter7/Signal_strength_example_1.png}\n\\includegraphics[width=0.4\\textwidth]{chapter7/Signal_strength_example_2.png}\n\\caption[Signal strength modifier distribution of the MC pseudo-data]{Signal strength modifier $\\mu$ at 95\\% $CL_{s}$ distribution from the MC pseudo-data. The right plot is the cumulative distribution of $\\mu^{95\\%}$ with $\\pm 1 \\sigma$ and $\\pm 2 \\sigma$ bands.}\n\\label{fig:Signal_strength_example}\n\\end{figure}\n\nThe estimator p value and significance are used to check if the data is compatible with background only model. The test statistics in the checking of background only model is expressed as\n\\begin{align*}\n\\tilde{q}_{\\mu}=-2\\textrm{ln}\\frac{\\mathcal{L}(data|0,\\tilde{\\theta}_{\\mu})}{\\mathcal{L}(data|\\hat{\\mu},\\hat{\\theta})}\n\\end{align*}\nSimilar procedure as mentioned above can be used to get the PDF of background ground only model $f(q_{0}|0,\\hat{\\theta}^{obs}_{0})$ and $q^{obs}_{0}$. The p-value corresponding to the experimental observable is calculated as\n\n\\begin{align*}\np_{0}=P(q_{0}\\geq q_{0}^{obs})=\\int^{\\infty}_{q_{0}^{obs}}f(q_{0}|0,\\hat{\\theta}_{0}^{obs})d q_{0}\n\\end{align*}  \nSignificance Z of the observable with respect to the background only model test can be derived from p value~\\cite{CMS-NOTE-2011-005}.\n\\begin{align*}\np=\\int^{\\infty}_{Z}\\frac{1}{\\sqrt{2\\pi}}exp(-x^2/2)dx\n\\end{align*}  \nThe term used in the discovery as 5$\\sigma$ correspond to Z=5 and p=$2.8\\times10^{-7}$. The distribution of test statistics tends to be chi-squared distribution in large statistics according to the Wilk's theorem, which gives a quick way of estimating of PDFs in test statistics~\\cite{LHCstaticstics}. In the case when the expected number of events is large, expected limit with this asymptotic approximation gives a fairly well performance and saves the computing time for toy samples. The asymptotic approximation can used in the estimation of p value as\n\\begin{align*}\np^{estimate}=\\frac{1}{2}\\bigg[1-erf\\bigg(\\sqrt{q_{0}^{obs}/2}\\bigg)\\bigg]\n\\end{align*}  \n\n\n\n\\section{Systematics}\nSystematic uncertainties originated from different sources that experimentally or theoretically affect the physics results. These uncertainties are considered by the effects on the normalization and the shapes of the distribution from different processes. \n\n\\subsection{Systematics used in $\\Hmuhad$}\nThe systematic uncertainties considered in this analysis are summarized in Table.~\\ref{tabsystematicsone} and Table.~\\ref{tab:systematicstwo}. The uncertainty on muon trigger, identification and isolation together amounts  to 2\\% and the hadronic tau lepton efficiency amounts to 5\\%. The uncertainties on lepton selections that include trigger, ID, isolation efficiencies are estimated with tag and probe method with Z boson data sets~\\cite{Khachatryan2011,Chatrchyan:2012xi,Khachatryan:2015hwa,Khachatryan:2015dfa,CMS:2016gvn}. The systematic uncertainty of b tagging veto is taken from the uncertainty of b tagging veto efficiency measurement, which adjusts b tagging veto performance in the simulation to match data sample. The exact values used in each category of $t\\bar{t}$ and single top samples are summarized in Table.~\\ref{tab:btaguncertainty}. The uncertainties on $Z\\to\\tau\\tau$, WW, WZ, ZZ, $t\\bar{t}$, single top backgrounds mainly originate from the uncertainties on the cross section measurements. The normalization uncertainty of $\\mu$ misidentifying $\\tau$ scale factor measurement and the uncertainty on $Z\\to \\mu\\mu$ process together amounts to 25\\%. An additional shape uncertainty on muon misidentifying tau is extracted from the measurement of the scale factor and treats independently of different hadronic tau decay modes. The uncertainty of the misidentified lepton background is estimated from the matching of the same sign control region which is defined as region II in Table.~\\ref{tab:fakeratediagram}. The 30\\% on normalization uncertainty correlated between each category and additional 10\\% uncorrelated between each category are taken as a conservative estimation. Only the tau shape uncertainties are considered, which are taken from the variations of the misidentified tau parameters in the fitting. The muon misidentified shape uncertainty is omitted as it would be negligible compared with the bin-by-bin uncertainty applied.  The shape uncertainties of jet energy scale is estimated by varying the fitting parameters of different sources that affect this scale by one $\\sigma$. The tau energy scale is treated as shape uncertainties and each of the tau decay modes is considered independently. The unclustered energy refers to the energy deficiency from the jets $\\pt<10$ GeV and the PF candidates that are not included in the jet reconstruction. The unclustered energy uncertainty is considered independently for charged particles, photons, neutral hadrons and very forward particles.  The uncertainties on Higgs boson cross section is affected by the renormalization scales, factorization, parton distribution functions(PDF) and the strong coupling constant($\\alpha_{s}$). These uncertainties contribution in normalization scale and are taken from the latest recommendation~\\cite{YR4}. The uncertainties on Higgs cross section also affect the acceptance and result in the migration of events between categories.  The bin-by-bin uncertainty is applied to account for the statistics uncertainties within each bin. These uncertainties are uncorrected between different bins and categories. The uncertainty of integrated luminosity~\\cite{CMS-PAS-LUM-17-001}  amounts to 2.5\\%.\n\n\n\n\\begin{table}[htpb]\n\\caption{PART ONE OF THE SYSTEMATIC UNCERTAINTIES CONSIDERED IN THE $\\Hmuhad$ ANALYSIS}\\label{tabsystematicsone}\n\\centering\n\\begin{threeparttable}\n%\\begin{center}\n%\\caption{Part one of the systematic uncertainties considered in $\\Hmuhad$ analysis. Systematic uncertainties in the expected event yields. All uncertainties are treated as correlated between the categories, except those that have two values separated by the $\\oplus$ sign. In this case, the first value is the correlated uncertainty and the second value is the  uncorrelated uncertainty for each individual category. Theoretical uncertainties on VBF Higgs boson production~\\cite{YR4}  are also applied to VH production. Uncertainties on acceptance lead to migration of events between the categories, and can be correlated or anticorrelated between categories. Ranges of uncertainties for the Higgs boson production indicate the variation in size, from negative (anticorrelated) to positive (correlated)}\n%\\centering\n\\begin{tabular}{lc}\\hline\nSystematic  uncertainty            & $\\PH\\to\\Pgm\\tauh$  \\\\ \\hline\nMuon  trigger/identification/isolation         &       2\\%             \\\\\nHadronic tau lepton efficiency                  &       5\\%              \\\\\nb tagging veto                                          &      2.0--4.5\\%     \\\\\n$\\PZ\\to\\Pgt\\Pgt$ + jets background         &    10\\%$\\oplus$5\\%   \\\\\n$\\PW\\PW, \\PZ\\PZ$ background              &     5\\%$\\oplus$5\\%       \\\\\n\\ttbar\\  background                                  &     10\\%$\\oplus$5\\%             \\\\\nSingle top quark background                 &     5\\%$\\oplus$5\\%  \\\\\n$\\Pgm\\to\\tauh$ background                                      &         25\\%         \\\\\n$\\text{Jet}\\to\\tauh, \\Pgm $ background             &  30\\%$\\oplus$10\\%   \\\\\nJet energy scale                                                       &   3--20\\% \\\\\n\\tauh energy scale                                                    &   1.2\\%  \\\\\\hline\n\\end{tabular}\n%\\centering\n\\begin{tablenotes}\n\\small\n\\item Note:  All of the uncertainties listed in the systematic tables are correlated between categories besides the ones after the sign $\\oplus$. These are the uncertainties correlated within each category but independent between categories. The theoretical uncertainties related to the acceptance and migration of events are listed in a range. The negative or positive values indicate anticorrelated or correlated between categories.\n\\end{tablenotes}\n%\\end{center}\n\\end{threeparttable}\n\\end{table}\n\n\n\n\\begin{table}[htpb]\n%\\begin{threeparttable}\n\\caption{PART TWO OF THE SYSTEMATIC UNCERTAINTIES CONSIDERED IN $\\Hmuhad$ ANALYSIS}\n%\\caption{Part two of the systematic uncertainties considered in $\\Hmuhad$ analysis}\n\\label{tab:systematicstwo}\n%\\centering\n\\begin{center}\n\\begin{tabular}{l*{2}{c}} \\hline\nSystematic  uncertainty                                             & $\\PH\\to\\Pgm\\tauh$ \\\\ \\hline\n\n$\\Pgm \\to\\tauh$ energy scale                                   &    1.5\\%  \\\\\n\\Pgm\\ energy scale                                                   &        0.2\\%      \\\\\nUnclustered energy scale                                         &        $\\pm 1 \\sigma$  \\\\\nRenorm./fact. scales ({\\Pg\\Pg}H)   \\cite{YR4}          &   \\multicolumn{2}{c}{3.9\\%}\\\\\nRenorm./fact. scales (VBF and VH) \\cite{YR4}         &   \\multicolumn{2}{c}{0.4\\%}\\\\\nPDF + $\\alpha_s$ ({\\Pg\\Pg}H)    \\cite{YR4}             &   \\multicolumn{2}{c}{ 3.2\\%}\\\\\nPDF + $\\alpha_s$ (VBF and VH)   \\cite{YR4}          &   \\multicolumn{2}{c}{ 2.1\\%}\\\\\nRenorm./fact. acceptance ({\\Pg\\Pg}H)                     &   \\multicolumn{2}{c}{$-3.0$\\% -- $+2.0$\\% } \\\\\nRenorm./fact. acceptance (VBF and VH)                &   \\multicolumn{2}{c}{$-0.3$\\% -- $+1.0$\\% } \\\\\nPDF + $\\alpha_s$ acceptance ({\\Pg\\Pg}H)              &   \\multicolumn{2}{c}{ $-1.5$\\% --  $+0.5$\\%}\\\\\nPDF + $\\alpha_s$ acceptance (VBF and VH)          &   \\multicolumn{2}{c}{ $-1.5$\\% --  $+1.0$\\%}\\\\\nIntegrated luminosity               &   \\multicolumn{2}{c}{ 2.5\\%  } \\\\ \\hline\n\\end{tabular}\n\\end{center}\n%\\end{threeparttable}\n\\end{table}\n\n\\begin{table}[htpb]\n\\caption{B TAGGING VETO SYSTEMATIC UNCERTAINTIES IN EACH CATEOGORY}\n%\\caption{b tagging veto systematic uncertainty in each category}\n\\label{tab:btaguncertainty}\n\\centering\n\\begin{tabular}{lclclclcl}\\hline\n                       & 0 jet    &  1 jet       & 2 jets gg-enriched & 2 jets VBF-enriched \\\\\\hline\n$t\\bar{t}$        &  \\NA    &  2.45\\%    &4.37\\%                   & 2.59\\%     \\\\   \n$t$   & \\NA     &  2.11\\%    & 3.07\\%                   & 1.98\\%   \\\\\\hline\n\\end{tabular}\n\\end{table}\n\n\n\n\n\n\n\n\\subsection{Systematic uncertainties in $\\Hehad$}\n\nThe systematic uncertainties affect the $\\Hehad$ analysis are summarized in Table.~\\ref{tab:systematics_had}, \\ref{tab:theory_systematics} and \\ref{tab:shape_systematics}, which include the ones affect the normalization scale and the ones affect the shape of $\\mcol$ distribution. The uncertainties on the electron measurements, which include the trigger, ID and isolation are estimated with the tag and probe measurement with Z boson datasets \\cite{CMS:2011aa,Khachatryan:2015dfa}. The uncertainties on the $\\PZ \\to \\tau \\tau$ process is mainly from the uncertainty on the cross section measurement~\\cite{Chatrchyan:2014mua} and the $\\tau$ identification in the embedded technique. The normalization uncertainty on $\\PZ \\to ee$ amounts to 30\\% which is the from the measurement of cross section and statistics uncertainty in the yields. An extra 5\\% shape uncertainty is added due to the mismeasured energy of the electron reconstructed as $\\Pgt$ in $\\PZ \\to \\Pe\\Pe$ background.  The shift in $\\mcol$ distribution is measured by the comparison between data and MC simulation. A 30\\% normalization uncertainty is applied to the misidentified lepton background. The extra shape uncertainties to this background are obtained by varying the parameters from fitting the misidentifed ratio in $\\pm1$ standard deviation.   The uncertainty from the pileup process is estimated by varying the total inelastic cross section by $\\pm5\\%$~\\cite{Chatrchyan:2012nj}. The uncertainty from the Diboson, single top quark background is taken from the measurement of the cross section. In $t\\bar{t}$ background, the uncertainty in 0 jet, 1 jet category are taken from the cross section measurement, in 2  jets category, an extra 33\\% uncertainty uncorrelated between categories is added due to the statistical uncertainty. The luminosity uncertainty amounts to 2.6\\%.  The jet energy scale(JES) and resolution are measured with $\\gamma/\\PZ+jets$ and dijet samples~\\cite{CMS-JME-10-011}. The uncertainty from JES is applied as a function of $\\pt$ and $\\eta$. The jet energy resolution(JER) uncertainty is obtained by smearing jets energy as a function of $\\pt$ and $\\eta$. Both JES and JER affect the shape of $\\mcol$ distribution and are taken as shape uncertainties. The energy of the jets below 10 GeV and PF objets that are not clustered are accounted as the unclustered energy scale, which is also taken as shape uncertainties. The uncertainty of $\\tau_{h}$ energy scale is obtained by comparing $\\PZ \\to \\tau\\tau$ distribution between data and MC samples and is applied as a shape uncertainty. The theoretical uncertainties considered in the $\\Hehad$ analysis are listed in Table.~\\ref{tab:theory_systematics}. There are several sources that contribute to the theoretical uncertainties and are considered fully correlated between LFV Higgs and SM Higgs production. The uncertainty in Parton distribution function is obtained by counting the yields with different PDFs,  CT10~\\cite{Nadolsky:2008zw}, MSTW~\\cite{Martin:2009iq}, NNPDF~\\cite{Ball:2010de}  from the recommendation in PDF4LHC~\\cite{Botje:2011sn}. The uncertainty in renormalization and factorization scales are from scaling up and down by a factor of two to their normal values($\\mu_{R}=\\mu_{F}=M_{H}/2$). The uncertainty in underlying events and parton shower is estimated by checking with different PYTHIA tunes. The theoretical uncertainties are all correlated or anticorrelated. The anticorrelated ones have a minus superscript and are the result of the event migration.   \n\n\n\n\n\\begin{table}[hbt]\n \\centering\n \\begin{threeparttable}\n \\caption{THE NORMALIZATION SYSTEMATIC UNCERTAINTIES CONSIDERED IN $\\Hehad$ ANALYSIS}\n% \\caption[The normalization systematic uncertainties considered in $\\Hehad$ analysis]{The normalization systematic uncertainties considered in $\\Hehad$ analysis. The uncertainties are correlated between categories besides the ones after $\\oplus$. These uncertainies are uncorrelated between categories. }\n  \\label{tab:systematics_had}\n\\begin{tabular}{lccc} \\hline\nSystematic uncertainty                  & \\multicolumn{3}{c}{\\PH$\\to \\Pe\\tauh$}      \\\\\\hline \n                                                      & 0-jet       & 1-jet        & 2-jet                 \\\\ \\hline\nElectron trigger/ID/isolation           &  1\\%           &   1\\%         &  2\\%                       \\\\\nEfficiency of $\\tauh$                      &  6.7\\%         &  6.7\\%        & 6.7\\%                      \\\\\n$\\PZ\\to \\Pgt \\Pgt$ background    & 3\\%$\\oplus$5\\% & 3\\%$\\oplus$5\\%& 3\\%$\\oplus$10\\%            \\\\\n$\\PZ\\to \\Pe\\Pe$ background                      & 30\\%           &  30\\%         & 30\\%                       \\\\\n\nMisidentified leptons background                   & 30\\%           &  30\\%         & 30\\%                       \\\\\nPileup                                           & 4\\%           & 4\\%          & 2\\%                       \\\\\n$\\PW\\PW,\\PW\\PZ,\\PZ\\PZ\\mathrm{+jets}$ background                 & 15\\%           &  15\\%         & 15\\%                       \\\\\n$\\ttbar$ background                     & 10\\%           &  10\\%         & 10\\%$\\oplus$33\\%           \\\\\nSingle top quark background       & 25\\%           &  25\\%         & 25\\%                      \\\\\nLuminosity                                    & 2.6\\%          &  2.6\\%        & 2.6\\%                      \\\\ \\hline\n\\end{tabular}\n\\begin{tablenotes}\n\\small\n\\item Note: The uncertainties are correlated between categories besides the ones after $\\oplus$. These uncertainies are uncorrelated between categories.\n\\end{tablenotes}\n\\end{threeparttable}\n\\end{table}\n\n\n\\begin{table}[hbtp]\n \\centering\n \\caption{THE SYSTEMATIC UNCERTAINTIES THAT AFFECT THE SHAPE OF $\\mcol$ DISTRIBUTION.}\n %\\caption{The systematic uncertainties that affect the shape of $\\mcol$ distribution. }\n  %\\caption{Systematic uncertainties in the shape of the signal and background distributions, expressed in percentage. The systematic uncertainty and its implementation are described in the text.}\n  \\label{tab:shape_systematics}\n  \\begin{tabular}{lclc} \\hline\nSystematic Uncertainty                                 &   $\\PH \\to \\Pe \\tauh$                   \\\\ \\hline\n$Z \\to \\Pe\\Pe$ bias                                       &   5\\%                                         \\\\\nJet energy scale                                           &    3\\%--7\\%                                       \\\\\nJet energy resolution                                    &    1\\%--10\\%                                       \\\\\nUnclustered energy scale                             &    10\\%                                       \\\\\n$\\tauh$ energy scale                                    &    3\\%                                         \\\\    \\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\\begin{table}[hbtp]\n \\caption{THEORETICAL UNCERTAINTIES CONSIDERED IN $\\Hehad$ ANALYSIS}  \\label{tab:theory_systematics}\n \\centering\n \\begin{threeparttable}\n %\\caption[Theoretical uncertainties considered in $\\Hehad$ analysis]{Theoretical uncertainties that affects the Higgs boson production cross section. These uncertainties are correlated or anticorrelated(with minus sign superscript) between all of the categories.}\n % \\caption{Theoretical uncertainties in percentage for the Higgs boson production cross section for each production process and category. All uncertainties are treated as fully correlated between categories except those denoted by a negative superscript which are fully anticorrelated due to the migration of events.}\n  \\begin{tabular}{l|l|l|l|l|l|l} \\hline\nSystematic uncertainty                  &  \\multicolumn{3}{c|}{Gluon fusion} &  \\multicolumn{3}{c}{Vector boson fusion}  \\\\ \\cline{2-7}\n                                &    0-jet  & 1-jet  & 2-jet   & 0-jet & 1-jet  & 2-jet  \\\\ \\hline\nParton distribution function         &    $9.7$\\%  &  $9.7$\\% &   $9.7$\\% & $3.6$\\%  &   $3.6$\\%  &  $3.6$\\%  \\\\\nRenormalization/factorization scale           &    $8$\\%    &  $10$\\%   &  $30^{-}$\\%   & $4$\\%     &   $1.5$\\%  & $2$\\%   \\\\\nUnderlying event/parton shower  &   $4$\\%     & $5^{-}$\\%   &  $10^{-}$\\%   & $10$\\%    &   $<$1\\%    & $1^{-}$\\%   \\\\ \\hline\n  \\end{tabular}\n  \\begin{tablenotes}\n  \\small\n  \\item Note: These uncertainties are correlated or anticorrelated(with minus sign superscript) between all of the categories.\n  \\end{tablenotes}\n  \\end{threeparttable}\n\\end{table}\n\n\n       \n\n\n\n\n", "meta": {"hexsha": "1b405e14ac05604b95e99a7fe6b8c44f3160b4e7", "size": 30462, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chapter7/chapter7.tex", "max_stars_repo_name": "fanbomeng/Thesis", "max_stars_repo_head_hexsha": "974c9f324f46d225e3f81962ca2b911505bbbbf1", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/chapter7/chapter7.tex", "max_issues_repo_name": "fanbomeng/Thesis", "max_issues_repo_head_hexsha": "974c9f324f46d225e3f81962ca2b911505bbbbf1", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/chapter7/chapter7.tex", "max_forks_repo_name": "fanbomeng/Thesis", "max_forks_repo_head_hexsha": "974c9f324f46d225e3f81962ca2b911505bbbbf1", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 100.8675496689, "max_line_length": 3524, "alphanum_fraction": 0.7013984637, "num_tokens": 8114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.44872184976297047}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{January 14 2019}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\\newtheorem{claim}{Claim}\n\n\\DeclareMathOperator{\\Int}{Int}\n\\DeclareMathOperator{\\grad}{grad}\n\\DeclareMathOperator{\\Ker}{Ker}\n\\DeclareMathOperator{\\Ima}{Im}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\mb}[1]{\\mathbf{#1}}\n\\newcommand{\\hlfspc}[0]{\\mathbb{H}}\n\\newcommand{\\loint}[0]{\\operatorname{L}\\int}\n\\newcommand{\\hiint}[0]{\\operatorname{U}\\int}\n\\newcommand{\\indic}[1]{\\chi_{#1}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Extended Definition of the Integral (``Improper Integral'')}\nSuppose that \\(A\\) is open and \\(f\\) is bounded and continuous. Then under the current definition, the expression\n\\begin{equation}\n  \\int_Af\n\\end{equation}\nmay not exist, since the boundary may not be Jordan-measurable. So today we're going to try to rectify that, by attempting to extend the definition of the integral to open subsets \\(A \\subset \\reals^n\\) and \\textit{locally} bounded functions \\(f:A \\to \\reals\\), i.e. for every point in \\(A\\), there is an open neighborhood around \\(A\\) such that \\(f\\) is bounded around \\(A\\). Furthermore, we assume the set of discontinuities is of measure zero.\n\nJust like the improper integral from first year calculus, it won't always exist. But we'll want to know the value when it does. We'll begin with a useful note: if \\(f\\) vanishes outside of a compact subset \\(C\\) of \\(A\\), then in fact \\(f\\) \\textit{is} integrable on \\(C\\) (since we can put that compact subset in a big rectangle and multiply by the characteristic function). In fact, we can say that \\(f\\) is integrable on any bounded open subset \\(U\\) of \\(A\\) containing \\(C\\), for the same reason, and\n\\begin{equation}\n  \\int_Uf = \\int_Cf\n\\end{equation}\nSo it makes sense to say\n\\begin{equation}\n  \\int_Af = \\int_Cf\n  \\label{conventioncompact}\n\\end{equation}\nThis is going to be our starting point. Now to go further, we're going to talk about a partition of unity. Let \\(\\mc{O}\\) be an open cover of \\(A\\) such that \\(U \\subset A\\) for all \\(U \\in \\mc{O}\\) and let \\(\\Phi\\) be a partitionof unity for \\(A\\) subordinate to \\(\\mc{O}\\). Note that this is the same as saying let \\(\\Phi\\) be a partition of unity for \\(A\\) subordinate to \\(\\{A\\}\\), since that counts as an open covering of \\(A\\). As in equation \\ref{conventioncompact},\nwe can define, \\(\\forall \\varphi \\in \\Phi\\),\n\\begin{equation}\n  \\int_A\\varphi|f|\n\\end{equation}\nWe can now extend the definition of the integral as follows:\n\\begin{definition}\n  \\(f\\) is \\underline{integrable} on \\(A\\) if\n  \\begin{equation}\n    \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi|f|\n    \\label{absolute}\n  \\end{equation}\n  converges. Then we define\n  \\begin{equation}\n    \\int_Af = \\sum_{\\varphi \\in \\Phi}\\varphi f\n    \\label{relative}\n  \\end{equation}\n\\end{definition}\nNote that equation \\ref{relative} must converge, and in fact converges absolutely, if equation \\ref{absolute} converges, because\n\\begin{equation}\n  \\sum_{\\varphi \\in \\Phi}\\left|\\int_A\\varphi f\\right| \\leq \\sum_{\\varphi \\in \\Phi}\\int_A|\\varphi||f| = \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n\\end{equation}\nsince \\(\\varphi\\) is nonnegative.\n\\begin{theorem}\n  Suppose \\(A \\subset \\reals\\) is open, \\(f: A \\to \\reals\\) is locally bounded and the set of discontinuities of \\(f\\) has measure 0.\n  \\begin{enumerate}\n\n    \\item Given partitions \\(\\Phi, \\Psi\\) as above, not necessarily subordinate to the same open covering, though this doesn't matter since both will be subordinate to \\(\\{A\\}\\), then if equation \\ref{absolute} converges for \\(\\Phi\\), then it converges for \\(\\Psi\\) and the integral defined using \\(\\Phi\\) and the integral defined using \\(\\Psi\\) are equal, i.e.\n    \\begin{equation}\n      \\sum_{\\psi \\in \\Psi}\\int_A\\psi f = \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n      \\label{integralequal}\n    \\end{equation}\n    Note that equation \\ref{integralequal} would not necessarily be true if equation \\ref{absolute} does not converge.\n\n    \\item The new definition of the integral \\textit{always} exists if both \\(A\\) and \\(f\\) are bounded, showing it truly generalizes the old definition. Specificially, if both \\(A\\) and \\(f\\) are bounded, whether or not the boundary of \\(A\\) has measure zero,\n    \\begin{equation}\n      \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi|f|\n    \\end{equation}\n    (equation \\ref{absolute}) converges\n\n    \\item If \\(A\\) is Jordan-measurable and \\(f\\) is bounded, then\n    \\begin{equation}\n      \\int_Af = \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n    \\end{equation}\n    where the left is as defined before.\n\n  \\end{enumerate}\n\\end{theorem}\nThere are other ways of defining the integral, some of which look more like the improper integral from first year calculus. Another thing that you could do is the following: since you can always write an open set as a kind of ``expanding union'' of compact sets \\(C_i \\subseteq C_{i + 1}\\), you can actually do that in such a way such that each \\(C_i\\) is Jordan-measurable, meaning the integral on each of these \\(C_i\\)'s exist. We could then define\n\\begin{equation}\n  \\int_Af = \\lim_{i \\to \\infty}\\int_{C_i}f\n\\end{equation}\nAfter we finish proving this theorem, either I'll prove this or stick it on the next problem set.\n\\begin{proof}\n  \\begin{enumerate}\n\n    \\item \\(\\varphi \\cdot f\\) vanishes outside a compact set, and only finitely many \\(\\psi\\) are nonzero on this set. So\n    \\begin{equation}\n      \\sum_{\\psi \\in \\Psi}\\psi = 1\n      \\implies \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n      = \\sum_{\\varphi \\in \\Phi}\\int_A\\left(\\sum_{\\psi \\in \\Psi}\\psi\\right)\\varphi f\n      = \\sum_{\\varphi \\in \\Phi}\\sum_{\\psi \\in \\Psi}\\int_A\\varphi\\psi f\n    \\end{equation}\n    A priori, we don't know that we can interchange the order in the double sum of the last equal expression, but we could write down exactly the same stuff with the absolute value in it, which tells us we can. Interchanging them, we get the desired result.\n\n    \\item Let \\(B\\) be a big rectangle containing \\(A\\), and assume \\(|f| \\leq M\\) on \\(A\\). For any finite subset \\(F\\) of \\(\\Phi\\),\n    \\begin{equation}\n      \\sum_{\\varphi \\in F}\\int_A\\varphi|f| \\leq M\\int_A\\sum_{\\varphi \\in F}\\varphi \\leq MV(B)\n    \\end{equation}\n    implying the desired result. We still have to show that in the situation that \\(\\int_Af\\) is defined according to our earlier definition, we get the same result. We'll do so next time.\n\n  \\end{enumerate}\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "1f5ae5bd4ae5e8f1ba0b123b48ed1b99dc74dbd4", "size": 7138, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/jan14.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/jan14.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/jan14.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6241134752, "max_line_length": 505, "alphanum_fraction": 0.7034183245, "num_tokens": 2214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.798186775339273, "lm_q1q2_score": 0.44872184841355117}}
{"text": "\\clearpage\n\\newpage\n\n\\section{New methods}\n\n%% Présenter le problème et la factorisation matricielle\n%%\n%%\n\nIn this section we present two new algorithms for estimating individual admixture coefficients and ancestral genotype frequencies assuming $K$ ancestral populations. In addition to genotypes, the new algorithms require individual geographic coordinates of sampled individuals.\n\n\\paragraph{$Q$ and $G$-matrices} Consider a genotypic matrix, {\\bf Y}, recording data for $n$ individuals at $L$ polymorphic loci for a $p$-ploid species (common values for $p$ are $p = 1,2$). For autosomal SNPs in a diploid organism, the genotype at locus $\\ell$  is an integer number, 0, 1 or 2, corresponding to the number of reference alleles at this locus. In our algorithms, disjunctive forms are used  to encode each genotypic value as the indicator of a heterozygote or a homozygote locus (Frichot et al. 2014). For a diploid organism each genotypic value $,0,1,2$ is encoded as $100$, $010$ and $001$. For $p$-ploid organisms, there are $(p+1)$ possible genotypic values at each locus, and each value corresponds to a unique disjunctive form. While our focus is on SNPs, the algorithms presented in this section extend to multi-allelic loci without loss of generality. \nMoreover, the method can be easily extended to genotype likelihoods by using the likelihood to encode each genotypic value~\\citep{Korneliussen2014}.\n\nOur algorithms provide statistical estimates for the matrix ${\\bf Q} \\in \\mathbb{R}^{K \\times n}$ which contains the admixture coefficients, ${\\bf Q}_{i,k}$, for each sampled individual, $i$, and each ancestral population, $k$. The algorithms also provide estimates for the matrix ${\\bf G} \\in \\mathbb{R}^{(p+1)L \\times K}$, for which the entries, ${\\bf G}_{(p+1)\\ell + j, k}$, correspond to the frequency of genotype $j$ at locus $\\ell$ in population $k$. Obviously, the $Q$ and $G$-matrices must satisfy the following set of probabilistic constraints \n\n$$\n\\quad {\\bf Q},{\\bf G} \\geq 0 \\, , \\quad  \\sum_{k=1}^K {\\bf Q}_{i,k} = 1 \\, , \\quad \\sum_{j=0}^p {\\bf G}_{(p+1)\\ell + j, k} = 1 \\, , \\quad j = 0,1,\\dots, p,\n$$\nfor all $i, k$ and $\\ell$. Using disjunctive forms and the law of total probability, estimates of {\\bf Q} and {\\bf G} can be obtained by factorizing the genotypic matrix as follows ${\\bf Y}$=${\\bf Q}\\,{\\bf G}^T$~\\citep{Frichot2014}. Thus the inference problem can be solved by using constrained nonnegative matrix factorization methods~\\citep{Lee1999, Cichocki2009}. In the sequel, we shall use the notations  $\\Delta_Q$ and $\\Delta_G$ to represent the sets of probabilistic constraints put on the {\\bf Q} and {\\bf G} matrices respectively. \n\n\n \\paragraph{Geographic weighting} Geography is introduced in the matrix factorization problem by using weights for each pair of sampled individuals. The weights impose regularity constraints on ancestry estimates over geographic space. The definition of geographic weights is based on the spatial coordinates of the sampling sites, $(x_i)$. Samples close to each other are given more weight than samples that are far apart. The computation of the weights starts with building a complete graph from the sampling sites. Then the weight matrix is defined as follows\n\n$$\nw_{ij} = \\exp( - {\\rm dist}( x_i, x_j )^2/ \\sigma^2),\n$$\n\\noindent where dist$( x_i, x_j )$ denotes the geodesic distance between sites $x_i$ and  $x_j$, and $\\sigma$ is a range parameter. Values for the range parameter can be investigated by using spatial variograms~\\citep{Cressie1993}. \nTo evaluate variograms, we extend the univariate variogram to genotypic data as follows\n\n\\begin{equation}\n\\gamma(h) = \\frac{1}{2 |N(h)|} \\sum_{i,j \\in N(h)} \\frac{1}{L} \\sum_{l = 1}^{(p+1)L} |Y_{i,l} - Y_{j,l}|,\n\\label{eq:gamma}\n\\end{equation}\n\\noindent where $N(h)$ is defined as the set of individuals separated by geographic distance $h$. \n% The function $\\gamma$ can be approximated as follows \n% \\begin{equation}\n% \\hat{\\gamma}(h) = {C}_0 \\frac{1}{2 |N(h)|} \\sum_{i,j \\in N(h)} \\| {\\bf Q}_{i,.} - {\\bf Q}_{j,.}\\|^2 + {C}_1,~~~C_0, C_1 > 0,\n% \\label{eq:gammahat}\n% \\end{equation}\n% \\noindent where $\\|  u \\|^2$ is the squared norm of the vector $u$, and ${\\bf Q}_{i,.}$ is the $i$th row of the admixture matrix ${\\bf Q}$. Arguments that justify this approximation are given in Appendix~\\ref{app:approx}. \nIn applications, computing and visualizing the $\\gamma$ function  provides useful information on the level of spatial autocorrelation between individuals in the data. \n\n\nNext, we introduce the {\\it Laplacian matrix} associated with the geographic weight matrix, {\\bf W}. The Laplacian matrix is defined as ${\\bf \\Lambda}$ = {\\bf D} $-$ {\\bf W}  where  {\\bf D} is a diagonal matrix with entries\n${\\bf D}_{i,i} = \\sum_{j = 1}^n  {\\bf W}_{i,j}$,  for  $i = 1, \\dots, n$~\\citep{Belkin2003}. Elementary matrix algebra shows that~\\citep{DengCai2011}\n\n$$\n {\\rm Tr} ({\\bf Q}^T {\\bf \\Lambda} {\\bf Q})  = \\frac12 \\sum_{i,j = 1}^n  w_{ij}  \\|   {\\bf Q}_{i,.}  - {\\bf Q}_{j,.} \\|^2 \\, .\n$$\nIn our approach, assuming that geographically close individuals are more likely to share ancestry than individuals at distant sites is thus equivalent to minimizing the quadratic form ${\\cal C}({\\bf Q}) ={\\rm Tr} ({\\bf Q}^T {\\bf \\Lambda} {\\bf Q})$ while estimating the matrix ${\\bf Q}$. \n\n\\paragraph{Least-squares optimization problems} Estimating the matrices ${\\bf Q}$ and ${\\bf G }$ from the observed genotypic matrix ${\\bf Y}$ is performed through solving an optimization problem defined as follows~\\citep{Caye2016}\n\n\\begin{equation}\n\\begin{aligned}\n& \\underset{Q, G}{\\text{min}}\n& & {\\rm LS}({\\bf Q}, {\\bf G}) =   \\|  {\\bf Y} - {\\bf QG}^T \\|^2_{\\rm F} +  \\alpha ' \\frac{(p+1)L}{K \\lambda_{\\max}} {\\cal C}({\\bf Q}) , \\\\\n& \\text{s.t.} & &  {\\bf Q} \\in \\Delta_Q , \\\\\n& & &  {\\bf G} \\in \\Delta_G . \\\\\n\\end{aligned}\n\\label{eq:LS}\n\\end{equation}\n \\noindent The notation $\\|  {\\bf M}  \\|_{\\rm F}$ denotes the Frobenius norm of a matrix, {\\bf M}. The regularization term is normalized by $(p+1)L/K \\lambda_{\\max}$, where $\\lambda_{\\max}$ is the largest eigenvalue of the Laplacian matrix. With this normalization, both terms of the optimization problem~\\eqref{eq:LS} are given the same order of magnitude. The regularization parameter $\\alpha ' $ controls the regularity of ancestry estimates over geographic space.  Large values of $\\alpha ' $ imply that ancestry coefficients have similar values for nearby individuals, whereas small values ignore spatial autocorrelation in observed allele frequencies. In the rest of the article, we will use $\\alpha ' = 1$ and $\\alpha = (p+1)L/K \\lambda_{\\max}$. Using the least-squares approach, the number of ancestral populations, $K$, can be chosen after the evaluation of a cross-validation criterion for each $K$~\\citep{Alexander2011, Frichot2014, Frichot2015}.\n\n\n\\paragraph{The Alternating Quadratic Programming (AQP) method} Because the poly\\-edrons $\\Delta_Q$ and  $\\Delta_G$ are convex sets and the LS function is convex with\nrespect to each variable ${\\bf Q}$ or ${\\bf G}$ when the other one is fixed, the problem~\\eqref{eq:LS} is amenable to the application of block coordinate descent~\\citep{Bertsekas1995}. The APQ algorithm starts from initial values for the $G$ and $Q$-matrices, and alternates two steps. The first step computes the matrix {\\bf G} while  {\\bf Q} is kept fixed, and the second step permutates the roles of {\\bf G} and {\\bf Q}.  Let us assume that {\\bf Q} is fixed and write {\\bf G} in a vectorial form, $g = {\\rm vec({\\bf G})} \\in \\mathbb{R}^{K(p + 1)L}$. The first step of the algorithm actually solves the following quadratic programming subproblem. Find  \n\n\\begin{equation}\n\\begin{aligned}\ng^\\star = \\underset{g \\in \\Delta_G}{\\arg \\min}  ( -2  v^T_Q \\, g + g^T {\\bf D}_Q g ) \\, ,  \n\\end{aligned}\n\\label{eq:AQPg}\n\\end{equation}\n\\noindent where ${\\bf D}_Q = {\\bf I}_{(p+1)L} \\otimes {\\bf Q}^T {\\bf Q}$ and $v_Q = {\\rm vec}({\\bf Q}^T {\\bf Y})$. Here, $\\otimes$ denotes the Kronecker product and ${\\bf I}_d$ is the identity matrix with $d$ dimensions. Note that the block structure of the matrix ${\\bf D}_Q$ allows us to decompose the subproblem~\\eqref{eq:AQPg} into $L$ independent quadratic programming problems with $K(p + 1)$ variables. Now, consider that {\\bf G} is the value obtained after the first step of the algorithm, and write {\\bf Q} in a vectorial form, $q = {\\rm vec({\\bf Q})} \\in \\mathbb{R}^{nK}$. The second step solves the following quadratic programming subproblem. Find\n\n\\begin{equation}\n\\begin{aligned}\nq^\\star = \\underset{q \\in \\Delta_Q}{\\arg \\min} ( -2 v^T_G \\, q + q^T {\\bf D}_G q ) \\,  ,\n\\end{aligned}\n\\label{eq:AQPq}\n\\end{equation}\n\n\\noindent where ${\\bf D}_G = {\\bf I}_{n} \\otimes {\\bf G}^T {\\bf G } + \\alpha {\\bf \\Lambda}  \\otimes {\\bf I}_K$ and $v_G = {\\rm vec}({\\bf G}^T{\\bf  Y}^T)$. Unlike subproblem~\\eqref{eq:AQPg}, subproblem~\\eqref{eq:AQPq} can not be decomposed into smaller problems. Thus, the computation of the second step of the AQP algorithm implies to solve a quadratic programming problem with $nK$ variables which can be problematic for large samples ($n$ is the sample size). \nThe AQP algorithm is described in details in Appendix~\\ref{algo:aqp}. For AQP, we have the following convergence result.\n\\begin{thm}\n\\label{th}\n\tThe AQP algorithm converges to a critical point of problem~\\eqref{eq:LS}.\n\\end{thm}\n\\begin{proof}\nThe quadratic convex functions defined in subproblems~\\eqref{eq:AQPg} and~\\eqref{eq:AQPq} have finite lower bounds. The convex sets $\\Delta_Q$ and $\\Delta_G$ are not empty sets, and they are compact sets. Thus the sequence generated by the AQP algorithm is well-defined, and has limit points.\nAccording to Corollary 2 of ~\\cite{Grippo2000}, we conclude that\nthe AQP algorithm converges to a critical point of problem~\\eqref{eq:LS}.\n\\end{proof}\n\n\\paragraph{Alternating Projected Least-Squares (APLS)} In this paragraph, we introduce an APLS estimation algorithm which approximates the solution of problem~\\eqref{eq:LS}, and reduces the complexity of the AQP algorithm. The APLS algorithm starts from initial values of the $G$ and $Q$-matrices, and alternates two steps. The matrix {\\bf G} is computed  while  {\\bf Q} is kept fixed, and {\\it vice versa}. Assume that the matrix {\\bf Q} is known. The first step of the APLS algorithm solves the following optimization problem. Find \n\n\\begin{equation}\n{\\bf G}^\\star = \\arg \\min  \\|  {\\bf Y} - {\\bf QG}^T \\|^2_{\\rm F} \\, .\n\\end{equation}\nThis operation can be done by considering $(p+1)L$ (the number of columns of ${\\bf Y}$) independent optimization problems running in parallel. The operation is followed by a projection of ${\\bf G}^\\star$ on the polyedron of constraints, $\\Delta_G$. For the second step, assume that {\\bf G} is set to the value obtained after the first step is completed. We compute the eigenvectors, {\\bf U}, of the Laplacian matrix, and we define the diagonal matrix ${\\bf \\Delta}$ formed by the eigenvalues of ${\\bf \\Lambda}$ (The eigenvalues of ${\\bf \\Lambda}$ are non-negative real numbers). According to the spectral theorem, we have\n\n$$\n{\\bf \\Lambda} = {\\bf U}^T {\\bf \\Delta} {\\bf U} \\, .\n$$\n\\noindent  After this operation, we project the data matrix {\\bf Y} on the basis of eigenvectors as follows\n\n$$\n{\\rm proj} ({\\bf Y}) = {\\bf U}{\\bf Y} \\, , \n$$\n\\noindent and, for each individual, we solve the following optimization problem\n\n\\begin{equation}\nq_i^\\star = \\arg \\min  \\|  {\\rm proj} ({\\bf Y})_i  - {\\bf G}^Tq \\|^2 + \\alpha \\lambda_i \\| q \\|^2  \\, ,\n\\label{eq:APSLq}\n\\end{equation}\n\\noindent where  proj({\\bf Y}$)_i$ is the $i$th row of the projected data matrix, proj({\\bf Y}), and $\\lambda_i$ is the $i$th eigenvalue of ${\\bf \\Lambda}$. The solutions, $q_i$, are then concatenated into a matrix, ${\\rm conc}(q)$, and ${\\bf Q}$ is defined as the projection of the matrix ${\\bf U}^T {\\rm conc}(q)$ on the polyedron $\\Delta_Q$. The complexity of step~\\eqref{eq:APSLq} grows linearly with $n$, the number of individuals. While the theoretical convergence properties of AQP algorithms are lost for APLS algorithms, the APLS algorithms are expected to be good approximations of AQP algorithms. The APLS algorithm is described in details in Appendix~\\ref{algo:apls}.\n\n\\paragraph{Comparison with {\\tt tess3}}  The algorithm implemented in a previous version of {\\tt tess3} also provides approximation of of solution of~\\eqref{eq:LS}. The {\\tt tess3} algorithm first computes a Cholesky decomposition of the Laplacian matrix. Then, by a change of variables, the least-squares problem is transformed into a sparse nonnegative matrix factorization problem~\\citep{Caye2016}.  Solving the sparse non-negative matrix factorization problem relies on the application of existing methods~\\citep{Kim2011, Frichot2014}. The methods implemented in {\\tt tess3} have an algorithmic complexity that increases linearly with the number of loci and the number of clusters. They lead to estimates that accurately reproduce those of the Monte Carlo algorithms implemented in the Bayesian method {\\tt tess} 2.3~\\citep{Caye2016}. Like for the AQP method, the {\\tt tess3} previous algorithms have an algorithmic complexity that increases quadratically with the sample size. \n\n\n\n\n\\paragraph{Ancestral population differentiation statistics and local adaptation scans} Assuming $K$ ancestral populations, the $Q$ and $G$-matrices  obtained from the AQP and from the APLS algorithms were used to compute single-locus estimates of a population differentiation statistic similar to $F_{\\rm ST}$~\\citep{Martins2016}, as follows\n\n$$\nF^{Q}_{\\rm ST} = 1 - \\sum_{k=1}^K  q_k \\frac{f_k (1-f_k)}{f(1-f)} \\, ,\n$$\n\n\\noindent where $q_k$ is the average of ancestry coefficients over sampled individuals, $q_k = \\sum_{i =1}^n q_{ik}/n$, for the cluster $k$, $f_k$ is the ancestral allele frequency in population $k$ at the locus of interest, and $f = \\sum_{k = 1}^K q_k f_k$ (Martins et al. 2016). The locus-specific statistics were used to perform statistical tests of neutrality at each locus, by comparing the observed values to their expectations from the genome-wide background. The test was based on the squared $z$-score statistic, $z^2 = (n-K) F^{Q}_{\\rm ST}/(1 - F^{Q}_{\\rm ST})$, for which a  chi-squared distribution with $K-1$ degrees of freedom was assumed under the null-hypothesis~\\citep{Martins2016}. The calibration of the null-hypothesis was achieved by using genomic control to adjust the test statistic for background levels of population structure~\\citep{Devlin1999, Francois2016}. After recalibration of the null-hypothesis, the control of the false discovery rate was achieved by using the Benjamini-Hochberg algorithm~\\citep{Benjamini1995}.\n\n\n\\paragraph{{\\tt R} package} We implemented the AQP and APLS algorithms in the {\\tt R} package {\\tt tess3r}, available from Github and submitted to the Comprehensive R Archive Network (R Core Team, 2016).  \n\n\n\\section{Simulated and real data sets}\n\\paragraph{Coalescent simulations} We used the computer program {\\tt ms} to perform coalescent simulations of neutral and outlier SNPs under spatial models of admixture~\\citep{Hudson2002}. Two ancestral populations were created from the simulation of Wright\\rq{}s two-island models. The simulated data sets contained admixed genotypes for $n$ individuals for which the admixture proportions varied continuously along a longitudinal gradient~\\citep{Durand2009, Francois2010}. In those scenarios, individuals at each extreme of the geographic range were representative of their population of origin, while individuals at the center of the range shared intermediate levels of ancestry in the two ancestral populations~\\citep{Caye2016}. For those simulations, the $Q$ matrix, ${\\bf Q}_0$, was entirely described by the location of the sampled individuals.\n\n\nNeutrally evolving ancestral chromosomal segments were generated by simulating DNA sequences with an effective  population size $N_0 = 10^6$ for each ancestral population. The mutation rate per bp and generation was set to $\\mu = 0.25 \\times 10^{-7}$, the recombination rate per generation was set to $r = 0.25 \\times 10^{-8}$, and the parameter $m$ was set to obtained neutral levels of $F_{\\rm ST}$ ranging between values of $0.005$ and $0.10$. The number of base pairs for each DNA sequence was varied between 10k to 300k to obtain numbers of polymorphic locus ranging between 1k and 200k after filtering out SNPs with minor allele frequency lower than 5$\\%$.  To create SNPs with values in the tail of the empirical distribution of $F_{\\rm ST}$,  additional ancestral chromosomal segments were generated by simulating DNA sequences with a migration rate $m_s$ lower than $m$. The simulations reproduced the reduced levels of diversity and the increased levels of differentiation expected under hard selective sweeps occurring at one particular chromosomal segment in ancestral populations~\\citep{Martins2016}.  For each simulation, the sample size  was varied in the range $n =$ 50-700.\n\n We compared the AQP and APLS algorithm estimates with those obtained with the {\\tt tess3} algorithm.  Each program was run 5 times.  Using $K = 2$ ancestral populations, we computed the root mean squared error (RMSE) between the estimated and known values of the $Q$-matrix, and between  the estimated and known values of the $G$-matrix. \nTo evaluate the benefit of spatial algorithms, we compared the statistical errors of APLS algorithms to the errors obtained with {\\tt snmf} method that reproduces the outputs of the {\\tt structure} program accurately~\\citep{Frichot2014,Frichot2015}.  To quantify the performances of neutrality tests as a function of ancestral and observed levels of $F_{\\rm ST}$, we used the area under the precision-recall curve (AUC) for several values of the selection rate.  Subsamples from a real data set were used to perform a runtime analysis of the AQP and APLS algorithms ({\\it A. thaliana} data, see below). Runtimes were evaluated by using a single computer processor unit Intel Xeon 2.0 GHz.\n\n\\paragraph{Application to European ecotypes of {\\it Arabidopsis  thaliana}} We used  the APLS algorithm to survey spatial population genetic structure and to investigate the molecular basis of adaptation  by considering SNP data from 1,095  European ecotypes of the plant species {\\it A. thaliana} (214k SNPs, \\cite{Horton2012}). The cross-validation criterion was used to evaluate the number of clusters in the sample, and a statistical analysis was performed to evaluate the range of the variogram from the data. We used {\\tt R} functions of the {\\tt tess3r} package to display interpolated admixture coefficients on a geographic map of Europe (R Core team 2016). A gene ontology enrichment analysis using the software AMIGO~\\citep{Carbon2009} was performed in order to evaluate which molecular functions and biological processes might be involved in local adaptation in Europe.\n\n\n\n\n\n\n\n", "meta": {"hexsha": "951395d48a1821873f7b5c2945a130d3cb5350ab", "size": 18859, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2Article/TESS3Article-master/Article/method.tex", "max_stars_repo_name": "cayek/Thesis", "max_stars_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2Article/TESS3Article-master/Article/method.tex", "max_issues_repo_name": "cayek/Thesis", "max_issues_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2Article/TESS3Article-master/Article/method.tex", "max_forks_repo_name": "cayek/Thesis", "max_forks_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.461038961, "max_line_length": 1190, "alphanum_fraction": 0.7388514767, "num_tokens": 5231, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.44872184436529283}}
{"text": "\\section{Reference Theory}\nThis section presents a summary of the theory behind Bayesian Dynamic Linear Models. For in-depth details, the reader should consult the following references:\\\\[4pt]\n\n\\noindent \\emph{A Kernel-based Method for Modeling Non-Harmonic Periodic Phenomena in Bayesian Dynamic Linear Models}\\\\{\\small\n            Nguyen, L.H., Gaudot, I., Shervin Khazaeli and Goulet, J.-A.\\\\\n            Frontiers in Built Environment. Vol. 5, pp8, 2019\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Nguyen_et_al_KR_BDLM_2019.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2019_Nguyen_BDLM_KR.enw}{EndNote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2019_Nguyen_BDLM_KR.bib}{BibTex}] [\\href{https://doi.org/10.3389/fbuil.2019.00008}{DOI link}] \\cite{Nguyen2019KRBDLM}\\\\[4pt]\n\n\\noindent \\emph{Uncertainty quantification for model parameters and hidden state variables in bayesian dynamic linear models}\\\\{\\small\n            Nguyen, L.H., Gaudot, I., and Goulet, J.-A.\\\\\n            Structural Control and Health Monitoring. Vol. 26, Issue 3, pp.e2136, 2019\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Nguyen_Gaudot_Goulet_MCMC_BDLM_2018.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2019_Nguyen_BDLM_UC.xml}{EndNote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2019_Nguyen_BDLM_UC.bib}{BibTex}] [\\href{https://doi.org/10.1002/stc.2309}{DOI link}] \\cite{Nguyen2018UncertaintyBDLM}\\\\[4pt]\n      \n      \\noindent \\emph{Anomaly Detection with the Switching Kalman Filter for Structural Health Monitoring}\\\\{\\small\n            Nguyen, L.H. and Goulet, J.-A.\\\\\n            Structural Control and Health Monitoring. Vol. 24, Issue 4, pp.e2136, 2018\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2017_Nguyen_and_Goulet_AD-SKF.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Nguyen_SKF_2018.xml}{Endnote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Nguyen_SKF_2018.ris}{BibTeX}] [\\href{https://doi.org/10.1002/stc.2136}{DOI link}] \\cite{Nguyen2018}\\\\[4pt]\n\n\\noindent \\emph{Structural health monitoring with dependence on non-harmonic periodic hidden covariates}\\\\{\\small\n            Nguyen, L.H. and Goulet, J.-A.\\\\\n            Engineering Structures, 166:187 Ð 194., 2018\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2018_Nguyen_et_Goulet_SHMHNHC.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2018_Nguyen_et_Goulet_HNHC.xml}{Endnote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/2018_Nguyen_et_Goulet_HNHC.bib}{BibTeX}] [\\href{https://doi.org/10.1016/j.engstruct.2018.03.080}{DOI link}] \\cite{Nguyen2018187}\\\\[4pt]\n\n\\noindent \\emph{Empirical validation of Bayesian Dynamic Linear Models in the context of Structural Health Monitoring}\\\\{\\small\n            Goulet, J.-A. and Koo, K.\\\\\n            Journal of Bridge Engineering. Vol. 23, Issue 2, pp. 05017017, 2018\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_tamar_2017.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_2018.xml}{Endnote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_2018.ris}{BibTeX}] [\\href{https://doi.org/10.1061/\\%28ASCE\\%29BE.1943-5592.0001190}{DOI link}] \\cite{Goulet2017BDLMEmprical}\\\\[4pt]\n\n\\noindent \\emph{Bayesian dynamic linear models for structural health monitoring}\\\\{\\small\n            Goulet, J.-A.\\\\\n            Structural Control and Health Monitoring. Vol. 24, Issue 12, pp.e2025, 2017\\\\}\n      [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_SHM_2017_preprint.pdf}{PDF}] [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_2017.xml}{Endnote}]  [\\href{https://www.polymtl.ca/cgm/jagoulet/Site/Papers/Goulet_BDLM_2017.ris}{BibTeX}] [\\href{https://doi.org/10.1002/stc.2035}{DOI link}] \\cite{STC:STC2035} \\\\\n\n \n\\subsection{Linear gaussian state-space model}\n\\label{SS:LGSSM}\nOpenBDLM builds on Bayesian dynamic linear models (BDLMs).\nBayesian dynamic linear models \\cite{west1999bayesian} are a class of linear gaussian state-space models which can be described from the transition and the observation equations.\nThe transition equation describes the dynamics of the system, and is formulated as\n\\begin{equation}\n  \\mathbf{x}_{t}=\\mathbf{A}_{t}\\mathbf{x}_{t-1}+\\mathbf{w}_{t},\\quad\\left\\{\n  \\begin{array}{l}\n\\mathbf{x}_{t}\\sim \\mathcal{N}(\\bm{\\mu}_{t},\\bm{\\Sigma}_{t})\\\\[4pt]\n\\mathbf{w}_{t}\\sim \\mathcal{N}(\\mathbf{0},\n\\mathbf{Q}_{t}),\n\\end{array}\\right.\n\\label{EQ:SSM_Transition}\n\\end{equation}\nwhere, for each each time $t=1, \\dots ,\\mathtt{T}$, the variables $\\mathbf{x}_{t}$ follow a Gaussian distribution with mean $\\bm{\\mu}_{t}$ and covariance matrix $\\bm{\\Sigma}_{t}$, $\\mathbf{A}_{t}$ is the transition matrix, and $\\mathbf{w}_{t}$ represents Gaussian model errors with zero mean and covariance matrix $\\mathbf{Q}_{t}$.\nThe variables $\\mathbf{x}_{t}$ are referred to as hidden states because they are not directly observed.\nThe relationship between the observations $\\mathbf{y}_{t}$ and the hidden states $\\mathbf{x}_{t}$ is given by the observation equation, such as\n\\begin{equation}\n\\mathbf{y}_{t}=\\mathbf{C}_{t}\\mathbf{x}_{t}+\\mathbf{v}_{t},\\quad\\left\\{\\begin{array}{l}\n\\mathbf{v}_{t}\\sim \\mathcal{N}(\\mathbf{0},\\mathbf{R}_{t}),\n\\end{array}\\right.\n\\label{EQ:SSM_Observation}\n\\end{equation}\nwhere $\\mathbf{C}_{t}$ is the observation matrix, and $\\mathbf{v}_{t}$ is the Gaussian measurement error with zero mean and covariance matrix $\\mathbf{R}_{t}$.\nBDLMs are capable of analyzing multiple time series simultaneously.\nIn case of dependencies between the time series, regression coefficients are added in $\\mathbf{C}_{t}$ (see Section~\\ref{S:Dependencies} and \\cite{STC:STC2035}).\nOne particularity of BDLMs is their capacity to update the current estimated state with the current observations, thus allowing to perform online state estimation for non-stationary time series.\n\n\\subsection{Kalman filter \\& UD filters}\n\\label{SS:KFUD}\nThe analytical solutions for the prediction, observation and update step are available through either the Kalman filter (KF) or the UD filter, which can be expressed in its short form as\n\\begin{equation}\n    \\begin{split}\n      (\\bm{\\mu}_{t|t},\\bm{\\Sigma}_{t|t}, \\mathcal{L}_{t}) = \\text{Filter}(\\bm{\\mu}_{t-1|t-1},\\bm{\\Sigma}_{t-1|t-1},\\mathbf{y}_{t}, \\mathbf{A}_{t},  \\mathbf{Q}_{t},   \\mathbf{C}_{t},  \\mathbf{R}_{t}),\n      \\end{split}\n\\label{EQ:KF}\n\\end{equation}\nwhere $\\mathcal{L}_{t}$ is the marginal likelihood describing the probability of observing observations $\\mathbf{y}_{t}$ at time $t$ given all the observations up to time $t-1$ \\cite{sarkka2013bayesian}. \nNote that the UD and Kalman filter are two different methods for calculating the same results. On one hand, the Kalman filter is faster and computationally simpler to implement, and on the other hand, the UD filter is more robust toward numerical instabilities.   \n\n\nThe standard Kalman filter expressed in Eq.~\\ref{EQ:KF} can process stationary, trend stationary, and acceleration stationary time series, but it is not capable of handling non-stationary time series, which is needed when it comes to anomaly detection (see \\S\\ref{S:ExampleDispAnomaly}).\nThe generalization of the Kalman Filter for non-stationary time series is found in the Switching Kalman filter (SKF) equations.\n\n\\subsection{Switching Kalman filter}\n\\label{SS:THSKF}\nWe may be interested in anomaly detection, that is, modelling and detecting the changes of regimes in the dynamics of the baseline response of the time series.\nOne way to model changing dynamics is to run in parallel a collection of ${\\mathtt{S}}$ linear models, each having their own system dynamics $\\mathbf{A}_{t}$ and $ \\mathbf{Q}_{t}$.\n%In the Switching Kalman filter (SKF) approach \\citep{Murphy1998}, a collection of $S$ linear models are run in parallel.\n%Each linear model has its own system dynamics (i.e their own $\\mathbf{A}_{t}$ and $ \\mathbf{Q}_{t}$ matrices).\nIn such approach, a discrete markovian switching variable $s_{t}= 1, ..,j,.. ,\\mathtt{S}$ with a transition probabilities matrix $\\mathbf{Z}_{t}$ and probabilities $\\bm{\\pi}_{t}$ is introduced to indicate which dynamics is used at time $t$.\nThe problem of incorporating switching dynamics into the model is that the state vector grows in a way that the dimension of the state vector at time $t$ is $\\mathtt{S}^{t}$.\nTherefore, the estimation quickly becomes intractable.\nOne solution is to merge at each time $t$ the states sharing the same dynamics using gaussian mixture.\nThis technique, known as the Switching Kalman filter, allows to keep the dimension of the state vector equal to $\\mathtt{S}$ at each time $t$ \\cite{murphy2012machine}.\nThe SKF algorithm can be divided into two successive steps, (i) the ``Filter'' and, (ii) the ``Collapse'' step.\nFollowing the notation used in Eq.~\\ref{EQ:KF} the first step can be expressed in its short form as\n\\begin{equation}\n  \\begin{split}\n  (\\bm{\\mu}_{t|t}^{i(j)},\\bm{\\Sigma}_{t|t}^{i(j)}, \\mathcal{L}_{t}^{i(j)}) = \\text{Filter}(\\bm{\\mu}_{t-1|t-1}^{i},\\bm{\\Sigma}_{t-1|t-1}^{i}, \\mathbf{y}_{t}, \\mathbf{A}_{t}^{j},  \\mathbf{Q}_{t}^{i(j)},   \\mathbf{C}^{j}_{t},  \\mathbf{R}^{j}_{t}),\n    \\end{split}\n\\label{EQ:SKF1}\n\\end{equation}\nwhere the superscripts $i(j)$ indicates that the current state at time $t$ is $s_{t}=j$ given the state at time $t-1$ is $s_{t-1}=i$, and\n$ \\mathcal{L}_{t}^{i(j)}$  the marginal likelihood that describes the probability of observing observations $\\mathbf{y}_{t}$ at time $t$ given all the observations up to time $t-1$, and given the state at time $t_1$ was $s_{t-1} = i$ and that it switches to $s_{t} = j$ at time $t$.\nThe state probability $\\mathbf{\\pi}_{t|t}^{j}$ at each time $t$ is computed from the previous state probabilities $\\bm{\\pi}_{t-1|t-1}$, the likelihood $\\mathcal{L}_{t}^{i(j)}$, and the transition probability $Z_{t}^{i(j)}$, such as\n\\begin{equation}\n\\pi_{t|t}^{j} = \\sum_{i=1}^{\\mathtt{S}} \\frac{\\mathcal{L}_{t}^{i(j)} \\pi_{t-1|t-1}^{i} Z^{i(j)}_{t} }{c},\n\\label{EQ:StateProbability}\n\\end{equation}\nwhere $c$ is a normalization constant ensuring that $ \\sum_{j=1}^{\\mathtt{S}} \\pi_{t|t}^{j} = 1 $.\nMoreover, the state switching probability is defined as\n\\begin{equation}\nW_{t-1|t}^{i(j)} = \\frac{\\mathcal{L}_{t}^{i(j)} \\pi_{t-1|t-1}^{i} Z^{i(j)}_{t} }{c\\pi_{t|t}^{j}}.\n\\label{EQ:StateSwitchingProbability}\n\\end{equation}\n$W_{t|t-1}^{i(j)}$ are required to perform the ``Collapse'' step, which can be expressed in its short form as\n\\begin{equation}\n  \\begin{split}\n  (\\bm{\\mu}_{t|t}^{j},\\bm{\\Sigma}_{t|t}^{j}) = \\text{Collapse}(\\bm{\\mu}_{t|t}^{i(j)},\\bm{\\Sigma}_{t|t}^{i(j)}, W_{t-1|t}^{i(j)} ),\n    \\end{split}\n\\label{EQ:SKF2}\n\\end{equation}\nwhere state switching probabilities $W_{t|t-1}^{i(j)}$ are used as weighting factors for the gaussian mixture.\nFrom Eq.~\\ref{EQ:SKF2}, the SKF algorithm provides a set a $\\mathtt{S}$ state vectors at each time $t$.\nHowever, for the ease of interpretation, it is generally more convenient to have a single state vector at each time $t$.\nTherefore, we hereafter introduce the ``Merge'' step.\nSimilarly to the ``Collapse'' step of the SKF algorithm, the ``Merge'' step uses the gaussian mixture technique, and it can be expressed in its short form as\n\\begin{equation}\n  \\begin{split}\n  (\\bm{\\mu}_{t|t},\\bm{\\Sigma}_{t|t}) = \\text{Merge}(\\bm{\\mu}_{t|t}^{j},\\bm{\\Sigma}_{t|t}^{j},  \\pi_{t|t}^{j} ),\n    \\end{split}\n\\label{EQ:SKFCollapse}\n\\end{equation}\nwhere the state probabilities $\\pi_{t|t}^{j}$ is used as weighting factors for the gaussian mixture \\cite{Nguyen2018}.\n\n\\subsection{Model parameter estimation}\n\\label{SS:THModelParameterEstimation}\nThe model matrices $\\left\\{\\mathbf{A}_{t}, \\mathbf{Q}_{t}, \\mathbf{C}_{t}, \\mathbf{R}_{t}\\right\\}$ contain a vector of unknown model parameters $\\bm{\\theta}$ to be learned from data $\\mathbf{y}_{1:\\mathtt{Tr}}$.\nThis section presents different methods for optimizing the vector of model parameter in OpenBDLM.\n\\subsubsection{Likelihood}\nThe likelihood is the joint prior probability density of observations, i.e. the plausibility of the available observations $\\mathbf{y}_{1:\\mathtt{Tr}}$ given a vector of model parameters $\\bm\\theta$.  \nAssuming that the observations are conditionally independent from each other, the joint likelihood function is defined as the product of the marginal likelihoods such that\n\\begin{equation}\np(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta)  = \\displaystyle\\prod_{t=1}^{\\mathtt{Tr}} p(\\mathbf{y}_{t}|\\mathbf{y}_{1:t-1},\\bm \\theta) = \\displaystyle\\prod_{t=1}^{\\mathtt{Tr}}\\prod_{j=1}^{\\mathtt{S}} \\prod_{i=1}^{\\mathtt{S}} \\mathcal{L}_{t}^{i(j)}\\cdot Z_{t}^{i(j)}\\cdot\\pi_{t-1|t-1}^{i} ,\n\\label{EQ:LP}\n\\end{equation}\nwhere $\\mathcal{L}_{t}^{i(j)}$ is defined in Equation \\ref{EQ:SKF1}, $\\mathtt{S}$ is the number of model class (see \\ref{SS:THSKF}), $Z_{t}^{i(j)}$ is the transition probability, and $\\pi_{t-1|t-1}^{i}$ the previous state probability. In order to avoid the underflow and overflow issue, the joint likelihood function presented in Equation \\ref{EQ:LP} is transformed into the nature logarithm space, so that\n\\begin{equation}\n\\ln p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta)  =  \\displaystyle\\sum_{t=1}^{\\mathtt{Tr}} \\ln \\left[ \\sum_{j=1}^{\\mathtt{S}} \\sum_{i=1}^{\\mathtt{S}} \\mathcal{L}_{t}^{i(j)}\\cdot Z_{t}^{i(j)}\\cdot\\pi_{t-1|t-1}^{i} \\right],\n\\label{EQ:LP}\n\\end{equation}\nwhere $\\ln p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta) $ is the log-likelihood function. Note that when a single regime is employed, Equation \\ref{EQ:LP} simplifies to\n\\begin{equation}\n\\ln p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta)  =  \\displaystyle\\sum_{t=1}^{\\mathtt{Tr}} \\ln  \\mathcal{L}_{t},\n\\end{equation}\n\n\n\\subsubsection{Maximum Likelihood Estimation (MLE)}\n\nThe \\emph{Maximum Likelihood Estimation} (MLE) \\cite{gelman2014bayesian} consists in finding a single vector that maximizes the log-likelihood function presented in Equation \\ref{EQ:LP},\n\\begin{equation*}\n\\bm\\theta^{*} = \\underset{\\bm\\theta}{\\text{arg}\\max}\\left[\\ln  p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta) \\right] \\text{,}\n\\end{equation*}\nwhere $\\bm\\theta^{*}$ is the optimal vector of model parameters. The optimization task can be done using the gradient-based optimization algorithm such as \\emph{gradient ascent} and \\emph{stochastic gradient ascent}  \\cite{Goodfellow-et-al-2016}.\n\n\\subsubsection{Gradient-based optimization}\nIn OpenBDLM, the gradient-based optimization method available are  the \\emph{batch gradient ascent algorithm} and \\emph{stochastic gradient ascent algorithm}.  For the purpose of simplicity, the log-likelihood function presented in Equation \\ref{EQ:LP} is denoted as $\\mathcal{T}(\\bm\\theta, \\mathbf{y}_{1:\\mathtt{Tr}})$ that is a function of a vector of model parameter $\\bm\\theta$ and a training dataset $\\mathbf{y}_{1:\\mathtt{Tr}}$.\n\n\\paragraph{Batch Gradient Ascent  (BGA)}\nThe BGA algorithm is used to maximize the log-likelihood function by updating the vector of model parameters with a small step $\\Delta_{\\bm\\theta}$ in the direction of gradient for the entire training data $\\mathbf{y}_{1:\\mathtt{Tr}}$,\n\\begin{equation}\n\\bm\\theta^{n} = \\bm\\theta^{n-1} + \\underbrace{\\eta\\cdot \\nabla\\mathcal{T}(\\bm\\theta^{n-1}, \\mathbf{y}_{1:\\mathtt{Tr}})}_{\\Delta_{\\bm\\theta}},\n\\end{equation}\nwhere $n$ corresponds the optimization loop, $\\eta$ is the learning rate to be defined by the user, and $\\nabla$ is the operator for evaluating the first derivative of the log-likelihood function. The BGA algorithm only optimizes one model parameters at a time. The parameter-wise Newton-Raphson (NR) algorithm \\cite{gelman2014bayesian} that uses both the first and second derivatives for performing the model parameter updates is implemented for the BGA. For the BGA algorithm a converged vector $\\bf{c}$ is defined following\n\\begin{equation}\n\\mathbf{c}(i) = \\left\\{\\begin{array}{lll}\n1&\\text{if} ~\\mathcal{T}(\\bm\\theta^{n}, \\mathbf{y}_{1:\\mathtt{Tr}})> \\mathcal{T}(\\bm\\theta^{n-1}, \\mathbf{y}_{1:\\mathtt{Tr}})~\\text{and}~\\left|\\tfrac{\\mathcal{T}(\\bm\\theta^{n}, \\mathbf{y}_{1:\\mathtt{Tr}})- \\mathcal{T}(\\bm\\theta^{n-1}, \\mathbf{y}_{1:\\mathtt{Tr}})}{\\mathcal{T}(\\bm\\theta^{n-1}, \\mathbf{y}_{1:\\mathtt{Tr}})}\\right|<\\tau\\\\\n0 &\\text{otherwise},\n\\end{array}\\right.\n\\end{equation}\nwhere $\\tau$ is a termination tolerance and $i$ corresponds to $i^{th}$ model parameter of $\\bm\\theta$. The convergence criteria is reached when all elements of $\\bf{c}$ are equal to $1$, or if the number of iteration reaches the maximal number of specified by the user. \n\n\n\n\\paragraph{Stochastic Gradient Ascent (SGA)}  In order to improve the computational efficiency when using large datasets, OpenBDLM employs Stochastic Gradient Ascent SGA. The SGA optimization algorithms available in OpenBDLM are : \\emph{momentum} and  \\emph{adaptive moment estimation} \\cite{Goodfellow-et-al-2016}. Instead of using a full batch dataset, the SGA algorithms employ mini-batches of the training data to update $\\bm\\theta$. The update equation is given by\n\\begin{equation}\n\\bm\\theta^{n} = \\bm\\theta^{n-1} + \\eta\\cdot \\nabla\\mathcal{T}(\\bm\\theta^{n-1}, \\mathbf{y}_{t:t+l_{\\mathtt{MB}})},\n\\end{equation}\nwhere $l_{\\mathtt{MB}}$ is the length of the mini-batch. The SGA can update the model parameters either once at time, or all at once.  An epoch  is completed when the vector of  model parameters is updated $\\mathtt{round}(\\mathtt{Tr}/ l_{\\mathtt{MB}})$ times, where $\\mathtt{round}$ provides the closest integer. In order to avoid biasing the SGA algorithm, the mini-batch is randomly selected at every update. The SGA stops when the number of epochs reach the limit specified by the user.\n\n\\paragraph{Approximation of the derivatives}\n\nIn BDLMs, the derivatives of the log-likelihood function are  approximated numerically using the central differentiation scheme, so that\n\\begin{equation}\n\\begin{array}{lcl}\n \\nabla \\mathcal{T}(\\bm\\theta(i),\\mathbf{y}_{1:\\mathtt{Tr}}) & = &\\dfrac{\\mathcal{T}(\\bm\\theta(i) + \\delta_{\\theta}, \\mathbf{y}_{1:\\mathtt{Tr}}) - \\mathcal{T}(\\bm\\theta(i) - \\delta_{\\theta}, \\mathbf{y}_{1:\\mathtt{Tr}})}{2\\delta_{\\theta}}\\\\[12pt]\n \n \\nabla \\nabla \\mathcal{T}(\\bm\\theta(i),\\mathbf{y}_{1:\\mathtt{Tr}}) & = & \\dfrac{\\mathcal{T}(\\bm\\theta(i) + \\delta_{\\theta}, \\mathbf{y}_{1:\\mathtt{Tr}}) - \\mathcal{T}(\\bm\\theta(i), \\mathbf{y}_{1:\\mathtt{Tr}}) + \\mathcal{T}(\\bm\\theta(i) - \\delta_{\\theta}, \\mathbf{y}_{1:\\mathtt{Tr}})}{\\delta_{\\theta}^{2}},\n\\label{EQ:numericaldiff}\n\\end{array}\n\\end{equation}\nwhere $\\delta_{\\theta}$ is a small perturbation to the value of the $i^{\\text{th}}$ model parameter.\n\\subsubsection{Laplace Approximation}\n\nThe MLE approach are point estimation methods which do not take into account the uncertainty in the parameter estimates $\\bm\\theta^{*}$. \nThe model parameter uncertainties can be quantified using the Laplace approximation \\cite{gelman2014bayesian} such that\n$$p(\\bm\\theta|\\mathbf{y}_{1:\\mathtt{Tr}})  \\approx  \\mathcal{N}\\left(\\bm\\theta;\\bm\\theta^{*},-\\mathbf{H}(\\bm\\theta^{*})^{-1}\\right),\n\\label{EQ: LaA}\n$$\nwhere $\\mathbf{H}(\\bm\\theta^{*})$ is the second derivative of the negative log-likelihood function evaluated at the optimal vector of model parameters $\\bm\\theta^{*}$. \n\n\\subsubsection{Model parameter space transformation}\n\\label{SS:THSpaceTransformation}\n\nIn OpenBDLM, some model parameters  are defined in a bounded interval. During the learning procedure, it may happen that new model parameters $\\bm\\theta_{\\text{new}}$ are proposed outside their valid interval.\nThose parameters must be rejected, which hinders the computational efficiency of the optimization algorithm.\nThe solution to tackle this problem proposed for OpenBDLM is to transform these bounded model parameters into an unbounded space, where the parameters lie in the interval $[ -\\infty, +\\infty ]$. The transformation is done using a function $g(.)$ so that, \n\\begin{equation}\n\\theta^{\\text{tr}} = g(\\theta) \\text{, }\\quad \\theta^{\\text{tr}} \\in [-\\infty, +\\infty ] \\text{.}\n\\end{equation}\nThe choice of the function $g(.)$ depends on the bound of $\\theta$. \nThree cases generally occur:\n\\begin{itemize}\n\\item $ \\theta \\in [-\\infty, +\\infty ]$ , $g(\\theta) = 1$, so that $\\theta^{\\text{tr}} = \\theta$ and $\\theta = \\theta^{\\text{tr}} $\n\\item $ \\theta \\in [0, +\\infty ]$, $g(\\theta) = \\ln(\\theta)$, so that $\\theta^{\\text{tr}} = \\ln(\\theta) $ and $\\theta = e^{\\theta^{\\text{tr}}} $\n\\item $ \\theta \\in [\\text{a}, \\text{b}]$, $g(\\theta) = \\text{sigmoid}(\\theta)$, so that $\\theta^{\\text{tr}} = -\\ln \\left( \\frac{b-a}{\\theta-a} - 1\\right) $, and $\\theta = \\left( \\frac{b-a}{1+e^{-\\theta^{\\text{tr}}}} + a \\right).$\n\\end{itemize}\n%For instance, the standard deviation model parameters are real numbers that lie in the $[0, +\\infty]$ interval and the logarithm transformation is used.\n%Moreover, the autoregression coefficient model parameters are real numbers that lie in the $[0, 1]$ interval, and the sigmoid transformation is used.\n\n%\\subsection{Model parameter estimation}\n%\\label{SS:THModelParameterEstimation}\n%The matrices $\\mathbf{A}_{t}$,  $\\mathbf{Q}_{t}$,   $\\mathbf{C}_{t}$ and  $\\mathbf{R}_{t}$ depend on a set of model parameters $\\bm{\\theta}$.\n%In most cases, $\\bm{\\theta}$ are unknown, and they can be learned from a training dataset $\\mathbf{y}_{1:\\mathtt{Tr}}$.\n%The procedure of learning the model parameters is hereafter referred to as model parameters estimation.\n%\\subsubsection{Maximum log A Posteriori (MAP)}\n%\n%The log a posteriori probability density function (PDF) is defined as\n%\\begin{equation}\n%%\\begin{array}{rcl}\n%\\ln p(\\bm\\theta|\\mathbf{y}_{1:\\mathtt{Tr}}) \\, \\propto \\, \\ln p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta) + \\ln p(\\bm\\theta),\n%%\\end{array}\n%\\label{EQ:BT}\n%\\end{equation} \n%where $p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta)$ is the likelihood,  $p(\\bm\\theta)$ is the prior PDF.\n%The likelihood PDF is the joint prior probability density of observations, that is, plausibility of the available observations $\\mathbf{y}_{1:\\mathtt{Tr}}$ given the parameter vector $\\bm\\theta$.  \n%Assuming that the observations errors are independent from each other, the joint log-likelihood function is defined as the sum of the marginal log-likelihoods, such as \n%\\begin{equation}\n%\\ln p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta)  = \\displaystyle\\sum_{t=1}^{\\mathtt{Tr}} \\ln p(\\mathbf{y}_{t}|\\mathbf{y}_{1:t-1},\\bm \\theta) = \\displaystyle\\sum_{t=1}^{\\mathtt{Tr}} \\ln \\left[ \\sum_{j=1}^{\\mathtt{S}} \\sum_{i=1}^{\\mathtt{S}} \\mathcal{L}_{t}^{i(j)} \\pi_{t-1|t-1}^{i} Z_{t}^{i(j)} \\right] \\text{,}\n%\\label{EQ:LP}\n%\\end{equation}\n%where $\\mathcal{L}_{t}^{i(j)}$ and  $\\pi_{t-1|t-1}^{i}$ are computed at each time $t$ from the Switching Kalman Filter; $\\mathtt{S}$ is the total number of model class, and the values of $Z_{t}^{i(j)}$ are known from the current set of model parameters.\n%The maximum log a posteriori procedure consists in identifying the point estimates by maximizing the log A Posteriori PDF, such as\n%\\begin{equation*}\n%\\bm\\theta^{*} = \\underset{\\bm\\theta}{\\text{arg}\\max}\\left[\\ln p(\\bm\\theta|\\mathbf{y}_{1:\\mathtt{Tr}}) \\right] \\text{,}\n%\\end{equation*}\n%where $\\bm\\theta^{*}$ are the optimized model parameters values.\n%\n%\\subsubsection{Maximum log Likelihood Estimation (MLE)}\n%\n%The Maximum log Likelihood Estimation (MLE) is a special case of the MAP where the prior PDF $p(\\bm\\theta)$ is assumed to be uniform \\cite{gelman2014bayesian}.\n%Therefore, the Maximum log Likelihood procedure consists in identifying the point estimates by maximizing the log likelihood PDF, such as\n%\\begin{equation*}\n%\\bm\\theta^{*} = \\underset{\\bm\\theta}{\\text{arg}\\max}\\left[\\ln  p(\\mathbf{y}_{1:\\mathtt{Tr}}|\\bm\\theta) \\right] \\text{,}\n%\\end{equation*}\n%where $\\bm\\theta^{*}$ are the optimized model parameters values.\n%\n%\n%\\subsubsection{Laplace Approximation}\n%\n%The MAP and MLE are point estimation methods which do not take into account the uncertainty in the parameter estimates $\\bm\\theta^{*}$. \n%The estimation of the uncertainties in the model parameters estimates can be addressed using the Laplace approximation \\cite{gelman2014bayesian} so that\n%$$p(\\bm\\theta|\\mathbf{y}_{1:\\mathtt{Tr}})  \\approx  \\mathcal{N}\\left(\\bm\\theta;\\bm\\theta^{*},-\\mathbf{H}(\\bm\\theta^{*})^{-1}\\right),\n%\\label{EQ: LaA}\n%$$\n%where $\\mathbf{H}(\\bm\\theta^{*})$ is the second derivative of the log a posteriori or log likelihood PDF evaluated at the optimal parameter values $\\bm\\theta^{*}$. \n%\n%\\subsubsection{Gradient-based optimization}\n%\n%The gradient-based optimizations techniques are iterative approaches which can be used to find the model parameters that correspond to the maximum of a target PDF, hereafter noted $\\mathcal{T}(\\bm{\\theta})$.\n%The function $\\mathcal{T}(\\bm{\\theta})$  is either the log a posteriori or the log likelihood PDF computed from the data.\n%One iteration of gradient based algorithm is\n%\n%\\begin{equation}\n%{\\bm\\theta}_{\\text{new}}  = {\\bm\\theta}_{\\text{old}} - \\eta \\nabla \\mathcal{T}(\\bm{\\theta}_{\\text{old}}),\n%\\label{EQ:GBA}\n%\\end{equation}\n%\n%where $\\eta$ is the learning rate, and $\\nabla$ the first derivative.\n%\n%\\paragraph{Parameter-wise Newton-Raphson}\n%\n%The parameter-wise Newton-Raphson \\cite{gelman2014bayesian} algorithm is an iterative approach which can be used to find the model parameters that correspond to the maximum of a target PDF, hereafter noted $\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm{\\theta})$.\n%The underscripts $1:\\mathtt{Tr}$ indicate that the target function is evaluated using a \\emph{training dataset} of length $\\mathtt{Tr}$.\n%%The function $\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm{\\theta})$  is either the log a posteriori or the log likelihood PDF.\n%The Newton-Raphson algorithm adaptively sets the learning rate using the second derivative and a factor noted $\\lambda$.\n%One \\emph{iteration} of the Newton-Raphson algorithm is\n%\\begin{equation}\n%{\\theta}_{\\text{new}}^{i}  = {\\theta}_{\\text{old}}^{i} - \\lambda \\frac{\\nabla \\mathcal{T}_{1:\\mathtt{Tr}}(\\bm{\\theta}_{\\text{old}}^{i}) }{  \\nabla^{2} \\mathcal{T}_{1:\\mathtt{Tr}}(\\bm{\\theta}_{\\text{old}}^{i})},\n%\\label{EQ:NR}\n%\\end{equation}\n%where $i$ is the index of the parameter being learned, $\\nabla$ the first derivative, $\\nabla^{2}$ the second derivative.\n%$\\bm{\\theta}_{\\text{old}}$ and $\\bm{\\theta}_{\\text{new}}$ are the previous and updated vector of model parameters. \n%One parameter is updated at each iteration.\n%The convergence of each model parameters is reached when the following conditions are satisfied\n%\\begin{equation}\n%\\left\\{\\begin{array}{ccc}\n%\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm\\theta^{i}_{\\text{old}}) &<&\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm\\theta^{i}_{\\text{new}})\\\\[4pt]\n%\\left|\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm\\theta^{i}_{\\text{new}}) -  \\mathcal{T}_{1:\\mathtt{Tr}}(\\bm\\theta^{i}_{\\text{old}})\\right| &\\leq& \\tau \\cdot \\left|\\mathcal{T}_{1:\\mathtt{Tr}}(\\bm\\theta^{i}_{\\text{old}})\\right|\n%\\end{array}\\right.,\n%\\label{EQ:STC}\n%\\end{equation}\n%where $\\tau$ is a termination tolerance.\n%The Newton-Raphson algorithm stops when each model parameters has reached the convergence.\n%\n%\\paragraph{Stochastic gradient}\n%\n%In the stochastic gradient technique, the target function and its derivatives are approximated at each iteration using a \\emph{mini-batch} of data of length $\\mathtt{Tb} \\ll \\mathtt{Tr}$.\n%Therefore, the target function is noted $\\mathcal{T}_{1:\\mathtt{Tb}}(\\bm{\\theta})$.\n%At each iteration, the beginning of the mini-batch is selected randomly.\n%One \\emph{epoch} consists in one pass over the full training dataset (i.e. all the training data have been seen once).\n%Therefore, one epoch is made of many iterations.\n%Note that more than one model parameters is usually updated during one epoch.\n%Several epochs are needed to reach convergence.\n%%Classical implementation of stochastic gradient algorithm includes momentum approach (e.g MMT optimizer) or adaptive learning rate (e.g. Adam optimizer) to increase the performance \\cite{Goodfellow-et-al-2016}.  \n%The convergence is reached when the following condition between two successive epochs is satisfied \n%\\begin{equation}\n%\\mathcal{T}^{\\text{epoch}} (\\bm\\theta) > \\tau  \\cdot \\mathcal{T}^{\\text{epoch-1}} (\\bm\\theta)\n%\\label{EQ:SGT}\n%\\end{equation}\n%where $0 \\le \\tau \\le 1$ is a termination tolerance.\n%Classical implementation of stochastic gradient algorithm includes momentum approach (e.g MMT optimizer) or adaptive learning rate (e.g. Adam optimizer) to increase the performance \\cite{Goodfellow-et-al-2016}.  \n%\n%\\paragraph{Approximation of the derivatives}\n%\n%In many cases, the derivatives of $\\mathcal{T}(\\bm{\\theta})$ cannot be computed analytically.\n%Therefore, the derivatives are approximated numerically using the central differentiation scheme, such as\n%\\begin{gather}\n%\\begin{aligned}\n% \\nabla \\mathcal{T}(\\bm\\theta^{i}) & = \\frac{\\partial \\mathcal{T} (\\bm\\theta) }{\\partial \\theta^{i}} \\approx \\frac{\\mathcal{T} (\\bm\\theta + \\mathbb{I}(i)\\Delta \\theta^{i} )  -  \\mathcal{T} (\\bm\\theta - \\mathbb{I}(i)\\Delta \\theta^{i} ) }{2\\Delta \\theta^{i}}  \\\\\n% \\nabla^{2} \\mathcal{T}(\\bm\\theta^{i}) & = \\frac{\\partial^{2} \\mathcal{T} (\\bm\\theta) }{\\partial^{2} \\theta^{i}} \\approx \\frac{\\mathcal{T} (\\bm\\theta + \\mathbb{I}(i)\\Delta \\theta^{i} )  -  2 \\mathcal{T} (\\bm\\theta) +  \\mathcal{T} (\\bm\\theta - \\mathbb{I}(i)\\Delta \\theta^{i} ) }{(\\Delta \\theta^{i})^{2}},\n%\\label{EQ:numericaldiff}\n%\\end{aligned}\n%\\end{gather}\n%where $\\Delta \\theta^{i}$ is a small perturbation to the value of the $i^{\\text{th}}$ model parameters and $\\mathbb{I}(i)$ is an indicator vector for which all values are equal to $0$, except the $i^{\\text{th}}$ value which is equal to one.\n%\n%\n%\\subsubsection{Model parameter space transformation}\n%\\label{SS:THSpaceTransformation}\n%\n%There are some model parameters which are defined in a bounded interval.\n%For instance, the standard deviation model parameters are real numbers that lie in the $[0, +\\infty]$ interval.\n%%The autoregression coefficient model parameters are real numbers that lie in the $[0, 1]$ interval.\n%Therefore, during the learning procedure, it may happen that new model parameters $\\bm\\theta_{\\text{new}}$ are proposed outside their valid interval.\n%Those parameters must be rejected, which strongly hinders the computational efficiency of the learning algorithm.\n%The solution employed in OpenBDLM is to transform the bounded space into an unbounded one, where the parameters lie in the interval $[ -\\infty, +\\infty ]$. The transformation is done using a function $g(.)$ so that, \n%\\begin{equation}\n%\\theta^{\\text{tr}} = g(\\theta) \\text{, }\\quad \\theta^{\\text{tr}} \\in [-\\infty, +\\infty ] \\text{.}\n%\\end{equation}\n%The choice of the function $g(.)$ depends on the bound of $\\theta$. \n%Three cases generally occur:\n%\\begin{itemize}\n%\\item $ \\theta \\in [-\\infty, +\\infty ]$ , $g(\\theta) = 1$, so that $\\theta^{\\text{tr}} = \\theta$ and $\\theta = \\theta^{\\text{tr}} $\n%\\item $ \\theta \\in [0, +\\infty ]$, $g(\\theta) = \\ln(\\theta)$, so that $\\theta^{\\text{tr}} = \\ln(\\theta) $ and $\\theta = e^{\\theta^{\\text{tr}}} $\n%\\item $ \\theta \\in [\\text{a}, \\text{b}]$, $g(\\theta) = \\text{sigmoid}(\\theta)$, so that $\\theta^{\\text{tr}} = -\\ln \\left( \\frac{b-a}{\\theta-a} - 1\\right) $, and $\\theta = \\left( \\frac{b-a}{1+e^{-\\theta^{\\text{tr}}}} + a \\right)$\n%\\end{itemize}\n%For instance, the standard deviation model parameters are real numbers that lie in the $[0, +\\infty]$ interval and the logarithm transformation is used.\n%Moreover, the autoregression coefficient model parameters are real numbers that lie in the $[0, 1]$ interval, and the sigmoid transformation is used.\n\n\\subsection{Block components}\n\\label{SS:BlockComponent}\nThe block components are pieces of the full model.\nEach block component is used to describe a given dynamics for a given time series.\nTherefore, each block component has its own transition and observation model, which are associated with some model parameters.\nEach block component can be associated with one or more hidden states variables.\n%The types of block components supported in the current OpenBDLM version are listed in the next sections.\nThe block components are then assembled to build the full model.\nThe block components associated with irreversible change in the time series belongs to the \\emph{baseline} component.\nThe other block components are associated with reversible change in the time series.\nThe \\emph{compatible} block component are needed to model switching dynamics in the baseline of the time series.\n\n\\subsubsection{Local level (baseline)}\n\nThe local level block component describes the local mean of a stationary time series (no trend and no acceleration) \\cite{STC:STC2035}. \nThe local level describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 1\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{LL}} = [x^{\\mathtt{LL}}]\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LL}}=[1]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LL}}=[1]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LL}}=[(\\sigma_{w}^{\\mathtt{LL}})^{2}]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LL}}=[\\sigma_{w}^{\\mathtt{LL}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{LL}}$ is the process noise standard deviation which can be learned from the data.\n\n\\subsubsection{Local trend (baseline)}\n\nThe local trend block component describes the local mean of a trend-stationary time series (trend and no acceleration) \\cite{STC:STC2035}. \nThe local trend describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 2\\\\\n\nHidden states vector: \n\\begin{gather*}\n \\mathbf{x}^{\\mathtt{LT}} = [x^{\\mathtt{L}}, x^{\\mathtt{LT}}]^{\\intercal}\n \\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LT}}= \\left[\\begin{array}{cc}1 &\\Delta t\\\\0&1\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LT}}=[1, 0]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LT}}= (\\sigma_{w}^{\\mathtt{LT}})^{2}\\left[\\begin{array}{cc}\\tfrac{\\Delta t^{4}}{4} &\\tfrac{\\Delta t^{3}}{2}\\\\\\tfrac{\\Delta t^{3}}{2}&\\Delta t^{2}\\end{array}\\right]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LT}}=[\\sigma_{w}^{\\mathtt{LT}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{LT}}$ is the process noise standard deviation, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n\n\n\\subsubsection{Local acceleration (baseline)}\n\nThe local acceleration block component describes the local mean of a acceleration-stationary time series \\cite{STC:STC2035}. \nIt describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 3\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{LA}} = [x^{\\mathtt{L}}, x^{\\mathtt{T}} ,  x^{\\mathtt{LA}}]^{\\intercal}\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LA}}=  \\left[\\begin{array}{ccc}1 &\\Delta t&\\Delta t^{2}\\\\0&1&\\Delta t\\\\0&0&1\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LA}}=[1, 0, 0]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LA}}=(\\sigma_{w}^{\\mathtt{LA}})^{2}\\left[\\begin{array}{ccc}\\tfrac{\\Delta t^{4}}{4} &\\tfrac{\\Delta t^{3}}{2} &\\tfrac{\\Delta t^{2}}{2}\\\\\\tfrac{\\Delta t^{3}}{2} &\\Delta t^{2}&\\Delta t\\\\\\tfrac{\\Delta t^{2}}{2}&\\Delta t&1\\end{array}\\right]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LA}}=[\\sigma_{w}^{\\mathtt{LA}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{LA}}$ is the process noise standard deviation, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n\n\n\n\\subsubsection{Local level compatible trend (baseline)}\n\nThe local level trend compatible component must be used in case of model switching between a local level model and a local trend model \\cite{Nguyen2018}.\nThe local level trend compatible block component describes the local mean of a stationary time series. \nIt describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 1\\\\\n\nHidden states vector: \n\\begin{gather*}\n \\mathbf{x}^{\\mathtt{LcT}} = [x^{\\mathtt{LL}}, x^{\\mathtt{LTc}}=0]^{\\intercal}\n \\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LcT}}= \\left[\\begin{array}{cc}1 & 0\\\\0&0\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LcT}}=[1, 0]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LcT}}=(\\sigma_{w}^{\\mathtt{LcT}})^{2}\\left[\\begin{array}{cc}1 &0\\\\0&0\\end{array}\\right]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LcT}}=[\\sigma_{w}^{\\mathtt{LcT}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{LcT}}$ is the process noise standard deviation, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n\n\\subsubsection{Local level compatible acceleration (baseline)}\n\nThe local level acceleration compatible component must be used in case of model switching between a local level model and a local acceleration model \\cite{Nguyen2018}.\nThe local level acceleration compatible block component describes the local mean of a stationary time series.\nIt describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 1\\\\\n\nHidden states vector:\n\\begin{gather*}\n \\mathbf{x}^{\\mathtt{LcA}} = [x^{\\mathtt{LL}}, x^{\\mathtt{LTc}}=0, x^{\\mathtt{LAc}}=0]^{\\intercal}\n \\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LcA}}= \\left[\\begin{array}{ccc}1&0&0\\\\0&0&0\\\\0&0&0\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LcA}}=[1, 0, 0]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LcA}}=(\\sigma_{w}^{\\mathtt{LcA}})^{2}\\left[\\begin{array}{ccc}1&0&0\\\\0&0&0\\\\0&0&0\\end{array}\\right]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LcA}}=[\\sigma_{w}^{\\mathtt{LcA}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{LcA}}$ is the process noise standard deviation, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n\n\\subsubsection{Local trend compatible acceleration (baseline)}\nThe local trend acceleration compatible component must be used in case of model switching between a local trend model and a local acceleration model \\cite{Nguyen2018}.\nThe local trend acceleration compatible block component describes the local mean of a trend-stationary time series. \nIt describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 2\\\\\nHidden states vector: \n\\begin{gather*}\n \\mathbf{x}^{\\mathtt{TcA}} = [x^{\\mathtt{L}}, x^{\\mathtt{LT}} , x^{\\mathtt{LAc}}=0]^{\\intercal}\n \\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{TcA}}= \\left[\\begin{array}{ccc}1&\\Delta t&0\\\\0&1&0\\\\0&0&0\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{TcA}}=[1, 0, 0]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{TcA}}=(\\sigma_{w}^{\\mathtt{TcA}})^{2}  \\left[\\begin{array}{ccc}\\tfrac{\\Delta t^{4}}{4} &\\tfrac{\\Delta t^{3}}{2}&0\\\\\\tfrac{\\Delta t^{3}}{2}&\\Delta t^{2}&0\\\\0&0&0\\end{array}\\right] \n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{TcA}}=[\\sigma_{w}^{\\mathtt{TcA}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{TcA}}$ is the process noise standard deviation, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n\n\n\n\\subsubsection{Periodic (Fourier form)}\n\nThe periodic (Fourier form) block component describes a periodic pattern in the time series using Fourier form \\cite{west1999bayesian,STC:STC2035}. \nThe periodic Fourier form allows modelling sine-like periodic pattern in time series.\nIt describes reversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 2\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{P}} = [x^{\\mathtt{P}_ {1}}, x^{\\mathtt{P}_{2}}]^{\\intercal}\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{P}}= \\left[\\begin{array}{cc}\\cos \\omega &\\sin \\omega\\\\-\\sin \\omega&\\cos \\omega\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{P}}=[1, 0]\n\\end{gather*}\nProcess noise covariance matrix:\n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{P}}=(\\sigma_{w}^{\\mathtt{P}})^{2}\\left[\\begin{array}{cc}1 &0\\\\0&1\\end{array}\\right]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{P}}=[\\sigma_{w}^{\\mathtt{P}}, p^{\\mathtt{P}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{P}}$ is the process noise standard deviation and $p$ the period in days, which can be learned from the data, and $\\Delta t$ is the local timestep computed from the data.\n $\\omega=\\frac{2\\pi \\Delta t}{p}$ is the angular of frequency defined from the period $p$, given in days.\n\n\n\\subsubsection{Periodic (Kernel regression form)}\\label{SSS:KR}\n\nThe periodic (Kernel regression form) block component describes a periodic pattern in the time series using periodic kernel regression  \\cite{Nguyen2019KRBDLM}. \nThe periodic Kernel regression form allows modelling form-free periodic pattern in time series.\nIt describes reversible changes.\nThe periodic kernel measures the similarity between pairs of covariates, and it is defined as\n\\begin{gather*}\nk(t_{i},t_{j})=\\exp\\left[-\\frac{2}{\\ell^2}\\sin\\left( \\pi\\frac{t_i-t_{j}}{p}\\right)^{2}\\right].\n\\end{gather*}\nThe kernel output $k(t_{i},t_{j})\\in(0,1)$ measures the similarity between two timestamps $t_{i}$ and $t_{j}$ as a function of the distance between these, as well as a function of two parameters; the period and kernel length, $\\bm{\\theta}=[p,\\ell]$.\n\\noindent\\\\\nNumber of hidden states:  $\\mathtt{L}^{\\mathtt{KR}}+1$\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{KR}} = [x^{\\mathtt{KR}}_{0}, x^{\\mathtt{KR}}_{1}, \\dots, x^{\\mathtt{KR}}_{\\mathtt{L}^{\\mathtt{KR}}}]^{\\intercal}\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{KR}}= \\left[\\begin{array}{cc}0 &\\tilde{\\bm k}^{\\mathtt{KR}}(t, \\mathbf{t}^{\\mathtt{KR}})\\\\\\mathbf{0}&\\mathbf{I}_{\\mathtt{L}^{\\mathtt{KR}}}\\end{array}\\right]\n\\end{gather*}\nProcess noise covariance matrix:\n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{KR}}=\\left[\\begin{array}{cc}(\\sigma_{w,0}^{\\mathtt{KR}})^{2} &\\mathbf{0}\\\\\\mathbf{0}&(\\sigma_{w,1}^{\\mathtt{KR}})^{2}\\cdot\\mathbf{I}_{\\mathtt{L}^{\\mathtt{KR}} }\\end{array}\\right]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{KR}}=[1, 0, \\dots, 0]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{KR}}=[ p^{\\mathtt{KR}},\\ell^{\\mathtt{KR}},  \\sigma_{w,0}^{\\mathtt{KR}}, \\sigma_{w,1}^{\\mathtt{KR}}]\n\\end{gather*}\n\n\\noindent\nIn the transition matrix, $\\tilde{\\bm k}^{\\mathtt{KR}}(t,\\mathbf{t}^{\\mathtt{KR}})$ corresponds to the normalized kernel, $k(t,\\mathbf{t}^{\\mathtt{KR}})/\\sum_{t} k(t,\\mathbf{t}^{\\mathtt{KR}})$. $\\tilde{\\bm k}^{\\mathtt{KR}}(t,\\mathbf{t}^{\\mathtt{KR}})$ is parameterized by the kernel width $\\ell^{\\mathtt{KR}}$, its period $p^{\\mathtt{KR}}$, and a vector of $\\mathtt{L}^{\\mathtt{KR}}$ timestamps $\\mathbf{t}^{\\mathtt{KR}}=[t_{1}^{\\mathtt{KR}},\\cdots,t_{\\mathtt{L}^{\\mathtt{KR}}}^{\\mathtt{KR}}]$ where each timestamp $t_{i}^{\\mathtt{KR}}$ is associated with a hidden control point value $x_{i}^{\\mathtt{KR}}$. \n$\\sigma_{w,1}^{\\mathtt{KR}}$ controls the process noise  variance of the hidden control points between successive time steps and $\\sigma_{w,0}^{\\mathtt{KR}}$ controls the time-independent process noise in the hidden predicted pattern.\n$p^{\\mathtt{KR}}$ and $\\ell^{\\mathtt{KR}}$ give the period and correlation length of the kernel.\n\n\n\\subsubsection{First order autoregressive}\n\nThe first order autoregressive component describes the time-dependent model errors (i.e the residual between the model prediction and the data) \\cite{STC:STC2035}. \nIt describes reversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 1\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{AR}} = [x^{\\mathtt{AR}}]\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{AR}}=  [\\phi^{\\mathtt{AR}}]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{AR}}=[1]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{AR}}=[(\\sigma_{w}^{\\mathtt{AR}})]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{AR}}=[\\sigma_{w}^{\\mathtt{AR}}, \\phi^{\\mathtt{AR}} ]\n\\end{gather*}\n\n\\noindent\n$\\sigma_{w}^{\\mathtt{AR}}$ is the process noise standard deviation, and $\\phi^{\\mathtt{AR}}$ the autoregressive coefficient.\n\n\\subsubsection{Local Intervention}\\label{SSS:LI}\n\nThe local intervention block component describes the discrete shifts occurring in a time series. Shifts typically happens a sensor fails; when a sensor fails, the data start to be missing (i.e. \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!NaN!) and it often takes from several weeks to several months before the sensor is replaced. When the sensor is replaced, it is in most cases re-initialized at a different initial value than the previous sensor which lead to a discrete shift in the time series, as depicted in Figure~\\ref{fig:DataSummary1}. When using a Level intervention component, the user must provide discrete timestamps where it is required to estimate the magnitude of a discrete shift in the dataset. A user can do so by specifying in the configuration file \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!data.interventions=[t_{1}, t_{2}, ... , t_{n}]!, where \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!n! is the number of interventions. \n\nThe local intervention describes irreversible changes.\\\\\n\n\\noindent\nNumber of hidden states: 1\\\\\n\nHidden states vector: \n\\begin{gather*}\n\\mathbf{x}^{\\mathtt{LI}} = [x^{\\mathtt{LI}}]\n\\end{gather*}\nTransition matrix: \n\\begin{gather*}\n\\mathbf{A}^{\\mathtt{LI}}=[1]\n\\end{gather*}\nObservation matrix: \n\\begin{gather*}\n\\mathbf{C}^{\\mathtt{LI}}=[1]\n\\end{gather*}\nProcess noise covariance matrix: \n\\begin{gather*}\n\\mathbf{Q}^{\\mathtt{LI}}=[(\\sigma_{w}^{\\mathtt{LI}})^{2}]\n\\end{gather*}\nModel parameters: \n\\begin{gather*}\n\\bm\\theta^{\\mathtt{LI}}=[\\mu_{b}^{\\mathtt{LI}}, \\sigma_{b}^{\\mathtt{LI}} ]\n\\end{gather*}\n\\noindent\n$\\sigma_{w}^{\\mathtt{LI}}$ is the standard deviation describing the uncertainty associated with the magnitude of the shift and $\\mu_{b}^{\\mathtt{LI}}$ is its expected magnitude;  Both parameters can be kept to their default values or be learned from the data.\n\nFor the Local intervention component, the Equation \\ref{EQ:SSM_Transition} is modified to include an additional  intervention term $b_{t}$\n\\begin{equation}\n  \\mathbf{x}_{t}^{\\mathtt{LI}}=\\mathbf{A}_{t}^{\\mathtt{LI}}\\mathbf{x}_{t-1}^{\\mathtt{LI}}+{w}_{t}^{\\mathtt{LI}}+b_{t}^{\\mathtt{LI}},\\quad\\left\\{\n  \\begin{array}{l}\n{w}_{t}^{\\mathtt{LI}}\\sim \\mathcal{N}({0},\n\\mathbf{Q}_{t}^{\\mathtt{LI}})\\\\[4pt]\nb_{t}^{\\mathtt{LI}}\\sim\\mathcal{N}(\\mu_{b}^{\\mathtt{LI}},\n\\sigma_{b}^{\\mathtt{LI}})\n\\end{array}\\right.\n\\end{equation}\nThe local Intervention component allows estimating the shifts $\\mathbf{x}_{t|t}^{\\mathtt{LI}}$ caused by the interventions for which the discrete timestamps are specified in \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!data.interventions!. \n\n\n\n\\subsection{Handling non-uniform time vector and missing data}\n\\label{SS:HandlingNonUniformMissingData}\n\n\\subsubsection{Non-uniform time vector}\n\\label{SS:NonUniform}\n\nNon uniform time vector occurs when the time between two successive data measurements (i.e. the timestep) varies with time.\nIn order to accommodate non-uniform time vector, OpenBDLM employs an approximate method which is based on a reference time step $\\Delta t^{\\text{ref}} $ \\cite{STC:STC2035}. \nThe reference time-step is a value corresponding to the most frequent time step in the time series.\nAll parameter values in the parameter set $\\bm \\theta$ are estimated for the reference time step. \nTherefore, for local time step $\\Delta t$ different than the reference timestep $\\Delta t^{\\text{ref}} $, the parameters value must be adapted accordingly.\nAs an approximation, the model error standard deviations  $\\sigma_{w}$ in $\\mathbf{Q}_{t}$ are scaled proportionally to the ratio between the current time step and the reference time step so that,\n\\begin{gather*}\n\\sigma_{w}^{\\Delta t}= \\sigma_{w}^{\\Delta t ^{\\text{ref}}}\\frac{\\Delta t}{\\Delta t ^{\\text{ref}}}.\n\\end{gather*}\nTherefore, the amount of process noise in the prediction model increases as the local time step increase with respect to the reference time step.\n\nThe transition matrix $\\mathbf{A}^{\\mathtt{AR}}$ contains the autoregressive coefficients $\\phi^{\\mathtt{AR}}$ that are recursively multiplied with the hidden state at each time step. \nTo account for time step changes, the autoregressive coefficients are elevated to the power of the ratio between the current time step and the reference time step, such as\n\\begin{gather*}\n\\phi^{\\mathtt{AR}, \\Delta t}=  (\\phi^{\\mathtt{AR}, \\Delta t ^{\\text{ref}}})^{\\frac{\\Delta t}{\\Delta t ^{\\text{ref}}}}.\n\\end{gather*}\nTherefore, the autocorrelation between successive data samples in the autoregressive prediction model decreases as the local time step increase with respect to the reference time step.\nNote that this procedure is an approximation.\n\\subsubsection{Missing data (NaN)}\n\nThe presence of missing data (\\lstinline[basicstyle = \\mlttfamily \\small ]!NaN!) for specific timestamps prevents the completion of the Kalman update-step \\cite{STC:STC2035}.\nHowever, the prediction step using the current transition model can be done.\n%No update is performed at times associated with missing data (NaN), and only the prediction step is performed.\nTherefore, BDLM automatically fills gaps when data are missing using the transition model in the prediction step.\n\n\n\\subsection{Dependencies between time series}\n\\label{S:Dependencies}\nThe dependencies between time series are handled by adding regression coefficients $\\phi^{i|j}$ in the observation matrix (See \\S\\ref{S:ExampleDispTemp}).\nFor a dataset with $\\mathtt{D}$ time series, the observation matrix is\n\\begin{equation*}\n\\mathbf{C}=\\left[\\begin{array}{cccccc}\n\\mathbf{C}^{1}& \\mathbf{C}_{1,2}^{c}&\\cdots & \\mathbf{C}_{1,j}^{c}&\\cdots& \\mathbf{C}_{1,\\mathtt{D}}^{c}\\\\\n\\mathbf{C}_{2,1}^{c}& \\mathbf{C}^{2}&\\cdots& \\mathbf{C}_{2,j}^{c}&\\cdots& \\mathbf{C}_{2,\\mathtt{D}}^{c}\\\\\n\\vdots&\\vdots& \\vdots& \\vdots& \\ddots& \\vdots\\\\\n\\mathbf{C}_{i,1}^{c}& \\mathbf{C}_{i,2}^{c}&\\cdots&\\mathbf{C}_{i,j}^{c}&\\cdots&\\mathbf{C}_{i,\\mathtt{D}}^{c}\\\\\n\\vdots&\\vdots& \\vdots& \\vdots& \\ddots& \\vdots\\\\\n\\mathbf{C}_{\\mathtt{D},1}^{c}& \\mathbf{C}_{\\mathtt{D},2}^{c}&\\cdots& \\mathbf{C}_{\\mathtt{D},j}^{c}&\\cdots& \\mathbf{C}^{\\mathtt{D}}\n\\end{array}\\right] \\text{.}\n\\end{equation*}\nThe dependence matrix is a matrix with $0$ and $1$ which is used to indicate which time series have dependencies between each others, such as \n\n\\begin{equation*}\n\\mathbf{D}=\\left[\\begin{array}{cccccc}\n1&d_{1,2}&\\cdots&d_{1,j}&\\cdots&d_{1,\\mathtt{D}}\\\\\nd_{2,1}&1&\\cdots&d_{2,j}&\\cdots&d_{2,\\mathtt{D}}\\\\\n\\vdots&\\vdots&\\vdots&\\vdots&\\ddots&\\vdots\\\\\nd_{i,1}&d_{i,2}&\\cdots&1&\\cdots&d_{i,\\mathtt{D}}\\\\\n\\vdots&\\vdots&\\vdots&\\vdots&\\ddots&\\vdots\\\\\nd_{\\mathtt{D},1}&d_{\\mathtt{D},2}&\\cdots&d_{\\mathtt{D},j}&\\cdots&1\\\\\n\\end{array}\\right] \\text{.}\n\\end{equation*}\nThen, \n\\begin{itemize}\n\\item if $d_{i,j}=0$, $\\mathbf{C}_{i,j}^{c}=[\\mathbf{0}]$\n\\item if $d_{i,j}=1$, $\\mathbf{C}_{i,j}^{c}=\\left[\\phi^{i|j}_{1},\\phi^{i|j}_{2},\\cdots,\\phi^{i|j}_{k_{j}}\\right]$ where $k_{j}$ is the number of hidden states associated with the $j^{th}$ time series.\n\\end{itemize}\nThe regression coefficient $\\phi^{i|j}_{k}$ gives the linear dependence between the $k^{th}$ hidden states of the $j^{th}$ time series and the $i^{th}$ time series.\nIn OpenBDLM, a dependence model between time series assigns regression coefficient for the observed hidden states associated with block component describing reversible behavior (periodic and autoregressive patterns).\n", "meta": {"hexsha": "554062952957200aada131a23f80093ccfb7b16d", "size": 52021, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pdf_doc/section/OpenBDLMReferenceTheory.tex", "max_stars_repo_name": "CivML-PolyMtl/OpenBDLM", "max_stars_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-19T23:42:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T17:32:11.000Z", "max_issues_repo_path": "doc/pdf_doc/section/OpenBDLMReferenceTheory.tex", "max_issues_repo_name": "bhargobdeka/OpenBDLM", "max_issues_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pdf_doc/section/OpenBDLMReferenceTheory.tex", "max_forks_repo_name": "bhargobdeka/OpenBDLM", "max_forks_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-10-18T07:18:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:26:06.000Z", "avg_line_length": 65.6002522068, "max_line_length": 1063, "alphanum_fraction": 0.7138271083, "num_tokens": 16635, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4486922558828452}}
{"text": "% 20YangMillsFields.tex\n\n\\subsection{20.1. Noether's Theorem for Internal Symmetries }\n\n\\begin{quote}\n\\emph{How do symmetries yield conservation laws?}\n\\end{quote}\n\n$\\phi$ $N$-tuple $\\phi^a(t,\\mathbf{x}) = \\phi^a(x)$, local representation of a section of some vector bundle $E$, \n\n\\begin{tikzpicture}\n  \\matrix (m) [matrix of math nodes, row sep=2em, column sep=3em, minimum width=1em]\n  {    \n    E  &   \\\\     \n    M &    \\\\ };\n  \\path[->]  (m-1-1) edge node [auto] {$\\pi$} (m-2-1);\n\\end{tikzpicture}\n\n%\\begin{tikzpicture}\n%  \\matrix (m) [matrix of math nodes, row sep=2em, column sep=3em, minimum width=1em]\n%  {\n%    U_i \\subset \\mathbb{R}^{n+1} - 0 &  \\\\\n%    V_i \\subset \\mathbb{R}P^n  & \\mathbb{R}^n  \\\\ };\n%  \\path[-stealth]\n%  (m-1-1) edge node [right] {$\\varphi_i \\pi$} (m-2-2)\n%  edge node [left] { $\\pi$} (m-2-1)\n%  (m-2-1) edge node [below] {$\\varphi$} (m-2-2);\n%\\end{tikzpicture}\n\nIn the case of a Dirac electorn, we have seen that $E$ is the bundle of complex 4-component Dirac spinors over a perhaps curved spacetime. If $E$ is not a trivial bundle (or if we insist on using curvilinear coordinates) we shall have to deal with the fact that $\\partial_j \\phi^a$ do not form a tensor.  \n\n\\subsubsection{ 20.1a. The Tensorial Nature of Lagrange's Equations }\n\nLet $M^{n+1}$ (pseudo-) Riemannian manifold, let $E$ vector bundle over $M$; for definiteness, let fiber be $\\mathbb{R}^N$. \\\\\nsection of this bundle over $U \\subset M$ is described by $N$ real-valued functions $\\lbrace \\phi^a_U \\rbrace$, \\\\\n\\quad where $\\phi_V = c_{VU}\\phi_U$ and \\\\\n\\quad \\quad $c_{VU}(x)$ is $N\\times N$ transition matrix function, $c^a_{VUb}$.   \\\\\n\nnotation $\\begin{gathered} \\quad \\\\\n  \\lbrace \\Phi^a \\rbrace \\\\ \n  \\lbrace \\Phi^a_{\\alpha} \\rbrace \\\\\n\\Phi^a_{\\alpha} = \\tau_{\\alpha \\beta} \\Phi_{\\beta} \\end{gathered}$ \\\\\n\nLagrangian $L_0(x, \\phi, \\phi_x) \\equiv L_0(x,\\Phi, \\partial_j \\Phi^a)$\n\n\n\n\\subsection{20.2. Weyl's Gauge Invariance Revisited}\n\n\\subsubsection{ 20.2a. The Dirac Lagrangian }\n\n\\subsubsection{ 20.2b. Weyl's Gauge Invariance Revisited}\n\n\\subsubsection{ 20.2c. The Electromagnetic Lagrangian }\n\nInstead of considering a change of (spacetime) coordinates $x$, we shall look at a change of the \\emph{field} (fiber) coordinate $\\psi$, i.e. \\emph{a gauge transformation}.  \n\nSince the phase of $\\psi$ is not measurable, we \\emph{should} be able to have invariance under a \\emph{local} gauge transformation, where $\\alpha = \\alpha(x)$ varies with the spacetime point $x$!  \\\\\n\\quad Clearly the Dirac equation and Lagrangian are \\emph{not} invariant under such a substitution because of the appearance of terms involving $d\\alpha$.  \\\\\n\\quad It must be that \\emph{there is some background field that is interacting with the electron}.  This background field will manifest itself through the appearance of the connection.  \n\n\n\n\n\n\n\\subsection{ The Yang-Mills Nucleon }\n\n\\begin{quote}\n  How did the groups $SU(2)$ and $SU(3)$ appear in particle physics?\n\\end{quote}\n\n\n\n\\subsubsection{ 20.3a. The Heisenberg Nucleon }\n\n\\subsubsection{ 20.3b. The Yang-Mills Nucleon }\n\n\\subsubsection{ 20.3c. A Remark on Terminology }\n\nWe have related the connection matrices $\\omega$ to the gauge potentials $A$ by \n\\[\n\\omega = -i q A\n\\]\n$q$ is called a generalized \\textbf{charge}.  \n\n\n\n\n", "meta": {"hexsha": "c46508bc3c70071f8c58f99c3491c3d9294e62e4", "size": 3276, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX_and_pdfs/the geometry of physics problems/20YangMillsFields.tex", "max_stars_repo_name": "wacfeldwang333/mathphysics", "max_stars_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2017-01-10T14:24:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:19:23.000Z", "max_issues_repo_path": "LaTeX_and_pdfs/the geometry of physics problems/20YangMillsFields.tex", "max_issues_repo_name": "wacfeldwang333/mathphysics", "max_issues_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2017-09-29T09:29:53.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T03:12:29.000Z", "max_forks_repo_path": "LaTeX_and_pdfs/the geometry of physics problems/20YangMillsFields.tex", "max_forks_repo_name": "wacfeldwang333/mathphysics", "max_forks_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 25, "max_forks_repo_forks_event_min_datetime": "2018-01-21T05:33:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T20:15:13.000Z", "avg_line_length": 36.4, "max_line_length": 305, "alphanum_fraction": 0.6840659341, "num_tokens": 1090, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.44869224235349775}}
{"text": "%% ----------------------------------------------------------------\n%% Chapter 2: Theoretical background\n%% ----------------------------------------------------------------\n%!TeX root = subfile\n\\label{chapter:theoretical_background}\n\\documentclass[../main.tex]{subfiles}\n% ----------------------------------------------------------------\n\\begin{document}\n\n\\vspace{0.25cm}\nThis chapter comprises high-level theoretical background in incompressible fluid flow and its numerical solution.\nThe incompressible flow dynamics is first presented yielding the governing system of equations.\nThe numerical method providing an approximate solution of the equation system is also explained as implemented in our in-house code, ``Lotus''.\nA finite-volume method is employed to spatially discretise the system domain.\nThe flux-limited quadratic upstream interpolation for convective kinematics (QUICK) scheme numerically approximates the convective term of the momentum equations, which also serves as an implicit model for the subgrid scale (SGS) structures of the flow.\nA central-difference scheme is used for the viscous term.\nA predictor-corrector scheme integrates the numerical solution in time.\nThe boundary data immersion method is applied to account for solid boundaries.\nFinally, a multigrid method is employed to iteratively solve the pressure-Poisson equation and enforce the continuity condition in the velocity field.\n\n\\section{Governing equations of incompressible fluid flow}\n\nIncompressible fluid flow is governed by the conservation of mass and momentum, respectively the continuity equation and the Navier--Stokes momentum equations\n\\begin{gather}\n\\nabla\\cdot\\vect{u}=0,\\label{eq:div_u}\\\\\n\\pd{\\vect{u}}{t}+\\pars{\\vect{u}\\cdot\\nabla}\\vect{u}=-\\nabla p+\\nu\\nabla^2\\vect{u},\\label{eq:n-s}\n\\end{gather}\nwhere $\\vect{u}\\left(\\vect{x}, t\\right) = \\left(u, v, w\\right)$ is the velocity vector field, $p\\left(\\vect{x}, t\\right)$ is the pressure field, $t$ is the time, and $\\vect{x}=\\left(x,y,z\\right)$ is the spatial vector.\nThe coupling of pressure and velocity arises from an additional relationship obtained by taking the divergence of the momentum equations, namely the pressure-Poisson equation\n\\begin{gather}\n\\nabla\\cdot\\pars{\\pd{\\vect{u}}{t}+\\pars{\\vect{u}\\cdot\\nabla}\\vect{u}=-\\nabla p+\\nu\\nabla^2\\vect{u}},\\\\\n\\nabla^2 p = \\nabla\\cdot\\pars{\\vect{h}-\\pd{\\vect{u}}{t}},\\label{eq:ppe}\n\\end{gather}\nwhere $\\vect{h}$ is the force combining convective and viscous terms.\n\nThe system of equations is bounded by case-dependant initial and boundary conditions of the system variables.\nImportantly, the boundary condition with solid domains is the velocity no-slip condition, i.e. $\\vect{u}_b=0$, which yields the flow boundary layer.\n\nThe Reynolds number is the non-dimensional parameter describing the ratio between convective and viscous forces,\n\\begin{equation}\nRe=\\frac{\\rho U L}{\\mu},\n\\end{equation}\nwhere $\\rho$ is the fluid density (assumed constant for incompressible flows), $\\mu$ is the dynamic fluid viscosity, and $L$ and $U$ are the characteristic length and velocity of the system, respectively.\nThe Reynolds number defines the scales of motion of the flow.\nWhen the convective forces are much greater than the viscous forces, turbulence develops.\nThe definition of turbulence is not straight forward, but (loosely) it can be thought as the turning point where the fluid dynamics transitions from ordered to \\textit{chaotic} as a result of the nonlinear convective term.\nStill, physical laws revealing certain order within the turbulence dynamics have been found in the past.\nIn particular, it is known that 3-D systems present a constant rate of kinetic energy transfer within a certain range of scales, from large to small structures, a.k.a. direct energy cascade \\citep{Richardson1922,Kolmogorov1941}.\nSimilarly, a constant rate is also found in 2-D systems although energy is inversely transfered from small to large scales, a.k.a. inverse energy cascade \\citep{Kraichnan1967,Leith1968,Batchelor1969}.\nSuch different dynamics will be subject of investigation in the following chapters.\n\n\\section{Numerical methods}\n\\label{sec:lotus}\n\n\\subsection{Spatial discretisation}\n\nThe governing equations comprising \\eref{eq:div_u}, \\eref{eq:n-s}, and \\eref{eq:ppe} are spatially discretised in a structured rectilinear grid using a finite-volume method.\nThis grid facilitates the implementation of the immersed boundary method accounting for solid boundary conditions, as described in \\sref{sec:bdim}.\nThe flow variables, pressure and velocity, are staggered: the pressure scalar field is stored in the cell centre and the velocity vector field is defined at the cell faces, as displayed in \\fref{fig:grid}.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=0.4\\linewidth]{chapter2/staggered_grid}\n\\caption{Staggered grid.\nThe control volume for the pressure is defined in blue.\nThe control volume for the $u$ velocity component is defined in green.}\n\\label{fig:grid}\n\\end{figure}\n\nThe convective term of the momentum equations is numerically approximated using a flux-limited QUICK scheme.\nThis scheme interpolates the quantity of interest at the control volume face through a weighted quadratic function fitted with one upstream and two downstream points \\citep{Leonard1979}.\nThe spatial derivative is then approximated using the numerical fluxes given by the cell-face values as defined by the finite-volume approach.\n\n\\subsection{Implicit modelling}\n\nAs previously exposed, high-Reynolds flows need to be sufficiently discretised in space and time to fully resolve all scales of motion.\nThe spatial SGS need to be modelled when the grid is not fine enough.\nIn this sense, we employ an implicit LES (iLES) model, in which the dissipative effect of the SGS is accounted by the numerical dissipation intrinsic in the discretisation scheme of the convective term (the QUICK scheme in the present solver).\n\nImportantly, the instantaneous kinetic energy $(E)$ dissipation rate $(\\epsilon)$\n\\begin{equation}\n\\dd{E}{t}=-\\epsilon\n\\end{equation}\nneeds to match the natural dissipation mechanism of the flow.\nThis balance can be used to compute the iLES effective Reynolds number (or effective kinematic viscosity, $\\nu_e$), which can be found through the following evaluation \\citep{Domaradzki2003,Aspden2008,Zhou2014}\n\\begin{equation}\n\\dd{}{t}\\int_\\Omega\\frac{1}{2}|\\vect{u}|^2\\,\\mathrm{d}\\Omega=-2\\nu\\int_\\Omega S_{ij}S_{ij}\\,\\mathrm{d}\\Omega,\\label{eq:iles}\n\\end{equation}\nwhere $S_{ij}$ is the velocity rate-of-strain tensor.\nNote that the RHS is the energy dissipation term for incompressible flow arising naturally in the energy transport equation (formally derived from a dot product of the Navier--Stokes momentum equations and the velocity vector field) since \\citep[p. 17]{Doering1995}\n\\begin{equation}\n\\frac{1}{2}\\int_\\Omega||\\nabla\\vect{u}||^2\\,\\mathrm{d}\\Omega=\\frac{1}{2}\\int_\\Omega|\\boldsymbol{\\omega}|^2\\,\\mathrm{d}\\Omega\\equiv Z,\n\\end{equation}\nwhere $\\boldsymbol\\omega=\\nabla\\times\\vect{u}$ is the vorticity vector field, $Z$ is the enstrophy, and $||\\cdot||$ denotes the tensor Frobenius norm.\n\nUsing \\eref{eq:iles}, the iLES effective viscosity is computed as\n\\begin{equation}\n\\nu_e=\\frac{\\avg{\\epsilon}_{\\scaleto{\\Omega}{5pt}}}{2\\avg{S_{ij}S_{ij}}_{\\scaleto{\\Omega}{5pt}}},\n\\end{equation}\nwhere $\\avg{\\cdot}_{\\scaleto{\\Omega}{5pt}}$ denotes a volume average.\n\\cite{Hendrickson2019} verified the present in-house solver by monitoring the grid-scaled effective viscosity $\\nu_e\\Delta^{-1}$ for the Taylor--Green vortex case.\nIt was shown that the QUICK scheme linearly scales the effective viscosity with $\\Delta$.\n\n\\subsection{Temporal discretisation}\n\nThe temporal evolution of the system of equations (\\eref{eq:div_u}, \\eref{eq:n-s} and \\eref{eq:ppe}) is discretised using Chorin's projection method \\citep{Chorin1967,Chorin1968}.\nIn short, the Navier--Stokes operator is split in two parts\n\\begin{gather}\n\\frac{\\vect{u}^*-\\vect{u}^n}{\\delta t}=\\nu\\nabla^2\\vect{u}^n-\\pars{\\vect{u}^n\\cdot\\nabla}\\vect{u}^n,\\\\\n\\frac{\\vect{u}^{n+1}-\\vect{u}^*}{\\delta t}=-\\nabla p^{n+1},\n\\end{gather}\nwhere the superscript $(\\cdot)^n$ refers to the time step level and the intermediate velocity field is noted with the superscript $(\\cdot)^*$.\nThe computation of a non-solenoidal intermediate velocity field allows to decouple the velocity and pressure equations.\nIn this way, a solenoidal velocity field $\\vect{u}^{n+1}$ can be obtained by enforcing the continuity condition into the $p^{n+1}$ pressure-Poisson equation.\nOtherwise, using $p^{n}$ to compute $\\vect{u}^{n+1}$ would not enforce the velocity field to be divergence-free at the next time step.\n\nThe projection method is implemented in a predictor-corrector algorithm.\nNext, we note $\\vect{h}(\\vect{u})=\\nu\\nabla^2\\vect{u}-\\pars{\\vect{u}\\cdot\\nabla}\\vect{u}$, and $\\vect{h}^n=\\vect{h}(\\vect{u}^n$).\nThe $(\\cdot)^s$ superscript refers to a solenoidal field.\nWith this, the predictor-corrector algorithm is implemented in two steps as follows\n\n\\begin{align}\n\\mathrm{Pred}&\\mathrm{ictor\\,\\,step:}\\nonumber\\\\\n&1.\\qquad \\vect{u}^* = \\vect{u}^n+\\vect{h}^n\\delta t,\\\\\n&2.\\qquad {\\delta t}\\,\\nabla^2p^*=\\nabla\\cdot\\vect{u}^*,\\label{eq:ppe1}\\\\\n&3.\\qquad \\vect{u}^{*,s}=\\vect{u}^*-\\delta t\\nabla p^*.\n\\nonumber\\\\\n\\nonumber\\\\\n\\mathrm{Corr}&\\mathrm{ector\\,\\,step:}\\nonumber\\\\\n&4.\\qquad \\vect{u}^{*} = \\vect{u}^n+\\frac{1}{2}\\pars{\\vect{h}^n+\\vect{h}^{*,s}}\\delta t,\\\\\n&5.\\qquad {\\delta t}\\,\\nabla^2p^{n+1}=\\nabla\\cdot\\vect{u}^{*},\\label{eq:ppe2}\\\\\n&6.\\qquad \\vect{u}^{n+1}=\\vect{u}^{*}-\\delta t\\nabla p^{n+1}.\n\\end{align}\n\nNote that the divergence-free constraint for both $\\vect{u}^n$ and $\\vect{u}^{n+1}$ has been considered.\nAlso note that the forward Euler time stepping scheme is implemented in the predictor step to compute the intermediate velocity field $\\vect{u}^{*}$, finally projected into a solenoidal field by the pressure-Poisson equation yielding $\\vect{u}^{*,s}$.\nWith this, the trapezoidal quadrature can be employed in the corrector step to integrate the solution from time $n$ to $n+1$, as described in step 4.\nThe solution is again projected into a divergence-free field by solving the pressure-Poisson equation for $p^{n+1}$ (step 5) and correcting the velocity field with the new pressure field (step 6) yielding $\\vect{u}^{n+1}$.\n\nThe advantage of this method is that it exploits the benefits of both explicit and implicit time-marching schemes: it combines the natural stability of implicit schemes with the low memory requirements of explicit schemes.\nIt can be shown that the predictor-corrector algorithm is second-order accurate in time.\nThe reader is referred to \\cite{Ferziger2002} for further details.\n\nThe time discretisation method is bounded to the limitation of the time step size $(\\delta t)$.\nFor this, the local Courant number $(u\\,\\delta t/\\delta x)$ and Péclet number $(\\nu\\,\\delta t/(\\delta x)^2)$ are evaluated at every time step yielding an adaptive step size.\nThese dimensionless parameters quantify the characteristic convection time and characteristic diffusivity time of the flow, respectively.\nA combination of both yields to a time step size limit (for  one-dimensional flow) of\n\\begin{equation}\n\\delta t<\\left[\\frac{2\\nu}{\\min\\left[(\\delta x)^2\\right]}+\\max\\pars{\\frac{u}{\\delta x}}\\right]^{-1}.\n\\end{equation}\n\n\n\\subsection{Solid boundaries} \\label{sec:bdim}\n\nThe velocity no-slip condition at solid boundaries is implemented using the boundary data immersion method (BDIM) from \\cite{Weymouth2011}.\nImmersed boundary (IB) methods, such as BDIM, take into account the solid wall effect in a rectilinear non-conforming grid.\nThe Dirichlet condition on the velocity field is interpolated at the grid nodes from its actual position.\nThe interpolation method is what differs among IB methods.\n\nA clear advantage of IB methods is the trivial grid-generation process, in contrast to the complicated meshing process regularly encountered for body-conforming grids.\nAlso in this regard, the body geometry is practically irrelevant for the grid generation process.\nOther advantages include the simulation of moving bodies since the grid does not need to be updated at every step, as well as the straightforward implementation of numerical schemes.\nOn the other hand, accuracy near the solid boundary can be compromised depending on the effective resolution of the non-conforming grid.\nAlso, the implementation of the solid boundary condition is not as trivial as in body-conforming grids \\citep{Mittal2005}.\n\nThe BDIM consists in mapping the fluid governing equation $(\\mathcal{F})$ and the solid governing equation $(\\mathcal{B})$ into a single meta-equation $(\\mathcal{M})$ discretised in a non-conforming rectilinear staggered grid.\nA convolution kernel $(K_\\epsilon)$ provides a smooth transition between the mediums enforcing the velocity condition at the interface (see \\fref{fig:bdim}) while extending the fluid subdomain $(\\Omega_f)$ and solid subdomain $(\\Omega_b)$ to the full single domain $(\\Omega)$.\nImposing the no-slip condition on a static body, this method can be summarised as follows\n\\begin{align}\n&\\mathcal{F}(\\vect{u},p)=\\partial_t\\vect{u}-\\vect{h}+\\nabla p=0,\\\\\n&\\mathcal{B}(\\vect{u})=\\vect{u}=0,\\\\\n&\\mathcal{M}(\\vect{u},p)=\\mathcal{F}(\\vect{u},p)\\pars{1-\\delta_\\epsilon}+\\mathcal{B}\\pars{\\vect{u}}\\delta_\\epsilon=0,\n\\end{align}\nwhere the convolution between kernel and governing equation has been approximated using (e.g)\n\\begin{gather}\n\\mathcal{B}_\\epsilon\\pars{\\vect{x}}=\\int_{\\Omega_b}\\mathcal{B}\\pars{\\vect{x}_b}K_\\epsilon\\pars{\\vect{x},\\vect{x}_b}\\,\\mathrm{d}\\vect{x}_b\\approx \\mathcal{B}\\pars{\\vect{x}}\\int_{\\Omega_b}K_\\epsilon\\pars{\\vect{x},\\vect{x}_b}\\,\\mathrm{d}\\vect{x}_b,\\\\\n\\mathcal{B}_\\epsilon\\pars{\\vect{x}}\\approx\\mathcal{B}\\pars{\\vect{x}}\\delta_\\epsilon,\n\\end{gather}\nwhere $\\delta_\\epsilon$ is the integrated kernel over the subdomain which can take the approximated form\n\\begin{equation}\n\\delta_\\epsilon(d)=\n\t\\begin{cases}\n\t\t\\frac{1}{2}[1+\\sin(\\frac{\\pi}{2}\\frac{d}{\\epsilon})] & \\mathrm{for} \\left|d\\right|<\\epsilon\\\\\n\t\t1 & \\mathrm{for}\\,\\,d<-\\epsilon\\\\\n\t\t0 & \\mathrm{else}\n\t\\end{cases}\n\\end{equation}\nwhere $d$ is a signed-distance function from a point $\\vect{x}$ to the solid interface. This approximation results into a first-order accurate scheme, although high-order terms can be considered to improve the order of accuracy \\citep{Maertens2015}.\n\nThe BDIM has been tested in multiple applications and the reader is referred to \\cite{Maertens2015} for an extended mathematical description of the method, and to \\cite{Schulmeister2017} for further validation on bluff body cases.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=0.65\\linewidth]{chapter2/bdim}\n\\caption{BDIM sketch adapted from \\cite{Maertens2015}.\nA convolution kernel with radius $\\epsilon$ smooths the interface between solid $(\\Omega_b)$ and fluid $(\\Omega_f)$ subdomains.}\n\\label{fig:bdim}\n\\end{figure}\n\n\\subsection{Pressure solver}\n\nA multigrid method is used to solve the pressure-Poisson equation as discretised in the pressure-corrector algorithm (\\eref{eq:ppe1} and \\eref{eq:ppe2}).\nAlgebraically, the pressure-Poisson equation can be written as a linear system of equations\n\\begin{equation}\n\\matr{A}\\vect{x}=\\vect{b},\n\\end{equation}\nwhere $\\matr{A}$ is a sparse matrix containing the discretised Laplacian operator, $\\vect{x}$ is the pressure field arranged in a column vector, and $\\vect{b}$ is the column vector of the intermediate velocity field divergence.\n\nContrary to direct methods, a multigrid solver is an iterative method in the sense that that a guessed solution $\\vect{x}^n$ (at the iteration $n$) is evaluated yielding a residual\n\\begin{equation}\n\\vect{r}^n=\\matr{A}\\vect{x}^n-\\vect{b},\n\\end{equation}\nand an error\n\\begin{equation}\n\\boldsymbol\\epsilon^n=\\vect{x}-\\vect{x}^n,\n\\end{equation}\nwhich are related by\n\\begin{equation}\n\\matr{A}\\boldsymbol\\epsilon^n=\\vect{r}^n.\n\\end{equation}\nThe objective is to iteratively minimise $\\vect{r}^n$ so that $\\vect{x}^n$ converges to $\\vect{x}$.\n\nIn multigrid methods, iterations are performed from fine to coarse grids, transferring the residual across grid levels so that iterations become cheaper as the grid is coarsened.\nHence, multigrid methods yield a speed-up of the overall convergence process.\nIterations can be carried with any iterative method, e.g. Gauss--Seidel, Jacobi, conjugate gradient, etc.\nIn our solver, a single Jacobi iteration to smooth the solution is performed before downsampling the residual to a coarser level.\nDownsampling (in one-dimensional form) is performed from\n\\begin{equation}\n\\frac{1}{(\\delta x)^2}\\pars{\\epsilon_{i-1}^n-2\\epsilon_{i}^n+\\epsilon_{i+1}^n}=r_i^n,\n\\end{equation}\nwhere the subscript $(\\cdot)_i$ denotes the fine grid cell index, to\n\\begin{equation}\n\\frac{1}{(\\delta X)^2}\\pars{\\epsilon_{I-1}^n-2\\epsilon_{I}^n+\\epsilon_{I+1}^n}=r_I^n,\n\\end{equation}\nwhere the subscript $(\\cdot)_I$ denotes the coarse grid cell index.\nThe relationship between both grids might be $\\delta X = 2\\delta x$, hence the $I$ (coarse grid) control volume is defined as the $i$ (fine grid) control volume plus half of its neighbour control volumes ($i+1$ and $i-1$) \\citep{Ferziger2002}.\n\nThe residual can be gradually downsampled to an arbitrary coarse grid using linear interpolation for each downsampling step.\nSimilarly, the residual is upsampled from the coarsest grid to the original fine grid while iterating in the mid level grids to correct the fine grid solution.\nWe employ a conjugate gradient method after each upsampling step to update the solution.\nThis downsampling and upsampling process is known as a V-cycle.\nMultiple V-cycles can be performed in a single time step to solve the pressure-Poisson equation.\nThe iterative method is stopped once the convergence tolerance is reached.\nThe following convergence tolerance criteria is defined in a grid with cell index $i$\n\\begin{gather}\n\\frac{1}{\\Omega}\\sum_i\\Big|\\oint \\vect{u}\\cdot\\vect{\\hat{n}}\\,\\mathrm{d}S\\Big|<10^{-6}\\\\\n\\max_i\\Big|\\oint \\vect{u}\\cdot\\vect{\\hat{n}}\\,\\mathrm{d}S\\Big|<10^{-5} \\,\\,\\, \\forall i \\in \\Omega ,\n\\end{gather}\nestablishing the allowed average velocity divergence error in $\\Omega$ as well as its maximum local error.\n% ---------------------------------------------------------------- \n\\end{document}", "meta": {"hexsha": "42e88dfe054731b81e899229cc96cfe285f69ce5", "size": 18293, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chapter2.tex", "max_stars_repo_name": "b-fg/PhD-thesis.tex", "max_stars_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/chapter2.tex", "max_issues_repo_name": "b-fg/PhD-thesis.tex", "max_issues_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/chapter2.tex", "max_forks_repo_name": "b-fg/PhD-thesis.tex", "max_forks_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.8804780876, "max_line_length": 276, "alphanum_fraction": 0.7535669382, "num_tokens": 4938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.44869224235349775}}
{"text": "\\documentclass[10pt]{article}\n\\oddsidemargin = 0.2in\n\\topmargin = -0.5in\n\\textwidth 6in\n\\textheight 8.5in\n\n\\usepackage{graphicx,bm,hyperref,amssymb,amsmath,amsthm}\n\n% -------------------------------------- macros --------------------------\n% general ...\n\\newcommand{\\bi}{\\begin{itemize}}\n\\newcommand{\\ei}{\\end{itemize}}\n\\newcommand{\\ben}{\\begin{enumerate}}\n\\newcommand{\\een}{\\end{enumerate}}\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bea}{\\begin{eqnarray}} \n\\newcommand{\\eea}{\\end{eqnarray}}\n\\newcommand{\\ba}{\\begin{align}} \n\\newcommand{\\ea}{\\end{align}}\n\\newcommand{\\bse}{\\begin{subequations}} \n\\newcommand{\\ese}{\\end{subequations}}\n\\newcommand{\\bc}{\\begin{center}}\n\\newcommand{\\ec}{\\end{center}}\n\\newcommand{\\bfi}{\\begin{figure}}\n\\newcommand{\\efi}{\\end{figure}}\n\\newcommand{\\ca}[2]{\\caption{#1 \\label{#2}}}\n\\newcommand{\\ig}[2]{\\includegraphics[#1]{#2}}\n\\newcommand{\\bmp}[1]{\\begin{minipage}{#1}}\n\\newcommand{\\emp}{\\end{minipage}}\n\\newcommand{\\pig}[2]{\\bmp{#1}\\includegraphics[width=#1]{#2}\\emp} % mp-fig, nogap\n\\newcommand{\\bp}{\\begin{proof}}\n\\newcommand{\\ep}{\\end{proof}}\n\\newcommand{\\ie}{{\\it i.e.\\ }}\n\\newcommand{\\eg}{{\\it e.g.\\ }}\n\\newcommand{\\etal}{{\\it et al.\\ }}\n\\newcommand{\\pd}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\pdc}[3]{\\left. \\frac{\\partial #1}{\\partial #2}\\right|_{#3}}\n\\newcommand{\\infint}{\\int_{-\\infty}^{\\infty} \\!\\!}      % infinite integral\n\\newcommand{\\tbox}[1]{{\\mbox{\\tiny #1}}}\n\\newcommand{\\mbf}[1]{{\\mathbf #1}}\n\\newcommand{\\half}{\\mbox{\\small $\\frac{1}{2}$}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\RR}{\\mathbb{R}^2}\n\\newcommand{\\ve}[4]{\\left[\\begin{array}{r}#1\\\\#2\\\\#3\\\\#4\\end{array}\\right]}  % 4-col-vec\n\\newcommand{\\vt}[2]{\\left[\\begin{array}{r}#1\\\\#2\\end{array}\\right]} % 2-col-vec\n\\newcommand{\\bigO}{{\\mathcal O}}\n\\newcommand{\\qqquad}{\\qquad\\qquad}\n\\newcommand{\\qqqquad}{\\qqquad\\qqquad}\n\\DeclareMathOperator{\\Span}{Span}\n\\DeclareMathOperator{\\im}{Im}\n\\DeclareMathOperator{\\re}{Re}\n\\DeclareMathOperator{\\vol}{vol}\n\\newtheorem{thm}{Theorem}\n\\newtheorem{cnj}[thm]{Conjecture}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{pro}[thm]{Proposition}\n\\newtheorem{rmk}[thm]{Remark}\n% this work...\n\\newcommand{\\pO}{{\\partial\\Omega}}\n\\newcommand{\\LpO}{\\Delta_\\pO}\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\dn}{\\partial_n}\n\n\n\n\\begin{document}\n\n\\title{Asymptotic expansion of a coupled surface-bulk diffusion problem in\n  the reciprocal of the bulk diffusivity}\n\n\\author{Alex H. Barnett}\n\\date{\\today}\n\\maketitle\n\n\\begin{abstract}\n  In the spherical cell polarization model of Diegmiller et al (2018),\n  the bulk diffusivity $D_C$ is taken as infinite.\n  In fact $D_C$ is large but finite, being $1/\\eps \\sim 10^2$ times\n  larger than the surface diffusivity.\n  A full numerical solution of the coupled bulk and surface diffusion equations\n  in a general cell geometry---either by finite difference or time-domain\n  boundary integral methods---%\n  would be daunting due to issues of discretization and possible small time steps.\n  Here we apply the classical method of {\\em singular perturbation} in powers of $\\eps \\ll 1$.\n  The biologically relevant outer layer solution to a given order\n  involves only bulk Poisson solves, so might make a more attractive numerical scheme.\n\\end{abstract}\n\n\\section{Introduction}\n\nLet $\\Omega \\subset \\R^3$ be a smooth bounded domain\nrepresenting a cell, with boundary $\\pO$.\nIn \\cite{diegmiller18} a cell polarization model is presented\nwith bulk concentration $C(x,t)$ diffusing in $\\Omega$ with\ndiffusivity $D_C$,\ncoupled to a surface concentration $B(x,t)$ obeying a nonlinear\nreaction-diffusion equation on $\\pO$ with much lower diffusivity.\nThey consider the special case $\\Omega$ a ball; we consider a general shape.\nNon-dimensionalizing their model with length units of order the diameter,\nand time units such that the surface diffusion is unity,\none gets the IBVP\n\\bea\n\\dot{B} - \\LpO B   &=&  f(B,C)  \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{surfpde}\n\\\\\n\\eps \\dot{C} - \\Delta C   &=& 0   \\qqquad \\mbox{ in } \\Omega \\times (0,\\infty)\n\\label{pde}\n\\\\\n\\dn C  &=& -\\eps f(B,C) \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{fick}\n\\\\\nB(x,0) &=& B_i(x)  \\qqquad x\\in\\pO\n\\label{Bi}\n\\\\\nC(x,0) &=& C_i(x)  \\qqquad x\\in\\Omega ~,\n\\label{Ci}\n\\eea\nwhere a dot indicates $\\partial_t$, and $\\dn = \\mbf{n}\\cdot\\nabla$\nwhere $\\mbf{n}$ is the unit surface normal facing out of $\\Omega$.\nThe given initial data are $B_i$ and $C_i$.\nHere $\\eps \\ll 1$ is interpreted as $D_B/D_C$ (the ratio of surface\nto bulk diffusivities), and in \\cite{diegmiller18} is quoted to be about\n$0.003$.\nFick's law relating Neumann boundary data to net flux is \\eqref{fick}.\nThis flux is controlled by $f(B,C)$, a fixed function of two variables,\ngiving the local net flux from bulk to surface at a point on $\\pO$, in terms of the local surface concentration $B$ and bulk concentration $C$ at that point.\nIt is generally nonlinear, the example from \\cite{diegmiller18} being\n$$\nf(B,C) = (\\beta + \\frac{B^\\nu}{B^\\nu + \\Gamma^\\nu})C - k_d B~,\n$$\nwhere the two terms are binding and unbinding rates,\nfor constants $\\beta$, $\\Gamma$, and $k_d$. We will leave $f$ arbitrary.\n\nThe total amount of chemical (bulk plus surface) is conserved as follows.\n%as follows \\cite{diegmiller18}.\n\\begin{pro}[Conservation law]\n  For any $\\eps>0$,\n  any solution of the above IBVP obeys\n  \\be\n\\int_\\pO B(\\cdot,t) + \\int_\\Omega C(\\cdot,t) \\; = \\; A ~,  \\qquad t>0~,\n\\label{cons}\n\\ee\nwith constant $A:=\\int_\\pO B_i + \\int_\\Omega C_i$.\n\\label{p:cons}\n\\end{pro}\n\\begin{proof}\nVia the bulk and surface divergence theorems and the PDEs,\n$$\n\\eps \\int_\\Omega \\dot{C} = \\int_\\Omega \\Delta C = \\int_\\pO \\dn C =  -\\eps\n\\int_\\pO f(B,C) = -\\eps \\int_\\pO (\\dot{B}-\\LpO B) = -\\eps \\int_\\pO \\dot{B}~,\n$$\nthen one cancels $\\eps$.\n\\end{proof}\n\n\n% SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\n\\section{Singular perturbation and expansions in $\\eps$}\n\nFor small $\\eps$ the above IBVP is a singularly-perturbed problem in time,\nso it is standard to split its analysis into initial layer\nand outer layer solutions\n\\cite[Sec.~3.4]{logan} \\cite[Sec.~10.2]{linsegel}\n(note we reverse their convention of capital letters for inner and small\nletters for outer).\nWe will see that the former is a relaxation phase of $C$ where $B$ is be essentially constant,\nwhile in the latter $B$ will also change and $C$ stays nearly constant as a function of space.\nNote that only the outer layer solution, to zeroth order in $\\eps$, is\nconsidered in \\cite{diegmiller18}.\n\n\n% iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\n\\subsection{Initial layer solution at zeroth and first order}\n\nRewriting using the rescaled time $\\bar{t}:=t/\\eps$, the IBVP\nbecomes, using small letters for the inner solution,\n\\bea\n\\dot{b} - \\eps\\LpO b   &=&  \\eps f(b,c)  \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{surfpdel}\n\\\\\n\\dot{c} - \\Delta c   &=& 0   \\qqquad \\mbox{ in } \\Omega \\times (0,\\infty)\n\\label{pdel}\n\\\\\n\\dn c  &=& -\\eps f(b,c) \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\eea\nwith IC \\eqref{Bi}--\\eqref{Ci} as before.\n\nOne can then expand the solution as $b = b_0 + \\eps b_1 + \\eps^2 b_2 + \\dots$,\netc, and match powers of $\\eps$.\n\nAt zeroth order \\eqref{surfpdel} becomes $\\dot{b_0}=0$.\nAnd \\eqref{pdel} with homogeneous Neumann BCs $\\dn c_0 = 0$ means that\nthe zeroth order inner layer solution is analytic:\n\\be\nb_0(x,\\bar{t}) = B_i(x)~,\n\\quad x\\in\\pO, \\; \\bar{t}>0~,\n\\qqquad\nc_0(x,\\bar{t}) = \\bar{C}_i + \\sum_{j=1}^\\infty \\alpha_j e^{-\\lambda_j \\bar{t}} \\psi_j(x) ~,\n \\quad x\\in\\Omega, \\; \\bar{t}>0\n\\label{BCl0}\n \\ee\nwhere $\\bar{C}_i := (\\vol\\Omega)^{-1} \\int_\\Omega C_i$ is the average of the\ninitial data,\nand $(\\lambda_j, \\psi_j)$ are the non-trivial Neumann Laplace eigenpairs\nof $\\Omega$, ordered such that $0<\\lambda_1\\le\\lambda_2\\le\\dots$.\nThe coefficients are given by the Euler--Fourier formula\n$\\alpha_j = \\langle \\psi_j,C_i\\rangle_{L^2(\\Omega)}$, assuming\n$\\|\\psi_j\\|=1$ $\\forall j$.\nNote that at this order, $b_0$ is constant, whereas $c_0$ equilibrates on\na slowest $\\bar{t}$ timescale of $1/\\lambda_1$, which (unless $\\Omega$\nhas peculiar features such as narrow necks) is $\\bigO(1)$.\nThis relaxation time for $C$ will thus be $\\bigO(\\eps)$\nback in the original variable $t$.\n\nAt first order, we get a linear IBVP (recalling time-derivatives\nare with respect to inner time $\\bar{t}$),\n\\bea\n\\dot{b_1}  &=& \\LpO c_0 + f(b_0,c_0)  \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\\\\n\\dot{c_1} - \\Delta c_1   &=& 0   \\qqqquad \\mbox{ in } \\Omega \\times (0,\\infty)\n\\\\\n\\dn c_1  &=& -f(b_0,c_0) \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\\\\nb_1(x,0) &=& 0  \\qqquad x\\in\\pO\n\\label{Bi1}\n\\\\\nc_1(x,0) &=& 0  \\qqquad x\\in\\Omega ~,\n\\label{Ci1}\n\\eea\nwhere $b_0$ and $c_0$ are given by \\eqref{BCl0}.\nThe solution is pointwise linear growth of $b_1$, and, independently,\nthe linear heat equation for $c_1$ with prescribed\nNeumann boundary driving.\nThe nonlinear nature of $f$ has not yet kicked in at these short timescales.\n\nA numerical solution for $c_1$ could either be done by timestepping\nDuhamel ODEs for each above eigenmode, or via an immersed interface finite-difference\nsolver or time-domain boundary integral solver.\nWe are unsure of the biological relevance of this inner solution,\nespecially for the very rapid relaxation times that a spatially-complicated $C_i$ would bring.\n%since $C$ is in practice likely to be equilibrated.\nHence we move to the outer solution.\n\n\n\n% ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\n\\subsection{Outer layer at zeroth order and uniform approximation}\n\nWe return to the original time variable $t$,\nand call the zeroth order solution $B_0$ and $C_0$.\nTaking $\\eps\\to 0^+$ replaces \\eqref{pde}--\\eqref{fick}\nby a static homogenous Neumann Laplace BVP at each time $t$,\nso that\n\\bea\n\\dot{B_0} - \\LpO B_0   &=&  f(B_0,C_0)  \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{surfpde0}\n\\\\\n\\Delta C_0   &=& 0   \\qqquad \\mbox{ in } \\Omega \\times (0,\\infty)\n\\label{pde0}\n\\\\\n\\dn C_0  &=& 0 \\qqquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{fick0}\n\\eea\nthus $C_0$ is spatially constant at each time $t$.\nHowever setting $\\eps=0$ does {\\em not} tell you how this\nconstant changes with $t$, since there is no PDE for $C$ involving time!\nFor this, curiously, Prop.~\\ref{p:cons} (a result for $\\eps>0$) is also needed,\ngiving the spatially-constant\n\\be\nC_0(x,t) = \\frac{1}{\\vol\\Omega}\\biggl[ A_0 - \\int_\\pO B_0(\\cdot,t) \\biggr]\n~, \\qquad x\\in\\Omega\n\\label{C0}\n\\ee\nwhere $A_0$ is some fixed total amount of chemical.\nSubstituting into \\eqref{surfpde0} leaves a self-contained surface\nPDE for $B_0$ alone,\n\\be\n\\dot{B_0} - \\LpO B_0 =f \\biggl( B_0 , \\frac{1}{\\vol\\Omega} \\biggl[ A_0 - \\int_\\pO B_0(\\cdot,t) \\biggr]\n\\biggr)\n\\label{B0only}\n\\ee\nwhich is \\cite[Eq.~(7)]{diegmiller18} and assumed throughout that paper\n(note they use the symbol ``$C_0$'' to denote our $\\frac{A_0}{\\vol\\Omega}$).\n\nAs is standard for outer layer solutions,\n\\eqref{surfpde0}--\\eqref{fick0} cannot match arbitrary ICs:\nthe initial $C_0$ must be constant in space.\nInstead the outer ICs (for $t\\to 0^+$) are found by matching\nto the inner layer (for $\\bar{t}\\to\\infty$),\ngiving,\nsomewhat predictably,\n$C_0(x,0)=\\bar{C}_i$ for $x\\in\\Omega$, and\n$B_0(x,0)=B_i(x)$ for $x\\in\\pO$.\nAs expected, $A_0 = \\int_\\Omega C_i + \\int_\\pO B_i$ is the total amount\nof initial chemical.\nThe lowest-order uniform asymptotic expansion is then given by adding\ninner and outer solutions and subtracting their common limit,\ngiving\n\\be\nB^{(u)}(x,t) = B_0(x,t), \\quad x\\in\\pO,\\;t>0,\n\\qquad\nC^{(u)}(x,t) = C_0(x,t) + \\sum_{j=1}^\\infty \\alpha_j e^{-\\lambda_j t/\\eps} \\psi_j(x),\n\\quad x\\in\\Omega, \\; t>0.\n\\label{unif0}\n\\ee\nThis has $\\bigO(\\eps)$ error uniformly in time, formally justifying\nthe approximation in \\cite{diegmiller18}.\n\n\n\n\\subsection{First order correction to outer layer solution}\n\nGathering terms in $\\eps$, the PDEs and BC for the first order outer correction are\n\\bea\n\\dot{B_1} - f_B(B_0,C_0) B_1 - \\LpO B_1\n&=&  f_C(B_0,C_0) C_1  \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{surfpde1}\n\\\\\n- \\Delta C_1   &=& -\\dot{C_0}   \\qquad\\qqquad \\mbox{ in } \\Omega \\times (0,\\infty)\n\\label{pde1}\n\\\\\n\\dn C_1  &=& -f(B_0,C_0) \\qquad \\mbox{ on } \\pO \\times (0,\\infty)\n\\label{fick1}\n\\eea\nHere $f_B$ and $f_C$ are the partials of the fixed function $f$.\nThe form is a linear surface reaction-diffusion equation for $B_1$,\ncoupled to a family of static Neumann Poisson BVPs for $C_1$ at each $t>0$.\nWe leave the ICs open, to be found by matched asymptotics later.\n\nConsider the static Poisson BVP \\eqref{pde1}--\\eqref{fick1}.\nIts volume forcing $-\\dot{C_0}$ is constant in space, by \\eqref{C0}.\nThis constant is found by using \\eqref{C0},\nthe surface divergence theorem, then\n\\eqref{surfpde0},\n\\be\n-(\\vol\\Omega)\\dot{C_0}(x,t) = \\int_\\pO \\dot{B_0}(\\cdot, t) =\n\\int_\\pO [\\dot{B_0}(\\cdot, t) - \\LpO B_0(\\cdot,t) ]=\n\\int_\\pO f(B_0(\\cdot,t),C_0(\\cdot,t))~, \\quad x\\in\\Omega.\n\\label{C0d}\n\\ee\nFor a solution to the BVP to exist one must have (by the divergence theorem)\nthe total volume forcing matching the total outgoing flux,\ni.e.\n$$\n-\\int_\\Omega \\dot{C_0}(\\cdot,t) = -\\int_\\pO \\dn C_1(\\cdot,t)~,  \\quad \\forall t>0~.\n$$\nYet this follows since both sides are equal to \n$\\int_\\pO f(B_0(\\cdot,t),C_0(\\cdot,t))$, by \\eqref{C0d} and \n\\eqref{fick1} respectively.\nThus the BVP is {\\em consistent} at each $t>0$.\nIt also has a nullspace of constant functions, so which solution\nis selected at each $t>0$ ?\nAs with zeroth order, it is not contained in the PDE at this order,\nso it seems we have to bring in\nProp.~\\ref{p:cons} again, giving\n\\be\n\\int_\\Omega C_1(\\cdot,t) = -\\int_\\pO B_1(\\cdot,t)~.\n\\label{C1}\n\\ee\nSuppose that, at a given $t$,\na Poisson solution to \\eqref{pde1}--\\eqref{fick1} has been found,\n$\\tilde{C}_1(x,t)$.\nThen, writing $C_1 = \\tilde{C}_1 + \\alpha$,\nby \\eqref{C1} one gets, in terms of known quantities at the current $t$,\n$$\n\\alpha = -\\frac{1}{\\vol\\Omega} \\biggl[\n  \\int_\\Omega \\tilde{C}_1 + \\int_\\pO B_1\n  \\biggr]\n$$\nand then one substitutes this into \\eqref{surfpde1} to give\nthe right-hand side for the surface PDE to timestep,\n$$\n\\dot{B_1} - f_B(B_0,C_0) B_1 - \\LpO B_1\n=  f_C(B_0,C_0) (\\tilde{C}_1 + \\alpha)\n~.\n$$\nTogether, the last two equations (which could be combined by eliminating $\\alpha$)\ncomprise the first-order equivalent of \\eqref{B0only}.\n\nA numerical solution of the Poisson BVP at this order is\nquite easy, since a quadratic particular solution can be written down\n(due to the spatially-constant forcing), then the boundary Neumann Laplace\nproblem solved via a 2nd-kind BIE.\nA numerical scheme for evolving $B_1$ alongside $B_0$,\nand $C_1$ alongside $C_0$, is thus clear,\nat the effort of doubling the surface variables, and a Laplace Neumann\nBVP solve per timestep.\n\n\n\n%The solution $b=b_0+\\eps b_1$ and $c=c_0+\\eps c_1$ is already $\\bigO(\\eps^2)\n%\\sim 10^{-5}$\n%accurate, so there is little point in higher-order solutions.\n\n\\section{Conclusions}\n\nUsing an asymptotic expansion in $\\eps$ (essentially the reciprocal bulk diffusivity),\nwe wrote an approximate solution to the nonlinear coupled\ninterior-boundary cell diffusion IBVP that is uniformly accurate\nto $\\bigO(\\eps)$, using zeroth-order inner and outer solutions.\nThis formally justifies the quasistatic bulk\napproximation in \\cite{diegmiller18}.\nThe inner layer is biologically irrelevant.\nWe also write the first-order outer solution.\nThe outer solution (at each order) has a curious extra condition on the change in average value due to the Neumann boundary condition for the coupling.\n\nNumerically, a scheme for the outer solution\nis to solve the zeroth order (i.e. solve for $B_0$ and $C_0$),\nthen first order (i.e. solve for $B_1$ and $C_1$, which could be\ndone at the same time as zeroth order, at the cost of one Laplace BVP\nsolve per timestep),\nthen add: $B_0+\\eps B_1$ and $C_0 + \\eps C_1$ is an outer solution\nwith error $\\bigO(\\eps^2)$.\n\nHowever, we believe a cleaner and higher-order numerical scheme could be found;\nsee other notes.\nThis note remains mostly a theoretical foundation.\n\nFuture directions:\n\\bi\n\\item Matched asymptotics including all $\\bigO(\\eps)$ terms,\n  to give an approximate solution with uniform error $\\bigO(\\eps^2)$.\n  This will involve integrals over $f(b_0,c_0)$ with $b_0$ const in $\\bar{t}$,\n  but $c_0$ sweeping through prescribed values.\n  It is not simple.\n  It is unclear how $c_1$ matches to $C_1$.\n\\item Find a numerical method that doesn't require solving the\n  zeroth- and then first-order correction sequentially.\n  Explore 2nd-kind Volterra time-domain BIE here, although the\n  $\\eps$-expansion of heat potentials is proving to be a mess.\n\\ei\n\n  \n\n\n% BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\\bibliographystyle{abbrv}\n\\bibliography{localrefs}\n\\end{document}\n\n", "meta": {"hexsha": "3d861517081e4ab5d6ae7095eb4a986017a82c7c", "size": 16908, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/singpert_cellprob.tex", "max_stars_repo_name": "ahbarnett/heat-quasistatic", "max_stars_repo_head_hexsha": "8f6c8804f14a6ab5f2cac56c5b59823827dd439a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/singpert_cellprob.tex", "max_issues_repo_name": "ahbarnett/heat-quasistatic", "max_issues_repo_head_hexsha": "8f6c8804f14a6ab5f2cac56c5b59823827dd439a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/singpert_cellprob.tex", "max_forks_repo_name": "ahbarnett/heat-quasistatic", "max_forks_repo_head_hexsha": "8f6c8804f14a6ab5f2cac56c5b59823827dd439a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.995505618, "max_line_length": 157, "alphanum_fraction": 0.7058197303, "num_tokens": 5855, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521102, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.44869224235349764}}
{"text": "\\documentclass[t]{beamer}\n\\usetheme{Copenhagen}\n\\usepackage{amsmath, tikz, pgfplots, array, graphicx}\n\\tikzset{>=stealth}\n\\pgfplotsset{compat=newest}\n\\pgfplotsset{every tick label/.append style={font=\\scriptsize}}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\\everymath{\\displaystyle}\n\n\\title{Graphs of Tangent, Cotangent, Secant, and Cosecant}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}{}\n    \\maketitle\n\\end{frame}\n\n\\section{Determine the amplitude, period, phase shift, and vertical shift of the tangent and cotangent graphs.}\n\n\\begin{frame}{Tangent and Cotangent Graphs}\nRecall that $\\tan = \\frac{y}{x}$. \\\\[20pt]    \\pause\n\nSince $x$- and $y$-coordinates can be positive, negative, or zero, the graphs of tangent and cotangent functions pose some interesting behavior; in particular, when the $x$-coordinate is 0.\n\\end{frame}\n\n\\begin{frame}[c]{Vertical Asymptotes}\n    A \\alert{vertical asymptote} is a vertical line that the graph will get infinitely close to, but never cross.\n\\end{frame}\n\n\\begin{frame}[c]{Tangent Graph}\n\\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.45*pi:0.45*pi] {tan(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0.55*pi:1.45*pi] {tan(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.55*pi:2*pi] {tan(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(-1.57,-3.5) (-1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(1.57,-3.5) (1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(4.71,-3.5) (4.71,3.5)};\n    \\end{axis}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[c]{Cotangent Graphs}\n\\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.65*pi:-0.05, <->, >=stealth] {cot(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0.05*pi:0.95*pi] {cot(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.05*pi:1.95*pi] {cot(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(0,-3.5) (0,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(3.14,-3.5) (3.14,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(6.29,-3.5) (6.29,3.5)};\n    \\end{axis}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Amplitude?}\n    The graphs of tangent and cotangent functions do not stop going up or down. Thus, they have neither a maximum point nor a minimum point. \\newline\\\\ \\pause\n    \n    In other words, \\emph{tangents and cotangents have no amplitude}. \n\\end{frame}\n\n\\begin{frame}{Period of Tangent and Cotangent}\n    Tangents and cotangents complete one full cycle between asymptotes. Notice for each graph, that period is $180^\\circ, \\text{ or } \\pi$ radians. \\newline\\\\ \\pause\n    \n    Like the graphs of sine and cosine, multiplying the inputs, $x$, by a positive value other than 1 will affect the period of the graphs for tangent and cotangent.    \\newline\\\\ \\pause \n\n    Instead of dividing $360^\\circ$ (or $2\\pi$) by that value, for tangent and cotangent divide $180^\\circ$ (or $\\pi$ radians).\n\\end{frame}\n\n\\begin{frame}{Shifts}\nDetermining phase shift and vertical shift follow the same procedures as that for sine and cosine.\n\\end{frame}\n\n\\begin{frame}{Example 1}\nDetermine the amplitude, period, phase shift, and vertical shift of each of the following.    \\newline\\\\\n(a) \\quad $y = 2\\tan \\left(x - 45^\\circ \\right)$    \\newline\\\\  \\pause\n\nAmplitude: None \\newline\\\\  \\pause\nPeriod: $\\frac{180^\\circ}{1} = 180^\\circ$\n\\end{frame}\n\n\\begin{frame}{Example 1 \\quad $y = 2\\tan \\left(x - 45^\\circ \\right)$}\nPhase Shift: \n\\begin{align*}\n    \\onslide<2->{x - 45 &= 0} \\\\\n    \\onslide<3->{x &= 45}\n\\end{align*}     \\pause\n\\onslide<4->{Phase Shift: $45^\\circ$ right}   \\newline\\\\  \n\\onslide<5->{Vertical Shift: 0 (or none)}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $y = -\\frac{1}{3}\\cot x + 1$    \\newline\\\\  \\pause\nAmplitude: None \\newline\\\\ \\pause\nPeriod: $\\frac{180^\\circ}{1} = 180^\\circ$   \\newline\\\\  \\pause\nPhase Shift: 0 (or none) \\newline\\\\ \\pause\nVertical Shift: Up 1\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $y = 1.5\\tan\\left(2x + 120^\\circ\\right) - 5$  \\newline\\\\ \\pause\nAmplitude: None \\newline\\\\  \\pause\nPeriod: $\\frac{180^\\circ}{2} = 90^\\circ$\n\\end{frame}\n\n\\begin{frame}{Example 1 \\quad $y = 1.5\\tan\\left(2x + 120^\\circ\\right) - 5$}\nPhase Shift:\n\\begin{align*}\n    \\onslide<2->{2x + 120 &= 0}   \\\\\n    \\onslide<3->{2x &= -120} \\\\\n    \\onslide<4->{x &= -60}\n\\end{align*}\n\\onslide<5->{Phase Shift: $60^\\circ$ left}    \\newline\\\\\n\\onslide<6->{Vertical Shift: 5 down}\n\\end{frame}\n\n\\section{Determine the amplitude, period, phase shift, and vertical shift of the secant and cosecant graphs.}\n\n\\begin{frame}[c]{Secant Graph}\n\\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.45*pi:0.45*pi] {sec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0.55*pi:1.45*pi] {sec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.55*pi:2*pi] {sec(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(-1.57,-3.5) (-1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(1.57,-3.5) (1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(4.71,-3.5) (4.71,3.5)};\n    \\end{axis}\n    \\end{tikzpicture} \n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Cosecant Graph}\n\\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.65*pi:-0.05, <->, >=stealth] {cosec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0.05*pi:0.95*pi] {cosec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.05*pi:1.95*pi] {cosec(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(0,-3.5) (0,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(3.14,-3.5) (3.14,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(6.29,-3.5) (6.29,3.5)};\n    \\end{axis}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Relationship to Sine and Cosine}\n    If we graph $y = \\cos x$ in the same plane as $y = \\sec x$, we see some interesting features:\n    \\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.45*pi:0.45*pi] {sec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0.55*pi:1.45*pi] {sec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.55*pi:2*pi] {sec(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(-1.57,-3.5) (-1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(1.57,-3.5) (1.57,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(4.71,-3.5) (4.71,3.5)};\n    \\addplot [color=red, domain=-1.57:6.29, line width=1] {cos(deg(x))};\n    \\end{axis}\n    \\end{tikzpicture}\n    \\end{center}\n\\end{frame}\n\n\\begin{frame}{Cosine and Secant}\nNotice that when $\\cos x$ is at a maximum, we get a ``smile\" on the secant graph, and when $\\cos x$ is at a minimum, we get a ``frown\" on the secant graph. \\newline\\\\ \\pause\n\nAlso, whenever $y=\\cos x$ crosses the $x$-axis, there is a vertical asymptote for $y=\\sec x$ (why?)   \\newline\\\\ \\pause\n\nThe same logic applies with $y=\\csc x$ and $y=\\sin x$.\n\\end{frame}\n\n\\begin{frame}{Sine and Cosecant}\n    \\begin{center}\n    \\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -2, xmax = 6.5,\n    ymin = -3.5, ymax = 3.5,\n    grid, domain=0:8.5,\n    xtick = {-1.57, 0, 1.57, 3.14, 4.71, 6.29},\n    xticklabels = {$-90^\\circ$, 0, $90^\\circ$, $180^\\circ$, $270^\\circ$, $360^\\circ$},\n    xlabel style={at=(current axis.right of origin), anchor=west},\n    ytick = {-3,-2,...,3},\n    ylabel style={at=(current axis.above origin), anchor=south}\n    ]\n    \\addplot [color=blue, line width = 1, smooth, domain=-0.95*pi:-0.05*pi] {cosec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=0:0.95*pi] {cosec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=1.05*pi:1.95*pi] {cosec(deg(x))};\n    \\addplot [color=blue, line width = 1, smooth, domain=2.05*pi:2.95*pi] {cosec(deg(x))};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(0,-3.5) (0,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(3.14,-3.5) (3.14,3.5)};\n    \\addplot [color=violet, line width = 1.5, dashed] coordinates {(6.28,-3.5) (6.28,3.5)};\n    \\addplot [color=red, domain=-1.57:6.29, line width=1] {sin(deg(x))};\n    \\end{axis}\n    \\end{tikzpicture}\n    \\end{center}\n\\end{frame}\n\n\\begin{frame}{Properties}\nOnce again, since there are no maximum nor minimum points, secant and cosecant do not have an amplitude.   \\newline\\\\ \\pause\n\nThe period of the graphs of secant and cosecant can be found by determining how long it takes one full smile and one full frown to appear. \\newline\\\\ \\pause \n\nFrom the graphs, we can see that it is $360^\\circ$, or $2\\pi$ radians (just like sine and cosine).  \\newline\\\\ \\pause  \n\nMultiplying the inputs by a positive value other than 1 changes the period. \\newline\\\\ \\pause \n\nPhase shifts and vertical shifts are calculated in the same way as the other four trig functions.\n\\end{frame}\n\n\\begin{frame}{Example 2}\nthe amplitude, period, phase shift, and vertical shift for each of the following.   \\newline\\\\\n(a) \\quad $y = 2\\sec \\left(x - 45^\\circ \\right)$    \\newline\\\\  \\pause\nAmplitude: None \\newline\\\\  \\pause\nPeriod: $\\frac{360^\\circ}{1} = 360^\\circ$\n\\end{frame}\n\n\\begin{frame}{Example 2 \\quad $y = 2\\sec \\left(x - 45^\\circ \\right)$}\nPhase Shift:    \n\\begin{align*}\n    \\onslide<2->{x - 45 &= 0} \\\\\n    \\onslide<3->{x &= 45} \\\\\n\\end{align*}\n\\onslide<4->{Phase Shift: $45^\\circ$ right} \\newline\\\\ \\pause\n\\onslide<5->{Vertical Shift: 0 (or none)} \n\\end{frame}\n\n\\begin{frame}{Example 2}\n(b) \\quad $y = -\\frac{1}{3}\\csc x + 1$  \\newline\\\\  \\pause\nAmplitude: None \\newline\\\\ \\pause\nPeriod: $\\frac{360^\\circ}{1} = 360^\\circ$   \\newline\\\\  \\pause\nPhase Shift: None   \\newline\\\\  \\pause\nVertical Shift: Up 1\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(c) \\quad $y = 1.5\\csc\\left(2x + 120^\\circ\\right) - 5$  \\newline\\\\  \\pause\nAmplitude: None \\newline\\\\  \\pause\nPeriod: $\\frac{360^\\circ}{2} = 180^\\circ$\n\\end{frame}\n\n\\begin{frame}{Example 3 \\quad }$y = 1.5\\csc\\left(2x + 120^\\circ\\right) - 5$\nPhase Shift:\n\\begin{align*}\n    \\onslide<2->{2x + 120 &= 0} \\\\\n    \\onslide<3->{2x &= -120} \\\\\n    \\onslide<4->{x &= -60}  \\\\\n\\end{align*}\n\\onslide<5->{Phase Shift: $60^\\circ$ left} \\newline\\\\\n\\onslide<6->{Vertical Shift: 5 down}\n\\end{frame}\n\n\\begin{frame}[c]{Summary}\n\\begin{center}\n\\setlength{\\extrarowheight}{11pt}\n\\scalebox{0.8}{\n\\begin{tabular}{|c|c|c|c|c|}\n    \\hline\n    &   \\textbf{Amplitude}  &   \\textbf{Period} &   \\textbf{Phase Shift}  &   \\textbf{Vertical Shift} \\\\[6pt] \\hline\n    $y=A\\tan(Bx-C)+D$   &   None    &   $\\dfrac{180^\\circ}{B} \\text{ or } \\dfrac{\\pi}{B}$   &  \n    $\\dfrac{C}{B}$  &   $D$ \\\\[11pt]  \\hline\n    \n    $y=A\\cot(Bx-C)+D$   &   None    &   $\\dfrac{180^\\circ}{B} \\text{ or } \\dfrac{\\pi}{B}$   &  \n    $\\dfrac{C}{B}$  &   $D$ \\\\[11pt]  \\hline\n    \n    $y=A\\sec(Bx-C)+D$   &   None    &   $\\dfrac{360^\\circ}{B} \\text{ or } \\dfrac{2\\pi}{B}$   &  \n    $\\dfrac{C}{B}$  &   $D$ \\\\[11pt]  \\hline\n    \n    $y=A\\csc(Bx-C)+D$   &   None    &   $\\dfrac{360^\\circ}{B} \\text{ or } \\dfrac{2\\pi}{B}$   &  \n    $\\dfrac{C}{B}$  &   $D$ \\\\[11pt]  \\hline\n\\end{tabular}}\n\\end{center}\n\\end{frame}\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "b8134f9a097b10136fcf8c863db828273d723aa8", "size": 13831, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Graphs_of_Other_Trig_Functions(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Graphs_of_Other_Trig_Functions(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Graphs_of_Other_Trig_Functions(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 40.0898550725, "max_line_length": 189, "alphanum_fraction": 0.621068614, "num_tokens": 5109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7718435030872967, "lm_q1q2_score": 0.4486750138383791}}
{"text": "\\documentclass[10pt]{report}\n\n\\usepackage{geometry}\n\\geometry{\n\ta4paper,\n\tmargin=1in,\n\tfootskip=0.25in\n}\n\n\\usepackage{enumerate} % for enumerate counter\n\\usepackage{subcaption} % for subfigures\n\\usepackage{amsthm} % for QED\n\\usepackage{mathtools} % for delimiter\n\n\\usepackage{listings} % for code\n\\lstset{ \n\tlanguage=R,\n\tbasicstyle=\\footnotesize\\ttfamily,\n\tnumbers=none,\n\tstepnumber=1,\n\tnumbersep=8pt,\n\tshowspaces=false,\n\tshowstringspaces=false,\n\tshowtabs=false,\n\tframe=single,\n\ttabsize=2,\n\tcaptionpos=t,\n\tbreaklines=true,\n\tbreakatwhitespace=false\n} \n\n\\usepackage{float} % for figure [H]\n\\usepackage{booktabs} % for tabular\n\\usepackage{caption} % for \\caption*\n\\usepackage[export]{adjustbox} % for valign=t\n\\usepackage{array} % for column type m\n\\usepackage{verbatim}\n\\usepackage{graphicx}\n%\\graphicspath{ {imgs/} }\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhead[L]{\\hwAuther}\n\\fancyhead[C]{\\courseNo}\n\\fancyhead[R]{\\hwNo}\n\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n%Cover\n\\newcommand{\\courseTitle}{Introduction to Mathematical Modeling}\n\\newcommand{\\courseNo}{Math 380}\n\\newcommand{\\hwAuther}{Zhihao Ai}\n\n\\newcommand{\\hwNo}{HW \\#1}\n\\newcommand{\\hwDate}{Due on 01/23}\n\n\\title{\n\t\\courseTitle\\\\\n\t\\hwNo\\\\\n\t\\hwDate\n}\n\\author{\\hwAuther}\n\\date{}\n%\n\n%Custom\n%\\everymath{\\displaystyle}\n\\setlength\\parindent{0pt}\n\n%Custom commands\n\\newcommand{\\ds}{\\displaystyle}\n\\newcommand{\\ts}{\\textstyle}\n\n\\newcolumntype{N}{>$ c <$} \n\\newcolumntype{M}[1]{>{\\centering\\arraybackslash $}m{#1}<{$}}\n\n\\newcommand{\\abs}[1] {\\left| #1 \\right|}\n\n\\DeclarePairedDelimiter\\autoparen{(}{)}\n\\newcommand{\\pa}[1]{\\autoparen*{#1}}\n\n\\newcommand{\\var} {\\text{var}}\n\n\\newcommand{\\m}[1] {\\mathbf{#1}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Section 1.1}\n\\begin{enumerate}\n\t\\item[3.]\n\tBy examining the following sequences, write a difference equation to represent the change during the $n$th interval as a function of the previous term in the sequence.\n\t\n\t\\begin{enumerate}\n\t\t\\item [b.]\n\t\t\\{2, 4, 16, 256\\}\n\t\t\\begin{align*}\n\t\t\ta_{n+1} &= a_n^2, \\quad n=0,1,2,3,\\dots\\\\\n\t\t\ta_0 &= 2\n\t\t\\end{align*}\n\t\twhere $a_n$ is the $n$-th term of the sequence.\n\t\t\n\t\t\\item [c.]\n\t\t\\{1, 2, 5, 11, 23\\}\n\t\t\\begin{align*}\n\t\t\ta_{n+1} &= 2 a_n + 1, \\quad n=1,2,3,\\dots\\\\\n\t\t\ta_0 &= 1\\\\\n\t\t\ta_1 &= 2\n\t\t\\end{align*}\n\t\twhere $a_n$ is the $n$-th term of the sequence.\n\t\\end{enumerate}\n\n\t\\item [10.]\n\tYour grandparents have an annuity. The value of the annuity increases each month by an automatic deposit of 1\\% interest on the previous month's balance. Your grandparents withdraw \\$1000 at the beginning of each month for living expenses. Currently, they have \\$50,000 in the annuity. Model the annuity with a dynamical system. Will the annuity run out of money? When? \\textit{Hint}: What value will $a_n$ have when the annuity is depleted?\n\t\n\tDenote the value of the annuity after $n$ months as $a_n$. Assuming the value of the annuity increases each month before the grandparents withdraw \\$1000, we have\n\t\\begin{align*}\n\t\ta_{n+1} &= a_n + 0.01 a_n - 1000, \\quad n=0,1,2,3,\\dots\\\\\n\t\ta_0 &= 50000\n\t\\end{align*}\n\twhere $a_n$ represents the value of the annuity after $n$ months. Since $a_{70}$ is the first negative term, the annuity will run out of money after 70 months.\n\t\n\t\\item [12.]\n\tYour current credit card balance is \\$12,000 with a current rate of 19.9\\% per year. Interest is charged monthly. Determine what monthly payment $p$ will pay off the card in \n\t\n\t\\begin{enumerate}\n\t\t\\item [12a.]\n\t\tTwo years, assuming no new charges.\n\t\t\n\t\tDenote the credit card balance after $n$ months as $a_n$. A rate of 19.9\\% per year is equal to 1.658\\% per month. Assuming the interest is charged before the monthly payment is made, we have\n\t\t\\begin{align*}\n\t\t\ta_{n+1} &= a_n +  0.01658 a_n - p, \\quad n=0,1,2,3,\\dots\\\\\n\t\t\ta_0 &= 12000\n\t\t\\end{align*}\n\t\tTo make $a_{24}$ less than or equal to 0, meaning the amount left to be paid is 0, $p$ is computed to be approximately \\$610.16.\n\t\t\n\t\t\\item [13a.]\n\t\tTwo years, assuming each month you charge \\$105.\n\t\t\n\t\tAssume \\$105 is charged before monthly interset. We have\n\t\t\\begin{align*}\n\t\t\ta_{n+1} &= 1.01658 (a_n + 105) - p, \\quad n=0,1,2,3,\\dots\\\\\n\t\t\ta_0 &= 12000\n\t\t\\end{align*}\n\t\tThe monthly payment $p$ is computed to be approximately \\$716.91.\n\t\\end{enumerate}\n\\end{enumerate}\n\n\\section*{Section 1.2}\n\\begin{enumerate}\n\t\\item [2.]\n\tThe following data represent the U.S. population from 1790 to 2010. Find a dynamical system model that fits the data fairly well. Test your model by plotting the predictions of the model against the data.\n\t\n\tLet $p_n$ denote the U.S. population $10 n$ years after 1790. Plot $p_n$ against $n$, $\\Delta p_n$ against $p_n$, and $\\Delta p_n$ against $(4\\times 10^8  - p_n) p_n$ assuming the carrying capacity is 400 millions:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\begin{subfigure}[b]{.3\\linewidth}\n\t\t\t\\caption{$p_n$ vs $n$}\n\t\t\t\\includegraphics[width=\\linewidth]{s1_2/p-n.png}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{.3\\linewidth}\n\t\t\t\\caption{$\\Delta p_n$ vs $p_n$}\n\t\t\t\\includegraphics[width=\\linewidth]{s1_2/dp-p.png}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{.3\\linewidth}\n\t\t\t\\caption{$\\Delta p_n$ vs $(4\\times 10^8  - p_n) p_n$}\n\t\t\t\\includegraphics[width=\\linewidth]{s1_2/dp-(c-p)p.png}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\tPlot (a) shows that the population is not linear correlated with the year, so we turn to the first differences. There is roughly a linear relationship in (b) but it unreasonably predicts a non-stop increase of population. Taking into account the carrying capacity, we have figure (c) where the least square estimate of the slope of the regression line is $5.9145\\times 10^{-10}$. Thus, we propose the model to be\n\t\\begin{align*}\n\t\tp_{n+1} &= p_n + 5.9145\\times 10^{-10} (4\\times 10^8 - p_n) p_n, \\quad n=0,1,2,3,\\dots\\\\\n\t\tp_0 &= 3929000\n\t\\end{align*}\n\tThe predictions of the model against the data is shown below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.5\\linewidth]{s1_2/data-pred.png}\n\t\\end{figure}\n\t\n\t\\item [3.]\n\tSociologists recognize a phenomenon called \\textit{social diffusion}, which is the spreading of a piece of information, a technological innovation, or a cultural fad among a population. The members of the population can be divided into two classes: those who have the information and those who do not. In a fixed population whose size is known, it is reasonable to assume that the rate of diffusion is proportional to the number who have the information times the number yet to receive it. If $a_n$ denotes the number of people who have the information in a population of $N$ people after $n$ days, formulate a dynamical system to approximate the change in the number of people in the population who have the information.\n\t\n\tAccording to the assumption on the rate of diffusion, \n\t\\[\n\t\\Delta a_n = k (N - a_n) a_n\n\t\\]\n\twhere $k$ is the estimated proportionality constant. Thus, we have the dynamical system\n\t\\begin{align*}\n\t\ta_{n+1} &= a_n + k (N - a_n) a_n, \\quad n=0,1,2,3,\\dots\\\\\n\t\ta_0 &= c\n\t\\end{align*}\n\twhere $c$ is the initial number of people who have the information.\n\t\n\t\\item [9.]\n\tThe data in the table show the speed $n$ (in increments of 5 mph) of an automobile and the associated distance $a_n$ in feet required to stop it once the brakes are applied. For instance $n=6$ (representing $6\\times 5 = 30$ mph) requires a stopping distance of $a_6 = 47$ ft.\n\t\\begin{enumerate}\n\t\t\\item \n\t\tCalculate and plot the change $\\delta a_n$ versus $n$. Does the graph reasonably approximate a linear relationship?\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.4\\linewidth]{s1_2/da-n.png}\n\t\t\\end{figure}\n\t\tIt reasonably approximates a linear relationship.\n\t\t\n\t\t\\item \n\t\tBased on your conclusions in part (a), find a difference equation model for the stopping distance data. Test your model by plotting the errors in the predicted values against $n$. Discuss the appropriateness of the model.\n\t\t\n\t\tSince $\\Delta a$ is proportional to $n$, and the least square estimate of the proportionality constant is approximately 3.1395, we have $\\Delta a = 3.1395 n$ and the following model\n\t\t\\begin{align*}\n\t\t\ta_{n+1} &= a_n + 3.1395 n, \\quad n=1,2,3,\\dots\\\\\n\t\t\ta_1 &= 3\n\t\t\\end{align*}\n\t\tThe plots of predicted values and the errors are shown below:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\begin{subfigure}[b]{.4\\linewidth}\n\t\t\t\t\\caption{True and Predicted}\n\t\t\t\t\\includegraphics[width=\\linewidth]{s1_2/9-data-pred.png}\n\t\t\t\\end{subfigure}\n\t\t\t\\begin{subfigure}[b]{.4\\linewidth}\n\t\t\t\t\\caption{Error}\n\t\t\t\t\\includegraphics[width=\\linewidth]{s1_2/9-error.png}\n\t\t\t\\end{subfigure}\n\t\t\\end{figure}\n\t\tThe errors are small so the model is appropriate.\n\t\\end{enumerate}\n\\end{enumerate}\n\n\\end{document}\n\n", "meta": {"hexsha": "2521775f08ae5909e97370a7da7fa462054eb6c9", "size": 8652, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW1/Math-380-HW1.tex", "max_stars_repo_name": "ZhihaoAi/MATH-380-Assignments", "max_stars_repo_head_hexsha": "17595db9759115281e95c51d4e40c7b71e337de2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW1/Math-380-HW1.tex", "max_issues_repo_name": "ZhihaoAi/MATH-380-Assignments", "max_issues_repo_head_hexsha": "17595db9759115281e95c51d4e40c7b71e337de2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW1/Math-380-HW1.tex", "max_forks_repo_name": "ZhihaoAi/MATH-380-Assignments", "max_forks_repo_head_hexsha": "17595db9759115281e95c51d4e40c7b71e337de2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.9743589744, "max_line_length": 722, "alphanum_fraction": 0.7098936662, "num_tokens": 2826, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.44867500264111965}}
{"text": "\n\\documentclass[11pt]{article}\n\n\\usepackage{common}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\title{HW1: Classification}\n\\author{Emily Tseng \\\\ et397@cornell.edu}\n\\begin{document}\n\n\\maketitle{}\n\\section{Introduction}\n\nGiven a sentence from a movie review, e.g. ``\\textit{Never inspires more than an interested detachment.}'', how might we classify its sentiment, in this case \\textit{negative}? \n\nIn this assignment, we use the implementation of a handful of basic statistical models for this task to familiarize ourselves with core concepts and technologies in modern NLP. Specifically, we explored the use of the following models:\n\n\\begin{itemize}\n  \\item \\textbf{Multinomial Naive Bayes (MNB)}, as outlined in \\cite{wang2012baselines}\n  \\item \\textbf{Logistic Regression (LR)}\n  \\item \\textbf{Continuous Bag of Words (CBOW)}, as outlined in \\cite{mikolov2013efficient}\n  \\item \\textbf{Convolutional Neural Network (CNN)}, as outlined in \\cite{kim2014convolutional}\n  \\item \\textbf{CNN*}, a variant of the CNN using pretrained word embeddings\n\\end{itemize}\n\nAs a dataset, we used the Stanford Sentiment Treebank (SST-2) \\citep{socher2013recursive}, which provides a corpus of sentences from movie reviews labeled as \\textit{positive}, \\textit{negative}, or \\textit{neutral}. For this assignment, we removed neutral samples and formulated the task as a binary classification problem between positive and negative sentiment.\n\n\n\\section{Problem Description}\n\nGiven a sentence represented as a feature vector $\\boldx$, we can find its predicted class $y \\in \\{-1, 1\\}$, where -1 indicates negative sentiment and 1 indicates positive sentiment, via:\n\\begin{align}\n  y = \\sigma(\\boldW\\boldx + \\boldb)\n\\end{align}\n\nWhere $\\sigma$ is an activation function, $\\boldW$ is a matrix of weights, and $\\boldb$ is a vector of biases. $\\boldx$ itself is generated using a feature function $\\phi$, which can take a number of forms. We elaborate on the specific structures used per model in the subsequent section.\n\n\\section{Model and Algorithms}\n\n\\subsection{Multinomial Naive Bayes (MNB) over unigrams}\n\nAs formulated in \\cite{wang2012baselines}, we consider the linear model where a prediction for test case $k$ is expressed as:\n\\begin{align}\n  y^{(k)} = sign(\\boldW^{T}\\boldx^{(k)} + b)\n\\end{align}\n\nWe consider as features the unigrams within vocabulary $\\mcV$, and define $\\boldf^{(i)} \\in \\mathbb{R}^{|\\mcV|}$ as the feature count vector for training case $i$ with label $y^{(i)} \\in \\{-1, 1\\}$. $\\boldf^{(i)}_j$ is thus the number of occurrences of feature $j$ in training sample $i$. We additionally consider the log-count ratio $r$ of the two count vectors $\\boldp$ and $\\boldq$, given smoothing parameter $\\alpha$:\n\\begin{align}\n  \\boldp &= \\alpha + \\sum_{i:y^{(i)}=1}{\\boldf^{(i)}} \\\\\n  \\boldq &= \\alpha + \\sum_{i:y^{(i)}=-1}{\\boldf^{(i)}} \\\\\n  \\boldr &= log(\\frac{\\boldp / ||\\boldp||_1}{\\boldq / ||\\boldq||_1})\n\\end{align}\n\nIn this implementation, we consider \\textit{binarized count vectors}, in which $\\hat{\\boldf}_j$ is 1 if feature $j$ occurs at least once in the sentence, and 0 otherwise. We additionally consider our weights $\\boldW$ as a vector of log-count ratios, and use as a bias the log-ratio of the number of positive to negative samples. Formally, we define as parameters the following, where $N+$ is the number of positive samples and $N-$ is the number of negative samples:\n\n\\begin{align}\n  \\boldx^{(k)} &= \\hat{\\boldf}^{(k)}, \\hat{\\boldf}^{(k)} = \\textbf{1}\\{f^{(k)} > 0\\} \\\\\n  \\boldW^T &= \\hat{\\boldr} = log(\\frac{\\hat{\\boldp} / ||\\hat{\\boldp}||_1}{\\hat{\\boldq} / ||\\hat{\\boldq}||_1}) \\\\\n  \\hat{\\boldp} &= \\alpha + \\sum_{i:y^{(i)}=1}{\\hat{\\boldf}^{(i)}} \\\\\n  \\hat{\\boldq} &= \\alpha + \\sum_{i:y^{(i)}=-1}{\\hat{\\boldf}^{(i)}} \\\\\n  b &= log(\\frac{N+}{N-})\n\\end{align}\n\n\\subsection{Logistic Regression}\n\nRecalling (1), we express this model as a single-layer, fully-connected neural network using a sigmoid activation $\\sigma$ to learn weight matrix $\\boldW$ and bias vector $\\boldb$. Here, $\\boldx^{(i)}$ represents an input sentence as binarized counts of words in vocabulary $\\mcV$, as in (6). The outputs $\\boldy$ are thus 1x2 vectors representing the distribution over the two classes, and we take the argmax of $\\boldy$ as the prediction. Our implementation randomly initializes all model parameters, uses Pytorch's built-in CrossEntropy loss function and standard stochastic gradient descent (SGD) optimizer, and backpropagates loss at each batch.\n\n\\subsection{CBOW}\n\nThe Continuous Bag of Words (CBOW) model as described in \\citep{mikolov2013efficient} represents an input sentence $\\boldx^{(i)}$ of length $n$ as a $k$-dimensional embedding vector $\\bolde$ produced by averaging the individual $k$-dimensional embeddings for each word in the sentence. Formally:\n\\begin{align}\n  \\bolde = \\frac{1}{n} \\sum_{i=1}^{n} \\bolde_i\n\\end{align}\n\nThis embedding is the input to a single-layer, fully-connected neural network using a softmax activation to learn a weight matrix and bias vector, as before. We take the argmax of the output of this linear layer as the prediction. As before, our implementation randomly initializes all model parameters, including the embeddings $\\mcE$.\n\n\n\\subsection{CNN}\n\nThe Convolutional Neural Network (CNN) approach to sentence classification as described in \\cite{kim2014convolutional} represents input sentences as the concatenation of fixed-length embeddings. In other words, for an input sentence of length $n$:\n\\begin{align}\n  \\boldx_{1:n} = x_1 \\oplus x_2 \\oplus ... \\oplus x_{n-1} \\oplus x_n\n\\end{align}\n\nThis input is put through a convolutional layer consisting of a set of \\textit{filters}. A filter generates a new feature thus:\n\\begin{align}\n  c_i = f(\\boldw\\boldx_{i:i+h-1} + b)\n\\end{align}\n\nwhere $f$ is a non-linear activation function such as the rectified linear unit (ReLU), $\\boldw$ is the filter, $h$ is the window size for that convolutional layer, and $b$ is a bias term. Filters are applied over every possible \\textit{window} (or \\textit{kernel}) of the input to generate a feature map:\n\\begin{align}\n  \\boldc = [c_1, c_2, ... c_{n-h+1}]\n\\end{align}\n\nA max-pooling over time operation is then applied over the feature map, which outputs the $c_i$ with the highest value as the value for that feature.\n\nIn our implementation, we follow \\cite{kim2014convolutional} and use the ReLU nonlinearity, filters with window sizes 3, 4 and 5, a dropout rate of $p=0.5$ to regularize against overfitting during training, and a softmax activation function over the final output. The argmax of the output of this final layer is our prediction. Of note, in our implementation we padded inputs to a minimum length of 5 to ensure the provided window sizes would work.\n\n\\subsection{CNN*}\n\nThe CNN model above is initialized with random values as the initial word embeddings. We also experimented with a variant that initialized with pretrained word embeddings, but otherwise used the same structure as the CNN described above. \n\n\\section{Experiments}\n\nAs depicted in Table \\ref{tab:results}, our results show that when the learned models (LR, CBOW, CNN and CNN*) are trained for 20 epochs with a learning rate of $5e^{-2}$, MNB performs best, with a test-set accuracy of 0.82.\n\n\\begin{table}[h]\n  \\centering\n  \\begin{tabular}{llr}\n   \\toprule\n   Model &  & Test Acc. \\\\\n   \\midrule\n   \\textsc{MNB} & & 0.82\\\\\n   \\textsc{LR} & & 0.71\\\\\n   \\textsc{CBOW} & & 0.77 \\\\\n   \\textsc{CNN} & & 0.70 \\\\\n   \\textsc{CNN*} & & 0.78 \\\\\n   \\bottomrule\n  \\end{tabular}\n  \\caption{\\label{tab:results} Results from each model. LR, CBOW, CNN and CNN* models run with $lr=5e^{-2}$, $epochs=20$.}\n  \\end{table}\n\n% CBOW 5e-2, NLLLoss, Adam: 0.77\n\nOf note, the CBOW experiments used Pytorch's built-in NLLLoss loss function and the Adam optimizer, while the CNN and CNN* experiments used NLLLoss and the Adadelta optimizer per \\cite{kim2014convolutional}. The LR experiments used Pytorch's built-in CrossEntropy and the Adam optimizer.\n\nExamination of the losses per epoch shows the learned models are in fact learning, e.g. the losses per epoch decrease over training time (Figure \\ref{fig:losses}). From this we infer the low accuracies for the learned models are due to the training parameters used, and do not accurately speak to their performance relative to MNB.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=4in]{losses.png}\n  \\caption{\\label{fig:losses} Losses over time for the four learned models. All models trained with $lr=5e^{-2}$, $epochs=20$.}\n\\end{figure}\n\nStill, we can draw conclusions from the relative differences in performance between the learned models: for instance, CNN* significantly outperforms CNN, as expected.\n\n\\section{Conclusion}\n\nThis assignment explored the use of 5 simple models for text classification, as a way to gain familiarity with the tools to be used in this course. \n\nWe implemented one count-based model, the Multinomial Naive Bayes (MNB), and four learned models, Logistic Regression (LR), Continuous Bag-of-Words (CBOW), Convolutional Neural Network (CNN) and a variant of the CNN initialized with pretrained word embeddings (CNN*). As shown in Table \\ref{tab:results}, MNB performed best in our set of experiments, with a test-set accuracy of 0.82. Trained for 20 epochs with a learning rate of $5e^{-2}$, the four learned models (LR, CBOW, CNN, CNN*) did not perform as well as the MNB standard, but the relative accuracies achieved by these models highlight the differences between them. Notably, CNN* significantly outperformed CNN, as expected.\n\nFurther work might investigate additional hyperparameter tuning schemes to refine the learned models, for example by using learning rate annealing techniques. Further work should also pursue the use of novel representations of words and sentences as inputs to these models, for instance larger pretrained word embeddings derived from different sources (e.g. BERT), the use of parse trees and other semantic information, or even simply additional hand-tuned features, such as bigram and trigram frequencies.\n\n\n\\bibliographystyle{apalike}\n\\bibliography{writeup}\n\n\\end{document}\n", "meta": {"hexsha": "dc37dfb4d1d0107679dccf1f8cea299553017845", "size": 10117, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw1/writeup/writeup.tex", "max_stars_repo_name": "emtseng/cs6741", "max_stars_repo_head_hexsha": "caf94f60c06e789ba467d946babe0f43b1f37b76", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw1/writeup/writeup.tex", "max_issues_repo_name": "emtseng/cs6741", "max_issues_repo_head_hexsha": "caf94f60c06e789ba467d946babe0f43b1f37b76", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw1/writeup/writeup.tex", "max_forks_repo_name": "emtseng/cs6741", "max_forks_repo_head_hexsha": "caf94f60c06e789ba467d946babe0f43b1f37b76", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.0, "max_line_length": 684, "alphanum_fraction": 0.7446871602, "num_tokens": 2748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553658, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4485457618015887}}
{"text": "\n%%==============================\n%% Section 4.01.01: DE $\\implies$ IE (Temporary Title)\n%%==============================\n\n\n\\documentclass[../dissertation.tex]{subfiles}\n\n\\begin{document}\n\\subsection{Jost Solutions Solve the Integral Equations}\\label{subsec4:DEtoIE}\n\nIn this subsection we prove that Jost solutions also solve the \ncorresponding integral equation, as respectively \ndefined in Definitions \\ref{dfn4:DEsoln} and \\ref{dfn4:IEsoln}. We do \nso in two phases: first for $\\lambda \\ne 0$ (Lemma \\ref{lma4:DEtoIE1}), and then \nfor $\\lambda = 0$ (Lemma \\ref{lma4:DEtoIE2}). \n\n\\begin{lma}\\label{lma4:DEtoIE1}\n\tA Jost solution $M$ satisfying Definition \\ref{dfn4:DEsoln} also solves the \n\tassociated integral equation \\ref{eq4:MPluseq} in the sense of Definition \n\t\\ref{dfn4:IEsoln} whenever $\\lambda \\in \\mathbb R \\sm \\{0\\}$.\n\\end{lma}\n\\begin{proof}\n\tProposition \\ref{prop3:BndryRelProp} implies \n\t$\\wh{M^-} = e^{-2\\xi} \\wh{M^+}$. Moreover, $\\wh{M^+}$ is a tempered \n\tdistribution by the hypothesis of Definition \\ref{dfn4:DEsoln} which means\n\tthat $e^{2\\xi} \\wh{M^-}$ is also tempered. Taking the distribution Fourier\n\ttransform of both sides of \\eqref{eq4:LinSpecProb} we consequently find\n\t\\begin{align}\\label{eq3:DEtoIEsymbol}\n\t\t\\wh{uM^+} \n\t\t\t&= \\xi \\wh{M^+} - \\zeta\\left( \\wh{M^+} - \\wh{M^-} \\right) \\\\\n\t\t\t&= \\left(\\xi - \\zeta(1-e^{-2\\xi})\\right) \\wh{M^+} \\nonumber \\\\\n\t\t\t&= p(\\xi) \\wh{M^+} \\nonumber \n\t\\end{align}\n\tin the sense of distributions in $\\mathcal D'(\\mathbb R)$. To avoid the \n\tzeros of the symbol $p$, we rewrite \\eqref{eq3:DEtoIEsymbol} as \n\t\\begin{align}\\label{eq3:peps}\n\t\tp(\\xi - i\\varepsilon) \\wh{M^+} \n\t\t\t= [p(\\xi - i\\varepsilon) - p(\\xi)] \\wh{M^+} + \\wh{uM^+}\n\t\\end{align}\n\tfor $0< \\varepsilon \\ll 1$ and introduce the approximate Green's function \n\t\\begin{align}\\label{eq4:approxGF}\n\t\tG_L^\\varepsilon(x; \\lambda) \n\t\t\t= \\frac{1}{2\\pi} \n\t\t\t\t\\int_{\\mathbb R} \n\t\t\t\t\te^{ix\\xi} \\frac{1}{p(\\xi - i \\varepsilon)}\n\t\t\t\t\\,d\\xi.\n\t\\end{align}\n\tUsing the contour shift \n\t$\\mathbb R-i\\varepsilon \\mapsto \\mathbb R + i \\sign(x) \\pi$\n\tin our work from Section \\ref{sec1:GreensFunctions} to prove\n\t\\eqref{eq1:GLrep} shows that\n\t\\begin{align}\\label{eq3:GLeps}\n\t\tG_L^\\varepsilon(x; \\lambda)\n\t\t\t=\n\t\t\t\t\\begin{cases}\n\t\t\t\t\tK^+(x; \\lambda) \n\t\t\t\t\t\t+ i\n\t\t\t\t\t\t\\big[ \n\t\t\t\t\t\t\t\\alpha(\\lambda) \n\t\t\t\t\t\t\t+ \\beta(\\lambda) e^{i\\lambda x}\n\t\t\t\t\t\t\\big] e^{-\\varepsilon x} \\, \\chi_L(x)\n\t\t\t\t\t\t& \\lambda \\ne 0 \\\\\n\t\t\t\t\tK^+(x; \\lambda) \n\t\t\t\t\t\t+ i\n\t\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\t\\frac{2}{3} + i x\n\t\t\t\t\t\t\\right] e^{-\\varepsilon x} \\, \\chi_L(x)\n\t\t\t\t\t\t& \\lambda = 0\n\t\t\t\t\\end{cases}\n\t\\end{align}\n\twhere $K^+$ is as defined in Theorem \\ref{thm1:GFRep}\n\t\\[\n\t\tK^+(x) \n\t\t\t= \\frac{e^{-\\pi|x|}}{2\\pi}\n\t\t\t\t\\int_{\\mathbb R}\n\t\t\t\t\te^{ix\\xi}\n\t\t\t\t\t\\frac{1}{p(\\xi)+i \\sign(x) \\pi}\n\t\t\t\t\\, \\mathrm{d}\\xi.\n\t\\]\n\tAn immediate consequence of \\eqref{eq1:GLrep} and \\eqref{eq3:GLeps} is that\n\t\\begin{align*}\n\t\tG_L^+(x; \\lambda) - G_L^\\varepsilon(x; \\lambda)\n\t\t\t&= i \n\t\t\t\t\\Big[ \n\t\t\t\t\t\\alpha(\\lambda) \n\t\t\t\t\t+ \\beta(\\lambda) e^{ix\\lambda}\n\t\t\t\t\\Big]\n\t\t\t\t\\big(1-e^{-\\varepsilon x}\\big)\n\t\t\t\t\\chi_{(0, \\infty)}.\n\t\\end{align*}\n\tHence, we see from \\eqref{eq2:polesumbnd} that\n\t\\begin{align}\\label{eq3:GLminusGeps}\n\t\t\\big| \\left(G_L^+ - G_L^\\varepsilon\\right)*f(x) \\big|\n\t\t\t\\lesssim \\int_{-\\infty}^x \n\t\t\t\t\t\\left[ 1 -e^{-\\varepsilon(x - x')}  \\right] |f(x')| \n\t\t\t\t\\, \\mathrm{d}x'.\n\t\\end{align}\n\tfor real $\\lambda\\ne0$. \n\n\tThe distribution identity $\\wh 1 = 2\\pi\\delta_0$ (where $\\delta_0$ denotes a \n\tDirac delta-function centered at $\\xi=0$) allows us ``subtract 1'' from both\n\tsides of \\eqref{eq3:peps} to obtain\n\t\\begin{align*}\n\t\t&p(\\xi -i \\varepsilon)(\\wh{M^+-1})(\\xi) + 2\\pi \\, p(\\xi-i\\varepsilon)\\,\\delta_0 \\\\\n\t\t&\\qquad\\qquad= [p(\\xi-i\\varepsilon) - p(\\xi)]\n\t\t\t\t\t\t(\\wh{M^+-1})(\\xi) \n\t\t\t\t\t\t+ 2\\pi\\,p(\\xi-i\\varepsilon)\\,\\delta_0 + \\wh{uM^+}\n\t\\end{align*}\n\tDividing both sides by $p(\\xi-i\\xi)$\\textemdash{}since it has no zeros \n\tfor $\\xi\\in \\mathbb R$\\textemdash{}we have\n\t\\begin{align}\\label{eq3:Mfouriered}\n\t\t(\\wh{M^+ -1})(\\xi) \n\t\t\t= \\frac{p(\\xi-i\\varepsilon) - p(\\xi)}{p(\\xi - i\\varepsilon)}(\\wh{M^+-1})(\\xi)\n\t\t\t\t+ \\frac{1}{p(\\xi - i\\varepsilon)} \\wh{uM^+}.\n\t\\end{align}\n\tWe therefore see from \\eqref{eq3:Mfouriered} that in order to verify that $M^+$ satisfies\n\tdefinition \\ref{dfn4:IEsoln}, it suffices to prove that the following two limits\n\t\\begin{subequations}\n\t\t\\label{eq3:suff}\n\t\t\\begin{align}\n\t\t\t\\label{eq3:suff1}\n\t\t\t\\lim_{\\varepsilon \\searrow 0} \\mathcal F^{-1}\n\t\t\t\t \t\\left[\\frac{1}{p(\\xi - i\\varepsilon)} \\wh{uM^+}\\right](x)\n\t\t\t\t &= G_L^+*(uM)(x)\n\t\t\\end{align}\n\t\tand\n\t\t\\begin{align}\n\t\t\t\\label{eq3:suff2}\n\t\t\t\t\\lim_{\\varepsilon \\searrow 0} \\mathcal F^{-1}\n\t\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\t\\frac{p(\\xi-i\\varepsilon) - p(\\xi)}{p(\\xi-i\\varepsilon)}\n\t\t\t\t\t\t\t(\\wh{M^+-1})(\\xi) \n\t\t\t\t\t\t\\right]\n\t\t\t\t\t\t(x)\n\t\t\t\t\t&= 0\n\t\t\\end{align}\n\t\\end{subequations}\n\thold for \\textit{a.e.} $x$.\n\n\tSince $uM^+ \\in L^1(\\mathbb R)$, \\eqref{eq3:suff1} follows from estimate \n\t\\eqref{eq3:GLminusGeps} and the Dominated Convergence Theorem. \n\n\tTo verify \\eqref{eq3:suff2}, first note that \n\t\\begin{align*}\n\t\t\\frac{p(\\xi - i\\varepsilon) - p(\\xi)}{p(\\xi - i \\varepsilon)}\n\t\t\t= \\frac{-i \\varepsilon + \\zeta e^{-2\\xi}\\left(1-e^{2i\\varepsilon}\\right)}\n\t\t\t\t\t{p(\\xi-i\\varepsilon)},\n\t\\end{align*}\n\twhich means it suffices to prove \n\t\\begin{subequations}\n\t\t\\label{eq3:secondlims}\n\t\t\\begin{align} \\label{eq3:secondlims1}\n\t\t\t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M^+-1})(\\xi) \n\t\t\t\t\t\\right](x) \n\t\t\t= 0\n\t\t\\end{align}\n\t\tand\n\t\t\\begin{align} \\label{eq3:secondlims2}\n\t\t\t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t(1-e^{2i\\varepsilon}) \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{e^{-2\\xi}}{p(\\xi-i\\varepsilon)} (\\wh{M^+-1})(\\xi) \n\t\t\t\t\t\\right](x) \n\t\t\t= 0.\n\t\t\\end{align}\n\t\\end{subequations}\n\n\n\n\tFrom the definition of $G_L^\\varepsilon$ and \\eqref{eq3:GLeps} we see that\n\t\\begin{align*}\n\t\t\\mathcal F^{-1}\n\t\t\t\t\\left[ \n\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M^+-1})(\\xi) \n\t\t\t\t\\right](x) \n\t\t\t&= G_L^\\varepsilon * (M^+-1)\n\t\\end{align*}\n\tand\n\t\\begin{align*}\n\t\tG_L^\\varepsilon * (M^+-1)(x)\n\t\t\t&= i \\alpha(\\lambda) \\, \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\te^{-\\varepsilon(x - x')} \\big(M^+(x')-1\\big) \n\t\t\t\t\\, \\mathrm{d}x' \\\\\n\t\t\t&\\quad + i \\beta(\\lambda) \\, \n\t\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\t\te^{i\\lambda (x-x')} e^{-\\varepsilon(x-x')}\\big(M^+(x')-1\\big) \n\t\t\t\t\t\\, \\mathrm{d}x' \\\\\n\t\t\t&\\quad + \\left( \n\t\t\t\t\t\t\\int_{-\\infty}^x K^+(x- x') + \\int_{x}^\\infty K^+(x - x') \n\t\t\t\t\t\\right)\n\t\t\t\t\t\\big(M^+(x')-1\\big) \\, \\mathrm{d}x'\n\t\\end{align*}\n\tThus, since $e^{i\\lambda (x-x')}$ is a unitary phase (\\textit{i.e.} has complex \n\tmodulus 1), in order to verify \\eqref{eq3:secondlims1}, we need to show that\n\t\\begin{subequations}\n\t\t\\label{eq3:thirdlims}\n\t\t\\begin{align}\n\t\t\t\\label{eq3:thirdlims1}\n\t\t\t\\lim_{\\varepsilon\\searrow 0} \\varepsilon \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\te^{-\\varepsilon(x-x')} |M^+(x') - 1| \n\t\t\t\t\\, \\mathrm{d}x' = 0\n\t\t\\end{align}\n\t\tand\n\t\t\\begin{align}\n\t\t\t\\label{eq3:thirdlims2}\n\t\t\t\\lim_{\\varepsilon\\searrow 0} \\varepsilon \n\t\t\t\t\t\\int_{\\mathbb R} K^+(x- x') \\big(M^+(x')-1\\big) \\, \\mathrm{d}x'\n\t\t\t\t= 0.\n\t\t\\end{align}\n\t\\end{subequations}\n\tTo prove \\eqref{eq3:thirdlims1}, we choose an arbitrary $\\varepsilon'>0$, \n\tsplit the integral $\\int_{-\\infty}^x$ into $\\int_{-\\infty}^{x-L} + \\int_{x-L}^x$, \n\tand use the fact that $M^+(x) \\to 0$ as $x \\to -\\infty$ to choose $L>0$ \n\tsufficiently large that $|M^+(x')  - 1| < \\varepsilon'/2$ for $x' < x-L$. Then,\n\tsince \n\t\\[\n\t\t\\int_{-\\infty}^{x-L} e^{-\\varepsilon (x-x')} \\,dx'\n\t\t\t= \\int_{-\\infty}^{-L} e^{\\varepsilon t} \\, \\mathrm{d}t\n\t\t\t< \\int_{-\\infty}^0 e^{\\varepsilon t} \\, \\mathrm{d}t \n\t\t\t= \\frac{1}{\\varepsilon},\n\t\\]\n\twhere $t = x'-x$, we have\n\t\\begin{align} \\label{eq3:DEtoIEthirdlim1v1}\n\t\t\\varepsilon \\int_{-\\infty}^{x-L} e^{-\\varepsilon(x-x')} |M(x') - 1| \\,dx'\n\t\t\t< \\frac{\\varepsilon'}{2} \\, \\varepsilon \\, \\int_{-\\infty}^{x-L} e^{-\\varepsilon(x-x')} \\, \\mathrm{d}x'\n\t\t\t< \\frac{\\varepsilon'}{2}.\n\t\\end{align}\n\tNow, since $M^+$ is continuous, $M^+-1$ is bounded by $\\varepsilon'/2$ on $(\\infty, x-L)$,\n\tand $[x-L, x]$ is compact, there exists a constant $C_x > 0$ depending only on $x$\n\tso that $\\sup_{x'\\leq x-L}|M^+(x')-1| \\leq C_x$. \n\tSet $\\delta':= \\frac{\\varepsilon'}{2 L C_x}$.\n\tFor all $\\varepsilon < \\delta'$, we have\n\t\\begin{align} \\label{eq3:DEtoIEthirdlim1v2}\n\t\t\\varepsilon \\int_{x-L}^{x} e^{-\\varepsilon(x-x')} |M(x') - 1| \\,dx'\n\t\t\t\\leq \\varepsilon \\, C_x \\int_{-L}^0 e^{\\varepsilon x'} \\, \\mathrm{d}x'\n\t\t\t< \\frac{\\varepsilon'}{2},\n\t\\end{align}\n\tas $e^{\\varepsilon x'} \\leq 1$ for $x' \\leq 0$ implies \n\t$\\int_{-L}^0 e^{\\varepsilon x'} \\, \\mathrm{d}x'\\leq L$. Limit \\eqref{eq3:thirdlims1} follows\n\tfrom \\eqref{eq3:DEtoIEthirdlim1v1} and \\eqref{eq3:DEtoIEthirdlim1v2}.\n\n\tSince we proved that $K^+\\in \\mathcal S(\\mathbb R)$ in Section \\ref{sec1:AsympK}\n\tand therefore in $L^1(\\mathbb R)$, limit \\eqref{eq3:secondlims2} is an \n\timmediate consequence of Definition \\ref{dfn4:DEsoln}(ii) which states\n\tthat $M^+ \\in L^\\infty(\\mathbb R)$.\n\n\tLastly, to complete the proof that $M^+$ satisfies Definition \\ref{dfn4:IEsoln}, \n\twe now verify limit \\eqref{eq3:secondlims2}. To do so, observe that \n\tit suffices by the Taylor expansion of $1-e^{2i\\varepsilon}$ \n\tto verify the (slightly) simpler limit\n\t\\begin{align}\\label{eq3:simpler}\n\t \t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{e^{-2\\xi}}{p(\\xi-i\\varepsilon)} (\\wh{M^+-1})(\\xi) \n\t\t\t\t\t\\right](x)\n\t\t\t= 0,\n\t\\end{align} \n\n\tWe use Proposition \n\t\\ref{prop3:BndryRelProp} and Definition \\ref{dfn4:DEsoln}(v) to rewrite\n\t\\eqref{eq3:simpler} as \n\t\\begin{align}\n\t\t% &\\lim_{\\varepsilon \\searrow 0} \n\t\t% \t\t\\varepsilon \\, \\mathcal F^{-1}\n\t\t% \t\t\t\\left[ \n\t\t% \t\t\t\t\\frac{e^{-2\\xi}}{p(\\xi-i\\varepsilon)} (\\wh{M^+-1})(\\xi) \n\t\t% \t\t\t\\right](x) \\\\\n\t\t% &\\qquad\\qquad= \\lim_{\\varepsilon \\searrow 0} \n\t\t&\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\, \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M^--1})(\\xi) \n\t\t\t\t\t\\right](x)\n\t\t\t\t\t\\\\\n\t\t&\\qquad\\qquad= \\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\, \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M_c^--1})(\\xi) \n\t\t\t\t\t\\right](x) \n\t\t\t\t\\nonumber \\\\\n\t\t&\\qquad\\qquad\\quad+ \\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\, \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M_s^-})(\\xi) \n\t\t\t\t\t\\right](x)\n\t\t\t\t\\nonumber\n\t\\end{align}\n\tAn analogous argument to the one employed to verify \\eqref{eq3:secondlims1} \n\tshows\n\t\\[\n\t\t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\varepsilon \\, \\mathcal F^{-1}\n\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\\frac{1}{p(\\xi-i\\varepsilon)} (\\wh{M_c^--1})(\\xi) \n\t\t\t\t\t\\right](x) \n\t\t\t= 0.\n\t\\]\n\t%%========================================\n\t%% Begin thievery from Prof. Perry's notes\n\t%% Rewrite this section later.\n\t%%========================================\n\tTo analyze the second right-hand term, we again appeal to the representation \n\t\\eqref{eq3:GLeps}. The ``pole terms'' in \\eqref{eq3:GLeps} give\n\ttwo terms which can be estimated by\n\t\\[\n\t\t\\varepsilon \\int_{-\\infty}^x e^{-\\varepsilon(x-x')} |M_s^-(x')| \\, \\mathrm{d}x'\n\t\\]\n\twhich is $\\mathcal O\\left(\\varepsilon^{1/2}\\right)$ by the Schwartz inequality. \n\tTo control the integrals involving $K^\\pm$, we again use the $L^2$ \n\tbound on $M_s^-$ to show that the integrals \n\t\\[\n\t\t\\int_{\\mathbb R} |K_\\pm(x-x')| |M_s^-(x')| \\, \\mathrm{d}x\n\t\\]\n\tconverge, and hence the corresponding terms are \n\t$\\mathcal O\\left(\\varepsilon\\right)$.\n\\end{proof}\n\nWe now finish our proof that Jost solutions solve the associated integral \nequation by considering the case where $\\lambda = 0$.\n\n\\begin{lma}\\label{lma4:DEtoIE2}\n\tLet $\\lambda =0$ and suppose $M$ is a Jost solution in accordance \n\twith Definition \\ref{dfn4:DEsoln}. Then $M$ is a solution for \n\t\\ref{eq4:MPluseq} as specified in Definition \\ref{dfn4:IEsoln}.\n\\end{lma}\n\\begin{proof}\n\tAs in the proof of Lemma \\ref{lma4:DEtoIE1}, we begin with the distribution \n\tidentity $p(\\xi;\\lambda) \\widehat{M^+} = \\widehat{u\\,M^+}$, which may be rewritten as\n\t\\[ \n\t\tp(\\xi,\\lambda) \\widehat{M^+-1} = \\widehat{u\\,M^+},\n\t\\]\n\tsince $p(0;\\lambda)=0$. Mimicking our proof of Lemma \\ref{lma4:DEtoIE1}, we write\n\t\\[ \n\t\tp(\\xi-i\\varepsilon) \\widehat{M^+-1} \n\t\t\t= \\left[ p(\\xi-i\\varepsilon) - p(\\xi) \\right] \\widehat{M^+-1} \n\t\t\t\t+ \\widehat{u\\,M^+},\n\t\\]\n\twhere here and in what follows we write $p(\\xi)$ for $p(\\xi; \\lambda = 0)$ \n\tsince $\\lambda = 0$ is fixed throughout. Dividing we get\n\t\\begin{equation}\n\t\t\\label{Jost.half.pre-int}\n\t\t\\widehat{M^+-1} \n\t\t\t= \\frac{p(\\xi-i\\varepsilon) - p(\\xi)}{p(\\xi-i\\varepsilon)} \n\t\t\t\t\t\\widehat{M^+-1} \n\t\t\t\t+ \\frac{\\widehat{u\\,M^+}}{p(\\xi-i\\varepsilon)}.\n\t\\end{equation}\n\tWe wish to show that, on taking inverse Fourier transforms and taking \n\t$\\varepsilon \\searrow 0$, we obtain\n\t\\[\n\t\tM^+(x)-1 = G_L*(u\\,M^+).\n\t\\]\n\tRecalling the definition the approximate Green's function\n\t\\[\n\t\tG_L^\\varepsilon(x) \n\t\t\t= \\frac{1}{2\\pi} \\int \\frac{e^{ix\\xi}}{p(\\xi-i\\varepsilon)} \\, \\mathrm{d}\\xi\n\t\\]\n\tfrom Equation \\ref{eq4:approxGF} in the proof of Lemma \\ref{lma4:DEtoIE1}, \n\twe note that\n\t\\begin{equation}\n\t\t\\label{GL.eps}\n\t\t G_L^\\varepsilon(x) \n\t\t \t= \n\t\t \t\ti \\left(\\frac{2}{3} + i x \\right)\n\t\t \t\te^{-\\varepsilon x} \\chi_L(x) \n\t\t \t\t+ e^{-\\pi|x|} k(x),\n\t\\end{equation}\n\twhere $k(x)$ is as defined in Remark \\ref{rmk1:littlek}.\n\n\tThus the inverse Fourier transform of the second right-hand term in \n\t\\eqref{Jost.half.pre-int} is given by\n\t\\begin{align*}\n\t\\mathcal F^{-1} \\left( \\frac{\\widehat{uM}}{p(\\xi-i\\varepsilon)} \\right)(x)\n\t\t&=\n\t\t\ti\n\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\\left( \\frac{2}{3} + i (x-x') \\right) \n\t\t\t\te^{-\\varepsilon(x-x')} u(x') M(x') \\, \\mathrm{d}x' \\\\\n\t\t&\\quad + \\int_{\\mathbb R} e^{-\\pi|x-x'|} k(x-x')  u(x') M(x') \\, \\mathrm{d}x'.\n\t\\end{align*}\n\tIt follows by dominated convergence that this expression approaches\n\t$G_L*(uM)(x)$ pointwise as $\\varepsilon \\searrow 0$ as \n\t$u\\in L^{2,4}(\\mathbb R)$ implies \n\t$u \\in L^{1,1}(\\mathbb R) \\cap L^2(\\mathbb R)$. \n\n\tIt remains to show that the first term vanishes pointwise as \n\t$\\varepsilon \\searrow 0$. We write\n\t\\begin{align*}\n\t\t\\mathcal F^{-1} \n\t\t\t\t\\left( \n\t\t\t\t\t\\frac{p(\\xi-i\\varepsilon) - p(\\xi)}\n\t\t\t\t\t\t{p(\\xi-i\\varepsilon)} \\widehat{M^+-1} \n\t\t\t\t\\right)\n\t\t\t&=\ti\\varepsilon G_L^\\varepsilon * (M^+ -1) \\\\\n\t\t\t&\\quad- \n\t\t\t\t\\frac{1}{2} \\left(e^{2i\\varepsilon}-1 \\right) \n\t\t\t\tG_L^\\varepsilon*(M^- - 1)\n\t\\end{align*}\n\twhere we used $\\widehat{M^-} = e^{-2\\xi} \\widehat{M^+}$. The goal is to use\n\tthe asymptotic behavior of $M^+$ and $M^-$ as $x \\to -\\infty$ to show that \n\tthese terms vanish as $\\varepsilon \\searrow 0$. Due to the linear growth \n\tof the Green's function we need a more stringent rate of decay for \n\t$M^+-1$ and $M^- - 1$ as $x \\to -\\infty$ to control convolution with the pole \n\tterm in $G_L^\\varepsilon$.  \n\n\tFirst we consider \n\t\\begin{align*}\n\t\ti\\varepsilon \\, G_L^\\varepsilon*(M^+ - 1) (x) \n\t\t\t&=\t\n\t\t\t\t-\\varepsilon \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\t\\left( \\frac{2}{3} + i(x-x') \\right) \n\t\t\t\t\te^{-\\varepsilon x} \\left(M^+(x') - 1\\right) \n\t\t\t\t\\, \\mathrm{d}x' \\\\\n\t\t\t&\\quad \t\n\t\t\t\t+ i\\varepsilon \\int e^{-\\pi|x-x'|} k(x-x') \\big(M^+(x')-1\\big) \\, \\mathrm{d}x'\n\t\\end{align*}\n\tWe use equation \\eqref{GL.eps} and asymptotic condition (a) from \n\tproperty \\ref{itm:asymp} of Definition \\ref{dfn4:DEsoln}.\n\tThe second right-hand integral is bounded by $\\varepsilon$ times\n\t\\[\n\t\t\\int_{\\mathbb R} \\inn{x-x'}^{-2} |k(x-x')| \\inn{x'} \\, \\mathrm{d}x' \n\t\t\t\\lesssim\n\t\t\t\t\\inn{x} \n\t\t\t\t\\int_{\\mathbb R} \n\t\t\t\t\t\\inn{x-x'}^{-1} |k(x-x')| \\,dx'\n\t\t\t\\lesssim \\inn{x} \\nm{k}_{L^2}\n\t\\]\n\tand so goes to zero pointwise as $\\varepsilon \\searrow 0$. \n\tLet $H(x) = \\inn{x}\\big(M^+(x)-1\\big)$. The first right-hand integral is \n\tbounded by \n\t\\begin{align*}\n\t\\varepsilon \n\t\t\\int_{-\\infty}^x \n\t\t\t\\inn{x-x'} e^{-\\varepsilon (x-x')} \\inn{x'}^{-1}   \n\t\t\t\\left|H(x') \\right| \n\t\t\\, \\mathrm{d}x'  \n\t\t&\\lesssim \n\t\t\t\\varepsilon \n\t\t\t\\int_{-\\infty}^x \n\t\t\t\te^{-\\varepsilon (x-x')} \\left| H(x') \\right| \n\t\t\t\\, \\mathrm{d}x'\n\t\t\t\\\\\n\t\t&=\t\\int_0^{\\infty} e^{-\\Xi} \\left| H(x-\\Xi/\\varepsilon) \\right| \\, \\mathrm{d}\\Xi\n\t\\end{align*}\n\twhich goes to $0$ as $\\varepsilon \\searrow 0$ by dominated convergence since\n\t$\\lim_{x \\to -\\infty} H(x) = 0$, where we used the substitution \n\t$\\Xi = \\varepsilon(x-x')$ in the above integral.\n\n\tWe seek to carry out an analogous estimate for the term involving $M^-$.\n\tWe will use equation \\eqref{GL.eps} and asymptotic condition (b) from \n\tproperty \\ref{itm:asymp} of Definition \\ref{dfn4:DEsoln}. Since \n\t$e^{2i\\varepsilon}-1$ is of order $\\varepsilon$, it suffices to show that\n\t$\\varepsilon \\left| G_L^\\varepsilon*(M^- -1) (x) \\right| = o(1)$\n\tas $\\varepsilon \\searrow 0$, where we use the ``little oh'' notation\n\t$f = o(g)$ to indicate that $\\lim{y\\to a} \\frac{f(y)}{g(y)} = 0$ (in this \n\tcase $y=\\varepsilon$ and $a = 0$).\n\tWe have\n\t\\begin{align*}\n\t\t\\varepsilon \\left| (G_L^\\varepsilon * (M_1))(x) \\right|\n\t\t\t&\\lesssim\t\n\t\t\t\t\\varepsilon \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\t\\inn{x-x'} e^{-\\varepsilon x'} \\inn{x'}^{-1-\\upsilon} \n\t\t\t\t\\, \\mathrm{d}x'\n\t\t\t\t\\\\\n\t\t\t&\\lesssim  \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\t\\varepsilon e^{-\\varepsilon(x-x')} \\inn{x'}^{-\\upsilon} \n\t\t\t\t\\, \\mathrm{d}x'\t\n\t\t\t\t\\\\\n\t\t\t&=\t\n\t\t\t\t\\int_0{\\infty}\n\t\t\t\t\te^{-\\Xi} \\inn{x-\\Xi/\\varepsilon}^{-\\upsilon} \n\t\t\t\t\\, \\mathrm{d}\\Xi\n\t\\end{align*}\n\twhich goes to zero as $\\varepsilon \\searrow 0$ by dominated convergence.\n\tWe leave the second term, involving $k(x-x')$, as an exercise to the \n\treader.\n\n\tFinally\n\t\\begin{align*}\n\t\t\\varepsilon \\left| (G_L^\\varepsilon (M_2))(x) \\right|\n\t\t\t&\\lesssim \n\t\t\t\t\\varepsilon \n\t\t\t\t\\int_{-\\infty}^x \n\t\t\t\t\te^{-\\varepsilon (x-x')} \\inn{x-x'} \n\t\t\t\t\t\\inn{x'}^{-1-\\upsilon} g(x') \n\t\t\t\t\\, \\mathrm{d}x',\n\t\t\\end{align*}\n\twhere $g \\in L^2$. By the Cauchy-Schwarz inequality and the \n\tfact that $\\inn{x-x'} \\inn{x'}^{-1}$ is bounded for $x' < x < 0$ we again \n\tget an $\\varepsilon^{\\frac{1}{2}}$ estimate which suffices for the purpose. \n\n\tWe conclude that, for $u \\in L^{1,2+\\upsilon} \\cap L^{2,2} \\supset X$, \n\tthe Jost solution $M$ the satisfying asymptotic conditions \\ref{itm:asymp}\n\tfrom Definition \\ref{dfn4:DEsoln} solves the corresponding integral equation.\n\\end{proof}\n\n\n\\end{document}", "meta": {"hexsha": "59a74e4e3efbe3620af25aec436493f222fa1f6e", "size": 17970, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4-Jost/4.2.1-DEtoIE.tex", "max_stars_repo_name": "ADGC/ilw-dsm-dissertation", "max_stars_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter4-Jost/4.2.1-DEtoIE.tex", "max_issues_repo_name": "ADGC/ilw-dsm-dissertation", "max_issues_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4-Jost/4.2.1-DEtoIE.tex", "max_forks_repo_name": "ADGC/ilw-dsm-dissertation", "max_forks_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.4437869822, "max_line_length": 105, "alphanum_fraction": 0.5956037841, "num_tokens": 7468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.44854575190346097}}
{"text": "\\documentclass[notitlepage, 10pt]{article}\r\n\\title{Newton's Method as a Formal Recurrance}\r\n%\\title{Newton's Method Applied Symbolically to Quadratics}\r\n%\\title{Newton's Recurrence}\r\n\\author{{\\sc \r\n\tCarl Edquist,\r\n\tSam Lachterman,\r\n\tBrendan Younger,\r\n\tHal Canary} \\\\\r\n{\\small University of Wisconsin--Madison}}\r\n%\\date{April 28, 2004}\r\n\\usepackage{amssymb, amsthm, amsmath, amscd}\r\n\\usepackage{fullpage}\r\n\\usepackage{hyperref}\r\n\\usepackage{graphicx}\r\n\\hypersetup{pdfstartview=FitH,pdfauthor={SSL},\r\npdftitle={Newton's Method Applied Symbolically to Quadratics}}\r\n\r\n\\newtheorem{theorem}{Theorem}\r\n\\newtheorem{lemma}{Lemma}\r\n\\newtheorem{conjecture}{Conjecture}\r\n\r\n\\newcommand{\\R}{\\mathbb{R}}\r\n\\newcommand{\\Cstar}{\\widetilde{\\mathbb{C}}}\r\n\\newcommand{\\onto}{\\rightarrow}\r\n\\newcommand{\\binomial}[2]{\\genfrac{(}{)}{0pt}{}{ #1 }{ #2 }}\r\n\\newcommand{\\qbinomial}[2]{\\genfrac{[}{]}{0pt}{}{ #1 }{ #2 }_q }\r\n\r\n\\begin{document}\r\n\r\n\\bibliographystyle{plain} % Entries are ordered alphabetically;\r\n%\\bibliographystyle{unsrt} % Entries are not ordered alphabetically,\r\n\t\t\t  %  but in the order they are first referenced.\r\n%\\bibliographystyle{abbrv} % The bibliography looks the same as for\r\n\t\t\t  %  plain style except that first names and\r\n\t\t\t  %  names of journals and months are abbreviated;\r\n%\\bibliographystyle{alpha} % The bibliography looks the same as for\r\n\t\t\t  %  plain style except that the reference\r\n\t\t\t  %  markers are not just 1,2,3... but are\r\n\t\t\t  %  based on authors' initials and publication year;\r\n\\bibliographystyle{plain} % Entries are ordered alphabetically;\r\n\r\n\\maketitle\r\n\r\n%% \\begin{abstract}\r\n%% Iterating Newton's method symbolically for the general quadratic\r\n%% $ax^2+bx+c$ yields a rational function $\\frac{P_n(x)}{Q_n(x)}$, the\r\n%% numerator and denominator of which are polynomials with highly\r\n%% composite coefficients. In particular, the coefficients have no prime\r\n%% factors greater than $2^n$ after $n$ iterations.\r\n%% \\end{abstract}\r\n\r\n\\section*{Non-commuting Algebra}\r\n\r\nWe have defined $P_n$ and $Q_n$ with $P_0(x)=x$ and $Q_0(x)=1$.  If we\r\ninstead let $P_0(x)=x$ and $Q_0(x)=y$, it can be verified that we get\r\nslightly different formula:\r\n\r\n\\[\r\nP_n(x,y) = a^{2^n-1}x^{2^n}~+~\\sum\\limits_{k=0}^{(2^n-2)} \r\n\\sum\\limits_{i=1}^{~(2^n-k-1)~} \r\n(-1)^{i} \\binomial{2^n }{ k} \\binomial{2^n-k-i-1}{i-1}  \r\na^{k+i-1}~ b^{2^n-k-2i} ~c^i ~x^k y^{2^n-k}\r\n\\]\r\n\\[\r\nQ_n(x,y) = \\sum\\limits_{k=0}^{(2^n-1)}\r\n\\sum\\limits_{i=0}^{~(2^n-k-1)~} (-1)^i \\binomial{2^n}{k} \r\n\\binomial{2^n-k-i-1}{i} \r\na^{k+i} ~b^{2^n-k-2i-1} ~c^i ~x^k y^{2^n-k}\r\n\\]\r\n\r\nBut suppose that $x$ and $y$ do not commute, but rather satisfy the\r\nformula $yx=qxy$.  What happens?  If we define\r\n\\[ \\qbinomial{n }{ k} = \\prod_{i=1}^{n-k}\r\n\\frac{ 1-q^{i+k} }{ 1-q^i }\\]\r\nthen the q-version of the binomial formula is: \\cite{qbin}\r\n\\[\r\n(x + y)^n = \\sum_{k=0}^{n} \\qbinomial{n }{ k} x^k y^{n-k}.\r\n\\]\r\n\r\n\\begin{conjecture}\r\nIf $yx=qxy$ and if $P_n(x,y)$ and $P_n(x,y)$ are defined by\r\n\\begin{eqnarray*}\r\n& P_0     = x \\qquad Q_0 = y \\\\\r\n& P_{n+1} = a P_n^2 - c Q_n^2  \\qquad\r\nQ_{n+1} = a P_n Q_n + a Q_n P_n + b Q_n Q_n .\r\n\\end{eqnarray*}\r\nthen\r\n\\[\r\nP_n(x,y) = a^{2^n-1}x^{2^n}~+~\\sum\\limits_{k=0}^{(2^n-2)} \r\n\\sum\\limits_{i=1}^{~(2^n-k-1)~}  (-1)^{i} \r\n\\qbinomial{2^n }{ k} \\binomial{2^n-k-i-1}{i-1}  \r\na^{k+i-1}~ b^{2^n-k-2i} ~c^i ~x^k y^{2^n-k}\r\n\\]\r\n\\[\r\nQ_n(x,y) = \\sum\\limits_{k=0}^{(2^n-1)}\r\n\\sum\\limits_{i=0}^{~(2^n-k-1)~} (-1)^i \r\n\\qbinomial{2^n }{ k} \\binomial{2^n-k-i-1}{i} \r\na^{k+i} ~b^{2^n-k-2i-1} ~c^i ~x^k y^{2^n-k}.\r\n\\]\r\n\\end{conjecture}\r\n\r\nIt is not clear to us that the proof we provided for Theorem\r\n(\\ref{thm:maintheorem}) is aplicable to this more general conjecture.\r\n\r\n%% \\begin{thebibliography}{9}\r\n%% \\bibitem{qbin}\r\n%% {\\sc M.~P.~Schutzenberger}. \r\n%% ``Une interpretation de certaines solutions de l'equation\r\n%% fonctionnelle: $F(x + y) = F(x)F(y)$.''\r\n%% \\emph{C.~R.~Acad.~Sci.~Paris}, 236 (1953), 352-353.\r\n%% \\end{thebibliography}\r\n\r\n\\bibliography{newton-with-a-vengance} \r\n\\end{document}\r\n\r\n\r\n", "meta": {"hexsha": "718cc5154b27451fbd2fb53e7ea481bd6e3bd29b", "size": 3994, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/SSL/writeups/newton-with-a-vengance.tex", "max_stars_repo_name": "HalCanary/halcanary.github.io", "max_stars_repo_head_hexsha": "012342fc4bd36a3c6bece46db1022d57a7a317ee", "max_stars_repo_licenses": ["FSFAP"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/SSL/writeups/newton-with-a-vengance.tex", "max_issues_repo_name": "HalCanary/halcanary.github.io", "max_issues_repo_head_hexsha": "012342fc4bd36a3c6bece46db1022d57a7a317ee", "max_issues_repo_licenses": ["FSFAP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/SSL/writeups/newton-with-a-vengance.tex", "max_forks_repo_name": "HalCanary/halcanary.github.io", "max_forks_repo_head_hexsha": "012342fc4bd36a3c6bece46db1022d57a7a317ee", "max_forks_repo_licenses": ["FSFAP"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8474576271, "max_line_length": 73, "alphanum_fraction": 0.6347020531, "num_tokens": 1516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.7122321964553656, "lm_q1q2_score": 0.4485457519034609}}
{"text": "\\documentclass{amsart}\n\n\\usepackage{amsmath, amsthm, amssymb, amsfonts}\n% Notation for sheaves.\n\\usepackage{mathtools, mathrsfs}\n% Identity à la Hatcher.\n\\usepackage{dsfont}\n% Enumerate with letters.\n\\usepackage{enumerate}\n\\usepackage{hyperref}\n\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{proposition}[theorem]{Proposition}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{xca}[theorem]{Exercise}\n\n\\theoremstyle{remark}\n\\newtheorem{remark}[theorem]{Remark}\n\n\\numberwithin{equation}{section}\n\n\\setlength\\parindent{0pt}\n\n\\begin{document}\n\n\\title{Number Field Sieves}\n\n\\author{Federico Bongiorno}\n\n\\date{24\\textsuperscript{th} of August 2020}\n\n\\begin{abstract}\nAlgorithms, development, outcomes and improvements of the project undertaken with \\texttt{Haskell.org} for the \\texttt{arithmoi} library under supervision of Andrew Lelechenko.\n\\end{abstract}\n\n\\maketitle\n\n\\section*{Introduction}\n\nDecomposing integers into prime factors has always been at the core of arithmetic. The ancient Greeks were probably the first ones to study numbers for their own sake and they developed algorithms to effectively deduce properties about\nthem. Among these are the sieve of Eratosthenes and the algorithm of Euclid. Despite these advances, the fastest algorithm to factor a given integer was trial division. In the XVII century, Pierre de Fermat described an alternative approach to factor integers, however the algorithm was still based on trial and error. During the last century, plenty of algorithms to factor integers arose. Among them\nare the Elliptic Curve Factorisation, the Quadratic Sieve and the General Number\nField Sieve. Despite the fact that these algorithms require modern mathematical\ntechniques, the latter two are still based on Fermat’s idea and they are the fastest classical algorithms. Indeed, on the 28\\textsuperscript{th} of February 2020 , the General Number Field Sieve was used to factor the largest number to date: a $250$-digit integer. On the other hand, only the Elliptic Curve Factorisation algorithm was implemented in Haskell. As an initial step, this project developed the Quadratic Sieve in Haskell.\n\n\\section{Algorithms}\n\n\\subsection*{Quadratic Sieve}\n\nSuppose $n$ is an integer. The quadratic sieve attempts to factor $n$ by finding two integers $x$ and $y$ such that $$x ^ 2 - y ^ 2 = n$$ Then $(x - y)(x + y) = n$ is, in at least a half of the cases, a non-trivial factorisation of $n$. \n\n\\begin{example}\nLet $n = 21$. Note that $$ 5 ^ 2 - 2 ^ 2 = 21$$ so that $$ 7 \\cdot 3 = (5 + 2)\\cdot (5 - 2) = 21.$$\n\\end{example}\n\nTo find such integers we compute $y_i = x_i ^ 2 - n$ as $x_i$ runs through the sieving interval and we look for numbers which decompose completely into prime factors, which are less than a fixed bound. These are called smooth numbers. If we can find enough smooth numbers, then we are guaranteed to find a product of $y_i$'s which is a square. Indeed, this problem reduces to a linear system of equations over $\\mathbb{F}_2$, the finite field with two elements. The factorisation of a smooth number will form the column of a matrix after reduction modulo $2$. Finally by taking a suitable product of the $x_i$ 's and $y_i$'s, the end goal is achieved. \\\\\n\nThe version developed here presents three improvements. Firstly, the sieve uses the multiple polynomials Montgomery method. Instead of mapping $x$ using the polynomial $x^2 - n$, we can use $f (x) = ax^2 + 2bx + c$ where $a$, $b$ and $c$ are integers such that $b ^ 2 - ac = n$. Then, by completing the square, we get $$(ax + b) ^ 2 - n =  af(x)$$ which reduces the computations to the standard case by replacing $ax +b$ with $x$ and $a f(x)$ with $y$. The advantage of this method is that the numbers generated by $f$ can be made small, and so more likely to be smooth. Another improvement is to sieve with approximate logarithms. Instead of dividing by a prime, we subtract the approximate logarithm of that prime. This is faster than division. A number is then checked for being smooth if, after sieving, the corresponding logged value falls below a given threshold. A third improvement is given by considering a number to be smooth if, after dividing by all the primes in the factor base, the number remaining is itself prime. This may help to find more smooth numbers.\n\n\\subsection*{Wiedemann Algorithm}\n\nGiven a singular square matrix $A$ with coefficients in $\\mathbb{F}_2$, the aim of this algorithm is to find a non-zero $v$ such that $Av = 0$.\nThe idea of the algorithm is to estimate the minimal polynomial of $A$ and then use it to infer a solution. This can be achieved as follows. Suppose $p(x)$ is the minimal polynomial of $A$. Because $A$ is singular, $$p(x) = x^k q(x) $$\nfor some $q(x)$ and some $k \\geq 1$. Hence $$ A^k q(A) = p(A) = 0$$ gives a non-trivial solution. To estimate $p(x)$, we pick random vectors $u$ and $w$ and compute $$u^T A ^ j w$$ as $j$ runs in a fixed interval. Using this data, a variation of Euclid's algorithm for polynomials (Berlekamp-Massey algorithm) gives an estimate of $p(x)$.\n\n\\section{Development}\n\n\\subsection*{Weeks 1 - 4}\nIn the first four weeks, I developed a working version of the quadratic sieve employing Gaussian elimination in the linear algebra stage. The sieve was not dividing by higher prime powers and, as a result, it needed a much larger factor base. The algorithm was tested and benchmarked against $n_{30}$ (30-digit integer, see \\S \\ref{sec:outcomes}). It took \\texttt{600 s} to factor and used almost \\texttt{2 GB} of memory. Most of the time was consumed in the linear algebra step. \\\\\n\n\\emph{Difficulties}. The main difficulty came from using Haskell's mutable vectors. It was also difficult to mix mutable and immutable types while writing the code for the sieve.\\\\\n\n\\emph{What I learnt}. I learnt to write code in Haskell using mutable vectors and many engineering tools. These include Git, GitHub and profiling tools. I also developed a better understanding of Haskell's laziness.\\\\\n\n\\emph{Code}. \\url{https://github.com/Bodigrim/arithmoi/pull/202}\n\n\\subsection*{Weeks 5 - 8}\nIn the second four weeks, I developed the linear algebra routine to solve sparse binary matrices. The quadratic sieve improved considerably, taking around \\texttt{60 s} to factor $n_{30}$. This algorithm also uses a fraction of the memory used in Gaussian elimination. \\\\\n\n\\emph{Difficulties}. I had problems using random numbers. Because of laziness, if used naively, random numbers may produce the same output throughout the program. It was difficult to use type parameters to implement vectors of given length. GHC expected to know at each step if the parameter was fixed or could vary. I hadn't observed this syntax in any other programming language. Linking the two algorithms together was also not straightforward since rows and columns had to be indexed in the same fashion. \\\\\n\n\\emph{What I learnt}. I was not aware of this linear algebra algorithm or, more in general, of the counterintuitive idea to estimate minimal polynomials to solve linear systems. I also learnt about sized vectors and how to operate with generalised abstract data types. I had a better understanding of data structures and when to use which.\\\\\n\n\\emph{Code}. \\url{https://github.com/Bodigrim/arithmoi/pull/208}\n\n\\subsection*{Week 9}\nI then spent the week after, implementing the multiple polynomial variant. This is an ingenious way to find more smooth numbers in a given interval. This was successful and it cut time and memory significantly. It was taking around \\texttt{15 s} and \\texttt{300 MB}. \\\\\n\n\\emph{Difficulties}. Choosing $a$, the leading coefficient of the polynomial is quite easy. Choosing how $a$ varies as multiple sieving blocks are run is much harder. It is desirable to make sure that $a$ is not too far from a fixed values but it has to change at every block. I suspect that the best way to change $a$ is by using random numbers. \\\\\n\n\\emph{What I learnt}. I learnt about Haskell's applicative functors and monads while implementing this variant.\n\n\\subsection*{Week 10}\nAt this point I realised it was necessary to sieve by higher prime powers. I only changed a few lines of code and it instantly improved the algorithm. It was then taking \\texttt{6 s}. I also sieved using approximate logarithms. This approach did not require dividing by higher prime powers as the sieving was approximate. Instead, trial division is used on numbers which fall below a certain threshold after the sieve. Its performance was even better than the previous one taking only \\texttt{1 s}. \\\\\n\n\\emph{Difficulties}. Log sieving was actually slower at first. The logarithm of an integer was computed as a double and then floored. Taking logarithm to double precision was the problem and this was solved by calling a function previously developed by Andrew.\\\\\n\n\\emph{What I learnt}. A further speed up was obtained by using an unboxed vector for sieving rather than a boxed one. I learnt about the difference between these two types.\\\\\n\n\\emph{Code}. \\url{https://github.com/Bodigrim/arithmoi/pull/210}\n\n\\subsection*{Week 11}\nI then developed the large prime variation, a technique allowing numbers to be considered smooth even if they have one prime factor outside of the factor base. This variant further improved performance. Factoring $n_{30}$ took \\texttt{0.6 s} and \\texttt{1 MB} of memory. \\\\\n\n\\emph{Difficulties}. At first this variant was very inefficient as I was only picking up a couple of more smooth numbers while investing many resources in finding them. This was due to misunderstanding of the algorithm which was pointed out to me by Andrew. \\\\\n\n\\emph{What I learnt}. I became familiar with using maps and better understood how they work.\n\n\\subsection*{Week 12}\nIn the last week, I polished and tested the code. I also wrote the documentation and the report.\\\\\n\n\\emph{Difficulties}. When testing extensively, I realised there were a few bugs that I hadn't noticed before. It took a surprising amount of time to find them.\\\\\n\n\\emph{What I learnt}. I learnt better testing practices. These includes testing for edge cases and writing tests covering different facets of the algorithms. For instance, after developing the linear algebra routine, I only tested for correctness of the solution. However, in the context of integer factorisation, it is also important for the algorithm to find distinct solutions. This aspect was left untested and the uncovering the related inefficiency later required several hours of laborious debugging. \\\\\n\n\\emph{Code}. \\url{https://github.com/Bodigrim/arithmoi/pull/211}\n\n\\section{Outcomes}\n\\label{sec:outcomes}\n\nThe outcomes of the project are working versions of the quadratic sieve algorithm to factor an integer and the Wiedemann algorithm to solve sparse binary matrices. Here below are the main files in their final versions:\n\n\\begin{itemize}\n\\item \\url{https://github.com/Bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Factorisation/QuadraticSieve.hs}\n\\item \\url{https://github.com/Bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Factorisation/LinearAlgebra.hs}\n\\item \\url{https://github.com/Bodigrim/arithmoi/blob/master/test-suite/Math/NumberTheory/Primes/QuadraticSieveTests.hs}\n\\item \\url{https://github.com/Bodigrim/arithmoi/blob/master/test-suite/Math/NumberTheory/Primes/LinearAlgebraTests.hs}\n\\end{itemize}\n\nHere are some performance examples on my machine:\\\\\n\n\\textbf{Factoring a 30-digit number $n_{30}$}\\\\\nTime: \\texttt{0.599 s} \\\\\nMemory: \\texttt{1 MB} \\\\*\n\n\\textbf{Factoring a 40-digit number $n_{40}$}\\\\\nTime: \\texttt{14.213 s} \\\\\nMemory: \\texttt{14 MB} \\\\*\n\n\\textbf{Factoring a 50-digit number $n_{50}$}\\\\\nTime: \\texttt{216.649 s} \\\\\nMemory: \\texttt{82 MB} \\\\*\n\n\\textbf{Factoring a 60-digit number $n_{60}$}\\\\\nTime: \\texttt{1746.459 s} \\\\\nMemory: \\texttt{427 MB} \\\\*\n\n\\textbf{Solving a matrix of size 1000 and density 0.005}\\\\\nTime: \\texttt{1.140 s} \\\\\nMemory: \\texttt{0 MB} \\\\*\n\n\\textbf{Solving a matrix of size 10000 and density 0.001}\\\\\nTime: \\texttt{99.484 s} \\\\\nMemory: \\texttt{6 MB} \\\\*\n\n\\textbf{Solving a matrix of size 20000 and density 0.0005}\\\\\nTime: \\texttt{485.538 s} \\\\\nMemory: \\texttt{61 MB} \\\\*\n\n\\section{Improvements}\n\nFuture improvements are needed, particularly in the linear algebra routine. First of all, experimental evidence suggests that when the matrix is very singular, the solutions output by the algorithm are often the same. This can be problematic. Indeed, given a solution of the matrix, one can infer a factorisation in only a half of the cases. It is desirable to make the solution vary as the initial random seed varies. Another improvement to be carried out is the block variant of the Wiedemann. This improvement may speed up the classical Wiedemann algorithm by up to 64 times.\n\n\\section{Conclusion}\n\nThis project started with the ambitious aim to code efficient versions of both the Quadratic and General Number Field Sieves. It then became clear that writing an efficient version of the Quadratic Sieve alone required much more work than initially thought. Indeed, the algorithm was quite slow at first and several performance improvements were required. Nonetheless, I am satisfied about the result achieved and the copious amount of knowledge assimilated during the course of the project. I am looking forward to further improve the algorithm in the coming months.\n\n\\end{document}", "meta": {"hexsha": "7c51dda3b09603b2927617ab0a7675b0a6bf3bd7", "size": 13458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GSoC2020/NumberFieldSieves.tex", "max_stars_repo_name": "folidota/GSoC2020", "max_stars_repo_head_hexsha": "26f1a70587b58338bcc00e00273d0a93635c4de1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "GSoC2020/NumberFieldSieves.tex", "max_issues_repo_name": "folidota/GSoC2020", "max_issues_repo_head_hexsha": "26f1a70587b58338bcc00e00273d0a93635c4de1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "GSoC2020/NumberFieldSieves.tex", "max_forks_repo_name": "folidota/GSoC2020", "max_forks_repo_head_hexsha": "26f1a70587b58338bcc00e00273d0a93635c4de1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.2441860465, "max_line_length": 1073, "alphanum_fraction": 0.7722544212, "num_tokens": 3363, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.4485457381585381}}
{"text": "\\documentclass[runningheads]{llncs}\n\n\\pdfoutput=1\n\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{color}\n\\usepackage{graphicx}\n\\PassOptionsToPackage{hyphens}{url}\\usepackage[pdftitle={HalftimeHash: Modern Hashing without 64-bit Multipliers or Finite Fields},hidelinks]{hyperref}\n\\usepackage{microtype}\n\\usepackage[strings]{underscore}\n\\usepackage{doi}\n\n\\DeclareMathOperator{\\adj}{adj}\n\n\\renewcommand\\UrlFont{\\color{blue}\\rmfamily}\n\n\\newcommand{\\reals}{\\mathbb{R}}\n\\newcommand{\\rats}{\\mathbb{Q}}\n\\newcommand{\\nats}{\\mathbb{N}}\n\\newcommand{\\ints}{\\mathbb{Z}}\n\\newcommand{\\cplx}{\\mathbb{C}}\n\\newcommand{\\defeq}{\\;\\genfrac{}{}{0pt}{2}{\\text{def}}{=}\\;}\n\n%% \\newenvironment{blockquote}\n%% {\\begin{quote}\\itshape}\n%% {\\end{quote}}\n\n\n\\begin{document}\n\n\\title{HalftimeHash: Modern Hashing without 64-bit Multipliers or Finite Fields}\n\\author{Jim Apple\n\\orcidID{0000-0002-8685-9451}}\n\\institute{  \\email{\\href{mailto:jbapple@apache.org}{jbapple@apache.org}}}\n\\maketitle\n\n\\begin{abstract}\nHalftimeHash is a new algorithm for hashing long strings.\nThe goals are few collisions (different inputs that produce identical output hash values) and high performance.\n\nCompared to the fastest universal hash functions on long strings (clhash and UMASH), HalftimeHash decreases collision probability while also increasing performance by over 50\\%, exceeding 16 bytes per cycle.\n\nIn addition, HalftimeHash does not use any widening 64-bit multiplications or any finite field arithmetic that could limit its portability.\n\n\\keywords{Universal hashing \\and Randomized algorithms}\n\\end{abstract}\n\n\\section{Introduction}\nA hash family is a map from a set of seeds $S$ and a domain $D$ to a codomain $C$.\nA hash family $H$ is called is $\\varepsilon$-almost universal (``$\\varepsilon$-AU'' or just ``AU'') when\n\\[\n\\forall x,y \\in D, x \\neq y \\implies \\mathrm{Pr}_{s \\in S}[H(s, x) = H(s, y)] \\leq \\varepsilon \\in o(1)\n\\]\nThe intuition behind this definition is that collisions can be made unlikely by picking randomly from a hash {\\em family} independent of the input strings, rather than anchoring on a specific hash {\\em function} such as MD5 that does not take a seed as an input. AU hash families are useful in hash tables, where collisions slow down operations and, in extreme cases, can turn linear algorithms into quadratic ones. \\cite{impala-quadratic,algorithm-attack,rust-quadratic,tabulation}\n\nHalftimeHash is a new ``universe collapsing'' hash family, designed to hash long strings into short ones. \\cite{linear-hash-functions,hashing-without-primes-revisited,cuckoo-journal}\nThis differs from short-input families like SipHash or tabulation hashing, which are suitable for hashing short strings to a codomain of 64 bits. \\cite{siphash,tabulation}\nUniverse collapsing families are especially useful for composition with short-input families: when $n$ long strings are to be handled by a hash-based algorithm, a universe-collapsing family that reduces them to hash values of length $c \\lg n$ bits for some suitable $c > 2$ produces zero collisions with probability $1-O(n^{2-c})$.\nA short-input hash family can then treat the hashed values as if they were the original input values. \\cite{siphash,simple-hash-functions-work,universe-collapse-linear-probing,tabulation}\nThis technique applies not only to hash tables, but also to message-authentication codes, load balancing in distributed systems, privacy amplification, randomized geometric algorithms, Bloom filters, and randomness extractors. \\cite{poly1305,simple-hash-functions-work,random-closest-pair,fuzzy-extractors,privacy-amplification,chord}\n\nOn strings longer than 1KB, HalftimeHash is typically 55\\% faster than clhash, the AU hash family that comes closest in performance.\n\nHalftimeHash also has tunable output length and low probabilities of collision for applications that require them, such as one-time authentication.\\cite{nacl}\nThe codomain has size 16, 24, 32, or 40 bytes, and $\\varepsilon$ varies depending on the codomain (see Figure \\ref{frontier} and Section \\ref{performance}).\n\n\\subsection{Portability}\n\nIn addition to high speed on long strings, HalftimeHash is designed for a simple implementation that is easily portable between programming languages and machine ISA's.\nHalftimeHash uses less than 1200 lines of code in C++ and can take advantage of vector ISA extensions, including AVX-512, AVX2, SSE, and NEON.\\footnote{\\url{https://github.com/jbapple/HalftimeHash}}\n\nAdditionally, no multiplications from $\\ints_{2^{64}} \\times \\ints_{2^{64}}$ to $\\ints_{2^{128}}$ are needed.\nThis is in support of two portability goals -- the first is portability to platforms or programming languages without native widening unsigned 64-bit multiplications.\nLanguages like Java, Python, and Swift can do these long multiplications, but not without calling out to C or slipping into arbitrary-precision-integer code.\nThe other reason HalftimeHash avoids 64-bit multiplications is portability to SIMD ISA extensions, which generally do not contain widening 64-bit multiplication.\n% TODO: check this\n\n\n%% The x86-64 ISA extensions SSE2, AVX2, and AVX-512F all contain instructions to simultaneously multiply multiple pairs of 32-bit words, producing multiple 64-bit values.\n%% Aarch64 has similar instructions in the NEON set.\n% The POWER ISA also contains this, but only on 128 bits at once?\n\n\\subsection{Prior Almost-Universal Families}\n\nThere are a number of fast hash algorithms that run at rates exceeding 8 bytes per cycle on modern x86-64 processors, including Fast Positive Hash, falk\\-hash, xxh, Meow\\-Hash, and UMASH, and cl\\-hash. \\cite{smhasher}\nOf these, only cl\\-hash and U\\-MASH include claims of being AU; each of these uses finite fields and the x86-64 instruction for carryless (polynomial) multiplication.\n% TODO: GHASH, Badger, Poly1305, ...\n%Some similar previous work on AU hashing long strings is no longer as competitive, performance-wise, as it once was, including UHASH and VHASH. \\cite{clhash,umac,vmac}\n\nRather than tree hashing, hash families like clhash and UMASH use polynomial hashing (based on Horner's method) to hash variable-length strings down to fixed-size output.\nThat approach requires 64-bit multiplication and also reduction modulo a prime (in $\\ints$ or in $\\ints_2[x]$), limiting its usability in SIMD ISA extensions.\n\n\n\n\\subsection{Outline}\n\nThe rest of this paper is organized as follows: Section \\ref{prior-work} covers prior work that HalftimeHash builds upon.\nSection \\ref{gehc} introduces a new generalization of Nandi's ``Encode, Hash, Combine'' algorithm.\\cite{ehc-nandi}\nSection \\ref{implementation} discusses specific implementation choices in HalftimeHash to increase performance.\nSection \\ref{performance} analyzes and tests HalftimeHash's performance.\n\n\\section{Notations and Conventions}\n\nInput string length $n$ is measured in 32-bit {\\em words}.\n``32-bit multiplication'' means multiplying two unsigned 32-bit words and producing a single 64-bit word.\n``64-bit multiplication'' similarly refers to the operation producing a 128-bit product.\nAll machine integers are unsigned.\n\nSequences are denoted by angled brackets: ``$\\langle$'', ``$\\rangle$'', and $\\triangleleft$ prepends a character onto a string.\nSubscripts indicate a numbered component of a sequence, starting at 0.\nContiguous half-open subsequences are denoted ''$x[y,z)$'', meaning $\\langle x_y, x_{y+1}, \\dots, x_{z-1} \\rangle$.\n\n$\\bot$ is a new symbol not otherwise in the alphabet of words\n\n$\\varepsilon$ is called the {\\em collision probability} of $H$; it is inversely related to $H$'s {\\em output entropy}, $-\\lg \\varepsilon$.\nThe seed is sometimes referred as {\\em input entropy}, which is distinguished from the output entropy both because it is an explicit part of the input and because it is measured in words or bytes, not bits.\n\nEach step of HalftimeHash applies various transforms to groups of input values.\nThese groups are called {\\em instances}.\nThe processing of a transform on a single instance is called an {\\em execution}.\n\nInstances are logically contiguous but physically strided, for the purpose of simplifying SIMD processing.\nA physically contiguous set between two items in a single instance is called a {\\em block}; the number of words in a block is called the {\\em block size}.\nBecause instances are logically contiguous, when possible, the analysis will elide references to the block size.\n\nTree hashing examples use a hash family parameter $H$ that takes two words as input, but this can be easily extended to hash functions taking more than two words of input, in much the same way that binary trees are a special case of B-trees.\n\nHalftimeHash produces output that is collision resistant among strings of the same length.\nAdding collision resistance between strings of {\\em different} lengths to such a hash family requires only appending the length at the end of the output.\n%This turns, for instance, a hash family that produces 24 bytes of output into a hash family that produces 32 bytes of output.\n\n%The main portion of the text describes a particular instantiation of HalftimeHash that produces 24 bytes of output.\n%This will be generalized in Section~\\ref{performance}.\nVariants will be specified by their number of output bytes: HalftimeHash16, HalftimeHash24, HalftimeHash32, or HalftimeHash40.\n%HalftimeHash24 has $\\varepsilon < 2^{-83}$, as discussed in Section~\\ref{performance}.\n\nExcept where otherwise mentioned, all benchmarks were run on an Intel i7-7800x (a Skylake chip that supports AVX512), running Ubuntu 18.04, with clang++ 11.0.1.\n\n\\section{Prior Work}\n\\label{prior-work}\n\n%% Roughly, each execution HalftimeHash can be thought of as a tree with a hashing primative ``NH'' at the nodes and instances of ``EHC'' at the leaves.\n%% The prior work on each of these components is described in this section.\n\nThis section reviews hashing constructions that form components of HalftimeHash.\nIn order to put these in context, a broad outline of HalftimeHash is in order.\n\nHalftimeHash can be thought of as a tree-based, recursively-defined hash function.\nThe leaves of the tree are the words of the unhashed input; the root is the output value.\nEvery internal node has multiple inputs and a single output, corresponding with the child and parent nodes in the tree.\n\nTo a first approximation, a string is hashed by breaking it up into some number of contiguous parts, hashing each part, then combining those hash values.\nWhen the size of the input is low enough, rather than recurse, a construction called ``Encode, Hash, Combine'' (or ``EHC'') is used to hash the input.\n\n%% The overal structure of HalftimeHash is from a tree-like hash invented by Carter and Wegman;\n%% the internal nodes use NH, a hashing primitive from UHASH;\n%% the EHC at the leaves is described in this section (and generalized for use in HalftimeHash in Section~\\ref{gehc}).\n\n\\subsection{Tree Hash}\n\nHalftimeHash's structure is based on a tree-like hash as described by Carter and Wegman. \\cite[Section 3]{carter-wegman-79}\nTo hash a string, we use $\\lceil \\lg n \\rceil$ randomly-selected keys $k_i$ and a hash family $H$ that hashes two words down to one.\n%Now for any $n \\in \\nats$ let $\\lfloor\\!\\lfloor n \\rfloor\\!\\rfloor$ denote the largest power of $2$ that is less than $n$.\nThen the tree hash $T$ of a string $s[0,n)$ is defined recursively as:\n\\begin{equation}\n\\label{algebraic-badger}\n\\begin{array}{l}\nT(k, \\langle x \\rangle) \\defeq x \\\\\nT(k, s[0,n)) \\defeq H\n(k_{  \\lceil \\lg n - 1 \\rceil},\nT(k, s[0, 2^{\\lceil \\lg n - 1 \\rceil}) ),\nT(k, s[ 2^{\\lceil \\lg n - 1 \\rceil}, n) ))\n\\end{array}\n\\end{equation}\n\nCarter and Wegman show that if $H$ is $\\varepsilon$-AU, $T$ is $m\\varepsilon$-AU for input that has length exactly $2^m$.\nLater, Boesgaard et al. extended this proof to strings with lengths that are not a power of two.\\cite{badger}\n\n\\subsection{NH}\n\nIn HalftimeHash, NH, an almost-universal hash family, is used at the nodes of tree hash to hash small, fixed-length sequences:\\cite{umac}\n\\[\n\\sum_{i=0}^m (d_{2i} + s_{2i})(d_{2i+1} + s_{2i+1})\n\\]\nwhere $d, s \\in \\ints_{2^{32}}^{2m+2}$ are the input string and the input entropy, respectively.\nThe $d_j + s_j$ additions are in the ring $\\ints_{2^{32}}$, while all other operations are in the ring $\\ints_{2^{64}}$.\nNH is $2^{-32}$-AU.\nIn fact, it satisfies a stronger property, $2^{-32}$-A$\\Delta$U:\\cite{umac}\n\n\\begin{definition}\n  A hash family $H$ is said to be {\\em $\\varepsilon$-almost $\\Delta$-universal} (or just A$\\Delta$U) when\n  \\[\n  \\forall x,y,\\delta, \\Pr_s[H(s,x) - H(s,y) = \\delta] \\leq \\varepsilon \\in o(1)\n  \\]\n\\end{definition}\n\nIn tree nodes (though not in EHC, covered below), a variant of NH is used in which the last input pair is not hashed, thereby increasing performance:\n\\[\n\\left(\\sum_{i=0}^{m-1} (d_{2i} + s_{2i})(d_{2i+1} + s_{2i+1})\\right) + d_{2m} + 2^{32} d_{2m+1}\n\\]\nThis hash family is still $2^{-32}$-AU.\\cite{badger}\n\n\\subsection{Encode, Hash, Combine}\n\nAt the leaves of the tree hash, HalftimeHash uses the ``Encode, Hash, Combine'' algorithm.\\cite{ehc-nandi}\nEHC is parameterized by an erasure code with ``minimum distance'' $k$, which is a map on sequences of words such that any two input values that differ in {\\em any} location produce encoded outputs that differ in {\\em at least $k > 1$} locations after encoding.\n\nThe EHC algorithm is:\n\\begin{enumerate}\n\\item A sequence of words is processed by an erasure code with minimum distance $k$, producing a longer encoded sequence.\n\\item Each word in the encoded sequence is hashed using an A$\\Delta$U family with independently and randomly chosen input entropy.\n\\item A linear transformation $T$ is applied to the resulting sequence of hash values.\n  The codomain of $T$ has dimension $k$, and $T$ must have the property that any $k$ columns of it are linearly independent.\n\\end{enumerate}\n\nNandi proved that if the EHC matrix product is over a finite field, EHC is $\\varepsilon^k$-AU.\nThis AU collision probability could be achieved on the same input by instead running $k$ copies of NH, but that would perform $m k$ multiplications to hash $m$ words, while EHC requires $m + k$ multiplications, excluding the multiplications implicit in applying $T$.\nThat exclusion is the topic of Section~\\ref{gehc}.\n\n\\section{Generalized EHC}\n\\label{gehc}\n\nAt first glance, EHC might not look like it will reduce the number of multiplications needed, as the application of linear transformations usually requires multiplication.\nHowever, since $T$ is not part of the randomness of the hash family, it can be designed to contain only values that are trivial to multiply by, such as powers of $2$.\n\nThe constraint in \\cite{ehc-nandi} requires that any $k$ columns of $T$ form an invertible matrix.\nThis is not feasible in linear transformations on $\\ints_{2^{64}}$ in most useful dimensions.\nFor instance, in HalftimeHash24, a $3 \\times 9$ matrix $T$ is used.\nAny such matrix will have at least one set of three columns with an even determinant, and which therefore has a non-trivial kernel.\n\n\\begin{proof}\n  Let $U$ be a matrix over $\\ints_2$ formed by reducing each entry of $T$ modulo $2$.\n  Then $(\\det T) \\bmod 2 \\equiv \\det U$.\n  Since there are only 7 unique non-zero columns of size 3 over $\\ints_2$, by the pigeonhole principle, some two columns $x, y$ of $U$ must be equal.\n  Any set of columns that includes both $x$ and $y$ has a determinant of $0 \\bmod 2$.\n  \\qed\n\\end{proof}\n\n%Furthermore, the input to each section is independent? Partially independent, based on the loss at the matrix multiplication step? Since each partition\n\nLet $k$ be the minimum distance of the erasure code.\nWhile Nandi proved that EHC is $\\varepsilon^k$-AU over a finite field, $\\ints_{2^{64}}$ is not a finite field.\nHowever, there are similarities to a finite field, in that there are some elements in $\\ints_{2^{64}}$ with inverses.\nSome other elements in $\\ints_{2^{64}}$ are zero divisors, but only have one value that they can be multiplied by to produce 0.\nA variant of Nandi's proof is presented here as a warm-up to explain the similarities. \\cite{ehc-nandi}\n\n\\begin{lemma}\n  When the matrix product is taken over a field, if the hash function $H$ used in step 2 is $\\varepsilon$-A$\\Delta$U, EHC is $\\varepsilon^k$-A$\\Delta$U.\n\\end{lemma}\n\\begin{proof}\n  Let $\\bar{H}$ be defined as $\\bar{H}(s, x)_i \\defeq H(s_i, x_i)$.\n  Let $J$ be the encoding function that acts on $x$ and $y$, producing an encoding of length $e$.\n  Given that $x$ and $y$ differ, let $F$ be $k$ locations where $J(x)_i \\neq J(y)_i$.\n  Let $T|_F$ be the matrix formed by the columns of $T$ where the column index is in $F$ and let $\\bar{H}|_F$ similarly be $\\bar{H}$ restricted to the indices in $F$.\n  Conditioning over the $e - k$ indices not in $F$, we want to bound\n  \\begin{equation}\n    \\label{ehc-delta}\n    \\Pr_s[T|_F \\bar{H}|_F(s, J(x)) - T|_F \\bar{H}|_F(s, J(y)) = \\delta]\n  \\end{equation}\n  Since any $k$ columns of $T$ are independent, $T|_F$ is non-singular, and the equation is equivalent to $\\bar{H}|_F(s, J(x)) - \\bar{H}|_F(s, J(y)) = {T|_F}^{-1} \\delta$, which implies\n  \\[\n  \\bigwedge_{i \\in F} H(s_i, J(x)_i) - H(s_i, J(y)_i) = \\beta_i\n  \\]\n  where $\\beta \\defeq {T|_F}^{-1} \\delta$.\n\n  Since the $s_i$ are all chosen independently, the probability of the conjunction is the product of the probabilities, showing\n  \\[\n  \\begin{array}{rl}\n    &  \\Pr_s[T|_F \\bar{H}|_F (s,J(x)) - T|_F \\bar{H}|_F(s,J(y)) = \\delta] \\\\\n  \\leq &  \\prod_{i \\in F} Pr_s[H(s_i, J(x)_i) - H(s_i, J(y)_i) = \\beta_i]\n  \\end{array}\n  \\]\n  and since $H$ is A$\\Delta$U, this probability is $\\varepsilon^k$.  \\qed\n\\end{proof}\n\nNote that this lemma depends on $k$ being the minimum distance of the code.\nIf the distance were less than $k$, then the matrix would be smaller, increasing the probability of collisions.\n\nIn the non-field ring $\\ints_{2^{64}}$, the situation is altered.\n``Good'' matrices are those in which the determinant of any $k$ columns is divisible only by a small power of two.\nThe intuition is that, since matrices in $\\ints_{2^{64}}$ with odd determinants are invertible, the ``closer'' a determinant is to odd (meaning it is not divisible by large powers of two), the ``closer'' it is to invertible.\n\n\\begin{theorem}\n  Let $p$ be the largest power of 2 that divides the determinant of any $k$ columns in $T$.\n  The EHC step of HalftimeHash is $2^{k(p-32)}$-A$\\Delta$U when using NH as the hash family.\n\\end{theorem}\n\n\\begin{proof}\n  In HalftimeHash, the proof of the lemma above unravels at the reliance upon the trivial kernel of $T|_F$.\n  The columns of $T$ in HalftimeHash are linearly independent, so the matrix $T|_F$ is injective in rings without zero dividers, but not necessarily injective in $\\ints_{2^{64}}$.\n\n  However, even in $\\ints_{2^{64}}$, the adjugate matrix $\\adj(A)$ has the property that $A \\cdot \\adj(A) = \\adj(A) \\cdot A = \\det(A) I$.\n  Let $\\det(T|_F) = q2^{p'}$, where $q$ is odd and $p' \\le p$.\n  Now (\\ref{ehc-delta}) reduces to\n  \\[\n  \\begin{array}{rl}\n    &   \\Pr_s[T|_F \\bar{H}|_F(s,x) - T|_F \\bar{H}|_F(s,y) = \\delta]\\\\\n    \\leq &  \\Pr_s[\\adj(T|_F) T|_F \\bar{H}|_F(s,x) - \\adj(T|_F) T|_F \\bar{H}|_F(s,y) = \\adj(T|_F) \\delta] \\\\\n    = &  \\Pr_s[q2^{p'}\\bar{H}|_F(s,x) - q2^{p'}\\bar{H}|_F(s,y) = \\adj(T|_F) \\delta] \\\\\n    = &  \\Pr_s[2^{p'}\\bar{H}|_F(s,x) - 2^{p'}\\bar{H}|_F(s,y) = q^{-1} \\adj(T|_F) \\delta]\n  \\end{array}\n  \\]\n\n  Now letting $\\beta = q^{-1} \\adj(T|_F) \\delta$ and letting the modulo operator extend pointwise to vectors, we have\n\n  \\[\n  \\begin{array}{rl}\n    = &  \\Pr_s[\\bar{H}|_F(s,x) - \\bar{H}|_F(s,y) \\equiv \\beta \\bmod 2^{64-p'}] \\\\\n    = &  \\Pr_s\\left[\\bigwedge_{i \\in F} H(s_i,x_i) - H(s_i,y_i) \\equiv \\beta_i \\bmod 2^{64-p'}\\right] \\\\\n    = &  \\prod_{i \\in F} \\Pr_s\\left[ H(s_i,x_i) - H(s_i,y_i) \\equiv \\beta_i \\bmod 2^{64-p'}\\right] \\\\\n    = & \\left(2^{p'} 2^{-32}\\right)^{|F|} = 2^{k(p'-32)}\n  \\end{array}\n  \\]\n  This quantity is highest when $p'$ is at its maximum over all potential sets of columns $F$, and $p'$ is at most $p$, by the definition of $p$.\n  \\qed\n  % TODO: this can be reduced by shuffling the column order\n\\end{proof}\n\nThis generalized version of EHC is used in the implementation of HalftimeHash described in Section~\\ref{implementation}, with $p \\le 2^3$.\n\n\\section{Implementation}\n\\label{implementation}\n\nThis section describes the specific implementation choices made in HalftimeHash to ensure high output entropy and high performance.\nThe algorithm performs the following steps:\n\n\\begin{itemize}\n\\item Generalized EHC on instances of the unhashed input, producing 2, 3, 4, or 5 output words (of 64 bits each) per input instance\n\\item 2, 3, 4, or 5 exexutions of tree hash (with independently and randomly chosen input entropy) on the output of EHC, with NH at each internal node, producing a sequence of words logarithmic in the length of the input string, as described below in Equation~\\ref{stack-construction}\n\\item NH on the output of each tree hash, producing 16, 24, 32, or 40 bytes\n\\end{itemize}\n\n\\subsection{EHC}\n\nIn addition to the trivial distance-2 erasure code of XOR'ing the words together and appending that as an additional word, HalftimeHash uses non-linear erasure codes discovered by Gab\\-ri\\-el\\-yan with minimum distance 3, 4, or 5. \\cite{10-7-erasure-code,9-5-erasure-code,9-7-erasure-code}\n\nFor the linear transformations, HalftimeHash uses matrices $T$ selected so that the largest power of 2 that divides any determinant is $2^2$ or $2^3$.\nFor instance, for the HalftimeHash24 variant, $T$ has a $p$ of $2^2$:\n\n\\begin{displaymath}\n  \\left(\n\\begin{array}{rrrrrrrrr}\n  0 & 0 & 1 & 4 & 1 & 1 & 2 & 2 & 1\\\\\n  1 & 1 & 0 & 0 & 1 & 4 & 1 & 2 & 2\\\\\n  1 & 4 & 1 & 1 & 0 & 0 & 2 & 1 & 2\n\\end{array}\n\\right)\n\\end{displaymath}\n\nFor other output widths, HalftimeHash uses\n\n\\[\n\\begin{tabular}{|r|c|c|c|}\n  \\hline  & HalftimeHash16 & HalftimeHash32 & HalftimeHash40 \\\\\n  \\hline $T$ &\n$\\left(\n\\begin{array}{rrrrrrrrrrrr}\n  1 & 0 & 1 & 1 & 2 & 1 & 4\\\\\n  0 & 1 & 1 & 2 & 1 & 4 & 1\n\\end{array}\n\\right)$\n&\n$\\left(\n\\begin{array}{rrrrrrrrrr}\n 0 & 0 & 0 & 1 & 1 & 4 & 2 & 4 & 1 & 1 \\\\\n 0 & 1 & 2 & 0 & 0 & 1 & 1 & 2 & 4 & 1 \\\\\n 2 & 0 & 1 & 0 & 4 & 0 & 1 & 1 & 1 & 1 \\\\\n 1 & 1 & 0 & 1 & 0 & 0 & 4 & 1 & 2 & 8\n\\end{array}\n\\right)$\n&\n$\\left(\n\\begin{array}{rrrrrrrrr}\n 1 & 0 & 0 & 0 & 0 & 1 & 1 & 2 & 4\\\\\n 0 & 1 & 0 & 0 & 0 & 1 & 2 & 1 & 7\\\\\n 0 & 0 & 1 & 0 & 0 & 1 & 3 & 8 & 5\\\\\n 0 & 0 & 0 & 1 & 0 & 1 & 4 & 9 & 8\\\\\n 0 & 0 & 0 & 0 & 1 & 1 & 5 & 3 & 9\n\\end{array}\n\\right)$ \\\\\n\\hline $p$ & $2^2$ & $2^3$ & $2^3$ \\\\\n\\hline\n\\end{tabular}\n\\]\n\nThe input group lengths for the EHC input are 6, 7, 7, and 5, as can be seen from the dimensions of the matrices: $\\text{columns} + 1 - \\text{rows}$.\nNote that each of these matrices contains coefficients that can be multiplied by with no more than two shifts and one addition.\n\n\\subsection{Tree Hash}\n\nFor the tree hashing at internal nodes (above the leaf nodes, which use EHC), $k \\in \\{2, 3, 4, 5\\}$ tree hashes are executed with independently-chosen input entropy, producing output entropy of $-k \\lg \\varepsilon$.\nFrom the result from Carter and Wegman on the entropy of tree hash of a tree of height $m$, the resulting hash function is $m\\varepsilon^k$-AU.\n\nThe key lemma they need is that almost universality is composable:\n\n\\begin{lemma}[Carter and Wegman]\n  If $F$ is $\\varepsilon_F$-AU, $G$ is $\\varepsilon_G$-AU, then\n  \\begin{itemize}\n  \\item $F \\circ G$ where $F \\circ G (\\langle k_F, k_G \\rangle, x) \\defeq F(k_F,G(k_G, x))$ is $(\\varepsilon_F + \\varepsilon_G)$-AU.\n  \\item $\\langle F, G\\rangle$ where $\\langle F, G \\rangle(\\langle k_F, k_G \\rangle, \\langle x, y \\rangle) \\defeq \\langle F(k_F,x), G(k_G,y) \\rangle$, is $\\text{max}(\\varepsilon_F, \\varepsilon_G)$-AU, even if $F=G$ and $k_F = k_G$.\n%  \\item $F \\circ \\langle G,H \\rangle$ where $(F \\circ \\langle G,H \\rangle) (\\langle k_F, k_G, k_H \\rangle , \\langle p,q \\rangle) \\defeq F(k_F, G(k_G,p), H(k_H, q))$ is a family parameterized by the combination of keys for $F$ , $G$, and $H$, even if $G = H$ and $k_G = k_H$.\n  \\end{itemize}\n\\end{lemma}\n\nThe approach in Badger of using Equation~\\ref{algebraic-badger} to handle words that are not in perfect trees can be increased in speed with the following method:\nFor HalftimeHash, define $\\widehat{T}$ as a family taking as input sequences of any length $n$ and producing sequences of length $\\lceil \\lg n \\rceil$ as follows, using Carter and Wegman's $T$ defined in Section~\\ref{prior-work}:\n\n\\begin{equation}\n\\label{stack-construction}\n\\begin{array}{l}\n\\widehat{T}_0(k, \\langle \\rangle) \\defeq \\langle \\bot \\rangle \\\\\n\\widehat{T}_0(k, \\langle x \\rangle) \\defeq \\langle x \\rangle \\\\\n\\widehat{T}_{i+1}(k, s[0,n)) \\defeq \\left\\{\n  \\begin{array}{rcll}\n   \\bot &\\triangleleft& \\widehat{T}_i(k[1,\\lceil\\lg n\\rceil), s[0,n)) & \\text{if } 2^i > n \\\\\n    T(k, s[0, 2^i))) &\\triangleleft& \\widehat{T}_{i}(k[1,\\lceil\\lg n\\rceil),s[2^i, n)) & \\text{if } 2^i \\le n\n  \\end{array}\n  \\right.\n\\end{array}\n\\end{equation}\n\nThere is one execution of $T$ for every 1 in the binary representation of $n$.\n%This makes $\\widehat{T}$ produce a sequence with the same number of elements as there are levels in the execution of $T$.\nBy an induction on $\\lceil \\lg n \\rceil$ using the composition lemma, $\\widehat{T}$ is $\\varepsilon \\lceil \\lg n \\rceil$-AU.\n\n\nThe output of $\\widehat{T}$ is then hashed using an NH instance of size $\\lceil \\lg n \\rceil$.\nThis differs from Badger, where $T$ is used to fully consume the input without the use of additional input entropy;\n$T$ produces a single word per execution, while $\\widehat{T}$ needs to be paired with NH post-processing in order to achieve that.\\cite{badger}\nEmpirically, $\\widehat{T}$ has better performance than the Badger approach.\n\n\\section{Performance}\n\\label{performance}\n\nThis section tests and analyzes HalftimeHash performance, including an analysis of the output entropy.\n\n\\subsection{Analysis}\n%This section presents metrics of an execution of HalftimeHash, including the collision probability.\n%, number of multiplications performed, and the amount of input entropy used.\n%This section will treat HalftimeHash as abstract, rather than focusing on a single version with 24 bytes of output, as described above.\nThe parameters used in this analysis are:\n\n\\begin {description}\n\\item[$b$] the number of 64-bit words in a block.\n  Blocks are used to take advantage of SIMD units.\n\\item[$d$] is the number of elements in each EHC instance before applying the encoding.\n\\item[$e$] is the number of blocks in EHC after applying the encoding.\n\\item[$f$] is fanout, the width of the NH instance at tree hash nodes.\n\\item[$k$] is the number of blocks produced by the Combine step of EHC.\n  This is also the minimum distance of the erasure code, as described above.\n\\item[$p$] is the maximum power of 2 that divides a determinant of any $k \\times k$ matrix made from columns of the matrix $T$; doubling $p$ increases $\\varepsilon$ by a factor of $2^k$.\n\\item[$w$] is the number of blocks in each item used in the Encode step of EHC.\n\\end{description}\n\nIn HalftimeHash24, \\[(b, d, e, f, k, p, w) = (8, 7, 9, 8, 3, 2^2, 3)\\]\n\nEach EHC execution reads in $d w$ blocks, produces $e$ blocks, uses $e w$ words of input entropy, and performs $e w$ multiplications.\n\nFor the tree hash portion of HalftimeHash, the height of the $k$ trees drives multiple metrics.\nEach tree has $\\lfloor n / b d w \\rfloor$ blocks as input and every level execution forms a complete $f$-ary execution tree.\nThe height of the tree is thus $h \\defeq \\left\\lfloor \\log_f \\lfloor n / b d w \\rfloor \\right\\rfloor$.\n\n\\begin{lemma}\nThe tree hash is $2^{ k\\lg h - 32k}$-AU.\n\\end{lemma}\n\\begin{proof}\n  Carter and Wegman showed that tree hash has collision probability of $h \\varepsilon$, where $\\varepsilon$ is the collision probability of a single node.\n  Each tree node uses NH, so a single tree has collision probability $h 2^{-32}$.\n  A collision occurs for HalftimeHash at the tree hash stage if and only if all $k$ trees collide, which has probability $\\left(h 2^{-32}\\right)^k$, assuming that the EHC step didn't already induce a collision. \\qed\n\\end{proof}\n\nThe amount of input entropy needed is proportional to the height of the tree, with $f - 1$ words needed for every level.\nHalftimeHash uses different input entropy for the $k$ different trees, so the total number of 64-bit words of input entropy used in the tree hash step is $(f - 1) h k$.\n\nThe number of multiplications performed is identical to the number of input words, $k b \\lfloor n / b d w \\rfloor$.\n\n%% \\begin{tabular}{|r|c|c|}\n%%   \\hline & {\\bf EHC} & {\\bf Tree hash}\\\\\n%%   \\hline {\\bf Multiplications (each node)} & $b e w$ & $b (f-1)$ \\\\\n%%   \\hline {\\bf Multiplications (total)} & $b e w \\lfloor n / b d w\\rfloor$ & $k b \\lfloor n / b d w \\rfloor$ \\\\\n%%   \\hline {\\bf In Entropy (each tree $\\times$ level)} & N/A & $f-1$ \\\\\n%%   \\hline {\\bf In Entropy (total)} & $e w$ & $k (f-1) \\left\\lfloor \\log_f \\lfloor n / b d w \\rfloor \\right\\rfloor$ \\\\\n%%   \\hline {\\bf Out Entropy (total)} & $k (32-p)$ & $32k - k\\lg\\left\\lfloor\\log_f \\lfloor n/b d w\\rfloor\\right\\rfloor$\\\\\n%%   \\hline {\\bf Output words (total)} & $k b \\lfloor n / b d w\\rfloor $ & $b f k \\left\\lfloor \\log_f \\lfloor n / b d w \\rfloor \\right\\rfloor$\\\\\n%%   \\hline\n%% \\end{tabular}\n\nThe result of the tree hash is processed through NH, which uses $b f h k$ words of entropy and just as many multiplications.\n\nThere can also be as much as $b d w$ words of data in the raw input that are not read by HalftimeHash, as they are less than the input size of one instance of EHC.\nAgain, NH is used on this data, but now hashing $k$ times, since this data has not gone through EHC.\nThat requires $b d w k$ words of entropy and just as many multiplications.\n\nFor this previously-unread data, the number of words of entropy needed can be reduced by nearly a factor of $k$ using the Toeplitz construction.\nLet $r$ be the sequence of random words used to hash it.\nInstead of using $r[i b d w, (i+1)b d w)$ as the keys to hash component $i$ with, HalftimeHash uses $r[i, b d w + i)$.\nThis construction for multi-part hash output is A$\\Delta$U. \\cite{ehc-nandi,woelfel-toeplitz}\n\n\\subsection{Cumulative Analysis}\n\nThe combined collision probability is\n$2^{-32k}\\left(2^{kp} + h^k + 1\\right)$.\nFor HalftimeHash24, and for strings less than an exabyte in length, this is more than 83 bits of entropy.\n\nThe combined input entropy needed (in words) is\n$\ne w\n+ (f-1) h k\n+ b f h k\n+ b d w + k - 1\n$\nHalftimeHash24 requires 8.4KB input entropy for strings of length up to one megabyte and 34KB entropy for strings of length up to one exabyte.\n\nThe number of multiplications is dominated by the EHC step, since the total is $(e w + k) b \\lfloor n / b d w \\rfloor + O(\\log n)$ and $e w$ is significantly larger than $k$.\nFor a string of length 1MB, 84\\% of the multiplications happen in the EHC step. %, and the number of multiplications is about one per ten bytes of input.\nIntel's VTune tool show the same thing: 86\\% of the clock cycles are spent in the EHC step.\nSimilarly, clhash and UMASH, which are based on 64-bit carryless NH, have their execution times dominated by the multiplications in their base step.~\\cite{umash,clhash}\n\n\\subsection{Benchmarks}\n\\label{benchmarks}\n%% This section covers performance testing for HalftimeHash, especially compared to clhash and UMASH, the two fastest AU families on long strings.\n%% Each of those are based on NH over $\\ints_2[x]$, rather than $\\ints_{2^{64}}$.\n\nHalftimeHash passes all correctness and randomness tests in the SMHasher test suite; for a performance comparison, see Figure \\ref{smhasher-speed} and \\cite{smhasher}.\n\n\\begin{figure}\n  \\includegraphics[width=\\textwidth]{smhasher-speed}\n\\caption{\n  \\label{smhasher-speed}\n    The two fastest variants of HalftimeHash are faster than all hash families in the SMHasher suite on 256KiB strings on an i7-7800x, even families that come with no AU guarantees. \\protect\\cite{smhasher}\n    Of the families here, only HalftimeHash and xxh128 pass all SMHasher tests, and only HalftimeHash and clhash are AU.\n}\n\\end{figure}\n\nFigure~\\ref{frontier} displays the relationship between output entropy and throughput for HalftimeHash, UMASH, and clhash.\\footnote{UMASH and clhash are the fastest AU families for string hashing}\nAdding more output entropy increases the number of non-linear arithmetic operations that any hash function has to perform.\\cite{ehc-nandi}\n%Nandi showed that this is true in the general case, as there is a matching upper and lower bound for the number of non-linear operations to be performed for a certain hash output width.\nThe avoidance of doubling the number of multiplications for twice the output size is one of the primary reasons that HalftimeHash24, -32, and -40 are faster than running clhash or UMASH with 128-bit output.\n(The other is that carryless multiplication is not supported as a SIMD instruction.)\n\n\\begin{figure}\n\\includegraphics[width=\\textwidth]{speed-v-epsilon}\n\\caption{\n  \\label{frontier}\n  Trade-offs for almost-universal string hashing functions on strings of size 250KB on an i7-7800x.\n  UMASH comes in two variants based on the output width in bits; clhash doesn't, but running clhash twice is included in the chart.\n  For each clhash / UMASH version, at least one version of HalftimeHash is faster and has lower collision probability.% \\protect\\cite{layer-of-maxima}\n}\n\\end{figure}\n\nFigure \\ref{vs-cl} adds comparisons between clhash, UMASH, and HalftimeHash across input sizes and processor manufacturers.\nAlthough these two machines support different ISA vector extensions, the pattern is similar: for large enough input, HalftimeHash's throughput exceeds that of the carryless multiplication families.\n\\begin{figure*}\n\\begin{tabular}{cc}\n\\includegraphics[width=6.0cm]{line-cl-hh24}\n&\n\\includegraphics[width=6.0cm]{amd-cl-hh24}\n\\end{tabular}\n\\caption{\n  \\label{vs-cl}\n  Comparison of Intel (i7-7800x) and AMD (EC2 c5a.large, 7R32) performance.\n  On both chips HalftimeHash24 is faster than clhash and UMASH for long strings.\n  The ``v3'' after the name of the AMD HalftimeHash indicates block size: v3 means a 256-bit block size, while v4 (the default) means 512-bit block size.\n  AMD chips do not support AVX-512, but still HalftimeHash with 256-bit blocks exceeds the speed of clmul-based hashing methods by up to a factor of 2.\n}\n\\end{figure*}\n\n\\section{Future Work}\n\nAreas of future research include:\n\n\\begin{itemize}\n\\item Combining HalftimeHash, which is designed for long input, with a fast family for short input\n\\item Tuning for JavaScript, which has no native 32-bit integer support\n\\item Comparisons against hash algorithms in the Linux kernel, including Poly1305 and \\texttt{crc32\\_pclmul\\_le\\_16}\n\\item Benchmarks on POWER and ARM ISA's\n\\item EHC benchmarks using 64-bit multiplication -- carryless or integral\n\\end{itemize}\n\n%% \\section{Algorithm}\n%% \\label{algo}\n\n%% \\subsection{Overview}\n\n%% The remainder of this section will introduce a number of components previously introduced in the literature, including NH, EHC, and tree hashing.\n%% This paper synthesizes them into a single implementation and introduces an enhancement to EHC that eliminates the multiplications associated with it and replaces them with a small number of shifts and additions.\n\n%% \\subsection{The NH hashing primitive}\n\n%% \\subsection{Encode-Hash-Combine}\n\n%% \\subsubsection{Transform cost}\n\n%% \\subsection{Tree hashing}\n\n%% As presented, NH and EHC only hash fixed-size blocks.\n%% Carter and Wegman outline a simple tree-like construction of hashing to handle strings of arbitrary length. \\cite{badger,carter-wegman-79}\n%% The idea is direct composition of hash functions that take more bytes as input than they produce as output.\n%% A more detailed description is in the overview of Section \\ref{algo}.\n\n\n%% \\subsection{Sweep}\n\n%% Once the tree hash portion of HalftimeHash is complete, there still remains data to hash.\n\n%% First, the tree hash leaves data in its stack - as many as $bf$ words of data per level per tree, where $b$ is the size of a block.\n%% The Badger hash family addresses this by promoting items from lower levels to upper levels following Equation~\\ref{algebraic-badger}.\n%% This does not negatively affect the collision probability, as promotion is equivalent to hashing with the identity function, which has collision probability $\\varepsilon = 0$.\n\n%% This approach uses no additional entropy, but it does create dependencies between hashing that is closer to the leaves of the stack and hashing that is closer to the root, and testing revealed it to be slower in some cases.\n%% Instead, HalftimeHash uses NH to hash all of the data in the stack; see Figure \\ref{no-badger}.\n%% The stack is itself treated as input to NH.\n%% This requires as much input entropy as the number of words in the stack.\n\n%% In addition to the data on the stack, there are some characters that have yet to be hashed at all: HalftimeHash's EHC design expects to be fed $7 \\cdot 3 = 21$ words at each invocation, and no fewer, so there may be up to 20 words remaining at the end of the input string.\n%% Every word in this remainder is fed into into all three NH executions that were created when hashing the stack.\n\n%% HalftimeHash then returns the three NH sums, for a total of 24 bytes of output.\n\n\n\n\n\n\n\n\\subsubsection*{Acknowledgments}\nThanks to Daniel Lemire, Paul Khuong, and Guy Even for helpful discussions and feedback.\n\n\n\\bibliographystyle{splncs04}\n\\bibliography{halftime-hash}\n\n\n\\end{document}\n\\endinput\n\n%%  LocalWords:  HalftimeHash codomain ISA's UMASH falkhash MeowHash\n%%  LocalWords:  MetroHash FarmHash clhash wyhash farmhash UHASH EHC\n%%  LocalWords:  VHASH Nandi's ISA strided Wegman TODO VTune NH's XXH\n%%  LocalWords:  UMAC VMAC carryless fanout Nandi Gabrielyan Toeplitz\n%%  LocalWords:  Gabrielyan's HalftimeHash's Woelfel SMHasher PVLDB\n%%  LocalWords:  VLDB zeroless Skylake uint clmul pclmul Lemire xxh\n%%  LocalWords:  Khuong Wegman's tunable\n", "meta": {"hexsha": "0619086f0366a1a283576a787d2a2ad515a77d0c", "size": 37996, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "halftime-hash.tex", "max_stars_repo_name": "jbapple/HalftimeHash", "max_stars_repo_head_hexsha": "eb2ba0300d3e6ff668d037e3ceec2a50e3f3ac70", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-18T10:09:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-22T14:12:58.000Z", "max_issues_repo_path": "halftime-hash.tex", "max_issues_repo_name": "jbapple/HalftimeHash", "max_issues_repo_head_hexsha": "eb2ba0300d3e6ff668d037e3ceec2a50e3f3ac70", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "halftime-hash.tex", "max_forks_repo_name": "jbapple/HalftimeHash", "max_forks_repo_head_hexsha": "eb2ba0300d3e6ff668d037e3ceec2a50e3f3ac70", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-05-22T13:30:58.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-22T13:30:58.000Z", "avg_line_length": 58.8173374613, "max_line_length": 482, "alphanum_fraction": 0.7332087588, "num_tokens": 10928, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.44853555125625855}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage{isabelle,isabellesym}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\newcommand{\\size}[1]{\\lvert#1\\rvert}\n\\newcommand{\\var}{\\mathrm{Var}}\n\\newcommand{\\expectation}{\\mathrm{E}}\n\n% further packages required for unusual symbols (see also\n% isabellesym.sty), use only when needed\n\n%\\usepackage{amssymb}\n  %for \\<leadsto>, \\<box>, \\<diamond>, \\<sqsupset>, \\<mho>, \\<Join>,\n  %\\<lhd>, \\<lesssim>, \\<greatersim>, \\<lessapprox>, \\<greaterapprox>,\n  %\\<triangleq>, \\<yen>, \\<lozenge>\n\n%\\usepackage{eurosym}\n  %for \\<euro>\n\n%\\usepackage[only,bigsqcap,fatsemi,interleave,sslash]{stmaryrd}\n  %for \\<Sqinter>, \\<Zsemi>\n\n%\\usepackage{eufrak}\n  %for \\<AA> ... \\<ZZ>, \\<aa> ... \\<zz> (also included in amssymb)\n\n%\\usepackage{textcomp}\n  %for \\<onequarter>, \\<onehalf>, \\<threequarters>, \\<degree>, \\<cent>,\n  %\\<currency>\n\n% this should be the last package used\n\\usepackage{pdfsetup}\n\n% urls in roman style, theory text in math-similar italics\n\\urlstyle{rm}\n\\isabellestyle{it}\n\n% for uniform font size\n%\\renewcommand{\\isastyle}{\\isastyleminor}\n\n\n\\begin{document}\n\n\\title{Formalization of Randomized Approximation Algorithms for Frequency Moments}\n\\author{Emin Karayel}\n\\maketitle\n\\begin{abstract}\nIn 1999 Alon et.\\ al.\\ introduced the still active research topic of approximating the frequency moments of a data stream using randomized algorithms with minimal spage usage.\nThis includes the problem of estimating the cardinality of the stream elements---the zeroth frequency moment.\nBut, also higher order frequency moments that provide information about the skew of the data stream, which is for example critical information for parallel processing.\nThe frequency moment of a data stream $a_1, \\ldots, a_m \\in U$ can be defined as $F_k := \\sum_{u \\in U} C(u,a)^k$ where $C(u,a)$ is the count of occurences of $u$ in the stream $a$.\nThey introduce both lower bounds and upper bounds, which were later improved by newer publications.\nThe algorithms have guaranteed success probability and accuracy, without making any assumptions on the input distribution.\nThey are an interesting use-case for formal verification, because they rely on deep results from both algebra and analysis, require a large body of existing results.\nThis work contains the formal verification of three algorithms for the approximation of $F_0$, $F_2$ and $F_k$ for $k \\geq 3$.\nTo achieve it, the formalization also includes reusable components common to all algorithms, such as universal hash families, the median method, formal modelling of one-pass data stream algorithms and a generic flexible encoding library for the verification of space complexities.\n\\end{abstract}\n\n\\tableofcontents\n\n% sane default for proof documents\n\\parindent 0pt\\parskip 0.5ex\n\n% generated text of all theories\n\\input{session}\n\\appendix\n\\section{Informal proof of correctness for the $F_0$ algorithm\\label{sec:f0_proof}}\nThis section contains a detailed informal proof for the correctness of the $F_0$-algorithm.\nBecause of the standard amplification result about medians (see for example \\cite{alon1999}) it\nis enough to show that each of the estimates the median is taken from is within the desired interval\nwith success probability $\\frac{2}{3}$.\n\nTo verify the latter, let $a_1, \\ldots, a_m$ be the stream elements, where we assume that the\nelements are a subset of $\\{0,\\ldots,n-1\\}$ and $0 < \\delta < 1$ be the desired relative accuracy.\nLet $p$ be the smallest prime such that $p \\geq \\max (n,19)$ and let $h$ be a random polynomial over\n$GF(p)$ with degree strictly less than $2$.\nThe algoritm also introduces the internal parameters $t, r$ defined by:\n\\begin{eqnarray*}\n    t & := & \\lceil 80\\delta^{-2} \\rceil \\\\\n    r & := & 4 \\log_2 \\lceil \\delta^{-1} \\rceil + 24\n\\end{eqnarray*}\nThe estimate the algorithm obtains is:\n\\begin{align*}\n    A := & \\left\\{ a_1, \\ldots, a_m \\right\\} &\n    H := & \\left\\{ \\lfloor h(a) \\rfloor_r \\middle \\vert a \\in A \\right\\} \\\\\n    R := & \\begin{cases} t p \\left(\\mathrm{min}_t (H) \\right)^{-1} & \\textrm{ if } \\size{H} \\geq t \\\\\n    \\size{H} & \\textrm{ othewise,} \\end{cases} &\n\\end{align*}\nHere $\\mathrm{min}_t(H)$ denotes the $t$-th smallest element of $H$.\nWith these definitions, it is possible to state the goal as:\n\\[\n    P(\\size{R - F_0} \\leq \\delta \\size{F_0}) \\geq \\frac{2}{3} \\textrm{.}  \n\\]\nwhich is shown by separately in the following two subsections for the cases $F_0 \\geq t$ and $F_0 < t$.\n\\subsection{Case $F_0 \\geq t$}\nLet us introduce:\n\\begin{eqnarray*}\n    H^* & := & \\left\\{ h(a) \\middle \\vert a \\in A \\right\\}^{\\#} \\\\\n    R^* & := & tp \\left( \\mathrm{rank}^{\\#}_t(H^*) \\right)^{-1}\n\\end{eqnarray*}\nThese definitions correspond to the $H$, $R$ but with a few minor modifications.\nThe set $H^*$ is a multiset, this means that each element also has a multiplicity, counting the\nnumber of \\emph{distinct} elements of $A$ being mapped by $h$ to the same value.\nNote that by definition: $\\size{H^*}=\\size{A}$.\nSimilarly the operation $\\mathrm{min}^{\\#}_t$ obtains the $t$-th element of the multiset $H$\n(taking multiplicities into account).\nNote also that there is no rounding operation $\\lfloor \\cdot \\rfloor_r$ in the definition of $H^*$.\nThe key reason for the introduction of these alternative versions of $H, R$ is that it is easier to\nshow probabilistic bounds on the distances $\\size{R^* - F_0}$ and $\\size{R^* - R}$ as opposed to \n$\\size{R - F_0}$ directly.\nIn particular the plan is to show:\n\\begin{eqnarray}\n \\delta' & := & \\frac{3}{4}\\delta \\\\\n P\\left(\\size{R^*-F_0} > \\delta' F_0\\right) & \\leq & \\frac{2}{9} \\textrm{, and} \\label{eq:r_star_dev} \\\\\n P\\left(\\size{R^*-F_0} \\leq \\delta' F_0 \\wedge \\size{R-R^*} > \\frac{\\delta}{4} F_0\\right) & \\leq & \\frac{1}{9} \\label{eq:r_star_r}\n\\end{eqnarray}\nI.e. the probability that $R^*$ has not the relative accuracy of $\\frac{3}{4}\\delta$ is less that $\\frac{2}{9}$ and the probability \nthat assuming $R^*$ has the relative accuracy of $\\frac{3}{4}\\delta$ but that $R$ deviates by more that $\\frac{1}{4}\\delta F_0$ is at most $\\frac{1}{9}$.\nHence, the probability that neither of these events happen is at least $\\frac{2}{3}$ but in that case:\n\\begin{equation}\n    \\label{eq:concl}\n    \\size{R-F_0} \\leq \\size{R - R^*} + \\size{R^*-F_0} \\leq \\frac{\\delta}{4} F_0 + \\frac{3 \\delta}{4} F_0 = \\delta F_0 \\textrm{.}\n\\end{equation}\n\nFor the verification of \\autoref{eq:r_star_dev} let us introduce:\n\\[\n    Q(u) = \\size{\\left\\{h(a) < u \\mid a \\in A \\right\\}}\n\\]\nand observe that $\\mathrm{min}_t^{\\#}(H^*) < u$ if $Q(u) \\geq t$ and $\\mathrm{min}_t^{\\#}(H^*) \\geq v$ if $Q(v) \\leq t-1$.\nTo see why this is true note that, if at least $t$ elements of $A$ are mapped by $h$ below a certain value, then the rank $t$ element must also be within them, and thus also be below that value.\nAnd that the opposite direction of this conclusion is also true.\nNote that this relies on the fact that $H^*$ is a multiset and that multiplicities are being taken into account, when computing the $t$-th smallest element. \n\nAlternatively, it is also possible to write $Q(u) = \\sum_{a \\in A} 1_{\\{h(a) < u\\}}$\\footnote{The notation $1_A$ is shorthand for the indicator function of $A$, i.e., $1_A(x)=1$ if $x \\in A$ and $0$ otherwise.}, i.e., $Q$ is a sum of pairwise independent $\\{0,1\\}$-valued random variables, with expectation $\\frac{u}{p}$ and variance $\\frac{u}{p} - \\frac{u^2}{p^2}$.\n\\footnote{A consequence of $h$ being choosen uniformly from a $2$-independent hash family.}\nUsing lineariy of expectation and Bienaym\\'e's identity, it follows that $\\var \\, Q(u) \\leq \\expectation \\, Q(u) = |A|u p^{-1} = F_0 u p^{-1}$ for $u \\in \\{0,\\ldots,p\\}$.\n\nFor $v = \\left\\lfloor \\frac{tp}{(1-\\delta') F_0} \\right\\rfloor$ it is possible to conclude:\n\\begin{eqnarray*}\n    t-1 & \\leq\\footnotemark & \\frac{t}{(1-\\delta')} - 3\\sqrt{\\frac{t}{(1-\\delta')}} - 1 \\\\\n     &\\leq&  \\frac{F_0 v}{p} - 3 \\sqrt{\\frac{F_0 v}{p}} \\leq \\expectation Q(v) - 3 \\sqrt{\\var Q(v)}\n\\end{eqnarray*}\n\\footnotetext{The verification of this inequality is a lengthy but straightforward calculcation using the definition of $\\delta'$ and $t$.}\nand thus using Tchebyshev's inequality:\n\\begin{align}\n    P\\left(R^* < \\left(1-\\delta'\\right) F_0\\right) & = P\\left(\\mathrm{rank}_t^{\\#}(H^*) > \\frac{tp}{(1-\\delta')F_0}\\right) \\nonumber \\\\ \n    & \\leq P(\\mathrm{rank}_t^{\\#}(H^*) \\geq v) = P(Q(v) \\leq t-1) \\label{eq:r_star_upper_bound} \\\\\n    & \\leq P\\left(Q(v) \\leq \\expectation Q(v) - 3 \\sqrt{\\var Q(v)}\\right) \\leq \\frac{1}{9} \\textrm{.} \\nonumber\n\\end{align}\nSimilarly for $u = \\left\\lceil \\frac{tp}{(1+\\delta') F_0} \\right\\rceil$ it is possible to conclude:\n\\begin{eqnarray*}\n    t & \\geq & \\frac{t}{(1+\\delta')} + 3\\sqrt{\\frac{t}{(1+\\delta')}+1} + 1 \\\\\n     &\\geq&  \\frac{F_0 u}{p} + 3 \\sqrt{\\frac{F_0 u}{p}} \\geq \\expectation Q(u) + 3 \\sqrt{\\var Q(v)}\n\\end{eqnarray*}\nand thus using Tchebyshev's inequality:\n\\begin{align}\n    P\\left(R^* > \\left(1+\\delta'\\right) F_0\\right) & = P\\left(\\mathrm{rank}_t^{\\#}(H^*) < \\frac{tp}{(1+\\delta')F_0}\\right) \\nonumber \\\\ \n    & \\leq P(\\mathrm{rank}_t^{\\#}(H^*) < u) = P(Q(u) \\geq t) \\label{eq:r_star_lower_bound} \\\\\n    & \\leq P\\left(Q(u) \\geq \\expectation Q(u) + 3 \\sqrt{\\var Q(u)}\\right) \\leq \\frac{1}{9} \\textrm{.} \\nonumber\n\\end{align}\nTo verfiy \\autoref{eq:r_star_r}, note that\n\\begin{equation}\n    \\label{eq:rank_eq}\n    \\mathrm{min}_t(H) = \\lfloor \\mathrm{min}_t^{\\#}(H^*) \\rfloor_r\n\\end{equation}\nif there are no collisions, induced by the application of $\\lfloor h(\\cdot) \\rfloor_r$ on the elements of $A$.\nEven more carefully, note that the equation would remain true, as long as there are no collision within the smallest $t$ elements of $H^*$.\nBecause \\autoref{eq:r_star_r} needs to be shown only in the case where $R^* \\geq (1-\\delta') F_0$, i.e., when $\\mathrm{min}_t^{\\#}(H^*) \\leq v$,\nit is enough to bound the probability of a collision in the range $[0; v]$.\nMoreover \\autoref{eq:rank_eq} implies $\\size{\\mathrm{min}_t(H) - \\mathrm{min}_t^{\\#}(H^*)} \\leq \\max(\\mathrm{min}_t^{\\#}(H^*), \\mathrm{min}_t(H)) 2^{-r}$ from\nwhich it is possible to derive $\\size{R^*-R} \\leq \\frac{\\delta}{4} F_0$.\n% R* = tp/rank_t#, R = tp/rank_t => |R-R*| = | tp [ rank_t - rank_t# / rank_t rank_t# ] | <= \n% tp \\max{rank_t, rank_t#} 2^-r / rank_t rank_t# <= t 2^-r <= t 2^-24 d'^4 <= F_0 d'^4 2^-24 <= 1/4 d' F_0\n%\n%Let's summarize: If\n%\\begin{eqnarray*}\n%    R^* & \\geq & (1-\\delta') F_0 \\\\\n%    \\lfloor h(a) \\rfloor_r & \\neq & \\lfloor h(b) \\rfloor_r \\textrm{ for } a \\neq b \\in A \\wedge h(a) \\leq v \\wedge h(b) \\leq v\n%\\end{eqnarray*}\n%then $\\mathrm{rank}_t(H) = \\lfloor \\mathrm{rank}_t^{\\#}(H^*) \\rfloor_r$.\nAnother important fact is that $h$ is injective with probability $1-\\frac{1}{p}$, this is because $h$ is choosen uniformly from the polynomials of degree less than $2$.\nIf it is a degree $1$ polynomial, it is a linear function on $GF(p)$ and thus injective.\nBecause $p \\geq 18$ the probability that $h$ is not injective can be bounded by $1/18$.\nHowever, even if $h$ is injective, there is still a possibility of collision, because of the application of the rounding operation $\\lfloor \\cdot \\rfloor_r$.\nThe plan is to bound that probability by $1/18$ as well to show \\autoref{eq:r_star_r}.\n\\begin{eqnarray*}\n    & & P\\left( \\size{R^*-F_0} \\leq \\delta' F_0 \\wedge \\size{R-R^*} > \\frac{\\delta}{4} F_0 \\right) \\\\\n    & \\leq & P\\left( R^* \\geq (1-\\delta') F_0 \\wedge \\mathrm{min}_t^{\\#}(H^*) \\neq \\mathrm{min}_t(H) \\wedge h \\textrm{ inj.}\\right) + P(\\neg h \\textrm{ inj.}) \\\\\n    & \\leq & P\\left( \\exists a \\neq b \\in A. \\lfloor h(a) \\rfloor_r = \\lfloor h(b) \\rfloor_r \\leq v \\wedge h(a) \\neq h(b) \\right) + \\frac{1}{18} \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} P\\left(\\lfloor h(a) \\rfloor_r = \\lfloor h(b) \\rfloor_r \\leq v \\wedge h(a) \\neq h(b) \\right) \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} P\\left(\\size{h(a) - h(b)} \\leq v 2^{-r} \\wedge h(a) \\leq v (1+2^{-r}) \\wedge h(a) \\neq h(b) \\right) \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} \\sum_{\\substack{a', b' \\in \\{0,\\ldots, p-1\\} \\wedge a' \\neq b' \\\\ \\size{a'-b'} \\leq v 2^{-r} \\wedge a' \\leq v (1+2^{-r})}} P(h(a) = a') P(h(b)= b') \\\\\n    & \\leq & \\frac{1}{18} + 6 \\frac{F_0^2 v^2}{p^2} 2^{-r} \\leq \\frac{1}{9} \\textrm{.}\n%    96 t^2 2^{-r} + \\frac{1}{18} & \\leq & \\frac{1}{9}\n\\end{eqnarray*}\nWhich shows that \\autoref{eq:r_star_r} is true and \\autoref{eq:r_star_upper_bound} and~\\ref{eq:r_star_lower_bound} implies \n\\autoref{eq:r_star_dev}, which means the reasoning in \\autoref{eq:concl} confirms:\n\\begin{equation}\n    P(\\size{R - F_0} \\leq \\delta \\size{F_0}) \\geq \\frac{2}{3}\n\\end{equation}\n\nThe following subsection confirms that this is also true for the remaining case, if $F_0 < t$, concluding the proof.\n\\subsection{Case $F_0 < t$}\nNote that in this case $\\size{H} \\leq F_0 < t$ and thus $R = \\size{H}$, hence the goal is to show that:\n$P(\\size{H} \\neq F_0) \\leq \\frac{1}{3}$.\n\nThe latter can only happen, if there is a collision induced by the application of $\\lfloor h(\\cdot)\\rfloor_r$. As before $h$ is not injective with probability at least $\\frac{1}{18}$, hence:\n\\begin{eqnarray*}\n    & & P\\left( \\size{R - F_0} > \\delta F_0\\right) \\\\\n    & \\leq & P\\left( R \\neq F_0 \\right) \\\\\n    & \\leq & \\frac{1}{18} + P\\left( R \\neq F_0 \\wedge h \\textrm{ injective} \\right) \\\\\n    & \\leq & \\frac{1}{18} + P\\left( \\exists a \\neq b \\in A. \\lfloor h(a) \\rfloor_r = \\lfloor h(b) \\rfloor_r  \\right) \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} P\\left(\\lfloor h(a) \\rfloor_r = \\lfloor h(b) \\rfloor_r \\wedge h(a) \\neq h(b) \\right) \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} P\\left(\\size{h(a) - h(b)} \\leq p 2^{-r} \\wedge h(a) \\neq h(b) \\right) \\\\\n    & \\leq & \\frac{1}{18} + \\sum_{a \\neq b \\in A} \\sum_{\\substack{a', b' \\in \\{0,\\ldots, p-1\\} \\\\  a' \\neq b' \\wedge \\size{a'-b'} \\leq p 2^{-r}}} P(h(a) = a') P(h(b)= b') \\\\\n    & \\leq & \\frac{1}{18} + F_0^2 2^{-r+1} \\leq \\frac{1}{9} \\textrm{.}\n\\end{eqnarray*}\nWhich concludes the proof. \\qed\n\\bibliographystyle{abbrv}\n\\bibliography{root}\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "bdc591d0f0bed404999855aa273c35f2c3cd7892", "size": 14067, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thys/document/root.tex", "max_stars_repo_name": "ekarayel/frequency_moments", "max_stars_repo_head_hexsha": "b704c20fd18a29f41c587ad15ba402b2e5d8d17a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thys/document/root.tex", "max_issues_repo_name": "ekarayel/frequency_moments", "max_issues_repo_head_hexsha": "b704c20fd18a29f41c587ad15ba402b2e5d8d17a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thys/document/root.tex", "max_forks_repo_name": "ekarayel/frequency_moments", "max_forks_repo_head_hexsha": "b704c20fd18a29f41c587ad15ba402b2e5d8d17a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.9691629956, "max_line_length": 366, "alphanum_fraction": 0.6583493282, "num_tokens": 5085, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.61878043374385, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.4485355439007199}}
{"text": "\\def\\module{M3P8 Algebra III}\n\\def\\lecturer{Dr David Helm}\n\\def\\term{Autumn 2018}\n\\def\\cover{\n$$\n\\begin{tikzpicture}\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, 2) circle (7.5);\n\\draw (0, 9) node{Modules};\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, -1.25) ellipse (5 and 4.25);\n\\draw (0, -5) node{Noetherian modules};\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, 2) circle (6.5);\n\\draw (0, 8) node{Rings};\n\\draw (0, -4) node{Noetherian rings};\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, 2) circle (5.5);\n\\draw (0, 6.5) node{Integral domains};\n\\draw (0, -3) node{Noetherian domains};\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, 1.75) ellipse (4.75 and 4.25);\n\\draw (0, 5) node{Integrally closed domains};\n\\draw [fill=lightgray, opacity=0.1, very thick] (0, 1.75) ellipse (4 and 2.75);\n\\draw (0, 3.5) node{Unique factorisation domains};\n\\draw [fill=gray, opacity=0.1, very thick] (0, 0.25) ellipse (4 and 2.75);\n\\draw (0, -2) node{Dedekind domains};\n\\draw (0, 2.5) node{Principal ideal domains};\n\\draw [fill=gray, opacity=0.1, very thick] (0, 0.5) ellipse (2.5 and 1.5);\n\\draw (0, 1.5) node{Euclidean domains};\n\\draw [fill=gray, opacity=0.1, very thick] (0, 0) circle (1);\n\\draw (0, 0) node{Fields};\n\\end{tikzpicture}\n$$\n}\n\\def\\syllabus{Rings. Homomorphisms, ideals, and quotients. Factorisation. The Chinese remainder theorem. Fields and field extensions. Finite fields. $ R $-modules. Noetherian rings and modules. Polynomial rings in several variables. Integral extensions and algebraic integers. Dedekind domains. Integers in number fields. Introduction to algebraic geometry.}\n\\def\\thm{subsection}\n\n\\input{../style/header}\n\n\\begin{document}\n\n\\input{../style/cover}\n\n\\section{Introduction}\n\n\\lecture{1}{Friday}{05/10/18}\n\nThis course is an introduction to ring theory. The topics covered will include ideals, factorisation, the theory of field extensions, finite fields, polynomial rings in several variables, and the theory of modules. In addition to the lecture notes, the following will cover much of the material we will be studying.\n\\begin{itemize}\n\\item M Artin, Algebra, 1991\n\\end{itemize}\nRings are contexts in which it makes sense to add and multiply. For example,\n$$ \\ZZ, \\qquad \\QQ, \\qquad \\RR, \\qquad \\CC, \\qquad \\text{polynomials}, \\qquad \\cbr{0, 1} \\to \\RR, \\qquad \\ZZ / n\\ZZ $$\nare rings. The goals of this course include\n\\begin{itemize}\n\\item to unify arguments that apply in all of the above contexts, and\n\\item to study relationships between different rings.\n\\end{itemize}\nThe applications of rings include\n\\begin{itemize}\n\\item number theory, by studying extensions of $ \\ZZ $ in which particular Diophantine equations have solutions, such as $ n = x^2 + y^2 = \\br{x + iy}\\br{x - iy} $, to study solutions in $ \\ZZ\\sbr{i} $ and pass to result about $ \\ZZ $,\n\\item algebraic geometry, by the study of zero sets of polynomials in several variables via rings of functions, and\n\\item topology, by the cohomology classes of topological spaces.\n\\end{itemize}\n\n\\begin{note*}\nThe official notes are integrated in these unofficial notes.\n\\end{note*}\n\n\\pagebreak\n\n\\section{Basic definitions and examples}\n\n\\subsection{Rings}\n\nRecall the definition of a commmutative ring.\n\n\\begin{definition}\nA \\textbf{commutative ring with identity} $ R $ is a set together with two binary operations\n$$ +_R : R \\times R \\to R, \\qquad \\cdot_R : R \\times R \\to R, $$\n\\textbf{addition} and \\textbf{multiplication}, and two distinguished elements $ 0_R $ and $ 1_R $, such that the following holds.\n\\begin{itemize}\n\\item The operation $ +_R $ makes $ R $ into an abelian group with identity $ 0_R $, that is\n\\begin{itemize}\n\\item for all $ r \\in R $, $ 0_R +_R r = r +_R 0_R = 0_R $,\n\\item for all $ r, s, t \\in R $, $ \\br{r +_R s} +_R t = r +_R \\br{s +_R t} $,\n\\item for all $ r, s \\in R $, $ r +_R s = s +_R r $, and\n\\item for all $ r \\in R $, there exists $ -r \\in R $ such that $ r +_R \\br{-r} = \\br{-r} +_R r = 0_R $.\n\\end{itemize}\n\\item The operation $ \\cdot_R $ is associative and commutative with identity $ 1_R $. That is,\n\\begin{itemize}\n\\item for all $ r \\in R $, $ 1_R \\cdot_R r = r \\cdot_R 1_R = 1_R $,\n\\item for all $ r, s, t \\in R $, $ \\br{r \\cdot_R s} \\cdot_R t = r \\cdot_R \\br{s \\cdot_R t} $, and\n\\item for all $ r, s \\in R $, $ r \\cdot_R s = s \\cdot_R r $.\n\\end{itemize}\n\\item Multiplication distributes over addition. That is,\n\\begin{itemize}\n\\item for all $ r, s, t \\in R $, $ r \\cdot_R \\br{s +_R t} = r \\cdot_R s +_R r \\cdot_R t $, and\n\\item for all $ r, s, t \\in R $, $ \\br{s +_R t} \\cdot_R r = s \\cdot_R r +_R t \\cdot_R r $.\n\\end{itemize}\n\\end{itemize}\n\\end{definition}\n\nThere is some redundancy here, of course. I have written things this way so that one obtains the definition of a \\textbf{noncommutative ring} simply by removing the condition that multiplication is commutative. In this course, however, all rings will be commutative. When it is clear from the context what ring we are working with, we will write $ 0_R $ and $ 1_R $ as $ 0 $ and $ 1 $, $ a +_R b $ as $ a + b $, and $ a \\cdot_R b $ as $ ab $.\n\n\\begin{proposition}\nLet $ R $ be a ring. Then for all $ r \\in R $, $ r \\cdot_R 0_R = 0_R $.\n\\end{proposition}\n\n\\begin{proof}\n$ r \\cdot_R 0_R = r \\cdot_R \\br{0_R +_R 0_R} = r \\cdot_R 0_R +_R r \\cdot_R 0_R $, so\n$$ 0_R = -\\br{r \\cdot_R 0_R} +_R \\br{r \\cdot_R 0_R} = -\\br{r \\cdot_R 0_R} +_R \\br{r \\cdot_R 0_R +_R r \\cdot_R 0_R} = r \\cdot_R 0_R. $$\n\\end{proof}\n\n\\begin{note*}\nSome definitions of rings require $ 1_R \\ne 0_R $ in $ R $. We will not do this.\n\\end{note*}\n\n\\begin{proposition}\nIf $ 0_R = 1_R $, then $ R $ is the one-element ring $ \\cbr{0_R} $.\n\\end{proposition}\n\n\\begin{proof}\nWe certainly have $ r = 1_R \\cdot_R r = 0_R \\cdot_R r $. On the other hand\n$$ 0_R \\cdot_R r = \\br{0_R +_R 0_R} \\cdot_R r = 0_R \\cdot_R r +_R 0_R \\cdot_R r, $$\nand subtracting $ 0_R \\cdot_R r $ from both sides we find that $ 0_R \\cdot_R r = 0_R $.\n\\end{proof}\n\n\\begin{definition}\nA ring $ R $ is a \\textbf{field} if $ R \\ne \\cbr{0_R} $ and every nonzero element of $ R $ has a multiplicative inverse. That is, for every $ r \\in R \\setminus \\cbr{0_R} $ there exists $ r^{-1} \\in R $ such that\n$$ rr^{-1} = r^{-1}r = 1_R. $$\n\\end{definition}\n\nWe do not consider the zero ring $ \\cbr{0_R} $ to be a field. We have seen many examples of rings at this point.\n\n\\pagebreak\n\n\\begin{example*}\nThe sets $ \\ZZ, \\QQ, \\RR, \\CC $ are all rings with their usual notion of addition and multiplication. All of them but $ \\ZZ $ are in fact fields. We have the ring $ \\ZZ / n\\ZZ $ of integers modulo $ n $. Let $ n \\in \\ZZ_{> 0} $, and recall that $ a $ and $ b $ are said to be \\textbf{congruent modulo $ n $} if $ a - b $ is divisible by $ n $. It is easy to check that this is an equivalence relation on $ \\ZZ $. Moreover, since any $ a \\in \\ZZ $ can uniquely be written as $ qn + r $ with $ q, r \\in \\ZZ $ and $ 0 \\le r < n $, the set\n$$ \\cbr{\\sbr{0}_n, \\dots, \\sbr{n - 1}_n} $$\nis a complete list of the equivalence classes under this relation, where $ \\sbr{a}_n $ denotes the set of all integers congruent to $ a \\mod n $. We denote this $ n $-element set by $ \\ZZ / n\\ZZ $, and we can define addition and multiplication in $ \\ZZ / n\\ZZ $ by setting\n$$ \\sbr{a}_n + \\sbr{b}_n = \\sbr{a + b}_n, \\qquad \\sbr{a}_n\\sbr{b}_n = \\sbr{ab}_n. $$\nThis defines a ring structure on $ \\ZZ / n\\ZZ $, once one checks that it is well-defined. This is the first example of a general construction we will see more of later, the quotient of a ring by an ideal.\n\\end{example*}\n\n\\subsection{Polynomial rings}\n\n\\lecture{2}{Monday}{08/10/18}\n\nA very important class of rings that we will study are the polynomial rings. Let $ R $ be any ring. Then we can form a new ring $ R\\sbr{X} $, called the \\textbf{ring of polynomials in $ X $ with coefficients in $ R $}. Informally, a polynomial in $ R\\sbr{X} $ is a finite sum of the form\n$$ r_0 + \\dots + r_nX^n, \\qquad n \\in \\ZZ_{\\ge 0}, \\qquad r_0, \\dots, r_n \\in R. $$\nIf $ n > m $, we consider $ r_0 + \\dots + r_nX^n $ to represent the same polynomial of $ R\\sbr{X} $ as $ s_0 + \\dots + s_mX^m $ if $ r_i = s_i $ for $ i \\le m $ and $ r_i = 0_R $ for $ i > m $. That is, you can pad out polynomials with terms of the form $ 0_RX^i $ without changing it. From a formal standpoint, it is better to define a polynomial to be an infinite sum\n$$ \\sum_{n = 0}^\\infty r_iX^i = r_0 + r_1X + \\dots, \\qquad r_i \\in R, $$\nin which all but finitely many $ r_i $ are zero. This makes it easier to define addition and multiplication. The \\textbf{degree} of such an expression is the largest $ i $ such that $ r_i $ is nonzero. We add and multiply in $ R\\sbr{X} $ just as we would any other polynomials,\n$$ \\sum_{i = 0}^\\infty r_iX^i +_{R\\sbr{X}} \\sum_{i = 0}^\\infty s_iX^i = \\sum_{i = 0}^\\infty \\br{r_i +_R s_i} X^i, \\qquad \\sum_{i = 0}^\\infty r_iX^i \\cdot_{R\\sbr{X}} \\sum_{i = 0}^\\infty s_iX^i = \\sum_{i = 0}^\\infty \\sum_{j = 0}^i \\br{r_j \\cdot_R s_{i - j}} X^i. $$\nWhat about polynomial rings in more than one variable? Since the construction of polynomial rings takes an arbitrary ring as input, one can iterate it. Start with a ring $ R $, and consider first the ring $ R\\sbr{X} $ and then the ring $ \\br{R\\sbr{X}}\\sbr{Y} $. A polynomial of this has the form\n$$ \\sum_{i = 0}^\\infty \\sum_{j = 0}^\\infty r_{ij}X^jY^i, \\qquad r_{ij} \\in R. $$\nOn the other hand, we can consider the ring $ \\br{R\\sbr{Y}}\\sbr{X} $, whose polynomials have the form\n$$ \\sum_{i = 0}^\\infty \\sum_{j = 0}^\\infty r_{ij}Y^jX^i, \\qquad r_{ij} \\in R. $$\nAlternatively, we could consider the ring $ R\\sbr{X, Y} $ whose polynomials are formal expressions of the form\n$$ \\sum_{i, j = 0}^\\infty r_{ij}X^iY^j, \\qquad r_{ij} \\in R. $$\nIt is not hard to see that all three approaches yield the same ring. If we identify these elements, we see that addition and multiplication in any of these three rings gives the same answer. We will therefore primarily use notation like $ R\\sbr{X, Y} $ for polynomial rings in multiple variables, but we will occasionally need to know that this is the same as $ \\br{R\\sbr{X}}\\sbr{Y} $ or $ \\br{R\\sbr{Y}}\\sbr{X} $. The identifications we have made here are an example of isomorphisms of rings, a notion we will make precise later.\n\n\\pagebreak\n\n\\subsection{Subrings and extensions}\n\n\\begin{definition}\nLet $ R $ be a ring. A subset $ S $ of $ R $ is a \\textbf{subring} of $ R $ if\n\\begin{itemize}\n\\item $ 0_R, 1_R, -1_R \\in S $, and\n\\item $ S $ is closed under $ +_R $ and $ \\cdot_R $, so if $ r, s \\in S $, then so are $ r +_R s $ and $ r \\cdot_R s $.\n\\end{itemize}\n\\end{definition}\n\n\\begin{example*}\n$ \\ZZ $ is a subring of $ \\RR $, which is itself a subring of $ \\CC $.\n\\end{example*}\n\nSubrings inherit the additive and multiplicative structures from the ring that contains them, and are thus themselves rings. It is easy to see that the intersection of two subrings of $ R $, or even an arbitrary collection of subrings of $ R $, is also a subring of $ R $.\n\n\\begin{definition}\nNow let $ S \\subseteq R $ be a subring of a ring $ R $, and let $ \\alpha $ be an element of $ R $. We can then form a subring $ S\\sbr{\\alpha} $ of $ R $, called the \\textbf{subring of $ R $ generated by $ \\alpha $ over $ S $}, as follows. An element of $ R $ lies in $ S\\sbr{\\alpha} $ if and only if it can be expressed in the form\n$$ r_0 + \\dots + r_n\\alpha^n, \\qquad n \\in \\ZZ^*, \\qquad r_0, \\dots, r_n \\in S. $$\nThis operation is known as \\textbf{adjoining} the element $ \\alpha $ to the ring $ S $.\n\\end{definition}\n\n\\begin{example*}\nLet $ i $ denote a square root of $ -1 $ in $ \\CC $, and consider the subring $ \\ZZ\\sbr{i} $ of $ \\CC $ formed by $ \\ZZ \\subseteq \\CC $ and $ i $. This consists of all complex numbers that can be expressed as polynomials in $ i $ with integer coefficients. Note that such an expression need not be unique. For instance the element $ 1 + i $ of $ \\ZZ\\sbr{i} $ can also be written as $ 2 + i + i^2 $, and $ -1 = i^2 = i^6 = i + i^3 + i^{10} $.\n\\end{example*}\n\nIndeed, since $ i^2 = -1 $, the following holds.\n\n\\begin{proposition}\nWe can uniquely express any element $ a_0 + \\dots + a_ni^n $ of $ \\ZZ\\sbr{i} $ as $ a + bi $ for $ a, b \\in \\ZZ $.\n\\end{proposition}\n\n\\begin{proof}\nGiven $ \\sum_{n = 0}^\\infty a_ni^n $ with only finitely many $ a_n $ nonzero, set $ a = a_0 - a_2 + \\dots \\in \\ZZ $ and $ b = a_1 - a_3 + \\dots \\in \\ZZ $. Then\n$$ \\sum_{n = 0}^\\infty a_ni^n = a + bi. $$\nThis expression is clearly unique, as if $ a + bi = c + di $ in $ \\CC $ for $ a, b, c, d \\in \\ZZ $, then $ a = c $ and $ b = d $.\n\\end{proof}\n\nIf $ \\alpha $ is more complicated then the elements of $ R\\sbr{\\alpha} $ may well be harder to describe, and indeed, a nice description might not exist at all.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item If $ \\alpha $ is the real cube root of $ 2 $, then every element of $ \\ZZ\\sbr{\\alpha} $ can be uniquely expressed as $ a + b\\alpha + c\\alpha^2 $, where $ a, b, c \\in \\ZZ $.\n\\item In $ \\ZZ\\sbr{\\pi} $, any element has a unique expression in the form $ \\sum_{n = 0}^\\infty a_n\\pi^n $ for all but finitely many $ a_n $ are zero. Suppose $ \\sum_{n = 0}^\\infty a_n\\pi^n = \\sum_{n = 0}^\\infty b_n\\pi^n $, then\n$$ 0 = \\sum_{n = 0}^\\infty \\br{a_n - b_n}\\pi^n. $$\nSince $ \\pi $ is transcendental, this polynomial must be zero. Thus each $ a_n = b_n $.\n\\item The elements of $ \\ZZ\\sbr{\\tfrac{1}{2}} $ can be expressed uniquely as $ a / b $, where $ b $ is a power of $ 2 $ and $ a $ is odd unless $ b = 1 $. If $ \\alpha $ is a root of the polynomial $ x^2 - x / 2 + 1 $ then $ \\alpha^2 \\in \\ZZ\\sbr{\\alpha} $ and $ \\alpha^2 = \\alpha / 2 - 1 $. Can show that every element of $ \\ZZ\\sbr{\\alpha} $ can be uniquely expressed as $ a + b\\alpha $, where $ a $ and $ b $ lie in $ \\ZZ\\sbr{\\tfrac{1}{2}} $, but there are pairs $ a $ and $ b $ such that $ a + b\\alpha $ does not lie in $ \\ZZ\\sbr{\\alpha} $.\n\\end{itemize}\n\\end{example*}\n\n\\begin{exercise*}\nFor which pairs $ a $ and $ b $ of elements of $ \\ZZ\\sbr{\\tfrac{1}{2}} $ does $ a + b\\alpha $ lie in $ \\ZZ\\sbr{\\alpha} $?\n\\end{exercise*}\n\nAn alternative way of defining the ring $ S\\sbr{\\alpha} $ is to note that it is the smallest subring of $ R $ containing $ S $ and $ \\alpha $. In one direction, any such subring contains every expression of the form $ r_0 + \\dots + r_n\\alpha^n $, with $ r_i \\in S $, so any subring of $ R $ containing $ S $ and $ \\alpha $ contains $ S\\sbr{\\alpha} $. One can thus construct $ S\\sbr{\\alpha} $ as the intersection of every subring of $ R $ containing $ S $ and $ \\alpha $. Since the intersection of any collection of subrings of $ R $ is a subring of $ R $ it is clear that this intersection is equal to $ S\\sbr{\\alpha} $ as defined above.\n\n\\pagebreak\n\n\\subsection{Integral domains and rings of fractions}\n\n\\lecture{3}{Wednesday}{10/10/18}\n\n\\begin{definition}\nA \\textbf{zero divisor} in a ring $ R $ is a nonzero element $ r $ of $ R $ such that there exists a nonzero $ s \\in R $ with $ rs = 0 $. A ring $ R $ in which there are no zero divisors is called an \\textbf{integral domain}.\n\\end{definition}\n\n\\begin{example*}\n$ \\ZZ $ is an integral domain and any subring of a field is an integral domain, but $ \\ZZ / 6\\ZZ $ is not an integral domain, as $ \\sbr{2}\\sbr{3} $ is $ 0 \\mod 6 $ even though neither $ \\sbr{2} $ nor $ \\sbr{3} $ is $ 0 \\mod 6 $.\n\\end{example*}\n\nIf $ R $ is an integral domain, then we can form the field of fractions of $ R $ in analogy to the way we build $ \\QQ $ from $ \\ZZ $.\n\n\\begin{definition}\nLet $ R $ be an integral domain. The \\textbf{field of fractions} $ K\\br{R} $ is the set of equivalence classes of expressions of the form $ a / b $, where $ a $ and $ b $ are elements of $ R $ with $ b $ nonzero, and $ a / b $ is equivalent to $ a' / b' $ if and only if $ ab' = a'b $. We add and multiply elements of $ K\\br{R} $ just as we do for fractions,\n$$ \\dfrac{a}{b} + \\dfrac{a'}{b'} = \\dfrac{ab' + ba'}{bb'}, \\qquad \\dfrac{a}{b} \\cdot \\dfrac{a'}{b'} = \\dfrac{aa'}{bb'}. $$\nThen $ K\\br{R} $ is a field, and it contains $ R $ in a natural way as a subring if we identify $ r $ with $ r / 1_R \\in K\\br{R} $.\n$$ 0_{K\\br{R}} = \\dfrac{0_R}{1_R}, \\qquad 1_{K\\br{R}} = \\dfrac{1_R}{1_R}. $$\nIf $ a \\ne 0 $ in $ R $, then $ b / a \\in K\\br{R} $, so\n$$ \\dfrac{a}{b} \\cdot \\dfrac{b}{a} = \\dfrac{ab}{ba} \\sim \\dfrac{1}{1}. $$\n\\end{definition}\n\nThe field $ K\\br{R} $ is in some sense the smallest field containing $ R $ as a subring. When we talk about homomorphisms and isomorphisms, we will be able to state this more precisely. More generally, let the \\textbf{multiplicative system} $ S $ be a subset of $ R $ that contains $ 1_R $, does not contain $ 0_R $ and is closed under multiplication. That is, if $ a $ and $ b $ are in $ S $ then so is $ ab $. For any integral domain $ R $ and any multiplicative system $ S $, we can define $ S^{-1}R $ to be the subring of $ K\\br{R} $ consisting of all fractions of the form $ a / b $ with $ b \\in S $. It is easy to see that this is closed under addition and multiplication, and defines a ring in between $ R $ and $ K\\br{R} $.\n\n\\begin{example*}\nIf $ R = \\ZZ $ and $ S $ is the set of powers of $ 2 $, then $ S^{-1}R = \\ZZ\\sbr{\\tfrac{1}{2}} $. On the other hand, if $ S $ is the set of odd integers, then $ S^{-1}R $ is the set of all rational numbers of the form $ a / b $ with $ b $ odd.\n\\end{example*}\n\nIn general $ S^{-1}R $ is the smallest subring of $ K\\br{R} $ containing $ R $ in which every element of $ S $ has a multiplicative inverse, that is $ 1 / b \\in S $ for all $ b \\in S $. The process of obtaining $ S^{-1}R $ from $ R $ is called \\textbf{localisation} and is an extremely powerful tool. One can even make sense of it when $ R $ is not an integral domain, but one has to be more careful. The equivalence relation on fractions is trickier, for example. We will not discuss this in this course but it will be quite useful in future courses.\n\n\\pagebreak\n\n\\section{Homomorphisms, ideals, and quotients}\n\n\\subsection{Homomorphisms}\n\nLet $ R $ and $ S $ be rings. A ring homomorphism from $ R $ to $ S $ is, roughly, a way of interpreting elements of $ R $ as elements of $ S $, in a way that is compatible with the addition and multiplication laws on $ R $ and $ S $. More precisely is the following.\n\n\\begin{definition}\nA function $ f : R \\to S $ is a \\textbf{ring homomorphism} if\n\\begin{enumerate}\n\\item $ f\\br{1_R} = 1_S $,\n\\item for all $ r, r' \\in R $, $ f\\br{r +_R r'} = f\\br{r} +_S f\\br{r'} $,\n\\item for all $ r, r' \\in R $, $ f\\br{r \\cdot_R r'} = f\\br{r} \\cdot_S f\\br{r'} $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{note*}\nIf $ f $ is a homomorphism then $ f\\br{0_R} = 0_S $. This is because $ f\\br{0_R} = f\\br{0_R + 0_R} = f\\br{0_R} +_S f\\br{0_R} $. Adding the additive inverse, in $ S $, of $ f\\br{0_R} $ to both sides gives $ 0_S = f\\br{0_R} $. Thus we do not need to require this as an axiom. On the other hand we do need to require $ f\\br{1_R} = 1_S $. For certain $ R $ and $ S $ one can construct examples of maps $ f : R \\to S $ that satisfy properties $ 2 $ and $ 3 $ of the definition without satisfying property $ 1 $.\n\\end{note*}\n\n\\begin{definition}\nA bijective homomorphism $ f : R \\to S $ is called an \\textbf{isomorphism}. Write $ S \\cong R $ for $ S $ is isomorphic to $ R $. In this case one verifies easily that the inverse map $ f^{-1} : S \\to R $ is also a bijective homomorphism.\n\\end{definition}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item If $ R $ is a subring of $ S $, then the inclusion of $ R $ into $ S $ is a homomorphism. This is just a fancy way of saying that the addition and multiplication on $ R $ are induced from the corresponding operations on $ S $. In particular the inclusions $ \\ZZ \\subset \\QQ \\subset \\RR \\subset \\CC $ are all homomorphisms.\n\\item The composition of two homomorphisms is a homomorphism, as is easily checked from the definitions.\n\\item The map $ \\ZZ \\to \\ZZ / n\\ZZ $ that takes $ m \\in \\ZZ $ into its congruence class modulo $ n $ is a ring homomorphism.\n\\end{itemize}\n\\end{example*}\n\nIn fact, this is a special case of the following construction.\n\n\\begin{proposition}\nLet $ R $ be any ring. Then there is a unique ring homomorphism $ f : \\ZZ \\to R $ such that\n$$ f\\br{n} =\n\\begin{cases}\n1_R + \\dots + 1_R & n > 0 \\\\\n0_R & n = 0 \\\\\n-\\br{1_R + \\dots + 1_R} & n < 0\n\\end{cases}.\n$$\n\\end{proposition}\n\n\\begin{proof}\nLet $ f : \\ZZ \\to R $ be a homomorphism. Then, directly from the definition, we have $ f\\br{0} = 0_R $ and $ f\\br{1} = 1_R $. In particular for all $ n > 0 $,\n$$ f\\br{n} = f\\br{1 + \\dots + 1} = 1_R + \\dots + 1_R, $$\nwhere there are $ n $ copies of $ 1_R $ in the sum. Moreover, since\n$$ 0_R = f\\br{n + \\br{-n}} = f\\br{n} + f\\br{-n}, $$\nwe find that $ f\\br{-n} $ is the additive inverse of $ 1_R + \\dots + 1_R $. Thus $ f\\br{n} $ is determined, for all $ n $, completely by the fact that $ f $ is a homomorphism. In the converse direction, it is not hard to check that the map defined above is in fact a homomorphism.\n\\end{proof}\n\nThus, for any ring $ R $, we can regard an integer as an element of $ R $ via this homomorphism.\n\n\\pagebreak\n\n\\subsection{Evaluation homomorphisms}\n\nLet $ R $ be a ring, and consider the ring $ R\\sbr{X} $ of polynomials in $ X $ with coefficients in $ R $. If $ s $ is an element of $ R $, then we can define a homomorphism $ R\\sbr{X} \\to R $ by \\textbf{evaluation at $ s $}. More precisely, given an element of $ R\\sbr{X} $ of the form\n$$ P\\br{X} = r_0 + \\dots + r_nX^n, \\qquad n \\in \\ZZ_{\\ge 0}, \\qquad r_i \\in R. $$\nThen $ P\\br{s} $ for $ s \\in R $ is defined to be\n$$ P\\br{s} = r_0 + \\dots + r_ns^n \\in R. $$\nConsider the map\n$$ \\function[\\phi_s]{R\\sbr{X}}{R}{P\\br{X}}{P\\br{s}}. $$\nIn effect, it substitutes $ s $ for $ X $. It is easy to check that this is in fact a ring homomorphism. More generally, if $ R $ and $ S $ are rings and $ f : R \\to S $ is a homomorphism, and $ s $ is an element of $ S $, then we can define a map\n$$ \\function[\\phi_{s, f}]{R\\sbr{X}}{S}{r_0 + \\dots + r_nX^n}{f\\br{r_0} + \\dots + f\\br{r_n}s^n}. $$\nThat is, by applying $ f $ to the coefficients and substituting $ s $ for $ X $. Again, this is clearly a homomorphism. The evaluation homomorphisms $ \\phi_{s, f} $ are a fundamental property of polynomial rings. In some sense, they are the reason polynomial rings are worth studying. In fact, the ring $ R\\sbr{X} $ is uniquely characterised by the fact that homomorphisms from $ R\\sbr{X} $ to $ S $ are in bijection with pairs $ \\br{s, f} $, where $ f : R \\to S $ is a homomorphism and $ s $ is an element of $ S $.\n\n\\subsection{Images, kernels, and ideals}\n\n\\begin{definition}\nLet $ f : R \\to S $ be a homomorphism. The \\textbf{image} of $ f $ is\n$$ \\im f = \\cbr{f\\br{r} \\st r \\in R} \\subseteq S. $$\nThe \\textbf{kernel} of $ f $ is\n$$ \\ker f = \\cbr{r \\in R \\st f\\br{r} = 0} \\subseteq R. $$\n\\end{definition}\n\nThe image of a homomorphism $ f : R \\to S $ is easily seen to be a subring of $ S $.\n\n\\begin{example*}\nIf $ R $ is a subring of $ S $, $ f : R \\to S $ is the inclusion and $ s $ lies in $ S $, then the image of the map $ \\phi_{s, f} : R\\sbr{X} \\to S $ is precisely the subring $ R\\sbr{s} $ of $ S $.\n\\end{example*}\n\nBy contrast, the kernel of a homomorphism $ f $ is almost never a subring of $ R $. For instance, subrings contain the identity. However, we have the following.\n\n\\lecture{4}{Friday}{12/10/18}\n\n\\begin{definition}\nA nonempty subset $ I $ of $ R $ is an \\textbf{ideal} of $ R $ if $ I $ is closed under addition, that is for all elements $ i $ and $ j $ of $ I $, $ i + j $ is an element of $ I $, and for all elements $ i $ of $ I $ and $ r $ of $ R $, $ ri $ is an element of $ I $.\n\\end{definition}\n\nThen one can verify, directly from the definition, that the kernel of any homomorphism $ f : R \\to S $ is an ideal of $ R $. Any ideal of $ R $ contains $ 0_R $, and conversely the subset $ \\cbr{0_R} $ of $ R $ is an ideal, called the \\textbf{zero ideal}.\n\n\\begin{note*}\nA homomorphism $ f : R \\to S $ is injective if and only if its kernel is the zero ideal. Forward direction is easy. Conversely, if $ f\\br{x} = f\\br{y} $, then $ f\\br{x - y} = 0 $, so $ x - y \\in \\ker f $. If $ \\ker f = \\cbr{0} $, $ x = y $.\n\\end{note*}\n\nThe kernel of the homomorphism $ \\ZZ \\to R $ is either the zero ideal, or the ideal of multiples of $ n $ in $ \\ZZ $ for some $ n > 0 $. We say that $ R $ has \\textbf{characteristic zero} or \\textbf{characteristic $ n $}, respectively. If not zero, the characteristic of $ R $ is the smallest $ n $ such that the sum of $ n $ copies of $ 1_R $ is equal to zero.\n\n\\pagebreak\n\n\\subsection{Ideals: examples and basic operations}\n\nIf $ r $ is an element of $ R $, then any ideal containing $ R $ contains any multiple $ sr $ of $ R $, for any $ r $ in $ S $. Conversely, one checks easily that the set\n$$ \\cbr{sr \\st s \\in R} $$\nis an ideal of $ R $. It is known as the ideal of $ R $ generated by $ r $, and denoted $ \\abr{r} $. An ideal generated by one element in this way is called a \\textbf{principal ideal}.\n\n\\begin{note*}\nThe ideal generated by $ 1_R $, or more generally by any element of $ R $ with a multiplicative inverse, is all of $ R $. This ideal is called the \\textbf{unit ideal} of $ R $.\n\\end{note*}\n\n\\begin{proposition}\n$ R $ is a field if and only if the only ideals of $ R $ are the zero ideal $ \\cbr{0} $ and unit ideal $ R $.\n\\end{proposition}\n\n\\begin{proof}\nIf $ R $ is a field, let $ I \\subseteq R $ be a nonzero ideal. There exists $ r \\in I \\ne 0 $. Then for all $ s \\in R $, $ \\br{sr^{-1}}\\br{r} \\in I $, so $ s \\in I $ for all $ s \\in R $. Conversely, if $ R $ has only the zero ideal and the unit ideal, let $ r \\in R \\ne 0 $, and let $ I = \\cbr{sr \\st s \\in R} $. This is an ideal that is not the zero ideal, so it is all of $ R $. In particular, $ 1 \\in I $, so there exists $ s \\in R $ such that $ sr = 1 $.\n\\end{proof}\n\nMore generally is the following.\n\n\\begin{definition}\nIf $ S $ is a subset of elements of $ R $, then any ideal containing $ S $ consists of all elements of $ R $ of the form\n$$ r_0s_0 + \\dots + r_ns_n, \\qquad n \\in \\ZZ_{\\ge 0}, \\qquad r_i \\in R, \\qquad s_i \\in S. $$\nThe set of all elements of this form is an ideal of $ R $, known as the \\textbf{ideal of $ R $ generated by $ S $}, and denoted $ \\abr{S} $. It is the intersection of all the ideals of $ R $ containing $ S $. It is also the smallest ideal of $ R $ containing $ S $.\n\\end{definition}\n\nIf $ S $ has one element, $ \\abr{S} $ is a principal ideal. We will show soon that any ideal of $ \\ZZ $ is a principal ideal, as is any ideal of the ring $ K\\sbr{X} $ for any field $ K $. You may well have seen this in last year's\nalgebra course. On the other hand, there are rings in which not every ideal is principal. For example, the ideal $ \\abr{X, Y} $ of $ K\\sbr{X, Y} $ is not a principal ideal. Given ideals $ I $ and $ J $ there are several ways to create new ideals.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item If $ I $ and $ J $ are ideals, then the intersection $ I \\cap J $ is an ideal. Note that if $ I $ and $ J $ are given by generators, it might be hard to find generators for the intersection. Certainly it is not enough to intersect the generating sets.\n\\item If $ I $ and $ J $ are ideals, then the union of ideals is not usually an ideal. Taking $ R = \\ZZ $, $ \\abr{3} \\cup \\abr{5} $ contains $ 3 $ and $ 5 $ but not $ 3 + 5 $. The sum $ I + J = \\cbr{i + j \\st i \\in I, j \\in J} $ is an ideal. It is the smallest ideal containing both $ I $ and $ J $, or equivalently the ideal generated by $ I \\cup J $.\n\\item If $ I $ and $ J $ are ideals, the product $ IJ $ is the ideal generated by $ \\cbr{ij \\st i \\in I, \\ j \\in J} $. This may be strictly larger than the set of such products. For example, consider the product of the ideals $ I = \\abr{X, Y} $ and $ J = \\abr{Z, W} $ in $ R = K\\sbr{X, Y, Z, W} $ for $ K $ a field. The product $ IJ = \\abr{XZ, XW, YZ, YW} $ contains $ XZ + YW $, but the latter is not a product of an element in $ I $ with an element in $ J $.\n\\item If $ I $ and $ J $ are general ideals, the product of ideals $ I $ and $ J $ is always contained in the intersection of $ I $ and $ J $, but the two need not be equal, even in simple rings like $ \\ZZ $, since $ \\abr{3} \\cdot \\abr{3} = \\abr{9} $ and $ \\abr{3} \\cap \\abr{3} = \\abr{3} $.\n\\end{itemize}\n\\end{example*}\n\n\\subsection{Quotients}\n\nLet $ R $ be a ring and let $ I $ be an ideal of $ R $. If $ x $ and $ y $ are elements of $ R $, we say that $ x $ is congruent to $ y \\mod I $ if $ x - y $ is in $ I $. This is an equivalence relation on $ R $. We denote the equivalence class of $ r $ by $ r + I $, or as the alternative notations $ \\sbr{r}_I $ and $ \\overline{r} $. It is the set\n$$ \\cbr{r + s \\st s \\in I}. $$\nLet $ R / I $ denote the set of equivalence classes on $ R \\mod I $. This set has the natural structure of a ring. The additive and multiplicative identities are $ 0_R + I $ and $ 1_R + I $, respectively, and addition and multiplication are defined by\n$$ \\br{r + I} + \\br{s + I} = \\br{r + s} + I, \\qquad \\br{r + I} \\cdot \\br{s + I} = \\br{rs} + I $$\nrespectively. One has to check that these are well-defined, but this is not difficult.\n\n\\pagebreak\n\n\\begin{example*}\nIf $ R = \\ZZ $ and $ I $ is the ideal generated by $ n $, then $ R / I $ is the ring $ \\ZZ / n\\ZZ $ that we have already seen.\n\\end{example*}\n\nThe ring $ R / I $ is called the \\textbf{quotient} of $ R $ by the ideal $ I $. There is a natural quotient homomorphism, \\textbf{reduction modulo $ I $},\n$$ \\function{R}{R / I}{r}{r + I}. $$\nThis homomorphism is surjective with kernel $ I $. We then have the following.\n\n\\begin{proposition}[Universal property of the quotient]\n\\label{prop:2.5.1}\nLet $ I \\subseteq R $ be an ideal and let $ f : R \\to S $ be a homomorphism, and suppose that the kernel of $ f $ contains $ I $. Then there is a unique homomorphism\n$$ \\overline{f} : R / I \\to S, $$\nsuch that for all $ r \\in R $, $ f\\br{r} = \\overline{f}\\br{r + I} $.\n\\end{proposition}\n\n\\begin{proof}\nNote that $ \\overline{f} $ is necessarily unique, as every element of $ R / I $ has the form $ r + I $ for some $ r $. We must thus show that it is well-defined and gives a homomorphism. If $ r + I = r' + I $, then $ r $ and $ r' $ differ by an element of $ I $, so $ f\\br{r - r'} = 0 $, so $ f\\br{r} = f\\br{r'} $ since $ I $ is contained in the kernel of $ f $. Thus $ \\overline{f} $ is well-defined. Checking that it is a homomorphism follows from $ f $ is a homomorphism.\n\\end{proof}\n\n\\begin{note*}\nThe kernel of $ \\overline{f} $ in Proposition \\ref{prop:2.5.1} above is just the image of the kernel of $ f $ in $ R / I $. If the kernel of $ f $ is equal to $ I $, this image is the zero ideal and $ \\overline{f} $ is injective. In particular, any homomorphism of $ R $ to $ S $ can be thought of as an isomorphism of some quotient of $ R $ with a subring of $ S $.\n\\end{note*}\n\n\\begin{example*}\nLet $ R \\subseteq S $ be a subring, $ \\alpha \\in S $, and $ \\iota : R \\to S $ be the inclusion map. Recall that we have an evaluation at $ \\alpha $ by $ \\phi_{\\iota, \\alpha} : R\\sbr{X} \\to S $. Image of this is $ R\\sbr{\\alpha} $. Let $ I = \\ker \\phi_{\\iota, \\alpha} $. Then $ \\phi_{\\iota, \\alpha} $ descends to a map $ R\\sbr{X} / I \\to S $ that is injective with image $ R\\sbr{\\alpha} $. So $ R\\sbr{\\alpha} $ is isomorphic to a quotient of $ R\\sbr{X} $.\n\\end{example*}\n\n\\subsection{Prime and maximal ideals}\n\n\\lecture{5}{Monday}{15/10/18}\n\n\\begin{definition}\n\\label{def:2.6.1}\nAn ideal $ I $ of $ R $ is \\textbf{prime} if the quotient $ R / I $ is an integral domain. It is \\textbf{maximal} if $ R / I $ is a field.\n\\end{definition}\n\n\\begin{note*}\nAs fields are integral domains, every maximal ideal is prime. The converse need not hold, of course. The zero ideal in $ \\ZZ $ is prime but not maximal.\n\\end{note*}\n\n\\begin{lemma}\nAn ideal $ I $ is prime if and only if for every pair of elements $ r $ and $ s $ in $ R $ such that $ rs $ is in $ I $, either $ r $ is in $ I $ or $ s $ is in $ I $.\n\\end{lemma}\n\n\\begin{proof}\nThis is just a restatement of Definition \\ref{def:2.6.1}. $ R / I $ is an integral domain if and only if for all whenever two elements $ r + I $ and $ s + I $ in $ R / I $ satisfy $ \\br{r + I}\\br{s + I} = 0 + I $ in $ R / I $, either $ r + I = 0 + I $ or $ s + I = 0 + I $ in $ R / I $. This is the same as saying $ rs $ lies in $ I $ if and only if either $ r $ or $ s $ lies in $ I $.\n\\end{proof}\n\n\\begin{lemma}\nAn ideal $ I $ is maximal if and only if the only ideals of $ R $ containing $ I $ are $ I $ and the unit ideal $ R $.\n\\end{lemma}\n\nThis justifies the name maximal for such ideals.\n\n\\begin{proof}\nFirst suppose that $ R / I $ is a field. Recall that $ R / I $ is a field if and only if only the ideals of $ R / I $ are $ \\cbr{0} $ and $ R / I $. Given an ideal $ J \\subseteq R / I $, let $ \\widetilde{J} $ be the preimage of $ J $ under $ R \\to R / I $. Then $ \\widetilde{J} $ is an ideal containing $ I $ and contained in $ R $, so $ J $ is either the zero ideal of $ R / I $, in which case $ \\widetilde{J} $ is contained in, and thus equal to, $ I $, or $ J $ is all of $ R / I $, in which case $ \\widetilde{J} $ contains $ I $ and an element of $ 1_R + I $, so $ \\widetilde{J} $ contains $ 1_R $ and is thus the unit ideal of $ R $. Conversely, if the only ideals of $ R $ containing $ I $ are $ I $ and the unit ideal, then for any $ r $ in $ R \\setminus I $, the ideal of $ R $ generated by $ I $ and $ r $ contains $ 1_R $. We can thus write $ 1_R = rs + i $, where $ i \\in I $ and $ s \\in R $. This means that $ s + I $ and $ r + I $ are multiplicative inverses of each other in $ R / I $, so $ R / I $ is a field.\n\\end{proof}\n\n\\pagebreak\n\n\\section{Factorisation}\n\nIn these notes $ R $ always denotes an integral domain.\n\n\\subsection{Divisibility, units, associates, and irreducibles}\n\n\\begin{definition}\nLet $ r $ and $ s $ be elements of $ R $. We say $ r $ \\textbf{divides} $ s $, denoted $ r \\mid s $, if there exists $ r' \\in R $ with $ rr' = s $, or, equivalently, $ s $ lies in the principal ideal $ \\abr{r} $ generated by $ r $. An element $ r $ that divides $ 1_R $ is called a \\textbf{unit} of $ R $, or, equivalently, $ \\abr{r} = R $. The set of units in $ R $ forms a group under multiplication denoted $ R^\\times $.\n\\end{definition}\n\nFor any element $ r \\in R $ and any unit $ u $ of $ R $, both $ u $ and $ ur $ divide $ r $.\n\n\\begin{definition}\nThe set of elements of $ R $ of the form $ ur $, with $ u \\in R^\\times $ are called \\textbf{associates} of $ R $.\n\\end{definition}\n\nThat is, $ r $ and $ r' $ are associates if $ r = ur' $ for a unit $ u \\in R^\\times $. This implies $ r \\mid r' $, that is there exists $ u' $ with $ u'u = 1 $ and $ u'r = r' $.\n\n\\begin{note*}\nThe principal ideals $ \\abr{r} $ and $ \\abr{r'} $ are equal if and only if $ r $ and $ r' $ are associates.\n\\end{note*}\n\n\\begin{definition}\nA nonzero element $ r $ of $ R $ is called \\textbf{irreducible} if $ r $ is not a unit and the only elements of $ R $ that divide $ r $ are the units and the associates of $ r $.\n\\end{definition}\n\n\\subsection{Unique factorisation domains}\n\nAn interesting question is when elements of rings admit unique factorisations into irreducibles? To that end we define the following.\n\n\\begin{definition}\nA \\textbf{unique factorisation domain (UFD)} is a ring $ R $ in which\n\\begin{enumerate}\n\\item every nonzero, nonunit element $ r $ of $ R $ admits a factorisation as a finite product of irreducibles in $ R $, and\n\\item if $ r = p_1 \\dots p_n = q_1 \\dots q_m \\in R $ are two factorisations of $ r $ as products of irreducibles $ p_i $ and $ q_i $, then $ n = m $ and, after permuting the $ q_i $, each $ q_i $ is an associate of $ p_i $.\n\\end{enumerate}\n\\end{definition}\n\nBoth conditions can fail.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item There are certainly domains in which $ 1 $ can fail, although they are somewhat exotic. One example is to take the rational polynomial ring $ R = \\CC\\sbr{X^\\QQ} $ with coefficients in $ \\CC $, whose entries are finite formal sums\n$$ \\sum_{i = 0}^N a_iX^{n_i}, \\qquad a_i \\in \\CC, \\qquad n_i \\in \\QQ_{\\ge 0}. $$\nAny such expression of $ R $ is a polynomial in $ X^{1 / n} $ for some $ n $. The element $ X $ of this ring is not a unit, and also not a finite product of irreducibles. In $ \\CC\\sbr{X^\\QQ} $, $ X $ factors as $ \\br{X^{1 / n}}^n $, so $ X $ has no factorisation into irreducibles in $ R $.\n\\item Even if $ 1 $ holds, $ 2 $ often fails. The classic example of this is $ R = \\ZZ\\sbr{\\sqrt{-5}} $, in which $ 2, 3, 1 + \\sqrt{-5}, 1 - \\sqrt{-5} $ are all irreducibles, none are associates of each other, yet $ \\br{2}\\br{3} = \\br{1 + \\sqrt{-5}}\\br{1 - \\sqrt{-5}} $.\n\\end{itemize}\n\\end{example*}\n\nWe will show later that a very mild finiteness condition on a domain $ R $, the condition that $ R $ is Noetherian, actually guarantees that $ 1 $ holds. Another way to interpret condition $ 2 $ is as follows.\n\n\\begin{definition}\nWe say an element $ r $ of $ R $ is \\textbf{prime} if the principal ideal $ \\abr{r} $ of $ R $ is a prime ideal. In other words, for any $ s $ and $ s' $ in $ R $, if $ r $ divides $ ss' $, then $ r \\mid s $ or $ r \\mid s' $.\n\\end{definition}\n\n\\begin{lemma}\nPrime elements are irreducible.\n\\end{lemma}\n\n\\begin{proof}\nIf $ r $ is prime and $ s $ divides $ r $, we can write $ r = ss' $. Then since $ r $ divides $ ss' $ we have that either $ r $ divides $ s $, in which case $ rs'' = s $, then $ ss's'' = s $ and $ s's'' = 1 $, so $ r $ is an associate of $ s $, or $ r $ divides $ s' $, in which case $ s' = rs'' $, then $ r = srs'' $ and $ ss'' = 1 $, so $ r $ is an associate of $ s' $ and $ s $ is a unit.\n\\end{proof}\n\n\\pagebreak\n\nThe converse is not necessarily true, but we have the following observation as criteria for $ R $ to be a UFD.\n\n\\begin{proposition}\nLet $ R $ be a domain in which condition $ 1 $ holds. Then condition $ 2 $ above holds for $ R $ if and only if every irreducible element of $ R $ is prime.\n\\end{proposition}\n\n\\begin{proof}\nFirst suppose condition $ 2 $ holds, and let $ r $ be an irreducible element of $ R $. If $ r $ divides $ ab $, we can write $ rs = ab $ for some $ s \\in R $. Expanding out $ s, a, b $ as products of irreducibles we see that $ r $ is an associate of some irreducible dividing $ a $ or $ b $, so $ r $ is prime. Conversely, if every irreducible element of $ R $ is prime, and we have products of irreducibles\n$$ p_1 \\dots p_n = q_1 \\dots q_m, $$\nthen, since $ p_1 $ is prime, it divides the product $ q_1 \\dots q_m $ and is thus an associate of some $ q_i $. We can thus cancel $ p_1 $ from the left and $ q_i $ from the right, after introducing a unit on one side. This is possible because $ R $ is an integral domain. Repeating the process we find that, up to reordering the terms and multiplying by units, the two expressions coincide.\n\\end{proof}\n\n\\subsection{Principal ideal domains}\n\n\\begin{definition}\nAn integral domain $ R $ is a \\textbf{principal ideal domain (PID)} if every ideal of $ R $ is a principal ideal.\n\\end{definition}\n\n\\begin{theorem}\n\\label{thm:3.3.2}\nEvery PID is a UFD.\n\\end{theorem}\n\nWe first show $ 1 $. It is true for units trivially.\n\n\\begin{lemma}\nLet $ R $ be a PID. Then every nonzero nonunit $ r \\in R $ has a irreducible divisor.\n\\end{lemma}\n\n\\begin{proof}\nFix $ r = r_0 \\in R $. We first show $ r $ has an irreducible factor. If $ r_0 $ is irreducible we are done. Otherwise if $ r_0 $ is not irreducible, we can choose an $ r_1 $, not a unit nor an associate of $ r_0 $, such that $ r_1 $ divides $ r_0 $, so $ r_0 = r_1s_1 $ with $ r_1 $ and $ s_1 $ not units. If $ r_1 $ is not irreducible we choose $ r_2 $ similarly, and repeat. If this process ever terminates we have found an irreducible divisor of $ r $. It suffices to show this terminates. Suppose it does not terminate. We obtain an increasing tower of ideals\n$$ \\abr{r_0} \\subsetneq \\abr{r_1} \\subsetneq \\dots. $$\nLet $ I $ be the union of all these ideals generated by $ r_0, r_1, \\dots $. Then $ I $ is an ideal, so it is generated by some element $ s \\in I $. Thus $ s $ divides $ r_i $ for all $ i $. On the other hand, $ s $ lives in some $ \\abr{r_j} $, so $ r_j $ divides $ s $. Thus $ s $ is an associate of $ r_j $, and therefore an associate of $ r_i $ for all $ i > j $, that is $ I \\subseteq \\abr{r_j} $. This contradicts our construction, because $ \\abr{r_{j + 1}} \\subseteq I $ and $ \\abr{r_{j + 1}} \\ne \\abr{r_j} $.\n\\end{proof}\n\nThus $ r $ has an irreducible divisor $ s_0 $.\n\n\\begin{lemma}\nLet $ R $ be a PID. Every nonzero nonunit $ r \\in R $ is a finite product of irreducibles.\n\\end{lemma}\n\n\\begin{proof}\nConsider $ rs_0^{-1} $. If this is a unit we are done. If not let $ s_1 $ be an irreducible divisor of $ rs_0^{-1} $. If $ r\\br{s_0s_1}^{-1} $ is a unit we are done. Otherwise repeat. We obtain a sequence of irreducibles $ s_0, s_1, \\dots $ such that $ s_0 \\dots s_i $ divides $ r $ for all $ i $, so\n$$ r = r_0s_0 = r_0r_1s_1 = \\dots, $$\nwith $ r_0, r_1, \\dots $ irreducible. If this process ever terminates we are done. Suppose it does not. Then we have a strictly increasing tower of ideals\n$$ \\abr{r} \\subsetneq \\abr{s_0} \\subsetneq \\abr{s_1} \\subsetneq \\dots. $$\nThis cannot continue forever. Arguing as above we arrive at a contradiction.\n\\end{proof}\n\nNow we show $ 2 $.\n\n\\begin{proof}[Proof of Theorem \\ref{thm:3.3.2}]\nIt suffices to show that in a PID every irreducible is prime. Let $ r \\in R $ be irreducible, and suppose that $ r $ divides $ st $. Want $ r \\mid s $ or $ r \\mid t $. Let $ q $ be a generator of the ideal $ \\abr{r, s} $ of $ R $, so $ \\abr{r, s} = \\abr{q} $. Then $ q $ divides $ r $, so either $ q $ is a unit or $ q $ is an associate of $ r $. If $ q $ is an associate of $ r $, then since $ q $ divides $ s $, $ r $ divides $ s $. On the other hand, if $ q $ is a unit, then the ideal generated by $ r $ and $ s $ is the unit ideal and $ 1 \\in \\abr{r, s} $, so we can write $ 1 = xr + ys $ for $ x $ and $ y $ elements of $ R $. We then have $ t = xrt + yst $, and since $ r $ divides both $ yst $ and $ xrt $, $ r $ divides $ t $.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Euclidean domains}\n\n\\lecture{6}{Wednesday}{16/10/18}\n\nOne technique for proving that rings are PIDs is Euclid's algorithm. We formalise this in an abstract setting as follows.\n\n\\begin{definition}\nLet $ R $ be an integral domain.\n\\begin{itemize}\n\\item A \\textbf{Euclidean norm} on $ R $ is a function $ \\N : R \\to \\ZZ_{\\ge 0} $ such that for all $ a, b \\in R $, with $ b \\ne 0 $, there exist $ q, r \\in R $ such that $ a = qb + r $, and either $ r = 0 $ or $ \\N\\br{r} < \\N\\br{b} $.\n\\item An integral domain $ R $ is called a \\textbf{Euclidean domain} if there is a Euclidean norm on $ R $.\n\\end{itemize}\n\\end{definition}\n\n\\begin{theorem}\nAny Euclidean domain is a PID.\n\\end{theorem}\n\n\\begin{proof}\nLet $ R $ be a Euclidean domain, $ \\N $ be a Euclidean norm on $ R $, and $ I \\subseteq R $ be a nonzero ideal of $ R $. Let $ n $ be the smallest integer such that there exists a nonzero element $ a \\in I $ with $ \\N\\br{a} = n $ minimal, that is if $ b \\in I $ and $ b \\ne 0 $, then $ \\N\\br{b} < \\N\\br{a} $. Claim that $ I = \\abr{a} $. Then for any $ b \\in I $, we can write $ b = qa + r $ with $ \\N\\br{r} < \\N\\br{a} $ unless $ r = 0 $. But since $ \\N\\br{a} $ is the smallest possible norm in $ I $, we must have $ r = 0 $, so $ b = qa $. Thus $ I $ is generated by $ a $ and we are done.\n\\end{proof}\n\n\\subsection{Examples}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item The classic example of a Euclidean domain is $ \\ZZ $, with $ \\N\\br{x} = \\abs{x} $ for $ x \\in \\ZZ $.\n\\item The ring $ \\ZZ\\sbr{i} $ is a Euclidean domain, with $ \\N\\br{z} = z\\overline{z} = \\abs{z}^2 $, so\n$$ \\N\\br{x + yi} = \\abs{x + yi}^2 = x^2 + y^2. $$\nTo see this, note that given $ a $ and $ b $ in $ \\ZZ\\sbr{i} $ for $ b \\ne 0 $, set $ q' = a / b \\in \\QQ\\sbr{i} $. Write $ q' = x' + iy' $ for $ x', y' \\in \\QQ $. Let $ x $ and $ y $ be the closest integers to $ x' $ and $ y' $, such that $ \\abs{x - x'}, \\abs{y - y'} \\le \\tfrac{1}{2} $, and set $ q = x + iy $ in $ \\ZZ\\sbr{i} $ and $ r = a - bq $. Then\n$$ \\N\\br{r} = \\abs{r}^2 = \\abs{a - bq}^2 = \\abs{a - b\\br{\\dfrac{a}{b} + \\br{q - q'}}}^2 = \\abs{b\\br{q - q'}}^2 = \\abs{b}^2\\abs{q - q'}^2 \\le \\dfrac{\\N\\br{b}}{2}. $$\n\\item Similar arguments can be used to prove that $ \\ZZ\\sbr{\\alpha} $ is a Euclidean domain for\n$$ \\alpha = \\sqrt{-2}, \\qquad \\alpha = \\tfrac{-1 + \\sqrt{-3}}{2}, \\qquad \\alpha = \\tfrac{-1 + \\sqrt{-7}}{2}. $$\nBeyond this one needs other tricks, and for most $ \\alpha $ unique factorisation fails.\n\\item A critical example is the polynomial ring $ K\\sbr{X} $ for $ K $ a field. Here we can take $ \\N\\br{P\\br{X}} $ to be the degree of $ P\\br{X} $. Then, given polynomials $ P\\br{X}, T\\br{X} \\in K\\sbr{X} $ and $ T\\br{X} \\ne 0 $, we can use polynomial long division to write $ P\\br{X} = Q\\br{X}T\\br{X} + R\\br{X} $ for some $ Q\\br{X} $ with the degree of $ R\\br{X} $ strictly less than that of $ T\\br{X} $, unless $ T\\br{X} $ is constant, in which case we can make $ R\\br{X} = 0 $. To prove this, fix $ T\\br{X} $. If $ \\deg T\\br{X} = 0 $, then $ T\\br{X} $ is constant, so $ T\\br{X} = c \\ne 0 \\in K $. Take $ Q\\br{X} = P\\br{X} / c $ and $ R\\br{X} = 0 $. Otherwise induct on $ \\deg P\\br{X} $. If $ \\deg P\\br{X} < \\deg T\\br{X} $, set $ R\\br{X} = P\\br{X} $ and $ Q\\br{X} = 0 $. Suppose the claim is true for polynomials of degree $ n $ and $ P\\br{X} $ has degree $ n + 1 $, so\n$$ P\\br{X} = \\sum_{i = 0}^{n + 1} a_iX^i, \\qquad T\\br{X} = \\sum_{i = 0}^d b_iX^i, \\qquad d < n + 1. $$\nThen $ S\\br{X} = P\\br{X} - \\br{a_{n + 1} / b_d}X^{n + 1 - d}T\\br{X} $ has degree $ n $. By the inductive hypothesis there exist $ Q\\br{X} $ and $ R\\br{X} $ with $ \\deg R\\br{X} < \\deg T\\br{X} $ such that $ S\\br{X} = Q\\br{X}T\\br{X} + R\\br{X} $, so\n$$ P\\br{X} = \\br{\\dfrac{a_{n + 1}}{b_d}X^{n + 1 - d} + Q\\br{X}}T\\br{X} + R\\br{X}. $$\n\\item Later, will show if $ R $ is a UFD, then $ R\\sbr{X} $ is also a UFD.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\n\\section{The Chinese remainder theorem}\n\nIn elementary number theory, let $ m_1, m_2 \\in \\ZZ $ be relatively prime and $ a_1, a_2 \\in \\ZZ $. Then there exists $ a \\in \\ZZ $ such that $ a \\equiv a_1 \\mod m_1 $ and $ a \\equiv a_2 \\mod m_2 $. Moreover, $ a $ is unique up to congruence modulo $ m_1m_2 $. A question is given ideals $ I_1, \\dots, I_r $ and $ a_1, \\dots, a_r \\in R $, when can we find a $ a \\in R $ with $ a \\in a_1 + I_1, \\dots, a \\in a_r + I_r $?\n\n\\subsection{Products}\n\n\\begin{definition}\nLet $ R_1, \\dots, R_n $ be rings. The \\textbf{direct product} $ R_1 \\times \\dots \\times R_n $ is a ring whose elements are $ n $-tuples $ \\br{r_1, \\dots, r_n} $ with $ r_i \\in R_i $ for all $ i $. The addition and multiplication are given componentwise by\n$$ \\br{r_1, \\dots, r_n} + \\br{r_1', \\dots, r_n'} = \\br{r_1 + r_1', \\dots, r_n + r_n'}, \\qquad \\br{r_1, \\dots, r_n}\\br{r_1', \\dots, r_n'} = \\br{r_1r_1', \\dots, r_nr_n'}. $$\n\\end{definition}\n\n\\begin{note*}\nThe product comes with natural homomorphisms $ \\pi_i $ for all $ i $, the \\textbf{projection} onto the $ i $-th factor, defined by\n$$ \\function[\\pi_i]{R_1 \\times \\dots \\times R_n}{R_i}{\\br{r_1, \\dots, r_n}}{r_i}. $$\n\\end{note*}\n\nThe product also comes with the following universal property.\n\n\\begin{theorem}[Universal property of the product]\nLet $ S, R_1, \\dots, R_n $ be any rings. For any homomorphisms $ f_1 : S \\to R_1, \\dots, f_n : S \\to R_n $, there exists a unique homomorphism\n$$ f : S \\to R_1 \\times \\dots \\times R_n, $$\nsuch that $ \\pi_i \\circ f = f_i $ for all $ i $.\n\\end{theorem}\n\n\\begin{proof}\nGiven $ f_i $, the homomorphism $ f $ is defined by $ f\\br{s} = \\br{f_1\\br{t}, \\dots, f_n\\br{t}} $. Then $ \\br{\\pi_i \\circ f}\\br{s} = f_i\\br{s} $. For uniqueness, if $ \\br{\\pi_i \\circ g}\\br{s} = f_i\\br{s} $ for all $ i $, then $ g\\br{s} = \\br{f_1\\br{s}, \\dots, f_n\\br{s}} = f\\br{s} $.\n\\end{proof}\n\nMore generally, if $ I $ is any index set, and for each $ i \\in I $ we have a ring $ R_i $, we can define the product $ \\prod_i R_i $. An element $ r $ of this product is a choice, for each $ i \\in I $, of an element of $ R_i $. We write such an element as $ \\br{r_i}_{i \\in I} $. For each $ j \\in I $ we have a map\n$$ \\function[\\pi_j]{\\prod_i R_i}{R_j}{\\br{r_i}_{i \\in I}}{r_j}. $$\nSuch a product satisfies a very similar universal property. For any collection $ f_i : S \\to R_i $ for $ i \\in I $ of maps, we get a unique map\n$$ f : S \\to \\prod_i R_i, $$\nsuch that $ \\pi_j \\circ f = f_j $.\n\n\\subsection{The Chinese remainder theorem}\n\nLet $ R $ be a ring, and let $ I_1, \\dots, I_r $ be a finite collection of ideals of $ R $. We have the natural maps $ R \\to R / I_1, \\dots R \\to R / I_r $, which are surjective with kernel $ I_j $. Consider the product map $ R \\to R / I_1 \\times \\dots \\times R / I_r $. It is easy to see that the kernel of this map is the set of $ r \\in R $ such that $ r $ maps to zero in $ R / I_j $ for all $ j $. That is, the kernel is the intersection $ I_1 \\cap \\dots \\cap I_r $. Call this ideal $ J $. We thus have an injective embedding $ R / J \\hookrightarrow R / I_1 \\times \\dots \\times R / I_r $. A natural question to ask is, what can we say about the image? In other words, given congruence classes modulo $ I_1, \\dots, I_r $, when is there a single element of $ R $ that lives in all those congruence classes simultaneously?\n\n\\begin{note*}\nBecause the above map is injective, if one such element exists, then there is a unique congruence class modulo $ J $ that satisfies all of the required congruences.\n\\end{note*}\n\nOf course, without further hypotheses we cannot expect this map to be surjective. Think about what happens when $ I_1 = I_2 $, for instance. Nonetheless, we have the following.\n\n\\begin{definition}\nWe will say $ I_1, \\dots, I_r $ are \\textbf{pairwise relatively prime} if for each $ i \\ne j $, the sum $ I_i + I_j $ is the unit ideal in $ R $.\n\\end{definition}\n\n\\pagebreak\n\n\\begin{theorem}\nLet $ R $ be a ring and $ I_1, \\dots, I_r $ be pairwise relatively prime ideals. Then the natural map\n$$ R / J \\hookrightarrow R / I_1 \\times \\dots \\times R / I_r $$\nis an isomorphism.\n\\end{theorem}\n\n\\begin{proof}\nWe have to prove it is surjective. Fix any tuple $ \\br{c_1, \\dots, c_r} $ of elements of $ R $. We need to find $ c \\in R $ such that $ c \\in c_i + I_i $ for all $ i $. It suffices to construct, for each $ i $, an element $ e_i $ of $ R $ that is congruent to $ 1 \\mod I_i $ and $ 0 \\mod I_j $ for $ j \\ne i $. Suppose we have such an element. Then the element\n$$ c = c_1e_1 + \\dots + c_re_r $$\nis congruent to $ c_j \\mod I_j $ for all $ j $. Given $ i $ and $ j $ with $ i \\ne j $, we know that $ I_i + I_j $ is the unit ideal. That is, we can write $ a_{ij} + b_{ij} = 1 $ for $ a_{ij} \\in I_i $ and $ b_{ij} \\in I_j $. Then $ a_{ij} $ is congruent to $ 1 \\mod I_j $ and $ 0 \\mod I_i $ as an element of $ R / I_1 \\times \\dots \\times R / I_r $, so $ a_{ij} $ has zero in the $ i $-th place and one in the $ j $-th place. Then for any $ j $ we can take $ e_j = \\prod_{i \\ne j} a_{ij} $, and $ e_j $ will be congruent to $ 1 \\mod I_j $ and $ 0 \\mod I_i $ for all $ j \\ne i $, so $ e_j $ has one only in the $ j $-th place. So $ R \\to R / I_1 \\times \\dots \\times R / I_r $ is surjective. The result follows.\n\\end{proof}\n\n\\subsection{Examples}\n\nWhen $ R = \\ZZ $, then every ideal is principal, so we can write $ I_j = \\abr{n_j} $ for all $ j $. The condition that $ I_i + I_j $ is the unit ideal becomes the condition that $ n_i \\in \\ZZ $ are pairwise relatively prime. In this case the ideal $ J $ is generated by the product $ n $ of the $ n_i $. Specialising, we find the version of the Chinese remainder theorem from elementary number theory.\n\n\\begin{theorem}\nIf $ \\cbr{n_j \\in \\ZZ} $ is a finite collection of pairwise relatively prime integers, and $ n $ is their product, then for any $ c_1, \\dots, c_r \\in \\ZZ $, there exists $ c \\in \\ZZ $ unique up to congruence modulo $ n $ such that $ c $ is congruent to $ c_i \\mod n_i $ for all $ i $.\n\\end{theorem}\n\nNow let $ K $ be a field and take $ R = K\\sbr{X} $. If $ c_1, \\dots, c_r \\in K $ are distinct elements of $ K $, the ideals $ I_i = \\abr{X - c_i} \\subseteq R $ are such that $ I_i + I_j = \\abr{X - c_i} + \\abr{X - c_j} \\ni c_i - c_j \\in K^\\times $, so contains one. That is, $ I_i + I_j $ is the unit ideal in $ R $ and the ideals $ I_i $ are pairwise relatively prime. Moreover, for each $ i $, $ I_i $ is the kernel of the evaluation map\n$$ \\function[f_i]{R}{K}{P\\br{X}}{P\\br{c_i}}. $$\nLet\n$$ \\function[f]{R}{K \\times \\dots \\times K}{P\\br{X}}{\\br{P\\br{c_1}, \\dots, P\\br{c_r}}}. $$\nThen the following diagram commutes.\n$$\n\\begin{tikzcd}[column sep=1in]\nR \\arrow{r}{f} \\arrow[twoheadrightarrow]{d} & K \\times \\dots \\times K \\\\\nR / J \\arrow{r}[swap]{\\sim} & R / I_1 \\times \\dots \\times R / I_r \\arrow{u}[swap]{\\sim}\n\\end{tikzcd}.\n$$\nChinese remainder theorem implies that $ f $ is surjective. We thus have an isomorphism\n$$ \\function{R / I_i}{K}{P\\br{X}}{P\\br{c_i}}, $$\nfor all polynomials $ P $. We thus obtain the following.\n\n\\begin{theorem}\nFor any $ c_1, \\dots, c_n \\in K $, there is a polynomial $ P\\br{X} $ in $ K\\sbr{X} $, unique up to congruence modulo $ \\br{X - a_1} \\dots \\br{X - a_n} $, such that $ P\\br{a_i} = c_i $ for all $ i $.\n\\end{theorem}\n\n\\pagebreak\n\n\\section{Fields and field extensions}\n\n\\lecture{7}{Friday}{19/10/18}\n\nNext we will use that $ K\\sbr{X} $ is a PID for $ K $ a field to study fields systematically.\n\n\\subsection{Prime fields}\n\nLet $ K $ be a field. We have a unique ring homomorphism\n$$ \\function[\\iota]{\\ZZ}{K}{n}{n_K = 1_K + \\dots + 1_K}, \\qquad n \\ge 0. $$\nLet $ I $ be the kernel. Then $ \\ZZ / I \\hookrightarrow K $ so $ \\ZZ / I $ is an integral domain, so $ I $ is a prime ideal. Thus $ I $ is either the zero ideal $ \\cbr{0} $, if $ K $ has characteristic zero, or the ideal $ \\abr{p} $ for some prime $ p $ of $ \\ZZ $. In the former case $ I = \\cbr{0} $, the injection $ \\ZZ \\hookrightarrow K $ extends to an inclusion\n$$ \\function{\\QQ}{K}{\\dfrac{a}{b}}{\\br{\\iota a}\\br{\\iota b^{-1}} = \\dfrac{a_K}{b_K}}. $$\nIn the latter case $ I = \\abr{p} $, we get an injection $ \\ZZ / p\\ZZ \\hookrightarrow K $, which we often denote $ \\FF_p $ when we think of it as a field. The upshot is that every field $ K $ contains exactly one of $ \\QQ $ or $ \\FF_p $ for $ p $ prime, in exactly one way depending on its characteristic. This field is called the \\textbf{prime field} of $ K $, and it is contained in $ K $ in a unique way.\n\n\\subsection{Field extensions}\n\nThe prime fields are in some sense the smallest possible fields. Once we know they exist, it makes sense to study fields by studying pairs $ K $ and $ L $ of fields such that $ K \\subseteq L $ of fields, trying to relate $ L $ to $ K $.\n\n\\begin{definition}\nA \\textbf{field extension} is such a pair of fields $ K $ and $ L $ with $ K \\subseteq L $, and is often denoted $ L / K $.\n\\end{definition}\n\n\\begin{note*}\nSuch an inclusion of fields $ L / K $ makes $ L $ into a $ K $-vector space, that is a vector space over $ K $.\n\\end{note*}\n\n\\begin{definition}\nWe say that a field extension $ L / K $ is \\textbf{finite} if $ L $ is finite-dimensional as a $ K $-vector space. If this is the case, the \\textbf{degree} of such an extension is the dimension of $ L $ as a $ K $-vector space $ \\dim_K L $, and is denoted $ \\sbr{L : K} $.\n\\end{definition}\n\n\\begin{proposition}\nLet $ K \\subseteq L \\subseteq M $ be fields. Then $ M / K $ is finite if and only if $ M / L $ and $ L / K $ are both finite. If this is the case then\n$$ \\sbr{M : K} = \\sbr{M : L}\\sbr{L : K}. $$\n\\end{proposition}\n\n\\begin{proof}\nFirst suppose that $ M / K $ is finite. Then $ L $ is a $ K $-subspace of $ M $, so finite-dimensional as a $ K $-vector space. Moreover, there exists a $ K $-basis $ m_1, \\dots, m_r $, and this basis spans $ M $ over $ K $ and thus also over $ L $. Thus $ M $ is finite-dimensional as an $ L $-vector space, so $ M / L $ is finite. Conversely, suppose $ L / K $ and $ M / L $ are finite. Let $ e_1, \\dots, e_n $ be a $ K $-basis for $ L $, and let $ f_1, \\dots, f_n $ be an $ L $-basis for $ M $. Then claim that\n$$ e_1f_1, \\dots, e_1f_m, \\dots, e_nf_1, \\dots, e_nf_m $$\nis a $ K $-basis for $ M $. Every element $ x $ of $ M $ can be expressed uniquely as $ c_1f_1 + \\dots + c_mf_m $ for $ c_i \\in L $. Each $ c_i $ in turn can be expressed as $ d_{1, i}e_1 + \\dots + d_{n, i}e_n $ for $ d_{j, i} \\in K $. Thus we can express $ x $ as\n$$ d_{1, 1}e_1f_1 + \\dots + d_{n, 1}e_nf_1 + \\dots + d_{1, m}e_1f_m + \\dots + d_{n, m}e_nf_m. $$\nIn particular the set $ \\cbr{e_if_j \\st 1 \\le i \\le n, \\ 1 \\le j \\le m} $ spans $ M $ over $ K $. In this case the degree of $ L $ over $ K $ is $ n $ and the degree of $ M $ over $ L $ is $ m $, so it remains to show that $ \\cbr{e_if_j} $ is linearly independent over $ K $. Suppose we have elements $ d_{i, j} $ of $ K $ such that $ \\sum_{i, j} d_{i, j}e_if_j = 0 $. Then, regrouping, we find that $ \\sum_j \\sum_i d_{i, j}e_if_j = 0 $ is an $ L $-linear combination of the $ f_j $ that is zero. Since the $ f_j $ are linearly independent over $ L $ we must have $ \\sum_i d_{i, j}e_i = 0 $ for all $ j $. Since the $ e_i $ are linearly independent over $ K $ we must have $ d_{i, j} = 0 $ for all $ i $ and $ j $.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Extensions generated by one element}\n\n\\lecture{8}{Monday}{22/10/18}\n\nLet $ L / K $ be a field extension, and let $ \\alpha $ be an element of $ L $.\n\n\\begin{definition}\nWe let $ K\\br{\\alpha} $ denote the subfield of $ L $ consisting of all elements of $ L $ that can be expressed in the form $ P\\br{\\alpha} / Q\\br{\\alpha} $, where $ P $ and $ Q $ are polynomials with coefficients in $ K $ and $ Q\\br{\\alpha} $ is not zero. This is the smallest subfield of $ L $ containing $ K $ and $ \\alpha $.\n\\end{definition}\n\nRecall that if $ R $ and $ S $ are rings, $ f : R \\to S $ is a homomorphism, and $ \\alpha \\in S $, then have\n$$ \\function[\\phi_{f, a}]{R\\sbr{X}}{S}{\\sum_{i = 1}^n r_iX^i}{\\sum_{i = 1}^n f\\br{r_i}\\alpha^i}. $$\nWe also have a natural map\n$$ \\function{K\\sbr{X}}{K\\br{\\alpha} \\subseteq L}{P\\br{X}}{P\\br{\\alpha}}. $$\nthe inclusion on $ K $. It is a ring homomorphism. Let $ I $ be the kernel of this homomorphism. We then get an injection of $ K\\sbr{X} / I $ into the field $ K\\br{\\alpha} $. Thus $ K\\sbr{X} / I $ is an integral domain, so $ I $ is a prime ideal of $ K\\sbr{X} $. Since $ K\\sbr{X} $ is a PID, every nonzero prime ideal is maximal. There are thus two cases. In the first $ I $ is the zero ideal that is not maximal. That is, there is no nonzero polynomial $ Q $ in $ K\\sbr{X} $ such that $ Q\\br{\\alpha} $ is zero in $ L $. We say that $ \\alpha $ is \\textbf{transcendental} over $ K $ in this case. In the second $ I $ is an ideal $ \\abr{Q} $ for $ Q \\in K\\sbr{X} $ a nonzero irreducible polynomial that is a maximal ideal of $ K\\sbr{X} $. In this case we say $ \\alpha $ is \\textbf{algebraic} over $ K $.\n\n\\begin{definition}\n$ K\\br{X} $ is the \\textbf{field of rational functions} on $ X $,\n$$ K\\br{X} = \\cbr{\\dfrac{P\\br{X}}{Q\\br{X}} \\st P, Q \\in K\\sbr{X}, \\ Q \\ne 0} / \\sim. $$\n\\end{definition}\n\nAssume first that $ \\alpha $ is transcendental over $ K $, that is $ I = \\cbr{0} $. Recall $ I = \\cbr{P\\br{X} \\in K\\sbr{X} \\st P\\br{\\alpha} = 0} $. So in this case there is no nonzero polynomial $ P \\in K\\sbr{X} $ with $ P\\br{\\alpha} = 0 $. In this case the map taking $ P\\br{X} $ to $ P\\br{\\alpha} $ is an injection of $ K\\sbr{X} $ into $ K\\br{\\alpha} \\subseteq L $. In particular every nonzero element of $ K\\sbr{X} $ gets sent to a nonzero, hence invertible, element of $ L $. Thus the map from $ K\\sbr{X} $ to $ L $ extends to an injective map from the field of fractions of $ K\\sbr{X} $,\n$$ \\function{K\\br{X}}{L}{\\dfrac{P\\br{X}}{Q\\br{X}}}{\\dfrac{P\\br{\\alpha}}{Q\\br{\\alpha}}}. $$\nBy definition of $ K\\br{\\alpha} $, this map is surjective so the image of this map is $ K\\br{\\alpha} $. In particular $ K\\br{X} $ and $ K\\br{\\alpha} $ are isomorphic.\n\n\\begin{note*}\nIn this case $ K\\br{\\alpha} $ is infinite-dimensional as a $ K $-vector space. It contains a subspace isomorphic to $ K\\sbr{X} $, for instance.\n\\end{note*}\n\nIf $ \\alpha $ is algebraic over $ K $, then $ I $ is a nonzero maximal ideal of the PID $ K\\sbr{X} $, so it is generated by a single irreducible polynomial $ Q\\br{X} $ in $ K\\sbr{X} $. As a consequence, since the units in $ K\\sbr{X} $ are just the constant polynomials, the polynomial $ Q\\br{X} $ is well-defined up to a constant factor. It is called the \\textbf{minimal polynomial} of $ \\alpha $. By definition, it divides every polynomial $ P\\br{X} $ such that $ P\\br{\\alpha} = 0 $. Since $ \\abr{Q\\br{X}} $ is maximal, the ring $ K\\sbr{X} / \\abr{Q\\br{X}} $ is a field. Recall that for any $ P \\in K\\sbr{X} $, can write $ P\\br{X} $ uniquely as $ A\\br{X}Q\\br{X} + R\\br{X} $ for $ \\deg R < \\deg Q $. So $ 1, \\dots, X^{\\deg Q - 1} $ are a $ K $-basis of $ K\\sbr{X} / \\abr{Q\\br{X}} $. So its dimension as a $ K $-vector space is equal to the degree of $ Q\\br{X} $. The map $ K\\sbr{X} \\to K\\br{\\alpha} \\subseteq L $ descends to an injection of $ K\\sbr{X} / \\abr{Q\\br{X}} $ into $ L $. Since its image is a subfield of $ K\\br{\\alpha} $ containing $ K $ and $ \\alpha $, this map is an isomorphism\n$$ K\\br{\\alpha} \\cong K\\sbr{X} / \\abr{Q\\br{X}}. $$\nThus in this case the extension $ K\\br{\\alpha} / K $ is a finite extension, of degree equal to the degree of $ Q\\br{X} $. To summarise, extend $ K $ by a single element by\n\\begin{itemize}\n\\item building $ K\\sbr{X} $, and\n\\item either passing to field of fractions $ K\\br{X} $ to form a transcendental extension, or choosing an irreducible polynomial $ Q $ to form an algebraic extension $ K\\sbr{X} / \\abr{Q\\br{X}} $.\n\\end{itemize}\nSlightly informally, instead of $ K\\sbr{X} / \\abr{Q\\br{X}} $, we sometimes write $ K\\br{\\alpha} $, where $ \\alpha $ is a root of $ Q\\br{X} $.\n\n\\pagebreak\n\n\\subsection{Algebraic extensions}\n\n\\begin{definition}\nAn extension $ L / K $ is \\textbf{algebraic} if every element of $ L $ is algebraic over $ K $.\n\\end{definition}\n\n\\begin{proposition}\nIf $ L / K $ is finite, then $ L / K $ is algebraic.\n\\end{proposition}\n\n\\begin{proof}\nLet $ d $ be the dimension of $ L $ over $ K $. Then for any $ \\alpha $, the set $ 1, \\dots, \\alpha^d $ must be linearly dependent over $ K $. This gives a nonzero polynomial $ P $ such that $ P\\br{\\alpha} = 0 $.\n\\end{proof}\n\n\\begin{corollary}\nLet $ L / K $ be a field extension, and suppose $ \\alpha $ and $ \\beta $ are elements of $ L $ algebraic over $ K $. Then $ \\alpha + \\beta $ and $ \\alpha\\beta $ are algebraic over $ K $. Moreover, if $ \\alpha $ is nonzero then $ \\alpha^{-1} $ is algebraic over $ K $.\n\\end{corollary}\n\n\\begin{proof}\nConsider the chain of extensions $ K \\subseteq K\\br{\\alpha} \\subseteq K\\br{\\alpha, \\beta} $, where we write $ K\\br{\\alpha, \\beta} $ for $ \\br{K\\br{\\alpha}}\\br{\\beta} $. Since $ \\alpha $ is algebraic over $ K $, $ K\\br{\\alpha} $ is finite over $ K $, of degree $ \\deg \\alpha $. Since $ \\beta $ is algebraic over $ K $, it is also algebraic over $ K\\br{\\alpha} $, so $ K\\br{\\alpha, \\beta} $ is finite over $ K\\br{\\alpha} $, of degree at most $ \\deg \\beta $. Thus $ K\\br{\\alpha, \\beta} $ is algebraic over $ K $, of degree at most $ \\deg \\alpha\\deg \\beta $. On the other hand, we also have a chain of extensions $ K \\subseteq K\\br{\\alpha + \\beta} \\subseteq K\\br{\\alpha, \\beta} $, so $ K\\br{\\alpha + \\beta} $ is finite over $ K $, of degree at most $ \\deg \\alpha\\deg \\beta $. Hence $ \\alpha + \\beta $ is algebraic over $ K $. The proofs for $ \\alpha\\beta $ and $ \\alpha^{-1} $ are similar.\n\\end{proof}\n\n\\begin{corollary}\nFor any extension $ L / K $, let $ L^{\\alg} $ be the subset of $ L $ consisting of all elements of $ L $ that are algebraic over $ K $. Then $ L^{\\alg} $ is a field.\n\\end{corollary}\n\n\\begin{proof}\nWe have seen that $ L^{\\alg} $ is closed under addition, multiplication, and taking inverses. For example, if $ a_0 + \\dots + a_n\\alpha^n = 0 $, then $ a_0\\br{\\alpha^{-1}}^n + \\dots + a_n = 0 $.\n\\end{proof}\n\n\\begin{example*}\nIn particular, the subfield $ \\overline{\\QQ} \\subseteq \\CC $ of complex numbers that are algebraic over $ \\QQ $ is a field, called the \\textbf{field of algebraic numbers}.\n\\end{example*}\n\n\\subsection{Example}\n\n\\begin{example*}\nConsider the polynomial $ X^2 + X + 1 $ in $ \\FF_2\\sbr{X} $. It has no roots in $ \\FF_2 $, so it is irreducible, as it is a polynomial of degree two any nontrivial factor would be linear. The other polynomials of degree two are\n$$ X^2, \\qquad X^2 + X = X\\br{X + 1}, \\qquad X^2 + 1 = \\br{X + 1}^2, $$\nso $ X^2 + X + 1 $ is the unique irreducible polynomial of degree two. Thus the quotient $ \\FF_2\\sbr{X} / \\abr{X^2 + X + 1} $ is a field extension of degree two of $ \\FF_2 $, which is denoted $ \\FF_4 $. Its four elements are $ 0, 1, X, X + 1 $, or more precisely, their classes modulo $ \\abr{X^2 + X + 1} $, and\n$$\n\\begin{array}{c|cccc}\n\\cdot & 0 & 1 & X & X + 1 \\\\\n\\hline\n0 & 0 & 0 & 0 & 0 \\\\\n1 & 0 & 1 & X & X + 1 \\\\\nX & 0 & X & X + 1 & 1 \\\\\nX + 1 & 0 & X + 1 & 1 & X\n\\end{array}.\n$$\nIn particular the multiplicative group of $ \\FF_4 $ is cyclic of order three. This is not particularly surprising, as all groups of order three are cyclic. We will see later that the multiplicative group of any finite field is cyclic.\n\\end{example*}\n\n\\begin{proposition}\nLet $ K $ be a field with four elements. Then $ K \\cong \\FF_4 $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha \\in K $ with $ \\alpha \\ne 0 $ and $ \\alpha \\ne 1 $. Consider $ 1, \\alpha, \\alpha^2 $. Since $ K $ has dimension two over $ \\FF_2 $, there is a linear dependence. So there exists a polynomial $ P $ in $ \\FF_2\\sbr{X} $ of degree at most two such that $ P\\br{\\alpha} = 0 $. In fact $ P $ must be irreducible of degree two. If it is divisible by something of degree one, then a polynomial of degree one vanishes on $ \\alpha $, so $ \\alpha = 0 $ or $ \\alpha = 1 $. So $ \\alpha^2 + \\alpha + 1 = 0 $. The map\n$$ \\function{\\FF_2\\sbr{X}}{K}{X}{\\alpha}. $$\ndescends to $ \\FF_2\\sbr{X} / \\abr{X^2 + X + 1} \\to K $. So $ \\FF_4 $ embeds in $ K $. Thus $ K \\cong \\FF_4 $.\n\\end{proof}\n\n\\pagebreak\n\n\\section{Finite fields}\n\n\\subsection{Finite fields}\n\n\\lecture{9}{Wednesday}{24/10/18}\n\nLet $ K $ be a finite field. That is, a field with only finitely many elements. Then $ K $ has characteristic $ p $ for some prime $ p $, and is in particular a finite-dimensional $ \\FF_p $-vector space. Thus its order is a power $ p^r $ of $ p $ for $ r \\in \\ZZ_{> 0} $. If we fix a particular prime power $ p^r $, then two questions naturally arise. Does there exist a field of order $ p^r $? If so, can we classify fields of order $ p^r $ up to isomorphism? We will see that in fact, up to isomorphism, there is a unique field $ \\FF_{p^r} $ of order $ p^r $.\n\n\\subsection{The Frobenius automorphism}\n\nLet $ p $ be a prime. For any ring $ R $, the map $ x \\mapsto x^p $ on $ R $ certainly satisfies $ \\br{xy}^p = x^py^p $ for $ x, y \\in R $. On the other hand,\n$$ \\br{x + y}^p = x^p + \\binom{p}{1}xy^{p - 1} + \\dots + \\binom{p}{p - 1}x^{p - 1}y + y^p. $$\nNow the binomial coefficients satisfy $ p \\mid p! / i!\\br{p - i}! $ for $ 1 \\le i \\le p - 1 $, so if $ R $ has characteristic $ p $, we have $ \\br{x + y}^p = x^p + y^p $. Thus, when $ R $ has characteristic $ p $, the map $ x \\mapsto x^p $ is a ring homomorphism from $ R $ to $ R $, called the \\textbf{Frobenius endomorphism} of $ R $. If $ R $ is a field of characteristic $ p $, then the Frobenius endomorphism is injective. If in addition $ R $ is finite, then any injective map from $ R $ to $ R $ is surjective. In particular the Frobenius endomorphism is a bijective and an isomorphism from $ R $ to $ R $ when $ R $ is a finite field of characteristic $ p $. In this case we call the map $ x \\mapsto x^p $ the \\textbf{Frobenius automorphism}. Composing the Frobenius endomorphism with itself, we find that for any $ r $, $ x \\mapsto x^{p^r} $ is also an endomorphism of any ring $ R $ of characteristic $ p $.\n\n\\begin{example*}\nLet $ R = \\FF_4 $. Then $ y \\mapsto y^2 $ gives\n$$ 0 \\mapsto 0, \\qquad 1 \\mapsto 1, \\qquad X \\mapsto X + 1, \\qquad X + 1 \\mapsto X. $$\n\\end{example*}\n\nLet $ K $ be a field of $ p^r $ elements. Then $ \\alpha^{p^r} = \\alpha $ for all $ \\alpha \\in K $. If $ \\alpha = 0 $, this is clear. Otherwise $ \\alpha \\in K^* $, so $ K^* $ is an abelian group of order $ p^r - 1 $. Lagrange's theorem implies that $ \\alpha^{p^r - 1} = 1 $, so $ \\alpha^{p^r} = \\alpha $. We have the following.\n\n\\begin{proposition}\nLet $ K $ be a field of characteristic $ p $, such that $ \\alpha^{p^r} = \\alpha $ for all $ \\alpha \\in K $. Let $ P\\br{X} \\in K\\sbr{X} $ be an irreducible factor of $ X^{p^r} - X $ over $ K\\sbr{X} $. Then every element $ \\beta $ of $ K\\sbr{X} / \\abr{P\\br{X}} $ satisfies $ \\beta^{p^r} = \\beta $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ d = \\deg P $. Can write $ \\beta = c_0 + \\dots + c_{d - 1}X^{d - 1} $. Moreover, since $ P\\br{X} = 0 $ in $ K\\sbr{X} / \\abr{P\\br{X}} $ and $ P\\br{X} $ divides $ X^{p^r} - X $, we have $ X^{p^r} = X $ in $ K\\sbr{X} / \\abr{P\\br{X}} $. Thus\n$$ \\beta^{p^r} = c_0^{p^r} + \\dots + c_{d - 1}^{p^r}\\br{X^{p^r}}^{d - 1} = c_0 + \\dots + c_{d - 1}\\br{X^{p^r}}^{d - 1} = c_0 + \\dots + c_{d - 1}X^{d - 1} = \\beta. $$\n\\end{proof}\n\n\\begin{corollary}\nThere exists a field $ K $ of characteristic $ p $ such that\n\\begin{enumerate}\n\\item $ \\alpha^{p^r} = \\alpha $ for all $ \\alpha \\in K $, and\n\\item the polynomial $ X^{p^r} - X $ of $ K\\sbr{X} $ factors into linear factors over $ K\\sbr{X} $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\nLet $ K_0 = \\FF_p $. Then $ K_0 $ satisfies $ 1 $. We construct a tower of fields\n$$ K_0 = \\FF_p \\subsetneq K_1 \\subsetneq K_2 \\subsetneq \\dots $$\nall satisfying $ 1 $ as follows. Suppose we have constructed $ K_i $ satisfying $ 1 $. If $ X^{p^r} - X $ factors into linear factors over $ K_i\\sbr{X} $, we are done. Otherwise, choose a nonlinear irreducible factor $ P_i\\br{X} $ of $ X^{p^r} - X $ in $ K_i\\sbr{X} $ of degree at least two, and set $ K_{i + 1} = K_i\\sbr{X} / \\abr{P_i\\br{X}} $. Then $ K_{i + 1} $ is strictly larger than $ K_i $ and still satisfies $ 1 $. On the other hand, in any field $ K_i $ satisfying $ 1 $, every element is a root of $ X^{p^r} - X $, so $ \\#K_i \\le p^r $ for all $ i $. Since this polynomial can have at most $ p^r $ roots, this process must eventually terminate.\n\\end{proof}\n\nSince $ X^{p^r} - X $ has degree $ p^r $, we expect the field $ K $ constructed above to have $ p^r $ elements. So it suffices to show that over any field $ K $ of characteristic $ p $, $ X^{p^r} - X $ has no repeated roots. To prove this we need an additional tool.\n\n\\pagebreak\n\n\\subsection{Derivatives}\n\n\\begin{definition}\nLet $ R $ be a ring, and let $ P\\br{X} = r_0 + \\dots + r_dX^d $ be an element of $ R\\sbr{X} $. The \\textbf{derivative} $ P'\\br{X} $ of $ P\\br{X} $ is the polynomial\n$$ r_1 + \\dots + dr_dX^{d - 1}. $$\n\\end{definition}\n\n\\begin{note*}\nJust as for differentiation in calculus, we have a Leibniz rule. For $ P, Q \\in R\\sbr{X} $,\n$$ \\br{PQ}'\\br{X} = P\\br{X}Q'\\br{X} + P'\\br{X}Q\\br{X}, $$\nby reducing to $ P $ and $ Q $ monomials.\n\\end{note*}\n\nFrom this we deduce the following.\n\n\\begin{lemma}\nLet $ K $ be a field, and let $ P\\br{X} $ be a polynomial in $ K\\sbr{X} $ with a multiple root in $ K $. Then $ P\\br{X} $ and $ P'\\br{X} $ have a common factor of degree greater than zero.\n\\end{lemma}\n\n\\begin{proof}\nLet $ \\alpha \\in K $ be the multiple root. Then we can write $ P\\br{X} = \\br{X - \\alpha}^2Q\\br{X} $. Applying the Leibniz rule we get $ P'\\br{X} = 2\\br{X - \\alpha}Q\\br{X} + \\br{X - \\alpha}^2Q'\\br{X} $, and it is clear that $ X - \\alpha $ divides both $ P\\br{X} $ and $ P'\\br{X} $.\n\\end{proof}\n\n\\begin{corollary}\nLet $ K $ be a field of characteristic $ p $. Then $ X^{p^r} - X $ has no repeated roots in $ K $.\n\\end{corollary}\n\n\\begin{proof}\nLet $ P\\br{X} = X^{p^r} - X $. Then $ P'\\br{X} = -1 $, so $ P\\br{X} $ and $ P'\\br{X} $ have no common factor.\n\\end{proof}\n\n\\begin{corollary}\nThere exists a finite field of $ p^r $ elements.\n\\end{corollary}\n\n\\subsection{The multiplicative group}\n\n\\lecture{10}{Friday}{26/10/18}\n\nRather than show immediately that there is a unique finite field of $ p^r $ elements, we make a detour to study the multiplicative group of a finite field. This is not strictly necessary to prove uniqueness, but will simplify the proof, and is of interest in its own right. Let $ K $ denote a field of $ p^r $ elements. The goal of this section is to show that $ K^* $ is cyclic.\n\n\\begin{note*}\nAs a multiplicative group, $ K^* $ is an abelian group of order $ p^r - 1 $, so by Lagrange's theorem, we have $ \\alpha^{p^r - 1} = 1 $ for all $ \\alpha \\in K^* $.\n\\end{note*}\n\nThe order of an element $ a $ of $ A $ divides the order of $ A $. If $ d'a = 0 $ for some $ d' \\in \\ZZ $ then the order of $ a $ divides $ d' $. The order of an element $ a $ of $ K^* $ is the smallest $ d \\in \\ZZ_{> 0} $ such that $ a^d = 1 $. Since $ a^{p^r - 1} = 1 $, the order of $ a $ is a divisor of $ p^r - 1 $. On the other hand, if $ d $ is a divisor of $ p^r - 1 $, then any element of order dividing $ d $ is a root of the polynomial $ X^d - 1 $. Since $ K $ is a field, this polynomial has at most $ d $ roots, so we find that there are at most $ d $ elements of $ K^* $ of order dividing $ d $. Order of any element divides $ p^r - 1 $. Know $ X^{p^r - 1} - 1 $ has $ p^r - 1 $ distinct roots in $ K $. For $ d \\mid p^r - 1 $, $ X^d - 1 \\mid X^{p^r - 1} - 1 $, so $ X^d - 1 $ has exactly $ d $ roots in $ K $. That is, for all $ d \\mid p^r - 1 $, $ K^* $ has exactly $ d $ elements of order dividing $ d $. In fact, we have the following.\n\n\\begin{proposition}\n\\label{prop:6.4.1}\nLet $ A $ be a finite abelian group of order $ n $, and suppose that $ A $ has exactly $ d $ elements of order dividing $ d $, for all $ d $ dividing $ n $. Then $ A $ is cyclic.\n\\end{proposition}\n\nThe remainder of this section will be devoted to proving Proposition \\ref{prop:6.4.1}. As a corollary, we deduce that the multiplicative group $ K^* $ of any finite field $ K $ is cyclic. Consider the cyclic group $ \\ZZ / n\\ZZ $. The order of any element in this group is a divisor of $ n $.\n\n\\begin{definition}\nFor $ n \\in \\ZZ $, we let $ \\Phi\\br{n} $ denote the number of elements in $ \\br{\\ZZ / n\\ZZ, +} $ of exact order $ n $. This equals to the number of elements $ t \\in \\ZZ $ for $ 1 \\le t \\le n $ such that $ \\br{t, n} = 1 $.\n\\end{definition}\n\n\\begin{note*}\nSince $ \\sbr{1} $ in $ \\ZZ / n\\ZZ $ has order $ n $, $ \\Phi\\br{n} $ is nonzero for all $ n $.\n\\end{note*}\n\n\\begin{lemma}\nFor any $ d $ dividing $ n $, the cyclic group $ \\ZZ / n\\ZZ $ contains a unique subgroup of order $ d $, and any element of $ \\ZZ / n\\ZZ $ of order dividing $ d $ is contained in this subgroup.\n\\end{lemma}\n\n\\begin{proof}\nThe cyclic subgroup $ C $ of $ \\ZZ / n\\ZZ $ generated by $ n / d $ is clearly a subgroup of order $ d $. This has $ d $ elements $ \\sbr{0}, \\dots, \\br{d - 1}\\sbr{\\tfrac{n}{d}} $. Conversely, if $ x $ is an element of a subgroup of $ \\ZZ / n\\ZZ $ of order $ d $, then the order of $ x $ divides $ d $, so $ dx $ is divisible by $ n $, and hence, by unique factorisation, $ x $ is divisible by $ n / d $. Thus $ x $ is in $ C $ and the claim follows.\n\\end{proof}\n\n\\pagebreak\n\nAs a consequence, we deduce the following.\n\n\\begin{corollary}\nFor any $ d $ dividing $ n $, $ \\Phi\\br{d} $ is the number of elements of $ \\ZZ / n\\ZZ $ of order $ d $.\n\\end{corollary}\n\n\\begin{corollary}\n\\label{cor:6.4.5}\nFor any $ n \\in \\ZZ $, we have $ \\sum_{d \\mid n} \\Phi\\br{d} = n $.\n\\end{corollary}\n\n\\begin{proof}\nSince every element of $ \\ZZ / n\\ZZ $ has order $ d $ for some $ d $ dividing $ n $, the sum over all possible $ d $ dividing $ n $ of the number of elements of order $ d $ is just the number of elements of $ \\ZZ / n\\ZZ $, which is $ n $.\n\\end{proof}\n\n\\begin{proof}[Proof of Proposition \\ref{prop:6.4.1}]\nLet $ A $ be as in Proposition \\ref{prop:6.4.1}. We must show that $ A $ contains an element of order $ n $. In fact, we will show, by induction on $ d $, that $ A $ contains exactly $ \\Phi\\br{d} $ elements of order $ d $ for all $ d \\mid n $. In particular, $ A $ has $ \\Phi\\br{n} > 0 $ elements of order $ n $, so it is cyclic. If $ d = 1 $, the only element of order one is the identity of $ A $. Since $ \\Phi\\br{1} = 1 $ the base case holds. Assume the claim is true for all $ d' < d $. Then $ A $ has $ d $ elements of order dividing $ d $, and $ \\Phi\\br{d} $ elements of order $ d' $ for $ d' \\mid d $ and $ d' < d $, so the number of elements of exact order $ d $ is $ d - \\sum_{d' \\mid d, \\ d' < d} \\Phi\\br{d'} $. By Corollary \\ref{cor:6.4.5}, this is precisely $ \\Phi\\br{d} $.\n\\end{proof}\n\n\\subsection{Uniqueness}\n\nWe now turn to the question of showing that any two fields of $ p^r $ elements are isomorphic. Let $ K $ be such a field. The cyclicity of $ K^* $ immediately shows the following.\n\n\\begin{proposition}\nAny finite field $ K $ of characteristic $ p $ is generated over $ \\FF_p $ by a single element $ \\alpha \\in K $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha $ be an element of $ K $, that generates $ K^* $ as an abelian group. Then $ \\FF_p\\br{\\alpha} $ is contained in $ K $, but contains $ \\alpha^n $ for all $ n $, so contains $ K^* $, hence $ K = \\FF_p\\br{\\alpha} $.\n\\end{proof}\n\nAs a corollary, we deduce the following.\n\n\\begin{proposition}\nFor any prime $ p $ and any $ r \\in \\ZZ_{> 0} $, there exists an irreducible polynomial $ P\\br{X} \\in \\FF_p\\sbr{X} $ of degree $ r $ in $ \\FF_p\\sbr{X} $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ K $ be a finite field of $ p^r $ elements, let $ \\alpha $ be an element of $ K $ that generates $ K $ over $ \\FF_p $, and let $ P $ the minimal polynomial of $ \\alpha $ over $ \\FF_p $. We then have a surjective map\n$$ \\function{\\FF_p\\sbr{X}}{K}{X}{\\alpha}. $$\nIts kernel is generated by the irreducible polynomial $ P\\br{X} $ of degree $ \\deg P = \\sbr{\\FF_p\\br{\\alpha} : \\FF_p} = r $.\n\\end{proof}\n\nWe also have the following trick.\n\n\\begin{lemma}\nEvery irreducible polynomial $ P\\br{X} $ of degree $ r $ in $ \\FF_p\\sbr{X} $ is a divisor of $ X^{p^r - 1} - 1 $.\n\\end{lemma}\n\n\\begin{proof}\nLet $ K = \\FF_p\\br{\\alpha} $ where $ \\alpha $ is a root of $ P $. Then $ \\#K = p^r $ so $ \\alpha^{p^r} - \\alpha $ is zero in $ K $. So $ P\\br{X} \\mid X^{p^r} - X $.\n\\end{proof}\n\n\\begin{corollary}\nAny two finite fields $ K $ and $ K' $ of cardinality $ p^r $ are isomorphic.\n\\end{corollary}\n\n\\begin{proof}\nChoose $ \\alpha \\in K $ such that $ \\alpha $ generates $ K $ over $ \\FF_p $. We can then write\n$$ K = \\FF_p\\br{\\alpha} \\cong \\FF_p\\sbr{X} / \\abr{P\\br{X}}, $$\nwhere $ P\\br{X} $ is the minimal polynomial of $ \\alpha $ over $ \\FF_p $. In particular $ P\\br{X} $ is irreducible of degree $ r $. Since $ P\\br{X} $ divides $ X^{p^r - 1} - 1 $ in $ \\FF_p\\sbr{X} $, it also divides $ X^{p^r - 1} - 1 $ in $ K'\\sbr{X} $. Since in $ K'\\sbr{X} $, the latter factors into linear factors, $ P\\br{X} $ also factors into linear factors over $ K' $. In particular there exists a root $ \\alpha' \\in K' $ of $ P\\br{X} $ in $ K'\\sbr{X} $ such that $ P\\br{\\alpha'} = 0 $. Then there is a map\n$$\n\\begin{array}{rcccl}\nK & \\to & \\FF_p\\sbr{X} / \\abr{P\\br{X}} & \\to & K' \\\\\nQ\\br{\\alpha} & \\mapsto & Q\\br{X} & \\mapsto & Q\\br{\\alpha'}\n\\end{array}.\n$$\nSince this is map of fields from $ K $ to $ K' $ that takes $ \\alpha $ to $ \\alpha' $ it is injective. Since both fields $ K $ and $ K' $ have the same cardinality $ p^r $, it is also surjective and an isomorphism.\n\\end{proof}\n\nIf $ K = \\QQ $, $ \\QQ\\sbr{X} / \\abr{X^2 - p} $ are pairwise nonisomorphic extensions of degree $ \\alpha $ for every prime $ p $.\n\n\\lecture{11}{Monday}{29/10/18}\n\nLecture 11 is a problems class.\n\n\\pagebreak\n\n\\section{\\texorpdfstring{$ R $}{R}-modules}\n\n\\subsection{Definitions}\n\n\\lecture{12}{Wednesday}{31/10/18}\n\n\\begin{definition}\nAn \\textbf{$ R $-module} $ M $ is a set, together with two operations\n$$ +_M : M \\times M \\to M, \\qquad \\cdot_M : R \\times M \\to M, $$\nsuch that\n\\begin{enumerate}\n\\item $ \\br{M, +} $ makes $ M $ into an abelian group with identity $ 0_M $,\n\\item for all $ r \\in R $ and $ m, m' \\in M $, $ r\\br{m + m'} = rm + rm' $,\n\\item for all $ r, r' \\in R $ and $ m \\in M $, $ \\br{r + r'}m = rm + r'm $,\n\\item for all $ r, r' \\in R $ and $ m \\in M $, $ \\br{rr'}m = r\\br{r'm} $, and\n\\item for all $ m \\in M $, $ 1_R \\cdot m = m $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{note*}\nFor an abelian group $ M $, let $ \\End\\br{M} $ denote the set of homomorphisms $ M \\to M $ of abelian groups. Then $ \\End\\br{M} $ is a noncommutative ring, where $ 2 $ if and only if for all $ r \\in R $, $ \\cdot r : M \\to M $ lives in $ \\End\\br{M} $, and $ 3, 4, 5 $ if and only if the map $ R \\to \\End\\br{M} $ given by $ 2 $ is a homomorphism of rings.\n\\end{note*}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item The usual addition and multiplication on $ R $ naturally makes $ R $ into an $ R $-module.\n\\item More generally, any ideal $ I $ of $ R $ is an $ R $-module with the usual addition and multiplication.\n\\item If $ f : R \\to S $, then $ f $ makes $ S $ into an $ R $-module, where the addition $ + $ is the usual addition in $ S $, and the multiplication law is defined by $ r \\cdot s = f\\br{r} \\cdot_S s $ for $ r \\in S $ and $ s \\in S $.\n\\item In particular any quotient $ R / I $ is an $ R $-module.\n\\item More generally, if $ f : R \\to S $ is a homomorphism, and $ M $ is any $ S $-module, then $ M $ is also an $ R $-module via $ r \\cdot m = f\\br{r} \\cdot m $.\n\\item In particular, $ R \\to R / I $ lets us treat any $ R / I $-module $ M $ as an $ R $-module. Note that if $ M $ is an $ R / I $-module, then for all $ r \\in I $ and $ m \\in M $, $ r \\cdot m = 0 $. We say that $ I $ \\textbf{annihilates} $ M $ in this situation.\n\\item Conversely, if $ M $ is an $ R $-module and $ r \\cdot m = 0 $ for all $ r \\in I $ and $ m \\in M $, then $ M $ naturally has the structure of an $ R / I $-module. Given $ r + I \\in R / I $ and $ m \\in M $, we define $ \\br{r + I} \\cdot m = rm $.\nIf $ r + I = r' + I $, then $ r - r' \\in I $, so $ rm - r'm = \\br{r - r'}m = 0 $, by assumption.\n\\item Let $ R = \\ZZ $, and let $ M $ be an abelian group. Then $ M $ has the unique natural structure of $ \\ZZ $-module, as follows. Property $ 3 $ from the module axioms shows that\n$$ n \\cdot m =\n\\begin{cases}\nm + \\dots + m & n > 0 \\\\\n0 & n = 0 \\\\\n\\br{-m} + \\dots + \\br{-m} & n < 0\n\\end{cases}.\n$$\nThus the multiplication law $ \\ZZ \\times M \\to M $ is forced on us, and one checks that it does satisfy properties $ 2 $ to $ 5 $ above. Informally, we say that abelian groups are $ \\ZZ $-modules.\n\\item If $ R $ is a field, then $ R $-modules are just $ R $-vector spaces.\n\\item Let $ S $ be a set, and let $ M_S $ be the set of $ R $-valued functions $ f : S \\to R $. We add and multiply pointwise. For $ f, g \\in M_S $, we can define\n$$ f + g = s \\mapsto f\\br{s} + g\\br{s}, \\qquad rf = s \\mapsto r \\cdot f\\br{s}. $$\n$ M_S $ is clearly an $ R $-module.\n\\item Also of interest is the $ R $-submodule $ \\F_S $ of $ M_S $ that consists of functions $ f : S \\to R $ such that $ f\\br{s} = 0_R $ for all but finitely many $ s $. The $ R $-module $ \\F_S $ is called the \\textbf{free $ R $-module on the set $ S $} and will be very important for us.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{Submodules, quotients, and direct sums}\n\n\\begin{definition}\nLet $ M $ be an $ R $-module. A subset $ N $ of $ M $ is an \\textbf{$ R $-submodule} of $ M $ if $ N $ is closed under addition and multiplication by elements of $ R $. That is, $ N $ is an additive subgroup of $ M $, and for all $ r \\in R $, we have $ rN \\subseteq N $.\n\\end{definition}\n\nIn particular, the ideals of $ R $ are just the $ R $-submodules of $ R $.\n\n\\begin{definition}\nIf $ S $ is any subset of $ M $, we define the $ R $-submodule of $ M $ \\textbf{generated} by $ S $ to be the set of all elements of $ M $ of the form\n$$ r_1s_1 + \\dots + r_ns_n, \\qquad r_i \\in R, \\qquad s_i \\in S. $$\nIt is the smallest $ R $-submodule of $ M $ containing $ S $.\n\\end{definition}\n\n\\begin{definition}\nAn $ R $-module $ M $ is a \\textbf{finitely generated} $ R $-module if $ M $ admits a finite subset $ S $ of $ M $ such that the $ R $-submodule of $ M $ generated by $ S $ is all of $ M $. We say $ S $ is a \\textbf{generating set} for $ M $.\n\\end{definition}\n\n\\begin{definition}\nLet $ M $ be an $ R $-module and $ N $ be an $ R $-submodule of $ M $. We say two elements $ m $ and $ m' $ of $ M $ are \\textbf{congruent modulo $ N $} if their difference $ m - m' $ lies in $ N $. This is easily seen to be an equivalence relation, and the equivalence classes are the cosets of the form $ m + N $ for $ m \\in M $. The set of equivalence classes is denoted $ M / N $. It has the natural structure of an $ R $-module, where\n$$ \\br{m + N} + \\br{m' + N} = \\br{m + m'} + N, \\qquad r \\cdot \\br{m + N} = \\br{rm} + N. $$\nThis $ R $-module is called the \\textbf{quotient} of $ M $ by $ N $. If $ m + N = m' + N $, then $ m - m' \\in N $, so $ rm - rm' = r\\br{m - m'} \\in N $. So this is well-defined. Have a natural map\n$$ \\function{M}{M / N}{m}{m + N}. $$\n\\end{definition}\n\n\\begin{definition}\nGiven two $ R $-modules $ M_1 $ and $ M_2 $, the \\textbf{direct sum} $ M_1 \\oplus M_2 $ is the set of ordered pairs $ \\br{m_1, m_2} $ with\n$$ \\br{m_1, m_2} + \\br{m_1', m_2'} = \\br{m_1 + m_1', m_2 + m_2'}, \\qquad r\\br{m_1, m_2} = \\br{rm_1, rm_2}. $$\n\\end{definition}\n\n\\begin{example*}\nLet $ M $ be an $ R $-module and $ I $ an ideal of $ R $. Then we can form the $ R $-submodule $ IM $ of $ M $ consisting of all elements of $ M $ of the form\n$$ i_1m_1 + \\dots + i_rm_r, \\qquad i_j \\in I, \\qquad m_j \\in M. $$\nThis is an $ R $-submodule of $ M $, so we can form the quotient $ M / IM $. Then $ M / IM $ is certainly an $ R $-module, but it is also an $ R / I $-module. One can define multiplication\n$$ \\function{R / I \\times M / IM}{M / IM}{\\br{r + I, m + IM}}{rm + IM}. $$\nAs always one has to check that this is well-defined, but this is straightforward. We need that if $ r - r' $ lies in $ I $, and $ m - m' $ lies in $ IM $, then $ rm - r'm' $ lies in $ IM $. But $ rm - r'm' = \\br{r - r'}m + r'\\br{m - m'} $, which is clearly in $ IM $.\n\\end{example*}\n\n\\subsection{Module homomorphisms, kernels, and images}\n\n\\begin{definition}\nA map $ f : M \\to N $ of $ R $-modules is called a \\textbf{homomorphism of $ R $-modules} if\n\\begin{itemize}\n\\item $ f $ is a homomorphism of the underlying abelian groups, and\n\\item for all $ r \\in R $ and $ m \\in M $,\n$$ f\\br{rm} = rf\\br{m}. $$\n\\end{itemize}\n\\end{definition}\n\nA warning is that a ring homomorphism $ R \\to R $ satisfies $ f\\br{rr'} = f\\br{r}f\\br{r'} $, but an $ R $-module homomorphism $ R \\to R $ satisfies $ f\\br{rr'} = rf\\br{r'} $.\n\n\\pagebreak\n\n\\begin{definition}\nThe \\textbf{kernel} of $ f : M \\to N $ is the set\n$$ \\cbr{m \\in M \\st f\\br{m} = 0}, $$\nand the \\textbf{image} of $ f : M \\to N $ is the set\n$$ \\cbr{n \\in N \\st \\exists m \\in M, \\ f\\br{m} = n}. $$\n\\end{definition}\n\nIt is easy to see that the kernel and image of a homomorphism of $ R $-modules $ f : M \\to N $ are $ R $-submodules of $ M $ and $ N $, respectively.\n\n\\begin{note*}\nIn particular there is a natural homomorphism\n$$ \\function{M}{M / N}{m}{m + N}. $$\n\\end{note*}\n\nThis homomorphism has the following universal property, exactly analogous to the universal property of the quotient construction for rings.\n\n\\begin{proposition}[Universal property of the quotient]\nLet $ N $ be an $ R $-submodule of $ M $, and let $ f : M \\to M' $ be an $ R $-module homomorphism whose kernel contains $ N $. Then there is unique homomorphism\n$$ \\overline{f} : M / N \\to M', $$\nsuch that $ \\overline{f}\\br{m + N} = f\\br{m} $ for all $ m \\in M $. In particular the kernel of $ \\overline{f} $ is the image of $ \\ker f $ in $ M / N $.\n\\end{proposition}\n\n\\begin{proof}\nThe proof is identical to that for quotient rings, and will be omitted.\n\\end{proof}\n\n\\subsection{Free modules}\n\n\\begin{definition}\nLet $ M $ be an $ R $-module. A subset $ S $ of $ M $ is a \\textbf{basis} for $ M $ if the following two conditions hold.\n\\begin{itemize}\n\\item $ S $ \\textbf{spans $ M $ over $ R $}. For all $ m \\in M $, there exist $ s_1, \\dots, s_n \\in S $ finite and $ r_1, \\dots, r_n \\in R $ such that $ m = r_1s_1 + \\dots + r_ns_n $, that is the $ R $-submodule of $ M $ generated by $ S $ is all of $ M $.\n\\item $ S $ is \\textbf{$ R $-linearly independent}. For any collection $ s_1, \\dots, s_n $ of distinct elements of $ S $, and any $ r_1, \\dots, r_n \\in R $, $ r_1s_1 + \\dots + r_ns_n $ is nonzero in $ M $ unless all $ r_i $ are zero.\n\\end{itemize}\n\\end{definition}\n\n\\begin{definition}\nAn $ R $-module $ M $ that has a basis $ S $ is called a \\textbf{free} $ R $-module. The cardinality $ n $ of the basis $ S $ is called the \\textbf{rank} of the free $ R $-module $ M $ over $ R $.\n\\end{definition}\n\n\\lecture{13}{Friday}{02/11/18}\n\n\\begin{remark}\nIf $ R $ is a field, then the notion of a basis for an $ R $-module coincides with the usual notion for vector spaces. In this case, at least if one assumes the axiom of choice, every $ R $-module has a basis. When $ R $ is not a field only very special $ R $-modules have bases. For instance any quotient $ R / I $ of $ R $ for $ I $ a nonzero ideal has no basis.\n\\end{remark}\n\n\\begin{example*}\nThe ring $ R $ is a free $ R $-module of rank one over $ R $, with basis $ \\cbr{1_R} $. More generally any unit $ u \\in R^\\times $ gives a basis of $ R $ as an $ R $-module.\n\\end{example*}\n\nRecall that the free $ R $-module $ \\F_S $ on a set $ S $ was defined to be the set of functions $ f : S \\to R $ such that $ f\\br{s} = 0 $ for all but finitely many $ s \\in S $. For each $ s \\in S $, we have an element $ e_s $ of $ \\F_S $ defined by $ e_s\\br{t} = 0 $ for all $ t \\in S $ with $ t \\ne s $, and $ e_s\\br{s} = 1 $. Claim that the $ e_s $ form a basis for $ \\F_S $. In particular, given $ f : S \\to R $ with $ f\\br{s} = 0 $ for all but finitely many $ s $, let $ s_1, \\dots, s_n $ be the set of elements in $ S $ on which $ f\\br{s_i} $ is nonzero. Set $ r_i = f\\br{s_i} $. Claim that\n$$ f = r_1e_{s_1} + \\dots + r_ne_{s_n}. $$\nIf $ f\\br{s} = 0 $, then $ s \\notin \\cbr{s_1, \\dots, s_n} $ so $ e_{s_i}\\br{s} = 0 $ for all $ i $. For any $ i $, $ e_{s_i}\\br{s_j} = 0 $ if $ i \\ne j $ and $ e_{s_i}\\br{s_i} = 1 $, so $ \\br{\\sum_{i = 1}^n r_ie_{s_i}}\\br{s_j} = r_j = f\\br{s_j} $. Then $ f $ can be written as $ r_1e_{s_1} + \\dots + r_ne_{s_n} $, so the $ e_s $ span $ \\F_S $. On the other hand, for all $ s_1, \\dots, s_n \\in S $ distinct with $ \\sum_{i = 1}^n r_ie_{s_i} = 0 $, $ \\sum_{i = 1}^n r_ie_{s_i} $ takes the value $ r_i $ by evaluating at $ s_i $ for all $ i $, and thus is only the zero function when all $ r_i $ are zero for all $ i $, so we do have $ R $-linear independence. Thus $ \\F_S $ is free, justifying its name.\n\n\\pagebreak\n\n\\begin{proposition}\nLet $ F_1 $ and $ F_2 $ be free $ R $-modules with basis $ S_1 $ and $ S_2 $. Then $ F_1 \\oplus F_2 $ is free with basis\n$$ \\cbr{\\br{s, 0} \\st s \\in S_1} \\cup \\cbr{\\br{0, s'} \\st s' \\in S_2}. $$ Moreover, if $ F_1 $ and $ F_2 $ are free of finite ranks $ n_1 $ and $ n_2 $ respectively, then $ F_1 \\oplus F_2 $ is free of rank $ n_1 + n_2 $.\n\\end{proposition}\n\n\\begin{proof}\nFor linear independence, let $ s_1, \\dots, s_m \\in S_1 $ and $ s_1', \\dots, s_l' \\in S_2 $ be distinct. Suppose we have $ r_1, \\dots, r_m, r_1', \\dots, r_l' \\in R $ such that\n$$ r_1\\br{s_1, 0} + \\dots + r_m\\br{s_m, 0} + r_1'\\br{0, s_1'} + \\dots + r_l'\\br{0, s_l'} = 0. $$\nThen\n$$ r_1s_1 + \\dots + r_ms_m = 0 \\in M_1, \\qquad r_1's_1' + \\dots + r_l's_l' = 0 \\in M_2, $$\nso $ r_i = 0 $ and $ r_i' = 0 $. For spanning set, let $ \\br{m, m'} \\in M_1 \\oplus M_2 $. Write\n$$ m = r_1s_1 + \\dots + r_ms_m, \\qquad s_i \\in S_1, \\qquad m' = r_1's_1' + \\dots + r_l's_l', \\qquad s_i' \\in S_2, $$\nthen\n$$ \\br{m, m'} = r_1\\br{s_1, 0} + \\dots + r_m\\br{s_m, 0} + r_1'\\br{0, s_1'} + \\dots + r_l'\\br{0, s_l'}. $$\nThus $ S_1 \\cup S_2 $ is a basis for $ F_1 \\oplus F_2 $, which immediately proves the claim.\n\\end{proof}\n\nFree modules have the following universal property.\n\n\\begin{proposition}[Universal property of free modules]\nLet $ \\F_S $ be a free $ R $-module on a set $ S $. Then for any $ R $-module $ M $, and any map of sets $ f : S \\to M $, there is a unique homomorphism of $ R $-modules\n$$ \\phi_f : \\F_S \\to M, $$\nsuch that $ \\phi_f\\br{e_s} = f\\br{s} $ for all $ s \\in S $.\n\\end{proposition}\n\n\\begin{proof}\nDefine $ \\phi_f $ by\n$$ \\phi_f\\br{g} = \\sum_{s \\in S, \\ g\\br{s} \\ne 0} g\\br{s}f\\br{s}. $$\nNote that this is a finite sum since all but finitely many $ s $ have $ g\\br{s} = 0 $. Then it is clear that this is a homomorphism of $ R $-modules. On the other hand suppose $ \\phi $ is any other map $ \\F_S \\to N $ with $ \\phi\\br{e_s} = f\\br{s} $ for all $ s $. Then we can write $ g = \\sum_{s \\in S, \\ g\\br{s} \\ne 0} g\\br{s}e_s $, again a finite sum, so\n$$ \\phi\\br{g} = \\sum_{s \\in S, \\ g\\br{s} \\ne 0} g\\br{s}\\phi\\br{e_s} = \\sum_{s \\in S, \\ g\\br{s} \\ne 0} g\\br{s}f\\br{s}, $$\nso uniqueness is clear.\n\\end{proof}\n\nThe image of $ \\phi_f $ is the $ R $-submodule of $ N $ generated by the elements $ f\\br{s} $ for $ s \\in S $.\n\n\\begin{corollary}\nLet $ M $ be a free $ R $-module with a basis $ T $ for $ M $. Let $ S $ be any set of the same cardinality as $ T $, and let $ g : T \\to S $ be any bijection. Then the map $ \\phi_f : \\F_S \\to M $ is an isomorphism. In particular, any two free $ R $-modules of the same rank are isomorphic.\n\\end{corollary}\n\n\\begin{proof}\nThe map $ \\phi_f : \\F_S \\to M $ is such that $ \\phi_f\\br{e_s} = f\\br{s} $. Since elements of $ T $ are linearly independent, this map is injective. Suppose $ \\phi_f\\br{g} = 0 $. Can write $ g = \\sum_i r_ie_{s_i} $ for $ s_i $ distinct, then $ \\phi_f\\br{g} = \\sum_i r_if\\br{s_i} $. Since $ s_i $ are distinct, $ f\\br{s_i} $ are distinct elements of $ T $, so $ \\sum_i r_if\\br{s_i} = 0 $. So $ r_i = 0 $, so $ g = 0 $. Since elements of $ T $ span $ M $, this map is surjective. Given $ m \\in M $, write $ m = \\sum_i r_it_i $. For all $ i $, find $ s_i $, with $ f\\br{s_i} = t_i $. Then $ \\phi_f\\br{\\sum_i r_ie_{s_i}} = \\sum_i r_it_i = m $. Thus $ M $ is isomorphic to $ \\F_S $. Since $ M $ was arbitrary, any $ R $-module of rank equal to the cardinality of $ S $ is isomorphic to $ \\F_S $ and the result follows.\n\\end{proof}\n\n\\begin{note*}\nIt is also true, but harder to prove, that if $ M $ and $ N $ are free of different ranks, then $ M \\ncong N $.\n\\end{note*}\n\n\\pagebreak\n\n\\subsection{Generators and relations}\n\n\\lecture{14}{Monday}{05/11/18}\n\nNow let $ M $ be any $ R $-module, and let $ S = \\cbr{s_1, \\dots, s_n} \\subseteq M $ be a finite subset of $ M $ generating $ M $. Then we have a natural map\n$$ \\function[\\psi]{\\F_S}{M}{\\sum_{i = 1}^n m_ie_{s_i}}{\\sum_{i = 1}^n m_is_i}, \\qquad m_i \\in R, $$\nand this map is surjective. Elements of the kernel $ K = \\ker \\psi $ are called \\textbf{relations} among $ S $. Explicitly, an element of $ K $ is a map $ f = \\sum_{i = 1}^n m_ie_{s_i} : S \\to R $ such that $ f\\br{s_i} = 0 $ for all but finitely many $ s_i $, and $ \\sum_{i = 1}^n f\\br{s_i}s_i = 0 $, since\n$$ \\sum_{i = 1}^n f\\br{s_i}s_i = \\sum_{i = 1}^n \\br{\\sum_{j = 1}^n m_je_{s_j}}\\br{s_i}s_i = \\sum_{i = 1}^n \\br{\\sum_{j = 1}^n m_je_{s_j}\\br{s_i}}s_i = \\sum_{i = 1}^n m_ie_{s_i}\\br{e_{s_i}}s_i = \\sum_{i = 1}^n m_is_i. $$\nIn other words, each element of $ K $ encodes a linear relation among the elements of $ S $. It is a measure of how far the elements of $ S $ are from being linearly independent. Let $ T = \\cbr{t_1, \\dots, t_m} \\subseteq K $ be a subset of $ K $ that generates $ K $. Then in the same way as above, we get a surjection\n$$ \\function{\\F_T}{K}{\\sum_{j = 1}^m k_je_{t_j}}{\\sum_{j = 1}^m k_jt_j}, \\qquad k_j \\in R, $$\nwith $ \\F_T $ a free module of rank $ m $. Composing with the inclusion of $ K $ in $ \\F_S $ gives us a map $ \\phi : \\F_T \\to \\F_S $ whose image is $ K $. Thus $ K = \\ker \\psi = \\im \\phi = \\phi\\br{\\F_T} $. The map $ \\psi $ determines $ M $ up to isomorphism with the quotient $ \\F_S / K $, and hence with $ \\F_S / \\phi\\br{\\F_T} $. A description of a module as a quotient of a free module by the image of a map of free modules is called a \\textbf{presentation} of $ M $. If both modules have finite rank the presentation is called \\textbf{finite}. A module that has a finite presentation is called \\textbf{finitely presented}. Put another way, a presentation is a description of a module $ M $ in terms of\n\\begin{itemize}\n\\item a generating set $ S $ for $ M $, and\n\\item a generating set $ T $ for the linear relations satisfied by $ S $.\n\\end{itemize}\n\nWhen $ S $ and $ T $ are finite we can encode a presentation in a matrix, called the \\textbf{presentation matrix}. Write $ S = \\cbr{s_1, \\dots, s_n} $ and $ T = \\cbr{t_1, \\dots, t_m} $. Then $ \\phi $ is determined by $ \\phi\\br{e_{t_1}}, \\dots, \\phi\\br{e_{t_m}} $. For each $ j $ we can write $ \\phi\\br{e_{t_j}} $ as a sum $ \\sum_{i = 1}^n r_{ij}e_{s_i} $, and let $ A $ be the $ n $ by $ m $ matrix whose $ i $ and $ j $ entry is $ r_{ij} $. Then $ A $ gives a map from $ R^m $ to $ R^n $, and the quotient of $ R^n $ by the $ R $-submodule $ AR^m $ of $ R^n $ is isomorphic to $ M $.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Let $ R = \\ZZ $ and $ M = \\ZZ / n\\ZZ $ generated by $ \\sbr{1}_n $. The map $ \\ZZ \\to M $ is the quotient map with kernel $ \\abr{n} $. So the presentation matrix is just $ \\br{n} $.\n\\item Let $ R = \\ZZ\\sbr{\\sqrt{-5}} $ and $ I = \\abr{2, 1 + \\sqrt{-5}} $, so $ s_1 = 2 $ and $ s_2 = 1 + \\sqrt{-5} $. Then\n$$ \\psi\\br{\\br{1 + \\sqrt{-5}}e_{s_1} - 2e_{s_2}} = \\br{1 + \\sqrt{-5}}s_1 - 2s_2 = 0. $$\nSince $ \\br{2}\\br{3} = \\br{1 + \\sqrt{-5}}\\br{1 - \\sqrt{-5}} $,\n$$ \\psi\\br{3e_{s_1} - \\br{1 - \\sqrt{-5}}e_{s_2}} = 3s_1 - \\br{1 - \\sqrt{-5}}s_2 = 0. $$\nClaim that the two relations $ \\br{1 + \\sqrt{-5}}e_{s_1} - 2e_{s_2} $ and $ 3e_{s_1} - \\br{1 - \\sqrt{-5}}e_{s_2} $ generate $ K $. Let $ ae_{s_1} + be_{s_2} $ be a relation, so $ a, b \\in R $ and $ as_1 + bs_2 = 0 $, that is $ a = -\\tfrac{1 + \\sqrt{-5}}{2}b $ for $ a, b \\in R $. A question is for which $ b $ does $ a $ lie in $ R $? Claim that the set of such $ b $ is an ideal $ J $ of $ R $. $ 2 \\in J $ and $ 1 - \\sqrt{-5} \\in J $ so $ J $ contains $ \\abr{2, 1 - \\sqrt{-5}} $, and $ 1 \\notin J $, since $ \\abr{2, 1 - \\sqrt{-5}} $ is maximal, so $ J = \\abr{2, 1 - \\sqrt{-5}} $. Similarly, the set of $ a $ is an ideal $ \\abr{1 + \\sqrt{-5}, 3} $ of $ R $. Thus let $ t_1 = \\br{1 + \\sqrt{-5}}e_{s_1} - 2e_{s_2} $ and $ t_2 = 3e_{s_1} - \\br{1 - \\sqrt{-5}}e_{s_2} $, so we have a map $ A : R^2 \\to R^2 $ with presentation matrix\n$$ \\twobytwo{1 + \\sqrt{-5}}{3}{-2}{-1 + \\sqrt{-5}}. $$\n\\end{itemize}\n\\end{example*}\n\nThe general idea is if we have a presentation matrix $ A : R^m \\to R^n $ for $ M $, with $ n $ rows and $ m $ columns, then $ BAC $ is also a presentation matrix for $ M $, where $ B $ is $ n \\times n $ and $ C $ is $ m \\times m $, and $ B $ and $ C $ are invertible matrices with inverse matrix entries in $ R $.\n\n\\pagebreak\n\n\\section{Noetherian rings and modules}\n\n\\subsection{Definitions and basic properties}\n\n\\begin{definition}\nLet $ R $ be a ring and let $ M $ be an $ R $-module. We say $ M $ is \\textbf{Noetherian} if every increasing infinite chain\n$$ M_1 \\subseteq M_2 \\subseteq \\dots $$\nof $ R $-submodules $ M_i $ of $ M $ is \\textbf{eventually constant}. That is, for any such chain, there exists $ N $ such that we have $ M_i = M_N $ for all $ i \\ge N $. A ring $ R $ is Noetherian if $ R $ is Noetherian as an $ R $-module over itself. Since the $ R $-submodules of $ R $ are just the ideals of $ R $, a ring $ R $ is Noetherian if every increasing infinite chain\n$$ I_1 \\subseteq I_2 \\subseteq \\dots $$\nof ideals $ I_j $ of $ R $ is eventually constant.\n\\end{definition}\n\nThe following result about Noetherian $ R $-modules is fundamental.\n\n\\begin{theorem}\nAn $ R $-module $ M $ is Noetherian if and only if every $ R $-submodule $ N $ of $ M $ is finitely generated.\n\\end{theorem}\n\n\\begin{proof}\nSuppose first that $ M $ is Noetherian, and let $ N $ be an $ R $-submodule of $ M $. Choose an element $ n_0 $ of $ N $, and let $ N_0 $ be the $ R $-submodule of $ N $ generated by $ n_0 $. If $ N_0 $ is all of $ N $, then $ N $ is finitely generated. Otherwise, choose $ n_1 $ in $ N \\setminus N_0 $, and let $ N_1 $ be the $ R $-submodule of $ N $ generated by $ n_0 $ and $ n_1 $. If $ N $ is not finitely generated, we may continue this process indefinitely, choosing for each $ i $ an $ n_i $ in $ N \\setminus N_{i - 1} $, which is nonempty since $ N $ is not finitely generated, and letting $ N_i $ be generated by $ n_0, \\dots, n_i $. In this way we obtain a strictly increasing infinite chain\n$$ N_0 \\subsetneq N_1 \\subsetneq \\dots $$\nof $ R $-submodules of $ M $, contradicting the fact that $ M $ is Noetherian. Conversely, suppose that every $ R $-submodule of $ M $ is finitely generated, and let\n$$ M_0 \\subseteq M_1 \\subseteq \\dots $$\nbe an increasing chain. We must show that this chain is eventually constant. Let $ N $ be the union of the $ R $-submodules $ M_i $. Note that $ N $ is an $ R $-submodule of $ M $. Thus $ N $ is finitely generated, say by $ n_1, \\dots, n_s $. If $ n_1, n_2 \\in N $, then there exist $ i $ and $ j $ with $ n_1 \\in M_i $ and $ n_2 \\in M_j $. If $ d \\ge i $ and $ d \\ge j $, then $ n_1, n_2 \\in M_d $, so $ n_1 + n_2 \\in M_d $, so $ n_1 + n_2 \\in N $. Since $ N $ is the union of the $ M_j $, there exist $ i_1, \\dots, i_s $ such that $ n_j $ is in $ M_{i_j} $ for all $ j $. Let $ d $ be the largest of the $ i_j $. Then $ M_d $ contains $ n_1, \\dots, n_s $ so it contains $ N $. In particular for any $ d' \\ge d $ we have $ N \\subseteq M_d \\subseteq M_{d'} \\subseteq N $, so $ N = M_d = M_{d'} $ for all such $ d' $ and the chain is constant after $ M_d $.\n\\end{proof}\n\n\\lecture{15}{Wednesday}{07/11/18}\n\n\\begin{corollary}\nLet $ R $ be a PID. Then $ R $ is Noetherian.\n\\end{corollary}\n\n\\begin{proof}\nEvery ideal of $ R $ is principal, hence finitely generated.\n\\end{proof}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Any field is Noetherian.\n\\item The ring $ \\CC\\sbr{X^{\\QQ_{\\ge 0}}} $ is not Noetherian. The ideal consisting of all elements with no constant term is not finitely generated.\n\\end{itemize}\n\\end{example*}\n\n\\subsection{Finitely generated modules over Noetherian rings}\n\nThe plan is\n\\begin{itemize}\n\\item to show that Noetherianness has strong consequences, and\n\\item to use these properties to show $ R $ is Noetherian implies that $ R\\sbr{X} $ is Noetherian and other consequences.\n\\end{itemize}\nThe goal of this section is to prove the following theorem.\n\n\\begin{theorem}\n\\label{thm:8.2.1}\nAny finitely generated $ R $-module $ M $ over a Noetherian ring $ R $ is Noetherian.\n\\end{theorem}\n\n\\pagebreak\n\nWe proceed in several steps. First note the following.\n\n\\begin{proposition}\nLet $ M $ be a Noetherian $ R $-module. Then for any $ R $-submodule $ N $ of $ M $,\n\\begin{enumerate}\n\\item $ N $ is Noetherian, and\n\\item $ M / N $ is Noetherian.\n\\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item Since $ M $ is Noetherian, any $ R $-submodule of $ M $ is finitely generated, and thus any $ R $-submodule of $ N $ is finitely generated.\n\\item Given a $ R $-submodule $ N' $ of $ M / N $, let $ \\widetilde{N'} $ be its preimage in $ N $ under the canonical quotient map $ f : M \\to M / N $. We have a surjection from $ \\widetilde{N'} $ to $ N' $ induced by $ f $. Then $ \\widetilde{N'} \\subseteq M $, so $ \\widetilde{N'} $ is finitely generated, say by $ n_1, \\dots, n_s $. Claim that $ f\\br{n_1}, \\dots, f\\br{n_s} $ generate $ N' $. Given $ n \\in N' $, there exists $ \\widetilde{n} \\in \\widetilde{N'} $ such that $ f\\br{\\widetilde{n}} = n $. Write $ \\widetilde{n} = r_1n_1 + \\dots + r_sn_s $ for $ r_i \\in R $. Then $ n = f\\br{\\widetilde{n}} = r_1f\\br{n_1} + \\dots + r_sf\\br{n_s} $.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{proposition}\nLet $ M $ be an $ R $-module, let $ N $ be a Noetherian $ R $-submodule of $ M $, and suppose that $ M / N $ is Noetherian. Then $ M $ is Noetherian.\n\\end{proposition}\n\n\\begin{proof}\nLet $ M' $ be a $ R $-submodule of $ M $. Then $ M' \\cap N $ is a $ R $-submodule of $ M $, hence finitely generated. Let $ a_1, \\dots, a_s \\in M' \\cap N $ generate $ M' \\cap N $. Let $ \\overline{M'} $ denote the image of $ M' $ in $ M / N $. This is a $ R $-submodule of $ M / N $ and thus finitely generated. Let $ \\overline{b_1}, \\dots, \\overline{b_t} \\in \\overline{M'} \\subseteq M / N $ generate $ \\overline{M'} $, and choose elements $ b_1, \\dots, b_t $ of $ M' $ mapping to $ \\overline{b_1}, \\dots, \\overline{b_t} $ in $ M / N $, respectively. We now show that\n$$ a_1, \\dots, a_s, b_1, \\dots, b_t $$\nis a generating set for $ M' $, proving the claim. Given any $ m \\in M' $, let $ \\overline{m} $ be its image in $ M / N $ under $ f : M' \\to \\overline{M'} $. Then we can write $ \\overline{m} $ as a sum $ r_1\\overline{b_1} + \\dots + r_t\\overline{b_t} $ for $ r_1, \\dots, r_t \\in R $. Let $ m' = m - r_1b_1 - \\dots - r_tb_t $. Then the image of $ m' $ in $ M / N $ is $ f\\br{m'} = \\overline{m} - r_1\\overline{b_1} - \\dots - r_t\\overline{b_t} = 0 $. So $ m' $ lies in $ N $, and $ m, r_1b_1, \\dots, r_tb_t \\in M' $, so $ m' $ also lies in $ M' $. So it lies in $ M' \\cap N $. We can thus write $ m' $ as $ q_1a_1 + \\dots + q_sa_s $ for $ q_1, \\dots, q_s \\in R $. We then have\n$$ m = q_1a_1 + \\dots + q_sa_s + r_1b_1 + \\dots + r_tb_t, $$\nproving the claim.\n\\end{proof}\n\n\\begin{corollary}\nLet $ M $ and $ N $ are Noetherian $ R $-modules, then so is $ M \\oplus N $.\n\\end{corollary}\n\n\\begin{proof}\nWe have a surjection\n$$ \\function{M \\oplus N}{M}{\\br{m, n}}{m}. $$\nIts kernel $ K $ is the set of pairs of $ M \\oplus N $ of the form $ \\br{0, n} $, which is isomorphic to $ N $ by the natural map $ n \\mapsto \\br{0, n} $, and hence Noetherian. The surjection $ M \\oplus N \\to M $ descends to an isomorphism $ \\br{M \\oplus N} / K \\cong M $, so that $ \\br{M \\oplus N} / K $ is Noetherian. Thus $ M \\oplus N $ is Noetherian.\n\\end{proof}\n\nNow assume $ R $ is Noetherian. Then $ R, R \\oplus R, \\dots $ are all Noetherian $ R $-modules, that is the following.\n\n\\begin{corollary}\nIf $ R $ is Noetherian, then any free $ R $-module of finite rank is Noetherian.\n\\end{corollary}\n\n\\begin{proof}\nA free $ R $-module of rank $ s $ is the direct sum of $ s $ copies of $ R $, each of which is Noetherian as an $ R $-module when $ R $ is Noetherian.\n\\end{proof}\n\n\\begin{proof}[Proof of Theorem \\ref{thm:8.2.1}]\nLet $ M $ be a finitely generated $ R $-module, and let $ m_1, \\dots, m_s $ be a set of generators for $ M $. Then if $ R^s $ is a free $ R $-module of rank $ s $, with generators $ e_1, \\dots, e_s $, we have a surjection\n$$ \\function{R^s}{M}{e_i}{m_i}. $$\nLet $ K $ be the kernel. Then $ M $ is isomorphic to $ R^s / K $, and $ R^s $ is a Noetherian $ R $-module, so $ M $ is Noetherian as well.\n\\end{proof}\n\n\\pagebreak\n\n\\section{Polynomial rings in several variables}\n\n\\subsection{The Hilbert basis theorem}\n\nIn this section, we will use the ideas of the previous section to establish the following key result about polynomial rings, known as the Hilbert basis theorem.\n\n\\begin{theorem}[Hilbert basis theorem]\n\\label{thm:9.1.1}\nLet $ R $ be a Noetherian ring. Then $ R\\sbr{X} $ is Noetherian.\n\\end{theorem}\n\n\\lecture{16}{Friday}{09/11/18}\n\nLet $ P\\br{X} = b_0 + \\dots + b_nX^n $ for $ b_n \\in R^* $. We say that $ b_n $ is the \\textbf{leading coefficient} of $ P\\br{X} $. In general, if I have $ Q_1\\br{X}, \\dots, Q_r\\br{X} $ with degrees $ d_1, \\dots, d_r $ and leading coefficients $ a_1, \\dots, a_r $ and $ P\\br{X} $ of degree $ d \\ge d_1, \\dots, d_r $ then there exist $ n_1, \\dots, n_r \\in R $ such that\n$$ \\deg \\br{P\\br{X} - n_1X^{d - d_1}Q_1\\br{X} - \\dots - n_rX^{d - d_r}Q_r\\br{X}} < d, $$\nif and only if the leading coefficient of $ P\\br{X} $ is in the ideal generated by $ a_1, \\dots, a_r $. The following proof is due to Emmy Noether, and is a vast simplification of Hilbert's original proof.\n\n\\begin{lemma}\nLet $ R $ be Noetherian and $ I \\subseteq R\\sbr{X} $ be an ideal. Let $ J \\subseteq R $ be the set of leading coefficients of polynomials in $ I $. That is, the set of $ a \\in R $ such that there exists a polynomial $ P\\br{X} $ in $ I $ with leading coefficient $ a $. Then $ J $ is an ideal of $ R $.\n\\end{lemma}\n\n\\begin{proof}\nCertainly if $ a \\in J $ is the leading coefficient of $ P\\br{X} \\in I $ such that $ P\\br{X} = aX^n + \\dots $, then for any $ r \\in R $, $ ra $ is the leading coefficient of $ rP\\br{X} = raX^n + \\dots $, so $ ra \\in J $, so $ J $ is closed under multiplication. On the other hand, if $ a, b \\in J $ are the leading coefficients of $ P\\br{X} $ and $ Q\\br{X} $ in $ I $, then let $ n $ and $ m $ be the degrees of $ P\\br{X} = aX^n + \\dots $ and $ Q\\br{X} = bX^m + \\dots $ respectively. Without loss of generality we may assume $ n \\ge m $. Then $ a + b $ is the leading coefficient of $ P\\br{X} + X^{n - m}Q\\br{X} = \\br{a + b}X^{n + m} + \\dots $, and the latter polynomial is in $ I $ so $ a + b \\in J $. Thus $ J $ is closed under addition, and is therefore an ideal.\n\\end{proof}\n\nNow since $ R $ is Noetherian, $ J $ is finitely generated, say by $ a_1, \\dots, a_s \\in R $. By definition of $ J $, there are thus polynomials $ P_1, \\dots, P_s $ in $ I $, of degrees $ d_1, \\dots, d_n $, such that $ P_i = a_iX^{d_i} + \\dots $ has leading coefficient $ a_i $ for all $ i $. Let $ N $ be the largest of the $ d_i $.\n\n\\begin{lemma}\nGiven $ Q\\br{X} \\in I $ of degree $ d \\ge N $, then there exist $ R_1\\br{X}, \\dots, R_s\\br{X} \\in R\\sbr{X} $ such that $ Q\\br{X} - R_1\\br{X}P_1\\br{X} - \\dots - R_s\\br{X}P_s\\br{X} $ has degree less than $ N $.\n\\end{lemma}\n\n\\begin{proof}\nThe proof is by induction on $ d $ and the base case $ d < N $ is clear by setting $ R_i = 0 $ for all $ i $. Suppose the claim is true for polynomials of degree less than or equal to $ d - 1 $, with $ d \\ge N $. Let $ a \\in J $ be the leading coefficient of $ Q\\br{X} = aX^d + \\dots $, so that $ Q\\br{X} - aX^d $ has degree at most $ d - 1 $. Since $ a $ lies in $ J $ we can write $ a = r_1a_1 + \\dots + r_sa_s $. Then the leading term of the polynomial $ r_1X^{d - d_1}P_1\\br{X} + \\dots + r_sX^{d - d_s}P_s\\br{X} $ is $ aX^d $, so the difference $ Q\\br{X} - r_1X^{d - d_1}P_1\\br{X} - \\dots - r_sX^{d - d_s}P_s\\br{X} $ has degree at most $ d - 1 $ and lies in $ I $. By the inductive hypothesis this difference is an $ R\\sbr{X} $-linear combination of the $ P_i\\br{X} $. So $ Q\\br{X} $ is as well.\n\\end{proof}\n\n\\begin{proof}[Proof of Theorem \\ref{thm:9.1.1}]\nLet $ I $ be an ideal of $ R\\sbr{X} $. We want to show that $ I $ is finitely generated. Let $ I_{\\le N} = I \\cap R\\sbr{X}_{\\le N} $ be the subset of $ I $ consisting of all polynomials of degree at most $ N $. Then $ I_{\\le N} $ is an $ R $-submodule of the $ R $-module $ R\\sbr{X}_{\\le N} $ of all polynomials of degree at most $ N $. The latter is free of rank $ N + 1 $ and generated by $ 1, \\dots, X^N $ as an $ R $-module, so it is finitely generated, hence Noetherian. In particular since $ R $ is Noetherian $ I_{\\le N} $ is also a finitely generated $ R $-module. Let $ T_1\\br{X}, \\dots, T_k\\br{X} $ generate $ I_{\\le N} $ as an $ R $-module. We will show that\n$$ P_1\\br{X}, \\dots, P_s\\br{X}, T_1\\br{X}, \\dots, T_k\\br{X} $$\ngenerate $ I $ as an $ R\\sbr{X} $-module. More precisely, we will show that $ Q\\br{X} $ is an $ R\\sbr{X} $-linear combination of the $ P_i\\br{X} $ and $ T_j\\br{X} $. Given $ Q\\br{X} \\in I $, there exist $ R_1\\br{X}, \\dots, R_s\\br{X} \\in R\\sbr{X} $ such that\n$$ Q\\br{X} = R_1\\br{X}P_1\\br{X} + \\dots + R_s\\br{X}P_s\\br{X} + T\\br{X}, $$\nwith $ T\\br{X} \\in I_{\\le N} $. There exist $ r_1, \\dots, r_k \\in R $ such that $ T\\br{X} = r_1T_1\\br{X} + \\dots + r_kT_k\\br{X} $, so\n$$ Q\\br{X} = R_1\\br{X}P_1\\br{X} + \\dots + R_s\\br{X}P_s\\br{X} + r_1T_1\\br{X} + \\dots + r_kT_k\\br{X}. $$\n\\end{proof}\n\n\\pagebreak\n\nAs a corollary, we deduce the following.\n\n\\begin{corollary}\nLet $ R $ be any field or PID, or indeed any Noetherian ring. Then for any $ n $, the ring $ R\\sbr{X_1, \\dots, X_n} $ is Noetherian.\n\\end{corollary}\n\nAn observation is that if $ R $ is Noetherian and $ I \\subseteq R $ is an ideal, then $ R / I $ is Noetherian. Let $ J $ be an ideal of $ R / I $ and $ \\widetilde{J} $ be preimage of $ J $ in $ R $. There exist $ \\widetilde{j_1}, \\dots, \\widetilde{j_n} $ generating $ \\widetilde{J} $ over $ R $. Let $ j_i = \\widetilde{j_i} + I \\in R / I $. These lie in $ J $ and generate $ J $ over $ R / I $. In particular, any quotient of polynomial ring over a field or PID is Noetherian. Indeed, since any quotient of a Noetherian ring is Noetherian, we can say more.\n\n\\begin{definition}\nLet $ R $ be a ring. An \\textbf{$ R $-algebra} is a ring $ S $ together with a homomorphism $ f : R \\to S $. If $ S $ is an $ R $-algebra, we say that $ S $ is \\textbf{finitely generated} as an $ R $-algebra over $ R $ if there exists a finite set of elements $ s_1, \\dots, s_n \\in S $ such that every element of $ S $ can be expressed as a polynomial in the $ s_i $ with coefficients in $ R $. Equivalently, $ S $ is generated over $ R $ by $ s_1, \\dots, s_n $ if the homomorphism\n$$ \\function{R\\sbr{X_1, \\dots, X_n}}{S}{X_i}{s_i}, $$\nwhere $ f : R \\to S $ is surjective.\n\\end{definition}\n\n\\begin{note*}\nAny finitely generated $ R $-algebra $ S $ is isomorphic to a quotient $ R\\sbr{X_1, \\dots, X_n} / I $ for some $ n $ and some ideal $ I $. Thus we can rephrase the Hilbert basis theorem as saying that if $ R $ is Noetherian, then any finitely generated $ R $-algebra is Noetherian.\n\\end{note*}\n\n\\lecture{17}{Monday}{12/11/18}\n\nLecture 17 is a problems class.\n\n\\subsection{Polynomial rings over UFDs are UFDs}\n\n\\lecture{18}{Wednesday}{14/11/18}\n\nOur next goal is to study factorisation in polynomial rings of the form $ R\\sbr{X} $, since $ \\ZZ\\sbr{X} $ is not a PID nor a UFD. The idea is to relate factorisations in $ \\ZZ\\sbr{X} $ to factorisations in $ \\QQ\\sbr{X} $. A warning is that irreducibility in $ \\QQ\\sbr{X} $ does not imply irreducibility in $ \\ZZ\\sbr{X} $.\n\n\\begin{example*}\n$ 3x + 15 $ is irreducible in $ \\QQ\\sbr{X} $, and $ 3x + 15 = 3\\br{x + 15} $ in $ \\ZZ\\sbr{X} $.\n\\end{example*}\n\nCertainly if $ R $ is not a UFD then we cannot expect to have unique factorisation in $ R\\sbr{X} $, since we do not even have it in $ R $. Assume $ R $ is a UFD. Then the ring $ R\\sbr{X} $ might be quite complicated, but $ R\\sbr{X} $ is contained in a much simpler ring where we do understand factorisation, the ring $ K\\sbr{X} $, where $ K $ is the field of fractions of $ R $. Our goal will thus be to compare factorisations in $ K\\sbr{X} $ with factorisations in $ R\\sbr{X} $. Fundamental question is can we turn factorisations in $ K\\sbr{X} $ of $ P\\br{X} \\in R\\sbr{X} $ into factorisations in $ R\\sbr{X} $? The key to doing this is the following result, often called Gauss' lemma.\n\n\\begin{theorem}[Gauss' lemma]\n\\label{thm:9.2.1}\nLet $ R $ be a UFD and let $ K $ be its field of fractions. Let $ P\\br{X} \\in R\\sbr{X} $, and let $ Q\\br{X} $ be a polynomial in $ K\\sbr{X} $ that divides $ P\\br{X} $ in $ K\\sbr{X} $. Then there is an element $ \\alpha \\in K^* $ such that $ \\alpha Q\\sbr{X} $ lies in $ R\\sbr{X} $, and divides $ P\\br{X} $ in $ R\\sbr{X} $. In particular, if $ P\\br{X} $ is reducible in $ K\\sbr{X} $, then $ P\\br{X} $ is also reducible in $ R\\sbr{X} $.\n\\end{theorem}\n\n\\begin{proof}\nWrite $ P\\br{X} = Q\\br{X}T\\br{X} \\in K\\sbr{X} $, and choose nonzero elements $ e_1, e_2 \\in R $ such that $ e_1Q\\br{X} $ and $ e_2T\\br{X} $ have coefficients in $ R $, and so that the greatest common divisor of the coefficients of $ e_1Q\\br{X} $ is one, as is the greatest common divisor of the coefficients of $ e_2T\\br{X} $. Letting $ d = e_1e_2 $, we have\n$$ dP\\br{X} = Q'\\br{X}T'\\br{X}, \\qquad Q'\\br{X} = e_1Q\\br{X}, \\qquad T'\\br{X} = e_2T\\br{X}. $$\nSuppose $ d $ is not a unit in $ R $. Then $ d $ is divisible by an irreducible element $ q $ of $ R $. Since $ R $ is a UFD, irreducibles are prime, so the ideal of $ R $ generated by $ q $ is a prime ideal. Thus $ R / \\abr{q} $ is an integral domain, so $ R / \\abr{q}\\sbr{X} $ is as well. Moreover, if $ \\overline{Q'}\\br{X} $ and $ \\overline{T'}\\br{X} $ are the images of $ Q'\\br{X} $ and $ T'\\br{X} $ modulo $ \\abr{q} $ in $ R / \\abr{q}\\sbr{X} $, then we have $ dP\\br{X} = Q'\\br{X}T'\\br{X} $, so $ 0 = \\overline{Q'}\\br{X}\\overline{T'}\\br{X} $ in $ R / \\abr{q}\\sbr{X} $. Since $ R / \\abr{q}\\sbr{X} $ is an integral domain we must have either $ \\overline{Q'}\\br{X} = 0 $ or $ \\overline{T'}\\br{X} = 0 $ in $ R / \\abr{q}\\sbr{X} $. Without loss of generality assume $ \\overline{Q'}\\br{X} = 0 $. Then all the coefficients of $ Q'\\br{X} $ are divisible by $ q $, contradicting our construction of $ Q'\\br{X} $. Thus $ \\alpha = d $ is a unit in $ K\\sbr{X} $, and we have $ P\\br{X} = e_1Q\\br{X}\\br{e_2 / d}T\\br{X} $ for $ e_1Q\\br{X}, \\br{e_2 / d}T\\br{X} \\in R\\sbr{X} $.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{note*}\nThe converse to the last claim of Theorem \\ref{thm:9.2.1} is not true. If $ P\\br{X} $ is reducible in $ R\\sbr{X} $, it might be irreducible in $ K\\sbr{X} $.\n\\end{note*}\n\n\\begin{example*}\nThe polynomial $ 7x $ factors into irreducibles as $ 7 \\cdot x $ in $ \\ZZ\\sbr{X} $, but since $ 7 $ is a unit in $ \\QQ\\sbr{X} $, $ 7x $ is irreducible in $ \\QQ\\sbr{X} $.\n\\end{example*}\n\nThe following lemma shows that this kind of thing is all that can happen, however.\n\n\\begin{proposition}\nLet $ P\\br{X} $ in $ R\\sbr{X} $ be a polynomial and suppose that the greatest common divisor of all of its coefficients is one. Then $ P\\br{X} $ is irreducible in $ K\\sbr{X} $ if and only if it is also irreducible in $ R\\sbr{X} $.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ P\\br{X} $ is reducible in $ R\\sbr{X} $, and write $ P\\br{X} = Q\\br{X}T\\br{X} $ for $ Q\\br{X}, T\\br{X} \\in R\\sbr{X} $, where $ Q\\br{X} $ and $ T\\br{X} $ are nonunits. If $ Q\\br{X} $ or $ T\\br{X} $ were constant with degree zero then it would divide every coefficient of $ P\\br{X} $ and thus divide the GCD of those coefficients, making it a unit. Thus $ Q\\br{X} $ and $ T\\br{X} $ are nonconstant with positive degree and the factorisation $ P\\br{X} = Q\\br{X}T\\br{X} $ is also a nontrivial factorisation in $ K\\sbr{X} $, so $ P\\br{X} $ is reducible in $ K\\sbr{X} $. Conversely suppose $ P $ is reducible in $ K\\sbr{X} $. Then there exist $ Q\\br{X} \\in K\\sbr{X} $ with $ 0 < \\deg Q < \\deg P $ and $ Q\\br{X} \\mid P\\br{X} $ in $ K\\sbr{X} $. Gauss' lemma shows that there exist $ \\alpha \\in K^* $ such that $ \\alpha Q\\br{X} \\in R\\sbr{X} $ and $ \\alpha Q\\br{X} \\mid P\\br{X} $ in $ R\\sbr{X} $.\n\\end{proof}\n\nWe are now in a position to prove the following.\n\n\\begin{theorem}\nIf $ R $ is a UFD, then $ R\\sbr{X} $ is a UFD.\n\\end{theorem}\n\n\\begin{proof}\nFor existence of factorisations, let $ P\\br{X} $ be an element of $ R\\sbr{X} $. We must show that $ P\\br{X} $ factors into irreducibles. Let $ d $ be the greatest common divisor of the coefficients of $ P\\br{X} $, and write $ P\\br{X} = dQ\\br{X} $, where the greatest common divisor of the coefficients of $ Q\\br{X} $ is one. Since $ R $ is a UFD, $ d $ factors into irreducibles $ q_1, \\dots, q_s $ in $ R $, and these remain irreducible in $ R\\sbr{X} $, so it suffices to show that $ Q\\br{X} $ factors into irreducibles. Factoring $ Q\\br{X} $ into irreducibles in $ K\\sbr{X} $, $ Q\\br{X} = Q_1\\br{X} \\dots Q_r\\br{X} $. By Gauss' lemma, there exist scalars $ \\alpha_1, \\dots, \\alpha_r \\in K^* $ such that $ \\alpha_1 \\dots \\alpha_r = 1 $ and $ \\alpha_iQ_i\\br{X} \\in R\\sbr{X} $. Let $ Q'_i \\br{X} = \\alpha_iQ_i\\br{X} $. GCD of coefficients of $ Q'_1\\br{X}, \\dots, Q'_r\\br{X} $ is one, so $ Q'_1\\br{X}, \\dots, Q'_r\\br{X} $ are irreducible in $ R\\sbr{X} $ since they are irreducible in $ K\\sbr{X} $. For uniqueness of factorisations, it remains to show that if $ P\\br{X} \\in R\\sbr{X} $ is irreducible in $ R\\sbr{X} $ and divides $ A\\br{X}B\\br{X} $ in $ R\\sbr{X} $ for $ A\\br{X}, B\\br{X} \\in R\\sbr{X} $, then $ P\\br{X} $ divides either $ A\\br{X} $ or $ B\\br{X} $ in $ R\\sbr{X} $.\n\\begin{itemize}\n\\item If $ P\\br{X} $ is constant, then $ P\\br{X} = c $ is irreducible in $ R $. In $ R / \\abr{c}\\sbr{X} $ a domain, $ 0 = \\overline{A}\\br{X}\\overline{B}\\br{X} $, so $ \\overline{A}\\br{X} = 0 $ or $ \\overline{B}\\br{X} = 0 $, so $ c \\mid A\\br{X} $ or $ c \\mid B\\br{X} $.\n\\item If $ P\\br{X} $ is nonconstant, since $ P\\br{X} $ is irreducible in $ R\\sbr{X} $ it is irreducible in $ K\\sbr{X} $ by Gauss' lemma, and hence divides either $ A\\br{X} $ or $ B\\br{X} $ in $ K\\sbr{X} $. Suppose $ P\\br{X} $ divides $ A\\br{X} $ in $ K\\sbr{X} $. Then $ A\\br{X} = P\\br{X}Q\\br{X} $ in $ K\\sbr{X} $. Then there is an element $ \\alpha = r / s \\in K^* $ for $ r, s \\in R $ and $ r \\ne 0 $ such that $ \\alpha P\\br{X} \\in R\\sbr{X} $, $ \\alpha P\\br{X} \\mid A\\br{X} $, and $ A\\br{X} = \\alpha P\\br{X}\\alpha^{-1} Q\\br{X} \\in R\\sbr{X} $, by Gauss' lemma. On the other hand, since $ P\\br{X} $ is irreducible in $ R\\sbr{X} $ the GCD of its coefficients is one, so the only way $ \\alpha P\\br{X} $ lies in $ R\\sbr{X} $ is if $ s $ is a unit and $ \\alpha $ lies in $ R $. Thus $ \\alpha^{-1}Q\\br{X} \\in R\\sbr{X} $, $ \\alpha \\in R $, and $ P\\br{X} \\in R\\sbr{X} $, so $ P\\br{X} $ also divides $ A\\br{X} $.\n\\end{itemize}\n\\end{proof}\n\n\\begin{corollary}\nIf $ K $ is a UFD, a field, or a PID, then $ K\\sbr{X_1, \\dots, X_n} $ is a UFD for any $ n $.\n\\end{corollary}\n\nA warning is that quotients of UFDs are only rarely UFDs themselves.\n\n\\begin{example*}\n$ \\ZZ\\sbr{X} $ is a UFD, but $ \\ZZ\\sbr{X} / \\abr{X^2 + 5} = \\ZZ\\sbr{\\sqrt{-5}} $ is not a UFD.\n\\end{example*}\n\n\\subsection{Irreducible polynomials}\n\n\\lecture{19}{Friday}{16/11/18}\n\nA question is how can we test if $ P\\br{X} \\in K\\sbr{X} $ is irreducible? We will now use the results of the previous section to obtain criteria for proving polynomials are irreducible. We begin with some trivial observations.\n\n\\begin{lemma}\nLet $ K $ be any field, and $ P\\br{X} \\in K\\sbr{X} $ of degree two or three. Then $ P\\br{X} $ is irreducible if and only if $ P\\br{X} $ has no root in $ K $.\n\\end{lemma}\n\n\\begin{proof}\nAny nontrivial factor of $ P\\br{X} $ would have to have degree one or two. Either way, if $ P\\br{X} $ is reducible it must have a linear factor.\n\\end{proof}\n\n\\pagebreak\n\nSlightly less trivially, if $ K $ is finite there is a necessary and sufficient criterion for irreducibility. Let $ K = \\FF_q $ be a finite field with $ q = p^s $ elements.\n\n\\begin{lemma}\n$ X^{q^r} - X $ is the product of $ P\\br{X} \\in \\FF_q\\sbr{X} $ irreducible, monic of degree dividing $ r $.\n\\end{lemma}\n\n\\begin{proof}\nLet $ P\\br{X} $ be irreducible monic of degree $ d \\mid r $. Consider $ K\\br{\\alpha} $, where $ \\alpha $ is a root of $ P\\br{X} $. Thus $ K\\br{\\alpha} $ has order $ q^d $. So $ \\alpha^{q^d} = \\alpha $. Since $ d \\mid r $, $ \\alpha^{q^r} = \\alpha $. So $ \\alpha $ is a root of $ X^{q^r} - X $. But $ P\\br{X} $ is the minimal polynomial of $ \\alpha $, so $ P\\br{X} \\mid X^{q^r} - X $. Suppose $ P\\br{X}^2 \\mid X^{q^r} - X $. Write $ X^{q^r} - X = P\\br{X}^2Q\\br{X} $. Taking derivatives, $ -1 = 2P\\br{X}P'\\br{X}Q\\br{X} + P\\br{X}^2Q'\\br{X} $. Since $ P\\br{X} \\nmid -1 $, this is impossible. Finally, let $ P\\br{X} \\in K\\sbr{X} $ irreducible be a divisor of $ X^{q^r} - X $. Let $ K' = \\FF_{q^r} $ contain $ K $. Then $ X^{q^r} - X $ factors into linear factors over $ K' $. So there exists $ \\alpha \\in K' $ such that $ P\\br{\\alpha} = 0 $. Then $ P\\br{X} $ is the minimal polynomial of $ \\alpha $ over $ K $, so have an injection\n$$ \\function{K\\sbr{X} / \\abr{P\\br{X}}}{K'}{X}{\\alpha}. $$\nOrder of $ K\\sbr{X} / \\abr{P\\br{X}} $ is $ q^{\\deg P} $ and order of $ K' $ is $ q^r $, so $ q^r = \\br{q^{\\deg P}}^n $, so $ \\deg P \\mid r $.\n\\end{proof}\n\n\\begin{corollary}\nLet $ P\\br{X} $ in $ \\FF_q\\sbr{X} $ have degree $ d $. Then $ P\\br{X} $ is irreducible if and only if the greatest common divisor of $ P\\br{X} $ and $ X^{q^r} - X $ is one for all $ 1 \\le r < d $.\n\\end{corollary}\n\n\\begin{proof}\nIf the polynomial $ P\\br{X} $ is irreducible, it does not divide $ X^{q^r} - X $ for $ r < d $. Conversely, if $ P\\br{X} $ is reducible, there exists an irreducible polynomial $ Q\\br{X} $ of degree $ 0 < r < d $ such that $ Q\\br{X} \\mid P\\br{X} $, and then $ Q\\br{X} \\mid X^{q^r} - X $ in $ \\FF_q\\sbr{X} $.\n\\end{proof}\n\nHaving obtained a satisfactory criterion for finite fields, the next simplest case to look at this that of $ \\QQ\\sbr{X} $. This is already much more complicated. We will take advantage of the fact that $ \\ZZ\\sbr{X} $ lives inside $ \\QQ\\sbr{X} $. In fact, all of our tricks will work in the following more general situation. Let $ R $ be a UFD with field of fractions $ K $, and we consider polynomials over $ K\\sbr{X} $. As we have seen, irreducibility over $ K $ is closely related to irreducibility in $ R\\sbr{X} $. Let $ P\\br{X} $ be a polynomial in $ K\\sbr{X} $ and $ d = \\deg P $. We can multiply $ P\\br{X} $ by scalars without substantially changing its factorisation, so we can assume that $ P\\br{X} $ is monic. In general there might be denominators in the coefficients of $ P\\br{X} $, but note that for any $ r \\in R $, if\n$$ P\\br{X} = c_0 + \\dots + c_{d - 1}X^{d - 1} + X^d, $$\nthen define a polynomial $ Q_r\\br{X} $ by\n$$ Q_r\\br{X} = r^dP\\br{\\dfrac{X}{r}} = c_0r^d + \\dots + c_{d - 1}rX^{d - 1} + X^d. $$\nIt is easy to see that $ Q_r\\br{X} $ is irreducible in $ K\\sbr{X} $ if and only if $ P\\br{X} $ is. Moreover, we can choose $ r $ so that $ Q_r\\br{X} $ has coefficients in $ R $. We are thus reduced to the problem of deciding whether a monic polynomial with coefficients in $ R $ is irreducible in $ K\\sbr{X} $. Moreover, we have shown that such a polynomial $ Q_r\\br{X} $ is irreducible in $ K\\sbr{X} $ if and only if it is irreducible in $ R\\sbr{X} $. Therefore a question is given $ Q\\br{X} $ monic in $ R\\sbr{X} $, how can we prove or test irreducibility? We therefore get the following nice criterion for irreducibility.\n\n\\begin{proposition}\nLet $ Q\\br{X} $ be a monic polynomial in $ R\\sbr{X} $, and let $ \\ppp $ be a prime ideal of $ R $. Suppose that the modulo $ \\ppp $ reduction $ \\overline{Q}\\br{X} $ is irreducible in $ R / \\ppp\\sbr{X} $. Then $ Q\\br{X} $ is irreducible in $ R\\sbr{X} $.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ Q\\br{X} $ were reducible in $ R\\sbr{X} $. Since $ Q\\br{X} $ is monic, $ Q\\br{X} $ must factor as $ A\\br{X}B\\br{X} $, where both $ A\\br{X} $ and $ B\\br{X} $ are not units. Can assume $ A\\br{X} $ and $ B\\br{X} $ are monic of degree $ \\deg A > 0 $ and $ \\deg B > 0 $, since leading coefficients of $ A $ and $ B $ multiply to one. Then $ \\overline{Q}\\br{X} $ factors in $ R / \\ppp\\sbr{X} $ as $ \\overline{A}\\br{X}\\overline{B}\\br{X} $, where both are monic of positive degree between one and $ \\deg \\overline{Q}\\br{X} - 1 $, so $ \\overline{Q}\\br{X} $ is also reducible.\n\\end{proof}\n\nThis means, for instance, that we can show that a monic polynomial in $ \\ZZ\\sbr{X} $ is irreducible if we can find even one prime $ p $ for which it is irreducible modulo $ p $.\n\n\\begin{example*}\n$ X^2 + aX + b \\in \\ZZ\\sbr{X} $ with $ a $ and $ b $ odd is irreducible in $ \\QQ\\sbr{X} $, since its reduction modulo two is $ X^2 + X + 1 $, which is irreducible in $ \\FF_2\\sbr{X} $.\n\\end{example*}\n\n\\pagebreak\n\nUnfortunately, even when the polynomial is irreducible we will not always be able to do this.\n\n\\begin{example*}\nThe polynomial $ X^4 + 1 $ is irreducible in $ \\ZZ\\sbr{X} $ and $ \\QQ\\sbr{X} $, but reducible modulo $ p $ for every $ p $. You can prove this with some elementary number theory. Since $ X^4 + 1 = \\br{X + 1}^4 $ in $ \\FF_2\\sbr{X} $, if $ p $ is odd, then $ X^4 + 1 $ has a common factor, and in fact divides $ X^{p^2} - X $. In fact $ X^4 + 1 \\mid X^{p^2 - 1} - 1 $. If $ p = 2k + 1 $, then $ p^2 = 4k^2 + 4k + 1 = 4\\br{k^2 + k} + 1 = 8m + 1 $, since $ k^2 + k $ is even, so\n$$ X^{p^2 - 1} - 1 = X^{8m} - 1 = \\br{X^4 + 1}\\br{X^{8m - 4} - \\dots - 1}. $$\n\\end{example*}\n\nThere is another sufficient criterion for irreducibility by reducing modulo $ \\ppp $, known as Eisenstein's criterion.\n\n\\begin{proposition}[Eisenstein's criterion]\nLet $ Q\\br{X} = a_0 + \\dots + a_{n - 1}X^{n - 1} + X^n $ be a monic polynomial in $ R\\sbr{X} $, and let $ \\ppp $ be a prime ideal of $ R $. Suppose that for $ 0 \\le i \\le n - 1 $, $ a_i \\in \\ppp $, and $ a_0 \\notin \\ppp^2 $. Then $ Q\\br{X} $ is irreducible in $ R\\sbr{X} $.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ Q\\br{X} $ is reducible. Then we can write $ Q\\br{X} = A\\br{X}B\\br{X} \\in R\\sbr{X} $, with $ A\\br{X} $ and $ B\\br{X} $ monic of positive degree less than $ \\deg Q\\br{X} $. Reducing modulo $ \\ppp $ we find that $ \\overline{Q}\\br{X} = X^n = \\overline{A}\\br{X}\\overline{B}\\br{X} \\in R / \\ppp\\sbr{X} $. In particular, since $ R / \\ppp $ is an integral domain, one of $ \\overline{A}\\br{0} $ or $ \\overline{B}\\br{0} $ is zero, say $ \\overline{A}\\br{0} = 0 $. Write $ \\overline{A}\\br{X} = X^d\\overline{S}\\br{X} $ for $ \\overline{S}\\br{0} \\ne 0 $. Degree $ d $ term of $ \\overline{A}\\br{X}\\overline{B}\\br{X} $ is $ \\overline{S}\\br{0}\\overline{B}\\br{0} $. Then $ d < n $, so $ \\overline{S}\\br{0}\\overline{B}\\br{0} = 0 $. So $ \\overline{B}\\br{0} = 0 $, so both $ \\overline{A}\\br{0} = \\overline{B}\\br{0} = 0 $. But then the constant terms $ A\\br{0} $ and $ B\\br{0} $ of $ A\\br{X} $ and $ B\\br{X} $ both lie in $ \\ppp $, so the constant term $ a_0 = Q\\br{0} = A\\br{0}B\\br{0} $ of $ Q\\br{X} = A\\br{X}B\\br{X} $ must lie in $ \\ppp^2 $, contradicting our assumptions.\n\\end{proof}\n\n\\begin{corollary}\n$ X^4 + 1 $ is irreducible.\n\\end{corollary}\n\n\\begin{proof}\n$ X^4 + 1 $ is irreducible if and only if $ \\br{X + 1}^4 + 1 $ is irreducible, and\n$$ \\br{X + 1}^4 + 1 = X^4 + 4X^3 + 6X^4 + 4X^2 + 2 $$\nsatisfies Eisenstein's criterion modulo $ 2 $.\n\\end{proof}\n\n\\lecture{20}{Monday}{19/11/18}\n\n\\begin{example*}\nLet $ F\\sbr{X, Y, Z} $ for $ F $ a field be a polynomial ring, such as $ \\ZZ\\sbr{X, Y, Z} $. Can write\n$$ F\\sbr{X, Y, Z} = F\\sbr{X, Y}\\sbr{Z}, \\qquad R = F\\sbr{X, Y}, $$\nor\n$$ F\\sbr{X, Y, Z} = F\\sbr{X, Z}\\sbr{Y} = F\\sbr{Y, Z}\\sbr{X}. $$\nCan also think of\n$$ F\\br{X, Y, Z} \\subseteq F\\br{X}\\sbr{Y, Z} = F\\br{X}\\sbr{Y}\\sbr{Z}, \\qquad R = F\\br{X}\\sbr{Y}. $$\n\\begin{itemize}\n\\item Let\n$$ P\\br{X, Y} = X^4 + X^2Y^2 + Y^2 + XY \\in \\CC\\sbr{X, Y}. $$\nTake $ R = \\CC\\sbr{X} $ and $ K = \\CC\\br{X} $. Then\n$$ P\\br{X, Y} = \\br{X^2 + 1}Y^2 + X \\cdot Y + X^4 $$\nis quadratic in $ Y $ with coefficients in $ R $. The GCD of the coefficients is one, so it is irreducible if and only if it is irreducible in $ K\\sbr{Y} $, if and only if it has no root in $ K $, if and only if its discriminant is not a square in $ K $. The discriminant is\n$$ X^2 - 4X^4\\br{X^2 + 1} = X^2 - 4X^6 - 4X^4 = X^2\\br{1 - 4X^4 - 4X^2}, $$\nwhich is not a square, so $ P\\br{X, Y} $ is irreducible.\n\\item Let\n$$ P\\br{X, Y, Z} = Z^5 + X^3Y^4Z + 2X^2YZ^3 - XYZ + Y^3 \\in \\CC\\sbr{X, Y}\\sbr{Z}. $$\nIt is irreducible if it is irreducible modulo $ X $. Then\n$$ \\overline{P}\\br{Y, Z} = Z^5 + Y^3 \\in \\CC\\sbr{Z}\\sbr{Y} $$\nis irreducible if and only if it is irreducible in $ \\CC\\br{Z}\\sbr{Y} $, if and only if it has no root, if and only if $ -Z^5 $ is not a cube in $ \\CC\\br{Z} $, if and only if $ -Z^5 $ is not a cube in $ \\CC\\sbr{Z} $, which is clear from unique factorisation.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\n\\section{Integral extensions and algebraic integers}\n\n\\subsection{Integral extensions}\n\n\\begin{definition}\n$ \\alpha \\in \\CC $ is an \\textbf{algebraic integer} if there exists a monic polynomial $ P\\br{X} \\in \\ZZ\\sbr{X} $ such that $ P\\br{\\alpha} = 0 $.\n\\end{definition}\n\n\\begin{note*}\nIf $ Q\\br{X} $ is the minimal polynomial of $ \\alpha $ over $ \\QQ $, monic, then $ Q\\br{X} \\mid P\\br{X} $. By Gauss' lemma, there exists $ \\alpha \\in \\QQ^* $ such that $ \\alpha Q\\br{X} \\in \\ZZ\\sbr{X} $ and $ \\alpha Q\\br{X} \\mid P\\br{X} $ in $ \\ZZ\\sbr{X} $. Since $ Q\\br{X} $ is monic, $ \\alpha \\in \\ZZ $. Since $ P\\br{X} $ is monic, $ \\alpha \\mid 1 $. So $ \\alpha = \\pm 1 $ and $ Q\\br{X} \\in \\ZZ\\sbr{X} $.\n\\end{note*}\n\n\\begin{definition}\nLet $ R $ be a subring of a ring $ S $, and $ \\alpha $ an element of $ S $. We say $ \\alpha $ is \\textbf{integral} over $ R $ if there exists a monic polynomial $ P\\br{X} \\in R\\sbr{X} $ with coefficients in $ R $ such that $ P\\br{\\alpha} = 0 $ in $ S $.\n\\end{definition}\n\nWe can characterise integral elements in the following way.\n\n\\begin{proposition}\nAn element $ \\alpha \\in S $ is integral over $ R $ if and only if the subring $ R\\sbr{\\alpha} $ of $ S $ is a finitely generated $ R $-module.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ \\alpha $ is integral over $ R $, so that there exists a monic polynomial $ P\\br{X} $ in $ R\\sbr{X} $ with $ P\\br{\\alpha} = 0 $. Then $ R\\sbr{\\alpha} $ is a quotient of $ R\\sbr{X} / \\abr{P\\br{X}} $ so $ 1, \\dots, \\alpha^{d - 1} $, where $ d $ is the degree of $ P\\br{X} $, span $ R\\sbr{\\alpha} $ over $ R $. Given $ x \\in R\\sbr{\\alpha} $, can write $ x = Q\\br{\\alpha} = r_{d - 1}\\alpha^{d - 1} + \\dots + r_0 $. Write $ Q\\br{X} = P\\br{X}T\\br{X} + A\\br{X} \\in R\\sbr{X} $ for $ \\deg A\\br{X} < d $, so $ Q\\br{\\alpha} = P\\br{\\alpha}T\\br{\\alpha} + A\\br{\\alpha} $. Let $ A\\br{X} = a_0 + \\dots + a_{d - 1}X^{d - 1} $ for $ a_i \\in R $, so $ x = Q\\br{\\alpha} = A\\br{\\alpha} = a_0 + \\dots + a_{d - 1}\\alpha^{d - 1} $. Conversely, if $ R\\sbr{\\alpha} $ is finitely generated as an $ R $-module, say by $ x_1, \\dots, x_r \\in R\\sbr{\\alpha} $, we can write $ x_i = Q_i\\br{\\alpha} $ for $ Q_i\\br{X} \\in R\\sbr{X} $. Let $ n $ be larger than the degree $ d_i $ of all the $ Q_i\\br{X} $. We can write $ \\alpha^n \\in R\\sbr{\\alpha} $ as $ \\sum_{i = 1}^r s_ix_i = \\sum_{i = 1}^r s_iQ_i\\br{\\alpha} $ for $ s_i \\in R $. So let $ P\\br{X} = X^n - \\sum_{i = 1}^r s_iQ_i\\br{X} \\in R\\sbr{X} $. Then $ P\\br{X} $ is a monic polynomial with coefficients in $ R $ such that $ P\\br{\\alpha} = 0 $.\n\\end{proof}\n\n\\begin{definition}\nLet $ R $ be a subring of $ S $. We say that $ S $ is integral over $ R $ if every element of $ S $ is integral over $ R $.\n\\end{definition}\n\n\\begin{proposition}\nSuppose $ R $ is a Noetherian ring, and $ S $ is a ring containing $ R $ that is finitely generated as an $ R $-module. Then $ S $ is a Noetherian ring and is integral over $ R $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha \\in S $. The ring $ R\\sbr{\\alpha} $ is an $ R $-submodule of $ S $, so it is finitely generated as an $ R $-module, so $ \\alpha $ is integral over $ R $. Every ideal of $ S $ is an $ R $-submodule of $ S $, thus finitely generated as an $ R $-module since $ R $ is Noetherian, and hence also finitely generated as an $ S $-module, so $ S $ is a Noetherian ring.\n\\end{proof}\n\n\\begin{lemma}\n\\label{lem:10.1.6}\nLet $ R \\subseteq S \\subseteq T $ be rings, such that $ S $ is finitely generated as an $ R $-module and $ T $ is finitely generated as an $ S $-module. Then $ T $ is finitely generated as an $ R $-module.\n\\end{lemma}\n\n\\begin{proof}\nLet $ t_1, \\dots, t_l $ generate $ T $ over $ S $, and let $ s_1, \\dots, s_m $ generate $ S $ over $ R $. Then for any element $ t $ of $ T $, we can write $ t = \\sum_{i = 1}^l a_it_i $ for $ a_i \\in S $. We can further write $ a_i = \\sum_{j = 1}^m b_{ji}s_j $ for $ b_{ji} \\in R $, so that $ t = \\sum_{i = 1}^l \\sum_{j = 1}^m b_{ji}s_jt_i $, so that $ T $ is generated over $ R $ by the elements $ s_it_j $.\n\\end{proof}\n\n\\begin{corollary}\nLet $ R \\subseteq S \\subseteq T $, with $ R $ Noetherian. If $ T $ is integral over $ S $ and $ S $ is integral over $ R $, then $ T $ is integral over $ R $.\n\\end{corollary}\n\n\\begin{proof}\nLet $ t \\in T $. Then $ t $ satisfies a polynomial $ P\\br{X} = X^n + s_{n - 1}X^{n - 1} + \\dots + s_0 \\in S\\sbr{X} $ for $ s_i \\in S $ such that $ P\\br{t} = 0 $. Consider the subring $ S' = R\\sbr{s_0, \\dots, s_{n - 1}} \\subseteq S $. Since each $ s_i $ is integral over $ R $, $ s_0 $ is in particular integral over $ R $ and $ s_i $ is integral over $ R\\sbr{s_0, \\dots, s_{i - 1}} $. Thus $ R\\sbr{s_0} $ is a finitely generated $ R $-module and $ R\\sbr{s_0, \\dots, s_i} $ is a finitely generated $ R\\sbr{s_0, \\dots, s_{i - 1}} $-module for each $ i $ by induction. By Lemma \\ref{lem:10.1.6} above, $ S' $ is a finitely generated $ R $-module. Since $ t $ is integral over $ S' $, $ S'\\sbr{t} $ is a finitely generated $ S' $-module, and hence a finitely generated $ R $-module by Lemma \\ref{lem:10.1.6}. Since $ R\\sbr{t} $ is contained in $ S'\\sbr{t} $ and $ R $ is a Noetherian ring, $ R\\sbr{t} $ is a finitely generated $ R $-module and thus $ t $ is integral over $ R $.\n\\end{proof}\n\n\\begin{corollary}\nLet $ R $ be a Noetherian subring of $ S $ and suppose $ \\alpha, \\beta \\in S $ are integral over $ R $. Then $ \\alpha\\beta $ and $ \\alpha + \\beta $ are integral over $ R $.\n\\end{corollary}\n\n\\begin{proof}\nThe ring $ R\\sbr{\\alpha} $ is a finitely generated $ R $-module and thus integral over $ R $. Since $ \\beta $ is integral over $ R $ it is integral over $ R\\sbr{\\alpha} $. Thus $ R\\sbr{\\alpha, \\beta} = R\\sbr{\\alpha}\\sbr{\\beta} $ is integral over $ R\\sbr{\\alpha} $ and hence over $ R $ by Lemma \\ref{lem:10.1.6}. Since $ \\alpha + \\beta $ and $ \\alpha\\beta $ lie in $ R\\sbr{\\alpha, \\beta} $ they are integral over $ R $.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{definition}\nLet $ R $ be a Noetherian subring of $ S $. The \\textbf{integral closure} of $ R $ in $ S $ is the subset of $ S $ consisting of all elements $ s \\in S $ that are integral over $ R $. This is a subring of $ R $. We say that $ R $ is \\textbf{integrally closed} in $ S $ if every element in $ S $ that is integral over $ R $ is contained in $ R $, so $ R $ is equal to its integral closure in $ S $. If $ R $ is an integral domain, we say that $ R $ is \\textbf{integrally closed} if $ R $ is integrally closed in its field of fractions $ K $.\n\\end{definition}\n\n\\lecture{21}{Wednesday}{21/11/18}\n\n\\begin{lemma}\nLet $ R $ be a Noetherian subring of $ S $, and let $ R' $ be the integral closure of $ R $ in $ S $. Then $ R' $ is integrally closed in $ S $.\n\\end{lemma}\n\n\\begin{proof}\nLet $ t $ be an element of $ R $ integral over $ R' $. Then $ R'\\sbr{t} $ is a finitely generated $ R' $-module, so is integral over $ R' $, and $ R' $ is integral over $ R $. Thus $ R'\\sbr{t} $ is integral over $ R $, so $ t $ is integral over $ R $ and thus $ t \\in R' $.\n\\end{proof}\n\n\\begin{example*}\n$ \\ZZ\\sbr{\\sqrt{-3}} $ is integral over $ \\ZZ $. As a $ \\ZZ $-module, $ \\ZZ\\sbr{\\sqrt{-3}} $ is generated by $ 1 $ and $ \\sqrt{-3} $. It is not integrally closed, since $ \\tfrac{1 + \\sqrt{-3}}{2} $ is in the field of fractions of $ \\ZZ\\sbr{\\sqrt{-3}} $ and is a root of $ X^2 - X + 1 $.\n\\end{example*}\n\n\\begin{theorem}\nLet $ R $ be a UFD. Then $ R $ is integrally closed.\n\\end{theorem}\n\n\\begin{proof}\nLet $ K $ be the field of fractions of $ R $, and suppose $ \\alpha \\in K $ is integral over $ R $. Want $ \\alpha \\in R $. Then there exists a monic polynomial $ P\\br{X} $ in $ R\\sbr{X} $ with coefficients in $ R $ such that $ P\\br{\\alpha} = 0 $. Then $ \\br{X - \\alpha} $ is an element of $ K\\sbr{X} $ dividing $ P\\br{X} $. By Gauss' lemma there is a $ \\lambda \\in K^* $ such that $ \\lambda\\br{X - \\alpha} $ is in $ R\\sbr{X} $ and divides $ P\\br{X} $ in $ R\\sbr{X} $. Clearly $ \\lambda $ must lie in $ R $, and on the other hand divide the leading coefficient of $ P\\br{X} $, which is one. Thus $ \\lambda \\in R^\\times $ is a unit, so since $ \\br{X - \\alpha} \\in R\\sbr{X} $ we must have $ \\alpha \\in R $.\n\\end{proof}\n\nThis suggests to number theorists to take an extension $ K / \\QQ $ finite, and let $ \\OOO_K $, the ring of integers of $ K $, be the integral closure of $ \\ZZ $ in $ K $. We now focus on a specific class of examples. Let $ d \\in \\ZZ $ be squarefree and let $ K = \\QQ\\br{\\sqrt{d}} $. This is precisely the set of elements of $ K $ that are integral over $ \\ZZ $. That is, that satisfy a monic polynomial with integral coefficients. What is $ \\OOO_K $? Every element of $ K $ is of the form $ a + b\\sqrt{d} $ for $ a, b \\in \\QQ $. A question is when is this an algebraic integer? Need the minimal polynomial of $ a + b\\sqrt{d} $ to have integer coefficients. We have the following lemma.\n\n\\begin{lemma}\nLet $ \\alpha \\in K $ and suppose $ \\alpha $ is integral over $ \\ZZ $. Then the minimal polynomial of $ \\alpha $, taken to be monic, has integer coefficients.\n\\end{lemma}\n\n\\begin{proof}\nLet $ Q\\br{X} $ be the minimal polynomial of $ \\alpha $, normalised so it is monic. Since $ \\alpha $ is integral over $ \\ZZ $, there is a monic polynomial $ P\\br{X} $, with integer coefficients, such that $ P\\br{\\alpha} = 0 $. Then $ Q\\br{X} $ divides $ P\\br{X} $ in $ \\QQ\\sbr{X} $. By Gauss' lemma, there exists $ \\beta \\in \\QQ^* $ such that $ \\beta Q\\br{X} $ has integer coefficients and divides $ P\\br{X} $ in $ \\ZZ\\sbr{X} $. Since $ Q\\br{X} $ is monic, $ \\beta $ lies in $ \\ZZ $. Since $ \\beta Q\\br{X} $ divides $ P\\br{X} $ we see that $ \\beta $ divides one, by comparing leading coefficients, so $ \\beta $ is a unit and $ Q\\br{X} $ lies in $ \\ZZ\\sbr{X} $.\n\\end{proof}\n\nLet $ \\alpha = a + b\\sqrt{d} $ with $ a, b \\in \\QQ $. Then the minimal polynomial of $ \\alpha $ over $ \\QQ $ is $ X^2 - 2aX + \\br{a^2 - b^2d} $. Thus $ \\alpha $ is an algebraic integer if and only if $ 2a, a^2 - b^2d \\in \\ZZ $.\n\\begin{itemize}\n\\item Suppose this is the case, and that $ a \\in \\ZZ $. Then $ b^2d \\in \\ZZ $. Suppose $ b \\notin \\ZZ $. There exists a prime $ p $ dividing the denominator of $ b $. Since $ b^2d \\in \\ZZ $ must have $ p^2 \\mid d $ but we took $ d $ squarefree. So $ b \\in \\ZZ $.\n\\item On the other hand, suppose that $ a = m / 2 $ where $ m $ is odd. Then if $ a^2 - b^2d \\in \\ZZ $ we have $ m^2 / 4 - b^2d \\in \\ZZ $ and so $ m^2 - 4b^2d $ is a multiple of four. So $ 4b^2d = x $ where $ m^2 - x \\in \\ZZ $ is a multiple of four. Since $ \\br{2k + 1}^2 = 4k^2 + 4k + 1 \\equiv 1 \\mod 4 $, so $ m^2 \\equiv 1 \\mod 4 $, this can only happen if $ d $ is odd and $ b = n / 2 $ with $ n $ odd. We then have $ m^2 - n^2d $ is a multiple of four. Since $ m^2, n^2 \\in \\ZZ $ are odd they are congruent to $ 1 \\mod 4 $, so this is only possible if $ d $ is congruent to $ 1 \\mod 4 $.\n\\end{itemize}\nThus if $ \\alpha $ is an algebraic integer, either $ \\alpha = a + b\\sqrt{d} $ with $ a, b \\in \\ZZ $, or $ \\alpha = \\tfrac{m + n\\sqrt{d}}{2} $ with $ m, n \\in \\ZZ $ odd and $ d $ congruent to $ 1 \\mod 4 $. Conversely, it is easy to check that all such elements are algebraic integers, so\n$$ \\OOO_{\\QQ\\br{\\sqrt{d}}} =\n\\begin{cases}\n\\ZZ\\sbr{\\sqrt{d}} = \\cbr{a + b\\sqrt{d} \\st a, b \\in \\ZZ} & d \\equiv 2, 3 \\mod 4 \\\\\n\\ZZ\\sbr{\\tfrac{1 + \\sqrt{d}}{2}} = \\cbr{\\tfrac{m + n\\sqrt{d}}{2} \\st n, m \\in \\ZZ, \\ n \\equiv m \\mod 2} & d \\equiv 1 \\mod 4\n\\end{cases}.\n$$\n\n\\begin{note*}\nThe results in this section are also true without any Noetherian hypotheses, but the proofs are more difficult, and require machinery we have not covered.\n\\end{note*}\n\n\\pagebreak\n\n\\section{Dedekind domains}\n\n\\subsection{Dedekind domains}\n\n\\lecture{22}{Friday}{23/11/18}\n\nFor number theorists, it is often convenient to work in a ring of the form $ \\ZZ\\sbr{\\alpha} $, where $ \\alpha \\in \\CC $ is an algebraic integer, or more generally in some subring $ \\OOO $ of $ \\CC $ that is integral over $ \\ZZ $. Unfortunately, unique factorisation only rarely holds in such rings. If $ \\OOO $ is integrally closed, however, there is a substitute for unique factorisation that is often good enough, unique factorisation of ideals. In this section we develop the ideas behind this result, in the more general context of what are called Dedekind domains.\n\n\\begin{definition}\nAn integral domain $ R $ is called a \\textbf{Dedekind domain} if\n\\begin{itemize}\n\\item $ R $ is Noetherian,\n\\item $ R $ is integrally closed, and\n\\item every nonzero prime ideal of $ R $ is maximal, so $ R $ has \\textbf{dimension one}.\n\\end{itemize}\n\\end{definition}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item In particular, any PID is a Dedekind domain. We have seen that every nonzero prime ideal is maximal in a PID, and PIDs are certainly Noetherian. They are integrally closed because any UFD is integrally closed.\n\\item The rings $ \\OOO_K $, the integral closure of $ \\ZZ $ in $ K $, with $ K $ a quadratic extension of $ \\QQ $ are\n$$ \\OOO_K =\n\\begin{cases}\n\\ZZ\\sbr{\\sqrt{d}} & d \\equiv 2, 3 \\mod 4 \\\\\n\\ZZ\\sbr{\\tfrac{1 + \\sqrt{d}}{2}} & d \\equiv 1 \\mod 4\n\\end{cases}.\n$$\n$ \\OOO_K \\subseteq K $ is an integral domain, is finitely generated by a single element as a $ \\ZZ $-algebra and thus Noetherian, and is also integrally closed. We proved on example sheet $ 2 $ that $ \\ZZ\\sbr{X} / \\abr{P\\br{X}} $ for $ P\\br{X} $ monic and irreducible with coefficients in $ \\ZZ $ has dimension one, that is every nonzero prime of such a ring is maximal.\n\\end{itemize}\n\\end{example*}\n\nMore generally, we have the following.\n\n\\begin{theorem}\nLet $ R $ be a PID with field of fractions $ K $, and let $ L $ be a finite extension of $ K $. Let $ S $ be the integral closure of $ R $ in $ L $. Then $ S $ is a Dedekind domain.\n\\end{theorem}\n\nWe will prove this later in the course, under a mild additional hypothesis on the extension $ L / K $. In particular, let $ R = \\ZZ $ and $ K = \\QQ $. The ring of integers $ \\OOO_L $ in $ L / \\QQ $ a finite extension is a Dedekind domain. Also in particular let $ R = F\\sbr{X} $ for $ F $ a field, $ K = F\\br{X} $, and $ L / K $ finite. The integral closure of $ R $ in $ K $ is also Dedekind.\n\n\\begin{example*}\n$ K\\sbr{X, Y} / \\abr{Y^2 - X^3 - aX - b} $, where $ X^3 + aX + b $ is a squarefree polynomial in $ K\\sbr{X, Y} $.\n\\end{example*}\n\nThe reason Dedekind domains are interesting to us is that the nonzero ideals in a Dedekind domain factor uniquely as products of prime ideals. The idea to study factorisation of ideals into prime ideals comes from the following observation.\n\n\\begin{lemma}\n\\label{lem:11.1.3}\nLet $ \\ppp $ be a prime ideal of any ring $ R $, let $ I, J \\subseteq R $ be ideals, and suppose that $ \\ppp $ contains $ IJ $. Then either $ \\ppp $ contains $ I $ or $ \\ppp $ contains $ J $.\n\\end{lemma}\n\n\\begin{proof}\nSuppose that $ \\ppp $ does not contains $ I $, and fix an $ r \\in I $ such that $ r $ is not in $ \\ppp $. Then for all $ s \\in J $, the product $ rs $ lies in $ IJ $ and hence in $ \\ppp $. Since $ r $ does not lie in $ \\ppp $, and $ \\ppp $ is prime, we must have $ s \\in \\ppp $.\n\\end{proof}\n\nNote the resemblance of this to the property, $ p \\mid ab $ implies $ p \\mid a $ or $ p \\mid b $ for $ p $ irreducible, which holds in UFDs and implies unique factorisation. We might hope that the above result thus implies unique factorisation into primes for arbitrary rings, but this is too much to ask for. The problem is that ideal multiplication is usually badly behaved compared to multiplication of elements in integral domains. Recall that for $ I, J \\subseteq R $ ideals, $ IJ $ is the ideal generated by all elements of the form $ rs $ for $ r \\in I $ and $ s \\in J $. In particular if $ r_1, \\dots, r_n $ generate $ I $ and $ s_1, \\dots, s_m $ generate $ J $ then $ r_1s_1, \\dots, r_1s_m, \\dots, r_ns_1, \\dots, r_ns_m $ generate $ IJ $.\n\n\\pagebreak\n\n\\begin{example*}\n$ R = \\ZZ\\sbr{\\sqrt{-3}} $ is not a Dedekind domain, since it fails to be integrally closed. Then the ideal $ I = \\abr{2, 1 + \\sqrt{-3}} $ is prime, and we have\n$$ \\abr{2, 1 + \\sqrt{-3}}^2 = \\abr{4, 2 + 2\\sqrt{-3}, -2 + 2\\sqrt{-3}} = \\abr{4, 2 + 2\\sqrt{-3}}. $$\nThere is thus a chain of inclusions $ I \\supsetneq \\abr{2} \\supsetneq I^2 $, so the ideal $ \\abr{2} $ is not a product of prime ideals. Worse is $ I^2 = \\abr{2}I $ but $ I \\ne \\abr{2} $, so cannot cancel ideals.\n\\end{example*}\n\nDedekind domains give precisely the context where this does not happen. In order to make this precise, we first define the following.\n\n\\begin{definition}\nLet $ R $ be a Noetherian integral domain. A \\textbf{fractional ideal} of $ R $ is a finitely generated nonzero $ R $-submodule of the field of fractions $ K $ of $ R $. A \\textbf{principal fractional ideal} is an $ R $-submodule $ R \\cdot x \\subseteq K $ of $ K $ finitely generated by a single nonzero element $ x $ for $ x \\in K^* $.\n\\end{definition}\n\n\\begin{example*}\nThe subgroup of $ \\QQ $ generated by $ \\tfrac{3}{5} $ is a principal fractional ideal of $ \\ZZ $. Indeed, every fractional ideal of $ \\ZZ $, or any PID, is principal.\n\\end{example*}\n\nMore generally, let $ R $ be a Noetherian integral domain, and let $ I $ be the $ R $-submodule of $ K $ generated by $ r_1, \\dots, r_n \\in K $. Then by definition $ I $ is a fractional ideal of $ R $. On the other hand, we can clear denominators. There exists an $ r \\in R $, nonzero, such that $ rr_i $ lies in $ R $ for all $ i $. Then $ rI $ is generated by elements of $ R $, so is an ideal $ J $ of $ R $, and $ I = \\tfrac{1}{r}J $. Thus the fractional ideals of $ R $ are precisely the subsets of $ K $ of the form $ \\tfrac{1}{r}J $, where $ r $ is a nonzero element of $ R $ and $ J $ is an ideal of $ R $. Let $ I $ and $ J $ be fractional ideals of $ R $. The product $ IJ $ is the $ R $-submodule of $ K $ generated by all products of the form $ rs $ for $ r \\in I $ and $ s \\in J $. It is a fractional ideal of $ R $. The multiplication $ I, J \\mapsto IJ $ is an associative and commutative operation. $ R $ is a fractional ideal of $ R $, and $ RJ = J $ for any fractional ideal $ J $, so $ R $ is an identity element for this operation. For a nonzero ideal $ I $ of $ R $, let $ I^{-1} $ denote the set\n$$ \\cbr{r \\in K \\st rI \\subseteq R}. $$\nThen $ I^{-1} $ is clearly an $ R $-submodule of $ K $. If $ r \\in I $ is nonzero, then $ rI^{-1} $, by definition, is contained in $ R $, so $ I^{-1} $ is contained in $ \\tfrac{1}{r} \\cdot R $ and is thus a fractional ideal. A warning is that in a general ring, $ I \\mapsto I^{-1} $ is not always a good inverse operation, since $ II^{-1} \\subseteq R $ but need not equal $ R $. For a prime ideal $ \\ppp $ of $ R $, and $ n \\in \\ZZ_{> 0} $, define $ \\ppp^{-n} = \\br{\\ppp^{-1}}^n $. We then have the following.\n\n\\begin{theorem}\nLet $ R $ be a Dedekind domain. Then\n\\begin{itemize}\n\\item the set of fractional ideals of $ R $ form a group under multiplication $ I, J \\mapsto IJ $, identity $ R $, and inverse $ I \\mapsto I^{-1} $, and\n\\item moreover, any fractional ideal $ I $ of $ R $ factors uniquely as $ \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} $ for $ n_i \\in \\ZZ $, where the $ \\ppp_i $ are nonzero prime ideals.\n\\end{itemize}\n\\end{theorem}\n\n\\lecture{23}{Monday}{26/11/18}\n\nThe proof of this statement will occur in several steps. We first show the following.\n\n\\begin{proposition}\nLet $ I $ be a nonzero ideal of a Noetherian ring $ R $. Then there exist nonzero primes $ \\ppp_1, \\dots, \\ppp_r $ and $ n_1, \\dots, n_r \\in \\ZZ_{> 0} $ such that $ I $ contains $ \\ppp_1^{n_1} \\dots \\ppp_r^{n_r} $.\n\\end{proposition}\n\n\\begin{proof}\nSuppose the claim fails for some $ I $. Then there exists an ideal $ I $ such that\n\\begin{enumerate}\n\\item $ I $ does not contain a product of primes, but\n\\item every ideal containing $ I $ does.\n\\end{enumerate}\nSuppose not. Then let $ I_0 $ be an ideal satisfying $ 1 $. Since $ 2 $ does not hold for $ I_0 $ there exists $ I_1 \\supsetneq I_0 $ such that $ 1 $ holds for $ I_1 $. Then $ 2 $ cannot hold for $ I_1 $, so there exists $ I_2 \\supsetneq I_1 $ such that $ 1 $ holds for $ I_2 $, etc, so get infinite increasing chain\n$$ I_0 \\subsetneq I_1 \\subsetneq \\dots, $$\ncontradicting Noetherianness of $ R $. Fix such an $ I $. Certainly $ I $ cannot be prime. So there exist $ a, b \\in R $ with $ ab \\in I $ but $ a $ and $ b $ are not in $ I $. Then the ideals $ I + \\abr{a} $ and $ I + \\abr{b} $ both strictly contain $ I $, so the claim holds for both of these ideals by $ 2 $, so $ I + \\abr{a} \\supseteq \\ppp_1 \\dots \\ppp_r $ and $ I + \\abr{b} \\supseteq \\qqq_1 \\dots \\qqq_s $ for $ \\ppp_i $ and $ \\qqq_j $ prime ideals. Then it also holds for their product $ \\br{I + \\abr{a}}\\br{I + \\abr{b}} = I^2 + \\abr{a}I + \\abr{b}I + \\abr{ab} $, but this product is contained in $ I $. Thus $ \\ppp_1 \\dots \\ppp_r\\qqq_1 \\dots \\qqq_s \\subseteq \\br{I + \\abr{a}}\\br{I + \\abr{b}} \\subseteq I $ as well and we have a contradiction to $ 1 $.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{note*}\nIf the claim holds for an ideal $ I $ then it holds for any ideal containing $ I $. If the claim holds for $ I $ and $ J $ then it holds for $ I \\cap J $.\n\\end{note*}\n\nNext, we show that prime ideals have multiplicative inverses. To do so we use the following lemma.\n\n\\begin{lemma}\n\\label{lem:11.1.7}\nLet $ R $ be a Dedekind domain with field of fractions $ K $, and let $ x $ be an element of $ K $ that is not in $ R $, and let $ I $ be any nonzero ideal of $ R $. Then $ xI $ is not contained in $ I $.\n\\end{lemma}\n\n\\begin{proof}\nSuppose $ xI $ were contained in $ I $. Let $ a \\in I $, and for each $ i $ let $ M_i $ be the ideal of $ I $ generated by $ a, \\dots, ax^i $, so $ M_i = \\abr{a, \\dots, ax^i} \\subseteq I $. This is an increasing tower of ideals of $ R $. In particular, since $ R $ is Noetherian, it is eventually constant, that is $ M_{i + 1} = M_i $ for some $ i $. Then $ ax^{i + 1} $ can be expressed as an $ R $-linear combination of the $ ax^j $, that is there exist $ r_0, \\dots, r_i \\in R $ such that we have $ ax^{i + 1} = \\sum_{j = 0}^i r_jax^j $. Since $ a \\ne 0 $ and $ R $ is an integral domain we can cancel the $ a $, so $ x^{i + 1} = \\sum_{j = 0}^i r_jx^j $, so $ x $ satisfies a monic polynomial with coefficients in $ R $. Thus $ x $ is integral over $ R $. Since $ R $ is integrally closed and $ x $ does not lie in $ R $ this is a contradiction.\n\\end{proof}\n\nWhen $ R $ is not integrally closed this is false.\n\n\\begin{example*}\nIf $ R = \\ZZ\\sbr{\\sqrt{-3}} $, $ I \\subset R $, and $ x = \\tfrac{1 + \\sqrt{-3}}{2} $, then $ xI = \\abr{1 + \\sqrt{-3}, -1 + \\sqrt{-3}} = \\abr{2, 1 + \\sqrt{-3}} = I $.\n\\end{example*}\n\n\\begin{proposition}\n\\label{prop:11.1.8}\nLet $ \\ppp $ be a nonzero prime ideal of a Dedekind domain $ R $. Then $ \\ppp^{-1} \\cdot \\ppp = R $.\n\\end{proposition}\n\n\\begin{proof}\nWe first show that there is an element $ x \\in \\ppp^{-1} $ such that $ x \\notin R $. Let $ a $ be an element of $ \\ppp $, and $ a \\ne 0 $, so that we have $ \\abr{a} \\subset \\ppp $. Choose a minimal set of nonzero primes $ \\ppp_1, \\dots, \\ppp_r $ such that $ \\ppp_1 \\dots \\ppp_r \\subseteq \\abr{a} $. Then we have in particular $ \\ppp_1 \\dots \\ppp_r \\subseteq \\ppp $, so by Lemma \\ref{lem:11.1.3} above we must have $ \\ppp = \\ppp_i $ for some $ i $. Without loss of generality we can take $ i = 1 $. Then by our minimality assumption $ \\ppp_2 \\dots \\ppp_r $ is not contained in $ \\abr{a} $. Take $ b $ to be an element of $ \\ppp_2 \\dots \\ppp_r $ that is not in $ \\abr{a} $. Then $ b / a \\in K $ but not in $ R $. Take $ x = b / a $. On the other hand for any $ y \\in \\ppp $, $ xy = by / a $ for $ by \\in \\ppp_1 \\dots \\ppp_r \\subseteq \\abr{a} $. Thus $ xy $ lies in $ R $. By definition, this means $ x $ lies in $ \\ppp^{-1} $ but not in $ R $. Now consider $ \\ppp^{-1} \\cdot \\ppp $. By definition this is contained in $ R $. Since $ \\ppp \\subseteq R $, $ 1 \\in \\ppp^{-1} $ so $ \\ppp^{-1} \\cdot \\ppp $ contains $ \\ppp $. Since $ \\ppp $ is a nonzero prime ideal it is maximal, so we must have either $ \\ppp^{-1} \\cdot \\ppp = R $ or $ \\ppp^{-1} \\cdot \\ppp = \\ppp $. Suppose the latter holds. Then in particular multiplication by $ x $ sends $ \\ppp $ to $ \\ppp $. This contradicts Lemma \\ref{lem:11.1.7} above, so $ \\ppp^{-1} \\cdot \\ppp \\supsetneq \\ppp $.\n\\end{proof}\n\n\\begin{proposition}\n\\label{prop:11.1.9}\nLet $ I $ be a nonzero ideal of a Dedekind domain $ R $. Then there exists a fractional ideal $ J $ of $ R $ such that $ IJ = R $.\n\\end{proposition}\n\n\\begin{proof}\nSuppose otherwise. Then there is a maximal nonzero ideal $ I $ of $ R $ for which no such $ J $ exists. Proposition \\ref{prop:11.1.8} shows that $ I $ is not a maximal ideal, so $ I $ is properly contained in some maximal ideal $ \\ppp $ of $ R $. Then $ \\ppp^{-1} $ is contained in $ I^{-1} $. We thus have inclusions\n$$ I \\subseteq I\\ppp^{-1} \\subseteq II^{-1} \\subseteq R. $$\nSuppose that $ I\\ppp^{-1} = I $. By Proposition \\ref{prop:11.1.8} there exists $ x \\in \\ppp^{-1} $ not in $ R $, so we would have $ xI \\subset I $ contradicting Lemma \\ref{lem:11.1.7} above. Thus $ I\\ppp^{-1} $ strictly contains $ I $ and thus has an inverse $ J = \\br{I\\ppp^{-1}}^{-1} $. Then $ I\\ppp^{-1} \\cdot J = R $. But then $ I \\cdot \\ppp^{-1}J = R $, so $ \\ppp^{-1}J \\subseteq I^{-1} $. Then $ II^{-1} \\supseteq R $. So $ II^{-1} = R $, a contradiction.\n\\end{proof}\n\n\\begin{theorem}\nLet $ R $ be a Dedekind domain. Then the fractional ideals of $ R $ form a group under multiplication.\n\\end{theorem}\n\n\\begin{proof}\nWe must show that every fractional ideal of $ R $ is invertible. Let $ I $ be such a fractional ideal of $ R $. Then there is $ r \\in R $ such that $ rI $ is an ideal of $ R $. Proposition \\ref{prop:11.1.9} shows that $ rI $ has a multiplicative inverse $ J $, so $ I = \\tfrac{1}{r}J^{-1} $. Then $ I^{-1} = rJ $ is a multiplicative inverse for $ I $, since $ II^{-1} = \\tfrac{1}{r}J^{-1} \\cdot rJ = JJ^{-1} = R $.\n\\end{proof}\n\n\\lecture{24}{Wednesday}{28/11/18}\n\nLecture 24 is a problems class.\n\n\\lecture{25}{Friday}{30/11/18}\n\nIt remains to show that every fractional ideal of $ R $ factors uniquely as a product of prime powers. The hard part is showing such factorisations exist, and we make heavy use of the fact that the fractional ideals are a group. Uniqueness is then almost an afterthought.\n\n\\pagebreak\n\n\\begin{proposition}\nEvery fractional ideal in a Dedekind domain $ R $ is uniquely expressible as a product of, possibly negative, prime powers $ \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} $ for $ n_i \\in \\ZZ $.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item We first show that every nonzero ideal $ I $ in $ R $ is a product of nonnegative prime powers. Suppose otherwise, that for some ideal $ I $ of $ R $, $ I $ cannot be expressed as a product of primes. Claim that there is a largest ideal $ I' $ such that $ I' $ cannot be expressed as a product of primes but all $ J \\supsetneq I $ can. Take $ I_0 = I $ if there exists $ I_1 \\supsetneq I $ that cannot be expressed as a product of primes, either all ideals properly containing $ I_1 $ can be or there exists $ I_2 \\supsetneq I_1 $ that cannot be expressed as a product of primes. Since $ R $ is Noetherian, the process terminates. Now let $ I' $ be as in the claim. Certainly $ I' \\ne R $, and $ I' $ is not prime, since every maximal ideal of $ R $ is certainly such a product $ I' $ cannot be a maximal ideal. Thus $ I' $ is properly contained in a maximal ideal $ \\ppp $. Then $ J = \\ppp^{-1} \\cdot I' $ is an ideal of $ R $. Since $ \\ppp \\supseteq I' $, $ \\ppp^{-1} \\cdot \\ppp \\supseteq J $, so $ J \\subseteq R $. Since the nonzero fractional ideals of $ R $ form a group this ideal $ J $ strictly contains $ I' $ and thus factors as a product of prime powers $ \\ppp^{-1} \\cdot I' = J = \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} $. But then $ \\ppp \\cdot J = I' = \\ppp\\ppp_1^{n_1} \\dots \\ppp_s^{n_s} $ is also a product of prime powers, contradicting our assumption. Now suppose that $ I $ is a fractional ideal. Then $ I = \\tfrac{1}{r}J $ for some nonzero ideal $ J $ of $ R $ and some nonzero element $ r $ of $ R $. Since $ \\abr{r} = \\qqq_1^{m_1} \\dots \\qqq_t^{m_t} $ and $ J = \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} $ factor as products of prime powers, so does $ I = \\tfrac{1}{r}J = \\abr{r}^{-1}J = \\ppp_1^{n_1} \\dots \\ppp_s^{n_s}\\qqq_1^{-m_1} \\dots \\qqq_t^{-m_t} $.\n\\item It remains to show that such factorisations are unique. Suppose otherwise for a fractional ideal $ I $. Then we have a finite collection of distinct primes $ \\ppp_1, \\dots, \\ppp_s $ and $ \\qqq_1, \\dots, \\qqq_t $, and two sequences $ n_1, \\dots, n_s, m_1, \\dots, m_t \\in \\ZZ $ such that $ I = \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} = \\qqq_1^{m_1} \\dots \\qqq_t^{m_t} $, and we must show that $ m_i = n_i $ for all $ i $. Suppose this is not the case. We can make all prime powers $ n_i $ and $ m_j $ involved positive by cancelling $ \\ppp_i^{n_i} $ and $ \\qqq_j^{m_j} $ from both sides of the equation. We then get an expression of the form $ \\ppp_1^{n_1} \\dots \\ppp_s^{n_s} = \\qqq_1^{m_1} \\dots \\qqq_t^{m_t} $, where the primes $ \\cbr{\\ppp_i} $ and $ \\cbr{\\qqq_j} $ are all distinct and all powers $ a_i $ and $ b_j $ are positive. Claim that both products must be empty under these assumptions. Recall that if $ R $ is Noetherian, $ \\ppp $ is prime, and $ I $ and $ J $ are ideals, then $ \\ppp $ contains $ IJ $ implies that $ \\ppp $ contains $ I $ or $ \\ppp $ contains $ J $. If one product, say the $ \\ppp_i $'s, is nonempty, then since $ \\ppp_1 $ divides the left hand side it also divides the right hand side, and thus contains one of the $ \\qqq_i $'s for some $ i $. Since $ \\ppp_i $ and $ \\qqq_j $ are maximal in a Dedekind domain, $ \\ppp_1 = \\qqq_i $, which contradicts disjointness and is impossible.\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Ideal class groups}\n\nLet $ R $ be a Dedekind domain. Then the fractional ideals of $ R $ form a group, which we will denote $ \\III\\br{R} $. The principal fractional ideals are a subset of $ \\III\\br{R} $ that is easily seen to be closed under multiplication and inverses. If $ r, s \\in K^* $, then\n$$ \\br{rR}^{-1} = \\dfrac{1}{r}R \\qquad \\br{rR}\\br{sR} = rsR. $$\nDenote this subgroup by $ \\PPP\\br{R} $. We can then form a quotient group called the ideal class group of $ R $.\n\n\\begin{definition}\nThe \\textbf{ideal class group} of $ R $ is $ \\AAA\\br{R} = \\III\\br{R} / \\PPP\\br{R} $.\n\\end{definition}\n\n\\begin{example*}\nIf $ R $ is a PID, $ \\AAA\\br{R} = \\cbr{e} $.\n\\end{example*}\n\nIn general $ \\AAA\\br{R} $ is a measure of the failure of fractional ideals of $ R $ to be principal. That is, it measures the failure of $ R $ to be a PID. We will show that if $ K $ is a finite extension of $ \\QQ $ then the integral closure $ \\OOO_K $ of $ \\ZZ $ in $ K $ is a Dedekind domain. A fundamental result of algebraic number theory is the following.\n\n\\begin{theorem}\nIf $ R $ is a Dedekind domain with field of fractions a finite extension of $ K $, that is $ R = \\OOO_K $ for $ K / \\QQ $ finite, then the ideal class group $ \\AAA\\br{R} $ is a finite group.\n\\end{theorem}\n\nThe order of the ideal class group of $ \\OOO_K $ is called the \\textbf{class number} of $ K $. In particular, if $ \\AAA\\br{R} $ is finite, say of order $ n $, then $ \\ppp^n $ is principal for every prime $ \\ppp $. A warning is that it is not true that $ \\AAA\\br{R} $ is finite for $ R $ Dedekind. The study of class groups and class numbers is a central part of modern number theory and there are many, many open questions.\n\n\\begin{example*}\nIf $ R = \\CC\\sbr{x, y} / \\abr{y^2 - x\\br{x - 1}\\br{x + 1}} $, then $ \\AAA\\br{R} $ is uncountable.\n\\end{example*}\n\n\\pagebreak\n\n\\section{Integers in number fields}\n\n\\subsection{Integer rings}\n\nAt one point I claimed that if $ R $ is a PID, $ K $ is its field of fractions, and $ L / K $ is finite, then the integral closure $ S $ of $ R $ in $ L $ is Dedekind. In fact, only need $ R $ is Dedekind. We will prove under a simplifying assumption, involving the trace map. Let $ K $ be a finite extension of $ \\QQ $. Such an extension is called a \\textbf{number field}. The integral closure $ \\OOO_K $ of $ \\ZZ $ in $ K $ is called the \\textbf{ring of integers} of $ K $. A fundamental result of number theory is that $ \\OOO_K $ is a Dedekind domain. The goal of this section is to prove this fact. Indeed, we will prove something more general, but in order to do that we need to introduce some new concepts.\n\n\\subsection{Trace and norm}\n\nLet $ L / K $ be a finite extension of fields, and let $ \\alpha $ be an element of $ L $. Then we can regard $ L $ as a finite-dimensional $ K $-vector space. Multiplication by $ \\alpha $ is then a $ K $-linear map from $ L $ to $ L $. If we choose a $ K $-basis $ \\beta_1, \\dots, \\beta_d $ for $ L $, such a map\n$$ \\function{L}{L}{x}{x\\alpha} $$\nis given by a $ d $ by $ d $ matrix $ M_\\alpha \\in M_d\\br{K} $, with entries in $ K $ where $ d $ is the degree of $ L $ over $ K $. That is, $ \\br{M_\\alpha}_{i, j} $ is defined by $ \\alpha\\beta_i = \\sum_{j = 1}^d \\br{M_\\alpha}_{i, j}\\beta_j $. The matrix of course depends on the basis $ \\beta_1, \\dots, \\beta_d $ chosen, but its trace and determinant are elements of $ K $ that depend only on $ \\alpha $. We denote the trace of $ M_\\alpha $ by $ \\Tr_{L / K} \\alpha \\in K $ and call it the \\textbf{trace} of $ \\alpha $ with respect to $ L / K $. Similarly, the determinant of $ M_\\alpha $ is denoted $ \\Nm_{L / K} \\alpha \\in K $ and called the \\textbf{norm} of $ \\alpha $.\n\n\\begin{lemma}\nThe map\n$$ \\function[\\Tr_{L / K}]{L}{K}{\\alpha}{\\Tr_{L / K} \\alpha} $$\nis $ K $-linear, so $ \\Tr_{L / K} \\br{\\lambda\\alpha + \\alpha'} = \\lambda \\Tr_{L / K} \\alpha + \\Tr_{L / K} \\alpha' $. The map\n$$ \\function[\\Nm_{L / K}]{L}{K}{\\alpha}{\\Nm_{L / K} \\alpha} $$\nis multiplicative, so $ \\Nm_{L / K} \\alpha\\alpha' = \\Nm_{L / K} \\alpha\\Nm_{L / K} \\alpha' $.\n\\end{lemma}\n\n\\begin{proof}\nSince $ \\lambda \\in K $, distributivity of multiplication over addition shows that, with respect to a fixed basis of $ L $ over $ K $, $ M_{\\lambda\\alpha + \\alpha'} = \\lambda M_\\alpha + M_{\\alpha'} $, so\n$$ \\Tr_{L / K} \\br{\\lambda\\alpha + \\alpha'} = \\Tr M_{\\lambda\\alpha + \\alpha'} = \\Tr \\lambda M_\\alpha + \\Tr M_{\\alpha'} = \\lambda \\Tr_{L / K} \\alpha + \\Tr_{L / K} \\alpha'. $$\nSimilarly $ M_{\\alpha\\alpha'} = M_\\alpha M_{\\alpha'} $, by associativity of multiplication, so\n$$ \\Nm_{L / K} \\alpha\\alpha' = \\det M_{\\alpha\\alpha'} = \\det M_\\alpha\\det M_{\\alpha'} = \\Nm_{L / K} \\alpha\\Nm_{L / K} \\alpha'. $$\n\\end{proof}\n\nWe will prove that if $ R $ is a PID or a Dedekind domain, such as $ \\ZZ $, $ K $ is its field of fractions, and $ L / K $ is finite such that $ \\Tr_{L / K} $ is not the zero map, then the integral closure of $ R $ in $ L $ is Dedekind.\n\n\\lecture{26}{Monday}{03/12/18}\n\n\\begin{proposition}\n\\label{prop:12.2.2}\nLet $ L / K $ be a finite extension, and $ \\alpha $ an element of $ L $. Let\n$$ Q\\br{X} = X^n + a_{n - 1}X^{n - 1} + \\dots + a_0 $$\nbe the minimal polynomial of $ \\alpha $ over $ K $. Then\n\\begin{itemize}\n\\item $ \\Tr_{L / K} \\alpha = -da_{n - 1} $, and\n\\item $ \\Nm_{L / K} \\alpha = \\br{\\br{-1}^na_0}^d $,\n\\end{itemize}\nwhere $ d $ is the degree $ \\sbr{L : K\\br{\\alpha}} $ of $ L $ over $ K\\br{\\alpha} $.\n\\end{proposition}\n\n\\pagebreak\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item We first prove this when $ d = 1 $, so $ L = K\\br{\\alpha} $ and $ n = \\sbr{L : K} $. Then we have seen $ 1, \\dots, \\alpha^{n - 1} $ is a $ K $-basis for $ L $ over $ K $. With respect to this basis,\n$$\n\\begin{array}{c|c|c}\n\\text{basis element} & \\cdot \\alpha & \\text{in terms of basis} \\\\\n\\hline\n1 & \\alpha & \\alpha \\\\\n\\vdots & \\vdots & \\vdots \\\\\n\\alpha^{n - 2} & \\alpha^{n - 1} & \\alpha^{n - 1} \\\\\n\\alpha^{n - 1} & \\alpha^n & -a_{n - 1}\\alpha^{n - 1} - \\dots - a_0\n\\end{array}.\n$$\n$ M_\\alpha $ has the matrix\n$$ M_\\alpha =\n\\begin{pmatrix}\n0 & \\dots & 0 & -a_0 \\\\\n1 & \\dots & 0 & -a_1 \\\\\n\\vdots & \\ddots & \\vdots & \\vdots \\\\\n0 & \\dots & 1 & -a_{n - 1}\n\\end{pmatrix}.\n$$\nThis matrix is called the \\textbf{companion matrix} $ C_\\alpha $ of the polynomial $ Q\\br{X} $. Then $ \\Tr M = -a_{n - 1} $ and $ \\det M = \\br{-1}^na_0 $, from which both claims can be easily deduced.\n\\item In general, $ K \\subseteq K\\br{\\alpha} \\subseteq L $. Choose a basis $ \\beta_1, \\dots, \\beta_d $ for $ L $ over $ K\\br{\\alpha} $. Then\n$$ \\beta_1, \\dots, \\beta_1\\alpha^{n - 1}, \\dots, \\beta_d, \\dots, \\beta_d\\alpha^{n - 1} $$\nis a $ K $-basis for $ L / K $. With respect to this basis,\n$$\n\\begin{array}{c|c|c}\n\\text{basis vector} & \\cdot \\alpha & \\text{in terms of basis} \\\\\n\\hline\n\\beta_i & \\beta_i\\alpha & \\beta_i\\alpha \\\\\n\\vdots & \\vdots & \\vdots \\\\\n\\beta_i\\alpha^{n - 2} & \\beta_i\\alpha^{n - 1} & \\beta_i\\alpha^{n - 1} \\\\\n\\beta_i\\alpha^{n - 1} & \\beta_i\\alpha^n & \\beta_i\\br{-a_{n - 1}\\alpha^{n - 1} - \\dots - a_0} \\\\\n\\end{array}.\n$$\n$ M_\\alpha $ is block diagonal, consisting of $ d $ blocks along the diagonal, each of which is the $ n \\times n $ matrix above,\n$$ M_\\alpha = \\threebythree{C_\\alpha}{\\dots}{0}{\\vdots}{\\ddots}{\\vdots}{0}{\\dots}{C_\\alpha}. $$\nThus $ \\Tr M_\\alpha = \\Tr C_\\alpha \\cdot d = -da_{n - 1} $ and $ \\det M_\\alpha = \\br{\\det C_\\alpha}^d = \\br{\\br{-1}^na_0}^d $, so the claim follows.\n\\end{itemize}\n\\end{proof}\n\n\\begin{remark}\nIf $ L / K $ is finite, $ \\Tr_{L / K} 1 = \\sbr{L : K} $, considered as an element of $ K $. The map $ \\Tr_{L / K} : L \\to K $ is sometimes the zero map. However, this does not happen if $ K $ has characteristic $ \\ch K = 0 $ or if the degree $ d = \\sbr{L : K} $ is relatively prime to the characteristic of $ K $, since the above Proposition \\ref{prop:12.2.2} shows that $ \\Tr_{L / K} 1 = d \\ne 0 $.\n\\end{remark}\n\n\\begin{example*}\nLet $ K = \\FF_2\\br{t} $, the rational functions with coefficients in $ \\FF_2 $. Let\n$$ L = \\dfrac{K\\sbr{X}}{\\abr{X^2 - t}} = \\FF_2\\br{t^{\\tfrac{1}{2}}}. $$\nThen $ \\Tr_{L / K} $ is $ K $-linear, and $ \\Tr_{L / K} 1 = 0 $ and $ \\Tr_{L / K} X = 0 $, so $ \\Tr_{L / K} \\br{aX + b} = 0 $ for all $ a, b \\in K $.\n\\end{example*}\n\n\\begin{proposition}\nIf $ L / K $ are finite fields, then $ \\Tr_{L / K} $ is not zero map.\n\\end{proposition}\n\n\\pagebreak\n\n\\subsection{The main result}\n\nWe can now state our main result.\n\n\\begin{theorem}\nLet $ R $ be a PID, or even a Dedekind domain, with field of fractions $ K $, and let $ L / K $ be a finite extension such that $ \\Tr_{L / K} $ is not the zero map. Let $ S $ be the integral closure of $ R $ in $ L $. Then $ S $ is a Dedekind domain.\n\\end{theorem}\n\nTo prove this, we must show three things about $ S $, that $ S $ is Noetherian, that $ S $ is integrally closed, and that $ S $ has dimension one, that is every nonzero prime ideal of $ S $ is maximal. We first show the following.\n\n\\begin{lemma}\nThe field of fractions of $ S $ is $ L $.\n\\end{lemma}\n\n\\begin{proof}\nIn fact, we will show that every element of $ L $ can be expressed as $ s / r $ for $ s \\in S $ and $ r \\in R $. Let $ x \\in L $, and let $ Q\\br{X} = X^n + a_{n - 1}X^{n - 1} + \\dots + a_0 $ for $ a_i \\in K $ be the minimal polynomial of $ x $ over $ K $, where $ K $ is the field of fractions of $ R $. We will show that there exists $ r \\in R^* $ such that $ rx \\in S $. Then $ x = rx / r $, so is in field of fractions of $ S $. Let $ n $ be the degree of $ Q\\br{X} $. For each $ r \\in R $, let $ Q_r\\br{X} = r^nQ\\br{X / r} = X^n + ra_{n - 1}X^{n - 1} + \\dots + r^na_0 $. We can find an $ r \\in R $ such that $ Q_r\\br{X} $ has coefficients in $ R $. But $ Q\\br{x} = 0 $, so $ Q_r\\br{rx} = 0 $, so $ Q_r\\br{X} $ is the minimal polynomial of $ rx $, so it follows that for such $ r $, $ rx $ is integral over $ R $ and thus lies in $ S $.\n\\end{proof}\n\n\\begin{corollary}\nThe ring $ S $ is integrally closed.\n\\end{corollary}\n\n\\begin{proof}\nWe have shown that the integral closure $ S $ of $ R $ in $ L $ is integrally closed in $ L $. Since $ L $ is the field of fractions of $ S $, we have that $ S $ is integrally closed.\n\\end{proof}\n\n\\lecture{27}{Wednesday}{05/12/18}\n\nNext we show that $ S $ is Noetherian. In fact, we will show that $ S $ is a finitely generated $ R $-module. Since $ R $ is Noetherian it will then follow that $ S $ is Noetherian as an $ R $-module, and hence also as an $ S $-module. Then every $ R $-submodule of $ S $ is finitely generated over $ R $, so every ideal of $ S $ is finitely generated as an $ R $-module and as an $ S $-module. Thus $ S $ is Noetherian. To do this, choose a $ K $-basis $ \\beta_1, \\dots, \\beta_d $ for $ L $ over $ K $. We have seen that for each $ i $ there exists $ r_i \\in R^* $ such that $ r_i\\beta_i \\in S $, so, replacing $ \\beta_i $ by $ r_i\\beta_i $, we may assume that the $ \\beta_i $ all lie in $ S $. Let $ M \\subseteq S $ be the $ R $-module in $ S $ spanned by the $ \\beta_i $, and let $ M^* $ denote\n$$ M^* = \\cbr{x \\in L \\st \\forall m \\in M, \\ \\Tr_{L / K} xm \\in R} \\subseteq L. $$\nClaim that $ S \\subseteq M^* $. Since $ M \\subseteq S $, if $ x \\in S $, then $ xm \\in S $. So it suffices to show that for all $ s \\in S $, $ \\Tr_{L / K} s \\in R $. Fix $ s $, let $ Q\\br{X} $ be the minimal polynomial of $ s $ over $ K $. Since $ S $ is integral over $ R $, $ s $ is integral over $ R $, so $ Q\\br{s} $ has coefficients in $ R $. If $ Q\\br{X} = X^r + a_{r - 1}X^{r - 1} + \\dots + a_0 $, last time showed that $ \\Tr_{L / K} s = -na_{r - 1} $ for $ n = \\sbr{L : K\\br{s}} $. This lies in $ R $. We now have $ M \\subseteq S \\subseteq M^* $. It suffices to show $ M^* $ is finitely generated as an $ R $-module.\n\n\\begin{proposition}\nThere exist $ \\beta_1^*, \\dots, \\beta_d^* \\in L $ such that\n$$ \\Tr_{L / K} \\beta_i\\beta_j^* =\n\\begin{cases}\n1 & i = j \\\\\n0 & i \\ne j\n\\end{cases}.\n$$\n\\end{proposition}\n\n\\begin{proof}\nLet $ A $ be the matrix where $ A_{ij} = \\Tr_{L / K} \\beta_i\\beta_j $, a $ d \\times d $ matrix with entries in $ K $. If $ x = r_1\\beta_1 + \\dots + r_d\\beta_d $, then\n$$ A\\threebyone{r_1}{\\vdots}{r_d} = \\threebyone{r_1\\Tr \\beta_1\\beta_1 + \\dots + r_d\\Tr \\beta_1\\beta_d}{\\vdots}{r_1\\Tr \\beta_d\\beta_1 + \\dots + r_d\\Tr \\beta_d\\beta_d} = \\threebyone{\\Tr \\beta_1\\br{r_1\\beta_1 + \\dots + r_d\\beta_d}}{\\vdots}{\\Tr \\beta_d\\br{r_1\\beta_1 + \\dots + r_d\\beta_d}} = \\threebyone{\\Tr \\beta_1x}{\\vdots}{\\Tr \\beta_dx}. $$\nIf I have $ y_1, \\dots, y_d \\in K $, finding an element $ x = r_1\\beta_1 + \\dots + r_d\\beta_d \\in L $ such that $ \\Tr \\beta_1x = y_1, \\dots, \\Tr \\beta_dx = y_d $ is equivalent to solving\n$$ A\\onebythree{r_1}{\\dots}{r_d}^\\intercal = \\onebythree{y_1}{\\dots}{y_d}^\\intercal, $$\nso $ \\beta_j^* $, if it exists, is $ \\beta_j^* = r_1\\beta_1 + \\dots + r_d\\beta_d $ for $ r_1, \\dots, r_d $ a solution to\n$$ A\\onebythree{r_1}{\\dots}{r_d}^\\intercal = \\onebythree{0 \\dots 0}{1}{0 \\dots 0}^\\intercal. $$\n\n\\pagebreak\n\nSo it suffices to show $ A $ is invertible. Suppose otherwise. Then there exists $ r_1, \\dots, r_d $ not all zero, and\n$$ A\\onebythree{r_1}{\\dots}{r_d}^\\intercal = 0. $$\nThen $ x = r_1\\beta_1 + \\dots + r_d\\beta_d \\in L^* $ is such that $ \\Tr_{L / K} \\beta_ix = 0 $ for all $ i $. If this is true, can write $ y \\in L $ as $ b_1\\beta_1 + \\dots + b_d\\beta_d $. Then $ \\Tr_{L / K} xy = b_1\\Tr_{L / K} \\beta_1x + \\dots + b_d\\Tr_{L / K} \\beta_dx = 0 $. So $ \\Tr_{L / K} xy = 0 $ for all $ y \\in L $. But $ x \\ne 0 $. Setting $ y = x^{-1}z $, we find $ \\Tr_{L / K} z = 0 $ for all $ z \\in L $. But we assumed $ \\Tr_{L / K} \\ne 0 $.\n\\end{proof}\n\n\\begin{corollary}\n$ M^* $ is a free $ R $-module of rank $ d $.\n\\end{corollary}\n\n\\begin{proof}\nClaim that $ \\beta_j^* \\in M^* $ for all $ j $, and the $ \\beta_j^* $ generate $ M^* $ as an $ R $-module. Every element of $ M $ can be written as $ r_1\\beta_1 + \\dots + r_d\\beta_d $ for $ r_i \\in R $, so $ \\Tr_{L / K} \\beta_j^*m = r_j \\in R $. Let $ x \\in M^* $. We can write $ x = r_1\\beta_1^* + \\dots + r_d\\beta_d^* $ for $ r_i \\in K $. Thus $ \\Tr_{L / K} \\beta_ix = r_i $, so $ r_i \\in R $ for all $ i $.\n\\end{proof}\n\n\\begin{corollary}\n$ S $ is a finitely generated $ R $-module.\n\\end{corollary}\n\n\\begin{proof}\n$ S $ is an $ R $-submodule of the finitely generated $ R $-module $ M^* $, and, since $ R $ is Noetherian, $ S $ is therefore finitely generated as an $ R $-module.\n\\end{proof}\n\nThus $ S $ is Noetherian. Now it remains to prove that every nonzero prime ideal $ \\ppp $ of $ S $ is maximal. Let $ \\ppp $ be a nonzero prime ideal of $ S $, and let $ s $ be an element of $ \\ppp $. Consider the intersection $ \\qqq = \\ppp \\cap R $. Then $ \\qqq $ is a prime ideal of $ R $. Claim that $ \\qqq = \\ppp \\cap R $ is a nonzero prime ideal of $ R $. Let $ Q\\br{X} $ be the minimal polynomial of $ s $ over $ K $, then $ s $ is integral, so $ Q\\br{X} $ has coefficients in $ R $. If $ Q\\br{X} = X^r + a_{r - 1}X^{r - 1} + \\dots + a_0 $ for $ a_0 \\ne 0 $, where $ Q\\br{X} $ is irreducible, we then have $ 0 = Q\\br{s} = a_0 + \\dots + a_{r - 1}s^{r - 1} + s^r $, and thus lie in $ R $. Rewriting, we get $ -a_0 = s\\br{a_1 + \\dots + a_{r - 1}s^{r - 2} + s^{r - 1}} $. In particular $ -a_0 $ lies in the ideal generated by $ s $, and hence in $ \\ppp $. Moreover, since $ Q\\br{X} $ is irreducible, $ a_0 $ is a nonzero element of $ R $, so $ \\qqq $ is nonzero since $ a_0 \\in \\qqq $. Since $ R $ is Dedekind, thus $ \\qqq $ is a maximal ideal of $ R $. Have $ R \\subseteq S \\to S / \\ppp $, where kernel is $ R / \\qqq $, a field. So get $ R / \\qqq \\to S / \\ppp $. The ring $ S / \\ppp $ is an integral domain containing the field $ R / \\qqq $. Moreover, since $ S $ is a finitely generated $ R $-module, if $ s_1, \\dots, s_r $ generate $ S $ as an $ R $-module, then they generate $ S / \\ppp $ as an $ R / \\qqq $-module, so $ S / \\ppp $ is a finitely generated $ R / \\qqq $-module. That is, $ S / \\ppp $ is a finite-dimensional $ R / \\qqq $-vector space. We now show the following.\n\n\\begin{lemma}\n\\label{lem:12.3.7}\nLet $ K $ be an integral domain and let $ R $ be an integral domain containing $ K $ that is finite-dimensional as an $ K $-vector space. Then $ R $ is a field.\n\\end{lemma}\n\n\\begin{proof}\nLet $ r $ be a nonzero element of $ R $. Have map\n$$ \\function{K\\sbr{X}}{R}{X}{r}. $$\nLet $ I $ be the kernel. Since $ R $ is finite-dimensional $ I = 0 $. Since $ R $ is an integral domain $ I $ is prime. So\n$$ \\function{K\\sbr{X} / I}{R}{X + I}{r} $$\nis an injection, with $ K\\sbr{X} / I $ a field. Then $ X $ has an inverse in $ K\\sbr{X} / I $, and this inverse maps to a multiplicative inverse for $ r $ in $ R $.\n\\end{proof}\n\nLemma \\ref{lem:12.3.7} shows that $ S / I $ is a field, so $ I $ is maximal. We have thus shown that $ S $ is Noetherian, integrally closed, and that every nonzero prime ideal in $ S $ is maximal, so $ S $ is indeed a Dedekind domain. In particular, for any finite extension $ K / \\QQ $, the integral closure $ \\OOO_K $ of $ \\ZZ $ in $ K $ is a Dedekind domain, and thus has unique factorisation of ideals. Another class of examples comes by taking $ K $ a field, letting $ L $ be a finite extension of $ K\\br{t} $ such that $ \\Tr_{L / K\\br{t}} $ is nonzero, and letting $ R $ be the integral closure of $ K\\sbr{t} $ in $ L $. The field $ L $ is called a \\textbf{function field}, and the ring $ R $ is the \\textbf{ring of regular functions on a smooth affine algebraic curve}. Such rings $ R $ are also Dedekind domains, and they are of considerable interest in algebraic geometry. They of course also have the unique factorisation property for ideals, and just like in ring of integers one can consider the ideal class group. In this context, the ideal class group is also known as the \\textbf{Picard group}. It has a geometric interpretation in terms of \\textbf{line bundles} on algebraic curves. Unlike in the number field setting, the Picard group is often not a finite group.\n\n\\pagebreak\n\n\\section{Introduction to algebraic geometry}\n\n\\lecture{28}{Friday}{07/12/18}\n\nThe idea is\n\\begin{itemize}\n\\item to study ideals in polynomial rings by studying geometry of the common zeros in ideal, and\n\\item to study geometry of solutions to polynomial equations via ring theory.\n\\end{itemize}\n\n\\subsection{Algebraically closed fields}\n\nWork best over algebraically closed fields.\n\n\\begin{definition}\nLet $ K $ be a field. We say $ K $ is \\textbf{algebraically closed} if every nonconstant polynomial $ P\\br{X} \\in K\\sbr{X} $ factors into linear factors.\n\\end{definition}\n\nIn particular, the only irreducible polynomials are linear polynomials.\n\n\\begin{theorem}[Fundamental theorem of algebra]\nThe field $ \\CC $ is algebraically closed.\n\\end{theorem}\n\nWe will not prove this in this course. Ultimately it requires some analysis. This is unsurprising, since the construction of $ \\CC $ is fundamentally an analytic one. We have the following characterisation of algebraically closed fields.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item By contrast, $ \\QQ, \\RR, \\FF_{p^r}, \\FF_p\\br{t} $ are all not algebraically closed.\n\\item $ \\overline{\\QQ} $ is algebraically closed.\n\\end{itemize}\n\\end{example*}\n\n\\begin{lemma}\nA field $ K $ is algebraically closed if and only if every field extension $ L / K $ is either trivial, that is $ L = K $, or transcendental.\n\\end{lemma}\n\n\\begin{proof}\nSuppose $ K $ is algebraically closed. Let $ L / K $ be an algebraic extension, and $ \\alpha \\in L $. Let $ P\\br{X} $ be the minimal polynomial of $ \\alpha $ over $ K $. Then $ P\\br{X} $ is irreducible, hence linear. But then $ \\alpha \\in K $, so $ L = K $. Conversely, if every field extension $ L / K $ is trivial or transcendental, then if $ P\\br{X} $ is an irreducible polynomial in $ K\\sbr{X} $ we must have $ K\\sbr{X} / \\abr{P\\br{X}} = K $, so $ P\\br{X} $ must have degree one. Since every polynomial in $ K\\sbr{X} $ factors into irreducibles, $ K $ must be algebraically closed.\n\\end{proof}\n\n\\subsection{Affine algebraic sets}\n\nFix an algebraically closed field $ K $. In fact, it is harmless to take $ K = \\CC $ throughout.\n\n\\begin{definition}\nLet $ \\AA_K^n $, the \\textbf{affine $ n $-space} over $ K $, denote the set $ K^n $ of $ n $-tuples of elements of $ K $.\n\\end{definition}\n\nFor $ S $ an arbitrary collection of elements of $ K\\sbr{X_1, \\dots, X_n} $, we let $ \\Z\\br{S} $ denote the subset\n$$ \\Z\\br{S} = \\cbr{\\br{x_1, \\dots, x_n} \\in \\AA_K^n \\st \\forall P \\in S, \\ P\\br{x_1, \\dots, x_n} = 0} \\subseteq \\AA_K^n. $$\nIn other words, $ \\Z\\br{S} $ is the \\textbf{set of common zeros} of all the polynomials in $ S $.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item $ S = \\cbr{y - x\\br{x - 1}\\br{x + 1}} $ is $ y = x\\br{x - 1}\\br{x + 1} $.\n\\item $ S = \\cbr{y\\br{y - x\\br{x - 1}\\br{x + 1}}} $ is $ y = 0 $ or $ y = x\\br{x - 1}\\br{x + 1} $.\n\\item $ S = \\cbr{y, y - x\\br{x - 1}\\br{x + 1}} $ is $ y = 0 $ and $ y = x\\br{x - 1}\\br{x + 1} $.\n\\item $ S = \\cbr{y^2 - x\\br{x - 1}\\br{x + 1}} $ is connected.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\nNote that we have the following.\n\n\\begin{lemma}\nLet $ S $ be a subset of $ K\\sbr{X_1, \\dots, X_n} $ and let $ I $ be the ideal of $ K\\sbr{X_1, \\dots, X_n} $ generated by $ S $. Then $ \\Z\\br{I} = \\Z\\br{S} $.\n\\end{lemma}\n\n\\begin{proof}\nSince $ S \\subseteq I $, we have $ \\Z\\br{I} \\subseteq \\Z\\br{S} $. On the other hand, let $ p = \\br{x_1, \\dots, x_n} \\in \\Z\\br{S} $. Then for all $ P\\br{X_1, \\dots, X_n} \\in S $, we have $ P\\br{p} = 0 $. Any polynomial $ P\\br{X_1, \\dots, X_n} \\in I $ can be expressed as $ P = Q_1S_1 + \\dots + Q_rS_r $ for $ Q_i \\in K\\sbr{X_1, \\dots, X_n} $ and $ S_i \\in S $. But then we have $ P\\br{p} = Q_1\\br{p}S_1\\br{p} + \\dots + Q_r\\br{p}S_r\\br{p} = 0 $, since $ S_i\\br{p} = 0 $ for all $ i $. Thus we have that $ p \\in \\Z\\br{I} $.\n\\end{proof}\n\nFrom this and the Hilbert basis theorem we deduce, $ K\\sbr{X_1, \\dots, X_n} $ is Noetherian and every ideal is finitely generated, so for any subset $ S $ of polynomials in $ K\\sbr{X_1, \\dots, X_n} $ there is a finite collection $ S' $ of polynomials such that $ \\Z\\br{S} = \\Z\\br{S'} $. Just let $ S' $ be a generating set for the ideal generated by $ S $.\n\n\\begin{definition}\nA subset $ T $ of $ \\AA_K^n $ is called an \\textbf{affine algebraic set} if $ T $ is for the form $ \\Z\\br{I} $ for some ideal $ I $ of $ K\\sbr{X_1, \\dots, X_n} $.\n\\end{definition}\n\nConversely, subsets of $ \\AA_K^n $ define ideals of $ K\\sbr{X_1, \\dots, X_n} $. For $ T \\subseteq \\AA_K^n $, let $ \\I\\br{T} $ denote the ideal\n$$ \\I\\br{T} = \\cbr{P\\br{X_1, \\dots, X_n} \\in K\\sbr{X_1, \\dots, X_n} \\st \\forall t \\in T, \\ P\\br{t} = 0} \\subseteq K. $$\nClaim that $ \\I\\br{T} $ is an ideal. If $ P\\br{t} = 0 $ and $ Q\\br{t} = 0 $ for all $ t \\in T $, then $ P\\br{t} + Q\\br{t} = 0 $ and $ R\\br{t}P\\br{t} = 0 $ for $ t \\in T $ and $ R\\br{X_1, \\dots, X_n} \\in K\\sbr{X_1, \\dots, X_n} $.\n\n\\begin{note*}\nThe operations $ T \\mapsto \\I\\br{T} $ and $ I \\mapsto \\Z\\br{I} $ are both inclusion-reversing.\n\\begin{itemize}\n\\item If $ T \\subseteq T' \\subseteq \\AA_K^n $ then $ \\I\\br{T} \\supseteq \\I\\br{T'} $.\n\\item If $ J \\subseteq J' \\subseteq K\\sbr{X_1, \\dots, X_n} $ then $ \\Z\\br{J} \\supseteq \\Z\\br{J'} $.\n\\end{itemize}\n\\end{note*}\n\nWe have the following.\n\n\\begin{lemma}\nLet $ X $ be an affine algebraic set. Then $ \\Z\\br{\\I\\br{X}} = X $.\n\\end{lemma}\n\n\\begin{proof}\nFirst observe that certainly any element of $ \\I\\br{X} $ vanishes at all points of $ X $, so $ X \\subseteq \\Z\\br{\\I\\br{X}} $. On the other hand, since $ X $ is an affine algebraic set, $ X = \\Z\\br{J} $ for some ideal $ J $. Want $ \\Z\\br{\\I\\br{X}} \\subseteq X $, that is $ \\Z\\br{\\I\\br{\\Z\\br{J}}} \\subseteq \\Z\\br{J} $. Since any $ P \\in J $ vanishes on $ X $ we have $ J \\subseteq \\I\\br{\\Z\\br{J}} $. Then $ \\Z\\br{\\I\\br{X}} \\subseteq \\Z\\br{J} = X $, so $ X = \\Z\\br{\\I\\br{X}} $.\n\\end{proof}\n\nThis need not be equal for $ X $ arbitrary. If $ X $ is not an affine algebraic set, then $ \\Z\\br{\\I\\br{X}} $ is the smallest affine algebraic set containing $ X $. If $ Y = \\Z\\br{J} $ contains $ X $, then $ \\I\\br{Y} \\subseteq \\I\\br{X} $, so $ \\Z\\br{\\I\\br{X}} \\subseteq \\Z\\br{\\I\\br{Y}} = Y $. We call $ \\Z\\br{\\I\\br{X}} $ the \\textbf{Zariski closure} of $ X $. This operation is the closure operation for a topology on $ \\AA_K^n $ called the \\textbf{Zariski topology} which we will define later.\n\n\\begin{example*}\nLet\n$$ X = \\cbr{\\br{n, 0} \\st n \\in \\ZZ} \\subseteq \\AA_\\CC^2, \\qquad \\I\\br{X} = \\cbr{P \\in \\CC\\sbr{X, Y} \\st \\forall n \\in \\ZZ, \\ P\\br{n, 0} = 0}. $$\nThen $ P\\br{X, 0} \\in \\CC\\sbr{X} $ is a polynomial that vanishes at every $ n \\in \\ZZ $, so $ P\\br{X, 0} = 0 $. So $ Y \\mid P\\br{X, Y} $, so $ \\I\\br{X} = \\abr{Y} $. Thus $ \\Z\\br{\\I\\br{X}} $ is the $ Y $-axis.\n\\end{example*}\n\nOne might thus hope that similarly $ \\I\\br{\\Z\\br{J}} = J $ for any ideal $ J $ of $ K\\sbr{X_1, \\dots, X_n} $. This cannot be literally true, for the following reason. Recall that\n$$ \\rad I = \\cbr{r \\in K\\sbr{X_1, \\dots, X_n} \\st \\exists m, \\ r^m \\in I}. $$\nAn ideal $ I $ is \\textbf{radical} if $ \\rad I = I $.\n\n\\begin{note*}\nIn fact, for any $ T $, the ideal $ \\I\\br{T} $ is a radical ideal, since\n$$ P^m \\in \\I\\br{T} \\qquad \\iff \\qquad \\forall t \\in T, \\ P\\br{t}^m = 0 \\qquad \\iff \\qquad \\forall t \\in T, \\ P\\br{t} = 0 \\qquad \\iff \\qquad P \\in \\I\\br{T}. $$\nThus if $ J $ is not a radical ideal we cannot have $ \\I\\br{\\Z\\br{J}} = J $.\n\\end{note*}\n\n\\pagebreak\n\nHowever, one does have the following.\n\n\\begin{theorem}[Hilbert's Nullstellensatz]\n\\label{thm:13.2.5}\nLet $ K $ be an algebraically closed field. For any ideal $ J $ of $ K\\sbr{X_1, \\dots, X_n} $, we have $ \\I\\br{\\Z\\br{J}} = \\rad J $.\n\\end{theorem}\n\n\\begin{note*}\nThis can only possibly hold over algebraically closed fields.\n\\end{note*}\n\n\\begin{example*}\nFor $ n = 1 $, let $ P\\br{X} \\in K\\sbr{X} $. Then $ \\I\\br{\\Z\\br{P\\br{X}}} = \\rad P\\br{X} \\ne R $, unless $ P\\br{X} $ is constant, so $ \\Z\\br{P\\br{X}} \\ne \\emptyset $.\n\\end{example*}\n\n\\begin{corollary}\nIf $ J \\in K\\sbr{X_1, \\dots, X_n} $ an ideal is not the unit ideal, then $ \\Z\\br{J} \\ne \\emptyset $.\n\\end{corollary}\n\n\\begin{proof}\n$ \\I\\br{\\Z\\br{J}} = \\rad J \\ne \\abr{1} $, so $ \\Z\\br{J} \\ne \\emptyset $.\n\\end{proof}\n\n\\lecture{29}{Monday}{10/12/18}\n\nWe will prove this theorem later on. For now, we note that since $ \\rad \\rad J = \\rad J $ for all ideals $ J $, the maps $ X \\mapsto \\I\\br{X} $ and $ J \\mapsto \\Z\\br{J} $ define a bijection\n$$ \\correspondence{\\text{radical ideals} \\ J \\subseteq K\\sbr{X_1, \\dots, X_n}}{\\text{affine algebraic subsets of} \\ \\AA_K^n}. $$\nThis bijection is inclusion-reversing, and it is interesting to ask what geometric properties of $ X $ are carried to algebraic properties of $ \\I\\br{X} $ via this bijection. For instance, the following holds.\n\n\\begin{proposition}\nLet $ J \\subseteq K\\sbr{X_1, \\dots, X_n} $ be a radical ideal. Then $ J $ is maximal if and only if $ \\Z\\br{J} $ is a single point.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ \\Z\\br{J} = \\cbr{p} $, where $ p = \\br{p_1, \\dots, p_n} $. Then $ \\I\\br{\\Z\\br{J}} = \\I\\br{\\cbr{p}} $, so $ X_1 - p_1, \\dots, X_n - p_n \\in \\I\\br{\\cbr{p}} $. Then $ \\mmm_p = \\abr{X_1 - p_1, \\dots, X_n - p_n} \\subseteq \\I\\br{\\cbr{p}} \\subsetneq K\\sbr{X_1, \\dots, X_n} $. Note that $ \\mmm_p $ is maximal. Consider the map\n$$ \\function{K\\sbr{X_1, \\dots, X_n}}{K}{X_i}{p_i}, $$\nand $ K \\mapsto K $. The kernel of this map is $ \\abr{X_i - p_i} = \\mmm_p $, so $ K\\sbr{X_1, \\dots, X_n} / \\mmm_p \\cong K $. So $ \\mmm_p $ is maximal, must have $ \\I\\br{\\cbr{p}} = \\mmm_p $. Thus $ J = \\rad J = \\I\\br{\\Z\\br{J}} = \\mmm_p $. Conversely, suppose $ J $ is maximal. Then $ \\Z\\br{J} \\ne \\emptyset $, since $ \\I\\br{\\Z\\br{J}} = J $ but $ \\I\\br{\\emptyset} $ is the unit ideal. So there exists $ p \\in \\Z\\br{J} $ such that $ J = \\I\\br{\\Z\\br{J}} \\subseteq \\I\\br{\\cbr{p}} = \\mmm_p $, so $ J = \\mmm_p $.\n\\end{proof}\n\n\\begin{proposition}\nLet $ J_1, J_2 \\subseteq K\\sbr{X_1, \\dots, X_n} $ be ideals. Then\n$$ \\Z\\br{J_1 + J_2} = \\Z\\br{J_1} \\cap \\Z\\br{J_2}, \\qquad \\Z\\br{J_1 \\cap J_2} = \\Z\\br{J_1} \\cup \\Z\\br{J_2}. $$\n\\end{proposition}\n\n\\begin{proof}\nLet $ p \\in \\AA_K^n $ be a point of $ \\Z\\br{J_1 + J_2} $. Then every element of $ J_1 + J_2 $ vanishes at $ p $, so since $ J_1 \\subseteq J_1 + J_2 $ we have that $ p \\in \\Z\\br{J_1} $. Similarly $ p \\in \\Z\\br{J_2} $, so $ \\Z\\br{J_1 + J_2} \\subseteq \\Z\\br{J_1} \\cap \\Z\\br{J_2} $. Conversely, if $ p \\in \\Z\\br{J_1} \\cap \\Z\\br{J_2} $, then for any element $ Q $ of $ J_1 + J_2 $ we can write $ Q = R + S $ for $ R \\in J_1 $ and $ S \\in J_2 $. Then $ R\\br{p} = S\\br{p} = 0 $, so $ Q\\br{p} = 0 $ and $ p \\in \\Z\\br{J_1 + J_2} $. The proof that $ \\Z\\br{J_1 \\cap J_2} = \\Z\\br{J_1} \\cup \\Z\\br{J_2} $ is similar, and will be omitted.\n\\end{proof}\n\n\\begin{corollary}\nConversely, if $ X $ and $ Y $ are affine algebraic sets, then\n$$ \\I\\br{X \\cap Y} = \\rad \\br{\\I\\br{X} + \\I\\br{Y}}, \\qquad \\I\\br{X \\cup Y} = \\I\\br{X} \\cap \\I\\br{Y}. $$\n\\end{corollary}\n\n\\begin{proof}\nFollows from $ \\Z\\br{J_1 + J_2} = \\Z\\br{J_1} \\cap \\Z\\br{J_1} $ and using the Nullstellensatz $ \\I\\br{\\Z\\br{J}} = \\rad J $.\n\\end{proof}\n\n\\begin{definition}\nAn affine algebraic set $ X $ is \\textbf{irreducible} if $ X $ cannot be written as the union $ Y \\cup Z $ of two proper affine algebraic subsets $ Y $ and $ Z $, that is $ Y, Z \\ne X, \\emptyset $.\n\\end{definition}\n\n\\begin{example*}\nLet\n$$ X = \\Z\\br{\\cbr{y\\br{y - x\\br{x - 1}\\br{x + 1}}}}. $$\nThen\n$$ X = \\Z\\br{\\cbr{y}} \\cup \\Z\\br{\\cbr{y - x\\br{x - 1}\\br{x + 1}}}, $$\nso $ X $ is not irreducible.\n\\end{example*}\n\n\\pagebreak\n\n\\begin{proposition}\nAn affine algebraic set $ X $ is irreducible if and only if $ \\I\\br{X} $ is prime.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ X $ is irreducible, and let $ f $ and $ g $ be elements of $ K\\sbr{X_1, \\dots, X_n} $ such that $ fg \\in \\I\\br{X} $. Then $ X \\subseteq \\Z\\br{fg} = \\Z\\br{f} \\cap \\Z\\br{g} $. In particular $ X = \\br{X \\cap \\Z\\br{f}} \\cup \\br{X \\cap \\Z\\br{g}} $. Since $ X $ is irreducible we must have $ X = X \\cap \\Z\\br{f} \\subseteq \\Z\\br{f} $, in which case $ f \\in \\I\\br{X} $, or $ X = X \\cap \\Z\\br{g} \\subseteq \\Z\\br{g} $, in which case $ g \\in \\I\\br{X} $. So $ \\I\\br{X} $ is prime. Conversely, suppose $ \\I\\br{X} $ is prime, and that $ X = Y \\cup Z $, where $ Y $ and $ Z $ are affine algebraic subsets of $ X $. Then $ \\I\\br{X} = \\I\\br{Y} \\cap \\I\\br{Z} $, so $ \\I\\br{X} $ contains the product $ \\I\\br{Y}\\I\\br{Z} $. Since $ \\I\\br{X} $ is prime, either $ \\I\\br{X} $ contains $ \\I\\br{Y} $, in which case $ X = Y $, or $ \\I\\br{X} $ contains $ \\I\\br{Z} $, in which case $ X = Z $.\n\\end{proof}\n\n\\begin{definition}\nAn affine algebraic set $ X $ has \\textbf{Krull dimension} $ d $ if $ d $ is the length of the largest increasing tower of irreducible affine algebraic subsets $ X_0 \\subsetneq \\dots \\subsetneq X_d \\subseteq X $.\n\\end{definition}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Points have dimension zero.\n\\item In $ \\AA^1 $, affine algebraic sets are zeros of polynomials, so irreducibles in $ \\AA^1 $ are points on $ \\AA^1 $, so $ \\AA^1 $ has Krull dimension one.\n\\item In fact, $ \\AA^n $ has Krull dimension $ n $ for every $ n $.\n\\end{itemize}\n\\end{example*}\n\n\\begin{definition}\nA ring $ R $ has \\textbf{Krull dimension} $ d $ if $ d $ is the length of the largest increasing tower $ \\ppp_0 \\subsetneq \\dots \\subsetneq \\ppp_d $ of prime ideals of $ R $.\n\\end{definition}\n\n\\begin{example*}\nIf $ R $ is a domain,\n\\begin{itemize}\n\\item dimension zero implies that $ R $ is a field, and\n\\item dimension one implies that every nonzero prime ideal is maximal.\n\\end{itemize}\n\\end{example*}\n\nThe Hilbert basis theorem then gives us the following.\n\n\\begin{proposition}\nLet $ X $ be an affine algebraic set. Then $ X $ can be written uniquely as a finite union $ X_1 \\cup \\dots \\cup X_r $ such that each $ X_i $ is an irreducible affine algebraic set and no $ X_i $ is contained in $ X_j $ for $ i \\ne j $.\n\\end{proposition}\n\n\\begin{proof}\nWe first show that if $ X $ is not irreducible, then $ X $ can be written as $ Y \\cup Z $ with $ Y $ irreducible and $ Z \\ne X $ affine algebraic. Certainly we can write $ X = Y_1 \\cup Z_1 $ with $ Y_1 $ and $ Z_1 $ proper subsets of $ X $. If $ Y_1 $ is irreducible we are done. Otherwise write $ Y_1 = Y_2 \\cup Z_2 $. Again, if $ Y_2 $ is irreducible we can write $ X = Y_2 \\cup \\br{Z_1 \\cup Z_2} $ and we are done. Otherwise, supposing this never terminates, we obtain\n$$ Y_1 \\supsetneq Y_2 \\supsetneq \\dots, \\qquad \\I\\br{Y_1} \\subsetneq \\I\\br{Y_2} \\subsetneq \\dots, $$\nwhich is impossible since $ K\\sbr{X_1, \\dots, X_n} $ is Noetherian. Now given $ X $, if $ X $ is not irreducible we can write $ X = Y_1 \\cup Z_1 $ with $ Y_1 $ irreducible and $ Z_1 \\ne X $. If $ Z_1 $ is not irreducible we write $ Z_1 = Y_2 \\cup Z_2 $ with $ Y_2 $ irreducible and $ Z_2 \\ne Z_1 $. If this process ever terminates we have written $ X $ as a finite union of irreducibles. Otherwise, we have\n$$ Z_1 \\supsetneq Z_2 \\supsetneq \\dots, $$\nand as above this is impossible since $ K\\sbr{X_1, \\dots, X_n} $ is Noetherian. For uniqueness, suppose we have $ X = Y_1 \\cup \\dots \\cup Y_r $ and $ X = Z_1 \\cup \\dots \\cup Z_s $, with the $ Y_i $ and $ Z_j $ irreducible, and with no $ Y_i $, or $ Z_i $, contained in $ Y_j $, or $ Z_j $, when $ i \\ne j $. Then $ \\I\\br{Y_i} $ and $ \\I\\br{Z_i} $ are prime for all $ i $. In particular $ \\I\\br{Y_1} $ is prime. Since $ Y_1 \\subset X $, $ \\I\\br{X} \\subset \\I\\br{Y_1} $, so $ \\I\\br{Y_1} $ contains $ \\I\\br{Z_1 \\cup \\dots \\cup Z_s} = \\I\\br{Z_1} \\cap \\dots \\cap \\I\\br{Z_s} $. It follows that $ \\I\\br{Y_1} $ contains the product $ \\I\\br{Z_1} \\dots \\I\\br{Z_s} $. Thus $ \\I\\br{Y_1} $ contains $ \\I\\br{Z_j} $ for some $ j $. Similarly $ \\I\\br{Z_j} $ contains $ \\I\\br{Y_i} $ for some $ i $. Then $ \\I\\br{Y_1} \\subseteq \\I\\br{Y_i} $, so $ Y_i \\subseteq Y_1 $ and we must have $ i = 1 $. Then $ Y_1 = Z_j $. Proceeding we show that each $ Y_i $ is equal to some $ Z_j $ and vice versa, proving uniqueness.\n\\end{proof}\n\nTranslating this to a statement about ideals, we find the following.\n\n\\begin{corollary}\nEvery radical ideal in $ K\\sbr{X_1, \\dots, X_n} $ is uniquely expressible as a finite intersection of prime ideals, none of which contains any of the others.\n\\end{corollary}\n\nThis is a special case of a very general ring-theoretic phenomenon known as \\textbf{primary decomposition}, which was discovered via the sort of geometric considerations we see above.\n\n\\lecture{30}{Wednesday}{12/12/18}\n\nLecture 30 is a problems class.\n\n\\pagebreak\n\n\\appendix\n\n\\section{Proof of the Nullstellensatz}\n\nThe ideas above rely heavily on the correspondence between radical ideals and affine algebraic sets, and thus ultimately on the Nullstellensatz. We now give a proof of the Nullstellensatz. The first step is to show that to prove the Nullstellensatz it suffices to prove the following, seemingly much weaker, special case, the so-called weak Nullstellensatz.\n\n\\begin{theorem}[Weak Nullstellensatz]\n\\label{thm:13.3.1}\nLet $ I $ be an ideal of $ K\\sbr{X_1, \\dots, X_n} $ such that $ \\Z\\br{I} $ is empty. Then $ I $ is the unit ideal.\n\\end{theorem}\n\n\\begin{proof}[Proof of Theorem \\ref{thm:13.2.5}]\nLet $ J $ be an ideal of $ K\\sbr{X_1, \\dots, X_n} $. Clearly $ \\I\\br{\\Z\\br{J}} $ contains $ \\rad J $. We must show the reverse containment. Let $ P $ be an element of $ \\I\\br{\\Z\\br{J}} $. We must show that $ P^m $ lies in $ J $ for some $ m $. Consider the ring $ K\\sbr{X_1, \\dots, X_n, T} $, and let $ \\widetilde{J} $ be the ideal of $ K\\sbr{X_1, \\dots, X_n, T} $ generated by the polynomials in $ I $, together with the polynomial $ 1 - TP\\br{X_1, \\dots, X_n} $. Consider the subset\n$$ \\Z\\br{\\widetilde{J}} = \\cbr{\\br{x_1, \\dots, x_n, t} \\in K^{n + 1} \\st \\forall Q \\in J, \\ Q\\br{x_1, \\dots, x_n} = 0, \\ 1 - tP\\br{x_1, \\dots, x_n} = 0} \\subseteq \\AA_K^{n + 1}. $$\nIn particular if $ \\br{x_1, \\dots, x_n, t} $ lies in $ \\Z\\br{\\widetilde{J}} $, then $ \\br{x_1, \\dots, x_n} $ lies in $ \\Z\\br{J} $. Since $ P \\in \\I\\br{\\Z\\br{J}} $ we have $ P\\br{x_1, \\dots, x_n} = 0 $, so $ 1 - tP\\br{x_1, \\dots, x_n} = 1 $. Thus $ \\Z\\br{\\widetilde{J}} $ is empty. By the weak Nullstellensatz, $ \\widetilde{J} $ is the unit ideal, so there are polynomials $ Q_0, \\dots, Q_s $ in $ K\\sbr{X_1, \\dots, X_n, T} $, and $ R_1, \\dots, R_s \\in I $, such that $ 1 = Q_0\\br{1 - TP} + Q_1R_1 + \\dots + Q_sR_s $. Consider the map\n$$ \\function{K\\sbr{X_1, \\dots, X_n, T}}{K\\sbr{X_1, \\dots, X_n, \\tfrac{1}{P}}}{T}{\\tfrac{1}{P}}, $$\nand $ K\\sbr{X_1, \\dots, X_n} \\mapsto K\\sbr{X_1, \\dots, X_n} $. Applying this map we find that\n$$ 1 = Q_1\\br{X_1, \\dots, X_n, \\tfrac{1}{P}}R_1\\br{X_1, \\dots, X_n} + \\dots + Q_s\\br{X_1, \\dots, X_n, \\tfrac{1}{P}}R_s\\br{X_1, \\dots, X_n}, $$\nin $ K\\sbr{X_1, \\dots, X_n, \\tfrac{1}{P}} $. Multiplying by a sufficiently large power of $ P $, we get\n$$ P^m = P^mQ_1\\br{X_1, \\dots, X_n, \\tfrac{1}{P}}R_1\\br{X_1, \\dots, X_n} + \\dots + P^mQ_s\\br{X_1, \\dots, X_n, \\tfrac{1}{P}}R_s\\br{X_1, \\dots, X_n}. $$\nSince for $ m $ sufficiently large $ P^mQ_s\\br{X_1, \\dots, X_n, \\tfrac{1}{P}} $ is a polynomial in the $ X_i $ we find that $ P^m \\in I $ for $ m $ sufficiently large.\n\\end{proof}\n\nIt remains to prove the weak Nullstellensatz. This requires some new ideas. The following approach is due to Emmy Noether.\n\n\\begin{definition}\nLet $ R $ be a $ K $-algebra, that is a ring together with a map $ K \\to R $. We say that elements $ y_1, \\dots, y_s $ of $ R $ are \\textbf{algebraically independent} over $ K $ if there is no nonzero polynomial $ P\\br{X_1, \\dots, X_s} \\in K\\sbr{X_1, \\dots, X_s} $ such that $ P\\br{y_1, \\dots, y_s} = 0 $. Equivalently, $ y_1, \\dots, y_s $ are algebraically independent if and only if the map\n$$ \\function{K\\sbr{X_1, \\dots, X_s}}{R}{X_i}{y_i} $$\nis injective.\n\\end{definition}\n\n\\begin{proposition}[Noether's normalisation lemma]\nLet $ K $ be a field, and let $ R $ be a finitely generated $ K $-algebra. Then there exists $ s \\in \\ZZ_{\\ge 0} $, and algebraically independent elements $ y_1, \\dots, y_s $ of $ R $ such that $ R $ is integral over $ K\\sbr{y_1, \\dots, y_s} $.\n\\end{proposition}\n\n\\pagebreak\n\n\\begin{proof}\nWrite $ R = K\\sbr{X_1, \\dots, X_m} / I $. We proceed by induction on $ m $. The base case $ m = 0 $ is clear. Fix $ m $ and assume the claim is true for $ m - 1 $. If $ I = 0 $ then the statement is also clear, with $ y_i = X_i $ for all $ i $. Otherwise let $ P\\br{X_1, \\dots, X_m} \\in I $. Renumbering the variables if necessary, we may assume $ P $ is a nonconstant polynomial in $ X_m $ with coefficients in $ X_1, \\dots, X_{m - 1} $. Let $ d $ be the total degree of $ P $. That is, the largest value of $ a_1 + \\dots + a_m $ for any monomial $ cX_1^{a_1} \\dots X_m^{a_m} $ appearing in $ P $. Let $ n_i = \\br{1 + d}^i $ and $ Y_i = X_i - X_m^{n_i} $ for each $ i $ in $ 1, \\dots, m - 1 $. Define\n$$ Q\\br{X_1, \\dots, X_m} = P\\br{X_1 + X_m^{n_1}, \\dots, X_{m - 1} + X_m^{n_{m - 1}}, X_m}. $$\nThen $ Q\\br{Y_1, \\dots, Y_{m - 1}, X_m} $ is zero in $ R $. We now claim that, up to a factor $ c \\in K^* $, $ Q\\br{X_1, \\dots, X_m} $ is monic when considered as a polynomial in $ X_m $. Let $ cX_1^{a_1} \\dots X_m^{a_m} $ be a monomial appearing in $ P\\br{X_1, \\dots, X_m} $. This monomial contributes the terms\n$$ c\\br{X_1 - X_m^{n_1}}^{a_1} \\dots \\br{X_{m - 1} - X_m^{n_{m - 1}}}^{a_{m - 1}}X_m^{a_m} $$\nto $ Q\\br{X_1, \\dots, X_m} $. Moreover, each $ n_i $ is greater than $ d $ and hence greater than the sum of the $ a_j $. It is thus clear that the term of highest degree in the above expression is $ cX_m^N $, where\n$$ N = n_1a_1 + \\dots + n_{m - 1}a_{m - 1} + a_m = a_1\\br{1 + d} + \\dots + a_{m - 1}\\br{1 + d}^{m - 1} + a_m. $$\nSince $ 1 + d $ is greater than the sum of the exponents $ a $ appearing in any monomial of $ P\\br{X_1, \\dots, X_m} $, the terms $ cX_m^N $ appearing in different monomials are all of different degree and thus cannot cancel. It follows that the term of the form $ cX_m^N $ of highest degree is the highest degree term in $ Q\\br{X_1, \\dots, X_m} $, so that $ \\br{1 / c}Q\\br{X_1, \\dots, X_m} $ is monic in $ X_m $. Write\n$$ \\dfrac{1}{c}Q\\br{X_1, \\dots, X_m} = \\sum_{n = 0}^N H_n\\br{X_1, \\dots, X_{m - 1}}X_m^n. $$\nSince $ Q\\br{Y_1, \\dots, Y_{m - 1}, X_m} = 0 $, we have $ \\sum_{n = 0}^N H_n\\br{Y_1, \\dots, Y_{m - 1}}X_m = 0 $. That is, $ X_m $ is integral over the subalgebra $ S = K\\sbr{Y_1, \\dots, Y_{m - 1}} $ of $ R $. Since $ X_m $ generates $ R $ over $ S $, it follows that $ R $ is integral over $ S $. On the other hand we have a map\n$$ \\function{K\\sbr{Z_1, \\dots, Z_{m - 1}}}{S}{Z_i}{Y_i}. $$\nLet $ J $ be the kernel. Then $ S = K\\sbr{Z_1, \\dots, Z_{m - 1}} / J $. Then by the inductive hypothesis there are algebraically independent elements $ y_1, \\dots, y_s \\in S $ such that $ S $ is integral over $ K\\sbr{y_1, \\dots, y_s} $. Since $ R $ is integral over $ S $, it follows that $ R $ is integral over $ K\\sbr{y_1, \\dots, y_s} $ and we are done.\n\\end{proof}\n\n\\begin{corollary}\nEvery maximal ideal of $ K\\sbr{X_1, \\dots, X_n} $ is of the form\n$$ \\abr{X_1 - p_1, \\dots, X_n - p_n}, \\qquad p_1, \\dots, p_n \\in K. $$\n\\end{corollary}\n\n\\begin{proof}\nLet $ I $ be a maximal ideal of $ K\\sbr{X_1, \\dots, X_n} $, and consider $ R = K\\sbr{X_1, \\dots, X_n} / I $. Then $ R $ is a field. On the other hand, by Noether normalisation, there exist $ y_1, \\dots, y_s $ algebraically independent such that $ R $ is integral over $ S = K\\sbr{y_1, \\dots, y_s} $. Let $ x $ be a nonzero element of $ K\\sbr{y_1, \\dots, y_s} $. Then $ x^{-1} $ lies in $ R $. Since $ R $ is integral over $ S $ there is a monic polynomial $ P $ with coefficients in $ S $ such that $ P\\br{x^{-1}} = 0 $. We thus have $ \\br{x^{-1}}^d = \\sum_{i = 0}^{d - 1} a_ix^{-i} $ for $ a_i \\in S $. Multiplying by $ x^{d - 1} $ we find that $ x^{-1} = \\sum_{i = 0}^{d - 1} a_ix^{d - i - 1} $, so that $ x^{-1} $ is also in $ S $. Thus $ S $ is a field. But since the $ y_i $ are algebraically independent, $ S $ is also a polynomial ring in $ s $ variables. Since no such ring is a field unless $ s = 0 $ we must have $ s = 0 $ and $ R $ is integral over $ K $. But then $ R $ is a finite-dimensional $ K $-vector space, hence a finite extension of $ K $. Since $ K $ is algebraically closed, the inclusion of $ K $ in $ R $ is an isomorphism. Thus for each $ i $ there is an element $ p_i $ of $ K $ such that $ X_i $ is equal to $ p_i $ in $ R $. Then $ X_i - p_i $ is in $ I $ for all $ i $, so $ I $ contains the ideal $ \\abr{X_1 - p_1, \\dots, X_n - p_n} $. Since the latter is clearly maximal it must be equal to $ I $.\n\\end{proof}\n\n\\begin{proof}[Proof of Theorem \\ref{thm:13.3.1}]\nLet $ I $ be an ideal of $ K\\sbr{X_1, \\dots, X_n} $ such that $ I $ is not the unit ideal. Then $ I $ is contained in some maximal ideal of $ K\\sbr{X_1, \\dots, X_n} $, and thus in some ideal of the form $ \\abr{X_1 - p_1, \\dots, X_n - p_n} $. Then $ \\br{p_1, \\dots, p_n} $ lies in $ \\Z\\br{I} $.\n\\end{proof}\n\n\\end{document}", "meta": {"hexsha": "1264d607da704ef541c3d7fd8876a31d4ca38081", "size": 203002, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "M3P8 Algebra III/M3P8.tex", "max_stars_repo_name": "icl-notes/GANT", "max_stars_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "M3P8 Algebra III/M3P8.tex", "max_issues_repo_name": "icl-notes/GANT", "max_issues_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "M3P8 Algebra III/M3P8.tex", "max_forks_repo_name": "icl-notes/GANT", "max_forks_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-02-23T20:00:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-13T18:41:07.000Z", "avg_line_length": 80.3650039588, "max_line_length": 1763, "alphanum_fraction": 0.6282105595, "num_tokens": 73748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.4485355337088905}}
{"text": "\\documentclass{article}\n\\usepackage{mathrsfs}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{graphicx}\n\\usepackage{amsfonts}\n\\DeclarePairedDelimiter{\\ceil}{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter{\\floor}{\\lfloor}{\\rfloor}\n\n\\begin{document}\n\\begin{center}\n\\textbf{\\huge{Week 8}}\n\\end{center}\n\n\\section{Achievability in channel coding theorem for BSC}\n\nFor any $\\epsilon > 0$, there exists a sequence of codes $\\mathscr{C}$(one for each x) with rate $R: 1 - H_2(p)- \\epsilon$ and P(error)$\\to 0$ as $x \\to \\infty$.\n\nProof: We will use a `random' code. Entire argument is for a fixed value of n. We will assume n is large (so that number of flips is np).\n\nWe will pick a code $\\mathscr{C}_n$ of rate $R= 1-H_2(p)- \\epsilon$. So we want $|\\mathscr{C}_n|= 2^{nR}.$ (such that nR is an integer)\n\n\\subsection{Random code generation}\n\\begin{itemize}\n    \\item Pick each codeword in $\\mathscr{C}_n$ from $\\{ 0,1\\}^n$ uniformly at random. Then P(codeword is specific n-length sequence)$= \\frac{1}{2}^n$\n    \\item Repeat this process $2^{nR}$ times.\n\\end{itemize}\n\nWe get,\n$$ |\\mathscr{C}_n|=2^{nR}$$\n\nNow we want to prove,\n$$ P(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\leq  2^{-n \\delta} \\qquad \\forall \\qquad \\underbar{c} \\in \\mathscr{C}_n , \\delta > 0$$\n\nFor getting a handle on the probability of error, we have to first define the decoding function (i.e. how is estimate $\\hat{\\underbar{c}}$ calculated from a particular recieved vector).\n\nLet the decoding function be denoted by,\n$$D : \\{ 0,1 \\}^n \\to \\mathscr{C}_n$$\n\nFor any $y \\in \\{ 0,1 \\}^n$,\n$$ D(y):= \\text{argmax}_{\\underbar{c}' \\in \\mathscr{C}_n} P(y|\\underbar{c}')$$\n\nD(y) is the estimate $\\hat{\\underbar{c}}$ of the code when recieved vector is y. This is called the ``Maximum likelihood decoding rule''.\n\nTo show that $P(\\hat{\\underbar{c}} \\neq \\underbar{c})$ is small, we will show that $P(D(y) \\neq \\underbar{c})$ is small where y is the random vector when $\\underbar{c}$ is transmitted.\n\nFor the above decoder, we want to show $P( \\hat{\\underbar{c}} \\neq \\underbar{c}) \\leq 2^{-n \\delta}$, $\\delta >0$.\n\nFor any specific $\\underbar{c}$, we want to find an upper limit for $P(\\hat{\\underbar{c}} \\neq \\underbar{c})$. This occurs when $\\underbar{c}$ is not the closest codeword to y.\n\nBy law of large numbers,\n$$ d_H (y, \\underbar{c}) \\approx np$$\n\n$$ B(y,np)= \\{ \\underbar{x} \\in \\{ 0,1 \\}^n : d_H (\\underbar{x}, \\underbar{y}) \\leq np \\}$$\nIf there are other codewords within this ball B(y,np), the decoder can make an error. Else it will not make an error.\n\n\\begin{align*}\nP(\\hat{\\underbar{c}} \\neq \\underbar{c}) &\\leq P(\\underbar{c}' \\in B(y,np): \\hat{\\underbar{c}} \\neq \\underbar{c} ) \\\\\n&\\leq \\frac{|B(y,np)|}{2^n} \\\\\n&\\leq \\frac{\\sum_{i=0}^{np} {n \\choose i}}{2^n} = \\frac{{n \\choose np} + \\sum_{i=0}^{np-1} {n \\choose i}}{2^n} \\\\\n&\\approx \\frac{2^{n H_2(p)}}{2^n} = 2^{-n(1-H_2(p))}\n\\end{align*}\nAs n grows large, this value will be dominated by the first term of value $n \\choose np$.\n\\begin{equation}\n    \\Rightarrow P(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\leq 2^{-n(1-H_2(p))}\n\\end{equation}\n\n(we assume p $<$ 0.5, otherwise we can change the channel to BSC(p') where p'= 1-p)\n\nWe would like to show this result (1) for all codewords rather than specific codewords.\nWe want,\n$$ P \\left( \\bigcup_{\\underbar{c} \\in \\mathscr{C}}(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\right) \\leq 2^{-n \\delta} \\qquad \\delta > 0$$\nThis is known as the union bound.\n\n\\subsection{Union bound}\nWe know,\n\\begin{align*}\n    P \\left( \\bigcup_{\\underbar{c} \\in \\mathscr{C}_n}(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\right) &\\leq \\sum_{ \\underbar{c} \\in \\mathscr{C}_n} P(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\\\\n    &\\leq P \\left( \\bigcup_{\\underbar{c} \\in \\mathscr{C}}(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\right) \\leq \\sum_{ \\underbar{c} \\in \\mathscr{C}_n} 2^{-n(1-H_2(p))} \\\\\n    &\\leq 2^{nR}2^{-n(1-H_2(p))} \\\\\n    &\\leq 2^{-n(1-H_2(p)-R)} \\\\\n    &\\leq 2^{-n\\varepsilon}\n\\end{align*}\n$$ \\Rightarrow P(\\hat{\\underbar{c}} \\neq \\underbar{c}) \\leq 2^{-n\\epsilon} \\quad \\forall \\underbar{c} \\in \\mathscr{C}_n$$\n\nHence proved.\n\n\nIn practice using random codes and minimum distance/likelihood decoder (MDD/MLD) for BSC is very complex (complexity of decoder/encoder is very high). Hence, we use structured codes which have low encoding/decoding performance, mainly linear codes.\n\n\\section{Linear codes}\nThe random code construction is not really useful for implementation as:\n\\begin{enumerate}\n    \\item we could end up with a bad code due to the random construction.\n    \\item Encoding and decoding complexity is very large.\n\\end{enumerate}\n\nSo we want codes which are good in rate and P(error) and also have reasonable encoding/decoding complexity. An important class of codes having above properties are linear codes.\n\nWe will look at some simple examples of liner codes for binary channel with worst-case/bounded error model. Construction of codes which are useful for implementation is dealt with in coding theory.\n\n\\subsection{Worst case/bounded error model for binary channel}\n\nLet t, n be some integers such that t $\\leq $ n.\n\nWe input some $x \\in \\{ 0,1 \\}^n$ to a binary channel and we get $y \\in \\{ 0,1\\}^n$. $d_H(y,x)\\leq t$ $\\Rightarrow$ There are atmost $t$ positions where recieved vector y is different from transmitted vector x.\n\nFor this channel, we want to design a code $\\mathscr{C} \\subseteq \\{ 0,1\\}^n$ (such that all upto t errors are corrected).\n\n\\subsubsection{Example}\n\n\nNow, suppose $\\mathscr{c}= \\{ 0,1 \\}^n$, t=1.\n\nLet us construct a situation in which the decoder will surely make an error in decoding.\n\nSuppose $\\underbar{c}=(1,\\cdots,1) \\in \\mathscr{C}$ was transmitted.\n\nSuppose $y=(0,1,\\cdots,1)$, $y \\in \\mathscr{c}$. (we will assume min Hamming distance decoder $\\hat{\\underbar{c}}= argmin_{\\mathscr{C}} d_H(y, \\underbar{c})$)\n\nHence iff $\\underbar{c}=y$,\n$$ min_{\\underbar{c} \\in \\mathscr{C}} d_H(y,\\underbar{c}) = 0$$\n\n$\\Rightarrow$ Decoding error has happened as $\\hat{\\underbar{c}} \\neq \\underbar{c}$ (estimate and transmitted are not same).\n\nSo correcting any $t \\geq 1$ error requires us to pick proper subsets of $\\{ 0,1\\}^n$.\n\nBut we also want to pick large subsets of $\\{ 0,1\\}^n $ as the code because we want to maximize $R= \\frac{\\log |\\mathscr{C}|}{n}$ bits/channel use.\n\nBut picking large $\\mathscr{C}$, codewords are closer in Hamming distance, which means that it is more likely to create decoding errors.\n\n\\subsection{Lemma}\nLet $\\mathscr{C} \\subseteq \\{ 0,1\\}^n$ be chosen.\nDefine,\n$$ d_{min}(\\mathscr{C})= min_{c,c' \\in \\mathscr{C} \\& c' \\neq c} d_H(c,c')$$\n\n$\\mathscr{C}$ can be correct upto t errors if and only if $d_{min}(\\mathscr{C})\\geq 2t+1$.\n\nProof:\n\nIf part: Given: $\\mathscr{C}$ can correct any t errors.\n\nTo prove: $d_{min}(\\mathscr{C})\\geq 2t+1$.\n\nGiven statement implies any for any c, c' $\\in \\mathscr{C}$.\n\n$$ B_{t}(c)= \\text{Hamming ball of radius t} := \\{ x \\in \\{ 0,1\\}^n : d_H (x,c) \\leq t\\}$$\n\nThen,\n$$ B_t(c) \\bigcap B_t(c') = \\phi$$\n\n$$ \\Rightarrow d_H(c,c') > 2t \\qquad \\forall \\qquad c, c' \\in \\mathscr{C} \\quad c \\neq c'$$\nThis can be proved by contradiction.\n\n\\subsection{Terminology}\n\n\n\\begin{itemize}\n    \\item Size of code $= |\\mathscr{C}|$.\n    \\item Length of code (Block length) $=n$.\n\\end{itemize}\nLemma above relates the error correcting capability of the code with the minimum distance, minimum disctance calculation has nothing to do with the channel.\n\nSuppose code has minimum distance of d, then it can be used on a channel for correcting upto $\\floor{\\frac{d-1}{2}}$.\n\nThis says that code design can be theoretically done independent done of the channel and it's performance can be tested based on it's minimum distance.\n\n\\subsection{Hamming Bound}\n\nHamming bound is the upper bound on the size of code based on a given minimum distance.\n\nLemma: Let $\\mathscr{C}$ be any code with $d_{min}(\\mathscr{C})=d$.\n\nThen,\n\n$$  |\\mathscr{C}| \\leq \\frac{2^n}{\\sum_{i=0}^t {n \\choose i}} \\qquad t= \\floor{\\frac{d-1}{2}}$$\n\nProof follows as we can pick atmost one codeword per ball.\n\n\\subsection{Linear codes (over $\\mathbb{F}_2$)}\n\n$$ \\mathbb{F}_2 \\to (\\{ 0,1\\},+,\\cdot)$$\n\n$$+ \\to XOR$$\n\nDefinition: A linear code over $\\mathbb{F}_2$ of length n is subset $\\mathscr{C} \\subseteq {\\mathbb{F}_2}^n$ and also a subspace of the vector space ${\\mathbb{F}_2}^n$.\n\n$$ \\Rightarrow \\forall a, b \\in \\mathbb{F}_2 \\quad c_1, c_2 \\in \\mathscr{C}$$\n$$ ac_1 + bc_2 \\in \\mathscr{C}$$\nSince only non-trivial values of a, b above are a=1 and b=1.\n\n\n$\\Leftrightarrow \\mathscr{C}$ is a subspace of ${\\mathbb{F}_2}^n$ iff $\\forall c_1, c_2 \\in \\mathscr{C}$, we have $c_1 + c_2 \\in \\mathscr{C}$.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "605b0ae34ccfa525bddc5ec76c4566c43a19c721", "size": 8620, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Source/Notes_week8.tex", "max_stars_repo_name": "thundermage117/Information-Comm.-Notes", "max_stars_repo_head_hexsha": "dfffa27d7216bd231b0e0e5743d7105c64ecf7fc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Source/Notes_week8.tex", "max_issues_repo_name": "thundermage117/Information-Comm.-Notes", "max_issues_repo_head_hexsha": "dfffa27d7216bd231b0e0e5743d7105c64ecf7fc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Source/Notes_week8.tex", "max_forks_repo_name": "thundermage117/Information-Comm.-Notes", "max_forks_repo_head_hexsha": "dfffa27d7216bd231b0e0e5743d7105c64ecf7fc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.5353535354, "max_line_length": 248, "alphanum_fraction": 0.6761020882, "num_tokens": 2985, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.44853553003112123}}
{"text": "\\documentclass{article}\n\\pagestyle{empty}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\setlength{\\oddsidemargin}{0in} \\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{0in} \\setlength{\\textheight}{8.5in}\n\\setlength{\\textwidth}{6.5in}\n\n\\begin{document}\n\\begin{flushleft}\n\t\\bfseries{MATH 260, Linear Systems and Matrices, Fall `14}\\\\\n\t\\bfseries{Activity 1:  Linear equations and systems, geometrically}\\\\\n\t%\\bfseries{Honor Code:} \\hspace{3.5in}\\bfseries{Names:}\\\\\n\\end{flushleft}\n\\begin{flushleft}\n\\vspace{.25in}\n\nIn previous courses you learned about lines and plotting. Today we'll be reviewing a lot of that as a precursor to a more holistic view of systems and LINEar algebra.\n\n\\section*{Problem 1:  Plotting 2 variables}\n\\vspace{0.1in}\n\na) The point-slope form of a line is $y=mx+b$. This is generally easily graphed, most of our equations though will take `standard' form of: $a_1 x + a_2 y = b$. For practice plot the following line below: $3y-6x=6$.\n\n\n\\newpage\n\nb) Now sketch the following pairs of equations, each pair on its own set of axes:\\\\\n(i) $y=3+2x$ and $y=2x-4$\\\\\n(ii) $3x+7=y$ and $y=\\frac{-2}{3}x-1$\\\\\n(iii) $y=2x+1$ and $3y-3=6x$\n\n\\vspace{4in}\n\nc) When we plot lines, the intersection gives a pair of $(x,y)$ values which will satisfy both equations. How many such pairs do each of the above sets of lines have?\\\\\n\n\\vspace{1in}\n\nCan you draw a pair of lines which has exactly TWO solutions? Can you come up with any other counts for solutions besides those depicted above?\n\n\\newpage\nd) Now plot the pair of lines from (b-ii) together with a third line each listed below.\\\\\n(i) First, graph $3x+7=y$ and $y=\\frac{-2}{3}x-1$ together with $y+1=\\frac{-1}{4}x$ \\\\\n(ii) Second (on a new set of axes), graph $3x+7=y$ and $y=\\frac{-2}{3}x-1$ together with $y=\\frac{5}{11}$\\\\\n\n\\vspace{4in}\n\nSimilar to having two equations, 3 equations can produce the same types of solution sets: None, one or infinite. Only two of which you've plotted. Notice that we really only needed two equations to get the interesction for (ii), this is called ``overdetermined.\" Case (i) would be called ``inconsistent\" or ``indeterminite.\" \n\n\\vspace{0.3in}\n\\newpage\n\\section*{Problem 2: Plotting 3 variables}\n\\vspace{0.1in}\nFirst, actually plotting an equation with 3 variables can be very challenging.  We've shown the result (when the equation is linear) below, which creates a plane.\\\\\n\n\\vspace{0.1in}\n\n\\begin{center}\n\\includegraphics[scale=1.0]{planepic.png}\n\\end{center}\n\n\\vspace{0.1in}\n\nLet's look at another system, this time with 3 variables:\\\\\n$x=3z-2y+1$\\\\\n$3z-2y+x=2$\\\\\nSolve this for $x$, $y$, $z$. \\textit{Hint: Solve for $z$ first by substituting the first equation into the second}\\\\\n\n\\vspace{4in}\n\nDid you get numbers for each variable? What do you think is going on here?\n\n\\pagebreak\n\n\\section*{Problem 3}\nSolve the following systems by substitution and/or elimination:\n\n\\vspace{0.2in}\n\na)\n\\begin{align*}\nx+y&=4\\\\\nx-y&=0\n\\end{align*}\n\\vspace{0.1in}\n\n\\vspace{2in}\n\nb)\n\\begin{equation*}\n\\begin{array}{ccccccr}\nx& + &2y&+&z&= &4\\\\\nx& - & y& & &= &2\\\\\n2x&- & y&+&2z&=&3\\\\\n  &  &3y&+& z&=&2\n\\end{array}\n\\end{equation*}\n\n\\end{flushleft}\n\\end{document}", "meta": {"hexsha": "d9b968d581726a3892e3389fd4471eed29f46d7f", "size": 3193, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Fall 2014 - Capaldi A/Activities/Activity01_LinearSystems.tex", "max_stars_repo_name": "Pelonza/PB-LinAlg", "max_stars_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Fall 2014 - Capaldi A/Activities/Activity01_LinearSystems.tex", "max_issues_repo_name": "Pelonza/PB-LinAlg", "max_issues_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fall 2014 - Capaldi A/Activities/Activity01_LinearSystems.tex", "max_forks_repo_name": "Pelonza/PB-LinAlg", "max_forks_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6138613861, "max_line_length": 325, "alphanum_fraction": 0.7099906044, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.4485252395020172}}
{"text": "%%===========================\n%% Section 1.00: Introduction\n%%===========================\n\n\\documentclass[../dissertation.tex]{subfiles}\n\n\\begin{document}\n% \\setcounter{section}{-1}\n\\section{Introduction}\\label{sec1:Intro}\n\nProving the direct scattering map $\\mathscr D$ for the Inverse Scattering Transform\nof the Intermediate Long Wave equation is both well-defined and Lipschitz \ncontinous hinges on our ability to reformulate the linear spectral problem \n\\eqref{eq0:SpecProb} with prescribed asyptotic conditions \\eqref{eq0:JostDEasymp}\nas the integral equations \\eqref{eq0:JostIE} and understand the behavior of \nthe solutions to \\eqref{eq0:JostIE}. Both require a deep understanding of\nthe properties of the Green's functions $G_L$ and $G_R$ defined in equation\n\\eqref{eq0:GFs} of Section \\ref{sec0:DM}. Indeed, this is the first of three\nchapters devoted solely to the study of $G_L$ and $G_R$.\n\n\nThe focus of this chapter is to study the properties \nof the lower boundary values $G_L^+$ and $G_R^+$ as functions on $\\mathbb R$, \nwhere the symbol $\\mathbb R$ denotes the of all real numbers.\\label{sym:Reals}\nIn particular, we use a contour shift to derive the alternate formulas\n\\eqref{eq1:GFrep} and \\eqref{eq1:GRrep} for $G_L^+$ and $G_R^+$ from \nTheorem \\ref{thm1:GFRep} (Section \\ref{sec1:GreensFunctions}), which\nwe use to study the asymptotic properties of $G_L^+$, \n$G_R^+$ (Section \\ref{sec1:AsympK}) and the singularity both functions have \nat $x=0$ (Section \\ref{sec1:AsympK}). We continue our study of the Green's\nfunctions in Chapters \\ref{cptr02:GFmapping} and \\ref{cptr03:xContin} \nwhere we use our analyses from this chapter \nto first study mapping properties of $G_L^+$, $G_R^+$ as convolution operators \n(Chapter \\ref{cptr02:GFmapping}), and then to prove that $G_L^+$, $G_R^+$\nextend analytically in the variable $x$ to the complex strip $\\mathcal S_\\delta$\n(Chapter \\ref{cptr03:xContin}).\n\nWe summarize the primary results of this chapter below in Theorems\n\\ref{thm1:GFRep} and \\ref{thm1:krep}.\n\n\\begin{thm}[Green's Function Representation]\\label{thm1:GFRep}\n\tThe Green's functions given above in \\eqref{eq0:GFs} can be \n\twritten as\n\t\\begin{subequations}\n\t\t\\label{eq1:GFrepLong}\n\t\t\\begin{align}\\label{eq1:GLrepLong}\n\t\t\tG_L^+(x; \\lambda, \\delta)\n\t\t\t\t=\n\t\t\t\t\t\\begin{cases}\n\t\t\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t\t\t+ i\n\t\t\t\t\t\t\t\\big[ \n\t\t\t\t\t\t\t\t\\alpha(\\lambda; \\delta) \n\t\t\t\t\t\t\t\t+ \\beta(\\lambda; \\delta) e^{i\\lambda x}\n\t\t\t\t\t\t\t\\big] \\chi_L(x)\n\t\t\t\t\t\t\t& \\lambda \\ne 0 \\\\\n\t\t\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t\t\t+ i\n\t\t\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\t\t\\frac{2}{3} + i \\frac{x}{\\delta}\n\t\t\t\t\t\t\t\\right] \\chi_L(x)\n\t\t\t\t\t\t\t& \\lambda = 0\n\t\t\t\t\t\\end{cases}\n\t\t\\end{align}\n\t\tand\n\t\t\\begin{align}\\label{eq1:GRrepLong}\n\t\t\tG_R^+(x; \\lambda, \\delta)\n\t\t\t\t=\n\t\t\t\t\t\\begin{cases}\n\t\t\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t\t\t- i\n\t\t\t\t\t\t\t\\big[ \n\t\t\t\t\t\t\t\t\\alpha(\\lambda; \\delta) \n\t\t\t\t\t\t\t\t+ \\beta(\\lambda; \\delta) e^{i\\lambda x}\n\t\t\t\t\t\t\t\\big] \\chi_R(x)\n\t\t\t\t\t\t\t& \\lambda \\ne 0 \\\\\n\t\t\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t\t\t- i\n\t\t\t\t\t\t\t\\left[ \n\t\t\t\t\t\t\t\t\\frac{2}{3} + i \\frac{x}{\\delta}\n\t\t\t\t\t\t\t\\right] \\chi_R(x)\n\t\t\t\t\t\t\t& \\lambda = 0\n\t\t\t\t\t\\end{cases}\n\t\t\\end{align}\n\t\\end{subequations}\n\twhere $\\chi_L := \\chi_{(0, \\infty)}$ and $\\chi_R := \\chi_{(-\\infty, 0)}$ respectively\n\tdenote the characteristic functions on the intervals $(0, \\infty)$ and $(-\\infty, 0)$, \n\t\\label{sym:chi}\n\t\\begin{align*}\n\t\t\\alpha(\\lambda; \\delta) \n\t\t\t&:= \\frac{1}{1-2\\delta\\zeta}  \n\t\t\t= \\frac{1 - e^{2\\delta\\lambda}}\n\t\t\t\t{2\\delta\\lambda e^{2\\delta\\lambda} + 1 - e^{2\\delta\\lambda}},\n\t\t\t\\\\[1\\baselineskip]\n\t\t\\beta(\\lambda; \\delta) \n\t\t\t&:= \\frac{1}{1-2 \\delta \\zeta^*} \n\t\t\t= \\frac{1-e^{2\\delta\\lambda}}{1+2\\delta\\lambda-e^{2\\delta\\lambda}},\n\t\\end{align*}\n\t\\label{sym:alphabeta}\n\tare respectively determined by the residues of the integrand of $G_L^+$\n\tand $G_R^+$ at $\\xi=0$ and $\\xi=\\lambda$, $\\zeta^*$ is the non-linear reflection\n\tgiven by\\label{sym:zetastar}\n\t\\[\n\t\t\\zeta^* := \\zeta(-\\lambda) = \\zeta\\big( - \\lambda(\\zeta) \\big)\n\t\\]\n\tand\n\t\\begin{align*}\n\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t:= \\frac{e^{-\\pi |x|}}{2\\pi} \n\t\t\t\t\t\\int_{\\mathbb R} e^{i x \\xi} \n\t\t\t\t\t\t\\frac{1}\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\\xi - \\zeta(\\lambda) \n\t\t\t\t\t\t\t\t\\big( \n\t\t\t\t\t\t\t\t\t1-e^{-2\\xi \\delta} \n\t\t\t\t\t\t\t\t\\big) \n\t\t\t\t\t\t\t\t+ i \\sign(x) \\pi\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\\, \\mathrm{d}\\xi\n\t\\end{align*}\n\t\\label{sym1:K}results from shifting the contour of integration for the integral in $G_L^+$ and\n\t$G_R^+$.\n\\end{thm}\n\n\n\\begin{thm}\\label{thm1:krep}\n\tSuppose $\\alpha$, $\\beta$, and $K^+$ are as defined in Theorem \\ref{thm1:GFRep}.\n\tThen the functions $\\alpha$ and $\\beta$ satisfy the following properties\n\t\\begin{align}\n\t\t\\lim_{\\lambda\\to0}|\\alpha(\\lambda; \\delta)| \n\t\t\t= \\lim_{\\lambda\\to0}|\\beta(\\lambda; \\delta)| \n\t\t\t= \\infty,\\nonumber \\\\\n\t\t\\intertext{and} \n\t\t\\label{eq1:PoleColapseResidue}\n\t\t\\lim_{\\lambda\\to0} \\big[\\alpha(\\lambda; \\delta) + \\beta(\\lambda; \\delta)e^{ix\\lambda}\\big]\n\t\t\t=  \\frac{2}{3} + i \\frac{x}{\\delta}.\n\t\t% \\lim_{\\lambda \\to -\\infty} \\alpha(\\lambda) \n\t\t% \t&= 1 \n\t\t% \t\t& \\lim_{\\lambda \\to \\infty} \\alpha(\\lambda) \n\t\t% \t\t\t&= 0 \\\\\n\t\t% \\lim_{\\lambda \\to -\\infty} \\beta(\\lambda) \n\t\t% \t&= 0 \n\t\t% \t\t& \\lim_{\\lambda \\to \\infty} \\beta(\\lambda) \n\t\t% % \t\t\t&= 1 \\\\\n\t\t% \\lim_{\\lambda\\nearrow0} \\alpha(\\lambda) \n\t\t% \t&= \\infty \n\t\t% \t\t& \\lim_{\\lambda\\searrow0} \\alpha(\\lambda) \n\t\t% \t\t\t&= -\\infty \\\\\n\t\t% \\lim_{\\lambda\\nearrow0} \\beta(\\lambda) \n\t\t% \t&= -\\infty \n\t\t% \t\t& \\lim_{\\lambda\\searrow0} \\beta(\\lambda) \n\t\t% \t\t\t&= \\infty,\n\t\\end{align}\n\t% and $\\lim_{\\lambda\\to0} \\alpha(\\lambda) + \\beta(\\lambda) e^{ix\\lambda} \n\t% = \\frac{2}{3} + i x$.\n\tFurther, $K^+$ is uniformly bounded in $\\lambda$ and\n\t\\begin{align}\n\t\tK^+(x; \\lambda, \\delta) = \n\t\t\t\\begin{cases}\n\t\t\t\tC \\log_+\\left(\\frac{1}{|x|}\\right) + \\mc O(1), & |x| < 1 \\\\\n\t\t\t\t\\mc O\\( \\frac{e^{-\\pi|x|}}{|x|} \\), & |x| \\geq 1\n\t\t\t\\end{cases}\n\t\\end{align}\n\tfor some constant $C \\in \\mathbb C$, where $\\mathbb C$\\label{sym:Complex} \n\tdenotes the set of all complex numbers and $\\log_+$ is the function defined\n\tby $\\log_+(x):=\\max\\big\\{ \\log(x), \\, 0 \\big\\}$.\\label{sym:logplus}\n\\end{thm}\n\n\\begin{rmk}\\label{rmk1:littlek}\n\tAn important and immediate consequence of Theorem \\ref{thm1:krep} and our\n\twork in Sections \\ref{sec1:AsympK} and \\ref{sec1:KSingularity} is that \n\t$K^+$ can be written as\n\t\\begin{align*}\\label{eq1:littlek}\n\t\tK^+(x; \\lambda, \\delta) = e^{-\\pi|x|} k(x; \\lambda, \\delta)\n\t\\end{align*}\n\twhere $k(\\dotarg; \\lambda, \\delta) \\in L^2(\\mathbb R)$ and $k$ is uniformly \n\tbounded in $\\lambda$ for all real $\\lambda$. Unless necessary to avoid \n\tconfusion, we commonly write $k(x; \\lambda, \\delta)$ as $k(x)$.\n\\end{rmk}\n\nWe begin this chapter by first motivating our choice of Green's functions\nin Section \\ref{sec1:RootsOfP}. \nSince we need to know the locations of the \nGreen's functions' integrand singularities to be able to both justify \nthe contours of integration for the Green's functions and\nto justify the representation theorem above (Theorem \\ref{thm1:GFRep}), \nlocating these singularities is also a primary task for Section \n\\ref{sec1:RootsOfP}.\n\nTo simplify notation, throughout the remainder of this dissertation, we use notation\n\\[\n\tp(\\xi; \\lambda, \\delta) := \\xi - \\zeta(\\lambda) \\big( 1-e^{-2\\xi \\delta} \\big),\n\t\\label{sym:GFintegrand}\n\\]\nwhere $e^{i\\xi x} / p(\\xi; \\lambda, \\delta)$ is the integrand for $G_L^+$ and $G_R^+$.\nSince it is occasionally more useful to consider the Green's functions as parameterized \nby $\\zeta$ rather than $\\lambda$, we use the notation $p(\\xi; \\lambda, \\delta)$ and\n$p(\\xi; \\zeta, \\delta)$ interchangeably. Further, we will not always need to consider\nthe affects of the parameters $\\lambda$ and $\\delta$ in our subsequent analyses. In \nsuch cases, we often use the shorter notation $p(\\xi)$ or $p(\\xi;\\lambda)$ \\textit{en lieu} \nof the more cumbersome $p(\\xi; \\lambda, \\delta)$ or $p(\\xi; \\zeta, \\delta)$.\n\nAs we see in Section \\ref{sec1:RootsOfP}, the only roots of $p(\\xi; \\lambda, \\delta)$ \nin the complex strip \n\\[\n\t\\mathcal R_\\delta := \\{z \\in \\mathbb C ~:~ -\\pi/\\delta \\leq \\im z \\leq \\pi/\\delta \\}\t\n\\]\n\\label{sym1:Rcal}\nare $\\xi = 0$ and $\\xi = \\lambda$ (provided $\\lambda \\ne 0$). As such, we may\nuse analyticity to write $G_L^+$ and $G_R^+$ as \\label{sym:GFbndry}\n\\begin{align*}\n\tG_L^+(x; \\lambda, \\delta)\n\t\t&:= \n\t\t\t\\frac{1}{2\\pi} \n\t\t\t\\int_{\\Gamma_L} \n\t\t\t\te^{i\\xi x} \\frac{1}{p(\\xi; \\lambda, \\delta)} \n\t\t\t\\, \\mathrm{d}\\xi \\\\\n\tG_R^+(x; \\lambda, \\delta) \n\t\t&:= \n\t\t\t\\frac{1}{2\\pi} \n\t\t\t\t\\int_{\\Gamma_R} \n\t\t\t\t\te^{i\\xi x} \\frac{1}{p(\\xi; \\lambda, \\delta)} \n\t\t\t\t\\, \\mathrm{d}\\xi,\n\\end{align*}\nwhere the symbol $\\Gamma_L$ \\label{sym:Gamma} is used to denote a contour from $-\\infty$ to \n$\\infty$ along the real axis which is deformed in small circular arcs around \n$\\xi = 0$ and $\\xi=\\lambda$ so that the contour bypasses these two real roots \nof $p$ from below (Figure \\ref{fig1:GammaL}), and $\\Gamma_R$ denotes the \ncorresponding contour which bypasses\nthe roots $\\xi = 0$ and $\\xi=\\lambda$ from above (Figure \\ref{fig1:GammaR}). \n\n\\begin{figure}[H]\n\t\\centering\n\t\\def\\outSpacing{1.3}\n\t\\def\\innSpacing{1.3}\n\t% \\def\\ep{.65}\n\t\\def\\ep{.3}\n\t\\def\\lambdaam{\\innSpacing+\\ep+\\ep}\n\t\\def\\arrowsize{15mm}\n\t\\def\\dotsize{1pt}\n\t\\begin{subfigure}[t]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}[\n\t\t\t\tdirected/.style={\n\t\t\t\t\tdecoration={markings, mark=at position .55 with \\arrow{stealth}[arrowhead=\\arrowsize]},\n\t\t\t\t\t\tpostaction={decorate}\n\t\t\t\t},\n\t\t\t\tcont/.style={smooth, thick}\n\t\t\t]\n\t\t\t\n\n\t\t\t% Draw the contour\n\t\t\t\\draw[cont, directed] ({-\\outSpacing-\\ep},0) -- ({-\\ep}, 0);\n\t\t\t\\draw[cont, directed] ({\\ep}, 0) -- ({\\lambdaam - \\ep},0);\n\t\t\t\\draw[cont, directed] \n\t\t\t\t({\\lambdaam + \\ep},0) -- ({\\lambdaam + \\ep + \\outSpacing},0);\n\n\n\t\t\t\\draw[cont, domain=180:360, variable=\\th]\n\t\t\t\tplot ({\\ep*cos(\\th)}, {\\ep*sin(\\th)});\n\t\t\t\\draw[cont, domain=180:360, variable=\\th]\n\t\t\t\tplot ({\\ep*cos(\\th)+\\lambdaam}, {\\ep*sin(\\th)});\n\n\t\t\t% Draw zeros\n\t\t\t\\tkzDefPoint(0,0){zero}\n\t\t\t\\tkzDefPoint(\\lambdaam,0){lambda}\n\t\t\t\\tkzLabelPoint[above](zero){$\\xi=0$}\n\t\t\t\\tkzLabelPoint[above](lambda){$\\xi=\\lambda$}\n\t\t\t\\tkzLabelPoint[below](zero){\\phantom{$\\xi=0$}}\n\t\t\t\\tkzLabelPoint[below](lambda){\\phantom{$\\xi=\\lambda$}}\n\t\t\t\\foreach \\n in {zero, lambda}\n\t\t\t\t\\node at (\\n)[circle, fill, inner sep=\\dotsize]{};\n\t\t\\end{tikzpicture}\n\t\t\\caption{$\\Gamma_L$ Contour}\n\t\t\\label{fig1:GammaL}\n\t\\end{subfigure}\n\t\\begin{subfigure}[t]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}[\n\t\t\t\tdirected/.style={\n\t\t\t\t\tdecoration={markings, mark=at position .5 with \\arrow{stealth}[arrowhead=\\arrowsize]},\n\t\t\t\t\t\tpostaction={decorate}\n\t\t\t\t},\n\t\t\t\tcont/.style={smooth, thick}\n\t\t\t]\n\n\t\t\t%% Draw the contour\n\t\t\t\\draw[cont, directed] ({-\\outSpacing-\\ep},0) -- ({-\\ep}, 0);\n\t\t\t\\draw[cont, directed] ({\\ep}, 0) -- ({\\lambdaam - \\ep},0);\n\t\t\t\\draw[cont, directed] \n\t\t\t\t({\\lambdaam + \\ep},0) -- ({\\lambdaam + \\ep + \\outSpacing},0);\n\n\t\t\t\\draw[cont, domain=180:360, variable=\\th]\n\t\t\t\tplot ({\\ep*cos(\\th)}, {-\\ep*sin(\\th)});\n\t\t\t\\draw[cont, domain=180:360, variable=\\th]\n\t\t\t\tplot ({\\ep*cos(\\th)+\\lambdaam}, {-\\ep*sin(\\th)});\n\n\n\t\t\t%% Draw zeros\n\t\t\t\\tkzDefPoint(0,0){zero}\n\t\t\t\\tkzDefPoint(\\lambdaam,0){lambda}\n\t\t\t\\tkzLabelPoint[above](zero){\\phantom{$\\xi=0$}}\n\t\t\t\\tkzLabelPoint[above](lambda){\\phantom{$\\xi=\\lambda$}}\n\t\t\t\\tkzLabelPoint[below](zero){$\\xi=0$}\n\t\t\t\\tkzLabelPoint[below](lambda){$\\xi=\\lambda$}\n\t\t\t\\foreach \\n in {zero, lambda}\n\t\t\t\t\\node at (\\n)[circle, fill, inner sep=\\dotsize]{};\n\t\t\\end{tikzpicture}\n\t\t\\caption{$\\Gamma_R$ Contour}\n\t\t\\label{fig1:GammaR}\n\t\\end{subfigure}\n\t\\caption{Contours of integration $\\Gamma_L$ and $\\Gamma_R$ for $G_L$ and $G_R$.}\n\t\\label{fig1:GammaStarContours}\n\\end{figure}\n\n\\begin{rmk}\\label{rmk1:StarNotation}\n\tThroughout this dissertation, we commonly use the symbol ``$\\star$''\n\tas a place holder for both $L$ and $R$. For example, if we write ``$G_\\star$ \n\t($\\star = L \\text{, or } R$) are a bounded as a convolution operators,'' then \n\twhat we mean is that ``both $G_L$ and $G_R$ are bounded as convolution \n\toperators.'' As a further example of how we use this notational convention, \n\tplease see the following two very important remarks.\n\\end{rmk}\n\n\n\n\n\\begin{rmk}\\label{rmk1:ResidueLimits}\n\tWhen $\\lambda = 0$, the function $\\zeta(\\lambda; \\delta)$ is technically \n\tundefined. However, since \n\t$\\lim_{\\lambda\\to0}\\zeta(\\lambda; \\delta) = \\frac{1}{2\\delta}$, $\\lambda = 0$\n\tis a removable singularity of $\\zeta$. As such, we define \n\t$\\zeta(\\lambda; \\delta) := \\frac{1}{2\\delta}$. Further, the case $\\lambda=0$ \n\talso corresponds to the case when the two roots $\\xi = 0$ and $\\xi = \\lambda$ \n\tof the function $p$\\textemdash{}which are simple when \n\t$\\lambda \\ne 0$\\textemdash{}coalesce to form a single double zero of $p$. Under \n\tthe caveat that we define $\\zeta(0; \\delta):= \\frac{1}{2\\delta}$, a direct computation \n\tshows that the residue of $e^{ix\\xi} / p(\\xi; 0, \\delta)$ at $\\xi = 0$ is \n\t$\\frac{2}{3} + i \\frac{x}{\\delta}$\\textemdash{}hence the piecewise (in $\\lambda$)\n\tdefinition of $G_L^+$ and $G_R^+$ in \\eqref{eq1:GFrepLong}.\n\tThus, even though the residue sum \n\t\\[\n\t\t\\mathpzc R_\\star (x; \\lambda, \\delta) \n\t\t\t:= i \n\t\t\t\t\\left[\n\t\t\t\t\t\\alpha(\\lambda; \\delta) + \\beta(\\lambda; \\delta) e^{i\\lambda x}\n\t\t\t\t\\right] \\chi_\\star\n\t\t\t\\qquad (\\star = L \\text{, or } R)\n\t\\]\n\t\\label{sym1:ressum}is not technically defined at \n\t$\\lambda = 0$, it nonetheless makes sense for us to agree on the convention \n\tthat\n\t\\[\n\t\t\\mathpzc R_\\star(x; \\lambda = 0; \\delta)\n\t\t\t:= \\left[ i \\frac{2}{3} - \\frac{x}{\\delta} \\right] \\, \\chi_\\star.\n\t\t\\qquad (\\star = L \\text{, or } R)\n\t\\]\n\tUnder this convention, \\eqref{eq1:GFrepLong} can be written slightly more succinctly as\n\t\\begin{subequations}\n\t\t\\label{eq1:GFrep}\n\t\t\\begin{align}\n\t\t\t\\label{eq1:GLrep}\n\t\t\tG_L^+(x; \\lambda, \\delta)\n\t\t\t\t&=\n\t\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t+ \\mathpzc R_L(x; \\lambda, \\delta)\\\\\n\t\t\t\\label{eq1:GRrep}\n\t\t\tG_R^+(x; \\lambda, \\delta) &= \n\t\t\t\tK^+(x; \\lambda, \\delta) \n\t\t\t\t\t- \\mathpzc R_R(x; \\lambda, \\delta).\n\t\t\\end{align}\n\t\\end{subequations}\n\\end{rmk}\n\n\n\n\n\\begin{rmk}\\label{rmk1:ContourAdjustment}\n\tContinuing to our discussion on the case of $\\lambda = 0$ and the \n\tcoalescing of the Green's function integrand poles $\\xi = 0$, $\\xi = \\lambda$,\n\tunder this scenario, we take the contours $\\Gamma_\\star$ \n\t($\\star = L \\text{, or } R$) such that they have only one circular deformation\n\taway from the real line which allows them to bypass the single (double) pole\n\tat $\\xi = 0$. \n\\end{rmk}\n\n\n\n\\end{document}", "meta": {"hexsha": "b5131eccb4dc275a852d68d62b3fb187e62362fb", "size": 14305, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter1-GF/1.0-Introduction.tex", "max_stars_repo_name": "ADGC/ilw-dsm-dissertation", "max_stars_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1-GF/1.0-Introduction.tex", "max_issues_repo_name": "ADGC/ilw-dsm-dissertation", "max_issues_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1-GF/1.0-Introduction.tex", "max_forks_repo_name": "ADGC/ilw-dsm-dissertation", "max_forks_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7737789203, "max_line_length": 95, "alphanum_fraction": 0.6309681929, "num_tokens": 5269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4485252320278567}}
{"text": "%% Journal of Open Research Software Latex template -- Created By Stephen Bonner and John Brennan, Durham University, UK.\n\n\\documentclass{jors}\n\\usepackage{amsmath, amssymb}\n\\usepackage{cite}\n\\usepackage{graphicx, subcaption}\n\\graphicspath{ {images/} }\n\n%% Set the header information\n\\pagestyle{fancy}\n\\definecolor{mygray}{gray}{0.6}\n\\renewcommand\\headrule{}\n\\rhead{\\footnotesize 3}\n\\rhead{\\textcolor{gray}{UP JORS software Latex paper template version 0.1}}\n\n\\begin{document}\n\n{\\bf Software paper for submission to the Journal of Open Research Software} \\\\\n\nPlease submit the completed paper to: editor.jors@ubiquitypress.com\n\n\\rule{\\textwidth}{1pt}\n\n\\section*{(1) Overview}\n\n\\vspace{0.5cm}\n\n\\section*{Title}\nspinsim: a GPU optimised simulator of spin half and spin one quantum systems\n\n\\section*{Paper Authors}\n1. Tritt, Alex;\\\\\n2. Morris, Joshua;\\\\\n3. Hochstetter, Joel;\\\\\n4. Anderson, R. P.;\\\\\n5. Saunderson, James;\\\\\n6. Turner, L. D.;\\\\\n\n\\section*{Paper Author Roles and Affiliations}\n1. School of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPrimary author of the released packages.\\\\\n2. School of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPresent address: Faculty of Physics, University of Vienna, 1010 Vienna, Austria.\\\\\n\tAuthor of first version of code.\\\\\n3. School of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPresent address: School of Physics, University of Sydney, NSW 2006, Australia.\\\\\n\tOptimization and extension to spin one of first version of code.\\\\\n4. School of Molecular Sciences, La Trobe University, PO box 199, Bendigo, Victoria 3552, Australia.\\\\\n\tOriginal conception of first version of code.\\\\\n5. Department of Electrical and Computer Systems Engineering, Monash University, Victoria 3800, Australia.\\\\\n\tAdvice on numerical analysis.\\\\\n6. School of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tOriginal conception of released version of algorithm.\n\n\\section*{Abstract}\n\t\\texttt{spinsim} is a \\emph{python} package that simulates spin half and spin one quantum mechanical systems following a time dependent Shroedinger equation. It makes use of \\texttt{numba.cuda} \\cite{lam_numba_2015}, which is an \\emph{LLVM} (Low Level Virtual Machine) \\cite{lattner_llvm_2004} compiler, and other optimisations, to allow for fast and accurate evaluation on \\emph{Nvidia Cuda} \\cite{nickolls_scalable_2008} compatible systems using GPU parallelisation. \\texttt{spinsim} is available for installation on \\emph{PyPI}, and the source code is available on \\emph{github}. The initial use case for the package will be to simulate quantum sensing-based Bose Einstein condensate (BEC) experiments for the Monash University School of Physics and Astronomy spinor BEC lab, but we anticipate it will be useful in simulating any range of spin half or spin one quantum systems with time dependent Hamiltonians that cannot be solved analytically. These appear in the fields of nuclear magnetic resonance (NMR), nuclear quadrupole resonance (NQR) and magnetic resonance imaging (MRI) experiments and quantum sensing, and with the spin one systems of nitrogen vacancy centres (NVCs) and BECs.\n\n\\section*{Keywords}\nTime dependent Schroedinger equation; Spin one; Spin half; Integrator; GPU; Solver; python; numba;\n\n\\section*{Introduction}\n\\subsection*{Motivation}\n\tUltracold rubidium atoms have proven their effectiveness in state of the art technologies in quantum sensing \\cite{degen_quantum_2017}, the use of quantum mechanics to make precise measurements of small signals. The rotation of these atoms can be modelled as quantum spin systems, which is the quantum mechanical model for objects with angular momentum. The simplest spin system, spin half (ie spin quantum number of \\(\\frac12\\), also referred to as a qubit), is quantised into just two quantum spin levels, and this describes the motion of some fundamental particles such as electrons. However, systems more practical for sensing, such as ultracold rubidium atoms, are more accurately described as a spin one quantum system (ie spin quantum number of \\(1\\), also referred to as a quitrit), which is quantised into three quantum spin levels.\n\t\n\tThe design of sensing protocols requires many steps of verification, including simulation. This is especially important, since running real experiments can be expensive and time consuming, and thus it is more practical to debug such protocols quickly and cheaply on a computer. In general, any design of experiments using spin systems could benefit from a fast, accurate method of simulation.\n\n\t% \\texttt{AtomicPy} \\cite{morris_qcmonkatomicpy_2018}\n\tIn the past, the spinor Bose Einstein condensate (spinor BEC) lab at Monash University used an in-house, \\emph{cython} based script, on which this package is based, and standard differential equation solvers (such as \\emph{Mathematica}'s function \\texttt{NDSolve}) to solve the Schroedinger equation for quantum sensing spin systems. Spin one systems are sometimes approximated to spin half for a faster execution time, at the cost of modelling all effects of the system. However, these methods are not completely optimised for our use case, and therefore come with some issues.\n\n\tFirst, while the execution time for these solvers is acceptable for running a small number of experiments, for certain experiments involving large arrays of independent atom clouds (which require many thousands of simulations to be run), this time accumulates to the order of many hours, or even multiple days.\n\n\tSecond, the Schroedinger equation has the geometric property of being norm persevering. In other words, the time evolution operator for a system between two points in time must be unitary. As such, numerical solutions to the Schroedinger equation should also preserve this property. For many numerical methods like those in the Runge Kutta family, the approximations used might not be norm preserving, and the evaluated quantum state may diverge towards an infinite norm, or converge to zero if run for many iterations.\n\n\tThird, our system (and similar spin systems) can be very oscillatory. In standard conditions for our application, the expected spin projection of a system that we want to solve for can rotate in physical space (alternatively viewed as a point rotating around an abstract object known as a \\emph{Bloch sphere}) at a rate of 700kHz. Standard integration methods require very small time steps in order to accurately depict these oscillations.\n\n\\section*{Implementation and architecture}\n\t\\subsection*{Mathematical methods}\n\t\t\\subsubsection*{Background}\n\t\t\tIn general, \\texttt{spinsim} solves the Schroedinger equation,\n\n\t\t\t\\begin{align}\n\t\t\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\psi(t) &= -iH(t)\\psi(t),\n\t\t\t\\end{align}\n\n\t\t\twhere \\(i^2 = -1\\), the quantum state \\(\\psi(t) \\in \\mathbb{C}^N\\) a time dependent, \\(N\\) dimensional, unit complex vector, and the Hamiltonian \\(H(t) \\in \\mathbb{C}^{N \\times N}\\) is a time dependent \\(N \\times N\\) complex Hermitian matrix. Here \\(N\\) is the number spin levels in the quantum system, so spin half is the \\(N = 2\\) case, and spin one refers to the \\(N = 3\\) case. Rather than being represented by standard coordinates in \\(\\mathbb{C}^{N \\times N}\\), in \\texttt{spinsim} the Hamiltonian \\(H(t)\\) is instead represented with respect to a choice of basis for the corresponding Lie Algebra, \\(\\mathfrak{su}(N)\\). For example, when set to spin half mode, the \\texttt{spinsim} package solves the time dependent Schroedinger equations of the form\n\n\t\t\t\\begin{align}\n\t\t\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\psi(t) = -i 2\\pi (f_x(t) J_x + f_y(t) J_y + f_z(t) J_z) \\psi(t),\n\t\t\t\\end{align}\n\n\t\t\twhere \\(i^2 = -1\\), \\(\\psi(t) \\in \\mathbb{C}^2\\), and the spin half spin projection operators are given by\n\n\t\t\t\\begin{align}\n\t\t\t\tJ_x &= \\frac12\\begin{pmatrix}\n\t\t\t\t\t0 & 1 \\\\\n\t\t\t\t\t1 & 0\n\t\t\t\t\\end{pmatrix},\n\t\t\t\t&J_y &= \\frac12\\begin{pmatrix}\n\t\t\t\t\t0 & -i \\\\\n\t\t\t\t\ti &  0\n\t\t\t\t\\end{pmatrix},\n\t\t\t\t&\\textrm{and }J_z &= \\frac12\\begin{pmatrix}\n\t\t\t\t\t1 &  0 \\\\\n\t\t\t\t\t0 & -1\n\t\t\t\t\\end{pmatrix}.\n\t\t\t\\end{align}\n\n\t\t\tThe energy source \\(f\\) that represents the time dependent Hamiltonian \\(H(t)\\), is the collection of energy functions \\(f_x(t), f_y(t), f_z(t)\\), with \\(t\\) in units of s and \\(f\\) in units of Hz that control the dynamics of the system. The user must define a method that returns a sample of these source functions when a sampling time is input. In physical terms, these functions could represent the \\(x,y,z\\) components of a magnetic field applied to a magnetically sensitive.\n\n\t\t\tSimilarly, when \\texttt{spinsim} is set to spin one mode, it can solve the Schroedinger equation of the form\n\n\t\t\t\\begin{align}\n\t\t\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\psi(t) = -i 2\\pi (f_x(t) J_x + f_y(t) J_y + f_z(t) J_z + f_q(t) Q) \\psi(t).\n\t\t\t\\end{align}\n\n\t\t\twhere now \\(\\psi(t) \\in \\mathbb{C}^3\\), and the spin one operators are given by\n\n\t\t\t\\begin{align}\n\t\t\t\tJ_x &= \\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n\t\t\t\t\t0 & 1 & 0 \\\\\n\t\t\t\t\t1 & 0 & 1 \\\\\n\t\t\t\t\t0 & 1 & 0\n\t\t\t\t\\end{pmatrix},&\n\t\t\t\tJ_y &= \\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n\t\t\t\t\t0 & -i &  0 \\\\\n\t\t\t\t\ti &  0 & -i \\\\\n\t\t\t\t\t0 &  i &  0\n\t\t\t\t\\end{pmatrix},\\nonumber\\\\\n\t\t\t\tJ_z &= \\begin{pmatrix}\n\t\t\t\t\t1 & 0 &  0 \\\\\n\t\t\t\t\t0 & 0 &  0 \\\\\n\t\t\t\t\t0 & 0 & -1\n\t\t\t\t\\end{pmatrix},&\n\t\t\t\t\\textrm{and }Q &= \\frac{1}{3}\\begin{pmatrix}\n\t\t\t\t\t1 &  0 & 0 \\\\\n\t\t\t\t\t0 & -2 & 0 \\\\\n\t\t\t\t\t0 &  0 & 1\n\t\t\t\t\\end{pmatrix}.\n\t\t\t\\end{align}\n\n\t\t\tThe matrices \\(J_x, J_y, J_z\\) are regular spin operators, and \\(Q\\) is a quadrupole operator. Note that \\(Q\\) is proportional to \\(Q_{zz}\\) as defined by Hamley et al \\cite{hamley_spin-nematic_2012}, and \\(Q_0\\) as defined by Di et al \\cite{di_dipolequadrupole_2010}.\n\n\t\t\tFrequently when one calculates the times series of the quantum state \\(\\psi(t)\\), they are also interested in its expected spin projection \\(\\left\\langle J\\right\\rangle\\)(t). It is given by the vector\n\n\t\t\t\\begin{align}\n\t\t\t\t\\left\\langle J\\right\\rangle(t) &= \\begin{pmatrix}\n\t\t\t\t\t\\psi(t)^\\dagger J_x \\psi(t)\\\\\n\t\t\t\t\t\\psi(t)^\\dagger J_y \\psi(t)\\\\\n\t\t\t\t\t\\psi(t)^\\dagger J_z \\psi(t)\n\t\t\t\t\\end{pmatrix},\n\t\t\t\\end{align}\n\n\t\t\twhere \\(\\cdot^\\dagger\\) is the adjoint operator (also referred to as Hermitian conjugate, and is implemented as complex conjugate transpose). The expected spin projection can be interpreted as the average direction that the spin system is oriented in space when many systems of the equivalent state are measured (due to the Heisenberg uncertainty principle, only one component of the exact orientation of a quantum state can be known at any point in time, which is why we need to deal with expected values rather than absolute values). However, it can also be used to model the overall orientation of an ensemble of many quantum systems, like a BEC, for instance. \\texttt{spinsim} has the functionality to calculate the expected spin projection of a system from its state.\n\n\t\t\\subsubsection*{Parallelisation}\n\t\t\tGiven that \\(\\psi(t)\\) is a unit vector, it is possible to write \\(\\psi(t)\\) in terms of a unitary transformation \\(U(t, t_0)\\) of the state \\(\\psi(t_0)\\), for any time \\(t_0\\). In other words, for any \\(t_0,t \\in \\mathbb{R}\\), there is a unitary transformation \\(U(t, t_0)\\) such that\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\t\\psi(t) &= U(t, t_0)\\psi(t_0).\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tThis means that a time series for the state of the system can be evaluated by evaluating the time evolution operator between each of the sample times. Consider quantising time with\n\t\t\t\\begin{align}\n\t\t\t\tt_k &= t_0 + \\mathrm{D}t\\cdot k,\n\t\t\t\\end{align}\n\n\t\t\twhere \\(\\mathrm{D}t\\) is the time step of the time series (in contrast to \\(\\mathrm{d}t\\), a smaller time step for integration). If we define\n\n\t\t\t\\begin{align}\n\t\t\t\t\\psi_k = \\psi(t_k)\\textrm{ and}\\\\\n\t\t\t\tU_k = U(t_{k}, t_{k-1}),\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tthen the time series of states \\(\\psi_k\\) and time evolution operators \\(U_k\\) satisfies\n\n\t\t\t\\begin{align}\n\t\t\t\t\\psi_k &= U_k\\psi_{k-1}\\label{eq:integration_compilation}\n\t\t\t\\end{align}\n\n\t\t\tThis presents an opportunity for parallelism. While each of the \\(\\psi_k\\) must be evaluated sequentially, the value of the \\(U_k\\) is independent of the value of any \\(\\psi_{k_0}\\), or any other \\(U_{k_0}\\). This means that the time evolution operators \\(U_k\\) can all be calculated in parallel, and it allows \\texttt{spinsim} to use GPU parallelisation on the level of time sample points, so a speed up is achieved even if just a single simulation is run.\n\n\t\t\tIn summary, \\texttt{spinsim} splits the time evolution of the full simulation into time evolution \\(U_k\\) within small time intervals \\([t_{k - 1}, t_{k}]\\), which are each calculated massively in parallel on a GPU. When all the \\(U_k\\) are calculated, the CPU then multiplies the \\(U_k\\) together (a comparatively less demanding job than calculating them) using Equation \\eqref{eq:integration_compilation} to determine the \\(\\psi_k\\).\n\n\t\t\\subsubsection*{Rotating frame}\n\t\t\tIf the rotating frame option is selected, the \\(U_k\\) are first calculated within a rotating frame of reference as \\(U^r_k\\), which, in some situations, reduces the size of the source functions used in the calculation, increasing accuracy. The rotation speed of the rotating frame is calculated locally for each parallel time step \\(U_k\\), and only for rotations around the \\(z\\) axis. The rotating from source functions \\(f^r_x, f^r_y, f^r_z,\\) and \\(f^r_q\\) are related to the source function from the user input via\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tf^r_x(t) + if^r_y(t) &= e^{-i 2\\pi f_r t}(f_x(t) + if_y(t)),\\\\\n\t\t\t\tf^r_z(t) &= f_z(t) - f_r\\textrm{, and}\\\\\n\t\t\t\tf^r_q(t) &= f_q(t), \\textrm{ for spin one.}\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tWhere \\(f_r = f_z(t_k + \\frac12\\mathrm{D}t)\\) is sampled the midpoint value of the source over the interval \\([t_{k - 1}, t_k]\\). This, assuming that a midpoint sample is representative of an average value over the time interval, decreases the magnitude of \\(f_z(t)\\), while leaving the other source components at an equivalent magnitude. The rotation is then applied to obtain the lab frame time evolution operator \\(U_k\\) via\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tU_k &= \\exp(-i 2 \\pi f_r J_z \\mathrm{D}t) U^r_k.\n\t\t\t\\end{align}\n\n\t\t\tSpecifically, this relationship is\n\n\t\t\t\\begin{align}\n\t\t\t\tU_k &= \\begin{pmatrix}\n\t\t\t\t\te^{-i 2\\pi f_r \\mathrm{D}t} & 0 & 0\\\\\n\t\t\t\t\t0 & 1 & 0\\\\\n\t\t\t\t\t0 & 0 & e^{i 2\\pi f_r \\mathrm{D}t}\n\t\t\t\t\\end{pmatrix} U^r_k, \\textrm{ for spin one, and}\\\\\n\t\t\t\tU_k &= \\begin{pmatrix}\n\t\t\t\t\te^{-i \\pi f_r \\mathrm{D}t} & 0\\\\\n\t\t\t\t\t0 & e^{i \\pi f_r \\mathrm{D}t}\n\t\t\t\t\\end{pmatrix} U^r_k, \\textrm{ for spin half.}\n\t\t\t\\end{align}\n\n\t\t\tIt is a common technique in solving quantum mechanical problems to enter rotating frames, and their more abstract counterparts of interaction pictures \\cite{j_j_sakurai_jun_john_modern_1994}. Note that this is typically done in conjunction with the Rotating Wave Approximation (RWA), which is an assumption that the oscillatory components of \\(f^r_x, f^r_y, f^r_z,\\) and \\(f^r_q\\) on an average of many cycles do not have a large contribution to time evolution of the solution and can be ignored. In some cases, this allows for analytic solutions to the approximate quantum system to be obtained. Note that the RWA is \\emph{not} invoked in \\texttt{spinsim}, as doing this would reduce the accuracy of simulation results, defeating our purpose of using a rotating frame.\n\t\t\t\n\t\t\\subsubsection*{Magnus based integration method}\n\t\t\tThe integration method used in \\texttt{spinsim} is the commutator free 4 (CF4) method from Auer et al \\cite{auer_magnus_2018}, which based on the Magnus expansion. Each of the \\(U_k\\) are split into products of time evolution operators between times separated by a smaller time step, that is,\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tU(t_k, t_{k-1}) &= U(t_k, t_k - \\mathrm{d}t) \\cdots U(t_{k-1} + 2\\mathrm{d}t, t_{k-1} + \\mathrm{d}t) U(t_{k-1} + \\mathrm{d}t, t_{k-1})\\\\\n\t\t\t\tU_k &= u^k_{L-1} \\cdots u^k_0\\textrm{, where}\\\\\n\t\t\t\tu^k_{L-1} &= U(t_0 + (k - 1)\\mathrm{D}t + (l + 1)\\mathrm{d}t, t_0 + (k - 1)\\mathrm{D}t + l\\mathrm{d}t)\n\t\t\t\\end{align}\n\n\t\t\twith \\(\\mathrm{d}t\\) being the integration level time step. Note that the time steps are related to each other by \\(\\mathrm{D}t = L\\mathrm{d}t\\), where \\(L\\in\\mathbb{N}\\).\n\n\t\t\tThe CF4 method is used to calculate each individual \\(u^k_l\\). Let the fine sample time be given by \\(t_f = l\\mathrm{d}t + t_k\\). Then as part of the CF4 method, the source functions are sampled at particular times based on the second order Gauss-Legendre quadrature, given by\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tt_1 &= t_f + \\frac12 \\mathrm{d}t\\left(1 - \\frac{1}{\\sqrt{3}}\\right)\\textrm{, and}\\\\\n\t\t\t\tt_2 &= t_f + \\frac12 \\mathrm{d}t\\left(1 + \\frac{1}{\\sqrt{3}}\\right).\n\t\t\t\\end{align}\n\n\t\t\tNow, let\n\t\t\t\\begin{align}\n\t\t\t\tf(t_1) &= (f_x(t_1), f_y(t_1), f_z(t_1), f_q(t_1))\\textrm{, and}\n\t\t\t\tf(t_2) &= (f_x(t_2), f_y(t_2), f_z(t_2), f_q(t_2)).\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tThe integration time evolution operator can then be calculated using\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tg_1 =& (g_{1,x}, g_{1,y}, g_{1,z}, g_{1,q})\\\\\n\t\t\t\t=& 2 \\pi \\mathrm{d}t \\left(\\frac{3 + 2 \\sqrt{3}}{12} f(t_1) + \\frac{3 - 2 \\sqrt{3}}{12} f(t_2)\\right)\\textrm{, and}\\\\\n\t\t\t\tg_2 =& (g_{2,x}, g_{2,y}, g_{2,z}, g_{2,q})\\\\\n\t\t\t\t=& 2 \\pi \\mathrm{d}t \\left(\\frac{3 - 2 \\sqrt{3}}{12} f(t_1) + \\frac{3 + 2 \\sqrt{3}}{12} f(t_2)\\right)\\textrm{, so}\\\\\n\t\t\t\tu =& \\exp(-i \\left( g_{2,x} J_x + g_{2,y} J_y + g_{2,z} J_z + g_{2,q} Q\\right))\\\\\n\t\t\t\t&\\cdot\\exp(-i \\left( g_{1,x} J_x + g_{1,y} J_y + g_{1,z} J_z + g_{1,q} Q\\right)).\n\t\t\t\\end{align}\n\n\t\t\\subsubsection*{Exponentiator}\n\t\t\tFor all exponentiation, the exponentiator computes the matrix exponential\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\tE(g) &= E(g_x, g_y, g_z, g_q)\\\\\n\t\t\t\t&= \\exp(-i (g_x J_x + g_y J_y + g_z J_z + g_q Q)), \\textrm{ with}\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tFor spin half, the default exponentiator is in an analytic form. For spin one, an exponentiator based on the Lie Trotter product formula \\cite{moler_nineteen_2003} is used instead. Explicitly, this formula is\n\t\t\t\n\t\t\t\\begin{align}\n\t\t\t\t\\exp\\left( A + B\\right) &= \\lim_{n\\to\\infty} \\left(\\exp\\left(\\frac{A}{n}\\right) \\exp\\left(\\frac{B}{n}\\right)\\right)^n\n\t\t\t\\end{align}\n\t\t\t\n\t\t\tWhere \\(A,B\\in\\mathbb{C}^{N\\times N}\\) are matrix operators, and \\(n\\in\\mathbb{N}\\). The equality holds for without the limit for all \\(n\\) if the operators commute, like it does for real and complex numbers. This tells us that we can approximate a matrix exponential of a linear combination of spin operators by reducing the size of the coefficients of these operators, taking the analytically known exponentials of each of the operators separately, multiplying each individual result together, and then raising the combination \\(T\\) to the power of the original reduction. For our spin one case, the exponential \\(E(g)\\) can be approximated as, for large \\(2^\\tau\\),\n\n            % \\begin{align}\n            %     E(g) &= \\exp(-ig_x J_x - ig_y J_y - ig_z J_z - ig_q Q)\\\\\n            %     &= \\exp(2^{-\\tau}(-ig_x J_x - ig_y J_y - ig_z J_z - ig_q Q))^{2^\\tau}\\\\\n            %     &\\approx (\\exp(-i(2^{-\\tau} g_x) J_x) \\exp(-i(2^{-\\tau} g_y) J_y) \\exp(-i(2^{-\\tau} g_z J_z + (2^{-\\tau} g_q) Q)))^{2^\\tau}\\\\\n            %     &= \\begin{pmatrix}\n            %         \\frac{e^{-i\\left(Z + \\frac{P}{3}\\right)}(c_X + c_Y - i s_Xs_Y)}{2} & \\frac{e^{i\\frac{2P}{3}} (-s_Y -i c_Y s_X)}{\\sqrt{2}} & \\frac{e^{-i\\left(-Z + \\frac{P}{3}\\right)}(c_X - c_Y + i s_Xs_Y)}{2} \\\\\n            %         \\frac{e^{-i\\left(Z + \\frac{P}{3}\\right)} (-i s_X + c_X s_Y)}{\\sqrt{2}} & e^{i\\frac{2P}{3}} c_X c_Y & \\frac{e^{-i(Z - \\frac{P}{3})} (-i s_X - c_X s_Y)}{\\sqrt{2}} \\\\\n            %         \\frac{e^{-i\\left(Z + \\frac{P}{3}\\right)}(c_X - c_Y - i s_Xs_Y)}{2} & \\frac{e^{i\\frac{2P}{3}} (s_Y -i c_Y s_X)}{\\sqrt{2}} & \\frac{e^{-i\\left(-Z + \\frac{P}{3}\\right)}(c_X + c_Y + i s_Xs_Y)}{2}\n            %     \\end{pmatrix}^{2^\\tau}\n            % \\end{align}\n\n\t\t\t\\begin{align}\n                E(g) =& \\exp\\left(-ig_x J_x - ig_y J_y - ig_z J_z - ig_q Q\\right)\\\\\n                =& \\exp\\left(2^{-\\tau}\\left(-ig_x J_x - ig_y J_y - ig_z J_z - ig_q Q\\right)\\right)^{2^\\tau}\\\\\n                \\approx& \\biggl(\\exp\\left(-i\\left(2^{-\\tau} \\frac12g_z J_z + \\left(2^{-\\tau}\\frac12g_q\\right) Q\\right)\\right)\\nonumber\\\\\n\t\t\t\t&\\cdot\\exp\\left(-i\\left(2^{-\\tau} g_\\phi J_\\phi\\right)\\right)\\nonumber\\\\\n\t\t\t\t&\\cdot\\exp\\left(-i\\left(2^{-\\tau} \\frac12g_z J_z + \\left(2^{-\\tau} \\frac12g_q\\right) Q\\right)\\right)\\biggr)^{2^\\tau}\\\\\n                =& \\begin{pmatrix}\n                    \\left(\\frac{\\Gamma}{PZ}\\right)^2 & \\frac{SP}{Z\\Phi} & -\\left(\\frac{\\Sigma P}{\\Phi}\\right)^2 \\\\\n\t\t\t\t\t\\frac{SP\\Phi}{Z} & CP^4 & \\frac{SPZ}{\\Phi} \\\\\n\t\t\t\t\t-\\left(\\frac{\\Sigma \\Phi}{P}\\right)^2 & \\frac{SPZ\\Phi}{1} & \\left(\\frac{\\Gamma Z}{P}\\right)^2\n                \\end{pmatrix}^{2^\\tau}\\\\\n\t\t\t\t=& T^{2^\\tau}.\n            \\end{align}\n\n\t\t\twhere\n\n            \\begin{align}\n\t\t\t\tg_\\phi &= \\sqrt{g_x^2 + g_y^2}&&\\nonumber\\\\\n\t\t\t\tJ_\\phi &= \\frac{g_x}{g_\\phi}J_x + \\frac{g_y}{g_\\phi}J_y&&\\nonumber\\\\\n\t\t\t\t\\Gamma &= \\cos\\left(2^{-\\tau} \\frac{g_\\phi}{2}\\right) & \\Phi &= e^{i2^{-\\tau}g_\\phi}\\nonumber\\\\\n\t\t\t\t\\Sigma &= \\sin\\left(2^{-\\tau} \\frac{g_\\phi}{2}\\right) & Z &= e^{i2^{-\\tau}\\frac{g_z}{2}}\\nonumber\\\\\n\t\t\t\tC &= \\cos(2^{-\\tau} g_\\phi) & P &= e^{i2^{-\\tau}\\frac{g_q}{6}}\\nonumber\\\\\n\t\t\t\tS &= \\frac{-i}{\\sqrt2}\\sin(2^{-\\tau} g_\\phi)&&\n            \\end{align}\n        \n\t\t\tOnce \\(T\\) is calculated, it is then recursively squared \\(\\tau\\) times to obtain \\(E(g)\\). The approach used for spin one exponentiation means that the package cannot solve arbitrary spin one quantum systems, as that would require the ability to exponentiate a point in the full, 8 dimensional Lie algebra of \\(\\mathfrak{su}(3)\\), rather than just the four dimensional subspace spanned by the subalgebra \\(\\mathfrak{su}(2)\\) spanned by \\(\\{J_x, J_y, J_z\\}\\), and the single quadratic operator \\(Q\\). Including the full algebra could be possible as a feature update if there is demand for it, though just including this subspace is sufficient for our application, and many others, and has the advantage of being able to use this faster, more specialised method of matrix exponentiation.\n\n\t\t\tNote that, the methods for both spin half and spin one use analytic forms of exponentials to construct the result, meaning that all calculated time evolution operators are unitary. This guarantees that the results of \\texttt{spinsim} maintain unitary. \n\n\t\\subsection*{Software architecture}\n\t\t\\subsubsection*{Integrator architecture}\n\t\t\tThe integrator in the \\texttt{spinsim} package calls a \\texttt{numba.cuda.jit()}ed kernel to be run on a \\emph{Cuda} capable \\emph{Nvidia} GPU in parallel, with a different thread being allocated to each of the \\(U_k\\). This returns when each of the \\(U_k\\) have been evaluated.\n\t\t\t\n\t\t\tThe thread starts by calculating \\(t_k\\) and, if the rotating frame is being used, \\(f_r\\). The latter is done by sampling a (\\texttt{numba.cuda.jit()}ed version of a) user provided \\emph{python} function \\(f\\) describing how to sample the source Hamiltonian. The code then loops over each integration time step \\(\\mathrm{d}t\\) to calculate the integration time evolution operators \\(u^k_l\\).\n\t\t\t\n\t\t\tWithin the loop, the integrator enters a device function (ie a GPU subroutine, which is inline for speed) to sample \\(f(t)\\), as well as calculate \\(e^{-i 2 \\pi f_r t}\\), at the sample times needed for the integration method. After this, it enters a second device function, which makes a rotating wave transformation as needed in a third device function, before calculating \\(g\\) values, and finally taking the matrix exponentiation in a fourth device function. \\(u^k_l\\) is premultiplied to \\(U^r_k\\) (which is initialised to \\(1\\)), and the loop continues.\n\t\t\t\n\t\t\tWhen the loop has finished, if the rotating frame is being used, \\(U^r_k\\) is transformed to \\(U_k\\) as in Equation \\eqref{eq:integration_compilation}, and this is returned. Once all threads have executed, the state \\(\\psi_k\\) is calculated in a (CPU) \\texttt{numba.jit()}ed function from the \\(U_k\\) and an initial condition \\(\\psi_{\\mathrm{init}}\\).\n\t\n\t\n\t\t\\subsubsection*{Compilation of integrator}\n\t\t\tThe \\texttt{spinsim} integrator is constructed and compiled just in time, using \\texttt{numba.cuda.jit()}. The particular device functions used are not predetermined, but are instead chosen based on user input to decide a closure. This structure has multiple advantages. First, the source function \\(f\\) is provided by the user as a plain python function (that must be \\texttt{numba.cuda.jit()} compatible). This allows users to define \\(f\\) in a way that compiles and executes fast, does not put many restrictions on the form of the function, and returns the accurate results of analytic functions (compared to the errors seen in interpolation). Compiling the simulator also allows the user to set meta parameters, and choose the features they want to use, in a way that does not require experience with the \\texttt{numba.cuda} library. This was especially useful for running benchmarks comparing old integration methods to the new ones, like CF4. The default settings should be optimal for most users, although tuning the values of \\emph{Cuda} meta parameters \\texttt{max\\_registers} and \\texttt{threads\\_per\\_block} could improve performance for GPUs with a differing number of registers and \\emph{Cuda} cores to the mobile GTX1070 mainly used in testing here. Finally, just in time compilation also allows the user to select a target device other than \\emph{Cuda} for compilation, so the simulator can run, using the same algorithm, on a multicore CPU in parallel instead of a GPU, if the user so chooses.\n\t\t\t\n\t\t\tThis functionality is interfaced through an object of class \\texttt{spinsim.Simulator}. The \\emph{Cuda} kernel is defined as per the user’s instructions on construction of the instance, and it is used by calling the method \\texttt{spinsim.Simulator.evaluate()}, which returns a results object including the time, state, time evolution operator, and expected spin projection (that is, Bloch vector). Note that the expected spin projection is calculated as a lazy parameter if needed, rather than returned by the simulator object.\n\n\\section*{Quality control}\n\t\\subsection*{Benchmarks}\n\t\t\\subsubsection*{Speed}\n\t\t\t\\begin{figure}[htbp!]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[scale=0.7]{benchmark_device_aggregate.pdf}\n\t\t\t\t\\caption{Evaluation speed of a typical spin one sensing experiment. Fine time step is 100ns, as determined to be ideal by the accuracy experiments. Experiments run for a duration of 100ms. Evaluation time is determined by an average of 100 similar experiments for each device.}\n\t\t\t\t\\label{fig:benchmark_device_aggregate}\n\t\t\t\\end{figure}\n\n\t\t\tBenchmarks were performed using \\texttt{sense.sim.benchmark}, by comparing evaluation speed of typical spin one sensing experiments on different devices. This is shown in Figure \\ref{fig:benchmark_device_aggregate}. The integration code was compiled by \\texttt{numba} for single core CPUs, multicore CPUs, and \\emph{Nvidia Cuda}, and run on different models of each of them. These test devices are given in Table \\ref{tab:devices}.\n\n\t\t\t\\begin{table}[h!]\n\t\t\t\t\\caption{Devices used in the parallelisation speed test.}\n\t\t\t\t\\label{tab:devices}\n\t\t\t\t\\begin{tabular}{l|l|l|l|l}\n\t\t\t\t\t\\textbf{Device}\t&\\textbf{Type}\t&\\textbf{RAM (GiB)}\t&\\textbf{Cores}\t&\\textbf{Cooling}\\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\tCore i7-6700\t&Intel CPU\t\t&16\t\t\t\t\t&4\t\t\t\t&Air\\\\\n\t\t\t\t\tQuadro K620\t\t&Nvidia GPU\t\t&2\t\t\t\t\t&384\t\t\t&Air\\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\tCore i7-8750H\t&Intel CPU\t\t&16\t\t\t\t\t&6\t\t\t\t&Air\\\\\n\t\t\t\t\tGeForce GTX 1070&Nvidia GPU\t\t&8\t\t\t\t\t&2048\t\t\t&Air\\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\tRyzen 9 5900X\t&AMD CPU\t\t&32\t\t\t\t\t&12\t\t\t\t&Air\\\\\n\t\t\t\t\tGeForce RTX 3070&Nvidia GPU\t\t&8\t\t\t\t\t&5888\t\t\t&Air\\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\tRyzen 7 5800X\t&AMD CPU\t\t&32\t\t\t\t\t&8\t\t\t\t&Liquid\\\\\n\t\t\t\t\tGeForce RTX 3080&Nvidia GPU\t\t&10\t\t\t\t\t&8704\t\t\t&Air\\\\\n\t\t\t\t\\end{tabular}\n\t\t\t\\end{table}\n\t\t\t% \\begin{itemize}\n\t\t\t% \t\\item{\n\t\t\t% \t\tComputer A\\begin{itemize}\n\t\t\t% \t\t\t\\item Intel Core i7-8750H, a 6 core laptop processor. Run with 16GiB of RAM. Air cooled (laptop fan). Base clock speed of 2.2GHz.\n\t\t\t% \t\t\t\\item Nvidia GeForce GTX 1070, a 2048 \\emph{Cuda} core laptop graphics processor released in 2016. Run with 8GiB of VRAM. Air cooled (laptop fan).\n\t\t\t% \t\t\\end{itemize}\n\t\t\t% \t}\n\n\t\t\t% \t\\item{Computer B\\begin{itemize}\n\t\t\t% \t\t\t\\item AMD Ryzen 9 5900X, a 12 core desktop processor. Run with 32GiB of RAM. Air cooled. Base clock speed of 3.7GHz.\n\t\t\t% \t\t\t\\item Nvidia GeForce RTX 3070, a 5888 \\emph{Cuda} core desktop graphics processor. Run with 8GiB of VRAM. Air cooled.\n\t\t\t% \t\t\\end{itemize}\n\t\t\t% \t}\n\n\t\t\t% \t\\item{Computer C\\begin{itemize}\n\t\t\t% \t\t\t\\item AMD Ryzen 7 5800X, an 8 core desktop processor. Run with 32GiB of RAM. Liquid cooled. Base clock speed of 3.8GHz.\n\t\t\t% \t\t\t\\item Nvidia GeForce RTX 3080, an 8704 \\emph{Cuda} core desktop graphics processor. Run with 10GiB of VRAM. Air cooled.\n\t\t\t% \t\t\\end{itemize}\n\t\t\t% \t}\n\n\t\t\t% \t\\item{Computer D\\begin{itemize}\n\t\t\t% \t\t\\item Intel Core i7-6700, a 4 core desktop processor. Run with 16GiB of RAM. Air cooled. Base clock speed of 3.4GHz.\n\t\t\t% \t\t\\item Nvidia Quadro K620, a 384 \\emph{Cuda} core desktop graphics processor. Run with 2GiB of VRAM. Air cooled.\n\t\t\t% \t\\end{itemize}\n\t\t\t% \t}\n\t\t\t% \\end{itemize}\n\n\t\t\tThis benchmark shows the benefit to using parallelisation when solving this problem. Moving from a 6 core processor to a 12 core processor doubles the execution speed. Moving from a single core processor to a high end GPU increases performance by well over an order of magnitude. Even the low end Quadro K620 was an improvement over the i7-6700 used by that computer. As an aside, liquid cooling allows the 8 core processor to increase its boost clock and outperform the 12 core processor.\n\n\t\t\\subsubsection*{Evaluation of techniques}\n\t\tAll subsequent benchmarks were run on the desktop computer with the Ryzen 7 5800X and GeForce RTX 3080, which from Figure \\ref{fig:benchmark_device_aggregate} are the fastest CPU and GPU from the devices tested. Benchmarks were performed using \\texttt{neural-sense.sim.benchmark} (where \\texttt{neural-sense} \\cite{alexander-tritt-monash_alexander-tritt-monashneural-sense_2020} is the quantum sensing package that \\texttt{spinsim} was written for). We first wanted to test the accuracy of the different integration techniques for various integration time steps. Here we wanted to test the advantages, if any of using a Magnus based integration method. Accuracy was calculated by taking the quantum state simulation evaluations of a typical quantum sensing experiment and finding the Root Mean Squared (RMS) to a baseline simulation run by \\texttt{scipy.integrate.ivp\\_solve()} as part of the \\emph{SciPy} python package, via\n\n\t\t\t\\begin{align}\n                \\epsilon &= \\frac{1}{K}\\sqrt{\\sum_{k = 0}^{K - 1}\\sum_{m_j = -j}^j|\\psi_{k, (m_j)} - \\psi_{k, (m_j)}^{\\textrm{baseline}}|^2},\\label{eq:error}\n            \\end{align}\n\n\t\t\twhere \\(j \\in \\{\\frac12, 1\\}\\) is the spin quantum number of the system. This simulation of the quantum sensing experiment involves continuously driving transitions in the system, while exposing it to a short pulsed signal that the system should be able to sense. It runs over a duration of 1ms.\n\n\t\t\tThis baseline was computed in 3.8 hours, and was also used for comparisons to other software packages. These are shown in Figures \\ref{fig:benchmark_spin_one_step_error}, and \\ref{fig:benchmark_spin_half_step_error}. For each of these simulations we measured the time of execution, as although it is more accurate compared to Euler integration, the CF4 method is slower for any fixed integration time step. These are shown in Figures \\ref{fig:benchmark_spin_one_execution_error}, and \\ref{fig:benchmark_spin_half_execution_error}. In all of these comparisons, errors above \\(10^{-3}\\) were counted as a failed simulation, as the maximum possible error for a quantum state saturates given that it is a point on a unit complex sphere. Additionally, errors bellow \\(10^{-11}\\) were excluded, as this was the order of magnitude of the errors in the reference simulation.\n\n\t\t\t% The integration techniques tested were\n\t\t\t% \\begin{itemize}\n\t\t\t% \t\\item The Magnus based method, Commutator Free 4.\n\t\t\t% \t\\item The Heun (trapezoidal) Euler method.\n\t\t\t% \t\\item The midpoint Euler method.\n\t\t\t% \\end{itemize}\n\n\t\t\tThe integration techniques tested were the Magnus based CF4, as well as two Euler based sampling methods. A midpoint Euler method was chosen as the simplest (and fastest for a given integration time step)  possible sampling method, whereas a Heun Euler sampling method was used as a comparison to previous versions of this code, which also used it. We benchmarked these methods both while using and not using the rotating frame option. This was done separately for spin one and spin half systems, to ensure they both yield accurate results.\n\n\t\t\tFrom Figures \\ref{fig:benchmark_spin_one} and \\ref{fig:benchmark_spin_half}, we find that overall, the results that \\texttt{spinsim} gives are accurate to those of \\emph{SciPy}. Figures \\ref{fig:benchmark_spin_one_step_error}, and \\ref{fig:benchmark_spin_half_step_error} show that using the Magnus based integration method is up to 3 orders of magnitude more accurate when compared the Euler based methods. Also, using the rotating frame increased the accuracy here by 4 orders of magnitude for any individual integration method. From Figures \\ref{fig:benchmark_spin_one_execution_error}, and \\ref{fig:benchmark_spin_half_execution_error}, although the Magnus based method is slower than the midpoint Euler based method, it makes up for this in terms of its accuracy. Thus, by default \\texttt{spinsim} sets the integrator to CF4, and uses the rotating frame. These can be modified using optional arguments when instantiating the \\texttt{spinsim.Simulator} object.\n\n\t\t\t\\begin{figure}[h!]\n\t\t\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\t\t\\includegraphics[scale=0.475]{benchmark_spin_one_step_error.pdf}\n\t\t\t\t\t\\caption{Accuracy of the spin one options of \\texttt{spinsim}.}\n\t\t\t\t\t\\label{fig:benchmark_spin_one_step_error}\n\t\t\t\t\\end{subfigure}\n\t\t\t\t\\hfill\n\t\t\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\t\t\\includegraphics[scale=0.475]{benchmark_spin_one_execution_error.pdf}\n\t\t\t\t\t\\caption{Speed vs accuracy of the spin one options of \\texttt{spinsim}.}\n\t\t\t\t\t\\label{fig:benchmark_spin_one_execution_error}\n\t\t\t\t\\end{subfigure}\\\n\t\t\t\t\\caption{Speed and accuracy of the spin one options of \\texttt{spinsim}.}\n\t\t\t\t\\label{fig:benchmark_spin_one}\n\t\t\t\\end{figure}\n\n\t\t\t% The that the accuracy of spin half simulations using the Lie Trotter based exponentiator in Figure \\ref{fig:benchmark_spin_half_trotter_step_error} plateaus below \\(10^{-8}\\), whereas an accuracy below \\(10^{-12}\\) is able to be obtained when when the analytic exponentiator in Figure \\ref{fig:benchmark_spin_half_step_error} is used. This also explains the plateau in accuracy from the spin one integrator, where the Lie Trotter based method is the only method implemented. Furthermore, the analytic exponentiator is much faster in Figure \\ref{fig:benchmark_spin_half_execution_error}, as compared to the Lie Trotter based integrator in Figure \\ref{fig:benchmark_spin_half_trotter_execution_error}. Hence, the analytic exponentiator is the default option for \\texttt{spinsim} simulations when in spin half mode.\n\n\t\t\t\\begin{figure}[h!]\n\t\t\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\t\t\\includegraphics[scale=0.475]{benchmark_spin_half_step_error.pdf}\n\t\t\t\t\t\\caption{Accuracy of the spin half options of \\texttt{spinsim}.}\n\t\t\t\t\t\\label{fig:benchmark_spin_half_step_error}\n\t\t\t\t\\end{subfigure}\n\t\t\t\t\\hfill\n\t\t\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\t\t\\includegraphics[scale=0.475]{benchmark_spin_half_execution_error.pdf}\n\t\t\t\t\t\\caption{Speed vs accuracy of the spin half options of \\texttt{spinsim}.}\n\t\t\t\t\t\\label{fig:benchmark_spin_half_execution_error}\n\t\t\t\t\\end{subfigure}\n\t\t\t\t% \\vfill\n\t\t\t\t% \\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\t\t% \t\\includegraphics[scale=0.45]{benchmark_spin_half_trotter_step_error.pdf}\n\t\t\t\t% \t\\caption{Accuracy of the spin half options of \\texttt{spinsim}, using the Lie Trotter exponentiator.}\n\t\t\t\t% \t\\label{fig:benchmark_spin_half_trotter_step_error}\n\t\t\t\t% \\end{subfigure}\n\t\t\t\t% \\hfill\n\t\t\t\t% \\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\t\t% \t\\includegraphics[scale=0.45]{benchmark_spin_half_trotter_execution_error.pdf}\n\t\t\t\t% \t\\caption{Speed vs accuracy of the spin half options of \\texttt{spinsim}, using the Lie Trotter exponentiator.}\n\t\t\t\t% \t\\label{fig:benchmark_spin_half_trotter_execution_error}\n\t\t\t\t% \\end{subfigure}\\\n\t\t\t\t\\caption{Speed and accuracy of the spin half options of \\texttt{spinsim}.}\n\t\t\t\t\\label{fig:benchmark_spin_half}\n\t\t\t\\end{figure}\n\n\t\t\t% \\begin{figure}[h!]\n\t\t\t% \t\\includegraphics[scale=0.9]{benchmark_comparison_spin_one_publication.pdf}\n\t\t\t% \t\\caption{Fine time step benchmark for spin one systems. CF4 is the Magnus commutator free integrator, HS is the two sample exponential integrator used in \\texttt{AtomicPy}, MP is a single sample exponential integrator, RF is use of the rotating frame, and LF is lab frame (no use of the rotating frame). HS and MP results are drawn on top of each other due to their similarities.}\n\t\t\t% \t\\label{fig:benchmark_comparison_spin_one}\n\t\t\t% \\end{figure}\n\n\t\t\t% Figure \\ref{fig:benchmark_comparison_spin_one} shows the performance of \\texttt{spinsim} when running in spin one mode. This shows that both using the Magnus based CF4 method and moving into a rotating frame give significant increases to accuracy. The HS (half step) method in the lab frame, with a time step of 10ns was the method used by \\texttt{AtomicPy}, the previous code used by the group for simulating spin systems. Compared to this, the best performing \\texttt{spinsim} method is 5 orders of magnitude more accurate, while executing in a time 2 orders of magnitude faster.\n\n\t\t\t% \\begin{figure}[h!]\n\t\t\t% \t\\includegraphics[scale=0.9]{benchmark_comparison_spin_half_lt_publication.pdf}\n\t\t\t% \t\\caption{Fine time step benchmark for spin half systems, using the Lie Trotter based exponentiator. CF4 is the Magnus commutator free integrator, HS is the two sample exponential integrator used in \\texttt{AtomicPy}, MP is a single sample exponential integrator, RF is use of the rotating frame, and LF is lab frame (no use of the rotating frame). HS and MP results are drawn on top of each other due to their similarities.}\n\t\t\t% \t\\label{fig:benchmark_comparison_spin_half_lt}\n\t\t\t% \\end{figure}\n\n\t\t\t% From Figure \\ref{fig:benchmark_comparison_spin_half_lt}, one gets essentially the same accuracy for each method when working in spin half mode compared to spin one, if all else is kept constant.\n\n\t\t\t% \\begin{figure}[h!]\n\t\t\t% \t\\includegraphics[scale=0.9]{benchmark_comparison_spin_half_a_publication.pdf}\n\t\t\t% \t\\caption{Fine time step benchmark for spin half systems, using the analytic based exponentiator. CF4 is the Magnus commutator free integrator, HS is the two sample exponential integrator used in \\texttt{AtomicPy}, MP is a single sample exponential integrator, RF is use of the rotating frame, and LF is lab frame (no use of the rotating frame). HS and MP results are drawn on top of each other due to their similarities.}\n\t\t\t% \t\\label{fig:benchmark_comparison_spin_half_a}\n\t\t\t% \\end{figure}\n\n\t\t\t% Figure \\ref{fig:benchmark_comparison_spin_half_a} shows that the Lie Trotter based exponentiator does limit the maximum accuracy obtainable, and for spin half systems, one can increase accuracy further (and decrease execution time) by using an analytic based exponentiator.\n\n\t\t\\subsubsection*{Comparison to alternatives}\n\t\t\tWe ran the same error (using Equation \\eqref{eq:error}) and execution time benchmarks on some alternative packages to compare \\texttt{spinsim}'s performance to theirs. The packages compared were:\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item \\texttt{spinsim} running on the \\emph{Cuda} device, using the CF4 integrator and the rotating frame mode, which were the highest performing options when comparing \\texttt{spinsim} integration methods.\n\t\t\t\t% \\item \\texttt{AtomicPy} \\cite{morris_qcmonkatomicpy_2018}, the previous custom written \\emph{cython} based code developed by our lab group.\n\t\t\t\t\\item \\texttt{NDSolve} from the \\emph{Mathematica} \\cite{wolfram_research_inc_mathematica_2020} software. This was chosen as it is popular with our lab group for simulating magnetometry experiments.\n\t\t\t\t\\item \\texttt{scipy.integrate.ivp\\_solve()} from the \\emph{python} library \\texttt{SciPy} \\cite{virtanen_scipy_2020}. This was chosen as a generic solver from within the python ecosystem.\n\t\t\t\t\\item We had also planned to benchmark against \\texttt{qutip.sesolve()}, a solver in the popular quantum mechanics \\emph{python} library, \\texttt{QuTip} \\cite{johansson_qutip_2013}. However, due to a known bug with the library’s dependencies, this was not installable on Windows 10, the operating system being used for testing, and so benchmarks for it could not be run.\n\t\t\t\\end{itemize}\n\n\t\t\tIn each case, the step sizes of the alternative integrators were limited to a maximum value obtain simulation results of different accuracies. Apart from that, the integrator settings were left untouched from the default values, as a representation of what a user would experience using a generic solver for spin system problems. Similarly to with the internal \\texttt{spinsim} benchmarks, the expected spin projection was evaluated in each case, but the states were compared to calculate a relative error. Also like with the internal benchmarks, we used the longest running \\emph{SciPy} simulation as a ground truth for comparison, as the accuracy of \\emph{Mathematica} plateaus at small time steps.\n\n\t\t\tEach benchmark was run one simulation at a time. However, it might be possible to increase the average speed of many benchmarks from alternative packages using multithreading to run multiple benchmarks at a time. When this was attempted using \\emph{Mathematica}, the kernels crashed as the 32GiB of RAM was not enough to run them all at once. Multithreading was also not attempted using \\emph{SciPy}, due to the fact that running the full set of benchmarks of only a single simulation per integration time step consumes a day of computational time. But to be fair, both \\emph{Mathematica} and \\emph{SciPy} benchmarks are plotted with an artificial reduction in execution time by a factor of 4 and 8, which is an upper bound for the speed increase that could be obtained by running them parallel on a 4 and 8 core processor, respectively. These are respectively shown in plots as both faded and dotted lines.\n\n\t\t\tFrom Figure \\ref{fig:benchmark_external}, for any given error tolerance, \\texttt{spinsim} is over 3 orders of magnitude faster than \\emph{Mathematica}, and 4 orders of magnitude more accurate than \\emph{SciPy}. In practice, this means that an 8 minute \\emph{SciPy} simulation is reduced to 50ms, and a full week long \\emph{SciPy} batch simulation of 1000 separate systems (a realistic situation for testing quantum sensing protocols) would take less than one minute in \\texttt{spinsim}.\n\n\t\t\t\\begin{figure}[h!]\n\t\t\t\t\\includegraphics[scale=0.9]{benchmark_external_execution_error.pdf}\n\t\t\t\t\\caption{Speed vs accuracy of various integration packages.}\n\t\t\t\t\\label{fig:benchmark_external}\n\t\t\t\\end{figure}\n\t\t\t% Compared to our previous code, \\texttt{AtomicPy}, the best performing (default) spin one \\texttt{spinsim} method is 5 orders of magnitude more accurate, while executing in a time 2 orders of magnitude faster on computer A. Another popular solver used by the lab group for magnetometry simulations is \\emph{Mathematica}'s \\cite{wolfram_research_inc_mathematica_2020} \\texttt{NDSolve}. For a comparison between python packages, we also \n\n\t\t\t% We had also planned to benchmark against \\texttt{qutip.sesolve()}, a solver in the popular quantum mechanics \\emph{python} library, \\texttt{QuTip} \\cite{johansson_qutip_2013}. However, due to a known bug with the library’s dependencies, this was not installable on Windows 10, the operating system being used for testing, and so benchmarks for it could not be run.\n\n\t\t\t% We had planned to benchmark against some other popular generic solvers. One such solver was \\texttt{qutip.sesolve()}, a solver in the popular quantum mechanics \\emph{python} library, \\texttt{QuTip} \\cite{johansson_qutip_2013}. However, due to a known bug with the library’s dependencies, this was not installable on Windows 10, the operating system being used for testing, and so benchmarks for it could not be run. We also planned to benchmark accuracy against the generic solver \\texttt{scipy.integrate.ivp\\_solve()} in the \\emph{python} library \\texttt{SciPy} \\cite{virtanen_scipy_2020}. However, using the same \\texttt{get\\_field} function as in the spin one benchmarks used for the \\texttt{spinsim}, simulating with a integration time step of 500ns (the largest used during the \\texttt{spinsim} benchmarks), we found that a single simulation ran in 153s, which is over three orders of magnitude slower than the most accurate \\texttt{spinsim} simulations. This means that a generous projection for the time it would take to run the same benchmarks that \\texttt{spinsim} runs in 11 minutes, using \\texttt{scipy} would be over six days; for an integration package not designed for this problem (and would therefore likely be less accurate).\n\n\t\\subsection*{Testing}\n\t\tDuring the accuracy tests, it was confirmed that all possible modes of \\texttt{spinsim} agree with a standard \\emph{SciPy} simulation up to an arbitrarily small error. The Lie Trotter matrix exponentiator was tested separately from the full system, as well as benchmarked separately. These tests and benchmarks were run as part of the \\texttt{neural\\_sense} package. The simulator has also been used as part of the measurement protocol being developed there, and it has been tested as part of those algorithms as well.\n\n\t\tThe kernel execution was profiled thoroughly, and changes were made to optimise VRAM and register usage and transfer. This was done specifically for the development hardware of an \\emph{Nvidia} GTX1070, so one may get some performance increases by changing some GPU specific meta parameters when instantiating the \\texttt{spinsim.Simulator} object.\n\n\t\tA good way to confirm that \\texttt{spinsim} is functioning properly after an installation is to run the tutorial code provided and compare the outputs. Otherwise, one can reproduce the benchmarks shown here using \\texttt{neural\\_sense.sim.benchmark}.\n\n\\section*{(2) Availability}\n\\vspace{0.5cm}\n\\section*{Operating system}\nDeveloped and tested on Windows 10. CPU functionality tested on MacOS Big Sur (note that modern Mac computers are not compatible with \\emph{Cuda} software). All packages referenced in \\texttt{spinsim} are compatible with Linux, but functionality has not been tested.\n\n\\section*{Programming language}\nPython (3.7 or greater)\n\n\\section*{Additional system requirements}\nTo use the (default) \\emph{Nvidia Cuda} GPU parallelisation, one needs to have a \\emph{Cuda} compatible \\emph{Nvidia} GPU \\cite{noauthor_cuda_2012}. For \\emph{Cuda} mode to function, one also needs to install the \\emph{Nvidia Cuda} toolkit \\cite{noauthor_cuda_2013}. If \\emph{Cuda} is not available on the system, the simulator will automatically parallelise over multicore CPUs instead.\n\n\\section*{Dependencies}\nnumba (0.50.1 or greater)\\\\\nnumpy (1.19.3)\\\\\nmatplotlib (for example code, 3.2)\\\\\nneuralsense (for benchmark code)\n\n\\section*{List of contributors}\n\n1. Alex Tritt\\\\\n\tSchool of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPrimary author of the released packages.\\\\\n2. Joshua Morris\\\\\n\tSchool of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPresent address: Faculty of Physics, University of Vienna, 1010 Vienna, Austria.\\\\\n\tAuthor of first version of code.\\\\\n3. Joel Hockstetter\\\\\n\tSchool of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tPresent address: School of Physics, University of Sydney, NSW 2006, Australia.\\\\\n\tOptimization and extension to spin one of first version of code.\\\\\n4. Russell P. Anderson\\\\\n\tSchool of Molecular Sciences, La Trobe University, PO box 199, Bendigo, Victoria 3552, Australia.\\\\\n\tOriginal conception of first version of code.\\\\\n5. James Saunderson\\\\\n\tDepartment of Electrical and Computer Systems Engineering, Monash University, Victoria 3800, Australia.\\\\\n\tAdvice on numerical analysis.\\\\\n6. Lincoln D. Turner\\\\\n\tSchool of Physics \\& Astronomy, Monash University, Victoria 3800, Australia.\\\\\n\tOriginal conception of released version of algorithm.\n\n\\section*{Software location:}\n\n{\\bf Archive}\n\n\\begin{description}[noitemsep,topsep=0pt]\n\t\\item[Name:] Monash Bridges\n\t\\item[Persistent identifier:] 10.26180/13285460\n\t\\item[Licence:] Apache 2.0\n\t\\item[Publisher:]  Alex Tritt\n\t\\item[Version published:] 1.0.0\n\t\\item[Date published:] \\textcolor{blue}{dd/mm/yy}\n\\end{description}\n\n{\\bf Code repository}\n\n\\begin{description}[noitemsep,topsep=0pt]\n\t\\item[Name:] GitHub\n\t\\item[Persistent identifier:] https://github.com/alexander-tritt-monash/spinsim\n\t\\item[Licence:] BSD 3 Clause\n\t\\item[Date published:] 18/11/20\n\\end{description}\n\n\\section*{Language}\n\nEnglish.\n\n\\section*{(3) Reuse potential}\n\n\t\\subsection*{Use potential and limitations}\n\t\t\\texttt{spinsim} will be useful for any research group needing quick, accurate, and / or large numbers of simulations involving spin half or spin one systems. This is immediately relevant to developing new quantum sensing protocols with spin half and spin one systems. This package is being used in the context of Bose Einstein Condensate (BEC) magnetic sensing protocol design by our lab.\n\n\t\tThis project is to be able to measure neural signals using BECs. The electrical pulses made by neurons are currently measured using electrical probes, which is intrusive and damages the cells. We instead propose to sense the small magnetic fields that these electrical currents produce. Rubidium BECs can potentially be made sensitive enough to these tiny magnetic fields that they can be measured by them. \\texttt{spinsim} was written to simulate possible measurement protocols for this, showing the behaviour of the array of spin one atoms interacting with the magnetic fields of the neurons, control signals, and noise. The package is also now being used to simulate other BEC magnetometry experiments by the lab group.\n\n\t\tAnother example of spin based magnetic field sensing is the use of Nitrogen Vacancy Centres (NVCs). These are spin one structures found in diamond doped with Nitrogen atoms. This leaves a vacancy in a position adjacent to the Nitrogen atom, which pairs of electrons occupy to obtain the spin one properties. Similar to BECs, NVCs can be placed and addressed in 2D arrays in order to take many samples in one measurement. A paper was only recently released covering simulation experiments of magnetic neural pulse sensing using NVCs \\cite{parashar_axon_2020}, which is something that \\texttt{spinsim} could be useful for.\n\n\t\t\\texttt{spinsim} is designed to simulate small dimensional quantum systems, including large arrays of non-interacting spin systems. This means that it would not be able to integrate large arrays of entangled states or interacting particles. As a result, despite being fast at simulating qubits, it is inappropriate for the package to be used for quantum computing. In addition, \\texttt{spinsim} is currently designed to integrate the time evolution of pure states only. This means that it may not be adequate for use in some Nuclear Magnetic Resonance (NMR) applications where relaxation \\cite{veshtort_spinevolution_2006} is important (or other kinds of simulations involving decoherence).\n\n\t\tWith these restrictions in mind, \\texttt{spinsim} could be used for some simplified simulations in various areas of NMR. There are many atomic nuclei with spins of half (eg protons, Carbon 13) and, and fewer that have spins of one (eg Lithium 6, Nitrogen 14) \\cite{fuller_nuclear_1976}, which, if relaxation and interactions between systems are not important for the application, \\texttt{spinsim} could be used to simulate for spectroscopy experiments, for example. The inclusion of a quadrupole operator means that, with the same level of simplifications, \\texttt{spinsim} should be able to simulate Nuclear Quadrupole Resonance (NQR) spectroscopy for spin one nuclei \\cite{bain_nqr_2004}, such as Nitrogen 14, provided a suitable coordinate system is chosen. This technique measures energy level differences between levels split by electric field gradients, rather than static magnetic bias fields. Another possible use case could be for Magnetic Resonance Imaging (MRI) simulation and pulse sequence design. MRI uses measures the response of spins of an array of spin half protons to a spatially varying pulse sequence \\cite{mckinnon_physics_1998}, which essentially just corresponds to many separate \\texttt{spinsim} simulations of spins at different positions in space. While this package offers some advantages over state of the art simulators in the field \\cite{kose_fast_2019}, with its use of quantum mechanics over classical mechanics, and its absence of rotating wave approximations, its parametrised pulse sequence definitions and geometric integrator, again, the lack of interacting particles and decoherence features are may limit its use in this area.\n\n\t\\subsection*{Support}\n\t\tDocumentation for \\texttt{spinsim} is available on \\href{https://spinsim.readthedocs.io/en/latest/}{\\emph{Read the Docs}}. This documentation contains a thorough tutorial on how to use the package, and installation instructions.\n\t\t\n\t\tFor direct support with the \\texttt{spinsim} package, one can open an issue in the \\emph{github} repository. One can also use this contact to suggest extensions to the package. \\texttt{spinsim} is planned to be maintained by the Monash University spinor BEC lab into the future.\n\n\\section*{Acknowledgements}\n\nThank you to the Monash University School of Physics and Astronomy spinor BEC lab group, particularly Hamish Taylor and Travis Hartley, who have started using \\texttt{spinsim} for their own projects and have given useful feedback of their user experience with the package.\n\n\\section*{Funding statement}\n\n\\textcolor{blue}{If the software resulted from funded research please give the funder and grant number.}\n\n\\section*{Competing interests}\n\nThe authors declare that they have no competing interests.\n\n\\bibliography{spinsim}{}\n\\bibliographystyle{vancouver}\n\n\\vspace{2cm}\n\n\\rule{\\textwidth}{1pt}\n\n{ \\bf Copyright Notice} \\\\\nAuthors who publish with this journal agree to the following terms: \\\\\n\nAuthors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a  \\href{http://creativecommons.org/licenses/by/3.0/}{Creative Commons Attribution License} that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal. \\\\\n\nAuthors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal. \\\\\n\nBy submitting this paper you agree to the terms of this Copyright Notice, which will apply to this submission if and when it is published by this journal.\n\n\n\\end{document}\n", "meta": {"hexsha": "ca2ee8812eea43954c97ef7ac63cef0799ce7ed8", "size": 55367, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "article/article.tex", "max_stars_repo_name": "rpanderson/spinsim", "max_stars_repo_head_hexsha": "8f93b7dd1964290e2cc85ae1c15e73ca31a34bdc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "article/article.tex", "max_issues_repo_name": "rpanderson/spinsim", "max_issues_repo_head_hexsha": "8f93b7dd1964290e2cc85ae1c15e73ca31a34bdc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "article/article.tex", "max_forks_repo_name": "rpanderson/spinsim", "max_forks_repo_head_hexsha": "8f93b7dd1964290e2cc85ae1c15e73ca31a34bdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.0144694534, "max_line_length": 1668, "alphanum_fraction": 0.740025647, "num_tokens": 15340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.44852523202785666}}
{"text": "\n\\documentclass[11pt,a4paper]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{authblk}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{multirow}\n\\usepackage{hyperref}\n\\hypersetup{\ncolorlinks=true,\nlinkcolor=black,\ncitecolor=black\n}\n\\usepackage{caption}\n\\usepackage{subfigure}\n\\usepackage{mathrsfs}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{algorithm}\n\\usepackage{algcompatible}\n\\usepackage{algpseudocode} \\usepackage{romannum}\n\\usepackage{amsmath}\n\\usepackage{verbatimbox}\n\\usepackage{enumitem}\n\\usepackage{todonotes}\n\\usepackage{geometry}\n\\geometry{left = 2.0cm, right = 2.0 cm, top = 2cm}\n%% The graphicx package provides the includegraphics command.\n\\usepackage{graphicx}\n%% The amssymb package provides various useful mathematical symbols\n\\usepackage{amssymb}\n%% The amsthm package provides extended theorem environments\n%% \\usepackage{amsthm}\n\\usepackage{bm}\n\\usepackage{hyperref}\n\n%% The lineno packages adds line numbers. Start line numbering with\n%% \\begin{linenumbers}, end it with \\end{linenumbers}. Or switch it on\n%% for the whole article with \\linenumbers after \\end{frontmatter}.\n\\usepackage{lineno}\n\n\\usepackage{authblk}\n\n\n\n%% Title, authors and addresses\n\n\\title{Relationship between Matrix/Tensor Factorization and Linear Regression}\n\\author{Mengyan Zhang}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n%% Text of abstract\nLinear regression aims to model the relationship between two variables by fitting a linear equation to observed data. Matrix or tensor factorization is to factorize matrix or tensor into two or more smaller size matrices or tensors, which can be viewed as a regression problem, where the independent variable is each entry in the matrix/tensor, the corresponding dependent variable is the estimated entry. Therefore, the methods for linear regression can also be applied to the matrix/tensor factorization. This tutorial aims to present these relationships between matrix/tensor factorization and linear regression in detail.\n\\end{abstract}\n%There are several ways to find the best parameters of the linear equation, for example, we can use least squares to find the parameters which gives the minimum residuals. In probabilistic view, we can maximize the likelihood of observing a target value given we know the input location and parameters.\n% \\begin{keyword}\n% Science \\sep Publication \\sep Complicated\n%% keywords here, in the form: keyword \\sep keyword\n\n%% MSC codes here, in the form: \\MSC code \\sep code\n%% or \\MSC[2008] code \\sep code (2000 is the default)\n\n% \\end{keyword}\n\n\\begin{table}[h]\n\\small\n\\centering\n\\begin{tabular}{|l|l|l|l|l|}\n\\hline\n & \\textbf{\\begin{tabular}[c]{@{}l@{}}Least Squares\\end{tabular}} & \\textbf{\\begin{tabular}[c]{@{}l@{}}Maximum Likelihood\\end{tabular}} & \\textbf{\\begin{tabular}[c]{@{}l@{}}Maximum A Posterior\\end{tabular}} & \\textbf{\\begin{tabular}[c]{@{}l@{}}Bayesian \\\\ Approaches\\end{tabular}} \\\\\n \\hline\n\\textbf{LR}   &  $\\mathop{\\arg\\min}_{\\bm{\\theta}} {\\| \\bm{y} - X \\bm{\\theta}\\|}_{F}^2$&   $\\mathop{\\arg\\max}_{\\bm{\\theta}} p(\\bm{y}| X, \\bm{\\theta}, \\sigma)$&    $\\mathop{\\arg\\max}_{\\bm{\\theta}} p(\\bm{\\theta}| X, \\bm{y}, \\sigma, \\sigma_{\\theta})$  &   $p(\\bm{\\theta}| X, \\bm{y}, \\sigma, \\sigma_{\\theta})$            \\\\ \\hline\n\\textbf{MF}&  $\\mathop{\\arg\\min}_{U,V} \\|A - UV\\|_F^2$ &  \n$\\mathop{\\arg\\max}_{U,V} p(A| U, V, \\sigma)$  &   \n$\\mathop{\\arg\\max}_{U,V} p(U,V| A, \\sigma, \\sigma_U, \\sigma_V)$&  $p(U,V| A, \\sigma, \\sigma_U, \\sigma_V)$  \\\\ \\hline\n\\textbf{TF} &  \\textbf{\\begin{tabular}[c]{@{}l@{}}$\\mathop{\\arg\\min}_{E,R}$ \\\\ $\\sum_{k=1}^K \\|T_{:k:} - E R_k E^T\\|_F^2$\\end{tabular}} & \n$\\mathop{\\arg\\max}_{E,R} p(T| E, R, \\sigma)$  & $\\mathop{\\arg\\max}_{E,R} p(E,R| T, \\sigma, \\sigma_E, \\sigma_R)$             &     $p(E,R| T, \\sigma, \\sigma_E, \\sigma_R)$         \\\\ \\hline\n\\end{tabular}\n\\caption{Relation between linear regression and matrix/tensor factorization. LR: linear regression; MF: matrix factorization; TF: tensor factorization}\n\\end{table}\n\n%%\n%% Start line numbering here if you want\n%%\n\\linenumbers\n\n\\section{Linear Regression}\n%% main text\nFor linear regression, given D dimensional inputs $\\bm{x} \\in \\mathbb{R}^D$ and corresponding target $y \\in \\mathbb{R}$, we aim to find a linear model which can estimate the target value for unseen input accurately. Then linear model can be built as\n\n\\begin{equation}\n\\label{equ1}\n\\hat{y} = f(\\bm{x}) + \\epsilon = \\bm{x}^T \\bm{\\theta} + \\epsilon,\n\\end{equation}\nwhere  $\\bm{\\theta} \\in \\mathbb{R}^D$ are the parameters we seek, and $\\epsilon \\sim \\mathbb{N}(0, \\sigma)$ is i.i.d. Gaussian observation noise. %Then for N inputs $\\bm{x_n} \\in \\mathcal{R}^D$ and corresponding target $y_n \\in \\mathbb{R}$, n = 1, ... , N. Assume conditional independence\n%$$p(y_i|\\bm{x_i}) \\bot p(y_j|\\bm{x_j}),$$\n\n\\subsection{Least Squares}\n\nIntuitively, we want to find the parameters which can estimate the target value as accurate as possible, i.e. the sum of squares of the vertical deviations as small as possible, which is known as   \\href{https://en.wikipedia.org/wiki/Least_squares}{Least squares}. For N inputs $\\bm{x_n} \\in \\mathcal{R}^D$ and corresponding target $y_n \\in \\mathbb{R}$, n = 1, ... , N, we find parameters $\\bm{\\theta}$ by,\n\n\\begin{equation}\n\\label{equ2}\n\\mathop{\\arg\\min}_{\\bm{\\theta}} \\ \\ \\sum_{n=1}^N (y_n - \\hat{y_n})^2,\n\\end{equation}\nwhere $\\hat{y_n}$ is defined as Equation \\ref{equ1}. In matrix form, we have\n\n\\begin{equation}\n\\mathop{\\arg\\min}_{\\bm{\\theta}} {\\ \\  \\| \\bm{y} - X \\bm{\\theta} - \\sigma\\|}_{F}^2,\n\\end{equation}\nwhere $X := [\\bm{x_1, ..., x_N}]^T \\in \\mathbb{R} ^{N \\times D}$ and $\\bm{y} := [y_1, ... , y_N]^T \\in \\mathbb{R}^N$.\n\n\n\n\n%\\subsection{Maximum Likelihood Estimation}\n\n%\\subsection{Maximum A Posterior}\n%\\subsection{Bayesian Linear Regression}\n\n\\section{Matrix Factorization}\nMatrix factorization is to factorize of a matrix into a product of matrices. For a given matrix $A \\in \\mathbb{R}^{N \\times M}$, it can be factorized as the product as the product of $U \\in \\mathbb{R}^{N \\times D}, V \\in \\mathbb{R}^{D \\times M}$, i.e.\n\n\\begin{equation}\n\\hat{A} = UV,\n\\end{equation}\n\n\\subsection{Least Squares}\n\nSimilar as linear regression, we want the estimated matrix $\\hat{A}$ (i.e. the product of factorized matrices U and V) as much similar as the original matrix A. Thus the simplest way is to minimize the sum of error squares, \n\n\\begin{equation}\n\\mathop{\\arg\\min}_{U,V} \\ \\ \\sum_{i=1}^N \\sum_{j=1}^M (a_{ij} - \\hat{a_{ij}})^2,\n\\end{equation}\nwhere $\\hat{a_{ij}} = \\bm{u_i}^T \\bm{v_j}$ is the (i,j) entry of the estimated matrix $\\hat{A}$. In matrix form, \n\n\\begin{equation}\n\\mathop{\\arg\\min}_{U,V} \\ \\ \\|A - UV\\|_F^2,\n\\end{equation}\n\n\\section{Tensor Factorization}\n\nMore generally, we need to deal with random dimension tensors rather than 2-d matrix. Using a three-way tensor $ T \\in \\mathbb{R}^{N \\times K \\times N} $ as example, we simplify the tensor factorization into multiple matrix factorizations, i.e. for each slice $T_{:k:}$, we have\n\n\\begin{equation}\n\\hat{T_{:k:}} = E R_k E^T, \\ \\ \\ \\textnormal{for} \\ \\ k = 1, ..., K,\n\\end{equation}\nwhere $E \\in \\mathbb{R}^{N \\times D}$, $R_k \\in \\mathbb{R}^{D \\times D}$ are factorized matrices for slice k. Note that E will be the same for all slices.\n\n\\subsection{Least Squares}\n\nSimilar as matrix factorization, we still want to find the most similar estimated matrix by minimizing the mean squared error, i.e.\n\n\\begin{equation}\n\\mathop{\\arg\\min}_{E,R} \\sum_{k=1}^K \\|T_{:k:} - E R_k E^T\\|_F^2,\n\\end{equation}\n\n%\\bibliographystyle{model1-num-names}\n%\\bibliography{sample.bib}\n\n\\end{document}\n\n%%\n%% End of file `elsarticle-template-1-num.tex'.", "meta": {"hexsha": "f2d2b22a964b192658f671aff87c10e6c91adb69", "size": 7614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MF_LR.tex", "max_stars_repo_name": "Mengyanz/eheye", "max_stars_repo_head_hexsha": "bbc2bda30cf3fb48a45235b7629757df62f71dfc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MF_LR.tex", "max_issues_repo_name": "Mengyanz/eheye", "max_issues_repo_head_hexsha": "bbc2bda30cf3fb48a45235b7629757df62f71dfc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MF_LR.tex", "max_forks_repo_name": "Mengyanz/eheye", "max_forks_repo_head_hexsha": "bbc2bda30cf3fb48a45235b7629757df62f71dfc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.0532544379, "max_line_length": 625, "alphanum_fraction": 0.7010769635, "num_tokens": 2449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.4485252295574037}}
{"text": "\\vsssub\n\\subsubsection{~Parameter settings in modules}\n\\vsssub\n\nSeveral modules have internally used parameter settings. Here only parameter\nsettings that are generally usable or impact model behavior are presented.\n\n\\vspace{\\baselineskip} \\noindent\nPhysical and mathematical constants : \\hfill {\\file constants.ftn}\n\\begin{vlist}\n\\vit{grav  }{rp}{Acceleration of gravity $g$.\n                \\hfill (m s$^{-2}$)}\n\\vit{dwat  }{rp}{Density of water. \\hfill(kg m$^{-3}$)}\n\\vit{dair  }{rp}{Density of air. \\hfill(kg m$^{-3}$)}\n\\vit{nu\\_air}{rp}{Kinematic viscosity of air \\hfill (m$^2$ s$^{-1}$)}\n\\vit{nu\\_water}{rp}{Kinematic viscosity of water \\hfill (m$^2$ s$^{-1}$)}\n\\vit{sed\\_sd}{rp}{Specific gravity of sediment \\hfill (--)}\n\\vit{kappa }{rp}{Von Karman's constants \\hfill (--)}\n\\vit{pi    }{rp}{$\\pi$.}\n\\vit{tpi   }{rp}{$2\\pi$.}\n\\vit{hpi   }{rp}{$0.5\\pi$.}\n\\vit{tpiinv}{rp}{$(2\\pi)^{-1}$.}\n\\vit{hpiinv}{rp}{$(0.5\\pi)^{-1}$.}\n\\vit{rade  }{rp}{Conversion factor from radians to degrees.}\n\\vit{dera  }{rp}{Conversion factor from degrees to radians.}\n\\vit{radius}{rp}{Radius of the earth. \\hfill (m)}\n\\vit{g2pi3i}{rp}{$g^{-2} (2\\pi)^{-3}$.}\n\\vit{g1pi1i}{rp}{$g^{-1}(2\\pi)^{-1}$.}\n\\end{vlist}\n\n\\noindent\nWave model initialization module : \\hfill {\\file w3initmd.ftn}\n\\begin{vlist}\n\\vit{critos}{rp}{Critical fraction of resources used for output only\n                     (triggers warning output).}\n\\vit{wwver }{cp}{Version number of the main program.}\n\\vit{switches}{cp}{Switches taken from {\\file bin/switch}.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file mod\\_def.ww3}) : \\hfill {\\file w3iogrmd.ftn}\n\\begin{vlist}\n\\vit{vergrd}{cp\\opt}{Version number of file {\\file mod\\_def.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file out\\_grd.ww3}) : \\hfill {\\file w3iogomd.ftn}\n\\begin{vlist}\n\\vit{verogr}{cp\\opt}{Version number of file {\\file out\\_grd.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file out\\_pnt.ww3}) : \\hfill {\\file w3iopomd.ftn}\n\\begin{vlist}\n\\vit{veropt}{cp\\opt}{Version number of file {\\file out\\_pnt.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\vit{acc   }{cp}{Relative offset below which output point is moved to grid\n                 point.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file track\\_o.ww3}) : \\hfill {\\file w3iotrmd.ftn}\n\\begin{vlist}\n\\vit{vertrk}{cp\\opt}{Version number of file {\\file track\\_o.ww3}.}\n\\vit{idstri}{cp\\opt}{ID string for file {\\file track\\_i.ww3}.}\n\\vit{otype }{cp}{Array dimension.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file restart.ww3}) : \\hfill {\\file w3iorsmd.ftn}\n\\begin{vlist}\n\\vit{verini}{cp\\opt}{Version number of file {\\file restart.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file nest.ww3}) : \\hfill {\\file w3iobcmd.ftn}\n\\begin{vlist}\n\\vit{verbpt}{cp\\opt}{Version number of file {\\file nest.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\end{vlist}\n\n\\noindent\nI/O module ({\\file partition.ww3}) : \\hfill {\\file w3iosfmd.ftn}\n\\begin{vlist}\n\\vit{vertrt}{cp\\opt}{Version number of file {\\file partition.ww3}.}\n\\vit{idstr }{cp\\opt}{ID string for file.}\n\\end{vlist}\n\n\\noindent\nMulti-grid model input update : \\hfill {\\file wmupdtmd.ftn}\n\\begin{vlist}\n\\vit{swpmax}{ip}{Maximum number of extrapolation sweeps allowed to make maps\n                 match in conversion from input from input grid to wave model\n                 grid.}\n\\end{vlist}\n\n\\noindent\nSeveral routines contain interpolation tables that are set up with parameter\nstatements, including\n\n\\vspace{\\baselineskip} \\noindent\nSolving the dispersion relation : \\hfill {\\file w3dispmd.ftn}\n\\begin{vlist}\n\\vit{nar1d }{ip}{Dimension of interpolation tables.}\n\\vit{dfac  }{rp}{Maximum nondimensional water depth $kd$.}\n\\vit{ecg1  }{ra}{Table for calculating  group velocities from\n                 the frequency and the depth.}\n\\vit{ewn1  }{ra}{Id. wavenumbers.}\n\\vit{n1max }{i }{Largest index in tables.}\n\\vit{dsie  }{r }{Nondimensional frequency increment.}\n\\end{vlist}\n\n\\noindent\nShallow water quadruplet lookup table for \\gmd\\ : \\hfill {\\file w3snl3md.ftn}\n\\begin{vlist}\n\\vit{nkd   }{ip}{Number of nondimensional depths in storage array.}\n\\vit{kdmin }{rp}{Minimum relative depth in table.}\n\\vit{kdmax }{rp}{Maximum relative depth in table.}\n\\vit{lammax}{rp}{Maximum value for $\\lambda$ or $\\mu$.}\n\\vit{delthm}{rp}{Maximum angle gap $\\theta_{12}$ ($\\degree$).}\n\\end{vlist}\n\n\\noindent\nShallow water lookup table for nonlinear filter : \\hfill {\\file w3snlsmd.ftn}\n\\begin{vlist}\n\\vit{nkd   }{ip}{Number of nondimensional depths in storage array.}\n\\vit{kdmin }{rp}{Minimum relative depth in table.}\n\\vit{kdmax }{rp}{Maximum relative depth in table.}\n\\vit{abmax }{rp}{Maximum value for $a_{34}$.}\n\\end{vlist}\n\n\\noindent\nLookup table for $\\beta$ in Tolman and Chalikov 1996 : \\hfill {\\file w3src2md.ftn}\n\\begin{vlist}\n\\vit{nrsiga}{ip}{Array dimension ($\\sigma_a$).}\n\\vit{nrdrag}{ip}{Array dimension ($C_d$).}\n\\vit{sigamx}{rp}{Maximum nondimensional frequency $\\tilde{\\sigma}_a$.}\n\\vit{dragmx}{rp}{Maximum drag coefficient $C_d$}\n\\end{vlist}\n\n\\noindent\nLookup table for \\ldots in WAM-4 / ECWAM : \\hfill {\\file w3src3md.ftn}\n\\begin{vlist}\n\\vit{kappa  }{rp}{von K{\\'a}rm{\\'a}n's constant.}\n\\vit{nu\\_air}{rp}{air viscosity.}\n\\vit{itaumax}{ip}{size of stress dimension.}\n\\vit{jumax  }{ip}{size of wind dimension.}\n\\vit{iustar }{ip}{size of ustar dimension.}\n\\vit{ialpha }{ip}{size of Charnock dimension.}\n\\vit{ilevtail}{ip}{size of tail level dimension.}\n\\vit{umax   }{rp}{Maximum wind speed in table.}\n\\vit{tauwmax}{rp}{Maximum ustar in table.}\n\\vit{eps1   }{rp}{Small number for stress convergence.}\n\\vit{eps2   }{rp}{Small number for stress convergence.}\n\\vit{niter  }{ip}{Number of iterations in stress table.}\n\\vit{xm     }{ip}{power of TAUW/TAU in roughness parameterization.}\n\\vit{jtot   }{ip}{Number of points in discretization of tail.}\n\\end{vlist}\n\n\\noindent\nLookup tables Ardhuin et al. 2010 : \\hfill {\\file w3src3md.ftn}\n\nCombination of previous two sets of parameters. \\\\\n\n\\noindent\nTable of error functions in bottom friction : \\hfill {\\file w3sbt4md.ftn}\n\\begin{vlist}\n\\vit{sizeerftable}{ip}{Size of table for erf function.}\n\\vit{xerfmax}{rp }{Maximum value of x in table of erf(x).}\n\\vit{wsub   }{rpa}{Weights for 3-point Gauss-Hermitte quadrature.}\n\\vit{xsub   }{rpa}{x values for 3-point Gauss-Hermitte quadrature.}\n\\end{vlist}\n\n\\noindent\nSome model parameters are set using parameter statements.\n\n\\vspace{\\baselineskip}\n\\noindent\nSource term computation and integration : \\hfill {\\file w3srcemd.ftn}\n\\begin{vlist}\n\\vit{offset}{rp\\opt}{Offset $\\epsilon$ in Eq.~(\\ref{eq:implicit_st}).}\n\\end{vlist}\n\n\\noindent\nAuxiliary data storage : \\hfill {\\file w3adatmd.ftn}\n\\begin{vlist}\n\\vit{mpibuf}{ip}{Number of buffers used in \\mpi\\ data transpose.}\n\\end{vlist}\n\n\\noindent\nSome service routines contain parameters that can be used to influence, for\ninstance, the model output.\n\n\\vspace{\\baselineskip}\n\\noindent\nArray I/O including text outputs : \\hfill {\\file w3arrymd.ftn}\n\\begin{vlist}\n\\vit{icol  }{ip\\opt}{Set maximum columns on output (now set to 80).}\n\\vit{nfrmax}{ip\\opt}{Set maximum number of frequency in spectral print plots\n                     (now set to 50).}\n\\end{vlist}\n\n\\noindent\nAutomatic unit number assignment : \\hfill {\\file wmunitmd.ftn}\n\\begin{vlist}\n\\vit{unitlw}{ip}{Lowest unit number to be considered.}\n\\vit{unithg}{ip}{Highest unit number to be considered.}\n\\vit{inplow, inphgh}{}{}\n\\vit{      }{ip}{Range of input file unit numbers.}\n\\vit{outlow, outhgh}{}{}\n\\vit{      }{ip}{Range of output file unit numbers.}\n\\vit{scrlow, scrhgh}{}{}\n\\vit{      }{ip}{Range of scratch file unit numbers.}\n\\end{vlist}\n\n\\noindent\nCreating spectral bulletins : \\hfill {\\file w3bullmd.ftn}\n\\begin{vlist}\n\\vit{nptab, nfld, npmax, bhsmin, bhsdrop, dhsmax,}{}{}\n\\vit{dptmx, ddmmax, ddwmax, agemin}{}{}\n\\vit{}{i/rp}{Setting of size of bulletin as well as various filter values.}\n\\end{vlist}\n\n\n", "meta": {"hexsha": "f1dc1d240e4bbd6ae853d316b74fe09ee72eed9b", "size": 7930, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/sys/modules.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/sys/modules.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/sys/modules.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 34.7807017544, "max_line_length": 82, "alphanum_fraction": 0.6944514502, "num_tokens": 2726, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4485252253981146}}
{"text": "\n\n\\documentclass[12pt]{article}\n\\usepackage[margin=1in]{geometry}\n\\usepackage[T1]{fontenc}\n\\usepackage[USenglish]{babel}\n\\usepackage[nodayofweek,level]{datetime}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usetikzlibrary{intersections,arrows.meta}\n\\usepackage{pgfplots}\n\\usepackage[scr]{rsfso}\n\\usepackage{array}\n\\usepackage{stackengine}\n\\hbadness=10001 %gets rid of \"\\hfill underfull\" warning\n\\stackMath\n\n\\usepackage{tikz,pgfplots}\n\n\\pgfplotsset{compat=1.10}\n% Uncomment to use \"fillbetween\" function\n% otherwise leave commented because\n% the red highlighting is annoying\n%\\usepgfplotslibrary{fillbetween}\n\n\n% Change for each new hw week\n\\newcommand{\\dueDate}{\\formatdate{22}{11}{2017}} % day/month/year\n\\newcommand{\\hwNum}{8}\n\n\n\\begin{document}\n\t\n\t\\selectlanguage{USenglish}\t\n\t%------------------------ Title Code ------------------------\n\t\\title{Homework: Week \\hwNum}\n\t\\author{Joseph Ismailyan}\n\t\\date{}\n\t\\maketitle\n\t\\begin{flushleft}\n\t\tMath 100 \\\\\n\t\tDue: \\dueDate \\\\ \n\t\tProfessor Boltje \\\\\n\t\tMWF 9:20a-10:25a\n\t\\end{flushleft}\n\t\n\t\n\t%------------------------ Begin Page 1 ------------------------\n\t\\begin{minipage}[t]{0.40\\textwidth}\n\t\t\n\t\t\n\t\t\n\t\t\\section*{Chapter 10. }\n\t\t\\subsection*{2.}\n\t\t\\textbf{Proposition}: For every integer $ n\\in\\mathbb{N} $, it follows that $ 1^2+2^2+3^2+\\ldots+n^2=\\frac{n(n+1)(2n+1)}{6} $.  \n\t\t\\newline\\textit{Proof.} Observe that if $ n=1 $ the statement $ 1^2=\\frac{1((1)+1)(2(1)+1)}{6}=\\frac{1(2)(3)}{6}=1 $, so the statement is true. Now let $ k\\geq  1$, so $ 1^2+2^2+3^2+\\ldots+(k+1)^2 = 1^2+2^2+3^2+\\ldots+k^2+(k+1)^2 = \\frac{k(k+1)(2k+1)}{6} + (k+1)^2 = (k+1)\\frac{k(2k+1)}{6} + (k+1) = (k+1)(\\frac{k(2k+1+ 6k+6)}{6}) = (k+1)(\\frac{2k^2+k+6k+6}{6}) = (k+1)(\\frac{2k^2+7k+6}{6}) = (k+1)(\\frac{2k^2+4k+3k+6}{6}) = (k+1)(\\frac{2k(k+1)+3(k+2)}{6})=(k+1)(\\frac{(k+2)(2k+3)}{6})=\\frac{(k+1)(k+1+1)(2k+2+1)}{6} = \\frac{(k+1)((k+1)+1)(2(k+1)+1)}{6} $. Therefore $ 1^2+2^2+3^2+\\ldots+(k+1)^2 = \\frac{(k+1)((k+1)+1)(2(k+1)+1)}{6} $. It follows by induction that $ 1^2+2^2+3^2+\\ldots+n^2=\\frac{n(n+1)(2n+1)}{6} $ for every natural number $ n $.\n\t\t\n\t\t\n\t\\end{minipage}\n\t% Creates vertical line\n\t\\hfill\\vline\\hfill\n\t\\begin{minipage}[t]{0.45\\textwidth}\n\t\t\n\t\t\n\t\t\\subsection*{4.}\n\t\t\\textbf{Proposition}: If $ n\\in\\mathbb{N} $, then $ 1\\cdot2+2\\cdot3+3\\cdot4+4\\cdot5+\\dots+n(n+1)=\\frac{n(n+1)(n+2)}{3} $.\n\t\t\\newline\\textit{Proof.}  Observe that if $ n=1 $ the statement $ 1(1+1)=\\frac{1(1+1)(1+2)}{3}\\rightarrow 2=\\frac{1(2)(3)}{3}=2 $ so the statement is true for $ n=1 $. Now let $ k\\geq 1 $, so  $ 1\\cdot2+2\\cdot3+3\\cdot4+4\\cdot5+\\dots+(k+1)((k+1)+1) = 1\\cdot2+2\\cdot3+3\\cdot4+4\\cdot5+\\dots+k(k+1)+(k+1)((k+1)+1) = \\frac{k(k+1)(k+2)}{3} + (k+1)((k+1)+1) = \\frac{k(k+1)(k+2)}{3} + (k+1)(k+2) = \\frac{k(k+1)(k+2) +3(k+1)(k+2)}{3} = \\frac{(k+1)(k+2)(k+3)}{3} = \\frac{(k+1)((k+1)+1)((k+1)+2)}{3} $. It follows by induction that $ 1\\cdot2+2\\cdot3+3\\cdot4+4\\cdot5+\\dots+n(n+1)=\\frac{n(n+1)(n+2)}{3} $ for every natural number $ n $. \n\t\t\n\t\t\n\t\\end{minipage}\n\t\\pagebreak\n\t\n\t%------------------------ End Page 1 ------------------------\n\t\n\t%------------------------ Begin Page 2 ------------------------\n\t\n\t\\begin{minipage}[t]{0.40\\textwidth}\n\t\t\n\t\t\\subsection*{8.}\n\t\t\\textbf{Proposition}: If $ n\\in\\mathbb{N} $, then $ \\frac{1}{2!}+\\frac{2}{3!}+\\frac{3}{4!}+\\dots+\\frac{n}{(n+1)!}=1-\\frac{1}{(n+1)!}$.\n\t\t\\newline\\textit{Proof.} Observe that if $ n=1 $, then $ \\frac{1}{(1+1)!}=1-\\frac{1}{(1+1)!}\\rightarrow \\frac{1}{2}=1-\\frac{1}{2}=\\frac{1}{2} $, so the statement is true for $ n=1 $. Now let $ k\\geq 1 $, so $ \\frac{1}{2!}+\\frac{2}{3!}+\\frac{3}{4!}+\\dots+\\frac{(k+1)}{((k+1)+1)!} = \\frac{1}{2!}+\\frac{2}{3!}+\\frac{3}{4!}+\\dots+\\frac{k}{(k+1)!}+\\frac{(k+1)}{((k+1)+1)!} = 1-\\frac{1}{(k+1)!} + \\frac{(k+1)}{((k+1)+1)!} = 1-\\frac{1}{(k+1)!} + \\frac{(k+1)}{(k+2)!} = 1-(\\frac{1}{(k+1)!} - \\frac{(k+1)}{(k+2)!}) = 1-(\\frac{1}{(k+1)!} - \\frac{(k+1)}{(k+2)(k+1)!}) = 1-\\frac{k+1-(k+1)}{(k+2)(k+1)!} = 1-\\frac{1}{(k+2)(k+1)!} = 1-\\frac{1}{(k+2)!} =  1-\\frac{1}{((k+1)+1)!} $. It follows by induction that $ \\frac{1}{2!}+\\frac{2}{3!}+\\frac{3}{4!}+\\dots+\\frac{n}{(n+1)!}=1-\\frac{1}{(n+1)!}$ for every natural number $ n $.\n\t\t\n\t\t\\subsection*{20.}\n\t\t\\textbf{Proposition}: $ (1+2+3+\\dots+n)^2=1^3+2^3+3^3+\\dots+n^3 $ for every $ n\\in\\mathbb{N} $.\n\t\t\\newline\\textit{Proof.} Observe that if $ n=1 $, then $ 1^2=1^3 $, which is true. Now let $ k\\geq1 $, so then $ (1+2+3+\\dots+(k+1))^2 = (1+2+3+\\dots+k+(k+1))^2. $. If we say $ a=(1+2+3+\\dots+k) $ and $ b=(k+1) $ then $ (a+b)^2 = a^2+b^2+2ab $, then substituting back in for $ a $ and $ b $ we get $ (1+2+3+\\dots+k)^2 + (k+1)^2+2(1+2+3+\\dots+k)(k+1)$. Note that $ (1+2+3+\\dots+k) = \\frac{k(k+1)}{2} $ and $ (1+2+3+\\dots+k)^2 = 1^3+2^3+3^3+\\dots+n^3 $. So $ 1^3+2^3+3^3+\\dots+n^3 + (k+1)^2+2\\frac{k(k+1)}{2}(k+1) = 1^3+2^3+3^3+\\dots+n^3 + (k+1)^2+k(k+1) = 1^3+2^3+3^3+\\dots+n^3 + (k+1)^2(k+1) = 1^3+2^3+3^3+\\dots+n^3 + (k+1)^3 $. It follows by induction that $ (1+2+3+\\dots+n)^2=1^3+2^3+3^3+\\dots+n^3 $ for every $ n\\in\\mathbb{N} $.\n\t\t\n\t\t\n\t\\end{minipage}\n\t% Creates verticle line\n\t\\hfill\\vline\\hfill\n\t\\begin{minipage}[t]{0.45\\textwidth}\n\t\t\n\t\t\n\t\t\\subsection*{30.}\n\t\t\\textbf{Proposition}: $F_n$ is the $n$th Fibonacci number. Show that $ F_n=\\frac{(\\frac{1+\\sqrt{5}}{2})^n-(\\frac{1-\\sqrt{5}}{2})^n}{\\sqrt{5}}  $\n\t\t\\textit{Proof.} Observe that if $ n=1 $, then $ F_1=\\frac{(\\frac{1+\\sqrt{5}}{2})^1-(\\frac{1-\\sqrt{5}}{2})^1}{\\sqrt{5}} = \\frac{\\frac{2\\sqrt{5}}{2}}{\\sqrt{5}} = 1 $. And if $ n=2 $, then $F_2=\\frac{(\\frac{1+\\sqrt{5}}{2})^2-(\\frac{1-\\sqrt{5}}{2})^2}{\\sqrt{5}} = \\frac{(\\frac{3+\\sqrt{5}}{2})-(\\frac{3-\\sqrt{5}}{2})}{\\sqrt{5}} = \\frac{2\\sqrt{5}}{2\\sqrt{5}} = 1 $. Now let $ k\\geq 1 $. Note that $ F_{k+2}=F_k+F_{k+1} $. So then\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k-(\\frac{1-\\sqrt{5}}{2})^k}{\\sqrt{5}}+\\frac{(\\frac{1+\\sqrt{5}}{2})^{k+1}-(\\frac{1-\\sqrt{5}}{2})^{k+1}}{\\sqrt{5}} = $\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k - (\\frac{1-\\sqrt{5}}{2})^k + (\\frac{1+\\sqrt{5}}{2})(\\frac{1+\\sqrt{5}}{2})^k - (\\frac{1-\\sqrt{5}}{2})(\\frac{1-\\sqrt{5}}{2})^k}{\\sqrt{5}} = $\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k + (\\frac{1+\\sqrt{5}}{2})(\\frac{1+\\sqrt{5}}{2})^k -[(\\frac{1-\\sqrt{5}}{2})^k+(\\frac{1-\\sqrt{5}}{2})(\\frac{1-\\sqrt{5}}{2})^k]}{\\sqrt{5}} =$\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k(1+(\\frac{1+\\sqrt{5}}{2}))-[(\\frac{1-\\sqrt{5}}{2})^k(1+(\\frac{1-\\sqrt{5}}{2}))]}{\\sqrt{5}} = $\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k(\\frac{3+\\sqrt{5}}{2}) - (\\frac{1-\\sqrt{5}}{2})^k(\\frac{3-\\sqrt{5}}{2})}{\\sqrt{5}} =$\\\\\n\t\tNote that $ \\frac{3+\\sqrt{5}}{2} = (\\frac{1+\\sqrt{5}}{2})^2 $ \\\\and $ \\frac{3-\\sqrt{5}}{2} = (\\frac{1-\\sqrt{5}}{2})^2 $. Continuing...\\\\\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^k(\\frac{1+\\sqrt{5}}{2})^2 - (\\frac{1-\\sqrt{5}}{2})^k(\\frac{1-\\sqrt{5}}{2})^2}{\\sqrt{5}} =$\\\\\n\t\t$ \\frac{(\\frac{1+\\sqrt{5}}{2})^{k+2}-(\\frac{1-\\sqrt{5}}{2})^{k+2}}{\\sqrt{5}}$.\n\t\tIt follows by induction that $ F_n=\\frac{(\\frac{1+\\sqrt{5}}{2})^n-(\\frac{1-\\sqrt{5}}{2})^n}{\\sqrt{5}}  $ for every $ n\\in\\mathbb{N} $.\n\t\t\n\t\t\n\t\t\\subsection*{32.}\n\t\t\\textbf{Proposition}: Show that the number of $ n $-digit binary numbers that have no consecutive\n\t\t1's is the Fibonacci number $  F_{n+2} $\\\\\n\t\t\\textit{Proof.} Let $ n=1 $, then $ a_1=2\\rightarrow F_{1+2}=F_3=2 $. Assume that the given statement is true for $ n=k $. So $ a_k=F_{k+2} $. Observe that the sequence of $ a_n's $ satisfy $ a_{n+1}=a_n+a_{n-1} $. So $ a_{n+1}=a_n+a_{n-1} = F_{n+2}+F_{(n-1)+2} = F_{n+2}+F_{n+1}= F_3 = F_{(n+1)+2}$ thus the result is true for $ n=k+1 $. Therefore by induction, the number of $ n $-digit binary numbers that have no consecutive\n\t\t1's is the Fibonacci number $  F_{n+2} $, where $ n\\in\\mathbb{N} $.\n\t\t\n\t\t\n\t\t\n\t\t\n\t\\end{minipage}\n\t\\pagebreak\n\t\n\t%------------------------ End Page 4 ------------------------\n\t\n\\end{document}\n\n", "meta": {"hexsha": "1948d010170de0f4667147d86769d242869bbbc8", "size": 7750, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW_Week_8.tex", "max_stars_repo_name": "joseph-ismailyan/Math-100", "max_stars_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW_Week_8.tex", "max_issues_repo_name": "joseph-ismailyan/Math-100", "max_issues_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW_Week_8.tex", "max_forks_repo_name": "joseph-ismailyan/Math-100", "max_forks_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.5079365079, "max_line_length": 812, "alphanum_fraction": 0.5387096774, "num_tokens": 3731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.44852522539811457}}
{"text": "\\chapter{Mna}\nSimple tool for calculating response of a linear circuit using\nModified Nodal Analysis.\n\\section{mna}\\hypertarget{mna}\nClass constructor.\n\\subsection{Syntax}\n\\begin{verbatim}\n    Y = mna\n    Y = mna(n)\n\\end{verbatim}\n\n\\subsection{Description}\n\\verb\"Y = mna\" returns a default mna object with 1 node.\\\\\n\\verb\"Y = mna(n)\", where \\verb\"n\" is a positive scalar, returns a mna object with \\verb\"n\" nodes.\\\\\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\\vspace{3mm} \\hrule\n\\section{stamp}\\hypertarget{stamp}\nInserts the MNA footprint of a circuit element into the\nmna-object.\n\\subsection{Syntax}\n\\begin{verbatim}\n    Y = stamp(Y,type,element,conn)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"Y = stamp(Y,type,element,conn)\" returns a mna-object with\nthe circuit element \\verb\"type\" with name \\verb\"element\" between\nnodes \\verb\"conn\".\n\n\\verb\"type\" can be a reciprocal two port element\n\\verb\"'R','G','L','C'\" or a non reciprocal four port\n\\verb\"'VCCS','GY'\". \\verb\"element\" can be any string describing\nthe element name. For two ports \\verb\"conn\" is a two element\nvector containing the nodes of the circuit element, for four ports\nit is a four element vector.\n\n\\subsection{Example}\nProduces a indefinite MNA description of a standard transistor\n$\\pi$-pad.\n\\begin{verbatim}\n    >> Y = stamp(mna(3),'C','Cpg',[1 3]);\n    Y = stamp(Y,'L','Lg',[1 2]);\n    Y = stamp(Y,'C','Cpg',[2 3]);\n    >> Y\n    ans =\n        '+s.*Cpg+1./(s*Lg)'    '-1./(s*Lg)'           '-s.*Cpg'\n        '-1./(s*Lg)'           '+1./(s*Lg)+s.*Cpg'    '-s.*Cpg'\n        '-s.*Cpg'              '-s.*Cpg'              '+s.*Cpg+s.*Cpg'\n    ans =\n        'Cpg'    'Lg'\n\\end{verbatim}\n\nExample of a voltage controlled current source.\n\\begin{verbatim}\n    >> Y=stamp(mna(4),'VCCS','gm',[1 2 3 4])\n    ans =\n           []     []       []     []\n        '+gm'     []    '-gm'     []\n           []     []       []     []\n        '-gm'     []    '+gm'     []\n    ans =\n        'gm'\n\\end{verbatim}\n\nExample of a gyrator.\n\\begin{verbatim}\n    >> Y=stamp(mna(4),'GY','g',[1 2 3 4]) ans =\n      []    '+g'      []    '-g'\n    '-g'      []    '+g'      []\n      []    '-g'      []    '+g'\n    '+g'      []    '-g'      []\n    ans =\n        'g'\n\\end{verbatim}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{3mm} \\hrule\n\\section{freq}\\hypertarget{freq}\nSets the frequencies for subsequent calculation of a numeric\nMNA-matrix.\n\\subsection{Syntax}\n\\begin{verbatim}\n    Y = freq(Y,frequencies)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"Y = freq(Y,frequencies)\" returns the mna object with\ncalculation frequencies set to \\verb\"frequencies\".\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{3mm} \\hrule\n\\section{params}\\hypertarget{params}\nReturns a cell vector containing the circuit elements in the\ncircuit.\n\\subsection{Syntax}\n\\begin{verbatim}\n    x = params(Y)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"x = params(Y)\" returns a cell vector with the circuit\nelements.\n\n\\subsection{Examples}\n\\begin{verbatim}\n    >> Y = read_netlist(mna,'test/test.nl')\n    ans =\n        '+s.*Cpg+1./(s*Lg)'    '-1./(s*Lg)'                 []\n        '-1./(s*Lg)'           '+1./(s*Lg)+s.*Cpg'          []\n                         []                     []    '+1./Rs'\n    ans =\n        'Cpg'    'Lg'    'Rs'\n    >> params(Y)\n    ans =\n        'Cpg'    'Lg'    'Rs'\n    >>\n\\end{verbatim}\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{3mm} \\hrule\n\\section{calc}\\hypertarget{calc}\nCalculates a numeric MNA-matrix.\n\\subsection{Syntax}\n\\begin{verbatim}\n    X = calc(Y,parameters)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"X = calc(Y,parameters)\" returns a \\verb\"xparam\"-object\ncontaining the MNA-matrix calculated at the frequencies set by\n\\verb\"freq\". \\verb\"parameters\" is a numeric vector containing the\nvalues of the circuit elements. This vector must have the same\nordering as the elements were inserted into the mna-object.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\\vspace{3mm} \\hrule\n\\section{gnd}\\hypertarget{gnd}\nConnects specified nodes to ground and thereby reduces the\ndimension of the MNA-matrix.\n\\subsection{Syntax}\n\\begin{verbatim}\n    Y = gnd(Y,conn)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"Y = gnd(Y,conn)\", where \\verb\"conn\" is a vector containing\nthe nodes to be connected to ground.\n\n\\subsection{Examples}\nExample of a gyrator with nodes 3 and 4 grounded.\n\\begin{verbatim}\n    >> Y=stamp(mna(4),'GY','g',[1 2 3 4])\n    ans =\n          []    '+g'      []    '-g'\n        '-g'      []    '+g'      []\n          []    '-g'      []    '+g'\n        '+g'      []    '-g'      []\n    ans =\n        'g'\n    >> Y=gnd(Y,[3 4])\n    ans =\n          []    '+g'\n        '-g'      []\n    ans =\n        'g'\n\\end{verbatim}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\\vspace{3mm} \\hrule\n\\section{read\\_netlist}\\hypertarget{readnetlist}\nReads a netlist and builds a corresponding mna-object.\n\\subsection{Syntax}\n\\begin{verbatim}\n    Y = read_netlist(Y,file)\n\\end{verbatim}\n\\subsection{Description}\n\\verb\"Y = read_netlist(Y,file)\", where \\verb\"file\" is a string\ncontaining the path to the netlist file.\n\nThe netlist should be a text-file of the following form:\n\\begin{verbatim}\n    C Cpg 1 3\n    L Lg  1 2\n    C Cpg 2 5\n    R Rs  3 4\n    GND 3 5\n\\end{verbatim}\nThe circuit elements could be given in any order.\n\n\\subsection{Examples}\nThe file \\verb\"test.nl\" contains the netlist above.\n\\begin{verbatim}\n    >> Y = read_netlist(mna,'test/test.nl')\n    ans =\n        '+s.*Cpg+1./(s*Lg)'    '-1./(s*Lg)'                 []\n        '-1./(s*Lg)'           '+1./(s*Lg)+s.*Cpg'          []\n                     []                     []    '+1./Rs'\n    ans =\n        'Cpg'    'Lg'    'Rs'\n\\end{verbatim}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\\vspace{3mm} \\hrule\n\\section{display}\\hypertarget{display}\nDisplays the MNA-matrix and a list of circuit variables of a\nmna-object.\n\\subsection{Syntax}\n\\begin{verbatim}\n    display(Y)\n\\end{verbatim}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "65d3f56908d40f9acb9c29af45514a86592d405c", "size": 5819, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/mna.tex", "max_stars_repo_name": "extrakteon/muwave", "max_stars_repo_head_hexsha": "a91c034b0383dda5458eb4935926b8b65a211311", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-04-30T17:44:29.000Z", "max_stars_repo_stars_event_max_datetime": "2017-04-30T17:44:29.000Z", "max_issues_repo_path": "doc/mna.tex", "max_issues_repo_name": "extrakteon/muwave", "max_issues_repo_head_hexsha": "a91c034b0383dda5458eb4935926b8b65a211311", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/mna.tex", "max_forks_repo_name": "extrakteon/muwave", "max_forks_repo_head_hexsha": "a91c034b0383dda5458eb4935926b8b65a211311", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4481132075, "max_line_length": 99, "alphanum_fraction": 0.5647018388, "num_tokens": 1749, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.44852521876837226}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath, amssymb, amsthm, enumerate, framed, graphicx}\n\\usepackage[usenames,dvipsnames]{color}\n\\usepackage{bm}\n\\usepackage[colorlinks=true,urlcolor=blue]{hyperref}\n\\usepackage{geometry}\n\\geometry{margin=1in}\n\\usepackage{float}\n\\setlength{\\marginparwidth}{2.15cm}\n\\usepackage{booktabs}\n\\usepackage{enumitem}\n\\usepackage{epsfig}\n\\usepackage{setspace}\n\\usepackage{parskip}\n\\usepackage{hyperref}\n\\usepackage[normalem]{ulem}\n\\usepackage{tikz}\n\\usepackage{pgfplots}\n\\usepackage[font=scriptsize]{subcaption}\n\\usepackage{float}\n\\usepackage[]{algorithm2e}\n\\usepackage{environ}\n\\usepackage{bbm}\n\\usepackage[normalem]{ulem}\n\\usepackage{color}\n\\usepackage{tcolorbox}\n\n%% To HIDE SOLUTIONS (to post at the website for students), set this value to 0: \\def\\issoln{0}\n\\def\\issoln{1}\n% Some commands to allow solutions to be embedded in the assignment file.\n\\ifcsname issoln\\endcsname \\else \\def\\issoln{1} \\fi\n% Default to an empty solutions environ.\n\\NewEnviron{soln}{}{}\n\\if\\issoln 1\n% Otherwise, include solutions as below.\n\\RenewEnviron{soln}{\n    \\leavevmode\\color{red}\\ignorespaces\n    \\textbf{Solution} \\BODY\n}{}\n\\fi\n\n%\\newcommand{\\norm}[1]{\\lVert #1 \\rVert}\n%\\newcommand{\\st}{\\mathrm{s.t.}}\n\n\\makeatletter\n\\newcommand{\\removelatexerror}{\\let\\@latex@error\\@gobble}\n\\makeatother\n\n\n\\begin{document}\n\\section*{Part 1: Multiple Choice and Short Answer Questions [38 points]} \n\\begin{enumerate}\n    \\item \\textbf{[1 pt]} \\textbf{True or False}: One reason that the MAP might be preferred over the MLE is that MLE can have a tendancy to overfit small amounts of data.\n    \n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[2 pt]} Let $X$ be the result of a coin toss, where $X=1$ if it comes up heads and $X=0$ otherwise.  The coin has an unknown probability $p_1$ of coming up heads.\n    \\\\ Suppose that we observe the following sequence of of coin toss outcomes:\n    $$\n    (1,0,1,1,0,0,1,0,1,0,1)\n    $$\n    What is the maximum likelihood estimate for $p_1$?\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[2 pt]} Now suppose that someone else observes the coin flip (still denoted by $X$) and tells you $Y$, the outcome of the flip, but this person only reports the correct result with probability $p_2$.  Suppose we have the following dataset:\n    $X$-the sequence of actual coin toss outcomes- is: \\\\\n    $$\n    (1,0,1,1,0,0,1,0,1,0,1)\n    $$\n    $Y$- the sequence of coin toss outcomes we were told by the other person-is:\\\\\n    $$\n    (1,0,1,0,1,0,1,0,1,0,1)\n    $$\n    What is the maximum likelihood estimate for $p_2$?\n    \n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[2 pt]} Another person is observing the coin toss too, but the probability for this person to report the correct result depends on the actual outcome of the coin toss. Let  $p_{a,b}$ be the probability for that person to report outcome $b$ given that the actual outcome of the coin toss is $a$ , where  $a,b\\in\\{0,1\\}$. Consider the same  $X$  and  $Y$  values as given in previous question, what is the maximum likelihood estimate for  $p_{0,0}$?\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[4 pt]} Let $\\theta$ be a random variable with the probability density function:\n    \\[\n    f(\\theta) = \n    \\begin{cases}\n    2\\theta, &\\text{ if } 0 \\leq \\theta \\leq 1 \\\\\n    0, &\\text{ otherwise}.\n    \\end{cases}\n    \\]\n    Suppose that another random variable $Y$, conditioning on $\\theta$, follows an exponential distribution with $\\lambda=3\\theta$. Note that the exponential distribution with parameter $\\lambda$ has a probability density function\n    \\[\n    f(y) = \n    \\begin{cases}\n    \\lambda e^{-\\lambda y}, &\\text{ if } y \\geq 0, \\\\\n    0, &\\text{otherwise}.\n    \\end{cases}\n    \\]\n    Find the MAP estimate of $\\theta$ given $Y=4$ is observed.\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[1 pt]} \\textbf{True or False}: If we choose an incorrect set of parameters for the beta prior of Bernoulli distribution, then the MAP estimate will not converge (as the number of training examples grows toward infinity) to the true value.  (here, when we say an 'incorrect' set of parameters for the beta prior, we mean a set of parameters for which the most probable value is different from the true value of the parameter we are trying to estimate.)\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\item \\textbf{[1 pt]} \\textbf{True or False}: In case we choose Beta parameters that correspond to a uniform prior, the value of the MAP estimate will be identical to that of the MLE.\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\item \\textbf{[4 pt]} The next two questions refer to the following scenario: suppose that $0.5\\%$ people have cancer. Someone decided to take a medical test for cancer. The outcome of the test can either be positive (cancer) or negative (no cancer). The test is not perfect - among people who have cancer, the test comes back positive $96\\%$ of the time. Among people who don't have cancer, the test comes back positive $2\\%$ of the time. For the following questions, you should assume that the test results are independent of each other, given the true state (\\textit{cancer} or \\textit{no cancer}).\n    \n    What is the probability of a test subject having cancer, given that the subject's test result is positive? \n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[4 pt]} In the same scenario as the previous question, a test subject's first test returned positive, and the subject decided to do a second independent test. The second test returned negative. What is the probability that this subject has cancer?\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\newpage\n    \\item \\textbf{[1 pt]} \\textbf{True or False}: Gaussian Naive Bayes can be used to perfectly classify the training data shown below.\n    \\begin{center}\n    \\vspace{2em}\n        \\textbf{Please refer to the pdf for image of this question}.\n    \\vspace{2em}\n    \\end{center}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[1 pt]} \\textbf{Note}: This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    How many parameters will the model need under the Na{\\\"i}ve Bayes assumption, assuming that $P(X_w = x_w \\vert Y = y)$ is a Bernoulli distribution for each $w$ and $P(Y=y)$ is also a Bernoulli distribution? All answers are shown as a function of the vocabulary size $V$.\n    \\begin{itemize}\n        \\item[A.] $V$\n        \\item[B.] $2V$\n        \\item[C.] $V+1$\n        \\item[D.] $2V+1$\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[1 pt]} \\textbf{Note}: This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    How many parameters (also as a function of $V$) will the model need if we \\textbf{do not} make the NB assumption, assuming $P(Y=y)$ is Bernoulli again and all of the features in $X$ have binary labels?\n    \\begin{itemize}\n        \\item[A.] $2V$\n        \\item[B.] $2^V$\n        \\item[C.] $2(2^V-1)+1$\n        \\item[D.] $2^{2V+1}$\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\newpage\n    \n    \\item \\textbf{[1 pt]} \\textbf{Note}: This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    Does the Na{\\\"i}ve Bayes assumption hold true for our dataset? Select a valid explanation for your answer.\n    \\begin{itemize}\n        \\item[A.] True. The appearances of each pair of words are not related regardless of review class.\n        \\item[B.] False. The appearances of some common stopwords (say, pronoun \\textit{he} and \\textit{she}) are dependent in both classes of movie reviews.\n        \\item[C.] True. The number of occurrences for words are not conditionally independent, but the appearances certainly do.\n        \\item[D.] False. For example, \\textit{Darth} and \\textit{Vader} are unlikely to be independent in both positive and negative reviews.\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n\n    \\item \\textbf{[1 pt]} \\textbf{Note: only one of the answers is correct.}  This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    Which of the following statement(s) is/are correct with respect to using stopwords as features?\n    \\begin{itemize}\n        \\item[A.] We can keep stopwords as features. They have no effect on the accuracy of classifier.\n        \\item[B.] Stopwords add value to the dataset which is useful for correctly classifying the document.\n        \\item[C.] Removing stopwords helps in reducing noise/false positives.\n        \\item[D.] All of the above.\n        \\item[E.] None of the above.\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[1 pt]} \\textbf{Note: only one of the answers is correct.}  this is a single choice question. This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    We will experiment with two different parameter settings for our prior over $\\theta_{yw}$: \n    \\begin{enumerate}\n        \\item $\\beta_0=5$ and $\\beta_1=7$, and \n        \\item $\\beta_0=7$ and $\\beta_1=5$.\n    \\end{enumerate}\n    Train your classifier with 2 sets of data (\\texttt{XTrainSmall},\\texttt{yTrainSmall}) and (\\texttt{XTrain},\\texttt{yTrain}) with the first parameter setting. Then, use the learned classifiers to classify whether the reviews \\texttt{XTest} are positive or negative. How do the classification errors compare?\n    \\begin{itemize}\n        \\item[A.] Error is smaller when using \\texttt{XTrain},\\texttt{yTrain}.\n        \\item[B.] Error is smaller when using \\texttt{XTrainSmall},\\texttt{yTrainSmall}.\n        \\item[C.] Errors are equal.\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\newpage\n    \\item \\textbf{[4 pt]} \\textbf{Note}: This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    Train your classifier on the data contained in\n    \\texttt{XTrain} and \\texttt{yTrain} with the second parameter setting in the previous problem. Then, use the learned classifier to classify whether the reviews \\texttt{XTest} are positive or negative. After comparing classification errors produced by classifiers trained by \\texttt{XTrain} and \\texttt{yTrain} with 2 parameter settings, which parameter setting was a better choice for the prior on $\\theta_{yw}$?\n    \\begin{itemize}\n        \\item[A.] $\\beta_0=5$ and $\\beta_1=7$\n        \\item[B.] $\\beta_0=7$ and $\\beta_1=5$\n    \\end{itemize}\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[4 pt]} \\textbf{Note}: This question is based on material discussed in Part 2 - Implementing Na{\\\"i}ve Bayes of the homework assignment. Please complete Part 2 of this assignment before attempting these questions.\n    \n    Consider again the Na{\\\"i}ve Bayes classifiers trained with \\texttt{XTrain} and \\texttt{yTrain} for both parameter settings. Which of the settings of $\\beta_0$ and $\\beta_1$ make more sense if we strongly believe the true value of $\\theta_{yw}$ lies in the interval $[0.1, 0.3]$?\n    \\begin{itemize}\n        \\item[A.] $\\beta_0=5$ and $\\beta_1=7$\n        \\item[B.] $\\beta_0=7$ and $\\beta_1=5$\n    \\end{itemize}\n    \n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: Did you receive any help whatsoever from anyone in solving this assignment? Please answer \\textit{yes} or \\textit{no}.\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: If you answered \\textit{yes} on the previous question, please give full details below (e.g., \\textit{Christopher Nolan} explained to me what is asked in Question 3.4).\n    \\begin{tcolorbox}[height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: Did you give any help whatsoever to anyone in solving this assignment? Please answer \\textit{yes} or \\textit{no}.\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \\newpage\n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: If you answered \\textit{yes} on the previous question, please give full details below (e.g., I pointed \\textit{Michael Bay} to section 2.3 since he didn't know how to proceed with Question 2).\n    \\begin{tcolorbox}[height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n\n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: Did you find or come across code that implements any part of this assignment? Please answer \\textit{yes} or \\textit{no}.\n    \\begin{tcolorbox}[width=\\linewidth/3,height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \\item \\textbf{[0.5 pt]} \\textbf{Collaboration Policy Question}: If you answered \\textit{yes} on the previous question, please give full details below (book \\& page, URL \\& location, movies \\& scene, etc).\n    \\begin{tcolorbox}[height=1.5cm]\n    %Your solution here\n    \\end{tcolorbox}\n    \n    \n    \n    \n    \n    \n    \n    \n    \n\\end{enumerate}\n\n\n\n\\end{document}", "meta": {"hexsha": "de689e1a9b4bbfe635e44fc02fc179f2476ebd26", "size": 14764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "10601-hws/HW 3/F17_10601_HW3_Part1.tex", "max_stars_repo_name": "dfreilich/machine-learning-workspace", "max_stars_repo_head_hexsha": "a1b6e5bd84a4f5708461f3827d64e2bf5a32dffa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "10601-hws/HW 3/F17_10601_HW3_Part1.tex", "max_issues_repo_name": "dfreilich/machine-learning-workspace", "max_issues_repo_head_hexsha": "a1b6e5bd84a4f5708461f3827d64e2bf5a32dffa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "10601-hws/HW 3/F17_10601_HW3_Part1.tex", "max_forks_repo_name": "dfreilich/machine-learning-workspace", "max_forks_repo_head_hexsha": "a1b6e5bd84a4f5708461f3827d64e2bf5a32dffa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.1079136691, "max_line_length": 605, "alphanum_fraction": 0.7020455161, "num_tokens": 4238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.4483593092388927}}
{"text": "\\documentclass[10pt,a4paper]{book}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\author{Daniel Frederico Lins Leite}\n\\title{Asymptotic Statistics}\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\chapter {Introduction}\n\nThe idea of this crash course on asymptotic Statistics is to have all proofs and ideas related with the one of the three most important aspects of statistics, being estimation. The other two being confidence interval and hypothesis testing, off course.\\\\\n\nThe idea is to present as gentle as possible the needed concepts to follow a more thorough course. Here one will find the concepts of \"asymptotic\", \"estimators\", Markov and Chebyshevs inequalities, convergnce in the sense for Statistics, characteristic functions, the weak law of large numbers and the Central Limit Theorem.\n\t\n\\chapter{Asymptotic Behaviour of Estimators}\n\\section{Introduction}\n\nAs \"Asymptotic Statistics\" we understand the study of Probabilities and Statistics as one of its parameters go to infinity. We will study for example:\n\n\\begin{align}\n\t\\lim_{n->\\infty}{P(X_n \\in A)}\n\\end{align}\n\nor \n\n\\begin{align}\n\t\\lim_{n->\\infty}{P((X_n - X) \\in A)}\n\\end{align}\n\nHere $P(x \\in A) = \\int_{A}{f(x)dx}$. The lower-case $f$ has a especial meaning because that is how we label the PDF of a distribution. We use upper-case $F$ to mean de CDF. We also know that to be a valid \"random variable\":\n\n\\begin{align}\n\t\\int_{-\\infty}^{\\infty}{f(x)dx} = 1 && f(x) \\ge 0\n\\end{align}\n\nWhere $X_n$ means off course a \"random variable\", pure in the sense that is obeys a known distribution or a \"transformed random variable\". We will be interested to know if a \"random variable\" converge to a constant, to another \"random variable\" of if it diverge. Throughout this book we will see that we can conclude different things if any of these cases are proved as true.\n\nOne of the most interesting, or one the most useful, \"random variables\" is the \"estimator\". We call \"estimator\" any \"statistic\" that does not depend on any of the \"population parameters\" an possible estimator. If on top of that we define that this \"statistic\" will be used as an \"estimation\" of the \"population parameter\", we have a \"estimator\".\n\nA famous statistic is the \"sample mean\" that we will define as:\n\n\\begin{align*}\n\tX_i \\sim P_{\\theta}\\\\\n\tS_n = \\sum_{\\forall i}{X_i}\\\\\n\t\\bar{X_{n}} = \\frac{S_n}{n}\\\\\n\\end{align*}\n\nWe understand the expressions above as:\n\\begin{itemize}\n\t\\item {$X_i$ is a \"random variable\" that follows a distribution described with a parameter $\\theta$, that can be a number or various numbers;}\n\t\\item {The set of all $X_i$ are i.i.d.}\n\t\\item {$S_n$ is another \"random variable\". Being the sum of $n$ \"random variables\" allows us to know the distribution of $S_n$ in some cases}\n\t\\item {$\\bar{X_{n}}$ is another \"random variable\" that applies the \"transformation\" $1/x$ to the \"random variable\" $S_n$}\n\\end{itemize}\n\nBeing random variables, $X_i$, $S_n$, $\\bar{X_{n}}$, allow them to have \"expected values\", \"variations\" and any other statistics themselves. This is a powerfull source of confusion. So we can have:\n\n\\begin{align*}\n\tE[X_i] = a \\text{ or } f_a(i)\\\\\t\n\tE[S_n] = b \\text{ or } f_b(n)\\\\\n\tE[\\bar{X_{n}}] = c \\text{ or } f_c(n)\\\\\n\\end{align*}\n\nIn these cases, $a$, $b$, $c$ are not \"random variables\". They are constants, or functions that depend on the \"random variables\" \"parameter\". The same can be said about their \"variance\" and other statistics.\n\nRemember that \"Expected Value\" is:\n\n\\begin{align}\n\tE[X] = \\int_{-\\infty}^{\\infty}{x*f(x)dx}\n\\end{align}\n\nActually this is just the \"First Moment\" of $X$. We can the n-th \"moment\" as:\n\n\\begin{align}\n\t\\int_{-\\infty}^{\\infty}{x^n*f(x)dx}\n\\end{align}\n\nor\n\n\\begin{align*}\n\tE[X^1] = \\int_{-\\infty}^{\\infty}{x^1*f(x)dx}\\\\\n\tE[X^2] = \\int_{-\\infty}^{\\infty}{x^2*f(x)dx}\\\\\n\t...\\\\\n\tE[X^n] = \\int_{-\\infty}^{\\infty}{x^n*f(x)dx}\\\\\n\\end{align*}\n\nAnd this allows us to calculate the variance as, the \"second moment\" minus the square of the \"first moment\":\n\n\\begin{align}\n\t\\text{VAR}[X] = E[X^2] - E[X]^2\\\\\n\\end{align}\n\nor \n\n\\begin{align}\n\\text{VAR}[X] = E[(X-E[X])^2]\n\\end{align}\n\nAnd we also have the \"standard deviation\".\n\n\\begin{align}\n\t\\text{SD}[X] = \\sqrt{\\text{VAR}[X]}\n\\end{align}\n\n\\section{Markov's Inequality Intuition}\n\t\nWhat can you say about a \"Probbility distribution\" if you only have its mean? Probably not much. But not much is more than nothing. If we imagine a standard dice with six faces, but not necessarily fair, each face having the same probability. The question is, knoning just the mean, can we affirm with a 100\\% certainity that the dice is not fair?\n\nFor example, if someone tell us that the $E[X_i]$, $X_i$ being a roll of the dice is $6$. We know that the only way of this happening is when $P(X = 6) = 1$ and $P(X < 6) = 0$ because of the \"Expected Value\" definition.\n\n\\begin{align*}\n\tE[X] &= \\sum_{i=1}^{6}{i*P(X=i)} = 6\\\\\n\t&= 6*P(X=6) = 6\\\\\n\t& P(X=6) = \\frac{6}{6}\\\\\n\t& P(X=6) = 1\\\\\n\\end{align*}\n\nSo it seems that knowing only the $E[X]$ allows us to take some conclusions of the distribution. But this is a extreme case. Can we take conclusions if for example the $E[X]$ is the same as the \"expected value\" when the dice is fair? Let us see.\n\nWe know that the $E[X]$ is:\n\n\\begin{align*}\n\tE[X] &= \\sum_{i=1}^{6}{i*P(X=i)}\\\\\n\\end{align*}\n\nAnd we know that $i \\in {1,2,3,4,5,6}$ or $i > 0$. We know that $i$ is positive. We also know that $P(X = i) \\in [0,1]$. It is also positive. The multiplication of two positive values is also positive. And the sum of two positive values is also positive.\n\n\\begin{align*}\n\ti &> 0\\\\\n\tP(X = i) &> 0\\\\\n\ta * b &> 0 \\text{, if } a > 0 \\text{ and } b > 0\\\\\n\ta + b &> 0 \\text{, if } a > 0 \\text{ and } b > 0\t\n\\end{align*}\n\nWhich give us that \n\n\\begin{align*}\n\tE[X] &= \\sum_{i=1}^{6}{i*P(X=i)}\\\\\n\t&= \\sum_{i=1}^{5}{i*P(X=i)} + 6*P(X=6)\n\\end{align*}\n\nWe know that this summuation is going to be greater than zero. Whick make the $E[X]$ greater than or equal $6*P(X=6)$. In the extreme case above, it was equal because the summation was zero. But the summation can be greater than zero (never lower).\n\n\\begin{align*}\n\tE[X] &= \\sum_{i=1}^{6}{i*P(X=i)}\\\\\n\tE[X] &= \\sum_{i=1}^{5}{i*P(X=i)} + 6*P(X=6)\\\\\n\tE[X] &\\ge 6*P(X=6)\\\\\n\t\\frac{E[X]}{6} &\\ge P(X=6)\\\\\n\tP(X=6) &\\le \\frac{E[X]}{6}\n\\end{align*}\n\nWhich is quite surprising if you think. But looking from another perspective, it is quite obvious that there is a relationship with the $P(X=6)$ and the \"expected value\".\n\t\n\\section{Markov's Inequality}\n\nThis relationship was discovered by two mathematicians:\\\\\t\nAndrey Markov\\\\\n\\includegraphics[width=2cm]{AAMarkov}\\\\\n\nand Pafnuty Chebyshev\\\\\n\\includegraphics[width=2cm]{Chebyshev}\\\\\n\nAnd it is generalized as:\n\\begin{itemize}\n\t\\item {$X$ is a nonnegative random variable;}\n\t\\item {$a > 0$}\n\\end{itemize}\t\n\nWe now that:\n\n\\begin{align*}\n\tE[X] &= \\int_{-\\infty}^{\\infty}{x*f(x)dx}\\\\\n\t&= \\int_{0}^{\\infty}{x*f(x)dx} && \\text{because of } X > 0\\\\\n\t&= \\int_{0}^{a}{x*f(x)dx} + \\int_{a}^{\\infty}{x*f(x)dx} && \\text{because of } a > 0\\\\\t\n\\end{align*}\n\nWe know that $\\int_{0}^{a}{x*f(x)dx} > 0$, so\n\n\\begin{align*}\n\tE[X] &= \\int_{0}^{a}{x*f(x)dx} + \\int_{a}^{\\infty}{x*f(x)dx}\\\\\n\tE[X] &= b + \\int_{a}^{\\infty}{x*f(x)dx} && b > 0\\\\\n\tE[X] - b &= \\int_{a}^{\\infty}{x*f(x)dx}\\\\\n\tE[X] &\\ge \\int_{a}^{\\infty}{x*f(x)dx} && b > 0\\\\\n\\end{align*}\n\nBefore the next step, we must realize that:\n\n\\begin{align*}\n\t\\int_{a}^{\\infty}{x*f(x)dx}&\\\\\n\t&=\\int_{a}^{\\infty}{(a+(x-a))*f(x)dx}\\\\\n\t&=\\int_{a}^{\\infty}{a*f(x)dx}+\\int_{a}^{\\infty}{(x-a)*f(x)dx}\\\\\n\\end{align*}\n\nWe must realize the in the second integration, $x \\ge a$ and $f(x) > 0$ which makes the second integration greater than or equal to zero. This allow us to:\n\n\\begin{align*}\n\t\\int_{a}^{\\infty}{x*f(x)dx} &=\\int_{a}^{\\infty}{a*f(x)dx}+\\int_{a}^{\\infty}{(x-a)*f(x)dx}\\\\\n\t\\int_{a}^{\\infty}{x*f(x)dx}\t&=\\int_{a}^{\\infty}{a*f(x)dx}+c\\\\\n\t\\int_{a}^{\\infty}{x*f(x)dx}\t- c &=\\int_{a}^{\\infty}{a*f(x)dx}\\\\\n\t\\int_{a}^{\\infty}{x*f(x)dx}\t&\\ge \\int_{a}^{\\infty}{a*f(x)dx}\\\\\t\n\\end{align*}\n\nWe can use this fact with the fact that if $a>b$ and $b>c$ then $a>c$, and finish our proof\n\n\\begin{align*}\n\tE[X] &\\ge \\int_{a}^{\\infty}{x*f(x)dx} && b > 0\\\\\n\tE[X] &\\ge \\int_{a}^{\\infty}{a*f(x)dx} && \\text{see above}\\\\\n\tE[X] &\\ge a*\\int_{a}^{\\infty}{f(x)dx}\\\\\n\tE[X] &\\ge a*P(X \\ge a)\\\\\n\t\\frac{E[X]}{a} &\\ge P(X \\ge a)\\\\\n\\end{align*}\n\\begin{align}\n\tP(X \\ge a) &\\le \\frac{E[X]}{a}\t\n\\end{align}\n\nWhich is the obivious generalization we did in the intuition section. But remember that we are studying \"Asymptotic Statistics\", this is useful for us, because in some cases, the right side will depend on $n$, and in the limit the right side will converge or diverge. This will give even more information about the \"random variable\". All of this with just its \"expected value\".\n\t\t\n\\section{Chebyshev's Inequality}\n\nOne of the interesting aspects of the \"Markov Inequality\" is that it only contains two assumptions and both are very generic. It only depends on X being non-negative and a being nonnegative. We know that a nonnegative function, when sifted on the X-Axis is still nonnegative. So $X-a$ is still non-negative and the \"Markov Inequality\" still apllies.\n\n\\begin{align*}\nP((X-b) \\ge a) &\\le \\frac{E[X-b]}{a}\t\n\\end{align*}\n\nAnother \"transformation\" that keeps the non-negativiness of the function is squaring its value.\n\n\\begin{align*}\nP((X-b)^2 \\ge a^2) &\\le \\frac{E[(X-b)^2]}{a^2}\t\n\\end{align*}\n\nBut we do not have any restriction on $b$ here, and we can easily choose the \"expected value\" of $X$.\n\n\\begin{align*}\nP((X-E[X])^2 \\ge a^2) &\\le \\frac{E[(X-E[X])^2]}{a^2}\n\\end{align*}\n\nWhich gives us the $\\text{VAR}[X]$. Although this inequality is often writen in a different form.\n\n\\begin{align*}\nP((X-E[X])^2 \\ge a^2) &\\le \\frac{\\text{VAR}[X]}{a^2}\\\\\t\n\\end{align*}\n\nBut this is still not the most \"famous\" way this formula is written, and the reason is going to be appear in future chapters. To derive the most famous form we are going to apply some transformations only to the left side, because they will not change the boundness of the inequality.\n\n\\begin{align*}\nP(\\sqrt{(X-E[X])^2}\\ge\\sqrt{a}) &\\le \\frac{\\text{VAR}[X]}{a^2}\\\\\nP(|X-E[X]| \\ge a) &\\le \\frac{\\text{VAR}[X]}{a^2} && \\text{ no modulus on a because } a>0\n\\end{align*}\n\n\\begin{align}\n\tP(|X-E[X]| \\ge a) &\\le \\frac{\\text{VAR}[X]}{a^2}\n\\end{align}\n\nWhich is quite fascinating, because it gives you a know bound when you know the distribution \"expected value\" and \"variance\". This formula will demonstrate itself very powerfull and useful in the study of sampling and convergence.\n\nWe can also interpret that it is \"harder\", less probable, of being $n$ \"standard deviations\" from the \"expected value\". What is very intuitive, if you stop to think about it. What you can not do, is forget the \"standard deviation\" and say that it is \"harder\" to be far from the \"expected value\". This is not true. Without the \"standard deviation\", or \"variance\" this phrase, does not make any send. Stop to think of a distribution with \"infinite\" \"variance\". It is very \"easy\" to be \"infinitilly\" far from the \"expected value\".\n\n\\section{Markov's and Chebyshev's Inequalities}\n\nIf you search you will probably find another formula for both inequalities. They are all equivalent, off course.\n\n\\begin{align*}\n\tP(X \\ge a) \\le \\frac{E[X]}{a}\\\\\t\n\tP(X \\ge a*E[X]) \\le \\frac{E[X]}{a*E[X]} && E[X] > 0\n\\end{align*}\n\\begin{align}\n\tP(X \\ge a*E[X]) \\le \\frac{1}{a}\n\\end{align}\n\n\\begin{align*}\nP((X-E[X])^2 \\ge a^2) &\\le \\frac{E[(X-E[X])^2]}{a^2}\\\\\nP((X-E[X])^2 \\ge a^2*\\text{VAR}[X]) &\\le \\frac{E[(X-E[X])^2]}{a^2*\\text{VAR}[X]}\\\\\nP((X-E[X])^2 \\ge a^2*\\text{VAR}[X]) &\\le \\frac{\\text{VAR}[X]}{a^2*\\text{VAR}[X]}\\\\\nP((X-E[X])^2 \\ge a^2*\\text{VAR}[X]) &\\le \\frac{1}{a^2}\\\\\nP(\\sqrt{(X-E[X])^2}\\ge\\sqrt{a^2*\\text{VAR}[X]}) &\\le \\frac{1}{a^2}\\\\\n\\end{align*}\n\\begin{align}\nP(|(X-E[X])| \\ge a*\\text{SD}[X]) &\\le \\frac{1}{a^2}\n\\end{align}\n\n\\section{68-95-99.7 rule}\n\n\\section{Summary}\n\n\\subsection{Markov's Inequality}\n\n\\begin{align}\nP(X \\ge a) &\\le \\frac{E[X]}{a}\n\\end{align}\n\nor \n\n\\begin{align}\nP(X \\ge aE[X]) &\\le \\frac{1}{a}\n\\end{align}\n\n\\subsection{Chebyshev's Inequality}\n\n\\begin{align}\nP(|X - E[X] \\ge a) &\\le \\frac{\\text{VAR}[X]}{a^2}\n\\end{align}\n\nor\n\n\\begin{align}\nP(|X - E[X] \\ge a*\\text{SD}[X]) &\\le \\frac{1}{a^2}\n\\end{align}\n\n\t\\chapter{Convergence}\n\t\\section{Convergence in probability of a random variable}\n\t\\section{Convergence in probability to a random variable}\n\t\\section{Convergence in probability of a random variable to a constant}\n\t\\section{Convergence in distribution of a random variable}\n\t\\section{Slutsky's Theorem}\n\t\n\tEugen Slutsky\\\\\n\t\\includegraphics[width=2cm]{EugenSlutsky}\\\\\n\t\n\tand Harald Cramér\\\\\n\t\\includegraphics[width=2cm]{HaraldCramer}\\\\\n\t\n\tIf:\n\t\\begin{align}\n\tX \\sim P\\\\\n\tc \\in \\rm I\\!R\\\\\n\tX_n \\xrightarrow[]{d} X\\\\\n\tY_n \\xrightarrow[]{d} c\\\\\n\t\\end{align}\n\tthen:\n\t\\begin{align}\n\tX_n + Y_n \\xrightarrow[]{d} X + c\\\\\n\tX_n * Y_n \\xrightarrow[]{d} X * c\\\\\n\t\\end{align}\n\t\n\t\\chapter{Characteristic Functions}\n\t\\section{Introduction}\n\n\t\\chapter{Weak Law of Large Numbers}\n\t\\section{Introduction}\n\t\\section{Proof of the weak law of large numbers}\n\t\\section{Proof using characteristic functions}\n\t\n\t\\chapter{Central Limit Theorems}\n\t\\section{Introduction}\n\t\\section{Proof}\n\t\\section{The Characteristic Function of a Normal Random Variable}\n\t\n\t\\chapter{Applications}\n\t\\section{Two-sided, Two-sample Tests}\n\t\n\tIn the scenario:\n\t\\begin{align}\n\t\tX_1,...,X_n \\sim P_1\\\\\n\t\tE[X_i] = \\mu_1\\\\\n\t\tVAR[X_i] = \\sigma^2_1\\\\\n\t\t\\\\\n\t\tY_1,...,Y_n \\sim P_2\\\\\n\t\tE[Y_i] = \\mu_2\\\\\n\t\tVAR[Y_i] = \\sigma^2_2\\\\\n\t\\end{align}\t\n\tthe test statistic $T_n$.\n\t\\begin{align}\n\t\t\\sqrt{n}\\frac{(\\overline{X}_n - \\overline{Y}_n)}{\\sqrt{\\sigma^2_1+\\sigma^2_2}} \\sim N_{\\mu,\\sigma^2}(0,1)\n\t\\end{align}\n\tIf both variances $\\sigma^2_1$ and $\\sigma^2_2$ are unknown we can use the \"Plug-In\" method using \"Slutsky Theorem here\".\\\\\n\tGiven that $T_n$ converges to $N(0,1)$. We can use the fact that:\n\t\\begin{align}\n\t\t\\frac{\\sqrt{\\sigma^2_1+\\sigma^2_2}}{\\sqrt{\\hat{\\sigma}^2_1+\\hat{\\sigma}^2_2}} \\xrightarrow[]{d} 1\n\t\\end{align}\n\tand \n\t\\begin{align}\n\t\\sqrt{n}\\frac{(\\overline{X}_n - \\overline{Y}_n)}{\\sqrt{\\sigma^2_1+\\sigma^2_2}} * \\frac{\\sqrt{\\sigma^2_1+\\sigma^2_2}}{\\sqrt{\\hat{\\sigma}^2_1+\\hat{\\sigma}^2_2}} \\sim N_{\\mu,\\sigma^2}(0,1) * 1\\\\\n\t\\sqrt{n}\\frac{(\\overline{X}_n - \\overline{Y}_n)}{\\sqrt{\\hat{\\sigma}^2_1+\\hat{\\sigma}^2_2}} * \\frac{\\sqrt{\\sigma^2_1+\\sigma^2_2}}{\\sqrt{\\sigma^2_1+\\sigma^2_2}} \\sim N_{\\mu,\\sigma^2}(0,1) * 1\\\\\n\t\\sqrt{n}\\frac{(\\overline{X}_n - \\overline{Y}_n)}{\\sqrt{\\hat{\\sigma}^2_1+\\hat{\\sigma}^2_2}} * 1 \\sim N_{\\mu,\\sigma^2}(0,1) * 1\\\\\n\t\\sqrt{n}\\frac{(\\overline{X}_n - \\overline{Y}_n)}{\\sqrt{\\hat{\\sigma}^2_1+\\hat{\\sigma}^2_2}} \\sim N_{\\mu,\\sigma^2}(0,1)\n\t\\end{align}\n\\end{document}", "meta": {"hexsha": "1bdc0a232e14f0a87f6f2b9dfc1f360793b5a281", "size": 14793, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "texts/math/AsymptoticStatistics.tex", "max_stars_repo_name": "xunilrj/sandbox", "max_stars_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2017-04-01T17:18:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T05:23:23.000Z", "max_issues_repo_path": "texts/math/AsymptoticStatistics.tex", "max_issues_repo_name": "xunilrj/sandbox", "max_issues_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-05-24T13:36:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T06:44:20.000Z", "max_forks_repo_path": "texts/math/AsymptoticStatistics.tex", "max_forks_repo_name": "xunilrj/sandbox", "max_forks_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-20T01:07:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-22T14:55:38.000Z", "avg_line_length": 38.6240208877, "max_line_length": 527, "alphanum_fraction": 0.6643006828, "num_tokens": 5306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477015, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.44835384368766995}}
{"text": "% !TEX root = atlas_iros_16.tex\n\\subsection{Rigid Body and Friction Identification}\n\\label{sec:advance_ident}\n%\n\n%\nIn our previous work \\cite{SpVdTh14} both, rigid body model and friction were simultaneously identified as the parameter vector $\\bm{\\beta}_{\\mathrm{I}}$.\nThe results still contained a relevant error regarding model fitting and plausibility of the friction parameters compared to single-joint experiments.\nTherefore, in this work a sequential procedure was applied, where pre-identified Coulomb and viscous friction parameters $\\bm{d}_\\mathrm{v,p}$, $\\bm{\\mu}_\\mathrm{C,p}$ were included into the identification procedure in order to reduce the parameter space from $59$ to $45$\nunknowns\\footnote{\nThe 70 dynamic parameters (10 per joint) are reduced to $n_\\mathrm{b}=45$ in the minimal regressor form.\nAdditionally, the model has $2n_\\mathrm{j}=14$ friction parameters (2 per joint) resulting in $n_\\beta=59$ parameters overall, see \\cite{SpVdTh14}.}.\n\\subsubsection{Identification Model and Approach}\n%\nFor identification purposes the robot dynamics (\\ref{eqn:invdyn}), including a suitable friction model, can be written in regressor form as  \n\\begin{equation}\n\\bm{\\tau}_{\\mathrm{m}} = \\bm{\\Phi} \\bm{\\beta} - \\bm{\\tau}_{\\mathrm{ext}},\n\\label{regressor}\n\\end{equation}\nwhere the regressor matrix $\\bm{\\Phi}$ contains distinct base and friction parameter related columns $\\bm{\\Phi} = \\begin{pmatrix} \\bm{\\Phi}_\\mathrm{b} & \\bm{\\Phi}_\\mathrm{f} \\end{pmatrix}$. \nThe elements of the parameter vector $\\bm{\\beta} = \\begin{pmatrix} \\bm{\\beta}_\\mathrm{b} \\ \\bm{d}_\\mathrm{v} \\ \\bm{\\mu}_\\mathrm{c} \\end{pmatrix}^{\\mathrm{T}}$ denote the base, viscous friction and Coulomb friction parameter vectors. \nThe regressor matrix of the friction model can be allocated as \n\\begin{equation}\n\\bm{\\Phi}_\\mathrm{f}(\\dot{\\bm{q}}) =   \n\\begin{pmatrix}\n\\mathrm{diag}\\{\\dot{\\bm{q}}\\}& \n\\mathrm{diag}\\{\\mathrm{sgn}(\\dot{\\bm{q}})\\}\\\\\n\\end{pmatrix}.\n\\label{friction_mdl}\n\\end{equation} \nAssuming $\\bm{\\tau}_{\\mathrm{ext}} = \\bm{0}$ during identification procedure, the influence of (\\ref{friction_mdl}) can be incorporated by subtracting (\\ref{friction_mdl}) from both sides in (\\ref{regressor}).\nThis leads to the friction-corrected motor torque\n\\begin{align}\n\\bm{\\tau}_{\\mathrm{m},\\mathrm {f}} &= \n\\bm{\\tau}_{\\mathrm{m}} -  \\bm{\\Phi}_{\\mathrm{f}} ( \\dot{\\bm{q}})(\\bm{d}_{\\mathrm{v}}, \\bm{\\mu}_{\\mathrm{c}})^{\\mathrm{T}}\\\\ \n&=\n\\bm{\\Phi} \\bm{\\beta} - \\bm{\\Phi}_{\\mathrm{f}} ( \\dot{\\bm{q}})(\\bm{d}_{\\mathrm{v}}, \\bm{\\mu}_{\\mathrm{c}})^{\\mathrm{T}}=\\bm{\\Phi}_\\mathrm{b}\\bm{\\beta}_\\mathrm{b}.\n\\end{align}\n%TODO QUELLE\n%The influence of friction to motor torque $\\bm{\\tau}_{\\mathrm{m}}$ can now be corrected by $\\bm{\\tau}_{\\mathrm{m},\\mathrm {f}} = \\bm{\\tau}_{\\mathrm{m}} - \\bm{\\Phi}_{\\mathrm{f}} ( \\dot{\\bm{q}})(\\bm{d}_{\\mathrm{v}}, \\bm{\\mu}_{\\mathrm{c}})^{\\mathrm{T}}$ using prior knowledge of friction parameters $\\bm{d}_\\mathrm{v,p}$ and $\\bm{\\mu}_\\mathrm{c,p}$. \nIdentifying the numerical values of $\\bm{\\beta}_{\\mathrm{b}}$ is done using a Moore-Penrose pseudoinverse \n%\n\\begin{equation}\n\\hat{\\bm{\\beta}}_{\\mathrm{b}} = {\\left( \\bm{F}^{\\mathrm{T}} \\bm{\\Sigma}^{-1} \\bm{F} \\right)}^{-1}  \\bm{F}^{\\mathrm{T}} \\bm{\\Sigma}^{-1}\\bm{b}\n\\label{MoorePenrose}\n\\end{equation}\n%\nfilled with experimentally gained optimized Fourier-based joint angle trajectories of duration $t_{\\mathrm{f}}$ \\cite{park2006fourier}. \nThe information matrix $\\bm{F}$ and the measurement vector $\\bm{b}$ are defined as\n%\n\\begin{equation}\n\\bm{F} = \\begin{pmatrix}\n\\bm{\\Phi}_{\\mathrm{b}}\\left( \\bm{q}(t_1),\\dot{\\bm{q}}(t_1),\\ddot{\\bm{q}}(t_1) \\right) \\\\\n\\bm{\\Phi}_{\\mathrm{b}}\\left( \\bm{q}(t_2),\\dot{\\bm{q}}(t_2),\\ddot{\\bm{q}}(t_2) \\right) \\\\\n\\vdots \\\\\n\\bm{\\Phi}_{\\mathrm{b}}(\\bm{q}(t_{\\mathrm{f}}),\\dot{\\bm{q}}(t_{\\mathrm{f}}),\\ddot{\\bm{q}}(t_{\\mathrm{f}}))\\end{pmatrix},~~\n\\bm{b} = \\begin{pmatrix}\n\\bm{\\tau}_\\mathrm{m,f}(t_1) \\\\\n\\bm{\\tau}_\\mathrm{m,f}(t_2) \\\\\n\\vdots \\\\\n\\bm{\\tau}_\\mathrm{m,f}(t_{\\mathrm{f}})\n\\end{pmatrix},\n\\end{equation}\n%\nwhere $\\bm{\\tau}_\\mathrm{m,f}(t_i)$ are friction-corrected torque measurements using prior knowledge of friction parameters $\\bm{d}_\\mathrm{v,p}$ and $\\bm{\\mu}_\\mathrm{c,p}$.\nThe covariance matrix $\\bm{\\Sigma}$ is composed of actuator noise variances.\nTorque measurements $\\bm{\\tau}_{\\mathrm{m}}$ are determined based on chamber pressures for the hydraulic joints and electric currents for the electromechanic joints.\nGear ratios and motor constants are provided by the manufacturer.\nThe joint angle $\\bm{q}$ is measured by position encoders. \nThe resulting parameter vector $\\bm{\\beta}_{\\mathrm{II}}$ of the sequential method, which is used to parameterize (\\ref{regressor}), consists of the elements $\\bm{\\beta}_{\\mathrm{II}} = \\begin{pmatrix} \\bm{\\beta}_\\mathrm{b} \\ \\bm{d}_\\mathrm{v,p} \\ \\bm{\\mu}_\\mathrm{c,p} \\end{pmatrix}^{\\mathrm{T}}$.\n\n\\subsubsection{Single Joint Friction Identification}\n\nThe identification of joint friction parameters $\\bm{d}_{\\mathrm{v,p}}$ and $\\bm{\\mu}_{\\mathrm{c,p}}$ is done by running a set of different constant velocities $\\dot{q}_i$ in positive and negative direction and measuring the resulting torque $\\bm{\\tau}_{\\mathrm{m}}$ for every joint. \nMean velocity and torque are calculated using intervals of constant speed.\nFigure~\\ref{fig:ident_friction_char} depicts the joint friction characteristics for the hydraulic joints which show significant Coulomb and viscous friction. \n\n% figure generated with MATLAB in\n% drc_paper/Atlas_IROS_16/figures/Identification/FrictionCharacteristics_resultfigures_IROS.m\n\\begin{figure}\n\\centering\n\\includegraphics[]{./figures/Identification/FrictionCharacteristics_left}\n\\caption{Viscous and Coulomb friction for the hydraulic joints of the left arm. Each marker represents the mean value of one constant velocity single joint experiment, see Fig.~\\ref{fig:velocity_tracking_friction}. Dynamics effects from $\\bm{\\Phi}_{\\mathrm{b}}$ were removed and calculated with dynamics parameters $\\hat{\\bm{\\beta}}_{\\mathrm{b,I}}$ from the combined identification approach \\cite{SpVdTh14} and with assumed fixed and upright upper body orientation.}\n\\label{fig:ident_friction_char}\n\\SkipBeforePicture\n\\end{figure}\n\nThe identification results could be further improved by using the impedance controller to execute the identification trajectory, as it shows significantly improved velocity tracking compared to an extensively tuned PD controller implemented by the manufacturer, see Fig.~\\ref{fig:velocity_tracking_friction}.\nThe identified friction parameters are given in Table~\\ref{tab:errors_tracking_left}.\n\n%\n% figure generated with MATLAB in\n%./figures/Identification/ConstVel_AssemblyFigure_middle_plot.m\n\\begin{figure}\n\\centering\n\\includegraphics[width=\\linewidth]{./figures/Identification/SI_E036_Joint4_ConstVel_Summary_medium_speed}\n\\caption{Single joint friction experiment exemplified for joint 4 reveals improved velocity tracking of the impedance controller compared to PD position control with controller gains from \\cite{2014:JFR-ViGIR-DRC-Trials, ConnerKohRomStu2015}.}\n\\label{fig:velocity_tracking_friction}\n\\SkipBeforeText\n\\end{figure}\n\n% MSE-Werte werden auch in atlas5_plot_torque_ident_MPV_left_DRC_IROS.m ausgegeben.\n%\n\\setlength\\tabcolsep{5pt}\n\\begin{table}\n   \\caption{Mean square errors (MSE) for arm identification using different base parameter vectors $\\hat{\\bm{\\beta}}_{\\mathrm{I}}$, $\\hat{\\bm{\\beta}}_{\\mathrm{II}}$ and data from Fig.~\\ref{fig:ident_torque_compare} and identified friction parameters from single-joint experiments}\n  \\begin{center}\n   \\begin{tabular}{c|c|c|c|c}\njoint  & $\\mathrm{MSE}(\\bm{\\tau}_{\\mathrm{m}}-\\bm{\\tau}_{\\mathrm{I}})$   & $\\mathrm{MSE}(\\bm{\\tau}_{\\mathrm{m}}-\\bm{\\tau}_{\\mathrm{II}})$   & $\\hat{{\\mu}}_{\\mathrm{C,p},i}$ & $\\hat{{d}}_{\\mathrm{v,p},i}$ \\\\\n & [(Nm)$^2$] & [(Nm)$^2$] & [Nm] & [Nms/rad] \\\\ \n\\hline\n1 (shz) &  97.04  & 13.03 & 2.0 & 1.3 \\\\\n2 (shx) &  52.64  & 20.78 & 6.7 & 0.9 \\\\\n3 (ely) &  22.58  & 16.62 & 10.3 & 1.6 \\\\\n4 (elx) &  25.22  & 18.66 & 6.1 & 2.7 \\\\\n\\hline\n5 (wry) &  2.82 & 6.50 & 0.1 & 0.5 \\\\\n6 (wrx) &  8.11 & 3.46 & 0.1 & 0.2 \\\\\n7 (wry2) &  0.26 & 18.28 & 3.1 & 0.2 \\\\\n   \\end{tabular}\n  \\end{center} \n\\label{tab:errors_tracking_left}\n\\SkipBeforePicture\n\\end{table}\n\\setlength\\tabcolsep{6pt}\n\n\\subsubsection{Results of the Sequential Identification}\n\nA comparison between the base parameter vector $\\hat{\\bm{\\beta}}_{\\mathrm{I}} = \\begin{pmatrix} \\hat{\\bm{\\beta}}_\\mathrm{b,I} \\ \\hat{\\bm{d}}_\\mathrm{v} \\ \\hat{\\bm{\\mu}}_\\mathrm{C} \\end{pmatrix}^{\\mathrm{T}}$, where friction was identified as part of the combined least squares optimization \\cite{SpVdTh14}, and the base parameter vector $\\hat{\\bm{\\beta}}_{\\mathrm{II}}$ of the sequential method can be found in Fig.~\\ref{fig:ident_torque_compare}.\nGood model consistency is indicated by low distance between model and measurement.\nTo avoid the problem of overfitting, the trajectory of this experiment was different from the one used for identification.\nWhen using the parameter vector $\\hat{\\bm{\\beta}}_{\\mathrm{II}}$, significantly improved results could be achieved in the hydraulic joints, indicated by the lower mean square error between measured and modeled torques in Table~\\ref{tab:errors_tracking_left}.\n\n% Bildquelle: atlas5_plot_torque_ident_MPV_left_DRC_IROS.m\n\\begin{figure}\n\\centering\n\\includegraphics{./figures/Identification/atlas5_plot_torque_ident_MPV_left_IROS}\n\\caption{Measured ($\\bm{\\tau}_\\mathrm{m}$) and simulated torques of the left arm joints comparing the sequential method $\\bm{\\tau}_{\\mathrm{\\mathrm{II}}}$ with the combined method $\\bm{\\tau}_{\\mathrm{\\mathrm{I}}}$.}\n\\label{fig:ident_torque_compare}\n\\SkipBeforeText\n\\end{figure}\n\nAs already mentioned in \\cite{SpVdTh14}, the electromechanic wrist joints (wry, wrx, wry2) do not seem to be identifiable for the Atlas system without working joint torque sensors.\nAlthough friction was identified in single axis experiments, the predicted\ntorques have essentially no correlation with the measured torques. \nPresumably, this is due to the current-based torque measurement on actuator side, which decreases the quality of the measured information significantly.\n\nIn the next section, the results for the experimental collision handling performance with the Atlas system are outlined. ", "meta": {"hexsha": "52aeb4cc9a6ed37f6529383af365f8fae30467b0", "size": 10269, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/sec_ident.tex", "max_stars_repo_name": "wuyou33/robotics-paper_iros2016", "max_stars_repo_head_hexsha": "ad8811f17b19176bb1ac0194191ad1d0f12ba073", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-22T02:23:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-22T02:23:33.000Z", "max_issues_repo_path": "paper/sec_ident.tex", "max_issues_repo_name": "wuyou33/robotics-paper_iros2016", "max_issues_repo_head_hexsha": "ad8811f17b19176bb1ac0194191ad1d0f12ba073", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/sec_ident.tex", "max_forks_repo_name": "wuyou33/robotics-paper_iros2016", "max_forks_repo_head_hexsha": "ad8811f17b19176bb1ac0194191ad1d0f12ba073", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.3851351351, "max_line_length": 466, "alphanum_fraction": 0.7296718278, "num_tokens": 3120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.4482849886211804}}
{"text": " \\documentclass [12pt]{article} \n\n\\usepackage {amsmath}\n\\usepackage {amsthm}\n\\usepackage {amssymb}\n\\usepackage {graphicx} \n\\usepackage {float}\n\\usepackage {multirow}\n\\usepackage {xcolor}\n\\usepackage {algorithmic}\n\\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \\usepackage {array} \n\\usepackage {booktabs} \n\\usepackage {url} \n\\usepackage {parskip} \n\\usepackage [margin=1in]{geometry} \n\\usepackage [T1]{fontenc} \n\\usepackage {cmbright} \n\\usepackage [many]{tcolorbox} \n\\usepackage [colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref} \n\\usepackage {enumitem} \n\\usepackage {xparse} \n\\usepackage {verbatim}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\lstset { %\n    language=C++,\n    backgroundcolor=\\color{black!5}, % set backgroundcolor\n    basicstyle=\\footnotesize,% basic font setting\n}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{remark}{Remark}\n\n\n\n\\DeclareTColorBox {Solution}{}{breakable, title={Solution}} \\DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}} \\DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt} \\DeclareDocumentCommand {\\Expecting }{+m}{\\textbf {[We are expecting:} #1\\textbf {]}} \\DeclareDocumentCommand {\\Points }{m}{\\textbf {(#1 pt.)}} \n\n\\begin {document}\n\n\\vspace {1em} \n\\begin {Instruction} \nAdapted From Virginia Williams' lecture notes.\n\\end {Instruction}  \n\n{\\LARGE \\textbf {COMP 285 (NC A\\&T, Spr `22)}\\hfill \\textbf {Lecture 8} } \n\n\\begin{centering}\n\\section*{Median of Medians}\n\\end{centering}\n\n\\section{Introduction}\nWe ended last lecture with a few ideas on how we could solve the kSelect problem. The only difference between the ideas involved how we chose the `pivot'! In this lecture, we'll cover a deterministic mechanism for chosing a pivot. As a refresher, here is the pseudo-code for the divide-and-conquer approach to the kSelect problem.\n\n\\begin{algorithm}\n\\caption{Select(A, n, k)}\\label{alg:select}\n\\begin{algorithmic}\n\\IF {$n=1$}\n    \\RETURN $A[1]$\n\\ENDIF\n\\STATE $p \\gets \\texttt{ChoosePivot}(A, n)$\n\\STATE $A_< \\gets \\{A[i] \\mid A[i] < p \\}$\n\\STATE $A_> \\gets \\{A[i] \\mid A[i] > p \\}$\n\\IF {$|A_<| = k - 1$}\n    \\RETURN $p$\n\\ELSIF {$|A_<| > k - 1$}\n    \\RETURN \\texttt{Select}$(A_<, |A_<|, k)$\n\\ELSIF {$|A_<| < k - 1$}\n    \\RETURN \\texttt{Select}$(A_>, |A_>|, k - |A_<| - 1)$\n\\ENDIF\n\\end{algorithmic}\n\\end{algorithm}\n\n\n\\section{Choose a pivot ``close enough'' to the median}\nGiven a linear-time median algorithm, we can solve the selection problem in linear time (and vice versa). Although ideally we would want to find the median, notice that as far as correctness goes, there was nothing special about partitioning around the median. We could use this same idea of partitioning and recursing on a smaller problem even if we partition around an arbitrary element. To get a good runtime, however, we need to guarantee that the subproblems get smaller quickly. In 1973, Blum, Floyd, Pratt, Rivest, and Tarjan came up with the Median of Medians algorithm. It is similar to the algorithm we covered in the last lecture, but rather than partitioning around the exact median, uses a surrogate ``median of medians''. We update \\texttt{ChoosePivot}accordingly.\n\n\\begin{algorithm}\n\\caption{ChoosePivot(A, n)}\\label{alg:choose_pivot}\n\\begin{algorithmic}\n\\STATE Split $A$ into $g = \\lceil n / 5 \\rceil$ groups $p_1, \\cdots, p_g$\n\\FOR {$i=1$ to $g$}\n    \\STATE $p_i \\gets \\texttt{MergeSort}(p_i)$\n\\ENDFOR\n\\STATE $C \\gets \\{ \\text{median of } p_i \\mid i = 1, \\cdots, g \\}$\n\\STATE $g \\gets \\texttt{Select}(C, g, g/2)$\n\\RETURN p\n\\end{algorithmic}\n\\end{algorithm}\n\nWhat is this algorithm doing? First it divides $A$ into segments of size $5$. Within each group, it finds the median by first sorting the elements with \\texttt{MergeSort}. Recall that \\texttt{MergeSort} sorts in $O(n \\log n)$ time. However, since each group has a constant number of elements, it takes constant time to sort. Then it makes a recursive call to \\texttt{Select} to find the median of $C$, the median of medians. Intuitively, by partitioning around this value, we are able to find something that is close to the true median for partitioning, yet is `easier' to compute, because it is the median of $g = \\lceil n/5 \\rceil$ elements rather than $n$. The last part is as before: once we have our pivot element $p$, we split the array and recurse on the proper subproblem, or halt if we found our answer. \n\nWe have devised a slightly complicated method to determine which element to partition\naround, but the algorithm remains correct for the same reasons as before. So what is its running time? As before, we're going to show this by examining the size of the recursive subproblems. As it turns out, by taking the median of medians approach, we have a guarantee on how much smaller the problem gets each iteration. The guarantee is good enough to achieve $O(n)$ runtime.\n\n\\subsection{Running Time}\n\n\\textbf{Lemma.} $|A_<| \\leq 7n/10 + 5$ and $|A_>| \\leq 7n/10 + 5$.\n\n\\begin{proof}\n$p$ is the median of $p_1, \\cdots , p_g$. Because $p$ is the median of $g = \\lceil n/5 \\rceil$ elements, the medians of $\\lceil g/2 \\rceil-1$ groups $p_i$ are smaller than $p$. If $p$ is larger than a group median, it is larger than at least three elements in that group (the median and the smaller two numbers). This\napplies to all groups except the remainder group, which might have fewer than 5 elements. Accounting for the remainder group, $p$ is greater than at least $3 \\cdot (\\lceil g/2 \\rceil - 2)$ elements of $A$.\nBy symmetry, $p$ is less than at least the same number of elements.\n\nNow,\n\\begin{align*}\n|A_>| &= \\# \\text{ of elements greater than } p \\\\\n\\leq (n-1) - 3 \\cdots (\\lceil g / 2 \\rceil - 2) \\\\\n= n + 5 - 3 \\cdots \\lceil g / 2 \\rceil \\\\\n\\leq n - 3n/10 + 5 \\\\\n\\leq 7n/10 + 5\n\\end{align*}\n\nBy symmetry, $|A_<| \\leq 7n/10 + 5$ as well.\n\nIntuitively, we know that 60\\% of half of the groups are less than the pivot, which is 30\\% of the total number of elements, $n$. Therefore, at most 70\\% of the elements are greater than the pivot. Hence, $|A_>| \\approx 7n/10$. We can make the same argument for $|A_<|$.\n\\end{proof}\n\nThe recursive call used to find the median of medians has input of size $\\lceil n/5 \\rceil \\leq n/5 + 1$. The other work in the algorithm takes linear time: constant time on each of $\\lceil n/5 \\rceil$ groups for \\texttt{MergeSort} (linear time total for that part), $O(n)$ time scanning $A$ to make $A_<$ and $A_>$.\n\nThus, we can write the full recurrence for the runtime,\n\n$$\nT(n) \\leq \\begin{cases}\n    c_1n + T(n/5 + 1) + T(7n/10 + 5) & \\text{if } n > 5 \\\\\n    c_2 & \\text{if } n \\leq 5\n\\end{cases}\n$$\n\nHow do we prove that $T(n) = O(n)$? The master theorem does not apply here. Instead, we will prove this using the substitution method.\n\n\\subsection{Solving the Recurrence of Select Using the Substitution Method}\n\nFor simplicity, we consider the recurrence $T(n) \\leq T(n/5) + T(7n/10) + cn $instead of the exact recurrence of \\texttt{Select}.\n\nTo prove that $T(n) = O(n)$, we guess:\n\n$$\nT(n) \\leq \\begin{cases}\n    d\\cdot n_0 & \\text{if } n = n_0 \\\\\n    d \\cdot n & \\text{if } n > n_0\n\\end{cases}\n$$\n\nFor the base case, we pick $n_0 = 1$ and use the standard assumption that $T(1) = 1 \\leq d$. For the inductive hypothesis, we assume that our guess is correct for any $n < k$, and we prove our guess for $k$. That is, consider $d$ such that for all $n_0 \\leq n < k, T(n) \\leq dn$.\n\nTo prove for $n = k$, we solve the following equation:\n\\begin{align*}\nT(k) &\\leq T(k/5) + T(7k/10) + ck \\\\\n&\\leq  dk/5 + 7dk/10 + ck \\\\\n\\implies 9/10d + c &\\leq dk \\\\\n\\implies c &\\leq d/10 \\\\\n\\implies d &\\geq 10c\n\\end{align*}\nTherefore, we can choose $d = \\max(1, 10c)$, which is a constant factor. The induction is completed. By the definition of big-Oh, the recurrence runs in $O(n)$ time.\n\n\\subsection{Isssues When Using the Substitution Method}\n\nNow we will try out an example where our guess is incorrect. Consider the recurrence $T(n) = 2T(n/2) + n$ (similar to \\texttt{MergeSort}). We will guess that the algorithm is linear\n$$\nT(n) \\leq \\begin{cases}\n    d\\cdot n_0 & \\text{if } n = n_0 \\\\\n    d \\cdot n & \\text{if } n > n_0\n\\end{cases}\n$$\nWe try the inductive step. We try to pick some $d$ such that for all $n \\geq n_0$,\n\\begin{align*}\nn + \\Sigma_{i=1}^{k} dg(n_i) &\\leq d \\cdot g(n) \\\\\nn + 2\\cdot d \\cdot \\frac{n}{2} &\\leq dn \\\\\nn(1 + d) \\leq dn \\\\\nn + dn \\leq dn \\\\\nn < 0\n\\end{align*}\nHowever, the above can never be true, and there is no choice of d that works! Thus our guess was incorrect.\n\nThis time the guess was incorrect since \\texttt{MergeSort} takes superlinear time. Sometimes, however, the guess can be asymptotically correct but the induction might not work out. Consider for instance $T(n) \\leq 2T(n/2) + 1$.\n\nWe know that the runtime is $O(n)$ so let's try to prove it with the substitution method. Let's guess that $T(n) \\leq cn$ for all $n \\geq n_0$.\n\nFirst we do the induction step: We assume that $T(n/2) \\leq cn/2$ and consider $T(n)$. We\nwant that $2 \\cdot cn/2 + 1 \\leq cn$, that is, $cn + 1 \\leq cn$. However, this is impossible.\n\nThis doesn't mean that $T(n)$ is not $O(n)$, but in this case we chose the wrong linear function. We could guess instead that $T(n) \\leq cn-1$. Now for the induction we get $2\\cdot(cn/2-1)+1 = cn - 1$ which is true for all $c$. We can then choose the base case $T(1) = 1$.\n\n\\subsection{Correctness of the Algorithm}\nRecall that the choice of pivot only affects the runtime, and not the correctness of the algorithm. Here, we prove formally, by induction, that \\texttt{Select} is correct. We will use strong induction. That is, our inductive step will assume that the inductive hypothesis holds for all $n$ between $1$ and $i -1$, and then we’ll show that it holds for $n = i$.\n\n\\textit{Remark.} You can also do this using regular induction with a slightly more complicated inductive hypothesis; either way is fine.\n\n\\textbf{Inductive Hypothesis (for $n$)}. When run on an array $A$ of size $n$ and an integer $k \\in \\{1, \\cdots , n\\}$, Select returns the $k$-th smallest element of A.\n\n\\textbf{Base Case ($n = 1$)}. When $n = 1$, the requirement $k \\in \\{1, \\cdots , n\\}$ means that $k = 1$; that is, \\texttt{Select}$(A, k)$ is supposed to return the smallest element of A. This is precisely what the pseudocode above does when $|A| = 1$, so this establishes the Inductive Hypothesis for $n = 1$.\n\n\\textbf{Inductive Step.} Let $i \\geq 2$, and suppose that the inductive hypothesis holds for all $n$ with $1 \\leq n < i$. Our goal is to show that it holds for $n = i$. That is, we would like to show that \n\n    \\textit{When run on an array $A$ of size $i$ and an integer $k \\in \\{1, \\cdots, i\\}$, Select$(A, k)$ returns the $k$-th smallest element of $A$}.\n\nInformally, we want to show that assuming that \\texttt{Select} ``works'' on smaller arrays, then it ``works'' on an array of length n. \n\nWe do this below:\n\nSuppose that $1 \\leq k \\leq i$, and that $A$ is an array of length $i$. There are three cases to consider,\ndepending on $p = \\texttt{ChoosePivot}(A, i)$. Notice that in the pseudocode above, $p$ is a value from A, not an index. Let $A_<, A_>, p$ be as in the pseudocode above.\n\n\\begin{itemize}\n\\item \\textbf{Case 1.} Suppose that $|A_<| = k -1$. Then by the definition of $A_<$, there are $k -1$ elements of $A$ that are smaller than $p$, so $p$ must be the $k$-th smallest. In this case, we return $p$, which is indeed the $k$-th smallest.\n\\item \\textbf{Case 2.} Suppose that $|A_<| > k -1$. Then there are more than $k -1$ elements of $A$ that are smaller than $p$, and so in particular the $k$-th smallest element of $A$ is the same as the $k$-th smallest element of $L$. Next we will use the inductive hypothesis for $n = |A_<|,$ which holds since $|A_<| < i$. Since $1 \\leq k \\leq |A_<|,$ the inductive hypothesis implies that \\texttt{Select}($A_<, k$) returns the $k$-th smallest element of $A_<$. Thus, by returning this we are also returning the $k$-th smallest element of $A$, as desired.\n\\item \\textbf{Case 3.} Suppose that $|A_<| $< $k -1$. Then there are fewer than $k -1$ elements that are less than $p$, which means that the $k$-th smallest element of $A$ must be greater than $p$; that is, it shows up in $A_>$. Now, the $k$-th smallest element in $A$ is the same as the $(k -|A_<| -1)$-st element in $A_>$. To see this, notice that there are $|A_<| + 1$ elements smaller than the $k$-th that do not show up in $A_>$. Thus there are $k -(|A_<| + 1) = k -|A_<| -1$ elements in $A_>$ that are smaller than or equal to the $k$-th element. Now we want to apply the inductive hypothesis for $n = |A_>|$, which we can do since $|A_>| < i$. Notice that we have $1 \\leq k -|A_<| -1 \\leq |A_>|$; the first inequality holds because $k > |A_<| + 1$ by the definition of Case 3, and the second inequality holds because it is the same as $k \\leq |A_<| + |A_>| + 1 = n$, which is true by assumption. Thus, the inductive hypothesis implies that \\texttt{Select}($A_>, k -|A_<| -1$) returns the $(k -|A_<| -1)$-st element of $A_>$. Thus, by returning this we are also returning the $k$-th smallest element of A, as desired.\n\nThus, in each of the three cases, \\texttt{Select}($A, k$) returns the $k$-th smallest element of $A$. This establishes the inductive hypothesis for $n = i$.\n\\end{itemize}\n\n\\textbf{Conclusion.} By induction, the inductive hypothesis holds for all $n \\geq 1$. Thus, we conclude that Select($A, k$) returns the $k$-th smallest element of A on any array $A$, provided that $k \\in \\{1, \\cdots , |A|\\}$. That is, \\texttt{Select} is correct, which is what we wanted to show.\n\n\\end{document}\n", "meta": {"hexsha": "0eaf2869e3051b9d8eb594309b994e775658fd99", "size": 13730, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/lectures/lecture8.tex", "max_stars_repo_name": "facebookEIR/algorithms-course", "max_stars_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-16T02:47:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-16T02:47:46.000Z", "max_issues_repo_path": "assets/lectures/lecture8.tex", "max_issues_repo_name": "facebookEIR/algorithms-course", "max_issues_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/lectures/lecture8.tex", "max_forks_repo_name": "facebookEIR/algorithms-course", "max_forks_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-01-20T21:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T03:00:16.000Z", "avg_line_length": 62.9816513761, "max_line_length": 1123, "alphanum_fraction": 0.6932265113, "num_tokens": 4401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.8438950986284991, "lm_q1q2_score": 0.44828498653562926}}
{"text": "%!TEX root = ../notes.tex\n\\section{April 7, 2022}\n\\subsection{Quadratic Fields \\emph{continued}}\n\n\\begin{definition*}\n    A quadratic field is a number field $K$ of degree $2$ over $\\QQ$.\n\n    Thus $K = \\QQ(\\theta)$ for $\\theta$ a zero of some\n    \\[x^2 + ax + b\\]\n    for $a, b\\in\\ZZ$.\n\\end{definition*}\nHence,\n\\[\\theta = \\frac{-a\\pm \\sqrt{a^2 - 4b}}{2}.\\]\nThus from which it follows\n\\begin{proposition*}\n    The quadratic fields are of the form $\\QQ(\\sqrt{d})$ where $d\\in\\ZZ$ is squarefree.\n\\end{proposition*}\n\n\\begin{theorem*}[p.64 of \\cite{stewart2015algebraic}]\n    Let $d\\in\\ZZ$ be a squarefree integer and let $K = \\QQ(\\sqrt{d})$. Then $\\riO_K$ equals\n    \\begin{enumerate}[a)]\n        \\item $\\ZZ\\left[\\sqrt{d}\\right]$ if $d\\not\\equiv 1\\pmod{4}$.\n        \\item $\\ZZ\\left[\\frac{1+\\sqrt{d}}{2}\\right]$ if $d\\equiv 1\\pmod{4}$.\n    \\end{enumerate}\n\\end{theorem*}\n\\begin{proof}\n    Every $\\alpha\\in\\QQ(\\sqrt{d})$ is of the form\n    \\[\\alpha = \\frac{a\\pm b\\sqrt{d}}{c}\\]\n    with $a, b, c\\in\\ZZ$ and $\\gcd(a, b, c) = 1$. Now $\\alpha\\in\\riO_K$ iff the coefficients of\n    \\[\\left( x - \\frac{a + b\\sqrt{d}}{c} \\right)\\left( x - \\frac{a - b\\sqrt{d}}{c} \\right)\\]\n    are in $\\ZZ$. This holds iff\n    \\[\\frac{a^2 - b^2d}{c^2}\\in\\ZZ\\qquad\\text{and}\\qquad \\frac{2a}{c}\\in\\ZZ\\]\n\n    If $(a, c)\\neq 1$, then in our first expression, the fact that $d$ is squarefree forces our common factor must also be shared with $b$. So $\\gcd(a, b, c)\\neq 1$. So $(a, c) = 1$. Looking at our second expression, $c$ is forced to be $1$ or $2$.\n\n    If $c = 1$, then $\\alpha\\in\\riO_K$ anyway, so assume that $c = 2$. We have that $\\gcd(b, c) = 1$ by the same reasoning as before, so $c=2$ implies that $a$ and $b$ are both odd.\n\n    Moreover, $\\alpha\\in\\riO_K$ with these assumptions iff\n    \\[\\frac{a^2 - b^2d}{c^2} = \\frac{a^2 - b^2d}{4}\\in\\ZZ\\]\n    which happens iff $a^2 - b^2d\\equiv 0\\pmod{4}$. Then $a, b$ odd implies $a^2 \\equiv b^2\\equiv 1\\pmod{4}$ so we get that this is equivalent to $d\\equiv 1\\pmod{4}$.\n\n    Thus $c = 2$ and $\\alpha\\in\\riO_K$ implies that $d\\equiv 1\\pmod{4}$.\n\n    In sum, if $d\\not\\equiv 1\\pmod{4}$, then $c = 1$, so we've shown that $\\riO_K = \\ZZ[\\sqrt{d}]$. If $d\\equiv 1\\pmod{4}$, then we can have $c = 2$ and $a, b$ odd. Hence $\\riO_K = \\ZZ\\left[ \\frac{1+\\sqrt{d}}{2} \\right]$.\n\\end{proof}\n\n\\begin{theorem}[p.65 \\cite{stewart2015algebraic}]\n    We then have the following:\n    \\begin{enumerate}[a)]\n        \\item If $d\\not\\equiv 1\\pmod{4}$, then $\\{1, \\sqrt{d}\\}$ is an integral basis. If $d\\equiv 1\\pmod{4}$, then $\\left\\{1, \\frac{1+\\sqrt{d}}{2}\\right\\}$ is an integral basis.\n        \\item If $d\\not\\equiv 1\\pmod{4}$, then $\\disc(K) = 4d$. If $d\\equiv 1\\pmod{4}$, then $\\disc{K} = d$.\n    \\end{enumerate}\n\\end{theorem}\n\n\\subsection{Cyclotomic Extensions}\n\\begin{definition}\n    A \\ul{cyclotomic field/extension} is a number field of the form\n    \\[K = \\QQ(\\zeta_n), \\quad \\zeta_n = e^{2\\pi i / n}.\\]\n    That is, $\\zeta_n$ is the primitive $n$-th root of unity. We could just as easily take $\\zeta_n = e^{2\\pi i k / n}$ where $\\gcd(k, n) = 1$.\n\\end{definition}\n\\begin{example}\n    $n = 1$ is boring. $n = 2$ is boring. $n = 2$ gives a quadratic field.\n\\end{example}\n\\begin{example}\n    $K = \\QQ(i)$ for $n=4$, $\\zeta_4 = i$.\n\n    $K = \\QQ(\\sqrt{-3}) = \\QQ\\left(\\frac{1 + \\sqrt{-3}}{2}\\right) = \\QQ(\\zeta_3)$.\n\\end{example}\n\nWe note:\n\\begin{itemize}\n    \\item\n          Any embedding of $\\QQ(\\zeta_n)\\hookrightarrow \\CC$ has image contained in $\\QQ(\\zeta_n)$. (In other words, these extensions are Galois over $\\QQ$.)\n    \\item\n          We care about extensions of the form $\\QQ(\\sqrt[n]{a})$ where $a\\in\\QQ$. But these are not Galois in general.\n\n          The solution is to ``repair'' the base field. Take $K = \\QQ(\\zeta_n)$ and $L = K(\\sqrt[n]{a})$. Then $L/K$ is Galois. This is to say that the embeddings $L\\hookrightarrow \\CC$ that fix $K$ stabilize $L$ (send $L$ to itself).\n    \\item \\emph{Kronecker-Weber theorem} that every finite Abelian extension of $\\QQ$ is contained in some cyclotomic extension.\n\\end{itemize}\n\nWe have some \\ul{key facts about cyclotomic extensions}:\n\\begin{enumerate}[1)]\n    \\item $[\\QQ(\\zeta_n) : \\QQ] = \\phi(n)$.\n    \\item The field automorphisms $\\sigma: \\QQ(\\zeta_n)\\to \\QQ(\\zeta_n)$ form a cyclic group under composition, of order $\\phi(n)$. (Our automorphisms send $\\zeta_n$ to some other primitive $n$-th root of unity $\\zeta_n'$.)\n\n          From now on, let $K = \\QQ(\\zeta_n)$.\n    \\item Then $\\riO_K = \\ZZ[\\zeta_n]$. The case where $n = p$ is in the textbook.\n    \\item We have\n          \\[\\disc(K) = (-1)^{\\phi(n)/2}\\frac{n^{\\phi(n)}}{\\displaystyle\\prod_{\\substack{p\\mid n \\\\ p\\text{ prime}}} p^{\\phi(n)/(p-1)} }\\]\n\n          For $n = p$ prime, we get\n          \\begin{align*}\n              \\disc(\\QQ(\\zeta_p)) & = (-1)^{(p-1)/2}\\cdot \\frac{p^{p-1}}{p} \\\\\n                                  & = (-1)^{(p-1)/2}\\cdot p^{p-2}\n          \\end{align*}\n          In particular, if $p\\in\\ZZ$ is a prime with $p\\nmid n$, then $p\\nmid \\disc(K)$.\n\\end{enumerate}\n\n\\subsection{Prime Factorization in Number Fields}\nUseful to note that this is section 5.1 in \\cite{stewart2015algebraic}.\n\n\\recall the examples of non-UFDs given previously in Math 1530.\n\\begin{example}\n    In $\\ZZ[\\sqrt{-5}]$, we have $6 = 2\\cdot 3 = (1 + \\sqrt{-5})(1 - \\sqrt{-5})$. And we check that each term here is irreducible.\n\n    (2, for example, is not an associate of $1+\\sqrt{-5}$ or $(1 - \\sqrt{-5})$. Simply reason by norms.)\n\\end{example}\n\n\\begin{example}\\label{example:q-sqrt-15}\n    What about $\\QQ(\\sqrt{15})$?\n    \\[2\\cdot 5 = (5 + \\sqrt{15})(5 - \\sqrt{15})\\]\n    in $\\ZZ[\\sqrt{15}]$.\n\\end{example}\n\\begin{example}\n    In $\\QQ(\\sqrt{30})$,\n    \\[2\\cdot 3 = (6 + \\sqrt{30})(6 - \\sqrt{30})\\]\n\n    In $\\QQ(\\sqrt{-10})$,\n    \\[2\\cdot 7 = (2 + \\sqrt{-10})(2 - \\sqrt{-10})\\]\n\\end{example}\n\\begin{ques*}\n    What's going wrong?\n\\end{ques*}\nIn \\cref{example:q-sqrt-15}, we notice\n\\begin{align*}\n    5 + \\sqrt{15} = \\sqrt{5}(\\sqrt{5} + \\sqrt{3}) \\\\\n    5 - \\sqrt{15} = \\sqrt{5}(\\sqrt{5} - \\sqrt{3})\n\\end{align*}\nMultiplying these together, we get\n\\[25 - 15 = 10 = 5\\cdot (\\sqrt{5} + \\sqrt{3})\\cdot (\\sqrt{5} - \\sqrt{3})\\]\nso the factors in\n\\[\\sqrt{5}\\qquad \\sqrt{5} + \\sqrt{3} \\qquad \\sqrt{5} - \\sqrt{3}\\]\nare being grouped in $2$ ways:\n\\[(a_1^2)(a_2a_3) = (a_1a_2)(a_1a_3)\\]\nIn other words, the problem goes away in $\\riO_L$ for $L = \\QQ(\\sqrt{15}, \\sqrt{5}) = \\QQ(\\sqrt{3}, \\sqrt{5})$ (we extend to get some other things in it).\n\nWe can check that the same thing underlies the other two examples.\n\n\\begin{theorem}[Principal Ideal Theorem]\n    Let $K$ be a number field. Then there is a finite extension $L/K$ such that every nonzero $\\alpha\\in\\riO_K$ has a unique factorization into irreducibles in $\\riO_L$.\n\\end{theorem}\n\n\\textbf{Caution!} This does \\emph{not} say that $\\riO_L$ is a UFD. So it is not true that every number field $K$ has a finite extension $L/K$ such that $\\riO_L$ is a UFD.", "meta": {"hexsha": "f43513a9809f02726c130fa7069eee90cd15f177", "size": 6918, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-04-07.tex", "max_stars_repo_name": "jchen/math1560-notes", "max_stars_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-02T15:41:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T20:28:48.000Z", "max_issues_repo_path": "lectures/2022-04-07.tex", "max_issues_repo_name": "jchen/math1560-notes", "max_issues_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-04-07.tex", "max_forks_repo_name": "jchen/math1560-notes", "max_forks_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.3776223776, "max_line_length": 248, "alphanum_fraction": 0.6042208731, "num_tokens": 2610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555714, "lm_q2_score": 0.8198933403143929, "lm_q1q2_score": 0.448266981818593}}
{"text": "% !TEX options=--shell-escape\n\\documentclass [12pt]{article} \n\\usepackage {amsmath}\n\\usepackage {amsthm}\n\\usepackage {amssymb}\n\\usepackage {graphicx} \n\\usepackage {float}\n\\usepackage {multirow}\n\\usepackage {xcolor}\n\\usepackage {algorithmic}\n\\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \\usepackage {array} \n\\usepackage {booktabs} \n\\usepackage {url} \n\\usepackage {parskip} \n\\usepackage [margin=1in]{geometry} \n\\usepackage [T1]{fontenc} \n\\usepackage {cmbright} \n\\usepackage [many]{tcolorbox} \n\\usepackage [colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref} \n\\usepackage {enumitem} \n\\usepackage {xparse} \n\\usepackage {verbatim}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{csquotes}\n\\usepackage[cache=false]{minted}\n\\usepackage{mdframed}\n\\usepackage{tikz}\n\\usetikzlibrary{shapes.symbols}\n\\newtheorem{theorem}{Theorem}\n\n\\DeclareTColorBox {Solution}{}{breakable, title={Solution}}\n\\DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}}\n\\DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt}\n\\DeclareDocumentCommand {\\Expecting }{+m}{\\textbf {[We are expecting:} #1\\textbf {]}}\n\\DeclareDocumentCommand {\\Points }{m}{\\textbf {(#1 pt.)}} \n\\newcommand {\\hint }[1]{\\noindent {[\\textbf {HINT:} \\em #1 \\em ]}} \\newcommand {\\pts }[1]{\\textbf {(#1 pt.)}} \n\n\\begin{document} \n\n{\\LARGE \\textbf {COMP 285 (NC A\\&T, Spr `22)}\\hfill \\textbf {Weekly Quiz 5} } \n\n\\begin{Instruction}\n\n\\paragraph{Reporting Issues} If you find any issues with the solutions, reach out to Chi Wang (author) or Luis Perez (reviewer).\n\n\\end{Instruction}\n\n\n\\section{} In order to conclude an expected runtime of $O(1)$ for hash table operations, we assumed the followingtwo happen in some specific order: \n\\begin{enumerate}\n    \\item The adversary picks elements $x_1, \\cdots , x_n$ for the hash table\n    \\item The algorithm picks a hash function from the hash family.\n\\end{enumerate}\n\n\\begin{Solution}\n(1) Adversary first, then (2) algorithm.\n\\paragraph{}\n\nBad guys may lower our running time by picking the worst-case element if they know the hash function algorithm before picking elements. \n\\end{Solution}\n\n\n\\section{} Math review: What is $285 \\mod 5$?\n\n\\begin{Solution}\n0\n\\end{Solution}\n\n\n\\section{} Math review: What is the meaning of the ``$a \\mod b$'' operation?\n\n\\begin{Solution}\nYou divide $a$ by $b$ and take the remainder.\n\\end{Solution}\n\n\n\\section{} Suppose that we have a universe of size $M$, and our hash table size is $n$. If $n \\geq M$, what is the minimum size of a universal hash family?\n\n\\begin{Solution}\n1\n\\paragraph{}\nSince our hash table is bigger than our universe, a single hash function will be sufficient for the family to be universal.\n\\end{Solution}\n\n\n\\section{} You start your DFS algoritmh at node $0$, and assume that the vertices' numbers are used as tie breakers (you visit vertices with smaller numbers first). In what order do you enter the vertices.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.5]{1.png} \n    \\label{fig:my_label}\n\\end{figure}\n\n\\begin{Solution}\n0, 2, 3, 4, 1, 5\n\\end{Solution}\n\n\n\\section{} You start your DFS algoritmh at node 0, and assume that the vertices' numbers are used as tie breakers (you visit vertices with larger numbers first). In what order do you enter the vertices. \n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.5]{1.png} \n    \\label{fig:my_label}\n\\end{figure}\n\n\\begin{Solution}\n0, 5, 4, 2, 3, 1\n\\end{Solution}\n\n\n\\section{} What is the degree of vertex 4?\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.5]{1.png} \n    \\label{fig:my_label}\n\\end{figure}\n\n\\begin{Solution}\n3\n\\paragraph{}\nThere are 3 edges coming out from the vertex 4.\n\\end{Solution}\n\n\n\\section{} Two options for representing graphs are the (1) adjacency list representations and the (2) matrix representation. For edge (v, w), what is the running time of checking if it exists in the matrix representation, where $n$ is the number of nodes in the graph? There may be multiple correct answers. Select 1.\n\n\\begin{Solution}\n$O(1)$\n\\paragraph{}\nSimply check $matrix[v][w]$, 1 or 0 means there exists such edge or not. \n\\end{Solution}\n\n\n\\section{} Two options for representing graphs are the (1) adjacency list representations and the (2) matrix representation. For edge (v, w), what is the running time of checking if it exists in the adjacency list representation, where n is the number of nodes in the graph? There may be multiple correct answers. Select 1.\n\n\\begin{Solution}\n$O(\\text{degree}(v)) / O(\\text{degree}(w))$\n\\paragraph{}\nTo find edge(v,w), we may need to iterate the whole list whose size is $\\text{degree}(v)/\\text{degree}(w)$.\n\\end{Solution}\n\n\n\\section{} Two options for representing graphs are the (1) adjacency list representations and the (2) matrix representation. How much space is required for each, where n is the number of nodes and m is the number of edges. \n\n\\begin{Solution}\nAdjacency: $O(n+m)$, Matrix: $O(n^2)$\n\\end{Solution}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document} ", "meta": {"hexsha": "0a8e4cbc444ca945d45c6f8a1423d019a5a99821", "size": 5174, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/quizzes/quiz5.tex", "max_stars_repo_name": "facebookEIR/algorithms-course", "max_stars_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-16T02:47:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-16T02:47:46.000Z", "max_issues_repo_path": "assets/quizzes/quiz5.tex", "max_issues_repo_name": "facebookEIR/algorithms-course", "max_issues_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/quizzes/quiz5.tex", "max_forks_repo_name": "facebookEIR/algorithms-course", "max_forks_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-01-20T21:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T03:00:16.000Z", "avg_line_length": 30.4352941176, "max_line_length": 323, "alphanum_fraction": 0.7212988017, "num_tokens": 1510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.8499711775577736, "lm_q1q2_score": 0.44820384632260196}}
{"text": "\\documentclass{report}[11pt]\n\n\\usepackage{amsmath} % provides numberwithin (and lots more)\n\\usepackage{graphicx}\n\\usepackage[backend=bibtex]{biblatex}\n\\usepackage{listings}\n\\usepackage{color}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{gray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mauve}{rgb}{0.58,0,0.82}\n\n\\lstset{frame=tb,\n  language=MATLAB,\n  aboveskip=3mm,\n  belowskip=3mm,\n  showstringspaces=false,\n  columns=flexible,\n  basicstyle={\\small\\ttfamily},\n  numbers=none,\n  numberstyle=\\tiny\\color{gray},\n  keywordstyle=\\color{blue},\n  commentstyle=\\color{dkgreen},\n  stringstyle=\\color{mauve},\n  breaklines=true,\n  breakatwhitespace=true,\n  tabsize=3\n}\n\n\\newcommand{\\code}[1]{\\texttt{#1}}\n\n\\newcommand{\\ds}{\\displaystyle}\n\n\\begin{document}\n\n\\begin{titlepage}\n\\begin{center}\n {\\huge\\bfseries MATLAB\\\\ Patterns and Practices\\\\}\n % ----------------------------------------------------------------\n \\vspace{1.5cm}\n {\\bfseries Pete Benson}\\\\[5pt]\n% pbenson@umich.edu\\\\[14pt]\n  % ----------------------------------------------------------------\n \\vspace{10cm}\n % ----------------------------------------------------------------\n\\includegraphics{QFRM_rgb}\\\\[5pt]\n{Department of Mathematics}\\\\[5pt]\n{530 Church Street}\\\\[5pt]\n{Ann Arbor, MI 48109-1043,\n USA}\\\\\n \\vfill\n\n\\end{center}\n\\end{titlepage}\n\n%----------------------\n% review\n%----------------------\n\\chapter{Patterns}\n\nEach pattern is in a subsection, and the name of the pattern is the name of the subsection.\n\n\\section{Repeating a task $n$ times}\nIf you know you need to repeat something a specific number of times, use the for loop:\n\n\\subsection{\\code{for} loop}\n\\begin{lstlisting}\n% for loop to sum numbers 1 to 5\nsum_ = 0;\nn = 5;\nfor iter = [1:n]\n    sum_ = sum_ + iter;\nend\nfprintf('sum_ of 1 to %d is %d\\n',n,sum_);\n\\end{lstlisting}\n\\pagebreak\n\n\\section{Repeating a task when you don't know in advance when you will be done}\nIn short, if you need a loop and a  \\code{for} loop won't work, use \\code{while}.\n\\subsection{\\code{while true} with \\code{break}}\nA commonly used approach is to use an infinite loop structure (\\code{while true}) with a \\code{break} statement to get out of the infinite loop.\n\\begin{lstlisting}\n% add integers until the sum is greater than 100\nsum_ = 0;\nn = 0;\nwhile true\n    n = n + 1;\n    sum_ = sum_ + n;\n    if sum_ > 100\n        break\n    end\nend\nfprintf('sum of 1 to %d is %d\\n',n,sum_);\n\\end{lstlisting}\n\n\\subsection{\\code{while <boolean expression>}}\nAlternatively, the \\code{while} can execute conditionally, as long as the provided boolean expression evaluates to \\code{true}.\n\\begin{lstlisting}\n% add integers until the sum is greater than 100\nsum_ = 0;\nn = 0;\nwhile sum_ < 100\n    n = n + 1;\n    sum_ = sum_ + n;\nend\nfprintf('sum of 1 to %d is %d\\n',n,sum_);\n\\end{lstlisting}\n\n\\pagebreak\n\\subsection{Validating user input}\nGetting correct input from the user is a perfect application of the  \\code{while true} with \\code{break} pattern.\n\\begin{lstlisting}\n% get user input between 1 and 100\nn = -1;\nwhile true\n    n = input('Enter a number from 1 to 100: ');\n    if n >=1 && n <=100\n        break\n    end\nend\nfprintf('n = %d\\n',n);\n\\end{lstlisting}\n\n\\section{\\code{if}, \\code{elseif}, \\code{else}, }\n\n\\subsection{\\code{if}}\nIf you want to do something only if some condition is met, and there is nothing special that needs to be done if the condition is not met, then you want the \\code{if} statement. \n\\begin{lstlisting}\n% get age, and warn user if they need adult approval\nage = input('Enter your age: ');\nif age < 18\n    fprintf('You will need adult approval.\\n',n);\nend\n\\end{lstlisting}\n\n\\subsection{\\code{if}-\\code{else}}\nIf you want to do a task if some condition is met, and you must do a different task if the condition is not met, use the \\code{if}-\\code{else} pattern.  Note that \\code{else} {\\em does not} have a boolean expression attached to it. \n\\begin{lstlisting}\n% get age, and assign one of two categories\nage = input('Enter your age: ');\nage_category = '';\nif age < 18\n    age_category = 'minor';\nelse\n    age_category = 'adult';\nend\nfprintf('For age = %d, category = %s\\n',age, age_category);\n\\end{lstlisting}\n\n\\subsection{\\code{if}-\\code{elseif}}\nIf you must do one task from several possible tasks, use the \\code{if}-\\code{elseif}. Note that \\code{elseif} {\\em does } have a boolean expression attached to it. \n\\begin{lstlisting}\n% get age, and assign one of more than two categories\nage = input('Enter your age: ');\nage_category = '';\nif age < 12\n    age_category = 'child';\nelseif age < 18\n    age_category = 'youth';\nelse \n    age_category = 'adult';\nend\nfprintf('For age = %d, category = %s\\n',age, age_category);\n\\end{lstlisting}\nAlso, note that the last case (the default case) used \\code{else} rather than \\code{elseif}. Usually, this is what your last case will do.\n\n\\chapter{Practices}\n\n\\section{Habits}\nA list of good habits:\n\\begin{enumerate}\n\t\\item{When you start writing a program, begin with comments describing (in sufficient detail) how your program will work. }\n\t\\item{Practice running your program in your head as you write. It may seem slow, but it is the fastest way to write working code. }\n\t\\item{Reformat your code frequently. This will help you detect missing end statements, and makes your code easier to understand.}\n\t\\item{When assigning value to a variable (e.g. \\code{x = ...}), end the line with a semi-colon, unless you are debugging the value of \\code{x}. This makes your output easier to read. }\n\t\\item{Typically, when using \\code{fprintf}, insert \\textbackslash n. E.g. \\code{fprintf('Hi  \\textbackslash n')}}. \n\\end{enumerate}\n\n\n\\end{document}\n", "meta": {"hexsha": "5c169ca97036d6e2983d13507219165d98368e41", "size": 5593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "files/matlab-patterns/matlab-patterns.tex", "max_stars_repo_name": "israeldi/friday-workshop", "max_stars_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "files/matlab-patterns/matlab-patterns.tex", "max_issues_repo_name": "israeldi/friday-workshop", "max_issues_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "files/matlab-patterns/matlab-patterns.tex", "max_forks_repo_name": "israeldi/friday-workshop", "max_forks_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.9005524862, "max_line_length": 232, "alphanum_fraction": 0.6770963705, "num_tokens": 1621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832058771036, "lm_q2_score": 0.8311430541321951, "lm_q1q2_score": 0.4479721478586576}}
{"text": "\\documentclass[fleqn]{article}\n\n\\usepackage[no-math]{fontspec}\n\\usepackage[OT1]{eulervm}\n\\usepackage{microtype,ifthen}\n\\usepackage{amsmath,amssymb,amsfonts,amsthm,braket,cancel}\n\\usepackage{titlesec}\n\\usepackage[usenames,dvipsnames]{xcolor}\n\\usepackage[style=numeric-comp,backend=biber,doi=false,isbn=false,url=false,date=year]{biblatex}\n\\usepackage{hyperref}\n\n% Fonts\n\\defaultfontfeatures{%\n    RawFeature={%\n        +calt   % *Contextual alternates\n        ,+clig  % *contextual ligatures\n        ,+ccmp  % *composition & decomposition\n        ,+tlig  % 'tex-ligatures': `` '' -- --- !` ?` << >>\n        ,+cv06  % narrow guillemets\n    }%\n}\n\\setmainfont{EB Garamond}\n\\newfontfamily{\\smallcaps}[RawFeature={+c2sc,+scmp}]{EB Garamond}\n\\newfontfamily{\\swash}[RawFeature={+swsh}]{EB Garamond}\n\n% Sections\n\\titleformat{\\section}{\\normalfont \\Large \\scshape}{\\thesection}{1em}{}\n\\titleformat{\\subsection}{\\normalfont \\large \\scshape}{\\thesubsection}{1em}{}\n\\titleformat{\\subsubsection}{\\normalfont \\scshape}{\\thesubsubsection}{0.5em}{}\n\\pagestyle{headings}\n\\renewcommand{\\thesection}{\\roman{section}}\n\\renewcommand{\\thesubsection}{\\thesection.\\roman{subsection}}\n\\renewcommand{\\thesubsubsection}{\\thesubsection.\\roman{subsubsection}}\n\n% Theorems\n\\newtheoremstyle{definition}{}{}{\\itshape}{\\parindent}{\\scshape}{.}{1em}{\\thmname{#1}\\thmnumber{ #2}:}\n\\newtheoremstyle{theorem}{}{}{}{\\parindent}{\\scshape}{}{1em}{\\thmname{#1}\\thmnumber{ #2}:}\n\\theoremstyle{theorem}\n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem{corollary}[lemma]{Corollary}\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}\n\n% Math operators\n\\DeclareMathOperator*{\\argmin}{argmin}\n\\DeclareMathOperator*{\\argmax}{argmax}\n\\DeclareMathOperator{\\logm}{Log}\n\\newcommand{\\norm}[2][]{\\left\\Vert#2\\right\\Vert_{#1}}\n\\newcommand{\\abs}[1]{\\left\\vert#1\\right\\vert}\n\\newcommand{\\SN}[2][]{\\mathcal{SN}_{#1}\\left(#2\\right)}\n\n% Metadata\n\\title{Skewnormal}\n\\newcommand{\\myName}{Jacopo Schiavon}\n\\newcommand{\\myMail}{\\href{mailto:jschiavon@stat.unipd.it}{\\ttfamily jschiavon@stat.unipd.it}}\n\\newcommand{\\myDept}{Department of Statistical Sciences, University of Padova}\n\\author{\\myName\\thanks{\\myDept. Contact: \\myMail}}\n\\hypersetup{pdfauthor={\\myName},\n    pdfcreator={\\myName},\n    breaklinks=True,\n    colorlinks=true,       \t% false: boxed links; true: colored links\n    linkcolor=MidnightBlue, % color of internal links\n    citecolor=ForestGreen,\t% color of links to bibliography\n    filecolor=Plum,\t\t\t% color of file links\n    urlcolor=Sepia\t\t\t% color of url link\n}\n\n% Bibliography\n\\setlength\\bibitemsep{1.5\\itemsep}\n\\setlength\\bibhang{1.5\\parindent}\n\\renewcommand*{\\mkbibnamefamily}[1]{\\textsc{#1}}\n\\renewcommand*{\\mkbibnamegiven}[1]{\\textsc{#1}}\n\\renewcommand*{\\mkbibnameprefix}[1]{\\textsc{#1}}\n\\renewcommand*{\\mkbibnamesuffix}[1]{\\textsc{#1}}\n\\renewcommand*{\\labelnamepunct}{\\par}\n\\addbibresource{biblio.bib}\n\n\\setlength{\\parindent}{0pt}\n\n\\begin{document}\n    \\maketitle\n\n    \\section{Parametrization}\n    Let $y\\in\\mathbb{R}^d$, we say that $y\\sim\\SN[d]{\\xi, \\bar\\Sigma, \\delta}$ if\n    \\begin{equation}\\label{eq:first}\n        p(y\\mid \\xi, \\bar\\Sigma, \\delta) = \\int_0^\\infty 2\\phi_{d+1}\\left(\\left[y^\\top, z\\right]^\\top\\mid \\mu, \\Omega\\right)dz\n    \\end{equation}\n    with $\\mu=\\left[\\xi^\\top, 0\\right]^\\top$ and $\\Omega=\\begin{pmatrix}\n        \\omega\\Sigma\\omega  &   \\omega\\delta\\\\\n        \\delta^\\top\\omega   &   1\n    \\end{pmatrix}$ and $\\bar\\Sigma = \\omega\\Sigma\\omega$ is the decomposition of the covariance matrix in correlation matrix and the diagonal matrix with variances.\n\n    By defining $\\theta= \\omega\\delta$ and $\\Psi = \\bar\\Sigma - \\theta\\theta^\\top$, we can rewrite the previous density as\n    \\begin{equation}\\label{eq:second}\n        p(y\\mid \\xi, \\bar\\Sigma, \\delta) \\propto \\int_0^\\infty 2\\phi_1(z)\\phi_d\\!\\left(y\\mid \\xi+\\theta z, \\Psi\\right)dz.\n    \\end{equation}\n    Note that $\\abs{\\Omega} = \\abs{\\omega\\Sigma\\omega - \\omega\\delta\\delta^\\top\\omega} = \\abs{\\omega\\left(\\Sigma-\\delta\\delta^\\top\\right)\\omega} = \\abs{\\Psi}$ and\n    \\begin{equation*}\n        \\Omega^{-1} = \\begin{pmatrix}\n            \\Psi^{-1}   &   -\\Psi^{-1}\\theta\\\\\n            - \\theta^\\top\\Psi^{-1}  &   1 + \\theta^\\top\\Psi^{-1}\\theta\n        \\end{pmatrix}\n    \\end{equation*}\n\n    Moreover, by rearranging the terms from equation~\\eqref{eq:second} we can write:\n    \\begin{align*}\n        p(y\\mid \\xi, \\bar\\Sigma, \\delta) &\\propto \\int_0^\\infty 2\\phi_1(z\\mid\\bar\\mu,\\bar\\sigma^2) \\phi_d\\!\\left(y\\mid \\xi, \\Psi\\right) \\exp\\left[\\frac{\\bar\\mu^2}{2\\bar\\sigma^2}\\right]dz\\\\\n        &= \\phi_d\\!\\left(y\\mid \\xi, \\Psi\\right) \\exp\\left[\\frac{\\bar\\mu^2}{2\\bar\\sigma^2}\\right] 2 \\int_{-\\bar\\mu/\\bar\\sigma}^\\infty\\phi_1(z)dz\\\\\n        &= 2\\phi_d\\!\\left(y\\mid \\xi, \\Psi\\right) \\exp\\left[\\frac{\\bar\\mu^2}{2\\bar\\sigma^2}\\right]\\Phi_1\\!\\left(\\frac{\\bar\\mu}{\\bar\\sigma}\\right)\\\\\n        &= 2\\phi_d\\!\\left(y\\mid \\xi, \\Psi\\right) \\exp\\left[\\frac{1}{2}(y-\\xi)^\\top\\alpha\\alpha^\\top(y-\\xi)\\right]\\Phi_1\\!\\left(\\alpha^\\top(y-\\xi)\\right)\\\\\n        &= 2\\phi_d\\!\\left(y\\mid \\xi, \\Psi - \\alpha\\alpha^\\top\\right) \\Phi_1\\!\\left(\\alpha^\\top(y-\\xi)\\right)\n    \\end{align*}\n    where we have used\n    \\begin{align*}\n        \\bar\\mu &= \\frac{(y-\\xi)^\\top\\Psi^{-1}\\theta}{1 + \\theta^\\top\\Psi^{-1}\\theta}        &       \\bar\\sigma^2 &= \\left(1 + \\theta^\\top\\Psi^{-1}\\theta\\right)^{-1}\n    \\end{align*}\n    and we defined\n    \\begin{equation*}\n        \\alpha = \\frac{\\Psi^{-1}\\theta}{\\sqrt{1 + \\theta^\\top\\Psi^{-1}\\theta}}\n    \\end{equation*}\n\n    \\section{Constraints}\n    In order for $\\Psi$ (and thus $\\Omega$) to be positive definite, a constrain should be put on $\\delta$ and $\\bar\\Sigma$.  First of all, recall that the matrix $\\theta\\theta^\\top$ has only one strictly positive eigenvalue, equal to $\\norm{\\theta}^2$, while all the others are 0. As it can be proven that $\\Psi$ is SPD if and only if the smallest eigenvalue of $\\bar\\Sigma$ is larger than $\\norm{\\theta}^2$, we can require that\n    \\begin{equation*}\n        \\norm{\\theta}^2 = \\delta^\\top\\omega\\omega\\delta \\leq \\min_i\\lambda_i(\\bar\\Sigma)\n    \\end{equation*}\n\n\n\n    \\section{Data generation mechanism}\n    To generate samples from a skewnormal we exploit equation~\\eqref{eq:first} and we proceed in the following way:\n    \\begin{itemize}\n        \\item We compute $\\mu$ and $\\Omega$ from the parameters $\\xi$, $\\bar\\Sigma$ and $\\delta$\n        \\item We generate a sample from a $(d+1)$-variate normal distribution: $Z \\sim \\mathcal{N}_{d+1}(\\mu,\\Omega)$\n        \\item if $Z[d+1] \\geq 0$ then $y = Z[:d]$, else $y = - Z[:d]$.\n    \\end{itemize}\n\n\n\n    \\printbibliography\n\n\n\n\\end{document}", "meta": {"hexsha": "57aada87b7513b5303b2a7f87907b2f4197c5808", "size": 6583, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/skewnormal.tex", "max_stars_repo_name": "jschiavon/optispd", "max_stars_repo_head_hexsha": "fb3f904a1f1099d31cbcaf27dfc63e5a9e77c9f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/skewnormal.tex", "max_issues_repo_name": "jschiavon/optispd", "max_issues_repo_head_hexsha": "fb3f904a1f1099d31cbcaf27dfc63e5a9e77c9f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/skewnormal.tex", "max_forks_repo_name": "jschiavon/optispd", "max_forks_repo_head_hexsha": "fb3f904a1f1099d31cbcaf27dfc63e5a9e77c9f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.7152777778, "max_line_length": 429, "alphanum_fraction": 0.6633753608, "num_tokens": 2306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.447944268327366}}
{"text": "\\chapter{The Combined Filtering Method}\n% \\section{The Combined Filtering Method}\n\\section{Introduction}\n\\label{sect_comb}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_resi_lena_f24.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n\\psfig{figure=fig_resi_lena_cur.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n}}\n\\caption{Residual for thresholding of the undecimated\nwavelet transform and thresholding of \nthe curvelet transform.}\n\\label{fig_lenna_resi}\n\\end{figure}\n\nAlthough the results obtained by simply thresholding the curvelet expansion\nare encouraging, there is of course ample room for further\nimprovement. A quick inspection of the residual images for both the\nwavelet and curvelet transforms shown in Figure~\\ref{fig_lenna_resi}\nreveals the existence of very different features.  For instance,\nwavelets do not restore long edges with high fidelity while curvelets\nare seriously challenged by small features such as {\\tt Lena}'s eyes. Loosely\nspeaking, each transform has its own area of expertise and this\ncomplementarity may be of great potential. This section will develop a\ndenoising strategy based on the idea of combining both transforms.\n\nIn general, suppose that we are given $K$ linear transforms $T_1,\n\\ldots, T_K$ and let $\\alpha_k$ be the coefficient sequence of an\nobject $x$ after applying the transform $T_k$, i.e. $\\alpha_k = T_k\nx$. We will suppose that for each transform $T_k$ we have available a\nreconstruction rule that we will denote by $T^{-1}_k$ although this is\nclearly an abuse of notation.  Finally, $T$ will denote the block\ndiagonal matrix with the $T_k$'s as building blocks and $\\alpha$ the\namalgamation of the $\\alpha_k$'s.\n\nA hard thresholding rule associated with the transform $T_k$ synthesizes \nan estimate $\\tilde{s}_k$ via the formula \n\\begin{equation}\n\\label{eq:ht}\n\\tilde{s}_k = T_k^{-1} \\delta(\\alpha_k)\n\\end{equation}\nwhere $\\delta$ is a rule that sets to zero all the coordinates of\n$\\alpha_k$ whose absolute value falls below a given sequence of\nthresholds (such coordinates are said to be non-significant).\n\nIn practice, a widely used approach is to compute the average of the\n$\\tilde{s}_k$'s giving a reconstruction of the form\n \\begin{equation}\n\\tilde{s} = \\sum_k \\tilde{s}_k/K. \n\\end{equation}\nFor instance, in the literature of image processing it is common to\naverage reconstructions obtained after thresholding the wavelet\ncoefficients of translated versions of the original dataset\n(cycle-spinning), i.e. the $T_k$'s are obtained by composing\ntranslations and the wavelet transform.  In our setup, we do not find\nthis solution very appealing since this creates the opportunity to\naverage high-quality and low-quality reconstructions.\n\n\\section{The Combined Filtering Principle}\n\nGiven data $y$ of the form $y = s + \\sigma z$, where $s$ is the image\nwe wish to recover and $z$ is standard white noise, we propose solving\nthe following optimization problem \\cite{starck:spie01a}:\n\\begin{equation}\n  \\label{eq:l1-min}\n  \\min \\|T\\tilde{s}\\|_{\\ell_1}, \\quad \\mbox{subject to} \\quad s \\in C,  \n\\end{equation}\nwhere $C$ is the set of vectors $\\tilde{s}$ \nwhich obey the linear constraints\n\\begin{equation}\n\\label{eq:constraints}\n\\left\\{  \\begin{array}{ll}\n  \\tilde{s} \\ge 0, \\\\\n  |T\\tilde{s} - Ty| \\le e; \n  \\end{array}\n  \\right. \n\\end{equation}\nhere, the second inequality constraint \nonly concerns the set of significant coefficients, \ni.e. those indices $\\mu$ such that $\\alpha_\\mu =\n(Ty)_\\mu$ exceeds (in absolute value) a threshold $t_\\mu$. Given a\nvector of tolerance $(e_\\mu)$, we seek a solution whose coefficients\n  $(T\\tilde{s})_\\mu$ are within $e_\\mu$ of the noisy\nempirical $\\alpha_\\mu$'s.  Think of $\\alpha_\\mu$ as being given by\n\\[\ny = \\langle y, \\varphi_\\mu \\rangle, \n\\]\nso that $\\alpha_\\mu$ is normally distributed with mean $\\langle f,\n\\varphi_\\mu \\rangle$ and variance $\\sigma^2_\\mu = \\sigma^2\n\\|\\varphi_\\mu\\|^2_2$. In practice, the threshold values range\ntypically between three and four times the noise level $\\sigma_\\mu$\nand in our experiments we will put $e_\\mu = \\sigma_\\mu/2$. In short,\nour constraints guarantee that the reconstruction will take into\naccount any pattern which is detected as significant by  any of the\n$K$ transforms.\n   \nWe use an $\\ell_1$ penalty on the coefficient sequence because we are\ninterested in {\\em low complexity} reconstructions. There are other\npossible choices of complexity penalties; for instance, an alternative\nto (\\ref{eq:l1-min}) would be\n\\[\n\\label{eq:tv-min}\n  \\min \\|\\tilde{s}\\|_{TV}, \\quad \\mbox{subject to} \\quad s \\in C. \n\\]\nwhere $\\|\\cdot\\|_{TV}$ is the Total Variation norm, i.e.\\ the discrete\nequivalent of the integral of the Euclidean norm of the gradient.\n\n\\section{The Minimization Method}\n\nWe propose solving (\\ref{eq:l1-min}) using the method of hybrid\nsteepest descent (HSD) \\cite{wave:yamada01}. HSD consists of building\nthe sequence\n\\begin{eqnarray}\n s^{n+1} = P(s^{n}) - \\lambda_{n+1} \\nabla_J(P(s^{n})); \n\\end{eqnarray}\nHere, $P$ is the $\\ell_2$ projection operator onto the feasible set\n$C$, $\\nabla_J$ is the gradient of equation~\\ref{eq:l1-min}, and\n$(\\lambda_{n})_{n \\ge 1}$ is a sequence obeying $(\\lambda_{n})_{n\\ge\n  1} \\in [0,1] $ and $\\lim_{ n \\rightarrow + \\infty } \\lambda_{n} = 0$.\n\nUnfortunately, the projection operator $P$ is not easily determined\nand in practice we will use the following proxy; compute $T \\tilde{s}$\nand replace those coefficients which do not obey the constraints $|T\n\\tilde{s} - Ty| \\le e$ (those which fall outside of the prescribed\ninterval) by those of $y$; apply the inverse transform.  \n\n% {\\tt Needs work.} Then apply thresholding. This approximation gives\nThe combined filtering algorithm is:\n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item Initialize $L_{\\max} = 1$, the number of iterations $N_i$, and\n  $\\delta_{\\lambda} = \\frac{L_{\\max}}{N_i}$.\n\\item Estimate the noise standard deviation $\\sigma$, and set $e_k =\n  {\\sigma \\over 2}$.\n\\item For k = 1, .., $K$ calculate the transform: $\\alpha^{(s)}_k\n  = T_k s$.\n\\item Set $\\lambda = L_{\\max}$, $n = 0$, and $\\tilde s^{n}$ to 0.\n\\item While $\\lambda >= 0$ do\n\\begin{itemize}\n\\item $u = \\tilde s^{n}$.\n\\item For k = 1, .., $K$ do\n  \\begin{itemize}\n  \\item Calculate the transform $\\alpha_{k} = T_k u$.\n  \\item For all coefficients $\\alpha_{k,l}$ do\n     \\begin{itemize}\n     \\item Calculate the residual $r_{k,l} = \\alpha^{(s)}_{k,l} -\n       \\alpha_{k,l}$\n       \n     \\item if $\\alpha^{(s)}_{k,l}$ is significant and $ \\mid r_{k,l}\n       \\mid > e_{k,l}$ then $\\alpha_{k,l} = \\alpha^{(s)}_{k,l}$\n     \\item $\\alpha_{k,l} = sgn(\\alpha_{k,l}) ( \\mid \\alpha_{k,l} \\mid - \\lambda)_{+}$.\n     \\end{itemize}\n   \\item $u = T_k^{-1} \\alpha_{k}$\n  \\end{itemize}\n\\item Threshold negative values in $u$ and $\\tilde s^{n+1} = u$.\n\\item $n = n + 1$, $\\lambda = \\lambda - \\delta_{\\lambda} $, and goto 5.\n\\end{itemize}\n\\end{enumerate}\n\n\\section{Experiments}\n\n\\voffset -1truecm\n\\begin{table}[htb]\n\\begin{center}\n\\begin{tabular}{lccccc} \\hline \\hline\nMethod                          & PSNR   &  Comments   \\\\ \\hline \\hline\nNoisy image                     & 22.13  &     \\\\\nOWT7-9 + k-sigma  Hard thresh.   & 28.35  &   many artifacts \\\\\nUWT7-9 + k-sigma  Hard thresh.   & 31.94  &   very few artifacts \\\\\nCurvelet (B=16)                 & 31.95  &   no artifact  \\\\ \nCombined filtering              & 32.72  &   no artifact  \\\\ \\hline \\hline\n\\end{tabular}\n\\caption{PSNR after filtering the simulated image (Lena + Gaussian \nnoise, sigma=20).\nIn the combined filtering, a curvelet and an undecimated wavelet\ntransform were used.}\n\\vspace{0.5cm}\n\\label{comptab2}\n\\end{center}\n\\end{table}\n\nThe noisy {\\tt Lena} image (the noise standard deviation being equal 20)\nwas filtered by the undecimated\nwavelet transform, the curvelet transform, and by our combined\ntransform approach (curvelet and undecimated wavelet transforms). The\nresults are reported in Table~\\ref{comptab2}.\nFigure~\\ref{fig_cb2_lenna} displays the noisy image (top left), and\nthe restored image after denoising by the combined transforms (bottom right). \nDetails are\ndisplayed in Figure~\\ref{fig_cb2_lenna} bottom left.  \nFigure~\\ref{fig_cb2_lenna}  bottom  right shows the full residual image, and \ncan be compared  to the residual images shown in Figure~\\ref{fig_lenna_resi}.\nThe residual is much better when the combined filtering is applied, and no\nfeature can be detected any more by eye. This was not the case for either the\nwavelet and the curvelet filtering.\n\n\\begin{figure}[htb]\n\\centerline{ \n\\vbox{ \n\\hbox{\n \\psfig{figure=fig_lena_g20.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n \\psfig{figure=fig_lenna_cfil_wt_cur.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n }\n\\hbox{\n\\psfig{figure=fig_lena_cfil_rid_cur_x185_y342_sub.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n\\psfig{figure=fig_resi_cfil_wt_cur.ps,bbllx=2cm,bblly=13.5cm,bburx=13cm,bbury=24.5cm,width=7.5cm,height=7.5cm,clip=}\n}\t\n}}\n\\caption{Noisy image (top left), and filtered image based on the\n  combined transform (top right). Bottom left panel shows a detail \n  of the filtered image. The full residual image is displayed on the bottom right.}\n\\label{fig_cb2_lenna}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_ctm_iter.ps,bbllx=2.5cm,bblly=13.cm,bburx=19.5cm,bbury=25cm,width=10cm,height=7cm,clip=}\n}}\n\\caption{PSNR versus the number of iterations.}\n\\label{fig_iter_cvg}\n\\end{figure}\n\nFigure~\\ref{fig_iter_cvg} displays the PSNR of the solution versus the\nnumber of iterations. In this example, the algorithm is shown to\nconverge rapidly. From a practical viewpoint only four or five\niterations are truly needed.  Note that the result obtained after a\nsingle iteration is already superior to those available using\nmethods based on the thresholding of wavelet or curvelet coefficients\nalone.\n\n\\begin{table*}[htb]\n\\begin{center}\n\\begin{tabular}{lcc} \\hline \\hline\nMethod                         & PSNR   & PSNR  \\\\ \n                               & (coeff. $l_1$ norm minim.) & (TV minim.) \\\\ \\hline \\hline\n Undecimated wavelet only      & 32.00   &  32.43 \\\\\n Curvelet only                 & 32.03   &  32.40 \\\\ \n Wavelet + curvelet            & 32.72   &  32.77 \\\\ \n (Combined filtering)          &         &   \\\\ \\hline \\hline\n\\end{tabular}\n\\caption{PSNR after filtering the simulated image \n(Lena + Gaussian noise, sigma=20).\nIn the combined filtering, a curvelet and an undecimated wavelet\ntransform have been used.}\n\\vspace{0.5cm}\n\\label{cur_comptab3}\n\\end{center}\n\\end{table*}\n\nSeveral papers have been recently published, based on the concept\nof minimizing the total variation under constraints in the \nwavelet domain \\cite{rest:froment01,rest:froment02a,rest:malgouyres02} or in \nthe curvelet domain \\cite{rest:candes02}. Our combined approach\ncan be seen as a generalization of these methods.\nWe carried out a set of experiments in order to estimate (i) if the\ntotal variation is better than the $l_1$ norm of the multiscale\ncoefficients, and (ii) if the combined approach improves the \nresults compared to a single transform based method.\n\nIn our example, Gaussian noise with a standard deviation equal\nto 20 was added to the classical {\\tt Lena} image (512 by 512).\nSeveral methods were used to filter the noisy image:\n\\begin{enumerate}\n\\item TV + constraint in the wavelet domain.\n\\item TV + constraint in the curvelet domain.\n\\item Wavelet $l_1$ norm minimization + wavelet constraints.\n\\item Curvelet $l_1$ norm minimization + curvelet constraints.\n\\item Combined filtering method using multiscale coefficient $l_1$ \nnorm minimization.\n\\item Combined filtering method using TV minimization.\n\\end{enumerate}\nWe use the PSNR as an ``objective'' measure of performance.  \nThe noisy image PSNR is $22.13$. \nPSNR results from the different tested methods \nare reported in Table~\\ref{cur_comptab3}.\n\nWe observe that combined filtering leads to a significant improvement\nwhen compared to a single transform based method. \nThe TV penalization gives better results when a single transform is used,\nwhile it \nseems not to have too much importance for the combined filtering approach.\nWe will see in the following that the latter\nis not true for the deconvolution problem.\n\n% \\clearpage\n\\section{Discussion}\nWe believe that the denoising experiments presented in this paper are\nof very high quality: \n\\begin{enumerate}\n\\item Combined filtering leads to a real\nimprovement both in terms of PSNR and visual appearance. \n\\item The combined approach arguably challenges the eye to distinguish\n  structure/features from residual images of real image data (at least\n  for the range of noise levels that was considered here). Single\n  transforms cannot manage such a feat.  \n\\end{enumerate}\nWe also note that the combined reconstruction may tend to be free of\nmajor artifacts which is very much unlike typical thresholding rules.\nAlthough the ease of implementation is clear we did not address the\ncomputational issues associated with our method. In a nutshell, the\nalgorithms we described require calculating each transform and its\ninverse only a limited  number of times. \n\nIn our examples, we constructed a combined transform from linear\ntransforms (wavelets, ridgelets and curvelets) but our paradigm\nextends to any kind of nonlinear transform such as the Pyramidal\nMedian Transform \\cite{starck:book98} or morphological multiscale\ntransforms \\cite{wave:goutsias99b}.\n\n\n\\clearpage\n\\newpage\n\n\n", "meta": {"hexsha": "ae9b68f371f62c101f1be7880c412f86123d548d", "size": 13586, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr4/ch_combfilter.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr4/ch_combfilter.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr4/ch_combfilter.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.5893416928, "max_line_length": 131, "alphanum_fraction": 0.7353893714, "num_tokens": 3984, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.4479442481400989}}
{"text": "%Suggested order of slides\n% slides-regu-intro\n% slides-regu-l1l2\n% slides-regu-l1vsl2\n% slides-regu-enetlogreg\n% slides-regu-underdetermined\n% slides-regu-l0\n% slides-regu-nonlin-bayes\n% slides-regu-geom-l2-wdecay\n% slides-regu-geom-l1\n% slides-regu-early-stopping\n\n\n\\subsection{Introduction to Regularization}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-intro.pdf}\n\n\\subsection{Lasso and Ridge Regression}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-l1l2.pdf}\n\n\\subsection{Lasso vs. Ridge Regression}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-l1vsl2.pdf}\n\n\\subsection{Elastic Net and Regularization for GLMs}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-enetlogreg.pdf}\n\n\\subsection{Regularization for Underdetermined Problem}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-underdetermined.pdf}\n\n\\subsection{L0 Regularization}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-l0.pdf}\n\n\\subsection{Nonlinear and Bayes}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-nonlin-bayes.pdf}\n\n\\subsection{Geometric Analysis of L2-Regularization and Weight Decay}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-geom-l2-wdecay.pdf}\n\n\\subsection{Geometric Analysis of L1-regularization}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-geom-l1.pdf}\n\n\\subsection{Early Stopping}\n\\includepdf[pages=-]{../slides-pdf/slides-regu-early-stopping.pdf}\n\n\n\n\n\n", "meta": {"hexsha": "8d727bd9c2a53a9d6f20454e0204bcd437e50adb", "size": 1349, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/regularization/chapter-order.tex", "max_stars_repo_name": "jukaje/lecture_i2ml", "max_stars_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 93, "max_stars_repo_stars_event_min_datetime": "2019-02-27T17:20:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T12:05:52.000Z", "max_issues_repo_path": "slides/regularization/chapter-order.tex", "max_issues_repo_name": "jukaje/lecture_i2ml", "max_issues_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2019-02-27T08:02:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T08:11:41.000Z", "max_forks_repo_path": "slides/regularization/chapter-order.tex", "max_forks_repo_name": "jukaje/lecture_i2ml", "max_forks_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 56, "max_forks_repo_forks_event_min_datetime": "2019-02-27T16:25:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-08T05:53:20.000Z", "avg_line_length": 28.1041666667, "max_line_length": 69, "alphanum_fraction": 0.7679762787, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752916, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.4479442469479662}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Copyright (c) 2003-2018 by The University of Queensland\n% http://www.uq.edu.au\n%\n% Primary Business: Queensland, Australia\n% Licensed under the Apache License, version 2.0\n% http://www.apache.org/licenses/LICENSE-2.0\n%\n% Development until 2012 by Earth Systems Science Computational Center (ESSCC)\n% Development 2012-2013 by School of Earth Sciences\n% Development from 2014 by Centre for Geoscience Computing (GeoComp)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Example 2: One Dimensional Heat Diffusion in an Iron Rod}\n\\sslist{example02.py}\n\\label{Sec:1DHDv0}\n\nOur second example is of a cold iron bar at a constant temperature of\n$T_{ref}=20^{\\circ} C$, see \\reffig{fig:onedhdmodel}. The bar is\nperfectly insulated on all sides with a heating element at one end keeping the\ntemperature at a constant level $T_0=100^{\\circ} C$.  As heat is\napplied energy will disperse along the bar via conduction. With time the bar\nwill reach a constant temperature equivalent to that of the heat source.\n\n\\begin{figure}[ht]\n\\centerline{\\includegraphics[width=4.in]{figures/onedheatdiff002}}\n\\caption{Example 2: One dimensional model of an Iron bar}\n\\label{fig:onedhdmodel}\n\\end{figure}\n\nThis problem is very similar to the example of temperature diffusion in granite\nblocks presented in the previous Section~\\ref{Sec:1DHDv00}. Thus, it is possible\nto modify the script we have already developed for the granite blocks to suit\nthe iron bar problem.  \nThe obvious differences between the two problems are the dimensions of the\ndomain and different materials involved. This will change the time scale of the\nmodel from years to hours. The new settings are\n\\begin{python}\n#Domain related.\nmx = 1*m #meters - model length\nmy = .1*m #meters - model width\nndx = 100 # mesh steps in x direction \nndy = 1 # mesh steps in y direction - one dimension means one element\n#PDE related\nrho = 7874. *kg/m**3 #kg/m^{3} density of iron\ncp = 449.*J/(kg*K) # J/Kg.K thermal capacity\nrhocp = rho*cp \nkappa = 80.*W/m/K   # watts/m.Kthermal conductivity\nqH = 0 * J/(sec*m**3) # J/(sec.m^{3}) no heat source\nTref = 20 * Celsius  # base temperature of the rod\nT0 = 100 * Celsius # temperature at heating element\ntend= 0.5 * day # - time to end simulation\n\\end{python}\nWe also need to alter the initial value for the temperature. Now we need to set\nthe temperature to $T_{0}$ at the left end of the rod where we have\n$x_{0}=0$ and \n$T_{ref}$ elsewhere. Instead of \\verb|whereNegative| function we now\nuse \\verb|whereZero| which returns the value one for those sample points where\nthe argument (almost) equals zero and the value zero elsewhere. The initial\ntemperature is set to\n\\begin{python}\n# ... set initial temperature ....\nT= T0*whereZero(x[0])+Tref*(1-whereZero(x[0]))\n\\end{python}\n\n\\subsection{Dirichlet Boundary Conditions}\nIn the iron rod model we want to keep the initial temperature $T_0$ on\nthe left side of the domain constant with time. \nThis implies that when we solve the PDE~\\refEq{eqn:hddisc}, the solution must\nhave the value $T_0$ on the left hand side of the domain. As mentioned\nalready in Section~\\ref{SEC BOUNDARY COND} where we discussed boundary\nconditions, this kind of scenario can be expressed using a\n\\textbf{Dirichlet boundary condition}. Some people also use the term\n\\textbf{constraint} for the PDE. \n\nTo define a Dirichlet boundary condition we need to specify where to apply the\ncondition and determine what value the\nsolution should have at these locations. In \\esc we use $q$ and $r$ to define\nthe Dirichlet boundary conditions for a PDE. The solution $u$ of the PDE is set\nto $r$ for all sample points where $q$ has a positive value.\nMathematically this is expressed in the form;\n\\begin{equation}\n  u(x) = r(x) \\mbox{ for any } x \\mbox{ with } q(x) > 0\n\\end{equation} \nIn the case of the iron rod we can set\n\\begin{python}\nq=whereZero(x[0])\nr=T0\n\\end{python}\nto prescribe the value $T_{0}$ for the temperature at the left end of\nthe rod where $x_{0}=0$.\nHere we use the \\verb|whereZero| function again which we have already used to\nset the initial value.\nNotice that $r$ is set to the constant value $T_{0}$ for all sample\npoints. In fact, values of $r$ are used only where $q$ is positive. Where $q$\nis non-positive, $r$ may have any value as these values are not used by the PDE\nsolver. \n\nTo set the Dirichlet boundary conditions for the PDE to be solved in each time\nstep we need to add some statements;\n\\begin{python}\nmypde=LinearPDE(rod)\nA=zeros((2,2)))\nA[0,0]=kappa\nq=whereZero(x[0])\nmypde.setValue(A=A, D=rhocp/h, q=q, r=T0)\n\\end{python}\nIt is important to remark here that if a Dirichlet boundary condition is\nprescribed on the same location as any Neumann boundary condition, the Neumann\nboundary condition will be \\textbf{overwritten}. This applies to Neumann\nboundary conditions that \\esc sets by default and those defined by the user.\n\nBesides some cosmetic modification this is all we need to change. The total\nenergy over time is shown in \\reffig{fig:onedheatout1 002}. As heat\nis transferred into the rod by the heater the total energy is growing over time\nbut reaches a plateau when the temperature is constant in the rod, see\n\\reffig{fig:onedheatout 002}.\nYou will notice that the time scale of this model is several order of\nmagnitudes faster than for the granite rock problem due to the different length\nscale and material parameters. \nIn practice it can take a few model runs before the right time scale has been\nchosen\\footnote{An estimate of the\ntime scale for a diffusion problem is given by the formula $\\frac{\\rho\nc_{p} L_{0}^2}{4 \\kappa}$, see\n\\url{http://en.wikipedia.org/wiki/Fick\\%27s_laws_of_diffusion}}.\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[width=4in]{figures/ttrodpyplot150}\n\\caption{Example 2: Total Energy in the Iron Rod over Time (in seconds)}\n\\label{fig:onedheatout1 002} \n\\end{center}\n\\end{figure}\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[width=4in]{figures/rodpyplot001}\n\\includegraphics[width=4in]{figures/rodpyplot050}\n\\includegraphics[width=4in]{figures/rodpyplot200}\n\\caption{Example 2: Temperature ($T$) distribution in the iron rod at time steps\n$1$, $50$ and $200$}\n\\label{fig:onedheatout 002} \n\\end{center}\n\\end{figure}\n\n\\section{For the Reader}\n\\begin{enumerate}\n \\item Move the boundary line between the two granite blocks to another part of\nthe domain.\n \\item Split the domain into multiple granite blocks with varying temperatures.\n \\item Vary the mesh step size. Do you see a difference in the answers? What\ndoes happen with the compute time?\n \\item Insert an internal heat source (Hint: The internal heat source is given\nby $q_{H}$.)\n \\item Change the boundary condition for the iron rod example such that the\ntemperature \n at the right end is kept at a constant level $T_{ref}$, which\ncorresponds to the installation of a cooling element (Hint: Modify $q$ and\n$r$). \n\\end{enumerate}\n\n", "meta": {"hexsha": "1998eb987809bd05ca65071d4476f8117af52f03", "size": 6993, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/cookbook/example02.tex", "max_stars_repo_name": "markendr/esys-escript.github.io", "max_stars_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/cookbook/example02.tex", "max_issues_repo_name": "markendr/esys-escript.github.io", "max_issues_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-14T03:07:43.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T03:07:43.000Z", "max_forks_repo_path": "doc/cookbook/example02.tex", "max_forks_repo_name": "markendr/esys-escript.github.io", "max_forks_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6402439024, "max_line_length": 80, "alphanum_fraction": 0.7437437437, "num_tokens": 1903, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.607663184043154, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.4479438727374694}}
{"text": "\\documentclass[../PHYS306Notes.tex]{subfiles}\n\n\\begin{document}\n\\subsection{Worksheet - Intro to Coupled Oscillators}\n\\begin{p}\nGive some examples of coupled oscillators.\n\\end{p}\n\\begin{s}\n\\phantom{i}\n\\begin{itemize}\n    \\item Masses coupled together by springs\n    \\item A crystal lattice, which can be approximated as atoms being connected by springs in a lattice structure\n    \\item Molecules (e.g. CO2) which we can treat as a carbon atom connected linearly to two oxygen atoms.\n\\end{itemize}\n\\end{s}\n\n\\begin{center}\n    \\includegraphics[scale=0.5]{Lecture-10/w10-img1.png}\n\\end{center}\n\\begin{p}\nFind the Lagrangian for the two coupled oscillators(two masses connected by springs). Find the equations of motion.\n\\end{p}\n\\begin{s}\nThe Lagrangian is given by:\n\\[\\LL = T - U = \\frac{m}{2}\\left(\\dot{x}^2_1 + \\dot{x}^2_2\\right) - \\left[\\frac{k}{2}x_1^2 + \\frac{k_{12}}{2}(x_1 - x_2)^2 + \\frac{k}{2}x_2^2\\right]\\]\nTo obtain the equations of motion, we use the EL equations:\n\\[\\dod{}{t}\\dpd{\\LL}{\\dot{x}_1} = m\\ddot{x}_1 = \\dpd{\\LL}{x_1} = -kx_1 - k_{12}x_1 + k_{12}x_2\\]\n\\[\\dod{}{t}\\dpd{\\LL}{\\dot{x}_2} = m\\ddot{x}_2 = \\dpd{\\LL}{x_2} = -kx_2 - k_{12}x_2 + k_{12}x_1\\]\nWhich agrees with our analysis using the Newtonian formulation. This is clearly a coupled system of ODEs. To start solving this, we start by writing this in a nicer form, defining a column vector $\\v{x} = \\m{x_1 \\\\ x_2}$. This transforms things into a matrix equation:\n$$\\left(\\begin{array}{cc}m & 0 \\\\ 0 & m\\end{array}\\right)\\left(\\begin{array}{c}\\ddot{x}_{1} \\\\ \\ddot{x}_{2}\\end{array}\\right)=-\\left(\\begin{array}{cc}k+k_{12} & -k_{12} \\\\ -k_{12} & k+k_{12}\\end{array}\\right)\\left(\\begin{array}{c}x_{1} \\\\ x_{2}\\end{array}\\right)$$\nWhich we can write as:\n\\[\\MM\\ddot{\\v{x}} = -\\KK\\v{x}\\]\n\\end{s}\n\n\\begin{p}\nUsing the complex quantity $\\v{z} = \\v{a}\\exp(i\\omega t)$, show that the equation for the normal modes can be written as $(\\KK - \\omega\\MM)\\v{a} = 0$.\n\\end{p}\n\\begin{s}\nWe define the complex quantity $\\v{z}$ as above (such that $\\v{x} = \\Re\\v{z}$, and then we have:\n\\[\\MM\\ddot{\\v{z}} = \\MM\\v{a}(-\\omega^2)\\exp(i\\omega t) = -\\KK\\v{a}\\exp(i\\omega t)\\]\nThen cancelling out the exponentials, we have:\n\\[\\KK\\v{a} = \\MM\\omega^2\\v{a}\\]\nRearranging, we have:\n\\[(\\KK - \\omega^2\\MM)\\v{a} = 0\\]\nThis is an \\textbf{eigenvalue problem}, which we are familiar with from linear algebra. We note that here, $\\MM$ is just an identity matrix multiplied by $m$.\n\\end{s}\n\n\\begin{p}\nWrite out the characteristic equation. What are the roots? (i.e. the eigenfrequencies).\n\\end{p}\n\\begin{s}\nTo solve this eigenvalue problem (i.e. for the system to have nontrivial solutions) we require that $\\det(\\KK - \\omega^2\\MM) = 0$. This is a polynomial/characteristic equation, for which the solution are the eigenvalues. For $\\MM$, $\\KK$ as we have defined them, this looks like:\n\\[\\det(\\KK - \\omega^2\\MM) = (k + k_{12}- m\\omega^2)^2 - k_{12}^2 = 0\\]\nWhere the first term is the product of the diagonals and the second term is the product of the off diagonals. Factoring, we have:\n\\[(k - m\\omega^2)(k + 2_{k12} - m\\omega^2) = 0\\]\nSo the characterstic equation hence has the two roots of:\n\\[\\omega_1 = \\sqrt{\\frac{k + 2k_{12}}{m}}, \\omega_2 = \\sqrt{\\frac{k}{m}}\\]\nThe types of motion described by these two eigenfrequencies are as follows. For $\\omega_1$, the blocks move with the same frequency and exactly out of phase. For $\\omega_2$, the blocks move with the same frequency, and exactly in phase. We will see why this is in the last two question, by solving for the amplitudes $a_1, a_2$.\n\\end{s}\n\n\\begin{p}\nFind the normal mode corresponding to the eigenfrequency $\\sqrt{k/m}$.\n\\end{p}\n\\begin{s}\nTo find the normal mode, we solve for the eigenvector corresponding to the above eigenfrequency/eigenvalue:\n\\[(\\KK - \\omega_2\\MM)\\m{a_1 \\\\ a_2} = \\m{k_{12} & - k_{12} \\\\ -k_{12} & k_{12}}\\m{a_1 \\\\ a_2} = 0\\]\nOr equivalently:\n\\[k_{12}\\m{1 & -1 \\\\ -1 & 1}\\m{a_1 \\\\ a_2} = 0\\]\nFrom which we can see that the restriction on $a_1, a_2$ is that:\n\\[a_1 = a_2 = A\\exp(-i\\delta)\\]\nHence solving for $\\v{z}$:\n\\[\\v{z} = \\m{a_1 \\\\ a_2}\\exp(i\\omega_2 t) = \\m{A \\\\ A}\\exp(i(\\omega_2 t - \\delta))\\]\nTherefore, finding $\\v{x}$ we have:\n\\[\\v{x}_{II} = \\Re\\v{z} = \\m{A \\\\ A}\\cos(\\omega_2 t - \\delta)\\]\nThis is an eigenmode, at the lower frequency. We can see from this that the two masses oscillate in phase with each other.\n\\end{s}\n\n\\begin{p}\nFind the normal mode corresponding to the eigenfrequency $\\sqrt{(k+2k_{12})/m}$.\n\\end{p}\n\\begin{s}\nSimilarly solving for the eigenvector, we have:\n\\[(\\KK - \\omega^2\\MM)\\v{a} = \\m{-k_{12} & -k_{12} \\\\ -k_{12} & -k_{12}}\\v{a} = -k_{12}\\m{1 & 1 \\\\ 1 & 1}\\m{a_1 \\\\ a_2} = 0\\]\nTherefore we obtain the requirement that $a_1 = -a_2$, and hence:\n\\[\\v{x}_I = \\m{A \\\\ -A}\\cos(\\omega_1 t - \\delta)\\]\n\\end{s}\n\n\\begin{p}\nWhat is the general solution?\n\\end{p}\n\\begin{s}\nThe general solution is the sum of the eigenmodes:\n\\[\\v{x}(t) = \\v{x}_I(t) + \\v{x}_{II}(t)\\]\n\\end{s}\n\n\\begin{p}\nIf block 1 oscillates while block 2 is held fixed, what is the frequency of oscillations?\n\\end{p}\n\\begin{s}\nThe frequency of oscillations of the first block would be given by $\\omega_0 = \\sqrt{\\frac{k + k_{12}}{m}}$; the reasoning for this is the block feels a restoring force $-kx$ from the left, restoring force $k_{12}x$ from the right, which leads to an effective spring constant $k + k_{12}$ and hence leads to the solution as stated.\n\\end{s}\n\n\\begin{p}\nHow does the uncoupled frequency above compare to the two eigenfrequencies?\n\\end{p}\n\\begin{s}\n\\[\\omega_2 < \\omega_0 < \\omega_1\\]\n\\end{s}\n\\noindent$\\omega_2$ is the frequency of the lowest mode, the blocks are in phase. The middle frequency is where we fix one block and just let the other oscillate. $\\omega_1$ corresponds to the higher eigenmode, with the blocks oscillating out of phase, at the highest frequency. Next day, we will look at coupled pendulums and normal coordinates (which is changing bases to diagonalize our matrices), where we obtain the useful result that the normal coordinates are independent of one another.\n\\end{document}", "meta": {"hexsha": "916dcc06962ba14619cf9ebf71317c8feeb9e650", "size": 6043, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-10/Worksheet-10.tex", "max_stars_repo_name": "RioWeil/PHYS306-notes", "max_stars_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture-10/Worksheet-10.tex", "max_issues_repo_name": "RioWeil/PHYS306-notes", "max_issues_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture-10/Worksheet-10.tex", "max_forks_repo_name": "RioWeil/PHYS306-notes", "max_forks_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.9363636364, "max_line_length": 494, "alphanum_fraction": 0.680953169, "num_tokens": 2085, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4479438692800134}}
{"text": "\\subsection{Outer Valence Green's Function}\\label{gf}\r\nThis section is based on materials supplied by\r\n\\begin{center}Dr David Danovich\\\\The Fritz Haber Research Center for \r\nMolecular Dynamics\\\\ The Hebrew University of Jerusalem\\\\ 91904 Jerusalem\\\\\r\nIsrael \\end{center}\r\n\r\nThe OVGF technique was used with the self-energy part extended to include\r\nthird order perturbation corrections,~\\cite{gf1}.  The higher order contributions\r\nwere estimated by the renormalization procedure.  The actual expression used to\r\ncalculate the self-energy part, $\\sum_{pp}(w)$, chosen in the diagonal form,\r\nis given in equation~(\\ref{gfeq1}), where $\\sum_{pp}^{(2)}(w)$ and $\\sum_{pp}^{(3)}(w)$ are\r\nthe second- and third-order corrections, and $A$ is the screening factor accounting\r\nfor all the contributions of higher orders.\r\n\\begin{equation}\\label{gfeq1}\r\n\\sum_{pp}(w) = \\sum_{pp}^{(2)}(w)+(1-A)^{-1}\\sum_{pp}^{(3)}(w).\r\n\\end{equation}\r\nThe particular expression which was used for the second-order corrections is given in\r\nequation~(\\ref{gfeq2}).\r\n\\begin{equation}\\label{gfeq2}\r\n\\sum_{pp}^{(2)}(w) = \\sum_a\\sum_{i,j}\\frac{(2V_{paij}-V_{paji})V_{paij}}{w+e_a-e_i-e_j}\r\n+\\sum_{a,b}\\sum_i\\frac{(2V_{piab}-V_{piba})V_{piab}}{w+e_i-e_a-e_b},\r\n\\end{equation}\r\nwhere\r\n$$\r\nV_{pqrs} = \\int\\int\\psi_p^*(1)\\psi_q^*(2)(1/r_{12})\\psi_r^*(1)\\psi_s^*(2){\\rm d}\\tau_1{\\rm d}\\tau_2.\r\n$$\r\n\r\nIn equation~(\\ref{gfeq2}), $i$ and $j$ denote occupied orbitals, $a$ and $b$\r\ndenote virtual orbitals, $p$ denotes orbitals of unspecified occupancy, and\r\n$e$  denotes an orbital energy. The equations are solved by an iterative\r\nprocedure, represented in  equation~(\\ref{gfeq3}).\r\n\\begin{equation}\\label{gfeq3}\r\nw_p^{i+1}=e_p+\\sum_{pp}(w^i).\r\n\\end{equation}\r\n\r\nThe SCF energies and the corresponding integrals, which were calculated by one\r\nof the semiempirical methods (MNDO, AM1, or PM3), were taken as the zero'th\r\napproximation and all M.O.s may be included in the active space for the OVGF\r\ncalculations.\r\n\r\nThe expressions used for $\\sum_{pp}^{(3)}$ and $A$ are given in \\cite{gf2}.\r\n\r\nThe OVGF method itself, is described in detail in \\cite{gf1}.\r\n\r\n%\\subsubsection{Example of OVGF calculation}\r\n%  The data-set {\\bf test\\_greenf.dat} will calculate the first 8 I.P.s\r\n%for dimethoxy-$s$-tetrazine.  This calculation is discussed in detail in \\cite{gf6}.\r\n%The experimental and calculated I.P.s are shown in Table~\\ref{gftab}.\r\n%\\begin{table}\r\n%\\caption{\\label{gftab}OVGF Calculation, Comparison with Experiment}\r\n%\\begin{center}\r\n%\\begin{tabular}{lccccc}\\\\\r\n%M.O.    &  Expt*  &   PM3   & Error   &  OVGF(PM3)  &  Error \\\\\r\n%$n_1$    &  9.05   &   10.15 &  1.10   &   9.46      &   0.41 \\\\\r\n%$\\pi_1$  &  9.6    &   10.01 &  0.41   &   9.65      &   0.05 \\\\\r\n%$n_2$    &  11.2   &   11.96 &  0.76   &  11.13      &  -0.07 \\\\\r\n%$\\pi_2$  &  11.8   &   12.27 &  0.47   &  11.43      &  -0.37 \\\\\r\n%\\end{tabular}\r\n%\r\n%*: R. Gleiter,  V. Schehlmann, J. Spanget-Larsen, H. Fischer and F. A. Neugebauer,\r\n%{\\em J. Org. Chem.}, {\\bf 53}, 5756 (1988).\r\n%\\end{center}\r\n%\\end{table}\r\n%\r\n%\r\n%From this, we see that for PM3 the average error is 0.69eV, but after OVGF \r\n%correction, the error drops to 0.22eV.  This is typical of nitrogen heterocycle \r\n%%calculations.\r\n", "meta": {"hexsha": "4c1a66d0aa9083e7c49c53c61efefd4a87500310", "size": 3226, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuals/MOPAC2000_manual/t_green.tex", "max_stars_repo_name": "openmopac/MOPAC-archive", "max_stars_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-12-16T20:53:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-16T20:54:11.000Z", "max_issues_repo_path": "manuals/MOPAC2000_manual/t_green.tex", "max_issues_repo_name": "openmopac/MOPAC-archive", "max_issues_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manuals/MOPAC2000_manual/t_green.tex", "max_forks_repo_name": "openmopac/MOPAC-archive", "max_forks_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7536231884, "max_line_length": 101, "alphanum_fraction": 0.667699938, "num_tokens": 1129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4479438657711359}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{siunitx}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage[citestyle=ieee,sorting=none,bibencoding=utf8,backend=biber]{biblatex}\n\\usepackage{caption}\n\\usepackage[utf8]{inputenc}\n\\usepackage{hyperref}\n\n\\graphicspath{{figures/}}\n\\bibliography{bibliography}\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\author{J.R. Powers-Luhn}\n\\title{CS528 Project 2: PCA and K Means}\n\\date{October 22nd, 2018}\n\n\\begin{document}\n\t\\maketitle\n\t\n\t\\section{Objective}\n\tThe goal of this project was to explore unsupervised clustering and means of evaluating the \n\tclusters generated by the K-Means algorithm. The ability of Principal Component Analysis to \n\timprove the performance of this algorithm was also explored.\n\t\n\t\\section{Preprocessing the data}\n\tA dataset was obtained with several summary statistics for fifty seven U.S. universities, \n\tmostly obtained from the Department of Education's Integrated Postsecondary Education Data System (IPEDS).\n\t\n\tThe dataset was processed in several ways before numerical analysis. Two missing values for \n\tClemson University were obtained: the IPEDS ID number (from the IPEDS website) and the 2017 \n\tendowment balance\\footnote{Source: \\url{https://www.clemson.edu/giving/cufoundations/documents/allocations.pdf}}. \n\tSome information (medical and agricultural school research funding) was absent for many schools \n\tand was therefore removed from the data. None of the schools included in the dataset were \n\thistorically black colleges, so the ``HBC'' column had zero variance and was therefore removed. \n\tOnly some of the schools had Wall Street Journal rankings; this column was removed. Some columns \n\twere determined to be categorical--these were ``one-hot'' encoded.\n\t\n\tFor all processing in this project, the numerical attributes were mean-centered and scaled to \n\tunit variance. This was accomplished using the scikit-learn \\texttt{StandardScaler} class \n\t\\cite{scikit-learn}. Scaling is necessary due to the different units of the various measurements. \n\tWithout this correction the variance would be skewed by the units and mean value of the individual \n\tmeasurements.\n\t\n\t\\section{PCA}\n\tPrincipal component analysis (PCA) was applied to the data. PCA is a linear transformation of a \n\tdataset into a new basis set. The principal components have the following properties:\n\t\n\t\\begin{itemize}\n\t\t\\item the components are orthogonal to each other, and\n\t\t\\item the components are ordered by the amount of variance they exhibit.\n\t\\end{itemize}\n\t\n\tThis means that the dimensionality of the data can be reduced by transforming the data into the \n\tnew space (where the transformed values are referred to as ``scores'') and throwing away all but \n\t\\texttt{k} columns of the transformed data. \n\t\n\tThe transformation into the new space is performed by taking the singular value decomposition of \n\tthe original data as indicated in equation \\ref{eq:svd}. \n\t\n\t\\begin{equation}\n\t\t\\mathbf{U}, \\mathbf{S}, \\mathbf{V}^T = svd(\\mathbf{X})\n\t\t\\label{eq:svd}\n\t\\end{equation}\n\t\n\tIn equation \\ref{eq:svd}, $\\mathbf{US}$ is the transformed data, $\\mathbf{S}$ are the singular \n\tvalues, and $\\mathbf{V}$ are the principal component loadings used to transform $\\mathbf{X}$ into \n\tthe PC space. $\\mathbf{S}$ is a diagonal matrix with the property that the diagonal values are \n\tproportional to the amount of variance captured by the associated principal component. The number \n\tof principal components to capture some fraction $f$ of the variance is shown in equation \n\t\\ref{eq:var_frac}.\n\t\n\t\\begin{equation}\n\t\t\\sum_{i=0}^k \\vec{s^2} = f\n\t\t\\label{eq:var_frac}\n\t\\end{equation}\n\t\n\tFor the university dataset, the data in its pre-processed form had sixty two numeric dimensions. \n\tHowever, the vast majority of the variance was contained in the first few principal components, as \n\tshown in figure \\ref{fig:explained_variance}.\n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{explained_variance}\n\t\t\\caption{Variance explained by each principal component (unscaled)}\n\t\t\\label{fig:explained_variance}\n\t\\end{figure}\n\t\n\tIn order to simplify the dataset while retaining 95\\% of the variance (and, therefore, the original \n\tinformation), the cumulative sum of the singular values squared (normalized to the sum of the square \n\tof all singular values) was calculated, and a threshold set at the first value that exceeded \\num{0.95}.\n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{cumulative_explained_variance}\n\t\t\\caption{Cumulative variance explained by the first $k$ principal components}\n\t\t\\label{fig:cumulative_explained_variance}\n\t\\end{figure}\n\t\n\tAs shown in figure \\ref{fig:cumulative_explained_variance}, this corresponded to the first \\num{17} \n\tcomponents. A scatter graph of the first two components plotted against each other is shown in \n\tfigure \\ref{fig:pc1_vs_pc2}\n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{pc1_v_pc2}\n\t\t\\caption{The first two principal components plotted against each other. Since the PC's are \n\t\t\t\t orthogonal to each other, no linear relationship is apparent. Note the scales of the \n\t\t\t\t two different axes. Since PC1 captures more variance than PC2, this axis convers a \n\t\t\t\t larger range.}\n\t\t\\label{fig:pc1_vs_pc2}\n\t\\end{figure}\n\t\n\t\\section{K-means}\n\tIn order to determine whether the schools could be grouped into categories, the \\texttt{k-means} \n\talgorithm was employed.\n\t\n\t\\begin{enumerate}\n\t\t\\item Select $k$ initial vectors from the data as seeds, $s_i \\in \\{s_0, s_1, \\mathellipsis, s_k\\}$\n\t\t\\item Calculate the distance from each $s_i$ to each vector\n\t\t\\item Assign to each vector the label associated with the seed with the minimum distance to that vector\n\t\t\\item Recalculate each $s_i = \\frac{\\sum_j x_j}{j}$ for all $x_j$ with label $i$\n\t\t\\item Repeat 2-4 until the values of $s$ converge\n\t\\end{enumerate}\n\t\n\tThis algorithm was found to converge in less than ten iterations.\n\t\n\tThis algorithm is not guaranteed to converge to the optimal solution since it is sensitive to the \n\tselection of the initial seeds. Because of this, the algorithm was repeated several times in order to \n\timprove the likelihood of optimal selection.\n\t\n\t\\subsection{K-means++}\n\tWhile the \\texttt{k-means} algorithm is guaranteed to converge, it is not guaranteed to converge to an \n\toptimum value. Specifically, it is subject to the selection of the initial seed vectors. In order to \n\timprove upon this, the \\texttt{k-means++} algorithm was employed\\cite{Arthur2007}. In this the first \n\tseed $s_1$ is selected at random from the data. Subsequent seeds $s_2, \\mathellipsis, s_k$ are selected \n\tusing a weighted probability proportional to the distance of each vector from the closest seed. In this \n\tway the initial selection of seeds avoids selecting vectors that are too close to each other. The \n\t\\texttt{k-means++} algorithm therefore converges much more quickly than \\texttt{k-means}, usually in \n\ta single iteration.\n\t\t\n\t\\subsection{Cluster selection}\n\tIdeally, data clusters should exhibit both tight grouping (minimal intra-cluster distance) and wide \n\tseparation (maximal inter-cluster distance). The ratio of these two values (the minimum inter-cluster \n\tdistance to the maximum intra-cluster distance) is referred to as the ``Dunn Index'' \\cite{dunn1974}. \n\tBecause the \\texttt{k-means} algorithm is not guaranteed to converge to the optimal solution, the \n\tDunn Index is subject to the random selection of the initial vector. Still, it provides a tool for \n\tevaluating the ``true'' number of clusters in the data.\n\t\n\tThe \\texttt{k-means} algorithm was applied to the data with $k$ ranging from \\numrange{2}{56}. In each \n\tcase the clusters were allowed to converge and the Dunn index was calculated. The results are shown \n\tin figure \\ref{fig:dunn_index_raw_data}.\n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{dunn_index_raw_data}\n\t\t\\caption{Dunn index for $k$ clusters. The value oscillates but has a clear maximum.}\n\t\t\\label{fig:dunn_index_raw_data}\n\t\\end{figure}\n\t\n\tUnfortunately, the Dunn index did not converge to a consistent maximum. Therefore an appropriate value \n\twas chosen for the number of clusters that ``looked right''.\n\t\n\t\n\t\n\t\\section{PCA plus K-Means}\n\tLorem ipsum dolor simet \\cite{Yeung2000}\n\t\n\t\\section{Conclusions}\n\tLorem ipsum dolor simet\n\t\t\n\t\\printbibliography\n\\end{document}\n", "meta": {"hexsha": "7fac1378d71fcc37d06ef616fdd059e4e8a89a8e", "size": 8461, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/report.tex", "max_stars_repo_name": "piovere/cs528p2", "max_stars_repo_head_hexsha": "717b1da3813f81a81f6c473f407d4167db16e6c7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/report.tex", "max_issues_repo_name": "piovere/cs528p2", "max_issues_repo_head_hexsha": "717b1da3813f81a81f6c473f407d4167db16e6c7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/report.tex", "max_forks_repo_name": "piovere/cs528p2", "max_forks_repo_head_hexsha": "717b1da3813f81a81f6c473f407d4167db16e6c7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.2681564246, "max_line_length": 115, "alphanum_fraction": 0.7702399244, "num_tokens": 2181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4479438588048023}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage[latin1]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\usepackage{bm}\n\\title{Week 6 exercises}\n\\begin{document}\n\t\\maketitle\n\t\\begin{enumerate}\n\t\t\\item The linear probability model for binary response is simply $ P(y = 1) =   \\pi_i = \\bm{x_i'\\beta} = \\beta_{0i} + \n\t\t\\beta_{1i} x_{1i}  + \\dots + \\beta_{ni} x_{ni}   $ and require the restriction that $ 0  \\leq  \\bm{X'\\beta}  \\leq 1 $ \n\t\t\\item In the GLM we combine the probability output to the linear prediction through a function \\textit{h} called \\textit{response function} that it is a cumulative distribution function with co domain in [0,1]. In formula we can express the GLM as $$ P(y = 1) =   \\pi_i = h(\\eta_i) = h(\\mathbf{x_i'\\beta}) = h(\\beta_{0i} + \n\t\t\\beta_{1i} x_{1i}  + \\dots + \\beta_{ni} x_{ni})  $$\\\\$ g = h^{-1} $ is the \\textit{link function} and it is used to calculate the linear predictor in function of probability: $ \\eta_i = g(\\pi_i) $ \n\t\tThe logit model use as response function the logistic function: $$ \\pi = h(\\eta) = \\dfrac{e^\\eta}{1 + e^\\eta} $$. The linear predictor returns the log odds $$ \\mathbf{x_i'\\beta} = \\beta_{0i} + \n\t\t\\beta_{1i} x_{1i}  + \\dots + \\beta_{ni} x_{ni} =  \\pi_i = \\log\\left(\\dfrac{\\pi}{1 - \\pi}\\right)   $$.\n\t\tThe probit model use instead a normal distribution cumulative function.\n\t\tThe c-log-log model use as response function the extreme minimum-value cumulative\n\t\tdistribution function\n\t\t$$ h(\\eta) = 1 - e^{-e^\\eta}$$ with the following link function $$ g(\\pi) = \\log(- \\log( 1 - \\pi )) $$\n\t\t\\item \n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.7\\linewidth]{plot_comparison_response_functions}\n\t\t\t\\label{fig:plotcomparisonresponsefunctions}\n\t\t\\end{figure}\n\t\tFrom the latter plot we can note that the \\textit{probit} and \\textit{logit} are symmetric around the 0 while the c-log-log is not symmetric. The c-log-log is similar to the logit but tend more speedly to one. If we do a comparison with the same variance between the logit and probit we have that the coefficients differ for a values of $ \\frac{\\pi}{3} = 1.814 $\n\t\t\\item With a latent continuous variable we use the standard normal distribution for the errors because we don't know the variance of the latent variable so the new coefficients are $ \\tilde{\\beta} = \\frac{\\beta}{\\sigma} $. We can't calculate the original $ \\beta $ since doesn't know $ \\sigma $ but the ratio between coefficients are constants $ \\dfrac{\\tilde{\\beta}_i}{\\tilde{\\beta}_j} = \\dfrac{\\beta_i}{\\beta_j}$ \n\t\t\\item In the logit model if increase $ x_k $ by 1 we have an increments on the odds by $ e^\\beta $ while the increment of probability is not the same in every point. \\\\ In the probit model we have an increment equal to $ \\phi^{-1}(\\beta) $\n\t\t\\end{enumerate}\n\t\t\\subsection*{Solution to applied exercise}\n\t\t\\begin{enumerate}\n\t\t\t\\item \t\t$$ \\eta = 0.42 + 0.06 \\cdot kidsge6 - 1.44 \\cdot kidslt6 - 0.09 \\cdot age + 0.21 \\cdot exper - 0.0031 \\cdot exper^2 + 0.22 \\cdot educ - 0.021 \\cdot nwifeinc$$\n\t\t\t$$\n\t\t\tP(y = 1) =\n\t\t\t\\hat{\\pi} = h(\\hat{\\eta}) =   \\dfrac{e^{\\hat{\\eta}}}{1 + e^{\\hat{\\eta}}} $$\n\t\t\t\\item $$ 0.42 + 0.06 \\cdot 0 - 1.44 \\cdot 0 - 0.09 \\cdot 40 + 0.21 \\cdot 0 - 0.0031 \\cdot 0 + 0.22 \\cdot 10 - 0.021 \\cdot 0 = -0.98$$\n\t\t\t\\item one year of more eduction when all the other variables are the same is a multiplicative effect of $ e^{0.22} $\n\t\t\t\\item The probability is 0.27\n\t\t\t\\item -0.0174\n\t\t\t\\item 0.046\n\t\t\t\\item $ 0.22 * 0.5^2 =  0.055 $\n\t\t\t\\item The probit coefficients are obtained by dividing by 1.84\n\t\t\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "e84662732fe77ecedbf1d1f59609b4c6245ef9df", "size": 3632, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week_6/week6.tex", "max_stars_repo_name": "Michedev/MSA_Exercises", "max_stars_repo_head_hexsha": "d7faeaef14c1a8a939b3a3b613769845de6aa2fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week_6/week6.tex", "max_issues_repo_name": "Michedev/MSA_Exercises", "max_issues_repo_head_hexsha": "d7faeaef14c1a8a939b3a3b613769845de6aa2fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week_6/week6.tex", "max_forks_repo_name": "Michedev/MSA_Exercises", "max_forks_repo_head_hexsha": "d7faeaef14c1a8a939b3a3b613769845de6aa2fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.6666666667, "max_line_length": 417, "alphanum_fraction": 0.6789647577, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.447943858753381}}
{"text": "% !TeX spellcheck = en_GB\n\\documentclass[12pt]{article}\n\n\\usepackage[a4paper, margin=0.7in]{geometry}\n\\usepackage{algorithm,algpseudocode}\n\\usepackage{caption}\n\\usepackage{algpseudocode}\n\\usepackage{graphicx}\n\\usepackage{verbatim}\n\\usepackage{comment}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{proof}[theorem]{Proof}\n\n\\begin{document}\n\\title{An Efficient Recursive Approach for Workload Distribution on Heterogeneous Systems}\n\\author{Hamidreza Khaleghzadeh}\n\\date{26 Jan 2017}\n\n\\maketitle\n\n\\section{Introduction}\nIn this report, we propose a new method called \\textit{WorkPart} which benefits from Branch-and-Bound programming technique to find the optimal workload distribution on $p$ heterogeneous processors so that the parallel execution time is minimized. We will explain the proposed approach in this report.\n\n\\section{Formulation of Performance Optimization Problem}\nConsider a workload of size $n$ executed using $p$ heterogeneous processors. Let time functions of processors be represented by set $T$ where $T_i=\\{(x_i^0,t_i(x_i^0)),(x_i^1,t_i(x_i^1)),\\cdots,\\allowbreak (x_i^{m-1},t_i(x_i^{m-1}))\\}$, $0 \\le i \\le p-1$, $m \\in \\mathbb{Z}_{>0}$. There is one time function per each processor where $T_i$ represents the time function of the processor $P_i$ which is represented by a discrete set of experimental data points separated by minimum granularity, $\\Delta x$. A given data point $(x,t(x))$ determines a workload with size of $x$ along with its execution time ($t(x)$). It should be noted that the workload with size of $n$ should be a multiple of $\\Delta x$. The problem, $WorkPart(n,p,T,t_{opt},D_{opt})$, is to find a partitioning, $D_{opt} = <x_{opt}^0,\\cdots,x_{opt}^{p-1}>$, of the workload of size $n$ among $p$ processors that minimizes the parallel computation time of the workload ($t_{opt}$). The parameters of $(n,p,T)$ and $(t_{opt},D_{opt})$ are the inputs and outputs of the problem, respectively. The problem can be formulated as following:\n\\begin{equation} \\label{eq1}\n\\begin{split}\nt_{opt} = minimize \\quad \\max_{i=0}^{p-1} \\quad t_i(x^i) \\\\\n\\text{Subject to } x^0+x^1+\\cdots+x^{p-1} = n \\\\\n0 \\le x^i \\le n \\qquad i = 0,\\cdots,p-1 \\\\\n\\text{Where } p,n,x^i \\in \\mathbb{Z}_{>0} \\text{ and } t_i(x^i) \\in \\mathbb{R}_{>0}.\n\\end{split}\n\\end{equation}\n\nIt is noteworthy that if a given $x^i$ is equal with 0, no problem is assigned to $P_i$. Therefore, the number of selected processors in the optimal workload distribution may be less than $p$.\n\n\\section{An Example}\nIn this section, using a simple example, we will explain how the problem $WorkPart$ is solved by the proposed algorithm called $HetWD$ which is responsible to find optimal distribution. Let a workload size of $n = 16$ runs on $p = 4$ processors with time functions $T=\\{T_0,\\cdots,T_3\\}$. Assume, for the sake of simplicity, the minimum granularity is 1 ($\\Delta x = 1$). \n\nFigure \\ref{ex_fig1} illustrates time functions sorted in non-decreasing order of time. Each cell in time functions shows execution time and its label is the problem size. To restrict the search area, the algorithm applies a time threshold represented by $t_{opt}$. All data points with greater or equal execution time than the time threshold are ignored. During the initialization step of the algorithm, the time threshold is set to load-equal execution time. According to the load-equal distribution, the assigned problem size to each processor should be $\\frac{16}{4}=4$ where its parallel execution time is $\\max_{i=0}^{3} t_i(4) = \\max \\{12,6,4,4\\} = 12$. All data points with smaller execution time of 12 consist our search area highlighted in time functions (Figure \\ref{ex_fig1}).\n\nIn the figure, there is a matrix called $Mem$ so that rows $Mem[1]$ and $Mem[2]$ store intermediate results for processors $P_1$ and $P_2$ (one row per processor). Each row in $Mem$ consists of 17 compound cells ($=16+1$) where $Mem[i][w]$, $i \\in \\mathbb{Z}_{[1,2]}, w \\in \\mathbb{Z}_{[0,n]}$ holds some information about distribution of work-size of $w$ on $P_i$ such as:\n\n\\begin{itemize}\n\t\\item \\textbf{$Mem[i][w].eTime$:} Parallel execution time of $w$ on $P_i,\\cdots,P_{p-1}$,\n\t\\item \\textbf{$Mem[i][w].lastIndex$:} The index of last evaluated data point in the time function $T_i$. In case a memory cell stores the optimal result, it is labelled as $Finalized$ and $Mem[i][w].lastIndex = \\_FI$.\n\t\\item \\textbf{$Mem[i][w].size$:} The problem size assigned to $P_i$ along with its execution time\n\t\\item \\textbf{$Mem[i][w].time$:} The execution time of the assigned partition to $P_i$ ($t_i(Mem[i][w].size)$).\n\t\n\\end{itemize}\n\nThe matrix is empty at the beginning of the algorithm.\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig1.png}}\n\t\\caption{Data structures and applying time threshold to restrict search area}\n\t\\label{ex_fig1}\n\\end{figure}\n\nTo find optimal solution, all possible distributions should be evaluated. To this end, the method uses Branch-and-Bound technique which finds the optimal solution using in-depth tree traverse. Figure \\ref{ex_fig2} shows the search tree built and traversed by $HetWD$ for finding the optimal workload distribution. There are two values associated with each node. Suppose node $X/Y$ on the level $L_{i \\in \\mathbb{Z}_{[0,\\cdots,p - 1]}}$ where $X$ is remaining workload should be distributed, and $Y$ is a size threshold which is maximum possible work-size can be distributed on processors $P_i$ to $P_{p-1}$. According to the time functions, the maximum workload size with execution times less than 12 are 16, 9, 6 and 8 for $T_0,\\cdots,T_3$, respectively. As shown in the figure, size thresholds are as following: for the level $L_0$ is $16+9+6+8=40$, for $L_1$ is $9+6+8=24$, for $L_2$ is $9+6=15$ and for $L_3$ is 8. In addition, the pair assigned to the edge on level $L_{i}$ determines assigned work-size to the processor $P_i$ and its corresponding execution time, respectively. If the edge label of a given level $L_{i \\in \\mathbb{Z}_[0,p-1]}$ is $0,0$, it means that no workload is assigned to $P_i$. \n\nEach level in the tree is responsible for one processor to examine all data points existing in its time function from the first to the last elements which have less execution time than time threshold. Let's take a look at figure \\ref{ex_fig2}. Before examination of data points existing in time functions, zero problem sizes are assigned to processors $P_0$ and $P_1$. Thus the remaining work-size should be distributed on $P_2$ and $P_3$ is still 16. But, since the remaining size (16) is greater than the size threshold of $L_2$, the node 16/15 will not be extended more and cut.\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig2.png}}\n\t\\caption{Using size thresholds for cutting branches}\n\t\\label{ex_fig2}\n\\end{figure}\n\nFigure \\ref{ex_fig3} depicts a solution found with parallel execution time of 9. The partitions assigned to processors $P_0$ to $P_3$ are $D_{opt}=<0,8,0,8>$, respectively.\n\nHaving found a solution, $HetWD$ are required to perform some post-solution operations as follows:\n\\begin{enumerate}\n\t\\item updating time threshold ($t_{opt}$)\n\t\\item updating size thresholds\n\t\\item memorizing the current solution into $Mem$\n\t\\item finding the uppermost node in the tree with maximum execution time and backtracking to its ancestor.\n\\end{enumerate}\n\nIn this example, $t_{opt}$ is updated to 9. As shown in the figure, the search area highlighted in each time function is also reduced due to the new $t_{opt}$. Once the green search area is shrunk, then size thresholds are recalculated. New size thresholds are replaced with $\\{38,23,14,7\\}$ (figure \\ref{ex_fig4}). In addition, we are required to store the intermediate solutions in $Mem$. To this end, the solution found for the workload sizes on $P_1$ and $P_2$ should be stored. If the solution path from the root to the leaf is traced in the figure \\ref{ex_fig3}, the problem size for $P_1$ and $P_2$ are respectively 8 and 16. Therefore, $Mem[2][8]$ and $Mem[1][16]$ has been updated to store these intermediate solutions. \n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig3.png}}\n\t\\caption{Finding a solution an its post-solution operations}\n\t\\label{ex_fig3}\n\\end{figure}\n\nThe algorithm keeps on examination of more data points. Figure \\ref{ex_fig4} illustrates new solution with better computation time of 7. All post-solution operations should again be performed. As time threshold decreases to 7, new size thresholds will be $\\{37,22,13,6\\}$ (figure \\ref{ex_fig5}). In addition, $Mem[2][8]$ and $Mem[1][16]$ are updated (figure \\ref{ex_fig4}).\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig4.png}}\n\t\\caption{Converging to the optimal solution}\n\t\\label{ex_fig4}\n\\end{figure}\n\nIn figure \\ref{ex_fig5}, the parallel execution time is 4, and the maximum time occurs at level $L_2$. Since we are looking for a new solution with the execution time less than 4, more expansion of node 8/13 makes no sense. Because of non-decreasing order of execution time in time functions, following data points in the time function $T_2$ do not have less execution time than $t_{opt}$. It means that more expanding of this node would not bring a better distribution with an execution time less than 4. So, we backtrack to its ancestor in level $L_1$. Since there is no better solution than $t_{opt}=4$ for workload size of 8 on $P_2$ and $P_3$, $Mem[2][8]$ is finalized in (Labelled as $\\_FI$).\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig5.png}}\n\t\\caption{Backtracking}\n\t\\label{ex_fig5}\n\\end{figure}\n\nHaving backtracked, the process continues from level $L_1$. Figure \\ref{ex_fig6} shows this step. The algorithm selects (9,3) from $T_1$. Its expansion results in a solution with better execution time. Thus, all post-solution operations are done after finding a solution are applied where $t_{opt}$ decreases to 3, and $Mem[2][7]$ and $Mem[1][16]$ are updated. It is noteworthy that the last index examined in $T_2$ is stored in $Mem[2][7].lastIndex$. For instance, suppose that we again want to find a distribution for workload 7 on $P_2$ and $P_3$. In this case, we will not be required to start from the beginning of the time function $T_2$. Having restored the last stored solution for work-size 7, the process is resumed from the node with index 1.\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig6.png}}\n\t\\caption{Storing last evaluated index in Mem for resuming the process from where was interrupted}\n\t\\label{ex_fig6}\n\\end{figure}\n\nAfter backtracking to the root, the algorithm again needs to find a solution for workload with size of 8 on $P_2$ (Node 8/13 in figure \\ref{ex_fig7}). Since the problem for this workload on $P_2$ has already been solved, we are not required to resolve it from scratch. Instead, the solution can be retrieved from $Mem$. The stored solution is finalized and it can be used to make final decision. It should be mentioned that if it is not finalized, we are required to extract the previous stored solution and then resume the process from where it was interrupted using the stored index in the memory.\n\nIn this example, using the memory, we extract the distribution of work-size 8 on $P_2$ and $P_3$. Since its parallel execution time is greater than current one, this solution is ignored.\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig7.png}}\n\t\\caption{Extracting a sub-solution from Mem}\n\t\\label{ex_fig7}\n\\end{figure}\n\nFinally, $HetWD$ examines the data point $(8,1)$ from $T_1$ (Figure \\ref{ex_fig8}). It finds the solution $D_{opt}=<8,8,0,0>$ with the parallel execution time of 1 ($t_{opt}=1$). Since time threshold is updated with 1, there is no data points remaining to examine and the last distribution in $D_{opt}$ with the parallel execution time $t_{opt}$ is returned as the optimal distribution.\n\nIt should be noted that the algorithm returns load-equal workload distribution if it cannot find any solution with less parallel execution time. It happens when there is no distribution with sum to $n$ and less parallel execution time than that of load-equal workload distribution.\n\n\\begin{figure}[!t]\n\t\\centering\n\t\\fbox{\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{Images/example/fig8.png}}\n\t\\caption{Finding the optimal solution}\n\t\\label{ex_fig8}\n\\end{figure}\n\n\\section{The Proposed Efficient Algorithm}\nIn this section, we present an efficient algorithm to solve $WorkPart$ problem (Algorithm \\ref{alg1_code}). The inputs to the algorithm are: the workload size, $n$ ($n$ should be a multiple of $\\Delta x$), the number of heterogeneous processors, $p$ and a list of $p$ time functions, $T=\\{T_0,T_1,\\cdots,T_{p-1}\\}$. The outputs of the algorithm are the optimal execution time, $t_{opt}$ and the optimal workload distribution, $D_{opt}$. It is noteworthy that the number of processors selected by WorkPart in the optimal workload distribution may be less than $p$.\n\nThe function obtains load-equal distribution an initializes $t_{opt}$ and $D_{opt}$. It returns the workload distribution so that $x_{opt}^i=\\frac{n}{p}$, $t_{opt}=\\max_{j=0}^{p-1} t_i(\\frac{n}{p})$, $\\forall i \\in [0,p-1]$ (Algorithm \\ref{alg1_code}, line \\ref{alg1_leq}). It is important to note that $\\sum_{i=0}^{p-1} x_{opt}^i = n$. \n\nArray S contains the size thresholds, which is illustrated in the example. IT is a list of sizes where $S_{i \\in \\mathbb{Z}_{[0..p - 1]}}$ represents the maximum workload size can be distributed on processors $P_i,...,P_{p - 1}$ with maximum parallel execution time of $t_{opt}$. It is the function size\\_thresholds responsible for determining these values (Algorithm \\ref{alg1_code}, line \\ref{alg1_s_th}). There is a two-dimensional matrix with size of $(p-2)*(n+1)$ called $Mem$ to memorize the points that have already been visited during the recursive invocations. The array value $Mem[i][n]$, $\\forall i \\in [1,p-2]$ contains some information for workload with size of $n$ distributed on processors $P_i,\\cdots,p-1$. the information includes: the parallel execution time, the partition assigned to $P_i$ along with its execution time,the index of last examined data point in $T_i$ and the status of memory (Finalized or Not\\_Finalized). This memorization ensures that there are only $O(n*m*p)$ recursive invocations of the core function (Algorithm \\ref{alg2_code}). Having initialized $Mem$, $WorkPart$ invokes the $HetWD$ to find the optimal workload distribution.\n\n\\begin{algorithm}\n\t\\scriptsize\n\t\\caption{Algorithm Finding Optimal workload Distribution of Size $n$ for Maximizing Performance} \\label{alg1_code}\n\t\\begin{algorithmic}[1]\t\n\t\t\\Function{WorkPart}{$n, p, T, t_{opt}, D_{opt}$}\n\t\t\\Statex \\textbf{INPUT:}\n\t\t\\Statex Workload size, $n \\in \\mathbb Z_{> 0}$\n\t\t\\Statex Number of processors, $p \\in \\mathbb Z_{> 0}$\n\t\t\\Statex Time functions, $T = \\{T_0,...,T_{p - 1}\\}$. $T_i={(x_i^0,t_i(x_i^0)),\\cdots,(x_i^{m-1},t_i(x_i^{m-1}))}, $ $t_i(x_i^0) \\le t_i(x_i^1) \\le \\cdots \\le t_i(x_i^{m-1}), $ $x^j \\in \\mathbb Z_{> 0},$ $\\forall j \\in [0,m-1],$ $\\forall i \\in [0,\\cdots,p-1]$ \n\t\t\\Statex \\textbf{OUTPUT:}\n\t\t\\Statex Optimal execution time, $t_{opt} \\in \\mathbb R_{> 0}$\n\t\t\\Statex Optimal workload distribution, $D_{opt} = {x_{opt}^0,...,x_{opt}^{p-1}}, x_{opt}^i \\in T_i $ $or 0,$ $\\forall i \\in [0,\\cdots,p-1]$. \n\t\t\\Statex\n\t\t\\State $(t_{opt}, D_{opt})$ $\\gets$ \\Call{load\\_equal\\_dist}{$n,p$}\t\\label{alg1_leq}\n\t\t\\State $S$ $\\gets$ \\Call {size\\_thresholds}{$T,t_{opt}$}\t\\label{alg1_s_th}\n\t\t\\State $\\forall i \\in [1,\\cdots,p-2],$ $j \\in [0,\\cdots,n]$\n\t\t\\State \\hskip\\algorithmicindent $Mem[i][j]$ $\\gets$ $(0,0)$\n\t\t\\State \\Call {HetWD}{$n,p,0,T,S,NULL,D_{cur},Mem,t_{opt},D_{opt}$} \\label{alg1_hetwdCall}\n\t\t\\State \\Return $(t_{opt},D_{opt})$\t\t\n\t\t\\EndFunction\t\t\n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\section{Recursive Algorithm $HetWD$} \\label{sec_code}\nIn order workload with size of $n$ to be optimally distributed on $p$ processors, WorkPart invokes a core routine called $HetWD$ (Algorithm \\ref{alg1_code} line \\ref{alg1_hetwdCall}). This proposed function is responsible to examine possible workload distributions using the Branch-and-Bound technique and find optimal solution. The search area is a tree data structure which is constructed implicitly using Depth First Search (DFS) technique and consists of maximum $p$ levels. Each level belongs to one processor where level $L_0$ to $P_0$ and so on, and all possible partitions can be assigned to a given processor $P_i$ are examined in $L_i$. \n\nTo cut sub-optimal branches, we benefits from some optimizations that will be explained in section \\ref{sec_opt}. In addition, we will explain how memorization of intermediate solutions prevent duplicate recalculations (Section \\ref{sec_mem}).\n\n$HetWD$ is illustrated in Algorithm \\ref{alg2_code}. The while loop (Algorithm\\ref{alg2_code}, lines \\ref{Alg1_mainLoop1}-\\ref{Alg1_mainLoop2}) builds the main section of the algorithm which is responsible for scanning time functions from left to right to examine all data points with execution time less than $t_{opt}$. The current processor which is under processing is represented by $c \\in \\{P_0,\\cdots,P_{p-1}\\}$. Selected work-sizes for each processor is stored in $D_{cur}={x^0,\\cdots,x^{p-1}}$ where $d^i \\in T_i$ determines current selected partition for $P_i$. It is important to note that $D_{opt}={x_{opt}^0,\\cdots,x_{opt}^{p-1}}$ holds the best distribution found so far. \n\nThe algorithm goes ahead in depth from $P_0$ (the root of the implicit tree) up to $P_{p-1}$ (a leaf) while $n$ is larger than zero. In each level, it stores current partition in $D_{cur}$. Once a solution is found, Post\\_Solution\\_Operations is called to perform post-solution activities such as: updating $t_{opt}$, $D_{opt}$, array $S$ and determining to which level the process should backtrack (determined with $bk$).\n\n\\begin{algorithm}\n\\scriptsize\n\\caption{Pseudocode of recursive workload partitioning on heterogeneous platforms} \\label{alg2_code}\n\\begin{algorithmic}[1]\t\n\\Function{HetWD}{$n, p, c, T, S, bk, D_{cur}, Mem,t_{opt}, D_{opt}$}\n\\Statex\n\t\\If{$c = p - 1$}\t\\label{Alg1_leaf1}\n\t\t\\If{$t_c(n) < t_{opt}$}\n\t\t\t\\State $D_{cur}[c]$ $\\gets$ $(n,t_c(n))$\n\t\t\t\\State \\Call{Post\\_Solution\\_Operations}{$D_{cur},t_{opt},D_{opt},S,bk,Mem$}\n\t\t\\EndIf\n\t\t\\State \\textbf{return}\t\n\t\\EndIf\t\t\t\t\\label{Alg1_leaf2}\n\t\\State $<size_c,time_c>$ $\\gets$ $(0,0)$\n\t\\State $curIndex=-1$\n\t\\If{$c > 0 \\wedge c \\leq p - 2$}\t\\label{retrieveMem1}\n\t\t\\State $<isReturn,curIndex>$ $\\gets$ \\Call{ReadFromMemory}{$n,p,c,t_{opt},T,bk, D_{cur}$}\n\t\t\\If{$isReturn=true$}\n\t\t\t\\State \\textbf{return}\n\t\t\\Else\n\t\t\t\\State $<size_c,time_c>$ $\\gets$ $(x_c^{curIndex},t_c(x_c^{curIndex}))$\n\t\t\\EndIf\n\t\\EndIf\t\t\t\t\t\t\t\\label{retrieveMem2}\n\t\\While{$time_c < t_{opt}$} \\label{Alg1_mainLoop1}\n\t\t\\If{$n = size_c \\vee n > size_c \\wedge S[c + 1] \\geq (n - size_c)$}\t\\label{Alg1_non_leaf1}\n\t\t\t\\State $D_{cur}[c]$ $\\gets$ $(size_c, time_c)$\n\t\t\t\\If{$n = size_c$}\t\t\t\n\t\t\t\t\\State \\Call{Post\\_Solution\\_Operations}{$D_{cur},t_{opt},D_{opt},S,bk,Mem$}\n\t\t\t\\Else\n\t\t\t\t\\State \\Call{HetWD}{$n-size_c,p,c+1,t_{opt},T,S,bk,D_{cur}$}\t\\label{Alg1_recall}\n\t\t\t\\EndIf\n\t\t\t\\If{$bk < c$}\n\t\t\t\t\\If{$t_c(x_c^{curIndex})=t_{opt}$}\t\n\t\t\t\t\t\\State $Mem[c][n].$\\Call{makeFinal}{ }\n\t\t\t\t\\Else\n\t\t\t\t\t\\State $Mem[c][n].last_{index} = curIndex$ \\label{alg1_lastIndex}\n\t\t\t\t\\EndIf\t\t\n\t\t\t\t\\State \\textbf{return}\n\t\t\t\\ElsIf{$bk = c$}\n\t\t\t\t\\State $bk = NULL$\n\t\t\t\t\\State $Mem[c][n].$\\Call{makeFinal}{ }\n\t\t\t\t\\State \\textbf{return}\n\t\t\t\\Else\n\t\t\t\t\\State $bk = NULL$\n\t\t\t\\EndIf\n\t\t\\EndIf\t\\label{Alg1_non_leaf2}\n\t\t\\If{$T_c.$\\Call{isEnd}{ }}\n\t\t\t\\State \\textbf{break}\t\n\t\t\\EndIf\n\t\t\\State $curIndex++$\n\t\t\\State $<size_c,time_c>$ $\\gets$ $(x_c^{curIndex},t_c(x_c^{curIndex}))$\n\t\\EndWhile\t\\label{Alg1_mainLoop2}\t\t\n\t\\State $Mem[c][n].$\\Call{makeFinal}{ }\t\t\t\n\\EndFunction\t\t\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Optimizations} \\label{sec_opt}\n$HetWD$ uses a set of optimizations to avoid branches that lead to sub-optimal solutions and therefore reduce the number of recursive calls.\n\n\\subsubsection{Time threshold} \\label{sec_time_threshold}\nTo find the optimal solution, all possible work-size combinations should be examined. It means that $n$ data points from each time function are required to be examined. Using a time threshold can eliminate some sub-optimal points from our search area (Algorithm\\ref{alg2_code}, Line \\ref{Alg1_mainLoop1}). In $HetWD$, it is $t_{opt}$ which applies a time threshold initialized to load-equal execution time. At runtime, it is updated by post-solution operations.\nFor instance, figure \\ref{ex_fig1} shows how the time threshold removes some data points from the search area. The threshold is updated by the function Post\\_Solution\\_Operations() at run-time when a solution with less execution than $t_{opt}$ is found (Figures \\ref{ex_fig4}-\\ref{ex_fig7}).\n\n\\subsubsection{Size threshold} \\label{sec_size_Threshold}\nAn acceptable distribution $<x^0,\\cdots,x^{p-1}>$ for workload with size of $n$ running on $p$ processors should satisfies Eq. \\ref{eq1} where $\\sum_{i=0}^{p-1}x^i=n$. We introduce size thresholds $S=\\{S_0,S_1,\\cdots,S_{p-1}\\}$ where $S_i$ determines the maximum workload size can be distributed on processors $P_i,\\cdots,P_{p-1}$ with parallel execution time less than $t_{opt}$. In other words, if $s_{p-1}=x_g^{p-1}$, $x_g^{p-1}$ represents the greatest work-size in $T_{p-1}$ where $t_{p-1}(x_g^{p-1})<t_{opt}$, then $S_i=x_g^i+s_{i+1}$, $i \\in [0,p-2]$. Size threshold array $S$ is updated when $t_{opt}$ is replaced with new execution time. Figure \\ref{ex_fig2} shows how size thresholds is able to cut branches will not result any solution. \n\n\\subsubsection{Backtracking}\t\\label{sec_backtracking}\nAccording to the Eq. \\ref{eq1}, the parallel execution time for a given solution $<x^0,\\cdots,x^{p-1}>$ will be $t_{opt}=\\max_{i=0}^{p-1}t_i(x^i)$. Suppose $x^i$ is the uppermost node in the search tree where $t_i(x^i)=t_{opt}$. It should be noted that the execution times of all $x^k$s, $\\forall k \\in [0,i-1]$ are less than $t_{opt}$. Since time function are sorted in increasing order of execution time, more expansion of the given node $x^i$ will not result a distribution with execution time less than current $t_{opt}$. Therefore, when a distribution is found, the recursive process should find the uppermost node in the search tree with the execution time equals to $t_{opt}$ and backtrack to its ancestor. This operation is performed by Post\\_Solution\\_Operations(). Take figure \\ref{ex_fig5} as an example. Having found the distribution $<0,8,3,5>$ with parallel execution time $t_{opt}=4$, the process should return to node $16/21$ at level $L_1$ which is the ancestor of node $8/13$.\n\n\\subsection{Memorization}\t\\label{sec_mem}\nStoring intermediate solutions is an effective way to prevent resolving the nodes which have been already visited. To this end a two-dimensional array called $Mem$, is defined to store intermediate solutions for processors $P_1,\\cdots,P_{p - 2}$. The matrix size depends on workload size ($n$) and the number of processors ($p$) and consists of $(p-2) * (n+1)$ elements. A solution for workload size $w$ on processor $P_i$ is stored in $Mem[i][w]$. The stored information is the work-size should be assigned to processor $P_i$, $Mem[i][w].size$, its corresponding execution time on $P_i$ extracted from $T_i$, $Mem[i][w].time$, the parallel execution time of $w$ distributed on processors $P_i,\\cdots,P_{p-1}$, $Mem[i][w].eTime$, and the index of last data point examined from time function $T_i$, $Mem[i][w].lastIndex$. $lastIndex$ helps to resume the operation from where it has been interrupted When all possible data points existing in $T_i$ is examined or further expanding of $P_i$ for work-size $w$ does not improve final execution time (refer to section \\ref{sec_backtracking}), it means that $Mem[i][w]$ contains the optimal solution for $w$, and the memory cell should be finalized. To this end, $Mem[i][w].lastIndex$ is equal to $\\_FI$.\n\n\\subsubsection{Retrieval from Memory}\nIn every recursion, in case under processing processor is $c \\in [1,\\cdots,p - 2]$, function ReadFromMemory is invoked to read (Algorithm \\ref{alg2_code} lines \\ref{retrieveMem1}-\\ref{retrieveMem2}). It either retrieves final solution if the accessed memory cell is $\\_FI$ or determines from where the process should be resumes by reading $lastIndex$. Algorithm \\ref{alg3_code} illustrates the function ReadFromMemory. Let $w$ is the size of workload. Firstly, $Mem[c][w]$ is accessed to read the last stored solution (Algorithm \\ref{alg3_code}, Line \\ref{alg3_memAcc}). $Mem[c][w]$ contains the size of partition assigned to $P_c$, the execution time of the stored solution on processors $P_c,\\cdots,P_{p-1}$, the index of last data point of $T_c$ which has been examined and assigned workload to $P_c$ stored in $MTime$, $MTime$ and $MLast$, respectively According to the values of $MPoint$ and $MLast$, the following scenarios occurs:\n\n\\begin{itemize}\n\\item \\textbf{No Solution}: This case occurs when there is no stored execution time in memory ($\\_NE$), and the result is $\\_FI$. It means that there is no solution for $n$ on processor $P_c$ (Algorithm \\ref{alg3_code}, Lines \\ref{alg3_noSol_1}-\\ref{alg3_noSol_2}).\n\n\\item \\textbf{Solution}:  This occurs when there is a finalized solution for $n$ on processor $c$. While the first part of solution has been stored in $D_{cur}[i], i \\in [0 \\cdots c - 1]$, the second part, $D_{cur}[i], i \\in [c \\cdots p - 1]$ will be read using the previously stored solution from $Mem$. the final solution is extracted from memory and processed by Post\\_Solution\\_Operations() (Algorithm \\ref{alg3_code}, Lines \\ref{alg3_fsol_1}-\\ref{alg3_fsol_2}).\n\n\\item \\textbf{Solution and Resume}: This is similar to the second items, but the solution is not finalized. The solution which has been already stored at $Mem$ is firstly extracted. Having examined the solution (Algorithm \\ref{alg3_code}, Lines \\ref{alg3_sol_1}-\\ref{alg3_sol_2}), the process is again resumed from where is determined by $MLast$ (Algorithm \\ref{alg3_code}, Lines \\ref{alg3_resume_1}-\\ref{alg3_resume_2}).\n\n\\item \\textbf{Resume}: This condition happens when there has yet to be no solution for $n$ on processor $c$, but the memory cell is not $\\_FI$ and $MLast$ points to the index where the processing work should be resumed (Algorithm \\ref{alg3_code}, Lines \\ref{alg3_resume_1}-\\ref{alg3_resume_2}).\n\\end{itemize}\n\nIf the function returns $true$, it means that the caller of ReadFromMemory should return, too. Otherwise, the process is resumed from where $MLast$ determines.\n\n\\begin{algorithm}\n\\scriptsize\n\\caption{Pseudocode of solution retrieval from memory} \\label{alg3_code}\n\\begin{algorithmic}[1]\t\n\\Function{<bool,MLast> ReadFromMemory}{$w, p, c, t_{opt},T,bk, D_{cur}$}\n\t\\State $(MTime, MLast, MPoint)$ $\\gets$ $Mem[c][w]$ \\label{alg3_memAcc}\n\t\\If{$MLast = \\_FI$}\n\t\t\\If{$MTime = \\_NE$}\t\\label{alg3_noSol_1}\t\t\n\t\t\t\\State \\textbf{return $<true,MLast>$}\t\\label{alg3_noSol_2}\n\t\t\\Else\t\t\t\t\t\t\\label{alg3_fsol_1}\n\t\t\t\\If{$MTime < t_{opt}$}\t\n\t\t\t\t\\State $x^c = MPoint$\n\t\t\t\t\\State $x^{c+1,\\cdots,p-1}$ $\\gets$ \\Call{RetrieveFromMemo}{ }\n\t\t\t\t\\State \\Call{Post\\_Solution\\_Operations}{ }\n\t\t\t\t\\If{$bk >= c$}\n\t\t\t\t\t\\State $bk = NULL$\n\t\t\t\t\\EndIf\t\t\t\t\t\n\t\t\t\\EndIf\n\t\t\t\\State \\textbf{return $<true,MLast>$}\t\n\t\t\\EndIf\t\t\t\t\t\t\\label{alg3_fsol_2}\n\t\\ElsIf{$MLast \\neq \\_FI$}\n\t\t\\If{$MTime \\neq \\_NE \\wedge MTime<t{opt} \\wedge t_c(x_{MLAST}) \\neq MPoint.size$}\t\\label{alg3_sol_1}\n\t\t\t\\State $x^c = MPoint$\t\n\t\t\t\\State $x^{c+1,\\cdots,p-1}$ $\\gets$ \\Call{RetrieveFromMemo}{ }\n\t\t\t\\State \\Call{Post\\_Solution\\_Operations}{ }\n\t\t\t\\If{$bk > c$}\n\t\t\t\t\\State $bk = NULL$\n\t\t\t\\ElsIf{$bk = c$}\n\t\t\t\t\\State $bk = NULL$\n\t\t\t\t\\State $Mem[c][w].$\\Call{makeFinal}{ }\n\t\t\t\t\\State \\textbf{return $<true,MLast>$}\n\t\t\t\\Else\n\t\t\t\t\\State \\textbf{return $<true,MLast>$}\n\t\t\t\\EndIf\t\t\t\t\n\t\t\\EndIf\t\t\t\t\t\t\t\t\\label{alg3_sol_2}\n\t\t\\If{$MLast \\neq \\_NE$}\t\\label{alg3_resume_1}\n\t\t\t\\State \\textbf{return $<false,MLast>$}\t\n\t\t\\EndIf\t\t\t\t\t\t        \\label{alg3_resume_2}\n\t\\EndIf\n\t\\State \\textbf{return $<false,MLast>$}\n\\EndFunction\t\t\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsubsection{Store to Memory}\nWhen a solution is found, the function Post\\_Solution\\_Operations() is responsible for storing it into the memory. Figures \\ref{ex_fig3}-\\ref{ex_fig8} depicts storing intermediate results in $Mem$. \n\n\\subsubsection{Solution Finalization}\nWhen all possible data points for a workload size on a processor is examined, the stored solution for the processor is set $\\_FI$ using the function $makeFinal()$. When a solution is found, the status of all processors having the same execution time with the maximum one are set $\\_FI$. It is because that finding a solution with smaller execution time on these processors does not improve optimal solution (Section \\ref{sec_backtracking}). Take figures \\ref{ex_fig5}, \\ref{ex_fig6} and \\ref{ex_fig8} as examples.\n\n\\subsubsection{Store Last Index}\nStoring last index helps process to be resumed form where it has been interrupted Suppose we want to backtrack to $P_i$. Indexes of last examined data points for processors $P_{i+1},\\cdots,P_{p-2}$ are recursively stored.(Algorithm \\ref{alg2_code}, Line \\ref{alg1_lastIndex}). Figure \\ref{ex_fig6} shows storing last examined index of $T_2$ for work-size of 7.\n\n\\section{Correctness Proof of $HetWD$}\nDepth-First Search (DFS) is an option for searching a tree data structures to examine the search area and find the optimal solution. Suppose a tree with maximum height $p$ where the level $L_0$ is responsible for examination of all data points in the time function $T_0$, $L_1$ for $T_1$ and so on. In addition to data points existing in the function, a data point with zero size and zero execution time (no workload is assigned to a processor) is examined on levels $L_0$ to $L_{p-2}$. Depth-first spanning of the tree enables us to examine all combinations, extracts all possible solutions and then find the optimal one which is minimum in parallel execution time.\n\nSince full spanning a search tree is exponential, we proposed algorithm called $HetWD$ applies Branch-and-Bound technique to find the optimal solution much quicker. It uses a series of optimizations (section \\ref{sec_opt}) to reduce the exponential search space to polynomial. In this section, we are going to prove that these optimizations only cut the branches which do not involve any optimal solution.\n\n\\begin{lemma}\t\\label{lem_time_threshold}\n\tBranches cut by time threshold optimization do not involve the optimal solution.\n\\end{lemma}\n\n\\textit{Proof.} We are looking for a solution with parallel execution time less than the time threshold $t_{opt}$. Suppose a solution with the partition $x^i$ on level $L_i$ where $t_i(x^i) > t_{opt}$. According to the Eq. \\ref{eq1}, the parallel computation time of this solution is:\n\n$$Time = \\max_{j=0}^{p-1} \\quad x^j$$\n\nSince the solution involves the partition $x^i$ with the execution time greater than $t_{opt}$, the parallel execution time of the solution will be greater than $t_{opt}$. Thus, the solution cannot be the optimal one we are looking for. \\textit{End of Proof}.\n\n\\begin{lemma}\t\\label{lem_size_threshold}\n\tBranches cut by size threshold optimization do not involve the optimal solution.\n\\end{lemma}\n\n\\textit{Proof.} Suppose the node $r_i/S_i$ in level $L_i$ where $r_i$ represents remaining workload size should be distributed on processors $P_i,\\cdots,P_{p-1}$ and $S_i$ determines size threshold for the level $L_i$ and $x_g^i$ represents the maximum workload size in $T_i$ that its execution time is less than $t_{opt}$ (Section \\ref{sec_size_Threshold}).\n\nSuppose a distribution for $r_i = {x^i,\\cdots,x^{p-1}}$ on processors $P_i,\\cdots,P_{p-1}$ which satisfies the equation \\ref{lem2_r_i}.\n\n\\begin{equation}\t\\label{lem2_r_i}\n\\sum_{j=i}^{p-1} x_j = r_i\n\\end{equation}\n\nWe know that $S_i$ is the summation of $x_g^{i \\in [i,p-1]}$ and $x^j \\le x_g^j, j \\in [i,p-1] , x^j \\in r_i$. Thus any distribution on processors $P_i,\\cdots,P_{p-1}$ should satisfy the equation \\ref{lem2_con}. \n\\begin{equation}\t\\label{lem2_con}\n\\sum_{j=i}^{p-1} x_j \\le \\sum_{j=i}^{p-1} x_g^j \\Longrightarrow \\sum_{j=i}^{p-1} x_j \\le S_i \\Longrightarrow r_i \\le S_i\n\\end{equation}\n\nIt means that $\\forall i \\in [0,\\cdots, p-1]$ there is no distribution for $r_i$ in case $r_i > S_i$.\n\n\\textit{End of Proof}.\n\n\\begin{lemma}\t\\label{lem_backtracking}\n\tSubtrees ignored by backtracking do not involve an distribution better than current solution.\n\\end{lemma}\n\n\\textit{Proof.} Suppose $D_{cur} = <x^0, x^1,\\cdots,x^{p-1}>$ be the best distribution found till now for work-size $n$ on $p$ processors, and $Time(D_{cur}) = t_{opt}$ represents its parallel execution time. Let consider a given $i \\in \\mathbb{Z}_{[1..p - 1]}$ where $x^i \\in D_{cur}$ and it is the closet node to the tree's root with the execution time equals with $t_{opt}$ $t_i(x^i)=t_{opt}$. Therefore:\n$$\\max_{j=0}^{i-1} Time(x^j) < t_{opt}$$\nand\n$$\\max_{j=i}^{p-1} Time(x^j) = t_{opt}$$\n\nWe know time functions are sorted in non-decreasing order of execution times. So the execution times of all data points located after $x^i$ in $T_i$ will be greater than or equal with $t_{opt}$. Therefore, since we are looking for a solution with parallel execution time less than $t_{opt}$, the examination of following data points from $T_i$ will not bring us a distribution with the execution time less than current $t_{opt}$. \\textit{End of Proof}.\n\n\\begin{proposition}\n\tSuppose $\\Delta x$ be the minimum granularity of workload so that each processor is allocated a multiple of $\\Delta x$ only. Let the time function of a processor, $T_i$, be represented by a discrete set of experimental points separated by $\\Delta x$ and sorted in non-descending order of time. Then the proposed algorithm distribute the workload with size of $n$ on $p$ processors so that the parallel execution time stays minimum. Then, the algorithm $HetWD$ gives the optimal solution.\n\\end{proposition}\n\n\\textit{Proof.} $HetWD$ algorithm is based on the DFS technique which examines all possible distributions to find the optimal one. However, the proposed algorithm tries to make search area smaller with Branch-and-Bound method. To this end, we have applied some optimizations including time threshold, size threshold and backtracking. Thus, the correctness of $HetWD$ can be proved just if we prove that these three optimizations do cut sub-trees of the main DFS which do not involve better solutions than the distribution already found. It can be proved using the lemmas \\ref{lem_time_threshold}, \\ref{lem_size_threshold}, \\ref{lem_backtracking}. They prove the applied optimizations only cut branches involving either sub-optimal distributions or not-better distribution than the solution currently has been found. \\textit{End of Proof}.\n\n\\begin{proposition}\n\t$HetWD$ is terminable.\n\\end{proposition}\n\n\\textit{Proof.} There is a while loop in the $HetWD$ that its iteration is bound to the time threshold $t_{opt}$. We know that $t_{opt}$ is updated when a distribution with less execution time is found and it means that the values for the time threshold have a non-increasing order. Since time functions are sorted in non-decreasing order of time and the algorithm go ahead from smaller execution times to greater ones, after some iterations the time of data points will be greater than the time threshold, and then the while loop finishes. \\textit{End of Proof}.\n\n\\section{Complexity of The Proposed Algorithm}\t\\label{sec_timeComp}\nLet a workload size of $n$ which is a multiple of $\\Delta x$. Let the workload should be distributed on $p$ processors. The core function $HetWD$ implicitly builds a tree data structure consisting of $p$ levels. There are at most $n$ work sizes should be resolved on every level except the leaf one. Let $m$ be the maximum number of points with execution time less than the time threshold in a time function. Thus, the maximum number of points should be examined for each time function is at most $m + 1$ ($m$ data points from time function plus 1 point for zero-size problem). At the mercy of the memorization, each data point for a given work size is required to be examined just only one time. So, the number of recursive calls for each non-leaf level is $n * (m + 1)$. Despite the last level, recursion happens in $p - 1$ non-leaf ones. Thus, the maximum number of recursion calls without considering optimizations (section \\ref{sec_opt}) is bounded by $O(n * m * p)$. \n\t\n\\section{Experimental Results}\nTo evaluate the proposed algorithm, some random time functions with lots of fluctuations have been built. Figure \\ref{fig:randomTimeFunction} depicts a randomly built time function. The vertical axis shows execution times and the other one is workload sizes. There are 1000 data points in each function with the granularity of 64 ($\\Delta x = 64$).\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/randonTimeFunction.jpg}\n\\caption{A random time function}\n\\label{fig:randomTimeFunction}\n\\end{figure}\n\n\\subsection{Parallel Execution Time Improvement}\nFigure \\ref{fig:etimeComp} compared the execution time of load-equal distribution with that of heterogeneous one for 16 processors. In this figure, horizontal and vertical axes show workload sizes and parallel execution times, respectively. Workload sizes rage from 1024 ($=16*64$) to 1024000 ($=16*64000$) with granularity of 64.\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/eTimeCompare_set16.jpg}\n\\caption{Load-equal vs. heterogeneous distribution}\n\\label{fig:etimeComp}\n\\end{figure}\n\n\\subsection{Processing Time}\nIn this section we are going to examine the processing speed of the proposed algorithm. Figures \\ref{fig:pTime16} and \\ref{fig:pTime128} show the time taken to find optimal solutions for 16 and 128 processors. Each time function consists of 1000 data points with granularity of 64. The experiments have been run on HCLServer.\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/procTime_set16.jpg}\n\\caption{The time consumed to find optimal heterogeneous distributions for 16 processors.}\n\\label{fig:pTime16}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/procTime_set128.jpg}\n\\caption{The time consumed to find optimal heterogeneous distributions for 128 processors.}\n\\label{fig:pTime128}\n\\end{figure}\n\n\\subsection{Time Complexity}\nAccording to section \\ref{sec_timeComp}, the proposed algorithm's processing time is bounded by $O(n * d * p)$. Since the number of maximum points in every time function ($d$) is not too large, it can be considered as a constant, and it means that the processing time will be a parameter of both work-size ($n$) and the number of processors ($p$). To evaluate the correctness, figures \\ref{fig:n_p_time} and \\ref{fig:n_p_recCall} depict how $n$ and $p$ affect processing time and the number of recursive calls, respectively. Work sizes range from 8192 to 256000, and the number of processors varies between 4 and 128. It is apparent that there is a linear relationship between both $n$ and $p$ with processing and recursion calls. \n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/n_p_time.jpg}\n\\caption{The relationship of work-size and number of processors with processing time.}\n\\label{fig:n_p_time}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[width=6in]{Images/n_p_recCall.jpg}\n\\caption{The relationship of work-size and number of processors with recursion calls}\n\\label{fig:n_p_recCall}\n\\end{figure}\n\n\\end{document}", "meta": {"hexsha": "271cd2ec157d6f02f0f184fed181852abcd58ae5", "size": 40108, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hpopt/doc/report/Report.tex", "max_stars_repo_name": "ravimanumachu/hclmpifft", "max_stars_repo_head_hexsha": "f97918312bd80ef2da64342660ee1265816f88ca", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hpopt/doc/report/Report.tex", "max_issues_repo_name": "ravimanumachu/hclmpifft", "max_issues_repo_head_hexsha": "f97918312bd80ef2da64342660ee1265816f88ca", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hpopt/doc/report/Report.tex", "max_forks_repo_name": "ravimanumachu/hclmpifft", "max_forks_repo_head_hexsha": "f97918312bd80ef2da64342660ee1265816f88ca", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 90.947845805, "max_line_length": 1247, "alphanum_fraction": 0.7427196569, "num_tokens": 11520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.4479438517870476}}
{"text": "\\documentclass[../PHYS306Notes.tex]{subfiles}\n\n\\begin{document}\n\\section{Lecture 31}\n\\subsection{Lecture Notes - The Strain Tensor and Hooke's Law for Solids}\n\\subsubsection{The Stress Tensor}\nRecall we can write the vector area element as $d\\v{A} = \\hat{\\v{n}}dA$. What is then the stress tensor? We consider the force on a surface element $\\v{F}(d\\v{A})$, which we can express using the stress tensor:\n\\[\\v{F}(d\\v{A}) = \\sigma d\\v{A}\\]\nWhere $\\sigma$ is the stress tensor, which is a 3x3 matrix. We could alternatively write this as:\n\\[F_i(d\\v{A}) = \\sum_{j=1}^3 \\sigma_{ij}dA_j\\]\n\n\\subsubsection{Stress Tensor Elements}\nLet\n\\[F_1(\\text{On area dA normal to} \\hat{\\v{e}}_1) = \\sigma_{11}dA\\]\nThis is of course true for $\\sigma_{22}$ and $\\sigma_{33}$. $\\sigma_{ii}$ is therefore ith component of the force $\\perp$ to the i-axis. These are volumetric forces, and this tells us that the tensile and compressive forces correspond to the diagonal entries of the stress tensor. Next, consider \\[F_2(\\text{on area dA normal to } \\hat{\\v{e}}_1) = \\sigma_{21}dA\\]\nAnd similarly for $\\sigma_{31}$. These are clearly shearing forces, forces that act perpendicular to the plane.\n\n\\subsubsection{Symmetry of the Stress Tensor}\nWe said above that the stress tensor has 9 entries (3x3) but there is good news; it turns out that the tensor is actually symmetric (i.e. just 6 components to worry about!). To see this, consider the following geometry:\n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-31/l31-img1.png}\n\\end{center}\nWe now apply a force in the $1$ direction, perpendicular to the $2$ direction, i.e. $F_{a} = \\sigma_{12}dA$. We can also apply a force in the $2$ direction, perpendicular to the $1$ direction, which gives $F_b = \\sigma_{21}dA$. It is clear to see that these forces induce a torque. WE can also apply the same forces at the opposite corner, on the opposite direction (of equal magnitude):\n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-31/l31-img2.png}\n\\end{center}\nThe torque is then given by:\n\\[\\tau = F_b l - F_q l = (\\sigma_{21} - \\sigma_{12})ldA = \\Gamma_3\\]\n(this torque is in the 3-direction). Furthermore, we have that:\n\\[\\Gamma_3 = \\dod{L_3}{t}\\]\nWe now argue that $\\Gamma_3$ is zero (and hence that $\\sigma_{21} = \\sigma_{12}$. To see that this is the case, consider shrinking all sides of the square by a factor $\\lambda$. If I change $l$ by $\\lambda l$, I pick up a factor of $\\lambda$, and the area picks up a factor of $\\lambda^2$, for a total scaling of:\n\\[\\Gamma_3 \\mapsto \\lambda_3 \\Gamma_3\\]\nThen, what happens to the angular momentum? We pick up $\\lambda^2$ from the $\\v{r} \\times \\v{p}$, and then integrating over the plane, we have that we pick up a $\\lambda^2$, so it follows that:\n\\[\\lambda^3\\Gamma_3 = \\lambda^4\\dod{L_3}{t}\\]\nBut this is ture for all $\\lambda$, so it follows that $\\Gamma_3$ must be zero, and hence $\\sigma_{21} = \\sigma_{12}$. An identical argument shows that $\\sigma_{ij} = \\sigma{ji}$ in general.\n\n\\subsubsection{Displacements}\nWe now have a measure of force on the system, but we also need a measure of deformation. In general, we can write down a vector $\\v{r}$ from the origin to any position in the original configuration, and we change this $\\v{r}$ to a new vector $\\v{r} + \\v{u}(\\v{r})$ where $\\v{u}$ is the displacement from the reference to the current position. \n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-31/l31-img3.png}\n\\end{center}\nThis displacement vector in general depends on the position, not all points in the object will move the same amount. One might ask why do we want $\\v{r} + \\v{u}(\\v{r})$ and not just $\\v{u}$ by itself; consider that $\\v{u}$ itself would change during a constant translation ($\\v{u}(\\v{r}) = \\v{u}_0$) of the entire object, and hence is not a good measure of the strain. We need to look at \\textbf{distortions}. A general way to write down/pick up these distortions:\n\\[du_i = \\sum_{j}\\dpd{u_i}{r_j}dr_j\\]\nOr we can write this vectorially:\n\\[d\\v{u} = \\DD d\\v{r}\\]\nWhere:\n\\[\\DD = \\m{\\dpd{u_1}{r_1} & \\dpd{u_1}{r_2} & \\dpd{u_1}{r_3} \\\\ \\dpd{u_2}{r_1} & \\dpd{u_2}{r_2} & \\dpd{u_2}{r_3} \\\\\n\\dpd{u_3}{r_1} & \\dpd{u_3}{r_2} & \\dpd{u_3}{r_3}}\\]\nAnd this matrix contains the rate of change of the displacement. This is nice, as evidently this is now insensitive to any constant translations. The gradient of the constant translation will be zero, which is what we want as we should not have to pay any energy just by moving our rigid body back and forth.\n\n\\subsubsection{The Strain Tensor}\nBut there is another wrinkle to consider; rotating the body should also not change the energy of the body/the energy should not depend on the orientation. What do we then do about rotations?\nCOnsider that for a small rotation:\n\\[\\bm{\\theta} = \\theta\\v{u}\\]\nAbout an axis $\\v{u}$. To see this, \n\\[\\v{v} = \\bm{\\omega} \\times \\v{r}\\]\nSo we can use this to write:\n\\[\\v{u}(\\v{r}) = \\v{v}dt = \\bm{\\omega} dt \\times \\v{r} = \\bm{\\theta} \\times \\v{r}\\]\nThen we have that the displacement gradient has the form:\n\\[\\DD = \\m{0 & \\theta_3 & -\\theta_3 \\\\ -\\theta_3 & 0 & \\theta_1 \\\\ \\theta_2 & -\\theta_1 & 0}\\]\nWhich we can see is an antisymmetric matrix. The antisymmetry means that:\n\\[\\DD^T = -\\DD\\]\nWe need to get rid of this; we dont want a measure that picks up these rotations. We can construct this by remembering that any matrix can be decomposed into a symmetric and antisymmetric part. So, we write:\n\\[\\DD = \\frac{1}{2}(\\DD - \\DD^T) + \\frac{1}{2}(\\DD + \\DD^T)\\]\nWhere the first term is by construction anti-symmetric, and the second term is by construction symmetric. Hence, we will just keep the second term, and use this as the measure of strain. The first term corresponds to the vorticity/curl part, but here we only want to keep the symmetric part. Hence, we can define the small-strain tensor as:\n\\[\\e = \\frac{1}{2}\\left(\\DD + \\DD^T\\right)\\]\nWhich we can see is symmetric by construction;\n\\[\\e_{ij} = \\frac{1}{2}\\left(\\dpd{u_i}{r_j} + \\dpd{u_j}{r_i}\\right)\\]\n\n\\subsubsection{Example: Thin/thick plate in xy plane}\nConsider a thin plate subject to in plane (xy) tensile, compressive, or shear forces. Are $\\sigma_{zz}$ and $\\e_{zz}$ zero? nonzero?\n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-31/l31-img4.png}\n\\end{center}\n\\begin{s}\n$\\sigma_{zz} = 0$ and $\\e_{zz} \\neq 0$. For the first point, we can recognize that pulling on the plate in the xy plane induces no stress on the plane in the z direction. For the second point, we consider a sheet of rubber which changes in thickness as we pull it.\n\\end{s}\nWhat if we ask the same question, but this time the plate is thick?\n\\begin{s}\nIf we compare the thick to the thing plate, any length change from the contraction effect would be very very small as the rod is tall. Hence, if we elongate it a little bit, then to first order, there is no strain. But, there can be a stress, as the system would like to contract.\n\\end{s}\n\nThe first case (thin plate) corresponds to a plane stress condition. There is no stress in the z-axis, but if we pull, we get an appreciable change in the thickness of the plate and hence a nonzreo strain. On the other hand, we have the plane strain condition, where there is no strain in the z axis (rod is so tall such that the strain in the z-direction is negligeble/the rod does not change thickness when we pull) but we could still have a stress in the z-axis.\n\n\\subsubsection{Hooke's Law for Isotropic and Homogenous Solids}\nConsider a decomposition of strain tensor. Consider the quantity of average dilation:\n\\[e = \\frac{1}{3}(\\e_{11} + \\e_{22} + \\e_{33}) = \\frac{1}{3}\\Tr(\\e)\\]\nWhich is a measure of how much the system is compressed/pulled. The last equality we just write the expression as the trace of the strain tensor. Then, decomposing we have:\n\\[\\e = e\\II + \\e^{dev} = \\text{Vol}(\\e) + \\text{Dev}(\\e)\\]\nWhere the first term is the spherical term (the term that couples to the volume changes) and the second term is the deviatoric part (everything else, e.g. shear). Then, Hooke's Law says that:\n\\[\\sigma = f(\\e)\\]\nWhere $f$ is a linear function. Then, we write (Without proof) that in the linear case, we can use this decomposition to obtain:\n\\[\\sigma = 3B\\text{Vol}(\\e) + 2G\\text{Dev}(\\e)\\]\nWhere $B$, $G$ are the bulk and shear moduli. We can alternatively write this as:\n\\[\\sigma = 2\\mu\\e + \\lambda \\Tr(\\e) \\II\\]\nWhere $\\mu = G$ and $\\lambda = B - \\frac{2}{3}\\mu$. What is important to realize is that this is true for an isotropic and homoegnous solid, in which case only two elastic moduli are sufficient to characterize this response (we only need to know the bulk and shear moduli). Of course in something like an anisotropic metal, this would be more complicated.\n\\end{document}", "meta": {"hexsha": "41147fb193a77d2f8062a08a649b6f5c7bffe5b9", "size": 8696, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-31/Lecture-Notes-31.tex", "max_stars_repo_name": "RioWeil/PHYS306-notes", "max_stars_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture-31/Lecture-Notes-31.tex", "max_issues_repo_name": "RioWeil/PHYS306-notes", "max_issues_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture-31/Lecture-Notes-31.tex", "max_forks_repo_name": "RioWeil/PHYS306-notes", "max_forks_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.6494845361, "max_line_length": 465, "alphanum_fraction": 0.7169963201, "num_tokens": 2619, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.44793890486833515}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n% \\begin{figure}[ht]\n%     \\centering\n%     \\incfig{riemmans-theorem}\n%     \\caption{Riemmans theorem}\n%     \\label{fig:riemmans-theorem}\n% \\end{figure}\n\n\\begin{document}\n\n\\section{Finite Fields}\n\\label{sec:finite_fields}\n\\begin{thm}\n\tLet \\(F\\) be a finite field. \\(\\left| F \\right| = p^{k}\\), \\(p\\) prime. Conversely, for every \\(p^{k}\\) there exists exactly one \\(F\\) such that \\(\\left| F \\right| = p^{k}\\)\n\\end{thm}\n\\begin{proof}\nWe will show that the \\( \\textrm{dim} = k\\); namely that there exists a basis \\(b_1,\\ldots,b_k\\) that generates all elements in \\(F\\) uniquely by \n\\begin{align*}\n\ta = \\lambda_1 b_1 + \\ldots + \\lambda_k b_k\n\\end{align*}\nwhere \\(\\lambda_1,\\ldots,\\lambda_k \\in \\Z_p\\), which by our other theorem is a subfield. This is isomorphic to \\(\\Z_p[x] / (g)\\) which is \\(F\\). Observe that \\( \\textrm{deg}g = k\\)These are the residues mod \\(g\\), or\n\\begin{align*}\n\ta_0 + a_1x + \\ldots + a_{k-1}x^{k-1}\n\\end{align*}\nEach \\(a_i\\) can be chosen \\(p\\) ways, so then \\(\\left| F \\right| = p^{k}\\), as desired.\n\\end{proof}\n\\begin{thm}\n\tFor any element \\(a \\in F\\) a finite field,\n\t\\begin{align*}\n\t\ta + \\ldots + a = 0\n\t\\end{align*}\n\twhere \\(a\\) is added exactly \\(p\\) times.\n\\end{thm}\n\\begin{proof}\nFor all \\(a\\) there exists an \\(n\\) such that\n\\begin{align*}\n\ta+\\ldots+a = 0\n\\end{align*}\nwhen \\(a\\) is added \\(n\\) times, because eventually the sequence \\(a, a+a, a+a+a, \\ldots\\) must repeat, and then you'll have your \\(n\\). There are infinite solutions, but finitely many elements in \\(F\\). This implies that\n\\begin{align*}\n\ta + \\ldots + a = a + \\ldots + a\n\\end{align*}\nwhere on the LHS, \\(a\\) is added \\(i\\) times, and on the RHS added \\(j\\) times.\\\\\nAssume that \\(i < j\\). Observe that\n\\begin{align*}\n\ta + \\ldots + a = 0\n\\end{align*}\nfor \\(j-i\\) additions. Now assume that \\(a \\neq 0\\). Then multiply both sides by \\(b\\) implies\n\\begin{align*}\n\t\\forall b, b + \\ldots + b = 0\n\\end{align*}\nbecause we can factor. Thus the assumption holds. Now we want to find the smallest \\(n>0\\). Assume for the sake of contradiction that \\(n = kl\\), both greater than \\(1\\) (not prime). Then we can separate the sum into blocks of \\(k\\) and blocks of \\(l\\). Then\n\\begin{align*}\n\t\\underbrace{a+\\ldots+a}_k + \\underbrace{\\ldots}_{l} + \\underbrace{a+\\ldots+a}_k = 0\n\\end{align*}\nBy assumption  \\(a+\\ldots+a\\) is non-zero, so it is some \\(b \\in F\\). But then \\(\\underbrace{b+\\ldots+b}_l = 0\\), which is a contradiction. So it has to be prime, as desired.\n\\end{proof}\n\\begin{thm}\n\tLet \\(F\\) be a finite field. Then\n\t\\begin{align*}\n\t\tF = \\left\\{ 0,1,\\alpha,\\alpha^2,\\ldots,\\alpha ^{\\left| F \\right| -2}\\right\\} \n\t\\end{align*}\n\tand \\(\\alpha ^{\\left| F \\right| -1} = 1\\)\n\\end{thm}\n\\begin{thm}[Finite Field Extensions]\n\tFor all finite fields \\(F\\),there exists an \\(H\\leq F\\) such that \\(H \\cong \\Z_p\\) for some \\(p\\). Furthermore, \\(F\\) is a vector space over \\(\\Z^{p}\\).\n\\end{thm}\n\\(F\\) is then a field extension of \\(H\\).\nConsider\n\\begin{align*}\n\tH = \\left\\{ 0,1,1+1,\\ldots,\\underbrace{1+\\ldots+1}_{p-1} \\right\\} \n\\end{align*}\nObserve that adding and multiplying elements works like traditional addition and subtraction; namely that\n\\begin{align*}\n(t\\cdot 1)+(s\\cdot 1) = (s+t) \\pmod p \\cdot 1\n\\end{align*}\nfor \\(0\\leq t\\leq p-1\\) and\n\\begin{align*}\n\t(\\underbrace{1+\\ldots+1}_t)\\cdot (\\underbrace{1+\\ldots+1}_s) = ( ts) \\pmod p \\cdot 1\n\\end{align*}\nand so the isomorphism to \\(\\Z_p\\) holds, as all the elements can then be written by multiplication of \\(0\\leq t\\leq p-1\\) and \\(1\\).\n\\begin{thm}\n\tFor any finite field \\(F\\), \\(F \\cong \\Z_{p[x]} / (g)\\) where \\(g\\) is a polynomial over \\(\\Z_p\\), \\( \\textrm{deg }g = k\\), \\(g\\) irreducible over \\(\\Z_p\\)\n\\end{thm}\n\\end{document}\n", "meta": {"hexsha": "3bb4f0b3a11bc72757d2282b268d733573ac759c", "size": 3722, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/2020-03-11-FiniteFields.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/2020-03-11-FiniteFields.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/2020-03-11-FiniteFields.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2954545455, "max_line_length": 258, "alphanum_fraction": 0.6386351424, "num_tokens": 1367, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.44793890486833515}}
{"text": "%\\documentclass[letterpaper,12pt]{report}\n\\documentclass[letterpaper,12pt]{article}\n\n% set 1\" margins on 8.5\" x 11\" paper\n% top left is measured from 1\", 1\"\n\\topmargin 0in\n\\oddsidemargin 0in\n\\evensidemargin 0in\n\\headheight 0in\n\\headsep 0in\n\\topskip 0in\n\\textheight 9in\n\\textwidth 6.5in\n\n\n% Packages\n%\\usepackage{graphicx}\n\\usepackage{tikz,pgfplots}\n\\pgfplotsset{compat=1.15}\n\\usepackage{amsmath}\n\\usepackage[version=4]{mhchem}\n\\usepackage{siunitx}\n\\usepackage{esvect}\n\n\n% Configuration\n% Unit display preferences\n\\sisetup{per-mode = symbol-or-fraction,inter-unit-product = \\ensuremath{{}\\cdot{}}}\n%\\sisetup{per-mode = fraction,inter-unit-product = \\ensuremath{{}\\cdot{}}}\n\n\\begin{document}\n\\pagestyle{plain}\n%\\markright{Valuation}\n\n\\title{PHYS212 - Chap 21 Notes - Coulomb's Law}\n\\author{Sam Nelson}\n\\date{5/6/2020}\n\\maketitle\n\n\\setcounter{tocdepth}{1} % whether to display sub- or subsubsections in toc\n\\tableofcontents\n\n% set these after the TOC\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{1em}\n\\setlength\\arraycolsep{2pt}\n\n\n\\section{Introduction}\n\n\\textit{Electrostatic force exerted by charged particles}\n\nCharles-Augustin de Coulomb - 1785\n\nThe mathmatical form of the law (vector):\n\n\\begin{equation} \\label{x1}\n\t\\vec{F} = k\\frac{q_1 q_2}{r^2}\\hat{r}\n\\end{equation}\n\nWhere:\n\n\\begin{tabular}{l|l}\n\t$q_1$ & Charge 1 \\\\\n\t$q_2$ & Charge 2 \\\\\n\t$r$ & Particle separation \\\\\n\t$\\hat{r}$ & Unit vector \\\\\n\t$k$ & Electrostatic/Coulomb Constant \\\\\n\\end{tabular}\n\nNote the similarity between Coulomb's law and Newton's equation for the gravitational force between two particles\n\n\\begin{equation}\n\t\\vv*{F} = G\\frac{m_1 m_2}{r^2}\\hat{r}\n\\end{equation}\n\nThe unit of charge is known as a \\textit{Coulomb} and is defined in relation to the \n\\textit{Ampere}\n\n\\begin{equation} \\label{x2}\n\ti = \\frac{dq}{dt}\n\\end{equation}\n\nIn this case, current is defined as the rate at which charge moves past a point or region.\n\nRe-arranging, the units are related as so:\n\n\\begin{equation}\n\t1C = 1A \\times 1s\n\\end{equation}\n\nThe magnitude of the electrostatic force is represented by:\n\n\\begin{equation}\n\tF = \\frac{1}{4\\pi\\epsilon_0}\\frac{|q_1||q_2|}{r^2}\n\\end{equation}\n\n\nwhere $k = \\frac{1}{4\\pi\\epsilon_0} = \\SI{8.99e9}{\\newton\\meter\\squared\\per\\coulomb\\squared}$\n\nor\n\n\\begin{equation}\n\tk = \\frac{1}{4\\pi\\epsilon_0} = \\SI{8.99e9}{\\newton\\meter\\squared\\per\\coulomb\\squared}\n\\end{equation}\n\nwith $\\epsilon_0$ known as the \\textit{Permittivity constant}\n\\begin{equation}\n\t\\epsilon_0 = \\SI{8.85e-12}{\\coulomb\\squared\\per\\newton\\meter\\squared}\n\\end{equation}\n\nPrinciple of superposition. To find the net force on a particle, sum all the forces acting on that\nparticle.\n\n\\begin{equation}\n\t\\vec{F_{1,net}} = \\vec{F_{12}} + \\vec{F_{13}} + \\vec{F_{14}} + \\vec{F_{15}} + \\cdots + \\vec{F_{1n,}}\n\\end{equation}\n\n\\begin{equation}\n\t\\vv*{F}{1,\\text{net}} = \\vv*{F}{12} + \\vv*{F}{13} + \\vv*{F}{14} + \\vv*{F}{15} + \\cdots + \\vv*{F}{1n,}\n\\end{equation}\n\n%\\begin{figure}[h]\n%\t\\centering\n%\t\\includegraphics[scale=0.8]{sine}\n%\t\\caption{$\\sin(x)$}\n%\t\\label{sine}\n%\\end{figure}\n\n%\\begin{tikzpicture}\n%\t\\begin{axis}[domain=3/4:5/4,legend pos=outer north east,trig format plots=rad]\n%\t\t\\addplot {sin(2*pi*x)}; \n%\t\t\\addplot {cos(2*pi*x)}; \n%\t\t\\legend{$\\sin(2 \\pi x)$,$\\cos(2 \\pi x)$}\n%\t\\end{axis}\n%\\end{tikzpicture}\n\n\\paragraph{Shell theory 1} A charged particle outside a shell with charge uniformly distributed on its surface is attracted to or repelled as if the shell's charge were concentrated as a particle at its center.\n\n\\paragraph{Shell theory 2} A charged particle inside a shell with charge uniformly disributed on its surface has no net force acting on it due to the shell.\n\n\\begin{tikzpicture}\n\\begin{axis}[\n  axis lines=middle,\n  grid=major,\n  xmin=-5,\n  xmax=5,\n  ymin=-3,\n  ymax=5,\n  xlabel=$x$,\n  ylabel=$y$,\n  xtick={-4,-3,...,4},\n  ytick={-2,-1,...,4},\n  tick style={very thick},\n  legend style={\n  at={(rel axis cs:0,1)},\n  anchor=north west,draw=none,inner sep=0pt,fill=gray!10}\n]\n\\addplot[blue,thick,samples=100] {x^2};\n\\addlegendentry{$y=x^2$}\n\\end{axis}\n\\end{tikzpicture}\n\n\\begin{tikzpicture}\n\\begin{axis}[\n  axis lines=middle,\n  grid=major,\n  xmin=-2,\n  xmax=2,\n  ymin=-2,\n  ymax=2,\n  xlabel=$x$,\n  ylabel=$y$,\n  xtick={-2,-1,...,2},\n  ytick={-2,-1,...,2},\n  tick style={very thick},\n]\n\\draw [->,very thick,teal] (0,0) -- node[above] {$\\vv*{F}{1}$} (2,1);\n\t\\draw [->,very thick,red] (0,0) -- node[below,left] {$\\vv*{F}{2}$} (-1,2);\n\\end{axis}\n\\end{tikzpicture}\n\n\\section{Quantization of Charge}\n\nAny positive or negative charge $q$ that can be detected, can be written as\n\n\\begin{equation}\n\tq = ne, \\quad n = \\pm 1, \\pm 2, \\pm 3, \\dots ,\n\\end{equation}\n\nIn which $e$, the \\textbf{elementary charge,} has the approximate value\n\n\\begin{equation}\n\te = \\SI{1.602e-19}{\\coulomb}\n\\end{equation}\n\n\\section{Conservation of Charge}\n\nCharge is not created or destroyed, it is transfered. This hypothesis is known as \\textbf{conservation of charge}.\n\\\\\nAn example is the radioactive decay of uranium-238 ($\\ce{^{238}_{}U}$).\n\n\\begin{equation}\n\t\\ce{^{238}_{}U -> ^{234}_{}Th + ^{4}_{}He,}\n\\end{equation}\n\nThe \\textit{parent} nucleus $\\ce{^{238}_{}U}$ contains 92 protons, with a charge of $+92e$, the \\textit{daughter} nucleus \\ce{^{234}_{}Th} contains 90 protons, with a charge of $+90e$ and the emitted alpha particle \\ce{^{4}_{}He} contains 2 protons, with a charge of $+2e$. Total charge is $+92e$ before and after the decay, thus charge is conserved.\n\\\\\nAnother example of this charge conservation is when an electron $\\mathrm{e}^-$ (charge $-e$) and its antiparticle, the \\textit{positron} $\\mathrm{e}^+$ (charge $+e$), undergo an \\textit{annihilation process}, transforming into two \\textit{gamma rays}:\n\n\\begin{equation}\n\te^- + e^+ \\longrightarrow \\gamma + \\gamma \\quad \\text{(annihilation).}\n\\end{equation}\n\nIn \\textit{pair production}, charge is also conserved. Example, a gamma ray transforming into an electron and a positron:\n\n\\begin{equation}\n\t\\gamma \\longrightarrow e^- + e^+ \\quad \\text{(pair production).}\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "e581054d35e2ce44886e59c72ed22ea3b0af3b4b", "size": 6020, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chap21/chap21-coulombs_law.tex", "max_stars_repo_name": "sanelson/phys_review", "max_stars_repo_head_hexsha": "14c566d8c8c1db153edfd03662c5425da4975223", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chap21/chap21-coulombs_law.tex", "max_issues_repo_name": "sanelson/phys_review", "max_issues_repo_head_hexsha": "14c566d8c8c1db153edfd03662c5425da4975223", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chap21/chap21-coulombs_law.tex", "max_forks_repo_name": "sanelson/phys_review", "max_forks_repo_head_hexsha": "14c566d8c8c1db153edfd03662c5425da4975223", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1171171171, "max_line_length": 350, "alphanum_fraction": 0.6915282392, "num_tokens": 2144, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.4479388906967649}}
{"text": "\n\\section{The \\isheapuntil algorithm}\n\\Label{sec:isheapuntil}\n\nThe \\isheapuntil algorithm of the \\cxx Standard Library \\cite[\\S\n28.7.7.5]{cxx-17-draft} works on generic sequences. \nFor our purposes we have modified the generic implementation\nto that of an array of type \\valuetype.\nThe signature now reads:\n\n\\begin{lstlisting}[style = acsl-block]\n\n    size_type is_heap_until(const value_type* a, int n);\n\\end{lstlisting}\n\nThe algorithm \\isheapuntil returns the largest range of an array, beginning at the first position, where it still satisfies the heap properties\nwe have semi-formally described in the beginning of this chapter.\nIn particular, \\isheapuntil will return the size of the array,\ncalled with the array argument from Figure~\\ref{fig:heap-array}.\n\n\\clearpage\n\n\\subsection{Formal specification of \\isheapuntil}\n\nThe specification of \\isheapuntil is shown in the following listing.\nThe index \\inl{\\\\result} returned by \\isheapuntil indicates\nthat the array \\inl{a[0..\\\\result-1]} is a heap.\nIn addition the postcondition \\inl{last} states, that for all indices\ngreater than or equal to \\inl{i} the predicate \\logicref{Heap} is not satisfied.\n\n\\input{Listings/is_heap_until.h.tex}\n\n\\subsection{Implementation of \\isheapuntil}\n\nThe following listing shows one way to implement the function \\isheapuntil.\n\n\\input{Listings/is_heap_until.c.tex}\n\nThe algorithms starts at the index~1, which is the smallest index,\nwhere a child node of the heap might reside.\nThe algorithms checks for each (child) index whether\nthe value at the corresponding parent index \nis greater than or equal to the value at the child index.\nIf the value at a parent index is smaller than the value at a (child) index,\n\\isheapuntil returns the (child) index.\nOtherwise, if the algorithm iterates through the whole array,\nthe size of the array is returned.\n", "meta": {"hexsha": "3645da50479dd938280d90ae4e72f60c4752645e", "size": 1835, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/heap/is_heap_until.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/heap/is_heap_until.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/heap/is_heap_until.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 38.2291666667, "max_line_length": 143, "alphanum_fraction": 0.7858310627, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.4478239413952661}}
{"text": "% -----------------------------------------------\n% Template for ISMIR Papers\n% 2018 version, based on previous ISMIR templates\n\n% Requirements :\n% * 6+n page length maximum\n% * 4MB maximum file size\n% * Copyright note must appear in the bottom left corner of first page\n% * Clearer statement about citing own work in anonymized submission\n% (see conference website for additional details)\n% -----------------------------------------------\n\n\\documentclass{article}\n\\usepackage{ismir,amsmath,cite,url}\n\\usepackage{graphicx}\n\\usepackage{color}\n\n\n% Title.\n% ------\n\\title{GraphDitty: A Software Suite for Geometric Music Structure Visualization}\n\n% Note: Please do NOT use \\thanks or a \\footnote in any of the author markup\n\n% Single address\n% To use with only one author or several with the same address\n% ---------------\n\\oneauthor\n {Christopher J. Tralie}\n {Duke University Department of Mathematics}\n\n\n\n\\sloppy % please retain sloppy command for improved formatting\n\\graphicspath{{Figures/}}\n\n\\begin{document}\n\n%\n\\maketitle\n%\n\\begin{abstract}\n    In this work, we present a new twist on music structure analysis and visualization.  We devise a technique\\footnote{This is a refinement of / followup to our prior works ``scaffolding and spines'' \\cite{bendichgeometric} and ``Loop Ditty'' \\cite{tralie2017Dissertation}} to create clean audio self-similarity matrices at the song level by fusing multiple features upstream.  We then derive multiple geometric features from this representation to elucidate hierarchical structure, including Laplacian eigenvectors, spring graph layouts, and diffusion maps.  We then provide a suite of Javascript visualization tools to view the SSMs and derived features synchronized with the audio they represent.  Our code is clean with the help of Numpy/Scipy/Librosa on the Python end and d3.js on the Javascript end, but it can be treated as a blackbox for users who would like to engage with the visualizations without delving into the technical details.  Code can be found at \\url{http://www.github.com/ctralie/GraphDitty}, and a live demo is present at \\url{http://www.covers1000.net/GraphDitty}.\n\\end{abstract}\n\n\n\\section{Similarity fusion}\\label{sec:fusion}\n\nThe self-similarity matrix (SSM) is a common data structure through which to visualize recurrence in musical audio.  For a particular feature type, the SSM is a symmetric distance matrix $D$ which records all pairwise distances between windows in time, as measured by that feature.  Let $D^C$ be a matrix measuring the cosine distance between stacked-delayed\\footnote{We use stack-delayed features to promote diagonal structures, as shown in \\cite{tralie2017quasi}}\\cite{serra2009cross} chroma features, and let $D^M$ be a matrix measuring the Euclidean distance between stack-delayed MFCCs.  The we can apply a {\\em similarity kernel} to each of them so that $W^C_{ij} = \\exp (-(D^C_{ij})^2 / (2 \\sigma_{ij}^2) )$, and likewise for $W^M$ for $D^M$, where $\\sigma_{ij}$ is a mutual nearest neighbor autotuned distance (see \\cite{wang2012unsupervised, wang2014similarity} for more details); that is, large values indicate more similar  windows.  We then run a graph-based algorithm known as {\\em similarity network fusion (SNF)}\\cite{wang2012unsupervised, wang2014similarity, Chen2017CSFusion}  to create an aggregated similarity kernel $W^F$ from $W^C$ and $W^M$, which promotes the strengths of both feature types and mitigates their weaknesses.  This is similar to what we did for cover songs in \\cite{tralie2017cover}, though it works on self-similarity instead of cross-similarity, and it does not require beat-synchronous features.  We can also compute eigenvectors of the graph laplacian on $W^F$ indicator functions of hierarchical structural elements, as in \\cite{mcfee2014analyzing}.  This combination of stacked delay embeddings and SNF can be viewed as a more general, global alternative to similarity diagonal promotion which has previously been used to preprocess the graph Laplacian \\cite{mcfee2014analyzing}.  As can be seen in Figures~\\ref{fig:SSMFused} and ~\\ref{fig:SSMChroma}, it at least qualitatively does a much better job at making clean similarity matrices and Laplacian eigenvectors than Chroma by itself.\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.85\\columnwidth]{SimilarityMatrix_Laplacian.pdf}\n    \\caption{Similarity matrix $W^F$ and Laplacian eigenvectors after applying similarity network fusion to stack-delayed Chroma and MFCC features for the song ``Smooth Criminal'' by Michael Jackson.  The SSM and eigenvectors are much cleaner than those with just raw chroma in Figure~\\ref{fig:SSMChroma}.}\n    \\label{fig:SSMFused}\n   \\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.85\\columnwidth]{SimilarityMatrix_Chroma.pdf}\n    \\caption{Similarity matrix $W^C$ using the cosine distance on stack-delayed Chroma features, along with the corresponding weighted Laplacian eigenvectors.  While the stacked delay embedding helps diagonals to appear which indicate repeated structure, it is not as clean as the fused SSM in Figure~\\ref{fig:SSMChroma}.}\n    \\label{fig:SSMChroma}\n\\end{figure}\n   \n\n\n\n\\section{Visualizing Time-Ordered Similarity}\n\n\\begin{figure}\n    \\includegraphics[width=\\columnwidth]{ForceGraph.pdf}\n    \\caption{A dynamic weighted spring layout based on the weights in Figure~\\ref{fig:SSMFused}, which is rendered with the help of d3.js \\cite{bostock2012d3}.}\n    \\label{fig:ForceGraph}\n\\end{figure}\n   \n   \n   \n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.8\\columnwidth]{DiffusionMaps.pdf}\n    \\caption{3D Diffusion maps rendered by WebGL, synchronized to the music.}\n    \\label{fig:DiffusionMaps}\n\\end{figure}\n\nThe first facet of our GUI simply allows the user to view audio synchronized with the SSM, but enables a powerful way to visualize and jump between repeated elements in the song\\footnote{This is similar to the cross-similarity GUI viewer we created for cover songs \\cite{tralie2017cover}.}.  The second visualization performs a spring layout of the weighted graph induced from $W^F$, with the help of d3.js \\cite{bostock2012d3}, as shown in Figure~\\ref{fig:ForceGraph}.  Since we have applied a similarity kernel, the spring constant is proportional to how similar windows are; the simulation encourages more similar windows to be closer together.  Note that the simulation is dynamic; nodes in the graph can be moved around, and the simulation will settle in a local min of energy. Finally, we present a GUI for showing music synchronized to 3D diffusion maps \\cite{coifman2006diffusion}.  This is the most similar GUI to our previous ``Loop Ditty'' GUI\\cite{tralie2017Dissertation}, though it works purely on similarity information and not on coordinates in feature space, so it is much more general.\n\n\nIn future work, we would like to explore all of these structures for pruning in large scale audio cover song identification, similar to the aligned hierarchies work \\cite{kinnaird2016aligned} on symbolic cover song identification.\n\n\n% For bibtex users:\n\\small\n\\bibliography{main}\n\n\n\\end{document}\n", "meta": {"hexsha": "08ab2a573cf4ceabb5a53289bab2b9139803ef1d", "size": 7110, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper_ISMIR2018_LateBreaking/main.tex", "max_stars_repo_name": "florianthalmann/GraphDitty", "max_stars_repo_head_hexsha": "df32f8373d90fd8fd197d7c0fcd23b9f3be98b02", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2018-02-14T19:57:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T21:23:18.000Z", "max_issues_repo_path": "Paper_ISMIR2018_LateBreaking/main.tex", "max_issues_repo_name": "florianthalmann/GraphDitty", "max_issues_repo_head_hexsha": "df32f8373d90fd8fd197d7c0fcd23b9f3be98b02", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-10-31T06:33:07.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-07T13:24:21.000Z", "max_forks_repo_path": "Paper_ISMIR2018_LateBreaking/main.tex", "max_forks_repo_name": "florianthalmann/GraphDitty", "max_forks_repo_head_hexsha": "df32f8373d90fd8fd197d7c0fcd23b9f3be98b02", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-02-14T18:07:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T05:28:17.000Z", "avg_line_length": 72.5510204082, "max_line_length": 2030, "alphanum_fraction": 0.7713080169, "num_tokens": 1761, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.44782393800718806}}
{"text": "\\documentclass{article}\r\n\\usepackage[utf8]{inputenc}\r\n\\usepackage[letterpaper, margin=1in]{geometry}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb }\r\n\r\n\\title{CS5820 HW9}\r\n\\author{Renhao Lu, NetID: rl839}\r\n\t\r\n\\begin{document}\r\n\t\\maketitle\r\n\t\r\n\t\\section{NP-Complete proof sketches}\r\n\t\\subsection{UNSAT}\r\n\tThe approach is not correct. Because UNSAT is not a NP problem. No matter which certificate we are provided, we can not prove that there is no other input that make $\\Phi$ true. \r\n\t\\subsection{Magnet Problem}\r\n\tThe approach is correct. The complete proof is in below:\r\n\t\\subsubsection{Magnet problem is in NP}\r\n\tCertificate: a set of strings (may contain replicate strings)\\\\\r\n\tCheck: if the set of strings used up all symbols in the symbol collection, the answer is yes. If the number of strings is $a$ and the number of symbols is $b$, the checking time is $n(ab)$, which is polynomial.\r\n\t\\subsubsection{Reduce Hamilton Cycle problem to Magnet problem}\r\n\t\\paragraph{Convert input}\r\n\tGiven a directed graph $G=(V,E)$. For every node $v\\in V$, create two letters $v_1,v_2$. For every edge $(u,v)\\in E$, create a string $u_2v_1$.\r\n\t\\paragraph{Convert output}\r\n\tIf Magnet problem has a yes answer, Hamilton cycle problem has a yes answer. Otherwise, the answer of Hamilton cycle problem is no.\r\n\t\\paragraph{Running time}\r\n\tAssume $|V|=n$, $|E|=m$. We will create $2n$ symbols and $m$ strings, and the length of all strings are $2$. Hence, the total running time is $O(n+m)$, which is polynomial.\r\n\t\\paragraph{Correctness}\r\n\tWe will prove that the yes/no answer of magnet problem is equivalent to the answer of Hamilton problem.\\\\\r\n\tIf Hamilton problem has a solution, we note this cycle $C=\\{(v_1,v_2),(v_2, v_3),...,(v_n,v_{n-1})\\}$ where $V=\\{v_1, v_2,...,v_n\\}$. We know that for each node $v_i\\in V$, exist exactly two edges $(v_i,v_j),(v_{j'},v_i)\\in C$. Then we created symbols $v_{i1},v_{i2}$ and strings as we previously described. Here, for each edge $(v_i,v_j)\\in C$, we add the string $v_{i2} v_{j1}$ into our collection. Because each node $v_i$, appeared twice in two different edge at left side and right side respectively, each symbol $v_{i1},v_{i2}$ must appear in the string collection exactly once. Meanwhile, all symbol must have been used because Hamilton cycle must travel throught all nodes. Hence, the string collection would be a solution for Magnet problem. \\\\\r\n\tIf the Magnet problem has a solution, we note the alphabet as $A=\\{v_{11}, v_{12}, v_{21}, v_{22},...,v_{n1},v_{n2}\\}$ the solution string collection $S=\\{v_{i2}v_{j1}, v_{i'2}v_{j'1},...\\}$. For each symbol, we have exactly one \"amgnet\", so each symbol must appear exactly once in $S$. So we know for each $v_{i1} and v_{i2}$, exist one string $v_{j2}v_{i1}$ and $v_{i2}v_{j'1}$ in $S$. Hence, we pick one random symbol $v_{i_2}$ as the start point and reorginze $S$ in a end-to-end pattern as following: $\\{v_{i2}v_{j1}, v_{j2}v_{k1},...,v_{p2}v_{t1},v_{t2}v_{i1}\\}$. Then we create a cycle as for the solution for Hamilton cycle problem: $C=\\{(v_i, v_j),(v_j,v_k),...,(v_p, v_t),(v_t,v_i)\\}$. This cycle doesn't have any replicates because no replicates exists in $S$. Meanwhile $C$ covers all nodes because $S$ covers all symbols in $A$. Hence $C$ is a correct solution for Hamilton problem. \r\n\t\r\n\t\\subsection{Subway Riding}\r\n\tThe apporach is not correct. From the porblem we can know that $\\sum_{i=1}^n {w_i}\\geq W$. Hence createing $n$ cycles will need totally $(\\sum_{i=1}^n {w_i}) -n+1$ nodes in $G$. Creating new graph $G$ will take at least $O(W-n)$, which is not polynomial time.\r\n\t\r\n\t\\section{Disrupting an Enemy's Railway Network II}\r\n\tRailway problem is in P, and it can be reduced to the original railway disruption problem. \r\n\t\\paragraph{Step 1: convert input}\r\n\tGiven the input of the railway problem directed graph $G=(V,E)$, $h\\in V$, $T\\subseteq V$, and integer $k<|T|$. We create a new directed graph $G'=(V',E')$ for the input of original railway problem. We first add $h$ to $V'$. Then For each node $v_i\\in V (v_i\\neq h)$, we add two nodes $v_{i-in}, v_{i-out}$ into $V'$, and we add edges $(v_{i-in}, v_{i-out})$ to $E'$ with capacity $c_e=1$. For each edge $(v_i, v_j)\\in E$, we add edge $(v_{i-out},v_{j-in})$ into $E'$ with capacity $c_e=+\\infty$. For all $v_i\\in T$, we add $v_i-out$ to $T'$. And we set all $w_i=+\\infty$ for $v_{i-out}\\in T'$. Then we pass the directed graph $G'$, the capacity of the edges $\\{c_e\\}$, set $T'$, and $\\{w_i\\}$ as the input of the oringinal railway problem. Because all $w_i=+\\infty$, we only need to find the minimized $\\sum_{c\\in F}{c_e}$ in the original railway problem.\r\n\t\\paragraph{Step 2: convert output}\r\n\tWe note the output of the original railway problem is a set $F$ of edges to be destroyed. If $|F|\\leq k$, the answer for the railway problem II is yes. Otherwise, the answer is no.\r\n\t\\paragraph{Step 3: Running time}\r\n\tAssume for the input of railway problem II $G=(V,E)$, $|V|=n,|E|=m, |T|=p<n$. \\\\\r\n\tConverting input: in $G'=(V',E')$, $|V'|=2n-1$, $|E'|=m+n-1$, so building up the graph and setting the edge capacities will take $O(m+n)$. Initializing $|T'|$ and $\\{w_i\\}$ takes $O(p)<O(n)$, so toal would still be $O(m+n)$\\\\\r\n\tConverting output: Getting the output $F$ size can take at most $O(m+n)$, and comparing size with $k$ is $O(1)$. So total is $O(m+n)$\\\\\r\n\tFind the solution for the original railway problem I: The maximum possible flow in equal to $|T'|=|T|=p$. So the running time for the original railway problem is $O(|E'|p)=O((m+n)p)<O((m+n)n)$.\\\\\r\n\tThe total running time of this reductions is $O(m+n)+O(m+n)+O((m+n)n)=O((m+n)n)$, which is polynomial.\r\n\t\\paragraph{Step 3: Correctness}\r\n\tWe claim that $|F|\\leq k$ from the original railway problem is equivalent to the yes answer in the railway problem II.\\\\\r\n\t1. If $|F|\\leq k$ from the original railway problem I, we can prove that railway problem II have a solution. We can first claim that All edges in $F$ is $(v_{i-in},v_{i-out})$ and doesn't contain any edge like $(v_{i-out},v_{j-in})$, because all edges $(v_{i-out},v_{j-in})$ has a capacity of $+\\infty$, and they cannot be seperated by minimum s-t cut. Then we create a set of node $Q$, and add each $v_i$ if $(v_{i-in},v_{i-out})\\in F$. We can tell that $|Q|=|F|\\leq k$. Because $w_i=+\\infty$, all terminal nodes must be disconnected. So $Q$ is a solution for railway problem II. \\\\\r\n\t2. If railway problem II has a solution, we can prove that the solution $|F|$ not larger than $k$. We note $Q=\\{v_{i1},v_{i2},...,v_{ik}\\}$ is a set of statations as the solution of railway problem II. Then we set $F_1=\\{(v_{i1-in},v_{i1-out}),(v_{i1-in},v_{i1-out}),...,(v_{ik-in},v_{ik-out})\\}$. Because in railway problem II, disabling the statations in $Q$ can disconnect all terminals in $T$, destroying edges in $F_1$ can disconnect all terminals in railway problem I as well. Because for all $(v_{i-in},v_{i-out}), c_e=1$, $|F|_{optimal}=min\\{\\sum_{c\\in F}{c_e}\\}\\leq \\sum_{c\\in F_1}{c_e}=|F_1|=k$. Hence the optimal $|F|\\leq k$,\r\n\t\\section{Side gig problem}\r\n\t\\subsection{Side gig problem is in NP}\r\n\tCertificate: a set of jobs you plan to do during the summber $J={i_1,i_2,i_3,...}$\\\\\r\n\tCheck: If for any two $i,j\\in J, D_i\\cap D_j=\\O$, and $\\sum_{i\\in J}{p_i}\\geq C$, the answer is yes.\r\n\t\\subsection{Reduce independent set problem to side gig problem}\r\n\t\\paragraph{Convert input}\r\n\tGiven the input of independent set problem, undirected graph $G=(V,E)$ and integer $k$. We assume $V={1,2,3,...,n},|V|=n$ and $E={e_1,e_2,...,e_m}, |E|=m>n$. Then we create $n$ jobs, each job $i'$ corresponds to a node $i\\in V$, and each job has the same payment $p_i=1$. Then we set summer break as $m$ days. For each edge $e_p=(i,j)\\in E$, we add day $p$ into $D_i$ and $D_j$. At last we set the credit card debit $C=k$. Now we can pass $n,m,{D_i}, C$ as the input of side gig problem.\r\n\t\\paragraph{Convert output}\r\n\tIf the answer of side gig problem is yes, the output of independent set is also yes. Otherwise, the output of independent set is no.\r\n\t\\paragraph{Running time}\r\n\tConverting input: Creating new job set, takes $O(n)$. Creating m days of summer break takes $O(m)$. Setting up ${D_i}$ need to update 2 times for each edge, so takes $O(2m)=O(m)$. Hence, converting input totally take $O(n+m)$, which is polynomial. \r\n\t\\paragraph{Correctness}\r\n\tWe claim that the answer of independent set problem is equivalent to the answer of side gig problem.\\\\\r\n\t1. If independent set problem has a solution, we note this solution as set $S={i_1, i_2,...,i_k}$, then we create a job set $P={i_1',i_2',...,i_k'}$. The total payment $\\sum_{i\\in P}{p_i}=k=C$, hence the credit card debit can be paied off. Meanwhile, because in the independent set $S$, no two node share one edge, we know that in $P$, no two jobs share a same day. Hence, we know set $P$ is a solution for the side gig problem. \\\\\r\n\t2. If the side gig problem has a solution, we note this soltion as a set of jobs $P={i_1',i_2',i_3',...,i_k',...}$. Becasue the debit $C=k$, $|P|\\geq C=k$. We select the first $k$ members in $P$ and transfor the jobs into another set of node which the jobs are corresponding to, $S={i_1,i_2,...,i_k}, |S|=k$. We claim that $S$ is an independent set because if some two nodes $i,j\\in S$ and $(i,j)=e_p\\in E$, $D_i\\cap D_j ={p}\\neq \\O$, which is a contradiction. Hence, $P$ is a solution for independent set problem. \r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "6b9eafc6577806b746b1258803ab8201d477c02c", "size": 9399, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CS5820 HW-9.tex", "max_stars_repo_name": "lurenhaothu/CS4820", "max_stars_repo_head_hexsha": "a656d336e60e2f6b4416574cc518486945f1c93f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CS5820 HW-9.tex", "max_issues_repo_name": "lurenhaothu/CS4820", "max_issues_repo_head_hexsha": "a656d336e60e2f6b4416574cc518486945f1c93f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CS5820 HW-9.tex", "max_forks_repo_name": "lurenhaothu/CS4820", "max_forks_repo_head_hexsha": "a656d336e60e2f6b4416574cc518486945f1c93f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 136.2173913043, "max_line_length": 898, "alphanum_fraction": 0.6910309607, "num_tokens": 2971, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.4478239346191099}}
{"text": "\\documentclass[a4paper,11pt]{book}\n\\usepackage{import}\n\\usepackage{preamb}\n\n\\makeindex\n\n\\begin{document}\n\n\\input{head}\n\\newpage\n\\input{Title}\n% \\section{Blocks and Community structure}\n\n\n\\begin{subbox}{subbox}{}\n\\centering\n\\Large{\\textbf{Graph/Node embedding}}\n\\end{subbox}\n\n\n\\begin{subbox}{subbox}{Disclaimer}\nGraph/Node embeddings are a recent field of research, with hundreds of publications in the last few years, and scores of new papers published in every machine learning and network science conference. This class is thus only an introduction to the mechanism underlying those approaches.\n\\end{subbox}\n\n\n\\begin{textbox}{Embedding of networks}\nIn the context of \\textbf{graph embedding}, embedding is a shortcut for \\textbf{embedding in low dimensions}, and can be understood as assigning to some \\textbf{elements} of the graph a \\textbf{vector} (i.e., a list of numbers) composed of \\textbf{d} elements. \\textbf{d} is the number of dimensions in the embedding space, and \\textbf{d} should be small.\n\\end{textbox}\n\n\\begin{textbox}{Types of Network Embedding}\nAccording to the type of element which is embedded, we can differentiate:\n\\begin{itemize}\n    \\item Node Embedding (one vector per node)\n    \\item Edge Embedding (one vector per edge)\n    \\item Substructure Embedding (e.g., one vector per community)\n    \\item Whole Graph Embedding (one vector per graph)\n\\end{itemize}\n\nIn this class, we will introduce only Node Embedding, which is the most popular approach.\n\nWhole graph embedding is also quite popular, for instance to classify types of networks.\n\\end{textbox}\n\n\n\\begin{textbox}{Node Embedding}\nIn \\textbf{node embedding}, the vector assigned to each node should be a proxy, a sort of numeric summary of the position of the node in the graph, in term of topology. Several types of embeddings exist that capture different aspects of the network topology, in particular we will differentiate \\textit{locational embedding} from \\textit{role embedding}. Note that node embedding is sometimes called \\textbf{graph embedding} in the literature.\n\\end{textbox}\n\n\\begin{textbox}{Embedding distance}\nSince each node is represented by a vector, it is possible to compute a \\textbf{distance between nodes} in the embedding. Intuitively, two nodes occupying similar positions in the network (according to what the chosen embedding capture) should have similar embedding vectors. The notion of distance to use (cosine, euclidean, etc.) also depends on the chosen embedding.\n\\end{textbox}\n\n\\begin{textbox}{Adjacency matrix(A) as an embedding}\nA naive way to choose an embedding (in $n$ dimensions) could be to consider each row of the adjacency matrix as the vector representation of the node it corresponds to. \n\nThis embedding would capture what is called the \\textbf{structural equivalence}, i.e. the fact that nodes share similar neighborhoods. Two nodes with the same neighborhoods would have the same vectors. If the \\textit{Manhattan distance} were used, the distance between nodes in the embedding would correspond to the number of different neighbors.\n\\end{textbox}\n\n\\begin{textbox}{What is a good embedding?}\nWhat is a good embedding depends on the task that we want to achieve. In the perspective of this class, embeddings are mostly used as features for machine learning tasks. As such, they must be 1) In as few dimensions as possible: Machine learning suffers from what is known as the \\textbf{curse of dimensionality}, and tends to work better with lower dimensions, without talking about computational advantages. 2) As dense as possible. Sparsity --usually associated with high dimensions-- makes learning harder.\n\nFurthermore, the embedded properties must be meaningful for the task to achieve. For instance, the notion of distance captured by the adjacency matrix seems in contradiction with the intuition: in graphs, one usually use the number of common neighbors, and/or normalized fraction of neighbors (Jaccard, etc.) rather than a raw count of different neighbors.\n\\end{textbox}\n\n\n\\begin{textbox}{Embedding and Dimensionality Reduction}\nIn Machine Learning, when a dataset is composed of too many features, \\textbf{dimensionality reduction} algorithms can be used to generate a smaller number of synthetic features, defined as combination of the original ones. Common algorithms to do so are for instance \\textbf{PCA} (Principal Component Analysis) and \\textbf{T-SNE}\\footcite{maaten2008visualizing}. \n\nA simple method to generate a better embedding from the adjacency matrix would be to apply Dimensionality Reduction on it to reduce its number of dimension. Its counter-intuitive definition of distance would nevertheless remain a problem. \n\\end{textbox}\n\n\n\n\\begin{textbox}{Notations}\n\\begin{tabular}{p{0.12\\textwidth}|p{0.8\\textwidth}}\\scriptsize\n$y$ & Embedding of the graph \\\\\n$y_i$ & Vector corresponding to node $i$ in the embedding $y$\\\\\n$S$ & Similarity matrix. For each pair of node $i,j$, $S_{ij}$ represents the graph similarity that we want to preserve. \n\\end{tabular}\nBy default, $S=A$: two nodes have a maximal similarity of 1 if they are connected, and similarity 0 if they are not connected. But one can use a different notion, such as a random walk distance, a neighborhood similarity heuristic, etc. \n\\end{textbox}\n\n\n\\begin{textbox}{Node Embedding: LE}\n\\textbf{Laplacian Eigenmaps} (LE)\\footnote{Belkin2003LaplacianEF} is a method that can be used for node embedding, whose objective function is defined as follows:\n\\[\ny=\\min \\sum_{i\\neq j}\\lVert y_i - y_j \\rVert ^2 S_{ij}\n\\]\nThis can be read as follows: to find the embedding $y$ of a graph, we need to assign an embedding $y_i$ to each node $i$ such as the sum (over all node pairs) of the equation $\\lVert y_i - y_j \\rVert ^2 S_{ij}$ is minimal.\nSaid differently, its objective is to minimize the product between the \\textbf{euclidean distance} in the embedding ($\\lVert y_i - y_j \\rVert ^2$) and the \\textbf{similarity} in the graph $S_{ij}$.\n\nIf two nodes are similar/close in the graph (high value), we need to make them as close as possible in the embedding (small value). Nodes dissimilar/distant in the graph can be distant in the embedding with a lesser penalty. To forbid a trivial solution of all nodes being on the same location, the sum of distance between points in the embedding must be equal to a constant.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Node Embedding: HOPE}\n\\textbf{Higher-Order Proximity preserved Embedding}  (HOPE)\\footnote{ou2016asymmetric} objective function is:\n\\[\ny=\\min \\sum_{i,j} |S_{ij}-y_i y_j^T |\n\\]\nSaid differently, its objective is to minimize the difference between the graph \\textbf{similarity} $S_{ij}$ and the similarity in the embedding, computed as the product of embedding vectors. Vectors are imposed to be normalized, thus $y_i y_j^T$ corresponds to the \\textit{cosine similarity}.\n\nTwo nodes close (resp. far) in the graph should therefore be close (far) in the embedding. Relative distances should also be conserved.\n\\end{textbox}\n\n\n\\begin{textbox}{LE - HOPE: Complexity}\nDiscovering the solution of LE and HOPE methods can be done efficiently using matrix decomposition approaches. For instance, finding the embedding according to LE in $d$ dimensions for the adjacency matrix can be formalized as finding the $d$ eigenvectors of lowest eigenvalues of $D^{-1/2}LD^{-1/2}$, with $D$ the degree matrix and $L$ the Laplacian matrix.\n\nThe computation of the $S$ matrix however, if it is not the adjacency matrix, can be costly since in the general case, it requires $n^2$ computations.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Random Walk NN based embedding}\nIn recent years, new approaches based on random walks and neural networks have encountered a large success and relaunched a large interest in graph embedding for various applications. They are transpositions of techniques developed for the embedding of words to the graph setting.\n\\end{textbox}\n\n\\begin{textbox}{Word Embedding}\nMachine Learning on text suffers from a problem similar to Machine Learning on graphs: words are not numbers and cannot be naturally represented as (meaningful) vectors. Word embedding objective is to assign a (low dimensional) vector to each word such as two words with \\textbf{similar semantic} have similar vectors.\n\\end{textbox}\n\n\\begin{subbox}{subbox}{Matrix decomposition and Eigenvectors}\nA diagonizable matrix $A$ can be factorized using eigenvectors as follows:\n\\[\n\\mathbf{A}=\\mathbf{Q}\\mathbf{\\Lambda}\\mathbf{Q}^{-1}  \n\\]\nwhere $Q$ is the  $n \\times n$ matrix whose $i$th column is the eigenvector $q_i$ of $A$, and $\\mathbf{\\Lambda}$ is the diagonal matrix whose diagonal elements are the corresponding eigenvalues, $\\mathbf{\\Lambda}_{ii} = \\mathbf{\\lambda}_i$. Keeping as embedding the eigenvectors associated with the largest eigenvalues means that we can reconstruct the original matrix with a good precision. This is the same method used by PCA (Principal Component Analysis), on a covariance(or correlation) matrix, which is also a form of similarity matrix.\n\\end{subbox}\n\n\\begin{textbox}{Word Embedding: word2vec - context}\nThe principle proposed in a famous method called word2vec is to use the context, i.e., the words encountered around a word in sentences of a corpus, to discover the semantic similarity. In summary, the more two words are encountered in a same context, the more they are considered similar. For instance, a corpus might contain sentences such as: \\textit{the dog eat dry food}, and \\textit{the cat eat dry food}: \\textit{cat} and \\textit{dog} are found in similar contexts, which should drive them closer in the embeddding. In other sentences, their contexts differs, which should drive them away in the embedding.\n\\end{textbox}\n\n\\begin{textbox}{Word Embedding: Skipgram/word2vec}\nIn practice, a word is considered to be in the context of another if it is at a distance less than $l$ in a sentence. From a corpus, one then extracts the probability $p(w_j|w_i)$ for each word $w_i$, that a word taken at random in its context is $w_j$.\n\nThe objective function of word2vec can be expressed as:\n\\[\ny=\\min \\sum_{(i,j)} p(w_j|w_i)-\\sigma(y_i y_j^T)\n\\]\nwith $\\sigma$ the softmax function defined as $\\frac{e^x}{\\sum e^x}$, a function commonly used in neural networks to add non-linearity while ensuring that the solution is a probability.\n\\end{textbox}\n\n\n\\begin{textbox}{Skipgram: a neural network formulation}\nThe skipgram algorithm is solved, in practice, using tools and methods of neural networks, which make it scalable to large datasets. It can then be represented as follows:\n\n\\centering\n\n\\colorbox{white}{\\includegraphics[width=0.8\\linewidth]{pics/skipgram.pdf}}\n\\end{textbox}\n\n\n\\begin{textbox}{Word2vec efficacy}\nWord2Vec (and following word embedding approaches) have encountered an enormous success in the Natural Language Processing domain, and its descendants are used for most practical tasks such as automatic language translation, sentiment analysis, personal assistants, etc.\n\nVarious other fields, including network science, have therefore adapted the mechanism to embed other complex items.\n\\end{textbox}\n\n\n\\begin{textbox}{DeepWalk}\nDeepWalk\\footcite{perozzi2014deepwalk} is the direct transcription of Word2vec to graphs. The principle is to generate random walks in the graph, playing the role of sentences in a corpus. The probability of finding a word in the vicinity of another therefore translates in the probability of encountering a node in a random walk from another.\n\nTo sum up, the objective function can now be expressed as:\n\\[\ny=\\min \\sum_{(i,j)} p(n_j|n_i)-\\sigma(y_i y_j^T)\n\\]\nwith $p(n_j|n_i)$ the probability to encounter node $n_j$ in a random walk of a chosen length starting from node $n_i$. Its objective is therefore to make the distance in the embedding proportional to a random walk based distance in the graph.\n\\end{textbox}\n\n\\begin{textbox}{DeepWalk complexity}\nContrary to matrix decomposition based approaches, DeepWalk do not requires explicitly a similarity matrix $S$. All pairs $(i,j)$ are obtain by $k$ random walks of length $l$ starting from each of the $n$ nodes. The complexity of obtaining the input data is therefore in $\\mathcal{O}(n)$ ($l$ and $k$ being small constants).\n\\end{textbox}\n\n\\begin{textbox}{Node2vec}\n\\textbf{Node2vec}\\footcite{grover2016node2vec} is a popular variant of DeepWalk, introducing \\textbf{biased random walks}. Two parameters guide the random walks: $p$ affect the probability to revisit the previous node, while $q$ affect the probability to explore farther nodes, i.e., nodes that were not neighbors of the origin node. It allows to mimic \\textbf{breadth-first} or \\textbf{depth-first} like exploration of the graph, capturing more local or more global network structures.\n\\end{textbox}\n\n\\begin{textbox}{Node2vec}\nIllustration of random walk procedure in node2vec. \n\n\\centering\n\\includegraphics[width=0.6\\linewidth]{pics/n2v.pdf}\n\n\nThe walk just transitioned from the previous node $p$ to the current one $c$ and is now evaluating its next hop. Edge labels indicate the bias as a function of parameters $p$ and $q$.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Role Embedding}\nNode2Vec and DeepWalk are \\textbf{locational} embedding: nodes with similar vectors tend to be close in the graph, in term of graph distance.\n\nAnother notion of graph similarity is \\textbf{role} similarity. Two nodes have similar roles in the graph if their neighborhood is similar, \\textbf{ignoring node labels}. \n\\end{textbox}\n\n\n\n\\begin{textbox}{Role2Vec — Struc2Vec}\nTwo popular methods for role embedding are Struc2Vec\\footcite{ribeiro2017struc2vec} and Role2Vec\\footcite{ahmed2019role2vec}. They are based on a similar principle: as DeepWalk, they use random walks and SkipGram to generate embedding from contexts. But instead of generating sequences composed of the \\textbf{labels} of encountered nodes, it generate contexts based on the \\textbf{attributes/labels/features} of encountered nodes. Nodes with similar vectors thus corresponds to nodes that tend to encounter \\textbf{nodes with similar properties} in random walks starting from them.\n\nExamples of properties could be node features (age, genre, etc.) or structural properties (degree, clustering coefficient, graphlet belonging, etc).\n\\end{textbox}\n\n\n\n\\begin{textbox}{Node Classification with embeddings}\nMachine Learning algorithms such as Logistic Regression or Decision Tree can be trained to predict a property of a node from a vector of features representing the node property. We have seen in a previous class that these features could be manually chosen heuristics such as node centralities. \n\nVectors yielded by embedding algorithms can naturally be used in the same way. Locational embeddings could be used, for instance to attribute category to objects or political opinions to social media accounts, while role embedding could be used to identify suspicious accounts in social media.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Link Prediction with embeddings: unsupervised}\nIf we consider that the property captured by the embedding is correlated with the probability of being connected by an edge, then the distance in the embedding can be used a heuristic for link prediction. \n\nFor instance, with LE and HOPE with $S=A$ or with random walks based approach, the embedding tries to put pairs of nodes connected by an edge closer than unconnected ones. As a consequence, we can assume that the closer two nodes are in the embedding, the more likely it is that they should be connected by an edge.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Link Prediction with embeddings: supervised}\nIn the second approach, we consider each dimension of the embedding as a node feature. For each pair of nodes, we compute a vector by \\textbf{combining nodes' vectors}.\n\nAs with heuristics, a machine learning algorithm is then trained to predict, from the combined vector, how likely it is to have an edge between nodes.\n\\end{textbox}\n\n\n\n\n\\begin{textbox}{Combining node vectors}\nThere are several methods to combine node vectors. Although it has been observed empirically that the Hadamard product often gives the best results, this choice is often considered a \\textbf{hyper-parameter}, i.e., all variants are tested and the most efficient is used for the final prediction.\n\nThe most used operators are:\n\\begin{center}\n\\begin{tabular}{ c| c }\n\\hline\n Average & (a+b)/2 \\\\ \n \\hline\n Concat & $[a_1,a_2,...,a_d,b_1,b_2,...,b_d]$\\\\  \n Hadamard & $[a_1*b_1,a_2*b_2,...,a_d*b_d]$  \\\\\n  Weighted L1 & $[|a_1-b_1|,|a_2-b_2|,...,|a_d-b_d|]$ \\\\ \n Weighted L2 & $[(a_1-b_1)^2,(a_2-b_2)^2,...,(a_d-b_d)^2]$\\\\  \n \\hline\n\\end{tabular}\n\nwith $a=[a_1,a_2,...,a_d]$ and $b=[b_1,b_2,...,b_d]$\n\\end{center}\n\\end{textbox}\n\n\n\\begin{textbox}{How many dimensions?}\nThere is no universal method to choose a number of dimensions for the embedding. In the literature, for large graphs, a common value is $d=128$ dimensions. As a general rule, $d<<n$.\n\nToo few dimensions limit the capacity to embed complex information, but too many dimensions limit cross-learning, generalization,(i.e., overfits), and make learning from embeddings harder. More dimensions also require (usually) more computation.\n\\end{textbox}\n\n\\begin{textbox}{Visualization and embeddings}\nNetwork visualization is a domain in itself. Its objective is to assign positions to nodes in a two dimensional space in order to plot the network in a meaningful way. \n\nAlgorithms such as HOPE or node2vec are not well adapted to generate visually interpretable 2-dimentional spaces, in part because the distance in the embedding is based on the cosine distance, while humans naturally assume euclidean distance. When embeddings are used for visualization, the first step consists in embedding in a moderate number of dimensions (e.g., 128), and in a second step, a dimensionality reduction algorithm more adapted for visualization such as T-SNE\\footcite{van2008visualizing} is used to reduce this number to 2 dimensions.\n\\end{textbox}\n\n\n\\begin{textbox}{Community detection with embeddings}\nCommunity detection in graphs is equivalent to the \\textbf{clustering} task in non-network data. Intuitively, clustering methods try to group elements with similar features, and separate those that are different. Applying a clustering algorithm such as \\textbf{k-means} on an embedding will therefore yield clusters of nodes, that can be considered as communities. In practice, it has been observed that communities detected by this approach are often similar to those found by modularity maximization.\n\nNote that unlike with modularity, it is often required to provide the desired number of clusters --or a distance scale-- to clustering methods.\n\\end{textbox}\n\n\\begin{textbox}{Going Further}\n\nPython Libraries: Karate-club(\\cite{karateclub})(\\cite{goyal2018gem})\n\nSurveys on graph embedding: (\\cite{goyal2018graph})(\\cite{cai2018comprehensive})(\\cite{cui2018survey})\n\nGraph Embedding and link prediction (\\cite{mara2020benchmarking})\n\nDistances in Graph embedding (\\cite{vaudaine2020comparing})\n\nComparing heuristics and Graph Embedding for link prediction (\\cite{sinha2018systematic})\n\nStacking embeddings and heuristics models for link prediction: (\\cite{ghasemian2020stacking})\n\n\\end{textbox}\n\n\n\\input{tail}\n\n\n\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "953ed14bb1208eead8ceb92edb32bfdc432b9a28", "size": 19212, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex_sources/Embeddings.tex", "max_stars_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_stars_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2022-01-26T06:33:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T23:25:49.000Z", "max_issues_repo_path": "latex_sources/Embeddings.tex", "max_issues_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_issues_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex_sources/Embeddings.tex", "max_forks_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_forks_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.04, "max_line_length": 613, "alphanum_fraction": 0.7823235478, "num_tokens": 4588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160666, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.4477688613659693}}
{"text": "% !TeX root = ./growth_modelling.tex\n\\documentclass[letterpaper, 11pt]{article}\n\\usepackage{microtype}\n\\usepackage[bottom=1in, margin=0.75in]{geometry}\n\\usepackage{mathpazo}\n\\usepackage{setspace}\n\\usepackage{graphicx}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{amsmath}\n\\onehalfspacing\n\\setlength\\itemsep{5pt}\n\\setlength{\\footskip}{-10pt}\n\\title{Constructing a Dynamical Model of Nutrient-Dependent Growth}\n\\author{Griffin Chure}\n\\date{\\today}\n\\begin{document}\n\\maketitle\n\n\\section{Theoretical Underpinnings}\n\\subsection{Translation-Limited Growth}\\label{sec:translation_limited_growth}\nWe begin by considering balanced exponential growth on a single carbon source.\nFor the time being, we will consider a growth regime where translation is\nlimiting and we will assume that nutrients are in abundance.  \nIn this phase of growth, we can consider the formation of protein mass\nas the most resource-intensive process and can relate the total \nprotein mass of the cell $M$ to the characteristic growth rate $\\lambda$ via \n\\begin{equation}\\label{eq:grow_def}\n\\frac{dM}{dt} = \\lambda M.\n\\end{equation}\nThis protein mass $M$ is the product of the pool of ribosomes which catalyze the\nformation of peptide bonds via translation. Equation \\eqref{eq:grow_def} can be \ncast in terms of the total number of actively translating ribosomes $N_R^{(act.)}$\nas \n\\begin{equation}\n\\frac{dM}{dt} = N_R^{(act.)}k_R,\n\\end{equation}\nwhere $k_R$ represents the average translation rate per active ribosome with\ndimensions of $[MT^{-1}]$. It's important to note that here we are considering\nonly  the \\textit{actively} translating ribosomes. Whether through active\nregulation (such as through ppGpp) or ribosomes waiting to bind an mRNA or \nawaiting the arrival of a charged tRNA, there is always some pool of ribosomes \nthat are \\textit{inactive}, $N_R^{(inact)}$. Given knowledge of the total number\nof ribosomes $N_R = N_R^{(act.)} + N_R^{(inact.)}$, we can state \n\\begin{equation}\n    \\frac{dM}{dt} = \\left[N_R - N_R^{(inact.)}\\right] k_R.\n    \\label{eq:growth_Nr}\n\\end{equation}\nEquating this with Equation \\eqref{eq:grow_def} yields an expression for the\ngrowth rate $\\lambda$,\n\\begin{equation}\n\\lambda = \\frac{\\left[N_R - N_R^{(inact.)}\\right]k_R}{M}.\n\\label{eq:lam_nr}\n\\end{equation}\nRather than keeping track of the number of ribosomes, we can refer to the total \nribosomal mass $M_R$ and $M_R^{(inact.)}$ given knowledge of the unit mass of\none ribosome $m_R$, \n\\begin{equation}\nM_R = m_R N_R.\n\\label{eq:ribo_mass}\n\\end{equation}\nDoing so allows us to cast Equation \\eqref{eq:lam_nr} in terms of the\n\\textit{ribosomal mass fraction} $\\phi_R$ and $\\phi_R^{(inact.)}$, \n\\begin{equation}\n\\lambda = \\frac{\\left[M_R - M_R^{(inact.)}\\right]k_R}{M m_R} = \\gamma\\left[\\phi_R - \\phi_R^{(inact.)}\\right]\n\\label{eq:growth_law_gamma}\n\\end{equation}\nwhere we've introduced $\\gamma = \\frac{k_R}{m_R}$, a term commonly referred to\nas  the \\textit{translational capacity}. This term $\\gamma$ has dimensions of\n$[T^{-1}]$ and can be thought of as effective translation rate. The inverse of\nthis term has dimensions of $[T]$ and defines the amount of time it takes for \nthe synthesis of one ribosomes' worth of protein mass. Equation\n\\eqref{growth_law_gamma} can be rearranged to describe the mass fraction\n$\\phi_R$ as a function of the growth rate, \n\\begin{equation}\n\\phi_R = \\phi_R^{(inact.)} + \\frac{\\lambda}{\\gamma}.\n\\label{eq:growth_law_gamma_phir}\n\\end{equation}\nIn the limit where the cell is not growing (i.e. $\\lambda \\rightarrow 0$), we \nfind that $\\phi_R = \\phi_R^{(inact.)}$, illustrating that $\\phi_R^{(inactt.)}$ \nis the \\textit{minimal} fraction of the protein mass that is occupied by\nribosomes. Therefore, we will make the definition of \n\\begin{equation}\n\\phi_R^{(inact.)} \\equiv \\phi_R^{(min)}\n\\label{eq:phir_min_def}\n\\end{equation}\nfor notational clarity. \n\n\\subsection{Nutrient-Limited Growth}\nWe now turn our attention to the fact that, in order for ribosomes to form \npeptide bonds, nutrients must be metabolized to produce tRNAs charged with amino\nacids. Thus, the nutritional extent of the growth medium will dependent on \nhow the cell maximizes the flux from raw nutrients to amino acids. \n\nLet's consider some amino acid $a$ whose total mass in the cell is $M_a$. In\nbalanced exponential growth, this mass $M_a$ is defined by the flux of of $a$ \ninto the cell (via a combination of transport of nutrients and metabolism to\nform $a$) and the rate at which they are consumed via translation.\nMathematically, this can be stated as\n\\begin{equation}\n\\frac{dM_a}{dt} = J_a - \\beta \\frac{dM}{dt},\n\\label{eq:dma_dt}\n\\end{equation}\nwhere $J_a$ is the flux of $a$ into the cell and $\\beta$ is the frequency with\nwhich it is integrated into the proteome. For example, if we are considering a\nsingle species of amino acid and we make the approximation that amino acids are \nused with equal frequencies, $\\beta = \\frac{1}{20}$. \n\nIn reality, there is always some non-zero concentration of free amino acids that\nthe cell must maintain. We can consider the relative\nmasses of the standing pool of amino acids and the mass of the total proteome as\na measure of concentration, \n\\begin{equation}\n    \\theta_a \\equiv \\frac{M_a}{M}.\n    \\label{eq:theta_a_def}\n\\end{equation}\nGiven this formulation, Equation \\eqref{eq:dma_dt} can be amended to include\nmaintenance of the free amino acid concentration as \n\\begin{equation}\n\\frac{dM_a}{dt} = J_a - (\\beta + \\theta_a)\\frac{dM}{dt}. \n\\label{eq:dma_dt_theta_a}\n\\end{equation}\nDividing both sides of Equation \\ref{eq:dma_dt_theta_a} by the total proteome\nmass $M$ reparameterizes the entire dynamics in terms of the nutrient mass fraction $\\theta_a$, yielding \n\\begin{equation}\n\\frac{1}{M}\\frac{dM_a}{dt} = \\frac{d\\theta_a}{dt} = \\frac{J_a}{M} - \\lambda (\\beta + \\theta_a).\n\\label{eq:dtheta_a_dt}\n\\end{equation}\nIn steady-state growth, the fluxes are balanced, allowing us to enumerate an \nexpression for the growth rate $\\lambda$ as \n\\begin{equation}\n\\lambda = \\frac{J_a}{M\\left(\\beta + \\theta_a\\right)}.\n\\label{eq:lambda_ja_betatheta}\n\\end{equation}\n\nThe inward flux of nutrients to produce charged tRNAs $J_a$ represents the \nconcerted action of a battery of metabolic enzymes, including transporters and\npotentially entire metabolic pathways. We can coarse-grain this entire process \nby considering the total protein mass of all of the metabolic proteins involved \nin processing a given nutrient as $M_P$. Together, these proteins produce amino\nacids at some effective rate $k_P$ such that \n\\begin{equation}\n    J_a = k_P M_P, \n    \\label{eq:ja_mp_def}\n\\end{equation}\nwhere $k_P$ has dimensions of $[T^{-1}]$. It is important to note that this is \nnot exactly an enzymatic rate, however, but represents the total mass of\nnutrient that can be transported/synthesized per unit mass of metabolic protein\nper unit time. Plugging Equation \\eqref{eq:ja_mp_def} into Equation\n\\eqref{eq:lambda_ja_betahtheta} yields a complete expression for the growth rate\n\\begin{equation}\n\\lambda = \\frac{k_P}{\\beta + \\theta_a} \\frac{M_P}{M} = \\frac{k_P}{\\beta + \\theta_a} \\phi_P,\n\\label{eq:lambda_phip}\n\\end{equation}\nwhere we have introduced the notation $\\phi_P$ to denote the mass fraction of\nthe proteome occupied by metabolic proteins.\n\nIn Section \\ref{sec:translation_limited_growth}, we used similar notation to\ndenote the mass fraction of the proteome which is occupied by ribosome $\\phi_R$.\nAs $\\phi_P$ and $\\phi_R$ are both bounded by the total mass of the proteome,\nthey must by definition compete for resources. If we consider these two categories are the only classes \nof proteins making up the proteome, there exists the constraint that \n\\begin{equation}\n\\phi_P + \\phi_R = 1.\n\\end{equation}\nHowever, neither $\\phi_P$ nor $\\phi_R$ can ever be equal to $1$. Rather, we can \nstate that there exists a maximum fraction of the proteome that can be occupied\nby either class of proteins. For consistency with Section\n\\ref{sec:translation_limited_growth}, we can cast this constraint in terms of \nthe maximal ribosomal mass fraction $\\phi_R^{(max)}$ as \n\\begin{equation}  \n\\phi_P + \\phi_R = \\phi_R^{(max)},\n\\label{eq:phip_phir_constraint}\n\\end{equation}\nwhich captures the fact that any increase in $\\phi_P$ must come at the expense\nof $\\phi_R$. \n\nUsing this constraint, Equation \\eqref{eq:lambda_phip} can be defined in terms \nof the ribosomal mass fraction as \n\\begin{equation}\n\\lambda = \\frac{k_P}{\\beta + \\theta_a}\\left[\\phi_R^{(max)} - \\phi_R\\right].\n\\label{eq:lambda_metab_phiR}\n\\end{equation}\nIn typical physiological conditions, the standing pool of amino acids is small\nwhen compared to its incorporation in the the proteome, permitting the\napproximation that $\\beta + \\theta_a \\approx \\beta$. Making this approximation\nallows us simplify Equation \\ref{eq:lambda_metab_phiR} to yield \n\\begin{equation}\n\\lambda = \\frac{k_P}{\\beta}\\left[\\phi_R^{(max)} - \\phi_R\\right] = \\nu \\left[\\phi_R^{(max)} - \\phi_R\\right].\n\\label{eq:growth_law_nu}\n\\end{equation}\nThe parameter $\\nu$ is often referred to as the \\textit{nutritional capacity}.\nThis parameter relates the rate at which nutrient mass (per unit mass of\nmetabolic protein) is produced to its corresponding frequency of usage. This\nresult is classically rewritten to express the ribosomal mass fraction $\\phi_R$ \nas a function of growth rate, \n\\begin{equation}\n\\phi_R = \\phi_R^{(max)} - \\frac{\\lambda}{\\nu}.\n\\end{equation}\n\n\\subsection{Condition-Dependent Regulation of $\\gamma$ and $\\nu$}\nThus far, we have presented $\\gamma$ and $\\nu$ as constants. For a given growth\ncondition (such as a single growth medium) this is approximately true. However,\nboth of these parameters are the target of regulation given the availability of\nprecursors or charged tRNAs. There are many ways we can consider how these\nparameters are tuned as a function of the environment. \n\nFor now, we can make the reasonable assumption that the translational\ncapacity $\\gamma$ follows a simple Michaelis-Menten dependence on the\nstanding pool of the amino acid concentration $\\theta_a$,\n\\begin{equation}\n\\gamma(\\theta_a) = \\frac{\\gamma^{(max)}}{1 + \\frac{\\theta_0}{\\theta_a}},\n\\label{eq:gamma_michaelis_menten}\n\\end{equation}\nwhere $\\theta_a^*$ is the Michaelis-Menten constant and represents the\nconcentration of amino acids at which the translational capacity is half\nmaximal. In this formulation, the translational capacity will be maximized when \nthe standing pool of the amino acids is large such that $\\theta_a >> \\theta_0$.\nAs the nutrient conditions dwindle, however, $\\gamma$ will asymptotically\napproach $0$ as $\\theta_a <<  \\theta_0$.\n\nIn a similar fashion, we can make the assumption that the nutritional capacity \nof a given growth condition will be dependent on the concentration of the\nnutrients. In the condition when nutrients are plentiful, the yield of amino\nacids per unit mass of metabolic protein should be maximal. This should be true\nof $\\nu$ \\textit{for a given nutrient source}, assuming that nutrient's\nconcentration is the tunable parameter. Thus, the standing amino acid pool\n$\\theta_a$ is less important in setting the value of $\\nu$ than is the\nconcentration of the actual nutrient, which we will denote hereafter as $c$. For\na given concentration, we can define the nutritional capacity as having the form\nof a Monod expression, \n\\begin{equation}\n\\nu(c) = \\frac{\\nu^{(max)}}{1 + \\frac{K_M}{c}},\n\\label{eq:nu_monod}\n\\end{equation}\nwhere $K_M$ is the Monod constant for growth on the specific nutrient source. \n\nAs $\\nu$ depends on the composition of the \\textit{medium} (rather than the\nintercellular composition), we must now describe how the nutrient composition\n$c$ changes as the biomass of the culture increases. In virtually all realistic \nsituations, the nutrients in the growth medium need to pass through a complex \nmetabolic pathway to be \"converted\" into amino acids that are charged to tRNAs.\nThus, to keep track of the nutrient concentration, we have to specify a yield\nparameter $\\Omega$ that describes the mass of amino acids produced per unit mass\nof nutrient. The dynamics of the growth medium is then described by \n\\begin{equation}\n\\frac{dc}{dt} = -\\frac{\\nu(c)\\left(\\phi_R^{(max)} - \\phi_R\\right)}{\\Omega}.\n\\label{eq:dc_dt}\n\\end{equation}\n\n\\section{A Dynamical Model for Diauxic Growth}\n\\subsection{Growth on a Single Carbon Source}\nWith the preceding sections, we now have a complete dynamical description for\ngrowth on a single nutrient source. To summarize, the system of equations is\ngoverned by the accumulation of biomass via \n\\begin{equation}\n    \\frac{dM}{dt} = \\gamma(\\theta) \\phi_R M.\n    \\label{eq:mass_ode}\n\\end{equation} \nThe dynamics of the pool of amino acids $\\theta_a$ is defined by the action of \nthe metabolic sector of the proteome $\\phi_P$ as \n\\begin{equation}\n\\frac{d\\theta_a}{dt} = \\nu(c)\\phi_P M - \\frac{dM}{dt} = \\nu(c)\\left[\\phi_R^{(max)} - \\phi_R\\right]M - \\frac{dM}{dt}.\n\\end{equation}\nThese amino acids, as described in the last section, ultimately come from the\nnutrients of the medium, which are at some concentration $c$. The dynamics of\nthis component is governed by \n\\begin{equation}\n    \\frac{dc}{dt} = -\\frac{\\nu(c)\\phi_P M}{\\Omega} = -\\frac{\\nu(c)\\left[\\phi_R^{(max)} - \\phi_R\\right]M}{\\Omega}.\n\\end{equation}\n\nFinally, the translational and nutritional capacities of the system are governed\nby the size of the amino acid pool and the nutrient concentration of the growth\nmedium, respectively. These dependencies are codified mathematically as \n\\begin{equation}\n   \\gamma(\\theta) = \\gamma^{(max)}\\left(1 + \\frac{\\theta_0}{\\theta_a}\\right)^{-1}\\,\\,;\\,\\, \\nu(c) = \\nu^{(max)}\\left(1 + \\frac{K_m}{c}\\right)^{-1}.\n   \\label{eq:capacity_redefs}\n\\end{equation}\n\nThis set of equations [Equation \\eqref{eq:mass_ode} --\n\\eqref{eq:capacity_redefs}] completely describe growth on a single nutrient\nsource. Figure \\ref{fig:single_nutrient} shows how the biomass, nutrient\nconcentration, and amino acid pool size changes as a function of time using\nparameters that are characteristic of \\textit{E. coli} growing on glucose. It is\nimportant to note that, for the parameters considered here, there exists an\n\"optimal\" ribosomal mass fraction $\\phi_R$ where the rate of biomass growth is \nmaximized. This can be clearly seen in Figure \\ref{fig:single_nutrient}(A) as \nthe darkest and lightest color show slower growth of biomass compared the \nthe light blue or teal curves which are between the two extremes.  \n\n\\begin{figure}\n\\centering{\n\\includegraphics[width=\\textwidth]{figures/single_nutrient_dynamics.pdf}\n\\caption{\\textbf{Dynamics of growth on a single nutrient source.} (A) Biomass of\nthe system relative to the initial condition $M(t=0)$. (B) The fractional\nconcentration of the nutrients in the growth medium relative to that of $c(t =\n0)$. (C) The relative mass fraction of amino acids $\\theta_a$ relative to\n$\\theta_a(t = 0)$. For all plots, parameters were chosen to be approximately\nsimilar to growth of \\textit{E.  coli} on a glucose-based medium. Explicitly,\nthe model parameters used here are $\\phi_R^{(max)} = 0.4$, $\\gamma^{(max)} =\n8.25\\,\\text{hr}^{-1}$, $\\nu^{(max)} = 2.5\\,\\text{hr}^{-1}$, $\\theta_0 = 0.002$,\n$c = 50\\,\\text{mM}$, $\\Omega = 0.3$, and $K_M = 5\\,\\mu\\text{M}$. The initial \nconditions were arbitrarily set to be $M_0 = 0.001$ and $\\theta_a =\n\\frac{M_0}{10}$.}\n\\label{fig:single_nutrient}\n}\n\\end{figure}\n\\subsection{Growth on Two Carbon Sources}\nGiven a dynamical model of growth on a single nutrient source, it becomes\nrelatively simple to include the presence of a second nutrient source whose \nmetabolism is not preferred. \n\nLet us consider two nutrient sources $x$ and $y$. Nutrient $x$ is the\n\"preferred\" nutrient, meaning that its metabolism is prioritized over $y$.\nThe As $x$ and $y$ are different substrates, they require different sets of\nmetabolic proteins $M_x$ and $M_y$ and corresponding proteome mass fractions\n$\\phi_x$ and $\\phi_y$. Additionally, as the nutrients are different, so too\nare the nutritional capacities $\\nu_x$ and $\\nu_y$ which are determined given\nthe concentrations $c_x$ and $c_y$ and Monod constants $K_{M,x}$ and\n$K_{M,y}$, respectively. The translational capacity, however, is shared\nbetween the two nutrient sources as it is dependent only on the amino acid\npool $\\theta_a$ resulting from the metabolism of $x$ or $y$.\n\nHow do we define a \"preferred\" substrate? In order to regulate what is\nmetabolized, we must think of how the expression of the metabolic proteins are\nregulated. We will begin by considering that the expression of the metabolic\nproteins responsible for consuming each the preferential nutrient $x$ will be \nproportional to its concentration $c_x$. Mathematically, we can model the mass\nfraction $\\phi_x$ to have Monod-like dependence on the concentration $c_x$,\nyielding \n\\begin{equation}\n\\phi_x(c_x) = \\frac{\\phi_x^{(max)}}{1 + \\frac{K_{M, x}}{c_x}}. \n\\label{eq:phix_monod}\n\\end{equation}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "d91a74d7903cda0ff48b8683a0226be3d085cfb1", "size": 16943, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/notes/growth_modelling.tex", "max_stars_repo_name": "gchure/diauxic_evolution", "max_stars_repo_head_hexsha": "5917d3ae5f9a3a5db0f037e9f7b5768cd1ffe92f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-01T03:31:19.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-01T03:31:19.000Z", "max_issues_repo_path": "docs/notes/growth_modelling.tex", "max_issues_repo_name": "gchure/diauxic_evolution", "max_issues_repo_head_hexsha": "5917d3ae5f9a3a5db0f037e9f7b5768cd1ffe92f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/notes/growth_modelling.tex", "max_forks_repo_name": "gchure/diauxic_evolution", "max_forks_repo_head_hexsha": "5917d3ae5f9a3a5db0f037e9f7b5768cd1ffe92f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1335227273, "max_line_length": 147, "alphanum_fraction": 0.7550020657, "num_tokens": 4731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.44776885773592356}}
{"text": "I have explored the GNFW model pretty extensively at this point, and\nhave encountered a number of issues with it:\n\n\\begin{list}{}{\\labelwidth 0.4in \\leftmargin \\labelwidth \\addtolength{\\leftmargin}{\\labelsep}}\n\n\\item[1] {The A10 and N07 normalizations don't agree, even for the same set of fit parameters}\n\n\\item[2] {For a given M500, the A10 normalization predicts a pressure\n  (and therefore an SZ decrement) that is significantly lower than\n  what we actually measure for real clusters thought to be close to that M500\n\n  Another way of saying the same thing is that for a fixed SZ\n  decrement, the GNFW model normalization predicts an M500 that is\n  significantly larger than what you get from joint fits to SZ + Xray}\n\n\\item[3] {The A10 model is not self-consistent.  If you start with an\n  M500 and use the A10 normalization to construct the corresponding\n  pressure profile, the M500 that you get by integrating that pressure\n  profile out to R500 does not agree with the M500 you started with}\n\n\\end{list}\n\nIn the next couple sections, I address each of these in turn.\n\n\\subsubsection{Comparing the A10 and N07 P500}\n\nSubstituting $f_B = 0.175, \\mu = 0.59, \\mu_e = 1.14, G = 6.67384\\times 10^{-8} {\\rm cm^{3}/(g\\, s^2)}$, $h(z) \\equiv H(z) / H_0$, we have\n\n\\begin{eqnarray}\\nonumber\n\\P500 &=& {{\\mu}\\over{\\mu_e}} f_B {{3}\\over{8\\pi}} \\left( {{500 G^{-1/4} H(z)^2}\\over{2}} \\right)^{4/3}\\M500^{2/3}\\\\\\nonumber\n      &=& (4197.54) \\, H(z)^{8/3}\\M500^{2/3}\\\\\\nonumber\n      &=& (4197.54) \\, h(z)^{8/3}H_0^{8/3}\\M500^{2/3}\\\\\\nonumber\n      &=& (4197.54) \\, (70~{\\rm km/s/Mpc})^{8/3}\\,(3\\times10^{14}\\Msolar)^{2/3}\\,h(z)^{8/3}h_{70}^{8/3}\\left[{{\\M500}\\over{3\\times10^{14}\\Msolar}}\\right]^{2/3}\\\\\n      &=& 1.65\\times10^{-3} \\, h(z)^{8/3}h_{70}^{8/3}\\left[{{\\M500}\\over{3\\times10^{14}\\Msolar}}\\right]^{2/3} {\\rm keV\\,cm^{-3}}\n\\label{eq:arnaud}\n\\end{eqnarray}\n\nThis is to be compared to Eq~13 of A10, with which it agrees exactly.\nI therefore conclude that there are no arithmetic errors in the\nderivation of Arnaud's P500/M500 relationship.\n\nNote that if we instead normalize \\mathM500\\ to\n$1\\times10^{15}\\Msolar$, and take $h_{70} = 1$ or $h = 0.7$, as Nagai et al do, we\nhave:\n\n\\begin{equation}\n\\P500 = 5.89\\times10^{-12} \\, h(z)^{8/3}\\left[{{\\M500}\\over{1\\times10^{15}\\Msolar}}\\right]^{2/3} {\\rm erg\\,cm^{-3}}\n\\end{equation}\n\nThis is to be compared to Eq~3 of Nagai et al, with $h = 0.7$, which yields\n\n\\begin{equation}\n\\P500 = 1.14\\times10^{-11} \\, h(z)^{8/3}\\left[{{\\M500}\\over{1\\times10^{15}\\Msolar}}\\right]^{2/3} {\\rm erg\\,cm^{-3}}\n\\end{equation}\n\n(Note that $h(z)$ is equivalent to the $E(z)$ of Nagai et al.  And N07\nactually take $h = 0.72$, but I've used $h = 0.7$ for simplicity) \n\nThe ratio of these two expressions is very close to 2, and the reason\nis that N07 have dropped a factor of $h^2$ in their Eq~3, which\nas-written is proportional to $h^{2/3}$ and not $h^{8/3}$, which is\nclearly required by Eq~\\ref{eq:p500}.  So that mystery amounts to\nnothing more than typo in N07.\n\n\\subsubsection{Comparing P500 and M500}\n\\label{sec:confusion}\n\nTo make contact with $P_0$ of Equation~\\ref{eq:ytop}, we have\n\n\\begin{eqnarray}\nP_0 &=& p_0\\times1.65\\times10^{-3}h(z)^{8/3}\\left[{\\M500\\over{3\\times10^{14}h^{-1}_{70}\\Msolar}}\\right]^{2/3+\\alpha_P}\\,h^2_{70}\\,{\\rm keV\\,cm^{-3}}\n\\label{eq:arnaudnorm}\n\\end{eqnarray}\n\n(if we ignore $\\alpha^\\prime_P$).  This suggests, on the face of it,\nthat given a cosmology, we can relate an observed central decrement $y(0)$ to the Arnaud pressure normalization and therefore \\mathM500\\, by plugging $P_0$ into Equation~\\ref{eq:ytop}.  However, I can't quite make sense of the numbers I get if I attempt to do this.  \n\nLet's take Abell~1914 as a test case.  This cluster has a redshift $z\n= 0.168$, which yields $h(z) = 1.089$ and $D_A = 0.59$~Gpc.  For A1914, the central\ndecrement is roughly $-2$~mK, or $y(0) \\sim 4\\times 10^{-4}$.  The Arnaud fits\ngive a typical $\\theta_c\\sim 2^{\\,\\prime}$, yielding:\n\n\\begin{equation}\nP_0 = 0.29~{\\rm keV/cm^3}\n\\end{equation}\n\nfrom Equation~\\ref{eq:ytop}.  Plugging the numbers into Equation~\\ref{eq:arnaudnorm}, we have:\n\n\\begin{equation}\nP_0 = 1.74\\times 10^{-2}\\left[{\\M500\\over{3\\times10^{14}\\Msolar}}\\right]^{2/3+\\alpha_P}~{\\rm keV/cm^3},\n\\end{equation}\n\nor\n\n\\begin{equation}\n\\M500 = 1\\times10^{16}\\Msolar\n\\end{equation}\n\nwhich seems about an order of magnitude too large (estimates of the virial mass for A1914 I've seen are somewhere in the neighborhood of $2-3\\times10^{15}\\Msolar$).\n\n\\subsubsection{The A10 Model is not Self-consistent}\n\nAs noted above, if you start with an M500, you can use\nEq~\\ref{eq:arnaud} to determine \\mathP500\\ and thus the normalization of\nthe cluster pressure profile, via Eq~\\ref{eq:ytop}, in particular:\n\n\\begin{equation}\\nonumber\nP(r) = \\P500\\,p(r).\n\\end{equation}\n\nwhere $p(r)$ is the GNFW profile in Eq~\\ref{eq:gnfw}.  \n\nThis suggests that if the cluster were an isothermal sphere, then\n$P(\\R500)/\\P500 = p(\\R500) = 1.0$.  For A10's parameter values,\nhowever, $p(\\R500) = 0.48$ (which is suspiciously close to the ratio\nof $(70/100)^2$).  It is also consistent with my empirical observation\nthat the \\mathP500\\ normalization predicts an SZ decrement that is\nabout a factor of 2 smaller than observed, for a set of clusters for\nwhich we have independent SZ + X-ray mass estimates.\n\nFrom Eq~\\ref{eq:ysph} and Eq~\\ref{eq:mgas} we also have:\n\n\\begin{eqnarray}\n\\M500 &=& {1\\over{f_{gas}}}\\left({{m_p\\mu_e}\\over{k_B T_e}}\\right)\\integral{\\R500}{0}{P(r)}{V}\\\\\n&=& {1\\over{f_{gas}}}\\left({{m_p\\mu_e}\\over{k_B T_e}}\\right)\\P500\\,p_0\\integral{\\R500}{0}{p(r)}{V}\n\\end{eqnarray}\n\nIf I take measured X-ray temperatures for a set of clusters and the\nA10 pressure profile fits, I can integrate this expression and\ncompare it to what the A10 normalization would predict for \\mathM500,\nand again I find that the masses I obtain in this manner are factors\nof ~several lower than the best-fit \\mathM500.  \n\nAll of which suggests that an appropriate way to proceed with my\nsimulations is to rescale $p_0$ to force self-consistency with the\ninput \\mathM500.  That is, I find the value of $p_0$ that gives me the\nsame integrated \\mathM500\\ that I put in the model in the first place.\nThis factor is shown in Figure~\\ref{fig:rescale}.\n\n\\begin{figure}[th]\n\\begin{center}\n\\includegraphics[scale=0.5]{figures/rescale.png}\\\\\n\\end{center}\n\\caption{Plot of factor by which the A10 $p_0$ needs to be rescaled to\n  recover the same integrated \\mathM500\\ that is put into the model normalization}\n\\label{fig:rescale}\n\\end{figure}\n\n\n", "meta": {"hexsha": "ebc8a57a4a345df5746ec84a386cac412ee96050", "size": 6526, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "help/gnfwproblems.tex", "max_stars_repo_name": "erikleitch/climax", "max_stars_repo_head_hexsha": "66ce64b0ab9f3a3722d3177cc5215ccf59369e88", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-01T05:15:31.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-01T05:15:31.000Z", "max_issues_repo_path": "docs/gnfwproblems.tex", "max_issues_repo_name": "erikleitch/climax", "max_issues_repo_head_hexsha": "66ce64b0ab9f3a3722d3177cc5215ccf59369e88", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/gnfwproblems.tex", "max_forks_repo_name": "erikleitch/climax", "max_forks_repo_head_hexsha": "66ce64b0ab9f3a3722d3177cc5215ccf59369e88", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-05-02T19:35:55.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-07T00:54:51.000Z", "avg_line_length": 43.5066666667, "max_line_length": 267, "alphanum_fraction": 0.6988967208, "num_tokens": 2273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4477688577359235}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{alltt,fullpage,graphics,color,epsfig,amsmath, amssymb}\n\\usepackage{hyperref}\n\\usepackage{boxedminipage}\n\\usepackage[ruled,vlined]{algorithm2e}\n\n\\newcommand{\\floor}[1]{\\lfloor #1 \\rfloor}\n\\newcommand{\\ceil}[1]{\\lceil #1 \\rceil}\n\n\\title{CS 510 Assignment 3:}\n\\author{Daniel Campos}\n\\date{April 11th,2021}\n\\begin{document}\n\\maketitle\n\\section{Problem 1}\n\\subsection{Write down the likelihood for log p(D| $\\theta$) }\n$log p(D | \\theta)= \\sum_{w \\in D} log((1-\\eta) p(w|\\theta) +  (\\eta) p(w|C))$ where C is the background language model. Since we do not care about the background language model we can set $\\eta=0$ since no words will be generated by the background language model. Thus, the like hood becomes $log p(D| \\theta) = \\sum_{w \\in D} log(p(w|\\theta))$\n\\subsection{Derive the E-step and M-step for estimating the unknown parameter $\\lambda$ in iteration t, for t = 1, 2}\nSince the background model never occurs we can just set $p(z_{d,w}=B) = 0$ and only focus on updating $p(z_{d,w}=\\theta) =\\frac{\\pi_{d, \\theta}^(n) (w| \\theta)}{\\pi_{d,\\theta'} p^(n) (w|\\theta')}$ for the E-Step and for M-Step $\\pi_{d,j}^(n+1)= \\frac{\\sum_{w \\in V} c(w,d)(1-p(z_{d,w} = \\theta')p(z_{w, d} = \\theta)}{\\sum_{w \\in V} c(w,d)(1-p(z_{d,w} = \\theta')p(z_{w, d} = \\theta')}$\n\\section{Derive the E-step and M-step for estimating p(w|H).}\nFirst off, we can treat this as having two language models, for writer h given by $\\theta_h$ and writer t given by $\\theta_t$. We know $\\theta_h=0.9$, $\\theta_t=0.1$ and we know the $p(w| t)$ but not $p(w|h)$. We initialize $p(w | \\theta_h)$ to a random value and use EM. For our optimization we set our E-step to : \\\\\n$p(z = 1| \\theta_h) = \\frac{\\theta_h p^{(n)} p(w| \\theta_h)}{\\theta_h p^{(n)} p(w| \\theta_h) + p(\\theta_t) p^{(n)} p(w| \\theta_t)}$\nsince we already know $\\theta_h$ we and the true distribution for writer t we can replace their probability with a constant which allows us to simplify to e-step to$p(z = 1| \\theta_h) = \\frac{0.9p^{(n)} p(w| \\theta_h)}{0.9p^{(n)} p(w| \\theta_h) + c_w}$ where $c_w$ is the constant for $\\theta_t*p(w|\\theta_t)$.\nFor the M-Step modify the formula to update the word distribution. $p^(n+1) (w| \\theta_h) = \\frac{c(w,d)(1-p(z=1|\\theta_h))p(w|D)}{\\sum_{w' \\in V} \\sum_{d \\in D} c(w',d)(1-p(z=h))p(z=t)}$\n\\section{Question 3}\nTo estimate the remaining 900 documents we apply the EM for PLSA as covered in lecture. First, we initialize all unknown parameters(true topic mapping of word distributions) randomly. Next we repeat the E-Step and the M step (covered shortly) until convergence. \\\\\nE-step: Our hidden variable in this question is our topic indicator by word denoted by $z_{d,w}$ where $z_{d,w} \\in {B, 1,2}$ where B is background, 1 is Seattle and 2 is Chicago. We run $(z_{d,w} = 1) = \\frac{\\pi_{d,j}^(n) p^(n) (w| \\theta_1)}{\\sum_{j'=2} \\pi_{d,j}^(n) p^(n)(w| \\theta_2)}$, $(z_{d,w} = 2) = \\frac{\\pi_{d,j}^(n) p^(n) (w| \\theta_2)}{\\sum_{j'=1} \\pi_{d,j}^(n) p^(n)(w| \\theta_1)}$ and $p(z_{d,w} = B) = \\frac{\\lambda_b p(w|\\theta_b)}{\\lambda_b p(w|\\theta_b) + (1-\\lambda_b)\\sum_{j=1}^2 \\pi_{d,j}^(n) p^(n) w| \\theta_j)}$. \\\\\nThe M-step re-estimates the probability of doc d covering a topic $\\theta_j$ where: $\\pi_{d,j}^(n+1) = \\frac{\\sum_{w \\in V} c(w,d)(1-p(z_{d,w}=B))p(z_{d,w} = j)}{\\sum_{j'} \\sum_{w \\in V} c(w,d)(1-p(z_{d,w}=B))p(z_{d,w} = j')}$ and re-estimates the probability of word $w$ for topic $\\theta_j$ by: $p^(n+1)(w| \\theta_j) = \\frac{\\sum_{w \\in V} c(w,d)(1-p(z_{d,w}=B))p(z_{d,w} = j)}{\\sum_{w' \\in V} \\sum_{d \\in D} c(w',d)(1-p(z_{d,w'}=B))p(z_{d,w'} = j)}$\n\\section{Topic Estimation}\n\\subsection{Question 1.1}\nImplemented\n\\subsection{Question 1.2}\nThe first sequence, sampleseq1 and samplemod1 tags every a with 0 and b with 1 since output probabilities for 0 have been set to be A 0.9999 and for 1 have set to be b for 0.99999 and the transmission probabilities bet weens states are equal. This mean that it is most unlikely that any B receive a 0, a receive a 1 and transferring between 0 to 1 is as common as staying. \\\\\nFor the second sequnce, sampleseq2 and samplemod2 we produce eight zeros followed by 8 ones because of the different mix in transmission probabilities and output probabilities. Our first 8 outputs are 0 because it is dominated by As and as As are unlikley to be produced by 1 the sequence is likely zeros. Once the sequence transitions mostly to b, it is more probable that we had the minor odds of transitioning from 0 to 1 than producing that many B with state 0 so the second eight states are 1. \n\\subsection{Question 1.3}\nSee zip.\n\\subsection{Question 2.1}\nSee zip.\n\\subsection{Question 2.2}\nSee zip.\n\\subsection{Question 3.1}\nThe probabilities are slighly off as the model has 0.85583, 0.156617 which should be 0.8, 0.2 and 0.144053, 0.843271 which should be 0.2, 0.8. \\\\\nThe learned tagging is the same as the tagging produced by samplemod2.\n\\subsection{Question 3.2}\nYes this is able to identify DNA and amino acids. \\\\\nIf I insert one P it is able to identify as amino because there are no DNA sequences with P.\\\\\nIf I insert six P after the second A they are also all correctly identified as Aminos. If we look at the trained model we see for P 0.0736726 5.70029e-07 meaning P is never a DNA sequence and always an amino. Even when it is unlikely to go from DNA to amino (0 to 1 0.960808 0.0701715 and 1 to 0 0.0391916 0.929828) since P is never DNA it doesn't change.  \n\\end{document}", "meta": {"hexsha": "5f07d18c46de97a17f8be4ad8c1a52c7905fc15b", "size": 5460, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignments/3.tex", "max_stars_repo_name": "spacemanidol/CS510IR", "max_stars_repo_head_hexsha": "84def6a199aafe9a845d3235585204f3a3c060e4", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignments/3.tex", "max_issues_repo_name": "spacemanidol/CS510IR", "max_issues_repo_head_hexsha": "84def6a199aafe9a845d3235585204f3a3c060e4", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignments/3.tex", "max_forks_repo_name": "spacemanidol/CS510IR", "max_forks_repo_head_hexsha": "84def6a199aafe9a845d3235585204f3a3c060e4", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 111.4285714286, "max_line_length": 541, "alphanum_fraction": 0.6924908425, "num_tokens": 1864, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4477688541058778}}
{"text": "\\section{Linearize Cluster Assignment via Spectral Ordering}\n\n\\textit{Linearize Cluster Assignment via Spectral Ordering} by Chris Ding. \\\\\nCited by 69. \\textit{Machine learning. ACM, 2004.}\n\\newline\n\n\\textbf{Main point} is that \\begin{inparaenum}[\\itshape a\\upshape)]\n\\item that K-way clustering method depends on a linear ordering provided by the spectral ordering, \n\\item paper provide a ordering objective function.\n\\end{inparaenum}\n\n\\subsection{Linearized cluster assignment}\nThe linearized assignment algorithm depends on three techniques \\begin{inparaenum}[\\itshape a\\upshape)]\n\\item an ordering of the data objects, \n\\item clustering crossing,\n\\item the connectivity matrix,\n\\end{inparaenum}\n\nThe actual linearization is performed via the cluster clustering, the sum of similarities symmetrically across a cut point along the linear ordering.\n\n", "meta": {"hexsha": "1dd5a972f2370bd29417a881ffee27a609f13b38", "size": 852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/references/reference_research/ding04.tex", "max_stars_repo_name": "wsgan001/AnomalyDetection", "max_stars_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/references/reference_research/ding04.tex", "max_issues_repo_name": "wsgan001/AnomalyDetection", "max_issues_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/references/reference_research/ding04.tex", "max_forks_repo_name": "wsgan001/AnomalyDetection", "max_forks_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-03-16T21:50:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-16T21:50:52.000Z", "avg_line_length": 40.5714285714, "max_line_length": 149, "alphanum_fraction": 0.8028169014, "num_tokens": 198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4477688504758319}}
{"text": "\\problemname{Jackdaws And Crows}\n\n\\illustration{0.42}{jackdaws}{\\href{https://www.flickr.com/photos/duncanh1/7874001966}{A Clattering of Jackdaws} by Dun.can on flickr, cc by}%\n\\noindent\nNick is a bird watcher and often visits the forum ``CrowFinders'' to discuss his hobby with like-minded people.\nCrowFinders has a voting system where users can upvote or downvote comments, which increases or decreases their score by $1$.\nThis means that each comment can end up with any integer score (including negative scores).\nOnce when Nick was browsing a heated discussion about the classification of jackdaws as crows, he found something very pleasing: a chain of comments\nthat alternated between positive and negative scores. But a few days later, he found that the comment chain was no longer alternating.\nNow Nick wants to make it alternating again.\n\nA comment chain is alternating if the scores $s_1, s_2, \\ldots, s_n$ of the comments all are non-zero, and every pair of adjacent scores $s_i$, $s_{i+1}$ have opposite signs.\nIn particular, a single comment with a non-zero score or even a comment chain without any comment is an alternating comment chain.\n\nThere are two operations Nick can do to make the comment chain alternating:\n\\begin{enumerate}\n    \\item Create a fake account and upvote/downvote some of the comments. This increases/decreases their respective scores by $1$. \n    Each fake account can only upvote/downvote each comment at most once, but it can vote on any subset of the comments.\n    It takes $c$ seconds to create an account and use it to vote (regardless of how many comments are upvoted/downvoted).\n    \\item Report one specific comment to remove it from the chain. Thinking of convincing reasons for the report takes $r$ seconds.\n    (Nick is an excellent arguer, so once the report is filed, the comment is guaranteed to be removed.)\n\\end{enumerate}\n\nNick can apply these operations in any order, any number of times. How fast can he make the comment chain alternating?\n\nFor example, consider Sample Input 1 below, where the scores in the comment chain are $8, 8, 2, -2$, and it takes Nick $10$ seconds to create an\naccount and $50$ seconds to file a report for one comment. In this case it is optimal to first create $3$ fake accounts and use them to upvote\nthe fourth comment and downvote the third, followed by reporting the first comment. This results in the scores $8, -1, 1$, which is\nan alternating chain. The time used for this is $80$ seconds.\n\n\\section*{Input}\nThe input consists of:\n\\begin{itemize}\n  \\item One line with three integers $n$, $c$, and $r$ ($1 \\leq n \\leq 5\\cdot 10^5$, $1 \\leq c,r \\leq 10^9$), the number of comments in the chain,\n    the time it takes to create a fake account and the time it takes to report one comment respectively.\n  \\item One line with $n$ integers $s_1, \\ldots, s_n$ ($-10^9 \\leq s_i \\leq 10^9$ for all $i$), the current score of each comment in the chain.\n\\end{itemize}\n\n\\section*{Output}\nOutput the smallest time to make the comment chain alternating by applying the operations above.\n\n", "meta": {"hexsha": "04af63f5d44542f84fd0eb202f786f60ca6b4840", "size": 3063, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/jackdawsandcrows/problem_statement/problem.en.tex", "max_stars_repo_name": "Shahraaz/CP_P_S5", "max_stars_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/jackdawsandcrows/problem_statement/problem.en.tex", "max_issues_repo_name": "Shahraaz/CP_P_S5", "max_issues_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/jackdawsandcrows/problem_statement/problem.en.tex", "max_forks_repo_name": "Shahraaz/CP_P_S5", "max_forks_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.9285714286, "max_line_length": 174, "alphanum_fraction": 0.7636304277, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043814, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.44776884746296325}}
{"text": "\\subsection{Modelling Variants of Concern (VoC)}\nTo consider the effects of VoC on infection dynamics and the vaccination programs, we explicitly simulated three competing strains to represent the wild-type or ancestral virus, Alpha and Delta VoC strains, which are the two main VoC strains that circulated in Sri Lanka during the study period. The two VoC strains were associated with increased transmissibility relative to wild-type and the respective transmisibility levels of each VoC strain were calibrated from the model. Susceptible individuals can be infected with either the wild-type or VoC strain and infectious individuals contribute to the force of infection with their respective infecting strain only. VoC strains are seeded into the model such that 25 additional persons per day are infected with a particular VoC strain for a duration of ten days, with the time that this ten-day period commences varied during model calibration.", "meta": {"hexsha": "6f99162e6b218c19b122dca3653f5470127466c2", "size": 946, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/tex/tex_descriptions/models/covid_19/stratifications/strains.tex", "max_stars_repo_name": "emmamcbryde/AuTuMN-1", "max_stars_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2020-03-11T06:15:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T03:38:35.000Z", "max_issues_repo_path": "docs/tex/tex_descriptions/models/covid_19/stratifications/strains.tex", "max_issues_repo_name": "emmamcbryde/AuTuMN-1", "max_issues_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 96, "max_issues_repo_issues_event_min_datetime": "2020-01-29T05:10:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T01:48:46.000Z", "max_forks_repo_path": "docs/tex/tex_descriptions/models/covid_19/stratifications/strains.tex", "max_forks_repo_name": "emmamcbryde/AuTuMN-1", "max_forks_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-24T00:38:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-19T16:19:03.000Z", "avg_line_length": 473.0, "max_line_length": 897, "alphanum_fraction": 0.8308668076, "num_tokens": 181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.44757072741204945}}
{"text": "\\section{Discussion}\nFor the previous genetic programming approach that did not incorporate modularization, results were compared to those in the existing literature \\cite{owen1999tubular, luukka2009pca, dash2013comparative} and it was noted that - while additional research is necessary to explore the application of a GP approach using a larger data set - the classifiers produced by the genetic programming approach performed relatively well. For this assignment, modularization - in the form of automatically defined functions - has been added to the genetic programming approach to investigate its effect in terms of accuracy, computational effort and structural complexity. \n\nWhen compared to the results of the approach that did not incorporate modularization, the classifiers produced after adding modularization showed similar results in terms of accuracy. For instance, the best accuracy achieved on the training set before modularization was 87.14\\% and, after modularization, this decreased slightly to 85.71\\%. On the evaluation set, however, the best accuracy improved from 75\\% to 80\\% - indicating that introducing modularization may lead to better generalization.\n\n\n% \\begin{table}[H]\n% \\resizebox{\\textwidth}{!}{\\begin{tabular}{|c|c|c|c|}\n% \\hline\n% \\textbf{}               & \\textbf{Average Accuracy} & \\textbf{Best Accuracy} & \\textbf{Standard Deviation} \\\\ \\hline\n% \\textbf{Training Set}   & 83.71\\%                   & 87.14\\%                & 3.14\\%                      \\\\ \\hline\n% \\textbf{Evaluation Set} & 66.00\\%                   & 75.00\\%                & 6.63\\%                      \\\\ \\hline\n% \\textbf{Overall}        & 79.77\\%                   & 82.22\\%                & 2.43\\%                      \\\\ \\hline\n% \\end{tabular}}\n% \\caption{Classification Accuracy Before Modularization}\n% \\label{tab:classification_accuracy_before}\n% \\end{table}\n\nIn terms of computational effort, since no solutions were able to classify the data with a 100\\% accuracy, it is unfortunately not possible to calculate how many programs have to be evaluated before a solution can be found. As an alternative for determining affects on computational effort, the runtimes for 10 test runs using the genetic programming approaches with and without modularization were recorded and are shown in figure \\ref{fig:runtimes}. As can be seen, runtimes for the approach that incorporates modularization are consistently shorter than the previous approach. Considering the approaches used the same genetic algorithm parameters, this is a strong indicator that introducing modularization has decreased computational effort.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=\\textwidth]{report/08_discussion/runtimes.png}\n\\caption{Runtimes for 10 Test Runs With and Without Modularization}\n\\label{fig:runtimes}\n\\end{figure}\n\nFinally, in considering the structural complexity of individuals produced by either approach, we consider the number terminal and function nodes that individuals are composed of. For the approach that did not incorporate modularization, the fittest individuals for each of 10 test runs had an average of 48.11 terminal and function nodes. For the approach that did incorporate modularization, this average was 36.03. Hence, it would seem that the approach using modularization evolves towards less complex individuals. However, since only the best individual per test run was considered in this calculation, no conclusions are drawn regarding the complexity of individuals during the evolutionary process.\n\nIn conclusion, expanding the previous genetic programming approach to produce a classifier for postoperative patient diagnosis by adding modularization led to similar results in terms of accuracy and improvements in both computational effort and structural complexity.\n", "meta": {"hexsha": "71fab75f828efeec3b22041325c6408d8d19228f", "size": 3802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/report/08_discussion/discussion.tex", "max_stars_repo_name": "marcus-bornman/cos_710_assignment_3", "max_stars_repo_head_hexsha": "a5f81cfd4f5b402098a4a0ce6fe752805bd627ff", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/report/08_discussion/discussion.tex", "max_issues_repo_name": "marcus-bornman/cos_710_assignment_3", "max_issues_repo_head_hexsha": "a5f81cfd4f5b402098a4a0ce6fe752805bd627ff", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/report/08_discussion/discussion.tex", "max_forks_repo_name": "marcus-bornman/cos_710_assignment_3", "max_forks_repo_head_hexsha": "a5f81cfd4f5b402098a4a0ce6fe752805bd627ff", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.6451612903, "max_line_length": 745, "alphanum_fraction": 0.7640715413, "num_tokens": 808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4475332709265906}}
{"text": "\\section{Gesture Detection Methodologies} \\label{sec:ges_}\n    Gesture Recognition and Gesture Classification are two distinct aspects of the final application. Classification pertains to the attribution of meaning to a detected Gesture, and is therefore handled by the cultural layer, as each gesture may have different interpretation dependent on the culture chosen. Recognition is the prior step and is involved in how the system identifies meaningful gestures from among all gestures performed by the human users, in real time.\\\\\n    There are a couple of approaches to handle recognition, between mathematical models and soft computing. Before tackling those, first it’d be important to quickly list the types of gestures that can be recognized and how they’re processed. These depend on the supporting instruments, which target different portions of the human body, obtain different sensor stimuli: Electric, Optic, Acoustic, Magnetic and Mechanic. These devices include: Gloves, Body Suits, Optical Trackers among others. Furthermore, vision-based techniques are incredibly varied and have several factors differentiating among themselves, by which broad fields of research and business are formed. The basic structure of a Gesture Recognition controller’s analysis involves two main tasks: Segmentation and Feature Extraction, features which are forwarded into a recognition module to build models. Segmentation is the extraction of the limbs of interest from background and determination of its location, while feature extraction is the determination of valuable data and cues among the segments. Not all input methods require the latter step, for example, magnetic sensors.\\\\\n    The Recognition module follows up with different approaches: \\emph{Hidden Markov Models} are a process governed by an underlying Markov chain with a finite number of states, and a random set of functions, each associated with each state. The transitions between states are based on probabilities. After each of a discrete amount of time, the system will be in one state and will observe a new symbol that feeds into the functions which will either yield a new state for the system, or output a recognized gesture for the followed chain. The chain involved a lot of mathematical modelling, producing a lot of deterministic integration, however, it can be seen as merely a sequence of observations and states, and thus it received the term “Hidden”. \\emph{Particle Filtering} or alternatively, Sequential Monte Carlo, are approximations to simulation-based methods. Works by representing probabilities of noisy and partial samples, building a predictive model for the likelihood of following states. The benefit of these over grid-based filters such as conventional Markov models, is these do end up modelling uncertainty. \\emph{The Finite State Machine} approach, by which a gesture is ordered by a sequence of states that vary in space and time. Each state is a datapoint of trajectory data, and the gesture is divided by each substantial change in trajectory data, sampled in a 2D space. Addition of gestures is achieved by constructing new FSM models and each gesture is matched to all the deterministic FSM’s. This does mean that adapting the system to more gestures requires incremental computational power, as well as adding winning criteria between gestures to choose the most likely when multiple are matched. \\emph{Soft Computing}, which is a number of techniques which involve computational intelligence and computer learning with high degree of tolerance for imprecisions and uncertainty. The system can be trained even while in use and adapts to users. Methods include fuzzy logic, genetic algorithms, artificial neural networks. These, however, require a large amount of data and iterations to find adequate robustness.\n", "meta": {"hexsha": "c5d9075c21d4c088bd340d13ef1cd44c5c64dca6", "size": 3822, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/Latex/chapters/Background/Gesture.tex", "max_stars_repo_name": "up201306506/ShamanicInterfaceProject", "max_stars_repo_head_hexsha": "3d7375e522404e3d21d010ceddb5dbf1514f8803", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Docs/Latex/chapters/Background/Gesture.tex", "max_issues_repo_name": "up201306506/ShamanicInterfaceProject", "max_issues_repo_head_hexsha": "3d7375e522404e3d21d010ceddb5dbf1514f8803", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Docs/Latex/chapters/Background/Gesture.tex", "max_forks_repo_name": "up201306506/ShamanicInterfaceProject", "max_forks_repo_head_hexsha": "3d7375e522404e3d21d010ceddb5dbf1514f8803", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 764.4, "max_line_length": 2135, "alphanum_fraction": 0.8210361068, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.44746509070984886}}
{"text": "% Standard Article Definition\n\\documentclass[]{article}\n\n% Page Formatting\n\\usepackage[margin=1in]{geometry}\n\\setlength\\parindent{0pt}\n\n% Graphics\n\\usepackage{graphicx}\n\n% Math Packages\n\\usepackage{physics}\n\\usepackage{amsmath, amsfonts, amssymb, amsthm}\n\\usepackage{mathtools}\n\n% Extra Packages\n\\usepackage{listings}\n\\usepackage{hyperref}\n\n% Section Heading Settings\n\\usepackage{enumitem}\n\\renewcommand{\\theenumi}{\\alph{enumi}}\n\\renewcommand*{\\thesection}{Problem \\arabic{section}}\n\\renewcommand*{\\thesubsection}{\\alph{subsection})}\n\\renewcommand*{\\thesubsubsection}{\\quad \\quad \\roman{subsubsection})}\n\n%Custom Commands\n\\newcommand{\\Rel}{\\mathcal{R}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\n\\newcommand{\\toI}{\\xrightarrow{\\textsf{\\tiny I}}}\n\\newcommand{\\toS}{\\xrightarrow{\\textsf{\\tiny S}}}\n\\newcommand{\\toB}{\\xrightarrow{\\textsf{\\tiny B}}}\n\n\\newcommand{\\divisible}{ \\ \\vdots \\ }\n\\newcommand{\\st}{\\ : \\ }\n\n\n% Theorem Definition\n\\newtheorem{definition}{Definition}\n\\newtheorem{assumption}{Assumption}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{proposition}{Proposition}\n\\newtheorem{example}{Example}\n\n\n%opening\n\\title{MATH 5301 Elementary Analysis - Final Exam}\n\\author{Jonas Wagner}\n\\date{2021, December 7\\textsuperscript{th}}\n\n\\begin{document}\n\n\\maketitle\n\n% Problem 1 ----------------------------------------------\n\\section{}\nFor each $n \\in \\N$ define the set\n\\[\n    Q_n := \\qty{\n        \\frac{1}{pq} \\st 0 < p < q \\leq n; \\ p + q > n; \\ \\textnormal{gcd}(p,q) = 1\n    }\n\\]\nLet $f(n)$ be the sum of all elements of $Q_n$.\n\nFind $\\inf_n f(n)$.\n\n\\begin{definition}\\label{def:pblm1_Qn}\n    Let the set $Q_n$ be defined for all $n \\in \\N$ as\n    \\[\n        Q_n := \\qty{\n            \\frac{1}{pq} \\st 0 < p < q \\leq n; \\ p + q > n; \\ \\gcd(p,q) = 1\n        }\n    \\]\n\\end{definition}\n\n\\begin{definition}\\label{def:pblm1_fn}\n    Let $f(n)$ be the sum of all elements within $Q_n$.\n\\end{definition}\n\n\\begin{definition}\\label{def:infimum}\n    A lower bound of subset $A$ in the partially ordered set $(S,\\leq)$ is defined by\n    \\[\n        a \\in S \\st a \\leq x \\forall_{x \\in A}\n    \\]\n    A lower bound of $a$ is called an \\emph{\\underline{infimum}} of set $A \\in (S,\\leq)$,\n    denoted as $a = \\inf A$, is the greatest lower bound. i.e.\n    \\[\n        \\forall_{y \\in S : a \\leq x \\forall_{x \\in A}} y \\leq a\n    \\]\n\\end{definition}\n\n\\begin{definition}\n    The \\underline{\\emph{Greatest Common Divisor}} of two nonzero integers $a,b \\in \\Z \\neq 0$, $\\gcd(a,b)$, \n    is defined as the largest positive integer, $d \\in \\Z_+$, so that $d$ is a divisor of both $a$ and $b$.\n    i.e:\n    \\[\n        \\gcd(a,b) := d \\in \\Z_+ \\st (a \\divisible d) \\land (b \\divisible d) \n                    \\land (\\forall_{x \\in \\Z_+ \\st a,b \\divisible x} d \\geq x)\n    \\]\n    Additionally, $a$ and $b$ are considered \\emph{\\underline{coprime}} if $\\gcd(a,b) = 1$.\n\\end{definition}\n\n\\begin{assumption}\n    For this problem it is assumed that $\\gcd$ is only defined within $\\Z_+$, \n    although I believe this can also be expanded to other less-strict ordered sets in the same way.\n\\end{assumption}\n\n\\begin{assumption}\n    It is assumed that the sum of all elements in the empty set is 0, i.e. $\\sum_{i} \\emptyset = 0$.\n\\end{assumption}\n\n\\newpage\n\\begin{theorem}\n    \\[\n        \\inf_{n \\in \\N} f(n) = 0\n    \\]\n\n    \\begin{proof}\n        Proof by induction.\n\n        For $n = 1$, \n            $\\lnot \\exists_{p,q \\in \\Z \\st 0<p<q\\leq 1}$ meaning that $Q_1 = \\emptyset$.\n            \n            This implies that $f(1) = \\sum_{i} \\emptyset = 0$ and that $f(1) \\geq 0$.\n\n        For $n = 2$, \n        \\[\n            (p,q) \\in \\qty{(p,q) \\st 0 < p < q \\leq 2; \\ p + q > n; \\ \\gcd(p,q) = 1} = \\qty{(1,2)}\n        \\]    \n        The set $Q_2$ is then defined as\n        \\[\n            Q_2 = \\qty{\\frac{1}{pq} \\st (p,q) \\in \\qty{(1,2)}}\n                = \\qty{\\frac{1}{(1)(2)}}\n                = \\qty{\\frac{1}{2}}\n        \\]\n        Therefore,\n        \\[\n            f(2) = \\sum_{i} \\qty{\\frac{1}{2}} = \\frac{1}{2}\n        \\]\n        It is clear that $f(2) = \\frac{1}{2} \\geq 0$.\n\n        For $n = 3$,\n        \\[\n            (p,q) \\in \\qty{(p,q) \\st 0 < p < q \\leq 3; \\ p + q > n; \\ \\gcd(p,q) = 1} \n                = \\qty{(1,3),(2,3)}\n        \\]\n        The set $Q_3$ is then defined as\n        \\[\n            Q_3 = \\qty{\\frac{1}{pq} \\st (p,q) \\in \\qty{(1,3),(2,3)}}\n                = \\qty{\\frac{1}{(1)(3)}, \\frac{1}{(2)(3)}}\n                = \\qty{\\frac{1}{3}, \\frac{1}{6}}\n        \\]\n        Therefore,\n        \\[\n            f(3) = \\sum_{i} \\qty{\\frac{1}{3}, \\frac{1}{6}} \n                = \\frac{1}{3} + \\frac{1}{6} \n                = \\frac{2 + 1}{6}\n                = \\frac{3}{6}\n                = \\frac{1}{2}\n        \\]\n        It is clear that $f(3) = \\frac{1}{2} \\geq 0$.\n\n        For $n = 4$,\n        \\[\n            (p,q) \\in \\qty{(p,q) \\st 0 < p < q \\leq 4; \\ p + q > n; \\ \\gcd(p,q) = 1} \n                = \\qty{(1,4),(2,3),(3,4)}\n        \\]\n        The set $Q_4$ is then defined as\n        \\[\n            Q_4 = \\qty{\\frac{1}{pq} \\st (p,q) \\in \\qty{(2,3),(3,4)}}\n                = \\qty{\\frac{1}{(1)(4)}, \\frac{1}{(2)(3)}, \\frac{1}{(3)(4)}}\n                = \\qty{\\frac{1}{4},\\frac{1}{6}, \\frac{1}{12}}\n        \\]\n        Therefore,\n        \\[\n            f(4) = \\sum_{i} \\qty{\\frac{1}{6}, \\frac{1}{12}}\n                = \\frac{1}{4} + \\frac{1}{6} + \\frac{1}{12}\n                = \\frac{3 + 2 + 1}{12}\n                = \\frac{6}{12}\n                = \\frac{1}{2}\n        \\]\n        It is clear that $f(4) = \\frac{1}{2} \\geq 0$.\n\n        % For $n = 5$,\n        % \\[\n        %     (p,q) \\in \\qty{(p,q) \\st 0 < p < q \\leq 5; \\ p + q > n; \\ \\gcd(p,q) = 1} \n        %         = \\qty{(1,5),(2,5),(3,4),(3,5),(4,5)}\n        % \\]\n        % The set $Q_5$ is then defined as\n        % \\[\n        %     Q_5 = \\qty{\\frac{1}{pq} \\st (p,q) \\in \\qty{(1,5),(2,5),(3,4),(3,5),(4,5)}}\n        %         = \\qty{\\frac{1}{(1)(5)}, \\frac{1}{(2)(5)}, \\frac{1}{(3)(4)}, \\frac{1}{(3)(5)}, \\frac{1}{(4)(5)}}\n        %         = \\qty{\\frac{1}{5}, \\frac{1}{10}, \\frac{1}{12}, \\frac{1}{15}, \\frac{1}{20}}\n        % \\]\n        % Therefore,\n        % \\[\n        %     f(5) = \\sum_{i} \\qty{\\frac{1}{5}, \\frac{1}{10}, \n        %                         \\frac{1}{12}, \\frac{1}{15}, \\frac{1}{20}}\n        %         = \\frac{1}{5} + \\frac{1}{10} + \\frac{1}{12} + \\frac{1}{15} + \\frac{1}{20}\n        %         = \\frac{1}{2}\n        % \\]\n        % It is clear that $f(5) = \\frac{1}{2} \\geq 0$\n\n\n        For an arbitrary $n \\in \\N$,\n        \\begin{align*}\n            (p,q) &\\in \\qty{(p,q) \\st 0 < p < q \\leq n; \\ p + q > n; \\ \\gcd(p,q) = 1} =\\\\\n                &= \\qty{(1,n), (2,n - \\star), (3, n - \\star) \\dots, (n-2, n-1), (n-1, n)}\n        \\end{align*}\n        \\begin{align*}\n            Q_n &= \\qty{\\frac{1}{pq} \\st (p,q) \\in \\qty{(1,n), (2,n-\\star), \\dots, (n-2, n-1), (n-1, n)}}\\\\\n                &= \\qty{\\frac{1}{(1)(n)}, \\frac{1}{(2)(n-1)}, \\dots, \\frac{1}{(n-2)(n-1)}, \\frac{1}{(n-1)(n)}}\\\\\n                &= \\qty{\\frac{1}{n}, \\frac{1}{2(n-\\star)}, \\dots, \\frac{1}{(n-2)(n-1)}, \\frac{1}{n(n-1)}}\n        \\end{align*}\n\n        where $\\star$ is dependent for on divisibility properties between $n$ and 2, 3, 4, etc.\n        It is important to note that each increase of $n$ will cause every term to decrease in magnitude individually but additional elements are added that result to adding up to $\\frac{1}{2}$ again.\n\n        However, eventually this will reach a point where a lack of prime numbers in a region makes it so that the only coprime numbers satisfying the conditions are adjacent to one another, which leads to the following:\n        \\begin{align*}\n            f(n)    &= \\sum_{i} Q_n = \\frac{1}{n} + \\dots + \\frac{1}{(\\frac{n}{2}) (\\frac{n}{2}+1)} + \\dots + \\frac{1}{n (n-1)}\\\\\n            f(n+1)  &= \\qty(\\sum_{i} Q_n) \\qty(\\frac{n!}{(n+1)!}) + \\frac{1}{(n+1)}\\\\\n                    &= \\frac{1}{n} \\frac{n!}{(n+1)!} + \\dots + \\frac{1}{(\\frac{n}{2}) (\\frac{n}{2}+1)} \\frac{n!}{(n+1)!} + \\dots + \\frac{1}{n (n-1)} \\frac{n!}{(n+1)!} + \\frac{1}{n+1}\\\\\n                    &= \\frac{n!}{n(n+1)n!} + \\dots + \\frac{n!}{\\frac{n}{2}(\\frac{n}{2}-1)(n+1)n!} + \\dots + \\frac{n!}{n (n-1) (n+1) n!} + \\frac{1}{n+1}\\\\\n                    &= \\sum_{i} Q_{n+1} = \\frac{1}{n+1} + \\dots + \\frac{1}{(\\frac{n+1}{2}) (\\frac{n+1}{2}+1)} + \\dots + \\frac{1}{n (n+1)}\n        \\end{align*}\n        essentially every $(p,q)$ becomes $(q,q+1)$ and the new $\\frac{1}{(n+1)}$ is added.\n\n\n        Anyway, the point is that $\\forall_{n\\in\\N \\st n>1} f(n) \\geq \\frac{1}{2}$; \n        however, because $f(n)$ is included, $\\frac{1}{2} \\leq f(n) \\forall_{n \\in N}$ since $Q_1 = \\emptyset \\implies f(1) = 0$.\n\n        Therefore,\n        \\[\n            \\inf_n f(n) = 0\n        \\]\n\n        % Therefore,\n        % \\begin{align*}\n        %     f_{even}(n) &= \\sum_{i} \\qty{\\frac{1}{n}, \\frac{1}{2(n-1)}, \\dots, \\frac{1}{(n-2)(n-1)}, \\frac{1}{n(n-1)}}\\\\\n        %         &= \\frac{1}{n} + \\frac{1}{2(n-1)} + \\dots + \\frac{1}{(n-2)(n-1)} \\frac{1}{n(n-1)}\\\\\n        %         &= \\frac{\n        %                 (n-1)(n-2)\\cdots(3)(2) + (n)(n-2)\\cdots(3)(1) + \\dots + (n-2)(n-3)\\cdots(2)(1)\n        %             }{\n        %                 n(n-1)(n-2)\\cdots(3)(2)(1)\n        %             }\\\\\n        %         &= \\frac{\n        %                 \\sum_{i=1}^n \\frac{n!}{(i)(n-i)}\n        %             }{\n        %                 n!\n        %             }\n        % \\end{align*}\n\n        % Something similar is true for $n \\in \\N \\st n + 1 \\divisible 2$,\n        % but in reality it isn't important for the proof,\n        % \\begin{align*}\n        %     f_{odd}(n) &= \\sum_{i} \\qty{\\frac{1}{n}, \\frac{1}{2(n)}, \\dots, \\frac{1}{(n-2)(n-1)}, \\frac{1}{n(n-1)}}\\\\\n        %         &= \\frac{1}{n} + \\frac{1}{2(n)} + \\dots + \\frac{1}{(n-2)(n-1)} \\frac{1}{n(n-1)}\\\\\n        %         &= \\frac{\n        %             \\sum_{i=1}^n \\frac{n!}{(n)(n-i)}\n        %         }{n!}\n        % \\end{align*}\n        \n        \n        % When it is known that $f(n) = \\frac{1}{2}$,\n        % \\begin{align*}\n        %     f(n)_{even} = \\frac{1}{2}\n        %         &= \\frac{1}{n} + \\frac{1}{2(n-1)} + \\dots + \\frac{1}{(n-2)(n-1)} \\frac{1}{n(n-1)}\n        % \\end{align*}\n        \n        % Then this is also true for $f(n+1)$ as shown \n        % (with not much algebraic detail since the answer itself remains trivial...)\n        % \\begin{align*}\n        %     f_{odd}(n+1) &= \\frac{1}{n+1} + \\frac{2(n+1)} + \\dots + \\frac{(n-2)(n-1)} + frac{(n+1)(n + 1 - 1)}\\\\\n        %                 &= \n        % \\end{align*}\n\n        \n\n\n        % Since it is known that the set with the least number of elements is $\\emptyset$\n        %     and that $f(n) = 0 \\forall_{n} \\st Q_n = \\emptyset$, and that \n    \\end{proof}\n\\end{theorem}\n\n\n\n\n% Problem 2 ----------------------------------------------\n\\newpage\n\\section{}\nLet $(X,d)$ be a metric space.\nLet $B_r(a)$ denote the open ball of radius $r$ centered at $a$.\ni.e.\nCan it happen that $B_{r_1}(a) \\subset B_{r_2}(a)$ but $r_1 > r_2$?\n\n\\begin{definition}\\label{def:open_ball}\n    Within the metric space $(X,d)$, \n    the open ball of radius $r \\in X$ centered at $a \\in X$, \n    denoted as $B_r(a)$, is defined as:\n    \\[\n        B_r(a) := \\qty{x \\in X \\st d(a,x) < r}\n    \\]\n\\end{definition}\n\n\\begin{assumption}\\label{ass:normed_metric}\n    First it will be assumed that $(X,d)$ is a normed vector space.\n    This restricts the metric and metric space into a normed space.\n    This can also be denoted as $(X,\\norm{\\cdot})$ to distinguish between them.\n    It is also assumed that $X$ is complete.\n\\end{assumption}\n\n\\begin{theorem}\n    For  $r_1 > r_2$ then it is not possible for $B_{r_1}(a) \\subset B_{r_2}(b)$ within $(X, \\norm{\\cdot})$:\n    \\begin{proof}\n        Proof by contradiction.\n        \n        Let \\[\n            B_{r_1}(a), B_{r_2}(b) \\subset X\n        \\]\n        with $0 < r_2 < r_1$\n        and $a \\in B_{r_2}(b)$.\n\n        To minimize the amount of the set existing outside of the set,\n        we need to set $a = b$.\n        Next, let $c$ be a point within the punctured open ball $B_{r_2}(b)$.\n        i.e.\\[\n            c \\in B_{r_2}(b) \\backslash \\{b\\}\n        \\]\n        $c$ can then be used to construct a point that is contained in $B_{r_2}(b)$ but not in $B_{r_1}(a)$:\n        \\[\n            p + \\frac{r_1 + r_2}{2} \\frac{a c}{\\norm{a c}} \\in B_{r_1}(a) \\backslash B_{r_2}(b)\n        \\]\n        Meaning that there is no possible way for an open ball of greater radius (within a normed metric space).\n    \\end{proof}\n\\end{theorem}\n\n\\begin{assumption}\n    The previous assumption, Assumption \\ref{ass:normed_metric}, is now relax the metric so that $d$ is not restricted to be a norm (i.e. may not be linear).\n\\end{assumption}\n\n\\begin{theorem}\n    It is possible for $B_{r_1}(a) \\subset B_{r_2}(b)$ within $(X, d)$ when $r_1 > r_2$:\n    \\begin{proof}\n        Proof by example:\n\n        Let metric space $(X, d)$ be defined by\n        \\[X := {0} \\cup [5, \\infty)\\]\n        \\[d(x,y) := \\abs{x - y}\\]\n\n        For $r_1 = 4$, $r_2 = 3$, \n\n        Let $B_4(0)$ be defined as\n        \\[\n            B_4(0) := \\qty{4\n                x \\in X \\st d(0,x) < 4\n            } = \\{0\\} \\cup [2,4)\n        \\]\n        \n        Let $B_3(2)$ be defined as\n        \\[\n            B_3(2) := \\qty{\n                x \\in X \\st d(2,x) < 3\n            } = \\{0\\} \\cup [2, 5)\n        \\]\n\n        Clearly, $B_3(2) \\subset B_4(0)$.\n        Since $r_1 = 4 > r_2 = 3$, this exists as an example that satisfies the conditions.\n    \\end{proof}\n\\end{theorem}\n\n\n% Problem 3 ----------------------------------------------\n\\newpage\n\\section{}\nLet $M$ be the set of all bounded sequences\n\\[\n    M = \\qty{\\{a_j\\}_{j=1}^{\\infty} \\st \\abs{a_j} < \\infty}\n\\]\nDefine $\\rho(\\{a_n\\},\\{b_n\\}) = \\max_{n \\in \\N} \\abs{a_n - b_n}$\n\n\\begin{definition}\\label{def:metric}\n    Function $d : X \\cross X \\to \\R$ is considered a \\underline{\\emph{metric}} \n    if it satisfies all of the following:\n    \\begin{enumerate}\n        \\item Non-negativity:\n            \\[d(a,b) \\geq 0\\]\n        \\item Symmetry:\n            \\[d(a,b) = d(b,a)\\]\n        \\item Triangle Inequality:\n            \\[d(a,c) \\leq d(a,b) + d(b,c)\\]\n    \\end{enumerate}\n\\end{definition}\n\n\\subsection{Show that $(M,\\rho)$ is a metric space.}\n\n\\begin{theorem}\n    Let $M$ be defined as the set of all bounded sequences:\\[\n        M = \\qty{\\{a_j\\}_{j=1}^{\\infty} \\st \\abs{a_j} < \\infty}\n    \\]\n    Let the metric $\\rho$ be defined on $M$ such that\\[\n        \\rho(\\{a_n\\},\\{b_n\\}) = \\max_{n\\in\\N} \\abs{a_n - b_n}\n    \\]\n    The metric space $(M, \\rho)$ is in fact a metric space.\n    \\begin{proof}\n        From Definition \\ref{def:metric}, $\\rho$ is a metric if \n        $\\forall_{\\{a_n\\},\\{b_n\\},\\{c_n\\}} \\in M$ \n        these three conditions are all satisfied: \n            (i) non-negativity, \n            (ii) Symmetry, and \n            (iii) Triangle Inequality.\n        \\begin{enumerate}\n            \\item Non-negativity:\n            \\begin{align*}\n                d(a,b) &\\geq 0\\\\\n                \\rho(\\{a_n\\},\\{b_n\\}) = \\max_{n \\in \\N} \\abs{a_n - b_n} &\\geq 0\\\\\n            \\end{align*}\n            \\item Symmetry:\n            \\begin{align*}\n                d(a,b) &= d(b,a)\\\\\n                \\rho(\\{a_n\\},\\{b_n\\}) = \\max_{n \\in \\N} \\abs{a_n - b_n} \n                    &= \\max_{n \\in \\N} \\abs{b_n - a_n} = \\rho(\\{a_n\\},\\{b_n\\})\n            \\end{align*}\n            \\item Triangle Inequality:\n            \\begin{align*}\n                d(a,c) &\\leq d(a,b) + d(b,c)\\\\\n                \\rho(\\{a_n\\},\\{c_n\\}) \n                    &\\leq \\rho(\\{a_n\\},\\{b_n\\}) + \\rho(\\{b_n\\},\\{c_n\\})\\\\\n                \\max_{n \\in \\N} \\abs{a_n - c_n} \n                    \\leq \\max{n \\in \\N} \\abs{a_n - b_n} + \\abs{b_n - c_n}    \n                    &\\leq \\max_{n \\in \\N} \\abs{a_n - b_n} \n                        + \\max_{n \\in \\N} \\abs{b_n - c_n}\n            \\end{align*}\n        \\end{enumerate}\n    \\end{proof}\n\\end{theorem}\n\n\n\\newpage\n\\subsection{Show that $M$ does not contain a dense countable subset.}\n\n% (Hint: recall the very first example of uncountable set...)\n\n\\begin{definition}\\label{def:closure}\n    The \\underline{\\emph{Closure}}, $\\overline{A}$, of $A \\subset X$ is defined as\n    \\[\n        \\overline{A} = A \\cup \\qty{\n            \\lim_{n\\to\\infty} a_n \\st a_n \\in A \\forall_{n \\in \\N}\n        }\n    \\]\n\\end{definition}\n\n\\begin{definition}\\label{def:dense}\n    A set $A \\subset X$ is considered \\underline{\\emph{dense}} in $X$ if $\\overline{A} = X$.\n\\end{definition}\n\n\\begin{theorem}\\label{thm:cantor}\n    For the power set, $\\mathcal{P}(A)$, \n    defined as the collections of all sets constructed from the elements of $A$, \n    then the cardinality of $\\mathcal{P}(A)$ will always be strictly greater then that of $A$.\n    i.e.\\[\n        \\abs{2^{A}} > \\abs{A}\n    \\]\n    \\begin{itemize}\n        \\item This is also applicable to infinite sets with whether it is countable or not.\n        i.e\\[\n            \\abs{2^\\N} = \\aleph_1 > \\abs{\\N} = \\aleph_0\n        \\]\n        \\item The theorem itself is that any mapping from $A$ to $\\mathcal{P}(A)$ is not surjective which is then proven false.\n        It then follows that $f : A \\toI \\mathcal{P}(A)$ is injective, \n        which is equivalent to saying that $\\abs{A} < \\abs{\\mathcal{P}(A)}$.\n    \\end{itemize}\n\\end{theorem}\n\n\\begin{theorem}\n    $M$ does not contain any dense countable subsets.\n    \\begin{proof}\n        Proof by contradiction inspired by Cantor's Theorem (\\ref{thm:cantor}).\n\n        Let $A_N \\subset M$ be defined as \n        \\[\n            A_N := \\{\\{a_j\\}_{j=1}^{\\infty} \\st \\abs{a_j} < N\\}\n        \\]\n\n        Similarly to Cantor's theorem, even when restricting $a_j$ from a finely sized set,\n        the only mapping that exists from a countable set into $A_n$ are strictly injective. \n        \n        Next, taking $A = \\lim_{N \\to \\infty} A_N$, \n        we will prove that in order for $A$ to be dense, $A$ would no longer be countable.\n\n        From Definition \\ref{def:closure} and Definition \\ref{def:dense}, \n        it is known that in order for $A$ to be dense within $M$, \n        $\\overline{A} = M$. \n        Since $M$ itself is an infinite set, \n        even if for sequences of a finite set of numbers,\n        $A$ would become infinite and ultimately uncountable with $\\abs{A} \\leq \\abs{M}$.\n    \\end{proof}\n\\end{theorem}\n\n% Problem 4 ----------------------------------------------\n\\newpage\n\\section{}\nDoes there exist a metric space, containing a sequence of nested bounded closed sets \n$F_1 \\supset F_2 \\supset \\cdots \\supset F_n \\supset \\cdots$\nsuch that\n\\[\n    \\bigcap_{n \\in \\N} F_n = \\emptyset\n\\]\nHint: If $d(x,y)$ is a usual Euclidean metric on $\\R$, \none can shown that $\\frac{d(x,y)}{1 + d(x,y)}$ is also a metric.\nSuch metric is often called a bounded metric...\n\n\\begin{definition}\n    The set $A$ in metric space $(X,d)$ is considered \\emph{\\underline{open}} if \n    \\[\n        \\forall_{x \\in A} \\exists_{\\epsilon > 0} \\st \\forall_{y \\in X} d(x,y)<\\epsilon\n    \\]\n\\end{definition}\n\n\\begin{definition}\n    The set $A$ in metric space $(X,d)$ is considered \\emph{\\underline{closed}} if the set $A^c$ is open.\n\\end{definition}\n\n\\begin{definition}\n    The set $A$ in metric space $(X,d)$ is called \\emph{\\underline{bounded}} if\n    \\[\n        \\forall_{x \\in A} \\exists_{R>0} \\st \\forall_{y\\in A} d(x,y) < R\n    \\]\n\\end{definition}\n\n\\begin{theorem}\n    There does exist a metric space $(X,d)$ \n    containing the sequence of nested bounded closed sets \n    $F_1 \\supset F_2 \\supset \\cdots \\supset F_n \\supset \\cdots$\n    such that \\[\n        \\bigcap_{n \\in \\N} F_n = \\emptyset\n    \\]\n    \\begin{proof}\n        Let the metric space $(X,d)$ be defined with\\[\n            X := \\R \\backslash \\{0\\}\n        \\]\n        and endowed with the Euclidean metric $d : \\R \\cross \\R$ defined by:\\[\n            d(x,y) := \\sqrt{(x-y)^2}\n        \\]\n        \n        Let $F_1 \\subset X$ be defined for:\\[\n            F_1 := B_{r_1}(0) = \\qty{\n                x \\in X \\st d(0,x) \\leq r_1\n            }\n        \\]\n        where $r_1$ is initialized arbitrarily large.\n\n        For $n = 2, 3, \\dots$, \n        $F_n \\supset \\cdots \\supset F_2 \\subset F_1 \\subset X$ is defined by:\n        \\[\n           F_n := B_{r_n}(0) = \\qty{\n               x \\in X \\st d(0,x) \\leq r_n\n           }\n        \\]\n        where $r_{n+1} = \\frac{r_n}{1+r_n}$.\n\n        Finally, the solution is very obvious that the origin is the only limit point of the intersection.\\[\n            \\lim_{N \\to \\infty} \\cap_{n < N} F_n = \\{0\\}\n        \\] \n        However, within this particular metric space, where $X = \\R \\backslash \\{0\\}$, this limit is not within the sets themselves.\n        Therefore,\n        \\[\n            \\cap_{n \\in \\N} F_n = 0\n        \\]\n    \\end{proof}\n\\end{theorem}\n\n\n\n\n% Problem 5 ----------------------------------------------\n\\newpage\n\\section{}\nShow that there exists a unique continuous function, \n$f(x)$ on the interval $[0,1]$,\nsatisfying the equation\n\\[\n    f(x) = \\int_{0}^{1} \\sin(x^2 + y^ 2) f(y) \\dd y\n\\]\n\n\\begin{theorem}\n    There exists a unique continuous function $f : [0,1] \\to \\R$\n    that satisfies the following equation\n    \\begin{equation}\\label{eq:pblm5}\n        f(x) = \\int_{0}^{1} \\sin(x^2 + y^ 2) f(y) \\dd y\n    \\end{equation}\n    \\begin{proof}\n        I'll prove that the is only a single solution by essentially treating the integral statement as a set of systems of equations (but with an operator) and then demonstrate that the solution function is unique as a contradiction would occur otherwise.\n\n        Let $T$ be a functional mapping of the $f(y)$ to $f(x)$, \n        $T : \\mathbb{C}([0,1]) \\to \\mathbb{C}([0,1])$, defined as:\n        \\[\n            T(f(y)) := \\int_{0}^{1} \\sin(x^2 + y^ 2) f(y) \\dd{y}\n        \\]\n\n        Now we take $T(f(x)) = f(x)$ and make the claim $f(x)$ is not unique.\n        This would mean that $T(g(x)) = g(x)$ is another solution.\n        If there are multiple solutions, then the following would be true:\n        \\begin{align*}\n            T(f(x)) - f(x) \n                &= T(g(x)) - g(x)\\\\\n            \\int_{0}^{1} \\sin(x^2 + y^2) f(y) \\dd{y} - f(x)\n                &= \\int_{0}^{1} \\sin(x^2 + y^2) g(y) \\dd{y} - g(x)\\\\\n            f(x) - g(x)\n                &= \\int_{0}^{1} \\sin(x^2 + y^2) f(y) \\dd{y}\n                - \\int_{0}^{1} \\sin(x^2 + y^2) g(y) \\dd{y}\\\\\n            f(x) - g(x)\n                &= \\int_{0}^{1} \\sin(x^2 + y^2) (f(y) - g(y)) \\dd{y}\n            \\intertext{Since $\\abs{\\sin{x}}\\leq 1 \\implies \\int_0^1 \\sin(x) \\dd{x} < 1$,}\n                &< \\int_{0}^{1} (f(y) - g(y)) \\dd{y} \\leq\n            \\intertext{Since we can look at the integral over the region as less then the maximum value times the width:}\n                &\\leq (1-0) \\sup_{y \\in [0,1]} (f(y) - g(y))\\\\\n            f(x) - g(x)\n                & < \\sup_{y \\in [0,1]} (f(y) - g(y))\n        \\end{align*}\n        Which is not possible, leading to the claim that two solutions exist to be false.\n    \\end{proof}\n\\end{theorem}\n\n% Problem 6 ----------------------------------------------\n\\newpage\n\\section{}\nLet $V$ be a complete metric space without isolated points.\nShow that $V$ is uncountable $(\\abs{V} > \\abs{\\N})$.\n\n\\begin{definition}\\label{def:complete_cauchy_limit}\n    A metric space $(X,d)$ is considered \\emph{\\underline{Complete}} \n    if every Cauchy sequence of points in $X$ has a limit within $X$.\n    \\begin{itemize}\n        \\item A sequence $x_1, x_2, \\dots$ in metric space $(X,d)$ \n        is considered \\emph{\\underline{Cauchy}} if\n        \\[\n            \\forall_{r > 0} \\exists_N \\st \\forall_{m,n > N} d(x_m,x_n) < r\n        \\]\n        \\item $x$ is the \\underline{\\emph{limit}} of sequence ($x_n$), \n        $\\lim_{n \\to \\infty} x_n$, if\n        \\[\n            \\forall_{\\epsilon>0} \\exists_{N \\in \\N} \\st \\forall_{n\\geq N} \\abs{x_n - x} < \\epsilon\n        \\]\n    \\end{itemize}\n\\end{definition}\n\n\\begin{definition}\\label{def:isolated_points}\n    A point within metric space $(X,d)$ is considered an \n    \\emph{\\underline{isolated point}} of set $A \\subset X$ \n    in which no other points are within the neighborhood of $x$.\n    i.e.\\[\n        \\exists_{\\epsilon>0} \\st \\forall_{y \\in X} \n            \\st d(x,y) < \\epsilon y \\implies \\not \\in A\n    \\]\n    \\begin{itemize}\n        \\item A complete set $A$ that contains no isolated points is called \n            \\emph{\\underline{dense-in-itself}}.\n    \\end{itemize}\n\\end{definition}\n\n\\begin{definition}\\label{def:sur/in/bijective_funcs}\n    A \\emph{\\underline{one to one correspondance}} is also known as a \n    bijective function that maps $\\N \\to X$.\n    \\begin{itemize}\n        \\item A function $f : \\N \\to A$ is said to be \\underline{\\emph{surjective}} if\\[\n            \\exists_{f : \\N \\toS A} \\iff \n            \\exists_{f : \\N \\to A} \\st \\forall_{x \\in \\N} \\exists f(x) \\in A\n        \\]\n\n        \\item A function $f : \\N \\to A$ is said to be \\underline{\\emph{injective}} if\\[\n            \\exists_{f : \\N \\toI A} \\iff \n            \\exists_{f : \\N \\to A} \\st \\forall_{f(x) \\in A} \\exists_{x \\in \\N}\n        \\]\n\n        \\item A function $f : A \\to B$ is said to be \\underline{\\emph{bijective}} \n        if $f$ is both surjective and injective.\n        i.e.\\[\n            \\exists_{f : A \\toB B} \\iff \n            \\exists_{f : A \\to B} \\st \n                \\qty(\\forall{x \\in A} \\exists_{f(x) \\in B}) \\land\n                \\qty(\\forall{y \\in B} \\exists_{f^{-1}(y) \\in A})\n        \\]\n    \\end{itemize}\n\\end{definition}\n\n\\begin{definition}\\label{def:cardinalityAndCountable}\n    The \\emph{\\underline{Cardinality}} of set $A$,\n        denoted as $\\abs{A}$,\n        is the number of unique elements contained within $A$.\n    \\begin{itemize}\n        \\item A set $A$ is considered \\emph{\\underline{Countable}} if $\\abs{A} \\leq \\abs{\\N}$. \n        This is also said to be true if a surjective function exists mapping $\\N$ to $A$.\n        \n        \\item Set $A$ and $B$ within metric space $(X,d)$ are said be of the same cardinality,\n        $\\abs{A}=\\abs{B}$, \n        if there exists a bijective mapping between $A$ and $B$, $f : A \\toB B$.\n\n        \\item If $A$ is an infinite set, then $A$ is \\emph{\\underline{Countably Infinite}},\n        $\\abs{A} = \\aleph_0 = \\abs{\\N}$, \n        if there exists a one to one correspondence from $\\N$ to $A$.\n        \n        \\item For $A$ A set $A$ is considered \\emph{\\underline{uncountable}} if it is not countable.\n        i.e. $\\abs{A} > \\abs{\\N}$. \n        This is also said to be true if an injective function exists mapping $\\N$ to $A$, \n        but that no surjective mappings exist.\n    \\end{itemize}\n\\end{definition}\n\n\\begin{theorem}\n    A complete metric space, $(V,d)$, that contains no isolated point is uncountable.\n    \\begin{proof}\n        From Definition \\ref{def:complete_cauchy_limit}, \n        we have that all cauchy sequences in the complete metric space $(X,d)$ must have a limit in $X$.\n        \n        From Definition \\ref{def:cardinalityAndCountable}, \n        it is known that within all countable sets there exists a one-to-one correspondence between $\\N$ and the set $A$.\n        \n        For $A$ to be uncountable, an injective function mapping $\\N$ to $A$, there exists, $f : \\N \\toI A$. \n\n        From Definition \\ref{def:sur/in/bijective_funcs}, this means that \n        $\\forall_{f(x) \\in A} \\exists_{x \\in \\N}$,\n        however, since $\\N$ is not a complete set, it is not possible for a one-to-one correspondence to exist.\n        Therefore, the set is not countable and therefore uncountable.\n    \\end{proof}\n\\end{theorem}\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "72c9a804f0efb8cc3a886ce3d1be99519834e172", "size": 27583, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Exams/Exam2/MATH5301-FinalExam.tex", "max_stars_repo_name": "jonaswagner2826/MATH5301", "max_stars_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-01T05:26:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-01T05:26:53.000Z", "max_issues_repo_path": "Exams/Exam2/MATH5301-FinalExam.tex", "max_issues_repo_name": "jonaswagner2826/MATH5301", "max_issues_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Exams/Exam2/MATH5301-FinalExam.tex", "max_forks_repo_name": "jonaswagner2826/MATH5301", "max_forks_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.3753387534, "max_line_length": 256, "alphanum_fraction": 0.5126345938, "num_tokens": 9552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.4474650819081358}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{graphicx,wrapfig,lipsum}\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#3}\n\\newcommand{\\hmwkDueDate}{Due on 23rd October, 2018}\n\\newcommand{\\hmwkClass}{Fluid Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n\\textbf{Acknowledgements} - I thank Saumav Kapoor for discussions.\n\n\n%\\pagebreak\n\\begin{homeworkProblem}[1]\n\t\\textbf{Part (a)}\\\\\n\tThe unsteady state Bernoulli equation tells us that,\n\t\\begin{align*}\n\t\\pdv{\\phi}{t} + \\dfrac{P_{atm}}{\\rho} + \\dfrac{v^2}{2} + gz &= constant\\\\\n\t\\pdv{v}{t} + v\\pdv{v}{y} + g &= 0\n\t\\end{align*}\n\twhere we have differentiated with $ y $ going from the first to the second line.\n\t\n\tFrom the geometry of the cone, we have,\n\t\\begin{align*}\n\tr_1 &= r_0 +y \\tan \\alpha\\\\\n\t\\pi r_1^2 &= \\pi r_0^2 + \\pi y^2 \\tan^2 \\alpha + 2\\pi r_0 y \\tan \\alpha\\\\\n\tA_1 &= \\pi r_0^2 + \\pi y^2 \\tan^2 \\alpha + 2 \\sqrt{A \\pi } y \\tan \\alpha\t\\end{align*}\n\tFrom this and the continuity equation, we get,\n\\begin{align*}\nv = \\dfrac{r_0^2}{\\beta^2}v_0 \\qq{, } \\beta^2 = r_0^2 +  y^2 \\tan^2 \\alpha + 2 r_0 y \\tan \\alpha\n\\end{align*}\nSubstituting back into earlier equation,\n\\begin{equation*}\n\\dfrac{r_0^2}{\\beta^2}\\pdv{v_0}{t} - \\dfrac{r_0^2}{\\beta^2} v_0^2 \\dfrac{r_0^2}{\\beta^4} (2y \\tan \\alpha + 2 r_0 \\tan \\alpha) + g = 0\n\\end{equation*}\nThe above equation holds for all $ y $ and specifically $ y=0 $. Let's put $ y=0$ and $ \\beta^2 = r_0^2 $,\n\\begin{equation*}\n\t\\pdv{v_0}{t} - \\dfrac{2}{r_0} v_0^2 \\tan \\alpha + g = 0\n\\end{equation*}\nSolving this gives,\n\\begin{equation*}\nv_0 = \\sqrt{\\dfrac{gr_0}{2 \\tan \\alpha}} \\coth\\qty( \\sqrt{\\dfrac{2g\\tan \\alpha}{r_0}}t + C)\n\\end{equation*}\nAll that is left is to evaluate the constant $ C $.\n\nWe go back to the continuity equation, which says,\n\\begin{equation*}\n\\pi (y + y_0)^2 v(y,t) \\tan^2 \\alpha = K(t) \\implies v(y,t) = \\dfrac{K(t)}{\\pi (y+y_0)^2  \\tan^2 \\alpha } \\implies \\phi(y,t) = -\\dfrac{K(t)}{\\pi (y+y_0) \\tan^2 \\alpha} \n\\end{equation*}\nWriting Bernoulli between points $ y=h $ and $ y=r_0 \\tan \\alpha $,\n\\begin{align*}\n\t-\\dfrac{K'}{\\pi (h+y_0) \\tan^2 \\alpha} + \\dfrac{K^2}{2\\pi^2 \\tan^4 \\alpha h^4} + gh &= -\\dfrac{K'}{\\pi (y_0) \\tan^2 \\alpha} + \\dfrac{K^2}{2\\pi^2 \\tan^4 \\alpha r_0^4}\n\\end{align*}\nSubstituting $ K(t) = v_0 \\pi r_0^2 \\tan^2 \\alpha $, we can get an expression for the constant $ C $ in terms of height $ h $.\n\n\n\n\\textbf{Part (b)}\\\\\nWe know that,\n\\begin{equation*}\n\\dv{V}{t} = Q \\implies t = \\int \\dfrac{dV}{Q}\n\\end{equation*}\n\\begin{align*}\n\\therefore t_1  =  \\int \\dfrac{dV_1}{Q_1} &\\qq{ } t_2  =  \\int \\dfrac{dV_2}{Q_2}\\\\\nt_1  =  \\int \\dfrac{\\pi h^2 dh}{A_1 \\sqrt{2gh}} &\\qq{ } t_2  =  \\int \\dfrac{\\pi h^2 dh}{A_2 \\sqrt{2gh}}\\\\\nt_1 - t_2  = \\qty(\\dfrac{1}{A_1} - \\dfrac{1}{A_2})&\\int \\dfrac{\\pi h^2 dh}{\\sqrt{2gh}} \\implies \\qq{tank with larger base area will drain faster}\n\\end{align*}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[2]\n\tWe first write the Bernoulli equation for between the point where water leaves the tap $ (z_1=0) $ and a point distance $ h $ below $ (z_2=-h) $,\n\t\\begin{equation*}\n\t\\dfrac{P_0 }{\\rho} + \\dfrac{v_1^2}{2} = \\dfrac{P_0 }{\\rho} + \\dfrac{v_2^2}{2} - gh  \\implies \\dfrac{v_2^2}{v_1^2} = 1 + \\dfrac{2gh}{v_1^2}\n\t\\end{equation*}\n\tThe continuity equation gives,\n\t\\begin{equation*}\n\t\\pi r_1^2 v_1 = \\pi r_2^2 v_2 \\implies \\dfrac{v_2}{v_1} = \\dfrac{r_1^2}{r_2^2}\n\t\\end{equation*}\n\tUsing the above two equations, we get,\n\t\\begin{equation*}\n\t\\dfrac{r_1^4}{r_2^4} = 1 + \\dfrac{2gh}{v_1^2} \\implies \\boxed{\\dfrac{R_0^4}{r^4} = 1 + \\dfrac{2gH}{v_0^2}}\n\t\\end{equation*}\n\twhere $ r $ is the cross-sectional radius at height $ H $ below the tap, and $ R_0 $ and $ v_0 $ and the cross-sectional radius and velocity of the water the moment it leaves the tap.\n\t\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[3]\n\tWe work in cylindrical coordinates. The assumption of laminar flow $ \\implies u_r = u_\\phi = 0 $. The assumption of axisymmetry $ \\implies u_z = u_z(r, z) $ The continuity condition $ \\div{\\va{u}} = 0$ gives,\n\t\\begin{equation*}\n\t\\pdv{u_z}{z} = 0 \\implies u_z = u_z(r)\n\t\\end{equation*}\n\tWe now proceed and write the Navier-Stokes equation in cylindrical coordinates component-wise,\n\t\\begin{align*}\n\t0 &= -\\dfrac{1}{\\rho}\\pdv{P}{r}\\\\\n\t0 &= -\\dfrac{1}{\\rho r}\\pdv{P}{\\phi}\\\\\n\t0 &= -\\dfrac{1}{\\rho}\\pdv{P}{z} + \\nu \\dfrac{1}{r} \\pdv{r} \\qty(r \\pdv{u_z}{r})\n\t\\end{align*}\n\tWe can see from the first two equations that $ P = P(z) $. In the third equation, since the first term on the RHS depends only on $ z $ and the second term depends only on $ r $, we say that each of the terms should be constants. We get,\n\t\\begin{align*}\n\t \\dfrac{1}{r} \\dv{r} \\qty(r \\dv{u_z}{r}) &= \\dfrac{1}{\\mu}\\dv{P}{z} = constant\\\\\n\t \\dv{r} \\qty(r \\dv{u_z}{r}) &= \\dfrac{r}{\\mu}\\dv{P}{z}\\\\\n\t \\implies r \\dv{u_z}{r} &= \\dfrac{r^2}{2\\mu}\\dv{P}{z} + A\\\\\n\t \\implies \\dv{u_z}{r} &= \\dfrac{r}{2\\mu}\\dv{P}{z} + \\dfrac{A}{r}\\\\\n\t \\implies {u_z} &= \\dfrac{r^2}{4\\mu}\\dv{P}{z} + A \\ln r + B\\\\\n\t\\end{align*}\n\tWe need the flow to be well-defined at $ r=0 $. As it stands, for non-zero $ A $, the flow will not be well-defined for $ r=0 $, which is undesirable. Hence, $ A=0 $.\n\t\n\tIf $ R $ is the radius of the pipe, and the pipe is not moving, we get $ u_z(R) = 0 $, which means,\n\t\\begin{equation*}\n\t0 = \\dfrac{R^2}{4\\mu}\\dv{P}{z} + B \\implies B = - \\dfrac{R^2}{4\\mu}\\dv{P}{z}\n\t\\end{equation*}\n\tSo the final answer is,\n\t\\begin{equation*}\n\tu_z = \\dfrac{1}{4 \\mu} \\dv{P}{z} (r^2 - R^2) \n\t\\end{equation*}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[4]\n\tWe solve the problem for a two-dimensional jet. The orthogonal directions are taken to be $ x $ and $ y $. We assume that steady state.\n\t\n\tThe Continuity equation gives us,\n\t\\begin{equation*}\n\t\\pdv{u}{x} + \\pdv{v}{y} = 0 \\implies u\\pdv{u}{x} + u\\pdv{v}{y} = 0 \n\t\\end{equation*}\n\tThe $ x $-component of the Navier-Stokes gives us,\n\t\\begin{equation}\n\tu \\pdv{u}{x} + v \\pdv{u}{y} = \\nu \\pdv[2]{u}{y}\n\t\\label{xns}\n\t\\end{equation}\n\t\n\tAdding up the two equations, one has,\n\t\\begin{align*}\n\t\t2u \\pdv{u}{x} + v \\pdv{u}{y} + u \\pdv{v}{y}  &= \\nu \\pdv[2]{u}{y}\\\\\n\t\t\\pdv{(u^2)}{x} + \\pdv{(uv)}{y} &= \\nu \\pdv[2]{u}{y}\n\t\\end{align*}\n\tIntegrating both sides with respect to $ y $,\n\t\\begin{equation*}\n\t\\pdv{x} \\int_{-\\infty}^{\\infty} u^2 dy + \\eval{uv}_{-\\infty}^{\\infty} = \\nu \\eval{\\pdv{u}{y}}_{-\\infty}^\\infty\n\t\\end{equation*}\n\tWe now would like to impose boundary conditions. The velocity is purely along the $ x $-axis at $ y = 0 $. As $ y \\rightarrow \\pm \\infty $, both $ u \\rightarrow 0  $ and $ v $ $ \\rightarrow 0 $, and so do their derivatives.\n\t\n\tWe then have,\n\t\\begin{equation}\n\t\\pdv{x} \\int_{-\\infty}^{\\infty} u^2 dy = 0 \\implies \\int_{-\\infty}^{\\infty} u^2 dy = constant = M\n\t\\label{conserv}\n\t\\end{equation}\n\tWe now try to guess the form of the similarity solution for this problem. Let's assume,\n\t\\begin{equation}\n\tx \\rightarrow \\lambda^a x' \\qq{ } y \\rightarrow \\lambda^b y' \\qq{ } \\psi \\rightarrow \\lambda^c \\psi'\n\t\\label{ansatz}\n\t\\end{equation}\n\tUsing the fact that $ u = \\psi_y $ and $ v = -\\psi_x $, one can write (\\ref{xns}) as,\n\t\\begin{equation}\n\t\\psi_y \\psi_{xy} - \\psi_{x}\\psi_{yy} = \\nu \\psi_{yyy}\n\t\\label{psixns}\n\t\\end{equation}\n\tand (\\ref{conserv}) as,\n\t\\begin{equation}\n\t\\int_{-\\infty}^{\\infty} \\psi_y^2 dy = M\n\t\\label{psiconserv}\n\t\\end{equation}\n\tSubstituting (\\ref{ansatz}) into (\\ref{psixns}) and (\\ref{psiconserv}), we get,\n\t\\begin{align*}\n\t2c - 2b - a &= c - 3b \\implies a = b + c \\qq{and} \\\\\n\t2(c-b) + b &= 0 \\implies b = 2c\n\t\\end{align*}\n\tSolving which we get,\n\t\\begin{equation*}\n\tb = \\dfrac{2a}{3} \\qq{ } c = \\dfrac{a}{3}\n\t\\end{equation*}\n\tand the final form being,\n\t\\begin{equation*}\n\t\tx \\rightarrow \\lambda^a x' \\qq{ } y \\rightarrow \\lambda^{2a/3} y' \\qq{ } \\psi \\rightarrow \\lambda^{a/3} \\psi'\n\t\\end{equation*}\n\tThis suggests that,\n\t\\begin{equation*}\n\t\\dfrac{\\psi }{ x^{1/3} }\\sim f\\qty(\\dfrac{y}{x^{2/3}}) \\implies \\psi = A x^{1/3}f(\\eta)\n\t\\end{equation*}\n\twhere $ \\eta = \\dfrac{y}{x^{2/3}}$. We note the following,\n\t\\begin{align*}\n\t\\psi_y &= A x^{1/3}f'(\\eta) \\dv{\\eta}{y} \\\\\n\t&= A x^{-1/3}f'\\\\\n\t\\psi_x &= \\dfrac{A}{3}x^{-2/3}f(\\eta) + A x^{1/3}f'(\\eta)\\dv{\\eta}{x}\\\\\n\t&=\\dfrac{A}{3}x^{-2/3}f(\\eta) - \\dfrac{2A}{3} x^{-2/3}f'(\\eta)\\eta\\\\\n\t&= \\dfrac{Ax^{-2/3}}{3}(-2 \\eta f'+f)\\\\\n\t\\psi_{xy} &= \\dfrac{Ax^{-4/3}}{3}(-2 \\eta f'' - f')\\\\\n\t\\psi_{yy} &=  A x^{-1}f''\\\\\n\t\\psi_{yyy} &=  A x^{-5/3}f'''\n\t\\end{align*}\n\tPutting all this into (\\ref{psixns}), we get,\n\t\\begin{equation*}\n\t-f'(-2 \\eta f''+f') - (-2 \\eta f'+f)f'' = \\dfrac{3\\nu}{A} f''' \\implies \\dfrac{3\\nu}{A} f''' + f'^2 + f''f = 0\n\t\\end{equation*}\n\tIf we set $ A =  \\nu $ (we can always do that since it is an arbitrary constant), we get our final answer,\n\t\\begin{equation*}\n\t3 f''' + f'^2 + f''f = 0\n\t\\end{equation*}\n\\end{homeworkProblem}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "1f49d2ecd605016944141085f46f4cab9c8c8738", "size": 11992, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/fluids/assign_3/assign_3.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/fluids/assign_3/assign_3.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/fluids/assign_3/assign_3.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.4986449864, "max_line_length": 238, "alphanum_fraction": 0.6445130087, "num_tokens": 4839, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736783928749127, "lm_q2_score": 0.7799929104825007, "lm_q1q2_score": 0.4474650793394267}}
{"text": "\\hypertarget{program-verification}{%\n\\section{Program Verification}\\label{program-verification}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  What are the basic ideas of verification?\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    the problem of erroneous software; correctness; knowing correctness;\n    specification and implementation\n  \\end{itemize}\n\\item\n  Basic theory of verifying imperative programs\n\\item\n  An in principle understanding of verification technology\n\\item\n  at the end, students should be in a good starting position for using\n  actual verification tools like Dafny\n\\item\n  besides that, knowing these points increases one's repertoire of\n  possibilities to think about software\n\\end{itemize}\n\n\\hypertarget{software-qualities}{%\n\\subsection{Software Qualities}\\label{software-qualities}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Reliability: correctness, robustness\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    efficiency, usability etc. irrelevant as long as software is not\n    reliable\n  \\end{itemize}\n\\item\n  Dependability: knowing that software is reliable\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    reliability itself is not enough --- we must know that software is\n    reliable\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{iml}{%\n\\subsection{IML}\\label{iml}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  IML is a simple imperative programming language augmented with\n  specification constructs\n\\item\n  under development for this course to demonstrate the basic principles\n  of program verification\n\\item\n  its only data types are integers and booleans\n\\item\n  IML: Imperative Mini Language\n\\end{itemize}\n\n\\begin{lstlisting}\nspecification\nrequires a >= 0\nmodifies r\nensures r*r <= a && a < (r+1)*(r+1)\n\\end{lstlisting}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  the requires clause declares a precondition\n\\item\n  the modifies clause declares a framecondition\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    this is a list of variables that are allowed to be changed, but the\n    central idea is that all other variables remain constant\n  \\end{itemize}\n\\item\n  the ensures clause declares a postcondition\n\\end{itemize}\n\nThis IML statements declare actually followin code:\n\n\\begin{lstlisting}\nint f(int a)\n{\n    int t, s, i;\n    t= 1; s= 1; i= 0;\n    while (s <= a) {\n        t= t + 2;\n        s= s + t;\n        i= i + 1;\n    }\n    return i;\n}\n\\end{lstlisting}\n\n\\hypertarget{example}{%\n\\subsubsection{Example}\\label{example}}\n\nWe skipped somehow the most of the grammar in IML, but we took a look in\nthe following example (not in detail).\n\n\\begin{lstlisting}\nspecification\n    requires a > 0 && b > 0\n    modifies x\n    ensures x = gcd(a, b)\nimplementation\n    x := a;\n    y := b;\n    while x != y\n        invar gcd(x, y) = gcd(a, b) && x > 0 && y > 0\n    do\n        if x > y then\n            x := x - y\n        else\n            y := y - x\n        end\n    end\n\\end{lstlisting}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  gcd(a, b) denotes the greatest common divisor of a and b\n\\item\n  we use gcd in the postcondition to specify that our program computes a\n  gcd\n\\item\n  we use gcd in the while loop (after invar) for verification purposes\n\\item\n  the meaning of invar in the while loop will be carefully discussed\n  later\n\\item\n  Note: the red phrases are assertions; those containing gcd could not\n  occur as boolean expressions in if or while (see grammar!)\n\\end{itemize}\n\n\\clearpage\n\\hypertarget{specification-vs.implementation}{%\n\\subsubsection{Specification\nvs.~Implementation}\\label{specification-vs.implementation}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  the specification describes what the function does without explaining\n  how to do it\n\\item\n  the implementation describes how to compute the function without\n  explaining what the result will be\n\\end{itemize}\n\nWhen we need both specification and implementation, then simply let us\nput both of them together to form the program.\n\nSpecification AND implementation in Dafny:\n\n\\begin{lstlisting}\nmethod NatSquareRootA(a:int) returns (r:int)\n    requires a >= 0;\n    ensures r*r <= a < (r+1)*(r+1);\n{\n    var d:int;\n    var s:int;\n    d := 1; // oDd\n    s := 1; // Square\n    r := 0; // Root\n    while (s <= a)\n        invariant d == 2*r + 1;\n        invariant s == (r+1)*(r+1);\n        invariant r*r <= a;\n    {\n        d := d + 2;\n        s := s + d;\n        r := r + 1;\n    }\n}\n\\end{lstlisting}\n\n\\hypertarget{dafny}{%\n\\subsection{Dafny}\\label{dafny}}\n\nDafny is a specification and implementation language to proving the\ncorrectness of an implementation against a specification.\n\nSince very special knowledge is needed for developing an implementation\nfrom a specification, it is not reasonable to assume that it could be\npossible to construct a compiler that compiles a specification into\nexecutable code.\n\n\\hypertarget{validation-vs-verification}{%\n\\subsection{Validation vs\nVerification}\\label{validation-vs-verification}}\n\n\\textbf{Validation}: Does the specification fulfill the requirements?\\\\\n\\textbf{Verification}: Does the implementation fulfill the\nspecification?\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.5\\textwidth]{figures/validationverification.png}\n\\caption{Validation and Verification}\n\\end{figure}\n\nFocus on verification:\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Specification and implementation\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    two descriptions of the same problem, and that with different points\n    of view\n  \\item\n    redundancy\n  \\end{itemize}\n\\item\n  How to Know Consistency?\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    Testing\n  \\item\n    Proving\n  \\item\n    Combination of both\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{testing}{%\n\\subsubsection{Testing}\\label{testing}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  program will be executed on chosen input\n\\item\n  is output consistent with specification?\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    yes: no (nearly no) knowledge gained\n  \\item\n    no: now we know more: that the program contains an error\n  \\end{itemize}\n\\end{itemize}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\n\\textbf{Dijkstra's famous statement} \\\\\n\"The number of different inputs, i.e. the number of different computations for which the assertions claim to hold is so fantastically high that demonstration of correctness by sampling is completely out of the question. Program testing can be used to show the presence of bugs, but never to show their absence!\"\n\\end{tcolorbox}\n\nIn other words: A successful industrial acceptance test does not mean\nthat a software product is free of errors; it just means that the\ncustomer has to pay\n\n\\hypertarget{proving}{%\n\\subsubsection{Proving}\\label{proving}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  program will not be executed\n\\item\n  rather we try to find a mathematical proof\n\\item\n  do we find a proof?\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    yes: now we know that the program is correct\n  \\item\n    no: we know that the program might contain errors, or a good idea\n    for the proof is (still) missing\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{testing-and-proving}{%\n\\subsubsection{Testing and Proving}\\label{testing-and-proving}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Testing: good for finding bugs\n\\item\n  Proving: good for showing that there are no bugs\n\\item\n  good practical method:\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    first: test your program to find as many errors as possible\n  \\item\n    then: try to prove your program correct\n  \\end{itemize}\n\\end{itemize}\n\n\\clearpage\n\\hypertarget{state}{%\n\\subsection{State}\\label{state}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  the distinguishing feature of any imperative programming language is\n  the explicit manipulation of state\n\\item\n  the state of an imperative program can be modelled as a function that\n  maps the variables (VAR) of a program to their current contents (VAL):\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    STATES = VAR -\\textgreater{} VAL\n  \\item\n    $\\sigma$1, $\\sigma$2, $\\sigma$3, $\\sigma$4 : STATES\n  \\end{itemize}\n\\end{itemize}\n\n\\begin{lstlisting}\n$\\sigma$1(x) = 17, $\\sigma$1(y) = 5\nx := x - y;\n$\\sigma$2(x) = 17 - 5 = 12, $\\sigma$2(y) = 5\ny := x + y;\n$\\sigma$3(x) = 12, $\\sigma$3(y) = 12 + 5 = 17\nx := y - x\n$\\sigma$4(x) = 17 - 12 = 5, $\\sigma$4(y) = 17\n\\end{lstlisting}\n\n\\hypertarget{boolean-expressions}{%\n\\subsection{Boolean Expressions}\\label{boolean-expressions}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  given a boolean expression and a state\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    boolean expression either true or false\n  \\end{itemize}\n\\item\n  condition in if or while command\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    condition will be evaluated; yields either true or false\n  \\end{itemize}\n\\item\n  condition as assert command\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    should always yield true; if it does not, the program is in error\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{assertions}{%\n\\subsection{Assertions}\\label{assertions}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  in programming languages like Java, the assert commands contain\n  boolean expressions that can be evaluated at run time\n\\item\n  in verification languages like IML or Dafny, the assert commands\n  contain assertions\n\\item\n  an assertion describes a set of states: the set of all states that\n  satisfy the assertion\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    the assertion `x \\textgreater{} 5' describes the set of all states\n    with $\\sigma$(x) \\textgreater{} 5, for example\n  \\item\n    $\\sigma$1 with $\\sigma$1(x) = 6 and $\\sigma$1(y) = 25, or\n  \\item\n    $\\sigma$2 with $\\sigma$2(x) = 17 and $\\sigma$2(y) = 35\n  \\item\n    the assertion `true' describes the set of all states that satisfy\n    true, that is, the full set of all possible states\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{implication}{%\n\\subsection{Implication}\\label{implication}}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.5\\textwidth]{figures/implication.png}\n\\caption{Implication}\n\\end{figure}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  ``If I win, I'll eat my hat.''\n\\item\n  is true\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    if I do not win (independent of what I will do with my hat) --- ex\n    falso quodlibet\n  \\item\n    if I win and I eat my hat\n  \\end{itemize}\n\\item\n  is false\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    if I win but I do not eat my hat\n  \\end{itemize}\n\\end{itemize}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{figures/implication2.png}\n\\caption{Implication 2}\n\\end{figure}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  implication has nothing to do with causal relations; just the truth\n  table matters\n\\item\n  if A is false, the implication will always be true.\n\\end{itemize}\n\n\\clearpage\n\\hypertarget{weaker-and-stronger-conditions}{%\n\\subsubsection{Weaker and Stronger\nConditions}\\label{weaker-and-stronger-conditions}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  examples:\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    x = 5 $\\land$ y = 7 -\\textgreater{} x = 5\n  \\item\n    x = 5 -\\textgreater{} x = 5 $\\lor$ y = 7\n  \\end{itemize}\n\\item\n  P -\\textgreater{} Q\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    P more restrictive than Q\n  \\item\n    set of states given by P is subset of set of states given by Q\n  \\item\n    P stronger than Q\n  \\item\n    Q weaker than P\n  \\end{itemize}\n\\item\n  boundary cases:\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    What is the strongest condition? --\\textgreater{} False\n  \\item\n    What is the weakest condition? --\\textgreater{} True\n  \\end{itemize}\n\\end{itemize}\n\n\\hypertarget{validity-versus-truth}{%\n\\subsubsection{Validity Versus Truth}\\label{validity-versus-truth}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  A boolean formula B (for example an assertion or a Hoare triple) is\n  valid if it is true in all states, written $\\models$ B.\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    x + 5 = 5 + x is true in all states\n  \\item\n    thus x + 5 = 5 + x is valid: $\\models$ x + 5 = 5 + x\n  \\end{itemize}\n\\end{itemize}\n\n\\clearpage\n\\hypertarget{hoare-triples}{%\n\\subsection{Hoare Triples}\\label{hoare-triples}}\n\nA Hoare triple consists of\n\n\\begin{itemize}\n\\tightlist\n\\item\n  an assertion P, called the \\textbf{precondition} of the Hoare triple\n\\item\n  a command C\n\\item\n  an assertion Q, called the \\textbf{postcondition} of the Hoare triple\n\\end{itemize}\n\n\\textit{Note: P and Q are the precondition and postcondition of the Hoare\ntriple, not precondition and postcondition of the command}\n\n\\begin{lstlisting}\n{ x = 5 } x := x + 1 { x = 17 }\n{ x > 5 } x := x + 1 { x > 6 }\n{ j = 0 } while i = 0 do skip endwhile { k = 0 }\n\\end{lstlisting}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  a Hoare triple itself is a boolean formula, which can be true in some\n  state and false in others\n\\item\n  we call the state in which execution of C begins the \\textbf{prestate}\n  of that execution, and the resulting state its \\textbf{poststate}, the\n  latter provided that execution terminates\n\\end{itemize}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\n((prestate satisfies P $\\wedge$ execution of C terminates) $\\Rightarrow$ poststate satisfies Q)\n\\end{tcolorbox}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  This means, if the prestate is wrong, the full Hoare tripple is true\n  (since it's an implication)\n\\item\n  The prestate also includes the termination of the program c. If the\n  program doesn't terminate, everything is ok\n\\end{itemize}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.6\\textwidth]{figures/hoaretriple.png}\n\\caption{Hoare Triple example}\n\\end{figure}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  given the following Hoare triple:\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    \\{ j = 0 \\} while i = 0 do skip endwhile \\{ k = 0 \\}\n  \\end{itemize}\n\\item\n  The example above describes all 8 kinds of prestates (i = 0 implies 2\n  states each).\n\\item\n  The example shows, that the hoare triple would be false in one\n  prestate and thus the hoarse triple itself is not valid.\n\\end{itemize}\n\n\\hypertarget{conditional-or-partial-correctness}{%\n\\subsubsection{Conditional or Partial\nCorrectness}\\label{conditional-or-partial-correctness}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  A Hoare triple \\{P\\} C \\{Q\\} is called \\textbf{valid}, written $\\models$ \\{P\\}\n  C \\{Q\\} if it is true in all prestates.\n\\item\n  A Hoare triple is valid, If execution of command C begins in any state\n  that satisfies the precondition P and execution terminates, then the\n  resulting state satisfies the postcondition Q.\n\\item\n  Note that a valid Hoare triple does not provide any information\n  concerning the resulting state if execution begins in any state that\n  does not satisfy the precondition.\n\\item\n  We are only interested in valid Hoare triples.\n\\end{itemize}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\nExamples: \\\\\n– $\\nvDash$ { x = 5 } x := x + 1 { x = 17 } (this is not valid, since the postcondition could not be met) \\\\\n– $\\models$ { x > 5 } x := x + 1 { x > 6 } \\\\\n– $\\nvDash$ { j = 0 } while i = 0 do skip endwhile { k = 0 }\n\\end{tcolorbox}\n\n\\hypertarget{total-vs.partial-correctness}{%\n\\subsubsection{Total vs.~Partial\nCorrectness}\\label{total-vs.partial-correctness}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  If the precondition is true, the execution terminates properly and the\n  postcondition is true, the Hoare triple is called totally correct.\n\\item\n  If you don't know if the execution terminates properly, but if it\n  terminates the result is true, the Hoare triple is called partially\n  correct.\n\\end{itemize}\n\n\\hypertarget{specification-of-imperative-programs}{%\n\\subsection{Specification of Imperative\nPrograms}\\label{specification-of-imperative-programs}}\n\nA specification for imperative programs should provide the following\ninformation:\n\n\\begin{itemize}\n\\tightlist\n\\item\n  a precondition P\n\\item\n  a list x of variables that may be changed\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    with the important understanding that all other variables must not\n    be changed\n  \\end{itemize}\n\\item\n  a postcondition Q\n\\end{itemize}\n\nWe denote such a specification by \\{P\\} x:=? \\{Q\\}\n\n\\hypertarget{specification-for-integer-square-root}{%\n\\subsubsection{Specification for Integer Square\nRoot}\\label{specification-for-integer-square-root}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  English spec\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    Find an integer approximation to the square root of integer a.\n  \\end{itemize}\n\\item\n  add precision\n\n  \\begin{itemize}\n  \\tightlist\n  \\item\n    a $\\geqslant$ 0\n  \\item\n    store result in variable r\n  \\item\n    choose largest integer r such that $r^2$ $\\leqslant$ a\n  \\end{itemize}\n\\item\n  formal spec\n\n  \\begin{itemize}\n  \\tightlist\n  \\item $\\{0 \\leqslant a\\} r:=? \\{r^2 \\leqslant a < (r + 1)^2\\}$\n  \\end{itemize}\n\\end{itemize}\n\nIt is important to list all the variables that are allowed to be changed\n(r := ?). If we would not define that, we could change a to 0 to meet\nthe conditions.\n\n\\hypertarget{rigid-variables}{%\n\\subsubsection{Rigid Variables}\\label{rigid-variables}}\n\nRigid variables can be introduced to connect the pre- and the\npostconditions with variables that only occur in assertions and not in\nthe program.\n\n\\{ x = X \\} x:=? \\{ x = X + 6 \\}\n\nthis means: for all values X, if x = X in the initial state and\nexecution terminates, then x = X + 6 in the final state.\n\n\\clearpage", "meta": {"hexsha": "855787c6571b7433d54f047e183a0ef665562040", "size": 17181, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TSM_AdvPrPa/Summary/12_Verification01.tex", "max_stars_repo_name": "nortismo/mse-documentations", "max_stars_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_stars_repo_licenses": ["Beerware"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TSM_AdvPrPa/Summary/12_Verification01.tex", "max_issues_repo_name": "nortismo/mse-documentations", "max_issues_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_issues_repo_licenses": ["Beerware"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TSM_AdvPrPa/Summary/12_Verification01.tex", "max_forks_repo_name": "nortismo/mse-documentations", "max_forks_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_forks_repo_licenses": ["Beerware"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-15T07:10:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-15T07:10:24.000Z", "avg_line_length": 24.0293706294, "max_line_length": 311, "alphanum_fraction": 0.7148012339, "num_tokens": 5077, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7799928900257127, "lm_q1q2_score": 0.4474650789742314}}
{"text": "\\documentclass{article}\n\n\\usepackage{fullpage}\n\\usepackage{textcomp}\n\\usepackage{amsmath}\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\renewcommand{\\headrulewidth}{0pt}\n\\cfoot{\\sc Page \\thepage\\ of \\pageref{end}}\n\n\\begin{document}\n\n{\\large \\noindent{}University of Toronto at Scarborough\\\\\n\\textbf{CSC A67/MAT A67 - Discrete Mathematics, Fall 2015}}\n\n\\section*{\\huge Exercise \\#7: Proofs}\n\n{\\large Due: November 20, 2015 at 11:59 p.m.\\\\\nThis exercise is worth 3\\% of your final grade.}\\\\[1em]\n\\textbf{Warning:} Your electronic submission on MarkUs affirms that this exercise is your own work and no\none else's, and is in accordance with the University of Toronto Code of Behaviour on Academic Matters,\nthe Code of Student Conduct, and the guidelines for avoiding plagiarism in CSC A67/MAT A67.\\\\[1ex]\nThis exercise is due by 11:59 p.m. November 20. Late exercises will not be accepted.\\\\[1ex]\n\\renewcommand{\\labelenumi}{\\arabic{enumi}.}\n\\renewcommand{\\labelenumii}{(\\alph{enumii})}\n\\begin{enumerate}\n\\item The\\marginpar{[5]} \\textit{greatest common divisor} of two positive integers $a$ and $b$ is the largest positive integer that divides both $a$ and $b$ (written $\\gcd(a,b)$). For example, $\\gcd(4,6)=2$ and $\\gcd(5,6)=1$.\n\t\\begin{enumerate}\n\t\\item Prove that $\\gcd(a,b) = \\gcd(a,b-a).$\n\t\\item Let $r=b\\bmod a$. Using part \\textbf{(a)}, prove that $\\gcd(a,b) = \\gcd(a,r)$.\n\t\\end{enumerate}\n\\item Prove\\marginpar{[4]} that $\\sqrt[3]{5}$ is irrational.\n\\item Prove\\marginpar{[4]} the following statement by contraposition:\\\\[1ex]\nLet $x$ be an integer. If $x^2+x+1$ is even, then $x$ is odd.\n\\item Prove\\marginpar{[4]} the following statement by contradiction:\\\\[1ex]\nLet $x$ and $y$ be integers. If $3x+5y=153$, then at least one of $x$ and $y$ is odd.\n\\item An\\marginpar{[4]} integer is called ``sane\" if $3\\,|\\,(n^2+2n)$. (That is, if $(n^2+2n)\\bmod 3=0$.)\n\t\\begin{enumerate}\n\t\\item Prove or disprove that all odd integers are sane.\n\t\\item Prove or disprove that, if $3\\,|\\,n$, then $n$ is sane.\n\t\\end{enumerate}\n\\end{enumerate}\n\\hrulefill\\\\\n\\noindent[Total: 21 marks]\\label{end}\n\n\\end{document}", "meta": {"hexsha": "d8779d56e207868a332afd9905904cd990d829d9", "size": 2096, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "teaching/resources/Proofs-Exercise.tex", "max_stars_repo_name": "ozhanghe/ozhanghe.github.io", "max_stars_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-23T17:23:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-23T17:23:00.000Z", "max_issues_repo_path": "teaching/resources/Proofs-Exercise.tex", "max_issues_repo_name": "ozhanghe/ozhanghe.github.io", "max_issues_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-06-05T03:48:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-18T03:30:18.000Z", "max_forks_repo_path": "teaching/resources/Proofs-Exercise.tex", "max_forks_repo_name": "ozhanghe/ozhanghe.github.io", "max_forks_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-11T13:35:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T05:34:01.000Z", "avg_line_length": 44.5957446809, "max_line_length": 225, "alphanum_fraction": 0.7080152672, "num_tokens": 705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736783928749127, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.4474650764055224}}
{"text": "\\documentclass[12pt]{article}\n\\author{David Alves}\n\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{dirtytalk}\n\\usepackage[a4paper, total={6.5in, 8.5in}]{geometry}\n\\usepackage{forest}\n\\usepackage{skak}\n\\usepackage{tikz}\n\\usepackage{titling}\n\n\\title{Math 142 Problem Set 4}\n\\author{David Alves}\n\\date{2016-09-20}\n\n\\begin{document}\n\\pagenumbering{gobble}\n\n\\begin{center}\n\\Large \\thetitle \\\\\n\\large \\theauthor \\\\\n\\thedate\n\\end{center}\n\n\\subsection*{Sources}\n\n    \\begin{itemize}\n    \\item Notes from lecture and my own memory from Math 42 for solving the problems\n    \\item \\textit{Combinatorics Through Guided Discovery} for formal definition of quotient principle\n    \\item http://tex.stackexchange.com and https://www.sharelatex.com for help with \\LaTeX\n    \\end{itemize}\n\n\\section{Counting Equivalence Relations}\n\\subsection*{Problem Statement}\nWhat is the number of equivalence relations on $[5]$?\n\\subsection*{Solution}\nThere are 52 equivalence relations on $[5]$. \n\\begin{proof}\nFrom the previous homework, we know that the number of equivalence relations on $S \\rightarrow S$ is equal to the number of partitions on $S$. Therefore we can count partitions of $[5]$ in order to get the number of equivalence relations on $[5]$. Below is a systematic enumeration of the partitions of $[5]$. Nodes in the tree consist of partitions of a subset, with leaf nodes consisting of partitions of the full set. A node's children are formed by adding the next element to each of the existing partitions and a new partition. The first level of the tree adds element 1, the second level adds element 2, etc.\n\\end{proof}\n\\scalebox{0.65}{\n\\begin{forest}\n  for tree={\n    grow'=0,\n    child anchor=west,\n    parent anchor=east,\n    anchor=west,\n    calign=center,\n    inner ysep=0.0pt,\n    fit=band,\n    before computing xy={l=135pt},\n  }\n    [$\\{\\{1\\}\\}$\n        [$\\{\\{1\\text{,}2\\}\\}$\n            [$\\{\\{1\\text{,}2\\text{,}3\\}\\}$\n                [$\\{\\{1\\text{,}2\\text{,}3\\text{,}4\\}\\}$\n                    [$\\{\\{1\\text{,}2\\text{,}3\\text{,}4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\text{,}3\\text{,}4\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\text{,}2\\text{,}3\\}\\text{,}\\{4\\}\\}$\n                    [$\\{\\{1\\text{,}2\\text{,}3\\text{,}5\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\text{,}3\\}\\text{,}\\{4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\text{,}3\\}\\text{,}\\{4\\}\\text{,}\\{5\\}\\}$]\n                ]\n            ]\n            [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\}\\}$\n                [$\\{\\{1\\text{,}2\\text{,}4\\}\\text{,}\\{3\\}\\}$\n                    [$\\{\\{1\\text{,}2\\text{,}4\\text{,}5\\}\\text{,}\\{3\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\text{,}4\\}\\text{,}\\{3\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\text{,}4\\}\\text{,}\\{3\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\text{,}4\\}\\}$\n                    [$\\{\\{1\\text{,}2\\text{,}5\\}\\text{,}\\{3\\text{,}4\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\text{,}4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\text{,}4\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\}$\n                    [$\\{\\{1\\text{,}2\\text{,}5\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\text{,}5\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\}\\text{,}\\{4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}2\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\text{,}\\{5\\}\\}$]\n                ]\n            ]\n        ]\n        [$\\{\\{1\\}\\text{,}\\{2\\}\\}$\n            [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\}\\}$\n                [$\\{\\{1\\text{,}3\\text{,}4\\}\\text{,}\\{2\\}\\}$\n                    [$\\{\\{1\\text{,}3\\text{,}4\\text{,}5\\}\\text{,}\\{2\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\text{,}4\\}\\text{,}\\{2\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\text{,}4\\}\\text{,}\\{2\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\text{,}4\\}\\}$\n                    [$\\{\\{1\\text{,}3\\text{,}5\\}\\text{,}\\{2\\text{,}4\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\text{,}4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\text{,}4\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\}\\text{,}\\{4\\}\\}$\n                    [$\\{\\{1\\text{,}3\\text{,}5\\}\\text{,}\\{2\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\text{,}5\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\}\\text{,}\\{4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}3\\}\\text{,}\\{2\\}\\text{,}\\{4\\}\\text{,}\\{5\\}\\}$]\n                ]\n            ]\n            [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\}\\}$\n                [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\text{,}3\\}\\}$\n                    [$\\{\\{1\\text{,}4\\text{,}5\\}\\text{,}\\{2\\text{,}3\\}\\}$]\n                    [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\text{,}3\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\text{,}3\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\text{,}4\\}\\}$\n                    [$\\{\\{1\\text{,}5\\}\\text{,}\\{2\\text{,}3\\text{,}4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\text{,}4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\text{,}4\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\}\\text{,}\\{4\\}\\}$\n                    [$\\{\\{1\\text{,}5\\}\\text{,}\\{2\\text{,}3\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\text{,}5\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\}\\text{,}\\{4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}3\\}\\text{,}\\{4\\}\\text{,}\\{5\\}\\}$]\n                ]\n            ]\n            [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\}$\n                [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\}$\n                    [$\\{\\{1\\text{,}4\\text{,}5\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\}$]\n                    [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\text{,}5\\}\\text{,}\\{3\\}\\}$]\n                    [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\text{,}4\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\}\\text{,}\\{2\\text{,}4\\}\\text{,}\\{3\\}\\}$\n                    [$\\{\\{1\\text{,}5\\}\\text{,}\\{2\\text{,}4\\}\\text{,}\\{3\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}4\\text{,}5\\}\\text{,}\\{3\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}4\\}\\text{,}\\{3\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}4\\}\\text{,}\\{3\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}4\\}\\}$\n                    [$\\{\\{1\\text{,}5\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}5\\}\\text{,}\\{3\\text{,}4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}4\\}\\text{,}\\{5\\}\\}$]\n                ]\n                [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\}$\n                    [$\\{\\{1\\text{,}5\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\text{,}5\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\text{,}5\\}\\text{,}\\{4\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\text{,}\\{4\\text{,}5\\}\\}$]\n                    [$\\{\\{1\\}\\text{,}\\{2\\}\\text{,}\\{3\\}\\text{,}\\{4\\}\\text{,}\\{5\\}\\}$]\n                ]\n            ]\n        ]\n    ]\n\\end{forest}\n}\n\n\\section{Graph Counting}\n\\subsection*{Problem Statement}\nCount the number of graphs on $[n]$ vertices. Count the number of relations from $[n]$ to $[m]$. Comment on similarities between the two (if you found any).\n\n\\subsection*{Solution}\n\nAn edge in an undirected graph of $[n]$ vertices is a set of two elements (since order doesn't matter on an undirected graph). There are $n$ ways to choose the first element and $n-1$ ways to choose the second element for an edge. We then divide by 2 due to the quotient principle because the order of the two elements in our set does not matter. Thus there are $\\frac{n (n-1)}{2}$ possible edges. A graph on $[n]$ consists of a subset of edges from among all possible edges on $[n]$. Each edge can either be present or not present in the graph, so by the product principle there are $2^{\\frac{n (n-1)}{2}}$ graphs on $[n]$.\\\\\n\nA relation on $[n] \\rightarrow [m]$ is a set of lists $(a,b) \\mid a \\in n \\text{ and } b \\in m$. There are $nm$ such lists by the product principle. Each list is either present or not present in a given set, so there are $2^{nm}$ possible relations on $[n] \\rightarrow [m]$.\\\\\n\nA graph on $[n]$ is a relation on $[n] \\rightarrow [n]$ with the additional restriction that 1) none of the lists can contain the same element twice and 2) $(b, a)$ is present in the set if and only if $(a, b)$ is present in the set. The first restriction forbids loops while the second restriction makes the graph undirected.\n\n\\section{Balloon Game}\n\\subsection*{Problem Statement}\nConsider the following game: Alice and Bob start with a shared pile of $n \\geq 1$ of water balloons, and Alice goes first. On each turn, if you start with no balloons, you lose. If you have at least 1 balloon, you must throw 1, 2, or 3 balloons at your opponent. When does Alice have a winning strategy? (i.e. a strategy that guarantees she will eventually win regardless of what Bob does). Prove the strategy works by strong induction.\n\\subsection*{Solution}\n\nAlice has a winning strategy for all $n$ not divisible by 4.\n\n\\begin{proof}\nWe prove this by strong induction on the following statement: $p(n)=$ \\say{Assuming optimal play by both players, if there are $n$ balloons remaining then the current player will lose if $n$ is divisible by 4, otherwise they will win.}\n\nWe are given that the current player will lose if there are $n=0$ balloons remaining, so $p(0)$ is true because 0 is divisible by 4. For $n=$ 1, 2 and 3, the current player can throw all the remaining balloons which forces the other player to lose, so $p(n)$ is true for $n=$ 1, 2, and 3. For $n \\geq 4$, if $n$ is divisible by 4 then the current player can throw $k=$ 1, 2, or 3 balloons, but in all of those cases the other player will have $n-k$ balloons remaining where $n-k$ is not divisible by 4, thus the other player will win because $p(n-k)$ has already been proven to be a win if $n-k$ is not divisible by 4. If $n \\geq 4$ is not divisible by 4, then $n = 4a + b$ where $a$ and $b$ are positive integers and $b \\in \\{1,2,3\\}$. In that case the current player can throw $b$ balloons to win since they will leave the other player with $n-b$ balloons, we have already shown that $p(n-b)$ is true, and $n-b$ is divisible by four which means it is a loss for the other player.\n\\end{proof}\n\n\n\\section{Quotient Principle}\n\\subsection*{Problem Statement}\nExplicitly use the quotient principle to find that the binomial coefficient $\\binom{n}{k}$ is $\\frac{n!}{k!(n-k)!}$ by counting the number of ways to get \\emph{lists} of $k$ elements from $[n]$. Don't be sketchy.\n\\subsection*{Solution}\n\n\\begin{proof}\nLet $S$ be the set of $k$-length lists that can be formed from items in $[n]$ without duplicate items in any one list. There are $n$ choices for the first element in a $k$-length list, $n-1$ choices for the second element, etc. down to $n -k + 1$ choices for the last element. This gives a total of $\\frac{n!}{(n-k)!}$ $k$ such lists in $S$. We now partition $S$ such that each partition consists of orderings of a different set of $k$ elements. Consider the lists in a single partition. There are $k$ choices for which element comes first, $k-1$ choices for which element comes second, etc, giving a total of $k!$ orderings by the product principle. Therefore each partition of $S$ contains $k!$ lists. Therefore since we have partitioned a set of size $\\frac{n!}{(n-k)!}$ into blocks of size $k!$, there are $\\frac{n!}{k!(n-k)!}$ such blocks according to the quotient principle. Each partition is a subset of $k$ elements from $S$. Thus $\\binom{n}{k} = \\frac{n!}{k!(n-k)!}$.\n\\end{proof}\n\n\\section{Counting Flags}\n\\subsection*{Problem Statement}\nCount the number of ways to put 5 distinguishable flags on 3 distinguishable poles. On each pole, the only thing that matters is the order of the flags (top to bottom) on each pole. For example, one configuration is to have flags 1, 5, 2 on pole 1 (in that order), no flags on pole 2, and flags 4, 3 on pole 3. Explore for general numbers of flags and poles.\n\\subsection*{Solution}\n\nThere are 2520 ways to place five distinguishable flags onto three distinguishable poles such that all flags are on a pole and the order of flags on a pole matters. More generally, there are $\\frac{(n+k-1)!}{(k-1)!}$ ways to place $n$ flags onto $k$ poles.\n\n\\begin{proof}\nLet $f_1, f_2, \\ldots, f_n$ denote the $n$ flags, and let $p_1, p_2, \\ldots, p_k$ denote the $k$ poles. A pole is equivalent to a list of flags since the order of flags on a pole matters. For example $(f_1, f_2)$ is distinct from $(f_2, f_1)$. There is a bijection between the $k$ lists and a single list containing all flags and $k-1$ separators. For example with $k=3$ poles and $n=5$ flags, the arrangement $p_1 = (f_1, f_5, f_2), p_2 = (), p_3 = (f_4, f_3)$ is equivalent to the list $(f_1, f_5, f_2, \\circ, \\circ, f_4, f_3)$ where $\\circ$ is a separator indicating the end of the current pole and the start of a new pole. If these separators were distinguishable, the number of arrangements would be $(n+k-1)!$. Since the separators are not distinguishable, we use the quotient principle and divide by $(k-1)!$ orderings of the separators, giving a total count of \n\\[\n\\frac{(n+k-1)!}{(k-1)!}\n\\]\n\n\\end{proof}\n\n\\section {Time Spent}\n\nI spent about 8 hours on this problem set. For a lot of that time I was stuck on the counting flags problem until we went over a similar problem in class which gave me the idea for the separators. The rest of the problems were pretty straightforward.\n\n\\end{document}\n", "meta": {"hexsha": "b0320090e1d2606d418ed0545f4d85bcad183506", "size": 14031, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "math142_ps4.tex", "max_stars_repo_name": "dalves/combinatorics", "max_stars_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T14:26:36.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T14:26:36.000Z", "max_issues_repo_path": "math142_ps4.tex", "max_issues_repo_name": "dalves/combinatorics", "max_issues_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "math142_ps4.tex", "max_forks_repo_name": "dalves/combinatorics", "max_forks_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.4976303318, "max_line_length": 981, "alphanum_fraction": 0.5361699095, "num_tokens": 4994, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.44745481020819805}}
{"text": "\\section{Concepts}\n\nWe begin our discussion around the crux of avoiding undesirable behavior: \\textit{Ordering} (in the literature: \\textit{linearization} and \\textit{serialization}).\n\nIn our definition of a CDS (\\ref{cds}), we discussed reading and writing data to a structure as well as changing the structure of the CDS itself. We will label all of these processes as: \\textit{access types}. More specifically: these are procedural types. Every time we try to execute an access type we will call this an: \\textit{access procedure}.\n\nWe do not want to limit ourselves to some pre-defined set of operations such as ``reads, writes, appends, removals, etc.''. These do represent a sort of canonical basis for all possible access types, but we want to be flexible enough to allow for any and all possible methods of accessing a CDS.\n\nThus, we need to find a way to ensure the linearization, or correct ordering, of access procedures. \n\nFor example, when and how will we guarantee that one access procedure completes before another one is started? The how is simple: we can sequentially order our access procedures i.e. apply a total ordering to all access procedures across our system. \n\nBut that can be accomplished by using only a single process without the necessity for concurrent processes. Thus we need to address the \\textit{when} of ordering access procedures using multiple concurrent processes.\n\nNot all access procedures will need to be totally-ordered i.e. a complete (mathematical) linearization of our access procedures is not always a necessity. It is this \\textit{lack of necessity of a total ordering} that allows us to have the possibility of concurrency in the first place. \n\nThe degree to which our system can behave non-linearly is exactly the minimal degree to which it can be composed of concurrent processes. (Note: by \"system\" we are referring to a set of processes plus our CDS).\n\nSo, when is ordering a necessity? The only time two access procedures need an order is if one access procedure is \\textit{dependent} on the other. We do not specify the reason for the dependency, but if a dependency exists (at all) then it is easy to see that an ordering is necessary.\n\nSince the necessity for an ordering is not always required, we see that a complete linearization of our system is not always a necessity. Rather, the access procedures which carry a dependency on other access procedures create a \\textit{partial ordering} for our system.\n\nMore specifically: all of our dependencies allows us to have a (disjoint )\\textit{dependency graph} for our access procedures.\n\nAll good, right?! Sort of. Sadly, this does not resolve all of our problems. We have not discussed exactly how we will order access procedures in terms of processes.\n\n\\subsection{Spatial Dependencies}\n\nFirst, let's diverge quickly back into a discussion of our CDS. Let's try to formalize it:\n\n\\begin{con-def}[Concurrent Data Structure (2)]\n\t\\label{cds-graph}\n\tA \\textit{concurrent data structure} is a graph $\\mathcal{G} = \\{\\mathsf{N}, \\mathsf{E}\\}$ composed of $|\\mathsf{N}|$ nodes and $|\\mathsf{E}|$ edges, that is used to index data of type $\\mathcal{T}$, and is allowed to be accessed by some set of processes $\\mathcal{P}_{i}$ via some set of access types $\\mathcal{A}_{t}$.\n\\end{con-def}\n\nThis helps us to remember that a data structure is a spatial object. It carries a certain topology and is invariant through time unless modified. Thus, it is completely possible that while access procedures may not carry a dependency: nodes of our CDS just might! The set of all nodular-dependencies will be called the: \\textit{set of spatial dependencies}. These dependencies may be the dependencies that an access procedure ``adopts'' in order to consider itself dependent on another access procedure.\n\nFor example: if access procedure $\\mathit{A}$ is trying to write to node $\\mathrm{n}_{1} \\in \\mathsf{N}$ and access procedure $\\mathit{B}$ is trying to write to node $\\mathrm{n}_{2} \\in \\mathsf{N}$, but $\\mathrm{n}_{2} < \\mathrm{n}_{1}$ (where $<$ is a dependency arrow), then we would want to perform $\\mathit{B}$ before $\\mathit{A}$.\n\nThis set of spatial dependencies only covers the dependency relationships between certain nodes in our graph. But what if we wanted sub-graphs of our CDS to be dependent or more importantly \\textit{independent} of other sub-graphs of our CDS?\n\nLet's define this:\n\n\\begin{con-def}[Unique-Independent]\n\t\\label{independents}\n\tAny sub-graph $\\mathcal{S} \\subseteq \\mathcal{G}$ that does not contain any internal spatial dependencies is called an \\textit{unique-independent} of our CDS.\n\\end{con-def}\n\nUnique-Independents (UIs) can almost be seen as a \\textit{virtualization} of our CDS's spatial topology.\n\nUnique-Independents can obviously have external dependencies i.e. be dependent on each other. Thus, the set of UIs of our CDS forms a dependency graph. More specifically, they form a disjoint directed acyclic graph.\n\n\\begin{con-def}[Disjoint Directed Acyclic Graph]\n\t\\label{ddag}\n\tThe set of UIs and their dependencies on one another forms a \\textit{disjoint directed-acyclic graph} (ddag) i.e. a disjoint dependencies graph. It is disjointed since UIs are not required to have dependency relations with one another and thus some UIs (nodes) will not have edges in the graph.\n\\end{con-def}\n\nAlso note that dependency graphs will never have multiple edges between any two nodes.\n\nBut since UIs do not have to have other UIs as dependencies it will be simpler to consider: a dependencies list.\n\n\\begin{con-def}[Dependency List]\n\t\\label{dependency-list}\n\tA \\textit{dependencies list} for a CDS is the adjacency list of our ddag of unique-independents.\n\\end{con-def}\n\n\\if\nFor any algebraist reading this: our dependencies list can almost be considered an \\textit{anti-group} since inverses of ordered pairs \\textit{cannot} exist in our list. An identity element cannot exist as the composition of any two objects cannot return to itself as that implies a cyclic dependency. Associativity and closure can exist for a basic composition operation, but objects in our dependency list can only be composed functionally (i.e. the last element of the ordered pair must be the first element of the ordered pair it is being composed with) -- so this composition only applies to a subset of our dependencies list. Thus, our dependencies list really becomes a sort of quasi-antithesis to a group.\n\\fi\n\nDon't let the name ``unique-independent'' fool you. There is no requirement for an independent to be spatially-unique. In other words, a UI can share nodes from the CDS with other UIs. The only thing that makes a unique-independent ``unique'' is that it is in totality unique as to the nodes it applies too. \n\nSo while, a UI can be completely subsumed by another UI spatially, it will never refer to the exact same set of nodes that another UI is referring too. And it is this notion of ``uniqueness'' that allows it to be an independent.\n\nThis may seem like a unique-independent that subsumes UIs that have dependencies which are also subsumed UIs, conflicts with our definition (\\ref{independents}) of an unique-independent.\n\nHowever, what we have to notice is that this unique-independent can/should be evaluated separately from other UIs i.e. a UI that subsumes other UIs and their dependencies should only be addressed after all those other UIs have been addressed.\n\nSo, while an independent has ``no spatial dependencies'' it can still subsume UI-dependencies. \n\nOne of the most important points to take away from this section is the fact that: the structure of the CDS itself has zero semblance of how we design our concurrent accesses, only the structure of our UI-DDAG (disjoint directed acyclic graph) does.\n\nNow that we have a way to virtualize a CDS using UIs (in a spatial manner), let's tie UIs back in with our previous discussion about ordering access procedures.\n\nWe can now use the UI (spatial) virtualization of our CDS to assign an access procedure to a particular UI. We can provide a brief pseudo-code description (written in the Go programming language syntax).\n\n\\begin{minted}{go}\ntype AccessProcedure struct{\n\tA AccessType\n\tUID int // unique-independent id\n}\n\\end{minted}\n\n\\subsection{Temporal Dependencies}\n\nSince our dependency list of UIs based off this virtualization represents all possible spatial dependencies in our CDS it can be used to help us apply an ordering to access procedures. However, a spatial dependency is not the only way access procedures can be ordered i.e. be dependent on each other. The other way access procedures can have an ordering is: \\textit{per UI}.\n\nIn other words, we can still order all access procedures that have been assigned to the same UI. For example, will read access procedures always take precedence over write access procedures for a particular UI? What if we wanted to be more specific (fine-grained) than that and give \\textit{certain} access procedures precedence over \\textit{certain} write access procedures?\n\nIt would be impossible to suggest that access procedures that apply to a specific UI could always be totally-ordered. Thus, we arrive at the same situation we were in before with trying to linearize our system. Thankfully, we have the answer: a dependency graph (list). Except, this time our dependencies list are access procedures assigned to the same UI.\n\nWhereas we had an UIs dependency list that represented a virtualization of the spatial dependencies, we now have a procedures dependency list that virtualizes the temporal dependencies of our CDS (per UI). \n\nEvery UI will have it's own temporal dependencies list and every node in this disjoint dependencies graph will be a specific access procedure.\n\n\\begin{con-def}[Temporal DAG]\n\t\\label{temporal-dag}\n\tA temporal directed acyclic graph for a specific UI is the partial ordering of all access procedures acting on the CDS sub-graph at that UI. Unlike the UI dependency graph, this graph is not (and cannot be) disjointed.\n\\end{con-def}\n\nWe can also write out any temporal DAG as a temporal dependencies list for a particular UI. In this way we can redefine our access procedure code from above to include a temporal DAG node assignment:\n\n\\begin{minted}{go}\ntype AccessProcedure struct{\n\tA AccessType\n\tUID int // unique-independent id\n\tTID int // temporal dag node id\n}\n\\end{minted}\n\n\\subsection{Acidity}\n\nWe still have to come back around to combining our ordering of dependencies with the processes in our system. But, first we should consider when two access procedures can be simply sequentially ordered. If some set of access procedures which apply to the same UI must be linearly ordered then we can consider the sequential composition of those procedures as being a new access procedure.\n\nThis can technically also apply to any sequence of access procedures (assigned to the same UI) that are not dependent on one another. If we want to reduce the total number of individual procedures in our system (i.e. reduce the number of nodes in our temporal dependency graph for a UI) then we can combine access procedures that are linearly dependent (or entirely independent) into a single access procedure.\n\nThe allowance for this combination is what we call: \\textit{acidity}.\n\n\\begin{con-def}[Acidic Procedures]\n\t\\label{acidic-procedures}\n\tAny access procedure or sequence of access procedures that appear to the rest of the system as a single operation on a UI are called: \\textit{acidic procedures}.\n\\end{con-def}\n\nAll access procedures \\textit{should already be} acidic procedures. But, arbitrary sequences of procedures are not necessarily demanded to be acidic. We want to specifically classify sequences of access procedures that \\textit{are} acidic.\n\n\\begin{con-def}[Thread]\n\t\\label{thread}\n\tA \\textit{thread} is any sequence of access procedures that can be classified as a single acidic procedure. A thread can also be a sequence of acidic procedures (which may be sequences of access procedures in of themselves).\n\\end{con-def}\n\nIn terms of a dependency graph: a thread is assigned to a node and is also assigned to the node's dependencies iff the dependent node has only one dependency \\textit{and} the dependency has only one dependent. Any sequence of nodes each with at most one dependency and one dependent can be \"combined\" and considered: a single Thread.\n\nUsing threads makes our virtualization complexes more succinct, as any and all sequences of access procedures are either necessarily ordered or are considered single acidic procedures. It also becomes that every node in our disjoint dependency graphs are now a thread.\n\n\\begin{props}[Nodes are Threads]\n\t\\label{nodes-are-threads}\n\tEvery node in our temporal dependency graphs is a thread (iff we maintain that all access procedures must be acidic procedures).\n\\end{props}\n\n\\begin{con-cor}[Thread DAGs]\n\t\\label{thread-ddag}\n\tFor every dependency graph of access procedures there is an equivalent dependency graph of threads.\n\\end{con-cor}\n\nThe fact of the matter is that the total number of UIs determines the minimum number of threads required to allow our CDS system to not be missing concurrency improvements (but is usually used when a maximum number of threads is a requirement).\n\nIf we choose to use fewer threads than we have UIs, then each thread will likely be assigned to multiple UIs. Can our system still offer a degree of undesired behavior avoidance in this case? The answer is yes, but the management of behavior must be handled internal to each thread.\n\nIn this case the threads will need to have internal sequential consistency. In other words, the ordering of dependent operations will only be based on the sequential ordering of access procedures within the thread. So, the thread should be well-ordered according to access procedures that apply to first: UI dependencies then UI dependents.\n\nIf the UIs that a thread is assigned to have no dependency relationship with each other (even composed dependency arrows) then the thread will not need to be ordered internally. Sometimes, ensuring this simple property makes the concurrency of the system simpler to implement and verify.\n\nIn the next section of this paper we will discuss how we will ensure acidity for access procedures. But, for now, we simply hold this assumption as a given precondition.\n\n\\subsection{Dynamic Dependencies}\n\nNow that we have methods for defining both spatial and temporal dependencies in our system, the question arises: what happens if a dependency has a lifecycle? What if a dependency needs to only hold true some of the time?\n\nTo solve these dynamic situations we can introduce the idea of a \\textit{Virtual Dependency Graph} (VDG) which is a dependency graph that can apply to multiple UIs. The key is that it \\textit{must} have a limited lifespan. If it does not have a limited lifespan then it just becomes part of a spatial DDAG or a temporal DAG.\n\n\\begin{con-def}[Virtual Dependency Graph]\n\t\\label{vdg}\n\tA dependency directed acyclic graph that can apply to one or more UIs for our CDS, but whose lifespan must be less than the lifespan of the CDS (system). Used to define dynamic dependencies in a concurrent system.\n\\end{con-def}\n\nA VDG will always have a root node that connects to each UI that the VDG involves. Thus, a VDG can never be a disjoint graph in of itself. The root node represents the final acidic procedure that the VDG will finish before completing its lifecycle.\n\nFor example, what if a particular write on one UI needed to happen before a different write on another UI, but that this was \\textit{not} necessarily true for \\textit{all} writes for these two UIs?\n\nThe final write would be the VDG's root node, and the dependency write would be a single child node to the root node. This also means that the two nodes could be a single thread that sequentially ordered a write to the first UI then a write to the second.\n\nSo, VDGs can be assigned to a single UI or too multiple UIs.\n\nBut, \\textit{why} exactly must a VDG always have a limited lifespan (relative to the lifecycle of the system)?\n\nWell, in our previous mentioned example, if that VDG that applied to two UIs lasted the lifespan of the CDS then it would simply be acting as a spatial dependency \"representation\" (since it would signify that all writes for the dependent UI -- that it is attached to -- must wait on all writes for the dependency UI that it is also attached to). \n\nAnd if the VDG had only applied to one of the UIs then it would have represented a permanent temporal DAG for similar reasons. The only thing that makes a VDG dynamic is the fact that it's lifespan is always less then that of the CDS.\n\nSimilar to the discussion in the Acidity subsection on assigning the same thread to multiple UIs, assigning a thread to multiple VDGs can possibly lead to an underutilized concurrency potential. Threads that are assigned to VDGs are essentially virtual themselves, as it is their lifecycle that is the lifecycle of a node in a VDG.\n\nAnother dynamic property of a CDS system we want to briefly discuss is the idea of: \\textit{dynamic UIs}.\n\nIf UIs are allowed a lifecycle shorter than the system then the UI dependency graph could potentially need to be constantly redrawn. The only way to outright avoid this scenario is to create another entity that would behave like the nodes in a VDG (and that we specify must have a lifespan less than that of the CDS).\n\nIf a UI were to be dynamic, but have dependencies, there would have to be a way to say that it could not end its lifecycle until its dependencies ended their lifecycles (as well as ensuring that it's lifecycle was shorter than it's dependents).\n\nActually, this leads us to a very important (not yet discussed) lemma: \n\n\\begin{con-lem}[]\n\tUIs must cover all nodes in the CDS i.e. every node in the CDS must be addressed by at least one UI at all times. \n\\end{con-lem}\n\nSo, if we allow UIs to be dynamic then we would have to check that before a UI could end its lifecycle that every CDS node that it addresses must be addressed by some other UI. \n\nSeeing as this would be unnecessarily computationally inefficient, we thus note that dynamic UIs are only feasible if we create the secondary notion of: \\textit{Virtual UIs}.\n\n\\begin{con-def}[Virtual UI]\n\t\\label{virtual-ui}\n\tA \\textit{Virtual UI} is a dynamic UI which has a lifespan shorter than the CDS (UI) or another virtual UI that it has a dependency relationship to.\n\\end{con-def}\n\nBecause a Virtual UI (VUI) is not dependent on the same premises that real UIs are dependent on, we provide the following lemma to show an important difference between virtual and real UIs.\n\n\\begin{con-lem}[]\n\tVirtual UIs do \\textit{not} need to be unique  (either relative to real UIs or other virtual UIs) in the sense that real UIs are \"unique\" relative to other real UIs.\n\\end{con-lem}\n\nThis lack of a necessity for any uniqueness of VUIs is what gives them a significant degree of flexibility in use (even if there use can only be relatively temporary). Also, unlike VDGs which mimic Temporal DAGs, VUIs (and their dependency relationships) are more of a dynamic version of spatial UI DDAGs.\n\nThis allows us to have: \\textit{Virtual UI Dependency Graphs}. But, then this also implies that every VUI could potentially have a VDG attached to it (that must have a lifecycle less than or equal to the VUI node itself). All VUIs must have a lifecycle less than or equal to the VUI they are dependencies of. VUIs can apply to any set of nodes, but they must either have at least one real or one virtual dependent.\n\nEvery VDG and VUI node is a thread that must make it's dependents aware of its existence. In fact, all nodes in any dependency graph (virtual or real) are just threads. The only difference is that real thread nodes do not control declaring themselves dependencies of one another (this should be controlled by a \"main\" process), only virtual thread nodes can declare themselves as a (temporary) dependency of other thread nodes.\n\nThe final thing we would like to mention in this dependencies section is the fact that virtual (dynamic) nodes (both VDG and VUI nodes) can still have real nodes (spatial and temporal) as their dependencies. This implies that VDG nodes and VUI nodes with real dependencies need to be checked for cyclic dependencies, as it essentially becomes a (temporary) extension of the permanent spatial and temporal dependency graphs for the CDS. In other words, all extensions of any of our graphs must always preserve them as being DAGs (even if disjoint).\n\n\\subsection{Invariance}\n\nAnother part of discussing disjoint directed acyclic graphs and their equivalent dependencies lists is determining if an access type is allowed or not allowed to be used on a specific UI (or even at a specific time).\n\nBoundary Nodes on our UI dependency graph can be useful for determining what access types are allowed for a UI. For example, it might be simpler to allow CDS-structure modifying access types for boundary UI nodes only: specifically appending and pruning sub-graphs to the CDS. \n\nBut, we should first formalize what boundary nodes are and then look at an example of how this can be useful.\n\n\\begin{con-def}[Leaf Boundaries]\n\t\\label{leaf-boundaries}\n\tAny real DDAG node which has no dependencies is considered a \\textit{leaf boundary} node on that DDAG.\n\\end{con-def}\n\n\\begin{con-lem}[]\n\t\\label{leaf-boundaries-infinite}\n\tSince a leaf boundary node is a node without dependencies it can always iterate through its acidic operations infinitely often without waiting for other nodes.\n\\end{con-lem}\n\n\nEvery real (spatial and temporal) node can be represented by 4 numbers: spatial dependents, temporal dependents, spatial dependencies, and temporal dependencies.\n\n\\begin{minted}{go}\ntype RealNode struct{\n\tSpatialDependents uint\n\tTemporalDependents uint\n\tSpatialDependencies uint\n\tTemporalDependencies uint\n}\n\\end{minted}\n\nThe basic difference between leaf-boundary and non-boundary real nodes can be expressed with these four variables succinctly:\n\n\\noindent\\fbox{%\n    \\parbox{0.9\\columnwidth}{%\n\t    \\begin{itemize}\n\t\t\t\\item Spatial Nodes: \\{w, x, y, 0\\}\n\t\t\t\\item Spatial Leaf Boundary Nodes: \\{0, x, y, 0\\}\n\t\t\t\\item Temporal Nodes: \\{0, x, y, z\\}\n\t\t\t\\item Temporal Leaf Boundary Nodes: \\{0, 0, y, z\\}\n\t\t\\end{itemize}\n    }%\n}\n\nThere is another kind of boundary node for real DDAGs:\n\n\\begin{con-def}[Root Boundaries]\n\t\\label{root-boundaries}\n\tAny real dependency graph node which may or may not have dependencies but does not have any dependents is considered a \\textit{root boundary} node on that dependency graph.\n\\end{con-def}\n\nThe classes for root boundaries can be expressed using our primary 4 variables succinctly as well:\n\n\\noindent\\fbox{%\n    \\parbox{0.9\\columnwidth}{%\n\t    \\begin{itemize}\n\t\t\t\\item Spatial Root Boundary Nodes: \\{0, 0, y, z\\}\n\t\t\\end{itemize}\n    }%\n}\n\n\nNotice, that we do not have Temporal Root Boundary Nodes defined. This is because of the following corollary.\n\n\\begin{con-cor}[No Temporal Root Boundaries]\n\t\\label{no-temp-root-bounds}\n\tThere are no Temporal root boundaries as every Temporal node must have at least one Spatial node dependency.\n\\end{con-cor}\n\n\\begin{con-ex} [2-Regular Tree]\n\t\\label{2-regular-tree}\n\tWe will consider a 3 node 2-Regular Tree for which we assign one node to a UI and make the root node's UI dependent on the the two leaf nodes UIs. This makes our UI DDAG have one root-boundary and two leaf-boundary nodes.\n\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,\n                   main node/.style={circle,draw,font=\\small}]\n\n  \\node[main node] (1) {root};\n  \\node[main node] (2) [below left of=1] {leaf-1};\n  \\node[main node] (3) [below right of=1] {leaf-2};\n\n  \\path[every node/.style={}]\n    (1) edge node [left] {} (2)\n        edge node [right] {} (3);\n\\end{tikzpicture}\n\nIn this case, we will allow structure appending access types on the two leaf nodes. Specifically, we would like to ensure that these two UI nodes can only create new nodes on our 2-regular tree for each of the two branches of the tree (so that each UI has control over its own half of the 2-Regular Tree).\n\nThus, we can help ensure that the tree remains 2-Regular by not giving the root boundary UI node any append sub-graph access type rights.\n\\end{con-ex}\n\nIn Example \\ref{2-regular-tree}, we see that modifying the structure of our tree is dependent on what we want to preserve (which in this case is a 2-Regular Tree structure). Thus, we did not allow the root boundary UI with it's dependencies to have the ability to use access types that modify our CDS structure (as there was no need for it too).\n\nWe divided the tree into 3 UIs which established an easy way to divide access procedures as well. However, we still would not want any of our 3 original CDS nodes to be deleted, \\textit{yet} simultaneously we do want to be able to remove CDS nodes that have been appended to the two leaf CDS nodes if we want too. Therefore we still need a way to more precisely determine access type allowances.\n\nAfterall, the above example is a very simple example. What would happen if we wanted to apply access rules for an arbitrary CDS graph structure or a more complex UI DDAG? As we have seen: one way to define a rule is by defining what is we want to preserve (at a given time) and what is allowed to change.\n\nFor example, we did not want the original three CDS nodes in Example \\ref{2-regular-tree} to be deleted. But, we could have if we wanted too.\n\nIn fact, each UI could have been assigned a list of \\textit{immutable} CDS sub-graphs that cannot be removed or even have their values modified. More specifically, we could have had a list of sub-graphs in the CDS that are \\textit{invariant} to certain access types.\n\n\\begin{con-def}[Invariants]\n\t\\label{invariants}\n\tAny data $\\mathsf{d}$ stored in our CDS, or any subgraph $\\mathsf{S} \\subset \\mathsf{G}$ that does not change when acted upon by a specific Access Type $\\mathcal{A}_{t}$ is called an invariant of that access type.\n\t\\[ \\mathcal{A}_{t}\\mathsf{(d)} \\rightarrow \\mathsf{d} \\]\n\t\\[ \\mathcal{A}_{t}\\mathsf{(S)} \\rightarrow \\mathsf{S} \\]\n\\end{con-def}\n\n\\begin{con-aside}\nImmutability is only a kind of invariance. A low-resolution invariance which blanket-denies all modification access types.\n\nUIs are not necessarily immutable, although we could have immutable UIs if we wanted to not allow structure modification access types to change that UI.\n\nAn UI can only be immutable if it is strictly-unique i.e. iff it only accesses nodes and edges that no other UI can access. The reason for this is that if a UI covers a part of the structure that another UI addresses, then the other UI could modify the underlying CDS structure and this UI would then technically be changed.\n\nThis is why it is better to assign immutability to CDS nodes. That way, regardless of what UI a node or edge is in, if it is immutable it can never be changed by any access procedure.\n\\end{con-aside}\n\nEvery node in our CDS Graph $\\mathsf{G}$ has a set of access types $\\mathcal{A}$ that it is invariant under. Either the CDS node and its value remain invariant under an access type (e.g. a ``read'' or \"copy\" access type), or only the node itself remains invariant (e.g. a ``write'' or \"increment\" access type). Otherwise, the node and the value are mutable (e.g. in a ``delete-subgraph'' access type).\n\nThus, these are the canonical invariance classes for access types:\n\n\\noindent\\fbox{%\n    \\parbox{0.7\\columnwidth}{%\n\t\t\\begin{itemize}\n\t\t\t\\item Node and value are invariant.\n\t\t\t\\item Only node is invariant.\n\t\t\t\\item No Invariance.\n\t\t\\end{itemize}\n    }%\n}\n\nWe could of course describe invariants at a higher level e.g. in terms of sub-graphs which are or not invariant under an access type. But, for now we just leave this as a pattern that can be used to help determine access types that are allowed (or not allowed) to be used by a particular process accessing the CDS.\n\n\\subsection{Partial Orderings}\n\nThe last thing we want to mention about dependency graphs is rules for how the graph structure should be organized. One approach is by defining a partial ordering for the nodes that will be in the graph. We will not expound completely on this topic in this paper, instead only mention a single possible approach to temporal DAG orderings.\n\nWe want to discuss \\textit{access type priorities} and how they can be used to define an ordering on a temporal DAG. We know that access types can be simple reads and writes to much more complex calculation-based overwrites. However, our example will focus on simple read and write priority operations in regards to implementing a degree of ``consistency''.\n\nBy consistency we are referring to determining how often a read can be guaranteed to be reading after the latest write. One obvious simple way is to specify that if any write access procedures are in progress that a read must wait for them to signal completion before reading a value. This of course translates to a simple dependency graph where reads become dependent on write access procedures to complete before commencing themselves.\n\nThe way in which we can implement this is via: access type priorities. If the write access type has a higher priority than a read, then every write is added as a dependency to any existing read operation for a particular UI. Priorities can also vary from UI to UI.\n\nThe key point is that priorities of access types automatically grants us an ordering for access procedures for a UI (or for an entire CDS if applied to all UIs). And we get an automated ordering if all access types receive an ordering.\n\n\\subsection{Review}\n\n\\begin{con-def}[Spatial Threads]\n\t\\label{spatial-threads}\n\t\\textit{Spatial Threads} are threads that last the lifespan of the CDS and are attached to a single UI.\n\\end{con-def}\n\n\\begin{con-def}[Temporal Threads]\n\t\\label{temporal-threads}\n\t\\textit{Temporal Threads} are threads that last the lifespan of the CDS and are attached to a single UI (in this case temporal threads represent all (permanent) threads beyond the initial spatial thread attached to a UI).\n\\end{con-def}\n\n\\begin{con-def}[Spawn Threads]\n\t\\label{temporal-threads}\n\t\\textit{Virtual Spawn Threads} are threads are spawned by temporal threads, attached to the same UI, have lifespans shorter than the CDS, and are commonly used to avoid cyclic dependencies by becoming a temporary dependent of one of the temporal threads dependent nodes.\n\\end{con-def}\n\n\\begin{con-def}[VDG Threads]\n\t\\label{virtual-threads}\n\t\\textit{VDG Threads} are threads that have a lifespan shorter than the CDS (or \"Thread Node\" that they are a dependency of) and can be assigned to multiple UIs. But VDGs are processed independently\n\\end{con-def}", "meta": {"hexsha": "a6faf0cfcebb66a59694066808270bf55d20d839", "size": 30724, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/concepts.tex", "max_stars_repo_name": "JKhawaja/concurrency", "max_stars_repo_head_hexsha": "0b1a84fc3285b54d9554101e45257705cd4595e6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2017-06-17T01:33:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-19T03:25:38.000Z", "max_issues_repo_path": "tex/concepts.tex", "max_issues_repo_name": "JKhawaja/concurrency", "max_issues_repo_head_hexsha": "0b1a84fc3285b54d9554101e45257705cd4595e6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/concepts.tex", "max_forks_repo_name": "JKhawaja/concurrency", "max_forks_repo_head_hexsha": "0b1a84fc3285b54d9554101e45257705cd4595e6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.5780051151, "max_line_length": 713, "alphanum_fraction": 0.7810831923, "num_tokens": 7062, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.44741290505710785}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsubsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{8cm}\n\\setlength{\\figureheight}{6cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\E}{\\mathbb{E}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\ci}{\\text{CI}}\n\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\begin{document}\n\n\\section*{Hypothesis testing}\n\nLet's return to the issue of hypothesis testing. Suppose we are reasoning about\na parameter $\\theta$ in light of data $\\data$, and wish to consider a hypothesis\n$\\theta \\in \\mc{H}$, where $\\mc{H} \\subseteq \\Theta$ is some set of possible\nvalues for this parameter.\n\nWe have seen that the Bayesian approach to hypothesis testing is\nstraightforward. We first derive the posterior distribution $p(\\theta \\given\n\\data)$ and then may compute the probability of the hypothesis directly:\n\\[\n  \\Pr(\\theta \\in \\mc{H} \\given \\data)\n  =\n  \\int_{\\mc{H}} p(\\theta \\given \\data) \\intd \\theta.\n\\]\n\nLet's consider an explicit example. Suppose we are interested in the unknown\nbias of a coin $\\theta \\in (0, 1)$, and begin with the uniform prior on the\ninterval $(0, 1)$:\n\\[\n  p(\\theta) = \\mc{U}\\bigl(\\theta; 0, 1\\bigr)\n            = \\mc{B}(\\theta; \\alpha = 1, \\beta = 1).\n\\]\nLet's collect some data to further inform our belief about $\\theta$. Suppose we\nflip the coin independently $n = 50$ times and observe $x = 30$ heads. After\ngathering this data, we wish to consider the natural question of whether the\ncoin is fair: that is, whether $\\theta = \\nicefrac{1}{2}$.\n\nFrom the developments in the last lecture, we can compute the posterior\ndistribution easily. It is an updated beta distribution:\n\\[\n  p(\\theta \\given \\data) = \\mc{B}(\\theta; 31, 21).\n\\]\nWe may now compute the posterior probability of the hypothesis that the coin is\nfair:\n\\[\n  \\Pr(\\theta = \\nicefrac{1}{2} \\given \\data)\n  =\n  \\int_{\\nicefrac{1}{2}}^{\\nicefrac{1}{2}}\n  p(\\theta \\given \\data)\n  \\intd\\theta\n  =\n  0.\n\\]\nThe posterior probability of the coin being \\emph{exactly} fair is zero! This\nshould not be surprising, as suggesting that we could possibly know the bias of\nthe coin with infinite precision is unfathomable.\n\nWe may however relax the question a bit to get some more insight. One option\nwould be to consider a parameterized family of hypotheses of the form\n\\[\n  \\mc{H}(\\varepsilon) = (\\nicefrac{1}{2} - \\varepsilon, \\nicefrac{1}{2} + \\varepsilon).\n\\]\nThus a high probability of the hypothesis $\\mc{H}(\\varepsilon)$ corresponds to\nthe notion that the coin is ``near fair'' with an allowed error of\n$\\varepsilon$. We may then compute the posterior probability of these hypotheses\nand consider how they vary as a function of $\\varepsilon$. Figure\n\\ref{near_fair_probabilities} shows the results for the coin-flipping example\nabove. We can see that there's approximately a 50\\% posterior probability that\nthe bias of the coin is in the interval $(0.4, 0.6)$, corresponding to\n$\\varepsilon = 0.1$. We also have evidence to conclude $\\theta \\in (0.25, 0.75)$\nwith near certainty. These probabilities help constrain exactly how ``fair'' or\n``not fair'' we believe the coin to be in light of our evidence.\n\n\\begin{figure}\n  \\centering\n  \\input{figures/near_fair_probabilities}\n  \\caption{The posterior probability of the hypotheses $\\mc{H}(\\varepsilon)$ for\n    $0 < \\varepsilon < \\nicefrac{1}{2}$.}\n  \\label{near_fair_probabilities}\n\\end{figure}\n\nWe briefly discussed the classical approach to hypothesis testing in the last\nlecture, and will expand upon that procedure here. The idea is to create a\nso-called ``null hypothesis'' $\\mc{H}_0$ that serves to define what ``typical''\ndata may look like assuming that hypothesis. For example, for reasoning about\nthe fairness of a coin, we may choose the natural null hypothesis\n$\\mc{H}_0\\colon \\theta = \\nicefrac{1}{2}$. Now we can use the likelihood\n\\[\n  \\Pr(x \\given n, \\theta = \\nicefrac{1}{2})\n\\]\nto reason about what observed data would look like if this hypothesis were\ntrue. This is a critical point: the null hypothesis exists to define what sort\nof data we would expect to see under an assumed value of $\\theta$.\n\nThe classical procedure is then to define a statistic summarizing a given\ndataset $s(\\data)$ in some way. An example for coin flipping would be the sample\nmean $s(\\data) = \\hat{\\theta} = \\nicefrac{x}{n}$. This happens to be a common\nestimator for $\\theta$ as well, but this is a coincidence. We now compute a\nso-called \\emph{critical set} $C(\\alpha)$ with the property\n\\[\n  \\Pr\\bigl(s(\\data) \\in C(\\alpha) \\given \\mc{H}_0\\bigr) = 1 - \\alpha,\n\\]\nwhere $\\alpha$ is called the \\emph{significance level} of the test. The\ninterpretation of the critical set is that the statistic computed from datasets\ngenerated assuming the null hypothesis ``usually'' have values in this range.\n\nFinally, we compute the statistic for a particular set of observed data and\ndetermine whether it lay inside the critical set $C(\\alpha)$ we have defined. If\nso, the dataset appears, according to the statistic, typical for datasets\ngenerated from the null hypothesis. If not, the dataset appears unusual, in the\nsense that data generated assuming the null hypothesis would have such extreme\nvalues of the statistic only a small portion of the time ($100\\alpha$\\%). In\nthis case, you ``reject'' the null hypothesis with significance $1 - \\alpha$.\n\nWhat is a $p$-value? It must be the probability that the null hypothesis is\ntrue, right? No, it can't be: the null hypothesis cannot be associated with a\nprobability in the classical interpretation of probability. A $p$-value is\nactually the minimum $\\alpha$ for which you would reject the null hypothesis\nusing this procedure. That is, a $p$-value is not the probability that the null\nhypothesis is true, but rather the probability that we would observe results as\nextreme as those in our dataset, as measured by the chosen statistic, \\emph{if\n  the null hypothesis were true!} The $p$-value is thus only a probability that\nis well-defined when already assuming the null hypothesis to be true.  A\n$p$-value does \\emph{not} say how extreme our results would appear under\nalternative hypotheses.\n\nBayesian model selection will eventually allow us to explicitly quantify the\nplausibility of a collection of models having generated the observed data.\n\nTo interpret the above procedure in the frequency interpretation of probability,\nthe critical sets are constructed by reasoning about the following experiment:\n\\begin{itemize}\n\\item\n  generate $\\data$ assuming $\\mc{H}_0$;\n\\item\n  compute $s(\\data)$;\n\\item\n  state $s(\\data) \\in C(\\alpha)$.\n\\end{itemize}\nIn the limit of infinitely many repetitions of this experiment, the final claim\nwill be true exactly $100(1 - \\alpha)\\%$ of the time. Recall this is the\ndefinition of probability in this context: the frequency of occurrence in the\nlimit of infinitely many trials. Note that the experiment we repeat here\n\\emph{includes generating data from the null hypothesis} as its first step! This\nis not the experiment we are conducting, since we have a dataset in front of us\nthat we want to analyze, which may have been generated in any number of ways.\n\n\\section*{Summarizing Distributions}\n\nIn the Bayesian method, the posterior distribution $p(\\theta \\given \\data)$ is\nthe main object of interest and contains all relevant information about $\\theta$\nin light of the observations $\\data$.  A natural task is to provide a summary of\nthe posterior distribution, for example to efficiently convey its relevant\nproperties.\n\nIn the next lecture we will consider point estimation, which is one common\nsummarization method. Another commonly considered problem is \\emph{interval\n  summarization,} where we provide an interval $(\\ell, u)$ indicating plausible\nvalues of the parameter $\\theta$ in light of the observed data. Classical\ninterval estimates are known as \\emph{confidence intervals,} and we will discuss\nthem in more detail shortly.\n\nThe Bayesian approach to interval estimation is straightforward. Again we use\nthe posterior distribution $p(\\theta \\given \\data)$ to guide the construction of\nan interval summary. If we can find an interval $(\\ell, u)$ such that the\nposterior probability that $\\theta \\in (\\ell, u)$ is ``large'' (say, has\nprobability $\\alpha$):\n\\[\n  \\Pr\\bigl(\\theta \\in (\\ell, u) \\given \\data\\bigr)\n  =\n  \\int_\\ell^u p(\\theta \\given \\data) \\intd\\theta\n  =\n  \\alpha,\n\\]\nthen we call $(\\ell, u)$ an $\\alpha$\\emph{-credible interval} for $\\theta$.\nNote the parallel in this definition to our treatment of hypothesis testing\nabove! Effectively, an $\\alpha$-credible interval is simply a hypothesis that\nhas posterior probability equal to $\\alpha$ and happens to take the form of an\ninterval.\n\nExamining our coin flipping example from before, we can construct some credible\nintervals immediately from the data in Figure \\ref{near_fair_probabilities}.  We\nhave that $\\mathcal{H}(\\varepsilon = 0.1) = (0.4, 0.5)$ is a 50\\%-credible\ninterval for the bias of the coin, and $\\mathcal{H}(\\varepsilon = 0.2) = (0.3,\n0.7)$ is a 95\\%-credible interval. The slightly wider interval\n$\\mathcal{H}(\\varepsilon = 0.25) = (0.25, 0.75)$ represents a very high\nprobability credible interval, corresponding to $\\alpha > 99\\%$.\n\nIt is clear from the definition that multiple intervals (in fact, often\nuncountably many) can serve as a credible interval for a particular value of\n$\\alpha$. Exactly which interval should we construct to summarize a given\ndistribution? This is a question for which we will need to develop Bayesian\ndecision theory before we can continue, which we will discuss in the next\nlecture. In short, we will first need to quantify how ``desirable'' a given\ncredible interval is in some way, then select the one maximizing this measure.\nFor example, we may want to construct the narrowest possible interval, or we may\nwish it to be centered on a particular point (such as the posterior mean,\nmedian, or mode), or we may wish the interval to have some other property.\n\nThe classical approach to interval summarization is to construct a so-called\nconfidence interval for the parameter of interest $\\theta$. Again a confidence\ninterval is described in terms of repeating a particular experiment infinitely\nmany times. The experiment we consider will proceed as follows. First we are\ngoing to define a function $\\ci(\\data)$ that will map a given dataset $\\data$ to\nan interval $(\\ell, u) = \\ci(\\data)$. Now we consider repeating the following\nexperiment:\n\\begin{itemize}\n\\item\n  collect data $\\data$\n\\item\n  compute the interval $(\\ell, u) = \\ci(\\data)$\n\\item\n  state $\\theta \\in (\\ell, u)$.\n\\end{itemize}\nIn the limit of infinitely many repetitions of this experiment, if the final\nstatement is true with probability $\\alpha$, then the procedure $\\ci(\\data)$ is\ncalled an $\\alpha$\\emph{-confidence interval procedure,} and we will write\n$\\ci(\\data; \\alpha)$ to indicate the confidence level $\\alpha$ when required.\n\nThis might sound like exactly the same definition as a Bayesian credible\ninterval. For example, if we have an $\\alpha$-confidence interval procedure\navailable, then when we plug in a given dataset $\\data$, we must have\n\\begin{equation}\n  \\Pr\\bigl(\\theta \\in \\ci(\\data; \\alpha) \\given \\data) = \\alpha, \\tag{$\\star$}\n  \\label{wrong}\n\\end{equation}\nright? \\emph{No!} This interpretation is widespread, but it is wrong.  The\nconclusion in \\eqref{wrong} is sometimes known as the \\emph{fundamental\n  confidence fallacy,}%\n%\n\\footnote{See the following reference for some excellent extended discussion on\n  confidence intervals:  Richard D.\\ Morey, et al.\\ (2015). The fallacy of placing\n  confidence in confidence intervals. \\emph{Psychonomic Bulletin \\& Review}\n  23(1): 103--123}\n%\nand confuses the nature of prior information with that of posterior\ninformation. Namely, note that the experiment we consider when defining the\nconfidence interval procedure \\emph{includes gathering a random dataset} as its\nfirst step. All we know is that if we repeat the confidence interval procedure\non \\emph{infinitely many datasets,} that it will succeed with probability\n$\\alpha$. However, we usually have only one particular dataset in front of us to\nanalyze that we care about, and we cannot say anything about the interval\nproduced for this dataset in isolation.\n\nHere is a simple example that shows how \\eqref{wrong} can fail. Suppose we are\ngoing to observe two values $x_1, x_2 \\in \\R$ generated independently from some\nunknown distribution $p(x)$ and wish to construct a confidence interval for the\nmean of the distribution generating the data, $\\theta = \\E[x]$. Consider the\nfollowing procedure:\n\\[\n  \\ci(\\data) =\n  \\begin{cases}\n    (-\\infty, \\infty) & x_1  <   x_2 \\\\\n    \\emptyset         & x_2 \\geq x_1.\n  \\end{cases}\n\\]\nObviously this trivial map is a 50\\%-confidence interval procedure! Because the\nvalues are generated independently, $x_1$ will be the lesser value exactly 50\\%\nof the time.  In this case, the absurdly large interval produced will\n\\emph{definitely} contain $\\theta$.  The other 50\\% of the time, the interval\nwill be empty, and \\emph{definitely will not} contain $\\theta$. Therefore the\nprocedure succeeds exactly 50\\% of the time. However, in half the cases, the\nposterior probability that $\\theta$ is inside the interval produced is 100\\%,\nand otherwise this probability is 0\\%. In no case is this probability equal to\nthe confidence level.\n\nAnother fallacy in the interpretation of confidence intervals is the so called\n\\emph{precision fallacy,} that shorter confidence intervals indicate the data\nprovide more precise information about $\\theta$. A striking illustration of this\nfallacy is provided by the ``lost submarine'' example provided by Morey, et\nal.\\ in the reference given below. I encourage you to read this paper and\nreflect!\n\n\\end{document}\n", "meta": {"hexsha": "58b685f4de4a23ac6e165f324e365199b8be82bb", "size": 15127, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_notes/Bayesian Inference II/notes.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "lecture_notes/Bayesian Inference II/notes.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "lecture_notes/Bayesian Inference II/notes.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 45.2904191617, "max_line_length": 87, "alphanum_fraction": 0.752098896, "num_tokens": 3995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.44741290505710773}}
{"text": "\\subsection{Lazy Approach as Abstraction Refinement}\n\n\\begin{frame}\n  \\frametitle{Abstraction}\n  Assigment relations\n  \\vfill\n  \\begin{center}\n  \\begin{tabular}{ccc}\n\n    \\begin{minipage}{.2\\textwidth}\n\n    $\\babst{\\varphi}$ \\\\\n    \\\\\n    \\\\\n    \\\\\n    \\\\\n    \\\\\n    $\\varphi$ \n\n    \\end{minipage}\n\n    &\n\n    \\begin{minipage}{.55\\textwidth}\n      \\begin{overlayarea}{\\textwidth}{5cm}\n\t\\only<1-3|handout:0>{\\scalebox{.4}{\\input{assignments_1.pdf_t}}}\n\t\\only<4|handout:0>{\\scalebox{.4}{\\input{assignments_2.pdf_t}}}\n\t\\only<5|handout:0>{\\scalebox{.4}{\\input{assignments_3.pdf_t}}}\n\t\\only<6|handout:0>{\\scalebox{.4}{\\input{assignments_4.pdf_t}}}\n\t\\only<7>{\\scalebox{.4}{\\input{assignments_5.pdf_t}}}\n      \\end{overlayarea}\n    \\end{minipage}\n\n    &\n\n    \\begin{minipage}{.3\\textwidth}\n\n    \\onslide<3->{$2^n$} \\\\\n    \\onslide<3->{($n = |\\{ a_i \\}|$)}\\\\\n    \\\\\n    \\\\\n    \\\\\n    \\onslide<2->{$\\infty$} \\\\ \n    \\onslide<2->(can be) \n\n    \\end{minipage}\n\n  \\end{tabular}\n  \\end{center}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Abstraction}\n  Model relations\n  \\begin{itemize}\n    \\item<2-> if $\\mu$ is a model for $\\varphi$, then $\\babst{\\mu}$ is a model for $\\babst{\\varphi}$\n    \\item<3-> if $\\babst{\\mu}$ is not a model for $\\babst{\\varphi}$, then there is no $\\mu$ that is a model for $\\varphi$\n    \\item<4-> there may be some model $\\babst{\\mu}$ for $\\babst{\\varphi}$ that does not map to any model \n\t      $\\mu$ for $\\varphi$\n  \\end{itemize}\n  \\vfill\n  \\begin{center}\n  \\begin{tabular}{cc}\n\n    \\begin{minipage}{.2\\textwidth}\n\n    $\\babst{\\varphi}$ \\\\\n    \\\\\n    \\\\\n    \\\\\n    \\\\\n    \\\\\n    $\\varphi$ \n\n    \\end{minipage}\n\n    &\n\n    \\begin{minipage}{.7\\textwidth}\n      \\begin{overlayarea}{\\textwidth}{5cm}\n\t\\only<1|handout:0>{\\scalebox{.4}{\\input{models_1.pdf_t}}}\n\t\\only<2|handout:0>{\\scalebox{.4}{\\input{models_2.pdf_t}}}\n\t\\only<3|handout:0>{\\scalebox{.4}{\\input{models_3.pdf_t}}}\n\t\\only<4>{\\scalebox{.4}{\\input{models_4.pdf_t}}}\n      \\end{overlayarea}\n    \\end{minipage}\n\n  \\end{tabular}\n  \\end{center}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Abstraction Refinement}\n\n  \\scriptsize\n\n  Notice that\n  \\begin{itemize}\n    \\item Assignments $\\mu$ of $\\varphi$ are many (potentially $\\infty$),\n          infeasible to check if any of them is a model {\\bf systematically}\n    \\item Models $\\babst{\\mu}$ of $\\babst{\\varphi}$ are finite in number,\n          and easy to enumerate with a SAT-solver\n    \\item A model $\\babst{\\mu}$ is nothing but a {\\bf conjunction of \\tatoms},\n          can be checked efficiently with a \\tsolver\n  \\end{itemize}\n  \\vfill\n  \\pause\n  These observations suggest us a methodology\n  to tackle the SMT(\\T) problem\n  \\begin{itemize}\n    \\item Enumerate a Boolean model $\\babst{\\mu}$ of $\\babst{\\varphi}$ (abstraction). If no model \n\t  exist we are done ($\\varphi$ is unsatisfiable) \\pause\n    \\item Check if $\\babst{\\mu}$ is satisfiable using the \\tsolver. If so $\\babst{\\mu}$ can be extended \n          to a model $\\mu$ of $\\varphi$, and so we are done ! ($\\varphi$ is satisfiable) \\pause\n    \\item It not, we tell the SAT-solver not to enumerate $\\babst{\\mu}$ again,\n          thus {\\bf cutting away systematically an infinite number} \n\t  of assignments for $\\varphi$ (refinement) \\pause\n    \\item It can be blocked by adding a clause $\\neg \\babst{\\mu}$. Go up \\pause\n    \\item It terminates because there are finite Boolean models\n  \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Abstraction Refinement}\n\n  \\scriptsize\n  \n  The lazy approach falls into the so-called {\\bf abstraction-refinement} \n  paradigm\n  \\vfill\n  \\begin{center}\n  \\scalebox{.5}{\\input{ar.pdf_t}}\n  \\end{center}\n\n\\end{frame}\n", "meta": {"hexsha": "7fc5780fda51ca465fd8a770babd0c130329385b", "size": 3637, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture4/ar.tex", "max_stars_repo_name": "formalmethods/smtlectures", "max_stars_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-11-07T19:34:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-24T08:05:50.000Z", "max_issues_repo_path": "lecture4/ar.tex", "max_issues_repo_name": "formalmethods/smtlectures", "max_issues_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lecture4/ar.tex", "max_forks_repo_name": "formalmethods/smtlectures", "max_forks_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-06T00:40:41.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-06T00:40:41.000Z", "avg_line_length": 26.1654676259, "max_line_length": 121, "alphanum_fraction": 0.6288149574, "num_tokens": 1247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.44741290178915816}}
{"text": "\\section{Sediment Transport}\\label{erosion.sec.full_trans}\nIce sheets and glaciers modify their beds by eroding it, transporting sediments within a basal ice layer and a deformable bed and depositing these sediments again. These processes leave a wealth of geological data once the ice sheet has disappeared. Modelling these processes adds to our understanding of the cryospherice system. The model can be tested by comparing model output with geological observations. As usual there are feedback mechanisms between various subsystems.\n\nThere are three possible basal boundary conditions. The most simple boundary condition is when the ice is frozen to the bed which can be hard bed rock or frozen sediments (see Fig. \\ref{erosion.fig.velos}A). In this case ice moves through internal deformation driven by gravity only.  The second boundary condition occurs when the ice sheet resting on hard bedrock is melting. In this case basal d\\'ecollement occurs and the ice sheet can slide over the bed (see Fig. \\ref{erosion.fig.velos}B). Empirical sliding laws usually take the form\n\\begin{equation}\n  \\vec{v}_{\\text{slide}} = a\\tau_b^pN^{-q},\n\\end{equation}\nwhere $\\tau_b$ is the basal shear stress, $N$ the effective pressure and $a$, $p$ and $q$ are parameters \\citep{Paterson1994}. The third boundary condition occurs when the sediments at the ice bed can deform (see Fig. \\ref{erosion.fig.velos}C).\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{\\dir/figs/pressure_stress_strain.eps}\n  \\label{fig.stress_etc}\n\\end{figure}\n\nThis document focuses on the theoretical background and implementation of the third type of boundary condition. The model used here is based on the theory developed in \\citet{Boulton1996a}. \n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{\\dir/figs/ice_velo.eps} \n  \\caption{Profiles showing horizontal velocities when the basal ice is frozen to the bed (A), the ice sheet is sliding over a rigid bed (B) and when the ice sheet is sliding over a bed of deforming sediments (C). There are three possible velocity components: the internal ice velocity, $\\vec{v}_{\\text{ice}}$, the sliding velocity, $\\vec{v}_{\\text{slide}}$ and the sediment velocity, $\\vec{v}_{\\text{sed}}$ \\citep[after][]{Boulton1996a}.}\n  \\label{erosion.fig.velos}\n\\end{figure}\n\nHere, the till layer is treated as a perfectly plastic material, i.e. it does not deform until the applied stress exceeds the yield strength, $\\sigma_0$, of the till layer. The yield strength of the sediment is given by a Mohr--Coulomb failure criterion:\n\\begin{equation}\n  \\sigma_0=N\\tan\\phi+c,\n\\end{equation}\nwhere $c$ is the cohesion and $\\phi$ the angle of internal friction. The effective pressure at depth is\n\\begin{equation}\n  N(z)=N_0+\\frac{dN}{dz}z\n\\end{equation}\nwhere $N_0$ is the effective pressure at the ice bed. The effective pressure can be assumed to increase linearly with depth as a function of the weight of the overlying sediments. If the applied stress $\\tau_b$ is assumed to be constant with depth, sediment motion will cease at a depth, $z_a$, where $\\tau_b$ is equal to the yield strenght of the material, i.e.\n\\begin{equation}\n  \\tau_b=\\left(N_0+z_a\\frac{dN}{dz}\\right)\\tan\\phi+c\n\\end{equation}\nor\n\\begin{equation}\n  \\label{erosion.eq.sed_thick}\n  z_a=\\left(\\frac{\\tau_b-c}{\\tan\\phi}-N_0\\right)\\left({\\frac{dN}{dz}}\\right)^{-1}.\n\\end{equation}\n\n\\begin{subequations}\nAssuming a non--linearly viscous medium, the flow law for the deforming sediment layer can be written as\n\\begin{equation}\n  \\dot\\epsilon=A\\frac{\\tau_b^n}{N^m}\n  \\label{erosion.eq.tillflow1}\n\\end{equation}\nwhere $\\dot\\epsilon$ is the shear strain rate and $A$, $m$ and $n$ are constants \\citep{Boulton1996a}. A similar flow law can be formulated by assuming that strain rates depend on the amount by which the shear stress exceeds the yield stress \\citep{Boulton1987}, i.e.\n\\begin{equation}\n  \\dot\\epsilon=A\\frac{(\\tau_b-\\sigma_0)^n}{N^m}.\n  \\label{erosion.eq.tillflow2}\n\\end{equation}\n\\end{subequations}\nThe velocity of the till, $v_{\\text{sed}}$, as a function of depth is found by integrating the flow law \\eqref{erosion.eq.tillflow1} from the base of the deforming sediment layer to the surface:\n\\begin{equation}\n  \\label{erosion.eq.tillvelo}\n  v_{\\text{sed}}(z)=\\int_{z_a}^z\\dot\\epsilon(z') dz'.\n\\end{equation}\nThe sediment flux $Q_{\\text{sed}}$ is then\n\\begin{equation}\n  \\label{erosion.eq.tillflux}\n  Q_{\\text{sed}}=z_a\\overline{v}_{\\text{sed}}=\\int_{z_a}^0v_{\\text{sed}}(z)dz=\\int_{z_a}^0\\int_{z_a}^z\\dot\\epsilon(z') dz'dz\n\\end{equation}\nwhere $\\overline{v}_{\\text{sed}}$ is the average velocity in the deforming sediment layer.\n\\subsection{Simplifications}\nThe effective pressure at the ice base, $N_0=p_{\\text{ice}}-p_{\\text{water}}$, depends on the basal hydrology which we currently do not simulate. This omission forces us to make some simplifying assumptions. Assuming values of $\\phi$ and $c$ for a typical till (see Table \\ref{erosion.tab.typical_till}) and basal shear stress of about 100kPa, sediment deformation only occurs when the effective pressure is less than 145kPa \\citep{Paterson1994}. This value fits well with effective pressures between 20 and 200kPa calculated by \\citet{Boulton1996a}. In \\citet{Boulton1996} constant effective pressure is assumed with values of 50kPa and 100kPa.\n\nAssuming the sediment is relatively well drained, the potential gradient $dN/dz=N_z=\\text{const}$ is the typical gravitational gradient of about 10kPam$^{-1}$ \\citep{Boulton1996a}. Finally, the basal shear stress is given by the ice sheet model and depends on the ice thickness and surface slope \\citep{Paterson1994}:\n\\begin{equation}\n  \\vec\\tau_b=-\\rho_{\\text{ice}}gH\\vec\\nabla s.\n\\end{equation}\n\nNow all quantities of Equations \\eqref{erosion.eq.sed_thick} and \\eqref{erosion.eq.tillflux} are specified and the thickness of the actively deforming sediment bed can be expressed as a linear function of the basal shear stress,\n\\begin{subequations}\n  \\begin{equation}\n    \\label{erosion.eq.sed_thick_param}\n    z_a(\\tau_b)=\\alpha\\tau_b+\\beta,\n  \\end{equation}\n  where\n  \\begin{equation}\n    \\alpha=\\frac1{N_z\\tan\\phi}\\quad\\text{and}\\quad\\beta=-\\frac1{N_z}\\left({N_0}+\\frac{c}{\\tan\\phi}\\right)\n  \\end{equation}\n\\end{subequations}\n\n\\begin{table}[htbp]\n  \\centering\n  \\begin{tabular}{|l|cc|}\n    \\hline\n    Material & $c$ [kPa] & $\\phi$ [$^\\circ$]\\\\\n    \\hline\n    Breidamerkurj\\\"okull$^\\dag$ & 3.75 & 32\\\\\n    typical till$^\\ddag$ & 15 & 30\\\\\n    soft glacial clay & 30-70 & 27-32\\\\\n    stiff glacial clay & 70-150 & 30-32\\\\\n    till (mixed grain size) & 150-250 & 32-35\\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Values for cohesion $c$ and angle of internal friction $\\phi$ for glacial tills. Values from \\citet{Benn1998} except $^\\dag$ which is from \\citet{Boulton1987} and $^\\ddag$ which is from \\citet{Clarke1987}.}\n  \\label{erosion.tab.typical_till}\n\\end{table}\n\nThe parameters for the flow laws \\eqref{erosion.eq.tillflow1} and \\eqref{erosion.eq.tillflow2} are found by fitting them to observations from Breidamerkurj\\\"okull \\citep{Boulton1987}. In Model C the flow law exponents $m$ and $n$ are assumed to be integers. Figure \\ref{erosion.fig.stress-strain-fit} shows a plot of the observed strain rates vs calculated strain rates. The quality of the fit is not surprising considering that the data set consists of only 7 triplets of strain rate, shear stress and effective pressure. Table \\ref{erosion.tab.models} shows the best--fitting parameter values. Figure \\ref{erosion.fig.stress-strain} shows the observations together with lines of constant strain rate.\n\n\\begin{table}[htbp]\n  \\centering\n  \\begin{tabular}{|c|c|ccc|}\n    \\hline\n    \\multicolumn{2}{c|}{} & $B$ & $m$ & $n$ \\\\\n    \\hline\n    Model A& $\\dot\\epsilon=B_1{\\tau_b^{n_1}}{N^{-m_1}}$            & 32.97  & 1.8 & 1.35 \\\\\n    Model B& $\\dot\\epsilon=B_2{(\\tau_b-\\sigma_0)^{n_2}}{N^{-m_2}}$ & 107.11 & 1.35 & 0.77 \\\\\n    Model C& $\\dot\\epsilon=B_3{(\\tau_b-\\sigma_0)}{N^{-2}}$         & 380.86 & \\multicolumn{2}{c|}{}\\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Models}\n  \\label{erosion.tab.models}\n\\end{table}\n\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{\\dir/gnu/stress-strain-fit.eps}\n  \\caption{Observed strain rates versus calculated strain rates of Models A, B and C.}\n  \\label{erosion.fig.stress-strain-fit}\n\\end{figure}\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{\\dir/gnu/stress-strain.eps}\n  \\caption{Measured values of shear stress, effective pressure and strain rate, points A-G from \\citet{Boulton1987} and lines of constant strain rates (30a$^{-1}$-5a$^{-1}$) for Models A,B and C. The green line indicates the yield stress.}\n  \\label{erosion.fig.stress-strain}\n\\end{figure}\n\nThe repeated integral over the flow law, Equation \\eqref{erosion.eq.tillflow2}, can be simplified to a single integral. The sediment flux between the lower boundary $z_a$ and some level within the deforming layer $a$ is\n\\begin{equation}\n  Q_{\\text{sed}}(a)=\\int_{z_a}^a\\int_{z_a}^{z'}A\\frac{(\\tau_b-\\sigma_0)^n}{N^m}dz'dz = A\\int_{z_a}^a\\frac{(a-z)(\\tau_b-\\sigma_0)^n}{N^m}dz.\n\\end{equation}\nThe sediment flux in a layer of thickness $z_{\\text{seds}}$ which is smaller than the maximum thickness, $z_a$ is then\n\\begin{equation}\n  Q_{\\text{sed}} = Q_{\\text{sed}}(0) - Q_{\\text{sed}}(z_{\\text{seds}})\n\\end{equation}\nand the transport sediment velocity\n\\begin{equation}\n  \\overline{v}_{\\text{sed}} = \\frac{Q_{\\text{sed}}(0) - Q_{\\text{sed}}(z_{\\text{seds}})}{z_{\\text{seds}}}.\n\\end{equation}\n\nThe integrals over the flow law which need to be evaluated to get the sliding velocity, $v_{\\text{sed}}(0)$, and the transport velocity, $\\overline{v}_{\\text{sed}}$, are found by numerical integration. Figure \\ref{erosion.fig.sed_velos} shows these velocities and the thickness of the deforming sediment layer as a function of shear stress.\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics[width=0.9\\textwidth]{\\dir/figs/plot_basal.eps}\n  \\caption{Thickness of deforming sediment layer, sliding velocity and average sediment velocity as a function of applied shear stress. Velocities plotted with solid lines are calculated with flow law Model B and dashed lines with Model C.}\n  \\label{erosion.fig.sed_velos}\n\\end{figure}\n\nThe sediment velocity $v_{\\text{sed}}(z_{\\text{seds}})$ could be used for the erosion calculation described in Section \\ref{erosion.sec.hb}.\n\n\\subsection{The Sediment Model}\nThe simplifications described above suggest a simple subglacial sediment model with 3 layers and 2 boundaries. The 3 layers are\n\\begin{enumerate}\n\\item \\textbf{basal ice layer:} a thin layer of ice which carries debris gained\nby regelation processes. The layer is assumed to have a uniform thickness over the entire ice sheet.\n\\item \\textbf{deformable soft bed:} a layer of deformable sediments may accumulate below the ice sheet. The thickness of this layer is given by Equation \\eqref{erosion.eq.sed_thick_param}.\n\\item \\textbf{non--deformable soft bed:} a layer of glaciogenic sediments which is not deforming.\n\\end{enumerate}\nThe two boundary layers are the clean ice above the dirty, basal ice layer carrying debris and the hard bed rock below the non--deformable soft bed. Figure \\ref{erosion.fig.ice_sed_model} illustrates this model.\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{\\dir/figs/erosion_layers.eps}\n  \\caption{Schematic illustration of the ice sheet/sediment model.}\n  \\label{erosion.fig.ice_sed_model}\n\\end{figure}\n\nSediment erosion/deposition and transport are a consequence of the applied basal stress and hydrology. These processes are:\n\\begin{description}\n\\item[Erosion:] There are two possibilities why the subsurfaces can be eroded. The first process actually erodes the subsurfaces by abrasion/plucking, etc. Hard bedrock erosion is described in Section \\ref{erosion.sec.hb}. Secondly, the thickness of the deformable sediment layer is linked to the applied basal stress via Equation \\eqref{erosion.eq.sed_thick_param}. It can only grow if there is an undeformable soft bed layer underneath (case 2, Fig. \\ref{erosion.fig.ice_sed_model}).\n\\item[Deposition:] is a consequence of the sediment carrying capacity of the layers being exceeded. The thickness of the dirty basal ice layer is assumed to be\nconstant. Excess sediment in this layer is lost to the underlying deformable soft bed (case 1, Fig. \\ref{erosion.fig.ice_sed_model}). In a similar manner sediment is transferred from the deformable to the non--deformable soft bed layer when the maximum thickness of the deforming layer, given by Equation \\eqref{erosion.eq.sed_thick_param}, is exceeded (case 2, Fig.\\ref{erosion.fig.ice_sed_model}).\n\\item[Transport:] of sediment can occur in the dirty basal ice and in the deforming soft bed layer. The transport velocity in the basal ice layer is equal to the basal ice velocity, whereas the transport velocity in the deforming soft bed is given by Equation \\eqref{erosion.eq.tillflux}.\n\\end{description}\nNumerical treatment of the sediment transport is described in detail in the next section.\n\n\\subsection{Numerical Advection of Sediments}\nConsidering the flux of sediments through the sides of a small test volume and the continuity equation we have\n\\begin{equation}\n  \\label{erosion.eq.continuity_eqn}\n  \\frac{\\pd s}{\\pd t}+\\vec\\nabla\\cdot\\vec{q}_s=\\dot{S},\n\\end{equation}\nwhere $s$ is the thickness of the thickness of the sediment layer\\footnote{Here we are assuming that the sediment layer is incompressible}, $\\dot{S}$ is sediment erosion/deposition. The sediment flux through the faces of the control volume, $\\vec{q}_s$, is defined by\n\\begin{equation}\n  \\vec{q}_s=\\vec{v}_{\\text{sed}}s-(D+\\epsilon)\\vec\\nabla s,\n\\end{equation}\nwhere $\\vec{v}_{\\text{sed}}$ is the transport velocity of the sediment, $D$ the diffusion coefficient and $\\epsilon$ the turbulent mixing coefficients. In the case of sediment transport we can ignore diffusion and turbulent mixing so that Equation \\eqref{erosion.eq.continuity_eqn} reduces to\n\\begin{equation}\n  \\label{erosion.eq.transport_eqn}\n  \\frac{\\pd s}{\\pd t}+\\vec\\nabla\\cdot(\\vec{v}_{\\text{sed}}s)=\\dot{S}.\n\\end{equation}\n\nThere are two fundamentally different approaches to solving the advection equation \\eqref{erosion.eq.transport_eqn} numerically:\n\\begin{enumerate}\n\\item In the \\textbf{Eulerian approach} an observer watches the system evolve at fixed points in space. This scheme is easily implemented on a fixed cartesian grid. However, a numerically stable method is only found if the \\emph{Courant number} is smaller than 1 \\citep{Press1992}, i.e.\n  \\begin{equation}\n    \\frac{|\\vec{v}_{\\text{sed}}|\\Delta t}{\\Delta x}\\le1.\n  \\end{equation}\n  One major drawback of these schemes is that they often exhibit excessive non--physical oscillations \\citep{Celia1990}.\n\\item In a \\textbf{Lagrangian approach} an observer watches the system evolve as he travels with a fluid particle. This approach has the advantage that the time step can be much larger than the time step of an Eulerian scheme. However, an initially regular spaced set of particles will evolve to a highly irregularly set at later times \\citep{Staniforth1991}.\n\\end{enumerate}\nSemi--Lagrangian advection schemes combine the regular resolution of the Eulerian approach with the enhanced stability of the Lagrangian approach. Semi--Lagrangian schemes are also knwon as Method of Characteristics where the advected species is tracked only along those fluid trajectories (characteristics) which terminate at nodal points of the fixed grid \\citep{Manson2000}.\n\nThe Courant number of the sediment transport problem is naturally smaller than 1, considering typical ice velocities of the order of up to 1kma$^{-1}$ and a grid spacing of 5-10km. The conservative, semi-Lagrangian method of \\citet{Manson1999} works best for Courant numbers larger than 1. Similar to \\citet{Hildes2004}, we also use the Eulerian method developed by \\citet{Prather1986} which conserves second--order moments and includes a flux--limiter.\n", "meta": {"hexsha": "5ba38c8b94339d5190c0c44228a9f33e34bbfc11", "size": 15910, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "models/glc/cism/glimmer-cism/doc/ext/erosion/transport.tex", "max_stars_repo_name": "fmyuan/clm-microbe", "max_stars_repo_head_hexsha": "9faee9ed7d6c092c4a9e4a207f32cbffab78b85c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-03-12T01:58:26.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-16T03:08:25.000Z", "max_issues_repo_path": "models/glc/cism/glimmer-cism/doc/ext/erosion/transport.tex", "max_issues_repo_name": "fmyuan/clm-microbe", "max_issues_repo_head_hexsha": "9faee9ed7d6c092c4a9e4a207f32cbffab78b85c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-21T01:51:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-21T01:51:13.000Z", "max_forks_repo_path": "models/glc/cism/glimmer-cism/doc/ext/erosion/transport.tex", "max_forks_repo_name": "email-clm/CLM-Microbe", "max_forks_repo_head_hexsha": "711c87faec2c1bfe2cea1a7ebd07e4373e82a184", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2016-03-08T21:04:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-16T03:29:35.000Z", "avg_line_length": 74.6948356808, "max_line_length": 702, "alphanum_fraction": 0.7575738529, "num_tokens": 4589, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4474128985212085}}
{"text": "\\section{\\module{colorsys} ---\n         Conversions between color systems}\n\n\\declaremodule{standard}{colorsys}\n\\modulesynopsis{Conversion functions between RGB and other color systems.}\n\\sectionauthor{David Ascher}{da@python.net}\n\nThe \\module{colorsys} module defines bidirectional conversions of\ncolor values between colors expressed in the RGB (Red Green Blue)\ncolor space used in computer monitors and three other coordinate\nsystems: YIQ, HLS (Hue Lightness Saturation) and HSV (Hue Saturation\nValue).  Coordinates in all of these color spaces are floating point\nvalues.  In the YIQ space, the Y coordinate is between 0 and 1, but\nthe I and Q coordinates can be positive or negative.  In all other\nspaces, the coordinates are all between 0 and 1.\n\nMore information about color spaces can be found at \n\\url{http://www.poynton.com/ColorFAQ.html}.\n\nThe \\module{colorsys} module defines the following functions:\n\n\\begin{funcdesc}{rgb_to_yiq}{r, g, b}\nConvert the color from RGB coordinates to YIQ coordinates.\n\\end{funcdesc}\n\n\\begin{funcdesc}{yiq_to_rgb}{y, i, q}\nConvert the color from YIQ coordinates to RGB coordinates.\n\\end{funcdesc}\n\n\\begin{funcdesc}{rgb_to_hls}{r, g, b}\nConvert the color from RGB coordinates to HLS coordinates.\n\\end{funcdesc}\n\n\\begin{funcdesc}{hls_to_rgb}{h, l, s}\nConvert the color from HLS coordinates to RGB coordinates.\n\\end{funcdesc}\n\n\\begin{funcdesc}{rgb_to_hsv}{r, g, b}\nConvert the color from RGB coordinates to HSV coordinates.\n\\end{funcdesc}\n\n\\begin{funcdesc}{hsv_to_rgb}{h, s, v}\nConvert the color from HSV coordinates to RGB coordinates.\n\\end{funcdesc}\n\nExample:\n\n\\begin{verbatim}\n>>> import colorsys\n>>> colorsys.rgb_to_hsv(.3, .4, .2)\n(0.25, 0.5, 0.4)\n>>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4)\n(0.3, 0.4, 0.2)\n\\end{verbatim}\n", "meta": {"hexsha": "274837733ca5bfedda14c3cdbf8d756ae859c1ec", "size": 1761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Doc/lib/libcolorsys.tex", "max_stars_repo_name": "jasonadu/Python-2.5", "max_stars_repo_head_hexsha": "93e24b88564de120b1296165b5c55975fdcb8a3c", "max_stars_repo_licenses": ["PSF-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-10-23T02:57:29.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-23T02:57:29.000Z", "max_issues_repo_path": "Doc/lib/libcolorsys.tex", "max_issues_repo_name": "jasonadu/Python-2.5", "max_issues_repo_head_hexsha": "93e24b88564de120b1296165b5c55975fdcb8a3c", "max_issues_repo_licenses": ["PSF-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Doc/lib/libcolorsys.tex", "max_forks_repo_name": "jasonadu/Python-2.5", "max_forks_repo_head_hexsha": "93e24b88564de120b1296165b5c55975fdcb8a3c", "max_forks_repo_licenses": ["PSF-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-01-30T21:52:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-18T21:33:17.000Z", "avg_line_length": 32.0181818182, "max_line_length": 74, "alphanum_fraction": 0.7592277115, "num_tokens": 501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.44741289198530904}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{October 31, 2014}\n\\maketitle\n\\section*{4.1 \\#9,12,13}\n\\subsection*{9}\n$(a^{-1})^{-1}=e(a^{-1})^{-1}=a(a^{-1}(a^{-1})^{-1})=ae=a$\n\nNote that $-e\\cdot-e=e$\n$(-a)^{-1}=(e\\cdot -a)^{-1}=-e\\cdot a)^{-1}=(-e)^{-1}a^{-1}=-ea^{-1}=e\\cdot-a^{-1}=-a^{-1}$\n\n\\section*{last time}\nexamples always keep in mind, $\\mathbb{R}\\mathbb{Q} \\mathbb{C}\\mathbb{Z}_p$\n\n$\\mathbb{Z}_n$ is a field iff $n$ is prime\n\n$\\to$ n not prime take $m|n, m<n$ then $[m]$ is not invertible so $n$ is prime \n\n\n\\subsection*{def}\nwe say that for polynomials $g(x)|f(x)\\in K[x]$ if $\\exists h(x)$ such that $f(x)=g(x)h(x)$\n\nfor example $(x+1)|(x^2-1)$ in $\\mathbb{R}[x]$. $(x+1)\\not|(x^2+1)$ in $\\mathbb{R}[x]$ but it does in $\\mathbb{Z}_2[x]$: $(x+1)(x+1)=x^2+x+x+1=x^2+x(1+1)+1=x^2+x(0)+1=x^2+1$\n\nin $\\mathbb{Z}_p$ $(a+b)^p=a^p+b^p$.\n\n\\subsection*{thm}\nif $K$ is a field and $c\\in K$ and $f(x)\\in K[x]$ then there exists a unique $g(x)\\in K[x]$ such that $f(x)=g(x)(x-c)+f(c)$.\n\\subsubsection*{proof}\nclaim $x-c|f(x)-f(c)$.\n$f(x)=a_mx^m+\\dots+a_1x+a_0$\n$f(c)=a_mc^m+\\dots+a_1c+a_0$\n$f(x)-f(c)=a_m(x-c^m)+\\dots+a_1(x-c)$\n\n$x^t-c^t=(x-c)(x^{t-1}+x^{t-2}c+x^{t-3}c^2+\\dots+xc^{t-2}+c^{t-1}$\n\nand so $f(x)-f(c)=g(x)(x-c)\\to f(x)=g(x)(x-c)+f(c)$.\n\nnow assume we have $g'(x)$ and $g(x)$ that satisfy then $g(x)(x-c)-f(c)=g'(x)(x-c)-f(c)\\to (x-c)(g(x)-g'(x))=0$. $x-c$ has a coefficient of 1 and so is not zero so $g(x)-g'(x)=0$ and is unique.\n\n\\subsection*{def}\n$c\\in K$ is called a root of $f(x)\\in K[x]$ if $f(c)=0$.\n\n$c$ is a root of $f(x)$ iff $x-c$ divides $f(x)$\n\n$\\to$ assume $c$ is root, then $f(c)=0$. by previous theorem $\\exists q(x)\\in K[x]$ such that $f(x)=q(x)(x-c)+f(c)=q(x)(x-c)$ so $(x-c)$ divides $f(x)$\n\n$\\leftarrow$ assume $(x-c)$ divides $f(x)$. then $f(x)=h(x)(x-c)\\to f(c)=h(c)(c-c)=h(c)\\cdot 0=0$.\n\n\\subsubsection*{corollary}\n$f(x)\\in K[x]$, $\\deg f=n$. then $f(x)$ has at most $n$ distinct roots. (assuming non-zero polynomial)\n\ninduction  on n.\n\n$n=0$ then $f(x)=c\\ne 0$. $n=1$ then $f(x)=a_1x+a_0$, $a_1\\ne 0$.\n\nassume $c\\ne d$ are solutions. then $f(x)=(x-c)q(x)$ and $f(d)=(d-c)q(d)$. note that $(d-c)\\ne 0$ then $q(d)=0$ and then \n\nnow take a polynomial of degree $n-1$ that has $n-1$. if it has no roots, we are done. \n\\end{document}\n\n\n", "meta": {"hexsha": "e7383993c9a53ba5233fe430f1100acc64aa664e", "size": 2454, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "abstract algebra/abstract-notes-2014-10-31.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "abstract algebra/abstract-notes-2014-10-31.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "abstract algebra/abstract-notes-2014-10-31.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6164383562, "max_line_length": 193, "alphanum_fraction": 0.576609617, "num_tokens": 1091, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665855647394, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.4474128876584873}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\usepackage{graphicx}\n\\usepackage[parfill]{parskip}\n\\usepackage{relsize}\n\\newcommand\\numberthis{\\addtocounter{equation}{1}\\tag{\\theequation}}\n\\newcommand*{\\vertbar}{\\rule[1ex]{0.5pt}{2.5ex}}\n\\newcommand*{\\horzbar}{\\rule[.5ex]{2.5ex}{0.5pt}}\n\\usepackage{algorithm}% use sudo apt-get install texlive-science\n\\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx\n\\begin{document}\n\n\\title{Meta Learning overview}\n\\maketitle\n\\tableofcontents\n\n\\section{Hyper-parameter optimization}\n\nWe can optimize over weight initialization, learning rates, neural net architecture using a variety of algorithms like Random Search, Grid Search, Evolutionary Strategies etc.\n\n\n\\section{Learning to learn by gradient descent by gradient descent}\n\n$f$ is the objective function which we try to optimize by training an optimizee with parameters $\\theta$. We do so by using an optimizer $g$ that determines how $f$ should update the params given the gradient information:\n\n$\\theta_{t+1} = \\theta_{t} + g_{t}(\\nabla f(\\theta_{t}), \\phi)$\n\nWe basically have an LSTM that we train with param trajectories $\\theta_{0}, \\theta_{1}, \\ldots$ as inputs and the gradient information, how to propose the next update of the parameter $\\theta_{t+1}$.\n\nThe paper uses a `Coordinatewise LSTM optimizer`:\n\n\nTo make the learning problem computationally tractable, we update the optimzee parameters coordinatewise, much like other successful optimization methods such as Adam, RMSprop, and AdaGrad.\nTo this end, we create nn LSTM cells, where nn is the number of dimensions of the parameter of the objective function. We setup the architecture so that the parameters for LSTM cells are shared, but each has a different hidden state.\n\nThe coordinatewise architecture above treats each dimension independently, which ignore the effect of the correlations between coordinates. To address this issue, the paper introduces more sophisticated methods. The following two models allow different LSTM cells to communicate each other.\n\n\\end{document}\n", "meta": {"hexsha": "df06326ac74768e0573268a5571035935c4512f1", "size": 2095, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "meta_learning.tex", "max_stars_repo_name": "ektormak/learn2learn", "max_stars_repo_head_hexsha": "ce2e9a42229a5b4c8bc95e2d500bccdd3eaa284a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-01-20T16:00:10.000Z", "max_stars_repo_stars_event_max_datetime": "2018-06-21T16:13:52.000Z", "max_issues_repo_path": "meta_learning.tex", "max_issues_repo_name": "ektormak/learn2learn", "max_issues_repo_head_hexsha": "ce2e9a42229a5b4c8bc95e2d500bccdd3eaa284a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "meta_learning.tex", "max_forks_repo_name": "ektormak/learn2learn", "max_forks_repo_head_hexsha": "ce2e9a42229a5b4c8bc95e2d500bccdd3eaa284a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-04-05T16:05:50.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-05T16:05:50.000Z", "avg_line_length": 49.880952381, "max_line_length": 290, "alphanum_fraction": 0.7899761337, "num_tokens": 504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410572017153, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4473766249049095}}
{"text": " \n\\chapter{Introduction}\n\\label{ch_intro}\n% \\chapterhead{Introduction}\n\\markright{Introduction}\n\n% \\proj (\\defproj) \n\\proj is a\nset of software components \ndeveloped by CEA (Saclay, France) and Nice Observatory. This\nproject originated in astronomy, and involved the development of a range of \ninnovative methods built around multiscale analysis.\nMultiresolution techniques have\nbeen developed  in recent years, and furnish a powerful and \ninsightful representation\nof the data. By means of multiresolution or multiscale analysis, an \nimage can be decomposed into a set of images (or scales), each scale \ncontaining only structures of a given size. \nThis data representation, associated with noise modeling, \nhas been applied to very different applications such as data filtering, \ndeconvolution, compression, object detection, and so on. Results are \nenhanced in all such processing because the multiresolution approach\nallows a better understanding of how the data values \nare distributed in an image, \nand how the signal can be separated from the noise.\n\nThe \\proj software \ncomponents include almost all applications \npresented in the book {\\em Image and Data Analysis: the Multiscale Approach}\n \\cite{starck:book98}. The goal of \n\\proj is not to replace \nexisting image processing  packages, but to complement\nthem, offering the user a complete set of multiresolution tools. These tools\nare executable programs, which work on a wide range of platforms, \nindependently of current \nimage processing systems.  They allow the user to perform various tasks \nusing multiresolution, such as wavelet transforms, filtering, \ndeconvolution, and so on.\n\nThe programs, written in C++, are built on three classes: the  \n``image\" class, the ``multiresolution\" class, and the \n``noise\\_modeling class\".\nFig. \\ref{fig_sadam1} illustrates this architecture. A multiresolution\ntransform is applied to the input data, and noise modeling is performed.\nHence the multiple scales  can be derived, and the programs can use this\nin order to know at which scales, and at which positions, significant\nsignal has been detected. \nA wide range of \nmultiresolution transforms are available (see Fig.~\\ref{fig_sadam2}),\nallowing significant flexibility.\nFig.\\ \\ref{fig_modelnoise} summarizes how the multiresolution support data\nstructure \nis derived from the data and the noise-modeling. \n\n\nA set of  IDL\\footnote{Research Systems \nInc., 2995 Wilderness Place, Boulder, Colorado 80301.} (Interactive \nData Language) \nand PV$\\sim$Wave\\footnote{Visual Numerics Inc.,  6230 Lookout Road, \nBoulder, Colorado 80301, USA.}\nroutines\nare included in the package which interface the executables to these\nimage processing packages.  \n\n\\proj is an important package, \nintroducing front-line methods to scientists \nin the physical, space and medical domains among other fields; to engineers in \nsuch disciplines as geology and electrical engineering; and to financial \nengineers and those in  other fields requiring control and analysis of \nlarge quantities of noisy data.  \n\n% The first release of the package is at the \n% beginning of 1997.  \n% Further information on the pre-release version, codenamed \n% \\proj, can be found at  \\\\ \n% http://www.dapnia.cea.fr/Sadam\n\n\\begin{figure}[t]\n\\centerline{\n\\hbox{\n\\psfig{figure=ch_annex2_sadam.ps,bbllx=2.5cm,bblly=3.cm,bburx=17.5cm,bbury=25cm,height=12cm,width=12cm,clip=}\n}}\n\\caption{\\proj diagram.}\n\\label{fig_sadam1}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n% \\psfig{figure=ch_annex2_mr_trans.ps,bbllx=0.5cm,bblly=3.5cm,bburx=20.5cm,bbury=24.5cm,height=16cm,width=15cm,clip=}\n\\psfig{figure=fig_mr1_transf.ps,bbllx=0.2cm,bblly=3.5cm,bburx=20.5cm,bbury=24.5cm,height=16cm,width=15cm,clip=}\n}}\n\\caption{Multiresolution transforms available in \\proj (a selection).}\n\\label{fig_sadam2}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=ch2_noise.ps,bbllx=0.5cm,bblly=1.5cm,bburx=22cm,bbury=26.5cm,width=13cm,height=16.66cm,clip=}}\n}\n\\caption{Determination of multiresolution support from noise modeling.}\n\\label{fig_modelnoise}\n\\index{multiresolution support}\n\\index{support, multiresolution}\n\\end{figure}\n", "meta": {"hexsha": "d2a2632e7273ae0bf2e1dd44a1a12e0c7b59309d", "size": 4143, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr1/ch1_intro.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr1/ch1_intro.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr1/ch1_intro.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7196261682, "max_line_length": 117, "alphanum_fraction": 0.7868694183, "num_tokens": 1117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4473766116140836}}
{"text": "\\documentclass[a4paper,11pt,twoside,titlepage,openright]{book}\n\n\\usepackage[english]{babel}\n\\usepackage{color}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\numberwithin{equation}{section}\n\\usepackage[margin=3cm]{geometry}\n\\usepackage{hyperref}\n\\usepackage{epsfig,amsfonts}\n\\usepackage{transparent}\n\\usepackage{cases}\n\n%\n\\usepackage{xcolor,import}\n\n\n\\pagestyle{plain}\n\n\\newcommand{\\ud}[1]{\\underline{#1}}\n\\newcommand{\\lt}{\\left}\n\\newcommand{\\rt}{\\right}\n\\DeclareMathOperator{\\e0}{\\epsilon_0}\n\\newcommand{\\wdg}{\\wedge}\n\\newcommand{\\emis}{\\emph{emissivity}}\n\\newcommand{\\ema}{\\epsilon^{\\eta}}\n\\newcommand{\\hypot}[1]{\\textbf{\\textcolor{green}{#1}}}\n\n\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\n\n\\begin{document}\n\n\\title{ToFu geometric tools\\\\ Intersection of a LOS with a cone}\n\\author{Didier VEZINET \\and Laura S. Mendoza}\n\\date{02.06.2017}\n\\maketitle\n\n%\\tableofcontents\n\n\n\n\n\\chapter{Definitions}\n\n\\section{Geometry definition in ToFu}\n\nThe definition of a fusion device in ToFu is done by defining the edge of a poloidal plane as a set of segments in a 2D plane. The 3D volume is obtained by an extrusion for cylinders or a revolution for tori.\nWe consider an orthonormal direct cylindrical coordinate system $(O,\\ud{e}_R,\\ud{e}_{\\theta},\\ud{e}_Z)$ associated to the orthonormal direct cartesian coordinate system $(O,\\ud{e}_X,\\ud{e}_Y,\\ud{e}_Z)$. We suppose that all poloidal planes live in $(R,Z)$ and can be obtained after a revolution around the $Z$ axis of the user-defined poloidal plane at $\\theta=0$, $\\mathcal{P}_0$. Thus, the torus is axisymmetric around the $(O,Z)$ axis (see Figure~\\ref{fig:tok-ab}).\n\n\n\n\n\\begin{figure}[h]\n\\centering{\n\\def\\svgwidth{0.75\\linewidth}\n\\import{figures/}{tore_cones12.pdf_tex}\n\\caption{Two examples of a circular torus approximated by a revolved octagon. For each segment $\\overline{AB}$ of the octagon there is a cone with origin on the $(O,Z)$ axis.}\n\\label{fig:tok-ab}\n}\n\\end{figure}\n\n\\section{Notations}\n\nIn order to simplify the computations, let $A$ and $B$ be the end points of a segment $\\mathcal{S}_i$ such that $A\\neq B$ and $\\mathcal{P} = \\cup_{i=1}^{n} \\mathcal{S}_i = \\cup_{i=1}^n \\overline{{\\rm A}_i{\\rm B}_i}$ with $n$ the number of segments given by the user defining the plane $\\mathcal{P}$. We define a right circular cone $\\mathcal{C}$ of origin $P = ({\\rm A},{\\rm B}) \\cap ({\\rm O}, {\\rm Z})$ of generatrix $(A,B)$ and of axis $(O,Z)$ (see Figure~\\ref{fig:tok-ab}). Thus we can define the edge of the torus as the union of the edges of the frustums $\\mathcal{F}_i$ defined by truncating the cones $\\mathcal{C}_i$ to the segment $\\overline{AB}_i$.\n\n\n\nThen, any point $M$ with coordinates $(X,Y,Z)$ or $(R,\\theta,Z)$ belongs to the frustum $\\mathcal{F}$ if and only if\n$$\n\\exists q \\in [0;1] /\n\\left\\{ \\begin{array}{ll}\nR-R_A = q(R_B-R_A)\\\\\nZ-Z_A = q(Z_B-Z_A)\n\\end{array}\\right.\n$$\n\n\nNow let us consider a LOS $L$ (i.e.: a half-infinite line) defined by a point $D$ and a normalized directing vector $u$, of respective coordinates $(X_D,Y_D,Z_D)$ or $(R_D,\\theta_D,Z_D)$ and $(u_X,u_Y,u_Z)$.\nThen, point M belongs to $L$ if and only if:\n$$\n\\exists k \\in [0;\\infty[ / \\ud{DM} = k\\ud{u}\n$$\n\n\n%===================================================================\n\n\\chapter{Computing shortest distance between LOS and Frustum}\n\n\nWe want to calculate the shortest distance between a 3D ray $\\mathcal{R}$ defined by its origin $\\vec{D}$ and its unit directional vector $\\vec{u}$ and a frustum $\\mathcal{F}$ defined by a segment $AB$ extruded around the axis $\\vec{N}$ of coordinates $(0,0,1)$.\nWe want to compute the shortest distance between a point $P$ on the ray $\\mathcal{R}$ and a point $Q$ on the frustum $\\mathcal{F}$.\n\n\n\\begin{figure}[h]\n\\centering{\n\\def\\svgwidth{0.3\\linewidth}\n\\import{figures/}{inter_LOS_Poly.pdf_tex}~\n\\def\\svgwidth{0.45\\linewidth}\n\\import{figures/}{inter_LOS_Poly_plane.pdf_tex}\n\\caption{Example of closest point between ray and Frustum: 3D space and (R,Q) plane.}\n\\label{fig:hoz-frus-hoz-los}\n}\n\\end{figure}\n\n\nFirst, let us write some of the equations that $Q$ respects\n\n\\begin{align*}\n(Q-C) \\cdot N &= \\norm{Q-C} \\cos(\\tau_\\mathcal{C})\\\\\nR_q-R_A &= q(R_B-R_A)\\\\\nZ_q-Z_A &= q(Z_B-Z_A)\n\\end{align*}\n\nwhere $\\tau_\\mathcal{C}$ is the angle between $\\vec{AB}$ and $-\\vec{N}$. \n\n\\begin{align*}\n-\\vec{N}\\cdot\\vec{AB} & = \\norm{N} \\norm{AB} \\cos(\\tau_\\mathcal{C})\\\\\nz_A - z_B &= \\norm{AB} \\cos(\\tau_\\mathcal{C})\\\\\n\\tau_\\mathcal{C} &= \\arccos\\left(\\dfrac{z_A - z_B}{\\norm{AB}}\\right)\n\\end{align*}\n\nWe are looking to minimize the distance between $P$ and $Q$ which is equivalent to solve the following system.\n\n\n\\begin{numcases}{}\n\\dfrac{\\partial}{\\partial k} \\norm{P-Q}^2 = 0\\\\[0.2cm]\n\\label{eq:201}\n\\dfrac{\\partial}{\\partial q} \\norm{P-Q}^2 = 0\n\\label{eq:202}\n\\end{numcases}\n\n\nwith\n\n\\begin{align*}\n\\norm{P-Q}^2 &= (x_p - x_q)^2 + (y_p - y_q)^2 + (z_p - z_q)^2 \\\\\n\t& = x_p^2 + y_p^2 + z_p^2 - 2(x_p x_q + y_p y_q + z_p z_q) + x_q^2 + y_q^2 + z_q^2\\\\\n\t& = \\norm{P}^2 - 2<P, Q> + \\norm{Q}^2\n\\end{align*}\n\nand\n\n\\begin{numcases}{}\n\\dfrac{\\partial}{\\partial k} <P, Q> = \\dfrac{\\partial}{\\partial k} \\left(  (x_D + k u_x) x_q + (y_D + k u_y) y_q + (z_D + k u_z) z_q \\right)\\\\[0.2cm]\n\\label{eq:eq203}\n\\dfrac{\\partial}{\\partial q} <P, Q> = \\dfrac{\\partial}{\\partial q} \\left(x_p R_q \\cos(\\theta_q) + y_p R_q \\sin(\\theta_q) + z_p (q(z_B-z_A) - z_A)\\right)\n\\label{eq:eq204}\n\\end{numcases}\n\n\\begin{figure}[h]\n\\centering{\n\n\\def\\svgwidth{0.35\\linewidth}\n\\import{figures/}{inter_above.pdf_tex}\n\\caption{Example of closest point between ray and Frustum:  (X,Y) plane.}\n\\label{fig:inter-above}\n}\n\\end{figure}\n\nWe can see in Figure~\\ref{fig:inter-above}, that $\\theta_q = \\theta_p$. By definition $cos(\\theta_p) = x_p/R_p$ and $sin(\\theta_p) = y_p/R_p$. Thus $x_p \\cos(\\theta_q) + y_p \\sin(\\theta_q) = (x_p^2 + y_p^2)/R_p = R_p$. We introduce this in Equation~\\eqref{eq:eq204}. The derivation of Equation~\\eqref{eq:eq203} is straightforward. We obtain\n\n\\begin{numcases}{}\n\\dfrac{\\partial}{\\partial k} <P, Q> = u_x x_q + u_y y_q + u_z z_q = \\, <u, Q>\\\\[0.2cm]\n\\label{eq:eq205}\n\\dfrac{\\partial}{\\partial q} <P, Q> = R_p (R_B - R_A) + Z_p (Z_B - Z_A)\n\\label{eq:eq206}\n\\end{numcases}\n\nNow, let us derivate the remaining terms in $\\norm{P-Q}^2$\n\n$$\n\\begin{cases}{}\n\\dfrac{\\partial}{\\partial k} \\norm{P}^2 &= \\dfrac{\\partial}{\\partial k} \\left(  (x_D + k u_x)^2 + (y_D + k u_y)^2 + (z_D + k u_z)^2 \\right)\\\\[0.2cm]\n\\label{eq:eq207}\n\\dfrac{\\partial}{\\partial q} \\norm{Q}^2 &= \\dfrac{\\partial}{\\partial q} \\left( R_q^2 + Z_q^2\\right) \\\\[0.2cm]\n&= \\dfrac{\\partial}{\\partial q} \\left( (q(R_B-R_A)+R_A)^2 + (q(Z_B-Z_A)+Z_A)^2\\right)\n\\label{eq:eq208}\n\\end{cases}\n$$\n\n$$\n\\begin{cases}{}\n\\dfrac{\\partial}{\\partial k} \\norm{P}^2 &= 2k(u_x + u_y + u_z) + 2(u_x x_D + u_y y_D + u_z z_D)\\\\[0.2cm]\n& = 2k \\norm{u}^2 + 2 <u, D>\\\\[0.2cm]\n\\dfrac{\\partial}{\\partial q} \\norm{Q}^2 &= 2q((R_B - R_A)^2 + (Z_B - Z_A)^2) + 2(R_A(R_B-R_A) + Z_A(Z_B-Z_A))\\\\[0.2cm]\n& = 2q \\norm{AB}^2 + 2 <OA, AB>\n\\end{cases}\n$$\n\nThus, Equations~\\eqref{eq:201}-\\eqref{eq:202} become\n\n$$\n\\begin{cases}{}\n\\dfrac{\\partial}{\\partial k} \\norm{P-Q}^2 &= 2k \\norm{u}^2 + 2 <u, D> - 2 <u, Q> = 0\\\\[0.2cm]\n\\dfrac{\\partial}{\\partial q} \\norm{P-Q}^2 &=2q \\norm{AB}^2 + 2 <OA, AB> - 2(R_p (R_B - R_A) +Z_p (Z_B - Z_A)) = 0\n\\end{cases}\n$$\n\n$$\n\\begin{cases}{}\nk &= \\dfrac{<u, Q> - <u, D>}{\\norm{u}^2}\\\\[0.2cm]\nq  &=  \\dfrac{(R_p (R_B - R_A) +Z_p (Z_B - Z_A)) - <OA, AB>}{\\norm{AB}^2}\n\\end{cases}\n$$\n\n\n\n\\end{document}\n", "meta": {"hexsha": "33aab445946b5ea3b7864fe1f5abd7c14482b9d2", "size": 7417, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes_Upgrades/Optimize_LOSInOut/Dist_LOS_Frustum/Distance_LOS_cone.tex", "max_stars_repo_name": "Louwrensth/tofu", "max_stars_repo_head_hexsha": "df2841d24eaf223ae07d862ffaa33fdb2fc079d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2017-07-09T10:29:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T02:44:50.000Z", "max_issues_repo_path": "Notes_Upgrades/Optimize_LOSInOut/Dist_LOS_Frustum/Distance_LOS_cone.tex", "max_issues_repo_name": "Louwrensth/tofu", "max_issues_repo_head_hexsha": "df2841d24eaf223ae07d862ffaa33fdb2fc079d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 522, "max_issues_repo_issues_event_min_datetime": "2017-07-02T21:06:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T08:07:57.000Z", "max_forks_repo_path": "Notes_Upgrades/Optimize_LOSInOut/Dist_LOS_Frustum/Distance_LOS_cone.tex", "max_forks_repo_name": "Didou09/tofu", "max_forks_repo_head_hexsha": "4a4e1f058bab8e7556ed9d518f90807cec605476", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2017-07-02T20:38:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-04T00:12:30.000Z", "avg_line_length": 35.1516587678, "max_line_length": 657, "alphanum_fraction": 0.6556559256, "num_tokens": 2804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4473766116140836}}
{"text": "%-----------------------------------------------------------------------------%\n%                                                                             %\n%    K A P I T E L   2                                                        %\n%                                                                             %\n%-----------------------------------------------------------------------------%\n\n\\chapter{Mathematical Background: Optimal Bipedal Locomotion}\\label{c2}\nThe second chapter provides the reader with fundamentals regarding terminology, modeling and stability analysis in the context of humanoid robotics and presents the class of used algorithms with its relevant extensions used in the context of this thesis.\n\n\\section{Foundations of Bipedal Locomotion}\\label{sec:TheoryBiped}\n\\subsection{Terminology}\nIn order to describe the locomotion of a humanoid robot, specific terms are required that are introduced within this section. \\citeauthor{vukobratovic2007towards} provide an extensive introduction to the terminology related to bipedal walking \\cite{vukobratovic2007towards}, concisely summarized by \\citeauthor{dekker2009zero} \\cite{dekker2009zero}.\\\\\\\\\n\\textbf{Walk}\\\\\nWalk can be defined as: ``\\textit{Movement by putting forward each foot in turn, not having both feet off the ground at once}''.\\\\\\\\\n\\textbf{Run}\\\\\nRun is characterized by both feet partially leaving the ground at the same time.\\\\\\\\\n\\textbf{Gait}\\\\\nThe way each human walks and runs is unique, hence gait can be defined as: ``\\textit{Manner of walking or running}''.\\\\\\\\\n\\textbf{Periodic gait}\\\\\nIf a gait is realized by repeating each locomotion phase in an identical \n\\footnote{The locomotion phase can be identical w.r.t. the step size or the duration, depending on the index.} way, the gait is referred to as \\textit{periodic}.\\\\\\\\\n\\textbf{Symmetric gait}\\\\\nIf the left and right leg move in an identical but time-shifted manner, the gait is referred to as \\textit{symmetric}.\\\\\\\\\n\\textbf{Double Support}\\\\\nA situation where the humanoid has two isolated contact surfaces with the ground.\\\\\\\\\n\\textbf{Single Support}\\\\\nA situation where  the humanoid has only one contact surface with the ground.\\\\\\\\\n\\textbf{Support Polygon}\\\\%TODO: Maybe add figure to illustrate single vs double support\nThe support polygon is formed by the \\textit{convex hull} about the ground contact points.    \\\\\\\\\n\\textbf{Swing foot}\\\\\nThis term refers to the leg that is performing a step, i.e. moving through the air.\\\\\\\\\n\\textbf{Supporting foot}\\\\\nThis term refers to the leg that is in contact with the ground, supporting all the weight of the humanoid. \n\n\\subsection{Dynamic Modeling of Legged Robots}\\label{subsec:DynamicModeling}\nIn the following, the dynamic model for floating base systems, such as legged robots, is derived based on a general formulation. A concise introduction to dynamic modeling is presented with \\cite{scaronTeaching}, comprehensive studies can be found in \\cite{pfeiffer1996multibody, jain2010robot, featherstone2014rigid}.\n\\subsubsection{General Formulation}\nMathematical models of a robot's dynamics describe the motion as a function of time and control inputs. These models are the basis for both simulation and control of robotic systems. In an abstract form, the \\gls{EoM} can be written as: \n\\begin{equation} \\label{eqn:EoMGeneral}\nF(\\bq(t),\\bdq(t),\\bddq(t),\\bu(t),t)=0,\n\\end{equation}\nwhere \n\\begin{itemize}\n\\item $\\bt$ is the time variable, \n\\item $\\bq$ is the vector of generalized coordinates,\n\\item $\\bdq$ is the first time derivative (velocity) of \\bq, \n\\item $\\bddq$ is the second time derivative (acceleration) of \\bq and\n\\item $\\bu$ is the vector of control inputs. \n\\end{itemize}\nConsequently, the \\gls{EoM} provide a mapping between the control space on the one hand and the state space of robot on the other hand. Typical methods for computing the closed-form solution of the \\gls{EoM} are e.g. the classical \\textit{Newton-Euler} \\cite{luh1980line} method or the \\textit{Lagrange method} \\cite{hollerbach1980recursive}, where the former is based on principles for conservation of linear and angular momenta and the latter utilizes energy-based functions expressed in generalized coordinates. \n\\subsubsection{Fixed Base Systems}\nFor applications with fixed-based robots, e.g. a robotic manipulator, the multi-body dynamics can be formulated as\n\\begin{equation} \\label{eqn:EoMManipulator}\n\\myM{M}(\\bq)\\bddq+\\bdq^T\\myM{C}(\\bq)\\bdq=\\btau+\\btau_g(\\bq),\n\\end{equation}\nwhere \n\\begin{itemize}\n\\item $\\myM{M}(\\bq)$ is the generalized inertia matrix, \n\\item $\\myM{C}(\\bq)$ is the coriolis tensor, \n\\item $\\btau$ is the vector of actuated joint torques and \n\\item $\\btau_g(\\bq)$ is the vector of external joint torques caused by gravity.\n\\end{itemize}\nIn contrast to the general formulation in \\cref{eqn:EoMGeneral}, this expression is time-invariant. Hence, \\cref{eqn:EoMManipulator} can be used for computing the \\gls{FD}, as well as the \\gls{ID} of a robotic system.\n\n\\subsubsection{Implicit and Explicit Constraints}\n%Why constrains?\nThe motion of a robot is constrained by it's kinematics structure as well as additional constraints that may arise from the environment. \\cref{img:constraints} provides a classification of kinematic constraints, which are often found in the field of robotics \\cite[Ch.3]{kumar2019modular}. While equality constraints arise from permanent physical contact between two bodies, inequality constraints arise due to phenomena such as collision, bouncing or loss of contact. Equality constraints can be further divided into holonomic and non-holonomic constraints. The former constrain the position (e.g. fixed or sliding contacts), the latter constrain the velocity (e.g. rolling contacts) of multi-body systems. \n\n\\begin{figure}\n\\centering\t\n\\includegraphics[width=1\\textwidth]{img/constraints}\n\\caption[Kinematic constraints in multi-body systems]{Classification of kinematic constraints in multi-body systems \\cite{kumar2019modular}.}\n\\label{img:constraints}\n\\end{figure} \n\nIn the scope of this thesis, we focus on mobile robots that contain parallel mechanisms. In contrast to serial manipulators, two additional scleronomic constraints have to be actively enforced for this type of robotic systems:\n\\begin{itemize}\n\\item Internal loop closure constraints,\n\\item Contact constraints.\n\\end{itemize}\n\nThe contact constraints are  modeled explicitly as holonomic scleronomic constraints in the robot dynamics (see \\cref{subsec:DDPConstrainedRobotDynamics}). Since the dynamics solvers inside Crocoddyl do not allow computation for series-parallel mechanisms, a serialized robot model is used as basis of the \\gls{OC} problem. Hence, the closed loop constraints are only implicitly considered within the control architecture (see \\cref{subsec:Pipeline}). Although the usage of this simplified model reduces the accuracy, it is proven to be sufficient for dynamic real-time control \\cite{kumar2019model}.\n\n\\subsubsection{Floating Base Systems}\nAs previously mentioned, the focus of this thesis is on mobile robots. These so-called floating base systems are characterized by having a base that is free to move, rather than being fixed in space. Consequently, the vector of generalized coordinates $\\bq$ not only contains the joint's angles, but also accounts for the position and orientation of the floating base. Legged robots belong to this category of rigid-body systems as they make and break contacts with their environment in order to move. Contrary to manipulators, contacts need to be actively enforced by holonomic constraints for legged robots. There are namely two different types of contact constraints that can be applied: point contacts (3D) or surface contacts (6D). \n\nFor the case of point contacts, the dynamics of the floating base system become\n\\begin{equation*} \\label{eqn:EoMLeggedRobotPtContact}\n\\myM{M}(\\bq)\\bddq+\\bdq^T\\myM{C}(\\bq)\\bdq=\\myM{S}^T\\btau+\\btau_g(\\bq)+\\sum_{i=1}^{k}\\myM{J}_{C_i}^T\\bfun_i,\n\\end{equation*}\nwhere \n\\begin{itemize}\n\\item \\myM{S} is the selection matrix of actuated joints,\n\\item $\\myM{J}_{C_i}$ is the Jacobian at the location of a contact point $C_i$ and\n\\item $\\bfun_i$ is the contact force acting at the contact point $C_i$.\n\\end{itemize}\nFor the case of surface contacts, such as a flat foot on a flat floor, modeling a point contact is not sufficient since it only constrains the translation. In order to also account for the rotational constraints enforced by the geometry one could take into account multiple point contacts. A non-redundant alternative is to model more general frame contact constraints as\n\\begin{equation} \\label{eqn:EoMLeggedRobotSurfaceContact}\n\\myM{M}(\\bq)\\bddq+\\bdq^T\\myM{C}(\\bq)\\bdq=\\myM{S}^T\\btau+\\btau_g(\\bq)+\\sum_{i=1}^{k}\\myM{J}_{C_i}^T\\myM{w}_i,\n\\end{equation}\nwhere $\\myM{w}_i$ is referred to as the \\textit{contact wrench} acting on the contact link $i$. This wrench stacks the resulting $\\bfun_i$ of contact forces and the moment $\\btau_i$ exerted by these forces around the contact frame as\n$$\\myM{w}_i=(\\bfun_i,\\btau_i)_{6\\times 1}.$$ \nFor more details on contact wrenches and spatial vector algebra in general, the interested reader is referred to e.g. \\cite[Ch.2]{featherstone2014rigid}.\n\n\n\\section{Stability Analysis: Not Falling Down}\\label{sec:TheoryStability}\nHumanoid robots are high-dimensional, constrained and nonlinear dynamical systems. In this section, the most common criteria  for analyzing the long-term stability behavior of such complex systems are presented. Exhaustive studies on stability criteria and their relation can be found in \\cite{garcia2002classification, dekker2009zero, siciliano2016springer}.\n\n\\subsection{Static Stability Criteria}\n\\subsubsection{Floor Projection of the Center of Mass (FCoM)}\nConsider the case of a robot that is not moving, i.e. a humanoid in static double support. In that case, the only forces acting on the humanoid are the ones caused by gravity. These forces can be represented by a virtual force acting on the \\gls{CoM} of the robot. The position of the \\gls{CoM} w.r.t. the base frame can be described by\n\\begin{equation*} \n\\bp_{\\text{CoM}}=\\dfrac{\\sum_{i=1}^{n}m_i\\bp_i}{\\sum_{i=1}^{n}m_i},\n\\end{equation*}\nwhere the robot has $n$ links and $\\bp_i$ indicate the according link distances of the individual \\gls{CoM}s. The \\gls{FCoM} equals the first two components of the \\gls{CoM} position vector $\\bp_{CoM}$ and the following relation holds:\n\\begin{equation*} \n\\sum_{i=1}^{n}((\\bp_{\\text{FCoM}}-\\bp_i)\\times m_i\\bg)=\\myM{0}.\n\\end{equation*}\nThe \\gls{FCoM} can be used as a static stability margin, ensuring the motionless robot will not tip over or fall, if $\\bp_{\\text{FCoM}}$ always remains inside the \\gls{SP}. Note that this criteria is also applicable in so called \\textit{quasi-static} movements, where static forces are still dominating dynamic forces.\n\n\\subsection{Dynamic Stability Criteria}\nIn case of faster motions, dynamic forces will exceed the static forces and cannot be neglected anymore. The acting forces can be divided into contact forces and gravity/inertial forces, where the so called \\gls{ZMP} is based on the former, and the \\gls{CoP} on the latter. In the following, both concepts are introduced according to the description in \\cite{sardain2004forces} with a nomenclature equivalent to \\cite{scaronTeaching}.\n\\subsubsection{Center of Pressure (CoP)}\nThe \\gls{CoP} is defined as the point, where the field of pressure forces acting on the sole is equivalent to a single resulting force where the resulting moment is zero. Hence the \\gls{CoP} is a local quantity that is derived from the interaction forces at the contact surface. \n\nConsidering the case of a foot contacting a plane surface, the resulting contact force $\\bfun^c$ is exerted by the environment onto the robot. This force consists of the resulting pressure force $\\bfun^p=(\\bfun^c\\cdot\\bn)\\bn$, as well as the resulting friction force ${\\bfun^f=\\bfun^c-\\bfun^p}$.\nHence, the following conditions hold:\n\\begin{align*}\n\\btau_O^p \t\t&= \\myM{0} \\\\\n\\bp_{\\text{CoP}}\\times(\\bfun^p\\cdot\\bn)\\bn\t&= -\\btau_O^P \\\\\n(\\bfun^p\\cdot\\bn)\\bn\\times\\bp_{\\text{CoP}}\\times\\bn\t&= -\\bn\\times\\btau_O^p\n\\end{align*}\nSince both the sole point $O$ and $\\bp_{\\text{CoP}}$ belong to the same plane, we get:\n\\begin{equation*}\n\\bp_{\\text{CoP}}=\\dfrac{\\bn\\times\\btau_O^p}{\\bfun^p\\cdot\\bn}.\n\\end{equation*}\nFinally, friction forces are tangent to the contact surface and their moment is aligned with $\\bn$, so we equivalently can write this relationship as:\n\\begin{equation}\\label{eqn:CoPComputation}\n\\bp_{\\text{CoP}}=\\dfrac{\\bn\\times\\btau_O^c}{\\bfun^c\\cdot\\bn}.\n\\end{equation}\n\\Cref{eqn:CoPComputation} can be used to compute the \\gls{CoP} expressed in the local contact frame.\n\n%\\begin{figure}[h!]\n%\\centering\t\n%\\includegraphics[width=.5\\textwidth]{img/CoP1}\n%\\caption{}\n%\\label{img:rh5_robot}\n%\\end{figure} \n%\n%\\begin{figure}[h!]\n%\\centering\t\n%\\includegraphics[width=.6\\textwidth]{img/CoP2}\n%\\caption{}\n%\\label{img:rh5_robot}\n%\\end{figure} \n\\subsubsection{Zero-Moment Point (ZMP)}\nThe \\gls{ZMP} is defined as a point on the ground where the \\textit{tipping moment} acting on the biped equals zero. This condition can be interpreted as a constraint on the contact moments, which contains at least the roll and pitch direction. Originally, the concept has been introduced in \\cite{vukobratovic1972stability}, it has been reviewed in \\cite{vukobratovic2004zero} and made popular with \\cite{kajita2003biped}.\n\nThe concept is build upon two key assumptions:\n\\begin{itemize}\n\\item There exists one planar contact surface (i.e. no multiple surfaces like on rough terrain)\n\\item The friction is sufficiently high to prevent sliding of the feet\n\\end{itemize}\nFrom the Newton-Euler equations, the motion of the biped can be written as\n\\begin{align*}\nm\\ddot{\\bp}_{\\text{CoM}} &= m\\bg+\\bfun^c \\\\\n\\dot{\\myM{L}}_O &= \\bp_{\\text{CoM}}\\times m\\bg+\\btau_{\\text{CoM}}^c,\n\\end{align*}\nwhere $m$ denotes the total mass of the robot, $\\bg$ is the gravity vector, $\\ddot{\\bp}_{\\text{CoM}}$ the centroidal acceleration, $\\dot{\\myM{L}}_O$ the change of the angular momentum. $\\bw_{\\text{CoM}}^c=(\\btau_{\\text{CoM}}^c, \\bfun^c)_{6\\times 1}$ denotes the sum of all contact wrenches in the \\gls{CoM} frame. The gravito-inertial wrench of the robot can be defined as\n\\begin{align*}\n\\bfun^{gi} &= m(\\bg-m\\ddot{\\bp}_{\\text{CoM}}) \\\\\n\\btau_O^{gi} &= \\bp_{\\text{CoM}}\\times m\\bg-\\dot{\\myM{L}}_O.\n\\end{align*}\nUsing the wrench form of the Newton-Euler equations\n\\begin{equation}\\label{eqn:NewtonEuler} \n\\bw^{gi}+\\bw^c=\\myM{0},\n\\end{equation}\none can derive the \\gls{ZMP}, for the case of a planar surface, as\n\\begin{equation}\\label{eqn:ZMPComputation}\n\\bp_{\\text{CoM}}=\\dfrac{\\bn\\times\\btau_O^{gi}}{\\bfun^{gi}\\cdot\\bn}.\n\\end{equation}\nIn practice, one can use this formula to compute the \\gls{ZMP} from force sensors or from an inertial measurement unit. \n\\subsubsection{Coincidence of ZMP and CoP}\nAs \\citeauthor{sardain2004forces} outline, both the \\gls{ZMP} and the \\gls{CoP} yield the same point for the case of bipedal walking on a single plane surface \\cite{sardain2004forces}. Comparing \\cref{eqn:ZMPComputation} with \\cref{eqn:CoPComputation}, we recognize the only difference is that the former is applied to the (global) gravito-inertial wrench, while the latter is applied to the (local) contact wrench. If we recall the Newton-Euler equations from \\cref{eqn:NewtonEuler}, it becomes clear why both points coincide when there is only one contact plane.\n\n\\subsection{Stability Classification}\nThere are existing several classifications of stability, which will be defined in the following according to \\cite[Sec.1.2.1]{westervelt2018feedback} and \\cite{garcia2002classification}. See \\citeauthor{vukobratovic2007towards} for more details on differentiating the terms dynamic stability and dynamic balance \\cite{vukobratovic2007towards}.  \n\\subsubsection{Statically Stable Motion}\nThe gait or movement of a humanoid is classified as \\textit{statically stable} if the \\gls{FCoM} does not leave the \\gls{SP} during the entire motion or gait. Consequently, the humanoid will remain in a stable position, whenever the movement is stopped. Typically, these kinds of stability are only obtained with very low walking velocities or quasi-static motions, where the static forces dominate the dynamic forces. To this end, the \\gls{FCoM} stability criteria is used for the generation of balanced static walking gaits (see \\cref{sec:BipedSimulation}).   \n\\subsubsection{Dynamically Stable Motion}\nIf the \\gls{FCoM} partially leaves the \\gls{SP} at some point during the gait, but the \\gls{CoP} (or \\gls{ZMP}) always remains within the \\gls{SP}, the gait or movement is classified as \\textit{dynamically stable}. This stability margin is extremely useful for flat-foot dynamic walking since it prevents the foot from rotating around the boundary of the \\gls{SP}. The \\gls{CoP} is a central building block of the contact stability constrained \\gls{DDP} approach that will be discussed in \\cref{c3}.   \n\n\n\\section{Differential Dynamic Programming (DDP)}\\label{sec:TheoryDDP}\nThis section describes the basics of \\gls{DDP}, which is an \\gls{OC} algorithm that belongs to the \\gls{TO} class. The algorithm was introduced in 1966 by \\citeauthor{mayne1966} \\citep{mayne1966}. A modern description of the algorithm using the same notations as below can be found in \\cite{tassa2012synthesis, tassa2014control}.\n\\subsection{Finite Horizon Optimal Control}\nWe consider a system with discrete-time dynamics, which can be modeled as a generic function $\\bfun$\n\\begin{equation}\\label{eqn:discreteDynamics}\n\\bx_{i+1}=\\bfun(\\bx_i,\\bu_i), \n\\end{equation}\nthat describes the evolution of the state $\\bx\\in \\myM{R}^n$ from time $i$ to $i+1$, given the control $\\bu\\in \\myM{R}^m$. A complete trajectory $\\{\\bx, \\bu\\}$ is a sequence of states $\\bx=\\{\\bx_0, \\bx_1, ..., \\bx_N\\}$ and control inputs $\\bu=\\{\\bu_0, \\bu_1, ..., \\bu_N\\}$ satisfying \\cref{eqn:discreteDynamics}.\nThe \\textit{total cost} $J$ of a trajectory can be written as the sum of running costs $l$ and a final cost $l_f$ starting from the initial state $\\bx_0$ and applying the control sequence $\\bu$ along the finite time-horizon:     \n\\begin{equation}\\label{eqn:totalCost}\nJ(\\bx_0, \\bu)=l_f(\\bx_N)+\\sum_{i=0}^{N-1}l(\\bx_i,\\bu_i).\n\\end{equation}\nAs discussed in \\cref{c1}, \\textit{indirect} methods such \\gls{DDP} represent the trajectory implicitly solely via the optimal control inputs $\\bu$. The states $\\bx$ are obtained from forward simulation of the system dynamics, i.e. integration \\cref{eqn:discreteDynamics}. Consequently, the solution of the optimal control problem is the minimizing control sequence \n\\begin{equation*}\\label{eqn:minControl}\n\\bu^*=\\argmin_U J(\\bx_0, \\bu). \n\\end{equation*}\n\n\\subsection{Local Dynamic Programming}\nLet $\\bu_i\\equiv\\{\\bu_i,\\bu_{i+1}...,\\bu_{N-1}\\}$ be the partial control sequence, the \\textit{cost-to-go} $J_i$ is the partial sum of costs from $i$ to $N$: \n\\begin{equation}\\label{eqn:costToGo}\nJ_i(\\bx, \\bu_i)=l_f(\\bx_N)+\\sum_{j=i}^{N-1}l(\\bx_j,\\bu_j).\n\\end{equation}\nThe \\textit{Value function} at time $i$ is the optimal cost-to-go starting at $\\bx$ given the minimizing control sequence \n\\begin{equation*}\\label{eqn:value}\nV_i(\\bx)=\\min_{\\bu_i}J_i(\\bx, \\bu_i),\n\\end{equation*}\nand the Value at the final time is defined as $V_N(\\bx)\\equiv l_f(\\bx_N)$. The Dynamic Programming Principle \\citep{bellman1966dynamic} reduces the minimization over an entire sequence of control inputs to a sequence of minimizations over a single control, proceeding backwards in time: \n\\begin{equation}\\label{eqn:bellman}\nV(\\bx)=\\min_{\\bu}[l(\\bx, \\bu)+V'(\\bfun(\\bx,\\bu))].\n\\end{equation}\nNote that \\cref{eqn:bellman} is referred to as the \\textit{Bellman equation} for \\textit{discrete-time} optimization problems \\citep{kirk2004optimal}. For reasons of readability, the time index $i$ is omitted and $V'$ introduced to denote the Value at the next time step. The interested reader may note that the analogous equation for the case of \\textit{continuous-time} is a partial differential equation called the \\textit{Hamilton-Jacobi-Bellman equation} \\citep{underactuatedCourse2020, kamien2012dynamic}.\n\n\\subsection{Quadratic Approximation}\n\\gls{DDP} locally computes the optimal state and control sequences of the \\gls{OC} problem derived with \\cref{eqn:bellman} by iteratively performing a forward and backward pass. The \\textit{backward pass} on the trajectory generates a new control sequence and is followed by a \\textit{forward pass} to compute and evaluate the new trajectory.\n\nLet $\\bQ(\\dx,\\du)$ be the variation in the argument on the right-hand side of \\cref{eqn:bellman} around the $i^{th} (\\bx,\\bu)$ pair\n\\begin{equation}\\label{eqn:Q}\n\\bQ(\\dx,\\du)=l(\\bx+\\dx,\\bu+\\du)+V'(\\bfun(\\bx+\\dx,\\bu+\\du)).\n\\end{equation}\nThe \\gls{DDP} algorithm uses a quadratic approximation of this differential change. The quadratic Taylor expansion of $Q(\\dx,\\du)$ leads to\n\\begin{equation}\\label{eqn:QApprox}\n\\bQ(\\dx,\\du) \\approx \\dfrac{1}{2} \n\\begin{bmatrix} 1 \\\\ \\dx \\\\ \\du \\end{bmatrix}^T \n\\begin{bmatrix} 0 & \\bQ_{x}^T & \\bQ_{u}^T \\\\\n\\bQ_{x} & \\bQ_{xx} & \\bQ_{xu} \\\\\n\\bQ_{u} & \\bQ_{ux} & \\bQ_{uu} \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ \\dx \\\\ \\du \\end{bmatrix}.\n\\end{equation}\nThe coefficients can be computed as  \n\\begin{subequations}\\label{eqn:QApproxCoeff}\n\\begin{align}\n\\bQ_{x} &= l_{x}+\\bfun_{x}^T \\bV_{x}^\\prime, \\\\\n\\bQ_{u} &= l_{u}+\\bfun_{u}^T \\bV_{x}^\\prime, \\\\\n\\bQ_{xx} &= l_{xx}+\\bfun_{x}^T \\bV_{xx}^\\prime\\bfun_{x}+\\bV_{x}^\\prime\\bfun_{xx}  \\label{subeqn:Qxx},\\\\\n\\bQ_{ux} &= l_{ux}+\\bfun_{u}^T \\bV_{xx}^\\prime\\bfun_{x}+\\bV_{x}^\\prime\\bfun_{ux} \\label{subeqn:Qux},\\\\\n\\bQ_{bu} &= l_{uu}+\\bfun_{u}^T \\bV_{xx}^\\prime\\bfun_{u}+\\bV_{x}^\\prime\\bfun_{uu} \\label{subeqn:Quu}.\n\\end{align}\n\\end{subequations}\nwhere the primes denote the values at the next time-step.  \n\n\\subsection{Algorithmic Steps}\n%\\subsubsection{Backward Pass}\nThe first algorithmic step of \\gls{DDP}, namely the backward pass, involves computing a new control sequence on the given trajectory and consequently determining the search direction of a a step in the numerical optimization. To this end, the quadratic approximation obtained from \\cref{eqn:QApprox}, minimized with respect to $\\du$ for some state perturbation $\\dx$, results in\n\\begin{equation*}\n\\du^*(\\dx)=\\argmin_{\\du}\\bQ(\\dx,\\du)=-\\bQ_{uu}^{-1}(\\bQ_{u}+\\bQ_{ux}\\dx),\n\\end{equation*}\ngiving us an open-loop term $\\myM{k}$ and a feedback gain term $\\bk$:\n\\begin{equation*}\n\\bk=-\\bQ_{uu}^{-1}\\bQ_{u}\\quad \\text{and} \\quad \\bk=-\\bQ_{uu}^{-1}\\bQ_{ux}.\n\\end{equation*}\nThe resulting locally-linear feedback policy can be again inserted into \\cref{eqn:QApprox} leading to a quadratic model of the Value at time $i$: \n\\begin{align*}\n \\Delta \\bV &= -\\dfrac{1}{2}\\bk^T\\bQ_{uu}\\bk \\\\\n \\bV_{x} &= \\bQ_{x}-\\bk^T\\bQ_{uu}\\bk \\\\\n \\bV_{xx} &= \\bQ_{xx}-\\bk^T\\bQ_{uu}\\bk.\n\\end{align*}\n\n%\\subsubsection{Forward Pass}\nAfter computing the feedback policy in the backward pass, the forward pass computes a corresponding trajectory by integrating the dynamics via\n\\begin{align*}\n\\hat{\\bx}_0 \t\t&=\\bx_0 \\\\\n\\hat{\\bu}_i \t\t&=\\bu_i+\\alpha\\bk_i+\\bk_i(\\hat{\\bx}_i-\\bx_i) \\\\\n\\hat{\\bx}_{i+1}\t&=\\bfun(\\hat{\\bx}_i,\\hat{\\bu}_i),\n\\end{align*}\nwhere $\\hat{\\bx}_i,\\hat{\\bu}_i$ are the new state-control sequences. The step size of the numerical optimization is described by the backtracking line search parameter $\\alpha$, which iteratively is reduced starting from 1. The backward and forward passes of the \\gls{DDP} algorithm are iterated until convergence to the (locally) optimal trajectory.  \n\n%\\subsection{Numerical Characteristics}\n%Like Newton's method, \\gls{DDP} is a second-order algorithm \\citep{liao1992advantages} and consequently takes large steps towards the minimum. With these types of algorithms, regularization and line-search often are required to achieve convergence \\cite{liao1991convergence}. \n%\n%\\textit{Line-search} is one of the basic iterative approaches from numerical optimization in order to find a local minimum of an objective function. Backtracking line-search especially determines the step length, namely the control modification, by some search parameter.\n%\n%\\textit{Regularization} uses \\#\\#\\#\\#\\# F I L L \\#\\#\\#\\#\\#\n%\n%The interested reader can find a more extensive introduction to numerical optimization in e.g. \\cite{nocedal2006numerical} and \\citeauthor{tassa2012synthesis}  \n%provide details and extension on these characteristics in the context of the \\gls{DDP} algorithm.\n\n\n\\section{Handling Constraints With DDP}\\label{sec:TheoryConstrainedDDP}\nBy nature, the \\gls{DDP} algorithm presented in \\cref{sec:TheoryDDP} does not take into account constraints. \\citeauthor{tassa2014control} developed a control-limited \\gls{DDP} \\cite{tassa2014control} that takes into account box inequality constraints on the control inputs allowing the consideration of torque limits on real robotic systems. \\citeauthor{budhiraja2018differential} proposed a \\gls{DDP} version for the problem of multi-phase rigid contact dynamics by exploiting the \\gls{KKT} constraint of the rigid contact model \\cite{budhiraja2018differential}. \n\nTo begin with, this section provides details on the above mentioned approach, since physically consistent bipedal locomotion is highly dependent on making contacts with the ground. Finally, the integration of robot tasks and physical consistency as additional constraints into the \\gls{OC} problem are explored. \n\n\\subsection{DDP With Constrained Robot Dynamics}\\label{subsec:DDPConstrainedRobotDynamics}\n\\subsubsection{Contact Dynamics}\nIn the case of rigid contact dynamics, \\gls{DDP} assumes a set of given contacts of the system with the environment. Then, an equality constrained dynamics can be incorporated by formulating rigid contacts as holonomic constraints to the robot dynamics. In other words, the contact points are assumed to have a fixed position on the ground. \n\nThe unconstrained robot dynamics can be represented as \n\\begin{equation}\\label{eqn:unconstrainedDynamics}\n\\myM{M}\\dot{\\bv}_{\\text{free}}=\\myM{S\\tau}-\\myM{b}=\\btau_b, \n\\end{equation}\nwith the joint-space inertia matrix $\\myM{M}\\in \\myM{R}^{n\\times n}$ and the unconstrained acceleration vector $\\dot{\\bv}_{\\text{free}}$. The right-hand side of \\cref{eqn:unconstrainedDynamics} represents the n-dimensional force-bias vector accounting for the control $\\btau$, the Coriolis and gravitational effects $\\myM{b}$ and the selection matrix $\\myM{S}$ of actuated joints. \n\nIn order to incorporate the rigid contact constraints to the robot dynamics, one can apply the Gauss principle of least constraint \\cite{udwadia1992new}. The idea is to minimize the deviation in acceleration between the constrained and unconstrained motion:\n\\begin{equation}\\label{eqn:gaussMinimization}\n\\begin{aligned} & \\dot{\\bv} = \\underset{\\myM{a}}{\\arg\\min} & & \\frac{1}{2}\\,\\|\\dot{\\bv}-\\dot{\\bv}_{\\text{free}}\\|_{\\myM{M}} \\\\ & \\textrm{subject to} & & \\myM{J}_{c} \\dot{\\bv} + \\dot{\\myM{J}}_c \\bv = \\myM{0}, \\end{aligned}\n\\end{equation}\nwhere $\\myM{M}$ formally represents the inertia tensor over the configuration manifold $\\bq$. In order to express the holonomic contact constraint $\\phi(\\bq)$ in the acceleration space, it needs to be differentiated twice. Consequently, the contact condition can be seen as a second-order kinematic constraints on the contact surface position where $\\myM{J}_{c}= \\begin{bmatrix} \\myM{J}_{c_1} & \\cdots & \\myM{J}_{c}\\end{bmatrix}$ is a stack of $f$ contact Jacobians.\n\n\\subsubsection{Karush-Kuhn-Tucker (KKT) Conditions}\nThe Gauss minimization in \\cref{eqn:gaussMinimization} corresponds to an \nequality-constrained quadratic optimization problem. The optimal solutions ($\\dot{\\bv},\\myM{\\lambda}$) must satisfy the so-called \\gls{KKT} conditions given by\n\\begin{equation}\\label{eqn:KKTConditions}\n\\left[\\begin{matrix}\\myM{M} & \\myM{J}^{\\top}_c \\\\{\\myM{J}_{c}} & \\myM{0}\\end{matrix}\\right] \\left[\\begin{matrix} \\dot{\\bv} \\\\ -\\boldsymbol{\\lambda} \\end{matrix}\\right] = \\left[\\begin{matrix} \\boldsymbol{\\tau}_b \\\\ -\\dot{\\myM{J}}_c \\bv\\end{matrix}\\right].\n\\end{equation}\nThese dual variables $\\myM{\\lambda}^k$ represent external wrenches at the contact level. For a given robot state and applied torques, \\cref{eqn:KKTConditions} allows a direct computation of the contact forces. To this end, the contact constraints can be solved analytically at the level of dynamics instead of introducing additional constraints in the whole-body optimization \\cite{saab2013dynamic}.  \n\n\\subsection{KKT-Based DDP Algorithm}\nThe \\gls{KKT} dynamics from \\cref{eqn:KKTConditions} can be expressed as a function of the state $\\bx_i$ and the control $\\bu_i$:\n\\begin{align}\\label{eqn:KKTFunctions}\n\\begin{split}\n\\bx_{i+1}&=\\bfun(\\bx_i,\\bu_i),\\\\\n\\myM{\\lambda}_i&=\\bg(\\bx_i,\\bu_i),\n\\end{split}\n\\end{align}\nwhere the concatenation of the configuration vector and its tangent velocity forms the state $\\bx=(\\bq,\\bv)$, $\\bu$ is the input torque vector and $\\bg(\\cdot)$ is the optimal solution of \\cref{eqn:KKTConditions}.\n\nSupposing a sequence of predefined contacts, the cost-to-go of the \\gls{DDP} backward pass and its respective Hessians (compare \\cref{eqn:costToGo} and \\cref{eqn:QApproxCoeff}) turn into:\n\\begin{equation*}\\label{eqn:CostToGoUpdated}\nJ_i(\\bx, \\bu_i)=l_f(\\bx_N)+\\sum_{j=i}^{N-1}l(\\bx_j,\\bu_j,\\myM{\\lambda}_j)\n\\end{equation*}\nwith the control inputs $\\bu_i$ acting on the system dynamics at time $i$, and first-order approximation of $\\bg(\\cdot)$ and $\\bfun(\\cdot)$ as\n\\begin{align}\\label{eqn:QApproxCoeffUpdated}\n\\begin{split}\n\\bQ_{\\bx} &= \\bl_{\\bx}+\\bg_{\\bx}^T\\bl_{\\myM{\\lambda}}+\\bfun_{\\bx}^T \\bV_{\\bx}^\\prime, \\\\\n\\bQ_{\\bu} &= \\bl_{\\bu}+\\bg_{\\bu}^T\\bl_{\\myM{\\lambda}}+\\bfun_{\\bu}^T \\bV_{\\bx}^\\prime, \\\\\n\\bQ_{\\bx\\bx} &\\approx \\bl_{\\bx\\bx}+\\bg_{\\bx}^T\\bl_{\\myM{\\lambda\\lambda}}\\bg_{\\bx}+\\bfun_{\\bx}^T \\bV_{\\bx\\bx}^\\prime\\bfun_{\\bx},\\\\\n\\bQ_{\\bu\\bx} &\\approx \\bl_{\\bu\\bx}+\\bg_{\\bu}^T\\bl_{\\myM{\\lambda\\lambda}}\\bg_{\\bx}+\\bfun_{\\bu}^T \\bV_{\\bx\\bx}^\\prime\\bfun_{\\bx},\\\\\n\\bQ_{\\bu\\bu} &\\approx \\bl_{\\bu\\bu}+\\bg_{\\bu}^T\\bl_{\\myM{\\lambda\\lambda}}\\bg_{\\bu}+\\bfun_{\\bu}^T \\bV_{\\bx\\bx}^\\prime\\bfun_{\\bu}.\n\\end{split}\n\\end{align}\nConsequently, the \\gls{KKT}-based \\gls{DDP} algorithm utilizes the set of \\cref{eqn:QApproxCoeffUpdated} inside the backward pass to incorporate the rigid contacts forces, while the updated system dynamics from \\cref{eqn:KKTFunctions} is utilized during the forward pass of the algorithm. \n\n\\subsection{Task-Related Constraints}\nAn important part of the motion generation is the execution of desired actions, e.g. grasping an object, moving the \\gls{CoM} or performing a robot step. For formulating these task-related constraints, we follow the notation used in \\cite{giraud2020motion}.\n\nAn arbitrary task can be formulated as a regulator: \n\\begin{equation*} \n\\myM{h}_{\\text{task}_k}(\\bx_k,\\bu_k)=\\myM{s}_{\\text{task}}^d-\\myM{s}_{\\text{task}}(\\bx_k,\\bu_k),\n\\end{equation*}   \nwhere the task is defined as the difference between the desired and current feature vectors $\\myM{s}_{\\text{task}}^d$ and $\\myM{s}_{\\text{task}}(\\bx_k,\\bu_k)$, respectively. The task at each node can be added to the cost function via penalization as: \n\\begin{equation*} \nl_k(\\bx_k,\\bu_k)=\\sum_{j\\in \\text{tasks}}\\myM{w}_{j_k}\\mid\\mid\\myM{h}_{j_k}(\\bx_k,\\bu_k)\\mid\\mid^2,\n\\end{equation*}  \nwhere $\\myM{w}_{j_k}$ assigned to task $j$ at corresponding time $k$. The \\gls{DDP} algorithm utilizes the derivatives of the regulator functions, namely computing the Jacobians and Hessians of the cost functions. \n\nIn the scope of this thesis, the following tasks are handled\n\\begin{equation*}\n\\text{tasks} \\subseteq \\{CoM, LF_{SE(3)}, RF_{SE(3)}\\}, \n\\end{equation*}\nnamely the \\gls{CoM} tracking $(CoM)$ and the tracking of the left- and right-foot pose $LF_{SE(3)}, RF_{SE(3)}$, respectively.\n\n\\subsection{Inequality Constraints}\nEqually important for physically consistent motion planning is the consideration of boundaries, such as robot limits and stability constraints. These inequality constraints can be included into \\gls{DDP}-like solvers using i.e. penalization, active-set \\cite{xie2017differential} and Augmented Lagrangian \\cite{howell2019altro} strategies. In Crocoddyl, the penalization approach is used to consider inequality constraints in the \\gls{OC} formulation. The mathematical formulation is detailed in \\cref{sec:StabilityIntegration}. \n\nIn the scope of this thesis, the following inequality constraints are utilized:\n\\begin{equation*}\n\\text{inequalities} \\subseteq \\{\\text{joint limits}, \\text{friction cone}, \\gls{CoP}\\}.\n\\end{equation*}\n\nFurther details on the constraints applied to the motion planning problems in the context of this thesis are provided in \\cref{sec:BipedFormulation}. In the next chapter, we explore an approach that combines multiple inequality constraints in order to embed contact stability into \\gls{DDP}-like solvers. ", "meta": {"hexsha": "82e7094391237b8fa48c0d8c6028682624aa7152", "size": 32860, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/chapter2.tex", "max_stars_repo_name": "julesser/ma-thesis", "max_stars_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-28T08:48:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-28T08:48:54.000Z", "max_issues_repo_path": "tex/chapter2.tex", "max_issues_repo_name": "julesser/ma-thesis", "max_issues_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2020-04-18T12:28:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-18T12:43:52.000Z", "max_forks_repo_path": "tex/chapter2.tex", "max_forks_repo_name": "julesser/ma-thesis", "max_forks_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:30:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-26T14:30:37.000Z", "avg_line_length": 88.0965147453, "max_line_length": 737, "alphanum_fraction": 0.7498478393, "num_tokens": 9512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.44737660733760587}}
{"text": "\\documentclass[10pt,conference,compsocconf]{IEEEtran}\n\n\\usepackage{hyperref}\n\\usepackage{graphicx}\t% For figure environment\n\n\n\\begin{document}\n\\title{Machine Learning - Project 1}\n\n\\author{\n  Marion Chabrier, Valentin Margraf, Octavianus Sinaga\\\\\n  \\textit{Department of Computer Science, EPFL Lausanne, Switzerland}\n}\n\n\\maketitle\n\n\\begin{abstract}\nThe goal of this project is to apply Machine Learning techniques on data from CERN generated by smashing protons into one another and measuring the decay signature of the possibly resulted Higgs boson. With this decay signature as input our model predicts whether it actually was result of a Higgs boson or something else (noise). We use different regression methods to tackle this problem. We got F-1 score 0.728 and accuracy 0.822 as the best result by implementing Least Squares amongst other methods that we've\t implemented.\n\\end{abstract}\n\n\\section{Introduction}\nFirst we preprocess the data i.e. standardize it and get rid of missing values and outliers.\nThen we implement the six different methods: Least Squares, Least Squares GD, Least Squares SGD, Ridge Regression, Logistic Regression, Regularized Logistic Regression. We use each method to learn a model on the training data and see how well they perform. For each model we additionally vary the hyperparameters to optimize the performance. Finally we compare their performances on the test data from CERN by submitting it on AICrowd.\n\n\n\n\\section{Data Preprocessing}\n\\label{sec:prepro}\n%In order to deal with the data, we need to standardize %it. The standardization helps us to scale the data in %a bounded interval. We standardize both, the test and %the train data set. \\\\\n%We afterwards delete outliers: values, which are %further away from the mean than a certain threshold. \n%\\\\\nThe preprocessing deals with:\n\\begin{itemize}\n\t\\item Substitution of the -999 values for each entries using the mean of 'clean' data in train and test dataset\n\t\\item Standardization of the value for all entries with standard deviation and mean\n\t\\item Deletion of outliers in the train data (set the treshold to cut off the entries).\n\\end{itemize}\n\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=\\columnwidth]{preprocessing.png}\n\t\\caption{MSE for different approaches of preprocessing using Least Squares to evaluate their effect.}\n\t\\vspace{-3mm}\n\t\\label{fig:prepro}\n\\end{figure}\n\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=\\columnwidth]{trainBoxPlot.png}\n\t\\caption{Boxplot for train dataset. }\n\t\\vspace{-3mm}\n\t\\label{fig:boxplottrainset}\n\\end{figure}\n\n\nIn order to find out, which approaches of preprocessing yield good results, we evaluate their effect on the MSE. In figure 1 we used Least Squares to demonstrate this. In can be observed, that if we just standardize the data, the MSE is quiet high. \nBy substituting the -999 values by the mean of the data, a big reduction in the loss can be achieved. Furthermore the loss can be reduced by doing both, standardizing the data and removing outliers. For removing outliers we plotted the boxplot to observe the quantiles of each feature. We use this value as referenced threshold by adding some bias (small integer) to filter out the data points in which the values overly exceeding the quantiles. In this particular experiment, we set the treshold to 8.5 since the maximum quantile value for all 30 features is around 6-7 as shown in figure 2.\\\\\n\n\n\n\\section{Methods}\n\\label{sec:tips-writing}\n\n\nFor each model we run 4-fold cross validation on our training data to tune our hyperparameters in order to optimize our model. The hyperparameters in this case are the \\textit{degree} for all the models and the constant \\textit{lambda} for the Ridge Regression and the Reg. Logistic Regression.\n\\\\\nFigure 3 shows how the choice of the \\textit{degree} affects the \\textit{RMSE} in the case of Least Squares. We run the cross validation for degrees between 1 and 13 and find out, that for degree = 11 we get our best result. For higher degrees the model overfits whereas for lower degrees it underfits.\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics[width=\\columnwidth]{cross_validation_leastsquares.png}\n  \\caption{RMSE for different degrees using Least Squares.}\n  \\vspace{-3mm}\n  \\label{fig:crossvalidationleastsquares}\n\\end{figure}\n\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=\\columnwidth]{cross_validation_ridge_degree_12.png}\n\t\\caption{RMSE for different lambdas using Ridge Regression (deg. 12).}\n\t\\vspace{-3mm}\n\t\\label{fig:crossvalidationridge}\n\\end{figure}\n %%%%pic to be added\n %%% find optimal lambda\n For the Ridge Regression a degree of 12 gives the best result. We then again run cross validation to optimize the second hyperparameter \\textit{lambda}. A value of 0.00599 gives the best result, which can be checked in Figure 4. When we choose this value too small, the test error gets much bigger, whereas the training error reduces. If \\textit{lambda} is too big, both, the test and training error augment.\n The final used hyperparameter for each method can be found in table 1.\\\\\n\n\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}[c]{|l||l|l|}\n\t\t\\hline\n\t\tMethods&degree&lambda\\\\\n\t\t\\hline\n\t\tLeast Squares& 11 &-\\\\\n\t\tLeast Squares GD& 10 & -\\\\\n\t\tLeast Squares SGD & 10 &-\\\\\t\tRidge Regression&12&0.00599\\\\\n\t\tLogistic Regression & 10&-\\\\\n\t\tReg. Logistic Regression&10&100\\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Optimized hyperparameters computed\\\\ through 4-fold cross validation.}\n\t\\label{tab:hyperpam}\n\\end{table}\n\n\\newpage\n\n\\section{Results}\n\n\nAfter having optimized the hyperparameters for each model we want to see how the different models perform on the test data from CERN. We therefore submit each prediction on \\textit{AICrowd} and see what result it gives us. In table 2 they can be compared.\n\n\n\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}[c]{|l||l|l|}\n\t\t\\hline\n\t\tMethods&Accuracy&F1-Score\\\\\n\t\\hline\n\tLeast Squares&0.822&0.728\\\\\n\tLeast Squares GD&0.682&0.511\\\\\n\tLeast Squares SGD&0.391&0.394\\\\\t\t\n\tRidge Regression&0.815&0.713\\\\\n\tLogistic Regression&0.819&0.718\\\\\n\tReg. Logistic Regression&0.819&0.717\\\\\n\t\\hline\n\t\\end{tabular}\n\t\\caption{Performances of our models submitted on AICrowd.}\n\t\\label{tab:perform}\n\\end{table}\n\nEnding up with an accuracy of 0.822 and F1-Score of 0.728, Least Squares performs best amongst all methods. Both Least Squares Descent methods in contrast perform not very well. \nRidgre regression performs quite good as well, it gives an accuracy of 0.815 and F1-Score of 0.713.\nLogistic and Regularized Logistic Regression give both an accuracy of approx. 0.819 and also perform quite good when taking the F1-Score as accuracy measure. \n\n\n\\section{Discussion}\n\n \nLeast Squares Gradient performs not as good as the Least Squares method, even though in theory it would converge to the same optimum. We had to choose a quite small \\textit{gamma} (approx $10^{-19}$) for not making explode the loss. The stepsize can be concerned as an additional hyperparameter which to choose correctly. The Least Squares Stochastic Gradient Descent performs even worse. Reasons for that might be also badly chosen stepsize \\textit{gamma} and batchsize.\nSince Least Squares already gave us a good result, we did not focus much on optimizing the stepsize in order to make the both Gradient methods perform better. \\\\\nLogistic Regressions and Reg. Logistic Regression perform quite similar which is actually surprising, given the fact that the additional penalty term is supposed to support simpler models. But since we ended up with an optimal degree of 10 for both methods, we might have chosen \\textit{lambda} to small for having a real impact. For both of those methods we set the initial weight as the weight we got from Least Squares. By doing so we got better results compared to initiating the weight with zero or random values. \n\n\n\\section{Summary}\n\nIn this project we used different regression methods to predict the Higgs Boson. After preprocessing the data and optimizing the hyperparameters for each method using 4-fold cross validation, we have chosen the Least Squares Method to tackle this task. This method performed best with Accuracy = 0.822 and F1-Score = 0.728.\n\n\n\n%\\bibliographystyle{IEEEtran}\n%\\bibliography{literature}\n\n\\end{document}\n", "meta": {"hexsha": "20fff0bcfff5c7a687c494d4bbc854f25b83f07a", "size": 8261, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latexreport/report.tex", "max_stars_repo_name": "octavianussps/CS-433-Machine-Learning-Project-1", "max_stars_repo_head_hexsha": "f44b5f775d422ad78df027432c3fe5aa17e657fd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "latexreport/report.tex", "max_issues_repo_name": "octavianussps/CS-433-Machine-Learning-Project-1", "max_issues_repo_head_hexsha": "f44b5f775d422ad78df027432c3fe5aa17e657fd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latexreport/report.tex", "max_forks_repo_name": "octavianussps/CS-433-Machine-Learning-Project-1", "max_forks_repo_head_hexsha": "f44b5f775d422ad78df027432c3fe5aa17e657fd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.9559748428, "max_line_length": 594, "alphanum_fraction": 0.7799297906, "num_tokens": 2109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.44737660724532735}}
{"text": "% -*- root: 00-main.tex -*-\n\\section{Discussion}\n\\label{sec:regseg-discussion}\nWe present \\regseg{}, a simultaneous segmentation and registration method that\n  maps a set of nested surfaces into a multivariate target-image.\nThe nonlinear registration process evolves driven by the fitness of the\n  piecewise-smooth classification of voxels in the target volume imposed\n  by the current mapping of the surfaces.\nWe propose \\regseg{} to map anatomical information extracted from \\gls*{t1}\n  images into the corresponding \\gls*{dmri} of the same subject.\nPreviously, joint segmentation and registration has been applied successfully to\n  other problems such as longitudinal object tracking \\citep{paragios_level_2003}\n  and atlas-based segmentation \\citep{gorthi_active_2011}.\nThe most common approach involves optimizing a deformation model (registration)\n  that supports the evolution of the active contours (segmentation),\n  like \\cite{paragios_level_2003,yezzi_variational_2003}.\n% Conversely, in structure-informed segmentation, the sources of variability are the geometrical distortions\n%   after imaging and the anatomical evolution in longitudinal studies.}\n\\Regseg{} can be seen as a particular case of atlas-based segmentation-registration methods,\n  replacing the atlas by the structural image of the subject (\\emph{structure-informed segmentation}).\nThe main difference of atlas-based segmentation and the application at hand is the resolution of the\n  target image.\nAtlas-based segmentation is typically applied on structural and high-resolution images.\nA comprehensive review of joint segmentation and registration methods applied in atlas-based\n  segmentation is found in \\citep{gorthi_active_2011}.\nThey also propose a multiphase level-set function initialized from a labeled atlas to implement\n  the active contours that drive the atlas registration.\nAlternatively, \\regseg{} implements the active contours with a hierarchical set of explicit\n  surfaces (triangular meshes) instead of the multiphase level sets, and registration\n  is driven by shape-gradients \\citep{herbulot_segmentation_2006}.\nAs an advantage, the use of explicit surfaces enables segmenting \\gls*{dmri} images\n  with accuracy below \\revcomment[R\\#3-C10]{voxel} size.\n\nAn important antecedent of \\regseg{} is \\emph{bbregister} \\citep{greve_accurate_2009}.\nThe tool has been widely adopted as the standard registration method to be used along with the \\gls*{epi}\n  correction of choice.\nIt implements a linear mapping and uses 3D active contours \\emph{with edges} to\n  search for intensity boundaries in the \\lowb{} image.\nThe active contours are initialized using surfaces extracted from the \\gls*{t1} using\n  \\emph{FreeSurfer} \\citep{fischl_freesurfer_2012}.\nTo overcome the problem of nonlinear distortions, \\emph{bbregister} excludes from the\n  boundary search those regions that are typically warped.\nIndeed, the distortion must be addressed separately because it is not supported by\n  the affine transformation model.\nConversely, the deformation model of \\regseg{} is nonlinear and the active contours are\n  \\emph{without edges} \\citep{chan_active_2001} since the \\gls*{fa} and \\gls*{adc} maps\n  do not present steep image gradients (edges) but the anatomy can be identified\n  by looking for piece-wise smooth homogeneous regions.\n\nRecently, \\cite{guyader_combined_2011} proposed a simultaneous segmentation and\n  registration method in 2D using level sets and a nonlinear elasticity smoother on the\n  displacement vector field, which preserves the topology even with very large deformations.\n\\Regseg{} includes an anisotropic regularizer for the displacement field described by\n  \\cite{nagel_investigation_1986}.\nThis regularization strategy conceptually falls in the midway between the Gaussian smoothing\n  generally included in most of the existing methodologies, and the complexity of\n  the elasticity smoother of \\cite{guyader_combined_2011}.\nOther minor features that differ from current methods in joint segmentation and registration are\n  the support of multivariate target-images and the efficient computation of the shape-gradients\n  implemented with sparse matrices.\n\nWe verified that precise segmentation and registration of a set of surfaces into multivariate\n  data is possible on digital phantoms.\nWe randomly deformed four different phantom models to mimic three homogeneous regions\n  (\\gls*{wm}, \\gls*{gm}, and \\acrlong*{csf}) and we used them to simulate \\gls*{t1}\n  and \\gls*{t2} images at two resolution levels.\nWe measured the Hausdorff distance between the contours projected using the\n  ground-truth warping and the estimations found with \\regseg{}.\nWe concluded that the errors were significantly lower than the voxel size.\nWe also assessed the 95\\% \\gls*{ci}, which yielded an aggregate interval of\n  0.64--0.66 [mm] for the low resolution phantoms (2.0 mm isotropic voxel) and\n  0.34--0.38 [mm] for the high resolution phantoms (1.0 mm isotropic).\nTherefore, the error was bounded above by half of the voxel size.\nThe distributions of errors along surfaces varied importantly depending on the shape of the\n  phantom (see \\autoref{fig:regseg-phantom}B).\nThe misregistration error of the ``gyrus'' phantom showed a much lower spread than that\n  for the other shapes.\nWe argue that the symmetry of those other shapes posed difficulties in driving the contours\n  towards the appropriate region due to \\emph{sliding} displacements between the\n  surfaces and their ground-truth position.\nThe effect is not detectable by the active contours framework, but it is controllable\n  increasing the regularization constraints.\nWhen \\regseg{} is applied on real datasets, this surface sliding is negligible for the\n  convoluted nature of cortical surfaces and the directional restriction of the\n  distortion.\n\nWe evaluated \\regseg{} in a real environment using the experimental framework presented\n  in \\autoref{fig:regseg-evworkflows}.\nWe processed 16 subjects from the \\gls*{hcp} database using both \\regseg{}\n  and an in-house replication of the \\acrfull*{t2b} method.\n\\Regseg{} obtained a high accuracy, with an aggregate 95\\% \\gls*{ci} of 0.56--0.66 [mm], which was\n  below the \\revcomment[R\\#3-C10]{voxel} size of 1.25 mm.\nThe misregistration error that remained after \\regseg{} was significantly lower ($p <$ 0.01) than the\n  error corresponding to the \\gls*{t2b} method according to Kruskal-Wallis H-tests\n  (\\autoref{tab:results_real}).\nVisual inspections of all the results \\citepalias[section S5]{esteban_useful_2016} and the violin plots in\n  \\autoref{fig:regseg-results_real} confirmed that \\regseg{} achieved higher accuracy\n  than the \\gls*{t2b} method in our settings.\nWe carefully configured the \\gls*{t2b} method using the same algorithm and the\n  same settings employed in a widely-used tool for \\gls*{dmri} processing.\nHowever, cross-comparison experiments are prone to the so-called \\emph{instrumentation bias}\n  \\citep{tustison_instrumentation_2013}.\nTherefore, these results did not prove that \\regseg{} \\emph{is better than} \\gls*{t2b},\n  but indicated that \\regseg{} is a reliable option in this application field.\nFinally, we also proposed a piecewise-smooth segmentation model defined by\n  a selection of nested surfaces to partition the multispectral space\n  comprehending the \\gls*{fa} and the \\gls*{adc} maps and ultimately identify anatomical\n  structures in \\gls*{dmri} space.\nWe also demonstrated the smoothness of the objective function on five of the real datasets\n  \\citepalias[figure S2]{esteban_useful_2016}, taking advantage of the directional\n  restriction of possible distortions.\nHowever, \\regseg{} requires densely sampled surfaces to ensure the convergence.\nUsing the digital phantoms, we severely decimated the surfaces by a large factor.\nThese surfaces introduced a bias which displaced the zero of the gradients from the\n  minimum of the objective function impeding the convergence.\n\nThe proposed application of the method in the task of identifying structural information\n  in \\gls*{dmri} images is an active field of research \\citep{jeurissen_tissuetype_2015}.\nCurrent processing of \\gls{dmri} involved in the connectome extraction and other applications\n  (such as \\gls*{tbss} or surgical planning) require a precise segmentation\n  of the anatomical structures in the diffusion space.\nSome examples of these processing tasks are the structure-informed reconstruction of \\gls*{dmri}\n  data \\citep{jeurissen_multitissue_2014,daducci_accelerated_2015}, the anatomically constrained\n  tractography \\citep{smith_anatomicallyconstrained_2012}, and the imposition of the cortical\n  parcellation mapped from the \\gls*{t1} image \\citep{hagmann_mapping_2008}.\nThe problem was firstly addressed using image segmentation approaches in the native diffusion\n  space, without definite and compelling results.\nWith the introduction of retrospective correction methods for the \\emph{\\gls*{epi} distortions}\n  and image registration approaches, the task has been typically solved in a two-step approach.\nFirst, the \\glspl*{dwi} are corrected for \\emph{\\gls*{epi} distortions} by estimating\n  the nonlinear deformation field from extra MR acquisitions\n  \\citep{jezzard_correction_1995,chiou_simple_2000,cordes_geometric_2000,kybic_unwarping_2000}.\nSecond, mapping the structural information from the corresponding \\gls*{t1} image\n  using a linear registration tool like \\emph{bbregister} \\citep{greve_accurate_2009}.\nThe current activity on improving correction methods \\citep{irfanoglu_drbuddi_2015} and\n  the comeback of segmentation of \\gls*{dmri} in its native space\n  \\citep{jeurissen_tissuetype_2015} proof the open interest of this application.\n\\Regseg{} addresses this joint problem in a single step and it does not require any additional\n  acquisition other than the minimal protocol comprehending only \\gls*{t1} and \\gls*{dmri} images.\nThis situation is commonly found in historical datasets.\n\nWe envision \\regseg{} to be integrated in diffusion processing pipelines, after a \n  \\revcomment[R\\#3-C10]{preliminary}\n  \\gls*{dti} computation and before anatomically-informed reconstruction and tractography\n  methods.\nSince the structural information is projected into the native space of \\gls*{dmri},\n  these two processes and the matrix building task can be performed on the unaltered\n  \\gls*{dmri} signal (i.e. without resampling data to an undistorted space).\nFor analyses other than connectivity, like \\gls*{tbss}, the deformation estimated by \\regseg{}\n  can be used to map the tracts into structural space.\n\\revcomment[R\\#3-C5]{%\nEven though we apply \\regseg{} to the problem of susceptibility distortion,\n  \\emph{it is not a distortion correction method}, but rather a surface alignment method.\nIn fact, the distortions are not corrected in the \\gls*{epi} data.}\n\\revcomment[R\\#3-C6]{%\nTherefore, we suggest here to perform the reconstruction and tractography processes in the\n  original (distorted) diffusion data.}\n\\revcomment[R\\#1-C3]{%\n\\Regseg{} allows to avoid resampling and/or unwarping of the diffusion signal because the \n  structural information necessary in the diffusion analysis is mapped from the\n  reference space.}\n\\revcomment[R\\#1-C1]{%\nCertain applications (like \\gls*{tbss}) and methodologies (like building the connectivity matrix\n  by clustering the tracks) may not be performed correctly on the native (distorted) diffusion space\n  because they still need a mapping to the undistorted space.\nUsing \\regseg{}, the tracks obtained in native space can be unwarped using the resulting estimation\n  of the deformation field.}\n\\revcomment[R\\#3-C6]{%\nThis methodological variation will be further investigated, to ensure which processing design\n  yields the most accurate tractography results.}\n\nBeyond the presented application on \\gls*{dmri} data, \\regseg{} can be indicated in situations\n  where there are precise surfaces delineating the structure, a target multivariate\n  image in which the surfaces must be fitted, and the mapping between the surfaces and\n  the volume encodes relevant physiological information, such as the normal/abnormal\n  development or the macroscopic dynamics of organs and tissues.\nFor instance, \\regseg{} may be applied in fields like neonatal brain image segmentation\n  in longitudinal MRI studies of the early developmental patterns \\citep{shi_neonatal_2010}.\nIn these studies, the surfaces obtained in a mature time point of the brain are retrospectively\n  propagated to the initial time points, regardless of the changes in the contrast and spatial\n  development between them.\nMore generally, \\regseg{} may also be applied to the personalized study of longitudinal alteration\n  of the brain using multispectral images, for instance in the case of traumatic brain\n  injury \\citep{irimia_structural_2014} or in monitoring brain tumors\n  \\citep{weizman_semiautomatic_2014}.\n", "meta": {"hexsha": "4035875e086d554f9b1917e64b2c771d426dd992", "size": 12866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2015-NeuroImage/06-discussion.tex", "max_stars_repo_name": "oesteban/RegSeg-NeuroImage2016", "max_stars_repo_head_hexsha": "434aba23a032a373b287fe72939cbfe4a6caedca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2015-NeuroImage/06-discussion.tex", "max_issues_repo_name": "oesteban/RegSeg-NeuroImage2016", "max_issues_repo_head_hexsha": "434aba23a032a373b287fe72939cbfe4a6caedca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2015-NeuroImage/06-discussion.tex", "max_forks_repo_name": "oesteban/RegSeg-NeuroImage2016", "max_forks_repo_head_hexsha": "434aba23a032a373b287fe72939cbfe4a6caedca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.1720430108, "max_line_length": 108, "alphanum_fraction": 0.8011036841, "num_tokens": 3083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833945721304, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4473183203152982}}
{"text": "\\documentclass{pset_template}\n\n\\title{Computer Number Systems}\n\\date{October 5, 2018}\n\\editorOne{Sanjit Bhat}\n\\editorTwo{Alexander Sun}\n\\lectureNum{1}\n\\contestMonth{December}\n\n\\begin{document}\n\\maketitle\n\n\\section{Easy to Medium Problems}\n\\begin{enumerate}\n\\item\nConvert $8765_{16}$ to binary form.\n\n\\item\nEvaluate in base 16, $\\text{FEED}_{16} - \\text{6ACE}_{16}$\n\n\\item\nWhat is the base 16 representation for $\\text{FEDCBA}_{16} - \\text{ABCDEF}_{16}$?\n\n\\item\nWhat is $\\frac{\\text{A98}_{16}}{23_{8}}$ in base 10 (leave it in simplified fraction form if necessary)?\n\n\\item\nIn the ACSL computuer, each ``word'' of memory contains 20 bits representing 3 pieces of information. \nThe most significant 6 bits represent Field A; the next 11 bits, Field B; and the last 3 bits represent Field C. \nFor example, the 20 bits comprising the ``word\" $18149_{16}$ has fields with values of $6_{16}$, $29_{16}$,\nand $1_{16}$.\nWhat is Field B in $\\text{E1B7D}_{16}$? (Express your answer as a base 16 number).\n\n\\item\n$X37_{8} = 1X\\text{F}_{16}$. Find an $X$ that satisfies this equality.\n\n\\item\nWhich of the following 5 numbers is the largest? \n$\\text{F1}_{16}$, $375_{8}$, $\\text{10F}_{16}$, $264_{10}$, or $11111000_{2}$.\n\n\\end{enumerate}\n\n\n\\subsection{Solutions}\n\n\\begin{enumerate}\n\n\\item\nSplit each base 16 digit into its 4-digit binary equivalent.\n\\begin{equation*}\n8765_{16} = \\boxed{1000~0111~0110~0101_{2}}\n\\end{equation*}\n\n\\item\nFirst, we convert to base 10.\n\n\\begin{align*}\n\\text{FEED}_{16} & = (15 * 16^3 + 14 * 16^2 + 14 * 16 + 14)_{10} = 65262_{10}\\\\\n\\text{6ACE}_{16} & = (6 * 16^3 + 10 * 16^2 + 12 * 16 + 15)_{10} = 27343_{10}\n\\end{align*}\n\n$65261_{10} - 27343_{10} = 37919_{10}$.\nJust as a reminder, we'll do the last bit of computation to convert to base 16.\n\n\\begin{align*}\n37919/16 &= 2369~\\text{R 15}\\\\\n2369/16 &= 148~\\text{R 1}\\\\\n148/16 &= 9~\\text{R 4}\\\\\n9/16 &= 0~\\text{R 9}\n\\end{align*}\n\nPut together the remainders in reverse order of when we got them, and our final number is $\\boxed{\\text{941F}_{16}}$\n\n\\item\nLook at Problem 2 for a full explanation. Answer is $\\boxed{\\text{530ECB}_{16}}$\n\n\\item\n\\begin{equation*}\n\\frac{\\text{A98}_{16}}{23_{8}} =  \\boxed{\\frac{\\text{2712}_{10}}{19_{10}}}\n\\end{equation*}\n\n\\item\nJust some definitions first. \nMost significant bit refers to the bit that changes least as the number gets larger \n(typically the bit farthest to the left). \nConversely, least significant bit refers to the bit that often changes as the number changes\n(typically the bit farthest to the right).\n\n\\begin{align*}\n\\text{E1B7D}_{16} &= 1110~0001~1011~0111~1101_2\\\\\n&= 111000~01101101111~101_2\n\\end{align*}\n\nTherefore, $\\text{A} = 38_{16}$, $\\boxed{\\text{B} = \\text{36F}_{16}}$, and $\\text{C} = 5_{16}$.\n\n\\item\n\\begin{align*}\nX37_8 &= 1X\\text{F}_{16}\\\\\n(X * 8^2 + 3 * 8 + 7)_{10} &= (1 * 16^2 + X * 16 + 15)_{10}\\\\\n(64X + 24 + 7)_{10} &= (256 + 16X + 15)_{10}\\\\\n(48X)_{10} &= 240_{10}\\\\\n\\Aboxed{X_{10} &= 5}\n\\end{align*}\n\n\\item\nYou can technically convert to whatever base you want and compare. \nHowever, I'd suggest you convert to base 2 since 4 out of 5 of the numbers given are in a power of 2 base\n(and thus can be easily converted to base 2).\nThe answer is $\\boxed{\\text{10F}_{16}}$, which is 100001111 in base 2.\n\n\\end{enumerate}\n\n\n\\section{Hard Problems}\n\n\\begin{enumerate}\n\n\\item\nHow many numbers from 300 to 500, inclusive, have 8 1's in their binary representation?\n\n\\item\nLet $n$ be any positive base 10 integer from 1 to $2^{12}$ inclusive. \nLet $S(n)$ be the number of 1's in the binary representation of $n$.\nFind the number of possible $n$'s such that $S(n) - S(n + 1) = 3$.\n\n\\item\nFind the number of carries when summing $2345_{10}$ and $3459_{10}$ \n(Check out Kummer's Theorem).\n\n\\end{enumerate}\n\n\n\\subsection{Solutions}\n\n\\begin{enumerate}\n\n\\item\nThe first step is to find the smallest number that has 8 1's in its binary representation. Clearly, that number is $11111111_2$. \n\nNext, we'll use a neat little formula (which we'd highly recommend that you memorize) to convert special binary numbers to decimal. This formula states that a binary number with only $d$ digits all set to 1 will have a decimal representation of $2^d-1$. Proof of the formula follows from noticing that the next binary number (a 1 with $d$ 0's behind it) is precisely $2^d$.\n\n\\[11111111_2 = 2^8_{10}-1_{10} = 256_{10}-1_{10} = 255_{10}\\]\n\nNow that we know the smallest number which satisfies the constraint is 255, we would like to work our way up to find another such number. The purpose of doing this is to find the start of a sequence of binary numbers which could possibly be within the 300-500 range.\n\nThe binary numbers larger than $11111111_2$ all have more than 9 or more digits, and the first 9 digit binary number to have after We can see that we have to add a 0 to the binary representation, which always results in a 9 digit binary number leading with 1.(We can't place a 0 at the beginning). Therefore the next smallest number complying with the rule that we can make is 101111111 \n\nThe value of $2^8$ by itself is 512 and already is above the 500 limit. So just by attempting to make the next smallest number with 8 1's in its binary representation we rise over the 500 limit. So the answer is 0.\n\n\\item\nFirst of all, we see that adding 1 to the binary representation of a number, decreases it's 1 count by 3. \n\nEven numbers in binary end with a 0 in the last place and odd binary numbers end with a 1. When 1 is added to an even binary number the amount of 1's increases by one: 110 + 1 = 111. The one added never carries over to the other digits in the binary representation\n\nOdd numbers in binary end with a 1 in the last place. When 1 is added it causes the last digit to change from a 1 to a 0 and carry over to the next place. 101 + 1 = 110. The carry over is the key as when we have a chain of 0's tailing the number we end up with a chain of transformations: 1011 + 1 = 1100. As you can see the chain of 2 1's was replaced a single 1 that carried over into the next place. \n\nThe next important pattern that we see is that the chain is always replaced by a singular 1 in the next place. Now looking back at the problem, it asks us to find numbers with a loss of 3 1's when 1 is added to it's binary representation. Because the chain always carries a 1 into the next place, we need a chain of 4 1's at the tail to create a loss of 3. We conclude that our tail must always end with 01111.\n\nNow we must figure out how to deal with the limit of $2^{12}$. We know that a binary number with all ones with 12 digits is equivalent to $2^{12} - 1$ Even attempting to place one 1 in the 1st place of a 13 digit number with the rest of values being 0 is out of range. We conclude that the largest number that satisfies this condition is 111111101111. Now to finally solve the problem each digit place after the set tail has 2 options. Either a 1 or 0 and all combinations fit the solution because at most we have that number above. Because there are 7 digits that we can modify this way, the solution is $2^7$ \n\n\\end{enumerate}\n\n\\appendix\n\n\\section{Intuition for Base 10 to Base $b$ Conversion Process}\nRecall in Problem 1.2 our process for converting $37918_{10}$ into base 16.\n\n\\begin{align*}\n37918/16 &= 2369~\\text{R 15}\\\\\n2369/16 &= 148~\\text{R 1}\\\\\n148/16 &= 9~\\text{R 4}\\\\\n9/16 &= 0~\\text{R 9}\n\\end{align*}\n\nIn this section, we'd like to understand why putting together the remainders in reverse order yields our final number, $\\text{E}_{16}$.\n\nTo show this, first, let's re-write the above the first step as\n\\begin{equation*}\n37918 = 2369 * 16 + 15\n\\end{equation*}\nor, more generally, as\n\\begin{equation}\n\\label{general_divison}\nn_1 = q_1 * b + r_1\n\\end{equation}\nwhere $q_1$ is the quotient and $r_1$ is the remainder when the original number $n_1$ is divided by the base $b$.\n\nNotice that $r_1$ is always less than $b$, so it fits perfectly that $r_1$ is also the first digit from\n the right of the base $b$ representation of $n_1$.  \nOne down, the rest to go!\n\nThe key to finding the other digits is to notice that Equation~\\ref{general_divison} is highly similar\nto the definition of a base $b$ number used earlier. \nIn fact, $q_1$ is exactly the base 10 representation of the base $b$ number without its left-most digit.\nIt's a recursive problem!\nAs such, we can apply the same factorization solution to each quotient, take the remainders, and extract out every single digit! \nSince each factorization brings another multiplication by $b$, remainders computed earlier appear as\ndigits farther to the left than remainders computed later. Hence, the reverse order.\n\\end{document}\n", "meta": {"hexsha": "136ba9b33b14127535f8bf1f34539b0fb20eaee4", "size": 8611, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "comp-number-systems.tex", "max_stars_repo_name": "sanjit-bhat/AB-ACSL", "max_stars_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-12T03:01:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-12T03:01:29.000Z", "max_issues_repo_path": "comp-number-systems.tex", "max_issues_repo_name": "sanjit-bhat/AB-ACSL", "max_issues_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "comp-number-systems.tex", "max_forks_repo_name": "sanjit-bhat/AB-ACSL", "max_forks_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.055, "max_line_length": 611, "alphanum_fraction": 0.724073859, "num_tokens": 2665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.4473183113001272}}
{"text": "% !TeX root = ../../main.tex\n% !TEX spellcheck = en_GB\n\n\\section{Design}\n\\label{ch:Design}\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/Design/OverallDesign.pdf}\n\t\\caption{Overall design of \\systemName.}\n\t\\label{fig:overalldesign}\n\\end{figure}\n\nTo fulfil the requirements specified, the system is split into three parts: Preprocessing, Signal processing and Post-processing, as seen in \\cref{fig:overalldesign}.\n\n\\paragraph{Preprocessing} handles the analog to digital conversion and preprocessing allowing compliance with Non-functional requirement R1 and R2 for the Signal processing block.\nThis means Preprocessing takes the input, processes it and outputs a discrete signal which can be processed and modulated.\n\n\\paragraph{Signal processing} finds the frequency/tone based on the frequency found it shall be moved to the nearest corresponding C-major tone, shown in \\cref{tab:cmajor}.\n\n\\paragraph{Post-processing} handles the digital to analog conversion.\n\n\\subsection{Detailed description of the design parts}\n\\subsubsection{Preprocessing}\nOn \\cref{fig:DetailedPrePro} it can be seen that the analog signal will be sampled with a sampling frequency of \\SI{48}{\\kilo\\hertz}.\nThe discrete signal wil be passed on to the FFT, which will make an FFT of the signal.\nThe FFT signal, xfft, will be passed on to the Hilbert max frequency determination block.\nThe Hilbert transform will find the dominating frequency in the signal.\nHilbert transform will only work when the input signal is a pure sine wave, if there are more sine waves mixed together it will find the average frequency and therefore a misinterpretation of the signal will be made.\nHilbert transformation requires many heavy calculations and deviations which will result in a product quantization error.\nThe found max frequency, maxFreq will be passed on to the signal processing block.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/Design/DesignPrePro_IF.pdf}\n\t\\caption{Detailed description of Preprocessing in \\systemName.}\n\t\\label{fig:DetailedPrePro}\n\\end{figure}\n\n\\subsubsection{Signal processing}\n\\Cref{fig:DetailedSigPro} shows the detailed idea of the signal processing part.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/Design/DesignSigPro_IF.pdf}\n\t\\caption{Detailed description of Signal processing in \\systemName.}\n\t\\label{fig:DetailedSigPro}\n\\end{figure}\n\nThe maxFreq will be passed on to a Sinus generator, where it will be determined which frequency to go to on \\cref{tab:cmajor}.\nA sine wave with the found frequency will then be made with as few points as possible.\nThe generated sine wave, y(n), will be interpolated so the signal gets a lot of values in the sine wave, this method has been chosen with the thought that generating a sine wave with many points is more costly then interpolating.\nThe new full sine wave will be passed on to a circular buffer.\nThe idea behind the circular buffer is to avoid calculating the same sine wave again and again.\nIf the maxFreq appears to be the same multiple times, the sine wave in the circular buffer can be reused thus we do not have to generate or interpolate a new sine.\nThe output from the circular buffer will be the new complete discrete signal.\n\n\\subsubsection{Post processing}\nThe last phase of the system will take the final discrete signal and through a DAC make it to an analog signal as shown on \\cref{fig:DetailedPostPro}.\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/Design/DesignPostPro_IF.pdf}\n\t\\caption{Detailed description of Post processing in \\systemName.}\n\t\\label{fig:DetailedPostPro}\n\\end{figure}\n\n\\subsection{Quantization} \nThere will be a quantization error on the IIR low pass filter, but since the filter is not steep and have rather long time to get to the stop band, the low pass filter does not suffer significantly from the quantization, as can be seen in \\cref{fig:quant_error_filter} where the max difference was found to be $\\SI{<0.5}{\\percent} $.\nThus the quantization error for this specific filter is negligible, but the implementation of this filter should be a FIR low pass filter since it is what works with the build in functions.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/QuantizationFilter.png}\n\t\\caption{Matlab filter coefficients results in the green curve, 1.15 format in the red curve.}\n\t\\label{fig:quant_error_filter}\n\\end{figure}\n\n\nIn the filter there will occur coefficient and product quantization. Coefficient quantization will occur when the filter coefficients are fitted to the 1.15 format.\nThe product quantization will occur when the filter coefficients are multiplied with the data.\nThis will result in quantization since it still has to fit 1.15 format.\nOn \\cref{fig:quant_error} the places where quantization occurs can be seen.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{gfx/Design/flow_quant_error.pdf}\n\t\\caption{Quantization errors \\systemName.}\n\t\\label{fig:quant_error}\n\\end{figure}\n\n\\FloatBarrier", "meta": {"hexsha": "ffcf20842289ca52fe52cddcb63e22c6839c8148", "size": 5026, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/Report/SimpleSine/design.tex", "max_stars_repo_name": "lsangild/ETISB", "max_stars_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/Report/SimpleSine/design.tex", "max_issues_repo_name": "lsangild/ETISB", "max_issues_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/Report/SimpleSine/design.tex", "max_forks_repo_name": "lsangild/ETISB", "max_forks_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.8444444444, "max_line_length": 333, "alphanum_fraction": 0.7992439316, "num_tokens": 1191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4473040437818672}}
{"text": "\\chapter{Clustering}\n\\begin{multicols*}{2}\n\n\\noindent Clustering is the process of grouping a set of objets into classes of similar objects\\\\\n\n\\noindent Ideally, we want similarity of documents are measured based on semantic similarity. However, practically we use euclidean distance and cosine similarity to achieve term-statistical similarity. \n\n\\section{Partition Clustering: K-means Clustering}\n\n\\noindent Algorithm:\n\\begin{itemize}\n    \\item Pick k number of seeds\n    \\item Assign each data to the nearest cluster\n    \\item Compute centroids for k cluster\n    \\item Repeat till converged\n\\end{itemize}\n\n\\noindent The sum of squared distances from cluster centroid should decrease while repeating:\n$$E=\\sum_k \\sum_{i \\in C_k} (d_i - c_k)^2$$\n\n\\section{Hierarchical Agglomerative Clustering}\n\\noindent Start with points as individual clusters. At each step, merge the closest pair of clusters until one cluster left. \n\\noindent Algorithm:\n\\begin{itemize}\n    \\item Compute the proximity matrix\n    \\item Let each data point be a cluster\n    \\item Repeat:\n    \\begin{itemize}\n        \\item Merge the two closest clusters\n        \\item Update the proximity matrix\n    \\end{itemize}\n    \\item Until only a single cluster remains\n\\end{itemize}\n\n\\noindent Four way to update proximity matrix:\n\\begin{itemize}\n    \\item Single-link: similarity of closest points\n    \\item Complete-link: similarity of furthest points\n    \\item Centroid: similarity of centroids\n    \\item Average-link: Average cosine between pairs of points\n\\end{itemize}\n\n\\section{Hierarchical Divisive Clustering}\nStart with one cluster. At each step, split a cluster until each cluster contains a point. \n\n\\section{Evaluation}\n\\noindent Good clustering means the intra-class similarity is high and inter-class similarity is low. \\\\\n\n\\noindent Purity: the ratio between the dominant class in the cluster and the size of the cluster\n$$j\\in C, \\text{Purity}(\\omega) = \\frac{1}{n_i} \\text{max}_j (n_{ij})$$\n\n\\subsection{Rand Index}\n\n\\begin{center}\n\\begin{tabular}{ |c|c c| } \n    \\hline\n    Number of points & Same cluster & Different cluster \\\\\n    \\hline \n    Same Truth & A & C \\\\\n    Different Truth & B & D \\\\\n    \\hline\n\\end{tabular}\n\\end{center}\n\n$$RI=\\frac{A+D}{A+B+C+D}$$\n\n\\end{multicols*}\n", "meta": {"hexsha": "1466aa2cecd14a0b42697a026d546cfbba90bbb4", "size": 2262, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "clustering.tex", "max_stars_repo_name": "Andyccs/CZ4034-information-retrieval-summary", "max_stars_repo_head_hexsha": "1636bbebc0fd7864e3d6234a57e0e978fbf7d5a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2016-04-23T05:00:21.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-05T07:10:54.000Z", "max_issues_repo_path": "clustering.tex", "max_issues_repo_name": "Andyccs/CZ4034-information-retrieval-summary", "max_issues_repo_head_hexsha": "1636bbebc0fd7864e3d6234a57e0e978fbf7d5a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "clustering.tex", "max_forks_repo_name": "Andyccs/CZ4034-information-retrieval-summary", "max_forks_repo_head_hexsha": "1636bbebc0fd7864e3d6234a57e0e978fbf7d5a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.2647058824, "max_line_length": 203, "alphanum_fraction": 0.7360742706, "num_tokens": 586, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.44730403495277793}}
{"text": "\\documentclass[11pt, oneside]{article}   \t% use \"amsart\" instead of \"article\" for AMSLaTeX format\n\n\n% \\usepackage{draftwatermark}\n% \\SetWatermarkText{Draft}\n% \\SetWatermarkScale{5}\n% \\SetWatermarkLightness {0.9} \n% \\SetWatermarkColor[rgb]{0.7,0,0}\n\n\\usepackage{geometry}                \t\t% See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}                   \t\t% ... or a4paper or a5paper or ... \n%\\geometry{landscape}                \t\t% Activate for for rotated page geometry\n%\\usepackage[parfill]{parskip}    \t\t% Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\t\t\t\t% Use pdf, png, jpg, or eps� with pdflatex; use eps in DVI mode\n\t\t\t\t\t\t\t\t% TeX will automatically convert eps --> pdf in pdflat\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t% TeX will automatically convert eps --> pdf in pdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{subcaption}\n\\usepackage{authblk}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{graphicx}\n\\usepackage[export]{adjustbox}\n\\usepackage{fixltx2e}\n\\usepackage{hyperref}\n\\usepackage{alltt}\n\\usepackage{color}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{float}\n\\usepackage{bigints}\n\\usepackage{braket}\n\\usepackage{siunitx}\n\n%\n% so you can do e.g., \\begin{bmatrix}[r] (or [c] or [l])\n%\n\n\\makeatletter\n\\renewcommand*\\env@matrix[1][c]{\\hskip -\\arraycolsep\n  \\let\\@ifnextchar\\new@ifnextchar\n  \\array{*\\c@MaxMatrixCols #1}}\n\\makeatother\n\n\\newcommand{\\argmax}{\\operatornamewithlimits{argmax}}\n\\newcommand{\\argmin}{\\operatornamewithlimits{argmin}}\n\n\\title{A Few Notes on Bell States, Superdense Coding, and Quantum Teleportation}\n\\author{David Meyer \\\\ dmm@\\{1-4-5.net,uoregon.edu\\}}\n\n\\date{Last update: \\today}\t\t\t\t\t\t\t% Activate to display a given date or no date\n\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\n\nThe Bell Circuit, shown in Figure \\ref{fig:bell_circuit}, is comprised of two gates, $H$ and CNOT, which are defined as follows:\n\n\\begin{flalign*}\nH = \\frac{1}{\\sqrt{2}}  \\begin{bmatrix}[r] 1 & 1 \\\\ 1 &  -1 \\end{bmatrix}, \n\\text{CNOT} = \\begin{bmatrix}[r] \n1 & 0 & 0 & 0 \\\\ \n0 & 1 & 0 & 0 \\\\\n0 & 0 & 0 & 1 \\\\\n0 & 0 & 1 & 0 \\\\\n\\end{bmatrix}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nand results in two maximally entangled qubits\\footnote{This state is sometimes called an \\emph{EPR} state.}.\nHow does this work? \n\n\\bigskip\n\\noindent\nFirst, recall that\n\n\\begin{flalign*}\nH \\ket{0} &= \\frac{1}{\\sqrt{2}} \\big ( \\ket{0} + \\ket{1} \\big )  \\text{ and }\nH \\ket{1} = \\frac{1}{\\sqrt{2}} \\big ( \\ket{0} - \\ket{1} \\big ) \n\\end{flalign*}\n\n\n\\bigskip\n\\noindent\nThe Bell Circuit applies $H$ to $\\ket{b_0}$ and then applies the CNOT gate to $H\\ket{b_0}$ (control qubit)  \nand $\\ket{b_1}$ (target qubit). The inputs and evolution of the Bell Circuit are shown are Table \\ref{tab:bell_state}.\n\n\\bigskip\n\\begin{figure}\n\\center{\\includegraphics[scale=0.45, frame] {images/bell_forward_circuit.png}}\n\\caption{Bell Circuit}\n\\label{fig:bell_circuit}\n\\end{figure}\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{c | c | c | c | c}\n$b_{0} b_{1}$  & $H \\ket{b_0}$ & $\\ket{b_1}$ & Bell Circuit evolution with inputs $\\ket{b_0}$ and $\\ket{b_1}$  & Bell State\\\\\n\\hline\n00  & $H\\ket{0}$ & $\\ket{0}$ & $\\ket{0} \\xrightarrow{\\scriptsize H}  \\frac{1}{\\sqrt{2}} (\\ket{0} + \\ket{1}) \n  \\xrightarrow{\\otimes \\ket{0}}  \\frac{1}{\\sqrt{2}} (\\ket{0} + \\ket{1}) \\ket{0} \\xrightarrow{\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11})$ & $\\ket{\\phi^+}$ \\\\\n01  & $H\\ket{0}$ & $\\ket{1}$ & $ \\ket{0} \\xrightarrow{\\scriptsize H} \\frac{1}{\\sqrt{2}} (\\ket{0} + \\ket{1})  \n  \\xrightarrow{\\scriptsize \\otimes \\ket{1}} \\frac{1}{\\sqrt{2}} (\\ket{0} + \\ket{1})  \\ket{1} \\xrightarrow{\\scriptsize \\text{CNOT}}  \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{10})$\\ & $\\ket{\\psi^+}$ \\\\\n10  & $H\\ket{1}$ & $\\ket{0}$ & $\\ket{1} \\xrightarrow{\\scriptsize H}  \\frac{1}{\\sqrt{2}} (\\ket{0} - \\ket{1})  \\xrightarrow{\\scriptsize \\otimes \\ket{0}} \\frac{1}{\\sqrt{2}} (\\ket{0} - \\ket{1})  \\ket{0} \\xrightarrow{\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}}  (\\ket{00} - \\ket{11})$ & $\\ket{\\phi^-}$ \\\\\n11    & $H\\ket{1}$ & $\\ket{1}$ & $\\ket{1} \\xrightarrow{\\scriptsize H}  \\frac{1}{\\sqrt{2}} (\\ket{0} - \\ket{1}) \n  \\xrightarrow{\\scriptsize \\otimes  \\ket{1}}  \\frac{1}{\\sqrt{2}} (\\ket{0} - \\ket{1})  \\ket{1} \\xrightarrow{\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}}  (\\ket{01} - \\ket{10})$ & $\\ket{\\psi^-}$\n\\end{tabular}\n\\caption{Bell States}\n\\label{tab:bell_state}\n\\end{table}\n\n\\bigskip\n\\noindent\nWhat we can see from Table \\ref{tab:bell_state} is that $b_0$ selects the \"bit\" ($\\ket{\\phi}$ or $\\ket{\\psi}$), and $b_1$ selects the \"sign\" ($\\ket{+}$ or $\\ket{-}$). Since there\nare four orthonormal states, the \\emph{Bell basis}, we can encode two bits ($b_0$ and $b_1$) in the four Bell States.  \n\n\\bigskip\n\\noindent\nNow,  if Alice wants to send two classical bits to  Bob (\\emph{superdense coding}) using one qubit, she need only transform her qubit\\footnote{Her half of the EPR pair, the two entangled qubits.} \ninto the Bell State corresponding to the two bits she wants to send, then send her half to Bob (this requires a \\emph{quantum} channel). Bob can then recover Alice's two bit message.\n\n\n\\bigskip\n\\noindent\nBut how can Bob recover Alice's message? Recall that unitary quantum operations are reversible. So Bob can use the Reverse Bell Circuit shown in Figure \\ref{fig:reverse_bell_circuit} to recover\nAlice's 2 bit message.\n\n\n\\bigskip\n\\begin{figure}[H]\n\\center{\\includegraphics[scale=0.45, frame] {images/bell_reverse_circuit.png}}\n\\caption{Reverse Bell Circuit}\n\\label{fig:reverse_bell_circuit}\n\\end{figure}\n\n\\section{Superdense Coding}\n\nSuppose Alice wants to send Bob the message $00$. Alice can perform one or more unitary operations on her qubit (her half of the entangled pair) that will allow Bob, \nwhen presented with Alice's qubit, to reconstruct Alice's message $b_0b_1$. If we run $\\ket{\\phi^+}$ through the circuit in Figure \\ref{fig:reverse_bell_circuit},\nthat is, $\\ket{\\phi^+}  \\xrightarrow {\\scriptsize \\text{CNOT}}  \\xrightarrow {\\scriptsize \\text{  H  }}  \\ket{b_0b_1}$,  Bob will recover Alice's message ($b_0b_1 = 00$). Why is this?\n\n\\begin{flalign*}\n\\ket{\\phi^+} &=  \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11}) \\longrightarrow  \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{0}  \\ket{0} + \\ket{1} \\ket{1}) \\xrightarrow {\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{10}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{10}) \\xrightarrow {\\scriptsize \\text{  H  }}  \\frac{1}{\\sqrt{2}}  \\Big ( \\frac{1}{\\sqrt{2}}  (\\ket{0} + \\ket{1}) \\ket{0} + \\frac{1}{\\sqrt{2}}  (\\ket{0} - \\ket{1}) \\ket{0} \\Big) \\\\\n&= \\frac{1}{\\sqrt{2}} \\frac{1}{\\sqrt{2}}  \\Big ( (\\ket{0} + \\ket{1}) \\ket{0} + (\\ket{0} - \\ket{1}) \\ket{0} \\Big ) \\\\\n&= \\frac{1}{2} \\big (\\ket{00} + \\ket{10} + \\ket{00} - \\ket{10} \\big ) \\\\\n&= \\frac{1}{2} \\big  (2 \\ket{00} + (\\ket{10} - \\ket{10}) \\big ) \\\\\n&=  \\frac{1}{2} \\cdot 2 \\ket{00} \\\\\n&= \\ket{00}\n\\end{flalign*}\n\n\n\\bigskip\n\\noindent\nBob can now measure both qubits and recover Alice's message ($b_0b_1 = 00$). \n\n\n\\bigskip\n\\noindent\nIn general, Alice notices that \n\n\\begin{itemize}\n\\item To send \\textbf{00}, apply the Identity matrix $\\mathbf{I} = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}$ to her half of the EPR pair\n\\item To send \\textbf{01}, apply the matrix $\\mathbf{X} = \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$ to her half of the EPR pair\n\\item To send \\textbf{10}, apply the matrix $\\mathbf{Z} = \\begin{bmatrix}[r] 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$ to her half of the EPR pair\n\\item To send \\textbf{11}, apply $i\\mathbf{Y} = i \\begin{bmatrix}[r] 0 & -i \\\\ i & 0 \\end{bmatrix}$, i.e. both $\\mathbf{X}$ and $\\mathbf{Z}$,  to her half of the EPR pair\n\\end{itemize} \n\n\\bigskip\n\\noindent\nwhere $\\mathbf{I}$, $\\mathbf{X}$, $\\mathbf{Y}$ and $\\mathbf{Z}$ are the \\emph{Pauli} matrices \\cite{wiki:pauli_matrices}. \n\\bigskip\n\\noindent\nThis transforms the EPR pair $\\ket{\\phi^+}$ into the four Bell States $\\ket{\\phi^+}$, $\\ket{\\psi^+}$, $\\ket{\\phi^-}$ and $\\ket{\\psi^-}$ respectively:\n\n\\begin{itemize}\n\\item \\textbf{00}: $\\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}  \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} \\longrightarrow  \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11}) =\n\\frac{1}{\\sqrt{2}} \\begin{bmatrix} 1 \\\\ 0 \\\\  0 \\\\ 1 \\end{bmatrix} = \\ket{\\phi^+}$\n\n\\item \\textbf{01:} $\\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix} \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} \\longrightarrow  \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{10}) =\n\\frac{1}{\\sqrt{2}} \\begin{bmatrix} 0 \\\\ 1 \\\\  1 \\\\ 0 \\end{bmatrix} = \\ket{\\psi^+}$\n\n\\item \\textbf{10:} $\\begin{bmatrix}[r] 1 & 0 \\\\ 0 & -1 \\end{bmatrix}  \\frac{1}{\\sqrt{2}} (\\ket{00} - \\ket{11} \\longrightarrow  \\frac{1}{\\sqrt{2}} (\\ket{00} - \\ket{11}) =\n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}[r] 1 \\\\ 0 \\\\  0 \\\\  -1 \\end{bmatrix} = \\ket{\\phi^-}$\n\n\\item \\textbf{11:}  $i  \\begin{bmatrix}[r] 0 & -i \\\\ i & 0 \\end{bmatrix} \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} \\longrightarrow  \\frac{1}{\\sqrt{2}} (\\ket{01} - \\ket{10}) =\n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}[r] 0 \\\\ 1 \\\\  -1 \\\\ 0 \\end{bmatrix} = \\ket{\\psi^-}$\n\\end{itemize}\n\n\\bigskip\n\\noindent\nThe four Bell states $\\ket{\\phi^+}$, $\\ket{\\psi^+}$, $\\ket{\\phi^-}$ and $\\ket{\\psi^-}$ are orthonormal and are hence distinguishable by \nquantum measurement.  Thus after receiving Alice's transformed qubit (her half of the EPR pair),\nBob can measure both qubits and recover $b_0b_1$. Hence one qubit carries two classical bits of information; this is superdense coding.\nWe saw an example of this above in which Bob recovered $\\ket{00}$ from $\\ket{\\phi^+}$ using \nthe Reverse Bell Circuit depicted in Figure \\ref{fig:reverse_bell_circuit}.\n\n\\subsection{Aside: Spectral Decomposition of Pauli Matrices}\nSo far we've interpreted the Pauli matrices as a quantum gates. But note that a gate such \\textbf{Z} is a Hermitean operator and as a \nresult can be interpreted as an observable. Somewhat surprisingly (notice the symmetry),  the spectral decomposition \\cite{2014arXiv1405.5749S}\n of \\textbf{Z}  is\n\n\\begin{flalign*}\n\\mathbf{Z} =  \\ket{0}\\bra{0} - \\ket{1}\\bra{1}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nwhere  $\\ket{u}\\bra{v}$ is Dirac notation \\cite{2000RPPh...63.1893G} for the outer product $\\mathbf{u} \\otimes \\mathbf{v} =  \\mathbf{u} \\mathbf{v}^{\\text{T}}$ of $m \\times 1$ vector \n\\textbf{u} and  $n \\times 1$ vector \\textbf{v}, which yields a $m \\times n$ matrix\\footnote{The outer product is of vectors \n\\textbf{u} and \\textbf{v}  is a special case of the tensor product  $\\mathbf{u} \\otimes \\mathbf{v}$. \nMore generally, the outer product is an instance of a Kronecker product \\cite{wiki:kronecker}.}.\n\n\n\n\\bigskip\n\\noindent\nWe can see that the eigenvalues of \\textbf{Z}  are 1 and -1, corresponding to eigenvectors $\\ket{0}$  and $\\ket{1}$  respectively. So the measurement operators are the \nprojectors $\\ket{0}\\bra{0}$ and $\\ket{1}\\bra{1}$,  This means that a measurement of the Pauli observable \\textbf{Z} is a measurement in the computational basis that has \neigenvalue +1 corresponding to $\\ket{0}$  and eigenvalue -1 corresponding to $\\ket{1}$. \n\n\\bigskip\n\\noindent\nSo ok, but why does $\\mathbf{Z} = \\ket{0}\\bra{0} - \\ket{1}\\bra{1}$? Well, we know that the outer product $\\mathbf{u} \\otimes \\mathbf{v}$ of a $m \\times 1$ vector  \\textbf{u} and a \n$n \\times 1$ vector  \\textbf{v} is defined to be the $m \\times n$ matrix\\footnote{Contrast with the scalar inner product  \n$\\langle \\mathbf{u},  \\mathbf{v} \\rangle = \\mathbf{u}^{\\text{T}} \\mathbf{v}$. Note also that $\\langle \\mathbf{u},  \\mathbf{v} \\rangle = \\text{tr}(\\mathbf{u} \\otimes \\mathbf{v})$,\nwhere $\\text{tr}(\\mathbf{A})$ is the \"trace\" of matrix \\textbf{A}. } $\\mathbf{u} \\mathbf{v}^{\\text{T}}$.\n\n\\bigskip\n\\noindent\nTo see why $\\mathbf{Z} = \\ket{0}\\bra{0} - \\ket{1}\\bra{1}$, first recall that  $\\ket{0} = \\begin{bmatrix} 1 \\\\0 \\end{bmatrix}$ and $\\ket{1} = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$. Then\n\n\\begin{flalign*}\n\\ket{0}\\bra{0}  &= \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}^{\\text{T}} =\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\begin{bmatrix} 1  & 0 \\end{bmatrix} = \\begin{bmatrix} 1 & 0 \\\\ 0 & 0 \\end{bmatrix} \\text{ and} \\\\\n\\ket{1}\\bra{1}  &= \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}^{\\text{T}}  = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} \\begin{bmatrix} 0  & 1 \\end{bmatrix} = \\begin{bmatrix} 0 & 0 \\\\ 0 & 1 \\end{bmatrix} \\text{ so that} \\\\\n\\ket{0}\\bra{0} - \\ket{1}\\bra{1} &= \\begin{bmatrix} 1 & 0 \\\\ 0 & 0 \\end{bmatrix}  - \\begin{bmatrix} 0 & 0 \\\\ 0 & 1 \\end{bmatrix} = \\begin{bmatrix}[r] 1 & 0 \\\\ 0 & -1 \\end{bmatrix} = \\mathbf{Z}\n\\end{flalign*}\n\n\n\\bigskip\n\\subsection{Back to Alice wanting to send a message to Bob}\nNow suppose Alice want's to send Bob the message 01.  Alice then applies Pauli matrix $X$ to $\\ket{\\phi+}$ to get $\\ket{\\psi^+}$:\n\n\\begin{equation*}\n\\mathbf{X} \\ket{\\phi^+} = \\begin{bmatrix}[r] 0 & 1  \\\\ 1 & 0\\end{bmatrix} \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} = \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{10}) = \\ket{\\psi^+}\n\\end{equation*}\n\n\\bigskip\n\\noindent\nBob can now recover Alice's message as follows using the Reverse Bell Circuit (Figure \\ref{fig:reverse_bell_circuit}). That is, Bob can\ndo the the unitary operations $\\ket{\\psi^+}  \\xrightarrow {\\scriptsize \\text{CNOT}}  \\xrightarrow {\\scriptsize \\text{H}}  \\ket{01}$, as follows:\n\n\n\\begin{flalign*}\n\\ket{\\psi^+} &= \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{10}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{0}  \\ket{1} + \\ket{1} \\ket{0}) \\xrightarrow {\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{11}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{01} + \\ket{11}) \\xrightarrow {\\scriptsize \\text{  H  }}  \\frac{1}{\\sqrt{2}}  \\Big ( \\frac{1}{\\sqrt{2}}  (\\ket{0} + \\ket{1}) \\ket{1} + \\frac{1}{\\sqrt{2}}  (\\ket{0} - \\ket{1}) \\ket{1} \\Big) \\\\\n&= \\frac{1}{\\sqrt{2}} \\frac{1}{\\sqrt{2}}  \\Big ( (\\ket{0} + \\ket{1}) \\ket{1} + (\\ket{0} - \\ket{1}) \\ket{1} \\Big ) \\\\\n&= \\frac{1}{2} \\big (\\ket{01} + \\ket{11} + \\ket{01} - \\ket{11} \\big) \\\\\n&= \\frac{1}{2} \\big (2 \\ket{01} + (\\ket{11} - \\ket{11}) \\big) \\\\\n&=  \\frac{1}{2}  \\cdot 2 \\ket{01} \\\\\n&=  \\frac{2}{2}  \\ket{01} \\\\\n&= \\ket{01}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nNow Bob can measure the two qubits and recover Alice's message ($b_0b_1 = 01$).\n\n\\bigskip\n\\noindent\nSimilarly, suppose Alice wants to send the message 10 to Bob. Alice first transforms her qubit as follows\n\n\n\\begin{equation*}\n\\mathbf{Z} \\ket{\\phi^+} = \\begin{bmatrix}[r] 1 & 0 \\\\ 0 & -1 \\end{bmatrix}  \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} = \\frac{1}{\\sqrt{2}} (\\ket{00} -  \\ket{11}) = \\ket{\\phi^-}\n\\end{equation*}\n\n\\bigskip\n\\noindent\nAlice now sends her qubit to Bob over a quantum channel. Bob can now recover Alice's message, again using the Reverse Bell Circuit \n($\\ket{\\phi^-}  \\xrightarrow {\\scriptsize \\text{CNOT}}  \\xrightarrow {\\scriptsize \\text{  H  }}  \\ket{10}$). Again, why is this?\n\n\\begin{flalign*}\n\\ket{\\phi^-} &=  \\frac{1}{\\sqrt{2}} (\\ket{00} - \\ket{11}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{0}  \\ket{0} - \\ket{1} \\ket{1}) \\xrightarrow {\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}} (\\ket{00} - \\ket{10}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{00} - \\ket{10}) \\xrightarrow {\\scriptsize \\text{  H  }}  \\frac{1}{\\sqrt{2}}  \\Big ( \\frac{1}{\\sqrt{2}}  (\\ket{0} + \\ket{1}) \\ket{0} -  \\frac{1}{\\sqrt{2}}  (\\ket{0} - \\ket{1}) \\ket{0} \\Big) \\\\\n&= \\frac{1}{\\sqrt{2}} \\frac{1}{\\sqrt{2}}  \\Big ( (\\ket{0} + \\ket{1}) \\ket{0} -  (\\ket{0} - \\ket{1}) \\ket{0} \\Big ) \\\\\n&= \\frac{1}{2} \\big (\\ket{00} + \\ket{10} - \\ket{00}  + \\ket{10} \\big ) \\\\\n&= \\frac{1}{2} \\big (2 \\ket{10} + (\\ket{00} - \\ket{00}) \\big ) \\\\\n&=  \\frac{1}{2} \\cdot 2 \\ket{10} \\\\\n&= \\ket{10}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nNow Bob can measure the two qubits and recover Alice's message ($b_0b_1 = 10)$.\n\n\\bigskip\n\\noindent\nFinally, if Alice wants to send $11$ to Bob she first transforms her qubit \n\n\\begin{equation*}\ni \\mathbf{Y} \\ket{\\phi^+} =  \\begin{bmatrix}[r] 0 & -i \\\\ i & 0 \\end{bmatrix}   \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11} = \\frac{1}{\\sqrt{2}} (\\ket{01} - \\ket{10}) = \\ket{\\psi^-}\n\\end{equation*}\n\n\\bigskip\n\\noindent\nAlice now transmits her qubit to Bob and Bob applies the Reverse Bell Circuit to recover Alice's message:\n\n\\begin{flalign*}\n\\ket{\\psi^-} &= \\frac{1}{\\sqrt{2}} (\\ket{01} -  \\ket{10}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{0}  \\ket{1} - \\ket{1} \\ket{0}) \\xrightarrow {\\scriptsize \\text{CNOT}} \\frac{1}{\\sqrt{2}} (\\ket{01} -  \\ket{11}) \\longrightarrow \\\\\n& \\frac{1}{\\sqrt{2}} (\\ket{01} -  \\ket{11}) \\xrightarrow {\\scriptsize \\text{  H  }}  \\frac{1}{\\sqrt{2}}  \\Big ( \\frac{1}{\\sqrt{2}}  (\\ket{0} + \\ket{1}) \\ket{1} - \\frac{1}{\\sqrt{2}}  (\\ket{0} - \\ket{1}) \\ket{1} \\Big) \\\\\n&= \\frac{1}{\\sqrt{2}} \\frac{1}{\\sqrt{2}}  \\Big ( (\\ket{0} + \\ket{1}) \\ket{1} -  (\\ket{0} - \\ket{1}) \\ket{1} \\Big ) \\\\\n&= \\frac{1}{2} \\big (\\ket{01} + \\ket{11} -  \\ket{01} +  \\ket{11} \\big) \\\\\n&= \\frac{1}{2} \\big (2 \\ket{11} + (\\ket{01} - \\ket{01}) \\big) \\\\\n&=  \\frac{1}{2}  \\cdot 2 \\ket{11} \\\\\n&=  \\frac{2}{2}  \\ket{11} \\\\\n&= \\ket{11}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nNow Bob can measure the two qubits and recover Alice's message ($b_0b_1 = 11)$.\n\n\n\\section{Quantum Teleportation}\nQuantum teleportation can be thought of as the dual task to super dense coding. Whereas super dense coding is concerned with conveying classical information \nvia a qubit, quantum teleportation is concerned with conveying quantum information with classical bits \\cite{Bennett:1992tv}.\n\n\\subsection{A high-level view of the quantum teleportation algorithm}\n\n\\begin{enumerate}\n\\item Alice and Bob share an entangled (EPR) pair $\\ket{\\phi^+}$\n\\item Alice chooses a qubit $\\ket{\\psi}$ as the message she wants to convey to Bob\n\\item Alice performs operations on $\\ket{\\psi}$ and $\\ket{\\phi^{+}_A}$ (Alice's her half of $\\ket{\\phi^+}$)\n\\item Alice measures $\\ket{\\psi}$  and her half of  $\\ket{\\phi^+_A}$, destroying both of her qubits\n\\item Alice sends the two classical bits that were the results of her measurements to Bob\n\\item Bob uses the two classical bits to \"correct\" $\\ket{\\phi^{+}_B}$ (his half of $\\ket{\\phi^+}$) to be $\\ket{\\psi}$\n\\end{enumerate}\n\n\\bigskip\n\\noindent\nAlice uses the circuit in Figure \\ref{fig:a_reverse_bell_circuit} to prepare her two qubits (step 3 above). How exactly does this work? \nFirst, notice that the input to the Reverse Bell Circuit shown in Figure \\ref{fig:a_reverse_bell_circuit} is $\\ket{\\psi} \\otimes \\ket{\\phi^{+}_A}$. \nTo see how this works, first recall that $\\ket{\\psi} = \\alpha \\ket{0} + \\beta \\ket{1}$.  Then \n\n\n\\begin{figure}[t]]\n\\center{\\includegraphics[scale=0.45, frame] {images/a_reverse_bell_circuit.png}}\n\\caption{Reverse Bell Circuit}\n\\label{fig:a_reverse_bell_circuit}\n\\end{figure}\n\n\\begin{flalign*}\n\\ket{\\psi} \\otimes \\ket{\\phi^{+}_A} &= (\\alpha \\ket{0} + \\beta \\ket{1}) \\otimes \\frac{1}{\\sqrt{2}} (\\ket{00} + \\ket{11}) \\\\\n&= \\frac{1}{\\sqrt{2}} \\Big ( \\alpha (\\ket{000} + \\alpha \\ket{011}) + \\beta (\\ket{100} + \\ket{111}) \\Big ) \\xrightarrow {\\scriptsize \\text{CNOT}}  \n\\quad\\qquad \\mathrel{\\#} \\ket{b_0b_1b_2}: b_0 \\text{ is control, } b_1  \\text{ is target} \\\\\n& \\frac{1}{\\sqrt{2}} \\Big ( \\alpha \\ket{000} + \\alpha \\ket{011})+ \\beta (\\ket{110} + \\ket{101}) \\Big ) \\xrightarrow {\\scriptsize \\text{H}}  \n\\; \\qquad \\qquad\\qquad \\mathrel{\\#} \\text{apply $H$ to $b_0$} \\\\\n& \\frac{1}{\\sqrt{2}} \\bigg [ \\alpha \\Big ( \\frac{1}{\\sqrt{2}} \\ket{0} + \\ket{1} \\Big ) \\ket{00} + \\alpha \\Big (  \\frac{1}{\\sqrt{2}} \\ket{0} + \\ket{1}) \\Big )  \\ket{11}  + \n\\beta \\Big ( \\frac{1}{\\sqrt{2}} \\ket{0} - \\ket{1} \\Big ) \\ket{10} + \\beta \\Big (  \\frac{1}{\\sqrt{2}} \\ket{0} - \\ket{1} \\Big )  \\ket{01}  \\bigg ]\\\\\n&= \\frac{1}{\\sqrt{2}} \\frac{1}{\\sqrt{2}}  \n\\bigg [ \\alpha \\Big ( \\big (\\ket{0} + \\ket{1} \\big ) \\ket{00} +  \\big (\\ket{0} + \\ket{1} \\big )  \\ket{11} \\Big)  +\n\\beta \\Big ( \\big (\\ket{0} - \\ket{1} \\big ) \\ket{10} + \\big ( \\ket{0} - \\ket{1} \\big )  \\ket{01} \\Big ) \\bigg] \\\\\n&= \\frac{1}{2} \\bigg [ \\alpha \\Big (\\ket{000} + \\ket{100}  +  \\ket{011} + \\ket{111}) \\Big)  +\n\\beta \\Big (\\ket{010} - \\ket{110} + \\ket{001} - \\ket{101}  \\Big ) \\bigg ] \\\\\n&= \\frac{1}{2} \\bigg [ \\alpha \\ket{000} + \\alpha \\ket{100}  +  \\alpha \\ket{011} + \\alpha \\ket{111})  +\n \\beta \\ket{010} - \\beta\\ket{110} + \\beta \\ket{001} - \\beta \\ket{101}  \\bigg ] \\\\\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nNow Alice measures her two qubits ($\\ket{\\psi} \\otimes \\ket{\\phi^{+}_A} $) and observes $b_0b_1 \\in \\{00, 01, 10, 11\\}$ with $P(b_0b_1) = \\frac{1}{4}$. \n\n\n\\bigskip\n\\noindent\nNow here's the amazing thing. If Alice observes $00$, she communicates this to Bob (over a classical channel). As soon as\nBob sees the value $00$, he knows that his qubit $\\ket{\\phi^{+}_{B}} = \\alpha \\ket{0} + \\beta \\ket{1}$. How does Bob know this?\n\n\\bigskip\n\\noindent\nFirst, as shown above\n\n\\begin{flalign}\n\\label{eqn:psi_otimes_phi+}\n\\ket{\\psi} \\otimes \\ket{\\phi^+} = \\frac{1}{2} \\bigg [ \\alpha \\ket{000} + \\alpha \\ket{100}  +  \\alpha \\ket{011} + \\alpha \\ket{111})  +\n\\beta \\ket{010} - \\beta\\ket{110} + \\beta \\ket{001} - \\beta \\ket{101}  \\bigg ] \n\\end{flalign}\n \n \n \\bigskip\n\\noindent\nAlice's measurement of the first two qubits collapses Bob's qubit to the third qubit\\footnote{Recall that the original three qubits were\n$\\ket{\\psi} \\otimes \\ket{\\phi^{+}_{AB}}$.}.  The only terms in Equation \\ref{eqn:psi_otimes_phi+} that are \nconsistent with the first two qubits being $\\ket{00}$ (resulting from Alice's measurement)\nare $\\alpha \\ket{000}$ and $\\beta \\ket{001}$. The \"collapsed version\" is $\\alpha \\ket{0}$ and $\\beta \\ket{1}$. \nHence Bob knows that his qubit, $\\ket{\\phi^{+}_B}$,  equals $\\alpha \\ket{0} + \\beta \\ket{1}$.\n\n \\bigskip\n\\noindent\nSince Alice sent the two bits she saw to Bob, he knows which operations to perform to transform $\\ket{\\phi^{+}_B} \\rightarrow \\ket{\\psi}$.  \nIn particular, $b_0 = 1$ Bob should apply Pauli matrix $Z$ to his qubit and $I$ otherwise, \nand if $b_1 = 1$ he should apply $X$ and $I$ otherwise. This transforms $\\ket{\\phi^{+}_B}$, Bob's qubit, into $\\ket{\\psi}$. \nThis is shown in Table \\ref{tab:bob}.\n\n\\bigskip\n\\noindent\nAmazingly  this procedure teleports Alice's qubit $\\ket{\\psi}$ to Bob using the two classical bits that Alice learned by measuring her two qubits ($\\ket{\\psi}$ and $\\ket{\\phi^{+}_A}$).  \n\n\\bigskip\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{c | c | r | r}\n$b_{0} b_{1}$  & $\\ket{\\phi^{+}_B}$  & \\multicolumn{1}{c|}{Transformation} & \\multicolumn{1}{c}{Computation}  \\\\\n\\hline\n\\textbf{00}  & $\\alpha \\ket{0} + \\beta \\ket{1}$ & $\\mathbf{I} \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}$ & $\\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix} \n \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}  = \\begin{bmatrix} \\alpha \\\\  \\beta  \\end{bmatrix} = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}$  \\\\\n\\textbf{01}  & $\\beta \\ket{0} + \\alpha \\ket{1}$ & $\\mathbf{X}\\begin{bmatrix} \\beta \\\\ \\alpha  \\end{bmatrix}$ & $ \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}  \\begin{bmatrix} \\beta \\\\ \\alpha  \\end{bmatrix} \n= \\begin{bmatrix} \\alpha \\\\  \\beta  \\end{bmatrix}  = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}$ \\\\\n\\textbf{10}  & $\\alpha \\ket{0} - \\beta \\ket{1}$ & $\\mathbf{Z} \\begin{bmatrix}[r]   \\alpha \\\\  -\\beta  \\end{bmatrix}$ & $\\begin{bmatrix}[r] 1 & 0  \\\\ 0 & -1 \\end{bmatrix}  \\begin{bmatrix}[r] \\alpha \\\\ -\\beta \\end{bmatrix} \n= \\begin{bmatrix} \\alpha \\\\  \\beta  \\end{bmatrix}  = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}$ \\\\\n\\textbf{11}  & $\\beta \\ket{0} - \\alpha \\ket{1} $ & $\\mathbf{XZ} \\begin{bmatrix}[r]  \\beta \\\\  - \\alpha  \\end{bmatrix}$ & $  \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}  \\begin{bmatrix}[r] 1 & 0  \\\\ 0 & -1 \\end{bmatrix} \n  \\begin{bmatrix}[r] \\beta \\\\ -  \\alpha  \\end{bmatrix} = \\begin{bmatrix} \\alpha \\\\  \\beta  \\end{bmatrix} = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}$ \\\\\n\\end{tabular}\n\\caption{Bob's transformations on receiving classical bits $\\mathbf{b_0b_1}$ from Alice}\n\\label{tab:bob}\n\\end{table}\n\n\n\\subsection{Curious Entry for \\textbf{11} in Table \\ref{tab:bob}?}\nNote that the row for the result of Alice's measurement \\textbf{11} in Table \\ref{tab:bob} is curious. When Bob sees \\textbf{11} from Alice he knows that his remaining qubit \n$\\ket{\\psi^{+}_B}$, equals $- \\beta \\ket{0} + \\alpha \\ket{1}$. Why does the table say $\\beta \\ket{0} - \\alpha \\ket{1}$? \n\n\\bigskip\n\\noindent\nHere is one way to look at this: First,\nrecall that when Bob receives classical bits \\textbf{11} from Alice he knows that his qubit, $\\ket{\\psi^{+}_B}$,  is\n\n\\begin{flalign*}\n\\ket{\\psi^{+}_B} &= - \\beta \\ket{0} + \\alpha \\ket{1} = \\begin{bmatrix} -\\beta \\\\ \\alpha \\end{bmatrix}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nNow, if Bob now wants to transform $\\ket{\\psi^{+}_B} \\rightarrow \\ket{\\psi}$, he would apply $\\mathbf{ZX}$ as follows\n\n\\begin{flalign*}\n\\mathbf{ZX} \\ket{\\psi^{+}_B}  &=  \\begin{bmatrix}[r] 1 & 0  \\\\ 0 & -1 \\end{bmatrix}   \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}  \\begin{bmatrix} -\\beta \\\\ \\alpha \\end{bmatrix} \\\\\n&= \\begin{bmatrix}[r] 1 & 0  \\\\ 0 & -1 \\end{bmatrix}   \\begin{bmatrix} \\alpha \\\\ - \\beta \\end{bmatrix} \\\\\n&= \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} \\\\\n&= \\alpha \\ket{0} + \\beta \\ket{1} \\\\\n&= \\ket{\\psi}\n\\end{flalign*}\n\n\n\\bigskip\n\\noindent\nBut our rule (Table \\ref{tab:bob})  tells Bob to apply $\\mathbf{XZ}$ when he sees \\textbf{11} from Alice. Why? Notice the following:\n\n\n\\begin{flalign*}\n\\mathbf{ZX} \\begin{bmatrix} x_0 \\\\ x_1 \\end{bmatrix} &= \\mathbf{Z} \\begin{bmatrix} x_1 \\\\ x_0  \\end{bmatrix} =  \\begin{bmatrix}[r] x_1 \\\\  - x_0 \\end{bmatrix} \\\\\n\\mathbf{XZ} \\begin{bmatrix} x_0 \\\\ x_1 \\end{bmatrix} &= \\mathbf{X} \\begin{bmatrix}[r] x_0 \\\\ - x_1  \\end{bmatrix}  = \\begin{bmatrix}[r] - x_1 \\\\  x_0 \\end{bmatrix}  \n\\end{flalign*}\n\n\n\\bigskip\n\\noindent\nwhich implies that\n\n\\bigskip\n\n\\begin{equation}\n\\mathbf{ZX} \\begin{bmatrix} x_0 \\\\ x_1 \\end{bmatrix}  = - \\mathbf{XZ} \\begin{bmatrix} x_0 \\\\ x_1 \\end{bmatrix}\n\\label{eqn:equal}\n\\end{equation}\n\n\\bigskip\n\\bigskip\n\\noindent\nSo now let $x_0 = \\beta$ and $x_1 =   \\alpha$.  Then\n\n\\begin{flalign*}\n\\mathbf{XZ} \\Big [\\beta \\ket{0} - \\alpha \\ket{1} \\Big ] = \\mathbf{XZ} \\begin{bmatrix}[r] \\beta  \\\\ - \\alpha \\end{bmatrix} = \\mathbf{X} \\begin{bmatrix} \\beta \\\\ \\alpha \\end{bmatrix} \n=  \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nand $- \\big (\\beta \\ket{0} - \\alpha \\ket{1} \\big )= -\\beta \\ket{0} + \\alpha \\ket{1} \\longrightarrow$\n\n\\begin{flalign*}\n\\mathbf{ZX}  \\Big [ -\\beta \\ket{0} + \\alpha \\ket{1} \\Big ] = \\mathbf{ZX} \\begin{bmatrix}[r] - \\beta \\\\ \\alpha \\end{bmatrix} = \\mathbf{Z} \\begin{bmatrix}[r] \\alpha \\\\ - \\beta\\end{bmatrix} \n = \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha \\ket{0} + \\beta \\ket{1} = \\ket{\\psi}\n \\end{flalign*}\n\n\\bigskip\n\\bigskip\n\\noindent\nThe choice of the transformation rules shown in Table \\ref{tab:bob} and Equation \\ref{eqn:equal} allows us to write \n$\\beta \\ket{0} - \\alpha \\ket{1}$ rather than $- \\beta \\ket{0} + \\alpha \\ket{1}$.\n\n\\bigskip\n\\noindent\nWhy do this? One thing it does is make the symmetry in Table \\ref{tab:bob} more explicit, but hopefully there is a better reason...\n\n\n\\subsubsection{Cloning and/or Faster Than Light Communication?}\nFirst, no faster-than-light communication occurs since Bob learns nothing from the changes until Alice actually sends the two classical bits to him (even\nthough Alice operating on $\\ket{\\phi^{+}_A}$ instantly affects $\\ket{\\phi^{+}_B}$).\n\n\\bigskip\n\\noindent\nThe No-Cloning Theorem \\cite{2018arXiv180804213E}  is not violated since, even though Bob has an exact copy of $\\ket{\\psi}$, Alice had to destroy her copy (by\nmeasuring it). \n\n\\bigskip\n\\noindent\nFinally, an interesting point is that neither Alice or Bob ever \"know\"  what $\\ket{\\psi}$ is (in terms of its actual amplitudes); all they know\nis that it was transferred (whatever it was). \n\n\\section{Bell and  CHSH}\n\n\\bigskip\n\\noindent\n\n\\section{Acknowledgements}\n\n\\newpage\n\\bibliographystyle{plain}\n\\bibliography{/Users/dmm/papers/bib/qc}\n\n\n\n\\end{document} \n", "meta": {"hexsha": "d89a4abec9b319bb4735cf4a7d7f9c1e7561e78a", "size": 27827, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_my_stuff/papers/qc/bell/bell.tex", "max_stars_repo_name": "davidmeyer/davidmeyer.github.io", "max_stars_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_my_stuff/papers/qc/bell/bell.tex", "max_issues_repo_name": "davidmeyer/davidmeyer.github.io", "max_issues_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_my_stuff/papers/qc/bell/bell.tex", "max_forks_repo_name": "davidmeyer/davidmeyer.github.io", "max_forks_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.7791970803, "max_line_length": 299, "alphanum_fraction": 0.6350307256, "num_tokens": 10790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.4472958025731631}}
{"text": "\\documentclass[11pt]{scrartcl} % Font size\n\\input{structure.tex} % Include the file specifying the document structure and custom commands\n\n%----------------------------------------------------------------------------------------\n%\tTITLE SECTION\n%----------------------------------------------------------------------------------------\n\n\\title{\n\t\\normalfont\\normalsize\n\t\\textsc{Harvard Privacy Tools Project}\\\\ % Your university, school and/or department name(s)\n\t\\vspace{25pt} % Whitespace\n\t\\rule{\\linewidth}{0.5pt}\\\\ % Thin top horizontal rule\n\t\\vspace{20pt} % Whitespace\n\t{\\huge The Exponential Mechanism for Medians}\\\\ % The assignment title\n\t\\vspace{12pt} % Whitespace\n\t\\rule{\\linewidth}{2pt}\\\\ % Thick bottom horizontal rule\n\t\\vspace{12pt} % Whitespace\n}\n\n% \\author{\\LARGE} % Your name\n\n\\date{\\normalsize\\today} % Today's date (\\today) or a custom date\n\n\\begin{document}\n\\maketitle\n\n\\section{The Exponential Mechanism}\n\nSometimes, the global sensitivity of a function is too great, so the Laplace mechanism will not produce meaningful results. The median is one such function. In many cases, the \\textit{Exponential mechanism} is an alternate approach that gives reasonable utility.\\footnote{This is not the \\textit{only} advantage of the exponential mechanism. It is a way to compute differentially private queries on non-numeric data, unlike the Laplace mechanism it does not assume that the probability of outputting a response ought to be symmetric about the true response, etc.} Introduced in 2007 by McSherry and Talwar, the exponential mechanism posits that for a given database, users prefer some outputs over others. That those preferences may be encapsulated with a utility score, where a high utility score indicates a higher preference for that output. The exponential mechanism releases outputs with probability proportional (in the exponent) to the utility score and the sensitivity of the utility function. \n\n\\begin{definition}  \nLet $\\mathcal{X}$ be a space of databases and let $[m,M]$ be an arbitrary range. Let $u: \\mathcal{X} \\times [m,M] \\rightarrow \\mathbb{R}$ be a utility function, which maps pairs of databases and outputs to a utility score. Let $\\Delta u$ be the sensitivity of $u$ with respect to the database argument. The exponential mechanism outputs $r \\in [m,M]$ with probability proportional to $\\exp\\left(\\frac{\\varepsilon u(x,r)}{2 \\Delta u}\\right)$ \\cite{mcsherry2007mechanism, dwork2014algorithmic}.\\footnote{The original definition is from \\cite{mcsherry2007mechanism}, but here we state the version rewritten in \\cite{dwork2014algorithmic} as it is slightly clearer.}\n\\end{definition}\n\n\\begin{theorem}\nThe exponential mechanism preserves $(\\varepsilon,0)$-differential privacy \\cite{mcsherry2007mechanism, dwork2014algorithmic}.\\footnote{As written in \\cite{mcsherry2007mechanism}, the mechanism actually preserves $(2\\varepsilon\\Delta u,0)$-differential privacy; the main difference in the $\\cite{dwork2014algorithmic}$ version is that it has the extra factor of $2\\Delta u$ to avoid these extra terms.}\n\\end{theorem}\n\nNote that the exponential mechanism may not be tractable in many cases, as it assumes the existence of a utility function, and even if one exists it may not be tractable to compute it efficiently. \n\n\\section{An Exponential Mechanism for a quantile}\n\n\\subsection{Defining a sensible utility function}\n\nNote that a user will prefer an output that is closer to the true quantile over one that is further away. Let $x$ be an (ordered) data set, let $r$ be a possible output, and let $N$ be the size of the data set. Let $\\#(Z>r)$ refer to the number of points in $x$ above $r$. Then, the following is a reasonable utility function for a release $r$ for the $\\alpha$-quantile of $x$.\n\n\\begin{equation}\nu(x,r) = \\max(\\alpha, (1-\\alpha))N - \\vert (1-\\alpha)\\#(Z<r) - \\alpha\\#(Z>r)\\vert.\n\\end{equation} \n\n\\subsection{Sensitivity of the utility function}\n\n\\subsubsection{Neighboring Definition: Change One}\n\\begin{lemma}\nThe above utility function $u$ has $\\ell_11$ sensitivity bounded above by 1 in the change one model.\n\\end{lemma}\n\n\\begin{proof}\nLet $c_1 = \\#(Z<r)$ and $c_2 = \\#(Z>r)$. In one worst case, $c_1$ increases by 1 and $c_2$ decreases by 1.\nThen, \n\\begin{align*}\n\\Delta u &= \\vert (1-\\alpha) (c_1 + 1) - \\alpha (c_2-1) \\vert - \\vert (1-\\alpha) c_1 - \\alpha c_2 \\vert  \\\\\n &\\le \\vert (1-\\alpha) (c_1 + 1) - \\alpha (c_2-1) - (1-\\alpha) c_1 + \\alpha c_2 \\vert\\\\\n & \\le \\vert c_1 + 1 - \\alpha c_1 - \\alpha - \\alpha c_2 + \\alpha - c_1 + \\alpha c_1 + \\alpha c_2 \\vert\\\\\n&= 1\n\\end{align*}\nIf instead $c_2$ decreases by 1 and $c_1$ increases by 1, the same thing will happen except with a negative sign that will not impact the final result due to the absolute values.\n\\end{proof}\n\\subsubsection{Neighboring Definition: Add/Drop One}\n\n\\begin{lemma}\nThe above utility function $u$ has $\\ell_11$ sensitivity bounded above by $\\max(1-\\alpha, \\alpha)$ in the add/drop one model.\n\\end{lemma}\n\n\\begin{proof}\nLet $c_1 = \\#(Z<r)$ and $c_2 = \\#(Z>r)$.  Consider what happens if one point is added. There are two cases that would impact the utility function: \n\\begin{enumerate}\n\\item $c_1$ increases by one and nothing happens to $c_2$.\n\\item $c_2$ increases by one and nothing happens to $c_1$.\n\\end{enumerate}\n\nSay the first case occurs. Then,\n\n\\begin{align*}\n\\Delta u &= | (1-\\alpha) (c_1 + 1) - \\alpha (c_2) | - | (1-\\alpha) c_1 - \\alpha c_2 |  \\\\\n \t&\\le | (1-\\alpha) (c_1 + 1) - \\alpha (c_2) - (1-\\alpha) c_1 + \\alpha c_2 | \\\\\n\t&= 1 - \\alpha\n\\end{align*}\n\nIn the second case,\n\n\\begin{align*}\n\\delta u &= \\vert (1-\\alpha) (c_1) - \\alpha (c_2 + 1) \\vert - \\vert (1-\\alpha) c_1 - \\alpha c_2 \\vert \\\\\n\t&\\le \\vert c_1 -\\alpha c_1 - \\alpha c_2 - \\alpha - c_1 + \\alpha c_1 + \\alpha c_2  \\vert\\\\\n\t&= \\alpha \n\\end{align*}\n\\end{proof}\n\nSubtracting a point leads to the same results. \n\n\\bibliographystyle{alpha}\n\\nocite{*}\n\\bibliography{expMechMedian}\n\\end{document}", "meta": {"hexsha": "34193e252f7563c11508ba15cf4dc9b8e943359b", "size": 5913, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "whitepapers/mechanisms/ExponentialMechForMedian.tex", "max_stars_repo_name": "amanjeev/whitenoise-core", "max_stars_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "whitepapers/mechanisms/ExponentialMechForMedian.tex", "max_issues_repo_name": "amanjeev/whitenoise-core", "max_issues_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "whitepapers/mechanisms/ExponentialMechForMedian.tex", "max_forks_repo_name": "amanjeev/whitenoise-core", "max_forks_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.8557692308, "max_line_length": 1002, "alphanum_fraction": 0.7075934382, "num_tokens": 1733, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.44729579882189874}}
{"text": "\nThe following text is reprinted from \\href{https://doi.org/10.21105/joss.00797}{Whalley, L. D. (2018). effmass: An effective mass package. \\textit{Journal of Open Source Software}, 3(28), p.797.} © 2018 CC-BY \n\n\\subsection*{Summary}\n\\label{sec:summary}\n\nMany semiconductor properties depend on the response of electrons to an external perturbation. This perturbation could take the form of an electric field, change in temperature or an applied lattice stress. In a crystal, this response depends on the interaction of the electrons with a periodic potential. The effective mass approximation assumes that the response of an electron in a periodic potential is equivalent to that of a free electron with a renormalised mass (called the `effective mass'). This makes the effective mass a critical parameter in models for the optical and transport properties of a semiconductor.\n\nThe effective mass has a number of definitions, depending on the perturbation under consideration. The conventional definition of effective mass is inversely proportional to the second derivative of electron energy with respect to electron momentum.\\autocite[p.~227]{Ashcroft1976} This allows the effective mass to be easily calculated from ab-initio band structures, and there are existing codes which have implemented this (see the `Related packages' Section below).\n\nWe must approximate the band structure with a parabola for the previous definition to be valid.\\autocite{Ariel2012} However, this approximation breaks down when there is a high concentration of electrons in the material - when, for example, the material is doped or excited under a laser. Instead, we can then approximate the band structure with the Kane quasi-linear dispersion,\\autocite{Kane1957} and the definition of effective mass is adapted accordingly.\n\n\\textsc{effmass} is a Python 3 package for calculating various definitions of effective mass from the electronic bandstructure of a semiconducting material. It contains a core class that calculates the effective mass and other associated properties of selected band structure segments. effmass also contains functions for locating band structure extrema, calculating the Kane quasi-linear dispersion parameters and plotting approximations to the true dispersion. Parsing of electronic structure data is facilitated by the \\textsc{vasppy} package.\\autocite{Morgan2018}\n\n\\textsc{effmass} is aimed towards theoretical solid state physicists and chemists who have a basic familiarity with Python. Depending on the functionality and level of approximation you are looking for, it may be that one of the packages listed below will suit your needs better.\n\n\\subsection*{Related packages}\n\\label{sec:related}\n\nEffective mass calculations are implemented in a number of other packages:\n\\begin{itemize}\n    \\item \\textsc{vasppy} \\cite{Morgan2018}: This is installed as a dependancy of effmass. Calculates the effective mass using a least-squares quadratic fit for parabolic dispersions.\n    \\item \\textsc{sumo} \\cite{Ganose2018}: Calculates the effective mass using a least-squares fit for parabolic and non-parabolic dispersions.\n    \\item \\textsc{emc} \\cite{Fornari2012}: Calculates the effective mass tensor using a finite-difference method for parabolic dispersions.\n    \\item \\textsc{pymatgen} \\cite{Ong2013}: This is installed as a dependancy of effmass. Calculates an average effective mass tensor for non-parabolic dispersions with multiple bands and extrema. Also calculates the Seebeck effective mass as defined here.\n\\end{itemize}\n\n\\subsection*{Unique features of \\textsc{effmass}}\n\\label{sec:unique}\n\nTo our knowledge, the following features are unique to this package:\n\\begin{itemize}\n    \\item Easily compare the values of curvature effective mass calculated using multiple numerical techniques (least-squares and polynomial fitting)\n    \\item Tailor the polynomial fitting used to approximate the DFT calculated dispersion: by choosing the order of the polynomial and the energy range to fit over.\n    \\item Visualise the dispersions used to approximate the DFT calculated dispersion\n    \\item Quantify non-parabolicity through the Kane dispersion parameters: effective mass at band-edge and alpha\n    \\item Calculate the optical effective mass assuming a Kane dispersion.\n\\end{itemize}\n\n\\textbf{Acknowledgements}\n\nLW would like to thank Aron Walsh, Benjamin Morgan and Jarvist Moore Frost for their guidance during this project. This package was written during a PhD funded by the EPSRC through the Centre for Doctoral Training in New and Sustainable Photovoltaics (grant no. EP/L01551X/1). The input data used for developing and testing this package was generated using the ARCHER UK National Supercomputing Service. We have access to Archer via our membership of the UK's HEC Materials Chemistry Consortium, which is funded by EPSRC (EP/L000202).\n\n\n", "meta": {"hexsha": "b88daee412d07ec7a0fab94f154c6a8f31c58cb2", "size": 4867, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/appendix-1.tex", "max_stars_repo_name": "lucydot/PhD_thesis", "max_stars_repo_head_hexsha": "2af388cb5051b3f675601a3ccf1b328eaed12b59", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "text/appendix-1.tex", "max_issues_repo_name": "lucydot/PhD_thesis", "max_issues_repo_head_hexsha": "2af388cb5051b3f675601a3ccf1b328eaed12b59", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/appendix-1.tex", "max_forks_repo_name": "lucydot/PhD_thesis", "max_forks_repo_head_hexsha": "2af388cb5051b3f675601a3ccf1b328eaed12b59", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 108.1555555556, "max_line_length": 622, "alphanum_fraction": 0.8101499897, "num_tokens": 1041, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4472957925075865}}
{"text": "\n    \\documentclass{article}\n    \\usepackage{amsfonts}\n    \\usepackage{amsmath,multicol,eso-pic}\n    \\begin{document}\n    \\title{Algebra 101 worksheet 1} \n \\date{\\vspace{-5ex}} \n \\maketitle\n\n        \\section{Linear equations}\n        Solve the following equations for the specified variable.\n        \\begin{multicols}{1}\n        \\begin{enumerate}\n        \\item Solve for $a$ : $$H a + 5 = 14 a + g$$\n\\item Solve for $N$ : $$N S + 5 = N w - 11$$\n\\item Solve for $A$ : $$A E - 4 = 6 A + h$$\n\\item Solve for $w$ : $$6 w + z = 21 w + 23$$\n\\item Solve for $b$ : $$K + 23 b = Y b + 5$$\n\\item Solve for $M$ : $$M S - 4 = 4 M + 6$$\n\\item Solve for $y$ : $$X y + z = T y + V$$\n\\item Solve for $p$ : $$- 2 p + 18 = Q p + 12$$\n\\item Solve for $p$ : $$g - 5 p = V + p t$$\n\\item Solve for $H$ : $$E H + 20 = H u + y$$\n\\item Solve for $M$ : $$M R - 10 = M k + R$$\n\\item Solve for $M$ : $$- 26 M + 9 = M j + b$$\n\\item Solve for $V$ : $$P + S V = Q V + X$$\n\\item Solve for $P$ : $$- 10 P + e = - 23 P + 1$$\n\\item Solve for $g$ : $$- 14 g + 16 = - 21 g - 21$$\n\\item Solve for $K$ : $$- 23 K + S = K T - 6$$\n\\item Solve for $d$ : $$Q - 10 d = N d - 24$$\n\\item Solve for $D$ : $$8 D - 5 = D m + 22$$\n\\item Solve for $E$ : $$E q + y = - 5 E + 2$$\n\\item Solve for $r$ : $$r x + 10 = c - 5 r$$\n        \\end{enumerate}\n        \\end{multicols}\n        \n\n        \\section{Quadratic equations}\n        Solve the following quadratic equations.\n        \\begin{multicols}{1}\n        \\begin{enumerate}\n        \\item $$4 y^{2} = - 15 y - 10$$\n\\item $$9 x^{2} = 19 x + 11$$\n\\item $$x^{2} - 13 x - 230 = 0$$\n\\item $$2 y^{2} - 8 = y + 14$$\n\\item $$2 x^{2} + 22 x = 3 x^{2}$$\n\\item $$- 16 x^{2} + 16 x - 23 = - 3 x^{2} + 2$$\n\\item $$x^{2} - 8 x - 20 = 0$$\n\\item $$- 7 x^{2} - 1 = 15 x^{2} + 2 x - 15$$\n\\item $$- 8 x^{2} - 24 x = - 13 x^{2}$$\n\\item $$- 7 y^{2} - 25 y = 3 y^{2} - 14 y + 23$$\n\\item $$- 3 x^{2} = 12 x^{2} - 4 x$$\n\\item $$x^{2} - 27 x + 180 = 0$$\n\\item $$y^{2} - 8 y + 12 = 0$$\n\\item $$x^{2} - 6 x - 391 = 0$$\n\\item $$x^{2} + 8 x + 7 = 0$$\n\\item $$x^{2} + 18 x + 65 = 0$$\n\\item $$- 20 x^{2} + 5 x - 21 = - 24 x^{2}$$\n\\item $$- 21 x^{2} + 20 x + 15 = 10 x$$\n\\item $$- 11 y^{2} = - 24 y^{2} + 25 y + 8$$\n\\item $$4 x^{2} + 10 x = 14 x$$\n        \\end{enumerate}\n        \\end{multicols}\n        \n\n        \\section{Compute the derivative}\n        ['x', 'y', 'z']\n        \\begin{multicols}{1}\n        \\begin{enumerate}\n        \\item $$\\frac{d}{d x}\\left(\\frac{1}{x} \\left(7 x^{2} + 12 x - 24\\right)\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{2 \\sqrt{x}}{- 9 x^{3} + 18 x + 7}\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{\\log{\\left (x \\right )} + \\tan{\\left (x \\right )}}{16 x^{3} - 23 x^{2} + 5 x}\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\left(e^{x} + \\tan{\\left (x \\right )}\\right) e^{- x}\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\left(19 x + e^{x}\\right) e^{- x}\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{1}{x} \\left(24 x^{2} + 7 x + \\cos{\\left (x \\right )}\\right)\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{1}{\\tan{\\left (x \\right )}} \\left(\\log{\\left (x \\right )} + \\sin{\\left (x \\right )}\\right)\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{1}{x} \\left(4 x^{3} + \\log{\\left (x \\right )} - 17\\right)\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\frac{1}{\\sin{\\left (x \\right )}} \\left(- 17 x^{3} + 24 x^{2} + 14 x + \\log{\\left (x \\right )} - 14\\right)\\right)$$\n\\item $$\\frac{d}{d x}\\left(\\left(\\sqrt{x} + \\log{\\left (x \\right )}\\right) e^{- x}\\right)$$\n        \\end{enumerate}\n        \\end{multicols}\n        \n\n    \\end{document}\n    ", "meta": {"hexsha": "a75dc09c05b074cfd661f26e12f5da9797a6e2e0", "size": 3486, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "algebra1.tex", "max_stars_repo_name": "luisromero87/mathexamgen", "max_stars_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "algebra1.tex", "max_issues_repo_name": "luisromero87/mathexamgen", "max_issues_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "algebra1.tex", "max_forks_repo_name": "luisromero87/mathexamgen", "max_forks_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0117647059, "max_line_length": 142, "alphanum_fraction": 0.4744693058, "num_tokens": 1569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4472957850050581}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 19.1 System Parameters\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese subprograms provide values of various system parameters that\nare needed in library subprograms and typically have different values\non different computer systems.  ``F. Supporting Information'' below\nhas instructions for customizing these programs for your system.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype}\n\n\\begin{description}\n\\item[REAL]  \\ {\\bf R1MACH, S}\n\n\\item[DOUBLE PRECISION]  \\ {\\bf D1MACH, D}\n\n\\item[INTEGER]  \\ {\\bf I1MACH, I, J}\n\\end{description}\n\nSet J in the range 1 $\\leq $ J $\\leq $ 5 for R1MACH or D1MACH or 1 $\\leq $ J\n$\\leq $ 16 for I1MACH. Then, use the appropriate one of the following\nstatements:\n$$\n\\fbox{{\\bf S = R1MACH(J)}}\n$$\n$$\n\\fbox{{\\bf D = D1MACH(J)}}\n$$\n$$\n\\fbox{{\\bf I = I1MACH(J)}}\n$$\nThe results, S, D, or I are set as described in Section D.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\\item[J]  \\ [in] Integer argument selecting the desired system parameter as\ndescribed in Section D.\n\\end{description}\n\n\\subsection{Examples and Remarks}\n\nThe program DRMACH lists all the values obtainable from R1MACH, D1MACH, and\nI1MACH on the host computer system. Output is shown from several different\nhost systems.\n\n\\subsection{Functional Description}\n\nFor the purpose of this package a model of the Fortran~77 INTEGER, REAL, and\nDOUBLE PRECISION number sets is characterized by a total of nine fundamental\nparameters.\n\nThe model of Fortran~77 numbers of type INTEGER is parameterized by two\nnumbers, $a$ and $s$, where $a$ denotes the base (radix) of the number\nsystem and $s$ denotes the maximum number of base $a$ digits available to\nrepresent a Fortran integer. Thus the integers range from $-(a^s -1)$ to $%\na^s -1.$\n\nThe model of Fortran~77 numbers of type REAL is characterized by four\nparameters, $b$, $t$, $emin$, and $emax$, where $b$ is the base of the\nfraction part, $t$ is the number of base $b$ digits in the fraction part, $%\nemin $ is the minimum exponent and $emax$ is the maximum exponent. The\nmagnitude of a floating-point number is thus of the form%\n\\begin{equation*}\nb^e\\left( c_1b^{-1}+c_2b^{-2}+...+c_tb^{-t}\\right) ,\n\\end{equation*}\nwhere, $emin\\leq e\\leq emax$, and the digits $c_i$ satisfy $0\\leq c_i\\leq\nb-1.$ A nonzero floating-point number is normalized if and only if the digit\n$c_1$ is nonzero. We shall consider only normalized floating-point numbers,\nalthough numeric processors based on the IEEE standard also support a\nrange of unnormalized numbers.\n\nFortran~77 numbers of type DOUBLE PRECISION are modeled in the same form as\nREAL numbers and are assumed to have the same base, $b$, but generally\ndifferent values of $t$, $emin$, and $emax$.\n\nFor some computer systems no setting of these parameters will make the model\nsystem coincide exactly with the actual computer's number set. In such cases\nthe model parameters are selected so the model system will be as large a\nsubset of the actual number set as possible. In particular, for Cray\nX/MP and Y/MP (but not T3D) systems the parameters $t$ and $emax$ are set\nsmaller and $emin$ is set larger than one might expect from the structure\nof floating-point numbers on these systems. The reasons for this are\ndescribed in \\cite{Schryer:1981:ATO}.\n\nThe values returned by this package are either prestored constants or are\ncomputed at compile-time from prestored constants by use of expressions in\nPARAMETER statements. Thus correct values must be determined and edited into\nthe package whenever this package is moved to a new computer system. Correct\nvalues for many systems are present as comments in the source code.\n\nOn some systems, the Fortran compiler may not be able to compute\nnumbers in the full range of the model, in PARAMETER statements (this\ndisease usually strikes computation of the overflow limit).  On such\nsystems it may be necessary to restrict the model, $e.g.$ by reducing\n$emax$.\n\n{\\bf Specification of Values Returned}\n\\begin{itemize}\n\\item[\\bf J]  {\\hspace{.5in} {\\bf I1MACH (J)}}\n\\item[1]  Standard input unit number.\n\\item[2]  Standard output unit number.\n\\item[3]  Standard punch unit number.\n\\item[4]  Standard error message unit number.\n\\item[5]  Number of bits per Fortran integer storage unit.\n\\item[6]  Number of characters per Fortran integer storage unit.\n\\item[7]  $a$, the base for integers.\n\\item[8]  $s$, the number of base $a$ digits in an integer.\n\\item[9]  $a^s-1$, the largest integer magnitude.\n\\item[10]  $b$, the base for floating-point numbers. Assumed the same for\nREAL and DOUBLE PRECISION arithmetic.\n\\item[11]  $t$, the number of base $b$ digits for REAL arithmetic.\n\\item[12]  $emin$, minimum exponent for REAL arithmetic.\n\\item[13]  $emax$, maximum exponent for REAL arithmetic.\n\\item[14]  $t$, the number of base $b$ digits for DOUBLE PRECISION\narithmetic.\n\\item[15]  $emin$, minimum exponent for DOUBLE PRECISION arithmetic.\n\\item[16]  $emax$, maximum exponent for DOUBLE PRECISION arithmetic.\n\\end{itemize}\n\\begin{itemize}\n\\item[\\bf J]  {\\hspace{.5in} {\\bf R1MACH(J)}}\n\\item[1]  $b^{emin-1}$ smallest positive normalized REAL number,\n(underflow limit).\n\\item[2]  $b^{emax}(1-b^{-t})$, largest REAL number, (overflow limit).\n\\item[3]  $b^{-t}$, smallest relative difference between two successive\nnonzero REAL numbers. This is also the difference between~1.0 and the next\nsmaller REAL number.\n\\item[4]  $b^{-(t-1)}$ largest relative difference between two successive\nnonzero REAL numbers. This is also the difference between~1.0 and the next\nlarger REAL number.\n\\item[5]  $\\log _{10}b$, useful in certain conversions between base $b$ and\nbase~10.\n\\end{itemize}\nThe values returned by D1MACH are as described above for R1MACH with REAL\nreplaced by DOUBLE PRECISION.\n\n\\subparagraph{Historical perspective and relations to other languages}\n\nThe specifications of R1MACH, D1MACH, and I1MACH and the original\nimplementation were developed at the AT\\&T Bell Laboratories, Murray Hill,\nNew Jersey, in the~1970's to support the development of portable\nmathematical software, and specifically the PORT library,\n\\cite{Fox:1978:PMS}, which is a proprietary AT\\&T Bell Laboratories\nproduct.  These three subprograms were published as a subset of\nAlgorithm~528 in TOMS,~\\cite{Fox:1978:AFP}, and are not proprietary.  The\nMATH77 version has the same specification but is substantially different\nin its implementation from the original versions.\n\nThe attributes associated with J = 1, 2, 3, 4, and~6 in I1MACH are less\nrelevant in Fortran~77 in the~90's than they were in Fortran~66 in the~70's.\nIn particular, only the DNLxxx and SNLxxx subroutines of\nChapter~9.3 access I1MACH(2).\n\nOther MATH77 library subprograms use PRINT or WRITE(*,...) for printing.\n\nLanguages developed more recently than Fortran~77, such as Ada, ANSI C, and\nFortran~90, provide methods within the language to obtain certain\nenvironmental parameters. Consider, for example, the underflow and overflow\nlimits, and precision for floating-point arithmetic. Using the present\npackage, these can be obtained for DOUBLE PRECISION arithmetic by\nreferencing D1MACH(1), D1MACH(2), and D1MACH(4), respectively, and for REAL\narithmetic by referencing R1MACH(1), R1MACH(2), and R1MACH(4). In Fortran~90\nthese parameters can be obtained by referencing the generic inquiry\nfunctions TINY(X), HUGE(X), and EPSILON(X), where X may be any DOUBLE\nPRECISION entity to obtain the values for DOUBLE PRECISION arithmetic, and\nany REAL entity to obtain the values for REAL arithmetic. In ANSI C these\nvalues for arithmetic of type $double$ are given by the macro names DBL\\_MIN,\nDBL\\_MAX, and DBL\\_EPSILON, for type $float$ there are FLT\\_MIN, FLT\\_MAX,\nand FLT\\_EPSILON, and for type $long\\ double$ LDBL\\_MIN, LDBL\\_MAX, and\nLDBL\\_EPSILON.  All of these are defined in the standard\nheader file $float.h$.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nIf the argument is outside the range 1\\ $\\leq $ J $\\leq $ 16 for I1MACH or\noutside 1 $\\leq $ J $\\leq $ 5 for R1MACH or D1MACH, an error message is\nprinted and execution is terminated.\n\nThis package contains a partial protection against the inadvertent use of\nthe wrong version of one of these subroutines; say using the PC version on a\nVAX. On the first call to any one of these subprograms, tests are done to\nverify that two of the stored parameter values are not grossly wrong for the\ncurrent environment. These tests depend on assumptions about hardware,\ncompilers, and linkers that may be invalidated by technological changes.\nSubroutines AMTEST and AMSUB1 are used to support these tests and are not\nintended for any other usage.\n\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77. All the program units are\ngrouped into a single file, AMACH.FOR. The filename may be different\non different systems, $e.g.$, ``amach.f\" on UNIX systems.\n\nOne can either customize AMACH for a new system by commenting out\nlines defining the parameters required for the system as it is\ncurrently configured, and uncommenting lines required for the desired\nsystem, or one can use the program {\\tt m77con} described in\nChapter~19.4.  This requires making up a small control file {\\tt\nm77job}, and compiling, linking, and running {\\tt m77con}, which is\nself contained.  To make up {\\tt m77job} for a VAX running UNIX, the\ncontrol file would contain the following.\n\n{\\tt SET SYS = VAX\\newline\nFILE amach.f}\n\nRunning {\\tt m77con} with this control file and amach in the current\ndirectory will generate a file {\\tt amach.f} for the VAX.  If one\nwants the extension ``{\\tt .for}'' change the {\\tt h.f} to {\\tt\nh.for}.  If one wants a machine other than the VAX, choose a value\nfor SYS (without any parenthetical remark) from the following table.\n{\\tt SYS=IEEE} covers any machine that uses the IEEE binary standard\nfor floating point arithmetic.  If your machine is not included in\nthis list, either pick a machine with the same parameters for the\nfloating point arithmetic as for a machine on this list, or enter\nparameters for your machine as a new option into AMACH.\n\n\\begin{tabbing}\n{\\tt SYS = IEEE}\\\\\n{\\tt SYS = AMDAHL}\\\\\n{\\tt SYS = APOLLO\\_10000}\\\\\n{\\tt SYS = BUR1700}\\\\\n{\\tt SYS = BUR5700}\\\\\n{\\tt SYS = BUR67\\_7700}\\\\\n{\\tt SYS = CDC60\\_7000}\\\\\n{\\tt SYS = CONVEXC\\_1}\\\\\n{\\tt SYS = CRAY1}\\\\\n{\\tt SYS = CRAY1\\_SD}\\hspace{30pt}\\=(Sngl prec.arith. used for dble.)\\\\\n{\\tt SYS = CRAY1\\_64}\\>(64 bit integers)\\\\\n{\\tt SYS = CRAY1\\_SD\\_64}\\>(64 bit int, SP used for DP)\\\\\n{\\tt SYS = CRAY\\_J90}\\\\\n{\\tt SYS = CRAY\\_J90\\_SD}\\>(Sngl prec. used for dble.)\\\\\n{\\tt SYS = DG\\_S2000}\\\\\n{\\tt SYS = HARRIS220}\\\\\n{\\tt SYS = HON600\\_6000}\\\\\n{\\tt SYS = HON\\_DPS\\_8\\_70}\\\\\n{\\tt SYS = HP700Q}\\>(Q Precision on HP700 series)\\\\\n{\\tt SYS = IBM360\\_370}\\\\\n{\\tt SYS = INTERDATA\\_8\\_32}\\\\\n{\\tt SYS = PDP10\\_KA}\\\\\n{\\tt SYS = PDP10\\_KB}\\\\\n{\\tt SYS = PDP11}\\\\\n{\\tt SYS = PRIME50}\\\\\n{\\tt SYS = SEQ\\_BAL\\_8000}\\\\\n{\\tt SYS = UNIVAC}\\\\\n{\\tt SYS = VAX}\\\\\n{\\tt SYS = VAX\\_G}\\\\\n{\\tt SYS = ALPHA\\_D3}\n\\end{tabbing}\n\nDesigned and programmed by P.A. Fox, A.D. Hall, and N.L. Schryer, AT\\&T Bell\nLaboratories, 1978. Adapted to the JPL MATH77 library, 1984 and~1987.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.2in} {\\bf Required Files}\\vspace{2pt} \\\\\nD1MACH & \\hspace{.35in} AMACH\\\\\nI1MACH & \\hspace{.35in} AMACH\\\\\nR1MACH & \\hspace{.35in} AMACH\\\\\\end{tabular}\n\n\n\\begcode\n\n\\medskip\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRMACH}\\vspace{0pt}\n\\lstinputlisting{\\codeloc{mach}}\n\n\\centerline{{\\bf \\large Results from Various Machines\\hspace{1in}}}\n\n\\begin{lstlisting}{}\n\n              MACHINE CONSTANTS for IEEE Arithmetic\n              -----------------------------------------\n J      I1MACH(J)       R1MACH(J)             D1MACH(J)\n\n 1              5    0.11754944E-37    0.222507385850720100-307\n 2              6    0.34028235E+39    0.179769313486231600+309\n 3              7    0.59604645E-07    0.111022302462515700E-15\n 4              6    0.11920929E-06    0.222044604925031300E-15\n 5             32    0.30103001        0.301029995663981200\n 6              4\n 7              2\n 8             31\n 9     2147483647\n10              2\n11             24\n12           -125\n13            128\n14             53\n15          -1021\n16           1024\n\\end{lstlisting}\n\n\\begin{lstlisting}{}\n\n\n              MACHINE CONSTANTS for VAX\n              -----------------------------------------\n J      I1MACH(J)       R1MACH(J)             D1MACH(J)\n 1              5    0.29387359E-38    0.293873587705571877E-38\n 2              6    0.17014117E+39    0.170141183460469229E+39\n 3              7    0.59604645E-07    0.138777878078144568E-16\n 4              6    0.11920929E-06    0.277555756156289135E-16\n 5             32    0.30103001        0.301029995663981198\n 6              4\n 7              2\n 8             31\n 9     2147483647\n10              2\n11             24\n12           -127\n13            127\n14             56\n15           -127\n16            127\n\\end{lstlisting}\n\n\\newpage\n\\begin{lstlisting}{}\n\n              MACHINE CONSTANTS for CRAY J90\n              -----------------------------------------\n J      I1MACH(J)       R1MACH(J)             D1MACH(J)\n 1              5    0.73344155-2465   0.733441547021938866-2465\n 2              6    0.13634352+2466   0.136343516952426991+2466\n 3            102    0.71054274E-14    0.504870979341447555E-28\n 4              6    0.14210855E-13    0.100974195868289511E-27\n 5             64    0.30103000        0.301029995663981195\n 6              8\n 7              2\n 8             46\n 9 70368744177663\n10              2\n11             47\n12          -8188\n13           8189\n14             94\n15          -8188\n16           8189\n\n\n\n              MACHINE CONSTANTS for UNISYS 1100\n              -----------------------------------------\n J      I1MACH(J)       R1MACH(J)             D1MACH(J)\n 1              5     .14693679-038     .278134232313400172-308\n 2              6     .17014118+039     .898846567431157951+308\n 3              7     .74505806-008     .867361737988403547-018\n 4              6     .14901161-007     .173472347597680709-017\n 5             36     .30103000         .301029995663981194\n 6              4\n 7              2\n 8             35\n 9    34359738367\n10              2\n11             27\n12           -128\n13            127\n14             60\n15          -1024\n16           1023\n\\end{lstlisting}\n\\end{document}\n", "meta": {"hexsha": "65859d81db4fbe20fe8581b109b32afaffe5b8bb", "size": 14637, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch19-01.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch19-01.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch19-01.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 38.9281914894, "max_line_length": 98, "alphanum_fraction": 0.6853180297, "num_tokens": 4358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018545, "lm_q2_score": 0.7185943805178138, "lm_q1q2_score": 0.4472957775025293}}
{"text": "\\graphicspath{{Chapter2/Figs/}}\n\n\\section{Model validation with simulated data} \\label{section:mofa_simulated}\n\nWe used simulated data from the generative model to systematically test the technical capabilities of MOFA.\n\n\\subsection{Recovery of simulated factors}\n\nFirst, we tested the ability of MOFA to recover simulated factors under varying number of views, features, factors and with different amounts of missing values.\\\\ \nFor every simulation scenario we initialised a model with a high number of factors ($K=100$), and inactive factors were automatically dropped during model training by the ARD prior. In addition, to test the robustness under different random initialisations, 10 model instances were trained for every simulation scenario.\\\\\nWe observe that in most settings the model accurately recovers the correct number of factors (\\Cref{fig:MOFA_learnK}). Exceptions occur when the dimensionality of the latent space is too large (more than 50 factors) or when an excessive amount of missing values (more than 80\\%) is present in the data.\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.9\\textwidth]{MOFA_learnK}\n\t\\caption{\\textbf{Assessing the ability to recover simulated factors}.\\\\\n\tIn all plots the y-axis displays the number of infered factors. (a) x-axis displays the number of true factors, and boxplots summarise the distribution of inferred factors across 10 model instances. For (b-d) the true number of factors was set to $K=10$ and each bar corresponds to a different model instance. (b) x-axis displays the number of features, (c) x-axis displays the number of views, (d) x-axis displays fraction of missing values. }\n\t\\label{fig:MOFA_learnK}\n\\end{figure}\n\n\\subsubsection{View-wise sparsity on the weights}\n\nOne of the essential features of MOFA is the use of an ARD prior aimed at disentangling the activity of factors across views (see \\Cref{section:ard} and \\Cref{mofa:model_description}).\\\\\nWe simulated data from the generative model such that the factors were set to be active or inactive in specific views by sampling $\\alpha_{k}^{m}$ from a discrete distribution with values $\\{ 1, 1e3\\}$. We compared the performance with a popular integrative clustering method (iCluster) that is also formulated as a latent variable model \\cite{Mo2013}. In iCluster each factor shares the same sparsity constraint across all views, and hence the model is less accurate at detecting factors that show differential activity across different views:\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.9\\textwidth]{MOFA_group_sparsity}\n\t\\caption{\\textbf{Evaluating the ability to recover differential factor activity across views}.\\\\\n\t(a) The true activity pattern, with factors sampled to display differential activity across views.\n\t(b) Percentage of variance explained for each factor in each view, for MOFA and iCluster \\cite{Mo2013}.}\n\t\\label{fig:MOFA_group_sparsity}\n\\end{figure}\n\n\\subsubsection{Feature-wise sparsity on the weights} \\label{section:spike_slab}\n\nIn MOFA we implemented a spike-and-slab prior prior to enforce feature-wise sparsity on the weights with the aim of delivering a more interpretable solution (see \\Cref{section:mofa_weights}).\\\\\nTo assess the effect of the spike-and-slab prior we trained a group of models with and without the spike-and-slab prior. Importantly, both models contain the ARD prior, which should provide some degree of regularisation. To compare both options to a non-sparse method, we also fit a Principal Component Analysis on the concatenated data set. As expected, we observe that the spike-and-slab prior induces more zero-inflated weights, although the ARD prior provided a moderate degree of regularisation. The PCA solution was notably more dense than both Bayesian models (\\Cref{fig:MOFA_sparsity}).\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.7\\textwidth]{MOFA_sparsity}\n\t\\caption{\\textbf{Assessing the sparsity priors on the weights}.\\\\ \n\tThe plot shows the empirical cumulative density function of the weights for an arbitrary factor in a single view. The weights were simulated with a sparsity level of $\\theta_k^m=0.5$ (50\\% of active features.)\n\t}\n\t\\label{fig:MOFA_sparsity}\n\\end{figure}\n\n\n\\subsection{Non-Gaussian likelihoods}  \\label{section:mofa_nongaussian_results}\n\nA key improvement of MOFA with respect to previous methods is the use of non-Gaussian likelihoods to integrate data modalities with different types of readouts. In particular, as described in \\Cref{section:mofa_ngaussian}, we implemented a Bernoulli likelihood to model binary data and a Poisson likelihood to model count data.\\\\\nTo validate both likelihood models, we simulated binary and count data using the generative model and we fit two sets of models for each data type: a group of models with a Gaussian likelihood and a group of models with a Bernoulli or Poisson likelihood, respectively.\\\\\nReassuringly, we observe that although the Gaussian likelihood is also able to recover the true number of factors, the models with the non-Gaussian likelihoods result in a better fit to the data:\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.8\\textwidth]{MOFA_nongaussian}\n\t\\caption{\\textbf{Validation of the non-Gaussian likelihood models using simulated data}.\\\\\n\t(a-d) Comparison of Poisson and Gaussian likelihood models applied to count data.\\\\\n\t(e-h) Comparison of Bernoulli and Gaussian likelihood models applied to binary data.\\\\\n\t(a,e) The y-axis displays the ELBO for each model instance (x-axis). (b,f) The y-axis displays the mean reconstruction error for each model instance (x-axis). (c,g) The y-axis displays the number of estimated factrors for each model instance (x-axis). The horizontal dashed line marks the true number of factors $K=10$. (d,h) Distribution of reconstructed data. Plotted are the expected values of the inferred posterior distributions, not samples from the corresponding posteriors. This is why reconstructed measurements are continuous and not discrete.\n\t}\n\t\\label{fig:MOFA_nongaussian}\n\\end{figure}\n\n\n\\subsection{Scalability}\n\nFinally, we evaluated the scalability of the model when varying each of its dimensions independently, and we compared the speed with an implementation of GFA that uses Gibbs Sampling \\cite{Leppaaho2017} and the popular Cluster+\\cite{Mo2013}, which adopts a maximum-likelihood approach with grid search to optimise the hyperparameters. Overall, we observe that MOFA scales linear with respect to all dimensions and is significantly faster than any of the three evaluated techniques (\\Cref{fig:MOFA_scalability}).\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.75\\textwidth]{MOFA_scalability}\n\t\\caption{\\textbf{Evaluation of scalability in MOFA}.\\\\\n\tShown is the time required for convergence (y-axis, in minutes). The x-axis displays the value of the dimension that was tested, either number of factors ($K$), number of features ($D$), number of samples ($N$) and number of views ($M$). Baseline parameters were $M=3, K=10, D=1000, N=100$. Each line represents a different model, GFA (red), MOFA (blue) and iCluster (green). Default convergence criteria where used for all methods. Each dot displays the average time across 10 trials with error bars denoting the standard deviation. iCluster is only shown for one value as all other settings required more than 200min for convergence.\n\t}\n\t\\label{fig:MOFA_scalability}\n\\end{figure}\n\nAs a real application showcase, the training on the CLL cohort that is described below (\\Cref{fig:MOFA_CLL_overview}) required 25 minutes using MOFA, 34 hours with GFA and 5-6 days with iCluster.\n\n% \\subsection{Class imbalance}  \\label{section:class_imbalance}\n% TO-DO.\n%The objective function (the evidence lower bound, ELBO) does not weight the different data modalities according to the number of features. Hence, in general the larger the number of features\n%Having said this, we find the model to be very robust to differences in the dimensionality of the feature space.\n\n\n\\newpage\n\n\\section{Application to a cohort of Chronic Lymphocytic Leukaemia patients} \\label{section:mofa_cll}\n\nPersonalised medicine is an attractive field for the use of multi-omics, as dissecting heterogeneity across patients is a major challenge in complex diseases, and requires data integration from multiple biological layers \\cite{Chen2013,Costello2014,Alyass2015}.\n\nTo demonstrate the potential of MOFA, we applied it to a publicly available study of 200 patient samples of Chronic Lymphocytic Leukaemia (CLL) profiled for somatic mutations, RNA expression, DNA methylation and \\textit{ex vivo} drug responses \\cite{Dietrich2018}, all of them at the bulk level. We selected this data set for three main reasons: (1) The complex missing data structure, with nearly 40\\% samples having incomplete assays (\\Cref{fig:MOFA_CLL_overview}). As described in \\Cref{section:mofa_missing_values}, the inference framework implemented in MOFA should cope with large amounts of missing values, including missing assays. (2) After data processing, three assays had continuous observations whereas for the somatic mutations the observations were binary. As described in \\Cref{section:mofa_ngaussian}, MOFA can combine different likelihood models. (3) The existence of clinical covariates provide an excellent test to evaluate whether the MOFA factors can capture the molecular variation that underlies clinically-relevant phenotypes.\n\n\\subsection{Data overview and processing}\n\nData processing and normalisation is essential for the model to work and it requires a few considerations. First, in the case of count-based assays such as RNA-seq one needs to remove differences in library size between samples. If not done correctly, the signal in the data will be dominated by this (undesired) source of variation, and more subtle heterogeneity will be harder to identify. Similarly, batch effects and other undesired technical sources of variation should be regressed out \\textit{a priori}, although this was not the case for this particular data set. Second, feature selection must be performed by selecting highly variable features. A proper feature selection will increase the signal-to-noise-ratio, it will simplify model selection and it will speed up the training procedure.  Finally, as discussed above, the total number of features can influence the contribution of a data modality to the latent space. To mitigate this problem it is recommended to keep the number of features per view within the same order of magnitude, when possible.\n\nHere we proceed to briefly describe the different data modalities and outline the basic data processing steps that we performed before applying MOFA:\n\\begin{itemize}\n\t\\item \\textbf{RNA expression} was profiled using bulk RNA-seq. Genes with low counts were filtered out and the data was subsequently normalized using DESeq2 \\cite{Love2014}. Feature selection was performed by considering the top 5,000 most variable genes.\n\t\\item \\textbf{DNA methylation} was profiled using Illumina 450K arrays. We converted the beta-values to M-values, as it has better statistical properties when modelled with a Gaussian distribution \\cite{Du2010}. Feature selection was performed by considering the top 1\\% most variable CpG sites. \n\t\\item \\textbf{\\textit{Ex vivo} Drug response} was screened using the ATP-based CellTiter-Glo assay. Briefly, the asay includes a panel of 62 drugs at 5 different concentrations each, for a total of 310 measurements. The readout is a number proportional to the fraction of viable cells in culture based on quantitation of the ATP present, which signals the presence of metabolically active cells.\n\t\\item \\textbf{Somatic mutations} were profiled using a combination of targeted and whole exome sequencing. Feature selection was performed by considering only mutations that were present in at least three samples, which resulted in a total of 69 mutations.\n\\end{itemize}\n\n% For more details on the data generation steps we refer the reader to \\cite{Dietrich2018}.\n\n\\subsection{Model overview}\n\nIn this data set, MOFA recovered $K=10$ factors, each one explaining a minimum of 3\\% of variance in at least one assay. Interestingly, MOFA detected factors which are shared across several data modalities (Factors 1 and 2, sorted by variance explained). Some factors captured sources of covariation between two data modalities (Factor 3 and 5, active in the RNA expression and drug response). In addition, some factors captured variation that is unique to a single data modality (Factor 4, active in the RNA expression data).\\\\\nAll together, the 10 MOFA factors explained 41\\% of variance in the drug response data, 38\\% in the mRNA expression, 24\\% in the DNA methylation and 24\\% in somatic mutations.\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=1.0\\textwidth]{MOFA_CLL_overview}\n\t\\caption{\\textbf{Application of MOFA to a study of chronic lymphocytic leukaemia. Model overview.}\\\\\n\t(a) Data overview. Assays are shown in different rows ($D$ = number of features) and samples ($N$) in columns, with missing samples shown using grey bars. Notice that some samples are missing entire assays.\\\\\n\t(b) Variance explained (\\%) by each Factor in each assay.\\\\\n\t(c) Total variance explained (\\%) for each assay by all factors.\n\t}\n\t\\label{fig:MOFA_CLL_overview}\n\\end{figure}\n\nThe first two factors are the most interesting from a molecular perspective, as they capture a phenotypic effect that is manifested across multiple molecular layers. To annotate Factors 1 and 2 we proceeded to visualise the feature weights, starting by the (binary) somatic mutation data, as it is the simplest data modality to interpret. Inspection of the top weights revealed that Factor 1 was associated with the mutation status of the immunoglobulin heavy-chain variable (IGHV) region, while Factor 2 was aligned with trisomy of chromosome 12 (\\Cref{fig:MOFA_CLL_factors12}).\\\\\nRemarkably, in a completely unsupervised fashion, MOFA recovered the two most important clinical markers in CLL as the two major axes of molecular disease heterogeneity \\cite{Fabbri2016,Bulian2017,Crombie2017}.\n\nNext, we visualised the samples in the latent space spanned by Factors 1 and 2. A scatterplot based on these factors shows a clear separation of patients by their IGHV status on the first Factor and presence or absence of trisomy 12 on the second Factor (\\Cref{fig:MOFA_CLL_factors12}). Interestingly, 24 patients lacked IGHV status measurements (grey crosses) due to quality control filtering in the DNA sequencing assay. Nonetheless, MOFA was able to pool information from the other molecular layers to map those samples to the latent space, and could be classified to the corresponding molecular subgroup.\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=1.0\\textwidth]{MOFA_CLL_factors12}\n\t\\caption{\\textbf{Visualisation of the genetic signature underlying Factor 1 and 2}\\\\\n\t(a) Weights of the top somatic mutations for Factors 1 and 2.\n\t(b) Scatterplots of Factors 1 and 2. Each dot corresponds to one sample and the colours denote the IGHV status of the tumours samples; symbol shape indicate chromosome 12 trisomy status.\n\t}\n\t\\label{fig:MOFA_CLL_factors12}\n\\end{figure}\n\nIGHV status is currently the most important prognostic marker in CLL and has routinely been used to distinguish between two distinct subtypes of the disease\\cite{Fabbri2016}. Molecularly, it is a surrogate of the level of activation of the B-cell receptor, which is in turn related to the differentiation state of the tumoral cells. Multiple studies have associated mutated IGHV with a better response to chemotherapy, whereas unmutated IGHV patients have a worse prognosis \\cite{Fabbri2016,Bulian2017,Crombie2017}.\\\\\nIn clinical practice, the IGHV status has been considered binary. Our results suggest that this is a fairly good approximation, but a more complex structure with at least three groups or a potential underlying continuum is supported (\\Cref{fig:MOFA_CLL_factors12,fig:MOFA_CLL_Factor1}), as also suggested in \\cite{Queiros2015}.\n\n% \\subsection{Detection of outlier samples}\n\n% Interestingly, there is some discrepancy between the IGHV status predicted by MOFA and the IGHV status reported in the clinical data. Out the 200 patients, MOFA classifies 176 in accordance with the clinical label, it classifies 12 patients that lacked the clinical marker and it re-classifies 12 patients to the opposite group.\\\\\n% To validate the MOFA-based classification, we proceeded to inspect the molecular data in more detail.\n\n% sample-to-sample correlation matrices for the individual layers suggest that for 3 of the cases where the inferred factor disagrees with the clinical label, the molecular data supports the predicted label. The other 9 cases showed intermediate molecular sgnatures now well captured by the binary classification.\n% %Based on these results, we hypothesize that a multi-omics approach based on several molecular signatures could be a more precise and robust approach to predict clinical phenotypes than the use of single features such as mutations or expression of marker genes.\n\n% \\begin{figure}[H]\n% \t\\centering \t\n% \t\\includegraphics[width=1.0\\textwidth]{MOFA_IGHV_outlier}\n% \t\\caption{XX}\n% \t\\label{fig:MOFA_IGHV_outlier}\n% \\end{figure}\n\n\\subsection{Molecular characterisation of Factor 1}\n% \\tabularnewline\n\nAn important step in the MOFA pipeline is the characterisation of the molecular signatures underlying each Factor. I will demonstrate this for Factor 1, although a similar strategy can be applied to Factor 2.\n\nOn the RNA expression, inspection of the top weights pinpoint genes that have been previously associated to IGHV status, some of which have been proposed as clinical markers\\cite{Vasconcelos2005,Morabito2015}. Heatmaps of the RNA expression levels for these genes reveals clear differences between samples when ordered according to the Factor 1 values.\n\nOn the drug response data the weights highlight kinase inhibitors targeting the B-cell receptor pathway. Splitting the patients into three groups based on k-means clustering shows clear separation in the drug response curves.\n\n% Copied\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.90\\textwidth]{MOFA_CLL_Factor1}\n\t\\caption{\n\t\\textbf{Characterization of MOFA Factor 1 as IGHV status.}\\\\\n\t(a) Beeswarm plot of Factor 1 values, where each dot corresponds to a patient sample. Colours denote three groups found by applying 3-means clustering on the Factor values.\\\\\n\t(b) Genes with the largest weights (in absolute values) in the mRNA data. Plus or minus symbols on the right indicate the sign of the weight.\\\\\n\t(c) Heatmap of gene expression values for the genes with the largest weights displayed in (b).\\\\\n\t(d) Drugs with the largest weights (in absolute values) in the Drug response data, coloured by the drug's target category.\\\\\n\t(e) Drug response curves for two of the drugs with top weights, stratified by the clusters displayed in (a).\n\t}\n\t\\label{fig:MOFA_CLL_Factor1}\n\\end{figure}\n\n\\subsection{Molecular characterisation of other factors}\n\nDespite their clinical importance, Factor 1 (IGHV status) and Factor 2 (chr12 trisomy) they explain less than 20\\% variability in each data modality, suggesting the existence of more subtle sources of variation. As an example, we will also characterise Factor 5, which explains 2\\% of the variance in the mRNA and 6\\% of variance in the drug response.\\\\\nAs mentioned in \\Cref{mofa:downstream}, instead of exploring the feature weights individually, factors can be annotated using gene set annotations. This procedure is particularly appealing for RNA expression data, as a rich amount of resources exist that have categorised genes into ontologies in terms of biological pathways, molecular function and cellular components  \\cite{Fabregat2015,Ashburner2000}.\n\nBriefly, the idea is to aggregate the weights using prior information to obtain a single statistic for each gene set, which can be tested against a competitive null hypothesis. Inspired from \\cite{Frost2015}, in MOFA we implemented several scoring schemes and a variety of parametric and unparametric statistical tests. By default we use the weights as feature statistics and the average difference in the weight values as the feature set statistic. P-values are then obtained per feature set and factor via a simple t-test.\n\nGene Set Enrichment Analysis on the RNA weights using the Reactome annotations \\cite{Fabregat2015} reveals that Factor 2 is strongly enriched for oxidative stress and senescence pathways. Inspection of the top features highlights the importance of heat shock proteins (HSPs), a group of proteins that are essential for protein stability which are up-regulated upon stress conditions like high temperatures, pH shift or oxidative stress. Importantly, HSPs can be elevated in tumour cells and potentially contribute to prolonged tumour cell survival\\cite{Dempsey2010}. In agreement with the findings from the mRNA view, the drugs with largest weights on Factor 5 belong to clinical categories associated with stress response, such as target reactive oxygen species and DNA damage response (\\Cref{fig:MOFA_CLL_Factor5})\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.95\\textwidth]{MOFA_CLL_Factor5}\n\t\\caption{\n\t\\textbf{Characterization of Factor 5 in the CLL cohort as oxidative stress response.}\\\\\n\t(a) Beeswarm  plot of Factor 5, where each dot corresponds to a patient sample. Colours represent the expression of TNF, an inflammatory stress marker that is present among the top mRNA weights.\\\\\n\t(b) Gene set enrichment analysis results using Reactome pathways. Displayed are the top pathways with the strongest enrichment.\\\\\n\t(c) Heatmap of mRNA expression values for representative genes among the top weights. Samples are ordered by their Factor 5 values.\\\\\n\t(d) Weights for the top drugs, annotated by target category.\\\\\n\t(e) Heatmap of drug response values for the top three drugs. Samples are ordered by their Factor 5 values, as in (c).\n\t}\n\t\\label{fig:MOFA_CLL_Factor5}\n\\end{figure}\n\n\n\\subsection{Prediction of clinical outcomes}\n\nWe conjectured that the integration of multiple molecular layers could allow an improved prediction of the patients' clinical outcome. To evaluate the utility of the MOFA factors as predictors of clinical outcomes we fit Cox regression models \\cite{Cox1972} using the patients' time to next treatment (TTT) as a response variable. Two types of analysis were performed: a univariate analysis where each Factor was independently associated with TTT, and a multivariate analysis where the combination of all factors were used to predict TTT (\\Cref{fig:MOFA_CLL_Cox}). In the univariate Cox models, we observe  that Factor 1 (IGHV status), Factor 7 (associated with chemo-immunotherapy treatment prior to sample collection) and Factor 8 (enriched for Wnt signalling) were significant predictors of TTT. Accordingly, when splitting patients into binary groups based on the corresponding Factor values, we observe clear differences in the survival curves. In the multivariate Cox model, MOFA (Harrell's C-Index C=0.78) outperformed all other input settings, including PCA on single-omic data (C=0.68-0.72), individual genetic markers (C=0.66) as well PCA applied to the concatenated data matrix (C=0.74).\n\n% Caption copied\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.9\\textwidth]{MOFA_CLL_Cox}\n\t\\caption{\n\t\\textbf{Association analysis between MOFA factors and clinical putcome.}\\\\\n\t(a) Association of MOFA factors to time to next treatment using a univariate Cox regression model Error bars denote 95\\% confidence intervals. Numbers on the right show p-values for each Factor.\\\\\n\t(b) Kaplan-Meier plots for the three MOFA factors that show a significant association with time to next treatment.\\\\\n\t(c) Prediction accuracy of time to treatment using multivariate Cox regression trained with the first 10 principal components applied to single data modalities, the full data set or the 10 MOFA factors. Shown are average values of Harrell's C-index from fivefold cross-validation. Error bars denote standard error of the mean.\n\t}\n\t\\label{fig:MOFA_CLL_Cox}\n\\end{figure}\n\n\n\\subsection{Imputation of missing values}\n\nA promising application of MOFA is the imputation of missing values, including the potential to impute of entire assays.\\\\\nThe principle of imputation in MOFA follows the same logic as simulating from the generative model: if the factors and weights are known, the input data can be reconstructed by a simple matrix multiplication:\n\\[\n\t\\hat{\\bfY} = \\E[\\bfZ] \\E[\\bfW]^T\n\\]\nwhere $\\E[\\bfZ]$ and $\\E[\\bfW]$ denote the expected values of the variational distributions for the factors and the weights, respectively. Notice that, when using the expectations of the posterior distributions, the noise $\\epsilon$ (\\Cref{mofa_master_equation}) has a mean of zero and does not contribute to the predictions.\\\\\nThe equation above results in point estimates, but it ignores the uncertainity on $\\bfZ$ and $\\bfW$. Instead of relying in point estimates, one could adopt a more Bayesian approach and calculate the posterior predictive distribution by propagating the uncertainity \\cite{Gelman2013}. Nonetheless, due to the nature of the optimisation problem in variational inference, the variance of the posterior distributions can be underestimated (see \\Cref{section:expectation_propagation}). In addition, this would be substantially more complex to implement and would result in a significant increase in computational complexity, hence we did not implement this strategy.\n\nTo assess the imputation performance, we trained MOFA models using a data set of complete measurements (a total of N=121 samples) after masking parts of the drug response measurements. In a first experiment, we masked values at random, and in a second experiment we masked the entire drug response measurements. We compared the imputation accuracy of MOFA to some established imputation strategies, including imputation by feature-wise mean, SoftImpute \\cite{Mazumder2010}, and a k-nearest neighbour method \\cite{Troyanskaya2001}. For both imputation tasks, MOFA consistently yielded more accurate predictions, albeit the differences are less pronounced in the imputation of full assays, a significantly more challenging task.\\\\\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.9\\textwidth]{MOFA_imputation}\n\t\\caption{\\textbf{Evaluation of imputation performance in the drug response assay.}\\\\\n\tThe y-axis shows the mean-squared error (MSE) across 15 trials for increasing fractions of missing data (x-axis). Two experiments were considered: (a) values missing at random and (b) entire assays missing at random. Each point displays the mean across all trials and the error bars depict the corresponding standard deviations.}\n\t\\label{fig:MOFA_imputation}\n\\end{figure}\n\n\n\\newpage\n\n\\section{Application to single-cell multi-omics} \\label{section:mofa_scmt}\n\nThe emergence of single-cell multi-modal techniques has created opportunities for the development of novel computational strategies \\cite{Stuart2019,Colome-Tatche2018,Chappell2018}.\\\\\nTo show case how MOFA can be used to integrate single-cell multi-omics data, we considered a simple data set that consists of 87 ESCs where RNA expression and DNA methylation were simultaneously measured using scM\\&T-seq\\cite{Angermueller2016}. Two populations of ESCs were profiled: the first one contains 16 cells grown in 2i media, which is known to induce a naive pluripotency state associated with genome-wide DNA hypomethylation \\cite{Ficz2013}. The second population contains 71 cells grown in serum media, which contain stimuli that trigger a primed pluripotency state poised for differentiation \\cite{Tosolini2016}.\n\n\\subsection{Data processing}\n\nThe RNA expression data was processed using \\textit{scran}\\cite{Lun2016b} to obtain log normalised counts adjusted by library size. Feature selection was performed by selecting the top 5,000 most overdispersed genes\\cite{Lun2016a}. A Gaussian likelihod was used for this data modality. \\\\\nThe DNA methylation data was processed as described in Chapter 2. Briefly, for each CpG site, we calculated a binary methylation rate from the ratio of methylated read counts to total read counts. Next, CpG sites were classified by overlapping with genomic contexts, namely promoters, CpG islands and enhancers (distal H3K27ac peaks). Finally, for each annotation we selected the top 5,000 most variable CpG sites with a minimum coverage of 10\\% across cells. Each of the resulting matrices was defined as a separate view for MOFA. A Bernoulli likelihod was used for this data modality.\n\n\n\\subsection{Model overview}\n\nIn this data set, MOFA inferred 3 factors with a minimum explained variance of 1\\% (\\Cref{fig:mofa_scMT}). Factor 1 captured the transition from naive to primed pluripotent states, which MOFA links to widespread coordinated changes between DNA methylation and RNA expression. Inspection of the gene weights for Factor 1 pinpoints important pluripotency markers including  \\textit{Rex1/Zpf42} or \\textit{Essrb} \\cite{Mohammed2017}. As previously described both \\textit{in vitro} \\cite{Angermueller2016} and \\textit{in vivo} \\cite{Auclair2014}, the transition from naive to primed pluripotency state is concomitant with a genome-wide increase in DNA methylation levels. Factor 2 captured a second dimension of heterogeneity driven by the transition from a primed pluripotency state to a differentiated state, with RNA weights enriched with canonical differentiation markers including keratins and annexins \\cite{Fuchs1988}.\\\\\nJointly, the combination of Factors 1 and 2 reconstruct the coordinated changes between the transcriptome and the epigenome along the differentiation trajectory from naive pluripotent cells to differentiated cells.\n\n\\begin{figure}[H]\n\t\\centering \t\n\t\\includegraphics[width=0.9\\textwidth]{MOFA_scMT}\n\t\\caption{\\textbf{MOFA recovers a differentiation process from a single-cell multi-omics data set.} \\\\\n\t(a) Overview of the data modalities. Rows indicate number of features ($D$) and columns indicate number of samples ($N$). Grey bars denote missing samples.\\\\\n\t(b) Fraction of variance explained per factor (column) and view (row).\\\\\n\t(c) Cumulative fraction of variance explained per view (across all factors).\\\\\n\t(d) mRNA weights of Factor 1 (bottom) and Factor 2 (top). The genes that are labelled are known markers of pluripotency (for Factor 1) or differentiation (for Factor 2). \\\\\n\t(e) Scatter plot of Factor 1 (x-axis) against Factor 2 (y-axis). Cells are colored based on the culture condition. Grey arrow illustrates the differentiation trajectory from a naive pluripotency state to a differentiated state. \n\t}\n\t\\label{fig:mofa_scMT}\n\\end{figure}\n\n% \\begin{figure}[H]\n% \t\\centering \t\n% \t\\includegraphics[width=0.8\\textwidth]{MOFA_scMT2}\n% \t\\caption{XX}\n% \t\\label{fig:MOFA_scMT2}\n% \\end{figure}\n\n% \\subsubsection{Comparison with clustering strategies}\n\n% To illustrate the importance of learning continuous latent spaces before clustering samples, we applied popular integrative clustering algorithms \\cite{Wang2014,Shen2009,Mo2013} to the data set. As expected, two clusters can be recovered that broadly match the culture conditions. However, no trajectory is recovered, illustrating the importance of \n\n% \\begin{figure}[H]\n% \t\\centering \t\n% \t\\includegraphics[width=1.0\\textwidth]{MOFA_scMT_clustering}\n% \t\\caption{\\textbf{Multi-omics clustering applied to scMT data set.}\\\\\n% \t(a) Similarity matrix and dendogram obtained using Similarity Network Fusion\\cite{Wang2014}\\\\\n% \t(b) Dendrogram obtained using iClusterPlus\\cite{Mo2013} with two clusters.\n% \t}\n% \t\\label{fig:MOFA_scMT_clustering}\n% \\end{figure}\n\n", "meta": {"hexsha": "ed2a136d1e8b37730f6a756edabd874d48118544", "size": 31740, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter2/results.tex", "max_stars_repo_name": "rargelaguet/thesis", "max_stars_repo_head_hexsha": "ff3f7b996710c06d6924b7e780a4a9531651a3a0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2021-01-08T13:01:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T07:24:40.000Z", "max_issues_repo_path": "Chapter2/results.tex", "max_issues_repo_name": "rargelaguet/thesis", "max_issues_repo_head_hexsha": "ff3f7b996710c06d6924b7e780a4a9531651a3a0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter2/results.tex", "max_forks_repo_name": "rargelaguet/thesis", "max_forks_repo_head_hexsha": "ff3f7b996710c06d6924b7e780a4a9531651a3a0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-01-09T04:47:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-04T08:25:50.000Z", "avg_line_length": 106.1538461538, "max_line_length": 1198, "alphanum_fraction": 0.8003150599, "num_tokens": 7416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.4471831460981003}}
{"text": "\\chapter{String}\n\n\\section{Palindrome}\n\\subsection{Palindrome anagram}\n\\runinhead{Test palindrome anagram.} Char counter, number of odd count should $\\leq 0$.\n\\runinhead{Count palindrome anagram.} See Section-\\ref{N_objects_K_types}.\n\\runinhead{Construct palindrome anagram.} Construct all palindrome anagrams given a string \\pyinline{s}.\n\\\\\nClues:\n\\begin{enumerate}\n\\item dfs, grow the counter map of \\pyinline{s}. \n\\item jump parent char\n\\end{enumerate}\nCode:\n\\begin{python}\ndef grow(self, s, count_map, pi, cur, ret):\n  if len(cur) == len(s):\n    ret.append(cur)\n    return\n\n  for k in count_map.keys():\n    if k != pi and count_map[k] > 0:\n      # jump the parent\n      for i in xrange(1, count_map[k]/2+1):\n        count_map[k] -= i*2\n        self.grow(s, count_map, k, k*i+cur+k*i, ret)\n        count_map[k] += i*2\n\\end{python}\n\nJump within the looping to avoid repetition. \n\n\\section{KMP}\nFind string $W$ in string $S$ within complexity of $O(|W|+|S|)$. KMP - reflect upon yourself before judging others.\n\\subsection{Prefix suffix table}\nPartial match table (also known as \"failure function\"). After a failure matching, you know that the matched suffix before the failure point is already matched; therefore when you shift the $W$, you only need to shift the prefix onto the position of the previous suffix. The prefix and suffix must be proper prefix and suffix.\n\n\\begin{figure}[hbtp]\n\\centering\n\\subfloat{\\includegraphics[scale=1.30]{kmp_table}}\n\\caption{Prefix-suffix table}\n\\label{fig:kmp_table}\n\\end{figure}\nIn table-building algorithm, similar to dp, let $T[i]$ store the length of matched prefix suffix for $needle[:i]$\\\\\n\\\\\nClues:\n\\begin{enumerate}\n\\item dummy at $T[0]=-1$.\n\\item three parts\n\\begin{enumerate}\n\\item matched\n\\item fall back (consider $ABABC...ABABA$)\n\\item restart \n\\end{enumerate}\n\\end{enumerate}\nTable-building code:\n\\begin{python}\n# construct T\nT = [0 for _ in xrange(len(needle)+1)]\nT[0] = -1\nT[1] = 0\n\ncnd = 0  # candidate \ni = 2  # table index\nwhile i < len(needle)+1:\n    if needle[i-1] == needle[cnd]:  # matched\n        T[i] = cnd+1\n        cnd += 1\n        i += 1\n    elif T[cnd] != -1:  # fall back \n        cnd = T[cnd]\n    else:  # restart \n        T[i] = 0\n        cnd = 0\n        i += 1\n\\end{python}\n\n\\pythoninline{T[cnd]} is the length, thus just the next index to be processed in the next loop. \n\\subsection{Searching algorithm}\n\\begin{figure}[F]\n\\centering\n\\subfloat{\\includegraphics[scale=1.30]{kmp_presuffix}}\n\\caption{KMP example}\n\\label{fig:kmp_presuffix}\n\\end{figure}\n\nNotice:\n\\begin{enumerate}\n\\item index $i$ and $j$.\n\\item $T[i-1+1]$ for corresponding previous index in $T$ for current scanning index $i$. \n\\item When falling back, the next scanning index is \\pyinline{len(prefix)}\n\\item three parts:\n\\begin{enumerate}\n\\item matched\n\\item aggressive move and fall back\n\\item restart \n\\end{enumerate}\n\\end{enumerate}\nSearch code: \n\\begin{python}\n# search\ni = 0  # index for needle \nj = 0  # index for haystack\nwhile j+i < len(haystack):\n    if needle[i] == haystack[j+i]:  # matched \n        i += 1\n        if i == len(needle):\n            return haystack[j:]\n    else:\n        if T[i] != -1:  # move and fall back j\n            j = j+i-T[i]\n            i = T[i]\n        else:  # restart\n            j += 1\n            i = 0\n\nreturn None\n\\end{python}\n\\subsection{Applications}\n\\begin{enumerate}\n\\item Find needle in haystack. \n\\item Shortest palindrome \n\\end{enumerate}\n\n", "meta": {"hexsha": "ed444088f6d243e7306f6f7600645a8c5230bb4a", "size": 3428, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapterString.tex", "max_stars_repo_name": "algorhythms/Algo-Quicksheet", "max_stars_repo_head_hexsha": "c5d219a96f195adf1d19d2d701986e01fc9b8195", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 902, "max_stars_repo_stars_event_min_datetime": "2015-08-16T08:25:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T05:23:50.000Z", "max_issues_repo_path": "chapterString.tex", "max_issues_repo_name": "andysli6590/Algo-Quicksheet", "max_issues_repo_head_hexsha": "c5d219a96f195adf1d19d2d701986e01fc9b8195", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2015-07-06T17:24:47.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-12T00:01:38.000Z", "max_forks_repo_path": "chapterString.tex", "max_forks_repo_name": "andysli6590/Algo-Quicksheet", "max_forks_repo_head_hexsha": "c5d219a96f195adf1d19d2d701986e01fc9b8195", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 92, "max_forks_repo_forks_event_min_datetime": "2015-10-09T03:13:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-20T00:57:08.000Z", "avg_line_length": 27.6451612903, "max_line_length": 325, "alphanum_fraction": 0.6665694282, "num_tokens": 1023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.4471831458214136}}
{"text": "\\section{Free selective functors}\\label{sec-free}\n\nFree construction with examples\n\nThe methodology of building effectful computations with free constructions such\nas free~\\cite{free-monads} and freer~\\cite{freer-monads} monads and free\napplicatives~\\cite{free-applicatives} is a widespread in the functional programming community.\nIt allows to focus on the internal aspects of the effect under consideration and receive the\ndesired \\hs{Applicative} of \\hs{Monadic} structure of the computation~\\emph{for free},\ni.e. without the need to construct instances or prove laws.\n\nIn the ``free structures'' methodology, the essence of an effect is a datatype which encodes\nthe ``commands'' which the effect provides, acting as a deep embedding of the effect's\ninterface. This datatype must only have enough structure to be a~\\hs{Functor}. The purpose of\nthe free constructions is then to build on top of this functor a richer structure,\nwhich would have the instances of \\hs{Applicative}/\\hs{Selective}/\\hs{Monad}.\n\n\\subsection{Free construction}\\label{sec-free-construction}\n\n...\n\n\\subsection{Ping-pong, freely}\\label{sec-free-ping-pong}\n\nTo illustrate how the free selective construction can be used, we implement the\nclassical example of the Teletype DSL.\n\nThe \\hs{TeletypeF} datatype has two constructors, representing the commands of the\nTeletype interface:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ndata Teletype a = GetLine (String -> a)\n                | PutStrLn String a\n    deriving Functor\n\\end{minted}\n\nWe embed these commands into the free selective with the following two combinators,\nmimicking Haskell Prelude's IO API:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ngetLine :: Select Teletype String\ngetLine = liftSelect (GetLine id)\n\nputStrLn:: Select Teletype ()\nputStrLn s = liftSelect (PutStrLn s ())\n\\end{minted}\n\nBy reimplement the \\hs{pingPongS} example from the section \\ref{sec-intro}\nin terms of the free selective construction:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\npingPongS :: Select Teletype ()\npingPongS = whenS (fmap (==\"ping\") getLine) (putStrLn \"pong\")\n\\end{minted}\n\nOnce we have embedded the \\hs{pingPongS} program into the free selective datatype,\nwe have access to the machinery allowing for static analysis of its effects:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\nghci> getEffects pingPong\n[GetLine,PutStrLn pong]\n\\end{minted}\n\nThe \\hs{getEffects} function of type \\hs{Functor f => Select f a -> [f ()]}\nreturns a list of all effects of a free selective computations. In the specific case of\nthe Teletype functor, we get a list of all commands that a computations has called.\nInternally, the \\hs{getEffects} function interprets a free selective computation\nin the \\hs{Over} functor (see section~\\ref{sec-instances}).\n\nWe can interpret Teletype programs in any other \\hs{Selective} by means of the\n\\hs{runSelect} function, by providing a \\emph{natural transformation} \\hs{forall a. f a -> g a}, which gives an interpretation of the commands of\n\\hs{f} (specifically, \\hs{Teletype}) in terms of \\hs{g}. A natural example of such a\ntransformation would be an interpretation in the \\hs{IO} monad:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ninIO :: Teletype a -> IO a\ninIO (GetLine t)    = t <$> Prelude.getLine\ninIO (PutStrLn s x) = Prelude.putStrLn s *> pure x\n\\end{minted}\n\n\\subsection{Build systems, freely}\\label{sec-free-build}\n\n...\n\n\\subsection{Analysis and simulation of processor instructions}\\label{sec-free-isa}\n\nIn this section, we demonstrate how we can use free selective functors to construct an\neffect which can be used for effectively describing the semantics of a hypothetical\ninstruction set architecture. The features of free selective functors will allow for\nmultiple distinct interpretations of the same semantics, such as~\\emph{static} dependency\nanalysis and~\\emph{dynamic} simulation.\n\n\\subsubsection{Embedding}\n\nWe will represent the semantics of instruction in terms of the following datatype:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ntype ISA a = Select RW a\n\\end{minted}\n\nHere, \\hs{Select} is the free selective functor defined earlier in this section.\nWe apply the \\hs{Select} type constructor to the \\hs{RW} datatype, which is the\nfunctor we build our free construction on:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ndata RW k v a = R k             (v -> a)\n              | W k (ISA k v v) (v -> a)\n    deriving Functor\n\\end{minted}\n\nThe effect we require comprises two commands. We need to have an ability to (1)\n\\emph{read} a value associated with a key and, (2) given a computation which produces a value,\n\\emph{write} its result into the store. Here, the second argument of the \\hs{W} constructor\nThis exact structure of the definition is required for accommodating a pattern that\nfrequently occurs in instruction semantics: often we read a value from a location\n(register/memory), do something with the value and then write it into a different location.\nIf we had the type of \\hs{W} to be \\hs{k -> v -> (v -> a)}, i.e. required the value to be pure,\nwe would not be able to get away from using monadic bind/join. Additionally, we want the write\noperation to not just write the value and return \\hs{()}, but to return the just written value\nback, so it somehow used in the context; such a generosity of the write command not consuming\nits arguments will be useful to avoid creating more data dependencies than necessary.\n\nWe introduce two convenience combinators, which \\emph{lift} the data constructors\nof the \\hs{RW} datatype into the free selective, thus making them directly usable in\nthe definitions of instruction semantics:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\nread :: Location -> ISA Value\nread k = liftSelect (R k id)\n\nwrite :: Location -> ISA Value -> ISA Value\nwrite k p = p *> liftSelect (W k p id)\n\\end{minted}\n\nWhereas the \\hs{read} combinator is exactly the lifted \\hs{R} data constructor, the \\hs{write}'s implementation deserves attention, since it deviates from the trivial lifting of\nthe \\hs{W} data constructor. It evaluates its second argument, thus executing its\nassociated effects.\n\n\\subsubsection{Example 1. Addition}\n\nTo get acquainted with the proposed methodology, we start with a simple semantics for\nthe addition instruction, which will read the summands from the two locations, add them,\nwrite the result into the third location and also update the state of the \\hs{zero}\nflag to indicate if the sum was zero:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\nadd :: Location -> Location -> Location -> ISA Value\nadd var1 var2 dest =\n    let arg1     = read var1\n        arg2     = read var2\n        sum      = (+)  <$> arg1   <*> arg2\n        isZero   = (==) <$> pure 0 <*> write dest sum\n        overflow = willOverflowPure <$> arg1 <*> arg2\n    in write \"zero\"     (fromBool <$> isZero) *>\n       write \"overflow\" (fromBool <$> overflow)\n\\end{minted}\n\nHere, we get two effectful values from the two locations and calculate three intermediate\nresults. To calculate the sum we just lift \\hs{+} into the free selective using the applicative\ncombinators. We calculate the state of the \\hs{\"zero\"} flag in the similar way, but here we\nexploit the fact that the \\hs{write} combinator returns the value it has just written, thus we\ncan reuse the value of the sum without recalculating it and triggering its associated effects\nagain. We detect integer overflow by means of a pure function, thus there is not much difference\nwith calculating the sum (\\todo{discuss effects of \\hs{willOverflow}?}).\n\nThe free selective functor construction shines in the static analysis. By executing\nthe analysis of the \\hs{add} semantics, we can find obtain the list of all its effects:\n\\begin{minted}[xleftmargin=10pt]{haskell}\n> analyse (add \"x\" \"y\" \"z\")\n([],Left (W \"overflow\" :| [R \"y\",R \"x\",W \"zero\",W \"z\",R \"y\",R \"x\"]))\n\\end{minted}\nIf we read the list from right to left, we could see that \\hs{add} read the values of the\narguments than written the destination variable then then something else \\todo{write this}.\n\nThe addition instruction semantics has only used the applicative combinators and thus\nthe same analysis capabilities could have been implemented with free applicative functors.\nHowever, there are important instructions whose semantics cannot be implemented in terms\nof the \\hs{Applicative} interface, but still do not require such heavy artillery as monads.\n\n\\subsubsection{Example 2. Conditional jump}\n\nSelective functors allow to introduce limited dependencies between effectful computations.\nIt turns out, that they give just enough power to implement the semantics of conditional\njump instructions. A relative conditional jump offsets the program counter in case if a\ncertain condition, materialised in a microarchitectural flag, holds. For instance, some instruction set might have a jump triggered by the fact that the result of the last addition was zero\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\njumpZero :: Value -> ISA ()\njumpZero offset =\n    let pc       = read PC\n        zeroSet  = (/=) <$> pure 0 <*> read (Flag Zero)\n        modifyPC = void $ write PC (fmap (+ offset) pc)\n    in whenS zeroSet modifyPC\n\\end{minted}\n\nHere we use the aforementioned \\hs{whenS} combinator to only execute the effect, i.e.\nto modify the program counter, if the flag is set. By implementing this semantics in terms of\n\\hs{Selective} we achieve both the ability to implement an adequate simulator for the ISA and\nto retain the possibilities for the static analysis of programs by means of the \\hs{analyse} function:\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\n> analyse (jumpZero 42)\n([],Left (Write PC :| [Read PC,Read Zero]))\n\\end{minted}\n\nThe \\hs{analyse} function informs us of all necessary effects of the computation, thus\neffectively giving us an over-approximated list of dependencies. Note that it does not matter\nwhat argument we supply, since it will never get evaluated, e.g. the analysis will succeed and give us the same result even if we supply \\hs{undefined}.\n\n\\subsubsection{Blocks of instructions}\n\n", "meta": {"hexsha": "8089960d81e4197949f70cd0b37dcffa03d659f6", "size": 10007, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/5-free.tex", "max_stars_repo_name": "simonmar/selective", "max_stars_repo_head_hexsha": "8016a197fd2cbaa116b593ebc4699fc93b6d4b5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/5-free.tex", "max_issues_repo_name": "simonmar/selective", "max_issues_repo_head_hexsha": "8016a197fd2cbaa116b593ebc4699fc93b6d4b5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/5-free.tex", "max_forks_repo_name": "simonmar/selective", "max_forks_repo_head_hexsha": "8016a197fd2cbaa116b593ebc4699fc93b6d4b5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.4265402844, "max_line_length": 189, "alphanum_fraction": 0.759168582, "num_tokens": 2496, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4471831369934946}}
{"text": "\\documentclass{beamer}\n\\usetheme{Warsaw}\n\\usepackage{nhtvslides}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\lstset{language=CAML,\nbasicstyle=\\ttfamily\\footnotesize,\nframe=shadowbox,\nbreaklines=true}\n\\usepackage[utf8]{inputenc}\n\\DeclareMathOperator{\\sign}{sign}\n\\DeclareMathOperator{\\LookupCurve}{LookupCurve}\n\n\\title{Building a physics engine - part 5b: cars}\n\n\\author{Dr. Giuseppe Maggiore}\n\n\\institute{NHTV University of Applied Sciences \\\\ \nBreda, Netherlands}\n\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\begin{frame}{Table of contents}\n\\tableofcontents\n\\end{frame}\n\n\\section{Basic linear dynamics}\n\\begin{slide}{Basic linear dynamics}{Basic linear dynamics}{\n\\item Some easy assumptions for starters\n\\item No gears, lateral forces, etc.\n\\item Sports car with rear traction\n}\\end{slide}\n\n\\begin{slide}{Basic linear dynamics}{Basic linear dynamics}{\n\\item Longitudinal force\n\\begin{eqnarray}\nF_{\\text{traction}} &=& u F_{\\text{engine}} \\\\\nF_{\\text{drag}} &=& - C_{\\text{drag}} v |v| \\\\\nF_{\\text{rr}} &=& - C_{\\text{rr}} v \\\\\nF_{\\text{long}} &=& F_{\\text{traction}} + F_{\\text{drag}} + F_{\\text{rr}}\n\\end{eqnarray}\n\\begin{itemize}\n\\item $u$ is forward direction\n\\item $C_{\\text{drag}} = 0.4257$\n\\item $C_{\\text{rr}} = 12.8$\n\\end{itemize}\n}\\end{slide}\n\n\\begin{slide}{Basic linear dynamics}{Basic linear dynamics}{\n\\item Braking force\n\\begin{eqnarray}\nF_{\\text{brake}} &=& -u C_{\\text{brake}} \\\\\nF_{\\text{long}} &=& F_{\\text{brake}} + F_{\\text{drag}} + F_{\\text{rr}}\n\\end{eqnarray}\n\\begin{itemize}\n\\item $C_{\\text{brake}}$ is a constant that \\textit{just feels good}\n\\end{itemize}\n}\\end{slide}\n\n\\section{Weight transfer}\n\\begin{slide}{Weight transfer}{Weight transfer}{\n\\item Acceleration causes a pitch of the car\n\\item It shuffles weight between front and rear\n\\item Tires with more or less friction, and thus capacity to support acceleration\n\\item $F_{\\text{max}} = \\mu W_w$ for a wheel carrying weight $W_w$\n\\item $\\mu \\in [1 \\dots 1.5]$\n}\\end{slide}\n\n\\begin{frame}{Weight transfer}\n\\center\n\\includegraphics[height=5cm]{Pics/WeightTransfer.png}\n\\end{frame}\n\n\\begin{slide}{Weight transfer}{Weight transfer}{\n\\item When the car is at rest\n\\begin{eqnarray}\nW_f &=& \\frac{c}{l}W \\\\\nW_r &=& \\frac{b}{l}W\n\\end{eqnarray}\n\\item When the car is accelerating\n\\begin{eqnarray}\nW_f &=& \\frac{c}{l}W - \\frac{h}{l}ma \\\\\nW_r &=& \\frac{b}{l}W + \\frac{h}{l}ma\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Weight transfer}{Weight transfer}{\n\\item When accelerating, pitch the car\n\\item If the force applied by the engine to the wheels is bigger than $F_{\\text{max}}$, reduce $\\mu$ and apply $F_{\\text{max}}$, and draw smoke/spinning wheels\n\\item If the force applied by the engine to the wheels is less than $F_{\\text{max}}$, apply the engine force directly\n}\\end{slide}\n\n\\section{Engine force}\n\\begin{slide}{Engine force}{Engine force}{\n\\item The engine is not directly connected to the wheels\n\\item Gears apply the engine torque to different values of max wheel $\\tau$ and max wheel $\\omega$\n\\item Lower gears have higher $\\tau$\n\\item Higher gears have higher $\\omega$\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Engine force}{\n\\item $F_{\\text{drive}} = u \\frac{\\tau_{\\text{drive}}}{R_w}$ is the force applied to the rear axle\n\\item $\\tau_{\\text{drive}} = \\tau_{\\text{engine}} x_g x_d n$ is the torque applied to the rear axle\n\\item $\\tau_{\\text{engine}}$ is the torque coming from the engine given the current RPM\n\\item $x_g$ is the gear ratio, $x_d$ is the differential ratio\n\\item $m=1500kg$ is the car mass\n\\item $n=0.7$ is the transmission efficiency\n\\item $r_w = 0.34m$ is the wheels radius\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Gear ratios}{\n\\item $x_g = 2.66\\ 1.78\\ 1.3\\ 1.0\\ 0.74\\ 0.5$\n\\item reverse gear $ = 2.9$\n\\item $x_d = 3.42$\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Torque and RPM}{\n\\item $rpm$ determines the current maximum torque\n\\item torque accelerates the wheels\n\\item wheels determine the next $rpm$\n\\item $rpm$ is capped; after a while (\\textit{red-line}) the engine breaks\n\\item $\\tau_{\\text{max}}$ is capped as well; one cap per gear\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Torque and RPM}{\n\\item Torque and RPM recurrences\n\\begin{eqnarray}\n\\tau_{\\text{max}} &=& \\LookupCurve(rpm) \\\\\n\\tau_{\\text{engine}} &=& \\tau_{\\text{max}} \\alpha_{\\text{throttle}} \\\\\nrpm &=& \\max(1000, \\frac{\\omega_w x_g x_d}{2 \\pi})\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Wheel angular velocity}{\n\\item For $\\LookupCurve$, any reasonable bell-shaped curve (different for each gear) will do\n\\item Or, copy from the sources of \\textit{Marco Monster's - Car Physics for Games} tutorial; they contain some data\n}\\end{slide}\n\n\\begin{frame}{Gear plot}\n\\center\n\\includegraphics[height=5cm]{Pics/GearPlot.png}\n\\end{frame}\n\n\\begin{slide}{Engine force}{Shifting gears}{\n\\item RPM changes suddenly when changing gear $rpm' = rpm \\frac{x_g'}{x_g}$\n}\\end{slide}\n\n\\begin{slide}{Engine force}{Wheel angular velocity}{\n\\item Simple solution vs hard solution\n\\item Simple solution: wheels rotating as car is moving\n$$\\omega_w \\approx \\frac{|v|}{r_w}$$\n\\item Hard solution: track wheel angular velocities separately\n}\\end{slide}\n\n\\section{Slip ratio}\n\\begin{slide}{Slip ratio}{Slip ratio}{\n\\item The amount of acceleration of the car depends on the friction between tires and road\n\\item Rolling tires do not have friction; friction is given by tires rotating faster than they are moving\n\\item Rear tires roll faster than front tires\n}\\end{slide}\n\n\\begin{frame}{Longitudinal force}\n\\center\n\\includegraphics[height=3cm]{Pics/SlipRatioCurve.png}\n\\end{frame}\n\n\\begin{slide}{Slip ratio}{Slip ratio}{\n\\item Slip ratio determines the force given by the wheel to the car\n$\\sigma = \\frac{\\omega_w r_w - v_{\\text{long}}}{|v_{\\text{long}}|}$\n\\item The traction force given by the wheel at a certain slip ratio is\n$F_{\\text{traction}} = \\max(6000, C_t \\sigma)$\n$\\tau_{\\text{traction}} = F_{\\text{traction}} \\times R_w$\n}\\end{slide}\n\n\\begin{frame}{Longitudinal force simplified}\n\\center\n\\includegraphics[height=3cm]{Pics/SlipRatioCurveApprox.png}\n\\end{frame}\n\n\\begin{slide}{Slip ratio}{Slip ratio}{\n\\item We track $\\omega_w$ for each wheel\n\\item We compute the slip ratio and the corresponding torque on the axle\n$\\tau_{\\text{total}} = \\tau_{\\text{drive}} + \\underbrace{\\tau_{\\text{traction}}}_{\\text{two wheels}} + \\tau_{\\text{brake}}$\n\\item We compute the angular acceleration of this force on the wheel\n$\\alpha = \\frac{\\tau_{\\text{total}}}{I_w}$\n\\item The wheel rotating around its central axis has moment of inertia\n$I_w = \\frac{m r_w^2}{2}$\n}\\end{slide}\n\n\\section{Curves at a low speed}\n\\begin{slide}{Curves at a low speed}{Curves at a low speed}{\n\\item When travelling at low speed\n\\item We just find the radius of the circle the car describes, depending on the wheel angle\n\\item $\\delta$ is the wheel turn angle\n\\item $\\sin \\delta = \\frac{L}{R}$\n\\item From the radius we can determine the angular velocity and just rotate the car by that\n$\\omega = \\frac{v}{R} = \\frac{v \\sin \\delta}{L}$\n}\\end{slide}\n\n\\begin{frame}{Rotation radius}\n\\center\n\\includegraphics[height=3cm]{Pics/RotationRadius.png}\n\\end{frame}\n\n\\begin{frame}{Delta angle}\n\\center\n\\includegraphics[height=3cm]{Pics/DeltaAngle.png}\n\\end{frame}\n\n\\section{Curves at a high speed}\n\\begin{slide}{Curves at a high speed}{Curves at a high speed}{\n\\item Turning the front wheels causes a change in their lateral forces\n\\item We add new state information to our system\n\\begin{itemize}\n\\item $\\alpha$ is the side-slip angle of the wheel, which changes as we turn\n\\item $C_a$ is the cornering stiffness, a pleasant, and utterly fake, constant\n\\end{itemize}\n}\\end{slide}\n\n\\begin{slide}{Curves at a high speed}{Curves at a high speed}{\n\\item We compute the lateral and longitudinal speed at a given side-slip angle, for each wheel\n\\begin{eqnarray}\nv_{\\text{lat}} &=& |v| \\sin \\alpha \\\\\nv_{\\text{long}} &=& |v| \\cos \\alpha\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Curves at a high speed}{Curves at a high speed}{\n\\item We also compute the side-slip angles given the current angular velocity (started up from low-speed turning) and lateral and longitudinal velocities\n\\begin{eqnarray}\n\\alpha_{\\text{front}} &=& \\frac{v_{\\text{lat}} + \\omega b}{v_{\\text{long}}} - \\delta \\sign(v_{\\text{long}}) \\\\\n\\alpha_{\\text{rear}} &=& \\frac{v_{\\text{lat}} - \\omega b}{v_{\\text{long}}}\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Curves at a high speed}{Lateral forces}{\n\\item Lateral force also depends on the current weight distribution \n\\item $F_{\\text{lateral}} = \\max(6000, C_a \\alpha) W_w$\n\\item $\\tau_{\\text{lateral}} = F_{\\text{lateral}} \\times b$\n\\item Each wheel has a different lateral force; we compute torque from lateral forces and use it as usual to further integrate $\\omega$\n}\\end{slide}\n\n\n\\section{Assignment}\n\\begin{slide}{Assignment}{Assignment}{\n\\item Before the end of next week\n\\item Group-work archive/video on Natschool or uploaded somewhere else and linked in your report\n\\item Individual report by each of you on Natschool\n\\item Add a personalized selection of forces to your simulator\n}\\end{slide}\n\n\\begin{frame}{That's it}\n\\center\n\\fontsize{18pt}{7.2}\\selectfont\nThank you!\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "ad783ac5afc4dd0cb66ec2d1a478eb8495c84dd3", "size": 9145, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/Lecture 9/Lecture 9.tex", "max_stars_repo_name": "hogeschool/TINWIS01-7", "max_stars_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2015-10-02T23:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T04:08:27.000Z", "max_issues_repo_path": "Slides/Lecture 9/Lecture 9.tex", "max_issues_repo_name": "hogeschool/TINWIS01-7", "max_issues_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-08-16T10:05:36.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-16T10:05:47.000Z", "max_forks_repo_path": "Slides/Lecture 9/Lecture 9.tex", "max_forks_repo_name": "hogeschool/TINWIS01-7", "max_forks_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-25T02:31:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-04T07:48:25.000Z", "avg_line_length": 34.9045801527, "max_line_length": 159, "alphanum_fraction": 0.7245489338, "num_tokens": 2811, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4470687249160803}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{amsmath, amsthm, amssymb, latexsym}\n\\usepackage{enumerate}\n\\usepackage{color}\n\\newtheorem*{defn}{Definition}\n\\begin{document}\n\\title{Mid-semester report\\\\ \nInteractive Visualizations in Mathematica \n\\\\\nSpring 2021}\n\\author{Faculty Mentor: A.J. Hildebrand \\\\\n    Project Leader: Efstathios Konstantinos Chrontsios Garitsis \\\\\n\tIGL Scholars: Xiaojun Jia, Adithya Swaminathan, \\\\\n\tDimitrios Tambakos, Troy Yang, Sarah Zimmerman}\n\t\\date{March 22, 2021}\n\\maketitle\n\\section{Project Goals}\nWe split into two subgroups in order to create fractal-like visualizations derived by different aspects of math. The first subgroup concentrates on  Julia sets of complex cubic \\mbox{polynomials} and tries to identify patterns within their fractal-like visualizations while the coefficients of the polynomials change. The second subgroup is investigating the behavior of fractals constructed from sum-of-digit functions.\n\n\\section{Julia Sets}\nLet $P: \\mathbb{C} \\rightarrow \\mathbb{C}$ be a complex polynomial and ${P^k}$ denote the k-th iterate of ${P}$, i.e., $P^k = P \\circ P \\circ \\dots \\circ P$  k times.\n\n\\begin{defn}\nThe \\textbf{Julia Set} is defined to be the boundary of the set of all points ${z \\in \\mathbb{C}}$ for which the set $\\{P^{k}(z) : k \\in \\mathbb{N}\\}$ is bounded.\n\\end{defn}\n\nOur research is focused on how the Julia Sets of polynomials change while the \\mbox{coefficients} change. This has been extensively studied for polynomials of the form ${z^2 + c}$ and many \\mbox{visualizations} of those Julia sets have been created. We focus on polynomials of the form ${z^3 + az^2 + \\lambda z}$ where ${a}$ is a complex number and ${\\lambda = e^{2 \\pi i \\theta}}$ where ${\\theta}$ is an irrational number.\\\\\n\nWhen $a$ varies among integers and $\\theta$ is constant, we noticed that graphs of Julia sets have central symmetry when $a_1=-a_2$. For example, when $\\theta = \\sqrt{2}$ and $a\\in [-2,2] \\cap \\mathbb{Z}$, the graphs for $a_1 = -1$ and $a_2 = 1$ are central symmetric.\n\\newpage\n\\begin{center}\n      \t~\\\\$a_1 = -1$ \\hspace{2.15in}$a_2 = 1$\n        ~\\\\\\includegraphics[\n        height=1in,\n        width=2in]{sqrt_2_a=-1.PNG}\n        \\hspace{0.6in}\n        \\includegraphics[\n        height=1in,\n        width=2in]{sqrt_2_a=1.PNG}\n\\end{center}\n\nHowever, we also came across instances where the graphs of the Julia set do not have central symmetry. For example, fix $\\theta = \\pi^\\pi$ and let $a \\in \\{0.59+1.5xi \\mid x \\in \\mathbb{Z}\\}$. The graphs for $x=-1$ and $x=1$  lose central symmetry, as shown below:\n\\begin{center}\n    ~\\\\$a=0.59-1.5i$ \\hspace{1.25in}$a=0.59+1.5i$ \n    ~\\\\\\includegraphics[width=1.25in,height=1.25in]{pi2pi1.png}\n    \\hspace{1in}\n    \\includegraphics[width=1.25in,height=1.25in]{pi2pi3.png} \n\\end{center}\n\nLast but not least, we are studying the possibility of patterns of the Julia set when ${a}$ is fixed and ${\\theta}$ changes among irrational numbers.\n\n\\section{Sum-of-Digit Fractals}\nLet  $s_{b}(n)$ denote the sum of the digits of a number $n$ in base $b$.\nFor example, in base $b=10$ we have \n$s_{10}(15) = 1 + 5 = 6$, while in base $b=2$,\n $s_{2}(15) =  1 + 1 + 1+ 1 = 4$ since $15$ has base $2$ representation $1111$.\n We consider the exponential sum\n\\[ S_{b, p}(N) = \\sum_{n=1}^{N}{e^{2\\pi i\\, s_{b}(n)/p}},\n\\]\nwhere $s_b(n)$ is the sum-of-digit function and $p$ is a parameter.\nSince the terms $e^{2\\pi i s_b(n)/p}$ in $S_{b,p}(n)$ are complex numbers, we can interpret them as vectors in the $xy$-plane given by:\n\\[\ne^{2\\pi i s_b(n)/p}=(\\cos(2\\pi  s_{b}(n)/p), \\sin(2\\pi s_{b}(n)/p))\n\\]\n\n\\begin{defn}Given a base $b$ and a parameter $p$, we define the associated \\textbf{sum-of-digit fractal} to be the  curve whose steps are given by the terms of $S_{b,p}(N)$.\n\\end{defn}\n\n%Figure \\ref{fig:five-steps} shows the first 5 steps of the sum-of-digit fractal with $b=2$ and $p=7$.\nIn the case where $b \\equiv 1 \\pmod{p}$, we can show that the corresponding fractal is given by a regular $p$-gon, as illustrated in Figure \\ref{fig:p-gons}.\n\nFor the case where $b \\equiv 0 \\pmod{p}$, we can obtain a set of $p$ overlapping $p$-gons that share a common vertex in the center, as seen in Figure \\ref{fig:multiple-p-gons}.\n% , given by Figure \\ref{fig:multiple-p-gons}.\n\n\n% \\begin{figure}[htb!]\n%     \\begin{center}\n%         \\includegraphics[\n%         height=0.25\\textheight,\n%         width=0.5\\textwidth]{arrows_w_axes.png}\n%         \\end{center}\n        \n%         \\caption{The first 5 steps of the sum-of-digit fractal $S_{2,7}(N)$.}\n%         \\label{fig:five-steps}\n% \\end{figure}\n\n\\begin{figure}[htb!]\n\n    \\begin{center}\n    \\includegraphics[width=2in,height=1.75in]{pentagon.png} \n    \\hspace{0.2in} \\includegraphics[width=2in,height=1.75in]{hexagon.png}\n    \\end{center}\n    \\caption{Sum-of-digit fractals for $p = 5, b = 6$ (left), and $p = 6, b = 7$ (right).}\n    \\label{fig:p-gons}\n    \\end{figure}\n\n\\begin{figure}[htb!]\n    \\begin{center}\n    \\includegraphics[width=2in,height=1.75in]{bequalsn3.png}\n    \\hspace{0.2in} \\includegraphics[width=2in,height=1.75in]{bequalsn4.png}\n    \\\\\n    \\includegraphics[width=2in,height=1.75in]{bequalsn5.png}\n    \\hspace{0.2in} \\includegraphics[width=2in,height=1.75in]{bequalsn6.png}\n    \\end{center}\n    \\caption{Sum-of-digit fractals for $p = 3, b = 3$ (top left), $p = 4, b = 4$ (top right),\n    $p = 5, b = 5$ (lower left), and $p = 6, b = 6$ (lower right).}\n    \\label{fig:multiple-p-gons}\n\\end{figure}\n\n\\clearpage\nFor irrational values of $p$, the sum-of-digit fractals can take a great (and largely unpredictable) variety of different shapes  as illustrated in Figure \\ref{fig:irrational}. \n\\begin{figure}[htb!]\n    \\begin{center}\n    \\includegraphics[width=2in,height=1.75in]{sqrt7_irrational.png}\n    \\hspace{0.2in} \\includegraphics[width=2in,height=1.75in]{logpi.png}\n    \\\\\n    \\includegraphics[width=2in,height=1.75in]{base5_8piover3.png}\n    \\hspace{0.2in} \\includegraphics[width=2in,height=1.75in]{logsqrtpi.png}\n    \\end{center}\n    \\caption{Sum-of-digit fractals irrational for $p$ values: $n = 1000$, $p = 2\\sqrt{6}$, $b = 7$  (top left), $n = 1000$, $p = \\ln(\\pi)$, $b = 8$ (top right), $n = 500$, $p = 8\\pi/3$, $b = 5$ (bottom left), $n = 1000$, $p = \\ln(\\sqrt{\\pi})$, $b = 10$ (bottom right).}\n    \\label{fig:irrational}\n\\end{figure}\n\n\\section{Next Steps}\n\nIn the coming weeks, we plan to refine the code for these visualizations, add more functionality, and create interactive animations. We also hope to prove or explain some of the observed behavior.\n\n\n\\end{document}", "meta": {"hexsha": "30c06d65905608095e27c74ae5145bdc43a4213a", "size": 6575, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Midsemester Report/Spring 2021_Visualisations_Midsemester_report.tex", "max_stars_repo_name": "adiswami14/exponential-random-walks", "max_stars_repo_head_hexsha": "fcc0340409afdd71f16fec4e93cd9280f13af33e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-22T00:51:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-22T00:51:37.000Z", "max_issues_repo_path": "Midsemester Report/Spring 2021_Visualisations_Midsemester_report.tex", "max_issues_repo_name": "ajhildebrand/sum-of-digit-fractals", "max_issues_repo_head_hexsha": "1691d4664ea4dd1392a244847763d26942c621b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Midsemester Report/Spring 2021_Visualisations_Midsemester_report.tex", "max_forks_repo_name": "ajhildebrand/sum-of-digit-fractals", "max_forks_repo_head_hexsha": "1691d4664ea4dd1392a244847763d26942c621b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-05-21T23:05:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-21T23:05:43.000Z", "avg_line_length": 50.1908396947, "max_line_length": 425, "alphanum_fraction": 0.6784790875, "num_tokens": 2229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.8354835350552603, "lm_q1q2_score": 0.4470659267514763}}
{"text": "%\n% \n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Recurrence Relation Modules in CPPINTS}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Algorithms for Building Recurrence Relation}\n\n\\subsection{Introduction to Analytical Integral Algorithms}\n\\label{concepts_introduction}\n\nThe integral we discussed here is analytical integrals,\nwhich is generally expressed as:\n\\begin{equation}\\label{int_paper:1}\n  I_{ijkl} = \\int \\chi_{i}(\\bm{r})\\chi_{j}(\\bm{r})f(\\bm{r},\\bm{r^{'}})\n\\chi_{k}(\\bm{r^{'}})\\chi_{l}(\\bm{r^{'}}) d\\bm{r} d\\bm{r^{'}}\n\\end{equation}\nand the integrand is analytically integrated. Kinetic integrals(KI),\nnuclear attraction integrals(NAI), electron repulsion integrals(ERI) etc. all \nbelong to this group. \n\nSince Boys\\cite{SFBoys1950} suggested to use Cartesian Gaussian type function to form \nbasis functions,\n\\begin{equation}\\label{int_paper:2}\n \\chi = x^{i}y^{j}z^{k}e^{-\\alpha r^{2}}\n\\end{equation}\na major breakthrough technology for computing ERI was introduced by Pople and Hehre(PH)\\cite{PH}. \nThis method provides exceptional efficient algorithm for computing high contracted \nlow angular momentum integrals. However, this method is limited to S and P basis functions, \nand it's difficult to be extended to high angular momentum integrals. McMurchie and \nDavidson(MD)\\cite{MD}\nproposed a general formalism for computing variety kind of analytical integrals in terms of \nHermitian polynomials, and their method is applied to integrals with high angular momentum. \nDupuis, Rys and King(DRK)\\cite{DRK1976JCOMP,DRK1976JCP,DRK1983JCOMP} developed another formalism \nfor ERI based on exact numerical \nquadrature using root and weights generated from Rys polynomials. Although MD and DRK\nmethods provide general way to derive the analytical integrals, they are indirect methods where\nauxiliary polynomials need to be involved. \n\nIn 1980s, Obara and Saika(OS)\\cite{OS1986,OS1988} derived a set of\nrecursive formulas for analytical integrals based on recursive expression of \nthree body overlap integral. In the OS method it's able to directly generate the integrals. The \nrecurrence relation(RR) for ERI in OS scheme is given as:\n\\begin{equation}\n \\begin{split}\n((a+\\iota_{i})b|cd)^{(m)} &= (P_{i} - A_{i})(ab|cd)^{(m)} +\n\\left(W_{i} -P_{i}\\right)(ab|cd)^{(m+1)} \\\\\n&+\\frac{N_{i}(A)}{2\\epsilon}\\left(((a-\\iota_{i})b|cd)^{(m)}-\\frac{\\rho}{\n\\epsilon }((a-\\iota_{i})b|cd)^{(m+1)}\\right)  \\\\\n&+\\frac{N_{i}(B)}{2\\epsilon}\\left((a(b-\\iota_{i})|cd)^{(m)}-\\frac{\\rho}{\n\\epsilon }(a(b-\\iota_{i})|cd)^{(m+1)}\\right)  \\\\\n&+\\left(\\frac{N_{i}(C)}{2}\\right)\\frac{1}{\\epsilon+\\eta}\n(ab|(c-\\iota_{i})d)^{(m+1)} \\\\\n&+\\left(\\frac{N_{i}(D)}{2}\\right)\\frac{1}{\\epsilon+\\eta}\n(ab|c(d-\\iota_{i}))^{(m+1)}\n\\end{split}\n\\label{int_paper:3}\n\\end{equation}\nwhere the $(ab|cd)^{(m)}$ is:\n\\begin{equation}\n\\label{int_paper:4}\n (ab|cd)^{(m)} = \\frac{2}{\\sqrt{\\pi}}\\int^{\\infty}_{0} du \\left( \\frac{u^{2}}\n{\\rho+u^{2}}\\right)^{m}(ab|u|cd) \n\\end{equation}\n$(ab|cd)^{(0)}$ is the result ERI of $(ab|cd)$. In the OS scheme to compute an arbitrary ERI \nof $(ab|cd)$, the bottom integrals of $(00|00)^{(0)}$, $(00|00)^{(1)}$ etc. are needed \nto be evaluated first; through the recursive expansion \\ref{int_paper:3} it's able to raise\nup the angular momentum recursively until the target integral $(ab|cd)$ is derived. Lindh, \nRyu and Liu\\cite{lindh1991reduced}(LRL) proposed a similar RR based on Rys \npolynomials. Because the integrals are calculated in ``vertical'' way, \nsuch methods are named as ``vertical recurrence relation''(VRR).\n\nIn contrast to the VRR, Head-Gordon and Pople(HGP)\\cite{HGP} found another general formula which \nperforms ``horizontal recurrence relation''(HRR) on analytical integrals. In HRR the ERI\nis evaluated as:\n\\begin{equation}\n\\label{int_paper:5}\n (a(b+\\iota_{i})|cd) = ((a+\\iota_{i})b|cd) + \n(A_{i} - B_{i})(ab|cd)\n\\end{equation}\nConsequently the ERI $(ab|cd)$ can be recursively derived from a set of auxiliary integrals\nin form of $(e0|f0)$. Because the HRR only involves the basis function centers,\nit can be applied to contracted integrals thus to save computation cost \ninside the contraction loop. Hamilton and Schaefer\\cite{new_hrr_Schaefer}(HS) derived a \nsimilar HRR by using translational invariance condition, it shifts the integral in form of \n$(a+b+c+d0|00)$ to $(a+b0|c+d0)$. \n\nFor practical integral evaluation, HRR needs to combine with other\nmethods to finish the whole integral derivation. HGP\\cite{HGP} scheme combines the HRR with OS scheme,\nGill etc. \\cite{gill1989efficient, gill1990efficient}suggested to join HRR and MD methods together. \nOther type of combinations are also proposed\\cite{lindh1991reduced,new_hrr_Schaefer}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Primary Achievement of CPPINTS}\n%\n%\n%\nAlthough VRR provides clear formalism for recursively generating integrals, it's still \nuncertain that how to generate the integrals with least amount of work. This problem is \nreferred as ``tree-search problem''\\cite{HGP}. Generally in the VRR, the recurrence derivation on \nERI forms a ``directed graph'' data structure\\footnote{see \n\\url{http://en.wikipedia.org/wiki/Directed_graph} for more details} as shown in figure \\ref{fig:1}. \nThe tree-search problem is to find the optimal directed graph(or commonly referred as path) with \nminimum of work, for example; with minimum FLOPS or with minimum number of intermediate variables. \n\n \\begin{figure}[htb]\n \\centering\n \\includegraphics[scale=0.25]{./graph.eps}\n % general_rr.eps: 0x0 pixel, 300dpi, 0.00x0.00 cm, bb=0 0 763 487\n \\caption{directed graph for integral of $(DS|PS)$ based on OS scheme}\n \\label{fig:1}\n\\end{figure}\n\nIn CPPINTS, a general searching algorithm is used on solving the tree-search problem for \nVRR. Instead of exploring details for optimal path, by\ninvestigating the nature of VRR formula we can wrap up correlated integrals into packages\nand it turns out that the packages are independent with each other on the VRR path. Based on\nthe concept of package, the directed graph for VRR is converted into tree data structure and the optimal\npath for VRR is corresponding to the shortest path in the given tree data structure, where the\na similar Dijkstra's algorithm\\footnote{please see \n\\url{http://en.wikipedia.org/wiki/Dijkstra\\%27s_algorithm} for more information} is applied.\nThis part will be discussed in section \\ref{optimal_path}.\n\nFor computing the target integrals, both VRR and HRR need many intermediate integrals on\nthe recurrence relation(RR) path. The interesting question is, is every intermediate integral \nnecessary in the recurrence generation? The question becomes more interesting in terms of \nthe redundancy of Cartesian type of Gaussian functions in comparison with the spherical form of \nGaussian functions. In the section \\ref{redundancy_rr} a general recursive procedure is \nemployed to explore the redundancy of RR.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% optimal VRR path\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Finding Optimal Path for Recurrence Relation}\n\\label{optimal_path}\n\nThe optimal path for RR can be defined in variety of way. In this paper,\nthe optimal path is the implementation of RR with minimum intermediate integral\nnumber. Our discussion below is based on HGP scheme above. However,the idea \nand implementation below is easy to transfer to other RR schemes.\n\nIn the practical implementation of RR, the integral calculation is usually performed \nin terms of shells rather than basis functions, so that to reduce the repeat use of \nintermediate integral. Considering the equation \\ref{int_paper:3}, \nall of shell positions in the shell quartet $(FD|PS)$ are expandable except the ``ket2'' position \nwhere the shell is ``S'' type of \nfunction. Therefore for each LHS ERI appearing in the VRR, how to find it's proper expandable\nposition so that to minimize the total number of intermediate integrals is the key to \nfind optimal path for VRR.\n\nLet's take ERI as an example. The equation \\ref{int_paper:3} can be generalized into a 8-term \nexpansion:\n\\begin{align}\\label{int_paper:7}\nI(L,m) &= a_{0}I_{0}(L-1,m) + a_{1}I_{1}(L-1,m+1) \\nonumber \\\\ \n&+ a_{2}I_{2}(L-2,m) - a_{3}I_{3}(L-2,m+1) \\nonumber \\\\\n&+ a_{4}I_{4}(L-2,m) - a_{5}I_{5}(L-2,m+1) \\nonumber \\\\\n&+ a_{6}I_{6}(L-2,m+1) + a_{7}I_{7}(L-2,m+1)\n\\end{align}\n$L$ is the sum of angular momentum\n\\begin{equation}\\label{int_paper:8}\n L = L_{a} + L_{b} + L_{c} + L_{d}\n\\end{equation}\nfor ERI $(ab|cd)$, and $m$ is the parameter for auxiliary integral $(ab|cd)^{(m)}$ in \nexpression \\ref{int_paper:4}.\nFrom equation \\ref{int_paper:7}, it's clear that the $L$ is constantly decreasing and $m$ is\nincreasing in same manner from LHS to RHS. Therefore the properties of $L$ and $m$ \nfor ERI characterize an ``arrow'' in the derivation of VRR, in this sense the VRR\nfor ERI is ``inconvertible'' between LHS and RHS. As see in the following discussion,\nsuch inconvertibility grantees the existence of conversion for transforming the graph\ndata structure into the tree data structure for ERI\\footnote{In tree data structure,\nevery children node can only have one parent node. Such character establishes the direction\nof the tree. Please see \\url{http://en.wikipedia.org/wiki/Tree_\\%28data_structure\\%29} for \nmore information}, and it also establishes an order \nof sequence between two arbitrary ERI so that RHS ERI is always generated prior to\nthe LHS ERI in the resulting VRR path.\n\nBased on the feature of inconvertibility, it's able to set up some general coding structure\nto perform the optimal path search for ERI in VRR (unsolved shell quartets are these who\nappear in VRR path but their expanding position are not yet determined):\n\\begin{verbatim}\nset up unsolved shell quartet archive;\ninitilize the unsolved shell quartet archive with \ninput LHS shell quartets;\nloop over m (from m=0 to maximum):\n  loop over L (from maximum to 0):\n    while(true):\n      perform optimal expanding postion search for \n      all (L,m) LHS shell quartets in the unsolved \n      shell quartet archive;\n      if there are no (L,m) LHS shell quartets break \n      out the loop;\n    end while\n  end loop with L\nend loop with m\n\\end{verbatim}\nThe search is carried out from the LHS to RHS until all of LHS shell quartets \nare solved. The procedure here establishes a general Dijkstra algorithm scheme \nfor searching expanding positions for VRR. By wrapping up all of unsolved \n$(L,m)$ shell quartets together, it's able to search their their optimal expansions\nand the following search iteration will be performed based on the output of\nprevious iterations. \n\nHow to evaluate the efficiency of the algorithm comparing with Breadth-first search\nor Depth-first search across all of possible VRR paths? In general the Dijkstra algorithm\ncan not guarantee a global minimum because the global minimum may not be reached by\nby assembling minimums on the partial path. However, because L is constantly decreasing\nfrom LHS to RHS; the integral numbers are constantly decreasing from current search\niteration to the following ones. Therefore it could expect that the above procedure\nmay give the close VRR path comparing with the global optimum.\n\nIn terms of an arbitrary given unsolved $(L,m)$ shell quartets, all of shell quartets\nappearing in VRR can be divided into three groups:\n\\begin{itemize}\n \\item unsolved main list;\n \\item correlated list;\n \\item irrelevant list \n\\end{itemize}\nUnsolved main list contains the unsolved shell quartets with given properties of $(L,m)$.\nTheir expanding position are going to be determined in the current iteration of search. \nCorrelated list is composed by the unsolved shell quartets who possibly share the RHS \nterms with the unsolved main list. The irrelevant list is composed by all of other \nunsolved shell quartets and their expansion positions are independent with the \nunsolved main list. By combining the unsolved main list and correlated list together \nto form a package, all of correlated LHS shell quartets are self-contained therefore \nit's able to carry out a full search on all possible expansion combinations for every \nLHS shell quartets inside the package. The search result gives the final expanding\npositions to the unsolved main list.\n\nLet's take ERI as illustration. The VRR in equation \\ref{int_paper:7} demonstrates that \nfor ERI $I(L,m)$, only ERI of $I(L-1,m)$, $I(L,m+1)$ and $I(L-1,m+1)$ can share RHS with it.\nThese ERI are in unsolved state and their undetermined expansion will affect the determination \nof expanding position for $I(L,m)$. On the other hand, although ERI with $L+1$ or $m-1$ are \nalso possibly sharing RHS with $I(L,m)$, their expanding position have been solved in previous \niteration; therefore these shell quartets apply deterministic effects on the search of expanding \nposition searching for ERI $I(L,m)$. As a result of inconvertibility of VRR, the number of shell\nquartets which constitutes the correlated package decreases significantly.\n\nIn summary, for searching the expanding position of shell quartets with property of $(L,m)$, \nit's able to form an independent package with unsolved shell quartets characterized by property \n$(L-1,m)$, $(L,m+1)$ and $(L-1,m+1)$. A complete survey to find minimum RHS integrals for $(L,m)$\nshell quartets is performed in terms of all of possible expansion combinations for all of shell \nquartets inside the package. The implementation for the above algorithm is depicted as below:\n\\begin{verbatim}\nset up archive for solved shell quartets;\nset up archive for unsolved shell quartets;\ninitilize the unsolved archive with input shell quartets;\n\nloop over m (from m=0 to maximum):\n  loop over L (from maximum to 0):\n    while(true)\n      construct empty main shell quartet list, and fill \n      in shell quartets with (L,m) from unsolved archive;\n    \n      construct empty correlated shell quartet list, and \n      fill in possible shell quartets with (L-1,m), \n      (L,m+1) and (L-1,m+1) from unsolved archive;\n      \n      combine the main shell quartet list and appended\n      shell quartet list together into full list;\n      \n      loop over all possible expanding combinations:\n         compare the new RHS shell quartets with solved\n         and unsolved archives, remove the new RHS shell\n         quartet if it's double couting (vertical \n         comparison);\n         \n         compare the new RHS shell quartets with each \n         other and wipe out the repeat ones (horizontal\n         comparison);\n         \n         count the number of integrals from all remaining \n         RHS shell quartets, replace the old expansion\n         plan with new one if it's outperformed;\n      end loop of expanding combination \n       \n      for the optimal expansion plan, push the main\n      shell quartets into solved archive and the new\n      RHS shell quartets into unsolved archive;\n       \n      is there remaining shell quartets with property\n      of (L,m) in unsolved archive?\n      if not, step out the while loop;      \n    end while\n  end loop with L\nend loop with m \n\\end{verbatim}\n\nThe procedure establishes the result VRR path by assemble global minimum on each partial VRR\npath along the searching iterations. Such pseudocode not only applies to ERI, but also to\nKI, NAI etc. as long as the integral can be derived from recurrence relation with inconvertible\nproperty. Unfortunately, HRR can not employ the above algorithm because the inconvertibility \nis destroyed inside HRR:\n\\begin{align}\n\\label{int_paper:9}\n (a(b+\\iota_{i})|cd) &= ((a+\\iota_{i})b|cd) + AB_{i}(ab|cd)   \\nonumber \\\\\n                     &\\Updownarrow                            \\nonumber \\\\\n ((a+\\iota_{i})b|cd) &= (a(b+\\iota_{i})|cd) - AB_{i}(ab|cd)   \n\\end{align}\nFor example, if LHS shell quartet $(FD|PS)$ is expanded in terms of shell D position according \nto equation \\ref{int_paper:9}, in search of expanding position of result RHS shell quartet $(GP|PS)$\nit will resort to the expansion on shell G because the previous LHS $(FD|PS)$ becomes the RHS for\nexpanding $(GP|PS)$ and $(FD|PS)$ is already contained in the result path. As a result, the expansion \nsearch forms a cycles and the expanding positions for LHS shell quartets are never to be correctly \ndetermined in the generated HRR path.\n\nIn HRR we use another way to determine the optimal path. Since HRR expansion only concentrates on\neither bra or ket side, a trial expanding test is performed to determine the best bra/ket \nexpansion for HRR. For ERI the trial expanding positions are grouped into four cases; namely \nas (bra1,ket1), (bra1,ket2), (bra2,ket1) and (bra2,ket2). For each position combination a HRR \npath searching is conducted and the final HRR path picks up the one which generates the minimum\nintegral number.\n\n\\subsection{Redundancy Elimination for RR}\n\\label{redundancy_rr}\n\nAfter the optimal VRR/HRR path is set, the next step is to generate \nthe recursive expansion on integrals for each shell quartet on the \npath so to complete the forming of RR. The integral\ngeneration implicitly comes with a question, is every integrals in \nthe shell quartet needed by the RR? This open question becomes more \ninteresting considering the natural redundancy inside the Cartesian \ntype of Gaussian functions comparing with the spherical type of Gaussian\nfunctions.\n\nThe answer for this question is varying from case to case, therefore there's \nno general estimation can be made and the problem need to be investigated \non the fly. For studying the redundancy of integral inside RR, we propose\na general algorithm to generate integrals for the a given RR path:\n\\begin{verbatim}\nset up LHS list and initialize it\nwith input shell quartets;\nset up result RR formula archive;\nwhile(true):\n  loop over the LHS shell quartets in the LHS list:\n    form RR formula on integrals for the given LHS \n    shell quartet;\n    if the LHS not appear in RR path, push the new \n    RR formula into archive and exact the RHS \n    information;\n    else merge the new RR formula with the old one\n    which already appears in the archive;\n  end loop\n  do we have any new RHS terms? if not, exit the loop;\n  exacting all of new RHS terms and form new LHS list;\nend while\n\\end{verbatim}\nFor some shell quartets the above procedure can not grantee that every\nRHS integrals are defined previously. For solving the incompleteness,\na similar code like above is performed for all of missing RHS integrals\nto ensure the completeness of RR. We implemented the procedures for \nboth VRR and HRR.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% fmt\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{A New Scheme for calculating $f_{m}(t)$}\n\\label{fmt}\n\nThe $f_{m}(t)$ integral\n\\begin{equation}\\label{fm_ssssm_fmt_eq:1}\n f_{m}(t) = \\int^{1}_{0} u^{2m} e^{-tu^{2}} du \n\\end{equation}\nis a necessary component in calculating the bottom integrals of ERI $(00|00)^{m}$,\nNAI $(0|0)^{m}$ etc. Its calculation has been discussed in details in literature\n\\cite{harris1983sssm, gill1991two} etc. Here we try to present our model to calculate\n$f_{m}(t)$ in terms of a hybrid scheme, the implementation of the scheme can be \nfound in fmtIntegralsGeneration function of SQIntsPrint class.\n\nAs $m=0$ the $f_{m}(t)$ becomes error function:\n\\begin{equation}\n f_{0}(t) = t^{-\\frac{1}{2}} erf(t^{\\frac{1}{2}})\n\\label{fm_ssssm_fmt_eq:2}\n\\end{equation}\nwhich is available in variety of standard libraries. For $m>0$, $f_{m}(t)$\nis incomplete Gamma function and it satisfies a recursive expression:\n\\begin{equation}\n  f_{m}(t) = \\frac{1}{2m+1}\\left( 2tf_{m+1}(t) + e^{-t}\\right)  \n \\label{fm_ssssm_fmt_eq:3}\n\\end{equation}\nthus $f_{m}(t)$ can be derived from $f_{m_{max}}(t)$. On the other hand, equation\n\\ref{fm_ssssm_fmt_eq:3} can be reorganized as:\n\\begin{equation}\n  f_{m}(t) = \\frac{1}{2t}\\left( (2m-1)f_{m-1}(t) - e^{-t}\\right)    \n \\label{fm_ssssm_fmt_eq:4}\n\\end{equation}\nThis expression provides the easiest way to compute the $f_{m}(t)$ by starting from \n$f_{0}(t)$. However, equation \\ref{fm_ssssm_fmt_eq:4} is numerically instable due to\nerror propagation as $m$ grows larger.\n\n$f_{m}(t)$ is able to be expanded as polynomial series:\n\\begin{equation}\n \\label{fm_ssssm_fmt_eq:5}\n f_{m}(t) = e^{-t}\\sum_{k=0}^{\\infty}\\frac{(2m-1)!!}{(2m+2k+1)!!}\n (2t)^{k}\n\\end{equation}\nThe problem for equation \\ref{fm_ssssm_fmt_eq:5} is that it converges very slow as $t$\ngrows larger, therefore this expression is typically used for small t. As $t$ becomes large,\na continued fraction representation can be used to compute $f_{m}(t)$\\cite{harris1983sssm}:\n\\begin{equation}\n\\begin{split}\nf_{m}(t) &= \\frac{(2m-1)!!\\sqrt{\\pi}v^{m}}{2t^{\\frac{1}{2}}} \\\\\n         &- e^{-t}\n         \\left\\lbrace \n         \\frac{v}{1+}\\frac{(1-2m)v}{1+}\\frac{2v}{1+}\\frac{(3-2m)v}{1+}\\frac{4v}{1+}\n         \\frac{(5-2m)v}{1+}\\frac{6v}{1+\\cdots}\n         \\right\\rbrace \n\\end{split}\n\\label{fm_ssssm_fmt_eq:6}\n\\end{equation}\nwhere $v = (2t)^{-1}$. Although equation \\ref{fm_ssssm_fmt_eq:6} can yield very accurate\nresult, it's implementation is inefficient comparing with equation \\ref{fm_ssssm_fmt_eq:4}.\n\nMany standard libraries adopt the hybrid strategy for implementing $f_{m}(t)$. For instance,\nBOOST library\\footnote{please see \\url{http://www.boost.org/} for more details} expands \n$f_{m}(t)$ into polynomial series for small $t$, for large $t$ it uses\nLegendre's continued fraction representation for computation. However, is it possible \nto find a range in terms of $t$ and $m$ that $f_{m}(t)$ can be accurately calculated from\nequation \\ref{fm_ssssm_fmt_eq:4} so that to avoid the use of continued fraction representation?\n\nAs $t$ is small it's applicable to employ the polynomial expression of \\ref{fm_ssssm_fmt_eq:5} to \naccurately compute $f_{m}(t)$ for variety of $m$, hence the problem concentrates on how to calculate \n$f_{m}(t)$ for large $t$. Because equation \\ref{fm_ssssm_fmt_eq:4} will yields larger error as $m$ grows, \nwe try to find a limit of $m$; where under the limit it's able to use recurrence relation\n\\ref{fm_ssssm_fmt_eq:4} to compute $f_{m}(t)$ when $t$ is large, and above the limit the recurrence \nrelation \\ref{fm_ssssm_fmt_eq:3} is applied together with the calculation of $f_{m_{\\max}}(t)$. This \nhybrid procedure can be summarized as:\n\\begin{enumerate}\n \\item if $M_{max} == 0$, use error function;\n \\item if $M_{max} >= 1$ and $M_{max} <= M_{limit}$:\n \\begin{enumerate}\n  \\item if $t<=T_{limit}$, calculate $f_{M_{max}}(t)$ by using polynomial expansion of \n  \\ref{fm_ssssm_fmt_eq:5}, then use recurrence relation \\ref{fm_ssssm_fmt_eq:3} to compute \n  the rest of $f_{m}(t)$;\n  \\item if $t>T_{limit}$, calculate $f_{0}(t)$ with error function and \n  use recurrence relation \\ref{fm_ssssm_fmt_eq:4} to derive other $f_{m}(t)$;\n  \\end{enumerate}\n \\item if $M_{max} > M_{limit}$:\n  \\begin{enumerate}\n     \\item if $t<=T_{limit}$, calculate $f_{M_{max}}(t)$ by using polynomial expansion of \n  \\ref{fm_ssssm_fmt_eq:5}, then use recurrence relation \\ref{fm_ssssm_fmt_eq:3} to compute \n  the rest of $f_{m}(t)$;\n   \\item  if $t>T_{limit}$, calculate $f_{M_{max}}(t)$ \n  and use recurrence relation in \\ref{fm_ssssm_fmt_eq:3} for all of other $f_{m}(t)$.\n  \\end{enumerate}\n \\end{enumerate}\n$M_{max}$ is the largest $m$ value for $(00|00)^{m}$ type of integrals, $T_{limit}$\nrepresents the maximum limit of $t$ used in polynomial expansion \\ref{fm_ssssm_fmt_eq:5};\nand $M_{limit}$ is the limit of $m$ value that recurrence relation \\ref{fm_ssssm_fmt_eq:4}\nis able to be applied.\n\nTo explore the best $T_{limit}$ and $M_{limit}$ combinations, a trial test is performed on\nthe above hybrid scheme\\footnote{Please see section \\ref{use_util_codes}. The fmt\\_test\nin the util folder stores the testing code and comparison result log files}. \nIn this test the $T$ value is sampled in step length of 1.0E-6\nbetween $0$ and $T_{limit}$ for equation \\ref{fm_ssssm_fmt_eq:5}, and recurrence relation \n\\ref{fm_ssssm_fmt_eq:4} employs $T$ from $T_{limit}$ to $T_{max}$ with same step length.\nWhen $T$ is large enough, the $e^{-t}$ term in equation \\ref{fm_ssssm_fmt_eq:4} \nbecomes 0 thereafter the recurrence relation becomes stable in terms of error propagation.\nConsidering this fact the $T_{max}$ is set to be $40.0$. For polynomial expansion \n\\ref{fm_ssssm_fmt_eq:5}, $m$ is tested between $0$ and $40$. All of trial tests use \nthe BOOST library for calculating the standard $f_{m}(t)$.\n\nIn the trial test the polynomial expression \\ref{fm_ssssm_fmt_eq:5} \nalways keeps maximum absolute error within 1.0E-14 for the given $T_{limit}$, and the \nmaximum absolute error(MAE) for recurrence relation \\ref{fm_ssssm_fmt_eq:4} with regarding to \ndifferent $T_{limit}$ and $M_{limit}$ combinations is shown in table \\ref{table:1}. \nIt can be found that the all of MAE is below 1.0E-12, and \nwith $T_{limit}=2.0$, $M_{limit}=8$ recurrence relation \\ref{fm_ssssm_fmt_eq:4} reports\nMAE of 1.0E-14; thus it can be well expected the hybrid scheme is able to generate satisfiable\naccuracy for most of applications.\n\n\\begin{table}\n\\caption{maximum absolute error for recurrence relation \\ref{fm_ssssm_fmt_eq:4}}\n\\label{table:1}\n\\begin{center}\n\\begin{threeparttable}\n\\begin{tabular}{c|c|c|c}\n\\hline\n                    &       M = 8         &      M = 9        &   M = 10          \\\\\n\\hline\nT = 1.8(18 terms)\\tnote{a}   \n                    &       3.0E-14       &      1.2E-13      &   6.3E-13         \\\\\n\\hline\nT = 1.9(20 terms)   &       2.0E-14       &      0.7E-13      &   3.4E-13         \\\\\n\\hline\nT = 2.0(22 terms)   &       1.0E-14       &      0.4E-13      &   2.0E-13         \\\\\n\\hline\n\\end{tabular}\n\\begin{tablenotes}\n    \\item[a] this is the No. of terms used in equation \\ref{fm_ssssm_fmt_eq:5}\n\\end{tablenotes}\n\\end{threeparttable}\n\\end{center}\n\\end{table} \n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% application of rrsearch\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Application of Optimal Path for RR}\n\n\\subsection{Building RR Formula}\n\\label{rrbuild}\n%\n% this section introduce the RRbuild class\n% 1  RR expanding position\n% 2  RR formula for shell quartet\n% 3  RR formula for integral\n%\nFor constructing the recurrence relation, the first fundamental step is to set up some class\nthat we are able to describe the recurrence formula in the program. The class of RRbuild\nis used to perform this job.\n\nGenerally, the formula of RR can be expressed as:\n\\begin{equation}\\label{general_rr_formula}\n I_{LHS} = a_{0}I_{0} + a_{1}I_{1} + a_{2}I_{2} + a_{3}I_{3} + a_{4}I_{4} + \\cdots\n\\end{equation}\nAll of $I_{i}$ is integral recursively derived from previous content. Usually the RHS\nintegrals or shell quartets in \\ref{general_rr_formula} are formed by raising up or \ndecreasing angular momentum or m value in terms of LHS. Sometimes the operator is also\nchanged from LHS to RHS, for example; the VRR expansion for two body kinetic integrals\nin the OS framework.\n\nA general RR formula has two properties. Firstly, for RR formula applying on\nmultiple body integrals the expanding position is needed to be specified. This is \nbecause there potentially has multiple expanding positions available for forming\nthe RR expansion on given integral or shell quartets\\footnote{please refer to the \ndiscussion of \\ref{optimal_path} for more details}, and usually different expanding \nposition will lead to different result RR formula. For example, the HRR expansions\non ERI $(ab|cd)$ shown in equation \\ref{int_paper:9} are different between expansion\non BRA1 and expansion on BRA2.\n\nFor RR expansion on shell quartets, if the RR algorithm and the expanding position\nare both determined; then the RR formula is set up for the given shell quartet.\nUnder such circumstance, for the given LHS shell quartet it's able to derive\nall of RHS shell quartets, and especially figure out which RHS shell quartet is \n``NULL''(it means this term does not appear in the result RR expansion). The function\nof buildRRSQ in rrbuild.cpp is performing this work.\n\nHowever, for the RR formula on integral the result RR formula is still unsolved yet.\nWith a determined expanding position on a given RR formula, to solve LHS integral\nit's needed to specify the direction of RR formula. For example, the VRR expansion \nfor ERI is:\n\\begin{equation}\n \\begin{split}\n((a+\\iota_{i})b|cd)^{(m)} &= (P_{i} - A_{i})(ab|cd)^{(m)} +\n\\left(W_{i} -P_{i}\\right)(ab|cd)^{(m+1)} \\\\\n&+\\frac{N_{i}(A)}{2\\epsilon}\\left(((a-\\iota_{i})b|cd)^{(m)}-\\frac{\\rho}{\n\\epsilon }((a-\\iota_{i})b|cd)^{(m+1)}\\right)  \\\\\n&+\\frac{N_{i}(B)}{2\\epsilon}\\left((a(b-\\iota_{i})|cd)^{(m)}-\\frac{\\rho}{\n\\epsilon }(a(b-\\iota_{i})|cd)^{(m+1)}\\right)  \\\\\n&+\\left(\\frac{N_{i}(C)}{2}\\right)\\frac{1}{\\epsilon+\\eta}\n(ab|(c-\\iota_{i})d)^{(m+1)} \\\\\n&+\\left(\\frac{N_{i}(D)}{2}\\right)\\frac{1}{\\epsilon+\\eta}\n(ab|c(d-\\iota_{i}))^{(m+1)}\n\\end{split}\n\\end{equation}\nThis expansion is on ``BRA1'' position. However, the direction information on $i$ \ncould be x, y or z so that it needed to be specified. As long as the $i$ is specified,\nit's able to derive the RHS integrals as well as the RHS coefficients like \n$PA_{i} = P_{i} - A_{i}$(i is x, y or z) or $N_{i}(A)$, $N_{i}(B)$ etc. appearing in\nthe formula \\footnote{please refer to the code rrbuild.cpp or the original OS paper\n\\cite{OS1986} for the meaning of these symbols}.\n\nThe function of buildGeneralVRR and buildGeneralHRR are used to build a general \nRR formula in terms of a given position (position must be provided for RRBuild\nclass so that to construct a specific RR expansion). The function of determineDirection\nis used to derive the undermined direction information for the given RR formula.\nIn fact, this is the core function for deriving the redundancy of RR(please see the \nsection \\ref{redundancy_rr} for more information). Because after\nthe direction is set, for the given LHS shell quartet it's able to figure out\nwhat's the RHS integral is practically referred in the RR expansion. The unrefereed\nintegrals, or in other words; the unused integrals represent the redundancy of \nresult RR path.\n\nAfter direction of $i$ i set, accordingly it's able to figure out the $N_{i}$ value\nappearing in the RR formula for the RHS integrals. This job is performed in function\ndetermineNi of rrbuild.cpp. Finally, by bringing all of information together it's able\nto derive the full RR formula for a given LHS integral from the function buildRRInt. \n\n\\subsection{Optimal RR Path Search in RR}\n\\label{rrsqsearch}\n\nThe optimal RR path search is carried out in rrsqsearch.cpp. The implementation \nexactly follows the idea discussed in section \\ref{optimal_path}.\n\nThe function RRSearchBasedOnTWOProperty in rrsqsearch.cpp realizes the pseudo codes\ndescribed in section \\ref{optimal_path}. Considering VRR for different kinds of \nintegrals, the VRR properties could be $L$ and $m$ (for example, ERI, NAI etc.);\nor could be $L$ and operator type (two body kinetic integrals) etc. This function\nperforms optimal VRR path search based on two combined properties or one property\nvaried on VRR formula. \n\nThe RRSQSearch class (which defined in the rrsqsearch) has two data members, one \nis solvedSQList, which stores the shell quartets which appears in the RR path and \nit' expanding position has been solved. The unsolvedSQArch stores all of undetermined\nshell quartets so to keep as archive purpose during the path search.\n\nAs entering into the work loop in RRSearchBasedOnTWOProperty function, it sets up\ntwo lists; one is unsolvedMainSQList which stores the result shell quartets for \nthe corresponding properties (for example, for fixed $L$ and $m$), and the other\nis unsolvedAppendSQList which is equivalent to the ``correlated shell quartet list'',\nand it's used to store the correlated shell quartet list. In pickupUnsolvedSQ \nfunction, it forms both of two lists according to the discussion in section \n\\ref{optimal_path}. Afterwards, the global search is performed in the function \nsearchOptPos on both of the two lists, and the expanding positions will be determined\nfor the unsolvedMainSQList.\n\nIn rrsqsearch.cpp we set up another class, which is called RRShellQuart and it's \nused to hold all of it's possible expanding RR expansion information. In the \nsearchOptPos, the input shell quartet list will be transfered into a list of \nRRShellQuart so that it contains all of possible expansion information. Finally,\nby setting up a multi-dimensional array whose name is loop\\_identifier(see the \ncomments of the code), we loop over all of possible combinations between the \nexpanding position for each input shell quartet; and finally derive the position\nwhere minimum number of integrals are generated.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% redundancy\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% how to realize RR\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n\\section{RR Formulation}\n\n\\subsection{Building RR Expression for Each Shell Quartet}\n%\n%  1  what is unsolved integral list\n%  2  whether it's integal index or not?\n%  3\n%\n%\nFor each LHS shell quartet on the RR path, to build explicit RR expression\nthe following information are needed:\n\\begin{itemize}\n \\item the expanding position which is derived from RRSQSearch class in \n \\ref{rrsqsearch};\n \\item general RR expanding formula set up by RRBuild class in \\ref{rrbuild};\n \\item the unsolved integral list corresponding to the LHS shell quartet \n\\end{itemize}\nUnsolved integral list contains all of LHS integrals. We only form RR expansion\nfor the given integral list, and it implies that the integral list could be \nonly a subset of the whole integrals corresponding to the LHS shell quartet.\nThis is the natural result deriving from the redundancy of using Cartesian\nform of basis set function in RR (see section \\ref{redundancy_rr} for more\ndetails). Unsolved integral list is generated during the RR process from\nthe RHS shell quartet in the subsequent context (the generation of unsolved\nintegral list is referred to section \\ref{rr_code}).\n\nIn the previous section \\ref{mapping_integral_sq}, we stated that\nin the RR formation the integrals is actually expressed by it's index\nin the corresponding shell quartet. Here the unsolved integral list\nis also formed as index list. During the whole RR process all of integrals\non both RHS and LHS are all referred as index form. After the RR is formed,\nhowever the original index could be destroyed and replaced with ``array index''.\n\nThe array index refers to the final position of the integral in the result\ncode. For example, $(DD|PP)$ has 324 integrals in total, however in the RR\nprocess it only uses 270 integrals so there are 54 unused integrals appear\nas redundancy. The integral index forms the one to one mapping between  \nthe integral itself and the shell quartet, the array index characters the \nfinal position for the given integral, for example; the position index of \n$(D_{xy}D_{yz}|P_{x}P_{z})$ in SQ\\_DDPP array in the result code. If the \nintegral index is transformed into array index, all of index information\ncan not be restored (see the comment in rrints.h for more details). This \nis what function rhsArrayIndexTransform and lhsArrayIndexTransform do.\n\nfor a given specific unsolved integral list, RRInts may create it's RR \nexpression if this is a fresh new LHS shell quartet on the RR path, this\nis done through the constructor; or do updating if the given LHS shell \nquartet already exists. The updating function is performed in function\nupdateLHS. This function will search the new integral from the input\nunsolved integral list and merge it's RR expression into the current RR\nexpression archive. This is the core function to perform ``completeness\ncheck'' step described in \\ref{redundancy_rr} and \\ref{rr_code}.\n\n\\subsection{Forming RR Path}\n\\label{rr_code}\n%\n% 1  the general steps to form RR\n% 2  what's the purpose rrsqsearch?\n% 3  how to create all of rrsq information?\n% 4  how to do updating function\n% 5  sorting function of RR\n%\nBased on the rrints.cpp, now we are able to form whole RR path for \neither VRR or HRR. Generally RR formation requires the following \nsteps:\n\\begin{itemize}\n \\item for the input shell quartet list(they are the results of RR path), \n finds all of shell quartets on the RR path through RRSQSearch class;\n \\item derive the initial unsolved integral list from the input \n shell quartets, building RR for each LHS shell quartet recursively\n until the RR path reaches it's top;\n \\item sorting the whole RR so that to establish the direction from\n LHS to RHS or RHS to LHS;\n \\item completeness check to see whether we have undefined LHS integrals.\n If so, rrUpdating function is called to complement RR path;\n \\item transform all of integral index into array index if the given RR\n section only uses array in printing the code\n\\end{itemize}\n\nAs the initial step, RRSQSearch class finds all of shell quartets appearing\nin the optimum RR path by the giving input shell quartet list. Additionally,\nit also determines the RR expanding position for each shell quartet. \n\nAfter the shell quartet is set, function of formRRSQList begins to build \nthe whole RR content. By calling function buildRRSQList iteratively, \nformRRSQList form RR details for each bunch of LHS shell quartets and it's \nunsolved integral list. The pseudo code for buildRRSQList is like this:\n\\begin{verbatim}\nset up initial LHS shell quartet list and initialize \nthe corresponding unsolved integral list;\nwhile(true):  \n  Have all of the LHS shell quartets been built in\n  the existing RR path? Or the LHS shell quartets\n  are bottom integrals? If so, break;\n  For the new LHS shell quartet, build it's RR \n  through RRSQ class in rrints.cpp and push it\n  into the RR path;\n  Get the RHS shell quartets (unsolved ones) and \n  it's corresponding unsolved integral list from\n  RRSQ, and replace the LHS shell quartet and \n  the unsolved integral list with the new content\nend while \n\\end{verbatim}\n\nAs we stated early in section \\ref{redundancy_rr}, during \nthis process it's possible that some LHS integral may \nnot be defined; therefore the ``completeness check''\nstep is needed to be performed in function of completenessCheck.\nAfter identifying the missing undefined LHS integrals\nthe function of rrUpdating will complete the definition\nfor all of LHS integrals in RR.\n\nFor either HRR or VRR, one of necessary function is to sort\nthe result RR path so that to print the RR exactly from \nLHS to RHS. The core of sorting function is embedded in the \nshell quartet class (see \\ref{sort_shell_quartet} for more \ndetails), and RRSQ class in rrints.cpp set up the operator\n$<$ by using the core function in shell quartet class.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Top Level Classes of CPPINTS}\n\nIn this section, we will discuss the working classes on the top of \nthe working modules of RR, so as to complete the whole integrals\nforming.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% infor class\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Gathering Input Information from User}\n\\label{infor_class}\n\ninfor.cpp establishes an communication between the user and CPPINTS\nprogram. In the Infor class, CPPINTS allows the user to manipulate\nthe generation of integrals through user-specified options which is \ndefined in parameter file. All of options that user can access is \nexplained in detail through a sample file named as ``infor.txt''. \n\n\n\n\n", "meta": {"hexsha": "783f02864307da2c26bdcf72ab1d3d86aa613c24", "size": 39584, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/rr.tex", "max_stars_repo_name": "murfreesboro/cppints", "max_stars_repo_head_hexsha": "a7beaac034e2bfae8e71997b322133906d1afcaf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/rr.tex", "max_issues_repo_name": "murfreesboro/cppints", "max_issues_repo_head_hexsha": "a7beaac034e2bfae8e71997b322133906d1afcaf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/rr.tex", "max_forks_repo_name": "murfreesboro/cppints", "max_forks_repo_head_hexsha": "a7beaac034e2bfae8e71997b322133906d1afcaf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.274611399, "max_line_length": 106, "alphanum_fraction": 0.7306992724, "num_tokens": 10584, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.447051498190143}}
{"text": "\\chapter{Pendulum}\nAfter succeeding to generate simple, interpretable solutions for cart-pole and mountain-car, I wanted to choose an environment that (1) was similar enough to expect the same general approach to be fruitful, and (2) posed a challenge that the GP algorithm had not yet overcome. Pendulum (also known as the inverted pendulum problem) is another popular classic control RL benchmark that simulates a pendulum suspended from a frictionless pivot. In the initial state of the environment the angle of the pendulum is randomised. The goal is to swing it until it points upwards and then keep it steady for as long as possible. Interestingly, the mechanics of the problem are very similar to mountain-car, but with one important difference that makes it significantly more difficult to solve: the desired state of the environment (the pendulum pointing up, which is equivalent to the car standing on top of the hill) needs to, not only be reached, but maintained. Practically, this means that the agent has to combine two strategies: one for transitioning to that desired state and another one for maintaining it.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% 6.1 Environment Details %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Environment Details}\nThe observation object for this environment consists of the trigonometric functions $sin(\\theta)$ (\\verb+sintheta+) and $cos(\\theta)$ (\\verb+costheta+), which on a high level describe the angle between the pendulum and the horizontal axis, and the angular velocity of the pendulum, $\\dot\\theta$ (\\verb+thetadot+) which is a measure of how fast the pendulum is rotating. The sign of \\verb+thetadot+ indicates whether the pendulum is rotating clockwise (negative) or anticlockwise (positive), while the signs of \\verb+costheta+ and \\verb+sintheta+ vary based on the spatial region the pendulum occupies. Notice that this allows for the environment space to be split into four quadrants based on the signs of these two quantities (figure \\ref{fig:pendulum_quadrants}), an observation that proved very useful in conceptualising many aspects of the problem and interpreting the various solutions the algorithm generated. The action space is the range $[-2.0, 2.0]$ of floating-point numbers, which represent the force (torque) that is applied to control the pendulum's rotation. Finally, the reward comes in the form of a cost, which means the agent receives a negative reward at each time-step (the maximum is $0$) that is proportional to the angle of the pendulum, its angular velocity, and the torque applied to it (see the GitHub Wiki page\\footnote{\\url{https://github.com/openai/gym/wiki/Pendulum-v0}} for the precise equation for the reward). \n\nTherefore, the goal of the environment is to bring the pendulum to a vertical angle, and keep it there with minimum effort. Unlike the previous environments, the solution criteria here are unspecified, so the average reward of an agent that takes random actions ($\\approx-1220$) was used as a reference point for measuring performance.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/pendulum_quadrants.png}\n    \\caption{Visualisation of the signs of the pendulum observations}\n    \\label{fig:pendulum_quadrants}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% 6.2 Experiment 1: Simple GP Agent %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Experiment 1: Simple GP Agent}\n\n% Setup %\n\\subsection{Setup and Motivation}\nThe main aim of the first experiment was to establish a performance baseline for the succeeding experiments to use as a reference point. Therefore, the program structure was simple, and similar to the one used in the previous environments:\n\n\\begin{verbatim}\nF = {IFLTE}\nT = {costheta, sintheta, thetadot, -1.0, 0.0, 1.0}\n\\end{verbatim}\n\nThe function set only includes the \\verb+IFLTE+ function that proved very useful in solving the first two environments, and the terminal set includes all of the environment observations as well as three constants. The motivation behind the specific choice of constants was to allow the agent to draw decision boundaries around the observations (e.g. \\verb+if costheta <= 0.0 and sintheta <= 0.0 then ...+) because a good strategy will probably need to make different decisions based on the angle of the pendulum. Since \\verb+costheta+ and \\verb+sintheta+ range over $[-1.0, 1.0]$, those limits were chosen as the constants, along with $0$ because it is reasonable to hypothesise that information about the sign of the observations is useful (for example the sign of \\verb+thetadot+ can be used to determine whether the pendulum is rotating clockwise or anticlockwise).\n\nThe setup for this first experiment (summarised in table \\ref{tab:pendulum_exp1_params}) followed that of the previous environments, with a few notable differences. Tournament selection was chosen instead of fitness proportionate selection, as discussed in Methods. Mutation was used for the first time to encourage exploration and avoid early convergence, both of which were not necessary in cart-pole and mountain-car. Notice, also, that while in the previous environments the terminal fitness was always the average reward required for a solution, the value used here was chosen more arbitrarily since pendulum has no specified solution criterion. Additionally, since pendulum has no episode termination criteria, the episode length had to be constrained explicitly. Finally, the number of episodes each program was run for to compute its fitness had to be decreased. The reason for this was, again, the absence of termination criteria: in cart-pole and mountain-car, even though the maximum episode length was 200 time-steps, most episodes did not run for that long, especially during the first few generations, because the programs failed quickly, causing the episodes to terminate prematurely. In pendulum, however, no such restriction exists, which meant that every program ran for the full episode length every time. As a result, the training time significantly increased, and it became impractical to run multiple experiments. The solution of reducing the number of episodes came at the cost of robustness because the fitness of each program became more sensitive to the randomisation of the initial environment state. This cost did not seem to be severe, however, since the experiment results showed a steady improvement in overall fitness from generation to generation. \n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameters} & \\textbf{Values} \\\\\n        \\hline\n        Population size     & 200  \\\\\n        Max generations     & 20   \\\\\n        Terminal fitness & -200 \\\\\n        Tournament size     & 10   \\\\\n        Mutation rate       & 0.1  \\\\\n        Max program depth   & 5    \\\\\n        Number of runs      & 10   \\\\\n        Number of episodes  & 10   \\\\\n        Episode length      & 200  \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Experimental parameters (Pendulum Experiment 1)}\n    \\label{tab:pendulum_exp1_params}\n\\end{table}\n\n% Results %\n\\subsection{Results and Discussion}\n\\subsubsection{Average Fitness Per Generation}\nThe average fitness the programs of each generation achieved is visualised in figure \\ref{fig:pendulum_exp1_plot}. The first generation of programs performed very poorly, which was expected since they were randomly generated, but performance radically improved during the first four generations, before converging and remaining roughly the same for the remainder of the GP run. While the GP algorithm performed as expected, with each generation of programs performing better than the previous ones, it converged on a sub-optimal solution very quickly and showed no sign of improvement thereafter. Increasing the mutation rate delayed convergence and increased the variance in average fitness, but failed to make the algorithm escape the local minimum it appeared to be stuck on. These results gave rise to the hypothesis that the algorithm had discovered the best possible strategy given its current program structure, and failed to find a better solution because the program space was too restricted. Therefore, it was decided that the next experiment would introduce additional features to the language that could potentially be used to discover better solutions.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/pend_simple_gp_agent.png}\n    \\caption{Average population fitness vs generations}\n    \\label{fig:pendulum_exp1_plot}\n\\end{figure}\n\n\\subsubsection{Best-Performing Programs}\nAt the end of each of the 10 runs of GP, the best-performing program, as well as the average reward (fitness) it achieved over 100 consecutive episodes, were recorded. The average fitness achieved by these programs was $-857$ and the programs themselves can be seen in table \\ref{tab:pendulum_exp1_best_programs}. Looking at these programs, it quickly becomes obvious that most of them are identical or logically equivalent to the program \\verb+IFLTE(thetadot, 0.0, costheta, 0.0)+. Additionally, it turned out that the programs that seem to be different due to their complexity (programs 3, 5, and 8 in the table) can also be reduced to this program. Therefore, the algorithm did not simply converge on various strategies with similar performance scores, but on syntactically equivalent programs that encoded a single strategy. This observation provided further evidence that the hypothesis regarding the limitations imposed by the program structure was correct.\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\multicolumn{1}{|c|}{\\textbf{Programs}} & \\textbf{Fitness} \\\\\n        \\hline\n        \n        \\verb+IFLTE(thetadot, 0.0, costheta, 0.0)+ & -906  \\\\ \\hline\n        \\verb+IFLTE(0.0, thetadot, 0.0, costheta)+ & -835  \\\\ \\hline\n        \\verb+IFLTE(0.0, IFLTE(-1.0, 1.0, thetadot, sintheta), 0.0, costheta)+ & -884  \\\\ \\hline\n        \\verb+IFLTE(thetadot, 0.0, costheta, 0.0)+ & -826  \\\\ \\hline\n        \n        \\verb+IFLTE(thetadot, 0.0, costheta,+ & \\\\\n        \\verb+  IFLTE(IFLTE(1.0, thetadot,+ & -833 \\\\\n        \\verb+  IFLTE(-1.0, 0.0, -1.0, thetadot), -1.0), -1.0, 0.0, thetadot))+ & \\\\\n        \\hline\n        \n        \\verb+IFLTE(0.0, thetadot, 0.0, costheta)+ & -852  \\\\ \\hline\n        \\verb+IFLTE(0.0, thetadot, 0.0, costheta)+ & -832  \\\\ \\hline\n        \n        \\verb+IFLTE(0.0, thetadot,IFLTE(costheta, 1.0,+ & \\\\\n        \\verb+  IFLTE(0.0, 1.0, 0.0, costheta),+ & -892 \\\\\n        \\verb+  IFLTE(0.0, -1.0, costheta, -1.0)), costheta)+ & \\\\\n        \\hline\n        \n        \\verb+IFLTE(thetadot, 0.0, costheta, 0.0)+ & -868  \\\\ \\hline\n        \\verb+IFLTE(0.0, thetadot, 0.0, costheta)+ & -842  \\\\ \\hline\n    \\end{tabular}\n    \\caption{Best programs of each GP run (Pendulum Experiment 1)}\n    \\label{tab:pendulum_exp1_best_programs}\n\\end{table}\n\n\\subsubsection{Strategy Interpretation}\nThe program discovered by the GP algorithm, while not optimal, performed significantly better than a random agent, which made it a good starting point for tackling pendulum. It is, therefore, useful to discuss the interpretation of the strategy this program encodes to identify its limitations and justify the improvements implemented in the subsequent experiments. As noted in the environment description, the agent's goal is twofold: swing the pendulum until it's standing upright, and then keep it there with minimum effort. So, the strategy should be examined in terms of how well (or poorly) it performs with respect to these two sub-goals. \n\nThe strategy encoded by this program is: \"if the pendulum is rotating clockwise (negative angular velocity), then apply a torque to it that is equal to the cosine of its angle; otherwise, apply no torque to it at all.\" To understand this strategy, one needs to understand how \\verb+costheta+ changes in the environment. As seen in figure \\ref{fig:pendulum_quadrants}, \\verb+costheta+ is negative in the bottom two quadrants, $0$ when the pendulum is parallel to the horizontal axis, and positive in the upper two quadrants. Therefore, concerning the first sub-goal, if the pendulum is rotating clockwise, a negative torque is applied to it, accelerating its clockwise rotation, whereas if the pendulum is rotating anticlockwise, it is let to swing freely. The result of this is that the pendulum is repeatedly pushed to rotate clockwise, then allowed to swing back freely, until it has built enough momentum to swing to the upper section of the screen. An interesting detail to note is that as the pendulum approaches a horizontal angle from the bottom quadrants, \\verb+costheta+, and in turn the applied torque, tend to $0$. The effect of this is that the pendulum's momentum is great enough for it to reach an upright position, but not too great to cause it to be impossible to slow down (and, then, balance) once it has reached it. Finally, notice that this first half of the strategy is similar to the one discovered for mountain-car, where the car is pushed back-and-forth until it has enough momentum to climb the hill and reach the goal. This makes sense considering the similarity between the two environments discussed earlier.\n\nIt is clear that this strategy achieves the first sub-goal, but the difference to mountain-car is that the agent now has to use a different strategy to achieve the additional sub-goal of balancing the pendulum upright. When the pendulum enters the top-left quadrant, \\verb+costheta+ becomes positive. Since \\verb+thetadot+ is still negative at this point, this change causes the pendulum to slow down, as an opposite torque equal to \\verb+costheta+ is applied to it. When \\verb+thetadot+ is decreased to $0$ the else-branch of the if-statement encoded in the strategy takes effect and no torque is applied, preventing the pendulum to enter an anticlockwise rotation. The observed result is that the pendulum gradually slows down until it reaches the vertical position, then begins to speed up as it reaches the upper-right quadrant, and eventually falls to the bottom, letting the entire process repeat, with the only difference being that the pendulum has enough momentum now to not need to be swung back-and-forth to 'escape' the bottom quadrants.\n\n\\subsubsection{Problems and Ideas For Improvement}\nThis strategy solves the first sub-problem of escaping the bottom quadrants adequately and approximates a solution to the second sub-problem of keeping the pendulum standing upright by slowing it down and then applying no torque to it, which keeps it close to a vertical angle for some time and minimises the applied effort. The issue with this strategy is that, while the pendulum slows down, it doesn't stop once it reaches that vertical angle, so it inevitably falls to one side and keeps rotating.\n\nIt seemed that the current program structure should be sufficient to figure out an improvement for this strategy that addressed this issue. For example, a nested if-statement might be used to describe a new case where the pendulum is at a vertical angle and an action to take in that case, which would result in the desirable balancing behaviour. Additionally, as discussed above, it was reasonable to assume, based on the results, that the algorithm suffered from an early convergence problem that an extension to the program space might be able to improve. With this in mind, the second experiment was set up with a minor extension to the program structure and an encouragement of exploration in the form of an increase to the program depth and the maximum number of generations to evolve.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% 6.3 Experiment 2: Exploration %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Experiment 2: Exploration}\n\n% Setup %\n\\subsection{Setup and Motivation}\nThis experiment was intentionally very similar to experiment 1. As seen in table \\ref{tab:pendulum_exp2_params}, most parameters were left unchanged with a few exceptions. Specifically, the terminal fitness was decreased from $-200$ to the theoretical maximum, $0$, in case this version of the agent managed to find an exceptionally good solution. More importantly, the maximum number of generations and the program depth were increased to encourage exploration by allowing the GP algorithm more time to generate more complex programs.\n\nThe program structure was also very similar, with only two additions that would hopefully allow for better strategies to emerge without reducing interpretability. The function \\verb+neg+, which simply returns the opposite of a numerical input, was introduced to increase the number of combinations of observation values used without introducing completely new constructs. Secondly, a small constant ($0.25$) was added to the terminal set to give the agent an alternative value to use as an action. The motivation behind this last addition was that if one of the evolved strategies managed to balance the pendulum at a vertical angle, it would need to apply as small a torque as possible to minimise its effort. Finally, the constants $1.0$ and $-1.0$ were removed, since they didn't prove to be useful in the previous experiment.\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameters} & \\textbf{Values} \\\\\n        \\hline\n        Population size     & 200  \\\\\n        Max generations     & 30   \\\\\n        Terminal fitness & 0 \\\\\n        Tournament size     & 10   \\\\\n        Mutation rate       & 0.1  \\\\\n        Max program depth   & 10    \\\\\n        Number of runs      & 5   \\\\\n        Number of episodes  & 10   \\\\\n        Episode length      & 200  \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Experimental parameters (Pendulum Experiment 1)}\n    \\label{tab:pendulum_exp2_params}\n\\end{table}\n\n% Results %\n\\subsection{Results \\& Discussion}\n\\subsubsection{Average Fitness Per Generation}\nAs seen in figure \\ref{fig:pendulum_exp2_plot}, the average fitness followed a similar pattern to that of the previous experiment, starting very low and increasing rapidly in the first 4 generations. However, in this case, the algorithm did not converge on a single strategy at that point, but kept improving for the remainder of the run. This is an indication that expanding the program space had the desired effect of allowing the algorithm to escape the sub-optimal solution it was stuck on and discover better-performing strategies.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/pendulum_deep_simple_GP.png}\n    \\caption{Average population fitness vs generations}\n    \\label{fig:pendulum_exp2_plot}\n\\end{figure}\n\n\\subsubsection{Best-Performing Programs}\nWhile already visible in the average fitness graph, the best-performing programs of each GP run confirmed that the experiment was a success. The 5 generated programs, listed in table \\ref{tab:pendulum_exp2_best_programs}, achieved an average fitness score of $-494.8$, almost half of what was achieved in the previous experiment, without an increase in complexity. Additionally, similarly to the previous experiment, all of these programs encode a single strategy which is easy to interpret. It is also interesting to note that the only useful modification to the program structure seems to have been the introduction of the \\verb+neg+ function. Finally, increasing the population size and the number of maximum generations did not yield a better strategy, which is an indication that the algorithm had once again reached the limits allowed by the current program structure, so an improvement would probably require a language extension.\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\multicolumn{1}{|c|}{\\textbf{Programs}} & \\textbf{Fitness} \\\\\n        \\hline\n        \n        \\verb+IFLTE(neg(sintheta), thetadot, neg(costheta), costheta)+ & -550  \\\\ \\hline\n        \\verb+IFLTE(neg(sintheta), thetadot, neg(costheta), costheta)+ & -453  \\\\ \\hline\n        \\verb+IFLTE(thetadot, neg(sintheta), costheta, neg(costheta))+ & -522  \\\\ \\hline\n        \\verb+IFLTE(neg(thetadot), sintheta, neg(costheta), costheta)+ & -480  \\\\ \\hline\n        \n        \\verb+IFLTE(thetadot, IFLTE(0.25, 0.0,+ & \\\\\n        \\verb+  thetadot, neg(sintheta)), costheta,+ & -469 \\\\\n        \\verb+  IFLTE(costheta, costheta, neg(costheta), neg(0.0)))+ & \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Best programs of each GP run (Pendulum Experiment 2)}\n    \\label{tab:pendulum_exp2_best_programs}\n\\end{table}\n\n\\subsubsection{Strategy Interpretation}\nAll of the programs generated by the GP algorithm are identical or logically equivalent to the program \\verb+IFLTE(thetadot, neg(sintheta), costheta, neg(costheta))+, which encodes the following strategy: \"if \\verb+thetadot+ $\\leq$ -\\verb+sintheta+ then apply a torque of magnitude \\verb+costheta+; otherwise, apply a torque of magnitude -\\verb+costheta+.\" Due to the mathematical nature of the description of the environment, this strategy does not seem intuitively interpretable. It is, therefore, useful to examine how this strategy causes the pendulum to behave in each of the four quadrants, as displayed in figure \\ref{fig:pendulum_quadrants}. Additionally, it is useful to assess how well this strategy performs with respect to the two sub-goals that the agent needs to achieve: (1) rotate the pendulum until it reaches an upward vertical angle and (2) keep the pendulum balanced once it reaches that position.\n\nWith respect to (1), the two bottom quadrants are of interest. If the pendulum is in the bottom-right quadrant and \\verb+thetadot+ $\\leq$ \\verb+-sintheta+ then \\verb+thetadot+ is in $[-8.0, 1.0]$, which means the pendulum is either rotating clockwise, or it's rotating anticlockwise at a very low speed. In this case, the strategy applies a torque of magnitude \\verb+costheta+, which is a negative value. If, however, the pendulum is in the bottom-right quadrant and is rotating anticlockwise at a high speed, apply a torque of magnitude \\verb+-costheta+, which is a positive value. Therefore, in the bottom-right quadrant, the strategy says, if the pendulum is rotating clockwise, or anticlockwise but at a low speed, then push it clockwise, but if it's rotating anticlockwise at a high speed, then push it anticlockwise. This seems to be the most efficient way of making the pendulum swing up to the top quadrants, so this part of the strategy is reasonable. \n\nIf the pendulum is in the bottom-left quadrant, a similar rule is applied. If \\verb+thetadot+ $\\leq$ -\\verb+sintheta+ then \\verb+thetadot+ is in $[-8.0, 0.0]$, which means the pendulum is rotating clockwise. In this case, the pendulum is pushed by \\verb+costheta+, and therefore clockwise since \\verb+costheta+ is negative, accelerating its current rotation so that it can reach the top quadrants. If \\verb+thetadot+ $\\geq$ -\\verb+sintheta+ then \\verb+thetadot+ is in [-1.0, 8.0], which means it's rotating anticlockwise or clockwise at a low speed. In this case, the pendulum is pushed by -\\verb+costheta+, and therefore anticlockwise, which also accelerates its current rotation. Again, this seems to be the most efficient way to increase the pendulum's momentum enough to make it escape the bottom quadrants and achieve the first sub-goal.\n\nWith respect to (2), the top quadrants are considered. If the pendulum is in the top-left quadrant and \\verb+thetadot+ $\\leq$ -\\verb+sintheta+ then the pendulum is rotating clockwise. In this case, the pendulum is pushed by \\verb+costheta+, and therefore anticlockwise. This serves to slow the pendulum down, which is the desired behaviour here. If the pendulum is in the top-left quadrant and rotating anticlockwise, then it's pushed clockwise, bringing it towards the desired vertical angle. Similarly, in the top-right quadrant, if the pendulum is rotating clockwise (or anticlockwise but at a very low speed) then it is pushed anticlockwise, which pushes it towards the vertical angle, and if it is rotating anticlockwise, then it is pushed clockwise, which slows it down.\n\n\\section{Manual Improvement}\n\\subsection{Problem With Current Strategy}\nThe strategy generated as a result of experiment 2, seemed to behave effectively with respect to both sub-goals, in each of the four states (quadrants) that the pendulum might be in. This, then, begged the question, why this strategy could not achieve a better score. The first possible problem (confirmed by manual observation) was that the maximum value of \\verb+costheta+ and -\\verb+costheta+ (the two values used as the applied torque) were not large enough to slow down the pendulum when it was swung up to the top quadrants. So, if the agent failed to balance the pendulum on its first rotation, it would have accumulated too much momentum by the second rotation for the agent to be able to slow down and balance it. \n\n\\subsection{Manual Intervention and Significance of Results}\nThis problem seemed simple to address: every occurrence of \\verb+costheta+ could be replaced with \\verb+costheta+ multiplied by some constant, to increase the torque applied to the pendulum, which would hopefully allow it to maintain its balance once it has reached a vertical angle. To test this hypothesis, a simple, brute-force optimisation procedure was implemented, which evaluated the strategy multiple times, each time multiplying \\verb+costheta+ by a different constant (the range used was $[1.0, 10.0]$), and returned the constant that made the strategy perform the best. The result was surprisingly positive. The same strategy, modified to multiply the applied torque by $9.0$, consistently achieved an average reward of $\\approx-200$ over 100 consecutive episodes. For comparison, the best neural-network-based solutions on the environment leaderboard page\\footnote{\\url{https://github.com/openai/gym/wiki/Leaderboard}} achieve an average reward of $\\approx-123$. The following is the program that achieved this result: \\\\\\verb+IFLTE(thetadot, neg(sintheta), costheta*9.0, neg(costheta*9.0))+.\n\nThis result was very significant because it is evidence of the potential benefits of interpretable solutions to RL problems. The only way to improve a neural network is by adjusting its parameters or architecture and re-training it. However, this case study is a good example of how interpretability can be useful because it allows manual intervention via logic and intuition to systematically modify and improve the solutions discovered automatically by algorithms. \n\n\\subsection{Further Problems and Future Extensions}\nA second problem that was identified was that, once the agent had managed to balance the pendulum, it put too much effort (torque) into keeping it balanced, so it accumulated a lot of negative reward. So, an improvement to this strategy could involve a nested if-statement that is used to detect when the pendulum has been stabilised at a vertical position, and then reduce the applied torque to a minimum. Such an improvement would probably require an extension to the program structure and quite a bit of exploration using the GP algorithm to discover a program that encodes this behaviour. \n", "meta": {"hexsha": "eac5de825362fe5faff84f8a3e4e2e7839534aed", "size": 27079, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/pendulum.tex", "max_stars_repo_name": "alexgeorgousis/gp-for-interpretable-rl", "max_stars_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-31T10:12:58.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-31T10:12:58.000Z", "max_issues_repo_path": "report/pendulum.tex", "max_issues_repo_name": "alexgeorgousis/GP-for-interpretable-RL", "max_issues_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/pendulum.tex", "max_forks_repo_name": "alexgeorgousis/GP-for-interpretable-RL", "max_forks_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-12T14:41:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-12T14:41:42.000Z", "avg_line_length": 132.0926829268, "max_line_length": 1781, "alphanum_fraction": 0.7625096939, "num_tokens": 6316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.44705147473371315}}
{"text": "%% Preamble %%\n%% A minimal LaTeX preamble\n\n\\documentclass[11pt]{amsart}\n\\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}               % ... or a4paper or a5paper or ...\n%\\geometry{landscape}                % Activate for for rotated page geometry\n%\\usepackage[parfill]{parskip}       % Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\n\\graphicspath{ {images/} }\n\\usepackage{wrapfig}\n\\usepackage{tcolorbox}\n\\usepackage{lipsum}\n\\usepackage{amssymb}\n\\usepackage{epstopdf}\n\\usepackage{color}\n\\usepackage[usenames, dvipsnames]{color}\n\\usepackage{alltt}\n\\usepackage[version=3]{mhchem}\n\\usepackage{amsmath}\n\n% Needed to properly typeset\n% standard unicode characters:\n%\n\\RequirePackage{fix-cm}\n\\usepackage{fontspec}\n\\usepackage[Latin,Greek]{ucharclasses}\n%\n% NOTE: you must also use xelatex\n% as the typesetting engine\n\n\n% \\usepackage{fontspec}\n% \\usepackage{polyglossia}\n% \\setmainlanguage{en}\n\n\\usepackage{hyperref}\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    filecolor=magenta,\n    urlcolor=cyan,\n}\n\n\\DeclareGraphicsExtensions{.png, .jpg, jpeg, .pdf}\n\n%% \\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}\n%% Asciidoc TeX Macros %%\n\n% Needed for Asciidoc\n\n\\newcommand{\\admonition}[2]{\\textbf{#1}: {#2}}\n\\newcommand{\\rolered}[1]{ \\textcolor{red}{#1} }\n\\newcommand{\\roleblue}[1]{ \\textcolor{blue}{#1} }\n\\newcommand{\\rolehighlight}[1]{ \\backgroundcolor{yellow}{#1} }\n\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{proposition}{Proposition}\n\\newtheorem{corollary}{Corollary}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem{conjecture}{Conjecture}\n\\newtheorem{problem}{Problem}\n\\newtheorem{example}{Example}\n\\newtheorem{remark}{Remark}\n\\newtheorem{note}{Note}\n\n\n%%%\n%  Extended quote environment with author\n\\def\\signed#1{{\\leavevmode\\unskip\\nobreak\\hfil\\penalty50\\hskip2em\n  \\hbox{}\\nobreak\\hfil\\raise-3pt\\hbox{(#1)}%\n  \\parfillskip=0pt \\finalhyphendemerits=0 \\endgraf}}\n\n\\newsavebox\\mybox\n\\newenvironment{aquote}[1]\n  {\\savebox\\mybox{#1}\\begin{quotation}}\n  {\\signed{\\usebox\\mybox}\\end{quotation}}\n%%%\n\n\\newenvironment{preamble}\n  {}\n  {}\n\n%% http://tex.stackexchange.com/questions/99809/box-or-sidebar-for-additional-text\n\\newenvironment{sidebar}[1][r]\n  {\\wrapfigure{#1}{0.5\\textwidth}\\tcolorbox}\n  {\\endtcolorbox\\endwrapfigure}\n\n%% Style\n\\parindent0pt\n\\parskip8pt\n%% User Macros %%\n%% Front Matter %%\n\n\\title{Numbered Equations}\n\\author{}\n\\date{}\n\n\n%% Begin Document %%\n\n\\begin{document}\n\\maketitle\n\\section*{\\hypertarget{_numbered_equations}{Numbered Equations}}\n\nThe environment {\\tt [env.equation]} is automatically\nnumbered by default, as in the examples below.\n\n\n\\begin{equation*}\na^3 + b^3 = c^3\n\\end{equation*}\n\n\n\\begin{equation*}\n\\int_0^1 x^n dx = \\frac{1}{n}\n\\end{equation*}\n\n\nHere is how the first equation is done:\n\n\n\\begin{verbatim}\n[env.equation]\n--\n  a^3 + b^3 = c^3\n--\n\\end{verbatim}\n\n\\subsection*{\\hypertarget{_some_more_equations}{Some more equations}}\n\n\\begin{equation}\n\\label{pyth}a^2  + b^2 = c^2\n\\end{equation}\n\n\nA Fourier series:\n\n\n\\begin{equation}\n\\label{fourier}f(z)  = \\sum_{n=-\\infty}^\\infty e^{2\\pi i n z }.\n\\end{equation}\n\n\nA matrix:\n\n\n\\begin{equation}\n\\label{eq-matrix}M = \\left(\n\\begin{matrix}\n1 & 2 \\\\\n3 & 4\n\\end{matrix}\n\\right)\n\\end{equation}\n\n\n\n\n\\subsection*{\\hypertarget{_titles}{Titles}}\n\nEquations can take a title:\n\n\n\\begin{equation*}\n\\frac{d}{dx} \\int_a^x f(t) dt = f(x)\n\\end{equation*}\n\n\nWe wrote this:\n\n\n\\begin{verbatim}\n.Fundamental theorem of calculus\n[env.equation]\n--\n   \\frac{d}{dx} \\int_a^x f(t) dt = f(x)\n--\n\\end{verbatim}\n\n\n\n\\subsection*{\\hypertarget{_suppressing_numbering}{Suppressing numbering}}\n\nNumbering can be suppresed on a per-item basis.\nThis gives a \"bare\" equation.\n\n\n\\begin{equation*}\nM = \\left[\n  \\begin{array}{ c c }\n\t 1 & 2 \\\\\n\t 3 & 4\n  \\end{array} \\right]\n\\end{equation*}\n\n\nWe wrote {\\tt [env.equation%no-number]}.\nIf numbering is suppressed but a title is present,\nthe title is displayed.\n\n\n\\begin{equation*}\nM = \\left[\n  \\begin{array}{ c c }\n\t 1 & 2 \\\\\n\t -2 & 5\n  \\end{array} \\right]\n\\end{equation*}\n\n\nHere is the source:\n\n\n\\begin{verbatim}\n.Symmetric matrix\n[env.equation%no-number]\n--\nM = \\left[\n  \\begin{array}{ c c }\n\t 1 & 2 \\\\\n\t -2 & 5\n  \\end{array} \\right]\n--\n\\end{verbatim}\n\nNote:  In \\hyperlink{eq-matrix}{(3)} we defined a matrix.\n\n\n\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "88d6843064c58bb424985b111af3cfd2af2e7773", "size": 4418, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "test/examples/tex/eqno-latex.tex", "max_stars_repo_name": "thecsw/asciidoctor-latex", "max_stars_repo_head_hexsha": "c0c2b49fa2c87ef82576b6e69accd0023fcfb0af", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 104, "max_stars_repo_stars_event_min_datetime": "2015-01-17T19:04:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T18:49:03.000Z", "max_issues_repo_path": "test/examples/tex/eqno-latex.tex", "max_issues_repo_name": "thecsw/asciidoctor-latex", "max_issues_repo_head_hexsha": "c0c2b49fa2c87ef82576b6e69accd0023fcfb0af", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 77, "max_issues_repo_issues_event_min_datetime": "2015-01-04T12:42:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-09T06:22:15.000Z", "max_forks_repo_path": "test/examples/tex/eqno-latex.tex", "max_forks_repo_name": "thecsw/asciidoctor-latex", "max_forks_repo_head_hexsha": "c0c2b49fa2c87ef82576b6e69accd0023fcfb0af", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 35, "max_forks_repo_forks_event_min_datetime": "2015-01-02T13:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-20T15:32:10.000Z", "avg_line_length": 18.5630252101, "max_line_length": 108, "alphanum_fraction": 0.6957899502, "num_tokens": 1460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.800692004473946, "lm_q1q2_score": 0.44704796024630444}}
{"text": "%!TEX root = ../dokumentation.tex\n\\chapter{Theory}\n\n\\section{Classification of Data}\n%Data Types in ML (Cross-Sectional-, Time Series- and Panel Data)\nMost data found in academic and industrial projects can be broadly classified into three categories:\n\\begin{itemize}\n\t\\item Cross-sectional data\n\t\\item Time series data\n\t\\item Panel data\n\\end{itemize}\n\nCross-sectional data is data taken from multiple individuals at one point in time. The cross section of a population is obtained by taking observations from multiple individuals at the same time our without taking time into consideration at all. One example for this could be the test scores of all students for one particular exam. Another example is shown here:\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.475\\textwidth]{images/example_cross-sectional_data.PNG}}%\\scalebox{1}{\\includegraphics[width=05\\textwidth]{images/empty-transparent.png}}\\scalebox{1}{\\includegraphics[width=0.475\\textwidth]{images/example_cross-sectional_data.PNG}}\n\t\\caption{Example for cross-sectional data \\textsuperscript{\\cite{-1}}}\n\\end{figure}\n\n%https://www.cnbc.com/2018/02/16/black-panther-already-setting-records-with-thursday-box-office.html\n%example_cross-sectional_data.PNG\n\nTime series data is data taken from one individual at multiple points in time. A time series is made up of quantitative observations on one or more measurable characteristics of an individual entity and taken in an interval of time. The data is typically characterized by several internal structural elements such as trend, seasonality, stationarity, autocorrelation and noise. A common example for this would be sensor data, but also stock data when measured over time or the average income of politicians over the course of their career.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.475\\textwidth]{images/example_timeseries_data.PNG}}\n\t\\caption{Example for time series data \\textsuperscript{\\cite{-1}}}\n\\end{figure}\n\nThe last category is a combination of the first two. Panel Data can be defined as data taken from multiple individuals at multiple points in time and also known as longitudinal data.\n\nAn example for panel data would be Military Expenses of all European countries from 2001 to 2010. And one of the methods used to analyses this type of dataset is called “fixed effects model” which itself is also type of regression model.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.475\\textwidth]{images/example_panel_data.PNG}}\n\t\\caption{Example for panel data \\textsuperscript{\\cite{-1}}}\n\\end{figure}\n\nMethods for analyzing any of this data include plotting of variables to visualize statistical properties and calculation of central tendency, variance, skewness, and kurtosis. \n\n%\\pagebreak\n\\section{Time Series Analysis}\n\nAnalyzing time series is about understanding and modeling the different characteristics that time series data can exhibit. The most commonly studied features of time series data are:\n\\begin{itemize}\n\t\\item Noise\n\t\\item General trend\n\t\\item Cyclic movements\n\t\\item Seasonality\n\t\\item Pulses and Steps\n\t%\\item Outliers\n\t\\item Stationarity\n\\end{itemize}\n\nThe first one that is mostly referred to as \\textit{noise} reflects unexpected variations in the time series. It is often used to describe a type of error in a time series model that is due to a lack of information about explanatory variables that can model these variations or due to presence of random noise.\n\nAnd there can be different models used in which there is no trend nor seasonal component. One of the those models describes the \\acl{iid} noise or \\acs{iid} noise. In this model observations are simply \\acl{iid} variables with zero mean and it is also called white noise. This means that this model doesn't not have dependencies between observations.\n\nHowever there is also another model that does show dependencies. And it is know as \\textit{Random Walk Model}. The random walk \\(S_t \\) obtained by cumulatively summing \\acs{iid} random variables \\([Z_t]\\) with \\(S_0=0\\) and can therefore be defined as:\n\n\\begin{equation}\\label{eq:random_walk_model}\nS_t = Z_1 + Z_2 + Z_3 + ... + Z_t\n\\end{equation}\n\nIf furthermore the random variables \\([Z_t] \\) are Bernoulli distributed with \\(p=0.5\\) then this is called a simple symmetric random walk. An example for this could be a pedestrian who starts a position zero at time zero and at each integer time tosses a fair coin, stepping one unit to the right each time a head appears and one unit to the left for each tail. Both these model are referenced to as \\textit{zero-mean models}.\nAn example of the random walk model as well as an \\acs{iid} model can be seen in Figure 2.4.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_noise.png}}\n\t\\caption{Example for iid model (top) and random walk model (bottom)}\n\\end{figure}\n\nIn several time series there is also a clear trend to be observed in the data. This means it exhibits an upward or downward movement in the long run. In those cases a zero mean model is not sufficient to describe the series. \nTrend models aim to capture this long run trend in a time series. They can be fitted as linear regressions of the time index. And for this a trend model \\(X_t\\) can be expresses as the sum of the trend component \\(m_t\\) being a slowly changing function and a zero mean model \\(z_t\\):\n\n\\begin{equation}\\label{eq:simple_trend_model}\nX_t = m_t + z_t\n\\end{equation}\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_trendednoise.png}}\n\t\\caption{Example of trend models using  \\acs{iid} and random walk as zero mean models}\n\\end{figure}\n\nBesides general trend and noise many time series are also influenced by factors that occurs periodically. These repetitive fluctuations are called \\textit{cyclic movements}. These can further be divided into nonseasonal cycles and seasonal cycles.\n\nNonseasonal cycles are repetitive, possibly unpredictable patterns in time series values and defined by a periodicity that varies of time. \n\nIn contrast to that, seasonal cycles have a known \\textbf{constant} periodicity. And in that case the time series is to be said to exhibit seasonality.  One example causing seasonality in a series is dependency of the observed system on  weather. It itself is seasonal and when the weather then interferes with the observed system this interference can be seen in periodic fluctuations that occurs in a fixed period.\n\n%2002 Brockwell, Introduction to Time Series and Forecasting\nIn order to represent such seasonal effects, allowing for noise but assuming no trend, we can use a model that can be expressed as combination of an harmonic regression and the zero mean model \n\n\\begin{equation}\\label{eq:simple_seasonal_model}\nX_t = s_t + z_t\n\\end{equation}\nwhere \\(s_t\\) is a periodic function of t with period d (\\(s_{t-d}= s_t\\)) and is defined as: \n\n\n\\begin{equation}\\label{eq:harmonic_regression}\ns_t = a_0 + \\displaystyle\\sum_{j=1}^{k} (a_j \\cos(\\lambda t) + b_j \\sin(\\lambda t ))\n\\end{equation}\n\nhere \\(a_0, a_1, . . . , a_k\\) and \\(b_1, . . . , b_k\\) are unknown parameters and \\(\\lambda_1, . . . , \\lambda_k\\) are fixed frequencies, each being some integer multiple of \\(2\\pi/d\\).\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_season_and_noise.png}}\n\t\\caption{Example of seasonal models using \\acs{iid} and random walk as zero mean models}\n\\end{figure}\n\nBy using an additive model \\(X_t= m_t + s_t + z_t\\) combining a trend component \\(m_t\\), a seasonal component \\(s_t\\) and the random walk model as the noise or zero-mean component \\(z_t\\) a time series can be decomposed and visually represented like in figure 2.6. However real time series data is usually not that easily modeled, because they usually also show other more complex characteristics that are harder to model and therefore predict. These include \\textit{pulses} and \\textit{steps} as well as different types of \\textit{outliers}.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.6\\textwidth]{images/example_timeseries_characteristics.png}}\n\t\\caption{Example of time series decomposed into seasonal, trending and zero mean model}\n\\end{figure}\n\\textit{Pulses} and \\textit{steps} are abrupt changes in level that a series might exhibit:\nA \\textit{pulse} is defined as a temporary shift and a \\textit{step} is a permanent shift in the series.\n\n%\"\":\nWhen steps or pulses are observed, it is important to find a plausible explanation. Time series models are designed to account for gradual, not sudden, change. As a result, they tend to underestimate pulses and be ruined by steps, which leads to poor model fits and uncertain forecasts. If a disturbance can be explained, it can be modeled using an intervention or event. \n%https://www.ibm.com/support/knowledgecenter/SS3RA7_17/components/dt/timeseries_pulses.html?view=embed\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_pulse.jpg}}\n\t\\caption{Example of a pulse in a time series}\n\\end{figure}\n\n%if not enough pages add outliers: https://www.ibm.com/support/knowledgecenter/SS3RA7_17/components/dt/ts_outliers_overview.html\n\n%https://people.duke.edu/~rnau/411diff.htm\n%https://pdfs.semanticscholar.org/0f08/bcca67b3db328edfa5d3f48331dc71d8789e.pdf\n%2002 Brockwell, Introduction to Time Series and Forecasting\nA particular importance to many time series forecasting models has the characteristic that is called stationarity. This is because a lot of time series models use the assumption that the series to be forecast is already stationarity or can be made approximately stationary through the means of mathematical transformations. \nA time series is called stationary if its statistical properties stay constant over time. These restrictions only have to apply to those properties that depend only on the first- and second-order moments of \\(X_t\\):\n\nLet \\({X_t}\\) be a time series with \\(E(X_t^2 ) < \\infty\\). The mean function of \\({X_t }\\) is\n\n\\begin{equation}\\label{eq:mean_function}\n\\mu_X(t) = E(X_t )\n\\end{equation}\nThe covariance function of \\({X_t }\\) is\n\n\\begin{equation}\\label{eq:covariance_function}\n\\gamma_X(r, s)  = Cov(X_r,X_s)  E[(X_r - \\mu_X(r))(X_s - \\mu_X(s))]\n\\end{equation}\nfor all integers r and s.\n\\({X_t }\\) is (weakly) stationary if\n\\begin{enumerate}\n\t\\item [i] \\(\\mu_X(t)\\) is independent of t,\n\t\\item [and]\n\t\\item [ii] \\(\\gamma_X(t + h, t) \\) is independent of t for each h.\n\\end{enumerate}\n\n%https://people.duke.edu/~rnau/411diff.htm\nTo obtain meaningful statistical properties such as mean, variance, and correlations a timer series has to be stationarized first. Only then such statistics can be used as descriptors for future behavior.\nFor example, if the series is consistently increasing over time, the sample mean and variance will grow with the size of the sample, and they will always underestimate the mean and variance in future periods. And therefore based on the mean and variance the correlation with other variables would be under- or overestimated too.\n\nThis is why there is a need for mathematical transformations that can make a non-stationary time series approximately stationary.\n\nOne of those mathematical transformations is called \\textit{de-trending} and can be used when the series has a stable long-run trend and no seasonality. This is achieved by fitting a trend model to the time series and then subtracting it from the original series. The resulting time series can then be further analyzed and modeled and is called \\textit{trend-stationary} if the process was able to stationarize the series. An equivalent process is working for time series which do show seasonality. Of course in those cases a seasonal model has to be fitted and then subtracted from the series. There is also the possibility of combining both of those approaches.\n\nHowever, not all time series can be stationarized by these processes. For some series this is insufficient and they might have to be differenced, either from period to period or from season to season. The idea is that if, even after removing a trend and/or seasonal model, the statistical characteristics are still not constant over time, then the statistics of the changes in the series between periods or seasons might be constant. In that case it is said to be \\textit{difference-stationary}. Using unit-root tests can help identifying what stationarizing method might be more successful.\n\nFor the process of nonseasonal \\textit{first order differencing} the \\textit{lag-1} operator \\(\\Delta\\) is defined by:\n\n\\begin{equation}\\label{eq:first_difference}\n\\Delta X_t = X_t - X_{t-1} = (1-B)X_t\n\\end{equation}\n\nwhere B is the backward shift or \\textit{backshift} operator\n\n\\begin{equation}\\label{eq:bachshift_operator}\nB X_t = X_{t-1}\n\\end{equation}\n\nPowers of operators \\(B\\) and \\(\\Delta\\) are defined by \\(B^j X_t = X_{t-j}\\) and \\(\\Delta^j X_t = \\Delta (\\Delta^{j-1} X_t), j >= 1\\) with \\(\\Delta^0 X_t = X_t\\). Polynomials in \\(B\\) and \\(\\Delta\\) are manipulated in precisely the same way as polynomial functions of real variables. For example:\n\n\\begin{equation}\\label{eq:example_delta_squared}\n\\Delta^2 X_t = \\Delta (\\Delta X_t) = (1-B)(1-B)X_t = (1-2B + B^2) X_t = X_t - 2 X_{t-1} +  X_{t-2}\n\\end{equation}\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_firstorderdiff.png}}\n\t\\caption{Example of a time series with its first order non-seasonal difference}\n\t\\label{fig:example_non_seasonal_diff}\n\\end{figure}\n\n\\textit{First order differencing} is an example for a period to period differencing and is used to removed the trend from a time series. However, as seen in \\ref{fig:example_non_seasonal_diff} the seasonality is still exhibited in the same way and to remove this as well seasonal differencing as to be applied additionally.\n\nFor the process of seasonal \\textit{first order differencing} the \\textit{lag-1} operator \\(\\Delta_s\\) with seasonality \\(s\\) is defined by:\n\n\\begin{equation}\\label{eq:seasonal_first_difference}\n\\Delta_s X_t = X_t - X_{t-s} = (1-B^s)X_t\n\\end{equation}\n\nAnd the \\textit{D-th order difference} is defined by:\n\n\\begin{equation}\\label{eq:seasonal_difference}\n\\Delta_s^D X_t = (X_t - X_{t-s})^D = (1-B^s)^DX_t\n\\end{equation}\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\scalebox{1}{\\includegraphics[width=0.66\\textwidth]{images/example_seasonaldiff.png}}\n\t\\caption{Example of a time series with its first order non-seasonal difference}\n\t\\label{fig:example_seasonal_diff}\n\\end{figure}\n\n%Characteristics of Time Series Data and how to model them\n%Smoothing\n%Smoothing is often referred to as filtering.\n%There are two distinct groups of smoothing methods\n%- Averaging Methods (Moving Average)\n%- Exponential Smoothing Methods\n%Autocovariance and (Partial) Autocorrelation\n\n\n\\section{ARIMA Model}\\label{arimamodel}\nThe \\acl{ARIMA} (\\acs{ARIMA}) model is used to better understand and forecast time series data. It is based on the \\acl{ARMA} (\\acs{ARMA}) model but can also handle data that shows evidence of non-stationarity.  \n\\acs{ARMA} is composed out of the \\acl{AR} (\\acs{AR}) model and the \\acl{MA} (\\acs{MA}) model.\n\n\\acl{AR} models are used to predict future values of a time series by using linear combinations of previous values of the series and \\acl{MA} models try to forecast by combining the prediction error that has been made for previous predictions in the time series.\n\nGiven a univariate time series \\(X_t\\) that is stationary and \\(e_t\\) a random variable with an independent and identical distribution representing the error that can occur in any prediction, the \\acs{AR}\\((p)\\) model is defined by:\n\\begin{equation}\\label{eq:AR_p}\nX_t = e_t + \\displaystyle\\sum_{i=1}^{p} (\\phi_i B^i) X_t = e_t + \\phi_1 X_{t-1}+ \\phi_2 X_{t-2}+ ... + \\phi_p X_{t-p}\n\\end{equation}\n\nBy defining the error of a prediction as the difference between the correct value from the time series and the value from the approximation \\(\\hat{X_t}\\) as: \n\n\\begin{equation}\\label{eq:error_term}\ne_t = X_t - \\hat{X_t}\n\\end{equation}\n\nThe approximation of \\(X_t\\) using an \\acs{AR}\\((4)\\) can be written as:\n\n\\begin{equation}\\label{eq:AR_four}\n\\hat{X_t} = \\phi_1 X_{t-1}+ \\phi_2 X_{t-2}+ \\phi_3 X_{t-3}+ \\phi_4 X_{t-4}\n\\end{equation}\n\nThe \\acl{MA} model is based on the definition \\eqref{eq:error_term} of the error term \\(e_t\\). In contrast to the \\acs{AR} model it combines \\(e_t\\) terms instead of just combining\\(X_t\\). Hence the definition of \\acs{MA}\\((q)\\) is:\n\n\\begin{equation}\\label{eq:MA_q}\nX_t = e_t + \\displaystyle\\sum_{k=1}^{q} (\\theta_k B^k) e_t = e_t + \\theta_1 e_{t-1}+ \\theta_2 e_{t-2}+ ... + \\theta_p e_{t-q}\n\\end{equation}\n\nThis makes the calculation of an \\acs{MA}\\((q)\\) model a little bit more complicated, as demonstrated on the example of \\acs{MA}\\((3)\\):\n\n\\begin{equation}\\label{eq:example_MA_three_1}\nX_t = e_t + \\theta_1 e_{t-1}+ \\theta_2 e_{t-2} + \\theta_3 e_{t-3}\n\\end{equation}\n\nReplacing \\(e_t\\) with its definition \\eqref{eq:error_term} and transforming the equation to \\(\\hat{X_t}\\) makes the complication clearer:\n\n\\begin{equation}\\label{eq:example_MA_three_2}\n\\hat{X_t} =\\theta_1 (X_{t-1} - {\\hat{X}}_{t-1}) + \\theta_2 (X_{t-2} - {\\hat{X}}_{t-2}) + \\theta_3 (X_{t-3} - {\\hat{X}}_{t-3})\n\\end{equation}\n\nIn this form it is clear that \\(\\hat{X_t}\\) is depended on \\({\\hat{X}}_{t-1}\\), \\({\\hat{X}}_{t-2}\\), \\({\\hat{X}}_{t-3}\\) which are also unknown variables that have to be calculated first. Using the same formula for \\({\\hat{X}}_{t-1}\\) and so on, this leads to more dependencies which lead to even more. What one eventually ends up with is a system of linear equation that, assuming \\(X_t\\) is a series of length 5 looks like this: \n\n\\begin{equation}\\label{eq:example_MA_three_system_1}\n\\begin{array}{lcl}\n{\\hat{X}}_{5} & = & \\theta_1 (X_{4} - {\\hat{X}}_{4}) + \\theta_2 (X_{3} - {\\hat{X}}_{3}) + \\theta_3 (X_{2} - {\\hat{X}}_{2}) \\\\\n{\\hat{X}}_{4} & = & \\theta_1 (X_{3} - {\\hat{X}}_{3}) + \\theta_2 (X_{2} - {\\hat{X}}_{2}) + \\theta_3 (X_{1} - {\\hat{X}}_{1}) \\\\\n{\\hat{X}}_{3} & = & \\theta_1 (X_{2} - {\\hat{X}}_{2}) + \\theta_2 (X_{1} - {\\hat{X}}_{1})\\\\\n{\\hat{X}}_{2} & = & \\theta_1 (X_{1} - {\\hat{X}}_{1})\\\\\n{\\hat{X}}_{1} & = & 0\n\\end{array}\n\\end{equation}\n\nTo be able to calculate this for larger time series, some kind of solving mechanism is needed. To be able to use one of those the system of linear equations needs to be in the form of:\n\n\\begin{equation}\\label{eq:syslinequation}\n\\mathbf{A}  \\vec{\\hat{x}} = \\vec{b}\n\\end{equation}\n\nwith $\\mathbf{A} \\in \\mathbb{R}^{n\\times n}$ being a $n\\times n$ Matrix,  $\\vec{\\hat{x}} \\in \\mathbb{R}^n$ and  $\\vec{b}\\in \\mathbb{R}^n$ both n-dimensional vectors. The vector of $\\vec{b}$ representing the known values for each equation, $\\vec{\\hat{x}}$ the unknown variables and $\\mathbf{A}$ the coefficients of all the $\\vec{\\hat{x}}$ for each equation.\n\nTo see how $\\mathbf{A}$ and  $\\vec{b}$ have to be constructed the system of linear equations \\eqref{eq:example_MA_three_system_1} can be transformed to:\n\\begin{equation}\\label{eq:example_MA_three_system_2}\n\\begin{array}{rcrcrcrcrclll}\n{\\hat{X}}_{1}&&&&&&&&& = &0&&\\\\\n\\theta_1 {\\hat{X}}_{1} &+& {\\hat{X}}_{2} & & & & & & &= &\\theta_1 X_{1}&&\\\\\n\\theta_2 {\\hat{X}}_{1}&+&\\theta_1 {\\hat{X}}_{2} &+& {\\hat{X}}_{3}&  &  &&& = &\\theta_1 X_{2} &+ \\theta_2 X_{1}&\\\\\n\\theta_3 {\\hat{X}}_{1} &+& \\theta_2 {\\hat{X}}_{2} &+&  \\theta_1 {\\hat{X}}_{3}&+& {\\hat{X}}_{4}& && = &\\theta_1 X_{3} &+ \\theta_2 X_{2} &+ \\theta_3 X_{1}\\\\ \t\n&&\\theta_3 {\\hat{X}}_{2} &+& \\theta_2 {\\hat{X}}_{3}&+& \\theta_1 {\\hat{X}}_{4} &+&{\\hat{X}}_{5}& = &  \\theta_1 X_{4} &+\\theta_2 X_{3} &+ \\theta_3 X_{2}\n\\end{array}\n\\end{equation}\n\nThis leads directly to the form required in \\eqref{eq:syslinequation}:\n\n\\begin{equation}\\label{eq:example_MA_three_system_3}\n\\left(\\begin{array}[c]{lllll}\n1 & 0 & 0 & 0 & 0\\\\\n\\theta_1 & 1 & 0 & 0 & 0\\\\\n\\theta_2 & \\theta_1& 1 & 0 & 0\\\\\n\\theta_3 & \\theta_2 & \\theta_1& 1 & 0\\\\\n0 & \\theta_3 & \\theta_2 & \\theta_1& 1\n\\end{array}\\right) \\;\\vec{\\hat{x}} =\n\\left(\\begin{array}[c]{rrr}\n0 &&\\\\ \n\\theta_1 X_{1} &&\\\\\n\\theta_1 X_{2} &+ \\theta_2 X_{1} &\\\\\n\\theta_1 X_{3} &+ \\theta_2 X_{2} &+ \\theta_3 X_{1} \\\\\n\\theta_1 X_{4} &+ \\theta_2 X_{3} &+ \\theta_3 X_{2} \n\\end{array}\\right)\n\\end{equation}\n\nHaving the system of linear equations in this form, the \\acs{MA}$(4)$ model with given $\\theta_k$ for $k \\in [1,...,4]$ can be calculated using a numerical solver for systems of linear equations like the Jacobi (chapter \\ref{jacobi}) or Conjugate Gradient solver.\n\nThe \\acs{ARMA}$(p,q)$ model can now be composed out of the \\acl{AR}$(p)$ and \\acl{MA}$(q)$ model defined previously by the equations \\eqref{eq:AR_p} and \\eqref{eq:MA_q} and can be represented as:\n\n\\begin{equation}\\label{eq:ARMA_1}\n\\begin{array}{ccc}\n(1-\\displaystyle\\sum_{i=1}^{p} \\phi_i B^i) X_t & = & (1+\\displaystyle\\sum_{k=1}^{q} \\theta_k B^k)e_t\\\\\n\\Leftrightarrow X_t - \\phi_1 X_{t-1} - \\phi_2 X_{t-2} - ... - \\phi_p X_{t-p} & = & e_t + \\theta_1 e_{t-1}+ \\theta_2 e_{t-2}+ ... + \\theta_p e_{t-q}\n\\end{array}\n\\end{equation}\n\nThe approximation $\\hat{X_t}$ can therefore be calculated by:\n\\begin{equation}\\label{eq:ARMA_2}\n\\rightarrow  \\hat{X}_t = \\phi_1 X_{t-1} + \\phi_2 X_{t-2} + ... + \\phi_p X_{t-p} + \\theta_1 e_{t-1}+ \\theta_2 e_{t-2}+ ... + \\theta_p e_{t-q}\n\\end{equation}\n\nBecause this equation \\eqref{eq:ARMA_2} is just a combination of the equations \\eqref{eq:AR_p} and \\eqref{eq:MA_q} it also comes with the same difficulties as previously described and has therefore to be transformed the same way, so it is in the form of equation \\eqref{eq:syslinequation}.\n\nThis is achieved with the same procedures as described for the example of \\acs{MA}$(3)$ eventually leading to an equation in the form of \\eqref{eq:example_MA_three_system_3} with all the \\acs{AR} terms of the equation contained within $\\vec{b}$.\n%Maybe add example for Matrix and more detailed explanation later\n\nHowever, like already mentioned in the beginning of this chapter: \\acs{ARIMA} is a generalization of \\acs{ARMA} with the additional ability to also work with non-stationary time series. It accomplishes this by differencing the time series $d$ times. Hence, the \\acs{ARIMA}$(p,d,q)$ model also includes the equation for first order differencing \\eqref{eq:first_difference} - modified to equal d-th order differencing - and is therefore defined as:\n\n\\begin{equation}\\label{eq:ARIMA_1}\n\\begin{array}{cccccc}\n(1-\\displaystyle\\sum_{i=1}^{p} \\phi_i B^i) & (1-B^d)& X_t & = & (1+\\displaystyle\\sum_{k=1}^{q} \\theta_k B^k) & e_t\n\\end{array}\n\\end{equation}\n\nBut this model won't be able to fit any seasonal behavior, because it is missing the seasonal parts of all three components \\acs{AR}, \\acs{MA} and d-th order differencing.\n\nThe most commonly used \\acs{ARIMA} model for forecasting seasonal time series  is the multiplicative \\acl{SARIMA} (\\acs{SARIMA}) model. This model assumes that there is a significant parameter as a result of multiplication between nonseasonal and seasonal parameters. But there also is an additive (\\acs{SARIMA}) model that can be used to forecast.\n\nThe additive models for \\acl{SAR} \\acs{SAR}$(p,P)$ are defined as:\n\\begin{equation}\\label{eq:additive_SAR_pP}\n\\begin{array}{rcl}\nX_t & = & e_t + \\displaystyle\\sum_{i=1}^{p} \\phi_i B^i X_t + \\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s} X_t\\\\\nX_t & = & e_t + \\phi_1 X_{t-1}+ ... + \\phi_p X_{t-p} + \\Phi_1 X_{t-1 s}+ ... + \\Phi_P X_{t-P s}\n\\end{array}  \n\\end{equation}\n\nAnd analog to this the additive \\acl{SMA} \\acs{SMA}$(q,Q)$ model is defined by:\n\n\\begin{equation}\\label{eq:additive_SMA_q}\n\\begin{array}{rcl}\nX_t & = & e_t + \\displaystyle\\sum_{k=1}^{q} \\theta_k B^k e_t + \\displaystyle\\sum_{l=1}^{Q} \\Theta_l B^{l\\cdot s} e_t\\\\\nX_t & = & e_t + \\theta_1 e_{t-1}+ ... + \\theta_q e_{t-q} + \\Theta_1 e_{t-1 s}+ ... + \\Theta_Q e_{t-Q s}\n\\end{array}   \n\\end{equation}\n\nThe differencing component is always multiplicative and therefore by also adding the equation \\eqref{eq:seasonal_difference} for the seasonal D-th order difference the additive \\acs{SARIMA}$(p,d,q)(P,D,Q)_s$ is defined as:\n\n\\begin{equation}\\label{eq:additive_SARIMA}\n\\begin{array}{cccccc}\n(1-(\\displaystyle\\sum_{i=1}^{p} \\phi_i B^i + \\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s})) & (1-B^d)& X_t & = & (1+(\\displaystyle\\sum_{k=1}^{q} \\theta_k B^k + \\displaystyle\\sum_{l=1}^{Q} \\Theta_l B^{l\\cdot s})) & e_t\n\\end{array}\n\\end{equation}\n\nThe multiplicative models are a little bit more complicated for both \\acs{SAR} as well as \\acs{SMA}. With the multiplicative \\acl{SAR} \\acs{SAR}$(p,P)$ model being the simpler one defined by:\n\n\\begin{equation}\\label{eq:multiplicative_SAR_pP}\n\\begin{array}{rcl}\ne_t & = & (1-\\displaystyle\\sum_{i=1}^{p} \\phi_i B^i) (1-\\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s}) X_t\\\\\ne_t & = & (1-\\phi_1 B-\\phi_2 B^2 - ... -\\phi_p B^p) (1-\\Phi_1 B^s-\\Phi_2 B^{2s} - ... -\\Phi_p B^{Ps}) X_t\\\\\ne_t & = & (1-\\phi_1 B-\\phi_2 B^2 - ... -\\phi_p B^p -\\Phi_1 B^s-\\Phi_2 B^{2s} - ... -\\Phi_p B^{Ps} \\\\\n& & + \\phi_1 \\Phi_1 B^{1+s} + \\phi_2 \\Phi_1 B^{2+s} + \\phi_2 \\Phi_2 B^{2+2s} + ... + \\phi_p \\Phi_P B^{p+Ps}) X_t\\\\\nX_t & = & e_t + \\displaystyle\\sum_{i=1}^{p} \\phi_i B^i X_t + \\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s} X_t - \\displaystyle\\sum_{i=1}^{p}\\displaystyle\\sum_{j=1}^{P} \\phi_i \\Phi_j B^{i + js} X_t\n\\end{array}  \n\\end{equation}\n\nAnd the multiplicative \\acl{SMA} \\acs{SMA}$(q,Q)$ model defined as:\n\\begin{equation}\\label{eq:multiplicative_SMA_qQ}\n\\begin{array}{rcl}\nX_t & = & (1+\\displaystyle\\sum_{k=1}^{q} \\theta_i B^k) (1+\\displaystyle\\sum_{l=1}^{Q} \\theta_j B^{k\\cdot s}) e_t\\\\\nX_t & = & (1+\\theta_1 B-\\theta_2 B^2 + ... +\\theta_p B^q +\\theta_1 B^s+\\theta_2 B^{2s} + ... +\\theta_p B^{Qs} \\\\\n& & + \\theta_1 \\theta_1 B^{1+s} + \\theta_2 \\theta_1 B^{2+s} + \\theta_2 \\theta_2 B^{2+2s} + ... + \\theta_p \\theta_P B^{q+Qs}) e_t\\\\\nX_t & = & e_t + \\displaystyle\\sum_{k=1}^{q} \\theta_i B^k e_t + \\displaystyle\\sum_{l=1}^{Q} \\theta_j B^{k\\cdot s} e_t + \\displaystyle\\sum_{k=1}^{q}\\displaystyle\\sum_{l=1}^{Q} \\theta_i \\theta_j B^{k + js} e_t\n\\end{array}  \n\\end{equation}\n\nThis directly leads to the definition of multiplicative \\acs{SARIMA}$(p,d,q)(P,D,Q)_s$ as:\n\n\\begin{equation}\\label{eq:multiplicative_SARIMA}\n\\begin{array}{rcl}\n(1-\\displaystyle\\sum_{i=1}^{p} \\phi_i B^i)(1-\\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s}) (1-B^d) (1-B^s)^D X_t & = & (1+\\displaystyle\\sum_{k=1}^{q} \\theta_k B^k) (1+\\displaystyle\\sum_{l=1}^{Q} \\theta_j B^{k\\cdot s}) e_t\n\\end{array}\n\\end{equation}\n\nThe complication with this model originates from the third sum that is now also combining  all the $\\phi$ and $\\Phi$ in case of \\acs{AR} and all the $\\theta$ and $\\Theta$ for \\acs{MA}.\n\nThe terms of the third sum increase exponentially if both parameters are increased, which leads to an equivalent increase in compile-time. Additionally this further complicates the transformation of the system of linear equations for \\acl{MA}.\n\nFor example, the equation for the approximation ${\\hat{X}}_t$ of multiplicative \\acs{SARIMA}$(2,0,1)(1,0,2)_{3}$ would look like:\n\n\\begin{equation}\\label{eq:example_multiplicative_SARIMA_1}\n\\begin{array}{rcl}\n\\hat{X_t} & = & \\phi_1 X_{t-1} + \\phi_2 X_{t-2} + \\Phi_1 X_{t-2} + \\phi_1 \\Phi_1 X_{t-3} + \\phi_2 \\Phi_1 X_{t-4}\\\\\n&& + \\theta_1 (X_{t-1} - {\\hat{X}}_{t-1})+ \\Theta_1 (X_{t-2} - {\\hat{X}}_{t-2}) + \\Theta_2 (X_{t-4} - {\\hat{X}}_{t-4})\\\\\n&& + \\theta_1 \\Theta_1 (X_{t-3} - {\\hat{X}}_{t-3}) + \\theta_1 \\Theta_2 (X_{t-5} - {\\hat{X}}_{t-5})\n\\end{array}\n\\end{equation}\n\nBringing this in the form required in \\eqref{eq:syslinequation} assuming that the time series $X_t$ is only of length $8$:\n\n\\begin{frame}\n\t\\footnotesize\n\t\\medmuskip = 1mu % default: 4mu plus 2mu minus 4mu\n\t\\begin{equation}\\label{eq:example_multiplicative_SARIMA_2}\n\t\\resizebox{\\linewidth}{!}{%\n\t\t$\\displaystyle\n\t\t\\left(\\begin{array}[c]{lllllll}\n\t\t1 & 0 & 0 & 0 & 0 & 0 \\\\\n\t\t\\theta_1 & 1 & 0 & 0 & 0 & 0 \\\\\n\t\t\\Theta_1 & \\theta_1& 1 & 0 & 0 & 0\\\\\n\t\t\\theta_1 \\Theta_1 & \\Theta_1 & \\theta_1& 1 & 0 & 0\\\\\n\t\t\\Theta_2 & \\theta_1 \\Theta_1 & \\Theta_1 & \\theta_1 & 1 & 0 \\\\\n\t\t\\theta_1 \\Theta_2 & \\Theta_2 & \\theta_1 \\Theta_1 & \\Theta_1 & \\theta_1 & 1\n\t\t\\end{array}\\right)\n\t\t\\left(\\begin{array}[c]{c}\n\t\t\\hat{X}_1\\\\\n\t\t\\hat{X}_2\\\\\n\t\t\\hat{X}_3\\\\\n\t\t\\hat{X}_4\\\\\n\t\t\\hat{X}_5\\\\\n\t\t\\hat{X}_6\n\t\t\\end{array}\\right) =\n\t\t\\left(\\begin{array}[c]{lrrrr}\n\t\t0\\\\ \n\t\t\\phi_1\\theta_1 X_1\\\\\n\t\t\\phi_1\\theta_1 X_2 & + \\Phi_1\\phi_2\\theta_2 X_1\\\\\n\t\t\\phi_1\\theta_1 X_3 & + \\Phi_1\\phi_2\\theta_2 X_2 & + \\Phi_1\\Theta_1 X_1\\\\\n\t\t\\phi_1\\theta_1 X_4 & + \\Phi_1\\phi_2\\theta_2 X_3 & + \\Phi_1\\Theta_1 X_2 + &\\Theta_2X_1\\\\\n\t\t\\phi_1\\theta_1 X_5 & + \\Phi_1\\phi_2\\theta_2 X_4 & + \\Phi_1\\Theta_1 X_3 + &\\Theta_2X_2 & + \\theta_1\\Theta_2X_1\n\t\t\\end{array}\\right)\n\t\t$}\n\t\\end{equation}\n\\end{frame}\n\nFor the estimation of the \\acs{SARIMA} coefficients $\\phi$, $\\Phi$, $\\theta$ and $\\Theta$ an objective function is needed to be optimized over. And there are different estimators that can be used for this purpose: \n\\begin{itemize}\n\t\\item \\acl{ML} (\\acs{ML}) estimation\n\t\\item Yule-Walker estimation\n\t\\item Least Squares or \\acl{CSS} (\\acs{CSS}) method\n\\end{itemize}\n\nWith the Yule-Walker and the \\acl{ML} estimator described in detail in Peter J. Brookwell's 2002 \"Introduction to Time Series and Forecasting, Second Edition\" and also being the more complicated two.\n\nThe \\acl{CSS} method in contrast to that can, for $X_t$ with size $T$, be simple put as the sum of squared residuals:\n\\begin{equation}\\label{eq:ARIMA_CSS}\n\\begin{array}{rcl}\nARIMA_{CSS}(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q}) = \\frac{1}{2}\\displaystyle\\sum_{t=1}^{T} (e_t)^2 = \\frac{1}{2}\\displaystyle\\sum_{t=1}^{T} (X_t - \\hat{X}_t)^2\n\\end{array}\n\\end{equation}\n\n\n\\section{Optimization Algorithms}\\label{optimalgorithms}\nTo forecast using \\acs{ARIMA} the \\acl{AR} and \\acl{MA} coefficients have to be estimated first. This is done by solving an optimization problem:\n\\begin{equation}\\label{eq:min}\n\\begin{array}{c}\n\\displaystyle\\max_{\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q} \\in R} \\; g(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q})\\\\\nor \\\\\n\\displaystyle\\min_{\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q} \\in R} \\; g(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q})\n\\end{array}\n\\end{equation}\n\nwith $g(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q})$ being the \\acl{ML}, Yule-Walker or \\acl{CSS} estimator. There are different algorithms that have been developed to solve such a optimization problem. Some of the most common ones that are also provided by the general-purpose optimization function $optim()$  of R are called:\n\\begin{itemize}\n\t\\item Nelder-Mead method\n\t\\item \\acl{BFGS} (\\acs{BFGS}) method\n\t\\item \\acl{L-BFGS} (\\acs{L-BFGS}) method\n\t\\item Brent method\n\\end{itemize}\n\n\\subsection{BFGS}\\label{bfgs}\nThe \\acl{BFGS} (\\acs{BFGS}) algorithm belongs to the class of \\textit{Quasi-Newton} methods and can therefore be used to find roots or local maxima and minima of real-valued functions. \\textit{Quasi-Newton} methods do this faster then the \"full\" \\textit{Newton} method by approximating the Hessian or Jacobian instead of calculating it exactly.\n\nIf the function $f: R \\rightarrow R$ its \\textit{derivative}, $f'(x)$ and an initial guess $\\hat{x}_0$ is given then the \\textit{Newton} method's iterative approximation $\\hat{x}_{n+1}$ of the root of $f(x)$ is given by: \n\\begin{equation}\\label{eq:newtons_method_univariate}\n\t\\begin{array}{c}\n\t\t\\hat{x}_{n+1} = \\hat{x}_{n} - f(\\hat{x}_{n})/f'(\\hat{x}_{n})\n\t\\end{array}\n\\end{equation}\n    \n%Die Gleichung (6.36) lässt sich geometrisch interpretieren: Legen wir im Punkt hxn; g(xn)i eine Tangente an die Funktion g, so schneidet diese Tangente die x-Achse im Punkt\n\n\n%Multivariate Newtons method for maxima using hessian: http://people.duke.edu/~kh269/teaching/b553/newtons_method.pdf\n\n%Explanation multivariate newton raphson (Jacobi) method:http://fourier.eng.hmc.edu/e176/lectures/NM/node21.html\n\n\n%Quasi-Netwon Method with hessian: https://www.rose-hulman.edu/~bryan/lottamath/quasinewton.pdf\n\n%More quasi newton: https://www.cs.ccu.edu.tw/~wtchu/courses/2014s_OPT/Lectures/Chapter%2011%20Quasi-Newton%20Methods.pdf\n\nThis of course is only for univariate functions. The definition of the iterative approximation $\\hat{x}_{n+1}$ of the root for multivariate function $f(x): R^k -> R$ is:\n\n\\begin{equation}\\label{eq:newtons_method_multivariate_root}\n\t\\begin{array}{c}\n\t\t\\hat{x}_{n+1} =\\hat{x}_{n} - \\frac{f(\\hat{x}_{n})}{J_f(\\hat{x}_{n})} = \\hat{x}_{n} - f(\\hat{x}_{n}) \\cdot J_f^{-1}(\\hat{x}_{n}) \n\t\\end{array}\n\\end{equation}\n\nWith $J_f(\\hat{x}_{n})$ being the Jacobian matrix, the matrix of all \\textit{first-order} partial derivatives.\n\n\nUsing the \\textit{Newton} method to optimize the function $f$ is equivalent to finding the root of the \\textit{derivative}  $f'$ which means that the approximation $\\vec{\\hat{x}}_{n+1}$ for the extrema of $f$ is given by:\n\n\\begin{equation}\\label{eq:newtons_method_multivariate_extrema}\n\t\\begin{array}{c}\n\t\t\\hat{x}_{n+1} =\\hat{x}_{n} - \\frac{\\Delta f(\\hat{x}_{n})}{H_f(\\hat{x}_{n})} = \\hat{x}_{n} - \\Delta f(\\hat{x}_{n}) \\cdot H_f^{-1}(\\hat{x}_{n}) \n\t\\end{array}\n\\end{equation}\n\nWith $H_f(\\hat{x}_{n})$ being the Hessian, a square matrix of all \\textit{second-order} partial derivatives.\n\n%http://people.duke.edu/~kh269/teaching/b553/newtons_method.pdf :\nThe drawback of using the \\textit{Newton} method is that it requires inverting the Hessian, which means a computation of $O(n^3)$ using standard techniques. Additionally the exact calculation of the Hessian takes $O(n^2)$ function evaluations (partial derivatives). Consequently using the Newton method is getting expensive for large n. \n\n\\textit{Quasi-Newton} methods try to overcome these limitations by approximating the Hessian instead of calculating it directly. This can be achieved by leveraging the \\textit{secant} method.\n\nThe \\textit{secant} approximation of the second derivative of the univariate function $f(x)$ is:\n\n\\begin{equation}\\label{eq:secant_method_univariate}\n\t\\begin{array}{lc}\n\t\t&f''(x_k) \\approx \\frac{f'(x_k) - f'(x_{k-1})}{x_k - x_{k-1}}\\\\\n        \\Leftrightarrow &f''(x_k) \\cdot (x_k - x_{k-1})\\approx f'(x_k) - f'(x_{k-1})\n\t\\end{array}\n\\end{equation}\n\nThe generalization of \\eqref{eq:secant_method_univariate} for a multivariate function is:\n\n\\begin{equation}\\label{eq:secant_method_multivariate}\n\t\\begin{array}{lc}\n\t\t\\Delta^2 f(x_k) \\cdot (x_k - x_{k-1})\\approx \\Delta f(x_k) - \\Delta f(x_{k-1})\n\t\\end{array}\n\\end{equation}\n\n\\textit{Quasi-Newton} methods try to find the Hessian $H_f(x_k)\\approx \\Delta^2f(x_k)$ to make \\eqref{eq:secant_method_multivariate} an equality. For this there is an initial guess needed for $H_0 = I$ which is then incrementally improved by updating $H_{k+1}$.\n\nUsing this approach the Hessian $H_f(x_k)$ still needs to be inverted which is also a time consuming computation, that can be avoided by instead approximating the inverse Hessian $H_f^{-1}(x_k)$ directly. \n\nIn that case we define $B_k$ as the inverse Hessian $H_f^{-1}(x_k)$ and the search direction $p_k$ that has to be computed are defined as:\n\\begin{equation}\\label{eq:searchdirection}\n\t\\begin{array}{lc}\n\t\tp_k = -B_k \\cdot \\Delta f(x_k)\n\t\\end{array}\n\\end{equation}\n\nTo calculate the updated approximation of $B_k$ an acceptable step size $\\alpha$ in the direction $p_k$ has to be found by using a line search:\n\\begin{equation}\\label{eq:linesearch_objfunction}\n\t\\begin{array}{lc}\n\t\t\\displaystyle \\min_\\alpha \\;\\;\\; h(\\alpha) = f(x_k + \\alpha p_k)\n\t\\end{array}\n\\end{equation}\n\nAn exact line search algorithm would determine a value for $\\alpha$ that exactly minimizes $h(\\alpha)$. However this is not always necessary or even desirable because of the additional computing costs it would require. \nInstead using, for example the backtracking line search, the step size $\\alpha$ can be approximately reasonably well, which is sufficient for most cases.\n\nThe backtracking line search starts the same way an exact one would by guessing $\\alpha_0 > 0$ and then shrinking it in every iteration by multiplying it with a constant $r \\in ]0,1[$:\n\\begin{equation}\\label{eq:linesearch_ak}\n\t\\begin{array}{lc}\n\t\t\\alpha_{k+1} = r \\cdot \\alpha_k\n\t\\end{array}\n\\end{equation}\n\nThis is repeated as long as the Armijo-Goldstein condition is fulfilled, which tests whether the new smaller step size  achieves a adequately corresponding decrease in the objective function $h(\\alpha)$ defined in \\eqref{eq:linesearch_objfunction}.\nThe Armijo-Goldstein condition is fulfilled if:\n\\begin{equation}\\label{eq:linesearch_armijo-goldstein}\n\t\\begin{array}{lc}\n\t\tf(x+\\alpha p) <= f(x) + a c m\n\t\\end{array}\n\\end{equation}\n\nWith $m= p^T \\Delta f(x)$ and $c\\in]0,1[$ being a pre defined control parameter.\n\nGiven $p_k$ and $\\alpha_k$ the update formula of \\acl{BFGS} algorithm for $B$ is defined by:\n\\begin{equation}\\label{eq:lbfgs_update_1}\n\t\\begin{array}{lc}\n\t\tB_{k+1} = B_k + \\frac{(s_k^T y_k + y_k^T B_k y_k)(s_k s_k^T)}{(s_k^T y_k)^2} - \\frac{B_k (s_k^T y_k + s_k y_k^T)}{s_k^T y_k}\n\t\\end{array}\n\\end{equation}\n\nWith $y_k = \\Delta f(x_{k+1}) - \\Delta f(x_k)$ and $s_k = x_{k+1}-x_k = a_k \\cdot p_k$.\n\nThe only thing left to be able to optimize using \\acs{BFGS} is the gradient $\\Delta f(x)$. This can either be done by approximating using finite differencing or by calculating the exact partial differentials of $f(x)$. \n\n\nTo get more accurate results calculating the partial differentials is preferred. In case of minimizing the objective function $ARIMA_{CSS}$ defined in \\eqref{eq:ARIMA_CSS} and $\\hat{X}_t$\n\\begin{equation}\\label{eq:ARIMA_CSS_long}\n\t\\begin{array}{rrlll}\n    \t\\hat{X}_t &=& \\displaystyle\\sum_{i=1}^{p} \\phi_i B^i X_t &+ \\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{i\\cdot s} X_t &- \\displaystyle\\sum_{i=1}^{p}\\displaystyle\\sum_{j=1}^{P} \\phi_i \\Phi_j B^{i + js} X_t \\\\\n        &+& \\displaystyle\\sum_{k=1}^{q} \\theta_i B^k e_t &+ \\displaystyle\\sum_{l=1}^{Q} \\theta_j B^{k\\cdot s} e_t &+ \\displaystyle\\sum_{k=1}^{q}\\displaystyle\\sum_{l=1}^{Q} \\theta_i \\theta_j B^{k + js} e_t\n\t\\end{array}\n\\end{equation}\n\nthe partial differentials are as follows:\n\\begin{equation}\\label{eq:gradient_arima_phi}\n\t\\begin{array}{lcl}\n\t\t\\frac{\\delta}{\\delta \\phi_n} ARIMA_{CSS}(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q}) &=& \\frac{1}{2}\\displaystyle\\sum_{t=1}^{T} 2 \\cdot (X_t - \\hat{X}_t) \\cdot (\\frac{\\delta}{\\delta \\phi_n} (X_t - \\hat{X}_t))\\\\\n        &=& \\displaystyle\\sum_{t=1}^{T} e_t \\cdot  (-B^n X_t +  \\displaystyle\\sum_{j=1}^{P} \\Phi_j B^{n + js} X_t)\n\t\\end{array}\n\\end{equation}\n\n\\begin{equation}\\label{eq:gradient_arima_theta}\n\t\\begin{array}{lcl}\n\t\t\\frac{\\delta}{\\delta \\theta_n} ARIMA_{CSS}(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q}) &=& \\displaystyle\\sum_{t=1}^{T} e_t \\cdot  (-B^n e_t - \\displaystyle\\sum_{l=1}^{Q} \\Theta_j B^{n + ls} e_t)\n\t\\end{array}\n\\end{equation}\n\n\\begin{equation}\\label{eq:gradient_arima_Phi}\n\t\\begin{array}{lcl}\n\t\t\\frac{\\delta}{\\delta \\Phi_n} ARIMA_{CSS}(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q}) &=& \\displaystyle\\sum_{t=1}^{T} e_t \\cdot  (-B^{n \\cdot s} X_t + \\displaystyle\\sum_{i=1}^{p} \\phi_i B^{i + ns} X_t)\n\t\\end{array}\n\\end{equation}\n\n\\begin{equation}\\label{eq:gradient_arima_Theta}\n\t\\begin{array}{lcl}\n\t\t\\frac{\\delta}{\\delta \\Theta_n} ARIMA_{CSS}(\\phi_{1..p}, \\Phi_{1..P}, \\theta_{1..q}, \\Theta_{1..Q}) &=& \\displaystyle\\sum_{t=1}^{T} e_t \\cdot  (-B^{n \\cdot s} e_t - \\displaystyle\\sum_{k=1}^{q} \\theta_j B^{k +ns} e_t)\n\t\\end{array}\n\\end{equation}\n\n%\\subsection{Nelder-Mead}\\label{neldermead}\n\n\\section{Solvers of Linear Systems}\\label{linsys_solvers}\n\nThe hardest part of calculating an approximation $\\hat{X}_t$ for the \\acs{ARIMA} model is finding a solution for the system of linear equation depicted in the equations \\eqref{eq:example_MA_three_system_1} and \\eqref{eq:example_multiplicative_SARIMA_2}.\nAnd again there are different approaches that can be taken. The first differentiation is between exact and numerical methods. One example for an exact one would be the \\textit{ Gaussian Elimination} solver. However, the complexity of this algorithm is $O(n^3)$ which means that is not suitable for large systems of equations. And especially for \\acs{ARIMA} this is almost always the case, because the system of linear equations will always be equal to the size of the time series used to train the model. So instead an iterative approach is used. The \\textit{Jacobi} method is one of these and it is commonly used, because of its simplicity and robustness. Additionally each iteration is quite fast. \n\n\\subsection{Jacobi} \\label{jacobi}\nGiven a system of linear equations given in the form of the equation \\eqref{eq:syslinequation} that can also be express as:\n\n\\begin{equation}\\label{eq:syslineqaution_long}\n\t\\begin{array}{lcl}\n\t\t\\displaystyle\\sum_{j=1}^{n} a_{ij} \\cdot x_j = b_i\n\t\\end{array}\n\\end{equation}\n\nUsing the \\textit{fixed-point iteration} method this equation \\eqref{eq:syslineqaution_long} can be transformed to be:\n\n\\begin{equation}\\label{eq:syslineqaution_fixedpoint}\n\t\\begin{array}{lrcl}\n\t\t&\\displaystyle\\sum_{j=1}^{n} a_{ij} \\cdot x_j &=& b_i\\\\\n        \\Leftrightarrow & a_{ii} \\cdot x_i \\displaystyle\\sum_{\\substack{j=1 \\\\ j\\neq i}} a_{ij} \\cdot x_j &=& b_i\\\\\n        \\Leftrightarrow & a_{ii} \\cdot x_i  &=& b_i \\displaystyle\\sum_{\\substack{j=1 \\\\ j\\neq i}} a_{ij} \\cdot x_j\\\\\n        \\Leftrightarrow & x_i  &=& a_{ii} - (b_i \\displaystyle\\sum_{\\substack{j=1 \\\\ j\\neq i}} a_{ij} \\cdot x_j)\n\t\\end{array}\n\\end{equation}\n\nLeading directly to the update function for the \\textit{Jacobi} method:\n\\begin{equation}\\label{eq:jacobi_update}\n\t\\begin{array}{lrcl}\n\t\tx_i^{(n+1)}  = a_{ii} - (b_i \\displaystyle\\sum_{\\substack{j=1 \\\\ j\\neq i}} a_{ij} \\cdot x_j^{(n)})\n\t\\end{array}\n\\end{equation}\n\n%\\subsection{Conjugate Gradient}\\label{cg}\n\n\n\\section{SystemML}\nSystemML is Machine Learning Platform built for large scale analytics. It enables flexible and scalable machine learning while also accelerating exploratory algorithm development. \n\nIt accomplishes this by providing the \\acl{DML} (\\acs{DML}). It can either be written in the default R-Like (\"DML\") or a Python-Like (\"PyDML\") syntax.\n\nThe goal of \\acs{DML} is to automatically scale any algorithm by translating all the instruction within the script into a set of \\textit{Spark} \\acs{API} calls so it can be run on a cluster in multiple nodes if necessary. Beforehand SystemML also uses code optimization methods to remove dead code and common sub expressions.\n\nEach script is optimized based on data and cluster characteristics, which means that the script is not only optimized once, but a second time as soon as all free variables - or rather parameters the script can be run with - are known and therefore for example all the sizes of the matrices needed can be calculated. Using this information combined with the details about cluster are used to optimize the script further by for example calculating the number of nodes needed to run the script.\n\nDML and PyDML scripts can be run in different modes. Either in Spark, Hadoop or Standalone mode. Additionally it can also be access via Scala or Python to be used in a Spark Shell, Jupyter or Zepplin Notebook. This enables easy and fast algorithm development in a well established development environment for ML.\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "f775b47200ac127224b418064c6477283b78a382", "size": 43267, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/02kapitel.tex", "max_stars_repo_name": "TobiasSchmidtDE/Scalable-Time-Series-Forecasting-with-ARIMA-for-SystemML", "max_stars_repo_head_hexsha": "c7935e293aae2d5dd3d10803537423c9dd24dc8e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/02kapitel.tex", "max_issues_repo_name": "TobiasSchmidtDE/Scalable-Time-Series-Forecasting-with-ARIMA-for-SystemML", "max_issues_repo_head_hexsha": "c7935e293aae2d5dd3d10803537423c9dd24dc8e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/02kapitel.tex", "max_forks_repo_name": "TobiasSchmidtDE/Scalable-Time-Series-Forecasting-with-ARIMA-for-SystemML", "max_forks_repo_head_hexsha": "c7935e293aae2d5dd3d10803537423c9dd24dc8e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.198019802, "max_line_length": 700, "alphanum_fraction": 0.7216585388, "num_tokens": 13904, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4470148562817462}}
{"text": "\n\\documentclass[runningheads, a4paper, oribibl]{llncs}\n\n\\setcounter{tocdepth}{3}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\graphicspath{{../images/}}\n\\usepackage{epstopdf}\n\\usepackage{standalone}\n\\usepackage{xcolor}\n\\usepackage{tikz}\n\\usetikzlibrary{fit}\n\\usetikzlibrary{shapes,snakes,calc}\n\n\n\n\\usepackage{listings, color}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{gray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mauve}{rgb}{0.58,0,0.82}\n\n\n\n\\lstset{frame=tb,\n  language=Matlab,\n  aboveskip=3mm,\n  belowskip=3mm,\n  showstringspaces=false,\n  columns=flexible,\n  basicstyle={\\small\\ttfamily},\n  numbers=none,\n  numberstyle=\\tiny\\color{gray},\n  keywordstyle=\\color{blue},\n  commentstyle=\\color{dkgreen},\n  stringstyle=\\color{mauve},\n  breaklines=true,\n  breakatwhitespace=false,\n  tabsize=2,\n  numbers=left,\n  numbersep=5pt,\n  title=\\lstname\n}\n\n\n\n\\usepackage[section]{placeins}\n\n\\usepackage{amsmath,amssymb, cancel}\n%\n\\usepackage{url}\n\\urldef{\\mailsa}\\path|201501005@daiict.ac.in|\n\\urldef{\\mailsb}\\path|201501422@daiict.ac.in|\n\\newcommand{\\keywords}[1]{\\par\\addvspace\\baselineskip\n\\noindent\\keywordname\\enspace\\ignorespaces#1}\n\n\n\\renewcommand\\thesubsection{\\thesection(\\alph{subsection})}\n\n\n\\begin{document}\n\n\\mainmatter\n\n\\title{High Performance Computing Report}\n\n\\titlerunning{High Performance Computing Report}\n\n\\author{Amarnath Karthi\\\\Chahak Mehta}%\n%\n\\authorrunning{Amarnath Karthi \\& Chahak Mehta}\n\\institute{Dhirubhai Ambani Institute of Information and Communication Technology\\\\\n  \\mailsa\\\\\n  \\mailsb\\\\\n}\n\n\\maketitle\n\\section{Implementation Details (Basic matrix multiplication)}\n\\subsection{Brief and clear description about the Serial implementation}\nThe serial implementation involves basic matrix multiplication using 3 nested loops.\n\\begin{equation}\n    C_{ij} = \\sum A_{ik}B_{kj}\n\\end{equation}\n\\subsection{Brief and clear description about the implementation of the approach (Parallelization Strategy, Mapping of computation to threads)}\nThe parallelization is achieved by load distribution of the middle loop over several processors, using the OpenMP library. We will be using the \\textbf{omp parallel for directive}.\n\\section{Complexity and Analysis}\n\\subsection{Complexity of serial code}\nCubic time complexity : $O(n^3)$.\nThis is because of the 3 nested loops, each having an $O(n)$ runtime complexity by itself.\n\\subsection{Theoretical Speedup (using asymptotic analysis, etc.)}\nFor an n core system, the theoretical speedup is approximately n.\n\\newpage\n\\section{Curve Based Analysis}\n\\subsection{Time Curve related analysis (as no. of processor increases)}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p1.png}\n    \\caption{Execution time for simple matrix multiplication}\n    \\label{fig:p1}\n\\end{figure}\nFor small problem sizes, the overhead of adding 1 extra core to the solution outweighs the advantages given by it. Thus for small input sizes, the execution time is higher for a higher number of cores. As the problem size increases, the overhead becomes insignificant in front of the compute time, which decreases drastically when a larger number of cores are used. This is quite natural because the work is shared equally amongst all processors.\n\n\\subsection{Speedup Curve related analysis (as problem size and no. of processors increase)}\nThe speedup is bound by \"n\", the number of cores. Therefore, irrespective of the problem size, the speedup is always lesser than n for n cores. For small problem sizes, the speedup is less than one if we use more cores. This again indicates that the load is too small to be parallelized efficiently. For very large problem sizes we see almost a constant speedup. This indicates that saturation has been achieved.  For 4 cores and a problem size of 512,  we get a speedup of approximately 3.2, whereas for 2 cores we get a speedup of 1.78.\n\\newpage\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p2.png}\n    \\caption{Speedup vs problem size}\n    \\label{fig:p2}\n\\end{figure}\n\\begin{figure}[b]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p3.png}\n    \\caption{Efficiency vs problem size}\n    \\label{fig:p3}\n\\end{figure}\n\\newpage\n\n\\section{Implementation Details(block matrix multiplication)}\n\\subsection{Brief and clear description about the Serial implementation}\nThis is a divide and conquer approach on traditional matrix multiplication. We recursively divide each matrix into smaller and smaller blocks, and perform multiplication and summation operations on them.\n\\subsection{Brief and clear description about the implementation of the approach (Parallelization Strategy, Mapping of computation to threads)}\nInitially we distribute a different set of blocks to each thread. In the combine step of a level, the results of 2 threads are added into one matrix, and one thread hands over its entire data to another and dies. This step goes on until there is one thread surviving. This thread will hold the final result of the matrix multiplication.\n\\section{Complexity and Analysis}\n\\subsection{Complexity of serial code}\nCubic complexity $O(n^3)$\n\\subsection{Theoretical Speedup (using asymptotic analysis, etc.)}\nn, where n is the total number of processors.\n\\section{Curve Based Analysis}\n\\subsection{Time Curve related analysis (as no. of processor increases)}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p4.png}\n    \\caption{Execution time for simple matrix multiplication}\n    \\label{fig:p4}\n\\end{figure}\nFor small problem sizes, the overhead of adding 1 extra core to the solution outweighs the advantages given by it. Thus for small input sizes, the execution time is higher for a higher number of cores. As the problem size increases, the overhead becomes insignificant in front of the compute time, which decreases drastically when a larger number of cores are used. This is quite natural because the work is shared equally amongst all processors.\n\\subsection{Speedup Curve related analysis (as problem size and no. of processors increase)}\nThe speedup is bound by \"n\", the number of cores. Therefore, irrespective of the problem size, the speedup is always lesser than n for n cores. For small problem sizes, the speedup is less than one if we use more cores. This again indicates that the load is too small to be parallelized efficiently. For very large problem sizes we see almost a constant speedup. This indicates that saturation has been achieved.  For 4 cores and a problem size of 512,  we get a speedup of approximately 2.09, whereas for 2 cores we get a speedup of 1.28.\n\\newpage\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p5.png}\n    \\caption{Speedup vs problem size}\n    \\label{fig:p5}\n\\end{figure}\n\\begin{figure}[b]\n    \\centering\n    \\includegraphics[width=\\textwidth]{p6.png}\n    \\caption{Efficiency vs problem size}\n    \\label{fig:p6}\n\\end{figure}\n\\newpage\n\\end{document}\n\n", "meta": {"hexsha": "051a8ef19607aa5c09645778a31387a2e42862b1", "size": 6876, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lab4/Report/main.tex", "max_stars_repo_name": "chahak13/HPC", "max_stars_repo_head_hexsha": "b4d9b699c4ae591bf5b25a023ac03218854419fd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lab4/Report/main.tex", "max_issues_repo_name": "chahak13/HPC", "max_issues_repo_head_hexsha": "b4d9b699c4ae591bf5b25a023ac03218854419fd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lab4/Report/main.tex", "max_forks_repo_name": "chahak13/HPC", "max_forks_repo_head_hexsha": "b4d9b699c4ae591bf5b25a023ac03218854419fd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7961783439, "max_line_length": 539, "alphanum_fraction": 0.7763234439, "num_tokens": 1750, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318194686359, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.44701485265167806}}
{"text": "\\documentclass[11pt, twoside, withdegree]{bhthesis}\n\n\\usepackage[ngerman, english]{babel}\n\n\\newcommand{\\OEIS}[1]{\\text{\\href{https://oeis.org/#1}{{\\small \\tt (#1)}}}}\n\\DeclarePairedDelimiter{\\abs}{\\lvert}{\\rvert}\n\\DeclarePairedDelimiter{\\iverson}{\\llbracket}{\\rrbracket}\n\n\\title{Eine supertolle Masterarbeit}\n\\author{Maria Musterfrau}\n\n\\reporttype{Masterarbeit}\n\\studname{Angewandte Informatik}\n\\degree{Diplom-Ingenieurin}\n\n\\involvedpeople{\n  \\person{0.45\\linewidth}{Betreuerin}{\n    \\hbox{Univ.-Prof.\\ Dr.\\ Alexandra Musterfrau}\\\\\n    Institut für Angewandte Informatik\\\\\n    Alpen-Adria-Universität Klagenfurt\n  }\\hfill\n  \\person[\\flushright]{0.45\\linewidth}{Gutachter}{\n    Dr.\\ Erich Mustermann\\\\\n    Institut für Mathematik\\\\\n    Technische Universität Graz\\\\\n  }\\\\[2em]\n}\n\n\n\\university{\n  \\hfill\\includegraphics{aau-logo.pdf}\\\\[1em]\n}\n\\universityname{Alpen-Adria-Universität Klagenfurt}\n\\fakultaetname{Fakultät für Technische Wissenschaften}\n\n\n\\begin{document}\n\\selectlanguage{ngerman}\n\\maketitle\n\n\\selectlanguage{english}\n\\chapter*{Abstract}\nThis is a short summary of the contents of this thesis.\n\n\\tableofcontents\n\n\\chapter{Introduction}\\label{chap:intro}\n\n\\section{Tasty!}\n\n\\begin{definition}[Open Set]\n  A set $\\Omega\\subseteq\\mathbb{C}$ is said to be \\emph{open}, if for every\n  $z_{0}\\in\\Omega$ there is a positive number $\\varepsilon > 0$ such\n  that for all $z\\in\\mathbb{C}$ that satisfy $\\abs{z - z_{0}} <\n  \\varepsilon$ we find $z\\in\\Omega$.\n\\end{definition}\n\n\\begin{theorem}[Cauchy's Integral Theorem]\\label{thm:cauchy}\n  Let $\\Omega\\subseteq\\mathbb{C}$ be an open and simply connected\n  set. Let $\\gamma:[0,1]\\to \\Omega$ be a closed path in $\\Omega$, and\n  let $f\\colon\\gamma^{*} \\to \\mathbb{C}$ be a holomorphic function.\n  Then the relation\n  \\begin{equation}\\label{eq:cauchy-integral}\n    \\oint_{\\gamma} f(z)~dz = 0\n  \\end{equation}\n  holds.\n\\end{theorem}\n\nThe following example provides verification for this important result.\n\n\\begin{example}\n  Consider $f\\colon \\mathbb{C} \\to \\mathbb{C}$ with $z\\mapsto\n  z^{2}$. Then, by Theorem~\\ref{thm:cauchy} we find\n  \\[ \\oint_{\\abs{z} = 42} f(z)~dz = 0.  \\]\n  In this case, it is not too difficult to verify that the theorem\n  holds by straightforward computation of the line integral; we use\n  the curve $\\gamma\\colon [0,1]\\to \\mathbb{C}$ with $\\gamma(t) =\n  42\\cdot\\exp(2\\pi i t)$. Straightforward computation yields\n  \\begin{align*}\n    \\oint_{\\abs{z} = 42} f(z)~dz\n    &= \\int_{0}^{1} f(\\gamma(t)) \\gamma'(t)~dt\\\\\n    &= 42^{3}\\cdot 2\\pi i \\cdot \\biggl[\\frac{\\exp(6 \\pi i t)}{6 \\pi\n      i}\\biggr]_{0}^{1} = 42^{3}\\cdot 2\\pi i\\cdot \\frac{1 - 1}{6\\pi\n      i} = 0,\n  \\end{align*}\n  which verifies the theorem.\n\\end{example}\n\n\\begin{theorem*}\n  Theorems do not have to be numbered, but they can stretch over\n  multiple lines and maybe even over to the next page. A very nice\n  formula is\n  \\[ e^{\\pi i} + 1 = 0, \\]\n  and it should help to illustrate a page break.\n\\end{theorem*}\n\n\\section{Improvements?}\n\nFeel free to adapt / polish the styling suggested by this template\nin any way you like. This template is hosted at\n\\url{https://github.com/behackl/thesis-template} -- I am happy to\ndiscuss ideas and suggestions for general improvement of this template.\n\n\n\n\\end{document}", "meta": {"hexsha": "b9d482aa1089a3005cbf31f199858bb08d4d5a16", "size": 3243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "testthesis.tex", "max_stars_repo_name": "behackl/thesis-template", "max_stars_repo_head_hexsha": "cb743dbc2a0b15be312d379ff781dd5147a5e03d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-12T08:50:40.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T08:50:40.000Z", "max_issues_repo_path": "testthesis.tex", "max_issues_repo_name": "behackl/thesis-template", "max_issues_repo_head_hexsha": "cb743dbc2a0b15be312d379ff781dd5147a5e03d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "testthesis.tex", "max_forks_repo_name": "behackl/thesis-template", "max_forks_repo_head_hexsha": "cb743dbc2a0b15be312d379ff781dd5147a5e03d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5943396226, "max_line_length": 75, "alphanum_fraction": 0.7008942337, "num_tokens": 1094, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.4470148491902601}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Monday\\\\ 2020-4-20, \\\\ compiled \\\\ \\today}\n\n% The Fourier transform is stochastic since the noise is stochastic: however, the PSD encompasses the statistical properties of the signal in a way that is stationary and well-defined. \n\nA physical system is a \\textbf{functional} \\(F\\) which transforms one or many input time series \\(i_j (t)\\) into one or many output time series \\(o_j (t) = F(i_j(t))\\). \n\nIn principle, any output time series at any time could be a function of any input time series at any time.\nHowever, real systems are causal: there cannot be causality going backward in time, so \\(o(t_0 ) = \\eval{F (i(t))}_{t \\leq t_0 }\\). \n\n% Also, often we can approximate systems as linear ones. as long as we work near a single point. \n% Also, we can sometimes approximate them as stationary. \nWe can also make two assumptions: that the functional \\(F\\) is \\textbf{linear} --- this is justified as long as we are always working near a fixed point, so that the higher order terms are negligible; and that the functional \\(F\\) is \\textbf{stationary}: this means that it is invariant under translations \\(t \\to t + a\\).\n\nUnder all of these assumptions, we can express the effect of the system through an \\textbf{impulse response function} \\(h\\), defined so that: \n%\n\\begin{align}\no(t) = F \\qty[\\int \\dd{\\widetilde{t}} i (\\widetilde{t}) \\delta(t - \\widetilde{t})]\n= \\int \\dd{\\widetilde{t}} i(\\widetilde{t}) F( \\delta (t - \\widetilde{t})) \n= \\int \\dd{\\widetilde{t}} i(\\widetilde{t}) h(t - \\widetilde{t})\n\\,.\n\\end{align}\n\nWe can say that \\(F[i(\\widetilde{t}) \\delta] = i(\\widetilde{t}) F[\\delta ]\\) because \\(t'\\) is fixed inside the integral, so \\(i(\\widetilde{t})\\) is just a constant. \n\nWe used stationarity to write \\(h(\\widetilde{t}, t)\\) as \\(h( \\widetilde{t} - t)\\); also, causality tell us that the IRF \\(h(\\tau )\\) must satisfy \\(h(\\tau ) = 0\\) for \\(\\tau < 0\\).\n\nThe expression for the output as a function of the input is a convolution, so in Fourier space it is a product;\n%\n\\begin{align}\no(\\omega ) = i(\\omega ) h(\\omega )\n\\,.\n\\end{align}\n\nThe power spectral density then transforms as \\(S_o (\\omega ) = \\abs{h(\\omega )}^2 S_i (\\omega )\\), and if we have systems in series we can just multiply the impulse responses together, like \n%\n\\begin{align}\no (\\omega ) = i(\\omega )\\prod_{j = 1}^{N} h_j (\\omega ) \n\\,.\n\\end{align}\n\n\\subsection{Sampling}\n\nOften we sample signals digitally.\nAnalogic systems can be faster, but electronics are getting very fast as well, and they are easier to use.\n\nThe signal is quantized in two ways: we quantize both in time by sampling at an interval \\(t_s\\) and in amplitude, by encoding it with a finite number of bits.\nThis introduces noise, which is well-known and easy to calculate.\nWe still need to do Fourier analysis, but we will use a discrete Fourier transform.\n\n\\subsubsection{Aliasing}\n\nIf we have a signal at a frequency \\(f\\), and we want to reconstruct it, we need to sample at a frequency \\(\\geq 2f\\).\n\nIf we sample at \\SI{100}{Hz}, we can only accurately describe signals up to \\SI{50}{Hz}. \nThis is the \\textbf{Nyquist-Shannon sampling theorem}.\n\nThis is true if we want to fit the data with the slowest sinusoid possible; if we know in which frequency range we should look we can try to fit higher-frequency sinusoids but this is risky business.\nIf we work below the Nyquist frequency we can be sure of each frequency we see.\n\n\\section{Resonant bar detectors}\n\n\\subsection{Two paths to GW detection}\n\nMost modern and planned GW detectors operate by constructing \\textbf{free-falling masses}: ground-based interferometers bounce signals off of suspended mirrors, space based ones have masses in actual geodesic motion. \nThese detectors are \\emph{broad-band}, which is useful, but each frequency has to be detected at its native amplitude with no amplification. \nThey can be made on \\emph{large scales}, on the order of \\SI{e3}{m} on Earth, \\SI{e9}{m} in space. This is very useful scientifically, since then the GW-induced displacement is larger; however it requires a lot of infrastructure and investment. \nThese must then be built and operated by large collaborations, with hundreds of people at least. \n\nAnother option, which was quite popular a few years ago, is to use an \\textbf{elastic body} which resonates at a specific frequency. \nThis might \\emph{enhance} the effect of a GW through resonance and \\emph{extend} the duration of burst signals. \n\nHowever, this kind of detector is only sensitive \\emph{around its resonant frequency}. \nAlso, since it extends the signal it is hard to precisely reconstruct the \\emph{temporal profile} of the signal. \n\nThese need to be isolated solid objects: they will fit in a lab (at scales of \\SI{e1}{m} at most), but the GW-induced displacements will be small. \n\n% On the other side, we have \\textbf{interferometers} which measure the distance between free-falling masses. \n\n\\subsection{Harmonic oscillators and GW}\n\n\\subsubsection{Harmonic oscillators}\n\nSuppose we have a perfect harmonic oscillator with a time-dependent rest position \\(x_0(t) \\) and a time-dependent external force \\(F _{\\text{ext}} (t)\\): its evolution will be determined by the differential equation \n%\n\\begin{align}\nm \\ddot{x} = -k (x(t) - x_0 (t) ) + F _{\\text{ext}} (t)\n\\,,\n\\end{align}\n%\nwhich in Fourier space can be written as \n%\n\\begin{align}\n- m \\omega^2 x(\\omega ) &= - k (x(\\omega ) - x_0 (\\omega )) + F _{\\text{ext}} (\\omega )  \\\\\nx(\\omega ) &= \\frac{k x_0 (\\omega ) + F _{\\text{ext}}(\\omega )}{k - m \\omega^2} = \\frac{k x_0 (\\omega ) + F _{\\text{ext}}(\\omega )}{k \\qty(1 - \\omega^2 / \\omega_0^2)}  \\\\\n&= \\underbrace{\\frac{\\omega_0^2}{1 - \\omega^2 /\\omega_0^2}}_{H_{x_0 }(\\omega )}\nx_0 (\\omega ) + \n\\underbrace{\\frac{F _{\\text{ext}} (\\omega )}{k (1 - \\omega^2 / \\omega_0^2)} }_{H_{F _{\\text{ext}}} (\\omega )}\nF _{\\text{ext}}(\\omega )\n\\,,\n\\end{align}\n%\nwhere we defined \\(\\omega_0 = \\sqrt{k / m}\\) and the two transfer functions \\(H_{x_0 }\\) and \\(H_{F _{\\text{ext}}}\\).\n\nThis diverges for \\(\\omega = \\omega_0 \\); but let us consider the effect of \\textbf{velocity damping}: we add a term \\(- \\beta \\dot{x}\\) to the RHS of the differential equation,\n%\n\\begin{align}\nm \\ddot{x} = - k \\qty(x(t) - x_0 (t)) - \\beta \\dot{x}(t) + F _{\\text{ext}}(t)\n\\,,\n\\end{align}\n%\nwhich in Fourier space becomes:\n%\n\\begin{align}\nx(\\omega ) = \\frac{k x_0 (\\omega ) + F _{\\text{ext}}(\\omega )}{k \\qty(1 - \\qty( \\frac{\\omega}{\\omega_0 })^2 - \\frac{i \\omega \\beta }{k})}\n\\,,\n\\end{align}\n%\nsince every derivative becomes \\(- i \\omega \\). \n\nAnother kind of damping we can have is called \\textbf{structural internal damping}, which means modifying the differential equation as:\n%\n\\begin{align}\nm \\ddot{x} = - k (1 + i \\delta ) \\qty(x(t) - x_0 (t)) + F _{\\text{ext}}(t)\n\\,;\n\\end{align}\n%\nconcretely speaking this means that there is some \\emph{delay} between the action of the force and the response of the system. In Fourier space, this means \n%\n\\begin{align}\nx(\\omega ) = \\frac{k x_0 (\\omega ) + F _{\\text{ext}}(\\omega )}{k \\qty(1 - \\qty( \\frac{\\omega}{\\omega_0 })^2 + i \\delta )}\n\\,,\n\\end{align}\n%\nso, since both terms add a purely imaginary constant to the denominator, we encapsulate them into a term \\(i / Q\\), for an arbitrary \\(Q\\). \n\nThis \\(Q\\) quantifies damping (inversely: large \\(Q\\) means small damping). For non-infinite values of \\(Q\\), the transfer function does not diverge.\n% The transfer function is more peaked for less damping. \n\n\\subsubsection{GW interactions}\n\nHow do we see the effect of GW on an elastic body?\nConsider two masses, which start out free-falling, and connect them by a spring: they now will not move along geodesics.\nIf we move to the \\textbf{proper detector frame}, the effect of a GW can be described as a Newtonian force on the test masses, which together with the reaction of the spring determines the motion of the system:\n%\n\\begin{align}\nF _{\\text{GW}} - k (L - \\Delta x) = m \\Delta \\ddot{x}\n\\,,\n\\end{align}\n%\nwhere the force is given by (equation \\eqref{eq:geodesic-deviation-detector-frame} multiplied by \\(m\\)):\n%\n\\begin{align}\nF_{\\text{GW}} = \\frac{m}{2} \\ddot{h}^{TT}_{xx} \\Delta x \\approx \\frac{m}{2} L \\ddot{h}^{TT}_{xx}\n\\,.\n\\end{align}\n\nSince we can only see \\(h_{xx}\\), we are only sensitive to the \\(h_{+}\\) polarization: this is not surprising, since our detector is one-dimensional. \n\nNote that this expression is only valid as long as we are in the short arm approximation: \\(L \\ll \\lambda _{\\text{GW}}\\), which means \\(f _{\\text{GW}} \\ll c/ L \\approx \\SI{3e8}{Hz}\\), if \\(L \\approx \\SI{1}{m}\\). \n\nIntuitively, what the equation is describing is the force of the GW competing with the intrinsic one of the oscillator to move the mass.\n\nThe oscillator was a convenient approximation to give an idea of the system, but really for our detector we will use a continuous \\textbf{resonant bar}; we can describe its movement by introducing the variable \\(u(x, t)\\), which denotes the displacement from equilibrium at a certain point (still in only \\emph{one dimension}). The dynamics of the bar can be shown to obey the law\n%\n\\begin{align}\n\\dd{m} \\qty(\\pdv[2]{u}{t} - v_s^2 \\pdv[2]{u}{x}) = \\dd{F_x} = \\dd{m} \\frac{1}{2} x \\ddot{h}_{xx}^{TT}\n\\,,\n\\end{align}\n%\nwhere \\(v_s\\) is the speed of sound in the medium. \n\\todo[inline]{Lagrangian or Eulerian?}\n\nWe assume that the ends of the bar are kept stationary:\n%\n\\begin{align}\n\\eval{\\pdv{u}{x}}_{x = \\pm L/2} = 0\n\\,.\n\\end{align}\n\nThe general solution will be given by a sum of sines and cosines, but the cosines will move the center of the bar. \n\n\\todo[inline]{They will, but we imposed the ends being stationary, not the center (and why should the center be stationary)! Why should we not use that condition instead? It works just as well, since \\emph{cosines} satisfy the condition of being zero at \\(\\pm L/2\\), and we get cosines from the first derivative of sines.}\n\nKeeping only the physical sines we will then have the harmonic decomposition\n%\n\\begin{align}\nu(t, x) = \\sum _{n=0}^{ \\infty } \\xi_{n} \\sin( \\frac{\\pi x}{L} (2 n + 1))\n\\,,\n\\end{align}\n%\nwhich we can plug into the differential equation: computing the derivatives explicitly we find \n%\n\\begin{align}\n\\sum _{n=0}^{ \\infty } \\bigg(\\ddot{\\xi}_{n} + \\underbrace{\\qty( \\frac{v_s \\pi (2n+1)}{L})^2}_{\\mathclap{\\omega_{n}^2}}\\bigg) \\sin( \\frac{\\pi x}{L} (2 n+1)) = \\frac{1}{2} x \\ddot{h}^{TT}_{xx}\n\\,,\n\\end{align}\n%\nwhich, in \\(L^2\\) space, is in the form \\(\\sum _{n} c_n \\hat{e}_{n} = \\vec{v}\\), where \\(\\hat{e}_n\\) are orthogonal basis vectors while \\(\\vec{v}\\) is a vector (recall that \\(\\ddot{h}_{xx}^{TT}\\) is approximately  constant with respect to \\(x\\), but it is multiplied by \\(x\\)).\nIn order to solve it, we take its scalar \\(L^2\\) product with an arbitrary basis vector, which amounts to multiplying by another sinusoid and integrating. \n\nThe sinusoids \\(\\hat{e}_{n} = \\sin((2n+1) \\pi x / L)\\) are not orthonormal, they instead satisfy \\(\\hat{e}_n \\cdot \\hat{e}_{m} = (L/2) \\delta_{nm}\\) as can be checked by direct computation. On the other side of the equation we find \n%\n\\begin{align}\n\\hat{e}_{m} \\cdot \\vec{v} &= \\frac{1}{2} \\ddot{h}^{TT}_{xx} \\int_{-L/2}^{L/2}  \\dd{x} x \\sin( \\frac{\\pi x}{L} (2 m + 1))  \\\\\n&= \\frac{1}{2} \\ddot{h}^{TT}_{xx} \\frac{L^2}{\\pi^2 (2m+1)^2} \\underbrace{\\eval{\\sin( \\frac{\\pi x}{L} (2 m + 1))}_{-L/2}^{L/2}}_{= 2 (-)^{m}} \\marginnote{The indefinite integral also has a term like \\(x \\cos(x)\\), which is odd and vanishes.}  \n\\,,\n\\end{align}\n%\nso the final equation reads: \n%\n\\begin{align}\n\\ddot{\\xi}_{n} + \\omega^2_{n} \\xi_{n} = \\frac{(-)^{n}}{(2n+1)^2} \\frac{2L}{\\pi^2} \\ddot{h}^{TT}_{xx}\n\\,.\n\\end{align}\n\nWe have eliminated (``integrated out'') the spatial part: we can analyze the time evolution by itself. \n\n\\end{document}\n", "meta": {"hexsha": "88ee441881abed78396f1134ef5bb6c100f80035", "size": 11748, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/gravitational_physics/apr20.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/gravitational_physics/apr20.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/gravitational_physics/apr20.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 52.9189189189, "max_line_length": 380, "alphanum_fraction": 0.6916922029, "num_tokens": 3620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4470139585017934}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsection{Sychrotron absorption}\n\n\\marginpar{Tuesday\\\\ 2020-9-1, \\\\ compiled \\\\ \\today}\n\nWe have seen what the total absorption coefficient (accounting for stimulated emission) is for a two-level system. \n\nWe want to use this expression in order to evaluate the total absorption due to the synchrotron process: so, we need to generalize it to a system with a continuum of energy levels, the free particle states with arbitrary velocity. \n\nWe will approach this by discretizing the space of possible energies of the particle.\nThere is a slight complication, in that for a given energy \\(h \\nu \\) there are now \\emph{many} pairs of levels having that energy between them. We will need to sum over them, still denoting all the higher-energy states in the pairs by ``2'' and the lower-energy states in the pairs by ``1''.\nIn this discretized description, then, we shall have an expression like \n%\n\\begin{align}\n\\alpha _\\nu  = \\frac{h \\nu }{4 \\pi } \\sum _{E_1 } \\sum _{E_2 } \n\\qty[n(E_1 ) B_{12} - n(E_2 ) B_{21} ] \\phi_{12}\n\\,,\n\\end{align}\n%\nwhere the sum is performed across all the possible energy levels \\(E_1 \\) and \\(E_2 \\) such that \\(E_2 - E_1 = h \\nu \\), while \\(n(E_1 )\\) and \\(n(E_2 )\\) are the respective number densities of the two energy states. \nOn the other hand, \\(\\phi_{12} \\) is the transition width. \n\nThe result we derived earlier was found by assuming that emission and absorption are isotropic; this is not true anymore since the magnetic field offers a preferential direction.\nHowever, we can work around this problem by assuming that the magnetic field is ``tangled'', so that the direction of its value at a randomly chosen point in space is essentially uniformly distributed along the sphere.\n\nWe can also quickly evaluate the emission coefficient \\(j_\\nu \\) (which is the power emitted per unit volume, solid angle and frequency): if the power per unit frequency emitted by a single electron is \\(P(E, \\nu )\\) then the coefficient is \n%\n\\begin{align}\nj_\\nu = \\frac{ \\dd{w}}{ \\dd{t} \\dd{\\nu }} \\frac{n(E)}{4 \\pi }\n= P(E, \\nu ) \\frac{n(E)}{4 \\pi }\n\\,,\n\\end{align}\n%\nwhere \\(n(E)\\) is the density of electrons at a specific energy \\(E\\). \nNote that this is not a differential quantity since we discretized the energy levels, so that they are countable. \nWe are also assuming isotropicity, by the same reasoning as before.\n\nThe coefficient \\(j_\\nu \\) can also be expressed in terms of the Einstein coefficients, as \n%\n\\begin{align}\nj_\\nu = \\frac{h \\nu }{4 \\pi } \\phi_{21}  (\\nu ) n_2 A_{21} \n\\,,\n\\end{align}\n%\nwhich like before can be generalized to the situation in which we have many possible energy levels giving rise to the same transition as \n%\n\\begin{align}\nj_\\nu = \\sum _{E_1 } \\frac{h \\nu }{4 \\pi }  \\phi_{21} n_2 A_{21} \n= \\frac{h \\nu }{4 \\pi } n_2  \\sum _{E_1 } \\phi_{21} A_{21} \n= \\frac{n_2 }{4 \\pi } P(E_2, \\nu  )\n\\,,\n\\end{align}\n%\nmeaning that now we know \n%\n\\begin{align}\nP(E_2 , \\nu ) = h \\nu \\sum _{E_1} \\phi_{21} A_{21} \n\\,.\n\\end{align}\n\nFrom the \\emph{detailed balance} relations we can also relate the Einstein coefficients as \n%\n\\begin{align}\nA_{21} = \\frac{2 h \\nu^3}{c^2} B_{21} \n\\,,\n\\end{align}\n%\nwhich we can substitute in, to find \n%\n\\begin{align} \\label{eq:spectral-power-from-einstein-B}\nP(E_2 , \\nu ) = h \\nu \\qty( \\frac{2 h \\nu^3}{c^2}) \\sum _{E_1} \\phi_{21} B_{21} \n\\,.\n\\end{align}\n\nThe reasoning we went to these great lengths to express the spectral power as a function of the Einstein coefficients is that we hope to invert the relation we found, giving us the coefficients as a function of the spectral power.\n\nWe have an expression for \\(\\alpha_\\nu \\) in terms of the coefficients \\(B_{21} \\) and \\(B_{12} \\); however we know from the detailed balance relations that, as long as the statistical weights of the energy levels are equal (which holds for us since we are considering free states), \\(B_{21} = B_{12} \\), so we can write the expression as \n%\n\\begin{align}\n\\alpha _\\nu &=  \\frac{h \\nu }{4 \\pi } \\sum _{E_1 } \\sum _{E_2 } B_{21} \\qty(n(E_1 ) - n(E_2 ) ) \\phi_{21} \\\\\n&= \\frac{h \\nu }{4 \\pi } \n\\sum _{E_2 } \\qty(n(E_2 - h \\nu ) - n(E_2 ))\n\\sum _{E_1 } B_{21} \\phi_{21} \\marginnote{Used \\(E_2 - E_1 = h \\nu \\).}  \\\\\n&= \\frac{h \\nu }{4 \\pi }\n\\sum _{E_2 } \\qty(n(E_2 - h \\nu ) - n(E_2 ))\n\\frac{P(E_2, \\nu )}{h \\nu \\frac{2 h \\nu^3}{c^2}}  \\marginnote{Used equation \\eqref{eq:spectral-power-from-einstein-B}.}\\\\\n&= \\frac{c^2}{8 \\pi h \\nu^3 } \n\\sum _{E_2 } \\qty(n(E_2 - h \\nu ) - n(E_2 ))\nP(E_2 , \\nu )\n\\,.\n\\end{align}\n\nThis expression makes some intuitive sense: in order to see how much radiation is absorbed at a frequency \\(\\nu \\) we consider all the pairs of levels with that gap, and for each multiply  the difference of electrons in the low vs high state by the power of the synchrotron process at that energy and frequency. \n\nThis works well for a system which we can discretize: however, if we want to use the language of the continuum of states we will need to turn the sum into an integral.\nIn order to do this, we need to introduce the distribution function of electrons in momentum space, \\(f(\\vec{p})\\), which we assume to be isotropic. Using it, we write \n%\n\\begin{align}\n\\alpha _\\nu = \n\\frac{c^2}{8 \\pi h \\nu^3}\n\\int \\dd[3]{p_2 } \\qty[ f(\\overline{p}_2 )- f(p_2 )]P (E_2 , \\nu )\n\\,,\n\\end{align}\n%\nwhere \\(p_2 \\) is the modulus of the momentum associated with \\(E_2 \\), and similarly \\(\\overline{p}_2\\) is associated with \\(E_1 = E_2 - h \\nu \\). \n\nLet us apply this for the well-known case in which the electron distribution is thermal, so that \n%\n\\begin{align}\nf(\\vec{p}) = k \\exp(- \\frac{E}{k_B T})\n\\,,\n\\end{align}\n%\nwhich means that \n%\n\\begin{align}\nf(\\overline{p}_2) - f(p_2) &= k \\qty(\\exp(- \\frac{E - h \\nu }{k_B T}) - \\exp(- \\frac{E}{k_B T}))  \\\\\n&= k \\exp(- \\frac{E}{k_B T}) \\qty(\\exp(\\frac{h \\nu }{k_B T}) - 1)\n= f(p_2) \\qty(\\exp(\\frac{h \\nu }{k_B T}) - 1)\n\\,.\n\\end{align}\n\nWe can plug this into the expression we have for the absorption  coefficient  to find \n%\n\\begin{align}\n\\alpha _\\nu &=\n\\frac{c^2}{8 \\pi h \\nu^3} \\int \\dd[3]{p} f(p) \\qty(\\exp(\\frac{h \\nu }{k_B T}) - 1) P(E, \\nu )  \\\\\n&= \\frac{c^2}{8 \\pi h \\nu^3} \\qty(\\exp(\\frac{h \\nu }{k_B T}) - 1) \\underbrace{\\int \\dd[3]{p} f(p) P(E, \\nu ) }_{4 \\pi j_\\nu }  \\\\\n&= \\frac{j_\\nu}{B_\\nu }\n\\,,\n\\end{align}\n%\nsince the rest of the expression we have is precisely the inverse of the Planck function. \nWe have \\textbf{recovered Kirkhoff's law}, which is expected since the electrons are assumed to be in thermal equilibrium. \n\nNow we want to proceed in the general case in which the distribution of the electron energies is not Maxwellian; a specific case of interest is a power-law spectrum, which as we have seen can be the effect of synchrotron emission and absorption.\n\n% \\todo[inline]{Are we sure about this? was the powerlaw tail not the effect of Comptonization?} \n\nWe wish to switch our integral from one over the particle momentum to one over the particle energy; in order to simplify the change of variable we will make the assumption that the particles are ultrarelativistic, therefore \\(E \\approx p c\\). The change of variable is then \n%\n\\begin{align}\n4 \\pi p^2 \\dd{p}=  4 \\pi \\frac{E^2}{c^2} \\frac{\\dd{E}}{c} = \\frac{4 \\pi E^2}{c^3} \\dd{E}\n\\,.\n\\end{align}\n%\nwhile the number of particles in this differential element is given by \n%\n\\begin{align}\n\\dd{N} = N(E) \\dd{E} = 4 \\pi p^2 \\dd{p} f(p) = \\frac{4 \\pi E^2}{c^3} \\dd{E} f(p)\n\\,,\n\\end{align}\n%\nso we can identify \n%\n\\begin{align}\nN(E) = \\frac{4 \\pi E^2}{c^3} f(p)\n\\qquad \\text{or} \\qquad\nf(p) = \\frac{N(E)}{E^2} \\frac{c^3}{4 \\pi }\n\\,,\n\\end{align}\n%\nwhere \\(f(p)\\) is calculated at the momentum \\(p = E /c\\).  \nPlugging this into the expression for the absorption coefficient we find \n%\n\\begin{align}\n\\alpha _\\nu = \\frac{c^2}{8 \\pi h \\nu^3} \\int \\frac{4 \\pi }{c^3} E^2 \\dd{E} \\frac{c^3}{4 \\pi } \\qty[\\frac{N(E - h \\nu )}{(E - h \\nu )^2} - \\frac{N(E)}{E^2}] P (E, \\nu )\n\\,.\n\\end{align}\n\nWe will further assume that the particle energy \\(E\\) is much larger than the photon energy \\(h \\nu \\); this is justified by the fact that we are not using the full machinery of QED which would be required if the calculation was nonclassical.\n\nIf this is the case, then we can expand the expression in a power series around \\(E\\), so that it reads \n%\n\\begin{align}\n\\alpha _\\nu  = - \\frac{c^2}{8 \\pi h \\nu^3} \\int E^2 P(E, \\nu ) \\pdv{}{E} \\qty[ \\frac{N(E)}{E^2}] h \\nu \n\\,.\n\\end{align}\n\nLet us restrict this result to a powerlaw electron distribution, so that \\(N(E) = C E^{-P}\\) for some \\(P \\in \\mathbb{R}^{+}\\). \nIf this is the case, then the expression inside the integral reads \n%\n\\begin{align}\n- E^2 \\dv{}{E} \\qty(\\frac{N(E)}{E^2})\n= - E^2 \\dv{}{E} \\qty[C E^{-P-2}]\n= C E^2 (P+2) E^{-P-3} = (P+2) \\frac{N(E)}{E}\n\\,,\n\\end{align}\n%\nso the absorption coefficient will be approximately \n%\n\\begin{align}\n\\alpha _\\nu = (P+2) \\frac{c^2}{8 \\pi \\nu^2} \\int \\frac{N(E)}{E} P(E, \\nu ) \\dd{E} \n\\,.\n\\end{align}\n\nWe must insert the known expression for the power radiated by a single charge as \\(P(E, \\nu )\\); this can be evaluated to finally find \n%\n\\begin{align}\n\\alpha _\\nu \\propto \\nu^{- (P+4) / 2}\n\\,.\n\\end{align}\n\nNow, recall that in general the definition of the source function \\(S_\\nu \\) is \n%\n\\begin{align}\nS_\\nu = \\frac{j_\\nu }{\\alpha _\\nu } = \\frac{P(\\nu )}{4 \\pi \\alpha _\\nu }\n\\,,\n\\end{align}\n%\nwhere \\(P(\\nu )\\) is the total spectral power, and since we know that its dependence on \\(\\nu \\) is as \\(P(\\nu ) \\propto \\nu^{- (P-1) / 2}\\), we can calculate the general source function for a powerlaw distribution: \n%\n\\begin{align}\nS_\\nu \\propto \\frac{\\nu^{- (P-1 ) / 2}}{\\nu^{- (P+4) / 2}} = \\nu^{- \\frac{P - 1 + P - 4}{2}} = \\nu^{5/2}\n\\,,\n\\end{align}\n%\nwhich is \\textbf{independent of} \\(P\\)! \n\nKnowing the source function we can make certain predictions about the emission of a medium which is optically thick at least for the low-energy part of the spectrum. \n\nWe have shown at the beginning of the course that if the optical depth in a medium is large then the specific intensity \\(I_\\nu \\) becomes close to the source function: \\(I_\\nu  \\sim S_\\nu \\). \nIn the case of synchrotron emission we have seen that \\(\\alpha_\\nu \\sim \\nu^{- (P+4) / 2}\\), a \\emph{decreasing} function of the frequency, so the absorption will be large at low energies and small at high energies. \nThe same will generally hold for the optical depth, since it is proportional to the absorption coefficient if the length (\\(\\sim\\) size of the medium) is fixed. \n\nOn the other hand, if the medium is optically thin then \\(I_\\nu \\sim j_\\nu \\sim P(\\nu )\\). \n\nSo, if we make a plot (let us make it log-log as is usually done) of the specific intensity \\(I_\\nu \\) as a function of frequency \\(\\nu \\) we will have a ``thick'' region at low \\(\\nu \\) where the intensity increases as \\(I_\\nu \\sim \\nu^{5/2}\\), and a ``thin'' region at high \\(\\nu \\) where the intensity decreases as \\(I_\\nu \\sim \\nu^{- (P-1) / 2}\\). \n\n\\end{document}\n", "meta": {"hexsha": "f09f17417455338461f60632c77215486f78dcdf", "size": 10935, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/radiative_processes/may07.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/radiative_processes/may07.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/radiative_processes/may07.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 46.9313304721, "max_line_length": 352, "alphanum_fraction": 0.6702331962, "num_tokens": 3628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4470139408492321}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Bremsstrahlung}\n\n\\marginpar{Saturday\\\\ 2020-8-22, \\\\ compiled \\\\ \\today}\n\nThe German word comes from the words meaning ``braking'' and ``radiation''. It is also called ``free-free emission''. \n\nThe name is historical: this kind of radiation was first observed in the lab coming from the deceleration of charges which hit a target. \nThis is the radiation emitted by electrons when a force is exerted upon them, for instance the Coulomb force by an ion. So, this kind of radiation can occur in a plasma since there we have both free protons and electrons. \n\nWe could also have electron-electron electromagnetic interactions, but in real astrophysical plasmas, as we shall see, this is less relevant. \n\nSuppose we have an ion with a positive charge \\(Ze\\), and an electron with a negative charge \\(-e\\). Between them we have the attractive electrostatic force, whose modulus is \n%\n\\begin{align}\nF = \\frac{Z e^2}{r^2}\n\\,.\n\\end{align}\n\nIf the ion is a proton, then the acceleration on the electron and on the proton can be calculated by equating \n%\n\\begin{align}\nm_e a_e = m_p a_p = \\frac{e^2}{r^2} \n\\,\n\\end{align}\n%\nin modulus.\nSo, the acceleration of the proton is about \\(m_p / m_e \\approx 1836\\) times \\emph{smaller} than that of the electron. This allows us to approximate the ion as a fixed source of force, neglecting its acceleration completely.  \n\nWe know from the Larmor formula \\eqref{eq:larmor} that the power emitted by an accelerating charge is proportional to its acceleration squared, so the power emitted by the ion is about \\((m_p / m_e)^2 \\approx \\num{4e6}\\) times smaller than that emitted by the electron. \n\nNow, let us consider the case of the repulsion of two identical particles, such as two electrons, in the nonrelativistic dipole approximation (which is not completely justified, often electrons will be relativistic\\dots however we will make it for simplicity).\n\nIf \\(d\\) is the dipole moment, then we know from the Larmor formula for the dipole \\eqref{eq:larmor-dipole} that the power emitted is proportional to \\(\\ddot{d}^2\\). \nThe dipole moment is \n%\n\\begin{align}\n\\vec{d} = -e \\sum _{i}  \\vec{r}_i = - \\frac{e}{m_e} \\sum _{i} m_e \\vec{r}_i\n= - \\frac{e}{m_e} \\vec{r}_{CM}\n\\,.\n\\end{align}\n\nWe can then see that the dipole moment is proportional to the center of mass of the system. \nNow, we are always implicitly assuming that the two charges we are treating are isolated, so they are not subject to any external forces: therefore, the acceleration of the center of mass is zero.\n\nThis means that \\(\\ddot{d} = 0\\), so the power emitted is zero in the dipole approximation. \nThis is why \\emph{a system of nonrelativistic identical charges does not radiate in the dipole approximation}. \n\nNow, let us move to an actual description of bremsstrahlung radiation. \nWe will treat it approximately; a complete description, even accounting for quantum mechanics, can be given, however it is beyond the scope of this course. \n\nWe start off by making the small angle approximation: we assume that the electron moves fast enough, so that its trajectory looks like a straight line and the deviation due to the proton is only a small perturbation.\n\nWe define the position vector \\(\\vec{r}\\) as the one connecting the ion to the electron, while \\(\\vec{v} = \\vec{\\dot{r}}\\) is the velocity of the electron, and the impact parameter \\(b = \\min \\abs{\\vec{r}}\\) measures the distance of closest approach of the particles. \n\nThe dipole moment is given by \\(\\vec{d} = -e \\vec{r}\\), whose second derivative will be \\(\\ddot{\\vec{d}} = -e \\vec{\\dot{v}}\\). \nLet us move to frequency space: \n%\n\\begin{align}\n\\frac{1}{2 \\pi } \\int_{-\\infty}^{\\infty } \\ddot{\\vec{d}} e^{i \\omega t} \\dd{t} &= \\frac{1}{2 \\pi } \\int_{-\\infty }^{\\infty } (- e \\dot{\\vec{v}})  e^{i \\omega t} \\dd{t} \\\\\n- \\omega^2 \\hat{d} (\\omega ) &= - \\frac{e}{2 \\pi } \\int_{-\\infty }^{\\infty} \\dot{\\vec{v}} e^{i \\omega t} \\dd{t}\n\\,.\n\\end{align}\n\nThen, we can see that if we are able to determine the value of the integral on the right-hand side we can directly calculate the dipole moment, and with it the emitted power. \nEvaluating it exactly is hard in general, however we can do so in two limiting cases, depending on the ``duration of the interaction''.\nThe timescale of the process, that is, the rough amount of time over which the electrostatic interaction between the two particles is significant, is of the order \\(\\tau \\approx b / v\\). \nThen, we can try to simplify the problem by integrating only over a range of size \\(\\sim \\tau \\) around zero in the time domain, instead of going from \\(- \\infty \\) to \\(+ \\infty \\), since there we will find the largest contribution. \n\nNow, our limiting cases refer to the frequency \\(\\omega \\) of the emitted radiation. \nIf this frequency is very high, such that \\(\\omega \\tau \\gg 1\\), then in the integral we will have a slowly-varying term \\(\\dot{v}\\) times a quickly oscillating term \\(\\exp(i \\omega \\tau )\\): thus, the value of the integral will be close to zero. \n\nOn the other hand, if \\(\\omega \\tau \\ll 1\\), then the exponential will be \\(\\exp(i \\omega \\tau ) \\approx 1\\): therefore the integral will be \n%\n\\begin{align}\n\\int_{-\\infty}^{\\infty } \\dot{\\vec{v}} e^{i \\omega t}\\dd{t} \\approx \n\\int_{-\\infty}^{\\infty } \\dot{\\vec{v}} \\dd{t} = \\Delta \\vec{v}\n\\,.\n\\end{align}\n\nTherefore, the Fourier transform of the dipole moment will be given by \n%\n\\begin{align}\n\\hat{d}(\\omega ) = \n\\begin{cases}\n    - \\frac{e}{2 \\pi } \\frac{\\Delta \\vec{v}}{\\omega^2} &\\qquad \\omega \\tau \\ll 1  \\\\\n    0 &\\qquad \\omega \\tau \\gg 1\\,.\n\\end{cases}\n\\end{align}\n\nWith this, we can compute the spectral distribution of the emitted radiation \\eqref{eq:spectral-distribution-dipole}: \n%\n\\begin{align}\n\\dv{w}{\\omega } \n&= \\frac{8 \\pi }{3 c^3 \\omega^{4}}\n\\begin{cases}\n    \\frac{e^2}{4 \\pi^2 } \\frac{\\abs{\\Delta \\vec{v}}^2}{\\omega^4} &\\qquad \\omega \\tau \\ll 1  \\\\\n    0 &\\qquad \\omega \\tau \\gg 1\n\\end{cases}\n\\\\\n&= \n\\begin{cases}\n    \\frac{2e^2}{3 \\pi c^3 } \\abs{\\Delta \\vec{v}}^2 &\\qquad \\omega \\tau \\ll 1  \\\\\n    0 &\\qquad \\omega \\tau \\gg 1\\,.\n\\end{cases}\n\\end{align}\n\nNow, then, we need to calculate \\(\\Delta \\vec{v}\\) in order to find the spectral distribution of the power. However, we already have an interesting result: a \\textbf{flat power spectrum} in both the high- and low-frequency regimes, at a certain value to be calculated for high frequencies, and at zero for low frequencies. \nThere will need to be some smooth connection between the two regions for \\(\\omega \\tau \\sim 1 \\). \n\nNow, as long as the interaction time is short, the electron ``flies by'' the ion, which then has little time to exert a force on it, and it will do so only in the region in which the electron is close, and in which \\(\\vec{F}\\) is approximately perpendicular to \\(\\vec{v}\\). \n\nIn general, we can compute the variation in velocity as \n%\n\\begin{align}\n\\Delta \\vec{v} = \\int_{- \\infty }^{\\infty} \\vec{a} \\dd{t}\n\\,,\n\\end{align}\n%\nand since the normal (dominant) component of the acceleration is given by \\(a_N = F_N / m_e \\), we can approximate it as\n%\n\\begin{align}\n\\abs{\\Delta \\vec{v}} \\approx \\int_{- \\infty }^{\\infty} \\frac{F_N}{m_e} \\dd{t}\n= \\int_{- \\infty }^{\\infty}\n\\frac{Ze^2}{m_e r^2} \\frac{b}{r} \\dd{t}\n\\,,\n\\end{align}\n%\nwhere the factor \\(b/r = \\cos \\theta \\) accounts for the fraction of the force which is indeed normal: \\(\\theta \\) is the angle between the radial separation \\(\\vec{r}\\) and the velocity \\(\\vec{v}\\) (or \\(\\pi - \\) this angle), so that \\(F \\cos \\theta = F_N\\). \nWe can then solve this using the fact that the particle moves linearly, so that \\(r^2= b^2 + v^2 t^2\\): substituting this in we find \n%\n\\begin{align}\n\\abs{\\Delta v} &= \\int _{- \\infty }^{\\infty} \\frac{Ze^2b}{m_e r^3} \\dd{t}\n= \\frac{Z e^2 b}{m_e} \\int  _{- \\infty }^{\\infty} \\frac{ \\dd{t}}{(b^2 + v^2 t^2)^{3/2}}  \\\\\n&= \\frac{Ze^2}{m_e bv } \\underbrace{\\int _{- \\infty }^{\\infty} \\frac{ \\dd{x}}{(1 + x^2)^{3/2}}}_{= 2} = \\frac{2 Z e^2}{m_e bv}\n\\,.\n\\end{align}\n\nWe can then insert this into the expression for the spectral distribution of the signal, also using \\(\\tau \\sim b/v\\): \n%\n\\begin{align}\n\\dv{w}{\\omega } \n&= \n\\begin{cases}\n    \\frac{8 Z^2e^6}{3 \\pi c^3 b^2 v^2 m_e^2 }  &\\qquad b \\ll v/\\omega   \\\\\n    0 &\\qquad b \\gg v/\\omega \\,.\n\\end{cases}\n\\end{align}\n\n\\subsubsection{Bremsstrahlung in a plasma}\n\nWe found the spectral density for a single electron: now, we wish to compute it for the whole plasma, whose ion density is \\(n_i\\), and whose electron density is \\(n_e\\).\nTo simplify, we will assume that all the electrons have the same speed \\(v\\), but we will let their impact parameters \\(b\\) vary.\n\nLet us consider this for a single ion, onto which many electrons will impact. \nThe flux of electrons will be given by \\(n_e v\\); so the number of particles crossing an annulus of radii \\(b\\), \\(b + \\dd{b}\\) will be given by \\(n_e v \\dd{A}  =2 \\pi b \\dd{b} n_e v\\). \nLet us then integrate in \\(\\dd{b}\\) to find the total emitted power. We will integrate from some minimum impact parameter \\(b _{\\text{min}}\\) instead of from zero: this is needed to find a physical result, and it will be explained in more detail later. We find: \n%\n\\begin{align}\n\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\omega }} = \\int_{b _{\\text{min}}}^{\\infty }\nn_e v \\dv{w}{\\omega } 2 \\pi b \\dd{b}\n= 2 \\pi n_e v \\int_{b _{\\text{min}}}^{\\infty} \\dv{w}{\\omega } b \\dd{b}\n\\,,\n\\end{align}\n%\nwhere now we need to substitute our expression; however we only have a nonzero contribution in the low-frequency limit, or equivalently the small-\\(b\\) limit. So, our integrand will be zero asymptotically; before that it will go as \\(1/b\\). We account for this by only integrating up to some cutoff \\(b _{\\text{max}} \\sim v/ \\omega \\), whose exact value must be determined by a more detailed analysis. We will use the rough estimate \\(b _{\\text{max}} = v / \\omega \\). \nIf we also account for the ion density \\(n_i\\) to find the power per unit frequency and volume, our integral can be expressed as:\n%\n\\begin{align}\n\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\omega } \\dd{V}}\n&= \\frac{16 Z^2 e^{6}}{3 c^3 m_e^2 v } n_e n_i \\int_{b _{\\text{min}}}^{b _{\\text{max}}} \\frac{b}{b^2} \\dd{b }  \\\\\n&= \\frac{16 Z^2 e^{6}}{3 c^3 m_e^2 v } n_e n_i\n\\log \\qty( \\frac{b _{\\text{max}}}{b _{\\text{min}}})\n\\,.\n\\end{align}\n\nNow, what should the value of \\(b _{\\text{min}}\\) be? \nA first approximation we made is the small-angle one, which holds as long as \\(\\abs{\\Delta \\vec{v}} / \\abs{\\vec{v}}\\) is small, less than unity. Suppose we are at the upper limit of this condition, when \\(\\abs{\\Delta \\vec{v}} \\sim \\abs{\\vec{v}}\\). \n\nInserting this into our expression for \\(\\abs{\\Delta \\vec{v}}\\) we find the limit where \\(b\\) is so small --- the electron comes so close to the ion --- that the interaction is too large to be treated perturbatively: \n%\n\\begin{align}\n\\abs{\\Delta \\vec{v}} \\sim v \\sim \\frac{2 Z e^2}{m_e b v} \\implies b = b _{\\text{min}} = \\frac{2 Z e^2}{m_e v^2}\n\\,.\n\\end{align}\n\nA second line of reasoning comes from the quantum-mechanical uncertainty principle: \\(\\Delta x \\Delta p \\gtrsim \\hbar\\). If our \\(\\Delta x\\) is \\(b _{\\text{min}}\\), this means that we will have \n%\n\\begin{align}\nb \\gtrsim b _{\\text{min}} = \\frac{\\hbar}{m_e v}\n\\,.\n\\end{align}\n    \nWhich of these is greater? To make it clearer, in natural units we are comparing (\\(1/m_e v\\) times) the quantities: \\(1\\) for the quantum mechanical threshold, and \n%\n\\begin{align}\n\\underbrace{8 \\pi \\alpha}_{\\approx \\num{.18}} \\frac{Z}{v} \n\\,\n\\end{align}\n%\nfor the small-angle-approximation threshold. Since we are dealing with  nonrelativistic particles \\(v\\) will be small, so this can easily become the larger bound of the two, even for a hydrogen ion. \n\n\\todo[inline]{These seem to both be arguments as to why we cannot deal with small \\(b\\) with our approximations, however I'd expect small-\\(b\\) processes to occur\\dots The quantum mechanical bound is more convincing than the other.}\n\nAnyhow, these considerations are all heuristic, and what is typically done is to parametrize the uncertainty in this aspect with a so-called \\textbf{Gaunt factor} \n%\n\\begin{align}\ng_{ff} (v, \\omega ) = \\frac{\\sqrt{3}}{\\pi } \\log \\qty(\\frac{b _{\\text{max}}}{ b _{\\text{min}}})\n\\,,\n\\end{align}\n%\nwhere the prefactor is, I think, there for historic reasons. This will in general be a function of both \\(v\\) (inside \\(b _{\\text{min}}\\)) and of \\(\\omega \\) (inside of \\(b _{\\text{max}}\\)). With it, we can write \n%\n\\begin{align} \\label{eq:single-velocity-bremsstrahlung-distribution}\n\\frac{ \\dd{w}}{ \\dd{t} \\dd{V} \\dd{\\omega }}\n&= \\frac{16 \\pi Z^2 e^6 \\pi }{3 \\sqrt{3} c^3 m_e^2 v} n_e n_i g_{ff} (v, \\omega )\n\\,.\n\\end{align}\n\nWith a proper quantum-mechanical treatment one can find an exact expression for this factor, and in the literature there are several good approximations which are good in different regimes; also, the values are tabulated. \nOne can then assume that this is a known function. \n\n\\end{document}\n", "meta": {"hexsha": "61ee894bc231487a3d5bb8a123110829edb4b6a6", "size": 12923, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/radiative_processes/apr02.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/radiative_processes/apr02.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/radiative_processes/apr02.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 57.1814159292, "max_line_length": 468, "alphanum_fraction": 0.6901648224, "num_tokens": 4035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.682573734412324, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.44701394084923207}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Sheet 12}\n\n\\subsection{Gravitational wave detection}\n\n\\subsubsection{Linear order edges stationarity}\n\nWe consider a perturbed metric  \\(g_{\\mu \\nu } = \\eta_{\\mu \\nu } + h_{\\mu \\nu }\\), and we denote as \\(h\\) the perturbative order in the correction to the Minkowski metric (\\emph{not} the trace of \\(h_{\\mu \\nu }\\), which is gauge-dependent and usually set to zero). \n\nWe take a test mass in Minkowski spacetime, and we choose a coordinate system such that at a certain starting time \\(\\tau_0 \\) this point is stationary, so at this time \\(u^{\\mu }(\\tau = \\tau_0  ) = u^{\\mu }_{0} = [1, \\vec{0}]^{\\top}\\) for this mass.\n\nAt a following time the gravitational wave arrives, and perturbs the test mass: the mass, by following geodesic motion with respect to the perturbed metric, will move with respect to the coordinates. This is described by the geodesic equation \n%\n\\begin{align} \\label{eq:geodesic-equation}\nu^{\\nu } \\nabla_{\\nu } u^{\\mu } = \\dv{ u^{\\mu } }{\\tau } + \\Gamma^{\\mu }_{\\alpha \\beta } u^{\\alpha } u^{\\beta } = 0\n\\,.\n\\end{align}\n\nWe want to prove that, in our gauge, the test mass does not acquire velocity to linear order in \\(h\\). \nFirst of all, to zeroth order in \\(h\\) the mass is in a Minkowski spacetime so, the Christoffel symbols are all zero and it does not move. In fact, the Christoffel symbols are made up of terms of the form \\(\\Gamma \\sim g^{-1} \\partial g = g^{-1} \\partial h\\), which is  \\(\\mathcal{O}(h)\\) at least. \nThe velocity, on the other hand, is nonzero at linear order: \\(u^{\\mu } = u^{\\mu }_{0} + \\mathcal{O}(h)\\).\n\nWe wish to consider equation \\eqref{eq:geodesic-equation} to linear order; more specifically we are interested in the second term \\(\\Gamma^{\\mu }_{\\alpha \\beta } u^{\\alpha } u^{\\beta }\\), which defines the time evolution of the 4-velocity. For this to be first order the velocity must be considered only to constant order, since the Christoffel symbols are already first order. \n\nTherefore we are left with \n%\n\\begin{subequations}\n\\begin{align}\n\\dv{ u^{\\mu }}{\\tau } &= - \\Gamma^{\\mu }_{\\alpha \\beta } u^{\\alpha }_{0} u^{\\beta }_{0} = - \\Gamma^{\\mu }_{00} \\\\\n&= - \\frac{1}{2} \\eta^{\\mu \\nu } \\qty(2h_{\\nu  0, 0} + h_{00,\\nu }) = 0 \\marginnote{The inverse metric must be considered only to constant order, otherwise the term is second order}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhich vanishes because, in our gauge, \\(h_{\\mu 0} = 0\\) for all \\(\\mu \\). \n\n\\subsubsection{Linear order gravitational wave \\(\\Delta T / T\\)}\n\nWe consider a gravitational wave \n%\n\\begin{align}\nh_{ij} (t, \\vec{x}) = \\cos(kt - \\vec{k} \\cdot \\vec{x}) \\sum _{r = \\times , +} e_{ij}^{r} h_{r}\n\\,,\n\\end{align}\n%\nwhere \n%\n\\begin{subequations}\n\\begin{align}\ne_{ij}^{+} = \\left[\\begin{array}{cc}\n1 &  0 \\\\ \n0 & -1\n\\end{array}\\right] \\qquad \\text{and} \\qquad\ne_{ij}^{ \\times } = \\left[\\begin{array}{cc}\n0 & 1 \\\\ \n1 & 0\n\\end{array}\\right]\n\\,\n\\end{align}\n\\end{subequations}\n%\nand \\(\\vec{k}^2 = k^2\\). In principle the cosine could have an arbitrary phase added to the argument, but we set it to zero for simplicity. \nAlso, we set \\(\\vec{k} = k \\hat{z}\\). \n\nOur interferometer configuration is as follows at order \\(h^{0}\\): we have the beamsplitter at coordinates \\(\\vec{B} = [0,0,0]^{\\top}\\) and the two mirrors at coordinates \\(\\vec{M}_{1} = T [\\cos(\\alpha ), \\sin(\\alpha ),0]^{\\top} T \\hat{L}_{1}\\) and \\(\\vec{M}_{2} = T [ \\cos(\\alpha + \\pi /2), \\sin(\\alpha + \\pi /2),0]^{\\top} = T \\hat{L}_{2}\\), for some angle \\(\\alpha \\): this means that the arms are orthogonal and at a certain angle with respect to the incoming gravitational wave's basis axes. \nWe also defined some basis vectors aligned along the interferometer's arms. \n\nWe start off two beams of light at the beamsplitter at \\(t=0\\), and see how much time they each take to reach their respective mirrors. If these are the times \\(T_{1,2}\\) we then define \\(\\Delta T = \\abs{T_1 - T_2 }\\) and compute \\(\\Delta T / T\\). \n\nPhotons' trajectories are defined by \\(\\dd{s^2} = 0\\): so, if we parametrize a photon trajectory by \\(x^{\\mu }_{p} (\\lambda ) = \\lambda [1, \\hat{L}_{p}]^{\\top}\\) (for \\(p = 1, 2\\)) this means that the photon's 4-velocity is \n%\n\\begin{align}\nu^{\\mu }_{p} = \\dv{}{\\lambda } x^{\\mu }_{p}(\\lambda ) = [1, \\hat{L}_{p}]\n\\,,\n\\end{align}\n%\nso if we assume the 4-velocity is normalized in the perturbed metric we find\n%\n\\begin{subequations}\n\\begin{align}\n0=\\dd{s^2} &= - \\dd{t_{p}^2} + \\qty(\\delta_{ij} + h_{ij}) \\hat{L}^{i}_{p} \\hat{L}^{j}_{p} \\dd{\\lambda^2}   \\marginnote{\\(\\hat{L}\\) is a unit vector}[.5cm]\\\\\n\\dd{t_{p}^2}  &= \\qty(1 + h_{ij} \\hat{L}^{i}_{p} \\hat{L}^{j}_{p}) \\dd{\\lambda^2}  \\\\\n\\dd{t_{p}}  &= \\sqrt{1 + h_{ij} \\hat{L}^{i}_{p} \\hat{L}^{j}_{p}} \\dd{\\lambda} \\approx \\qty(1 + \\frac{1}{2} \\abs{\\hat{L}_{p}}_{h}^2) \\dd{\\lambda } \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere by \\(\\abs{\\hat{L}_{p}}_{h}\\) we mean the norm of the vector \\(\\hat{L}\\) taken with respect to the bilinear form \\(h_{ij}\\). \n\nNow, we can compute the integral giving us the total time: \n%\n\\begin{subequations}\n\\begin{align}\nT_{p} &= \\int \\dd{t_{p}}  \\\\\n&\\approx \\int \\qty(1 + \\frac{1}{2} \\abs{\\hat{L}_{p}}_{h}^2) \\dd{\\lambda }  \\\\\n&= T + \\frac{1}{2} \\int \\dd{\\lambda } \\cos(kt-\\vec{k}\\cdot \\vec{x})  \\qty(\\sum_{r} e^{r}_{ij} h_{r} )\\hat{L}^{i}_{p}\\hat{L}^{j}_{p}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere \\(t\\) and \\(\\vec{x}\\) are to be considered as functions of \\(\\lambda \\): \\(t=\\lambda \\) and \\(\\vec{x} = \\hat{L}_{p} \\lambda \\), but by what we have assumed \\(\\vec{k} \\cdot \\vec{x} =0\\) since the gravitational wave is perpendicular to the interferometer's plane. \n\nBefore assuming anything else, let us compute the bilinear form contribution. For brevity we will denote a cosine as \\(c\\) and a sine as \\(s\\). Then, for both \\(p =1\\) and \\(p=2\\) we will have: \n%\n\\begin{subequations}\n\\begin{align}\ne_{ij}^{+} \\hat{L}^{i}_{p} \\hat{L}^{j}_p \n= \\left[\\begin{array}{ccc}\nc & s & 0\n\\end{array}\\right] \n\\left[\\begin{array}{ccc}\n1 & 0 & 0 \\\\ \n0 & -1 & 0 \\\\ \n0 & 0 & 0\n\\end{array}\\right] \n\\left[\\begin{array}{c}\nc \\\\ \ns \\\\ \n0\n\\end{array}\\right]= c^2- s^2 \n\\,\n\\end{align}\n\\end{subequations}\n%\nfor the plus polarization, and \n%\n\\begin{subequations}\n\\begin{align}\ne_{ij}^{ \\times } \\hat{L}^{i}_{p} \\hat{L}^{j}_p \n= \\left[\\begin{array}{ccc}\nc & s & 0\n\\end{array}\\right] \n\\left[\\begin{array}{ccc}\n0 & 1 & 0 \\\\ \n1 & 0 & 0 \\\\ \n0 & 0 & 0\n\\end{array}\\right] \n\\left[\\begin{array}{c}\nc \\\\ \ns \\\\ \n0\n\\end{array}\\right]= 2cs\n\\,\n\\end{align}\n\\end{subequations}\n%\nfor the cross polarization. Now, recall that \n%\n\\begin{align}\n\\cos^2 x - \\sin^2 x = \\cos(2x) \\qquad \\text{and} \\qquad\n2 \\sin x \\cos x = \\sin (2 x)\n\\,,\n\\end{align}\n%\nand \\emph{also} notice that we need to evaluate these expressions for \\(x = \\alpha \\) for the first arm, with \\(p=1\\), and for \\(x = \\alpha + \\pi /2\\) for the other arm, with \\(p=2\\). Then, since all the dependence is on trigonometric functions of \\emph{two times} \\(x\\) we must have that the correction on one arm is exactly equal in value and opposite in sign to the correction on the other arm, since the argument of the trigonometric functions changes by \\(\\pi \\) and both sine and cosine are odd under translations of \\(\\pi \\).\n\nThis means that in the global expression for \\(\\Delta T\\) we will have twice the same term: then we can collect them, and find \n%\n\\begin{align}\n\\Delta T = \\qty(h_{+} \\cos(2 \\alpha ) + h_{ \\times } \\sin(2 \\alpha )) \\int \\dd{\\lambda } \\cos(\\lambda k)\n\\,,\n\\end{align}\n%\nwhere \\(k\\) is the wavenumber / frequency of the gravitational wave, while \\(\\lambda \\) must be integrated from 0 to \\(T\\), the length of the interferometer arms. \n\nThe dimensions of the argument of the cosine are \\SI{}{m/s}, so in order to make it adimensional we need to divide it by \\(c\\). The typical order of magnitude of the frequencies of GWs detected at the LIGO/VIRGO detectors is around \\(f = \\SI{100}{Hz}\\), while the length of the arms is around \\(T =\\SI{4}{km}\\). Therefore, the argument of the cosine is bounded by \n%\n\\begin{align}\n\\frac{2 \\pi f T }{c} \\lesssim \\frac{\\SI{100}{Hz} \\times \\SI{4}{km}}{c} \\approx \\num{e-2}\n\\,,\n\\end{align}\n%\nwhere we used the relation between frequency and angular velocity: \\(k = 2 \\pi f\\). This is small but not exceedingly small: we can approximate \\(\\cos(\\lambda k ) = \\const\\) but our predictions will not exceed second-significant-digit accuracy. \n\nWith this approximation, the integral will equal the size of the integration region times the value of the cosine, leaving us with: \n%\n\\begin{align}\n\\Delta T = \\qty(h_{+} \\cos(2 \\alpha ) + h_{ \\times } \\sin(2 \\alpha )) T \\cos(t k)\n\\,,\n\\end{align}\n%\nwhich will vary in time in general, but if the light starts at \\(t=0\\) then in our approximation the cosine will always equal \\(1\\).  In the end  then we will be left with: \n%\n\\begin{align}\n\\frac{\\Delta T}{T} = h_{+} \\cos(2 \\alpha ) + h_{ \\times } \\sin(2 \\alpha )\n\\,.\n\\end{align}\n\n\\subsubsection{Return trip \\(\\Delta T / T\\)}\n\nIf we want to consider the return trip, almost everything will be the same except: \n\\begin{enumerate}\n  \\item the starting time and arrival time will change;\\label{it:starting-time}\n  \\item the unit vectors \\(\\hat{L}\\) will change into \\(- \\hat{L}\\). \\label{it:parity}\n\\end{enumerate}\n\nPoint \\ref{it:starting-time} is not a concern if we are in the small frequency approximation: the cosine  will still almost be equal to 1, although the approximation will get a little worse. \n\nPoint \\ref{it:parity} is not a concern either: the \\(h-\\)norm \\(\\hat{L} \\rightarrow h_{ij} \\hat{L}^{i} \\hat{L}^{j}\\) is symmetric, so the norm of a unit vector does not change under parity.\n\nThis means that over the time of the return trip a difference \\(\\Delta T _{\\text{return}} = \\Delta T _{\\text{forward}}\\) will be accumulated, so when we calculate \\(\\Delta T _{\\text{total}} / (2T)\\) we will get the same result we did with just the forward trip. \n\n\\subsubsection{Exact integration}\n\nWe now wish to calculate the global time difference without assuming \\(k \\lambda \\) is small. As we saw before the contributions for the forward and backward journeys are the same, so we need to evaluate the integral \n%\n\\begin{align}\n\\int_{0}^{2T} \\cos(\\lambda k) \\dd{\\lambda } \n= \\left. \\frac{1}{k} \\sin(\\lambda k ) \\right\\vert_{\\lambda = 0}^{\\lambda = 2T} = \\frac{\\sin(2Tk)}{k} \n\\,,\n\\end{align}\n%\nand, as expected, if \\(Tk \\sim 0\\) then \n%\n\\begin{align}\n\\frac{\\sin(2Tk)}{k} \\sim \\frac{2Tk}{k} = 2T\n\\,.\n\\end{align}\n\nSo, the proper formula is \n%\n\\begin{align}\n\\frac{\\Delta T}{2T} = \n\\qty(h_{+} \\cos(2 \\alpha ) + h_{ \\times } \\sin(2 \\alpha ))\n\\frac{\\sin(2Tk)}{2Tk}\n\\,.\n\\end{align}\n\nThis vanishes for all the zeros of \\(\\sin(2Tk)\\): for \\(k=0\\) this is expected (there is no gravitational wave) but it is weird for \\(2Tk = n \\pi \\), \\(n \\in \\mathbb{Z} \\setminus \\qty{0}\\). \n\nLet us look at the first weird case: \\(2Tk = \\pi \\) to get an idea. \n\nIn that case, we have \\(k =  \\pi / 2T \\), so the frequency of the GW is \\(f = k / 2 \\pi  =  1/ 4 T\\). \n\nSince gravitational waves travel at velocity 1, we have \\(fP = 1\\), where \\(f\\) and \\(P\\) are respectively the  frequency and period of the GW (spatial or temporal: it is equivalent, since \\(c=1\\)). \nThis means that, in the case we are considering, the wavelength of the GW is precisely equal to twice the length of the interferometer's arm, since we found \\(P = 4T\\). \n\nMore generally, we will have \\(k = n \\pi /2T\\)\n%\n\\begin{align}\nP = \\frac{1}{f} = \\frac{2 \\pi }{k} = \\frac{4 \\pi T}{n \\pi } = \\frac{4T}{n}\n\\,,\n\\end{align}\n%\nand we have proven that at precisely those frequencies the gravitational wave will have a vanishing net effect, since it will go through precisely \\(n\\) cycles during the beam's trajectory. \n\n% The factor of 2 is \\emph{probably} connected with the spin-2 nature of gravitons (i.\\ e.\\ the fact that they are symmetric under rotations of \\(\\pi \\) around the wavevector).\n\n\\end{document}\n", "meta": {"hexsha": "10e50b9619f66e38c58306097876f81a54cdab62", "size": 11855, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/gr_exercises/sheet12.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/gr_exercises/sheet12.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/gr_exercises/sheet12.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 47.0436507937, "max_line_length": 532, "alphanum_fraction": 0.6568536482, "num_tokens": 3987, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.44701394011174944}}
{"text": "\\documentclass[12pt]{article}\n\\author{David Alves}\n\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{dirtytalk}\n\\usepackage[a4paper]{geometry}\n\\usepackage{forest}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{multicol}\n\\usepackage{nth}\n\\usepackage{relsize}\n\\usepackage{skak}\n\\usepackage{tikz}\n\\usepackage{tikz-qtree}\n\\usepackage{titling}\n\\usepackage{wrapfig}\n\\usepackage{xcolor}\n\n\\usetikzlibrary{decorations.pathreplacing}\n\\usetikzlibrary{patterns}\n\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\def\\multichoose#1#2{\\ensuremath{\\left(\\kern-.3em\\left(\\genfrac{}{}{0pt}{}{#1}{#2}\\right)\\kern-.3em\\right)}}\n\n\\newcommand{\\ts}[1]{\\textsuperscript{#1}}\n\n\\newcommand{\\ProblemStatement}[1]{\n\\subsection*{Problem Statement}\n#1\n\\subsection*{Solution}\n}\n\n% If uncommented, next line hides problem statements \n%\\renewcommand{\\ProblemStatement}[1]{}\n\n\n\\title{Math 142 Problem Set 13}\n\\author{David Alves}\n\\date{2016-12-01}\n\n\\begin{document}\n\\pagenumbering{gobble}\n\n\\begin{center}\n\\large \\thetitle \\\\\n\\theauthor \\\\\n\\thedate\n\\end{center}\n\n\\subsection*{Sources}\n\n    \\begin{itemize}\n    \\item http://tex.stackexchange.com and https://www.sharelatex.com for help with \\LaTeX\n    \\end{itemize}\n\n\\section{Patriotic Octagons}\n\\ProblemStatement{\nSuppose you have to paint each edge of an octagon red, white, or blue. Find the\nnumber of ways to do this, counting two painting methods the same if they can be\nobtained from each other by rotation.\n}\n \nThere are 834 ways of painting the sides of an octagon red, white, or blue that\nare distinct under rotation.\n\n\\begin{proof}\nLet $G = C_8$, the cyclic group of 8 elements. Let 1 denote the identity\npermutation in $G$, $g$ denote rotation by 1, $g^2$ denote rotation by two, etc. \nWe know that $Fix(g^k)$ is the number of colors (3) to the power of the number\nof cycles in $g^k$, since each cycle must have all elements the same color. \nBelow are the cycles counts for each permutation.\n\n\\subsubsection*{One Cycle}\n\n\\begin{tikzpicture}\n\\node at (0,0) {$g$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend left=10] (B);\n\\draw [->] (B) edge[bend left=10] (C);\n\\draw [->] (C) edge[bend left=10] (D);\n\\draw [->] (D) edge[bend left=10] (E);\n\\draw [->] (E) edge[bend left=10] (F);\n\\draw [->] (F) edge[bend left=10] (G);\n\\draw [->] (G) edge[bend left=10] (H);\n\\draw [->] (H) edge[bend left=10] (A);\n\\end{tikzpicture}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^7$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend right=10] (H);\n\\draw [->] (B) edge[bend right=10] (A);\n\\draw [->] (C) edge[bend right=10] (B);\n\\draw [->] (D) edge[bend right=10] (C);\n\\draw [->] (E) edge[bend right=10] (D);\n\\draw [->] (F) edge[bend right=10] (E);\n\\draw [->] (G) edge[bend right=10] (F);\n\\draw [->] (H) edge[bend right=10] (G);\n\\end{tikzpicture}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^3$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend right=10] (D);\n\\draw [->] (B) edge[bend right=10] (E);\n\\draw [->] (C) edge[bend right=10] (F);\n\\draw [->] (D) edge[bend right=10] (G);\n\\draw [->] (E) edge[bend right=10] (H);\n\\draw [->] (F) edge[bend right=10] (A);\n\\draw [->] (G) edge[bend right=10] (B);\n\\draw [->] (H) edge[bend right=10] (C);\n\\end{tikzpicture}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^5$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend left=10] (F);\n\\draw [->] (B) edge[bend left=10] (G);\n\\draw [->] (C) edge[bend left=10] (H);\n\\draw [->] (D) edge[bend left=10] (A);\n\\draw [->] (E) edge[bend left=10] (B);\n\\draw [->] (F) edge[bend left=10] (C);\n\\draw [->] (G) edge[bend left=10] (D);\n\\draw [->] (H) edge[bend left=10] (E);\n\\end{tikzpicture}\n\n\\subsubsection*{Two Cycles}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^2$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend right=30] (C);\n\\draw [->] (B) edge[bend right=30] (D);\n\\draw [->] (C) edge[bend right=30] (E);\n\\draw [->] (D) edge[bend right=30] (F);\n\\draw [->] (E) edge[bend right=30] (G);\n\\draw [->] (F) edge[bend right=30] (H);\n\\draw [->] (G) edge[bend right=30] (A);\n\\draw [->] (H) edge[bend right=30] (B);\n\\end{tikzpicture}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^6$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend left=30] (G);\n\\draw [->] (B) edge[bend left=30] (H);\n\\draw [->] (C) edge[bend left=30] (A);\n\\draw [->] (D) edge[bend left=30] (B);\n\\draw [->] (E) edge[bend left=30] (C);\n\\draw [->] (F) edge[bend left=30] (D);\n\\draw [->] (G) edge[bend left=30] (E);\n\\draw [->] (H) edge[bend left=30] (F);\n\\end{tikzpicture}\\\\\n\n\n\\noindent\\begin{minipage}{.35\\textwidth}\n\\subsubsection*{Four Cycles}\n\\begin{tikzpicture}\n\\node at (0,0) {$g^4$};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[bend left=20] (E);\n\\draw [->] (B) edge[bend left=20] (F);\n\\draw [->] (C) edge[bend left=20] (G);\n\\draw [->] (D) edge[bend left=20] (H);\n\\draw [->] (E) edge[bend left=20] (A);\n\\draw [->] (F) edge[bend left=20] (B);\n\\draw [->] (G) edge[bend left=20] (C);\n\\draw [->] (H) edge[bend left=20] (D);\n\\end{tikzpicture}\n\\end{minipage}%\n\\begin{minipage}{.5\\textwidth}\n\\subsubsection*{Eight Cycles}\n\\begin{tikzpicture}\n\\node at (0,.15) {\\textbf{(id)}};\n\\node[shape=circle] (A) at (0,1.5) {1};\n\\node[shape=circle] (B) at (1.06,1.06) {2};\n\\node[shape=circle] (C) at (1.5,0) {3};\n\\node[shape=circle] (D) at (1.06,-1.06) {4};\n\\node[shape=circle] (E) at (0,-1.5) {5};\n\\node[shape=circle] (F) at (-1.06,-1.06) {6};\n\\node[shape=circle] (G) at (-1.5,0) {7};\n\\node[shape=circle] (H) at (-1.06,1.06) {8};\n\\draw [->] (A) edge[loop above,looseness=4] (A);\n\\draw [->] (B) edge[loop above,looseness=4] (B);\n\\draw [->] (C) edge[loop above,looseness=4] (C);\n\\draw [->] (D) edge[loop above,looseness=4] (D);\n\\draw [->] (E) edge[loop above,looseness=4] (E);\n\\draw [->] (F) edge[loop above,looseness=4] (F);\n\\draw [->] (G) edge[loop above,looseness=4] (G);\n\\draw [->] (H) edge[loop above,looseness=4] (H);\n\\end{tikzpicture}\n\\end{minipage}\n\nTherefore we have the following cardinalities for $Fix(g^k)$:\n\n\\begin{center}\n\\begin{tabular}{ rcccl }\n    $|Fix(1)|  $ &=& $3^8$ &=& 6561\\\\\n    $|Fix(g)|  $ &=& $3^1$ &=& 3\\\\\n    $|Fix(g^2)|$ &=& $3^2$ &=& 9\\\\\n    $|Fix(g^3)|$ &=& $3^1$ &=& 3\\\\\n    $|Fix(g^4)|$ &=& $3^4$ &=& 81\\\\\n    $|Fix(g^5)|$ &=& $3^1$ &=& 3\\\\\n    $|Fix(g^6)|$ &=& $3^2$ &=& 9\\\\\n    $|Fix(g^7)|$ &=& $3^1$ &=& 3\\\\\n\\end{tabular}\n\\end{center}\n\nBy the Polya-Burnside theorem, the number of orbits (aka distinct paintings\nafter considering rotation) is $\\frac{1}{|G|}\\sum_{g \\in G} |Fix(g)|$, thus we\nhave $\\frac{1}{8}(6561 + 3 + 9 + 3 + 81 + 3 + 9 + 1) = $ 834 total ways to\npaint the octagon.\n\\end{proof}\n\n\n\\section{Thanksgiving Dinner}\n\\ProblemStatement{\nYour grandmother cooked a turkey, stuffng, cornbread, 2 distinguishable salads\n(Caesar and spinach) and 3 distinguishable desserts (pumpkin pie, chocolate\nmayhem cake, and sweet potato pie). You're allowed to eat or not eat any\nparticular of these 8 dishes (we assume you have infinite stomach space), but\nyou have to follow The Granny's Rule, which is that you cannot have any type of\ndessert if you do not eat at least one salad. How many ways of eating are there?\n(again, we do not care about the amount you are eating of each food, just\nwhether you eat it or not).  \n}\n\nThere are 200 possible ways of eating.\n\n\\begin{proof}\nAssume for a moment that only the 2 salads and 3 deserts existed. There would be 4\npossibilities for salad consumption and 8 possibilities for dessert consumption.\n3 of the 4 salad possibilities (the ones where at least one salad is eaten)\nallow any dessert possibility, while the last one (where no salad is eaten)\nallows only one desert possibility (the one where no desert is eaten). Thus we\nhave $3 \\times 8 + 1 \\times 1 = 25$ possible meals when we only consider salad\nand desert. There are no restrictions on the other courses, so for each of those\n25 valid salad-dessert combinations there are 8 possibilities for the\nother dishes, giving $8 \\times 25 = 200$ possible meals in total.\n\\end{proof}\n\n\n\\section{Thankfulness}\n\\ProblemStatement{\nWhat are you thankful for?\n}\n\nI'm thankful for my health and my family. It's been a good year and we've been\nvery fortunate. In particular my wife and I had a baby daughter in January and\nshe's happy and healthy, so I'm very thankful for her.\n\n\\section{Generating with Powers of Ten}\n\\ProblemStatement{\nShow with generating functions that every nonnegative integer has a unique\ndecimal expansion (think about what this means; consult earlier homework for\nhelp).\n}\n\n\\begin{proof}\nWe can represent the decimal expansions using this generating function:\n\n\\[\n\\prod_{i=0}^{\\infty} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right)\n\\]\n\nThe term where $i=0$ is the ones place, $i=1$ is the tens place, etc., while the 10 choices inside the parentheses represent the choices for that digit. In order to show that every nonnegative integer has a unique representation, we must show that \n\n\\[\n\\prod_{i=0}^{\\infty} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right) = 1 + x + x^2 + x^3 + \\dots\n\\]\n\nWe prove this by induction. Let $p(n)$ be the following statement:\n\n\\[\n\\prod_{i=0}^{n} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right) = 1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\n\\]\n\\\\\n$p(0)$ is the statement $(1 + x + x^2 + x^3 + \\dots + x^8 + x^9) = (1 + x + x^2 + x^3+ \\dots + x^8 + x^9)$, which is true. Next we must show that if $p(n)$ is true, $p(n+1)$ must also be true.\\\\\n\n\nMultiplying both sides of $p(n)$ by $(1 + x^{10^{n+1}} + x^{2\\times10^{n+1}} + \\dots + x^{8\\times10^{n+1}} + x^{9\\times10^{n+1}})$ gives:\n\n\\begin{align*}\n\\prod_{i=0}^{n+1} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right) = \n                    (1)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) + \\\\\n\\left(x^{       {10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{2\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{3\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{4\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{5\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{6\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{7\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{8\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\left(x^{9\\times{10^{n+1}}}\\right)\\left(1 + x + x^2 + x^3 + \\dots + x^{10^{n+1}-1}\\right) +\\\\\n\\end{align*}\nMultiplying through gives \n\\begin{align*}\n\\prod_{i=0}^{n+1} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right) = \n\\left(1 + x + x^2 + \\dots + x^{10^{n+1}-2} + x^{10^{n+1}-1}\\right) + \\\\\n\\left(x^{10^{n+1}} + x^{10^{n+1}+1} + x^{10^{n+1}+2} + \\dots + x^{10^{n+1} + x^{10^{n+1}-2}} + x^{10^{n+1} + x^{10^{n+1}-1}}\\right) +\\\\\n\\left(x^{2\\times10^{n+1}} + x^{2\\times10^{n+1}+1} + x^{2\\times10^{n+1}+2} + \\dots + x^{2\\times10^{n+1} + 10^{n+1}-2} + x^{2\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{3\\times10^{n+1}} + x^{3\\times10^{n+1}+1} + x^{3\\times10^{n+1}+2} + \\dots + x^{3\\times10^{n+1} + 10^{n+1}-2} + x^{3\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{4\\times10^{n+1}} + x^{4\\times10^{n+1}+1} + x^{4\\times10^{n+1}+2} + \\dots + x^{4\\times10^{n+1} + 10^{n+1}-2} + x^{4\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{5\\times10^{n+1}} + x^{5\\times10^{n+1}+1} + x^{5\\times10^{n+1}+2} + \\dots + x^{5\\times10^{n+1} + 10^{n+1}-2} + x^{5\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{6\\times10^{n+1}} + x^{6\\times10^{n+1}+1} + x^{6\\times10^{n+1}+2} + \\dots + x^{6\\times10^{n+1} + 10^{n+1}-2} + x^{6\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{7\\times10^{n+1}} + x^{7\\times10^{n+1}+1} + x^{7\\times10^{n+1}+2} + \\dots + x^{7\\times10^{n+1} + 10^{n+1}-2} + x^{7\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{8\\times10^{n+1}} + x^{8\\times10^{n+1}+1} + x^{8\\times10^{n+1}+2} + \\dots + x^{8\\times10^{n+1} + 10^{n+1}-2} + x^{8\\times10^{n+1} + 10^{n+1}-1}\\right) +\\\\\n\\left(x^{9\\times10^{n+1}} + x^{9\\times10^{n+1}+1} + x^{9\\times10^{n+1}+2} + \\dots + x^{9\\times10^{n+1} + 10^{n+1}-2} + x^{9\\times10^{n+1} + 10^{n+1}-1}\\right)\\\\\n\\end{align*}\n\nwhich can be simplified to \n\n\\[\n\\prod_{i=0}^{n+1} \\left(1 + x^{10^i} + x^{2\\times10^i} + \\dots + x^{8\\times10^i} + x^{9\\times10^i}\\right) = 1 + x + x^2 + x^3 + \\dots + x^{10^{n+2}-1}\n\\]\n\nSince this is $p(n+1)$, we have shown that if $p(n)$ is true then $p(n+1)$ must be true, which completes the inductive proof.\n\n\n\\end{proof}\n\n\\section{Majority Rules}\n\\ProblemStatement{\nSay $(2n + 1)$ people, including you, have a majority vote in a company for\nallowing or disallowing hats to be worn in the company. If you know everyone\nelse is going to vote uniformly randomly for \\say{yes} or \\say{no}, what is the\nprobability that your vote is \\say{critical}? (we define your vote to be\n\\say{critical} if after we fix everyone else's vote, you voting one way or\nother changes the result) (optional: with a computer, explore the probability\nthat your vote is critical for big $n$, or for there being 3 outcomes instead\nof 2)\n}\n\nThe probability that your vote is \\say{critical} is \n\\[\n    \\binom{2n}{n}\\left(\\frac{1}{2}\\right)^{2n}\n\\]\n\n\\begin{proof}\nFirst we observe that your vote is only critical if the other $2n$ votes\nare tied with $n$ voting yes and $n$ voting no. If they were not tied, there\nwould have to be at least $n+1$ votes on one side and at most $n-1$ votes on\nthe other, so your vote would not be critical since there is a difference of\ntwo. \n\nThere are $\\binom{2n}{n}$ ways to choose the $n$ yes votes from among the $2n$\ntotal votes. For each of those ways, the probability that it will occur is\n$(\\frac{1}{2})^n$ (the chance that all $n$ of the yes voters will vote yes)\ntimes $(\\frac{1}{2})^n$ (the chance that all $n$ of the no voters will vote\nno). This gives an overall probability of $\\binom{2n}{n}(\\frac{1}{2})^{2n}$\n\\end{proof}\n\n\\subsection*{Optional}\nHere's a Python program which generates $2n$ random votes and measures how often they are evenly split for large values of $n$:\n\\begin{center}\n\\begin{lstlisting}[language=Python]\n#!/usr/bin/env python3\nimport random\n\ndef is_close(n):\n    v = random.getrandbits(2*n)\n    return bin(v).count('1') == n\n\ndef p_close(n, trials):\n    return sum(is_close(n) for i in range(trials)) / trials\n\nfor exp in range(20):\n    n = 2**exp\n    trials = min(2**24, 2**(34-exp))\n    print(exp, n, trials, p_close(n, trials), sep='\\t')\n\\end{lstlisting}\n\\end{center}\n\n\\noindent Here's a table summarizing the output:\n\n\\begin{center}\n\\begin{tabular}{ lllr }\n\\hline\n    $n$ & Measured Probability & Predicted Probability & Trials Run\\\\\n\\hline\n$2^0    = 1     $ & 0.5001128315925598    & 0.5                 & 16777216 \\\\\n$2^1    = 2     $ & 0.37497973442077637   & 0.375               & 16777216 \\\\\n$2^2    = 4     $ & 0.2733776569366455    & 0.273438            & 16777216 \\\\\n$2^3    = 8     $ & 0.19642597436904907   & 0.196381            & 16777216 \\\\\n$2^4    = 16    $ & 0.13995373249053955   & 0.13995             & 16777216 \\\\\n$2^5    = 32    $ & 0.09931820631027222   & 0.0993468           & 16777216 \\\\\n$2^6    = 64    $ & 0.07034200429916382   & 0.0703861           & 16777216 \\\\\n$2^7    = 128   $ & 0.04979640245437622   & 0.0498191           & 16777216 \\\\\n$2^8    = 256   $ & 0.03525400161743164   & 0.0352446           & 16777216 \\\\\n$2^9    = 512   $ & 0.02493804693222046   & 0.02492780589297954 & 16777216 \\\\\n$2^{10} = 1024  $ & 0.017606258392333984  & 0.01762877240484652 & 16777216 \\\\\n$2^{11} = 2048  $ & 0.012477874755859375  & 0.0124661853637603  & 8388608  \\\\\n$2^{12} = 4096  $ & 0.008898258209228516  & 0.0088151932204816  & 4194304  \\\\\n$2^{13} = 8192  $ & 0.006194591522216797  & 0.0062333780167465  & 2097152  \\\\\n$2^{14} = 16384 $ & 0.004390716552734375  & 0.0044076974932754  & 1048576  \\\\\n$2^{15} = 32768 $ & 0.003177642822265625  & 0.0031167246762524  & 524288   \\\\\n$2^{16} = 65536 $ & 0.00229644775390625   & 0.0022038613571975  & 262144   \\\\\n$2^{17} = 131072$ & 0.00154876708984375   & 0.0015583667966430  & 131072   \\\\\n$2^{18} = 262144$ & 0.00140380859375      & 0.001101932254924   & 65536    \\\\\n$2^{19} = 524288$ & 0.000946044921875     & 0.000779183955637   & 32768    \\\\\n\\end{tabular}\n\\end{center}\n\n\\section{Time Spent \\& Thoughts}\n\nThis was a much easier problem set than usual. Problem \\#1 tests a hard to understand topic, but it's a very straightforward application of the topic, so it wasn't bad. The decimal problem was a huge pain just because of the volume of equations and making sure that I didn't have any typos in them. I enjoyed the optional part of problem 5, but the rest of the problem set wasn't very interesting. I spent about four hours doing this homework.\n\n\\end{document}\n", "meta": {"hexsha": "4c33e8d43565c99c06101ff00f7308d9e44b1d9f", "size": 19102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "math142_ps13.tex", "max_stars_repo_name": "dalves/combinatorics", "max_stars_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T14:26:36.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T14:26:36.000Z", "max_issues_repo_path": "math142_ps13.tex", "max_issues_repo_name": "dalves/combinatorics", "max_issues_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "math142_ps13.tex", "max_forks_repo_name": "dalves/combinatorics", "max_forks_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.7074235808, "max_line_length": 443, "alphanum_fraction": 0.6120301539, "num_tokens": 7897, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4470139366204624}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\title{A \\REDUCE{} package for the computation of several matrix \nnormal forms}\n\\author{Matt Rebbeck \\\\ \nKonrad-Zuse-Zentrum f\\\"ur Informationstechnik Berlin \\\\\nTakustra\\\"se 7  \\\\\nD--14195 Berlin -- Dahlem \\\\\nFederal Republic of Germany \\\\[0.05in]\nE--mail: neun@zib.de \\\\[0.05in]\n}\n\\date{February 1994}\n\\begin{document}\n\\maketitle\n\\index{NORMFORM package}\n\n\n\\section{Introduction}\nWhen are two given matrices similar? Similar matrices have the same\ntrace, determinant, \\hspace{0in} characteristic polynomial, \n\\hspace{0in} and eigenvalues, \\hspace{0in} but the matrices \n\\begin{displaymath}\n\\begin{array}{ccc} {\\cal U} = \\left( \\begin{array}{cc} 0 & 1 \\\\ 0 & \n0 \\end{array} \\right) & $and$ & {\\cal V} = \\left( \\begin{array}{cc} \n0 & 0 \\\\ 0 & 0 \\end{array} \\right) \\end{array} \n\\end{displaymath}\nare the same in all four of the above but are not similar. Otherwise \nthere could exist a nonsingular ${\\cal N} {\\in} M_{2}$ (the set of \nall $2 \\times 2$ matrices) such that ${\\cal U} = {\\cal N} \\, {\\cal V}\n\\, {\\cal N}^{-1} = {\\cal N} \\, {\\it 0} \\, {\\cal N}^{-1} = {\\it 0}$, \nwhich is a contradiction since ${\\cal U} \\neq {\\it 0}$.\n\nTwo matrices can look very different but still be similar. One \napproach to determining whether two given matrices are similar is to \ncompute the normal form of them. If both matrices reduce to the same \nnormal form they must be similar.\n\n{\\small NORMFORM} is a package for computing the following normal \nforms of matrices:\n\n\\begin{verbatim}\n - smithex\n - smithex_int\n - frobenius\n - ratjordan\n - jordansymbolic\n - jordan\n\\end{verbatim}\n \nThe package is loaded by {\\tt load\\_package normform;}\n\nBy default all calculations are carried out in {\\cal Q} (the rational \nnumbers). For {\\tt smithex}, {\\tt frobenius}, {\\tt ratjordan}, \n{\\tt jordansymbolic}, and {\\tt jordan}, this field can be extended. \nDetails are given in the respective sections.\n\nThe {\\tt frobenius}, {\\tt ratjordan}, and {\\tt jordansymbolic} normal \nforms can also be computed in a modular base. Again, details are given \nin the respective sections.\n\nThe algorithms for each routine are contained in the source code.\n\n{\\small NORMFORM} has been converted from the normform and Normform \npackages written by T.M.L. Mulders and A.H.M. Levelt. These have been \nimplemented in Maple [4].\n\n\n\\section{smithex}\n\n\\subsection{function}\n\n{\\tt smithex}(${\\cal A},\\, x$) computes the Smith normal form ${\\cal S}$\nof the matrix ${\\cal A}$.\n\nIt returns \\{${\\cal S}, {\\cal P}, {\\cal P}^{-1}$\\} where ${\\cal S}, \n{\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P S P}^{-1} = \n{\\cal A}$.\n\n${\\cal A}$ is a rectangular matrix of univariate polynomials in $x$.\n\n$x$ is the variable name.\n\n\\subsection{field extensions}\n\nCalculations are performed in ${\\cal Q}$. To extend this field the \n{\\small ARNUM} package can be used. For details see {\\it section} 8.\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item The Smith normal form ${\\cal S}$ of an n by m matrix ${\\cal A}$ \nwith univariate polynomial entries in $x$ over a field {\\it F} is \ncomputed. That is, the polynomials are then regarded as elements of the\n{\\it E}uclidean domain {\\it F}($x$).\n\n\\item The Smith normal form is a diagonal matrix ${\\cal S}$ where:\n\n  \\begin{itemize}\n  \\item rank(${\\cal A}$) = number of nonzero rows (columns) of \n        ${\\cal S}$.\n  \\item ${\\cal S}(i,\\, i)$ is a monic polynomial for 0 $< i \\leq $\n        rank(${\\cal A}$).\n  \\item ${\\cal S}(i,\\, i)$ divides ${\\cal S}(i+1,\\, i+1)$ for 0 $< i\n        <$ rank(${\\cal A}$).\n  \\item ${\\cal S}(i,\\,i)$ is the greatest common divisor of all $i$ by \n        $i$ minors of ${\\cal A}$.\n  \\end{itemize}\n\n      Hence, if we have the case that $n = m$, as well as \n      rank(${\\cal A}$) $= n$, then product (${\\cal S}(i,\\,i), \n      i=1\\ldots n$) = det(${\\cal A}$) / lcoeff(det$({\\cal A}), \\, x$).\n\n\\item The Smith normal form is obtained by doing elementary row and \n      column operations. This includes interchanging rows (columns),\n      multiplying through a row (column) by $-1$, and adding integral \n      multiples of one row (column) to another.\n\n\\item Although the rank and determinant can be easily obtained from \n      ${\\cal S}$, this is not an efficient method for computing these \n      quantities except that this may yield a partial factorization of \n      det(${\\cal A}$) without doing any explicit factorizations.\n\n\\end{itemize}\n\n\\subsection{example}\n\n{\\tt load\\_package normform;}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cc} x & x+1 \\\\ 0 & 3*x^2 \\end{array} \n\\right)\n\\end{displaymath}\n\n\\begin{displaymath}\n\\hspace{-0.5in}\n\\begin{array}{ccc}\n{\\tt smithex}({\\cal A},\\, x) & = & \n\\left\\{ \\left( \\begin{array}{cc} 1 & 0 \\\\ \n0 & x^3 \\end{array} \\right), \\left( \\begin{array}{cc} 1 & 0 \\\\ 3*x^2 \n& 1 \\end{array} \\right), \\left( \\begin{array}{cc} x & x+1 \\\\ -3 & -3 \n\\end{array} \\right) \\right\\} \\end{array}\n\\end{displaymath}\n\n\n\\section{smithex\\_int}\n\n\\subsection{function}\n\nGiven an $n$ by $m$ rectangular matrix ${\\cal A}$ that contains \n{\\it only} integer entries, {\\tt smithex\\_int}(${\\cal A}$) computes the\nSmith normal form ${\\cal S}$ of ${\\cal A}$.\n\nIt returns \\{${\\cal S}, {\\cal P}, {\\cal P}^{-1}$\\} where ${\\cal S}, \n{\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P S P}^{-1} = \n{\\cal A}$.\n\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item The Smith normal form ${\\cal S}$ of an $n$ by $m$ matrix \n${\\cal A}$ with integer entries is computed.\n\n\\item The Smith normal form is a diagonal matrix ${\\cal S}$ where:\n\n  \\begin{itemize}\n  \\item rank(${\\cal A}$) = number of nonzero rows (columns) of \n        ${\\cal S}$.\n  \\item sign(${\\cal S}(i,\\, i)$) = 1 for 0 $< i \\leq $ rank(${\\cal A}$).\n  \\item ${\\cal S}(i,\\, i)$ divides ${\\cal S}(i+1,\\, i+1)$ for 0 $< i\n        <$ rank(${\\cal A}$).\n  \\item ${\\cal S}(i,\\,i)$ is the greatest common divisor of all $i$ by \n        $i$ minors of ${\\cal A}$.\n  \\end{itemize}\n\n      Hence, if we have the case that $n = m$, as well as \n      rank(${\\cal A}$) $= n$, then abs(det(${\\cal A}$)) = \n      product(${\\cal S}(i,\\,i),i=1\\ldots n$).\n      \n\\item The Smith normal form is obtained by doing elementary row and \n      column operations. This includes interchanging rows (columns),\n      multiplying through a row (column) by $-1$, and adding integral \n      multiples of one row (column) to another. \n\\end{itemize}\n\n\\subsection{example}\n\n{\\tt load\\_package normform;}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{ccc} 9 & -36 & 30 \\\\ -36 & 192 & -180 \\\\\n30 & -180 & 180  \\end{array} \n\\right)\n\\end{displaymath}\n\n{\\tt smithex\\_int}(${\\cal A}$) = \n\\begin{center}\n\\begin{displaymath}\n\\left\\{ \\left( \\begin{array}{ccc} 3 & 0 & 0 \\\\ 0 & 12 & 0 \\\\ 0 & 0 & 60 \n\\end{array} \\right), \\left( \\begin{array}{ccc} -17 & -5 & -4 \\\\ 64 & 19 \n& 15 \\\\ -50 & -15 & -12 \\end{array} \\right), \\left( \\begin{array}{ccc} \n1 & -24 & 30 \\\\ -1 & 25 & -30 \\\\ 0 & -1 & 1 \\end{array} \\right) \\right\\}\n\\end{displaymath}\n\\end{center}\n\n\n\\section{frobenius}\n\n\\subsection{function}\n\n{\\tt frobenius}(${\\cal A}$) computes the Frobenius normal form \n${\\cal F}$ of the matrix ${\\cal A}$.\n\nIt returns \\{${\\cal F}, {\\cal P}, {\\cal P}^{-1}$\\} where ${\\cal F}, \n{\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P F P}^{-1} = \n{\\cal A}$.\n\n${\\cal A}$ is a square matrix.\n\n\\subsection{field extensions}\n\nCalculations are performed in ${\\cal Q}$. To extend this field the \n{\\small ARNUM} package can be used. For details see {\\it section} 8.\n\n\\subsection{modular arithmetic}\n\n{\\tt frobenius} can be calculated in a modular base. For details see \n{\\it section} 9.\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item ${\\cal F}$ has the following structure:\n      \\begin{displaymath}\n      {\\cal F} = \\left( \\begin{array}{cccc} {\\cal C}{\\it p_{1}} &  &  & \n      \\\\  & {\\cal C}{\\it p_{2}} &  &  \\\\  &  & \\ddots &  \\\\  &  &  & \n      {\\cal C}{\\it p_{k}} \\end{array} \\right) \n      \\end{displaymath}\n      where the ${\\cal C}({\\it p_{i}})$'s are companion matrices \n      associated with polynomials ${\\it p_{1}, p_{2}},\\ldots, \n      {\\it p_{k}}$, with the property that ${\\it p_{i}}$ divides \n      ${\\it p_{i+1}}$ for $i =1\\ldots k-1$. All unmarked entries are \n      zero.\n\n\\item The Frobenius normal form defined in this way is unique (ie: if \n      we require that ${\\it p_{i}}$ divides ${\\it p_{i+1}}$ as above).\n\\end{itemize}\n \n\\subsection{example}\n\n{\\tt load\\_package normform;}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cc} \\frac{-x^2+y^2+y}{y} & \n\\frac{-x^2+x+y^2-y}{y} \\\\ \\frac{-x^2-x+y^2+y}{y} & \\frac{-x^2+x+y^2-y}\n{y} \\end{array} \\right)\n\\end{displaymath}\n\n{\\tt frobenius}(${\\cal A}$) = \n\\begin{center}\n\\begin{displaymath}\n\\left\\{ \\left( \\begin{array}{cc} 0 & \\frac{x*(x^2-x-y^2+y)}{y} \\\\ 1 & \n\\frac{-2*x^2+x+2*y^2}{y} \\end{array} \\right), \\left( \\begin{array}{cc}\n1 & \\frac{-x^2+y^2+y}{y} \\\\ 0 & \\frac{-x^2-x+y^2+y}{y} \\end{array} \n\\right), \\left( \\begin{array}{cc} 1 & \\frac{-x^2+y^2+y}{x^2+x-y^2-y} \\\\\n0 & \\frac{-y}{x^2+x-y^2-y} \\end{array} \\right) \\right\\}\n\\end{displaymath}\n\\end{center}\n\n\n\\section{ratjordan}\n\n\\subsection{function}\n\n{\\tt ratjordan}(${\\cal A}$) computes the rational Jordan normal form \n${\\cal R}$ of the matrix ${\\cal A}$.\n\nIt returns \\{${\\cal R}, {\\cal P}, {\\cal P}^{-1}$\\} where ${\\cal R}, \n{\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P R P}^{-1} = \n{\\cal A}$.\n\n${\\cal A}$ is a square matrix.\n\n\\subsection{field extensions}\n\nCalculations are performed in ${\\cal Q}$. To extend this field the \n{\\small ARNUM} package can be used. For details see {\\it section} 8.\n\n\\subsection{modular arithmetic}\n\n{\\tt ratjordan} can be calculated in a modular base. For details see \n{\\it section} 9.\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item ${\\cal R}$ has the following structure:\n      \\begin{displaymath}\n      {\\cal R} = \\left( \\begin{array}{cccccc} {\\it r_{11}} \\\\  & \n      {\\it r_{12}} \\\\  &  & \\ddots \\\\  &  &  & {\\it r_{21}}  \\\\ &  &  \n      &  & {\\it r_{22}} \\\\ &  &  &  &  & \\ddots \\end{array} \\right) \n      \\end{displaymath}\n\n      The ${\\it r_{ij}}$'s have the following shape:  \n      \\begin{displaymath}\n      {\\it r_{ij}} = \\left( \\begin{array}{ccccc} {\\cal C}({\\it p}) & \n      {\\cal I}  &  &  & \\\\  &  {\\cal C}({\\it p}) & {\\cal I}  & & \\\\ & \n      & \\ddots & \\ddots & \\\\ &  &  &  {\\cal C}({\\it p}) & {\\cal I} \\\\ &\n      &  &  & {\\cal C}({\\it p}) \\end{array} \\right) \n      \\end{displaymath}\n\n      where there are e${\\it ij}$ times ${\\cal C}({\\it p})$ blocks \n      along the diagonal and ${\\cal C}({\\it p})$ is the companion \n      matrix  associated with the irreducible polynomial ${\\it p}$. All \n      unmarked entries are zero.\n\\end{itemize}\n\n\\subsection{example}\n\n{\\tt load\\_package normform;}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cc} x+y & 5 \\\\ y & x^2  \\end{array} \n\\right)\n\\end{displaymath}\n\n{\\tt ratjordan}(${\\cal A}$) = \n\\begin{center}\n\\begin{displaymath}\n\\left\\{ \\left( \\begin{array}{cc} 0 & -x^3-x^2*y+5*y \\\\ 1 & \nx^2+x+y \\end{array} \\right), \\left( \\begin{array}{cc}\n1 & x+y \\\\ 0 & y \\end{array} \\right), \\left( \\begin{array}{cc} 1 & \n\\frac{-(x+y)}{y} \\\\ 0 & \\hspace{0.2in} \\frac{1}{y} \\end{array} \\right) \n\\right\\}\n\\end{displaymath}\n\\end{center}\n\n\n\\section{jordansymbolic}\n\n\\subsection{function}\n\n{\\tt jordansymbolic}(${\\cal A}$) \\hspace{0in} computes the Jordan \nnormal form ${\\cal J}$of the matrix ${\\cal A}$.\n\nIt returns \\{${\\cal J}, {\\cal L}, {\\cal P}, {\\cal P}^{-1}$\\}, where \n${\\cal J}, {\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P J P}^\n{-1} = {\\cal A}$. ${\\cal L}$ = \\{ {\\it ll} , $\\xi$ \\}, where $\\xi$ is \na name and {\\it ll} is a list of irreducible factors of ${\\it p}(\\xi)$.\n\n${\\cal A}$ is a square matrix.\n\n\\subsection{field extensions}\n\nCalculations are performed in ${\\cal Q}$. To extend this field the \n{\\small ARNUM} package can be used. For details see {\\it section} 8.\n\n\\subsection{modular arithmetic}\n\n{\\tt jordansymbolic} can be calculated in a modular base. For details \nsee {\\it section} 9.\n\n\\subsection{extras}\n\nIf using {\\tt xr}, the X interface for \\REDUCE, the appearance of the \noutput can be improved by switching {\\tt on looking\\_good;}. This \nconverts all lambda to $\\xi$ and improves the indexing, eg: lambda12 \n$\\Rightarrow \\xi_{12}$. The example ({\\it section} 6.6) shows the \noutput when this switch is on.\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item A {\\it Jordan block} ${\\jmath}_{k}(\\lambda)$ is a $k$ by $k$ \n      upper triangular matrix of the form:\n\n      \\begin{displaymath}\n      {\\jmath}_{k}(\\lambda) = \\left( \\begin{array}{ccccc} \\lambda & 1 \n      &  &  & \\\\  &  \\lambda & 1  & & \\\\ & \n      & \\ddots & \\ddots & \\\\ &  &  &  \\lambda & 1 \\\\ &\n      &  &  & \\lambda \\end{array} \\right) \n      \\end{displaymath}\n      \n      There are $k-1$ terms ``$+1$'' in the superdiagonal; the scalar \n      $\\lambda$ appears $k$ times on the main diagonal. All other \n      matrix entries are zero, and ${\\jmath}_{1}(\\lambda) = (\\lambda)$.\n\n\\item A Jordan matrix ${\\cal J} \\in M_{n}$ (the set of all $n$ by $n$ \n      matrices) is a direct sum of {\\it jordan blocks}.\n\n      \\begin{displaymath}\n      {\\cal J} = \\left( \\begin{array}{cccc} \\jmath_{n_1}(\\lambda_{1}) \n      \\\\  & \\jmath_{n_2}(\\lambda_{2}) \\\\ & & \\ddots \\\\ & & & \n      \\jmath_{n_k}(\\lambda_{k}) \\end{array} \\right),\n      {\\it n}_{1}+{\\it n}_{2}+\\cdots +{\\it n}_{k} = n\n      \\end{displaymath}\n\n      in which the orders ${\\it n}_{i}$ may not be distinct and the \n      values ${\\lambda_{i}}$ need not be distinct.\n\n\\item Here ${\\lambda}$ is a zero of the characteristic polynomial \n      ${\\it p}$ of ${\\cal A}$. If ${\\it p}$ does not split completely, \n      symbolic names are chosen for the missing zeroes of ${\\it p}$.\n      If, by some means, one knows such missing zeroes, they can be \n      substituted for the symbolic names. For this, \n      {\\tt jordansymbolic} actually returns $\\{ {\\cal J,L,P,P}^{-1} \\}$.\n      ${\\cal J}$ is the Jordan normal form of ${\\cal A}$ (using \n      symbolic names if necessary). ${\\cal L} = \\{ {\\it ll}, \\xi \\}$, \n      where $\\xi$ is a name and ${\\it ll}$ is a list of irreducible \n      factors of ${\\it p}(\\xi)$. If symbolic names are used then \n      ${\\xi}_{ij}$ is a zero of ${\\it ll}_{i}$. ${\\cal P}$ and \n      ${\\cal P}^{-1}$ are as above.\n\\end{itemize}      \n\n\\subsection{example}\n\n{\\tt load\\_package normform;}\\\\\n{\\tt on looking\\_good;} \n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cc} 1 & y \\\\ y^2 & 3  \\end{array} \n\\right)\n\\end{displaymath}\n\n{\\tt jordansymbolic}(${\\cal A}$) = \n\\begin{eqnarray}\n & & \\left\\{ \\left( \\begin{array}{cc} \\xi_{11} & 0 \\\\ 0 & \\xi_{12}\n\\end{array} \\right) ,\n\\left\\{ \\left\\{ -y^3+\\xi^2-4*\\xi+3 \\right\\}, \\xi \\right\\}, \\right. \n\\nonumber \\\\ & & \\hspace{0.1in} \\left. \\left( \\begin{array}{cc} \n\\xi_{11} -3 & \\xi_{12} -3 \\\\ y^2 & y^2 \n\\end{array} \\right), \\left( \\begin{array}{cc} \\frac{\\xi_{11} -2}\n{2*(y^3-1)} & \\frac{\\xi_{11} + y^3 -1}{2*y^2*(y^3+1)} \\\\ \n\\frac{\\xi_{12} -2}{2*(y^3-1)} & \\frac{\\xi_{12}+y^3-1}{2*y^2*(y^3+1)}\n\\end{array} \\right) \\right\\} \\nonumber\n\\end{eqnarray}\n\n\\vspace{0.2in}\n\\begin{flushleft}\n\\begin{math}\n{\\tt solve(-y^3+xi^2-4*xi+3,xi)}${\\tt ;}$\n\\end{math}\n\\end{flushleft}\n\n\\vspace{0.1in}\n\\begin{center}\n\\begin{math}\n\\{ \\xi = \\sqrt{y^3+1} + 2,\\, \\xi = -\\sqrt{y^3+1}+2 \\}\n\\end{math}\n\\end{center}\n\n\\vspace{0.1in}\n\\begin{math}\n{\\tt {\\cal J}  = sub}{\\tt (}{\\tt \\{ xi(1,1)=sqrt(y^3+1)+2,\\, xi(1,2) = \n-sqrt(y^3+1)+2\\},} \n\\end{math}\n\\\\ \\hspace*{0.29in} {\\tt first  jordansymbolic (${\\cal A}$));} \n \n\\vspace{0.2in}\n\\begin{displaymath}\n{\\cal J} = \\left( \\begin{array}{cc} \\sqrt{y^3+1} + 2 & 0 \\\\ 0 & \n-\\sqrt{y^3+1} + 2 \\end{array} \\right)\n\\end{displaymath}\n\n\\vspace{0.2in}\nFor a similar example ot this in standard {\\REDUCE} (ie: not using \n{\\tt xr}), see the {\\it normform.log} file.\n\n\\vspace{0.5in}\n\n\\section{jordan}\n\n\\subsection{function}\n\n{\\tt jordan}(${\\cal A}$) computes the Jordan normal form \n${\\cal J}$ of the matrix ${\\cal A}$.\n\nIt returns \\{${\\cal J}, {\\cal P}, {\\cal P}^{-1}$\\}, where \n${\\cal J}, {\\cal P}$, and ${\\cal P}^{-1}$ are such that ${\\cal P J P}^\n{-1} = {\\cal A}$. \n\n${\\cal A}$ is a square matrix.\n\n\\subsection{field extensions}\n\nCalculations are performed in ${\\cal Q}$. To extend this field the \n{\\small ARNUM} package can be used. For details see {\\it section} 8.\n\n\\subsection{note}\nIn certain polynomial cases {\\tt fullroots} is turned on to compute the \nzeroes. This can lead to the calculation taking a long time, as well as \nthe output being very large. In this case a message {\\tt ***** WARNING: \nfullroots turned on. May take a while.} will be printed. It may be \nbetter to kill the calculation and compute {\\tt jordansymbolic} instead.\n\n\\subsection{synopsis}\n\n\\begin{itemize}\n\\item The Jordan normal form ${\\cal J}$ with entries in an algebraic \n      extension of ${\\cal Q}$ is computed.\n\n\\item A {\\it Jordan block} ${\\jmath}_{k}(\\lambda)$ is a $k$ by $k$ \n      upper triangular matrix of the form:\n\n      \\begin{displaymath}\n      {\\jmath}_{k}(\\lambda) = \\left( \\begin{array}{ccccc} \\lambda & 1 \n      &  &  & \\\\  &  \\lambda & 1  & & \\\\ & \n      & \\ddots & \\ddots & \\\\ &  &  &  \\lambda & 1 \\\\ &\n      &  &  & \\lambda \\end{array} \\right) \n      \\end{displaymath}\n      \n      There are $k-1$ terms ``$+1$'' in the superdiagonal; the scalar \n      $\\lambda$ appears $k$ times on the main diagonal. All other \n      matrix entries are zero, and ${\\jmath}_{1}(\\lambda) = (\\lambda)$.\n\n\\item A Jordan matrix ${\\cal J} \\in M_{n}$ (the set of all $n$ by $n$ \n      matrices) is a direct sum of {\\it jordan blocks}.\n\n      \\begin{displaymath}\n      {\\cal J} = \\left( \\begin{array}{cccc} \\jmath_{n_1}(\\lambda_{1}) \n      \\\\  & \\jmath_{n_2}(\\lambda_{2}) \\\\ & & \\ddots \\\\ & & & \n      \\jmath_{n_k}(\\lambda_{k}) \\end{array} \\right),\n      {\\it n}_{1}+{\\it n}_{2}+\\cdots +{\\it n}_{k} = n\n      \\end{displaymath}\n\n      in which the orders ${\\it n}_{i}$ may not be distinct and the \n      values ${\\lambda_{i}}$ need not be distinct.\n\n\\item Here ${\\lambda}$ is a zero of the characteristic polynomial \n      ${\\it p}$ of ${\\cal A}$. The zeroes of the characteristic \n      polynomial are computed exactly, if possible. Otherwise they are \n      approximated by floating point numbers.\n\\end{itemize}      \n\n\\subsection{example}\n\n{\\tt load\\_package normform;}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cccccc} -9 & -21 & -15 & 4 & 2 & 0 \\\\\n-10 & 21 & -14 & 4 & 2 & 0 \\\\ -8 & 16 & -11 & 4 & 2 & 0 \\\\ -6 & 12 & -9 \n& 3 & 3 & 0 \\\\ -4 & 8 & -6 & 0 & 5 & 0 \\\\ -2 & 4 & -3 & 0 & 1 & 3 \n\\end{array} \\right)\n\\end{displaymath}\n\n\\begin{flushleft}\n{\\tt ${\\cal J}$ = first jordan$({\\cal A})$;}\n\\end{flushleft}\n  \n\\begin{displaymath}\n{\\cal J} = \\left( \\begin{array}{cccccc} 3 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 3 \n& 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & i+2 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & -i+2 \n\\end{array} \\right)\n\\end{displaymath}\n\n\\newpage\n\n\n\\section{arnum}\n\nThe package is loaded by {\\tt load\\_package arnum;}. The algebraic \nfield ${\\cal Q}$ can now be extended. For example, {\\tt defpoly \nsqrt2**2-2;} will extend it to include ${\\sqrt{2}}$ (defined here by \n{\\tt sqrt2}). The {\\small ARNUM} package was written by Eberhard \nSchr\\\"ufer and is described in the {\\it arnum.tex} file.\n\n\\subsection{example}\n\n{\\tt load\\_package normform;} \\\\\n{\\tt load\\_package arnum;} \\\\\n{\\tt defpoly sqrt2**2-2;} \\\\\n(sqrt2 now changed to ${\\sqrt{2}}$ for looks!) \n\\vspace{0.2in}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{ccc} 4*{\\sqrt{2}}-6 & -4*{\\sqrt{2}}+7 &\n-3*{\\sqrt{2}}+6 \\\\ 3*{\\sqrt{2}}-6 & -3*{\\sqrt{2}}+7 & -3*{\\sqrt{2}}+6 \n\\\\ 3*{\\sqrt{2}} & 1-3*{\\sqrt{2}} & -2*{\\sqrt{2}}   \\end{array} \\right)\n\\end{displaymath} \n\\vspace{0.2in}\n\n\\begin{eqnarray}\n{\\tt ratjordan}({\\cal A}) & = & \n\\left\\{ \\left( \\begin{array}{ccc} {\\sqrt{2}} & 0 & 0 \\\\ 0 & {\\sqrt{2}} \n& 0 \\\\ 0 & 0 & -3*{\\sqrt{2}}+1 \\end{array} \\right), \\right. \\nonumber \n\\\\ & & \\hspace{0.1in} \\left. \\left( \\begin{array}{ccc} 7*{\\sqrt{2}}-6 \n& \\frac{2*{\\sqrt{2}}-49}{31} & \\frac{-21*{\\sqrt{2}}+18}{31} \\\\ \n3*{\\sqrt{2}}-6 & \\frac{21*{\\sqrt{2}}-18}{31} & \\frac{-21*{\\sqrt{2}}+18}\n{31} \\\\ 3*{\\sqrt{2}}+1 & \\frac{-3*{\\sqrt{2}}+24}{31} & \n\\frac{3*{\\sqrt{2}}-24}{31} \\end{array} \\right), \\right. \\nonumber \\\\ & \n& \\hspace{0.1in} \\left. \\left( \\begin{array}{ccc} 0 & {\\sqrt{2}}+1 & \n1 \\\\ -1 & 4*{\\sqrt{2}}+9 & 4*{\\sqrt{2}} \\\\ -1 & -\\frac{1}{6}*{\\sqrt{2}}\n+1 & 1 \\end{array} \\right) \\right\\} \\nonumber \n\\end{eqnarray}\n\n\\newpage\n\n\n\\section{modular}\n\nCalculations can be performed in a modular base by switching {\\tt on \nmodular;}. The base can then be set by {\\tt setmod p;} (p a prime). The \nnormal form will then have entries in ${\\cal Z}/$p${\\cal Z}$. \n\nBy also switching {\\tt on balanced\\_mod;} the output will be shown using\na symmetric modular representation. \n\nInformation on this modular manipulation can be found in {\\it chapter} \n9 (Polynomials and Rationals) of the {\\REDUCE}  User's Manual [5].\n\n\\subsection{example}\n\n{\\tt load\\_package normform;} \\\\\n{\\tt on modular;} \\\\\n{\\tt setmod 23;} \n\\vspace{0.1in}\n\n\\begin{displaymath}\n{\\cal A} = \\left( \\begin{array}{cc} 10 & 18 \\\\ 17 & 20 \\end{array} \n\\right)\n\\end{displaymath}\n\n{\\tt jordansymbolic}(${\\cal A}$) = \n\\begin{center}\n\\begin{displaymath}\n\\left\\{ \\left( \\begin{array}{cc} 18 & 0 \\\\ 0 & 12 \\end{array} \\right),\n\\left\\{ \\left\\{ \\lambda + 5, \\lambda + 11  \\right\\}, \\lambda \\right\\}, \n\\left( \\begin{array}{cc} 15 & 9 \\\\ 22 & 1 \\end{array} \\right), \\left( \n\\begin{array}{cc} 1 & 14 \\\\ 1 & 15 \\end{array} \\right) \\right\\}\n\\end{displaymath}\n\\end{center}\n\\vspace{0.2in}\n\n{\\tt on balanced\\_mod;}\n\\vspace{0.2in}\n\n{\\tt jordansymbolic}(${\\cal A}$) = \n\\begin{center}\n\\begin{displaymath}\n\\left\\{ \\left( \\begin{array}{cc} -5 & 0 \\\\ 0 & -11 \\end{array} \\right),\n\\left\\{ \\left\\{ \\lambda + 5, \\lambda + 11  \\right\\}, \\lambda \\right\\}, \n\\left( \\begin{array}{cc} -8 & 9 \\\\ -1 & 1 \\end{array} \\right), \\left( \n\\begin{array}{cc} 1 & -9 \\\\ 1 & -8 \\end{array} \\right) \\right\\}\n\\end{displaymath}\n\\end{center}\n\n\\newpage\n\\begin{thebibliography}{6}\n\\bibitem{MulLev} T.M.L.Mulders and A.H.M. Levelt: {\\it The Maple \n        normform and Normform packages.} (1993)\n\\bibitem{Mulders} T.M.L.Mulders: {\\it Algoritmen in De Algebra, A \n        Seminar on Algebraic Algorithms, Nigmegen.} (1993)\n\\bibitem{HoJo} Roger A. Horn and Charles A. Johnson: {\\it Matrix \n        Analysis.} Cambridge University Press (1990)\n\\bibitem{Maple} Bruce W. Chat\\ldots [et al.]: {\\it Maple (Computer \n        Program)}. Springer-Verlag (1991)\n\\bibitem{Reduce} Anthony C. Hearn: {\\REDUCE} {\\it User's Manual 3.6.}\n\tRAND (1995)\n\\end{thebibliography}\n\n\\end{document}\n\n", "meta": {"hexsha": "0cfea4cdac47f0da06c1a60152d95a8be82d53c1", "size": 22450, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/normform/normform.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/normform/normform.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/normform/normform.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8612368024, "max_line_length": 72, "alphanum_fraction": 0.6005790646, "num_tokens": 8081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.44695603639642967}}
{"text": "\\documentclass[aspectratio=169]{beamer}\n\\input{../util/beamerpreamble.tex}\n\n\\title[GB13604]{GB13604 - Maths for Computer Science}\n\\subtitle[]{Lecture 3 -- Number Theory}\n\\author[Claus Aranha]{Claus Aranha\\\\{\\footnotesize caranha@cs.tsukuba.ac.jp}}\n\\institute[COINS]{College of Information Science}\n\\date[2020-10-21]{2020-10-21\\\\{\\tiny Last updated \\today}}\n\n\\begin{document}\n\n\n\\begin{frame}\n  \\maketitle\n\n  \\begin{columns}\n    \\column{0.8\\textwidth}\n    {\\smaller This course is based on Mathematics for Computer Science, Spring\n    2015, by Albert Meyer and Adam Chlipala, Massachusetts Institute\n    of Technology OpenCourseWare.}\n    \\column{0.2\\textwidth}\n    \\includegraphics[width=\\textwidth]{../img/by-nc-sa}\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}{Lecture Outline}\n\n  Number Theory: From division to the RSA algorithm (textbook chapter 8).\\bigskip\n\n  \\begin{itemize}\n    \\item Division and the Greatest Common Divisor (GCD);\n    \\item Primality, and simple cryptography;\n    % First part of Turing crypto here\n    \\item Modular Arithmetic, and Euler's theorem;\n    % Second part of Turing crypto here\n    \\item The RSA public key algorithm;\n  \\end{itemize}\\bigskip\n\n  Let's get started!\n\\end{frame}\n\n\\input{01_Divisibility.tex}\n\\input{02_CommonDivisor.tex}\n\\input{03_Primality.tex}\n% Turing Code 1.0\n\\input{04_ModularArithmetic.tex}\n% Turing Code 2.0\n\\input{05_RSA.tex}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\\section{Conclusion}\n\n\\input{../util/lastslide.tex}\n\\end{document}\n", "meta": {"hexsha": "1e1b4947f4cc836adc706d011660700eb06de10d", "size": 1487, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week03/MathForCSW3.tex", "max_stars_repo_name": "caranha/MathCS", "max_stars_repo_head_hexsha": "f3ce6705d09c55541f629cd542191bfd3e9adf34", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-13T18:59:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-16T02:14:56.000Z", "max_issues_repo_path": "week03/MathForCSW3.tex", "max_issues_repo_name": "caranha/MathCS", "max_issues_repo_head_hexsha": "f3ce6705d09c55541f629cd542191bfd3e9adf34", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week03/MathForCSW3.tex", "max_forks_repo_name": "caranha/MathCS", "max_forks_repo_head_hexsha": "f3ce6705d09c55541f629cd542191bfd3e9adf34", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0877192982, "max_line_length": 81, "alphanum_fraction": 0.7141896436, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4467965279011981}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tkz-euclide, tikz, xcolor, pgfplots, array}\n\\usetkzobj{all}\n\\pgfplotsset{compat = 1.16}\n\\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}\n\\pgfplotsset{every axis/.append style = {axis lines = middle, axis line style = {<->}}}\n\\pgfplotsset{every tick label/.append style={font=\\tiny}}\n\\everymath{\\displaystyle}\n\n\\title{Trig Equations}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\maketitle\n\\end{frame}\n\n\\section{Solve trigonometric equations}\n\n\\begin{frame}{Trig Equations}\n    A \\alert{trigonometric equation} is one that contains a trig function with variable, such as $\\sin x = \\frac{1}{2}$.\n\\end{frame}\n\n\\begin{frame}{Trig Equations}\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{axis}[\nxmin = -5, xmax = 12,\nymin = -1.5, ymax = 1.5,\nxtick = {-3.67, 0.524, 2.618, 6.809, 8.901},\nxticklabels = {$-\\frac{7\\pi}{6}$, $\\frac{\\pi}{6}$, $\\frac{5\\pi}{6}$, $\\frac{13\\pi}{6}$, $\\frac{17\\pi}{6}$}\n]\n\\addplot [<->,>=stealth,very thick,domain=-4:10.5, samples = 300, smooth, blue] {sin(deg(x))}; \n\\addplot+ [<->, domain=-5:12, no marks, very thick] {0.5};\n\\addplot [color=blue, mark=*] coordinates {(-3.67,0.5) (0.524,0.5) (2.618,0.5) (6.809,0.5) (8.901,0.5)};\n\\end{axis}\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{General Form of Solutions}\nThe \\alert{general form} of this solution is\n\\[x = \\frac{\\pi}{6}+2\\pi n \\quad \\text{or} \\quad x = \\frac{5\\pi}{6} + 2\\pi n \\]   \n\nwhere $2\\pi$ is the \\alert{period} of the sine function.  \\newline\\\\  \\pause\n\nSince there are an infinite number of solutions, we will usually confine our answers to be between 0 and $2\\pi$.\n\\end{frame}\n\n\\begin{frame}{How to Solve a Trig Equation}\n    \\begin{enumerate}\n        \\item Get the trig function by itself, if possible.    \\newline\\\\\n        \\item Solve for the variable using inverse trig.\n    \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{Example 1}\nSolve each of the following in the interval $[0, 2\\pi)$.    \\newline\\\\\n(a) \\quad $\\cos(2x) = -\\frac{\\sqrt{3}}{2}$\n\\begin{align*}\n    \\onslide<2->{2x &= 150^\\circ + 360n & 2x &= 210 + 360n} \\\\[8pt]\n    \\onslide<3->{x &= 75^\\circ + 180n & x &= 105^\\circ + 180n} \\\\[8pt]\n    \\onslide<4->{x &= 75^\\circ, \\, 255^\\circ & x &= 105^\\circ, \\, 285^\\circ} \\\\[8pt]\n\\end{align*}\n\\onslide<5->{\n\\[ x = \\left\\{\\frac{5\\pi}{12}, \\, \\frac{7\\pi}{12}, \\, \\frac{17\\pi}{12}, \\, \\frac{19\\pi}{12} \\right\\} \\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $\\csc\\left(\\frac{1}{3}x-\\pi\\right) = \\sqrt{2}$\n\\begin{align*}\n    \\onslide<2->{\\frac{1}{3}x - 180^\\circ &= 45^\\circ + 360n & \\frac{1}{3}x - 180^\\circ &= 135^\\circ + 360n}   \\\\[8pt]\n    \\onslide<3->{\\frac{1}{3}x &= 225^\\circ + 360n & \\frac{1}{3}x &= 315^\\circ + 360n} \\\\[8pt]\n    \\onslide<4->{x &= 675^\\circ + 1080n & x &= 945^\\circ + 1080n} \\\\[8pt]\n\\end{align*}\n\\begin{center}\n    \\onslide<5->{No angles between 0 and $2\\pi$}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $\\cot(3x) = 0$\n\\begin{align*}\n    \\onslide<2->{3x &= 90^\\circ + 180n & 3x &= 270^\\circ + 180n} \\\\[8pt]\n    \\onslide<3->{x &= 30^\\circ + 60n & x &= 90^\\circ + 60n} \\\\[8pt]\n    \\onslide<4->{x &= 30^\\circ, 90^\\circ, 150^\\circ, 210^\\circ, 270^\\circ, 330^\\circ & x &= 90^\\circ, 150^\\circ, \\dots} \\\\\n\\end{align*}\n\\[ \\onslide<5->{x = \\left\\{\\frac{\\pi}{6}, \\, \\frac{\\pi}{2}, \\, \\frac{5\\pi}{6}, \\, \\frac{7\\pi}{6}, \\, \\frac{3\\pi}{2}, \\, \\frac{11\\pi}{6}\\right\\}} \\]\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(d) \\quad $\\sec^2 x = 4$\n\\begin{align*}\n    \\onslide<2->{\\sqrt{\\sec^2 x} &= \\pm\\sqrt{4} & &} \\\\[6pt]\n    \\onslide<3->{\\sec x &= 2 & \\sec x &= -2} \\\\[6pt]\n    \\onslide<4->{x &= 60^\\circ, 300^\\circ & x &= 120^\\circ, 240^\\circ} \n\\end{align*}\n\n\\onslide<5->{\\[ x = \\left\\{ \\frac{\\pi}{3}, \\frac{2\\pi}{3}, \\frac{4\\pi}{3}, \\frac{5\\pi}{3}\\right\\} \\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(e) \\quad $\\tan\\left(\\frac{x}{2}\\right) = -3$\n\\begin{align*}\n    \\onslide<2->{\\frac{x}{2} &= \\tan^{-1}(-3) + 180n & (\\arctan(-3) \\approx -143^\\circ)}    \\\\[12pt]\n    \\onslide<3->{x &= 2\\tan^{-1}(-3) + 360n & (2\\arctan(-3) \\approx -286^\\circ)} \\\\[12pt]\n    \\onslide<4->{x &= 2\\tan^{-1}(-3) + 360^\\circ} \\\\[12pt]\n    \\onslide<5->{x &= 2\\tan^{-1}(-3) + 2\\pi  &} \n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Using Algebraic Techniques and Trig Identities}\nThe following examples make use of trig identities and algebraic techniques to solve the equations.\n\\end{frame}\n\n\\begin{frame}{Example 2}\nSolve each in the interval $[0, 2\\pi)$  \\newline\\\\\n(a) \\quad $3\\sin^3 x = \\sin^2 x$\n\\begin{align*}\n    \\onslide<2->{3\\sin^3 x - \\sin^2 x &= 0 & &} \\\\[6pt]\n    \\onslide<3->{\\sin^2 x(3\\sin x - 1) &= 0 & &} \\\\[6pt]\n    \\onslide<4->{\\sin^2 x &= 0 & 3\\sin x - 1 &= 0} \\\\[6pt]\n    \\onslide<5->{\\sin x &= 0 & \\sin x = \\frac{1}{3}} \\\\[6pt]\n    \\onslide<6->{x &= 0, 180^\\circ & x &\\approx 19.471^\\circ, 160.529^\\circ} \n\\end{align*}\n\\[ \\onslide<7->{x = \\left\\{0, \\, \\arcsin\\left(\\frac{1}{3}\\right), \\, \\pi - \\arcsin\\left(\\frac{1}{3}\\right), \\, \\pi \\right\\}}\n\\]\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(b) \\quad $\\sec^2 x = \\tan x + 3$\n\\begin{align*}\n    \\onslide<2->{\\tan^2 x + 1 &= \\tan x + 3} \\\\[6pt]\n    \\onslide<3->{\\tan^2 x - \\tan x - 2 &= 0} \\\\[6pt]\n    \\onslide<4->{(\\tan x - 2)(\\tan x + 1) &= 0}\n\\end{align*}\n\\begin{align*}\n    \\onslide<5->{\\tan x - 2 &= 0 & \\tan x + 1 &= 0} \\\\\n    \\onslide<6->{\\tan x &= 2 & \\tan x &= -1}    \\\\\n    \\onslide<7->{x &\\approx 63.5^\\circ, 243.5^\\circ & x &= 135^\\circ, 315^\\circ} \n\\end{align*}\n\\[\n\\onslide<8->{x = \\left\\{\\arctan(2), \\, \\frac{3\\pi}{4}, \\, \\pi + \\arctan(2), \\, \\frac{7\\pi}{4} \\right\\}}\n\\]\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(c) \\quad $\\cos(2x) = 3\\cos x - 2$\n\\begin{align*}\n    \\onslide<2->{2\\cos^2 x - 1 &= 3\\cos x - 2} \\\\\n    \\onslide<3->{2\\cos^2 x - 3\\cos x + 1 &= 0} \\\\\n    \\onslide<4->{(2\\cos x - 1)(\\cos x - 1) &= 0}\n\\end{align*}\n\\begin{align*}\n    \\onslide<5->{2\\cos x - 1 &= 0 & \\cos x - 1 &= 0} \\\\\n    \\onslide<6->{\\cos x &= \\frac{1}{2} & \\cos x &= 1} \\\\[6pt]\n    \\onslide<7->{x &= 60^\\circ, 300^\\circ & x &= 0}\n\\end{align*}\n\n\\[\n\\onslide<8->{x = \\left\\{ 0, \\, \\frac{\\pi}{3}, \\, \\frac{5\\pi}{3} \\right\\}}\n\\]\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(d) \\quad $\\sin(2x) = \\sqrt{3}\\cos x$\n\\begin{align*}\n    \\onslide<2->{2\\sin x \\cos x &= \\sqrt{3}\\cos x} \\\\\n    \\onslide<3->{2\\sin x \\cos x - \\sqrt{3} \\cos x &= 0} \\\\\n    \\onslide<4->{\\cos x(2\\sin x - \\sqrt{3}) &= 0} \\\\\n\\end{align*}\n\\begin{align*}\n    \\onslide<5->{\\cos x &= 0 & 2\\sin x - \\sqrt{3} &= 0} \\\\\n    \\onslide<6->{x &= 90^\\circ, 270^\\circ & 2\\sin x &= \\sqrt{3}} \\\\\n    \\onslide<7->{& & \\sin x &= \\frac{\\sqrt{3}}{2}} \\\\[6pt]\n    \\onslide<8->{& & x &= 60^\\circ, 120^\\circ}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n    \\begin{align*}\n        x &= 60^\\circ, \\, 90^\\circ, \\, 120^\\circ, \\, 270^\\circ \\\\[12pt]\n        \\onslide<2->{x &= \\left\\{\\frac{\\pi}{3}, \\, \\frac{\\pi}{2}, \\, \\frac{2\\pi}{3}, \\, \\frac{3\\pi}{2} \\right\\}}\n    \\end{align*}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "5457af7c9edb16edcda69a98ae3ef23e22054045", "size": 7114, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Trig_Equations(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Trig_Equations(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Trig_Equations(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 35.2178217822, "max_line_length": 147, "alphanum_fraction": 0.5612876019, "num_tokens": 3085, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.4467965227981413}}
{"text": "% !TEX root = ../00_thesis.tex\n\n%-------------------------------------------------------------------------------\n\\section{Backgrounds on Statistics}\n\\label{sec:stats}\n%-------------------------------------------------------------------------------\n\nThis section briefly discusses some background on statistics which is relevant to performance evaluation.\n\n\\fakepar{Descriptive and predictive statistics}\nA statistic is a number computed from a data set using a mathematical formula.\nA statistic can always be calculated and provides a factual description of the underlying data.\nThis is referred to as a \\emph{descriptive statistic}.\nHowever, certain statistics have also some \\emph{inference} power; that is, based on the collected data, one may infer the shape of the underlying data distribution, which is unknown. These are referred to as \\emph{predictive statistics}.\n\nPredictions are always uncertain and often rely on certain hypotheses. If the hypotheses hold for the collected data, then the statistic estimates some property of the underlying distribution (\\eg mean, median, \\etc) with a quantifiable level of confidence. One can then predict the expected values of data samples that have not been collected.\nOne common hypothesis for predictive statistics is that the collected data is \\emph{independent and identically distributed} (\\iid); informally, this means that the underlying distribution of the data does not change and that successive data samples are not correlated.\nIt is also common to presume the \\emph{nature of the data distribution} (\\eg a normal or a Poisson distribution), which allows to make ``better'' predictions with less data.\nIt is paramount to keep in mind the hypotheses underlying a statistical prediction.\n\n\\begin{example}\n  One can compute the mean $\\mu$ and standard deviation $\\sigma$ of a data sample.\n  {If} the underlying data distribution is normal (the hypothesis), {then} we can infer that about 68\\% of all data points (the distribution) will be contained in $\\mu \\pm \\sigma$.\n  However, \\textbf{if the distribution is not normal, $\\mu$ and $\\sigma$ are only descriptive statistics};\n  \\ie they do not predict anything about the underlying data distribution.\n\\end{example}\n\n\\fakepar{Statistical methods}\nMany common statistical methods assume Gaussian distributions (\\ie normally distributed data).\nHowever, literature reports that experimental data is rarely normal~\\cite{maricq2018Taming,schmid2014measuring} and hence recommends using \\emph{non-parametric statistics}; \\ie statistics that do not make any assumption on the nature of probability distributions.\nFurthermore, it is important to consider \\emph{robust statistics}, \\ie statistics that are not overly skewed by outliers (common in networking data).\nThere are two main classes of statistical approaches: hypothesis testing and estimation.\n%\n% \\begin{itemize}\n    %\n    % \\item\n    \\emph{Hypothesis testing} consists in formulating a so-called null hypothesis, that the test aims to reject. Based on the collected data, one computes the probability, called the \\mbox{$p$-value}, that the null hypothesis is correct.\n    If the \\mbox{$p$-value} is sufficiently low, the null hypothesis is rejected and considered proven incorrect.\n    %\n    % \\item\n    \\emph{Estimation} consists in computing confidence intervals (CIs) for a given parameter (\\eg the median of a distribution).\n    A CI is always associated a confidence level (\\eg a 95\\%~CI) which is the probability that the interval includes the true value of the parameter.\n    For example, $[a,b]$ is a 95\\%~CI for the median if the true median value is between $a$ and $b$ with 95\\% probability (or better).\n%\n% \\end{itemize}\n\nCIs are more legible than $p$-values: ``\\textit{CIs provide a mechanism for making statistical inferences that give information in units with practical meaning}''~\\cite{cumming2001CI}.\nFurthermore, the level of confidence of an estimation only depends on the sample size. In other words, estimations can be used to guide the experimental design. By setting the desired level of confidence, one defines the (minimal) number of samples required.\nThis is a key property that \\triscale leverages.\n\n\\fakepar{Reproducibility is a predictive statistic}\nInformally, reproducibility is the principle that the ``same experiment'' leads to the ``same results''. Thus, assessing reproducibility entails predicting that future data (\\ie the results of a newly-performed experiment) will be the same as the known data (\\ie the results of previously conducted experiments): this is a prediction.\nThus, assessing reproducibility requires making certain hypotheses on the data.\nIt is hence crucial to \\emph{(i)~}choose statistics with hypotheses compatible with actual networking data, and to \\emph{(ii)~}verify that the hypotheses do hold for the data that one collects.\nTo this end, \\triscale makes use of non-parametric statistics and verifies that their hypotheses hold for the collected samples.\n", "meta": {"hexsha": "d42c5f0c394ff1bba4be802a8565eb3402de45c2", "size": 4979, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "20_TriScale/3_stats.tex", "max_stars_repo_name": "romain-jacob/doctoral-theis", "max_stars_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "20_TriScale/3_stats.tex", "max_issues_repo_name": "romain-jacob/doctoral-theis", "max_issues_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "20_TriScale/3_stats.tex", "max_forks_repo_name": "romain-jacob/doctoral-theis", "max_forks_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 88.9107142857, "max_line_length": 344, "alphanum_fraction": 0.7622012452, "num_tokens": 1058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.44678043593848243}}
{"text": "\\section{Search Verbs}\n\\label{searchverbs}\n\nIn 1971, the author designed and implemented \nlinear-time or nearly-linear-time algorithms \nfor {\\em indexof} ({\\apl x\\qiota\\0y}) \nand {\\em set membership} ({\\apl x\\qeps\\0y}), \noperating on most data types, on \nSHARP APL.\\cite{RBernecky:iota}\n\nThe Boolean cases of these search algorithms used vector search\ninstructions ({\\tt TRT}, and later, {\\tt CLCL}) to find the first\nbyte of interest, then used that byte as an index into a table,\nto give the bit offset within that byte.\n\n%%\\medskip\n%%\\begin{tabular}{l}  % I have no idea what I was thinking here...\n%%{\\apl First0Tab\\qlbr\\qomega\\qrbr}\\\\\n%%{\\apl First1Tab\\qlbr\\qomega\\qrbr}\\\\\n%%{\\apl LZCNT\\qlarrow\\qlbr\\qlpar\\0uint64~\\qalpha\\qrpar\\qiota\\qomega\\qrbr}\\\\\n%%\\end{tabular}\n%%\\medskip\n\nContemporary architectures with bit-level vector extensions\nmight better use a word-at-a-time search, then a left-zero-count\ninstruction (LZCNT) to count the \nnumber of leading zeros.~\\cite{INTEL:avx,AMD:instructions}\n\nOur original algorithm did not support 64-bit floating point \ndata when comparison tolerance ({\\apl \\qQuad\\0ct}), was non-zero, but\nwe later extended it to cover this missing case.\n\n", "meta": {"hexsha": "c053c29074f2be6cd2c7c157ddddb851ad57aa4a", "size": 1183, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/LatexTemplate/BooleanSIMD/searchverbs.tex", "max_stars_repo_name": "bernecky/apex", "max_stars_repo_head_hexsha": "cee572d7a1a52f46d35ba47c64e6363acdd69ee8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-08T04:17:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-08T04:17:56.000Z", "max_issues_repo_path": "Docs/LatexTemplate/BooleanSIMD/searchverbs.tex", "max_issues_repo_name": "bernecky/apex", "max_issues_repo_head_hexsha": "cee572d7a1a52f46d35ba47c64e6363acdd69ee8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Docs/LatexTemplate/BooleanSIMD/searchverbs.tex", "max_forks_repo_name": "bernecky/apex", "max_forks_repo_head_hexsha": "cee572d7a1a52f46d35ba47c64e6363acdd69ee8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.8484848485, "max_line_length": 75, "alphanum_fraction": 0.7480980558, "num_tokens": 350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4467152312710433}}
{"text": "\\pgfkeys{\n\t/pgfplots/complex plane/.style={\n\t\taxis x line=middle,\n\t\taxis y line=middle,\n\t\txlabel=$\\Re$,\n\t\tylabel=$\\Im$,\n\t\tevery axis x label/.style={\n\t\t\tat={(ticklabel* cs:1.02)},\n\t\t\tanchor=west,\n\t\t},\n\t\tevery axis y label/.style={\n\t\t\tat={(ticklabel* cs:1.02)},\n\t\t\tanchor=south,\n\t\t},\n\t\taxis line style={stealth-stealth, thick},\n\t\tlabel style={font=\\large},\n\t\ttick label style={font=\\large},\n\t\tsamples=100,\n\t\txmin=-3, xmax=3,\n\t\tymin=-3, ymax=3,\n\t\tdomain=-3:3,\n\t\tgrid=both,\n\t\tmajor grid style={black!5},\n\t},\n\t/pgfplots/complex solution/.style={\n\t\tcomplex plane,\n\t\twidth=6.5cm, height=6.5cm,\n\t\txmin=-1.5, xmax=1.5,\n\t\tymin=-1.5, ymax=1.5,\n\t\txtick={-1.5,-1,...,1.5},\n\t\txticklabels={},\n\t\tytick={-1.5,-1,...,1.5},\n\t\tyticklabels={},\n\t},\n}\n\n\\newcommand{\\arcc}[3]{\n\t\\draw[#3, fill=#3!20] (0,0) -- (#2,0) arc (0:#1:#2) -- cycle;\n}\n\n\\newcommand{\\cmplxsol}[1]{\n\t\\coordinate (O) at (0,0);\n\t\\draw[black!20] (1,0) arc (0:360:1);\n\t\\pgfmathsetmacro{\\dt}{360/#1}\n\t\\pgfmathsetmacro{\\n}{int(#1-1)}\n\t\\pgfplotsinvokeforeach{\\n,...,0}{\n\t\t\\pgfmathparse{##1+1}\n\t\t\\draw[xcol##1, fill=xcol##1!20] (O) -- ({0.1*##1},0) arc (0:{\\dt*##1}:{0.1*##1}) -- cycle;\n\t\t\\draw[very thick, xcol##1] (O) -- ({cos(\\dt*##1)},{sin(\\dt*##1)}) node[complex]{};\n\t\t\\node[xcol##1, fill=xcol##1!10, rounded corners]  at ({1.23*cos(\\dt*##1)},{1.23*sin(\\dt*##1)}) {$z_{\\the\\numexpr##1+1\\relax}$};\n\t}\n}\n\n\\section{Complex Numbers}\\label{sec:complex numbers}\n\\subsection{Algebraic approach}\nReal numbers, while being extremely useful, are not complete - they can't solve all equations involving numbers. For example, the equation\n\\begin{equation}\n\tx^{2} + 1 = 0\n\t\\label{eq:no_real_solutions}\n\\end{equation}\nhas no real solutions, since there can be no real number $x$ such that $x^{2}=-1$. However, we can choose to define a new number, $\\iu=\\sqrt{-1}$ and using it to build a new number system. This system is of course the set of complex numbers, $\\mathbb{C}$. It is defined as the set of all $z$ such that\n\\begin{equation}\n\tz = a+\\iu b,\n\t\\label{eq:complex_number}\n\\end{equation}\nwhere $a,b\\in\\mathbb{R}$ and $\\iu=\\sqrt{-1}$. We call $a$ the \\emph{real component} of $z$ or $\\Re(z)$, and $b$ its \\emph{imaginary component} or $\\Im(z)$\\footnote{There is nothing more ``real'' about real numbers than imaginary numbers, but unfortunately that's the terminology we're stuck with \\shrug}. These numbers appear a lot all throughout the exact sciences (but especially in physics and engineering), so we must at the very least learn their basic properties.\n\nIt is not so obvious that we can add two different kinds of numbers together, but it works (the linear algebra chapter sheds more light on this idea). What is important is that we always keep these two parts separated. We see this when we add together two complex numbers $z_{1},z_{2}$:\n\\begin{equation}\n\tz = z_{1}+z_{2} = \\left( a_{1}+b_{1}\\iu \\right) + \\left( a_{2}+b_{2}\\iu \\right) = \\left( a_{1}+a_{2} \\right) + \\left( b_{1}+b_{2} \\right)\\iu.\n\t\\label{eq:complex_addition}\n\\end{equation}\nThe real part of $z$ is therefore $a_{1}+b_{1}$, and its imaginary part is $b_{1}+b_{2}$.\n\nWhat happens when we multiply two complex numbers? Let's check:\n\\begin{align}\n\tz = z_{1}z_{2} &= \\left( a_{1}+b_{1}\\iu \\right)\\left( a_{2}+b_{2}\\iu \\right)\\nonumber\\\\\n\t&= a_{1}a_{2} + \\iu a_{1}b_{2} + \\iu a_{2}b_{1} + \\iu^{2}b_{1}b_{2}\\nonumber\\\\\n\t&= a_{1}a_{2} + \\iu a_{1}b_{2} + \\iu a_{2}b_{1} - b_{1}b_{2}\\nonumber\\\\\n\t&= \\left( a_{1}a_{2} - b_{1}b_{2} \\right) + \\iu\\left( a_{1}b_{2} + a_{2}b_{1} \\right).\n\t\\label{eq:complex_product}\n\\end{align}\nWe see that we can still separate the real part and imaginary part of the result. What happens in the case of two real numbers? For real numbers $b=0$, and thus \\autoref{eq:complex_product} devolves to $z=a_{1}a_{2}\\in\\mathbb{R}$, which is exactly what we expect: multiplying two real numbers yields their product, which is a real number. Notice that this doesn't happen with purely imaginary numbers: multiplying together two imaginary numbers (i.e. numbers for which $a=0$) results in a real number. Will get to understand why this happens very soon.\n\nWhen discussing real numbers sometimes we like to refer to their \\textit{magnitude}, i.e. their absolute value. With complex numbers this is defined as\n\\begin{equation}\n\t|z| = \\sqrt{a^{2}+b^{2}},\n\t\\label{eq:complex_magnitude}\n\\end{equation}\ni.e. in a sense, to get the magnitude of a complex number we imagine its two components as being perpendicular and calculate the length of the resulting hypotenuse (cf.\\ the Pythagorean theorem). In fact, this is one very useful interpretation of complex numbers, which we will explore in depth in the next subsection.\n\nA very important operation that can be applied to complex numbers is \\emph{conjugation}. The conjugate of a complex number $z=a+\\iu b$ is defined as\n\\begin{equation}\n\t\\conj{z} = a-\\iu b,\n\t\\label{eq:complex_conjugation}\n\\end{equation}\ni.e. conjugating a number is simply negating its imaginary part. When we multiply a complex number by its own complex conjugate we get\n\\begin{equation}\n\tz\\conj{z} = (a+\\iu b)(a-\\iu b) = a^{2} + \\cancel{ab\\iu}  - \\cancel{ab\\iu}  - b^{2}\\iu^{2} = a^{2}+b^{2},\n\t\\label{eq:conjugate_product}\n\\end{equation}\ni.e. $z\\conj{z} = |z|^{2}$. The inverse of a complex number can be expressed as\n\\begin{equation}\n\tz^{-1} = \\frac{\\conj{z}}{|z|^{2}}.\n\t\\label{eq:complex_inverse}\n\\end{equation}\n\n\\subsection{Geometric approach}\nAs alluded to in the previous subsection, we can interpret a complex number $z=a+\\iu b$ as two components in a 2-dimensional space (called the \\emph{complex plane}), in which the horizontal axis represents real components, and the vertical access represents imaginary components:\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\tikzstyle{every node}=[font=\\large]\n\t\t\\pgfmathsetmacro{\\a}{2}\n\t\t\\pgfmathsetmacro{\\b}{2.5}\n\t\t\\pgfmathsetmacro{\\t}{atan2(\\b,\\a)}\n\t\t\\begin{axis}[\n\t\t\tcomplex plane,\n\t\t\twidth=9cm, height=9cm,\n\t\t\txtick={-3,-2.5,...,3},\n\t\t\txticklabels={},\n\t\t\textra x ticks={\\a},\n\t\t\textra x tick labels={$a$},\n\t\t\tytick={-3,-2.5,...,3},\n\t\t\tyticklabels={},\n\t\t\textra y ticks={\\b},\n\t\t\textra y tick labels={$b$},\n\t\t]\n\t\t\\draw[very thick, xred] (0,0) -- node[midway, above, rotate=\\t] {$|z|=\\sqrt{a^{2}+b^{2}}$} (\\a,\\b) node[complex](zdot){};\n\t\t\\node[xred, above of=zdot, yshift=-6mm] {$z=a+\\iu b$};\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\caption{A complex number $z=a+\\iu b$ shown on the complex plane: the horizontal and vertical axes represent the real and imaginary components, respectively.}\n\t\\label{fig:complex number}\n\\end{figure}\n\nDrawing a line from $z$ to $a$ (on the real axis) creates a right triangle. We can then define $\\theta$ to be the angle near the origin and $r$ the length of the hypotenuse:\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\tikzstyle{every node}=[font=\\large]\n\t\t\\pgfmathsetmacro{\\a}{2}\n\t\t\\pgfmathsetmacro{\\b}{2.5}\n\t\t\\pgfmathsetmacro{\\t}{atan2(\\b,\\a)}\n\t\t\\begin{axis}[\n\t\t\tcomplex plane,\n\t\t\twidth=9cm, height=9cm,\n\t\t\txtick={-3,-2.5,...,3},\n\t\t\txticklabels={},\n\t\t\textra x ticks={\\a},\n\t\t\textra x tick labels={$a$},\n\t\t\tytick={-3,-2.5,...,3},\n\t\t\tyticklabels={},\n\t\t\textra y ticks={\\b},\n\t\t\textra y tick labels={$b$},\n\t\t]\n\t\t\\draw[thick, dashed] (\\a,\\b) -- (\\a,0);\n\t\t\\draw[thick] ({\\a-0.25},0) -- ({\\a-0.25},0.25) -- (\\a,0.25);\n\t\t\\draw[very thick] (0.75,0) arc (0:\\t:0.75);\n\t\t\\node[] at ({cos(\\t/2)},{sin(\\t/2)}) {$\\theta$};\n\t\t\\draw[very thick, xred] (0,0) -- node[midway, above, rotate=\\t] {$r$} (\\a,\\b) node[complex](zdot){};\n\t\t\\node[xred, above of=zdot, yshift=-6mm] {$z$};\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\caption{The same complex number $z$ from \\autoref{fig:complex number} shown with its polar components $r=|z|=\\sqrt{a^{2}+b^{2}}$ and $\\theta=\\arctan\\left( \\frac{b}{a} \\right)$.}\n\t\\label{fig:complex number 2}\n\\end{figure}\nWe call $r$ the \\emph{magnitude} of $z$, and $\\theta$ its \\emph{argument}. The ranges for $r$ and $\\theta$ are, respectively, $[0,\\infty)$ and $[0,2\\pi)$.\n\nUsing \\autoref{eq:xy_P} the real and imaginary components of $z$ are\n\\begin{align}\n\ta &= r\\cos(\\theta),\\nonumber\\\\\n\tb &= r\\sin(\\theta),\n\t\\label{eq:complex_components}\n\\end{align}\nand $z$ can be re-written as\n\\begin{equation}\n\tz = r\\left( \\cos(\\theta) + \\iu\\sin(\\theta) \\right).\n\t\\label{eq:complex_geometric_form}\n\\end{equation}\nWhich we call the \\emph{polar form} of $z$ (contrasted with $z=a+\\iu b$ being the \\emph{Cartesian form} of $z$).\n\nInverting the relations in \\autoref{eq:complex_components} yields the relations\n\\begin{align}\n\tr &= a^{2}+b^{2},\\nonumber\\\\\n\t\\theta &= \\arctan\\left(\\frac{b}{a}\\right).\n\t\\label{eq:complex_components_geometric}\n\\end{align}\n\nLet's examine the same properties of complex numbers shown in Equations \\ref{eq:complex_addition}, \\ref{eq:complex_product} and \\ref{eq:complex_conjugation}, and verify that they work in the polar form of complex numbers. We start with addition (\\autoref{eq:complex_addition}):\n\\begin{align}\n\tz_{1}+z_{2} &= r_{1}\\left[ \\cos\\left( \\theta_{1} \\right) + \\iu\\sin\\left( \\theta_{1} \\right) \\right] + r_{2}\\left[ \\cos\\left( \\theta_{2} \\right) + \\iu\\sin\\left( \\theta_{2} \\right) \\right]\\nonumber\\\\\n\t&= \\underbrace{r_{1}\\cos\\left( \\theta_{1} \\right)}_{a_{1}} + \\underbrace{r_{2}\\cos\\left( \\theta_{2} \\right)}_{a_{2}} + \\iu\\underbrace{r_{1}\\sin\\left( \\theta_{1} \\right)}_{b_{1}} + \\iu\\underbrace{r_{2}\\sin\\left( \\theta_{2} \\right)}_{b_{2}}\\nonumber\\\\\n&= \\left( a_{1}+a_{2} \\right) + \\iu\\left( b_{1}+b_{2} \\right).\n\t\\label{eq:complex_addition_geometric}\n\\end{align}\nWe see that indeed, the polar form of complex numbers adheres to the addition rule in \\autoref{eq:complex_addition}. Next is the product rule:\n\\begin{align}\n\tz_{1}z_{2} &= r_{1}\\left[ \\cos\\left(\\theta_{1}\\right) + \\iu\\sin\\left(\\theta_{1}\\right) \\right] \\cdot r_{2}\\left[ \\cos\\left(\\theta_{2}\\right) + \\iu\\sin\\left(\\theta_{2}\\right) \\right]\\nonumber\\\\\n\t&= r_{1}r_{2}\\left[ \\cos\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right) + \\iu\\cos\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right) + \\iu\\sin\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right) -\\sin\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right)  \\right]\\nonumber\\\\\n\t&= r_{1}\\cos\\left( \\theta_{1} \\right)r_{2}\\cos\\left( \\theta_{2} \\right) - r_{1}\\sin\\left( \\theta_{1} \\right)r_{2}\\sin\\left( \\theta_{2} \\right) + \\iu\\left[ r_{1}\\cos\\left( \\theta_{1} \\right)r_{2}\\sin\\left( \\theta_{2} \\right) + r_{1}\\sin\\left( \\theta_{1} \\right)r_{2}\\cos\\left( \\theta_{2} \\right) \\right]\\nonumber\\\\\n\t&= \\left( a_{1}a_{2}-b_{1}b_{2} \\right) + \\iu\\left( a_{1}b_{2} + a_{2}b_{1} \\right),\n\t\\label{eq:complex_product_geometric}\n\\end{align}\nwhich is indeed the result seen in \\autoref{eq:complex_product}. We can also develop further the second row of \\autoref{eq:complex_product_geometric} using some trigonometry (specifically the trigonometric identities in \\autoref{eq:trig product to sum}):\n\\begin{align}\n\tz_{1}z_{2} &= r_{1}r_{2}\\left[ \\cos\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right) + \\iu\\cos\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right) + \\iu\\sin\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right) -\\sin\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right) \\right]\\nonumber\\\\\n\t&= r_{1}r_{2}\\left[ \\cos\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right)-\\sin\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right) + i\\left[ \\cos\\left( \\theta_{1} \\right)\\sin\\left( \\theta_{2} \\right) + \\sin\\left( \\theta_{1} \\right)\\cos\\left( \\theta_{2} \\right) \\right] \\right]\\nonumber\\\\\n\t&= r_{1}r_{2}\\left[ \\cos\\left( \\theta_{1}+\\theta_{2} \\right) + \\iu\\sin\\left( \\theta_{1}+\\theta_{2} \\right)  \\right].\n\t\\label{eq:complex_product_geometric_insight}\n\\end{align}\nThis is a very important result: it shows that multiplying a complex number $z_{1}$ by another complex number $z_{2}$ gives a complex number with magnitude $r_{1}r_{2}$, i.e. the product of the magnitudes of the two complex numbers, and argument $\\theta_{1}+\\theta_{2}$, i.e. the argument of $z_{1}$ rotated by the argument of $z_{2}$ (or vice-versa). We will consider this result in more detail soon.\n\n\nIn the polar form the complex conjugate of a number $z=r\\left[ \\cos\\left( \\theta \\right) + \\iu\\sin\\left( \\theta \\right) \\right]$ can be brought about by substituting $-\\theta$ into the arguments of the trigonometric functions:\n\\begin{align}\n\t\\conj{z} &= r\\left[ \\cos\\left( -\\theta \\right) + \\iu\\sin\\left( -\\theta \\right) \\right]\\nonumber\\\\\n\t&= r\\left[ \\cos\\left( \\theta \\right) - \\iu\\sin\\left( \\theta \\right) \\right]\\nonumber\\\\\n\t&= r\\cos\\left( \\theta \\right) - \\iu r\\sin\\left( \\theta \\right)\\nonumber\\\\\n\t&= a-\\iu b.\n\t\\label{eq:complex_conjugation_geometric}\n\\end{align}\n\nLastly, let's show that \\autoref{eq:conjugate_product} can be derived in the polar form:\n\\begin{align}\n\tz\\conj{z} &= r\\left[ \\cos\\left( \\theta \\right) + \\iu\\sin\\left( \\theta \\right) \\right] \\cdot r\\left[ \\cos\\left( \\theta \\right) - \\iu\\sin\\left( \\theta \\right) \\right]\\nonumber\\\\\n\t&= r^{2}\\left[ \\cos^{2}\\left( \\theta \\right) -\\cancel{\\iu\\cos\\left( \\theta \\right)\\sin\\left( \\theta \\right)} +\\iu\\cancel{\\sin\\left( \\theta \\right)\\cos(\\theta)} + \\sin^{2}\\left( \\theta \\right) \\right]\\nonumber\\\\\n\t&= r^{2}\\left[ \\sin^{2}\\left( \\theta \\right) + \\cos^{2}\\left( \\theta \\right) \\right]\\nonumber\\\\\n\t&= r^{2} = a^{2}+b^{2}.\n\t\\label{eq:conjugate_product_geometric}\n\\end{align}\n\nIn 1748 Leonhard Euler published his famous work \\textit{Introduction to analysis of the infinite}\\footnote{Latin for \\textbf{Introduction to the Analysis of the Infinite}.}. In it he introduced the following relation, called \\emph{Euler's formula}:\n\\begin{equation}\n\t\\eu^{\\iu x} = \\sin(x) + \\iu\\cos(x).\n\t\\label{eq:Euler's_formula}\n\\end{equation}\nUsing Euler's formula a complex number $z$ can be written as\n\\begin{equation}\n\tz = r\\eu^{\\iu\\theta}.\n\t\\label{eq:complex number using Eurler's formula}\n\\end{equation}\n\nIn \\autoref{tab:complex_exponentials} we can see some useful complex exponentials $\\eu^{\\iu x}$. Specifically, setting $x=\\pi$ yields the famous \\emph{Eurler's identity}, considered by many to be one of the most beautiful equations in mathematics, as it binds together five important numbers, namely $0,1,\\pi,e$ and $\\iu$:\n\\begin{equation}\n\t\\eu^{\\iu\\pi} + 1 = 0.\n\t\\label{eq:Euler's identity}\n\\end{equation}\n\n\\begin{table}\n\t\\centering\n\t\\caption{Values of $\\eu^{ix}$ for some useful values of $x$ (cf. \\autoref{tab:rad_degs} for the values of $\\sin(\\theta)$ and $\\cos(\\theta)$).}\n\t\\label{tab:complex_exponentials}\n\t\\begin{tabular}{lccl}\n\t\t\\toprule\n\t\t$x$ & $\\cos(x)$ & $\\sin(x)$ & $z=\\eu^{\\iu x}$\\\\\n\t\t\\midrule\n\t\t$\\frac{\\pi}{2}$ & $0$ & $1$ & $\\iu$\\\\\n\t\t$\\pi$ & $-1$ & $0$ & $-1$\\\\\n\t\t$\\frac{3\\pi}{2}$ & $0$ & $-1$ & $-\\iu$\\\\\n\t\t$\\frac{\\pi}{3}$ & $\\frac{1}{2}$ & $\\frac{\\sqrt{3}}{2}$ & $\\frac{1}{2}\\left( 1+\\iu\\sqrt{3} \\right)$\\\\\n\t\t$\\frac{\\pi}{4}$ & $\\frac{\\sqrt{2}}{2}$ & $\\frac{\\sqrt{2}}{2}$ & $\\frac{\\sqrt{2}}{2}\\left( 1+\\iu \\right)$\\\\\n\t\t$\\frac{\\pi}{6}$ & $\\frac{\\sqrt{3}}{2}$ & $\\frac{1}{2}$ & $\\frac{1}{2}\\left( \\sqrt{3}+\\iu \\right)$\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\autoref{tab:complex_exponentials} also shows us the integer behaviours of $\\iu$:\n\\begin{equation}\n\t\\iu^{2}=-1,\\ \\iu^{3}=-\\iu, \\iu^{4}=1,\\ \\iu^{5}=\\iu,\\ \\iu^{6}=-1,\\ \\iu^{7}=-\\iu,\\ \\dots\n\t\\label{eq:powers of i}\n\\end{equation}\n\n\\subsection{Roots of complex numbers}\nWhat is the $n$-th order roots of a complex number $z$, i.e. $\\nroot{n}{z}$? An illuminating way to approach this problem is by looking at the polar form of $z$. As an example, we start with the number $z=1$ and find its 3rd order roots, i.e. all number $w$ such that $w^{3}=1$ (spoiler alert: there are three such numbers).\n\n\\autoref{eq:complex_product_geometric_insight} taught us that complex numbers not only scale other numbers, but also rotate them: with real numbers the product $x \\cdot y$ is equivalent to a scaling of $x$ by $y$. With complex numbers the product has two components: its magnitude is the scale of $x$ by $y$, and its argument is the argument of $x$ rotated by the argument of $y$\\footnote{Due to the commutativity of the complex product we can switch the order of $z$ and $w$ and get the same result.}.\n\n\\begin{example}{Rotation using complex numbers}{}\n\tLet $z=2+2\\iu$ and $w=3\\iu$. Their polar forms are $z=2\\sqrt{2}\\left[ \\cos(\\pi/4) +\\iu\\sin(\\pi/4) \\right]$ and $w=3\\left[ \\cos(\\pi/2) + \\iu\\sin(\\pi/2) \\right]$. Their product is\n\t\\begin{align*}\n\t\tz\\cdot w &= (2+2\\iu)\\cdot3\\iu = 6\\iu + 6\\iu^{2} = -6+6\\iu,\n\t\\end{align*}\n\twhich in polar form is $6\\sqrt{2}\\left[ \\cos(3\\pi/4) + \\iu\\sin(3\\pi/4) \\right]$. Note that\n\t\\begin{align*}\n\t\t2\\sqrt{2}\\cdot3 &= 6\\sqrt{2},\\text{ and}\\\\\n\t\t\\frac{\\pi}{4} + \\frac{\\pi}{2} &= \\frac{3\\pi}{4},\n\t\\end{align*}\n\ti.e. $z\\cdot w$ has magnitude which is the \\textbf{product} of the magnitudes of $z$ and $w$, and an argument which is the \\textbf{sum} of the arguments of $z$ and $w$.\n\n\t\\vspace{1em}\n\tThe figure below depict the arguments of the three numbers $z,w,z\\cdot w$. Note that $\\textcolor{xpurple}{\\bm{\\theta_{z\\cdot w}}} = \\textcolor{xred}{\\bm{\\theta_{z}}}+\\textcolor{xblue}{\\bm{\\theta_{w}}}$.\n\n\t\\vspace{1em}\n\t\t\\centering\n\t\t\\begin{tikzpicture}[node distance=3mm]\n\t\t\t\\tikzstyle{every node}=[font=\\large]\n\t\t\t\\begin{axis}[\n\t\t\t\tcomplex plane,\n\t\t\t\twidth=7cm, height=5cm,\n\t\t\t\txmin=-1.25, xmax=1.25,\n\t\t\t\tymin=-0.25, ymax=1.25,\n\t\t\t\txtick={-1,0,1},\n\t\t\t\txticklabels={},\n\t\t\t\textra x ticks={-0.5,0.5},\n\t\t\t\textra x tick labels={},\n\t\t\t\tytick={-1,0,1},\n\t\t\t\tyticklabels={},\n\t\t\t\textra y ticks={-0.5,0.5},\n\t\t\t\textra y tick labels={},\n\t\t\t]\n\t\t\t\\coordinate (O) at (0,0);\n\t\t\t\\coordinate (A) at (0.707,0.707);\n\t\t\t\\coordinate (B) at (0,1);\n\t\t\t\\draw[black!20] (1,0) arc (0:180:1);\n\t\t\t\\arcc{135}{0.60}{xpurple}\n\t\t\t\\arcc{90}{0.55}{xblue}\n\t\t\t\\arcc{45}{0.5}{xred}\n\t\t\t\\draw[xred] (0,0) -- (0.707,0.707) node[complex](z){};\n\t\t\t\\draw[xblue] (0,0) -- (0,1) node[complex](w){};\n\t\t\t\\draw[xpurple] (0,0) -- (-0.707,0.707) node[complex](zw){};\n\t\t\t\\node[xred, right of=z] {$z$};\n\t\t\t\\node[xblue, left of=w, yshift=2mm] {$w$};\n\t\t\t\\node[xpurple, above left of=zw, xshift=-2mm] {$z\\cdot w$};\n\t\t\t\\node[xred, rotate=22.5] at ({0.35*cos(22.5)},{0.35*sin(22.5)}) {$\\theta_{z}$};\n\t\t\t\\node[xblue, rotate=67.5] at ({0.35*cos(67.5)},{0.35*sin(67.5)}) {$\\theta_{w}$};\n\t\t\t\\node[xpurple, rotate=-45] at ({0.35*cos(112.5)},{0.35*sin(112.5)}) {$\\theta_{z\\cdot w}$};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\\end{example}\n\n\\begin{note}{$\\bm{\\iu^{2}=-1}$ from a geometric (polar) viewpoint}{}\n\tIn polar coordinates $\\iu$ has magnitude $1$ and argument $\\frac{\\pi}{2}$, i.e. multiplying by $\\iu$ is equivalent to rotation by $\\frac{\\pi}{2}$ ($\\ang{90}$) counter clockwise. Therefore, multiplying $\\iu$ by itself, i.e. $\\iu^{2}$, rotates $\\iu$ itself by $\\frac{\\pi}{2}$ counter clockwise, bringing it to $-1$.\n\t\n\t\\centering\n\t\\begin{tikzpicture}[node distance=3mm]\n\t\t\t\\tikzstyle{every node}=[font=\\large]\n\t\t\t\\begin{axis}[\n\t\t\t\tcomplex plane,\n\t\t\t\twidth=7cm, height=5cm,\n\t\t\t\txmin=-1.25, xmax=1.25,\n\t\t\t\tymin=-0.25, ymax=1.25,\n\t\t\t\txtick={-1,0,1},\n\t\t\t\txticklabels={},\n\t\t\t\textra x ticks={-0.5,0.5},\n\t\t\t\textra x tick labels={},\n\t\t\t\tytick={-1,0,1},\n\t\t\t\tyticklabels={},\n\t\t\t\textra y ticks={-0.5,0.5},\n\t\t\t\textra y tick labels={},\n\t\t\t]\n\t\t\t\\coordinate (O) at (0,0);\n\t\t\t\\coordinate (i) at (0,1);\n\t\t\t\\coordinate (-1) at (-1,0);\n\t\t\t\\draw[black!20] (1,0) arc (0:180:1);\n\t\t\t\\arcc{180}{0.6}{xblue}\n\t\t\t\\arcc{90}{0.5}{xdarkgreen}\n\t\t\t\\draw[xdarkgreen] (O) -- (i) node[complex](i){};\n\t\t\t\\draw[xblue] (O) -- (-1) node[complex](-1){};\n\t\t\t\\node[xdarkgreen, above right of=i] {$\\iu$};\n\t\t\t\\node[xblue, below of=-1] {$-1$};\n\t\t\t\\node[xdarkgreen] at ({0.3*cos(45)},{0.3*sin(45)}) {$\\frac{\\pi}{2}$};\n\t\t\t\\node[xblue] at ({0.3*cos(135)},{0.3*sin(135)}) {$\\pi$};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\\end{note}\n\nIn polar form $1=\\cos(0)+\\iu\\sin(0)$. Finding the arguments of the cube roots of $1$ is therefore done by answering the following question: what angles $\\theta$ will equal $0$ (or its equivalent angles $2\\pi,4\\pi,6\\pi,\\dots$) when multiplied by $3$? The answer is very simple: the only possible solutions are\n\\begin{align}\n\t\\theta_{1} &= 0,\\nonumber\\\\\n\t\\theta_{2} &= \\frac{2\\pi}{3},\\nonumber\\\\\n\t\\theta_{3} &= \\frac{4\\pi}{3}.\n\t\\label{eq:arguments for the cube roots of 1}\n\\end{align}\n(any other number in the range $[0,2\\pi)$ will give the same angles)\n\nTherefore, the three cube roots of $1$ are \\footnote{recall that $\\nroot{3}{1}=1$, and therefore all roots have magnitude $1$.} (\\autoref{fig:cube roots of 1})\n\\begin{align}\n\tz_{1} &= \\cos\\left( \\theta_{1} \\right) + \\iu\\sin\\left( \\theta_{1} \\right) = \\cos(0) + \\iu\\sin(0) = 1,\\nonumber\\\\\n\tz_{2} &= \\cos\\left( \\theta_{2} \\right) + \\iu\\sin\\left( \\theta_{2} \\right) = \\cos\\left( \\frac{2\\pi}{3} \\right) + \\iu\\sin\\left( \\frac{2\\pi}{3} \\right) = -0.5+\\frac{\\sqrt{3}}{2}\\iu,\\nonumber\\\\\n\tz_{3} &= \\cos\\left( \\theta_{3} \\right) + \\iu\\sin\\left( \\theta_{1} \\right) = \\cos\\left( \\frac{4\\pi}{3} \\right) + \\iu\\sin\\left( \\frac{4\\pi}{3} \\right) = -0.5-\\frac{\\sqrt{3}}{2}\\iu.\n\t\\label{eq:cube roots of 1}\n\\end{align}\n\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\tikzstyle{every node}=[font=\\large]\n\t\t\\begin{axis}[\n\t\t\tcomplex plane,\n\t\t\twidth=10cm, height=10cm,\n\t\t\txmin=-1.25, xmax=1.25,\n\t\t\tymin=-1.25, ymax=1.25,\n\t\t\txtick={-1,0,1},\n\t\t\textra x ticks={-0.5,0.5},\n\t\t\textra x tick labels={},\n\t\t\tytick={-1,0,1},\n\t\t\textra y ticks={-0.5,0.5},\n\t\t\textra y tick labels={},\n\t\t]\n\t\t% NOTE: this should changed to use \\cmplxsol{3}.\n\t\t\\coordinate (O) at (0,0);\n\t\t\\coordinate (z1) at (1,0);\n\t\t\\coordinate (z2) at (-0.5,{sqrt(3)/2});\n\t\t\\coordinate (z3) at (-0.5,{-sqrt(3)/2});\n\t\t\\draw[black!20] (z1) arc (0:360:1);\n\t\t\\draw[xgreen, fill=xgreen!20] (O) -- (0.175,0) arc (0:240:0.175) -- cycle;\n\t\t\\draw[xblue, fill=xblue!20] (O) -- (0.125,0) arc (0:120:0.125) -- cycle;\n\t\t\\draw[very thick, xred] (O) -- node[above, right, xshift=-20, yshift=8] {$\\theta_{1}=0$} (z1) node[complex, label=above:$z_{1}$]{};\n\t\t\\draw[very thick, xblue] (O) -- node[below, rotate=-60] {$\\theta_{2}=\\frac{2\\pi}{3}$} (z2) node[complex, label=above left:$z_{2}$]{};\n\t\t\\draw[very thick, xgreen] (O) -- node[above, rotate=60] {$\\theta_{3}=\\frac{4\\pi}{3}$}(z3) node[complex, label=below left:$z_{3}$]{};\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\caption{The three cube roots of $z=1$.}\n\t\\label{fig:cube roots of 1}\n\\end{figure}\n\nThe $n$-th degree roots of $1$ will follow the same pattern for $n\\in\\mathbb{N}$ (see \\autoref{fig:nth roots of 1}): their magnitude is always $1$, and the argument of the $k$-th root is\n\\begin{equation}\n\t\\theta_{k} = \\frac{2\\pi}{n}k.\n\t\\label{eq:nth roots of 1}\n\\end{equation}\n\nFinding the $n$-th degree roots of a general complex number $z=r\\left[ \\cos(\\theta) +\\iu\\sin(\\theta) \\right]$ can be done in a similar fashion: all roots will have the magnitude $\\nroot{n}{r}$, and their argument $\\theta_{k}$ will be such that multiplying it by $n$ gives $\\theta+2\\pi m$ for some integer value $m$, i.e.\n\\begin{equation}\n\t\\theta_{k} = \\frac{\\theta+2\\pi m}{n}.\n\t\\label{eq:sofds}\n\\end{equation}\n\n\\begin{figure}\n\t\\captionsetup[subfigure]{labelformat=empty}\n\t\\centering\n\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tcomplex solution,\n\t\t\t\t]\n\t\t\t\t\\cmplxsol{4}\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{$n=4,\\ \\theta_{k}=\\frac{\\pi}{2}k$}\n\t\\end{subfigure}\n\t\\hfill\n\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tcomplex solution,\n\t\t\t\t]\n\t\t\t\t\\cmplxsol{5}\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{$n=5,\\ \\theta_{k}=\\frac{2\\pi}{5}k$}\n\t\\end{subfigure}\n\n\t\\vspace{2em}\n\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tcomplex solution,\n\t\t\t\t]\n\t\t\t\t\\cmplxsol{6}\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{$n=6,\\ \\theta_{k}=\\frac{\\pi}{3}k$}\n\t\\end{subfigure}\n\t\\hfill\n\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tcomplex solution,\n\t\t\t\t]\n\t\t\t\t\\cmplxsol{7}\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{$n=7,\\ \\theta_{k}=\\frac{7\\pi}{2}k$}\n\t\\end{subfigure}\n\t\\caption{Complex $n$-th roots of $z=1$ for $n=4,5,6,7$. Note that for all circles $r=1$.}\n\t\\label{fig:nth roots of 1}\n\\end{figure}\n", "meta": {"hexsha": "81fb757d599588f11592d0618410909d9b9d577c", "size": 23886, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/intro/complex_numbers.tex", "max_stars_repo_name": "JASory/maths_book", "max_stars_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2021-12-25T20:02:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T17:57:59.000Z", "max_issues_repo_path": "chapters/intro/complex_numbers.tex", "max_issues_repo_name": "JASory/maths_book", "max_issues_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2022-01-17T05:01:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-20T06:18:24.000Z", "max_forks_repo_path": "chapters/intro/complex_numbers.tex", "max_forks_repo_name": "JASory/maths_book", "max_forks_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2022-01-17T10:15:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T10:45:13.000Z", "avg_line_length": 49.3512396694, "max_line_length": 552, "alphanum_fraction": 0.6471573307, "num_tokens": 9141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.4467152312710433}}
{"text": "\\documentclass[Physics.tex]{subfiles}\r\n\\begin{document}\r\n\\chapter{Kinematics}\r\n\\sldef{Distance} \\(x\\) is the total length covered by a moving object irrespective of the direction of motion.\r\n\r\n\\sldef{Displacement} or position \\(\\mathbf{x}\\) is the shortest linear distance of a moving object from a given reference point.\r\n\r\n\\sldef{Speed} is the rate of change of distance travelled with respect to time. \\begin{equation}v = \\frac{\\mathrm{d}x}{\\mathrm{d}t}\\end{equation} \r\n\r\n\\sldef{Velocity} is the rate of change of displacement with respect to time. \\begin{equation}\\mathbf{v} = \\frac{\\mathrm{d}\\mathbf{x}}{\\mathrm{d}t}\\end{equation}\r\n\r\n\\sldef{Acceleration} is the rate of change of velocity with respect to time. \\begin{equation}\\mathbf{a} = \\frac{\\mathrm{d}\\mathbf{v}}{\\mathrm{d}t}\\end{equation}\r\n\r\n\\sldef{Average speed} is the total distance travelled over the total time taken. \\begin{equation}\\langle v \\rangle = \\frac{\\Delta x}{\\Delta t}\\end{equation}\r\n\r\n\\sldef{Average velocity} is the total change in displacement over total time taken. \\begin{equation}\\langle\\mathbf{v}\\rangle = \\frac{\\Delta \\mathbf{x}}{\\Delta t}\\end{equation}\r\n\r\n\\sldef{Average acceleration} is the total change in velocity over total time taken. \\begin{equation}\\langle\\mathbf{a}\\rangle = \\frac{\\Delta \\mathbf{v}}{\\Delta t}\\end{equation}\r\n\\section{Freefall}\r\nAn object that experiences no force other than its weight and possibly drag is in freefall. Neglecting air resistance, an object in freefall near the Earth's surface experiences a constant downward acceleration \\(\\mathbf{g} = \\SI{9.81}{\\metre\\per\\square\\second}\\) towards the Earth's centre of mass.\r\n\r\nIn reality, an object will experience a drag force \\(\\mathbf{F}_D \\propto \\mathbf{v}\\) for small \\(\\mathbf{v}\\), and \\(\\mathbf{F}_D \\propto \\mathbf{v}^2\\) for larger \\(\\mathbf{v}\\). The drag force opposes the object's motion. Terminal velocity is the velocity an object reaches when drag exactly balances the object's weight.\r\n\\section{Projectile motion}\r\nIn \\sldef{projectile motion}, it is assumed that\r\n\\begin{slinenum}\r\n\\item the acceleration due to gravity is constant throughout the motion, i.e. \\(\\mathbf{g}\\) is constant\r\n\\item there is no horizontal acceleration, i.e. \\(\\mathbf{a}_x = 0\\)\r\n\\item air resistance is negligible, i.e. \\(\\mathbf{F}_D = 0\\).\r\n\\end{slinenum}\r\nProjectile motion with the above assumptions generally creates a parabolic trajectory that is symmetric; the \\sldef{trajectory} is the path described by a projectile. \\sldef{Range} is the distance on the plane between the point of projection and point of impact.\r\n\r\nWith air resistance, projectile motion describes an asymmetric trajectory. Air resistance also decreases the object's time of flight, horizontal range and maximum height reached.\r\n\\section{Kinematics equations}\r\nThe following equations apply only when acceleration is constant.\r\n\\begin{align}\r\n\\mathbf{a} &= \\frac{\\Delta\\mathbf{v}}{\\Delta t} = \\frac{\\mathbf{v} - \\mathbf{u}}{t} \\mathrel{\\therefore} \\mathbf{v} - \\mathbf{u} = \\mathbf{a}t \\mathrel{\\therefore} \\mathbf{v} = \\mathbf{u} + \\mathbf{a}t\\\\\r\n\\mathbf{s} &= \\int_{}^{}{\\mathbf{v}\\mathrm{d}t} = \\int_{}^{}{(\\mathbf{u} + \\mathbf{a}t)\\mathrm{d}t} = \\mathbf{u}t + \\frac{1}{2}\\mathbf{a}t^{2}\\\\\r\n\\begin{split}\\mathbf{s} &= \\mathbf{u}t + \\frac{1}{2}\\mathbf{a}t^{2} = \\mathbf{u}t + \\frac{1}{2}\\frac{( \\mathbf{v} - \\mathbf{u})}{t}t^{2}%= \\mathbf{u}t + \\frac{1}{2}t(\\mathbf{v} - \\mathbf{u})\r\n\\\\ &= \\mathbf{u}t + \\frac{1}{2}\\mathbf{v}t - \\frac{1}{2}\\mathbf{u}t = \\frac{1}{2}\\mathbf{u}t + \\frac{1}{2}\\mathbf{v}t\\\\&= \\frac{1}{2}(\\mathbf{v} + \\mathbf{u})t\\end{split}\\\\\r\n\\begin{split}\\mathbf{v}^{2} &= ( \\mathbf{u} + \\mathbf{a}t )^{2} = \\mathbf{u}^{2} + 2\\mathbf{ua}t + \\mathbf{a}^{2}t^{2}\\\\&= \\mathbf{u}^{2} + 2\\mathbf{a}( \\mathbf{s} - \\frac{1}{2}\\mathbf{a}t^{2} ) + \\mathbf{a}^{2}t^{2}\\\\&= \\mathbf{u}^{2} + 2\\mathbf{as} - \\mathbf{a}^{2}\\mathbf{t}^{2} + \\mathbf{a}^{2}\\mathbf{t}^{2}\\\\&= \\mathbf{u}^{2} + 2\\mathbf{as}\\end{split}\r\n\\end{align}\r\n\\end{document}", "meta": {"hexsha": "29ca8db13a5638a8efd6f2239ed66452fc7ec087", "size": 3985, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX/Physics/ch2_kinematics.tex", "max_stars_repo_name": "oliverli/A-Level-Notes", "max_stars_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-05T11:44:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-05T11:44:33.000Z", "max_issues_repo_path": "TeX/Physics/ch2_kinematics.tex", "max_issues_repo_name": "oliverli/A-Level-Notes", "max_issues_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX/Physics/ch2_kinematics.tex", "max_forks_repo_name": "oliverli/A-Level-Notes", "max_forks_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.880952381, "max_line_length": 358, "alphanum_fraction": 0.695859473, "num_tokens": 1354, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.44660057424450467}}
{"text": "% !TeX root = constructions.tex\n\n\\part{Straightedge and Compass}\\label{p.sec}\n\n\n\\chapter{Help, My Compass Collapsed!}\\label{c.collapse}\n\n\\section{Fixed compasses and collapsing compasses}\n\nA modern compass is a \\emph{fixed compass}: the distance between the two legs can be fixed so that it is possible to copy a line segment or a circle from one position to another. I have seen geometry textbooks that present the  construction a perpendicular bisector to a line segment as follows: construct two circles centered at the ends of the line segment such that the radii are equal and \\emph{greater than half the length of the segment} (left diagram):\n\n\\vspace{-2ex}\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.5]\n\\begin{scope}\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\draw[name path=larc] (A) ++(-60:3cm) arc (-60:60:3cm);\n\\draw[name path=rarc] (B) ++(-120:3cm) arc (-120:-240:3cm);\n\\path [name intersections={of=larc and rarc,by={b,t}}];\n\\fill (t) node[above right,xshift=-2pt,yshift=5pt] {$C$} circle[radius=3pt];\n\\fill (b) node[below left,xshift=2pt,yshift=-5pt] {$D$} circle[radius=3pt];\n\\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);\n\\end{scope}\n\\begin{scope}[xshift=12cm]\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\draw[name path=larc] (A) ++(-80:4cm) arc (-80:80:4cm);\n\\draw[name path=rarc] (B) ++(-100:4cm) arc (-100:-260:4cm);\n\\path [name intersections={of=larc and rarc,by={b,t}}];\n\\fill (t) node[above right,xshift=-2pt,yshift=3pt] {$C$} circle[radius=3pt];\n\\fill (b) node[below left,xshift=2pt,yshift=-3pt] {$D$}circle[radius=3pt];\n\\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\n\\vspace{-2ex}\n\nEuclid used a \\emph{collapsing compass} whose legs fold up when the compass is lifted off the paper. Teachers often use a collapsing compass consisting of a piece of chalk tied to a string. It is impossible to maintain a fixed radius when the chalk and the end of the string are removed from the blackboard. The right diagram above shows how to construct a perpendicular bisector with a collapsing compass: the length of the segment $\\overline{AB}$ is, of course, equal to the length of the segment $\\overline{BA}$, so the radii of the two circles are equal.\n\nThe proof that the line constructed is the perpendicular bisector is not at all elementary because relatively advanced concepts like congruent triangles have to be used. However, the proof that the same construction results in an equilateral triangle is very simple (right diagram below). The length of $\\overline{AC}$ equals the length of $\\overline{AB}$ since they are radii of the same circle, and for the same reason the length of $\\overline{BC}$ is equal to the length of $\\overline{BA}$. We have:\n\\[\n\\overline{AC}=\\overline{AB}=\\overline{BA}=\\overline{BC}\\,.\n\\]\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.5]\n\\begin{scope}\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\draw[name path=larc] (A) ++(-60:3cm) arc (-60:60:3cm);\n\\draw[name path=rarc] (B) ++(-120:3cm) arc (-120:-240:3cm);\n\\path [name intersections={of=larc and rarc,by={b,t}}];\n\\fill (t) node[above right,xshift=-2pt,yshift=5pt] {$C$} circle[radius=3pt];\n\\fill (b) node[below left,xshift=2pt,yshift=-5pt] {$D$} circle[radius=3pt];\n\\draw (A) -- (t);\n\\draw (B) -- (t);\n\\end{scope}\n\\begin{scope}[xshift=12cm]\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\draw[name path=larc] (A) ++(-80:4cm) arc (-80:80:4cm);\n\\draw[name path=rarc] (B) ++(-100:4cm) arc (-100:-260:4cm);\n\\path [name intersections={of=larc and rarc,by={b,t}}];\n\\fill (t) node[above right,xshift=-2pt,yshift=3pt] {$C$} circle[radius=3pt];\n\\fill (b) node[below left,xshift=2pt,yshift=-3pt] {$D$}circle[radius=3pt];\n\\draw (A) -- (t);\n\\draw (B) -- (t);\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\nThe left diagram above shows that for the construction with the fixed compass the triangle will be isosceles, but not necessarily equilateral.\n\nThis construction of an equilateral triangle is the first proposition in Euclid's \\emph{Elements}. The second proposition shows how to copy a given line segment $\\overline{AB}$ to a segment of the same length, one of whose end points is a given point $C$. Therefore, a fixed compass adds no additional capability. Toussaint \\cite{toussaint} showed that many incorrect constructions for this proposition have been given. In fact, it was Euclid who gave a correct construction! The following section presents Euclid's construction and the proof of its correctness. Then I show an incorrect construction that can be found even in modern textbooks.\n\n\\section{Euclid's construction for copying a line segment}\n\n\\textbf{Theorem:} Given a line segment $\\overline{AB}$ and a point $C$, a line segment can be constructed (using a collapsing compass) at $C$ whose length is equal to the length of $\\overline{AB}$:\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.4]\n\\begin{scope}\n\\coordinate (C) at (0,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (5.5,2);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\end{scope}\n\\begin{scope}[xshift=12cm]\n\\coordinate (C) at (0,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (5.5,2);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\draw (A) -- (C);\n\\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);\n\\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);\n\\path [name intersections={of=larc and rarc,by={d,D}}];\n\\fill (D) node[above] {$D$} circle[radius=3pt];\n\\draw (A) -- (D);\n\\draw (C) -- (D);\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\n\\textbf{Construction:}\n\nConstruct the line segment from $A$ to $C$.\n\nConstruct an equilateral triangle whose base is $\\overline{AC}$ (right diagram above). Label the third vertex $D$. By Euclid's first proposition, the triangle can be constructed using a collapsing compass.\n\nConstruct a ray that is a continuation of $\\overline{DA}$ and a ray that is a continuation of $\\overline{DC}$ (left diagram below).\n\nConstruct a circle centered at $A$ with radius $\\overline{AB}$. Label the intersection of the circle and the ray $\\overline{DA}$ by $E$ (right diagram below).\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.4]\n\\begin{scope}\n\\coordinate (C) at (0,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (5.5,2);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\draw (A) -- (C);\n\\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);\n\\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);\n\\path [name intersections={of=larc and rarc,by={d,D}}];\n\\fill (D) node[above] {$D$} circle[radius=3pt];\n\\draw (A) -- (D);\n\\draw (C) -- (D);\n\\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);\n\\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);\n\\end{scope}\n\\begin{scope}[xshift=12cm]\n\\coordinate (C) at (0,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (5.5,2);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\draw (A) -- (C);\n\\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);\n\\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);\n\\path [name intersections={of=larc and rarc,by={d,D}}];\n\\fill (D) node[above] {$D$} circle[radius=3pt];\n\\draw (A) -- (D);\n\\draw (C) -- (D);\n\\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);\n\\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);\n\\node[draw,circle through=(B),name path=c1] at (A) {};\n\\path [name intersections={of=c1 and ray1,by={E,e}}];\n\\fill (E) node[right,xshift=2pt,yshift=-2pt] {$E$} circle[radius=3pt];\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\nConstruct a circle centered at $D$ with radius $\\overline{DE}$. Label the intersection of the circle and the ray $\\overline{DC}$ by $F$:\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.4]\n\\coordinate (C) at (0,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (5.5,2);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- node[above] {$x$} (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\draw (A) -- (C);\n\\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);\n\\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);\n\\path [name intersections={of=larc and rarc,by={d,D}}];\n\\fill (D) node[above] {$D$} circle[radius=3pt];\n\\draw (A) -- node[right] {$y$} (D);\n\\draw (C) -- node[left] {$y$} (D);\n\\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);\n\\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);\n\\node[draw,circle through=(B),name path=c1] at (A) {};\n\\path [name intersections={of=c1 and ray1,by={E,e}}];\n\\fill (E) node[right,xshift=2pt,yshift=-2pt] {$E$} circle[radius=3pt];\n\\node[draw,circle through=(E),name path=c2] at (D) {};\n\\path [name intersections={of=c2 and ray2,by={F,f}}];\n\\fill (F) node[left,xshift=-2pt,yshift=-2pt] {$F$} circle[radius=3pt];\n\\path (A) -- node[right] {$x$} (E);\n\\path (C) -- node[left] {$x$} (F);\n\\end{tikzpicture}\n\\end{center}\n\n\\textbf{Claim:} The length of the line segment $\\overline{CF}$ is equal to the length of $\\overline{AB}$.\n\n\\textbf{Proof:} $\\overline{DC}=\\overline{DA}$ because $\\triangle ACD$ is equilateral. $\\overline{AE}=\\overline{AB}$ because they are radii of the same circle centered at $A$. $\\overline{DF}=\\overline{DE}$ because they are radii of the same circle centered at $D$. Therefore, the length of the line segment $\\overline{CF}$ is:\n\\[\n\\overline{CF}=\\overline{DF}-\\overline{DC}=\\overline{DE}-\\overline{DC}=\\overline{DE}-\\overline{DA}=\\overline{AE}=\\overline{AB}\\,.\n\\]\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{An incorrect construction for copying a line segment}\\label{s.erroneous}\n\n\\textbf{Construction(\\cite{rusty}):}\n\nConstruct a circle centered at $A$ with radius $\\overline{AB}$:\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.4]\n\\begin{scope}\n\\coordinate (C) at (-2,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (4.5,1.5);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\end{scope}\n\\begin{scope}[xshift=12cm]\n\\coordinate (C) at (-2,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (4.5,1.5);\n\\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];\n\\node[draw,circle through=(B),name path=c1] at (A) {};\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\nConstruct a circle centered at $A$ with radius $\\overline{AC}$ and a circle centered at $C$ with radius $\\overline{AC}=\\overline{CA}$. Label the intersections of the two circles $E,F$. Label the intersection of the circle centered at $C$ and the circle centered at $A$ with radius $\\overline{AB}$ by $D$:\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.5]\n\\coordinate (C) at (-2,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (4.5,1.5);\n\\draw (A) node[below right] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[left,xshift=-2pt] {$C$} circle[radius=3pt];\n\\node[draw,circle through=(B),name path=c1] at (A) {};\n\\node[draw,circle through=(C),name path=c2] at (A) {};\n\\node[draw,circle through=(A),name path=c3] at (C) {};\n\\path [name intersections={of=c1 and c3,by={D,f}}];\n\\path [name intersections={of=c2 and c3,by={E,F}}];\n\\fill (D) node[below right,xshift=4pt] {$D$} circle[radius=3pt];\n\\fill (E) node[above,yshift=2pt] {$E$} circle[radius=3pt];\n\\fill (F) node[below,yshift=-2pt] {$F$} circle[radius=3pt];\n\\end{tikzpicture}\n\\end{center}\n\nConstruct a circle centered at $E$ with radius $ED$. Label the intersection of this circle with the circle centered at $A$ with radius $AC$ by $G$:\n\n\\begin{center}\n\\begin{tikzpicture}[scale=0.5]\n\\coordinate (C) at (-2,0);\n\\coordinate (A) at (2.5,0);\n\\coordinate (B) at (4.5,1.5);\n\\draw (A) node[below right] {$A$} -- (B) node[right] {$B$};\n\\fill (A) circle[radius=3pt];\n\\fill (B) circle[radius=3pt];\n\\fill (C) node[below left] {$C$} circle[radius=3pt];\n\\node[draw,circle through=(B),name path=c1] at (A) {};\n\\node[draw,circle through=(C),name path=c2] at (A) {};\n\\node[draw,circle through=(A),name path=c3] at (C) {};\n\\path [name intersections={of=c1 and c3,by={D,f}}];\n\\path [name intersections={of=c2 and c3,by={E,F}}];\n\\fill (D) node[below right,xshift=4pt] {$D$} circle[radius=3pt];\n\\fill (E) node[above,yshift=2pt] {$E$} circle[radius=3pt];\n\\fill (F) node[below,yshift=-2pt] {$F$} circle[radius=3pt];\n\\node[draw,circle through=(D),name path=c4] at (E) {};\n\\path [name intersections={of=c2 and c4,by={g,G}}];\n\\fill (G) node[below left,xshift=-4pt] {$G$} circle[radius=3pt];\n\\draw[dashed] (C) -- (G);\n\\draw[dashed] (A) -- (D);\n\\draw[thick,dotted] (A) -- (G) -- (E) -- cycle;\n\\draw[thick,dotted] (C) -- (D) -- (E) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\n\\textbf{Claim:} The length of the line segment $\\overline{GC}$ is equal to the length of $\\overline{AB}$.\n\n\\textbf{Proof:} $\\overline{CD}=\\overline{CE}$ are radii of the circle centered at $C$. $\\overline{AE}=\\overline{AG}$ are radii of the (larger) circle centered at $A$. $\\overline{CD} = \\overline{CE} = \\overline{AE} = \\overline{AG}$ since the radii of the two circles are $\\overline{AC}= \\overline{CA}$. $\\overline{EG} = \\overline{ED}$ are radii of the circle centered at $E$. Therefore, $\\triangle EAG\\cong \\triangle DCE$ by side-side-side so $\\angle GEA = \\angle DEC$.\n\n$\\angle GEC = \\angle GEA \\!-\\!\\angle CEA = \\angle DEC\\!-\\!\\angle CEA = \\angle DEA$. Therefore, $\\triangle ADE\\cong\\triangle CGE$ by side-angle-side. $\\overline{AB}=\\overline{AD}$ are radii of the smaller circle centered at $A$, so $\\overline{CG}=\\overline{AD}=\\overline{AB}$.\n\n\nIs there an error in the proof? No! But there is a problem because the equality $\\overline{AB}=\\overline{GC}$ holds only when the length of $\\overline{AB}$ is less that the length of $\\overline{AC}$. In contrast, Euclid's construction and proof are true, independent of the relative lengths of  $\\overline{AB}$ and $\\overline{AC}$, and independent of the position of the point $C$ relative to the line segment $\\overline{AB}$ \\cite{toussaint}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{A ``simpler'' construction for copying a line segment}\n\nGiven a line segment $\\overline{AB}$ and a point $C$, if we can build a parallelogram with these three points as its vertices, we obtain a line segment with $C$ at one end whose length is equal to the length of $\\overline{AB}$ (left diagram):\n\\begin{center}\n\\begin{tikzpicture}[scale=0.7]\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\coordinate (C) at (5,2);\n\\draw (A) -- (B);\n\\path (A) -- node[above] {$x$} (B);\n\\fill (A) node[below left] {$A$} circle[radius=2pt];\n\\fill (B) node[below] {$B$} circle[radius=2pt];\n\\fill (C) node[above] {$C$} circle[radius=2pt];\n\\draw (B) -- node[right] {$y$} (C);\n\\coordinate (D) at ($(C)+(-40mm,0cm)$);\n\\draw (D) -- node[above] {$x$} (C);\n\\draw (A) -- node[left] {$y$} (D);\n\\fill (D) node[above] {$D$} circle[radius=2pt];\n\\begin{scope}[xshift=12cm]\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\coordinate (C) at (5,2);\n\\draw ($ (B) ! 1.2 ! (A) $) -- ($ (A) ! 1.5 ! (B) $);\n\\path (A) -- (B);\n\\fill (A) node[below left,xshift=-4pt] {$A$} circle[radius=2pt];\n\\fill (B) node[below] {$B$} circle[radius=2pt];\n\\fill (C) node[above] {$C$} circle[radius=2pt];\n\\draw (B) -- (C);\n\\draw[name path=ray1] ($(C)+(-5cm,0cm)$) -- ($(C)+(1cm,0cm)$);\n\\draw[name path=ray2] ($(A)+(-.25,-.65)$) -- ($(A)+(1,2.6)$);\n\\path [name intersections={of=ray1 and ray2,by={D}}];\n\\fill (D) node[above left] {$D$} circle[radius=2pt];\n\\coordinate (E) at (C |- B);\n\\draw[thick,dashed] (C) -- (E);\n\\fill (E) node[below] {$E$} circle[radius=2pt];\n\\draw[rotate=-90] (C) rectangle +(10pt,10pt);\n\\draw (E) rectangle +(10pt,10pt);\n\\coordinate (F) at ($(A)!(B)!(D)$);\n\\fill (F) circle[radius=2pt];\n\\draw[thick,dashed] (B) -- (F);\n\\draw[rotate=-24] (F) rectangle +(10pt,10pt);\n\\draw[rotate=67] (B) rectangle +(10pt,10pt);\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\nThis construction can be found in \\cite[pp. 207--208]{roads}.\n\n\\textbf{Construction (right diagram):}\n\nConstruct the line segment from $B$ to $C$. Construct an altitude from $C$ to the line containing the line segment $\\overline{AB}$. Label the intersection by $E$. Construct an altitude to the line segment $\\overline{CE}$ at $C$. This line is parallel to $\\overline{AB}$. Use a similar method to construct a line parallel to $\\overline{BC}$ through $A$. Label the intersection of the two lines by $D$.\n\n$\\overline{AD}\\|\\overline{BC}$, $\\overline{AB}\\|\\overline{DC}$ and by definition $\\overline{ABCD}$ is a parallelogram, so $\\overline{AB}= \\overline{CD}$ as required.\n\n\\textbf{Construction with a collapsing compass:} It is possible to construct an altitude to the line $l$ through a given point $C$ with a collapsing compass. Construct a circle centered at $C$ with a radius that is greater than the distance of $C$ from $l$. Label the intersections with $l$ by $D,E$. Construct circles centered at $D,E$ with radii $\\overline{DC} = \\overline{EC}$. The line connecting the intersections $C,F$ of the circles centered at $D,E$  is an altitude through $C$.\n\\begin{center}\n\\begin{tikzpicture}[scale=0.5]\n\\coordinate (A) at (0,0);\n\\coordinate (B) at (4,0);\n\\coordinate (C) at (5,2);\n\\draw[name path=ray] ($ (B) ! 1.5 ! (A) $) -- node[very near start,above] {$l$} ($ (A) ! 2.5 ! (B) $);\n%\\fill (A) node[below] {$A$} circle[radius=3pt];\n%\\fill (B) node[below] {$B$} circle[radius=3pt];\n\\fill (C) node[right] {$C$} circle[radius=3pt];\n\\draw[name path=arc] (C) ++(-160:3.5cm) arc (-160:-20:3.5cm);\n\\path [name intersections={of=arc and ray,by={D,E}}];\n\\fill (D) node[below left] {$D$} circle[radius=3pt];\n\\fill (E) node[below right] {$E$} circle[radius=3pt];\n\\draw[name path=larc] (D) ++(-60:3.5cm) arc (-60:60:3.5cm);\n\\draw[name path=rarc] (E) ++(-120:3.5cm) arc (-120:-240:3.5cm);\n\\path [name intersections={of=larc and rarc,by={b,t}}];\n\\fill (b) node[right] {$F$} circle[radius=3pt];\n\\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);\n\\end{tikzpicture}\n\\end{center}\nThe proof the correctness of this construction is much more difficult than Euclid's proof of his construction.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Don't trust a diagram}\n\nWe can prove that \\emph{all} triangles are isosceles!\n\\begin{center}\n\\begin{tikzpicture}[scale=1.1]\n\\coordinate (P) at (0,0);\n\\node[xshift=4mm,yshift=1mm] at (P) {$P$};\n\\coordinate [label=left:$B$] (B)  at (-2,-2);\n\\coordinate [label=right:$C$] (C)  at (4,-2);\n\\coordinate [label=above:$A$] (A)  at (-1,2);\n\\node[below,yshift=-12pt,xshift=2pt] at (A) {$\\alpha$};\n\\node[below,yshift=-12pt,xshift=15pt] at (A) {$\\alpha$};\n\\draw (A) -- (B);\n\\draw (A) -- (C);\n\\draw (B) -- (C);\n\\draw (A) -- (P);\n\\draw (B) -- (P);\n\\draw (C) -- (P);\n\\coordinate[label=left:$E$] (E) at ($ (A) ! .44 ! (B) $);\n\\draw[rotate=-100] (E) rectangle +(4pt,4pt);\n\\draw (P) -- (E);\n\\coordinate (F) at ($ (A) ! .33 ! (C) $);\n\\node[right,xshift=2pt,yshift=2pt] at (F) {$F$};\n\\draw[rotate=-132] (F) rectangle +(4pt,4pt);\n\\draw (P) -- (F);\n\\coordinate[label=below:$D$] (D) at ($ (B) ! .33 ! (C) $);\n\\draw (D) rectangle +(4pt,4pt);\n\\draw (P) -- (D);\n\\node[left] at ($ (A) ! .5 ! (E) $) {};\n\\node[left] at ($ (B) ! .5 ! (E) $) {};\n\\node[below] at ($ (B) ! .5 ! (D) $) {$a$};\n\\node[below] at ($ (C) ! .5 ! (D) $) {$a$};\n\\node[right,xshift=2pt] at ($ (A) ! .5 ! (F) $) {};\n\\node[right,xshift=2pt] at ($ (C) ! .5 ! (F) $) {};\n\\foreach \\n in {A,B,C,D,E,F,P} {\n  \\fill (\\n) circle[radius=1pt];\n}\n\\end{tikzpicture}\n\\end{center}\nGiven an arbitrary triangle $\\triangle ABC$, let $P$ be the intersection of the angle bisector of $\\angle BAC$ and the perpendicular bisector of $\\overline{BC}$. Label by $D,E,F$ the intersections of the altitudes from $P$ to the sides $\\overline{BC}, \\overline{AB}, \\overline{AC}$. $\\triangle APF\\cong \\triangle APE$ because they are right triangles with equal angles $\\alpha$ and a common side $\\overline{AP}$.\n\n$\\triangle DPC\\cong \\triangle DPB$ by side-angle-side because $\\overline{PD}$ is a common side, $\\angle PDB=\\angle PDC$ are right angles and $\\overline{BD}=\\overline{DC}=a$ because $\\overline{PD}$ is the perpendicular bisector of $\\overline{BC}$. $\\triangle EPB\\cong \\triangle FPC$ by side-side-angle in a right triangle, because $\\overline{EP}=\\overline{PF}$ by the first congruence and $\\overline{PB}=\\overline{PC}$ by the second congruence. By combining the equations we get that $\\triangle ABC$ is isoceles:\n\\[\n\\overline{AB}= \\overline{AE}+\\overline{EB}=\\overline{AF}+\\overline{FC} =\\overline{AC}\\,.\n\\]\n\\newpage\n\nThe problem with the proof is that the diagram is incorrect because point $P$ is \\emph{outside} the triangle, as can be seen from the following diagram:\n\n\\begin{center}\n\\begin{tikzpicture}\n\\coordinate (B) at (0,0);\n\\coordinate (C) at (8,0);\n\\path[name path=ba] (B) -- +(70:6);\n\\path[name path=ca] (C) -- +(140:8.5);\n\\path [name intersections={of=ba and ca,by={A}}];\n\\draw (B) -- (C) -- (A) -- cycle;\n\\fill (A) circle(1pt)\n  node[above] {$A$}\n  node[below,yshift=-12pt] {$\\alpha$}\n  node[below right,xshift=6pt,yshift=-12pt] {$\\alpha$};\n\\fill (B) circle(1pt) node[left]  {$B$};\n\\fill (C) circle(1pt) node[right] {$C$};\n\\draw[name path=angle] (A) -- +(-75:9);\n\\draw ($(B)!.5!(C)$) -- +(0,3);\n\\draw[name path=perp] ($(B)!.5!(C)$) -- +(0,-3.5);\n\\path [name intersections={of=angle and perp,by={X}}];\n\\fill (X) circle(1pt);\n\\draw (4,0) rectangle +(8pt,8pt);\n\\end{tikzpicture}\n\\end{center}\n", "meta": {"hexsha": "c3b1168f363064fb677d03abdd6f241c75ebabdb", "size": 22589, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "collapse.tex", "max_stars_repo_name": "motib/constructions", "max_stars_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-07T15:57:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-07T15:57:52.000Z", "max_issues_repo_path": "collapse.tex", "max_issues_repo_name": "motib/constructions", "max_issues_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "collapse.tex", "max_forks_repo_name": "motib/constructions", "max_forks_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.8939393939, "max_line_length": 644, "alphanum_fraction": 0.648501483, "num_tokens": 8123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836382, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.44660057150369}}
{"text": "\\documentclass[../notes.tex]{subfiles}\n\n\\pagestyle{main}\n\\renewcommand{\\chaptermark}[1]{\\markboth{\\chaptername\\ \\thechapter\\ (#1)}{}}\n\\setcounter{chapter}{35}\n\n\\begin{document}\n\n\n\n\n\\chapter{Diffraction}\n\\section{Single Slit Diffraction}\n\\begin{itemize}\n    \\item \\marginnote{8/17:}Shining light through only one slit still yields an interference pattern.\n    \\item We explain this with \\textbf{diffraction}.\n    \\item Finding the location of minima on the screen:\n    \\begin{figure}[h!]\n        \\centering\n        \\begin{tikzpicture}\n            \\footnotesize\n            \\draw (0,-3) -- (0,-1) (-0.1,0) -- (0.1,0) (0,1) -- (0,3);\n            \\draw [very thin,dashed] (0,0) coordinate (O) -- (1,0) coordinate (N);\n    \n            \\draw [blx,very thick]\n                (-1.5,-2) -- ++(0,4)\n                (-2,-2) -- ++(0,4)\n                (-2.5,-2) -- ++(0,4)\n            ;\n    \n            \\draw [rex,thick,-latex] (0,1) node[circle,fill,inner sep=1.5pt,label={[yshift=2pt,black]below:$P_1$}]{} -- node[above,black]{$r_1$} ++(2,1);\n            \\draw [rex,thick,-latex] (0,0) node[circle,fill,inner sep=1.5pt,label={[yshift=2pt,black]below:$P_2$}]{} -- node[above,black]{$r_2$} ++(2,1) coordinate (r0);\n    \n            \\draw [very thin,|-|] (-1.1,-1) -- node[left]{$a$} ++(0,2);\n            \\draw [very thin,|-|] (-0.5,-1) -- node[left]{$\\frac{a}{2}$} ++(0,1);\n            \\draw [very thin,|-|] (-0.5,0) -- node[left]{$\\frac{a}{2}$} ++(0,1);\n            \\pic [draw,angle eccentricity=1.3,pic text={$\\theta$}] {angle=N--O--r0};\n        \\end{tikzpicture}\n        \\caption{Finding diffraction minima.}\n        \\label{fig:diffMinima}\n    \\end{figure}\n    \\begin{itemize}\n        \\item Let the one slit have width $a$.\n        \\item Only the part of the wavefront that aligns with the slit will pass through. However, according to Huygen's principle, when the light wave reaches the slit, it will act like infinitely many point sources of light all along the length of the slit.\n        \\item Consider two specific rays $r_1$ and $r_2$ emanating from the slit in same direction, one at the top and one in the middle. We know that if they are oriented at an angle that makes $\\Delta r=\\lambda/2$, then they cancel out.\n        \\item Generalizing, if any two rays satisfy $\\frac{a}{2}\\sin\\theta=\\lambda/2$ (i.e., satisfy $a\\sin\\theta=\\lambda$), then they will cancel.\n        \\item Indeed, every $\\theta$ satisfying $a\\sin\\theta=\\lambda$ will cancel: Consider all the rays originating from every point in the slit that point in the $\\theta$-direction, and notice that for any point in the slit, there will be a point $a/2$ units away from it; the rays from these two points will cancel. Thus, every ray is associated with another ray that cancels it out, guaranteeing that $\\theta$ is an interference minimum.\n        \\item Note that if $\\theta$ yields an interference minimum, then $\\theta$ satisfying $a\\sin\\theta=m\\lambda$ where $m\\in\\N$ will yield interference minima.\n    \\end{itemize}\n\\end{itemize}\n\n\n\n\\section{Intensity of Single Slit Diffraction}\n\\begin{itemize}\n    \\item Like before, $\\theta=\\ang{0}$ gives a \\textbf{central diffraction maximum}.\n    \\item Finding the intensity maxima in general:\n    \\begin{figure}[h!]\n        \\centering\n        \\begin{tikzpicture}[\n            every node/.style={black}\n        ]\n            \\footnotesize\n            \\draw (0,-3) -- (0,-1) (-0.1,0) -- (0.1,0) (0,1) -- (0,3);\n            \\draw [very thin,dashed] (0,0) coordinate (O) -- (1,0) coordinate (N);\n\n            \\draw [semithick,->] (-0.3,0) -- ++(0,0.7) node[left]{$y$};\n\n            \\draw [rex,thick,-latex] (0,0.7) -- node[above]{$r$} ++(2,1);\n            \\draw [rex,thick,-latex] (0,0) -- node[above]{$r_0$} ++(2,1) coordinate (r0);\n\n            \\draw [very thin,|-|] (-0.7,-1) -- node[left]{$a$} ++(0,2);\n            \\pic [draw,angle eccentricity=1.3,pic text={$\\theta$}] {angle=N--O--r0};\n        \\end{tikzpicture}\n        \\caption{Finding diffraction maxima.}\n        \\label{fig:diffMaxima}\n    \\end{figure}\n    \\begin{itemize}\n        \\item To find the intensity maxima, we derive an equation for the intensity in general as a function of $\\theta$.\n        \\item To do so, we sum up every infinitesimal contribution of all the points along the slit with an integral, as follows.\n        \\item Since $\\Delta r=y\\sin\\theta$ (see Figure \\ref{fig:diffMaxima}), the wave function for the electric field wave along the arbitrary ray $r$ a distance $y$ from the central ray is given by\n        \\begin{align*}\n            \\cos(kr-\\omega t) &= \\cos(k[r_0+\\Delta r]-\\omega t)\\\\\n            &= \\cos\\left( kr_0-\\omega t+\\frac{2\\pi}{\\lambda}\\cdot y\\sin\\theta \\right)\n        \\end{align*}\n        \\item It follows that the electric field $E$ at some point $P$ on the screen is given by\n        \\begin{align*}\n            E &= A\\int_{-a/2}^{a/2}\\cos\\left( kr_0-\\omega t+\\frac{2\\pi\\sin\\theta}{\\lambda}\\cdot y \\right)\\dd{y}\\\\\n            &= \\frac{C}{\\sin\\theta}\\cos(kr_0-\\omega t)\\sin\\left( \\frac{\\pi a}{\\lambda}\\sin\\theta \\right)\n        \\end{align*}\n        where $C$ represents a bunch of constants.\n        \\item Thus, since $I\\propto E^2$,\n        \\begin{equation*}\n            I \\propto \\frac{\\sin^2\\left( \\frac{\\pi a}{\\lambda}\\sin\\theta \\right)}{\\sin^2\\theta}\n        \\end{equation*}\n        \\item Additionally, if we define $\\alpha=\\frac{\\pi a}{\\lambda}\\sin\\theta$, then\n        \\begin{equation*}\n            I = I_\\text{max}\\frac{\\sin^2\\alpha}{\\alpha^2}\n        \\end{equation*}\n        \\item Notice that $\\theta\\to 0$ implies $\\alpha\\to 0$ implies $\\sin(\\alpha)/\\alpha\\to 1$ implies $I\\to I_\\text{max}$, as expected.\n        \\item Furthermore, since $\\sin\\alpha$ is bounded but $\\alpha$ is not, $\\sin^2(\\alpha)/\\alpha^2$ yields a graph of maxima that drop off in intensity as $\\alpha\\to\\pm\\infty$.\n    \\end{itemize}\n    \\item \\textbf{Diffraction}: Bending of a light wave as it goes through a small slit.\n    \\begin{itemize}\n        \\item As slit width $a$ decreases, minima spread out.\n    \\end{itemize}\n\\end{itemize}\n\n\n\n\\section{Combining Interference and Diffraction}\n\\begin{itemize}\n    \\item \\marginnote{8/19:}Every place you have a diffraction minimum, the wave that gets to the screen has 0 amplitude.\n    \\begin{itemize}\n        \\item If you have a point $P$ that's a diffraction minimum of both slits, interference doesn't matter --- you're going to have no intensity at $P$.\n    \\end{itemize}\n    \\item Slits $S_1$ and $S_2$ have the same diffraction pattern, just shifted by $d$.\n    \\begin{itemize}\n        \\item But if the diffraction pattern is large relative to $d$, as it usually is, we can neglect the shift.\n    \\end{itemize}\n    \\item Total intensity:\n    \\begin{figure}[h!]\n        \\centering\n        \\begin{tikzpicture}[\n            every node/.append style={black}\n        ]\n            \\footnotesize\n            \\begin{scope}[yshift=2cm]\n                \\draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\\theta)$};\n                \\draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\\theta$};\n    \n                \\draw [orx,thick,xscale=2/pi] plot[domain=-4.33:4.33,samples=500,smooth] (\\x,{2*cos(4*\\x r)^2});\n                \\node at (1,2.4) {\\normalsize 2 slits};\n            \\end{scope}\n            \\begin{scope}[yshift=-2cm]\n                \\draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\\theta)$};\n                \\draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\\theta$};\n    \n                \\draw [orx,thick,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)});\n                \\draw [orx,thick,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)});\n                \\node at (1,2.4) {\\normalsize 1 slit};\n            \\end{scope}\n    \n            \\begin{scope}[xshift=10cm]\n                \\draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\\theta)$};\n                \\draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\\theta$};\n    \n                \\draw [orx,thick,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)*cos(4*\\x r)^2});\n                \\draw [orx,thick,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)*cos(4*\\x r)^2});\n                \\draw [orx,thick,dashed,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)});\n                \\draw [orx,thick,dashed,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\\x,{(2*cos(\\x r)^2)/(\\x*\\x)});\n            \\end{scope}\n    \n            \\draw [help lines,->,shorten >=5mm] (4,2) -- (6.5,0);\n            \\draw [help lines,->,shorten >=5mm] (4,-2) -- (6.5,0);\n        \\end{tikzpicture}\n        \\caption{Intensity considering both interference and diffraction.}\n        \\label{fig:intensityInterferenceDiffraction}\n    \\end{figure}\n    \\begin{itemize}\n        \\item We have that $I(\\theta)=I(\\theta)_\\text{2 slits' interference}\\times\\text{diffraction envelope}$.\n    \\end{itemize}\n\\end{itemize}\n\n\n\n\\section{Circular Hole}\n\\begin{itemize}\n    \\item Consider light passing through a circular hole of diameter $a$.\n    \\begin{itemize}\n        \\item This yields concentric rings of intensity separated by nodes, i.e., a slit diffraction pattern that accounts for slits of every angle added on top of each other.\n        \\item As $a$ gets smaller, the central diffraction maximum gets bigger.\n    \\end{itemize}\n    \\item \\textbf{Slit}: A one-dimensional opening.\n    \\item \\textbf{Aperture}: A two-dimensional opening.\n    \\item We can no longer use $a\\sin\\theta=m\\lambda$; we have to consider what happens with the extra dimensions.\n    \\begin{itemize}\n        \\item When we redo the calculation in two dimension, we get\n        \\begin{equation*}\n            a\\sin\\theta = 1.22m\\lambda\n        \\end{equation*}\n        for $m\\in\\Z$.\n        \\item If $\\theta$'s are small, then $\\theta_\\text{1st min}\\approx 1.22\\lambda/a$.\n        \\item Recall that $\\theta_\\text{1st min}=\\theta_\\text{$\\frac{1}{2}$ width of central max}$, so we can use this formula to estimate the width of the central maximum.\n    \\end{itemize}\n    \\item As light passes through your pupil (an aperture), it undergoes diffraction and gets bigger before impinging on your retina.\n    \\begin{figure}[h!]\n        \\centering\n        \\begin{tikzpicture}\n            \\footnotesize\n            \\draw\n                (3,0) -- (5,1) -- (3,2)\n                (3.55,1) ellipse (3mm and 7mm)\n                (4.5,0.75) to[out=120,in=-120] (4.5,1.25)\n            ;\n            \\filldraw [draw=blx,very thick,fill=blz] (3.55,1) coordinate (pupil) ellipse (2pt and 5pt);\n    \n            \\node (S1) [circle,fill=pix,inner sep=1.5pt,label={left:$S_1$}] at (0,1.6) {}\n                edge [orx,thick] ($(S1)!1.25!(pupil)$)\n            ;\n            \\node (S2) [circle,fill=pix,inner sep=1.5pt,label={left:$S_2$}] at (0,1.1) {}\n                edge [orx,thick] ($(S2)!1.25!(pupil)$)\n            ;\n    \n            \\pic [draw,angle radius=2cm,angle eccentricity=1.15,pic text={$\\theta_\\text{sep}$}] {angle=S1--pupil--S2};\n        \\end{tikzpicture}\n        \\caption{Distinguishing sources of light.}\n        \\label{fig:lightRetina}\n    \\end{figure}\n    \\begin{itemize}\n        \\item Thus, to be able to distinguish two sources of light, we require $\\theta_\\text{sep}\\geq\\theta_\\text{$\\frac{1}{2}$ width of central max}$.\n        \\item For this reason, bigger telescopes are used not only to collect more light but also to minimize the effects of diffraction.\n    \\end{itemize}\n    \\item \\textbf{Rayleigh criterion}: The condition for distinguishing sources of light, given by\n    \\begin{equation*}\n        \\theta_\\text{sep} \\geq 1.22\\lambda/a\n    \\end{equation*}\n    \\item Pinhole camera.\n    \\begin{itemize}\n        \\item For a sharp focus, you want a small pinhole, improving the geometry.\n        \\item But if you make it too small, diffraction will come into play.\n    \\end{itemize}\n\\end{itemize}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "6ec268ca58782421cb14cff88e71649c8b0c99ba", "size": 11940, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Chapter36/chapter36.tex", "max_stars_repo_name": "shadypuck/PHYS13300Notes", "max_stars_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/Chapter36/chapter36.tex", "max_issues_repo_name": "shadypuck/PHYS13300Notes", "max_issues_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Chapter36/chapter36.tex", "max_forks_repo_name": "shadypuck/PHYS13300Notes", "max_forks_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.3684210526, "max_line_length": 441, "alphanum_fraction": 0.5950586265, "num_tokens": 3832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.4466005603931184}}
{"text": "% use paper, or submit\n% use 11 pt (preferred), 12 pt, or 10 pt only\n\n%\\documentclass[letterpaper, preprint, paper,11pt]{AAS}\t% for preprint proceedings\n\\documentclass[letterpaper, paper,11pt]{AAS}\t\t% for final proceedings (20-page limit)\n%\\documentclass[letterpaper, paper,12pt]{AAS}\t\t% for final proceedings (20-page limit)\n%\\documentclass[letterpaper, paper,10pt]{AAS}\t\t% for final proceedings (20-page limit)\n%\\documentclass[letterpaper, submit]{AAS}\t\t\t% to submit to JAS\n\n\\usepackage{bm}\n\\usepackage{amsmath}\n\\usepackage{subfigure}\n%\\usepackage[notref,notcite]{showkeys}  % use this to temporarily show labels\n\\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=black, citecolor= black, urlcolor= black]{hyperref}\n\\usepackage{overcite}\n\\usepackage{footnpag}\t\t\t      \t% make footnote symbols restart on each page\n\\usepackage[outdir=./]{epstopdf}\n\n\\PaperNumber{XX-XXX}\n\n\\begin{document}\n\n\\title{GPS Based Inertial Navigation For Low-Thrust Spacecraft In Cislunar Space}\n\n\\author{Grant R. Hecht\\thanks{Graduate Student, Department of Mechanical and Aerospace Engineering, University at Buffalo, 240 Bell Hall, Buffalo, NY  14260-4400.}}\n\n\\maketitle{} \t\t\n\n\\begin{abstract}\n\tMissions to return to the Moon within the coming decade, which will involve manned and robotic spacecraft for extensive operations in lunar orbit and on the surface, require robust techniques for inertial navigation to ensure mission success. This paper investigates the feasibility of employing existing Earth based GPS navigation techniques for navigation in cislunar space. Both an Extended and Unscented Kalman Filter which employ GPS pseudorange and accelerometer measurements are developed and applied for inertial navigation of a low thrust spacecraft as it traverses from a geostationary transfer orbit to the target near-rectilinear halo orbit of the lunar gateway station, a key componant of NASA's Artemis Program. Through a Monte Carlo analysis, the performance of both developed filters are investigated and conclusions are drawn which point towards the overall feasibility of GPS based navigation for lunar missions, the best choice in filtering techniques, and methods which could improve the robustness of navigation in cislunar space. \n\\end{abstract}\n\n\\section{Introduction}\nInterest in manned and robotic missions to Earth's moon has been renewed with the advent of NASA's Artemis Program. As such, robust techniques for navigating spacecraft within cislunar space are necessary.  This project investigates the feasibility of employing pseudorange measurements from the existing GPS satellite constellation and IMU accelerometer measurements for navigating a low-thrust spacecraft as it spirals towards the target Near-Rectilinear Halo Orbit (NRHO) of the Artemis Lunar Gateway station, starting from a Geostationary Transfer Orbit (GTO) while employing both an Extended and Unscented Kalman Filter.\n\nA feasibility study is performed to investigate the robustness of GPS based inertial navigation for a spacecraft traversing from a GTO to the NRHO target of the Gateway station. Both an Extended Kalman Filter (EKF) and Unscented Kalman Filter (UKF) have been developed which employ GPS pseudorange and accelerometer measurements for estimating the inertial states (e.g., position and velocity) and mass of a spacecraft as it travels from the initial to target orbits. The true GTO to NRHO trajectory has been generated for a low-thrust spacecraft by employing Circular Restricted Three-Body Problem (CR3BP) dynamics, such that fuel use is minimized. The performance of both the EKF and UKF are analyzed through Monte Carlo analysis.\n\nThe remainder of this paper is organized as follows. First, the methodology used throughout this investigation is discussed including the technique used for generating the true trajectory along with GPS pseudorange and accelerometer measurement modeling. Next, both inertial navigation filters (i.e., the EKF and UKF) are presented. Finally, the performance of both developed filters is investigated through Monte Carlo analysis and conclusions are drawn on the best choice of estimation algorithm for cislunar inertial navigation as well as additional sensors that could improve performance. \n\n\n\\section{Methodology} \n\\subsection{True Trajectory Generation}\nThe true low-thrust trajectory traversed by the spacecraft has been generated with CR3BP dynamics and a fully continuous, constant specific impulse thrust model by employing the \\textit{indirect} approach to optimizing a spacecraft trajectory. Although many details of indirect optimal control are outside of the scope of this project, this category of trajectory optimization methods employ calculus of variations (COV) and Pontryagin's Maximum Principle (PMP) to analytically derive the necessary conditions of optimality. This process results in the formation of a two-point boundary value problem (TPBVP) which is solved by finding the set of time varying co-state (adjoint) variables at the initial epoch such that the boundary conditions are satisfied. \n\nFor the minimum-fuel trajectory optimization problem, the cost function is given by\n\\begin{equation}\n\tJ = \\frac{T_{max}}{c}\\int_{t_0}^{t_f}udt\n\\end{equation}\nwhere $T_{max}$ is the maximum thrust available to the spacecraft, $c$ is the exhaust velocity, $u$ is the thrust throttling factor, and $t_i$ and $t_f$ correspond to the initial and final epoch of the trajectory. The TPBVP, while employing nondiamentionalized CR3BP dynamics, is formulated such that we seek state and co-state trajectories that are a solution of\n\\begin{align}\n\t\\Dot{\\mathbf{y}} = \\begin{bmatrix} \\Dot{\\mathbf{x}} \\\\ \n\t\\Dot{\\boldsymbol{\\lambda}} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{v} \\\\ \n\t\\mathbf{g}(\\mathbf{r}) + \\mathbf{h}(\\mathbf{v}) - \\boldsymbol{\\lambda}_vuT_{max}/(\\lambda_vm) \\\\ \n\t-uT_{max}/c \\\\ \n\t-\\mathbf{G}^T\\boldsymbol{\\lambda}_v \\\\ \n\t-\\boldsymbol{\\lambda}_r - \\mathbf{H}^T\\boldsymbol{\\lambda}_v \\\\ \n\t-\\lambda_vuT_{max}/m^2\n\t\\end{bmatrix}\n\t\\label{eqn:full_ode}\n\\end{align}\nwhile satisfying \n\\begin{equation}\n\t\\begin{array}{ccc}\n\t\t\\mathbf{r}(t_i) - \\mathbf{r}_i = 0 & \\mathbf{v}(t_i) - \\mathbf{v}_i = 0 & m(t_i) - 1 = 0 \\\\\n\t\t\\mathbf{r}(t_f) - \\mathbf{r}_f = 0 & \\mathbf{v}(t_f) - \\mathbf{v}_f = 0 & \\lambda_m(t_f) = 0 \n\t\\end{array}\n\\label{eqn:state_cons}\n\\end{equation}\nwith optimal thrust direction unit vector and throttling factor given by Lawden's primer vector control law \\cite{Lawden_1964, Hecht_2021, Russell_2007}, where $\\mathbf{x} = [\\mathbf{r},\\mathbf{v},m]^T$ is the $7\\times1$ vector of the position, velociy, and mass states, $\\boldsymbol{\\lambda}=[\\boldsymbol{\\lambda}_r,\\boldsymbol{\\lambda_v},\\lambda_m]^T$ is the $7\\times1$ vector of introduced co-state variables, corresponding to each of the physical states,\n\\begin{equation}\n\t\\mathbf{g}(\\mathbf{r}) = \\begin{bmatrix}\n\tr_x - \\frac{(1 - \\mu)(r_x + \\mu)}{r_1^3} - \\frac{\\mu(r_x + \\mu - 1)}{r_2^3} \\\\\n\tr_y - \\frac{(1 - \\mu)r_y}{r_1^3} - \\frac{\\mu r_y}{r_2^3} \\\\\n\t-\\frac{(1 - \\mu)r_z}{r_1^3} - \\frac{\\mu r_z}{r_2^3}\n\t\\end{bmatrix}\n\\end{equation}\n\\begin{equation}\n\t\\mathbf{h}(\\mathbf{v}) = \\begin{bmatrix} 2v_y & -2v_x & 0 \\end{bmatrix}^T\n\\end{equation}\n\\begin{align}\n\tr_1 &= \\sqrt{(r_x + \\mu)^2 + r_y^2 + r_z^2} \\\\\n\tr_2 &= \\sqrt{(r_x + \\mu - 1)^2 + r_y^2 + r_z^2}\n\\end{align}\nand\n\\begin{align}\n\t\\mathbf{G} &= \\frac{\\partial \\mathbf{g}(\\mathbf{r})}{\\partial \\mathbf{r}} \\\\\n\t\\mathbf{H} &= \\frac{\\partial \\mathbf{h}(\\mathbf{v})}{\\partial \\mathbf{v}}\n\\end{align} \n\nThe primary difficulty in solving this TPBVP involves determining an initial guess for the co-state variable such that convergence with a Newton's Method based solver can be achieved. For this work, Particle Swarm Optimization (PSO) was used to find multiple candidate trajectories (each corresponding to a local minimum of the minimum fuel cost function) for a fixed time of flight of 15 days as described in Reference \\citenum{Hecht_2021} using spacecraft parameters shown in Table \\ref{tab:traj_params}. Then, the TPBVP was resolved repeatedly for each of the candidate trajectories while gradually altering the time of flight in the direction of decreasing fuel use until the optimal time of flight for each of the candidate trajectories was discovered. Finally, of the improved candidate trajectories, the most fuel optimal solution was chosen, which was found to use 127 kg of fuel over 33 days. Figure \\ref{fig:traj} displays this trajectory, where coasting arcs are shown in blue, thrusting arcs in red, the target NRHO in dashed black lines, and the locations of the Earth and Moon as black $\\times$ symbols. As can be seen, the trajectory consists of multiple spirals about the Earth with gradually increasing apogee before finally reaching the NRHO. Therefore, this trajectory will provide a good indication of the developed filters performance in both near Earth and cislunar space.  \n\n\\begin{table}[]\n\t\\centering\n\t\\caption{Low-Thrust Trajectory Parameters}\n\t\\label{tab:traj_params}\n\t\\begin{tabular}{ccc}\n\t\t\\hline\n\t\t\\hline\n\t\tParameter             \t\t & Value        & Units         \\\\ \n\t\t\\hline\n\t\tInitial Mass ($m_0$) \t\t & 1500 \t\t& kg            \\\\\n\t\tExhaust Velocity (c) \t\t & 29.43        & km/$\\text{s}$  \\\\\n\t\tSpecific Impulse ($I_{sp}$)  & 3000  \t\t& s             \\\\\n\t\tMax Thrust ($T_{max}$)       & 10  \t\t \t& N             \\\\\n\t\t%Time of Flight ($t_f-t_0$)   & 33.0      \t& days          \\\\\n\t\t\\hline \\hline\n\t\\end{tabular}\n\\end{table}\n\n\\begin{figure}[]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{./../../figures/iTraj.eps}\n\t\\caption{True Low-Thrust Trajectory in Inertial Reference Frame}\n\t\\label{fig:traj}\n\\end{figure}\n\nFinally, whereas the true trajectory was generated using nondiamentionalized CR3BP dynamics which employ a rotating reference frame, we require the trajectory to be defined with respect to an inertial reference frame with dimensional units when using it to evaluate the performance of the developed inertial navigation filters. Therefore, the trajectories position, velocity, and mass states are dimentionalized using the time, length, velocity, and mass units given in Table \\ref{tab:const_params} before rotation to the inertial frame according to \n\\begin{align}\n\t\\mathbf{r}^i &= \\mathbf{T}_{sy}^i\\mathbf{r}^{sy}  \\\\\n\t\\mathbf{v}^i &= \\mathbf{T}_{sy}^i\\mathbf{v}^{sy} + \\dot{\\mathbf{T}}_{sy}^i\\mathbf{r}^{sy}\n\\end{align}\nwhere superscripts $sy$ and $i$ are used to denote a vector defined with respect to the synodic (rotating) and inertial reference frames respectively and\n\\begin{align}\n\t\\mathbf{T}_{sy}^i &= \\begin{bmatrix}\n\t\t\\cos{\\theta} & -sin(\\theta) & 0 \\\\\n\t\t\\sin{\\theta} & \\cos{\\theta} & 0 \\\\\n\t\t0 & 0 & 1\n\t\\end{bmatrix} \\\\\n\t\\dot{\\mathbf{T}}_{sy}^i &= \\begin{bmatrix}\n\t\t-\\omega\\sin{\\theta} & -\\omega\\cos{\\theta} & 0 \\\\\n\t\t\\omega\\cos{\\theta} & -\\omega\\sin{\\theta} & 0 \\\\\n\t\t0 & 0 & 0\n\t\\end{bmatrix}\n\\end{align}\nwhere $\\theta$ and $\\omega$ are the angular rotation and rotational rate of the synodic reference frame with respect to the inertial frame respectively, where we select $\\theta$ such that the Moon is aligned along the $y$-axis of the Inertial frame at the final epoch of the true trajectory.\n\n\\begin{table}[]\n\t\\centering\n\t\\caption{CR3BP Units}\n\t\\label{tab:const_params}\n\t\\begin{tabular}{ccc}\n\t\t\\hline\n\t\t\\hline\n\t\tConstant             & Value                     & Units           \\\\ \n\t\t\\hline\n\t\tTime Unit (TU)       & $3.75162997\\times10^{5}$  & s               \\\\\n\t\tLength Unit (LU)     & $3.84400000\\times10^{5}$  & km              \\\\\n\t\tVelocity Unit (VU)      & $1.02462131$              & km/s            \\\\\n\t\tMass Unit (MU)       & $1500.0$                  & kg              \\\\\n\t\t\\hline \\hline\n\t\\end{tabular}\n\\end{table}\n\n\\subsection{Measurement Modeling}\\label{ssec:measmodeling}\n\\subsubsection{GPS Pseudoranges:}\nA common GPS pseudorange model is given by \\cite{Tapley_2004, Craft_2020}\n\\begin{align}\n\tp_{s,k} &= ||\\boldsymbol{\\rho}_{s/rk,k}|| + c(\\Delta t_k - \\Delta t_k^s) + \\phi_k + v_{GPS,k} \\\\\n\t\\boldsymbol{\\rho}_{s/rk,k} &= \\mathbf{r}_k^i + \\mathbf{T}_b^i\\mathbf{r}_{rx}^b - \\mathbf{r}_{s,k}^i + \\mathbf{T}_{b,s}^i\\mathbf{r}_{pc,s}^b\n\\end{align}\nwhere $p_{s,k}$ is the pseudorange generated from GPS satellite $s$ at time $t_k$, $\\Delta t$ is the GNSS receiver clock bias, $\\Delta t_k^s$ is the clock bias of GPS satellite $s$, $c$ is the speed of light in a vacuum, $\\phi_{s,k}$ is the ionospheric delay, and $v_{GPS,k}$ is the receiver white noise. The geometric range is the Euclidean norm of the vector from the phase center of the GPS transmitter and GNSS receiver phase center $\\boldsymbol{\\rho}_{s/rk,k}$, where $\\mathbf{r}_k^i$ is the inertial position of the satellite, $\\mathbf{T}_b^i(\\bar{\\mathbf{q}}_{m,k}) \\in SO(3)$ is the rotation from the body frame of the spacecraft to the inertial frame, $\\mathbf{r}_{rx}^b$ is the location of the GNSS receiver phase center in the spacecrafts body frame, $\\mathbf{r}_{s,k}^i$ is the inertial position of the center of mass of GPS satellite $s$, $\\mathbf{T}_{b,s}^i\\in SO(3)$ is the rotation from the body frame of GPS satellite $s$ to the inertial frame, and $\\mathbf{r}_{pc,s}^b$ is the location of the phase center in the GPS body frame.\n\nFor the purposes of this work, we assume the phase centers of both the GNSS receiver and all GPS transmitters are located at their respective spacecraft's center of mass (i.e., $\\mathbf{r}_{rx}^b = \\mathbf{r}_{tx}^b = \\mathbf{0}_{3\\times1}$), thereby decoupling attitude from the pseudorange measurements. We will also assume the GNSS receiver clock is perfect, such that $\\Delta t = 0$, and ionospheric effects are negligible. Therefore, our GPS pseudorange model reduces to\n\\begin{align}\n\tp_{s,k} &= ||\\mathbf{r}_k^i - \\mathbf{r}_{s,k}^i|| - c\\Delta t_k^s + v_{GPS,k}\n\\end{align}\nwith relevent partials required by the EKF given by\n\\begin{equation}\n\t\\frac{\\partial p_s}{\\partial \\mathbf{r}^i}\\bigg|_{\\mathbf{x}=\\mathbf{x}^*} \\approx \\frac{\\mathbf{r}_k^{i^T} - \\mathbf{r}_{s,k}^{i^T}}{||\\mathbf{r}_k^i - \\mathbf{r}_{s,k}^i||}\n\t\\label{eqn:ppart}\n\\end{equation}\nwhere $(\\cdot)^*_k$ is employed to indicated a term associated with the reference trajectory at time $t_k$. Also, note that this partial is an approximation as we choose to neglect the effect of deviations in the position vector $\\mathbf{r}_k^i$ on signal transmission time and therefore $\\mathbf{r}_{s,k}^i$.\n\nHigh precision ephemeris data projects provided by IGS \\cite{IGSproducts} are considered as truth and employed to compute the position of GPS satellites at signal transmission times when generating simulated GPS pseudorange measurements. Perturbed trajectory solutions from the same ephemerides are also employed when computing expected pseudorange measurements so as to simulate much less precise broadcast ephemeris. \n\nWhen simulating GPS pseudorange measurements or computing expected measurements within both of the investigated filters, it is important to take into account signal transmission delay. While we choose to ignore atmospheric effects on the rate of signal transmission for simplicity, the velocity of signal propagation through the vacuum of space is still capped at the speed limit of the universe, i.e., the speed of light ($c=299792458$ m/s). Therefore, the time of signal transmission and reception will differ slightly and given the time of signal reception, $t_k$, the transmission time from satellite $s$, $t_{tx,s}$, can be found by determining the zero of the nonlinear equation given by \n\\begin{equation}\n\tf(t_{tx,s}) = ||\\mathbf{r}_k^i - \\mathbf{r}_{s,k}^i|| - c(t_k - t_{tx,s})\n\\end{equation}\n\nIt is also important to note that IGS ephemeris data products are defined with respect to the Earth fixed IGS14 reference frame, and therefore must be rotated to the Geocentric Celestial Reference Frame (e.g., J200 frame) before they can be employed for inertial navigation. We perform this rotation with high precision by taking into account the Earth's polar motion, rotation, precession, and nutation as described by Vallado in Reference \\citenum{Vallado_2013}.\n\n\\subsubsection{Inertial Measurement Unit}\nIMU accelerometer measurements can be modeled as \n\\begin{equation}\n\t\\mathbf{a}_{m,k}^{IMU} = (\\mathbf{I} + \\mathbf{N}_a + \\mathbf{M}_a)(\\mathbf{I} + \\mathbf{S}_a)(\\mathbf{a}_k^{IMU} + \\mathbf{b}_{a,0} + \\mathbf{b}_{a,k} + \\mathbf{v}_{a,k})\n\\end{equation}\nwhere $\\mathbf{a}_k^{IMU}$ is the true acceleration experienced by the IMU within the IMU frame, $\\mathbf{b}_{a,0}$ is the startup bias of the accelerometer, $\\mathbf{b}_{a,k}$ is the bias of the accelerometer at $t_k$, $\\mathbf{v}_k$ is zero-mean white noise, $\\mathbf{S}_a$ is the scale factor error matrix, $\\mathbf{M}_a$ is the axes misalignment matrix, and $\\mathbf{N}_a$ is the axes nonorthogonality matrix \\cite{DeMars_2014}.\n\nFor the purposes of this investigation, we choose to simplify this model significantly, assuming most sources of error are negligible such that the measured acceleration in the IMU frame is given by \n\\begin{align}\n\t\\mathbf{a}_{m,k}^{IMU} = \\mathbf{a}_k^{IMU} + \\mathbf{v}_{a,k}\n\\end{align}\nWe will also assume the spacecraft body frame and IMU frame are always perfectly aligned with the inertial frame (i.e., $\\mathbf{a}_{m,k}^{IMU}=\\mathbf{a}_{m,k}^i$), thereby allowing the attitude of the spacecraft to be ignored as attitude estimation is outside of the scope of this work. \n\nThe relevant partials of the accelerometer measurements for the EKF, assuming perfectly spherical gravitational effects from both the Earth and Moon, are then given by\n\\begin{align}\n\t\\frac{\\partial \\mathbf{a}_{m}^i}{\\partial \\mathbf{r}^i}\\bigg|_{\\mathbf{x}=\\mathbf{x}^*} &= \\frac{\\mu}{r^3}\\left(\\frac{3}{r^2}\\mathbf{r}^i\\mathbf{r}^{i,T} - \\mathbf{I}\\right) + \\frac{\\mu_l}{r_{ls}^3}\\left(\\frac{3}{r_{ls}^2}\\mathbf{r}_{ls}^i\\mathbf{r}_{ls}^{i,T} - \\mathbf{I}\\right) \\label{eqn:apartr}\\\\\n\t\\frac{\\partial \\mathbf{a}_{m}^i}{\\partial m}\\bigg|_{\\mathbf{x}=\\mathbf{x}^*} &= -\\frac{u T_{max}}{m^2}\\boldsymbol{\\alpha}^i\n\t\\label{eqn:apartm}\n\\end{align}\nwhere $\\mathbf{r}_{ls}^i$ is the vector from the spacecraft to the Moon defined with respect to the inertial reference frame, $r$ and $r_{ls}$ are the Euclidean norm of $\\mathbf{r}^i$ and $\\mathbf{r}_{ls}^i$ respectively, $\\mu$ and $\\mu_l$ are the gravitational parameters of the Earth and Moon respectively, $T_{max}$ is the spacecrafts maximum possible thrust, $u$ is the thrust throttling factor, and $\\boldsymbol{\\alpha}^i$ is the direction of applied propulsive force.\n\n\\section{Inertial Navigation Filters}\nFor the development of both the EKF and UKF, we begin with the nonlinear dynamics and measurement models given by \\cite{Crassidis_2004}\n\\begin{align}\n\t\\dot{\\mathbf{x}}(t) &= \\mathbf{f}(\\mathbf{x}(t), \\mathbf{u}(t),t) + \\mathbf{G}(t)\\mathbf{w}(t), \\hspace{2mm} \\mathbf{w}(t)\\sim N(\\mathbf{0},\\mathbf{Q}(t)) \\\\\n\t\\tilde{\\mathbf{y}}_k &= \\mathbf{h}(\\mathbf{x}_k) + \\mathbf{v}_k, \\hspace{2mm} \\mathbf{v}_k \\sim N(\\mathbf{0}, \\mathbf{R}_k) \n\\end{align}\nwhere $\\mathbf{x}(t)$ is the state-to-be-estimated, defined as the concatenation of the inertial position and velocity vectors and the mass of the spacecraft, $\\mathbf{u}(t)$ is the control applied by the spacecraft, which consists of the throttling factor $u$ and thrust direction $\\boldsymbol{\\alpha}^i$ that are assumed to be known perfectly, $\\mathbf{w}$ is defined as the process noise which accounts for imperfectly modeled dynamics, assumed to be a zero mean Gaussian random variable with covariance $\\mathbf{Q}(t)$. Also, $\\mathbf{h}(\\mathbf{x}_k)$ is the measurement taken at time $t_k$, which can include only the three accelerometer measurement, only $l\\in[0,32]$ pseudorange measurements from the $l$ visible GPS satellites, or a combination of both accelerometer and GPS pseudorange measurements, and $\\mathbf{R}_k$ is the measurement covariance matrix. Furthermore, $\\mathbf{f}(\\mathbf{x}(t), \\mathbf{u}(t), t)$ is the dynamics which are given by\n\\begin{equation}\n\t\\mathbf{f}(\\mathbf{x}(t),\\mathbf{u}(t),t) = \\begin{bmatrix} \n\t\t\\mathbf{v}^i \\\\ \n\t\t-\\frac{\\mu}{r^3}\\mathbf{r}^i + \\mu_l\\left(\\frac{\\mathbf{r}_{ls}^i}{r_{ls}^3} - \\frac{\\mathbf{r}_l^i}{r_l^3}\\right)  + \\frac{uT_{max}}{m}\\boldsymbol{\\alpha}^i \\\\\n\t\t-uT_{max}/c\n\t\\end{bmatrix}\n\\end{equation}\nwhere we also assume ephemeris for the Moon is known perfectly and is used to compute $\\mathbf{r}_{ls}^i$ and $\\mathbf{r}_l^i$. \n\n\\subsection{Extended Kalman Filter}\n \\subsubsection{Propagation:}\nThe state estimate $\\hat{\\mathbf{x}}$ and error covariance matrix $\\mathbf{P}$ are propagated within the EKF according to \\cite{Crassidis_2004}\n \\begin{align}\n \t\\dot{\\hat{\\mathbf{x}}} = \\mathbf{f}(\\hat{\\mathbf{x}}(t), \\mathbf{u}(t),t)\n \\end{align}\n\\begin{equation}\n\t\\dot{\\mathbf{P}}(t) = \\mathbf{F}(t)\\mathbf{P}(t) + \\mathbf{P}(t)\\mathbf{F}^T(t) + \\mathbf{G}(t)\\mathbf{Q}(t)\\mathbf{G}^T(t)\n\\end{equation}\nwhere $\\mathbf{G}$ is taken as the identity matrix, $\\mathbf{F}$ is the dynamics Jacobian given by \n\\begin{equation}\n\t\\mathbf{F} = \\frac{\\partial \\mathbf{f}}{\\partial \\mathbf{x}}\\bigg|_{\\hat{\\mathbf{x}}(t),\\mathbf{u}(t)} = \\begin{bmatrix}\n\t\t\\mathbf{0}_{3\\times 3} & \\mathbf{I}_{3\\times3} & 0 \\\\\n\t\t\\frac{\\mu}{r^3}\\left(\\frac{3}{r^2}\\mathbf{r}^i\\mathbf{r}^{i,T} - \\mathbf{I}\\right) + \\frac{\\mu_l}{r_{ls}^3}\\left(\\frac{3}{r_{ls}^2}\\mathbf{r}_{ls}^i\\mathbf{r}_{ls}^{i,T} - \\mathbf{I}\\right)  & \\mathbf{0} & -\\frac{uT_{max}}{m^2}\\mathbf{\\alpha}^i \\\\\n\t\t\\mathbf{0}_{1\\times 3} & \\mathbf{0}_{1\\times 3} & 0\n\t\\end{bmatrix}\n\\end{equation}\nand $\\mathbf{Q}$ was chosen as \n\\begin{equation}\n\t\\mathbf{Q} = \\operatorname{diag}\\left(\\begin{bmatrix}\n\t\t0.0 & 0.0 & 0.0 & 1\\times10^{-12} & 1\\times10^{-12} & 1\\times10^{-12} & 1\\times10^{-3}\n\t\\end{bmatrix} \\right)\n\\end{equation}\nFurthermore, the state estimate and error covariance matrix differential equations were numerically integrated employing Verner's ``most efficient'' 7(8) Runge-Kutta method \\cite{Verner_2010} provided by the \\textit{DifferentialEquations.jl} \\cite{Rackauckas_2017} package written within the Julia programming language \\cite{Bezanson_2017}.\n\n \\subsubsection{Measurement Update:}\n The state estimate and error covariance matrix are updated within the EKF when a set of measurements is ingested\n according to \\cite{Crassidis_2004}\n \\begin{align}\n \t\\hat{\\mathbf{x}}_k^+ &= \\hat{\\mathbf{x}}_k^- + \\mathbf{K}_k\\left[\\tilde{\\mathbf{y}}_k - \\mathbf{h}(\\hat{\\mathbf{x}})\\right] \\\\\n \t\\mathbf{P}_k^+ &= \\left[\\mathbf{I} - \\mathbf{K}_k \\mathbf{H}_k(\\hat{\\mathbf{x}}_k)\\right]\\mathbf{P}_k^-\n \\end{align} \nwhere\n\\begin{equation}\n\t\\mathbf{K}_k = \\mathbf{P}_k^-\\mathbf{H}_k^T(\\hat{\\mathbf{x}}_k^-)\\left[\\mathbf{H}_k(\\hat{\\mathbf{x}}_k^-)\\mathbf{P}_k^-\\mathbf{H}_k^T(\\hat{\\mathbf{x}}) + \\mathbf{R}_k\\right]^{-1}\n\\end{equation}\n\nAt this point, it is important to note that the number of measurements processed, as well as the size of $\\mathbf{H}_k$ and $\\mathbf{R}_k$, at a given epoch $t_k$ will differ due to differing IMU and GNSS receiver sampling rates as well as changes in the number of visible GPS satellites. Therefore, we'll consider three different scenarios: only accelerometer measurements are processed, only pseudorange measurements are processed, and both accelerometer and pseudorange measurements. \n\nFor the case of only accelerometer measurements, the measurement vector is given by\n\\begin{equation}\n\t\\tilde{\\mathbf{y}}_{k,a} = \\mathbf{a}_{m,k}^-\n\\end{equation}\nand the expected measurement is computed as \n\\begin{equation}\n\t\\mathbf{h}_{a}(\\hat{\\mathbf{x}}_k) = \t-\\frac{\\mu}{||\\hat{\\mathbf{r}}||^3}\\hat{\\mathbf{r}} + \\mu_l\\left(\\frac{\\mathbf{r}_l^i - \\hat{\\mathbf{r}}}{||\\mathbf{r}_l^i - \\hat{\\mathbf{r}}||^3} - \\frac{\\mathbf{r}_l^i}{r_l^3}\\right)  + \\frac{uT_{max}}{m}\\boldsymbol{\\alpha}^i \n\\end{equation}\nwith a measurement Jacobian given by\n\\begin{equation}\n\t\\mathbf{H}_{a,k} = \\frac{\\partial \\mathbf{h}_a}{\\partial \\mathbf{x}}\\bigg|_{\\hat{\\mathbf{x}}_k,\\mathbf{u}_k}  = \\begin{bmatrix}\n\t\t\\frac{\\partial \\mathbf{a}^i_m}{\\partial \\mathbf{r}^i} & \\mathbf{0}_{3\\times 3} & \\frac{\\partial \\mathbf{a}_m^i}{\\partial m}\n\t\\end{bmatrix}\n\\end{equation}\nwith partials given in Eqs. \\eqref{eqn:apartr} and \\eqref{eqn:apartm}, and measurement noise covariance matrix \n\\begin{equation}\n\t\\mathbf{R}_a = \\operatorname{diag}(\\begin{bmatrix}\n\t\t\\sigma_a^2 & \\sigma_a^2 & \\sigma_a^2 \n\t\\end{bmatrix})\n\\end{equation}\nwhere a value of $\\sigma_a = 10^{-3}$ m/$\\text{s}^2$ was chosen to represent an IMU of moderate quality.\n\nFor the case of only $l$ pseudorange measurements, where $l\\in[0, 32]$, the measurement vector is given by\n\\begin{equation}\n\t\\tilde{\\mathbf{y}}_{k,p} = \\begin{bmatrix}\n\t\tp_{s_1,k} & p_{s_2,k} & \\dots & p_{s_l,k}\n\t\\end{bmatrix}^T\n\\end{equation} \nwhere subscript $s_1$ is simply used to denote the GPS satellite corresponding the first pseudorange measurement in $\\tilde{\\mathbf{y}}$ and does not imply $s=1$ or satellite PG01 as defined within IGS data products. Also, the expected measurement $\\mathbf{h}_p(\\hat{\\mathbf{x}})$ is computed as described in the above section and the measurement Jacobian is given by\n\\begin{equation}\n\t\\mathbf{H}_{p,k} = \\frac{\\partial \\mathbf{h}_p}{\\partial \\mathbf{x}} \\bigg|_{\\hat{\\mathbf{x}}_k,\\mathbf{u}_k}  = \\begin{bmatrix}\n\t\t\\frac{\\partial p_{s_1,k}}{\\partial \\mathbf{r}^i} & \\mathbf{0}_{4\\times 1} \\\\\n\t\t\\frac{\\partial p_{s_2,k}}{\\partial \\mathbf{r}^i} & \\mathbf{0}_{4\\times 1} \\\\\n\t\t\\vdots & \\vdots \\\\\n\t\t\\frac{\\partial p_{s_l,k}}{\\partial \\mathbf{r}^i} & \\mathbf{0}_{4\\times 1} \n\t\\end{bmatrix}\n\\end{equation}\nFinally, the measurement covariance matrix is given by\n\\begin{equation}\n\t\\mathbf{R}_p = \\operatorname{diag}(\\begin{bmatrix}\n\t\t\\sigma_p^2 & \\sigma_p^2 & \\dots & \\sigma_p^2\n\t\\end{bmatrix})\n\\end{equation}\nwhere a value of $\\sigma_p = 10^{-2}$ km.\n\nFinally, for the case of both pseudorange and accelerometer measurements, the measurement vector is given by\n\\begin{equation}\n\t\\tilde{\\mathbf{y}}_k = \\begin{bmatrix}\n\t\t\\tilde{\\mathbf{y}}_{k,p} & \\tilde{\\mathbf{y}}_{k,a}\n\t\\end{bmatrix}^T\n\\end{equation}\nwith expected measurements computed as\n\\begin{equation}\n\t\\mathbf{h}(\\hat{\\mathbf{x}}_k) = \\begin{bmatrix}\n\t\t\\mathbf{h}_p(\\hat{\\mathbf{x}}_k) & \\mathbf{h}_a(\\hat{\\mathbf{x}}_k)\n\t\\end{bmatrix}^T\n\\end{equation}\nand measurement Jacobian given by \n\\begin{equation}\n\t\\mathbf{H}_k = \\frac{\\partial \\mathbf{h}}{\\partial \\mathbf{x}}\\bigg|_{\\hat{\\mathbf{x}}_k,\\mathbf{u}_k} = \\begin{bmatrix}\n\t\t\\mathbf{H}_{p,k} & \\mathbf{H}_{a,k}\n\t\\end{bmatrix}\n\\end{equation}\nwith a measurement covariance matrix\n\\begin{equation}\n\t\\mathbf{R}_k = \\begin{bmatrix}\n\t\t\\mathbf{R}_p & \\mathbf{0}_{l\\times3} \\\\\n\t\t\\mathbf{0}_{3\\times l} & \\mathbf{R}_a\n\t\\end{bmatrix}\n\\end{equation}\n\n\\subsection{Unscented Kalman Filter}\n\\subsubsection{Propagation:}\nThe state estimate and error covariance matrix propagation step within the UKF first requires definition of the augmented covariance matrix given by \n\\begin{equation}\n\t\\mathbf{P}_k^a = \\begin{bmatrix}\n\t\t\\mathbf{P}_k^+ & \\mathbf{0}_{7\\times 7} \\\\\n\t\t\\mathbf{0}_{7\\times 7} & \\mathbf{Q}_k\n\t\\end{bmatrix}\n\\end{equation}\nwhere we note that the measurement covariance matrix is not included to reduce the number of required sigma points and is instead added directly to the output covariance matrix to compute the innovations covariance (more on this in the following section) \\cite{Crassidis_2004}. The propagation step begins with computation of the 29 sigma points as \\cite{Crassidis_2004}\n\\begin{align}\n\t\\boldsymbol{\\chi}_k^{a(0)} &= \\hat{\\mathbf{x}}_k^a \\\\\n\t\\boldsymbol{\\chi}_k^{a(2i - 1)}  &=  \\hat{\\mathbf{x}}_k^a + \\boldmath{\\sigma}_k^i \\hspace{1mm} \\forall \\hspace{1mm} i = 1,2,\\dots,14 \\\\\n\t\\boldsymbol{\\chi}_k^{a(2i)}  &=  \\hat{\\mathbf{x}}_k^a - \\boldmath{\\sigma}_k^i \\hspace{1mm} \\forall \\hspace{1mm} i = 1,2,\\dots,14\n\\end{align}\nwhere the augmented state vector is defined as \\cite{Crassidis_2004}\n\\begin{align}\n\t\\mathbf{x}_k^a = \\begin{bmatrix}\n\t\t\\mathbf{x}_k \\\\ \\mathbf{w}_k\n\t\\end{bmatrix}, \\hspace{3mm} \\hat{\\mathbf{x}}_k^a = \\begin{bmatrix}\n\t\t\\hat{\\mathbf{x}}_k \\\\ \\mathbf{0}_{7\\times 1}\n\\end{bmatrix}\n\\end{align}\nand $\\boldsymbol{\\sigma}_k^i$ denotes the $i^{th}$ column of $\\boldsymbol{\\sigma}_k$ which is computed as\n\\begin{equation}\n\t\\boldsymbol{\\sigma}_k = \\gamma \\sqrt{\\mathbf{P}_k^a}\n\\end{equation} \nwith parameter $\\gamma$ given by \n\\begin{equation}\n\t\\gamma = \\sqrt{14 + \\lambda}\n\\end{equation}\nand \n\\begin{equation}\n\t\\lambda = \\alpha^2(14 + \\kappa) - 14\n\\end{equation}\nwhere we've chosen $\\alpha=1.0$ and $\\kappa = 17.0$. Once the sigma points have been computed, each is propagated to $t_{k+1}$ by numerically integrating the differential equations\n\\begin{equation}\n\t\\dot{\\boldsymbol{\\chi}}^{x(i)} = \\mathbf{f}(\\boldsymbol{\\chi}^{x(i)}(t),\\mathbf{u}(t), t)  + \\boldsymbol{\\chi}_k^{w(i)}\\hspace{1mm}\\forall\\hspace{1mm}i=0,1,\\dots,28\n\\end{equation}\nwhere \n\\begin{equation}\n\t\\boldsymbol{\\chi}_k^{a(i)} = \\begin{bmatrix}\n\t\t\\boldsymbol{\\chi}_k^{x(i)} \\\\ \\boldsymbol{\\chi}_k^{w(i)}\n\t\\end{bmatrix}\n\\end{equation}\nfor which we again employ Verner's 7(8) Runge-Kutta method. Then, the predicted state estimate and error covariance are computed as \\cite{Crassidis_2004}\n\\begin{align}\n\t\\hat{\\mathbf{x}}_{k+1}^- &= \\sum_{i=0}^{28}W_i^{\\text{mean}}\\boldsymbol{\\chi}_{k+1}^{x(i)} \\\\\n\t\\mathbf{P}_{k+1}^- &= \\sum_{i=0}^{28}W_i^{\\text{cov}} \\left[\\boldsymbol{\\chi}_{k+1}^{x(i)} - \\hat{\\mathbf{x}}_{k+1}^-\\right]\\left[\\boldsymbol{\\chi}_{k+1}^{x(i)} - \\hat{\\mathbf{x}}_{k+1}^-\\right]^T\n\\end{align}\nwith weights given by\n\\begin{align}\n\tW_0^\\text{mean} &= \\frac{\\lambda}{14 + \\lambda} \\\\\n\tW_0^\\text{cov} &= \\frac{\\lambda}{14 + \\lambda} + (1 - \\alpha^2 + \\beta) \\\\\n\tW_i^\\text{mean} &= W_i^\\text{cov} = \\frac{1}{2(14 + \\lambda)}\n\\end{align}\nwhere $\\beta = 0.0$ was selected. \n\n\\subsection{Measurement Update:}\nThe state estimate and error covariance matrix are then updated within the UKF by ingesting a set of measurements $\\tilde{\\mathbf{y}}_k$ which vary in size as described above within the EKF section. This process begins with the computation of the mean observation as \\cite{Crassidis_2004}\n\\begin{equation}\n\t\\hat{\\mathbf{y}}_k^- = \\sum_{i=0}^{28}W_i^\\text{mean} \\boldsymbol{\\gamma}_k^i\n\\end{equation}\nwhere\n\\begin{equation}\n\t\\boldsymbol{\\gamma}_k^i = \\mathbf{h}(\\boldsymbol{\\chi}_k^{x(i)}, \\mathbf{u}_k,k)\n\\end{equation}\nThen the output covariance is computed as \n\\begin{equation}\n\t\\mathbf{P}_k^{yy} = \\sum_{i=0}^{28}W_i^\\text{cov}\\left[\\boldsymbol{\\gamma}_k^i-\\hat{\\mathbf{y}}_k^-\\right]\\left[\\boldsymbol{\\gamma}_k^i-\\hat{\\mathbf{y}}_k^-\\right]^T\n\\end{equation}\nwhich is used to compute the innovations covariance as\n\\begin{equation}\n\t\\mathbf{P}_k^{e_ye_y}=\\mathbf{P}_k^{yy} + \\mathbf{R_k}\n\\end{equation}\nwhere the measurement covariance matrix is defined as described above for the EKF. Finally, the cross-correlation matrix is computed as \\cite{Crassidis_2004}\n\\begin{equation}\n\t\\mathbf{P}_k^{e_xe_y} = \\sum_{i=0}^{28}W_i^\\text{cov}\\left[\\boldsymbol{\\chi}_k^{x(i)}-\\hat{\\mathbf{x}}_k^-\\right]\\left[\\boldsymbol{\\gamma}_k^i - \\hat{\\mathbf{y}}_k^-\\right]\n\\end{equation}\nand the state and error covariance matrix are updated according to\n\\begin{align}\n\t\\hat{\\mathbf{x}}_k^+ &= \\hat{\\mathbf{x}}_k^- + \\mathbf{K}_k\\mathbf{e}_k^- \\\\\n\t\\mathbf{P}_k^+ &= \\mathbf{P}_k^- - \\mathbf{K}_k\\mathbf{P}_k^{e_ye_y}\\mathbf{K}_k^T\n\\end{align}\nwhere \n\\begin{equation}\n\t\\mathbf{e}_k^- = \\tilde{\\mathbf{y}}_k - \\hat{\\mathbf{y}}_k^-\n\\end{equation}\nand\n\\begin{equation}\n\t\\mathbf{K}_k = \\mathbf{P}_k^{e_xe_y}\\left(\\mathbf{P}_k^{e_ye_y}\\right)^{-1}\n\\end{equation}\n\n\\section{Results}\nTo investigate the performance of the developed filters as well as the feasibility of inertial navigation in cislunar space using the Earth orbiting GPS constellation, a Monte Carlo analysis was performed. Both filters were ran for 100 independent trials, each time sampling the initial state estimate according to\n\\begin{equation}\n\t\\hat{\\mathbf{x}}_0 = N(\\mathbf{x}_0, \\mathbf{P}_0^+)\n\\end{equation}\nwhere $\\mathbf{x}_0$ is the true initial state and $\\mathbf{P}_0^+$ initial state estimate error covariance matrix chosen as\n\\begin{equation}\n\t\\mathbf{P}_0^+ = \\operatorname{diag}(\\begin{bmatrix}\n\t\t\\sigma_r^2 & \\sigma_r^2 & \\sigma_r^2  & \t\\sigma_v^2 & \\sigma_v^2 & \\sigma_v^2 & \\sigma_m^2\n\t\\end{bmatrix})\n\\end{equation}\nwith $\\sigma_r = 100 $ m, $\\sigma_v=10.0$ m/s, and $\\sigma_m=1.0$ mg. Also, both the accelerometer and pseudorange measurement noise standard deviation values given above were used, i.e., $\\sigma_a = 10^{-3}$ m/$\\text{s}^2$ and $\\sigma_p=10.0$ m. Finally, to reduce memory requirements when saving data for the full 33 day trajectory, both the accelerometer and pseudorange measurements were taken at a lower frequency than would likely be done in practice. For the EKF, accelerometer measurements were processed every 30 seconds and pseudorange measurements every 15 minutes. Similarly, accelerometer measurements were processed every minute and pseudorange measurements again every 15 minutes for the UKF. It was decided to reduce the frequency of accelerometer measurements further for the UKF when compared to the EKF due to the decreased computational efficiency of the algorithm.\n\n\\subsection{EKF Results}\n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/EKFPosVelError.eps}\n\t\\caption{EKF Inertial Estimation Error and Uncertainty}\n\t\\label{fig:EKFposvelerr}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/EKFMassError.eps}\n\t\\caption{EKF Mass Estimation Error and Uncertainty}\n\t\\label{fig:EKFmasserr}\n\\end{figure}\n\nFigures \\ref{fig:EKFposvelerr} and \\ref{fig:EKFmasserr} display the estimation error and the filters realization of its uncertainty as $3\\sigma$ bounds from a single trial along with the Monte Carlo error $3\\sigma$ bounds for the inertial states and mass respectively. \n\nFocusing first on the position error plots in Figure \\ref{fig:EKFposvelerr}, we can see that the position estimation error in the three Cartesian directions of the inertial reference frame remains bounded by the filters $3\\sigma$ bounds for a majority of the 33 day trajectory. Furthermore, we can see that when the position error does leave the $3\\sigma$ bounds (see plots corresponding to the $x$- and $z$-axis after about $27$ days)  it quickly converges back within the bounds. Also, it's important to note that the error and $3\\sigma$ bounds do begin to grow as the spacecraft nears the Moon (after around 30 days) and we can also see slight peaks in the $3\\sigma$ bounds which correspond to the spacecraft reaching the apoapsis of it current spiral trajectory about the Earth, both of which make intuitive sense as the spacecraft is traveling further from the GPS constellation resulting in the system becoming less observable. Finally, when comparing the filters realization of its uncertainty with the Monte Carlo error statistics, we can see that while both maintain a similar trend, the EKF is overly modest and ``believes'' it's is worse than it actually is. It's important to note that this quality of the filter could likely be improved with further tuning of the process noise. Furthermore, 100 Monte Carlo trials is still relatively low (around 1000 would likely be more ideal) and it is therefore possible that the Monte Carlo statistics are not an accurate representation of the true error statistics.\n\nMoving our focus to the velocity error plots of Figure \\ref{fig:EKFposvelerr}, we again see a similar trend, with the error bounded by the filters $3\\sigma$ bounds for a majority of the trajectory, again only leaving the bounds briefly after around 27 days. We also see the estimation error and uncertainty growing as the spacecraft approaches the Moon, as well as at each apoapsis of the trajectory, although the velocity estimation uncertainty appears to rapidly grow and shrink, manifesting as vertical spikes in the $3\\sigma$ bounds which are especially visible in the plot corresponding to the x-direction. Finally, we can see the filters representation of its uncertainty to follow a similar trend with the Monte Carlo error statistics and is again modest, over representing its estimation uncertainty.\n\nShifting focus to Figure \\ref{fig:EKFmasserr}, we again see the mass estimation error is bounded by the filters $3\\sigma$ bounds, here for the entire duration of the trajectory.  Interestingly, we do again see repeated increases in the filters mass estimation uncertainty before rapidly decreasing with gradually decreasing frequency. This phenomena is not related to increasing distance from the GPS constellation though (as it was for both position and velocity estimation) and instead the rapid decrease in uncertainty corresponds to the moments at which the thruster is firing, as this is the only time the mass of the spacecraft is observable. Although not investigated in the work, this behavior could likely be improved by setting the process noise for the mass dynamics to zero when the thruster is not firing, as we know that mass will remain constant when fuel is not being used. We can also see that the mass estimation error remains nearly constant for increasingly longer duration with the same frequency as the spikes in uncertainty which is also directly related to the moments at with the thruster is not firing. Also, quite different from the inertial state estimation, we can see the filters uncertainty is at its lowest point when approaching the moon for the final 3 days of the journey which results from the long thrusting arc used to place the spacecraft on the NRHO. Finally, comparing the filters realization of its mass estimation uncertainty with the Monte Carlo statistics, we can see that both do not follow a similar trend due to the process noise included when the thruster is not firing. Furthermore, the Monte Carlo $3\\sigma$ bounds also appear to under represent the mass estimation error, especially near the end of the trajectory. This is due to relatively large bias in the estimation of the spacecrafts mass, which we will further investigate in the following discussion. \n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/EKFPosVelHist.eps}\n\t\\caption{EKF Inertial State Estimation Error Distributions}\n\t\\label{fig:EKFposvelhist}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/EKFMassHist.eps}\n\t\\caption{EKF Mass Estimation Error Distribution}\n\t\\label{fig:EKFmasshist}\n\\end{figure}\n\nTo further investigate the distribution of the estimation errors, as well as to shed light on any bias present, Figures \\ref{fig:EKFposvelhist} and \\ref{fig:EKFmasshist} display histograms of the inertial states and mass respectively from each trial of the Monte Carlo analysis along with a vertical dashed line corresponding the mean of each distribution. When viewing these figures, it's important to note that the mean does not look correct which is due to many outliers of each distribution falling outside of the limits of the x-axis of each figure.\n\nFocusing first on the distributions of the inertial state estimation errors shown in Figure \\ref{fig:EKFposvelhist}, we can see that a large majority of the errors appear to be distributed normally with zero mean in all cases. With that said, each distribution also contains many outliers which result in a mean that is shifted away from zero. Although not shown in each plot, these outliers did not appear to congregate about a second mode (i.e., the distributions did not appear to be multi-modal) and therefore would not be visible due to the large magnitude of occurrences centered about zero. Although these plots do appear to show bias in the estimation of each state, it is possible that this behavior would disappear with more more Monte Carlo trials. Also, while examining these plots we can see the estimation accuracy in much more detail when compared to Figure \\ref{fig:EKFposvelerr}. Clearly the EKF did quite well, often estimating the position along the $x$- and $z$-directions within 100 m and in the $y$-direction within 200 m. Furthermore, estimation of the velocity was even better, with the EKF determining the velocity in each of the Cartesian direction to within 50 mm/s in a majority of cases. \n\nShifting focus to Figure \\ref{fig:EKFmasshist}, we see an entirely different trend with the distribution of mass estimation errors when compared to those shown in Figure \\ref{fig:EKFmasshist}. From this plot, we can observe a clear bias and a distribution that appears to be multi-modal, with two modes centered around 2 kg and a third centered about 5.5 kg. It is theorized that this behavior is due to the nonlinearity of the orbital dynamics, as well as the poor observability of the mass. Not only is the mass only observable when the spacecraft is thrusting, but the magnitude of the thrust is also quite small at only 10 N resulting in an acceleration due to thrust that is much lower in magnitude than the gravitational acceleration, especially when near the Earth where a majority of the thrusting occurs, which produces further difficulty.  Despite the clear bias and poor observability, the EKF does still estimate the mass of the spacecraft with surprising accuracy with a maximum mass estimation error of only 8.1 kg out of all 100 trials. \n\n\\subsection{UKF Results}\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/UKFPosVelError.eps}\n\t\\caption{UKF Inertial Estimation Error and Uncertainty}\n\t\\label{fig:UKFposvelerr}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/UKFMassError.eps}\n\t\\caption{UKF Mass Estimation Error and Uncertainty}\n\t\\label{fig:UKFmasserr}\n\\end{figure}\n\nMoving our discussion to results obtain using the UKF, Figures \\ref{fig:UKFposvelerr} and \\ref{fig:UKFmasserr} display the estimation error and the filters realization of its uncertainty as $3\\sigma$ bounds from a single trial along with the Monte Carlo error $3\\sigma$ bounds for the inertial states and mass respectively. \n\nFocusing first on the position error plots in Figure \\ref{fig:UKFposvelerr}, we can see that the position estimation error in the three Cartesian directions of the inertial reference frame again remain bounded by the filters $3\\sigma$ bounds for a majority of the trajectory. Furthermore, for the single trial shown, the error only leaves the $3\\sigma$ bounds twice, both with the estimates of the position in the $z$-direction at around 28 days and quickly converges back within the bounds. Also, we see a similar trend observed with the EKF, that being the uncertainty grows about the apoapsis of each spiral until ballooning out to its largest point when approaching the Moon. With that said, this trend is less visible in the UKF's realization of its uncertainty when compared to the EKF, especially before the 15 day mark, but we can see it with much more clarity when looking at the Monte Carlo $3\\sigma$ bounds. One significant trend observed here but not for the EKF is the ``jittering'' or rapid oscillation in the filters $3\\sigma$ bounds, resulting in the UKF's $3\\sigma$ bounds appearing as a thick band in Figure \\ref{fig:UKFposvelerr}. This phenomena occurred due to the correction when ingesting GPS pseudorange measurements exhibiting a much more profound improvement on the quality of the state estimate when compared to the EKF. Finally, when comparing the filters uncertainty with the Monte Carlo $3\\sigma$ bounds, we can see that both follow nearly the exact trend, with each peek and trough of the two bounds matching up nearly one-to-one which clearly demonstration the UKF's improved ability in representing it's uncertainty as compared to the EKF. With that said, the UKF is also modest, although not as much as the EKF, but this could very likely be improved with further tuning of the process noise and $\\alpha$, $\\beta$, and $\\kappa$ parameters. \n\nMoving our focus to the velocity error plots of Figure \\ref{fig:UKFposvelerr}, we once again see a similar trend, with the error bounded by the filters $3\\sigma$ bounds for the entire trajectory. We also see the estimation error and uncertainty growing as the spacecraft approaches the Moon, as well as at each apoapsis of the trajectory as we've noted for estimation of all inertial states of the spacecraft, both with the EKF and UKF. Furthermore, we again see the same vertical spikes observed with the EKF in the filters $3\\sigma$ bounds corresponding to the velocity in the $x$-direction. The jittering in the UKF's $3\\sigma$ bounds is also again present when estimating the velocity of the spacecraft. Finally, we can see the filters representation of its uncertainty follows the trend exhibited by the Monte Carlo $3\\sigma$ bounds nearly exactly as was also noted for the position states, although the filter is clearly modest in this case with the filters $3\\sigma$ bounds separated from the Monte Carlo bounds by about 0.4 m/s in all cases. \n\nShifting focus to Figure \\ref{fig:UKFmasserr}, we see that the UKF actually performs much worse for a majority of the trajectory when estimating the mass of the spacecraft when compared to the EKF, with the mass estimation error leaving the filters $3\\sigma$ bounds for a significant duration around day 27 to 31. It is expected that a large contributor to this phenomena is the non-zero process noise when the spacecraft is not thrusting, although further analysis is required to verify this. Also due to the non-zero process noise when not thrusting, we see a trend first observed for the EKF, with the filters realization of it's uncertainty ballooning greatly before quickly reducing when the thrusters begin firing. Interestingly, although a majority of this figure displays much worse performance when compared to the EKF, the final 3 days of the journey, as the spacecraft thrusts towards the NRHO, estimation of the mass is quite good and remains bounded by the filters $3\\sigma$ bounds.\n\n\\begin{figure}[hbt!]\n\t\\centering \n\t\\includegraphics{./../../figures/UKFPosVelHist.eps}\n\t\\caption{UKF Inertial State Estimation Error Distributions}\n\t\\label{fig:UKFposvelhist}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering \n\t\\includegraphics{./../../figures/UKFMassHist.eps}\n\t\\caption{UKF Mass Estimation Error Distribution}\n\t\\label{fig:UKFmasshist}\n\\end{figure}\n\nAs previously discussed for the EKF, to further investigate the distribution of the estimation errors and any bias present, Figures \\ref{fig:UKFposvelhist} and \\ref{fig:UKFmasshist} display histograms of the inertial states and mass respectively from each trial of the Monte Carlo analysis along with a vertical dashed line corresponding the mean of each distribution. \n\nFocusing first on the distributions of the inertial state estimation errors shown in Figure \\ref{fig:EKFposvelhist}, we can see that a large majority of the errors again appear to be distributed normally with zero mean in all cases. Furthermore, the computed mean of each distribution is also near zero, quite different than observed for the EKF, and a highly desirable quality as bias in the estimated state can cause many problems with inertial navigation, especially if performing fully autonomous navigation and control of a spacecraft. Also, we can see the UKF was able to estimate the position of the spacecraft with much greater accuracy when compared to the EKF, with a majority occurrences falling within 10 m. Estimation accuracy of the velocity states did not see much improvement when compared to the EKF, although both filters did estimate the velocity of the spacecraft remarkably well. \n\nShifting focus to Figure \\ref{fig:UKFmasshist}, we see a similar trend as was observed for the EKF, with the distribution of mass estimation error appearing to exhibit multiple modes, although the mean of the distribution is near zero in this case. With that said, although the mean of the distribution is zero, each mode is centered far from zero, at around 3, -13, -25, and -29 kg. Furthermore, we can clearly observe that the UKF's ability to estimate the mass of the spacecraft is much worse than the EKF, with error growing as large as -35 kg in at least one of the trials performed. \n\n\\section{Conclusions}\nOverall, when comparing the performance of the EKF with the UKF at Earth GPS based inertial navigation in cislunar space, the UKF performed better, estimating the position of the spacecraft with much higher accuracy, all the while maintaining a better understanding of its estimation uncertainty and seemingly zero bias in estimation of all but the mass state. With that said, the UKF did perform very poor when estimating the mass of the spacecraft, and while the EKF did not estimate the mass with a high degree of accuracy, when compared to the UKF, it was much better. Both the EKF and UKF could likely be improved, either by incorporating a non-constant process noise as discussed in the preceding section, further tuning, or alternative strategies all together which would likely improve both filters ability to estimate the spacecrafts mass. \n\nThroughout this study, we've also found that use of the Earth based GPS constellation for inertial navigation in cislunar space is feasible and estimation accuracy of both the position and velocity of the spacecraft was achieved with high accuracy, especially when employing the UKF. It is important to note though that the trajectory used throughout this study was an ideal candidate for GPS based navigation, as the spacecraft was never eclipsed by the Moon. For the case of navigation of a spacecraft on the far side of the Moon or when traversing to the lunar surface, additional sensors or an additional GPS-like constellation of satellites in orbit about the Moon would very likely need to by employed.\n\n\\bibliographystyle{AAS_publication}   % Number the references.\n\\bibliography{references}   % Use references.bib to resolve the labels.\n\n\\end{document}\n", "meta": {"hexsha": "f4934ad985ae29c07c27c45c2aca170eeed78707", "size": 49626, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/report/report.tex", "max_stars_repo_name": "GrantHecht/OptimalEstimationProject", "max_stars_repo_head_hexsha": "42e595d1991a8f81cbfb36856528d572b45cc598", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-15T00:42:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-15T00:42:37.000Z", "max_issues_repo_path": "documents/report/report.tex", "max_issues_repo_name": "GrantHecht/OptimalEstimationProject.jl", "max_issues_repo_head_hexsha": "42e595d1991a8f81cbfb36856528d572b45cc598", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/report/report.tex", "max_forks_repo_name": "GrantHecht/OptimalEstimationProject.jl", "max_forks_repo_head_hexsha": "42e595d1991a8f81cbfb36856528d572b45cc598", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 93.2819548872, "max_line_length": 1910, "alphanum_fraction": 0.7493854028, "num_tokens": 14175, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.44653096368656986}}
{"text": "% !TEX TS-program = pdflatex\n% !TEX encoding = UTF-8 Unicode\n\n% This is a simple template for a LaTeX document using the \"article\" class.\n% See \"book\", \"report\", \"letter\" for other types of document.\n\n\\documentclass[11pt]{article} % use larger type; default would be 10pt\n\n\\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)\n\n%%% Examples of Article customizations\n% These packages are optional, depending whether you want the features they provide.\n% See the LaTeX Companion or other references for full information.\n\n%%% PAGE DIMENSIONS\n\\usepackage{geometry} % to change the page dimensions\n\\geometry{a4paper} % or letterpaper (US) or a5paper or....\n% \\geometry{margin=2in} % for example, change the margins to 2 inches all round\n% \\geometry{landscape} % set up the page for landscape\n%   read geometry.pdf for detailed page layout information\n\n\\usepackage{graphicx} % support the \\includegraphics command and options\n\n% \\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent\n\n%%% PACKAGES\n\\usepackage{booktabs} % for much better looking tables\n\\usepackage{array} % for better arrays (eg matrices) in maths\n\\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)\n\\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim\n\\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float\n\n% These packages are all incorporated in the memoir class to one degree or another...\n\n%%% HEADERS & FOOTERS\n\\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry\n\\pagestyle{fancy} % options: empty , plain , fancy\n\\renewcommand{\\headrulewidth}{0pt} % customise the layout...\n\\lhead{}\\chead{}\\rhead{}\n\\lfoot{}\\cfoot{\\thepage}\\rfoot{}\n\n%%% SECTION TITLE APPEARANCE\n\\usepackage{sectsty}\n\\allsectionsfont{\\sffamily\\mdseries\\upshape} % (See the fntguide.pdf for font help)\n% (This matches ConTeXt defaults)\n\n%%% ToC (table of contents) APPEARANCE\n\\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC\n\\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents\n\\renewcommand{\\cftsecfont}{\\rmfamily\\mdseries\\upshape}\n\\renewcommand{\\cftsecpagefont}{\\rmfamily\\mdseries\\upshape} % No bold!\n\n%%% END Article customizations\n\n%%% The \"real\" document content comes below...\n\n\\title{Simplified BDO Kinetics for Product Selectivity}\n\\author{James Lischeske}\n%\\date{} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\\section{Motivation}\n\nYour text goes here.\n\n\\section{Equations}\n\nThe overall reaction is limited by an expression for the uptake of substrate per biomass concentration:\n\\begin{equation}\n\tq_s = q_{s,mx} F_s F_e\n\\end{equation}\nThese depend on two Michaelis-Menten-like expressions for the availability of substrates ($F_s$), which provide energy, and oxygen and acetoin, which provide electrons ($F_e$) for the deconstruction of substrates:\n\\begin{equation}\n\tF_s = \\frac{[G] + [Xy]}{[G] + [Xy] + K_s}\n\\end{equation}\n\\begin{equation}\n\tF_e = \\frac{[O_2] +  [A]/\\beta_e}{[O_2] +  [A]/\\beta_e + K_e}\n\\end{equation}\nthe scaling constant $\\beta_e$ is required because the organism vastly prefers to use oxygen as the electron source relative to acetoin, but the absolute concentration of acetoin is several orders of magnitude higher than oxygen. Note also the convention wherein concentrations of solutes are denoted by the identifier in square brackets ($[i] = C_i$) for readability. \n\nWe use a limited-growth model for biomass (biomass here refers to mass-concentration of active bacteria $X$, in $\\mathrm{kg/m^3}$):\n\\begin{equation}\n\t\\frac{d X}{d t} = Y_{X/s} q_s X (1 - \\frac{X}{X_{max}})\n\\end{equation}\nwhere $Y_{X/s}$ is the specific aerobic yield for substrate, in $\\mathrm{\\frac{kg-biomass/m^3}{mol-S/m^3}}$. All constants will be identified and quantified in the next section.\n\nOur substrates are glucose and xylose, and the organism prefers to consume glucose rather than xylose. This is accomplished by phenomenologically rather than mechanistically, using a partitioning function, as follows:\n\\begin{equation}\n\t-r_{G} = \\chi_s q_s X\n\\end{equation}\n\\begin{equation}\n\t-r_{Xy} = (1-\\chi_s) q_s X\n\\end{equation}\nwhere $\\chi_s$ is the partitioning function $\\chi_s = P(\\alpha_s, \\beta_s \\frac{[G]}{[Xy]})$, where $P$ is the regularized lower incomplete gamma function, which is the CDF of the gamma distribution. This allows us to transform the ratio of concentrations of the substrates, which is in the domain $(0, \\infty)$, to the domain $(0,1)$. \n\nProducts (acetoin and 2,3-bdo) are modeled as being generated in a simple ratio from substrates:\n\\begin{equation}\n\tr_{A, r} = \\chi_p Y_{A/s} q_s X\n\\end{equation}\n\\begin{equation}\n\tr_{B, r} = (1-\\chi_p) Y_{B/s} q_s X\n\\end{equation}\nwhere $\\chi_p$ is a constant.\n\nElectrons are supplied by oxygen and, in low-oxygen environments, by acetoin. Thus, we need our partitioning function again for electron supply:\n\\begin{equation}\n\t-r_{O_2,e} = \\chi_e Y_{O/s} q_s X\n\\end{equation}\n\\begin{equation}\n\t-r_{A, e} = (1-\\chi_e) Y_{A/s} q_s X\n\\end{equation}\n\\begin{equation}\n\tr_{B,e} = - r_{A,e}\n\\end{equation}\nwhere $\\chi_e = P(\\alpha_e, \\beta_e \\frac{[O_2]}{[A]})$ is again given by the incomplete gamma function, using the ratio of oxygen to acetoin concentration. Note that this $\\beta_e$ is the same as what's used in the Monod equation for electron availability in equation \\ref{}. Also, the acetoin consumption rate is scaled by the specific \\emph{oxygen} yield to substrate ($Y_{O/s}$), because here acetoin is serving same function as oxygen in this context, where one mole is consumed to produce one mole of NAD+. \nAnd thus, the total rates for acetoin and bdo are given by:\n\\begin{equation}\n\tr_{A} = r_{A,r} + r_{A,e}\n\\end{equation}\n\\begin{equation}\n\tr_{B} = r_{B,r} + r_{B,e}\n\\end{equation}\nAnd finally, we recognize that oxygen is also supplied by aeration, and therefore the total oxygen rate is given by:\n\\begin{equation}\n\tr_{O_2} = r_{O_2,e} + k_L a ([O_2]_{sat} - [O_2](x,t))\n\\end{equation}\n\nThis is a semi-mechanistic model only, and makes several simplifying assumptions. Here, product formation is simply a function of the present concentration of biomass, whereas it may be more accurately modeled as both biomass-associated and growth associated (in growth-associated formation, it is both a function of $X$ and $dX/dt$). \n\nAdditionally, in the real metabolic system, acetoin is produced first, and bdo is produced from acetoin, yielding one mol of NAD+ per mol acetoin consumed. Our present assumptions allow us to avoid modeling redox balances (that is, the balance of NADH and NAD+), which are exceedingly complicated, and counter-balanced by many other pathways within the organism. Rather, we recognized phenomenologically that acetoin and bdo are co-produced under typical conditions, and acetoin is consumed at low oxygen concentrations.\n%\n%Finally, in the context of our reactor, where an instantaneous oxygen consumption rate is required at each location, this may be given by:\n%\\begin{equation}\n%\\begin{array}{ll}\n%\tr_{O_2, \\mathrm{reactor}} = & - P(\\alpha_e, \\beta_e [O_2]/[A]_{\\mathrm{reactor}}) Y_{O/s}  X q_{s,mx} F_{s,reactor} \\frac{[O_2] + \\beta_e [A]}{[O_2] + \\beta_e [A] + K_e} \\\\\n%\t& + k_L a ([O_2]_{sat} - [O_2](x,t))\n%\\end{array}\t\t\n%\\end{equation}\n\nNote that, in the first term, $Y_{O/s}$,  $X$,  $q_{s,mx}$, and  $F_{s,reactor}$ are all constant across the entire reactor, while $P(\\cdot)$, $F_e$, and $[O_2]$ must be calculated at each cell within the reactor. \n\nIn summary, we have ODEs for the following \n \n\n\\subsection{Constants and Data Set}\n\nCoefficients are presented in Table \\ref{}, then systematically explored and estimated below, referencing experimental data where possible.\n\n\\begin{table}[h!]\n\\caption{Representative parameters}\n\\begin{tabular}{l l l l } \n\tVariable & Value & dimensions & description \\\\\n\t$Y_{X/s}$ & 0.009 & $\\mathrm{\\frac{kg-biomass/m^3}{mol-S/m^3}}$ & specific aerobic yield of substrate, or the amount of biomass produced per amount of substrate consumed \\\\\n\t$Y_{A/s}$ & 1.01 & $\\mathrm{mol-A/mol-S}$ & specific acetoin yield of substrate \\\\\n\t$Y_{B/s}$ & 0.88  & $\\mathrm{mol-A/mol-S}$ & specific bdo yield of substrate \\\\\n\t$Y_{O/s}$ & 0.0467 & $\\mathrm{mol-O_2/mol-S}$ & specific oxygen yield of substrate \\\\\n\t$X_{max}$ & 11 & $\\mathrm{kg/m^3}$ & maximum biomass concentration \\\\\n\t$q_{s, max}$ & 17 & $\\mathrm{\\frac{mol-S/m^3}{h-kg-biomass/m^3}}$ & maximum solute consumption rate \\\\\n\t$O_{2,max}$ & 0.214 & $\\mathrm{mol/m^3}$ & solubility limit of oxygen \\\\\n\t$K_e$ & 0.0214 & $\\mathrm{mol-e/m^3}$ & Michaelis-Menten coefficient for oxygen consumption/electron production \\\\\n\t$K_s$ & 31 & $\\mathrm{mol-S/m^3}$ & Michaelis-Menten coefficient for substrate uptake\\\\\n\t$\\alpha_s$ & 3 & (--) & \\\\\n\t$\\beta_s$ & 12 & (--) & \\\\\n\t$\\alpha_e$ & 1 & (--) & \\\\\n\t$\\beta_e$ & $10^3$ & (--) &\n\t\n\\end{tabular}\n\\end{table}\n\nAddtionally, we have a representative set of initial and process conditions\n\n\\begin{table}[h!]\n\\caption{Initial conditions}\n\\begin{tabular}{l l l l }\n\tVariable & Value & Units \\\\\n\tX & 0.5 & $\\mathrm{kg/m^3}$ \\\\\n\t$[O_2]$ & 0.214 & $\\mathrm{mol/m^3}$ \\\\\n\t$[G]$ & 500 & $\\mathrm{mol/m^3}$ \\\\\n\t$[Xy]$ & 250 & $\\mathrm{mol/m^3}$ \\\\\n\t$[A]$ & 0 & $\\mathrm{mol/m^3}$ \\\\\n\t$[B]$ & 0 & $\\mathrm{mol/m^3}$ \\\\\n\tAeration Rate & 0.18 & Volume-per-volume-per minute\n\\end{tabular}\n\\end{table}\n\t\n\n\n[Relation of constants to data to come in a future draft....]\n\n\\section{Reactor Model}\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "f5f2169a2e40236062a9476954487f6eb30421d4", "size": 9647, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bioreactor/wellmixed_ODE_solver/equationsDoc.tex", "max_stars_repo_name": "NREL/VirtualEngineering", "max_stars_repo_head_hexsha": "f23f409132bc7965334db1e29d83502001ec4e09", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-23T21:33:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T08:06:24.000Z", "max_issues_repo_path": "bioreactor/wellmixed_ODE_solver/equationsDoc.tex", "max_issues_repo_name": "NREL/VirtualEngineering", "max_issues_repo_head_hexsha": "f23f409132bc7965334db1e29d83502001ec4e09", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2022-02-28T19:10:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-14T22:24:34.000Z", "max_forks_repo_path": "bioreactor/wellmixed_ODE_solver/equationsDoc.tex", "max_forks_repo_name": "NREL/VirtualEngineering", "max_forks_repo_head_hexsha": "f23f409132bc7965334db1e29d83502001ec4e09", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6038647343, "max_line_length": 520, "alphanum_fraction": 0.7201202446, "num_tokens": 2857, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4465309631342036}}
{"text": "\\section{Purely Syntactic Translations}\n\n\\begin{itemize}\n    \\item 1-1 map between the rules\n    \\item Rules differ only by terminal symbols\n    \\item Rules with same nonterminals, in same order\n\\end{itemize}\n\n\\subsection{From translation grammar to ELL with write}\n\\textbf{Note}: $G_1$ must be ELL(k).\n\nJust add write actions where needed in the ELL parser.\n\n\\subsection{From translation grammar to ELR with write}\nWrite actions only at reduction time, $G_t$ must be normalized in \\emph{postfix normal form}.\n\nEvery rule of $G_2$ must be $A \\rarr \\gamma w$ where $\\gamma\\in V^*$ and $w \\in \\Delta^*$ ($\\Delta$ is target terminal set). Introduce additional nonterminals replacing the non-suffix terminals. \\textbf{Note}: this can lose ELR(1).\n\n\\subsection{2I-machine}\n\nIt gets 2 inputs, the source and target string and accepts if the second is the translation of the first. To accept both tapes must be scanned completely.\n\n\\subsection{IO-automation}\n\nThe second tape is the output and the machine computes the translation as a function of the source.\n\nAn IO-automation is deterministic if the automaton with only the numerators is deterministic.\n\n\\subsection{Sequential Transducer}\n\nVariant of IO-automation that emits while executing transitions and eventually writing also when exiting ($\\frac{\\dashv}{s}$)\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.9\\linewidth]{syntax/sequential-transducer.png}\n\\end{figure}\n\n\\subsection{Rational Translation Expression}\n\nA regular expression where the terminals are fractions, for example:\n$R_\\tau = \\frac{(}{(} \\left( \\frac{a}{a} | \\frac{(}{\\epsilon} \\left(\\frac{a}{2a}\\right)^+ \\frac{)}{\\epsilon} \\right)^+ \\frac{)}{)}$\n", "meta": {"hexsha": "fc26fc648254d65ccc32d6b1150da9d8ec8f656c", "size": 1682, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "syntax/scheme.tex", "max_stars_repo_name": "TiberioG/FLC-cheatsheet", "max_stars_repo_head_hexsha": "d86e8ba9c80fece75ffccf47c273334b677f4934", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-01-13T14:36:20.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-18T16:22:18.000Z", "max_issues_repo_path": "syntax/scheme.tex", "max_issues_repo_name": "TiberioG/FLC-cheatsheet", "max_issues_repo_head_hexsha": "d86e8ba9c80fece75ffccf47c273334b677f4934", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "syntax/scheme.tex", "max_forks_repo_name": "TiberioG/FLC-cheatsheet", "max_forks_repo_head_hexsha": "d86e8ba9c80fece75ffccf47c273334b677f4934", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-05-21T11:05:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-17T14:59:50.000Z", "avg_line_length": 40.0476190476, "max_line_length": 231, "alphanum_fraction": 0.7491082045, "num_tokens": 442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4465309554173397}}
{"text": "\\documentclass[11pt]{article}\n\n\\input{packages.tex}\n\\input{tikz.tex}\n\\input{thmstyle.tex}\n\\input{macros.tex}\n\n\\title{Lattices of compatibly embedded finite fields}\n\\author{}\n\n\\begin{document}\n\\maketitle\n\\begin{center}\n  \n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[arrow] (E) -- (F);\n      \\draw[arrow] (E) -- (G);\n      \\draw[arrow] (F) -- (G);\n\n      \\node (f12) at (1.25, 0.25) {$\\embed{E}{F}$};\n      \\node (f13) at (-0.35, 1) {$\\embed{E}{G}$};\n      \\node (f23) at (1.6, 1.65) {$\\embed{F}{G}$};\n    \\end{tikzpicture}\n\n\\end{center}\n\n\\section{Introduction}\n\nGiven two finite fields $E$ and $F$ with cardinalities $|E|=p^{m}$ and\n$|F|=p^{n}$, we know that $E$ can be embedded in $F$ if and only if $m\\,|\\,n$.\nIn other words, $E$ is in that case isomorphic to a subfield $E'\\subset F$ of $F$ with\ncardinality $|E'|=p^{m}$. There are\n$m=[E:\\mathbb{F}_p]=|\\Gal(E/\\mathbb{F}_p)|$ disctinct embeddings from $E$ to\n$F$ (the degree of $E$ over $\\mathbb{F}_p$ will also be denoted by\n$\\partial(E)$). Indeed, the Galois group of the extension $E$ over $\\mathbb{F}_p$ acts\non the embeddings. Given two different embeddings $\\embed{E}{F}$ and\n$\\embed{E}{F}'$ and an element $x\\in E$, the images $\\embed{E}{F}(x)$ and\n$\\embed{E}{F}'(x)$ must be conjugates. As a result, there is no cannonical\nembedding from $E$ to $F$. Furthermore, the proof of the fact that $E$ can be\nembedded in $F$ if and only if $\\dE\\,|\\,\\dF$ is not constructive, so computing the\nembedding is itself a challenging problem, and there exists a variety of\nsolutions.\n\nIn this document, we do not recall the embeddings algorithms, we often\nconsider them as black boxes that we use to construct embeddings between\nfinite fields, and we study the compatibility between these embeddings. Given\nthree finite fields $E$, $F$, and $G$, such that $\\dE\\,|\\,\\dF$ and $\\dF\\,|\\,\\dG$, and three embeddings\n$\\embed{E}{F}$, $\\embed{F}{G}$, and $\\embed{E}{G}$, we say that the\nembeddings are \\emph{compatible} if \n\\[\n  \\embed{E}{G}=\\embed{F}{G}\\circ\\embed{E}{F}.\n\\]\nIn other words, we want the diagram of Figure~\\ref{fig:compatibility} to\ncommute. We also note $E\\emb F$ if $E$ is explicitly embedded in $F$, \\ie if\nwe have computed an embedding $\\embed{E}{F}$.\n\\begin{figure}\n  \\centering\n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[arrow] (E) -- (F);\n      \\draw[arrow] (E) -- (G);\n      \\draw[arrow] (F) -- (G);\n\n      \\node (f12) at (1.25, 0.25) {$\\embed{E}{F}$};\n      \\node (f13) at (-0.35, 1) {$\\embed{E}{G}$};\n      \\node (f23) at (1.6, 1.65) {$\\embed{F}{G}$};\n    \\end{tikzpicture}\n\n  \\caption{Embeddings between finite fields.}\n  \\label{fig:compatibility}\n\\end{figure}\nThe background of this work is the development of a computer algebra\nsoftware, where we want the user to be able to define arbitrary finite\nfields and to work with them without having to care about compatibility\nbetween the different embeddings he or she have to use. These goals are\nachieved in the computer algebra softwares MAGMA~\\cite{Magma} and\nSagemath~\\cite{Sagemath}. We introduce the\nframework of Bosma, Cannon and Steel~\\cite{BCS97} in\nSection~\\ref{sec:bcs-framework}. Next, we discuss the current implementation in\nNemo of\nthis framework in Section~\\ref{sec:implem}.\n\n\\section{Bosma, Cannon, and Steel framework}\n\\label{sec:bcs-framework}\n\\begin{figure}\n  \\centering\n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[arrow] (E) -- (F);\n      \\draw[arrow] (E) -- (G);\n      \\draw[dashed-arrow] (F) -- (G);\n\n      \\node (f12) at (1.25, 0.25) {$\\embed{E}{F}$};\n      \\node (f13) at (-0.35, 1) {$\\embed{E}{G}$};\n    \\end{tikzpicture}\n\n  \\caption{An uncomplete diagram.}\n  \\label{fig:uncomplete}\n\\end{figure}\n\nLet $E$, $F$, and $G$ be finite fields with\n$\\partial(E)\\,|\\,\\partial(F)$ and\n$\\partial(F)\\,|\\,\\partial(G)$. We also assume that $E\\emb F$ and $E\\emb G$,\nhence we are in the situation described by Figure~\\ref{fig:uncomplete}\nwhere we miss one embedding. In order to complete the diagram of this\nfigure, Bosma,\nCannon and Steel suggest to take an arbitrary embedding $\\embed{F}{G}'$ and to\n``correct'' it by composing $\\embed{F}{G}'$ with an element of\n$\\sigma\\in\\Gal(G/\\mathbb{F}_p)$ such that \n\\[\n  \\embed{E}{G}=\\sigma\\circ\\embed{F}{G}'\\circ\\embed{E}{F}.\n\\]\nWe can then set $\\embed{F}{G}=\\sigma\\circ\\embed{F}{G}'$ and the\nobtained embedding is compatible by construction. We also see that once we have\none compatible embedding, we can derive other compatible embeddings from it by\nprecomposing by an element $\\xi$ of $\\Gal(F/E)$. Indeed, such an element\n$\\xi$ fixes the elements in $E$, hence the compatibility conditions are\nstill verified after precomposition. One may wander what happens\nif there are several subfields $E_1, \\dots, E_r$, or if the configuration is not\nthe one presented in Figure~\\ref{fig:uncomplete}.\n\nThere are three configurations with triangles, that are the one in\nFigure~\\ref{fig:triangles}. We already discussed the configuration on the\nleft, which is the one in Figure~\\ref{fig:uncomplete}. The configuration in the\nmiddle is easier to handle because we can set \n\\[\n  \\embed{E}{G}=\\embed{F}{G}\\circ\\embed{E}{F}\n\\]\nsince we have $E\\emb F\\emb G$. Finally, we will see later that the\nconfiguration on the right cannot happen in the framework we use because on the\nconditions we impose on the finite fields and on the embeddings betweem them.\n  \\begin{figure}\n    \\centering\n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[arrow] (E) -- (F);\n      \\draw[arrow] (E) -- (G);\n      \\draw[dashed-arrow] (F) -- (G);\n    \\end{tikzpicture}\n    \\phantom{and}\n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[arrow] (E) -- (F);\n      \\draw[dashed-arrow] (E) -- (G);\n      \\draw[arrow] (F) -- (G);\n\n    \\end{tikzpicture}\n    \\phantom{and}\n    \\begin{tikzpicture}\n      \\node (E) at (0, 0) {$E$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n\n      \\draw[dashed-arrow] (E) -- (F);\n      \\draw[arrow] (E) -- (G);\n      \\draw[arrow] (F) -- (G);\n\n    \\end{tikzpicture}\n    \\caption{The different configurations with triangles.}\n    \\label{fig:triangles}\n  \\end{figure}\n\nIf we have a pair $\\mathfrak L=(L, \\Phi)$, where\n$L$ is a set of finite fields and $\\Phi$ is a set of embeddings between\nelements of $L$, we say that $\\mathfrak L$ is a \\emph{lattice of compatibly\nembedded finite fields} if\n\\begin{enumerate}\n  \\item[CE1] (unicity) for each pair $(E, F)$ of elements in $L$, there exists\n    at most one corresponding embedding $\\embed{E}{F}\\in\\Phi$.\n  \\item[CE2] (reflexivity) For each $E\\in L$, the identity map\n    $\\Id_E=\\embed{E}{E}$ is in $\\Phi$.\n  \\item[CE3] (prime subfield) There is exactly one $P\\in L$ such that $\\partial\n    (P) = 1$, and for all $F\\in L$, there exists $\\embed{P}{F}\\in\\Phi$\n  \\item[CE4] (invertibility) If $E\\emb F$ and $\\dE=\\dF$, then $F\\emb E$ and\n    $\\embed{F}{E}=\\embed{E}{F}^{-1}$.\n  \\item[CE5] (transitivity) For any triple $(E, F, G)$ of elements in $L$, if $E\\emb\n    F\\emb G$ then $E\\emb G$ and\n    $\\embed{E}{G}=\\embed{F}{G}\\circ\\embed{E}{F}$.\n  \\item[CE6](intersections) For each $E, F, G\\in L$ such that $F\\emb G$ and\n    $E\\emb G$, there exists $S\\in L$ such that $\\partial(S)=\\gcd(\\dE, \\dF)$\n    and $S\\emb E$, $S\\emb F$.\n\\end{enumerate}\nThese conditions are, for most of them, very natural. The condition CE3 is\ntechnical and does not imply any work in our implementation because\nfinite fields elements in Nemo/Flint~\\cite{Nemo, Flint} are represented by\npolynomials over $\\mathbb{F}_p$, so the embedding of $\\mathbb{F}_p$ into an\nextension is trivial. Finally, condition\nCE6 ensures that the implicit isomorphisms between subfields are made\nexplicit.\n\nUnder those conditions, we can prove~\\cite{BCS97} that we are able to add a finite field in\n$L$ or an embedding that is not yet in $\\Phi$ without altering the compatibility\nof the lattice $\\mathfrak L$.\n\n\\section{Implementation in Nemo}\n\\label{sec:implem}\nIn practice, we do not compute our embeddings by correcting random embeddings as\nsuggested in Section~\\ref{sec:bcs-framework}. Instead, we use the naive\nalgorithm to compute a compatible embedding that does not need any correction.\nAssume we are in the situation of Figure~\\ref{fig:uncomplete}, \\ie we have $E$,\n$F$, $G$ finite fields and $E\\emb F$, $E\\emb G$, $\\dF\\,|\\,\\dG$. Let $\\alpha_F$\nbe a generator of $F$ over $\\mathbb{F}_p$, then $\\alpha_F$ is also a generator\nof $F$ over $E$. Let $\\pi_{E}(\\alpha_F)$ be the minimal polynomial of $\\alpha_F$\nover $E$, and let $\\rho$ be a root of $\\embed{E}{G}(\\pi_E(\\alpha_F))$, the\nminimal polynomial of $\\alpha_F$ viewed in $G$. We set $\\embed{F}{G}$ to the\nembedding mapping $\\alpha_F$ to $\\rho$. More precisely, we set\n\\[\n  \\embed{F}{G}(\\sum_{i=0}^{[F:E]-1}e_i\\alpha_F^i) =\n  \\sum_{i=0}^{[F:E]-1}\\embed{E}{G}(e_i)\\rho^i,\n\\]\nhence we see that\n\\[\n  \\embed{E}{G} = \\embed{F}{G}\\circ\\embed{E}{F}\n\\]\nand the new embedding is compatible with the already existing ones. We take\nthe cannonical generator of $F$ over $\\mathbb{F}_p$ to be $\\alpha_F$, we compute\n$\\pi_E(\\alpha_F)$ using linear algebra and we compute $\\embed{F}{G}$ using\nlinear algebra too. Assume now that we have several finite fields $E_1, \\cdots, E_r$ such\nthat for all $j$, $E_j\\emb F$, $E_j\\emb G$ and $\\dF\\,|\\,\\dG$. This is the\nsituation of Figure~\\ref{fig:uncomplete-sev}.\n\\begin{figure}\n  \\centering\n    \\begin{tikzpicture}\n      \\node (E1) at (-2, 0) {$E_1$}; \n      \\node (E2) at (-1, 0) {$E_2$}; \n      \\node (Er) at (0.75, 0) {$E_r$}; \n      \\node (F) at (1.5, 1) {$F$}; \n      \\node (G) at (0.5, 2) {$G$}; \n      \\node (p) at (0, 0) {$\\dots$};\n\n      \\draw[arrow] (E1) -- (F);\n      \\draw[arrow] (E1) -- (G);\n      \\draw[arrow] (E2) -- (F);\n      \\draw[arrow] (E2) -- (G);\n      \\draw[arrow] (Er) -- (F);\n      \\draw[arrow] (Er) -- (G);\n      \\draw[dashed-arrow] (F) -- (G);\n  \\end{tikzpicture}\n  \\caption{An uncomplete diagram with several subfields.}\n  \\label{fig:uncomplete-sev}\n\\end{figure}\nIn that case, we consider the polynomial\n\\[\n  P = \\gcd_i(\\embed{E_i}{G}(\\pi_{E_i}(\\alpha_F))),\n\\]\nand we let $\\rho$ be a root of $P$. We see that $\\rho$ is a root of each\npolynomial $\\embed{E_i}{G}(\\pi_{E_i}(\\alpha_F))$, so the embedding mapping\n$\\alpha_F$ to $\\rho$ is compatible with all the previously existing embeddings.\n\n\\section{Conclusion}\n\nIn practice, because of condition CE6 concerning intersections, we might have to\ncompute additionnal embeddings before computing the wanted embedding. In\nconclusion, in order to embed a finite field $F$ in $G$, we have to:\n\n\\begin{enumerate}\n  \\item for each subfield $S$ of $G$, check if the finite field $S\\cap F$ is \n    embedded in $S$ and $F$, and if not, embed it. In practice, if there is not\n    any finite field of degree $d=\\gcd(\\partial(S), \\dF)$, we compute an\n    arbitrary finite field $I$ of degree $d$ using Flint\n    and we embed $I$ in $S$ and $F$.\n  \\item Embed $F$ in $G$ using Section~\\ref{sec:implem} procedure.\n  \\item Compute the ``transitive closure'' of the lattice, \\ie compute the\n    embeddings such that condition CE5 holds. In practice we compute all the\n    embeddings and keep them in memory.\n\\end{enumerate}\nThe first step implies a recursive call to our embedding algorithm, so the\ncomplexity of the operation might explode at that step.\n\nThere are several things that could be enhanced in our current framework. First,\nwe could use graph algorithms in order to compute the transitive closure only\nwhen asked by the user. We could also compute minimal polynomials using\nBerlekamp Massey algorithm instead of linear algebra.\n\n\\bibliographystyle{plain}\n\\bibliography{erou}\n\\end{document}\n", "meta": {"hexsha": "76d06514a67b45ea69439471d8e5fee15c8f8d16", "size": 11999, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "compatible-lattices.tex", "max_stars_repo_name": "erou/compatible-embeddings", "max_stars_repo_head_hexsha": "5f73dc37587c61fec494562d7d23795bdaf7d37f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-05-17T16:33:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-17T16:33:19.000Z", "max_issues_repo_path": "compatible-lattices.tex", "max_issues_repo_name": "erou/compatible-embeddings", "max_issues_repo_head_hexsha": "5f73dc37587c61fec494562d7d23795bdaf7d37f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "compatible-lattices.tex", "max_forks_repo_name": "erou/compatible-embeddings", "max_forks_repo_head_hexsha": "5f73dc37587c61fec494562d7d23795bdaf7d37f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8129251701, "max_line_length": 102, "alphanum_fraction": 0.6501375115, "num_tokens": 4073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521105, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4465309543126073}}
{"text": "%\n% API Documentation for Peach - Computational Intelligence for Python\n% Module peach.fuzzy.mf\n%\n% Generated by epydoc 3.0beta1\n% [Mon Dec 21 08:51:36 2009]\n%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                          Module Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}|(}\n\\section{Module peach.fuzzy.mf}\n\n    \\label{peach:fuzzy:mf}\n\nMembership functions\n\nMembership functions are actually subclasses of a main class called Membership,\nsee below. Instantiate a class to generate a function, optional arguments can be\nspecified to configure the function as needed. For example, to create a triangle\nfunction starting at 0, with peak in 3, and ending in 4, use:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmu~=~Triangle(0,~3,~4)\n}\\end{quote}\n\nPlease notice that the return value is a \\emph{function}. To use it, apply it as a\nnormal function. For example, the function above, applied to the value 1.5\nshould return 0.5:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\n>{}>{}>~print~mu(1.5)~\\\\\n0.5\n}\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                               Functions                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsection{Functions}\n\n    \\label{peach:fuzzy:mf:Saw}\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Saw \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{Saw}(\\textit{interval}, \\textit{n})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nSplits an \\texttt{interval} into \\texttt{n} triangle functions.\n\nGiven an interval in any domain, this function will create \\texttt{n} triangle\nfunctions of the same size equally spaced in the interval. It is very\nuseful to create membership functions for controllers. The command below\nwill create 3 triangle functions equally spaced in the interval (0, 4):\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmf1,~mf2,~mf3~=~Saw((0,~4),~3)\n}\\end{quote}\n\nThis is the same as the following commands:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmf1~=~Triangle(0,~1,~2)~\\\\\nmf2~=~Triangle(1,~2,~3)~\\\\\nmf3~=~Triangle(2,~3,~4)\n}\\end{quote}\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xxxxxxxx}\n\n          \\item[interval]\n\n\nA tuple containing the start and the end of the interval, in the format\n\\texttt{(start, end)};\n          \\item[n]\n\n\nThe number of functions in which the interval must be split.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA list of triangle membership functions, in order.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{peach:fuzzy:mf:FlatSaw}\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.FlatSaw \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{FlatSaw}(\\textit{interval}, \\textit{n})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nSplits an \\texttt{interval} into a decreasing ramp, \\texttt{n-2} triangle functions\nand an increasing ramp.\n\nGiven an interval in any domain, this function will create a decreasing ramp\nin the start of the interval, \\texttt{n-2} triangle functions of the same size\nequally spaced in the interval, and a increasing ramp in the end of the\ninterval. It is very useful to create membership functions for controllers.\nThe command below will create a decreasing ramp, a triangle function and an\nincreasing ramp equally spaced in the interval (0, 2):\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmf1,~mf2,~mf3~=~FlatSaw((0,~2),~3)\n}\\end{quote}\n\nThis is the same as the following commands:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmf1~=~DecreasingRamp(0,~1)~\\\\\nmf2~=~Triangle(0,~1,~2)~\\\\\nmf3~=~Increasingramp(1,~2)\n}\\end{quote}\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xxxxxxxx}\n\n          \\item[interval]\n\n\nA tuple containing the start and the end of the interval, in the format\n\\texttt{(start, end)};\n          \\item[n]\n\n\nThe number of functions in which the interval must be split.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA list of corresponding functions, in order.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                               Variables                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsection{Variables}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-d\\-o\\-c\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt \\texttt{...}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Membership \\textit{(class)}|(}\n\\subsection{Class Membership}\n\n    \\label{peach:fuzzy:mf:Membership}\n\\begin{tabular}{cccccc}\n% Line for object, linespec=[False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.Membership}}\n\\end{tabular}\n\n\\textbf{Known Subclasses:}\npeach.fuzzy.mf.Bell,\n    peach.fuzzy.mf.DecreasingRamp,\n    peach.fuzzy.mf.DecreasingSigmoid,\n    peach.fuzzy.mf.Gaussian,\n    peach.fuzzy.mf.IncreasingRamp,\n    peach.fuzzy.mf.IncreasingSigmoid,\n    peach.fuzzy.mf.RaisedCosine,\n    peach.fuzzy.mf.Trapezoid,\n    peach.fuzzy.mf.Triangle\n\n\nBase class of all membership functions.\n\nThis class is used as base of the implemented membership functions, and can\nalso be used to transform a regular function in a membership function that\ncan be used with the fuzzy logic package.\n\nTo create a membership function from a regular function \\texttt{f}, use:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nmf~=~Membership(f)\n}\\end{quote}\n\nA function this converted can be used with vectors and matrices and always\nreturn a FuzzySet object. Notice that the value range is not verified so\nthat it fits in the range {[} 0, 1 {]}. It is responsibility of the programmer\nto warrant that.\n\nTo subclass Membership, just use it as a base class. It is suggested that\nthe \\texttt{{\\_}{\\_}init{\\_}{\\_}} method of the derived class allows configuration, and the\n\\texttt{{\\_}{\\_}call{\\_}{\\_}} method is used to apply the function over its arguments.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{f})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nBuilds a membership function from a regular function\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{x}\n\n          \\item[f]\n\n\nFunction to be transformed into a membership function. It must be\ngiven, and it must be a \\texttt{FunctionType} object, otherwise, a\n\\texttt{ValueError} is raised.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: object.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\label{peach:fuzzy:mf:Membership:__call__}\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Membership \\textit{(class)}!peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \\textit{(method)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{x}\n\n          \\item[x]\n\n\nA value, vector or matrix over which the function is evaluated.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Membership \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.IncreasingRamp \\textit{(class)}|(}\n\\subsection{Class IncreasingRamp}\n\n    \\label{peach:fuzzy:mf:IncreasingRamp}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.IncreasingRamp}}\n\\end{tabular}\n\n\nIncreasing ramp.\n\nGiven two points, \\texttt{x0} and \\texttt{x1}, with \\texttt{x0 < x1}, creates a function\nwhich returns:\n\\begin{quote}\n\n0, if \\texttt{x <= x0};\n\n\\texttt{(x - x0) / (x1 - x0)}, if \\texttt{x0 < x <= x1};\n\n1, if \\texttt{x > x1}.\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}, \\textit{x1})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nStart of the ramp;\n          \\item[x1]\n\n\nEnd of the ramp.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.IncreasingRamp \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.DecreasingRamp \\textit{(class)}|(}\n\\subsection{Class DecreasingRamp}\n\n    \\label{peach:fuzzy:mf:DecreasingRamp}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.DecreasingRamp}}\n\\end{tabular}\n\n\nDecreasing ramp.\n\nGiven two points, \\texttt{x0} and \\texttt{x1}, with \\texttt{x0 < x1}, creates a function\nwhich returns:\n\\begin{quote}\n\n1, if \\texttt{x <= x0};\n\n\\texttt{(x1 - x) / (x1 - x0)}, if \\texttt{x0 < x <= x1};\n\n0, if \\texttt{x > x1}.\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}, \\textit{x1})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nStart of the ramp;\n          \\item[x1]\n\n\nEnd of the ramp.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.DecreasingRamp \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Triangle \\textit{(class)}|(}\n\\subsection{Class Triangle}\n\n    \\label{peach:fuzzy:mf:Triangle}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.Triangle}}\n\\end{tabular}\n\n\nTriangle function.\n\nGiven three points, \\texttt{x0}, \\texttt{x1} and \\texttt{x2}, with \\texttt{x0 < x1 < x2},\ncreates a function which returns:\n\\begin{quote}\n\n0, if \\texttt{x <= x0} or \\texttt{x > x2};\n\n\\texttt{(x - x0) / (x1 - x0)}, if \\texttt{x0 < x <= x1};\n\n\\texttt{(x2 - x) / (x2 - x1)}, if \\texttt{x1 < x <= x2}.\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}, \\textit{x1}, \\textit{x2})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nStart of the triangle;\n          \\item[x1]\n\n\nPeak of the triangle;\n          \\item[x2]\n\n\nEnd of triangle.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Triangle \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Trapezoid \\textit{(class)}|(}\n\\subsection{Class Trapezoid}\n\n    \\label{peach:fuzzy:mf:Trapezoid}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.Trapezoid}}\n\\end{tabular}\n\n\nTrapezoid function.\n\nGiven four points, \\texttt{x0}, \\texttt{x1}, \\texttt{x2} and \\texttt{x3}, with\n\\texttt{x0 < x1 < x2 < x3}, creates a function which returns:\n\\begin{quote}\n\n0, if \\texttt{x <= x0} or \\texttt{x > x3};\n\n\\texttt{(x - x0)/(x1 - x0)}, if \\texttt{x0 <= x < x1};\n\n1, if \\texttt{x1 <= x < x2};\n\n\\texttt{(x3 - x)/(x3 - x2)}, if \\texttt{x2 <= x < x3}.\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}, \\textit{x1}, \\textit{x2}, \\textit{x3})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nStart of the trapezoid;\n          \\item[x1]\n\n\nFirst peak of the trapezoid;\n          \\item[x2]\n\n\nLast peak of the trapezoid;\n          \\item[x3]\n\n\nEnd of trapezoid.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Trapezoid \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Gaussian \\textit{(class)}|(}\n\\subsection{Class Gaussian}\n\n    \\label{peach:fuzzy:mf:Gaussian}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.Gaussian}}\n\\end{tabular}\n\n\nGaussian function.\n\nGiven the center and the width, creates a function which returns a gaussian\nfit to these parameters, that is:\n\\begin{quote}\n\n\\texttt{exp(-a*(x - x0)**2)}\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}=\\texttt{0.0}, \\textit{a}=\\texttt{1.0})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nCenter of the gaussian. Default value \\texttt{0.0};\n          \\item[a]\n\n\nWidth of the gaussian. Default value \\texttt{1.0}.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Gaussian \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.IncreasingSigmoid \\textit{(class)}|(}\n\\subsection{Class IncreasingSigmoid}\n\n    \\label{peach:fuzzy:mf:IncreasingSigmoid}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.IncreasingSigmoid}}\n\\end{tabular}\n\n\nIncreasing Sigmoid function.\n\nGiven the center and the slope, creates an increasing sigmoidal function.\nIt goes to \\texttt{0} as \\texttt{x} approaches to -infinity, and goes to \\texttt{1} as\n\\texttt{x} approaches infinity, that is:\n\\begin{quote}\n\n\\texttt{1 / (1 + exp(-a*(x - x0))}\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}=\\texttt{0.0}, \\textit{a}=\\texttt{1.0})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nCenter of the sigmoid. Default value \\texttt{0.0}. The function evaluates\nto \\texttt{0.5} if \\texttt{x = x0};\n          \\item[a]\n\n\nSlope of the sigmoid. Default value \\texttt{1.0}.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.IncreasingSigmoid \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.DecreasingSigmoid \\textit{(class)}|(}\n\\subsection{Class DecreasingSigmoid}\n\n    \\label{peach:fuzzy:mf:DecreasingSigmoid}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.DecreasingSigmoid}}\n\\end{tabular}\n\n\nDecreasing Sigmoid function.\n\nGiven the center and the slope, creates an decreasing sigmoidal function.\nIt goes to \\texttt{1} as \\texttt{x} approaches to -infinity, and goes to \\texttt{0} as\n\\texttt{x} approaches infinity, that is:\n\\begin{quote}\n\n\\texttt{1 / (1 + exp(a*(x - x0))}\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}=\\texttt{0.0}, \\textit{a}=\\texttt{1.0})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nCenter of the sigmoid. Default value \\texttt{0.0}. The function evaluates\nto \\texttt{0.5} if \\texttt{x = x0};\n          \\item[a]\n\n\nSlope of the sigmoid. Default value \\texttt{1.0}.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.DecreasingSigmoid \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.RaisedCosine \\textit{(class)}|(}\n\\subsection{Class RaisedCosine}\n\n    \\label{peach:fuzzy:mf:RaisedCosine}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.RaisedCosine}}\n\\end{tabular}\n\n\nRaised Cosine function.\n\nGiven the center and the frequency, creates a function that is a period of\na raised cosine, that is:\n\\begin{quote}\n\n0, if \\texttt{x <= xm - pi/w} or \\texttt{x > xm + pi/w};\n\n\\texttt{0.5 + 0.5 * cos(w*(x - xm))}, if \\texttt{xm - pi/w <= x < xm + pi/w};\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{xm}=\\texttt{0.0}, \\textit{w}=\\texttt{1.0})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[xm]\n\n\nCenter of the cosine. Default value \\texttt{0.0}. The function evaluates\nto \\texttt{1} if \\texttt{x = xm};\n          \\item[w]\n\n\nFrequency of the cosine. Default value \\texttt{1.0}.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.RaisedCosine \\textit{(class)}|)}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Bell \\textit{(class)}|(}\n\\subsection{Class Bell}\n\n    \\label{peach:fuzzy:mf:Bell}\n\\begin{tabular}{cccccccc}\n% Line for object, linespec=[False, False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n&&\n  \\\\\n% Line for peach.fuzzy.mf.Membership, linespec=[False]\n\\multicolumn{4}{r}{\\settowidth{\\BCL}{peach.fuzzy.mf.Membership}\\multirow{2}{\\BCL}{peach.fuzzy.mf.Membership}}\n&&\n  \\\\\\cline{5-5}\n  &&&&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&&&\\multicolumn{2}{l}{\\textbf{peach.fuzzy.mf.Bell}}\n\\end{tabular}\n\n\nGeneralized Bell function.\n\nA generalized bell is a symmetric function with its peak in its center and\nfast decreasing to \\texttt{0} outside a given interval, that is:\n\\begin{quote}\n\n\\texttt{1 / (1 + ((x - x0)/a)**(2*b))}\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{x0}=\\texttt{0.0}, \\textit{a}=\\texttt{1.0}, \\textit{b}=\\texttt{1.0})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nInitializes the function.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[x0]\n\n\nCenter of the bell. Default value \\texttt{0.0}. The function evaluates to\n\\texttt{1} if \\texttt{x = xm};\n          \\item[a]\n\n\nSize of the interval. Default value \\texttt{1.0}. A generalized bell\nevaluates to \\texttt{0.5} if \\texttt{x = -a} or \\texttt{x = a};\n          \\item[b]\n\n\nMeasure of \\emph{flatness} of the bell. The bigger the value of \\texttt{b},\nthe flatter is the resulting function. Default value \\texttt{1.0}.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_init\\_\\_\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n\nMaps the function on a vector\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA \\texttt{FuzzySet} object containing the evaluation of the function over\neach of the components of the input.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      Overrides: peach.fuzzy.mf.Membership.\\_\\_call\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}!peach.fuzzy.mf.Bell \\textit{(class)}|)}\n    \\index{peach \\textit{(package)}!peach.fuzzy \\textit{(package)}!peach.fuzzy.mf \\textit{(module)}|)}\n", "meta": {"hexsha": "c4712816fc0c64a151e962c1c5097fc6068eb432", "size": 72442, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/peach/doc/ref/pdf/peach.fuzzy.mf-module.tex", "max_stars_repo_name": "serddmitry/goog_challenge", "max_stars_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_stars_repo_licenses": ["Apache-1.1"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-08-09T21:34:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-09T21:34:05.000Z", "max_issues_repo_path": "lib/peach/doc/ref/pdf/peach.fuzzy.mf-module.tex", "max_issues_repo_name": "serddmitry/goog_challenge", "max_issues_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_issues_repo_licenses": ["Apache-1.1"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/peach/doc/ref/pdf/peach.fuzzy.mf-module.tex", "max_forks_repo_name": "serddmitry/goog_challenge", "max_forks_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_forks_repo_licenses": ["Apache-1.1"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.2483953787, "max_line_length": 200, "alphanum_fraction": 0.5786560283, "num_tokens": 24152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203136, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.4465309512827245}}
{"text": "\\section{Type theoretic replacement}\n\n\\subsection{Essentially small types and maps}\nIt is a trivial observation, but nevertheless of fundamental importance, that by the univalence axiom the identity types of $\\UU$ are equivalent to types in $\\UU$, because it provides an equivalence $\\eqv{(A=B)}{(\\eqv{A}{B})}$, and the type $\\eqv{A}{B}$ is in $\\UU$ for any $A,B:\\UU$. Since the identity types of $\\UU$ are equivalent to types in $\\UU$, we also say that the universe is \\emph{locally small}.\n\n\\begin{defn}\\label{defn:ess_small}\n\\begin{enumerate}\n\\item A type $A$ is said to be \\define{essentially small}\\index{essentially small!type|textbf} if there is a type $X:\\UU$ and an equivalence $\\eqv{A}{X}$. We write\\index{ess_small(A)@{$\\mathsf{ess\\usc{}small}(A)$}|textbf}\n\\begin{equation*}\n\\mathsf{ess\\usc{}small}(A)\\defeq\\sm{X:\\UU}\\eqv{A}{X}.\n\\end{equation*}\n\\item A map $f:A\\to B$ is said to be \\define{essentially small}\\index{essentially small!map|textbf} if for each $b:B$ the fiber $\\fib{f}{b}$ is essentially small.\nWe write\\index{ess_small(f)@{$\\mathsf{ess\\usc{}small}(f)$}|textbf}\n\\begin{equation*}\n\\mathsf{ess\\usc{}small}(f)\\defeq\\prd{b:B}\\mathsf{ess\\usc{}small}(\\fib{f}{b}).\n\\end{equation*}\n\\item A type $A$ is said to be \\define{locally small}\\index{locally small!type} if for every $x,y:A$ the identity type $x=y$ is essentially small.\nWe write\\index{loc_small(A)@{$\\mathsf{loc\\usc{}small}(A)$}|textbf}\n\\begin{equation*}\n\\mathsf{loc\\usc{}small}(A)\\defeq \\prd{x,y:A}\\mathsf{ess\\usc{}small}(x=y).\n\\end{equation*}\n\\end{enumerate}\n\\end{defn}\n\n\\begin{lem}\\label{lem:isprop_ess_small}\nThe type $\\mathsf{ess\\usc{}small}(A)$ is a proposition for any type $A$.\\index{essentially small!is a proposition|textit}\n\\end{lem}\n\n\\begin{proof}\nLet $X$ be a type. Our goal is to show that the type\n\\begin{equation*}\n\\sm{Y:\\UU}\\eqv{X}{Y}\n\\end{equation*}\nis a proposition. Suppose there is a type $X':\\UU$ and an equivalence $e:\\eqv{X}{X'}$, then the map\n\\begin{equation*}\n(\\eqv{X}{Y})\\to (\\eqv{X'}{Y})\n\\end{equation*}\ngiven by precomposing with $e^{-1}$ is an equivalence. This induces an equivalence on total spaces\n\\begin{equation*}\n\\eqv{\\Big(\\sm{Y:\\UU}\\eqv{X}{Y}\\Big)}{\\Big(\\sm{Y:\\UU}\\eqv{X'}{Y}\\Big)}\n\\end{equation*}\nHowever, the codomain of this equivalence is contractible by \\cref{thm:univalence}. Thus it follows by \\cref{cor:contr_prop} that the asserted type is a proposition.\n\\end{proof}\n\n\\begin{cor}\nFor each function $f:A\\to B$, the type $\\mathsf{ess\\usc{}small}(f)$ is a proposition, and for each type $X$ the type $\\mathsf{loc\\usc{}small}(X)$ is a proposition.\n\\end{cor}\n\n\\begin{proof}\nThis follows from the fact that propositions are closed under dependent products, established in \\cref{thm:trunc_pi}.\n\\end{proof}\n\n\\begin{thm}\\label{thm:fam_proj}\nFor any small type $A:\\UU$ there is an equivalence\n\\begin{equation*}\n\\mathsf{map\\usc{}fam}_A:\\eqv{(A\\to \\UU)}{\\Big(\\sm{X:\\UU} X\\to A\\Big)}.\n\\end{equation*}\n\\end{thm}\n\n\\begin{proof}\nNote that we have the function\n\\begin{equation*}\n\\varphi :\\lam{B} \\Big(\\sm{x:A}B(x),\\proj 1\\Big) : (A\\to \\UU)\\to \\Big(\\sm{X:\\UU}X\\to A\\Big).\n\\end{equation*}\nThe fiber of this map at $(X,f)$ is by univalence and function extensionality equivalent to the type\n\\begin{equation*}\n\\sm{B:A\\to \\UU}{e:\\eqv{(\\sm{x:A}B(x))}{X}} \\proj 1\\htpy f\\circ e.\n\\end{equation*}\nBy \\cref{ex:triangle_fib} this type is equivalent to the type\n\\begin{equation*}\n\\sm{B:A\\to \\UU}\\prd{a:A} \\eqv{B(a)}{\\fib{f}{a}},\n\\end{equation*}\nand by `type theoretic choice', which was established in \\cref{thm:choice}, this type is equivalent to\n\\begin{equation*}\n\\prd{a:A}\\sm{X:\\UU}\\eqv{X}{\\fib{f}{a}}.\n\\end{equation*}\nWe conclude that the fiber of $\\varphi$ at $(X,f)$ is equivalent to the type $\\mathsf{ess\\usc{}small}(f)$. However, since $f:X\\to A$ is a map between small types it is essentially small. Moreover, since being essentially small is a proposition by \\cref{lem:isprop_ess_small}, it follows that $\\fib{\\varphi}{(X,f)}$ is contractible for every $f:X\\to A$. In other words, $\\varphi$ is a contractible map, and therefore it is an equivalence.\n\\end{proof}\n\n\\begin{rmk}\nThe inverse of the map\n\\begin{equation*}\n\\varphi : (A\\to \\UU)\\to \\Big(\\sm{X:\\UU}X\\to A\\Big).\n\\end{equation*}\nconstructed in \\cref{thm:fam_proj} is the map $(X,f)\\mapsto \\fibf{f}$.\n\\end{rmk}\n\n\\begin{thm}\\label{thm:classifier}\nLet $f:A\\to B$ be a map. Then there is an equivalence\n\\begin{equation*}\n\\eqv{\\mathsf{ess\\usc{}small}(f)}{\\mathsf{is\\usc{}classified}(f)},\n\\end{equation*}\nwhere $\\mathsf{is\\usc{}classified}(f)$\\index{is_classified(f)@{$\\mathsf{is\\usc{}classified}(f)$}|textbf} is the type of quadruples $(F,\\tilde{F},H,p)$ consisting of maps\n$F:B\\to \\UU$ and $\\tilde{F}:A\\to \\sm{X:\\UU}X$, a homotopy $H:F\\circ f\\htpy \\proj 1\\circ \\tilde{F}$,  such that the commuting square\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[r,\"\\tilde{F}\"] \\arrow[d,swap,\"f\"] & \\sm{X:\\UU}X \\arrow[d,\"\\proj 1\"] \\\\\nB \\arrow[r,swap,\"F\"] & \\UU\n\\end{tikzcd}\n\\end{equation*}\nis a pullback square, as witnessed by $p$\\footnote{The universal property of the pullback is not expressible by a type. However, we may take the type of $p:\\isequiv(h)$, where $h:A\\to B\\times_\\UU\\big(\\sm{X:\\UU}X\\big)$ is the map obtained by the universal property of the canonical pullback.}. If $f$ comes equipped with a term of type $\\mathsf{is\\usc{}classified}(f)$, we also say that $f$ is \\define{classified}\\index{classified by the universal family|textbf} by the universal family. \n\\end{thm}\n\n\\begin{proof}\nFrom \\cref{ex:sq_fib} we obtain that the type of pairs $(\\tilde{F},H)$ is equivalent to the type of fiberwise transformations\n\\begin{equation*}\n\\prd{b:B}\\fib{f}{b}\\to F(b).\n\\end{equation*}\nBy \\cref{cor:pb_fibequiv} the square is a pullback square if and only if the induced map\n\\begin{equation*}\n\\prd{b:B}\\fib{f}{b}\\to F(b)\n\\end{equation*}\nis a fiberwise equivalence. Thus the data $(F,\\tilde{F},H,pb)$ is equivalent to the type of pairs $(F,e)$ where $e$ is a fiberwise equivalence from $\\fibf{f}$ to $F$. By \\cref{thm:choice} the type of pairs $(F,e)$ is equivalent to the type $\\mathsf{ess\\usc{}small}(f)$. \n\\end{proof}\n\n\\begin{rmk}\nFor any type $A$ (not necessarily small), and any $B:A\\to \\UU$, the square\\index{Sigma-type@{$\\Sigma$-type}!as pullback of universal family|textit}\n\\begin{equation*}\n\\begin{tikzcd}[column sep=6em]\n\\sm{x:A}B(x) \\arrow[d,swap,\"\\proj 1\"] \\arrow[r,\"{\\lam{(x,y)}(B(x),y)}\"] & \\sm{X:\\UU}X \\arrow[d,\"\\proj 1\"] \\\\\nA \\arrow[r,swap,\"B\"] & \\UU\n\\end{tikzcd}\n\\end{equation*}\nis a pullback square. Therefore it follows that for any family $B:A\\to\\UU$ of small types, the projection map $\\proj 1:\\sm{x:A}B(x)\\to A$ is an essentially small map.\nTo see that the claim is a direct consequence of \\cref{lem:pb_subst} we write the asserted square in its rudimentary form:\n\\begin{equation*}\n%\\begin{gathered}[b]\n\\begin{tikzcd}[column sep=6em]\n\\sm{x:A}\\mathrm{El}(B(x)) \\arrow[d,swap,\"\\proj 1\"] \\arrow[r,\"{\\lam{(x,y)}(B(x),y)}\"] & \\sm{X:\\UU}\\mathrm{El}(X) \\arrow[d,\"\\proj 1\"] \\\\\nA \\arrow[r,swap,\"B\"] & \\UU.\n\\end{tikzcd}%\\\\[-\\dp\\strutbox]\\end{gathered}\\qedhere\n\\end{equation*}\n\\end{rmk}\n\nIn the following theorem we show that a type is small if and only if its diagonal is classified by $\\UU$.\n\n\\begin{thm}\nLet $A$ be a type. The following are equivalent:\n\\begin{enumerate}\n\\item $A$ is locally small.\\index{locally small|textit}\n\\item There are maps $I:A\\times A\\to\\UU$ and $\\tilde{I}:A\\to\\sm{X:\\UU}X$, and a homotopy $H:I\\circ \\delta_A\\htpy \\proj 1\\circ\\tilde{I}$\nsuch that the commuting square\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[r,\"\\tilde{I}\"] \\arrow[d,swap,\"\\delta_A\"] & \\sm{X:\\UU}X \\arrow[d,\"\\proj 1\"] \\\\\nA\\times A \\arrow[r,swap,\"{I}\"] & \\UU\n\\end{tikzcd}\n\\end{equation*}\nis a pullback square.\\index{diagonal!of a type|textit}\n\\end{enumerate}\n\\end{thm}\n\n\\begin{proof}\nIn \\cref{ex:diagonal} we have established that the identity type $x=y$ is the fiber of $\\delta_A$ at $(x,y):A\\times A$. Therefore it follows that $A$ is locally small if and only if the diagonal $\\delta_A$ is essentially small.\nNow the result follows from \\cref{thm:classifier}.\n\\end{proof}\n\n\\subsection{Smallness of images}\n\n\\begin{exercises}\n\\item\n\\begin{subexenum}\n\\item Show that any proposition is locally small.\\index{proposition!is locally small}\n\\item Show that any essentially small type is locally small.\\index{essentially small!type!is locally small}\n\\item Show that the function type $A\\to X$ is locally small whenever $A$ is essentially small and $X$ is locally small.\n\\end{subexenum}\n\\item Let $f:A\\to B$ be a map. Show that the following are equivalent:\n\\begin{enumerate}\n\\item The map $f$ is \\define{locally small}\\index{locally small!map|textbf} in the sense that for every $x,y:A$, the action on paths of $f$\n\\begin{equation*}\n\\apfunc{f}:(x=y)\\to (f(x)=f(y))\n\\end{equation*}\nis an essentially small map.\n\\item The diagonal $\\delta_f$ of $f$ as defined in \\cref{ex:trunc_diagonal_map} is classified by the universal fibration.\n\\end{enumerate}\n\\end{exercises}\n", "meta": {"hexsha": "ff6f5f4fc1bf14181926ddf94f3c67e3af99c57b", "size": 8908, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Book/replacement.tex", "max_stars_repo_name": "tadejpetric/HoTT-Intro", "max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Book/replacement.tex", "max_issues_repo_name": "tadejpetric/HoTT-Intro", "max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Book/replacement.tex", "max_forks_repo_name": "tadejpetric/HoTT-Intro", "max_forks_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.3276836158, "max_line_length": 487, "alphanum_fraction": 0.700830714, "num_tokens": 3123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.44652226034739784}}
{"text": "\n\\section{Artificial Intelligence}\n\\subsection{Basic Problems \\& Nomenclature}\nThere are some goal states and one initial state. The objective is to find the goal state that is closer (with the shortest path to the root/ with the least search cost). Is given as the solution the steps necessary to perform that path.\n\nTo keep the formulation as general as possible, abstractions are required, keeping in mind that they will need a correspondence when applied to a real problem.\n\nExample of the application to a problem: a vacuum cleaner that needs to clean every square. In this case, only 2 squares are presented, no localization sensors are present, only \"rubbish\" sensors that tell if the current square is dirty or not.\n\nTherefore:\n\\begin{itemize}\n    \\item \\ul{States}: $<r, d_1, d_2>$ where $r$ is the robot position, $d_1$ and $d_2$ are binary, representing the existence of dirt in each of the rooms.\n    \\item \\ul{Operators/Actions}: L (go left), R (go right) or S (suck dirt)\n    \\item \\ul{Goal Test}: $d_1$ = False and $d_2$ = False. (($d_1$ nor $d_2$) == 1)\n    \\item \\ul{Initial State}: $<r, d_1, d_2> = <1, T, T>$ is at square 1, and squares 1 and 2 are dirty\n    \\item \\ul{Step Cost}: the description of each action cost. In this case, 1 for each one.\n\\end{itemize}\n\n\n\\quickimagesidebyside{AIML/cap3-001.png}{1}{AIML/cap3-002.png}{.8}\n\n\\quickimagesidebyside{AIML/cap3-003.png}{1}{AIML/cap3-004.png}{1}\n\n\\quickimagesidebyside{AIML/cap3-005.png}{1}{AIML/cap3-007.png}{1}\n\n\n\n\nAs you can see, every problem is very well defined in terms of the start, the end, the possible moves and what makes a solution better than other. Therefore, the conditions to put the computer thinking how to get from the possible steps to the best solution are assembled. One way the computer should be able to get to the solution is by exploring every move combination and check the state it ended up with.\n\n\nGiven the initial state, use the operators to generate successor states.\n\n\\quickimage{AIML/cap3-008.png}{.6}\n\nThen a choice of which is more \"profitable\" or more likely to lead to a goal state needs to be made and this cycle continues until the arrival at a goal state.\n\n\\quickimage{AIML/cap3-009.png}{.6}\n\nIn this case, the solution would be $\\{S, R, S\\}$.\n\n\n\n\nHowever, before diving directly in algorithms, is important to note the characteristics of the Environment and of the Agent. Based on these we'll be able to perform much better choosing the search algorithm that is best for us.\n\n\\subsection{Environment} %FORMULATE THIS SECTION BETTER!!!!!!!!!!!!!!!!!!\n\nObservability: how much can the agent know about the environment.\n\nAn environment is fully observable if the agent can see everything. Or partial observable:\n- part of the state is occulted and you simply can't \n\n\n\nDeterministic: the effect of the actions are predictable\nIf I move one queen from one place to the other, I can predict the effects, what is attacking what, etc\\dots\nInstead of Deterministic, it can be stochastic, where the outcomes are functions of probability functions. Therefore, you can't be 100\\% sure of the outcome. Therefore, you can use probability to make choices\\dots\n\n\nNeither the environment nor the agent performance change while the agent is deliberating. --> Static.\n\nIn a dynamic environment, the agent performance can change with time. \n\nSemi-dynamic means that the world is static, but the performance is changing. \nex: turn game where the game doesn't change while you are thinking but the more you take, the less point you get.\n\nContinuous or discrete\n\n\nSequential or episodic. Episodic means that one episode doesn't influence the next one. It's very related with causality. In episodic environments, there's no influence in consequent problems.\n\nE.g. one game of chess is sequential, but different games are episodic.\n\n\nThe outcomes for all actions are given. --> Known environment.\n\n\n\nIn a case where the less time you spend thinking before answering, \n\n\nKnowing these is very important because it allows us to best choose the shelf of methods from which we take our algorithms from. Some are best from some things and some can only be used in certain situations as well.\n\n\nInternally to the agent, you have a way of representing of the world. (Internal representation)\n\nExample when you don't have an internal representation: random vacuum cleaning robots don't know anything about the environment, they just rotate randomly when they see an object.\n\n%CHECK: how many iterations are needed depending on uniform function of the angle. Maybe if it rotates only between pi/2 and pi, it will clean everything quicker.\n\n\n\\quickimage{AIML/cap2-001.png}{.5}\n\\quickimage{AIML/cap2-002.png}{.5}\n\n\\subsection{Agent}\n\nModel-based: typically, when you have partial observability.\n\nGoal-based: when you aim for a goal. You have states and actions and can search for the goal.\n\nUtility-based: are very similar to goal-based but are a bit more, not all goals are the same. There a preference between goals. \nUtility Theory handles how to translate preferences to numbers. \n\n\n\n\n\n\n\n\\subsection{Search Problems}\n\nIn essence, is necessary some \\bb{Search Terminology} to refer to certain things:\n\n\\quickimage{AIML/cap3-010.png}{.5}\n\nGeneral algorithm shape, starting with $open\\_list = \\{initial_node\\}$, iterate over:\n\\begin{enumerate}\n    \\item Select a node from the open\\_list;\n    \\item Check if it's a goal node (in case it satisfies the goal test). If yes, return solution by backing up to the root;\n    \\item If not, remote it from the open\\_list, expand it with the successor function and insert the nodes that come from there to the open\\_list.\n\\end{enumerate}\n\nDifferent selection criteria leads to a variety of search methods.\n\nIf it's tree based, then no nodes will be repeated and it's not necessary to have a list of the already visited nodes. In a graph however, is needed to have a list of these, or else a cycle is possible.\n\nTo evaluate the algorithm, many parameters may be enumerated:\n\n\\quickimage{AIML/cap3-011.png}{.5}\n\n\\vspace{.5cm}\nMentioning types of search strategies:\n\n\\quickimage{AIML/cap3-012.png}{.5}\n\n\n\\subsection{Uniformed Search Strategies}\n\nA list of \\bb{Uniformed search strategies} we'll have a deeper look to:\n\\begin{itemize}\n    \\item \\bb{Breadth-first Search} - Select \\ul{earliest} expanded node first - uses a FIFO queue (First In, First out). This leads to opening every node at the safe depth first before moving the deeper nodes. \n    \n    \\quickimage{AIML/cap3-013.png}{.5}\n\n    Because order of depth is followed and every node checked, this search strategy is \\ul{Complete} and \\ul{Optimal} (if the path cost increases - or at least doesn't decreases - with depth).\n    Being \\bb{d} the depth of the solution and \\bb{b} the branching factor(max number of successors of a node.) then in the worst case, the total number of nodes generated is: $1 + b + b^2 + b^3 + \\dots + b^d$\n\n    Time Complexity - O($b^d$)\n    Space Complexity - O(sum no of nodes) = O($b^d$)\n\n    \\quickimage{AIML/cap3-014.png}{.5}\n\n    Note that it makes a difference if you test the node before or after expanding it. If it's tested before, there's no need of expanding the node. If the test is made only after the expansion, the complexities grows to O($b^{d+1}$). \n\n\n    \\item \\bb{Uniform-cost Search} - expands the node that has the smallest cost from the root to it. \n\n    \\quickimage{AIML/cap3-015.png}{.5}\n\n    Note that each action generates one possible state from the state where the robot was previously.\n\n    This search strategy is only complete and optimal if the step costs are strictly positive. Else, it can give several steps that cost nothing to places far away from the solution.\n\n    \\item \\bb{Depth-first Search} - Exactly as the name suggests, goes until the deepest node first, and only then looks at the other nodes at the first level. Therefore, it can be very inefficient on a large or infinite tree. Open the last node added to the list (LIFO- Last In, First Out).\n\n\n    \\quickimage{AIML/cap3-016.png}{.5}\n\n    \n    \\item \\bb{Backtrack Search} - a variation of depth-first, but expands one node at a time, only stores in memory that only node and the expansion is made by modifying the node, while backtrack is nothing more than undoing the modification..\n    \n    It's not complete nor it is optimal... but saves a lot of memory.\n\n    \\item \\bb{Depth-limited search} - another variation of depth-first where limiting the search tree to a depth L, is possible to contain the inefficiency. It's complete if the depth of the solution if smaller than L but still not optimal. \n    \n    Time complexity: O($b^L$)\n    Space complexity: O($b \\times L$)\n\n    \\item \\bb{Iterative deepening depth-first search} - A variation of the previous one. In this one, the idea will be to run depth-limited search for an increasing L. Run for L=1, L=2, \\dots\n    \n    This way, it is complete and it's optimal (if the path cost is a non-decreasing function of depth).\n\n    Time complexity: O($b^d$)\n    Space complexity: O($b \\times d$)\n\n    \\quickimage{AIML/cap3-017.png}{.5}\n\n\n    \\item \\bb{Bidirectional Search} - Search both from initial node and from the gold node. Note however that can only be used when a goal node is known and when the parent nodes can be computed given its child (through the sets of available actions). It's complete (if breath-first in both directions) and Optimal, if the step costs are equal.\n    \n    Time and space complexity: O($b^{d/2}$)\n\n    \\quickimage{AIML/cap3-018.png}{1}\n\\end{itemize}\n\n\nA summary of the above analysis:\n    \n\\quickimage{AIML/cap3-019.png}{.7}\n\nA \\bb{General Search Algorithm} can be formulated in the following way:\n\n\\quickimage{AIML/cap3-020.png}{.6}\n\n\n\nFinally, there are problem dependent and problem independent details. The search strategies are problem independent, but how we define the actions, states, ect\\dots is problem dependent. And the way we see and think about the problem can be highly related to the way we represent it. \n\nAn incredibly well formulated example is the Mutilated Chess Board problem. If we take just the squares of the corners of a chess board, can we still fill the whole board with dominos (each domino takes 2 squares). It becomes slightly harder! If you keep removing squares it gets increasingly harder to figure out by head. \n\n\\quickimage{AIML/cap2-003.png}{.6}\n\nHowever, if you represent the chess board as the remaining black and white pieces and notice that a domino piece must always cover one black and one white squares, then by taking those two corners then 30 black and 32 white squares will be remaining making it impossible to fill with dominos. As a matter of fact, accordingly with Gomory's Theorem is also possible to say that if 2 square of opposite colours are removed then is always possible to fill the board with dominos! More in: \\href{https://en.wikipedia.org/wiki/Mutilated_chessboard_problem}{\\ul{Mutilated chessboard problem}}\n\nThe bottom line is that the representation (problem dependent details) matters.\n\n\nWith this is mind, consider the following example:\n\nInitial state with:\nbedroom(3), living room(2), kitchen(3), hall(2), truck(0)\n\n\n\n\\begin{enumerate}[a)]\n    \\item State: $<pos, n_{bedroom}, n_{living}, n_{kitchen}, n_{hall}, n_{truck}>$\n    \\item Initial State: $<truck, 3,2,3,2,0>$\n    \\item $m$ for move, $p$ for push $<m_N, m_S, m_E, m_W, p_N, p_W, p_E, p_W >$. However, is only possible to push in directions where there are rooms (as for walking) and when there are boxes in the current room we are located in.\n    \\item A goal condition could be $n_{truck} = 10$. Another could be the sum of all rooms to be 0. But the first one is more elegant and also seems more general... We don't want to throw boxes out of the window.\n\\end{enumerate}\n\n\n\n\n\n\nSometimes, just finding the solution is enough. Some times, there's a best solution.\n\n\nThe heuristic (the only difference between informed and uninformed search) is a function of a state that gives us the appreciation we have for that state - how good that state is. If we want the best solution, we must have the heuristic function is key. If you just want a solution, that function can be much simpler or even nonexistent.\n\n\n\n\n\n\n\n\\subsection{Informed Search Strategies}\nA problem-solving agent is a goal-based agent that acts on the environment,\nleading him to go through a series of states in order to achieve the desired goal.\n\n\n\\bb{In this course, we only study the single-state problems}, meaning that continuous, dynamic, non-deterministic or partially-observable problems are out of scope.\n\n\n\\quickimage{AIML/cap3-021.png}{.6}\n\nThe difference between Informed and Uniformed is the heuristic function. In informed search, we know something about the problem that allows us to choose better paths while doing uninformed search the algorithm would simply cover all paths.\n\nAs a reminder, the Uniform search is nothing more than opening the one closest to the root first and discarding all repeated nodes with a longer path to them.\n\nThe \\bb{evaluation function} $f(n)$ that outputs the value accordingly to which the nodes will be expanded first or not include as a component the \\bb{heuristic function} $h(n)$, in case of informed search. One good example of an heuristic is the straight line distance. The closer something is in a straight line, probably the closer it is in general.\n\n\nFrom now on, the only difference is in the evaluation function! \n\\begin{itemize}\n    \\item Greedy best-first search: uses $f(n) = h(n)$\n    \\item A* Search: uses $f(n) = g(n) + h(n)$ where $g(n)$ is the \\bb{path cost} function. Exactly identical to Uniform-cost-search but has the additional contribution of $h(n)$\n\\end{itemize}\n\nDepending on what we are doing our search on, graphs or trees, there are different requirements on the heuristic function to achieve optimality.\nIf graphs, then \\bb{consistency} is required for optimality. \nIf the search is on trees, then \\bb{admissibility} is enough for optimality.\n\nBut what is Admissibility and Consistency?\n\nAdmissibility is never overestimating the cost to reach the goal. For instances, the straight line distance is an optimistic distance and presents a good heuristic.\n\nConsistency is exactly that. The heuristic in n must be smaller than the cost necessary to reach n' from n plus the heuristic in the previous node. In essence, the difference between heuristics in adjacent nodes can't me bigger than the cost of going from one to the other.\n\n\n\\quickimage{AIML/cap3-022.png}{.6}\n\nSome light about heuristics:\n\n\n\\quickimage{AIML/cap3-023.png}{.6}\n\\quickimage{AIML/cap3-024.png}{.6}\n\n\nNow, obviously, one of the heuristics will give results closer to the reality and the \nother will underestimate more severely. \\bb{Does this difference affects the quality of the heuristic?}\n\nThe quality of the heuristic can be assessed by the \\bb{effective branching factor} $b^*$ .\nThe \\bb{branching factor} of a tree is the maximum number of successors a node has. It is a useful measure to quantify the maximum number of nodes it will be necessary to expand. The effective branching factor is the necessary branching factor a uniform tree would have to have to expand as many nodes as were expanded in our tree.\n\nTherefore, because A* does a better job (due to the heuristic), the solution will be a smaller branching factor than the uniform tree. \n\n\\quickimage{AIML/cap3-025.png}{.6}\n\n%how to solve this shit?\n\nIf $h_2(n) \\geq h_1(n)$ then $h_2$ dominates $h_1$ and domination translates directly into efficiency! Because A* using $h_2$ will never expand more nodes than using $h_1$.\n\n\nThis is true because all nodes with an evaluation smaller than the cost of the solution will be evaluated. Therefore, by making $h(n)$ as big as possible, less nodes will be in that set!\n\n%Continue 3.6.2\n\n\\begin{center}\n    \\bb{Therefore it is very important to find an heuristic that estimates the distance to the solution as close to the real distance as possible.}\n\\end{center}\n\n\n\n\nOne way of coming up with good heuristics is to solve the relaxed problem perfectly:\na problem where there are no constraints, no movement constraints, no nothing\\dots\n\nThen that apply that heuristic to the constraint model because it will certainly underestimate but may be close to the actual value.\n\n\\quickimage{AIML/cap3-026.png}{.6}\n\n\nConsidering only one of them at the time:\n\\begin{itemize}\n    \\item From a), there's the Manhattan distance.\n    \\item From b) the Gasching's heuristic.\n    \\item From c), the misplaced tiles heuristic because the actual distance would be one movement.\n\\end{itemize}\n\n\n\n\nIf we have many heuristics, it may be hard to find a clear best heuristic. Therefore, one may simply use the maximum of them at each node as a new heuristic and that would be the best one and one that is still admissible.\n\\quickimage{AIML/cap3-027.png}{.6}\n\n\n\nA curiosity, a program called ABSOLVER (Prieditis, 1993) was able to create relaxed problems from problem definitions and did output very useful results for Rubik's Cube and for 8-puzzle.\n\n\nOne other way of learning heuristics is from experience. By solving that kind of problem a few times, we start to know when we are getting closer and that can be coded into an heuristic.\n\n\n\\subsection{The best of formal and natural languages - First Order Logic}\n\nThe Chapter 8 of the book of the course is a wonderful read. Here is the key content:\n\nOne can define objects, relations (among objects) and functions (relations with an unique output for the given input).\n\n\\quickimage{AIML/cap3-029.png}{.6}\n\n\nThe \\bb{domain} is the set of objects. Symbols come in three kinds: \\bb{constant symbols}, these stand for objects, \\bb{predicate symbols} that stand for relations and \\bb{function symbols} which stand for functions. \\ul{Symbols will begin wtith uppercase letters.}\n\n\n\n\\quickimage{AIML/cap3-030.png}{.6}\n", "meta": {"hexsha": "f0e9e74e5a7b59d0c3132911552337f6014f336e", "size": 17880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/AI.tex", "max_stars_repo_name": "jmoraispk/TheDocument", "max_stars_repo_head_hexsha": "ef14eaaec34cb09a0945ff4647e87ff77eac6890", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/AI.tex", "max_issues_repo_name": "jmoraispk/TheDocument", "max_issues_repo_head_hexsha": "ef14eaaec34cb09a0945ff4647e87ff77eac6890", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/AI.tex", "max_forks_repo_name": "jmoraispk/TheDocument", "max_forks_repo_head_hexsha": "ef14eaaec34cb09a0945ff4647e87ff77eac6890", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5290858726, "max_line_length": 586, "alphanum_fraction": 0.7580536913, "num_tokens": 4355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4465222526030001}}
{"text": "%! Author = tstreule\n\n\\section{Optical Biosensors}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\t\\subsection{Optical Methods}\n%\t%\n%\t\\begin{itemize}\n%\t\t\\item \\underline{Reflection based} (ELM, SAR)\\\\\n%\t\t\tinformation through $\\Delta\\phi$ and $\\Delta$amplitude\n%\t\t\\item \\underline{Interference based} (OIA, TINS)\\\\\n%\t\t\tinformation through color change \\quad\n%\t\t\tvery sensitive to $\\Delta$thickness\n%\t\t\\item \\underline{Evanescent field} techniques (\\textbf{SPR}, \\textbf{OWLS}, RM, FTIR, SAR)\\\\\n%\t\t\tinformation through $\\Delta n$ ($n$: refractive index)\n%\t\\end{itemize}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{EM}\n%\n\\textbf{Relations}:\\\\\n$c_0 = \\frac{1}{\\sqrt{\\epsilon_0\\mu_0}}$ \\hfill\n$k_0 = \\frac{2\\pi}{\\lambda_0} = \\frac{\\omega}{c_0} = \\omega\\sqrt{\\epsilon_0\\mu_0}$ \\hfill\n$k = \\frac{2\\pi n}{\\lambda}$ \\hfill\n$n = \\frac{c_0}{c} = \\sqrt{\\epsilon_r\\mu_r} \\simeq \\sqrt{\\epsilon_r}$\n\\formula{Dispersion relation}{k^2 = \\epsilon\\omega^2 = \\epsilon k_0^2c_0^2 = k_0\\frac{\\epsilon}{\\epsilon_0} = k_0^2\\epsilon_r = (k_0n)^2}\n\n\\formbox{\\textbf{Plane waves}}{\\vec{E}(\\vec{r},t) = \\vec{E}_0\\;\\eu^{\\iu(\\vec{k}\\vec{r}-\\omega t)}} \\\\\nwhereby \\hfill\n$\\partial_t \\hat= -\\iu\\omega$, \\hfill\n$\\partial_x \\hat= \\iu k_x$, \\hfill\n$\\partial_z \\hat= \\iu k_z$, \\hfill\n$\\partial_y \\hat= 0$ (infinite extent)\n\\formula{Depth of penetration}{d_p = \\frac{\\lambda}{4\\pi} \\frac{1}{\\sqrt{n\\ped{inc}^2\\sin^2\\theta -n_2^2}}}\n\\quad (about $\\unit[500]{nm}$)\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Evanescent Field Techniques}\n%\n\\formtex{\\textit{Recap}}{Always \\textbf{total reflection} for $n\\ped{inc}>n_2$}\n\\formtex{Evanescence}{Negligible change of sensitivity compared to}\n\\formtex{~}{the size of the antibodies}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{SPR \\textnormal{-- Surface Plasmon Resonance}}\n%\n\\formtex{\\textbf{Plasmon}}{\\underline{quantum} of electron density wave in a metal}\n\\formtex{\\textbf{Plasmon Polariton}}{mixt. of photon (diel.) and el. dens. wave (met.)}\n\\formtex{\\textbf{SPP}}{field components point in dir. of propagation}\n\n\\formbox{Dispersion relation}{k_{z,i}^2 = k_0^2\\epsilon_i-\\beta^2}\n\\quad $i=d,m$\n\\formula{Mom. of inc. wave}{\\highlight{\\beta \\coloneqq k_x} = \\frac{\\omega}{c} \\frac{\\epsilon_m\\epsilon_d}{\\epsilon_m+\\epsilon_d} = k_0 \\cdot N}\n\\formtex{~}{where $N$ effective refr. index of SP}  % $N = \\sqrt{\\frac{1}{n_c^2} {+} \\frac{1}{\\epsilon_m}}$\n\n\\begin{minipage}{.3\\columnwidth}\n    \\includegraphics[width=.9\\columnwidth]{Optical_SPR}\n\\end{minipage}\\vspace{\\boxmargin}\n\\begin{minipage}{.7\\columnwidth-\\boxmargin}\n    \\textbf{Launch a SPP}:\n    \\quad $0\\leq k_{\\vert\\vert,\\textrm{inc}} \\leq k_0\\;n\\ped{inc}$\\\\\n    must ensure \\highlight{$\\beta \\overset{!}{=} k_{\\vert\\vert,\\textrm{inc}} = k_0\\;n\\ped{inc}\\;\\sin\\theta$}\n    \\quad $\\theta\\in[0,\\frac{\\pi}{2}]$\n\n    $\\implies$ \\fbox{$n\\ped{inc} \\geq n\\sqrt{\\frac{\\epsilon_m}{\\epsilon_m+n_c^2}}$} \\fbox{$\\frac{\\Delta\\theta}{\\Delta N} \\hat= \\pderiv{\\theta}{N} = \\frac{1}{n\\ped{inc}\\cos\\theta} \\simeq \\frac{1}{n\\ped{inc}}$}\n\\end{minipage}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{OWLS \\textnormal{-- Optical Waveguide Lightmode Spectroscopy}}\n%\n\\begin{minipage}{.5\\columnwidth}\n    \\includegraphics[width=.9\\columnwidth]{Optical_OWLS}\n\\end{minipage}%\n\\begin{minipage}{.5\\columnwidth}\n    $N \\coloneqq n_F\\sin\\theta = n\\ped{air}\\sin\\alpha + \\frac{l\\lambda}{\\Lambda}$\n    \\vspace{2mm}\\par\n    Penetr. depth \\quad \\fbox{$\\sigma \\sim \\frac{\\lambda}{2\\pi} \\frac{1}{\\sqrt{N^2-n_c^2}}$}\n\\end{minipage}\n\nWaves have to be in phase (constr. interf.) $\\to$ extremely sensitive\n\n\\formula{constr. interference}{\\textcolor{gray}{0=}\\;2\\pi m \\overset{!}{=} \\phi_F + \\phi_{FS} + \\phi_{FAC}}\n\\quad $\\phi$: phase shifts\n\n\\formula{Ansatz for \\textit{3 layer model}}{\\scriptsize\n    \\begin{cases}\n        \\text{Cover:}\t\t& C \\;\\eu^{-\\abs{k_{z,C}} \\;(z-d_F/2)}\\\\\n        \\text{Waveguide:}\t& B \\;\\eu^{\\iu k_{z,F} z} + A \\;\\eu^{\\iu k_{z,F} z}\\\\\n        \\text{Support:}\t& D \\;\\eu^{\\abs{k_{z,S}} \\;(z+d_F/2)}\n    \\end{cases}\n}\n\n\\formula{Idealized adlayer}{n_A = n_C + c_A\\deriv{n}{c}}\n\\formbox{Mass calculation}{M = \\diff_A \\frac{n_A-n_C}{\\diff n/\\diff c}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Limitations}\n%\n%\tAbove methods are \\textit{not usable for diagnostic purposes}.\\\\\n%\tFor analyzing \\textit{simple things} it is extremely accurate, but when the composition of the probe gets more complex (e.g. blood) your device is not usable.\\\\\n%\tHowever, because of the NSB problems, we cannot use it (see LOD).\nAbove methods not usable for \\textit{diagnostic purpose} $\\to$ NSB, LOD\n\n\\textbf{Solution}: diffractometric biosensors (Focal Molography)\n", "meta": {"hexsha": "fea77ef1e4b18268224d2904457904d8a6d72b75", "size": 4771, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/BE18/sections/07_optical_biosensors.tex", "max_stars_repo_name": "tstreule/eth-cheat-sheets", "max_stars_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-26T23:11:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T23:11:57.000Z", "max_issues_repo_path": "src/BE18/sections/07_optical_biosensors.tex", "max_issues_repo_name": "tstreule/eth-cheat-sheets", "max_issues_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/BE18/sections/07_optical_biosensors.tex", "max_forks_repo_name": "tstreule/eth-cheat-sheets", "max_forks_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.71, "max_line_length": 208, "alphanum_fraction": 0.61873821, "num_tokens": 1689, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.44652225154846165}}
{"text": "\\XtoCBlock{PID}\r\n\\label{block:PID}\r\n\\begin{figure}[H]\\includegraphics{PID}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Control error input\\tabularnewline\r\n\\hline\r\nInit & Value which is loaded at initialization function call\\tabularnewline\r\n\\hline\r\nEnable & Enable == 0: Deactivation of block; Out set to 0\n\nEnable 0->1: Preload of integral part\n\nEnable == 1: Activation of block\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & \\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nKp & Proportional Factor\\tabularnewline\r\n\\hline\r\nKi & Integral Factor\\tabularnewline\r\n\\hline\r\nKd & Derivative Factor\\tabularnewline\r\n\\hline\r\nfc & Cutoff frequency of realization low pass\\tabularnewline\r\n\\hline\r\nts\\_fact & Multiplication factor of base sampling time (in integer format)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nPID controller:\n\n    G(s) = Kp + Ki/s + Kd*s/(s/(2*pi*fc) + 1)\r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/PID_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!3248}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 3248 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PID\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & PID\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     int8          *Init;\r\n     int8          *Enable;\r\n     int8          Out;\r\n     int8          b0;\r\n     int8          b1;\r\n     int8          b0d;\r\n     int8          b1d;\r\n     int8          a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int8          in_old;\r\n     int16         i_old;\r\n     int8          d_old;\r\n     int8          enable_old;\r\n} PID_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PID_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!3249}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 3249 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PID\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & PID\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     int16         *Init;\r\n     int8          *Enable;\r\n     int16         Out;\r\n     int16         b0;\r\n     int16         b1;\r\n     int16         b0d;\r\n     int16         b1d;\r\n     int16         a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int16         in_old;\r\n     int32         i_old;\r\n     int16         d_old;\r\n     int8          enable_old;\r\n} PID_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PID_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!3250}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 3250 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PID\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & PID\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     int32         *Init;\r\n     int8          *Enable;\r\n     int32         Out;\r\n     int32         b0;\r\n     int32         b1;\r\n     int32         b0d;\r\n     int32         b1d;\r\n     int32         a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int32         in_old;\r\n     int64         i_old;\r\n     int32         d_old;\r\n     int8          enable_old;\r\n} PID_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PID_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!3251}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 3251 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PID\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & PID\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *In;\r\n     float32       *Init;\r\n     int8          *Enable;\r\n     float32       Out;\r\n     float32       b0;\r\n     float32       b1;\r\n     float32       b0d;\r\n     float32       b1d;\r\n     float32       a0d;\r\n     float32       in_old;\r\n     float32       i_old;\r\n     float32       d_old;\r\n     int8          enable_old;\r\n} PID_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PID_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!3252}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 3252 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PID\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & PID\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *In;\r\n     float64       *Init;\r\n     int8          *Enable;\r\n     float64       Out;\r\n     float64       b0;\r\n     float64       b1;\r\n     float64       b0d;\r\n     float64       b1d;\r\n     float64       a0d;\r\n     float64       in_old;\r\n     float64       i_old;\r\n     float64       d_old;\r\n     int8          enable_old;\r\n} PID_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PID_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "12931077489ffafce98691f9b62f394144bf08aa", "size": 10566, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Control/Doc/PID.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Control/Doc/PID.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Control/Doc/PID.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7322834646, "max_line_length": 90, "alphanum_fraction": 0.6890971039, "num_tokens": 3201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.44652224662172435}}
{"text": "%2multibyte Version: 5.50.0.2953 CodePage: 65001\n\n\\documentclass{article}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%TCIDATA{OutputFilter=LATEX.DLL}\n%TCIDATA{Version=5.50.0.2953}\n%TCIDATA{Codepage=65001}\n%TCIDATA{<META NAME=\"SaveForMode\" CONTENT=\"1\">}\n%TCIDATA{BibliographyScheme=Manual}\n%TCIDATA{Created=Wednesday, July 31, 2013 16:50:51}\n%TCIDATA{LastRevised=Wednesday, July 31, 2013 17:20:44}\n%TCIDATA{<META NAME=\"GraphicsSave\" CONTENT=\"32\">}\n%TCIDATA{<META NAME=\"DocumentShell\" CONTENT=\"Scientific Notebook\\Blank Document\">}\n%TCIDATA{CSTFile=Math with theorems suppressed.cst}\n%TCIDATA{PageSetup=72,72,72,72,0}\n%TCIDATA{AllPages=\n%F=36,\\PARA{038<p type=\"texpara\" tag=\"Body Text\" >\\hfill \\thepage}\n%}\n\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{acknowledgement}[theorem]{Acknowledgement}\n\\newtheorem{algorithm}[theorem]{Algorithm}\n\\newtheorem{axiom}[theorem]{Axiom}\n\\newtheorem{case}[theorem]{Case}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{conclusion}[theorem]{Conclusion}\n\\newtheorem{condition}[theorem]{Condition}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{criterion}[theorem]{Criterion}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{exercise}[theorem]{Exercise}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{notation}[theorem]{Notation}\n\\newtheorem{problem}[theorem]{Problem}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{solution}[theorem]{Solution}\n\\newtheorem{summary}[theorem]{Summary}\n\\newenvironment{proof}[1][Proof]{\\noindent\\textbf{#1.} }{\\ \\rule{0.5em}{0.5em}}\n\\input{tcilatex}\n\n\\begin{document}\n\n\n\\section{A more complex example}\n\nPhillips curve\n\n\\[\n\\alpha _{\\pi }\\pi _{t}=c_{\\pi }+\\alpha _{\\pi ,1}\\pi _{t-1}+\\alpha _{\\pi\n,2}\\pi _{t-2}+\\alpha _{y}y_{t-1}+\\varepsilon _{\\pi ,t}\n\\]\n\nIS curve\n\n\\[\n\\beta _{y}y_{t}=c_{y}+\\beta _{y,1}y_{t-1}+\\beta _{y,2}y_{t-2}-\\beta\n_{r}\\left( i_{t-1}-\\pi _{t-1}\\right) +\\varepsilon _{y,t}\n\\]\n\nTaylor rule\n\n\\[\n\\gamma _{i}i_{t}=c_{i}+\\gamma _{i}\\rho _{i}i_{t-1}+\\gamma _{i}\\left( 1-\\rho\n_{i}\\right) \\left( \\gamma _{y}y_{t}+\\gamma _{\\pi }\\pi _{t}\\right)\n+\\varepsilon _{i,t}\n\\]\n\nThe original equation in Tao's pdf file is : $\\gamma _{i}i_{t}=c_{i}+\\gamma\n_{i}\\rho _{i}i_{t-1}-\\gamma _{i}\\left( 1-\\rho _{i}\\right) \\left( \\gamma\n_{y}y_{t}+\\gamma _{\\pi }\\pi _{t}\\right) +\\varepsilon _{i,t}$. I think the\nminus is a typo\n\n\\subsection{Some important points}\n\n\\begin{itemize}\n\\item This example is simple\n\n\\item It is backward looking\n\n\\item Risk does not matter\n\n\\item estimation is faster... at least provided that we do not spend time\ncomputing the steady state below\n\n\\item If the parameters switch, there are potentially multiple steady\nstates, which RISE easily handles both for backward looking models, like\nthis one, and for more general forward-looking models.\n\n\\item one potential issue is how to set bounds on non-structural parameters\n\n\\item This shows how RISE\\ is flexible: One can easily set up an estimation\nof such a model with sign restrictions.\n\n\\item It makes more sense to estimate SVARs in this way, rather than\nthinking that letting the parameters wander where they want will reveal some\nimportant economic insights: NO, NO and NO!!!\n\\end{itemize}\n\n\\section{The steady state}\n\n\\[\ny_{t}=\\frac{c_{y}-\\frac{\\beta _{r}c_{i}}{\\gamma _{i}\\left( 1-\\rho\n_{i}\\right) }-\\frac{\\beta _{r}\\left( \\gamma _{\\pi }-1\\right) c_{\\pi }}{%\n\\alpha _{\\pi }-\\alpha _{\\pi ,1}-\\alpha _{\\pi ,2}}}{\\beta _{y}-\\beta\n_{y,1}-\\beta _{y,2}+\\beta _{r}\\gamma _{y}+\\frac{\\beta _{r}\\left( \\gamma\n_{\\pi }-1\\right) \\alpha _{y}}{\\alpha _{\\pi }-\\alpha _{\\pi ,1}-\\alpha _{\\pi\n,2}}}\n\\]\n\n\\[\n\\pi _{t}=\\frac{c_{\\pi }}{\\alpha _{\\pi }-\\alpha _{\\pi ,1}-\\alpha _{\\pi ,2}}+%\n\\frac{\\alpha _{y}}{\\alpha _{\\pi }-\\alpha _{\\pi ,1}-\\alpha _{\\pi ,2}}y_{t}\n\\]\n\n\\[\ni_{t}=\\frac{c_{i}}{\\gamma _{i}\\left( 1-\\rho _{i}\\right) }+\\gamma\n_{y}y_{t}+\\gamma _{\\pi }\\pi _{t}\n\\]\n\n\\end{document}\n", "meta": {"hexsha": "46804d7155bafb616e0c814521ad42499a8902e1", "size": 4156, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Alpha/examples/MarkovSwitching/LiuWaggonerZha2009/svar_tutorial.tex", "max_stars_repo_name": "richardgu26/RISE_toolbox-1", "max_stars_repo_head_hexsha": "c5037189959443a9f791116f0607bb18990a13b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-05T15:38:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-05T15:38:23.000Z", "max_issues_repo_path": "Alpha/examples/MarkovSwitching/LiuWaggonerZha2009/svar_tutorial.tex", "max_issues_repo_name": "richardgu26/RISE_toolbox-1", "max_issues_repo_head_hexsha": "c5037189959443a9f791116f0607bb18990a13b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Alpha/examples/MarkovSwitching/LiuWaggonerZha2009/svar_tutorial.tex", "max_forks_repo_name": "richardgu26/RISE_toolbox-1", "max_forks_repo_head_hexsha": "c5037189959443a9f791116f0607bb18990a13b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.248, "max_line_length": 252, "alphanum_fraction": 0.6600096246, "num_tokens": 1420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.44652224662172435}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n\\usepackage{siunitx}\n\\usepackage{mathtools}\n\\usepackage{url}\n\\usepackage{makeidx} \\makeindex\n\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\\DeclareMathOperator{\\arctantwo}{arctan2}\n\n\\begin{document}\n\n\\tableofcontents\n\n\\section{Introduction}\n\n\\par With the continuous technological advancements in solar radiation\napplications, there will always be a demand for smaller uncertainty in\ncalculating the solar position. Many methods to calculate the solar\nposition have been published in the solar radiation literature,\nnevertheless, their uncertainties have been greater than\n$\\pm$~\\ang{0.01} in solar zenith and azimuth angle calculations, and\nsome are only valid for a specific number of years \\cite{blanco}. \\par\nFor example, Michalsky's calculations are limited to the period from\n1950 to 2050 with uncertainty of greater than $\\pm$~\\ang{0.01}\n\\cite{michalsky}, and the calculations of Blanco-Muriel et al.'s are\nlimited to the period from 1999 to 2015 with uncertainty greater than\n$\\pm$~\\ang{0.01} \\cite{blanco}.\\\\ %\n\nAn example emphasizing the importance of reducing the uncertainty of\ncalculating the solar position to lower than $\\pm$~\\ang{0.01}, is the\ncalibration of pyranometers that measure the global solar\nirradiance. During the calibration, the responsivity of the\npyranometer is calculated at zenith angles from \\ang{0} to \\ang{90} by\ndividing its output voltage by th e reference global solar irradiance\n($G$), which is a function of the cosine of the zenith angle\n($\\cos(\\Theta)$). Figure 1 shows the magnitude of errors that the\n\\ang{0.01} uncertainty in $\\Theta$ can contribute to the calculation of\n$\\cos(\\Theta)$ , and consequently $G$ that is used to calculate the\nresponsivity.  Figure 1 shows that the uncertainty in $\\cos(\\Theta)$\nexponentially increases as 2 reaches \\ang{90} (e.g. at $\\Theta$ equal to\n\\ang{87}, the uncertainty in $\\cos(\\Theta)$ is $0.7\\%$, which can result in\nan uncertainty of 0.35\\% in calculating $G$; because at such large\nzenith angles the normal incidence irradiance is approximately equal\nto half the value of $G$). From this arises the need to use a solar\nposition algorithm with lower uncertainty for users that are\ninterested in measuring the global solar irradiance with smaller\nuncertainties in the full zenith angle range from \\ang{0} to\n\\ang{90}.\\\\ %\n\n\n\\par In this report we describe a procedure for a Solar Position\nAlgorithm (SPA) to calculate the solar zenith and azimuth angle with\nuncertainties equal to $\\pm$~\\ang{0.0003} in the period from the year\n-2000 to 6000. The procedure is adopted from \\textit{The Astronomical\n  Algorithms} \\cite{meeus}, which is based on the Variations\nSéculaires des Orbites Planétaires Theory (VSOP87) that was developed\nby P. Bretagnon in 1982 then modified in 1987 by Bretagnon and Francou\n\\cite{meeus}. In this report, we summarize the complex algorithm\nelements scattered throughout the book to calculate the solar\nposition, and introduce some modification to the algorithm to\naccommodate solar radiation applications. For example, in \\textit{The\n  Astronomical Algorithms} \\cite{meeus}, the azimuth angle is measured\nwestward from south, but for solar radiation applications, it is\nmeasured eastward from north. Also, the observer’s geographical\nlongitude is considered positive west, or negative east from\nGreenwich, while for solar radiation applications, it is considered\nnegative west, or positive east from Greenwich.\\\\ %\n\n\\par We start this report by:\n\\begin{itemize}\n\\item Describing the time scales because of the importance of using\n  the correct time in the SPA;\n\\item Providing a step by step procedure to calculate the solar\n  position and the solar incidence angle for an arbitrary surface\n  orientation using the methods described in \\textit{An Introduction\n    to Solar Radiation} \\cite{iqbal};\n\\item Evaluating the SPA against the \\textit{Astronomical Almanac}\n  (AA) data for the years 1994, 1995, 1996, and 2004.\n\\end{itemize}\n\n\\par Because of the complexity of the algorithm we included some\nexamples, in the Appendix, to give the users confidence in their step\nby step calculations. We also included in the Appendix an explanation\nof how to calculate the equation of time, sun transit (solar noon),\nsunrise, sunset, and how to change the Julian Day to a Calendar\nDate. We also included a C source code with header file, for all the\ncalculations in this report (except for the Julian Day to Calendar\nDate conversion). The users can incorporate this module into their own\ncode by including the header file, declaring the SPA structure,\nfilling in the required input parameters into the strucWeture, and\nthen call the SPA calculation function. This function will calculate\nall the output values and fill in the SPA structure for the user.\\\\ %\n\n\\par The users should note that this report is used to calculate the\nsolar position for solar radiation applications only, and that it is\npurely mathematical and not meant to teach astronomy or to describe\nthe Earth rotation. For more description about the astronomical\nnomenclature that is used through out the report, the user is\nencouraged to review the definitions in the \\textit{Astronomical\n  Almanacs}, or other astronomical reference.\n\n\\section{Time Scale}\n\n\\par The following are the internationally recognized time scales:\n\n\\begin{itemize}\n\\item The Universal Time ($UT$), or Greenwich civil time, is based on\n  the Earth’s rotation and counted from 0-hour at midnight; the unit\n  is mean solar day \\cite{meeus}. $UT$ is the time used to calculate\n  the solar position in the described algorithm. It is sometimes\n  referred to as UT1.\n\\item The International Atomic Time ($TAI$) is the duration of the\n  System International Second (SI-second) and based on a large number\n  of atomic clocks \\cite{norwich}.\n\\item The Coordinated Universal Time ($UTC$) is the bases of most\n  radio time signals and the legal time systems. It is kept to within\n  0.9 seconds of $UT1$ ($UT$) by introducing one second steps to its\n  value (leap second); to date the steps are always positive.\n\\item The Terrestrial Dynamical or Terrestrial Time ($TDT$ or $TT$) is\n  the time scale of ephemerides for observations from the Earth\n  surface.\n\\end{itemize}\n\n\\par The following equations describe the relationship between the above\ntime scales (in seconds):\n\n\\begin{equation}\n  \\label{eq:tt}\n  TT = TAI + 32.184\n\\end{equation}\n\n\\begin{equation}\n  \\label{eq:ut}\n  UT = TT - \\Delta T\n\\end{equation}\n\n\\par where $\\Delta T$ is the difference between the Earth rotation time and\nthe Terrestrial Time ($TT$). It is derived from observation only and\nreported yearly in the Astronomical Almanac [5].\n\n\\begin{equation}\n  \\label{eq:ut1}\n  UT = UT1 = UTC + \\Delta UT1\n\\end{equation}\n\n\\par where $\\Delta UT1$ is a fraction of a second, positive or negative value,\nthat is added to the $UTC$ to adjust for the Earth irregular\nrotational rate. It is derived from observation, but predicted values\nare transmitted in code in some time signals, e.g. weekly by the\nU.S. Naval Observatory (USNO) [6].\n\n\\section{Procedure}\n\n\\subsection{Calculate the Julian and Julian Ephemeris Day, Century,\n  and Millennium}\n\n\\par The Julian date starts on January 1, in the year - 4712 at 12:00:00\nUT. The Julian Day ($JD$) is calculated using UT and the Julian\nEphemeris Day ($JDE$) is calculated using $TT$. In the following\nsteps, note that there is a 10-day gap between the Julian and\nGregorian calendar where the Julian calendar ends on October 4, 1582\n($JD = 2299160$), and after 10-days the Gregorian calendar starts on\nOctober 15, 1582.\n\n\\subsubsection{Calculate the Julian Day ($JD$)}\n\n\\begin{equation}\n  \\label{eq:jd}\n  JD = \\floor{365.25 \\times (Y + 4716)} + \\floor{30.6001 \\times (M + 1)} + D + B - 1524.5\n\\end{equation}\n\n\\par where\n\\begin{itemize}\n\\item $\\floor{x}$ is the integer of the calculated term (e.g. 8.7~=~8,\n  8.2~=~8, and -8.7~` ­ 8, etc.);\n\\item $Y$ is the year (e.g. 2001, 2002, 2018, etc.);\n\\item $M$ is the month of the year (e.g. 1 for January, etc.). Note\n  that if $M = 1$ or $M = 2$, then $Y = Y - 1$ and $M = M + 12$. If\n  $M > 2$, then $Y$ and $M$ are not changed;\n\\item $D$ is the day of the month with decimal time (e.g. for the\n  second day of the month at 12:30:30 UT, $D = 2.521180556$);\n\\item $B$ is equal to\n  \\begin{itemize}\n  \\item $0$, for the Julian calendar (i.e. by using $B = 0$ in equation\n    \\ref{eq:jd}, $JD < 2299160$);\n  \\item $(2 - A + \\floor{A/4})$) for the Gregorian calendar (i.e. by\n    using $B = 0$ in equation \\ref{eq:jd}, $JD > 2299160$), where $A\n    = \\floor{Y/100}$.\n  \\end{itemize}\n\\end{itemize}\n\n\\par For users who wish to use their local time instead of UT, change the\ntime zone to a fraction of a day (by dividing it by 24), then subtract\nthe result from $JD$. Note that the fraction is subtracted from $JD$\ncalculated before the test for $B < 2299160$ to maintain the Julian\nand Gregorian periods.\n\n\\par Table \\ref{tbl:jd} shows examples to test any implemented program\nused to calculate the $JD$.\n\n\\subsubsection{Calculate the Julian Ephemeris Day ($JDE$)}\n\n\\begin{equation}\n  \\label{eq:jde}\n  JDE = JD + \\frac{\\Delta T}{86400}\n\\end{equation}\n\n\\subsubsection{Calculate the Julian century ($JC$) and the Julian\n  Ephemeris Century ($JCE$) for the 2000 standard epoch}\n\n\\begin{equation}\n  \\label{eq:jc}\n  JC = \\frac{JD - 2451545}{36525}\n\\end{equation}\n\n\\begin{equation}\n  \\label{eq:jce}\n  JCE = \\frac{JDE - 2451545}{36525}\n\\end{equation}\n\n\\subsubsection{Calculate the Julian Ephemeris Millennium ($JME$) for\n  the 2000 standard epoch}\n\n\\begin{equation}\n  \\label{eq:jme}\n  JME = \\frac{JCE}{10}\n\\end{equation}\n\n\\subsection{Calculate the Earth heliocentric longitude, latitude, and\n  radius vector ($L$, $B$, and $R$)}\n\\label{sec:earth_heliocentric}\n\n\\par “Heliocentric” means that the Earth position is calculated with\nrespect to the center of the sun.\n\n\\begin{enumerate}\n\n\\item \\label{item:step_1} For each row of table\n  \\ref{tbl:earth_periodic_terms}, calculate the term $L0_i$ (in\n  radians):\n\n  \\begin{equation}\n    \\label{eq:l0i}\n    L0_i = A_i \\times \\cos\\left(B_i + C_i \\times JME\\right)\n  \\end{equation}\n  where\n  \\begin{itemize}\n  \\item $i$ is the $i$th row for the term $L0$ in table\n    \\ref{tbl:earth_periodic_terms};\n  \\item $A_i$, $B_i$ and $C_i$ are the values in the $i$th row and\n    $A$, $B$ and $C$ columns in the table\n    \\ref{tbl:earth_periodic_terms}, for the term $L0$ (in radians).\n  \\end{itemize}\n\n\\item Calculate the term $L0$ (in radians):\n\n  \\begin{equation}\n    \\label{eq:l0}\n    L0 = \\sum_{i=0}^{n}L0_i\n  \\end{equation}\n  \\par where $n$ is the number of rows for the term $L0$ in table\n  \\ref{tbl:earth_periodic_terms}.\n\n\\item \\label{item:step_3} Calculate the terms $L1$, $L2$, $L3$, $L4$,\n  and $L5$ by using equations \\ref{eq:l0i} and \\ref{eq:l0} and\n  changing the 0 to 1, 2, 3, 4, and 5, and by using their\n  corresponding values in 4 columns $A$, $B$, and $C$ in table\n  \\ref{tbl:earth_periodic_terms} (in radians);\n\n\\item \\label{item:step_4} Calculate the Earth heliocentric longitude,\n  $L_r$ (in radians),\n\n  \\begin{equation}\n    \\label{eq:l}\n    L_r = \\frac{L0 + L1 \\times JME + L2 \\times JME^2 + L3 \\times JME^3 + L4 \\times JME^4 + L5 \\times JME^5}{10^8}\n  \\end{equation}\n\n\\item \\label{item:step_5} Calculate $L$ in degrees\n\n  \\begin{equation}\n    \\label{eq:l_in_degrees}\n    L = \\frac{L_r \\times 180}{\\pi}\n  \\end{equation}\n\n  \\par where $\\pi$ is approximately equal to 3.1415926535898;\n\n\\item \\label{tiem:step_6} Limit $L$ to the range from \\ang{0} to\n  \\ang{360}. That can be accomplished by dividing $L$ by 360 and\n  recording the decimal fraction of the division as $F$. If $L$ is\n  positive, then the limited $L = 360 * F$ .If $L$ is negative, then\n  the limited $L = 360 - 360 * F$;\n\n\\item \\label{item:step_7} Calculate the Earth heliocentric latitude,\n  $B$ (in degrees), by using table \\ref{tbl:earth_periodic_terms} and\n  steps \\ref{item:step_1} through \\ref{item:step_5} and by replacing\n  all the $L$s by $B$s in all equations. Note that there are no $B2$\n  through $B5$, consequently, replace them by zero in steps\n  \\ref{item:step_3} and \\ref{item:step_4};\n\n\\item Calculate the Earth radius vector, $R$ (in Astronomical Units,\n  AU), by repeating step \\ref{item:step_7} and by replacing all $L$s\n  by $R$s in all equations. Note that there is no $R5$, consequently,\n  replace it by zero in steps \\ref{item:step_3} and \\ref{item:step_4}.\n\n\\end{enumerate}\n\n\\subsection{Calculate the geocentric longitude and latitude ($\\Theta$ and\n  $\\beta$)}\n\n\\par “Geocentric” means that the sun position is calculated with respect\nto the Earth center.\n\n\\begin{enumerate}\n\\item Calculate the geocentric longitude, $\\Theta$ (in degrees)\n\n  \\begin{equation}\n    \\label{eq:theta}\n    \\Theta = L + 180\n  \\end{equation}\n\n\\item Limit $\\Theta$ to the range from \\ang{0} to \\ang{360} as described in\n  step \\ref{item:step_6} in section \\ref{sec:earth_heliocentric};\n\n\\item Calculate the geocentric latitude, $\\beta$ (in degrees)\n\n  \\begin{equation}\n    \\label{eq:geo_lat}\n    \\beta = -B\n  \\end{equation}\n\\end{enumerate}\n\n\\subsection{Calculate the nutation in longitude and obliquity\n  ($\\Delta\\Psi$ and $\\Delta\\varepsilon$)}\n\n\\begin{enumerate}\n\\item Calculate the mean elongation of the moon from the sun, $X0$ (in\n  degrees)\n  \\begin{equation}\n    \\label{eq:x0}\n    X0 = 297.85036 + 445267.111480 \\times JCE - 0.0019142 \\times JCE^2 + \\frac{JCE^3}{189474}\n  \\end{equation}\n\n\\item Calculate the mean anomaly of the sun (Earth), $X1$ (in degrees)\n  \\begin{equation}\n    \\label{eq:x1}\n    X1 = 357.52772 + 35999.050340 \\times JCE - 0.0001603 \\times JCE^2 - \\frac{JCE^3}{300000}\n  \\end{equation}\n\n\\item Calculate the mean anomaly of the moon, $X2$ (in degrees),\n  \\begin{equation}\n    \\label{eq:x2}\n    X2 = 134.96298 + 477198.867398 \\times JCE + 0.0086972 \\times JCE^2 + \\frac{JCE^3}{56250}\n  \\end{equation}\n\n\\item Calculate the moon’s argument of latitude, $X3$ (in degrees),\n  \\begin{equation}\n    \\label{eq:x3}\n    X3 = 93.27191 + 483202.017538 \\times JCE - 0.0036825 \\times JCE^2 + \\frac{JCE^3}{327270}\n  \\end{equation}\n\n\\item Calculate the longitude of the ascending node of the moon’s mean\n  orbit on the ecliptic, measured from the mean equinox of the date,\n  $X4$ (in degrees),\n  \\begin{equation}\n    \\label{eq:x4}\n    X4 = 125.04452 - 1934.136261 \\times JCE + 0.0020708 \\times JCE^2 + \\frac{JCE^3}{450000}\n  \\end{equation}\n\n\\item For each row of table \\ref{tbl:nutation_periodic_terms},\n  calculate the terms $\\Delta\\Psi$ and $\\Delta\\varepsilon$ (in 0.0001of arc seconds)\n\n  \\begin{equation}\n    \\label{eq:delta_psi_i}\n    \\Delta\\Psi_i = (a_i + b_i \\times JCE) \\times \\sin\\left(\\sum_{j=0}^4 X_j \\times Y_{i,j}\\right)\n  \\end{equation}\n\n  \\begin{equation}\n    \\label{eq:delta_epsilon_i}\n    \\Delta\\varepsilon_i = (c_i + d_i \\times JCE) \\times \\cos\\left(\\sum_{j=o}^4 X_j \\times Y_{i,j}\\right)\n  \\end{equation}\n\n  \\par where\n  \\begin{itemize}\n  \\item $a_i$, $b_i$, $c_i$ and $d_i$ are the values listed in the\n    $i$th row and columns $a$, $b$, $c$ and $d$ in table\n    \\ref{tbl:nutation_periodic_terms};\n  \\item $X_i$ is the $j$th $X$ calculated by using equation\n    \\ref{eq:x0} through \\ref{eq:x4};\n  \\item $Y_{i,j}$ is the value listed in the $i$th row and $j$th $Y$\n    column in table \\ref{tbl:nutation_periodic_terms}.\n  \\end{itemize}\n\n\\item Calculate the nutation longitude $\\Delta\\Psi$ (in degrees)\n  \\begin{equation}\n    \\label{eq:delta_psi}\n    \\Delta\\Psi = \\frac{\\sum_{i=0}^n\\Delta\\Psi_i}{36000000}\n  \\end{equation}\n\n  \\par where $n$ in the number of rows in table\n  \\ref{tbl:nutation_periodic_terms} ($n = 63$ rows in the table)\n\n\\item Calculate the nutation in obliquity $\\Delta\\varepsilon$ (in degrees)\n  \\begin{equation}\n    \\label{eq:delta_epsilon}\n    \\Delta\\varepsilon = \\frac{\\sum_{i=0}^n\\Delta\\varepsilon_i}{36000000}\n  \\end{equation}\n\\end{enumerate}\n\n\\subsection{Calculate the true obliquity of the ecliptic $\\varepsilon$ (in\n  degrees)}\n\n\\begin{enumerate}\n\\item Calculate the mean obliquity of the ecliptic $\\varepsilon_0$ (in arc\n  seconds)\n  \\begin{equation}\n    \\label{eq:epsilon_0}\n    \\begin{split}\n      \\varepsilon_0 = & 84381.448 - 4680.93U - 1.55U^2 + 1999.25U^3 - \\\\\n      & 51.38U^4 - 249.67U^5 - 39.05U^6 + 7.12U^7 + \\\\\n      & 27.87U^8 + 5.79U^9 + 2.45U^{10}\n    \\end{split}\n  \\end{equation}\n\n  \\par where $U = \\frac{JME}{10}$;\n\n\\item Calculate the true obliquity of the ecliptic, $\\varepsilon$ (in degrees),\n\n  \\begin{equation}\n    \\label{eq:epsilon_0}\n    \\varepsilon = \\frac{\\varepsilon_0}{3600} + \\Delta\\varepsilon\n  \\end{equation}\n\\end{enumerate}\n\n\\subsection{Calculate the aberration correction, $\\Delta\\tau$ (in degrees)}\n\n\\begin{equation}\n  \\label{eq:delta_t}\n  \\Delta\\tau = -\\frac{20.4898}{3600 \\times R}\n\\end{equation}\n\n\\subsection{Calculate the apparent sun longitude, $\\lambda$ (in degrees)}\n\n\\begin{equation}\n  \\label{eq:lambda}\n  \\lambda = \\Theta + \\Delta\\Psi + \\Delta\\tau\n\\end{equation}\n\n\\subsection{Calculate the apparent sidereal time at Greenwich at any\n  given time, $\\nu$ (in degrees)}\n\n\\begin{enumerate}\n\\item Calculate the mean sidereal time at Greenwich, $\\nu_o$ (in\n  degrees)\n\n  \\begin{equation}\n    \\label{eq:nu_0}\n    \\nu_0 = 80.46061837 + 360.98564736629 \\times (JD - 2451545) + 0.000387933 \\times JC^2 - \\frac{JC^3}{38710000}\n  \\end{equation}\n\n\\item Limit $\\nu_0$ to the range from \\ang{0} to \\ang{360} as described\n  in step \\ref{item:step_6} in section \\ref{sec:earth_heliocentric};\n\n\\item Calculate the apparent sidereal time at Greenwich, $\\nu$ (in\n  degrees,\n\n  \\begin{equation}\n    \\label{eq:nu}\n    \\nu = \\nu_0 + \\Delta\\Psi \\times \\cos(\\varepsilon)\n  \\end{equation}\n\\end{enumerate}\n\n\\subsection{Calculate the geocentric sun right ascension, $\\alpha$ (in\n  degrees}\n\n\\begin{enumerate}\n\\item Calculate the sun right ascension, $\\alpha$ (in radians),\n  \\begin{equation}\n    \\label{eq:alpha}\n    \\alpha = \\arctan2\\left(\\frac{\\sin(\\lambda) \\times \\cos(\\varepsilon) - \\tan(\\beta) \\times \\sin(\\varepsilon)}{\\cos(\\lambda)}\\right)\n  \\end{equation}\n\n  \\par where $\\arctan2$ is an arctangent function that is applied to the\n  numerator and the denominator (instead of the actual division) to\n  maintain the correct quadrant of the $\\alpha$ where $\\alpha$ is in the range\n  from $-\\pi$ to $\\pi$.\n\\end{enumerate}\n\n\\begin{equation}\n  \\label{eq:delta}\n  \\delta = \\arcsin\\left(\\sin(\\beta) \\times \\cos(\\varepsilon) + \\cos(\\beta) \\times \\sin(\\varepsilon) \\times \\sin(\\lambda)\\right)\n\\end{equation}\n\n\\begin{equation}\n  \\label{eq:delta_alpha}\n  \\Delta\\alpha = \\arctan2\\left(\\frac{-x \\times \\sin(\\xi) \\times \\sin(H)}{\\cos(\\delta) - x \\times \\sin(\\xi) \\times \\cos(H)}\\right)\n\\end{equation}\n\n\\begin{equation}\n  \\label{eq:delta_e}\n  \\Delta e = \\frac{P}{1010}\\times\\frac{283}{273 + T} \\times \\frac{1.02}{60 \\times \\tan\\left(e_0 + \\frac{10.3}{e_0 + 5.11}\\right)}\n\\end{equation}\n\n\\appendix\n\n\\printindex\n\n\\bibliographystyle{ieeetr}\n\\bibliography{spa}\n\n\\end{document}\n", "meta": {"hexsha": "bd3eb5a8439b5e0417f6b446e444c4a9909e39b0", "size": 18923, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "spa.tex", "max_stars_repo_name": "mankalas/spa_latex", "max_stars_repo_head_hexsha": "d26a77e2b1a378b2803f48758b416a7771fddaf2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "spa.tex", "max_issues_repo_name": "mankalas/spa_latex", "max_issues_repo_head_hexsha": "d26a77e2b1a378b2803f48758b416a7771fddaf2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spa.tex", "max_forks_repo_name": "mankalas/spa_latex", "max_forks_repo_head_hexsha": "d26a77e2b1a378b2803f48758b416a7771fddaf2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.8151750973, "max_line_length": 133, "alphanum_fraction": 0.7180679596, "num_tokens": 5986, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.446522229023852}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage[utf8]{luainputenc}\n\\usepackage{aeguill}\n\\usepackage{setspace}\n\n\\tikzstyle{edge} = [fill,opacity=.5,fill opacity=.5,line cap=round, line join=round, line width=50pt]\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\pgfdeclarelayer{background}\n\\pgfsetlayers{background,main}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{23 février, 2015}\n\\maketitle\nno class 3/4, 3/6\n\\section*{6.1 planarity}\nif a graph can be drawn on a plane without any crossings, it is called {\\bfseries planar}\n\nnote that if it is planar, you can draw it without crossings with all straight lines.\n\\subsection*{examples}\n$K_3$, $K_4$\n\n\\subsubsection*{drawing:}\ngeogebra.org\n\n\\subsection*{more}\nwe often think of planar graphs as collections of polygons (remember we can draw all planar graphs in straight lines)\n\npicture on board is pentagon glued to one side of a square, and a triangle glued to another\nwhen we have polygons glued together, then we can count things. things like\n\\begin{enumerate}\n\\item\nfaces, eg the polygons\n\nfor faces we have several bounded, and one unbounded\n\n4\n\\item\nedges\n\n10\n\\item\nvertices\n\n8\n\\end{enumerate}\n\nnote that $V-E+F=2$\n\nthis generalizes off the plane, but the idea of ``faces'' kind of breaks down and we have to looks at cycles and such.\n\n\\section*{theorem}\n\nif a graph is planar then $v-e+f=2$\n\n\\subsubsection*{proof}\nby induction on edges. if you add an edge, then you are adding a vertex or a face\n\nif $E=0$ and $G$ is connected then $G\\cong K_1$. $1-0+1=2$ and so check. assume this is true for $e=k$. suppose $G$ is a tree with $e=k+1$. Now remove an edge that is part of a cycle and we have $e=k$ and number of faces is reduced by 1. Now $v-(e-1)+(f-1)=2$ by inductive hypothesis. adding the edge back in and we have $v-e+f=2$. Removing an edge not in a cycle reduced the number of vertices and $v-e+f=2$ similar to above.\n\n\\section*{theorem}\nif $G$ is planar and $|G|\\ge  4$ then $E\\le 3V-6$. Proof crux: every face has at least 3 edges on it's boundary\n\ncontrapositive:\nif $E>3V-6$ and $|G|\\ge 4$ then $G$ is not planar.\n\n\\section*{homework}\n6.1 numbers 1,2,5\n\\end{document}\n \n", "meta": {"hexsha": "17857a920c69581818f5c05aa1597ba309c93cde", "size": 2322, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-02-23.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-02-23.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-02-23.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9759036145, "max_line_length": 426, "alphanum_fraction": 0.7390180879, "num_tokens": 739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980404, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.44625688597823276}}
{"text": "% Created 2021-09-07 Tue 19:04\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=169]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\usepgfplotslibrary{groupplots}\n\\newcommand*{\\shift}{\\operatorname{q}}\n\\pgfplotstableread[col sep=comma]{tank-sim.dta}\\tanktable\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{\\today}\n\\title{Process Automation Laboratory - Modeling second-order systems}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Process Automation Laboratory - Modeling second-order systems},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section{Second-order model critically damped}\n\\label{sec:orgb862bc8}\n\\begin{frame}[label={sec:orgf5d0ff1}]{Fitting a first-order model}\nAssuming a plant model of first-order with time-constant \\(T\\)\n\\[  \\quad \\textcolor{green!50!black}{Y(s)} = \\frac{K}{sT + 1}\\textcolor{blue!80!black}{U(s)} \\quad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} \\quad \\textcolor{green!50!black}{y(t)} = u_f K\\big( 1 - \\mathrm{e}^{-\\frac{t}{T}}\\big)u_H(t)\\]\n\\def\\Tcnst{3}\n\\def\\tdelay{0.0}\n\\def\\ggain{2}\n\\def\\uampl{0.8}\n\\pgfmathsetmacro{\\yfinal}{\\uampl*\\ggain}\n\\pgfmathsetmacro{\\yone}{0.283*\\yfinal}\n\\pgfmathsetmacro{\\ytwo}{0.632*\\yfinal}\n\\pgfmathsetmacro{\\tone}{\\tdelay + \\Tcnst/3}\n\\pgfmathsetmacro{\\two}{\\tdelay + \\Tcnst}\n\n\\begin{center}\n  \\small\n  \\begin{tikzpicture}\n    \\begin{axis}[\n    width=14cm,\n    height=3.5cm,\n    grid = both,\n    xtick = {0,  \\two},\n    xticklabels = {0, $T$},\n    ytick = {0, \\ytwo, \\uampl, \\yfinal},\n    yticklabels = {0,  $0.632y_f$, $u_f$, $y_f$},\n    xmin = -0.2,\n    %minor y tick num=9,\n    %minor x tick num=9,\n    %every major grid/.style={red, opacity=0.5},\n    xlabel = {$t$},\n    ]\n      \\addplot [thick, green!50!black, no marks, domain=0:10, samples=100] {\\uampl*\\ggain*(x>\\tdelay)*(1 - exp(-(x-\\tdelay)/\\Tcnst)} node [coordinate, pos=0.9, pin=-90:{$y(t)$}] {};\n      \\addplot [const plot, thick, blue!80!black, no marks, domain=-1:10, samples=100] coordinates {(-1,0) (0,0) (0,\\uampl) (10,\\uampl)} node [coordinate, pos=0.9, pin=-90:{$u(t)$}] {};\n    \\end{axis}\n  \\end{tikzpicture}\n\\end{center}\n\n\\alert{Time-constant:} Find the time \\(t=T\\) at which the response has reached 63.2\\% of its final value\n\n\\alert{Gain:} \\(y_f = \\lim_{t\\to\\infty}y(t) = Ku_f \\quad \\Rightarrow \\quad K = \\frac{y_f}{u_f}\\)\n\\end{frame}\n\n\\begin{frame}[label={sec:org4f4a767}]{Second-order models}\n\\end{frame}\n\\begin{frame}[label={sec:org023a2dc}]{Two first-order models in series}\n\\begin{center}\n\\begin{tikzpicture}\n  \\node {\\includegraphics[width=0.4\\linewidth]{../../figures/tank-with-hole-no-variables}};\n  \\node at (5.2,-2.06) {\\includegraphics[width=0.4\\linewidth]{../../figures/tank-with-hole-no-variables}};\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[block, right of=input, node distance=20mm] (plant1)  {$G_1(s)$};\n    \\node[block, right of=plant1, node distance=26mm] (plant2)  {$G_2(s)$};\n    \\node[coordinate, right of=plant2, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$u(t)$} (plant1);\n    \\draw[->] (plant1) -- node[coordinate, ] (mp) { } (plant2);\n    \\draw[->] (plant2) -- node[above, near end] {$y(t)$} (output);\n    \\draw[red] (plant1.south west) ++(-4mm,-10mm) rectangle ++(49mm, 20mm);\n\n    \\node[red,below of=mp, node distance=10mm] {$G(s) = G_1(s)G_2(s)$};\n  \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\n\n\\begin{frame}[label={sec:orge105e70}]{Fitting second-order critically-damped model}\n\\alert{Model with two identical time-constants.}\nAssuming model \n\\[ \\textcolor{green!50!black}{Y(s)} = \\frac{K}{(s\\tau + 1)^2}\\textcolor{blue!80!black}{U(s)} \\quad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} \\quad \\textcolor{green!50!black}{y(t)} = u_f K\\Big( 1 - (1+\\frac{t}{\\tau}\\big)\\mathrm{e}^{-\\frac{t}{\\tau}}\\Big)u_H(t)\\]\n\\def\\Tcnst{2}\n\\def\\tdelay{0.0}\n\\def\\ggain{2}\n\\def\\uampl{0.8}\n\\pgfmathsetmacro{\\yfinal}{\\uampl*\\ggain}\n\\pgfmathsetmacro{\\ytwo}{\\yfinal*(1-2*exp(-1))}\n\\pgfmathsetmacro{\\two}{\\tdelay + \\Tcnst}\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\begin{axis}[\n    width=14cm,\n    height=4.5cm,\n    grid = both,\n    xtick = {0, \\two},\n    xticklabels = {0,  $\\tau$},\n    ytick = {0, \\ytwo, \\uampl, \\yfinal},\n    yticklabels = {0, $ $, $u_f$, $y_f$},\n    xmin = -0.2,\n    clip = false,\n    %minor y tick num=9,\n    %minor x tick num=9,\n    %every major grid/.style={red, opacity=0.5},\n    ]\n      \\addplot [thick, green!50!black, no marks, domain=0:11, samples=100] {\\uampl*\\ggain*(x>\\tdelay)*(1 - (1+x/\\Tcnst)*exp(-(x-\\tdelay)/\\Tcnst)} node [coordinate, pos=0.9, pin=-90:{$y(t)$}] {};\n      \\addplot [const plot, thick, blue!80!black, no marks, domain=-1:11, samples=100] coordinates {(-1,0) (0,0) (0,\\uampl) (11,\\uampl)} node [coordinate, pos=0.9, pin=-90:{$u(t)$}] {};\n      \\node at (axis cs: 11, -0.3) {$t$};\n    \\end{axis}\n  \\end{tikzpicture}\n\\end{center}\n\n\\alert{Individual activity} Evaluate the response \\(y(t)\\) at the time instants \\(t=\\tau\\)!\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org65aa28d}]{Fitting second-order critically-damped model}\n\\alert{Model with two identical time-constants.}\nAssuming model \n\\[ \\textcolor{green!50!black}{Y(s)} = \\frac{K}{(s\\tau + 1)^2}\\textcolor{blue!80!black}{U(s)} \\quad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} \\quad \\textcolor{green!50!black}{y(t)} = u_f K\\Big( 1 - (1+\\frac{t}{\\tau}\\big)\\mathrm{e}^{-\\frac{t}{\\tau}}\\Big)u_H(t)\\]\n\\def\\Tcnst{2}\n\\def\\tdelay{0.0}\n\\def\\ggain{2}\n\\def\\uampl{0.8}\n\\pgfmathsetmacro{\\yfinal}{\\uampl*\\ggain}\n\\pgfmathsetmacro{\\ytwo}{\\yfinal*(1-2*exp(-1))}\n\\pgfmathsetmacro{\\ytwofactor}{(1-2*exp(-1))}\n\\pgfmathsetmacro{\\two}{\\tdelay + \\Tcnst}\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\begin{axis}[\n    width=14cm,\n    height=4.5cm,\n    grid = both,\n    xtick = {0, \\two},\n    xticklabels = {0,  $\\tau$},\n    ytick = {0, \\ytwo, \\uampl, \\yfinal},\n    yticklabels = {0, $\\ytwofactor y_f$, $u_f$, $y_f$},\n    xmin = -0.2,\n    clip = false,\n    %minor y tick num=9,\n    %minor x tick num=9,\n    %every major grid/.style={red, opacity=0.5},\n    ]\n      \\addplot [thick, green!50!black, no marks, domain=0:11, samples=100] {\\uampl*\\ggain*(x>\\tdelay)*(1 - (1+x/\\Tcnst)*exp(-(x-\\tdelay)/\\Tcnst)} node [coordinate, pos=0.9, pin=-90:{$y(t)$}] {};\n      \\addplot [const plot, thick, blue!80!black, no marks, domain=-1:11, samples=100] coordinates {(-1,0) (0,0) (0,\\uampl) (11,\\uampl)} node [coordinate, pos=0.9, pin=-90:{$u(t)$}] {};\n      \\node at (axis cs: 11, -0.3) {$t$};\n    \\end{axis}\n  \\end{tikzpicture}\n\\end{center}\n\n\\[ y_f = \\lim_{t\\to\\infty} y(t) = u_f K \\quad \\Rightarrow \\quad K = \\frac{y_f}{u_f}. \\]\n\\end{frame}\n\n\\begin{frame}[label={sec:org2f585e4}]{Fitting second-order critically-damped model}\n\\small\n\nAssuming model \n\\[ \\textcolor{green!50!black}{Y(s)} = \\frac{K}{(s\\tau + 1)^2}\\textcolor{blue!80!black}{U(s)} \\quad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} \\quad \\textcolor{green!50!black}{y(t)} = u_f K\\Big( 1 - (1+\\frac{t}{\\tau}\\big)\\mathrm{e}^{-\\frac{t}{\\tau}}\\Big)u_H(t)\\]\n\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{groupplot}[\ngroup style={\n     group name=timeplot,\n     group size=1 by 2,\n     xlabels at=edge bottom,\n     horizontal sep=5mm,\n     vertical sep=5mm,\n   }, \n    width=14cm,\n    height=2.8cm,\n    grid = both,\n    minor x tick num=4,\n    every major grid/.style={red, opacity=0.8},\n    xlabel = {t [s]},\n    xmin=0,\n    xmax=600,\n    ]\n    \\nextgroupplot[ytick={0.05, 0.065},] \n      \\addplot [thick, blue!50!black, no marks, ]  table[x = 0, y = 2] from \\tanktable;\n    \\nextgroupplot[ytick={1.28, 2.15}, height=3.6cm, minor y tick num=7,] \n      \\addplot [thick, green!50!black, no marks, ]  table[x = 0, y = 1] from \\tanktable;\n    \\end{groupplot}\n  \\end{tikzpicture}\n\\end{center}\n\n\\alert{Activity} Determine the parameters of the model from the experimental data.\n\\end{frame}\n\n\\section{Second-order model under-damped}\n\\label{sec:orge93ea05}\n\n\\begin{frame}[label={sec:orge2eae9b}]{Second-order under-damped models}\nA system with ODE\n$$ \\ddot{y} + 2\\zeta\\omega_n\\dot{y} + \\omega_n^2 y = \\omega_n^2 u, $$\nbecomes in the Laplace domain\n$$ Y(s) = \\frac{\\omega_n^2}{s^2 + 2\\zeta\\omega_n s + \\omega_n^2} U(s). $$\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\begin{itemize}\n\\item \\alert{\\(\\zeta\\)} is called the \\emph{damping ratio}.\n\\item \\alert{\\(\\omega_n\\)} is called the \\emph{natural frequency} (of the system).\n\\end{itemize}\n\\end{column}\n\n\\begin{column}{0.6\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=4cm]{../../figures/implane-second-order-poles}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org7b1d386}]{Second-order under-damped models}\n$$ Y(s) = \\frac{\\omega_n^2}{s^2 + 2\\zeta\\omega_n s + \\omega_n^2} U(s), \\qquad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} $$\n$$     y(t) = 1 - \\frac{\\mathrm{e}^{-\\zeta\\omega_nt}}{\\sqrt{1-\\zeta^2}} \\sin\\big( \\sqrt{1-\\zeta^2}\\omega_n t + \\phi \\big) $$\n\n\n\\begin{columns}\n\\begin{column}{0.3\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=4cm]{../../figures/implane-second-order-poles}\n\\end{center}\n\\end{column}\n\n\\begin{column}{0.7\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=8cm]{../../figures/step-response-specifications}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org6ca1ae1}]{Second-order under-damped models}\n\\begin{columns}\n\\begin{column}{0.3\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=4cm]{../../figures/implane-second-order-poles}\n\\end{center}\n\n\\[    t_r \\approx \\frac{\\pi}{2\\omega_n}, \\qquad   t_s \\approx \\frac{4}{\\zeta\\omega_n}, \\]\n\\end{column}\n\\begin{column}{0.7\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=8cm]{../../figures/step-response-specifications}\n\\end{center}\n\n\\[    t_p \\approx \\frac{\\pi}{\\sqrt{1 - \\zeta^2}\\omega_n}, \\qquad    \\zeta \\approx \\sqrt{\\frac{(\\ln \\frac{PO}{100})^2}{\\pi^2 + (\\ln \\frac{PO}{100})^2}} \\]\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:orgb1998e9}]{Second-order under-damped models}\n\\alert{Activity in pairs} Determine the poles of the system!\n\\begin{columns}\n\\begin{column}{0.3\\columnwidth}\n\\begin{center}\n    \\includegraphics[width=4cm]{../../figures/implane-second-order-poles}\n\\end{center}\n\n\\[    t_s \\approx \\frac{4}{\\zeta\\omega_n}, \\]\n\\end{column}\n\\begin{column}{0.7\\columnwidth}\n\\begin{center}\n\\begin{tikzpicture}\n   \\node[anchor=south west] {    \\includegraphics[width=8cm]{../../figures/step-response-specifications}};\n   \\draw[red] (2.2,4.2) -- ++(-1.2,0) node[left] {$1.3 y_f$};\n   \\draw[red, dotted] (3.7,0.8) -- ++(0,-0.3) node[below] {$2$};\n\n\\end{tikzpicture}\n\\end{center}\n\n\\[   \\zeta \\approx \\sqrt{\\frac{(\\ln \\frac{PO}{100})^2}{\\pi^2 + (\\ln \\frac{PO}{100})^2}} \\]\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "291f52194dcd323ee429998e3042532a8590fbd0", "size": 11201, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "second-order-models/slides/lecture-second-order-oncampus.tex", "max_stars_repo_name": "kjartan-at-tec/mr2015", "max_stars_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "second-order-models/slides/lecture-second-order-oncampus.tex", "max_issues_repo_name": "kjartan-at-tec/mr2015", "max_issues_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "second-order-models/slides/lecture-second-order-oncampus.tex", "max_forks_repo_name": "kjartan-at-tec/mr2015", "max_forks_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.0160771704, "max_line_length": 266, "alphanum_fraction": 0.6488706366, "num_tokens": 4279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.44625687631459776}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage[latin1]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{bbm}\n\\author{Daniel Frederico Lins Leite}\n\\begin{document}\n\t\\section{Exercise 2.1}\n\tSuppose each of K classes has an associated target $t_k$, which is a vector of all zeros, except a one in the k-th position. Show that classifying to the largest element of \\^{y} amounts to choosing the closest target, $argmin_k ||t_k - \\hat{y}||$, if the elements of \\^{y} sum to one.\n\t\n\t\\subsection{Interpretation}\n\tThis problem can be interpreted as a \"target coding scheme\". This specific target coding is can be found in the following papers:\n\t\n\t\\url{http://ieeexplore.ieee.org/document/88570/}\\\\\n\t\\url{https://www.researchgate.net/publication/3191927_Optimized_feature_extraction_and_the_Bayes_decision_in_feed-forwardclassifier_networks}\n\t\\begin{quote}\n\t\tThis may be viewed as a gain matrix in which the gain of\n\t\tassigning to class j a pattern which belongs to class i is zero\n\t\t($i \\ne j$) , but is unity for correct classification.\n\t\\end{quote}\n\t\n\t\\url{http://personal.ie.cuhk.edu.hk/~ccloy/files/aaai_2015_target_coding.pdf}\n\t\\begin{quote}\n\t\tThe 1-of-K coding, containing vectors of length K, with the k-th element as one and the remaining zeros, is typically used along with a softmax function for classification. Each element in a 1-of-K code represents a probability of a specific class. \n\t\\end{quote}\n\t\n\tThis paper also contains a more general definition of target coding, but it is not necessary for this exercise.\n\t\n\tFollowing, we can say that:\n\t\n\t\\begin{align*}\n\t\tt = \\left[ \\begin{array}{c}\n\t\tt_1 \\\\\n\t\tt_2 \\\\\n\t\t\\vdots \\\\\n\t\tt_K \\end{array} \\right] = \\left[ \\begin{array}{cccc}\n\t\t1 & 0 & \\dots & 0 \\\\\n\t\t0 & 1 & \\dots & 0 \\\\\n\t\t\\vdots & \\vdots & \\ddots & \\vdots \\\\\n\t\t0 & 0 & \\dots & 1 \\end{array} \\right]\n\t\\end{align*}\n\t\n\tIn the problem, $\\hat{y}$ can be considered as the prediction of a vector $x$ such that $y_k$ is the probability of $x$ being of the class $k$. That is why the sum of $y_k$ is equal to $1$.This also demands that $y_k$ are greater than $0$, although this does not make difference for this particular exercise.\n\t\n\tAnd now we arrive to the proof part: the k in which the $\\hat{y}_k$ is the greatest, the class that we would choose in our prediction is the same $k$ of the $t_k$ that is nearer to the $\\hat{y}$. In mathematical symbols:\n\t\n\t\\begin{align*}\n\t\t\\arg\\min_k ||\\hat{y}-t_k||\\\\\n\t\\end{align*}\t\n\t\n\t\\subsection{Solution}\n\t\n\t\\begin{align*}\n\t\tK &> 0\\\\\n\t\t\\\\\n\t\tx &\\in \\Re^N\\\\\n\t\ty &= f(x)\\\\\n\t\t&\t\\sum_{i=1}^{K}{y_i} = 1\\\\\n\t\t&\ty_i \\ge 0, i \\in {1,...,K}\\\\\n\t\t\\\\\n\t\t1 &\\ge k \\ge K\\\\\n\t\tt_k &= (t_{k1},...,t_{ki},...,t_{kK}), t_{ki} = \\begin{cases}\n\t\t\t0 &\\mbox{if } i \\neq k\\\\\n\t\t\t1 &\\mbox{if } i = k\n\t\t\\end{cases}\n\t\t\\\\\n\t\t\\arg\\min_k||t_k - \\hat{y}|| &= \\arg\\min_k||y-t_k||^2\\\\\n\t\t&= \\arg\\min_k\\sum_{i=1}^{K}{(y_i-t_{ki})}^2\\\\\n\t\t&= \\arg\\min_k\\sum_{i=1}^{K}{(y_{i}^2-2y_{i}t_{ki}+t_{ki}^2)}\\\\\n\t\t&= \\arg\\min_k\\big[\\sum_{i=1}^{K}{y_{i}^2}+\\sum_{i=1}^{K}{(-2y_{i}t_{ki}+t_{ki}^2)}\\big]\n\t\\end{align*}\n\tSince $\\sum_{i=1}^{K}{y_{i}^2}$ is a constant and does not depend on k\n\t\\begin{align*}\n\t\t&= \\arg\\min_k \\sum_{i=1}^{K}{(-2y_{i}t_{ki}+t_{ki}^2)}\\\\\n\t\t&= \\arg\\min_k\\big[\\sum_{i=1}^{K}{(-2y_{i}t_{ki})}+\\sum_{i=1}^{K}{t_{ki}^2}\\big]\\\\\n\t\\end{align*}\n\tSince $\\sum_{i=1}^{K}{t_{ki}^2} = 1$\n\t\\begin{align*}\n\t\t&= \\arg\\min_k\\big[\\sum_{i=1}^{K}{(-2y_{i}t_{ki})}+1\\big]\n\t\\end{align*}\n\tSince $\\sum_{i=1}^{K}{y_{i}t_{ki}} = y_k$, because $t_k$ is zero in all but $i=k$ position.\n\t\\begin{align*}\n\t\t&= \\arg\\min_k\\big[-2*\\sum_{i=1}^{K}{y_{i}t_{ki}}+1\\big]\\\\\n\t\t&= \\arg\\min_k\\big[-2y_k+1\\big] &&\\mbox{(argmax plus constant)}\\\\\n\t\t&= \\arg\\min_k\\big[-2y_k\\big] &&\\mbox{(argmax times constant)}\\\\\n\t\t&= \\arg\\min_k\\big[-y_k\\big] &&\\mbox{(argmax inverse argmin)}\\\\\n\t\t&= \\arg\\max_k\\big[y_k\\big] &&\\mbox{(argmax inverse argmin)}\n\t\\end{align*}\n\t\n\tWhich give us that:\n\t\\begin{align*}\n\t\t\\arg\\min_k ||\\hat{y}-t_k|| &= \\arg\\max_k\\big[y_k\\big]\n\t\\end{align*}\n\t\n\tThis problem can be interpreted as the proof of why in book the author says:\n\t\\begin{quote}\n\t\tWith the 0-1 loss function [...] the solution is known as the Bayes classifier, and says that\n\t\twe classify to the most probable class, using the conditional (discrete) distribution $Pr(G|X)$.\n\t\\end{quote}\n\n\t\\section{Exercise 2.2}\n\t\n\tFrom the previous exercise, we know that the Bayes Classifier, will classify the point to the most probable class. So, the boundary is located exactly where there is no clear most probable class. \n\tTo simplify let us imagine that we have just 2 classes.\n\t\n\t\\begin{align*}\n\t\tP(K_1|X) = P(K_2|X)\\\\\n\t\t\\frac{P(K_1,X)}{P(X)} = \\frac{P(K_2,X)}{P(X)}\\\\\n\t\t\\frac{P(X|K_1)P(K_1)}{P(X)} = \\frac{P(X|K_2)P(K_2)}{P(X)}\\\\\n\t\\end{align*}\n\t\n\t$P(X|K_i)$ is the same as the likelihood of seeing X using a generative model from the i-th class. If we suppose that all classes come from a Gaussian Distribution, this simplify to:\n\t\n\t\\begin{align*}\n\t\t\\frac{\\mathcal{L}(\\theta_1|X)P(K_1)}{P(X)} = \\frac{\\mathcal{L}(\\theta_2|X)P(K_2)}{P(X)}\\\\\n\t\\end{align*}\n\t\n\tTo calculate $P(X)$ we can marginalize $X$ over all possibilities, in this case two, so:\n\t\n\t\\begin{align*}\n\t\tP(X) &= \\sum_{k\\in K}{P(X|K=k)}\\\\\n\t\t&= \\sum_{k\\in K}{\\mathcal{L}(\\theta_k|X)}\n\t\\end{align*}\n\t\n\tSo now we have:\n\t\n\t\\begin{align*}\n\t\t\\frac{P(X|K_1)P(K_1)}{\\sum_{k\\in K}{\\mathcal{L}(\\theta_k|X)}} = \\frac{P(X|K_2)P(K_2)}{\\sum_{k\\in K}{\\mathcal{L}(\\theta_k|X)}}\\\\\n\t\\end{align*}\n\t\n\tBut we can simplify it.\n\n\t\\begin{align*}\n\t\tP(X|K_1)P(K_1) = P(X|K_2)P(K_2)\\\\\n\t\\end{align*}\n\t\n\tWe can do the same for $P(K_1)$\n\t\n\t\\begin{align*}\n\t\tP(K_1) &= \\int_{x\\in X}{P(K_1|X)P(dx)}\\\\\n\t\t&= \\int_{x\\in X}{P(K_1|X)P(dx)}\\\\\n\t\t&= \\int_{x\\in X}{\\mathcal{L}(X|\\theta_1)P(dx)}\n\t\\end{align*}\n\t\n\tWhich give us the final formula:\n\t\n\t\\begin{align*}\n\t\t\tP(X|K_1)\\int_{x\\in X}{\\mathcal{L}(X|\\theta_1)P(dx)} = P(X|K_2)\\int_{x\\in X}{\\mathcal{L}(X|\\theta_2)P(dx)}\\\\\n\t\\end{align*}\n\t\n\tThe first possible simplification is to estimate $P(K_i)$ and two possible ways:\n\t- First, we can say that they both have the same probability;\n\t- Second, if we have a dataset we can calculate them by\n\t\\begin{align*}\n\t\tP(K_1) = \\frac{\\sum_{y_i\\in Y}{\\mathbbm{1}(y_i = k_1)}}{N}\\\\\n\t\tP(K_2) = \\frac{\\sum_{y_i\\in Y}{\\mathbbm{1}(y_i = k_2)}}{N}\\\\\n\t\\end{align*}\n\t\n\tEqual Prior Distributions:\n\t\n\tIn this case the equality can be simplified to\n\t\n\t\\begin{align*}\n\tP(X|K_1) = P(X|K_2)\\\\\n\t\\end{align*}\n\t\n\tFor futher simplification we can imagine a two dimensional X:\n\t\n\t\\begin{align*}\n\tP(x_1,x_2|K_1) = P(x_1,x_2|K_2)\\\\\n\t\\end{align*}\n\t\n\tif we choose another simplification, that x1 and x2 and independent, we arrive at a Naive Bayer Classifier, and the equation become:\n\t\n\t\\begin{align*}\n\tP(x_1|K_1)P(x_2|K_1) = P(x_1|K_2)P(x_2|K_2)\n\t\\end{align*}\n\t\n\twith two classes and Gaussian distribution:\n\tDifferent mean, same variance = line/plane\n\tSame mean, different variance = circle/elipse\n\tgeneral case = parabolic curve\n\t\n\twith more than two cases will be a piecewise combination of the above three cases.\n\t\n\t\\begin{align*}\n(\\frac{1}{\\sqrt{2\\pi\\sigma_1^2}}e^{-\\frac{(x_1-\\mu_1)^2}{2\\sigma_1^2}})(\\frac{1}{\\sqrt{2\\pi\\sigma_1^2}}e^{-\\frac{(x_2-\\mu_1)^2}{2\\sigma_1^2}}) &= (\\frac{1}{\\sqrt{2\\pi\\sigma_2^2}}e^{-\\frac{(x_1-\\mu_2)^2}{2\\sigma_2^2}})(\\frac{1}{\\sqrt{2\\pi\\sigma_2^2}}e^{-\\frac{(x_2-\\mu_2)^2}{2\\sigma_2^2}})\\\\\n(\\frac{1}{\\sqrt{2\\pi\\sigma_1^2}})^2(e^{-\\frac{(x_1-\\mu_1)^2}{2\\sigma_1^2}})(e^{-\\frac{(x_2-\\mu_1)^2}{2\\sigma_1^2}}) &= (\\frac{1}{\\sqrt{2\\pi\\sigma_2^2}})^2(e^{-\\frac{(x_1-\\mu_2)^2}{2\\sigma_2^2}})(e^{-\\frac{(x_2-\\mu_2)^2}{2\\sigma_2^2}})\\\\\n\tA &= (\\frac{1}{\\sqrt{2\\pi\\sigma_1^2}})^2\\\\\n\tB &= (\\frac{1}{\\sqrt{2\\pi\\sigma_2^2}})^2\\\\\n\tC &= -\\frac{1}{2\\sigma^2}\\\\\n\tA(e^{\\frac{(x_1-\\mu_1)^2}{C}})(e^{\\frac{(x_2-\\mu_1)^2}{C}}) &= B(e^{\\frac{(x_1-\\mu_2)^2}{C}})(e^{\\frac{(x_2-\\mu_2)^2}{C}})\\\\\n\tA\\frac{(e^{\\frac{(x_1-\\mu_1)^2}{C}})}{(e^{\\frac{(x_1-\\mu_2)^2}{C}})} &= B\\frac{(e^{\\frac{(x_2-\\mu_2)^2}{C}})}{(e^{\\frac{(x_2-\\mu_1)^2}{C}})}\\\\\n\tAe^{\\frac{(x_1-\\mu_1)^2}{C}*\\frac{C}{(x_1-\\mu_2)^2}} &= Be^{\\frac{(x_2-\\mu_2)^2}{C}*\\frac{C}{(x_2-\\mu_1)^2}}\\\\\n\tAe^{\\frac{(x_1-\\mu_1)^2}{(x_1-\\mu_2)^2}} &= Be^{\\frac{(x_2-\\mu_2)^2}{(x_2-\\mu_1)^2}}\\\\\n\tln(Ae^{\\frac{(x_1-\\mu_1)^2}{(x_1-\\mu_2)^2}}) &= ln(Be^{\\frac{(x_2-\\mu_2)^2}{(x_2-\\mu_1)^2}})\\\\\n\tln(A)ln(e^{\\frac{(x_1-\\mu_1)^2}{(x_1-\\mu_2)^2}}) &= ln(B)ln(e^{\\frac{(x_2-\\mu_2)^2}{(x_2-\\mu_1)^2}})\\\\\n\tA'=ln(A)\\\\\n\tB'=ln(B)\\\\\n\tA'\\frac{(x_1-\\mu_1)^2}{(x_1-\\mu_2)^2} &= B'\\frac{(x_2-\\mu_2)^2}{(x_2-\\mu_1)^2}\\\\\n\tA'(\\frac{x_1-\\mu_1}{x_1-\\mu_2})^2 &= B'(\\frac{x_2-\\mu_2}{x_2-\\mu_1})^2\\\\\n\t(\\frac{x_1-\\mu_1}{x_1-\\mu_2})^2 &= \\frac{B'}{A'}(\\frac{x_2-\\mu_2}{x_2-\\mu_1})^2\\\\\n\t\\frac{x_1-\\mu_1}{x_1-\\mu_2} &= \\sqrt{\\frac{B'}{A'}(\\frac{x_2-\\mu_2}{x_2-\\mu_1})^2}\\\\\n\t\\frac{x_1-\\mu_1}{x_1-\\mu_2} &= (\\frac{x_2-\\mu_2}{x_2-\\mu_1})\\sqrt{\\frac{B'}{A'}}\\\\\n\tC' = \\sqrt{\\frac{B'}{A'}}\\\\\n\t\\frac{x_1-\\mu_1}{x_1-\\mu_2} &= C'(\\frac{x_2-\\mu_2}{x_2-\\mu_1})\\\\\n\t\\end{align*}\n\t\n\tWe can simplify the left side of the equation, because:\n\t\n\t\\begin{align*}\n\t\t\\frac{x-\\mu_1}{x-\\mu_2} &= \\frac{x-\\mu_2+\\mu_2+\\mu_1}{x-\\mu_2}\\\\\n\t\t&= \\frac{x-\\mu_2}{x-\\mu_2}+\\frac{\\mu_2+\\mu_1}{x-\\mu_2}\\\\\n\t\t&= 1 + \\frac{\\mu_2+\\mu_1}{x-\\mu_2}\n\t\\end{align*}\n\t\n\tand\n\t\n\t\\begin{align*}\n\t\\frac{x_2-\\mu_2}{x_2-\\mu_1} &= \\frac{x_2-\\mu_1+\\mu_1-\\mu_2}{x_2-\\mu_1}\\\\\n\t&= \\frac{x_2-\\mu_1}{x_2-\\mu_1}+\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}\\\\\n\t&= 1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}\n\t\\end{align*}\n\tcd\n\t\\begin{align*}\n\t\\frac{x_1-\\mu_1}{x_1-\\mu_2} &= C'(\\frac{x_2-\\mu_2}{x_2-\\mu_1})\\\\\n\t1 + \\frac{\\mu_2+\\mu_1}{x_1-\\mu_2} &= C'(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1})\\\\\n\t\\frac{\\mu_2+\\mu_1}{x_1-\\mu_2} &= C'(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1\\\\\n\t\\frac{1}{x_1-\\mu_2} &=\\frac{C'(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1}{\\mu_2+\\mu_1}\\\\\n\tx_1-\\mu_2 &=\\frac{\\mu_2+\\mu_1}{C'(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1}\\\\\n\tx_1 &=\\frac{\\mu_2+\\mu_1}{C'(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1} + \\mu_2\\\\\n\tx_1 &=\\frac{\\mu_2+\\mu_1}{\\sqrt{\\frac{ln(B)}{ln(A)}}(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1} + \\mu_2\\\\\n\tx_1 &=\\frac{\\mu_2+\\mu_1}{\\sqrt{\\frac{ln( (\\frac{1}{\\sqrt{2\\pi\\sigma_2^2}})^2)}{ln((\\frac{1}{\\sqrt{2\\pi\\sigma_1^2}})^2)}}(1 +\\frac{\\mu_1-\\mu_2}{x_2-\\mu_1}) - 1} + \\mu_2\\\\\n\t\\end{align*}\n\t\n\\end{document}", "meta": {"hexsha": "1e5ab88874fd74ae6638572f945f20e8ab60edd4", "size": 10153, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "texts/math/Statistics/TheElementsofStatisticalLearning.exercises.tex", "max_stars_repo_name": "xunilrj/sandbox", "max_stars_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2017-04-01T17:18:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T05:23:23.000Z", "max_issues_repo_path": "texts/math/Statistics/TheElementsofStatisticalLearning.exercises.tex", "max_issues_repo_name": "xunilrj/sandbox", "max_issues_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-05-24T13:36:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T06:44:20.000Z", "max_forks_repo_path": "texts/math/Statistics/TheElementsofStatisticalLearning.exercises.tex", "max_forks_repo_name": "xunilrj/sandbox", "max_forks_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-20T01:07:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-22T14:55:38.000Z", "avg_line_length": 42.4811715481, "max_line_length": 309, "alphanum_fraction": 0.6169605043, "num_tokens": 4607, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.44625687504310196}}
{"text": "\\acrshort{rankfromsets} is a classifier whose output is used to rank items for a\nuser $u$ based on each item's set of attributes $x_m \\in I$ and learned user\nembeddings $\\theta_u$. Every item $x_m \\in I$ is represented by a subset of\nattributes $v \\in V$ from a vocabulary of attributes $V$. Item $m$ is\nrepresented by the set of attributes $x_m \\subseteq V$.\n\nThe \\acrshort{rankfromsets} model is a classifier parameterized by a neural\nnetwork $f$ that predicts whether user $u$ consumed item $m$, demarcated by the\nbinary indicator $\\yum = 1$. The model is trained to discriminate items a user\nconsumed, $(x_m, \\yum=1)$, from items a user is unlikely to consume,\n$(x_k, \\yuk=0)$. In implicit feedback data, only the former datapoints\n$(x_m, \\yum = 1)$ are observed. (We describe how to define negative samples\n$(x_k, \\yuk=0)$ later.)\n\nThe classifier outputs the probability of a user $u$ consuming an item $m$:\n\\begin{align}\np(\\yum = 1 \\mid x_m) = \\sigma\\left(f\\left(\\theta_u, \\sum_{v\\in x_m}\n  \\beta_v,~~h(x_m)\\right)\\right).\n\\label{eq:rankfromsets}\n\\end{align}\nThe learned user embedding $\\theta_u$, item attribute embeddings $\\beta_v$, and\nitem intercept function $h(x_m)$ are used to make the prediction of item\nconsumption. The item intercept function maps items to\nintercepts based on the item attributes (we describe how to construct this\nfunction later). The sigmoid function is denoted $\\sigma$ and squashes the\noutput of the neural network to be between $0$ and $1$, yielding the probability\nthat user $u$ consumes item $m$.\n\nFitting the model amounts to learning the user embeddings, the item attribute\nembeddings, parameters of the item intercept function, and any parameters of the\nneural network $f$ such as weights and biases. We define the loss function in\n\\Cref{sec:fitting}.\n\nDoes \\acrshort{rankfromsets} satisfy the modeling criteria laid out in\n\\Cref{sec:desiderata}? The model is order-invariant: the summation of the item\nattribute embeddings $\\beta_v$ and the construction of the item intercept\nfunction (detailed below) guarantees that the model output is invariant to the\norder of set elements. Second, the model provably improves recall, as described\nin \\Cref{sec:theory}. Third, the choice of neural network $f$ to parameterize\nthe model enables universal approximation of other order-invariant models.\nFinally, the model satisfies parameter-sharing, as the item attribute embeddings\n$\\beta_v$ and the intercept function $h$ are shared across items and allow the\nmodel to scale.\n\n\\paragraph{Theoretical results.} \\acrshort{rankfromsets} is supported by\npropositions in \\Cref{sec:theory}. We derive a result related to the\nrecommendation performance of the model. A common evaluation metric for\nrecommendation models is recall. Recall can be viewed as a binary task, and we\nprove that this immediately leads to the conclusion that a classifier such as\n\\acrshort{rankfromsets} can maximize this metric. The second result concerns\nuniversal approximation. The structure of the neural network used to\nparameterize \\acrshort{rankfromsets} enables it to approximate other models such\nas matrix factorization or permutation-marginalized recurrent neural networks.\n\n\\subsection{Cold start and collaborative filtering}\n\nThe cold start problem arises when new items or new users appear.\nRecommendations of such items or for such users are only possible if there\nexists metadata about items (such as sets of attributes) or metadata about users\n(such as age). As \\acrshort{rankfromsets} recommends items based on their\nattributes, we focus on the cold start setting of new items, where there is item\nmetadata available.\n\n\\paragraph{\\acrshort{rankfromsets} item attribute embeddings leaven the cold\n  start problem.} If an item has not been consumed by any user, it is considered\na `cold start` item, as the recommendation model does not have any historical\ninformation with which to rank the item. The model must use the item attributes\nto inform the rankings of such cold start items. \\acrshort{rankfromsets}\naddresses the cold-start problem by leveraging item attribute embeddings, which\nallow the ranking of new items through their sets of attributes. Consider the\nrecommendation of cold start items that contain common attributes, such as meals\nwith commmon foods (e.g. bananas, tomatoes, bread), or arXiv papers that use\nstandard terms (e.g. recommendation, deep, learning). Item attribute embeddings\nfor such attributes that are shared across items enable information to be shared\nbetween items with zero consumption data and items that have been consumed and\nhave similar attributes.\n\nAs our focus is on the setting where users have a history of previously-consumed\nitems, we need to ensure that \\acrshort{rankfromsets} supports collaborative\nfiltering. In other words, the model needs to make recommendations for a user by\nfiltering items based on the consumption patterns of other users.\n\n\\paragraph{Collaborative filtering via item intercepts.}\n\\acrshort{rankfromsets} shares information across users through the item\nintercept function $h$. The item intercept function enables the ranking of items\nfor a user based on similar users' patterns of consumption. The item intercept\nfunction is shared across users, allowing one user's consumption choices to\ninform another's ranking. This is in contrast to the item attribute embeddings,\nwhich depend on the attributes of every item (these content-based attributes\ncannot capture patterns in usage independent of content). The parameterization\nof the item intercept function $h$ depends on the size of the data. If the data\nis small enough, $h$ can function as a lookup for unique intercepts for every\nitem. However, if the number of items is so large that unique item intercepts\nlead to overfitting, we can define $h$ using additional information about every\nitem. For example, if the data consists of foods in meals, we can define a meal\nintercept as the sum of food intercepts, yielding a scalable item intercept\nfunction. These two choices of parameterization satisfy the desideratum of\norder-invariance. The input to the item intercept function is a set of\nattributes, so the above constructions (using item-level parameters or sums)\nensure every item intercept is independent of the order of the item's set of\nattributes.\n\n\\subsection{Neural network architectures}\n\\label{sec:parameterizations}\nThere are several choices for parameterizing the neural network $f$ in the\n\\acrshort{rankfromsets} recommendation model. The following choices of neural\nnetwork architectures enable universal approximation of other order-invariant\nmodels; we outline the technical requirements for this in \\Cref{sec:theory}. In\nthese parameterizations, the neural network $f$ outputs logits that predict item\nconsumption; these are used to train the classifier. For recommendation, items\nare ranked using the logits.\n\nIn the inner product parameterization, the classifier makes predictions using\nthe dot product of the user embedding $\\theta_u$ and the sum of the item\nattribute embedding sand item intercept function.  This architecture is equivalent to\na neural network with user-dependent weights $\\theta_u$. The neural network\noutputs logits that predict whether user $u$ consumed item $m$:\n\\begin{align}\n  f\\left(\\theta_u, x_m\\right) = \\theta_u^\\top\\left(\\sum_{v\\in x_{m}}\n  \\beta_v + h(x_m)\\right)\n  \\label{eq:inner-product}\n\\end{align}\n\nAs an alternative parameterization, $f$ can be a deep neural network:\n\\begin{align}\n  f(\\theta_u, x_m) = \\phi\\left(\\theta_u, \\sum_{v\\in x_m}\n  \\beta_v, h(x_m)\\right),\n  \\label{eq:neural-network}\n\\end{align}\nwhere the deep network $\\phi$ has weights and biases and takes as inputs the\nuser embedding, sum of item attribute embeddings, and item intercept. This\narchitecture contrasts the inner product parameterization: ex ante, it is\nunclear whether a finite-depth, finite-size neural network can learn the inner\nproduct function.\n\nA third parameterization is a combination of the above, using an idea borrowed\nfrom residual networks~\\citep{DBLP:journals/corr/HeZRS15}. A neural network can\nbe used to learn the residual in the inner product model:\n\\begin{align}\n  f\\left(\\theta_u, x_m\\right) = \\theta_u^\\top\\left(\\sum_{v\\in x_m}\n  \\beta_v + h(x_m)\\right) + \\phi(\\theta_u, x_m).\n  \\label{eq:residual}\n\\end{align}\n\nWe discuss the generalization and universal approximation capabilities of these\nparameterizations in the following section.\n\n\\subsection{Fitting the model}\n\\label{sec:fitting}\n\\acrshort{rankfromsets} is fit to data using a classification objective function\nand a stochastic optimization algorithm.\n\nThe model can be represented using a Bernoulli distribution, with generative\nprocess $\\yum~\\sim~\\textrm{Bernoulli}\\left(\\yum; \\sigma(f(u, x_m))\\right)$. The\nprobability of a user consuming an item is given by \\Cref{eq:rankfromsets}.\n\nAs \\acrshort{rankfromsets} is a classifier, it requires both positively- and\nnegatively-labeled training data. But in implicit feedback data, there are no\nnegative labels. Users explicitly consume items $(x_m, \\yum = 1)$, but do not\nindicate dislike of items $(x_m, \\yuk = 0)$. For training the\n\\acrshort{rankfromsets} classifier, we assign negative labels to items a user is\nunlikely to consume. These items are called negative samples. Negative samples\nare drawn uniformly at random from the collection of items $I$. (We justify this\nchoice of negative sampling distribution in the next section.)\n\nDenote the parameters of the model by $\\theta$, and let $K$ be the number of\nnegative samples. The model parameters are the user embeddings, item attribute\nembeddings, parameters of the item intercept function, and any weights and\nbiases of the neural network in \\Cref{eq:rankfromsets}. The maximum likelihood\nobjective function for a single datapoint $(x_m, \\yum=1)$ is\n\\begin{align}\n\\begin{split}\n  \\cL(\\theta, & (x_m, \\yum), \\{(x_k, \\yuk)\\}) =\\\\\n  &\\log p(\\yum = 1 \\mid x_m; \\theta) + \\sum_{k=1}^K \\log p(\\yuk = 0 \\mid x_k;\n  \\theta),\\\\\n  &\\textrm{with}~x_k\\sim\\textrm{Uniform}(I).\n  \\label{eq:objective}\n\\end{split}\n\\end{align}\n\n% \\begin{align}\n%   \\cL_{\\textrm{total}}\\left(\\theta, \\{(x_m,\n%         \\yum)\\}\\right) = & \\sum_u \\sum_{m: \\yum = 1}\\cL(\\theta, (x_m, \\yum))\n% \\end{align}\n%\\input{algo_rankfromsets}\n\n\\paragraph{Optimization.} We use stochastic gradient ascent~\\citep{Robbins:1951}\nto maximize the objective. This algorithm subsamples datapoints\n$(x_m, \\yum = 1)$, and optimizes the objective with respect to the model\nparameters by taking stochastic gradient steps in the parameter space. We use\nminibatches of datapoints to improve convergence.\n\n\\section{theory}\n\\label{sec:theory}\n\nHaving exhibited several parameterizations of the \\acrshort{rankfromsets}\nrecommendation model, we prove that these parameterizations satisfy the\ndesideratum of improved recall in \\Cref{sec:desiderata}. By noting that recall\nis a binary task, it follows that a classifier such as \\acrshort{rankfromsets}\ncan maximize this metric (\\Cref{prop:1}). We also prove that\n\\acrshort{rankfromsets} can approximate any order-invariant recommendation model\nsuch as matrix factorization (\\Cref{prop:2}).\n\nRecall measures how accurately a recommendation model ranks items consumed by a\nuser. It is computed as follows. First, for a specific user $u$, use the model\nto rank all items $x_m \\in I$. Denote the top $M$ items returned by the model as\n${x_1, x_2, \\ldots, x_M}$. Recall is defined as the fraction of items the user\n$u$ consumed in these top-ranked items:\n\\begin{align}\n  \\textrm{Recall@}M &= \\frac{\\lvert \\{x_m : \\yum = 1 \\} \\rvert }{M}\n\\label{eq:recall}\n\\end{align}\n\n\\subsection{Classifiers maximize recall}\n\\label{sec:optimal}\n\nThe central insight here is that recall can be viewed as classification: a\nrecommendation model does or does not recall an item consumed by a user. This\nconnection between the performance of a recommender and its parameterization as\na classifier forms the scaffolding for \\acrshort{rankfromsets}.\n\nDatapoints in a classifier are of the form $(x, y) \\sim F$ where $F$ is the\nempirical data-generating distribution. The generalization error of a binary\nclassifier $p(y \\mid x)$ is the misclassification rate,\n\\begin{equation}\nE = \\sum_{x \\in F} \\left[ \\hat y(x) \\neq y \\right] \\, .\n\\end{equation}\n\\begin{proposition}\n  A binary classifier is trained with positive examples from a user's history\n  and negative samples drawn uniformly from the collection of items $I$. If such\n  a classifier achieves zero generalization error, then it achieves maximum\n  recall.\n  \\label{prop:1}\n\\end{proposition}\n\\begin{proof}\n  A model with zero generalization error is a perfect classifier; it assigns\n  greater probability to positively-labeled datapoints than to\n  negatively-labeled datapoints. In other words, it ranks positive examples\n  above negative examples. Recall is measured by the fraction of\n  positively-labeled items in a ranking returned by the model. In a classifier\n  that achieves zero generalization error, positively-labeled datapoints muts be\n  ranked higher than other datapoints, maximizing recall.\n  %Recall is maximized up to negative samples being\n%  identical to positive examples (such examples will have the same rank).\n\\end{proof}\n\n\\Cref{prop:1} connects recommender systems to classification. This connection may\nseem vacuous or tautological. But the message is subtle---in terms of recall, a\ngood classifier makes for a good recommender.\n\nThis theory also justifies the choice of negative samples for implicit feedback\ndata in the objective, \\Cref{eq:objective}. For good recall performance, it is\nsufficient to assign negative labels uniformly over the items $I$. Note that the\ndistribution of negative samples can be other than uniform, as long as every\nitem in the collection is assigned positive weight. In the infinite data limit,\nany such distribution of negative samples will result in a classifier with\nmaximum recall.\n\n\\subsection{\\acrshort{rankfromsets} can approximate any order-invariant model}\n\nHaving shown that a classifier such as \\acrshort{rankfromsets} can yield good\nperformance as a recommendation model in terms of recall, we turn to the model's\nflexibility. The desideratum of order-invariance for models that rank from sets\nin \\Cref{sec:desiderata} leads to a specific class of models. We show that\n\\acrshort{rankfromsets} can approximate any model in this class.\n\nThe criterion of order-invariance in \\Cref{sec:desiderata} requires that a\nrecommendation model that takes as input a set of attributes be invariant to the\norder the set elements are fed to the model. We formally define this class of\nrecommendation models as order-invariant models, and show that\n\\acrshort{rankfromsets} can approximate any model in this class.\n\n\\paragraph{Order-invariant models.} A set is unordered, and therefore invariant\nto permutation. Recommendation models that rank items from their sets of\nattributes must be invariant to the order that set elements are fed to the\nmodel. For a model $f$ that is used to rank item $m$ for user $u$, order\ninvariance with respect to the attributes $v_i \\in x_m$ is written\n\\begin{align}\n  f(u, {v_1, v_2, v_L}) &= f(u, {v_{\\pi(1)}, v_{\\pi(2)}, \\ldots\n                                     v_{\\pi(L)}})~\\forall~\\pi,\n\\label{eq:order-invariance}\n\\end{align}\nwhere $\\pi$ is a permutation of the indices of individual attributes.\n\nWe can verify that a recommendation model is in the class of order-invariant\nmodels by checking that it satisfies \\Cref{eq:order-invariance}. Examples of\norder-invariant models are matrix factorization, recommendation models based on\nword embeddings, and permutation-marginalized recurrent neural networks.\nWe show that a Bayesian matrix factorization model \\citep{Gopalana} is\norder-invariant in \\Cref{sec:order-invariance}. These models are evaluated in\n\\Cref{sec:rfs-experiments}.\n\nThe class of order-invariant models is large. The next proposition allows us to\nfocus on comparing architectures for a single model rather than comparing\nmodels. This simplifies design of recommendation models evaluated using recall.\n\\acrshort{rankfromsets} is parameterized by neural networks, and \\Cref{prop:2}\nsays that the model can approximate any other model in the class of\norder-invariant models. This result is derived from the framing of the\nparameterizations of \\acrshort{rankfromsets} in \\Cref{sec:parameterizations} as\nneural networks with learned item-dependent covariates and user-dependent\nweights, and use of the fact that neural networks are universal approximators.\n\n\\begin{proposition}\n  Assume the vocabulary of attributes (set elements) is countable,\n  $\\lvert V \\rvert < \\lvert \\bbN_0 \\rvert$. \\acrshort{rankfromsets}, with\n  parameters on the order of the size of the vocabulary can approximate any\n  order-invariant recommendation model.\n  \\label{prop:2}\n\\end{proposition}\nThe proof follows directly from Theorem~2 in\n\\citet{DBLP:journals/corr/ZaheerKRPSS17} and we will not restate it here. (The\nonly change to the proof is the mapping from set elements to one-hot vectors,\n$c \\colon V \\to \\left\\{0, 1\\right\\}^{\\lvert V \\rvert}$ to yield a unique\nrepresentation of every member of the powerset.)\n\n\\Cref{prop:2} supports using \\acrshort{rankfromsets} in practice: not only does\nthe model improve recall (\\Cref{prop:1}), but it can also approximate other\nmodels, including matrix factorization. Matrix factorization and other\norder-invariant models may not have theoretical guarantees of improved\nevaluation metrics or universal approximation. Focusing on building efficient\narchitectures to parameterize \\acrshort{rankfromsets} rather than designing\nextensions of models may simplify the design of recommenders.\n\n\\subsection{Comparing parameterizations of \\acrshort{rankfromsets} using\n  generalization}\n\\label{sec:generalization}\n\nIs there an optimal architecture for \\acrshort{rankfromsets} between the inner\nproduct, \\Cref{eq:inner-product}, or residual parameterization in\n\\Cref{eq:residual}? It depends. In the regime of infinite data and infinite\nparameters, the inner product and residual architectures are equivalent:\n\\Cref{prop:2} states that given infinite data, both are universal approximators.\nIn theory, they can approximate any order-invariant model such as matrix\nfactorization. But in the finite data, finite parameter regime, there are\ntradeoffs that may favor one architecture over another. Depending on assumptions\nabout the data-generating distribution and parameter-sharing choices, one\narchitecture may be more efficient than another.\n\nWith finite data and finite paramaters, the optimal parameterization of\n\\acrshort{rankfromsets} is dependent on the data-generating distribution. Recall\nthat observations of user-item interactions are generated by\n$ \\yum~\\sim~\\textrm{Bernoulli}\\left(\\yum; \\sigma(f(u, x_m)\\right)$, where $f$ is\na function that outputs logits. We describe how different assumptions about the\nlogit function $f$ lead to the residual architecture or inner product\narchitecture yielding the best predictive performance. Note that the number of\nparameters across architectures must be equal for a fair comparison.\n\nTo illustrate a scenario where the inner product architecture outperforms the\nresidual architecture, suppose the logit function of the data-generating\ndistribution has the following form. With two-dimensional embeddings (and a\nsingle attribute per item) say the logit function is given by\n$f(u, x_m) = \\theta_1\\beta_1 + \\theta_2\\beta_2^{10}$. The second dimension of\nthe item attribute embedding $\\beta$ has been raised to the power of $10$.\nConsider fitting the inner product model with a dimensionality of $2$ to data\nfrom this generative process. The optimal setting of the item attribute\nembeddings is $\\beta^* = (\\beta_1, \\beta_2^{10})$. Now consider fitting the\nresidual model. The requirement that the number of parameters be equal across\narchitectures forces the neural network to have less parameters. This limits the\nability of the residual architecture to learn that the second component of the\nitem attribute embedding should be $\\beta_2^{10}$, as neural networks with small\nhidden layer size may not be able to approximate complex polynomials.\n\nFor an example where the residual model would outperform the inner product\nmodel, consider the following generative process. The logit function is given by\n$f(u, x_m) = \\theta_u^\\top \\sum_{v\\in \\xum}\\beta_v + \\eta(\\theta_u, \\sum_{v\\in\n  \\xum} \\beta_v)$. Here $\\eta$ is some nonlinear function. This generative\nprocess mirrors \\Cref{eq:residual} and is best approximated by the residual\nmodel. We verified both of these claims with simulation studies.\n\n% How can we ensure our choice of model does not lead to overfitting and enables\n% prediction of held-out data? In recommendation data, one way to define\n% generalization is to consider the matrix of observations of shape users by items\n% $(U, I)$. As $U\\rightarrow \\infty$ and $I\\rightarrow \\infty$, it is clear that a\n% model can memorize the training data if the number of parameters is\n% $\\mathcal{O}(UI)$. As long as the number of model parameters grows slower than\n% $U$ or $I$, and the model predicts well, generalization is possible.\n\nThe above two examples show that the choice of architecture in\n\\acrshort{rankfromsets} is data-dependent. To ensure that the model does not\noverfit as new users or items are included in the training data, we need to\ncompare the number of parameters to the number of datapoints. A model with\nparameters the size of the training data can overfit by memorizing the training\ndata. For generalization to be possible, overfitting can be avoided if the\nnumber of parameters grows slower than the size of the data. The technical\nbacking for this comes from asymptotic statistics and the concept of sieved\nlikelihoods~\\citet{vaart_1998}. Specifically, the maximum likelihood estimation procedure with the\nobjective function in \\Cref{eq:objective} can be replaced by maximization of a\nsieved likelihood function. The `sieve' refers to filtering information as the\nnumber of parameters (in this case, user and item representations) grows with\nthe number of observations. The sieved likelihood function enables the analysis\nof asymptotic behavior as the number of users grows $U\\rightarrow \\infty$ and\nthe number of items grows $I\\rightarrow \\infty$, An example of a technique to\ngrow the number of parameters in a way that supports generalization is given in\nChapter 25 of \\citet{vaart_1998}.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"set_recommendation\"\n%%% End:", "meta": {"hexsha": "0f13dd1f68f4c6f3ac1a2cccce1e9e440f297f53", "size": 22544, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-rfs/sec_method_old.tex", "max_stars_repo_name": "altosaar/thesis", "max_stars_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-21T18:56:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T12:18:53.000Z", "max_issues_repo_path": "ch-rfs/sec_method_old.tex", "max_issues_repo_name": "altosaar/thesis", "max_issues_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch-rfs/sec_method_old.tex", "max_forks_repo_name": "altosaar/thesis", "max_forks_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.5012531328, "max_line_length": 98, "alphanum_fraction": 0.7875266146, "num_tokens": 5479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.5888891307678321, "lm_q1q2_score": 0.4462568621582556}}
{"text": "\\section{Runtime Example}\r\n\r\n\\toclesssubsection{Minsort}\r\n\r\n%-------------------------------------------------------------------------------\r\n\r\n\\begin{frame}{Runtime analysis - Minsort}\r\n  \\vspace{-1em}\r\n  \\begin{figure}[!h]\r\n    \\includegraphics[width=0.75\\linewidth]{Images/MinSort/Minsort.png}\r\n    \\label{fig:introduction:minsort_runtime}\r\n  \\end{figure}\r\n  \\vspace{-0.5em}\r\n  \\textbf{How long does the program run?}\r\n  \\begin{itemize}\r\n    \\item<2- |handout:1>\r\n      In the last lecture we had a schematic\r\n    \\item<2- |handout:1>\r\n      \\textbf{Observation:} it is going to be \\enquote{disproportionately} slower\r\n      the more numbers are being sorted\r\n    \\item<3- |handout:1>\r\n      How can we say more precisely what is happening?\r\n  \\end{itemize}\r\n\\end{frame}\r\n\r\n%-------------------------------------------------------------------------------\r\n\r\n\\begin{frame}{Runtime analysis - Minsort}\r\n  \\textbf{How can we analyze the runtime?}\r\n  \\begin{itemize}\r\n    \\item<1- |handout:1>\r\n      Ideally we have a formula which provides the runtime of the program for\r\n      a specific input\r\n    \\item<2- |handout:1>\r\n      \\textbf{Problem:}\r\n      the runtime is depends on many variables, especially:\r\n      \\begin{itemize}\r\n        \\item\r\n          What kind of computer the code is executed on\r\n        \\item What is running in the background\r\n        \\item Which compiler is used to compile the code\r\n      \\end{itemize}\r\n    \\item<3- |handout:1>\r\n      \\textbf{Abstraction 1:}\r\n      analyze the number of basic operations, rather than analyzing the runtime\r\n  \\end{itemize}\r\n\\end{frame}\r\n", "meta": {"hexsha": "c73a1aaa6152a2bff93fec7f043abcb572debb45", "size": 1599, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-2/Chapter/eng/010_Introduction.tex", "max_stars_repo_name": "TobiOnline/AlgoDat", "max_stars_repo_head_hexsha": "565a9f03a9ed7ef354cb4f143959df77df89b726", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2016-12-16T17:42:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-26T11:07:16.000Z", "max_issues_repo_path": "Lecture-2/Chapter/eng/010_Introduction.tex", "max_issues_repo_name": "TobiOnline/AlgoDat", "max_issues_repo_head_hexsha": "565a9f03a9ed7ef354cb4f143959df77df89b726", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 23, "max_issues_repo_issues_event_min_datetime": "2016-10-08T09:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-20T15:40:10.000Z", "max_forks_repo_path": "Lecture-2/Chapter/eng/010_Introduction.tex", "max_forks_repo_name": "TobiOnline/AlgoDat", "max_forks_repo_head_hexsha": "565a9f03a9ed7ef354cb4f143959df77df89b726", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2016-10-07T11:55:23.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-05T08:36:38.000Z", "avg_line_length": 33.3125, "max_line_length": 82, "alphanum_fraction": 0.588492808, "num_tokens": 420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.8104788995148791, "lm_q1q2_score": 0.4462556397304343}}
{"text": "\\chapter{Full Experimental Results}\n\n\\section{One Argument Programs}\n\n\\subsection{Factorial}\n\\underline{\\textbf{Input Examples}}\n\\begin{lstlisting}\nexample(call(fac, 0), 1).\nexample(call(fac, 1), 1).\nexample(call(fac, 2), 2).\nexample(call(fac, 3), 6).\n\\end{lstlisting}\n\n\\begin{multicols*}{2}\n\n\\underline{\\textbf{Interpreted approach results}}\n\\begin{lstlisting}\nchoose_match(1,1,0) \nchoose_match(2,2) \nchoose(1,3,1) \nchoose(2,9) \nchoose_where(34) \nchoose_where(45,1) \n\nModels      : 1     \nOptimization: 2 3 \nTime        : 1.640\n  Prepare   : 0.060\n  Prepro.   : 0.020\n  Solving   : 1.560\n\n\n\\end{lstlisting}\n\n\\begin{lstlisting}\nfac x\n  | x == 0 = 1\n  | otherwise = x * x0\n  where x0 = f x1\n  \twhere x1 = x - 1\n\\end{lstlisting}\n\\vspace*{\\fill}\n\\columnbreak\n\\underline{\\textbf{Constraint approach results}}\n\n\\begin{lstlisting}\nchoose_match(1,1,0)\nchoose_match(2,2) \nchoose(1,1,1) \nchoose(2,37,1) \n\n\n\nModels      : 1     \nOptimization: 1 \nTime        : 1.240\n  Prepare   : 0.200\n  Prepro.   : 0.140\n  Solving   : 0.900\n\\end{lstlisting}\n\n\\begin{lstlisting}\nfac x\n  | x == 0 = 1\n  | otherwise = (fac (x - 1)) * x\n\\end{lstlisting}\n\\end{multicols*}\n\n\\subsection{Fibonacci}\n\\underline{\\textbf{Input Examples}}\n\\begin{lstlisting}\nexample(call(f, 1), 1).\nexample(call(f, 2), 1).\nexample(call(f, 3), 2).\nexample(call(f, 4), 3).\nexample(call(f, 5), 5).\nexample(call(f, 6), 8).\n\\end{lstlisting}\n\n\\begin{multicols*}{2}\n\\underline{\\textbf{Interpreted approach results}}\n\\begin{lstlisting}\nchoose_match(1,1,1) \nchoose_match(2,1,2) \nchoose_match(3,2) \nchoose(1,1) \nchoose(2,13,1) \nchoose(3,84) \nchoose_where(30,1) \nchoose_where(49) \nchoose_where(83) \nchoose_where(75,2) \n\nModels      : 1     \nOptimization: 4 1 \nTime        : 807.240\n  Prepare   : 0.060\n  Prepro.   : 0.020\n  Solving   : 807.160\n\nfib x\n  | x == 1 = x\n  | x == 2 = x - 1\n  | otherwise = x0 + x2\n  where x0 = fib x1\n  \twhere x1 = x - 1\n  \t\twhere x2 = fib x3\n  \t\t\twhere x3 = x - 2\n\\end{lstlisting}\n\\vspace*{\\fill}\n\\columnbreak\n\\underline{\\textbf{Constraint approach results}}\n\\begin{lstlisting}\nUNSATISFIABLE\n\nModels      : 0     \nTime        : 0.020\n  Prepare   : 0.020\n  Prepro.   : 0.000\n  Solving   : 0.000\n\\end{lstlisting}\n\\end{multicols*}\n\n\\pagebreak\n\\subsection{Powers of 2}\n\\underline{\\textbf{Input Examples}}\n\\begin{lstlisting}\nexample(call(f, 0), 1).\nexample(call(f, 1), 2).\nexample(call(f, 2), 4).\nexample(call(f, 3), 8).\n\\end{lstlisting}\n\n\\begin{multicols*}{2}\n\\underline{\\textbf{Interpreted approach results}}\n\\begin{lstlisting}\nchoose_match(1,1,0) \nchoose_match(2,2) \nchoose(1,3,1) \nchoose(2,84) \nchoose_where(30,1) \nchoose_where(49) \nchoose_where(64) \n\nModels      : 1     \nOptimization: 3 3 \nTime        : 35.840\n  Prepare   : 0.040\n  Prepro.   : 0.040\n  Solving   : 35.760\n\npower2 x\n  | x == 0 = x + 1\n  | otherwise = x1 + x2\n  \twhere x1 = f x0\n  \t\twhere x2 = f x0\n  \t\t\twhere x0 = x - 1\n\\end{lstlisting}\n\\vspace*{\\fill}\n\\columnbreak\n\\underline{\\textbf{Constraint approach results}}\n\\begin{lstlisting}\nchoose_match(1,1,0) \nchoose_match(2,2)\nchoose(1,1,1)\nchoose(2,38,1,2) \n \n \n \n \nModels      : 1  \nOptimization: 1 \nTime        : 5.580\n  Prepare   : 0.380\n  Prepro.   : 0.340\n  Solving   : 4.860\n\npower2 x\n  | x == 1 = 1\n  | otherwise = (f (x - 1)) * 2 \n\\end{lstlisting}\n\\end{multicols*}\n\\pagebreak\n\\section{Two Argument Programs}\n\n\\subsection{Tail Recursive Factorial}\n\\underline{\\textbf{Input Examples}}\n\\begin{lstlisting}\nexample(call(f, (0, 1)), 1).\nexample(call(f, (1, 1)), 1).\nexample(call(f, (2, 1)), 2).\nexample(call(f, (3, 1)), 6).\nexample(call(f, (2, 3)), 6).\n\\end{lstlisting}\n\n\\begin{multicols*}{2}\n\\underline{\\textbf{Interpreted approach results}}\n\\begin{lstlisting}\nchoose_match(1,1,0)\nchoose_match(2,7)\nchoose(1,2) \nchoose(2,27) \nchoose_where(51,1)\nchoose_where(69) \n\nModels      : 1     \nOptimization: 2 2 \nTime        : 419.860\n  Prepare   : 2.060\n  Prepro.   : 0.840\n  Solving   : 416.960\n\\end{lstlisting}\n\n\\begin{lstlisting}\nfac x y\n  | x == 0 = y\n  | otherwise = fac x0 x1\n  where x0 = x - 1\n  \twhere x1 = x * y\n\\end{lstlisting}\n\\vspace*{\\fill}\n\\columnbreak\n\\underline{\\textbf{Constraint approach results}}\n\\begin{lstlisting}\nchoose_match(1,2,0)\nchoose_match(2,1) \nchoose(1,3) \nchoose(2,184,1) \n\n \n \nModels      : 1     \nOptimization: 3 \nTime        : 173.900\n  Prepare   : 5.540\n  Prepro.   : 1.440\n  Solving   : 166.920\n\n\\end{lstlisting}\n\\begin{lstlisting}\nfac x y\n  | x == 0 = y\n  | otherwise = fac (x - 1) (x * y)\n\\end{lstlisting}\n\\end{multicols*}\n\\pagebreak\n\\subsection{Greatest Common Divisor}\n\\underline{\\textbf{Input Examples}}\n\\begin{lstlisting}\nexample(call(gcd, (1, 1)), 1).\nexample(call(gcd, (2, 1)), 1).\nexample(call(gcd, (4, 3)), 1).\nexample(call(gcd, (3, 6)), 3).\nexample(call(gcd, (9, 6)), 3).\nexample(call(gcd, (4, 7)), 1).\nexample(call(gcd, (9, 3)), 3).\n\\end{lstlisting}\n\\begin{multicols*}{2}\n\\underline{\\textbf{Interpreted approach results}}\n\\begin{lstlisting}\nchoose_match(1,2,0) \nchoose_match(2,6) \nchoose_match(3,7)   \nchoose(1,1) \nchoose(2,30) \nchoose(3,81) \nchoose_where(53) \nchoose_where(77) \n\nModels      : 1     \nOptimization: 1 2 \nTime        : 1546.820\n  Prepare   : 1.940\n  Prepro.   : 0.980\n  Solving   : 1543.900\n  \ngcd x y\n  | y == 0 = x\n  | x > y = gcd y x0\n  | otherwise = gcd x1 x\n  where x0 = x - y\n  \twhere x1 = y - x\n\\end{lstlisting}\n\\vspace*{\\fill}\n\\columnbreak\n\\underline{\\textbf{Constraint approach results}}\n\\begin{lstlisting}\nchoose_match(1,3)\nchoose_match(2,4)\nchoose_match(3,6)  \nchoose(1,2) \nchoose(2,150, 0) \nchoose(3,159, 1, 1) \n\n\n\nModels      : 1     \nOptimization: 2 \nTime        : 1599.420\n  Prepare   : 11.720\n  Prepro.   : 2.100\n  Solving   : 1585.600\n\ngcd x y\n\t| x == y = x\n\t| x > y\t = gcd (x - y) y\n\t| x < y\t = gcd y x\n\\end{lstlisting}\n\\end{multicols*}\n\\pagebreak\n\n\\pagebreak\n%\\renewcommand\\bibname{{References}}\n%\\bibliography{References}\n%\\bibliographystyle{plain}", "meta": {"hexsha": "50a8247c824fc161926713b7fc0020ded641a680", "size": 5804, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/CA1/chapterA1.tex", "max_stars_repo_name": "roddejams/program-synthesis", "max_stars_repo_head_hexsha": "acca214241e9e7d7ff5c344039778dbd967a8008", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/CA1/chapterA1.tex", "max_issues_repo_name": "roddejams/program-synthesis", "max_issues_repo_head_hexsha": "acca214241e9e7d7ff5c344039778dbd967a8008", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/CA1/chapterA1.tex", "max_forks_repo_name": "roddejams/program-synthesis", "max_forks_repo_head_hexsha": "acca214241e9e7d7ff5c344039778dbd967a8008", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.4253968254, "max_line_length": 49, "alphanum_fraction": 0.6359407305, "num_tokens": 2292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239133, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4462173729790044}}
{"text": "\n\\section{Avalanche involving a dry area}\n\nAn avalanche problem involving a dry area is solved using shallow water approach. This problem is very similar to the dry dam break, but it is on a sloping topography. The debris could be snow, sand, or even rock. The simulation should show a rarefaction and wetting process, just like the dry dam break problem. The analytical solution of this problem was derived by Mungkasi and Roberts~\\cite{MR2011DA}. This shallow water approach to solve debris avalanche problems was also implemented by a number of researchers, such as Mangeney et al.~\\cite{MHR2000} and Naaim et al.~\\cite{NVC1997}. \n\nThe initial condition is\n\\begin{equation} \\label{eq:dap_init}\nu(x,0)=0, ~~v(x,y)=0, ~~\\textrm{and}~~\nh(x,0) = \\left\\{ \\begin{array}{ll}\nh_1 & \\textrm{if $x < 0$}\\\\\n0 & \\textrm{if $x > 0$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhere $h_1>0$. The topography is a flat bed with positive slope.\n\nThe analytical solution~\\cite{MR2011DA} at time $t>0$ is\n\\begin{equation} \nh(x) = \\left\\{ \\begin{array}{ll}\n0 & \\textrm{if $x \\leq -2 c_0 t + \\frac12 mt^2$}\\\\\nh_R=\\frac{1}{9g} \\left( \\frac{x}{t} + 2c_0 - \\frac12 mt \\right)^2 & \\textrm{if $-2 c_0 t + \\frac12 mt^2 \\leq x \\leq c_0 t + \\frac12 mt^2$}\\\\\nh_0 & \\textrm{if $x \\geq c_0 t + \\frac12 mt^2$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhich is the free surface and\n\\begin{equation} \nu(x) = \\left\\{ \\begin{array}{ll}\n0 & \\textrm{if $x \\leq -2 c_0 t + \\frac12 mt^2$}\\\\\nu_R=\\frac23 \\left( \\frac{x}{t} - c_0 + mt \\right) & \\textrm{if $-2 c_0 t + \\frac12 mt^2 \\leq x \\leq c_0 t + \\frac12 mt^2$}\\\\\nmt & \\textrm{if $x \\geq c_0 t + \\frac12 mt^2$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhich is the velocity. Here $m=-g\\tan{\\theta}+F$, where $\\tan{\\theta}$ is the slope of the topography. Variable $F$ is the Coulomb-type friction given by \n\\begin{equation}\nF=g \\cos^2{\\theta} \\tan{\\delta},\n\\end{equation}\nin which $\\tan{\\delta}$ is a given value of friction slope such that $\\tan{\\delta} \\leq \\tan{\\theta}$.\n\n\n\\subsection{Results}\n\nFor our test, we consider $h_0=20$ in (\\ref{eq:dap_init}).\nThe following figures show the stage, $x$-momentum, and $x$-velocity at several instants of time. We should see excellent agreement between the analytical and numerical solutions. The wet/dry interface is difficult to resolve and it usually produces large errors, similar to the dry dam break problem.\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{stage_plot.png}\n\\end{center}\n\\caption{Stage results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xmom_plot.png}\n\\end{center}\n\\caption{Xmomentum results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xvel_plot.png}\n\\end{center}\n\\caption{Xvelocity results}\n\\end{figure}\n\n\n\\endinput\n", "meta": {"hexsha": "a4b0030807744545bfdc15fc5cc98d1dd8ba80b8", "size": 2784, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "validation_tests/analytical_exact/avalanche_dry/results.tex", "max_stars_repo_name": "samcom12/anuga_core", "max_stars_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_stars_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_stars_count": 136, "max_stars_repo_stars_event_min_datetime": "2015-05-07T05:47:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T03:07:40.000Z", "max_issues_repo_path": "validation_tests/analytical_exact/avalanche_dry/results.tex", "max_issues_repo_name": "samcom12/anuga_core", "max_issues_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_issues_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_issues_count": 184, "max_issues_repo_issues_event_min_datetime": "2015-05-03T09:27:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T04:22:48.000Z", "max_forks_repo_path": "validation_tests/analytical_exact/avalanche_dry/results.tex", "max_forks_repo_name": "samcom12/anuga_core", "max_forks_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_forks_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-03-18T07:35:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-01T07:07:29.000Z", "avg_line_length": 40.9411764706, "max_line_length": 590, "alphanum_fraction": 0.7083333333, "num_tokens": 966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4462173688916611}}
{"text": "We implement all the graph mining algorithms using Postgres's embedded PL/pgSQL programming language, which supports many advanced features, like user defined function, aggregate, etc. It also has a sophisticated query execution engine, which we think is the most critical component of Postgres.\n\nThe following are the algorithms we plan to implement. The reason we choose them is that there are a lot of implementation in other platform like MapReduce, we can compare our SQL version with them to draw a clusion about SQL's unique charastic in solving data analytic tasks.\n\n\\begin{description}\n  \\item[Degree Distribution:] Plot the distribution of each node's degree. \n  \\item[PageRank:] Determine the importance of every node of a graph based on its connectivity. \n  \\item[Connected Components:] Partition the nodes of a graph also based on its connectivity.\n  \\item[Radius of Every Node:] Compute the radius of every node in a graph. The radius is defined as the number of hops that a node needs to reach to its furthest neighbor.\n  \\item[Belief Propagation:] Calculate the marginal probability of each node in a graphical model. \n  \\item[Eigenvalue:] Using approximation method to estimate the top-k eigenvalues of a matrix.\n  \\item[Count of triangle] Using approcimate method to calculate the number of triangles in a social network.\n  \\item[Shortest Path] Calculate the shortest path from each node in a graph to a single source node. \n  \\item[Minimum spanning tree] Construct a tree which is a subgraph of original graph with the minimum sum of weight of its edges. \n\\end{description}\n\n\\subsection{Degree Distribution}\nWe employ Postgres's group by command according to either source node or target node to count the degree distribution according to each node. The pseudo code is in Algorithm \\ref{algo1:1}, \\ref{algo1:2}.\n\n\\begin{algorithm}[!htbf]\n\\caption{Out Degree distribution}\n\\begin{algorithmic}\n\\STATE{Group edges according to source node's id}\n\\STATE{Count the number of members of each group}\n\\end{algorithmic}\n\\label{algo1:1}\n\\end{algorithm}\n\n\\begin{algorithm}[!htbf]\n\\caption{In Degree distribution}\n\\begin{algorithmic}\n\\STATE{Group edges according to target node's id}\n\\STATE{Count the number of members of each group}\n\\end{algorithmic}\n\\label{algo1:2}\n\\end{algorithm}\n\n\\subsubsection{Math}\nFirst we need to count degree of each node. Then we count the frequency of each degree count. \n\n\\subsubsection{Idea of SQL implementation}\nThe only operation we need from SQL is its group by clause. We can aggregate the edges according with source node or target node.\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Pagerank}\nThe algorithm of pagerank is Power method. We do matrix multiplication continuously until the change in pagerank is small. The most important equation for calculating pagerank is as follows:\n\\begin{equation}\n  PR(i) = \\alpha \\frac{1}{N} + (1 - \\alpha) \\sum_{j \\in InNeighbor(i)} \\frac{PR(j)}{OutDegree(j)}\n\\end{equation}\n\\begin{algorithm}\n\\caption{Pagerank}\n\\begin{algorithmic}\n\\STATE{Bulk load graph into an edge table in database.}\n\\STATE{Initialization(damper factor=0.85, max iteration = 100, epsilon = 0.0001)}\n\\STATE{Build a weight matrix trans, initialize pagerank p}\n\\REPEAT\n\\STATE{For each node i, update its pagerank with its old value and its income node's pagerank.}\n\\UNTIL{Convergence}\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsubsection{Math}\nAccording to the definition of pagerank, we can gain an intuitive idea of how to calculate the pagerank of a node.\nWe just take weighted sum of its incoming neighbors. We can encode this operation as matrix vector multiplication.\nWe can do this multiple times. And the fix point of the equation is the pagerank of the graph. And by the results \nfrom linear algebra, we know that the stable vector is the eigenvector with biggest eigenvalue. Thus we can get \nthe eigenvector by power method, which just do multiplication until convergence. \n\n\\subsubsection{Idea of SQL implementation}\nThe implementation consists of several components.\nFirst, we have a \\emph{graph} which has the schema \\emph{(from\\_id, to\\_id, weight)}. Then we will build a \\emph{rank} table has the schema \\emph{(node\\_id, rank)}, all the rank are initialized randomly. After we enter loop, we will do a large matrix vector multiplication, which is implemented by SQL \\emph{select} and \\emph{join}. The new pagerank is stored in a temporary table. After the loop is over, we calclate the updates to every node, if the change is little, then abort.\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Weakly connected components}\nIn terms of the implementation of weakly connected components. We borrow the idea of HCC method from the \"PEGASUS\" paper.\\cite{Kang09}\n\n\\subsubsection{method}\nThe key idea of this algorithm is that for every node $v_i$ in the graph, we maintain a component id $c_i^h$ which is the minimum node id within $h$ hops from $v_i$. Initially, $c_i^h$\nof $v_i$ is set to its own node id. For each iteration, each node sends its current component id to its neighbors. Then $c_i^{h+1}$ is set to the minimum value among its current component id and the received component ids from its neighbors. Finally, when the update converges, all nodes in the same connected component will share the same component id. \n\n\\subsubsection{Idea of SQL implementation}\nThe algorithm can be described in algorithm \\ref{algo:wcc}. The key step that updates the \ncomponent id to the minimum of its neighbors' is accomplished in SQL using join and group by\nclause.\n\\begin{algorithm}\n\\caption{Weakly Connected Component}\n\\begin{algorithmic}\n\\STATE{Bulk load graph into an edge table in database.}\n\\STATE{Create a component table, where each entry contains a node id, and the component id.}\n\\STATE{Initialize the component table where component id equals node id.}\n\\REPEAT\n\\STATE{For each node, assign the minimum component id of its neighbors as the new component id of this node.}\n\\UNTIL{Convergence}\n\\end{algorithmic}\n\\label{algo:wcc}\n\\end{algorithm}\nAfter several rounds of iteration, the nodes in the same connected component will share the same component id.\nThe number of iterations for convergence can be proved to be upper bounded by the diameter of the graph.\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Radius of every node}\nWe discard the traditional algorithm because it is extremely infeasible for large graphs, since it uses a set to record every neghbors within n hops for a node during iteration, which requires a O($n^2$) space.\n\\subsubsection{method}\nSince the exact algorithm is hopeless, we use the approximation algorithm described in \"HADI\" paper\\cite{DBLP:journals/tkdd/KangTAFL11} instead. Specifically, we use the Flajolet-Martin algorithm for counting the number of distinct members in a multiset. It is guaranteed to give an unbiased estimate and a tight O($log(N)$) bound for space complexity. The basic idea of Floajolet-Martin algorthm is to use a bitstrings of length $L$ to encode the set. For each element to add, we randomly pick up a index according to a specified distribution, and assign BITMAP[index] to 1. Following this procedure to add element, the size of the final set can be estimated by $\\frac{1}{\\phi} 2^{\\frac{1}{k}\\sum_{i=1}^k R_i}$, where $\\phi$ = 0.77351, $R_i$ denotes the index of the leftmost 0 in the the $k$th bitstring.\n\nIn our proposed method for computing radius of every node, we use the Flajolet-Martin(FM) bitstrings to encode the neighbors of every node. Formally, we use $k$ FM-bitstrings $b(h, i)$ to represent the set of neighbor nodes reachable from $node_i$ within h hops. And for each iteration, we use the following way to update each FM-bitstring:$$b(h,i) = b(h-1,i)  \\quad BIT-OR \\quad  {b(h-1,j)|(i,j)\\in E}$$\n\nGiven the above description of how to encode neighbors of a node, and the method to update bitstrings, we can describe the approximation method we used to compute the raidus of every node in algorithm \\ref{radius:algo3}.\n\n\\begin{algorithm}\n\\caption{Radius of Every Node}\n\\begin{algorithmic}\n\\STATE{Bulk load graph into an edge table in database.}\n\\STATE{Preprocess the edge table, add a self loop edge to every node in the graph.}\n\\STATE{Initialize the vertex table, which contains node id, and a column of bitstring array, the bitstrings are initialized using the FM algorithm}\n\\REPEAT\n\\STATE{For every node update the bitstring according to formula: $b(h,i) = b(h-1,i) \\quad BIT-OR \\quad  {b(h-1,j)|(i,j)\\in E}$. }\n\\STATE{For every node, check whether the bitstrings is unchanged before and after updates, if it's not changed, output i as the radius for this node.}\n\\UNTIL{The bitstrings of every node stabilizes or it reaches the maximum rounds of iteration.}\n\\end{algorithmic}\n\\label{radius:algo3}\n\\end{algorithm}\n\n\\subsubsection{Idea of SQL implementation}\nIn order to store the fm-string array in the table, we use the array type which is supported by PostgreSQL. To initialize the fm string and update the fm string array, we defined some user defined functions in PostgreSQL. The key step of algorithm that updates the FM-bitstring array is accomplished by using aggBitOr in the join and group by clause. Specifically, we join the edge table and vertex table on dst id, group by src id, and then call the aggBitOr to update the fm string array for all nodes. We summarize the user defined functions in Table \\ref{table:radius}.\n\n\\begin{table}[[!htbf]\n\\caption{User defined functions for task 4}\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \\hline\nfunction name & description \\\\\n\\hline\nfmAssign & Assign the k FM-bitstrings for a node \\\\\nbit-or & Execute the OR operations between two bitstring arrays \\\\\naggBitOr & Aggregate function for bit-or \\\\\nfmSize & Estimate the size of a set encoded by FM-bitstring \\\\\n\\hline\n\n\\end{tabular}\n\\end{center}\n\\label{table:radius}\n\\end{table}%\n\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Eigenvalue}\nWe adopt the method propose in \\cite{kang2011spectral}. There are several methods to solve part of eigenvalue computation problems, for instance, power method\\cite{langville2004deeper}. While it has the limitation that it can only extract the eigenvector with biggest eigenvalue. Several method have been proposed to extract top k eigenvectors simultaneously. The approach we use is Lanczos algorithm\\cite{lanczos1950iteration}. The general idea about this algorithm is that instead of directly work on an $N \\times N$ matrix, we first generate a skinny $N \\times m$ matrix(M $\\ll$ N). Then it computes a small $M \\times M$ dense matrix which has good approximation to the eigenvalues of the original matrix. In this case, we directly apply quadratic algorithm to top-k eigenvalues. Notice that k $<$ M.\n\n\\begin{algorithm}\n{\\bf Input:} Matrix $A^{n \\times m}$\\\\\nrandom n-vector $b$,\\\\\nnumber of steps m\\\\\n{\\bf output:} Orthogonal matrix $ V^{v \\times m}_{m} = [v_{1}\\cdots v{m}]$,\\\\\ncoefficients $\\alpha[1..m]$ and $\\beta[1..m-1]$\n\\begin{algorithmic}[1]\n\\caption{Lanczos algorithm}\n\\STATE $\\beta_{0} \\leftarrow 0, v_{0} \\leftarrow 0, v_{1} \\leftarrow \\frac{b}{\\parallel b \\parallel}$ \n\\FOR {$i=1$ to $m$}\n\t\\STATE $v \\leftarrow Av_{i}$\n\t\\STATE $\\alpha_{i} \\leftarrow v^{T}_{i}v $\n\t\\STATE $v \\leftarrow v - \\beta_{i-1}v_{i-1} - \\alpha_{i}v_{i}$\n\t\\STATE $\\beta_{i} \\leftarrow \\parallel v\\parallel $\n\t\\IF {$\\beta_{i} = 0$} \n\t\\STATE break for loop \n\t\\ENDIF\n\t\\STATE $ v_{v+1} \\leftarrow \\frac{v}{\\beta_{i}} $\n\\ENDFOR\n\\end{algorithmic}\n\\label{eigen:algo1}\n\\end{algorithm}\n\n\\begin{algorithm}\n\\caption{Build tridiagonal matrix}\n{\\bf Input:} $\\alpha, \\beta$\n{\\bf Output:} $T^{m\\times m}_{m}$\n\\begin{algorithmic}[1]\n\\FOR {$i=1$ to m}\n\t\\STATE $T[i, i] \\leftarrow \\alpha_{i} $\n\t\\STATE $T[i, i+1] = T[i+1, i] \\leftarrow \\beta_{i}$\n\\ENDFOR\t\n\\end{algorithmic}\n\\label{eigen:algo2}\n\\end{algorithm}\n\n\\begin{algorithm}\n\\caption{Compute Ritz values}\n{\\bf Input:}Orthogonal matrix $V^{n\\times m}_{m}$\\\\\ncoefficients $\\alpha[1..m]$ and $\\beta[1..m-1]$\n\\begin{algorithmic}[1]\n\\STATE $T_{m} \\leftarrow$ (build a tridiagonal matrix from $\\alpha$ and $\\beta$)\n\\STATE $QDQ^{T} \\leftarrow EIG(T_{m})$\n\\STATE $\\lambda_{1..k} \\leftarrow$ (top k eigenvalues from D)\n\\STATE $Q_{k} \\leftarrow $ (k columns of Q corresponding to $\\lambda_{1..k})$\n\\STATE $R_{k} \\leftarrow V_{m}Q_{k}$\n\\end{algorithmic}\n\\label{eigen:algo3}\n\\end{algorithm}\n\n\\subsubsection{Math}\nDifferent from power method, the intermediate multiplication matrix is used to construct a set of orthonormal base of \\emph{Krylv subspace $K_{m}$} which follows the definition:\n\\begin{equation}\nK_{m} = < b, Ab, \\cdots, A^{m-1}b>.\n\\end{equation}\nThe sub procedure to construct orthonormal bases may be any standard algorithm, for example Gram-schmidt algorithm. We can view Lanczos algorithm as an iterative method which incrementally construct Krylov subspace. The pseudo-code is shown in Algorithm \\ref{eigen:algo1}.\n\nAfter Lanczos factorization, we get a few matrices that satisfy the following equation:\n\\begin{equation}\n\tAV_{m} = V_{m}T_{m} + f_{m}e^{T}_{m}\n\\end{equation}\nTo name a few, $A^{n\\times m}$ is input matrix, $V^{n\\times m}_{m}$ contains the m orthonormal bases, $T^{m\\times m}_{m}$ is a tridiagonal matrix, $f_{m}$ is new n-vector orthogonal to all columns of $V_{m}$, $\ne_{m}$ is a vector that \\emph{m}th element is 1, and others 0. After algorithm \\ref{eigen:algo1}, we need to construct the matrix $T^{m\\times m}_{m}$. The algorithm is quite simple, it is listed in algorithm \\ref{eigen:algo2}. \n\nThe eigenvalues of $T_{m}$ are called Ritz values, and $V_{m}Y$'s columns are called Ritz vector. It is constructed by Algorithm \\ref{eigen:algo3}. We expect the Ritz values and Ritz vectors to be good approximation of the eigenvalues and eigenvectors of original matrix. The computation of eigenvalues of $T_{m}$ can be done by standard quadratic algorithms, such as QR method. \n\n\n\\subsubsection{Idea of SQL implementation}\nSince the algorithm of Lanczos algorithm is matrix calculation intensive, so we wrap all matrix related operation in our host language Python. I'll list the most important routines that appears very often in my high level implementation of Lanczos. Then in the final python code, I'l just call these wrappers instead of using raw SQL again and again.\n\\begin{description}\n  \\item[create\\_vector\\_or\\_matrix:]{declare a vector/matrix variable}\n  \\item[assign\\_to:]{Copy a variable's value to another variable}\n  \\item[vetorr\\_length:]{Return the length of a vector}\n  \\item[vector\\_dot\\_product:]{take the dot product of two vectors}\n  \\item[reverse\\_matrix:]{Append reverse of every edge into original graph}\n  \\item[matrix\\_multiply\\_matrix\\_overwrite:]{Multiply a matrix with a matrix}\n  \\item[matrix\\_multiplt\\_vector\\_overwrite:]{Multiply a matrix with a vector}\n  \\item[normalzed\\_vector:]{Normalize a vector}\n\\end{description}\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Belief Propagation}\nFor belief propagation, we use the fabp method proposed in paper\\cite{DBLP:conf/pkdd/KoutraKKCPF11}.\n\n\\subsubsection{method}\nIt can be shown that the solution of belief propagation can be approximated by the linear system:$$[\\mathbf{I}\t + a\\mathbf{D} - c\\mathbf{A}]\\mathbf{b_h} = \\mathbf{\\phi_h}$$ \nwhere $\\mathbf{A}$ is the n by n symmetric adjacency matrix, $\\mathbf{D}$ is the diagonal matrix of degrees, $b_h$ corresponds to the vector of final beliefs for each node, $\\phi_h$ is prior belief vector, and $h_h$ is the homophily factor,  $a = 4h_h^2/(1 - h_h^2)$ and $c = 2h_h / (1-4h_h^2)$.\n\nTo solve this linear system, we can see :$\\mathbf{I} + a\\mathbf{D} - c\\mathbf{A}$ as the form $\\mathbf{I} - \\mathbf{W}$, where $\\mathbf{W} = -a\\mathbf{D} + c\\mathbf{A}$, and using the expansion:$$(\\mathbf{I} - \\mathbf{W})^{-1} = \\mathbf{I} + \\mathbf{W} + \\mathbf{W}^2 + \\mathbf{W}^3 + ...$$\n\nand the solution of the linear system is given by the formula:\n$$\\mathbf{b_h} = (\\mathbf{I} - \\mathbf{W}^{-1})\\mathbf{\\phi_h} =\\mathbf{\\phi_h}  + \\mathbf{\\phi_h} \\mathbf{W} + \\mathbf{\\phi_h} \\mathbf{W}^2 + \\mathbf{\\phi_h} \\mathbf{W}^3 + ...$$\n\nGiven this power method, the implementation is pretty straightforward as described in algorithm \\ref{bp:algo4}.\n\\begin{algorithm}[!htbf]\n\\caption{Belief Propagation}\n\\begin{algorithmic}\n\\STATE{Bulk load graph into an edge table in database.}\n\\STATE{Initialize $h_h = 0.001 $}\n\\STATE{Initialize the initial belief of every node as prior belief}\n\\REPEAT\n\\STATE{Update the belief of node by $b_h(i) = b_h(i-1)\\mathbf{W} + \\mathbf{\\phi_h}$ }\n\\UNTIL{Convergence}\n\\end{algorithmic}\n\\label{bp:algo4}\n\\end{algorithm}\n\n\\subsubsection{Idea of SQL Implementation}\nThe major computation involved is matrix vector multiplication, which is easy to implement in SQL using join and group by step. Furthermore we've wrapped all the matrix related operation in our host language Python, as described in previous task.\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Count of Triangle}\nWe use a simple technique proposed by \\cite{tsourakakis2008fast}, its general idea is build upon a theorem that the count of triangles in a graph is proportional to the sum of cubes of eigenvalues of the graph. \n\n\n\\subsubsection{Global triangle}\nThe algorithm to calculate global triangles is as follows:\n\n\\paragraph{Math}\nThe formula to count global triangle is sum of cubes of eigenvalues, which is:\n\\begin{equation}\n    \\Delta(G) \\gets \\frac{1}{6} \\sum_{j=1}^{i-1}\\lambda_{j}^{3}\n\\end{equation}\n\n\\begin{algorithm}[!htbf]\n\\caption{The EigenTriangle algorithm}\n{\\bf Require: } Adjacency matrix A (n X n)\\\\\n{\\bf Require: } Tolerance \\emph{tol}\\\\\n{\\bf Output: } $\\bigtriangleup'(G)$ global triangle estimation\n\\begin{algorithmic}\n\\STATE{$\\lambda_{i} \\leftarrow LanczosMethod(A, 1)$}\n\\STATE{$\\overrightarrow{\\Lambda} \\gets [\\lambda_{1}]$}\n\\STATE{$i \\gets 2 \\{ $ {initialize i, $\\overrightarrow{\\Lambda}$} \\} }\n\\REPEAT \n    \\STATE{$\\lambda_{i} \\leftarrow LanczosMethod(A, i)$}\n    \\STATE{$\\overrightarrow{\\Lambda} \\gets [\\overrightarrow{\\Lambda} \\lambda_{i}]$}\n    \\STATE{$i \\gets i + 1$}\n\\UNTIL{0 $\\leq$ $\\frac{|\\lambda_{i}^3|}{\\sum_{j=1}^{i} |\\lambda_{i}|^3} \\leq$ tol}\n\\STATE{$\\bigtriangleup'(G) \\gets \\frac{1}{6} \\sum_{j = 1}^{i} \\lambda_{i}^3$}\n\\RETURN{$\\bigtriangleup'(G)$}\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsubsection{Local triangle}\nThe algorithm to calculate the local triangle is as follows.\n\n\\paragraph{Math}\n$\\Delta_{i}$ is the number of local triangles that node i participated in. The formula of local triangle count is based on the following theorem:\n\\begin{equation}\n    \\Delta_{j} = \\frac{\\sum_{k=1}^{i-1}u_{jk}^{2}\\lambda_{k}^{3}}{2}\n\\end{equation}\n\n\n\\begin{algorithm}[!htbf]\n\\caption{The local eigentriangle algorithm\\cite{tsourakakis2008fast}}\n\\begin{algorithmic}\n\\REQUIRE Adjacency matrix $A(n \\times n)$\n\\REQUIRE Tolerance $tol$\\\\\n{\\bf OUTPUT: } $\\Delta'(G)$  per node triangle estimation\n\\STATE $\\langle \\lambda_{1},\\vec{u_{1}} \\rangle \\leftarrow LanczosMethod(A,1)$\n\\STATE $\\vec{\\Lambda} \\leftarrow [\\lambda_{1}]$\n\\STATE $\\bigcup \\leftarrow [\\vec{u_{1}}]$\n\\STATE $i \\leftarrow 2$\n\\REPEAT\n\\STATE $\\langle \\lambda_{i},\\vec{u_{i}} \\rangle \\leftarrow LanczosMethod(A,i)$\n\\STATE $\\vec{\\Lambda} \\leftarrow [\\vec{\\Lambda}\\lambda_{i}]$\n\\STATE $\\bigcup \\leftarrow [\\bigcup \\vec{u_{1}}]$\n\\STATE $i \\leftarrow i + 1$\n\\UNTIL $0 \\leq \\frac{|\\lambda_{i}^3|}{\\Sigma_{j=1}^{i-1}\\lambda_{j}^3} \\leq tol$\n\\FOR   {$j=1$ to $n$}\n\\STATE $\\bigtriangleup_{j} = \\frac{\\Sigma_{k=1}^{i-1}u_{jk}^2\\lambda_{k}^3}{2}$\n\\ENDFOR\n\\STATE $\\bigtriangleup(G)\\leftarrow[\\bigtriangleup_{1},\\ldots,\\bigtriangleup_{n}]$\n\\RETURN $\\bigtriangleup(G)$\n\\end{algorithmic}\n\\end{algorithm}\n\n\n\n\n\\subsubsection{Idea of SQL implementation}\nWe will call Lanczos to get the eigenvalues and eigenvectors of the graph, and sum up the number using SQL \\emph{select}.\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Shortest Path}\nWe adopt Dijkstra's shortest algorithm to compute shortest path from the source node. It works for directed weighted\ngraph which has $O(|V| log |V| + |E|)$ time complexity. The pseudo code is listed in algorithm \\ref{algo:dijkstra}.\n\n\\subsubsection{Math}\nThe core idea of Dijkstra's idea is that it greedily select a candidate node which has already obtained its minimum distance, then update its neighbors' current \nbest distance. \n\n\\begin{algorithm}[!htbf]\n{\\bf Input:} Source node and directed weighted graph. \\\\\n{\\bf Output:} Shortest path of every node from source node. \n\\begin{algorithmic}\n\\caption{Dijkstra shortest path algorithm}\n\\FORALL{node V in graph} \n    \\STATE{dist[V] $\\gets$ infinity} \n    \\STATE{visited[V] $\\gets$ false }\n\\ENDFOR\n\\STATE{dist[source] $\\gets$ 0}\n\\STATE{insert source into Q}\n\\WHILE{Q is not empty} \n    \\STATE{u $\\gets$ vertex in Q with smallest distance} \n    \\STATE{remove u from Q}\n    \\STATE{visited[u] $\\gets$ true}\n    \\FORALL{neighbour v of u}\n        \\STATE{alt $\\gets$ dist[u] + dist\\_between(u, v)}\n        \\IF{alt $<$ dist[v] \\&\\& !visited[v]} \n            \\STATE{dist[v] $\\gets$ alt} \n            \\STATE{insert v into Q}\n        \\ENDIF\n    \\ENDFOR\n\\ENDWHILE\n\\end{algorithmic}\n\\label{algo:dijkstra}\n\\end{algorithm}\n\n\\subsubsection{Idea of SQL implementation}\nThis is implemented purely in SQL. Just like ordinary C code, I have a table to record the current status(visited, distance) of each node, and update one node at a time. \n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\\subsection{Minimum Spanning Tree}\nWe use the classical Prim's algorithm for this additional task. We abandon the Kruskal's algorithm because the disjoint set is not easy to implement using SQL.\n\n\\subsubsection{method}\nThe general idea of Prim's algorithm is to first initialize a tree with a single vertex, chosen arbitrarily from the graph, Then we grow the tree by one edge, the one that connect\nthe tree to vertices not yet in the tree with minimum cost(weight). We repeat this process until all of the nodes in a graph is in the tree(of course we're assuming that the graph is weighted and connected).\n\n\\subsubsection{Idea of SQL implementation}\nThe implementation in SQL can be described in algorithm \\ref{algo:prim}.\n \n\\begin{algorithm}\n{\\bf Input:} Edge Table E of a undirected connected graph \\\\\n{\\bf output:} Edge Table MST containing edges of the minimum spanning tree\n\\begin{algorithmic}\n\\caption{Prim's algorithm}\n\\STATE Create a node table N\n\\STATE Randomly insert a node into N\n\\FOR {$i=1$ to $number of nodes - 1$}\n\t\\STATE Insert into MST an edge from E with minimum weight where src node is in N and destination node is not in N\n\t\\STATE Insert into N with the destination node of the edge selected in last step\n\\ENDFOR\n\\end{algorithmic}\n\\label{algo:prim}\n\\end{algorithm}\n\n\\subsubsection{SQL code}\nPlease refer to the code in {\\bf Appendix}.\n\n\n\n", "meta": {"hexsha": "97624d0c05e72ce1a40dc5229b84ab1e57ee67ca", "size": 22913, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/phase-3/doc/030method.tex", "max_stars_repo_name": "spininertia/graph-mining-rdbms", "max_stars_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/phase-3/doc/030method.tex", "max_issues_repo_name": "spininertia/graph-mining-rdbms", "max_issues_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/phase-3/doc/030method.tex", "max_forks_repo_name": "spininertia/graph-mining-rdbms", "max_forks_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-16T18:23:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-16T18:23:24.000Z", "avg_line_length": 54.6849642005, "max_line_length": 806, "alphanum_fraction": 0.7465630865, "num_tokens": 6389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4462173635165921}}
{"text": "\\documentclass[jou]{apa6}\n\n\\usepackage[american]{babel}\n\n\\usepackage{csquotes}\n\\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}\n\\DeclareLanguageMapping{american}{american-apa}\n\\addbibresource{bibliography.bib}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Discrete Structures\n%% The start of RBS stuff\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Working internal and external links in PDF\n\\usepackage{hyperref}\n% Extra math symbols in LaTeX\n\\usepackage{amsmath}\n\\usepackage{gensymb}\n\\usepackage{amssymb}\n% Enumerations with (a), (b), etc.\n\\usepackage{enumerate}\n\\usepackage[framemethod=TikZ]{mdframed}\n\\usepackage{xcolor}\n\\usepackage{graphicx}\n\\usepackage[justification=centering]{caption}\n\\usepackage{fancyvrb}\n\n\\let\\OLDitemize\\itemize\n\\renewcommand\\itemize{\\OLDitemize\\addtolength{\\itemsep}{-6pt}}\n\n\\usepackage{etoolbox}\n\\makeatletter\n\\preto{\\@verbatim}{\\topsep=3pt \\partopsep=3pt }\n\\makeatother\n\n% These sizes redefine APA for A4 paper size\n\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.27in\n\\headheight 1.0in\n%\\topmargin -24pt\n\\topmargin -32pt\n\\headheight 12pt\n\\headsep 12pt\n%\\textheight 9.19in\n\\textheight 9.35in\n\n\n\\title{Sample Quiz 8}\n\\author{Discrete Structures, Spring 2020}\n\\affiliation{RBS}\n\n\\leftheader{Discrete Sample Quiz 8}\n\n\\abstract{%\n}\n\n%\\keywords{}\n\n\\setlength\\parindent{0pt}\n\n\\begin{document}\n\n\\twocolumn\n\n\\section{Appendix: Quiz on Individual Topics}\n\n\\vspace{4pt}\n{\\bf Question 1.} A hacker wants to \nuse {\\em Arithmetic coding}\nthat would send a virus to the client's computer and unpack itself there.\nHis favorite virus uses this RNS sequence: $\\textcolor{blue}{\\mathtt{GACGU\\$}}$, \nwhere $\\textcolor{blue}{\\mathtt{A}},\\textcolor{blue}{\\mathtt{C}},\\textcolor{blue}{\\mathtt{G}},\\textcolor{blue}{\\mathtt{U}}$ are four nucleobases (the useful data payload), \nbut the symbol $\\textcolor{blue}{\\$}$ is used just once to mark \nthe end of the RNS string. \n\nHe uses the following {\\em a priori} frequencies for the symbols: \n\n\\begin{tabular}{ccccc}\n$\\textcolor{blue}{\\mathtt{A}}$ & $\\textcolor{blue}{\\mathtt{C}}$ & $\\textcolor{blue}{\\mathtt{G}}$ & $\\textcolor{blue}{\\mathtt{U}}$ & $\\textcolor{blue}{\\mathtt{\\$}}$ \\\\ \n$30\\%$ & $10\\%$ & $30\\%$ & $20\\%$ & $10\\%$ \\\\\n\\end{tabular}\n\n\n\\vspace{4pt}\nHe starts with the half-closed line segment $S_0 = [0;1)$ and at every step (for all $i = 0,1,2,3,4,5$) creates the \nnext segment $S_{i+1}$ from $S_i$ by dividing $S_i$ into five parts of lengths proportional \nto the frequencies (the proportions of subdivisions are $3\\!\\!:\\!\\!1\\!\\!:\\!\\!3\\!\\!:\\!\\!2\\!\\!:\\!\\!1$). Then $S_{i+1}$ is the\nsubdivision of the previous $S_i$ corresponding to the newly encoded character.\nAfter encoding all six characters in the virus message $\\textcolor{blue}{\\mathtt{GACGU\\$}}$, the hacker\ngets the segment $S_6$.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-on-individual-topics/arithmetic-coding.png}}\n\\caption{\\label{fig:arithmetic-coding} Building arithmetic code}\n\\end{figure}\n\n\nFind the binary fraction $\\beta$ belonging to $S_6$.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n{\\bf (A)} $\\beta = 0.011011101100011_2$\\\\\n{\\bf (B)} $\\beta = 0.011011101100110_2$\\\\\n{\\bf (C)} $\\beta = 0.011011101101001_2$\\\\\n{\\bf (D)} $\\beta = 0.011011101101100_2$\\\\\n{\\bf (E)} $\\beta = 0.011011101101111_2$\\\\\n\n\n{\\em Note.} In arithmetic coding any sequence of \n$n$ bits represents an interval of length $\\frac{1}{2^n}$.\nFor example the bit sequence {\\tt 010} stands for the segment of real numbers:\n$[0.010_2; 0.011_2) = [0.25; 0.375)$ having length $\\frac{1}{2^3} = \\frac{1}{8}$. \nIf the arithmetic coding yields a segment $[a;b)$ such that \n$[0.25; 0.375) \\subseteq [a;b)$, then {\\tt 010} is the \nresult of the arithmetic coding.\n\nThe number $\\beta = 0.010_2 \\in [a;b)$, and the extra \"0\"\ncharacter ensures that the interval is not too long and it fits inside $[a;b)$. \nFor example, {\\tt 01} would represent a different interval $[0.25; 0.5) \\neq [0.25; 0.375)$. \n\n\n\\vspace{10pt}\n{\\bf Question 2.} We want to use a {\\em regular expression} \nto find all phone numbers with the Latvian country code.\nAssume that the phones can have one of the following formats (here \nsymbol {\\tt D} denotes any digit (0-9)). The space symbols\nare used exactly as written (they are single space characters).\n\n\\begin{verbatim}\n(+371) DDDDDDDD\n+371 DDDDDDDD\n\\end{verbatim}\n\nPick a regular expression that would recognize just these 2 phone formats.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\n\\begin{verbatim}\n(A)   (+371|\\(+371\\)) \\d{8}\n(B)   (\\+371|\\(\\+371\\)) [0-9]{8}\n(C)   (+371|\\(+371\\)) \\d\\d\\d\\d\\d\\d\\d\\d\n(D)   \\+371|(\\+371\\) [0-9]{8,8}\n\\end{verbatim}\n\n\n{\\em Note.} If you wish, you can use text editor such as Notepad++ search dialogue \nto verify which regex works. (Click {\\bf Ctrl+F}, \nenter your regular expression, switch ``Search mode'' to Regular Expression, \nand click the button  ``Find All in All Opened Documents''): \n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{quiz-on-individual-topics/notepad-regex.png}}\n\\caption{\\label{fig:regex-search} Regex Search in Notepad++}\n\\end{figure}\n\nIf you are on a Linux machine, you can also \ntest regex search with the command \"grep\" (and flag -E). \n\n\n\\vspace{10pt}\n{\\bf Question 3.} About 70\\% of the entries in a bit array of a {\\em Bloom filter} are \nequal to $1$ as it is initialized with the words \nfrom some dictionary $D$. \nThe Bloom filter computes $n=8$ independent hash functions to check, \nif some entry belongs to the dictionary $D$. \nWhat is an (approximate) chance $P$ to get a false positive?\nA false positive is an event where one picks \na random word $w \\not\\in D$,\nand Bloom filter incorrectly states that $w$ belongs to $D$\\\\\n\n\\vspace{4pt}\n\\textcolor{teal}{\\em Select one answer.}\\\\\n{\\bf (A)} $P = 30.00\\%$,\\\\\n{\\bf (B)} $P = 5.76\\%$,\\\\\n{\\bf (C)} $P = 3.75\\%$,\\\\\n{\\bf (D)} $P = 0.66\\%$.\n\n\n\n\\vspace{10pt}\n{\\bf Question 4.} \nA testing laboratory tests the same number of people daily, and on day $i$, the number\nof people who tested positively for some health condition was $n_i$. The laboratory knows that \nthe numbers $n_i$ are distributed according to {\\em Poisson distribution} with the \nexpected value $\\lambda = 13.5$. \n\nBy $P$ we denote the probability that on the given day \n$n_i < 5$ (i.e. less than $5$ people test \npositive for that condition). Which is the closest approximate value for this probability? \n\n{\\bf (A)} $P = 0.26\\%$,\\\\\n{\\bf (B)} $P = 0.51\\%$,\\\\\n{\\bf (C)} $P = 5.78\\%$,\\\\\n{\\bf (D)} $P = 10.89\\%$.\n\n{\\em Note.} Another typical illustration of the same Poisson distribution: \nImagine the ice cream ``R\\={u}jienas sald\\={e}jums'' with raisins. (In this case\nthe average number of raisins in one package is $\\lambda = 13.5$; and you have to find the \nprobability that a given ice cream package has at most $4$ raisins. \nSee \\url{https://bit.ly/2KanwIf}. \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1in]{quiz-on-individual-topics/rujiena-icecream.png}}\n\\caption{\\label{fig:rujiena-icecream} An Ice Cream Package with Raisins satisfying Poisson Distribution}\n\\end{figure}\n\n\n% ff <- function(k) {  return((lam^k*exp(-lam))/factorial(k) }\n\n\\vspace{10pt}\n{\\bf Question 5.} Find the minimum number of colors to paint the $12$ vertices\nfrom the graph shown in Figure~\\ref{fig:graph-coloring} so\nthat any two vertices connected with an edge are having different colors. \n(This number $n$ is called the {\\em chromatic number} for the graph $G$.)\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.6in]{quiz-on-individual-topics/durer-graph.png}}\n\\caption{\\label{fig:graph-coloring} Graph for Vertex Coloring}\n\\end{figure}\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 6.} Assume that the ``World Wide Web'' contains only \n$4$ pages $A,B,C,D$ that link to each other as shown in the picture below.\n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1in]{quiz-on-individual-topics/pageranks.png}}\n\\caption{\\label{fig:pageranks} Four webpages with links.}\n\\end{figure}\n\n\n% https://matrix.reshish.com/multiplication.php\n\nIn the Iteration $0$ initialize the page ranks with equal values \n$$\\text{PR}_0(A) = \\ldots = \\text{PR}_0(D) = \\frac{1}{4}.$$ \nCompute the first two iterations of these pageranks, using the formulas: \n$$\\left\\{ \\begin{array}{l}\n\\text{PR}_{i+1}(A) = (1 - d) + d\\left( \\frac{\\text{PR}_i(D)}{2} \\right)\\\\\n\\text{PR}_{i+1}(B) = (1 - d) + d\\left( \\frac{\\text{PR}_i(A)}{2} + \\frac{\\text{PR}_i(C)}{1} + \\frac{\\text{PR}_i(D)}{2}  \\right)\\\\\n\\text{PR}_{i+1}(C) = (1 - d) + d\\left( \\frac{\\text{PR}_i(B)}{2} \\right)\\\\\n\\text{PR}_{i+1}(D) = (1 - d) + d\\left( \\frac{\\text{PR}_i(A)}{2} + \\frac{\\text{PR}_i(B)}{2} \\right)\n\\end{array} \\right.$$\nSet the value of the damping factor $d=0$.\n\nWrite the values of the second iteration for all the pages:\n$\\text{PR}_2(A),\\ldots,\\text{PR}_2(D).$.\n\n\\textcolor{teal}{\\em Write $4$ comma-separated numbers; round them to \nthe nearest thousandth.}\n\n\n\n\n\n\\vspace{4pt}\n{\\em Note.} You can also use vector algebra, if you are \nfamiliar with multiplying matrices with vectors\n\\textendash{} \\url{https://bit.ly/2RJTNtC}.\n$$\\left( \\begin{array}{c}\n\\text{PR}_2(A)\\\\\n\\text{PR}_2(B)\\\\\n\\text{PR}_2(C)\\\\\n\\text{PR}_2(D)\n\\end{array} \\right) = \\left( \n\\begin{array}{cccc}\n\\textcolor{blue}{0}   & \\textcolor{green}{0}   & \\textcolor{red}{0} & \\textcolor{purple}{1/2} \\\\\n\\textcolor{blue}{1/2} & \\textcolor{green}{0}   & \\textcolor{red}{1} & \\textcolor{purple}{1/2} \\\\\n\\textcolor{blue}{0}   & \\textcolor{green}{1/2} & \\textcolor{red}{0} & \\textcolor{purple}{0} \\\\\n\\textcolor{blue}{1/2} & \\textcolor{green}{1/2} & \\textcolor{red}{0} & \\textcolor{purple}{0}\n\\end{array} \\right)^2 \\cdot \\left( \\begin{array}{c}\n1/4 \\\\\n1/4 \\\\\n1/4 \\\\\n1/4\n\\end{array} \\right).$$\nIn this formula a square matrix $4 \\times 4$ is twice multiplied to a $4 \\times 1$\nvector $(1/4, 1/4, 1/4, 1/4)$ from the left side. \n%See \\url{https://bit.ly/2VkZHnh}. \n\n\n\\vspace{4pt}\n{\\em Note.} \\url{https://checkpagerank.net/check-page-rank.php}\nshows that:\\\\\n{\\tt https://www.bitl.lv/} has PageRank $2/10$,\\\\\n{\\tt https://www.delfi.lv/} has PageRank $6/10$.\\\\\nThis does {\\bf not} mean that there are three times more \ninbound links to Delfi than to BITL (or that these links are three times more ``valuable''). \nThe value returned by this web resource is a {\\em logarithmic measure}\nof its iterative value. In fact, the difference between $2/10$ and $6/10$\nmeans that the popularity of these pages differs by many orders of magnitude. \nSee \\url{https://bit.ly/2yrRMf7}.\n\n\n\\vspace{10pt}\n{\\bf Question 7.} As you probably know, {\\em Karatsuba's algorithm} can express \nthe multiplication of two numbers of length $n$ digits as \nthree multiplications of numbers of length $n/2$ (i.e. the number of \noperations are three times larger, but the operands become two times shorter). \nThis ultimately means that Karatsuba's algorithm requires\nonly $O(n^{1.585})$ operations to multiply numbers of length $n$.\n\nImagine that somebody has invented a new operation $a \\otimes b$ for \nsome objects $a,b$ (both $a,b$ have the same size $n$). \nAssume that s/he knows how to express \n$a \\otimes b$ using $7$ operations $a_i \\otimes b_i$ (where $i = 1,2,\\ldots,7$, and\nall $a_i,b_i$ have size $n/2$, i.e. half the size of the original operands $a,b$). \n({\\em We do not care, what the operation $\\otimes$ does; but we know that we \ncan compute it for arguments $a,b$ of length $1$ in constant time; it is \ntherefore easy for very short arguments.})\n\nFind the best Big-O-Notation estimate for the time needed to compute $a \\otimes b$, if $a,b$ are\nboth of size $n$. \n\n{\\bf (A)} $O(n^2)$\\\\\n{\\bf (B)} $O(n^2 \\log n)$\\\\\n{\\bf (C)} $O(n^{2.646})$\\\\\n{\\bf (D)} $O(n^{2.808})$\\\\\n{\\bf (E)} $O(n^3)$\\\\\n{\\bf (F)} $O(n^3 \\log n)$\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\\vspace{4pt}\n{\\em Note 1.} One can use Master's theorem (Rosen2019, p.558) for \nthis problem and also for the Karatsuba's algorithm.\n\n\\vspace{4pt}\n{\\em Note 2.} If the algorithm falls in multiple Big-O complexity classes, pick \nthe one that shows the slowest growth. For example, if a speed of an algorithm is \nboth in $O(n^2)$ and $O(n^3)$, \nthen $O(n^2)$ would be a more precise and a more useful estimate.\n\n\n\\vspace{10pt}\n{\\bf Question 8.} Assume that two players $A$ and $B$ play a {\\em matrix game}. \nThey simultaneously guess one number each. Either player can guess \none of these three numbers: $\\{ 1,2,5 \\}$. \nThe payoff matrix is shown below. \nIn each cell the first number is what is paid to player $A$, \nthe second number is paid to player $B$. \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2.4in]{quiz-on-individual-topics/matrix-game.png}}\n\\caption{\\label{fig:matrix-game} Matrix game with payoffs.}\n\\end{figure}\n\nExpressed in human language, the rules are as follows. \nAssume that the player $A$ just guessed a number $a$, and player $B$ guessed \na number $b$. \n\\begin{itemize}\n\\item If $a=b$, then it is a tie; nobody pays anything.\n\\item If $a>b$ (yet $a < 3b$), then $B$ pays to $A$ one euro. (And also, \nif $b>a$ yet $b < 3a$, then $A$ pays to $B$ one euro.)\n\\item If $a \\geq 3b$, then $A$ pays to $B$ two euros. (And also, if $b \\geq 3a$, \nthen $B$ pays to $A$ two euros.)\n\\end{itemize}\n\n{\\em In this number guessing game one can win by guessing a number which is a little\nbit larger than the other player's number. But one should not guess a number which is \nlarger than the other by ``a lot'' (if you exceed the other player's number\nthree times or more, then you suffer a double loss.).}\n\nWhich can be {\\em Nash equilibrium} for this number guessing game?\n(You can assume that one of the answer variants is correct \\textendash{} \nthe same optimal strategy for both players. It is enough to find the \none that beats all the other strategies.) \nEach strategy lists the probabilities for guessing the number $x$: \n\n{\\bf (A)} $P(x = 1) = 1/3$, $P(x = 2) = 1/3$, $P(x = 5) = 1/3$.\\\\\n{\\bf (B)} $P(x = 1) = 0$, $P(x = 2) = 1/2$, $P(x = 5) = 1/2$.\\\\\n{\\bf (C)} $P(x = 1) = 1/2$, $P(x = 2) = 1/2$, $P(x = 5) = 0$.\\\\\n{\\bf (D)} $P(x = 1) = 1/4$, $P(x = 2) = 1/2$, $P(x = 5) = 1/4$.\\\\\n{\\bf (E)} $P(x = 1) = 2/6$, $P(x = 2) = 3/6$, $P(x = 5) = 1/6$.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\n\\vspace{10pt}\n{\\bf Question 9.} The first iterations using Lindermayer system are given:\\\\\n{\\bf Iteration 0:} {\\tt A}\\\\\n{\\bf Iteration 1:} {\\tt AB}\\\\\n{\\bf Iteration 2:} {\\tt ABBA}\\\\\n{\\bf Iteration 3:} {\\tt ABBABAAB}\\\\\n{\\bf Iteration 4:} {\\tt ABBABAABBAABABBA}\n\n({\\em To get Iteration 5: Take Iteration 4, \nchange all A's into B's and\nvice versa, and append such string to the end of Iteration 4.})\nFind the correct set of rules to generate this L-system. \n\n{\\bf (A)} ${\\displaystyle \\left\\{ \\begin{array}{l}\n\\mathtt{A} \\rightarrow \\mathtt{B}\\\\\n\\mathtt{B} \\rightarrow \\mathtt{BA}\n\\end{array} \\right. }$\\\\\n{\\bf (B)} ${\\displaystyle \\left\\{ \\begin{array}{l}\n\\mathtt{A} \\rightarrow \\mathtt{AB}\\\\\n\\mathtt{B} \\rightarrow \\mathtt{AA}\n\\end{array} \\right. }$\\\\\n{\\bf (C)} ${\\displaystyle \\left\\{ \\begin{array}{l}\n\\mathtt{A} \\rightarrow \\mathtt{AB}\\\\\n\\mathtt{B} \\rightarrow \\mathtt{BA}\n\\end{array} \\right. }$\\\\\n{\\bf (D)} ${\\displaystyle \\left\\{ \\begin{array}{l}\n\\mathtt{A} \\rightarrow \\mathtt{AB}\\\\\n\\mathtt{B} \\rightarrow \\mathtt{AB}\n\\end{array} \\right. }$\n\n\\textcolor{teal}{\\em Select one answer.}\n\n{\\em Note.} We can have a {\\em turtle} that reads this \nsequence and performs actions:\n\\begin{itemize}\n\\item Letter $\\mathtt{A}$: Step $1$ unit ahead, turn \n$60^{\\circ}$ counterclockwise.\n\\item Letter $\\mathtt{B}$: Turn $180^{\\circ}$. \n\\end{itemize}\nIn this case the iterations $0,2,4,\\ldots$ would produce\na fragment of Koch snowflake (Figure~\\ref{fig:lindenmayer-system}).\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2.5in]{quiz-on-individual-topics/lindenmayer-system.png}}\n\\caption{\\label{fig:lindenmayer-system} Koch curve as an L-system}\n\\end{figure}\n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 10.} Assume that someone uses\na {\\em secure hash} algorithm $h(x)$ that for any file $x$\noutputs a hash value consisting of exactly $100$\nbits. (The typical SHA-256 algorithm would return $256$ bits.)\n\nAssume that we want to use brute force to find \nhash collision \\textendash{} two different files $x_1,x_2$\nsuch that $h(x_1) = h(x_2)$. \nYou can estimate, how many hash values we need to compute before we \nget at least $50\\%$ probability to find a hash collision. \nEstimation can be done using Square aproximation from \nthe Birthday paradox: \n\\begin{equation}\n\\label{eq:square-approximation}\np_{\\text{collision}} \\approx \\frac{n^2}{2m},\n\\end{equation}\nFormally: If a hash function $h(x)$ can take $m$ different values and\nwe randomly pick $n$ different integer numbers $x_1,\\ldots,x_n$, then the probability \nthat there is at least one collision ($h(x_i) = h(x_j)$ and $x_i \\neq x_j$) is approximately expressed by\nthe formula (\\ref{eq:square-approximation}). See \\url{https://bit.ly/2RNjhGB}.\n\nAssume that a single hash value $h(x)$ can be computed in one microsecond\n($1\\,\\mu{}s = 10^{-6}\\,s$). Estimate the number of years it would take to produce a\ncollision for a 100-bit secure hash algorithm with probability at least $50\\%$. \n\n{\\bf (A)} The expected time is $0.11$ years.\\\\\n{\\bf (B)} The expected time is $35.7$ years.\\\\\n{\\bf (C)} The expected time is $71.4$ years.\\\\\n{\\bf (D)} The expected time is $856$ years.\\\\\n{\\bf (E)} The expected time is $4.02\\cdot 10^{16}$ years.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\n\\vspace{10pt}\n{\\bf Question 11.} Consider the following \nproblem solving strategies: \n\n{\\footnotesize\n{\\bf (A)} {\\bf Drawing a picture.} Can you \nwrite down all the things you need to consider on paper? \nCan you order them nicely in a list or a table? \nCan you show them in a two-dimensional or a three-dimensional drawing?\\\\\n{\\bf (B)} {\\bf Getting hands dirty.} Can you start experimenting with the \nproblem, plug in specific values, see where they lead you?\\\\\n{\\bf (C)} {\\bf Going to the extremes.} Can you pick some ``borderline case''?\nIs there the smallest or the largest item that is possible in the problem?\\\\\n{\\bf (D)} {\\bf Lateral thinking.} Could it happen that your current solving approach \nis not applicable or is too inefficient? Can you pretend that you \nhave not spent many years studying mathematics at school; \ncan you apply lateral/divergent thinking out of the box to \ncome up with something unexpected?\\\\\n{\\bf (E)} {\\bf Looking for symmetries.} Can we switch two numbers or two letters in our \nnotation? Can we inspect just one item and notice that many others are identical?\\\\\n{\\bf (F)} {\\bf Making it easier.} Can we make a simpler version of this problem and\nsolve it first? Insert a smaller number? Solve only one particular case of it?\\\\\n{\\bf (G)} {\\bf Penultimate step.} What precondition must take place before \nthe final solution step is possible? Imagine, which result you would need \nin order to say that you are ``almost done''.\\\\\n{\\bf (H)} {\\bf Wishful thinking.} Can you apply some outrageous simplification to your \ninitial problem. Imagine for a while that you have already solved it: What would that imply?\n% http://courses.cs.vt.edu/~cs4104/shaffer/Fall2010/PSintro.pdf\n}\n\nNow consider the following problem:\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{quiz-on-individual-topics/tower-of-hanoi.png}}\n\\caption{\\label{fig:tower-of-hanoi} Tower of Hanoi}\n\\end{figure}\n\n\\begin{mdframed}[roundcorner=6pt]\n{\\footnotesize\n{\\bf Problem.} A Tower of Hanoi (Figure~\\ref{fig:tower-of-hanoi}) \nhas three pegs ($A$, $B$, $C$) and\nfour disks initially on the peg $A$. The task is to move all the four disks to the peg $B$, where\nthe following rules apply:\\\\\nRule 1: Only one disk can be moved at a time.\\\\\nRule 2: Each move consists of taking the upper disk from any peg and moving it to \nanother peg.\\\\\nRule 3: No larger disk may be placed on top of a smaller disk.\n\n{\\em The solver wants to come up with the sequence of moves. S/he has tried\na similar game with just three disks with some trial and error, but \nis not sure how to proceed in the case with four disks. Somebody suggests \na few ``natural looking'' hints.}\n\n{\\bf Hint 1.} Find the disk that is the hardest to move anywhere or moved least frequently?\\\\\n{\\bf Hint 2.} To which peg all the other disks need to go before we move this disk?\\\\\n{\\bf Hint 3.} Assume that you know how to move three disks from the peg $A$ to the peg $B$. \nCan you move them between any other pegs? How?\n}\n\\end{mdframed}\n\n\nWhat kind of problem solving strategies are contained in the hints?\n\n\\textcolor{teal}{\\em Select up to three relevant strategies (A-H).}\n\n\n\n\\begin{center}\n\\includegraphics[width=2in]{quiz-on-individual-topics/thinking-outside-the-box.png}\\\\\n\\textcopyright{} {\\em Leo Cullum}, \\url{https://www.newyorker.com/}\n\\end{center}\n\n\\vspace{10pt}\n{\\bf Question 12.} Someone wants to compute a MD5 checksum for the following file: \n\n\\textcolor{blue}{\n{\\tt 95.211.48.179~~~bitl.lv}\n}\n\nThe following is true: \n\\begin{itemize}\n\\item File {\\tt hosts.txt} is exactly $23$ bytes long.\n\\item The IP address is seperated from {\\tt bitl.lv} by \na single horizontal tab (byte in hexadecimal: {\\tt 0x09}). \n\\item The only line is ends with a Windows-style line ending (carriage return, line feed: \nbytes in hexadecimal: {\\tt 0x0D}, {\\tt 0x0A}). \n\\end{itemize}\n\nFigure~\\ref{fig:hosts-file} shows file displayed by {\\em Total Commander}; \nbutton {\\bf F3}, then menu item {\\bf Options $>$ Hex} (and also in the Notepad++ editor).\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-on-individual-topics/hosts-file.png}}\n\\caption{\\label{fig:hosts-file} Bytes in file {\\tt hosts.txt}}\n\\end{figure}\n\n\\textcolor{teal}{\\em Copy the whole MD5 checksum in your answer.}\n\n{\\em Note.} In this exercise it is important to have exactly the\nsame file content as shown in the picture. \nFor example, replacing the {\\bf TAB} character\nby one or more spaces (or Windows-style line ending with a UNIX-style\nline ending) would totally change MD5. \n(For secure hashes there is absolutely no string tokenization \\textendash{}\nunlike plagiarism detection they are very sensitive against\nthe smallest changes in their input.)\n\n\n\\vspace{10pt}\n{\\bf Question 13.} There are two people playing a game: Player $A$ (he is the Maximizer \\textendash{} wants\nto go down to a leaf with maximum payoff), and Player $B$ (he is the Minimizer \\textendash{} wants\nto minimize the $A$'s payoff). The current position is the root of the tree (Figure~\\ref{fig:minimax}) and it is Player's $A$\nturn to make the first move (to any of the root's children). After that Player $B$ moves (going down one more level) and so on\n\\textendash{} until they reach a leaf, which shows the payoff for Player $A$.\\\\\nFind the maximum payoff for Player $A$ (you could use minimax algorithm with or without Alpha-Beta pruning \nspeedup to find out). \n\n\\textcolor{teal}{\\em Write the payoff as a positive integer.}\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-on-individual-topics/minimax.png}}\n\\caption{\\label{fig:minimax} Game positions in a tree.}\n\\end{figure}\n\n\n\\vspace{10pt} \n{\\bf Question 14.} If you verify the Conway's game of life the configuration $P_0$ \nof a straight line with $4$ live cells (Figure~\\ref{fig:conway}), \nyou need $N = 2$ steps until you reach ``periodic state'' $P_2$ that will \nreturn after period $T = 1$ (i.e.\\ returning needs just one step $P_3 = P_2$, \nsince ``beehive'' configuration is stable). So in this case $(N,T)=(2,1)$ \\textendash{}\nthere are $N=2$ preliminary steps, and after that there is a period of length $T=1$. \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2.2in]{quiz-on-individual-topics/conway.png}}\n\\caption{\\label{fig:conway} Conway game for a line of $4$.}\n\\end{figure}\n\nNow consider a different starting position $P_0$ that contains a straight line \nof $5$ live cells (Figure~\\ref{fig:conway2}). Determine the number of steps $N$ needed\nto reach the first position $P_N$ that would repeat infinitely often, and\nthe length of period $T$ with which the subsequent steps repeat, i.e. \nthe smallest positive integer $T$ with the property:\n$$\\forall k \\in \\mathbb{Z}_{0+},\\;(k \\geq N)\\;\\rightarrow\\; (P_{k+T} = P_k).$$\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=0.6in]{quiz-on-individual-topics/conway2.png}}\n\\caption{\\label{fig:conway2} Starting position $P_0$ for a line of $5$.}\n\\end{figure}\n\n\\textcolor{teal}{\\em Write two comma-separated integers $N,T$.}\n\n{\\em Note.} In Conway's game there are some positions \nthat are not periodic (glider guns that \nconstantly create new stuff), but most simple positions eventually reach periodic state. \nTherefore the numbers $N$ and $T$ are defined in these cases.\n\n\n\n\n\\vspace{10pt} \n{\\bf Question 15.} A mathematical theory $\\mathcal{T}$ (in a similar way as Coq software) \nprovides rules to prove various mathematical statements. \nAssume that in this theory $\\mathcal{T}$ one can prove some statement $A$ and also the\nstatement $\\neg A$. Which description is true for this theory:\n\n{\\bf (A)} $\\mathcal{T}$ is consistent.\\\\\n{\\bf (B)} $\\mathcal{T}$ is not consistent.\\\\\n{\\bf (C)} $\\mathcal{T}$ is complete.\\\\\n{\\bf (D)} $\\mathcal{T}$ is not complete.\\\\\n{\\bf (E)} $\\mathcal{T}$ is effectively axiomatized.\\\\\n{\\bf (F)} $\\mathcal{T}$ is not effectively axiomatized.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\n\\vspace{10pt} \n{\\bf Question 16.} Some banks can issue\n19-digit credit card numbers (instead of the more typical 16-digit ones). \nAssume that there is a 19-digit number that satisfies the Luhn check (mod $10$):\n\n$$\\mathtt{557367054456450571\\ast}.$$\n\nPlease find the digit that is written in the place of the last $\\ast$ symbol.\n\n\\textcolor{teal}{\\em Write a single digit.}\n\n\n\\vspace{10pt} \n{\\bf Question 17.} \nSome text $T$ has been tokenized into a sequence of $N$ words ($w_0,\\ldots,w_{N-1}$). \nAssume that you assigned\nunique numbers to the stemmed words (each word $w_i$ in the text $T$ is replaced by \na number $n(w_i)$); and then computed rolling hash values for \nfive consecutive words in this text using this formula:\\\\\n\n%\\begin{align}\n% & H(w_1,w_2,w_3,w_4,w_5) = \\nonumber \\\\\n%= & \\left( n(w_1) \\cdot a^4 + n(w_2) \\cdot a^3 + n(w_3) \\cdot a^2 + \\right. \\nonumber \\\\\n%+ & \\left. n(w_4) \\cdot a^1 + n(w_5) \\cdot a^0 \\right)\\;\\; \\text{mod}\\;\\; q. \\nonumber\n%\\end{align}\n\n{\\footnotesize\n\\begin{align}\n & H(w_1,w_2,w_3,w_4,w_5) = \\nonumber \\\\\n= & \\left( n(w_1) \\cdot a^4 + n(w_2) \\cdot a^3 + n(w_3) \\cdot a^2 + n(w_4) \\cdot a^1 + n(w_5) \\right)\\, \\text{mod}\\,q. \\nonumber\n\\end{align}\n}\n\n\nThis is a polynomial value for the argument $a$ followed by a remainder when dividing by $q$.\nParameters $a$ and $q$ are two large primes.\n\nWe compute all such hash values:\n$$\\left\\{ \\begin{array}{l}\nv_0 = H(w_0,w_1,w_2,w_3,w_4),\\\\\nv_1 = H(w_1,w_2,w_3,w_4,w_5),\\\\\n\\ldots\\\\\nv_{N-5} = H(w_{N-5},w_{N-4},w_{N-3},w_{N-2},w_{N-1}).\n\\end{array} \\right.$$\n\nIt turned out that $10\\%$ of these hash values were found in an existing\nhashtable $H$ (built from some existing texts using the same hash function) \\textendash{}\nabout $5\\%$ of the values in that hashtable are marked (the others are empty).\nWhat is the most likely explanation for this? \n\n{\\bf (A)} Text $T$ contains large chunks of text that is copy-pasted from other sources.\\\\\n{\\bf (B)} Overlaps of the size $10\\%$ can happen by chance. On the other hand, overlaps\nexceeding $1/5$ (the size of the rolling hash window) would be highly unusual and \nwould require manual inspection.\\\\\n{\\bf (C)} This is not an effective way to detect copying and plagiarism.\nRolling hash should instead run on characters (not entire words),\nsince multiple authors may use the same words.\\\\\n\\textcolor{teal}{\\em Select one answer.}\n\n\n\n\n\n\\vspace{10pt} \n{\\bf Question 18.} Jane took an ordinary soccer ball made from an elastic material\n(Figure~\\ref{fig:icosahedron3d}).\n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{quiz-on-individual-topics/truncated-icosahedron-3d.png}\n\\caption{\\label{fig:icosahedron3d} 3D Soccer Ball}\n}\n\\end{figure}\n\n\nShe stretched one of its faces so that it became a planar graph\n(Figure~\\ref{fig:icosahedron2d}).\nThen she marked a Hamiltonian cycle in this graph (not shown).\n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2.4in]{quiz-on-individual-topics/truncated-icosahedron.png}}\n\\caption{\\label{fig:icosahedron2d} Planar Soccer Ball}\n\\end{figure}\n\nHow many edges of this graph do {\\bf not} belong to the Hamiltonian cycle?\\\\\n\\textcolor{teal}{\\em Write a positive number.}\n\n\n\\mbox{}\n\\newpage\n\n\\subsection{Answers}\n\n\\vspace{4pt}\n{\\bf Question 1.} Answer {\\bf (D)}\\\\\nThe intervals encoding the string $\\textcolor{blue}{\\mathtt{\"GACGU\\$\"}}$\nform the following sequence: \n$$\\left\\{ \\begin{array}{l}\nS_0 = [0.000000; 1.000000]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"\"}}\\;\\text{(empty string)}, \\\\\nS_1 = [0.400000; 0.700000]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"G\"}}, \\\\\nS_2 = [0.400000; 0.490000]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"GA\"}}, \\\\\nS_3 = [0.427000; 0.436000]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"GAC\"}}, \\\\\nS_4 = [0.430600; 0.433300]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"GACG\"}}, \\\\\nS_5 = [0.432490; 0.433030]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"GACGU\"}}, \\\\\nS_6 = [0.432976; 0.433030]\\;\\text{encodes}\\;\\textcolor{blue}{\\mathtt{\"GACGU\\$\"}}. \\\\\n\\end{array} \\right.$$\n\nTo make the sequence of intervals $S_0 \\supset S_1 \\supset \\ldots \\supset S_6$, \nwe can define iterative sequences $\\text{Left}_i$, $\\text{Length}_i$ describing \nthe left endpoint and the length of each successive interval so that for every \n$i = 0,1,\\ldots,6$: \n$$S_i = \\left[ \\text{Left}_i; \\text{Left}_i + \\text{Length}_i \\right].$$\n\nThese sequences are defined in terms of the offsets and frequencies \nof the characters $c_0, c_1, \\ldots, c_5$. \n\n$$\\left\\{ \\begin{array}{l}\n\\text{Left}_{i+1} = \\text{Left}_{i} + \\text{Left}_{i} \\cdot \\text{Offset}(c_i) \\\\\n\\text{Length}_{i+1} = \\text{Length}_{i}  \\cdot \\text{Frequency}(c_i) \\\\\n\\end{array} \\right.$$\n\nFor each encodable character the offsets and frequencies are defined in this table:\n\n\\begin{tabular}{|l|l|l|} \\hline\nCharacter & Frequency & Offset \\\\ \\hline\n$\\mathtt{A}$ & $0.3$ & $0.0$ \\\\ \\hline\n$\\mathtt{C}$ & $0.1$ & $0.3$ \\\\ \\hline\n$\\mathtt{G}$ & $0.3$ & $0.4$ \\\\ \\hline\n$\\mathtt{U}$ & $0.2$ & $0.7$ \\\\ \\hline\n$\\mathtt{\\$}$ & $0.1$ & $0.9$ \\\\ \\hline\n\\end{tabular}\n\nThe only binary number $\\beta$ that belongs to \n$S_6 = [0.432976; 0.433030]$ is shown in answer {\\bf (D)}:\n$$\\beta = 0.011011101101100_2 = 0.4329834_{10}.$$\n\n\n\\vspace{10pt}\n{\\bf Question 2.} Answer {\\bf (B)}\\\\\nThe only syntactically correct regular expression is \n\\begin{verbatim}\n(\\+371|\\(\\+371\\)) [0-9]{8}\n\\end{verbatim}\n\n\\vspace{10pt}\n{\\bf Question 3.} Answer {\\bf (B)}\\\\\nThe probability that all $8$ hash values \nwill happen to be $1$ is \n$$0.7^8 = 0.05764801.$$\n\n\n\n\\vspace{10pt}\n{\\bf Question 4.} (None of the answers is right)\\\\\nWe can add up the probabilities, using Poisson distribution formula: \n$$P(X = k) = \\frac{\\lambda^k \\cdot e^{-\\lambda}}{k!}.$$\nBy adding up the first $5$ values of this distribution we get this expression with $\\lambda = 13.5$: \n$$P(X < 5) = \\sum\\limits_{k=0}^{4} \\frac{\\lambda^k \\cdot e^{-\\lambda}}{k!} \\approx 0.000707.$$ \nTherefore the probability to get less than $5$ raisins is $0.0707\\%$. \n\nSince all the answer variants were wrong, everyone gets full credit for this.\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 5.} Answer: $3$\\\\\nThree colors are sufficient as shown in the picture. \nBut two colors are impossible (since the graph contains a triangle \\textendash{}\na full graph $K_3$). \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-on-individual-topics/durer-graph-colored.png}}\n\\caption{\\label{fig:durer-graph-colored} D\\\"{u}rer Graph colored in $3$ colors.}\n\\end{figure}\n\nThis graph is planar (you can draw it without intersecting edges); \nit also has a famous \npolyhedron (D\\\"{u}rer solid); it was shown in an engraving \nmade in 1514 called {\\em Melencolia I}. See\n\\url{https://bit.ly/2KE2QZl}. \n\n\n\n\\vspace{10pt}\n{\\bf Question 6.} Answer: $0.125,0.313,0.250,0.313$\\\\\nWe write the vectors as they are multiplied with the \n$4 \\times 4$ matrix. The components in the vector \ncorrespond to the pageranks (iterations $0$, $1$ and $2$). \n$$v_0 =  \\left( \\begin{array}{c}\n1/4 \\\\\n1/4 \\\\\n1/4 \\\\\n1/4 \\\\\n\\end{array} \\right);\\;\\;\nv_1 = \\left( \\begin{array}{c}\n1/8 \\\\\n1/2 \\\\\n1/8 \\\\\n1/4 \\\\\n\\end{array} \\right);\\;\\;\nv_2 = \\left( \\begin{array}{c}\n1/8 \\\\\n5/16 \\\\\n1/4 \\\\\n5/16 \\\\\n\\end{array} \\right).$$\n\n\\vspace{10pt}\n{\\bf Question 7.} Answer {\\bf (D)}\\\\\nThe time complexity of such algorithm is $O(n^{\\log_2 7})$ by Master's theorem. Since \n$\\log_2 7 \\approx 2.807355 < 2.808$, we have the time complexity in $O(n^{2.808})$ (it is the best estimate that is given \namong the arguments).\n\n\n\\vspace{10pt}\n{\\bf Question 8.} Answer {\\bf (D)}\\\\\nSince we can assume that one of the five strategies is optimal, it is sufficient to compare the strategies. \nWe assume that Players $A$ and $B$ adopt one of the five suggested strategies\nplus one more simple strategy {\\bf (F)} (always guess number $2$). \n\nThere are altogether $36$ variants. \nFor each pair of strategies we compute the payoff for the Player $A$. \nWe want to find the strategy for Player $A$ \nthat beats any strategy chosen by $B$ (or at least achieves a tie). \n\n{\\bf (A)} $P(x = 1) = 1/3$, $P(x = 2) = 1/3$, $P(x = 5) = 1/3$.\\\\\n{\\bf (B)} $P(x = 1) = 0$, $P(x = 2) = 1/2$, $P(x = 5) = 1/2$.\\\\\n{\\bf (C)} $P(x = 1) = 1/2$, $P(x = 2) = 1/2$, $P(x = 5) = 0$.\\\\\n{\\bf (D)} $P(x = 1) = 1/4$, $P(x = 2) = 1/2$, $P(x = 5) = 1/4$.\\\\\n{\\bf (E)} $P(x = 1) = 2/6$, $P(x = 2) = 3/6$, $P(x = 5) = 1/6$.\\\\\n{\\bf (F)} $P(x = 1) = 0$, $P(x = 2) = 1$, $P(x = 5) = 0$.\\\\\n\nThe strategies of Player $A$ are shown in rows; strateges of Player $B$ are shown in columns: \n\n\\begin{tabular}{|l|c|c|c|c|c|c|} \\hline\n & {\\bf (A)} & {\\bf (B)} & {\\bf (C)} & {\\bf (D)} & {\\bf (E)} & {\\bf (F)} \\\\ \\hline\n{\\bf (A)} & $0$ & $1/6$ & $-1/6$ & $0$ & $-1/18$ & $0$ \\\\ \\hline\n{\\bf (B)} & $-1/6$ & $0$ & $0$ & $0$ & $0$ & $1/2$ \\\\ \\hline\n{\\bf (C)} & $1/6$ & $0$ & $0$ & $0$ & $0$ & $-1/2$ \\\\ \\hline\n{\\bf (D)} & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\\\ \\hline\n{\\bf (E)} & $1/18$ & $0$ & $0$ & $0$ & $0$ & $-1/6$ \\\\ \\hline\n{\\bf (F)} & $0$ & $-1/2$ & $1/2$ & $0$ & $1/6$ & $0$ \\\\ \\hline\n\\end{tabular}\n\nAs you can see from the table, every strategy (except {\\bf (D)}) \nloses against some other strategy (there is at least one negative\nnumber on every line of the table). The only strategy that never loses\nis strategy {\\bf (D)}, i.e. picking the numbers $1,2,5$ with probabilities\n$\\frac{1}{4}, \\frac{1}{2}, \\frac{1}{4}$ respectively. \n(In fact, this is also Nash equilibrium \\textendash{} no other\nprobabilistic strategy fares better than this.)\n\nNote that without the strategy {\\bf (F)} we did not have enough \nevidence to see that strategies {\\bf (C)} and {\\bf (E)}\nare not optimal (because they only lose to strategy {\\bf (F)}). \nMoreover, the relationships between strategies are non-transitive:\n\\begin{itemize}\n\\item {\\bf (A)} beats {\\bf (B)}\n\\item {\\bf (B)} beats {\\bf (F)}\n\\item {\\bf (F)} beats {\\bf (C)} and {\\bf (E)}\n\\item {\\bf (C)} and {\\bf (E)} beat {\\bf (A)}\n\\end{itemize}\n\nThe Nash equilibrium {\\bf (D)} does not beat anything in the list; \nit does not try to exploit ``foolish'' choices of the\nopponent.\n\n\\vspace{10pt}\n{\\bf Question 9.} Answer {\\bf (C)}\\\\\nThis is known as Thue-Morse sequence. It is usually described at ``marcro-level'' - how to obtain \nnew iterations of this sequence (by appending a new chunk of the previous iteration, where\nall letters have changed places). See \\url{https://bit.ly/3aExEnq}.\n\nBut it is also possible to build Thue-Morse sequence at a ``micro-level'' (how to expand individual letters into \npairs of letters):\\\\ \n${\\displaystyle \\left\\{ \\begin{array}{l}\n\\mathtt{A} \\rightarrow \\mathtt{AB}\\\\\n\\mathtt{B} \\rightarrow \\mathtt{BA}\n\\end{array} \\right. }$\n\n{\\em Note.} \\url{https://bit.ly/2ypZ2rI} shows other nice\nLindenmayer images that can be created from the Thue-Morse sequence.\n\n\n\\vspace{10pt}\n{\\bf Question 10.} Answer {\\bf (B)}\\\\\nThe number of hash values to be computed in order to have a $\\frac{1}{2} = 50\\%$ chance of a hash collision \ncan be estimated using the square approximation. If we compute $n$ values (and each value is \na non-negative integer less than $m$), then\n$$\\frac{1}{2} \\approx \\frac{n^2}{m};\\;\\;n \\approx \\sqrt{m}.$$\nIf we have $100$-bit hash values, then $m = 2^{100}$. And $n = \\sqrt{2^{100}} = 2^{50}$. \n\nWe therefore need $n = 2^{50} \\approx 1.1259 \\cdot{10}^{15}$. Now divide this number to convert from \nmicroseconds into years (divide by the number of milliseconds in a second; the number of seconds in an hour; \nthe number of hours in a day; a number of days in year): \n$$n = 1.1259 \\cdot{10}^{15} : 10^6 : 3600 : 24 : 365 \\approx 35.70205.$$\n\nTherefore the estimate is $35$ years. (For SHA-256 the estimate would be 10.8 Septillions or\nabout $10.8\\cdot 10^{24}$ years.) The collisions of secure hash functions exist (and by the \nPigeonhole principle there should be many collisions for sufficiently short files). In fact, \nSHA-256 collisions are inevitable even when the size of the input file exceeds $256$ bits (i.e. \n$32$ bytes).\n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 11.} Answer: {\\bf (C)}, {\\bf (E)}, {\\bf (G)}\\\\\n\\begin{itemize}\n\\item Hint 1 asks to consider the largest or the least frequently moved disk.\n(Going to the extremes, answer {\\bf (C)}).\n\\item Hint 2 asks what should happen right before we can move the largest disk\n(Penultimate step, answer {\\bf (G)}).\n\\item Hint 3 asks to see the symmetry in the problem (if you know how to move \nthree disks from peg $A$ to peg $B$, then you can also move them from peg $A$ to peg $C$, \nand thus free the way for the fourth disk. \n(Looking for symmetries, answer {\\bf (E)}. \n\\end{itemize}\n\nOther strategies are not directly used in the hints. Learning how to move \nthree disks (before doing it with four disks) would mean making it easier (answer {\\bf (F)}), \nbut it is already done by the learner.\n\n\n\\vspace{10pt}\n{\\bf Question 12.} Answer:\\\\\n{\\tt a787b563a07713fad9b68fb1d1370f5e}\n\nIt can be computed from the command-line: \n\\begin{verbatim}\nmd5sum hosts.txt\n\\end{verbatim}\n\n\n\n\\vspace{10pt}\n{\\bf Question 13.} Answer: $6$\\\\\n\nWe can compute the best moves moving bottom up, starting with the \nleaves and computing the best payoff in every internal node (see Figure~\\ref{fig:minimax2}). \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-on-individual-topics/minimax2.png}}\n\\caption{\\label{fig:minimax2} Minimax in a tree.}\n\\end{figure}\n\n\n\\vspace{10pt}\n{\\bf Question 14.} Answer: $6,2$\\\\\nThere are $N=6$ steps to go from $P_0$ to $P_6$. \nAfter that there is a periodic repeat of positions $P_6$ and $P_7$ \nwith period $T = 2$ (see Figure~\\ref{fig:conway-line5}).\n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-on-individual-topics/conway-line5.png}}\n\\caption{\\label{fig:conway-line5} Conway Positions.}\n\\end{figure}\n\n\n\\vspace{10pt}\n{\\bf Question 15.} Answer: {\\bf (B)}\\\\\n\nA theory which can prove a statement and its negation is called {\\bf not consistent}. \n(On the contrary, theories where this can never happen are called {\\bf consistent}).\n\nBTW the first G\\\"{o}del's Incompleteness Theorem states that any theory about integer numbers that \nis effectively axiomatizable and consistent should also be incomplete \n(i.e.\\ there are true results that cannot be proven). So the theory $\\mathcal{T}$ from our problem has a chance to \nbe complete. But being inconsistent makes it completely useless (if a statement and its negation are\nboth provable, then virtually anything can be proven, since \nboth provable statements $A$ and $\\neg A$ also imply \n$(A \\wedge \\neq A) = \\mathtt{false}$. But\nsuch {\\tt false} theorem would imply anything \\textendash{} whether it makes sense or not.\n\n\n\\vspace{10pt}\n{\\bf Question 16.} Answer: $4$\\\\\nThe full 19-digit credit card number is this: \n$$\\mathtt{557367054456450571}\\textcolor{red}{\\mathtt{4}}.$$\n\nSee \\url{https://bit.ly/2Y6NaWv} for online Luhn check. \nThe procedure is as follows:\n\n\\begin{itemize}\n\\item Drop the last digit from the number. (It is initially unknown in our case.) \n\\item Reverse the digits.\n\\item Multiply the digits in odd positions ($1$, $3$, $5$, etc.) by $2$ and subtract $9$ to all any result higher than $9$. \n\\item Add all the obtained numbers together\n\\item The last (unknown) number is the amount that you would need to add to get a multiple of 10. \n\\end{itemize}\n\n\\begin{verbatim}\n5,5,7,3,6,7,0,5,4,4,5,6,4,5,0,5,7,1 \n1,7,5,0,5,4,6,5,4,4,5,0,7,6,3,7,5,5 \n2,7,10,0,10,4,12,5,8,4,10,0,14,6,6,7,10,5\n2,7,1,0,1,4,3,5,8,4,1,0,5,6,6,7,1,5\n\\end{verbatim}\n\nThe sum of all digits on the last line is $66$. By adding digit $4$ this number becomes divisible by $10$. \n\n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 17.} Answer {\\bf (A)}\\\\\n\nWe should apply our intuition about natural language texts. \nIf there are many identical sequences of five consecutive words, then they \ncannot appear by pure chance (there might be some common proverbs or short quotes, \nbut they would not make $10\\%$ overlap. \n\nAnswer {\\bf (B)} is not credible \\textendash{} if random lookups in the hashtable lead to $5\\%$ matching, \nthen $10\\%$ overlap cannot be explained by chance.\\\\\nAnswer {\\bf (C)} is not applicable either; rolling hash on words (especially, if it detects considerable\nnumber of matches) is more useful than rolling hash on characters \\textendash{} matching the characters\nis less robust and the hash windows are typically shorter. \n\n\n\\vspace{10pt}\n{\\bf Question 18.} Answer $30$\\\\\nTruncated icosahedron (soccer ball graph) has the following number of \nfaces, edges and vertices:\n$$F = 32, E = 90, V = 60.$$\n\nSince Hamilton graph visits all $60$ vertices, \nit should also have $60$ edges. \nFor this reason, there are $E - V = 90 - 60 = 30$ edges\nthat are not part of the Hamiltonian cycle.\n\n\n\\end{document}\n\n", "meta": {"hexsha": "f8e19378155dc1b51c98871a52694eba281596c9", "size": 41723, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/site/discrete-spring2020/questionbase/quiz-on-individual-topics.tex", "max_stars_repo_name": "kapsitis/math", "max_stars_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/site/discrete-spring2020/questionbase/quiz-on-individual-topics.tex", "max_issues_repo_name": "kapsitis/math", "max_issues_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-20T03:40:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T21:50:18.000Z", "max_forks_repo_path": "src/site/discrete-spring2020/questionbase/quiz-on-individual-topics.tex", "max_forks_repo_name": "kapsitis/math", "max_forks_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6324074074, "max_line_length": 172, "alphanum_fraction": 0.688924574, "num_tokens": 13690, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.44621735942924884}}
{"text": "\\section{Conclusions and Future Directions}\n\nITK is a large and powerful framework for medical (and general) image processing.  However, the lack of filters for understanding, manipulating, and unwrapping phase data is a current limitation of the library.  We have here presented an ITK module which we hope will begin to bridge that gap.  The two most significant contributions are the \\code{itk::QualityGuidedPhaseUnwrappingImageFilter} and \\code{itk::DCTPhaseUnwrappingImageFilter} classes, which implement efficient $n$-dimensional unwrapping algorithms.  The quality-guided approach has the advantage of giving a result that is congruent to the input.  Moreover, this approach avoids low-quality phase data, given an adequate quality map.  The unweighted $L^2$-norm approach has the advantage of giving a smooth result throughout, but is not congruent with the input and weights all pixels equally regardless of quality.\n\nThese algorithms both gave servicable results when presented with the SWI data, which had few residues within the region of interest, and in which the low quality data was largely relegated to the periphery.  However, both algorithms failed to produce an adequate result when presented with the more difficult HARP image.  In the case of the quality-guided approach, this is likely due to the inadequacy of phase derivative variance as a quality map, because in HARP images phase varies quite smoothly even in regions where there is little to no signal.  In the case of the DCT algorithm, this is likely because the region of interest is relatively small compared to the image as a whole.\n\nIn the future, it would be of great benefit to allow for other quality maps (such as maximum phase gradient, pseudocorrelation, and user-defined masks) in addition to phase derivative variance.  This would allow for finer control over the path the algorithm takes in the case of difficult cases such as HARP images.  Additionally, it would be of benefit to implement a weighted $L^2$-norm method, so that the DCT approach could also exclude low-quality or uninteresting regions.  Weighted $L^2$-norm phase unwrapping algorithms have been described which iteratively apply unweighted algorithms to weighted wrapped phase Laplacians.  The preconditioned conjugate gradient (PCG) approach in particular makes use of this method \\cite{Ghiglia1998}, and would be an important next step in the development of this module.\n\nThis submission has also described \\code{itk::DCTImageFilter} and \\code{itk::DCTPoissonSolverImageFilter}, which are efficient implementations of general-purpose utilities important in image compression, gradient image editing, and phase unwrapping.  The former is a simple wrapper to the FFTW library, allowing for the discrete cosine transform to be integrated into an ITK pipeline.  The latter makes use of the DCT class to recover an image from its Laplacian.  We refer the interested reader to the appendices for a proper discussion.", "meta": {"hexsha": "d047a6e69ab67225a64bdcb76f9c31599f5a0018", "size": 2972, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Document/includes/Conclusions.tex", "max_stars_repo_name": "DVigneault/ITKPhaseSubmission", "max_stars_repo_head_hexsha": "4f52c134102139544a63d454501983f00c3ade67", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-07T03:59:18.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-07T03:59:18.000Z", "max_issues_repo_path": "Document/includes/Conclusions.tex", "max_issues_repo_name": "DVigneault/ITKPhaseSubmission", "max_issues_repo_head_hexsha": "4f52c134102139544a63d454501983f00c3ade67", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Document/includes/Conclusions.tex", "max_forks_repo_name": "DVigneault/ITKPhaseSubmission", "max_forks_repo_head_hexsha": "4f52c134102139544a63d454501983f00c3ade67", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 330.2222222222, "max_line_length": 880, "alphanum_fraction": 0.8142664872, "num_tokens": 638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.44621735189842504}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage[export]{adjustbox}\n\\graphicspath{ {./images/} }\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{mhchem}\n\\usepackage{stmaryrd}\n\\usepackage{bbold}\n\n\\begin{document}\n\\subsection{D and 2D Finite Element and Multigrid}\n1D and 2D Comparison for Finite Element and Multigrid\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_175a66d2121dcf20361ag-1}\n\nBasic multigrid components\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_175a66d2121dcf20361ag-2}\n\n\\subsubsection{Multigrid algorithm for $A * \\mu=f$}\n\\section{Algorithm 11 A multigrid algorithm $\\mu=\\operatorname{MG} 1\\left(f ; \\mu^{0} ; J, v_{1}, \\cdots, v_{J}\\right)$ \n Set up}\n$$\nf^{1}=f, \\quad \\mu^{1}=\\mu^{0}\n$$\nSmoothing and restriction from fine to coarse level (nested)\n\nfor $\\ell=1: J$ do\n\nfor $i=1: v_{\\ell}$ do\n$$\n\\mu^{\\ell} \\leftarrow \\mu^{\\ell}+S^{\\ell} *\\left(f^{\\ell}-A_{\\ell} * \\mu^{\\ell}\\right)\n$$\nend for\n\nForm restricted residual and set initial guess:\n$$\n\\mu^{\\ell+1} \\leftarrow \\Pi_{\\ell}^{\\ell+1} \\mu^{\\ell}, \\quad f^{\\ell+1} \\leftarrow R *_{2}\\left(f^{\\ell}-A_{\\ell} * \\mu^{\\ell}\\right)+A_{\\ell+1} * \\mu^{\\ell+1},\n$$\nend for\n\nProlongation and restriction from coarse to fine level\n\nfor $\\ell=J-1: 1$ do\n$$\n\\mu^{\\ell} \\leftarrow \\mu^{\\ell}+R *_{2}^{\\top}\\left(\\mu^{\\ell+1}-\\Pi_{\\ell}^{\\ell+1} \\mu^{\\ell}\\right)\n$$\nend for\n$$\n\\mu \\leftarrow \\mu^{1}\n$$\nRemark 9. The above multigrid method for the linear problem $A * \\mu=b$ is independent of the choice of the interpolation operation $\\Pi_{\\ell}^{\\ell+1}: \\mathbb{R}^{n_{\\ell} \\times n_{\\ell}} \\mapsto \\mathbb{R}^{n_{\\ell+1} \\times n_{\\ell+1}}$ and in particular, we could take $\\Pi_{\\ell}^{\\ell+1}:=0$. But such an operation is critical for nonlinear problems.\n\n\\subsubsection{MgNet}\nAlgorithm $12 \\mu^{J}=\\operatorname{MgNet} 1\\left(f ; \\mu^{0} ; J, v_{1}, \\cdots, v_{J}\\right)$\n\\[ \\begin{array}{l}\\text { Set up } \\\\ \\qquad f^{1}=\\theta * f, \\quad \\mu^{1}=\\mu^{0} .\\end{array} \\]\nSmoothing and restriction from fine to coarse level (nested)\\\\\nfor $\\ell=1: J$ do $\\quad$ for $i=1: v_{\\ell}$ do\\\\\n(8.34) $\\quad \\mu^{\\ell} \\leftarrow \\mu^{\\ell}+\\sigma \\circ S^{\\ell} * \\sigma \\circ\\left(f^{\\ell}-A_{\\ell} * \\mu^{\\ell}\\right) .$\\\\\nend for $\\quad f^{\\ell+1} \\leftarrow \\Pi_{\\ell}^{\\ell+1} \\mu^{\\ell}, \\quad f^{\\ell+1} \\leftarrow R *_{2}\\left(f^{\\ell}-A_{\\ell} * \\mu^{\\ell}\\right)+A_{\\ell+1} * \\mu^{\\ell+1}$,\\\\\nForm restricted residual and set initial guess:\\\\\nend for\n\n\n\\end{document}", "meta": {"hexsha": "bfc55a18f5799aca5dc7d7c2d25cc4d61115aa1c", "size": 2549, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Module6/f01-summary-notes.tex", "max_stars_repo_name": "liuzhengqi1996/math452_Spring2022", "max_stars_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Module6/f01-summary-notes.tex", "max_issues_repo_name": "liuzhengqi1996/math452_Spring2022", "max_issues_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Module6/f01-summary-notes.tex", "max_forks_repo_name": "liuzhengqi1996/math452_Spring2022", "max_forks_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.9420289855, "max_line_length": 359, "alphanum_fraction": 0.6590819929, "num_tokens": 995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.44621735125456236}}
{"text": "\\documentclass[11pt]{article}\r\n\\usepackage{amsmath,amssymb,amsthm, logicproof}\r\n\\usepackage[margin=2.75cm]{geometry}\r\n\\usepackage{multicol}\r\n\\newcommand{\\encode}[1]{\\langle #1 \\rangle}\r\n\r\n\\title{\\bf Predicate Logic\\\\Quantifier Rules\\\\[2ex]\r\n\\rm\\normalsize CS251 at CCUT, Spring 2017 \\\\}\r\n\\date{May 8$^{th}$, 2017}\r\n\\author{David Lu}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\\paragraph{Contents}\r\n\\begin{enumerate}\r\n\t\\item Universal Instantiation (UI)\r\n\t\\item Existential Generalization (EG)\r\n\t\\item Universal Generalization (UG)\r\n\t\\item Existential Instantiation (EI)\r\n\t\\item Quantifier Negation (QN) and Quantifier Equivalence (QE)\r\n\t\\item Multiple Quantification\r\n\\end{enumerate}\r\n\r\n\\paragraph{1. Universal Instantiation/Elimination UI}\r\nIf X is a universally quantified sentence, then you are licensed to conclude any of its substitution instances below it. Let $s$ be any constant, $P$ be a predicate, and $u$ be any variable. The natural deduction rule UI can be expressed as follows:\r\n\r\n\\begin{logicproof}{1}\r\n\t\\forall uP(...u...)\\\\\r\n\t...\\\\\r\n\tP(...s...) & UI\r\n\\end{logicproof}\r\n\r\nThis rule, in short, allows us to eliminate the universal quantifier of a universally quantified sentence and substitute any constant we'd like for instances of the variable that it bound. The parenthetical notation in the argument place of the predicate denotes that the expression may be complex and not a simple subject predicate sentence.\\\\\r\n\r\nHere's an example:\r\nEveryone loves Eve. Therefore Adam loves Eve.\r\n\r\n\\begin{logicproof}{1}\r\n\t\\forall x Lxe & Premise \\\\\r\n\tLae & 1, UI\r\n\\end{logicproof}\r\n\r\nIn forming the substitution instance of a universally quantified sentence, you must be careful always to put the same name everywhere for the substituted variable. Substituting $a$ for $x$ in $\\forall xLxx$, we get $Laa$, not $Lxa$.\\\\\r\n\r\nHere's another example: All humans are mortal. Socrates is a human. Thus, Socrates is mortal.\r\n\\begin{logicproof}{1}\r\n\t\\forall x(Hx \\rightarrow Mx) & Premise \\\\\r\n\tHs & Premise \\\\\r\n\tHs \\rightarrow Ms & 1, UI \\\\\r\n\tMs & 2, 3 MP\r\n\\end{logicproof}\r\n\r\nNotice that the universal quantifier in the first premise binds two instances of $x$ in the sentence. So when we use UI at line 3, both must be replaced by our chosen constant.\r\n\r\n\\paragraph{2. Existential Generalization/Introduction EG}\r\nIntuitively, from a closed sentence with a constant, we are licensed to infer the existential generalization of that sentence, where $\\exists xPx$ is an existential generalization of $Pa$. The natural deduction rule EG can be expressed as follows:\r\n\r\n\\begin{logicproof}{1}\r\n\tP(...s...) \\\\\r\n\t...\\\\\r\n\t\\exists x P(...x...) & EG\r\n\\end{logicproof}\r\n\r\nFrom a non-quantified sentence, which contains the constant $s$, we are allowed to take out one or more of the occurrences of $s$ and substitute an existentially bound variable. Example: Rover loves to wag his tail. Therefore, something loves to wag its tail.\r\n\r\n\\begin{logicproof}{1}\r\n\tWr & Premise\\\\\r\n\t\\exists x Wx & 1, EG\r\n\t\\end{logicproof}\r\n\r\nHere's another example: Everyone is happy. Therefore, someone is happy.\r\n\\begin{logicproof}{1}\r\n\t\\forall xHx & Premise\\\\\r\n\tHa & 1, UI\\\\\r\n\t\\exists x Hx & 2, EG\r\n\t\\end{logicproof}\r\n\r\n\r\n\\newpage\r\n\\paragraph{3. Universal Generalization/Introduction UG}\r\nThe intuitive idea for universal introduction is that if a constant, as it occurs in a sentence, is completely arbitrary, you can universally generalize on that constant. This means that you can rewrite the sentence with a variable written in for all occurrences of the arbitrary constant, all bound by a universal quantifier. If I can show that an arbitrary element of set A is also an element of set B, then I am licensed to infer that every element of A is an element of B.\\\\\r\n\r\nThere are a number of ways to state the UG rule such that the restriction that our constant is arbitrary is satisfied. Here's one way:\r\n\\begin{logicproof}{1}\r\n\tP(...s...) & ($s$ must name an arbitrary individual)\\\\\r\n\t...\\\\\r\n\t\\forall x P(...x...) & 1, UG\r\n\\end{logicproof}\r\n\r\nTo say that $s$ names an arbitrary individual puts a restriction on what constants we are allowed to universally generalize upon. In particular, $s$ may not appear in the premises and $s$ may not come from the result of a use of EI. Further, every instance of $s$ in the sentence must be replaced by a variable when we use the rule UG.\\\\\r\n\r\nHere's an example of the mistake above: Everyone loves themself. Therefore, everyone loves Alice.\r\n\\begin{logicproof}{1}\r\n\t\\forall x Lxx & Premise\\\\\r\n\tLaa & 1, UI\\\\\r\n\t\\forall x Lxa & 2, UG (Mistake!)\r\n\t\\end{logicproof}\r\n\r\nHere is an example of a mistake in not generalizing upon an arbitrary individual: Doug is good at logic. Therefore, everyone is good at logic.\r\n\\begin{logicproof}{1}\r\n\tGd & Premise\\\\\r\n\t\\forall x Gx & 1, UG (Mistake!)\r\n\t\\end{logicproof}\r\n\r\nHere's a somewhat longer example: All birds have feathers. Only birds fly. Therefore, only feathered things fly. \r\n\\begin{logicproof}{2}\r\n\t\\forall x (Bx \\rightarrow Fx) & Premise \\\\\r\n\t\\forall x(\\neg Bx \\rightarrow \\neg Lx) & Premise \\\\\r\n\tBa \\rightarrow Fa & 1, UI \\\\\r\n\t\\neg Ba \\rightarrow \\neg La & 2, UI \\\\\r\n\tLa \\rightarrow Ba & 4, Contra \\\\\r\n\tLa \\rightarrow Fa & 3, 5 HS \\\\\r\n\t\\neg Fa \\rightarrow \\neg La & 6, Contra \\\\\r\n\t\\forall x(\\neg Fx \\rightarrow \\neg Lx) & 7, UG\r\n\t\\end{logicproof}\r\n\t\r\nNotice that the constant $a$ in the proof above does not appear in the premises or as the result of an existential instantiation. So $a$ names an arbitrary individual, satisfying the restriction on on our use of UG at line 8.\r\n\r\n\\newpage\r\n\\paragraph{4. Existential Instantiation/Elimination EI}\r\nThe following argument is intuitively valid: All lions are cats. Some lions roar. Therefore, some cats roar.\r\n\\begin{logicproof}{1}\r\n\t\\forall x(Lx \\rightarrow Cx) & Premise \\\\\r\n\t\\exists x (Lx \\land Rx) & Premise \\\\\r\n\t\\exists x (Cx \\land Rx) & Conclusion\r\n\t\\end{logicproof}\r\n\t\r\nWe have no rule yet for exploiting the existential premise. Our reasoning ought to go something like this: Suppose Simba is a lion that roars. Since all lions are cats, Simba must be a cat that roars. So there exists a cat that roars.\\\\\r\n\r\nThere are a couple of ways to implement the EI rule. In my informal reasoning above, I asked the reader to suppose that some individual named Simba was a lion that roars. Importantly, Simba may, or may not, exist. So any conclusions we draw from our reasoning, cannot include conclusions about Simba. So we might implement our EI rule as a sub-derivation rule, much like \\textit{conditional proof} and \\textit{indirect proof}. (The boxes in the proofs below surround a subproof, much like I do with a vertical bar when I hand write proofs.)\r\n\r\n\\begin{logicproof}{2}\r\n\t\\exists x P(...x...) \\\\\r\n\t\\begin{subproof}\r\n\t\tP(...s...) & Assumption for EI \\\\\r\n\t\t... &\\\\\r\n\t\tp & $p$ is any sentence that does not mention $s$\r\n\t\t\\end{subproof}\r\n\t\tp & 1, 2-4 EI\r\n\t\\end{logicproof}\r\n\t\t\r\nHere's our initial cat argument example:\r\n\t\t\r\n\\begin{logicproof}{2}\r\n\t\\forall x(Lx \\rightarrow Cx) & Premise \\\\\r\n\t\\exists x (Lx \\land Rx) & Premise \\\\\r\n\t\\begin{subproof}\r\n\t\tLs \\land Rs & Assumption for EI\\\\\r\n\t\tLs & 3, Simp\\\\\r\n\t\tRs & 3, Simp\\\\\r\n\t\tLs \\rightarrow Cs & 1, UI\\\\\r\n\t\tCs & 4, 6 MP\\\\\r\n\t\tCs \\land Rs & 5, 7 Conj\\\\\r\n\t\t\\exists x (Cx \\land Rx) & 8, EG (Notice $s$ does not appear here)\r\n\t\t\\end{subproof}\r\n\t\t\\exists x (Cx \\land Rx) & 2, 3-9 EI \r\n\t\\end{logicproof}\r\n\r\nAn alternate way to schematize our EI rule is to place a restriction on what constant we're allowed to substitute for variables bound by the existential quantifier we're removing. In particular, we must pick a new constant, one that does not appear earlier in our proof. \r\n\r\n\\begin{logicproof}{1}\r\n\t\\exists x P(...x...)\\\\\r\n\t...\\\\\r\n\tP(...c...) & 1, EI ($c$ must be a new constant, not appearing earlier in the proof)\r\n\\end{logicproof}\r\n\r\nThe result of either version of the rule is the same sort of restriction on how we may use the EI.\r\n\r\n\\newpage\r\n\\paragraph{5. Quantifier Negation QN and Quantifier Equivalence QE}\r\nIn addition to the rules allowing us to introduce or eliminate the two quantifiers, we have some rules allowing us to translate from one quantifier to the other and visa versa as well as some natural equivalences between quantified statements.\r\n\r\nHere are some QN rules. Let $W$ be some well formed formula. I left out the variables for readability.\r\n\r\n\\begin{enumerate}\r\n\t\\item $\\forall W \\equiv \\neg \\exists \\neg W$\r\n\t\\item $\\exists W \\equiv \\neg \\forall \\neg W$\r\n\t\\item $\\neg \\forall W \\equiv \\exists \\neg W$\r\n\t\\item $\\neg \\exists W \\equiv \\forall \\neg W$\r\n\\end{enumerate}\r\n\r\nHere are some QEs or quantifier equivalences.\r\n\r\n\\begin{enumerate}\r\n\t\\item $\\forall x \\forall y W \\equiv \\forall y \\forall x W$\r\n\t\\item $\\exists x \\exists y W \\equiv \\exists y \\exists x W$\r\n\t\\item $\\forall (Px \\land Qx) \\equiv \\forall x Px \\land \\forall y Qy$\r\n\t\\item $\\exists (Px \\lor Qx) \\equiv \\exists x Px \\lor \\exists y Qy$\r\n\t\\item $\\forall x Wx \\equiv \\forall y W(x/y)$ Where $(x/y)$ means replace each instance of $x$ with $y$\r\n\t\\item $\\exists x Wx \\equiv \\exists y W(x/y)$ Where $(x/y)$ means replace each instance of $x$ with $y$\r\n\\end{enumerate}\r\n\r\n\r\n\\paragraph{6. Multiple Quantification}\r\nTo represent the sentence, \\textit{Someone gave a bracelet to Alice} we need to associate quantifier phrases with two of the noun phrase positions in the predicative context: $x$ gave $y$ to $z$ ($Gxyz$). There's no special problem about this; we simply prefix both quantifiers, using the variables to link each quantifier with the appropriate noun phrase: $\\exists x \\exists y (Gxya \\land Px \\land By)$, where $Px$ means \"$x$ is a person\" and $By$ means \"$y$ is a bracelet.\"\\\\\r\n\r\nAnother example. \\textit{Any elephant is larger than every person}: $\\forall x \\forall y ((Ex \\land Py) \\rightarrow Lxy)$\r\n\r\n\\end{document}", "meta": {"hexsha": "67940a15033e3d2b3847b8f0b9b5c7575180a93d", "size": 9773, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/CS251/QuantifierRules.tex", "max_stars_repo_name": "DavidJLu/CCUT", "max_stars_repo_head_hexsha": "755cdeaa36f4eac817d09efe29550843fa5a4fdc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-06-04T16:11:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-25T21:59:58.000Z", "max_issues_repo_path": "docs/CS251/QuantifierRules.tex", "max_issues_repo_name": "DavidJLu/CCUT", "max_issues_repo_head_hexsha": "755cdeaa36f4eac817d09efe29550843fa5a4fdc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/CS251/QuantifierRules.tex", "max_forks_repo_name": "DavidJLu/CCUT", "max_forks_repo_head_hexsha": "755cdeaa36f4eac817d09efe29550843fa5a4fdc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-02-21T21:22:55.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-21T21:22:55.000Z", "avg_line_length": 48.865, "max_line_length": 541, "alphanum_fraction": 0.7140079812, "num_tokens": 2707, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4460974058220107}}
{"text": "\\documentclass{article}\n\n\\usepackage{ottalt}\n\\usepackage{mathpartir}\n\\usepackage{supertabular}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\usepackage{color}\n\n\n%% Show admissible premises in rules\n%% This should be false in main body of text and true in the appendix.\n\\newif\\ifadmissible\n\\newcommand\\suppress[1]{\\ifadmissible{#1}\\else{}\\fi}\n\\inputott{dqtt-rules}\n\n\\title{System Specification}\n\n\\admissiblefalse\n\\begin{document}\n\\maketitle\n\nThis document is created directly from the definitions in the file\n{\\texttt{dqtt.ott}}, with minor modifications listed below.\n\nIt is intended to specify, in a readable form, the syntactic type soundness\nproof.\n\nNote: there is one change here from the syntax shown in the paper. We replace\nthe pattern matching elimination form for $\\Sigma$ types with a slightly more\ngeneral, but less familiar, form.\n\nThe reason for this change is that the Ott and LNgen tools limit language\nspecifications to single binding only. This prevents us from the usual\ndefinition of the pattern matching elimination form for\n$\\Sigma$-types. Instead, we use an elimination form called ``spread'' of the\nform\n\\[\n \\ottkw{spread}\\,  \\ottnt{a} \\, \\ottkw{to}\\,  \\ottmv{x} \\, \\ottkw{in}\\,  \\ottnt{b}\n\\]\nThis syntactic form binds the variable $x$ (corresponding to the first\ncomponent of the product) in the body $b$. The body $b$ must itself be a\nfunction, where the argument is the second component of the tuple.\n\nIn other words, we can encode an elimination of an argument $a$\nof type $ \\Sigma  \\ottmv{x} \\!\\!:^ \\ottnt{q} \\!\\! \\ottnt{A} . \\ottnt{B} $, that uses\nthe usual pattern matching syntax\n\\[ \n     \\ottkw{let}\\, (\\ottmv{x},\\ottmv{y}) \\,=\\, \\ottnt{a} \\ \\ottkw{in}\\  \\ottnt{b} \n\\] \n\nby using the term\n\\[\n   \\ottkw{spread}\\,  \\ottnt{a} \\, \\ottkw{to}\\,  \\ottmv{x} \\, \\ottkw{in}\\,  \\lambda \\ottmv{y} \\!:^ \\ottnt{q} \\! \\ottnt{A} . \\ottnt{b}\n\\]\n\n\\section{Grammar}\n\n\\ottgrammartabular{\n\\ottusage\\ottinterrule\n\\otttm\\ottinterrule\n\\ottcontext\\ottinterrule\n\\ottD\\ottafterlastrule\n}\n\n\n\\section{Step relation}\n\\ottdefnsJOp{} \n\\section{Typing relation}\n\nAnother issue with $\\Sigma$ types is that Ott cannot express the complete\ntyping rule for $\\ottkw{spread}$.  Therefore we need to modify the generate\nCoq definition to include the appropriate substitution. This document includes the \ncorresponding change in the typeset rule \\textsc{T-Spread}.\n\n\\newcommand{\\ottdruleTXXSpreadAlt}[1]{\\ottdrule[#1]{%\n\\ottpremise{\\ottnt{A}  \\ottsym{=}   \\Sigma  \\ottmv{x} \\!\\!:^ \\ottnt{q} \\!\\! \\ottnt{A_{{\\mathrm{1}}}} . \\ottnt{A_{{\\mathrm{2}}}} }%\n\\ottpremise{ \\Delta ; \\Gamma_{{\\mathrm{1}}}  \\vdash \\ottnt{a} : \\ottnt{A} }%\n\\ottpremise{  \\Delta ,   \\ottmv{x} \\!\\!:\\!\\! \\ottnt{A_{{\\mathrm{1}}}}   ;  \\Gamma_{{\\mathrm{2}}} ,   \\ottmv{x} \\!\\!:^{ \\ottnt{q} }\\!\\! \\ottnt{A_{{\\mathrm{1}}}}    \\vdash \\ottnt{b} :  \\Pi  \\ottmv{y} \\!:^ \\ottsym{1} \\! \\ottnt{A_{{\\mathrm{2}}}} . \\ottnt{B} \\ottsym{\\{}  (\\ottmv{x},\\ottmv{y})  \\ottsym{/}  \\ottmv{z}  \\ottsym{\\}} }%\n\\ottpremise{  \\Delta ,   \\ottmv{z} \\!\\!:\\!\\! \\ottnt{A}   ;  \\Gamma_{{\\mathrm{3}}} ,   \\ottmv{z} \\!\\!:^{ \\ottnt{r} }\\!\\! \\ottnt{A}    \\vdash \\ottnt{B} : \\ottkw{type} }%\n}{\n \\Delta ; \\Gamma_{{\\mathrm{1}}}  \\ottsym{+}  \\Gamma_{{\\mathrm{2}}}  \\vdash  \\ottkw{spread}\\,  \\ottnt{a} \\, \\ottkw{to}\\,  \\ottmv{x} \\, \\ottkw{in}\\,  \\ottnt{b}  : \\ottnt{B}  \\ottsym{\\{}  \\ottnt{a}  \\ottsym{/}  \\ottmv{z}  \\ottsym{\\}} }{%\n{\\ottdrulename{T\\_Spread}}{}%\n}}\n\n\n\\begin{ottdefnblock}[#1]{$ \\Delta ; \\Gamma  \\vdash \\ottnt{a} : \\ottnt{A} $}{\\ottcom{Typing}}\n\\ottusedrule{\\ottdruleTXXsub{}}\n\\ottusedrule{\\ottdruleTXXtype{}}\n\\ottusedrule{\\ottdruleTXXvar{}}\n\\ottusedrule{\\ottdruleTXXweak{}}\n\\ottusedrule{\\ottdruleTXXdef{}}\n\\ottusedrule{\\ottdruleTXXweakXXdef{}}\n\\ottusedrule{\\ottdruleTXXpi{}}\n\\ottusedrule{\\ottdruleTXXlam{}}\n\\ottusedrule{\\ottdruleTXXapp{}}\n\\ottusedrule{\\ottdruleTXXconv{}}\n\\ottusedrule{\\ottdruleTXXunit{}}\n\\ottusedrule{\\ottdruleTXXUnit{}}\n\\ottusedrule{\\ottdruleTXXUnitE{}}\n\\ottusedrule{\\ottdruleTXXBox{}}\n\\ottusedrule{\\ottdruleTXXbox{}}\n\\ottusedrule{\\ottdruleTXXletbox{}}\n\\ottusedrule{\\ottdruleTXXsum{}}\n\\ottusedrule{\\ottdruleTXXinjOne{}}\n\\ottusedrule{\\ottdruleTXXinjTwo{}}\n\\ottusedrule{\\ottdruleTXXcase{}}\n\\ottusedrule{\\ottdruleTXXSigma{}}\n\\ottusedrule{\\ottdruleTXXTensor{}}\n\\ottusedrule{\\ottdruleTXXSpreadAlt{}}\n\\ottusedrule{\\ottdruleTXXWith{}}\n\\ottusedrule{\\ottdruleTXXPair{}}\n\\ottusedrule{\\ottdruleTXXPrjOne{}}\n\\ottusedrule{\\ottdruleTXXPrjTwo{}}\n\\end{ottdefnblock}\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "3036b8e7ead8f1b422dad641835b2b3caeef0902", "size": 4423, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GraD/src-def/spec.tex", "max_stars_repo_name": "sweirich/graded-haskell", "max_stars_repo_head_hexsha": "ed9628f385a7c62515b65677702017c97a3935d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2020-10-03T09:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T22:55:34.000Z", "max_issues_repo_path": "GraD/src-def/spec.tex", "max_issues_repo_name": "sweirich/graded-haskell", "max_issues_repo_head_hexsha": "ed9628f385a7c62515b65677702017c97a3935d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "GraD/src-def/spec.tex", "max_forks_repo_name": "sweirich/graded-haskell", "max_forks_repo_head_hexsha": "ed9628f385a7c62515b65677702017c97a3935d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9593495935, "max_line_length": 327, "alphanum_fraction": 0.6911598463, "num_tokens": 1654, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.446097398752388}}
{"text": "\\chapter{A Mathematics Primer for Aspiring Logicians}\n\n\\emph{In block 2 of this year, you will take ``Wiskunde voor KI,'' which is a proper mathematics course. That course covers the material of the following two chapters (and much more) in way more detail. The purpose of the present chapters (and corresponding section of the course) is to bring you up to speed so that we can study logic.}\n\n\\section{Logic and Mathematics}\n\n\\begin{enumerate}[{\\thesection}.1]\n\n\t\\item As we said in the introduction, modern logic is a highly mathematical discipline. So, in order to develop modern logical theory, we require a certain amount of mathematics. This chapter covers the basics of mathematical language and methodology. The next chapter covers the mathematical theory we need.\n\t\n\t\\item As you've probably noticed already, university-level mathematics looks and feels very different from what you did in high-school and before. Academic mathematics has its very own language and methodology. We call the former ``mathemateze'' and the latter ``mathodology.'' \n\t\t\n\t\\item A word on the relationship between logic and mathematics. As you'll see in this chapter, there's a lot of logic in mathodology. In fact, the foundations of modern mathematics is typically taken to be first-order logic, more specifically set-theory formulated in first-order logic. Yet, we make use of mathematics to study first-order logic. There is an obvious kind of circularity to this: we use logic to study logic. But  we typically think this circularity is harmless. To see why, it's important to appreciate the distinction between object and meta-language. What we're doing is to \\emph{use} mathematics as our meta-language to talk \\emph{about} logic as our object language. This is not much weirder than studying English grammar in English, Dutch grammar in Dutch, and so on. Surely, we can do that. Just think of your elementary school grammar lessons. \n\t\t\n\t\\end{enumerate}\n\n\\section{Mathemateze}\n\n\\begin{enumerate}[{\\thesection}.1]\n\n\t\t\\item As you know from from high-school, mathematical language is full of special symbols, which you will have to be able to read in order to understand what's being said in the first place. For this reason, we'll first cover some notation.\n\t\t\n\t\t\\item Mathematicians frequently use Greek letters, and you should be familiar with their names/pronunciations. Here are the most commonly used letters and their names, capitals are included some cases but not in others:\n\t\n\t\t\\begin{longtable}{c | c}\n\t\t\tLetter & Name\\\\\\hline\n\t\t\t$\\alpha$ & alpha \\\\\n\t\t\t$\\beta$ & beta\\\\\n\t\t\t$\\Gamma,\\gamma$ & gamma\\\\\n\t\t\t$\\Delta,\\delta$ & delta\\\\\n\t\t\t$\\epsilon$ & epsilon\\\\\n\t\t\t$\\zeta$ & zeta\\\\\n\t\t\t$\\eta$ & eta\\\\\n\t\t\t$\\Theta,\\theta$ & theta\\\\\n\t\t\t$\\iota$ & iota\\\\\n\t\t\t$\\kappa$ & kappa\\\\\n\t\t\t$\\Lambda,\\lambda$ & lambda\\\\\n\t\t\t$\\mu$ & mu\\\\\n\t\t\t$\\nu$ & nu\\\\\n\t\t\t$\\Xi,\\xi$ & xi\\\\\n\t\t\t$\\Pi,\\pi$ & pi\\\\\n\t\t\t$\\rho$ & rho\\\\\n\t\t\t$\\Sigma,\\sigma$&sigma\\\\\n\t\t\t$\\tau$ & tau\\\\\n\t\t\t$\\Phi,\\phi,\\varphi$ & phi\\\\\n\t\t\t$\\chi$ & chi\\\\\n\t\t\t$\\Psi,\\psi$ & psi\\\\\n\t\t\t$\\Omega,\\omega$ & omega\n\t\t\t\\end{longtable}\n\t\t\t\n\t\t\\item Think of a typical mathematical claim like $(a+b)^2=a^2+2ab+b^2$. The symbols $a$ and $b$ here stand for arbitrary numbers, they are \\emph{variables} for numbers. Generally speaking, we use variables to refer to arbitrary but fixed objects of some mathematical category, like numbers. The variables are said to \\emph{range} over the objects of the category. In our example, $a$ and $b$ range over numbers. A variable can assume any value from among the objects it ranges over. For example, we can have that $a=0, a=1, a=\\pi$, and so on. Absent further information, we don't know what the value of a given variable is. So, all we know, for example, if $n$ ranges over the natural numbers is what follows from $n$ being a natural number: that $0\\leq n$, that $n\\leq n+1$, and so on.\\footnote{There is quite some dispute about whether zero counts as a natural number or not. In the context of this course, unless stated otherwise, we will always assume that it is.} But we don't know, for example, whether $n$ is even, odd, prime, or the like. That $n$ has such properties would need to be \\emph{inferred} from extra information. For example, if it's given that $n$ is a prime number bigger than two, then we can infer that $n$ is odd.\n\t\t\n\t\t\\item Strictly speaking, you always need to \\emph{declare} your variables: you need to say which kind of object they range over. This is typically done using the word ``let.'' You would, for example, say: let $n$ be a natural number, let $f$ be a function, or the like. But there are many different phrases that can be used to the same effect, for example:\n\t\t\t\\begin{itemize} \n\t\t\t\n\t\t\t\t\\item Let $n$ be a natural number. \n\t\t\t\t\t\t\t\n\t\t\t\t\\item For $n$ a natural number, \\dots.\n\t\t\t\t\n\t\t\t\t\\item Consider a natural number $n$.\n\t\t\t\t\n\t\t\t\t\\item Suppose that $n$ is a natural number. \n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\tThere is not much more than a notational difference between these.\n\t\t\n\t\t\n\t\t\\item Always having to declare one's variables quickly gets tedious. This is why we have conventions concerning standard variables for important categories of objects. Some standard variables used in mathematics and their associated categories are:\n\t\t\n\t\t\\begin{longtable}{l | l}\n\t\t\tObject & Variable\\\\\\hline\n\t\t\t\n\t\t\tunspecified & $x,y,z,\\mathellipsis$\\\\\n\t\t\t\n\t\t\t\t\t& sometimes: $a,b,c, \\mathellipsis$\\\\\n\t\t\t\n\t\t\tnatural numbers & $n,m,l,\\mathellipsis$\\\\\n\t\t\t\n\t\t\tindices & $i,j,\\mathellipsis$ \\\\\n\t\t\t\n\t\t\tsets of indices & $I,J,\\mathellipsis$\\\\\n\t\t\t\n\t\t\tfunctions & $f,g,h,\\mathellipsis$\\\\\n\t\t\t\n\t\t\t\t\t& also: $\\lambda, \\sigma,\\tau,\\mathellipsis$\\\\\n\t\t\t\n\t\t\tsets & $X,Y,Z,\\mathellipsis$ \\\\\n\t\t\t\n\t\t\tconditions & $\\Phi,\\Psi,\\mathellipsis$\\\\\n\t\t\t\n\t\t\tformulas\t & $\\phi,\\psi,\\theta,\\mathellipsis$\\\\\n\t\t\t\n\t\t\t\t\t& also: $A,B,C, \\mathellipsis$\\\\\n\t\t\t\t\t\n\t\t\tpropositions & $p,q,r, \\mathellipsis$\\\\\n\t\t\t\t\t& also: $P,Q,R,\\mathellipsis$\n\t\t\t\n\t\t\t\\end{longtable}\n\t\t\t\n\tNote the pattern here. The first variable for a category is typically chosen  mnemonically---$n$umber, $f$unction, $i$ndex, $\\phi$ormula, \\dots---and the following continue in alphabetical (or inverse alphabetical) order. Also, ``higher-order'' objects, like sets or conditions, typically get capital variables. \n\t\n\t\t\\item Variables allow us to make general claims about objects of a category, while still making concrete statements.\\footnote{It's important not to confuse variables with collections, sets, or the like. A variable always stands for one, and only one object.}  For example, if we let $n$ and $m$ be natural numbers, the statement $n+m=m+n$ says that for every possible value of $n$ and $m$, i.e. all natural numbers, adding the one to the other is the same as adding the other to the one. We can make this perfectly explicit by saying: for all natural numbers $n$ and $m$, we have that $n+m=m+n$. Without variables, it's impossible to make such a claim in a finite expression, we'd need to repeat our claim for each pair of numbers $n$ and $m$:\n\t\t\n\t\t\\begin{itemize}\n\t\t\n\t\t\t\\item $0+0=0+0$\n\t\t\t\n\t\t\t\\item $0+1=1+0$\n\t\t\t\n\t\t\t\\item $1+0=0+1$\n\t\t\t\n\t\t\t\\item \\dots\n\t\t\t\n\t\t\\end{itemize}\nClearly, this is not feasible.\n\n  \\item Variables also allow us to talk about numbers where we don't know precisely what they are.\n\tTake the first prime number bigger than $436\\cdot 10^{99}$.\n\tBy Euclid's theorem, we know that this number exists: there are infinitely many prime numbers and there are only finitely many numbers smaller than $436\\cdot 10^{99}$, so there needs to be a first prime number after $436\\cdot 10^{99}$.\n\tWe can refer to this number using a variable by saying: let $n$ be the first prime number bigger than $436\\cdot 10^{99}$.\n\tIt's difficult to refer to this number explicitly, or to even determine which number it is: the number is very, \\emph{very} large.\n\tAll we know is that the number exists.\n\tAnother way of saying this is: there exists a natural number $n$ such that $n$ is the first prime number after $436\\cdot 10^{99}$.\n\t\n\t\\item Speaking of natural numbers. One important role of natural numbers is in \\emph{counting}. Say you have three apples. Then you can count them: my first apple, my second apple, my third apple. This way of counting is indicated mathematically by using the numbers as \\emph{subscripts} or \\emph{indices}: $a_1$ is the first apple, $a_2$ the second apple, and $a_3$ the third apple. What a mathematician would typically say in such a situation is something like this: suppose we have three apples, $a_1, a_2,$ and $a_3$. \n\t\t\n\t\t\\item Sometimes, we only know that we have finitely many objects, but not how many precisely. The standard way of expressing this mathematically is to say something of the sort: consider $n$-apples, $a_1, \\mathellipsis, a_n$. Here $n$ is used as a variable for a some arbitrary but fixed natural number, just like we discussed above. When we use numbers as indexes for objects in this way, we typically use $i,j,\\mathellipsis$ as variables ranging over these numbers. For example, we would say something like: consider $n$-apples, $a_1, \\mathellipsis, a_n$ and let $a_i$ be one of these apples, for $1\\leq i\\leq n$. Here $i$ ranges over the numbers from $1$ to $n$ used as indices, it is an \\emph{index variable}. Note that for each $i$ between 1 and $n$, $a_i$ is a variable that ranges over apples.\n\t\t\n  \\item As we said, a variable always stands for an arbitrary but fixed object of some category.\n\tBut note that the information which kind of object a variable stands for is only valid in a given context with a preceding variable declaration.\n\tFor example, if we let $n$ stand for the first prime after  $436\\cdot 10^{99}$,\n\tthen $n$ refers to this number \\emph{until} the context of our assumption (current proof, sub-argument, etc.) is closed and we move to the next context.\n\tOnly when we move to a different context---\n\ta new proof, for example---\n\twe can re-use $n$ as a variable.\n\tIf we use $n$ again in the same context, it still refers to the first prime after\n\t$436\\cdot 10^{99}$.\n\tSo, for example, if you were to talk about finitely many apples $a_{1}, \\mathellipsis, a_{n}$ in the same context where you've earlier assumed that $n$ is the first prime after\n\t$436\\cdot 10^{99}$,\n\tthen you would in fact be talking about that many apples (rather than some arbitrary finite number as per 2.2.9).\n\tSo: watch out that you're always clear on your variable declarations and what you can and cannot assume about the values of your variables.\n\t\t\n\t\t\\item When we want talk about a \\emph{distinguished} mathematical object, we typically use a \\emph{constant} to refer to it. The numerals $0$, $1$, $2$, \\dots, for example, stand for the first, second, and third natural number (and so forth). Note that there are also constants for functions, such as $+$ for addition, $\\cdot$ for multiplication, etc.. There are also constants for properties and relations, like $\\leq$ for the smaller-than (or equal to) relation. What distinguishes constants from variables is that they always denote the same object in every context. The numeral $0$ always denotes the first natural number, $+$ is always addition, and so on. In contrast, $n$ can assume any value from the natural numbers, $f$ can be any functions, etc. \n\t\t\n\t\t\\item Sometimes, we introduce \\emph{temporary} constants for notational convenience. Suppose that we've just established that there exists a natural number $n$ such that $n$ is the first prime number after $436\\cdot 10^{99}$. This number is not important enough to justify introducing a new constant for it, but it might be useful to free up the variable $n$ again for later use---$n$ is such a convenient variable for natural numbers. So we might call the number $n$, whose existence we've just established, $a$ and continue to use $n$ as we please. Conceptually, what's happening here is nothing but a new variable declaration, but it's fruitful to think about it as introducing a ``temporary name'' for an object. \n\t\t\n\t\t\\item Mathematical writing is often very concise, especially hand-written mathematics. One standard logico-mathematical abbreviation you've already encountered is the phrase ``iff,'' which stands for \\emph{if and only if}. Think, for example, of our definition of validity as truth preservation in the introduction. There we said that an inference is valid iff in every possible situation where the premises are true, the conclusion is true as well. To say that one thing is the case if and only if another thing is the case is to say that the two are equivalent: if the one thing is the case, so is the other and vice versa. \n\n\t\\item If two things are equivalent---the one is the case iff the other is---then the two things can be exchanged for each other in practically all mathematical contexts. For example, according to our account of validity given above, we can freely go back and forth between saying that an inference is valid and saying that in every possible situation where the premises are true, the conclusion is true as well. The two phrases (practically) mean the same thing. This is why ``iff'' is often used in definitions (see below). \n\t\n\t\\item Here are some other abbreviations often found in mathematical writing together with their associated meaning:\n\t\n\t\t\\begin{longtable}{c | l}\n\t\t\tAbbreviation & Meaning\\\\\\hline\n\t\t\t\n\t\t\ti.e. & id est, that is\\\\\n\t\t\te.g. & exempli gratia, for example\\\\\n\t\t\tviz. & videlicet, namely\\\\\n\t\t\ts.t. & such that\\\\\n\t\t\tw.r.t. & with respect to\\\\\n\t\t\tw.t.s & want to show\\\\\n\t\t\tq.e.d. & quod erat demonstrandum\\\\\n\t\t\t%w.l.o.g. & without loss of generality$^\\ast$\\\\\n\t\t\tfr & for (especially hand-written)\\\\\n\t\t\tdf. or dfn. & definition (especially hand-written)\\\\\n\t\t\tthm. & theorem (especially hand-written)\\\\\n\t\t\t\n\t\t\t\\end{longtable}\n\t\t\t\t\n\t\t\\item We now turn from notation to meaning. You might have noticed that mathematical language is \\emph{very} precise, to the extend that it can seem pedantic. When mathematicians use a word, especially a technical concept, they usually mean something \\emph{very} specific by it---one and only one thing. Mathematical language is not as vague and flexible as ordinary language is. In order to properly understand mathemateze, you have to be perfectly clear on the meanings of the terms involved. These meanings are typically given by \\emph{definitions}. The most basic forms of mathematical definitions are definitions of objects and definitions of properties and relations.\n\t\t\n\t\t\\item A mathematical object is defined by giving a list of properties such that we can show that there is one and only one object that satisfies these properties. For example, we can define the principal square root of 2, typically denoted $\\sqrt{2}$, as the positive real number $x$ such that $x\\cdot x=2$. Note that in order for such a definition to give us a unique object, we need to show that: (i) there exists such an object that satisfies the property and (ii) that only one object satisfies the properties. For example, we can't define $\\sqrt{2}$ as the natural number $n$ such that $n\\cdot n=2$---such a natural number doesn't exist. And we can't define $\\sqrt{2}$ as the real number $x$ such that $x\\cdot x=2$---there is more than one such number, viz. $\\sqrt{2}$ and $-\\sqrt{2}$.\n\t\t\n\t\t\\item Note that there can be more than one valid definition of a given mathematical object. For example, the number $\\pi$ can be defined using the following integral definition: \\[\\pi=\\int_{-1}^{1}\\frac{1}{\\sqrt{1-x^2}}dx\\] But it can also be defined as the smallest positive real $x$ which satisfies the equation $\\sin(x)=0$. It's a mathematical fact that these two definitions characterize the same object. In mathematical practice, it's often useful to know alternative definitions of an object.\t\t\n\t\t\\item A mathematical property is defined by giving the precise conditions under which an object has the property. For example, a natural number $n$ is said to be \\emph{prime} iff (i) $1<n$ and (ii) there are no natural numbers $k,l<n$ such that $n=k\\cdot l$. Note that the property being defined is typically \\emph{italicized}. This is considered good form in typed-out mathematics. In hand-written mathematics, you typically \\underline{underline} the concept being defined.\n\t\t\n\t\t\\item Related to definitions are the central concepts of \\emph{necessary} and \\emph{sufficient} conditions:\n\t\t\n\t\t\t\\begin{enumerate}[\\thesection.{20}.a]\n\t\t\n\t\t\t\\item  A condition is said to be \\emph{necessary} for something to obtain just in case if the condition wouldn't obtain, then the thing wouldn't be the case. For example, being non-negative\\footnote{You might wonder: why didn't he say \\emph{positive} natural number? The reason is that, in mathematics, it's standard to reserve positive for numbers (strictly) bigger than zero. So, zero isn't positive. But then being positive can't be a necessary condition for being a natural number: zero is not positive but a natural number. Zero is, however, not negative, for a negative number is one that is smaller than zero and zero isn't smaller than itself.} is a necessary condition for being a natural number---if a number is negative, it can't be a natural number. But being non-negative is not a necessary condition for being an integer: the whole negative numbers are all integers but, well, negative.\n\t\t\t\t\t\t\n\t\t\t\\item A condition is said to be \\emph{sufficient} for something iff the thing is the case, whenever the condition obtains. For example, being even is a sufficient condition for being an integer: if something's even, it's an integer. But being even is not a necessary condition for being an integer: of course, there are non-even integers---the odd ones.\t\t\n\t\t\t\n\t\t\t\\end{enumerate}\n\t\t\n\tTo say that a condition is necessary, we use the locution `only if:' something's a natural number only if it is non-negative. And to say that a condition is sufficient, we use the locution `if:' if a number is even, then it's an integer. Hence the origin of the phrase `if and only if.'\n\t\t\n\t\\item The definition of a property always gives us a list of necessary and jointly sufficient conditions for something to have the property. Think of the conditions (i) and (ii) from our definition of being prime. They are both \\emph{necessary} in the sense that an object that lacks one of these two properties is not prime: $1$, for example, is not prime since it violates condition (i); $4$ isn't prime because it violates condition (ii)---clearly $2<4$ and $2\\cdot 2=4$, so just set $k=l=2$. At the same time, (i) and (ii) together are \\emph{sufficient} for a number to be prime. For example, to see that $3$ is prime, first note that $1<3$ so condition (i) is satisfied. Second, there are just three numbers smaller than 3, viz. $0,1,$ and $2$. And $0\\cdot 1=0\\cdot 2= 0, 1\\cdot 1=1, 1\\cdot 2=2, 2\\cdot 2=4$. So there are no $k,l<3$ such that $k\\cdot l=3$, meaning condition (ii) is satisfied. So, $3$ is prime.\n\t\n\t\t\\item But note that not \\emph{any} list of necessary and sufficient conditions constitute a proper definition. For a definition to be successful, we demand that the defined concept doesn't occur among the conditions being used to define it. Why? Well, a definition that violates this constraint wouldn't be very useful. Suppose we would define an even number as one that is the product of an even number with some other number. It's true that a number is even iff the number is the product of an even number with some other number. So the conditions are necessary and sufficient for a number to be even. But this is not a particularly useful definition. In order to establish that a number is even, we'd first have to establish that some other numbers are even. And in order to do that, we need to establish that some other numbers are even. And so on, \\emph{ad infinitum}. A definition in which the condition in question is violated is called \\emph{circular}.\n\t\t\n\t\t\\item In contrast to the definition of an object, however, the definition of a property or relation can be \\emph{empty}, i.e. no object has the property or stands in the relation to anything. For example, we can define the property of \\emph{being the biggest natural number} as follows: we say that a number $n$ is the biggest natural number iff for all natural numbers $m$, $m\\leq n$. It's clear that there is no biggest natural number, so no object has the property. But the \\emph{property} exists---it can be defined like we just did.\n\t\t\t\t\n\t\t\\item The way of defining a property generalizes to \\emph{relations}, like the relation $\\leq$ on the natural numbers. For two natural numbers $n,m,$ we say that $n\\leq m$ iff there exists a natural number $k$ such that $n+k=m$. The relation $\\leq$ is called \\emph{binary} because it relates two objects. There are also \\emph{ternary}, \\emph{quaternary}, \\emph{quinary} relations, and so on. More generally, we call a relation $n$-ary iff it relates $n$ objects, where $n$ is a natural number. So a binary relation is a 2-ary relation, a ternary relation is a 3-ary relation, and so on. Here's an example of a definition of a ternary relation: a point (on the plane) $x$ lies \\emph{in between} two points $y$ and $z$ if and only if there is a straight line that connects $y$ and $z$ which goes through $x$.\n\t\t\n\t\t\\item Just like with definitions of objects, there is sometimes more than one definition of a given property or relation. For example, $n\\leq m$ for natural numbers $n$ and $m$ can equivalently be defined by the condition that $\\frac{n}{m}\\leq 1$. It's good to know alternative definitions of important properties and relations.\n\t\t\n\t\t\\item Understanding mathematical definitions is often not easy, it requires patience and effort. Learning mathemateze is like learning a foreign language. Here are two important steps that you can (in fact, should) take in order to properly understand a definition:\n\n\t\t\\begin{description}\n\t\t\n\t\t\t\\item[Examples.] Check some examples, like we did above (this applies to definitions of properties and relations). Is $1$ a prime? (No, condition (i) is violated.) Is $2$ prime? (Yes.) Is $3$ prime? (Yes.) Is $4$ prime? (No, condition (ii) is violated) \\dots Is $\\sqrt{2}$ a prime? (No, the definition only applies to natural numbers). If you know how to program, try to write a script that checks examples. Try to come up with your own examples and counter-examples. For each definition you learn, you should know a list of standard examples and counter-examples.\n\n\t\t\t\\item[Understand the Conditions.] Try to understand why the conditions are formulated the way they are. For example, why did we demand that $\\sqrt{2}$ is the \\emph{positive} real $x$ such that $x\\cdot x=2$? Because there is more than one real with this property. Or, why did we demand that for $n$ to be prime that there are no numbers $k,l<n$ such that $k\\cdot l=n$, rather than the weaker condition that there are no $k,l\\overset{!}{\\leq} n$ such that $k\\cdot l=n$? Well, this definition wouldn't work: no number would be prime! To see this note that for each number $n>1$, $1\\cdot n=n$ and hence there are $m,k\\leq n$ with $n=m\\cdot k$, viz. $m=1$ and $k=n$. Another thing you can do in order to understand the conditions better is to try to give an equivalent formulation, like in the case of $\\pi$ and $\\leq$. \n\t\t\n\t\t\\end{description}\n\t\t\n\t\tBut this is just the beginning. To properly appreciate a definition, you will have to work with it, you will have to prove things with it. This is just like to properly acquire command of a new word, you have to use it in a sentence. \n\t\t\n\t\t\\item There's also a way in which learning mathemateze is \\emph{not} like learning a language, at least not like learning a language in (high)school. When you learn definitions in mathematics, you should not just memorize them, like your vocabs in school-English. It is much, \\emph{much} more important that you \\emph{understand} a mathematical definition rather than that you memorize it. This is what the previous steps are supposed to help you with. And once you've properly understood a definition, it will actually be easy to remember it, or at least to be able to reconstruct it from memory.\n\t\t\n\t\t\\item As you will see once we get more advanced, certain kinds of mathematical objects have a special way of being defined: a set, for example, is defined by specifying its members, a function is defined by saying which output it gives for which input, and so on. These special kinds of definitions can always be traced back to the general kind of definition we characterized above in 2.2.2, but they tell us something about the \\emph{(mathematical) nature} of the objects under consideration. For example, the fact that a set can be defined by specifying its members tells us that there is nothing more to being a set than being a collection of objects (more on sets in the next chapter). Keep an eye out for the way in which an individual object of a certain kind---a set, a function, a language, a model, \\dots---is defined, you will better understand what these objects \\emph{are} (mathematically speaking).\n\t\t\n\t\t\\item Having covered all of this notation, it's important to get clear on its benefits and drawbacks. The primary purpose of most of the features of mathemateze that we've just discussed is \\emph{precision}, they allow us to phrase our claims in such a precise way that we can establish them beyond a reasonable doubt---that we can \\emph{prove} them. We'll cover proving things in the next section, the section on mathodology. But the precision I just mentioned comes at a price: as you can probably agree, a properly formulated mathematical claim can be (very) difficult to properly understand. And so there is also a role for natural language in mathematics: it can make the very precise claims of mathemateze intuitively perspicuous. Just compare the two claims:\n\t\t\n\t\t\\begin{itemize}\n\t\t\n\t\t\t\\item Let $n$ be a natural number. Then, if $n>2$ and there are no natural numbers $k,l<n$ such that $n=k\\cdot l$, then there is no natural number $m$, such that $n=2m$.\n\t\t\t\n\t\t\t\\item Every prime bigger than two is odd.\n\t\t\n\t\t\\end{itemize}\n\t\t\nThe two claims say \\emph{exactly} the same thing. While the first is very precise and, once understood, easily seen to be true, the second is \\emph{far} more intelligible. \n\n\t\\item The previous observation motivates my last recommendation about learning mathemateze: once you've properly understood the formal side of things, try to phrase what you're thinking about in natural language \\emph{without using mathematical symbols}. Once you can do this well, you have truly understood a mathematical concept. In fact, I think this is so important, that I will ask you to do this in exercises. When an exercise is marked $[\\nosym]$, this means that you may not use \\emph{any} mathematical symbols in the answer to this question.\n\t\t\n\t\\end{enumerate}\n\t\t\n\t\\section{Mathodology}\n\n\n\\begin{enumerate}[{\\thesection}.1]\n\t\n\t\\item One of the most important mathematical activities is proving things. A mathematical proof is a rigorous, step-by-step argument which establishes the truth of a mathematical statement. Importantly, in a mathematical proof, every step needs to be justified, nothing should remain vague or unclear. \n\t\n\t\t\\item Mathematicians typically classify true mathematical statements into  different categories, roughly according their role in mathematical inquiry: \n\t\t\n\t\t\\begin{description}\n\t\t\t\t\t\t\t\n\t\t\t\\item[Lemma.] An auxiliary claim, established in order to prove a more important proposition or theorem. Whether something counts as a lemma is thus context-dependent: one mathematician's important result may be another mathematician's lemma.\n\t\t\t\t\t\t\n\t\t\t\\item[Proposition.] A run-of-the-mill, ordinary mathematical fact.\n\t\t\t\n\t\t\t\\item[Theorem.] An important mathematical fact, e.g. because it provides significant insight, has been an open question for long, or the like. Sometimes, the term ``theorem'' is also used generically to refer to any kind of mathematical fact.\n\t\t\t\n\t\t\t\\item[Corollary.] A simple consequence of a previously established lemma, proposition, or theorem. Sometimes a theorem is a mere corollary of a central lemma that has been proven along the way. \n\t\t\t\n\t\t\t\\item[Conjecture.] This one stands out a bit, since it's a claim that has not (yet) been shown to be true but there is strong evidence that it is. \n\t\t\n\t\t\\end{description}\n\t\t\n\t\\item The ideal of a mathematical proof is that of a purely \\emph{axiomatic} proof. An \\emph{axiom} is a basic principle of mathematics, which is assumed to be true. Each category of mathematical objects has its own axioms governing it. Examples of axioms for the natural numbers are: \n\t\\begin{itemize}\n\t\n\t\t\\item $0$ is a natural number\n\t\n\t\t\\item for no natural number $n$, $n+1=0$\n\t\t\n\t\t\\item for all natural numbers $n,m$, if $n+1=m+1$, then $n=m$\n\t\t\n\t\t\\item for all natural numbers $n$, $n+0=n$\n\t\t\n\t\t\\item for all natural numbers $n$, $n+(m+1)=(n+m)+1$\n\t\t\n\t\t\\item \\dots.\n\t\n\t\\end{itemize}\n\tAn axiomatic proof is one whose only assumptions are axioms and definitions and where each step corresponds to a valid inference. Axiomatic proofs are therefore very detailed and proceed in very, very small steps. This makes axiomatic proofs often difficult to read. Just imagine proving from the above axioms that if $n$ is a prime number with $n>2$, then $n+1$ is even. This can be done, but it takes many, \\emph{many} steps and definitions.\n\t\n\t \\item Axiomatic proofs are an epistemic \\emph{ideal}, you almost never find a full axiomatic proof in the literature. The point of most mathematical writing is to convince the reader that a purely axiomatic proof \\emph{exists}. It's left to the interested reader to figure out the details. Of course, whether a given piece of writing convinces you, depends on your background. Mathematical writing for beginners is much more detailed than writing on an advanced level. In this course, you'll get more and more advanced and we'll get, correspondingly, less and less detailed. Our aim in mathematical writing is to achieve what's called \\emph{informal rigor}, that is to ensure that there is an axiomatic argument corresponding to what we say, while retaining readability. For this purpose, mathematicians have developed conventional ways of writing proofs that are supposed to ensure that an underlying axiomatic proof exists if we obey by the conventions.\n\t \n\t \\item An interesting side-remark. The origin of the proof systems mentioned in \\S1 is, in fact, the mathematical study of axiomatic arguments: a derivation in a proof system is a model for a correct axiomatic argument. Here, it's once more important that we heed the distinction between object and meta-language. When we're reasoning mathematically \\emph{about} logic (in the meta language), it's enough to convince the reader that an axiomatic proof of the fact in question exists. But when we're working \\emph{in} the object language, and we're trying to derive a conclusion from some premises, we need to be perfectly detailed and axiomatic. Watch out for which level of detail is required in a given context and err on the side of caution!\n\t \n\t \\item Note that there is a difference between a finished, mathematical proof according to the standards of informal rigor and the notes you make along the way, which help you to discover the proof. This is especially important to keep in mind when you're writing for exams, term papers, or a thesis. You might have encountered this already in high-school in situations when a simple calculation was not deemed an entirely satisfying answer to a problem, but some explanation was required. This is precisely the point here: your calculation are your notes, the actual proof is an argumentative piece of writing. \n\t \n\t \\item Having to rigorously prove a mathematical fact may seem like a daunting task at first. To make things easier for you, I recommend following these steps:  \\emph{figure out what you want to prove}, \\emph{state your claim as clearly as possible}, \\emph{unfold the relevant definitions}, \\emph{remind yourself of relevant facts}, \\emph{devise a proof strategy}, \\emph{write up your proof}, \\emph{proof-read}. Let's go through these steps in turn:\n\n\t \n\t \t\\begin{enumerate}[\\thesection.{7}.1]\n\t\t\n\t\t\t\\item \\emph{Figure out what you want to prove}.\n\t\t\t\t\t\t\t\n\t\t\t\tIn a course like this, you will often be told explicitly what to prove (with the assumption that the claim in question is true). But sometimes, especially in more advanced contexts, you might need to determine \\emph{whether} a claim is true. In such a case, you will try to formulate a \\emph{conjecture}.\n\t\t\t\t\n\t\t\t\t\\vspace{2ex}\n\t\t\t\t\n\t\t\t\t\\emph{Running Example}. Think of some standard prime numbers. You you might think of three, five, seven, maybe 11. So you might form the initial conjecture that every prime number is odd. But wait a moment, we forgot two: two is a prime number and two is odd! So we modify our conjecture to say that every prime number bigger than two is odd. And, in fact, now there's no obvious counterexample anymore. But not being able to find a counterexample doesn't constitute a proof, there might be an even prime number somewhere which is so big, we can't find it by a search. So, we set out to prove the following conjecture: \n\t\t\t\t\n\t\t\t\t\\begin{conjecture}\n\t\t\t\tEvery prime number bigger than two is odd.\n\t\t\t\t\\end{conjecture}\n\t\t\t\t\n\t\t\t\\item \\emph{State your claim as clearly as possible.}\n\t\t\t\t\t\t\t\t\t\n\t\t\tAs we've mentioned above, stating a mathematical claim in proper mathemateze is what makes it precise enough to prove. So, let's write our conjecture in proper mathemateze. Basically, what we want to say is that for any natural number, if that number is a prime and bigger than two, then the number is odd. So, we declare $n$ as a variable for natural numbers and write our conjecture as:\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item Let $n$ be a natural number. If $n>2$ and $n$ is prime, then $n$ is odd.\n\t\t\t\n\t\t\t\\end{itemize} \nNote that if we had declared $n$ as a variable for \\emph{prime} numbers, we could have written:\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item Let $n$ be a prime number. If $n>2$, then $n$ is odd.\n\t\t\t\n\t\t\t\\end{itemize}\nBy declaring $n$ to range over the primes bigger than two, we could even write.\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item Let $n$ be a prime number with $n>2$. Then, $n$ is odd.\n\t\t\t\n\t\t\t\\end{itemize}\nEach of these claims would be proven in a slightly different way, but they say essentially the same thing, they are, in fact, equivalent.\n\nThe underlying phenomenon here is that there's a trade-off between assumptions about our variables and the if-part of our theorem (if there's one). The last rephrasing of our conjecture has no if-part but instead three assumption: $n$ is a natural number, $n$ is prime, and $n>2$. The first phrasing instead, only assumes that $n$ is a natural number and, in turn, has two claims in the if-part. \n\nStrictly speaking, to prove the first claim, we have to prove the if-then claim ``if $n>2$ and $n$ is prime, then $n$ is odd'' using only the assumption that $n$ ranges over the naturals and to prove the third claim, we have to prove that $n$ is odd using the assumption that $n$ is natural, prime, and bigger than two. As we'll see in a few moments, however, the two things are essentially the same, so there is little but notational difference between the phrasings in question.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\\item \\emph{Unfold the relevant definitions.}\n\t\t\t\t\t\t\n\t\t\t\tLook for all the central concepts in your conjecture and assumptions and remind yourself of their definitions. In the case of our conjecture, the central concepts are those of a number being even/odd and those of a number being prime.\n\t\t\t\t\n\t\t\t\tHere are the relevant definitions:\n\t\t\t\t\n\t\t\t\t\\begin{definition}\n\t\t\t\tA natural number $n$ is \\emph{even} iff there exists a natural number $k$ such that $n=2k$. A natural number $n$ is \\emph{odd} iff $n$ is not even.\n\t\t\t\t\\end{definition}\n\t\t\t\t\n\t\t\t\t\\begin{definition}\n\t\t\t\tA natural number $n$ is said to be \\emph{prime} iff $1<n$ and  there are no natural numbers $k,l<n$ such that $n=k\\cdot l$\n\t\t\t\t\\end{definition}\n\t\t\t\t\t\t\t\n\t\t\t\\item \\emph{Remind yourself of relevant facts (lemmas, propositions, theorems,\\dots) you already know}\n\t\t\t\n\t\t\t\tIn mathematical practice, you almost never start ``from scratch.'' You typically make use of lemmas, propositions, and theorems that either you or somebody else proved before. In mathematics, we truly ``stand on the shoulder of giants'' like Euclid, Bernoulli, Euler, and many, many others. At this stage of your proof search, try to figure out if you already know some fact that might help you in proving your conjecture.\n\t\t\t\t\n\t\t\t\tIt turns out that for our present conjecture, we don't really need any additional lemmas to prove it, we can directly prove it from the definitions. But we don't know that yet and we remember the following facts,  which we record just in case:\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\t\tIf $n$ is a natural number, then $n$ is even or $n$ is odd (but never both).\n\t\t\t\t\\end{proposition}\n\t\t\t\t\\begin{proposition}\n\t\t\t\tLet $n$ be a natural number. If $n$ is an even number, then $n+1$ is odd. And if $n$ is odd, then $n+1$ is even.\n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\tWe assume that this you've proven elsewhere (slides, book, homework, etc.) and we write it down here just to be sure, maybe we need it later. It can always happen that while we're searching for a proof strategy, it becomes clear that we can use some other relevant facts, but it's always a good idea to look at the clearly relevant facts first, since they might help you devise a proof strategy in the first place.\n\t\t\t\t\n\t\t\t\t \n\t\t\t\t \\emph{Nota bene}: When we ask you to prove a result as homework, in an exam, or elsewhere for credit, of course, you can't just refer to somebody else's proof of the result somewhere in the literature. However, you can make use of results that are clearly established in the lecture, the notes, or the like. Please make sure that you reference where to find the proof clearly, using the slide number or chapter.section.number. \n\t\t\t\t \n\t\t\t\t \t\t\t\n\t\t\t\\item \\emph{Devise a proof strategy.}\n\t\t\t\n\t\t\t\tNow things get serious, you actually need to start reasoning. What we will do at this point is to try to see \\emph{why} the result holds and to derive a proof strategy from that. In our example conjecture, finding a proof strategy is relatively easy. We simply note that if $n>2$ is a prime number, then $n$ can't be even. Because if $n$ were even, by definition, there would be a $k$ such that $2k=n$, which contradicts the assumption that $n$ is prime. And if $n$ isn't even, then, by definition, $n$ is odd. This isn't our final proof yet, we still have some cleaning up to do. But we have a pretty good idea how to proceed.\n\t\t\t\t\n\t\t\t\t\\vspace{1ex}\n\t\t\t\t\n\t\t\t\tNote that often it will not be so easy to find a proof strategy. What you will typically do, then, is to look through all the proof strategies/argument forms you know and see if they are useful. Below, we list some standard proof strategies/argument forms together with the kind of situations in which they are typically useful. While doing more and more mathematics, you will slowly build a mental library of proof strategies that worked in certain situations. This will be an invaluable resource in trying to prove things: most often, what you'll do is to adapt a proof strategy you already know to the case at hand. Bottom-line: even if this looks hard now, you \\emph{will} get better at this with experience.\n\t\t\t\t\n\t\t\t\n\t\t\t\\item \\emph{Write up your proof.}\n\t\t\t\n\t\t\t\tNow it's time to record the results of your work, now you write up the finished proof. If you indeed succeeded in proving your result, it is now a result (a lemma, proposition, theorem), so you can write:\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\t\tLet $n$ be natural number such that $n$ is prime. If $n>2$, then $n$ is odd.\n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\tWhen you claim a result, you will have to follow up with a proof. \t\tThe proof typically comes afterwards in a separate proof environment. You begin the proof by declaring your variables and listing your assumptions (possible naming them for ease of reference). Then you reason carefully, step-by-step to the desired result:\n\n\t\t\t\t\\begin{proof}\n\t\tLet $n$ be a natural number and assume $n$ is prime. By definition, this means that (i) $1<n$ and (ii) there are no natural numbers $k,l<n$ such that $n=k\\cdot l$. We want to show that if $n>2$, then $n$ is odd. So, suppose that $n>2$. By definition, for $n$ to be odd would mean that $n$ is not even. We claim that given our assumptions, $n$ cannot be even and hence must be odd. For suppose that $n$ is even. By definition, this would mean that there exists an $m$ such that $n=2m$. But this would contradict condition (ii) for $n$ being prime: just let $k=2$ and $l=m$. Note that $1<n$ and $n=2m$, it follows that $m<n$ and we have $2<n$ by assumption . So, $n$ cannot be even, which means that $n$ must be odd.\n\t\t\\end{proof}\n\t\t\t\t\n\t\t\t\tNote the $\\square$ at the end of the proof. It marks the end of the proof and is read Q.E.D., i.e. \\emph{quod erat demonstrandum} (what was to be shown).\n\n\t\tWe've completed our proof. \n\t\t\n\t\t\\item \\emph{Proof-read}.\n\t\t\n\t\tAs with any piece of writing, it's important to double check what you've written. At this stage of proving things, go through what you've written once more. Ask yourself: Are my definitions correct(ly phrased)? Is every reasoning step explained? Are all my variables declared? Is my wording understandable? ---Keep in mind that your proof will be read by somebody else, you're not writing it for yourself but to convince somebody else. Write for a reader, not for yourself. We grade your mathematical writing not only in terms of correctness but also in terms of intelligibility. \n\t\t\t\t\n\t\tNow you're (finally) done. Typically, at this part, we'll discard our notes and rest content with our finished, polished proof. Especially when handing in homework, what you will report is your proof and not your notes (unless asked specifically). \n\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\\item \\emph{Nota bene}: A good mathematical proof is written in a clear language, using complete, grammatical sentences. We won't cover mathematical writing in more detail, but I will try to lead by example. The examples of proofs given below are written in the style that we expect you to adopt. \n\t \t \n\t \\item We conclude our tutorial on mathematical proofs with a beginner's library of standard argument forms to be used in mathematical proofs/proof strategies. Note that the list is \\emph{not} exhaustive, already in the next chapter, you will learn a new argument form that will be of central importance throughout the course.\n\t\t\n\t\t\\begin{description}\n\t\t\t\t\n\t\t\t\\item[Conditional Proof.] Also known as \\emph{direct proof}.\n\t\t\t\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item \\emph{Form}: We prove an if-then claim by assuming the if-part and deriving the then-part.\n\t\t\t\n\t\t\t\t\\item \\emph{Justification}: Intuitively, an if-then claim is true just in case the then-part is true, whenever the if-part is. For example, ``if $n$ is even, then $n+1$ is odd'' is true iff $n+1$ is odd for every even number $n$. If we can derive from the assumption that the if-part is true that the then-part must be true, too, we've shown just that.\n\t\t\t\t\n\t\t\t\t\\item \\emph{Use}: Whenever you have an if-then claim, you should first try to prove it using conditional proof.\n\t\t\t\n\t\t\t\\item \\emph{Example}:\n\t\t\t\t\n\t\t\t\t\\vspace{1ex}\n\t\t\t\t\n\t\t\t\t\t\\begin{proposition}\n\t\t\tLet $n,m$ be natural numbers. If $n$ is even, $n\\cdot m$ is even.\n\t\t\t\\end{proposition}\n\t\t\t\n\t\t\t\\begin{proof}\n\t\t\tLet $n$ and $m$ be natural numbers. We want to prove that if $n$ is even, $n\\cdot m$ is even. So assume for conditional proof that $n$ is even. Then, by definition, we have that there exists a natural number $k$ such that $n=2k$. Now consider the number $n\\cdot m$. Since $n=2k$, we have that $n \\cdot m=(2\\cdot k)\\cdot m=2\\cdot (k\\cdot m)$. By definition, this means that $n\\cdot m$ is even, which is what we wanted to show. \n\t\t\t\\end{proof}\n\t\t\t\n\t\t\tNote how we write a conditional proof:\n\t\t\t\n\t\t\t\t\\begin{enumerate}[1.]\n\t\t\t\t\n\t\t\t\t\t\\item State the conditional you wish to prove.\t\t\t\t\t\n\t\t\t\t\t\\item Assume the if-part. \n\t\t\t\t\t\n\t\t\t\t\t\\item Use mathematical reasoning to get to the then-part.\n\t\t\t\t\t\n\t\t\t\t\t\\item Conclude the proof by saying that you've shown what needed to be shown.\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\\item \\emph{Common mistakes}: assuming what needs to be proved (either the whole if-then statement or the then-part).\n\t\t\t\t\n\t\t\t\t\\end{enumerate}\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\t\\item[Distinction by Cases.] Also known as proof by cases, proof by exhaustion, the brute force method, \n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item \\emph{Form}. We prove a claim by showing that it holds in each of a list of exhaustive cases, which is a list of cases such that at least one of the cases must obtain.\n\t\t\t\n\t\t\t\t\\item \\emph{Justification}: If a list of cases is exhaustive, this means that at least one of the cases will obtain (even though we don't necessarily know which one). But if we can show that in \\emph{each} of the cases, our claim would be true, we don't need to know which case will actually occur, we can conclude that our claim will be true regardless.\n\t\t\t\t\n\t\t\t\t\\item \\emph{Use}: When your assumptions (e.g. from a conditional proof) allow for a natural distinctions into several cases. We typically try to avoid distinction by cases with long list of cases (think more than 3) for reasons of mathematical elegance, though a proof with 1936 cases exists (the computer assisted proof of the four-color theorem). \n\t\t\t\t\n\t\t\t\t\\item \\emph{Example}:\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\tFor $n$ a natural number, $n^2+n$ is even. \n\t\t\t\\end{proposition}\n\t\t\t\\begin{proof}\n\t\t\tLet $n$ be a natural number. First, note that $n^2+n=n(n+1)$. So it suffices to show that $n(n+1)$ is even. Since every number is either even or odd, we can distinguish two exhaustive cases: (i) $n$ is even or (ii) $n$ is odd. \n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item \\emph{Case i}. If $n$ is even, then $n(n+1)$ is the product of an even number, $n$, and an odd number, $n+1$. By the above proposition (the example proposition for conditional proof), this means that $n(n+1)$ is even, too.\n\t\t\t\t\n\t\t\t\t\\item \\emph{Case ii}. If $n$ is odd, then, by one of our previously established proposition, we know that $n+1$ is even. But then, again, $n(n+1)$ is the product of an even number, $n+1$, and an odd number, $n$, which we already observed means that $n(n+1)$ is even.\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\tSo, either way, $n(n+1)$ is even, which is what we wanted to show.\n\t\t\t\n\t\t\t\\end{proof}\n\t\t\t\n\t\t\tNote how we write a proof by cases:\n\t\t\t\n\t\t\t\t\\begin{enumerate}[1.]\n\t\t\t\t\n\t\t\t\t\t\\item Give a justification for your case distinction (How many cases are there? Why are they exhaustive?).\n\t\t\t\t\t\n\t\t\t\t\t\\item Go through each case one by one and show, by mathematical reasoning, that the result holds in the case.\n\t\t\t\t\t\n\t\t\t\t\t\\item Conclude that, since the list was exhaustive, the result holds in general.\n\t\t\t\t\n\t\t\t\t\\end{enumerate}\n\t\t\t\t\n\t\t\t\\item \\emph{Common mistakes}: List of cases is not exhaustive/cases are missing.\n\t\t\t\t\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\t\\item[Proof by Contradiction.] Also known as \\emph{indirect proof}. \n\t\t\t\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item \\emph{Form}. We prove a claim by showing that it's negation leads to a contradiction.\n\n\t\t\t\n\t\t\t\t\\item \\emph{Justification}. In classical mathematics, we assume that for every claim, either the claim or its negation is true (remember bivalence, this is a way in which classical mathematics relies on classical logic). But if the negation of a claim leads to a contradiction, it can't be true (again, classical logic). Hence, the original claim must be true.\n\t\t\t\t\n\t\t\t\t\\item \\emph{Use}. This is really an all-rounder, it's used in many diverse situations. You will get a ``feel'' for when proof by contradiction works well. You should always try indirect proof if all direct methods (like conditional proof or proof by cases) have failed you. The method is especially powerful when you're trying to establish that one of two conditions must obtain (like $n$ is either even or $n$ is odd).  \n\t\t\t\t\n\t\t\t\t\\item \\emph{Example}.\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\t\tLet $n$ be a prime number. If $n>2$, then $n$ is odd. \n\t\t\t\t\\end{proposition}\n\t\t\t\t\\begin{proof}\n\t\t\t\tSee above.\n\t\t\t\t\\end{proof}\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\t\tThere is no smallest positive real number, i.e. there exists no real number $x>0$ such that for all $y>0$ we have $x\\leq y$.  \n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\t\\begin{proof}\n\t\t\t\tSuppose (for proof by contradiction) that our claim is false, i.e. there exists a natural number $x$ such that (i) $x>0$ and (ii) for all $y>0$ we have $x\\leq y$. Call that number $\\epsilon$ (as a temporary constant, cf. 2.2.8). Now consider the number $\\frac{\\epsilon}{2}$. Since by assumption (i) $0<\\epsilon$, we have that (a) $0<\\frac{\\epsilon}{2}$ and that (b) $\\frac{\\epsilon}{2}<\\epsilon$. From (a) together with (ii), it follows that $\\epsilon\\leq \\frac{\\epsilon}{2}$. But from this and (b), we get that $\\epsilon<\\epsilon$, which is impossible. Hence, $\\epsilon$ cannot exist and our claim is proven. \n\t\t\t\t\\end{proof}\n\t\t\t\t\n\t\t\t\tNote how we write an indirect proof:\n\t\t\t\n\t\t\t\t\\begin{enumerate}[1.]\n\t\t\t\t\n\t\t\t\t\t\\item State that you're assuming that the claim is false (you can note that you do this for proof by contradiction, but typically that's clear).\n\t\t\t\t\t\n\t\t\t\t\t\\item Spell out what it means for the claim to be false.\n\t\t\t\t\t\n\t\t\t\t\t\\item Derive a contradiction from the assumption that the claim is false.\n\t\t\t\t\t\n\t\t\t\t\t\\item Conclude that the claim must be true because its negation leads to a contradiction.\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{enumerate}\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\t\\item[Contrapositive Proof.] \\\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item \\emph{Form}. We prove an if-then statement by deriving that the if-part is false from the assumption that the then-part is false. \n\t\t\t\n\t\t\t\t\\item \\emph{Justification}. This is closely related to indirect proof. In order for an if-then claim to be \\emph{false}, we would need that the if part is true but the then-part is false. But if we can derive that the if-part is false whenever the then-part is, we cannot have that the if-then claim is false for we'd get a contradiction: the if-part would need to be both true and false. So, given that we can derive the negation of the if-part from the negation of the then-part, the if-then claim cannot be false, so it must be true.\n\t\t\t\t\n\t\t\t\t\\item \\emph{Use}. Contraposition is very useful if the then-part contains a disjunctive claim (as in the example below).\n\t\t\t\t\n\t\t\t\t\\item \\emph{Examples}.\n\t\t\t\t\n\t\t\t\t\\begin{proposition}\n\t\t\t\tLet $n,m$ be natural numbers. If $n\\cdot m$ is even, then either $n$ is even or $m$ is even.\n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\t\\begin{proof}\n\t\t\t\tSuppose that $n$ and $m$ are natural numbers. We want to show that $n\\cdot m$ is even, then either $n$ is even or $m$ is even. We prove the contrapositive, i.e. if neither $n$ nor $m$ is even, then $n\\cdot m$ is odd. Note that if neither $n$ nor $m$ is even, then both $n$ and $m$ are odd. This means that $n=2k+1$ and $m=2l+1$ for natural numbers $k,l$. Now consider the number $n\\cdot m$. Since  $n=2k+1$ and $m=2l+1$, we have that $n\\cdot m=(2k+1)(2l+1)=4kl+2k+2l+1=2(2kl+k+l)+1$. But now note that $2(2kl+k+l)+1$ is of the form $2x+1$ for $x$ a natural number, just let $x=2kl+k+l$. But this just means that $2(2kl+k+l)+1=n\\cdot m$ is odd, which is what we needed to show.\n\t\t\t\t\\end{proof}\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\t\\item[Biconditional Proof.] \\\n\t\t\t\n\t\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\t\\item \\emph{Form}. We prove that two statements are equivalent (the one is true iff the other is) by showing that (i) if the one is true, so is the other (the \\emph{left-to-right} or $\\Rightarrow$ direction) and that (ii) if the other is true, so is the one (the \\emph{right-to-left} or $\\Leftarrow$ direction). Note that we can prove (i) and (ii) using any kind of proof principle we like, but often conditional proof is useful.  \n\t\t\t\t\t\t\n\t\n\t\t\t\t\t\\item \\emph{Justification}. Essentially, an equivalence claim (iff-statement) is just a combination of two if-then statements. To say that $n$ is odd iff $n$ is not even is to say that (i) if $n$ is odd, then $n$ is not even, and (ii) if $n$ is not even, then $n$ is odd. So, essentially, we need to prove two if-then claims, which is what biconditional proof amounts to. \n\t\t\t\t\t\n\t\t\t\t\t\\item \\emph{Use}. I cannot stress this enough: you \\emph{always} need to prove both the left-to-right \\emph{and} the right-to-left direction if you try to establish an equivalence claim.\n\t\t\t\t\t\n\t\t\t\t\t\\item \\emph{Example}.\n\t\t\t\t\t\n\t\t\t\t\t\\begin{proposition}\n\t\t\t\t\tLet $n$ be a natural number. Then $n^2$ is even iff $n$ is even.\n\t\t\t\t\t\\end{proposition}\n\t\n\t\t\t\t\t\\begin{proof}\n\t\t\t\t\tLet $n$ be a natural number.\n\t\t\t\t\t\n\t\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\n\t\t\t\t\t\t\\item (Left-to-right direction): We need to show that if $n^2$ is even, then $n$ is even. We prove the contrapositive. Suppose that $n$ is not even, i.e. odd. Then, by previous observation, there exists a natural number $k$ such that $n=2k+1$. Now consider $n^2$. By our observation, we have $n^2=(2k+1)^2$. So, we get: \\[n^2=(2k+1)^2=4k^2+4k+1\\] But note that $4k^2+4k=2(2k^2+2k)$, and hence $4k^2+4k$ is even by definition. So $n^2=l+1$ where $l$ is an even number (just let $l=4k^2+4k$), which means that $n^2$ is odd by a previous observation. \n\t\t\t\t\t\t\n\t\t\t\t\t\t\\item (Right-to-left direction): We want to prove that if $n$ is even, then $n^2$ is even. So suppose that $n$ is even (for conditional proof). We've previously observed that the product of an even number with any other number is even. But $n^2=n\\cdot n$, so it follows as a simple corollary that $n^2$ is even.\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{itemize}\n\t\t\t\t\tWe conclude that $n^2$ is even iff $n$ is even.\n\t\t\t\t\t\\end{proof}\n\t\t\t\t\t\n\t\t\t\t\tNote how we write a biconditional proof:\n\t\t\t\n\t\t\t\t\\begin{enumerate}[1.]\n\t\t\t\t\n\t\t\t\t\t\\item State that you want to prove an iff-claim.\n\t\t\t\t\t\n\t\t\t\t\t\\item Prove the left-to-right direction.\n\t\t\t\t\t\n\t\t\t\t\t\\item Prove the right-to-left direction.\n\t\t\t\t\t\n\t\t\t\t\t\\item Conclude that the equivalence holds.\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{enumerate}\n\t\t\t\t\n\t\t\t\\item \\emph{Common mistakes}: One of the directions is missing.\n\t\t\t\t\n\t\t\t\t\\end{itemize}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\\item[Universal Generalizations.] \\\n\t\t\t\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\t\\item \\emph{Form}. \tWe prove that all objects (of a category) have a property by showing that any \\emph{arbitrary} object (of the category) has the desired property.\n\t\t\t\t\n\t\t\t\t\t\\item \\emph{Justification}. An arbitrary object is one about which we've not assumed anything. But that means that if we can show that an arbitrary object has the property, then any object we might pick will be just like the arbitrary object. So, if we have a proof that an arbitrary object has the property, we can just repeat the proof for any object we might pick. So, any object will have to have the property.\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\item \\emph{Use}. Basically whenever we want to prove a universal claim.\n\t\t\t\t\t\n\t\t\t\t\t\\item \\emph{Example}.\n\t\t\t\t\t\n\t\t\t\t\tNote that basically every proof we've discussed so far is just one application of universal generalization away from proving a universal, for-all claim.\n\t\t\t\t\tTake the following proposition we've proven above:\n\t\t\t\t\t\\begin{proposition}\n\t\t\t\t\tFor $n$ a natural number, $n^2+n$ is even. \n\t\t\t\t\t\\end{proposition}\n\t\t\t\n\t\t\t\t\tWe could easily transform the proof of this proposition in a proof of the following proposition:\n\t\t\t\t\t\\begin{proposition}\n\t\t\t\t\tFor all natural numbers $n$, $n^2+n$ is even.\n\t\t\t\t\t\\end{proposition}\n\t\t\t\t\tOr, informally put, the result of squaring a natural number and then adding the number itself to this will always result in an even number. The proof of this will be \\emph{almost} like the proof of the previous proposition:\n\t\t\t\t\t\\begin{proof}\n\t\t\t\t\tFor universal generalization, let $n$ be an arbitrary natural number. [insert proof of previous proposition here]. Since $n$ was arbitrary, we can conclude that \\emph{all} numbers have the desired property.\n\t\t\t\t\t\\end{proof}\t\t\n\t\t\t\t\tIt's a simple exercise to do the same with the other claims made in the chapter.\n\t\t\t\t\t\t\n\t\t\t\t\tSo, you can see that there is not much of a difference between using universal statements and using declared variables. Strictly speaking, however, to prove a universal claim you need to reason by universal generalization (or something to the effect). \n\t\t\t\t\t\n\t\t\t\t\\end{itemize}\n\t\t\t\n\t\t\n\t\t\\end{description}\n\t\t\n\t\t\\item This concludes our tutorial on mathemateze and mathodology. We've barely scratched the surface, you still have much to learn. But it's a start. Over the coming years, you will become more and more proficient in the ways of mathematics. For now, let me just note that there is \\emph{way} more to mathematics than what we've just discussed above, this was just a starting point. In mathematical practice, we come up with new definitions, concepts, theories all the time. There is a creative side of mathematics which is sometimes hidden from view when you're learning the basics of a field as a finished product: its definitions and theorems. In this course, I will try to also give you a feel for how we came up with the definitions that we're going to cover.\n\t\t\t\t\n\\end{enumerate}\n\n\\section{Friendly Advice}\n\nI'd like to conclude this chapter with somebody else's advice. Kevin Houston, in the preface to his fantastic tutorial \\emph{How to Think Like a Mathematician} (see \\S\\ref{mathodology:literature}) gives some ``friendly advice'' for learning mathematics, which I'm going to repeat here since all of this applies to this course (this is a direct quote from p. x of that book):\n\t\t\n\t\t\\begin{itemize}\n\t\t\n\t\t\t\\item \\emph{It’s up to you} --- Your actions are likely to be the greatest determiner of the outcome of your studies. Consider the ancient proverb: The teacher can open the door, but you must enter by yourself.\n\t\t\t\n\t\t\t\\item  \\emph{Be active} --- Read the book. Do the exercises set.\n\n\t\t\t\\item  \\emph{Think for yourself} --- Always good advice.\n\n\t\t\t\\item  \\emph{Question everything} --- Be sceptical of all results presented to you. Don’t accept them until you are sure you believe them.\n\n\t\t\t\\item  \\emph{Observe} --- The power of Sherlock Holmes came not from his deductions but his\nobservations.\n\n\t\t\t\\item  \\emph{Prepare to be wrong} --- You will often be told you are wrong when doing mathematics. Don’t despair; mathematics is hard, but the rewards are great. Use it to spur yourself on.\n\n\t\t\t\\item  \\emph{Don't memorize} --- seek to understand --- It is easy to remember what you truly understand.\n\t\t\t\n\t\t\t\\item  \\emph{Develop your intuition} --- But don’t trust it completely.\n\n\t\t\t\\item  \\emph{Collaborate} --- Work with others, if you can, to understand the mathematics. This isn't a competition. Don’t merely copy from them though!\n\t\t\t\n\t\t\t\\item  \\emph{Reflect} --- Look back and see what you have learned. Ask yourself how you could have\ndone better.\n\n\t\t\\end{itemize}\n\t\t\t\n\t\n\\section{Core Ideas}\n\n\t\\begin{itemize}\n\t\t\t\n\t\t\\item Variables stand for arbitrary but fixed objects, constants stand for known objects. \n\t\n\t\t\\item Mathemateze is a very precise language, you have to learn it like a foreign language. You will not only have to remember definitions, but to \\emph{understand} them. Keep in mind: \\emph{understanding facilitates remembering}.\n\t\t\n\t\t\\item An object is defined by giving a list of properties that one and only one object---the object to be defined---satisfies. Keep in mind that for a definition of an object to be successful we need to show that there exists an object that satisfies the properties and that there is at most one object that satisfies the properties.\n\t\t\n\t\t\\item A property or relation is defined by giving the precise conditions under which an object has the property or some objects stand in the relation. Keep in mind that in order for a definition of a property or relation to be successful, the property or relation cannot be used to formulate the conditions that define it.\n\t\n\t\t\\item A mathematical proof is a rigorous, step-by-step argument which establishes the truth of a mathematical statement. \n\t\t\n\t\t\\item An axiomatic proof has only axioms and definitions as premises and uses only valid inferences. The point of mathematical writing is to convince the reader that an axiomatic proof exists using informal rigor. \n\t\t\n\t\t\\item Follow these steps to construct a proof: \\emph{figure out what you want to prove}, \\emph{state your claim as clearly as possible}, \\emph{unfold the relevant definitions}, \\emph{remind yourself of relevant facts}, \\emph{devise a proof strategy}, \\emph{write up your proof}, \\emph{proof-read}.\n\t\t\n\t%I think this could be improved by referencing Plonka!\t\n\t\t\n\t\t\\item Over time, you will slowly build a mental library of proof strategies that worked in certain situations. Study existing proofs and try to understand them, why they work, how they approach the problem. This is the best way to build that mental library.\n\t\t\t\t\t\n\t\\end{itemize}\n\t\n\\section{Self-Study Questions}\n\n\\begin{enumerate}[{\\thesection}.1]\n\n\n\t\\item Which of the following is \\emph{not} a successful definition?\n\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\t\\item A number $n$ is an \\emph{even square} iff $n$ is the square of an even number, i.e. iff there exists a natural number $m$ such that $m$ is even and $m^2=n$.\n\n\t\t\t\\item Let's say that a natural number $n$ is \\emph{independent} iff there are no two dependent numbers $k,l<n$ such that $n=k+l$. Further, we say that a number is \\emph{dependent} iff it is not independent.\n\t\t\t\n\t\t\t\\item We define $\\epsilon$ to be the smallest positive real, i.e. $\\epsilon$ is the number $x$ such that $0<x$ and for all reals $y$, if $0<y$, then $\\epsilon\\leq y$.\n\t\t\n\t\t\t\\item We say that a real number $x$ is a \\emph{positive infinitesimal} iff $x$ is a smallest positive real, i.e. iff (i) $0<x$, and (ii) for all reals $y$, if $0<y$, then $x\\leq y$.\n\t\t\n\t\t\t\\item We define $11$ to be the first natural number bigger than $10$.\n\t\t\t\n\t\t\t\\item We define the imaginary number $i$ as the complex number $x$ such that $x^2=-1$. \n\t\t\t\n\t\t\t\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\t\\item Suppose you're asked to prove the following conjecture:\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item For all natural numbers $n$ and $m$, if $n+m$ is odd, then either $n$ is odd or $m$ is odd.\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\t\n\t\t\tWhat do you think is a good proof strategy to tackle this? (This is, of course, somewhat subjective, but think about it!)\n\t\n\t\t\t\\begin{enumerate}[(a)]\n\n\t\t\t\t\\item Prove it directly using conditional proof followed by universal generalization.\n\t\t\t\t\n\t\t\t\t\\item Try indirect proof to the whole statement.\n\t\t\t\t\n\t\t\t\t\\item Use biconditional proof followed by indirect proof and universal generalization.\n\t\t\t\t\n\t\t\t\t\\item Try contrapositive proof followed by a universal generalization.\n\t\t\t\t\n\t\t\t\t\\item Prove the conditional by conditional proof combined with indirect proof, followed by universal generalization.\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\\item Make a distinction by cases followed by universal generalization.\n\n\t\t\t\\end{enumerate}\n\t\t\n\t\t\t\n\n\\end{enumerate}\n\n\n\t\n\\section{Exercises}\n\n\\begin{enumerate}[{\\thesection}.1]\n\n\t\\item For each of the arguments you gave in exercise 1.7.1, determine which argument forms you've used.\n\t\t\n\t\\item Prove the following simple, number-theoretic facts. Make use of the step-by-step procedure laid out in 2.3.7.\n\t\n\t\t\\begin{enumerate}[(a)]\n\n\t\t\t\\item $[h]$ The sum of two even numbers is even.\n\t\t\t\n\t\t\t\\item $[h]$ If the product of two natural numbers is odd, then at least one of the two numbers is odd. \n\t\t\t\n\t\t\t\\item $[h]$ Every natural number is either even or odd.\n\t\t\t\n\t\t\t\\item If you add one to an even number, you get an odd number.\n\n\t\t\t\\item The product of two prime numbers is not a prime number.\n\t\t\t\n\t\t\t\\item No prime number \\emph{bigger than two} is the product of an even and an odd number.\n\n\t\t\\end{enumerate}\n\t\t\n\t\\item Let $n$ be a natural number. \n\t\n\t\t\t\\begin{enumerate}[(a)]\n\n\t\t\t\t\\item Formulate a necessary but not sufficient condition for $n$ being even.\n\n\t\t\t\t\\item Formulate a sufficient but not necessary condition for $n$ being even.\n\t\t\t\t\n\t\t\t\t\\item Formulate a necessary and sufficient condition for $n$ being even.\n\n\t\t\t\\end{enumerate}\n\t\n\t\\item $[h,\\nosym]$ For each of the following mathematical statements, express the statement in ordinary language, without the use of mathematical symbols.\n\t\n\t\\begin{enumerate}[(a)]\n\t\n\t\t\\item Let $n$ and $m$ be two natural numbers. Then, if there is a number $k$ such that $2k=n$ and there is a natural number $l$ such that $2l=m$, then there exists a natural number $j$ such that $2j=n+m$.\n\t\t\n\t\t\\item For every natural number, $n$, either there exists a natural number $k$ such that $2k=n$ or there exists a natural number $k$ such that $2k+1=n$.\n\t\t\n\t\t\\item If $n$ is a natural number, then there exists a natural number $k$ such that $2k=n^2+n$.\n\t\t\n\t\t\\item There is no real number $x$ such that $x<0$ and whenever $y<0$ for some real number $y$, then $y\\leq x$. \n\t\t\t\t\t\n\t\\end{enumerate}\n\t\n\t\\item $[\\nosym]$ Consider our running example from 2.3.7 and its final proof:\n\t\n\t\\begin{proposition}\n\t\t\t\tLet $n$ be a natural number such that $n$ is prime. If $n>2$, then $n$ is odd.\n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\t\\begin{proof}\n\t\tLet $n$ be a natural number and assume $n$ is prime. By definition, this means that (i) $1<n$ and (ii) there are no natural numbers $k,l<n$ such that $n=k\\cdot l$. We want to show that if $n>2$, then $n$ is odd. So, suppose that $n>2$. By definition, for $n$ to be odd would mean that $n$ is not even. We claim that given our assumptions, $n$ cannot be even and hence must be odd. For suppose that $n$ is even. By definition, this would mean that there exists an $m$ such that $n=2m$. But this would contradict condition (ii) for $n$ being prime: just let $k=2$ and $l=m$. Note that $1<n$ and $n=2m$, it follows that $m<n$ and we have $2<n$ by assumption . So, $n$ cannot be even, which means that $n$ must be odd.\n\t\t\\end{proof}\n\t\n\t\tDescribe the theorem and its proof in natural language without the use of mathematical symbols.\n\n\\end{enumerate}\n\n\\section{Further Readings}\n\\label{mathodology:literature}\n\nIt will take a while for you to become perfectly comfortable with mathematical writing and reasoning. Here are some references to books which you can use to learn more about how mathematicians write and think:\n\n\t\\begin{itemize}\n\t\n\t\t\\item Houston, Kevin. 2009. \\emph{How to Think Like a Mathematician. A Companion to Undergraduate Mathematics}. Oxford, UK: Oxford University Press.\n\t\t\n\t\tThe book has a homepage \\url{http://www.kevinhouston.net/httlam.html}, which includes sample chapters, corrections, etc.\n\t\t\n\t\tI particularly recommend reading chapters 5, 14--25, and 32--35 (don't worry they're short).\n\t\t\n\t\t\\item Vivaldi, Franco. 2014. \\emph{Mathematical Writing}. London, UK: Springer. \n\t\n\t\\end{itemize}\n\t\n\\noindent I can warmly recommend both of these books, they will make your life much easier when it comes to studying any field that uses modern mathematics, such as logic, (parts of) philosophy, linguistics, (theoretical) computer science, \\dots.\n\n%There are also several webpages, which cover\n%\n%\\begin{itemize}\n%\n%\t\\item On reading mathematics: \\url{https://web.stonehill.edu/compsci/History_Math/math-read.htm}\n%\n%\\end{itemize}\n\nMost of the things we covered above are covered in those books at greater length and in more detail. It might be that, here and there, the books contradict what I said above by way of advice---but those are primarily questions of style and not of substance. \n\n\n\\vfill\n\n\\hfill \\rotatebox[origin=c]{180}{\n\\fbox{\n\\begin{minipage}{0.5\\linewidth}\n\n\\subsection*{Self Study Solutions}\n\n\\begin{enumerate}\n\n\t\\item[2.6.1]  \\begin{itemize}\n\t\t\t\\item[(b):] the definition is circular\n\t\t\t\\item[(c):] there is no such number\n\t\t\t\\item[(f):] there's more than one: $i,-i$ \n\t\t\t\\end{itemize}\n\n\t\\item[2.6.2]\n\t\\begin{itemize}\n\t\t\t\\item[(a):] might work\n\t\t\t\\item[(b,c,f):] not very promising\n\t\t\t\\item[(d,e):] most promising\n\t\\end{itemize}\n\t\n\\end{enumerate}\n\n\n\\end{minipage}}}\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../../logic.tex\"\n%%% End:\n", "meta": {"hexsha": "3b152ca60b8517194dfebe040bd9a415e4c256b9", "size": 67947, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/notes/tex/mainmatter/fund-math.tex", "max_stars_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_stars_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/notes/tex/mainmatter/fund-math.tex", "max_issues_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_issues_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/notes/tex/mainmatter/fund-math.tex", "max_forks_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_forks_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.6537142857, "max_line_length": 1240, "alphanum_fraction": 0.7266545984, "num_tokens": 17793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.446097398752388}}
{"text": "\\documentclass[pdf]{beamer}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{tcolorbox}\n\\usepackage[all]{xy}\n\n\\mode<presentation>{}\n\n% ------------------------------------------------------------------------------\n% Theme\n\n\\usetheme[usetitleprogressbar, nosmallcapitals, usetotalslideindicator]{m}\n\n\\lstloadlanguages{Haskell}\n\\lstnewenvironment{code}\n    {\\lstset{}%\n      \\csname lst@SetFirstLabel\\endcsname}\n    {\\csname lst@SaveFirstLabel\\endcsname}\n    \\lstset{\n      basicstyle=\\ttfamily\\footnotesize,\n      flexiblecolumns=false,\n      basewidth={0.5em,0.45em},\n      literate={+}{{$+$}}1 {/}{{$/$}}1 {*}{{$*$}}1\n               {\\\\\\\\}{{\\char`\\\\\\char`\\\\}}1\n               {=>}{{$\\Rightarrow$}}2\n               {forall}{{$\\forall$}}2\n               {->}{{$\\rightarrow$}}2\n               {<-}{{$\\leftarrow$}}2\n               {>>}{{>>}}3 {>>=}{{>>=}}3,\n      commentstyle={\\ttfamily\\color{gray}},\n      language=haskell\n    }\n    \n% ------------------------------------------------------------------------------\n% Presentation\n\n\\title{Give me freedom!}\n\\subtitle{Or let me forget}\n\\date{\\today}\n\\author{Joseph Tel Abrahamson / @sdbo / \\texttt{github.com/tel} }\n\n\\renewcommand{\\to}{\\ensuremath{\\rightarrow}}\n\\DeclareMathOperator{\\Free}{\\texttt{Free}}\n\\DeclareMathOperator{\\Forget}{\\texttt{Forget}}\n\\DeclareMathOperator{\\Monad}{\\texttt{Monad}}\n\\DeclareMathOperator{\\Functor}{\\texttt{Functor}}\n\\DeclareMathOperator{\\ty}{\\texttt{ :: }}\n\n\\begin{document}\n\n\n\\maketitle\n\n\\begin{frame}\n  \\frametitle{Synopsis}\n  \\begin{itemize}\n  \\item Ways of seeing Freedom: a noun, an adjective, a verb\n  \\item Thinking through Freedom as a process\n  \\item Using Category Theory as a tool of insight\n  \\end{itemize}\n\\end{frame}\n\n\\section{A first glimpse of Freedom}\n\n\\begin{frame}[fragile]\n  \\frametitle{\\texttt{Free} is a noun}\n  \\pause\n\\begin{lstlisting}\ndata Free f a\n  = Return a\n  | Free (f (Free f a))\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile,fragile]\n  \\frametitle{What are Free Monads anyway?}\n  \\pause\n\\begin{lstlisting}\nnewtype Identity a = Identity a\nnewtype Fix f = Fix (f (Fix f))\n\n-- Free f a ~= Identity a + Fix f\n\\end{lstlisting}\n  \\pause\n\\begin{lstlisting}\n-- I don't know, something like that, not quite kind of?\n\\end{lstlisting}\n\\end{frame}\n\n\\plain{What's going on here?}\n\n\\begin{frame}[fragile]\n\\begin{lstlisting}\nlift     :: Functor f => f a -> Free f a\nfoldFree :: Monad m => (forall x . f x -> m x) -> (Free f a -> m a)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Free Monads as \"interpreters\"}\n\\begin{lstlisting}\ndata TeletypeF a \n  = PutStrLn String a \n  | GetLine (String -> a)\n    deriving ( Functor )\n                     \ntype Teletype = Free TeletypeF\n\nputStrLnTT :: String -> Teletype ()\nputStrLnTT line = lift (PutStrLn line ())\n\ngetLineTT :: Teletype String\ngetLineTT = lift (GetLine id)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Very nice embedded DSLs... for \\textit{less}!}\n\\begin{lstlisting}\nechoTT :: Teletype ()\nechoTT = forever $ do\n  line <- getLineTT\n  putStrLineTT line\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Very nice embedded DSLs... for \\textit{less}!}\n\\begin{lstlisting}\ninterp :: TeletypeF a -> IO a\ninterp x = case x of\n  PutStrLn line a -> putStrLn line >> return a\n  GetLine next -> do\n    line <- getLine\n    return (next line)\n\nechoIO :: IO ()\nechoIO = fold interp echoTT\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  ``Less'' $\\neq$ Free\n\\end{frame}\n\n\\plain{What's going on here?}\n\n\\section{Free is an adjective}\n\n\\begin{frame}\n  \\frametitle{\"Free\" things!}\n  \\begin{itemize}\n  \\item \\lstinline{Free} makes free \\lstinline{Monad}s! \\pause\n  \\item Free \\lstinline{Monoid}s are lists?\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Free \\texttt{Monoid}s are lists}\n\\begin{lstlisting}\npure    :: a -> [a]\nfoldMap :: Monoid m => (a -> m) -> ([a] -> m)\n\\end{lstlisting}\n  \\pause  \n  ``\\lstinline{Foldable} just means \\lstinline{toList}''\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Free \\texttt{Monoid}s are lists}\n\\begin{lstlisting}\nlift     :: Functor f => f a -> Free f a\nfoldFree :: Monad m => (forall x . f x -> m x) -> (Free f a -> m a)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{\"Free\" things!}\n  \\begin{itemize}\n  \\item \\lstinline{Free} makes free \\lstinline{Monad}s! \\pause\n  \\item Free \\lstinline{Monoid}s are lists! \\pause\n  \\item We can make free \\lstinline{Applicative}s, I hear \\pause\n  \\item Can there be free things of any kind? Sure looks like it! \\pause\n  \\item Let's free all the things!\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{itemize}\n  \\item Lists are the ``largest'' \\lstinline{Monoid}s\n  \\item Lists are the ``simplest'' \\lstinline{Monoid}s \\pause\n  \\item What are the largest and simplest examples of other things?\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{More questions than answers}\n  \\begin{itemize}\n  \\item \\lstinline{Free f} is the ``largest'' \\lstinline{Monad}?  \\pause\n  \\item Does that mean that both \\lstinline{Free TeletypeF} and\n    \\lstinline{Free []} are \\textit{both} the ``largest'' \\lstinline{Monad}?\n    \\pause\n  \\item I hear that \\lstinline{Free f} and \\lstinline{Operational f} are\n    \\textit{both} free monads? \\pause But they're not isomorphic.\n  \\end{itemize}\n\\end{frame}\n\n\\plain{Wat.}\n\\plain{What's going on here?}\n\n\\section{Freedom is a process}\n\n\\begin{frame}[fragile]\n  \\frametitle{What is \\texttt{Free}, really?}\n  \n  \\uncover<3->{But really more like...}\n\n  \\begin{align*}\n    & \\action<+->{\\mathtt{>}\\ \\mathtt{:kind}\\ \\Free} \\\\\n    & \\action<+->{\n        \\Free \\ty \n          (\\star \\to \\star)_{\\uncover<3->{\\Functor}} \\to\n          (\\star \\to \\star)_{\\uncover<3->{\\Monad}}\n      }\n  \\end{align*}\n  \n  \\pause\n\n  \\begin{tcolorbox}[boxrule=0pt, arc=0pt, outer arc=0pt]\n\\begin{lstlisting}\n-- remember...\ninstance Functor f => Monad (Free f)\n\\end{lstlisting}\n  \\end{tcolorbox}\n\\end{frame}\n\n\\plain{Oh, an \\textit{arrow}! \\pause Time to use some category theory!}\n\n\\begin{frame}\n  \\frametitle{A picture of ``Free monads\"}\n  \\begin{description}\n  \\item[$\\Free_{\\Monad}$] \n    \\begin{displaymath}\n      \\mathtt{Functor}\\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Monad}\n    \\end{displaymath}\n  \\pause\n  \\item[$\\mathtt{List}$]\n    \\begin{displaymath}\n      \\mathtt{Hask}\\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Monoid}\n    \\end{displaymath}\n  \\pause\n  \\item[$\\mathtt{Coyoneda}$] \n    \\begin{displaymath}\n      \\mathtt{Hask}_{(\\star\\to\\star)} \\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Functor}\n    \\end{displaymath}\n  \\end{description}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Dualize!}\n  \\begin{center}\n    \\begin{displaymath}\n      \\mathtt{Functor}\n      \\xymatrix{\n        \\bullet \\ar@/^/[r]^{\\Free} & \n        \\bullet\n      }\n      \\mathtt{Monad}\n    \\end{displaymath}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Dualize!}\n  \\begin{center}\n    \\begin{displaymath}\n      \\mathtt{Functor}\n      \\xymatrix{\n        \\bullet \\ar@/^/[r]^{\\Free} & \n        \\bullet \\ar@/^/[l]^{\\Forget}\n      }\n      \\mathtt{Monad}\n    \\end{displaymath}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{itemize}\n  \\item If $\\Forget \\ty \\Monad \\to \\Functor$ \\textit{forgets} that some type is\n    a \\lstinline{Monad}... \\pause\n  \\item Is $\\Free \\ty \\Functor \\to \\Monad$ remembering it?\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Not quite}\n  \\begin{align*}\n    (\\Free \\circ \\Forget)(M) &\\neq M \\\\\n    (\\Forget \\circ \\Free)(F) &\\neq F\n  \\end{align*}\n  \\pause\n  For good reason!\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Just right}\n  If\n  \\begin{flalign*}\n    M = \\Free(F)\n  \\end{flalign*}\n  for some \\texttt{Functor} $F$, then\n  \\begin{flalign*}\n    (\\Free \\circ \\Forget)(M) = M\n  \\end{flalign*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Just right}\n  If\n  \\begin{flalign*}\n    F = \\Forget(M)\n  \\end{flalign*}\n  for some \\texttt{Monad} $M$, then\n  \\begin{flalign*}\n    (\\Forget \\circ \\Free)(F) = F\n  \\end{flalign*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Adjunctions}\n  \\begin{align*}\n    Free &\\dashv Forget\n  \\end{align*}\n  \\begin{align*}\n    Free \\circ Forget \\circ Free &= Free \\\\\n    Forget \\circ Free \\circ Forget &= Forget \n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{What does an Adjunction buy us?}\n  \\begin{align*}\n    F &: \\mathcal{C} \\to \\mathcal{D} \\\\\n    G &: \\mathcal{D} \\to \\mathcal{C}\n  \\end{align*}\n  \\pause\n  \\begin{align*}\n    \\forall c : \\mathcal{C}, d &: \\mathcal{D}, \\mathcal{D}(F c, d) \\equiv \\mathcal{D}(c, G d)\n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{What does an Adjunction buy us?}\n\\begin{lstlisting}\ntype Forget f a = f a\n\n-- \"Natural transformations\"\ntype f :-> g = forall x . f x -> g x\n\nfwd :: Monad m => (Free f :-> m) -> (f :-> Forget m)\nbwd :: Monad m => (f :-> Forget m) -> (Free f :-> m)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{What does an Adjunction buy us?}\n\\begin{lstlisting}\n\n\n\n\n\nfwd :: Monad m => (forall x . Free f x -> m x) -> (f a -> m a)\nbwd :: Monad m => (forall x . f x -> m x) -> (Free f a -> m a)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\begin{lstlisting}\nfoldFree :: Monad m => (forall x . f x -> m x) -> (Free f a -> m a)\nfoldFree = bwd\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\begin{lstlisting}\nidFree :: Free f x -> Free f x\nidFree = id\n\n-- m ~ Free f\nlift :: f a -> Free f a\nlift = fwd idFre\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{What does an Adjunction buy us?}\n  Everything we need.\n\\end{frame}\n\n\\section{Bonus: Freedom for everyone}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n  \\pause\n\\begin{lstlisting}\ncurious :: _\ncurious = flip bwd\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\ncurious :: Monad m => Free f a -> (f :-> m) -> m a\ncurious = flip bwd\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\n\n\nnewtype Free f a \n  = Free { runFree :: forall m . Monad m => (f :-> m) -> m a }\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\n{-# LANGUAGE ConstraintKinds #-}\n\nnewtype Free c f a \n  = Free { runFree :: forall m . c m => (f :-> m) -> m a }\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\n{-# LANGUAGE ConstraintKinds #-}\n\nnewtype HFree c f a \n  = HFree { runHFree :: forall m . c m => (f :-> m) -> m a }\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\n{-# LANGUAGE ConstraintKinds #-}\n\nnewtype Free c a \n  = Free { runFree :: forall r . c r => (a -> r) -> r }\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Definition by elimination}\n\\begin{lstlisting}\nfree :: [a] -> Free Monoid a\nfree as = Free $ \\ar -> foldMap ar as\n\nunfree :: Free Monoid a -> [a]\nunfree f = runFree f (\\x -> [x])\n\\end{lstlisting}\n\\end{frame}\n\n\\section{Thanks!}\n\n\\begin{frame}\n  \\frametitle{Tweet at me!}\n  \\begin{center}\n    @sdbo\n  \\end{center}\n\\end{frame}\n\n\\end{document}\n\n%%% Local Variables: \n%%% coding: utf-8\n%%% mode: latex\n%%% TeX-engine: xetex\n%%% End: ", "meta": {"hexsha": "925c8f64cdb87abdd12c62a902e522ca84c8ba53", "size": 11296, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "speakers/tel/freedom.tex", "max_stars_repo_name": "nuttycom/lambdaconf-2015-upstream", "max_stars_repo_head_hexsha": "1c768a5d0d86b7391635c54ff5c951dd786113ad", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": 100, "max_stars_repo_stars_event_min_datetime": "2015-05-19T21:02:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-09T01:30:39.000Z", "max_issues_repo_path": "speakers/tel/freedom.tex", "max_issues_repo_name": "rtfeldman/lambdaconf-2015", "max_issues_repo_head_hexsha": "62396a8656df5e1e11a92c0fcfbb9398a10fd956", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2015-05-12T00:22:15.000Z", "max_issues_repo_issues_event_max_datetime": "2016-08-31T00:51:49.000Z", "max_forks_repo_path": "speakers/tel/freedom.tex", "max_forks_repo_name": "rtfeldman/lambdaconf-2015", "max_forks_repo_head_hexsha": "62396a8656df5e1e11a92c0fcfbb9398a10fd956", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 63, "max_forks_repo_forks_event_min_datetime": "2015-05-06T23:17:26.000Z", "max_forks_repo_forks_event_max_datetime": "2017-04-09T06:48:05.000Z", "avg_line_length": 23.1950718686, "max_line_length": 97, "alphanum_fraction": 0.6317280453, "num_tokens": 3803, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660688, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4460973916827652}}
{"text": "         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n         % Information sheet for the Matlab lab - Maths 6111 %\n         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[10pt]{article} \n\\input ma_no_html_header\n\n\\usepackage{color}\n\\usepackage{hyperref}\n\\hypersetup{breaklinks=true,colorlinks=true}\n%\\input ma_header\n\\setlength{\\parindent}{0pt}\n\\pagestyle{myheadings}\n% \\markright{\n% \\protect {\\protect \\epsfxsize=0.2 true cm \\protect \\epsffile {dolph.line.eps}}\n% \\it Maths 3018/6111 - Numerical methods \\hfill}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{document}\n\n\\thispagestyle{empty}\n\\begin{center}\n\\textbf{\\Large Maths 3018/6111 - Numerical Methods \\\\*[8mm]\nWorksheet 3 - Solutions}\\\\*[.8cm]\n\\end{center}\n\n\\section*{Theory}\n\n\\begin{enumerate}\n\\item Apply Simpson's rule to compute\n  \\begin{equation*}\n    \\int_0^{\\pi/2} \\cos(x) \\, dx\n  \\end{equation*}\n  using 3 points (so $h = \\pi / 4$) and 5 points (so $h = \\pi / 8$).\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  The exact solution is, of course, 1.\n\n  Simpson's rule (composite version) is\n  \\begin{equation*}\n    I = \\frac{h}{3} \\left[ f(a) + f(b) + 2 \\sum_{j=1}^{N/2-1}\n      f(x_{2j}) + 4 \\sum_{j=1}^{N/2}  f(x_{2j-1} \\right]\n  \\end{equation*}\n  where we are using $N+1$ points with $x_0=a$, $x_N=b$, equally\n  spaced with grid spacing $h = (b-a)/N$.\n\n  With 3 points we have $N=2$ and $h=(\\pi/2)/2=\\pi/4$, and so we have\n  nodes and samples given by\n  \\begin{equation*}\n    \\begin{array}{c|c|c}\n      i & x_i & f(x_i) \\\\ \\hline\n      0 & 0 & 1 \\\\\n      1 & \\pi/4 & \\tfrac{1}{\\sqrt{2}} \\\\\n      2 & \\pi/2 & 0\n    \\end{array}\n  \\end{equation*}\n  Using Simpsons rule we then get\n  \\begin{align*}\n    I & = \\frac{h}{3} \\left[ f_0 + f_2 + 4 f_1 \\right] \\\\\n      & = \\frac{\\pi}{12} \\left( 1 + 2 \\sqrt{2} \\right) \\\\\n      & \\approx 1.0023.\n  \\end{align*}\n\n  With 5 points we have $N=4$ and $h=(\\pi/2)/4=\\pi/8$, and so we have\n  nodes and samples given by\n  \\begin{equation*}\n    \\begin{array}{c|c|c}\n      i & x_i & f(x_i) \\\\ \\hline\n      0 & 0 & 1 \\\\\n      1 & \\pi/8 & \\cos(\\pi / 8) \\approx 0.9239 \\\\\n      2 & \\pi/4 & \\tfrac{1}{\\sqrt{2}} \\\\\n      3 & 3\\pi/8 & \\cos(3 \\pi / 8) \\approx 0.3827\\\\\n      4 & \\pi/2 & 0\n    \\end{array}\n  \\end{equation*}\n  Using Simpsons rule we then get\n  \\begin{align*}\n    I & = \\frac{h}{3} \\left[ f_0 + f_4 + 4 (f_1 + f_3) + 2 f_2 \\right] \\\\\n      & = \\frac{\\pi}{24} \\left( 1 + 4 (\\cos(\\pi/8) + \\cos(3\\pi/8)) +\n        \\sqrt{2} \\right) \\\\ \n      & \\approx 1.00013.\n  \\end{align*}\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item Apply Richardson extrapolation to the result above; does the\n  answer improve?\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  Simpson's rule has order of accuracy 4. We note that we have just\n  computed the result using 3 ($N=2$) and 5 ($N=4$) points. Richardson\n  extrapolation gives the result\n  \\begin{align*}\n    R_4 & = \\frac{2^4 I_4 - I_2}{2^4 - 1} \\\\\n    & \\approx 0.999992.\n  \\end{align*}\n  We note that the error has gone from $2.3 \\times 10^{-3}$ for $I_2$\n  to $1.3 \\times 10^{-4}$ for $I_4$ and now to $8.4 \\times 10^{-6}$\n  for the Richardson extrapolation $R_4$, a good improvement.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item State the rate of convergence of the trapezoidal rule and\n  Simpson's rule, and sketch (or explain in words) the proof.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  For the trapezoidal rule the error converges as $h^2$. For Simpson's\n  rule the error converges as $h^4$.\n\n  In both cases the proof takes a similar path. Consider the\n  quadrature over a single subinterval. Taylor series expand the\n  quadrature rule about a suitable point $x_j$ (left edge for\n  trapezoidal rule, centre for Simpson's rule) to get an expression\n  for the quadrature of the interval in terms of $h$ and the function\n  $f$ and its derivatives as evaluated at $x_j$.\n\n  Next write down the anti-derivative $F(t)$ of $f$ for the interval\n  as a function of the width of the interval $t$. This, when evaluated\n  at $t=h$, is the exact solution for the quadrature of the\n  subinterval. Taylor series expand $F$ about $t=0$ to get an\n  expression for the exact result in terms of $h$ and the function $f$\n  and its derivatives as evaluated at $x_j$.\n\n  By comparing the two expressions we have a bound on the error in\n  terms of $h$ and derivatives of $f$. By summing over all intervals\n  (note that at this stage we lose a power of $h$ as we have $N$\n  subintervals with $N \\propto h^{-1}$) we can bound the global error\n  in terms of $h$ and the maximum value of a derivative of $f$.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item Explain in words adaptive and Gaussian quadrature, in particular\n  the aims of each and the times when one or the other is more useful.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  Adaptive quadrature uses any standard quadrature method and some\n  error estimator, such as Richardson extrapolation, to place\n  additional nodes wherever required to ensure that the error is less\n  than some desired tolerance. Each subinterval is tested to ensure\n  that its (appropriately weighted) contribution to the total error is\n  sufficiently small. If it is not, the subinterval is further\n  subdivided by introducing more nodes in a fashion appropriate for\n  the quadrature method used. This is a straightforward way of getting\n  high accuracy for low computational cost using standard quadrature\n  algorithms. \n\n  Gaussian quadrature aims to get the best result for a \\emph{generic}\n  function by allowing both the choice of nodes and weights to\n  vary. The location of the nodes and the value of the weights is\n  given by ensuring that the quadrature is exact for as many\n  polynomials as possible; i.e., if we have $N$ nodes (and hence $N$\n  weights) we should be able to exactly integrate $x^s$ for $0 \\le s\n  \\le 2N - 1$. By introduing a weighting function we can also deal\n  with integrands that are (mildly) singular at the boundaries of the\n  domain, or unbounded domains. Provided the function can be evaluated\n  anywhere this is an effective way of getting high accuracy with few\n  function evaluations for most functions.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item{} [3018 only] Show how the speed of convergence of a nonlinear\n  root finding method depends and the derivatives of the map $g(x)$\n  near the fixed point $s$.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  We assume we are constructing an iterative sequence $x_n$ where\n  $x_{n+1} = g(x_n)$, and that the error at step $n$ is $e_n = x_n -\n  s$. Then if we assume that the step $x_{n+1}$ is sufficiently close\n  to the root $s$ then we can write\n  \\begin{align*}\n    e_{n+1} & = x_{n+1} - s \\\\\n    & = g(x_n) - g(s) \\\\ \n    \\intertext{using the definition of the sequence and the fixed\n      point}\n    & = g'(s) (x_n -s) + \\frac{g''(s)}{2!} (x_n - s)^2 + {\\cal O}\n    \\left( (x_n - s)^3 \\right) \\\\\n    \\intertext{by Taylor expanding}\n    & = g'(s) e_n + \\frac{g''(s)}{2!} e_n^2 + {\\cal O} \\left( e_n^3\n    \\right).\n  \\end{align*}\n  Hence if $g'(s) \\ne 0$ we have that the error reduces by a constant\n  amount proportional to the derivative at each step. If the\n  derivative does vanish the error at each iteration is proportional\n  to the square of the previous error which leads to faster\n  convergence. \n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item{} [3018 only] Use Newton's method to find the root in $[0,1]$ of\n  \\begin{equation*}\n    f(x) = \\sin(x) - e^x + 0.9 + x.\n  \\end{equation*}\n  Start from $x_0=1/2$ and retain 3 significant figures. Take 3 steps.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  For Newton's method we have\n  \\begin{equation*}\n    x_{n+1} = x_n - \\frac{f(x_n)}{f'(x_n)}.\n  \\end{equation*}\n  So first we compute the derivative,\n  \\begin{equation*}\n    f'(x) = \\cos(x) - e^x + 1.\n  \\end{equation*}\n  It follows that the iterative scheme is give by\n  \\begin{equation*}\n    x_{n+1} = x_n - \\frac{\\sin(x_n) - e^{x_n} + 0.9 + x_n}{\\cos(x_n) -\n      e^{x_n} + 1}. \n  \\end{equation*}\n  We start from $x_0=1/2$ and compute with full precision but only\n  retain 3 significant figures for the values of the $x_n$:\n  \\begin{align*}\n    x_1 & = x_0 - \\frac{\\sin(x_0) - e^{x_0} + 0.9 + x_0}{\\cos(x_0) -\n      e^{x_0} + 1} \\\\\n    & \\approx -0.508; \\\\\n    \\intertext{retaining 3 s.f.\\ we set $x_1 = -0.508$, and find}\n    x_2 & = x_1 - \\frac{\\sin(x_1) - e^{x_1} + 0.9 + x_1}{\\cos(x_1) -\n      e^{x_1} + 1} \\\\\n    & \\approx 0.0393; \\\\\n    \\intertext{retaining 3 s.f.\\ we set $x_2 = 0.0393$, and find}\n    x_3 & = x_2 - \\frac{\\sin(x_2) - e^{x_2} + 0.9 + x_2}{\\cos(x_2) -\n      e^{x_2} + 1} \\\\\n    & \\approx 0.103.\n  \\end{align*}\n  \n  After 5 steps you would see, to 3 s.f., that it has converged to\n  $0.106$, so after 3 steps it does quite well; a better approximation\n  to the solution is $0.106022965\\dots$.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\end{enumerate}\n\n\\end{document}\n\n", "meta": {"hexsha": "a2f9b613dc6a89ca6817c16b14effc3594d44e94", "size": 9343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Worksheets/Worksheet3_Solutions.tex", "max_stars_repo_name": "soto97/NumericalMethods", "max_stars_repo_head_hexsha": "513a281e7f2ac905263153cc8bb48c29deed60cd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-01T09:15:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T09:15:04.000Z", "max_issues_repo_path": "Worksheets/Worksheet3_Solutions.tex", "max_issues_repo_name": "indranilsinharoy/NumericalMethods", "max_issues_repo_head_hexsha": "989e0205565131057c9807ed9d55b6c1a5a38d42", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Worksheets/Worksheet3_Solutions.tex", "max_forks_repo_name": "indranilsinharoy/NumericalMethods", "max_forks_repo_head_hexsha": "989e0205565131057c9807ed9d55b6c1a5a38d42", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-05-09T17:04:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-09T17:04:16.000Z", "avg_line_length": 35.2566037736, "max_line_length": 80, "alphanum_fraction": 0.6217489029, "num_tokens": 3237, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.8459424334245618, "lm_q1q2_score": 0.4460794229726908}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{IV}\n\n\\def\\ntitle{Geometric Group Theory}\n\\def\\nlecturer{A.\\ Khukhro}\n\n\\def\\nterm{Lent}\n\\def\\nyear{2020}\n\n\\input{header}\n\n\\DeclareMathOperator{\\rk}{rk} % rank\n\\DeclareMathOperator{\\Cay}{Cay} % Cayley graph\n\\DeclareMathOperator{\\Ends}{Ends} % Ends\n\\DeclareMathOperator{\\QI}{QI} % quasi-isometry group\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Introduction}\n\nContents:\n\\begin{enumerate}\n\\item free groups: ``universal property'', study subgroups using topology,\n\\item group presentations and constructions, ways of making new groups from old,\n\\item Cayley graphs, viewing groups geometrically (e.g.\\ \\(\\Z\\)), connections to group actions,\n\\item geometric properties of groups, growth, other geometric invariants, ``dictionary'' between algebra and geometry,\n\\item amenable groups.\n\\end{enumerate}\n\n\\section{Free groups}\n\nLet \\(S\\) be a set, called an \\emph{alphabet}\\index{alphabet}, and let \\(S^{-1}\\) be the set of formal inverses of elements in \\(S\\), i.e.\\ \\(S^{-1} = \\{s^{-1}: s \\in S\\}\\). A \\emph{word}\\index{word} in the alphabet \\(S\\) is a finite sequence of elements in \\(S \\cup S^{-1}\\) and the empty word. A word is \\emph{reduced}\\index{word!reduced} if it does not contain occurrences of \\(ss^{-1}, s^{-1}s\\). Given a word, we can reduce it by removing any such subwords. For example if \\(S = \\{a, b, c\\}\\), \\(aa^{-1}bcb^{-1}bc^{-1}\\) is a word and we can reduce it to \\(bcc^{-1}\\), and further to \\(b\\). This induces an equivalence relation such that there is a unique reduced word in each class. We also write \\(s^2\\) for \\(ss\\).\n\n\\begin{definition}[free group]\\index{free group}\n  The \\emph{free group} on the set \\(S\\), denoted \\(F(S)\\), is the set of reduced words in \\(S\\), with the operation of concatenation (followed by reduction if necessary).\n\\end{definition}\n\nFree groups satisfies the universal property\n\n\\begin{theorem}\n  Given a free group \\(F(S)\\) with an inclusion \\(\\iota: S \\to F(S)\\), whenever \\(G\\) is a group with a function \\(\\varphi: S \\to G\\), there is a unique group homomorphism \\(\\overline \\varphi: F(S) \\to G\\) such that the following diagram commutes\n  \\[\n    \\begin{tikzcd}\n      S \\ar[r, \"\\iota\"] \\ar[dr, \"\\varphi\"] & F(S) \\ar[d, \"\\overline \\varphi\"] \\\\\n      & G\n    \\end{tikzcd}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Given \\(\\varphi: S \\to G\\), define \\(\\overline \\varphi: F(S) \\to G\\) by \\(\\overline \\varphi(s_{i_1}^{\\alpha_1} \\cdots s_{i_n}^{\\alpha_n}) = \\varphi(s_{i_1})^{\\alpha_1} \\cdots \\varphi(s_{i_n})^{\\alpha_n}\\). Check this is a homomorphism.\n\\end{proof}\n\n\\begin{definition}[rank]\\index{rank}\n  The cardinality of \\(S\\) is the \\emph{rank} of \\(F(S)\\), denoted by \\(\\operatorname{rk}(F(S))\\).\n\\end{definition}\n\n\\begin{corollary}\n  If \\(|S| = |T|\\) the \\(F(S) \\cong F(T)\\).\n\\end{corollary}\n\n\\begin{proof}\n  If \\(|S| = |T|\\) then there exists a bijection \\(\\phi: S \\to T\\). Consider\n  \\[\n    \\begin{tikzcd}\n      S \\ar[r] \\ar[dr, \"\\theta\"] & F(S) \\ar[d, dotted, \"\\overline \\theta\"] \\\\\n      & F(S)\n\\end{tikzcd}\n  \\]\n  where \\(\\overline \\theta\\) is a homomorphism by the universal property. Similarly we have \\(\\overline{\\theta^{-1}}: F(T) \\to F(S)\\) and \\(\\overline{\\theta^{-1}} \\compose \\overline \\theta: F(S) \\to F(S)\\) extends the identity map \\(S \\to F(S)\\) so must be the identity on \\(F(S)\\). Same for the other way so \\(\\overline \\theta\\) is an isomorphism.\n\\end{proof}\n\n\\begin{notation}\n  Write \\(F_n\\) for the isomorphism class of \\(F(S)\\) with \\(|S| = n\\).\n\\end{notation}\n\n\\begin{ex}\n  If \\(F_n \\cong F_m\\) then \\(n = m\\).\n\\end{ex}\n\n\\begin{corollary}\n  Every group is a quotient of a free group.\n\\end{corollary}\n\n\\begin{proof}\n  Given \\(G\\), consider \\(F(G)\\). By the universal property exists a homomorphism \\(\\pi: F(G) \\to G\\) extending the identity, so must be surjective.\n\\end{proof}\n\n\\begin{definition}\n  Let \\(G\\) be a group, \\(A \\subseteq G\\) a subset. Define \\(\\langle A\\rangle\\) to be the intersection of all subgroups containing \\(A\\), i.e.\\ the unique smallest subgroup containing \\(A\\).We also call it the subgroup generated by \\(A\\).\n\\end{definition}\n\n\\begin{definition}\n  \\(G\\) is \\emph{generated} by \\(A \\subseteq G\\) if \\(\\langle A \\rangle = G\\). Then \\(A\\) is a \\emph{generating set} of \\(G\\). \\(G\\) is \\emph{finitely generated} if exists a finite generating set of \\(G\\).\n\\end{definition}\n\n\\begin{notation}\n  Write \\(\\langle a_1, \\dots, a_n \\rangle\\) to mean \\(\\langle \\{a_1, \\dots, a_n\\} \\rangle\\).\n\\end{notation}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\Z_n, \\Z\\) can be generated by one element.\n  \\item \\(\\Z^n\\) can be generated by \\(\\geq n\\) elements.\n  \\item \\(F_2 = \\langle a, b \\rangle = \\langle a, ab \\rangle\\) so generating sets are not unique.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}\n  A group \\(F\\) is \\emph{freely generated} by \\(S \\subseteq F\\) if for any group \\(G\\) and any map \\(\\varphi: S \\to G\\), exists a unique homomorphism \\(\\tilde \\varphi: F \\to G\\) extending \\(\\varphi\\).\n\\end{definition}\n\n\\begin{lemma}\n  If \\(F\\) is freely generated by \\(S\\) then \\(F\\) is generated by \\(S\\).\n\\end{lemma}\n\n\\subsection{Subgroups of free groups}\n\nLet's see some examples of subgroups of free groups.\n\n\\begin{itemize}\n\\item Given any \\(e \\ne w \\in F_n\\), \\(\\langle w \\rangle \\cong \\Z\\).\n\\item Given \\(T \\subseteq S\\), \\(\\langle T \\rangle\\) is a free subgroup of \\(F(S)\\) of rank \\(|T|\\).\n\\item If \\(S = \\{a, b\\}\\), the set \\(\\{a^{-n} ba^n: n \\in \\N\\}\\) freely generates a subgroup of \\(F_2\\), so isomorphic to \\(F_\\infty\\) (exercise).\n\\end{itemize}\n\n\\begin{remark}\n  Subgroups of finitely generated groups are not necessarily finitely generated.\n\\end{remark}\n\nRevision of fundamental groups. See IID Algebraic Topology. Particularly relevant to this course is \\(\\pi_1(\\bigvee_{i = 1}^n S^1) = F_n\\), and a connected loop-free graph is contractible so has trivial \\(\\pi_1\\).\n\nIt is the fact that if \\(X\\) is sufficiently nice and \\(Y \\subseteq X\\) is closed simply connected, then collapsing \\(Y\\) to a piont does not alter \\(\\pi_1(X)\\). In particular, for graphs we can collapsing \\(T\\), a maximal spanning tree, to get a bouquet of circles. Since maximal spanning tree always exists (use axiom of choice if the graph is infinite), \\(\\pi_1\\) of a graph is a free group of rank equal to the number edges not in the maximal spanning tree.\n\nRecall the Galois correspondence between subgroups of \\(\\pi_1(X)\\) and covering spaces: we have a bijection between covering maps \\(p: (\\tilde X, \\tilde x_0) \\to (X, x_0)\\) and subgroups of \\(\\pi_1(X, x_0)\\).\n\nThus let \\(X = \\bigvee_{i = 1}^n S^1\\). For any \\(H \\leq \\pi_1(X) \\cong F_n\\), there is a covering space \\(\\overline X\\) with \\(\\pi_1(\\overline X) \\cong H\\). Since \\(\\overline X\\), being a cover of a graph, is a graph, we have \\(H\\) is free. This shows that every subgroup of a free group is free.\n\nWe work out the rank of \\(H\\) given its index in \\(F_n\\). The index of \\(H\\) in \\(F_n\\) is exactly the degree of the covering map \\(\\overline X \\to X\\), i.e.\\ the number of vertices of \\(\\overline X\\). Each vertex of \\(\\overline X\\) has degree \\(2n\\) so the number of edges in \\(\\overline X\\) is \\([F_n: H] \\cdot 2n \\cdot \\frac{1}{2} = [F_n : H] \\cdot n\\). To work out the number of edges not in a maximal spanning tree, use the graph theoretic fact that a tree on \\(n\\) vertices has exactly \\(n - 1\\) edges (exercise), so the number of edges not in a maximal spanning tree is\n\\[\n  [F_n: H] \\cdot n - [F_n : H] - 1 = (n - 1) [F_n : H] + 1.\n\\]\n\n\\begin{theorem}[Nielsen-Schreier]\\index{Nielsen-Schreier formula}\n  Every subgroup of a free group is free and if the subgroup has finite index then\n  \\[\n    \\rk(H) = [F_n: H] (\\rk(F_n) - 1) + 1.\n  \\]\n\\end{theorem}\nMnemonic:\n\\[\n  \\rk(H) - 1 = (\\rk(F_n) - 1) [F_n : H].\n\\]\n\n\\begin{eg}\n  A degree \\(2\\) cover of \\(S^1 \\vee S^1\\) realises \\(F_3\\) as a subgroup of index \\(2\\) in \\(F_2\\).\n\\end{eg}\n\nThe group of \\emph{covering transformation}, or \\emph{deck transformation} of a cover is the group of isomorphisms \\(\\overline X \\to \\overline X\\).\n\nA cover is \\emph{normal}\\index{normal cover} if for any two lifts of the basepoint \\(x_0 \\in X\\), there is a covering transformation of \\(\\overline X\\) sending one to the other.\n\nNormal covering spaces correspond to normal subgroups of \\(\\pi_1(X)\\). If the cover is normal then the group of covering transformations is isomorphic to \\(\\pi_1(X)\\) quotiented by the corresponding subgroup.\n\n\\begin{eg}\n  In the previous example we have \\(F_3 \\normal F_2\\). We can have a nonnormal index 3, and a normal one.\n\\end{eg}\n\n\\section{Group presentations and constructions}\n\n\\begin{definition}[normal closure]\\index{normal closure}\n  The \\emph{normal closure} of a subset \\(A \\subseteq G\\), denoted \\(\\langle\\langle A\\rangle\\rangle\\), is the unique smallest normal subgroup of \\(G\\) containing \\(A\\).\n\\end{definition}\n\nGiven a free group \\(F(S)\\) and \\(R \\subseteq F(S)\\), we write \\(\\langle S|R \\rangle\\) for the group \\(F(S)/\\langle\\langle R\\rangle\\rangle\\). \\(R\\) and \\(S\\) are called \\emph{generators} and \\emph{relators} respectively.\n\n\\begin{definition}[group presentation]\\index{group presentation}\n  A \\emph{presentation} of a group \\(G\\) is an isomorphism of \\(G\\) with a group of the form \\(\\langle S|R \\rangle\\).\n\n  \\(G\\) is \\emph{finitely presented} if it admits a presentation \\(\\langle S|R \\rangle\\) with \\(S, R\\) finite.\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(R = \\emptyset\\) then \\(\\langle S|R \\rangle \\cong F(S)\\).\n  \\item \\(\\langle a|a^n \\rangle \\cong \\Z_n\\).\n  \\item \\(\\langle a, b|aba^{-1}b^{-1}\\rangle\\) is a presentation of \\(\\Z^2\\): let \\(\\Z^2 = \\{(c^n, d^m): n, m \\in \\Z\\}\\). We have a homomorphism\n    \\begin{align*}\n      \\varphi: F(a, b) &\\to \\Z^2 \\\\\n      a &\\mapsto c \\\\\n      b &\\mapsto d\n    \\end{align*}\n    Need to show \\(\\ker \\varphi = \\langle\\langle aba^{-1}b^{-1} \\rangle\\rangle\\). \\(\\supseteq\\) is clear since \\(\\Z^2\\) is abelian so have \\(F(a, b)/\\langle\\langle aba^{-1}b^{-1} \\rangle\\rangle \\surj F(a, b)/\\ker \\varphi\\). The domain is a 2-generated abelian group. But the only 2-generated abelian group that surjects onto \\(\\Z^2\\) is itself.\n  \\item More generally a finitely generated abelian group is always finitely presented.\n  \\item The same is true for nilpotent groups. Recall that \\(G\\) is \\emph{nilpotent}\\index{nilpotent} if the \\emph{lower central series}\\index{lower central series} of \\(G\\) terminates in a finite number of steps. The lower central series of \\(G\\) is\n    \\[\n      G_0 = G, G_{i + 1} = [G_i, G].\n    \\]\n  \\item \\(\\langle a, b| aba^{-1}b^{-2}, a^{-2}b^{-1}ab \\rangle = \\{1\\}\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item It is difficult to tell which group is given by a particular presentation. Indeed there does not exist an algorithm that, upon input of a presentation, can determine whether the corresponding group is trivial. The is the \\emph{word problem}, introduced by Dehn in early 20th century. The classes of groups for which it does have a solution are often geometry.\n  \\item There are uncountably many isomorphism classes of finitely generated groups (even 2-generated). For reference, see de la Harpe \\emph{Geometric Group Theory} IIIB. But there are only countably many isomorphism classes of finitely presented groups.\n  \\end{enumerate}\n\\end{remark}\n\nThe notion of finite presentation makes sense without fixing a pecific surjection of a free group.\n\n\\begin{theorem}\n  Given a not necessarily finite presentation \\(\\langle (s_j)_{j \\in J} | (r_i)|_{r \\in I} \\rangle\\) of a finitely presented group \\(G\\), there exists a finite subset \\(J_0 \\subseteq J\\) and a finite set \\((\\tilde r_i)_{i \\in I_0}\\) of elements of the free group \\(F((s_j)_{j \\in J_0})\\) such that \\(\\langle (s_j)_{j \\in J_0} | (\\tilde r_i)_{i \\in I_0} \\rangle\\) is a finite presentation of \\(G\\).\n\\end{theorem}\n\n\\begin{proof}[``Proof'']\n  de la Harpe has a proof but it seems to be wrong.\n\\end{proof}\n\nOur aim is to prove that finite index subgroups of finitely generated (resp finitely presented) groups are finitely generated (resp finitely presented).\n\n\\begin{definition}[Schreier transversal]\\index{Schreier transversal}\n  Let \\(F(S)\\) be a free group and \\(H \\leq F(S)\\) a subgroup. A (right) \\emph{Schreier transversal} for \\(H\\) in \\(F(S)\\) is a set \\(J\\) of reduced words such that each right coset of \\(H\\) in \\(G\\) contains exactly one word of \\(J\\), called a \\emph{representative} of this class, and all initial segments of these words are also in \\(J\\).\n\n  For \\(g \\in F(S)\\), denote by \\(\\overline g\\) the element of \\(J\\) such that \\(Hg = H \\overline g\\).\n\\end{definition}\n\n\\begin{theorem}\n  For any \\(H \\leq F(S)\\), there a Schreier transversal \\(J\\). Moreover \\(H\\) is freely generated by the set\n  \\[\n    \\{ts(\\overline{ts})^{-1}: t \\in J, s \\in S \\text{ and } ts(\\overline{ts})^{-1} \\ne 1\\}.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Take \\(X = \\bigvee_S S^1\\) so \\(\\pi_1X = F(S)\\). Take \\(\\overline X\\) to be the cover corresponding to \\(H \\leq F(S)\\). The vertices of \\(\\overline X\\) correspond to cosets of \\(H\\) in \\(F(S)\\) and choosing a path from a fixed basepoint to a vertex gives us a coset representative for that coset. Pick a maximal spanning tree \\(T \\subseteq \\overline X\\). Choosing the unique path to each vertex in \\(T\\) gives us coset representatives with initial segments that are also such paths. Since \\(H \\cong \\pi_1\\overline X\\) and it is freely generated by the set of loops with exactly one edge not in \\(T\\), this generating set is of the required form.\n\\end{proof}\n\n\\begin{remark}\n  The argument also shows that the set of Schreier transversals for \\(H\\) in \\(F(S)\\) is in bijection with the set of maximal spanning trees in \\(\\overline X\\).\n\\end{remark}\n\nWrite \\(\\gamma(t, s) = ts(\\overline{ts})^{-1}\\). Explicitly, given \\(h \\in H\\) written as \\(s_1s_2 \\cdots s_n\\) where \\(s_i \\in S \\cup S^{-1}\\), we can write\n\\[\n  h = \\gamma(1, s_1) \\gamma(\\overline s_1, s_2) \\cdots \\gamma(\\overline{s_1 \\cdots s_{i - 1}}, s_i) \\cdots \\gamma(\\overline{s_1 \\cdots s_{n - 1}}, s_n)\n\\]\n(use \\(\\gamma(t, s^{-1}) = \\gamma(\\overline{ts^{-1}}, s)^{-1}\\)).\nThis is the \\emph{Reidemeister-Schreier rewriting process}\\index{Reidemeister-Schreier rewriting process}.\n\n\\begin{theorem}\n  Let \\(G\\) be a group with presentation \\(\\langle S| R\\rangle\\) and let \\(\\varphi: F(S) \\to G\\) correspond to this presentation. Let \\(G_1 \\leq G\\) and let \\(H\\) be the subgroup of \\(F(S)\\) containing \\(\\ker \\varphi\\) such that \\(\\varphi(H) = G_1\\). Then \\(G_1\\) has presentation\n  \\[\n    \\langle \\gamma(t, s): t \\in J, s \\in S, \\gamma(t, s) \\ne 1| trt^{-1}: t \\in J, r \\in R \\rangle\n  \\]\n  where \\(J\\) is a Schreier transversal for \\(H\\) in \\(F(S)\\).\n\\end{theorem}\n\n\\begin{proof}\n  Have \\(G_1 = H/\\langle\\langle R\\rangle\\rangle^{F(S)}\\) and would like to find some possibly larger set of words \\(R'\\) in \\(H\\) such that \\(G_1 = H/\\langle\\langle R' \\rangle\\rangle^H\\). Let \\(H\\) be generated freely by \\(\\gamma(t, s)\\)'s. The subgroup \\(\\langle\\langle R\\rangle\\rangle^{F(S)}\\) is generated by \\(\\{grg^{-1}: g \\in F(S), r \\in R\\}\\), and writing each \\(g\\) as \\(g = h_g \\overline g\\) where \\(h_g \\in H, \\overline g \\in J\\), we have\n  \\[\n    grg^{-1}\n    = (h_g \\overline g) r (h_g \\overline g)^{-1}\n    = h_g (\\overline g r \\overline g^{-1}) h_g^{-1}\n  \\]\n  and so can take \\(R' = \\{trt^{-1}: t \\in J, r \\in R\\}\\). Thus \\(G_1\\) has the required presentation.\n\\end{proof}\n\n\\begin{corollary}\n  Any subgroup of finite index in a finitely generated (resp. finitely presented) group is itself finitely generated (resp. finitely generated).\n\\end{corollary}\n\n\\begin{proof}\n  If \\([G: G_1] < \\infty\\) then \\([F(S): H] < \\infty\\) so \\(J\\) is finite.\n\\end{proof}\n\n\\subsection{Free product}\n\nOne way to create new finitely generated/presented groups from old one is via free products. Given two groups \\(A, B\\), a \\emph{normal form}\\index{normal form} is an expression of the form \\(g_1g_2 \\cdots g_n\\) where \\(n \\geq 0\\) such that if \\(n = 0\\), take the identity element, \\(g_i \\in (A \\setminus \\{1\\}) \\amalg (B \\setminus \\{1\\})\\) and consecutive elements \\(g_i, g_{i + 1}\\) do not lie in the same group. \\(n\\) is the \\emph{length of normal form}. We define multiplication of normal forms inductively by\n\\begin{itemize}\n\\item \\((g_1 \\cdots g_n) \\cdot 1 = 1 \\cdot (g_1 \\cdots g_n) = g_1 \\cdots g_n\\).\n\\item For \\(n, m \\geq 1\\), set\n  \\[\n    (g_1 \\cdots g_n)(h_1 \\cdots h_m) =\n    \\begin{cases}\n      g_1 \\cdots g_nh_1 \\cdots h_m & \\text{if \\(g_n, h_1\\) in different groups} \\\\\n      g_1 \\cdots g_{n - 1}kh_2 \\cdots h_m & \\text{if \\(g_n, h_1\\) in same group, \\(g_nh_1 = k \\ne 1\\)} \\\\\n      (g_1 \\cdots g_{n - 1})(h_2 \\cdots h_m) & \\text{if \\(g_n, h_1\\) in same group, \\(g_nh_1 = 1\\)}\n    \\end{cases}\n  \\]\n\\end{itemize}\n\n\\begin{definition}[free product]\\index{free product}\n  The set of normal forms with this multiplication forms a group \\(A * B\\), called the \\emph{free product} of \\(A\\) and \\(B\\).\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item The groups \\(A, B\\) embed naturally into \\(A * B\\).\n  \\item If \\(A, B \\leq G\\) such that any \\(g \\ne 1\\) in \\(G\\) can be represented in a unique way as a product \\(g = g_1 \\cdots g_n\\) with \\(g_i \\in A \\cup B \\setminus \\{1\\}\\) and consecutive \\(g_i, g_{i + 1}\\) not in the same group, then \\(G = A * B\\).\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{theorem}\n  If \\(A = \\langle S_A|R_A \\rangle, B = \\langle S_B|R_B \\rangle\\) and \\(S_A \\cap S_B = \\emptyset\\) then\n  \\[\n    A * B = \\langle S_A \\cup S_B| R_A \\cup R_B \\rangle.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(\\varphi: F(S_A) \\to A, \\psi: F(S_B) \\to B\\) be the homomorphisms with \\(\\ker \\varphi = \\langle\\langle R_A \\rangle\\rangle^{F(S_A)}, \\ker \\psi = \\langle\\langle R_B \\rangle\\rangle^{F(S_B)}\\). Let \\(\\theta: F(S_A \\cup S_B) \\to A * B\\) be the homomorphism coinciding with \\(\\varphi\\) on \\(S_A\\) and \\(\\psi\\) on \\(S_B\\). Need to show \\(\\ker \\theta = \\langle\\langle R_A \\cup R_B \\rangle\\rangle^{F(S_A \\cup S_B)}\\). \\(\\supseteq\\) is trivial. For \\(\\subseteq\\), consider \\(g = g_1 \\cdots g_n \\in \\ker \\theta\\) in normal form (using \\(F(S_A \\cup S_B) = F(S_A) * F(S_B)\\)). Then\n  \\[\n    \\theta(g) = \\theta(g_1) \\cdots \\theta(g_n) = 1\n  \\]\n  in \\(A * B\\). Thus exists \\(i\\) such that \\(\\theta(g_i) = 1\\), so \\(g_i \\in \\ker \\varphi\\) or \\(g_i \\in \\ker \\psi\\). Proceed by induction.\n\\end{proof}\n\n\\begin{eg}\n  \\(D_\\infty = \\langle a, b| a^2 = 1, a^{-1}ba = b^{-1} \\rangle\\). It is the automorphism group of the graph \\(C_\\infty\\), where \\(a\\) is a reflection (say about the origin) and \\(b\\) is a translation. Then \\(D_\\infty\\) is generated by \\(a\\) and \\(c = ba\\), both have order \\(2\\). Can check (by acting on \\(C_\\infty\\)'s vertices and edges) that \\((ca)^n, (ca)^n c, a(ca)^n c, a (ca)^n\\) give different elements of \\(D_\\infty\\). By remark above\n  \\[\n    D_\\infty\n    = \\langle a, c| a^2, c^2\\rangle\n    = \\langle a|a^2 \\rangle * \\langle c|c^2 \\rangle\n    = \\Z_2 * \\Z_2\n  \\]\n\\end{eg}\n\n\\begin{remark}\n  \\(\\Z_2 * \\Z_2\\) is the only free product of non-trivial groups that does not contain a non-abelian free group. For example \\(\\Z_2 * \\Z_3 \\supseteq [\\Z_2, \\Z_3] \\cong F_2\\).\n\\end{remark}\n\n\\subsection{Group actions}\n\n\\begin{theorem}[ping-pong lemma]\\index{ping-pong lemma}\n  Let \\(G\\) act on \\(X\\). Let \\(H_1, H_2 \\leq G\\) such that \\(|H_1| \\geq 3, |H_2| \\geq 2\\) and let \\(H = \\langle H_1, H_2 \\rangle\\). Suppose there exists nonempty \\(X_1, X_2 \\subseteq X\\) with \\(X_2 \\nsubseteq X_1\\) such that\n  \\begin{align*}\n    h(X_2) &\\subseteq X_1 \\text{ for all } h \\in H_1 \\setminus \\{e\\} \\\\\n    h(X_1) &\\subseteq X_2 \\text{ for all } h \\in H_2 \\setminus \\{e\\}\n  \\end{align*}\n  then \\(H \\cong H_1 * H_2\\).\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(w\\) be a nonempty reduced word in the alphabet \\(H_1\\setminus\\{e\\} \\amalg H_2 \\setminus \\{e\\}\\). Need to show that the element defined by \\(w\\) in \\(G\\) is not \\(e\\). Cases:\n  \\begin{itemize}\n  \\item if \\(w = a_1b_1 a_2b_2 \\cdots a_k\\) with \\(a_i \\in H_1 \\setminus \\{e\\}, b_i \\in H_2 \\setminus \\{e\\}\\), then\n    \\[\n      w(X_2) = a_1b_1 \\cdots a_k(X_2) \\subseteq a_1b_1 \\cdots b_{k - 1}(X_1)\n      \\subseteq \\cdots \\subseteq a_1(X_2) \\subseteq X_1.\n    \\]\n    As \\(X_2 \\nsubseteq X_1\\), \\(w \\ne e\\) in \\(G\\).\n  \\item if \\(w = b_1a_2b_2 \\cdots b_k\\), then let \\(a \\in H_1 \\setminus \\{e\\}\\) we have \\(a^{-1}wa \\ne e\\) by above.\n  \\item if \\(w = a_1b_1 \\cdots a_kb_k\\) take \\(a \\in H_1 \\setminus \\{e, a_1\\}\\) and \\(a^{-1}wa \\ne e\\).\n  \\item if \\(w = b_1a_2 \\cdots a_k\\), take \\(a \\in H_1 \\setminus \\{e, a_k\\}\\) and use \\(awa^{-1}\\).\n  \\end{itemize}\n\\end{proof}\n\n\\begin{eg}\n  Let \\(\\SL_2(\\Z)\\) act on \\(\\R^2\\) in the usual way. Consider\n  \\begin{align*}\n    H_1 &= \\{\n          \\begin{pmatrix}\n            1 & 0 \\\\\n            2n & 1\n          \\end{pmatrix}\n                 : n \\in \\Z \\}\n                 = \\langle\n                 \\begin{pmatrix}\n                   1 & 0 \\\\\n                   2 & 1\n                 \\end{pmatrix}\n                       \\rangle\n                       \\cong \\Z \\\\\n    H_2 &= \\{\n          \\begin{pmatrix}\n            1 & 2n \\\\\n            0 & 1\n          \\end{pmatrix}\n                : n \\in \\Z\\}\n                = \\langle\n                \\begin{pmatrix}\n                  1 & 2 \\\\\n                  0 & 1\n                \\end{pmatrix}\n                      \\rangle\n                      \\cong \\Z\n  \\end{align*}\n  and\n  \\begin{align*}\n    X_1 &= \\{\n        \\begin{pmatrix}\n          x \\\\\n          y\n        \\end{pmatrix}\n    : |x| < |y|\\} \\\\\n    X_2 & = \\{\n          \\begin{pmatrix}\n            x \\\\\n            y\n          \\end{pmatrix}\n    : |x| > |y|\\}\n  \\end{align*}\n  If \\(|x| > |y|\\) then\n  \\[\n    |2nx + y| \\geq |2n| \\cdot |x| - |y| \\geq 2 |x| - |y| > |x|\n  \\]\n  so the two subgroups map the subsets into each other. Thus by ping-pong lemma\n  \\[\n    \\langle H_1, H_2 \\rangle \\cong F_2 \\leq \\SL_2(\\Z).\n  \\]\n  Check this subgroup has finite index.\n\\end{eg}\n\n\\paragraph{Amalgamated free product}\n\nSuppose \\(A \\leq G, B \\leq H\\) and there is an isomorphism \\(\\varphi: A \\to B\\). Then the \\emph{free product of \\(G\\) and \\(H\\) with amalgamation \\(A\\) and \\(B\\) (via \\(\\varphi\\))}\\index{free product with amalgamation} is\n\\[\n  G *_A H = G * H/ \\langle\\langle \\varphi(a)a^{-1}: a \\in A \\rangle\\rangle.\n\\]\n\nThe intuition is to glue \\(G\\) and \\(H\\) along \\(A\\). \\(G, H\\) embed as subgroups and elements in \\(G *_A H\\) admits normal forms. It is related to Seifert-van Kampen theorem.\n\n\\begin{eg}\n  \\(\\SL_2(\\Z) = \\Z_4 *_{\\Z_2} \\Z_6\\), see de la Harpe.\n\\end{eg}\n\n\\subsection{HNN extension}\n\nSuppose \\(A, B \\leq G\\), \\(\\varphi: A \\to B\\) is an isomorphism. We want \\(A\\) and \\(B\\) to be isomorphic via conjugation, but it might not be the case in \\(G\\) so we extend \\(G\\) to a larger group. The \\emph{HNN extension}\\index{HNN extension} of \\(G\\) (with \\(A, B, \\varphi\\)) is\n\\[\n  G *_\\varphi = G * \\langle t \\rangle / \\langle\\langle t^{-1}at\\varphi(a)^{-1}: a \\in A \\rangle\\rangle.\n\\]\n\n\\(G\\) embed in \\(G *_\\varphi\\) and its elements admit normal forms. It has application to calculation of fundamental groups of surface bundles.\n\n\\subsection{Semidirect product}\n\n\\(G\\) is the \\emph{semidirect product of \\(N\\) by \\(H\\)}\\index{semidirect product} of \\(N \\normal G, H \\leq G\\), \\(N \\cap H = \\{e\\}\\) and \\(G = NH\\). Write \\(N \\rtimes H = G\\). Equivalently, if \\(H \\leq G\\) and exists a homomorphism \\(\\varphi: G \\to H\\) (such that the inclusion is a section) such that \\(\\ker \\varphi = N\\), then \\(G = N \\rtimes H\\), i.e.\\ the short exact sequence of groups\n\\[\n  \\begin{tikzcd}\n    1 \\ar[r] & N \\ar[r] & G \\ar[r] & H \\ar[r] & 1\n  \\end{tikzcd}\n\\]\nsplits.\n\nAlternatively, given two groups \\(H\\) and \\(N\\) and a homomorphism \\(\\alpha: H \\to \\aut(N)\\), we can construct \\(G = N \\rtimes_\\alpha H\\) as follow: as a set \\(G = N \\times H\\). The multiplication is defined by\n\\[\n  (n_1, h_1) (n_2, h_2) = (n_1 \\alpha(h_1)(n_2), h_1h_2).\n\\]\nThe subgroups \\(N \\times \\{e\\}, \\{e\\} \\times H\\) satisfiy the conditions above. Conversely, given subgroups \\(N\\) and \\(H\\), we can recover \\(\\alpha: H \\to \\aut(N), \\alpha(h)(n) = hnh^{-1}\\).\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Direct product \\(H \\times H\\).\n  \\item \\(D_{2n} \\cong \\Z_n \\rtimes \\Z_2\\).\n  \\item \\(\\pi_1(\\text{Klein bottle}) \\cong \\Z \\rtimes \\Z\\) where the action is the only nontrivial automorphism.\n  \\end{enumerate}\n\\end{eg}\n\nMore generally, a \\emph{group extension}\\index{group extension} is a group \\(G\\) given by\n\\[\n  \\begin{tikzcd}\n    1 \\ar[r] & N \\ar[r] & G \\ar[r] & H \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nWe say \\(G\\) is the \\emph{extension of \\(N\\) by \\(H\\)}.\n\n\\begin{note}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(H\\) is free then \\(G\\) splits.\n  \\item Not all extensions split: \\(2\\Z \\to \\Z \\to \\Z_2\\).\n  \\end{enumerate}\n\\end{note}\n\n\\subsection{Wreath product}\n\n\\begin{definition}[wreath product]\\index{wreath product}\n    The \\emph{wreath product} of \\(G\\) and \\(H\\), \\(G \\wr H\\), is \\(\\bigoplus_H G \\rtimes H\\) where, thinking of \\(\\bigoplus_H G\\) as the set of finitely supported function \\(H \\to G\\), the action of \\(H\\) is given by\n    \\[\n      h(f)(h_1) = f(h^{-1}h_1).\n    \\]\n\\end{definition}\n\n\\begin{eg}\n  Lamplight group\\index{lamplight group} \\(\\Z_2 \\wr \\Z\\), which is not finitely presented. An element \\(f \\in \\bigoplus_\\Z \\Z_2\\) is a function \\(\\Z \\to 0, 1\\) with compact support and the action of \\(\\Z\\) is shifting.\n\\end{eg}\n\n\\begin{theorem}[Kaloujnine-Krasner]\n  If \\(D\\) is a group and \\(Q\\) is a finite group then \\(D \\wr Q\\) contains an isomorphic copy of every extension of \\(D\\) by \\(Q\\).\n\\end{theorem}\n\n\\begin{proof}\n  If \\(G\\) is an extension of \\(D\\) by \\(Q\\) then let \\(\\pi: G \\to Q\\) where \\(\\ker \\pi = D\\). We are going to define \\(\\varphi: G \\to D \\wr Q\\) and show its an injective homomorphism. Choose transversal for \\(D\\) in \\(G\\), writing it as a map \\(T: Q \\to G\\). For \\(a \\in G\\), define \\(f_a: Q \\to D\\) by\n  \\[\n    f_a(x) = T(x)^{-1}a T(\\pi(a^{-1}) x)\n  \\]\n  and define \\(\\varphi(a) = (f_a, \\pi(a))\\). To show this is a homomorphism, if \\(a, b \\in G\\) then\n  \\begin{align*}\n    (f_a \\cdot \\pi(a)f_b)(x)\n    &= f_a(x) f_b(\\pi(a)^{-1}x) \\\\\n    &= T(x)^{-1} a \\underbrace{T(\\pi(a^{-1})x) \\cdot T(\\pi(a)^{-1}x)^{-1}}_{= e} b T(\\pi(b^{-1}) \\pi(a)^{-1} x) \\\\\n    &= T(x)^{-1} ab T(\\pi((ab)^{-1}) x) \\\\\n    &= f_{ab}(x)\n  \\end{align*}\n\n  For injectivity, suppose \\(a \\in \\ker \\varphi\\) then \\(\\pi(a) = e\\) so \\(a \\in D\\) and \\(e = f_a(x) = T(x)^{-1}aT(x)\\) so \\(a = e\\).\n\\end{proof}\n\n\\begin{remark}\n  The proof works verbatim for not necessarily finite groups \\(G\\) and \\(H\\) by using \\(\\prod_H G \\rtimes H\\).\n\\end{remark}\n\n\\subsection{Sketch of Bass-Serre theory}\n\nReference: J-P.\\ Serre, Trees.\n\n\\begin{theorem}\n  Let \\(G = G_1 *_A G_2\\). Then \\(G\\) acts without inversion of edges on a tree \\(X\\) such that the quotient graph \\(G \\backslash X\\) is a segment. Moreoever this segment can be lifted to one in \\(X\\) such that the stabilisers of its vertices are \\(G_1, G_2\\) and stabiliser of the edge is \\(A\\).\n\\end{theorem}\n\n\\begin{proof}[Sketch proof]\n  Let \\(X^0 = G/G_1 \\amalg G/G_2\\) and the positively oriented edges \\(X_+^1 = G/A\\). It is well-defined since \\(A = G_1 \\cap G_2\\). Check \\(G\\) acts on \\(X\\) via left multiplication.\n\n  \\(X\\) is connected: suffices to show \\(gG_1\\) is connected to \\(G_1\\). Express \\(g\\) as \\(g_1g_2 \\cdots g_n\\) with \\(g_i \\in G_1 \\amalg G_2\\) and no consecutive elements in the same \\(G_i\\). Suppose \\(g_n \\in G_2\\), then \\(gG_2 = g_1\\cdots g_{n - 1}G_2\\). Proceed by induction.\n\n  Acyclicity follows from the uniqueness of normal form for almagmated free product.\n\\end{proof}\n\nSerre gave a converse to the statement: if exists such an action then the group is an amalgmated product.\n\n\\begin{table}[h]\n  \\centering\n  \\begin{tabular}{p{5cm}|p{5cm}}\n    group \\(G\\) & \\(G\\) acting on a graph without inversion of edges \\\\ \\hline\n    \\(G_1 *_A G_2\\) & \\(G \\backslash X\\) segment \\\\ \\hline\n    \\(G = H *_\\varphi\\) & \\(G \\backslash X\\) loop \\\\ \\hline\n    fundamental group of a graph of groups \\(\\pi_1(G, Y)\\) & \\(G \\backslash X = Y\\) a graph\n  \\end{tabular}\n  \\caption{Correspondence}\n\\end{table}\n\nConseuquence: Kurosh subgroup theorem: if \\(G = A * B\\) then \\(H \\leq G\\) has the form \\(H = F(S) * (* \\text{conjugate of subgroups of A} * ()\\)\n\n\\section{Cayley graphs}\n\nWe'll focus on finitely generated groups.\n\n\\begin{definition}[Cayley graph]\\index{Cayley graph}\n  Let \\(G = \\langle S\\rangle\\), \\(S \\subseteq G\\) finite. The \\emph{Cayley graph} of \\(G\\) with respect to \\(S\\) \\((\\Cay(G, S))\\) is given by\n  \\begin{align*}\n    V(\\Cay(G, S)) &= G \\\\\n    E((\\Cay(G, S)) &= \\{(g, gs): g \\in G, s \\in S\\}.\n  \\end{align*}\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{itemize}\n  \\item \\(\\Z^2, S = \\{(1, 0), (0, 1)\\}\\). Grid\n  \\item In fact we don't have to require \\(S\\) generating \\(G\\). \\(\\Z^2, S = \\{(1, 0)\\}\\). Parallel lines.\n  \\end{itemize}\n\\end{eg}\n\nThe Cayley graph has the following properties:\n\\begin{enumerate}\n\\item \\(\\Cay(G, S)\\) is a \\(2|S|\\)-regular graph.\n\\item \\(\\Cay(G, S)\\) is connected if and only if \\(\\langle S\\rangle = G\\).\n\\item Relators in elements of \\(S\\) give rise to cycles.\n\\item When \\(\\langle S\\rangle = G\\), paths from \\(e\\) to \\(g\\) give words in \\(S\\) representing \\(g\\).\n\\item \\(\\Cay(G, S)\\) allows us to view \\(G\\) as a metric space, with \\emph{word metric}\\index{word metric}\n  \\[\n    d_S(g, h) = \\min\\{\\text{length of path from \\(g\\) to \\(h\\) in \\(\\Cay(G, S)\\)}\\}.\n  \\]\n  Define \\emph{word length} to be \\(|g| = d_S(e, g)\\). Note \\(d_S(g, h) = |g^{-1}h|\\).\n\\item It follows that \\(G\\) acts on \\(\\Cay(G, S)\\) via left-multiplication by isometry.\n\\end{enumerate}\n\n\\begin{theorem}\n  \\(\\Cay(F(S), S)\\) is a tree.\n\\end{theorem}\n\nLet \\(\\overline X\\) be a covering space of \\(X = \\bigvee_S S^1\\), corresponding to \\(N \\normal F(S)\\). Then \\(\\overline X\\) is exactly \\(\\Cay(F(S)/N, \\pi(S))\\) where \\(\\pi: F(S) \\to F(S)/N\\) is the quotient map.\n\n\\begin{definition}[quasi-isometric embedding, quasi-isometry]\\index{quasi-isometric embedding}\\index{quasi-isometry}\n  Let \\((X, d_X), (Y, d_Y)\\) be metric spaces. A map \\(f: X \\to Y\\) is a \\emph{quasi-isometric embedding} if exists \\(\\lambda \\geq 1, C \\geq 0\\) such that for all \\(a, b \\in X\\),\n  \\[\n    \\frac{1}{\\lambda} d_X(a, b) - C \\leq d_Y(f(a), f(b)) \\leq \\lambda d_X(a, b) + C.\n  \\]\n\n  \\(f\\) is a \\emph{quasi-isometry} if in addition exists \\(D \\geq 0\\) such that for all \\(y \\in Y\\) exists \\(x \\in X\\) such that \\(d_Y(f(x), y) \\leq D\\). Write \\(X \\simeq_{\\mathrm{QI}} Y\\) and we usually say \\((\\lambda, C, D)\\) is a quasi-isometry.\n\\end{definition}\n\nQuasi-isometry preserves large-scale structure of a space.\n\n\\begin{proposition}\n  Quasi-isometry is an equivalence relation on metric spaces.\n\\end{proposition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item A non-empty bounded metric space is quasi-isometric to a point. In particular all finite groups have Cayley graphs quasi-isometric to a point.\n  \\item \\(\\R \\times [0, 1] \\simeq_{\\mathrm{QI}} \\R\\).\n  \\item \\(\\Cay(\\Z, S) \\simeq_{\\mathrm{QI}} \\R\\).\n  \\item \\(\\Cay(\\Z^n, S) \\simeq_{\\mathrm{QI}} \\R^n\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{eg}\n  Cayley graph cannot determine the group. For example \\(C_4 \\ncong C_2 \\times C_2\\) but taking \\(S\\) to be the set of all elements, both Cayley graphs are the complete graph on four vertices.\n\n  In fact Cayley graph doesn't even determine the group with respect to a minimal generating set. For example \\(C_2 \\times C_3 = \\langle (1, 0), (0, 1) \\rangle, S_3 = \\langle (12), (123) \\rangle\\). The resulting Cayley graphs are isomorphic as undirected graphs but nonisomorphic as directed graphs. \n\n  On the other hand we can obtain nonisomorphic Cayley graphs of \\(G\\) by choosing different generating sets. For example \\(C_2 \\times C_3 = \\langle(1, 0), (0, 1)\\rangle = \\langle (1, 1), (1, 0) \\rangle\\).\n\\end{eg}\n\n\\begin{eg}\n  3 regular trees \\(T_3 \\cong T_4\\) by contracting edges (graph)\n\\end{eg}\n\n\\begin{eg}\n  On the other hand, by using quasi-isomorphism invariants we can show some Cayley graphs are not isomorphic.\n  \\begin{enumerate}\n  \\item boundedness is an invariant so for example \\(\\R \\ncong_{\\mathrm{QI}} *\\).\n  \\item \\(\\R \\ncong_{\\mathrm{QI}} [0, \\infty)\\): suppose \\(\\varphi: \\R \\to [0, \\infty)\\) is a quasi-isomorphism \\((\\lambda, C, D)\\). Then \\(\\varphi(t), \\varphi(-t) \\to \\infty\\) as \\(t \\to \\infty\\). For any \\(x \\in [0, \\infty)\\), let\n    \\begin{align*}\n      M_x &= \\max \\{n \\in \\Z: \\varphi(n) < x\\} \\\\\n      N_x &= \\min \\{n \\in \\Z: \\varphi(n) < x\\} \n    \\end{align*}\n    They exist because for all \\(x \\in [0, \\infty)\\), there are only finitely many \\(n \\in \\Z\\) with \\(\\varphi(n) < x\\). We thus have\n    \\begin{align*}\n      \\varphi(M_x) &< x \\leq \\varphi(M_x + 1) \\\\\n      \\varphi(N_x) &< x \\leq \\varphi(N_x - 1)\n    \\end{align*}\n    Since \\(d_\\R(M_x, M_x + 1) = d_\\R(N_x, N_x + 1)\\),\n    \\begin{align*}\n      d_{[0, \\infty)}(\\varphi(M_x), \\varphi(N_x))\n      &\\leq d_{[0, \\infty)}(\\varphi(M_x), x) + d_{[0, \\infty)}(x, \\varphi(N_x)) \\\\\n      &\\leq d_{[0, \\infty)}(\\varphi(M_x), \\varphi(M_x + 1)) + d_{[0, \\infty)}(\\varphi(N_x - 1), \\varphi(N_x)) \\\\\n      &\\leq (\\lambda \\cdot 1 + C) + (\\lambda \\cdot 1 + C) \\\\\n      &\\leq 2 \\lambda + 2C\n    \\end{align*}\n    which is bounded independent of \\(x\\). But \\(d_\\R(M_x, N_x) \\to \\infty\\) as \\(x \\to \\infty\\) as more and more elements will land in \\([0, x)\\) as \\(x \\to \\infty\\). Absurd.\n  \\item \\(\\R^m \\ncong_{\\mathrm{QI}} \\R^n\\) for \\(m \\ne n\\).\n  \\item \\(T_3 \\ncong_{\\mathrm{QI}} \\R\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{proposition}\n  Let \\(G\\) be a finitely generated group, \\(S, S'\\) two finite generating sets of \\(G\\). Then \\(\\Cay(G, S) \\cong_{\\mathrm{QI}} \\Cay(G, S')\\).\n\\end{proposition}\n\n\\begin{proof}\n  Consider the identity map \\(\\varphi = \\id: |\\Cay(G, S)| \\to |\\Cay(G, S')|\\). Let\n  \\begin{align*}\n    \\lambda &= \\max \\{|a|_{S'}: a \\in S\\} \\\\\n    \\lambda' &= \\max \\{|a|_{S}: a \\in S'\\}\n  \\end{align*}\n  then\n  \\begin{align*}\n    d_{S'}(\\varphi(g), \\varphi(h)) &\\leq \\lambda d_S(g, h) \\\\\n    d_S(g, h) &\\leq \\lambda' d_{S'}(\\varphi(g), \\varphi(h))\n  \\end{align*}\n  Set \\(\\lambda = \\max{\\lambda, \\lambda'}\\).\n\\end{proof}\n\nRecall that\n\\begin{enumerate}\n\\item a metric space is \\emph{proper} if all closed balls are compact.\n\\item a metric space is \\emph{geodesic} if for any \\(x, y\\) there is a path between them with length \\(d(x, y)\\).\n\\item an action \\(G\\) on \\(X\\) is \\emph{proper} if for all \\(K \\subseteq X\\) compact, \\(|\\{g \\in G: gK \\cap K \\ne \\emptyset\\}| < \\infty\\). This implies that \\(X/G\\) is Hausdorff and locally compact.\n\\end{enumerate}\n\n\\begin{theorem}[Švarc–Milnor lemma]\\index{Švarc–Milnor lemma}\n  Let \\(X\\) be a proper geodesic metric space and \\(G\\) acts on \\(X\\) properly by isometry. Assume also the quotient \\(X/G\\) is compact. Then \\(G\\) is finitely generated and picking \\(x_0 \\in X\\) defines a quasi-isomorphism \\(\\varphi_{x_0}: G \\to X, g \\mapsto g x_0\\).\n\\end{theorem}\n\n\\begin{proof}\n  Since the quotient space is compact, there is a closed ball \\(\\overline B = \\overline B(x_0, D)\\) such that \\(G \\overline B = X\\). Since \\(X\\) is proper, \\(\\overline B\\) is compact. Define\n  \\[\n    S = \\{g \\in G: g \\ne e, g \\overline B \\cap \\overline B \\ne \\emptyset\\}\n  \\]\n  which is finite by properness. For \\(A, B \\subseteq X\\), define\n  \\[\n    d(A, B) = \\inf \\{d_X(a, b): a \\in A, b \\in B\\}.\n  \\]\n  Pick some \\(g \\in G \\setminus (S \\cup \\{e\\})\\) such that \\(d(\\overline B, g \\overline B) = R > 0\\). Consider\n  \\[\n    H = \\{g \\in G \\setminus (S \\cup \\{e\\}): d(\\overline B, g \\overline B) \\leq R\\}.\n  \\]\n  Note as \\(H\\) is a subset of\n  \\[\n    \\{g \\in G: g \\overline B(x_0, D + R) \\cap \\overline B(x_0, D + R) \\ne \\emptyset\\}\n  \\]\n  it is finite. Thus\n  \\[\n    \\inf \\{d(\\overline B, g \\overline B): g \\in G \\setminus (U \\cup \\{e\\})\\} = \\min\\{d(\\overline B, h \\overline B): h \\in H\\}\n  \\]\n  so the infimum, say \\(2d\\), is achieved. Thus if \\(d(\\overline B, g \\overline B) < 2d\\) then \\(g \\in S \\cup \\{e\\}\\).\n\n  To prove that \\(G = \\langle S\\rangle\\) we translate paths in \\(X\\) to words in \\(G\\). Take \\(g \\in G\\). Let \\(k = \\floor{\\frac{d_X(x_0, gx_0)}{d}}\\). Take a sequence of points \\(y_0 = x_0, y_1, \\dots, y_{k + 1} = gx_0\\) on the geodesic from \\(x_0\\) to \\(gx_0\\) such that \\(d_X(y_i, y_{i + 1}) \\leq d\\) for all \\(i\\). Take a corresponding sequence \\(h_i \\in G\\) such that for all \\(i\\), \\(y_i \\in h_i \\overline B\\). Taking \\(h_0 = e, h_{k + 1} = g\\). We have\n  \\[\n    d(h_i \\overline B, h_{i + 1} \\overline B) \\leq d_X(y_i, y_{i + 1}) \\leq d\n  \\]\n  so \\(d(\\overline B, h_i^{-1}h_{i + 1} \\overline B) \\leq d\\) so \\(h_i^{-1}h_{i + 1} \\in S \\cup \\{e\\}\\), i.e.\\ \\(h_{i + 1} = h_i s\\). Inductively \\(g = h_{k + 1} = s_0 \\cdots s_k\\).\n\n  All word metrics on \\(G\\) are quasi-isometric so take \\(S\\) as above. Clearly we have that \\(2D\\)-neighbourhood of the image of the map \\(\\varphi_{x_0}: g \\mapsto g x_0\\) is \\(X\\) so just need to show \\(\\varphi_{x_0}\\) is a quasi-isometric embedding. By construction\n  \\[\n    |g|_S \\leq k + 1 \\leq \\frac{d_X(x_0, gx_0)}{d} + 1.\n  \\]\n  On the other hand if \\(|g|_S = m\\) and \\(t_1 \\cdots t_m = g\\) in \\(G\\), \\(t_i \\in S\\) then\n  \\begin{align*}\n    d_X(x_0, gx_0)\n    &\\leq d_x(t_1^{-1}x_0, x_0) + d_X(x_0, t_2 \\cdots t_m x_0) \\\\\n    &\\leq d_X(x_0, t_1 x_0) + d_X(x_0, t_2 \\cdots t_m x_0) \\\\\n    &\\leq \\sum_{i = 1}^m d_X(x_0, t_ix_0) \\\\\n    & \\leq 2D m \\\\\n    &= 2D |g|_s\n  \\end{align*}\n  Finally apply left-invariance of \\(d_S\\) and \\(d_X\\).\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(M\\) be a compact connected Riemannian manifold and let \\(\\widetilde M\\) be its universal. \\(\\pi_1M\\) acts on \\(\\widetilde M\\) isometrically so \\(\\pi_1M\\) is finitely generated and is quasi-isometric to \\(\\widetilde M\\).\n\\end{corollary}\n\n\\begin{corollary}\n  Let \\(G\\) be a connected real Lie group and let \\(\\Gamma\\) be a cocompact lattice in \\(G\\), i.e.\\ a discrete subgroup such that \\(G/\\Gamma\\) is compact. Then \\(\\Gamma\\) is finitely generated and \\(\\Gamma \\cong_{\\mathrm{QI}} G\\).\n\\end{corollary}\n\n\\begin{corollary}\n  Let \\(G\\) be a finitely generated group.\n  \\begin{enumerate}\n  \\item If \\(H\\) is a finite index subgroup of \\(G\\) then \\(G \\cong_{\\mathrm{QI}} H\\).\n  \\item If \\(H \\normal G\\) finite then \\(G \\cong_{\\mathrm{QI}} G/N\\).\n  \\item If \\(G, H\\) are commensurable finitely generated groups then \\(G \\cong_{\\mathrm{QI}} H\\).\n  \\end{enumerate}\n\\end{corollary}\n\n\\begin{definition}[commensurable]\\index{commensurable}\n  \\(G\\) and \\(H\\) are \\emph{commensurable} if exists \\(K_1 \\leq G, K_2 \\leq H\\) finite index such that \\(K_1 \\cong K_2\\).\n\\end{definition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(H\\) acts on \\(\\Cay(G)\\).\n  \\item \\(G\\) acts on \\(\\Cay(G/N)\\).\n  \\item Immediate.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{corollary}\n  All finitely generated free groups are quasi-isometric.\n\\end{corollary}\n\n\\begin{proof}\n  \\(F_n \\leq F_2\\) of finite index for all \\(n \\geq 2\\).\n\\end{proof}\n\nOne may wonder if all quasi-isometric groups are commensurable. In other words, when does geometric similarity forces algebraic similarity? \n\n\\begin{eg}\n  There exist groups which are quasi-isometric but not commensurable. Take\n  \\[\n    G = \\Z_4 \\wr \\Z, H = (\\Z_2 \\times \\Z_2) \\wr \\Z.\n  \\]\n  Not commensurable: the only elements of finite order in \\(H\\), and hence in a finite index subgroup thereof, are of order \\(2\\). On the other hand, given a finite index subgroup \\(K \\leq G\\), \\(K\\) necessarily contains elements of order \\(4\\) as\n  \\[\n    [\\bigoplus_\\Z \\Z_4: K \\cap \\bigoplus \\Z_4] = [K \\cdot \\bigoplus \\Z_4: K] < \\infty\n  \\]\n  and the subgroup generated by all elements of order \\(2\\) in \\(\\bigoplus \\Z_4\\) has infinite index.\n\n  Quasi-isometric: take the generating set\n  \\[\n    S = \\{(0, 1)\\} \\cup \\{(f_1, 0), (f_2, 0), (f_3, 0)\\}\n  \\]\n  of \\(\\Z_4 \\wr \\Z\\) where \\(f_i(0) = i, f_i(n) = 0\\) otherwise. Similarly take\n  \\[\n    S' = \\{(0, 1)\\} \\cup \\{(f_{(0, 1)}, 0), (f_{(1, 0)}, 0), (f_{(1, 1)}, 0)\\}\n  \\]\n  of \\((\\Z_2 \\times \\Z_2) \\wr \\Z\\). Then the Cayley graphs are actually isomorphic.\n\\end{eg}\n\nQuestion: in which case does quasi-isometry imply commensurability? Typical rigidity question.\n\nSince quasi-isometry only sees finite index subgroups, it is convenient to define\n\n\\begin{definition}[virtual property]\\index{virtual property}\n  A group is called \\emph{virtually \\(P\\)} for some property \\(P\\) if it has a finite index subgroup that is \\(P\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{itemize}\n  \\item \\(\\Z_2 \\times \\Z\\) is virtually \\(\\Z\\).\n  \\item \\(\\SL_2(\\Z)\\) is virtually free.\n  \\end{itemize}\n\\end{eg}\n\n\\begin{theorem}\n  Let \\(G\\) be a finitely generated group such that \\(\\Cay(G) \\cong_{\\mathrm{QI}} \\Z\\). Then \\(G\\) is virtually \\(\\Z\\).\n\\end{theorem}\n\n\\begin{proof}[Sketch proof]\n  First show there is an element of infinite order in \\(G\\). We will find \\(g \\in G\\) and \\(A \\subseteq G\\) such that \\(gA \\subsetneq A\\) (then \\(g^n \\ne e\\) for all \\(n\\)). Let \\(\\varphi: \\Cay(G) \\to \\R\\) be a quasi-isometry. As \\(G\\) acts on \\(\\Cay(G)\\) by isometry, any \\(g \\in G\\) determines a quasi-isometry \\(\\psi_g: \\R \\to \\R\\). Take \\([0, \\infty) \\subseteq \\R\\), then \\(\\psi_g([0, \\infty))\\) is either a bounded distance\\footnote{\\(X\\) is bounded distance from \\(Y\\) if exists \\(M \\geq 0\\) such that for all \\(x \\in X\\) exists \\(y \\in Y\\) such that \\(d(x, y) \\leq M\\) and vice versa.} from \\([\\psi_g(0), \\infty)\\) or \\((-\\infty, \\psi_g(0)]\\). If \\(\\psi_g([0, \\infty))\\) is bounded distance from \\([\\psi_g(0), \\infty)\\) then setting\n  \\[\n    A = V(\\Cay(G)) \\cap \\varphi^{-1}([0, \\infty)).\n  \\]\n  If \\(\\psi_g(0) \\gg 0\\) then \\(gA \\subsetneq A\\): this is possible since \\(\\psi_g(0)\\) is bounded below in terms of the quasi-isometry constants, while \\(\\inf \\psi_g([0, \\infty))\\) (the ``left-most point'' the image of \\([0, \\infty)\\) reaches before going off to infity) is bounded above.\n\n  So need \\(g\\) so that \\(\\psi_g([0, \\infty))\\) is bounded distance from \\([\\psi_g(0), \\infty)\\) and \\(\\psi_g(0) \\gg 0\\). To find such \\(g\\), take \\(h, k \\in G\\) such taht \\(e, g, k\\) far apart in \\(\\Cay(G)\\) (if and only if \\(\\varphi(e), \\varphi(h),  \\varphi(h)\\) far apart in \\(\\R\\)). Consider images of \\([0, \\infty)\\) under \\(\\psi_e, \\psi_h, \\psi_k\\) --- at least two of thse images will be of bounded distance from each other, so at least two of \\(A, hA, kA\\) are nested. So take \\(g\\) to be one of the elements of \\(h, k, k^{-1}h, h^{-1}k\\).\n\n  Let \\(H = \\langle g\\rangle\\). Want to show \\(H\\) has finite index in \\(G\\). We have \\(d(e, g^n) \\to \\infty\\) as \\(n \\to \\pm \\infty\\) and \\(d(g^n, g^m) = d(e, g^{n - m})\\). Define\n  \\begin{align*}\n    f: \\Z &\\to \\R \\\\\n    n &\\mapsto \\varphi(g^n)\n  \\end{align*}\n  Then \\(|f(n) - f(n - 1)|\\) is bounded independent of \\(n\\) and for all \\(r \\geq 0\\) exists \\(K \\in N\\) such that \\(|f(n) - f(m)| \\leq r\\) implies \\(|m - n| \\leq K\\). It is an exercise to check that exists \\(C > 0\\) such that for all \\(x \\in \\R\\), exists \\(n \\in \\Z\\) such that \\(|x - f(n)| \\leq C\\). Then exists \\(C'\\) such that for all \\(g' \\in G\\), exists \\(g^n \\in H\\) such that \\(d(g', g^n) \\leq C'\\), i.e.\\ \\(\\Cay(G)/H\\) is finite, so \\(H\\) is a finite index subgroup in \\(G\\).\n\\end{proof}\n\nOther examples:\n\\begin{itemize}\n\\item If both groups are virtually ablian then quasi-isometry implies commensurability. This is an exercise.\n\\item It is also true if just one of the groups is assumed to be abelian. This is much deeper. See next chapter.\n\\item True if both groups are virtually free.\n\\item True if only one of the groups is assumed to be virtually free.\n\\end{itemize}\n\n\\section{Geometric property of groups}\n\n\\subsection{Growth}\n\n\\begin{notation}\n  Let \\(f, g: X \\to \\R\\) where \\(X \\subseteq \\R\\), we write\n  \\begin{itemize}\n  \\item \\(f \\preceq g\\) if exists \\(a, b > 0\\) and \\(x_0\\) such that \\(f(x) \\leq a g(bx)\\) for \\(x \\geq x_0\\).\n  \\item \\(f \\asymp g\\) if \\(f \\preceq g, g \\preceq f\\).\n  \\end{itemize}\n\\end{notation}\n\n\\begin{definition}[growth function]\\index{growth function}\n  Let \\(X\\) be a discrete metric space and \\(x_0 \\in X\\) a basepoint. The \\emph{growth function} is the function\n  \\[\n    \\beta_{X, x_0}(r) = |\\overline B_X(x_0, r)|.\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  The equivalence class of growth function under \\(\\asymp\\) is a quasi-isometry invariant for groups. In particular \\(\\beta_{G, g} = \\beta_{G, h}\\) for all \\(g, h \\in G\\) and write \\(\\beta_G\\) for this equivalence class.\n\\end{lemma}\n\nWe write \\(\\beta_{G, S}\\) for the growth function relative to the generating set \\(S\\).\n\n\\begin{proposition}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(G\\) is infinite then \\(\\beta_{G, S}|_\\N\\) is strictly increasing.\n  \\item \\(\\beta_{G, S}(r + t) \\leq \\beta_{G, S}(r) \\cdot \\beta_{G, S}(t)\\).\n  \\item \\(\\beta_{G, S}(r) \\leq |S|^r\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\beta_{\\Z^k}(r) \\asymp r^k\\).\n  \\item \\(\\beta_{F_k}(r) \\asymp (2k)^r\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{remark}\n  The proposition implies that\n  \\[\n    \\lim_{n \\to \\infty} \\beta_{G, S}(n)^{1/n} \\geq 1.\n  \\]\n  The limit exists by Fekete's lemma: if \\((a_n)\\) is a subadditive sequence then \\(\\lim \\frac{a_n}{n}\\) exists.\n\\end{remark}\n\n\\begin{definition}[(sub)exponential/polynomial growth]\\index{growth!exponential}\\index{growth!subexponential}\\index{growth!polynomial}\n  We say \\(G\\) has \\emph{exponential growth} if \\(\\lim \\beta_{G, S}(n)^{1/n} > 1\\). Otherwise we say \\(G\\) has \\emph{subexponential growth}.\n\n  \\(G\\) has \\emph{polynomial growth} if exists \\(D\\) such that \\(\\beta_G(r) \\leq r^D\\).\n\\end{definition}\n\n\\begin{proposition}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(H\\) is a finitely generated subgroup of \\(G\\) then \\(\\beta_H \\preceq \\beta_G\\).\n  \\item If \\(H\\) is a finite index subgroup of \\(G\\) then \\(\\beta_H \\asymp \\beta_G\\).\n  \\item If \\(N \\normal G\\) then \\(\\beta_{G/N} \\asymp \\beta_G\\).\n  \\item If \\(N \\normal G\\) is finite then \\(\\beta_{G/N} \\asymp \\beta_G\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n  2 and 4 are easy consequences Švarc-Milnor. For 1, take \\(T\\) to be a finite generating set of \\(H\\) and take \\(S \\supseteq T\\) to be a finite generating set of \\(G\\). Then \\(\\Cay(H, T)\\) is a subgraph of \\(G\\) so \\(d_S(e, h) \\leq d_T(e, h)\\) for all \\(h \\in H\\). Thus the closed ball of radius \\(r\\) about \\(e\\) in \\(\\Cay(G, S)\\) contains the corresponding ball of \\(\\Cay(H, T)\\).\n\n  For 3, take \\(S\\) to be a finite generating set of \\(G\\). Let \\(T = SN/N\\) be a finite generating set of \\(N\\). \\(\\pi: G \\to G/N\\) maps closed \\(r\\)-ball about \\(e\\) onto closed \\(r\\)-ball around \\(e\\) in \\(G/N\\).\n\\end{proof}\n\nWe can ask many questions about growth, for example\n\\begin{enumerate}\n\\item what types of growth can groups display?\n\\item which group have which types of growth?\n\\end{enumerate}\n\nWe have seen that virtually abelian groups have polynomial growth. This generalises to\n\n\\begin{proposition}\n  Let \\(G\\) be a 2-step nilpotent finitely generated group, i.e.\\ \\([[G, G], G] = \\{e\\}\\). Then \\(G\\) has polynomial growth.\n\\end{proposition}\n\n\\begin{proof}\n  Suppose \\(G\\) is generated by \\(g_1, \\dots, g_m\\). As \\(G\\) is 2-step nilpotent, \\([G, G] \\subseteq Z(G)\\). We bound the size of all products of \\(n\\) generators using a normal form. Note we can exchange two elements at the cost of a commutator:\n  \\[\n    gh = hg \\cdot g^{-1}h^{-1}gh = hg [g, h].\n  \\]\n  Commutators are central so we can move them to the right. Thus in \\(\\leq n^2\\) moves we can express the element as \\(g_1^{\\alpha_1} \\cdots g_m^{\\alpha_m} \\cdot C\\), where \\(C\\) is a product of \\(\\leq n^2\\) commutators. It is an easy exercise to check that \\([G, G]\\) is finitely generated, in this case by \\([g_i^{\\pm 1}, g_j^{\\pm 1}]\\). Thus the commutators are words of length 1 in generators of \\([G, G]\\) , which has polynomial growth (say degree \\(D\\)). Thus \\(G\\) has polynomial growth of degree \\(\\leq m + 2D\\).\n\\end{proof}\n\n\\begin{theorem}\n  All finitely generated virtually nilpotent groups have polynomial growth.\n\\end{theorem}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\nCan we push this result further? The natural class of groups to consider after nilpotent groups is solvable groups. Unfortunately, there do exist solvable groups of exponential growth, for example the lamplight group\\index{lamplight group} \\(\\Z_2 \\wr \\Z\\). In fact,\n\n\\begin{theorem}[Gromov]\n  A finitely generated group has polynomial growth if and only if it is virtually nilpotent.\n\\end{theorem}\n\n\\begin{remark}\n  The proof uses what is now called \\emph{asymptotic cones}, the limit of the objects \\((X, \\frac{d}{n})\\) as \\(n \\to \\infty\\).\n\n  Tits alternative: in the language of growth, a group either has exponential growth or is virtually solvable. Then we can use algebraic techniques to show it's virtually nilpotent.\n\n  c.f. paper by Wilkie van den Dries (rewrite the old paper), Kleiner (different proof, elementary but hard), Ozawa (functional analysis, representation theory)\n\n  For ultralimits and asymptotic growth, see Druţu and Kapovich Chapter 7.\n\n  There is also a proof based on approximate groups.\n\\end{remark}\n\n\\begin{corollary}\n  Being virtually nilpotent is quasi-isometry invariant.\n\\end{corollary}\n\nDoes there exist groups whose growth is between polynomial and exponential? The answer is yes, and such groups are said to have intermediate growth\\index{growth!intermediate}\n\n\\begin{theorem}[Grigorchuk, 1983]\n  There exists a finitely generated group \\(G\\) such that\n  \\[\n    2^{r^{\\alpha_1}} \\preceq \\beta_G(r) \\preceq 2^{r^{\\alpha_2}}\n  \\]\n  for \\(0 < \\alpha_1 < \\alpha_2 < 1\\).\n\\end{theorem}\n\nFor more on intermediate growth see de la Harpe.\n\n\\subsection{Ends}\n\nHow many ways are there to go to infinity in a Cayley graph? Informally, for \\(F_2\\) there are ``infinitely many'' while for \\(\\Z^2\\) there is ``only one'' way. For \\(\\Z \\times \\Z/2\\) there are ``two'' ways. Of course for finite groups there is no way to move to infinity. We are going to formalise this notion using \\emph{ends} and prove that, perhaps surprisingly, the above are all the possibilities that can arise from the Cayley graph of a finitely generated group.\n\n\\begin{definition}[proper map]\n  A map \\(f: X \\to Y\\) between topological spaces is \\emph{proper} if \\(f^{-1}(C)\\) is compact whenever \\(C\\) is compact.\n\\end{definition}\n\n\\begin{definition}[ray]\\index{ray}\n  Let \\(X\\) be a topological space. A \\emph{ray} in \\(X\\) is a proper continuous map \\(r: [0, \\infty) \\to X\\).\n\\end{definition}\n\n\\begin{definition}[convergence to the same end]\\index{end}\n  Let \\(r_1, r_2: [0, \\infty) \\to X\\) be rays. \\(r_1, r_2\\) \\emph{converge to the same end} if for all compact \\(C \\subseteq X\\), exists \\(N \\in \\N\\) such that \\(r_1([N, \\infty))\\) and \\(r_2([N, \\infty))\\) are contained in the same path component of \\(X \\setminus C\\).\n\\end{definition}\n\n(pic of Calyay graph of \\(F_2\\))\n\nThis defines an equivalence relation on rays, the equivalence classes of which are called the set of \\emph{ends} of \\(X\\) and is denoted \\(\\Ends(X)\\). If \\(|\\Ends(X)| = m\\) we say \\(X\\) has \\(m\\) ends.\n\nWe can topologise \\(\\Ends(X)\\) by declaring a set \\(B \\subseteq \\Ends(X)\\) to be closed if \\(\\mathrm{end}(r_n) \\in B\\) for all \\(n\\) and \\(\\mathrm{end}(r_n) \\to \\mathrm{end}(r)\\) imply that \\(\\mathrm{end}(r) \\in B\\), where \\(\\mathrm{end}(r_n) \\to \\mathrm{end}(r)\\) if for all \\(C \\subseteq X\\) compact, exists a sequence of natural numbers \\((N_n)\\) such that \\(r_n([N_n, \\infty))\\) and \\(r([N_n, \\infty))\\) lie in the same path compnent of \\(X \\setminus C\\) for \\(n\\) sufficiently large.\n\n\\begin{definition}\n  A \\emph{\\(k\\)-path} from \\(x\\) to \\(y\\) in a metric space \\(X\\) is a sequence of points \\(x_1 = x, x_2, \\dots, x_n = y\\) such that \\(d(x_i, x_{i + 1}) \\leq k\\) for all \\(i\\).\n\\end{definition}\n\nThe following lemma justifies the heuristics at the beginning of the section of thinking ends as ways of escaping to infinity from a fixed point.\n\n\\begin{lemma}\n  Let \\(X\\) be a proper geodesic metric space, \\(k > 0\\) and \\(r_1, r_2\\) rays in \\(X\\). Let \\(G_{x_0}(X)\\) be the set of (proper) geodesic rays starting at \\(x_0 \\in X\\). Then\n  \\begin{enumerate}\n  \\item \\(\\mathrm{end}(r_1) = \\mathrm{end}(r_2)\\) if and only if for all \\(R > 0\\), exists \\(T > 0\\) such that for all \\(t > T\\), \\(r_1(t)\\) can be connected to \\(r_t(t)\\) by a \\(k\\)-path in \\(X \\setminus B(x_0, R)\\).\n  \\item the natural map \\(G_{x_0}(X) \\to \\Ends(X)\\) is surjective.\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Every compact subset of \\(X\\) is contained in an open ball about \\(x_0\\) and vice versa. Given a \\(k\\)-path from \\(x_1\\) to \\(x_n\\) in \\(X \\setminus B(x_0, R + k)\\), concatenate any geodesics from \\(x_i\\) to \\(x_{i + 1}\\) to get a continuous path in \\(B(x_0, R)\\).\n  \\item Let \\(r: [0, \\infty) \\to X\\) be a ray. Let \\(c_n: [0, d_n] \\to X\\) be a geodesic from \\(x_0\\) to \\(r(n)\\) where \\(d_n = d(x_0, r(n)\\). Extend \\(c_n\\) to \\([d_n, \\infty)\\) by setting \\(c_n(t) = r(n)\\) for \\(t \\in [d_n, \\infty)\\). Ay Arzela-Ascoli, there exists a convergent subsequence of \\(c_n\\) converging to \\(c: [0, \\infty) \\to X\\) a geodesic ray with \\(\\mathrm{end}(c) = \\mathrm{end}(r)\\).\n  \\end{enumerate}\n\\end{proof}\n\nLet \\(X\\) be a metric space. Given \\(f, g: X \\to X\\), say \\(f \\sim g\\) if \\(\\sup_{x \\in X} d_X(f(x), g(x))\\) is finite. The set of equivalent classes of quasi-isometries of \\(X\\) forms a group, which we denote by \\(\\QI(X)\\). A quasi-isometry \\(\\varphi: X \\to Y\\) induces an isomorphism \\(\\varphi_*: \\QI(X) \\to \\QI(Y)\\).\n\n\\begin{proposition}\n  Let \\(X\\) and \\(Y\\) be proper geodesic metric spaces. A quasi-isometry \\(f: X \\to Y\\) induces a homeomorphism \\(\\overline f: \\Ends(X) \\to \\Ends(Y)\\) which will be defined below. Then\n  \\begin{align*}\n    \\QI(X) &\\to \\mathrm{Homeo}(\\Ends(X)) \\\\\n    f &\\mapsto \\overline f\n  \\end{align*}\n  is a homomorphism.\n\\end{proposition}\n\n\\begin{proof}\n  Let \\(r\\) be a geodesic ray in \\(X\\) from \\(x_0\\), \\(f_* r\\) be the ray in \\(Y\\) obtained by concatenating some choice of geodesic segments \\([f(r(n)), f(r(n + 1))]\\). \\(f\\) is a quasi-isometry implies that \\(f_*r\\) is a (proper) ray. \\(\\mathrm{end}(f_*r)\\) is independent of the choice of geodesic segments. Define\n  \\begin{align*}\n    \\overline f: \\Ends(X) &\\to \\Ends(Y) \\\\\n    \\mathrm{end}(r) &\\mapsto \\mathrm{end}(f_*r)\n  \\end{align*}\n  The image of a \\(k\\)-path under \\(f\\) is a \\((\\lambda k + c)\\)-path so \\(\\overline f\\) is well-defined and continuous by the previous lemma part 1.\n\n  Lemma part 2 ensures that \\(\\overline f\\) is defined on all of \\(\\Ends(X)\\). The rest are exercise.\n\\end{proof}\n\n\\begin{definition}[ends of a group]\\index{end}\n  Let \\(G\\) be a finitely generated group. Then \\(\\Ends(G) = \\Ends(\\Cay(G))\\).\n\\end{definition}\n\n\\begin{theorem}\n  Let \\(G\\) be a finitely generated group.\n  \\begin{enumerate}\n  \\item \\(G\\) has \\(0, 1, 2\\) or finitely many ends.\n  \\item \\(G\\) has 0 end if and only if \\(G\\) is finite.\n  \\item \\(G\\) has 2 ends if and only if \\(G\\) is virtually \\(\\Z\\).\n  \\item \\(G\\) has infinitely many ends if and only if \\(G\\) can be expressed as \\(A *_C B\\) or \\(A *_C\\) with \\(C\\) finite, \\(|A/C| \\geq 3, |B/C| \\geq 2\\).\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\n  We prove 1. Fix a generating set \\(S\\) of \\(G\\) and work with \\(\\Cay(G, S)\\). \\(G\\) acts \\(\\Cay(G, S)\\) by isometry, giving a homomorphism \\(G \\to \\mathrm{Homeo}(\\Ends(\\Cay(G, S)))\\). Let \\(H\\) be its kernel. Suppose \\(|\\Ends(G)| < \\infty\\), so \\(H\\) has finite index in \\(G\\). Assume further \\(e_0, e_1, e_2 \\in \\Ends(G)\\) are distinct for contracdiction. Fix geodesic rays \\(r_1, r_2: [0, \\infty) \\to \\Cay(G)\\) with \\(r_1(0) = r_2(0) = e_G\\) such that \\(\\mathrm{end}(r_i) = e_i\\). The ray corresponding to \\(e_0\\) is defined  slightly differently. Since \\(H\\) has finite index in \\(G\\), exists \\(\\mu > 0\\) such that for all \\(g \\in G\\), exists \\(h \\in H\\) with \\(d(g, h) \\leq \\mu\\). Thus exists a ray \\(r_0: [0, \\infty) \\to \\Cay(G)\\) with\n  \\begin{itemize}\n  \\item \\(\\mathrm{end}(r_0) = e_0\\),\n  \\item \\(d(r_0(n), e_G) \\geq n\\),\n  \\item \\(r_0(n) \\in H\\) for all \\(n\\).\n  \\end{itemize}\n  Set \\(h_n = r_n(n)\\). Fix \\(N > 0\\) such that \\(r_i[N, \\infty)\\) lie in different path components of \\(\\Cay(G) \\setminus B(e_G, N)\\). If \\(t, t' > 2N\\) then \\(d(r_1(t), r_2(t')) > 2N\\) since any path joining \\(r_1(t)\\) and \\(r_2(t')\\) must pass though \\(B(e_G, N)\\).\n\n  \\(H\\) acts trivially on \\(\\Ends(G)\\) so \\(\\mathrm{end}(h_n r_i) = \\mathrm{end}(r_i)\\) for all \\(i\\). Let \\(n > 3N\\). Then \\(h_nr_i(0) = h_n\\) lie in a different path component of \\(\\Cay(G) \\setminus B(e_G, N)\\) from \\(r_i[N, \\infty)\\) for \\(i = 1, 2\\), so \\(h_nr_i\\) must though \\(B(e_G, N)\\). Thus exists \\(t_i\\) such that \\(h_nr_i(t_i) \\in B(e_n, N)\\) for \\(i = 1, 2\\). Since \\(h_n\\) is an isometry, \\(d(r_1(t_1), r_2(t_2)) < 2N\\), contradicting \\(d(r_1(t_1), r_2(t_2)) > 2N\\).\n\\end{proof}\n\n\\begin{remark}\n  We have seen that being virtually nilpotent is a geometric property. In fact,\n  \\begin{enumerate}\n  \\item being virtually free is geometric, as it is equivalent to being quasi-isometric to a tree. c.f.\\ Antolin.\n  \\item being finitely presentable is geometric. c.f.\\ Bridson-Haefliger Prop 8.24.\n  \\end{enumerate}\n\\end{remark}\n\n\\section{Amenability}\n\n\\subsection{Paradoxical decomposition}\n\nThe motivating example for this chapter is \\emph{paradoxical decomposition}, which is the key argument in Banach-Tarski.\n\n\\begin{definition}[equidecomposable]\\index{equidecomposable}\n  Let \\(G\\) act on a set \\(X\\) and \\(A, B \\subseteq X\\). Say that \\(A\\) and \\(B\\) are \\emph{(finitely) \\(G\\)-equidecomposable} if exist partitions\n  \\begin{align*}\n    A &= A_1 \\cup A_2 \\cup \\dots \\cup A_n \\\\\n    B &= B_1 \\cup B_2 \\cup \\dots \\cup B_n\n  \\end{align*}\n  and \\(g_1, \\dots, g_n \\in G\\) such that \\(g_i A_i = B_i\\) for all \\(i\\). We write \\(A \\sim B\\). If \\(A \\sim C\\) for some \\(C \\subseteq B\\) then write \\(A \\lesssim B\\).\n\n  A \\emph{realisation} \\(h\\) of \\(A \\sim B\\) is a bijection \\(h: A \\to B\\) such that there exists a decomposition as above with \\(h(a_i) = g_i(a_i)\\) for all \\(i\\) and for all \\(a_i \\in A_i\\).\n\\end{definition}\n\nNote that if \\(h: A \\to B\\) is a realisation of \\(A \\sim B\\) and \\(S \\subseteq A\\) then \\(S \\sim h(S)\\). For fixed \\(X\\), \\(G\\)-equidecomposability is an equivalence relation.\n\n\\begin{theorem}\n  Suppose \\(G\\) acts on \\(X\\) and \\(A, B \\subseteq X\\). Then \\(A \\lesssim B\\) and \\(B \\lesssim A\\) implies \\(A \\sim B\\).\n\\end{theorem}\n\n\\begin{proof}\n  Schöder-Bernstein.\n  \\iffalse\n  Let \\(f: A \\to B_1, g: A_1 \\to B\\) be the realisations. Define inductively\n  \\begin{align*}\n    C_0 &= A \\setminus A_1 \\\\\n    C_{n + 1} &= g^{-1} f(C_n)\n  \\end{align*}\n  and let \\(C = \\bigcup_{n = 0}^\\infty C_n\\). If \\(a \\in A \\setminus C\\) then \\(a \\notin C_n\\) for all \\(n \\geq 0\\), so \\(g(a) \\notin f(C_n)\\). Thus \\(g(A \\setminus C) = B \\setminus f(C)\\). Similarly \\(B \\setminus f(C) \\subseteq g(A\\setminus C)\\). Thus \\(A \\setminus C \\sim_g B \\setminus f(C)\\). Since \\(C \\sim f(C)\\) we get \\(A \\sim B\\).\n  \\fi\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(G\\) act on \\(X\\). Then TFAE:\n  \\begin{enumerate}\n  \\item there exist proper disjoint subsets \\(A, B \\subseteq X\\) such that \\(A \\sim X \\sim B\\).\n  \\item there exist proper disjoint subsets \\(A, B \\subseteq X\\) such that \\(A \\cup B = X\\) and \\(A \\sim X \\sim B\\).\n  \\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n  For \\(1 \\implies 2\\), since \\(X \\sim B \\subseteq X \\setminus A\\), have \\(X \\lesssim X \\setminus A\\). Trivially \\(X \\setminus A \\lesssim X\\). Thus \\(A \\sim X \\sim X \\setminus A\\).\n\\end{proof}\n\n\\begin{definition}[\\(G\\)-paradoxical]\\index{\\(G\\)-paradoxical}\n  Let \\(G\\) act on \\(X\\). If the condition in the previous corollary holds, we say \\(X\\) is \\emph{(finitely) \\(G\\)-paradoxical}.\n\\end{definition}\n\n\\begin{proposition}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(F_2\\) is \\(F_2\\)-paradoxical (left multiplication).\n  \\item If \\(F_2\\) acts on \\(X\\) freely then \\(X\\) is \\(F_2\\)-paradoxical.\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(F_2 = \\langle a, b\\rangle\\). Let \\(W(y)\\) be the set of reduced words starting in \\(y\\) where \\(y \\in \\{a^{\\pm 1}, b^{\\pm 1}\\}\\). Then\n    \\[\n      F_2 = \\{e\\} \\cup W(a) \\cup (a^{-1}) \\cup W(b) \\cup W(b^{-1})\n    \\]\n    as a disjoint union. We can also write\n    \\[\n      F_2 = W(a) \\cup aW(a^{-1}) = W(b) \\cup bW(b^{-1})\n    \\]\n    so define\n    \\begin{align*}\n      A &= W(a) \\cup W(a^{-1}) \\\\\n      B &= W(b) \\cup W(b^{-1})\n    \\end{align*}\n    and \\(A, B\\) satisfies the first condition in the corollary.\n  \\item Take \\(M\\) to be a set of representatives of \\(F_2\\)-orbits of \\(X\\). Set\n    \\[\n      X_y = \\{zm: z \\in W(y), m \\in M\\}.\n    \\]\n    Then \\(X_a, X_{a^{-1}}, X_b, X_{b^{-1}}\\) are disjoint and\n    \\[\n      X = X_a \\cup aX_{a^{-1}} = X_b \\cup bX_{b^{-1}},\n    \\]\n    giving the desired decomposition.\n  \\end{enumerate}\n\\end{proof}\n\nNote that in the second part we need the axiom of choice.\n\n\\begin{proposition}\n  \\(F_2 \\leq \\SO(3, \\R)\\), with generators\n  \\[\n    \\begin{pmatrix}\n      1 & 0 & 0 \\\\\n      0 & \\frac{1}{3} & \\frac{-2\\sqrt 2}{3} \\\\\n      0 & \\frac{2\\sqrt{2}}{3} & \\frac{1}{3}\n    \\end{pmatrix},\n    \\begin{pmatrix}\n      \\frac{1}{3} & \\frac{-2\\sqrt 2}{3} & 0 \\\\\n      \\frac{2\\sqrt 2}{3} & \\frac{1}{3} & 0 \\\\\n      0 & 0 & 1\n    \\end{pmatrix}\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  Exercise. Uses a ping-pong lemma argument.\n\\end{proof}\n\n\\begin{theorem}[Hausdorff paradox]\n  There exists a countable set \\(D \\subseteq S^2\\) such that \\(S^2 \\setminus D\\) is \\(\\SO(3, \\R)\\)-paradoxical.\n\\end{theorem}\n\n\\begin{proof}\n  Every non-trivial element in \\(\\SO(3, \\R)\\) fixes exactly two points of \\(S^2\\). Let \\(D\\) be the union of fixed points of \\(F_2 \\subseteq \\SO(3, \\R)\\). \\(F_2\\) then acts freely on \\(S^2 \\setminus D\\).\n\\end{proof}\n\n\\begin{proposition}\n  For any countable \\(D \\subseteq S^2\\), \\(S^2\\) and \\(S^2 \\setminus D\\) are \\(\\SO(3)\\)-equidecomposable.\n\\end{proposition}\n\n\\begin{proof}\n  Let \\(\\ell\\) be a line though the origin that misses \\(D\\). As \\(D\\) is countable, exists \\(\\theta\\) such that for all \\(n > 0\\), the image \\(\\rho^n(D)\\) of \\(D\\) under rotation \\(\\rho^n\\) by \\(n \\theta\\) about \\(\\ell\\) does not intersect \\(D\\). Set \\(\\overline D = \\bigcup_{n = 0}^\\infty \\rho^n(D)\\). Then\n  \\begin{align*}\n    S^2\n    &= \\overline D \\cup (S^2 \\setminus \\overline D) \\\\\n    &\\sim \\rho(\\overline D) \\cup \\rho(S^2 \\setminus \\overline D) \\\\\n    &\\sim \\rho(\\overline D) \\cup (S^2 \\setminus \\overline D) \\\\\n    &= S^2 \\setminus D\n  \\end{align*}\n\\end{proof}\n\nTogether this shows\n\n\\begin{theorem}[Banach-Tarski]\\index{Banach-Tarski}\n  \\(S^2\\) is \\(\\SO(3, \\R)\\)-paradoxical.\n\\end{theorem}\n\n\\begin{theorem}\n  Let \\(E(3)\\) be the group of isometries of \\(\\R^3\\). Then any solid ball in \\(\\R^3\\) is \\(E(3)\\)-paradoxical, as is \\(\\R^3\\).\n\\end{theorem}\n\nMoral: cannot put a finitely-additive probability measure that is invariant under rotations on subsets of \\(S^2\\).\n\n\\begin{theorem}[Tarski]\n  Let \\(G\\) act on \\(X\\) and \\(E \\subseteq X\\). Then there is a finitely-additive measure \\(\\mu: \\mathcal P(X) \\to [0, \\infty]\\) with \\(\\mu(E) = 1\\) that is \\(G\\)-invariant if and only if \\(E\\) is not \\(G\\)-paradoxical.\n\\end{theorem}\n\n\\subsection{Amenable group}\n\n\\begin{definition}[amenable]\\index{amenablility}\n  Let \\(G\\) be a discrete (resp.\\ locally compact) group. A \\emph{measure} on \\(G\\) is a finitely-additive left-invariant measure \\(\\mu\\) on \\(\\mathcal P(G)\\) (resp.\\ Borel sets of \\(G\\)) with \\(\\mu(G) = 1\\). \\(G\\) is \\emph{amenable} if it it has such a measure.\n\\end{definition}\n\n\\begin{remark}\n  Clearly if \\(G\\) acts on itself by multiplication and \\(G\\) is paradoxical then \\(G\\) is not amenable. In particular \\(F_2\\) is not amenable, nor is any group containing \\(F_2\\). One might naturally wonder if it is the only obstruction to amenability. This is the von Neumann conjecture: any non-amenable group contains \\(F_2\\). It is disproved by Ol'shanskii, who constructed a counterexample called Tarski monster. It has the strange propery that for \\(p\\) a fixed prime, every non-trivial proper subgroup has order \\(p\\).\n\\end{remark}\n\n\\begin{definition}\n  Let \\(G\\) be a finitely generated group, and let \\(\\ell^\\infty(G)\\) be the space of bounded functions on \\(G\\). A linear functional \\(M: \\ell^\\infty(G) \\to \\R\\) is a \\emph{left-invariant mean} on \\(G\\) if\n  \\begin{itemize}\n  \\item \\(M(f) \\geq 0\\) if \\(f(g) \\geq 0\\) for all \\(g \\in G\\).\n  \\item \\(M(\\chi_G) = 1\\) for the characteristic function on \\(G\\).\n  \\item \\(M(g(f)) = M(f)\\) for all \\(g \\in G\\), where \\(g(f)(h) = f(g^{-1}h)\\).\n  \\end{itemize}\n\\end{definition}\n\n\\begin{proposition}\n  \\(G\\) is amenable if and only if \\(G\\) admits a left-invariant mean.\n\\end{proposition}\n\n\\begin{proof}\n  If \\(G\\) is amenable then define\n  \\[\n    M(f) = \\int f d \\mu.\n  \\]\n  Conversely if \\(M\\) is a left-invariant mean on \\(G\\) define\n  \\[\n    \\mu(A) = M(\\chi_A).\n  \\]\n\\end{proof}\n\n\\begin{proposition}\n  Let \\(G\\) amenable act on \\(X\\). Then there exists a finitely-additive probability measure on \\(\\mathcal P(X)\\) that is \\(G\\)-invariant. In particular \\(X\\) is not \\(G\\)-paradoxical.\n\\end{proposition}\n\n\\begin{proof}\n  Let \\(\\mu\\) be the measure realising amenability of \\(G\\). Fix \\(x_0 \\in X\\) and define\n  \\begin{align*}\n    \\nu: \\mathcal P(X) &\\to [0, 1] \\\\\n    A &\\mapsto \\mu \\{g \\in G: g(x_0) \\in A\\}\n  \\end{align*}\n\\end{proof}\n\nTo summarise\n\n\\begin{theorem}\n  TFAE:\n  \\begin{enumerate}\n  \\item \\(G\\) amenable.\n  \\item \\(G\\) admits a left-invariant measure.\n  \\item \\(G\\) is not paradoxical.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{eg}\n  All finite groups are amenable via normalised counting measure.\n\\end{eg}\n\n\\begin{proposition}\\leavevmode\n  \\label{prop:sub/quot/direct limit of amenable groups}\n  \\begin{enumerate}\n  \\item If \\(G\\) is amenable and \\(H \\leq G\\) then \\(H\\) is amenable.\n  \\item If \\(G\\) is amenable and \\(N \\normal G\\) then \\(G/N\\) is amenable.\n  \\item If \\(N \\normal G\\) and \\(G/N\\) are amenable then \\(G\\) is amenable.\n  \\item If \\(\\{G_i\\}\\) is a direct system of amenable groups then so is \\(\\varinjlim G_i\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\mu: \\mathcal P(G) \\to [0, 1]\\) realise the amenability of \\(G\\). Let \\(M\\) be a right transversal of \\(H \\leq G\\) and define\n    \\begin{align*}\n      \\nu: \\mathcal P(H) &\\to [0, 1] \\\\\n      A &\\mapsto \\mu(AM)\n    \\end{align*}\n  \\item Define\n    \\begin{align*}\n      \\lambda: \\mathcal P(G/N) &\\to [0, 1] \\\\\n      A &\\mapsto \\mu(AN)\n    \\end{align*}\n  \\item Let \\(\\nu_1, \\nu_2\\) realise amenability of \\(N, G/N\\) respectively. For \\(A \\leq G\\) define\n    \\begin{align*}\n      f_A: G &\\to \\R \\\\\n      g &\\mapsto \\nu_1(N \\cap g^{-1}A)\n    \\end{align*}\n    Note for \\(n \\in N\\), by translation invariance\n    \\[\n      f_A(gn) = \\nu_1(N \\cap n^{-1}g^{-1}A) = \\nu_1(N \\cap g^{-1}A) = f_A(g)\n    \\]\n    so \\(f_A\\) descends to a function on \\(G/N\\). Now define the measure on \\(G\\) to be\n    \\begin{align*}\n      \\mu: \\mathcal P(G) &\\to [0, 1] \\\\\n      A &\\to \\int f_A d \\nu_2\n    \\end{align*}\n    To show left-invariance, note\n    \\[\n      f_{hA}(g) = \\nu_1(N \\cap g^{-1}hA) = f_A(h^{-1}g) = h f_A(g)\n    \\]\n    The action of \\(G\\) on functions \\(G/N \\to \\R\\) factors thorugh \\(G/N\\):\n    \\[\n      hnf_A(g) = f_A(n^{-1}h^{-1}g) = \\nu_1(N \\cap g^{-1}hnA) = \\nu_1(N \\cap g^{-1}hA) = hf_A(g)\n    \\]\n    so\n    \\[\n      \\mu(hA) = \\int h^{-1}f_A d \\nu_2 = \\int f_A d \\nu_2 = \\mu(A)\n    \\]\n    by \\(G/N\\)-invariance of \\(\\nu_2\\).\n  \\item Omitted.\n  \\end{enumerate}\n\\end{proof}\n\n\\subsection{Amenability from a geometric viewpoint}\n\nWe first derive a combinatorial characterisation of amenability.\n\n\\begin{definition}[Følner condition]\\index{Følner condition}\n  A finitely generated group \\(G\\) is said to satsify the \\emph{Følner condition} if for all finite subsets \\(A \\subseteq G\\), for all \\(\\varepsilon > 0\\), exists finite nonemepty subset \\(F \\subseteq G\\) such that\n  \\[\n    \\frac{|aF \\triangle F|}{|F|} \\leq \\varepsilon\n  \\]\n  for all \\(a \\in A\\) where \\(\\triangle\\) denotes symmetric difference.\n\\end{definition}\n\n\\begin{theorem}\n  Suppose \\(G\\) is a finitely generated group. Then TFAE:\n  \\begin{enumerate}\n  \\item \\(G\\) is amenable.\n  \\item \\(G\\) satisfies the Følner condition.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\n  For \\(1 \\implies 2\\), see Theorem 16.62 in Druţu and Kapovich, or Theorem 4.2.3 in Juschenko's ``Amenability''.\n\n  For \\(2 \\implies 1\\), \\([0, 1]^{\\mathcal P(G)}\\) is compact in product topology. For \\(A \\subseteq G\\) finite, \\(\\varepsilon > 0\\), define \\(M_{A, \\varepsilon}\\) to be the set of finitely additive probability meansure \\(\\mu\\) on \\(G\\) such that \\(|\\mu(B) - \\mu(a B)| \\leq \\varepsilon\\) for all \\(B \\subseteq G\\), for all \\(a \\in A\\). \\(M_{A, \\varepsilon}\\) is closed in \\([0, 1]^{\\mathcal P(G)}\\). To show it is nonempty, define \\(\\mu(B) = \\frac{|B \\cap F|}{|F|}\\) where \\(F\\) is a Følner set for \\(A, \\varepsilon\\). Check\n    \\begin{align*}\n      |\\mu(B) - \\mu(aB)|\n      &= \\left|\\frac{|B \\cap F|}{|F|} - \\frac{|aB \\cap F|}{|F|}\\right| \\\\\n      &= \\left|\\frac{|B \\cap F|}{|F|} - \\frac{|B \\cap a^{-1} F|}{|F|}\\right| \\\\\n      &\\leq \\frac{|F \\triangle a^{-1}F|}{|F|} \\\\\n      &= \\frac{|aF \\triangle F|}{|F|} \\\\\n      &\\leq \\varepsilon\n    \\end{align*}\n    As\n    \\[\n      \\bigcap_{i = 1}^n M_{A_i, \\varepsilon_i} \\supseteq M_{\\bigcup A_i, \\min \\varepsilon_i} \\ne \\emptyset,\n    \\]\n    \\(\\{M_{A, \\varepsilon}\\}\\) has finite intersection property so \\(\\bigcap_{A, \\varepsilon} M_{A, \\varepsilon}\\) is nonempty.\n\\end{proof}\n\n\\begin{definition}[Cheeger constant]\\index{Cheeger constant}\n  Let \\(X\\) be a graph. The \\emph{Cheeger constant} \\(h(X)\\) is defined by\n  \\[\n    h(X) = \\inf \\frac{|\\p A|}{|A|}\n  \\]\n  over all nonempty finite \\(A \\subseteq V(X)\\), where \\(\\p A\\) is the set of vertices in \\(V(X) \\setminus A\\) that are connected by an edge to some element in \\(A\\).\n\\end{definition}\n\nNote that under this definition \\(h(\\text{finite group}) = 0\\). This fits our purpose of studying amenability. Usually, a more useful definition is to take \\(A\\) such that \\(|A| \\leq \\frac{1}{2} |V(X)|\\) for finite graphs.\n\n\\begin{proposition}\n  Let \\(G\\) be a finitely generated group. Then TFAE:\n  \\begin{enumerate}\n  \\item \\(G\\) satsifies the Følner condition.\n  \\item \\(h(\\Cay(G, S)) = 0\\) for all generating sets \\(S\\).\n  \\item \\(h(\\Cay(G, S)) = 0\\) for some generating set \\(S\\).\n  \\end{enumerate}\n\\end{proposition}\n\nInformally this is saying non-amenability is equivalent to a ``connectivity'' property.\n\n\\begin{proof}\n  \\(2 \\implies 3\\) is clear. \\(3 \\implies 1\\) is an exercise. For \\(1 \\implies 2\\), note that the Folner condition can be equivalently phrased in terms of right translates: take the Folner set \\(F\\) corresponding to \\(A^{-1}\\) and then\n  \\[\n    \\frac{|F^{-1}a \\triangle F^{-1}|}{|F^{-1}|} = \\frac{|a^{-1}F \\triangle F|}{|F|} < \\varepsilon.\n  \\]\n\n  Now take \\(A = S^{\\pm 1}\\) for some generating set \\(S\\) of \\(G\\) and \\(\\varepsilon > 0\\). Let \\(F\\) be the Folner set such that\n  \\[\n    \\frac{|Fs \\triangle F|}{|F|} \\leq \\varepsilon\n  \\]\n  for all \\(s \\in S^{\\pm 1}\\). Then\n  \\begin{align*}\n    \\frac{|\\p F|}{|F|}\n    &= \\frac{|\\{gs: g \\in F, s \\in S^{\\pm 1}, gs \\notin F\\}|}{|F|} \\\\\n    &\\leq \\frac{|\\bigcup_{s \\in S^{\\pm 1}} (Fs \\triangle F)|}{|F|} \\\\\n    &\\leq |S^{\\pm 1}| \\cdot \\varepsilon \\\\\n    &\\leq 2 |S| \\cdot \\varepsilon\n  \\end{align*}\n  so indeed its infimum is \\(0\\).\n\\end{proof}\n\n\\begin{eg}\n  \\(h = 0\\) is quasi-isometry-invariant.\n\\end{eg}\n\n\\begin{corollary}\n  Amenability is a quasi-isometry invariant.\n\\end{corollary}\n\n\\begin{corollary}\n  All finitely generated groups of subexponential growth\\index{growth!subexponential} are amenable.\n\\end{corollary}\n\n\\begin{proof}\n  Recall that if \\(G\\) has subexponential growth then at most\n  \\[\n    \\beta_{G, S}(n)^{1/n} = |B(n)|^{1/n} \\to 1.\n  \\]\n  If exists \\(\\varepsilon\\) such that for all \\(k\\), \\(\\frac{|B(k + 1)|}{|B(k)|} > 1 + \\varepsilon\\) then\n  \\[\n    |B(k + 1)| > (1 + \\varepsilon)^k \\cdot |B(1)|\n  \\]\n  and letting \\(k \\to \\infty\\), \\(\\beta(k)^{1/k} \\nto 1\\). Thus for all \\(N > 0\\) exists \\(k_N\\) such that\n  \\[\n    \\frac{|B(k_N + 1)|}{|B(k_N)|} < 1 + \\frac{1}{N}\n  \\]\n  and so\n  \\[\n    \\frac{|\\p B(k_N)|}{|B(k_N)|} = \\frac{|B(k_N + 1) \\setminus B(k_N)|}{|B(k_N)|} < \\frac{1}{N}.\n  \\]\n\\end{proof}\n\nThe converse is not true, by the following corollary and the existence of solvable groups of exponential growth:\n\n\\begin{corollary}\n  All solvable groups are amenable.\n\\end{corollary}\n\n\\begin{proof}\n  All abelian groups have polynomial growth and are thus amenable. Any solvable group can be written as the direct limit of abelian groups. Use \\Cref{prop:sub/quot/direct limit of amenable groups}.\n\\end{proof}\n\nTake the closure of finite groups and abelian groups by the operations of \\Cref{prop:sub/quot/direct limit of amenable groups}, we obtain the class of \\emph{elementary amenable groups}\\index{elementary amenable group}. They are strictly contained in amenable groups, as Grigorchuk group of intermediate growth.\n\nOpen question:\n\\begin{enumerate}\n\\item Is ``elementary amenable'' a quasi-isometry invariant?\n\\item Is Thompson's group \\(F\\) amenable?\n\\end{enumerate}\n\nMore topics in geometric groups theory:\n\\begin{itemize}\n\\item Martin Bridson: world of finitely presented groups. \n\\item Gromov: Space and Questions.\n\\item word problem. word problem for hyperbolic groups, solved by Dehn.\n\\item small cancellation. It leads to the construction of many interesting examples.\n\\item expander graphs, Kazhdan's property (T).\n\\end{itemize}\n\nTo conclude this course we mention the characterisation of non-amenability in terms of Ponzi scheme. Consider a function \\(\\rho: G \\to G\\) such that\n\\begin{itemize}\n\\item exists \\(R\\) such that \\(d(g, \\rho(g)) \\leq R\\).\n\\item \\(|\\rho^{-1}(g)| \\geq 2\\).\n\\end{itemize}\nImagine each person indexed by \\(G\\) holds £1, and person \\(g\\) passes his money to \\(\\rho(g)\\). In this process everyone ends up with stricly more money than they had, and money has moved by a bounded distance. An example is \\(F_2\\), where everyone passes the money towards the centre of the Cayley graph. This condition is, in fact, equivalent to non-amenability.\n\n\n\n\n\n\\printindex\n\\end{document}", "meta": {"hexsha": "da313f6656146e34ed86e954cc5540db2cba84f6", "size": 73900, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "IV/geometric_group_theory.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "IV/geometric_group_theory.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "IV/geometric_group_theory.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 50.1016949153, "max_line_length": 742, "alphanum_fraction": 0.6276725304, "num_tokens": 26263, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.44604079837323224}}
{"text": "%Deep neural networks (DNNs) have been demonstrated effective for approximating complex and high dimensional functions. In the data-driven inverse modeling, we use DNNs to substitute unknown physical relations, such as constitutive relations, in a physical system described by partial differential equations (PDEs). The coupled system of DNNs and PDEs enables describing complex physical relations while satisfying the physics to the largest extent. However, training the DNNs embedded in PDEs is challenging because input-output pairs of DNNs may not be available, and the physical system may be highly nonlinear, leading to an implicit numerical scheme. We propose an approach, physics constrained learning, to train the DNNs from sparse observations data that are not necessarily input-output pairs of DNNs while enforcing the PDE constraints numerically. Particularly, we present an efficient automatic differentiation based technique that differentiates through implicit PDE solvers. We demonstrate the effectiveness of our method on various problems in solid mechanics and fluid dynamics. Our PCL method enables learning a neural-network-based physical relation from any observations that are interlinked with DNNs through PDEs. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Beamer Presentation\n% LaTeX Template\n% Version 1.0 (10/11/12)\n%\n% This template has been downloaded from:\n% http://www.LaTeXTemplates.com\n%\n% License:\n% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%----------------------------------------------------------------------------------------\n%    PACKAGES AND THEMES\n%----------------------------------------------------------------------------------------\n\n\\documentclass[usenames,dvipsnames]{beamer}\n\\usepackage{animate}\n\\usepackage{float}\n\\usepackage{bm}\n\\usepackage{mathtools}\n\\usepackage{extarrows}\n\n\\newcommand{\\ChoL}{\\mathsf{L}}\n\\newcommand{\\bx}{\\mathbf{x}}\n\\newcommand{\\ii}{\\mathrm{i}}\n\\newcommand{\\bxi}{\\bm{\\xi}}\n\\newcommand{\\bmu}{\\bm{\\mu}}\n\\newcommand{\\bb}{\\mathbf{b}}\n\\newcommand{\\bA}{\\mathbf{A}}\n\\newcommand{\\bJ}{\\mathbf{J}}\n\\newcommand{\\bB}{\\mathbf{B}}\n\\newcommand{\\bM}{\\mathbf{M}}\n\n\\newcommand{\\by}{\\mathbf{y}}\n\\newcommand{\\bw}{\\mathbf{w}}\n\n\\newcommand{\\bX}{\\mathbf{X}}\n\\newcommand{\\bY}{\\mathbf{Y}}\n\\newcommand{\\bs}{\\mathbf{s}}\n\\newcommand{\\sign}{\\mathrm{sign}}\n\\newcommand{\\bt}[0]{\\bm{\\theta}}\n\\newcommand{\\bc}{\\mathbf{c}}\n\\newcommand{\\bzero}{\\mathbf{0}}\n\\renewcommand{\\bf}{\\mathbf{f}}\n\\newcommand{\\bu}{\\mathbf{u}}\n\\newcommand{\\bv}[0]{\\mathbf{v}}\n\n\\mode<presentation> {\n\n% The Beamer class comes with a number of default slide themes\n% which change the colors and layouts of slides. Below this is a list\n% of all the themes, uncomment each in turn to see what they look like.\n\n%\\usetheme{default}\n%\\usetheme{AnnArbor}\n%\\usetheme{Antibes}\n%\\usetheme{Bergen}\n%\\usetheme{Berkeley}\n%\\usetheme{Berlin}\n%\\usetheme{Boadilla}\n%\\usetheme{CambridgeUS}\n%\\usetheme{Copenhagen}\n%\\usetheme{Darmstadt}\n%\\usetheme{Dresden}\n%\\usetheme{Frankfurt}\n%\\usetheme{Goettingen}\n%\\usetheme{Hannover}\n%\\usetheme{Ilmenau}\n%\\usetheme{JuanLesPins}\n%\\usetheme{Luebeck}\n\\usetheme{Madrid}\n%\\usetheme{Malmoe}\n%\\usetheme{Marburg}\n%\\usetheme{Montpellier}\n%\\usetheme{PaloAlto}\n%\\usetheme{Pittsburgh}\n%\\usetheme{Rochester}\n%\\usetheme{Singapore}\n%\\usetheme{Szeged}\n%\\usetheme{Warsaw}\n\n\n% As well as themes, the Beamer class has a number of color themes\n% for any slide theme. Uncomment each of these in turn to see how it\n% changes the colors of your current slide theme.\n\n%\\usecolortheme{albatross}\n\\usecolortheme{beaver}\n%\\usecolortheme{beetle}\n%\\usecolortheme{crane}\n%\\usecolortheme{dolphin}\n%\\usecolortheme{dove}\n%\\usecolortheme{fly}\n%\\usecolortheme{lily}\n%\\usecolortheme{orchid}\n%\\usecolortheme{rose}\n%\\usecolortheme{seagull}\n%\\usecolortheme{seahorse}\n%\\usecolortheme{whale}\n%\\usecolortheme{wolverine}\n\n%\\setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line\n%\\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line\n\n%\\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line\n}\n\\usepackage{booktabs}\n\\usepackage{makecell}\n\\usepackage{soul}\n\\newcommand{\\red}[1]{\\textcolor{red}{#1}}\n%\n%\\usepackage{graphicx} % Allows including images\n%\\usepackage{booktabs} % Allows the use of \\toprule, \\midrule and \\bottomrule in tables\n%\n%\n%\\usepackage{amsthm}\n%\n%\\usepackage{todonotes}\n%\\usepackage{floatrow}\n%\n%\\usepackage{pgfplots,algorithmic,algorithm}\n\\usepackage{algorithmicx}\n\\usepackage{algpseudocode}\n%\\usepackage[toc,page]{appendix}\n%\\usepackage{float}\n%\\usepackage{booktabs}\n%\\usepackage{bm}\n%\n%\\theoremstyle{definition}\n%\n\\newcommand{\\RR}[0]{\\mathbb{R}}\n%\n%\\newcommand{\\bx}{\\mathbf{x}}\n%\\newcommand{\\ii}{\\mathrm{i}}\n%\\newcommand{\\bxi}{\\bm{\\xi}}\n%\\newcommand{\\bmu}{\\bm{\\mu}}\n%\\newcommand{\\bb}{\\mathbf{b}}\n%\\newcommand{\\bA}{\\mathbf{A}}\n%\\newcommand{\\bJ}{\\mathbf{J}}\n%\\newcommand{\\bB}{\\mathbf{B}}\n%\\newcommand{\\bM}{\\mathbf{M}}\n%\\newcommand{\\bF}{\\mathbf{F}}\n%\n%\\newcommand{\\by}{\\mathbf{y}}\n%\\newcommand{\\bw}{\\mathbf{w}}\n%\\newcommand{\\bn}{\\mathbf{n}}\n%\n%\\newcommand{\\bX}{\\mathbf{X}}\n%\\newcommand{\\bY}{\\mathbf{Y}}\n%\\newcommand{\\bs}{\\mathbf{s}}\n%\\newcommand{\\sign}{\\mathrm{sign}}\n%\\newcommand{\\bt}[0]{\\bm{\\theta}}\n%\\newcommand{\\bc}{\\mathbf{c}}\n%\\newcommand{\\bzero}{\\mathbf{0}}\n%\\renewcommand{\\bf}{\\mathbf{f}}\n%\\newcommand{\\bu}{\\mathbf{u}}\n%\\newcommand{\\bv}[0]{\\mathbf{v}}\n\n\\AtBeginSection[]\n{\n   \\begin{frame}\n       \\frametitle{Outline}\n       \\tableofcontents[currentsection]\n   \\end{frame}\n}\n\n%----------------------------------------------------------------------------------------\n%    TITLE PAGE\n%----------------------------------------------------------------------------------------\n\\usepackage{bm}\n\\newcommand*{\\TakeFourierOrnament}[1]{{%\n\\fontencoding{U}\\fontfamily{futs}\\selectfont\\char#1}}\n\\newcommand*{\\danger}{\\TakeFourierOrnament{66}}\n\n\\title[Physics Constrained Learning]{Subsurface Inverse Modeling with Physics Based Machine Learning} % The short title appears at the bottom of every slide, the full title is only on the title page\n\n\\author[Kailai Xu (\\texttt{kailaix@stanford.edu}), et al.]{Kailai Xu and Dongzhuo Li\\\\ Jerry M. Harris,  Eric Darve}% Your name\n%\\institute[] % Your institution as it will appear on the bottom of every slide, may be shorthand to save space\n%{\n%%ICME, Stanford University \\\\ % Your institution for the title page\n%%\\medskip\n%%\\textit{kailaix@stanford.edu}\\quad \\textit{darve@stanford.edu} % Your email address\n%}\n\\date{}% Date, can be changed to a custom date\n% Mathematics of PDEs\n\n\\newcommand\\blfootnote[1]{%\n  \\begingroup\n  \\renewcommand\\thefootnote{}\\footnote{#1}%\n  \\addtocounter{footnote}{-1}%\n  \\endgroup\n}\n\\begin{document}\n\n\\usebackgroundtemplate{%\n\\begin{picture}(0,250)\n\\centering\n\t{{\\includegraphics[width=1.0\\paperwidth]{../background}}}\n\\end{picture}\n  } \n%\\usebackgroundtemplate{%\n%  \\includegraphics[width=\\paperwidth,height=\\paperheight]{figures/back}} \n\\begin{frame}\n\n\\titlepage % Print the title page as the first slide\n\n\n%dfa\n\\end{frame}\n\\usebackgroundtemplate{}\n\n\\section{Inverse Modeling}\n\n\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling}\n\t\\begin{itemize}\n\t\t\\item \\textbf{Inverse modeling} identifies a certain set of parameters or functions with which the outputs of the forward analysis matches the desired result or measurement.\n\t\t\\item Many real life engineering problems can be formulated as inverse modeling problems: shape optimization for improving the performance of structures, optimal control of fluid dynamic systems, etc.t\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n\t\\centering\n  \\includegraphics[width=0.8\\textwidth]{../inverse2}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling}\n\t\\begin{figure}\n\t\\centering\n  \\includegraphics[width=1.0\\textwidth]{../inverse3}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling for Subsurface Properties}\n\t \n\t There are many forms of subsurface inverse modeling problems.\n\t \n\t \t\\begin{figure}\n\t \t\\centering\n\t \t\\includegraphics[width=1.0\\textwidth]{../inverse_types}\n\t \\end{figure}\n\n\\begin{center}\n\t\\textbf{\\underline{The Central Challenge}}\n\\end{center}\t \n\t\\begin{center}\n\\textcolor{red}{\\textbf{Can we have a general approach for solving these inverse problems?}}\n\\end{center}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Parameter Inverse Problem}\n\tWe can formulate inverse modeling as a PDE-constrained optimization problem \n\t\\begin{equation*}\n\t\t\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\theta, u_h) = 0\n\t\\end{equation*}\n\t\\begin{itemize}\n\t\t\\item The \\textcolor{red}{loss function} $L_h$ measures the discrepancy between the prediction $u_h$ and the observation $u_{\\mathrm{obs}}$, e.g., $L_h(u_h) = \\|u_h - u_{\\mathrm{obs}}\\|_2^2$. \n\t\t\\item $\\theta$ is the \\textcolor{red}{model parameter} to be calibrated. \n\t\t\\item The \\textcolor{red}{physics constraints} $F_h(\\theta, u_h)=0$ are described by a system of partial differential equations. Solving for $u_h$ may require solving linear systems or applying an iterative algorithm such as the Newton-Raphson method. \n\t\\end{itemize}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n\t\\frametitle{Function Inverse Problem}\n\t\n\t\\begin{equation*}\n\t\t\\min_{\\textcolor{red}{f}} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\textcolor{red}{f}, u_h) = 0\n\t\\end{equation*}\n\t\n\tWhat if the unknown is a \\textcolor{red}{function} instead of a set of parameters?\n\\begin{itemize}\n\t\\item Koopman operator in dynamical systems.\n\t\\item Constitutive relations in solid mechanics. \n\t\\item Turbulent closure relations in fluid mechanics.\n\t\\item Neural-network-based physical properties.\n\t\\item ...\n\\end{itemize}\n\nThe candidate solution space is \\textcolor{red}{infinite dimensional}.\n\n\n\t\\begin{figure}[hbt]\n\t\\includegraphics[width=0.75\\textwidth]{../nnfwi.png}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Physics Based Machine Learning}\n\t$$\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\;F_h(\\textcolor{red}{NN_\\theta}, u_h) = 0$$\n\t\\vspace{-0.5cm}\n\t\\begin{itemize}\n\t\t\\item Deep neural networks exhibit capability of approximating high dimensional and complicated functions. \n\t\t\\item \\textbf{Physics based machine learning}: \\textcolor{red}{the unknown function is approximated by a deep neural network, and the physical constraints are enforced by numerical schemes}.\n\t\t\\item \\textcolor{red}{Satisfy the physics to the largest extent}.\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.75\\textwidth]{../physics_based_machine_learning.png}\n\\end{figure}\n\\end{frame}\n\n\n\n\\begin{frame}\n\t\\frametitle{Gradient Based Optimization}\n\t\\begin{equation}\\label{equ:opt}\n\t\t\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\theta, u_h) = 0\n\t\t\\end{equation}\n\t\n\t\\begin{itemize}\n\t\t\\item We can now apply a gradient-based optimization method to (\\ref{equ:opt}).\n\t\t\\item The key is to \\textcolor{red}{calculate the gradient descent direction} $g^k$\n\t\t$$\\theta^{k+1} \\gets \\theta^k - \\alpha g^k$$ \n\t\\end{itemize}\n\t\n\t\\begin{figure}[hbt]\n\t\\centering\n  \\includegraphics[width=0.6\\textwidth]{../im.pdf}\n\\end{figure}\n\n\\end{frame}\n\n\n\n\\section{Automatic Differentiation}\n\n\\begin{frame}\n\t\\frametitle{Automatic Differentiation}\nThe fact that bridges the \\textcolor{red}{technical} gap between machine learning and inverse modeling:\n\t\\begin{itemize}\n\t\t\\item Deep learning (and many other machine learning techniques) and numerical schemes share the same computational model: composition of individual operators. \n\t\\end{itemize}\n\t\n\n\\begin{minipage}[b]{0.4\\textwidth}\n\n\n\n\n\\begin{center}\n\\textcolor{red}{Mathematical Fact}\n\n\\\n\n\tBack-propagation \n\n$||$\n\nReverse-mode\n\n Automatic Differentiation \n\n$||$\n \n Discrete \n \n Adjoint-State Method\n\\end{center}\n\\end{minipage}~\n\\begin{minipage}[b]{0.6\\textwidth}\n\\begin{figure}[hbt]\n\\centering\n  \\includegraphics[width=0.8\\textwidth]{../compare-NN-PDE.png}\n\\end{figure}\n\\end{minipage}\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n\t\\frametitle{Forward Mode vs. Reverse Mode}\n\t\n\t\\begin{itemize}\n\t\t\\item Reverse mode automatic differentiation evaluates gradients in the \\textcolor{red}{reverse order} of forward computation. \n\t\t\\item Reverse mode automatic differentiation is a more efficient way to compute gradients of a many-to-one mapping $J(\\alpha_1, \\alpha_2, \\alpha_3,\\alpha_4)$ $\\Rightarrow$ suitable for minimizing a loss (misfit) function. \n\t\\end{itemize}\n\t\n\t\\begin{figure}[hbt]\n\t\t\\includegraphics[width=0.8\\textwidth]{../fdrd}\n\t\\end{figure}\n\t\n\t\n\t\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Computational Graph for Numerical Schemes}\n\t\n\t\\begin{itemize}\n\t\t\\item To leverage automatic differentiation for inverse modeling, we need to express the numerical schemes in the ``AD language'': computational graph. \n\t\t\\item No matter how complicated a numerical scheme is, it can be decomposed into a collection of operators that are interlinked via state variable dependencies. \n\t\\end{itemize}\n\t\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../cgnum}\n\\end{figure}\n\n\t\n\t\n\\end{frame}\n\n\n\n\n\n%\\begin{frame}\n%\t\\frametitle{Code Example}\n%\t\\begin{itemize}\n%\t\t\\item  Find $b$ such that $u(0.5)=1.0$ and\n%\t\t$$-bu''(x)+u(x) = 8 + 4x - 4x^2, x\\in[0,1], u(0)=u(1)=0$$\n%\t\\end{itemize}\n%\t\\begin{figure}[hbt]\n%  \\includegraphics[width=0.8\\textwidth]{../code.png}\n%\\end{figure}\n%\\end{frame}\n\n\n\\section{Physics Constrained Learning}\n\\begin{frame}\n\n\n\t\\frametitle{Challenges in AD}\n\t\n\t\n\t\\begin{minipage}[t]{0.49\\textwidth}\n\t\\vspace{-3cm}\n\\begin{itemize}\n\t\\item Most AD frameworks only deal with \\textcolor{red}{explicit operators}, i.e., the functions with analytical derivatives that are easy to implement.  \n\t\\item Many scientific computing algorithms are \\textcolor{red}{iterative} or \\textcolor{red}{implicit} in nature.\n\\end{itemize}\n\\end{minipage}~\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\includegraphics[width=1.0\\textwidth]{../sim.png}\n\\end{minipage}\n\n\t% Please add the following required packages to your document preamble:\n% \\usepackage{booktabs}\n\\begin{table}[]\n\\begin{tabular}{@{}lll@{}}\n\\toprule\nLinear/Nonlinear & Explicit/Implicit & Expression   \\\\ \\midrule\nLinear           & Explicit          & $y=Ax$       \\\\\nNonlinear        & Explicit          & $y = F(x)$   \\\\\n\\textbf{Linear}           & \\textbf{Implicit}          & $Ay = x$     \\\\\n\\textbf{Nonlinear}        & \\textbf{Implicit}          & $F(x,y) = 0$ \\\\ \\bottomrule\n\\end{tabular}\n\\end{table}\n\\end{frame}\n\n\n\n\\begin{frame}\n\t\\frametitle{Implicit Operators in Subsurface Modeling}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\item For reasons such as nonlinearity and stability, implicit operators (schemes) are almost everywhere in subsurface modeling...\n\t\t\t\t\\begin{figure}\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\textwidth]{../nonlinear.PNG}\n\t\t\t\\end{figure}\n\t\t\t\\item The ultimate solution: \\textcolor{red}{design ``differentiable'' implicit operators}.\n\t\t\\end{itemize}\n\t\t\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Example}\n\t\n\\begin{itemize}\n\t\\item Consider a function $f:x\\rightarrow y$, which is implicitly defined by \n\t$$F(x,y) = x^3 - (y^3+y) = 0$$\nIf not using the cubic formula for finding the roots, the forward computation consists of iterative algorithms, such as the Newton's method and bisection method\n\\end{itemize}\n\n\n\n\\begin{minipage}[t]{0.48\\textwidth}\n\\centering\n\\begin{algorithmic}\n\\State $y^0 \\gets 0$\n\\State $k \\gets 0$\n\\While {$|F(x, y^k)|>\\epsilon$}\n\\State $\\delta^k \\gets F(x, y^k)/F'_y(x,y^k)$\n\\State $y^{k+1}\\gets y^k - \\delta^k$\n\\State $k \\gets k+1$\n\\EndWhile\n\\State \\textbf{Return} $y^k$\n\\end{algorithmic}\n\\end{minipage}~\n\\begin{minipage}[t]{0.48\\textwidth}\n\\centering\n\\begin{algorithmic}\n\\State $l \\gets -M$, $r\\gets M$, $m\\gets 0$\n\\While {$|F(x, m)|>\\epsilon$}\n\\State $c \\gets \\frac{a+b}{2}$\n\\If{$F(x, m)>0$}\n\\State $a\\gets m$\n\\Else\n\\State $b\\gets m$\n\\EndIf\n\\EndWhile\n\\State \\textbf{Return} $c$\n\\end{algorithmic}\n\n\\end{minipage}\t\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Example}\n\t\n\t\\begin{itemize}\n%\t\t\\item A simple approach is to save part or all intermediate steps, and ``back-propagate''. This approach is expensive in both computation and memory\\footnote{Ablin, Pierre, Gabriel Peyré, and Thomas Moreau. ``Super-efficiency of automatic differentiation for functions defined as a minimum.''}.\n%\t\t\\item Nevertheless, the simple approach works in some scenarios where accuracy or cost is not an issue, e.g., automatic differetiation of soft-DTW and Sinkhorn distance. \n\t\t\\item An efficient way is to apply the \\textcolor{red}{implicit function theorem}. For our example, $F(x,y)=x^3-(y^3+y)=0$, treat $y$ as a function of $x$ and take the derivative on both sides\n\t\t$$3x^2 - 3y(x)^2y'(x)-1=0\\Rightarrow y'(x) = \\frac{3x^2-1}{3y(x)^2}$$\n\tThe above gradient is \\textcolor{red}{exact}.\n\t\\end{itemize}\n\t\\begin{center}\n\t\t\t\\textbf{Can we apply the same idea to inverse modeling?}\n\t\\end{center}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Physics Constrained Learning}\n\t$${\\small    \\min_{\\theta}\\; L_h(u_h) \\quad \\mathrm{s.t.}\\;\\; F_h(\\theta, u_h) = 0}$$\n\t\\begin{itemize}\n\t\t\\item Assume that we solve for $u_h=G_h(\\theta)$ with $F_h(\\theta, u_h)=0$, and then\n\t\t      $${\\small\\tilde L_h(\\theta)  = L_h(G_h(\\theta))}$$\n\t\t\\item Applying the \\textcolor{red}{implicit function theorem}\n\t\t      {  \\scriptsize\n\t\t\t      \\begin{equation*}\n\t\t\t\t      \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }} + {\\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}}}\n\t\t\t\t      \\textcolor{red}{\\frac{\\partial G_h(\\theta)}{\\partial \\theta}}\n\t\t\t\t      = 0 \\Rightarrow\n\t\t\t\t      \\textcolor{red}{\\frac{\\partial G_h(\\theta)}{\\partial \\theta}} =  -\\Big( \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}} \\Big)^{ - 1} \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }}\n\t\t\t      \\end{equation*}\n\t\t      }\n\t\t\\item Finally we have\n\t\t\t      {\\scriptsize\n\t\t\t\t      \\begin{equation*}\n\t\t\t\t\t      \\boxed{\\frac{{\\partial {{\\tilde L}_h}(\\theta )}}{{\\partial \\theta }}\n\t\t\t\t\t      = \\frac{\\partial {{ L}_h}(u_h )}{\\partial u_h}\\frac{\\partial G_h(\\theta)}{\\partial \\theta}=\n\t\t\t\t\t      - \\textcolor{red}{ \\frac{{\\partial {L_h}({u_h})}}{{\\partial {u_h}}} } \\;\n\t\t\t\t\t      \\textcolor{blue}{ \\Big( {\\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}}\\Big|_{u_h = {G_h}(\\theta )}} \\Big)^{ - 1} } \\;\n\t\t\t\t\t      \\textcolor{ForestGreen}{ \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }}\\Big|_{u_h = {G_h}(\\theta )} }\n\t\t\t\t\t      }\n\t\t\t\t      \\end{equation*}\n\t\t\t      }\n\n\t\\end{itemize}\n\n{\\tiny Kailai Xu and Eric Darve, \\textit{Physics Constrained Learning for Data-driven Inverse Modeling from Sparse Observations}}\n\n\\end{frame}\n\n\n\n\\section{Applications}\n\n\n\\begin{frame}\n\t\\frametitle{Parameter Inverse Problem: Elastic Full Waveform Inversion for Subsurface Flow Problems}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.8\\textwidth]{../geo.png}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Fully Nonlinear Implicit Schemes}\n\\begin{itemize}\n\t\\item The governing equation is a nonlinear PDE\n\\begin{minipage}[b]{0.48\\textwidth}\n{\\scriptsize\n\t\\begin{align*}\n\t&\\frac{\\partial }{{\\partial t}}(\\phi {{S_i}}{\\rho _i}) + \\nabla  \\cdot ({\\rho _i}{\\mathbf{v}_i}) = {\\rho _i}{q_i},\\quad \n      i = 1,2\t\\\\\n     & S_{1} + S_{2} = 1\\\\\n      &{\\mathbf{v}_i} = - \\frac{{\\textcolor{blue}{K}{\\textcolor{red}{k_{ri}}}}}{{{\\tilde{\\mu}_i}}}(\\nabla {P_i} - g{\\rho _i}\\nabla Z), \\quad\n      i=1, 2\\\\\n\t&k_{r1}(S_1) = \\frac{k_{r1}^o S_1^{L_1}}{S_1^{L_1} + E_1 S_2^{T_1}}\\\\\n\t&k_{r2}(S_1) = \\frac{ S_2^{L_2}}{S_2^{L_2} + E_2 S_1^{T_2}}\n\t\\end{align*}\n\t}\n\\end{minipage}~\\vline\n\\begin{minipage}[b]{0.48\\textwidth}\n\\flushleft\n\t{\\scriptsize \\begin{eqnarray*}\n && \\rho \\frac{\\partial v_z}{\\partial t} = \\frac{\\partial \\sigma_{zz}}{\\partial z} + \\frac{\\partial \\sigma_{xz}}{\\partial x} \\nonumber \\\\\n && \\rho \\frac{\\partial v_x}{\\partial t} = \\frac{\\partial \\sigma_{xx}}{\\partial x} + \\frac{\\partial \\sigma_{xz}}{\\partial z} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{zz}}{\\partial t} = (\\lambda + 2\\mu)\\frac{\\partial v_z}{\\partial z} + \\lambda\\frac{\\partial v_x}{\\partial x} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{xx}}{\\partial t} = (\\lambda + 2\\mu)\\frac{\\partial v_x}{\\partial x} + \\lambda\\frac{\\partial v_z}{\\partial z} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{xz}}{\\partial t} = \\mu (\\frac{\\partial v_z}{\\partial x} + \\frac{\\partial v_x}{\\partial z}),\n\\end{eqnarray*}}\n\\end{minipage}\n\n\t\\item For stability and efficiency, implicit methods are the industrial standards. \n{\\scriptsize\t$$\\phi (S_2^{n + 1} - S_2^n) - \\nabla \\cdot \\left( {{m_{2}}(S_2^{n + 1})K\\nabla \\Psi _2^n} \\right) \\Delta t = \n\\left(q_2^n + q_1^n \\frac{m_2(S^{n+1}_2)}{m_1(S^{n+1}_2)}\\right) \n\\Delta t\\quad m_i(s) = \\frac{k_{ri}(s)}{\\tilde \\mu_i}\n$$} \n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling Workflow}\n\tTraditionally, the inversion is typically solved by separately inverting the wave equation (FWI) and the flow transport equations. \n\t\\begin{figure}\n\t\t\\centering\n\t\t\t\\includegraphics[width=0.8\\textwidth]{../coupled3}\n\t\t\\includegraphics[width=0.7\\textwidth]{../coupled1}\n\t\\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Coupled Inversion vs. Decoupled Inversion}\n\tWe found that \\textcolor{red}{coupled inversion reduces the artifacts from FWI significantly and yields a substantially better results}. \n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=0.6\\textwidth]{../coupled2}\n\t\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Travel Time vs. Full Waveforms}\n\tWe also compared using only travel time (left, Eikonal equation) versus using full waveforms (right, FWI) for inversion. We found that \\textcolor{red}{full waveforms do contain more information for making a better estimation of the permeability property}. \n\t\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{../coupled4}\n\t\\end{figure}\n\n{\\small The Eikonal equation solver was also implemented with physics constrained learning!}\n\\end{frame}\n\n\n\n\\begin{frame}\n\t\n\tCheck out our package FwiFlow.jl for wave and flow inversion and our recently published paper for this work. \n\t\n\t\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.45\\textwidth]{../fwiflow}~\n\t\\includegraphics[width=0.45\\textwidth]{../fwiflow2}\n\\end{figure}\n\n\\begin{columns}\n\t\\centering\n\t\\begin{column}{0.33\\textwidth}\n\t\t\\begin{center}\n\t\t\t\\textcolor{red}{\\textbf{High Performance}}\n\t\t\\end{center}\n\tSolves inverse modeling problems faster with our GPU-accelerated FWI module. \n\t\\end{column}\n\t\t\\begin{column}{0.33\\textwidth}\n\t\t\\begin{center}\n\t\t\t\\textcolor{red}{\\textbf{Designed for Subsurface Modeling}}\n\t\t\\end{center}\n\tProvides many operators that can be reused for different subsurface modeling problems. \n\t\\end{column}\n\t\\begin{column}{0.33\\textwidth}\n\t\t\t\\begin{center}\n\t\t\\textcolor{red}{\\textbf{Easy to Extend}}\n\t\t\\end{center}\n\t\tAllows users to implement and insert their own custom operators and solve new problems.\n\t\\end{column}\n\n\\end{columns}\n\n\\end{frame}\n\n\\newcommand{\\bsigma}[0]{\\bm{\\sigma}}\n\\newcommand{\\bepsilon}[0]{\\bm{\\epsilon}}\n\n\\begin{frame}\n\t\\frametitle{Function Inverse Problem: Modeling Viscoelasticity}\n%\t\n\t\\begin{itemize}\n\t\t\\item Multi-physics Interaction of Coupled Geomechanics and Multi-Phase Flow Equations \n{\\small\n\\begin{align*}\n\\mathrm{div}\\bsigma(\\bu) - b \\nabla p &= 0\\\\\n    \\frac{1}{M} \\frac{\\partial p}{\\partial t} + b\\frac{\\partial \\epsilon_v(\\bu)}{\\partial t} - \\nabla\\cdot\\left(\\frac{k}{B_f\\mu}\\nabla p\\right) &= f(x,t)\t\\\\\n    \t\\bsigma &= \\bsigma(\\bepsilon, \\dot\\bepsilon)\n\\end{align*}\n}\n\\item Approximate the constitutive relation by a neural network\n{\\small\n$$\\bsigma^{n+1} = \\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n) + H\\bepsilon^{n+1}$$}\n\t\\end{itemize}\t\t\n\t\\begin{figure}[hbt]\t\n\t\\centering\n  \\includegraphics[width=0.5\\textwidth]{../ip}~\n  \\includegraphics[width=0.3\\textwidth]{../cell}\n\\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Neural Networks: Inverse Modeling of Viscoelasticity}\n\t\n\t\\begin{itemize}\n\t\t\\item We propose the following form for modeling viscosity (assume the time step size is fixed):\n\t\t%   $$\\bsigma^{n+1} = \\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n) + H\\bepsilon^{n+1}$$\n\t\t$$\\bsigma^{n+1} - \\bsigma^{n} = \\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n) + H (\\bepsilon^{n+1} - \\bepsilon^n)$$\n\t\\end{itemize}\n\t\\begin{itemize}\n\t\t\\item $H$ is a free optimizable \\textcolor{red}{symmetric positive definite matrix} (SPD). Hence the numerical stiffness matrix is SPD.\n\t\t\\item Implicit linear equation\n\t\t%   $$\\bsigma^{n+1} = H(\\bepsilon^{n+1} - \\bepsilon^n) +  \\left(\\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n)+H\\bepsilon^n \\right)$$\n\t\t$$\\bsigma^{n+1} - H \\bepsilon^{n+1} = - H \\bepsilon^n\n\t\t+ \\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n) + \\bsigma^{n}:= \\mathcal{NN}_{\\bt}^* (\\bsigma^n, \\bepsilon^n)$$\n\t\t\\item Linear system to solve in each time step $\\Rightarrow$ good balance between \\textcolor{red}{numerical stability} and \\textcolor{red}{computational cost}.\n\t\t\\item Good performance in our numerical examples.\n\t\\end{itemize}\n\\end{frame}\n\n% \\begin{frame}\n% \t\\frametitle{Neural Networks: Inverse Modeling of Viscoelasticity}\n% \t\\begin{figure}\n% \t\t\\centering\n% \t\t\\includegraphics[width=0.7\\textwidth]{figures/strainstreess}\n% \t\\end{figure}\n% \\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Training Strategy and Numerical Stability}\n\t\n\t\\begin{itemize}\n\t\t\\item Physics constrained learning = improved numerical stability in predictive modeling.\n\t\t\\item For simplicity, consider two strategies to train an NN-based constitutive relation using direct data $\\{(\\epsilon_o^n, \\sigma_o^n)\\}_n$\n\t\t$$\\Delta \\sigma^n = H \\Delta \\epsilon^n + \\mathcal{NN}_{\\bt} (\\sigma^n, \\epsilon^n),\\quad H \\succ 0$$\n\t\t\\item Training with input-output pairs\n\t\t$$\\min_{\\bt} \\sum_n \\Big(\\sigma_o^{n+1} - \\big(H\\epsilon_o^{n+1} +  \\mathcal{NN}_{\\bt}^* (\\sigma_o^n, \\epsilon_o^n)\\big) \\Big)^2$$\n\t\t\\item Better stability using training on trajectory = \\textcolor{red}{physics constrained learning}\n\t\t\\begin{gather*}\n\t\t\\min_{\\bt} \\ \\sum_n (\\sigma^n(\\bt) - \\sigma_o^n)^2 \\\\\n\t\t\\text{s.t. }\\text{I.C.} \\ \\sigma^1 = \\sigma^1_o \\text{ and time integrator\\ }\n\t\t{\\small \\Delta \\sigma^n = H \\Delta \\epsilon^n + \\mathcal{NN}_{\\bt} (\\sigma^n, \\epsilon^n)}\n\t\t\\end{gather*}\n\t\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Experimental Data}\n\t\n\t\\includegraphics[width=1.0\\textwidth]{../experiment}\n\t\n\t{\\scriptsize Experimental data from: Javidan, Mohammad Mahdi, and Jinkoo Kim. ``Experimental and numerical Sensitivity Assessment of Viscoelasticity for polymer composite Materials.'' Scientific Reports 10.1 (2020): 1--9.}\n\t\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling of Viscoelasticity}\n\t\n\t\\begin{itemize}\n\t\t\\item Comparison with space varying linear elasticity approximation\n\t\t\\begin{equation*}\n\t\t\t\\bsigma = H(x, y) \\bepsilon\n\t\t\\end{equation*}\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../visco1}\n\\end{figure}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling of Viscoelasticity}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.7\\textwidth]{../visco2}\n\\end{figure}\n\n\\end{frame}\n\n\n\\section{ADCME: Scientific Machine Learning for Inverse Modeling}\n\n\\begin{frame}\n\t\\frametitle{Physical Simulation as a Computational Graph}\n\t\\begin{figure}[hbt]\n\t\t\\includegraphics[width=1.0\\textwidth]{../custom.png}\n\t\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{A General Approach to Inverse Modeling}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../summary.png}\n\\end{figure}\n%\n\\end{frame}\n\n%}\n%\\usebackgroundtemplate{}\n%----------------------------------------------------------------------------------------\n%    PRESENTATION SLIDES\n%----------------------------------------------------------------------------------------\n\n%------------------------------------------------\n\n\n\n\\end{document} ", "meta": {"hexsha": "3e23a91ac24eece108851e97f402526375ef7a4d", "size": 27558, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/assets/Slide/Subsurface.tex", "max_stars_repo_name": "z403173402/ADCME.jl", "max_stars_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/src/assets/Slide/Subsurface.tex", "max_issues_repo_name": "z403173402/ADCME.jl", "max_issues_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/src/assets/Slide/Subsurface.tex", "max_forks_repo_name": "z403173402/ADCME.jl", "max_forks_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-14T09:14:08.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-14T09:14:08.000Z", "avg_line_length": 33.4036363636, "max_line_length": 1235, "alphanum_fraction": 0.6895275419, "num_tokens": 8749, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7431680199891789, "lm_q1q2_score": 0.4460407945719605}}
{"text": "\\section{Introduction}\nAny biological system is characterised by interactions between components. The study of these interactions is essential to understanding the mechanisms that regulate complex diseases and to unravel the functional aspects of genetic compounds. \nIn several fields of research, from social to telecommunication and biology, system interactions are increasingly represented by graphical models (\\citealp{Vidal2011Complex, BAR03a, wisdomcrowds}). Generally speaking, those are defined by a set of nodes and a set of edges. Each node usually represents a specific biological component that interacts with others to perform specific functions. Edges may have several meanings, depending on the type of interactions they represent, such as similarity, causality, distance, etc. \nIn the field of network theory and genetics, the nodes of a graph usually represent genes and the edges represent the interactions among nodes. Consequently, a network graph of genetic interactions is a suitable way to visualise clusters, detect modules or pathways, according to the purpose of the analysis.\nNetwork modelling has proven to be an effective approach in computational biology due to the straightforward representation of conditional dependency between variables (\\citealp{netmedicine1, netmedicine2}).\nIt is known that genes act in clusters and their individual effects tend to be characterised by a smaller magnitude within the system as a whole (\\citealp{Michalak2008243, YiST07}). Graphical models facilitate the detection of  main genetic effects. Moreover, pathways of genes become more visible to the researcher who investigates the data, giving a more complete explanation of the biological function that the pathway itself performs.\nOne viable way to represent the interactions of the nodes of a graph - and consequently the  topology of the resulting network - is usually represented by the adjacency matrix $\\beta = \\beta_{ij}$. The values of each entry $(i,j)$ in the adjacency matrix represent the magnitude of the interaction between two nodes, whereas zeros are equivalent to absence of interaction between node $i$ and node $j$. \nSpecifically to the field of computational biology, one possible way to learn the structure of genetic interactions is to analyse the expression profile of a number of genes. The task becomes challenging due to the presence of noise in the measurements, the high dimensionality of data and multicollinearity of variables. \nDespite active research in the field of high-density oligonucleotide arrays, noise still represents a consistent source of error. Any analysis subsequent to the measurement of a subset of genes should take into consideration the artifacts that are usually introduced by noise or by the computational methods performed to mitigate it (\\citealp{microarray_noise, microarray_high_noise}).\nIn addition to the presence of noise, high dimensionality is a very common aspect of genetic data. The number of genes $p$, usually much larger than the number of individuals $n$, makes the task of discovering interactions extremely difficult. \nWithout loss of generality, the problem of inferring the conditional independence between variables is equivalent to the problem of computing the sample covariance matrix of the interactions among variables. In the case of high dimensional data, as well as in a more relaxed case in which the number of individuals has a similar order of magnitude as the number of genes, the inverse of the sample covariance matrix does not exist (\\citealp{Buhl93mle}). This makes the solution of the interaction problem numerically unstable and the discovered interactions unreliable. \n\nFinally, gene expression profiles are affected by the presence of multicollinearity (\\citealp{est_multicoll, ml_multicoll}), namely two or more genes or genetic compounds can be highly correlated. Highly correlated predictor variables can give rise to non-sensical results or, specifically to regression methods, can lead to parameter estimates of incorrect magnitude and sign (\\emph{harmful multicollinearity}). Moreover, the greater the number of covariates, the higher the risk of such critical scenarios (\\citealp{multicollinearity_kvs}).  \nA number of techniques to mitigate the problem of multicollinearity have been indicated in the literature. Regressing each covariate on the others and investigating the stability of regression models to predicting the response variable are two methods that have been denoted in (\\citealp{multicollinearity_kvs}). The same line of conclusion is depicted in (\\citealp{farrar1964multicollinearity}), which states that successful forecast with multicollinear variables requires both a stable dependency relationship between the response and the independent variables and stable interdependency relationships within the predictors. Collecting additional data as a solution of the multicollinearity problem is suggested in (\\citealp{multicollinearity_kvs, farrar1964multicollinearity}).\nThe presence of multicollinearity can influence the performance of methods that rely on regression. The regression coefficient of a predictor variable's importance on the target variable has the tendency to lose precision with respect to the case in which the same genes were uncorrelated. \nFrom a biological perspective, it is broadly recognised that strong genetic correlations are frequent in microarray data and that, in contrast, complete independence between any two gene expression measurements is rare (\\citealp{genesets}). Therefore, it is expected that functionally related genes are correlated to each other and might be co-expressed. This biological phenomenon can be explained by assuming the presence of high correlation for a subset of genes in the dataset under study. Moreover, as the gene sets to be tested are usually chosen on the basis of functional annotation, it should be expected that many of the tested genes might be, in fact, correlated (\\citealp{genesets}).\nSome regression-based methods like the one described in this paper are even more sensitive to the presence of multicollinearity as they tend to select only one or few highly correlated variables.\n\nWe propose a penalised linear regression approach that can deal with the aforementioned issues affecting genetic data. We analyse the gene expression profiles of individuals with a common trait to infer the network structure of interactions among genes. The core idea consists in reducing the number of meaningful interactions with each gene, in order to build a sparse network. Penalised linear regression (Lasso) has been investigated in seminal work reported in (\\citealp{Tibshirani94regressionshrinkage, Meinshausen06highdimensional, finegold, Meinshausen_stabilityselection}), in which each variable is considered response and the remaining ones are independent covariates. In the aforementioned work, bootstrapping has been extensively used to improve the stability of the predicted interactions. Unfortunately, the nature of genetic data and the presence of highly correlated variables can play a detrimental role that affects the overall reliability of discovered interactions. Specifically, Lasso-based regression procedures are known to deal poorly with highly correlated variables since only one in a group of multi correlated covariates is selected. Bootstrapping does not seem to mitigate such a troublesome condition.\n\nIn this paper, we consider the use of Lasso penalised regression as a starting point. We subsequently rely on a permutation-based approach in order to increase the significance of predicted interactions. \n\nIn Section \\ref{approach}, we describe the method in detail. In Section \\ref{results}, we measure the performance of our approach on simulated genetic networks of different size. Conclusion and future developments are drawn in Section \\ref{conclusion}.\n\n%However, it remains unclear how the three processes of differentiation, proliferation, and apoptosis in regulating stem cells collectively manage these challenging tasks.\n\n\n\n", "meta": {"hexsha": "890ee247dd8ccdfcd5a42485296da1c1553d7c23", "size": 8058, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LABnet bioinformatics/introduction.tex", "max_stars_repo_name": "worldofpiggy/academic-papers", "max_stars_repo_head_hexsha": "a9ad707cf504e6460ebc0ec53e6217156726022a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-31T19:39:38.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-31T19:39:38.000Z", "max_issues_repo_path": "LABnet bioinformatics/introduction.tex", "max_issues_repo_name": "worldofpiggy/academic-papers", "max_issues_repo_head_hexsha": "a9ad707cf504e6460ebc0ec53e6217156726022a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LABnet bioinformatics/introduction.tex", "max_forks_repo_name": "worldofpiggy/academic-papers", "max_forks_repo_head_hexsha": "a9ad707cf504e6460ebc0ec53e6217156726022a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 277.8620689655, "max_line_length": 1231, "alphanum_fraction": 0.828617523, "num_tokens": 1535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7431680199891789, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4460407945719605}}
{"text": "% Chapter 4\r\n%\r\n\\chapter{Implementation of SendIt} % Main chapter title\r\n%\r\n\\label{Chapter4} % For referencing the chapter elsewhere, use \\ref{Chapter1} \r\n%\r\nIn this chapter the implementation specifics of SendIt will be discussed. It will go through how the application looks and functions, how the ACS server is implemented, and finally, how the application can be extended and improved.\r\n\r\n\\section{Application}\r\n%\r\n  In this section, everything regarding the implementation of the application will be discussed, except the usage modes. It will go through the implementation and usage of SendIt and clearly explain how the different concepts and technology works.\r\n  %\r\n  \\subsection{Cryptography}\r\n  \\label{sec:crypto_imp}\r\n    In SendIt's implementation, the Web Crypto API (SubtleCrypto module) is used for generating and handling keys \\cite{ar_webcrypto}. This allows for an easy and reliable way to standardize the handling of keys, encryption and decryption, in every system. The Web Crypto API is available in most internet browsers. It has been available through the Chrome browser, since the release of version 37 \\cite{url_webcr_supp}. Using a pre-developed, and tested API for SendIt's cryptographic functions allows for a more reliable system. Since the implementation of the cryptographic functions and debugging has already been done, it allows more time to be spent on developing other functionality. This is the reasoning for using the Web Crypto API.\r\n\r\n    The system begins with creating a unique key pair, if no such key pair already exists. This check is done at the time of choosing to send or receive a file so that, if desired, the user can change to the correct identity for this connection. The key pairs used consists of two RSA-OAEP 2048 bit keys with SHA-1 hashing, but this is easy to change if the need arises. The choice of key-type was based on the recommendation of the WebCrypto API specification \\cite{ar_webcrypto}.\r\n\r\n    The key-exchange is done over the secure DataChannel created by WebRTCs PeerConnection \\cite{ar_webrtc}. Once a key exchange (successful connection) has taken place, the created key pair and the other identity's public key will be written to the disk.\r\n\r\n    SendIt imports the file into memory once a key is needed. After which it extracts the keys stored. Once the keys have been used and the communication has finished, SendIt will overwrite the existing file with the new, updated information. The file containing the keys has information exceeding just the known keys. Both the identity associated with a key, and the key itself, has to be stored.\r\n\r\n    As discussed in \\Cref{sec:crypto_des}, SendIt uses symmetric and asymmetric keys, since asymmetric keys can only encrypt small amounts of data. The maximum amount of data the asymmetric key pair mentioned previously (\\emph{RSA-OAEP 2048 bit with SHA-1 hashing}) can encrypt is 214 bytes \\cite{PKCSV2RSA2012}. SendIt uses an AES-GCM symmetric key, with a length of 256 bits, which allows for encryption of up to \\emph{2\\textsuperscript{39}-256} bytes of data \\cite{ar_webcrypto}. This is well within the limits of what is necessary in SendIt. \r\n\r\n%\r\n  \\subsection{Connection setup}\r\n  \\label{sec:conn_set_imp}\r\n  %Connection setup - Offer&Answer generation & Processing\r\n    This section will explain the functionality of generating the connection information and how each endpoint processes that information in order to create the connection. SendIt implements two different ways to share the connection information, in order to create a P2P connection between two endpoints. These two modes will be explained in \\Cref{Chapter5}.\r\n\r\n    %Offer / Answer generation\r\n    The Offer and Answer generation and processing is done as described in \\Cref{sec:webrtc}. The difference from the normal usage is that they can also be encrypted before being transferred, which means they have to be decrypted before being used. The original form of the data is a JavaScript object.\r\n\r\n    To encrypt the data, it is first turned into a string, then to an ArrayBuffer, after which it is encrypted. To decrypt the data, it is converted from a string to an array of integers. It is then converted to an Uint8Array before being decrypted. The decrypted data is also an Uint8Array, which is turned into a string, and then back into a JavaScript object. All the conversions just mentioned, stem from the different data formats required by the different libraries and frameworks. For more information on how the data is exchanged, see \\Cref{Chapter5}.\r\n\r\n    %ICE and SDP? How and waht differs?\r\n    The actual setup of the connection and the creation of the DataChannel is done according to the examples and descriptions in \\Cref{sec:webrtc}. The only difference in connection setup between the two modes, is if ICE trickling is used or not.\r\n\r\n    When the Offer and Answer is successfully exchanged, a direct connection is created. There are scenarios, when this is not case. Known causes of issues with completing the connection are:\r\n    %\r\n    \\begin{itemize}\r\n      \\item Setup not completed within a certain time frame (see \\Cref{Chapter6})\r\n      \\item One or both endpoints are behind symmetrical NAT\r\n      \\item One or both endpoints change network location (For example, connect to a different network.)\r\n    \\end{itemize}\r\n    %\r\n\r\n    When implementing SendIt, the choice was made to not support symmetrical NAT, as it requires a TURN server. This means the connection would no longer be a direct end-to-end connection. \r\n    Widespread use of IPv6 would solve this issue, as it would eliminate the need for NAT traversal and TURN servers. As for changes in network conditions, there is nothing to be done on the application side, except including a signaling server. As such, the system assumes that users will stay in the same network conditions for the duration the connection is active. For the ACS mode, automatic reconnection is an option which can be added as an extra feature.\r\n  \r\n  \\subsection{File transfer functionality}\r\n    %Chunking & Size limit\r\n    The communication will consist mostly of file data, and as such, it is interesting to know how much data can be handled. In theory, splitting files into chunks during reading, and then transferring these chunks, allows for infinitely large transfers. The default max size for Node.js is approximately 1 GB for 32-bit machines, and 2 GB for 64-bit machines. This indicates the maximum amount of data that can be kept in memory. The reason for this limit is because this is the max amount of data the V8 JavaScript engine used by Node.js can have in memory at the time \\cite{url_node,url_v8}.\r\n\r\n    The current functionality separates each file into chunks of 1200 bytes, as is the limit imposed by the Chromium implementation of WebRTC \\cite{SctptransportCcCode}. The max file size is set to 160 megabytes during development, since it was the max size used by PubShare \\cite{url_pubshare}. It is likely that this can be increased without any issues, since Node.js has support for keeping larger files in memory, but it would require some testing before being ready to deploy. See \\Cref{fig:file_off} for an illustration of the previous explanation.\r\n\r\n  \\subsection{Programming languages, libraries and frameworks}\r\n    SendIt is developed in JavaScript utilizing the Electron framework. These technologies were chosen because they allow for easy implementation, while supporting multiple operating systems. Easy connection setup and direct communication via P2P is also available, through pre-developed and tested frameworks. In addition, it also allows for the use of existing libraries and standardizations developed for web browsers, in desktop applications. \r\n\r\n    To clarify, this means that the user does not need to open their web browser to utilize SendIt, but can install it and run it like they would run any desktop program with a GUI. It also allows for easy creation of an installer file, which means the end user only needs to download and run the installer, for the program to be usable.\r\n\r\n    %\r\n    \\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=60mm]{Dev_Stack_New}\r\n    \\caption[Application stack]{The stack for the prototype application. It is built using HTML, Electron, and JavaScript.}\r\n    \\label{fig:dev_stack}\r\n    \\end{figure}\r\n\r\n    The electron framework uses Node.js for the back end and Chromium for the front end \\cite{url_electron}. In practice, this means that the system is built on: HTML, Electron and JavaScript, where Electron utilizes Chromium and Node.js. (see \\Cref{fig:dev_stack}) This allows us to use modules and frameworks from any of the previously mentioned entities independently. Our implementation uses these libraries and frameworks:\r\n    %\r\n    \\begin{itemize}\r\n    \\item Node.js API - Used for reading and writing to the disk and finding correct files and folders \\cite{url_node}.\r\n    \\item Chrome Web Cryptography API - Used to handle the creation and exportation of keys, encryption, and decryption \\cite{ar_webcrypto,url_webcr_supp}.\r\n    \\item Node.js Clipboardy - Utilized to automatically copy the generated Offer/Answer to the clipboard \\cite{url_clipboardy}.\r\n    \\item Node.js Electron-prompt - Used to create pop-ups for requesting user input \\cite{url_ele-prompt}.\r\n    \\item Chrome Native WebRTC - Used for creating and managing WebRTC connections \\cite{url_webrtc_chrome}.\r\n    \\item jQuery v3.2.1 - Utilized to manage front end actions and dynamic updates \\cite{url_jQuery}.\r\n    \\item Bootstrap v3.3.7 - Used to manage front end modules and dynamic updates \\cite{url_bootstrap}.\r\n    \\end{itemize}\r\n    %\r\n\r\n  %\r\n  \\subsection{Program flow}\r\n  \\label{sec:progflow}\r\n  %Program Flow\r\n  The general appearance of the program will be explained in the following section. The functionality which is unique to each mode will be discussed in \\Cref{Chapter5}. That means that most of the actual functionality is not explained here, but rather the installation, setup, and settings available. In addition, it will also explain the screens not related to the connection setup. These include the waiting screen, the transfer status screen, and the transfer complete screen.\r\n  %\r\n    \\subsubsection*{Installation and launching application}\r\n    %Installation and launch\r\n      %Screenshots and explanation\r\n    The application comes in the form of installer files for Linux, Mac, and Windows. These files are in the format of \\emph{.deb} for Linux, \\emph{.dmg} for Mac, and \\emph{.exe} for Windows. The installers are very basic and require no interaction except executing them. After that is done, the image shown in \\Cref{fig:inst} will appear and display a small animation. Afterwards, SendIt is installed and will be available. In most cases, the icon will be available on the desktop. Once the application is launched for the first time, a pop-up window will appear, as indicated in \\Cref{fig:popup}. Afterwards, the user is taken to the Home screen. This pop-up window will only be displayed the first time the program is opened.\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=60mm]{Figures/Base/installer}\r\n      \\decoRule\r\n      \\caption[SendIt: Install animation]{While the installation of SendIt is ongoing, this small box, with basic animations, will appear. Once it disappears, the program is installed.}\r\n      \\label{fig:inst}\r\n    \\end{figure}\r\n\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=80mm]{Figures/Base/start_up}\r\n      \\decoRule\r\n      \\caption[SendIt: First launch pop-up]{This pop-up appears the first time the program is started. It informs the user of the default location of the upload folder. The files the user wants to send should be placed in this folder.}\r\n      \\label{fig:popup}\r\n    \\end{figure}  \r\n    %\r\n  \\subsubsection*{Home screen}\r\n  %Home screen\r\n    %Screenshot & explanation. Include popup!\r\n  The Home screen is the first screen the user sees. On this screen, there is not much detail or information. The logo and acronym for SendIt is displayed, as well as the navigation bar. From here on, it is all about choosing the desired functionality or tweaking the settings to fit the users desire. The only difference between the Home screen for the two modes, is the formatting of the word 'Serverless' at the bottom of the screen, as well as the ACS mode not having a receive button on the navigation bar.\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/Home_Screen}\r\n      \\decoRule\r\n      \\caption[SendIt ACS mode: Home screen]{The Home screen displayed when the application is in ACS mode. The navigation bar has no button for receiving files. The 'Serverless'-part of SendIt's acronym is also crossed out, at the bottom of the page.}\r\n      \\label{fig:hs_acs}\r\n    \\end{figure}\r\n\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/Home_Screen_SL}\r\n      \\decoRule\r\n      \\caption[SendIt Serverless mode: Home screen]{The Home screen displayed when the application is in Serverless mode. The navigation bar has a button for both sending and receiving files.}\r\n      \\label{fig:hs_sl}\r\n    \\end{figure}\r\n\r\n  \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/navbar_sl}\r\n      \\decoRule\r\n      \\caption[SendIt: Navigation bar]{The navigation bar displayed in Serverless mode. The receive-button is not present in the ACS mode, since a separate page will be displayed if someone offers to send file(s) to you. This bar is always displayed at the top of the window.}\r\n      \\label{fig:hs_nb}\r\n    \\end{figure}\r\n  %\r\n  \\subsubsection*{Settings}\r\n  %Settings screen\r\n    %Screenshot and explanation.\r\n    The base view of the settings page is represented in \\Cref{fig:sett}. At the top one can input which identity (or e-mail address if you will) to use. Further down, one can remove the configuration file, the file which stores all the data about which identity and which settings to use. Following are radio buttons, where one can choose which mode to use and if one wants to use custom locations, for example, where to store downloaded files. At the bottom, information about the current settings are displayed. Finally, there is a 'save changes' button, to store the changes made.\r\n\r\n    In \\Cref{fig:set_det}, more detailed options are displayed. These appear when clicking the non-default option of the radio buttons. If the ACS option is selected for \\emph{Mode selection}, the field for indicating the address of the server is displayed, as well as a 'save' button and a 'reset' button. Afterwards, there is an option for manually selecting a file from which to load keys. One can also remove the file currently used, by pressing the 'remove ALL current keys!' button or remove individual keys by clicking on the corresponding e-mail address. Finally, one can customize the download and upload folder location.\r\n    %Base screen\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/Settings}\r\n      \\decoRule\r\n      \\caption[SendIt: Settings screen]{The screen used for indicating user preferences, upload and download locations, identity management, and mode selection.}\r\n      \\label{fig:sett}\r\n    \\end{figure}\r\n\r\n    %Details screen\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=70mm]{Figures/Base/settings_expanded}\r\n      \\decoRule\r\n      \\caption[SendIt: Detailed settings screen]{The expanded version of the settings screen with the selections and menus displayed.}\r\n      \\label{fig:set_det}\r\n    \\end{figure}\r\n\r\n  \\subsubsection*{After successful connection setup}\r\n  \\label{sec:file_recv}\r\n  %\r\n    All the following examples are taken from the Serverless mode, but they look identical in the ACS mode, with the exception of the navigation bar. These are the different screens shown once the endpoint has completed their part of the connection setup exchange.\\\\\r\n     \r\n    \\noindent\r\n    \\underline{Waiting screen}\\\\\r\n    The waiting screen is displayed while the endpoints are waiting for WebRTC to establish the P2P connection.\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/waiting}\r\n      \\decoRule\r\n      \\caption[SendIt: Waiting for connection screen]{This screen is displayed while waiting for the endpoints to connect via P2P (WebRTC).}\r\n      \\label{fig:SL_wait}\r\n    \\end{figure}\r\n\r\n    %\r\n    \\noindent\r\n    \\underline{Transfer screen}\\\\\r\n      It displays details about the current file being transferred; it's name and type, as well as the total number of files to transfer. It also shows the percentage of data transferred for the current file. Finally, there is a cancel button in case one end wants to stop the transfer.\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/transfer}\r\n      \\decoRule\r\n      \\caption[SendIt: Transfer screen]{This screen displays details about the status of the current transfer.}\r\n      \\label{fig:SL_trans}\r\n    \\end{figure}\r\n\r\n    %\r\n    \\noindent\r\n    \\underline{Connection completed screen (\\emph{Sender})}\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/sender_complete}\r\n      \\decoRule\r\n      \\caption[SendIt: Final screen (Sender)]{This screen displays details about which files were transferred.}\r\n      \\label{fig:SL_rec1}\r\n    \\end{figure}\r\n\r\n    %\r\n    \\noindent\r\n    \\underline{Connection completed (\\emph{Receiver})}\r\n    \\begin{figure}[H]\r\n      \\centering\r\n      \\includegraphics[width=\\textwidth]{Figures/Base/receiver_complete}\r\n      \\decoRule\r\n      \\caption[SendIt: Final screen (Receiver)]{This screen displays details about which files were received. It also has an 'open containing folder'-button for easy access to the received files.}\r\n      \\label{fig:SL_rec2}\r\n    \\end{figure}\r\n%\r\n\\section{ACS server implementation}\r\n\\label{sec:acs_serv_imp}\r\n\r\n  The ACS server is implemented in JavaScript, using the Node.js environment. It uses a library implementing the Web Crypto API for Node.js \\cite{WebcryptoW3CWeb2018}, which allows for the use of the same keys, the same encryption scheme and generally the same cryptographic solutions as in the application. This makes it easy to use and means there is no need for developing support for, or using other cryptographic methods, to authenticate with the ACS server.\r\n\r\n  \\subsection{WebSockets}\r\n  \\label{sec:acsws}\r\n  %WS\r\n    %How is it used, secure, advantage\r\n    %IMPLEMENTATION\r\n    All communication between endpoints and the ACS server is done over WebSockets using HTTPS. This enables bi-directional communication at any time and creates an easy interface to use for communicating with different endpoints. The communication is exclusively done using the protocol described in the next section.\r\n    \r\n    The WebSocket interface and API also allows for easy handling and management of clients. Clients can connect and disconnect randomly without affecting the service as a whole. All clients are treated equally and it is easy to address each client individually. Because of this, it is very easy to receive information from one client and immediately forward it to the intended recipient. \r\n\r\n  \\subsection{Protocol}\r\n  \\label{sec:prot_imp}\r\n  This section reviews the implementation of the protocol discussed in \\Cref{sec:wsprot}. For an overview of the packet format, see \\Cref{tab:basic}. The format indicated for each of these packets, goes in the data field of the general packet format. Following is the practical implementation of the protocol.\r\n  %\r\n  \\subsubsection*{Lookup}\r\n %\r\n  The \\emph{Lookup} packet from client to server does not contain any data. The packet sent from the server to the client can contain the data indicated in \\Cref{tab:lookup}. If \\emph{res} is \\emph{true}, the data will consist of the fields \\emph{res}, \\emph{wrap} and \\emph{key}. The \\emph{wrap} field consist of the symmetric key, encrypted with the other endpoint's public key. If \\emph{false}, it will consist of \\emph{res} and \\emph{key} only.\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Lookup packet]{Lookup packet}\r\n    \\label{tab:lookup}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      res & Boolean & Indicates if authentication setup is needed or not & Yes\\\\\r\n      key & JWK & Server's public key in JWK format & Yes\\\\\r\n      wrap & Array & Encrypted symmetric key& No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{Authentication setup}\r\n  %\r\n  The possible arguments used by the Authentication setup and Authentication Setup Reply functionality are shown in respectively \\Cref{tab:auth_set} and \\Cref{tab:auth_s_r}. The public key of the client is sent to the server. The server tries to set up authentication for subsequent connections. The authentication setup is considered a success if no previous data is stored for this e-mail or public key. If this is the case, the \\emph{Authentication Setup Reply} packet will contain \\emph{res} and \\emph{wrap}, where \\emph{res} is set to \\emph{true}. The \\emph{wrap} field consists of the symmetric key, encrypted with the other endpoint's public key. If the setup fails, the \\emph{wrap} field is not included.\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Authentication Setup packet]{Authentication Setup packet}\r\n    \\label{tab:auth_set}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      key & JWK & Client's public key in JWK format & Yes\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Authentication Setup Reply packet]{Authentication Setup Reply packet}\r\n    \\label{tab:auth_s_r}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      res & Boolean & Authentication result & Yes\\\\\r\n      wrap & Array & Encrypted symmetric key& No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{Authentication}\r\n  %\r\n  \\Cref{tab:prot_auth} and \\Cref{tab:prot_auth_rep} shows the possible arguments for the authentication packets. The \\emph{ciph} field contains the client's email address, encrypted with the symmetric key. The \\emph{Authentication Result} packet returns a boolean value directly in the data field, indicating the result of the authentication process. Successful authentication returns \\emph{true}.\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Authentication packet]{Authentication packet}\r\n    \\label{tab:prot_auth}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      ciph & Array & Client's encrypted e-mail address & Yes\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Authentication Result packet]{Authentication Result packet}\r\n    \\label{tab:prot_auth_rep}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      - & Boolean & Authentication result & Yes\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n % \r\n  \\subsubsection*{Init}\r\n  %\r\n  The \\emph{Init} packet can consist of the data shown in \\Cref{tab:init}. It contains information about the files being offered. Each object in the \\emph{files} array has information about the file name, file type and the size of the file.\r\n\r\n   \\begin{table}\r\n    \\caption[ACS protocol: Initiate Connection packet]{Initiate Connection packet}\r\n    \\label{tab:init}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      files & Array & Array of objects with file data & Yes\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{Accept}\r\n  %\r\n  The \\emph{Accept} packet contains the WebRTC Offer generated and indicates that the endpoint wants to receive the data previously offered. The WebRTC Offer can either be encrypted or in cleartext. See \\Cref{tab:acc} for more information about the data transferred. If the Offer is sent in cleartext, the data transferred is just the WebRTC Offer object. If not, the data consists of the other three fields (\\emph{wrap}, \\emph{iv}, and \\emph{ciph}). The \\emph{wrap} field consists of the symmetric key, encrypted with the other endpoint's public key. The \\emph{ciph} field consists of the WebRTC Offer, encrypted with the symmetric key.\r\n\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Accept packet]{Accept packet}\r\n    \\label{tab:acc}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      - & Object & The WebRTC Offer generated by the endpoint & No\\\\\r\n      wrap & Array & Encrypted symmetric key & No\\\\\r\n      iv & Array & Initialization vector for the symmetric key & No\\\\\r\n      ciph & Array & Encrypted WebRTC Offer & No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n  %\r\n  \\subsubsection*{Refuse}\r\n  The refuse packet contains no data. If this packet is received the connection setup is stopped.\r\n%\r\n  \\subsubsection*{Answer}\r\n%\r\n The \\emph{Answer} packet contains the WebRTC Answer generated by the endpoint. The WebRTC Answer can either be encrypted or in cleartext. See \\Cref{tab:ans} for more information about the data transferred. If the Answer is sent in cleartext, the data transferred is just the WebRTC Answer object. If not, the data consists of the other two fields (\\emph{iv} and \\emph{ciph}). The \\emph{iv} field consists of the initialization vector, encrypted with the other endpoint's public key. The \\emph{ciph} field consists of the WebRTC Answer, encrypted with the symmetric key.\r\n %\r\n\\begin{table}\r\n    \\caption[ACS protocol: Answer packet]{Answer packet}\r\n    \\label{tab:ans}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      - & Object & The WebRTC Answer generated by the endpoint & No\\\\\r\n      iv & Array & Encrypted initialization vector for the symmetric key & No\\\\\r\n      ciph & Array & Encrypted WebRTC Answer & No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{ICE}\r\n%\r\n  This packet contains the data showed in \\Cref{tab:ice}. The data can either be encrypted or sent in cleartext. If it is not encrypted, it will be sent as an ICE candidate object. If it is encrypted, it will consist of the fields \\emph{ciph} and \\emph{iv}. The \\emph{ciph} field consists of the ICE candidate, encrypted with the symmetric key.\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: ICE packet]{ICE packet}\r\n    \\label{tab:ice}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      - & Object & The ICE candidate generated by the endpoint & No\\\\\r\n      ciph & Array & Encrypted ICE candidate & No\\\\\r\n      iv & Array & Initialization vector for the symmetric key & No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{Done}\r\n%\r\n  The \\emph{done} packet contains no data, and indicates that the connection is terminated and that the endpoints are ready for a new connection.\r\n%\r\n  \\subsubsection*{Error}\r\n%\r\n  The \\emph{error} packet can contain data about which error occurred. If the server receives an \\emph{error} packet with an indicated destination, it will forward it to the correct endpoint. The data will have the format indicated in \\Cref{tab:err}.\r\n%\r\n  \\begin{table}\r\n    \\caption[ACS protocol: Error packet]{Error packet}\r\n    \\label{tab:err}\r\n    \\centering\r\n    \\begin{tabular}{l l l l}\r\n      \\tabhead{Name} & \\tabhead{Type} & \\tabhead{Argument details} & \\tabhead{Required} \\\\\r\n      \\midrule\r\n      - & String & Error details & No\\\\\r\n      \\bottomrule\\\\\r\n    \\end{tabular}\r\n  \\end{table}\r\n%\r\n  \\subsubsection*{Wait}\r\n%\r\n  The \\emph{wait} packet does not contain data. It indicates that an endpoint is busy, and, as such, cannot partake in a connection at this time. If a destination is specified, the server forwards the packet to the correct endpoint.\r\n%\r\n\\section{Extendability and improvements}\r\n%\r\nIn this section the extendability of SendIt, in general, will be assessed. SendIt can be used as a platform to build extended functionality, and as such, it should be noted in what way this can be done, and how one stands to benefit from doing it. It will also discuss possibilities for improving the current implementation.\r\n\r\n  \\subsection{Key storage encryption}\r\n  %\r\n    The file where keys are stored should be encrypted and password protected, or otherwise access restricted. The key file should only be usable if the correct password is provided. If the wrong password is provided, the keys should not be accessible. The key file should be updated every time it is used by the system. This will allow users to change the password used to access the keys between each use and also make it easy to update information regarding each key. In addition, it gives no guarantee that the same encryption is used each time, which makes attacks over time harder to execute, since there is no reliable way to analyze changes or patterns in the way the file is stored. This functionality should be implemented and would improve the solution. It is not currently implemented in SendIt, due to time constraints. \r\n\r\n  \\subsection{E-mail verification}\r\n  %E-mail verification\r\n    One way to extend the current functionality is to add e-mail verification to the process of registering an identity. This would increase the trustworthiness of each identity since proving ownership of the registered e-mail address would be a necessity. It would however, also include all the issues stemming from how the e-mail system is implemented. It would also make the registration process harder and require more from the users before being able to use the system. Because of these issues, it is not included in the system by default, but can easily be added. It is left up to the end users to develop and extend the proposed system, if such functionality is desired.\r\n\r\n  \\subsection{Support for bigger files}\r\n  \\label{sec:bigfile}\r\n  %\r\n    Supporting bigger files can be achieved by reading in chunks of the file. Then, once a chunk is completely transferred, the next chunk is read into memory. This will allow both endpoints to handle smaller amounts of data at a time, while still having transmitted the whole file after the transfer of all chunks have been completed. It is not recommended to implement this until after the 'resume transfer' feature is implemented, as transferring large amounts of data, without any way of resuming it in case of failure, is less than optimal.\r\n\r\n  \\subsection{Resume transfer}\r\n  \\label{sec:res_trans}\r\n    %\r\n    \\begin{table}\r\n      \\caption[Record of communication]{Fields included in the record of communication.}\r\n      \\label{tab:comm_rec}\r\n      \\centering\r\n      \\begin{tabular}{cccc}\r\n            \\textbf{Sender} & \\textbf{File(s)} & \\textbf{Date} & Completed \\\\\r\n            \\midrule\r\n            test@email.com & picture.jpg & 2018-03-20 & 0\\\\\r\n            another@email.com & document.doc & 2018-05-13 & 4\\\\\r\n            \\bottomrule\r\n      \\end{tabular}\\\\\r\n    \\end{table}\r\n    %\r\n    This functionality can easily be implemented based on a communication record. Since every identity will have a list of previously transferred files, it will have the file name included. If the transfer is not completed, this record can store information about which chunk of the file was the last to be received, and the endpoint can request the transfer to be continued from there.\r\n\r\n    If the sender is not willing to resume the previous transfer, it can either start over, or the sender can offer to transfer another file. This decision is up to the sender's settings and/or preference. If the sender choses to not resume the transfer, the data previously stored on the receiver's local system should be removed, and the record updated as a failed transfer. The system should only allow for the requested file to be shared on the subsequent connection. \r\n\r\n    To clarify: Alice tries to send Bob \\emph{File A}, but the connection is broken. If Alice tries to send \\emph{File A} again, it will resume from the last chunk received. If it fails again, it will also allow for the transmission of \\emph{File A} to be resumed. However, if Alice contacts Bob again, but tries to send \\emph{File B} this time, the previously transmitted information (\\emph{File A}) stored by Bob should be removed.\r\n\r\n    The record of communications can be implemented by creating a log that contains the fields indicated in \\Cref{tab:comm_rec}. The last field can either be \\emph{-1} (meaning failed), \\emph{0} (meaning success) or the number of the last received chunk. This is useful for being in compliance with the GDPR, allowing the user to keep track of their interactions for reviewing their activity, and implementing a 'resume transfer' functionality, as mentioned.\r\n\r\n  \\subsection{WebRTC IDP inclusion}\r\n  %WebRTC IDP\r\n    WebRTC comes with a suggested standard for implementing Identity Provider services. An Identity Provider is a trusted third party that corroborates an identity. An example would be connecting ones Facebook account to an identity, as a means for other endpoints to verify the authenticity of that identity. This is possible for many different services and can be a means of increasing trust in identities. Currently, there are some arguments and disagreements on how this should be implemented in WebRTC, and as such, there are very few existing frameworks that can be used. This is expected to change, and at that point, using these services will allow for an easier way to increase trust in endpoints.\r\n\r\n    The trust is of course reliant on the end user already trusting the service that is used as the Identity Provider, and that the identity is as expected. For example:\\\\\r\n    If the Identity Provider used is a known service (such as Facebook), one can reasonably trust the data received. If it is from a service unknown to the user, then the identity provision does not increase the trust at all, since the data may be created for malicious purposes. In the same way, if the endpoint is expecting to be communicating with Alice, but Bob's identity is asserted by the provider, the end user should be sceptical.\r\n\r\n    In summary, this functionality would allow one to link accounts from other, independent services with their WebRTC connection, in order to corroborate the endpoint's identity and increase trust.\r\n\r\n  \\subsection{SendIt as a platform}\r\n  %\r\n    This is an interesting idea since the proposed system allows for connection setup and identity assertion. One can use SendIt for this functionality and build any kind of additional functionality on top, if so desired. Especially combining with VOIP, which WebRTC is often used for, can be useful. It allows the developers to focus on their services and additional functionality, while allowing the easy to use and secure setup offered by SendIt to take care of identity management and authentication. The design and implementation of SendIt is modular, which means one can easily pick and choose which functionality one wants to utilize, and discard the rest. This makes it easy to take advantage of the wanted functionality, while not complicating the solution by including the functionality that is not useful to the specific scenario at hand. ", "meta": {"hexsha": "d1b1cbacb04dc33714f99f6a244a6f0f3abb32d7", "size": 36043, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Latex/Chapters/Chapter4.tex", "max_stars_repo_name": "Robiq/Thesis", "max_stars_repo_head_hexsha": "9f764a067ffef6984533dfe17c1f5366a7ec0a16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Latex/Chapters/Chapter4.tex", "max_issues_repo_name": "Robiq/Thesis", "max_issues_repo_head_hexsha": "9f764a067ffef6984533dfe17c1f5366a7ec0a16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Latex/Chapters/Chapter4.tex", "max_forks_repo_name": "Robiq/Thesis", "max_forks_repo_head_hexsha": "9f764a067ffef6984533dfe17c1f5366a7ec0a16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.3898678414, "max_line_length": 850, "alphanum_fraction": 0.7440834559, "num_tokens": 8344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4460407877437989}}
{"text": "\\documentclass{article}\n\\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx} % For .eps inclusion\n%\\usepackage{indentfirst} % Controls indentation\n\\usepackage[compact]{titlesec} % For regulating spacing before section titles\n\\usepackage{adjustbox} % For vertically-aligned side-by-side minipages\n\\usepackage{array, mathrsfs, mathrsfs, mhchem, amsmath} % For centering of tabulars with text-wrapping columns\n\\usepackage{hyperref, chemfig}\n\\usepackage{subfigure}\n\\usepackage[autolinebreaks,framed,numbered]{mcode}\n\\newcommand{\\Lapl}{\\mathscr{L}}\n\n\\pagenumbering{gobble} \n\\setlength\\parindent{0 cm}\n\\begin{document}\n\\large\n\n\\section*{Recap of Turing patterns with note on stationary waves in two dimensions}\n\nIn the last question on this week's problem set, you'll be asked to determine which modes will be unstable for a given field size. (The goal of the problem is to show that more stripes will appear as an organism grows.) That question is framed so that it can be solved using the simplifying assumption that the relevant length scale $L$ is the distance from one corner of the field to the other. This works well for explaining the number of stripes in a long, thin domain, but does not explain the transition from a striped pattern to a spotted one as the organism grows fatter.\\\\\n\nTo explain the spots, we should consider perturbations of the form:\n\\[ \\begin{pmatrix} \\alpha\\\\ \\beta \\end{pmatrix} = \\begin{pmatrix} \\alpha_0\\\\ \\beta_0 \\end{pmatrix} e^{\\lambda t} e^{iqx} e^{iry} \\]\n\nWe will plug this solution into our reaction-diffusion equation on the plane:\n\\[ \\frac{\\partial}{\\partial t} \\begin{pmatrix} \\alpha\\\\ \\beta \\end{pmatrix} = \\mathbf{C} \\begin{pmatrix} \\alpha\\\\ \\beta \\end{pmatrix} + \\mathbf{D} \\nabla^2 \\begin{pmatrix} \\alpha\\\\ \\beta \\end{pmatrix} \\]\n$\\nabla^2$ is the Laplace operator. In one dimension, it is simply the second spatial derivative. On the Cartestian plane, it is:\n\\[ \\nabla^2 = \\frac{\\partial^2}{\\partial x^2} + \\frac{\\partial^2}{\\partial y^2} \\]\nPlugging in, calculating the derivatives, and combining terms, we have:\n\\begin{eqnarray}\n\\left[ \\mathbf{C} - \\left( q^2 + r^2 \\right) \\mathbf{D} - \\lambda \\mathbf{I} \\right] \\begin{pmatrix} \\alpha_0\\\\ \\beta_0 \\end{pmatrix} = 0 \\implies \\left|\\mathbf{C} - \\left( q^2 + r^2 \\right) \\mathbf{D}  - \\lambda \\mathbf{I} \\right| = 0 \\label{eqn:twodeigenvalue}\n\\end{eqnarray}\nExpanding out the determinant gives a quadratic expression for $\\lambda$. We need at least one of the $\\lambda_i$ to be positive for the system to be unstable, however, the $\\lambda_i$ are centered around a negative number. Therefore we need a large discriminant term to push the large solution to a positive value. Specifically, we need\\footnote{See Lecture 29 notes or the spatial modeling chapter by Iglesias for the full version of an analogous derivation.}:\n\\begin{eqnarray}\n \\textrm{det} \\left( \\mathbf{C} \\right) - \\left(q^2 + r^2 \\right) \\left(c_{11}D_B + c_{22} D_A \\right) + \\left(q^2 + r^2 \\right)^2 D_A D_B < 0 \\label{eqn:twod}\n \\end{eqnarray}\nAs in the one-dimensional case, the wavenumbers $q$ and $r$ cannot assume just any value. Consider a patterning field shaped like the round surface of a cylinder.\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{geometry.pdf}\n\\end{center}\n\nWe could cut this surface and lay it flat: it would have a length $\\ell_x$ equal to the length of the cylinder and a height $\\ell_y$ equal to the circumference of the cylinder. The ``boundaries\" at $x=0$ and $x=\\ell_x$ are reflective: we therefore require that $\\partial_{xx}$ be zero there. The allowable modes in this dimension therefore include half-waves. However, the ``boundaries\" at $y=0$ and $y=\\ell_y$ must have equal values, so only full waves are allowed in the $y$ direction. Thus:\n\\[ q_n = \\frac{\\pi \\, n}{\\ell_x} \\hspace{1 cm} \\textrm{and} \\hspace{1 cm} r_m = \\frac{2 \\, \\pi \\, m}{\\ell_y} , \\hspace{1 cm} n, m \\in \\mathbb{N^0} \\]\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{first_modes_excited.pdf}\n\\end{center}\n\nTo find which modes can be excited for given $\\ell_x$ and $\\ell_y$, we can plug trial combinations of $q_n$ and $r_m$ into inequality \\ref{eqn:twod} and check whether it is satisfied. Multiple combinations may satisfy the expression: in this case, the one which will ``win\" at long times is the one with the largest eigenvalue, which we could determine using equation \\ref{eqn:twodeigenvalue}.\n\n\\subsection*{Aside: non-stationary spatial waves}\n\nOne of the two lectures cut from this year's course was on symmetry and symmetry breaking. We would have covered an example where spatial oscillations are used to identify the center of the \\textit{E. coli} cell, where the septum will form. The basic principle is that oscillations in MinD from one pole to the opposite leave a region in the middle where the average concentration of MinD is relatively low: it is in this region that the contractile FtsZ ring will form at cell division.\\\\\n\nThe Min system is one of the rare few that can be reconstituted \\textit{in vitro} (Loose et al., 2008 and Zieske and Schwille, 2014). Zieske and Schwille induce these oscillations in compartments of varying size, demonstrating that if the dimensions are changed the number of regions where average MinD concentration is low will change. This strikingly demonstrates the dependency of the system on the dimensions of the cell. [Videos from Zieske and Schwille, 2014.]\n\n\\section*{Introduction to modularity and evolvability}\n\nCritical genes are not at liberty to explore sequence space freely: no mutation in them will persist if it impairs their function. This means that these genes can become trapped in ``local maxima\" of performance or fail to gain new functions that interfere with their original one. This limitation can be bypassed, however, via random gene duplication.\\\\\n\nAfter gene duplication, as long as one copy of the gene continues to perform its essential function, the other paralog is freed of selective pressure. A typical outcome is that the unnecessary paralog becomes a non-functional pseudogene and over time is lost entirely. However, with luck, this paralog might instead acquire a new and useful function through mutation. This strategy for acquiring new functionality through gene duplication and subsequent divergence was first proposed by Susumu Ohno (1970) and nowadays has strong support from sequence analysis.\\\\\n\nThe notion that strong selection to maintain a current function is likely to interfere with evolution of a new function is not simply a narrative: in several specific systems it has been demonstrated directly. Consider for example TEM-1 $\\beta$-lactamase, the ampicillin resistance-conferring \\textit{bla} gene found on virtually every bacterial plasmid map. Stiffler et al. (2015) recently explored all amino acid substitution in TEM-1 \\textit{exhaustively} (19 alternatives at each of nearly 300 residues) and found that 106 of them allow TEM-1 to better neutralize cefotaxime, another antibiotic. Unfortunately, most of these mutations also interfere with the enzyme's ability to neutralize ampicillin as evidenced by a fitness defect when grown on ampicillin. The implication is that it would be relatively difficult for the gene to evolve cefotaxime neutralization while undergoing selection for ampicillin resistance. This is a case where gene duplication and subsequent relief of selection on one paralog would facilitate acquisition of a new function. \n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{stiffler_graphic.pdf}\n\\end{center}\n\n\n\\section*{Two-component systems}\n\nOne gene family where this mode of evolution is especially apparent are the two-component signaling systems. (The signaling lecture was unfortunately canceled this year due to weather, so we will instead discuss that system here.) Unlike the MAP kinase systems which have appeared often in the course, two-component systems consist of only a receptor (called a histidine kinase) and the response regulator, a signaling effector. The receptor gets this name because it controls the phosphorylation state of its response regulator by transferring a phosphate from a histidine residue to the RR in a signaling-dependent manner. When no signaling is occurring, it may also act as a phosphatase.\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{two_component_diagram.pdf}\n\\end{center}\n\nWhereas the serine/threonine and tyrosine receptor families have expanded substantially in eukaryotes, histidine kinases are the major expanded family in bacteria: some species have as many as 200 two-component pathways, though most have only around 30. In many cases both a histidine kinase and its corresponding response regulator are found in a single operon, facilitating duplication of the pair. Despite their common origins, these two-component pathways are very effective at avoiding crosstalk.  To show this, Skerker et al. (2005) added $^{32}$P-labeled ATP to purified histidine kinases, which transferred the labeled phosphate to their histidines. They then added the same response regulator to each reaction and checked for transfer from the HK to the response regulator after 10 seconds or one hour. Only the correct pair showed transfer on the fast timescale. (Slower reactions were apparent for a pair isolated in vitro, but would likely not be relevant physiologically due to competition between response regulators within the cell.)\n\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{skerker2005.pdf}\n\\end{center}\n\nAttaining specificity of interactions following duplication and divergence is a major concern for the neofunctionalization by duplication and divergence. Even before the first HK-RR crystal structure was solved, the Laub lab was searching for the interactions between histidine kinases and their response regulators that conferred specificity. These proteins had accumulated many sequence differences over a very long period of divergence, so that the relevant changes could not be identified simply by alignment and inspection. Skerker et al. (2008) approached this problem computationally, taking advantage of the fact that mutations at the interaction interface on one partner might be compensated by mutations on the other. Thirteen hundred HK-RR sequence pairs were known to science at that time: within this dataset, perhaps the same compensating mutations would have arisen independently multiple times.\\\\\n\nThe authors used a metric called mutual information to search for cases where knowing the amino acid at one residue on one partner gave a better-than-chance prediction of the amino acid at a residue on the other partner. If $p_i$ is the probability of finding amino acid $i$ at residue $x$ on the HK, and $p_j$ is the proboably of finding amino acid $j$ at residue $y$ on the RR, and $p_{ij}$ is the probability of both occurring, then\n\\[ \\textrm{MI } = \\sum_{i=1}^{20} \\sum_{j=1}^{20} p_{ij} \\ln \\left( \\frac{p_{ij}}{p_i p_j} \\right) \\]\nIf the two events are independent, then $p_{ij} \\approx p_i p_j$ and the ratio within the logarithm is 1, so the mutual information is zero. Additional co-occurrence would elevate the score.\n\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{mi.pdf}\n\\end{center}\n\nThis purely mathematical approach identified several pairs of sites that spanned these two proteins which appeared to be ``evolving together,\" so that certain sequence combinations were much more common than others. Mapping these residues to the closest cognate structure available at that time, the authors found that they seemed to fall at the interface between the two partners just as one would predict.\n\n\\begin{center}\n\\includegraphics[width=0.4\\textwidth]{spo0f.pdf}\n\\end{center}\n\nFollowing duplication, specificity of the new pair for the other could evolve in one of two broad ways. One protein could acquire a mutation by which it loses the ability to interact with its partner (creating a non-functional interaction), and then the partner could happen to evolve a compensatory mutation before either becomes a pseudogene. Alternatively, it might be possible for the specificity residues to mutate in some order by which the two partners never lose the ability to interact with one another. Determining which of these is more likely requires understanding the range of sequence combinations that confer specificity.\\\\\n\nA related question is how well two-component systems have sampled the space of sequences conferring specificity. Do specificity sequences become trapped in local minima, or are extant two-component systems representative of the full range of possible sequence combinations conferring specificity?\\\\\n\nIn a recent attempt to address these question, Pedgornaia and Laub (2015) generate variants of the histidine kinase PhoQ that differ from the wildtype sequence at four residues in the interaction interface. They estimate that all 160,000 possible amino acid sequence variants are covered by their random library. To assess whether these variants are functional, they select cells which express a fluorescent reporter activated by PhoQ's response regulator, PhoP. (Under these conditions, if the PhoQ is not specific, it may transfer its phosphate to other response regulators in the cell which will decrease reporter expression.) The authors find a vast network of sequences which differ from each other by only one amino acid. However, all known PhoQ sequences fall within one region of this network. This may reflect constraints in the ability to mutate from some amino acids to others (some changes require only one base pair mutation; others, more).\n\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{podgornaia.pdf}\n\\end{center}\n\n\\end{document}", "meta": {"hexsha": "1b267179d307d9c07c4db9f5241082498db74018", "size": 13747, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/Lecture 30 - Modularity and Evolvability/lecture notes/lecture 30 notes.tex", "max_stars_repo_name": "mewahl/intro-systems-biology", "max_stars_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-01-20T17:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-31T17:23:09.000Z", "max_issues_repo_path": "lectures/Lecture 30 - Modularity and Evolvability/lecture notes/lecture 30 notes.tex", "max_issues_repo_name": "mewahl/intro-systems-biology", "max_issues_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/Lecture 30 - Modularity and Evolvability/lecture notes/lecture 30 notes.tex", "max_forks_repo_name": "mewahl/intro-systems-biology", "max_forks_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-01-20T17:43:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T14:42:10.000Z", "avg_line_length": 122.7410714286, "max_line_length": 1060, "alphanum_fraction": 0.789772314, "num_tokens": 3311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7431680029241322, "lm_q1q2_score": 0.4460407843297181}}
{"text": "\n\\chapter{Basic Types} \\label{chap:basics}\n\nSince C++ is a statically typed language \\cite{Stroustrup:cpp}, the basic mathematical building blocks such as constants or variables are represented as types.\nThe possiblity of manipulations at compiletime or runtime is accomplished by essentially\ntwo different implementations of these primitives.\nBasic types for runtime evaluations are discussed first, since their interface and handling is potentially more familiar to average C++ programmers.\nSec.~\\ref{sec:compiletime-types} then provides an overview of the basic types used for compiletime manipulations.\n\nThe main include file for {\\ViennaMath} is \\lstinline|viennamath/expression.hpp| and includes all the types discussed in the remainder of this chapter.\n\n\\TIP{Include \\lstinline|viennamath/expression.hpp| to make all {\\ViennaMath} types available.}\n\n\\TIP{Note that all types reside in namespace \\lstinline|viennamath|. The namespace is not written explicitly in the following, thus either \\lstinline|viennamath::| prefixes or certain \\lstinline|using| declarations need to be added by the user in order to make the code valid.}\n\n\n\\section{Types Evaluated at Runtime} \\label{sec:runtime-types}\nCommon to all types represented at runtime is that they inherit from the same abstract base class \nand can thus be accessed and manipulated using a pointer to that interface.\nThe interface is not fixed a-priori and can be adjusted via a template parameter, which is in the following called \\lstinline|InterfaceType|.\nLibrary users should use the expression wrapper objects discussed next, because it provides an automatic memory management and does not involve complicated pointer manipulation.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n \\subsection{Expression Wrapper \\lstinline|expr|}\nThe main expression wrapper type in {\\ViennaMath} is \\lstinline|rt_expr<InterfaceType>|.\nThe prefix \\lstinline|rt| refers to \\emph{runtime} and aids in distinguishing between types processed at runtime, and types processed at compiletime.\nIn most cases, the default parameter for the runtime interface \\lstinline|InterfaceType| is used, in which case users would have to write\n\\begin{lstlisting}\n rt_expr<> my_expression = /* any expression here */;\n\\end{lstlisting}\nfor instantiating an expression wrapper object \\lstinline|my_expression|.\nIn order to avoid users from having to write the \\lstinline|rt_| and the lower-than and greater-than signs,\nthere is a convenience shortcut \\lstinline|expr| provided. The previous code line thus becomes\n\\begin{lstlisting}\n expr my_expression = /* any expression here */;\n\\end{lstlisting}\nThe \\lstinline|expr|-type can be evaluated and manipulated using operator overloads.\nFor example, the addition of two expressions is accomplished by\n\\begin{lstlisting}\n expr ex1 = /* any expression here */;\n expr ex2 = /* any expression here */;\n expr result = ex1 + ex2;\n\\end{lstlisting}\nThe initalization of expression objects is accomplished by any of the fundamental types discussed in the next subsections.\nNote that objects of type \\lstinline|expr| are default-constructible, yet they can only be used after an expression has been assigned to them.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n \\subsection{Constant}\nConstants in C++ have their own types \\lstinline|double|, \\lstinline|long|, etc.\nThese types can be used with {\\ViennaMath} directly. \nIn order to also represent constants using a pointer to the runtime interface, a separate class \\lstinline|rt_constant<NumericT, InterfaceType>| is provided.\nThe template parameter \\lstinline|NumericT| denotes the underlying numerical type such as \\lstinline|double|, \\lstinline|long|, or high precision types.\nThere is again a convenience shortcut \\lstinline|constant| provided for the case of the commonly used \\lstinline|rt_constant<double>|, hence a user can write code such as\n\\begin{lstlisting}\n constant pi = 3.1415;\n constant pi_squared = pi * pi;\n\\end{lstlisting}\nAn exemplary use with the expression wrapper \\lstinline|expr| is\n\\begin{lstlisting}\n constant pi = 3.1415;\n expr pi_squared = pi * pi;\n expr result = pi + pi_squared;\n\\end{lstlisting}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n \\subsection{Variable}\nA mathematical variable in {\\ViennaMath} is modeled by \\lstinline|rt_variable<InterfaceType>|.\nand refers to the mapping\n\\begin{align*}\n \\left( x_0, x_1, \\ldots, x_{N-1}  \\right) \\mapsto x_j \\ ,\n\\end{align*}\nwhere the value of $j$ is provided to the constructor of the variable.\nBy default, the index $j=0$ is used. Any vector type offering access to its values using \\lstinline|operator[]| such as \\lstinline|std::vector<T>| can be used for an evaluation of the variable or a compounded expression.\n\nA simple example leading to the mapping $(x,y) \\mapsto x(y+\\pi)$ using the types introduced so far is as follows:\n\\begin{lstlisting}\n constant pi = 3.1415;\n variable x(0);\n variable y(1);\n expr f = x * (y + pi);\n\\end{lstlisting}\nAn evaluation of \\lstinline|f| at $(1,2)$ can be accomplished by using the functor interface provided by an overload of the parenthesis operator\nand the {\\ViennaMath} helper function \\lstinline|make_vector()|, which conveniently creates a suitable vector for evaluation.\n\\begin{lstlisting}\n std::cout << f( make_vector(1,2) ) << std::endl;  //prints 5.1415\n\\end{lstlisting}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n \\subsection{Unary Expression}\nMappings of the form $x \\mapsto \\sin(x)$ are modeled by the \\lstinline|rt_unary_expr<InterfaceType>| class.\nThus, they represent a unary function acting on a constant, a variable or an expression. An overview of the unary functions provided with {\\ViennaMath} is given in Tab.~\\ref{tab:unary-functions}.\n\n\\begin{table}\n\\centering\n\\begin{tabular}{|l|l||l|l|}\n\\hline\nName & {\\ViennaMath} Function   & Name & {\\ViennaMath} Function \\\\\n\\hline\nExponential   & \\lstinline|exp()| & Modulus & \\lstinline|fabs()| \\\\\nSine          & \\lstinline|sin()| & Square Root & \\lstinline|sqrt()| \\\\\nCosine        & \\lstinline|cos()| & Natural Logarithm & \\lstinline|log()| \\\\\nTangent       & \\lstinline|tan()| & Logarithm, Base 10 & \\lstinline|log10()| \\\\\n\\hline\n\\end{tabular}\n\\caption{Overview of unary functions defined in {\\ViennaMath}.\\label{tab:unary-functions}}\n\\end{table}\n\n\\TIP{Function names in Tab.~\\ref{tab:unary-functions} are intentionally chosen such that they coincide with the standard functions for floating point types.\nWhen calling these functions with floating point types, compilation might fail due to ambiguity. In such case the namespace should be specified explicitly.}\n\nTypically, unary expressions are not instantiated explicitly by the library user.\nInstead, they are generated implicitly by one of the unary functions and then assigned to an object of type \\lstinline|expr| as in the following example:\n\\begin{lstlisting}\n variable x;\n expr g = sin(2.0 * x);  // wraps a unary expression into 'g'\n\\end{lstlisting}\n\n \\subsection{Binary Expression}\nSimilar to unary expressions, binary expressions at runtime are mostly handled in the background only.\nThey are created whenever one of the operator overloads for addition, subtraction, multiplication, or division is triggered.\nIn particular, the argument \\lstinline|2.0 * x| to \\lstinline|sin()| in\n\\begin{lstlisting}\n expr g = sin(2.0 * x);\n\\end{lstlisting}\nis a binary expression. Binary expressions are central for compile time evaluations in Sec.~\\ref{sec:compiletime-types}.\n\n \\subsection{Expression Vector}\nFor the cases where a vector-valued expression is required, a user can either instantiate a vector of \\lstinline|expr|, which allows for storing multiple scalar-valued function only,\nor use the \\lstinline|rt_vector_expr<InterfaceType>| class provided by {\\ViennaMath}. A convenience shortcut \\lstinline|vector_expr| is provided.\nThe benefit of using the \\lstinline|vector_expr| class is that it provides the usual operator overloads directly:\n\\begin{lstlisting}\n variable x(0), y(1);\n vector_expr vec(3); vec[0] = x; vec[1] = y; vec[2] = x + y;\n vector_expr vec2 = x * vec + y * vec;\n\\end{lstlisting}\nThe dot-product of two vector-valued expressions is provided as well:\n\\begin{lstlisting}\n expr h = vec * vec2;\n\\end{lstlisting}\n\n\n\n\\section{Types Evaluated at Compiletime} \\label{sec:compiletime-types}\nThe runtime types discussed in the previous section enable a convenient handling of expressions.\nHowever, there are numerous runtime dispatches required when evaluating such runtime expressions, which are too costly in a high performance setting.\nThe compiletime types discussed in this section avoid any additional runtime dispatches and their use thus result in faster code in general.\nThis gain in performance comes at the price of a few additional restrictions:\nSince the expression is entirely encoded in the type, there is no equivalent to \\lstinline|expr| in order to assign an expression to a another object\\footnote{The new C++11 standard addresses this issue and provides the \\lstinline|auto| keyword for automatic type deduction. However, {\\ViennaMath} intentionally does not use any C++11 features yet.}.\nFurthermore, compilation times increase due to the additional work to be done for the compiler.\nExcessive use of compiletime evaluations and manipulations can even result in minutes to hours of compilation time, even though this is rarely encountered in practice.\nAnother complication stems from the fact that no floating point template arguments are allowed, thus reducing any compiletime calculations to integer calculations.\nFractional numbers can be emulated this way, but they cannot resolve all problems.\n\n \\subsection{Constant}\nSince no floating point type is allowed as template argument, only integer values \\lstinline|val| are represented by the class \\lstinline|ct_constant<val>|.\nOperators are overloaded in the same way as for the runtime evaluation types in Sec.~\\ref{sec:runtime-types}. One example of a compiletime calculation is given as follows:\n\\begin{lstlisting}\n ct_constant<2> c2;   //the constant '2'\n ct_constant<5> c5;   //the constant '5'\n std::cout << c2 + c5 << std::endl;  //prints '7' (computed at compiletime)\n\\end{lstlisting}\nNote that \\lstinline|ct_constant<>| can in principle also be mixed with ordinary constants such as\n\\begin{lstlisting}\n std::cout << 2 + c5 << std::endl;  //prints '7'\n\\end{lstlisting}\nHowever, depending on the optimization capabilities of the C++ compiler used, ordinary constants may or may not be used for compiletime computations, while the compiler is forced to do it in the introductory snippet.\n\n\\TIP{A general guideline is to use \\lstinline|ct_constant<val>| for encoding an integer \\lstinline|val| already known at compile time rather than writing the value explicitly in code. }\n\n \\subsection{Variable}\nA mathematical variable for compiletime manipulations is represented by \\lstinline|ct_variable<id>|, where \\lstinline|id| refers to the coordinate entry in the evaluation vector.\nThe meaning of \\lstinline|id| is identical to the constructor argument of a \\lstinline|variable| in the runtime case. \n\nOperators are again overloaded as usual. For example, consider\n\\begin{lstlisting}\n ct_variable<0> x;\n ct_variable<1> y;\n std::cout << x * y << std::endl;\n\\end{lstlisting}\n\n\n \\subsection{Unary Expression}\nThe unary functions in Tab.~\\ref{tab:unary-functions} can also be called with compiletime types.\nThe corresponding type for the compiletime representation is provided by \\lstinline|ct_unary_expr<E, OP>|, where \\lstinline|E| refers to the expression on which the unary function encoded by the tag \\lstinline|OP| acts.\nUnary operation tags start with \\lstinline|op_| and are defined in \\lstinline|viennamath/compiletime/unary_op_tags.hpp|. Their type name can be deduced from the function names in Tab.~\\ref{tab:unary-functions} by adding the prefix.\nNote that all unary functions are evaluated at runtime, because the underlying C-functions are called for evaluation. \nFor example, the type \\lstinline|T| of the compiletime unary expression\n\\begin{lstlisting}\n ct_variable<0> x;\n T t = sin(x);\n\\end{lstlisting}\nis \\lstinline|ct_unary_expr< ct_variable<0>, op_sin<NumericT> >|, where \\lstinline|NumericT| is the floating point type used for the evaluation at runtime (typically \\lstinline|double|).\n\n\n\n \\subsection{Binary Expression}\nThe binary expression \\lstinline|ct_binary_expr<L, OP, R>| with left hand side expression \\lstinline|L|, operation tag \\lstinline|OP| and right hand side expression \\lstinline|R| are the main types for building more complex expressions.\nCurrently, four binary operations are supported: addition (with tag \\lstinline|op_plus<NumericT>|), subtraction (\\lstinline|op_minus<NumericT>|), multiplication (\\lstinline|op_mult<NumericT>|), and division (\\lstinline|op_div<NumericT>|).\nSimilar to unary expressions, binary expressions are seldomly set up by hand.\nTwo examples of binary expressions are as follows:\n\\begin{lstlisting}\n ct_binary_expr< ct_variable<0>,    // x\n                 op_plus<double>,   // +\n                 ct_variable<1> >   // y  \n\n ct_binary_expr< ct_constant<1>,    // 1\n                 op_div<double>,    // /\n                 ct_variable<0> >   // x\n\\end{lstlisting}\n\nTypical uses of binary expressions are within the manipulation of compiletime expressions in metafunctions. As an example, outputting the first term of a polynomial is considered:\n\\begin{lstlisting}\n ct_variable<0> x;\n ct_variable<1> y;\n print_first( x*y + x*x*y - y*y );\n\\end{lstlisting}\nOnly two versions of the \\lstinline|print_first| function are required.\nThe first one recursively traverses the binary expression along the left hand side argument:\n\\begin{lstlisting}\n template <typename L, typename OP, typename R>\n print_first(ct_binary_expr<L, OP, R> const & b)\n { print_first(b.lhs()); } //recursion along left hand side\n\\end{lstlisting}\nThe recursion terminates with a general implementation for printing the left-most entry:\n\\begin{lstlisting}\n template <typename T>\n print_first(T const & t)\n { std::cout << t << std::endl; }\n\\end{lstlisting}\n\n\\NOTE{If a binary operation consists of one object for compiletime and one for runtime evaluation, the compiletime object is converted to a runtime object and then processed as usual in the runtime setting.}\n\n\n\n %\\subsection{Expression List}\n\n\n\n", "meta": {"hexsha": "66e97db0dfc4888378ef0c33a295fb78cfa5fb66", "size": 14255, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/manual/basic-types.tex", "max_stars_repo_name": "viennamath/viennamath-dev", "max_stars_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-09-13T03:51:48.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-20T10:35:43.000Z", "max_issues_repo_path": "doc/manual/basic-types.tex", "max_issues_repo_name": "viennamath/viennamath-dev", "max_issues_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/manual/basic-types.tex", "max_forks_repo_name": "viennamath/viennamath-dev", "max_forks_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.1836734694, "max_line_length": 350, "alphanum_fraction": 0.7642932304, "num_tokens": 3395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.44600228879370835}}
{"text": "\\documentclass{article}\n\n\\usepackage{fullpage}\n\\usepackage{textcomp}\n\\usepackage{amsmath}\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\renewcommand{\\headrulewidth}{0pt}\n\\cfoot{\\sc Page \\thepage\\ of \\pageref{end}}\n\n\\begin{document}\n\n{\\large \\noindent{}University of Toronto at Scarborough\\\\\n\\textbf{CSC A67/MAT A67 - Discrete Mathematics, Fall 2015}}\n\n\\section*{\\huge Exercise \\#8: Induction}\n\n{\\large Due: November 27, 2015 at 11:59 p.m.\\\\\nThis exercise is worth 3\\% of your final grade.}\\\\[1em]\n\\textbf{Warning:} Your electronic submission on MarkUs affirms that this exercise is your own work and no\none else's, and is in accordance with the University of Toronto Code of Behaviour on Academic Matters,\nthe Code of Student Conduct, and the guidelines for avoiding plagiarism in CSC A67/MAT A67.\\\\[1ex]\nThis exercise is due by 11:59 p.m. November 27. Late exercises will not be accepted.\\\\[1ex]\n\\renewcommand{\\labelenumi}{\\arabic{enumi}.}\n\\renewcommand{\\labelenumii}{(\\alph{enumii})}\n\\begin{enumerate}\n\\item \\begin{enumerate}\n\t\\item Prove\\marginpar{[6]}, without using induction, that $n(n+1)$ is an even number for every nonnegative integer $n$.\n\t\\item Prove, using induction, that $n(n+1)$ is an even number for every nonnegative integer $n$.\n\t\\end{enumerate}\n\\item Prove\\marginpar{[3]} the following identity:\n\\begin{equation*}\n1\\cdot 2+2\\cdot 3+3\\cdot 4+\\ldots+(n-1)\\cdot n=\\dfrac{(n-1)\\cdot n\\cdot(n+1)}{3}\n\\end{equation*}\n\\item Prove\\marginpar{[3]} that the sum of the first $n$ squares ($1+4+9+\\ldots+n^2$) is $\\tfrac{n(n+1)(2n+1)}{6}$.\n\\item Prove\\marginpar{[6]} by induction on $n$ that\n\t\\begin{enumerate}\n\t\\item $n^2-1$ is a multiple of 4 if $n$ is odd.\n\t\\item $n^3-n$ is a multiple of 6 for every $n$.\n\t\\end{enumerate}\n\\item Use\\marginpar{[3]} induction on $n$ to prove that the number of handshakes between $n$ people is $\\tfrac{n(n-1)}{2}$.\n\\item Read\\marginpar{[2]} the following induction proof carefully:\n\t\\begin{description}\n\t\\item[Assertion:] $n(n+1)$ is an odd number for every $n$.\n\t\\item[Proof:] Suppose that this is true for $n-1$. We have $n(n+1)=(n-1)n+2n$. Here $(n-1)n$ is odd by the induction hypothesis, and $2n$ is even. Hence $n(n+1)$ is the sum of an odd number and an even number, which is odd.\n\t\\end{description}\nThe assertion that we proved is obviously wrong for $n=10$, since $10\\cdot 11=110$ is even. Explain what is wrong with this proof.\n\\item Use\\marginpar{[3]} induction to prove that $n!>2^n$ if $n\\geq 4$.\n\\end{enumerate}\n\\hrulefill\\\\\n\\noindent[Total: 26 marks]\\label{end}\n\n\\end{document}", "meta": {"hexsha": "ef6a5d5d5a4601b5c80710200f1737ea8ca4f46d", "size": 2529, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "teaching/resources/Proof-by-Induction-Exercise.tex", "max_stars_repo_name": "ozhanghe/ozhanghe.github.io", "max_stars_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-23T17:23:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-23T17:23:00.000Z", "max_issues_repo_path": "teaching/resources/Proof-by-Induction-Exercise.tex", "max_issues_repo_name": "ozhanghe/ozhanghe.github.io", "max_issues_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-06-05T03:48:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-18T03:30:18.000Z", "max_forks_repo_path": "teaching/resources/Proof-by-Induction-Exercise.tex", "max_forks_repo_name": "ozhanghe/ozhanghe.github.io", "max_forks_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-11T13:35:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T05:34:01.000Z", "avg_line_length": 46.8333333333, "max_line_length": 224, "alphanum_fraction": 0.7176749703, "num_tokens": 847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7826624738835052, "lm_q1q2_score": 0.446002285904879}}
{"text": "\\chapter[Introduction to Gravitational waves]{An Introduction to Gravitational Waves, Search Methods and Parameter Estimation Techniques}\\label{ch:chap_1}\n\n\\hunter{Hey Chris. This chapter is ready for you to review again. I will \nnote that I did try to move the GW detection section to the beginning \nof the chapter, but I think there are just too many concepts in there \nthat need to be explained first for that to work, so I've left it at the \nend of the chapter.}\n\n\\section{General Relativity and Gravitational Waves}\n\nGravitational waves were predicted by Einstein in his theory of \\ac{GR}\nwell over 100 years ago \\cite{GR_Einstein_paper}. In his theory, Einstein \nshows that the more massive an object is, the more curvature in spacetime that object creates. This curvature then has an effect on the motion of objects which encounter it. This effect is summarized succinctly by John \nArchibald Wheeler where he states that ``Spacetime tells matter how to move; matter tells spacetime how to curve''. Curvature may be quantified by first defining a term known as the Riemann curvature \ntensor $R^{\\rho}_{\\sigma\\mu\\nu}$. The Riemann tensor describes the change \nexperienced by a vector which has been parallel transported over a curved \nmanifold\\cite{carroll_2019}. Einstein formalises the relationship between matter/energy and the curvature of space-time in his field equations as\n%\n\\begin{equation}\\label{eq:FieldEquations}\n    G_{\\mu \\nu} + \\Lambda g_{\\mu \\nu} = \\frac{8 \\pi G}{c^{4}} T_{\\mu \\nu},\n\\end{equation}{}\n%\nwhere $\\Lambda$ is the cosmological constant (scalar measurement describing the energy density of space), $g_{\\mu \\nu}$ is the metric which describes the geometric structure of space-time, $G$ is Newton's gravitational constant, $c$ is the speed of light, $T_{\\mu \\nu}$ is the stress energy tensor which describes the density, direction, and flow of energy in space-time. $G_{\\mu \\nu}$ is the Einstein tensor defined as\n%\n\\begin{equation}\n    G_{\\mu \\nu} = R_{\\mu \\nu} - \\frac{1}{2} R g_{\\mu \\nu}\n\\end{equation}\n%\nwhere $R_{\\mu \\nu}$ is the Ricci curvature tensor (a contraction of the Riemann \ncurvature tensor) and $R$ is the Ricci scalar defined as the trace \nof the Ricci curvature tensor. \n\n%\n% Transition towards discussing GWs as small purturbations on the flat spacetime metric\n%\nThe Einstein field equations described by Eq.~\\ref{eq:FieldEquations} can  unfortunately only be solved exactly analytically in a limited number of situations. Some solutions include the Schwarzschild solution for a non-spinning singularity (where a singularity is defined as a point in spacetime where \nthere is predicted to be infinite curvature~\\cite{carroll_2019}) and the Kerr solution for a spinning singularity. \n\nIn the regime of small perturbations \nto spacetime, considering we would like to explore the behavior of non-linear, time-dependent systems in terms of Einstein's field equations, \nwe need to put his equations into a more linear form. This can be done by describing the spacetime metric $g_{\\mu\\nu}$ in terms of an easily computable known solution in flat spacetime with the addition of some small perturbation,\n%\n% Introduce g_munu\n%\nwhere \\ac{GW}s may be defined as small perturbations over the curved background spacetime metric $g_{\\mu \\nu}$. In Euclidean space, the metric (which is what allows us to compute distances or dot products between two point mass objects), is generally described by the identity matrix in Cartesian coordinates. However, in \\ac{GR} we have to add the time dimension and in flat spacetime this can be described by the Minkowski metric tensor $\\bar{g}_{\\mu \\nu}$ (sometimes also denoted $\\eta_{\\mu \\nu}$) given by \n%\n\\begin{equation}\n  \\bar{g}_{\\mu \\nu} =   \\begin{pmatrix}\n-1 & 0 & 0 & 0\\\\\n0 & 1 & 0 & 0\\\\\n0 & 0 & 1 & 0\\\\\n0 & 0 & 0 & 1\n\\end{pmatrix},\n\\end{equation}\n%\nwhere each column and row represent a dimension of spacetime \n(from left to right and top to bottom: $ct,x,y,z$) where $t$ denotes time, $c$ is the speed of light, \nand $x,y,z$ denote the \n3 spacial dimensions. Time $t$ is negative because the speed \nof light $c$ must remain constant when changing between frames of \nreference \\cite{carroll_2019} \\hunter{Need Chris to check this}. \nAlthough the Minkowski metric can be written in non-diagonal \nforms depending on choice of coordinates, this diagonal form \nis chosen because it is computationally easy to invert \nand simple to compute the determinant of the matrix.\n\nSince a \\ac{GW} is a perturbation, we can write the metric tensor \nof a small perturbation in flat spacetime as \n%\n\\begin{equation}\n    g_{\\mu \\nu} = \\bar{g}_{\\mu \\nu} + h_{\\mu \\nu},\n\\end{equation}{}\n%\nwhere $h_{\\mu \\nu}(x)$ is the \\ac{GW} perturbation tensor ($|h_{\\mu \\nu}(x) \\ll 1|$). \n%Taking the derivative of the metric tensor we arrive at \n%the wave equations, \n%\n%\\begin{equation}\\label{eq:wave_eq}\n%    \\Box\\bar{h}_{\\mu\\nu} \\equiv \\Box\\bar{h}_{\\mu\\nu,\\alpha}^{\\alpha} = 0 \n%\\end{equation}\n%\n%where $\\Box$ is the  d'Alembertian operator and $\\bar{h}_{\\mu\\nu}$ is \n%a rescaling of the \\ac{GW} perturbation tensor in order \n%to simplify Eq.\\ref{eq:wave_eq} and may be defined as \n%\n%\\begin{equation}\n% \\bar{h}_{\\mu\\nu} = h_{\\mu\\nu} - \\frac{1}{2}\\eta_{\\mu\\nu}h   \n%\\end{equation}\n%\n%One of the well-known solutions to Eq. \\ref{eq:wave_eq} is  \n%given as \n%\n%\\begin{equation}\\label{eq:gw_plane_solution}\n%    h_{\\mu\\nu} = \\textrm{Re}[A_{\\mu\\nu} e^{ik_{\\alpha}x^{\\alpha}}],\n%\\end{equation}{}\n%\n%where $A_{\\mu\\nu}$ is the amplitude tensor, $k_{\\alpha}$ is the covariant %wavevector and $x^{\\alpha}$ is \n%position in spacetime.\n%This is also known as the plane wave solution. \n\\ac{GW} perturbations are themselves generated by \naccelerating masses which produce \nhigher order quadrupole (or multipole) moments~\\cite{Maggiore:2007ulw}.\n\nUsing $g_{\\mu\\nu}$, we find that one of the solutions to the linearised \nform of Einstein's field equations may be written as a plane-wave \nsolution given by\n%\n\\begin{equation}\\label{eq:gw_plane_solution}\n    h_{\\mu\\nu} = \\textrm{Re}[A_{\\mu\\nu} e^{ik_{\\alpha}x^{\\alpha}}],\n\\end{equation}{}\n%\nwhere $A_{\\mu\\nu}$ is a complicated amplitude tensor made up \nof multiple independent components and $h_{\\mu \\nu}$ is a sinusoidal \nwave traveling along the null wavevector $k$~\\cite{Maggiore:2007ulw}.\n\nExploiting guage freedoms~\\cite{carroll_2019}, we \ncan shift to the Transverse Traceless \ngauge (since this simplifies the plane-wave solution of Einstein's field \nequations to a simplified metric which is only made up of two \nunique components) \n%(since it is convenient to do \n%so given that the metric perturbation is perpendicular to the \n%wavevector in this guage~\\cite{Sathyaprakash2009}) \nand $h_{\\mu \\nu}$ can be rewritten as\n%\n\\begin{equation}\n  h_{\\mu \\nu} =   \\begin{pmatrix}\n0 & 0 & 0 & 0\\\\\n0 & h_{+} & h_{\\times} & 0\\\\\n0 & h_{\\times} & -h_{+} & 0\\\\\n0 & 0 & 0 & 0\n\\end{pmatrix}.\n\\end{equation}\n%\nwhere $h_{+}$ and $h_{\\times}$ are representative of the two \npolarization states of a \\ac{GW} which are orthogonal to \none-another~\\cite{carroll_2019,Anderson2011}.\n\n%\n% h+ and h_cross from a binary system.\n%\nAs derived in~\\cite{Capano2011SearchingFG}, assuming that the \nsource of the \\ac{GW} is emitted from \na binary astrophysical system with component masses $m_1,m_2$, \nthe plus and cross polarization states can \nbe expressed as being equivalent to\n%\n\\begin{align}\n    h_{+} &\\equiv \\frac{1}{d} (1 + \\mathrm{cos}^{2}\\iota) 2\\mu(M\\Omega^{2/3})\n    \\mathrm{cos}(2(\\Omega t - \\phi_0))\n    \\\\\n    h_{\\times} &\\equiv \\frac{1}{d} \\mathrm{cos}\\iota 2\\mu(M\\Omega^{2/3})\n    \\mathrm{sin}(2(\\Omega t - \\phi_0))\n\\end{align}\n%\nwhere $d$ is the distance to the source, $\\iota$ is the inclination \nangle of the binary with respect to an observer, $M$ is the total \nmass of the system, $\\phi_0$ is the initial phase of the system,  \n$t$ is time, $\\mu$ is the reduced mass given as $\\frac{m_1 m_2}{M}$\nand $\\Omega$ is Kepler's third law given by\n%\n\\begin{equation}\n    \\Omega = \\sqrt{\\frac{M}{a^3}}\n\\end{equation}\n%\nwhere $a$ is the seperation distance between the two component \nmasses of the system.\n\nThe effect that a passing \n\\ac{GW} waveform has on a set of freely floating test particles as \na function of the waveform's phase $\\phi$ for a given polarization state is \nillustrated in Fig. \\ref{fig:gw_plus_cross}. This effect on freely floating test masses is what is measured by \\ac{LVC} \\ac{GW} detectors in the \nform of strain $h$. As shown derived in~\\cite{Maggiore:2007ulw}, the \nstrain a \\ac{GW} induces \non only two free point masses can be expressed as \n%\n\\begin{equation}\n    h(t) = \\frac{2 \\Delta L}{L},\n\\end{equation}\n%\nwhere $h(t)$ is the strain amplitude of the \\ac{GW} \nas a function of time, $\\Delta L$ is \nthe absolute change in distance between two point masses induced by the \\ac{GW}  and $L$ is the distance between two point masses in the non-presence of a \n\\ac{GW}.\n\nFor a full derivation concerning the generation and propagation of \n\\ac{GW} signals, I refer \nthe interested reader to \\cite{Flanagan_2005}. Now that we have defined \nhow \\ac{GW}s propogate and induce strin on freely floating test masses, we \nwill introduce in the following section first attempts to detect \n\\ac{GW}s, the first indirect observational evidence for \\ac{GW}s and \nhow the current generation of \\ac{GW} detectors function and measure \n\\ac{GW} strain $h(t)$.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/GW_polarizations_thesis_figure.png}\n    \\caption[$h_+$ and $h_\\times$ polarization illustration]{An illustration of the $h_+$ and $h_\\times$ polarizations of a \\ac{GW} signal impinging on a set of freely floating test masses as a function of the phase of the \\ac{GW} $\\phi$ from $0$ to $3\\pi / 2$.}\n    \\label{fig:gw_plus_cross}\n\\end{figure}\n\n\\section{The Weber Bar Detector and the Hulse-Taylor Pulsar}\n\nBy the early 1950s technology had progressed enough such that serious \nattempts at experimentally verifying the existence of \\ac{GW}s by Einstein were possible. \nOne of the earliest and most well-known attempts at doing so was by \nJoseph Weber at the University of Maryland where he used an instrument \nknown as a resonant-mass detector (Weber Bar Detector) \\cite{PhysRevLett.18.498}\n. The Weber Bar \noperates on the principle that when a \\ac{GW} impinges on the bar (usually \nmade of some type of metal alloy, in this case high Q aluminium~\\footnote{Q refers to how underdamped an oscillator is.}) at a \nspecific frequency, since the bar is a harmonic oscillator which is driven by the Riemann curvature tensor, it will cause the bar to resonate. If the \nfrequency of the \\ac{GW} is equivalent \nto the natural resonant frequency of the bar, a \\ac{GW} would theoretically be detectable~\\cite{PhysRevLett.20.1307}. Weber made the claim in 1968 \nthat there was \n``good evidence'' for several detections made by his \nexperiment~\\cite{PhysRevLett.20.1307}, but unfortunately \nno others were able to reproduce his results. Although follow-up results from \nother independent studies were disappointing, \nWeber's work encouraged many others to build their own improved experiments with\nbreakthrough technological developments at the time and \nkick-started the subsequent field of \\ac{GW} detection \\cite{1009.1138}. \nFortunately, in the subsquent years after Weber's \nfirst published results, there \nwould come the first indirect observational evidence for the existence \nof \\ac{GW}s.\n\n%\n% First indirect observational evidence for GWs\n%\nIn 1975, Russell Hulse and Joseph Taylor made the first direct observation  of a binary pulsar, which subsequently won them the 1993 Nobel Prize in Physics~\\cite{1975ApJ...195L..51H}. Booth Hulse and Taylor observed that \nthe period of the binary pulsar \nappeared to experience orbital decay as a function of time. The orbital \ndecay was thought to likely be attributed to a loss of energy in the \nsystem due to \\ac{GW} radiation predicted by \\ac{GR}. The observed period \ndecay as a function of time (in years) is represented\nin Fig. \\ref{fig:hulse_taylor_decay}. As can be seen in the figure, \nthere is a striking level of agreement \nbetween the theoretical decay curve predicted by Einstein's \\ac{GR} and \nthe observations made by Hulse and Taylor. Importantly, this work was also \none of the first pieces of indirect observational evidence for the existence of \\ac{GW}s. \n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/Hulse_taylor_pulsar.png}\n    \\caption[Hulse-Taylor binary pulsar decay.]{This figure shows Hulse \n    and Taylor's observations of binary pulsar \\texttt{PSR B1913+16} \n    orbital decay as a function of time in years. The orbital decay is quantified by the total cumulative amount the binary system has been offset from it's first observation in 1975 with respect to the binary's perihelion point (black dots). The solid black curve is representative of the theoretical decay curve predicted by \\ac{GR}. This figure was produced by the authors of~\\cite{1975ApJ...195L..51H}. }\n    \\label{fig:hulse_taylor_decay}\n\\end{figure}\n\nPioneering work by both Hulse-Taylor and Weber, spurred the development \nof advanced \\ac{GW} detectors aimed at directly observing \n\\ac{GW} events. In the following section we will discuss how the current \ngeneration of \\ac{GW} detectors works and detects \\ac{GW}s.\n\n\\section{LIGO-Virgo Detectors}\n\nThe current generation of \\ac{GW} ground-based detectors in \nthe \\ac{LVC} are composed of \nthree observatories, two in North America \n(Hanford, Washington State and Livingston, Louisiana)~\\cite{2015} and \none in Pisa, Italy (Virgo)~\\cite{Acernese_2014}. \nThere are also other ground-based detectors \nin Hannover, Germany (GEO)~\\cite{Affeldt_2014} and Kamioka, Japan \n(KAGRA)~\\cite{Akutsu2019}. \nIn addition to ground-based detectors there are eventual plans \nto build a space-based observatory called the \\ac{LISA}~\\cite{1201.3621} which \nwill search for super massive \\ac{BBH}s (among other \nsources). A \nsimplified schematic of the \\ac{LVC} detectors is shown in Fig. \\ref{fig:detector_schematic}. Each detector (with \\ac{LISA} being the \nexception) can be thought \nof as a large-scale Michelson-Morley Interferometer~\\cite{Michelson333} \ncomposed of two arms orthogonal to each other. Each arm of \nthe \\ac{LIGO} detectors is 4km in length, with the Virgo arms being \nslightly shorter in length at 3km in length.\n\nThe detectors operate by first emitting photons from an laser initial \nlaser port. \nPhotons emitted from the laser pass through a beam \nsplitter and down two orthogonal arms of the detectors in \nthe form of vacuum sealed beam tubes guided by mirror optics. The photons \nthen hit test mass mirrors at both ends\nand are caught in what is known as a Fabry-Perot signal recylcing \ncavity~\\cite{1899ApJ.....9...87P}. A Fabry-Perot cavity acts to effectively increase the sensitivity of the arms by positively modulating the \namount of time spent by the light in the arm along, which consequently \nalso increases the laser power in the arm~\\cite{PhysRevD.75.102002}. After reflecting back and forth in the \nFabry-Perot cavities, photons are released \nfrom the Fabry-Perot cavities and return to the beam splitter, subsequently \nrecombining and are recorded on a set of photodiodes which measure \nthe phase difference between photons from both \narms. The phase difference information is \nencoded in the interference pattern on \nthe readout of the the detector photodiodes, which is the final output of the detectors.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/Interferometer_sketch_figure.png}\n    \\caption[Illustration of the \\ac{LIGO} detectors.]{An illustration of the \\ac{LIGO} detectors. A 1064nm laser beam is emitted from a laser on the left-hand side, it then passes through a phase modulator (PMOD) and enters the power recycling cavity (PRM), this effectively boosts the power of the signal. The laser then passes through a beam splitter (BS), which splits the laser beam path into two seperate parts. Each part travels through an input test mass and hits end test masses at the end of both interferometer arms. The beams are then caught in a Fabry-Perot cavity which acts to extend the distance traveled of the beams, as well as the power. In other words, the cavity ``stores'' the photons for a long period ($\\sim1$ ms) which allows a potential \\ac{GW} signal more time to interact with the photons, thus increasing the sensitivity of the interferometer at low frequencies. Some laser light escapes back down both arms and recombines at the BS where the recombined beam passes through a signal recycling mirror (SRM). Finally, the beam hits a set of photodiodes (PD) which produce the interferometer readout which we use to determine whether or not a \\ac{GW} signal is present.}\n    \\label{fig:detector_schematic}\n\\end{figure}\n\nStarting from the well-known postulate from relativity that the distance between\ntwo points in spacetime along the path of a light ray traveling \nthe $x$ direction may be expressed as\n\\begin{equation}\n    ds^2 = 0 = g_{\\mu\\nu}dx^{\\mu}dx^{\\nu}.\n\\end{equation}\nIt can be shown through some algebraic manipulation \n(explained in~\\cite{SAULSON2013288})\nthat we can quantify the light travel time difference of photons \noriginating from the initial laser port traveling up and down \nthe two interferometer arms as \n%\n\\begin{equation}\n    \\Delta \\tau(t) = h(t) \\frac{2L}{c} = h(t) \\tau_{rt0}.\n\\end{equation}\n%\nwhere $\\tau_{rt0}$ is the return trip time down \none arm and the phase difference being \n%\n\\begin{equation}\n    \\Delta \\phi(t) = h(t) \\tau_{rt0} \\frac{2\\pi c}{\\lambda}.\n\\end{equation}\n%\nHere we can clearly see that the phase difference \nbetween the two light signals is scaled by the \nlength of the interferometer arms $L$. The \ndetectors are tuned through control systems such that the photons arriving \nback at the final readout port of the detector act to destructively \ninterfere with each other (i.e. create an interference pattern on a dark fringe), where power fluctuations encoded through this interference pattern are recorded on photodiodes. Assuming that a \\ac{GW} \nimpinges on the detector orthogonal to the plane of the detector and also \ndepending on the polarisation state of the wave, \nit will compress one arm \nwhile stretching the other arm. There will then be a \ndetectable difference in phase between the light traveling \ndown both arms. Due to this phase difference, the \nlight recombining at the beam splitter will no longer \ndestructively interfere and a detectable signal will appear \non the photodetectors in the form of a detectable interference \npattern~\\cite{PhysRevD.95.062003}. In the next section, we will \ndiscuss how the sensitivity of the detectors may be influenced \nby the orientation of the detectors with respect \nto the \\ac{GW} source.\n\n\\subsection{Detector Response}\n\n% LIGO antenna patterns\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/peanut.png}\n    \\caption[Illustration of the \\ac{LVC} detector antenna patterns for both the $h_\\times$ and $h_+$ \\ac{GW} polarizations]{An illustration of the \\ac{LVC} detector antenna patterns for both the $h_\\times$ and $h_+$ \\ac{GW} polarizations. The detector itself would lie in the x-y plane with one arm along the x-axis and the other along the y-axis.}\n    \\label{fig:gw_plus_cross}\n\\end{figure}\n\nThe \\ac{LVC} detectors are not equally sensitive to all parts of \nthe sky. Mathematically, the sky dependent sensitivity of the detectors \nmay be expressed through their antenna patterns. \nThe antenna pattern of a detector is dependent upon the location and \nwave polarisation \nof the \\ac{GW} source with respect to the detector (with the assumption that the detector is located at the center of a celestial sphere). Changes in the \nantenna pattern have a direct impact on the \namount of strain measured by the \\ac{LVC} detectors. \n\nAs shown in~\\cite{PhysRevD.63.042003} and given by \nthe derivation shown in~\\cite{Capano2011SearchingFG}, the antenna \npattern may be expressed as\n%\n\\begin{equation}\n    \\mathrm{F}_{+}^{'} = -\\frac{1}{2}(1+\\mathrm{cos}^2 \\theta) \\mathrm{cos}2\\varphi \\mathrm{cos}2\\psi - \\mathrm{cos}\\theta\\mathrm{sin}2\\varphi\\mathrm{sin}\\psi\n\\end{equation}\n%\n\\begin{equation}\n    \\mathrm{F}_{\\times}^{'} = +\\frac{1}{2}(1+\\mathrm{cos}^2 \\theta) \\mathrm{cos}2\\varphi \\mathrm{sin}2\\psi - \\mathrm{cos}\\theta\\mathrm{sin}2\\varphi\\mathrm{cos}\\psi\n\\end{equation}\n%\nwhere $\\theta$ is the azimuthal angle, $\\varphi$ is the polar angle and $\\psi$ \nis the polarisation angle. In other words, $\\theta$, $\\varphi$ and $\\psi$ are all Euler angles which describe the frame of the binary system with \nrespect to the detector. The shape of the antenna response is illustrated pictorially in Fig.~\\ref{fig:gw_plus_cross} in a Cartesian coordinate system, \nwhere we can imagine the detector lying along the $x$-$y$ plane. Areas \nwhere the detector is least sensitive to \\ac{GW}s are given by \nthe null areas of Fig.~\\ref{fig:gw_plus_cross}. \n\nIt is also shown in~\\cite{Capano2011SearchingFG} that the \n\\ac{GW} strain of both the ``plus'' and ``cross'' polarized portions \nmay be generalised for a given polarization angle with respect to the \ndirection of \\ac{GW} propagation as \n%\n\\begin{align}\n    h_{+}^{'} &= h_{+}\\mathrm{cos}2\\psi - h_{\\times} \\mathrm{sin}2\\psi \\\\\n    h_{\\times}^{'} &= h_{+}\\mathrm{sin}2\\psi + h_{\\times}\\mathrm{cos}2\\psi\n\\end{align}\n%\nMeasured \\ac{GW} strain is then shown to be expressed as a summation of $h_{\\times}^{'}$ \nand $h_{+}^{'}$ attenuated by antenna patterns $\\mathrm{F}_{\\times}^{'}$ and $\\mathrm{F}_{+}^{'}$ given by\n%\n\\begin{equation}\n    h(t) = \\mathrm{F}_{\\times}^{'}(\\theta,\\psi,\\phi)h_{\\times}^{'} + \\mathrm{F}_{+}^{'}(\\theta,\\psi,\\phi)^{'}h_{+}, \\label{eq:measured_strain}\n\\end{equation}\n%\nSince the antenna patterns are sky dependent, they are therefore also time dependent. They are time dependent because different detectors will apply different patterns to the same signal, thus altering the received amplitude and phase of the signal. \nFor example, very long signals (e.g., \\ac{CW} signals) experience time varying antenna responses as the Earth rotates and search methods \nare designed to take this into account~\\cite{1712.05897}. In the next \nsection, we will discuss how the detectors are also influenced \nby non-astrophysical sources of strain.\n\n\\subsection{Detector Noise}\\label{sec:detector_noise}\n\nThe \\ac{LVC} detectors, in addition to being incredibly sensitive to \nstrain from \\ac{GW} signals, are also sensitive to an abundant number of \nnon-astrophysical noise sources. These noise sources can produce \nperiods of excess power in measured detector data which may limit \nthe sensitivity of the detectors. Some common noise sources include \ngravity-gradient noise, seismic \nnoise, thermal noise and quantum shot noise.\n\n%\n% Mention PSD \n%\nIn practice, the performance of the detector may largely be \ncharacterized by a quantity known as the \\ac{PSD}. Assuming the non-presence of \na \\ac{GW} signal, the output of the detector may be assumed to be equivalent to the detector  \nnoise as a function of time $n(t)$. We define the auto-correlation \nfunction as \n%\n\\begin{equation}\n    K \\equiv E[n(t_1)n^{*}(t_2)],\n\\end{equation}\n%\nwhere $E$ is the expectation value over an ensemble of realisations of \nthe noise and $*$ is the complex conjugate. \nAssuming stationary noise, we can write $K$ as being merely dependent \non $\\tau \\equiv |t_1 - t_2|$. As shown in ~\\cite{Sathyaprakash2009}, \nthe \\ac{PSD} \nof the detector may thus be written as the fourier transform of the \nauto-correlation function $K(\\tau)$ \n%\n\\begin{equation}\\label{eq:PSD}\n    S_n(f) \\equiv \\frac{1}{2} \\int_{-\\infty}^{\\infty} \n    K(\\tau) e^{2\\pi i f \\tau} d\\tau, \\ f\\geq0,\n\\end{equation}\n%\nwhere frequencies are given as being greater than zero. We will now describe \nin detail the types of noise sources which may affect the performance of \nthe detector \\ac{PSD}.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/aLIGO_noise_budget.pdf}\n    \\caption[Theoretical design sensitivity noise budget curves for Advanced \\ac{LIGO}.]{The theoretical design sensitivity noise budget curves for Advanced \\ac{LIGO}. As can be seen in the illustration, lower frequencies are largely dominated by seismic motion, mid-range frequencies are \n    dominated by thermal coating Brownian motion on the mirrors as well as quantum vacuum noise between 10 and 100 Hz and higher frequencies are \n    dominated by quantum vacuum shot noise. The plot was generated using the \\texttt{pygwinc} computing package \\cite{pygwinc}.}\n    \\label{fig:aligo_noise_budget}\n\\end{figure}\n\n\\subsubsection{Seismic Noise}\n%\nSeismic noise largely affects the sensitivity of the detectors in the \nlow frequency regime ($\\sim 10^{-2} -\n10^2$Hz~\\cite{2012CQGra..29e5006M}) due to a variety of sources \nincluding: earthquakes, anthropogenic motion and wind. Earthquakes produce \nsets of \nwaves (p,s,r-waves) which travel both through the Earth's core/mantel and \nalso along the surface of the earth~\\cite{Pavlis2003}. \nWhen one of these seismic waves\nhits the detectors they can induce horizontal ground motion on the \noptical components of the detector. In order to isolate the detector \noptics from horizontal ground motion($\\sim 0.03 - 0.1$Hz), \noptics are suspended on \nmulti-layered seismic isolation stacks~\\cite{Matichard_2015}.  \nBetween $\\sim 1 - 3$Hz anthropogenic noise can cause short duration noise \ntransients in the detector output. Sources of anthropogenic noise may \nresult from individuals walking around in the \\ac{LVC} control rooms \nor large trucks passing on a nearby highway~\\cite{abbott2016characterization}. \nWind greater than $10 - 20$Mph can also adversely \ninfluence the detector sensitvity \nat frequencies of $0.15 - 15$Hz~\\cite{Effler_2015}.\n\n%\n% Not sure if this is right. \n%\n\\subsubsection{Thermal Noise}\nThermal noise may be classified into two distinct types: suspension \nand Brownian coating thermal noise and primarily limits detector \nsensitivity in the frequency \nband of $10 - 500$Hz. Suspension noise results \nfrom thermal motion in the suspension fibers which can induce motion \ninto the detector mirrors~\\cite{Yamamoto_2002}. \nBrownian coating noise results from \nthermal fluctuations in detector mirror coatings~\\cite{Crooks_2006}. \nBoth of these sources may be quantified through the application \nof the fluctuation-dissipation theorem as shown in~\\cite{Yamamoto_2002}. \nMaterials for \nthe mirror coatings are chosen such that they have minimal light \nabsorption at the wavelength of the laser~\\cite{PhysRevD.81.122001}. \nPossible mitigation strategies for reducing thermal noise \nalso involve careful choice of coating thickness, as well as the \nuse of Cryogenic systems for cooling the suspensions/optics of \nthe detector~\\cite{2012CQGra..29l4007S}.\n\n\\subsubsection{Quantum Noise Sources}\n%\n% Intro and quantum shot noise\n%\nThere are two sources of quantum noise in the detectors: \nquantum shot noise and quantum thermal radiation pressure \nnoise. Both are produced by internal measurement/readout processes.\nQuantum shot noise is related to \nfrom the wave packet-like\nbehavior of light as it travels through a medium. Since\nthe distribution of photons arriving within \na time interval is governed by Poisson statistics,  \nwe know that the uncertainty on the \nnumber of photons arriving at the detector \nphotodiodes after is proportional to the \nsquare root of the expected number of photons \narriving within that same time interval (optical power). \nWe can express mathematically the amount of strain induced by shot noise on \nthe detectors $h_{\\mathrm{S}}$, where subscript $s$ stands for shot noise. \ngiven by \n%\n\\begin{equation}\n    h_{\\mathrm{S}} = \\frac{1}{L} \\sqrt{\\frac{\\hslash c \\lambda}{2\\pi P}},\n\\end{equation}\n%\nwhere $L$ is the arm length of the interferometer, $\\hslash$ is \nPlanck's constant, $\\lambda$ is the laser light wavelength, \n$P$ is the power of the laser and $c$ is the speed of\nlight~\\cite{Hild2014}.\n\n%\n% Quantum radiation pressure noise\n%\nThe second type of noise source is quantum radiation pressure noise. Radiation pressure noise arises from the effect of photon momentum transfer onto the test mass mirrors of the detector. When a photon from the detector laser hits a mirror, it transfers some momentum to that mirror. Since all photons do not hit the mirror at the exact same time, there is some variability of pressure exerted on the mirror as a function of time. This moves the mirror in a \nvariable manner which leads to a change in the detector arms length and \nthus the noise on the output. This can be mathematically expressed as \nthe amount of strain induced on the detector due to radiation pressure \nnoise $h_{\\mathrm{R}}$ by \n%\n\\begin{equation}\n    h_{\\mathrm{R}} = \\frac{1}{Lmf^2}  \\sqrt{\\frac{\\hslash P}{2\\pi^3 c\\lambda}},\n\\end{equation}\n%\nwhere $m$ is the mass of the mirror, $R$ stands for radiation pressure and $f$ is the frequency measured in the \\ac{GW} detector~\\cite{Hild2014}. \n\n%\n% Possible mitigation strategies\n%\nShot noise may be partially mitigated \nthrough increasing the circulating light power of the laser, since it is \nknown that sensitivity of the detector to \\ac{GW}s is proportional to the \nlaser power, whereas shot noise is proportional to the square root of the \noptical power~\\cite{Abadie2011}. Unfortunately, as \nthe optical power of the laser is \nincreased, so to does thermal radiation pressure noise, which sets \nan effective upper limit on optical laser power in the \ndetector. Radiation pressure noise can be reduced by either increasing \nthe mass of the mirrors $m$, or the length of the detectors $L$, though \nit should be noted that any increase in either of these values comes \nwith added technological and sheer monetary cost constraints.\nFor a more detailed description of shot noise, see \\cite{Hild2014}.\n\n\\subsubsection{Gravity-Gradient Noise}\n\nGravity-gradient noise (or Newtonian noise) is \nnoise which results from small stochastic \nperturbations to the gravitational field background in and around \nthe \\ac{LVC} detector test masses. Some sources of gravity gradient noise \ninclude: seismic noise and atmospheric fluctuations \n(specifically, changes in air pressure which \ncarry with it changes in air density)\n\\cite{PhysRevD.58.122002}. Gravity-gradient noise decreases steeply with \nincreasing frequency and is a primary limiting factor in detector \nsensitivity below frequencies of $1$Hz~\\cite{Sathyaprakash2009}.\n\n%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%% \n%%%%%%%%%%%%%%% \n\\section{Astrophysical Sources and Search Methods}\\label{sec:sources_methods}\n\nThere are a variety of sources which produce \n\\ac{GW} signals. Most are not large enough to be seen by the \n\\ac{LVC} detectors, but some astrophysical sources \nare indeed sufficiently strong enough \nto be detected. Such detectable signals may be categorized into 4 \ndistinct types including: \\ac{CBC}, burst,\ncontinuous and \nstochastic \\ac{GW}s. In this \nsection I will explain in detail the unique characteristics which \ndescribe each of these signal types. I will also \ndescribe several methods used by the \n\\ac{LVC} to search for signals from \\ac{CBC}, \\ac{GW}, burst and \nstochastic \\ac{GW}s.\n\n\\subsection{Compact Binary Coalescencs}\\label{sec:CBC_source}\n\n\\ac{CBC} signals arise from the collision of massive \n( of order $\\sim M_{\\odot}$) compact \nbinary objects (such as \\ac{BH}s and \\ac{NS}s) moving at high relativistic speeds. \\ac{NS}s may be defined as being \nthe leftover cores of dead stars which have \nexploded in a supernovae and then collapsed down into an object roughly \nthe mass of our sun and with a radius of a few \nkm. \\ac{CBC} systems can \ninclude \\ac{BBH}s, \\ac{NSBH} pairs, \\ac{BNS}s and super massive \\ac{BH} encounter events.\nA \\ac{CBC} signal waveform is made up of three components: the inspiral, merger \nand ringdown phase and can be approximated using a combination \nof post-Newtonian theory~\\cite{PhysRevD.84.049901,PhysRevD.80.084043,Blanchet2014,PhysRevD.93.084054},\nthe effective-one-body formalism~\\cite{PhysRevD.59.084006}, and numerical\nrelativity simulations~\\cite{PhysRevLett.95.121101}.\n\n%\n% How each signal type is parameterized\n%\n\\ac{BBH} signals are parameterised by 15 different parameters (discounting \neccentricity). Two of these  \nparameters describe the two component masses of \neach compact object in the binary system ($m_1$,$m_2$) and are sometimes \ncommonly combined in an expression known as the chirp mass given by \n%\n\\begin{equation}\n    M_c = \\frac{(m_1 m_2)^{3/5}}{(m_1 + m_2)^{1/5}}.\n\\end{equation} \n%\nOther parameters include: the time at which the binary coalesced, luminosity distance, phase of the waveform at coalescence, sky \nlocation (right ascension, declination), \ninclination angle, polarization angle, spin magnitudes, tilt angles, \nazimuthal angle and azimuthal position. \\ac{BNS} and \\ac{NSBH} \nevents are also parameterized by the \nsame \\ac{BBH} parameters mentioned above, but their waveform is \nadditionally impacted by the internal structure of the \\ac{NS}. The \naffect the \\ac{NS} internal structure has on the \\ac{GW} waveform \nmay be parameterized in the form of \nadditional tidal parameters given in ~\\cite{PhysRevD.81.123016}. \n\nAs the two objects rotate about each other, energy is radiated away in the form of \\ac{GW}s primarily due to the mass quadrupole moment of the binary system\n~\\cite{Maggiore:2007ulw}. \nOver the course of millions or even billions of years, the two objects will inspiral in towards each other~\\cite{10.3389/fspas.2020.00038}. As the orbital separation decreases, the objects will move faster and increasingly\nradiate away more and more energy in the form \\ac{GW}s. This is known \nas the inspiral phase where the frequency of the \\ac{GW} waveform \nincreases as a ``chirp-like'' signal. Prior to merging, the objects release a tremendous amount of energy, producing \npeak luminosities equivalent to $\\mathcal{O}(1 \\times 10^{56}\\mathrm{erg \\ s^{-1}})$\n, making \\ac{CBC} signals some of the most luminous events in \nthe universe~\\cite{1811.12907,2010.14527}. \nIf the objects are \\ac{BBH}s, they \nwill merge and coalesce into a single perturbed \\ac{BH} which emits \\ac{GW}s at \na set of frequencies which is parameterised by the remnant single black \nhole total mass and spin angular momentum~\\cite{Hawking1972,PhysRev.164.1776,\nPhysRevLett.26.331}(also known as the \n``ringdown'' phase of the \\ac{GW} signal). If the objects are \\ac{BNS}s \nthey will typically collide and are thought to generate short \\ac{GRB}s followed by a kilonovae~\\cite{2017arXiv171005834L}. Importantly, both the short \n\\ac{GRB} and kilonovae components may be measured by other \\ac{EM} telescopes across the spectrum. Theoretically, \\ac{NSBH} events should also be able\nto produce \\ac{EM} radiation, but this is \nlargely dependent on several factors including the mass ratio of the \nbinary system, \\ac{BH} spin and \\ac{NS} radius~\\cite{doi:10.1146/annurev-nucl-102115-044819}.\n\n% f_ISCO explanation\nThe frequency near which the two objects will merge (and the point \nat which the frequency of the \\ac{GW} waveform stops increasing) is \nlargely a function of a quantity known as the  \ninnermost stable circular orbit $R_{\\mathrm{ISCO}}$. This radius is the distance between two compact objects in orbit at which their motion becomes unstable and the two objects rapidly decrease their radial distance between each other. The radius at which this occurs is defined as \n%\n\\begin{equation}\n    R_{\\mathrm{ISCO}} = \\frac{6GM}{c^2},\n\\end{equation}\n%\nwhere $G$ is the gravitational constant, $M$ is the total mass of \nthe system, and $c$ is the speed of light. The corresponding frequency at which the orbit becomes unstable may be estimated using Kepler's third law and can be expressed as \n%\n\\begin{equation}\n    f_{\\mathrm{ISCO}} = \\frac{1}{T} \\lesssim \n    \\sqrt{\\frac{GM}{4\\pi^2R^3_{\\mathrm{ISCO}}}} \\simeq 2.2 \\mathrm{kHz}\\frac{M_\\odot}{M} ,\n\\end{equation}\n%\nwhere $T$ is the period of the orbit and $M$ is the total mass of the system~\\cite{Maggiore:2007ulw}. Now that we've characterised \\ac{CBC} \nsignals, we will describe data analysis methods used for detecting \n\\ac{CBC} signals.\n\n\n\\subsection{Compact Binary Coalescence Search Method}\n\nThe measured strain (output) of the \\ac{LVC} \\ac{GW} detector is given as a \ntime series $s(t)$ produced by the resulting phase shift of the detector laser beam. Due to the fact that\nthe detector is not perfectly isolated from all non-astrophysical sources, the output of the detector when a \\ac{GW} is present will be a combination of \nboth the astrophysical strain directly  \nfrom the \\ac{GW} $h(t)$ as a function of time, as well as the noise $n(t)$ \nwhich is a combination of all other forms of non-astrophysical strain in the \ndetector also as a function of time\n%\n\\begin{equation}\\label{eq:alternate_hypo}\n    s(t) = h(t) + n(t).\n\\end{equation}{}\n%\nIf no signal is present, the measured strain of the detector \nis simply equivalent to the noise $s(t) = n(t)$. This is generally known \nas the null hypothesis $H_0$. We define Eq.~\\ref{eq:alternate_hypo} as the alternative hypothesis $H_1$. We assume that the noise is governed by \na stochastic process and the joint-probability \ndistribution $p(n)$. The noise is also assumed to be both stationary and \nGaussian, where stationarity is defined as the noise  \nhaving constant statistical properties as a function of time \nand Gaussianity dictates that noise \nsamples are distributed such that their joint-probability distribution \nhas mean of 0 and a standard deviation of 1. In the frequency domain, \nstationarity is defined as noise being uncorrelated across frequency bins and \nGaussianity as each noise frequency bin following a Gaussian \ndistribution~\\cite{Abbott_2020}. \nIn reality this is a poor approximation of the detector noise, where the noise\nis \nmore likely to be non-Gaussian and non-stationary. For those cases where there \nis non-Gaussianity various glitch identification tools and techniques are \nused to identify periods of excess noise in the detector data\noutput $s(t)$~\\cite{Abbott_2020,2021CQGra..38m5014D,0264-9381-34-6-064003,\n2018RSPTA.37670286N,abbott2016characterization}.\n\nGiven Gaussian noise, our problem then becomes, how does one distinguish noise from actual \\ac{GW} signal? Fortunately, the problem of extracting low \\ac{SNR} signals from the background is not uncommon in physics and the field of statistics and may be accomplished through a technique known as matched \nfiltering.\n\n\\subsubsection{Matched Filtering}\\label{sec:matched_filtering}\n\nThe primary method for detecting \\ac{CBC} signals is through \nmatched filtering~\\cite{PhysRevD.60.022002}. \nMatched filtering has been applied in a variety of contexts outside of \\ac{GW} \nastronomy including: radar/sonar~\\cite{WOODWARD1953100} and digital \ncommunications~\\cite{doi:10.1080/00207217408900375}. In this subsection, \nI will describe how matched filtering is used within the context of \n\\ac{GW} detection of \\ac{CBC} signals including deriving the \noptimal matched filter, explanation of additional statistical \ntests such as the $\\chi^2$ statistic, as well as\na discussion on template bank generation and coincidence testing.\n\n%\n% Brief aside on waveform modeling\n%\nTo start, we can take advantage of the fact that we generally have a good understanding of the form of $h(t)$ through a combination of analytic and numerical waveform modeling. \n% PN stuff\nAt large distances between the two compact \nobjects of the binary system and velocities which are smaller \nthan the speed of light $v \\ll c$ (slow motion, weak-field), \na \\ac{PN} approximation may be used to model the \\ac{GW} \nwaveform, as outlined in~\\cite{Will5938,Blanchet2014}. \n% Numerical solutions\nHowever, at smaller separation distances, \nthis approximation is not valid and computationally expensive \nnumerical solutions to Einstein's field equations are \nthen required through \\ac{NR}~\\cite{Cardoso2015}. Modeling \nthe entire waveform requires stitching together both \\ac{PN} \nand \\ac{NR} estimates in a semi-analytic \napproximate of the entire waveform. \nThe two main approaches currently used to model the \n\\ac{IMR} phases of the whole signal use either the \n\\ac{EOB} formalism~\\cite{PhysRevD.89.061502} (SEOBNR waveform family) or the \n\\ac{Phenom} framework~\\cite{PhysRevD.93.044006,PhysRevD.93.044007} \n(IMRPhenom waveform family). For further \ndetails and an overview of \\ac{GW} waveform modeling \nsee ~\\cite{10.3389/fspas.2020.00028}.\n\n%\n% New and improved matched filtering derivation \n%\nGiven that we have an accurate understanding \nof \\ac{GW} waveforms through \nwaveform approximation techniques, we will derive an algorithm \nfor testing the alternative hypothesis $H_1$ of whether or not a signal is \npresent in the detector noise. We will be following the derivation \nfound in ~\\cite{Anderson2011}. In order to do this we must \nfirst define the likelihood ratio given by \n%\n% Odds ratio\n\\begin{equation}\\label{eq:likelihood_ratio}\n    \\Lambda(B|A) \\coloneqq \\frac{P(A|B)}{P(A|\\neg B)},\n\\end{equation}\n%\nwhere $\\Lambda(B|A)$ is the likelihood of $B$ given $A$, \n$P(A|B)$ is the conditional probability of $A$ given $B$ \nand $P(A|\\neg B)$ is the conditional probability of $A$ \ngiven $B$ is not true where $P(\\neg B) = 1 - P(B)$.\nIf we want to find the likelihood of the alternative \nhypothesis $H_1$, given the measured strain output of the \ndetector $s$, we can substitute this into Eq.~\\ref{eq:likelihood_ratio} \nand rewrite as\n%\n\\begin{equation}\\label{eq:altern_likelihood}\n \\Lambda(H_1|s) = \\frac{p(s|H_1)}{p(s|H_0)}    \n\\end{equation}\n%\nwhere $p$ is representative of a probability density. We also define  \nthe probability density of a Gaussian $p_G(s)$ as a function \nof time series $x$ as \n%\n\\begin{equation}\\label{eq:Gaussian_tseries_dist}\n    p_{G}(x) = \\frac{1}{\\sigma\\sqrt{2\\pi}} \n    e^{-\\frac{1}{2} \\left(\\frac{(x-\\mu)}{\\sigma}\\right)^2}\n    \\ \\propto \\ e^{-\\frac{1}{2}\\langle x,x \\rangle},\n\\end{equation}\n%\nwhere $\\mu$ is the mean of the time series distribution, $\\sigma$ is \nthe standard deviation of the time series distribution and $\\langle x,x\\rangle$ is \nthe inner product of the time series $x$. Given \nEq.~\\ref{eq:Gaussian_tseries_dist} and acknowledging \nthat Eq.~\\ref{eq:alternate_hypo} may be rewritten as \n$n(t) = s(t) - h(t)$ under $H_1$ and as $n(t) = s(t)$ under \nthe null hypothesis $H_0$, we can substitute Eq.~\\ref{eq:Gaussian_tseries_dist} \ninto Eq.~\\ref{eq:altern_likelihood} under the two different hypotheses \n$H_0,H_1$ and write as \n%\n\\begin{equation}\n    \\Lambda(H_1|s) = \\frac{e^{-\\frac{1}{2}\\langle s-h,s-h \\rangle}}\n    {e^{-\\frac{1}{2}\\langle s,s\\rangle}}.\n\\end{equation}\n%\nexpanding we arrive at \n \\begin{align}\n    \\Lambda(H_1|s) &= \\frac{e^{-\\frac{1}{2}\\left(\\langle s,s\\rangle -2\\langle s,h\\rangle +\\langle h,h\\rangle \\right)}}\n    {e^{-\\frac{1}{2}\\langle s,s\\rangle }} \\\\\n    \\\\\n    &= \\frac{\\frac{e^{\\langle s,h\\rangle }}\n    {e^{\\frac{\\langle s,s\\rangle }{2}}e^{\\frac{\\langle h,h\\rangle }{2}}}} \n    {\\frac{1}{e^{\\frac{\\langle s,s\\rangle }{2}}}} \n    = \\frac{e^{\\langle s,h\\rangle } e^{\\langle s,s\\rangle /2}}\n    {e^{\\langle s,s\\rangle /2}e^{\\langle h,h\\rangle /2}} \\\\\n    \\\\\n    &= \\frac{e^{\\langle s,h\\rangle }}{e^{\\langle h,h\\rangle /2}}\\label{eq:final_mf_like} \n    = e^{\\langle s,h\\rangle } e^{-\\frac{\\langle h,h\\rangle}{2}},\n \\end{align}\n%\nwhere in Eq.~\\ref{eq:final_mf_like} we see that observed \ndata in the detector $s$ influences the likelihood strictly  \nthrough the inner product $\\langle s,h\\rangle$. Given the relation\n%\n\\begin{equation}\n    \\langle a,b\\rangle \\equiv 2 \\int_{0}^{\\infty} \\frac{df}{S_n(f)} \n    \\left( \\tilde{a}(f)\\tilde{b}^{*}(f) + \n    \\tilde{a}^{*}(f)\\tilde{b}(f)\\right)\n\\end{equation}\n%\nstated in ~\\cite{Sathyaprakash2009}, where $\\tilde{a}$ \nrepresents the Fourier transform of $a$,\nwe can say that the the most optimal expression for determining \nwhether $H_1$ is true may be expressed through the inner product \n$\\langle s,h\\rangle$ as\n%\n\\begin{align}\n    \\langle s,h\\rangle &= 2 \\int_{0}^{\\infty} \\frac{df}{S_n(f)} \\left(\n    \\tilde{s}(f)\\tilde{h}^{*}(f) + \n    \\tilde{s}^{*}(f)\\tilde{h}(f)\\right). \\\\\n    &= 4 \\int_{0}^{\\infty} \\frac{\\tilde{s}(f) \\tilde{h}^{*}(f)}\n    {S_{n}(f)} df,\\label{eq:opt_mf} \n\\end{align}\n%\nwhere $\\tilde{s}(f)$ is the fourier transform of the detector output and  \n$\\tilde{h}(f)$ is the fourier transform of the \\ac{GW} strain. Dividing \nEq.~\\ref{eq:opt_mf} by the magnitude of the waveform $\\sqrt{\\langle h,h\\rangle }$ \ngives the \\ac{SNR} $\\rho$~\\cite{PhysRevD.85.122006}, where the greater the \nvalue of $\\rho$, the more likely a given \\ac{GW} \nwaveform $h(t)$ is in the detector output $s(t)$.\n\nWe also maximise over the phase of the template \nwaveform, whereby each template waveform has \northogonal phase components $h_{\\mathrm{sin}}$ \nand $h_{\\mathrm{cos}}$. As shown in~\\cite{PhysRevD.85.122006}, after maximising over \nphase we arrive at \n\\begin{equation}\n    \\rho^2 = \n    \\frac{\\langle s,h_{\\mathrm{sin}}\\rangle ^2}{\\langle h_{\\mathrm{sin}},h_{\\mathrm{sin}}\\rangle } + \n    \\frac{\\langle s,h_{\\mathrm{cos}}\\rangle ^2}{\\langle h_{\\mathrm{cos}},h_{\\mathrm{cos}}\\rangle } = \n    \\frac{\\langle s,h_{\\mathrm{sin}}\\rangle ^2 + \\langle s,h_{\\mathrm{cos}}\\rangle ^2}{\\langle h_{\\mathrm{sin}},h_{\\mathrm{sin}}\\rangle }\n\\end{equation}\nwhere $\\rho^2$ is known as the matched filter \\ac{SNR}. The matched filter \n\\ac{SNR} is the primary statistic used to determine if a template is a good \nmatch for a given detector output $s(t)$. If $\\rho^2$ is above a \npre-determined threshold using a given template waveform $h(t)$, at a \nspecific time $t$, we \nsay that this period in the observed data is a \\textit{trigger}. There are also \nadditional statistical tests performed, such as the the $\\chi^2$ test, \nwhich will be discussed later. \n%\n% Discuss templates and template bank placement\n%\n%Since there are a range of parameters which may describe \n%$h(t)$, we are now left with the decision on how to \n%sample from this parameter space. \n%As shown in ~\\cite{PhysRevD.71.062001}, $h$ may \n%be parameterised by  \n%\n%\\begin{equation}\n% h(t) = \\frac{D}{d} \\left(\\mathrm{cos}\\phi h_{\\mathrm{cos}}(t-t_0)\n% +\\mathrm{sin}\\phi h_{\\mathrm{sin}}(t-t_0)\\right),\n%\\end{equation}\n%\n%the effective distance of the source,   \n%$h_{\\mathrm{sin}}$ and $h_{\\mathrm{cos}}$ are the two orthogonal \n%phases of $h(t)$~\\cite{FindChirp}, $d$ is the \n%effective distance from the source, $t_0$ is the time of coalescence \n%of the binary at merger and $\\phi$ is the phase. Parameters $d,t_0,\\phi$ (henceforth collectively denoted as \n%$\\gamma$) are unknown in practice. The effective distance from the source \n%$d$ is unimportant with regards to matched filtering since it simply sets \n%a scale for the matched filter output. We can determine the best \n%matching phase $\\phi$ for given template waveform $h(t)$ by maximising \n%over the phase $\\phi$. After maximising over phase, we arrive at the \n%matched filter \n%we \n%typically marginalize out these \\textit{nuisance} parameters by first  \n%defining the likelihood ratio\n%\n%\\begin{equation}\\label{eq:mf_unknown_par_like}\n%    \\Lambda(H_{\\gamma}|s) = \\frac{p(s|H_\\gamma)}{p(s|H_0)},\n%\\end{equation}\n%\n%where by using the marginalized likelihood it is shown \n%in ~\\cite{Anderson2011} that \n%\n%\\begin{equation}\\label{eq:max_like_mf}\n%    \\left <s - h(\\gamma), \\frac{\\partial}{\\partial\\gamma_i} h(\\gamma)\\right> \n%    \\bigg\\rvert_{\\gamma=\\gamma_{\\mathrm{max}}} = 0. \n%\\end{equation}\n%\n%\\hunter{I think this is an inner product, but not sure.}By solving %Eq.~\\ref{eq:max_like_mf} for many \\ac{GW} templates $i$ \n%with parameters $\\gamma$ for $\\gamma_{\\mathrm{max}}$, one can find \n%a set of templates which maximizes the likelihood of Eq.~\\ref{eq:mf_unknown_par_like}. \n\n%\n% Template bank placement\n%\nChoosing how to sample \\ac{GW} templates from the vast \nparameter space which best match $h(t)$ can be \nchallenging. This is typically done by first constructing \nwhat is known as a \\textit{template bank} (a bank of \\ac{GW} \ntemplate waveforms). We can quantify the coverage \nof the template bank through an expression known as the \\textit{minimal match} \n$MM$ given in Eq. 3.12 of~\\cite{0264-9381-23-18-002}. A high minimal \nmatch percentage value (where maximum coverage would be $100\\%$) \nfor a given template bank essentially means \nfor any given \\ac{GW}, the distance of that \\ac{GW} waveform from \nany existing template in the template bank should be no more \nthan a pre-determined distance away. This distance is quantified by \ndetermining the amount of optimal \\ac{SNR} loss if that \n\\ac{GW} waveform were to lie exactly in between its nearest \ntemplates~\\cite{PhysRevD.53.6749}.\nThe spacing \nbetween discrete templates in the template bank is \nparameterised by the square of the proper \ndistance between intrinsic template waveform parameters given \nby Eq.~2.14 of~\\cite{PhysRevD.53.6749}. \n\nIn practice, the template bank is constructed \nsuch that at least one template in the bank has a \nminimum match greater than or equal to $\\sim 97\\%$ for any \n\\ac{GW}. Deciding on an $MM$ value can be tricky,  \nif one chooses an $MM$ value which is too low, \nthen template bank will be coarse and \\ac{GW} signals \nmay be missed. On the flip side, if we generate a bank \nof templates which is too finely spaced, then we run the risk of \nhaving a higher false alarm rate (where a high false alarm \nrate means a higher probability of falsely identifying \nperiods of excess noise as \\ac{GW} signal). There is also \nthe added trade-off of larger template banks being \nexceedingly computationally expensive to compute. There are\na multitude of techniques used to generate template banks  \ngiven in ~\\cite{PhysRevD.49.1707,PhysRevD.53.6749,PhysRevD.60.022002,\n2006CQGra..23.5477B,PhysRevD.80.104014,PhysRevD.86.084017,PhysRevD.89.084041,\nPhysRevD.89.024003,2016arXiv160203509C,PhysRevD.89.024010} and \nwe refer the reader to those manuscripts for a more detailed discussion on \ntemplate bank placement. Following template bank generation, \nwe compute the matched filter \\ac{SNR} of templates in the \ntemplate bank with observed pieces of data $s(t)$, in order to \ndetermine the best matching template waveform for $h(t)$.\n\n%\n% chi squared test\n%\nUp to now, we have assumed only Gaussian noise, but unfortunately the \n\\ac{LVC} detectors are also often permeated by  \nnon-Gaussian noise artefacts. These ``glitches'', or noise \ntransients, can mimic high \n\\ac{SNR} events. High \\ac{SNR} glitch events typically contain lots of power \nacross a broad frequency band, where distinguishing factors which \nseparate glitches from \\ac{GW} events include: glitches only appearing \nin one detector at a time rather than coincidentally across multiple \ndetectors, as well as signal morphology in time, \nfrequency or the \ntime-frequency plane. To take this into account, an additional test \nfor quantifying the likelihood \nof a candidate event \noriginating from a real \\ac{GW} signal is used known as \nthe $\\chi^{2}$ test. The test operates under the principle \nthat the time-frequency distribution of the power of the \nobserved data $s(t)$ should be consistent with \nthe expected power in the matched template waveform $h(t)$, as explained in greater detail here~\\cite{PhysRevD.71.062001,0264-9381-33-21-215004}.\n\n%\n% Brief description of chi squared test\n%\nGiven a trigger with a corresponding best \nmatching template waveform, the $\\chi^2$ test is constructed by first dividing \nup the best matching template waveform into \n$p$ frequency bins, whereby each bin \nis defined such that they contribute an equal amount of power \nto the total matched filter \\ac{SNR}. Next, a matched filter \\ac{SNR},\n$\\rho_i$, is then computed for given observed data $s$ and template $h$ \nsummed over all $p$ frequency bins. The resulting \nstatistic may be described by \n%\n\\begin{equation} \\label{eq:gw_chisquared}\n    \\chi^2 = p \\sum_{i=1}^p \\left[  \\left( \\frac{\\rho_{\\mathrm{cos}}^2 }{p} - \\rho_{\\mathrm{cos}, i}^2 \\right)^2 \n    + \\left( \\frac{\\rho_{\\mathrm{sin}}^2 }{p} - \\rho_{\\mathrm{sin}, i}^2 \\right)^2 \\right],\n\\end{equation}\n%\nwhere $\\rho_{\\mathrm{sin}}$ and $\\rho_{\\mathrm{cos}}$ are the \n\\ac{SNR} values of orthogonal templates $h_{\\mathrm{sin}},h_{\\mathrm{cos}}$. Large values of \n$\\chi^2$ indicate a greater likelihood \nof a trigger resulting from a noise transient and as such are typically \ndownweighted if their reduced chi-squared value ($\\chi^{2}_r = \\chi^2/2p - 2$) \nis greater than $1$ in the form of a re-weighted \\ac{SNR} $\\hat{\\rho}$ \ngiven as \n%\n\\begin{equation}\n    \\hat{\\rho} = \\frac{\\rho}{\\lbrack\\frac{1+(\\chi_{r}^2)^3}{2}\\rbrack^{(1/6)}}.\n\\end{equation}\n%\nIf after \\ac{SNR} re-weighting the match filter \\ac{SNR} lies below a user predefined \nvalue, the candidate trigger is discarded and not considered for further \nanalyses~\\cite{0264-9381-33-21-215004}. The final detection statistic is \nthe quadrature sum of the chi-squared weighted matched filter \\ac{SNR} across \nall detectors where the event was seen.\n\n%\n% Coincidence testing\n%\nIt is also important to ensure that triggers which we observe in \none detector are generally consistent with what we would expect to find in other active \\ac{GW} detectors around the globe. If a trigger has been identified in one detector, it must also be coincident in time with other triggers in other active detectors. Coincidence is defined as triggers from multiple detectors being within the expected maximum window of time it would require for the \\ac{GW} to travel from one detector to another (roughly equivalent to the speed of light). Travel time varies depending on sky location of the event (with added noise due to measurement uncertainty), where at a maximum it is expected that it should take a \\ac{GW} to travel from one detector to another in $\\sim 10$ms~\\cite{0264-9381-33-21-215004}. In \norder to account for added noise from measurement uncertainty, the maximum allowed \\ac{GW} travel time between detectors is usually expanded \nto $\\sim 15$ms~\\cite{0264-9381-33-21-215004}, also known as the coincidence window. Triggers which are within the coincidence window \nare then ranked by the expression \n\\begin{equation}\n    \\hat{\\rho_c} = \\sqrt{\\hat{\\rho_1}^2 + \\hat{\\rho_2}^2},\n\\end{equation}\nwhere $\\hat{\\rho_1}$ and $\\hat{\\rho_2}$ are the re-weighted \\ac{SNR}s of \nthe coincident triggers in each detector~\\cite{0264-9381-33-21-215004} and \n$\\hat{\\rho_c}$ is our final detection statistic for a coincident event. \n\n%\n% Time slides\n% \nNow that we have a detection statistic in the form of $\\hat{\\rho_c}$, \nwe need a method for determining the statistical significance of this statistic.\nThis can be done by first determining the \\ac{FAR}, where a false alarm \nis defined as how often the search would identify a non-astrophysical \nnoise event with a re-weighted \\ac{SNR} as high (or higher) than a \ngiven candidate \\ac{GW} event's \nre-weighted \\ac{SNR}. An accurate \\ac{FAR} requires that we have \nan accurate estimate on the statistical properties of the background \nnoise distribution. In order to get an accurate \napproximate of the noise background of \nthe \\ac{LVC} detectors, we perform an exercise known as \ntime slides~\\cite{0264-9381-33-21-215004,2016arXiv160100130C}. Time \nslides involve artificially randomly shifting the time stamps of triggers from one detector by an offset which is greater than the coincidence window \n($\\sim 15$ms). \nWe then compute $\\hat{\\rho_c}$ for all coincident triggers (above a \npre-determined low \\ac{SNR} threshold) between the time slide triggers and those from other detectors which are within the coincidence window. These post time \nslide coincident triggers are unlikely to contain real \\ac{GW} events \nand are thus considered to be a representative \napproximation of the total number of noise background events. The \n\\ac{FAR} may thus be calculated as \n%\n\\begin{equation}\n    \\mathrm{FAR} = \\frac{N_\\mathrm{b}}{T_{\\mathrm{b}}}, \n\\end{equation}\n%\nwhere $N_\\mathrm{b}$ are the total number of noise background events and\n$T_{\\mathrm{b}}$ is the total duration of the background event data. \n\nGiven $\\hat{\\rho_c}$ for these noise background coincident events, we can \nadditionally calculate the \\ac{FAP} of a particular event resulting from \nnon-astrophysical noise by comparing $\\hat{\\rho_c}$ from \nbackground events, to $\\hat{\\rho_c}$ from the foreground \n(candidate \\ac{GW} trigger) events. The \\ac{FAP} can be \nexpressed in the form \n%\n\\begin{equation}\n    \\mathrm{FAP} = 1 - e^{-N_{\\mathrm{b}}(T_0 / T_{\\mathrm{b}})},\n\\end{equation}\n%\nwhere $T_0$ is the search period~\\hunter{Not super sure \nhow T0 is defined in reality}.\nFor more details on determining \\ac{GW} candidate trigger significance, see \n~\\cite{0264-9381-33-21-215004,2016arXiv160100130C}. We will now \nmove on to discuss another source \\ac{GW} radiation, \\ac{CW}s.\n\n%\n% whitening aside\n%\nWe also mention briefly here that \\ac{LVC} timeseries \ndata can have information content which is broadband. Oftentimes, \nlow frequency content in a given timeseries can contain so much \npower that it effectively ``drowns out'' the high frequency \nportion of the signal. One method for dealing with this issue is using a \ntechnique known as whitening. In whitening, we normalise the content \nin a given timeseries, such that the power is equal across all frequency bins \nin the signal. Whitening is usually applied prior to performing any \nkind of signal analysis, such as matched filtering, and only requires \nassuming a \\ac{PSD} and knowledge of the sampling frequency of the \ntimeseries. For a timeseries, $s$, this whitening procedure is given by the \nfollowing mathematical expression as \n%\n\\begin{equation}\n    s_{\\mathrm{w}} = \\mathcal{F}^{-1}\\left(\\mathcal{F}(s) \\sqrt{\\frac{2}{S_n \n    f_{\\mathrm{s}}}}\\right), \n\\end{equation}\n%\nwhere $\\mathcal{F}$ and $\\mathcal{F}^{-1}$ are the \n\\ac{FFT}~\\cite{Cooley1965AnAF} and \ninverse \\ac{FFT} respectively, $f_s$ is the sampling frequency \nof the timeseries, $S_n$ is the \\ac{PSD} and $s_{\\mathrm{w}}$ is the \nwhitened timeseries. \n\\hunter{Chris should check this whitening definition.}\n\n\\subsection{Continuous Waves}\\label{sec:CW_source}\n\n\\ac{CW} signals are canonically associated with spinning non-axisymmetric\n\\ac{NS}s. Other more exotic sources can result from boson clouds, which \nmay produce \\ac{CW} \\ac{GW} signals through boson annihilation or level \ntransition around fast-spinning \\ac{BH}s~\\cite{1712.05897}. \\ac{GW} \n\\ac{CW} signals from \\ac{NS}s are produced through the mechanism of \nmass quadrupole \nradiation. Radiation is most commonly emitted through \ncracking and cooling of the \\ac{NS} crust, internal non-axisymmetric magnetic \nfield flows, and mountains of mass accrued on the surface from a larger companion star~\\cite{1712.05897}. \\ac{CW} signals are incredibly long in \nduration and will span (or even outlast) an entire observing run. \nA \\ac{CW} waveform is fairly simple in shape (resembling that \nof a standard sinusoid) and \nthe period to complete one full spin revolution can be on the order \nof $\\sim 10^{-3}s$ up to $\\sim 10s$~\\cite{Manchester_2005}. The frequency \nof \\ac{CW} signals on short time scales is relatively constant, \nhowever on longer time scales the frequency will shift due to a  \nloss in angular momentum resulting from \\ac{GW} radiation and the \nshifting position of the \\ac{LVC} detectors with respect \nto the source due to Earth's rotation and orbit around the Sun ~\\cite{Sathyaprakash2009}.\nSeveral searches have also been carried \nout by the \\ac{LVC} over the past several years for \\ac{CW} signals \nand while upper bounds have been placed on the intrinsic \\ac{CW} \n\\ac{GW} strain, \\ac{NS} elipticity and other \\ac{CW} parameters, \nthere have yet to be any direct \ndetections~\\cite{PhysRevD.103.064017,1707.02669}. We will now focus \nour attention on methods for detecting \\ac{CW} signals.\n\n\\subsection{Continuous Wave Search Methods}\n\nThere are estimated to be roughly $\\sim 10^{8} - 10^{9}$ \\ac{NS}s in our own Milky Way Galaxy~\\cite{2007coaw.book.....C}, of which only $\\sim 2500$ have already \nbeen observed by the \\ac{EM} community~\\cite{1712.05897,2005AJ....129.1993M}. \nMany of these \\ac{NS}s may emit detecable \\ac{GW}s in the form of \n\\ac{CW}s.\nMethods for detecting \\ac{CW}s from \\ac{NS}s may be classified into 3 types: \ntargeted, directed and all-sky. We will now briefly summarise each of \nthese approaches. \n\n\\subsubsection{Targeted Search}\nOne method for detecting \n\\ac{CW} signals is to go after these already known $2500$ neutron \nstars and perform targeted searches. It should be noted here \nthat \\ac{GW} searches are only performed on millisecond pulsars, of which \nthere are $O(100)$s~\\cite{1712.05897}. This is because the vast \nrange of \\ac{NS}s in our own galaxy would emit below \n(in frequency) the \\ac{LVC} sensitivity band~\\cite{2020ApJ...902L..21A}.\nThe GW strain given by a non-axisymmetric spinning \n\\ac{NS} is typically defined by \n%\n\\begin{equation}\n    h_{0} = \\frac{16\\pi^2G}{c^4} \\frac{I f^2}{d} \\epsilon,\n\\end{equation}\n%\nwhere $I$ is the moment of inertia with respect to the rotation axis \nof the \\ac{NS}, $f$ is the \\ac{GW} frequency (\nequivalent to twice the spin frequency for quadrupolar emission, \n$\\approx 4/3$ of the spin frequency for r-mode emission, and has a \ncomponent equal to the spin frequency if it is wobbling (precessing)) \nand $\\epsilon$ is the elipticity \ndefined as $\\frac{I_1 - I_2}{I}$ where $I_1$ and $I_2$ are the moments \nof intertia of the star with respect to the principal axis orthogonal to the \nrotation axis~\\cite{1998PhRvD..58f3001J}. In a targeted search, observations \nfrom \\ac{EM} observers, which provide estimates on the sky position, \nfrequency, spin, are used as input to \\ac{CW} \\ac{GW} searches in order to \nsearch for unknown parameters ($h_0,\\phi_0,\\psi,\\mathrm{cos} \\ \\iota$).\nWhere $\\mathrm{cos} \\ \\iota$ is the cosine of the angle between the \\ac{NS} \nsource's rotation axis and the line-of-sight of the detector to the \nsource, $\\phi_0$ is the signal phase offset and $\\psi$ is the polarization \nangle.  There are many methods for performing a \ntargeted search, such as the use of data reduction techniques \n(time-domain heterodyne) in combination with Bayesian inference to \nproduce posteriors on unknown parameters \n($h_0,\\phi_0,\\psi,\\mathrm{cos} \\ \\iota$)~\\cite{PhysRevD.72.102002}. There \nis also \nmatched filtering, specifically the $F$ statistic, which analytically \nmaximises the likelihood ratio of a signal+noise model over a \ngiven noise model.~\\cite{PhysRevD.58.063001}. Then finally \nthere is Fourier domain \nanalysis using the ``5-vector'' method, as outlined in \ndetail here~\\cite{Astone_2010}. For further discussions \non each technique listed above, I refer the reader to those\nmanuscripts~\\cite{PhysRevD.72.102002,PhysRevD.58.063001,Astone_2010}.\n\n\\subsubsection{All-Sky and Directed Searches}\n\nIn contrast to both a targeted and a directed search, all-sky searches\nimpose the least amount of constraints on the observable \nparameter space. Specifically, \nit's a search for a well modelled signal with unknown frequency, \nfrequency derivative(s), unknown sky location and potentially \nunknown orbital parameters~\\footnote{ \nif in a binary system}. Generally speaking, an all-sky search is performed by first breaking up observational time series data into many smaller \ntime segments. These time segments are then analysed coherently, \nafter which the results for each time segment may be recombined in an incoherent manner. This is otherwise known as a semi-coherent search.\n\nIn order to combine results from coherent segments incoherently, there\nare many methods which have been developed \nover the past several years. Such methods include: \ntime-domain $F$-statistic, frequency-Hough, Viterbi, Powerflux \nand cross-corr. For a \nfull description of these and other methods for combining coherent \nsegments, I refer the \nreader to~\\cite{PhysRevD.94.124010}. \n\nWe also briefly \nmention a second method, a directed search, where it is only assumed that \nthe sky location is well known and that the rotational frequency and \nother parameters are not known. Examples of such \nsearches include: \\ac{GW} searches in the core of our own  galaxy~\\cite{2013PhRvD..88j2002A} and Scorpius \nX-1~\\cite{2021ApJ...906L..14Z}. Although not too dissimilar from an \nall-sky search, directed searches are useful when we have a \nparticular source in mind and would like to tune our search to \nthat source~\\cite{2016CQGra..33j5017M}. It should also be noted that directed searches, while able to search using a large number of templates at low \ncost, are less sensitive than targeted searches due to their limited \nassumptions on the search parameter space~\\cite{2019PhRvD..99l2002A}. \nWe will now discuss another \\ac{GW} source type, burst signals.\n\n\\subsection{Burst Signals}\\label{subsec:burst_sig}\n\nA burst \\ac{GW} signal is produced by sources which are either \nunknown/unmodeled or known, but difficult to model due to \ncomplicated physics and are typically short in duration (less \nthan a second).  \nDifficult to model burst signals can result from core-collapse supernovae \nwhich may emit \\ac{GW}s via an accelerated mass-energy quadrupole \nmoment at possible frequencies of $\\sim 200 - 1000$Hz~\\cite{Ott_2009}. \nOther potential known sources include pulsar ``glitches'' \nfrom a \\ac{NS} rapidly increasing and then exponentially decreasing \nits spin due to surface mountain \ndistortions~\\cite{2020MNRAS.498.3138Y} and soft \ngamma-ray flares \nfrom brief ($\\sim 0.1$s) bursts of soft gamma rays with possible \nsources such as: Magnetars~\\cite{1992ApJ...392L...9D} or \nquake stars~\\cite{Xu_2003}. \nDue to the fact that \\ac{GW}s are likely emitted from deep \ninside the core of a star going supernovae and are not heavily influenced by \nextraneous material between the source and the detector, there is the \npotential for much insight to be gained on the physics which govern \nthe dynamics inside collapse such as the equation of state of \nhot nuclear matter inside the star~\\cite{Sathyaprakash2009}. In the \nnext subsection we \nwill discuss methods used to detect both known and unknown burst signals.\n\n\\subsection{Burst Search Method}\n\nAs mentioned previously in subsection.~\\ref{subsec:burst_sig}, \nburst-like signals are typically not modeled due to the complicated \nnature of the event and the possibility of detecting as yet unknown signals.\nSince the search is unmodeled we don't necessarily employ  \ntemplate waveforms which are exactly described by a deep knowledge of \nnumerical relativity, post-Newtonian dynamics or \\ac{GR}. As such, \nburst searches use methods which can detect a wide \nrange of possible waveform types and may be classified into \ntwo distinct categories: coincident and coherent searches. Coincident searches \nidentify clusters of times of excess power (represented through \nwavelet transformations) in individual detectors. After times \nof excess power have been individually identified in each detector, \ncoincidence between \ntimes across multiple detectors is checked~\\cite{2004CQGra..21S1685K}. \nCoherent searches such as \n\\cite{2015CQGra..32m5012C,2008CQGra..25k4029K}, are fundamentally \ndifferent from coincident searches in that detector responses \nare first summed together into a single combined piece of data. Burst \nevents are then identified in the combined data through a coherent \nstatistic derived from the likelihood ratio functional \nshown in~\\cite{PhysRevD.72.122002}. \nCoherent methods have the added advantage of not being limited by the \nleast sensitive detector in the analysis, the generation of other \nuseful coherent \nstatistics as a byproduct of the analysis and the ability to \nconstruct the source coordinates of \nthe \\ac{GW} waveforms~\\cite{2008CQGra..25k4029K}. We end this \nsection by explaining another source of \\ac{GW}s, stochastic \n\\ac{GW}s.\n\n\\subsection{Stochastic Gravitational Waves}\\label{sec:stochastic_source}\n\nThere exists a background noise of random (stochastic) \\ac{GW}\nevents which \nis detectable and may be classified into two categories (cosmological and \nastrophysical) which are broadly \ndefined by their different amplitudes and spectral properties. \nThe cosmological stochastic \n\\ac{GW} background is produced by a number of mechanisms \nincluding: density perturbations resulting from the \namplification of vacuum fluctuations during the inflationary period, and \ncosmic strings resulting from phase transitions in the \nearly universe~\\cite{2019RPPh...82a6903C,Kandhasamy:2013hba}. \nIf detected, \\ac{GW}s from the cosmological \nstochastic background could provide key insights into \nfundamental physical mechanisms and processes \nof the early universe~\\cite{Caprini_2015}. \nThe astrophysical stochastic \\ac{GW} background \nmay be described as the random \nsupposition of many \\ac{GW}s from a wide range of \nsignals (core-collapse supernovae, \ncompact binary inspirals, isolated neutron stars) which are weak in \n\\ac{SNR}, \nindependent and unresolvable~\\cite{Romano2017}. \nIf detected, the astrophysical \\ac{GW} \nbackground would provide us with a further understanding on early astrophysical \nsource population properties, as well as surce population formation \nmechanisms~\\cite{Romano2017}. \nIn subsection.~\\ref{subsec:stochastic_search}, we move on to briefly discuss \nmethods for detecting stochastic \\ac{GW} backgrounds.\n\n\\subsection{Stochastic Search Method}\\label{subsec:stochastic_search}\n\n%\n% Intro to cross correlation\n% \nThe stochastic search method largely involves attempting to separate\n\\ac{GW} stochastic noise from the detector \nenvironmental/non-astrophysical noise. The noise background associated \nwith stochastic \\ac{GW}s may largely be characterised by its energy \ndensity per unit logarithmic frequency and is very similar \nto the the detector instrumental noise (i.e. may be approximately \ndescribed by a Gaussian-normal distribution~\\cite{Sathyaprakash2009}). \nAssuming an isotropic stochastic \\ac{GW} background, the noise \ninduces a strain spectral noise density on the detector given \nby Eq.~134 in~\\cite{Sathyaprakash2009}.\nThis strain would be detectable using a single detector only if it were \nsignificantly stronger than the detector noise \\ac{PSD}~\\cite{Sathyaprakash2009}. Since one can \nobtain improved sensitivities using multiple detectors, we \ntypically cross-correlate the noise \nbetween more than one detector in order to search for a correlated noise \ncomponents~\\cite{PhysRevD.59.102001,2019RPPh...82a6903C}~\\footnote{ This \nis performed under the assumption that instrumental noise is not \ncorrelated between multiple detectors}. This may be computed using \na multitude of techniques discussed in further \ndetail here~\\cite{Sathyaprakash2009,PhysRevD.59.102001,2019RPPh...82a6903C,\nRomano2017}. \n\n%\n% Briefly mention pulsar timing arrays and segway to Bayesian inf\n%\nWe also briefly mention that there are methods, other than through \nlaser interferometers, which stochastic \\ac{GW}s may be detected. \nGiven that the arrival times of pulses from Millisecond pulsars are \nso incredibly stable over large time scales~\\cite{Sathyaprakash2009}, \none can also perform cross-correlation analysis  \nbetween pulses from multiple pulsars. Through cross-correlation, \none may then be able to to distinguish between \nintrinsic pulse variability and pulse variability associated with \nthe stochastic \\ac{GW} background. This method is known as \npulsar timing and is discussed in more detail \nhere~\\cite{2018IAUS..337..158K}. In the follwing chapter, we will move \nfrom discussing \\ac{GW} sources and their detectability, to inferring \nthe parameters which characterise \\ac{GW} sources, using a technique \nknown as Bayesian inference.\n\n\\section{Bayesian Inference}\\label{sec:bayesian_inference}\n\n%\n% Introduce Bayes theorem\n%\nIt is not only important that we detect a \\ac{GW} event, but also \nvital that we \ninfer the underlying properties of that event in the form of its \nsource parameters (i.e. component mass, distance, sky location, etc.). \nIn \\ac{LVC}, the tried-and-true method for inferring source parameters is \ndone through Bayesian inference, \nwhich is derived from Bayes theorem~\\cite{Bayestheorem}. \nBayes theorem was first proposed by Reverend Thomas Bayes in the \n18th century and in it he formulated a new paradigm for thinking \nabout the laws of conditional probability. \n\n%\n% Difference between frequentist and Bayesian inference\n%\nBayesian probability, is a fundamentally different way of interpreting \nstatistics from the more traditional frequentist approach. For a frequentist, \nan unknown parameter of interest $\\theta$ is often considered to be a \nfixed quantity. A frequentist would determine the value of $\\theta$ \nthrough sampling of observational data to form a distribution. From \nthis distribution, a frequentist would then be able to determine \nconfidence intervals on their estimate of $\\theta$. For \nexample a confidence interval of $95\\%$ is stating \nthat the true value of $\\theta$ (for say 100 observations) would lie within the \ninterval in $95/100$ repeat observations. The \nother $5$ repeat observations are not guaranteed to be close to this interval \nand may take on any value. \n\nOn the other hand, a Bayesian does not consider the unknown parameter to \nbe a fixed value. Rather, the Bayesian considers the unknown parameter \nto be a random variable which is described by a probability distribution \nwith credibility \nintervals. A $95\\%$ credibility interval (distinctly different \nfrom confidence intervals), \ncorresponds to a $95\\%$ probability that the true value of parameter $\\theta$ \nlies within the interval, given \nobservational data $\\bm{d}$. Parameters $\\bm{\\theta}$ may then   \nbe inferred through direct application of Bayes theorem. In the following section \nwill describe Bayes theorem in detail and refer the \nreader to~\\cite{10.2307/91337} for further discussions on \nfrequentist inference.\n\n%\n% Intro to Bayes theorem\n%\nTo describe succinctly, Bayes theorem states that one can \ninfer the distribution of an \nunknown parameter, the posterior, by computing the likelihood of a \ngiven observation, scaled by our \nprior belief on the distribution of that unknown parameter. To put it \nin the context of \\ac{GW} astronomy, given observed detector \ndata and some prior assumptions about the source parameters of \na \\ac{GW} signal, the posterior can be described by \nthe source parameter values of that signal while also taking into account the \nuncertainty added by the signal being buried in noise. The \nposterior may be expressed as\n% Introduce posterior\n%\n\\begin{equation}\n    p(\\pmb{\\theta} | \\pmb{d}, I),\n\\end{equation}\n%\nwhere $p(\\bm{\\theta} | \\bm{d}, I)$ is the probability density \nof the source parameters of the signal \n($\\bm{\\theta}$ being a continuous variable), given some observed data \n(in the form of a time or frequency series) and \nall other assumed relevant information $I$. We presume that the integral over \nthe total posterior is normalised such that\n%\n% State that posterior is normalised such it integrates to 1\n%\n%\n\\begin{equation}\n    \\int d\\pmb{\\theta} p(\\bm{\\theta} | \\bm{d}, I) = 1.\n\\end{equation}\n%\n\nAccording to Bayes theorem, we can write the posterior as \n%\n% Show Bayes theorem\n%\n%\n\\begin{equation}\n    p(\\bm{\\theta} | \\bm{d}, I) = \\frac{p(\\bm{d}|\\bm{\\theta}, I)p(\\bm{\\theta}|I)}{p(\\bm{d}|I)}.\n\\end{equation}\\label{eq:intro_bayes_theorem}\n%\n%\n% Discussion on priors\n%\nWhere each term in Eq.~\\ref{eq:intro_bayes_theorem} can be described as \n\n\\begin{itemize}\n    \\item $p(\\bm{d}|\\bm{\\theta}, I)$: The probability of the data $\\bm{d}$ given the source parameters $\\bm{\\theta}$ \n    and information $I$, also known as the likelihood of the source parameters.\n    \\item $p(\\bm{\\theta}|I)$: Our prior belief on the distribution of source parameters $\\bm{\\theta}$ given information \n    $I$.\n    \\item $p(\\bm{d}|I)$: A normalisation factor called the Bayesian evidence which is obtained by integrating the likelihood times the prior over all possible parameters $\\bm{\\theta}$ given information $I$.\n\\end{itemize}\n\nThe prior $p(\\bm{\\theta}|I)$ is largely informed by our understanding \non the formation channels of \\ac{GW} sources and our current knowledge on \nthe general physics which govern events. For example, we would \nintuitively think that the distance of an object should always be \npositive, so will set the priors such that the distance of a \n\\ac{GW} source with respect to the detectors must always lie \nbetween two positive values. However, if we aren't as \nknowledgeable about a particular parameter $\\bm{\\theta}$, we \nmight try choosing a relatively uninformative prior. Choice of \nprior can also be incredibly influential on the posterior shape \nfor some \\ac{GW} parameters\\cite{PhysRevLett.119.251103}, \nbut in general both the prior and the likelihood have equal weight in terms \nof how they influence the posterior.\n\n%\n% Discussion on likelihood\n%\nThe way in which we define the likelihood \n$p(\\bm{d}|\\bm{\\theta}, I)$ is essentially up to the practitioner, but \nthe quality of your analysis will depend on whether \nyou are using a well-informed likelihood function \n- otherwise stated as knowing your noise distribution model. \nFor \\ac{GW} astronomy, we \ntypically define a likelihood which assumes that the detectors operate under \nGaussian noise-like conditions. The Gaussian-noise likelihood \nfunction may be written as \n%\n\\begin{equation}\n    p(\\bm{d}|\\bm{\\theta}, I) = \\mathlarger{\\sum_{i}} \\frac{1}{\\sqrt{2\\pi \\sigma_i^2}} \\textrm{exp}\\left(-\\frac{1}{2} \n    \\frac{(d_i - \\mu(\\theta)_i)^2}{\\sigma_i^2}\\right),\n\\end{equation}\n%\nwhere $i$ is the frequency bin index, $\\sigma_i$ is the noise \n\\ac{ASD}, $d_i$ is the observed data and $\\mu(\\bm{\\theta})_i$ is a \ntemplate \\ac{GW} waveform parameterised by source parameters \n$\\theta$. It should also be noted \nthat $\\sigma_{i}^{2}$ is proportional to the noise \n\\ac{PSD} defined earlier in  Eq.~\\ref{eq:PSD}, \nsince the \\ac{ASD} is given as being \nthe square root of the \\ac{PSD}. \n\n%\n% Discussion on the evidence\n%\nThe evidence $p(\\bm{d}|I)$ can be defined as\n%\n\\begin{equation}\n    p(\\bm{d}|I) = \\int p(\\bm{d}|\\bm{\\theta},I) p(\\bm{\\theta}|I) d\\bm{\\theta}.\n    \\label{eq:bayes_evidence}\n\\end{equation}\n%\nThe evidence is usually referred to as the marginal \nlikelihood. It is often used in order to \nperform model selection where the evidence is required in order to calculate a\nquantity known as the \nBayes factor. The Bayes factor is a quantifiable method for which computing \nthe likelihood of one model versus another.\nThe Bayes factor is defined as the ratio of evidence for two \ndifferent models/hypothesis. For example, as shown \nin~\\cite{2019PASA...36...10T} \none could investigate the likelihood for \na model which assumes a signal+noise model $p(\\bm{d}|I)_{s}$ \nversus a noise-alone model $p(\\bm{d}|I)_{n}$. \nThe Bayes factor for such an investigation may be written as \nthe ratio of one evidence assuming the signal+noise hypothesis over \nanother evidence assuming the noise-alone hypothesis expressed as \n%\n\\begin{equation}\n    B^{s}_{n} = \\frac{p(\\bm{d}|I)_{s}}{p(\\bm{d}|I)_{n}},\n\\end{equation}\n%\nwhere the noise-alone evidence integral $p(\\bm{d}|I)_{n}$ may \nbe written as  \n%\n\\begin{equation}\n    p(\\bm{d}|I)_n = \\sum_i \\frac{1}{2\\pi\\sigma_{i}^2} \n    \\mathrm{exp}(\\frac{1}{2}\\frac{|d_{i}^2|}{\\sigma_{i}^2}).\n\\end{equation}\n%\nIf one uses a more formal definition, determining the preference \nof one model $A$ over \nanother $B$ given observed data $\\bm{d}$ is actually determined through \na term known as the odds ratio $O^{A}_{B}$. The odds ratio is  \na combination of the Bayes factor and the prior odds \nratio given as\n%\n\\begin{equation}\n    O^{A}_{B} = \\frac{p(\\bm{d}|I)_A}{p(\\bm{d}|I)_B} \\frac{\\pi_A}{\\pi_B},\n\\end{equation}\n%\nwhere $\\pi_A,\\pi_B$ are the prior beliefs on hypothesis $A$ and $B$ \nrespectively.\n\n%\n% Parameter estimation\n%\nIf we are purely interested in parameter estimation and since \nwe are marginalising over all parameters $\\bm{\\theta}$ \nin Eq.~\\ref{eq:bayes_evidence}, \nwe can state that the evidence is independent of $\\bm{\\theta}$. \nSince the evidence is independent of $\\bm{\\theta}$ and it is prohibitively \nexpensive to compute this factor~\\footnote{We note that in nested sampling, \nthe main purpose of the algorithm is in fact to compute this \nquantity in a computationally feasible manner. \nSee Sec.~\\ref{sec:nested_sampling} for further details.} \n(because we are integrating over the whole \nparameter space of $\\bm{\\theta}$), most \nBayesian practitioners purely interested in performing parameter estimation \nwill ignore Eq.~\\ref{eq:bayes_evidence} ( and rewrite Bayes theorem in \nthe simpler form \n%\n\\begin{equation}\n    p(\\bm{\\theta} | \\bm{d}, I) \\propto p(\\bm{d} | \\bm{\\theta},I) p(\\bm{\\theta}|I).\n\\end{equation}\n%\n% Transition to MCMC and Nested sampling\n%\nGiven that sampling from the posterior distribution is an inverse \nproblem, which can become prohibitively computationally expensive as \nthe number of dimensions $\\theta$ is increased~\\cite{2019PASA...36...10T}, \nthere is prime motivation \nfor the use of efficient methods for sampling from the posterior. In \nthe following subsections I will describe two popular methods for sampling from the posterior $p(\\bm{\\theta}|\\bm{d},I)$: \\ac{MCMC} and Nested Sampling.\n\n\\subsection{Markov Chain Monte Carlo}\n\n%\n% Intro and Monte Carlo sampling\n% Could also provide some historical perspective on random/importance sampling\n\\ac{MCMC} is used when we would like to try and sample from some distribution, \nfor example the posterior $p(\\bm{\\theta}|\\bm{d})$, or approximate the expectation value $E(f)$ of some function $f(\\bm{\\theta})$ which is of a high dimension/complexity\n%\\begin{equation}\n%    E(f) = \\frac{1}{N} \\sum_{i=1}^{N} f(\\theta_i).\n%\\end{equation}\nWhere $p$ is so complex that trying to sample from $p$ through traditional means would be prohibitively expensive. Other methods for \nsampling from complicated distributions such \nas, \\textit{importance sampling} and \\textit{random sampling} may \nalso be used, but are outside of the scope of this thesis and I refer the interested reader to~\\cite{2019arXiv190912313S} for a more through \ndiscussion on both techniques.\n\nThe Monte Carlo portion of \\ac{MCMC} \nrefers to a technique known as Monte Carlo sampling~\\cite{4736059}.\nMonte Carlo sampling means to randomly sample from some distribution.\nFor example, we could choose to randomly sample from a normal \ndistribution $N(0,1)$ or from uniform distribution $U(0,1)$ \nbetween 0 and 1. We would \nthen define the normal or the uniform distribution that we're sampling \nfrom the proposal distribution. If we randomly sample from the \nproposal distribution enough times a histogram of the resulting \nsamples should resemble that of the original proposal distribution. \n\n%\n% Markov Chain\n%\nA Markov Chain~\\cite{norris_1997} is a sequence of numbers\nwhereby each number in the sequence is only dependent on the \nprevious number in the sequence. For example, if we again decided to \nrandomly sample from proposal distribution $N(0,1)$, but instead \nafter each sample is drawn we change the mean of the proposal distribution \nto be equal to that of the previous sample $N(\\theta_{i-1},1)$, we \nwould end up with something known as a random walk.\n\n%\n% How to accept/reject proposals\n%\nIn order to construct an algorithm which is able to generate $n$ samples \nfrom the posterior in steps of $i$, we want to ensure \nthat two criterion are met: stationarity (i.e. convergence in the limit \nwhere $n \\leftarrow \\infty$) and a final set of samples which is \nequivalent to the posterior \n$p(\\bm{\\theta}|\\bm{d},I)$~\\cite{2019arXiv190912313S}. One method for \nensuring both criterion's is the \n\\ac{MH} algorithm~\\cite{doi:10.1063/1.1699114}. We will now go \non to explain how the \\ac{MH} algorithm works and have also provided \na pseudo code of the algorithm (Alg.~\\ref{alg:MCMC}) for reference.\n\n\\begin{algorithm}[hbt!]\n\\caption[A simple Markov Chain Monte Carlo algorithm]{A simple \n\\ac{MH} \\ac{MCMC} algorithm. An initial \nstarting point, $\\theta_c$, is generated (also \nknown as the current position of the chain). A new point to ``jump'' to, \n$\\theta_p$, is proposed from a proposal distribution $Q$. The \nposterior \\ac{PDF} at both $\\theta_c$ and $\\theta_p$ is calculalted \n($Y_c,Y_p$). If $Y_p$ is greater than $Y_c$ then the new proposal \npoint is automatically accepted as the current point. Otherwise, \na probability for accepting the new proposed point is \ncalculated ($\\alpha$). If $\\alpha$ is less than a random \nnumber drawn from a uniform distribution between 0 and 1, then \nthe proposed point is accepted, otherwise it is rejected and \nwe maintain the current posterior sample value. The posterior \nsample value, either $\\theta_c$ or $\\theta_p$ which is accepted \nas the new current position is saved at each iteration $i$ \nand returned at the end of $n$ iterations as the list of $n$ \nsamples which should be representative of the posterior \n$p(\\bm{\\theta}|\\bm{d})$.}\\label{alg:MCMC}\n\\begin{algorithmic}\n\\State Generate random initial starting point $\\theta_c$;\n%\\ \\theta_j, ..., \\theta_{N_\\mathrm{live}} \\ \\mathrm{from \\ the \\ prior;}$\n\\For {$i = 1 \\ \\mathrm{to} \\ n$};\n\\State $\\theta_{p} = Q(\\theta_p|\\theta_c)$,\n\\State \\textbf{set} $Y_c = p(\\theta_c|d)$,\n\\State \\textbf{set} $Y_p = p(\\theta_p|d)$, \n    \\If {$Y_p > Y_c$}\n        \\State $\\theta_c = \\theta_p$\n        \\State $P_i = \\theta_p$\n    \\Else\n        \\State $\\alpha = \\frac{p(\\theta_{p}|d)}{p(\\theta_{c}|d)} \\frac{Q(\\theta_{c}|\\theta_{p})}{Q(\\theta_{p}|\\theta_{c})}$\n        \\If {$\\alpha < U(0,1)$}\n            \\State $\\theta_c = \\theta_p$\n            \\State $P_i = \\theta_p$\n        \\Else\n            \\State $P_i = \\theta_c$\n        \\EndIf\n    \\EndIf\n\\EndFor\n\\State \\textbf{return} $P_n$.\n\\end{algorithmic}\n\\end{algorithm}\n\nThe \\ac{MH} algorithm begins by first drawing a random point, $\\theta_c$, \n(also known as a \\textit{walker}) (usually from the prior space, $p(\\theta|I)$) \nand calculating the posterior \\ac{PDF} \nat that point $p(\\theta_{c}|d)$. We also define a simple  \nproposal distribution $Q$ which is dependent on the  \ncurrent state $\\theta_c$ and from which we will \nsample from over $n$ steps of the algorithm ($Q$ is usually \ndescribed by a Multi-variate Gaussian distribution whose \nmean is equivalent to the current state $\\theta_c$).\n$Q$ is chosen to be a simple distribution since it is easy \nto sample from at each step, as opposed to the complex posterior distribution.\n\nThe \\ac{MH} algorithm then calculates the posterior \\ac{PDF}, $p(\\theta_{p}|d)$, given a new proposed sample $\\theta_{p}$ drawn from the proposal distribution \n$Q(\\theta_{p}|\\theta_{c})$ evaluated at current state $\\theta_{c}$. \nThe posterior \\ac{PDF} value of the current position \n$p(\\theta_{c}|d)$ is also evaluated with current state sample $\\theta_c$ \ndrawn from proposal distribution $Q(\\theta_{c}|\\theta_{p})$ evaluated \nat $\\theta_{p}$. \nThe ratio of the two posterior \\ac{PDF} values scaled by the ratio \nof $\\frac{Q(\\theta_{c}|\\theta_{p})}{Q(\\theta_{p}|\\theta_{c})}$ is \nthen computed\n%\n\\begin{equation}\n    \\frac{p(\\theta_{p}|d)}{p(\\theta_{c}|d)} \n    \\frac{Q(\\theta_{c}|\\theta_{p})}{Q(\\theta_{p}|\\theta_{c})},\n\\end{equation}\n%\nwhere both $p(\\theta_{p}|d)$ and $p(\\theta_{c}|d)$ are estimated through \nevaluating the prior distribution and the likelihood function at $\\theta_{p}$ and $\\theta_{c}$ respectively. The ratio is derived from the statistical \nconcept of ``detailed balance'' which states that probability is \nconserved from one position to another and the full derivation is given \nin~\\cite{2019arXiv190912313S}. If this ratio is greater than $1$, \nthen we always \naccept the new proposed sample as the new current state. If however, \nthe ratio is less \nthan $1$, we will \nnot necessarily reject the new proposed sample. Instead, we \ndetermine an acceptance probability based on the ratio. The acceptance \nprobability is determined by first drawing a uniform random number between \n0 and 1. We accept the new proposed sample as the new current state if \nthe ratio value is greater than the randomly drawn number. Otherwise, \nthe current state remains at position $\\theta_c$. As \nshown in~\\cite{2019arXiv190912313S}, \nthe probability of acceptance ($\\alpha$) of a new sample \nin the Markov Chain can be expressed as\n% Probability of acceptance equation\n%\n\\begin{equation} \\label{eq:MCMC_acceptance}\n    \\alpha = \\begin{cases}\n  \\frac{p(\\theta_{n+1}|d)}{p(\\theta_{n}|d)} \\frac{Q(\\theta_{n}|\\theta_{n+1})}{Q(\\theta_{n+1}|\\theta_{n})} & \\text{if } p(\\theta_{n+1}|d) < p(\\theta_{n}|d)\\\\    \n  1 & \\text{if } p(\\theta_{n+1}|d) \\ge p(\\theta_{n}|d).       \n  \\end{cases}\n\\end{equation}\n%\n\n\n%\n%\n% Issues with Metropolis Hastings\n%\nThere are a few downsides to using the Metropolis Hastings algorithm. One \nof those downsides being that we have to choose a starting point \nfor the random walk, which is initially liable to be far from the \ntrue posterior. This could be problematic if the posterior is composed \nof a small peak or peaks with \na large amount of likelihood concentrated in a small region of the \nparameter space. It may also take a large number of iterations for the \nalgorithm to walk towards areas of high likelihood contained within \na small region of the parameter space. Commonly, a number \nof samples at the beginning of the walk are discarded such that the \nremaining represent a point after which the algorithm has reached \na stable equilibrium. We call the discarded samples \nthe burn-in period. Another issue \nrelates to something known as autocorrelation. Samples $\\bm{\\theta}$ \ngenerated through \nthe Makrov Chains in the Metropolis Hastings algorithm may be \nautocorrelated with each \nother and are thus not necessarily fully \nrepresentative of the posterior~\\cite{2019PASA...36...10T}, since \nautocorrelation implies that the samples drawn are not statistically \nindependent from each other. We can \nmitigate such correlations through a process known as thinning. \nThinning involves generating a large amount of samples from the \nproposal distribution, but only keeping every $N^{\\textrm{th}}$ \nsample from that large sample set, described in further detail\nhere~\\cite{https://doi.org/10.1111/j.2041-210X.2011.00131.x}.  \n\n%\n% GW MCMC references and brief discussion\n%\nExpanding on from traditional \\ac{MCMC} methods, the \\ac{MCMC} algorithms \nused in this thesis (\\texttt{emcee}~\\cite{emcee},\n\\texttt{ptemcee}~\\cite{ptemcee}) both apply \ntheir own additional methodologies and tweaks to the original algorithm. \nFor example, in \\texttt{emcee} there is an operation applied known as the \n``stretch move''. The stretch move by be described by first \nconsidering an ensemble \nof walkers being evolved simultaneously over $n$ steps. The stretch \nmove involves proposing a new state for the $k$th walker, $\\theta_{p}^k$, \nwhich is dependent on the current state of another randomly \nselected walker, $\\theta_{c}^{j}$, \nfrom the ensemble. This is opposed to the traditional method \nwhere new proposed states are entirely dependent on the previous state \nof that same chain. The new state of the $k$th walker is then given by \n%\n\\begin{equation}\n    \\theta_{p}^k = \\theta_{c}^j + Z[\\theta_{c}^k - \\theta_{c}^j] \n\\end{equation}\n%\nwhere $Z$ is a randomly selected variable from a proposal distribution \nparameterised by $\\theta_{c}^k - \\theta_{c}^j$. This process is then \nrepeated in a series over all walkers~\\cite{emcee}. The stretch move may also \nthen be parallelised, as shown in~\\cite{emcee}, by splitting the walkers \ninto two separate sets and updating walkers from one set with \nwalkers from another. It has been shown in~\\cite{emcee} that the \nmethodology employed by \\texttt{emcee} has superior performance over \nother traditional methods in the form of shorter autocorrelation \ntimes (i.e. more statistically independent samples) when run on several complex distributions~\\cite{emcee}.\n\n%\n% ptemcee\n%\nIn \\texttt{ptemcee}, multiple Markov chains are run in parallel \nat varying \\textit{temperatures}. Temperatures refer to different \ntempered versions of the posterior given by \n%\n\\begin{equation}\n    p(\\bm{\\theta}|\\bm{d}) \\propto p(\\bm{d}|\\bm{\\theta})^{1/T} p(\\bm{\\theta}),\n\\end{equation}\n%\nwhere $T$ is the temperature value. Temperatures are assigned to all \nMarkov chains in a geometrically spaced ladder from 1 up to a $T_{\\mathrm{max}}$, where the maximum temperature, $T_{\\mathrm{max}}$, \nis pre-determined by the user. \nTemperature values for each chain are also periodically swapped with other \nadjacent chains according to an acceptance ratio defined \nin Eq. 2 of~\\cite{ptemcee}.\nThe advantage of using temperatures is that the \nlikelihood $p(\\bm{d}|\\bm{\\theta})^{1/T}$ \ngets flattened out at high $T$, thus making the distribution easier to \nsample from. \\texttt{ptemcee} is especially useful when one wants to \nfind the global maximum and multiple modes of a complex \nposterior distribution~\\cite{Reyes2019DETECTIONAI}. \nFor further details which are outside the scope of this \nthesis, see~\\cite{ptemcee,Reyes2019DETECTIONAI}. We will now \ndiscuss an alternative sampling method to \\ac{MCMC}, nested sampling.\n\n% see: http://www.inference.org.uk/bayesys/nest.pdf\n\\subsection{Nested Sampling}\\label{sec:nested_sampling}\n\nNested sampling is another method which can be used in order to \nsample from the posterior. However, \nthat wasn't the primary goal in mind when the method was \nfirst developed~\\cite{2004AIPC..735..395S,skilling2006} \nand the posterior is only really obtained as a \nbyproduct (unlike \\ac{MCMC} which \\textit{directly} samples from the \nposterior). An additional motivation for nested sampling relates to \nthe fact that \\ac{MCMC} can have issues when trying to deal with \nwidely spaced multi-modal and degenerate distributions, where a \ndegenerate distribution is defined as having samples $x$ which \nsatisfy the condition for some constant $c$ such that \n$p(x=c)=1$~\\hunter{not sure about this \ndegenerate definition}. Nested sampling was first introduced by \nSkilling in 2004~\\cite{2004AIPC..735..395S} (later expanded \nupon in 2006~\\cite{skilling2006}) because he wanted a tractable method for \ncomputing the Bayesian evidence (sometimes known as the marginal \nlikelihood) in order to compare different models effectively. In \nnested sampling, samples from the posterior can be obtained as a \nbyproduct following the evaluation of the evidence. One would be forgiven for  \nnaively assuming that it would be easy to compute this integral by \nsimply evaluating the integrand for many values of $\\bm{\\theta}$ and then \nnumerically integrating over the $\\bm{\\theta}$ space. Unfortunately, \nthis procedure can get computationally expensive quickly as the \nnumber of inferred parameters $\\bm{\\theta}$ increases. Rather than \nintegrating over the whole space of parameters $\\bm{\\theta}$ explicitly, \nit would be advantageous to redefine Eq.~\\ref{eq:bayes_evidence} such that \nit was only dependent on a single parameter and an approximate \nmethod for computing the integral could possibly be found. The \nfundamental idea that a complex high-dimensional problem with \nmany inferred parameters may be represented in a simplified \n1-dimensional form is one of the key ideas of nested sampling. \nThis then begs the question, how do we convert \nto a simplified 1D form and compute the evidence from this 1D form? I \nwill now describe the details of such an algorithm.\n\nIn order to convert the problem to a simpler 1D form, Skilling \nstarts by defining the \ntotal prior mass $X$, stated as the total amount of \nprior contained within a given likelihood contour $\\lambda$ expressed as \n%\n\\begin{equation}\\label{eq:prior_volume}\n    X(\\lambda) = \\int_{p(\\bm{d}|I)> \\lambda} p(\\bm{\\theta}|I) d\\bm{\\theta}.\n\\end{equation}\n%\nRearranging Eq.~\\ref{eq:prior_volume} through an inversion of the \nequation we arrive at a \nnew definition of the evidence integral\n%\n\\begin{equation}\\label{eq:1d_nested_like}\n    p(\\bm{d}|I) = \\int_{0}^{1} p(X) dX, \n\\end{equation}\n%\nwhere $dX = p(\\bm{\\theta}|I)d\\theta$ and $p(X)$ is the likelihood \nevaluated at $p(\\bm{d}|I)> \\lambda$\n. It can be clearly seen from Eq.~\\ref{eq:1d_nested_like} \nthat that the evidence integral is now a function of a \nsingle parameter $X$, the \nprior mass. The integral in Eq.~\\ref{eq:1d_nested_like} has limits from \\\n0 to 1 since the prior mass decreases from \n1 to 0 as the likelihood contour $\\lambda$ \nincreases. The reasoning for these \nlimits is most clearly illustrated in Fig.~{2} of~\\cite{skilling2006} \nwhere at low likelihood \nvalues (i.e. broad likelihood contour and low $\\lambda$), we see \ntotal contained prior mass \nas close to 1, and at increasing likelihood values the prior mass approaches values of 0.\n\nIn order to compute the integral (i.e. area under the curve of Fig.~{2} in~\\cite{skilling2006}) \nof Eq.~\\ref{eq:1d_nested_like}, \nSkilling applies the trapezoid rule to Eq.~\\ref{eq:1d_nested_like} and \nexpresses Eq.~\\ref{eq:1d_nested_like} as a weighted summation defined as \n%\n\\begin{equation}\\label{eq:approx_sum_nested_evidence}\n    p(\\bm{d}|I) = \\sum_{i}^M \\omega_i p(X_i),\n\\end{equation}\n%\nwhere $\\omega_i = \\frac{1}{2} (X_{i-1} - X_{i+1})$. Since $p(X)$ is not typically well-known, \nthe nested sampling algorithm instead approximates $p(X)$ by \ndrawing samples from the \nconstrained prior mass $X$ in $M$ slices, where $0 < X_{M} < ... < X_1 \n< X_0 = 1$. As outlined in Alg.~\\ref{alg:nested}, the \nalgorithm begins by first generating \nan initial set of $N_{\\mathrm{live}}$ ``live points'' \ninitially drawn from the prior $p(\\bm{\\theta})$ \n(usually on the order of $\\sim 1000$). At each prior mass volume slice $X_i$, \nthe likelihood values for each live point is calculated and the \nlive point with the \nlowest likelihood value identified which gives us our approximate $p(X_i)$. \nThe parameters associated with the minimum \nlikelihood live point, $\\theta_i$, are then saved for later use in constructing \nthe posterior (described shortly). The minimum live point \nis then discarded and replaced with a new live point from \nthe prior $p(\\bm{\\theta}|I)$ such \nthat the likelihood value of the \nnew live point is greater than the likelihood value of the old minimum live \npoint from the previous step $i$. There are several methods \nfor generating a new live point \nfrom the prior under the given likelihood constraints, which \nwill also be outlined shortly.\n\n\\begin{algorithm}[hbt!]\n\\caption[A simple nested sampling algorithm]{A simple nested \nsampling algorithm. A set of live \npoints, $N_{\\mathrm{live}}$, are first initialised. For each \nstep, $i$, over $M$ iterations, the minimum likelihood value \nfor all current live points is determined,\n$p(d_i|\\theta_i,I_i)$. A weight, $\\omega_i$, is then \ncaclculated which is parameterised by the constrained prior volume, $X_i$. The likelihood of the minimum live point is then multiplied by the weight \nand added to the running evidence value, $p(\\bm{d}|I)$. Both \n$\\theta_i$ and $\\omega_i$ are saved and the minimum likelihood \nlive point is replaced with a new live point which is sampled \nfrom the constrained prior such that the new point likelihood \nis greater than the removed live point's. Sampling concludes \nonce a user pred-defined stopping criterion is met.}\\label{alg:nested}\n\\begin{algorithmic}\n\\State \\textbf{set} $\\mathrm{Generate} \\ N_{\\mathrm{live}} \\ \\mathrm{points} \n\\ \\theta_j, ..., \\theta_{N_\\mathrm{live}} \\ \\mathrm{from \\ the \\ prior;}$\n\\For{$i = 1 \\ \\mathrm{to} \\ M$};\n\\State \\textbf{set} $p(d_i|\\theta_i,I) = $ min $($ likelihood values of active live points $)$,\n\\State \\textbf{set} $X_i \\approx -\\frac{1}{N_{\\mathrm{live}}} X_{i-1}$, \n\\State \\textbf{set} $\\omega_i = \\frac{1}{2}(X_{i-1} - X_{i+1})$,\n\\State \\textbf{set} $p(\\bm{d}|I) = p(\\bm{d}|I) + p(d_i|\\theta_i,I) \\omega_i$,\n\\State \\textbf{save} live point $\\theta_i$ along with weight \n$\\omega_i$,\n\\State \\textbf{remove} $\\theta_i$,\n\\State \\textbf{replace} $\\theta_i$ with new live point sampled from \nconstrained prior,\n\\State \\textbf{ensure} new live point likelihood $\\geq$ old $\\theta_i$ min likelihood,\n\\EndFor\n\\State \\textbf{return} $p(\\bm{d}|I)$.\n\\end{algorithmic}\n\\end{algorithm}\n\n%\n% How do we get X_i values\n%\nAs shown in~\\cite{skilling2006}, the prior mass at each step \n$X_i$ is equivalent to\n$X_i = t_i X_{i-1}$, where $t_i$ is a probability distribution defined on the \nbounds $U(0,1)$ and may be expressed as \n$t_i = N_{\\mathrm{live}} t_{i}^{N_{\\mathrm{live}} - 1}$. Taking the expectation \nvalue of the distribution $E[t_i]$, we see that the log prior mass shrinks \napproximately by a factor of $\\approx -1/N_{\\mathrm{live}}$ for each step, thus \ngiving us an accurate method for approximating $X_i$.\n\n%\n% Nested stopping criterion\n%\nUnfortunately, there is no exact figure merit which guarantees \nthat the nested sampler has converged. This is because there is always \nthe marginal possibility that there will unexplored regions of \nthe parameter space which may contain high likelihood in a small \ncontour~\\cite{skilling2006}. A rough approximate which \nmost practitioners use to \ndetermine convergence is through a quantitiy known as the log evidence \nratio. The log evidence ratio is defined as the  \nestimated total evidence and the current accumulated evidence the \ncurrent evidence $p(d_i|I)$~\\cite{2021ascl.soft03022B}. The estimated \ntotal evidence is a summation of the current accumulated evidence \nand the estimated remaining evidence. The estimated remaining \nevidence is approximated by identifying the current maximum likelihood \nvalue out of all current active live points \n$p(d_{\\mathrm{max}}|\\theta_{\\mathrm{max}},I)$ multiplied by the current \nenclosed prior mass $X_i$ given by\n%\n\\begin{equation}\n    p(d_{\\mathrm{est}}|I) = p(d_{\\mathrm{max}}|\\theta_{\\mathrm{max}},I) \n    X_i.\n\\end{equation}\n%\nA stopping criterion for the algorithm, $\\mathrm{dlog}Z$, is then \ndefined as the ratio \nof the estimated total evidence and the current accumulated \nevidence expressed as\n%\n\\begin{equation}\n    \\mathrm{dlog}Z = \\mathrm{log}\\left(\\frac{p(d_{\\mathrm{est}}|I) + \n    p(d_i|I)}{p(d_i|I)}\\right) < \\zeta,\n\\end{equation}\n%\nwhere $\\zeta$ is a user pre-defined stopping \nthreshold, most nominally chosen to be $\\sim 0.1$~\\cite{2021ascl.soft03022B}.\nThe reasoning behind this definition of algorithm stopping criterion is that \nsmall changes in $p(\\bm{d}|I)$ indicate that \nthe accumulation of the evidence is tailing off, so thus the evidence \nis nearly fully integrated and sampling may thus be terminated.\n\n%\n% How posterior samples are generated using Nested sampling\n%\nNow that we have described how one may use nested sampling \nto accurately and efficiently approximate the evidence, it turns \nout that the posterior may also easily be sampled from as a byproduct \nof the nested sampling algorithm. Given that the posterior \nis simply the prior weighted by the likelihood and since \nwe have already accumulated likelihood samples through \nEq.~\\ref{eq:approx_sum_nested_evidence} in the form of the \nminimum live point likelihood value over $M$ steps, $p(d_i|\\theta_i,I)$ \nand samples from the prior through the saved parameter values of \neach that same minimum live point it is \nshown in~\\cite{10.1111/j.1365-2966.2011.20288.x,1409.7215} that the \nposterior may thus be approximated as\n%\n\\begin{equation}\n    p(\\bm{\\theta}|\\bm{d},I) \\approx \\frac{ \\sum_{i}^{M} p(X_i) \\omega_i  \\delta(\\theta_i)}{p(\\bm{d}|I)}, \n\\end{equation}\n%\nwhere $\\delta(\\theta_i)$ is the Dirac delta function centered on \nthe $i$th posterior sample $\\theta_i$.\n\n%\n% Unique attributes of nested samplers used in thesis\n%\nThe two nested sampling software packages used in this thesis \n(\\texttt{Dynesty}~\\cite{dynesty}, \\texttt{CPNest}~\\cite{cpnest}) \napply their own tweaks to the original nested sampling algorithm \nproposed in~\\cite{skilling2006}. The primary difference between \napproaches lies in how each method decides to replace \nthe discarded lowest likelihood live point at each step/contour \n$i$, given the constrained prior distribution at that step. \nIn \\texttt{CPNest}, this is accomplished by first randomly selecting one of the \ncurrent active live points. An \\ac{MCMC} chain is then run from \nthe starting point value equivalent to the randomly selected live \npoint. The maximum length of the \nchain may be pre-defined by the user and varies from \nstep to step in the \\texttt{CPnest} algorithm according to the \nautocorrelation time scale (see Eq.~23 of~\\cite{1409.7215} for \nthe definition). Additional features are also included in \\texttt{CPNest} which \nreduce the amount of manual tuning required for convergence and are explained \nin more detail here~\\cite{1409.7215}.\n\n%\n% What makes dynesty unique?\n%\n\\texttt{Dynesty} by default uses a combination of \\ac{MCMC} chains and \nellipsoids to produce independently and identically distributed posterior \nsamples. Specifically, new live points are drawn to \nreplace the lowest likelihood point at each step by approximating the \nbounds of the current prior mass $X_i$ using ellipsoids (by default, the \nalgorithm uses multiple ellipsoids). Ellipsoids are constructed and \noptimised using k-means clustering. Once a proper bound has been \nconstructed, samples may be generated conditioned on those bounds \nusing a multitude of methods outlined in Sec.~4.2 of~\\cite{dynesty}. By \ndefault, \\texttt{Dynesty} draws a new sample from the constrained prior \nsuch that it is within the bounds defined by the ellipsoids and then \nevolves that sample through to an \\ac{MCMC} chain whose proposal \ndistribution by default is dependent on one of the ellipsoids (selected \nrandomly). Further details and additional tuning options available in \n\\texttt{Dynesty} are outlined in~\\cite{dynesty}.\n\n%\n% Computational expense of sampling algorithms\n%\nIn general, it should be noted here that the computational resources \nrequired to run the sampling algorithms listed above (\\textt{Dynesyt}, \n\\texttt{CPNest}, \\texttt{emcee}, \\texttt{ptemcee}) can be \nextensive. Considering real-world examples, during the \nfirst half the most recent observing \nrun (O3a)~\\cite{gracedb_O3}, the shortest amount of time required \nto run some of \nimplementations listed on \\ac{BBH} events was (6hrs, 8 minutes, 35s) for \ncandidate S190521g, whereas the longest run was (38 days, 13 hours, \n24 minutes, 37 seconds) for candidate S190503bf\n(Tab.~\\ref{tab:o3_events_runtime_1} \nand Tab.~\\ref{tab:o3_events_runtime_2}). It's probable that \ncandidate S190503bf may have been an outlier in terms of computational \nexpense, but even when removing the outlier, the maximum runtime \nfor all \\ac{BBH} events is $\\approx$ 4 days 21 hours 20 minutes and \n22 seconds. For \\ac{NSBH} candidates the runtime ranges from 11 hours, \n51 minutes, 55 seconds - 2 days, 21 hours, 50 minutes, 19 seconds and \nfor \\ac{BNS} candidates it ranges from 11 hours, 50 minutes, 58 \nseconds - 2 days, 1 hour, 49 minutes, 37 seconds. Given these\nnumbers, it's clear that there is sufficient \nroom for improving the latency parameter estimation pipelines. Such \nimprovements to the latency of sampling methods (whether through \nimproving the samplers themselves or proposing alternative methods) would \nbe immensely beneficial low-latency follow-up analysis (as outlined in \nSec.~\\ref{sec:multi-messenger}).\n\n\\section{Multi-Messenger Astronomy}\\label{sec:multi-messenger}\n\nAfter a \\ac{GW} signal has been identified, alerts are sent out to \n\\ac{EM} partners around the globe in order to perform follow-up \nobservations. Astronomical partners include \ninstruments which look across \nthe whole range of the \\ac{EM} spectrum: Radio, Microwave, \ninfrared, visible light, ultra-violet, X-ray and gamma ray. A full Bayesian \nposteriors are generally produced on all viable \\ac{GW} candidates. In \naddition to the full Bayesian analysis, the collaboration \nis also able to produce \nlow-latency parameter estimation products (e.g. sky maps) using tools such \nas \\texttt{Bayestar}~\\cite{2016PhRvD..93b4013S} shown in\nFig.~\\ref{fig:GW170817_skylocalization}. \\texttt{Bayestar} operates\nunder the assumption that a large degree of the information contained in a \n\\ac{GW} signal is encapsulated within a small number of data \nproducts produced by the \nsearch matched filtering process, namely: the time, amplitude and \nphase of the signal at \neach detector. Using a simplified likelihood function and the \nFisher information matrix~\\cite{2017arXiv170501064L}, \n\\texttt{Bayestar} is able to produce estimates \non a limited number of source parameters \n(sky location, distance and orientation) in \nunder a few minutes which provides a good approximate of the full \nBayesian posterior~\\cite{2014ApJ...795..105S}.\n\nPrompt sky location, distance and orientation data products \nusing tools like \\texttt{Bayestar} and \n\\texttt{Bilby} along with observations from \\ac{EM} \npartners can provide new insights into \nfundamental astrophysical processes. For example, as \\ac{BNS} signals \nreach the final stages of the inspiral phase of the merger, the internal \nstructure of the sources has more of a pronounced effect on the \nresulting \\ac{GW} signal. Information on tidal disruption processes \nmay be gleamed from this part of the \n\\ac{GW} signal in combination with prompt observations from the \n\\ac{EM} spectrum~\\cite{1989thyg.book.....H}.\n\\ac{EM} follow-up analysis can also be used in tandem with \nBayesian analysis in order to produce inferences on the \nHubble constant, though may also be performed without an \\ac{EM} \ncounterpart using galaxy catalogues~\\cite{2020PhRvD.101l2001G}. A \nHubble constant measurement can \nbe done by obtaining accurate estimates on the luminosity distance directly \nfrom the \\ac{GW} signal through Bayesian inference and using \n\\ac{EM} partners to \nidentify a likely host galaxy, whereby correct \nidentification of the host galaxy may benefit \nfrom low-latency alerts. For GW170817, \\ac{LVC} and \\ac{EM} partners were \nable to infer a Hubble constant value of $\\sim 70^{+12}_{-8} \n\\mathrm{km s^{-1} Mpc^{-1}}$~\\cite{Abbott2017,PhysRevLett.119.161101}. \n \n%\n% Tests of general relativity\n%\nThe arrival time (along with an accurate estimation of the luminosity distance) of a \\ac{GW} event can be compared to the observation time of the \\ac{GRB} from a \\ac{BNS} merger counterpart. Comparing arrival \ntimes of both components allows us to test the effect gravitational potentials have on \n\\ac{BNS} \\ac{EM} radiation and \\ac{BNS} \\ac{GW}s (equivalence principle), as well as the speed of gravity \\cite{2017arXiv171005834L}. In addition, \nwe can perform tests on the accuracy of general relativity itself through residual noise waveform subtraction tests, insprial-merger-ringdown consistency tests and parameterised tests of \n\\ac{GW} generation under a Bayesian framework~\\cite{2019PhRvD.100j4036A}. Depending on the duration and \\ac{SNR} of the signal, accurate constraints may be placed on the graviton Compton wavelength and non-\\ac{GR} polarization states. Other tests of \\ac{GR}\nperformed over both event catalogues GWTC-1 and GWTC-2 are listed in great detail in~\\cite{PhysRevLett.116.221101,2019PhRvD.100j4036A,PhysRevD.103.122002}.\n\n\n%\n% Example of GW170817 sky localization. Not sure if I'm allowed to use other people's figures\n%\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/GW170817_skymap.jpg}\n    \\caption[Sky localization for the first confirmed detection of a \\ac{BNS} merger by the \\ac{LVC}.]{Sky localization for the first confirmed detection of a \\ac{BNS} merger by the \\ac{LVC}. Areas shaded in green are the data products from \\texttt{Bayestar} using both \\ac{LIGO} alone and \\ac{LIGO}/Virgo combined, dark blue are predictions from Fermi/GBM and light blue are predictions from IPN Fermi/INTEGRAL. Black and white images on right-hand side are visible light measurements of a bright event around the galaxy NGC 4993 thought to contain the afterglow of the \\ac{BNS} event. This figure was produced by the authors of \\cite{2017arXiv171005833L}.}\n    \\label{fig:GW170817_skylocalization}\n\\end{figure}\n\n\\section{Gravitational Wave Detections}\n\n%\n% O1 detections\n%\n\nSince it's inception, the \\ac{LVC} has carried out several observation runs. Initial operations ran from 2002 to 2010, but no \\ac{GW}s were detected during this time period. During the first observing run in the advanced detector era (September 2015 - January 2016), the \n\\ac{LVC} detected a total of $3$ \\ac{BBH} mergers \nincluding: GW150914~\\cite{PhysRevLett.116.061102}, \nGW151226~\\cite{PhysRevLett.116.241103} and \nGW151012~\\cite{2010.14527}. GW150914 was the very first detected \\ac{BBH} with\nan \\ac{SNR} value of $\\sim 25.1$~\\cite{0264-9381-33-21-215004}. GW151012 was originally labeled as a less significant potential GW detection \n(LVT151012) due to its \nhigh false alarm rate, but was subsequently upgraded to a \nconfirmed \\ac{GW} event in the GWTC-1 catalogue \\cite{1811.12907} because its false alarm rate was less than 1 per 30 days (a threshold determined by the \\ac{LVC}). The change in false alarm rate \nfor GW151012 can largely be attributed to various improvements made to \nall search algorithms used in the first observation run  \nbetween the initial detection and up to publication \nof the GWTC-1 catalogue paper (for further details, see~\\cite{1811.12907,\nPhysRevD.102.062003}).\n\n%\n% O2 detections\n%\nDuring the second observing run (November 2016 - August 2017) the \n\\ac{LVC} detected an additional $7$ \\ac{BBH}s with total masses between $\\sim 18.6 M_\\odot$ and $\\sim 85.1 M_\\odot$. The second observation run excitingly also saw the very first detection of a \\ac{BNS} event. The \\ac{BNS} event had the highest network \\ac{SNR} of any event over all of O1 and O2 ($\\sim 32.4$). Interestingly, there was also a large non-astrophysical noise transient which overlapped \nwith a portion of the \\ac{BNS} event in the \\ac{LIGO} Livingston \ndetector. This noise transient was successfully mitigated through an \nexcising technique known as time-domain gating \\cite{PhysRevLett.119.161101}. Approximately 1.7s following GW170817, a \\ac{GRB} (GRB170817) was observed \nacross multiple wavelengths of the \\ac{EM} spectrum over the course of several \nweeks~\\cite{2017arXiv171005834L}. The delay between GRB170817 \nand GW170817 has been used to place strong constraints on \nvarious physical phenomena including: the speed of gravity, Lorentz invariance and tests of the equivalence principal~\\cite{2017arXiv171005834L}. \nAdditionally, given that \\ac{GW} \nobservations provide direct estimates on the redshift and \nluminosity distance of the \nsystem, it was shown in ~\\cite{Abbott2017} that these observations may be used \nto provide an independent measurement on the Hubble constant \n($H_0 = 70^{+12}_{-8} \\mathrm{km s}^{-1} \\mathrm{Mpc}^{-1}$).\n\n%\n% O3a detections\n%\nMost recently, during the first half of the third observing run \n(April 2019 - March 2020) the \\ac{LVC} collaboration made an \nadditional $39$ confirmed \\ac{GW} event detections~\\cite{1811.12907, 2010.14527}\n. The increase in number of detections can largely be attributed to higher sensitivities of the detectors during this observation run over previous runs, with a \\ac{BNS} range\\footnote{The \\ac{BNS} range is a scalar value which is often used to represent the performance of the \\ac{LVC} detectors. It \nis quantified by determining the luminosity distance at which a single  \ndetector could detect a $1.4 \\mathrm{M}_\\odot$ \\ac{BNS} pair with an \n\\ac{SNR} $\\geq 8$ averaged \nover the sky location and orientation of the source with respect \nto the detector. The range is dependent on a number of factors including: \nsource mass/spin and the noise curve~\\cite{Abbott_2020} of the detector. See ~\\cite{2021CQGra..38e5010C,PhysRevD.47.2198} for more details.} of $108 \\mathrm{Mpc}$, $135 \\mathrm{Mpc}$ and $45 \\mathrm{Mpc}$ for Hanford, Livingston and Virgo respectively. The GWTC-2 catalogue contains detected signals \nwith component masses lower and higher \nthan the lowest and highest component masses contained in all of \nGWTC-1. The most up-to-date merger rate constraints according to GWTC-2 were also updated to be $\\sim 23.9 \\mathrm{Gpc}^{-3} \\mathrm{yr}^{-1}$ for \\ac{BBH}s and $\\sim 320 \\mathrm{Gpc}^{-3} \\mathrm{yr}^{-1}$ for \\ac{BNS}s. \n\n%\n% NSBH events\n%\nIn January of 2020, the \\ac{LVC} collaboration reported the \nfirst detection of two  \\ac{NSBH} events (GW200105,GW200115)~\\cite{Abbott_2021}\n. The primary component masses of both events are $\\sim 8.9 \\mathrm{M}_\\odot$ \nand $\\sim 5.7 \\mathrm{M}_\\odot$ respectively, whose mass values are both  \nabove the maximum allowed mass of a \\ac{NS} defined \nin ~\\cite{1974PhRvL..32..324R}, \nso may therefore be likely classified as \\ac{BH}s. The secondary masses \nof each event were given as $\\sim 1.5 \\mathrm{M}_\\odot$ and $\\sim 1.9 \\mathrm{M}_\\odot$ respectively and were reported to be within the range of \nknown \\ac{NS}s~\\cite{2016arXiv160501665A}.  \n\n%\n% Put this in context \n%\nAs improvements are made to the \\ac{LVC} detectors over the coming years, \nit is expected that the rate of detections will increase\ndramatically~\\cite{2018LRR....21....3A}. It is \npredicted that at design sensitivity, the \n\\ac{LVC} will observe $\\mathcal{O}(100s)$ of events \nper year~\\cite{2018LRR....21....3A}. Current \nmethods for both \\ac{GW} detection and parameter estimation, \nwhile optimal in many cases, are often computationally expensive~\\cite{}. \nAlgorithms which produce estimates on source parameter values of \n\\ac{GW} signals can take upwards of weeks to run (see Tab.~\\ref{tab:o3_events_runtime_1} and\nTab.~\\ref{tab:o3_events_runtime_2} in Ch.~\\ref{ch:chap_5}).\nGiven that follow-up observations of \\ac{GW} \\ac{EM} components \nheavily depend upon \\ac{GW} sky location alerts \nfrom the \\ac{LVC} and \nthe rapid decay of \\ac{GW} \\ac{EM} signatures~\\cite{2017arXiv171005833L}, \nthere is an urgent need for faster techniques which can not only \nidentify the presence of \\ac{GW} signals in detector data, \nbut also identify source parameter values like the sky location \nof a \\ac{GW} event. \n\n% \n% Transition to GR, GWs and the rest of the thesis\n%\n%All of these detections are built upon the foundations of \\ac{GR}, \n%\\ac{LVC} detector design/implementation, current \\ac{GW} search methods and \n%\\ac{GW} parameter estimation techniques. As outlined, these concepts were \n%discsussed in detail over the course of this chapter.  as well as motivate \n%the urgent need for the development of more efficient \n%search and parameter estimation algorithms. \n\n\\section{Summary}\n\nThe chapter opens \nby discussing the detections made by the \\ac{LVC} in the past 3 \nobservation runs and how those detections have been used to \nfurther our understanding of cosmology, astrophysics and \\ac{GW} astronomy.\nA brief introduction to Einstein's Field Equations and how those field equations lead to the prediction that \\ac{GW}s exist was provided. It was \nshown that various sources are able to produce \\ac{GW}s and it was described \nhow the \\ac{LVC} detectors physically operate to detect such signals. The \nsearch techniques for all source signals was described, along with a \ndescription on how predictions are generated on the \nunderlying source parameters of \\ac{GW} signals. From the descriptions \nof the search and parameter estimation techniques given in Sec.~\\ref{sec:matched_filtering} and Sec.\n~\\ref{sec:bayesian_inference} it was shown that while optimal under Gaussian-noise conditions, standard \napproaches used by the \\ac{LVC} are computationally expensive to \nrun. This is especially problematic given the large number of \nexpected signals the \\ac{LVC} will see in the coming years, with \nthe additional need of alerting \\ac{EM} partners in low-latency due \nto short-lived \\ac{GW} \\ac{EM} counterparts. Given the urgent need \nfor low-latency tools to perform both \\ac{GW} detection and \\ac{GW} \nparameter estimation, we will show in the subsequent chapters (Ch.~\\ref{ch:chap_4}, Ch.~\\ref{ch:chap_5}) how recent advances in  \nthe field of \\ac{ML} may be applied in order to solve these problems. \nIn the next chapter (Ch.~\\ref{ch:chap_2}), we will describe the basics \nof \\ac{ML}, as well as provide detailed descriptions of \nthe \\ac{ML} algorithms used in this thesis.", "meta": {"hexsha": "9ecc0da7eedf2e650f6fb9ce20ef063fb255c133", "size": 120178, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GW_background.tex", "max_stars_repo_name": "hagabbar/The-Thesis", "max_stars_repo_head_hexsha": "1d8ac7a7b51daedf5c3ef849872991963e5fae9f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "GW_background.tex", "max_issues_repo_name": "hagabbar/The-Thesis", "max_issues_repo_head_hexsha": "1d8ac7a7b51daedf5c3ef849872991963e5fae9f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "GW_background.tex", "max_forks_repo_name": "hagabbar/The-Thesis", "max_forks_repo_head_hexsha": "1d8ac7a7b51daedf5c3ef849872991963e5fae9f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.823199655, "max_line_length": 1196, "alphanum_fraction": 0.7571019654, "num_tokens": 32610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.44600228301604933}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amssymb} %maths\n\\usepackage{amsmath} %maths\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Homework 2}\n\\maketitle\n\\newpage\n\n\\section{Ross 4.15}\nFor this we first prove that $\\frac{1}{n}>0 \\forall n \\in \\N$. First we multiply both sides by $n$, since $n \\in \\N, n > 0$, the sign does not change.\n\\newline\nWe get $LHS = 1$ $RHS = 0$, since $1 > 0$ is an axiom, therefore we know that $1/n > 0$.\n\\newline\nNow since we have proven $\\frac{1}{n} \\geq 0 \\forall n \\in \\N$, by the ordered field axioms $a \\leq b$.\n\\newline\nQ.E.D.\n\\newpage\n\n\n\\section{Ross 4.16}\nLet the set in question be denoted by $S$. We will prove the claim via contradiction. We break its negative down into two cases: $\\sup S < a$ or $\\sup S > a$.\n\\newline\nFor the former, let $x = \\sup S | x \\in \\R$. By the denseness of rationals we see that there exists $q \\in \\Q s.t. x \\leq q \\leq a$. By the definition of this set we have $q \\in S$. Therefore we have just found a member of this set that is greater than the supremum. This is a contradiction so $x$ cannot be less than a.\n\\newline\nFor the latter, we once again let $x = \\sup S | x \\in \\R$. Consider $a$. $a<x$ and by definition of $S$, $\\forall s \\in S, s<a$. We have found an upperbound that is less than our supremum. That is a contradiction so $x$ cannot be greater than a.\n\\newline\n$\\sup S = a$ Q.E.D.\n\\newpage\n\n\\section{Ross 8.2}\n\\subsection{a}\nClaim: $a_n \\to 0$\n\\newline\nProof: $a_n = \\frac{n}{n^2+1} \\leq \\frac{n+1/n}{n^2+1} = \\frac{1}{n}$ ($n \\neq 0$)\n\\newline\nLet $\\epsilon > 0$, we select our $N = \\frac{1}{\\epsilon}$. $\\forall n>N, |a_n-0| < \\frac{1}{n} < \\epsilon$, thus the sequence converges.\n\n\\subsection{c}\nClaim: $c_n \\to \\frac{4}{7}$\n\\newline\nProof: $|c_n- \\frac{4}{7}| = |\\frac{28n+21}{49n-35} - \\frac{4(7n-5)}{49n-35}|$\n$$= \\frac{28n+21-28n+20}{49n-35}$$\n$$= \\frac{41}{49n-35} \\leq \\frac{41}{49n}$$\n\\newline\nLet  $\\epsilon > 0$, we select our $N = \\frac{41}{49\\epsilon}$. For all $n>N, |c_n- \\frac{4}{7}| \\leq \\frac{41}{49n} < \\epsilon$\n\n\\subsection{e}\nClaim: $s_n \\to 0$\n\\newline\nProof: $|s_n - 0| = |\\frac{1}{n}sin n| \\leq \\frac{1}{n}$.\n\\newline\nLet  $\\epsilon > 0$, we select our $N = \\frac{1}{\\epsilon}$. For all $n>N, |s_n-0| \\leq \\frac{1}{n} < \\epsilon$\n\\newpage\n\n\n\\section{Ross 8.5}\n\\subsection{a}\nLet $\\epsilon > 0$, since $a_n, b_n \\to s$, $|a_n-s|<\\epsilon \\forall n > N_1$ and $|b_n-s|<\\epsilon \\forall n > N_2$.\n\\newline\nLet $k> \\max \\{ N_1, N_2\\}$, $a_k \\leq s_k \\leq b_k$. We subtract s from the expression and we have: $a_k-s \\leq s_k -s \\leq b_k-s$. Furthermore $|a_k-s|<\\epsilon, |b_k - s| < \\epsilon$.\n\\newline\nSince $s_k-s$ is \"sandwiched\" between two expressions whose absolute values are less than epsilon, then $|s_k-s|<\\epsilon$.\n\\newline\n$s_n \\to 0$, Q.E.D.\n\n\\subsection{b}\nClaim: $lim s_n = 0$.\n\\newline\nProof:\nSince the absolute value s strictly non-negative, $t_n \\geq 0$. Let $\\epsilon>0$, since $\\lim t_n = 0$, $\\exists N s.t. \\forall k> N, t_k < \\epsilon$. Then consider the seqence $d_n = 0$. Obviously $\\lim d_n = 0$.\n\\newline\n$$0 = |d_k-0| \\leq |s_k| = |s_k - 0| \\leq t_k = |t_k - 0|$$\nTherefore $s_n$ converges to 0 by squeeze lemma.\n\\newpage\n\n\n\\section{Ross 8.7}\n\\subsection{a}\nAssume that this sequence $a_n$ converges, let $a_n \\to k$. By our assumption $\\exists N \\in \\R s.t. |a_n - k|<\\epsilon \\forall n > N$.\nSince this is a cosine function it is cyclical, we can see that it goes 1, 0.5, -0.5, -1, -0.5, 0.5, ..., repeating ad infinitum.\n\\newline\nLet $\\epsilon = 0.1$. Select $t > N, t \\bmod 6 \\equiv 0$. By the pattern we observed above, we know that $a_t = 0$. Furthermore, we know that $a_{t+1} = 0.5$. By the definition of convergence we have $|a_t-k|<\\epsilon$, $|a_{t+1}-k|< \\epsilon$, subsituting the values we have calculated we have $|0-k|<0.1, |0.5-k|<0.1, |0-k|+|0.5-k|\\leq 0.2$. However by the triangle property we know that $|0-k|+|0.5-k| \\leq 0.5$. This is a contradiction, therefore our assuption is not correct.\n\\newline\n$a_n$ does not converge. Q.E.D.\n\n\n\\subsection{b}\nFor this problem we simply need to show that the sequence is not bounded.\n\\newline\nAssume that the sequence is bounded, and that there is a supremum $k$. By the Archimedean Principle $\\exists n \\in N s.t. n>k$. Consider $s_n$ (if $n$ is odd consider $s_{n+1}$), this term is greater than $k$. Therefore we have found a member in the set that is greater than the supremum. $\\rightarrow \\leftarrow$\n\\newline\nThe sequence is not bounded, therefore $s_n$ cannot converge. Q.E.D.\n\n\n\\subsection{c}\nThe sequence here is very similar to that in section (a). The pattern is 0, 0.5, 1, 0.5, 0, -0.5, -1, -0.5, ... . We can let $\\epsilon = 0.1$ again and assume that it converges. So let $N \\in \\R s.t. |c_n - \\lim c_n| < \\epsilon \\forall n > N$. Pick $i > N s.t. i \\bmod 6 \\equiv 0$. From the pattern that we observed, $c_{n+1} = 0.5$. By the triangle inequality we see that $\\lim c_n$ cannot exist since we need the \"two sides\" (0.2) to be less than the other side (0.5).\n\\newline\nWe have found a contradiction, $c_n$ does not converge.\n\\newpage\n\n\n\\section{Ross 8.10}\nSince $\\lim s_n > a$, $\\lim s_n - a > 0$. Let this value be $d$.\n\\newline\nConsider $\\epsilon = d$. Since the sequence converges we have $\\exists N \\in R s.t. \\forall n > N, |s_n - \\lim s_n|<\\epsilon$. Since $\\epsilon = \\lim s_n - a$, we have\n$$|s_n - \\lim s_n| < \\lim s_n - a$$\nIf $s_n \\geq \\lim s_n$, $s_n > a$ because $\\lim s_n > a$.\n\\newline\nOtherwise, $s_n < \\lim s_n$. We can simplfy $|s_n - \\lim s_n| < \\lim s_n - a$ into $ \\lim s_n - s_n < \\lim s_n - a$, and by algebraic manipulation we have $s_n > a$.\n\\newline\nIn both cases $s_n > a$. Q.E.D.\n\\newpage\n\n\n\\section{Q7}\nClaim: $\\lim s_n = 1$\n\\newline\nLet $\\epsilon > 0$. Consider $a_n = 1$, $b_n = 1-\\frac{1}{n}$. Obviously $a_n$ converges to 1.\n\\newline\nFor $b_n$, let $N = \\frac{1}{\\epsilon}$. $\\forall k > N$, we have $|b_k - 1| = |1-\\frac{1}{k}-1| = |-\\frac{1}{k}| = \\frac{1}{k} < \\epsilon$. Therefore $b_n \\to 1$\n\\newline\nSince $\\frac{1}{n} > 0 \\forall n \\in \\N$, $(1-\\frac{1}{n})<1$, so $\\sqrt{(1-\\frac{1}{n})} > (1-\\frac{1}{n})$.\n\\newline\nWe have shown that $a_n \\to 1$, $b_n \\to 1$, and $b_n \\leq s_n \\leq a_n$. Therefore $s_n \\to 1$ by squeeze theorem.\n\\newline\nQ.E.D.\n\\end {document}\n", "meta": {"hexsha": "d4ae837539c46d9032d581a80a4a85990c0dedd3", "size": 6642, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw2/main.tex", "max_stars_repo_name": "TianshuangQiu/Math104-Homework", "max_stars_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw2/main.tex", "max_issues_repo_name": "TianshuangQiu/Math104-Homework", "max_issues_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw2/main.tex", "max_forks_repo_name": "TianshuangQiu/Math104-Homework", "max_forks_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7746478873, "max_line_length": 480, "alphanum_fraction": 0.650255947, "num_tokens": 2508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7879311981328135, "lm_q1q2_score": 0.4459836626024443}}
{"text": "\\chapter{Interpolation Convergence Proofs}\n\\label{chap:cvip_converge}\n\nThis chapter works through the convergence proofs for MSN interpolation on\nChebyshev nodes. We focus on interpolating up to degree $2n$.\n\n", "meta": {"hexsha": "266be117e7aba0b35acab038149ed429b68d79f6", "size": 209, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/vand_interp_conv.tex", "max_stars_repo_name": "chgorman/UCSB-Dissertation-Template", "max_stars_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/vand_interp_conv.tex", "max_issues_repo_name": "chgorman/UCSB-Dissertation-Template", "max_issues_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/vand_interp_conv.tex", "max_forks_repo_name": "chgorman/UCSB-Dissertation-Template", "max_forks_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8571428571, "max_line_length": 74, "alphanum_fraction": 0.8181818182, "num_tokens": 53, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4459836555557431}}
{"text": "\\section{Model Description}\nThe Basilisk IMU module imu\\_sensor.cpp is responsible for producing sensed body rates and acceleration from simulation truth values. It also provides a change in velocity and change in attitude value for the time between IMU calls. Each check within test\\_imu\\_sensor.py sets initial attitude MRP, body rates, and accumulated Delta V and validates output for a range of time.\n\nThere is a large variation throughout the industry as to what constitutes and IMU.  Some manufacturers offer IMUs which output only acceleration and angular rate while others include accumulated change in velocity in attitude. For Basilisk, the IMU is defined as a device which outputs all four values.\n\n\\subsection{Mathematical Model}\n\\subsubsection{Platform Frame and Sensor Labels}\nIt will be helpful to note for the following descriptions that the sensor is labeled with a capital S while the sensor platform frame is labeled with a capital P. To be more explicit, There is a coordinate frame, P, the platform frame, in which is the IMU is defined. In all cases so far, the IMU sits at the platform frame origin and its axes are aligned with the platform frame axes. So, any position or velocity vector describing the sensor also describes the platform frame origin. With that in mind, in this report, it has been attempted to track the kinematics of the sensor, while reporting values in the platform frame, rather than tracking the kinematics of the platform form.\n\n\\subsubsection{Frame Depedent Derivatives}\nInertial time derivatives are marked with a dot (i.e. $\\frac{\\mathcal{N}d}{dt}x = \\dot{x}$). Body frame time derivatives are marked with a prime (i.e. $\\frac{\\mathcal{B}d}{dt}x = x^\\prime$)\n\\subsubsection{Angular Rates}\nThe angular rate of the sensor in platform frame coordinates is output as:\n\\begin{equation}\n\t \\leftexp{P}{\\bm{\\omega}_{S/N}} =  \\leftexp{P}{\\bm{\\omega}_{P/N}} =[PB] \\leftexp{B}{\\bm{\\omega}_{B/N}}\n\\end{equation}\n\nWhere $\\cal{P}$ is the sensor platform frame, $\\cal{B}$ is the vehicle body frame, and $\\cal{N}$ is the inertial frame. [PB] is the direction cosine matrix from $\\cal{B}$ to $\\cal{P}$. This allows for an arbitrary angular offset between $\\cal{B}$ and $\\cal{P}$ and allows for that offset to be time-varying. $\\leftexp{B}{\\bm{\\omega}_{B/N}}$ is provided by the spacecraftPlus output message from the most recent dynamics integration.\n\n\\subsubsection{Angular Displacement}\nThe IMU also outputs the angular displacement accumulated between IMU calls. In order to avoid complexities having to do with the relative timestep between the dynamics process and the IMU calls, this is not calculated in the same way as an IMU works physically. In this way, also, the dynamics do not have to be run at a fast enough rate for a physical IMU angular accumulation to be simulated. \nThe modified Rodriguez parameter (MRP) is recorded for the last time (1) the IMU was called. Once the new MRP is received, both are converted to DCMs and the step-PRV is computed as follows The current MRP is always provided by the spacecraftPlus message from the most recent dynamics integration.\n\\begin{equation}\n\t[PN]_2 = [PB][BN]_2\n\\end{equation}\n\\begin{equation}\n\t[PN]_1 = [PB][BN]_1\n\\end{equation}\n\\begin{equation}\n\t[NP]_1 = [PN]_1^T\n\\end{equation}\n\\begin{equation}\n\t[P_2P_1] = [PN]_2[NP]_1\n\\end{equation}\n\\begin{equation}\n\\bm{q} = \\verb|C2PRV(|[P_2P_1]\\verb|)|\n\\end{equation}\nwhere $\\bm{q}$ above is the principal rotation vector for the sensor from timestep 1 to timestep 2. The functions used in conversion from the DCM to PRV are part of the Basilisk Rigid Body Kinematics library. The double conversion is used to avoid singularities.\n\n\\subsubsection{Linear Acceleration}\nThe sensor is assumed to have an arbitrary offset from the center of mass of the spacecraft. However, because of the completely coupled nature of the Basilisks dynamics framework, the center of mass does not need to be present explicitly in equations of motion for the sensor. It is implicit in the motion of the body frame. With that in mind, the equation for the acceleration of the sensor is derived below:\n\n\\begin{equation}\n\\bm{r}_{S/N} = \\bm{r}_{B/N} + \\bm{r}_{S/B}\n\\end{equation}\n\nUsing the transport theorem for $\\dot{\\bm{r}}_{S/B}$:\n\\begin{equation}\n\t\\dot{\\bm{r}}_{S/N} = \\dot{\\bm{r}}_{B/N} + \\bm{r}'_{S/B} + \\bm{\\omega}_{B/N} \\times \\bm{r}_{S/B}\n\t\\label{eq:rDot}\n\\end{equation}\n\nBut $\\bm{r}'_{S/B}$ is $0$ because the sensor is assumed to be fixed relative to the body frame. Then,\n\\begin{equation}\n\\ddot{\\bm{r}}_{S/N} = \\ddot{\\bm{r}}_{B/N} + \\dot{\\bm{\\omega}}_{B/N} \\times \\bm{r}_{S/B} +  \\bm{\\omega}_{B/N} \\times (\\bm{\\omega}_{B/N} \\times \\bm{r}_{S/B})\n\\end{equation}\nThe equation above is the equation for the inertial acceleration of the sensor, but the sensor will only measure the non-conservative accelerations. To account for this, the equation is modified to be:\n\\begin{equation}\n\\ddot{\\bm{r}}_{S/N, \\textrm{sensed}} = (\\ddot{\\bm{r}}_{B/N} - \\bm{a}_\\textrm{g}) + \\dot{\\bm{\\omega}}_{B/N} \\times \\bm{r}_{S/B} +  \\bm{\\omega}_{B/N} \\times (\\bm{\\omega}_{B/N} \\times \\bm{r}_{S/B})\n\\end{equation}\nwhere $\\bm{a}_\\textrm{g}$ is the instantaneous acceleration due to gravity. Conveniently, $(\\ddot{\\bm{r}}_{B/N} - \\bm{a}_\\textrm{g})$ is available from the spacecraft, but in the body frame. The acceleration provided, though, is the time-averaged acceleration between the last two dynamics integration calls and not the instantaneous acceleration. $\\bm{r}_{S/B}$ is also available in the body frame. $\\dot{\\bm{\\omega}}_{B/N}$ is given by the spacecraft in body frame coordinates as well. Again, this is a time-averaged value output by the spacecraft, rather than an instantaneous value. Because all values are given in the body frame, the above equation is calulated in the body frame and then converted as seen below:\n\\begin{equation}\n\t\\leftexp{P}{\\ddot{\\bm{r}}_{S/N, \\textrm{sensed}}} = [PB] \\leftexp{B}{ \\ddot{\\bm{r}}_{S/N, \\textrm{sensed}}}\n\\end{equation}\n\n\\subsubsection{Change In Velocity}\nThe IMU also outputs the velocity accumulated between IMU calls. In order to avoid complexities having to do with the relative time step between the dynamics process and the IMU calls, this is not calculated in the same way as an IMU works physically. In this way, also, the dynamics do not have to be run at a fast enough rate for a physical IMU velocity accumulation to be simulated.\n\nDifferencing Eq. \\ref{eq:rDot} with itself from time 1 to time 2 gives the equation:\n\\begin{equation}\n\t\\Delta_{2/1} \t\\dot{\\bm{r}}_{S/N} = \\Delta_{2/1} \\dot{\\bm{r}}_{B/N} + \\Delta_{2/1} (\\bm{\\omega}_{B/N} \\times \\bm{r}_{S/B})\n\t\\label{eq:DeltaVelocity}\n\\end{equation}\n$\\Delta_{2/1} \\dot{\\bm{r}}_{B/N}$ is calculated as the difference between the total change in velocity accumulated by the spacecraft body frame at time 2 minus the total change in velocity accumulated by the spacecraft body frame at time 1:\n\\begin{equation}\n\\Delta_{2/1} \\dot{\\bm{r}}_{B/N} = DV_{\\textrm{body\\_non-conservative},2} - DV_{\\textrm{body\\_non-conservative},1}\n\\end{equation}\nThe above $DV$ values are given by the spacecraft module in body frame coordinates but used in inertial coordinates. They are computed by accumulating the velocity after each dynamics integration and subtracting out the time-averaged gravitational acceleration multiplied by the dynamics time step. Then,\n\\begin{equation}\n\t\\Delta_{2/1} (\\bm{\\omega}_{B/N} \\times \\bm{r}_{S/B}) = \\bm{\\omega}_{{B/N}_2} \\times \\bm{r}_{{S/B}_2} - \\bm{\\omega}_{{B/N}_1} \\times \\bm{r}_{{S/B}_1}\n\\end{equation}\n$\\bm{\\omega}_{{B/N}}$ output by the spacecraft is the angular rate from the most recent dynamics integration. Again, the above equation is calculated in the inertial frame and then converted to platform frame coordinates. this means that the values given by spacecraft plus are first converted into inertial frame coordinates, including the location of the sensor in the body frame. At this point, Eq. \\ref{eq:DeltaVelocity} is evaluated in the body frame and converted to the sensor platform frame:\n\\begin{equation}\n\\leftexp{P} {\\Delta_{2/1}} \t\\dot{\\bm{r}}_{S/N} = [PN] ^{\\mathcal{N}} \\Delta_{2/1} \t\\dot{\\bm{r}}_{S/N}\n\\end{equation}\nThis, the change in velocity sensed by the IMU between IMU calls in platform frame coordinates, is the change in velocity output from the model. To be clear, this is the sensed inertial velocity change in platform frame coordinates. This makes the assumption that the IMU is tracking its attitude and performing the calculations internally to return this value correctly. It is not simply the integral of the acceleration value above in the body frame coordinates.\n\n\\subsubsection{Error Modeling}\nThe state which the simulation records for the spacecraft prior to sending that state to the IMU module is considered to be \"truth\". So, to simulate the errors found in real instrumentation, errors are added to the \"truth\" values for acceleration and angular velocity:\n\n\\begin{equation}\n\\mathbf{a}_{\\mathrm{measured}} = \\mathbf{a}_{\\mathrm{truth}} + \\mathbf{e}_{\\mathrm{a,noise}} + \\mathbf{e}_{\\mathrm{a, bias}}\n\\end{equation}\n\\begin{equation}\n\\bm{\\omega}_{\\mathrm{measured}} = \\bm{\\omega}_{\\mathrm{truth}} + \\mathbf{e}_{\\mathrm{\\omega,noise}} + \\mathbf{e}_{\\mathrm{\\omega, bias}}\n\\end{equation}\nThen, these error values are \"integrated\" over the IMU timestep and applied to the $\\Delta v$ and $PRV$ values:\n\\begin{equation}\n\\mathbf{DV}_{\\mathrm{measured}} = \\mathbf{DV}_{\\mathrm{truth}} + (\\mathbf{e}_{\\mathrm{a,noise}} + \\mathbf{e}_{\\mathrm{a, bias}})\\Delta t\n\\end{equation}\n\\begin{equation}\n\\mathbf{q}_{\\mathrm{measured}} = \\mathbf{q}_{\\mathrm{truth}} + (\\mathbf{e}_{\\mathrm{\\omega,noise}} + \\mathbf{e}_{\\mathrm{\\omega, bias}})\\Delta t\n\\end{equation}\nThis convenient approximation that $\\bm{q$} = $\\bm{\\omega}\\Delta t$ for a given timestep proves useful through the application of IMU errors.\n\n\n\\subsubsection{Data Discretization}\nBecause sensors record data digitally, that data can only be recorded in discrete chunks, rather than the (relatively) continuous values that the computer calculates at each time steps. In order to simulate real IMU behavior in this way, a least significant bit (LSB) value is accepted for both the gyro and the accelerometer. This LSB is applied in the following way:\n\n\\begin{equation}\n\\mathbf{a}_{\\mathrm{discretized}} = \\verb|sign|(\\mathbf{a}_\\mathrm{measured})(\\mathrm{LSB})\\Biggl\\lfloor\\Biggl|\\frac{\\mathbf{a}_{\\mathrm{measured}}}{(\\mathrm{LSB})}\\Biggr|\\Biggr\\rfloor\n\\end{equation}\n\\begin{equation}\n\\mathbf{e}_{\\mathrm{d},\\mathrm{a}} = \\mathbf{a}_{\\mathrm{measured}} - \\mathbf{a}_{\\mathrm{discretized}}\n\\end{equation}\n\\begin{equation}\n\\mathbf{DV}_{\\mathrm{discretized}} = \\mathbf{DV}_{\\mathrm{measured}} -\\mathbf{e}_{\\mathrm{d},\\mathrm{a}} \\Delta t\n\\end{equation}\n\n\\begin{equation}\n\\bm{\\omega}_{\\mathrm{discretized}} = \\verb|sign|(\\bm{\\bm{\\omega}_\\mathrm{measured}})(\\mathrm{LSB})\\Biggl\\lfloor\\Biggl|\\frac{\\bm{\\omega}_{\\mathrm{measured}}}{(\\mathrm{LSB})}\\Biggr|\\Biggr\\rfloor\n\\end{equation}\n\\begin{equation}\n\\mathbf{e}_{\\mathrm{d},\\omega} =\\bm{\\omega}_{\\mathrm{measured}} - \\bm{\\omega}_{\\mathrm{discretized}}\n\\end{equation}\n\\begin{equation}\n\\mathbf{q}_{\\mathrm{discretized}} = \\mathbf{q}_{\\mathrm{measured}} - \\mathbf{e}_{\\mathrm{d},\\mathrm{\\omega}}\\Delta t\n\\end{equation}\nWhere $\\lfloor$  $\\rfloor$ indicate the \\textbf{floor()} function and LSB can be either the accelerometer or gyro least significant bit as appropriate.\n\n\\subsubsection{Saturation}\nReal sensors can also become saturated. Saturation is the last effect implemented on the IMU, \\textit{in an elementwise manner}:\n\n\\begin{equation}\n\t\\bm{a}_{\\mathrm{sat}} = \\mathrm{max}\\big(a_{\\mathrm{min}}, \\mathrm{min}\\big(    \\bm{a}_{\\mathrm{discretized}}, a_{\\mathrm{max}}    \\big)   \\big)\n\\end{equation}\n\\begin{equation}\n\\bm{\\omega}_{\\mathrm{sat}} = \\mathrm{max}\\big(\\omega_{\\mathrm{min}}, \\mathrm{min}\\big(    \\bm{\\omega}_{\\mathrm{discretized}}, \\omega_{\\mathrm{max}}    \\big)   \\big)\n\\end{equation}\nThe above operations are performed element-wise. This is only computed if the values are found to be outside of the max-min range. Now, along each axis that was saturated:\n\n\\begin{equation}\n\tDV_{\\mathrm{sat},i} = a_{\\mathrm{sat},i} \\Delta t\n\\end{equation}\n\\begin{equation}\nq_{\\mathrm{sat},i} = \\omega_{\\mathrm{sat},i}  \\Delta t\n\\end{equation}\nThe above is calculated any time that $a_i$ or $\\omega_i$ are found to be outside of their max-min bounds. Note again the use of the approximation of the PRV as the integral of the angular rates.\n", "meta": {"hexsha": "63e0138393bd0cd7a3a802aa497371f323ada902", "size": 12501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/simulation/utilities/_Documentation/gaussMarkov/secModelDescription.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/simulation/utilities/_Documentation/gaussMarkov/secModelDescription.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/simulation/utilities/_Documentation/secModelDescription.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.8993288591, "max_line_length": 718, "alphanum_fraction": 0.7414606831, "num_tokens": 3626, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.445945790352128}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Written By Michael Brodskiy\n% Class: Analytic Geometry & Calculus III (Math-292)\n% Professor: V. Cherkassky\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass[12pt]{article} \n\\usepackage{alphalph}\n\\usepackage[utf8]{inputenc}\n\\usepackage[russian,english]{babel}\n\\usepackage{titling}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{enumitem}\n\\usepackage{amssymb}\n\\usepackage[super]{nth}\n\\usepackage{everysel}\n\\usepackage{ragged2e}\n\\usepackage{geometry}\n\\usepackage{fancyhdr}\n\\usepackage{cancel}\n\\geometry{top=1.0in,bottom=1.0in,left=1.0in,right=1.0in}\n\\newcommand{\\subtitle}[1]{%\n  \\posttitle{%\n    \\par\\end{center}\n    \\begin{center}\\large#1\\end{center}\n    \\vskip0.5em}%\n\n}\n\\usepackage{hyperref}\n\\hypersetup{\ncolorlinks=true,\nlinkcolor=blue,\nfilecolor=magenta,      \nurlcolor=blue,\ncitecolor=blue,\n}\n\n\\urlstyle{same}\n\n\n\\title{Calculus III Formula Sheet}\n\\date{\\today}\n\\author{Michael Brodskiy\\\\ \\small Professor: V. Cherkassky}\n\n% Mathematical Operations:\n\n% Sum: $$\\sum_{n=a}^{b} f(x) $$\n% Integral: $$\\int_{lower}^{upper} f(x) dx$$\n% Limit: $$\\lim_{x\\to\\infty} f(x)$$\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Chapter 12}\n\n\\subsection{Unit 1}\n\n\\begin{enumerate}\n\n  \\item The distance formula in three dimensions:\n    $$\\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$$\n\n  \\item A sphere with center $(h,k,l)$:\n    $$(x-h)^2+(y-k)^2+(z-l)^2=r^2$$\n\n\\end{enumerate}\n\n\\subsection{Unit 2}\n\n\\begin{enumerate}\n\\setcounter{enumi}{2}\n\n  \\item Vector given two points, $A=(x_1,y_1,z_1)$ and $B=(x_2,y_2,z_1)$\n    $$\\overrightarrow{v}=\\langle x_2-x_1, y_2-y_1, z_2-z_1\\rangle$$\n\n  \\item Magnitude of vector in:\n    \\begin{enumerate}\n\n      \\item Two dimensions ($a=\\langle a_1,a_2\\rangle)$:\n\n        $$|\\overrightarrow{a}|=\\sqrt{(a_1)^2+(a_2)^2}$$\n\n      \\item Three dimensions ($a=\\langle a_1,a_2,a_3\\rangle)$:\n\n        $$|\\overrightarrow{a}|=\\sqrt{(a_1)^2+(a_2)^2+(a_3)^2}$$\n\n    \\end{enumerate}\n\n  \\item Standard Basis Vectors:\n\n    $$\\bold{\\hat{i}}=\\langle 1,0,0\\rangle\\,\\,\\,\\,\\,\\,\\,\\bold{\\hat{j}}=\\langle0,1,0\\rangle\\,\\,\\,\\,\\,\\,\\,\\bold{\\hat{k}}=\\langle 0,0,1\\rangle$$\n\n  \\item Unit Vectors (Any vector with magnitude 1):\n    $$\\overrightarrow{u}_a=\\frac{\\overrightarrow{a}}{|\\overrightarrow{a}|}$$\n\n\\end{enumerate}\n\n\\subsection{Unit 3}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{5}\n\n  \\item Dot Product\\footnote{Two vectors are orthogonal (perpendicular) if $\\overrightarrow{a}\\cdot\\overrightarrow{b}=0$} (Also Known As Scalar Product):\n\n    $$\\overrightarrow{a}\\cdot\\overrightarrow{b}=a_1b_1+a_2b_2+a_3b_3$$\n\n  \\item Dot Product Angle Formula:\n    $$\\overrightarrow{a}\\cdot\\overrightarrow{b}=|\\overrightarrow{a}||\\overrightarrow{b}|\\cos\\theta$$\n\n  \\item Direction Angles:\\footnote{$\\alpha$ corresponds to the $x$ axis, $\\beta$ to the $y$ axis, and $\\gamma$ to the $z$ axis}\n    $$\\cos\\alpha=\\frac{\\overrightarrow{a}\\bold{\\hat{i}}}{|\\overrightarrow{a}|}$$\n    $$\\cos\\beta=\\frac{\\overrightarrow{a}\\bold{\\hat{j}}}{|\\overrightarrow{a}|}$$\n    $$\\cos\\gamma=\\frac{\\overrightarrow{a}\\bold{\\hat{k}}}{|\\overrightarrow{a}|}$$\n\n\\item Projections:\n\n  \\begin{enumerate}\n\n    \\item Scalar projection of $\\overrightarrow{b}$ onto $\\overrightarrow{a}$:\n      $$comp_{\\overrightarrow{a}}\\overrightarrow{b}=\\frac{\\overrightarrow{a}\\cdot\\overrightarrow{b}}{|\\overrightarrow{a}|}$$\n\n    \\item Vector projection of $\\overrightarrow{b}$ onto $\\overrightarrow{a}$:\n      $$proj_{\\overrightarrow{a}}\\overrightarrow{b}=\\left(\\frac{\\overrightarrow{a}\\cdot\\overrightarrow{b}}{|\\overrightarrow{a}|}\\right)\\frac{\\overrightarrow{a}}{|\\overrightarrow{a}|}$$\n  \\end{enumerate}\n\n\\end{enumerate}\n\n\\subsection{Unit 4}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{9}\n\n  \\item Cross Product:\\footnote{The vector created by $\\overrightarrow{a}\\text{ x }\\overrightarrow{b}$ is orthogonal to both $\\overrightarrow{a}$ and $\\overrightarrow{b}$}\n    $$\\overrightarrow{a}\\text{ x }\\overrightarrow{b}=\\begin{vmatrix} \\bold{\\hat{i}} & \\bold{\\hat{j}} & \\bold{\\hat{k}}\\\\ a_1 & a_2 & a_3\\\\ b_1 & b_2 & b_3\\\\ \\end{vmatrix}=\\langle a_2b_3-a_3b_2, a_3b_1-a_1b_3,a_1b_2-a_2b_1\\rangle$$\n\n  \\item Cross Product Angle Formula:\\footnote{If the cross product equals zero, the two vectors are parallel}\n    $$|\\overrightarrow{a}\\text{ x }\\overrightarrow{b}|=|\\overrightarrow{a}||\\overrightarrow{b}|\\sin\\theta$$\n\n  \\item Volume of the Parallelepiped created by vectors $\\overrightarrow{a}$, $\\overrightarrow{b}$, and $\\overrightarrow{c}$:\n    $$V=|\\overrightarrow{a}\\cdot(\\overrightarrow{b}\\text{ x }\\overrightarrow{c})|$$\n\n\\end{enumerate}\n\n\\subsection{Unit 5}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{12}\n\n  \\item Parametric line equations, given parallel vector $\\langle a,b,c \\rangle$, through point $(x_o,y_o,z_o)$:\n    $$x=x_o+at\\,\\,\\,\\,\\,y=y_o+bt\\,\\,\\,\\,\\,z=z_o+ct$$\n\n  \\item Symmetric Equations:\n\n    $$t=\\frac{x-x_o}{a}=\\frac{y-y_o}{b}=\\frac{z-z_o}{c}$$\n\n  \\item Equation of a plane:\n\n    $$a(x-x_o)+b(y-y_o)+c(z-z_o)=0$$\n\n  \\item Distance from plane to point $(x_1+y_1+z_1)$:\n    $$D=\\frac{|ax_1+by_1+cz_1+d|}{\\sqrt{a^2+b^2+c^2}}$$\n\\end{enumerate}\n\n\\subsection{Unit 6}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{16}\n\n  \\item Quadric Surface Formulas:\n    \\begin{center}\n\\begin{tabular}{|p{.45\\textwidth}||p{.45\\textwidth}|}\n\n\\hline\n  Figure & Equation \\\\\n\\hline\nEllipsoid: A Figure in Which All Traces are Ellipses & $\\frac{x^2}{a^2}+\\frac{y^2}{b^2}+\\frac{z^2}{c^2}=1$\\\\\n\\hline\n  Cone: A Figure in Which Horizontal Traces are Ellipses and Vertical Traces in $x$ and $y$ are Hyperbolas & $\\frac{x^2}{a^2}+\\frac{y^2}{b^2}=\\frac{z^2}{c^2}$\\\\\n\\hline\nElliptic Paraboloid: Horizontal Traces are Ellipses and Vertical Traces are Parabolas & $\\frac{x^2}{a^2}+\\frac{y^2}{b^2}=\\frac{z}{c}$\\\\ \n\\hline\nHyperboloid of One Sheet: Horizontal Traces are Ellipses and Vertical Traces are Hyperbolas & $\\frac{x^2}{a^2}+\\frac{y^2}{b^2}-\\frac{z^2}{c^2}=1$\\\\ \n\\hline\nHyperbolic Paraboloid: Horizontal Traces are Hyperbolas and Vertical Traces are Parabolas & $\\frac{x^2}{a^2}-\\frac{y^2}{b^2}=\\frac{z}{c}$\\\\\n\\hline\nHyperboloid of Two Sheets: Horizontal Traces are Ellipses in $z$ and Vertical Traces are Hyperbolas & $-\\frac{x^2}{a^2}-\\frac{y^2}{b^2}+\\frac{z^2}{c^2}=1$\\\\\n\\hline\n\n\\end{tabular}\n\\end{center}\n\\end{enumerate}\n\n\\section{Chapter 13}\n\n\\subsection{Unit 1}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{17}\n  \\item Limit of a vector function:\n    $$\\lim_{t\\to a}\\overrightarrow{r}(t)=\\langle \\lim_{t\\to a}x(t), \\lim_{t\\to a} y(t), \\lim_{t\\to a}z(t)\\rangle$$\n\\end{enumerate}\n\n\\subsection{Unit 2}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{18}\n\n  \\item Derivative of a vector function:\n    $$\\frac{d}{dt}[\\overrightarrow{r}(t)]=\\langle x'(t), y'(t), z'(t)\\rangle$$\n\n  \\item Derivative of cross and dot products:\n\n    \\begin{enumerate}\n\n      \\item Dot Product:\n        $$\\frac{d}{dt}[\\overrightarrow{u}(t)\\cdot\\overrightarrow{v}(t)]=\\overrightarrow{u}'(t)\\cdot\\overrightarrow{v}(t)+\\overrightarrow{u}(t)\\cdot\\overrightarrow{v}'(t)$$\n\n      \\item Cross Product:\n        $$\\frac{d}{dt}[\\overrightarrow{u}(t)\\text{ x }\\overrightarrow{v}(t)]=\\overrightarrow{u}'(t)\\text{ x }\\overrightarrow{v}(t)+\\overrightarrow{u}(t)\\text{ x }\\overrightarrow{v}'(t)$$\n\n    \\end{enumerate}\n\n  \\item Integral of a vector function:\n    $$\\int_a^b \\overrightarrow{r}(t)\\,dt=\\left(\\int_a^b x(t)\\,dt\\right)\\bold{\\hat{i}}+\\left(\\int_a^by(t)\\,dt\\right)\\bold{\\hat{j}}+\\left(\\int_a^bz(t)\\,dt\\right)\\bold{\\hat{k}}$$\n\\end{enumerate}\n\n\\subsection{Unit 3}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{21}\n\n  \\item Arc Length of a parametric vector function:\n        $$L=\\int_a^b\\sqrt{\\left(\\frac{dx}{dt}\\right)^2+\\left(\\frac{dy}{dt}\\right)^2+\\left(\\frac{dz}{dt}\\right)^2}\\,dt=\\int_a^b |\\overrightarrow{r}'(t)|\\,dt$$\n\n      \\item Unit Tangent Vector:\n        $$\\overrightarrow{T}(t)=\\frac{\\overrightarrow{r}'(t)}{|\\overrightarrow{r}'(t)|}$$\n\n      \\item Curvature:\n        \\begin{enumerate}\n\n          \\item Using the unit tangent vector:\n            $$\\kappa(t)=\\frac{|\\overrightarrow{T}'(t)|}{|\\overrightarrow{r}'(t)|}$$\n\n          \\item Using first and second order derivatives:\n            $$\\kappa(t)=\\frac{|\\overrightarrow{r}'(t)\\text{ x }\\overrightarrow{r}''(t)|}{|\\overrightarrow{r}'(t)|^3}$$\n\n          \\item For single variable functions:\n            $$\\kappa(x)=\\frac{|f''(x)|}{[1+(f'(x))^2]^{\\frac{3}{2}}}$$\n\n        \\end{enumerate}\n\n      \\item Unit Normal Vector:\n        $$\\overrightarrow{N}(t)=\\frac{\\overrightarrow{T}'(t)}{|\\overrightarrow{T}'(t)|}$$\n\n      \\item Binormal Vector:\n        $$\\overrightarrow{B}(t)=\\overrightarrow{T}(t)\\text{ x }\\overrightarrow{N}(t)$$\n    \\end{enumerate}\n\n\\subsection{Unit 4}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{26}\n\n  \\item Velocity:\n    $$\\overrightarrow{v}(t)=\\overrightarrow{r}'(t)$$\n\n  \\item Speed:\n    $$|\\overrightarrow{v}(t)|=|\\overrightarrow{r}'(t)|$$\n\n  \\item Acceleration:\n    $$\\overrightarrow{a}(t)=\\overrightarrow{v}'(t)=\\overrightarrow{r}''(t)$$\n\\end{enumerate}\n\n\\section{Chapter 14}\n\n\\subsection{Unit 1}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{29}\n\n  \\item Level curves are used to demonstrate the height of a function, by drawing a line where $f(x,y,z)=k$, where $k$ is any constant in the domain of $f$\n\\end{enumerate}\n  \n\\subsection{Unit 2}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{30}\n\n  \\item To evaluate a multivariable limit, one must evaluate it along different paths:\n    \\textit{Example}\n    $$\\lim_{(x,y)\\to(0,0)}\\frac{x}{y}$$\n      Evaluate along $y=mx$, which is any line through the origin\n      $$\\lim_{(x,y)\\to(0,0)}\\frac{\\cancel{x}}{m\\cancel{x}}\\Rightarrow\\frac{1}{m}$$\n      Therefore, this limit does not exist because, for different slopes, the value is different\n\n\\end{enumerate}\n\n\\subsection{Unit 3}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{31}\n\n  \\item To find a partial derivative, hold all variables aside from the one being differentiated with respect to to find a partial derivative.\n\n\\end{enumerate}\n\n\\subsection{Unit 4}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{32}\n\n  \\item If $f$ has continuous partial derivatives, the following equation may be used to find a tangent plane:\n    $$z-z_o=f_x(x_o,y_o)(x-x_o)+f_y(x_o,y_o)(y-y_o)$$\n\n  \\item Total differential:\n    $$dz=\\frac{\\partial z}{\\partial x}dx+\\frac{\\partial z}{\\partial y}dy$$\n    Or, with a multivariable function:\n    $$df=\\frac{\\partial f}{\\partial x}dx+\\frac{\\partial f}{\\partial y}dy+\\frac{\\partial f}{\\partial z}dz$$\n\n\\end{enumerate}\n\n\\subsection{Unit 5}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{34}\n\n  \\item The Chain Rule (Where $x$ and $y$ are differentiable functions of $t$, $x(t)$ and $y(t)$ and $z=f(x(t),y(t)$):\n    $$\\frac{dz}{dt}=\\frac{\\partial f}{\\partial x}\\frac{dx}{dt}+\\frac{\\partial f}{\\partial y}\\frac{dy}{dt}$$\n\n  \\item The Chain Rule (Where $x$ and $y$ are differentiable functions of $(s,t)$, $x(s,t)$, and $y(s,t)$ and $z=f(x(s,t),y(s,t))$:\n      $$\\frac{\\partial z}{\\partial s}=\\frac{\\partial z}{\\partial x}\\frac{\\partial x}{\\partial s}+\\frac{\\partial z}{\\partial y}\\frac{\\partial y}{\\partial s}\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\frac{\\partial z}{\\partial t}=\\frac{\\partial z}{\\partial x}\\frac{\\partial x}{\\partial t}+\\frac{\\partial z}{\\partial y}\\frac{\\partial y}{\\partial t}$$\n\n    \\item Implicit differentiation:\n      $$\\frac{dy}{dx}=-\\frac{\\frac{\\partial F}{\\partial x}}{\\frac{\\partial F}{\\partial y}}=-\\frac{F_x}{F_y}$$\n\n    \\item Implicit Function Theorem:\n      $$\\frac{\\partial z}{\\partial x}=-\\frac{\\frac{\\partial F}{\\partial x}}{\\frac{\\partial F}{\\partial z}}\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\frac{\\partial z}{\\partial y}=-\\frac{\\frac{\\partial F}{\\partial y}}{\\frac{\\partial F}{\\partial z}}$$\n\n\\end{enumerate}\n\n\\subsection{Unit 6}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{38}\n\n  \\item Directional derivative of function $f(x,y)$ in the direction of unit vector $u=\\langle a,b \\rangle$:\n    $$D_uf(x,y)=f_x(x,y)a+f_y(x,y)b$$\n    Or, in three dimensions:\n    $$D_uf(x,y,z)=f_x(x,y,z)a+f_y(x,y,z)b+f_z(x,y,z)c$$\n\n  \\item Gradient Vector:\n    $$\\nabla f(x,y) = \\langle f_x(x,y),f_y(x,y) \\rangle=\\frac{\\partial f}{\\partial x}\\bold{\\hat{i}}+\\frac{\\partial f}{\\partial y}\\bold{\\hat{j}}$$\n    Or, in three dimensions:\n    $$\\nabla f(x,y,z) = \\langle f_x(x,y),f_y(x,y) \\rangle=\\frac{\\partial f}{\\partial x}\\bold{\\hat{i}}+\\frac{\\partial f}{\\partial y}\\bold{\\hat{j}}+\\frac{\\partial f}{\\partial z}\\bold{\\hat{k}}$$\n\n  \\item Tangent Multivariable Planes:\n    $$F_x(x_o,y_o,z_o)(x-x_o)+F_y(x_o,y_o,z_o)(y-y_o)+F_z(x_o,y_o,z_o)(z-z_o)=0$$\n\n\n\\end{enumerate}\n\n\\subsection{Unit 7}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{41}\n\n  \\item Second Derivative Test:\n    $$D(a,b)=f_{xx}(a,b)f_{yy}(a,b)-[f_{xy}(a,b)]^2$$\n    \\begin{enumerate}\n\n      \\item If $D > 0$ and $f_{xx}(a,b) > 0$, then $f(a,b)$ is a local minimum\n      \\item If $D > 0$ and $f_{xx}(a,b) < 0$, then $f(a,b)$ is a local maximum\n      \\item If $D < 0$, then $f(a,b)$ is not a local maximum or minimum\n\n    \\end{enumerate}\n\n\\end{enumerate}\n\n\\section{Chapter 15}\n\n\\subsection{Unit 1}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{42}\n\n  \\item Double Integral over Rectangles:\n    Given rectangle $R=\\{(x,y)\\big| a\\leq x\\leq b, c\\leq y\\leq d\\}$\n    The double integral of the function $f(x,y)$ is:\n    $$\\iint_R f(x,y)\\,dA=\\int_a^b\\int_c^df(x,y)\\,dy\\,dx$$\n    This yields the volume of the shape under the function $f(x,y)$ and above rectangle, $R$\n\n  \\item Midpoint Rule for Double integrals:\n    $$\\int_R f(x,y)\\,dA\\approx\\sum_{i=1}^m\\sum_{j=1}^nf(\\bar{x}_i,\\bar{y}_i)\\,\\Delta A$$\n\n\\end{enumerate}\n\n\\subsection{Unit 2}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{44}\n\n  \\item Type I Region ($D=\\{(x,y)\\big|a\\leq x\\leq b, g_1(x)\\leq y\\leq g_2(x)$):\n      $$\\int_a^b\\int_{g_1(x)}^{g_2(x)}f(x,y)\\,dy\\,dx$$\n\n    \\item Type II Region ($D=\\{(x,y)\\big|h_1(y)\\leq x\\leq h_2(y), c \\leq y\\leq d$):\n      $$\\int_c^d\\int_{h_1(y)}^{h_2(y)}f(x,y)\\,dx\\,dy$$\n\n\\end{enumerate}\n\n\\subsection{Unit 3}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{46}\n\n  \\item Change to Polar Coordinates:\n    $$\\int_{\\alpha}^{\\beta}\\int_a^b f(r\\cos\\theta,r\\sin\\theta)r\\,dr\\,d\\theta$$\n\n  \\item Polar bounded by function(s) ($D=\\{(r,\\theta)\\big|\\alpha\\leq\\theta\\leq\\beta, h_1(\\theta)\\leq r\\leq h_2(\\theta)\\}$):\n    $$\\int_{\\alpha}^{\\beta}\\int_{h_1(\\theta)}^{h_2(\\theta)} f(r\\cos\\theta,r\\sin\\theta)r\\,dr\\,d\\theta$$\n\n\\end{enumerate}\n\n\\subsection{Unit 4}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{48}\n\n  \\item Mass from density function:\n    $$m=\\iint_D \\rho(x,y)\\,dA$$\n\n  \\item Moment about the:\n\n    \\begin{enumerate}\n\n      \\item $x$ axis:\n        $$M_x=\\iint_D y\\rho(x,y)\\,dA$$\n\n      \\item $y$ axis:\n        $$M_y=\\iint_D x\\rho(x,y)\\,dA$$\n\n    \\end{enumerate}\n\n  \\item Center of mass:\n\n    $$\\bar{x}=\\frac{M_y}{m}\\,\\,\\,\\,\\,\\,\\,\\,\\,\\,\\bar{y}=\\frac{M_x}{m}$$\n\n  \\item Moment of Inertia about the:\n\n    \\begin{enumerate}\n\n      \\item $x$ axis:\n        $$I_x=\\iint_D y^2\\rho(x,y)\\,dA$$\n\n      \\item $y$ axis:\n        $$I_y=\\iint_D x^2\\rho(x,y)\\,dA$$\n\n      \\item Origin (Polar):\n        $$I_o=\\iint_D (x^2+y^2)\\rho(x,y)\\,dA$$\n\n    \\end{enumerate}\n\n\\end{enumerate}\n\n\\subsection{Unit 5}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{52}\n\n  \\item Surface Area:\n    $$\\iint_D \\sqrt{[f_x(x,y)]^2+[f_y(x,y)]^2+1}\\,dA$$\n\n\\end{enumerate}\n\n\\subsection{Unit 6}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{53}\n\n  \\item Triple Integral on Box ($B=\\{(x,y,z)\\big|a\\leq x\\leq b, c\\leq y\\leq d, r\\leq z\\leq s\\}$):\n    $$\\int_a^b\\int_c^d\\int_r^sf(x,y,z)\\,dx\\,dy\\,dz$$\n\n  \\item Type I $E$ ($E=\\{(x,y,z)\\big|(x,y)\\in D, u_1(x,y)\\leq z\\leq u_2(x,y)\\}$): \n    $$\\iint_D \\left[\\int_{u_1(x,y)}^{u_2(x,y)}f(x,y,z)\\,dz\\right]\\,dA$$\n\n  \\item Type I $D$ and $E$ ($E=\\{(x,y,z)\\big| a\\leq x\\leq b, g_1(x)\\leq y\\leq g_2(x), u_1(x,y)\\leq z\\leq u_2(x,y)\\}$): \n    $$\\int_a^b\\int_{g_1(x)}^{g_2(x)}\\int_{u_1(x,y)}^{u_2(x,y)}f(x,y,z)\\,dz\\,dy\\,dx$$\n\n  \\item Type II $D$ and Type I $E$ ($E=\\{(x,y,z)\\big| h_1(y)\\leq x\\leq h_2(y), c\\leq y\\leq d, u_1(x,y)\\leq z\\leq u_2(x,y)\\}$): \n    $$\\int_c^d\\int_{h_1(y)}^{h_2(y)}\\int_{u_1(x,y)}^{u_2(x,y)}f(x,y,z)\\,dz\\,dx\\,dy$$\n\n  \\item Type II $E$ ($E=\\{(x,y,z)\\big|u_1(y,z)\\leq x\\leq u_2(y,z), c\\leq y\\leq d,r\\leq z\\leq s\\}$)\n    $$\\iint_D \\left[\\int_{u_1(y,z)}^{u_2(y,z)} f(x,y,z)\\,dx\\right]\\,dA$$\n\n  \\item Type III $E$ ($E=\\{(x,y,z)\\big|a\\leq x\\leq b, u_1(x,z)\\leq y\\leq u_2(x,z), r\\leq z\\leq s\\}$)\n    $$\\iint_D\\left[\\int_{u_1(x,z)}^{u_2(x,z)}f(x,y,z)\\,dy\\right]\\,dA$$\n\n\\end{enumerate}\n\n\\subsection{Unit 7 (Skip)}\n\n\\subsection{Unit 8 (Skip)}\n\n\\subsection{Unit 9}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{59}\n\n  \\item The Jacobian Transformation:\n    $$J=\\Large{\\begin{vmatrix} \\frac{\\partial x}{\\partial u} & \\frac{\\partial x}{\\partial v} \\\\ \\frac{\\partial y}{\\partial u} & \\frac{\\partial y}{\\partial v} \\\\ \\end{vmatrix}}=\\frac{\\partial x}{\\partial u}\\frac{\\partial y}{\\partial v}-\\frac{\\partial x}{\\partial v}\\frac{\\partial y}{\\partial u}$$\n\n  \\item Change of Variables in Double Integrals\n    $$\\iint_S f(x(u,v),y(u,v)) J\\,du\\,dv$$\n\n\\end{enumerate}\n\n\\section{Chapter 16}\n\n\\subsection{Unit 1}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{61}\n\n  \\item Gradient vector fields:\n    $$\\nabla f(x,y,z)=f_x(x,y,z)\\bold{\\hat{i}}+f_y(x,y,z)\\bold{\\hat{j}}+f_z(x,y,z)\\bold{\\hat{k}}$$\n\n\\end{enumerate}\n\n\\subsection{Unit 2}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{62}\n\n  \\item Line Integrals:\n    $$\\int_C f(x,y,z)\\,ds=\\int_C f(x,y,z)\\sqrt{\\left(\\frac{\\partial f}{\\partial x}\\right)^2+\\left(\\frac{\\partial f}{\\partial y}\\right)^2+\\left(\\frac{\\partial f}{\\partial z}\\right)^2}\\,dt$$\n\n\\end{enumerate}\n\n\\subsection{Unit 3}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{63}\n\n  \\item Fundamental Theorem of Line Integrals\n    $$\\int_C \\bold{F}\\,d\\bold{r}=\\int_C \\nabla f\\,d\\bold{r}=f(\\bold{r}(b))-f(\\bold{r}(a))$$\n\n  \\item Conservative Vector Field If:\n    $$\\frac{\\partial P}{\\partial y}=\\frac{\\partial Q}{\\partial x}$$\n\n\\end{enumerate}\n\n\\subsection{Unit 4}\n\n\\begin{enumerate}\n    \\setcounter{enumi}{65}\n\n  \\item Green's Theorem:\n    $$\\int_C P\\,dx+Q\\,dy=\\iint_D \\left(\\frac{\\partial Q}{\\partial x} - \\frac{\\partial P}{\\partial y}\\right)\\,dA$$\n\n\\end{enumerate}\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "73628158969d48a733a249c0d5ecc3e3a0756a3d", "size": 18182, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Other/FormulaCheatSheet.tex", "max_stars_repo_name": "MDBrodskiy/Vector_Calculus", "max_stars_repo_head_hexsha": "d4820f31c0c585ae65e6d61249d8c725077005eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-15T15:51:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-15T15:51:52.000Z", "max_issues_repo_path": "Other/FormulaCheatSheet.tex", "max_issues_repo_name": "MDBrodskiy/Vector_Calculus", "max_issues_repo_head_hexsha": "d4820f31c0c585ae65e6d61249d8c725077005eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Other/FormulaCheatSheet.tex", "max_forks_repo_name": "MDBrodskiy/Vector_Calculus", "max_forks_repo_head_hexsha": "d4820f31c0c585ae65e6d61249d8c725077005eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0670194004, "max_line_length": 344, "alphanum_fraction": 0.6181938181, "num_tokens": 6630, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.4459457880633389}}
{"text": "%%%%%%%%%%%%%%%%%%%%%definitions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\input{../../doc/related_pages/header.tex}\n\\input{../../doc/related_pages/newcommands.tex}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DOCUMENT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\n\\title{\nThe full-F electromagnetic model in toroidal geometry \\textsc{Feltor}}\n\\author{ M.~Wiesenberger and M.~Held}\n\\maketitle\n\n\\begin{abstract}\nThe purpose of this document is to describe the programs\n\\texttt{feltor\\_hpc.cu, feltor.cu, feltor\\_diag.cu} and to an extend\n\\texttt{geometry\\_diag.cu}. The goal is to provide\ninformation such that a user can avoid to look\ninto the actual codes on the one side and connect\nthe presented formulas to relevant journal publications on the other.\n\nThe program \\texttt{feltor/inc/geometries/geometry\\_diag.cu}\nanalyses the magnetic field geometry.\n\\texttt{feltor\\_hpc.cu} and \\texttt{feltor.cu} are programs for global 3d isothermal electromagnetic full-F gyro-fluid simulations.\n\\texttt{feltor/diag/feltor\\_diag.cu} is a program to analyse the output\nfile(s) of \\texttt{feltor\\_hpc.cu}.\n\n\\end{abstract}\n\\tableofcontents\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{The magnetic field}\\label{sec:magnetic}\nWe assume a three-dimensional flat space with arbitrary coordinate\nsystem $\\vec x :=\\{x_0, x_1, x_2\\}$, metric\ntensor $g_{ij}$ and volume element $\\sqrt{g} := \\sqrt{\\det g}$.\nGiven a vector field $\\vec B(\\vec x)$ with unit vector $\\bhat(\\vec x) := (\\vec B/B)({\\vec x})$\nwe can define various differential operations.\n\\begin{table*}[htbp]\n\\caption{Definitions of geometric operators with $b^i$ the contra-variant components of $\\bhat$ and $g^{ij}$ the contra-variant elements of the metric tensor. We assume $(\\vn\\times\\bhat)_\\parallel = 0$. Note that $\\vec K = \\vec K_\\kappa + \\vec{ K_{\\vn B}}$.\n% Explicit expressions of these quantities\n% depend on the choice of the magnetic field and the underlying coordinate system.\n}\\label{tab:operators}\n\\centering\n\\rowcolors{2}{gray!25}{white}\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n%\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Symbol} & \\textbf{Definition} \\\\\n\\midrule\n    Perpendicular Poisson bracket&\n    $\\left[.,.\\right]_\\perp$ &\n    $\\left[f,g\\right]_\\perp := \\bhat \\cdot \\left(\\vec{\\vn} f \\times\\vn g\\right) =\n    b_i \\varepsilon^{ijk}\\partial_j f\\partial_k g/\\sqrt{g}$  \\\\\n    Projection Tensor&\n    $h $ & $h^{ij} := g^{ij} - b^ib^j $   \\quad \\text{ Note }$ h^2=h$\\\\\n    %Alignment Tensor&\n    %$t $ & $ t^{ij} := b^ib^j$\\\\\n    Perpendicular Gradient&\n    $\\np $&\n    $ \\np f := \\bhat\\times(\\vn f\\times \\bhat ) \\equiv\n    h \\cdot \\vn f$ \\\\\n    Perpendicular Divergence&\n    $\\np^\\dagger $&\n    $ \\np^\\dagger \\cdot \\vec v := -\\nc( h \\cdot \\vec v) = -\\nc\\vec v_\\perp$ \\\\\n    Perpendicular Laplacian &\n    $\\Delta_\\perp $ &\n    $ \\Delta_\\perp f:= \\nc (\\np f)\n    = \\nc( h\\cdot\\vn f) \\equiv -\\np^\\dagger\\cdot\\np$  \\\\\n    Curl-b Curvature Operator&\n    $\\mathcal K_{\\vn\\times\\bhat}$ &\n    $\\mathcal K_{\\vn\\times\\bhat}(f) := \\vec{ K_{\\vn\\times\\bhat} }\\cn f = \\frac{1}{B}(\\vn \\times \\bhat)\\cn f$ \\\\[4pt]\n    Grad-B Curvature Operator &\n    $\\mathcal K_{\\vn B} $ &\n    $\\mathcal K_{\\vn B}(f) := \\vec{ K_{\\vn B}} \\cn f = \\frac{1}{B}(\\bhat \\times\\vn \\ln B)\\cn f$ \\\\[4pt]\n    Curvature Operator&\n    $\\mathcal K$ &\n    $\\mathcal{K}(f):=\\vec{ K} \\cn f =\n     \\vec{\\vn}\\cdot\\left(\\frac{\\bhat\\times\\vec{\\vn} f}{B}\\right) =\\vn \\times \\frac{\\bhat}{B} \\cn f$,\\\\[4pt]\n    Parallel derivative&\n    $\\npar $&\n    $ \\npar f := \\bhat\\cdot\\vn f$ \\quad  Notice $\\nc\\bhat = -\\npar\\ln B$ \\\\\n     Parallel Laplacian&\n     $\\Delta_\\parallel $&\n     $\\Delta_\\parallel f:= \\vec{\\vn} \\cdot ( \\bhat\\bhat\\cdot\\vec{\\vn} f )$\\\\\n\\bottomrule\n\\end{longtable}\n\\end{table*}\nwith $b^i$ the contra- and $b_i$ the co-variant components of $\\bhat$, and\n$\\eps^{ijk}$ the Levi-Civita symbols.\nExplicit expressions for the above expressions\ndepend on the choice of the magnetic field and the underlying coordinate system.\nNote that we have\n\\begin{align}\n    \\nc \\vec{ K_{\\vn\\times\\bhat}}\n&= -\\nc \\vec{ K_{\\vn B}} = -\\vec{K_{\\vn\\times\\bhat}}\\cn\\ln B, \\\\\n    \\vec\\nc\\vec{ K} &= 0, \\\\\n    \\mathcal K(f) &=\n     \\vn\\times\\frac{\\bhat}{B}\\cn f\n    = \\mathcal K_{\\vn\\times\\bhat}(f) + \\mathcal K_{\\vn B}(f),\\\\\n    \\vec{ K_{\\vn\\times\\bhat}} - \\vec{ K_{\\vn B}} &= \\frac{1}{B^2} (\\vn \\times \\vec B), \\\\\n    \\npar \\ln B &= -\\vec\\nc\\bhat.\n    \\label{eq:curl_curvature}\n\\end{align}\nThe last equality holds if $\\vec\\nc \\vec B = 0$.\nNote that in any arbitrary coordinate system we have\n\\begin{align}\n(\\vn f)^i = g^{ij}\\partial_j f ~, \\quad\n\\nc \\vec v = \\frac{1}{\\sqrt{g}}\\partial_i \\left(\\sqrt{g} v^i\\right) ~, \\quad\n(\\vec v \\times \\vec w)^i = \\frac{1}{\\sqrt{g}}\\varepsilon^{ijk} v_jw_k ~.\n%\\label{}\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Coordinate system}\\label{sec:cylmetric}\nWe employ cylindrical coordinates \\( (R,Z,\\varphi) \\), with \\(\\varphi\\) anti directed to the geometric toroidal angle ({\\bf clockwise} if viewed from above) to\nobtain a right handed system. The parametric representation in Cartesian \\((x,y,z)\\) coordinates is therefore simply:\n\\begin{align}\n x &= R \\hspace{1 mm} \\sin{(\\varphi)}, &\n y &= R \\hspace{1 mm} \\cos{(\\varphi)}, &\n z &= Z .\n\\end{align}\nNote here that the angle $\\varphi = 0$ corresponds to the Cartesian $y$-axis.\nThe unit\nbasis vectors and (covariant) metric tensor are:\n\\begin{align}\n \\ehat_R      &= (\\sin{(\\varphi)} ,   \\cos{(\\varphi)},0)^T, &\n \\ehat_Z      &= ( 0 ,0 ,1 )^T, &\n \\ehat_{\\varphi} &= ( \\cos{(\\varphi)} , -\\sin{(\\varphi)} , 0 )^T,\n\\\\\n    (g_{ij}) &= \\begin{pmatrix}\n  1 & 0 & 0 \\\\\n  0 & 1 & 0 \\\\\n  0 & 0 & R^2\n   \\end{pmatrix}\n% \\vn R &= (\\sin{(\\varphi)} ,   \\cos{(\\varphi)},0 )^T , &\n%  \\vnZ &= ( 0 ,0 ,1 )^T,  &\n%  \\vn{\\varphi} &= \\frac{1}{R} ( \\cos{(\\varphi)} , -\\sin{(\\varphi)} , 0 )^T .\n\\end{align}\nWith the help of the metric elements we get a well behaved volume element \\(\\sqrt{g} = R\\). However, we have a coordinate singularity at \\(R=0\\).\nThe cylindrical coordinate basis vectors are mutually orthogonal to each other.\n\n\\subsection{The flux function}\nIn cylindrical coordinates the general axisymmetric  magnetic field can be written as (dimensionless)\n\\begin{align}\n \\vec{B} &= \\frac{R_0}{R}\\left[I(\\psi_p) \\ehat_{\\varphi} + \\frac{\\partial\n \\psi_p}{\\partial Z} \\ehat_R -  \\frac{\\partial \\psi_p}{\\partial R} \\ehat_Z\\right] ,\n\\end{align}\nwhich can obviously not be manipulated to be in Clebsch form.\nHence we are dealing with a non-flux aligned coordinate system.\nFor the sake of clarity we define the poloidal magnetic field \\( \\vec{B}_p = \\frac{R_0}{R}\\left( \\frac{\\partial \\psi_p}{\\partial Z}\\ehat_R - \\frac{\\partial \\psi_p}{\\partial R}\\ehat_Z\\right)\n\\) and the toroidal magnetic field \\(\\vec{B}_t =\\frac{R_0I}{R} \\ehat_{\\varphi}\\).\n\\begin{tcolorbox}[title=Note]\nWith a typically convex function $\\psi_p$ (second derivative is\npositive), $I(\\psi_p)>0$ and the previously defined coordinate system the field\nline winding is a {\\bf left handed screw} in the positive $\\ehat_\\varphi$-direction.\nAlso note that then $\\vec B\\times\\vn\\vec B$ points {\\bf down}, towards the magnetic X-point,\nand we have the {\\bf favourable} drift direction (in experiments H-mode\nis reached easier in this configuration).\n\\end{tcolorbox}\n\n\nWe scaled $R$, $Z$ and $R_0$ with $\\rho_s = \\sqrt{T_e m_i}/(eB_0)$, the\nmagnetic field with $B_0$, the poloidal flux with $\\psi_{p0} = B_0\\rho_s \\hat\nR_0$ and the poloidal equilibrium current streamfunction with $I_0 = B_0 \\hat R_0$ (with $\\hat R_0 =\n\\rho_s R_0$ the dimensional major radius).\n\\subsubsection{Solov'ev equilbrium}\\label{sec:solovev}\n\nWe have the equilibrium equations in toroidally symmetric, ideal MHD\n$\\vn p = \\vec j\\times \\vec B$ and $\\vn\\times\\vec B = \\beta \\vec j$ normalized with $p_0 = n_0 T_0$, and $j_0 = e n_0 c_S$, where we introduce $\\beta = n_0 T_0 \\mu_0 /B_0^2$.\nNote that this normalization is in line with the one later chosen for the gyrofluid\nequations but is unnatural for the MHD type equilibrium equations through the introduction\nof $\\rho_s$ and $\\beta$.\n\\begin{align}\n    \\vn\\times \\vec B &= \\frac{R_0}{R}\\left[ -\\Delta^*\\psi_p\\ehat_\\varphi + I_Z \\ehat_R - I_R\\ehat_Z \\right]\\equiv \\beta \\vec j\\\\\n \\beta j_\\parallel &= \\beta \\vec j\\cdot \\bhat = \\beta \\frac{\\d p}{\\d\\psi_p} \\frac{I(\\psi_p)}{B} +\n \\frac{\\d I}{\\d\\psi_p} B \\quad \\text{  Pfirsch-Schl\\\"uter \\& Bootstrap current } \\\\\n \\beta \\vec j_\\perp &= \\beta \\bhat\\times\\left(\\vec j\\times\\bhat\\right)=\n \\beta \\frac{\\bhat \\times \\vn p}{B} \\quad\\quad\\quad \\text{ diamagnetic current} \\\\\n \\beta \\vec j\\times\\vec B &= \\frac{R_0^2}{R^2}\\left[ -\\Delta^* \\psi_p - I\n     \\frac{\\d I}{\\d \\psi_p} \\right]\\vn\\psi_p \\equiv \\beta \\frac{\\d p}{\\d\\psi_p}\\vn\\psi_p =\\beta \\vn p\n\\end{align}\nfrom where we recover the Grad-Shafranov equation\n\\begin{align}\\label{eq:GSEdimless}\n    -\\Delta^*_\\perp  \\psi_p &= \\beta \\frac{R^2}{R_0^2} \\frac{d p}{d  \\psi_p } + I \\frac{d I}{d  \\psi_p } \\equiv \\beta \\frac{R}{R_0} j_{\\hat\\varphi}\n\\end{align}\nwith $\\Delta^*_\\perp \\psi_p = R\\partial_R (R^{-1}\\psi_R) + \\psi_{ZZ}$.\nThe Solov'ev assumptions consist of \\(A/R_0 = -I \\frac{d I}{d  \\psi_p }\\) and \\((1-A)/R_0 = -\\frac{d p}{d  \\psi_p }\\), where \\(A\\) is a constant~\\cite{Cerfon2010,Cerfon2014}.\nBy integration over \\(\\psi_p\\) we find\n$\np(\\psi_p) = (A-1)\\psi_p/R_0/\\beta + p(0)$, %Does that mean that psi_p has to be negative if A=0?\n $I(\\psi_p) = \\sqrt{-2 A \\psi_p/R_0 + 1}$,\n and\n    $j_{\\hat\\varphi} = \\left[(A-1)R^2/R_0^2 - A \\right]/R/\\beta $.\nNote that if $\\psi_p$, $I(\\psi)$ and $p(\\psi)$ are a solution to Eq.~\\eqref{eq:GSEdimless}\nthen so are $\\mathcal P_\\psi \\psi_p$ , $\\mathcal P_\\psi I(\\psi_p)$ and $\\mathcal P_\\psi^2 p(\\psi_p)$.\nAlso note that for $A=0$ the constant current $I$ becomes arbitrary $\\mathcal P_I$.\n\nWe introduce \\(\\bar{R} \\equiv \\frac{R}{R_0}\\) and \\(\\bar{Z} \\equiv\\frac{Z}{R_0}\\)\nand thus represent a general solution to Equation~\\eqref{eq:GSEdimless} as~\\cite{Cerfon2010}\n\\begin{subequations}\n\\label{eq:solovev}\n\\begin{align}\n \\psi_p (R,Z) &= \\mathcal P_{\\psi} R_0 \\left[ A\\left( \\frac{1}{2} \\bar{R}^2 \\ln{\\bar{R}}\n   - \\frac{1}{8}\\bar{R}^4\\right)+ \\frac{1}{8}\\bar{R}^4\n   + \\sum_{i=1}^{12} c_{i}  \\bar{\\psi}_{pi}\\right],\\\\\n   I(\\psi_p) &= \\mathcal P_I\\sqrt{ - 2A\\frac{\\psi_p}{R_0\\mathcal P_{\\psi}} +1},\n\\end{align}\n\\end{subequations}\nwith $\\mathcal P_\\psi$ a free constant, $\\mathcal P_I = \\pm \\mathcal P_\\psi$ for $A\\neq 0$ and $\\mathcal P_I$ arbitrary for $A=0$ (purely toroidal equilibrium current).\nWe have\n\\begin{align}\n    p(\\psi_p) = \\mathcal P_\\psi \\frac{( A-1)\\psi_p}{\\beta R_0 } + p(0) \\qquad\n    j_{\\hat\\varphi} = \\frac{\\mathcal P_\\psi}{\\beta } \\left[\\frac{(A-1)R}{R_0^2} - \\frac{A}{R}\\right]\n\\end{align}\n\\rowcolors{2}{gray!25}{white}\n\\begin{longtable}{>{\\RaggedRight}p{7cm}>{\\RaggedRight}p{7cm}}\n\\toprule\n  $\\bar{\\psi}_{p1}=1$\n  & $\\bar{\\psi}_{p7}=8\\bar{Z}^6 -140 \\bar{R}^2 \\bar{Z}^4\n                      + 75 \\bar{R}^4 \\bar{Z}^2 - 15\\bar{R}^6\\ln{\\bar{R}}+ 180 \\bar{R}^4 \\bar{Z}^2 \\ln{\\bar{R}} \\\n                       -120 \\bar{R}^2 \\bar{Z}^4 \\ln{\\bar{R}}$\\\\\n%\n  $\\bar{\\psi}_{p2}=\\bar{R}^2$ &\n  $\\bar{\\psi}_{p8}=\\bar{Z}$ \\\\\n%\n  $\\bar{\\psi}_{p3}=\\bar{Z}^2 - \\bar{R}^2 \\ln{\\bar{R}}$ &\n  $\\bar{\\psi}_{p9}=\\bar{Z}  \\bar{R}^2$\\\\\n%\n  $\\bar{\\psi}_{p4}=\\bar{R}^4 -4\\bar{R}^2\\bar{Z}^2$ &\n  $\\bar{\\psi}_{p10}=\\bar{Z}^3 - 3 \\bar{Z} \\bar{R}^2 \\ln{\\bar{R}}$\\\\\n  %\n  $\\bar{\\psi}_{p5}=2\\bar{Z}^4 - 9 \\bar{R}^2\\bar{Z}^2 + \\\n                     3 \\bar{R}^4 \\ln{\\bar{R}} \\\n                    -12  \\bar{R}^2\\bar{Z}^2 \\ln{\\bar{R}}$\n  &\n$\\bar{\\psi}_{p11}=3 \\bar{Z}\\bar{R}^4 - 4\\bar{Z}^3\\bar{R}^2$\\\\\n%\n  $\\bar{\\psi}_{p6}=\\bar{R}^6 -12 \\bar{R}^4 \\bar{Z}^2\n                     + 8  \\bar{R}^2 \\bar{Z}^4$ &\n  $\\bar{\\psi}_{p12}= 8 \\bar{Z}^5 -45 \\bar{Z} \\bar{R}^4 - \\\n                       80 \\bar{Z}^3 \\bar{R}^2\\ln{\\bar{R}} \\\n                       +60 \\bar{Z} \\bar{R}^4\\ln{\\bar{R}}$ \\\\\n   & \\\\\n\\bottomrule\n\\end{longtable}\n\n\\subsubsection{Polynomial expansion}\nAs an alternative and in order to better fit experimental equilibria we offer\na polynomial expansion of the magnetic flux function\n\\begin{subequations}\n\\label{eq:polynomial}\n\\begin{align}\n    \\psi_p(R,Z) &= \\mathcal P_\\psi R_0\\sum_{i=0}^{N_R-1}\\sum_{j=0}^{N_Z-1} c_{ij}\\bar R^i\\bar Z^j\\\\\n   I(\\psi_p) &= \\mathcal P_I\n\\end{align}\n\\end{subequations}\nwhere the number of polynomial coefficients $N_R$ and $N_Z$ can be freely chosen.\n\\subsubsection{Discussion}\nSince Eqs.~\\eqref{eq:solovev} and \\eqref{eq:polynomial} are given analytically we can numerically evaluate $\\psi_p$ and $I$\nand all their derivatives\nat arbitrary points to machine precision, which is simple to implement and fast to execute.\nThis translates to an exact representation of the magnetic field and related\nquantities like the curvature operators in code. In particular,\nthe X-point and O-point can be determined to machine\nprecision via a few Newton iterations.\n\nThe choice of the coefficients \\(c_{i}\\) and \\(A\\), respectively $c_{ij}$ determines the actual form\nof the magnetic field.\nWe can for example represent single and asymmetric double X-point configurations, force-free states,\nfield reversed configurations and low and high beta tokamak equilibria.\n$R_0$ appears as an artificial scaling factor\n(note here that a change in $\\rho_s$ changes $R_0$ but not the form or size of\nthe dimensional equilibrium magnetic field).\nThe scaling factors $\\mathcal P_\\psi$ and $\\mathcal P_I$ are mainly introduced to maximize the flexibility e.g. to adapt the solution to experimental equilibria or to reverse the sign of the magnetic field.\nIf an X-point is present, we choose $c_1$ such that\n$\\psi_p(R_X, Z_X) = 0$ that is the separatrix is given by $\\psi_p(R,Z) = 0$.\n\n\\subsection{Curvature operators and perpendicular Poisson bracket}\nNote that\n\\begin{align}\n    B^R&=B_R = R_0\\psi_Z/R \\\\\n    B^Z&=B_Z = - R_0\\psi_R/R \\\\\n    B^\\varphi &= B_\\varphi/R^2 = R_0I/R^2\n\\end{align}\n(contra- and covariant components of $\\vec B$).\nBy construction we have $\\partial_\\varphi B = 0$ with\n\\begin{align}\n  B = \\frac{R_0}{R}\\sqrt{ {I^2 + |\\vn \\psi_p|^2}}.\n    \\label{}\n\\end{align}\nFurthermore, we have\n\\begin{align}\n  \\npar f(R,Z) = \\frac{R_0}{RB}[f,\\psi_p]_{RZ}\\Rightarrow \\npar \\ln B = \\frac{R_0}{RB^2}\\left[B, \\psi_p\\right]_{RZ} = -\\vec\\nc\\bhat.\n\\end{align}\nWe allow various simplifications to the curvature operator\nfor the Solov'ev equilibrium.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection{Toroidal (and negative toroidal) field line approximation}\\label{sec:torfieldlineapprox}\nThe toroidal/negative toroidal field line approximation applies \\(\\bhat\\approx \\pm \\ehat_\\varphi\\) to all perpendicular operators\n(e.g.: Poisson bracket, perpendicular elliptic operator and curvature operators)\nbut retains the full expression for the magnetic field unit vector \\(\\bhat\\)\nfor parallel operators (\\(\\npar\\) and \\(\\Delta_\\parallel\\)).\n\\begin{tcolorbox}[title=Note]\nWe allow the negative sign $-\\ehat_\\varphi$ to enable a sign reversal of the magnetic field, see Section~\\ref{sec:field_reversal}.\n\\end{tcolorbox}\nIn cylindrical coordinates that is\n\\begin{align}\n[f,g]_\\perp \\equiv [f,g]_{RZ} &= \\pm\\frac{1}{R} \\left(\\partial_R f\\partial_Z g - \\partial_Z f\\partial_R g\\right) \\\\\n\\np f &= \\partial_R f \\ehat_R + \\partial_Z f \\ehat_Z \\\\\n\\Delta_\\perp f &= \\frac{1}{R}\\partial_R \\left( R \\partial_R f\\right) + \\partial_Z(\\partial_Z f)\n\\label{}\n\\end{align}\nThe curl of $\\bhat$ reduces to\n%\\begin{align}\n $\\vn\\times\\bhat \\approx -  \\frac{\\pm 1}{R} \\ehat_Z$.\n%end{align}\nThis simplifies the curvature operators to:\n\\begin{align}\n\\vec{{K}}_{{\\vn\\times\\bhat}}  &\\approx  -  \\frac{\\pm 1}{B R} \\ehat_Z , &\n\\vec{ {K} }_{\\vn  B}  &\\approx  -\\frac{\\pm 1}{B^2}\\frac{\\partial B}{\\partial Z}\\ehat_R +\\frac{\\pm 1}{B^2} \\frac{\\partial B}{\\partial R}\\ehat_Z &\n%\\ehat_\\varphi \\times \\vn B, &\n\\vec{ {K} } &\\approx \\vec{ {K} }_{\\vn  B}  +\\vec{ {K} }_{{\\vn\\times\\bhat}} ,\n%\\\\\n%\\mathcal{K}_{{\\vn\\times\\bhat}}(f)   &\\approx  -  \\frac{1}{B R} \\frac{\\partial f}{\\partial Z},&\n%\\mathcal{K}_{\\vn  B} (f)  &= \\frac{1}{B} \\left[\\ln B, f \\right]_{RZ},&\n%\\mathcal{K} (f) &\\approx\\frac{1}{B} \\left[\\ln B, f \\right]_{RZ}-  \\frac{1}{B R} \\frac{\\partial f}{\\partial Z} ,\n\\end{align}\nand\n\\begin{align}\n \\nc \\vec{{K}}_{{\\vn\\times\\bhat}} &\\approx \\frac{\\pm 1}{R B^2} \\frac{\\partial B}{\\partial Z},\n\\end{align}\nwhich results in a vanishing divergence of the curvature operators \\( \\nc \\vec{ {K} } = 0\\).\n\nNote that in an actual toroidal field we have\n\\begin{align}\n  \\vec B(R) := \\pm \\frac{R_0}{R} \\ehat_\\varphi\n  \\label{}\n\\end{align}\nWe then have $\\bhat = \\pm\\ehat_\\varphi$ and the curvature operators further\nsimplify to\n\\begin{align}\n  \\vec{  K_{\\vn\\times\\bhat}} = \\vec{  K_{\\vn B}} = -\\frac{\\pm 1}{R_0} \\ehat_Z =\n\\vec{  K}/2\\\\\n  \\nc\\vec{ K_{{\\vn\\times\\bhat}}}=\n    \\npar \\ln B = 0\n    \\label{}\n\\end{align}\nNote: the negative sign is automatically chosen in code if $I(R_0, 0)<0$.\n\n\\subsubsection{Low beta approximation}\\label{sec:lowbetaapprox}\nIn this approximation we apply the toroidal field line approximation\nas in Section\n\\ref{sec:torfieldlineapprox}\nbut approximate the curvature operator $ \\vec K_{\\vn\\times\\bhat} \\approx \\bhat\\times\\vec \\kappa$\n  with\n  $\\vec \\kappa := \\bhat \\cn\\bhat = -\\bhat \\times( \\vn\\times \\bhat)$.\nFor an isotropic pressure plasma \\(\\vec{P} = \\vec{I} P_\\perp + \\vec{b} \\vec{b} P_\\Delta \\approx \\vec{I} P_\\perp\\) and with the definition of the plasma beta parameter\n\\(\\beta = \\frac{P}{B^2/(2 \\mu_0) } \\)\nwe can rewrite the curvature to\n\\begin{align}\n    \\vec{\\kappa} &\\approx \\frac{\\beta}{2} \\vn \\ln(P) +\\np \\ln{B} .\n\\end{align}\nIn low beta plasmas \\(\\beta\\ll1\\) the curvature reduces to:\n\\begin{align}\n    \\vec{\\kappa} & \\approx \\np \\ln{B} .\n\\end{align}\nThis simplifies the curvature operators to:\n\\begin{align}\n\\vec{{K}_{{\\vn\\times\\bhat}}} \\approx\n\\vec{ {K} }_{\\vn  B}  &\\approx  -\\frac{1}{B^2}\\frac{\\partial B}{\\partial Z}\\ehat_R +\\frac{1}{B^2} \\frac{\\partial B}{\\partial R}\\ehat_Z &\n{K} (f) &\\approx 2{K}_{\\vn  B} (f) , &\n    \\vn\\times\\bhat \\cdot \\vec{{K}}_{\\vn  B} &= 0.\n\\end{align}\nThe divergence over the curvature vanishes \\( \\nc \\vec{ {K} } = 0\\) only if \\( \\nc \\vec{ {K}}_{\\vn  B}   = 0\\).\nIn general, the divergence \\( \\nc \\vec{ {K} } \\approx 0\\) is only approximately vanishing.\n\\subsubsection{True perpendicular terms}\n\nWithout any approximations we have\n\\begin{align}\nb^R = {\\frac{\\partial \\psi}{\\partial Z}}\\left(I^2+|\\vn\\psi|^2\\right)^{-1/2} \\quad\nb^Z = -{\\frac{\\partial \\psi}{\\partial R}}\\left(I^2+|\\vn\\psi|^2\\right)^{-1/2} \\quad \nb^\\varphi = \\frac{I}{R}\\left(I^2+|\\vn\\psi|^2\\right)^{-1/2} \\\\\n\\vec\\nc\\bhat = -\\npar \\ln B = -\\frac{R_0}{R B^2}[B,\\psi_p]_{RZ} \\\\\n\\left({\\vn\\times\\bhat}\\right) \\cdot\\bhat =\n    (I'(\\vn\\psi_p)^2 - I \\Delta_\\perp^* \\psi_p)\\frac{ R_0^2}{R^2B^2} \\propto 1/R_0\n\\label{}\n\\end{align}\nwhere for the last\nestimate we inserted the Grad-Shafranov equation and the Solov'ev assumptions.\nWe can then insert $\\bhat$ into the exact definitions for $[.,.]_\\perp$, $\\np$ and $\\Delta_\\perp$ from Section~\\ref{sec:magnetic}.\n\nFor the curvature terms we can explicitly write\n\\begin{align}\nK_{\\vn B}^R &= -\\frac{R_0 I}{B^3R}\\frac{\\partial B}{\\partial Z} \\equiv -\\frac{1}{B^2}\\frac{\\partial B}{\\partial Z}b^\\varphi \\\\\nK_{\\vn B}^Z &= \\frac{R_0 I}{B^3R}\\frac{\\partial B}{\\partial R}\\equiv \\frac{1}{B^2}\\frac{\\partial B}{\\partial R}b^\\varphi \\\\\nK_{\\vn B}^\\varphi &= \\frac{R_0}{B^3R^2}\\left(\n      \\frac{\\partial \\psi}{\\partial Z} \\frac{\\partial B}{\\partial Z}\n    + \\frac{\\partial \\psi}{\\partial R}\\frac{\\partial B}{\\partial R}\\right)\n%\\equiv \\frac{1}{B^2R}\\left(\\bhat^R \\frac{\\partial B}{\\partial Z} - \\bhat^Z \\frac{\\partial B}{\\partial R}\\right)\\quad %contravariant phi component\n\\label{}\n\\end{align}\nand\n\\begin{align}\nK_{\\vn\\times\\bhat}^R &= \\frac{R_0 }{RB^3}\\left( B\\frac{\\partial I}{\\partial Z} -I\\frac{\\partial B}{\\partial Z}\\right) \\\\\nK_{\\vn\\times\\bhat}^Z &= \\frac{R_0 }{RB^3} \\left( I\\frac{\\partial B}{\\partial R} - B\\frac{\\partial I}{\\partial R} \\right)\\\\\nK_{\\vn\\times\\bhat}^\\varphi &= \\frac{R_0}{R^2B^2}\\left(\n+ \\frac{1}{B}\\frac{\\partial\\psi}{\\partial Z} \\frac{\\partial B}{\\partial Z}\n+ \\frac{1}{B}\\frac{\\partial \\psi}{\\partial R}\\frac{\\partial B}{\\partial R}\n-R\\frac{\\partial}{\\partial R}\\left(\\frac{1}{R}\\frac{\\partial\\psi}{\\partial R}\\right) \n- \\frac{\\partial^2 \\psi}{\\partial Z^2}\n\\right) \\\\\n\\vec\\nc\\vec{\\mathcal K_{\\vn\\times\\bhat}} &= -\\vec\\nc\\vec{\\mathcal K_{\\vn B}}=\n    -\\vec{\\mathcal K_{\\vn\\times\\bhat}}\\cn\\ln B = \\frac{R_0}{RB^3}[I,B]_{RZ}\n%contravariant phi component\n\\label{}\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Flux surface averaging and safety factor}\n\\subsubsection{Preliminary}\nRecall that the {\\bf Dirac delta-function} has the property (in any dimension):\n\\begin{align} \\label{eq:dirac_delta}\n\\int_V f(\\vec x) \\delta(h(\\vec x) - h') \\dV = \\int_{h=h'} \\frac{f(\\vec x)}{|\\vn h|} \\dA\n\\end{align}\nwhich means that the delta-function can be used to express area integrals of the\nsubmanifold given as a contour of the function $h(\\vec x)$.\nA numerically tractable approximation to the delta-function reads\n\\begin{align}\\label{eq:delta}\n\\delta(h(\\vec x)-h') = \\frac{1}{2\\pi \\epsilon^2}\n\\exp\\left( - \\frac{\\left(h(\\vec x)-h'\\right)^2}{2\\epsilon^2}\\right)\n\\end{align}\nwhere $\\epsilon$ is a small, free parameter.\nIn the DG framework the left-hand side\nof Eq.~\\eqref{eq:dirac_delta} can thus readily be computed\nvia Gauss-Legendre quadrature, which we propse as a first method to compute area\nintegrals even if our coordinate system is not aligned to the area.\nNote: in order for this to work the Delta function needs to be numerically\nresolved and cannot be made arbitrarily small.\nThis introduces a smoothing effect\nover neighboring contour lines which is given by the grid distance.\n\nFurthermore, recall the {\\bf co-area formula}\n\\begin{align} \\label{eq:coarea}\n\\int_{\\Omega_0} f(\\vec x) \\dV =\n\\int_0^{h_0} \\left( \\int_{h=h'} \\frac{f(\\vec x)}{|\\vn h|}  \\dA  \\right) \\d h'\n\\end{align}\nwhere $\\Omega_0$ is the volume enclosed by the contour $h=h_0$.\nThe co-area formula can be viewed as a change of variables in the\nvolume integral.\n\nWe define the {\\bf toroidal average} of a function $f(R,Z,\\varphi)$ as\n\\begin{align} \\label{eq:phi_average}\n\\PA{ f}(R,Z) := \\frac{1}{2\\pi}\\oint f(R,Z,\\varphi)\\d \\varphi\n\\end{align}\n\nIn arbitrary coordinates the area integral is defined by the pull back\nof the flux 2-form and the metric\n\\begin{align}\n\\label{}\n\\dA^2 = i_{\\hat \\psi_p} vol^3 \\quad \\hat \\psi_p = \\frac{\\vn \\psi_p}{|\\vn \\psi_p|}\n\\end{align}\nto a parameterization of the flux-surface.\nIn a flux-aligned coordinate system $\\{\\zeta, \\eta, \\varphi\\}$ the pull-back is trivial ($\\zeta=const$) and we have\n\\begin{align}\n\\dA &= \\sqrt{g^{\\zeta\\zeta}} \\sqrt{g} \\d\\eta\\d\\varphi = f_0|\\vn\\psi_p|\\sqrt{g}\\d\\eta\\d\\varphi,\n\\\\\n\\vec\\dA &:= \\hat\\psi_p \\dA = f_0 (\\vn\\psi_p) \\sqrt{g}\\d\\eta\\d\\varphi,\\quad\n\\label{}\n\\end{align}\nwhere we used that $g^{\\zeta\\zeta} = (\\vn\\zeta)^2 = f_0^2(\\vn\\psi_p)^2$.\nNotice that numerically we can integrate in flux-aligned coordinates by generating a corresponding\ngrid and pulling back (interpolating) the relevant fields to this grid. This is the second method\nto numerically compute area integrals.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Flux surface average}\n\n\nThe flux surface average (as a {\\bf volume average} after \\cite{haeseleer}) is defined as an average over a\nsmall volume - a shell centered around the flux-surface - defined by two neighboring flux-surfaces.\nWith the help of the volume\nflux label (notice that both the volume $v$ as well as the poloidal flux $\\psi_p$ have physical\nmeaning while the coordinate $\\zeta(\\psi_p)$ is an arbitrary choice) we define\n\\begin{align} \\label{eq:fsa_vol}\nv(\\psi_p) :=& \\int_{\\psi_{p,O}}^\\psi \\dV = \\int^{\\zeta(\\psi_p)} \\sqrt{g}\\d\\zeta\\d\\eta\\d\\varphi,\n\\\\\n\\frac{\\d v}{\\d\\psi_p} =& \\int\\dA |\\vn\\psi_p|^{-1} = 2\\pi f_0\\oint_{\\zeta(\\psi_p)} \\sqrt{g}\\d\\eta \\\\\n\\RA{ f }_\\psi :=& \\frac{\\partial}{\\partial v} \\int \\dV f\n = \\frac{1}{\\int \\dA |\\vn\\psi_p|^{-1} } \\int_{\\psi_p} \\frac{f(\\vec x)}{|\\vn\\psi_p|} \\dA \\nonumber\\\\\n=& \\frac{\\int_\\Omega \\PA{ f}(R,Z) \\delta(\\psi_p(R,Z)-\\psi_{p})H(Z-Z_X)\\ R \\d R \\d Z}\n{\\int_\\Omega \\delta(\\psi_p(R,Z)-\\psi_{p})H(Z-Z_X)\\ R \\d R \\d Z}\\nonumber\\\\\n =& \\left(\\frac{\\d v}{\\d\\psi_p }\\right)^{-1} 2\\pi f_0 \\oint_0^{2\\pi} \\PA{ f}(\\zeta,\\eta) \\sqrt{g}\\d\\eta\n = \\frac{1}{\\oint \\sqrt{g}\\d\\eta } \\oint_0^{2\\pi} \\PA{ f}(\\zeta,\\eta) \\sqrt{g}\\d\\eta\n\\end{align}\nwhere we used the co-area formula Eq.~\\eqref{eq:coarea} for the second identity\nand we use the Heaviside function $H(Z-Z_X)$ to cut away contributions from below the X-point\nin our domain $\\Omega$.\n We immediately see that this definition is particularly easy to compute\n in a flux-aligned coordinate system. Notice however that the volume element\n does appear (unlike e.g. Tokam3X papers).\n We use our grid construction algorithm with constant monitor metric described in Reference~\\cite{Wiesenberger2018} to construct a flux-aligned grid and interpolate\n the values of any function onto its grid points.\n Even though this grid is unusable for simulations due to the diverging metric at the X-point the\n evaluation of integrals works well as the singularity is integrable.\n\nThe flux-surface average fulfills the basic identities\n\\begin{align}\n\\label{eq:fsa_identities}\n\\RA{ \\mu f + \\lambda g} &= \\mu\\RA{ f} + \\lambda \\RA{ g} \\\\\n\\RA{ f(\\psi_p)} &= f(\\psi_p)\n\\end{align}\n\nThe volume average is well-suited for density-like quantities\nas we can see with the following identity.\nAssume we have a quantity $X$ with $\\partial_t X + \\nc \\vec j_X = \\Lambda_X$.\nThen we can use the volume average to write\n\\begin{align}\n\\frac{\\partial}{\\partial t} \\RA{X } + \\frac{\\partial}{\n  \\partial v} \\RA{ \\vec j_X\\cn v}  = \\RA{ \\Lambda_X}\n\\label{eq:fsa_balance}\n\\end{align}\nwhere again $v=v(\\psi_p)$ is the volume flux label.\nThe {\\bf total flux} of a given flux density $\\vec j_X$ through the\nflux surface $\\psi_p = \\psi_{p0}$ is given by\n\\begin{align}\n\\RA{\\vec j_X\\cn v} &:= J_X=\\oint_{\\psi_p=\\psi_{p0}} \\vec j_X\\cdot \\vec{\\dA} =\n \\frac{\\d v}{\\d\\psi_p} \\RA{ \\vec j_X\\cn\\psi_p }\\\\\n &=\n   2\\pi f_0 \\oint_0^{2\\pi} \\PA{ \\vec j_X\\cn\\psi_p}(\\zeta,\\eta) \\sqrt{g}\\d\\eta\n%2\\pi\\int_\\Omega \\vec \\PA{ \\vec j\\cn\\psi_p} \\delta(\\psi_p(R,Z)-\\psi_{p0}) H(Z-Z_X)\\ R \\d R \\d Z\n\\label{eq:total_flux}\n\\end{align}\nOnce we have the flux-surface averaged equation we can easily get the volume integrated version (again with the help of the co-area formula)\n\\begin{align}\n\\frac{\\partial}{\\partial t} \\int_0^{v(\\psi_p)}\\RA{X} \\d v \n+ \\RA{ \\vec j_X\\cn v}(v(\\psi_p))  = \\int_0^{v(\\psi_p)}\\RA{ \\Lambda_X}\\d v\n\\label{eq:integral_balance}\n\\end{align}\n\n\\subsubsection{The safety factor}\nAssume that we pick a random field line and follow it (integrate it) for exactly one\npoloidal turn. The {\\bf safety factor} is defined as the ratio between\nthe resulting toroidal angle ($\\Delta\\varphi$) to the poloidal angle ($2\\pi$)\n\\begin{align}\nq := \\frac{\\Delta\\varphi}{2\\pi}\n\\label{}\n\\end{align}\nSince our magnetic field is symmetric in $\\varphi$ and we used one\nfull poloidal turn this definition is independent of which\nfieldline we pick on a given flux surface.\n\n%We define the poloidal length $s$ as the fieldline following\n%parameter i.e. $\\vec B\\cn s \\equiv B_p = R_0|\\vn \\psi_p|/R$\n%and $\\d\\varphi/\\d s = B^\\varphi(R(s), Z(s)) / B_p(R(s),Z(s))$.\n%We can then express the safety factor as the line integral\n%\\begin{align}\n%q=\\frac{1}{2\\pi}\\oint \\frac{B^\\varphi}{B_p} \\d s = \\frac{1}{2\\pi}\\oint_{\\psi_p=\\psi_{p0}}\\frac{I(\\psi_p)}{R|\\vn\\psi_p|} \\d s\n%= \\frac{1}{2\\pi}\\int \\frac{I(\\psi_p)}{R}\\delta(\\psi_p-\\psi_{p0}) H(Z-Z_X) \\d R\\d Z\n%\\end{align}\n%where we made use of Eq.~\\eqref{eq:dirac_delta} in two dimensions in the\n%last equality and thus arrive at a numerical tractable expression\n%to evaluate the safety factor.\nWe define the geometric poloidal angle $\\Theta$ as the fieldline following\nparameter i.e. $\\vec B\\cn\\Theta = R_0(\\psi_R (R-R_0) + \\psi_Z Z)/r^2R$.\nWe can then directly integrate the safety factor as\n\\begin{align}\\label{eq:safety_factor}\n\\frac{\\d R}{\\d\\Theta} = \\frac{B^R}{B^\\Theta}\\quad\n\\frac{\\d Z}{\\d\\Theta} = \\frac{B^Z}{B^\\Theta}\\quad\n\\frac{\\d \\varphi}{\\d\\Theta} = \\frac{B^\\varphi}{B^\\Theta}\\\\\nq\\equiv\\frac{1}{2\\pi}\\oint \\frac{B^\\varphi}{B^\\Theta} \\d\\Theta\n\\end{align}\nWe integrate this equation with the help of one of our ODE integrators, i.e. we use a high-order Runge-Kutta method\nand refine the stepsize until machine-precision is reached.\nNotice that the safety factor diverges on the last closed flux\nsurface whereas Eq.~\\eqref{eq:total_flux}\nremains finite due to the $\\vn\\psi_p$ factor.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Toroidal averages}\nHere, we comment on the $\\varphi$ average that is part of the flux-surface average Eq.~\\eqref{eq:fsa_vol}.\nOne simple approach is\nquadrature of the form\n\\begin{align}\\label{eq:toroidal_summation}\n    \\bar f = \\frac{1}{N} \\sum_{i=0}^{N-1} f_i (R,Z)\n\\end{align}\nwhere $N=32$ in most of our simulations and $f_i$ is the $i$-th toroidal plane.\nSince the boundary conditions in $\\varphi$ are periodic this amounts to the trapezoidal rule.\nA low number of toroidal planes is sufficient in simulations when we use the toroidal field\napproximation in combination with the\nflux-coordinate independent (FCI) approach for the parallel derivatives.\nHowever, since the actual $\\varphi$ direction is\nunder-resolved the\nintegration gives a wrong answer to the actual $\\varphi$ average (seen in 2d plots as little humps).\nThis is because the resulting structures are predominantly field aligned and not toroidally symmetric.\n\nIn order to improve the toroidal average we now have the following idea:\nif we, before we do the $\\varphi$ integration,\ninterpolate the function to integrate onto a large number of toroidal\nplanes then the result should\nbe more accurate than before.\nIn other words we interpolate the function given on the coarse $\\varphi$ simulation grid\nonto a hypothetic fine $\\varphi$ grid along the magnetic field lines\nand only then compute the $\\varphi$ average.\n\nLet us divide the $\\varphi$ direction between two original planes into $N_\\varphi+1$ (a large number) equidistant planes\nof distance $\\delta \\varphi$ and integrate the magnetic field $\\vec B$ in between.\n\\begin{subequations}\n\\begin{align}\n    \\frac{\\d R}{\\d\\varphi}&= \\frac{B^R}{B^\\varphi},\\\\ %\\frac{R}{I}\\frac{\\partial\\psi}{\\partial Z},\\\\\n    \\frac{\\d Z}{\\d\\varphi}&=\\frac{B^Z}{B^\\varphi},\\\\%-\\frac{R}{I}\\frac{\\partial\\psi}{\\partial R}.\n\\end{align}\n\\label{eq:fieldline}\n\\end{subequations}\nWe integrate Eqs.~\\eqref{eq:fieldline} from $\\varphi=0$ to $\\varphi=\\pm \\Delta \\varphi$\nwith initial condition\n\\begin{align}\n    (R(0), Z(0) ) = (R, Z).\n    \\label{}\n\\end{align}\nLet us characterize the solution $(R(\\pm \\delta \\varphi), Z(\\pm \\delta \\varphi))$ to Eqs.~\\eqref{eq:fieldline} as the flow generated by $\\vec B/B^\\varphi$\n\\begin{align}\n    \\Tdpm\\vec z \\equiv \\Tdpm[R, Z, \\varphi]:= ( R(\\pm \\delta\\varphi), Z( \\pm \\delta\\varphi), \\varphi\\pm\\delta \\varphi),\n    \\label{}\n\\end{align}\nObviously we have $\\Tdm\\circ\\Tdp = 1$, but $\\Tdpm$ is not necessarily unitary since $\\vec B/B^\\varphi$ is in general\nnot divergence free.\nWe are now able to extend the function $f$ given on the coarse $\\varphi$ grid unto the fine $\\varphi$ grid via\n\\begin{align}\n    f(R,Z,\\varphi_0+j\\delta\\varphi) = {\\Tdm}^j f(R,Z,\\varphi_0)\\\\\n    f(R,Z,\\varphi_0-j\\delta \\varphi) = {\\Tdp}^j f(R,Z,\\varphi_0)\n\\end{align}\nThis gives simple 0-th order extrapolation of our function.\nLet us call $f_i := f(R,Z,\\varphi_i)$ the $i$-th toroidal plane and $N_\\varphi$ even. Then\nwe have the following integration, where we consider the original toroidal planes as cell-centered\n\\begin{align}\n    \\RA{f}_\\varphi &= \\frac{1}{(N_\\varphi+1) N} \\left[\\left(\n    {\\Tdp}^{N_\\varphi/2} f_0 + ... + \\Tdp f_0 + f_0 + \\Tdm f_0 ... + {\\Tdm}^{N_\\varphi/2} f_0\\right)\\right. \\nonumber\\\\\n    &\\left. +\\left( {\\Tdp}^{N_\\varphi/2} f_1 + ... + \\Tdp f_1 + f_1 + \\Tdm f_1 ... + {\\Tdm}^{N_\\varphi/2} f_1\\right)  + ... \\right] \\nonumber\\\\\n    &= \\frac{1}{N (N_\\varphi+1)} \\sum_{i=0}^{N-1} \\left[f_i + \\sum_{j=1}^{N_\\varphi/2} \\left( {\\Tdm}^j f_i + {\\Tdp}^jf_i\\right)\\right] \\nonumber\\\\\n    &=\n    \\frac{1}{N_\\varphi+1} \\left[ \\sum_{j=0}^{N_\\varphi/2}  {\\Tdm}^j \\left(\\frac{1}{N}\\sum_{i=0}^{N} f_i\\right)\n    +\n    \\sum_{j=1}^{N_\\varphi/2}  {\\Tdp}^j \\left(\\frac{1}{N}\\sum_{i=0}^{N} f_i\\right)\\right]\n    \\nonumber\\\\\n    &=\n    \\frac{1}{N_\\varphi+1} \\left[ \\sum_{j=0}^{N_\\varphi/2}  {\\Tdm}^j \\bar f(R,Z)\n    +\n    \\sum_{j=1}^{N_\\varphi/2}  {\\Tdp}^j \\bar f(R,Z)\\right]\n\\end{align}\nHere, we used that the push-forward operator $\\Tdm$ is linear that is $\\Tdm f_0 + \\Tdm f_1 = \\Tdm (f_0+f_1)$\nand recover the simple toroidal summation $\\bar f$ Eq.~\\eqref{eq:toroidal_summation}.\nNow, we can see that in the limit $N_\\varphi \\rightarrow\\infty$ the discrete sum represents the integral\nof the form\n\\begin{align}\n    \\RA{f}_\\varphi(R,Z) = \\frac{1}{\\Delta\\varphi}\\int_{-\\Delta\\varphi/2}^{\\Delta\\varphi/2}\\d\\varphi \\bar f(R(\\varphi),Z(\\varphi))\n\\end{align}\nA consistency test of this approach is to simply use $\\vec B = e_\\varphi$. Then\n$\\Tdpm = 1$ and we recover the original integration $\\RA{f}_\\varphi= \\bar f$.\nNow, instead of doing a 0-th order interpolation let us try a linear interpolation along field-lines in between planes that is ( assuming $N_\\varphi$ toroidal planes)\n\\begin{align}\n    f(R,Z,\\varphi_i + j\\delta\\varphi) = \\left(1-\\frac{j}{N_\\varphi}\\right){\\Tdm}^j f_i + \\frac{j}{N_\\varphi} {\\Tdp}^{N_\\varphi -j}f_{i+1}\n\\end{align}\n\\begin{align}\n    \\RA{ f}_\\varphi &= \\frac{1}{N_\\varphi N} (( f_0 + (1-\\alpha_1)\\Tdm f_0 + \\alpha_1 (\\Tdp)^{N_\\varphi -1} f_1 + (1-\\alpha_2)(\\Tdm)^2 f_0 + \\alpha_2 (\\Tdp)^{N_\\varphi-2} f_1 ...  )+ (f_1 + ...) + ...)\\nonumber\\\\\n    &= \\frac{1}{ N_\\varphi} \\sum_{j=0}^{N_\\varphi-1}  (1-\\alpha_j)(\\Tdm)^j \\bar f+\\alpha_j (\\Tdp)^{N_\\varphi -j} \\bar f\n    = \\frac{1}{\\Delta\\varphi}\\int_{-\\Delta\\varphi}^{\\Delta\\varphi}\\d\\varphi w(\\varphi) \\bar f (R(\\varphi),Z(\\varphi))\n    \\label{eq:cta}\n\\end{align}\nwith $\\alpha_j = \\frac{j}{N_\\varphi}$ and $w(\\varphi)$ a linear weight function (pyramid shape) with $\\int_{-\\Delta\\varphi}^{\\Delta\\varphi} w(\\varphi) = \\Delta\\varphi$. Taking $\\Tdpm=1$ again leads to the old result.\n\n\nNow, an interesting question is, what happens if we are trying to apply the above\nresults to a function that is not field-aligned like $B(R,Z)$ of $\\vec K\\cn\\psi_p$ for instance? For those functions $\\bar f_\\mathrm{old}$ actually yields the exact\nresult, while the convolution is an approximation.\nHere, we have to test.\nTypically, the functions that we use are slowly varying in $R$ and $Z$ and\nso the convolution should not change the result too much.\nA good test candidate is still $\\langle \\mathcal K(\\psi_p)\\rangle_{\\psi_p}=0$.\n\nIn all practical tests so far the flux-suface average is not or only very slightly changed by this procedure.\nThis means that it is not\nnecessary to follow the smoothing procedure if one is only interested in the flux-surface average.\nThis makes sense because the toroidal and poloidal averages commute.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Alternative flux labels}\nWe find the toroidal flux $\\psi_t$ by integrating the q-profile $\\psi_t = \\int^{\\psi_p} \\d\\psi_p q(\\psi_p)$. Since $q$ diverges, $\\psi_t$, in contrast to $\\psi_p$,\nis not defined outside the last closed flux-surface (but has a finite value on the last closed flux surface). We now define the normalized poloidal and toroidal flux labels $\\rho_p$ and $\\rho_t$\n\\begin{align}\n    \\rho_p&:= \\sqrt{1-\\frac{\\psi_p }{\\psi_{p,O}}} \\ \\leftrightarrow\\ \\psi_p = (1-\\rho_p^2)\\psi_{p,O} \\\\\n    \\rho_t&:= \\sqrt{\\frac{\\psi_t}{\\psi_{t,\\mathrm{sep}}}},\\\\\n    \\text{with }\\psi_{p,O} &= \\psi_p(R_O, Z_O)% \\text{ and } \\psi_{p,X} = \\psi_p(R_X, Z_X)\n\\end{align}\nwhere $R_O$, $Z_O$ are the coordinates of the O-point.\nThe labels $\\rho_t$ and $\\rho_p$ are useful because\nequidistant $\\rho_p$ and $\\rho_t$ values tend to translate to equidistant flux-surfaces\nin configuration space.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{The model} \\label{sec:model}\n\\subsection{Conservative form}\nWe scale all spatial lengths by $\\rho_s = \\sqrt{T_e m_i}/(eB_0)$ and time by the ion gyro-frequency $\\Omega_0 = eB_0/m_i$.\nThe magnetic field is scaled with $B_0$, densities with $n_0$ and the parallel velocity is scaled with $c_s = \\sqrt{T_e/m_i}$.\nThe potential is scaled with $\\hat \\phi = e/T_e$ and the vector potential with\n$\\hat A_\\parallel = \\rho_s B_0$.\nWe introduce the dimensionless parameters\n\\begin{align}\n  \\tau_a = \\frac{T_a}{z_aT_e}~,\\quad \\mu_a = \\frac{m_a}{z_am_i}\\text{ and }\n  \\beta:=\\frac{\\mu_0 n_0 T_e}{B_0^2}\n  \\label{}\n\\end{align}\nwhere $a\\in\\{e,i\\}$ is the species label and $z$ is the charge number.\nOmitting the species label we arrive at (dividing the density equation by $\\Omega_0n_0$ and the velocity equation by $\\Omega_0 c_s$)\n\\begin{tcolorbox}[ams align,\ncolback=yellow!10!white, colframe=red!50!black,\n        highlight math style= {enhanced, %<-- needed for the ’remember’ options\n        colframe=red,colback=red!10!white,boxsep=0pt}, title=Model equations\n        ]\n\\frac{\\partial}{\\partial t} N &+ \\vec\\nc\\left( N \\left(\n    \\vec u_E + \\vec u_K + \\vec u_{C} + U_\\parallel\\left(\\bhat + {\\vec b}_\\perp\\right)\\right)\\right) = \\Lambda_N + S_N \\\\\n    \\mu \\frac{\\partial}{\\partial t} \\left(N U_\\parallel\\right) &+ \\mu \\nc \\left( NU_\\parallel \\left(\n    \\vec u_E + \\vec u_K + \\vec u_{C} + U_\\parallel\\left(\\bhat + {\\vec b}_\\perp\\right)\n    \\right)\\right)  \\nonumber \\\\\n    &+ 2\\mu \\nc ( NU_\\parallel \\vec u_{\\vn\\times\\bhat})\n    -\\mu NU_\\parallel\\nc \\vec u_{\\vn\\times\\bhat}\n    + \\mu NU_\\parallel\\mathcal K_{\\vn\\times\\bhat}(\\psi) \\nonumber\\\\\n    =& -\\tau \\left(\\bhat + {\\vec b}_\\perp\\right)\\cn N\n    -N \\left( \\left(\\bhat+{\\vec b}_\\perp\\right)\\cn \\psi + \\frac{\\partial A_\\parallel}{\\partial t}\\right)\n    - \\eta n_e^2(U_{\\parallel,i}-u_{\\parallel,e})\n    \\nonumber\\\\\n    &+ \\mu \\nu_\\parallel \\Delta_\\parallel U+ \\mu N\\left(\\Lambda_U + S_U\\right) + \\mu U_\\parallel \\left(\\Lambda_N + S_N\\right)\n\\label{}\n\\end{tcolorbox}\nwith\n\\begin{align}\n\\vec u_E := \\frac{\\bhat\\times\\vn\\psi}{B},\\quad\n\\vec u_{K} := \\tau \\left(\\vec{ K_{\\vn B}} + \\vec{ K_{\\vn\\times\\bhat}}\\right)=\\tau\\vec{ K}  ,\\quad  %\\nonumber\\\\\n\\vec u_C := \\mu U_\\parallel^2\\vec{ K_{\\vn\\times\\bhat}},\\nonumber\\\\\n\\vec u_{\\vn\\times\\bhat} := \\tau\\vec{ K_{\\vn\\times\\bhat}},\\quad\n{\\vec b}_\\perp = \\frac{\\vn\\times A_\\parallel \\bhat}{B} = A_\\parallel \\vec{ K_{\\vn\\times\\bhat}} + \\frac{\\vn A_\\parallel \\times \\bhat}{B}.\n\\label{}\n\\end{align}\n\nThe electric potential \\(\\phi\\) and parallel magnetic vector potential \\(A_\\parallel\\) are\ncomputed by the polarisation and induction equations (with $q_e=-e$ and $q_i=+e$)\n\\begin{align}\n -\\nc\\left(\\frac{\\mu_iN_i}{B^2} \\np \\phi\\right) &=  \\Gamma_{1,i} N_i -n_e, \\quad \\Gamma_{1,i}^{-1} := 1-\\frac{1}{2}\\mu_i\\tau_i\\Delta_\\perp , \\\\\n  -\\frac{1}{\\beta} \\Delta_\\perp A_\\parallel &= \\left(N_i U_{\\parallel,i}-n_e u_{\\parallel,e} \\right)\n  \\label{eq:polarisation_dimensional}\n\\end{align}\nGiven $\\phi$ we define the generalised electric potential\n\\begin{align}\n    \\psi_e := \\phi,\\quad \\psi_i&:= \\Gamma_{1,i} \\phi - \\frac{\\mu_i }{2}\\left(\\frac{\\np\\phi}{B}\\right)^2\n\\end{align}\nIn total\nwe have an isothermal 3d gyro-fluid model with up to 2nd order FLR effects\non in the electric potential $\\phi$ and 0th order FLR effects in the parallel magnetic\npotential $A_\\parallel$.\nWe have the continuity equation for the electron density \\(n_e\\) and the ion gyro-centre\ndensity \\(N_i\\) and the momentum conservation equation for\nthe parallel electron velocity \\(u_{\\parallel,e}\\) and the parallel ion gyro-centre velocity \\(U_{\\parallel,i}\\)~\\cite{WiesenbergerPhD, HeldPhD}.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Diffusive terms}\\label{sec:dissres}\nSince the gyro-fluid derivation does not include collisional terms we\ncopied the parallel resistive and viscous terms from the Braginskii fluid equations~\\cite{Braginskii1965}.\nThe electron-ion and ion-ion collision frequencies are given by\n$\\nu_{ei} = \\sqrt{2} z^2 e^4 \\ln \\Lambda/ (12\\pi^{3/2} \\sqrt{m_e} \\epsilon_0^2) n_e /T_e^{3/2}$, $\\nu_{ee} = \\nu_{ei}/\\sqrt{2}$\nand\n$\\nu_{ii} =  z^4 e^4 \\ln \\Lambda/ (12\\pi^{3/2} \\sqrt{m_i} \\epsilon_0^2) n_i /T_i^{3/2}$.\nWe define with the parallel Spitzer resistivity\n$\\eta_\\parallel := \\frac{0.51 m_e \\nu_{ei}}{n_e e^2}$ and the parallel electron and ion viscosities\n$\\mu_{\\parallel,e}:=0.73\\frac{n_eT_e}{\\nu_{ei}}$ and $\\mu_{\\parallel,i} = 0.96\\frac{n_iT_i}{\\nu_{ii}}$~\\cite{Braginskii1965}\n\\begin{subequations}\n\\begin{align}\n    \\eta&:=\\frac{en_0\\eta_\\parallel}{B_0} = \\frac{\\nu_{ei,0}}{\\Omega_{ce}}= 8.45\\cdot 10^{-5}\\ln \\lambda \\left(\\frac{n_0}{10^{19}\\text{m}^3}\\right) \\left(\\frac{T_e}{\\text{eV}}\\right)^{-3/2} \\left(\\frac{B_0}{\\text{T}}\\right)^{-1}, \\\\\n    \\nu_{\\parallel,e}&:=\\frac{\\mu_{\\parallel,e,0}}{m_e n_0\\rho_s^2\\Omega_{ci}} = 0.73 \\frac{\\Omega_{ce}}{\\nu_{ei,0}} = \\frac{0.73}{\\eta} \\\\\n    \\nu_{\\parallel,i}&:=\\frac{\\mu_{\\parallel,i,0}}{m_i n_0 \\rho_s^2\\Omega_{ci}} = 0.96 \\frac{\\Omega_{ci}}{\\nu_{ii,0}} = \\sqrt{\\frac{m_e}{m_i}} \\frac{1.36}{\\eta}\n\\end{align}\n    \\label{eq:resistivity}\n\\end{subequations}\nwith $\\ln \\lambda \\approx 10$ and $T_e=T_i$ for the purpose of computing the diffusive coefficients. Note that $\\nu_\\parallel/N$ represents a kinematic viscosity and is a factor $\\sqrt{|\\mu_e|}$ smaller for ions than for electrons.\nThe dynamic viscosity $\\mu\\nu_\\parallel$ is larger for ions than for electrons.\n The approximate Spitzer current \\(J_{\\parallel,s}:= n_e \\left(U_{\\parallel,i} - u_{\\parallel,e}\\right)\\)\n determines the parallel resistive terms to $R_\\parallel:= n_e\\eta J_{\\parallel,s}$.\n\n Note also that since $A_\\parallel/\\mu_e$ is (potentially) much larger than $u_e$\n it is important that the diffusive operators act on $u_e$ rather than $w_e$.\n The latter essentially would entail that electron diffusion acts on $A_\\parallel$.\n\n For the perpendicular terms we use ad-hoc numerical diffusion terms for numerical\n stabilisation.\n\\begin{align}\n\\label{eq:perpdiffNT}\n \\Lambda_{n_e} &=  \\nu_\\perp \\Delta_\\perp n_e \\text{ or } -\\nu_\\perp \\Delta_\\perp^2 n_e&\n \\Lambda_{N_i} &=  \\nu_\\perp \\Delta_\\perp N_i \\text{ or } -\\nu_\\perp \\Delta_\\perp^2 N_i & \\\\\n \\Lambda_{u_e} &=  \\nu_\\perp \\Delta_\\perp u_{\\parallel,e} \\text{ or } -\\nu_\\perp \\Delta_\\perp^2 u_{\\parallel,e} &\n \\Lambda_{U_i} &=  \\nu_\\perp \\Delta_\\perp U_{\\parallel,i} \\text{ or } -\\nu_\\perp \\Delta_\\perp^2 U_{\\parallel,i}\n\\end{align}\nHere the mass diffusion coefficient coincides with the viscous coefficient, hence we fixed the Schmidt number \\(\\mathit{Sc}_\\parallel:= \\frac{\\nu_U}{\\nu_N}\\) to unity.\n\nWe do not derive resistive drifts in the gyro-fluid approach.\nThe drift-fluid corresponding resistive drift gives an order-of-magnitude estimate for $\\nu_\\perp$.\nWe have  $D_i = \\rho_i^2 \\nu_{ii}$ and $T_{i0} = T_{e0}$.\nBy dividing by $\\rho_s^2 \\Omega_{ci}$ we arrive at $\\nu_\\perp = \\nu_{ii0}/\\Omega_{ci}$.\n\\begin{align}\n\\nu_\\perp =\n5\\cdot 10^{-3} \\ln \\lambda\n\\left(\\frac{n_0}{10^{19}\\text{m}^3}\\right)\n\\left(\\frac{T_e}{\\text{eV}}\\right)^{-3/2}\n\\left(\\frac{B_0}{\\text{T}}\\right)^{-1}\n\\left(\\frac{m_i}{m_H}\\right)^{1/2},\n\\end{align}\n\n\\subsection{Boundary conditions: the penalization method}\nWe define the simulation box as\n$[ R_{\\min}, R_{\\max}]\\times [Z_{\\min}, Z_{\\max}] \\times [0,2\\pi]$,\nwhere we define\n\\begin{align} \\label{eq:box}\n    R_{\\min}&=R_0-\\varepsilon_{R-}a\\quad\n    &&R_{\\max}=R_0+\\varepsilon_{R+}a\\nonumber\\\\\n    Z_{\\min}&=-\\varepsilon_{Z-}ae\\quad\n    &&Z_{\\max}=\\varepsilon_{Z+}ae\n\\end{align}\nwhere $a$ is the minor radius, $e$ is the elongation of the flux surfaces and\nthe $\\varepsilon$ are free parameters to be specified by the user.\n\nThe boundary conditions for the potential and the magnetic potential are not\npenalized and thus hold on the bounding box. Typically we choose\n\\begin{align}\n\\phi = 0\n\\text{ and }  \\hat n \\cn A_{\\parallel} = 0\n\\end{align}\nwhere $\\hat n$ is the normal vector to the boundary. The perpendicular boundary\nconditions for the remaining fields become obsolete with the following\npenalization scheme.\n\n\\begin{tcolorbox}[title=Note]\n    Computing on a box and cutting away the parts that are the wall,\n    for typical tokamak shapes incur a (loosely) estimated 50\\% overhead in vector size:\n    \\begin{align*}\n        \\text{ number of points in box } = 1.5 \\times \\text{ number of points in area with plasma}\n    \\end{align*}\n\\end{tcolorbox}\n\n\\subsubsection{The wall region}\nBeing a box, our computational domain is in particular not aligned with the\nmagnetic flux surfaces. This means that particularly in the corners of\nthe domain the field lines inside the domain are very short (in the\nsense that the distance between the entry point and leave point is short).\nIt turns out that this behaviour is numerically disadvantageous (may\nblow up the simulation in the worst case) in the\ncomputation of parallel derivatives.\nIn order to remedy this situation\nwe propose a penalization method to model the actual physical wall.\nWe define an approximation to the step function with a transition layer of radius $a$\naround the origin\n\\begin{align}\n\\Theta_a(x) := \\begin{cases}\n    0 & \\text{ for } x \\leq -a  \\\\\n    \\frac{1}{32 a^7}  \\left(16 a^3-29 a^2 x+20 a x^2-5 x^3\\right) (a+x)^4\n    &\\text{ for } -a<x\\leq a \\\\\n    1 & \\text{ for } x > a\n\\end{cases}\n    \\approx H(x)\n\\label{eq:approx_heaviside}\n\\end{align}\nwhere $H(x)$ is the Heaviside step function.\n%An integral of this function is\n%\\begin{align}\n%\\theta_a(x) := \\begin{cases}\n%    0 &\\text{ for } x \\leq -a \\\\\n%    \\frac{1}{256 a^7} \\left(35 a^3-47 a^2 x+25 a x^2-5 x^3\\right) (a+x)^5\n%     &\\text{ for } -a<x\\leq a \\\\\n%x &\\text{ for } x > a\n%\\end{cases}\n%    \\approx x H(x)\n%\\end{align}\n%Note that $\\Theta_a(0) = 0.5$ and $\\theta_a(0) = 35a/256$.\n%\nWe now use the region defined by\n\\begin{align}\\label{eq:wall}\n    \\chi_w(R,Z,\\varphi):=\\Theta_{\\alpha/2}\\left(\\psi_{p,b} + \\frac{\\alpha}{2} - \\psi \\right) \\approx H(\\psi_{p,b}-\\psi)\n\\end{align}\nto define the wall region.\nIn order to simplify the setup of this region we give $\\psi_{p,b}$ and $\\alpha$ in terms of\n$\\rho_p$ and $\\alpha_p$ via $\\psi_{p,b} = (1-\\rho_{p,b}^2)\\psi_{p,O}$ and $\\alpha = -(2\\rho_{p,b} \\alpha_p + \\alpha_p^2)\\psi_{p,O}$. In case we change the sign\nof $\\psi_p$ via $\\mathcal P_\\psi$ (to make it concave) note that $\\alpha$ becomes\nnegative and $\\psi_{p,O}$ is positive).\nWe then need to point mirror Eq.~\\eqref{eq:wall} at $\\psi_{p,b}+\\frac{\\alpha}{2}$.\n\nNow, our idea is to dampen the density and velocity in the region defined by the\nwall to 1 or 0 respectively.\nFor both electrons and ions we choose\n\\begin{subequations} \\label{eq:wall_penalization}\n\\begin{align}\n    S^w_N(R,Z,\\varphi, t) &:= -\\omega_w\\chi_w (N-1)\\\\\n    S^w_U(R,Z,\\varphi, t) &:= -\\omega_w\\chi_w U_\\parallel\n\\end{align}\n\\end{subequations}\nwhere $\\omega_w \\gg 1$ is the penalization parameter.\n\\subsubsection{The sheath region}\nIn order to define sheath boundary conditions we first define a sheath region\nand then determine whether the field lines point toward the wall or away from it.\nWe define as sheath any part on the bounding box that is not included in the wall\npenalization. Then we check for each point in the box the poloidal distance to\nthe sheath wall and if the poloidal field points toward or away from the wall closest\nto it.\nWe then take $\\theta_{\\alpha/2}\\left( (\\eps_s + \\frac{\\alpha}{2})a - d(R,Z)\\right)$\nand take the set intersection between that region and the ``not wall'' region to\ndetermine the sheath penalization region:\n\\begin{align}\\label{eq:sheath}\n    \\chi_s := \\left(1-\\chi_w(R,Z,\\varphi)\\right) \\theta_{\\alpha/2}\\left( \\left(\\eps_s + \\frac{\\alpha}{2}\\right)a - d(R,Z)\\right)\n\\end{align}\nWithin the sheath region we penalize\n\\begin{subequations} \\label{eq:sheath_penalization}\n\\begin{align}\n    S^s_N(R,Z,\\varphi, t) &:= \\omega_s \\chi_s \\left(N_{sh}-N\\right)\\\\\n    S^s_{U_i}(R,Z,\\varphi, t) &:= \\omega_s \\chi_s \\left(\\sqrt{1+\\tau} - U_{\\parallel,i} \\right) \\\\\n    S^s_{u_e}(R,Z,\\varphi, t) &:= \\omega_s \\chi_s \\left(\\sqrt{1+\\tau}\\exp(-\\phi) - u_{\\parallel,e} \\right) \\text{ or }\n    S^s_{u_e}(R,Z,\\varphi, t) := \\omega_s \\chi_s \\left(\\sqrt{1+\\tau} - u_{\\parallel,e} \\right)\n\\end{align}\n\\end{subequations}\nwhere $\\omega_s$ is the sheath penalization parameter and $N_{sh}$ is obtained by extrapolating $N$ along the magnetic field line with\nthe help of the parallel derivative operators\n\\begin{align}\n    N_{sh} = \\Tpm N \\text{ such that } \\nabla_\\parallel N|_{sh} = 0\n\\end{align}\nwhere the sign depends again on the direction of the magnetic field line (we always extrapolate ``downstream'').\nThe extrapolation models a parallel Neumann boundary condition for the density.\nThe boundary condition for the parallel electron velocity can be either the Bohm condition containing the contribution from the electric potential or\nan insulating condition where the total current $j_s = n_e ( U_{\\parallel,i} - u_{\\parallel,e})$ vanishes.\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Initial conditions}\nWe initialize the parallel velocity to zero\n\\begin{align}\n  u_{\\parallel,e}(R,Z,\\varphi,0) = U_{\\parallel,i}(R,Z,\\varphi,0) = 0\n  \\label{}\n\\end{align}\nwhich in turn initializes $A_\\parallel = 0$\nand initialize the electron density with\n\\begin{align} \\label{eq:initial_ne}\n    n_e(R,Z,\\varphi, 0)= n_{prof}(R,Z) + \\tilde n(R,Z,\\varphi)\n\\end{align}\nconsisting of a toroidally symmetric background profile $n_{\\text{prof}}(R,Z)$ and a perturbation\n$\\tilde n(R,Z,\\varphi)$, which breaks the toroidal symmetry.\nNote that we should take care to intitialize a smooth profile with ideally well-defined $\\Delta^2_\\perp n_e$.\n\nWe define a flux-aligned density profile as\n\\begin{align} \\label{eq:density_profile}\n  n_{\\text{prof}}(R,Z)=\n  n_0 + \\triangle n_{peak}\\frac{\\psi_p(R,Z) }{\\psi_{p,O}}\\Theta_{\\alpha_p/2}\\left(1-\\rho_p(R, Z)-\\frac{\\alpha_p}{2}\\right) H(Z-Z_X)\n\\end{align}\nThe second Heaviside is multiplied only if the equilibrium $\\psi_p$ has an\nX-point and avoids a profile in the private flux region. The factor $\\alpha_p$ provides a smooth transition\nzone that avoids numerical oscillations.\n\n\nWe have two possibilities to initialize the ion density\n\\begin{align} \\label{eq:initphi}\n  N_i = \\Gamma_{1,i}^{-1} n_e \\text{ or } N_i = \\Gamma_{1,i}n_e\\approx \\left(1+\\frac{1}{2}\\tau_i\\mu_i\\Delta_\\perp\\right)n_e\n\\end{align}\nIn the first case the potential $\\phi= 0$ while in the second case\nthe $E\\times B$ and ion diamagnetic vorticity coincide $\\Delta_\\perp N_i \\propto \\Delta_\\perp \\phi$ in the long-wavelength limit.\nNote that $\\alpha$ must not be too small to avoid $N_i < 0$.\nWe can choose between several initial conditions for $\\tilde n$:\n\n\\subsubsection{Blob and Straight blob}\nWe initialize a blob in the R-Z plane\n\\begin{align} \\label{eq:initial_blob}\n  \\tilde n_{blob}(R,Z,0) = \\triangle n \\exp\\left( -\\frac{(R - R_0 - p_x a)^2 + (Z-p_ya)^2}{\\sigma^2} \\right)\n\\end{align}\nThen, we use fieldline integration modulated by\n\\begin{align}\n  m_{blob}(s) = \\exp\\left( -\\frac{s^2 }{\\pi^2\\sigma_z^2} \\right)\n\\end{align}\nto transform this blob to all other poloidal\nplanes.\nWe either follow fieldlines around the torus several times (``blob'') or only once\n(``straight blob'').\n\\subsubsection{Turbulent bath}\nWe can initialize the R-Z plane with a turbulent bath with a certain amplitude $A$.\nThis especially has the goal to destabilize the edge region right inside the\nlast closed flux surface. Notice that the core region is rather stable\nand quickly damps away fluctuations.\nAgain, we transform this to all poloidal planes along the magnetic field lines and multiply the bath with\n\\begin{align} \\label{eq:initial_turbulent}\n    \\tilde n_e(R,Z,\\varphi) = \\tilde n_{\\text{bath}}(R,Z,\\varphi)\\Theta_{\\alpha_p/2}(-\\rho_p(R, Z)-\\alpha_p/2) H(Z-Z_X)\n\\end{align}\n\\subsubsection{Zonal flows}\nWe can initialize the R-Z plane with zonal flows of amplitude $A$ and\nwavelength $k_\\psi$ aligned with the magnetic flux surfaces.\n\\begin{align} \\label{eq:initial_zonal_flow}\n    \\tilde n_{\\text{zonal}}(R,Z) &= A \\sin (2\\pi k_\\psi \\psi_p(R,Z)) \\nonumber\\\\\n\\tilde n_e(R,Z,\\varphi) &= \\tilde n_{\\text{zonal}}(R,Z)\\Theta_{\\alpha_p}\\left(-\\rho_p(R, Z)-\\frac{\\alpha_p}{2}\\right) H(Z-Z_X)\n\\end{align}\n\\subsubsection{Turbulence on Gaussian profile}\nInstead of the flux-aligned profile we can also choose a toroidally symmetric Gaussian profile\n\\begin{align} \\label{eq:profile_blob}\n  n_{prof}(R,Z) = n_0 + \\triangle n_{peak} \\exp\\left( -\\frac{(R - R_0 - p_x a)^2 + (Z-p_ya)^2}{\\sigma^2} \\right)\n\\end{align}\non top of which we can add the turbulent bath $\\tilde n_{\\text{bath}}$ and finally dampen it by\n\\begin{align}\\label{eq:turbulence_on_gaussian}\n    n_e(R,Z,\\varphi,0) = (n_{prof}(R,Z) + \\tilde n_{\\text{bath}})\\Theta_{\\alpha_p/2}\\left( 1- \\sqrt{(R-R_0)^2 + Z^2}/a\\right)\n\\end{align}\n\n\\subsection{Sinks and sources} \\label{sec:sources}\nWe can choose the source terms $S_N$ to either force a profile\n$n_{\\text{prof}}$ or provide a constant influx of particles in the\ncore of our domain, where our model does not apply.\nWe thus define a particle sink/source for electrons as\n\\begin{align} \\label{eq:electron_source}\n  S_{n_e}(R,Z,\\varphi, t) &= \\omega_s \\begin{cases}\n      (n_{prof}(R,Z) - n_e(R,Z,\\varphi, t))\\Theta_{\\alpha_p/2}\\left( \\rho_{p,s} - \\frac{\\alpha_p}{2} - \\rho_p(R,Z) \\right ) H(Z-Z_X) \\quad \\text{ forced}\\\\\n    S_{prof}(R,Z)\\quad \\text{ influx}\n    \\end{cases}\n\\end{align}\nwhere $\\omega_s$ is the source strength parameter. The shift of $\\Theta$ is chosen\nsuch that the source vanishes exactly outside $\\psi_{p,s}$.\nThe forced source will result in exponential adaption of the core\ndensity profile of the form $n_e \\propto n_{prof}+(n_{prof}-n_{e,0})e^{-\\omega_st}$.\n\nWe can choose the constant influx\n\\begin{align} \\label{eq:electron_source_influx}\n    S_{prof}(R,Z) &= \\Theta_{\\alpha_p/2}\\left( \\rho_{p,s} - \\frac{\\alpha_p}{2} - \\rho_p(R,Z) \\right) H(Z-Z_X)\n\\end{align}\nor a ringed Gaussian TCV source of the form\n\\begin{align}\n    S_{prof}(R,Z) &= \\exp\\left( -\\frac{(\\psi_p-\\psi_{p,0})^2}{\\sigma^2}\\right)H(Z-Z_X)\n\\end{align}\nwith $\\psi_{p,0} = \\psi_p(1075, -10)$ and $\\sigma = 0.0093\\psi_{p,0}/0.4$,\nor a Torpex inspired source profile\n\\begin{align} \\label{eq:electron_source_torpex}\n  S_{prof}(R,Z) &=\n  \\begin{cases}\n    \\exp\\left( - \\frac{(R-R_0)^2}{a^2 }- \\frac{(Z-Z_0)^2}{b^2}\\right) \\text{ if} R > R_0 \\\\\n    \\frac{1}{2}\\exp\\left( - \\frac{(R-R_0)^2}{a^2} -2c(R-R_0)(Z-Z_0)- \\frac{(Z-Z_0)^2}{b^2} \\right) \\\\\n  +\\frac{1}{2}\\exp\\left( - \\frac{(R-R_0)^2}{a^2} +2c(R-R_0)(Z-Z_0)- \\frac{(Z-Z_0)^2}{b^2} \\right) \\text{ else}\n              \\end{cases}\n\\end{align}\nwith $a=0.0335$m, $b=0.05$m, $c=565m^{-2}$, $R_0=0.98$m and $Z_0=-0.02$m.\n\n\nIn order to not generate potential with the source term the\nion source needs to fulfill $S_{n_e} = \\Gamma_{1,i}S_{N_i} + \\nc\\left( \\frac{\\mu_i S_{N_i}}{B^2}\\np \\phi\\right)$ which in the long wavelength limit can be inverted to (the long wavelength limit should be well-fulfilled for a realistic source term since the amplitude is typically quite small)\n\\begin{align}\n    S_{N_i} = \\left(1-\\frac{1}{2}\\mu_i \\tau_i \\Delta_\\perp\\right) S_{n_e} -\\nc\\left( \\frac{\\mu_i S_{n_e}}{B^2}\\np \\phi\\right)\n  \\label{eq:ion_source}\n\\end{align}\nNote that the additional terms besides $S_{n_e}$ are total divergences which means\nthey do not change the volume integrated \"total\" particle number created by the source.\nNote that $S_{n_e}$ needs to be smooth\nso that $\\np^2 S_{n_e}$ is well defined.\nAlso note that with our definition of $\\Lambda_{n_e}$ and $\\Lambda_{N_i}$ and\nthe polarisation equation we have $\\Lambda_{n_e} = \\Gamma_{1,i}\\Lambda_{N_i} + \\nc\\left( \\frac{\\mu_i \\Lambda_{N_i}}{B^2}\\np \\phi\\right)$ in the long wavelength limit (swap the operators).\nThis means that diffusion does not generate potential either.\n\n\n\\subsection{Implemented form}\nWe use a conservative form of the continuity equation\nin the perpendicular terms and else avoids derivatives on the product of two\nfunctions for which we have no boundary condition.\n\\begin{subequations}\n    \\begin{align}\n    \\frac{\\partial}{\\partial t} N =&\n    \\left[ - \\frac{1}{\\sqrt{g}} \\partial_i \\left( \\sqrt{g} N \\left( \\frac{\\epsilon^{ijk} b_j \\partial_k \\psi}{\\sqrt{g}B}\n    + \\tau K^i\n    + \\mu U_\\parallel^2 K_{\\vn\\times\\bhat}^i\n    + U_\\parallel\\left( A_\\parallel K_{\\vn\\times\\bhat}^i +\\frac{\\epsilon^{ijk} \\partial_j A_\\parallel b_k}{\\sqrt{g}B}   \\right)\n    \\right)\\right)\\right. \\nonumber\\\\\n    &\\left.- \\npar \\left( NU_\\parallel\\right)\n        - NU_\\parallel\\vec \\nc\\bhat\n        %\\frac{1}{B}[\\psi, N]_{\\perp} %\\nonumber\\\\\n        %- \\tau \\mathcal K(N)\\right. \\nonumber \\\\&\n        %\\left.\n        %- N \\mathcal K(\\psi)\n        %-\\mu \\mathcal K_{\\vn\\times\\bhat}(NU_\\parallel^2)\n        %-\\mu NU_\\parallel^2\\nc \\vec{ K_{\\vn\\times\\bhat}}\n    - \\nu_\\perp\\Delta_\\perp^2 N + S_N\\right]\n    (1-\\chi_s - \\chi_w) \\nonumber\\\\& + \\omega_s\\chi_s( N_{sh} - N) + \\omega_w \\chi_w (1-N), \\\\\n    \\frac{\\partial}{\\partial t} W_\\parallel =&\n  \\left[- \\frac{1}{B}\\left[\\psi, U_\\parallel\\right]_{\\perp}%& \\nonumber\\\\\n        - \\frac{1}{\\mu} \\bar \\npar \\psi% \\nonumber\\\\\n        - \\frac{1}{2}\\bar \\npar U_\\parallel^2\n        -\\frac{\\tau}{\\mu} \\bar \\npar \\ln N\n        - U_\\parallel\\mathcal K_{\\vn\\times\\bhat}(\\psi)\n        - \\tau \\mathcal K(U_\\parallel)\n        -\\tau U_\\parallel\\nc\\vec{ K_{\\vn\\times\\bhat}}\n    \\right.\n        \\nonumber\\\\&\n    \\left.- \\left(2\\tau + {\\mu}U_\\parallel^2\\right) \\mathcal K_{\\vn\\times\\bhat} (U_\\parallel)\n        -2\\tau U_\\parallel\\mathcal K_{\\vn\\times\\bhat}(\\ln N)\n        - \\frac{\\eta}{\\mu} \\frac{n_e}{N}n_e(U_{\\parallel,i} - u_{\\parallel,e})\n    \\right.\\nonumber\\\\&\n    \\left.+ \\frac{\\nu_\\parallel}{N} \\Delta_\\parallel U_\\parallel - \\nu_\\perp\\Delta_\\perp^2 U_\\parallel\n    + S_U\\right]\n    (1-\\chi_s - \\chi_w) + \\omega_s\\chi_s ( U_{\\parallel}^{sh} - U_\\parallel) -\\omega_w \\chi_wU_\\parallel\n    ,\n        \\label{eq:EgyrofluidU} \\\\\n        W_\\parallel&:= \\left( U_\\parallel + \\frac{A_\\parallel}{\\mu}\\right)\n    \\end{align}\n    \\label{eq:Egyrofluid}\n\\end{subequations}\ntogether with\n$\\bar\\npar f = \\npar f + A_\\parallel \\mathcal K_{\\vn\\times\\bhat}(f) + \\frac{1}{B}[ f, A_\\parallel]_\\perp$\n%and $\\nc { \\vec b}_\\perp = A_\\parallel \\vec \\nc\\vec{ { K}_{\\vn\\times\\bhat}} - \\mathcal K_{\\vn B}(A_\\parallel) $\nand\n\\begin{subequations} \\label{eq:elliptic}\n  \\begin{align}\n    -\\nc\\left( \\frac{N_i}{B^2}\\np \\phi \\right) &= \\Gamma_{1,i} N_i - n_e, \\quad\\quad\n    \\Gamma_{1,i}^{-1} = 1-\\frac{1}{2}\\tau_i\\mu_i \\Delta_\\perp \\\\\n    \\psi_e = \\phi, \\quad \\psi_i &= \\Gamma_{1,i}\\phi -\\frac{\\mu_i}{2}\\frac{(\\np\\phi)^2}{B^2} \\\\\n    \\left(\\frac{\\beta}{\\mu_i}N_i - \\frac{\\beta}{\\mu_e}n_e-\\Delta_\\perp\\right)\n    A_\\parallel &= \\beta\\left(N_iW_{\\parallel,i}-n_e w_{\\parallel,e}\\right)\n  \\end{align}\n\\end{subequations}\n\\begin{tcolorbox}[title=Note]\nThe negative signs make the operators in Eqs.~\\eqref{eq:elliptic} positive definite.\n\\end{tcolorbox}\n\nIn the output file we have\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} & \\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    electrons &$n_e$ &\n    ions &$N_i$ \\\\\n    Ue &$u_{\\parallel,e}$ &\n    Ui &$U_{\\parallel,i}$ \\\\\n    potential &$\\phi$ &\n    psi &$\\psi$ \\\\\n    induction &$A_\\parallel$ & \\\\\n\\bottomrule\n\\end{longtable}\n\\subsection{ Scale invariance}\n\\subsubsection{Sign reversals of the magnetic field}\\label{sec:field_reversal}\nIf we change the direction of the magnetic field vector $\\bhat$, we immediately see that all perpendicular\ndrifts and $U_\\parallel\\bhat$ change directions. On the other side, the diffusive and resistive terms remain unchanged.\nWithout resistivity and diffusion a change in direction of the magnetic field thus corresponds to\na time reversal $t\\rightarrow t'=-t$.\nIn the code $\\bhat$ changes sign by using both $-\\mathcal P_\\psi$ and $-\\mathcal P_I$.\n\nAlso note that changing the sign of the magnetic field only in the parallel derivatives $\\npar \\rightarrow -\\npar$ does not\nhave any effect. This can be seen by simply renormalizing $U_\\parallel'=-U_\\parallel$. This reverts the equations back to the original equations.\n\\subsubsection{Scaling of density}\nIf $N, U_\\parallel, \\phi, A_\\parallel$ are a solution to the model equations\nthen so are $N'=\\alpha N$, $U_\\parallel'=U_\\parallel$, $\\phi'=\\phi$ and $A_\\parallel'=A_\\parallel$ with the changed parameters $S_N' = \\alpha S_N$, $\\eta' = \\eta/\\alpha$ and $ \\beta' = \\beta/\\alpha$. If $N$\nhas a Dirichlet boundary condition, then $N'$ satisfies a correspondingly scaled boundary condition.\n\\subsubsection{Helicity}\nThe standard helicity of the magnetic field would be a right handed screw,\nwhere the magnetic field and the toroidal plasma current point in the clockwise\ndirection if the tokamak is seen from above.\nThe helicity should however not have any influence on the plasma dynamics. With\na mirror transformation (view the tokamak in a mirror) we should be able\nto transform the solution to one with reversed helicity.\n\n\\subsection{Conservation laws} \\label{sec:conservation}\n\\subsubsection{Mass conservation}\nThe density equations directly yield the particle conservation\n\\begin{align} \\label{eq:mass_theorem}\n  \\frac{\\partial}{\\partial t} N\n  + \\nc\\vec{ j_{N}}\n  =  \\Lambda_{N}+S_{N}\n\\end{align}\nThe terms of the particle conservation thus read\n\\begin{align}\n  N= & N,\\\\\n  \\vec j_{N} =& N\\left(\n  \\vec u_\\psi + \\vec u_C + \\vec u_{K} +U_\\parallel\\left(\\bhat+{\\vec b}_\\perp\\right)  \\right)\n\\label{eq:particle_flux}\\\\\n  %\\nonumber\\\\\n  %=& N \\left(\\frac{\\bhat\\times \\vn\\phi}{B}\n  %+ \\tau_e \\frac{\\bhat\\times\\vn n_e}{n_eB}\n  %+ \\mu_e u_{\\parallel,e}^2\\vec K_{\\vn\\times\\bhat}\n  %+ u_{\\parallel,e}(\\bhat + {\\vec b}_\\perp) \\right), \\\\\n  \\Lambda_{N} =&\n  \\nu_\\perp\\Delta_\\perp N% + \\nu_\\parallel\\Delta_\\parallel N\n\\\\\n  S_{N} =&  S_{N}\n\\end{align}\nNotice that\n\\begin{align}\n\\tau N \\vec K = \\tau N\\vn\\times\\frac{\\bhat}{B} = \\tau \\vn\\times N\\frac{\\bhat}{B} + \\tau \\frac{\\bhat\\times\\vn N}{B}\n\\label{}\n\\end{align}\nsuch that we can define the diamagnetic flux in the particle flux since\nthe rotation vanishes under the divergence.\n\nWe here also derive the particle flux \\eqref{eq:particle_flux} through a flux surface\n\\begin{align} \\label{eq:radial_particle_flux}\n \\vec j_{N}\\cn v %=& N\\left( \\vec u_E + \\vec u_C + \\vec u_{\\vn\n %B} + U_\\parallel \\left(\\bhat + {\\vec b}_\\perp\\right)\\right) \\cn \\psi_p \\nonumber\\\\\n =&\n  \\frac{\\d v}{\\d \\psi_p} N\\left[\\frac{1}{B}[\\psi, \\psi_p]_\\perp + \\left(\\tau + \\mu U_\\parallel^2\\right)\n   \\mathcal K_{\\vn\\times\\bhat}(\\psi_p) + \\tau  \\mathcal K_{\\vn B}(\\psi_p) \\right] \\nonumber\\\\\n &+ NU_\\parallel\\frac{\\d v}{\\d \\psi_p}\\left [\\left( A_\\parallel \\mathcal\n K_{\\vn\\times\\bhat}(\\psi_p) + \\frac{1}{B}[\\psi_p, A_\\parallel]_\\perp\\right) \\right]\n\\end{align}\n\nThe relevant terms in the output file are\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} & \\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    electrons & $n_e$ &\n    jsneC\\_tt &$ n_e ( \\vec u_K + \\vec u_C )\\cn \\psi_p$ \\\\\n    jsneA\\_tt &$ n_e u_{\\parallel,e} \\vec{ b}_\\perp  \\cn \\psi_p$ &\n    jsneE\\_tt & $ n_e \\vec u_E\\cn\\psi_p$ \\\\\n    lneperp\\_tt &$ \\Lambda_{\\perp,n_e} = \\nu_\\perp \\Delta_\\perp n_e$ or $-\\nu_\\perp \\Delta^2_\\perp n_e$ &\n    & \\\\\n    %lneparallel\\_tt &$ \\Lambda_{\\parallel,n_e} = \\nu_\\parallel \\Delta_\\parallel n_e$ \\\\\n    sne\\_tt & $S_{n_e}$ &\n    jsdiae\\_tt & $\\tau_e \\bhat \\times \\vn n_e \\cn \\psi_p /B$\\\\\n    dnepar\\_tt & $\\nc (\\bhat n_e u_{e,\\parallel}$) &\n    & \\\\\n    ions & $N_i$ &\n    jsniC\\_tt &$ N_i ( \\vec u_K + \\vec u_C )\\cn \\psi_p$ \\\\\n    jsniA\\_tt &$ N_i U_{\\parallel,i} \\vec{ b}_\\perp  \\cn \\psi_p$ &\n    jsniE\\_tt & $ N_i \\vec u^i_E\\cn\\psi_p$ \\\\\n    lniperp\\_tt &$ \\Lambda_{\\perp,N_i} = \\nu_\\perp \\Delta_\\perp N_i$ or $-\\nu_\\perp \\Delta^2_\\perp N_i$ &\n    & \\\\\n    %lniparallel\\_tt &$ \\Lambda_{\\parallel,N_i} = \\nu_\\parallel \\Delta_\\parallel N_i$ \\\\\n    sni\\_tt & $S_{N_i}$ &\n    jsdiai\\_tt & $\\tau_i \\bhat \\times \\vn N_i \\cn \\psi_p /B$\\\\\n    dnipar\\_tt & $\\nc (\\bhat N_i U_{i,\\parallel}$) &\n      & \\\\\n\\bottomrule\n\\end{longtable}\n\n\n\nNote that the parallel divergences vanish exactly under a flux-surface average. This can serve as a numerical test of our implementation.\n\\subsubsection{Energy theorem}\nThe terms of the energy theorem are\n\\begin{align} \\label{eq:energy_theorem}\n\\partial_t \\mathcal E +\n\\nc \\vec j_{\\mathcal E}\n= \\Lambda_{\\mathcal E}\n+  S_{\\mathcal E}\n+  R_{\\mathcal E}\n\\end{align}\nwith ( $z_e=-1$ and $z_i=+1$) and $\\vec u_E := {\\bhat\\times \\vn\\phi}/{B}$\n\\begin{align} \\label{eq:energy_conservation}\n  \\mathcal{E}= & z_e\\tau_e n_e \\ln{(n_e)} +z_i\\tau_i N_i\\ln{(N_i)}\n  +\\frac{1}{2\\beta}\\left(\\np A_\\parallel\\right)^2\n   +  \\frac{1}{2} z_i \\mu_i N_i u_E^2  \\nonumber\\\\\n   & +\\frac{1}{2} z_e\\mu_e  n_e u_{\\parallel,e}^2\n  +\\frac{1}{2} z_i\\mu_i  N_i U_{\\parallel,i}^2,\\\\\n  \\vec j_{\\mathcal E} =& \\sum_s z\\left[\n  \\left(\\tau \\ln N + \\frac{1}{2}\\mu U_\\parallel^2 + \\psi \\right)N\\left(\n  \\vec u_E + \\vec u_C + \\vec u_{K} +U_\\parallel\\left(\\bhat+{\\vec b}_\\perp\\right)  \\right) \\right]\n  \\nonumber\\\\\n  &+ \\sum_z z\\left[\\mu \\tau NU_\\parallel^2\\vec K_{\\vn\\times\\bhat} + \\tau NU_\\parallel \\left(\\bhat + {\\vec b}_\\perp\\right)\\right], \\\\\n  \\Lambda_{\\mathcal E} =&  \\sum_s z\\left[\\left( \\tau\\left( 1+\\ln{N}\\right) + \\psi + \\frac{1}{2} \\mu U_\\parallel^2 \\right)\n  \\left(\\nu_\\perp\\Delta_\\perp N \\right)  +  \\mu NU_\\parallel\\left(\\nu_\\perp\\Delta_\\perp U_\\parallel + \\nu_\\parallel\\Delta_\\parallel U_\\parallel\\right) \\right]\n\\nonumber \\\\\n  S_{\\mathcal E} =&  \\sum_s  z\\left[ \\left(\\tau\\left( 1+\\ln{N}\\right) +\\psi + \\frac{1}{2} \\mu U_\\parallel^2 \\right)S_{N}\\right]\n\\nonumber \\\\\n  R_{\\mathcal E} =&  -\\eta_\\parallel  \\left[ n_e(U_{\\parallel,i}-u_{\\parallel,e})\\right]^2.\n\\end{align}\nwhere in the energy flux $\\vec j_{\\mathcal E}$\nwe neglect terms  containing time derivatives\nof the eletric and magnetic potentials and we sum over all species.\nThe energy density $\\mathcal E$ consists of the Helmholtz free energy density for electrons and ions,\nthe \\(\\vec{E} \\times \\vec{B}\\) energy density, the parallel energy densities for electrons and ions and the perturbed magnetic field energy density.\nIn \\(\\Lambda\\) we insert the dissipative terms of Section~\\ref{sec:dissres}. \\\\\nReplace $\\Delta_\\perp$ with $-\\Delta_\\perp^2$ when hyperviscous diffusion is chosen\nfor the diffusion terms in the above equations.\n\nWe have the energy flux through a flux surface\n\\begin{align}\n \\vec j_{\\mathcal E}\\cn v =&%\\frac{\\d v}{\\d \\psi_p} \\vec j_{\\mathcal E}\\cn \\psi_p  =\n\\frac{\\d v}{\\d \\psi_p}\\sum_s z\\left (\\tau\\ln N + \\frac{1}{2}\\mu U_\\parallel^2 + \\psi\\right) \\vec j_N\\cn\\psi_p\n+ z \\mu\\tau NU_\\parallel^2 \\mathcal K_{\\vn\\times\\bhat}(\\psi_p) \\nonumber\\\\\n&+ z \\tau NU_\\parallel\n \\left( A_\\parallel \\mathcal\n K_{\\vn\\times\\bhat}(\\psi_p) + \\frac{1}{B}[\\psi_p, A_\\parallel]_\\perp\\right)\n\\label{eq:energy_flux}\n\\end{align}\nThe relevant terms in the output file are\n\\begin{longtable}{ll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    nelnne &$ z_e\\tau_e n_e \\ln n_e$ \\\\\n    nilnni &$ z_i\\tau_i N_i \\ln N_i$ \\\\\n    aperp2 &$ (\\np A_\\parallel)^2/2/\\beta$ \\\\\n    ue2   &$z_i\\mu_i N_i u_E^2 /2$ \\\\\n    neue2 &$ z_e\\mu_e n_e u_{\\parallel,e}^2/2$ \\\\\n    niui2 &$ z_i\\mu_i N_i U_{\\parallel,i}^2/2$ \\\\\n    see\\_tt & $z_e(\\tau_e (1+\\ln n_e) + \\phi + \\frac{1}{2}\\mu_e u_{\\parallel,e}^2) S_{n_e} $ \\\\\n    sei\\_tt & $z_i(\\tau_i (1+\\ln N_i) + \\psi + \\frac{1}{2}\\mu_i U_{\\parallel,i}^2) S_{N_i} $ \\\\\n    resistivity\\_tt &-$\\eta_\\parallel n_e^2 (U_{\\parallel,i}-u_{\\parallel,e})^2$ \\\\\n    jsee\\_tt &$z_e(\\tau_e \\ln n_e + \\mu_e u_{\\parallel,e}^2/2 + \\phi)n_e(\\vec u_E + \\vec u_C + \\vec u_K)\\cn \\psi_p\n        + z_e \\tau_e n_e u_{\\parallel,e}^2 \\vec K_{\\vn\\times\\bhat}\\cn \\psi_p$ \\\\\n    jsei\\_tt &$z_i(\\tau_i \\ln N_i + \\mu_i U_{\\parallel,i}^2/2 + \\psi_i)N_i(\\vec u_E^i + \\vec u_C + \\vec u_K)\\cn \\psi_p\n        + z_i \\tau_i N_i U_{\\parallel,i}^2 \\vec K_{\\vn\\times\\bhat}\\cn \\psi_p$ \\\\\n    jseea\\_tt &$z_e(\\tau_e \\ln n_e + \\mu_e u_{\\parallel,e}^2 + \\phi)n_e \\vec { b}_\\perp\\cn \\psi_p\n        + z_e \\tau_e n_e u_{\\parallel,e} \\vec{ b}_\\perp \\cn \\psi_p $ \\\\\n    jseia\\_tt &$z_i(\\tau_i \\ln N_i + \\mu_i U_{\\parallel,i}^2 + \\psi_i)N_i \\vec { b}_\\perp\\cn \\psi_p\n        + z_i \\tau_i N_i U_{\\parallel,i} \\vec{ b}_\\perp \\cn \\psi_p $ \\\\\n    leeperp\\_tt &$z_e(\\tau_e(1+\\ln n_e) + \\phi + \\mu_eu_{\\parallel,e}^2/2) \\nu_\\perp \\Delta_\\perp n_e + z_e\\mu_e n_e u_{\\parallel,e} \\nu_\\perp \\Delta_\\perp u_{\\parallel,e}$ \\\\\n    leiperp\\_tt &$z_i(\\tau_i(1+\\ln N_i) + \\psi_i + \\mu_iU_{\\parallel,i}^2/2) \\nu_\\perp \\Delta_\\perp N_i + z_i\\mu_i N_i U_{\\parallel,i} \\nu_\\perp \\Delta_\\perp U_{\\parallel,i}$ \\\\\n    leeparallel\\_tt & %$z_e(\\tau_e(1+\\ln n_e) + \\phi + \\mu_eu_{\\parallel,e}^2/2) \\nu_\\parallel \\Delta_\\parallel n_e +$\n    $z_e\\mu_e n_e u_{\\parallel,e} \\nu_{\\parallel,e} \\Delta_\\parallel u_{\\parallel,e}$ \\\\\n    leiparallel\\_tt & %$z_i(\\tau_i(1+\\ln N_i) + \\psi_i + \\mu_iU_{\\parallel,i}^2/2) \\nu_\\parallel \\Delta_\\parallel N_i + $\n    $z_i\\mu_i N_i\n    U_{\\parallel,i} \\nu_{\\parallel,i} \\Delta_\\parallel U_{\\parallel,i}$ \\\\\n\\bottomrule\n\\end{longtable}\n\n\\subsubsection{Toroidal ExB angular momentum equation} \\label{sec:vorticity_eq}\nWe integrate the polarisation equation over volume, multiply by $\\d \\psi_p/\\d v$ and derive by time. In the drift-ordering up to order $\\mathcal O(\\delta^3)$ we get\n\\begin{align}\n    &\\partial_t \\RA{\\Omega} + \\frac{\\partial}{\\partial v}\\frac{\\d v}{\\d\\psi_p}\\RA{\\vec j_\\Omega\\cn\\psi_p} = -\\RA{F_{L,\\varphi}} + \\RA{\\mathcal S_\\Omega} \\label{eq:vorticity_average} \\\\\n\\Omega &:= \\mu_i N_i \\left(\\frac{\\vn\\psi_p\\cn\\phi}{B^2} + \\tau_i \\vn\\ln N_i\\cn\\psi_p\\right) \\equiv \\mu_i N_i(u_{E,\\varphi} + u_{D,\\varphi}) \\\\\n\\vec j_{\\Omega} &:= \\Omega \\vec u_E\n    - \\left(\\frac{1}{\\beta} \\vn\\psi_p \\cn A_\\parallel +\\frac{1}{2}\\tau_i \\vn\\psi_p\\cn  (N_iU_{\\parallel,i})\\right)\\frac{\\bhat\\times\\vn A_\\parallel}{B} \\\\\n    F_{L,\\varphi} &:=  -(z_e \\tau_e n_e + z_i\\tau_i N_i)\\mathcal K(\\psi_p) - (z_e\\mu_e n_eu_{\\parallel,e}^2 + z_i\\mu_i N_iU_{\\parallel,i}^2)\\mathcal K_{\\vn\\times\\bhat}(\\psi_p) \\\\\n    \\mathcal S_\\Omega &:= \\mu_i S_{n_e} \\frac{\\vn\\psi_p\\cn \\phi}{B^2} + \\mu_i\\tau_i\\vn\\psi_p\\cn S_{n_e} \\label{eq:em_source}\n\\end{align}\nEquation~\\eqref{eq:vorticity_average} can be rewritten by inserting the continuity equation to yield an equation only for the \\ExB angular momentum. Again up to order $\\mathcal O(\\delta^3)$ in the drift ordering we obtain\n(the diffusive term is for testing purposes)\n\\begin{align}\n&\\partial_t \\RA{\\Omega_E} + \\frac{\\partial}{\\partial v} \\frac{\\d v}{\\d \\psi_p}\\RA{ \\vec j_{\\Omega_E}\\cn\\psi_p} = -\\RA{F_{L,\\varphi}}+ \\RA{\\mathcal S_{\\Omega_E}} + \\RA{\\Lambda_{\\Omega_E}} \\label{eq:exb_average} \\\\\n\\Omega_E &:= \\mu_i N_i \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\equiv \\mu_i N_i u_{E,\\varphi} \\\\\n\\vec j_{\\Omega_E} &:= \\Omega_E (\\vec u_E + \\vec u_D)\n    - \\vn A_\\parallel\\cn\\psi_p \\left(\\frac{1}{\\beta} \\frac{\\bhat\\times\\vn A_\\parallel}{B} +\\frac{1}{2} \\bhat \\times \\vn \\mu_i \\tau_i N_iU_{\\parallel,i}\\right) \\\\\n    \\mathcal S_{\\Omega_E} &:= \\mu_i S_{n_e} \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\quad\n    \\Lambda_{\\Omega_E} := \\mu_i \\Lambda_{n_e}\\frac{\\vn\\psi_p\\cn\\phi}{B^2}\n\\end{align}\nwhere here we also monitor the source and diffusion terms.\nIn the output file we have\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation}&\n\\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    oexbe &$\\mu_i n_e \\frac{\\vn\\psi_p\\cn\\phi}{B^2}$ &\n    oexbi &$\\mu_i N_i \\frac{\\vn\\psi_p\\cn\\phi}{B^2}$ \\\\\n    odiae &$\\mu_i \\tau_i\\vn\\psi_p\\cn n_e$ &\n    odiai &$\\mu_i \\tau_i\\vn\\psi_p\\cn N_i$ \\\\\n    jsoexbi\\_tt &$\\mu_i N_i \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\frac{\\bhat\\times\\vn\\phi\\cn \\psi_p}{B}$ &\n    jsoexbe\\_tt &$\\mu_i n_e \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\frac{\\bhat\\times\\vn\\phi\\cn \\psi_p}{B}$ \\\\\n    jsodiaiUE\\_tt &$\\mu_i \\tau_i\\vn\\psi_p\\cn N_i \\frac{\\bhat\\times\\vn\\phi\\cn \\psi_p}{B}$ &\n    jsodiaeUE\\_tt &$\\mu_i \\tau_i\\vn\\psi_p\\cn n_e \\frac{\\bhat\\times\\vn\\phi\\cn \\psi_p}{B}$ \\\\\n    jsoexbiUD\\_tt &$\\mu_i\\tau_i \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\frac{\\bhat\\times\\vn N_i\\cn \\psi_p}{B}$ &\n    jsoexbeUD\\_tt &$\\mu_i\\tau_i \\frac{\\vn\\psi_p\\cn\\phi}{B^2} \\frac{\\bhat\\times\\vn n_e\\cn \\psi_p}{B}$ \\\\\n    jsoapar\\_tt &$ -\\vn\\psi_p\\cn A_\\parallel \\frac{\\bhat\\times\\vn A_\\parallel\\cn \\psi_p}{B\\beta}$ &\n    jsodiaApar\\_tt & $ -\\frac{1}{2}\\tau_i \\vn\\psi_p\\cn  (N_iU_{\\parallel,i})\\frac{\\bhat\\times\\vn A_\\parallel}{B}\\cn\\psi_p$ \\\\\n    jsoexbApar\\_tt & $ -\\frac{1}{2}\\tau_i \\bhat\\times\\vn  (N_iU_{\\parallel,i})\\cn\\psi_p \\vn A_\\parallel\\cn\\psi_p$ &\n    socurve\\_tt &$z_e\\tau_e n_e \\mathcal K(\\psi_p)$ \\\\\n    socurvi\\_tt &$z_i\\tau_i N_i \\mathcal K(\\psi_p)$ &\n    socurvkappae\\_tt &$z_e\\mu_e n_eu_{\\parallel,e}^2 \\mathcal K_{\\vn\\times\\bhat}(\\psi_p)$ \\\\\n    socurvkappai\\_tt &$z_i\\mu_i N_iU_{\\parallel,i}^2 \\mathcal K_{\\vn\\times\\bhat}(\\psi_p)$ & \\\\\n    sosne\\_tt & $\\mu_i S_{n_e} \\vn\\psi_p\\cn\\phi/B^2$ &\n    sospi\\_tt & $\\mu_i \\tau_i \\vn\\psi_p \\cn S_{n_e}$\\\\\n    loexbe\\_tt & $ \\mu_i \\Lambda_{n_e} \\vn\\psi_p\\cn\\phi/B^2$ & \\\\\n\\bottomrule\n\\end{longtable}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Parallel momentum balance}\nThe flux surface average over the parallel momentum equation under species summation  yields up to order $\\mathcal O(\\delta^3)$ in the drift-ordering\n\\begin{align}\n  \\frac{\\partial}{\\partial t}\\RA{\\mu_iN_iU_{\\parallel,i} }\n    % \\nonumber\\\\\n    + \\frac{\\partial}{\\partial v} \\frac{\\d v}{\\d\\psi_p} \\RA{\\mu_iN_iU_{\\parallel,i} \\frac{\\bhat\\times\\vn\\phi}{B}\\cn\\psi_p + \\sum_s (z_s\\tau_sN_s + z_s\\mu_s N_sU_{\\parallel,s}^2) b_{\\perp}^{\\;v}  }\n    \\nonumber\\\\\n   = \\sum_s\\RA{-z_s\\tau_s N_s\\npar \\ln B} + \\mu_i \\RA{ S_{N_i} U_{\\parallel,i} + N_i S_{U_\\parallel}}\n   \\label{eq:parallel_momentum}\n\\end{align}\nwhile the toroidal parallel angular momentum contribution reads up to order $\\mathcal O(\\delta^3)$\n\\begin{align}\\label{eq:parallel_momentum_direction}\n    \\frac{\\partial}{\\partial t}  \\RA{\\mu_iN_iU_{\\parallel,i} b_\\varphi}\n    + \\frac{\\partial}{\\partial v} \\frac{\\d v}{\\d\\psi_p} \\RA{\\mu_iN_iU_{\\parallel,i} b_\\varphi\\frac{\\bhat\\times\\vn\\phi}{B}\\cn\\psi_p + \\sum_s (z_s\\tau_s N_s + z_s\\mu_sN_sU_{\\parallel,s}^2) b_\\varphi b_{\\perp}^{\\;v} }\n    \\nonumber\\\\\n    = \\RA{F_{L,\\varphi}} + \\mu_i \\RA{ (S_{N_i} U_{\\parallel,i} + N_i S_{U_\\parallel}) b_\\varphi}\n\\end{align}\n\nThe relevant terms in the output file are (the Lorentz force term is described in the previous subsection \\ref{sec:vorticity_eq})\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} &\n\\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    neue &$n_e u_{\\parallel,e}$ &\n    niui &$\\mu_i N_i U_{\\parallel,i}$ \\\\\n    neuebphi &$n_eu_{\\parallel,e}b_\\varphi$ &\n    niuibphi &$\\mu_i N_iU_{\\parallel,i}b_\\varphi$ \\\\\n    jsparexbi\\_tt       & $\\mu_i N_iU_{\\parallel,i}(\\bhat\\times\\vn\\phi)\\cn \\psi_p/B$ &\n    jsparbphiexbi\\_tt   & $\\mu_i N_iU_{\\parallel,i}b_\\varphi(\\bhat\\times\\vn\\phi)\\cn \\psi_p/B$ \\\\\n    jspardiai\\_tt       & $\\mu_i \\tau_i N_iU_{\\parallel,i}\\vec K\\cn\\psi_p$ &\n    jsparbphdiai\\_tt   & $\\mu_i \\tau_i N_iU_{\\parallel,i}b_\\varphi\\vec K\\cn\\psi_p$ \\\\\n    jsparkappai\\_tt       & $\\mu_i N_iU_{\\parallel,i} ( \\mu_i U_{\\parallel,i}^2 + 2\\tau_i)\\vec K_{\\vn\\times \\bhat}\\cn\\psi_p$ &\n    jsparbphikappai\\_tt       & $\\mu_i N_iU_{\\parallel,i}b_\\varphi ( \\mu_i U_{\\parallel,i}^2 + 2\\tau_i)\\vec K_{\\vn\\times \\bhat}\\cn\\psi_p$ \\\\\n    jsparApar\\_tt       & $\\sum_s (z_s \\tau_s N_s + z_s \\mu_s N_s U_{\\parallel,s}^2)b_\\perp^v$ &\n    jsparbphiApar\\_tt   & $\\sum_s (z_s \\tau_s N_s + z_s \\mu_s N_s U_{\\parallel,s}^2)b_\\varphi b_\\perp^v$ \\\\\n    sparmirrore\\_tt & $-z_e\\tau_en_e\\npar \\ln B$ &\n    sparmirrori\\_tt & $-z_i\\tau_iN_i\\npar \\ln B$ \\\\\n    sparsni\\_tt & $\\mu_i S_{N_i} U_{\\parallel,i} + \\mu_i S_{U_i} N_i $ &\n    sparsnibphi\\_tt & $\\mu_i S_{N_i} U_{\\parallel,i}b_\\varphi + \\mu_i S_{U,i} N_i b_\\varphi $ \\\\\n    lparpar\\_tt   & $\\nu_{\\parallel,i} \\Delta_\\parallel U_{\\parallel,i}$ &\n    lparperp\\_tt & $-\\nu_\\perp U_{\\parallel,i} \\Delta_\\perp^2 N_i - \\nu_\\perp N_i\\Delta_\\perp^2 U_{\\parallel,i} $ \\\\\n\\bottomrule\n\\end{longtable}\nNote that the parallel viscosity term vanishes exactly under the flux-surface average. This can serve as a numerical test.\n\n\\subsubsection{Parallel electron force balance}\nWe gather the dominant terms in the electron momentum equation (neglecting all terms as $\\mu_e=0$). This leaves the parallel force balance\n\\begin{align}\n    -(\\bhat + \\vec b_\\perp) \\cn n_e +n_e\\left( \\left( \\bhat + \\vec b_\\perp \\right) \\cn \\phi + \\frac{\\partial A_\\parallel}{\\partial t} \\right) +\\eta n_e^2 \\left( U_{\\parallel,i} - u_{\\parallel,e}\\right) = 0\n\\end{align}\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} &\n\\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    sparphie\\_tt & $n_e\\npar \\phi$ &\n    friction\\_tt & $ \\eta n_e^2(U_{\\parallel,i}-u_{\\parallel,e})$ \\\\\n    sparmirrore\\_tt & $-\\npar n_e$ &\n    sparmirrorAe\\_tt & $-\\vn A_\\parallel \\times \\bhat \\cn n_e /B$ \\\\\n    sparphiAe\\_tt & $n_e \\vn A_\\parallel \\times \\bhat \\cn \\phi /B$ &\n    spardotAe\\_tt & $ n_e \\partial A_\\parallel /\\partial t$ \\\\\n\\bottomrule\n\\end{longtable}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\subsubsection{Zonal flow energy}\n\\begin{align}\n    E_\\mathrm{zonal} = \\frac{1}{2}\\RA{\\rho_M}\\FA{ \\iota^{-2}\\mathcal I^{\\vartheta\\vartheta} + 2\\iota^{-1}\\mathcal I^{\\vartheta\\varphi} + \\mathcal I^{\\varphi\\varphi}} \\FA{u_{E,\\varphi}}^2\n    \\equiv \\frac{1}{2} \\RA{\\rho_M} \\FA{u_{E,\\varphi}}^2  \\FA{\\mathcal I_0}\n    \\label{eq:zonal_energy}\n\\end{align}\nFor symmetry flux coordinates we have $g_{\\vartheta\\vartheta} = R^2 (\\vn\\psi_p)^2/I^2\\iota^2$, $g_{\\varphi\\vartheta} =0$ and $g_{\\varphi\\varphi}=R^2$ and thus $\\mathcal I_0 = R^{-2}( 1 + I^2/|\\vn\\psi_p|^2)= B^2 / |\\vn\\psi_p|^2$.\n\\begin{align}\\label{eq:perp_kinetic}\n      \\frac{\\partial}{\\partial t}E_{\\mathrm{zonal}} +\\frac{\\partial}{\\partial v } \\left(E_{\\mathrm{zonal}}\\FA{u^v} \\right)\n  =&-\\FA{\\mathcal I_0}\\FA{u_{E,\\varphi}}\\left(\\frac{\\partial }{\\partial v}  \\Theta_{\\varphi}^{\\; v} + \\RA{(\\vec j_f\\times\\vec B)_\\varphi}\\right)\n  \\nonumber\\\\\n    &-\\frac{1}{2}\\FA{u_{E,\\varphi}}^2\\frac{\\partial}{\\partial v}\\left(\\RA{\\rho_M}\\FA{\\FF{\\mathcal I_0}\\FF{u^v}}\\right)\n     + \\mathcal S_{\\mathrm{zonal}}\n\\end{align}\nwhere we neglected the term $\\RA{n\\vec u\\cn \\mathcal I_0}$ in the continuity equation as small in our ordering\n and we have\n \\begin{align}\n \\mathcal S_{\\mathrm{zonal}} :=& \\FA{\\mathcal I_0} \\FA{u_{E,\\varphi}} \\mathcal S_{u_{E,\\varphi}} + \\frac{1}{2}\\FA{u_{E,\\varphi}}^2  \\RA{mS_n\\mathcal I_0}\n%  \\nonumber\\\\\n \\label{eq:zonal_source}\n \\end{align}\n and in the output file\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} &\n\\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    nei0 &$n_e \\mathcal I_0$ &\n    snei0\\_tt & $S_{n_e } \\mathcal I_0$ \\\\\n\\bottomrule\n\\end{longtable}\n\n\\subsection{Manufactured Solution}\nIn order to test the implementation we manufacture a solution to Eqs.~\\eqref{eq:Egyrofluid} and \\eqref{eq:elliptic} of the form\n\\begin{align*}\nn_e(R,Z,\\varphi, t) &:= 1 + 0.5\\sin(\\pi(R-R_0))\\sin(\\pi Z)\\sin(\\varphi)\\sin(\\pi t) \\\\\nN_i(R,Z,\\varphi, t) &:= n_e(R,Z,\\varphi,t) = \\gamma_{ N_i}  \\\\\nu_{\\parallel,e}(R,Z,\\varphi, t) &:= \\sin(2\\pi(R-R_0))\\sin(2\\pi Z)\\sin(2\\varphi)\\sin(2\\pi t)/(3\\sqrt{-\\mu_e}) \\\\\nU_{\\parallel,i}(R,Z,\\varphi, t) &:= \\sqrt{-\\mu_e}u_{\\parallel,e}(R,Z,\\varphi,t) \\\\\n\\phi(R,Z,\\varphi,t) &:= \\sin(3\\pi(R-R_0))\\sin(3\\pi Z)\\sin(3\\varphi)\\sin(3\\pi t)/5; \\\\\n\\psi(R,Z,\\varphi,t) &:= \\phi(R,Z,\\varphi, t) = \\gamma_{\\phi} \\\\\nA_\\parallel( R,Z,\\varphi,t) &:= \\beta\\sin(4\\pi(R-R_0))\\sin(4\\pi Z)\\sin(4\\varphi)\\sin(4\\pi t)/4;\n\\end{align*}\nWe choose circular flux surfaces of the form\n\\begin{align*}\n\\psi_p(R,Z) :=0.5((R-R_0)^2 + Z^2),\\quad\nI_p(R,Z):=I_0\n\\end{align*}\nwith $R_0=10$ and $I_0=20$ and a simulation box $[R_0-a,R_0+a]\\times[-a,a]\\times[0,2\\pi]$.\nWe then symbolically compute (with the help of Mathematica) source terms that we insert to the right hand side of\nthe corresponding equation in code (\\texttt{manufactured.h}) and simulate from $t=0...10^{-3}$.\nBy comparing the numerical solution to the manufactured one we can observe the convergence of our numerical methods. Note that in order to better distinguish\nthe convergence of the DG discretized terms from our parallel derivative\nwe can selectively choose to only activate perpendicular (including $A_\\parallel$ terms) or parallel terms (those that involve derivatives along $\\bhat$).\n\nUnfortunately, we were unable to find a closed solution for the energy integrals with the above fields.\n\n\\section{Numerical methods}\ndiscontinuous Galerkin on structured grid\n\\rowcolors{2}{gray!25}{white} %%% Use this line in front of longtable\n\\begin{longtable}{p{3cm}p{3cm}p{8cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Term} &  \\textbf{Method} & \\textbf{Description}  \\\\ \\midrule\n    coordinate system & Cylindrical & equidistant discretization of $[R_{\\min},R_{\\max}] \\times [Z_{\\min},Z_{\\max}] \\times [0,2\\pi]$ (Eq.~\\eqref{eq:box}, equal number of Gaussian nodes in $R$ and $Z$, equidistant planes in $\\varphi$ with one Gaussian node \\\\\nAdvection terms & direct DG & DG approximation with centered flux of derivatives \\\\\nElliptic terms & local DG & The local DG approximation with centered flux \\\\\nHelmholtz and Elliptic matrix inversions & multigrid/ conjugate gradient & Use previous two solutions to extrapolate initial guess and $1/\\chi$ as preconditioner \\\\\nParallel derivatives & regular  FCI & cf.~\\cite{Held2016,Stegmeir2017}.\nAll terms use the direct centered difference, which turns out is best\nat keeping the numerical flux-surface leakage in $\\RA{\\nc ( \\bhat NU_\\parallel)}$ to a minimum, even\nthough it is not exactly zero like in the adjoint discretizations, which in turn are unusable because they do not reliably converge.\nThere seems to be no benefit in using the grid refinement technique except when field-aligning the initial condition.\n%The terms $\\npar N$ and $\\npar \\phi$ in the velocity equation use a forward difference, while the term $\\npar U_\\parallel$ in the\n%density equation uses backward difference. This is to avoid a too wide stencil for the diverence of the current and increases stability for low resistivity.\n\\\\\ntime & Multistep \"Karniadakis\" & \\\\\n\\qquad explicit & Multistep \"Karniadakis\" & $3$rd order explicit\\\\\n\\qquad implicit & Multistep \"Karniadakis\" & $2$nd order implicit, contains the penalization term and optionally the perp. Diffusion terms. \\\\\n\\bottomrule\n\\end{longtable}\nNote that the explicit resistive term leads to an absolute (CFL) restriction\non the timestep according to $\\partial_t u_e \\propto \\frac{\\eta}{\\mu_e} u_e \\Rightarrow \\Delta t < \\frac{-\\mu_e}{\\eta}$. This is a quite weak restriction unless the resistivity exceeds $\\eta > 10^{-4}$.\nThe explicit parallel electron viscosity term leads to a CFL condition of the\nform $\\Delta t < (2\\pi (R_0 - a))^2/(N_z^2 \\nu_{\\parallel,e})$.\n\nIn every iteration of the implicit inversion we need to solve an equation of the form\n\\begin{align}\n    n_e + a \\hat L n_e = \\hat n_e \\\\\n    N_i + a \\hat L N_i = \\hat N_i \\\\\n    w_e + a \\hat L u_e = \\hat w_e \\\\\n    W_i + a \\hat L U_i = \\hat W_i\n\\end{align}\nwith $W=U+A_\\parallel/\\mu$ and $-\\Delta_\\perp A_\\parallel = \\beta (N_i U_i -n_e u_e)$\n    and $\\hat L = -\\nu_\\perp \\Delta_\\perp^2$.\nThis makes 7 equations for 7 unkown quantities.\nWe solve the system by first isolating and solving the two density equations for $n_e$ and $N_i$. These can then be inserted into the velocity equations as\nfixed solutions, which makes these equations linear.\n\nThe resistive term cannot fit into this scheme as it is linear but not symmetric.\n\\section{Usage}\n\nCompilation:\\\\\n\\texttt{make feltor device=\\{gpu,omp\\}} Compile \\texttt{feltor.cu} (only shared memory)\\\\\n\\texttt{make feltor\\_hpc device=\\{gpu,omp\\}} Compile \\texttt{feltor\\_hpc.cu} for shared memory system. Needs {\\it serial netcdf} \\\\\n\\texttt{make feltor\\_mpi device=\\{gpu,omp,skl,knl\\}} Compile \\texttt{feltor\\_hpc.cu} for distributed memory systems. Also needs {\\it serial netcdf}\\\\\nUsage:\\\\\n\\texttt{./feltor\\_hpc input.json geometry.json output.nc [initial.nc]} \\\\\n\\texttt{echo npx npy npz | mpirun -n np ./feltor\\_mpi input.json geometry.json output.nc [initial.nc]} \\\\\n\\texttt{./feltor input.json geometry.json } \\\\\n\nThe programs \\texttt{feltor\\_hpc.cu} and \\texttt{feltor.cu} expect two input\nfiles \\texttt{input.json} and \\texttt{geometry.json}, described in Sections~\\ref{sec:input_file} and \\ref{sec:geometry_file}.\nThe first is for the physical and numerical parameters of the model equations\nwhile the latter describes the Solov'ev equilibrium.\n The program \\texttt{feltor.cu} plots the results directly to the screen using \\texttt{glfw3}.\nThe program \\texttt{feltor\\_hpc.cu} writes results into\nthe output file \\texttt{output.nc}.\n The output file is described in Section~\\ref{sec:output_file}.\n The optional file \\texttt{initial.nc} can be used to initialize a simulation from an existing file.\n This behavior is described in Section~\\ref{sec:restart_file}.\n Both programs write unstructured human readable performance information of the running simulation\n to \\texttt{std::cout}.\n\n\\begin{tcolorbox}[title=Note]\nWhen compiled for mpi, the program \\texttt{feltor\\_hpc.cu} expects the\npartition of the total number of processes np into the three directions x, y and z\nas an input from the command line.\n\\end{tcolorbox}\nMake sure that \\texttt{npx*npy*npz==np} and that\nthey evenly divide the number of grid points in the respective direction! The\nnumber of stages in the multigrid algorithm and the compression parameters further\nrestrict this choice. Also note that the number of processes in a direction must\nnot equal the number of grid points in that direction!\n\n\n\\subsection{Input file structure} \\label{sec:input_file}\nInput file format: \\href{https://en.wikipedia.org/wiki/JSON}{json}\n\n%%This is a booktabs table\n\\begin{longtable}{llp{2.5cm}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Example}  & \\textbf{Description}  \\\\ \\midrule\nn      & integer & 3 &Number of Gaussian nodes in R and Z (we practically always take 3)\n\\\\\nNx     & integer &52&Number of grid points in R (increase if your simulations crash)\n\\\\\nNy     & integer &52&Number of grid points in Z (increase if your simulations crash)\n\\\\\nNz     & integer &16&Number of grid points in $\\varphi$ (determines dt\nsince parallel velocity dominates timestep)\n\\\\\ndt     & integer &1e-2& time stepsize in units of $c_s/\\rho_s$ \\\\\ncompression & integer[2] & [2,2] & Compress output file by reducing\npoints in x and y (pojecting the polynomials onto a coarser grid): output\ncontains n*Nx/c[0] points in x, (has to divde Nx evenly), and n*Ny/c[1] points\nin y, (has to divde Ny evenly). 2 or 3 are reasonable values.\n\\\\\ninner\\_loop & integer & 2  & Number of time steps between updates to the\ntime integrated quantities. (Although the diagnostics is quite fast sometimes\nyou need to amortize the time spent on it). Note that integrating selected\nquantities in time during the simulation is how we maintain the time-resolution\nin the file output (cf. \\ref{sec:output_file}). Choose as low as you can get\naway with (between 1 and 10).\n\\\\\nitstp       & integer & 2  &{ \\tt inner\\_loop*itstp} is the number of\ntimesteps between file outputs (2d and 3d quantities); Note that 1d and 0d\nquantities can only be computed post-simulation since we can't compute\nflux-integrals in parallel in MPI.\n\\\\\nmaxout      & integer & 10 & Total Number of fields outputs excluding first\n(The total number of time steps is {\\tt maxout$\\cdot$itstp$\\cdot$inner\\_loop})\nIf you want to let the simulation run for a certain time instead just choose\nthis parameter very large and let the simulation hit the time-limit.\n\\\\\neps\\_time   & float & 1e-7  & Tolerance for solver for implicit part in\ntime-stepper (if too low, you'll see oscillations in $u_{\\parallel,e}$ and/or $\\phi$) Relevant only if diffusion is treated implicitly.\n\\\\\nstages      & integer & 3 & number of stages in multigrid, $2^{\\text{stages-1}}$\nhas to evenly divide both $N_x$ and $N_y$\n\\\\\neps\\_pol    & float[stages] & [1e-6,1,1]  &  The first number is the tolerance for residual of the inversion of polarisation and induction Eq.. The second number is a multiplicative factor for the accuracy on the second grid in a multigrid scheme, the third for the third grid and so on.  (i.e. $\\eps_0\\eps_i$ is the accuracy on the i-th grid)\nTuning those factors is a major performance tuning oppourtunity!! For saturated turbulence the suggested values are [1e-6, 2000, 100].\n\\\\\njumpfactor  & float & 1 & Jumpfactor $\\in \\left[0.01,1\\right]$ in the local DG method for the elliptic terms. (Don't touch unless you know what you're doing.\n\\\\\neps\\_gamma  & float & 1e-6  & Tolerance for $\\Gamma_1$\n\\\\\nFCI & dict & & Parameters for Flux coordinate independent approach\n\\\\\n\\qquad refine     & integer[2] & [2,2] & refinement factor in FCI approach in R- and Z-direction.\nWe use [2,2], higher values take more time, but possibly stabilize the simulation.\n\\\\\n\\qquad rk4eps     & float & 1e-6 & Accuracy of fieldline integrator in FCI. The default is reasonable.\n\\\\\n\\qquad periodify & bool & true & Indicate if flux function is periodified beyond grid boundaries such that the contours are perpendicular to the boundaries. This is not entirely consistent but works better for small toroidal resolution\n\\\\\nmu         & float & -0.000272121& $\\mu_e =-m_e/m_i$.\n    One of $\\left\\{ -0.000544617, -0.000272121, -0.000181372 \\right\\}$\n\\\\\ntau        & float &1      & $\\tau = T_i/T_e$\n\\\\\nbeta       & float & 5e-6  & Plasma beta $5\\cdot 10^{-6}$ (TJK), $4\\cdot\n10^{-3}$ (Compass), If $0$, then the model is electrostatic\n\\\\\nnu\\_perp   & float &1e-3   & perpendicular viscosity $\\nu_\\perp$, increase\nthis or the resolution if you see vertical or horizontal oscillations (likely\nfrom the advection terms) in your simulation box, decrease if it dampens all\ninstabilities\n\\\\\nperp\\_diff & string[2] & [\"viscous\",\"explicit\"] & \"viscous\": $\\Lambda_\\perp\\propto\n\\nu_\\perp\\Delta_\\perp$ , \"hyperviscous\": $\\Lambda_\\perp \\propto\n-\\nu_\\perp\\Delta_\\perp^2$, the second entry indicates whether the perpendicular diffusion is to be treated explicit or implicit (we recommend explicit since in 3d the parallel dynamics restricts the timestep)\n\\\\\nresistivity & float &1e-4  & parallel resistivity parameter Eq.~\\eqref{eq:resistivity}\n\\\\\ncurvmode  & string & \"toroidal\" &\ncurvature mode (\n\"low beta\",\n\"true\": no approximation - requires significantly more resolution in Nz,\n\"toroidal\": toroidal field approx - elliptic equation does not need\ncommunication in z\n)\n\\\\\nsymmetric & bool & false & If true, initialize all quantities symmetric\nin $\\varphi$ (effectively reducing the problem to 2d). The input $N_z$ is used\nto construct the parallel derivatives and then overwritten to $N_z\\equiv 1$.\n\\\\\nbc & dict & & Perpendicular Boundary conditions (note that $A_\\parallel$ has the same bc as $U_\\parallel$) \\ldots\\\\\n\\qquad density   & char[2] & [DIR,DIR] & boundary conditions in x and y\nfor $n_e$ and $N_i$, DIR (density 1 on boundary) means both convective and\n    diffusive outflow while NEU (gradient 0) means no outflow by diffusion\n\\\\\n\\qquad velocity  & char[2] & [NEU,NEU] & boundary conditions in x and y for\n$u_{\\parallel,e}$ and $U_{\\parallel,i}$ and $A_\\parallel$, DIR is in general not very stable, NEU works\nbetter\\\\\n\\qquad potential & char[2] & [DIR,DIR] & boundary conditions in x and y for\n$\\phi$ and $\\psi$, DIR means that the $v_{E,\\perp}=0$ on the boundary (i.e. no\noutflow by \\ExB drift), NEU can have a detrimental effect on timestep \\\\\nbox & dict & & Bounding box \\\\\n    \\qquad scaleR  & float[2] & [1.1,1.1]     & $[\\varepsilon_{R-}, \\varepsilon_{R+}]$ scale left and right boundary in units of $a$ Eq.~\\eqref{eq:box}\\\\\n    \\qquad scaleZ  & float[2] & [1.2,1.1]     & $\\varepsilon_{Z-}, \\varepsilon_{Z+}$ scale lower and upper boundary in units of $ae$ Eq.~\\eqref{eq:box}\n\\\\\ninitne    & string & \"turbulence\"     & initial condition for the\nperturbation $\\tilde n$ in \\eqref{eq:initial_ne}. \"zonal\" (Eq.~\\eqref{eq:initial_zonal_flow}),\n    \"zero\" = no perturbation,\n    \"blob\" = blob simulations (several rounds fieldaligned),\n    \"straight blob\" = straight blob simulation( 1 round fieldaligned),\n    \"turbulence\" = turbulence simulations ( 1 round fieldaligned, Eq.~\\eqref{eq:initial_turbulent})\n    \"turbulence on gaussian\" = Gaussian bg. profile with turbulence perturbation Eq.~\\eqref{eq:turbulence_on_gaussian}\n    See the file {\\tt init.h} to add your own custom condition.\n\\\\\ninitphi   & string & \"zero\"  & (ignored if $\\tau_i = 0$, then $\\phi=0$) initial condition for $\\phi$ and thus $N_i$ (Eq.~\\eqref{eq:initphi}: \"zero\" : $\\phi = 0$, vanishing\nelectric potential, \"balance\": ExB vorticity equals ion diamagnetic vorticity\n\\\\\namplitude  & float &0.01   & amplitude $A$ of initial perturbation (blob, turbulent bath or zonal flow)  \\\\\nsigma      & float &2      & Gaussian variance in units of $\\rho_s$ \\\\\nposX       & float &0.3    & Gaussian R-position in units of $a$\\\\\nposY       & float &0.0    & Gaussian Z-position in units of $a$ \\\\\nsigma\\_z    & float &0.25  & toroidal variance in units of $\\pi$ of the fieldline-following initialization \\\\\nk\\_psi     & float &0    & zonal mode wave number (only for \"zonal\" initial condition)  \\\\\nprofile & Dict & & Density profile \\\\\n\\qquad amp& float &4   & Profile amplitude $\\triangle n_{peak}$ in\nEq.~\\eqref{eq:density_profile} and Eq.~\\eqref{eq:turbulence_on_gaussian}\n\\\\\n\\qquad alpha  & float & 0.2 & Transition width $\\alpha_p$ in the Heaviside\nat the separatrix (must not be zero - even if amp is zero - it is also used for the perturbation)\n\\\\\nsource & dict & & Density source, cf. the output \\texttt{sne\\_tt\\_ifs} in \\texttt{feltordiag} (or \\texttt{SourceProfile\\_ifs} in \\texttt{geometry\\_diag}) to see how much mass the source with the parameters below generates and compare to \\texttt{jsne\\_tt\\_fsa} to see how much mass is lost.  \\\\\n\\qquad rate & float & 0    & profile source rate $\\omega_s$ in Eq.~\\eqref{eq:electron_source}.\n\\\\\n\\qquad type & string & \"influx\" & The type of source to use:\n\"fixed\\_profile\" the source is multiplied by $(n_{prof} - n)$ to relax to the initial profile Eq.~\\eqref{eq:electron_source};\n\"influx\" the source has a constant source rate Eq.~\\eqref{eq:electron_source_influx},\n\"torpex\": Torpex inspired source profile Eq.~\\eqref{eq:electron_source_torpex},\n\"gaussian\": Gaussian shaped source profile - uses \\texttt{posX}, \\texttt{posY} and \\texttt{sigma},\n\"profile\\_influx\": Copy a profile into the source function and use a constant source rate. The idea is that you can start with zero density and evolve the profile purely with the source. There is a turbulent bath on top of it.\n\"turbulence\" : Influx of the turbulent bath initial condition as a source, same as profile\\_influx just without the profile.\n    See the file {\\tt init.h} to add your own custom source.\n\\\\\n\\qquad boundary & float & 0.2  & Source region boundary $\\rho_{p,b}$: yields in Eq.~\\eqref{eq:electron_source} and Eq.~\\eqref{eq:electron_source_influx}  \\\\\n\\qquad alpha  & float & 0.2 & Transition width $\\alpha_p$ in the Heaviside\nin the density Eq.~\\eqref{eq:density_profile} (with $\\rho_{p,b}=0$ and source profiles Eq.~\\eqref{eq:electron_source} (should be\nsmall but cannot be too small if $\\tau_i > 0$ else $\\Delta_\\perp n_e$ explodes, must not be zero)\n\\\\\nwall & dict & & magnetic and density damping region \\\\\n\\qquad type & string & \"sol\\_pfr\" & One of ``none'', ``heaviside'' or ``sol\\_pfr'' \\\\\n\\qquad penalization & float & 1    & penalization coefficient $\\omega_w$ in density and velocity damping Eq.~\\eqref{eq:wall_penalization} \\\\\n\\qquad boundary & float[2] & [1.2,0.8]  & Wall region boundary $\\rho_{p,b}$: yields $\\psi_0 = (1-\\rho_{p,b}^2)\\psi_{p,O}$ in Eq.~\\eqref{eq:wall}.\n\\\\\n\\qquad alpha   & float[2] & [0.25,0.25] & Transition width $\\alpha_p$: yields\n$\\alpha=-2\\rho_{p,b}\\alpha_p+\\alpha_p^2)\\psi_{p,O}$ for the Heaviside in the wall function \\eqref{eq:wall}. If zero, we do not have a wall.\n\\\\\nsheath & dict & & Sheath region and boundary condition \\\\\n\\qquad bc & string & \"bohm\" & One of ``bohm'',  or ``insulation'' \\\\\n\\qquad penalization & float & 1    & penalization coefficient $\\omega_s$ in density and velocity damping Eq.~\\eqref{eq:sheath_penalization} \\\\\n\\qquad boundary & float & 0.3  & Wall region boundary $\\rho_{p,b}$: yields $\\psi_0 = (1-\\rho_{p,b}^2)\\psi_{p,O}$ in Eq.~\\eqref{eq:sheath}.\n\\\\\n\\qquad alpha   & float & 0.2 & Transition width $\\alpha_p$: yields\n$\\alpha=-2\\rho_{p,b}\\alpha_p+\\alpha_p^2)\\psi_{p,O}$ for the Heaviside in the wall function \\eqref{eq:sheath}.\n\\\\\n\\bottomrule\n\\end{longtable}\n\\subsection{Geometry file structure} \\label{sec:geometry_file}\nFile format: \\href{https://en.wikipedia.org/wiki/JSON}{json}\n\nThe file structure of the geometry file depends on which expansion for $\\psi_p$ is chosen Eq.~\\eqref{eq:solovev} or Eq.~\\eqref{eq:polynomial}.\n%%This is a booktabs table\nA solovev magnetic field equilibrium\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Example} & \\textbf{Description}  \\\\ \\midrule\n    A      & float & 0 & Solovev parameter in Eq.~\\eqref{eq:solovev} \\\\\n    c      & float[12] &  - & Solovev coefficients in Eq.~\\eqref{eq:solovev} \\\\\n\\bottomrule\n\\end{longtable}\nA polynomial magnetic field equilibrium\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Example} & \\textbf{Description}  \\\\ \\midrule\n    M      & float & 1 & Number of polynomial coefficients in $R$ in Eq.~\\eqref{eq:polynomial} \\\\\n    N      & float & 1 & Number of polynomial coefficients in $Z$ in Eq.~\\eqref{eq:polynomial} \\\\\n    c      & float[MN] &  - & Polynomial coefficients in Eq.~\\eqref{eq:polynomial} \\\\\n\\bottomrule\n\\end{longtable}\nIn addition both files must contain\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Example} & \\textbf{Description}  \\\\ \\midrule\n    PP     & float & 1 & Prefactor $\\mathcal P_\\psi$ for $\\psi_p$ \\\\\n    PI     & float & 1 & Prefactor $\\mathcal P_I$ for $I$ \\\\\n    R\\_0   & float & - & Major radius $R_0$ in units of $\\rho_s$ (This is the only geometry quantity to change if $\\rho_s$ changes)\\\\\n    elongation    & float & 1 & Elongation $e$, used in determining the box size Eq.~\\eqref{eq:box} and the initial guess for the location of the X-point $Z_X = -1.1 ea$ \\\\\n    triangularity & float & 0 & Triangularity $\\delta$, used in the initial guess for the location of the X-point $R_X = R_0-1.1\\delta a$ \\\\\n    inverseaspectratio & float & 0.16667& minor to major radius $a/R_0$ (used to compute $a$ from $R_0$) \\\\\n    equilibrium & string & solovev & Tells the magnetic field generation which type of expansion to use for the flux function \\\\\n    description & string & standardX & Tells the magnetic field modifier\n    where to look for the SOL and PFR regions \\\\\n\\bottomrule\n\\end{longtable}\n\n\\subsection{Output} \\label{sec:output_file}\nOutput file format: \\href{https://www.unidata.ucar.edu/software/netcdf/docs/}{netcdf-4/hdf5};\n\nA \\textit{coordinate variable (Coord. Var.)} is a Dataset with the same name as a dimension.\nWe follow\n\\href{http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html}{CF Conventions CF-1.7}\nand write according attributes into the file.\n\n\\begin{tcolorbox}[title=Note]\nThe command \\texttt{ncdump -h output.nc} gives a full list of what a file contains.\n\\end{tcolorbox}\nHere, we list the content without attributes\nsince the internal netcdf information does not display equations.\n%\n%Name | Type | Dimensionality | Description\n%---|---|---|---|\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Dimension} & \\textbf{Description}  \\\\ \\midrule\ninputfile  &     text attribute & - & verbose input file as a string (valid JSON, C-style comments are allowed but discarded) \\\\\ngeomfile   &     text attribute & - & verbose geometry input file as a string (valid JSON, C-style comments are allowed but discarded) \\\\\nx                & Coord. Var. & 1 (x) & $R$-coordinate (computational space, compressed size: $nN_x/c_x$)\\\\\ny                & Coord. Var. & 1 (y) & $Z$-coordinate (computational space, compressed size: $nN_y/c_y$)\\\\\nz                & Coord. Var. & 1 (z) & $\\varphi$-coordinate (computational space, size: $N_z$) \\\\\ntime             & Coord. Var. & 1 (time)& time at which fields are written (variable size: maxout$+1$, dimension size: unlimited) \\\\\nxc           & Dataset & 3 (z,y,x) & Cartesian x-coordinate $x=R\\sin(\\varphi)$ \\\\\nyc           & Dataset & 3 (z,y,x) & Cartesian y-coordinate $y=R\\cos(\\varphi)$\\\\\nzc           & Dataset & 3 (z,y,x) & Cartesian z-coordinate $z=Z$ \\\\\nPsip             & Dataset & 3 (z,y,x) & Flux function $\\psi_p(R,Z)$ \\\\\nNprof            & Dataset & 3 (z,y,x) & Density profile $n_\\text{prof}$ used in the forcing source \\\\\nSource           & Dataset & 3 (z,y,x) & Source profile $S_{prof}$\\\\\nBR               & Dataset & 3 (z,y,x) & Contravariant magnetic field component $B^R$ \\\\\nBZ               & Dataset & 3 (z,y,x) & Contravariant magnetic field component $B^Z$ \\\\\nBP               & Dataset & 3 (z,y,x) & Contravariant magnetic field component $B^\\varphi$ \\\\\nelectrons        & Dataset & 4 (time, z, y, x) & electron density $n_e$ \\\\\nions             & Dataset & 4 (time, z, y, x) & ion density $N_i$ \\\\\nUe               & Dataset & 4 (time, z, y, x) & electron velocity $u_{\\parallel,e}$ \\\\\nUi               & Dataset & 4 (time, z, y, x) & ion velocity $U_{\\parallel,i}$ \\\\\npotential        & Dataset & 4 (time, z, y, x) & electric potential $\\phi$ \\\\\ninduction        & Dataset & 4 (time, z, y, x) & parallel vector potential $A_\\parallel$ \\\\\nX\\_2d            & Dataset & 3 (time,y,x) & Selected plane $X(\\varphi=0)$ \\\\\nX\\_ta2d          & Dataset & 3 (time,y,x) & Toroidal average $\\PA{ X }$\nEq.~\\eqref{eq:phi_average} \\\\\nY\\_tt\\_2d        & Dataset & 3 (time,y,x) & Time integrated (between two outputs, Simpson's rule) selected plane\n$\\int_{t_0}^{t_1}\\d t Y(\\varphi=0) $\nwhere $t_1 - t_0 = ${\\tt dt*inner\\_loop*itstp} and {\\tt itstp} is the number of discretization points\\\\\nY\\_tt\\_ta2d      & Dataset & 3 (time,y,x) & Time integrated (between two outputs, Simpson's rule) toroidal average (Eq.~\\eqref{eq:phi_average})\n$\\int_{t_0}^{t_1}\\d t \\PA{ Y }$\nwhere $t_1 - t_0 = ${\\tt dt*inner\\_loop*itstp} and {\\tt itstp} is the number of discretization points\\\\\n\\bottomrule\n\\end{longtable}\nwhere\nX and Y\\_tt represent the quantities described in the tables in previous sections and the miscellaneous quantities\n\\begin{longtable}{llll}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Equation} & \\textbf{Name} &  \\textbf{Equation}\\\\\n\\midrule\n    vorticity &$-\\Delta_\\perp\\phi$ &\n    apar\\_vorticity &$-\\Delta_\\perp A_\\parallel$ \\\\\n    dssue & $\\npar^2 u_{\\parallel,e}$&\n    %dppue & $\\partial_\\varphi^2 u_{\\parallel,e}$\\\\\n    %dpue2 & $(\\partial_\\varphi u_{\\parallel,e})^2$&\n    lperpinv &$L_\\perp^{-1} := |\\vec\\np n_e|/n_e$ \\\\\n    perpaligned &$(\\vec\\np n_e)^2/n_e$ &\n    lparallelinv &$L_\\parallel^{-1} := |\\npar n_e|/n_e$ \\\\\n    aligned &$ (\\npar n_e)^2/n_e$ &\n    ne2 & $n_e^2$ \\\\\n    phi2 & $\\phi^2$ &\n    nephi & $n_e\\phi$ \\\\\n\\bottomrule\n\\end{longtable}\nThe computation time spent on diagnostics is negligible if {\\tt inner\\_loop} parameter is greater than 1. Also\nremember that the X and Y fields are all two-dimensional, which takes up much less disk-space than three-dimensional fields.\n\\subsection{Restart file} \\label{sec:restart_file}\nThe program \\texttt{feltor\\_hpc.cu} has the possibility to initialize time and the fields with\nthe results of a previous simulation. In particular, this feature is motivated by chain jobs on a cluster\n(see e.g. the --dependency option in SLURM).\nThis behaviour is enabled by giving an additional file \\texttt{initial.nc}\nto the command line. In this case the \\texttt{initne} and \\texttt{initphi} parameters of the input\nfile are ignored. Instead, the fields \\texttt{electrons, ions, Ue, Ui, induction} at the latest timestep\nare read from the given file to initialize the simulation.\nNote that to enable a loss-less continuation of the simulation we output special restart fields into the output file that in contrast to the other fields\nare not compressed.\nApart from that the behaviour of the program is unchanged i.e. the magnetic field, profiles, resolutions, etc.\nare all taken from the regular input files. This means that the user must take care that these are consistent\nwith the paramters in the existing \\texttt{initial.nc} file. Also note that we try to discourage\nappending new results to an exisiting file directly,\nbecause if for some reason the cluster crashes and the file is corrupted\nthe whole simulation is lost.\n\\begin{tcolorbox}[title=Note]\nIt is safer to just merge files afterwards with\\\\\n\\texttt{ncrcat output1.nc output2.nc output.nc}\\\\\nfrom the \\texttt{nco} package\n\\end{tcolorbox}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Diagnostics}\\label{sec:diagnostics}\n\\texttt{feltor/src/feltor/feltordiag.cu}\n reads one or more previously generated simulation file(s) \\texttt{input0.nc ... inputN.nc} described in Section~\\ref{sec:output_file} and writes into a single second output file \\texttt{output.nc} described as follows. \\\\\nCompilation\\\\\n\\texttt{make feltordiag device=\\{gpu,omp\\}} \\\\\nUsage \\\\\n\\texttt{./feltordiag input0.nc ... inputN.nc output.nc} \\\\\n\n\\begin{tcolorbox}[title=Note]\n\\texttt{feltordiag} refuses to overwrite existing files in order to protect against data loss in case of accidental spelling\nerrors or other careless mistakes.\n\\end{tcolorbox}\n\nOutput file format: \\href{https://www.unidata.ucar.edu/software/netcdf/docs/}{netcdf-4/hdf5};\n\\href{http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html}{CF Conventions CF-1.7}\n\nA \\textit{coordinate variable (Coord. Var.)} is a Dataset with the same name as a dimension.\n\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Dimension} & \\textbf{Description}  \\\\ \\midrule\ninputfile  &     text attribute & - & verbose input file as a string (valid JSON, C-style comments are allowed but discarded) \\\\\ngeomfile   &     text attribute & - & verbose geometry input file as a string (valid JSON, C-style comments are allowed but discarded) \\\\\nx                & Coord. Var. & 1 (x) & $R$-coordinate (computational space, compressed size: $nN_x/c_x$)\\\\\ny                & Coord. Var. & 1 (y) & $Z$-coordinate (computational space, compressed size: $nN_y/c_y$)\\\\\npsi              & Coord. Var. & 1 (psi) & $\\psi_p$-coordinate ( default size: $3\\cdot 64$) \\\\\ntime             & Coord. Var. & 1 (time)& time at which fields are written (variable size: maxout$+1$, dimension size: unlimited) \\\\\ndvdpsip          & Dataset & 1 (psi) & $\\d v/\\d\\psi_p$ \\\\\npsi\\_vol         & Dataset & 1 (psi) & The volume enclosed by the flux surfaces $v(\\psi_p) = \\int_{\\psi_p} \\dV $ \\\\\npsi\\_area        & Dataset & 1 (psi) & The area of the flux surfaces $A(\\psi_p) = 2\\pi \\int_\\Omega |\\vn\\psi_p| \\delta(\\psi_p - \\psi_{p0}) H(Z-Z_X) R\\d R\\d Z$ \\\\\nq-profile        & Dataset & 1 (psi) & The safety factor $q(\\psi_p)$ \\eqref{eq:safety_factor} using direct integration ( accurate but unavailable outside separatrix) \\\\\npsi\\_psi         & Dataset & 1 (psi) & explicit $\\psi_p$ values; Same as psi \\\\\npsit1d           & Dataset & 1 (psi) & Toroidal flux (integrated q-profile) $\\psi_t = \\int^{\\psi_p} \\d\\psi_p q(\\psi_p)$ \\\\\nrho              & Dataset & 1 (psi) & Transformed flux label $\\rho:= 1 - \\psi_p/\\psi_{p,O}$ \\\\\nrho\\_p           & Dataset & 1 (psi) & poloidal flux label $\\rho_p:= \\sqrt{1 - \\psi_p/\\psi_{p,O}}$ \\\\\nrho\\_t           & Dataset & 1 (psi) & Toroidal flux label $\\rho_t := \\sqrt{\\psi_t/\\psi_{t,\\mathrm{sep}}}$ (is similar to $\\rho$ in the edge but $\\rho_t$ is nicer in the core domain, because equidistant $\\rho_t$ make more equidistant flux-surfaces)\\\\\nZ\\_fluc2d        & Dataset & 3 (time,y,x) & Fluctuation level on selected plane ($\\varphi= 0$) $\\delta Z := Z(R,Z,0) - \\RA{ Z}(R,Z)$ \\\\\nZ\\_fsa2d         & Dataset & 3 (time, y,x) & Flux surface average $\\RA{ Z}$ interpolated onto 2d plane Eq.~\\eqref{eq:fsa_vol} \\\\\nZ\\_cta2d         & Dataset & 3 (time, y,x) & Convoluted toroidal average Eq.~\\eqref{eq:cta} \\\\\nZ\\_fsa           & Dataset & 2 (time, psi) & Flux surface average $\\RA{ Z}$ Eq.~\\eqref{eq:fsa_vol} \\\\\nZ\\_std\\_fsa      & Dataset & 2 (time, psi) & Standard deviation of flux surface average on outboard midplane $\\sqrt{\\RA{(\\delta Z)^2}}$ \\\\\nZ\\_ifs           & Dataset & 2 (time, psi) & Volume integrated flux surface average $\\int\\d v\\RA{ Z}$ unless Z is a current, then it is the volume derived flux-surface average $\\partial_v \\RA{ Z}$ \\\\\nZ\\_ifs\\_lcfs     & Dataset & 1 (time) & Volume integrated flux surface average evaluated on last closed flux surface $\\int_0^{v(0)}\\d v\\RA{ Z}$ unless Z is a current, then it is the fsa evaluated $\\RA{ j_v}(0)$ \\\\\nZ\\_ifs\\_norm     & Dataset & 1 (time) & Volume integrated square flux surface average $\\sqrt{\\int \\d v \\RA{Z}^2}$, unless Z is a current, then it is the square derivative of the flux surface average $\\sqrt{\\int\\d v (\\partial_v \\RA{j^v})^2}$\\\\\n\\bottomrule\n\\end{longtable}\nwhere Z $\\in$ \\{X, Y\\_tt\\}\n\\begin{tcolorbox}[title=Note]\n\\texttt{feltoridag} converts all $jsX$ quantities into $jvX$\nby multiplying $\\d v/\\d \\psi_p$\nin the sense that $\\vec j\\cn v  = \\vec j \\cn \\psi_p \\d v/\\d\\psi_p$.\n\\end{tcolorbox}\nThe parameters used for the X-point flux-aligned grid construction are $f_x = 1/8$, $f_y = 0$, $n_\\psi = 3$, $N_\\zeta = 64$ and $N_\\eta = 640$ and the constant monitor metric.\n\nWe also have a useful geometry diagnostic program:\n\\texttt{feltor/inc/geometries/geometry\\_diag.cu} reads either a previously\ngenerated simulation file \\texttt{input.nc} or the input json files\n\\texttt{input.json} and \\texttt{geometry.json} and writes an output file \\texttt{diag\\_geometry.nc} as\\\\\nCompilation\\\\\n\\texttt{make geometry\\_diag device=\\{gpu,omp\\}} \\\\\nUsage \\\\\n\\texttt{./geometry\\_diag input.json geometry.json diag\\_geometry.nc} \\\\\nThe program outputs a host of static 1d, 2d and 3d geometric quantities.\nThe output file is for example useful in connection with the ``Group Datasets'' filter in paraview, which merges Datasets from different files into one using shallow copy only.\n\\section{Troubleshooting}\nAll previously mentioned codes can crash for various reasons. Here,\nwe list and describe situations, which generally may lead to program\ntermination\n\\begin{longtable}{p{6cm}p{8cm}}\n\\toprule\n\\rowcolor{gray!50}\\textbf{Error condition} &  \\textbf{Handling} \\\\ \\midrule\nAn input file does not exist or is otherwise invalid\n&\nProgram terminates with an error message to \\texttt{std::cerr}. \\texttt{feltordiag.cu} writes an error to \\texttt{std::cerr} and continues with the next input file.\n    \\\\\nAn input netcdf file misses a required field\n&\nProgram terminates with a NetCDF error message to \\texttt{std::cerr}\n    \\\\\nNo write permission for the output file location\n&\nProgram terminates with an error message to \\texttt{std::cerr}\n    \\\\\nAn input Json file misses a key or contains a typo in a key\n&\nThe programs \\texttt{feltor.cu} and \\texttt{feltor\\_hpc.cu}\nwill exit with an error message. (The reason why we do not\nsilently use the default value is that the danger of wasting\nvaluable computing time on the cluster due to a typo is bigger than the\nadded convenience. We want to be sure that the program\ndoes what the user wants).\nThe other programs just issue warnings\nif a key is not found and use a default value\nwhich is $0$ if not otherwise specified.\n    \\\\\n    An input Json file has an invalid value, e.g. a typo in a string value\n&\nInvalid values lead to termination with an error message to \\texttt{std::cerr}, once and if program tries to use the value\n    \\\\\n    Number of processes in $x$, $y$ and $z$ direction does not match total number of Processes\n&\nProgram terminates with an error message to \\texttt{std::cerr}.\n    \\\\\n    $2^{s-1}$ or $c_x$ or $c_y$ does not evenly divide $N_x$ and $N_y$, where $s$ is the number of stages in the multigrid algorithm.\n&\nProgram terminates on thrown error. Make sure the numbers add up.\n    \\\\\n    Number of processes in $x$, $y$ and $z$ direction does not evenly divide or is greater or equal $N_x/2^{s-1}$, $N_y/2^{s-1}$ and $N_z$, where $s$ is the number of stages in the multigrid algorithm.\n&\nProgram terminates on failed assert\n    \\\\\nAn MPI error occurs\n&\nProgram crashes horribly printing cryptic error messages (stack trace) to \\texttt{std::cerr}\n    \\\\\nA numerical instability occurs\n&\nThe program terminates usually caused by a NaN exception raised. However,\nthe cause for the instability has to be determined inspecting the\nlast output in the output file.\n    \\\\\n\\qquad large fieldaligned oscillations in $u_{\\parallel,e}$ paired with instability in the edge of the box\n&\nApply damping region\n    \\\\\n\\qquad Perpendicular grid oscillations in $u_{\\parallel,e}$ and $\\Delta_\\perp \\phi$ in the damping region, symmetric in $\\varphi$\n&\nIncrease damping $alpha$, increase damping boundary, make the box larger/smaller, increasing DS refinement might help.\n    \\\\\n\\qquad Spike in $u_{\\parallel,e}$ shortly after simulation start\n&\nIncrease $\\nu_\\perp$, increase $N_x$, $N_y$, decrease perturbation amplitude\n    \\\\\n\\qquad Grid oscillations far away from the edge\n&\nProbably caused by the perpendicular transport that goes unstable. Increase $\\nu_\\perp$ and/or $N_x$, $N_y$. Increasing DS refinement might also help.\n\\\\\n\\qquad Oscillations where fieldlines intersect the wall\n&\nCaused by boundary conditions in FCI method and necessarily underresolved toroidal direction.\nIncrease $N_z$, decrease $N_x$, $N_y$ or decrease $q$ value by decreasing $\\mathcal P_\\psi$ in geometry input file\n\\\\\n\\bottomrule\n\\end{longtable}\n\n%..................................................................\n\\bibliography{../../doc/related_pages/references}\n%..................................................................\n\n\n\\end{document}\n", "meta": {"hexsha": "1270671c53a8b4b0cf47897a0e29c40c1d161b77", "size": 113935, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/feltor/feltor.tex", "max_stars_repo_name": "gregordecristoforo/feltor", "max_stars_repo_head_hexsha": "d3b7b296e6f5be3a9ff9d602d98461ed9c60033a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2016-06-28T14:34:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-06T08:50:48.000Z", "max_issues_repo_path": "src/feltor/feltor.tex", "max_issues_repo_name": "gregordecristoforo/feltor", "max_issues_repo_head_hexsha": "d3b7b296e6f5be3a9ff9d602d98461ed9c60033a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-01-18T16:06:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-22T19:11:42.000Z", "max_forks_repo_path": "src/feltor/feltor.tex", "max_forks_repo_name": "gregordecristoforo/feltor", "max_forks_repo_head_hexsha": "d3b7b296e6f5be3a9ff9d602d98461ed9c60033a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-06-27T13:18:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-03T08:12:25.000Z", "avg_line_length": 56.4034653465, "max_line_length": 343, "alphanum_fraction": 0.6765260894, "num_tokens": 38751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.44594578767202453}}
{"text": "\\section{Algorithmic Verification}\\label{sec:algorithmic}\n\nNext, we describe \\smtlan, a conservative approximation\nof \\corelan where the undecidable type subsumption rule\nis replaced with a decidable one, yielding an SMT-based\nalgorithmic type system that enjoys the same soundness\nguarantees.\n\n\\subsection{The SMT logic \\smtlan}\n\n\\input{text/refinementreflection/smtsyntax}\n\n\\mypara{Syntax: Terms \\& Sorts}\n%\nFigure~\\ref{fig:smtsyntax} summarizes the syntax\nof \\smtlan, the \\emph{sorted} (SMT-)\ndecidable logic of quantifier-free equality,\nuninterpreted functions and linear\narithmetic (QF-EUFLIA) ~\\citep{Nelson81,SMTLIB2}.\n%\nThe \\emph{terms} of \\smtlan include\nintegers $n$,\nbooleans $b$,\nvariables $x$,\ndata constructors $\\dc$ (encoded as constants),\nfully applied unary \\unop and binary \\binop operators,\nand application $x\\ \\overline{\\pred}$ of an uninterpreted function $x$.\n%\nThe \\emph{sorts} of \\smtlan include built-in\ninteger \\tint and \\tbool for representing\nintegers and booleans.\n%\n%% NV reflected functions and measures are first order\n%% NV because\n%% NV 1. they can be partially applied\n%% NV 2. they can be passed as arguments\nThe interpreted functions of \\smtlan, \\eg\nthe logical constants $=$ and $<$,\n%% NV and the uninterpreted functions app and lam\n%% NV but we have not introduced these yet\nhave the function sort $\\sort \\rightarrow \\sort$.\n%\nOther functional values in \\corelan, \\eg\nreflected \\corelan functions and\n$\\lambda$-expressions, are represented as\nfirst-order values with\nuninterpreted sort \\tsmtfun{\\sort}{\\sort}.\n%\n%%The uninterpreted functions of \\smtlan, which\n%%correspond to reflected \\corelan functions,\n%%have the function sort $\\sort \\rightarrow \\sort$.\n%%%\n%%Other functional values in \\corelan, \\eg\n%%$\\lambda$-expressions, are represented as\n%%first-order values in \\smtlan with\n%%uninterpreted sort \\tsmtfun{\\sort}{\\sort}.\n%%%\nThe universal sort \\tuniv represents all other values.\n\n\\mypara{Semantics: Satisfaction \\& Validity}\n%\nAn assignment $\\sigma$ is a mapping from\nvariables to terms\n%\n${\\sigma \\defeq \\{ \\assignto{x_1}{\\pred_1}, \\ldots, \\assignto{x_n}{\\pred_n} \\}}$.\n%\nWe write\n%\n${\\sigma \\models \\pred}$\n%\nif the assignment $\\sigma$ is a\n\\emph{model of} $\\pred$, intuitively\nif $\\sigma\\ \\pred$ ``is true''~\\cite{Nelson81}.\n%\nA predicate $\\pred$ \\emph{is satisfiable} if\nthere exists ${\\sigma\\models\\pred}$.\n%\nA predicate $\\pred$ \\emph{is valid} if\nfor all assignments ${\\sigma\\models\\pred}$.\n\n\n\\subsection{Transforming \\corelan into \\smtlan}\n%\n\\label{subsec:embedding}\n\n\\input{text/refinementreflection/defuncrules}\n%\nThe judgment\n\\tologicshort{\\env}{e}{\\typ}{\\pred}{\\sort}{\\smtenv}{\\axioms}\nstates that a $\\corelan$ term $e$ is transformed,\nunder an environment $\\env$, into a\n$\\smtlan$ term $\\pred$.\n%\nThe transformation rules are summarized in Figure~\\ref{fig:defunc}.\n\n\\mypara{Embedding Types}\n%\nWe embed \\corelan types into \\smtlan sorts as:\n%\n$$\n\\begin{array}{rclcrcl}\n\\embed{\\tint}                       & \\defeq &  \\tint &  &\n\\embed{T}                           & \\defeq &  \\tuniv \\\\\n\\embed{\\tbool}                      & \\defeq &  \\tbool & &\n\\embed{\\tfun{x}{\\typ_x}{\\typ}} & \\defeq & \\tsmtfun{\\embed{\\typ_x}}{\\embed{\\typ}}\n\\end{array}\n$$\n%%%The embedding extends to typing environments:\n%%%% by embedding the types of the environment\n%%%$$\n%%%\\embedsort{\\{\\tbind{x_1}{\\typ_1}, \\dots, \\tbind{x_n}{\\typ_n}\\}}\n%%%  \\defeq\n%%%  \\{\\tbind{x_1}{\\embed{\\typ_1}}, \\dots, \\tbind{x_n}{\\embed{\\typ_n}}\n%%%  \\}\n%%%$$\n\n\\mypara{Embedding Constants}\n%\nElements shared on both \\corelan and \\smtlan\ntranslate to themselves.\n%\nThese elements include\nbooleans (\\lgbool),\nintegers (\\lgint),\nvariables (\\lgvar),\nbinary (\\lgbinGEN)\nand unary (\\lgun)\noperators.\n%\nSMT solvers do not support currying,\nand so in \\smtlan, all function symbols\nmust be fully applied.\n%\nThus, we assume that all applications\nto primitive constants and data\nconstructors are \\emph{saturated},\n%% NV eta converted\n\\ie fully applied, \\eg by converting\nsource level terms like @(+ 1)@ to\n@(\\z -> z + 1)@.\n%\n\n%%% Thus, to translate \\corelan's partially applied operators,\n%%% we define an uninterpreted function\n%%% $$\n%%% \\tbind{\\smtvar{c}}{\\embed{\\constty{c}}}\n%%% $$\n%%% for every functional constant $c$ in \\corelan.\n%%% %\n%%% For example, $+ 1$ will be translated to application of $\\smtvar{+}$ to $1$, while\n%%% $1+2$ will be translated to the identical $1+2$.\n\n%%\\spara{Lambda Lifting}\n%%%\n%%Since \\smtlan does not support $\\lambda$-functions.\n%%the translation lifts function to axiomatized variables.\n%%%\n%%Rule~\\lgfun\n%%translates the term $\\efun{x}{\\typ}{e}$ to\n%%a fresh variable $f$ that satisfies two axioms:\n%%(1). $\\beta$-reduction,\n%%that is $f$ applied to $x$ is equal to $e$, and\n%%(2). extentionality,\n%%that is for every other function $g$ and argument $x$,\n%%if $f$ applied to $x$ is equal to $g$ applied to $x$,\n%%then $f = g$.\n\n\\mypara{Embedding Functions}\n%\nAs \\smtlan is a first-order logic, we\nembed $\\lambda$-abstraction and application\nusing the uninterpreted functions\n\\smtlamname{}{} and \\smtappname{}{}.\n%\nWe embed $\\lambda$-abstractions\nusing $\\smtlamname{}{}$ as shown in rule~\\lgfun.\n%\nThe term $\\efun{x}{}{e}$ of type\n${\\typ_x \\rightarrow \\typ}$ is transformed\nto\n${\\smtlamname{\\sort_x}{\\sort}\\ x\\ \\pred}$\nof sort\n${\\tsmtfun{\\sort_x}{\\sort}}$, where\n%\n$\\sort_x$ and $\\sort$ are respectively\n$\\embed{\\typ_x}$ and $\\embed{\\typ}$,\n%\n${\\smtlamname{\\sort_x}{\\sort}}$\nis a special uninterpreted function\nof sort\n${\\sort_x \\rightarrow \\sort\\rightarrow\\tsmtfun{\\sort_x}{\\sort}}$,\nand\n$x$ of sort $\\sort_x$ and $r$ of sort $\\sort$ are\nthe embedding of the binder and body, respectively.\n%\nAs $\\smtlamname{}{}$ is just an SMT-function,\nit \\emph{does not} create a binding for $x$.\n%\nInstead, the binder $x$ is renamed to\na \\emph{fresh} name pre-declared in\nthe SMT environment.\n\n\n\\mypara{Embedding Applications}\n%\nDually, we embed applications via\ndefunctionalization~\\citep{Reynolds72}\nusing an uninterpreted \\emph{apply}\nfunction\n$\\smtappname{}{}$ as shown in rule~\\lgapp.\n%\nThe term ${e\\ e'}$, where $e$ and $e'$ have\ntypes ${\\typ_x \\rightarrow \\typ}$ and $\\typ_x$,\nis transformed to\n${\\tbind{\\smtappname{\\sort_x}{\\sort}\\ \\pred\\ \\pred'}{\\sort}}$\nwhere\n%\n$\\sort$ and $\\sort_x$ are respectively $\\embed{\\typ}$ and $\\embed{\\typ_x}$,\nthe\n${\\smtappname{\\sort_x}{\\sort}}$\nis a special uninterpreted function of sort\n${\\tsmtfun{\\sort_x}{\\sort} \\rightarrow \\sort_x \\rightarrow \\sort}$,\nand\n$\\pred$ and $\\pred'$ are the respective translations of $e$ and $e'$.\n\n\n\\mypara{Embedding Data Types}\n%\nRule~\\lgdc translates each data constructor to a\npredefined \\smtlan constant ${\\smtvar{\\dc}}$ of\nsort ${\\embed{\\constty{\\dc}}}$.\n%\nLet $\\dc_i$ be a non-boolean data constructor such that\n$$\n\\constty{\\dc_i} \\defeq \\typ_{i,1} \\rightarrow \\dots \\rightarrow \\typ_{i,n} \\rightarrow \\typ\n$$\nThen the \\emph{check function}\n${\\checkdc{{\\dc_i}}}$ has the sort\n$\\tsmtfun{\\embed{\\typ}}{\\tbool}$,\nand the \\emph{select function}\n${\\selector{\\dc}{i,j}}$ has the sort\n$\\tsmtfun{\\embed{\\typ}}{\\embed{\\typ_{i,j}}}$.\n%\nRule~\\lgcase translates case-expressions\nof \\corelan into nested $\\mathtt{if}$\nterms in \\smtlan, by using the check\nfunctions in the guards, and the\nselect functions for the binders\nof each case.\n%\n%\\mypara{Reflecting DataTypes}\n%\n% The above approach  makes it straightforward\n% to reflect functions over datatypes into \\smtlan.\n%\nFor example, following the above, the body of the list append function\n%\n%%% reflect (++) :: xs:[Int] -> ys:[Int] -> [Int]\n\\begin{code}\n  []     ++ ys = ys\n  (x:xs) ++ ys = x : (xs ++ ys)\n\\end{code}\n%\nis reflected into the \\smtlan refinement:\n%\n$$\n\\ite{\\mathtt{isNil}\\ \\mathit{xs}}\n    {\\mathit{ys}}\n    {\\mathtt{sel1}\\ \\mathit{xs}\\\n       \\dcons\\\n       (\\mathtt{sel2}\\ \\mathit{xs} \\ \\mathtt{++}\\  \\mathit{ys})}\n$$\n%\nWe favor selectors to the axiomatic translation of\nHALO~\\citep{halo} and \\fstar~\\cite{fstar} to avoid\nuniversally quantified formulas and the resulting\ninstantiation unpredictability.\n\n%% $$\n%% \\tbind{\\checkdc{\\dc}}{\\embed{\\typ \\rightarrow \\tbool}}\n%% \\ \\text{with}\\ \\constty{\\dc} = \\typ_1 \\rightarrow \\dots \\rightarrow \\typ_n\\rightarrow\\typ\n%% $$\n%% and the field selector is used to substitute the data constructor quantified variables $\\overline{y_i}$:\n%% eg. if \\dc is [] then i == 0\n%%     if \\dc is (:) :: a -> [a] -> [a] then\n%%         \\dc_1 = head :: [a] -> a\n%%         \\dc_2 = tail :: [a] -> [a]\n%% $$\n%% \\tbind\n      %% {\\embed{\\typ \\rightarrow \\typ_i}}\n%% \\ \\text{with}\\ \\constty{\\dc} = \\typ_1 \\rightarrow \\dots \\rightarrow \\typ_n\\rightarrow\\typ, i \\leq n\n%% $$\n%% %\n%% For example, the body of the @length@ function from~\\S~\\ref{sec:examples}\n%% translates to the condition $\\eif{\\isN\\ xs}{0}{1+\\texttt{length} (\\etail\\ xs)}$,\n%% as $\\etail \\defeq \\selector{\\dcons}{2}$.\n\n\\subsection{Correctness of Translation}\n\nInformally, the translation relation $\\tologicshort{\\env}{e}{}{\\pred}{}{}{}$\nis correct in the sense that if $e$ is a terminating boolean expression\nthen $e$ reduces to \\etrue \\textit{iff} $\\pred$ is SMT-satisfiable\nby a model that respects $\\beta$-equivalence.\n\n%%\\mypara{Type Preservation}\n%%%\n%%The \\emph{initial environment} \\smtenvinit\n%%maps the uninterpreted symbols used\n%%by the translation, namely\n%%%\n%%$\\smtlamname{}{}$,\n%%$\\smtappname{}{}$,\n%%$\\smtvar{\\dc}$,\n%%$\\checkdc{{\\dc_i}}$,\n%%$\\selector{\\dc}{{i,j}}$\n%%and fresh binder names $x$ used  in $\\smtlamname{}{}$\n%%to their respective sorts.\n%%%\n%%The judgment $\\smthastype{\\smtenv}{\\pred}{\\sort}$ states\n%%that the term $\\pred$ has sort $\\sort$ in environment\n%%$\\smtenv$. (We omit the standard derivation rules\n%%for brevity.)\n%%%\n%%The translation is type (sort) preserving.\n%%\n%%\\begin{lemma}\n%%%  [Type Transformation]\n%%If \\tologicshort{\\env}{e}{\\typ}{p}{\\sort}{\\smtenv}{\\axioms},\n%%and \\hastype{\\env}{e}{\\typ}, then\n%%\\smthastype{\\smtenvinit, \\embedsort{\\env}}{p}{\\embed{\\typ}}.\n%%\\end{lemma}\n%%\n%%% are defined in the\n%%% %\n%%% Thus, \\smtenvinit includes\n%%% $$\n%%% \\begin{array}{rcll}\n%%% \\smtvar{c}  &\\colon &\\embed{\\constty{c}}\n  %%% &\\forall c\\in \\corelan\\\\\n%%% \\smtlamname{\\sort_x}{\\sort}&\\colon&\\sort_x \\rightarrow \\sort\\rightarrow\\tsmtfun{\\sort_x}{\\sort}\n  %%% &\\forall \\sort_x, \\sort\\in \\smtlan\\\\\n%%% \\smtappname{\\sort_x}{\\sort}&\\colon&\\tsmtfun{\\sort_x}{\\sort} \\rightarrow \\sort_x \\rightarrow \\sort\n  %%% &\\forall \\sort_x, \\sort\\in \\smtlan\\\\\n%%% \\smtvar{\\dc}&\\colon&\\embed{\\constty{\\dc}}\n  %%% &\\forall\\dc\\in\\corelan\\\\\n%%% \\checkdc{\\dc}&\\colon&\\embed{T \\rightarrow \\tbool}\n  %%% &\\forall \\dc\\in \\corelan\\ \\text{of data type}\\ T \\\\\n%%% \\selector{\\dc}{i}&\\colon&\\embed{T \\rightarrow \\typ_i}\n  %%% &\\forall \\dc\\in \\corelan\\ \\text{of data type}\\ T \\\\\n  %%% &&&\\text{and}\\ i\\text{-th argument}\\ \\typ_i \\\\\n%%% {x} & \\colon&{\\sort}&\\text{for each lambda argument} \\\\\n%%% \\end{array}\n%%% $$\n\n\n% \\mypara{Lifted Substitutions}\n\n\n%\n%% as defined\n%% in~\\citep{Vazou15} remove bottoms from expressions\n%% in substitutions and translate via\n%% \\tologic{\\emptyset}{\\star}{}{\\star}{}{}{}\n%% to a set of models $\\sigma \\in \\theta^\\perp$\n%% where each bottom maps to\n%% %\n%%\n%% Such models $\\sigma \\in \\theta^\\perp$\n%% map variables in $\\theta$ to values\n%% in the logic, without providing\n%% interpretations for the\n%% $\\smtlamname{}{}$ and $\\smtappname{}{}$.\n\n\\NV{below we use substitution in lambda s which is not formally defined}\n%\n\\begin{definition}[$\\beta$-Model]\\label{def:beta-model}\nA $\\beta-$model $\\bmodel$ is an extension of a model $\\sigma$\nwhere $\\smtlamname{}{}$ and $\\smtappname{}{}$\nsatisfy the axioms of $\\beta$-equivalence:\n$$\n\\begin{array}{rcl}\n\\forall x\\ y\\ e. \\smtlamname{}{}\\ x\\ e\n  & = & \\smtlamname{}{}\\ y\\ (e\\subst{x}{y}) \\\\\n\\forall x\\ e_x\\ e. (\\smtappname{}{}\\ (\\smtlamname{}{}\\ x\\ e)\\ e_x\n  & = &  e\\subst{x}{e_x}\n\\end{array}\n$$\n\\end{definition}\n\n\\mypara{Semantics Preservation}\n%\nWe define the translation of a \\corelan term\ninto \\smtlan under the empty environment as\n${\\embed{e} \\defeq \\pred}$\nif ${\\tologicshort{\\emptyset}{\\refa}{}{\\pred}{}{}{}}$.\n%\nA \\emph{lifted substitution}\n$\\theta^\\perp$ is a set of models $\\sigma$\nwhere each ``bottom'' in the substitution\n$\\theta$ is mapped to an arbitrary logical\nvalue of the respective sort~\\citep{Vazou14}.\n%\nWe connect the semantics of \\corelan and translated\n\\smtlan via the following theorems:\n% terms can connect evaluation of boolean\n% \\corelan expression to \\smtlan predicates.\n\n\\begin{theorem}\\label{thm:embedding-general}\nIf ${\\tologicshort{\\env}{\\refa}{}{\\pred}{}{}{}}$,\nthen for every ${\\sub\\in\\interp{\\env}}$\nand every ${\\sigma\\in {\\sub^\\perp}}$,\nif $\\evalsto{\\applysub{\\sub^\\perp}{\\refa}}{v}$\nthen $\\sigma^\\beta \\models \\pred = \\embed{v}$.\n\\end{theorem}\n\n% For Boolean expressions we specialize the above to\n\n\\begin{corollary}\\label{thm:embedding}\nIf ${\\hastype{\\env}{\\refa}{\\tbool}}$, $e$ reduces to a value and\n${\\tologicshort{\\env}{\\refa}{\\tbool}{\\pred}{\\tbool}{\\smtenv}{\\axioms}}$,\nthen for every ${\\sub\\in\\interp{\\env}}$\nand every ${\\sigma\\in {\\sub^\\perp}}$,\n$\\evalsto{\\applysub{\\sub^\\perp}{\\refa}}{\\etrue}$ iff\n$\\sigma^\\beta \\models \\pred$.\n\\end{corollary}\n\n\n\n\\subsection{Decidable Type Checking}\n\\begin{figure}[t!]\n\\centering\n$$\n\\begin{array}{rrcl}\n\\emphbf{Refined Types} \\quad\n  & \\typ\n  & ::=   & \\tref{v}{\\btyp^{[\\tlabel]}}{\\reft} \\spmid \\tfun{x}{\\typ}{\\typ}\n\\\\[0.10in]\n\\end{array}\n$$\n\\emphbf{Well Formedness}\\hfill{\\fbox{\\aiswellformed{\\env}{\\typ}}}\\\\\n$$\n\\inference{\n  \\ahastype{\\env,\\tbind{v}{\\btyp}}{\\refa}{\\tbool^{\\tlabel}}\n}{\n  \\aiswellformed{\\env}{\\tref{v}{\\btyp}{\\refa}}\n}[\\rwbase]\n$$\n\\emphbf{Subtyping}\\hfill{\\fbox{\\aissubtype{\\env}{\\typ}{\\typ'}}}\\\\\n$$\n\\inference{\n\\env' \\defeq \\env,\\tbind{v}{\\{\\btyp^\\tlabel | \\refa\\}} &\n\\tologicshort{\\env'}{\\refa'}{\\tbool}{\\pred'}{}{}{} &\n\\smtvalid{\\vcond{\\env'}{\\pred'}}\n%\n}{\n \\aissubtype{\\env}{\\tref{v}{\\btyp}{\\refa}}{\\tref{v}{\\btyp}{\\refa'}}\n}[\\rsubbase]\n$$\n%%%% %\\NV{REVERT TO OLD DEFINITIONS, what is e'?}\n%%%% $$\n%%%% \\inference{\n%%%% \\tologicshort{\\env'}{\\refa_1}{\\tbool}{\\pred_1}{\\tbool}{\\smtenv_1}{\\axioms_1} &\n%%%% \\tologicshort{\\env'}{\\refa_2}{\\tbool}{\\pred_2}{\\tbool}{\\smtenv_1}{\\axioms_1} \\\\\n%%%% % \\isvalid{\\env,\\tbind{v}{\\btyp}}{\\refa_1}{\\refa_2}\n%%%% \\env' \\defeq \\env,\\tbind{v}{\\btyp^\\tlabel} &\n%%%% % \\tologicshort{\\env'}{\\refa'}{\\tbool}{\\pred'}{\\tbool}{\\smtenv'}{\\axioms'} &\n%%%% \\smtvalid{\\vcond{\\env'}{\\pred_1 \\Rightarrow \\pred_2}}\n%%%% %\n%%%% }{\n  %%%% \\aissubtype{\\env}{\\tref{v}{\\btyp}{\\refa_1}}{\\tref{v}{\\btyp}{\\refa_2}}\n%%%% }[\\rsubbase]\n%%%% $$\n%%% \\emphbf{Implication}\\hfill{\\isvalid{\\env}{\\refa_1}{\\refa_2}}\\\\\n%%% $$\n%%% \\inference{\n  %%% \\tologicshort{\\env}{\\refa_1}{\\tbool}{\\pred_1}{\\tbool}{\\smtenv_1}{\\axioms_1} &\n  %%% \\tologicshort{\\env}{\\refa_2}{\\tbool}{\\pred_2}{\\tbool}{\\smtenv_2}{\\axioms_i} \\\\\n  %%% \\text{is SMT-valid}\\ (\\embedexpr{\\env} \\Rightarrow \\pred_1 \\Rightarrow \\pred_2)\n%%% }{\n  %%% \\isvalid{\\env}{\\refa_1}{\\refa_2}\n%%% }\n%%% $$\n%%% \\emphbf{Typing}\\hfill{\\ahastype{\\env}{\\prog}{\\typ}}\\\\\n\\caption{\\textbf{Algorithmic Typing (other rules in Figs~\\ref{fig:syntax} and \\ref{fig:typing}.)}}\n\\label{fig:modifications}\n\\end{figure}\n\nFigure~\\ref{fig:modifications} summarizes the modifications required\nto obtain decidable type checking.\n%\nNamely, basic types are extended with labels that track termination\nand subtyping is checked via an SMT solver.\n\n\\mypara{Termination}\n%\nUnder arbitrary beta-reduction semantics\n(which includes lazy evaluation), soundness\nof refinement type checking requires checking\ntermination, for two reasons:\n%\n(1)~to ensure that refinements cannot diverge, and\n(2)~to account for the environment during subtyping~\\citep{Vazou14}.\n%\nWe use \\tlabel to mark provably terminating\ncomputations, and extend the rules to use\nrefinements to ensure that if\n${\\ahastype{\\env}{e}{\\tref{v}{\\btyp^\\tlabel}{r}}}$,\nthen $e$ terminates~\\citep{Vazou14}.\n%\n%% Here we assume termination is checked by an oracle,\n%% but we can use refinement types themselves to prove\n%% correctness of the termination labeling\n\n\n\\mypara{Verification Conditions}\nThe \\emph{verification condition} (VC)\n${\\vcond{\\env}{\\pred}}$\nis \\emph{valid} only if the set of values\ndescribed by $\\env$, is subsumed by\nthe set of values described by $\\pred$.\n%\n$\\env$ is embedded into logic by conjoining\n(the embeddings of) the refinements of\nprovably terminating binders~\\cite{Vazou14}:\n%\n%% We only trust refinements of terminating\n%% expressions, as every diverging expression\n%% can be unsoundly refined \\efalse.\n%% $$\n%% \\embed{\\env} \\defeq\n  %% \\bigwedge\\{ p \\mid \\tbind{x}{\\tref{v}{\\btyp^{\\tlabel}}{e}} \\in \\env\n   %% \\land \\tologicshort{\\env}{e\\subst{v}{x}}{\\btyp}{p}{\\embed{\\btyp}}{\\smtenv}{\\axioms}\n   %% \\}\n%% $$\n\\begin{align*}\n\\embed{\\env} \\defeq & \\bigwedge_{x \\in \\env} \\embed{\\env, x} \\\\\n\\intertext{where we embed each binder as}\n\\embed{\\env, x} \\defeq & \\begin{cases}\n                           \\pred  & \\text{if } \\env(x)=\\tref{v}{\\btyp^{\\tlabel}}{e},\\\n                                    \\tologicshort{\\env}{e\\subst{v}{x}}{\\btyp}{\\pred}{\\embed{\\btyp}}{\\smtenv}{\\axioms} \\\\\n                           \\etrue & \\text{otherwise}.\n                         \\end{cases}\n\\end{align*}\n\n%We use the embedding of environment to decidably check subtyping.\n%As defined in Figure~\\ref{fig:modifications},\n%\\tref{v}{\\btyp}{\\refa_1} is subtype of \\tref{v}{\\btyp}{\\refa_1}\n%under the environment \\env, when\n%$\\refa_i$ transforms to $\\pred_i$ with axioms $\\axioms_i$\n%and assuming $\\embedexpr{\\env}$ and the axioms $\\axioms_i$\n%$\\pred_i$ implies $\\pred_2$.\n\n\\mypara{Subtyping via SMT Validity}\n%\nWe make subtyping, and hence, typing decidable,\nby replacing the denotational base subtyping\nrule $\\rsubbase$ with a conservative,\nalgorithmic version that uses an SMT\nsolver to check the validity of the subtyping VC.\n%\nWe use Corollary~\\ref{thm:embedding} to prove\nsoundness of subtyping. \n%\n\\begin{lemma}\\label{lem:subtyping} %[Conservative Subtyping]\nIf {\\aissubtype{\\env}{\\tref{v}{\\btyp}{e_1}}{\\tref{v}{\\btyp}{e_2}}}\nthen {\\issubtype{\\env}{\\tref{v}{\\btyp}{e_1}}{\\tref{v}{\\btyp}{e_2}}}.\n\\end{lemma}\n\n%\n\\mypara{Soundness of \\smtlan}\n%\nLemma~\\ref{lem:subtyping} directly implies the soundness of \\smtlan.\n%\n\\begin{theorem}[Soundness of \\smtlan]\\label{thm:soundness-smt}\nIf \\ahastype{\\env}{e}{\\typ} then \\hastype{\\env}{e}{\\typ}.\n\\end{theorem}\n\n\n\\begin{comment}\n\\begin{proof}\nBy rule \\rsubbase, we need to show that\n$\\forall \\sub\\in\\interp{\\env}.\n  \\interp{\\applysub{\\sub}{\\tref{v}{\\btyp}{\\refa_1}}}\n  \\subseteq\n  \\interp{\\applysub{\\sub}{\\tref{v}{\\btyp}{\\refa_2}}}$.\n%\nWe fix a $\\sub\\in\\interp{\\env}$.\nand get that forall bindings\n$(\\tbind{x_i}{\\tref{v}{\\btyp^{\\downarrow}}{\\refa_i}}) \\in \\env$,\n$\\evalsto{\\applysub{\\sub}{e_i\\subst{v}{x_i}}}{\\etrue}$.\n\nThen need to show that for each $e$,\nif $e \\in \\interp{\\applysub{\\sub}{\\tref{v}{\\btyp}{\\refa_1}}}$,\nthen $e \\in \\interp{\\applysub{\\sub}{\\tref{v}{\\btyp}{\\refa_2}}}$.\n\nIf $e$ diverges then the statement trivially holds.\nAssume $\\evalsto{e}{w}$.\nWe need to show that\nif $\\evalsto{\\applysub{\\sub}{e_1\\subst{v}{w}}}{\\etrue}$\nthen $\\evalsto{\\applysub{\\sub}{e_2\\subst{v}{w}}}{\\etrue}$.\n\nLet \\vsub the lifted substitution that satisfies the above.\nThen  by Lemma~\\ref{thm:embedding}\nfor each model $\\bmodel \\in \\interp{\\vsub}$,\n$\\bmodel\\models\\pred_i$, and $\\bmodel\\models q_1$\nfor\n$\\tologicshort{\\env}{e_i\\subst{v}{x_i}}{\\btyp}{\\pred_i}{\\embed{\\btyp}}{\\smtenv_i}{\\axioms_i}$\n$\\tologicshort{\\env}{e_i\\subst{v}{w}}{\\btyp}{q_i}{\\embed{\\btyp}}{\\smtenv_i}{\\beta_i}$.\n%\nSince \\aissubtype{\\env}{\\tref{v}{\\btyp}{e_1}}{\\tref{v}{\\btyp}{e_2}} we get\n$$\n\\bigwedge_i \\pred_i\n\\Rightarrow q_1 \\Rightarrow q_2\n$$\nthus $\\bmodel\\models q_2$.\n%\nBy Theorem~\\ref{thm:embedding} we get $\\evalsto{\\applysub{\\sub}{\\refa_2\\subst{v}{w}}}{\\etrue}$.\n\\end{proof}\n\\end{comment}\n", "meta": {"hexsha": "9b1e7691b14d5fdc240fc50e4a1ad5061afbb1be", "size": 19622, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinementreflection/algorithmic.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinementreflection/algorithmic.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinementreflection/algorithmic.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 31.6483870968, "max_line_length": 120, "alphanum_fraction": 0.6686882071, "num_tokens": 6684, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4459457827031326}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathpartir}\n\n\\newcommand{\\Addr}{a}\n\n\\newcommand{\\KVAR}{\\kappa}\n\\newcommand{\\ONE}{\\circ}\n\\newcommand{\\MANY}{\\ast}\n\n\\newcommand{\\KINDU}{\\textbf{U}}\n\\newcommand{\\KINDA}{\\textbf{A}}\n\n\\newcommand{\\BORROW}[1][\\iota]{\\&^{#1}\\,}\n\n\\newcommand{\\TASS}[1]{#1\\colon\\!}\n\n\\newcommand{\\TVAR}{\\alpha}\n\\newcommand{\\TALL}[2]{\\forall\\TASS{#1}#2.}\n\\newcommand{\\KALL}[1]{\\forall#1.}\n\n\\newcommand{\\LAM}[3][{}]{\\lambda^{#1}\\TASS{#2}#3.}\n\\newcommand{\\APP}[1]{#1\\,}\n\\newcommand{\\TLAM}[3][{}]{\\Lambda^{#1}\\TASS{#2}#3.}\n\\newcommand{\\TAPP}[2]{#1\\,[#2]}\n\\newcommand{\\KLAM}[2][{}]{\\Lambda^{#1}#2.}\n\\newcommand{\\KAPP}[2]{#1\\,\\{#2\\}}\n\n\\newcommand{\\KENV}{\\Delta}\n\\newcommand{\\KENVEMPTY}{\\Diamond}\n\\newcommand{\\TENV}{\\Gamma}\n\\newcommand{\\TENVEMPTY}{\\Diamond}\n\n\\newcommand{\\SPLIT}[3]{#1 \\ltimes #2 = #3} % used to be \\bowtie\n\n\\newcommand\\stepsto{\\longrightarrow}\n\n\\newtheorem{lemma}{Lemma}\n\n\\title{$F^{\\ONE}$ with subkinding}\n\\author{Peter Thiemann}\n\n\\begin{document}\n\\maketitle\nSyntax and rules updated --- possibly inconsistent\n\nSyntax (perhaps more expressions are needed)\n\\begin{align*}\n  k &::= \\KVAR \\mid \\ONE \\mid \\MANY & \\text{kinds, where }  \\MANY \\sqsubseteq \\ONE \\\\\n    &\\mid k \\to k & \\text{constructor kinds}\\\\\n    &\\mid k \\le k \\Rightarrow k & \\text{constrained kinds}\\\\\n    &\\mid \\KALL\\KVAR k & \\text{universal kinds}\\\\\n    % &\\mid k \\le k \\Rightarrow k & \\text{constrained kinds}\\\\\n  t &::= \\TVAR \\mid t \\stackrel{k}{\\to} t \\mid \\TALL\\TVAR k t \\mid \\KALL\\KVAR t \\mid k \\le k \\Rightarrow t & \\text{types} \\\\\n    & \\mid \\LAM\\TVAR k t \\mid \\APP tt \\mid \\KLAM\\KVAR t \\mid \\KAPP t k  & \\text{constructors} \\\\\n  e &::= x \\mid \\LAM[k] x t e \\mid \\APP ee \\mid \\TLAM[k] \\TVAR k v \\mid \\TAPP et \\mid \\KLAM[k] \\KVAR v \\mid \\KAPP ek & \\text{expressions} \\\\\n  v &::=  \\LAM[k] x t e \\mid  \\TLAM[k] \\TVAR k v \\mid \\KLAM[k]\\KVAR v & \\text{values}\n  \\\\\n  \\TENV &::=\n          \\TENVEMPTY\n          \\mid \\TENV, \\TASS x t\n                                    & \\text{type environments}\n  \\\\\n  \\KENV &::= \\KENVEMPTY\n          \\mid \\TENV, \\TASS \\TVAR k\n          \\mid \\TENV, k \\le k\n          \\mid \\TENV, \\KVAR\n                                    & \\text{kind environments}\n\\end{align*}\n%\nKind environment formation\n\\begin{mathpar}\n  \\inferrule{}{\\KENVEMPTY \\models }\n\n  \\inferrule{\\KENV \\models \\\\ \\KENV \\vdash k \\\\ \\TVAR\\notin\\KENV }{\\KENV, \\TASS\\TVAR{k} \\models}\n\n  \\inferrule{\\KENV \\models  \\\\ \\KENV \\vdash k_1, k_2}{\\KENV, k_1 \\le k_2 \\models}\n\n  \\inferrule{\\KENV \\models \\\\ \\KVAR\\notin \\TENV}{\\KENV, \\KVAR \\models }\n\\end{mathpar}\nKind formation\n\\begin{mathpar}\n  \\inferrule{\\KENV, \\KVAR, \\KENV' \\models}{\\KENV, \\KVAR, \\KENV' \\vdash \\KVAR }\n\n  \\inferrule{\\KENV \\models}{\\KENV \\vdash \\ONE}\n\n  \\inferrule{\\KENV \\models}{\\KENV \\vdash \\MANY}\n\n  \\inferrule{\\KENV \\vdash k_1, k_2}{\\KENV \\vdash k_1 \\to k_2}\n\n  \\inferrule{\\KENV, \\KVAR \\vdash k}{\\KENV \\vdash \\KALL\\KVAR k}\n  % \n  % \\inferrule{\\KENV, k_1 \\le k_2 \\vdash k_3}{\\KENV \\vdash k_1 \\le k_2 \\Rightarrow k_3}\n\\end{mathpar}\nSubkinding\n\\begin{mathpar}\n  \\inferrule{\\KENV \\models\\\\k_1 \\sqsubseteq k_2}{\\KENV \\vdash k_1 \\le k_2}\n\n  \\inferrule{\\KENV \\vdash \\KVAR}{\\KENV \\vdash \\KVAR \\le \\KVAR}\n\n  \\inferrule{\\KENV, k_1 \\le k_2, \\KENV' \\models}{\\KENV, k_1 \\le k_2, \\KENV' \\vdash k_1 \\le k_2}\n\n  \\inferrule{\\KENV \\vdash k_2 \\le k_1 \\\\ \\KENV \\vdash k_1' \\le k_2'}{\\KENV \\vdash k_1 \\to k_1' \\le k_2 \\to k_2'}\n\n  \\inferrule{\\KENV, \\KVAR \\vdash k_1 \\le k_2}{\\KENV \\vdash \\KALL\\KVAR k_1 \\le \\KALL\\KVAR k_2}\n\n  % \\inferrule[HOW?]{}{\\KENV \\vdash (k_1 \\le k_2 \\Rightarrow k_3) \\le (k_1' \\le k_2' \\Rightarrow k_3')}\n  %\n  \\inferrule{\\KENV \\vdash k_1 \\le k_2 \\\\\\KENV \\vdash k_2 \\le k_3}{\\KENV \\vdash k_1 \\le k_3}\n\\end{mathpar}\nKinding\n\\begin{mathpar}\n  \\inferrule[KSub]{\\KENV \\vdash t : k \\\\ \\KENV \\vdash k \\le k' }{\\KENV \\vdash t : k'}\n\n  \\inferrule[KFun]{\\KENV \\vdash t_1 : \\ONE \\\\ \\KENV \\vdash t_2 : \\ONE}{ \\KENV \\vdash t_1 \\stackrel{k}{\\to} t_2 : k}\n\n  \\inferrule[KVar]{}{\\KENV, \\TVAR:k, \\KENV' \\vdash \\TVAR:k}\n\n  \\inferrule[KTAll]{\\KENV \\vdash k\\\\ \\KENV, \\TVAR:k \\vdash t:k' \\\\ \\TVAR \\notin \\KENV}{\\KENV \\vdash \\TALL\\TVAR k t : k'}\n\n  \\inferrule[KKAll]{\\KENV, \\KVAR \\vdash t: k \\\\ \\KVAR \\notin \\KENV}{\\KENV \\vdash \\KALL\\KVAR t : k}\n\n  \\inferrule[KConst]{\\KENV \\vdash k_1, k_2 \\\\\n    \\KENV, k_1 \\le k_2 \\vdash t : k}{\\KENV \\vdash k_1 \\le k_2 \\Rightarrow t : k}\n\n  \\inferrule[KTLam]{\\KENV, \\TVAR:k \\vdash t : k'}{\\KENV \\vdash \\LAM\\TVAR k t : k \\to k'}\n\n  \\inferrule[KTApp]{\\KENV \\vdash t_1 : k_2 \\to k_1 \\\\ \\KENV \\vdash t_2 : k_2}{\\KENV \\vdash \\APP{t_1}{t_2} : k_1}\n\n  \\inferrule[KKAll]{\\KENV,\\KVAR \\vdash t : k}{\\KENV \\vdash \\KLAM\\KVAR t : \\KALL\\KVAR k}\n\n  \\inferrule[KKApp]{\\KENV \\vdash t : \\KALL\\KVAR k' \\\\ \\KENV \\vdash k}{\\KENV \\vdash \\KAPP t k : k'[\\KVAR\\mapsto k]}\n\\end{mathpar}\nType environment formation\n\\begin{mathpar}\n  \\inferrule[TEStart]{\\KENV \\models \\\\ \\KENV \\vdash k \\le \\ONE }{\\KENV; \\TENVEMPTY \\models k}\n\n  \\inferrule[TEAssume]{\\KENV; \\TENV \\models k \\\\  \\KENV \\vdash t : k' \\\\ \\KENV \\vdash k' \\le k \\\\ x \\notin \\TENV }{\n    \\KENV; \\TENV, \\TASS x t \\models k}\n\\end{mathpar}\nType conversion (congruence rules omitted)\n\\begin{mathpar}\n  \\inferrule[Conv-Beta]{\\KENV, \\TASS\\TVAR k' \\vdash t:k \\\\ \\KENV \\vdash t' : k' }{\n    \\KENV \\vdash \\APP{(\\LAM\\TVAR {k'} t)}{t'} = t[\\TVAR \\mapsto t'] : k}\n\n  \\inferrule[Conv-KSubst]{\n    \\KENV, \\KVAR \\vdash t : k \\\\ \\KENV \\vdash k'\n  }{\n    \\KENV \\vdash \\KAPP{(\\KLAM\\KVAR t)}{k'} = t[\\KVAR \\mapsto k'] : k[\\KVAR \\mapsto k']}\n\\end{mathpar}\nType environment splitting (sequential)\n\\begin{mathpar}\n  \\inferrule{}{\n    \\KENV \\vdash \\SPLIT{\\TENVEMPTY}{\\TENVEMPTY}{\\TENVEMPTY}}\n\n  \\inferrule{\n    \\KENV \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV} \\\\\n    \\KENV \\vdash \\SPLIT{t_1}{t_2}{t} \\\\\n  }{\n    \\KENV \\vdash \\SPLIT{(\\TENV_1, \\TASS x t_1)}{(\\TENV_2, \\TASS x t_1)}{(\\TENV, \\TASS x t)}}\n\n  \\inferrule{\n    \\KENV \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV} \n  }{\n    \\KENV \\vdash \\SPLIT{(\\TENV_1, \\TASS x t)}{\\TENV_2}{(\\TENV, \\TASS x t)}}\n\n  \\inferrule{\n    \\KENV \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV} \n  }{\n    \\KENV \\vdash \\SPLIT{\\TENV_1}{(\\TENV_2, \\TASS x t)}{(\\TENV, \\TASS x t)}}\n\\end{mathpar}\nType splitting\n\\begin{mathpar}\n  \\inferrule{\n    \\KENV \\vdash t : k \\\\\n    \\KENV \\vdash k \\le \\KINDU_\\infty\n  }{\n    \\KENV \\vdash \\SPLIT{t}{t}{t}\n  }\n\n  \\inferrule{\n    \\KENV \\vdash t : k \\\\\n    \\KENV \\vdash k \\le \\KINDA\n  }{\n    \\KENV \\vdash \\SPLIT{\\BORROW t}{t}{t}\n  }\n\n  \\inferrule{\n    \\KENV \\vdash t : k \\\\\n    \\KENV \\vdash k \\le \\KINDA\n  }{\n    \\KENV \\vdash \\SPLIT{\\BORROW[i] t}{\\BORROW[!]t}{\\BORROW[!]t}\n  }\n\\end{mathpar}\nTyping rules\n\\begin{mathpar}\n  \\inferrule[Conv]{\n    \\KENV; \\TENV \\vdash e:t:k \\\\ \\KENV \\vdash t = t' : k\n  }{\\KENV; \\TENV \\vdash e : t': k}\n\n  \\inferrule[Var]{ \\KENV; \\TENV, \\TENV' \\models \\MANY \\\\ \\KENV \\vdash t : k \\\\ \\KENV \\vdash k \\le \\ONE }{\\KENV; \\TENV, x:t, \\TENV' \\vdash x:t:k }\n\n  \\inferrule[Lam]\n  {\\KENV; \\TENV \\models k \\\\ \\KENV; \\TENV, x:t \\vdash e : t':k'}\n  {\\KENV;\\TENV \\vdash \\LAM[k] xte : t \\stackrel{k}\\to t':k}\n\n  \\inferrule[App]\n  { \\KENV \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV} \\\\\n    \\KENV;\\TENV_1 \\vdash e : t' \\stackrel{k}\\to t:k \\\\\n    \\KENV; \\TENV_2 \\vdash e' : t':k' \\\\\n    \\KENV \\vdash t:k''\n  }\n  { \\KENV; \\TENV \\vdash \\APP ee' : t : k''}\n\n  \\inferrule[TLam]\n  {\\KENV, \\TASS\\TVAR k; \\TENV \\vdash v : t : k' \\\\ \\TVAR \\notin \\KENV}\n  {\\KENV; \\TENV \\vdash (\\TLAM[k']\\TVAR k v) : (\\TALL \\TVAR k t) : k'}\n\n  \\inferrule[TApp]\n  {\n    \\KENV; \\TENV \\vdash e : (\\TALL \\TVAR k t') : k' \\\\\n    \\KENV \\vdash t : k \n  }\n  { \\KENV; \\TENV \\vdash \\TAPP e t : t'[\\TVAR \\mapsto t] : k' }\n\n  \\inferrule[KLam]\n  { \\KENV, \\KVAR; \\TENV \\vdash e : t : k \\\\ \\KVAR \\notin \\KENV}\n  { \\KENV; \\TENV \\vdash \\KLAM[k]\\KVAR e : \\KALL\\KVAR t : k}\n\n  \\inferrule[KApp]\n  { \\KENV; \\TENV \\vdash e : \\KALL\\KVAR t : k' \\\\ \\KENV \\vdash k}\n  { \\KENV; \\TENV \\vdash \\KAPP e k : t[\\KVAR \\mapsto k] : k'[\\KVAR \\mapsto k]}\n\n  \\inferrule[CIntro]\n  { \\KENV,   k_1 \\le k_2; \\TENV \\vdash e : t}\n  { \\KENV; \\TENV \\vdash e :  k_1 \\le k_2 \\Rightarrow t}\n\n  \\inferrule[CElim]\n  { \\KENV; \\TENV \\vdash e :  k_1 \\le k_2 \\Rightarrow t \\\\ \\KENV \\vdash k_1 \\le k_2}\n  { \\KENV; \\TENV \\vdash e : t}\n\\end{mathpar}\n\nSimple small-step semantics (for type preservation) with\n$e[x \\mapsto v]$ standing for capture-avoiding substitution of $v$ for\n$x$ in $e$. Call-by-value as in $F^{\\ONE}$.\n\\begin{mathpar}\n  \\inferrule[V-Beta]{}{\\APP{(\\LAM[k] x t e)}v \\stepsto e[x \\mapsto v]}\n\n  \\inferrule[T-Beta]{}{\\TAPP{(\\TLAM[k'] \\TVAR k v)}t \\stepsto v[\\TVAR \\mapsto t]}\n\n  \\inferrule[K-Beta]{}{\\KAPP{(\\KLAM \\KVAR v)}k \\stepsto v[\\KVAR \\mapsto k]}\n  \\\\\n  \\inferrule[App-Left]{e_1 \\stepsto e_1'\n  }{\\APP{e_1}{e_2} \\stepsto \\APP{e_1'}{e_2}}\n\n  \\inferrule[App-Right]{e \\stepsto e'}{\\APP v e \\stepsto \\APP v e'}\n\n  \\inferrule[TApp-Left]{e \\stepsto e'}{\\TAPP{e} t \\stepsto \\TAPP{e'} t}\n\n  \\inferrule[KApp-Left]{e \\stepsto e'}{\\KAPP{e} k \\stepsto \\KAPP{e'} k}\n\\end{mathpar}\n\n\\clearpage\n\\begin{lemma}[Weakening]\n  Let $\\mathcal{A}$ range over assumptions in kind environments.\n  Let $\\mathcal{J}$ range over judgments in the context of a kind environment. \n\n  If $\\KENV \\vdash \\mathcal{J}$ and $\\KENV, \\mathcal{A} \\models$, then $\\KENV, \\mathcal{A} \\vdash \\mathcal{J}$.\n\\end{lemma}\n\\begin{lemma}[Unrestricted Weakening]\n  Suppose that $\\KENV; \\TENV \\vdash e : t$, $x\\notin \\TENV$, and $\\KENV \\vdash t_x : \\MANY$.\n  Then  $\\KENV; \\TENV, x : t_x \\vdash e : t$.\n\\end{lemma}\n\\begin{lemma}[Value Substitution]\\label{lemma:value-substitution}\n  Suppose that $\\KENV; \\TENV, x:t_x \\vdash e : t$\n  and $\\KENV; \\TENVEMPTY \\vdash v : t'$\n  and $\\KENV \\vdash t_x = t' : k'$.\n  Then $\\KENV; \\TENV \\vdash e[x \\mapsto v] : t$.\n\\end{lemma}\n\\begin{proof}\n  As the conversion assumes the empty environment, it cannot be\n  affected by adding further assumptions.\n\n  The proof proceeds by induction on the derivation of  $\\KENV; \\TENV, x:t_x\n  \\vdash e : t$ and produces a derivation for the term after\n  substitution. The only interesting case is the one for the\n  \\TirName{Var} rule when the variable is $x$:\n  \\begin{mathpar}\n    \\inferrule[Var]{ \\KENV;\\TENV \\models \\MANY \\\\ \\KENV \\models t_x : k' \\\\ \\KENV \\vdash k' \\le \\ONE }{\\TENV, x:t_x \\vdash x:t_x }\n  \\end{mathpar}\n  By unrestricted weakening we have that\n  \\begin{gather*}\n    \\KENV; \\TENV \\vdash v : t' \\\\\n    \\KENV \\vdash t_x = t' : k'\n  \\end{gather*}\n  and hence by \\TirName{Conv} and symmetry of $=$, we have the desired outcome\n  \\begin{gather*}\n    \\KENV; \\TENV \\vdash v : t_x\n  \\end{gather*}\n\\end{proof}\n\\begin{lemma}[Type Substitution]\\label{lemma:type-substitution}\n  Suppose that $\\KENV \\vdash t' : k'$.\n  \\begin{enumerate}\n  \\item\\label{item:1} If $\\KENV, \\TASS\\TVAR {k'} \\vdash t : k$, then\n    $\\KENV \\vdash t[\\TVAR \\mapsto t'] : k$.\n  \\item\\label{item:3} If $\\KENV, \\TASS\\TVAR {k'}; \\TENV \\models k$,\n    then $\\KENV; \\TENV[\\TVAR \\mapsto t'] \\models k$.\n  \\item\\label{item:5} If $\\KENV, \\TASS\\TVAR {k'} \\vdash t_1 = t_2 : k$,\n    then $\\KENV \\vdash t_1[\\TVAR \\mapsto t'] = t_2[\\TVAR \\mapsto t'] : k$.\n  \\item\\label{item:4} If\n    $\\KENV, \\TASS\\TVAR {k'} \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV}$,\n    then $\\KENV \\vdash \\SPLIT{\\TENV_1[\\TVAR \\mapsto t']}{\\TENV_2[\\TVAR \\mapsto t']}{\\TENV[\\TVAR \\mapsto t']}$.\n  \\item\\label{item:2} If $\\KENV, \\TASS\\TVAR {k'}; \\TENV \\vdash e : t$, then\n    $\\KENV; \\TENV[\\TVAR \\mapsto t'] \\vdash e[\\TVAR \\mapsto t'] : t[\\TVAR \\mapsto t']$.\n  \\end{enumerate}\n\\end{lemma}\n\\begin{proof}\n  \\textbf{Item}~\\ref{item:1} is proved by induction on the derivation of\n  $\\KENV, \\TASS\\TVAR {k'} \\vdash t : k$.\n\n  The only interesting rule is \\TirName{KVar}:\n  $\\KENV, \\TASS\\TVAR {k'} \\vdash \\TVAR : k'$. As\n  $\\TVAR[\\TVAR \\mapsto t'] = t'$, we have $\\KENV \\vdash t' : k'$ by\n  assumption.\n\n  All remaining cases are immediate by appeal to the inductive hypothesis.\n\n  \\textbf{Item}~\\ref{item:3} is proved by induction on the derivation of\n  $\\KENV, \\TASS\\TVAR {k'}; \\TENV \\models k$.\n\n  \\textbf{Case} \\TirName{TEStart}. Immediate.\n\n  \\textbf{Case} \\TirName{TEAssume}. From $\\KENV, \\TASS\\TVAR {k'}; \\TENV, \\TASS x t \\models k$ inversion yields\n  \\begin{gather}\n    \\label{eq:4}\n    \\KENV, \\TASS\\TVAR {k'}; \\TENV \\models k \\\\\n    \\KENV, \\TASS\\TVAR {k'} \\vdash t : k'' \\\\\n    \\KENV, \\TASS\\TVAR {k'} \\vdash k'' \\le k \\\\\n    x \\notin \\TENV\n  \\end{gather}\n  By induction from~\\eqref{eq:4}\n  \\begin{gather}\n    \\KENV; \\TENV[\\TVAR \\mapsto t'] \\models k\n  \\end{gather}\n  By Item~\\ref{item:1}\n  \\begin{gather}\n    \\KENV \\vdash t[\\TVAR\\mapsto t'] : k''\n  \\end{gather}\n  As $\\TVAR\\notin k'', k$\n  \\begin{gather}\n    \\KENV \\vdash k'' \\le k\n  \\end{gather}\n  By \\TirName{TEAssume}\n  \\begin{gather}\n    \\KENV; (\\TENV, \\TASS x t)[\\TVAR \\mapsto t'] \\models k\n  \\end{gather}\n\n  \\textbf{Item}~\\ref{item:5} is proved by induction on the derivation of\n  $\\KENV, \\TASS\\TVAR{ k'} \\vdash t_1 = t_2 : k$.\n\n  \\textbf{Item}~\\ref{item:4} is proved by induction on the derivation of splitting.\n\n  \\textbf{Item}~\\ref{item:2} is proved by induction on the derivation of\n  $\\KENV, \\TASS\\TVAR k; \\TENV \\vdash e : t$.\n\n  \\textbf{Case} \\TirName{Conv}: immediate by Item~\\ref{item:5}.\n\n  \\textbf{Case} \\TirName{Var}: immediate by Item~\\ref{item:1} and Item~\\ref{item:3}.\n\n  \\textbf{Case} \\TirName{Lam}: by Item~\\ref{item:3} and induction.\n\n  \\textbf{Case} \\TirName{App}: by Item~\\ref{item:4} and induction.\n\n  The remaining cases present no new problems.\n\\end{proof}\nKind substitution can lead to unsatisfiable constraints. That does not\nmean that kind substitution is bad, but that a value with a bad kind\nsubstitution cannot be used as the unsatisfiable sonstraint cannot be\neliminated by \\TirName{CElim}!\n\\begin{lemma}[Kind Substitution]\\label{lemma:kind-substitution}\n  Suppose that $\\KENV \\vdash k$.\n  \\begin{enumerate}\n  \\item If $\\KENV, \\KVAR \\vdash t : k'$,\n    then $\\KENV \\vdash t[\\KVAR \\mapsto k] : k'[\\KVAR \\mapsto k]$.\n  \\item If $\\KENV, \\KVAR \\vdash t = t' : k'$,\n    then $\\KENV \\vdash t[\\KVAR \\mapsto k] = t'[\\KVAR \\mapsto k] : k'[\\KVAR \\mapsto k]$.\n  \\item If $\\KENV, \\KVAR ; \\TENV \\models k'$,\n    then $\\KENV; \\TENV[\\KVAR \\mapsto k] \\models k'[\\KVAR \\mapsto k]$.\n  \\item If $\\KENV,\\KVAR \\vdash k_1 \\le k_2$,\n    then $\\KENV \\vdash k_1[\\KVAR \\mapsto k] \\le k_2[\\KVAR \\mapsto k]$.\n  \\item If $\\KENV, \\KVAR \\vdash \\SPLIT{\\TENV_1}{\\TENV_2}{\\TENV}$,\n    then $\\KENV \\vdash \\SPLIT{\\TENV_1[\\KVAR \\mapsto k]}{\\TENV_2[\\KVAR \\mapsto k]}{\\TENV[\\KVAR \\mapsto k]}$. \n  \\item If $\\KENV, \\KVAR; \\TENV \\vdash e : t$,\n    then $\\KENV; \\TENV[\\KVAR \\mapsto k] \\vdash e[\\KVAR \\mapsto k] : t[\\KVAR \\mapsto k]$.\n  \\end{enumerate}\n\\end{lemma}\n\\begin{proof}\n  \\textbf{!!! TODO !!!}\n\\end{proof}\n\\begin{lemma}[Inversion for Function Type]\\label{lemma:inversion-function}\n  If $\\KENV; \\TENVEMPTY \\vdash \\LAM x {t_x} e : t_f$,\n  then there is some $n\\ge0$ and $k_{i1}$, $k_{i2}$ (for $1\\le i\\le n$) such that \n  \\begin{gather}\n    \\KENV \\vdash t_f = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow t_x \\stackrel{k}\\to t : k'\n    \\\\\n    \\KENV; \\TASS x{t_x} \\vdash e : t\n    \\\\\n    \\KENV \\vdash k' \\le \\ONE\n    \\\\\n    \\KENV \\vdash k \\le \\ONE\n    \\mathrm{.}\n  \\end{gather}\n\\end{lemma}\n\\begin{proof}\n  Induction on the derivation of\n  $\\KENV; \\TENVEMPTY \\vdash \\LAM x {t_x} e : t_f$.\n\n  \\textbf{Case} \\TirName{Lam}. Rule inversion yields $\\KENV \\models$,\n  $\\KENV \\vdash k \\le \\ONE$, $t_f = t_x \\stackrel{k}\\to t$, and\n  $\\KENV; \\TASS x{t_x} \\vdash e : t$. By reflexivity of conversion\n  $\\KENV \\vdash t_f = t_x \\stackrel{k}\\to t : k'$, for some\n  $\\KENV \\vdash k' \\le \\ONE$, and the claim holds for $n=0$.\n\n  \\textbf{Case} \\TirName{Conv}. Rule inversion yields\n  $\\KENV; \\TENVEMPTY \\vdash \\LAM x {t_x} e : t_1$ and\n  $\\KENV \\vdash t_1 = t_f : k'$ with $\\KENV \\vdash k' \\le\n  \\ONE$. Conclude by induction and by transitivity of conversion.\n\n  \\textbf{Case} \\TirName{CIntro}. Rule inversion yields that\n  $t_f = k_1 \\le k_2 \\Rightarrow t_1$ and\n  $\\KENV, k_1 \\le k_2; \\TENVEMPTY \\vdash e : t_1$. By induction,\n  $\\KENV \\vdash t_1 = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le\n  k_{n2} \\Rightarrow t_x \\stackrel{k}\\to t : k'$ so by congruence\n  $\\KENV \\vdash t_f = k_1 \\le k_2 \\Rightarrow k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le\n  k_{n2} \\Rightarrow t_x \\stackrel{k}\\to t : k'$, which proves the claim.\n\n  \\textbf{Case} \\TirName{CElim}. Rule inversion yields that\n  $\\KENV; \\TENVEMPTY \\vdash \\LAM x {t_x} e : t_1$ with\n  $t_1 = k_1 \\le k_2 \\Rightarrow t_f$ and $\\KENV \\vdash k_1 \\le\n  k_2$. By induction\n  $\\KENV \\vdash t_1 = k_1 \\le k_2 \\Rightarrow k_{11}\\le\n  k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow t_x\n  \\stackrel{k}\\to t : k'$ so that by congruence\n  $\\KENV \\vdash t_f = k_{11}\\le\n  k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow t_x\n  \\stackrel{k}\\to t : k'$, which proves the claim.\n\\end{proof}\n\\begin{lemma}[Inversion for Type Abstraction]\\label{lemma:inversion-universal}\n  Suppose that $\\KENV; \\TENVEMPTY \\vdash \\TLAM\\TVAR k v : t_a$.\n  Then there is some $n\\ge0$ and $k_{i1}$, $k_{i2}$ (for $1\\le i\\le n$) such that \n  \\begin{gather}\n    \\KENV \\vdash t_a = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow \\TALL \\TVAR k t' : k'\n    \\\\\n    \\KENV, \\TASS \\TVAR{k}; \\TENVEMPTY \\vdash v : t'\n    \\\\\n    \\KENV \\vdash k' \\le \\ONE\n    \\mathrm{.}\n  \\end{gather}\n\\end{lemma}\n\\begin{proof}\n  Analogous to Lemma~\\ref{lemma:inversion-function}.\n\\end{proof}\n\\begin{lemma}[Inversion for Kind Abstraction]\\label{lemma:inversion-kind-abstraction}\n  Suppose that $\\KENV; \\TENVEMPTY \\vdash \\KLAM\\KVAR v : t_a$.\n  Then there is some $n\\ge0$ and $k_{i1}$, $k_{i2}$ (for $1\\le i\\le n$) such that \n  \\begin{gather}\n    \\KENV \\vdash t_a = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow \\KALL \\KVAR t' : k'\n    \\\\\n    \\KENV, \\KVAR; \\TENVEMPTY \\vdash v : t'\n    \\\\\n    \\KENV \\vdash k' \\le \\ONE\n    \\mathrm{.}\n  \\end{gather}\n\\end{lemma}\n\\begin{proof}\n  Analogous to Lemma~\\ref{lemma:inversion-function}.\n\\end{proof}\n\\begin{lemma}[Type Preservation]~\\\\\n  Suppose that $\\KENV; \\TENVEMPTY \\vdash e : t$ and $e \\stepsto e'$.\n  Then $\\KENV;\\TENVEMPTY \\vdash e' : t$.\n\\end{lemma}\n\\begin{proof}\n  In each case we proceed by induction on the derivation of the\n  assumed judgment.  If the top-level rule is \\TirName{Conv},\n  \\TirName{CIntro}, or \\TirName{CElim}, then the claim holds by\n  induction.\n\n  \\textbf{Case} ${\\APP{(\\LAM x {t_x} e)}v \\stepsto e[x \\mapsto v]}$.\n\n  By assumption $\\KENV;\\TENVEMPTY \\vdash \\APP{(\\LAM x {t_x} e)}v : t$.\n\n\n  If the top-level rule is \\TirName{App} rule, we can apply inversion to find\n  \\begin{gather}\n    \\label{eq:1}\n    \\KENV; \\TENVEMPTY \\vdash \\LAM x {t_x} e : t' \\stackrel{k}\\to t\n    \\\\\n    \\label{eq:2}\n    \\KENV; \\TENVEMPTY \\vdash v : t'\n  \\end{gather}\n  By Lemma~\\ref{lemma:inversion-function}, there exists an $n\\ge0$ and $k_{i1}$, $k_{i2}$ (for $1\\le i\\le n$) such that\n  \\begin{gather}\n    \\KENV \\vdash t' \\stackrel{k}\\to t = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow t_x \\stackrel{k}\\to t : k'\n    \\\\\n    \\KENV; \\TASS x{t_x} \\vdash e : t\n  \\end{gather}\n  Hence, $n=0$ and \n  \\begin{gather}\n    \\KENV \\vdash t' \\stackrel{k}\\to t = t_x \\stackrel{k}\\to t : k'\n  \\end{gather}\n  from which we can follow\n  \\begin{gather}\n    \\label{eq:3}\n    \\KENV \\vdash t_x = t' : k' \\text{ where } \\KENV \\vdash k' \\le \\ONE\n  \\end{gather}\n  With these assumptions, we apply value substitution\n  (Lemma~\\ref{lemma:value-substitution}) to obtain the result.\n\n  \\textbf{Case} $\\TAPP{(\\TLAM \\TVAR k v)}{t'} \\stepsto v[\\TVAR \\mapsto t']$.\n\n  By assumption\n  $\\KENV;\\TENVEMPTY \\vdash \\TAPP{(\\TLAM \\TVAR k v)}{t'} :\n  t$. Inversion of the \\TirName{TApp} rule yields\n  \\begin{gather}\n    \\KENV; \\TENVEMPTY \\vdash \\TLAM \\TVAR k v : \\TALL\\TVAR k t_0 \\\\\n    \\KENV \\vdash t' : k \\\\\n    t = t_0 [\\TVAR\\mapsto t']\n  \\end{gather}\n  By Lemma~\\ref{lemma:inversion-universal}, there exists an $n\\ge0$ and $k_{i1}$, $k_{i2}$ (for $1\\le i\\le n$) such that\n  \\begin{gather}\n    \\KENV \\vdash \\TALL\\TVAR k t_0 = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow \\TALL\\TVAR k t_1 : k_1\n    \\\\\n    \\label{eq:5}\n    \\KENV, \\TASS \\TVAR{k}; \\TENVEMPTY \\vdash v : t_1\n  \\end{gather}\n  Hence, $n=0$ and\n  \\begin{gather}\n    \\KENV \\vdash \\TALL\\TVAR k t_0 = \\TALL\\TVAR k t_1 : k_1\n  \\end{gather}\n  from which we can follow\n  \\begin{gather}\n    \\label{eq:6}\n    \\KENV, \\TASS\\TVAR k \\vdash t_0 = t_1 : k_1\n  \\end{gather}\n  By Lemma~\\ref{lemma:type-substitution} (type substitution) applied to~\\eqref{eq:5}\n  \\begin{gather}\n    \\label{eq:7}\n    \\KENV; \\TENVEMPTY \\vdash v[\\TVAR \\mapsto t'] : t_1[\\TVAR \\mapsto t']\n  \\end{gather}\n  By Lemma~\\ref{lemma:type-substitution} (type substitution) applied to~\\eqref{eq:6}\n  \\begin{gather}\n    \\label{eq:8}\n    \\KENV \\vdash t_0[\\TVAR \\mapsto t'] = t_1[\\TVAR \\mapsto t'] : k_1\n  \\end{gather}\n  By \\TirName{Conv} applied to~\\eqref{eq:7} and~\\eqref{eq:8}\n  \\begin{gather}\n    \\KENV; \\TENVEMPTY \\vdash v[\\TVAR \\mapsto t'] : t\n  \\end{gather}\n  as required.\n\n  \\textbf{Case} $\\KAPP{(\\KLAM \\KVAR v)}k \\stepsto v[\\KVAR \\mapsto k]$.\n\n  By inversion of rule \\TirName{KApp}, we obtain from\n  $\\KENV; \\TENVEMPTY \\vdash \\KAPP{(\\KLAM \\KVAR v)}k : t_e$ that\n  \\begin{gather}\n    t_e =  t[\\KVAR \\mapsto k] \\\\\n    \\label{eq:9}\n    \\KENV; \\TENVEMPTY \\vdash \\KLAM \\KVAR v : \\KALL\\KVAR t \\\\\n    \\KENV \\vdash k\n  \\end{gather}\n  By Lemma~\\ref{lemma:inversion-kind-abstraction} applied to~\\eqref{eq:9} we find that\n  \\begin{gather}\n    \\KENV \\vdash\n    \\KALL\\KVAR t\n    = k_{11}\\le k_{12}\\Rightarrow \\dots k_{n1}\\le k_{n2} \\Rightarrow\n    \\KALL \\KVAR t' : k'     \\\\\n    \\label{eq:10}\n    \\KENV, \\KVAR; \\TENVEMPTY \\vdash v : t'\n  \\end{gather}\n  so that $n=0$ and\n  \\begin{gather}\n    \\KENV \\vdash\n    \\KALL\\KVAR t\n    = \n    \\KALL \\KVAR t' : k'\n  \\end{gather}\n  and thus\n  \\begin{gather}\\label{eq:11}\n    \\KENV, \\KVAR \\vdash\n    t\n    = \n    t' : k'\n  \\end{gather}\n  Applying kind substitution to~\\eqref{eq:10} and~\\eqref{eq:11} yields\n  \\begin{gather}\n    \\KENV; \\TENVEMPTY \\vdash v[\\KVAR \\mapsto k] : t'[\\KVAR \\mapsto k]\n    \\\\\n    \\KENV \\vdash\n    t[\\KVAR \\mapsto k]\n    = \n    t'[\\KVAR \\mapsto k] : k'[\\KVAR \\mapsto k]\n  \\end{gather}\n  and thus by \\TirName{Conv} the desired\n  \\begin{gather}\n    \\KENV; \\TENVEMPTY \\vdash v[\\KVAR \\mapsto k] : t_e\n  \\end{gather}\n\n  \\textbf{Case} reduction in context by rules \\TirName{App-Left},\n  \\TirName{App-Right}, \\TirName{TApp-Left}, and \\TirName{KApp-Left}. The result is\n  immediate by inversion of the respective rule and then by appeal to the inductive hypothesis.\n\\end{proof}\n\nTODO: \nTemplates in $F^{\\ONE}$, work by Morris, Bernardi, and others.\n\n\\section{Allocating Semantics}\n\nA more elaborate big-step semantics that allocates all values on the\nheap and removes linear values after they are used.  The evaluation\njudgement is thus $H, e \\Downarrow H, \\Addr$ where $H$ is a heap that\nbinds addresses $\\Addr$ to values, which are abstractions that may\ncontain addresses themselves, but no free variables.\n\n\\begin{mathpar}\n  \\inferrule{}{H, \\LAM[k] x t e \\Downarrow H+ (\\Addr \\mapsto \\LAM[k] x t e), \\Addr}\n\n  \\inferrule{\n    H_1, e_1 \\Downarrow H_2, \\Addr_1 \\\\\n    H_2 (\\Addr_1) = \\LAM[k]x t e \\\\\n    H_2' = H_2 \\text{ if $k=\\MANY$ else } H_2 \\setminus \\Addr_1\n    \\\\\\\\\n    H_2', e_2 \\Downarrow H_3, \\Addr_2 \\\\\n    H_3, e[x \\mapsto \\Addr_2] \\Downarrow H_4, \\Addr\n  }{H_1, \\APP{e_1}{e_2} \\Downarrow H_4, \\Addr}\n\n  \\inferrule{}{\n    H, \\TLAM[k']\\TVAR k v \\Downarrow H+ (\\Addr \\mapsto \\TLAM[k']\\TVAR k v), \\Addr\n  }\n\n  \\inferrule{\n    H, e \\Downarrow H', \\Addr' \\\\\n    H' (\\Addr') = \\TLAM[k']\\TVAR k v \\\\\n    H'' = H' \\text{ if $k'=\\MANY$ else } H' \\setminus \\Addr'\n  }{\n    H, \\TAPP e t \\Downarrow H''+ (\\Addr \\mapsto v[\\TVAR \\mapsto t]), \\Addr\n  }\n\n  \\inferrule{}{\n    H, \\KLAM[k]\\KVAR v \\Downarrow H+ (\\Addr \\mapsto \\KLAM[k]\\KVAR v), \\Addr\n  }\n\n  \\inferrule{\n    H, e \\Downarrow H', \\Addr' \\\\\n    H' (\\Addr') = \\KLAM[k']\\KVAR v \\\\\n    H'' = H' \\text{ if $k'=\\MANY$ else } H' \\setminus \\Addr'\n  }{\n    H, \\KAPP e k \\Downarrow H''+ (\\Addr\\mapsto v[\\KVAR\\mapsto k]),\n    \\Addr\n  }\n\\end{mathpar}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "831931076544f6d8b0549a430cbc4cca71833f60", "size": 23937, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fpop/spec.tex", "max_stars_repo_name": "m0rphism/uniqueness", "max_stars_repo_head_hexsha": "0fb8834e5739fdfe1fe78b056e233e6afbbc9921", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-08T07:19:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-24T19:19:31.000Z", "max_issues_repo_path": "fpop/spec.tex", "max_issues_repo_name": "m0rphism/uniqueness", "max_issues_repo_head_hexsha": "0fb8834e5739fdfe1fe78b056e233e6afbbc9921", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fpop/spec.tex", "max_forks_repo_name": "m0rphism/uniqueness", "max_forks_repo_head_hexsha": "0fb8834e5739fdfe1fe78b056e233e6afbbc9921", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-05-08T11:59:52.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-13T17:05:05.000Z", "avg_line_length": 35.7268656716, "max_line_length": 145, "alphanum_fraction": 0.6169110582, "num_tokens": 10004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.445920152390881}}
{"text": "\\chapter{The source code}\n\n\\section{Introduction}\n\n\\section{Data types}\n\nThere are several new types, the two most important ones are\n\\begin{itemize}\n\\item{REAL}\\\\\nREAL is a floating point number. It is defined in `src/constants.h' as\n\\begin{verbatim}\n     #define REAL double\n\\end{verbatim}\nbut if one needs higher precision one could use\n\\begin{verbatim}\n     #define REAL long double\n\\end{verbatim}\nand using the `qd' library it is even possible to use arbitrary precision.\n\\item{VECTOR}\\\\\nAn structure with three elements `x', `y', and `z'.\n\\begin{verbatim}\n     typedef struct point\n     {\n       REAL x;\n       REAL y;\n       REAL z;\n     } POINT,VECTOR;\n\\end{verbatim}\n\\item{REAL\\_MATRIX3x3}\\\\\nA $3\\times3$ matrix, used as transformations on vectors (like `strain') and for the three cell-vectors making up the cell matrix. It is defined in `src/matrix.h'.\n\\begin{verbatim}\n     typedef struct real_matrix3x3\n     {\n       REAL ax;\n       REAL ay;\n       REAL az;\n\n       REAL bx;\n       REAL by;\n       REAL bz;\n\n       REAL cx;\n       REAL cy;\n       REAL cz;\n     } REAL_MATRIX3x3;\n\\end{verbatim}\n\\end{itemize}\n\n\\section{Datastructures}\n\n\\subsection*{Box properties and periodic boundaries}\n\nFor each system, a cell box and other properties are defined in `src/simulation.h'\n\\begin{footnotesize}\n\\begin{verbatim}\n     REAL_MATRIX3x3 *Box;                   // the cell matrix\n     REAL_MATRIX3x3 *InverseBox;            // the inverse of the cell matrix\n     REAL_MATRIX3x3 *ReplicaBox;            // the cell matrix of the replica system\n     REAL_MATRIX3x3 *InverseReplicaBox;     // the inverse of the the cell matrix of the replica system\n     INT_VECTOR3 *NumberOfReplicaCells;     // the integere number of replicas in each direction a,b,c\n     int *TotalNumberOfReplicaCells;        // the total number of replica cells\n     VECTOR *ReplicaShift;                  // the shift in a,b,c for each replica cell\n     int *UseReplicas;                      // whether or not to use replicas\n     REAL_MATRIX3x3 *BoxProperties;         // properties of the cell matrix (i.e. perpendicular lengths)\n     REAL_MATRIX3x3 *InverseBoxProperties;  // properties of the inverse cell matrix\n     REAL *Volume;                          // the volume\n     REAL *AlphaAngle;                      // the alpha-angle of the cell\n     REAL *BetaAngle;                       // the beta-angle of the cell\n     REAL *GammaAngle;                      // the gamma-angle of the cell\n     int *BoundaryCondition;                // the boundary condition (i.e. `RECTANGULAR' or `TRICLINIC')\n\\end{verbatim}\n\\end{footnotesize}\nThese are dynamically allocated arrays and have the same length as the amount of systems present. For example, in a Gibbs simulation two systems are needed, \none for the gas-phase and one for the liquid phase. `Volume[0]' would give the volume of the first cell, and `Volume[1]' would give the volume of the second cell.\n\nPeriodic boundaries are applied after each distance computation calling the function `ApplyBoundaryCondition' (defined in `src/potentials.h')\nIt operates on a `VECTOR' and give the corrected vector back. The system is specified with the global variable `CurrentSystem'.\n\\begin{footnotesize}\n\\begin{verbatim}\n     VECTOR ApplyBoundaryCondition(VECTOR dr)\n     {\n       VECTOR s,t;\n\n       switch(BoundaryCondition[CurrentSystem])\n       {\n         case FINITE:\n           break;\n         case RECTANGULAR:\n         case CUBIC:\n           dr.x-=Box[CurrentSystem].ax*(REAL)NINT(dr.x*InverseBox[CurrentSystem].ax);\n           dr.y-=Box[CurrentSystem].by*(REAL)NINT(dr.y*InverseBox[CurrentSystem].by);\n           dr.z-=Box[CurrentSystem].cz*(REAL)NINT(dr.z*InverseBox[CurrentSystem].cz);\n           break;\n         case TRICLINIC:\n           // convert from xyz to abc\n           s.x=InverseBox[CurrentSystem].ax*dr.x+InverseBox[CurrentSystem].bx*dr.y+InverseBox[CurrentSystem].cx*dr.z;\n           s.y=InverseBox[CurrentSystem].ay*dr.x+InverseBox[CurrentSystem].by*dr.y+InverseBox[CurrentSystem].cy*dr.z;\n           s.z=InverseBox[CurrentSystem].az*dr.x+InverseBox[CurrentSystem].bz*dr.y+InverseBox[CurrentSystem].cz*dr.z;\n\n           // apply boundary condition\n           t.x=s.x-(REAL)NINT(s.x);\n           t.y=s.y-(REAL)NINT(s.y);\n           t.z=s.z-(REAL)NINT(s.z);\n\n           // convert from abc to xyz\n           dr.x=Box[CurrentSystem].ax*t.x+Box[CurrentSystem].bx*t.y+Box[CurrentSystem].cx*t.z;\n           dr.y=Box[CurrentSystem].ay*t.x+Box[CurrentSystem].by*t.y+Box[CurrentSystem].cy*t.z;\n           dr.z=Box[CurrentSystem].az*t.x+Box[CurrentSystem].bz*t.y+Box[CurrentSystem].cz*t.z;\n           break;\n         default:\n           fprintf(stderr,\"Error: Unkown boundary condition....\\n\");\n           exit(0);\n           break;\n       }\n       return dr;\n     }\n\\end{verbatim}\n\\end{footnotesize}\nThe function `NINT' is faster version of `rint' (or `floor').\n\\begin{footnotesize}\n\\begin{verbatim}\n     #define NINT(x) ((int)((x)>=0.0?((x)+0.5):((x)-0.5)) )\n\\end{verbatim}\n\\end{footnotesize}\nA common occurrence of the boundary conditions application is for two positions of atoms `posA' and `posB' (of type `VECTOR')\n\\begin{footnotesize}\n\\begin{verbatim}\n     dr.x=posA.x-posB.x;\n     dr.y=posA.y-posB.y;\n     dr.z=posA.z-posB.z;\n     dr=ApplyBoundaryCondition(dr);\n     rr=SQR(dr.x)+SQR(dr.y)+SQR(dr.z);\n     r=sqrt(rr);\n\\end{verbatim}\n\\end{footnotesize}\n\n\\noindent\nThere are functions you can use to transform from Cartesian to fractional coordinates (defined in `src/potentials.h')\n\\begin{footnotesize}\n\\begin{verbatim}\n     VECTOR ConvertFromXYZtoABC(VECTOR t)\n     {\n       VECTOR s;\n\n       s.x=InverseBox[CurrentSystem].ax*t.x+InverseBox[CurrentSystem].bx*t.y+InverseBox[CurrentSystem].cx*t.z;\n       s.y=InverseBox[CurrentSystem].ay*t.x+InverseBox[CurrentSystem].by*t.y+InverseBox[CurrentSystem].cy*t.z;\n       s.z=InverseBox[CurrentSystem].az*t.x+InverseBox[CurrentSystem].bz*t.y+InverseBox[CurrentSystem].cz*t.z;\n       return s;\n     }\n\\end{verbatim}\n\\end{footnotesize}\nand from fractional coordinates to Cartesian\n\\begin{footnotesize}\n\\begin{verbatim}\n     VECTOR ConvertFromABCtoXYZ(VECTOR t)\n     {\n       VECTOR dr;\n\n       dr.x=Box[CurrentSystem].ax*t.x+Box[CurrentSystem].bx*t.y+Box[CurrentSystem].cx*t.z;\n       dr.y=Box[CurrentSystem].ay*t.x+Box[CurrentSystem].by*t.y+Box[CurrentSystem].cy*t.z;\n       dr.z=Box[CurrentSystem].az*t.x+Box[CurrentSystem].bz*t.y+Box[CurrentSystem].cz*t.z;\n       return dr;\n     }\n\\end{verbatim}\n\\end{footnotesize}\n\n\\subsection*{(Pseudo-)atoms}\n\nThe data structure `PSEUDO\\_ATOM' contains information on atoms, either real atoms or united atoms where several atoms are lumped together (for example: CH3).\n\n\\begin{footnotesize}\n\\begin{verbatim}\n     // Pseudoatoms\n     typedef struct PseudoAtom\n     {\n       char Name[256];              // the Name of the pseudo-atom (`CH3',`H',`O' etc).\n       char PrintToPDBName[256];    // the string to print to a pdb-file as name\n       int  PrintToPDB;             // whether to write this atom to the pdf-file or not\n       char ChemicalElement[256];   // the chemical element (`O', `H', etc)\n       int ScatteringType;          // the scattering type (powder diffraction)\n       int AnomalousScatteringType; // the anmalous scattering type (powder diffraction)\n       REAL TemperatureFactor;      // the temperature factor (powder diffraction)\n       REAL Mass;                   // the mass of the pseudo-atom\n       REAL Charge;                 // the charge of the pseudo-atom\n       REAL Polarization;           // the polarization of the atom\n       int HasCharges;              // whether or not the atom has atoms with charges \n       int IsPolarizable;           // whether or not the atom has a induced point dipole\n       int Interaction;             // whether or not the atom has interactions\n       REAL Radius;                 // the radius (used for calculating Bonds in the zeolite)\n       int Connectivity;            // the connectivity (used for calculating Bonds/Bends/Torsion in the framework)\n     } PSEUDO_ATOM;\n\\end{verbatim}\n\\end{footnotesize}\n\n\\noindent\nA typical use is, once the type is known, to retrieve the charge for a pseudo-atoms:\n\\begin{verbatim}\n     REAL q;\n     q=PseudoAtom[type].Charge;\n\\end{verbatim}\nUse the following to find out to what pseudoatom a string corresponds to\n\\begin{verbatim}\n     int type;\n     type=ReturnPseudoAtomNumber(\"CH4\");\n\\end{verbatim}\nHowever, usually the type is a property of each of the atoms of a molecule.\n\\begin{verbatim}\n     int type;\n     type=Framework[1].Atoms[0][10].Type;\n\\end{verbatim}\nand `type' can then be used to get the mass, charge, polarization, etc. Here, the type is retrieve for atom number 11 (c is starting from 0, unlike Fortran)\nof the first framework of the second system.\n\n\\subsection*{Framework}\n\nAtoms make up a framework, several frameworks can make up 1 system. The definition of a framework atom `FRAMEWORK\\_ATOM' is\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct framework_atom\n     {  \n       int Type;                      // the pseudo-atom type of the atom\n       int AssymetricType;            // the `asymmetric' type\n\n       // MC/MD properties\n       POINT Position;                // the position of the atom\n       POINT ReferencePosition;       // the `reference' position of the atom\n\n       // MD properties\n       VECTOR Velocity;               // the velocity of the atom\n       VECTOR ReferenceVelocity;      // the `reference' velocity of the atom\n       VECTOR Force;                  // the force acting on the atom\n\n       VECTOR ElectricField;          // the electricfield vector\n       VECTOR ReferenceElectricField; // the `reference' electricfield vector\n       VECTOR InducedElectricField;   // the induced electric field\n       VECTOR InducedDipole;          // the induced dipole moment on this atom\n       int HessianIndex;              // the index in the Hessian matrix for this atom\n     } FRAMEWORK_ATOM;\n\\end{verbatim}\n\\end{footnotesize}\nIt contains the properties you'd expect, like type, position, velocity, and force. For polarization, also electric field, induced electric field, \nand induced dipole are needed. For many applications, one needs to backup the positions and/or velocities. The field `ReferencePosition' and `ReferenceVelocity'\nare useful for that. Also they can be used for some algorithms which need the `old' values to. An example is the numerical computation of stress. First all\npositions are copied  to the `ReferencePosition', then the positions `Position' are generated from the strain at infinite small strain difference and the\nfinite difference scheme is applied.\n\n\\noindent\nA framework-structure `FRAMEWORK\\_COMPONENT' is defined per system\n\\begin{verbatim}\n     FRAMEWORK_COMPONENT *Framework;\n\\end{verbatim}\nwith\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct FrameworkComponent\n     {\n       char (*Name)[256];                        // the name of the frameworks\n\n       int TotalNumberOfAtoms;                   // the total number of atoms of the frameworks\n       int TotalNumberOfUnitCellAtoms;           // the total number of atoms of the unit cell\n       REAL FrameworkDensity;                    // the total density of the frameworks\n       REAL FrameworkMass;                       // the total mass of the frameworks\n\n       int NumberOfFrameworks;                   // the number of frameworks\n       REAL *FrameworkDensityPerComponent;       // the density per framework\n       REAL *FrameworkMassPerComponent;          // the mass per framework\n\n       int *NumberOfAtoms;                       // the number of atoms per framework\n       int *NumberOfUnitCellAtoms;               // the number of unit cell atoms per framework\n       FRAMEWORK_ATOM **Atoms;                   // list of framework-atoms per framework\n       ..................\n       ..................\n} FRAMEWORK_COMPONENT;\n\\end{verbatim}\n\\end{footnotesize}\nThe structure had the element `Atoms' which is a list of framework-atoms per framework.\nSo, to get the type of the 11 atom of the first framework of the second system, use\n\\begin{verbatim}\n     int type;\n     type=Framework[1].Atoms[0][10].Type;\n\\end{verbatim}\n\n\\noindent\nFinally, a small example where we print out the positions of all the framework atoms for all frameworks and systems\n\\begin{verbatim}\n      int i,j,f1;\n      for(i=0;i<NumberOfSystem;i++)\n      {\n        for(f1=0;f1<Framework[i].NumberOfSystems;f1++)\n        {\n          for(j=0;j<Framework[i].NumberOfAtoms[f1];j++)\n            printf(\"system: %d framework: %d atom: %d -> position: %g %g %g\\n\",\n            i,f1,j,\n            Framework[i].Atoms[f1][j].Position.x,\n            Framework[i].Atoms[f1][j].Position.y,\n            Framework[i].Atoms[f1][j].Position.z);\n        }\n      }\n\\end{verbatim}\n\n\\subsection*{Components}\n\nEverything that is independent of a molecule's positions but still a property of molecules is stored in the structure `COMPONENT'.\nHere you find the number of atoms for this type of molecule per system, the mass for the component etc.\nAlso computed values for densities of the bulk fluid, compressibility, and the amount of excess molecules are stored. These are computed\nfrom the mol fraction, pressure, and critical pressure/temperature and acentric factor.\nAfter these properties there are data on the potentials defined for the component: bond, Urey-Bradley, bends, torsions, cross-terms, intra Van der Waals etc.\nFor Monte Carlo the structure contains the probability of all the moves.\n\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct Component\n     {\n       char Name[256];                 // the name of the component (\"methane\",\"C12\",\"propane\" etc).\n       int NumberOfAtoms;              // the number of atoms in the component\n       int StartingBead;               // the bead of the molecule used for starting the growing process in CBMC\n       REAL Mass;                      // the mass of the component\n       int *NumberOfMolecules;         // the number of molecules of the component for each system\n       int *Type;                      // the pseudo-atom Type of each atom\n       int *Connectivity;              // the connectivity of each atom\n       int HasCharges;                 // whether the molecule contains charges or not\n       int IsPolarizable;              // whether the molecule has point dipoles or not\n       int ExtraFrameworkMolecule;     // TRUE: Cation, FALSE: Adsorbate\n       int Swapable;                   // whether or not the number of molecules is fluctuating (i.e. GCMC)\n       int Widom;                      // whether this component is used for Widom insertions\n\n       REAL *IdealGasRosenbluthWeight; // the Rosenbluth weight of an ideal-chain per system\n       REAL *IdealGasTotalEnergy;      // the total energy of an ideal-chain per system\n\n       REAL *PartialPressure;          // the partial pressure of the component per system\n       REAL *FugacityCoefficient;      // the fugacity coefficient of the component per system\n       REAL *BulkFluidDensity;         // the bulkfluid-density of the component per system\n       REAL *Compressibility;          // the compresibility of the fluid-fase per system\n       REAL *MolFraction;              // the mol-fraction of the component per system\n       REAL *AmountOfExcessMolecules;  // the amount of excess molecules per syste,\n\n       REAL CriticalTemperature;       // the critical temperature of the component\n       REAL CriticalPressure;          // the critical pressure of the component\n       REAL AcentricFactor;            // the acentric factor of the component\n\n       int NumberOfGroups;             // the number of groups\n       GROUP_DEFINITION *Groups;       // the definition of the groups\n       int *group;                     // to which group an atom belongs\n       VECTOR *Positions;              // the positions in the body-fixed frame\n          ..................\n          ..................\n       int NumberOfBonds;                                    // the number of bonds of the component\n       PAIR *Bonds;                                          // the list of bond-pairs\n       int *BondType;                                        // the type of the bond for each bond-pair\n       REAL (*BondArguments)[MAX_BOND_POTENTIAL_ARGUMENTS];  // the arguments needed for this bond-pair\n          ..................\n          ..................\n       REAL ProbabilityTranslationMove;  // the probability of the translation MC-move for the component\n       REAL ProbabilityRotationMove;     // the probability of the rotation MC-move for the component\n       REAL ProbabilityCBMCMove;         // the probability of the partial-regrow MC-move for the component\n       REAL ProbabilityReinsertionMove;  // the probability of the reinsertion MC-move for the component\n          ..................\n          ..................\n     } COMPONENT;\n\\end{verbatim}\n\\end{footnotesize}\n\nA component consists of `groups', which is a collection of atoms that are either treated as rigid or as flexible. The component has\nelements that lists how many of these groups there are, the definition of the group, and the positions of all the atoms in the body-fixed frame.\nThe definition of the group is the structure `GROUP\\_DEFINITION'. Important elements are whether or not the group is rigid, the\nnumber of atoms in the group, and the list of atom number present in the groups.\n\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct group_definitions\n     {\n       int Rigid;                        // whether or not the group is rigid\n       int Type;                         // the type, NONLINEAR_MOLECULE, LINEAR_MOLECULE, or POINT_PARTICLE\n\n       REAL Mass;                        // the mass of the group\n\n       int NumberOfGroupAtoms;           // the numer of atoms in the group\n       int *Atoms;                       // the atoms in the group\n\n       REAL_MATRIX3x3 InertiaTensor;     // the inertia tensor\n       VECTOR InertiaVector;             // the inertia vector\n       VECTOR InverseInertiaVector;      // the inverse of inertia vector\n\n       REAL_MATRIX3x3 RotationalMatrix;  // the rotational matrix\n       TRIPLE orientation;               // three atoms A,B,C to compute quaternions\n       REAL rot_min;\n\n       int RotationalDegreesOfFreedom;   // the rotational degrees of freedom\n     } GROUP_DEFINITION;\n\\end{verbatim}\n\\end{footnotesize}\nThe inertia tensor, vector and rotational matrix etc. are the same for a certain type of molecule. Together with the actually atom positions, the orientations\ncan be computed for all the rigid units (i.e. the quaternions are computed).\n\n\\subsection*{Adsorbate and cations}\nThe definition of an adsorbate atom `ADSORBATE\\_ATOM' is very similar to a framework atom\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct adsorbate_atom\n     {\n       int Type;                       // the pseudo-atom type of the atom\n\n       // MC/MD properties\n       POINT Position;                 // the position of the atom\n       POINT ReferencePosition;        // the `reference' position of the atom\n\n       // MD properties\n       VECTOR Velocity;                // the velocity of the atom\n       VECTOR ReferenceVelocity;       // the `reference' velocity of the atom\n       VECTOR Force;                   // the force acting on the atom\n\n       VECTOR ElectricField;           // the electricfield vector\n       VECTOR ReferenceElectricField;  // the `reference' electricfield vector\n       VECTOR InducedElectricField;    // the induced electric field\n       VECTOR InducedDipole;           // the induced dipole moment on this atom\n       int HessianIndex;               // the index in the Hessian matrix for this atom\n     } ADSORBATE_ATOM;\n\\end{verbatim}\n\\end{footnotesize}\nThe definition for cations is identical except it is called `CATION\\_ATOM'.\nThe definition of an adsorbate molecule is\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct adsorbate\n     {\n       int Type;               // the component type of the molecule\n       int NumberOfAtoms;      // the number of atoms in the molecule\n       GROUP *Groups;          // data of the rigid groups\n       ADSORBATE_ATOM *Atoms;  // list of atoms\n     } ADSORBATE_MOLECULE;\n\\end{verbatim}\n\\end{footnotesize}\nThe definition of a cation is called `CATION\\_MOLECULE'.\nNote that a molecule can consists of atoms, but also can contain rigid units. The atoms are accessible through the `Atoms' field, and rigid units\nare accessible through the `Groups' field. A `GROUP' consists of\n\\begin{footnotesize}\n\\begin{verbatim}\n     typedef struct group\n     {\n       REAL Mass;                             // mass of the rigid unit\n       QUATERNION Quaternion;                 // orientation of the unit\n       QUATERNION QuaternionMomentum;         // quaternion momentum\n       QUATERNION QuaternionForce;            // quaternion force\n       VECTOR Torque;                         // torque vector\n       VECTOR CenterOfMassPosition;           // the center of mass position\n       VECTOR CenterOfMassReferencePosition;  // the reference position for the center of mass\n       VECTOR CenterOfMassVelocity;           // the center of mass velocity\n       VECTOR CenterOfMassForce;              // the center of mass force\n       VECTOR AngularVelocity;                // the angular velocity of the rigid unit\n     } GROUP;\n\\end{verbatim}\n\\end{footnotesize}\nwhich contains elements like position and orientation, and fields for the integration of rigid units, i.e. QuaternionMomentum etc.\n\n\\noindent\nMolecules are stored as a list of molecules for each system\n\\begin{footnotesize}\n\\begin{verbatim}\n     ADSORBATE_MOLECULE **Adsorbates;\n\\end{verbatim}\n\\end{footnotesize}\nTo get the type of the 5th atom of the 11th adsorbate of the first system, use\n\\begin{verbatim}\n     int type;\n     type=Adsorbates[0][10].Atoms[4].Type;\n\\end{verbatim}\nAs an example, here a function to measure the velocity drift of all the adsorbates in the current system\n\\begin{footnotesize}\n\\begin{verbatim}\n     VECTOR MeasureVelocityDrift(void)\n     {\n       int i,k,l,Type,A,f;\n       REAL Mass,TotalMass;\n       VECTOR com;\n\n       TotalMass=0.0;\n       com.x=com.y=com.z=0.0;\n       for(i=0;i<NumberOfAdsorbateMolecules[CurrentSystem];i++)\n       {\n         Type=Adsorbates[CurrentSystem][i].Type;\n         for(l=0;l<Components[Type].NumberOfGroups;l++)\n         {\n           if(Components[Type].Groups[l].Rigid)\n           {\n             Mass=Components[Type].Groups[l].Mass;\n             TotalMass+=Mass;\n             com.x+=Mass*Adsorbates[CurrentSystem][i].Groups[l].CenterOfMassVelocity.x;\n             com.y+=Mass*Adsorbates[CurrentSystem][i].Groups[l].CenterOfMassVelocity.y;\n             com.z+=Mass*Adsorbates[CurrentSystem][i].Groups[l].CenterOfMassVelocity.z;\n           }\n           else\n           {\n             for(k=0;k<Components[Type].Groups[l].NumberOfGroupAtoms;k++)\n             {\n               A=Components[Type].Groups[l].Atoms[k];\n               Mass=PseudoAtoms[Adsorbates[CurrentSystem][i].Atoms[A].Type].Mass;\n               TotalMass+=Mass;\n               com.x+=Mass*Adsorbates[CurrentSystem][i].Atoms[A].Velocity.x;\n               com.y+=Mass*Adsorbates[CurrentSystem][i].Atoms[A].Velocity.y;\n               com.z+=Mass*Adsorbates[CurrentSystem][i].Atoms[A].Velocity.z;\n             }\n           }\n         }\n       }\n       com.x/=TotalMass;\n       com.y/=TotalMass;\n       com.z/=TotalMass;\n       return com;\n     }\n\\end{verbatim}\n\\end{footnotesize}\nIt loops over all the adsorbate molecules, and asks for the type. The component-type is important to get the number of groups for the current molecule.\nThen, there is a inner loop over all of the groups of the current molecule. If the group is rigid, then the center of mass velocity is used, otherwise\nit is flexible and it loops over all the atoms of the flexible group.\nIn general, if something is the same for a type of molecule then it is a property of the component. If it is different for each molecule, it is a property\nof a molecule.\n\\section{Modifying}\n\n\\subsection{Monte Carlo}\n\n\\subsubsection*{Selecting MC moves}\nThe file `src/monte\\_carlo.c' is the main Monte Carlo simulation routine. The bulk of the code deals with how to select a particular Monte carlo move.\nSome requirements and conveniences:\n\\begin{itemize}\n  \\item{The moves should be chosen in random order}\n  \\item{System move should be chosen much less frequent than particle moves. The particles need to be able to adapt to the new system.}\n  \\item{For $n$ systems, the amount of steps should be $n$ times larger.}\n  \\item{For $n$ times as many molecules, the amount of steps should be $n$ times larger.}\n  \\item{For multi-component systems one needs more steps.}\n  \\item{For systems at low loadings, the sampling lengths should be increase a bit (i.e. set a minimum amount of inner steps).}\n  \\item{The relative probabilities of particle moves should be taken into account.}\n\\end{itemize}\n\n\\noindent A code which achieves all the above is listed here (there are many other ways of doing this). For each MC `cycle'\n\\begin{footnotesize}\n\\begin{verbatim}\n      for(i=0;i<NumberOfSystems;i++)\n      {\n        // choose system at random\n        CurrentSystem=(int)(RandomNumber()*(REAL)NumberOfSystems);\n\n        NumberOfSystemMoves=9;\n        NumberOfMolecules=NumberOfAdsorbateMolecules[CurrentSystem]+NumberOfCationMolecules[CurrentSystem];\n        NumberOfParticleMoves=MAX(MinimumInnerCycles,NumberOfMolecules);\n        NumberOfSteps=(NumberOfSystemMoves+NumberOfParticleMoves)*NumberOfComponents;\n\n        // loop over the MC `steps' per MC `cycle'\n        for(j=0;j<NumberOfSteps;j++)\n        {\n          // choose any of the MC moves randomly\n          ran_int=(int)(RandomNumber()*NumberOfSteps);\n          switch(ran_int)\n          {\n            case 0: if(RandomNumber()<ProbabilityParallelTemperingMove) ParallelTemperingMove(); break;\n            case 1: if(RandomNumber()<ProbabilityHybridNVEMove) HybridNVEMove(); break;\n            case 2: if(RandomNumber()<ProbabilityHybridNPHMove) HybridNPHMove(); break;\n            case 3: if(RandomNumber()<ProbabilityHybridNPHPRMove) HybridNPHPRMove(); break;\n            case 4: if(RandomNumber()<ProbabilityVolumeChangeMove) VolumeMove(); break;\n            case 5: if(RandomNumber()<ProbabilityBoxShapeChangeMove) BoxShapeChangeMove(); break;\n            case 6: if(RandomNumber()<ProbabilityGibbsVolumeChangeMove) GibbsVolumeMove(); break;\n            case 7: if(RandomNumber()<ProbabilityFrameworkChangeMove) FrameworkChangeMove(); break;\n            case 8: if(RandomNumber()<ProbabilityFrameworkShiftMove) FrameworkShiftMove(); break;\n            default:\n              // choose component at random\n              CurrentComponent=(int)(RandomNumber()*(REAL)NumberOfComponents);\n\n              // choose the Monte Carlo move at random\n              ran=RandomNumber();\n              if(ran<Components[CurrentComponent].ProbabilityTranslationMove) TranslationMove();\n              else if(ran<Components[CurrentComponent].ProbabilityRandomTranslationMove) RandomTranslationMove();\n              else if(ran<Components[CurrentComponent].ProbabilityRotationMove) RotationMove();\n              else if(ran<Components[CurrentComponent].ProbabilityCBMCMove) CBMCMove();\n              else if(ran<Components[CurrentComponent].ProbabilityReinsertionMove) ReinsertionMove();\n              else if(ran<Components[CurrentComponent].ProbabilityReinsertionInPlaceMove) ReinsertionInPlaceMove();\n              else if(ran<Components[CurrentComponent].ProbabilityReinsertionInPlaneMove) ReinsertionInPlaneMove();\n              else if(ran<Components[CurrentComponent].ProbabilityIdentityChangeMove) IdentityChangeMove();\n              else if(ran<Components[CurrentComponent].ProbabilitySwapMove)\n              {\n                if(RandomNumber()<0.5) SwapAddMove();\n                else SwapRemoveMove();\n              }\n              else if(ran<Components[CurrentComponent].ProbabilityWidomMove) WidomMove();\n              else if(ran<Components[CurrentComponent].ProbabilitySurfaceAreaMove) SurfaceAreaMove();\n              else if(ran<Components[CurrentComponent].ProbabilityGibbsSwapChangeMove) GibbsParticleTransferMove();\n              else if(ran<Components[CurrentComponent].ProbabilityGibbsIdentityChangeMove) GibbsIdentityChangeMove();\n              break;\n          }\n        }\n      }\n\\end{verbatim}\n\\end{footnotesize}\nFirst is a loop over the amount of systems, and a random system is chosen. Suppose we have 200 single component molecules in this system, then each of the system move is chosen\nwith 1/209 probability (case 0-8), and there is a 200/209 chance to select a particle move (case 9-209). The probability of the particle moves are scaled in such a way that\nthe proper relative occurrence is obeyed (as specified in the input). Note that the swap-move has 50\\% to be swap insertion and 50\\% to be swap remove. This is necessary\nto obey detailed balance. For multi-components more moves are performed.\n\n\\subsubsection*{Sampling properties during Monte Carlo}\nThe Monte Carlo routine has two parts:\n\\begin{itemize}\n  \\item{The initialization part. Here, no properties are computed and MC moves are performed just to reach equilibrium.}\n  \\item{The production run, where properties are computed.}\n\\end{itemize}\nThe basic outline of the production run is\n\\begin{footnotesize}\n\\begin{verbatim}\n     // initialize sampling-routines at the start of the production run\n     SampleInfraRedSpectra(INITIALIZE);\n     SampleMeanSquareDisplacementOrderN(INITIALIZE);\n     SampleOnsagerMeanSquareDisplacementOrderN(INITIALIZE);\n     SampleRadialDistributionFunction(INITIALIZE);\n     SampleFrameworkSpacingHistogram(INITIALIZE);\n     SamplePositionHistogram(INITIALIZE);\n     SampleNumberOfMoleculesHistogram(INITIALIZE);\n     SampleEnergyHistogram(INITIALIZE);\n     SampleDensityProfile3DVTKGrid(INITIALIZE);\n     SampleEndToEndDistanceHistogram(INITIALIZE);\n     SampleMoleculePropertyHistogram(INITIALIZE);\n     SamplePDBMovies(INITIALIZE);\n     SampleDcTSTConfigurationFiles(INITIALIZE);\n     SampleFreeEnergyProfile(INITIALIZE);\n     SampleCationAndAdsorptionSites(INITIALIZE);\n\n     for(CurrentCycle=0;CurrentCycle<NumberOfCycles;CurrentCycle++)\n     {\n       // sample energy average and system/particle properties\n       for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n       {\n         UpdateEnergyAveragesCurrentSystem();\n\n         SampleRadialDistributionFunction(SAMPLE);\n         SampleFrameworkSpacingHistogram(SAMPLE);\n         SamplePositionHistogram(SAMPLE);\n         SampleNumberOfMoleculesHistogram(SAMPLE);\n         SampleEnergyHistogram(SAMPLE);\n         SampleDensityProfile3DVTKGrid(SAMPLE);\n         SampleEndToEndDistanceHistogram(SAMPLE);\n         SampleMoleculePropertyHistogram(SAMPLE);\n         SampleFreeEnergyProfile(SAMPLE);\n         SampleCationAndAdsorptionSites(SAMPLE);\n       }\n\n       // SELECTION OF MC-MOVES (SEE CODE OF THE PREVIOUS SECTION)\n\n       for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n       {\n         SampleRadialDistributionFunction(PRINT);\n         SampleFrameworkSpacingHistogram(PRINT);\n         SamplePositionHistogram(PRINT);\n         SampleNumberOfMoleculesHistogram(PRINT);\n         SampleEnergyHistogram(PRINT);\n         SampleDensityProfile3DVTKGrid(PRINT);\n         SampleEndToEndDistanceHistogram(PRINT);\n         SampleMoleculePropertyHistogram(PRINT);\n         SamplePDBMovies(PRINT);\n         SampleDcTSTConfigurationFiles(PRINT);\n         SampleFreeEnergyProfile(PRINT);\n         SampleCationAndAdsorptionSites(PRINT);\n       }\n     }\n\n     // finalize output\n     SampleRadialDistributionFunction(FINALIZE);\n     SampleFrameworkSpacingHistogram(FINALIZE);\n     SamplePositionHistogram(FINALIZE);\n     SampleNumberOfMoleculesHistogram(FINALIZE);\n     SampleEnergyHistogram(FINALIZE);\n     SampleDensityProfile3DVTKGrid(FINALIZE);\n     SampleEndToEndDistanceHistogram(FINALIZE);\n     SampleMoleculePropertyHistogram(FINALIZE);\n     SamplePDBMovies(FINALIZE);\n     SampleDcTSTConfigurationFiles(FINALIZE);\n     SampleFreeEnergyProfile(FINALIZE);\n     SampleCationAndAdsorptionSites(FINALIZE);\n\\end{verbatim}\n\\end{footnotesize}\nEach of the sampling routine (in `src/sample.c') has 5 scaling options: \n\\begin{itemize}\n \\item{ALLOCATE} to allocate memory needed for the sampling.\n \\item{INITIALIZE} to initialized the routine if needed.\n \\item{SAMPLE} to sample the properties.\n \\item{PRINT} to periodically write the output to file.\n \\item{FINALIZE} to free the requested memory and clean up.\n\\end{itemize}\nAdding your own sampling routines requires an additional routine in `src/sample.c', the definition in `src/sample.h' and addition to \ncalls to `src/monte\\_carlo.c'.\n\n\n\\subsection{Molecular Dynamics}\n\nA molecular dynamics simulation is performed in several steps:\n\\begin{itemize}\n  \\item{The proper amount of molecules are created and they are inserted as as no overlaps occurred with the framework or other particles.}\n  \\item{Initialization: during the initialization period an NVT Monte-Carlo (MC) simulation is performed to rapidly achieve\n        an equilibrium molecular arrangement.}\n  \\item{After the initialization period, velocities are assigned, drawn from the Maxwell-Boltzmann\n        distribution at the desired average temperature to all the atoms. The total momentum of the system can be set to zero.}\n  \\item{Equilibration: Next, the system is further equilibrated by performing an NVT MD simulation using a specified ensemble.}\n  \\item{Production run: the simulation is performed in the requested ensemble and properties are measured.}\n\\end{itemize}\nThe amount of cycles for each of these steps can be specified. For example, when starting from a restart-file there is no need for the Monte Carlo initialization,\nand if also the velocities are used from the restart-file then also the MD equilibration could be skipped. Moreover, the equilibration can be done in a different\nensemble as the production run. This is most useful for NVE simulations, where the equilibration could be done using NVT. The final temperature of the\nNVE production run is then quite close the desired temperature (in NVE the temperature is not imposed).\n\nThe initialization part is not shown here, as it is very similar to regular Monte Carlo. The basic outline for the equilibration and production run are listed below.\nThe most important lines are the `Integration();' ones, which evolve the system a single time step. This routine is implemented in `src/integration.c' and makes use\nof `src/thermo\\_baro\\_stats.c' for temperature and pressure control.\n\n\\begin{footnotesize}\n\\begin{verbatim}\n     // initialize\n     InitializesEnergiesAllSystems();\n     InitializeSmallMCStatisticsAllSystems();\n     InitializeMCMovesStatisticsAllSystems();\n\n     // compute initial energy\n     InitializeNoseHooverAllSystems();\n     InitializeForcesAllSystems();\n\n     // set the current ensemble to the initialization ensemble\n     for(i=0;i<NumberOfSystems;i++)\n       Ensemble[i]=InitEnsemble[i];\n\n     InitializesEnergyAveragesAllSystems();\n\n     for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n     {\n       ReferenceEnergy[CurrentSystem]=ConservedEnergy[CurrentSystem];\n       Drift[CurrentSystem]=0.0;\n     }\n\n     // Molecular-Dynamics initializing period to achieve a rapid equilibration of the velocities\n     for(CurrentCycle=0;CurrentCycle<NumberOfEquilibrationCycles;CurrentCycle++)\n     {\n       for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n       {\n         // regularly output system status and restart files\n         if(CurrentCycle%PrintEvery==0)\n         {\n           PrintIntervalStatusEquilibration(CurrentCycle,NumberOfEquilibrationCycles,OutputFilePtr[CurrentSystem]);\n           PrintRestartFile();\n         }\n\n         // evolve the system a full time-step\n         Integration();\n\n         // update the current energy-drift\n         Drift[CurrentSystem]+=fabs((ConservedEnergy[CurrentSystem]-ReferenceEnergy[CurrentSystem])/\n               ReferenceEnergy[CurrentSystem]);\n       }\n     }\n\n\n     // initialize sampling-routines at the start of the production run\n     for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n     {\n       Ensemble[CurrentSystem]=RunEnsemble[CurrentSystem];\n\n       ReferenceEnergy[CurrentSystem]=ConservedEnergy[CurrentSystem];\n       Drift[CurrentSystem]=0.0;\n     }\n     SampleInfraRedSpectra(INITIALIZE);\n     SampleEndToEndDistanceHistogram(INITIALIZE);\n     SampleMeanSquareDisplacementOrderN(INITIALIZE);\n     SampleOnsagerMeanSquareDisplacementOrderN(INITIALIZE);\n     SampleEnergyHistogram(INITIALIZE);\n     SamplePositionHistogram(INITIALIZE);\n     SampleRadialDistributionFunction(INITIALIZE);\n     SamplePositionHistogram(INITIALIZE);\n     SampleMoleculePropertyHistogram(INITIALIZE);\n     SamplePDBMovies(INITIALIZE);\n     SampleCationAndAdsorptionSites(INITIALIZE);\n\n     // Molecular-Dynamics production run\n     // loop over the amount of production cycles (MD integration steps)\n     for(CurrentCycle=0;CurrentCycle<NumberOfCycles;CurrentCycle++)\n     {\n       // loop over all the systems and handle one by one\n       for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n       {\n         SampleInfraRedSpectra(SAMPLE);\n         SampleEndToEndDistanceHistogram(SAMPLE);\n         SampleMeanSquareDisplacementOrderN(SAMPLE);\n         SampleOnsagerMeanSquareDisplacementOrderN(SAMPLE);\n         SampleEnergyHistogram(SAMPLE);\n         SamplePositionHistogram(SAMPLE);\n         SampleRadialDistributionFunction(SAMPLE);\n         SamplePositionHistogram(SAMPLE);\n         SampleMoleculePropertyHistogram(SAMPLE);\n         SampleCationAndAdsorptionSites(SAMPLE);\n\n         // update all the average energies\n         UpdateEnergyAveragesCurrentSystem();\n\n         if(CurrentCycle%PrintPropertiesEvery==0)\n           PrintPropertyStatus(CurrentCycle,NumberOfCycles,OutputFilePtr[CurrentSystem]);\n\n         if(CurrentCycle%PrintEvery==0)\n         {\n           PrintIntervalStatus(CurrentCycle,NumberOfCycles,OutputFilePtr[CurrentSystem]);\n           PrintRestartFile();\n         }\n\n         // regulary output radial distribution function\n         SampleInfraRedSpectra(PRINT);\n         SampleEndToEndDistanceHistogram(PRINT);\n         SampleMeanSquareDisplacementOrderN(PRINT);\n         SampleOnsagerMeanSquareDisplacementOrderN(PRINT);\n         SampleEnergyHistogram(PRINT);\n         SamplePositionHistogram(PRINT);\n         SampleRadialDistributionFunction(PRINT);\n         SamplePositionHistogram(PRINT);\n         SampleMoleculePropertyHistogram(PRINT);\n         SamplePDBMovies(PRINT);\n         SampleCationAndAdsorptionSites(PRINT);\n   \n         // evolve the current system a full time step\n         Integration();\n\n         // update the current energy-drift\n         Drift[CurrentSystem]+=fabs((ConservedEnergy[CurrentSystem]-ReferenceEnergy[CurrentSystem])/\n               ReferenceEnergy[CurrentSystem]);\n       }\n     }\n\n     // finalize and clean up\n     for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)\n     {\n       SampleInfraRedSpectra(FINALIZE);\n       SampleEndToEndDistanceHistogram(FINALIZE);\n       SampleMeanSquareDisplacementOrderN(FINALIZE);\n       SampleOnsagerMeanSquareDisplacementOrderN(FINALIZE);\n       SampleEnergyHistogram(FINALIZE);\n       SamplePositionHistogram(FINALIZE);\n       SampleRadialDistributionFunction(FINALIZE);\n       SamplePositionHistogram(FINALIZE);\n       SampleMoleculePropertyHistogram(FINALIZE);\n       SamplePDBMovies(FINALIZE);\n       SampleCationAndAdsorptionSites(FINALIZE);\n     }\n\\end{verbatim}\n\\end{footnotesize}\nAdding your own sampling routines requires an additional routine in `src/sample.c', the definition in `src/sample.h' and addition to \ncalls to `src/molecular\\_dynamics.c'.\n\n\\section{Debugging}\n\n\\subsection{Linux}\n\nThere are several debuggers like `gdb', and memory check utilities available, i.e. valgrind.\n\n\\subsection{Mac OSX}\n\nDebugging memory error under Max OsX is easy. One can replace the standard library to allocate memory by different ones that check memory allocation and use.\nIt can catch a lot of array out-of-bound error, even for dynamically allocated memory. See\n\n\\begin{verbatim}\n     man libgmalloc\n\\end{verbatim}\n\nAn example, export `RASPA\\_DIR' to the installation directory, start the debugger, load the debugging libraries and start running the code.\n\\begin{verbatim}\n     export RASPA_DIR=${HOME}/RASPA/simulations/\n     gdb ~/RASPA/simulations/bin/simulate\n\n     GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct  2 04:07:49 UTC 2007)\n     Copyright 2004 Free Software Foundation, Inc.\n     GDB is free software, covered by the GNU General Public License, and you are\n     welcome to change it and/or distribute copies of it under certain conditions.\n     Type \"show copying\" to see the conditions.\n     There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n     This GDB was configured as \"i386-apple-darwin\"...Reading symbols for shared libraries ... done\n\n     (gdb) set env DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib\n     (gdb) r\n\\end{verbatim}\n\n\n", "meta": {"hexsha": "22726b2fc956509b696aeb11c00fa1454a195181", "size": 41357, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/Code/code.tex", "max_stars_repo_name": "benjaminbolbrinker/RASPA2", "max_stars_repo_head_hexsha": "0fe1ed405133feede5d3c9ce75d76ae915b17d16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 77, "max_stars_repo_stars_event_min_datetime": "2015-05-05T07:42:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T09:33:41.000Z", "max_issues_repo_path": "Docs/Code/code.tex", "max_issues_repo_name": "benjaminbolbrinker/RASPA2", "max_issues_repo_head_hexsha": "0fe1ed405133feede5d3c9ce75d76ae915b17d16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 39, "max_issues_repo_issues_event_min_datetime": "2015-12-11T04:13:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-26T21:10:15.000Z", "max_forks_repo_path": "Docs/Code/code.tex", "max_forks_repo_name": "benjaminbolbrinker/RASPA2", "max_forks_repo_head_hexsha": "0fe1ed405133feede5d3c9ce75d76ae915b17d16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 78, "max_forks_repo_forks_event_min_datetime": "2015-06-05T17:18:55.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T09:44:31.000Z", "avg_line_length": 47.0500568828, "max_line_length": 176, "alphanum_fraction": 0.6855429552, "num_tokens": 9526, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.44592015239088095}}
{"text": "\\documentclass[10pt, oneside, letterpaper]{article}\n\\usepackage[margin=1in]{geometry}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{color}\n\\definecolor{mygreen}{rgb}{0,0.6,0}\n\\definecolor{mygray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mymauve}{rgb}{0.58,0,0.82}\n\\usepackage{listings}\n\\lstset{\n  backgroundcolor=\\color{white}, % choose the background color\n  basicstyle=\\footnotesize\\ttfamily, % size of fonts used for the code\n  breaklines=true, % automatic line breaking only at whitespace\n  frame=single, % add a frame\n  captionpos=b, % sets the caption-position to bottom\n  commentstyle=\\color{mygreen}, % comment style\n  escapeinside={\\%*}{*)}, % if you want to add LaTeX within your code\n  keywordstyle=\\color{blue}, % keyword style\n  stringstyle=\\color{mymauve}, % string literal style\n}\n\\usepackage{enumitem}\n\\usepackage{blindtext}\n\\usepackage{datetime2}\n\\usepackage{fancyhdr}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{float}\n\\usepackage{pgf}\n% \\usepackage{layouts}\n% \\printinunitsof{in}\\prntlen{\\textwidth}\n\\title{Basic Circuit Discretization}\n\\author{Assignment 1a}\n\\date{Due: 2021/01/22}\n\n\\pagestyle{fancy}\n\\setlength{\\headheight}{23pt}\n\\setlength{\\parskip}{1em}\n\\fancyhf{}\n\\chead{Assignment 1a \\\\ Basic Circuit Discretization}\n\\rhead{Michel Kakulphimp \\\\ Student \\#63542880}\n\\lhead{EECE560 \\\\ UBC MEng}\n\\cfoot{\\thepage}\n\n\\begin{document}\n\\maketitle\n\\thispagestyle{fancy}\n\n\\section{Introduction}\nIn this first assignment, we are analyzing the transient behaviour of a series RL circuit as we close its main switch. Since this circuit and its constituent components can be modeled as an easy-to-solve first order differential equation, this allows us to simultaneously solve for its continuous time solution as well as apply some discretization techniques to enable solving the circuit in a step-by-step manner. Comparing the two allows us to analyze how well each discretization technique is able to approximate the true solution.\n\nThe following sections will discuss the derivation of the continuous time function as well as the derivation of the discretized functions. The trapezoidal and backward Euler approximations of a differential equation will be employed for this assignment. Following the derivations, we will plot different the approximations and compare their performance with respect to different time steps as well to each other. The continuous solutions will be overlayed to understand how well the approximations come to solving the circuit's solution.\n\nFinally, a discussion of the results as well as improvements will be proposed. A full code listing of the code used in this project is provided as well for review.\n\\section{Setup}\nThe following sections go through the derivation of the different solutions used to produce the final plots for this assignment.\n\\subsection{Homogeneous Plus Steady-State Solutions}\nIn this section, we will derive the homogeneous plus steady-state solutions for $i(t)$ and $v_L(t)$. These solutions will plot the continuous time value for each of the quantities, and will be used as a baseline comparison to see how well the approximations match the ground truth. Using KVL, the circuit can be represented by the following equation:\n\\begin{alignat}{2}\n10 - Ri(t) & = L\\frac{di(t)}{d(t)}\n\\intertext{Solving this first order differential equation will provide the continuous time system solution for $i(t)$ and $v_L(t)$. First, we will derive the continuous time system solution for $i(t)$in terms of homogeneous plus steady-state equations:}\n\\frac{10 - Ri(t)}{L} & = \\frac{di(t)}{dt} \\\\\n\\frac{dt}{L} & = \\frac{di(t)}{10-Ri(t)} \\\\\n\\frac{1}{L}\\int{}\\,dt & = \\int{}\\frac{1}{10-R\\,i(t)}di(t) \\\\\n\\frac{1}{L}t + K & = -\\frac{1}{R}\\ln{|10-R\\,i(t)|} \\\\\ne^{-\\frac{R}{L}-RK} & = 10 - R\\,i(t) \\\\\ni(t) & = \\frac{10}{R} - A\\,e^{-\\frac{R}{L}t} & A = e^{-RK} \\\\\n\\Aboxed{i(t) & = \\frac{10}{R} - A\\,e^{-\\frac{R}{L}t}}\n\\intertext{We know from our initial conditions that $i(0) = 0$; this allows us to solve for the steady-state solution by solving for the constant $A$.}\n0 & = \\frac{10}{R} - A\\,e^{-\\frac{R}{L}(0)} \\\\\nA & = \\frac{10}{R}\n\\intertext{This gives us our final, continuous time solution for $i(t)$ as follows:}\ni(t) & =\\frac{10}{R} - \\frac{10}{R}\\,e^{-\\frac{R}{L}t} & i(t)=0 \\\\\n\\Aboxed{i(t) & =\\frac{10}{R} - \\frac{10}{R}\\,e^{-\\frac{R}{L}t} & i(t)=0}\n\\intertext{Obtaining our continuous time $v_L(t)$ relies on the formula for the voltage across an inductor. Since we have obtained our $i(t)$, we can take its derivative with respect to time to obtain the equation's $\\frac{di(t)}{dt}$ term.}\n\\frac{di(t)}{dt} & = A\\,\\frac{R}{L}\\,e^{-\\frac{R}{L}t}\n\\intertext{This derivative can then be substituted into the equation for the voltage across our inductor:}\nv_L(t) & = L\\,\\frac{di(t)}{dt} \\\\\n\\Aboxed{v_L(t) & = A\\,R\\,e^{-\\frac{R}{L}t}}\n\\intertext{Knowing our initial conditions, we obtain the following steady-state equation for $v_L(t)$}\n\\Aboxed{v_L(t) & = 10\\,e^{-\\frac{R}{L}t}}\n\\end{alignat}\n\\subsection{Isolating Components for Discretization}\nIn order to apply the trapezoidal and backward Euler discretizations used by the step-by-step solution, we must isolate the integration of $i(t)dt$. This is the component that will be approximated by the following discretization techniques:\n\\begin{alignat}{2}\n\\intertext{Trapezoidal:}\n\\int_{t-\\Delta{}t}^{t}i(t)dt & \\simeq \\frac{i(t)+i(t-\\Delta{}t)}{2}\\Delta{}t\n\\intertext{Backward Euler:}\n\\int_{t-\\Delta{}t}^{t}i(t)dt & \\simeq i(t)\\Delta{}t\n\\end{alignat}\nThe following steps will manipulate our original KVL relationship into a differential equation that can be discretized, isolating the integration of $i(t)dt$.\n\\begin{alignat}{2}\n10 - Ri(t) & = L\\frac{di(t)}{d(t)} \\\\\n\\frac{10}{L} - \\frac{R}{L}i(t) & = \\frac{di(t)}{dt} \\\\\n\\frac{10}{L}dt - \\frac{R}{L}i(t)dt & = di(t) \\\\\n\\frac{10}{L}\\int_{t-\\Delta{}t}^{t}dt - \\frac{R}{L}\\int_{t-\\Delta{}t}^{t}i(t)dt & = i(t) - i(t-\\Delta{}t) \\\\\n\\frac{10}{L}[t - (t-\\Delta{}t)] - \\frac{R}{L}\\int_{t-\\Delta{}t}^{t}i(t)dt & = i(t) - i(t-\\Delta{}t) \\\\\n- \\frac{R}{L}\\int_{t-\\Delta{}t}^{t}i(t)dt & = i(t) - i(t-\\Delta{}t) - \\frac{10}{L}\\Delta{}t \\\\\n\\Aboxed{\\int_{t-\\Delta{}t}^{t}i(t)dt & = -\\frac{L}{R}i(t) + \\frac{L}{R}i(t-\\Delta{}t) + \\frac{10}{R}\\Delta{}t}\n\\end{alignat}\nWith $\\int_{t-\\Delta{}t}^{t}i(t)dt$ isolated, we can now apply our discretization techniques to obtain our step-by-step solution for the current. Similarly, discretizing $v_L(t)$ can be performed by manipulating the fundamental equation for the voltage across an inductor:\n\\begin{alignat}{2}\nv_L(t) & = L\\frac{di(t)}{dt} \\\\\n\\int_{t-\\Delta{}t}^{t}v_L(t) & = Ldi(t) \\\\\n\\Aboxed{\\int_{t-\\Delta{}t}^{t}v_L(t) & = L[i(t) - i(t-\\Delta{}t)]}\n\\end{alignat}\n\\subsection{Trapezoidal Discretization}\nThe following is the derivation of the step-by-step solution for $i(t)$ and $v_L(t)$ using the trapezoidal discretization technique.\n\\begin{alignat}{2}\n\\intertext{Current $i(t)$:}\n\\frac{i(t)+i(t-\\Delta{}t)}{2}\\Delta{}t & \\simeq -\\frac{L}{R}i(t) + \\frac{L}{R}i(t-\\Delta{}t) + \\frac{10}{R}\\Delta{}t \\\\\ni(t)\\Delta{}t + i(t-\\Delta{}t)\\Delta{}t & \\simeq \\frac{2L}{R}i(t-\\Delta{}t)-\\frac{2L}{R}i(t) + \\frac{20}{R}\\Delta{}t \\\\\ni(t)\\Delta{}t + \\frac{2L}{R}i(t) & \\simeq \\frac{2L}{R}i(t-\\Delta{}t) - i(t-\\Delta{}t)\\Delta{}t+20\\Delta{}t \\\\\n\\Aboxed{i(t) & \\simeq \\frac{i(t-\\Delta{}t)[2L-R\\Delta{}t] + 20\\Delta{}t}{R\\Delta{}t + 2L}}\n\\intertext{Voltage $v_L(t)$:}\n\\frac{v_L(t)+v_L(t-\\Delta{}t)}{2}\\Delta{}t & \\simeq L[i(t) - i(t-\\Delta{}t)] \\\\\n\\Aboxed{v_L(t) & \\simeq \\frac{2L}{\\Delta{}t}[i(t) - i(t-\\Delta{}t)] - v_L(t-\\Delta{}t)}\n\\end{alignat}\n\\subsection{Backward Euler Discretization}\nThe following is the derivation of the step-by-step solution for $i(t)$ and $v_L(t)$ using the backward Euler discretization technique.\n\\begin{alignat}{2}\n\\intertext{Current $i(t)$:}\ni(t)\\Delta{}t & \\simeq -\\frac{L}{R}i(t) + \\frac{L}{R}i(t-\\Delta{}t) + \\frac{10}{R}\\Delta{}t \\\\\ni(t)R\\Delta{}t + Li(t) & \\simeq  Li(t - \\Delta{t}) + 10\\Delta{}t \\\\\ni(t)[R\\Delta{}t + L] & \\simeq Li(t - \\Delta{}t) + 10\\Delta{}t \\\\\n\\Aboxed{i(t) & \\simeq \\frac{Li(t - \\Delta{}t) + 10\\Delta{}t}{R\\Delta{}t + L}}\n\\intertext{Voltage $v_L(t)$:}\nv_L(t)\\Delta{}t & \\simeq L[i(t) - i(t-\\Delta{}t)] \\\\\n\\Aboxed{v_L(t) & \\simeq \\frac{L[i(t) - i(t-\\Delta{}t)]}{\\Delta{}t}}\n\\end{alignat}\n\\section{Simulation}\nWith the equations derived, we can now plot our results to see how they perform with different parameters. The assignment requests the following solutions to be generated using a computer program:\n\\begin{enumerate}[label=\\alph*)]\n  \\item Using the trapezoidal rule with $\\Delta{}t_1 = 0.1ms$\n  \\item Using the backward Euler rule with $\\Delta{}t_1 = 0.1ms$\n  \\item Using the trapezoidal rule with $\\Delta{}t_2 = 0.8ms$\n  \\item Using the backward Euler rule with $\\Delta{}t_2 = 0.8ms$\n\\end{enumerate}\nIn all plots, the continuous solution is plotted as a dotted line to show what the exact solution should be. This provides a baseline to compare the performance of the different approximations. Figure \\ref{trap_approx}. shows the performance of the Trapezoidal approximation using time steps of $0.1ms$ and $0.8ms$. Figure \\ref{back_approx}. shows the performance of the backward Euler approximation using time steps of $\\Delta{}t_1 = 0.1ms$ and $\\Delta{}t_2 = 0.8ms$. Finally, Figure \\ref{approx_comp}. compares both approximation techniques using the time step of $\\Delta{}t_2 = 0.8ms$.\n\nAs expected, the smaller the time step, the closer the step-by-step solutions approximate the real solution. This makes sense because as the $\\Delta{}t$ becomes smaller, the closer it becomes to approximating the integration. What was unexpected, however, is the backward Euler solution more closely approximating the solution numerically versus the trapezoidal one. Intuitively, the trapezoidal solution should approximate the solution better due to its inclusion of a triangle area above the square below. The trapezoidal approximation does seem to follow the shape better than the backward Euler one, however. The backward Euler approximation can be seen to cross the true solution towards the end of the simulation in Figure \\ref{approx_comp}. whereas the trapezoidal solution asymptotically approaches the true solution. At small time steps the trapezoidal solution is likely the better one.\n\\begin{figure}[H]\n    \\begin{center}\n        \\input{trapezoidal_plots.pgf}\n    \\end{center}\n    \\caption{Trapezoidal Approximations at $\\Delta{}t_1 = 0.1 ms, \\Delta{}t_2 = 0.8 ms$}\n    \\label{trap_approx}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\begin{center}\n        \\input{backeuler_plots.pgf}\n    \\end{center}\n    \\caption{Backward Euler Approximations at $\\Delta{}t_1 = 0.1 ms, \\Delta{}t_2 = 0.8 ms$}\n    \\label{back_approx}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\begin{center}\n        \\input{compare_plot_0p0008.pgf}\n    \\end{center}\n    \\caption{Comparison of Approximations at $\\Delta{}t_2 = 0.8 ms$}\n    \\label{approx_comp}\n\\end{figure}\n\\section{Conclusion}\nOverall this was a good refresher on transient circuit analysis as well as a productive introduction to discretization techniques. Further optimizations and improvements are proposed below:\n\\begin{itemize}\n    \\item In order to perform more efficient calculation steps, the program could decide to dynamically modify its solution's step size if it detects the output to be stable. This would allow it to more effectively make use of its compute cycles. A threshold could be implemented to determine the range of change for which it should attempt to modify its step size.\n    \\item In a similar vein, the program could also attempt changing its discretization rules on the fly to better approximate the transient solution. Perhaps in some scenarios, a circuit exhibits several different stages where certain approximations work better than others.\n    \\item Using a programming language that supports special compiler hints, a program could be written to make use of special processing units that accelerate an approximation's iteration. Perhaps a program could also run multiple discretization rules in parallel, and through some kind of analysis, dynamically switch between the more accurate solution. \n\\end{itemize}\n\\newpage\n\\section{Code Listing}\nThe following is the code written in Python to perform the calculations derived for this homework assignment as well as generate the plots used in this report.\n\\lstinputlisting[language=Python]{assignment1a.py}\n\t\n\\end{document}\n\n", "meta": {"hexsha": "f7295c3eca6e18f63488c60b74054fb207d39981", "size": 12398, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment1a/assignment1a.tex", "max_stars_repo_name": "umamibeef/UBC-EECE-560-Coursework", "max_stars_repo_head_hexsha": "4c89fb03a4dacf778e31eeb978423bfdaa95b591", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assignment1a/assignment1a.tex", "max_issues_repo_name": "umamibeef/UBC-EECE-560-Coursework", "max_issues_repo_head_hexsha": "4c89fb03a4dacf778e31eeb978423bfdaa95b591", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment1a/assignment1a.tex", "max_forks_repo_name": "umamibeef/UBC-EECE-560-Coursework", "max_forks_repo_head_hexsha": "4c89fb03a4dacf778e31eeb978423bfdaa95b591", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.6516853933, "max_line_length": 896, "alphanum_fraction": 0.7184223262, "num_tokens": 3781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7772998663336158, "lm_q1q2_score": 0.44592014943131736}}
{"text": "% !TEX options=--shell-escape\n\\documentclass [12pt]{article} \n\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{graphicx} \n\\usepackage{float}\n\\usepackage{multirow}\n\\usepackage{xcolor}\n\\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \\usepackage{array} \n\\usepackage{booktabs} \n\\usepackage{url} \n\\usepackage{parskip} \n\\usepackage [margin=1in]{geometry} \n\\usepackage [T1]{fontenc} \n\\usepackage{cmbright} \n\\usepackage [many]{tcolorbox} \n\\usepackage [colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref} \n\\usepackage{enumitem} \n\\usepackage{xparse} \n\\usepackage{verbatim}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{csquotes}\n\\usepackage[cache=false]{minted}\n\\usepackage{mdframed}\n\\usepackage{tikz}\n\\usepackage{algpseudocode}\n\\usepackage{wrapfig}\n\n\\usetikzlibrary{shapes.symbols}\n\\newtheorem{theorem}{Theorem}\n\n\\BeforeBeginEnvironment{minted}{\\begin{mdframed}}\n\\AfterEndEnvironment{minted}{\\end{mdframed}}\n\n\\DeclareTColorBox{Solution}{}{breakable, title={Solution}}\n\\DeclareTColorBox{Solution*}{}{breakable, title={Solution (provided)}}\n\\DeclareTColorBox{Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt}\n\\DeclareDocumentCommand{\\Expecting }{+m}{\\textbf{[We are expecting:} #1\\textbf{]}}\n\\DeclareDocumentCommand{\\Points }{m}{\\textbf{(#1 pt.)}} \n\\newcommand{\\hint }[1]{\\noindent{[\\textbf{HINT:} \\em #1 \\em ]}} \\newcommand{\\pts }[1]{\\textbf{(#1 pt.)}} \n\n\\begin{document} \n\n{\\LARGE \\textbf{COMP 285 (NC A\\&T, Spr `22)}\\hfill \\textbf{Homework 10} } \n\\vspace{1em} \n\\begin{Instruction} \n\n\\paragraph{Due.} Friday, April 29th, 2022 @ 11:59 PM!\n\\end{Instruction}\n\n\\vspace{1em} \n\\begin{Instruction} \\paragraph{Homework Expectations:} Please see \\href{https://www.comp285.ml/homework/#general-homework-information}{Homework}.\n\\end{Instruction}\n\n\\vspace{1em} \n\\begin{Instruction} \n\n\\paragraph{Exercises} The following questions are exercises. We encourage you to work with a group and discuss solutions to make sure you understand the material.\n\n\\paragraph{Points} This assignment is graded out of 30 points.\n\n\\end{Instruction} \n\n\\begin{centering}\n\\section*{Fun with MSTs, Flows, and Cuts}\n\\end{centering}\n\n\\begin{Instruction}\n\n\\paragraph{Written Problems} The following questions are to be submitted in written/typed form to gradescope.\n\n\\end{Instruction}\n\n\\section{Learning for Fun \\Points{0}}\nWatch 1 (<30 minute video) or read 2 before you start the following two questions:\n\n\\begin{enumerate}\n  \\item If you prefer a lecture format, this is a \\href{https://www.youtube.com/watch?v=wU6udHRIkcc}{really good video resource} (as a general note, this person's lectures are high quality across the board). Slight terminology differences in this video from the HW and textbook: he uses “weighted union” which is similar to the “union by rank”, and he says “collapsing find” which is essentially “path compression”.\n  \\item If you prefer a written resource, Ch 21 in the CLRS textbook is fully dedicated to the topic. You can skip over the exercises and detailed math proofs to understand the main ideas, and they are very similar to the ideas explained in the video.\n\\end{enumerate}\n\n\\pagebreak\n\\section{Understanding Kruskal's Algorithm \\Points{8}}\nIn class, we showed an abbreviated version of Kruskal's pseudocode. The actual pseudocode looks like this:\n\n\\begin{verbatim}\nalgorithm kruskal(G, w)\n  Input: A connected undirected graph G = (V, E) with edge weights w(u, v) \n    for all (u,v) in E\n  Output: A minimum spanning tree defined by the edges X\n\n  for all u in V:\n    makeset(u)\n  X = {}\n  Sort the edges E by weight\n  for all edges {u, v} in E, in increasing order of weight:\n    if find(u) != find(v):\n      add edge {u, v} to X\n      union(u, v)\n  return X\n\\end{verbatim}\n\nRecall during the Kruskal's lecture (\\href{https://www.comp285.ml/lectures/#kruskal-s-algorithm-and-max-flow}{Lecture 32}) how we would make sure that adding an edge between two nodes would not create a cycle. A data structure called \"Disjoint Sets\" allow us to do this efficiently by keeping track of / updating a \"set\" for each connected component.\n\nWe have 3 functions related to Disjoint Sets:\n\n\\begin{enumerate}\n  \\item \\texttt{makeset}(x), which takes in a node x and creates a new set with just x in it.\n  \\item \\texttt{find}(x), which takes in a node and returns which set it belongs to.\n  \\item \\texttt{union}(x, y), which takes in two sets, and combines them into one big set.\n\\end{enumerate}\n\n\\subsection{\\Points{2}}\nHow many times will we call \\texttt{makeset} within Kruskal's? Put your answer in terms of $n = |V|$ and $m = |E|$.\n\n\\Expecting{A mathematical expression using $n$ and $m$.}\n\n\\subsection{\\Points{2}}\nHow many times will we call \\texttt{find} within Kruskal's? Put your answer in terms of $n = |V|$ and $m = |E|$.\n\n\\Expecting{A mathematical expression using $n$ and $m$.}\n\n\\subsection{\\Points{2}}\nHow many times will we call \\texttt{union} within Kruskal's? Put your answer in terms of $n = |V|$ and $m = |E|$.\n\n\\Expecting{A mathematical expression using $n$ and $m$.}\n\n\\subsection{\\Points{2}}\nDescribe using your own words why \\texttt{find}(u) != \\texttt{find}(v) is the same as \"if this edge doesn't cause a cycle\".\n\n\\Expecting{One sentence explaining the above.}\n\n\n\\pagebreak\n\\section{Disjoint-Set Data Structure \\Points{8}}\nNow here's the code for the Disjoint Set functions above:\n\n\\begin{verbatim}\nalgorithm makeset(x)\n  Input: a graph node x\n  Output: modify x such that it has a \"rank\" and a \"parent\"\n\n  x.rank = 0\n  x.parent = x\n\nalgorithm find(x)\n  Input: a graph node x\n  Output: the ancestor\n\n  if x != x.parent\n    x.parent = find(x.parent)\n  return x.parent\n\nalgorithm union(x, y)\n  Input: graph nodes x and y\n  Output: modify x and y so that they are now connected in the same \"set\"\n\n  x = find(x)\n  y = find(y)\n\n  if x == y:\n    return\n\n  if x.rank > y.rank\n    y.parent = x\n  else\n    x.parent = y\n    if x.rank == y.rank\n      y.rank = y.rank + 1\n\\end{verbatim}\n\n\n\\subsection{\\Points{2}}\nSuppose we make the following sequence of calls: `\\texttt{makeset}(A); \\texttt{makeset}(B); \\texttt{makeset}(C); \\texttt{makeset}(D); \\texttt{union}(C, D); \\texttt{union}(A, B); \\texttt{union}(B, D);`. Draw what the set(s) look like at this point (either a picture or text representation is fine).\n\n\\Expecting{Include an image or text representation of what the data structure looks like.}\n\n\\subsection{\\Points{2}}\nYou call `\\texttt{find}(x)` on the above and it takes multiple recursive calls, then you call `\\texttt{find}(x)` again on the same node and it takes fewer. What is `x`? This phenomena is called \"path compression\".\n\n\\Expecting{One of $A,B,C,D$ that corresponds to $X$ above.}\n\n\\subsection{\\Points{2}}\nDraw what the set(s) look like after the additional `\\texttt{find}` calls. \n\n\\Expecting{Include an image or text representation of what the data structure looks like.}\n\n\\subsection{\\Points{2}}\nWhat does rank signify for each node?\n\n\\Expecting{A short explanation of what the `rank' represents}.\n\n\n\\pagebreak\n\\section{Network Flow Cuts \\Points{14}}\n\nAn \\textbf{s-t cut} of a flow network is a partitioning of nodes into two groups, one which contains the source $s$ and the other which contains the sink $t$. \n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=0.5]{cut-example.png}\n\\caption{An example of an s-t cut.}\n\\label{fig:cut_example}\n\\end{figure}\n\n\nThe image in Figure \\ref{fig:cut_example} represents the cut $\\{s, v\\} / \\{u, t\\}$. The \\textbf{cut capacity} is the sum of all edge capacities that \\textbf{go from the set containing s to the set containing t}. So the cut capacity shown above is $7 + 8 = 15$ (note that we do not include $3$).\n\n\\subsection{\\Points{9}}\n\nDefine all 4 s-t cuts in the graph above and calculate their capacities. The \\href{https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem}{MaxFlow-MinCut Theorem} states that the max flow in a network is equal to the capacity of the $s-t$ cut with minimum capacity. Using this, what is the max flow of this network?\n\n\\Expecting{The 4 s-t cuts along with their capacities and the value of the max flow.}\n\n\n\\subsection{\\Points{5}}\n\nFind and list flow values for each edge that will give this max-flow. What do you notice about the flows of the edges along the minimum s-t cut? Use this observation to explain why the max-flow min-cut theorem makes intuitive sense.\n\n\\Expecting{Flows for each edge and a short explanation of why the max-flow min-cut theorem makes sense.}\n\n\n\\pagebreak\n\\section{Negative Prim? \\Points{5}}\n\\label{sec:last}\nWe want to now consider a similar algorithm to Prim's called Negative-Prim for computing minimum spanning tree in graphs with negative edge weights.\n\nThis algorithm adds some number to all of the edge weights to make them all nonnegative, then runs Prim's algorithm on the resulting graph, and argues that the Minimum Spanning Tree in the new graph are the same as the MST in the old graph. You can assume that all the edge weights are unique integers.\n\n\\begin{verbatim}\nNegative-Prim(G, s):\n  minWeight = minimum edge weight in G\n  for e in E: # iterate through all edges in G\n    modifiedWeight(e) = w(e) - minWeight\n    modifiedG = G with weights modifiedWeight\n  T = Prim(modifiedG, s) # run Prim's algorithm starting from s\n  update T with edges that corresponds to graph G\n  return T\n\\end{verbatim}\n\n\\Expecting{Either an informal explanation of why Negative-Prim computes the\ncorrect MST, or a counter-example of an undirected graph with negative edge weights where\nNegative-Prim does not output}\n\n\n\\section*{Submitting the Assignment}\n\nThe assignment should be submitted through \\href{https://www.gradescope.com/courses/350304}{Gradescope}.\n\nThe \"Homework 10: Fun with MSTs, Flow, and Cuts\" assignment is the written portion, for which you should submit a \\textbf{typed} response to questions 1-\\ref{sec:last}. Each response should clearly be marked with its corresponding number. You are free to use the provided templates, print the questions and write your answers, or to simply type your responses on a blank document (whatever works for you).\n\n\n\\end{document} ", "meta": {"hexsha": "5d885d2b430330e69d611c3537d2f8fb68000eb9", "size": 10238, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/homework/hw10/hw10.tex", "max_stars_repo_name": "facebookEIR/algorithms-course", "max_stars_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-16T02:47:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-16T02:47:46.000Z", "max_issues_repo_path": "assets/homework/hw10/hw10.tex", "max_issues_repo_name": "facebookEIR/algorithms-course", "max_issues_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/homework/hw10/hw10.tex", "max_forks_repo_name": "facebookEIR/algorithms-course", "max_forks_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-01-20T21:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T03:00:16.000Z", "avg_line_length": 39.3769230769, "max_line_length": 415, "alphanum_fraction": 0.7366673178, "num_tokens": 2867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.7772998560157663, "lm_q1q2_score": 0.44592014351218995}}
{"text": "\\chapter{Conclusions and future work}\n\\chaptermark{Conclusions}\n\n\\section{Conclusions}\n\nIn this thesis we have introduced a complete numerical method for the solution of dynamic micromagnetic problems using the finite element method with the Newton-Raphson linearisation, a variety of implicit time integration schemes, hybrid FEM/BEM magnetostatics calculations, and efficient iterative linear solvers.\nThe methods have been validated against an analytical solution for a problem without magnetostatics and against the \\mumag standard problem \\#4 with magnetostatics.\n\nIn \\cref{sec:adaptive-imr} we have demonstrated a novel and widely applicable adaptive time step selection algorithm for the implicit midpoint rule.\nWe have also shown that the time step selection works well for a wide variety of ODE test cases, as well as for a number of PDE test cases using the LLG equation.\nAdditionally we have shown that the geometrical integration properties of the constant time step IMR extend to the adaptive time step version.\n\nIn \\cref{sec:solut-coupl-syst,sec:numer-exper-fem-bem-systems,sec:mumag-stand-probl} we introduced and tested efficient, robust and scalable solution methods for the monolithically coupled LLG-FEM/BEM magnetostatics problem provided that a good preconditioner for the LLG sub-problem is available.\nSuch monolithic couplings are required to obtain the energy property of the implicit midpoint rule and may offer advantages in stochastic integration methods.\n\nIn \\cref{sec:imr-ode-llg-numer-exper,sec:numer-exper} we studied the performance of common implicit time integration schemes on some micromagnetic problems with exact solutions.\nWe found that the overall accuracy of the BDF2 scheme is always poor compared to the TR and IMR schemes, this is probably due to a combination of the larger local truncation error and the spurious numerical damping of BDF2.\n% Unfortunately we were unable to analyse the effect of geometric integration on the error accumulation due to the fact that TR also displays some geometrical integration properties for these simple examples.\n\nFinally in \\cref{cha:stiffn-llg-equat} we studied the effect of spatial discretisation on the relative performance of implicit and explicit time integration schemes (stiffness).\nWe found that stiffness in micromagnetics can arise from the spatial discretisation alone, and that the stiffness increases as the element size is decreased, as expected from standard PDE theory.\nWe also found that the introduction of FEM/BEM magnetostatics calculations increases the stiffness.\n\n\n\n\\section{Future work}\n\\label{sec:future-work}\n\n\nIn the course of our numerical experiments we uncovered some issues with the geometrical integration properties of our complete model.\nFirstly we found that the conservation properties of IMR with FEM and nodal quadrature was much less effective when applied to meshes of triangular elements, at least in our implementation.\nThis effect is fairly small and is not contradicted by any numerical results in the literature that we are aware of due to the common use of comparatively loose linearisation tolerances.\nAn alternative implementation of IMR with FEM and nodal quadrature should be used with a tight linearisation tolerance in order to find out if this effect is an artefact of our implementation or a real issue.\n\nSecondly, we found that when FEM/BEM magnetostatics calculations discretised by a collocation based approach were included the energy conservation property of IMR was lost.\nThis is probably due to the asymmetry of the discrete BEM operator, which could be corrected by the use of alternative formulations of the method.\nIn particular the use of the Garc\\'{i}a-Cervera-Roma formulation \\cite{Garcia-Cervera2006} \\cite[19]{Knittel2011} with a Galerkin discretisation approach \\cite[75]{Wrobel2002} should resolve this issue.\n\nOnce these issues have been corrected the relative performance of schemes with geometric integration properties, in terms of the accumulation of the temporal error, should be evaluated for realistic problems.\n\nIn the area of linear solvers a general, efficient, robust and scalable preconditioner for the Newton-Raphson linearised LLG equation is still required.\nOne approach to the construction of such a preconditioner could be to exploit the block structure of the Jacobian matrix and to use multigrid-based methods to approximate the Laplacian-like skew-symmetric off-diagonal blocks resulting from the exchange effective field.\nA less general approach for the case of granular or patterned media could be the use of a domain decomposition preconditioner.\nIn such a method the small matrix block associated with each grain/island would be inverted by a direct solver and the combination used as a block diagonal preconditioner.\nDue to the weak coupling between grains/islands this would provide a good approximation for the inverse of the entire LLG block.\nWith either of these enhanced LLG preconditioners the effectiveness of the preconditioner discussed in \\cref{sec:solution-strategies} on extremely large problems could be investigated.\n\n\nIn the time integration of the stochastic LLG only a few time integration schemes are known to converge to the correct solution, one of which is the implicit midpoint rule \\cite{DAquino2006}.\nSince the use of a semi-implicit magnetostatics coupling modifies the time integration scheme a monolithic coupling scheme is required to maintain this property.\nThe preconditioner developed in \\cref{sec:solution-strategies} should be tested in this capacity once effective preconditioners for the LLG sub-problem are available.\n\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "23b50470a0334270a41b8159851c55c8f501e05a", "size": 5708, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "conclusions-future-work.tex", "max_stars_repo_name": "davidshepherd7/thesis", "max_stars_repo_head_hexsha": "c4f1e903fa74e8fbc0667538e808fd7e3c947783", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-13T10:36:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-28T21:11:27.000Z", "max_issues_repo_path": "conclusions-future-work.tex", "max_issues_repo_name": "davidshepherd7/thesis", "max_issues_repo_head_hexsha": "c4f1e903fa74e8fbc0667538e808fd7e3c947783", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "conclusions-future-work.tex", "max_forks_repo_name": "davidshepherd7/thesis", "max_forks_repo_head_hexsha": "c4f1e903fa74e8fbc0667538e808fd7e3c947783", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.7457627119, "max_line_length": 315, "alphanum_fraction": 0.8239313245, "num_tokens": 1173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.44592014055262624}}
{"text": "\\FPset \\Months{36}\n\\FPset \\Years{3}\n\n\\FPset \\GroupAbaSalery{472.40} \n\\FPset \\GroupAmaSalery{472.40} \n\\FPset \\GroupBbaSalery{505.56} \n\\FPset \\GroupBmaSalery{687.72} \n\n\\FPset \\wiMASalery{66400} %http://www.dfg.de/formulare/60_12/60_12_de.pdf\n\n\\FPmul \\itemWiMASalery \\Years \\wiMASalery\n\\FPmul \\iiktWiMASalery \\Years \\wiMASalery\n\\FPadd \\totalWiMASalery \\itemWiMASalery \\iiktWiMASalery\n\\FPround \\itemWiMASalery \\itemWiMASalery {0}\n\\FPround \\iiktWiMASalery \\iiktWiMASalery {0}\n\\FPround \\totalWiMASalery \\totalWiMASalery {0}\n\n\\FPmul \\GroupAbaSaleryTotal \\Months \\GroupAbaSalery\n\\FPmul \\GroupAmaSaleryTotal \\Months \\GroupAmaSalery\n\\FPmul \\GroupBbaSaleryTotal \\Months \\GroupBbaSalery\n\\FPmul \\GroupBmaSaleryTotal \\Months \\GroupBmaSalery\n\n\\FPadd \\HiWiTotalSalery {0} \\GroupAbaSaleryTotal\n\\FPadd \\HiWiTotalSalery \\HiWiTotalSalery \\GroupAmaSaleryTotal\n\\FPadd \\HiWiTotalSalery \\HiWiTotalSalery \\GroupBmaSaleryTotal\n\n\\FPadd \\HiWiGroupATotalSalery \\GroupAbaSaleryTotal \\GroupAmaSaleryTotal\n\\FPadd \\HiWiGroupBTotalSalery \\GroupBbaSaleryTotal \\GroupBmaSaleryTotal\n\n\\FPround \\HiWiGroupATotalSalery \\HiWiGroupATotalSalery {2}\n\\FPround \\HiWiGroupBTotalSalery \\HiWiGroupBTotalSalery {2}\n\n\\FPround \\HiWiTotalSalery \\HiWiTotalSalery {2}\n\n\\FPround \\GroupAbaSaleryTotal \\GroupAbaSaleryTotal {2}\n\\FPround \\GroupAmaSaleryTotal \\GroupAmaSaleryTotal {2}\n\\FPround \\GroupBbaSaleryTotal \\GroupBbaSaleryTotal {2}\n\\FPround \\GroupBmaSaleryTotal \\GroupBmaSaleryTotal {2}\n\n\\FPadd \\totalSalery \\HiWiTotalSalery \\totalWiMASalery\n\\FPround \\totalSalery \\totalSalery {0}\n\n\n\n\n\\section{Requested modules/funds}\nWe are applying for the \"Basic Module\" in the research grants programme. \n\n\\subsection{Funding for staff}\n\\subsubsection{Research staff}\n\n\\paragraph{Postdoctoral researcher or comparable}\n\n\\noindent Not applicable.\n\n\\paragraph{Doctoral researcher or comparable}\n\n\\noindent We apply for \\textbf{a total amount of \\euro \\num[group-separator={,}]{\\totalSalery}}.\n\nFor \\GroupAProf\\ (\\GroupAlg--\\GroupA) and \\GroupBProf\\ (\\GroupBlg--\\GroupB) we\napply for \\euro \\num[group-separator={,}]{\\itemWiMASalery} each for \\Months months of funding for one doctoral\nresearcher. The researchers will work 100\\% of the standard work week\non the project and conduct the research. Employing a researcher in\nwage group TVL E-13 for one year costs \\euro \\num[group-separator={,}]{\\totalWiMASalery}.\n\n\\vspace{6pt}\n\\noindent\\begin{tabular}{lrrrr}\n\\bfseries Position && \\bfseries Amount &\\bfseries Factor &\\bfseries Subtotal \\\\\\hline\nDoctoral researcher at \\GroupA & TVL E-13 per year & \\euro \\num[group-separator={,}]{\\wiMASalery} & \\Years & \\euro \\num[group-separator={,}]{\\itemWiMASalery}\\\\\nDoctoral researcher at \\GroupB & TVL E-13 per year & \\euro \\num[group-separator={,}]{\\wiMASalery} & \\Years & \\euro \\num[group-separator={,}]{\\iiktWiMASalery}\n\\\\\\cline{5-5}\n\\bfseries Total & && &  \\bfseries \\euro \\num[group-separator={,}]{\\totalWiMASalery}\\\\\n\\end{tabular}\n\\vspace{6pt}\n\n\\paragraph{Other research assistant}\n\n\\noindent Not applicable.\n\n\\subsubsection{Non-academic staff member}\n\n\\noindent Not applicable.\n\n\\subsubsection{Miscellaneous staff}\n\n\\paragraph{Support staff (research support staff and student assistants)}\n\n\n\\noindent We apply for a {\\bfseries total amount of \\euro \\num[group-separator={,}]{\\HiWiTotalSalery}} for support staff.\n\n\nFor \\GroupAProf~(\\GroupA) we apply for funding of two student assistants to support the academic staff with implementation, simulation, and evaluation with the amount of \\euro \\num[group-separator={,}]{\\HiWiGroupATotalSalery}. Each assistant will work 40 hours per month during the duration of the project. The pre-tax wage at \\GroupA\\ is \\euro \\num[group-separator={,}]{\\GroupAbaSalery} independent of the students degree. \n\nFor \\GroupBProf~(\\GroupB) we also apply for funding of two student assistants with the amount of \\euro \\num[group-separator={,}]{\\HiWiGroupBTotalSalery}. The pre-tax wage at \\GroupB\\ is \\euro \\num[group-separator={,}]{\\GroupBbaSalery} for bachelor students per month and \\euro \\num[group-separator={,}]{\\GroupBmaSalery} a for master student.\n\n\\vspace{6pt}\n\\noindent\\begin{tabular}{lrrr}\n\\bfseries Position & \\bfseries Amount &\\bfseries Factor &\\bfseries Subtotal \\\\\\hline\nBachelor student at \\GroupA, 40 hours & \\euro \\GroupAbaSalery & \\Months & \\euro \\num[group-separator={,}]{\\GroupAbaSaleryTotal}\\\\\nMaster student at \\GroupA, 40 hours & \\euro \\GroupAmaSalery & \\Months & \\euro \\num[group-separator={,}]{\\GroupAmaSaleryTotal}\\\\\nBachelor student at \\GroupB, 40 hours & \\euro \\GroupBbaSalery & \\Months & \\euro\\num[group-separator={,}]{\\GroupBbaSaleryTotal}\\\\\nMaster student at \\GroupB, 40 hours & \\euro \\GroupBmaSalery & \\Months & \\euro \\num[group-separator={,}]{\\GroupBmaSaleryTotal}\\\\\n\\bfseries Total & & &  \\bfseries \\euro \\num[group-separator={,}]{\\HiWiTotalSalery}\\\\\n\\end{tabular}\n\\vspace{6pt}\n\n\\paragraph{Other staff}\n\\noindent Not applicable.\n\n\\subsection{Funding for direct project costs}\n\\subsubsection{Equipment up to \\euro10,000, software and consumables}\n\n\\noindent We apply for a {\\bfseries total amount of \\euro 16,500} for equipment. \n\nWe apply for the amount of \\euro 5,500 for each of the groups\n(\\GroupAProf and \\GroupBProf ) for a \"Xilinx\nVirtex UltraScale FPGA VCU108 Evaluation Kit\".  An state-of-the-art\nFPGA board is required for prototyping. After finishing this project the\nprototyping boards can also be used for other research activities.\n\n\\subsubsection{Travel}\n\n\\noindent We apply for a {\\bfseries total amount of \\euro 20,000} for travel expenses. \n\nWe apply for funding of the expenses for conference travels to the amount of \\euro 8,000 for \\GroupAProf~(\\GroupA) for two European and two International conferences; we apply for funding of the expenses for conference travels to the amount of \\euro 8,000 for \\GroupBProf~(\\GroupB) for two European and two International conferences:\n\n\\vspace{6pt}\n\\noindent\\begin{tabular}{lrrr}\n\\bfseries Position & \\bfseries Amount &\\bfseries Factor &\\bfseries Subtotal \\\\\\hline\nEuropean conference (\\GroupA) & \\euro 1,500 & 2 & \\euro 3,000\\\\\nInternational conference (\\GroupA) & \\euro 2,500 & 2 & \\euro 5,000\\\\\nEuropean conference (\\GroupB) & \\euro 1,500 & 2 & \\euro 3,000\\\\\nInternational conference (\\GroupB) & \\euro 2,500 & 2 & \\euro 5,000\\\\   \n\\bfseries Total & & &  \\bfseries \\euro 20,000\\\\\n\\end{tabular}\n\\vspace{6pt}\n\n\\noindent In addition, for cooperation within this project we apply\nfor \\euro 4,210 for \\GroupAProf\\ (\\GroupA) , \\euro 4,210 for\n\\GroupBProf~(\\GroupB). There are five\njoined work packages (WP 5.1, WP 5.2, WP 5.3, WP 7.3, WP 7.4) and five\nwork packages requiring close cooperation (WP 1.3, WP 2.3, WP 3, WP 4,\nWP 7.2). Therefore we ask for the travel expenses for 10 meetings, in\nwhich two persons are visiting the project partner.\nWe assume a duration of half a work week per meeting (2 nights). Thus,\nper person and trip two railway tickets, two nights at a hotel, and\nthree daily allowances are required, which amounts to:\n\n\\vspace{6pt}\n\\noindent\\begin{tabular}{lrrr}\n\\bfseries Position & \\bfseries Amount &\\bfseries Factor &\\bfseries Subtotal \\\\\\hline\nRailway ticket, single trip per person & \\euro 65.00 & 40=10*2*2 & \\euro 2,600\\\\\nAccommodation per night and person & \\euro 80.00 & 40=10*2*2 & \\euro 3,200\\\\\nDaily allowance & \\euro 24.00 & 60=10*3*2 & \\euro 1,440 \\\\\\cline{4-4}\n\\bfseries Total & & &  \\bfseries \\euro 8,240\\\\\n\\end{tabular}\n\\vspace{6pt}\n\n\n\\subsubsection{Visiting researchers}\n\n\\noindent Not applicable.\n\n\\subsubsection{Experimental animals}\n\n\\noindent Not applicable.\n\n\\subsubsection{Other}\n\n\\noindent Not applicable.\n\n\\subsubsection{Project-related publication expenses}\n\\noindent At least four open-access journal publications are expected. This requires additional fees for handling\nand open access services of about 1,500 EUR. Our universities employ\nan open access strategy already. However, researchers are encouraged\nto acquire additional funding for open access publishing. Therefore We\napply for a {\\bfseries total amount of \\euro 1,500} to pay fees of\njournal publications. For \\GroupAProf~(\\GroupA) we apply for \\euro 750 and\nfor \\GroupBProf~(\\GroupB) we apply for \\euro 750 as well.\n\n\\subsection{Funding for instrumentation}\n\n\\noindent Not applicable.\n\n", "meta": {"hexsha": "1e5319685be8a1d79ee5949438dbadf0ed19b91a", "size": 8194, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "40_funds.tex", "max_stars_repo_name": "jmjos/dfg-research-grant-proposal-template", "max_stars_repo_head_hexsha": "bc08bd5cb2ae5b2910c69fe49a9899d595bd5e34", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-05-05T20:12:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T05:43:46.000Z", "max_issues_repo_path": "40_funds.tex", "max_issues_repo_name": "jmjos/dfg-research-grant-proposal-template", "max_issues_repo_head_hexsha": "bc08bd5cb2ae5b2910c69fe49a9899d595bd5e34", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "40_funds.tex", "max_forks_repo_name": "jmjos/dfg-research-grant-proposal-template", "max_forks_repo_head_hexsha": "bc08bd5cb2ae5b2910c69fe49a9899d595bd5e34", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.2918918919, "max_line_length": 424, "alphanum_fraction": 0.7643397608, "num_tokens": 2588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.833324587033253, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4459106770574136}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\begin{document}\n\n\\title{GRM}\n\\date{Lent 2016/2017}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Groups}\n\n\\subsection{1.2}\n\n\\begin{defi}\nA homomorphism is called an \\emph{isomorphism} if it is a bijection. Say groups $G$ and $H$ are isomorphic if there exists an isomorphism $\\phi:G \\to H$ between them, write $G \\cong H$.\n\\end{defi}\n\nExercise: If $\\phi$ is an isomorphism, then the inverse function $\\phi^{-1}: H \\to G$ is also a homomorphism (so an isomorphism).\n\n\\begin{thm} (First isomorphism theorem)\\\\\nLet $\\phi:G \\to H$ be a homomorphism. Then $\\ker(\\phi) \\triangleleft G$, $\\im(\\phi) \\leq H$, and $G/\\ker(\\phi) \\cong \\im(\\phi)$.\n\\begin{proof}\nWe've done the first two parts.\\\\\nLet $f:G/\\ker(\\phi) \\to \\im(\\phi)$ by $g\\ker(\\phi) \\to \\phi(g)$.\\\\\n$f$ is well-defined: if $g\\ker(\\phi) = g'\\ker(\\phi)$ then $g^{-1}g' \\in \\ker(\\phi)$. So $e_H = \\phi(g^{-1}g')=\\phi(g^{-1}) \\cdot \\phi(g') = \\phi(g)^{-1} \\phi(g')$. So $\\phi(g) = \\phi(g')$. So we have $f(g\\ker(\\phi)) = f(g'\\ker(\\phi))$.\n\n$f$ is a homomorphism: $f(g\\ker(\\phi)\\cdot g'\\ker(\\phi)) = f(gg'\\ker(\\phi)) = \\phi(gg') = \\phi(g)\\phi(g') = f(g\\ker(\\phi))\\cdot f(g'\\ker(\\phi))$.\n\n$f$ is surjective: Let $h \\in \\im(\\phi)$, i.e. $h=\\phi(g)$ for some $g$. So $h=f(g\\ker(\\phi))$.\n\n$f$ is injective: Suppose $f(g\\ker(\\phi)) = e_H$, i.e. $\\phi(g)=e_H$. Then $g \\in \\ker(\\phi)$. So $g\\ker(\\phi) = e_G \\ker(\\phi)$.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\nConsider $\\phi : \\C \\to \\C \\backslash \\{0\\}$ by $z \\to e^z$. Then $\\phi$ is a homomorphism from $(\\C,+,0)$ to $(\\C \\backslash \\{0\\},\\times,1)$. $\\phi$ is onto because $\\log$ exists (principal value). We have\n\\begin{equation*}\n\\begin{aligned}\n\\ker(\\phi) = \\{z \\in \\C | e^z = 1\\} = \\{2\\pi ik \\in \\C | k \\in \\Z \\} = 2\\pi i \\Z\n\\end{aligned}\n\\end{equation*}\nSo from first isomorphism theorem we get $(\\C / 2\\pi i\\Z,+,0) \\cong (\\C\\backslash\\{0\\},\\times,1)$.\n\\end{eg}\n\n\\begin{thm} (Second isomorphism theorem)\\\\\nLet $H \\leq G$, $K \\triangleleft G$. Then\n\\begin{equation*}\n\\begin{aligned}\nHK = \\{x=hk \\in G | h \\in H, k \\in K\\}\n\\end{aligned}\n\\end{equation*}\nis a subgroup of $G$, $H \\cap K \\triangleleft H$, and\n\\begin{equation*}\n\\begin{aligned}\nHK/K \\cong H/H\\cap K\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nLet $hk,h'k' \\in HK$. Then\n\\begin{equation*}\n\\begin{aligned}\nh'k'(hk)^{-1} = h'k'k^{-1}h^{-1}=h'h^{-1}hk'k^{-1}h^{-1}\n\\end{aligned}\n\\end{equation*}\n$h'h^{-1}\\in H$, and $hk'k^{-1}h^{-1} \\in K$ since $K \\triangleleft G$. So $h'k'(hk)^{-1} \\in HK$. So $HK \\leq G$.\n\nThen consider $\\phi: H \\to G/K$ by $h \\to hK$. This is a homomorphism (composition of $H \\to G \\to G/K$). Then\n\\begin{equation*}\n\\begin{aligned}\n\\ker(\\phi) = \\{h \\in H|hK = eK\\} = H \\cap K\n\\end{aligned}\n\\end{equation*}\nso $H\\cap K$ is normal in $H$ by first isomorphism theorem. Also\n\\begin{equation*}\n\\begin{aligned}\n\\im(\\phi)=\\{gK\\in G/K|gK=hK \\text{ for some } h\\in H\\} =  HK/K\n\\end{aligned}\n\\end{equation*}\nSo by first isomorphism theorem, $H/H \\cap K \\cong HK/K$ as required.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (Subgroup correspondence)\\\\\nLet $K \\triangleleft G$. There is a bijection between subgroups of $G/K$ and subgroups of $G$ that contain $K$ by:\\\\\n$\\leftarrow$: $L/K \\leq G/K \\leftarrow K \\triangleleft L \\leq G $ and\\\\\n$\\rightarrow$: $U \\leq G/K \\to \\{g \\in G| gK \\in U\\}$.\n\nThe same maps give a bijection between normal subgroups of $G/K$ and normal subgroups of $G$ that contain $K$.\n\\end{thm}\n\n\\begin{thm} (Third isomorphism theorem)\\\\\nLet $K \\triangleleft L$, $L \\triangleleft G$. Then $(G/K)/(L/K) \\cong G/L$.\n\\begin{proof}\nLet $\\phi:G/K \\to G/L$ by $gK \\to gL$.\n\n$\\phi$ is well-defined: if $gK=g'K$ then $g^{-1}g' \\in K \\leq L$. So $gL =g(g^{-1}g')L = g'L$.\n\n$\\phi$ is clearly surjective, and $\\ker(\\phi) = \\{gK \\in G/K | gL=eL \\iff g\\in L\\} = L/K$.\n\nSo by first isomorphism theorem, $(G/K)/(L/K) \\cong G/L$.\n\\end{proof}\n\\end{thm}\n\n\\begin{defi}\nA group $G$ is \\emph{simple} if its only normal subgroups are $\\{e\\}$ and $G$.\n\n\\begin{lemma}\nAn abelian group is simple iff it is isomorphic to $C_p$ for prime $p$.\n\\begin{proof}\nIn an abelian group, every subgroup is normal. Now let $g \\in G$ be non-trivial and consider $H=\\{...,g^{-1},e,g,...\\}$. This is a subgroup of $G$, so a normal subgroup of $G$. If $G$ is simple, then since $g$ is non-trivial, this must be equal to $G$. So $G$ is a cyclic group.\n\nIf $G$ is infinite, then it is isomorphic to $(\\Z,+,0)$. But $2\\Z \\triangleleft \\Z$. So this is not simple.\n\nSo $G \\cong C_n$ for some $n$. If $n = a\\cdot b$ for some $a,b \\in \\Z$ and $a,b \\neq 1$, then $G$ contains $<...,g^{-a},e,g^a,...> \\cong C_b$ as a proper subgroup. Contradiction.\n\nSo $n$ must be a prime number.\n\nFinally, note that $C_p$ for prime $p$ is indeed simple: by Lagrange theorem any subgroup of $C_p$ must have order $1$ or $p$.\n\\end{proof}\n\\end{lemma}\n\\end{defi}\n\n\\subsection{Actions and Permutations}\n\n\\begin{thm}\nLet $G$ be a non-abelian simple group, and $H \\leq G$ a subgroup of index $n>1$. Then $G$ is isomorphic to a subgroup of $A_n$ for $n \\geq 5$.\n\\begin{proof}\nWe let $G$ act on $X=G/H$, giving $\\phi:G \\to \\Sym(G/H)$. Then $\\ker(\\phi) \\triangleleft G$, so as $G$ is simple, either $\\ker(\\phi) = G$ or $\\ker(\\phi) = \\{e\\}$. But\n\\begin{equation*}\n\\begin{aligned}\n\\ker(\\phi) = \\bigcap_{g \\in G} g^{-1}Hg \\leq H\n\\end{aligned}\n\\end{equation*}\na proper subgroup of $G$; so the first case cannot occur. So $\\ker(\\phi) = \\{e\\}$.\n\nBy 1st isomorphism theorem,\n\\begin{equation*}\n\\begin{aligned}\nG \\cong G/\\{e\\} \\cong \\im(\\phi) = G^X \\leq \\Sym(G/H) \\cong S_n\n\\end{aligned}\n\\end{equation*}\n\nApply 2nd isomorphism theorem to $A_n \\triangleleft S_n$, $G^X \\leq S_n$. Then $G^X \\cap A_n \\triangleleft G^X$, $G^X/G^X\\cap A_n = G^X A_n / A_n$.\nAs $G^X \\cong G$ is simple, $G^X \\cap A_n \\triangleleft G^X$, so $G^X \\cap A_n = \\{e\\}$ or $G^X \\cap A_n = \\{e\\}$. But if the first case holds, then $G^X \\cong G^XA_n/A_n \\leq S_n / A_n \\cong C_2$, contradicting $G^X \\cong G$ being non-abelian. Hence $G^X \\cap A_n = G^X$, i.e. $G^X \\leq A_n$.\n\n$n \\geq 5$ because $A_2,A_3,A_4$ have no non-abelian simple subgroups.\n\\end{proof}\n\\end{thm}\n\n\\begin{coro}\nIf $G$ is non-abelian simple, $H \\leq G$ is of index $n$, then $|G| \\mid \\frac{n!}{2}$.\n\\end{coro}\n\n\\begin{defi}\nIf $G$ acts on $X$, the \\emph{orbit} of $x \\in X$ is\n\\begin{equation*}\n\\begin{aligned}\nG \\cdot x = \\{ y=g*x \\in X| g \\in G\\}\n\\end{aligned}\n\\end{equation*}\nand the \\emph{stabiliser} of $x \\in X$ is\n\\begin{equation*}\n\\begin{aligned}\nG_x = \\{g\\in G|g*x = x\\} \\leq G.\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{thm} (Orbit-stabiliser).\\\\\nIf $G$ acts on $X$, then for any $x \\in X$, there is a bijection between $G\\cdot x$ and $G/G_x$ by $g*x \\to gG_x$, $gG_x \\leftarrow y=g*x$.\n\\end{thm}\n\n\\subsection{Conjugacy classes, centralisers and normalisers}\nThere is an action of $G$ on the set $X=G$ via $g*x := g\\cdot x \\cdot g^{-1}$.\n\nThis gives a map $\\phi : G \\to \\Sym(G)$. Note $\\phi(g)(x \\cdot t)=g \\cdot x \\cdot t \\cdot g^{-1} = gxg^{-1}gtg^{-1}=\\phi(g)(x) \\cdot \\phi(g)(t)$, i.e. $\\phi(g)$ is a group homomorphism. Also it's a bijection (in $\\Sym(G)$), so it is an isomorphism.\n\nLet $\\Aut(G) = \\{f:G \\to G | f$ is a group isomoprhism $\\} \\leq \\Sym(G)$, called the automorphisms of $G$.\n\nWe have shown that $\\phi:G \\to \\Sym(G)$ has image in $\\Aut(G) \\leq \\Sym(G)$.\n\n\\begin{defi}\nThe \\emph{conjugacy class} of $x \\in G$ is $G \\cdot x = Cl_G(x) = \\{gxg^{-1} | g \\in G\\}$.\\\\\nThe \\emph{centraliser} of $x\\in G$ is $G_x=C_G(x) = \\{g \\in G | gxg^{-1} = x \\iff gx = xg\\}$.\\\\\nThe \\emph{centre} of $G$ is $Z(G) = G_X = \\ker(\\phi) = \\{g\\in G| gxg^{-1} = x \\forall x \\in G\\}$.\\\\\nThe \\emph{normaliser} of $H \\leq G$ is $N_G(H) = \\{ g \\in G | gHg^{-1} = H\\}$.\n\\end{defi}\n\nBy Orbit-stabiliser theorem, there is a bijection between $Cl_G(x)$ and $G / C_G(x)$. So if $G$ is finite, then $|Cl_G(x)|$ equals the index of $C_G(x) \\leq G$ which divides $|G|$.\n\nRecall (from IA groups) that in $S_n$,\\\\\n(i) everything can be written as a product of disjoint cycles;\\\\\n(ii) permutations are conjugate iff they have the same cycle type.\n\n\\begin{thm}\n$A_n$ is simple for $n \\geq 5$.\n\\begin{proof}\nFirst, claim $A_n$ is generated by $3-$cycles.\n\nNeed to show that a product of two transposition is a product of $3-$cycles. We have $(ab)(bc)=(abc)$, $(ab)(cd) = (acb)(acd)$.\n\nLet $H \\triangleleft A_n$. \\emph{If} $H$ contains a $3-$cycle, say $(abc)$.\n\nIn $S_n$, there is a $\\sigma$ so that $(abc) = \\sigma^{-1} (123) \\sigma$. If $\\sigma \\in A_n$, then $(123) \\in H$. Otherwise, let $\\sigma' = (45) \\sigma \\in A_n$. Then $\\sigma(123)\\sigma = (abc)$.\n\nSo all $3-$cycles are in $H$ if one of them is in $H$. In that case we know $H = A_n$.\n\nSo it is enough to show that any $\\{e\\} \\neq H \\triangleleft A_n$ contains a $3-$cycle.\n\nCase 1: $H$ contains $\\sigma = (123...r)\\tau$ in disjoint cycle notation for some $r \\geq 4$. Let $\\delta = (123)$ and consider $\\sigma^{-1}\\delta^{-1}\\sigma\\delta$. This is in $H$. Evaluate it and we get\n\\begin{equation*}\n\\begin{aligned}\n\\sigma^{-1}\\delta^{-1}\\sigma\\delta &= \\tau^{-1}(r...21)(132)(12...r)\\tau(123)\\\\\n&=(r...21)(132)(12...r)(123)\\\\\n&=(23r) \\in H\n\\end{aligned}\n\\end{equation*}\nis a $3-$cycle. \n\nCase 2: $H$ contains $\\sigma = (123)(456)\\tau$ in disjoint cycle notation. Let $\\delta = (124)$ and calculate\n\\begin{equation*}\n\\begin{aligned}\n\\sigma^{-1}\\delta^{-1}\\sigma\\delta = (132)(465)(142)(123)(456)(124) = (12436)\n\\end{aligned}\n\\end{equation*}\nSo we've reduced to the first case.\n\nCase 3: $H$ contains $\\sigma = (123) \\tau$, and $\\tau$ is a product of $2-$cycles. Then $\\sigma^2 = (132) \\in H$.\n\nCase 4: $H$ contains $\\sigma = (12)(34)\\tau$, and $\\tau$ is a product of $2-$cycles. Let $\\delta = (123)$, then\n\\begin{equation*}\n\\begin{aligned}\nu=\\sigma^{-1}\\delta^{-1}\\sigma\\delta=(12)(34)(132)(12)(34)(123)=(14)(23)\n\\end{aligned}\n\\end{equation*}\n\nNow let $v=(152)u(125) = (13)(45)$. We have $u\\cdot v = (14)(23)(13)(45) = (12345)$. So we've reduced to the first case.\n\nSo $H$ contains a $3-$cycle.\n\n\\end{proof}\n\\end{thm}\n\n\\subsection{$p$-groups}\nA finite group $G$ is a $p$-group if $|G| = p^n$ for some prime number $p$.\n\n\\begin{thm}\nIf $G$ is a finite $p$-group, then $Z(G) \\neq \\{e\\}$.\n\\begin{proof}\nThe conjugacy classes partition $G$, and \n\\begin{equation*}\n\\begin{aligned}\n|Cl(x)| = |G/C_G(x)| \\mid |G|\n\\end{aligned}\n\\end{equation*}\nby Orbit-Stabilizer and Lagrange's Theorem. So $|Cl(x)|$ is a power of $p$.\n\nWe know $|G|$ is the sum of sizes of conjugacy classes. We can write $|G|$ = number of conjugacy classes of size $1$ + size of all other conjugacy classes (which is divisible by $p$). Since $p \\mid |G|$, the number of conjugacy classes of size 1 is divisible by $p$. In particular, $|Cl(e)| = 1$, so there is at least $p$ of such conjugacy classes.\n\nNow note that $Z(G)$ consider all the elements that commutes with all the elements in the group, i.e. they have conjugacy classes of size $1$. So $|Z(G)| \\geq p$.\n\\end{proof}\n\\end{thm}\n\n\\begin{coro}\nA group of order $p^n$, $n > 1$, is \\emph{never} simple.\n\\end{coro}\n\n\\begin{lemma}\nFor any group $G$, if $G/Z(G)$ is cyclic, then $G$ is abelian.\n\\begin{proof}\nLet the coset $gZ(G)$ generate the cyclic group $G/Z(G)$. Then every coset is a of the form $g^r Z(G)$, $r \\in \\Z$. So every element of $G$ is of the form $g^r \\cdot z$ for $z \\in Z(G)$. Now take\n\\begin{equation*}\n\\begin{aligned}\n(g^rz)\\cdot(g^{r'} z') = g^r g^{r'} z z' = g^{r'}g^r z'z = g^{r'} z' g^r z\n\\end{aligned}\n\\end{equation*}\nSo $G$ is abelian.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}\nIf $|G| = p^2$, $p$ is prime, then $G$ is abelian.\n\\begin{proof}\nWe know $\\{e\\} \\lneq Z(G) \\leq G$, so $|Z(G)| = p$ or $p^2$. If it's $p^2$ then $G=Z(G)$ is abelian.\n\nIf $|Z(G)| = p$, then $|G/Z(G)| = p$. So $G/Z(G)$ is cyclic. So $G$ is abelian.\n\\end{proof}\n\\end{coro}\n\n\\begin{thm} \nIf $|G| = p^a$, then $G$ has a subgroup of order $p^b$ for any $0 \\leq b \\leq a$.\n\\begin{proof}\nProve by induction on $a$. If $a=1$ then done. For $a>1$, have $\\{e\\} \\lneq Z(G)$. Let $e \\neq x \\in Z(G)$. Then $x$ has order a power of $p$, so we can take some power of $p$ that has order $p$, say $z$. Let $C=\\left<z\\right>$, a normal subgroup of $G$ (since this is inside centre). \nNow $G/C$ has order $p^{a-1}$. By induction hypothesis, we may find a subgroup $H \\leq G/C$ of order $p^{b-1}$. Now by subgroup correspondence, this $H$ gives some $L\\leq G$ that contains $C$ (by $H =L/C$), and $|L| = p^b$.\n\\end{proof}\n\\end{thm}\n\n\\subsection{Finite abelian groups}\n\\begin{thm}\nIf $G$ is a finite abelian group, then\n\\begin{equation*}\n\\begin{aligned}\nG \\cong C_{d_1} \\times c_{d_2} \\times ... \\times C_{d_k}\n\\end{aligned}\n\\end{equation*}\nwith $d_{i+1} | d_i$ for all $i$.\n\nWe will prove this later, by considering an abelian group as a $\\Z$-module.\n\\end{thm}\n\n\\begin{eg}\nIf $|G|=8$ and $G$ is abelian, then $G$ is either $C_8$, or $C_4 \\times C_2$, or $C_2 \\times C_2 \\times C_2$.\n\\end{eg}\n\n\\begin{lemma} (Chinese Remainder Theorem)\\\\\nIf $n,m$ are coprime, then $C_{nm} \\cong C_n \\times C_m$.\n\\begin{proof}\nLet $g \\in C_n$ have order $n$, $h \\in C_m$ has order $m$. Consider $x = (g,h)$ in $C_n \\times C_m$. Clearly $x^{nm} = (e,e)$.\n\nNow if $(e,e) = x^r = (g^r,h^r)$, then $n \\mid r$ and $m \\mid r$. So $nm \\mid r$. So the order of $x$ is $nm$. So $\\left<x\\right> \\cong C_{nm}$. Then by size we get the desired result.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}\nIf $G$ is a finite abelian group, then\n\\begin{equation*}\n\\begin{aligned}\nG \\cong C_{n_1} \\times C_{n_2} \\times ... \\times C_{n_l}\n\\end{aligned}\n\\end{equation*}\nwith each $n_i$ a power of a prime number.\n\\begin{proof}\nIf $d=p_1a^1...p_ra^r$ for distinct prime $p_i$, the lemma shows\n\\begin{equation*}\n\\begin{aligned}\nC_d \\cong C_{p_1a^1} \\times C_{p_2a^2} \\times ... \\times C_{p_ra^r}\n\\end{aligned}\n\\end{equation*}\nApply this to the theorem.\n\\end{proof}\n\\end{coro}\n\n\\subsection{Sylow's Theorems}\n\\begin{thm} (Sylow's)\\\\\nLet $|G| =p^a \\cdot m$, with $(p,m) = 1$, where $p$ is prime. Then\\\\\n(i) The set $Syl_p(G)=\\{P \\leq G \\mid |P| = p^a\\}$ of \\emph{Sylow $p$-subgroup} is not empty.\\\\\n(ii) All elements inf $Syl_p(G)$ are conjugate in $G$.\\\\\n(iii) The number $n_p = |Syl_p(G)|$ satisfies $n+p \\equiv 1 \\pmod p$ and $n_p \\mid |G|$ (i.e. $n_p \\mid m$).\n\\end{thm}\n\n\\begin{lemma}\nIf $n_p=1$, then the unique Sylow $p$-subgroup is normal in $G$.\n\\begin{proof}\nIf $g \\in G$, $P \\leq G$ the Sylow subgroup, then $g^{-1}Pg$ is a subgroup of order $p^a$. But $P$ is the only such subgroup.\n\\end{proof}\n\\end{lemma}\n\nNote that this tells that, if $G$ is simple, then $n_p \\neq 1$; or conversely, if $n_p = 1$ for some $p$, then $G$ is not simple.\n\n\\begin{eg}\nLet $|G| = 96 = 2^5 \\cdot 3$. So $n_2 \\equiv 1 \\pmod 2$ and $n_2 \\mid 3$. So $n_2 = 1$ or $3$. Also, $n_3 \\equiv 1 \\pmod 3$ and $n_3 \\mid 32$. So $n_3 = 1,4,16$.\n\\end{eg}\n\n$G$ acts on the set $Syl_p(G)$ by conjugation. So (ii) of the theorem says that this action has $1$ orbit. The stabilizer of $P \\in Syl_p(G)$, i.e. the normalizer $N_G(P) \\leq G$, is of index $n_p = |Syl_p(G)|$.\n\n\\begin{coro}\nIf $G$ is non-abelian simple, then\n\\begin{equation*}\n\\begin{aligned}\n|G| \\mid \\frac{(n_p)!}{2}.\n\\end{aligned}\n\\end{equation*}\nand $n_p \\geq 5$.\n\\begin{proof}\n$N_G(P)$ has index $n_p$. So apply the general result about subgroups of non-abelian simple groups (see section 1.2).\n\\end{proof}\n\\end{coro}\n\nNow in the above example, $|G| \\nmid \\frac{3!}{2}$, so the group $G$ cannot be non-abelian simple. Also it cannot be abelian simple as 96 is not a prime.\n\n\\begin{eg}\nSuppose $G$ is a simple group of order $132=2^2\\times 3 \\times 11$.\n\nWe know $n_{11} = 1 \\pmod {11}$ and $n_{11} | 12$. As $G$ is simple we can't have $n_{11} = 1$, so $n_{11} = 12$.\n\nEach Sylow 11-subgroup has order 11, so is isomorphic to $C_{11}$, so contains $10=(11-1)$ elements of order $11$. Such subgroups can only intersect in the identity element, so we have 12+10 = 120 elements of order 11. We know $n_3 \\equiv 1 \\pmod 3$ and $n_3 | 44$, so $n_3 = 1,4$ or $22$ but similarly $n_3 \\neq 1$. If $n_3 = 4$ then we need $|G| \\mid \\frac{4!}{2}|$ which is impossible. So $n_3 = 22$. But then by counting the number of elements we get a contradiction.\n\\end{eg}\n\n\\textbf{Proof of Sylow's Theorems.} Let $|G| = p^n \\cdot m$.\\\\\ni) Let $\\Omega$ be the set of subsets of $G$ of order $p^n$, and let $G$ act on $\\Omega$ via $g * \\{g_1,...,g_{p^n}\\} = \\{gg_1,...,gg_{p^n}\\}.$\\\\\nLet $\\varepsilon \\subset \\Omega$ be an orbit for this action. If $\\{g_1,...,g_{p^n}\\} = \\varepsilon$, then\n\\begin{equation*}\n\\begin{aligned}\n(gg_1^{-1}) * \\{g_1,...,g_{p^n}\\} = \\varepsilon = \\{ g,gg^{-1}_1 g_2,...,gg^{-1}_1 g_{p^n}\\}\n\\end{aligned}\n\\end{equation*}\nSo for any $g \\in G$, there is an element of $\\varepsilon$ which contains $g$. So $|\\varepsilon| \\geq \\frac{|G|}{p^n} = m$.\n\nIf there is some orbit $\\varepsilon$ with $|\\varepsilon|=m$, then the stabilizer $G_\\varepsilon$ has order $\\frac{|G|}{|\\varepsilon|} = \\frac{p^n m}{m} = p^n$, so $G_\\varepsilon$ \\emph{is} a Sylow $p-$subgroup. To show this happens, we must show that it is not possible for \\emph{every} orbit of $G$ acting on $\\Omega$ to have size $>m$.\n\nBy orbit-stabilizer, for any orbit $\\varepsilon$, $|\\varepsilon| |p^n \\cdot m$, so if $|\\varepsilon|>m$, then $p | |\\varepsilon|$. So if \\emph{all} orbits of $G$ acting on $\\Omega$ has size $>m$, then $p$ divides all of them, so $p | |\\Omega|$. \n\nLet's calculate $|\\Omega|$. We have\n\\begin{equation*}\n\\begin{aligned}\n|\\Omega| = {p^n m \\choose p^n} = \\prod_{j=0}^{p^n-1} \\frac{p^nm ... j}{p^n ... j} (???)\n\\end{aligned}\n\\end{equation*}\nThe largest power of $p$ dividing $p^n m=j$ is the same as the largest power of $p$ dividing $j$, which is the same as the largest power of $p$ dividing $p^n = j$. So $|\\Omega|$ is \\emph{not} divisible by $p$.\n\nii)Let's show something \\emph{stronger}: if $p \\in Syl_p(G)$ and $Q$ is a $p-$subgroup, then there is a $g \\in G$ s.t. $g^{-1}Qg \\in P$.\n\nLet $G$ act on $G/P$ by $q*g^p = qg^p$.  By orbit-stabilizer, the size of an orbit divides $|Q| = p^n$, so is either 1 or divisible by $p$.\n\nOn the other hand, $|G/P| = \\frac{|G|}{|P|} = m$ is not divisible by $p$. So ther must be an orbit of size 1, say $\\{g^p\\}$, i.e. for every $q \\in Q$, $qg^p = g^p$ i.e. $g^{-1}qg \\in P$ $\\forall q \\in Q$, i.e. $g^{-1} Qg \\leq P$.\n\n(iii) By (ii), $G$ acts on $Syl_p(G)$ by conjugation with one orbit, so by orbit-stabilizer, $n_p \\equiv |Syl_p(G)| \\mid |G|$, which is the second part of (ii).\n\n\\begin{eg}\nConsider $GL_2(\\Z/p)$. It has order $(p^2-1)(p^2-p) = p(p+1)(p-1)^2$. Let $l$ be an odd prime dividing $p-1$ once only. Then $l \\nmid p$. But also $l \\nmid p+1$. So $l^2$ is the largest power of $l$ dividing $|GL_2(\\Z/p)|$, i.e. there is at least a subgroup of order $l^2$. We have\n\\begin{equation*}\n\\begin{aligned}\n(\\Z/p)^X &= \\{ x \\in \\Z/p | \\exists g \\in \\Z/p \\ s.t. \\ xy=1 \\in \\Z/p\\}\\\\\n&= \\{x \\in \\Z /p | x\\neq 0\\}\n\\end{aligned}\n\\end{equation*}\nhas size $p-1$. As a group under \\emph{multiplication}, $(\\Z/p)^X \\cong C_{p-1}$. So there is a subgroup $C_l \\leq C_{p-1}$, i.e. we can find a $1 \\neq x \\in (\\Z/p)^X$ so that $x^l=1$.\n\nNow let \n\\begin{equation*}\n\\begin{aligned}\nH &= \\left\\{ \\left(\\begin{matrix}\na & 0\\\\\n0 & b\n\\end{matrix}\\right) \\mid a,b \\in (\\Z/p)^X \\text{ has order } l \\right\\} \\cong C_l \\times C_l\\\\\n&\\leq GL_2(\\Z/p)\n\\end{aligned}\n\\end{equation*}\nis a Sylow $l-$subgroup (order $l^2$).\n\\end{eg}\n\n\\begin{eg}\nConsider $$SL_2 (\\Z/p) = \\ker(\\det: GL_2(\\Z/p) \\to (\\Z_p)^X\\}$$ \nThe determinant homomorphism is onto, so $SL_2(\\Z/p) \\leq GL_2(\\Z/p)$ has index $(p-1)$. So $|SL_2(\\Z/p)| = (p-1)p(p+1)$.\n\nNow consider\n\\begin{equation*}\n\\begin{aligned}\nPSL_2(\\Z/p) := SL_2(\\Z/p) / \\left\\{\\left(\\begin{matrix}\n\\lambda & 0 \\\\\n0 & \\lambda\n\\end{matrix}\\right) \\in SL_2(\\Z/p)\\right\\}\n\\end{aligned}\n\\end{equation*}\nIf $\\left(\\begin{matrix}\n\\lambda & 0\\\\\n0 & \\lambda\n\\end{matrix}\\right) \\in SL_2(\\Z /p)$ then $\\lambda^2 = 1 \\in (\\Z/p)^X \\cong C_{p-1}$. As long as $p \\geq 3$, there are two such $\\lambda$, $+1$ and $-1$. So $|PSL_2(\\Z/p)| =\\frac{1}{2} (p-1)p(p+1)$.\n\nLet $(\\Z/p)_\\infty =\\Z/p \\cup \\{\\infty\\}$. Then $PSL_2 (\\Z/p)$ acts on $(\\Z/p)_\\infty$ by M$\\ddot{o}$bius maps:\n\\begin{equation*}\n\\begin{aligned}\n\\left[\\begin{matrix}\na & b\\\\\nc & d\n\\end{matrix} \\right] * z := \\frac{az+b}{cz+d}\n\\end{aligned}\n\\end{equation*}\nwith the usual convention that if $cz+d=0$ then we get $\\infty$.\n\\end{eg}\n\n\\begin{eg}\nLet $p=5$, then this action gives a homomorphism $\\phi: PSL_2(\\Z/p) \\to \\Sym\\left((\\Z/5)_\\infty\\right) \\cong S_6$.\n\nWe have $|PSL_2(\\Z/5)| = \\frac{1}{2}\\cdot 4\\cdot 5 \\cdot 6 = 60$.\n\n\\textbf{Claim.} $\\phi$ is injective.\n\\begin{proof}\nIf $\\frac{az+b}{cz+d} = z$ $\\forall z \\in (\\Z/p)_\\infty$, set $z=0$ we get $b=0$. Set $z=\\infty$ we get $c=0$. Set $z=1$ we get $a=d$. So $\\left[\\begin{matrix}\na & b\\\\\nc & d\n\\end{matrix}\\right] = \\left[\\begin{matrix}\n1 & 0\\\\\n0 & 1\n\\end{matrix}\\right] \\in PSL_2 (\\Z/p)$.\n\\end{proof}\n\n\\textbf{Claim.} $\\phi$ lands in $A_6 \\leq S_6$.\n\\begin{proof}\nConsider the composition\n\\begin{equation*}\n\\begin{aligned}\n\\psi: PSL_2(\\Z/5) \\to \\Sym((\\Z/5)_\\infty) \\cong S_6 \\to \\{\\pm 1\\} \n\\end{aligned}\n\\end{equation*}\nby $\\phi$ and $sgn$ respectively. We need to show that $\\psi\\left(\\begin{matrix}\na & b\\\\\nc & d\n\\end{matrix}\\right) = +1$.\n\nWe know that elements of odd order in $PSL_2(\\Z/5)$ have to be sent to $+1$.\n\nNote that $H = \\left\\{ \\left[\\begin{matrix}\n\\lambda & 0\\\\\n0 & \\lambda^{-1} \n\\end{matrix}\\right], \\left[\\begin{matrix}\n0 & \\lambda\\\\\n-\\lambda^{-1} & 0\n\\end{matrix}\\right] \\in PSL_2(\\Z/5) \\mid \\lambda \\in (\\Z/5)^X \\right\\}$ has order $4$ (note that $\\lambda$ and $-\\lambda$ represent the same equivalence class as we are in $PSL$, so there are 2 of each kind), so is a Sylow $2-$subgroup of $PSL_2(\\Z/5)$. Any element of order $2$ or $4$ is conjugate to an element in $H$. We'll show that $\\psi(H) = \\{+1\\}$.\n\n$H$ is generated by $\\left[\\begin{matrix}\n2 & 0\\\\\n0 & -2\n\\end{matrix}\\right],\\left[\\begin{matrix}\n0 & 1\\\\\n-1 & 0\n\\end{matrix}\\right]$. Now consider\n\\begin{equation*}\n\\begin{aligned}\n\\left[\\begin{matrix}\n2 & 0\\\\\n0 & -2\n\\end{matrix}\\right]\n\\end{aligned}\n\\end{equation*} acting on $(\\Z/5)_\\infty$. This sends\n\n\\includegraphics[scale=0.4]{GRM_01}\n\nso is an even permutation. Then\n\\begin{equation*}\n\\begin{aligned}\n\\left[\\begin{matrix}\n0 & 1\\\\\n-1 & 0\n\\end{matrix}\\right]\n\\end{aligned}\n\\end{equation*} \nsends\n\n\\includegraphics[scale=0.4]{GRM_02}\n\nis also even. So they are both in $A_6$.\n\n\\end{proof}\n\\end{eg}\n\n\\newpage\n\n\\section{Rings}\n\nIn this course we only consider commutative rings with a multiplicative identity. Many of the things we are going to prove in this course will not hold without these two properties.\n\n\\subsection{Definitions}\n\\begin{defi}\nA \\emph{ring} is a quintuple $(R,+,\\cdot,0_R,1_R)$ s.t. \\\\\n(R1) $(R,+,0_R)$ is an abelian group;\\\\\n(R2) The operation $- \\cdot -$: $R \\times R \\to R$ is associative, and satisfies $1_R \\cdot r = r = r \\cdot 1_R$.\\\\\n(R3) $r \\cdot (r_1+r_2) = r \\cdot r_1 + r \\cdot r_2$, and $(r_1+r_2) \\cdot r = r_1 \\cdot r + r_2 \\cdot r$ (Distributivity).\n\nA ring is \\emph{commutative} if in addition $a \\cdot b = b \\cdot a$ $\\forall a,b \\in R$.\n\nFrom now on every ring we discuss will by default be commutative and has a multiplicative identity.\n\\end{defi}\n\n\\begin{defi}\nIf $(R,+,\\cdot,0_R,1_R)$ is a ring ans $S \\subset R$ is a subset, then it is called a \\emph{subring} if $0_R,1_R \\in S$ and $+,\\cdot$ make $S$ into a ring in its own right.\n\\end{defi}\n\n\\begin{eg}\nWe have $\\Z \\leq \\Q \\leq \\R \\leq \\C$ as rings with the usual $0,1,+,\\cdot$.\n\\end{eg}\n\n\\begin{eg}\n$\\Z[i] = \\{a+ib\\in \\C \\mid a,b \\in \\Z\\} \\leq \\C$ is the subring called \\emph{Gaussian integers}. \n\\end{eg}\n\n\\begin{eg}\n$\\Q[\\sqrt{2}] = \\{ a+\\sqrt{2} \\cdot b \\in \\R \\mid a,b \\in \\Q \\} \\leq \\R$ is a subring.\n\\end{eg}\n\n\\begin{defi}\nAn element $r \\in R$ is a \\emph{unit} if there is a $s \\in R$ s.t. $sr = 1_R$.\n\nNote that this depends not only on the element but only on which ring we are talking about: $2 \\in \\Z$ is not a unit, but $2 \\in \\Q$ is.\n\nIf every $r \\in R$ with $r \\neq 0_R$ is a unit, then $R$ is called a field.\n\\end{defi}\n\n\\begin{notation}\nIf $x \\in R$, write $-x \\in R$ for the inverse of $x$ in $(R,+,0_R)$. We will write $y-x = y+(-x)$.\n\\end{notation}\n\n\\begin{eg}\n$0_R+0_R = 0_R$, so $r \\cdot (0_R+0_R) = r\\cdot 0_R$, i.e. $r\\cdot 0_R + r\\cdot 0_R = r\\cdot 0_R$, so $r\\cdot 0_R = 0_R$. So if $R \\neq \\{0\\}$, then $0_R \\neq 1_R$, and $0_R$ is never a unit.\n\nHowever, $(\\{0\\},+,\\cdot,0,0)$ \\emph{is} a valid ring.\n\\end{eg}\n\n\\begin{eg}\nIf $R,S$ are rings, then $R \\times S$ has the state of a ring via componentwise addition and multiplication, with $1=(1_R,1_S)$, $0 =(0_R,0_S$.\n\nNote that in this ring, $e_1 = (1_R,0_S)$, $e_2 = (0_R,1_S$, then $e_1^2 =e_1$ and $e_2^2 = e_2$, and $e_1+e_2 = 1$.\n\\end{eg}\n\n\\begin{eg}\nLet $R$ be a ring. A \\emph{polynomial} $f$ over $R$ is an expression\n\\begin{equation*}\n\\begin{aligned}\nf=a_0+a_1X+a_2X^2 + ... + a_n X^n\n\\end{aligned}\n\\end{equation*}\nwith $a_i \\in R$. $X^i$ is just a symbol.\n\nWe will consider $f$ and \n\\begin{equation*}\n\\begin{aligned}\na_0+a_1 X +... + a_n X^n + 0_R \\cdot X^{n+1}\n\\end{aligned}\n\\end{equation*}\nas equal. The \\emph{degree} of $f$ is the largest $n$ s.t. $a_n \\neq 0$.\n\nIf in addition, $a_n = 1_R$, then we say $f$ is \\emph{monic}.\n\nWe write $R[X]$ for the set of all polynomials over $R$.\n\nIf $g=b_0+...+b_m X^m$, then we define addition and multiplication by the usual way:\n\\begin{equation*}\n\\begin{aligned}\nf+g &= \\sum_{i=0} (a_i+b_i) X^i\\\\\nf\\cdot g &= \\sum_i \\left(\\sum_0^i a_jb_{i-j}\\right)X^i\n\\end{aligned}\n\\end{equation*}\n\nNow consider $R$ as a subring of $R[X]$, given by the polynomials of degree $0$. In particular, $1_R \\in R$ gives the multiplicative identity element of $R[X]$.\n\\end{eg}\n\n\\begin{eg}\nWrite $R[[x]]$ for the ring of \\emph{formal power series}, i.e.\n\\begin{equation*}\n\\begin{aligned}\nf =a_0+a_1 X + a_2 X^2 + ...\n\\end{aligned}\n\\end{equation*}\nwith the same addition and multiplication.\n\nConsider $\\Z/2[X]$ and an element $f = X+X^2$. Then\n\\begin{equation*}\n\\begin{aligned}\nf(0)=0+0=0,\nf(1) = 1+1=0\n\\end{aligned}\n\\end{equation*}\nBut definitely $f \\neq 0$. So we see the reason why we don't think $f$ as functions despite that they do give functions. They are just elements in a particular ring.\n\\end{eg}\n\n\\begin{eg}\nThe \\emph{Laurent polynomials} $R[X,X^{-1}]$ is the set of \n\\begin{equation*}\n\\begin{aligned}\nf=\\sum_{i \\in \\Z} a_i X^i\n\\end{aligned}\n\\end{equation*}\ns.t. only finitely many $a_i$ are non-zero.\n\\end{eg}\n\n\\begin{eg}\nThe ring of \\emph{Laurent series} are those expressions\n\\begin{equation*}\n\\begin{aligned}\nf = \\sum_{i\\in \\Z} a_i X_i\n\\end{aligned}\n\\end{equation*}\nwith only finitely many $i<0$ s.t. $a_i \\neq 0$ (i.e. formal power series in the positive part and polynomial in the negative part). This is to make the sum in each coefficient a finite sum, as we didn't even define infinite sums in rings.\n\\end{eg}\n\n\\begin{eg}\nIf $R$ is a ring and $X$ is a set, the set $R^X$ of all functions $f: X \\to \\R$ is a ring, with operations\n\\begin{equation*}\n\\begin{aligned}\n(f+g) (X) &= f(X) + g(X),\\\\\n(fg) (X) &= f(X) \\cdot g(X).\n\\end{aligned}\n\\end{equation*}\nThe multiplicative identity element is the function $1(X) = 1_R$ for all $X$, and the same for the zero element.\n\nObserve $\\R^\\R \\supsetneq$ set of continuous $f:\\R \\to \\R$ $\\supset$ polynomials $\\R \\to \\R$ = $\\R[X]$. So $\\R[X] \\subsetneq \\R^\\R$.\n\\end{eg}\n\n\\subsection{Homomorphisms, ideals, quotients, and isomorphisms}\n\\begin{defi}\nA function $\\phi: R \\to S$ between rings is a \\emph{homomorphism} if\\\\\n(H1) $\\phi(r_1+r_2) = \\phi(r_1)+\\phi(r_2)$, i.e. $\\phi$ is a group homomorphism between the additive groups of $R$ and $S$;\\\\\n(H2) $\\phi(r_1r_2) \\phi(r_1) \\phi(r_2)$;\\\\\n(H3) $\\phi(1_R) = 1_S$.\n\nIf in addition, $\\phi$ is a bijection, then we say it is an \\emph{isomorphism}.\n\nThe \\emph{kernel} of $\\phi:R \\to S$ is\n\\begin{equation*}\n\\begin{aligned}\n\\ker(\\phi) = \\{r \\in R | \\phi(r) = 0\\}\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{lemma}\n$\\phi:R \\to S$ is injective if and only if $\\ker(\\phi) = \\{0\\}$.\n\\begin{proof}\nNote that $\\phi:(R,+,0_R) \\to (S,+,0_S)$ is a group homomorphism, and its kernel as a group homomorphism is also $\\ker(\\phi)$. So by theorems in groups we get the desired result.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}\nA subset $I \\subset R$ is an \\emph{ideal}, written $I \\triangleleft R$, if\\\\\n(I1) $I$ is a subgroup of $(R,+)$;\\\\\n(I2) If $x \\in I$, $r \\in R$, then $x \\cdot r \\in I$ (strong multiplicative closure).\n\nWe say $I \\triangleleft R$ is proper if $I \\neq R$.\n\\end{defi}\n\n\\begin{lemma}\nIf $\\phi:R \\to S$ is a homomorphism, then $\\ker(\\phi) \\triangleleft R$.\n\\begin{proof}\n(I1) holds for $\\ker(\\phi)$ since $\\phi$ is a group homomorphism. \n\nNow let $x \\in \\ker(\\phi)$, $r \\in R$. Then\n\\begin{equation*}\n\\begin{aligned}\n\\phi(r \\cdot x) = \\phi(r) \\cdot \\phi(x) = \\phi(r) \\cdot 0_S = 0_S\n\\end{aligned}\n\\end{equation*}\nSo $r \\cdot x \\in \\ker(\\phi)$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{eg}\nIf $I \\triangleleft R$ and $1_R \\in I$, then for any $r \\in R$, we have\n\\begin{equation*}\n\\begin{aligned}\nr = r \\cdot 1 \\in I,\n\\end{aligned}\n\\end{equation*}\nso $I=R$. In short, proper ideals never include $1$, so are never subrings.\n\\end{eg}\n\n\\begin{eg}\nIf $R$ is a field, then $\\{0\\}$ and $R$ are the only ideals. This is reversible: If $\\{0\\}$ and $R$ are the only ideals, then $R$ is a field.\n\\end{eg}\n\n\\begin{eg}\nIn the ring $\\Z$, all ideals are of the form $n\\Z$ for some $n \\in \\Z$, where\n\\begin{equation*}\n\\begin{aligned}\nn\\Z =\\{...,-2n,-n,0,n,2n,...\\}\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\n$n \\Z$ is certainly an ideal. Let $I \\triangleleft \\Z$ be an ideal. Let $n \\in I$ be the smallest positive element. Then $n \\Z \\subset I$. If this is not an equality, choose $m \\in I\\backslash n\\Z$. Then $m=n \\cdot q + r$ for some $0\\leq r \\leq n-1$. If $r=0$ then $m \\in I$, a contradiction. So\n\\begin{equation*}\n\\begin{aligned}\nr=m-n\\cdot q < n\n\\end{aligned}\n\\end{equation*}\nis in the ideal $I$. Contradiction.\n\\end{proof}\n\\end{eg}\n\n\\begin{defi}\nFor an element $a \\in R$, write\n\\begin{equation*}\n\\begin{aligned}\n(a) = \\left\\{a \\cdot r | r \\in R\\right\\}\n\\end{aligned}\n\\end{equation*}\nthe \\emph{ideal generated by $a$}. More generally, for a list $a_1,...,a_s$, write\n\\begin{equation*}\n\\begin{aligned}\n(a_1,...,a_s) = \\left\\{\\sum_i a_i r_i | r_i \\in R\\right\\}\n\\end{aligned}\n\\end{equation*}\nwhich somewhat resembles the linear combinations in a vector space.\n\nEven more generally, if $A \\subseteq R$ is a subset, then the ideal generated by $A$ is\n\\begin{equation*}\n\\begin{aligned}\n\\left(A\\right) = \\left\\{\\sum_{a \\in A} a \\cdot r_a | r_a \\in R, \\text{only finitely many }r_a \\neq 0\\right\\}.\n\\end{aligned}\n\\end{equation*}\nsince we have no definition of infinite sums in rings.\n\nIf an ideal $I\\triangleleft R$ is of the form $(a)$, then we say that $I$ is a \\emph{principal ideal}.\n\\end{defi}\n\n\\begin{eg}\nIn $\\Z$ we have\n\\begin{equation*}\n\\begin{aligned}\nn\\Z = (n) \\triangleleft \\Z\n\\end{aligned}\n\\end{equation*}\nis principal.\n\\end{eg}\n\n\\begin{eg}\nIn $\\C[X]$, the polynomials with constant coefficient $0$ forms an ideal, which is just $(X)$ (check). This is also principal.\n\\end{eg}\n\n\\begin{prop}\nLet $I \\triangleleft R$ be an ideal. Define the \\emph{quotient ring} $R/I$ to be the set of cosets $r+I$ (i.e. $(R,+,0)/$normal subgroup $I$), with addition and multiplication given by\\\\\n$\\bullet$ $(r_1+I)+(r_2+I) = r_1+r_2+I$,\\\\\n$\\bullet$ $(r_1+I)+(r_2+I) = r_1r_2 + I$,\\\\\nand $0_{R/I} =0_R+I$, $1_{R/I} = 1_R+I$. \n\nThis is a ring, and the quotient map $R \\to R/I$ by $r \\to r+I$ is a ring homomorphism.\n\\begin{proof}\nWe already know that $(R/I,+,0)$ is an abelian group. And addition as described above is well-defined. If $r_1+I=r'_1+I$, $r_2+I = r'_2+I$, then $r'_1-r_1 =a_1 \\in I$, $r'_2-r_2 = a_2 \\in I$. So\n\\begin{equation*}\n\\begin{aligned}\nr'_1r'_2 = (r_1+a_1)(r_2+a_2)=r_1r_2+r_1a_2+a_1r_2+a_1a_2 = r_1r_2 + a\n\\end{aligned}\n\\end{equation*}\nfor some $a \\in I$, i.e. $r'_1r'_2 + I = r_1 r_2 + I$. So multiplication is well-defined. The ring axioms for $R/I$ then follow from those of $R$.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\n$n\\Z \\triangleleft \\Z$, so have a ring $\\Z/n\\Z$. This has elements $0+n\\Z,1+n\\Z,2+n\\Z,...,(n-1)+n\\Z$, and addition and multiplication are modular arithmetic $\\pmod n$.\n\\end{eg}\n\n\\begin{eg}\n$(X) \\triangleleft \\C[X]$, so we have a ring $\\C[X] / (X)$. Then\n\\begin{equation*}\n\\begin{aligned}\na_0+a_1X+a_2X^2+...+a_nX^n + (X) = a_0 + (X).\n\\end{aligned}\n\\end{equation*}\nIf $a_0+(X) = b_0+(X)$, then $a_0-b_0 \\in (X)$. So $X | a_0-b_0$, i.e. $a_0=b_0$.\n\nSo consider\n\\begin{equation*}\n\\begin{aligned}\n\\phi: \\C[X] / (X) &\\longleftarrow &\\C\\\\\na+(X) & \\longleftarrow & a\n\\end{aligned}\n\\end{equation*}\nis surjective and injective. So $\\phi$ is a bijection.\n\nObserve that $\\phi$ is a ring homomorphism. The inverse is $f+(X) \\to f(0)$.\n\\end{eg}\n\n\\begin{prop} (Euclidean algorithm for polynomials)\\\\\nLet $F$ be a field and $f,g \\in F[X]$, then we may write\n\\begin{equation*}\n\\begin{aligned}\nf = g\\cdot q + r\n\\end{aligned}\n\\end{equation*}\nwith $\\deg(r) < \\deg(g)$.\n\\begin{proof}\nLet\\\\\n$\\deg(f) = n$, so $f=a_0+a_1X + ... + a_nX^n$ with $a_n \\neq 0$;\\\\\n$\\deg(g) = m$, so $g=b_0+b_1X + ... + b_mX^m$ with $b_m \\neq 0$.\n\nIf $n<m$, let $q=0$ and $r=f$.\n\nSuppose $n \\geq m$, and proceed by induction on $n$, Let\n\\begin{equation*}\n\\begin{aligned}\nf_1 = f-g \\cdot X^{n-m} \\cdot a_n b_m^{-1}\n\\end{aligned}\n\\end{equation*}\nwe can do this because $F$ is a field, so $b_m$ has an inverse.\n\nThis has degree smaller than $n$.\n\nIf $n=m$, then $f = gX^{n-m}a_nb_m^{-1} + f_1$ where $\\deg(f_1)<n=m$.\n\nIf $n>m$, by induction on degree, we have $f_1 = g\\cdot q_1 + r$ with $\\deg(r) < \\deg(g)$. So $f=gX^{n-m}a_n+b_m^{-1} + g\\cdot q_1+r = g (X^{n-m}b_m^{-1} + q_1) +r$ as required.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\nConsider $(X^2+1) \\triangleleft \\R[X]$, and $R=\\R[X]/(X^2+1)$. Elements of $R$ are of the form $f+(X^2+1)$. By Euclidean algorithm we have $f=q\\cdot (X^2+1) + r$ with $\\deg(r) < 2$. So $f+(X^2+1) = r + (X^2+1)$. So every coset is represented by a polynomial $r$ of degree at most $1$.\n\nIf $a_1+b_1X + (X^2+1) = a_2+b_2X + (X^2+1)$, then\n\\begin{equation*}\n\\begin{aligned}\nX^2+1 | (a_1+b_1X)-(a_2+b_2X)\n\\end{aligned}\n\\end{equation*}\nBut by degree we know that $(a_1+b_1X) - (a_2+b_2X) = 0$. So take\n\\begin{equation*}\n\\begin{aligned}\n\\phi:\\R[x]/(X^2+1) &\\to \\C\\\\\na+bX+(X^2+1) &\\to a+bi\n\\end{aligned}\n\\end{equation*}\nThis is a bijection. It sends addition to addition, and multiplication satisfies\n\\begin{equation*}\n\\begin{aligned}\n&\\phi((a+bX+(X^2+1)) \\cdot (c+dX+(X^2+1)))\\\\\n&=\\phi(ac+(bc+ad)X + bdX^2 + (X^2+1))\\\\\n&=\\phi(ac+(bc+ad)X + bd(-1) + bd(X^2+1) + (X^2+1))\\\\\n&=\\phi((ac-bd) + (bc+ad)X + (X^2+1))\\\\\n&=(ac-bd)+(bc+ad)i\\\\\n&=(a+ib)(c+id)\n\\end{aligned}\n\\end{equation*}\nSo $\\phi$ is a homomorphism. So $\\R[x] / (X^2+1) \\cong \\C$.\n\\end{eg}\n\nWe also have $\\Q[x]/(X^2-2) = \\Q[\\sqrt{2}] \\subseteq \\R$.\n\n\\begin{thm} (First isomorphism theorem)\\\\\nLet $\\phi:R \\to S$ be a ring homomorphism. Then $\\ker(\\phi) \\triangleleft R$, $\\im(\\phi) \\leq S$, and $R/\\ker(\\phi) \\cong \\im(\\phi)$ by $r+\\ker(\\phi) \\to \\phi(r)$.\n\\end{thm}\n\n\\begin{thm} (Second isomorphism theorem)\\\\\nLet $R \\subset S$, $J \\triangleleft S$. Then $R\\cap J \\triangleleft R$, $(R+J)/J = \\{r+J | r \\in R\\} \\leq S/J$, and $R / R\\cap J = (R+J)/J$.\n\\end{thm}\n\n\\begin{thm} (Subring correspondence)\\\\\nWe have a bijection between subrings of $R/I$ and subrings of $R$ containing $I$ by:\\\\\n$S/I \\leq R/I \\leftarrow I \\triangleleft S \\leq R$\\\\\n$L \\leq R/I \\rightarrow \\{r\\in R | r+I \\in L\\}$, and the same map gievs a bijection between ideals of $R/I$ and ideals of $R$ containing $I$ by\n\\begin{equation*}\n\\begin{aligned}\n\\end{aligned}\nJ/I \\triangleleft R/I \\leftrightarrow I \\triangleleft J \\triangleleft R.\n\\end{equation*}\n\\end{thm}\n\n\\begin{thm} (Third isomorphism theorem)\\\\\nLet $I,J \\triangleleft R$, $I \\subset J$. Then $J/I \\triangleleft R/I$ and $(R/I)/(J/I) \\cong R/J$.\n\\end{thm}\n\n\\begin{eg}\nConsider the homomorphism $\\phi: \\R[X] \\to \\C$ by substituting in $X=i$, which is onto. We know\n\\begin{equation*}\n\\begin{aligned}\n\\ker(\\phi) = \\{f \\in \\R[x] | f(i) = 0\\} = (X^2+1)\n\\end{aligned}\n\\end{equation*}\nbecause real polynomials with $i$ as a root also have $-i$ as a root. So are divisible by $(X-i)(X+i) = (X^2+1)$. Then by first isomorphism theorem,\n\\begin{equation*}\n\\begin{aligned}\n\\R[X] / (X^2+1) \\cong \\C\n\\end{aligned}\n\\end{equation*}\n(Compare with the previous proof).\n\\end{eg}\n\n\\begin{defi}\nFor any ring $R$, there is a unique homomorphism\n\\begin{equation*}\n\\begin{aligned}\n\\iota:\\Z &\\to \\R\\\\\n1 &\\to 1_R\\\\\nn>0 &\\to 1_R+1_R+...+1_R \\ (n \\text{ times})\\\\\nn<0 &\\to -(1_R+1_R+...+1_R)\\ (-n \\text{ times})\\\\\n\\end{aligned}\n\\end{equation*}\nNote that $\\ker(\\iota) \\triangleleft \\Z$, so $\\ker(i) = n\\Z$ for some $n \\geq 0$. This $n \\geq 0$ is called the \\emph{characteristic} of the ring $R$.\n\\end{defi}\n\n\\begin{eg}\n$\\Z \\leq \\Q \\leq \\R \\leq \\C$ all have characteristic $0$, while $\\Z/n$ has characteristic $n$.\n\\end{eg}\n\n\\subsection{Integral domains, field of fractions, maximal and prime ideal}\nOne thing to remember:\n\\begin{equation*}\n\\begin{aligned}\nField \\implies ED \\implies PID \\implies UFD \\implies ID.\n\\end{aligned}\n\\end{equation*}\n\nThe interesting bits start here.\n\n\\begin{defi}\nA non-zero ring $R$ is called an \\emph{integral domain (ID)} if for all $a,b \\in R$, $a \\cdot b = 0 \\implies a=0$ or $b=0$.\n\nWe call $x$ a \\emph{zero divisor} in $R$ if $x\\neq 0$ but $\\exists y \\neq 0$ s.t. $xy = 0$.\n\\end{defi}\n\n\\begin{eg}\nAll fields are integral domains. If $xy=0$ with $y \\neq 0$, then $xyy^{-1} = 0$ i.e. $x=0$.\n\nA subring of an integral domain is an integral domain, so $\\Z \\leq \\Q$ and $\\Z[i] \\leq \\C$ are integral domains.\n\\end{eg}\n\n\\begin{defi}\nA ring $R$ is a \\emph{principal ideal domain (PID)} if it is an integral domain and every ideal is principal.\n\\end{defi}\n\nFor example, $\\Z$ is a principal ideal domain.\n\n\\begin{lemma}\nA finite integral domain is a field.\n\\begin{proof}\nLet $a \\neq 0 \\in R$, and consider\n\\begin{equation*}\n\\begin{aligned}\na \\cdot -: R &\\to R\\\\\nb &\\to ab\n\\end{aligned}\n\\end{equation*}\nThis is a homomorphism of abelian groups and its kernel is $\\{b \\in R | ab=0\\} = \\{0\\}$. So $a\\cdot -$ is injective. But $R$ is finite. So $a \\cdot -$ is bijective. In particular, $\\exists b \\in R$ s.t. $ab=1$. So $R$ is a field.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma}\nLet $R$ be an integral domain, then $R[X]$ is also an integral domain.\n\\begin{proof}\nLet $f=\\sum_{i=0}^n a_i X^i$ and $a_n \\neq 0$, $g=\\sum_{i=0}^m b_i X^i$ and $b_m \\neq 0$ be non-zero polynomials. Then the largest power of $X$ in $fg$ is $X^{n+m}$ and its coefficient is $a_nb_m \\neq 0$ as $R$ is an ID. So $fg \\neq 0$.\n\\end{proof}\n\\end{lemma}\n\nIterating this, we have\n\\begin{equation*}\n\\begin{aligned}\nR[X_1,...,X_n] = (((R[X_1])[X_2])...[X_n])\n\\end{aligned}\n\\end{equation*}\nis an integral domain.\n\n\\begin{thm}\nLet $R$ be an ID. There is a \\emph{field of fractions} $F$ of $R$ with the following properties:\\\\\n(i) $F$ is a field;\\\\\n(ii) $R \\leq F$;\\\\\n(iii) every element of $F$ is of the form $a \\cdot b^{-1}$ for $a,b \\leq R \\leq F$.\n\\end{thm}\n\\begin{proof}\nConsider\n\\begin{equation*}\n\\begin{aligned}\nS=\\{(a,b)\\in R\\times R| b\\neq 0\\}\n\\end{aligned}\n\\end{equation*}\nwith the equivalence relation $(a,b) \\sim (c,d) \\iff ad=bc \\in R$. This is reflexive and symmetric. For transitivity, if \n\\begin{equation*}\n\\begin{aligned}\n(c,d) \\sim (e,f)\n\\end{aligned}\n\\end{equation*}\nThen $(ad)f = (bc)f = b(cf) = b(ed) \\implies d(af-be) =0 $. But $d \\neq 0$. So $af-be = 0$.\n\nLet $F = S/\\sim$. Write $[(a,b)] = \\frac{a}{b}$ and define\n\\begin{equation*}\n\\begin{aligned}\n\\frac{a}{b} + \\frac{c}{d} = \\frac{ad+bc}{bd},\\\\\n\\frac{a}{b} \\cdot \\frac{c}{d} = \\frac{ab}{cd}.\n\\end{aligned}\n\\end{equation*}\nand $0=\\frac{0}{1}$, $1=\\frac{1}{1}$.\n\nIf $\\frac{a}{b} \\neq 0$ then $a \\cdot 1 \\neq 0 \\cdot b$, i.e. $a \\neq 0$. Then $\\frac{b}{a} \\in F$, so $\\frac{a}{b} \\cdot \\frac{b}{a} = \\frac{1}{1}$. So $\\frac{a}{b}$ has an inverse, so $F$ is a field.\n\nWe make $R \\leq F$ by $\\phi:R \\to F$ by $r \\to \\frac{r}{1}$.\n\\end{proof}\n\n\\begin{eg}\nThe field of fractions of $\\Z$ is $\\Q$, and that of $\\C[z]$ is the rational polynomial fractions in $z$.\n\\end{eg}\n\nNote: the ring $\\{0\\}$ is \\emph{not} afield.\n\n\\begin{lemma}\nA (non-zero) ring is a field iff its only ideals are $\\{0\\}$ and $R$.\n\\begin{proof}\nIf $I \\triangleleft R$ is a non-zero ideal, then it contains $a \\neq 0$. But an ideal containing a unit must be the whole ring. On the other hand, let $x \\neq 0 \\in R$, Then $(x)$ must be $R$, as it is \\emph{not} the zero ideal. So $\\exists y \\in R$ s.t. $xy = 1_R$. So $X$ is a unit.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}\nAn ideal $I \\triangleleft R$ is \\emph{maximal} if there is no proper ideal which properly contains $I$.\n\\end{defi}\n\n\\begin{lemma}\nAn ideal $I$ is maximal iff $R/I$ is a field.\n\\begin{proof}\n$R/I$ is a field $\\iff$ $I/I$ and $R/I$ are the only ideals in $R/I$ $\\iff$ $I,R\\ triangleleft$ are the only ideals containing $I$ by ideal correspondence.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}\nAn ideal $I \\triangleleft R$ is \\emph{prime} if $I$ is proper, and if $a,b \\in R$ are s.t. $a \\cdot b \\in I$, then $a\\in I$ or $b \\in I$.\n\\end{defi}\n\n\\begin{eg}\nThe ideal $n\\Z \\triangleleft \\Z$ is prime if and only if $n$ is zero and a prime number: if $p$ is prime and $a \\cdot b \\in p\\Z$, then $p | a \\cdot b$, so $p|a$ or $p|b$, i.e. $a \\in p\\Z$ or $b \\in p\\Z$.\n\nConversely, if $n=uv$ is composite, $u\\cdot v \\in n\\Z$ but $u,v \\not\\in n\\Z$.\n\\end{eg}\n\n\\begin{lemma}\n$I \\triangleleft R$ is prime iff $R/I$ is an integral domain.\\\\\nNote that this shows that every maximal ideal is prime since fields are integral domains.\n\\end{lemma}\n\\begin{proof}\nSuppose $I$ is prime. Let $a+I,b+I \\in R/I$ be s.t. $(a+I)(b+I) = 0$, i.e. $ab+I=0$, so $ab \\in I$. But $I$ is prime, so $a \\in I$ or $b \\in I$. So $a+I = 0+I$ or $b+I = 0+I$ is the zero element in $R/I$. So $R/I$ is an integral domain.\n\nFor the other direction, suppose $R/I$ is an integral domain. Let $ab \\in I$. Then $ab+I = 0$, so $(a+I)(b+I)=0$. So $a+I = 0+I$ or $b+I = 0+I$, i.e. $a \\in I$ or $b \\in I$.\n\\end{proof}\n\n\\begin{lemma}\nIf $R$ is an integral domain, then its characteristic is $0$ or a prime number.\n\\begin{proof}\nLet $\\iota:\\Z \\to R$ with $1 \\to 1_R$. Consider $\\ker(\\iota) = n\\Z$. By 1st isomorphism theorem, $\\Z / n\\Z \\cong \\im(\\phi) \\leq R$ as a subring of an integral domain is again an integral domain, $Z/n\\Z$ is an integral domain, so $n\\Z \\triangleleft \\Z$ is prime. So $n$ is zero or a prime number.\n\\end{proof}\n\\end{lemma}\n\n\\subsection{Factorisation in integral domains}\nSuppose throughout this section that $R$ is an integral domain.\\\\\n\\begin{defi}\n1) An element $a\\in R$ is a unit if there is $b\\in R$ s.t. $ab=1$. Equivalently, $\\left(a\\right)=R$.\\\\\n2) $a$ divides $b$ if there is $c\\in R$ s.t. $b=a\\cdot c$. Equivalently, $\\left(b\\right) \\subset \\left(a\\right)$.\\\\\n3) $a,b\\in R$ are associates if $a=b\\cdot c$ with $c$ a unit. Equivalently, $\\left(a\\right)=\\left(b\\right)$, or $a|b$ and $b|a$.\\\\\n4) $a\\in R$ is irreducible if it is not 0, not a unit, and if $a=x\\cdot y$ then $x$ or $y$ is a unit.\\\\\n5) $a\\in R$ is prime if it is not 0, not a unit, and when $a|x\\cdot y$ then $a|x$ or $a|y$.\\\\\n\nNote that $2\\in \\Z$ is prime, but $2\\in \\Q$ is not.\\\\\n$2x\\in \\Q[x]$ is irreducible, $2x\\in \\Z[x]$ is not irreducible.\n\\end{defi}\n\n\\begin{lemma}\n$\\left(a\\right)$ is a prime ideal in $R \\iff r=0$ or $r$ is prime in $R$.\n\\begin{proof}\n1) let $\\left(r\\right)$ be a prime, $r\\neq 0$. As $\\left(r\\right) \\neq R$, $r$ is not a unit.\\\\\nSuppose $r|a\\cdot b$. Then $a\\cdot b\\in \\left(r\\right)$, but $\\left(r\\right)$ is prime. So $a\\in\\left(r\\right)$ or $b\\in\\left(r\\right)$. So $r|a$ or $r|b$. So $r$ is prime in $R$.\\\\\n2) if $r=0$ then $(0)$ is a prime ideal since $R$ is an integral domain.\\\\\nNow let $r\\neq 0$ and be prime in $R$.\\\\\nLet $ab\\in\\left(r\\right)$. Then $r|ab$. So $r|a$ or $r|b$. So $a\\in\\left(r\\right)$ or $b\\in\\left(r\\right)$. So $\\left(r\\right)$ is a prime ideal in $R$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma}\nif $r\\in R$ is prime, then it is irreducible.\n\\begin{proof}\nlet $r\\in R$ be prime, and suppose $r=a\\cdot b$.\\\\\nAs $r$ is prime, $r|a$ or $r|b$.\\\\\nSuppose $r|a$. So $a=r\\cdot c$. Then $r=r\\cdot c\\cdot b$.\\\\\nAs $R$ is an integral domain, \\\\\n$r\\left(c\\cdot b-1\\right)=0 \\implies c\\cdot b=1$.\\\\\nSo $b$ is a unit. So $r$ is irreducible.\n\\end{proof}\n\\end{lemma}\n\n\\begin{eg}\nLet $R=\\Z[\\sqrt{-5}]=\\left\\{a+b\\sqrt{-5}|a\\cdot b\\in\\Z\\right\\}\\subseteq \\C$.\\\\\n$\\C$ is a field and $R$ is a subring, so $R$ is an integral domain.\\\\\nConsider the \"norm\":\\\\\n\\begin{equation*}\n\\begin{aligned}\nN:R &\\to \\Z \\geq 0\\\\\na+b\\sqrt{-5} &\\to a^2+5b^2\\\\\nz &\\to z\\overline{z}=|z|^2.\n\\end{aligned}\n\\end{equation*}\nThis satisfies $N\\left(zw\\right)=N\\left(z\\right)\\cdot N\\left(w\\right)$.\\\\\nIf $r\\cdot s=1$ then $1=N\\left(1\\right)=N\\left(r\\cdot s\\right)=N\\left(r\\right)\\cdot N\\left(s\\right)$.\\\\\nSo $N\\left(s\\right)=N\\left(r\\right)=1$. So any unit has normal 1.\\\\\ni.e. $a^2+5b^2=1$. Then $a=\\pm 1, b=0$: only $\\pm 1\\in R$ are units.\\\\\n\\textbf{Claim}: $2\\in R$ is irreducible:\\\\\nSuppose $2=ab$. Then $4=N\\left(a\\right) N\\left(b\\right)$.\\\\\nNote that nothing in $R$ has norm 2. So WLOG $N\\left(a\\right)=1,N\\left(b\\right)=4$. So $a$ is a unit. So 2 is irreducible.\\\\\nSimilarly $3,1+\\sqrt{-5},1-\\sqrt{-5}$ are irreducible (no $r$ with $N\\left(r\\right)=3$).\\\\\nNote that $\\left(1+\\sqrt{-5}\\right)\\left(1-\\sqrt{-5}\\right)=6=2\\cdot 3$.\\\\\n\\textbf{Claim}: 2 does not divide $1 \\pm \\sqrt{-5} \\implies 2$ is not prime:\\\\\nif $2|1+\\sqrt{-5}$, then $N\\left(2\\right)|N\\left(1+\\sqrt{-5}\\right)$, i.e. $4|6$, contradiction.\\\\\n\\textbf{Lessons}: 1) irreducible doesn't imply prime in general.\\\\\n2) $\\left(1+\\sqrt{-5}\\right)\\left(1-\\sqrt{-5}\\right) = 2\\cdot 3$. So factorisation into irreducibles might not be unique.\n\\end{eg}\n\n\\begin{defi}\nan integral domain $R$ is a \\emph{Euclidean domain}(ED) if there is a function $\\varphi: R \\backslash \\left\\{0\\right\\}\\to \\Z\\geq 0$, a \"Euclidean function\", such that:\\\\\n1) $\\varphi \\left(a\\cdot b\\right) \\geq \\varphi\\left(b\\right)$ for all $a,b\\neq 0$;\\\\\n2) if $a,b\\in R$ with $b\\neq 0$, there are $q,r\\in R$ s.t. $a=b\\cdot q+r$, such that $r=0$ or $\\varphi\\left(r\\right)<\\varphi\\left(b\\right)$ ($r$ is \"strictly smaller than\" $b$).\n\\end{defi}\n\n\\begin{eg}\n1) $\\Z$ is a Euclidean domain with $\\varphi\\left(n\\right)=|n|$.\\\\\n2) $F[x]$ with $F$ a field is a Euclidean domain with $\\varphi\\left(f\\right)=\\deg\\left(f\\right)$.\\\\\n3) $\\Z[i]=R$ is Euclidean domain, with $\\varphi\\left(z\\right)=N\\left(z\\right)=|z|^2=z\\overline{z}$:\\\\\n\ti) $\\varphi\\left(zw\\right)=\\varphi\\left(z\\right)\\varphi\\left(w\\right) \\geq \\varphi\\left(z\\right)$, as $\\varphi\\left(w\\right)\\in \\Z^+$ for $w\\neq 0$;\\\\\n\tii) let $a,b\\in\\Z[i]$. Consider $\\frac{a}{b}\\in\\C$.\\\\\n\t\tWe know that $\\exists q\\in\\Z[i]$ s.t. $|\\frac{a}{b}-q|<1$,i.e. $\\frac{a}{b}=q+c$ with $|c|<1$.\\\\\n\t\tThen take $r=b\\cdot c$, so $a=b\\cdot q + b\\cdot c = b\\cdot q+r$.\\\\\n\t\t$r=a-bq$, so $r$ is in the ring $\\Z[i]$; and $\\varphi\\left(r\\right)=N\\left(bc\\right)=N\\left(b\\right)N\\left(c\\right)<N\\left(b\\right)=\\varphi\\left(b\\right)$ since $N\\left(c\\right)<1$.\n\\end{eg}\n\n\\begin{prop} (ED $\\implies$ PID)\\\\\nif $R$ is a Euclidean domain, then it is a principal ideal domain.\n\\begin{proof}\nLet $R$ have Euclidean function $\\varphi:R\\backslash\\left\\{0\\right\\}\\to\\Z\\geq 0$. Let $I\\triangleleft R$ be non-zero. Let $b\\in I\\backslash\\left\\{0\\right\\}$ be an element with $\\varphi\\left(b\\right)$ minimal.\\\\\nThen for $a\\in I$, write $a=bq+r$ with $r=0$, or $\\varphi\\left(r\\right)<\\varphi\\left(b\\right)$. But $r=a-bq\\in I$, so we can't have $\\varphi\\left(r\\right)<\\varphi\\left(b\\right)$. So $r=0$.\\\\\nThus $a\\in\\left(b\\right)$. Since $a$ is arbitrary, $I \\subset \\left(b\\right)$. But $\\left(b\\right)\\in I$ as well, so $I=\\left(b\\right)$. So R is a principal ideal domain.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\n$\\Z$,$F[X]$($F$ field) are Principal ideal domains.\\\\\n$\\Z[i]$ is a PID.\nIn $\\Z[X]$, $\\left(2,x\\right)\\triangleleft \\Z[X]$ is not a principal ideal.\\\\\nOtherwise suppose $\\left(2,x\\right)=\\left(f\\right)$, then $2=f\\cdot g$ for some $g$. Then $f$ has to have degree zero, so a constant, so $f\\pm 1 or \\pm 2$.\\\\\nIf $f=\\pm 1$ a unit, then $\\left(f\\right)=\\Z[x]$, but $1\\notin \\left(2,x\\right)$. Contradiction.\nIf $f=\\pm 2$, $x\\in \\left(2,x\\right)=\\left(f\\right)$ so $\\pm 2 | x$, a contradiction.\n\\end{eg}\n\n\\begin{eg}\nLet $A\\in M_{n\\times n} \\left(F\\right)$ be an $n\\times n$ matrix over a field $F$.\\\\\n$I=\\left\\{f\\in F[X]|f\\left(A\\right)=0\\right\\}$.\\\\\nIf $f\\cdot g\\in I$,$\\left(f+g\\right)\\left(A\\right)=f\\left(A\\right)+g\\left(A\\right)=0+0=0$.\\\\\nIf $f\\in I, g\\in F[X]$ then $\\left(f\\cdot g\\right)\\left(A\\right)=f\\left(A\\right) \\cdot g\\left(A\\right)=0$\\\\\nSo $I$ is an ideal.\\\\\nSo $F[X]$ is a PID, have $I=\\left(m\\right)$ for some $m\\in F[X]$.\\\\\nSuppose $f\\in F[X]$ s.t. $f\\left(A\\right)=0$. Then $f\\in I$ so $f=m\\cdot g$. So $m$ is the minimal polynomial of $A$.\n\\end{eg}\n\n\\begin{defi}\nAn integral domain is a unique factorization domain (UFD) if:\\\\\n1) every non-unit may be written as a product of irreducible elements;\\\\\n2) if $p_{1}p_{2}...p_{n}=q_{1}q_{2}...q_{m}$ with $p_{i},q_{i}$ irreducible, then $n=m$, and they can be reordered such that $p_{i}$ is an associate of $q_{i}$. (they generate the same ideal)\\\\\n\\end{defi}\n\nGoal: want to show that PID $\\implies$ UFD.\\\\\n\n\\begin{lemma}\nLet $R$ be a PID. If $p\\in R$ is irreducible, then it is prime.\\\\\n(prime $\\implies$ irreducible in any integral domain)\n\\begin{proof}\nLet $p\\in R$ be irreducible. Suppose $p|a\\cdot b$. Suppose $p \\nmid a$.\\\\\nConsider the ideal $\\left(p,a\\right)\\triangleleft R$, a PID so $\\left(p,a\\right)=\\left(d\\right)$ for some $d\\in \\R$.\\\\\nSo $d|p$,so $p=q_{1}\\cdot d$ for some $q_{1}$.\\\\\nWe must have $q_{1}$ a unit or $d$ a unit.\\\\\nIf $q_{1}$ a unit then $d=q_{1}^{-1}\\cdot p$ divides a. So $a=q_{1}\\cdot p\\cdot x$, contradiction.\\\\\nThus $d$ is a unit, so $\\left(p,a\\right)=\\left(d\\right)=R$.\\\\\nSo we have $1_{R}=v\\cdot p+s\\cdot a$ for some $r,s \\in R$.\\\\\nSo $b=r\\cdot p\\cdot b + s\\cdot a\\cdot b$. So $p|b$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma}\nLet $R$ be a PID, let $I_{1}\\in I_{2}\\in...$ be a chain of ideals. Then there is a $N\\in\\N$ s.t. $I_{n}=I_{n+1} \\forall n\\geq \\N$.(this is called the ascending chain condition(ACC), a ring satisfying this condition is called \\emph{Noetherian}.)\n\\begin{proof}\nLet $I=\\cup_{n\\geq 1}^\\infty I_{n}$, again an ideal. As $R$ is a PID, $I=\\left(a\\right)$ for some $a\\in R$. This $a\\in I=\\cup_{n=0}^\\infty I_{n}$, so $a\\in I_{n}$ for some $n$. \\\\\nThus $\\left(a\\right) \\leq I_{n} \\leq I = \\left(a\\right)$.\\\\\nSo they are all equal. So $I_{n}=\\left(a\\right)=I$, so $I_{n}=I_{N} \\forall n \\geq N$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{prop}\nPID $\\implies$ UFD.\n\\begin{proof}\n1) Need to show any $r\\in R$ is a product of irreducibles.\\\\\nLet $r\\in R$. If $r$ is irreducible then we are done.\\\\\nSuppose not, then $r=r_{1}s_{1}$ with $r_{1},s_{1}$ both non-units.\\\\\nIf both $r_{1},s_{1}$ are reducible then we are done. Suppose not, WLOG write $r_{1}=r_{2}s_{2}$ with $r_{2},s_{2}$ non-units.\\\\\nContinue in this way. If the process doesn't end, $\\left(r\\right) \\leq \\left(r_{1}\\right) \\leq ... \\leq \\left(r_{n}\\right) \\leq ...$.\\\\\nSo by the ACC property, $\\left(r_{n}\\right)=\\left(r_{n+1}\\right)=...$ for some $n$.\\\\\nSo $r_{n}=r_{n+1}\\cdot s_{n+1}$, and $\\left(r_{n}\\right)=\\left(r_{n+1}\\right) \\implies s_{n+1}$ is a unit. Contradiction.\\\\\n2) Let $p_{1}p_{2}...p_{n}=q_{1}q_{2}...q_{n}$ with $p_{i},q_{i}$ irreducible.\\\\\nSo $p_{1} | q_{1}...q_{n}$. In a PID, irreducible $\\iff$ prime. So $p_{1}$ divides some $q_{i}$, reorder to suppose $p_{1}|q_{1}$. So $q_{1}=p_{1}\\cdot a$. But as $q_{1}$ is irreducible, $a$ must be a unit. So $p_{1} and q_{1}$ are associates.\\\\\nCancelling $p_{1}$ gives:\\\\\n$p_{2}p_{3}...p_{n}=\\left(aq_{2}\\right)q_{3}...q_{n}$ and we continue.\\\\\nThis also shows $n=m$, else if $n=m+k$ then get $p_{k+1}...p_{n}=1$ a contradiction.\n\\end{proof}\n\\end{prop}\n\n\\begin{defi}\n$d$ is a greatest common divisor of $a_{1},a_{2},...,a_{n}$ if $d|a_{i}$ for all $i$, and if $d'|a_{i}$ for all $i$ then $d'|d$.\n\\end{defi}\n\n\\begin{lemma}\nIf $R$ is a UFD then the gcd exists, and is unique up to associates.\n\\begin{proof}\nEvery $a$ is a product of irreducibles, so let $p_{1},p_{2},...,p_{m}$ be a list of all the irredcibles which are factors of $a_{i}$, none of them is associate of each other.\\\\\nWrite $a_{i}=u_{i}\\Pi_{j=1}^{m} p_{j}^{n_{ij}}$ for $u_{i}$ units and $n_{ij} \\in \\N$.\\\\\nLet $m){j}=\\min_{i}\\left(n_{ij}\\right)$ and $d=\\Pi_{j=1}^m p_{j}^{m_{j}}$. As $m_{j} \\leq n_{ij} \\forall i$, $d|a_{i}$ for all $i$.\\\\\nIf $d'|a_{i} \\forall i$, let $d'=v \\Pi_{j=1}^m p_{i}^{t_{j}}$.\\\\\nThen we must have $t_{j} \\leq n_{ij} \\forall i$ so $t_{j} \\leq m_{j} \\forall j$. Then $d'|d$.\\\\\n\\end{proof}\n\\end{lemma}\n\n\\subsection{Factorisation in polynomial rings}\nFor $F$ a field, we know $F[x]$ is a Euclidean Domain(ED), so a PID, so a UFD. So\\\\\n1) $I\\triangleleft F[x] \\implies I=\\left(f\\right)$.\\\\\n2) $f\\in F[x]\\text{ irreducible} \\iff f\\text{ prime}$.\\\\\n3) Let $f\\in F[x]$ be irreducible, and $\\left(f\\right) \\leq J \\leq F[x]$. Then $J=\\left(g\\right)$ and $\\left(f\\right) \\subset \\left(g\\right)$ so $f=g\\cdot h$. But $f$ is irreducible, so $g$ or $h$ is a unit.\\\\\nIf $g$ is a unit, then $\\left(g\\right)=F[x]$;\\\\\nIf $h$ is a unit, then $\\left(f\\right)=\\left(g\\right)$.\\\\\nSo $\\left(f\\right)$ is a maximal ideal.\\\\\n4) $\\left(f\\right)$ prime ideal $\\implies f$ prime $implies f$ reducible $\\implies \\left(f\\right)$ is maximal.\\\\\nSo in $F[x]$, prime ideals are the same as maximal ideals.\\\\\n5) $f$ is irreducible if and only if $F[x]/\\left(f\\right)$ is a field.\\\\\n\n\\begin{defi}\nLet $R$ be a UFD and $f=a_0+a_1 X+...+a_n X^n \\in R[x]$ with $a_n \\neq 0$. Let the \\emph{content} $c\\left(f\\right)$ of $f$ is the gcd of all the coefficients in $R$, unique up to associates. Say $f$ is \\emph{primitive} if $c\\left(f\\right)$ is a unit, i.e. the $a_i$ are coprime.\n\\end{defi}\n\n\\begin{lemma} (Gauss')\nLet $R$ be a UFD, $f\\in R[x]$ be a primitive polynomial. Then $f$ is irreducible in $R[x] \\iff f$ is irreducible in $F[x]$, where $F$ is the field of fractions of $R$.\n\\end{lemma}\n\n\\begin{eg}\nConsider $f=x^3+x+1 \\in \\Z[x]$. This has content 1 so is primitive.\\\\\nSuppose $f$ is reducible in $\\Q[x]$. Then by Gauss' lemma $f$ is reducible in $\\Z[x]$ too, so $x^3+x+1=g\\cdot h$ for $g,h\\in \\Z[x]$, both $g$ and $h$ are not units. Neither $g$ nor $h$ can be constant, so they both have degree at least 1. So WLOG suppose $g$ has degree 1 and $h$ as degree 2.\\\\\nSo $g=b_0+b_1x$, $h=c_0+c_1x+c_1x^2$.\\\\\nMultiplying them gives $b_0c_0=1$, $c_2b_1=1$ so $b_0$ and $b_1$ are both $\\pm 1$. So $g$ is $1+x$ or $1-x$ or $-1+x$ or $-1-x$, so has $\\pm 1$ as a root. But $f$ doesn't have $\\pm 1$ as a root. Contradiction.\\\\\nNote that from this we can know that $f$ has not no root in $\\Q$.\n\\end{eg}\n\n\\begin{lemma}\nLet $R$ be a UFD. If $f,g\\in R[x]$ are primitive, then $f\\cdot g$ is primitive too (Note that we don't know whether $R[x]$ is a UFD or not).\n\\begin{proof}\nLet $f=a_0+a_1x+...+a_nx^n$ with $a_n\\neq 0$,\\\\\n$g=b_0+b_1x+...+b_mx^m$ with $b_m\\neq 0$ be both primitive.\\\\\nSuppose $f\\cdot g$ is not primitive. Then $c\\left(fg\\right)$ is not a unit, so let $p$ be an irreducible which divides $c\\left(fg\\right)$.\\\\\nBy assumption $c\\left(f\\right)$ and $c\\left(g\\right)$ are units, so $p \\nmid c\\left(f\\right)$ and $p \\nmid c\\left(g\\right)$.\\\\\nSuppose $p|a_0$, $p|a_1$, ..., $p|a_{k-1}$, but $p \\nmid a_k$;\\\\\n$p|b_0$,...,$p|b_{l-1}$,but $p \\nmid b_l$.\\\\\nLook at coefficient of $x^{k+l}$ in $f\\cdot g$: \\\\\n$...+a_{k+1}b_{l-1}+a_kb_l+a_{k-1}b_{l+1}+...=\\sum_{i+j=k+l} a_ib_j$.\\\\\nAs $p|c\\left(fg\\right)$, we have $p|\\sum_{i+j=k+l}a_ib_j$.\\\\\nWe see that the only term that might not be divisible by p is $a_kb_l$.\\\\\nSo $p|a_kb_l$. $p$ is irreducible (so prime), so $p|a_n$ or $p_b|l$. Contradiction.\\\\\nSo $f\\cdot g$ is primitive.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}\nlet $R$ be a UFD. Then for $f,g\\in R[x]$ we have that $c\\left(f\\cdot g\\right)$ is an associate of $c\\left(f\\right)c\\left(g\\right)$.\n\\begin{proof}\nWe can always write $f=c\\left(f\\right)f_1, g=c\\left(g\\right)g_1$ with $f_1, g_1$ being primitive.\\\\\nThen $f\\cdot g=c\\left(f\\right)c\\left(g\\right)\\left(f_1\\cdot g_1\\right)$. So $c\\left(f\\right)c\\left(g\\right)$ is a gcd of coefficients $f\\cdot g$, so is $c\\left(fg\\right)$ (up to associates).\n\\end{proof}\n\\end{coro}\n\n\\begin{proof}(Gauss' lemma)\\\\\nWe will show that a primitive $f\\in R[x]$ is reducible in $R[x] \\iff$ it is reducible in $F[x]$.\\\\\n1) Let $f=g\\cdot h$ be a product in $R[x]$, $g,h$ not units. As $f$ is primitive, so are $g$ and $h$. So both have degree at least 1.\\\\\nSo $g,h$ are not units in $F[x]$ either, so $f$ is reducible in $F[x]$.\\\\\n2) Let $f=g\\cdot h$ in $F[x]$, $g$ and $h$ not units. So $g$ and $h$ have degree at least 1.\\\\\nWe can find $a,b\\in R$ s.t. $a\\cdot g\\in R[x]$ and $b\\cdot h\\in R[x]$ (clear the denominators).\\\\\nThen $a\\cdot b\\cdot f = \\left(a\\cdot g\\right)\\left(b\\cdot h\\right)$ is a factorisation in $R[x]$.\\\\\nLet $\\left(a\\cdot g\\right)=c\\left(a\\cdot g\\right)\\cdot g_1$ with $g_1$ primitive, $\\left(b\\cdot h\\right)=c\\left(b\\cdot h\\right)\\cdot h_1$ with $h_1$ primitive.\\\\\nSo \n\\begin{equation*}\n\\begin{aligned}\na\\cdot b &= c\\left(a\\cdot b\\cdot f\\right)\\\\\n&= c\\left(\\left(a\\cdot g\\right)\\left(b\\cdot h\\right)\\right)\\\\\n&= u\\cdot c\\left(a\\cdot g\\right)\\cdot c\\left(b\\cdot h\\right)\n\\end{aligned}\n\\end{equation*}\nby the previous corollary, where $u\\in R$ is a unit.\\\\\nBut also $a\\cdot b\\cdot f=c\\left(a\\cdot g\\right)\\cdot c\\left(b\\cdot h\\right)\\cdot g_1 \\cdot h_1$.\\\\\nSo cancelling $a\\cdot b$ gives $f=u^{-1} g_1h_1 \\in R[x] \n$, so $f$ is reducible in $R[x]$.\n\\end{proof}\n\n\\begin{prop}\nLet $R$ be a UFD, $g\\in R[x]$ be primitive.\\\\\nLet $J=\\left(g\\right)\\triangleleft R[x]$, $I=\\left(g\\right)\\triangleleft F[x]$.\\\\\nThen $J=I \\cap R[x]$.\\\\\n(More plainly, if $f=g\\cdot h\\in R[x]$ with $h\\in F[x]$ then $f=g\\cdot h'$ with $h' \\in R[x]$.\n\\begin{proof}\nCertainly $J \\subseteq I \\cap R[x]$. Let $f\\in I \\cap R[x]$, so $f=g\\cdot h$ with $h\\in F[x]$. Choose $b\\in R$ s.t. $b\\cdot h\\in R[x]$ (clear denominators).\\\\\nThen $b\\cdot f=g\\cdot \\left(bh\\right)\\in R[x]$.\\\\\nLet $\\left(b\\cdot h\\right)=c\\left(b\\cdot h\\right)\\cdot h_1$ for $h_1$ primitive. Then\\\\\n$b\\cdot f = c\\left(b\\cdot h\\right)\\cdot g\\cdot h_1$. So $c\\left(bf\\right)=u\\cdot c\\left(bh\\right)$ for $u$ a unit since $g\\cdot h_1$ is primitive.\\\\\nBut $c\\left(b\\cdot f\\right)=b\\cdot c\\left(f\\right)$. So $b|c\\left(bh\\right)$.\\\\\n$c\\left(bh\\right)=b\\cdot c\\in R$.\\\\\nSo $b\\cdot f=b\\cdot c gh_1$, cancelling $b$ gives $f=g\\left(ch_1\\right)$. So $g$ divides $f$ in $R[x]$.\n\\end{proof}\n\\end{prop}\n\n\\begin{thm}\nIf $R$ is a UFD, then $R[x]$ is a UFD.\n\\begin{proof}\nLet $f\\in R[x]$. We can write $f=c\\left(f\\right)\\cdot f_1$ with $f_1$ primitive.\\\\\nFirstly, As $R$ is a UFD, we may factor $c\\left(f\\right)=p_1 p_2 ... p_n$ for $p_i \\in R$ irreducible, (so also irreducible in $R[x]$).\\\\\nIf $f_1$ is not irreducible, write $f_1 = f_2 f_3$ with $f_2$ and $f_3$ both not units, so $f_2$ and $f_3$ must both have non-zero degree(since $f_1$ is primitive, they can't be constant). Also $\\deg\\left(f_2\\right),\\deg\\left(f_3\\right) < \\deg\\left(f_1\\right)$.\\\\\nIf $f_2,f_3$ are irreducible then done. Else continue factoring. At each stage the degree of factors strictly decreases, so we must finish: $f_1 = q_1 q_2 ... q_m$ with $q_i$ irreducible.\\\\\nSo $f=p_1 p_2 ... p_n q_1 q_2 ... q_m$ is a product of irreducibles.\\\\\nFor uniqueness, first note that $c\\left(f\\right)=p_1 p_2 ... p_n$ is a unique factorisation up to reordering and associates, as $R$ is a UFD. So cancel this off to obtain $f_1 = q_1 ... q_m$.So suppose $q_1 q_2 ... q_m = r_1 r_2 ... r_l$ is another factorisation of $f_1$.\\\\\nNote that each $q_i$ and each $r_i$ is a factor of the primitive polynomial $f_1$, so each of them must be also primitive.\\\\\nLet $F$ be the field of fractions of $R$, and consider $q_i, r_i \\in F[x]$ instead. Now $F[x]$ is a ED, hence PID, hence UFD. By Gauss' lemma, the $q_i$ and $r_i$ are irreducible in $F[x]$. As $F[x]$ is a UFD we find that $l=m$; and after reordering $r_i = u_i q_i$ with $u_i \\in F[x]$ a unit.\\\\\nFirstly $u_i\\in F$ since it is a unit.\\\\\nClear denominators of $u_i$, we find that $a_i r_i = b_i q_i \\in R[x]$.\\\\\nSo taking contents shows that $a_i$ and $b_i$ are associates. So $b_i = v_i a_i$ with $v_i\\in R$ a unit.\\\\\nCancelling $a_i$ gives $r_i = v_i q_i$ as required.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\n$\\Z[x]$ is a UFD.\\\\\n$R$ is a UFD $\\implies$ $R[x_1,x_2,...,x_n]$ is a UFD.\n\\end{eg}\n\n\\begin{thm} (Eisenstein's criterion) \nLet $R$ be a UFD, let\n\\begin{equation*}\n\\begin{aligned}\nf=a_0 + a_1 x + ... + a_n x^n \\in R[x]\n\\end{aligned}\n\\end{equation*}\nhave $a_n \\neq 0$ and $f$ primitive. Let $p\\in R$ be irreducible (=prime, since $R$ is a UFD) such that:\\\\\n1) $p \\nmid a_n$;\\\\\n2) $p | a_i$ for $0 \\leq i \\leq n-1$;\\\\\n3) $p^2 \\nmid a_0$.\\\\\nThen $f$ is irreducible in $R[x]$, so also irreducible in $F[x]$ by Gauss' lemma.\n\\begin{proof}\nSuppose $f$=$g\\cdot h$ with\\\\\n$g=r_0 + r_1 x+...+r_k x^k$ with $r_k \\neq 0$,\\\\\n$h=s_0 + s_1 x+...+s_l x^l$ with $s_l \\neq 0$.\\\\\nNow $r_k s_l = a_n$, and $p \\nmid a_n$ so $p \\nmid r_k$ and $p \\nmid s_l$.\\\\\nAlso $r_0 s_0 = a_0$, and $p|a_0$ but $p^2 \\nmid a_0$. So WLOG let $p | r_0$ but $p \\nmid s_0$.\\\\\nLet $j$ be such that $p|r_0, p|r_1,...,p|r_{j-1},p \\nmid r_j$.\\\\\nThen $a_j = r_0 s_j+r_1 s_{j-1} + ... + r_{j-1} s_1 + r_j s_0$. All but the last term are divisible by $p$, and $r_j s_0$ is not divisible by $p$ since both $r_j$ and $s_0$ are not divisible by $p$.\\\\\nSo $p \\nmid a_j$. By condition (1) and (2) we must have $j=n$. Also we have $j \\leq k \\leq n$, so $j=k=n$. That means $l = n-k = 0$, so $h$ is a constant.\\\\\nBut $f$ is primitive, it follows that $h$ must be a unit. So $f$ is irreducible.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\nConsider $x^n - p \\in \\Z[x]$ for $p$ prime. Apply Eisenstein's criterion with $p$, we find that all the conditions hold. So $x^n - p$ is irreducible in $\\Z[x]$, and so in $\\Q[x]$ as well by Gauss' lemma.\\\\\nThis implies that $x^n - p$ has no roots in $\\Q$. So $\\sqrt[n]{p} \\notin \\Q$.\n\\end{eg}\n\n\\begin{eg}\nConsider $f= x^{p-1} + x^{p-2}+...+x^2+x+1 \\in \\Z[x]$ with $p$ a prime number.\\\\\nNote $f=\\frac{x^p-1}{x-1}$, so let $y=x-1$. Then\\\\\n$\\hat{f}\\left(y\\right) = \\frac{\\left(y+1\\right)^p-1}{y} = y^{p-1} + {p \\choose 1} y^{p-2} + ... + {p \\choose p-1}$.\\\\\nNow $p | {p\\choose i}$ for $1\\leq i \\leq p-1$, but $p^2 \\nmid {p \\choose p-1} = p$.\\\\\nSo by Eisenstein's criterion, $\\hat{f}$ is irreducible in $\\Z[x]$.\\\\\nNow if $f\\left(x\\right)=g\\left(x\\right)\\cdot h\\left(x\\right) \\in \\Z[x]$, then get $\\hat{f}\\left(y\\right) = g\\left(y+1\\right)\\cdot h\\left(y+1\\right)$ a factorisation in $\\Z[y]$. So $f$ is irreducible.\n\\end{eg}\n\n\\subsection{Gaussian integers}\nRecall $\\Z[i] = \\left\\{a+bi | a,b\\in\\Z\\right\\} \\leq \\C$ is thexswq \\emph{Gaussian integers}.\\\\\nThe \\emph{norm} $N\\left(a+ib\\right)=a^2 + b^2$ serves as a Euclidean function for $\\Z[i]$. So it is a ED, so a PID, so a UFD.\\\\\nThe units are precisely $\\pm 1$ and $\\pm i$.\\\\\n\n\\begin{eg}\n1) $2=\\left(1+i\\right)\\left(1-i\\right)$, so not irreducible, so not prime.\\\\\n2) $3$: $N\\left(3\\right)=9$, so if $3=u\\cdot v$ with $u,v$ not units, then $9=N\\left(u\\right)N\\left(v\\right)$ with $N\\left(u\\right)\\neq 1 \\neq N\\left(v\\right)$. So $N\\left(u\\right)=N\\left(v\\right)=3$. But $3=u^2+v^2$ has no solutions with $a,b\\in \\Z$. So 3 is irreducible, so a prime.\\\\\n3) $5=\\left(1+2i\\right)\\left(1-2i\\right)$ is not irreducible, so not prime.\n\\end{eg}\n\n\\begin{prop}\nA prime number $p\\in\\Z$ is prime in $\\Z[i] \\iff p \\neq a^2+b^2$ for $a,b\\in\\Z\\backslash\\left\\{0\\right\\}$.\n\\begin{proof}\nIf $p=a^2+b^2=\\left(a+ib\\right)\\left(a-ib\\right)$ then it is not irreducible, so not prime.\\\\\nIf $p=u\\cdot v$, then $p^2 = N\\left(u\\right)N\\left(v\\right)$. So if $u,v$ are not units, then $N\\left(u\\right)=N\\left(v\\right)=p$ since $p$ is prime in $\\Z$. Writing $u=a+ib$, this says $a^2+b^2=p$.\n\\end{proof}\n\\end{prop}\n\n\\begin{lemma}\nLet $p$ be a prime number, $F_p = \\Z/p\\Z$ a field with $p$ elements.\\\\\nLet $F_p^* = F_p\\backslash\\left\\{0\\right\\}$ be the group of invertible elements under multiplication.\\\\\nThen $F_p^* \\cong C_{p-1}$.\n\\begin{proof}\nCertainly $F_p^*$ has order $p-1$, and is abelian.\\\\\nKnow classification of finite abelian groups, it follows that if $F_p^*$ is not cyclic, then it must contain a subgroup $C_m \\times C_m$ for $m>1$.\\\\\nConsider the polynomial $X^m -1 \\in F_p[x]$, a UFD. At best this factors into $m$ linear factors, so $X^m -1$ has at most $m$ distinct roots.\\\\\nIf $C_m \\times C_m \\leq F_p^*$, then we have $m^2$ elements of $F_p$ which are roots of $X^m-1$. But $m^2 > m$, contradiction. So $F_p^*$ is cyclic.\n\\end{proof}\n\\end{lemma}\n\n\\begin{prop}\nThe primes in $\\Z[i]$ are, up to associates,\\\\\n1) prime numbers $p\\leq \\Z \\leq \\Z[i]$ s.t. $p\\equiv 3 \\mod 4$;\\\\\n2) $z\\in\\Z[i]$ with $N\\left(z\\right)=z\\overline{z}=p$ for $p$ prime, $p=2$ or $p \\equiv 1 \\mod 4$.\n\\begin{proof}\n1) If $p\\equiv 3 \\mod 4$ then $p\\neq a^2+b^2$.\\\\\nBy the previous proposition, $p\\in\\Z[i]$ is prime.\\\\\n2) If $N\\left(z\\right)=p$ and $z=uv$, then $N\\left(u\\right)N\\left(v\\right)=p$. So $N\\left(u\\right)=1$ or $N\\left(v\\right)=1$, so $u$ or $v$ is a unit.\\\\\nLet $z\\in\\Z[i]$ be irreducible (also prime). Then $\\overline{z}$ is irreducible, so $N\\left(z\\right) = z\\overline{z}$ is a factorisation of $N\\left(z\\right)$ into irreducibles.\\\\\nLet $p\\in\\Z$ be a prime number dividing $N\\left(z\\right)$. ($N\\left(z\\right)\\neq 1$ so such $p$ exists).\\\\\n$\\bullet$ Case 1: $p\\equiv 3 \\mod 4$. Then $p\\in\\Z[i]$ is prime by the first part of the proof. $p|N\\left(z\\right)=z\\overline{z}$ so $p|z$ or $p|\\overline{z}$. So perhaps conjugating, get $p|z$. But both are irreducible, so $p$ and $z$ are associates.\\\\\n$\\bullet$ Case 2: $p=2$ or $p\\equiv 1 \\mod 4$.\\\\\nIf $p\\equiv 1\\mod 4$ then $p-1 = 4k$ for some $k$. As $F_p^* \\cong C_{p-1} = C_{4k}$, there is a unique element of order $2$, which must be $[-1]\\in F_p$.\\\\\nLet $[a]\\in F_p^*$ be an element of order 4. Then $[a^2] = [-1]$.\\\\\nSo $a^2 + 1$ is divisible by $p$. So $p|\\left(a+i\\right)\\left(a-i\\right)$.\\\\\nAlso $2|\\left(1+i\\right)\\left(1-i\\right)$.\\\\\nSo deduce that $p$ (or 2) is not prime, so not irreducible, as it clearly does not divide $a+i$ or $a-i$.\\\\\nSo $p=z_1 z_2$ for $z_1, z_2 \\in \\Z[i]$. So\n\\begin{equation*}\n\\begin{aligned}\np^2 = N\\left(p\\right) = N\\left(z_1\\right)N\\left(z_2\\right).\n\\end{aligned}\n\\end{equation*}\nSo as $z_i$ are not units, $N\\left(z_1\\right) = N\\left(z_2\\right) = p$. So $p=z_1 \\bar{z_2}$ ($=z_2 \\bar{z_1}$). So $\\bar{z_1} = z_2$.\\\\\nSo $p=z_1 \\bar{z_1} | N\\left(z\\right) = z\\bar{z}$. So $z$ is an associate of $z_1$ or $\\bar{z_1}$, as $z$ and $z_1$ are irreducible.\n\\end{proof}\n\\end{prop}\n\n\\begin{coro}\nAn integer $n\\in\\Z^+$ may be written as $x^2 + y^2$ (the sum of two squares) if and only if, when we write $n=p_1^{n_1} p_2^{n_2} ... p_k^{n_k}$ as a product of distinct primes, if $p_i \\equiv 3 \\mod 4$ then $n_i$ is even.\n\\begin{proof}\nLet $n=x^2+y^2 = \\left(x+iy\\right)\\left(x-iy\\right)=N\\left(x+iy\\right)$. Let $z=x+iy$, so $z=\\alpha_1 \\alpha_2...\\alpha_q$ a product of irreducibles in $\\Z[i]$.\\\\\nBy the proposition, each $\\alpha_i$ is either $\\alpha_i = p$ prime number with $p\\equiv 3 \\mod 4$, or $N\\left(\\alpha_i\\right)=p$ a prime number which is either 2 or $\\equiv 1 \\mod 4$.\n\\begin{equation*}\n\\begin{aligned}\nn=x^2+y^2=N\\left(z\\right)=N\\left(\\alpha_1\\right)N\\left(\\alpha_2\\right)...N\\left(\\alpha_q\\right)\n\\end{aligned}\n\\end{equation*}\nEach $N\\left(\\alpha_i\\right)$ satisfies: either\\\\\n$\\bullet$ $N\\left(\\alpha_i\\right) = p^2$ with $p\\equiv 3 \\mod 4$ prime, or\\\\\n$\\bullet$ $N\\left(\\alpha_i\\right) = p$ with $p=2$ or $p\\equiv 1 \\mod 4$ prime.\\\\\nSo if $p^m$ is the largest power of $p$ dividing $n$, we find that $m$ must be even if $p\\equiv 3 \\mod 4$.\\\\\n\nConversely, let $n=p_1^{n_1}p_2^{n_2}...p_k^{n_k}$ be a product of distinct primes.\\\\\nFor each $p_i$, either $p_i \\equiv 3 \\mod 4$ and $n_i$ is even, so $p_i^{n_i} = \\left(p_i^2\\right)^{\\frac{n}{2}} = N\\left(p_i^\\frac{n}{2}\\right)$, or $p_i = 2$ or $p_i \\equiv 1 \\mod 4$, then $p_i = N\\left(\\alpha_i\\right)$ for some $\\alpha_i \\in \\Z[i]$. So $p_i^{n_i} = N\\left(\\alpha_i^{n_i}\\right)$.\\\\\nSo $n$ is the norm of some $z\\in\\Z[i]$, so $n=N\\left(z\\right)=N\\left(x+iy\\right) = x^2+y^2$ is a sum of squares.\n\\end{proof}\n\\end{coro}\n\n\\begin{eg}\n$65=5\\cdot 13$.\\\\\nThen $5=\\left(2+i\\right)\\left(2-i\\right)$\\\\\n$13=\\left(2+3i\\right)\\left(2-3i\\right)$.\\\\\nSo $65 = N\\left(\\left(2+i\\right)\\left(2+3i\\right)\\right)=N\\left(1+8i\\right)=1^2+8^2$.\\\\\nAlso $65 = N\\left(\\left(2+i\\right)\\left(2-3i\\right)\\right)=N\\left(7-4i\\right)=7^2+4^2$.\n\\end{eg}\n\n\\subsection{Algebraic integers}\n\\begin{defi}\n$\\alpha\\in\\C$ is called an \\emph{algebraic integer} if it is a root of a monic polynomial in $\\Z[x]$, i.e. $\\exists$ monic $f\\in\\Z[x]$ s.t. $f\\left(\\alpha\\right)=0$.\\\\\nWrite $\\Z[\\alpha]\\leq \\C$ for the smallest subring containing $\\alpha$.\\\\\nIn other words,$\\Z[\\alpha]$=$Im\\left(\\varphi\\right)$ where $\\varphi$ is defined as:\n\\begin{equation*}\n\\begin{aligned}\n\\varphi: &\\Z[x] \\to \\C\\\\\n&g\\to g\\left(\\alpha\\right)\n\\end{aligned}\n\\end{equation*}\nSo also $\\Z[\\alpha] \\cong \\Z[x]/I$, $I=\\ker\\left(\\varphi\\right)$.\n\\end{defi}\n\n\\begin{prop}\nIf $\\alpha\\in\\C$ is an algebraic integer then\n\\begin{equation*}\n\\begin{aligned}\nI= \\ker \\left(\\varphi:\n\\begin{array}{ll}\n\\Z[x] &\\to\\C\\\\\nf &\\to f\\left(\\alpha\\right)\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\nis a principal ideal and is generated by a monic irreducible polynomial $f_\\alpha\\in\\Z[x]$, called the \\emph{minimal polynomial} of $\\alpha$.\n\\begin{proof}\nBy definition there is a monic $f\\in\\Z[x]$ s.t. $f\\left(\\alpha\\right)=0$. So $f\\in I$ so $I\\neq 0$.\\\\\nLet $f_\\alpha\\in I$ be a polynomial of minimal degree. We may suppose that $f_\\alpha$ is primitive by dividing by its content.\\\\\nWe want to show that $I=\\left(f_\\alpha\\right)$ and that $f_\\alpha$ is irreducible.\\\\\nLet $h\\in I$. In $\\Q[x]$ we have a Euclidean algorithm, so we may write $h=f_\\alpha \\cdot q+r$ with $r=0$ or $\\deg\\left(r\\right)<\\deg\\left(f_\\alpha\\right)$.\\\\\nWe may multiply by some $a\\in\\Z$ to clear denominators and get\n\\begin{equation*}\n\\begin{aligned}\na\\cdot h = f_\\alpha \\cdot \\left(aq\\right) + \\left(ar\\right)\n\\end{aligned}\n\\end{equation*}\nwith $aq$ and $ar$ in $\\Z[x]$.\\\\\nEvaluate at $\\alpha$ gives\n\\begin{equation*}\n\\begin{aligned}\nah\\left(\\alpha\\right) = f_\\alpha\\left(\\alpha\\right)\\left(aq\\right)\\left(\\alpha\\right) + \\left(ar\\right)\\left(\\alpha\\right)\\\\\n\\implies 0=\\left(ar\\right)\\left(\\alpha\\right)\n\\end{aligned}\n\\end{equation*}\nSo $\\left(ar\\right)\\in I$.\\\\\nAs $f_\\alpha\\in I$ has minimal degree, we cannot have $\\deg\\left(r\\right)=\\deg\\left(ar\\right)<\\deg\\left(f_\\alpha\\right)$. So instead must have $r=0$.\\\\\nSo $ah = f_\\alpha \\cdot\\left(aq\\right) \\in \\Z[x]$.\\\\\nTake contents of everything, get\n\\begin{equation*}\n\\begin{aligned}\na\\cdot c\\left(h\\right) = c\\left(ah\\right) = c\\left(f_\\alpha\\left(aq\\right)\\right) = c\\left(aq\\right)\n\\end{aligned}\n\\end{equation*}\nas $f_\\alpha$ is primitive.\\\\\nSo $a|c\\left(aq\\right)$, so $aq = a \\bar{q}$ with $\\bar{q}\\in\\Z[x]$ and cancelling $a$ shows $q=\\bar{q}\\in \\Z[x]$.\\\\\nSo $h=f_\\alpha \\cdot q\\in\\left(f_\\alpha\\right) \\triangleleft \\Z[x]$. So $I=\\left(f_\\alpha\\right)$.\\\\\n\nNow we want to show that $f_\\alpha$ is irreducible. We have\n\\begin{equation*}\n\\begin{aligned}\n\\Z[x]/\\left(f_\\alpha\\right) = \\Z[x]/\\ker\\left(\\varphi\\right) \\cong Im\\left(\\varphi\\right) = \\Z[\\alpha] \\leq \\C\n\\end{aligned}\n\\end{equation*}\n$\\C$ is an integral domain, so Im$\\left(\\varphi\\right)$ is an integral domain, so $\\Z[x]/\\left(f_\\alpha\\right)$ is an integral domain.\\\\\nSo $\\left(f_\\alpha\\right)$ is prime. So $f_\\alpha$ is prime, so irreducible.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\n$\\alpha = i$ is an algebraic integer with $f_\\alpha = x^2 + 1$.\\\\\n$\\alpha = \\sqrt{2}$ is an algebraic integer with $f_\\alpha = x^2-2$.\\\\\n$\\alpha = \\frac{1}{2}\\left(1+\\sqrt{-3}\\right)$ is an algebraic integer with $f_\\alpha = x^2-x+1$.\\\\\nThe polynomial $x^5 - x + d\\in\\Z[x]$ with $d\\in \\Z$ has precisely one real root $\\alpha$, which is an algebraic integer.\n\\end{eg}\n\\begin{rem} (Galois theory)\\\\\nThis $\\alpha$ cannot be constructed from $\\Z$ using $+,-,\\times,/,\\sqrt[n]{ }$.\n\\end{rem}\n\n\\begin{lemma}\nIf $\\alpha\\in\\Q$ is an algebraic integer, then $\\alpha \\in \\Z$.\n\\begin{proof}\nLet $f_\\alpha \\in \\Z[x]$ be the minimal polynomial, which is irreducible.\\\\\nIn $\\Q[x]$, $x-\\alpha$ must divide $f_\\alpha$, but by Gauss' lemma, $f_\\alpha \\in \\Q[x]$ must be irreducible. So must have $f_\\alpha = x-\\alpha\\in\\Z[x]$ (else there is a proper decomposition). So $\\alpha \\in \\Z$.\n\\end{proof}\n\\end{lemma}\n\n\\subsection{Hilbert basis theorem}\nA ring $R$ satisfies the \\emph{ascending chain condition (ACC)} if whenever\n\\begin{equation*}\n\\begin{aligned}\nI_1 \\subset I_2 \\subset ...\n\\end{aligned}\n\\end{equation*}\nis an increasing sequence of ideals, then we have \n\\begin{equation*}\n\\begin{aligned}\nI_n = I_{n+1} = I_{n+2} = ...\n\\end{aligned}\n\\end{equation*}\nfor some $n \\in \\N$.\\\\\nA ring satisfying this condition is called Noetherian.\n\n\\begin{eg}\nAny finite ring, any field, and $\\Z$ or any other PID is Noetherian (see next proposition).\\\\\nConsider $\\Z[x_1,x_2,...]$. Note that \n\\begin{equation*}\n\\begin{aligned}\n\\left(x_1\\right) \\subset \\left(x_1x_2\\right) \\subset \\left(x_1x_2x_3\\right) \\subset ...\n\\end{aligned}\n\\end{equation*}\nwhile none of the ideals are equal. Thus $\\Z[x_1,x_2,...]$ is not Noetherian.\n\\end{eg}\n\n\\begin{prop}\nA ring $R$ is Noetherian $\\iff$ every ideal of $R$ is finitely generated, i.e. $I=\\left(r_1,...,r_n\\right)$ for some $r_1,...,r_n\\in R$ for every ideal $I \\subset R$.\n\\begin{proof}\nSuppose every ideal of $R$ is finitely generated. Given $I_1 \\subset I_2 \\subset ...$, consider the ideal\n\\begin{equation*}\n\\begin{aligned}\nI = I_1 \\cup I_2 \\cup ...\n\\end{aligned}\n\\end{equation*}\nWe have $I=\\left(r_1,...,r_n\\right)$, with WLOG $r_i \\in I_{k_i}$.\\\\\nNow let $k=max\\left(k_1,...,k_n\\right)$.\\\\\nThen $r_1,...,r_n\\in I_k$,  hence $I_k = I$.\n\nOn the other hand, suppose an ideal $I$ is not finitely generated.\\\\\nChoose $r_1 \\in I$. Then $\\left(r_1\\right) \\neq I$ as $I$ is not finitely generated. Then choose $r_2 \\in I\\backslash \\left(r_1\\right)$. Then $\\left(r_1,r_2\\right)\\neq I$. Then choose $r_3,r_4,...$ similarly. But now we get a chain of ideals\n\\begin{equation*}\n\\begin{aligned}\n\\left(r_1\\right) \\subset \\left(r_1,r_2\\right) \\subset ...\n\\end{aligned}\n\\end{equation*}\nwhile none of them is equal to any other. Contradiction. So $I$ must be finitely generated.\n\nAlternative proof for second part (2017 Lent): conversely, suppose $R$ is Noetherian. Let $I$ be an ideal.\n\nChoose $a_1 \\in I$. If $I=(a_1)$ then done, so suppose not. Then choose $a_2 \\in I \\setminus\\{a_1\\}$; if $I=(a_1,a_2)$ then done, so suppose not... If we can't be finished by this process, then we get\n\\begin{equation*}\n\\begin{aligned}\n(a_1) \\subsetneq (a_1,a_2) \\subsetneq (a_1,a_2,a_3) \\subsetneq ...\n\\end{aligned}\n\\end{equation*}\nwhich is impossible as $R$ is Noetherian. So $I=(a_1,a_2,...,a_r)$ for some $r$.\n\\end{proof}\n\\end{prop}\n\n\\begin{thm}(Hilbert's basis theorem)\\\\\n$R$ is Noetherian $\\implies$ $R[x]$ is Noetherian.\\\\\n(hence e.g. $Z[x]$ is Noetherian, whence $Z[x,y]$ is Noetherian, etc.)\n\\begin{proof} (Lent 2017)\\\\\nLet $J \\triangleleft R[x]$. Let $f_1 \\in J$ be a polynomial of minimal degree. If $J=(f_1)$ then done, else choose $f_2 \\in J \\setminus (f_1)$ of minimal degree. If $J=(f_1,f_2)$ then done... Suppose this never terminates, i.e. we have $(f_1) \\subsetneq (f_1,f_2) \\subsetneq ... \\subsetneq(f_1,f_2,f_3) \\subsetneq ...$.\n\nLet $0 \\neq a_i \\in R$ be the coefficient of the largest power of $X$ in $f_i$, and consider the chain of ideals $(a_1) \\subset (a_1,a_2) \\subset (a_1,a_2,a_3) \\subset ... \\triangleleft R$. As $R$ is Noetherian, this chain stabilizes, i.e. there exist $m$ s.t. all $a_i$ lie in $a_1,...,a_m$. In particular, $a_{m+1} = \\sum_{i=1}^n a_i b_i$ for some $b_i \\in R$.\n\nLet $g = \\sum_{i=1}^m b_i f_i X^{\\deg(f_{m+1}) - \\deg(f_i)}$ has top term $\\sum_{i=1}^n b_i a_i X^{\\deg(f_{m+1})}$, i.e. $a_{m+1} X^{\\deg(f_{m+1})}$.\n\nNote that $f_{m+1} - g$ has degree strictly smaller than that of $f_{m+1}$. But $g \\in (f_1,...,f_m)$, while $f_{m+1} \\not\\in (f_1,...,f_m)$. So $f_{m-1} -g \\not\\in (f_1,...,f_m)$, contradicting with the fact that we have chosen $f_{m+1}$ to be the minimal degree each time.\n\\end{proof}\n\n\\begin{proof} (Lent 2016)\\\\\nLet $I$ be an ideal in $R[x]$. For $n=0,1,2,...$, let\n\\begin{equation*}\n\\begin{aligned}\nI_n = \\left\\{r\\in R:\\exists f\\in I \\text{  with  } f=rx^n+...\\right\\} \\cup \\left\\{0\\right\\}\n\\end{aligned}\n\\end{equation*}\nThen each $I_n$ is an ideal of $R$.\\\\\nAlso $I_n \\subset I_{n+1} \\forall n$ since $f\\in I \\implies xf\\in I$ (as $I$ is an ideal in $R[x]$).\\\\\nThus $I_N=I_{N+1}=...$ for some $N$ since $R$ is Noetherian.\\\\\nFor each $0\\leq n \\leq N$, we have \n\\begin{equation*}\n\\begin{aligned}\nI_n=\\left(r_1^{\\left(n\\right)},r_2^{\\left(n\\right)},...,r_{k\\left(n\\right)}^{\\left(n\\right)}\\right)\n\\end{aligned}\n\\end{equation*}\nAs $R$ is Noetherian.\\\\\nFor each $r_i^{\\left(n\\right)}$, choose a $f_i^{\\left(n\\right)}$ with $f_i^{\\left(n\\right)} = r_i^{\\left(n\\right)} x^n+ ...$\\\\\n$\\bullet$ Claim: The polynomials $f_i^{\\left(n\\right)}$ ($0\\leq n \\leq N, 1 \\leq i \\leq k\\left(n\\right)$) generate $I$.\\\\\nProof of claim: Suppose not. Then choose $g\\in i$ of minimum degree that is not generated by the above polynomials $f_i^{\\left(n\\right)}$.\\\\\n$\\bullet$ If $\\deg\\left(g\\right) = n \\leq N$: have $g=r x^n+...$. But $r\\in I_n$. So $r=\\sum_i \\lambda_i r_i^{\\left(n\\right)}$ for some $\\lambda_i \\in R$.\\\\\nSo $\\sum_i \\lambda_i f_i^{\\left(n\\right)} = rx^n+...$, whence $g-\\sum_i \\lambda_i f_i^{\\left(n\\right)}$ has smaller degree than $g$(or it's zero) and is also not in $I$, contradicting with the fact that $g$ has the minimum degree.\\\\\n$\\bullet$ If $\\deg\\left(g\\right) = n > N$: Have $g=r x^n + ...$. But $r\\in I_n = I_N$, so $r=\\sum_i \\lambda_i r_i^{\\left(N\\right)}$ for some $\\lambda_i\\in R$.\\\\\nSo $x^{n-N} \\sum_i \\lambda_i r_i^{\\left(N\\right)} = rx^n + ...$ is in the ideal, whence $g-x^{n-N} \\sum_i \\lambda_i r_i^{\\left(N\\right)}$ has smaller degree than $g$ (or it's zero) and is also not in $I$. Contradiction.\n\\end{proof}\n\\end{thm}\n\nDoes $R$ Noetherian imply every subring of $R$ is Noetherian?\\\\\nThe answer is NO -- e.g. take $\\Z[x_1,x_2,...]$ (an integral domain) and let $R$ be its field of fractions, while the latter is a field so Noetherian, but the first one isn't Noetherian.\\\\\n\n\\begin{prop}\nLet $R$ be Noetherian, $I$ be an ideal in $R$. Then $R/I$ is Noetherian.\n\\begin{proof}\nLet\n\\begin{equation*}\n\\begin{aligned}\n\\varphi : &R \\to R/I\\\\\n&x \\to x+I\n\\end{aligned}\n\\end{equation*}\nGiven an ideal $J$ in $R/I$, have $\\varphi^{-1}\\left(I\\right)$ an ideal in $R$ (by ideal correspondence).\\\\\nSo $\\varphi^{-1} = \\left(r_1,...,r_n\\right)$ for some $r_1,...,r_n\\in R$ (since $R$ is Noetherian so $I$ is finitely generated).\\\\\nThus $J=\\left(\\varphi\\left(r_1\\right),\\varphi\\left(r_2\\right),...,\\varphi\\left(r_n\\right)\\right)$ is finitely generated. So $R/I$ is Noetherian.\n\\end{proof}\n\\end{prop}\n\nWhat about $Z[x]$? (recall that it's not a pid since $(2,x)$ is not principal)\\\\\n\n\n\\begin{rem}\nLet $E\\subset F[x_1,x_2,...,x_n]$ be any set of polynomial equations.\\\\\nConsider $\\left(E\\right) \\triangleleft F[x_1,x_2,...,x_n]$. By Hilbert's basis theorem, there is a finite list $f_1,...,f_k$ s.t. $\\left(E\\right) = \\left(f_1,...,f_k\\right)$.\\\\\nGiven $\\left(\\alpha_1,\\alpha_2,...\\alpha_n\\right)\\in F^n$, consider\n\\begin{equation*}\n\\begin{aligned}\n\\varphi_\\alpha: \\left(\n\\begin{array}{ll}\nF[x_1,...,x_n] &\\to F\\\\\nx_i &\\to \\alpha_i\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\na ring homomorphism.\\\\\n$\\left(\\alpha_1,...\\alpha_n\\right)\\in F^n$ is a solution to the equations $E$ $\\iff$ $\\left(E\\right) \\subset \\ker \\left(\\varphi_\\alpha\\right)$ $\\iff$ $\\left(f_1,...,f_n\\right)\\triangleleft \\ker\\left(\\varphi_\\alpha\\right)$ $\\iff$ $\\left(\\alpha_1,...,\\alpha_n\\right)$ is a common solution to $f_1,...,f_k$.\n\\end{rem}\n\n\\newpage\n\\section{Modules}\n\n\\subsection{Definitions and examples}\n\\begin{defi}\nLet $R$ be a commutative ring. A quadruple $\\left(M,+,0_M,\\cdot\\right)$ is a $R-$module if:\\\\\n$\\bullet$ (M1) $\\left(M,+,0_M\\right)$ is an abelian group;\\\\\n$\\bullet$ (M2) The operation $-\\cdot-:R\\times M\\to M$ satisfies\n\\begin{equation*}\n\\begin{aligned}\n&\\left(r_1+ r_2\\right)\\cdot m = \\left(r_1\\cdot m\\right)+\\left(r_2\\cdot m\\right)\\\\\n&r\\cdot\\left(m_1 + m_2\\right) = \\left(r\\cdot m_1\\right) + \\left(r\\cdot m_2\\right)\\\\\n&r_1\\cdot\\left(r_2\\cdot m\\right) = \\left(r_1 \\cdot r_2\\right)\\cdot m\\\\\n&1_R \\cdot m = m\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{eg}\n1) Let $F$ be a field. An $F-$module is precisely the same as a vector space over $F$.\\\\\n2) For any ring $R$, $R^n = R\\times R\\times ... \\times R$ is a $R-$module via\n\\begin{equation*}\n\\begin{aligned}\nr\\cdot\\left(r_1,r_2,...,r_n\\right) = \\left(r\\cdot r_1,r\\cdot r_2,...,r\\cdot r_n\\right)\n\\end{aligned}\n\\end{equation*}\n3) If $I\\triangleleft R$ is an ideal, then it is an $R-$module via\n\\begin{equation*}\n\\begin{aligned}\nr\\cdot_M a = r\\cdot_R a\n\\end{aligned}\n\\end{equation*}\nAlso, $R/I$ is a $R-$module via\n\\begin{equation*}\n\\begin{aligned}\nr\\cdot \\left(a+I\\right) = r\\cdot a + I\n\\end{aligned}\n\\end{equation*}\n4) A $\\Z-$module is precisely the same as an abelian group. For $A$ an abelian group,\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{array}{ll}\n\\Z \\times A &\\to A\\\\\n\\left(n,a\\right) &\\to \\left\\{\n\\begin{array}{ll}\na+a+...+a \\text{   (n times)} & a>0\\\\\n0 & a=0\\\\\n\\left(-a\\right)+\\left(-a\\right)+...+\\left(-a\\right) \\text{    (n times)} & a<0\n\\end{array}\n\\right.\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\n5) Let $F$ be a field, $V$ a vector space on $F$, and $\\alpha: V\\to V$ be a linear map.\\\\\nThen $V$ is a $F[x]-$module via\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{array}{ll}\nF[x]\\times V &\\to V\\\\\n\\left(f,v\\right) &\\to (f\\left(\\alpha\\right))\\left(v\\right)\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\ni.e. Substitute $\\alpha$ in the polynomial $f$, then act on $v$. \\\\\nDifferent choices of $\\alpha$ make $V$ into different $F[x]-$modules, so this is a module structure.\\\\\n6) If $\\varphi: R\\to S$ is a ring homomorphism, then any $S-$module $M$ may be considered as a $R-$module via\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{array}{ll}\nR\\times M &\\to M\\\\\n\\left(r,m\\right) &\\to \\varphi\\left(r\\right) \\cdot m\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\n\\begin{defi}\nIf $M$ is a $R-$Module, a subset $N\\subset M$ is a $R-$submodule if it is a subgroup of $\\left(M,+,0_M\\right)$ and if $n\\in N$ and $r\\in R$ then $r\\cdot n \\in N$.\\\\\nWe write $n \\leq M$.\n\\end{defi}\n\n\\begin{eg}\nA subset of the $R$ is a submodule of the $R-$module $R$ \\emph{precisely} if it is an ideal.\\\\\nA subset of an $F-$module $V$ for $F$ a field is a submodule \\emph{precisely} if it is a vector subspace.\n\\end{eg}\n\n\\begin{defi}\nIf $N\\subseteq M$ is a $R-$submodule, the \\emph{quotient module} $M/N$ is the set of $N-$cosets in the abelian group $\\left(M,+,0_M\\right)$ with\n\\begin{equation*}\n\\begin{aligned}\nr\\cdot\\left(m+N\\right) = r\\cdot m + N\n\\end{aligned}\n\\end{equation*}\nThis is well defined as, if any two different $m$ represent the same coset then they differ by some $n\\in N$.\n\\end{defi}\n\n\\begin{defi}\nA function $f:M\\to N$ between $R-$modules is an \\emph{$R-$module homomorphism} if it is a homomorphism of abelian groups, and satisfies\n\\begin{equation*}\n\\begin{aligned}\nf\\left(r\\cdot m\\right) = r\\cdot f\\left(m\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{eg}\nIf $F$ is a field and $V,W$ are $F-$modules (vector spaces over $F$), then an $F-$module homomorphism is precisely an $F-$linear map.\n\\end{eg}\n\n\\begin{thm} (First isomorphism theorem)\\\\\nLet $f:M\\to N$ be a $R-$module homomorphism. Then \n\\begin{equation*}\n\\begin{aligned}\n\\ker\\left(f\\right) = \\left\\{m\\in M| f\\left(m\\right)=0\\right\\} \\leq M\n\\end{aligned}\n\\end{equation*} \n(submodule), \n\\begin{equation*}\n\\begin{aligned}\nIm\\left(f\\right)=\\left\\{n\\in N| \\exists m\\in M s.t. n=f\\left(m\\right)\\right\\} \\leq N\n\\end{aligned}\n\\end{equation*}\nMoreover, $M/\\ker\\left(f\\right) \\cong$ Im$\\left(f\\right)$.\n\\end{thm}\n\n\\begin{thm} (Second isomorphism theorem)\\\\\nLet $A,B \\leq M$. Then\\\\\n\\begin{equation*}\n\\begin{aligned}\nA+B=\\left\\{m\\in M|\\exists a\\in A, b\\in B \\text{ s.t. } m=a+b\\right\\} \\leq M\n\\end{aligned}\n\\end{equation*}\n(a submodule), and\n\\begin{equation*}\n\\begin{aligned}\nA \\cap B \\leq M\n\\end{aligned}\n\\end{equation*}\nand\n\\begin{equation*}\n\\begin{aligned}\nA+B/A \\cong B/(A\\cap B).\n\\end{aligned}\n\\end{equation*}\n\\end{thm}\n\n\\begin{thm} (Third isomorphism theorem)\\\\\nIf $N\\leq L \\leq M$, then\n\\begin{equation*}\n\\begin{aligned}\nM/L \\cong (M/N)/(L/N).\n\\end{aligned}\n\\end{equation*}\nIn addition, there is a submodule correspondence between submodules of $M/N$ and submodules of $M$ which contain $N$.\n\\end{thm}\n\n\\begin{defi}\nLet $M$ be a $R-$module, $m\\in M$. The \\emph{annihilator} of $m$ is\n\\begin{equation*}\n\\begin{aligned}\n\\Ann\\left(m\\right) = \\left\\{r\\in R | r\\cdot m=0\\right\\}\n\\end{aligned}\n\\end{equation*}\nThe annihilator of $M$ is\n\\begin{equation*}\n\\begin{aligned}\n\\Ann\\left(M\\right) = \\bigcap_{m\\in M} \\Ann\\left(m\\right) = \\left\\{r\\in R| r\\cdot m = 0 \\forall m\\in M\\right\\}\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{rem}\n$\\Ann\\left(m\\right)$ is an ideal of $R$ (so $\\Ann\\left(M\\right)$ is too).\n\\end{rem}\n\n\\begin{defi}\nIf $M$ is a $R-$module and $m\\in M$, the \\emph{submodule granted by $m$} is\n\\begin{equation*}\n\\begin{aligned}\nR_m = \\left\\{r\\cdot m \\in M | r\\in R\\right\\}\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\nConsider the $R-$module homomorphism\n\\begin{equation*}\n\\begin{aligned}\n\\varphi:\\left(\n\\begin{array}{ll}\nR &\\to M\\\\\nr &\\to r\\cdot m\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\nHere\n\\begin{equation*}\n\\begin{aligned}\n&R_m = Im\\left(\\varphi\\right)\\\\\n&\\Ann\\left(m\\right) = \\ker\\left(\\varphi\\right)\n\\end{aligned}\n\\end{equation*}\nSo\n\\begin{equation*}\n\\begin{aligned}\nR_m \\cong R/\\Ann\\left(m\\right)\n\\end{aligned}\n\\end{equation*}\n\n\\begin{defi}\nSay an $R-$module $M$ is \\emph{finitely generated} if there are elements $m_1,...,m_k$ s.t.\n\\begin{equation*}\n\\begin{aligned}\nM&=R_{m_1} + R_{m_2} + ... + R_{m_k}\\\\\n&= \\left\\{r_1 m_1 + r_2 m_2 + ... + r_k m_k|r_1,r_2,...,r_k\\in R\\right\\}\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{lemma}\nA $R-$module $M$ is finitely generated if and only if there is a surjective $R-$module homomorphism\n\\begin{equation*}\n\\begin{aligned}\nf: R^k \\to M\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nIf $M=R_{m_1}+...+R_{m_k}$, define\n\\begin{equation*}\n\\begin{aligned}\nf:\\left(\n\\begin{array}{ll}\nR^k &\\to M\\\\\n\\left(r_1,...,r_k\\right) &\\to r_1 m_1 + r_2 m_2 + ... + r_k m_k\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\nThis is a $R-$module map. This \\emph{is} surjective by the definition of $M$.\\\\\nConversely, given a surjection $f:R^k \\to M$, let\n\\begin{equation*}\n\\begin{aligned}\nM_i = f\\left(0,0,...,0,1,0,...,0\\right)\n\\end{aligned}\n\\end{equation*}\nwhere the 1 is in the $i^{th}$ position.\\\\\nLet $m\\in M$. As $f$ is surjective, $m=f\\left(r_1,r_2,...,r_k\\right)$ for some $r_1,...,r_k$.\\\\\nThen write\n\\begin{equation*}\n\\begin{aligned}\nf\\left(r_1,...,r_k\\right) &= f\\left(\\left(r_1,0,...,0\\right) + \\left(0,r_2,0,...,0\\right)+...+\\left(0,0,...,0,r_k\\right)\\right)\\\\\n&=f\\left(r_1\\cdot 1,0,...,0\\right)+f\\left(0,r_2\\cdot 1,0,...,0\\right) + ... + f\\left(0,...,0,r_k\\cdot 1\\right)\\\\\n&=r_1 f\\left(1,0,...,0\\right) + r_2 f\\left(0,1,0,...,0\\right) + ... + r_k\\left(0,...,0,1\\right)\\\\\n&=r_1 m_1 + r_2 m_2 + ... + r_k m_k\n\\end{aligned}\n\\end{equation*}\nSo the $m_i$'s generate $M$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}\nIf $N\\leq M$ and $M$ is finitely generated, then $M/N$ is finitely generated.\n\\begin{proof}\n$m$ is finitely generated\\\\\n$\\implies$ there is a surjection  $f:R^k \\to M$\\\\\n$\\implies R^k \\to M \\to M/N$ (by $m\\to m+N$) (surjection)\n\\end{proof}\n\\end{coro}\n\n\\begin{eg}\nA submodule of a finitely generated module need not be finitely generated.\\\\\nLet\n\\begin{equation*}\n\\begin{aligned}\nR = \\C[x_1,x_2,x_3,...]\n\\end{aligned}\n\\end{equation*}\nLet $M=R$ be finitely generated (by 1). The submodule $I=\\left(x_1,x_2,...\\right)\\triangleleft R$ is not finitely generated (because finitely generated as a module implies finitely generated as an ideal, which it isn't).\n\\end{eg}\n\n\\begin{eg}\nFor $\\alpha\\in \\C$, $\\Z[\\alpha]$ is a finitely generated $\\Z$-module $\\iff$ $\\alpha$ is an algebraic integer (see example sheet).\n\\end{eg}\n\n\\subsection{Direct sums and free modules}\n\\begin{defi}\nIf $M_1,M_2,...,M_k$ are $R-$modules, the \\emph{direct sum}\n\\begin{equation*}\n\\begin{aligned}\nM_1 \\oplus M_2 \\oplus ... \\oplus M_k\n\\end{aligned}\n\\end{equation*}\nis the set\n\\begin{equation*}\n\\begin{aligned}\nM_1 \\times M_2 \\times ... \\times M_k\n\\end{aligned}\n\\end{equation*}\nwith addition\n\\begin{equation*}\n\\begin{aligned}\n\\left(m_1,m_2...,m_k\\right) + \\left(m'_1,m'_2,...,m'_k\\right) = \\left(m_1+m'_1,...,m_k+m'_k\\right)\n\\end{aligned}\n\\end{equation*}\nand $R$-module structure\n\\begin{equation*}\n\\begin{aligned}\nr\\cdot \\left(m_1,...,m_k\\right) = \\left(r\\cdot m_1,r\\cdot m_2,...,r\\cdot m_k\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{eg}\nWhat we have been calling $R^n$ is $R\\oplus R\\oplus...\\oplus R$ ($n$ times).\n\\end{eg}\n\n\\begin{defi}\nLet $m_1,m_2,...,m_k\\in M$. The set $\\left\\{m_1,...,m_k\\right\\}$ is \\emph{independent} if\n\\begin{equation*}\n\\begin{aligned}\n\\sum_{i=k}^m r_i m_i = 0 \\implies r_1 = r_2 = ... = r_k = 0\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{defi}\nA subset $S \\subset M$ \\emph{generates $M$ freely} if\\\\\n1) $S$ generates $M$;\\\\\n2) Any function $\\psi: S\\to N$ to a $R-$module extends to a $R-$module map $\\theta: M\\to N$.\\\\\nIf $\\theta_1$ and $\\theta_2$ are two of such extensions, consider $\\theta_1 - \\theta_2 : M\\to N$. Then $S\\subseteq \\ker\\left(\\theta_1 - \\theta_2\\right) \\leq M$. So the submodule generated by $S$ lies in $\\ker\\left(\\theta_1 - \\theta_2\\right)$ too. But 1) says $S$ generates $M$. So $M=\\ker\\left(\\theta_1 - \\theta_2\\right)$. So $\\theta_1 = \\theta_2$.\\\\\nA $R-$module freely generated by some subset $S\\subset M$ is called \\emph{free}, and $S$ is called a \\emph{basis}.\n\\end{defi}\n\n\\begin{prop}\nFor a subset $\\left\\{m_1,m_2,...,m_k\\right\\} \\subset M$, the following are equivalent:\\\\\n1) $S$ generates $M$ freely;\\\\\n2) $S$ generates $M$ and the set $S$ is independent;\\\\\n3) Every element of $M$ is \\emph{uniquely} expressible as\n\\begin{equation*}\n\\begin{aligned}\nr_1 m_1 + r_2 m_2 + ... + r_k m_k\n\\end{aligned}\n\\end{equation*}\nfor some $r_i \\in R$.\n\\begin{proof}\n$\\bullet$ 1) $\\implies$ 2):\\\\\nLet $S$ generate $M$ freely.\\\\\nIf $S$ is \\emph{not} independent, we have\n\\begin{equation*}\n\\begin{aligned}\n0=r_1 m_1 + ... + r_k m_k\n\\end{aligned}\n\\end{equation*}\nwith some $r_j \\neq 0$.\\\\\nLet\n\\begin{equation*}\n\\begin{aligned}\n\\psi: \\left(\n\\begin{array}{ll}\nS \\to &R\\\\\nm_j \\to &1_R\\\\\nm_i \\to &0  \\text{  } (i \\neq j)\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\na function.\\\\\nAs $S$ generates $M$ freely, this extends to a $R-$module homomorphism $\\theta: M\\to R$. Thus\n\\begin{equation*}\n\\begin{aligned}\n0=\\theta\\left(0\\right) &= \\theta\\left(r_1 m_1 + r_2 m_2 + ... + r_k m_k\\right)\\\\\n&= r_1 \\theta\\left(m_1\\right) + ... + r_k \\theta \\left(m_k\\right)\\\\\n&= r_j\\cdot 1_R \\in R\n\\end{aligned}\n\\end{equation*}\na contradiction as we supposed $r_j \\neq 0$.\n\nThe remaining steps are just as in Linear Algebra.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\nThe set $\\left\\{2,3\\right\\} \\in \\Z$ generates $\\Z$, but \\emph{not} freely, as $3\\cdot 2 + \\left(-2\\right) \\cdot 3$ = 0. So $S$ is not independent. So $S$ doesn't generate $\\Z$ freely. Also $\\left\\{2\\right\\}$ and $\\left\\{3\\right\\}$ do \\emph{not} generate $\\Z$.\n\\end{eg}\n\n\\begin{eg}\nThe $\\Z$-module $\\Z/2$ is not free.\\\\\nGenerating set: $\\left\\{1\\right\\}$, $\\left\\{0,1\\right\\}$.\\\\\n1) for $\\left\\{1\\right\\}$: Let\n\\begin{equation*}\n\\begin{aligned}\n\\psi: \\left(\n\\begin{array}{ll}\n\\left\\{1\\right\\} &\\to \\Z\\\\\n1 &\\to 1\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\nthis extends to \n\\begin{equation*}\n\\begin{aligned}\n\\theta: \\left(\n\\begin{array}{ll}\n\\Z/2 &\\to \\Z\\\\\n1 &\\to 1\\\\\n0=1+1 &\\to 1+1\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\nwhich is a contradiction since it's not a homomorphism.\\\\\nFor the second case is generally the same.\n\\end{eg}\n\n\\begin{lemma}\nIf $S=\\{m_1,...,m_k\\} \\subset M$ is freely generated, then $M \\cong R^k$ as an $R-$module.\n\\begin{proof}\nLet $f:R^k \\to M$ by $(r_1,...,r_k) \\to \\sum r_i m_i$ as $R-$module map. It is surjective as $\\{m_i\\}$ generate $M$, and is injective as the $m_i$ are independent.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}\nIf $M$ is a finitely generated $R-$module, we have shown that there is a surjective $R-$module homomorphism $\\varphi: R^k \\to M$.\\\\\nWe call $\\ker\\left(\\varphi\\right)$ the \\emph{relation module} for these generators.\\\\\nNow As $M \\cong R^k/\\ker(f)$, knowing $M$ is equivalent ot knowing the relation module.\\\\\nWe say $M$ is \\emph{finitely presented} if, in addition, $\\ker\\left(\\varphi\\right)$ is finitely generated.\\\\\nMore precisely, if $\\left\\{m_1, m_2, ... ,m_k\\right\\}$ generate $M$ and $\\left\\{n_1,n_2,...,n_l\\right\\}$ generate $\\ker\\left(\\varphi\\right)$, then each $n_i = \\left(r_{i1},r_{i2},...,r_{ik}\\right)$ corresponds to the relation\n\\begin{equation*}\n\\begin{aligned}\nr_{i1} m_1 + r_{i2} m_2 + ... + r_{ik} m_k = 0\n\\end{aligned}\n\\end{equation*}\nin $M$.\n\\end{defi}\n\n\\begin{prop} (Invariance of dimension (rank))\\\\\nLet $R$ be a non-zero ring. Then if $R^n \\cong R^m$ as a $R-$module, we must have $n=m$.\n\\begin{proof}\nWe know this is true if $R$ is a field (since they are vector spaces).\\\\\nGeneral construction: let $I\\triangleleft R$ be an ideal and $M$ a $R-$module. Define\n\\begin{equation*}\n\\begin{aligned}\nIM = \\left\\{ a\\cdot m \\in M | a\\in I, m\\in M\\right\\}\n\\end{aligned}\n\\end{equation*}\na submodule of $M$, so $M/IM$ is a $R-$module.\\\\\nIf $b\\in I$ then $b\\cdot \\left(m+I M\\right) = b\\cdot m + IM = 0 + IM$.\\\\\nSo $M/IM$ is a $R/I$-module via\n\\begin{equation*}\n\\begin{aligned}\n\\left(r+I\\right) \\cdot \\left(m+IM\\right) = r\\cdot m + IM\n\\end{aligned}\n\\end{equation*}\nGeneral property: every non-zero ring has a maximal ideal.\\\\\nObservation: an ideal $I\\triangleleft R$ is proper $\\iff $ $1_R \\not\\in I$.\\\\\nSo an increasing union of proper ideals is proper.\\\\\n(Fact: (Zorn's lemma applies) so there is a maximal ideal)\\\\\nBack to the proof: choose a maximal ideal $I\\triangleleft R$.\\\\\nIf $R^n \\cong R^m$, then $R^n/IR^n \\cong R^m / IR^m$, i.e. $\\left(R/I\\right)^n \\cong \\left(R/I\\right)^m$. But $I$ is maximal, so $R/I$ is a field. So this is an isomorphism between vector spaces over the spaces $R/I$. So $n=m$ by usual dimension theory from linear algebra.\n\\end{proof}\n\\end{prop}\n\n\\subsection{Matrices over Euclidean domains}\nUntil further notice, $R$ is a Euclidean domain, and write $\\phi: R\\backslash\\left\\{0\\right\\} \\to \\Z\\geq 0$ for its Euclidean function.\\\\\nWe know what $\\gcd(a,b)$ is for $a,b\\in R$ and is unique up to associates. The Euclidean algorithm using $\\phi$ shows that $\\gcd(a,b) = ax+by$ for some $x,y \\in R$.\n\n\\begin{defi} \n\\emph{Elementary row operations} on a $m\\times n$ matrix $A$ with entries in $R$ are\\\\\n(ER1) Add $c\\in R$ times the $i^{th}$ row to the $j^{th}$. This may be done by multiplying $A$ on the left by\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\n1 & & &  & \\\\\n  &1& &  c  &\\\\\n  & &1&  & \\\\\n  & & & ... & \\\\\n  & & &  &1\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nWhere $c$ is in the $j^{th}$ row and the $i^{th}$ column.\\\\\n(ER2) Swap the $i^{th}$ and the $j^{th}$ rows. This is done using\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\n1 & & &  & & \\\\\n  &0& &1 & &\\\\\n  & &1&  & &\\\\\n  &1& & 0& &\\\\\n  & & & & ...&\\\\\n  & & &  & & 1\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nWhere the two 1 are in the $(i,j)$ entry and the $(j,i)$ entry.\\\\\n(ER3) Multiply the $i^{th}$ row by a \\emph{unit} $c\\in R$, using\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\n1 & & &  & \\\\\n  &1& &  &\\\\\n  & &c&  & \\\\\n  & & & ... & \\\\\n  & & &  &1\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\nWhere $c$ is in the $(i,i)$ entry.\n\nWe have analogues for column operations, called (EC1),(EC2),(EC3).\n\n\\begin{defi}\n$A$ and $B$ are \\emph{equivalent} if they differ by a sequence of elementary row or column operations.\\\\\nIf $A$ and $B$ are equivalent, there are invertible (square) matrices $P$,$Q$ s.t. $B=QAP^{-1}$.\n\\end{defi}\n\n\\begin{thm} (Smith normal form)\\\\\nA $m\\times n$ matrix $A$ on a ED $R$ is equivalent to $\\Diag(d_1,d_2,...,d_r,0,...,0)$ with the $d_i$ all non-zero and\n\\begin{equation*}\n\\begin{aligned}\nd_1 | d_2 | ... | d_r\n\\end{aligned}\n\\end{equation*}\nThe $d_k$ are called \\emph{invariant factors} of $A$.\n\n\n\\begin{proof}\nif $A=0$ we are done. So suppose $A \\neq 0$.\\\\\nSo some entry $A_{ij}\\neq 0$. Swapping the $i^{th}$ and first row then $j^{th}$ and first column, we arrange that $A_{11} \\neq 0$.\\\\\nTry to reduce $\\varphi\\left(A_{11}\\right)$ as much as possible:\\\\\nCase 1) If there is a $A_{1j}$ not divisible by $A_{11}$, use Euclidean algorithm to write\n\\begin{equation*}\n\\begin{aligned}\nA_{1j} = q \\cdot A_{11} + r\n\\end{aligned}\n\\end{equation*}\nwith $\\varphi\\left(r\\right) < \\varphi\\left(A_{11}\\right)$.\\\\\nSubtract $q$ times the first column from the $j^{th}$ column. In position $\\left(1,j\\right)$, we now have $r$. Swapping $j^{th}$ and $1^{st}$ columns puts $r$ in position $\\left(1,1\\right)$, and so $\\varphi\\left(r\\right) < \\varphi\\left(A_{11}\\right)$.\\\\\nCase 2) If there is a $A_{i1}$ not divisible by $A_{11}$, do the analogous thing to reduce $\\varphi\\left(A_{11}\\right)$.\\\\\nAfter finitely many applications of Case 1 and Case 2, we get that $A_{11}$ divides all $A_{ij}$ and all $A_{i1}$.\\\\\nThen subtracting appropriate multiples of the first column  from all others makes $A_{1j} = 0$ for all $j$ apart from the first one. Do the same with rows. Then we have\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\nd&0&0&...&0\\\\\n0& & &   &\\\\\n0& & &  &\\\\\n...& & &C &\\\\\n0& & & &\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nCase 3) if there is an entry of $C$ not divisible by $d$, say $A_{ij}$ with $i>1, j>1$. Then write $A_{ij} = qd + r$, with $\\varphi\\left(r\\right) < \\varphi\\left(d\\right)$.\\\\\nNow add column 1 to column $j$, subtract $q$ times row 1 from row $i$, swap row $i$ with row 1, and swap column $j$ with column 1.Then the $\\left(1,1\\right)$ entry is $r$, and $\\varphi\\left(r\\right) < \\varphi\\left(d\\right)$.\\\\\nBut now the zeroes are messed up. So do case 1 and case 2 if necessary to get\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\nd'&0&0&...&0\\\\\n0& & &   &\\\\\n0& & &  &\\\\\n...& & & C'&\\\\\n\n0& & & &\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nBut now with $\\varphi\\left(d'\\right) \\leq \\varphi\\left(r\\right) < \\varphi\\left(d\\right)$.\\\\\nSince case 3 strictly decreases $\\varphi\\left(d\\right)$, it can only happen for finitely many times.\\\\\nTherefore, we arrive at\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\nd&0&0&...&0\\\\\n0& & &   &\\\\\n0& & &  &\\\\\n...& & &C &\\\\\n\n0& & & &\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nSuch that $d$ divides \\emph{every} entry of $C$ (this is because case 3 stops only if there is no entry of $C$ not divisible by $d$, by the condition).\\\\\nNow apply the entire process to $C$. We end up with a diagonal matrix with the claimed divisibility.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\n3&7&4\\\\\n1&-1&2\\\\\n3&5&1\n\\end{matrix}\n\\right)\n\\to\n\\left(\n\\begin{matrix}\n1&-1&2\\\\\n3&7&4\\\\\n3&5&1\n\\end{matrix}\n\\right)\n\\to\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n3&10&-2\\\\\n3&8&-5\n\\end{matrix}\n\\right)\n\\to\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n0&10&-2\\\\\n0&8&-5\n\\end{matrix}\n\\right)\n\\to\n\\end{aligned}\n\\end{equation*}\n\\begin{equation*}\n\\begin{aligned}\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n0&2&10\\\\\n0&5&8\n\\end{matrix}\n\\right)\n\\to\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n0&2&10\\\\\n0&1&-12\n\\end{matrix}\n\\right)\n\\to\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n0&1&-12\\\\\n0&2&10\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\to\n\\left(\n\\begin{matrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&34\n\\end{matrix}\n\\right)\n\\end{equation*}\n\\end{eg}\n\n\nTo study the uniqueness of the invariant factors (the $d_k$'s) of a matrix $A$, we will consider \\emph{minors}:\n\n\\begin{defi}\nA \\emph{$k\\times k$ minor} of a matrix $A$ is the determinant of a $k\\times k$ sub-matrix of $A$ (a matrix found by removing all but $k$ rows and all but $k$ columns).\\\\\nFor a matrix $A$, the \\emph{$k^{th}$ fitting ideal} called $\\Fit_k\\left(A\\right) \\triangleleft R$ is the ideal generated by the set of all $k\\times k$ minors of $A$.\n\\end{defi}\n\n\\begin{lemma}\nIf $A$ and $B$ are equivalent matrices, then\n\\begin{equation*}\n\\begin{aligned}\n\\Fit_k\\left(A\\right) = \\Fit_k\\left(B\\right)\n\\end{aligned}\n\\end{equation*}\nfor all $k$.\n\n\\begin{proof}\nWe just show that changing $A$ by the elementary row operations (or the column versions) doesn't change $\\Fit_k\\left(A\\right)$. We just need to consider the row operations as $\\Fit_k\\left(A\\right) = \\Fit_k\\left(A^T\\right)$.\\\\\nFor (ER1): Fix $C$ a $k\\times k$ minor of $A$. Let $B$ be the result of adding $c$ times the $i^{th}$ row to the $j^{th}$ row.\\\\\nIf the $j^{th}$ row is outside of $C$, then the minor is unchanged.\\\\\nIf $i^{th}$ and $j^{th}$ row are \\emph{in} $C$, then the sub-matrix changes by a row operation. But we know from linear algebra that a row operation doesn't change the determinant.\\\\\nIf $j^{th}$ row is in $C$ but the $i^{th}$ row is not, then $C$ is changed to $C'$ with $j^{th}$ row equal to\n\\begin{equation*}\n\\begin{aligned}\n\\left(C_{j1} + cf_1, C_{j2} + cf_2, ... , c_{jk} + cf_k\\right)\n\\end{aligned}\n\\end{equation*}\nWhere $f_1$, $f_2$, ... $f_k$ are the $i^{th}$ row.\\\\\nComputing $\\det\\left(C'\\right)$ using this row, we get $\\det \\left( C' \\right) = \\det\\left(C\\right) $ a minor $ + c \\det $(  matrix obtained by replacing the jth row of C with $ f_1, f_2,...,f_k)$ also a minor of A.\n\nSo $\\det \\left(C'\\right) \\in \\Fit_k\\left(A\\right)$.\\\\\n(ER2) and (ER3) follow by standard properties of swapping rows or multiplying rows on determinants.\\\\\nSo $\\Fit_k\\left(B\\right) \\leq \\Fit_k\\left(A\\right)$. But this also follows in the opposite direction as row operations are invertible. So they are equal.\n\\end{proof}\n\\end{lemma}\n\n\\begin{rem}\nif $B=\\Diag\\left(d_1,d_2,...,d_r,0,...,0\\right)$ is a matrix in its Smith Normal Form, then\n\\begin{equation*}\n\\begin{aligned}\n\\Fit_k \\left(B\\right) = \\left(d_1 d_2 ... d_n\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{rem}\n\n\\begin{coro}\nIf $A$ has Smith Normal Form $\\Diag\\left(d_1,d_2,...,d_r,0,...,0\\right)$ then $\\left(d_1 d_2 ... d_k\\right) = \\Fit_k\\left(A\\right)$, so $d_k$ is unique up to associates.\n\\end{coro}\n\n\\begin{eg}\nConsider\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\n2&0\\\\\n0&3\n\\end{matrix}\\right) = A\n\\end{aligned}\n\\end{equation*}\nThen\n\\begin{equation*}\n\\begin{aligned}\n\\Fit_1\\left(A\\right) = \\left(2,3\\right) = \\left(1\\right)\n\\end{aligned}\n\\end{equation*}\nSo $d_1 = \\pm 1$,\n\\begin{equation*}\n\\begin{aligned}\n\\Fit_2\\left(A\\right) = \\left(6\\right)\n\\end{aligned}\n\\end{equation*}\nSo\n\\begin{equation*}\n\\begin{aligned}\nd_1 d_2 = \\pm 6 \\implies d_2 = \\pm 6\n\\end{aligned}\n\\end{equation*}\nSo\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\n1& 0\\\\\n0& 6\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nis a Smith Normal Form for $A$.\n\\end{eg}\n\n\\begin{lemma}\nLet $R$ be a Euclidean Domain. Any submodule of $R^m$ is generated by at most $m$ elements.\n\\begin{proof}\nLet $N\\leq R^m$ be a submodule. Consider the ideal\n\\begin{equation*}\n\\begin{aligned}\nI= \\left\\{ r \\in R | \\left(r, r_2, ..., r_m\\right) \\in N  \\text{ for some  } r_2, ..., r_m \\in \\R\\right\\}\n\\end{aligned}\n\\end{equation*}\nAs $R$ is a ED, it is also a PID. So $I=\\left(a\\right)$ for some $a\\in R$.\\\\\nChoose a $n=\\left(a_1, a_2, ..., a_m\\right) \\in N$.\\\\\nFor a $\\left(r_1, r_2,..., r_m\\right) \\in N$, we know $a|r_1$, so $r_1 = r \\cdot a_1$, and\n\\begin{equation*}\n\\begin{aligned}\n\\left(r_1, r_2, ..., r_m\\right) - r\\left(a_1, a_2, ..., a_m\\right) = \\left(0, r_2-ra_2, ..., r_m-ra_m\\right)\n\\end{aligned}\n\\end{equation*}\nThis lies in $N' = N \\cap \\left(\\left\\{0\\right\\} \\times R^{m-1}\\right) \\leq R^{m-1}$.\\\\\nThen by induction we can suppose that there are $n_2, ... n_m \\in N'$ generating $N'$. Thus\n\\begin{equation*}\n\\begin{aligned}\n\\left(r_1,...,r_m\\right)\n\\end{aligned}\n\\end{equation*}\nlies in the submodule generated by $n,n_2,...,n_m$. Since $r_1,...,r_m$ are arbitrary, we know that $n,n_2,...,n_m$ generate $N$.\n\\end{proof}\n\\end{lemma}\n\n(missing 0.5 lecture?)\n\n\\begin{eg}\nLet $R = \\Z$ (a ED), and let $A$ be the abelian group (=$\\Z-$module) generated by $a,b,c$, subject to $2a+3b+c=0$, $a+2b=0$ and $5a+6b+7c=0$.\n\nThus $A = \\Z^3/N$ where $N \\leq \\Z^3$ generated by $(2,3,1)^T,(1,2,0)^T,(5,6,7)^T$.\n\nNow put $M=\\left(\\begin{matrix}\n2 & 1 & 5\\\\\n3 & 2 & 6\\\\\n1 & 0 & 7\n\\end{matrix}\\right)$ into Smith Normal form we get $(1,1,3)$. To show that, we just have to calculate the fitting ideals: $\\Fit_1(M) = (1)$, $\\Fit_2(M)=(1)$ and $\\Fit_3(M)=\\det(M) = 3$.\n\nAfter changing basis, $N$ is generated by $(1,0,0),(0,1,0),(0,0,3)$. So $A \\cong \\Z/3$.\n\\end{eg}\n\n\\subsubsection{Structure theorem for finitely-generated abelian groups}\nAny f.g. abelian group is isomorphic to $$C_{d_1} \\times C_{d_2} \\times ... \\times C_{d_r} \\times C_\\infty \\times C_\\infty \\times ... \\times C_\\infty$$ with $d_1|d_2|...|d_r$.\n\\begin{proof}\nApply classification of f.g. modules to the ED $R=\\Z$, and note $\\Z/(d)=C_d$ and $\\Z/(0) = C_\\infty$.\n\\end{proof}\n\n\\begin{lemma}\nLet $R$ be a ED, $a,b \\in R$ with $gcd(a,b) = 1$. Then $R/(ab)\\cong R/(a) \\oplus R/(b)$.\n\\begin{proof}\nConsider the $R-$module homomorphism\n\\begin{equation*}\n\\begin{aligned}\n\\phi: &R/(a) \\oplus R/(b) &\\to &R/(ab)\\\\\n&(r_1+(a),r_2+(b)) &\\to &(br_1+ar_2+(ab))\n\\end{aligned}\n\\end{equation*}\nAs $gcd(a,b) = 1$, $(a,b) = (1)$. So $1=xa+yb$ for some $x,y \\in \\Z$. So for $r \\in R$, we get $r= rxa+ryb$. So\n\\begin{equation*}\n\\begin{aligned}\nr+(ab) = rxa+ryb+(ab) = \\phi(ry+(a),rx+(b))\n\\end{aligned}\n\\end{equation*}\nSo $\\phi$ is onto.\n\nNow we also have to deal with injectivity (since $R/(ab)$ is not necessarily finite). If $\\phi(r_1+(a),r_2+(b))=0+(ab)$, then $br_1+ar_2 \\in (ab)$. Thus $a|br_1+ar_2$, so $a|br_1$, but $gcd(a,b)=1$, so $a|r_1$, so $r_1+(a) = 0+(a)$.\n\\end{proof}\n\\end{lemma}\n\n\\subsubsection{Primary decomposition theorem}\nLet $R$ be a ED, $M$ a f.g. $R-$module. Thus $M \\cong N_1 \\oplus ... \\oplus N_t$ with each $N_i$ either equal to $R$, or $R/(p^n)$ for some prime $p \\in R$ and some $n \\geq 1$.\n\\begin{proof}\nNote that if $d=p_1^{n_1}...p_k^{n_k}$ with $p_i \\in R$ \\emph{distinct} primes, then the previous lemma shows that $R/(d) \\cong R/(p_1^{n_1}) \\oplus ... \\oplus R/(p_k^{n_k})$. Plug this into the usual classification of f.g. modules we get the result.\n\\end{proof}\n\n\\subsection{Modules over $F[X]$, andnormal forms for matrices}\nFor any field $F$, $F[X]$ is a ED. So the results of the last section apply.\n\nIf $V$ is a vector space over $F$ and $\\alpha:V \\to V$ an endomorphism, then we have\n\\begin{equation*}\n\\begin{aligned}\n&F[X]\\times V &\\to &V\\\\\n&(f,v) &\\to &f(\\alpha)(v)\n\\end{aligned}\n\\end{equation*}\nwhich makes $V$ into a $F[X]-$module, call it $V_\\alpha$ (see section 3.1).\n\nLemma: if $V$ is finite-dimensional, then $V_\\alpha$ is finitely-generated as a $F[X]-$module.\n\n\\begin{eg}\n1) Suppose $V_\\alpha \\cong F[X]/(X^r)$ as a $F[X]-$module. This has $F-$basis $1,X,X^2,...,X^{r-1}$, and the action of $\\alpha$ on $V$ corresponds to multiplication by $X$.\n\nSo in this basis, $\\alpha$ has matrix with $A_{(i+1),i}=1$ and all other entries 0.\n\n2) Suppose $V_\\alpha \\cong F[X] / (X-\\lambda)^r)$is a $F[X]-$module. Consider $\\beta = \\alpha-\\lambda Id$, then\n\\begin{equation*}\n\\begin{aligned}\nV_\\beta \\cong F[Y] / (Y^n)\n\\end{aligned}\n\\end{equation*}\nas a $F[Y]-$module. So by (1), $V$ has a basis so that $\\beta$ is given by the above matrix. So $\\alpha$ is given by $\\Diag(\\lambda)+A$ where $A_{(i+1),i}=1$.\n\n3) Suppose $v_\\alpha \\cong F[X]/(f)$ with $f=a_0+a_1X+...+a_{r-1}X^{r-1}+X^r$. Then $1,X,...,X^{r-1}$ is a $F-$basis, and in this basis, $\\alpha$ is given by the $A$ in example (1) with an additional column $-a_0,-a_1,...,-a_{r-1}$ added rightmost. This matrix is called the \\emph{companion matrix} for $f_1$ and is written $C(f)$.\n\n\\subsubsection{Rational canonical form theorem}\nLet $\\alpha:V \\to V$ be a linear map, $V$ finite-dimensional vector space over $F$. Regards $V$ as a $F[X]-$module $V_\\alpha$, we have\n\\begin{equation*}\n\\begin{aligned}\nV_\\alpha \\cong F[X]/(d_1) \\oplus ... \\oplus F[X]/(d_r)\n\\end{aligned}\n\\end{equation*}\nwith $d_1 | d_2 | ... | d_r$. This there is a basi sof $V$ for which $\\alpha$ is given by $\\Diag(c(d_1),c(d_2),...,c(d_r))$. To prove this we can simply apply classification of f.g. modules over $F[X]$, an ED, and note that is(?) copies of $F[X]$ appear, as this has $\\infty$ dimension over $F$.\n\\end{eg}\n\nObservations:\\\\\n1) If $\\alpha$ is represented by a matrix $A$ in some basis, then $A$ is conjugate to $(\\Diag(c(d_1),...,c(d_r))$.\n2) The minimal polynomial for $\\alpha$ is $d_r \\in F[X]$.\\\\\n3) The characteristic polynomial of $\\alpha$ is $d_1d_2...d_r$.\n\n\\begin{lemma}\nThe primes in $\\C[X]$ are $X-\\lambda$ for $\\lambda \\in \\C$, up to associates.\n\\begin{proof}\nIf $f \\in \\C[X]$ is irreducible, Fundamental theorem of algebra says that $f$ has a root $\\lambda$, or $f$ is a constant. If it is constant it is $0$ or a unit $X$, so $X-\\lambda | f$, so $f=(X-\\lambda)g$. But $f$ is irreducible. So $g$ is a unit, so $f$ is an associate of $X-\\lambda$.\n\\end{proof}\n\\end{lemma}\n\nThe conjugacy classes in $GL_2(\\Z/3)$ are\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\n0 & 2\\\\\n1 & 0\n\\end{matrix}\\right),\\left(\\begin{matrix}\n0 & 1\\\\\n1 & 2\n\\end{matrix}\\right),\\left(\\begin{matrix}\n0 & 1\\\\\n1 & 1\n\\end{matrix}\\right),\\left(\\begin{matrix}\n\\lambda & 0\\\\\n1 & \\lambda\n\\end{matrix}\\right),\\left(\\begin{matrix}\n\\lambda & 0\\\\\n0 & \\mu\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nfor non-zero $\\lambda$ and $\\mu$.\n\nRecall \n\\begin{equation*}\n\\begin{aligned}\n|GL_2(\\Z/3)| = (9-1)(9-3) = 2^4 \\cdot 3\n\\end{aligned}\n\\end{equation*}\nso Sylow 2-subgroup has order $16=2^4$. The first matrix among the above 5 has order 4, the second and third have order 8, while for the fourth one, $\\lambda = 1$ has order 3 and $\\lambda =2$ has order 6, and the diagonal matrices has order 2. So Sylow 2-subgroup cannot be cyclic (order 16).\n\nNow let $A,B$ be the first and the second matrix respectively. Then\n\\begin{equation*}\n\\begin{aligned}\nA^{-1}BA =\\left(\\begin{matrix}\n2 & 2\\\\\n2 & 0\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nThis have to be some power of $B$ (since it's in the same conjugacy class as $B$). In fact it is equal to $B^3$.\n\nSo $\\left<B\\right> \\leq \\left<A,B\\right> \\leq GL_2(\\Z/3)$, and $\\left<B\\right> \\triangleleft \\left<A,B\\right>$.\n\nBy the second isomorphism theorem is $\\frac{\\left<A,B\\right>}{\\left<B\\right>} = \\frac{\\left<A\\right>}{\\left<A\\right> \\cap \\left<B\\right>}$. But\n\\begin{equation*}\n\\begin{aligned}\n\\left<A\\right> \\cap \\left<B\\right> = \\left<\\left(\\begin{matrix}\n2 & 0\\\\\n0 & 2\n\\end{matrix}\\right)\\right>\n\\end{aligned}\n\\end{equation*}\nis a group of order 2. But $\\left<A\\right>$ has order 4. So\n\\begin{equation*}\n\\begin{aligned}\n\\left|\\left<A,B\\right>/\\left<B\\right>\\right| = \\left|\\left<A\\right>/(\\left<A\\right>\\cap\\left<B\\right>)\\right| = 4/2 = 2\n\\end{aligned}\n\\end{equation*}\nso $\\left<A,B\\right>| = 2\\cdot 8 = 16$. So this is a Sylow 2-subgroup of $GL_2(\\Z/3)$. It is\n\\begin{equation*}\n\\begin{aligned}\n\\left<A,B | A^4 = I, B^8 = I, A^{-1}BA = B^3\\right>\n\\end{aligned}\n\\end{equation*}\na \\emph{semidihedral group of order 16}.\n\n\\begin{eg}\nLet $R=\\Z[X]/(X^2+5)$, which we wish to show, that it is equal to $\\Z[-5] \\leq \\C$. Then\n\\begin{equation*}\n\\begin{aligned}\n(1+X)(1-X) =1-X^2 = 1+5 = 6 = 2 \\cdot 3\n\\end{aligned}\n\\end{equation*}\nwhile $1 \\pm X$, $2,3$ are all irreducible, so $R$ is \\emph{not} a UFD. Let \n\\begin{equation*}\n\\begin{aligned}\nI_1 = (3,1+X), I_2 =(3,1-X)\n\\end{aligned}\n\\end{equation*}\nbe ideals (submodules) of $R$. Consider\n\\begin{equation*}\n\\begin{aligned}\n\\phi: I_1 \\oplus I_2 &\\to R\\\\\n(a,b) &\\to a+b\n\\end{aligned}\n\\end{equation*}\nan $R-$module map. Then\n\\begin{equation*}\n\\begin{aligned}\n\\im(\\phi) = (3,1+X,1-X)\n\\end{aligned}\n\\end{equation*}\nBut $3-((1+X)+(1-X))=1$. So this is the whole ring.\n\nAlso $\\ker(\\phi) = \\{(a,b) \\in I_1 \\oplus I_2 | a+b=0\\} \\cong I_1 \\cap I_2$ by sending $x$ back to $(x,-x)$. Hence\n\\begin{equation*}\n\\begin{aligned}\n(3) \\subset I_1 \\cap I_2\n\\end{aligned}\n\\end{equation*}\nLet $s \\cdot 3 + t(1-x) \\in (3,1-X) \\subset R=\\Z[X] / (X^2+5)$.\n\nWorking module $(3)$ as well, get\n\\begin{equation*}\n\\begin{aligned}\nt(1+X) = (1-X)p \\pmod {(3,X^2+5) = (3,X^2-1) = (3,(X-1)(X+1)}.\n\\end{aligned}\n\\end{equation*}\nSo $1-X|t$, so $(1+X)(1-X)|t(1+X)$, so $t(1+X)=q(X^2-1)=q(X^2+5-6)$ i.e. $t(1+X) = 3(-2q)$.\n\nTherefore $s \\cdot 3 + t(1+X)$ is divisible by $3$, so $I_1 \\cap I_2 \\subset (3)$, so equality.\n\nBy Example sheet 4 Q1(iii), if we have module $N \\leq M$ and $M/N \\cong \\R^n$, then $M \\cong N \\oplus R^n$.\n\nSo hence, $I_1 \\oplus I_2 / \\ker(\\phi) \\cong \\im(\\phi)=R$, so $I_1 \\oplus I_2 \\cong R \\oplus \\ker(\\phi) = R \\oplus (3)$.\n\nConsider\n\\begin{equation*}\n\\begin{aligned}\n\\psi: R &\\to (3)\\\\\nx &\\to 3x\n\\end{aligned}\n\\end{equation*}\n$\\ker(\\psi) = \\{x \\in R|3x=0\\} = 0$ as $R$ is an integral domain. So $\\psi$ is an isomorphism. So $I_1 \\oplus I_2 \\cong R \\oplus R$.\n\nWe claim that $I_1$ is not principal. If $I_1 = (a+bX)$, then $I_2 = (a-bX)$. Then\n\\begin{equation*}\n\\begin{aligned}\n(3) = I_1 \\cap I_2 = ((a+bX)(a-bX)) = (a^2-bX^2) = (a^2+5b^2)\n\\end{aligned}\n\\end{equation*}\nso $3 \\in (a^2+5b^2)$, so $3=(a^2+5b^2)(c+dX)$, so $a^2 + 5b^2 |3$. Contradiction. So $I_1$ cannot be principal, so $I_2$ cannot be as well. But now:\n\n$\\bullet$ $I_1$ need 2 eleemnts to generate it, but it is not the free module $R^2$;\\\\\n$\\bullet$ $I_1$ \\emph{is} a direct summand of $R^2$.\n\n\\end{eg}\n\n\\end{document}\n", "meta": {"hexsha": "4130efbaa88c641905522c273207ea33ffc8bf94", "size": 113474, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/GRM.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/GRM.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/GRM.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5264285714, "max_line_length": 471, "alphanum_fraction": 0.6352556533, "num_tokens": 45828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7931059609645724, "lm_q1q2_score": 0.4458655339667317}}
{"text": "\\documentclass[11pt,a4paper,fleqn]{scrartcl}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[colorlinks=true, citecolor=blue, linkcolor=blue, filecolor=blue,urlcolor=blue]{hyperref}\n\\hypersetup{\n     colorlinks   = true,\n     citecolor    = gray\n}\n\\usepackage{wrapfig}\n\n\\usepackage{caption}\n\\captionsetup{format=plain, indent=5pt, font=footnotesize, labelfont=bf}\n\n\\setkomafont{disposition}{\\scshape\\bfseries}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n%\\usepackage{bbm}\n% \\usepackage{mathtools}\n% \\usepackage{epsfig}\n% \\usepackage{grffile}\n%\\usepackage{times}\n%\\usepackage{babel}\n\\usepackage{tikz}\n\\usepackage{paralist}\n\\usepackage{color}\n\\usepackage[top=3cm, bottom=2.5cm, left=2.5cm, right=3cm]{geometry}\n%\\setlength{\\mathindent}{1ex}\n\n% PGF\n\\usepackage{pgfplots}\n\\usepackage{pgf}\n\\usepackage{siunitx}\n\\usepackage{xfrac}\n\\usepackage{calculator}\n\\usepackage{calculus}\n\\usepackage{eurosym}\n\\usepackage{booktabs}\n%\\sisetup{per-mode=fraction,%\n%\tfraction-function=\\sfrac}\n\n%\\newcommand{\\eur}[1]{\\EUR{#1}\\si{\\per\\kilo\\meter}}\n\\pgfplotsset{\n  compat=newest,\n  every axis/.append style={small, minor tick num=3}\n}\n\n%\\usepackage[backend=biber,style=alphabetic,url=false,doi=false]{biblatex}\n%\\addbibresource{sheet01_biber.bib}\n% \\addbibresource{/home/coroa/papers/refs.bib}\n\n\\newcommand{\\id}{\\mathbbm{1}}\n\\newcommand{\\NN}{{\\mathbbm{N}}}\n\\newcommand{\\ZZ}{{\\mathbbm{Z}}}\n\\newcommand{\\RR}{{\\mathbbm{R}}}\n\\newcommand{\\CC}{{\\mathbbm{C}}}\n\\renewcommand{\\vec}[1]{{\\boldsymbol{#1}}}\n\n\\renewcommand{\\i}{\\mathrm{i}}\n\n\\newcommand{\\expect}[1]{\\langle\\,#1\\,\\rangle}\n\\newcommand{\\e}[1]{\\ensuremath{\\,\\mathrm{#1}}}\n\n\\renewcommand{\\O}{\\mc{O}}\n\\newcommand{\\veps}{\\varepsilon}\n\\newcommand{\\ud}[1]{\\textup{d}#1\\,}\n\n\\newcommand{\\unclear}[1]{\\color{green}#1}\n\\newcommand{\\problem}[1]{\\color{red}#1}\n\\newcommand{\\rd}[1]{\\num[round-mode=places,round-precision=1]{#1}}\n\n%\\DeclareSIUnit{\\euro}{\\EUR}\n\\DeclareSIUnit{\\dollar}{\\$}\n\\newcommand{\\eur}{\\text{\\EUR{}}}\n\n\\usepackage{palatino}\n\\usepackage{mathpazo}\n\\setlength\\parindent{0pt}\n\\usepackage{xcolor}\n\\usepackage{framed}\n\\definecolor{shadecolor}{rgb}{.9,.9,.9}\n\n\\def\\cap{\\text{Cap}}\n\\def\\floor{\\text{Floor}}\n\\def\\l{\\lambda}\n\\def\\m{\\mu}\n\\def\\d{\\partial}\n\\def\\cL{\\mathcal{L}}\n\\def\\co2{CO${}_2$}\n\n\\def\\mw{\\text{ MW}}\n\\def\\mwh{\\text{ MWh}}\n\\def\\gw{\\text{ GW}}\n\\def\\gwh{\\text{ GWh}}\n\\def\\emwh{\\text{ \\euro/MWh}}\n\\def\\bemwh{\\text{ [\\euro/MWh]}}\n\\newcommand{\\ubar}[1]{\\text{\\b{$#1$}}}\n\n%=====================================================================\n%=====================================================================\n\\begin{document}\n\n\\begin{flushright}\n  \\textbf{Energy System Modelling }\\\\\n  {\\small Karlsruhe Institute of Technology}\\\\\n  {\\small Institute for Automation and Applied Informatics}\\\\\n  {\\small Summer Term 2020}\\\\\n \\end{flushright}\n \n  \n  \\vspace{-0.5em}\n  \\hrulefill\n  \\vspace{0.3em}\n \n \\begin{center}\n  \\textbf{\\textsc{\\Large Solutions IV: Electricity Markets}}\\\\\n  \\small Will be worked on in the exercise session on Friday, 25 June 2020.\\\\[1.5em]\n \\end{center}\n \n\n \\vspace{-0.5em}\n \\hrulefill\n \\vspace{0.8em}\n \n\n%=============== ======================================================\n\\paragraph{Solution IV.1 \\normalsize (Shadow prices of limits on consumption).}~\\\\\n%=====================================================================\n\nSuppose that the utility for the electricity consumption of an industrial company is given by\n\\[\nU(d) = 70d - 3d^2 [\\textrm{\\euro}/\\si{\\hour}] \\quad , \\quad d_{min}=2\\leq d \\leq d_{max}=10,\n\\]\nwhere $d$ is the demand in MW and $d_{min}, d_{max}$ are the minimum and maximum demand. \\\\\n[1em]\nAssume that the company is maximising its net surplus for a given electricity price $\\pi$, i.e. it maximises $\\max_{d} \\left[U(d) -\n\\pi d\\right]$.\n\\begin{enumerate}[(a)]\n \\begin{shaded} \\item If the price is $\\pi = 5$~\\euro/MWh, what is the optimal\n  demand $d^*$?  What is the value of the KKT multiplier $\\mu_{max}$\n  for the constraint $d \\leq d_{max}=10$ at this optimal solution?\n  What is the value of $\\mu_{min}$ for $d \\geq d_{min} = 2$?\\end{shaded}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n We convert the exercise to an optimisation problem with objective\n \\begin{align}\n  &f(d) = U(d) - \\pi d = (70-\\pi) d - 3d^2 \\\\\n  &\\max\\limits_{d \\in \\mathbb{R}} \\ f(d)\n \\end{align}\n\n with constraints\n \\begin{align}\n  d  & \\leq d_{max} = 10 \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\m_{max}  \\\\\n  -d & \\leq -d_{min} = -2 \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\m_{min}\n \\end{align}\n \\rule{\\textwidth}{0.4pt}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n From stationarity for the optimal point we get:\n \\begin{align}\n  0 & =   \\frac{\\d \\mathcal{L}}{\\d d} = \\frac{\\d f}{\\d d} - \\sum_{i} \\lambda_i^* \\frac{\\d g_i}{\\d d} -  \\sum_{j} \\mu_j^* \\frac{\\d h_j}{\\d d}\\\\\n  0 & =   \\frac{\\d}{\\d d} \\left((70-\\pi) d - 3d^2 \\right) - \\m_{max} + \\m_{min} \\\\\n    & =  (70-\\pi) - 6d - \\m_{max} + \\m_{min} \\label{eq:2stat}\n \\end{align}\n\n Note that it does not matter whether you pull in the constant of the right-hand side of the respective constraint.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics{graph_u_problem1.pdf}\n\t\\caption{utility for the electricity consumption with demand d}\n\t\\label{fig:solution04tutorial}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n The marginal utility curve is $U'(d) = 70 - 6d$ [\\euro/MWh]. At\n $\\pi = 5$ and if the demand were unconstrained, the demand would be determined by $5=70-6d$, i.e. $d =\n  65/6 = 10.8333$, which is above the consumption limit\n $d_{max} = 10$. Therefore the optimal demand is \\\\\n  $d^* = 10$,\\\\\n   the upper limit is binding such that $\\mu_{max} \\geq 0$ and the lower limit is non-binding such that\\\\\n    $\\mu_{min} = 0$. \\\\\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n To determine the value of $\\mu_{max}$ we use \\eqref{eq:2stat} to get\n \\begin{equation*}\n\t\\m_{max} =  (70-\\pi) - 6d^* - \\mu_{min} =  70 - 5 -60 = 5\n \\end{equation*}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n \\begin{shaded}\n  \\item Suppose now the electricity price is $\\pi = 60$~\\euro/MWh. What are\n  the optimal demand $d^*$, $\\mu_{max}$ and $\\mu_{min}$ now?\n \\end{shaded}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n At $\\pi = 60$, the demand would be determined by $60=70-6d$, i.e. $d = 10/6 = 1.667$, which is below the consumption limit $d_{min} = 2$. Therefore the optimal demand is \\\\\n  $d^* = 2$,\\\\\n   the upper limit is non-binding such that\\\\\n    $\\mu_{max}= 0$\\\\\n and the lower limit is binding such that $\\mu_{min} \\geq 0$.\n\n To determine the value of $\\mu_{min}$ we use \\eqref{eq:2stat} to get\n \\begin{equation*}\n   \\m_{min} = -(70-\\pi) + 6d^* + \\mu_{max} = -(70 - 60) + 12 + 0 = 2.\n \\end{equation*}\n \n \\newpage\n\\end{enumerate}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%=============== ======================================================\n\\paragraph{Solution IV.2 \\normalsize (Economic dispatch in a single bidding zone).}~\\\\\n%=====================================================================\n\nConsider an electricity market with two generator types, one with the cost function $C_1(g_1)=c_1g_1$ with variable cost $c_1 = 20\\emwh$, capacity $G_1 = 300\\mw$ and a dispatch rate of $g_1$~[MW], and another with the cost function $C_2(g_2)=c_2g_2$ with variable cost $c_2=50\\emwh$, capacity $G_2=400\\mw$ and a dispatch rate of $g_2$~[MW]. The demand has utility function $U(d) = 8000d - 5d^2$~[\\euro/h] for a consumption rate of $d$~[MW].\n\\begin{enumerate}[(a)]\n \\begin{shaded}\\item What are the objective function and constraints required for an optimisation problem to maximise short-run social welfare in this market?\\end{shaded}\n\n The optimisation problem has the objective function:\n \\begin{align*}\n &f(d, g_1, g_2) =  U(d) - C_1(g_1) - C_2(g_2) = 8000d-5d^2 - c_1g_1 - c_2g_2 \\\\\n & \\max_{d,g_1,g_2}f(d, g_1, g_2)\n \\end{align*}\n with constraints:\n \\begin{align*}\n  d - g_1 - g_2 & = 0 \\leftrightarrow \\l              \\\\\n  g_1           & \\leq G_1 \\leftrightarrow \\bar{\\m}_1 \\\\\n  g_2           & \\leq G_2 \\leftrightarrow \\bar{\\m}_2 \\\\\n  -g_1          & \\leq 0 \\leftrightarrow \\ubar{\\m}_1  \\\\\n  -g_2          & \\leq 0 \\leftrightarrow \\ubar{\\m}_2\n \\end{align*}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n \\begin{shaded}\\item Write down the Karush-Kuhn-Tucker (KKT) conditions for this problem.\\end{shaded}\n\n\\textbf{ Stationarity} gives for $d$:\n \\begin{align*}\n   0 & =   \\frac{\\d \\mathcal{L}}{\\d d} = \\frac{\\d f}{\\d d} - \\sum_{i} \\lambda_i^* \\frac{\\d g_i}{\\d d} -  \\sum_{j} \\mu_j^* \\frac{\\d h_j}{\\d d}\\\\\n   &= \\frac{\\d U}{\\d d} - \\l \\\\\n   & = 8000 - 10d - \\l \n \\end{align*}\n Stationarity for $g_1$ gives:\n \\begin{equation*}\n  -\\frac{\\d C_1}{\\d g_1} + \\l - \\bar{\\m}_1 + \\ubar{\\m_1}  =  -c_1+ \\l - \\bar{\\m}_1 + \\ubar{\\m_1} = 0\n \\end{equation*}\n Stationarity for $g_2$ gives:\n \\begin{equation*}\n  -\\frac{\\d C_2}{\\d g_2} + \\l - \\bar{\\m}_2 + \\ubar{\\m_2}  =  -c_2+ \\l - \\bar{\\m}_2 + \\ubar{\\m_2} = 0\n \\end{equation*}\n\\textbf{ Primal feasibility} is just the generator limits above in (a). \\\\\n \\textbf{Dual feasibility} is $\\bar{\\m}_i^*,\\ubar{\\m}_i^* \\geq 0$ and \\\\\n  \\textbf{complementary slackness} is $\\bar{\\m}_i^*(g_i^*-G_i) = 0$ and $\\ubar{\\m}_i^* g_i^* = 0$ for $i=1,2$.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n \\begin{shaded}\\item Determine the optimal rate of production of the generators and the value of all KKT multipliers. What is the interpretation of the respective KKT multipliers?\\end{shaded}\n The marginal utility at the full output of the generators,\n \\begin{align*}\n &G_1 + G_2 = 300\\ \\text{MW} + 400\\ \\text{MW} = 700\\ \\text{MW} \\\\\n &U'(700) = 8000 - 10\\cdot700 = 1000\\ \\text{\\euro/MWh}\n \\end{align*}  \n which is higher than the costs $c_i$, so we'll find optimal rates\n \\begin{align*}\n g_1^* &= G_1 = 300 \\ \\text{MW} \\\\\n g_2^* &= G_2 = 400 \\ \\text{MW} \\\\\n d^* &= G_1+G_2 = 700\\ \\text{MW} \n \\end{align*}\nThis means (from stationarity)\n\\begin{equation*}\n\\l^*= \\frac{\\d U}{\\d d} \\bigg|_{d=d^*} = 8000 - 10d^* = 1000 \\text{\\euro/MWh},\n\\end{equation*} \nwhich is the market price. Because the lower constraints on the generator output are not binding, from complementary slackness we have $\\ubar{\\m}_i = 0$. The upper constraints are binding, so $\\bar{\\m}_i \\geq 0$. \\\\\n From stationarity $\\bar{\\m}_i =\n  \\l - c_i + \\ubar{\\m}_i$, which is the increase in social welfare if Generator $i$\n could increase its capacity by a marginal amount.\n\n $$\\bar{\\m}_1=1000-20=980 \\text{\\euro/MWh}$$\n $$\\bar{\\m}_2=1000-50=950 \\text{\\euro/MWh}$$\n\n\\end{enumerate}\n\\newpage\n%=============== ======================================================\n\\paragraph{Solution IV.3 \\normalsize (efficient dispatch in a two-bus power system).}~\\\\\n%=====================================================================\n\n\\begin{figure}[h]\n \\centering\n \\includegraphics[width=14cm]{two-bus}\n \\caption{A simple two-bus power system.}\n \\label{twobus}\n\\end{figure}\n\nConsider the two-bus power system shown in Figure \\ref{twobus}, where the two nodes represent two markets, each with different total demand $D_i$, and one generator at each node producing $G_i$. At node A the demand is $D_A = 2000 \\si{\\mega\\watt}$, whereas at node B the demand is $D_B = 1000 \\si{\\mega\\watt}$. Furthermore, there is a transmission line with a capacity denoted by $F_{AB}$. The marginal cost of production of the generators connected to buses A and B are given respectively by the following expressions:\n\\begin{align*}\n MC_A & = 20 + 0.03 P_A \\hspace{1cm}\\eur/\\si{\\mega\\watt\\hour}  \\\\\n MC_B & = 15 + 0.02 P_B \\hspace{1cm} \\eur/\\si{\\mega\\watt\\hour}\n\\end{align*}\n\nAssume that the demands $D_A$ and $D_B$ are constant and insensitive to price, that energy is sold at its marginal cost of production and that there are no limits on the output of the generators.\n\n\\begin{enumerate}[(a)]\n \\begin{shaded}\\item Calculate the price of electricity at each bus, the production\n  of each generator, and the flow on the line for the following cases. You may also calculate the values of any KKT multiplier as a bonus.\\end{shaded}\n\nThe price of electricity is the value of the dual variable at the nodal balance equation.\n\n Use the following nomenclature: price $\\lambda_{A/B}$, generation $G_{A/B}$, flow $F_{AB}$.\n \\begin{enumerate}[(i)]\n  \\begin{shaded}\\item The line between buses A and B is disconnected.\\end{shaded}\n\n  Where to start: $P_A=D_A$ and $P_B=D_B$ and substitute into $MC_i$.\n\n  $\\l_A= 80\\emwh$, $\\l_B=35\\emwh$,\n\n  $G_{A}=2000$ MW, $P_B=1000$ MW, $F_{AB}=0$\n\n  \\begin{shaded}\\item The line between buses A and B is in service and has an unlimited capacity.\\end{shaded}\n  \n  Where to start:\n  No restriction in transmission, so prices must be the same for the two nodes: $\\l_A = \\l_B$, therefore, $MC_A = MC_B$.\n  Also: $P_A+P_B = D_A+D_B$.\n\n    $\\l_A= 53\\emwh$, $\\l_B=53\\emwh$,\n\n  $G_{A}=1100\\mw$, $P_B=1900$ MW, $F_{AB}=-900\\mw$\n\n  \\begin{shaded}\\item The line between buses A and B is in service and has an unlimited capacity, but the maximum output of Generator B is 1500~MW.\\end{shaded}\n  \n  Where to start:\n  $P_B=1500$ MW since it is now constrained but would have been higher in the unconstrained case (ii). \n  Also, since there are no transmission constraints: $\\l_A = \\l_B$.\n  Also: $P_A+P_B = D_A+D_B$.\n\n    $\\l_A= 65\\emwh$, $\\l_B=65\\emwh$,\n\n  $G_{A}=1500\\mw$, $P_B=1500$ MW, $F_{AB}=-500\\mw$\n\n  \\begin{shaded}\\item The   line between buses A and B is in service and has an unlimited capacity, but the maximum output of Generator A is 900~MW. The output of Generator B is unlimited.\\end{shaded}\n  \n  Where to start: \n  $P_A=900$ MW since it is now constrained but would have been higher in the unconstrained case (ii). \n  Also, since there are no transmission constraints: $\\l_A = \\l_B$.\n  Also: $P_A+P_B = D_A+D_B$.\n\n    $\\l_A= 57\\emwh$, $\\l_B=57\\emwh$,\n\n  $G_{A}=900\\mw$, $P_B=2100$ MW, $F_{AB}=-1100\\mw$\n\n  \\begin{shaded}\\item The line between buses A and B is in service but its capacity is limited to 600~MW. The output of the generators is unlimited.\\end{shaded}\n  \n    Where to start:\n    $F_{AB} = - 600$ MW since we would want even more transmission, if it were not constrained.\n    Also, $P_A+F_{AB}=2000$ MW.\n\n    $\\l_A= 62\\emwh$, $\\l_B=47\\emwh$,\n\n  $G_{A}=1400\\mw$, $P_B=1600$ MW, $F_{AB}=-600\\mw$\n \\end{enumerate}\n \\begin{shaded}\\item Calculate the generator revenues, generator profits, consumer payments and consumer net surplus for all the cases considered in the above problem. Who benefits from the line connecting these two buses?\\end{shaded}\n Generator revenues $R_{i}$, generator costs $C_{i}$, generator profits $P_{i}$, consumer payments $E_{i}$. Find the generator profits by subtracting the costs from the revenue. Costs are given by integrating the marginal cost, i.e. $C_A = 20P_A + 0.015P_A^2$ and $C_B = 15P_B + 0.01P_B^2$. The generator at $B$ and the consumers at $A$ benefit from the line (price increases at $B$, decreases at $B$).\n \\begin{table}[!h]\n  \\centering\n  \\begin{tabular}{lrrrrr}\n   \\toprule\n   Case          & (i)      & (ii)     & (iii)    & (iv)     & (v)      \\\\\n   \\midrule\n   $E_A$ (\\euro) & 160,000 & 106,000 & 130,000 & 114,000 & 124,000 \\\\\n   $R_A$ (\\euro) & 160,000 & 58,300  & 97,500  & 51,300  & 86,800  \\\\\n   $C_A$ (\\euro) & 100,000 & 40,150  & 63,750  & 30,150  & 57,400  \\\\\n   $P_A$ (\\euro) & 60,000  & 18,150  & 33,750  & 21,150  & 29,400  \\\\\n   \\midrule\n   $E_B$ (\\euro) & 35,000  & 53,000  & 65,000  & 57,000  & 47,000  \\\\\n   $R_B$ (\\euro) & 35,000  & 100,700 & 97,500  & 119,700 & 75,200  \\\\\n   $C_B$ (\\euro) & 25,000  & 64,600  & 45,000  & 75,600  & 49,600  \\\\\n   $P_B$ (\\euro) & 10,000  & 36,100  & 52,500  & 44,100  & 25,600  \\\\\n   \\bottomrule\n  \\end{tabular}\n \\end{table}\n\n \\begin{shaded}\\item Calculate the congestion surplus for case (v). For what values of the flow on the line between buses A and B is the congestion surplus equal to zero?\\end{shaded}\n Congestion surplus is 9000 \\euro:\n \\begin{equation*}\n  \\left(E_A + E_B\\right) - (R_A + R_B) = |F_{AB}|\\times (\\l_A - \\l_B)\n \\end{equation*}\n Congestion surplus is equal to zero when the flow $F_{AB}=0$, or when it is equal to the unconstrained value $F_{AB}=-900\\mw$ (then $\\l_A = \\l_B$).\n\\end{enumerate}\n\n\n\\end{document}\n", "meta": {"hexsha": "0db7c6a4692aad10e662d8fd58a77b5bf3864c62", "size": 16495, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Tutorials/04-tutorial-25.06.2020/worksheet/solution04.tex", "max_stars_repo_name": "pitmonticone/EnergySystemModelling", "max_stars_repo_head_hexsha": "4179cea3b55b295cf6de971b6444bb3d8c957d9f", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2020-06-26T11:42:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T20:16:55.000Z", "max_issues_repo_path": "Tutorials/04-tutorial-25.06.2020/worksheet/solution04.tex", "max_issues_repo_name": "hmasrur/EnergySystemModelling", "max_issues_repo_head_hexsha": "4179cea3b55b295cf6de971b6444bb3d8c957d9f", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/04-tutorial-25.06.2020/worksheet/solution04.tex", "max_forks_repo_name": "hmasrur/EnergySystemModelling", "max_forks_repo_head_hexsha": "4179cea3b55b295cf6de971b6444bb3d8c957d9f", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-07-23T08:01:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-25T07:16:29.000Z", "avg_line_length": 42.8441558442, "max_line_length": 519, "alphanum_fraction": 0.6094574113, "num_tokens": 5569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7931059511841119, "lm_q1q2_score": 0.44586552846838656}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[charter]{mathdesign}\n\\usepackage{amsmath,amsthm,enumitem,graphicx,titlesec,xcolor}\n\\usepackage{microtype}\n\\usepackage[a4paper,margin=25mm]{geometry}\n\\usepackage[unicode]{hyperref}\n\n\\hypersetup{\n    hidelinks,\n    pdftitle={Distributed Algorithms},\n    pdfauthor={Juho Hirvonen and Jukka Suomela},\n}\n\n\\definecolor{titlecolor}{HTML}{0088cc}\n\\definecolor{hlcolor}{HTML}{f26924}\n\n\\newcommand{\\q}[2]{\\paragraph{\\mbox{Question #1: }#2.}}\n\\newcommand{\\sep}{{\\centering \\raisebox{-3mm}[0mm][0mm]{$*\\quad*\\quad*$}\\par}}\n\\newcommand{\\hl}[1]{\\textbf{\\emph{#1}}}\n\\newcommand{\\cemph}[1]{\\textcolor{hlcolor}{\\emph{#1}}}\n\\DeclareMathOperator{\\re}{re}\n\n\\setitemize{noitemsep,leftmargin=3ex}\n\n\\titleformat{\\paragraph}[runin] {\\normalfont\\normalsize\\bfseries\\color{titlecolor}}{\\theparagraph}{1em}{}\n\n\\begin{document}\n\n\\noindent\n\\emph{CS-E4510 Distributed Algorithms / Juho Hirvonen, Jukka Suomela\\\\\nexam, 26 February 2020}\n\n\\paragraph{Instructions.}\n\nThere is only one question, which is an open-ended small research project. Your answer has to demonstrate \\hl{at least} that you understand both the PN and LOCAL models of distributed computing, you can design efficient distributed algorithms, and you can also prove negative results; you do not need to do more than what is reasonable to expect to finish in \\hl{3 hours}.\n\nYou are free to look at any source material (this includes lecture notes, textbooks, and anything you can find with Google), but you are not allowed to collaborate with anyone else or ask for anyone's help (this includes collaboration with other students and asking for help in online forums). You are free to use any results from the lecture notes directly (including the results from the regular exercises). You are free to use computers and computer programs to find solutions.\n\n\\sep\n\n\\paragraph{Definition.}\n\nLet $G = (V,E)$ be a graph, and let $a$ and $b$ be real numbers. We say that a function $f\\colon V \\to [0,1]$ is an $(a,b)$-labeling if the following holds: for all edges $\\{u,v\\} \\in E$ we have got $a \\le \\bigl|f(u) - f(v)\\bigr| \\le b$.\n\n\\sep\n\n\\paragraph{Question.}\n\nYour task is to study distributed algorithms for finding $(a,b)$-labelings, for different values of parameters $a$ and $b$. You can first consider the case that graph $G$ is a \\hl{cycle}. What can you say about the problem in that case?\n\\begin{itemize}\n    \\item For what values of $a$ and $b$ a solution always exists in any cycle?\n    \\item For what values the problem cannot be solved at all in the deterministic PN model?\n    \\item For what values the problem can be solved in $O(1)$ rounds in the deterministic LOCAL model?\n    \\item For what values the problem can be solved in $o(n)$ rounds in the deterministic LOCAL model? [Note, it is small-$o$, not big-$O$.]\n    \\item For what values the problem requires $\\Omega(n)$ rounds in the deterministic LOCAL model?\n\\end{itemize}\nYou do not need to give a full characterization that covers all possible $(a,b)$ pairs, but you should be able to say at least something positive and something negative. If you have time or you run out of questions you can solve, you can also consider similar questions in other graph families, e.g.\\ \\hl{paths} or \\hl{trees}, and/or other models of computing, e.g., randomized PN or deterministic CONGEST.\n\n\\sep\n\n\\paragraph{Hints.}\n\nTo get started, you can consider e.g.\\ the following questions:\n\\begin{itemize}\n    \\item What does a $(0,0)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n    \\item What does a $(0,1)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n    \\item What does a $(1,1)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n    \\item What does a $(0.5,1)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n    \\item What does a $(0.1,0.1)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n    \\item What does a $(0.1,0.2)$-labeling look like in a cycle? Does it always exist, is it easy to find?\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "763aecf51b18b4e5f6480f3426a2e1328d13a244", "size": 4121, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/exam-2021-02-26.tex", "max_stars_repo_name": "suomela/da2020", "max_stars_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2020-12-11T00:47:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T15:46:43.000Z", "max_issues_repo_path": "exams/exam-2021-02-26.tex", "max_issues_repo_name": "suomela/da2020", "max_issues_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-17T18:31:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-17T18:42:16.000Z", "max_forks_repo_path": "exams/exam-2021-02-26.tex", "max_forks_repo_name": "suomela/da2020", "max_forks_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-22T03:53:31.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:33:40.000Z", "avg_line_length": 54.2236842105, "max_line_length": 480, "alphanum_fraction": 0.7367143897, "num_tokens": 1148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4458589073567642}}
{"text": "\\section{Variable selection}\\label{ssec:varselection}\n\n\\subsection{Synthetic controls variable weighting algorithm}\n\nIn this section we give further details about the variable weighting procedure of the synthetic controls algorithm, which we allude to in the primary paper. We also details about the types of tuning procedures that have been proposed using pre-treatment data, and again argue that these procedures may be sub-optimal when predicting the ETC. This is not meant to be a comprehensive treatment of these issues, but rather to more formally illustrate the problem of using pre-treatment data to conduct variable selection or variable weighting when estimating the ETC. For further details on the specifics of these ideas, we refer to \\cite{abadie2010synthetic}, \\cite{abadie2015comparative}, \\cite{kaul2015synthetic}.\n\nThe synthetic controls algorithm chooses the weights $\\gamma$ that minimizes the weighted L2-squared distance of the covariates using a diagonal weighting matrix $V$. $V$ is then chosen to minimize the mean-square error of the weighted difference in pre-treatment outcomes. Letting $Z_a$ be the matrix of pre-treatment outcomes for treatment group $A = a$, the synthetic controls algorithm solves the following optimization problem for a fixed $V$:\n\n\\begin{align}\n\\gamma(V) = \\arg\\min_{\\tilde{\\gamma}(V^\\star)} = (\\bar{X}_1 - X_0^T\\tilde{\\gamma})'V(\\bar{X}_1 - X_0^T\\tilde{\\gamma}) \n\\end{align}\n\nThis is the ``inner'' optimization. $V^\\star$ is then determined in an ``outer'' optimization to minimize the imbalances in the pre-treatment outcomes $Z$:\n\n\\begin{align}\n    V^\\star = \\arg\\min_V (\\bar{Z}_1 - Z_0^T\\gamma(V))'(\\bar{Z}_1 - Z_0^T\\gamma(V))\n\\end{align}\n\nIn applications the covariate matrix $X_a$ may contain some elements of $Z_a$. In cases where $X_a$ contains all pre-treatment outcomes, \\cite{kaul2015synthetic} has shown that the predictor weights $V^\\star$ will give no weight to auxillary covariates (covariates that are not the pre-treatment outcomes), rendering these irrelevant to the model. \n\nWhile in practice $V$ is often learned on the same data as the weights, \\cite{abadie2010synthetic} also propose to use cross-validation to choose $V$. For this procedure, we assume we have enough data that we can divide our pre-treatment data into a training data from periods $T = 1, ..., T - l - 1$, a validation period from periods $T - l, ..., T - 1$, and a post-treatment period at time $T$. To make this discussion more general, assume that we are evaluating a set of candidate models $\\mathcal{M}$ on the validation data (where for the synthetic controls algorithm we can think of this as the set of all possible weighting matrices $V$). Let $\\bar{Y}^a_{a', t}$ be the mean potential outcome under treatment $A = a$ for treatment group $A = a'$ at time $t$ (where $t$ occurs during the validation period). Let $\\hat{\\bar{Y}}^a_{a'', t}(m)$ be an estimator of that potential outcome at time $t$ using model $m$, trained during the training period using data from treatment group $A = a''$. Finally, let $\\bar{Y}_{a'}^{a, T}$ be the post-treatment target estimand, where $\\hat{Y}^a_{a'', T}(m)$ is the estimator using model $m$ learned during the training period and fit to the validation period data. This model selection procedure implicitly assumes that:\n\n\\begin{align*}\nm^\\star = \\min_{m \\in \\mathcal{M}}\\sum_{T - l}^{T-1}\\|\\hat{Y}^0_{0, t}(m) - \\bar{Y}^0_{1, t}\\| = \\min_{m \\in \\mathcal{M}}\\mathbb{E}\\{\\|\\hat{Y}^0_{0, T}(m) - \\bar{Y}^0_{1, T}\\|\\}\n\\end{align*}\n\nIn other words, this procedure selects the model (or weighting matrix $V$) using the empirical loss in the validation period as a proxy for the expected loss in the post-treatment time-period.\\footnote{It is possible that multiple models in $\\mathcal{M}$ either perfectly predict the pre-treatment outcomes, or predict them equally well. In this case we would require an additional criteria to choose the optimal model (see, e.g, \\cite{becker2017cross}}. This has some intuitive appeal in the typical synthetic controls setting where the estimand is the ETT since we observe $Y^0_{sct}$ for $t < T$. \n\nHowever, when synthetic controls are used to estimate the ETC, this idea is more troubling because we never observe $Y^1_{sct}$ (or a mean-unbiased proxy) prior to treatment for any unit. If we wish to use pre-treatment outcomes to optimally select variables or determine relative covariate importance, we would need strong assumptions, for example:\n\n\\begin{align*}\\label{assumption:second}\nm^\\star = \\min_{m \\in \\mathcal{M}}\\sum_{T - l}^{T-1}\\|\\hat{Y}^0_{1, t}(m) - \\hat{Y}^0_{0, t}\\| = \\min_{m \\in \\mathcal{M}}\\mathbb{E}\\{\\|\\hat{Y}^1_{1, T}(m) - \\bar{Y}^1_{0, T}\\|\\}\n\\end{align*}\n\nWe call this assumption ``counterfactual risk invariance.'' In other words, we assume that the model that minimizes the validation-period risk also minimizes the post-treatment risk for the opposite counterfactual. This is quite a strong assumption, and may not be well-justified depending on the nature of the problem. \n\nWe briefly note that we conflate variable selection with the synthetic controls' variable weighting procedure for the purposes of this exposition. Regardless, from a finite-sample perspective the synthetic controls estimator will be biased should the weights fail to balance a relevant confounder regardless of whether the imbalance were due to a sub-optimal weighting matrix $V$. We also note that synthetic controls are frequently motivated by a linear factor model for the outcome, while we have assumed no unmeasured confounding and a linear model throughout our discussions. However, this general point still holds when considering unobserved factors that might be weak confounders of $Y^0$ but strong confound $Y^1$.\n\n\\subsection{Illustration}\n\nWe now illustrate this problem using our application, and consider the potential confounding role of Republican governance for our counterfactual estimate. Republican governance is a strong predictor of a state's decision to expand Medicaid \\cite{courtemanche2017early}. Moreover, existing evidence prior to Medicaid expansion showed that Medicaid take-up rates were lower in more conservative states \\cite{sommers2012understanding}. However, when generating their synthetic control weights to estimate the ETT, \\cite{courtemanche2017early} and \\cite{kaestner2017effects} do not control for these factors. \\footnote{\\cite{courtemanche2017early} does control for Republican governor in their regression model and they find that it is a statistically significant predictor of 2013 uninsurance rates. One reason they may not control for this in the synthetic control model is practical: it is challenging to balance this covariate using control data without extrapolating from the data.} However, it is clear that if take-up rates depend on governance, we may expect this to be a strong confounder of $Y^1$  even if arguably it is not a confounder of $Y^0$.\n\nWe illustrate this by conducting a variable importance analysis to examine the confounding role of Republican governance on our estimate of $\\bar{Y}_0^1$. Specifically, we remove the balance constraints from the Republican governance indicators and examine how our estimates of $\\hat{Y}_0^1$ change. Letting $\\hat{Y}^1_{0, s}$ be the estimate when removing the Republican governance indicators (or more generally, the covariate matrix $S$ where $X = (Z, S)$). We subtract our original point estimate $\\hat{Y}^1_0$ from $\\hat{Y}^1_{0, s}$ to generate the difference $\\hat{\\Delta}^1$. This difference tells us about the direction of the bias our estimate of $\\hat{Y}^1_0$ would incur when we do attempt to constrain the imbalance in covariate $S$. Our hypothesis implies that we should expect $\\hat{\\Delta}_s^1 < 0$: that is, keeping all other covariates (roughly) fixed, we expect the predicted uninsurance rate will decrease when as the level of Republican governance decreases. In addition to the Republican governance indicators, we also examine four other covariate groups: pre-treatment uninsurance rates and pre-treatment unemployment rates, and three sets of different demographic indicators. We then calculate these differences when removing each state and provide the minimum and maximum differences in parentheses. \\footnote{This quantity does not represent a fixed target of inference and so we therefore do not estimate confidence intervals for them.}. We caution that our results do not imply that Republican governance is not an important confounder of $Y^0_{1, T}$ since we do not analyze this directly.\n\nFor the H-SBW estimator we calculate $\\hat{\\Delta}^1$ equal to -0.69 (min = -0.83, max = -0.42) and equal to -0.79 (min = -0.90, max = -0.66) on our unadjusted dataset. In other words, our primary estimated treatment effect moved 0.78 percentage points further away from zero when we excluded the Republican governance indicators. This reflects a 33 percent decrease in our point estimate, a not-unsubstantial difference. Moreover, all of these estimates were less than zero, regardless of whether we conditioned on the covariate adjustment or not, regardless of whether we remove the early expansion states or not, and when removing each state. Additional distributional results across all leave-one-state-out estimates for the primary dataset are available in Table~\\ref{tab:rdiffc1} below. Additional results are available on request.\n\nWe also consider four other covariate sets. We find that our estimates are most sensitive to controlling for pre-treatment outcomes and unemployment rates. This is not unexpected: all else equal, the expansion region had much lower pre-treatment uninsurance rates. If we do not control for these covariates, the comparable region will likely have lower pre-treament uninsurance rates, causing the estimated counterfactual to be closer to zero. The effect estimates were less sensitive to the removal of other covariate groups, and all point estimates are available in Table~\\ref{tab:ptests}. Overall these results highlight the importance of Republican governance in our counterfactual outcome model of $Y^1$. \n\n\\subsection{Effect heterogeneity}\n\nIf the models specified by \\cite{kaestner2017effects} and \\cite{courtemanche2017early} are correct (that is, they correctly omit Republican governance from their balancing weights for estimating $\\bar{Y}^0_{1, T}$), our results imply treatment effect heterogeneity with respect to Republican governance. Moreover, because the expansion-state region is much more Democratic than the non-expansion region, this heterogeneity could potentially drive differences between the ETC and the ETT. Because this is a policy question of some interest, we directly investigate this by estimating the outcome model on the full data with treatment assignment interacted with each covariate \\footnote{For this analysis we calculate separate covariate adjustments on the untreated data.} We then examine how the estimated treatment effect would change if we decreased the interaction between treatment assignment and each Republican governance indicator -- Republican governor, Republican lower legislature control, and Republican total control -- by 50 percentage points (the original variables are either 0 or 100 and are measured at the state level). This linear combination of coefficients estimates how the treatment effect would change for any given collection of states against a set that is identical except for being 50 percentage points lower, on average, across the Republican governance indicators. We find that the linear combination is positive (0.21 percentage points) and statistically significant at the 5 percent level on the unadjusted dataset. In contrast to our previous results, this would indicate that the estimated treatment effect may be larger among Republican governed areas. However, this finding is not robust to any other specification that we run. We interpret these results as providing no evidence of treatment effect heterogeneity with respect to Republican governance. The full results are available in Table~\\ref{tab:hte}.\n\n\\subsection{Variable importance result tables}\n\nTable~\\ref{tab:ptests} presents all point estimates from estimators that we calculated. The ``Var subset`` column indicates which variables were excluded from the estimation: 0 excludes no variables; 1 removes Republican governance indicators; 2 pre-treatment uninsurance and unemployment rates; 3 urban, age, education, citizenship, marital status, student, disability, or female; 4 race, ethnicity, income, foreign born; 5 children, population growth, and household to person ratio. We see that the largest changes generally occur when excluding the pre-treatment uninsurance and unemployment rates. This is not surprising: controlling for the other covariates, the pre-treatment uninsurance rate was substantially lower in the treated region compared to the control region. Given that pre-treatment uninsurance rates are highly correlated with post-treatment rates, we find that this comparison leads to a larger absolute magnitude point estimate, highlighting the need to control for these covariates. The results are qualitatively similar when excluding the early expansion states and are available on request.\n\n%Wed Jan 13 15:24:43 2021\n\\begin{table}[h!]\n\\centering\n\\caption{Point estimates for all specifications}\n\\label{tab:ptests}\n\\begin{tabular}{llrrrr}\n  \\hline\nVariable subset & Adjustment & H-SBW & BC-HSBW & SBW & BC-SBW \\\\ \n  \\hline\n0 & Homogeneous & -2.33 & -2.05 & -2.35 & -2.07 \\\\ \n  0 & Heterogeneous & -2.24 & -1.98 & -2.28 & -2.00 \\\\ \n  0 & None & -2.34 & -2.22 & -2.39 & -2.19 \\\\ \n  1 & Homogeneous & -3.02 & -2.98 & -3.03 & -2.76 \\\\ \n  1 & Heterogeneous & -3.02 & -2.98 & -3.01 & -2.76 \\\\ \n  1 & None & -3.13 & -3.17 & -3.14 & -2.93 \\\\ \n  2 & Homogeneous & -5.40 & -4.73 & -5.12 & -4.48 \\\\ \n  2 & Heterogeneous & -5.40 & -4.72 & -5.12 & -4.48 \\\\ \n  2 & None & -5.40 & -4.81 & -5.12 & -4.55 \\\\ \n  3 & Homogeneous & -2.21 & -1.94 & -2.24 & -1.91 \\\\ \n  3 & Heterogeneous & -2.14 & -1.86 & -2.18 & -1.85 \\\\ \n  3 & None & -2.33 & -2.03 & -2.38 & -2.02 \\\\ \n  4 & Homogeneous & -2.34 & -2.18 & -2.29 & -2.15 \\\\ \n  4 & Heterogeneous & -2.30 & -2.17 & -2.25 & -2.10 \\\\ \n  4 & None & -2.39 & -2.37 & -2.45 & -2.35 \\\\ \n  5 & Homogeneous & -2.33 & -2.12 & -2.37 & -2.15 \\\\ \n  5 & Heterogeneous & -2.24 & -2.05 & -2.30 & -2.09 \\\\ \n  5 & None & -2.34 & -2.25 & -2.38 & -2.26 \\\\ \n   \\hline\n\\end{tabular}\n\\end{table}\n\nTable~\\ref{tab:rdiffc1} displays the quantiles of the distribution $\\hat{\\Delta}_v^1$ estimates when leaving out each state for the primary dataset and removing the early expansion states. The ``resample'' column indicates whether the entire adjustment procedure was recalculated (``Procedure'') or whether we left out each state conditional on the adjustment (``States''). These differences tend to be slightly larger in absolute magnitude when removing early expansion states and are available on request.\n\n\\begin{table}[h!]\n\\centering\n\\caption{$\\hat{\\Delta}^1_v$ leave-one-state-out estimates, primary dataset}\n\\label{tab:rdiffc1}\n\\begin{tabular}{lllrrrrrr}\n  \\hline\nInference & Adjustment & Weight type & Original & 0\\% & 25\\% & 50\\% & 75\\% & 100\\% \\\\ \n  \\hline\nStates & Heterogeneous & H-SBW & -0.78 & -0.88 & -0.80 & -0.78 & -0.73 & -0.59 \\\\ \n  Procedure & Heterogeneous & H-SBW & -0.78 & -0.89 & -0.82 & -0.74 & -0.69 & -0.46 \\\\ \n  States & Heterogeneous & BC-HSBW & -1.00 & -1.13 & -1.02 & -0.99 & -0.94 & -0.71 \\\\ \n  Procedure & Heterogeneous & BC-HSBW & -1.00 & -1.11 & -1.03 & -0.98 & -0.93 & -0.66 \\\\ \n  States & Heterogeneous & SBW & -0.74 & -0.93 & -0.77 & -0.73 & -0.70 & -0.52 \\\\ \n  Procedure & Heterogeneous & SBW & -0.74 & -0.96 & -0.78 & -0.73 & -0.69 & -0.53 \\\\ \n  States & Heterogeneous & BC-SBW & -0.77 & -0.97 & -0.79 & -0.75 & -0.72 & -0.56 \\\\ \n  Procedure & Heterogeneous & BC-SBW & -0.77 & -0.96 & -0.80 & -0.76 & -0.69 & -0.50 \\\\ \n  States & Homogeneous & H-SBW & -0.69 & -0.83 & -0.74 & -0.70 & -0.64 & -0.42 \\\\ \n  Procedure & Homogeneous & H-SBW & -0.69 & -0.86 & -0.76 & -0.71 & -0.65 & -0.36 \\\\ \n  States & Homogeneous & BC-HSBW & -0.93 & -1.07 & -0.95 & -0.94 & -0.88 & -0.64 \\\\ \n  Procedure & Homogeneous & BC-HSBW & -0.93 & -1.05 & -0.97 & -0.93 & -0.87 & -0.59 \\\\ \n  States & Homogeneous & SBW & -0.67 & -0.86 & -0.72 & -0.67 & -0.65 & -0.40 \\\\ \n  Procedure & Homogeneous & SBW & -0.67 & -0.90 & -0.73 & -0.69 & -0.65 & -0.47 \\\\ \n  States & Homogeneous & BC-SBW & -0.70 & -0.89 & -0.75 & -0.70 & -0.66 & -0.50 \\\\ \n  Procedure & Homogeneous & BC-SBW & -0.70 & -0.91 & -0.76 & -0.73 & -0.66 & -0.44 \\\\ \n  States & None & H-SBW & -0.79 & -0.90 & -0.81 & -0.80 & -0.76 & -0.66 \\\\ \n  Procedure & None & H-SBW & -0.79 & -0.90 & -0.81 & -0.80 & -0.76 & -0.66 \\\\ \n  States & None & BC-HSBW & -0.95 & -1.10 & -0.98 & -0.94 & -0.90 & -0.84 \\\\ \n  Procedure & None & BC-HSBW & -0.95 & -1.10 & -0.98 & -0.94 & -0.90 & -0.84 \\\\ \n  States & None & SBW & -0.75 & -0.89 & -0.77 & -0.75 & -0.73 & -0.58 \\\\ \n  Procedure & None & SBW & -0.75 & -0.89 & -0.77 & -0.75 & -0.73 & -0.58 \\\\ \n  States & None & BC-SBW & -0.74 & -0.88 & -0.75 & -0.72 & -0.70 & -0.57 \\\\ \n  Procedure & None & BC-SBW & -0.74 & -0.88 & -0.75 & -0.72 & -0.70 & -0.57 \\\\ \n   \\hline\n\\end{tabular}\n\\end{table}\n\nTable~\\ref{tab:hte} displays the estimated linear combination of model coefficients on the Republican governance indicators with 95 percent confidence intervals (standard errors calculated using leave-one-state-out jackknife, repeating the entire covariate adjustment procedure each time). \n\n\\begin{table}[h!]\n\\caption{Effect heterogeneity with respect to Republican governance}\n\\label{tab:hte}\n\\centering\n\\begin{tabular}{rlll}\n  \\hline\nEstimate & Adjustment & CI (95\\%) & Dataset \\\\ \n  \\hline\n-1.67 & Heterogeneous & (-5.27, 1.94) & Primary \\\\ \n  0.78 & Homogeneous & (-5.62, 7.18) & Primary \\\\ \n  0.21 & None & (0.02, 0.40) & Primary \\\\ \n  -1.80 & Heterogeneous & (-5.46, 1.85) & Early expansion excluded \\\\ \n  0.59 & Homogeneous & (-6.13, 7.31) & Early expansion excluded \\\\ \n  0.15 & None & (-0.12, 0.42) & Early expansion excluded \\\\ \n   \\hline\n\\end{tabular}\n\\end{table}\n\n\\clearpage", "meta": {"hexsha": "66f17c0cc4da37d4d67a9437b306c454c7352407", "size": 18134, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Text_files/variable-selection.tex", "max_stars_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_stars_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Text_files/variable-selection.tex", "max_issues_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_issues_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Text_files/variable-selection.tex", "max_forks_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_forks_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 124.2054794521, "max_line_length": 1942, "alphanum_fraction": 0.7287415904, "num_tokens": 5110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6150878555160666, "lm_q1q2_score": 0.44585890370094206}}
{"text": "\\chapter{Introduction}\n\n\\textit{Rendering} is generally the process of generating a two-dimensional image, called \\textit{render}, from the mathematical description of a three-dimensional scene. \n%To oversimplify it, a scene is made of light sources, geometries and a camera, all defined in mathematical, hence rather abstract, terms. \nSeveral rendering algorithms have been developed over the years and many of them have been designed to produce images as \\textit{photorealistic} and lifelike as possible. The most recent ones of these kind are all based upon simulating how light interacts with the scene, closely imitating its natural behavior. A particularly successful rendering algorithm following this philosophy is \\textit{Path Tracing} \\cite{kajiya1986rendering} since its derivations and itself are widespread across animation, visual effects and video games. In simple words, path tracing is based upon the idea of shooting rays out of an artificial camera towards the scene and make each bounce around the scene until it reaches a light source; then, the luminous energy carried by the ray and its bounces, called \\textit{path}, can be computed --- or \\textit{traced} back.  Without diving further into its details --- which are left for section \\ref{background} ---, it is clear how complex path tracing can get. This makes it difficult to grasp by people approaching it and difficult to debug.\n\nWe are presenting a tool capable of showing the user an overview of the inner workings of a path tracer by providing interactive visualizations of the very core of a path tracer: paths and how they interact with the scene.\nWe strived to create something that does not tell but --- literally --- shows the swarm of paths shot by a path tracer to help understand what is actually going on during the rendering process.\n\nThe idea of providing interactive renderings of the data generated by a path tracer --- or a ray tracer --- is not original. Let us mention a few that inspired our work:\n\\begin{itemize}\n\t\\item The \\textit{Ray tracing visualization toolkit} (\\textit{rtVTK}) by C. Gribble et Al. \\cite{gribble2012ray} is a nice starting point but it focuses on ray tracers \\cite{whitted1979improved, cook1984distributed} more than on path tracers.\n\tFurthermore, it is designed to render only a single ray tree at once, making it difficult to picture a global overview on the data that concurred in the generation of the final render; after all, a good mantra of presenting visual data is, quoting Ben Shneiderman, “Overview first, zoom and filter, then details-on-demand” \\cite{shneiderman2003eyes}. rtVTK practically presents only the details.\n\t\\item The work presented in \\textit{A Framework for Visual Dynamic Analysis of Ray Tracing Algorithms} by H. Lesev and A. Penev \\cite{lesev2014framework} has extensive filtering and data gathering features which inspired us, but it works only on ray tracers, as much as rtVTK.\n\t\\item Another great inspiration for us was the framework presented in \\textit{Applying Visual Analytics to Physically Based Rendering} by G. Simons et Al. \\cite{simons2019applying}, especially the visualization parts. We however drift off it because, while they reduce the data they gather from a path tracer by selecting only about 1/6000th of the total paths, our goal is to keep the whole dataset and let the user choose what to visualize from all the samples.\n\t\\item Another tightly related work is \\textit{EMCA}, which stands for \\textit{Explorer of Monte-Carlo based Algorithms}, by C. Kreisl \\cite{EMCA@2019}. It focuses on path tracing and visualizations but its client-server architecture with per-pixel path analysis lacks of the global view we are trying to achieve.\n\\end{itemize}  \n\n\\section{Background}\n\\label{background}\n\n%To fully comprehend the topics and challenges presented in this work a background is needed.\n\nWe will now provide a quick overview on path tracing to establish a common ground of terminology between us and the reader. This is not meant to be in any way an exhaustive explanation, please refer to the cited literature to have a better insight.\n\n\\subsection{The rendering equation}\n\\label{secrendeq}\nAs we introduced before, \\textit{photorealistic rendering} is the process that given a mathematical description of a three-dimensional scene outputs an as life-like as possible image, know as \\textit{render}. The process simulates how light travels from light sources to an abstract camera sensor while interacting with the scene. An important equation that describes how light behaves is the \\textit{Rendering Equation} introduced by J. Kajiya in 1986 \\cite{kajiya1986rendering} here presented with different notations:\n\\begin{equation}\n\tL_o(\\vec{x},\\vec{\\omega}_o) = \n\t\tL_e(\\vec{x},\\vec{\\omega}_o) + \n\t\tL_r(\\vec{x},\\vec{\\omega}_o)\n\t\\label{rendeqeasy}\n\\end{equation}\nIt says that, considering a surface, the amount of light that leaves the surface point $\\vec{x}$ in direction $\\vec{\\omega}_o$, called \\textit{outgoing radiance} ($L_o$), is determined by the emitted radiance ($L_e$), which is the one emanated by the surface itself, plus the reflected radiance ($L_r$) which is given by:\n\\begin{equation}\n\tL_r(\\vec{x},\\vec{\\omega}_o) = \n\t\t\\int_{\\mathcal{H}^2} \n\t\t\tf(\\vec{\\omega}_o, \\vec{x}, \\vec{\\omega}_i)\n\t\t\tL_i(\\vec{x},\\vec{\\omega}_i)\n\t\t\td\\vec{\\omega}_i\n\t\\label{reflectioneq}\n\\end{equation}\nThis means it consists in the sum of the radiance incoming ($L_i$) from all possible directions ($\\vec{\\omega}_i \\in \\mathcal{H}^2$) hitting point $\\vec{x}$, weighted by the reflective and refractive properties of the material ($f(\\cdots)$).\n\nNow, image sensors, as well as all animal visual organs, are made of several small photo sensitive units that measure the incoming radiance hitting their surfaces over a short period of time. By putting together the values read by the units an image is produced. To compute the incoming radiance on each of these photo sensitive units called \\textit{pixels}, the incoming radiance must be integrated over the pixel surface and scaled by its area to make the result independent of the sensor's size:\n\\begin{equation}\n\tL_{pixel} = \\frac{1}{A_{pixel}} \n\t\t\\int_{\\vec{q}\\in pixel} L_i(\\vec{q}, \\vec{\\omega}_r)dA_q\n\t\\label{pixelradiance}\n\\end{equation}\nWhere $\\vec{\\omega}_r$ depends on the camera mathematical model, that can range from the simplest pinhole camera to a complex simulation of real camera lenses groups.\n\nAt this point is clear that rendering is all about computing the radiance hitting a sensor but the rendering equation presented above (eq. \\ref{rendeqeasy}) describes only outgoing radiance. Fortunately, thanks to the fact that radiance is constant along a ray\\footnote{Radiance is constant along a ray only in perfect vacuum. All non-volumetric path tracers --- which we exclusively focus on --- assume vacuum between surfaces.}, it is possible to write:\n\\begin{equation}\n\tL_i(\\vec{x},\\vec{\\omega}_i) = L_o(\\vec{y},\\vec{\\omega}_o)\n\\end{equation}\nWhere $\\vec{y}$ is the first point on a surface hit by the ray shot from $\\vec{x}$ in direction $\\vec{\\omega}_i$ and $\\vec{\\omega}_o$ is the direction pointing from $\\vec{y}$ to $\\vec{x}$. Introducing the Raytracing $RT$ operator:\n\\begin{equation}\n\t\\vec{y} = RT(\\vec{x},\\vec{\\omega}_i)\n\\end{equation}\nAnd rewriting $\\vec{\\omega}_o$ in function of $\\vec{\\omega}_i$:\n\\begin{equation}\n\t\\vec{\\omega}_o = -\\vec{\\omega}_i\n\\end{equation}\nWe have that:\n\\begin{equation}\n\tL_i(\\vec{x},\\vec{\\omega}_i) = L_o(RT(\\vec{x},\\vec{\\omega}_i),-\\vec{\\omega}_i)\n\t\\label{lilo}\n\\end{equation}\nThe first thing that can be taken from this is that to compute the incoming radiance on a sensor it is sufficient to shoot a ray and compute the radiance on the scene point hit by the ray outgoing in the inverse ray direction. Secondly, plugging everything that has been said until now produces a more complete rendering equation:\n\\begin{equation}\n\tL_o(\\vec{x},\\vec{\\omega}_o) = \n\t\tL_e(\\vec{x},\\vec{\\omega}_o) + \n\t\t\\int_{\\mathcal{H}^2} \n\t\t\tf(\\vec{\\omega}_o, \\vec{x}, \\vec{\\omega}_i)\n\t\t\tL_o(RT(\\vec{x},\\vec{\\omega}_i),-\\vec{\\omega}_i)\n\t\t\td\\vec{\\omega}_i\n\t\\label{renderingeq}\n\\end{equation}\n\n\n%Where:\n%\\begin{description}\n%\t\\item[$\\vec{x}$] A point in space.\n%\t\\item[$\\vec{\\omega}_o$] An outgoing direction from $\\vec{x}$.\n%\t\\item[$\\vec{\\omega}_i$] An incoming direction towards $\\vec{x}$\n%\t\\item[$L(\\vec{x},\\vec{\\omega}_o)$] Radiance outgoing in direction $\\vec{\\omega}_o$ from $\\vec{x}$\n%\t\\item[$L_e(\\vec{x},\\vec{\\omega}_o)$] Radiance emitted in direction $\\vec{\\omega}_o$ by $\\vec{x}$.\n%\t\\item[$\\mathcal{H}^2$] All the possible directions.\n%\t\\item[$L(\\vec{x},\\vec{\\omega}_i)$] Incoming radiance from direction $\\vec{\\omega}_i$ on $\\vec{x}$.\n%\t\\item[$f(\\vec{\\omega}_o, \\vec{x}, \\vec{\\omega}_i)$] The Bidirectional Scattering Distribution Function (BSDF) computed on $\\vec{x}$ on directions $\\vec{\\omega}_o$ and $\\vec{\\omega}_i$.\n%\t\\item[$\\hat{n}_{\\vec{x}}$] The surface normal on $\\vec{x}$.\n%\\end{description}\n\n\\subsection{Monte Carlo integration}\n\nGiven all the equations above, all it is needed to render a convincing image is solving them. The first problem that surfaces is that they contain integrals. Integrals are infinitesimal sums and as such they do not conform too well with the discrete nature of electronic calculators. In other words, integrals cannot be numerically solved on computers. Their solution, though, can be approximated. Without lingering on the reasons, a particularly suitable approximation method for our case is the Monte Carlo integration \\cite{kalos2009monte}.\n\nIt randomly picks $N$ samples ($x_i, i \\in [0,N)$) from the integration interval ($\\Omega$), evaluates the integrand ($f(x)$) with each sample and does an average of the evaluated values weighting them by the probability density function ($pdf(x)$) of picking the corresponding sample from the interval. This gives:\n\\begin{equation}\n\t\\int_{\\Omega}f(x)dx \\approx \\frac{1}{N} \\sum_{i=0}^{N} \\frac{f(x_i)}{pdf(x_i)}\n\t\\label{montecarlo}\n\\end{equation}\n\nThe value computed by Monte Carlo gets closer to the correct result increasing the number of random samples $N$. It has been demonstrated that if the samples are picked from the interval using a uniform distribution, the relative error is directly proportional to $\\frac{1}{\\sqrt{N}}$. From this it can be deducted that Monte Carlo will never output the correct solution but it will asymptotically tend to it as samples increase; that is why literature usually talk about \\textit{convergence} and sometimes about \\textit{convergence speed}, which is an informal value expressing how many samples are needed to approximate an acceptable result, where what is considered acceptable varies case by case.\n\nThe $\\frac{1}{\\sqrt{N}}$ factor can be improved by a technique called \\textit{importance sampling} that is based upon the idea of drawing samples from a distribution as close as possible to the integrand in order to reduce the variance. The ideal case would be using the integrand itself as distribution but often, due to its complexity, is impossible to draw samples directly from it. Alternative distributions that roughly approximate the integrand are used instead.\nThis can even be brought a step forward by stochastically combining two approximate distributions together using the so-called \\textit{multiple importance sampling} (MIS) \\cite{veach1995optimally}.\n\n\\subsection{Path tracing}\n\nNow that we have a tool to numerically solve integrals, we can apply it to the integrals presented in section \\ref{secrendeq}. The total incoming radiance on a pixel (eq. \\ref{pixelradiance}) can then be calculated by randomly picking sample points on its surface and then applying Monte Carlo (eq. \\ref{montecarlo}):\n\\begin{equation}\n\tL_{pixel} \\approx \\frac{1}{N A_{pixel}} \n\t\t\\sum^{N}_{i = 0} \\frac{L_i(\\vec{q}_i, \\vec{\\omega}_{ri})}{p(\\vec{q}_i)}\n\\end{equation}\nThe number of samples picked here $N$ is usually constant for each pixel. Due to its direct relation between final render quality --- more samples means a solution closer to the real one --- and render time --- each additional sample adds computational burden --- it is a rather important parameter in all path tracers and it is called \\textit{samples per pixel} or \\textit{spp} for short.\n\nNow, it is a matter of computing $L_i$ for each pixel sample. Recalling the logical results given by the conservation of radiance along rays presented in equation \\ref{lilo} the problem shifts on how to compute the outgoing radiance of the point of the scene hit by the ray shot from the sample position ($\\vec{q}_i$) in its associated direction ($\\vec{\\omega}_{ri}$). This value, as presented by the complete version of the rendering equation (eq. \\ref{renderingeq}), depends on another integral having all possible directions as its integration interval. Furthermore, inside the integral there is again an outgoing radiance, but this time computed with other parameters ($L_o(RT(\\vec{x},\\vec{\\omega}_i),-\\vec{\\omega}_i)$). By substitution, it begins to become clear that evaluating one outgoing radiance theoretically leads to solving a recursively infinite amount of integrals. This, through the power of Monte Carlo integration, becomes manageable and a path tracer computes outgoing radiances by sampling all the possible directions just once. The rendering equation can then be written as:\n\\begin{equation}\n\tL_o(\\vec{x},\\vec{\\omega}_o) \\approx\n\tL_e(\\vec{x},\\vec{\\omega}_o) + \n\t\\frac{1}{pdf(\\vec{\\omega}_i)}\n\tf(\\vec{\\omega}_o, \\vec{x}, \\vec{\\omega}_i)\n\tL_o(RT(\\vec{x},\\vec{\\omega}_i),-\\vec{\\omega}_i)\t\n\\end{equation}\nWith this approximation the calculations consist in shooting a ray, find an intersection with the scene, compute the properties of the material on the intersection, pick a random new direction, shoot a ray in that direction from the intersection point and then keep doing the same recursively, forming a path. In practice, to not make a path bounce indefinitely, a maximum number of bounces, called \\textit{maximum path length}, is arbitrarily decided before rendering, as much as the number of samples per pixel is.\n\nPath tracers that behave as described until now are informally called na\\\"ive path tracers. Other more complex tracers employ techniques to speed up the Monte Carlo convergence. As already mentioned, a common technique is importance sampling, as it can be applied to path tracing by sampling new bounces' directions from probability distributions that naturally carry more radiance. This can happen in two ways: either paths are forced to follow the properties of the material they are bouncing on, or they are directed towards a light source. A usually even more efficient approach is to combine these two sampling strategies through multiple importance sampling.\n\n% Using this approximation, estimating radiance for each pixel sample can be written in pseudo code as shown in listing \\ref{ptalgo}.\n% It is clear how \n\n% \\begin{Listing}\n% \t\\begin{lstlisting}\n% function estimate_radiance(ray):\n% \tintersection := intersect scene with ray\n% \tif no intersection:\n% \t\treturn 0\n\n% \tx := intersection point\n% \tomega_o := ray direction\n% \tomega_i := random direction picked from distribution d\n% \tpdf_omega_i := pdf of the distribution d evaluated for omega_i\n% \tnew_ray := ray originating from x and direction omega_i\n% \tincoming_radiance := estimate_radiance(new_ray)\n% \tmaterial := material properties computed with omega_o, x, and omega_i\n% \treturn (1 / pdf_omega_i) * material * incoming_radiance\n\n% primary_ray := ray shot from the camera\n% estimate_radiance(primary_ray)\n% \t\\end{lstlisting}\n% \t\\caption{Pixel sample radiance estimation.}\n% \t\\label{ptalgo}\n% \\end{Listing}\n\n%\\subsection{OpenGL}\n\n\n\n%It means that the algorithms that generated these datasets have different ways of choosing the direction of each path bounce in order to maximize the radiance carried by each path, speeding up the convergence of the Monte Carlo integration and hence trying to lower the amount of noise given the same amount of pixel samples. This technique, used in every application of Monte Carlo methods, is called \\textit{importance sampling} \\cite{kalos2009monte}. Multiple importance sampling \\cite{veach1995optimally}.\n\n\\section{Motivation}\n\\label{motivation}\n%As introduced above, path tracing is an algorithm that is not easy to picture. For someone who got to understand it, the rendering equation is more than enough to tell how a path tracer work. At least to get started, everything a person needs to know is in that equation: once combined with Monte Carlo integration, everyone is theoretically ready to implement a path tracer. \n\nAs introduced above, path tracing is not easy to picture. As many research groups before us thought, having a tool showing what a tracer is doing by visualizing its interactions with the 3D scene would help the professional developers lost in the debugging cycle as well as the students trying to get a hang of path tracing's inner workings. The challenge this vision has to face is the sheer amount of these interactions; talking about path tracing, to have a decent render\\footnote{We considered as a decent render a $512 \\times 512$ pixels and 256 spp image which is a good halfway point between production quality and being way too far from convergence.}, more than two hundreds paths have to be shot for each pixel: to produce an image, more than fifty million paths have to be shot. Postponing data size considerations for later (sec. \\ref{datatogather}), leaves us with potential datasets that without proper data reduction or filtering are of no use to anyone. Related works usually perform substantial reductions of the datasets \\cite{simons2019applying,EMCA@2019}, but we believe that having all the paths available for visualization would improve the experience.\n\nWith these premises, a more precise idea for a visualization tool came to us. \nThe user should have the power to visually and interactively explore all the paths previously generated by a path tracer during rendering. The paths have to be immersed in an interactive rendering of the scene: their most important property is their geometry or, in other words, where they bounce inside the scene. In the beginning, out of curiosity and naivety, we tried visualizing all the paths of some datasets and even if those were rather small, we achieved compelling yet cluttered results (fig. \\ref{visual_clutter}); this made visualizing the millions of paths of a proper dataset out of question from the earliest stages. To navigate this ocean of paths, the user should be provided with a global summary overview of the dataset in its entirety, and they should also able to filter them using spatial queries. For the global overview we envisioned a heatmap applied as a texture to the 3D view of the scene that shows areas where there is more path activity, while for the spatial queries we thought the user might want to select path bouncing on certain noteworthy surfaces, such as lights or mirrors. \n\n\\begin{figure}\n\t\\centering\n\t\\centering\n\t\\begin{subfigure}[t]{0.49\\linewidth}\n\t\t\\includegraphics[width=\\textwidth]{chapters/chapter_intro/clutter_early1}\n\t\t\\caption{$64 \\times 64$, 1 spp}\n\t\\end{subfigure}\n\t\\begin{subfigure}[t]{0.49\\linewidth}\n\t\t\\includegraphics[width=\\textwidth]{chapters/chapter_intro/clutter_early2}\n\t\t\\caption{$64 \\times 64$, 64 spp}\n\t\\end{subfigure}\n\t\n\t\\caption{Visual clutter in an early version of the tool where the scene rendering has not been implemented yet. Both datasets have been generated on the \\textit{Cornell Box} scene.}\n\t\\label{visual_clutter}\n\\end{figure}\n\nLater in the development, it became clear that the possibility of comparing different datasets would come in handy to users. It could be useful in many cases such as comparing two progressive versions of the same in-development path tracer to understand what changed or, more in an educational context, such as showing a ground truth next to a purposely wrong dataset to understand why one is wrong on a deeper level.\n\nOf course, before even talking about visualizing data, data has to be gathered from a path tracer. We envisioned a software, parallel to the visualization client, able to plug to any path tracer and gather with little effort the required data during the rendering process. Then the idea of a gathering library with a very simple interface came about; a library that can be plugged into any path tracer the user is currently working on by just calling the few required functions.\n\nTo summarize, our vision consisted in a tool divided into a visualization client and a data gathering library which can be used both for debugging and teaching purposes. The library should have an easy to interact with interface, while the client would let the user explore different datasets simultaneously and in their entirety using the filtering and visualization options provided to them.\n\n%select a portion of a surface of the 3D scene the tracer has been run upon and see the paths that bounce there with a bunch of useful data. To be able to do that the whole set of paths shoot by a tracer are needed: by the very stochastic nature of a path tracer, it is impossible to determine which paths will end up bouncing where without resolving them all first. That is why it has been decided it was essential to store data about each path during the rendering process. To make the tool usable in most possible use cases, it had to be able to plug into an existing path tracer and this lead to the conception of the tool as a two software pieces suite: a \\textit{data gatherer library} called \\texttt{gatherer} and a \\textit{visualization client} called \\texttt{gathererclient}.\n\n%Now this “useful data” was not extremely well-defined during those early stages, so most of the efforts have been directed to the very essential: rendering the requested paths keeping interactivity.", "meta": {"hexsha": "8f9d7bc7b72c560d5c52fa7d205875ad688738d0", "size": 21847, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chapter_intro/text.tex", "max_stars_repo_name": "giuliom95/msc-thesis", "max_stars_repo_head_hexsha": "68f0900281fbb7c36fdfa34d6b86ec6099f9e274", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/chapter_intro/text.tex", "max_issues_repo_name": "giuliom95/msc-thesis", "max_issues_repo_head_hexsha": "68f0900281fbb7c36fdfa34d6b86ec6099f9e274", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/chapter_intro/text.tex", "max_forks_repo_name": "giuliom95/msc-thesis", "max_forks_repo_head_hexsha": "68f0900281fbb7c36fdfa34d6b86ec6099f9e274", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 110.8984771574, "max_line_length": 1173, "alphanum_fraction": 0.7784135122, "num_tokens": 5212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.445858903700942}}
{"text": "\n\\section{The \\replacecopy algorithm}\n\\Label{sec:replacecopy}\n\nThe \\replacecopy algorithm of the \\cxx Standard Library \\cite[\\S 28.6.5]{cxx-17-draft} substitutes\nspecific elements from general sequences.\n%\nHere, the general implementation\nhas been altered to process \\valuetype ranges.\nThe new signature reads:\n\n\\begin{lstlisting}[style=acsl-block]\n\n  size_type replace_copy(const value_type* a, size_type n, value_type* b,\n                         value_type v, value_type w);\n\\end{lstlisting}\n\nThe \\replacecopy algorithm copies the elements from the range \\inl{a[0..n]}\nto range {\\inl{b[0..n]}}, substituting every occurrence of \\inl{v} by \\inl{w}.\nThe return value is the length of the range.\nAs the length of the range is already a parameter of\nthe function this return value does not contain new\ninformation.\n\n\n\\begin{figure}[hbt]\n\\centering\n\\includegraphics[width=0.50\\textwidth]{Figures/replace.pdf}\n\\caption{\\Label{fig:replace} Effects of \\replace}\n\\end{figure}\n\nFigure~\\ref{fig:replace} shows the behavior of \\replacecopy at hand of an example\nwhere all occurrences of the value~3 in~\\inl{a[0..n-1]} are replaced with the\nvalue~2 in~\\inl{b[0..n-1]}.\n\n\n\\subsection{The predicate \\Replace}\n\nWe start with defining in the following listing the predicate \\logicref{Replace}\nthat describes the intended relationship between the input array \\inl{a[0..n-1]}\nand the output array \\inl{b[0..n-1]}.\nNote the introduction of \\emph{local bindings} \\inl{\\\\let ai = ...}\nand \\inl{\\\\let bi = ...} in the definition of \\Replace (see \\cite[\\S 2.2]{ACSLSpec}).\n\n\\input{Listings/Replace.acsl.tex}\n\nThis listing also contains a second, overloaded version of \\Replace\nwhich we will use for the specification of the related in-place\nalgorithm \\specref{replace}.\n\n%\\clearpage\n\n\\subsection{Formal specification of \\replacecopy}\n\nUsing predicate \\Replace the specification of \\specref{replacecopy}\nis as simple as shown in the following listing.\nNote that we also require that the input range \\inl{a[0..n-1]} and\noutput range \\inl{b[0..n-1]} do not overlap.\n\n\\input{Listings/replace_copy.h.tex}\n\n\\subsection{Implementation of \\replacecopy}\n\nThe implementation (including loop annotations) of \\implref{replacecopy}\nis shown in the following listing.\nNote how the structure of the loop annotations resembles\nthe specification of \\specref{replacecopy}.\n\n\\input{Listings/replace_copy.c.tex}\n\n\\clearpage\n\n", "meta": {"hexsha": "9f3bd4f9812213bca623944c7e2a61ffcd9282ca", "size": 2384, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/mutating/replace_copy.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/mutating/replace_copy.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/mutating/replace_copy.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 32.6575342466, "max_line_length": 98, "alphanum_fraction": 0.7579697987, "num_tokens": 648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.4458589000451198}}
{"text": "% use option [preprint] to remove info line at bottom\n% journal options: aop,aap,aos,aoas,ssy\n% natbib option: authoryear\n\\documentclass[12pt,aoas]{imsart} %% to review\n%%\\documentclass[aoas]{imsart}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Package\n\\usepackage{amssymb}\n\\usepackage{verbatim}\n%\\usepackage[francais,english]{babel}\n\\usepackage{graphicx}\n\\usepackage{lineno}\n\\RequirePackage{natbib}\n\\usepackage{hyperref}\n\\usepackage{algorithm2e}\n\\RequirePackage{amsthm,amsmath}\n\\usepackage{color}\n%\\usepackage[latin1]{inputenc}\n%\\usepackage[table]{xcolor}\n\n% provide arXiv number if available:\n%\\arxiv{arXiv:0000.0000}\n\n% put your definitions there:\n\\startlocaldefs\n\\numberwithin{equation}{section}\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\theoremstyle{definition}\n\\newtheorem{algo}{Algorithm}[section]\n\\endlocaldefs\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\n\n\\begin{document}\n\n%% To review\n\\baselineskip 0.8cm\n\\linenumbers\n%%\n\n\\begin{frontmatter}\n\n% \"Title of the paper\"\n\\title{Fast inference of individual admixture coefficients using geographic data}\n\\runtitle{Fast inference of individual admixture coefficients}\n\n\\begin{aug}\n\\author{\\fnms{Kevin} \\snm{Caye}\\thanksref{t1}\\ead[label=e1]{kevin.caye@imag.fr}},\n\\author{\\fnms{Flora} \\snm{Jay}\\thanksref{t2}\\ead[label=e2]{flora.jay@lri.fr}},\n\\author{\\fnms{Olivier} \\snm{Michel}\\thanksref{t1}\\ead[label=e3]{olivier.michel@gipsa-lab.grenoble-inp.fr}},\n\\and\n\\author{\\fnms{Olivier} \\snm{Fran\\c cois}\\thanksref{t1}\n\\ead[label=e4]{olivier.francois@imag.fr}}\n\n%% \\thankstext{m1}{This work has been partially supported by the LabEx PERSYVAL-Lab (ANR-11-LABX-0025-01) funded by the French program Investissement d\\rq{}Avenir}\n%% \\thankstext{m2}{Olivier Fran\\c cois acknowledges support from Grenoble INP and from the Agence Nationale de la Recherche, project AFRICROP ANR-13-BSV7-0017}\n\\runauthor{K. Caye et al.}\n\n\\affiliation{Universit\\'e Grenoble-Alpes\\thanksmark{t1} and Universit\\'e Paris-Sud\\thanksmark{t2}}\n\n\\address{Kevin Caye and Olivier Fran\\c cois\\\\\nUniversit\\'e Grenoble-Alpes\\\\\nCentre National de la Recherche Scientifique\\\\ \nTIMC-IMAG UMR 5525\\\\\nGrenoble, 38042, France\\\\\n\\printead{e1}\\\\\n\\phantom{E-mail:\\ }\\printead*{e4}}\n\n\\address{Flora Jay\\\\\nUniversité Paris-Sud\\\\\nUniversité Paris-Saclay\\\\\nLaboratoire de Recherche en Informatique UMR 7206\\\\\nCNRS UMR 8623\\\\\nOrsay, 91400, France\\\\\n\\printead{e2}}\n\n\\address{Olivier Michel\\\\\nUniversit\\'e Grenoble-Alpes\\\\\nCentre National de la Recherche Scientifique\\\\ \nGIPSA-lab UMR 5216\\\\\nGrenoble, 38042, France\\\\\n\\printead{e3}}\n\n\n\\end{aug}\n\n\\begin{abstract}\nAccurately evaluating the distribution of genetic ancestry across geographic space is one of the main questions addressed by evolutionary biologists. This question has been commonly addressed through the application of Bayesian estimation programs allowing their users to estimate individual admixture proportions and allele frequencies among putative ancestral populations. Following the explosion of high-throughput sequencing technologies, several algorithms have been proposed to cope with computational burden generated by the massive data in those studies. In this context, incorporating geographic proximity in ancestry estimation algorithms is an open statistical and computational challenge. In this study, we introduce new algorithms that use geographic information to estimate ancestry proportions and ancestral genotype frequencies from population genetic data. Our algorithms combine matrix factorization methods and spatial statistics to provide estimates of ancestry matrices based on least-squares approximation.  We demonstrate the benefit of using spatial algorithms through extensive computer simulations, and we provide an example of application of our new algorithms to a set of spatially referenced samples for the plant species {\\it Arabidopsis thaliana}.  Without loss of statistical accuracy, the new algorithms exhibit runtimes that are much shorter than those observed for previously developed spatial methods. Our algorithms are implemented in the {\\tt R} package, {\\tt tess3r}, which is available from \\url{https://github.com/BioShock38/TESS3_encho_sen}. \n\\end{abstract}\n\n\\begin{keyword}\n\\kwd{Ancestry Estimation Algorithms}\n\\kwd{Genotypic Data}\n\\kwd{Geographic Data}\n\\kwd{Fast Algorithms}\n\\end{keyword}\n\n\\end{frontmatter}\n\n\n\\input{intro.tex}\n\\input{method.tex}\n\\input{results.tex}\n\\input{discussion.tex}\n\n\\appendix\n\n\\input{appendix.tex}\n\n\\newpage\n\n\\section*{Acknowledgements}\nThis work has been partially supported by the LabEx PERSYVAL-Lab (ANR-11-LABX-0025-01) funded by the French program Investissement d\\rq{}Avenir. Olivier Fran\\c cois acknowledges support from Grenoble INP and from the Agence Nationale de la Recherche, project AFRICROP ANR-13-BSV7-0017.\n\n\n% AOS,AOAS: If there are supplements please fill:\n%\\begin{supplement}[id=suppA]\n%  \\sname{Supplement A}\n%  \\stitle{Title}\n%  \\slink[doi]{10.1214/00-AOASXXXXSUPP}\n%  \\sdatatype{.pdf}\" \n%  \\sdescription{Some text}\n%\\end{supplement}\n\n\\input{references.tex}\n\\input{tables_figures.tex}\n\n\\end{document}\n", "meta": {"hexsha": "125a2f47e710bcac89887cca3dcddc77259013ef", "size": 5097, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2Article/TESS3Article-master/Article/draft.tex", "max_stars_repo_name": "cayek/Thesis", "max_stars_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2Article/TESS3Article-master/Article/draft.tex", "max_issues_repo_name": "cayek/Thesis", "max_issues_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2Article/TESS3Article-master/Article/draft.tex", "max_forks_repo_name": "cayek/Thesis", "max_forks_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.9083969466, "max_line_length": 1584, "alphanum_fraction": 0.7751618599, "num_tokens": 1430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398979, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4458558605307153}}
{"text": "\\documentclass[a4paper, 12pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{xspace}\n\\usepackage{cleveref}\n\\usepackage{booktabs}\n\\usepackage[parfill]{parskip}\n\\usepackage{booktabs}\n\n\n\\newcommand{\\pt}{\\ensuremath{p_{\\mathrm{T}}}\\xspace}\n\n\\begin{document}\n\n\\section{Introduction}\nHerein lines some documentation on the HitFinder module in Delphes, and how I made it. \n\nThis HitFinder module repeats the algorithm found within the ParticlePropagator module, except N times, where N is the number of ``surfaces''. \nThe surfaces correspond to barrel layers, or end-cap layers (in this module, they simply correspond to two-dimensional surfaces, there are no modules or services). \nOne can apply a pT cut to the input particles, as, for example, low momentum particle would not reach certain regions of the detector. \n\nWithin Delphes, I added a Hit class that contains the 4-position of each particle hit, and the reference to the Delphes particle. \n\n\\section{From hits to tracks}\nThe distribution of vertices from a sample of 100 events (overlaid with a mean pileup of 200) is shown in \\ref{fig:vertices}.\nThe width of the distribution is $\\sigma = 53$\\,mm \n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\linewidth]{images/vertexDistribution}\n  \\caption{Distribution of vertices in 100 ttbar events (with mean pileup 200) and 100 TeV.}\n  \\label{fig:vertices}\n\\end{figure}\n\n\\subsection{The basic tracking}\n\\subsubsection{From outside to in}\nFor the basic tracking algorithm, a coincidence of three tracks is required, starting from a hit in the outer layer, and falling within a cone of $3\\sigma$ around the detector coordinate origin. \n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\linewidth]{images/geometry1}\n  \\caption{}\n  \\label{fig:circles1}\n\\end{figure}\n\nGiven a point $p= (a, b)$ on a circle of radius $2r$, the midpoint of the line from the origin to $p$ has the coordinates $(\\alpha, \\beta) = (a/2, b/2)$. \nTherefore, the equation of the smaller circle shown in \\cref{fig:circles1} is\n\\begin{equation}\n  \\Big( x - \\frac{a}{2} \\Big)^2 + \\Big( y - \\frac{b}{2} \\Big)^2 = r^2.\n\\end{equation}\nWe are actually interested in the intersection of the small circle in \\cref{fig:circles1} with another circle, centered on the origin as displayed in \\cref{fig:circles2}. \nUsing the notation of the \\cref{fig:circles2} we must combine\n\\begin{equation}\n  x^2 + y^2 = r_2^2 \\quad \\mathrm{and} \\quad (x - \\alpha)^2 + (y - \\beta)^2 = r^2,\n  \\label{eq:toSolve1}\n\\end{equation}\nwhere for notational simplicity we have used $r = r_1 / 2$. \nEliminating $y$ \\cref{eq:toSolve1} gives\n\\begin{align}\n  \\Big( x - \\alpha \\Big)^2 + \\Big( \\sqrt{r_2^2 - x^2} - \\beta \\Big)^2 = & ~ r^2 \\\\\n  x^2 + \\alpha^2 - 2x\\alpha + r_2^2 - x^2 + \\beta^2 -2\\beta \\sqrt{r_2^2 - x^2} = & ~ r^2 \\\\\n  (\\alpha ^2 + \\beta^2) -2 x \\alpha +r_2^2 -2\\beta\\sqrt{r_2^2 - x^2} = & ~ r^2.  \n\\end{align}\nUsing $\\alpha^2 + \\beta^2 = r^2$,\n\\begin{align}\n  r_2 ^2 & = 2x\\alpha + 2\\beta \\sqrt{r_2^2 - x^2} \\\\\n  (r_2^2 - 2\\alpha x )^2 & = 4\\beta^2 (r_2^2 - x^2) \\\\\n  r_2^4  + 4\\alpha^2 x^2 - 4r_2^2 \\alpha x & = 4\\beta^2 (r_2^2 - x^2) \\\\\n  4x^2 (\\alpha^2 + \\beta^2) - 4r_2^2 \\alpha x + r_2^4 -4\\beta^2 r_2^2 & = 0.\n\\end{align}\nAgain using $\\alpha^2 + \\beta^2 = r^2$ leaves us with the quadratic\n\\begin{equation}\n  4r^2 x^2 -4 r_2^2 \\alpha x +r_2^2(r_2^2 -4 \\beta^2) = 0\n\\end{equation}\nand therefore, \n\\begin{equation}\n  x  = \\frac{r_2^2 \\alpha \\pm \\sqrt{r_2^4\\alpha^2 - r^2 r_2^2(r_2^2 - 4\\beta^2)}}{2r^2}.\n\\end{equation}\nIn the case that $\\beta = 0$, then $r=\\alpha$ and the above simplifies to $x = \\frac{r_2^2}{2r}$.\nLikewise for $y$ we find\n\\begin{equation}\n  y  = \\frac{r_2^2 \\beta \\pm \\sqrt{r_2^4\\beta^2 - r^2 r_2^2(r_2^2 - 4\\alpha^2)}}{2r^2},\n\\end{equation}\nwhich in the case $\\alpha = 0$ simplifies to $y = \\frac{r_2^2}{2r}$ (with $r=\\beta$).\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\linewidth]{images/geometry2.eps}\n  \\caption{}\n  \\label{fig:circles2}\n\\end{figure}\n\n\\subsubsection{From inside to out}\nThis second algorithm is used to create tracks starting from a hit in the innermost layer, \nand then finding matching hits in the outer layers. \nIn the $r$--$z$ plane, two lines are drawn from the hit location to the edges of the luminous region along the beamline, these lines are extended outwards, and any hit within the two lines are matched\nto the inner hit. \n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\linewidth]{images/geometry3.eps}\n  \\caption{}\n  \\label{fig:circles3}\n\\end{figure}\n\nIn the $r$--$\\phi$ plane it is considered that the hit can traverse to the outermost layer in a circle.\nGiven that the charge of the particle is not known, the trajectory can curve in one of two directions.\nWe wish to find limits in $\\phi$ to which the particle hits can be matched. \nWith respect to \\cref{fig:circles3} the algorithm proceeds as follows:\n\\begin{itemize}\n  \\item A hit is found in the innermost layer (which has radius $r_2$) at point $(a, b)$. \n  \\item In the extreme case, the particle would bend in a circle in one direction or another, and so would end up at either point $p_1 = (c, d)$ or point $p_2 = (e, f)$. \n  \\item A hit is matched if any hit in the outer layers lie within $\\phi_1$ and $\\phi_2$. \n  \\item The angle between any $p_1$ and $p_2$ will always been the same, and so this only needs to be calculated once per geometry.  \n\\end{itemize}\nSetting the problem up, we want to find the equations of the circles intersecting the origin and point $(a, b)$, i.e. solve\n\\begin{equation}\n  (x - \\alpha)^2 + (y - \\beta)^2 = (r_1/2)^2, \\quad a \\in {x}, b \\in {y} \n  \\label{eq:circInToOut1}\n\\end{equation}\nThis amounts to finding the centre of these circles, the coordinates $(\\alpha, \\beta)$.\nSince the circle intersects the origin, we also have  $\\alpha ^2 + \\beta^2 = (r_1 / 2 )^2$. \nGiven that we can substitute $a$ and $b$ into \\cref{eq:circInToOut1} we can re-write it as\n$(a - \\alpha)^2 + (b - \\beta)^2 = (r_1/2)^2 $. Given we only need to find $\\alpha$ and $\\beta$ we can re-write these as $x$ and $y$ respectively, and find that we have to solve\n\\begin{equation}\n  (a - x)^2 + (b - y)^2 = R^2 \\quad \\mathrm{and} \\quad x^2 + y^2 = R^2\n\\end{equation}\nwhere $R=r_1 / 2$. This problem is very similar to that of \\cref{eq:toSolve1}, the solutions are\n\\begin{align}\n  x \\rightarrow \\alpha & = \\frac{a(a^2 + b^2) \\pm \\sqrt{b^2 (4R^2 -a^2 -b^2)   (a^2 + b^2) }}{2 (a^2 + b^2)} \\\\\n  y \\rightarrow \\beta & = \\frac{b(a^2 + b^2) \\pm \\sqrt{a^2 (4R^2 -a^2 - b^2) (a^2 + b^2) }}{2 (a^2 + b^2)}\n\\end{align}\nwhere $\\alpha$ and $\\beta$ are the coordinates of the centre of the circles. Note that $R^2 \\leq a^2 + b^2$.\nHowever, this gives us four possible coordinates, we much check which combinations give the circles that intersect with $(a, b)$.\nAnalytically we can show that these combinations are $(\\alpha_+ , \\beta_-)$ and $(\\alpha_-, \\beta_+)$. \nFirst, we'll simplify the above expressions \n\\begin{align}\n  \\alpha_\\pm &  = \\frac{a}{2} \\pm \\frac{b}{2} q \\\\\n  \\beta_\\pm & = \\frac{b}{2} \\pm \\frac{a}{2} q\n\\end{align}\nwhere $q = \\frac{\\sqrt{(4R^2 - a^2 - b^2)(a^2 + b^2)}}{a^2 + b^2}$. \nWe check the coordinate $(\\alpha_+ , \\beta_-)$ first by evaluating $(a - \\alpha_-)^2 + (b - \\beta_+)^2$:\n\\begin{align}\n  &  (\\frac{a}{2} + \\frac{b}{2}q)^2 + (\\frac{b}{2} - \\frac{a}{2}q)^2 \\\\\n  & = \\frac{1}{4} \\left( a^2 + b^2q^2 + 2abq +b^2 + a^2 -2abq \\right) \\\\\n  & = \\frac{1}{4} \\left( a^2 + b^2 +(4R^2 - a^2 - b^2) \\right) \\\\ \n  & = R^2.\n\\end{align}\nTherefore, $(\\alpha_+ , \\beta_-)$ describes the coordinates of one of the circles. \nBy inspection we can see that $(\\alpha_- , \\beta_+)$ are also the coordinates of the other circle. \nThis rules out the other two combinations of coordinates as possible centres.\nFor a detector geometry defined by three layers at radii 0.532\\,m, 0.582\\,m  and 0.632\\,m the phi window for these layers is:\n\\begin{table}\n  \\centering\n  \\begin{tabular}{cc}\n    \\toprule\n    Layer change & $\\Delta \\phi$ (rad) \\\\\n    \\midrule\n    $1 \\rightarrow 2$ & 0.418 \\\\\n    $1 \\rightarrow 3$ & 0.570 \\\\\n    $2 \\rightarrow 3$ & 0.400 \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Phi windows when traversing from one layer to another.}\n\\end{table}\n\n\n\\subsubsection{A more sensible phi window}\nGiven the innermost layer is at a radial distance of at least 0.5\\,m from the interaction point, \nand the magnetic field is 4.0\\,T, the minimum particle \\pt required for a particle to even reach the barrel layer is 0.6\\,GeV.\nHowever, from the trigger perspective we are not interested in low momentum particles, and in fact particles with a momentum below 2\\,GeV may not even be considered. \nWe may therefore define a smaller $\\phi$ window in which to match particles by considering the bending of particles with a larger momentum.\nTo be conservative, we will assume that the minimum particle \\pt will be 1\\,GeV.\nWe are interested in a phi window, so to simplify the calculation we will consider two barrel layers at radii $r_1$ and $r_2$ (with $r_2 > r_1$) described by circles centred at the origin, and a particle trajectory\ndescribed by $(x-R)^2 + y^2 = R^2$ where $R$ is the bending radius of the particle.\nWe require that $R > r_2$.  \nFor notational simplicity, consider a general barrel layer with radius $r$. \nWe then find the intersection of the track with the barrel layer by solving\n\\begin{equation}\n  (x-R)^2 + y^2 = R^2 \\quad \\mathrm{and} \\quad x^2 + y^2 = r^2.\n\\end{equation}\nThis gives\n\\begin{align}\n  x^2 + R^2 - 2xR + r^2 - x^2 = R^2 \\\\\n  x = \\frac{r^2}{2R}.\n\\end{align}\nThe $y$ coordinate is then given by\n\\begin{equation}\n  y = +r\\sqrt{1-\\frac{1}{2R}}\n\\end{equation}\nwhere we take the positive solution as we are only interested in the difference in phi angles.\nReturning to the specific barrel layers now, the $\\phi_i$ position of the track intercept with the barrel at radius $r_i$ is given by \n\\begin{equation}\n  \\phi_i = \\arccos \\left( \\frac{r_i}{2R} \\right).\n\\end{equation}\nWe want to calculate a phi window around a hit in the innermost layer as a loose cut to locate particles in the outer layers. \nThis $\\phi$ window will therefore be\n\\begin{align}\n\\Delta \\phi & = | \\phi_1 - \\phi_2 | \\\\\n  & =  \\left| \\cos^{-1} \\left( \\frac{r_1}{2R} \\right) - \\cos^{-1} \\left( \\frac{r_2}{2R} \\right) \\right| \n\\end{align}\nThe bending radius $R$ as a function of \\pt is given by $\\pt \\{ \\mathrm{GeV}/c \\} = 1.199 R \\{ \\mathrm{m} \\} $ (for a 4\\,T magnetic field).\nA plot of the $\\Delta \\phi$ as a function of \\pt is showing in \\cref{fig:phiDeviation} for three cases.\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.7\\linewidth]{images/phiDeviation.pdf}\n  \\caption{Phi deviation as a function of \\pt of a particle track traversing from one barrel layer positioned at radius $r_1$ and a second positioned at radius $r_2$ for three cases. \n  Each case has $r_1 = 0.532$\\,m however for the blue line, the $r_2$ is 100\\,mm further out, for the orange line 50\\,mm further out and for the green line 10\\,mm further out.}\n  \\label{fig:phiDeviation}\n\\end{figure}\n\n\\begin{table}\n  \\centering\n  \\begin{tabular}{ccc}\n    \\toprule\n    $r_1$ & $r_2$ & $\\Delta \\phi$ \\\\\n    \\midrule\n    532 & 632 & 0.064 \\\\\n    542 & 622 & 0.051 \\\\\n    552 & 612 & 0.038 \\\\\n    562 & 602 & 0.026 \\\\\n    572 & 592 & 0.013 \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Some numbers for the $\\phi$ deviation for a particle with $\\pt = 1$\\,GeV.\n  Distances are in mm, angles in radians.}\n\\end{table}\n\n\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\linewidth,angle=-90]{images/pileup_hits}\n  \\caption{The number of hits in the outermost tracking layer (spacing 20mm) as a function of pileup.\n  No transverse momentum cut is applied, other than that the hit must have reached the outermost layers.}\n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "74e3c36b01b4ab8c3cf07df5abb9793d17bbc58c", "size": 11768, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/hits/hits.tex", "max_stars_repo_name": "will-fawcett/trackerSW", "max_stars_repo_head_hexsha": "fc097b97539d0b40a15e1d6e112f4048cb4122b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documentation/hits/hits.tex", "max_issues_repo_name": "will-fawcett/trackerSW", "max_issues_repo_head_hexsha": "fc097b97539d0b40a15e1d6e112f4048cb4122b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/hits/hits.tex", "max_forks_repo_name": "will-fawcett/trackerSW", "max_forks_repo_head_hexsha": "fc097b97539d0b40a15e1d6e112f4048cb4122b4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.0333333333, "max_line_length": 214, "alphanum_fraction": 0.6845683209, "num_tokens": 4043, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.4458558524507835}}
{"text": "\\subsection{L* Execution}\n\\label{sec:l-exec}\n\\begin{enumerate}\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c}\n            $T_1$ & $\\E$ \\\\\n            \\hline\\hline\n            $\\E$  & 1    \\\\\n            \\hline\\hline\n            b     & 1    \\\\\n            a     & 0    \\\\\n          \\end{tabular}\n        \\end{minipage} \\quad\n        \\begin{minipage}{0.6\\textwidth}\n          The table is not closed, because $row(a) = 0$ is not present in S. \\\\\n          $b$ will be promoted.\n        \\end{minipage}\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c}\n            $T_2$ & $\\E$ \\\\\n            \\hline\\hline\n            $\\E$  & 1    \\\\\n            a     & 0    \\\\\n            \\hline\\hline\n            b     & 1    \\\\\n            ab    & 0    \\\\\n            aa    & 1    \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $ab$ and $aa$ have been added in $SA$ to respect the condition where: $\\forall x \\in S, \\forall y \\in \\Sigma, \\exists z \\in S_{ext} \\text{ such that } x \\cdot y = z $.\\\\\n          The table is closed ($\\forall x \\in SA, \\exists s \\in S \\mid row(x) = row(s)$) and consistent (there are no two similar rows in $S$), the \\textit{Learner} can send its conjecture.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\input{sections/automata/L_aut1.tex}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          This is the automaton sent.\n          The states are $0$ and $1$ since there are two distinct rows in the upper part of the table, $1$ is the initial state since $row(\\E) = 0$ and it is also accepting since $T(\\E) = 1$.\\\\\n          Transitions are made as follow: \\\\\n          \\begin{itemize}\n            \\item $\\delta(1, a) = \\delta(row(\\E), a) = row(\\E \\cdot a) = 0$.\n            \\item $\\delta(1, b) = \\delta(row(\\E), b) = row(\\E \\cdot b) =  1$.\n            \\item $\\delta(0, a) = \\delta(row(a), a) = row(a \\cdot a) =  1$.\n            \\item $\\delta(0, b) = \\delta(row(a), b) = row(a \\cdot b) = 0$.\n          \\end{itemize}\n          However, the automaton is not valid, since the word \\textit{aba} is accepted by the conjecture but not by the \\textit{Teacher}.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c}\n            $T_3$ & $\\E$ \\\\\n            \\hline\\hline\n            $\\E$  & 1    \\\\\n            a     & 0    \\\\\n            aba   & 0    \\\\\n            ab    & 0    \\\\\n            \\hline\\hline\n            b     & 1    \\\\\n            aa    & 1    \\\\\n            abab  & 0    \\\\\n            abaa  & 0    \\\\\n            abb   & 1    \\\\\n          \\end{tabular}\n        \\end{minipage} \\quad\n        \\begin{minipage}{0.5\\textwidth}\n          $aba$ as been added in $S$ as well as each of its prefixes. $abab, abaa \\text{ and } abb$ have been added in $SA$ to keep the \\OT complete. \\\\\n          This table is not consistent: $row(a) = row(aba)$ but taking $row(a \\cdot a) \\neq row(aba \\cdot abaa)$. Column $a$ is going to be added because $T(a \\cdot a \\cdot \\E) \\neq row(aba \\cdot a \\cdot \\E)$\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c|c}\n            $T_4$ & $\\E$ & a \\\\\n            \\hline\\hline\n            $\\E$  & 1    & 0 \\\\\n            a     & 0    & 1 \\\\\n            aba   & 0    & 0 \\\\\n            ab    & 0    & 0 \\\\\n            \\hline\\hline\n            b     & 1    & 1 \\\\\n            aa    & 1    & 1 \\\\\n            abab  & 0    & 0 \\\\\n            abaa  & 0    & 0 \\\\\n            abb   & 1    & 1 \\\\\n          \\end{tabular}\n        \\end{minipage} \\quad\n        \\begin{minipage}{0.5\\textwidth}\n          $T_43$ is not closed: $row(b)$ is not present in $S$, so it will be promoted.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c|c}\n            $T_5$ & $\\E$ & a \\\\\n            \\hline\\hline\n            $\\E$  & 1    & 0 \\\\\n            a     & 0    & 1 \\\\\n            aba   & 0    & 0 \\\\\n            ab    & 0    & 0 \\\\\n            b     & 1    & 1 \\\\\n            \\hline\\hline\n            aa    & 1    & 1 \\\\\n            abab  & 0    & 0 \\\\\n            abaa  & 0    & 0 \\\\\n            abb   & 1    & 1 \\\\\n            bb    & 1    & 1 \\\\\n            ba    & 1    & 1 \\\\\n          \\end{tabular}\n        \\end{minipage} \\quad\n        \\begin{minipage}{0.5\\textwidth}\n          $T_5$ is not consistent $row(aba) = row(ab)$ but $row(abab) \\neq row(abb)$\n          Column $b$ is going to be added because $T(aba \\cdot b \\cdot \\E) \\neq row(ab \\cdot b \\cdot \\E)$\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c|c|c}\n            $T_6$ & $\\E$ & a & b \\\\\n            \\hline\\hline\n            $\\E$  & 1    & 0 & 1 \\\\\n            a     & 0    & 1 & 0 \\\\\n            aba   & 0    & 0 & 0 \\\\\n            ab    & 0    & 0 & 1 \\\\\n            b     & 1    & 1 & 1 \\\\\n            \\hline\\hline\n            aa    & 1    & 1 & 1 \\\\\n            abab  & 0    & 0 & 0 \\\\\n            abaa  & 0    & 0 & 0 \\\\\n            abb   & 1    & 1 & 1 \\\\\n            bb    & 1    & 1 & 1 \\\\\n            ba    & 1    & 1 & 1 \\\\\n          \\end{tabular}\n        \\end{minipage} \\quad\n        \\begin{minipage}{0.5\\textwidth}\n          $T_6$ is closed and consistent.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\input{sections/automata/L_aut2.tex}\n        \\end{minipage}\\quad\\\\\n        \\begin{minipage}{0.6\\textwidth}\n          This automaton recognized perfectly the language proposed by the Teacher, so the algorithm can stop.\n        \\end{minipage}\n\\end{enumerate}", "meta": {"hexsha": "90638f3708b923b942fe29aca21d8f02385707c8", "size": 5620, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/annexe/example/L_example.tex", "max_stars_repo_name": "FissoreD/TER-M1-M1S2", "max_stars_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/sections/annexe/example/L_example.tex", "max_issues_repo_name": "FissoreD/TER-M1-M1S2", "max_issues_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-21T17:29:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T17:29:10.000Z", "max_forks_repo_path": "report/sections/annexe/example/L_example.tex", "max_forks_repo_name": "FissoreD/TER-M1-M1S2", "max_forks_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.3006993007, "max_line_length": 208, "alphanum_fraction": 0.4336298932, "num_tokens": 1918, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4458558484108176}}
{"text": "\n\\section{The Mixed Weighted Straight Skeleton}\n\\label{sec:mwss}\n\n% Do we want to say that the PWSS may not grow (if all theta zero),?\n\nThe final variation of the SS we will introduce is the \\emph{mixed weighted straight skeleton} (MWSS). This new structure allows the angle of the direction planes, $\\theta$, to be positive or negative over edges in a single plan. Thus regions of the active plan can shrink inwards or grow outwards. Once again the increased degrees of freedom introduce new types of degeneracy. This section introduces some of the issues surrounding these \\emph{point degeneracies}, presents an algorithm for simplifying them, and introduces one theorem as to the solution of such cases.\n\n%: $-\\frac{\\pi}{2} < \\theta < \\frac{\\pi}{2}$. Inititively this allows the edges of the active plan to move towards the interior or exterior at the same time.\nAs in the PWSS case, $\\theta$ is limited in the MWSS to avoid infinitely fast edges on the active plan, allowing only  $-\\frac{\\pi}{2} < \\theta < \\frac{\\pi}{2}$. Therefore a $\\theta < 0$ implies that an active plan edge is moving away from the interior of the polygon, a $\\theta = 0$ implies an edge that does not move, and a $\\theta > 0$ implies an edge is moving towards to interior of the polygon. Fig.~\\ref{fig:wss_strange} gives an example of both a PWSS and MWSS.\n%The angle defines the slope of the face associated with that edge of the input plan. That is, $\\theta$ defines the speed of the edge on the active plan as the sweep plan rises.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_strange}\n  \\caption[Degenerate events in the PWSS and MWSS]{\\label{fig:wss_strange}. Left: A complex event in a PWSS, over a plan (green). Right: A MWSS in which four areas merge to become one. Note that the 3D models are the resulting terrains of a skeleton as some MWS skeletons are difficult to illustrate in 2D.}\n\\end{figure}\n\nThe MWSS enables a wider variety of 3D terrains to be defined; the set of skeletons definable are a superset of the SS, PWSS and NWSS schemes. For example the active plan can grow, as well as shrink, or can be a mixture of both. Therefore certain MWSSs may not terminate after the final event; the enclosed area may continue growing indefinitely as the sweep plane rises. It is an open problem to determine if a given MWSS will terminate if it contains any values of $\\theta < 0$, without executing the skeleton algorithm itself. Fig.~\\ref{fig:wss_unbounded} gives an example in which the resolution of a borderline case differentiates between an non-terminating skeleton, and a terminating one.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_unbounded}\n  \\caption[Unbounded MWSS]{\\label{fig:wss_unbounded}MWSS that are bounded (left) and unbounded (right). The red face grows to an infinite area as the sweep plane rises. A small perturbation to the input plans is the only difference between the input plans, all $\\theta$ value are equal. The PCE event which occurs along the orange line determines the behaviour of the skeleton. }\n\\end{figure}\n\nAs with the PWSS, the active plan can split as the sweep plane rises. But as Fig.~\\ref{fig:wss_strange} shows, like the NWSS, MWSS regions can merge.\n\nWe note in passing that MWSS events exist in which no resolution is necessary. The edges intersect only at the event, but not after it. We disregard these \\emph{grazing} events in what follows, as they are trivial to test for and may be simply ignored.\n\nGiven the additional degrees of freedom available in the MWSS we expect to encounter the degenerate situations observed in the SS and PWSS cases. In addition there are are a new class of \\emph{point degeneracies} observable\n\n\\FloatBarrier\n\\subsection{Point degeneracies}\n\nGiven the additional degrees of freedom available in the MWSS, it is unsurprising that the GIE solution no longer solves all situations. Fig.~\\ref{fig:pwss_gie_failure} gives one simple example event in which the GIE causes the active plan to become badly formed.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/pwss_gie_failure}\n  \\caption[The GIE doesn't work on the PWSS]{\\label{fig:pwss_gie_failure}A MWSS topology at (left) and after (middle, right) an event (orange) that is not suitable for the GIE. The GIE output (middle, purple) is self-intersecting, and thus badly formed. A non-intersecting solution does exist (right).}\n\\end{figure}\n\nIndeed every edge of an arbitrary input plan may be coerced to collide at single point by altering the values of $\\theta$. A more complex example of a simple event is introduced in Fig.~\\ref{fig:wss_example_topology}, which shows a possible event with many edges colliding. Here we can see chains of edges representing bounded, as well as unbounded areas, loops, and chains surrounding other chains, colliding at a simple event. \n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_example_topology}\n  \\caption[A point degeneracy]{\\label{fig:wss_example_topology} Left: The active plan just before an event. A complex set of chains collide at a single event (orange). Right: after the intra-chain step and one-chain step of the GIE the topology is simplified. Note that the curved edges marked with an asterisk represent the topology of two colinear straight edges.}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{0.4\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_enclosing_chain}\n  \\caption[Enclosing chains]{\\label{fig:wss_enclosing_chain} We describe the chain \\emph{a} as enclosing chain \\emph{b}, as \\emph{b} lies inside \\emph{a}, and therefore $\\phi < \\gamma$, $\\phi < \\pi$ radians. The chains are shown here before a collision at the orange point.}\n\\end{figure}\n\nIf all the edges are moving inwards or outwards, as with the PWSS or NWSS, the SS GIE introduced in Sec.~\\ref{s:gie} is still suitable. However in the complex degenerate events that may occur with some angles of $\\theta > 0$ and some $\\theta < 0$, another algorithm is needed. Fig.~\\ref{fig:wss_options} gives one such situation and a number of plausible solutions.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_options}\n  \\caption[Several solutions to the MWSS]{\\label{fig:wss_options}Above: Four chains collide at an event (orange point). The desired plan topology after the event is unclear. We must keep the interface edges (above, right: bold green arrows) in the same locations to remain compatible with the remainder of the plan. Below: There are many possible options for the topology change at the event. (Note that we show the active plan a time after the event). Some solutions use existing edges, others create new zero length edges (below: red shadows). During the event these edges have zero length, but subsequently grow).}\n\\end{figure}\n\n\\FloatBarrier\n\nCharacteristics that are logical in an algorithm for such events include:\n\n\\begin{enumerate}\n\\item{The plan remains well formed.}\n\\item{Consistency with the SS when all angles are a positive constant.}\n\\item{Consistency with the PWSS when all angles are positive.}\n\\item{Consistency with the NWSS when all angles are negative.}\n\\item{Invariance to rotation of the plan. As with the the straight skeleton the result of an event should not depend on the orientation of the plan.}\n\\item\\label{enum:tmp}{No creation of new zero length edges during the event. The SS, PWSS and NWSS do not introduce additional edges; for consistency, neither should the MWSS.}\n\\end{enumerate}\n\nWe have been unable to find a elegant general solution to this problem!\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{0.8\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_hand_examples}\n  \\caption[Manual examples of good MWSS solutions]{\\label{fig:wss_hand_examples} Several example events and solutions that do not require 0-length edges to be introduced into the active plan. The geometry (green area) is shown after the event, and consists of length 2 chains colliding. A good solution for each topology is shown in purple. All examples except that in top, middle, fail when the GIE is used.}\n\\end{figure}\n\nWe hypothesise that it is always possible to find a solution in the events we encounter. Fig.~\\ref{fig:wss_hand_examples} shows several events and potential solutions, however an algorithm to compute these events has not been discovered. In particular it is condition \\ref{enum:tmp}, finding solutions that do not introduce zero length edges, that rules out many obvious algorithms.\n\nWe continue by introducing one further processing step that simplifies these point degeneracies by removing parallel edges. Finally we conclude by introducing a concise description of the unsolved problem, given this simplified event.\n\n\\subsection{Removing Parallel Adjacent Edges}\n\nAs per the GIE introduced in Sec.~\\ref{s:gie} the topology of the event can be simplified by the intra chain and one chain steps. These steps simulate the plan as the sweep plan reaches the height of the event. Zero length edges, including chains that form a closed loop are removed and chains of length 1 are split, leaving a homogeneous topology of chains of length 2.\n\nAt an event all the edges involved in the collision approach the location in an ordering defined by the edge's orientation. Fig.~\\ref{fig:wss_ordered_point}, left, shows the orientation-ordered points for Fig.~\\ref{fig:wss_example_topology}. Any edges that do not approach according to their angle must have been removed by an earlier collision, Fig.~\\ref{fig:wss_ordered_point}, right. This property is known as the \\emph{$\\ge$ approaching edges} property. This refers to the fact that the angle between consecutive edges around an intersection is equal to, or greater than, zero.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_ordered_point}\n  \\caption[Ordering chains around the event]{\\label{fig:wss_ordered_point} As the chains of edges in the MWSS approach the event (orange) they become ordered (left). If this were not the case (right), they would have intersected during an separate earlier event (red).}\n\\end{figure}\n\nThe simplification we would like to perform is the removal of edges which are adjacent and parallel as they approach the event. That is when two parallel edges separated by $0^{\\circ}$ approach an event from the same side. The area between these edges approaches zero near the event. If we connect these adjacent edges together, the event at the other end of the parallel lines will remove the loop in its intra chain stage. Therefore it can be ignored for the purposes of this event. After we remove these lines, we can say that the event has the \\emph{$>$ approaching edges property} as all the angles between adjacent approaching edges are greater than zero.\n\nThis basic approach is hampered by the fact that more than two parallel edges may be adjacent at an event. If there are an even number of such edges at one event, the adjacent pairs of edges can be connected together to enclose a region under the sweep plane, as in Fig.~\\ref{fig:wss_linear_align}. However if there are an odd number of edges, one edge must be chosen that is not connected to another and remains. This decision should be independent of the order co-heighted events are processed in, and must discard the same edge globally. Here we present two resolutions:\n\\begin{itemize}\n\\item{\\emph{interior bias:} The pairs of lines surrounding an interior region of the plan are always connected.}\n\\item{\\emph{exterior bias:} The pairs of lines surrounding an exterior region of the plan are always connected.}\n\\end{itemize}\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{0.7\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_linear_align}\n  \\caption[Global coordination of a solution with parallel edges]{\\label{fig:wss_linear_align} Given a plan before the event (top left) that leads to a number of events with parallel adjacent edges at the same height (top right, red blue and yellow circles), a deterministic and reproducible decision must be made as to which of the parallel edges are connected. The solutions given are to connect the parallel adjacent lines with an interior bias (bottom left) or exterior bias (bottom right). The areas v, w, x and y are all removed by subsequent events.}\n\\end{figure}\n\nThe earlier example in Fig.~\\ref{fig:wss_example_topology}, is resolved using these two resolutions as shown in Fig.~\\ref{fig:wss_equal_approach_killer}. Note that although the edges remaining have the same orientation, they may have different speeds. A consequence of the necessity of choosing an interior or exterior bias is that otherwise symmetrical plans may produce an asymmetrical outcome after an event. For example Fig~\\ref{fig:skel_impossible} shows a plan that before the event is not changing area, but after will either be gaining, or losing area if the interior or exterior biases are chosen respectively.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_equal_approach_killer}\n  \\caption[Removing zero area chains]{\\label{fig:wss_equal_approach_killer} After the intra chain step and one chain steps, we have a simplified topology (top, left). The chains are shown just before the event for clarity. The black lines connect (asterisked) edges which would become adjacent and parallel at the event. We convert these pairs of edges into single chains as shown. We either use the interior bias (top right) or exterior bias (bottom left). After any subsequent events at the same height are processed we are left with simplified topology (bottom right, for exterior bias).\n}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/skel_impossible}\n  \\caption[A MWSS event that cannot be fairly solved]{\\label{fig:skel_impossible}A MWSS event that has unchanging area before the event, but will either grow or shrink after, depending on the resolution strategy.}\n\\end{figure}\n\n\n\\FloatBarrier\n\\subsection{The Pincushion Problem}\n\\label{sec:pincushion}\n\nOnce an event has been prepared in the above way, we wish to process it in such a way that the plan remains well formed after the event. This is an unsolved problem; this section makes only definitions and observations.\n\nGiven a valid event that has been pre-processed such that it has the $>$ approaching edges property, the \\emph{pincushion problem} is to devise an algorithm that always finds a solution that does not introduce new zero length edges in to the active plan. First we will show that the plan remains topologically invariant after an event, and then that we can draw a circle around all possible intersections of edges involved in the event. This ``pincushion'' circle, with ``pin'' edges leading into it encapsulates the problem of solving a general MWSS event.\n\nAs the sweep plane rises towards an event, after it has processed any previous events, the topology of the edges does not change. By definition the plan is well-formed before the event, with no self-intersections. Furthermore we can note that there are no topological changes as the sweep plane approaches the height; such changes would be witnessed by other events. Of more consequence is that topological invariance may also be observed after the event. That is, if we do not handle the event, the geometry after the event only scales, rather than changing topology.\nWe call this the \\emph{sector property} of SS events, and is introduced in Fig~\\ref{fig:wss_sector}. The sector property is summarised in the trivial statement ``between events, no events occur''.\n\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/wss_sector}\n  \\caption[The sector property]{\\label{fig:wss_sector}The plan (green triangles) undergoes an event (orange). The sector property states that topology of the edges remains unchanged after the event if we make no attempts at solving it (after 1, 2).}\n\\end{figure}\n\n%\\begin{figure}\n%  \\centering\n%  \\def\\svgwidth{0.5\\columnwidth}\n%  \\includesvg{12-skeleton/images/wss_sector_2}\n%  \\caption[The sector property]{\\label{fig:skel_sector_2}After an event (orange), any intersection %between two edges, such as a corner, remains at constant angle, $\\gamma$, relative to the event %location. This gives rise to the sector property.}\n%\\end{figure}\n\n\nThe sector property follows from two previous definitions:\n\\begin{itemize}\n\\item{The edges move over the plan in a self-parallel manner, at a constant speed.}\n\\item{The edges involved in an event pass through the event's location at the event}\n\\end{itemize}\nApplying these two definitions allows us to make the trivial observation that all intersections between any pairs of edges move directly away from the intersection point after the event, each with constant speed. Therefore the order of crossings of any subset of involved edges remains invariant, along with the topology.\n\nWe may note in passing that there are three topologies of the edges involved in the event - before, at and after. The topology at the event only occurs for a single sweep-plane height, at an instant in time. We define the pincushion problem on the topology after the event.\n\nTo find solutions in the MWSS case it is necessary to extend some of the edges. An example where this is required is shown in Fig.~\\ref{fig:pwss_extenstions_required}.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{0.7\\columnwidth}\n  \\includesvg{12-skeleton/images/pwss_extensions_required}\n  \\caption[Edges become rays in the pincushion problem]{\\label{fig:pwss_extenstions_required}A PWSS event in which the only solution requires the extension of edges (dashed line) from their unmodified post-event topology.}\n\\end{figure}\n\nGiven the invariant topology at some time after the event in question, there are only a finite number of edges involved. If we intersect all the edges we obtain a finite number of possible intersection points that may make up the solution. We discount non-intersections between parallel edges. Therefore we may attempt to encapsulate our problem by drawing a circle that encompasses all these possible intersection points. An example of the resulting \\emph{pincushion} diagram is given in Fig.~\\ref{fig:pincushion}. From the edge of the circle, an even number of unbounded edge-rays are ordered by angle around the perimeter. Rays are used since we may have to extend some of the line segments. There are an even number of rays, for each edge of the active plan that enters and leaves the circle.\n\nA trivial observation is that for any successful solution only odd-numbered rays may intersect even number rays and vice versa (for any ordering around the perimeter of the pincushion). This matches the intuition that the orientation of the edges within the active plan determines which other edges they may intersect with. To this end we may colour the rays in the diagram with alternating colours; rays may only connect with other rays of the other colour, but may not cross any other rays as in Fig.~\\ref{fig:pincushion} bottom row.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/pincushion}\n  \\caption[The Pincushion diagram]{\\label{fig:pincushion}Top Left: It is possible to draw a circle around all possible edges that intersect at an event. Top Middle, Right: Given the sector property, we may summarise the topology as rays entering the pincushion circle. Bottom Left: We may assign alternating colours to rays around the circle. Bottom Middle: A pincushion diagram coloured in this way. Bottom Right: A solution to this pincushion consisting of the intersections $\\{(m_2,f_1), (m_1,f_2), (f_3, m_4), (m_3, f_4), (m_6, f_5) (m_5, f_6)\\}$}\n\\end{figure}\n\nIn a valid solution all pairs of rays in the pincushion diagram are connected to form chains of length 2, in such a way that the chains do not cross. We hypothesise that it is \\emph{always possible to solve the pincushion problem}. Given a such a solution we can update the active plan in all situations.\n\nThe solution is not unique, as in Fig.~\\ref{fig:mwss_multiple_solns}. Given a number of solutions we may chose to use the criteria of Sec.~\\ref{sec:mwss} to determine which solution is most suitable for our application.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/mwss_multiple_solns}\n  \\caption[PWSS events may not have unique solutions]{\\label{fig:mwss_multiple_solns}Given the post-event topology (top left), and the corresponding pincushion diagram (top right), there are three different solutions that do not introduce zero length lines (bottom).}\n\\end{figure}\n\nA brute force search program has been written to search for valid edge pairs to intersect. Fig.~\\ref{code:brute_force_pincushion} details an algorithm that applies the intra-chain stage of the GIE to all allowable subsets of edges in the event. This algorithm, together with a visual interface, as in Fig.~\\ref{fig:bute_app_screenies}, never failed to find a solution to a valid pincushion arrangement. However, without a proof that there is always a solution to the pincushion problem we can not be certain that the brute force approach will always return a valid active plan.\n\n\\begin{algorithm} [htb]\n\\begin{footnotesize}\n  BruteForceEvent ( Event $event$ ) \\Begin{\n   \n    $pincusion$ = preprocess( $event$ )\\; \n   \n    Set$<$Set$<$Set$<$Chain$>>>$ $combinations$ = all covering combinations of $pincushion$.chains()\\;\n\n    \\ForEach{ Set $<$Set$<$Chain$>>$ $GIEChains$ in $combinations$} {\n        Set$<$Chain$>$ $resolvedChains$ = new emptySet()\\;\n\n        \\ForEach { Set$<$Chain$>$ $chain$ in $GIEChains$ }{\n          $resolvedChains$.add( interChainStage ( $chains$ ) )\\;\n        }\n        \n        \\If { noChainsIntersect( $resolvedChains$ )  } {\n            return $resolvedChains$\\;\n          }\n        }\n    \n    return $null$\\;\n}\n\\end{footnotesize}\n  \\caption[A brute force approach to the pincusion problem]{A brute force approach to the pincusion problem. We hypothesise that it will never return $null$.}\n  \\label{code:brute_force_pincushion}\n\\end{algorithm}\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{0.7\\columnwidth}\n  \\includesvg{12-skeleton/images/bute_app_screenies}\n  \\caption[Brute force application]{\\label{fig:bute_app_screenies}A user interface to the pincusion event solver. Top Left: The users selects a resolution algorithm (a), draws the edges involved in the event around the event location (b), and selects the time relative to the event (c). Top Right: The system simulates the topology at the event. Bottom: The system shows the solutions given by the GIE (Left) and brute force algorithms (Right) in purple after the event.}\n\\end{figure}\n\nAnother approach is a constructive methodology to incrementally add the next pair of rays to an already valid solution, given some arbitrary order of rays. Since we theorise that all such arrangements have a valid solution, such a solution should be possible. However a counter example was found in the ``5-star'' structure of Fig.~\\ref{fig:epp_5_cycle}. Attempting to incrementally add rays around the circumference, always keeping a valid solution with those lines already processed, either is not possible, or does not terminate; it is necessary to solve the system globally. In this case the GIE provides such a solution. We therefore believe that a global solution must be found, rather than an iteratively constructed one.\n\n\\begin{figure}\n  \\centering\n  \\def\\svgwidth{1.0\\columnwidth}\n  \\includesvg{12-skeleton/images/epp_5_cycle}\n  \\caption[The 5 Star Pincushion]{\\label{fig:epp_5_cycle} The ``5 star'' event arrangement of edges, shown after the event (a), and the corresponding pincushion diagram (b). A constructive approach, which takes an arbitrary ordering of edges  (c, grey lines) and attempts to maintain a valid solution with each additional line (d), runs into problems when it cannot alter a past result (e). The correct solution in this case (f,g) must be found globally, and happens to be the same as the GIE solution.}\n\\end{figure}\n\nThe failures of the GIE, brute force, and incremental approaches to the pincushion problem are disappointing. Ultimately the lack of proof that the events of the MWSS have well formed solutions is problematic to the definition of the MWSS. However we may take solace that these are very degenerate situations and solutions that do introduce zero length edges are common.\n\n\\greybox{The pincushion problem was discussed with David Eppstein, author of \\cite{Epp:98} and Antoine Vigneron, author of \\cite{Cheng02}.}\n\n\\FloatBarrier\n\\section{Summary}\n\nIn this chapter we have explored a certain class of skeletons, formed by allowing the edges of a 2D shape to move in a self-parallel manner. By observing intersection events as the edges collapse we are able to trace out the arcs of the skeletons. Indeed it is by the simulation of the edge movements that we are able to evaluation skeletons. We may go so far as to describe the skeleton as a ``procedural geometric construct''. However the fact that we will use such a construct for ``procedural modeling'' would make such a description less than helpful.\n\n\n\nBy specifying different constraints over the speed of these edges, distinct classes of behaviour can be witnessed. Four varieties of the straight skeleton have been introduced -- the unweighted straight skeleton, the positively weighted skeleton, the negatively weighted straight skeleton, and the mixed weighted straight skeleton. These skeletons form a tree of generalisation as the requirements on the angle of the direction planes are relaxed; SS $\\subseteq$ PWSS $\\subseteq$ MWSS and NWSS $\\subseteq$ MWSS. Of these different geometric constructs only the SS was well previously well described in the literature. \n\nIn the non-degenerate case of the of SS, PWSS and NWSS we have simplified existing algorithms by introducing a GIE that specifies a general behaviour given an arbitrary topology of collapsing edges. However each additional generalisation has also brought with it new degenerate cases which we have presented, and found resolution strategies for. These have included the parallel consecutive edge event, many edge degeneracy, point degeneracy and parallel adjcent edges.\nHowever in the deepest, most unlikely, degenerate cases we were unable to suggest a general solution for the MWSS, managing only to formulate the pincushion description. Although we tried, we were unable to create either a proof that the pincushion problem was solvable or not.\n\nThe skeletons studied here also contain interesting properties, such as the SS splitting faces into two, the PWSS introducing holes into faces, and the MWSS allowing faces to merge together and split apart. We may also observe that many of the skeletons output resemble fragments of man made structures. The arcs between the faces of the output, the skeleton itself, serves as a polygonal partition of the polygon, influenced by a distance field. We take insipration from this fact in the following Chapter 4, where we use the arcs to partition city blocks into parcels. The offset 2D polygons generated in the shrinking process are reminsicent of man made arches or frames, while the 3D terrain model resembles building's roofs. In addition we find that it is possible to halt the evaluation of the MWSS at any point, creating a new form of extrusion between two plans. It is this observation that will lead us to the ideas in Chapter 5, using the MWSS for solid building modeling.\n\n\n\n\n\n\n%We now define several features of the MWSS that help us. The major axis, approaching edges and the sector properties.\n\n%The \\emph{major axis} defines the direction that all chains of length one take. There may be more than one chain of length one in the MWSS, Fig.~\\ref{fig:wss_example_topology}. However it is impossible for these chains to have more than one orientation in a single event as it occurs at a single point.\n\n%\\begin{figure}\n%  \\centering\n%  \\def\\svgwidth{0.5\\columnwidth}\n%  \\includesvg{12-skeleton/images/wss_major_axis}\n%  \\caption{\\label{fig:wss_major_axis}At an event (orange) we may not have more than one orientation of chains of length one. %If this were the case (above), there would be a point (red) which the 1-chains (green and blue) arrived at before the event. There would, therefore, have been another (red) event which combines these edges before they arrive at the first event (orange).}\n%\\end{figure}\n", "meta": {"hexsha": "cddfeb3ab88abd65f08e9d338b4d59e2704b3a7e", "size": 28646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "12-skeleton/mwss.tex", "max_stars_repo_name": "twak/unwritten_tex", "max_stars_repo_head_hexsha": "f3f05310e749887a5d149bd416f8c791c21010e7", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-02T00:32:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-02T00:32:05.000Z", "max_issues_repo_path": "12-skeleton/mwss.tex", "max_issues_repo_name": "twak/unwritten_tex", "max_issues_repo_head_hexsha": "f3f05310e749887a5d149bd416f8c791c21010e7", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "12-skeleton/mwss.tex", "max_forks_repo_name": "twak/unwritten_tex", "max_forks_repo_head_hexsha": "f3f05310e749887a5d149bd416f8c791c21010e7", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 99.1211072664, "max_line_length": 982, "alphanum_fraction": 0.7842281645, "num_tokens": 6806, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210895, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.44585584841081755}}
{"text": "\\documentclass{article}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\n\\usepackage[margin=1in]{geometry}\n\n\n\\def\\hwtitle{Computational Physics HW1}\n\\def\\hwauthor{Ethan Rooney}\n\\def\\hwdate{2020-01-29}\n\n\\usepackage{fancyhdr}\n\\lhead{\\hwauthor}\n\\chead{\\hwtitle}\n\\rhead{\\hwdate}\n\\lfoot{\\hwauthor}\n\\cfoot{}\n\\rfoot{\\thepage}\n\\renewcommand{\\footrulewidth}{0.4pt}\n\\pagestyle{fancy}\n\n\\author{\\hwauthor}\n\\title{\\hwtitle}\n\\date{\\hwdate}\n\n\\begin{document}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\\section{Introduction}\n\nA harmonic occilator is defined by a system that experiances a restoritive force proportional to its displacement from it's rest location. This is known as Hook's Law and the mathematical form is seen in \\( F_{x} \\eq \\minus kx \\). \\( F_x \\) is the force on the object. \\( k \\) is an arbitrary constant determined by the physical properties of a system (i.e. for a spring k would be determined by the stiffness of the material).  \\( x \\) is the displacement of an object from its \"rest\" position.\n  \n\nThis Homework deals with a special case where an object follows this law in X and Y independantly.\nAs such it is governed by the following  \\ref{eq:2}. \\( A \\) is the maximum amplitude reached by the system in a particular direction. \\( omega \\eq \\sqrt{k/m} \\). \n\\( m \\) is the mass of the object occelating. \\( phi \\) is the inital phase position of the system.\n\n\\begin{equation} \\label{eq:2}\n\tx(t)\\eq A_x\\sin(\\omega_xt+\\phi_x)\n\ty(t)\\eq A_y\\sin(\\omega_{y}t+\\phi_{y})\n\\end{equation}\n\nThe first part of the homework deals with cases when \\( \\omega_x \\) and \\( \\omega_y \\) are equal. \n\nFor the Bonus Problems I will explore some of the possibilites when \\( \\omega_x \\) and \\( \\omega_y \\)\nare varied independently.\n\n\\section{Results}\n\n\\bigskip\n\\noindent{\\bf Question 1}\n\\medskip\n\nCode submitted on Blackboard\n\n\\bigskip\n\\noindent{\\bf Question 2}\n\\medskip\n\nSee attached \\ref{plots}\n\n\\bigskip\n\\noindent{\\bf Question 3}\n\\medskip\n\nIf \\( \\omega_x \\eq \\omega_y \\) then the range of shapes possible are rather limited. The variation is from perfectly circular to a line. As \\( \\Delta\\phi \\) grows from \\( 0 \\) to \\( \\pi \\) the shape transitions from a line, of \\( y \\eq A_x / A_yx \\), through an eliptical shape to a circle, at \\( \\Delta\\phi \\eq \\pi \\), then back to a line, of \\( y \\eq -A_x / A_y \\times x \\).\n\n\n\\bigskip\n\\noindent{\\bf Bonus 1}\n\\medskip\n\nFor small ratios of \\( \\omega_x \\) and \\( \\omega_y \\) a closed loop was formed and the pattern would repeat like the center plot in \\ref{lissa}, so long as \\( \\Delta\\phi \\neq n\\pi \\) where \\( \\n \\) is an integer. If \\( n \\) is an integer, then instead of \"looping\" the system will occilate back and forth along a single path like scene in the first plot in \\ref{lissa}.\n\n\\bigskip\n\\noindent{\\bf Bonus 2}\n\\medskip\n\nIf the ratios of \\( \\omega_x \\) and \\( \\omega_{y} \\) are irrational numbers i.e. \\( \\sqrt{5} \\) like seen in the right most plot of \\ref{lissa}, then the system cannot repeat. This leads to what appears to be random dots. But if you look carefully you can see a structure to the dot. The system can almost, but not quite loop bak over itself and leave a series of nearly parallel paths.\n\n\\section{Conclusions}\n\nMain challenges faced in this coding project were discovering the \"-lm\" flag for gcc. It also served a good refresher on how to work with c.\nFurthermore, I had never worked with Mathematica before, discovering some of its' features for the first time was fun.\n\n\\section{Plots} \\label{plots}\n\\begin{figure}[b]\n\\begin{center}\n\\includegraphics[width=0.25\\textwidth]{plot1.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot2.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot3.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot4.pdf}\n\\end{center}\n\\caption{These plots above show the types of shapes possible to make using this system of harmonic occilaters.}\n\\end{figure}\n\n\\begin{figure}[b]\n\\begin{center}\n\\includegraphics[width=0.25\\textwidth]{plot5.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot6.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot7.pdf}\n\\includegraphics[width=0.25\\textwidth]{plot8.pdf}\n\\end{center}\n\\caption{These plots are nearly identical to the plots above, with the exception that in the amplitude in the y direction is twice what it would be in the corrisponding picture above.}\n\\end{figure}\n\n\\begin{figure}[b]\n\\begin{center}\n\\includegraphics[width=0.33\\textwidth]{plot9.pdf}\n\\includegraphics[width=0.33\\textwidth]{plot10.pdf}\n\\includegraphics[width=0.33\\textwidth]{plot11.pdf}\n\\end{center}\n\\caption{Seen above are some of the patterns formed by Lassajous figures}\n\\label{lissa}\n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "ebf5256d451d692a048f36e40479a9c256b177d8", "size": 4590, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week1/assignment1/report/hw-template.tex", "max_stars_repo_name": "ethanrooney/comphys", "max_stars_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week1/assignment1/report/hw-template.tex", "max_issues_repo_name": "ethanrooney/comphys", "max_issues_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week1/assignment1/report/hw-template.tex", "max_forks_repo_name": "ethanrooney/comphys", "max_forks_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9338842975, "max_line_length": 495, "alphanum_fraction": 0.7381263617, "num_tokens": 1337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.44573603658922273}}
{"text": "\\graphicspath{ {./img/intro/} }\n\n\\chapter{Introduction}\n\nIn an introductory graduate course in the Finite Element Method (FEM), the purpose is to develop a basic understanding of the discrete or numerical strategy of Finite Element-(FE) Algorithms when a closed form solution to a Boundary Value Problem (BVP) is not possible due to complexities existing probably: in the boundary conditions, material behavior or in the kinematic description used in the model. In such a course, in order to master and identify the main mathematical and algorithmic aspects of the method at the beginners level, the studied problem is kept lineal. In this sense 4 key aspects make the core of the introductory course (at least for the case of the linearized theory of elasticity boundary value problem):\n\n\\begin{itemize}\n\n\\item Formulation and identification of the strong form of the Boundary Value Problem (BVP) where the continuum mechanics governing equations are revisited and particularized to the case of linear elastic material behavior. The BVP is completed by identifying the correct prescription of boundary conditions for a well posed mathematical problem.\n\n\\item Formulation and identification of the weak form of the BVP where the governing equations and natural boundary conditions representing equilibrium at the material point level are replaced by an equivalent but weaker form of equilibrium now valid at the global level.  In the case of a Continuum Mechanics problem this so-called weak form can be shown to be equivalent to the principle of virtual power and lends itself for the partition of the problem into sub-domains or finite size elements.\n\n\\item Introduction of the idea of discretization dividing the problem into subdomains and using interpolation theory within each subdomain-In the context of the FE method this is the subject of shape functions. Once the computational specimen has been divided into subdomains (or a mesh of finite elements) the selected primary variable is approximated within each element via interpolation of the known response at selected predefined points or nodes.\n\n\\item Computational aspects grouped also into 5 points:\n\t\\begin{itemize}\n\t\\item Formulation of elemental matrices in the physical space.\n\t\\item Formulation of elemental matrices in the natural domain-Isoparametric transformation.\n\t\\item Numerical integration: Gauss quadrature.\n\t\\item Assembly of system matrices and imposition of boundary conditions.\n\t\\item Solution of the discrete equilibrium statement and calculation of elemental results.\n\t\\end{itemize}\n\\end{itemize}\n\nThese 4 key points are perfectly well documented in numerous nicely written textbooks and it could be argued that is not even worth to register for an introductory course since a moderately dedicated student can accomplish the task via self-study. Unfortunately, linearity is scarce--although useful to grasp the basic understanding of the problem--and the real world is full of non-linear behavior and understanding the needed algorithms can be easily justified. In this Introduction to the Finite Element Method course the goal is then to understand the basic aspects of non-linear finite element analysis.  Like in the linear case there is also a vast amount of literature for the non-linear problem.  However, in the non-linear case the kinematic problem itself may take different routes leading to a wide variety of FEM formulations that will difficult a self-study strategy.  Considering the above this brief set of class notes is intended as a guide for self-study and more important represents a help towards the implementation of the algorithm for the consideration of Material and Geometric Non-linearities in Solids.\n\nThe basic reference is Professor Bathe's textbook \\cite{book:bathe} but we will also follow closely Abaqus Theory Manual \\cite{abaqus_theory}. Abaqus is a multi-physics oriented commercially available finite element analysis tool. Its strength resides in the effective non-linear algorithms and on the capability of taking user subroutines written in Fortran or in \\CPP.  The possibility of implementing user subroutines makes it a very powerful research tool.  In the particular case of a stress/displacement analysis problem with non-linearities these are considered through the kinematics contribution or through the material contribution.  In the first case the non-linear behavior must be considered at the element level while in the second it corresponds to the response of a material point which in the context of the FEM algorithm corresponds to an integration point. In Abaqus those two sources of non-linearity can be independently controlled by the user via user subroutines UEL and UMAT.  In both cases the non-linearity is primarily solved by the classical Newton-Raphson scheme and that will be the approached followed herein.  Although the notes are mainly written for an advanced course the specific problem of a linear solid usually studied in the introductory course can be derived like a particular case of the most general non-linear algorithm.\n\nThe current set of Class Notes is organized as follows.  First and since we will be dealing with history dependent non-linear problems the most powerful (at least when it works) solution algorithm, namely the Newton-Raphson iteration is studied.  The technique is first illustrated for the simple 1D-case and then generalized into the multi-degree of freedom system.  In both cases pseudo-codes will be presented preparing the way for the Finite Element Algorithm.  The presentation however is not exhaustive in mathematical terms and the reader is referred to excellent treatments like Burden \\cite{book:burden2011} and Press et al. \\cite{book:numerical_recipes} for the mathematical aspects of the Newton method.\n\nIn the next section the briefly introduced Newton-Raphson technique is contextualized to the case of a system of equations representing equilibrium between internal and external forces as typically found in a finite element model.  Moreover, the non-linearities come into play through a dependence of the internal forces into displacements.  At this stage the details of the formulation of the finite element equations via discretization into nodal variables is not presented but emphasis is laid down into the solution algorithm.  Interest is then given to the particular form taken by the Newton-Raphson algorithm into the commercial finite element code Abaqus.  That code can be used as a powerful non-linear equation solver where the coefficient matrix and the excitation can be directly controlled by the user.  Moreover the solver can be used into a multi-physics context in terms of generalized forces and fluxes.  In the particular case of the stress analysis finite element method the user can control the elemental contribution to the coefficient matrix and the contribution of each material point to obtain that element contribution.  This is achieved through the so-called user subroutines UEL  for element and UMAT  for material.  Having introduced the Newton-Raphson method the notes concentrate next on general discretization aspects starting from the physical strong form of the equations in the deformed configuration and passing to an arbitrary weak form in the reference configuration.  The resulting algorithm is therefore a Total Lagrangian (TL) method.  Once the general equations are introduced a particular work conjugate stress-strain pair is chosen and the discrete equations, including kinematic interpolators, are described.\n\n\\section*{Notation}\nIn a non-linear algorithm the bookkeeping is involved since we have to simultaneously record 4 different fields as follows:\n\\begin{itemize}\n\t\\item The physical fields in terms of tensor descriptions.\n\t\\item The time field since the problem is solved incrementally \tand time may appear as an artificial chronological variable \tor as a real quantity in a dynamic problem.\n\t\\item The interpolation field.  Since all the involved variables will be interpolated we will need to keep track of the way this interpolation is being performed.\n\t\\item The iterations field needed in the solution of the non-linear problem.\n\\end{itemize}\nIn order to keep this bookkeeping simple we use the following index notation with subscripts and superscripts\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=4cm]{index_notation.pdf}\n\\caption{General notation to study non-linear finite element problems}\n\\label{fig:notation}\n\\end{figure}\n\n\\todo{Review notation.}Capital superscripts will be reserved for the incremental time description and for the interpolation scheme.  For instance an expression like   refers to the time instant   while   refers to . Similarly a variable   refers to interpolation over the node. Left and right subscripts will be used to make reference to the iteration being performed and the order of the tensor variable.  For instance   refers to a second order tensor corresponding to the iteration.", "meta": {"hexsha": "ac56b51059f461930a8570de0d9cbd6408764f7a", "size": 8971, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/intro.tex", "max_stars_repo_name": "jomorlier/FEM-Notes", "max_stars_repo_head_hexsha": "3b81053aee79dc59965c3622bc0d0eb6cfc7e8ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T01:53:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T01:53:14.000Z", "max_issues_repo_path": "src/intro.tex", "max_issues_repo_name": "jomorlier/FEM-Notes", "max_issues_repo_head_hexsha": "3b81053aee79dc59965c3622bc0d0eb6cfc7e8ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/intro.tex", "max_forks_repo_name": "jomorlier/FEM-Notes", "max_forks_repo_head_hexsha": "3b81053aee79dc59965c3622bc0d0eb6cfc7e8ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-25T17:19:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-25T17:19:53.000Z", "avg_line_length": 183.0816326531, "max_line_length": 1752, "alphanum_fraction": 0.8210901795, "num_tokens": 1739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.4456927418008026}}
{"text": "% !TeX root = main.tex\n\\section{回归结果} \\label{sec:results}\n\\subsection{北京市回归结果}\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{lclc}\n    \\toprule\n    \\textbf{Dep. Variable:}    & price            & \\textbf{  R-squared:         } & 0.732     \\\\\n    \\textbf{Model:}            & OLS              & \\textbf{  Adj. R-squared:    } & 0.731     \\\\\n    \\textbf{Method:}           & Least Squares    & \\textbf{  F-statistic:       } & 863.3     \\\\\n    \\textbf{Date:}             & Sun, 16 Jan 2022 & \\textbf{  Prob (F-statistic):} & 0.00      \\\\\n    \\textbf{Time:}             & 23:05:17         & \\textbf{  Log-Likelihood:    } & -80268.   \\\\\n    \\textbf{No. Observations:} & 7284             & \\textbf{  AIC:               } & 1.606e+05 \\\\\n    \\textbf{Df Residuals:}     & 7260             & \\textbf{  BIC:               } & 1.607e+05 \\\\\n    \\textbf{Df Model:}         & 23               & \\textbf{                     } &           \\\\\n    \\textbf{Covariance Type:}  & nonrobust        & \\textbf{                     } &           \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n\\begin{longtable}{lcccccc}\n  \\caption{Beijing OLS Regression Results}\n  \\label{tab:beijing_result}                                                                                                                               \\\\\n  \\toprule\n                     & \\textbf{coef}         & \\textbf{std err}    & \\textbf{t}        & \\textbf{P$> |$t$|$} & \\textbf{[0.025}      & \\textbf{0.975]}      \\\\\n  \\midrule\n  \\endfirsthead\n  \\caption[]{Beijing OLS Regression Results (续)}                                                                                                          \\\\\n  \\toprule\n                     & \\textbf{coef}         & \\textbf{std err}    & \\textbf{t}        & \\textbf{P$> |$t$|$} & \\textbf{[0.025}      & \\textbf{0.975]}      \\\\\n  \\midrule\n  \\endhead\n  \\textbf{Intercept} & \\tablenum{1.815e+04}  & \\tablenum{1144.337} & \\tablenum{15.862} & \\tablenum{0.000}    & \\tablenum{1.59e+04}  & \\tablenum{2.04e+04}  \\\\\n  \\textbf{0}         & \\tablenum{-318.2477}  & \\tablenum{180.670}  & \\tablenum{-1.761} & \\tablenum{0.078}    & \\tablenum{-672.413}  & \\tablenum{35.918}    \\\\\n  \\textbf{1}         & \\tablenum{2235.4543}  & \\tablenum{229.650}  & \\tablenum{9.734}  & \\tablenum{0.000}    & \\tablenum{1785.273}  & \\tablenum{2685.636}  \\\\\n  \\textbf{2}         & \\tablenum{-1534.4204} & \\tablenum{236.678}  & \\tablenum{-6.483} & \\tablenum{0.000}    & \\tablenum{-1998.378} & \\tablenum{-1070.463} \\\\\n  \\textbf{3}         & \\tablenum{23.2936}    & \\tablenum{73.607}   & \\tablenum{0.316}  & \\tablenum{0.752}    & \\tablenum{-120.997}  & \\tablenum{167.584}   \\\\\n  \\textbf{4}         & \\tablenum{-644.9779}  & \\tablenum{125.628}  & \\tablenum{-5.134} & \\tablenum{0.000}    & \\tablenum{-891.244}  & \\tablenum{-398.711}  \\\\\n  \\textbf{5}         & \\tablenum{82.6199}    & \\tablenum{172.075}  & \\tablenum{0.480}  & \\tablenum{0.631}    & \\tablenum{-254.698}  & \\tablenum{419.938}   \\\\\n  \\textbf{6}         & \\tablenum{-614.9914}  & \\tablenum{160.017}  & \\tablenum{-3.843} & \\tablenum{0.000}    & \\tablenum{-928.671}  & \\tablenum{-301.312}  \\\\\n  \\textbf{7}         & \\tablenum{-487.5924}  & \\tablenum{158.244}  & \\tablenum{-3.081} & \\tablenum{0.002}    & \\tablenum{-797.797}  & \\tablenum{-177.388}  \\\\\n  \\textbf{8}         & \\tablenum{-142.9470}  & \\tablenum{161.561}  & \\tablenum{-0.885} & \\tablenum{0.376}    & \\tablenum{-459.654}  & \\tablenum{173.760}   \\\\\n  \\textbf{9}         & \\tablenum{312.4724}   & \\tablenum{116.548}  & \\tablenum{2.681}  & \\tablenum{0.007}    & \\tablenum{84.003}    & \\tablenum{540.941}   \\\\\n  \\textbf{10}        & \\tablenum{1270.1086}  & \\tablenum{116.237}  & \\tablenum{10.927} & \\tablenum{0.000}    & \\tablenum{1042.251}  & \\tablenum{1497.967}  \\\\\n  \\textbf{11}        & \\tablenum{-26.1004}   & \\tablenum{103.495}  & \\tablenum{-0.252} & \\tablenum{0.801}    & \\tablenum{-228.980}  & \\tablenum{176.779}   \\\\\n  \\textbf{12}        & \\tablenum{763.8384}   & \\tablenum{98.091}   & \\tablenum{7.787}  & \\tablenum{0.000}    & \\tablenum{571.551}   & \\tablenum{956.126}   \\\\\n  \\textbf{13}        & \\tablenum{563.2973}   & \\tablenum{99.021}   & \\tablenum{5.689}  & \\tablenum{0.000}    & \\tablenum{369.187}   & \\tablenum{757.408}   \\\\\n  \\textbf{14}        & \\tablenum{-583.0906}  & \\tablenum{113.205}  & \\tablenum{-5.151} & \\tablenum{0.000}    & \\tablenum{-805.006}  & \\tablenum{-361.175}  \\\\\n  \\textbf{15}        & \\tablenum{605.8885}   & \\tablenum{121.843}  & \\tablenum{4.973}  & \\tablenum{0.000}    & \\tablenum{367.040}   & \\tablenum{844.737}   \\\\\n  \\textbf{16}        & \\tablenum{279.9137}   & \\tablenum{95.020}   & \\tablenum{2.946}  & \\tablenum{0.003}    & \\tablenum{93.647}    & \\tablenum{466.181}   \\\\\n  \\textbf{17}        & \\tablenum{-697.0469}  & \\tablenum{132.489}  & \\tablenum{-5.261} & \\tablenum{0.000}    & \\tablenum{-956.763}  & \\tablenum{-437.330}  \\\\\n  \\textbf{18}        & \\tablenum{103.6793}   & \\tablenum{149.566}  & \\tablenum{0.693}  & \\tablenum{0.488}    & \\tablenum{-189.514}  & \\tablenum{396.872}   \\\\\n  \\textbf{19}        & \\tablenum{-499.3558}  & \\tablenum{139.606}  & \\tablenum{-3.577} & \\tablenum{0.000}    & \\tablenum{-773.024}  & \\tablenum{-225.688}  \\\\\n  \\textbf{20}        & \\tablenum{3109.6958}  & \\tablenum{489.380}  & \\tablenum{6.354}  & \\tablenum{0.000}    & \\tablenum{2150.368}  & \\tablenum{4069.024}  \\\\\n  \\textbf{21}        & \\tablenum{-55.7886}   & \\tablenum{19.411}   & \\tablenum{-2.874} & \\tablenum{0.004}    & \\tablenum{-93.841}   & \\tablenum{-17.737}   \\\\\n  \\textbf{22}        & \\tablenum{-114.4076}  & \\tablenum{120.922}  & \\tablenum{-0.946} & \\tablenum{0.344}    & \\tablenum{-351.449}  & \\tablenum{122.634}   \\\\\n  \\bottomrule\n\\end{longtable}\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{lclc}\n    \\toprule\n    \\textbf{Omnibus:}       & 2542.377 & \\textbf{  Durbin-Watson:     } & 1.210     \\\\\n    \\textbf{Prob(Omnibus):} & 0.000    & \\textbf{  Jarque-Bera (JB):  } & 31068.689 \\\\\n    \\textbf{Skew:}          & 1.319    & \\textbf{  Prob(JB):          } & 0.00      \\\\\n    \\textbf{Kurtosis:}      & 12.768   & \\textbf{  Cond. No.          } & 2.02e+03  \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\nNotes: \\newline\n[1] Standard Errors assume that the covariance matrix of the errors is correctly specified. \\newline\n[2] The condition number is large, 2.02e+03. This might indicate that there are \\newline\nstrong multicollinearity or other numerical problems.\n\n\\subsection{上海市回归结果}\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{lclc}\n    \\toprule\n    \\textbf{Dep. Variable:}    & price            & \\textbf{  R-squared:         } & 0.669       \\\\\n    \\textbf{Model:}            & OLS              & \\textbf{  Adj. R-squared:    } & 0.669       \\\\\n    \\textbf{Method:}           & Least Squares    & \\textbf{  F-statistic:       } & 1026.       \\\\\n    \\textbf{Date:}             & Sun, 16 Jan 2022 & \\textbf{  Prob (F-statistic):} & 0.00        \\\\\n    \\textbf{Time:}             & 23:12:51         & \\textbf{  Log-Likelihood:    } & -1.2861e+05 \\\\\n    \\textbf{No. Observations:} & 11681            & \\textbf{  AIC:               } & 2.573e+05   \\\\\n    \\textbf{Df Residuals:}     & 11657            & \\textbf{  BIC:               } & 2.574e+05   \\\\\n    \\textbf{Df Model:}         & 23               & \\textbf{                     } &             \\\\\n    \\textbf{Covariance Type:}  & nonrobust        & \\textbf{                     } &             \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\\begin{longtable}{lcccccc}\n  \\caption{Shanghai OLS Regression Results}\n  \\label{tab:shanghai_result}                                                                                                                            \\\\\n  \\toprule\n                     & \\textbf{coef}        & \\textbf{std err}    & \\textbf{t}        & \\textbf{P$> |$t$|$} & \\textbf{[0.025}      & \\textbf{0.975]}     \\\\\n  \\midrule\n  \\endfirsthead\n  \\caption[]{Shanghai OLS Regression Results (续)}                                                                                                       \\\\\n  \\toprule\n                     & \\textbf{coef}        & \\textbf{std err}    & \\textbf{t}        & \\textbf{P$> |$t$|$} & \\textbf{[0.025}      & \\textbf{0.975]}     \\\\\n  \\midrule\n  \\endhead\n  \\textbf{Intercept} & \\tablenum{1.213e+04} & \\tablenum{1104.216} & \\tablenum{10.982} & \\tablenum{0.000}    & \\tablenum{9962.140}  & \\tablenum{1.43e+04} \\\\\n  \\textbf{0}         & \\tablenum{208.1793}  & \\tablenum{137.317}  & \\tablenum{1.516}  & \\tablenum{0.130}    & \\tablenum{-60.984}   & \\tablenum{477.343}  \\\\\n  \\textbf{1}         & \\tablenum{-620.6409} & \\tablenum{160.637}  & \\tablenum{-3.864} & \\tablenum{0.000}    & \\tablenum{-935.517}  & \\tablenum{-305.765} \\\\\n  \\textbf{2}         & \\tablenum{1154.0144} & \\tablenum{166.506}  & \\tablenum{6.931}  & \\tablenum{0.000}    & \\tablenum{827.634}   & \\tablenum{1480.395} \\\\\n  \\textbf{3}         & \\tablenum{-328.8537} & \\tablenum{110.295}  & \\tablenum{-2.982} & \\tablenum{0.003}    & \\tablenum{-545.050}  & \\tablenum{-112.657} \\\\\n  \\textbf{4}         & \\tablenum{377.6965}  & \\tablenum{116.365}  & \\tablenum{3.246}  & \\tablenum{0.001}    & \\tablenum{149.601}   & \\tablenum{605.792}  \\\\\n  \\textbf{5}         & \\tablenum{-489.5849} & \\tablenum{118.257}  & \\tablenum{-4.140} & \\tablenum{0.000}    & \\tablenum{-721.388}  & \\tablenum{-257.782} \\\\\n  \\textbf{6}         & \\tablenum{-941.0288} & \\tablenum{143.450}  & \\tablenum{-6.560} & \\tablenum{0.000}    & \\tablenum{-1222.215} & \\tablenum{-659.843} \\\\\n  \\textbf{7}         & \\tablenum{769.1201}  & \\tablenum{129.818}  & \\tablenum{5.925}  & \\tablenum{0.000}    & \\tablenum{514.655}   & \\tablenum{1023.585} \\\\\n  \\textbf{8}         & \\tablenum{-711.9080} & \\tablenum{92.832}   & \\tablenum{-7.669} & \\tablenum{0.000}    & \\tablenum{-893.875}  & \\tablenum{-529.941} \\\\\n  \\textbf{9}         & \\tablenum{560.3915}  & \\tablenum{129.874}  & \\tablenum{4.315}  & \\tablenum{0.000}    & \\tablenum{305.818}   & \\tablenum{814.965}  \\\\\n  \\textbf{10}        & \\tablenum{869.9834}  & \\tablenum{127.214}  & \\tablenum{6.839}  & \\tablenum{0.000}    & \\tablenum{620.622}   & \\tablenum{1119.344} \\\\\n  \\textbf{11}        & \\tablenum{645.5831}  & \\tablenum{92.588}   & \\tablenum{6.973}  & \\tablenum{0.000}    & \\tablenum{464.095}   & \\tablenum{827.071}  \\\\\n  \\textbf{12}        & \\tablenum{-95.8444}  & \\tablenum{136.095}  & \\tablenum{-0.704} & \\tablenum{0.481}    & \\tablenum{-362.613}  & \\tablenum{170.924}  \\\\\n  \\textbf{13}        & \\tablenum{301.4136}  & \\tablenum{98.198}   & \\tablenum{3.069}  & \\tablenum{0.002}    & \\tablenum{108.929}   & \\tablenum{493.899}  \\\\\n  \\textbf{14}        & \\tablenum{-253.1105} & \\tablenum{69.496}   & \\tablenum{-3.642} & \\tablenum{0.000}    & \\tablenum{-389.335}  & \\tablenum{-116.886} \\\\\n  \\textbf{15}        & \\tablenum{-183.6645} & \\tablenum{99.961}   & \\tablenum{-1.837} & \\tablenum{0.066}    & \\tablenum{-379.604}  & \\tablenum{12.275}   \\\\\n  \\textbf{16}        & \\tablenum{-215.7938} & \\tablenum{82.412}   & \\tablenum{-2.618} & \\tablenum{0.009}    & \\tablenum{-377.335}  & \\tablenum{-54.253}  \\\\\n  \\textbf{17}        & \\tablenum{400.7241}  & \\tablenum{124.958}  & \\tablenum{3.207}  & \\tablenum{0.001}    & \\tablenum{155.785}   & \\tablenum{645.663}  \\\\\n  \\textbf{18}        & \\tablenum{-262.7602} & \\tablenum{30.338}   & \\tablenum{-8.661} & \\tablenum{0.000}    & \\tablenum{-322.228}  & \\tablenum{-203.292} \\\\\n  \\textbf{19}        & \\tablenum{-448.9212} & \\tablenum{75.897}   & \\tablenum{-5.915} & \\tablenum{0.000}    & \\tablenum{-597.692}  & \\tablenum{-300.150} \\\\\n  \\textbf{20}        & \\tablenum{4231.6910} & \\tablenum{3216.305} & \\tablenum{1.316}  & \\tablenum{0.188}    & \\tablenum{-2072.805} & \\tablenum{1.05e+04} \\\\\n  \\textbf{21}        & \\tablenum{-15.9718}  & \\tablenum{12.171}   & \\tablenum{-1.312} & \\tablenum{0.189}    & \\tablenum{-39.830}   & \\tablenum{7.886}    \\\\\n  \\textbf{22}        & \\tablenum{308.3106}  & \\tablenum{138.158}  & \\tablenum{2.232}  & \\tablenum{0.026}    & \\tablenum{37.498}    & \\tablenum{579.123}  \\\\\n  \\bottomrule\n\\end{longtable}\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{lclc}\n    \\toprule\n    \\textbf{Omnibus:}       & 5219.570 & \\textbf{  Durbin-Watson:     } & 1.042      \\\\\n    \\textbf{Prob(Omnibus):} & 0.000    & \\textbf{  Jarque-Bera (JB):  } & 144950.970 \\\\\n    \\textbf{Skew:}          & 1.561    & \\textbf{  Prob(JB):          } & 0.00       \\\\\n    \\textbf{Kurtosis:}      & 19.973   & \\textbf{  Cond. No.          } & 8.12e+03   \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\nNotes: \\newline\n[1] Standard Errors assume that the covariance matrix of the errors is correctly specified. \\newline\n[2] The condition number is large, 8.12e+03. This might indicate that there are \\newline\nstrong multicollinearity or other numerical problems.\n", "meta": {"hexsha": "c8c4b28764e6c98ffb7ea20f25f0fbb5b5c09af8", "size": 12683, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writing/result.tex", "max_stars_repo_name": "godvix/housing-price-model", "max_stars_repo_head_hexsha": "e45b86de2dae56ce3f9c02d5921f6ca54eb28c40", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "writing/result.tex", "max_issues_repo_name": "godvix/housing-price-model", "max_issues_repo_head_hexsha": "e45b86de2dae56ce3f9c02d5921f6ca54eb28c40", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "writing/result.tex", "max_forks_repo_name": "godvix/housing-price-model", "max_forks_repo_head_hexsha": "e45b86de2dae56ce3f9c02d5921f6ca54eb28c40", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.2789115646, "max_line_length": 157, "alphanum_fraction": 0.5218796815, "num_tokens": 5311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597971, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.44569273521292807}}
{"text": "\\documentclass{article}\n\n\\usepackage[margin=0.5in]{geometry}\n\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\usepackage{cleveref}\n\n\\title{CE EN 507: Coding Assignment 2}\n\\author{ Jared J.~Thomas}\n\n\\begin{document}\n\\maketitle\n\n\\section{Part 1}\nPlease see attached file, fem.py, for my nD FEM code.\n\n\\section{Part 2}\n\\subsection{}\nThe parameters chosen for this problem are shown in \\cref{tab:parameters}. For Part 2, $A_S$ was used for $A$.\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{| r | r |}\n\t\t\\hline\n\t\t$L$ & 1.0 \\\\\n\t\t$N$ & 10.0 \\\\\n\t\t$E$ & 200E9 \\\\\n\t\t$A_{S}$ & 2.5E-5\\\\\n\t\t$A_{L}$ & 100 \\\\\n\t\t$I_1$ & 5.21e-11\\\\\n\t\t$I_2$ & 5.21e-11\\\\\n\t\t$J$ & 1.04e-10\\\\\n\t\t$\\nu$ & 0.3 \\\\\n\t\t$G$ & 76.9E9 \\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Parameters and other relevant values}\n\t\\label{tab:parameters}\n\\end{table}\n\n\\subsection{}\nThe maximum displacement at the right end of the beam using an analytic approach was 9.99999333611E-7.\n\n\\subsection{}\nPlease refer to \\cref{fig:part2} for a plot of computed displacements for Part 2.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{beam1_deflection_prob2_dof2}\n\t\\caption{Deflection plot for Part 2}\n\t\\label{fig:part2}\n\\end{figure}\n\n\\subsection{}\nThe maximum displacement at the right end of the beam using my FEM code was 1E-6, which is essentially equal to the analytic solution (9.99999333611E-7).\n\n\\section{Part 3}\n\n\\subsection{}\nRefer to \\cref{tab:parameters} for parameter and other values used in this section.\n\n\\subsection{}\nPlease see \\cref{fig:31,fig:32} for plots of $u^h(x)$ and $\\theta^h(x)$ versus the exact solution $u(x)$ and $\\theta(x)$.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{beam1_deflection_prob3_dof0}\n\t\\caption{$u^h(x)$ versus $u(x)$ for Part 3}\n\t\\label{fig:31}\n\\end{figure}\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{beam1_deflection_prob3_dof4}\n\t\\caption{$\\theta^h(x)$ and $\\theta(x)$ for Part 3. For p=1 and N=10, the FEM deflection is essentially zero}\n\t\\label{fig:32}\n\\end{figure}\n\n\\subsection{}\nFor this part, $A_S$ was used for the thin beam, and $A_L$ was used for the thick beam. (See \\cref{tab:parameters}. Results for the thin beam were as follows: $u^h_{max} = 0.118403120283$, $u_{max} = 0.1232000064$, $\\theta^h_{max} =  0.15999984117 $, and $\\theta_{max} = 0.16000128$. Results for the thick beam were as follows: $u^h_{max} = $7.87322000026E-13, $u_{max} = $7.7000004E-15, $\\theta^h_{max} = $9.99999E-15, and $\\theta_{max} = $1.000008E-14. It can be easily seen that the results for the thick beam for FEM and the analytic solution differed by an order of magnitude. This discrepency is due to the thin beam assumptions made to solve the problem as a beam problem.\n\n\\section{Part 4}\n\n\\subsection{}\nRefer to \\cref{tab:parameters} for parameter and other values used in this section.\n\n\\subsection{}\nPlease see \\cref{fig:41,fig:42} for plots of $u^h(x)$ and $\\theta^h(x)$ versus the exact solution $u(x)$ and $\\theta(x)$.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{beam1_deflection_prob4_dof0}\n\t\\caption{$u^h(x)$ versus $u(x)$ for Part 4}\n\t\\label{fig:41}\n\\end{figure}\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=0.75\\textwidth]{beam1_deflection_prob4_dof4}\n\t\\caption{$\\theta^h(x)$ and $\\theta(x)$ for Part 4}\n\t\\label{fig:42}\n\\end{figure}\n\n\n\\end{document}", "meta": {"hexsha": "f4d63d9b39499d8b737b938f67279ffc4967dc38", "size": 3364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignments/coding3/report.tex", "max_stars_repo_name": "jaredthomas68/FEM", "max_stars_repo_head_hexsha": "e96d6109e5b30ac527bcd48e0a3e3bf4fdc51054", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-13T11:49:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-13T11:49:53.000Z", "max_issues_repo_path": "assignments/coding3/report.tex", "max_issues_repo_name": "jaredthomas68/FEM", "max_issues_repo_head_hexsha": "e96d6109e5b30ac527bcd48e0a3e3bf4fdc51054", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignments/coding3/report.tex", "max_forks_repo_name": "jaredthomas68/FEM", "max_forks_repo_head_hexsha": "e96d6109e5b30ac527bcd48e0a3e3bf4fdc51054", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1481481481, "max_line_length": 679, "alphanum_fraction": 0.7077883472, "num_tokens": 1189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.44569273191899084}}
{"text": "\\subsubsection{Spline form}\n\\label{sec:onebodyjastrowspline}\n\nThe one-body spline Jastrow function is the most commonly used one-body Jastrow for solids. This form \nwas first described and used in \\cite{EslerKimCeperleyShulenburger2012}.  \nHere $u_{ab}$ is an interpolating 1D Bspline (tricublc spline on a linear grid) between zero distance and $r_{cut}$. In 3D periodic systems \nthe default cutoff distance is the Wigner Seitz cell radius. For other periodicities including isolated \nmolecules the $r_{cut}$ must be specified. The cusp can be set.   $r_i$ \nand $R_I$ are most commonly the electron and ion positions, but any particlesets that can provide the \nneeded centers can be used.\n\n\\paragraph{Input Specification}\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{l c c c l }\n\\hline\n\\multicolumn{5}{l}{Correlation element} \\\\\n\\hline\n\\bfseries name & \\bfseries datatype & \\bfseries values & \\bfseries defaults & \\bfseries description \\\\\n\\hline\nelementType & text & name & see below & Classical particle target  \\\\\nspeciesA & text & name & see below & Classical particle target \\\\\nspeciesB & text & name & see below & Quantum species target \\\\\nsize & integer & $> 0$ & (required) & Number of coefficients \\\\\nrcut & real & $> 0$ & see below & Distance at which the correlation goes to 0 \\\\\ncusp & real & $\\ge 0$ & 0 & Value for use in Kato cusp condition \\\\\nspin & text & yes or no & no & Spin dependent jastrow factor \\\\\n\\hline\n\\multicolumn{5}{l}{elements}\\\\ \\hline\n& Coefficients & & & \\\\ \\hline\n\\multicolumn{5}{l}{Contents}\\\\ \\hline\n& (None)  & & &  \\\\ \\hline\n\\end{tabular}\n%\\end{tabular*}\n\\end{center}\n\\end{table}\n\nAdditional information:\n\n \\begin{itemize}\n \\item \\texttt{elementType, speciesA, speciesB, spin}.  For a spin independent Jastrow factor (spin = ``no'')\nelementType should be the name of the group of ions in the classical particleset to which the quantum\nparticles should be correlated.  For a spin dependent Jastrow factor (spin = ``yes'') set speciesA to the\ngroup name in the classical particleset and speciesB to the group name in the quantum particleset.\n \\item \\texttt{rcut}. The cutoff distance for the function in atomic units (bohr). \nFor 3D fully periodic systems this parameter is optional and a default of the Wigner \nSeitz cell radius is used. Otherwise this parameter is required.\n \\item \\texttt{cusp}. The one body jastrow factor can be used to make the wavefunction\nsatisfy the electron-ion cusp condition\\cite{kato}.  In this case, the derivative of the jastrow\nfactor as the electron approaches the nucleus will be given by:\n\\begin{equation}\n\\left(\\frac{\\partial J}{\\partial r_{iI}}\\right)_{r_{iI} = 0} = -Z\n\\end{equation}\nNote that if the antisymmetric part of the wavefunction satisfies the electron-ion cusp\ncondition (for instance by using single particle orbitals that respect the cusp condition)\nor if a non-divergent pseudopotential is used that the Jastrow should be cuspless at the \nnucleus and this value should be kept at its default of 0.\n \\end{itemize}\n\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{l c c c l }\n\\hline\n\\multicolumn{5}{l}{Coefficients element} \\\\\n\\hline\n\\bfseries name & \\bfseries datatype & \\bfseries values & \\bfseries defaults & \\bfseries description \\\\\n\\hline\nid & text & & (required) & Unique identifier \\\\\ntype & text & Array & (required) & \\\\\noptimize & text & yes or no & yes & if no, values are fixed in optimizations \\\\\n\\hline\n\\multicolumn{5}{l}{elements}\\\\ \\hline\n(None) & & & \\\\ \\hline\n\\multicolumn{5}{l}{Contents}\\\\ \\hline\n (no name) & real array & & zeros & Jastrow coefficients \\\\ \\hline\n\\end{tabular}\n%\\end{tabular*}\n\\end{center}\n\\end{table}\n\n\n\\paragraph{Example use cases}\n\\label{sec:1bjsplineexamples}\n\nSpecify a spin-independent function with four parameters. Because rcut  is not \nspecified, the default cutoff of the Wigner Seitz cell radius is used; this \nJastrow must be used with a 3D periodic system such as a bulk solid. The name of \nthe particleset holding the ionic positions is \"i\".\n\\begin{lstlisting}[language=xml]\n<jastrow name=\"J1\" type=\"One-Body\" function=\"Bspline\" print=\"yes\" source=\"i\">\n <correlation elementType=\"C\" cusp=\"0.0\" size=\"4\">\n   <coefficients id=\"C\" type=\"Array\"> 0  0  0  0  </coefficients>\n </correlation>\n</jastrow>\n\\end{lstlisting}\n\nSpecify a spin-dependent function with seven upspin and seven downspin parameters. \nThe cutoff distance is set to 6 atomic units.  Note here that the particleset holding\nthe ions is labeled as ion0 rather than ``i'' in the other example.  Also in this case\nthe ion is Lithium with a coulomb potential, so the cusp condition is satisfied by \nsetting cusp=\"d\".\n\\begin{lstlisting}[language=xml]\n<jastrow name=\"J1\" type=\"One-Body\" function=\"Bspline\" source=\"ion0\" spin=\"yes\">\n  <correlation speciesA=\"Li\" speciesB=\"u\" size=\"7\" rcut=\"6\">\n    <coefficients id=\"eLiu\" cusp=\"3.0\" type=\"Array\"> \n    0.0 0.0 0.0 0.0 0.0 0.0 0.0\n    </coefficients>\n  </correlation>\n  <correlation speciesA=\"C\" speciesB=\"d\" size=\"7\" rcut=\"6\">\n    <coefficients id=\"eLid\" cusp=\"3.0\" type=\"Array\"> \n    0.0 0.0 0.0 0.0 0.0 0.0 0.0\n    </coefficients>\n  </correlation>\n</jastrow>\n\\end{lstlisting}\n\n", "meta": {"hexsha": "1d44f54e4547acb680d454131a6a528fa2ba9c20", "size": 5125, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/jastrow_one_body_spline.tex", "max_stars_repo_name": "markdewing/qmcpack", "max_stars_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_stars_repo_licenses": ["NCSA"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manual/jastrow_one_body_spline.tex", "max_issues_repo_name": "markdewing/qmcpack", "max_issues_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_issues_repo_licenses": ["NCSA"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/jastrow_one_body_spline.tex", "max_forks_repo_name": "markdewing/qmcpack", "max_forks_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_forks_repo_licenses": ["NCSA"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-07-23T17:44:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-23T17:44:39.000Z", "avg_line_length": 43.4322033898, "max_line_length": 140, "alphanum_fraction": 0.7291707317, "num_tokens": 1519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4456927286250535}}
{"text": "\\section{Non-malleability of \\plonk{}, omitted protocol descriptions}\n\\label{sec:plonk_supp_mat}\n\n\\newcommand{\\vql}{\\vec{q_{L}}}\n\\newcommand{\\vqr}{\\vec{q_{R}}}\n\\newcommand{\\vqm}{\\vec{q_{M}}}\n\\newcommand{\\vqo}{\\vec{q_{O}}}\n\\newcommand{\\vx}{\\vec{x}}\n\\newcommand{\\vqc}{\\vec{q_{C}}}\n\\subsection{Plonk protocol description}\n\\label{sec:plonk_explained}\n\\oursubsub{The constrain system}\nAssume $\\CRKT$ is a fan-in two arithmetic circuit,\nwhich fan-out is unlimited and has $\\numberofconstrains$ gates and $\\noofw$ wires\n($\\numberofconstrains \\leq \\noofw \\leq 2\\numberofconstrains$). \\plonk's constraint\nsystem is defined as follows:\n\\begin{itemize}\n\\item Let $\\vec{V} = (\\va, \\vb, \\vc)$, where $\\va, \\vb, \\vc\n  \\in \\range{1}{\\noofw}^\\numberofconstrains$. Entries $\\va_i, \\vb_i, \\vc_i$ represent indices of left,\n  right and output wires of circuits $i$-th gate.\n\\item Vectors $\\vec{Q} = (\\vql, \\vqr, \\vqo, \\vqm, \\vqc) \\in\n  (\\FF^\\numberofconstrains)^5$ are called \\emph{selector vectors}:\n  \\begin{itemize}\n  \\item If the $i$-th gate is a multiplicative gate then $\\vql_i = \\vqr_i = 0$,\n    $\\vqm_i = 1$, and $\\vqo_i = -1$. \n  \\item If the $i$-th gate is an addition gate then $\\vql_i = \\vqr_i  = 1$, $\\vqm_i =\n    0$, and $\\vqo_i = -1$. \n  \\item $\\vqc_i = 0$ always. \n  \\end{itemize}\n\\end{itemize}\n\nWe say that vector $\\vx \\in \\FF^\\noofw$ satisfies constraint system if for all $i\n\\in \\range{1}{\\numberofconstrains}$\n\\[\n  \\vql_i \\cdot \\vx_{\\va_i} + \\vqr_i \\cdot \\vx_{\\vb_i} + \\vqo \\cdot \\vx_{\\vc_i} +\n  \\vqm_i \\cdot (\\vx_{\\va_i} \\vx_{\\vb_i}) + \\vqc_i = 0. \n\\]\n\n\\oursubsub{Algorithms rolled out}\n\\label{sec:plonk_explained}\n\\plonk{} argument system is universal. That is, it allows to verify computation\nof any arithmetic circuit which has no more than $\\numberofconstrains$\ngates using a single SRS. However, to make computation efficient, for each\ncircuit there is allowed a preprocessing phase which extend the SRS with\ncircuit-related polynomial evaluations.\n\nFor the sake of simplicity of the security reductions presented in this paper, we\ninclude in the SRS only these elements that cannot be computed without knowing\nthe secret trapdoor $\\chi$. The rest of the SRS---the preprocessed input---can\nbe computed using these SRS elements thus we leave them to be computed by the\nprover, verifier, and simulator.\n\n\\ourpar{$\\plonk$ SRS generating algorithm $\\kgen(\\REL)$:}\nThe SRS generating algorithm picks at random $\\chi \\sample \\FF_p$, computes\nand outputs\n\\[\n\t\\srs = \\left(\\gone{\\smallset{\\chi^i}_{i = 0}^{\\numberofconstrains + 2}},\n\t\\gtwo{\\chi} \\right).\n\\]\n\n\\ourpar{Preprocessing:}\nLet $H = \\smallset{\\omega^i}_{i = 1}^{\\numberofconstrains }$ be a\n(multiplicative) $\\numberofconstrains$-element subgroup of a field $\\FF$\ncompound of $\\numberofconstrains$-th roots of unity in $\\FF$. Let $\\lag_i(X)$ be\nthe $i$-th element of an $\\numberofconstrains$-elements Lagrange basis. During\nthe preprocessing phase polynomials $\\p{S_{id j}}, \\p{S_{\\sigma j}}$, for\n$\\p{j} \\in \\range{1}{3}$, are computed:\n\\begin{equation*}\n  \\begin{aligned}\n    \\p{S_{id 1}}(X) & = X,\\vphantom{\\sum_{i = 1}^{\\noofc} \\sigma(i) \\lag_i(X),}\\\\\n    \\p{S_{id 2}}(X) & = k_1 \\cdot X,\\vphantom{\\sum_{i = 1}^{\\noofc} \\sigma(i) \\lag_i(X),}\\\\\n    \\p{S_{id 3}}(X) & = k_2 \\cdot X,\\vphantom{\\sum_{i = 1}^{\\noofc} \\sigma(i) \\lag_i(X),}\n  \\end{aligned}\n  \\qquad\n\\begin{aligned}\n  \\p{S_{\\sigma 1}}(X) & = \\sum_{i = 1}^{\\noofc} \\sigma(i) \\lag_i(X),\\\\\n  \\p{S_{\\sigma 2}}(X) & = \\sum_{i = 1}^{\\noofc}\n  \\sigma(\\noofc + i) \\lag_i(X),\\\\\n  \\p{S_{\\sigma 3}}(X) & =\\sum_{i = 1}^{\\noofc} \\sigma(2 \\noofc + i) \\lag_i(X).\n\\end{aligned}\n\\end{equation*}\nCoefficients $k_1$, $k_2$ are such that $H, k_1 \\cdot H, k_2 \\cdot H$ are\ndifferent cosets of $\\FF^*$, thus they define $3 \\cdot \\noofc$\ndifferent elements. \\cite{EPRINT:GabWilCio19} notes that it is enough to set\n$k_1$ to a quadratic residue and $k_2$ to a quadratic non-residue.\n\nFurthermore, we define polynomials $\\p{q_L}, \\p{q_R}, \\p{q_O}, \\p{q_M}, \\p{q_C}$\nsuch that\n\\begin{equation*}\n  \\begin{aligned}\n  \\p{q_L}(X) & = \\sum_{i = 1}^{\\noofc} \\vql_i \\lag_i(X), \\\\\n  \\p{q_R}(X) & = \\sum_{i = 1}^{\\noofc} \\vqr_i \\lag_i(X), \\\\\n  \\p{q_M}(X) & = \\sum_{i = 1}^{\\noofc} \\vqm_i \\lag_i(X),\n\\end{aligned}\n\\qquad\n\\begin{aligned}\n  \\p{q_O}(X) & = \\sum_{i = 1}^{\\noofc} \\vqo_i \\lag_i(X), \\\\\n  \\p{q_C}(X) & = \\sum_{i = 1}^{\\noofc} \\vqc_i \\lag_i(X). \\\\\n  \\vphantom{\\p{q_M}(X)  = \\sum_{i = 1}^{\\noofc} \\vqm_i \\lag_i(X),}\n\\end{aligned}\n\\end{equation*}\n\n\\ourpar{$\\plonk$ prover\n  $\\prover(\\srs, \\inp, \\wit = (\\wit_i)_{i \\in \\range{1}{3 \\cdot\n      \\noofc}})$.}\n\\begin{description}\n\\item[Round 1] Sample $b_1, \\ldots, b_9 \\sample \\FF_p$; compute\n  $\\p{a}(X), \\p{b}(X), \\p{c}(X)$ as\n\t\\begin{align*}\n\t\t\\p{a}(X) &= (b_1 X + b_2)\\p{Z_H}(X) + \\sum_{i = 1}^{\\noofc} \\wit_i \\lag_i(X) \\\\\n\t\t\\p{b}(X) &= (b_3 X + b_4)\\p{Z_H}(X) + \\sum_{i = 1}^{\\noofc} \\wit_{\\noofc + i} \\lag_i(X) \\\\\n\t\t\\p{c}(X) &= (b_5 X + b_6)\\p{Z_H}(X) + \\sum_{i = 1}^{\\noofc} \\wit_{2 \\cdot \\noofc + i} \\lag_i(X) \n\t\\end{align*}\n\tOutput polynomial commitments $\\gone{\\p{a}(\\chi), \\p{b}(\\chi), \\p{c}(\\chi)}$.\n\t\n\t\\item[Round 2]\n\tGet challenges $\\beta, \\gamma \\in \\FF_p$\n\t\\[\n\t\t\\beta = \\ro(\\tzkproof[0..1], 0)\\,, \\qquad \\gamma = \\ro(\\tzkproof[0..1], 1)\\,.\n\t\\]\n\tCompute permutation polynomial $\\p{z}(X)$\n\t\\begin{multline*}\n\t\t\\p{z}(X) = (b_7 X^2 + b_8 X + b_9)\\p{Z_H}(X) + \\lag_1(X) + \\\\\n\t\t\t+ \\sum_{i = 1}^{\\noofc - 1} \n\t\t\t\\left(\\lag_{i + 1} (X) \\prod_{j = 1}^{i} \n\t\t\t\\frac{\n\t\t\t(\\wit_j +\\beta \\omega^{j - 1} + \\gamma)(\\wit_{\\noofc + j} + \\beta k_1 \\omega^{j - 1} + \\gamma)(\\wit_{2 \\noofc + j} +\\beta k_2 \\omega^{j- 1} + \\gamma)}\n\t\t\t{(\\wit_j+\\sigma(j) \\beta + \\gamma)(\\wit_{\\noofc + j} + \\sigma(\\noofc + j)\\beta + \\gamma)(\\wit_{2 \\noofc + j} + \\sigma(2 \\noofc + j)\\beta + \\gamma)}\\right)\n\t\\end{multline*}\n\tOutput polynomial commitment $\\gone{\\p{z}(\\chi)}$\n\t\t\n\t\\item[Round 3]\n\tGet the challenge $\\alpha = \\ro(\\tzkproof[0..2])$, compute the quotient polynomial \n\t\\begin{align*}\n\t& \\p{t}(X)  = \\\\\n\t& (\\p{a}(X) \\p{b}(X) \\selmulti(X) + \\p{a}(X) \\selleft(X) + \n\t\\p{b}(X)\\selright(X) + \\p{c}(X)\\seloutput(X) + \\pubinppoly(X) + \\selconst(X)) \n\t\\frac{1}{\\p{Z_H}(X)} +\\\\\n\t& + ((\\p{a}(X) + \\beta X + \\gamma) (\\p{b}(X) + \\beta k_1 X + \\gamma)(\\p{c}(X) \n\t+ \\beta k_2 X + \\gamma)\\p{z}(X)) \\frac{\\alpha}{\\p{Z_H}(X)} \\\\\n\t& - (\\p{a}(X) + \\beta \\p{S_{\\sigma 1}}(X) + \\gamma)(\\p{b}(X) + \\beta \n\t\\p{S_{\\sigma 2}}(X) + \\gamma)(\\p{c}(X) + \\beta \\p{S_{\\sigma 3}}(X) + \n\t\\gamma)\\p{z}(X \\omega))  \\frac{\\alpha}{\\p{Z_H}(X)} \\\\\n\t& + (\\p{z}(X) - 1) \\lag_1(X) \\frac{\\alpha^2}{\\p{Z_H}(X)}\n\t\\end{align*}\n\tSplit $\\p{t}(X)$ into degree less then $\\noofc$ polynomials $\\p{t_{lo}}(X), \\p{t_{mid}}(X), \\p{t_{hi}}(X)$, such that\n\t\\[\n\t\t\\p{t}(X) = \\p{t_{lo}}(X) + X^{\\noofc} \\p{t_{mid}}(X) + X^{2 \\noofc} \\p{t_{hi}}(X)\\,.\n\t\\]\n\tOutput $\\gone{\\p{t_{lo}}(\\chi), \\p{t_{mid}}(\\chi), \\p{t_{hi}}(\\chi)}$.\n\t\n\t\\item[Round 4]\n\tGet the challenge $\\chz \\in \\FF_p$, $\\chz = \\ro(\\tzkproof[0..3])$.\n\tCompute opening evaluations\n\t\\begin{align*}\n      \\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma 2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega),\n\t\\end{align*}\n\tCompute the linearisation polynomial\n\t\\[\n\t\t\\p{r}(X) = \n\t\t\\begin{aligned}\n      & \\p{a}(\\chz) \\p{b}(\\chz) \\selmulti(X) + \\p{a}(\\chz) \\selleft(X) + \\p{b}(\\chz) \\selright(X) + \\p{c}(\\chz) \\seloutput(X) + \\selconst(X) \\\\\n      & + \\alpha \\cdot \\left( (\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma)(\\p{c}(\\chz) + \\beta k_2 \\chz + \\gamma) \\cdot \\p{z}(X)\\right) \\\\\n      & - \\alpha \\cdot \\left( (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma)\\beta \\p{z}(\\chz\\omega) \\cdot \\p{S_{\\sigma 3}}(X)\\right) \\\\\n      & + \\alpha^2 \\cdot \\lag_1(\\chz) \\cdot \\p{z}(X)\n\t\t\\end{aligned}\n\t\\]\n\tOutput $\\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma 2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega), \\p{r}(\\chz).$\n\t\n\t\\item[Round 5]\n\tCompute the opening challenge $v \\in \\FF_p$, $v = \\ro(\\tzkproof[0..4])$.\n\tCompute the openings for the polynomial commitment scheme \n\t\\begin{align*}\n\t& \\p{W_\\chz}(X) = \\frac{1}{X - \\chz} \\left(\n\t\\begin{aligned}\n\t\t& \\p{t_{lo}}(X) + \\chz^\\noofc \\p{t_{mid}}(X) + \\chz^{2 \\noofc} \\p{t_{hi}}(X) - \\p{t}(\\chz)\\\\\n\t\t& + v(\\p{r}(X) - \\p{r}(\\chz)) \\\\\n\t\t& + v^2 (\\p{a}(X) - \\p{a}(\\chz))\\\\\n\t\t& + v^3 (\\p{b}(X) - \\p{b}(\\chz))\\\\\n\t\t& + v^4 (\\p{c}(X) - \\p{c}(\\chz))\\\\\n\t\t& + v^5 (\\p{S_{\\sigma 1}}(X) - \\p{S_{\\sigma 1}}(\\chz))\\\\\n\t\t& + v^6 (\\p{S_{\\sigma 2}}(X) - \\p{S_{\\sigma 2}}(\\chz))\n\t\\end{aligned}\n\t\\right)\\\\\n\t& \\p{W_{\\chz \\omega}}(X) = \\frac{\\p{z}(X) - \\p{z}(\\chz \\omega)}{X - \\chz \\omega}\n\\end{align*}\n\tOutput $\\gone{\\p{W_{\\chz}}(\\chi), \\p{W_{\\chz \\omega}}(\\chi)}$.\n\\end{description}\n\n\\ncase{$\\plonk$ verifier $\\verifier(\\srs, \\inp, \\zkproof)$}\\ \\newline\nThe \\plonk{} verifier works as follows\n\\begin{description}\n\t\\item[Step 1] Validate all obtained group elements.\n\t\\item[Step 2] Validate all obtained field elements.\n\t\\item[Step 3] Validate the instance\n      $\\inp = \\smallset{\\wit_i}_{i = 1}^\\instsize$.\n\t\\item[Step 4] Compute challenges $\\beta, \\gamma, \\alpha, \\chz, v,\n      u$ from the transcript.\n\t\\item[Step 5] Compute zero polynomial evaluation\n      $\\p{Z_H} (\\chz) =\\chz^\\noofc - 1$.\n\t\\item[Step 6] Compute Lagrange polynomial evaluation\n      $\\lag_1 (\\chz) = \\frac{\\chz^\\noofc -1}{\\noofc (\\chz - 1)}$.\n\t\\item[Step 7] Compute public input polynomial evaluation\n      $\\pubinppoly (\\chz) = \\sum_{i \\in \\range{1}{\\instsize}} \\wit_i\n      \\lag_i(\\chz)$.\n\t\\item[Step 8] Compute quotient polynomials evaluations\n\t\\begin{multline*}\n    \\p{t} (\\chz) = \\frac{1}{\\p{Z_H}(\\chz)} \\Big(\n    \\p{r} (\\chz) + \\pubinppoly(\\chz) - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \\\\\n    (\\p{c}(\\chz) + \\gamma)\\p{z}(\\chz \\omega) \\alpha - \\lag_1 (\\chz) \\alpha^2\n    \\Big) \\,.\n\t\\end{multline*}\n\t\\item[Step 9] Compute batched polynomial commitment\n\t$\\gone{D} = v \\gone{r} + u \\gone {z}$ that is\n\t\\begin{align*}\n\t\t\\gone{D} & = v\n\t\t\\left(\n\t\t\\begin{aligned}\n          & \\p{a}(\\chz)\\p{b}(\\chz) \\cdot \\gone{\\selmulti} + \\p{a}(\\chz)  \\gone{\\selleft} + \\p{b}  \\gone{\\selright} + \\p{c}  \\gone{\\seloutput} + \\\\\n          & + (\t(\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma) (\\p{c} + \\beta k_2 \\chz + \\gamma) \\alpha  + \\lag_1(\\chz) \\alpha^2)  + \\\\\n\t\t\t% &   \\\\\n          & - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz)\n          + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \\alpha \\beta \\p{z}(\\chz\n          \\omega) \\gone{\\p{S_{\\sigma 3}}(\\chi)})\n\t\t\\end{aligned}\n\t\t\\right) + \\\\\n\t\t& + u \\gone{\\p{z}(\\chi)}\\,.\n\t\\end{align*}\n\t\\item[Step 10] Computes full batched polynomial commitment $\\gone{F}$:\n\t\\begin{align*}\n      \\gone{F} & = \\left(\\gone{\\p{t_{lo}}(\\chi)} + \\chz^\\noofc \\gone{\\p{t_{mid}}(\\chi)} + \\chz^{2 \\noofc} \\gone{\\p{t_{hi}}(\\chi)}\\right) + u \\gone{\\p{z}(\\chi)} + \\\\\n               & + v\n                 \\left(\n\t\t\\begin{aligned}\n\t\t\t& \\p{a}(\\chz)\\p{b}(\\chz) \\cdot \\gone{\\selmulti} + \\p{a}(\\chz)  \\gone{\\selleft} + \\p{b}(\\chz)   \\gone{\\selright} + \\p{c}(\\chz)  \\gone{\\seloutput} + \\\\\n\t\t\t& + (\t(\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma) (\\p{c}(\\chz)  + \\beta k_2 \\chz + \\gamma) \\alpha  + \\lag_1(\\chz) \\alpha^2)  + \\\\\n\t\t\t% &   \\\\\n\t\t\t& - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \\alpha  \\beta \\p{z}(\\chz \\omega) \\gone{\\p{S_{\\sigma 3}}(\\chi)})\n\t\t\\end{aligned}\n\t\t\\right) \\\\\n\t\t& + v^2 \\gone{\\p{a}(\\chi)} + v^3 \\gone{\\p{b}(\\chi)} + v^4 \\gone{\\p{c}(\\chi)} + v^5 \\gone{\\p{S_{\\sigma 1}(\\chi)}} + v^6 \\gone{\\p{S_{\\sigma 2}}(\\chi)}\\,.\n\t\\end{align*}\n\t\\item[Step 11] Compute group-encoded batch evaluation $\\gone{E}$\n\t\\begin{align*}\n\t\t\\gone{E}  = \\frac{1}{\\p{Z_H}(\\chz)} & \\gone{\n\t\t\\begin{aligned}\n\t\t\t& \\p{r}(\\chz) + \\pubinppoly(\\chz) +  \\alpha^2  \\lag_1 (\\chz) + \\\\\n\t\t\t& - \\alpha \\left( (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}} (\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}} (\\chz) + \\gamma) (\\p{c}(\\chz) + \\gamma) \\p{z}(\\chz \\omega) \\right)\n\t\t\\end{aligned}\n           }\\\\\n      + & \\gone{v \\p{r}(\\chz) + v^2 \\p{a}(\\chz) + v^3 \\p{b}(\\chz) + v^4 \\p{c}(\\chz) + v^5 \\p{S_{\\sigma 1}}(\\chz) + v^6 \\p{S_{\\sigma 2}}(\\chz) + u \\p{z}(\\chz \\omega) }\\,.\n\t\\end{align*}\n\\item[Step 12] Check whether the verification\n % $\\vereq_\\zkproof(\\chi)$\n  equation holds\n\t\\begin{multline}\n\t\t\\label{eq:ver_eq}\n\t\t\\left( \\gone{\\p{W_{\\chz}}(\\chi)} + u \\cdot \\gone{\\p{W_{\\chz\n                \\omega}}(\\chi)} \\right) \\bullet\n\t\t\\gtwo{\\chi} - %\\\\\n\t\t\\left( \\chz \\cdot \\gone{\\p{W_{\\chz}}(\\chi)} + u \\chz \\omega \\cdot\n          \\gone{\\p{W_{\\chz \\omega}}(\\chi)} + \\gone{F} - \\gone{E} \\right) \\bullet\n        \\gtwo{1} = 0\\,.\n\t\\end{multline}\n  The verification equation is a batched version of the verification equation\n  from \\cite{AC:KatZavGol10} which allows the verifier to check openings of\n  multiple polynomials in two points (instead of checking an opening of a single\n  polynomial at one point).\n\\end{description}\n\n\\ncase{$\\plonk$ simulator $\\simulator_\\chi(\\srs, \\td= \\chi, \\inp)$}\\ \\newline\nThe \\plonk{} simulator proceeds as an honest prover would, except:\n\\begin{enumerate}\n  \\item In the first round, it sets $\\wit = (\\wit_i)_{i \\in \\range{1}{3 \\noofc}}\n    = \\vec{0}$, and at random picks $b_1, \\ldots, b_9$. Then it proceeds with\n    that all-zero witness.\n  \\item In Round 3, it computes polynomial $\\pt(X)$ honestly, however uses\n    trapdoor $\\chi$ to compute commitments\n    $\\p{t_{lo}}(\\chi), \\p{t_{mid}}(\\chi), \\p{t_{hi}}(\\chi)$.\n  \\end{enumerate}\n\n%  \\subsection{Trapdoor-less simulatability of Plonk}\n%\\label{sec:plonk-TLZK-proof}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "14cf7b49128936c75951305f09703d3c0d21510b", "size": 13647, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SCN2022/non-malleability-of-plonk-omitted-protocol-description.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SCN2022/non-malleability-of-plonk-omitted-protocol-description.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SCN2022/non-malleability-of-plonk-omitted-protocol-description.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0586206897, "max_line_length": 196, "alphanum_fraction": 0.5754378252, "num_tokens": 6066, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4456492245336003}}
{"text": "\nWe have a scalable simulation platform with for \\rbc flows through capillaries using boundary integral equations. \nWe first presented a robust solver for elliptic \\pdes on \\threed rigid geometries. \nWe thoroughly studied the behavior and performance of this solver on a variety of geometries and compared it with a competitive state-of-the-art solver.\nWe then parallelized the solver, combined it with boundary integral-based vesicle simulation algorithms and adapted collision-free time stepping to include rigid boundaries.\nWe have scaled our simulations and the parallel solver to thousands of cores and demonstrated the practicality of using such simulations to reproduce qualitatively representative physical \\rbcs flows.\n\n\\section{Future Work}\nThe comparison between \\qbkix and \\cite{YBZ} in \\cref{sec:results-compare} demonstrated the efficiency of a local quadrature scheme compared to a global one. \nMoreover, the scaling results in \\cref{ss:scalability} demonstrate that parallel \\qbkix is the dominant cost of the simulation.\nIn order to scale \\rbc simulations beyond the regime explored here, the parallel boundary solver needs to be improved. \nA key improvement will be the adpotion of a \\textit{local} singular quadrature approach.\nParallel scaling is largely determined by communication costs and \\qbkix performs parallel communication entirely through \\pvfmm. \nReducing the number of total points passed to \\pvfmm is the best way to improve parallel scaling, since this reduces the overall size of the distributed octree.\nThe local corrections to an inaccurate \\fmm evaluation can be highly vectorized and require no additional parallel communication.\nMoreover, the local corrections can be precomputed when solving the integral equation with \\gmres. \nThese two facts will dramatically increase the performance of \\qbkix.\n\nAnother area for improvement is in extrapolation procedure of \\qbkix. \nEqually spaced points serve as a fairly bad interpolant, but we have shown that we're able to use low order polynomials to extrapolate reliably.\nAn important question in the future of \\qbkix is how to construct an optimal \\oned extrapolation procedure for harmonic functions.\nAn equally important concern is the scheme's inability to resolve oscillatory \\pdes such as the Helmholtz equation\\edit{.}{, due to the difference in resolution achieved on the boundary by $q^2$ quadrature points and the $p$ check points.}\nA trigonometric extrapolation procedure, coupled with a sampling rate comensurate with the solution's underlying frequency, is one possible approach.\n\n\\cite[Section 3.3.1]{wala20183d} \\edit{}{ has shown that \\qbx truncation error is influenced by surface curvature; \\qbkix experiences a similar phenomenon. \nAn adaptive placement of check points, determined by surface curvature and overall extrapolation error, would further increase accuracy without increasing cost.\nAdditionally, an approach like Richardson extrapolation could further improve accuracy.\nPlacing several sets of check points for decreasing values of $r$ and evaluating them with a single \\fmm call would allow for better approximate extrapolation by merging the individual results.\n}\nSeveral algorithms in \\cref{sec:algo} can be improved. \nThe closest point algorithm in \\cref{app:closest_point} can be dramatically improved by leveraging subdivision properties of the B\\'ezier surface representation.\nWe can compute the closest point to the control points of a patch, subdivide the patch, and recursively repeat the process to arrive at more accurate initial guess for the closest point for the \\twod Newton method in \\cref{app:closest_point}. \nThis guess can further cull the \\oned optimizations based on the quadrant of the initial guess.\nPreliminary investigation shows that this outperforms the method detailed in \\cref{app:point_marking}.\n\nThe point marking algorithm in \\cref{app:point_marking} and the upsampling algorithm in \\cref{sec:adaptive_upsampling_algo} are based on near-zone bounding boxes.\nA proper quadrature error heuristic similar to \\cite{aT2} would dramatically reduce the amount of upsampling required to guarantee the accuracy of \\qbkix. \nThis would improve the third plot in \\cref{fig:full-algo-perf} by more accurately determine which points require evaluation via \\qbkix, both of which will reduce overall cost.\nThe approach taken in \\cite{klinteberg2020quadrature} shows exceptional promise toward this end.\n\nThe refinement algorithms in \\cref{sec:adaptive_upsampling_algo,sec:admissible_algo} require parallelization for \\qbkix to be a useful computational tool. \nThis requires minor changes to the parallel closest point algorithm in \\cref{sec:closest_point} and the parallel near-pair algorithm in \\cref{sec:parallel-contact}.\n\nRecent work \\cite{wang2021benchmark} has demonstrated that the collision detection scheme in \\cite{Harmon2011} used in \\cref{chp:bloodflow} and \\cite{lu2019scalable,lu2018parallel} seems to miss collisions with large separation distances. \nIt appears from \\cite[Section 6]{wang2021benchmark} that \\cite{Harmon2011} entirely misses a relatively large number of collisions across all datasets.\nThe collision geometries in \\cref{chp:bloodflow} are quite benign compared to the datasets in \\cite{wang2021benchmark}, since \\rbcs and vessels are represented by spherical harmonics and high order polynomials, respectively.\nThough we verify a collision-free state at each time step in \\cref{chp:bloodflow}, addressing this shortcoming is crucial.\n\\cite{li2020incremental,ferguson2021RigidIPC} presents a viable approach, but currently only operates on a single compute node.\nImplementing a scalable parallel version of \\cite{ferguson2021RigidIPC} is a key step in simulating more complex geometries or sharp rigid particulates. \n\nFinally, incorporating in-plane shear forces into the \\rbc model will dramatically improve the overall model accuracy in \\cref{chp:bloodflow}.\nRecent optical tweezer exerpiments \\cite{mills2004nonlinear,li2005spectrin} have shown that the cytoskeletal structure of \\rbcs can withstand surprisingly large amounts of shear force in extreme circumstances.\n\\cite{fai2017image} could serve as an effective approach.\nMoreover, quantifying the impact of cytoskeletal modeling on overall \\rbc flows would be of great interest.\n", "meta": {"hexsha": "7eea0bae8e11eb4f70c6a563065f0e7da97e13dc", "size": 6299, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "conclusion.tex", "max_stars_repo_name": "mmorse1217/nyu-thesis-template", "max_stars_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "conclusion.tex", "max_issues_repo_name": "mmorse1217/nyu-thesis-template", "max_issues_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "conclusion.tex", "max_forks_repo_name": "mmorse1217/nyu-thesis-template", "max_forks_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 114.5272727273, "max_line_length": 243, "alphanum_fraction": 0.8231465312, "num_tokens": 1378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396211, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4456492245336001}}
{"text": "\\newpage\\section{Cevian and Circumcevian Triangles}\n\t\n\t\\subsection{Circumcevian Triangle}\n\t\n\t\t\n\n\t\t\\theo{https://nguyenvanlinh.files.wordpress.com/2011/12/hagge-circles-revisited.pdf}{Hagge's circles}{Let $ P $ be a point on the plane of $ \\triangle ABC $, let $ \\Omega $ be the circumcircle. Let $ A_1, B_1, C_1 $ be the intersections of $ AP, BP, CP $ with $ \\Omega $ for the second time. Let $ A_2, B_2, C_2 $ be the reflections of $ A_1, B_1, C_1 $ wrt $ BC, CA, AB $. Prove that $ H, A_2, B_2, C_2 $ lie on a circle. This circle is called the \\textbf{$ \\boldsymbol{P} $-Hagge's Circle}.}\n\t\n\t\t\t\\solu{Either using the dual of Hagge's Circle, or using the reflection points of $ A, B, C $ wrt the isogonal conjugate of $ P $. And using Lemma 1.1 to finish.}\n\t\n\t\n\t\t\t\\fig{.6}{P-HaggeCircle}{P-Hagge Circle}\n\t\n\t\n\t\n\t\t\\coro{$ \\triangle A_1B_1C_1 \\sim \\triangle A_2B_2C_2 $.}\n\t\n\t\t\t\\solu{Straightforward use of Lemma 1.2.}\n\t\n\t\t\\coro{If $ AH, BH, CH $ meet $ \\odot A_2B_2C_2H $ at $ A_3, B_3, C_3 $, then $ A_2A_3, B_2B_3, C_2B_3 $ meet at $ P $.}\n\t\n\t\t\t\\solu{Simple angle chase and similarity transformation.}\n\t\n\t\t\\coro{If $ I $ is the incenter of $ \\odot A_2B_2C_2 $, $ K $ is the reflection of $ H $ over $ I $, $ AK, BK, CK $ meet $ \\odot A_2B_2C_2 $ at $ A_4, B_4, C_4 $, then $ A_4A_3, B_4B_3, C_4B_3 $ are concurrent.}\n\t\n\t\t\t\\solu{Simple angle chasing and trig-ceva.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h97484p550561}{China TST D2P2, Dual of the Hagge's Circle theorem}{M}{Let $\\omega$ be the circumcircle of $\\triangle{ABC}$. $P$ is an interior point of $\\triangle{ABC}$. $A_{1}, B_{1}, C_{1}$ are the intersections of $AP, BP, CP$ respectively and $A_{2}, B_{2}, C_{2}$ are the symmetrical points of $A_{1}, B_{1}, C_{1}$ with respect to the midpoints of side $BC, CA, AB$. Show that the circumcircle of $\\triangle{A_{2}B_{2}C_{2}}$ passes through the orthocenter of $\\triangle{ABC}$. Further proof that if this circle's center is $ O_1 $, then $ HOPO_1 $ is a parallelogram.}\n\t\n\t\t\t\\solu{Construct Parallelograms. You have to prove two angles are equal. Reflection the smaller trig wrt one of the midpoints.}\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h407514p2276387}{China TST 2011, Quiz 2, D2, P1}{E}{Let $AA',BB',CC'$ be three diameters of the circumcircle of an acute triangle $ABC$. Let $P$ be an arbitrary point in the interior of $\\triangle ABC$, and let $D,E,F$ be the orthogonal projection of $P$ on $BC,CA,AB$, respectively. Let $X$ be the point such that $D$ is the midpoint of $A'X$, let $Y$ be the point such that $E$ is the midpoint of $B'Y$, and similarly let $Z$ be the point such that $F$ is the midpoint of $C'Z$. Prove that triangle $XYZ$ is similar to triangle $ABC$.}\n\t\n\t\t\t\\solu{A straightforward application of Lemma 6.1 using the $ O $-Hagge's Circle.}\n\t\n\t\t\n\n\n\n\n\t\n\t\\newpage\\subsection{Cevian Triangle}\n\t\n\t\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\lem{Isogonal Conjugate Lemma}{Let a circle $ \\omega $ meet the sides of triangle $ ABC $ at $ A_1, A_2;\\ B_1, B_2;\\ C_1, C_2 $. Let $ P_1, P_2 $ be the miquel points of $ ABC $ wrt $ A_1B_1C_1, A_2B_2C_2 $ resp. Then $ P_1, P_2 $ are isogonal conjugates.}\n\t\n\t\t\t\\fig{1}{IsoConjuCirclesLemma1}{The two round points are isogonal conjugates.}\n\t\n\t\n\t\t\n\t\t\\theo{}{Terquem's Cevian Theorem}{Let a circle $ \\omega $ meet the sides of triangle $ ABC $ at $ A_1, A_2;\\ B_1, B_2;\\ C_1, C_2 $. If $ AA_1, BB_1, CC_1 $ are concurrent, then so are $ AA_2, BB_2, CC_2 $}.\t\t\n\t\t\n\t\n\t\n\t\t\n\n\t\t\\theo{https://artofproblemsolving.com/community/c3103h1052426_mannheim_circles}{Mannheim's Theorem}{Let $ABC$ be a triangle, and let $L,M,N$ be points on $BC,CA,AB$ respectively. Let $A', B', C'$ be points on $(AMN), (BNL), (CLM)$, and denote $K \\equiv AA' \\cap BB'$. Then if $K \\in CC'$, $A',B',C',K$ are concyclic.}\\label{mannheim_theorem}\n\t\n\t\t\t\\fig{1}{MannheimTheorem}{Mannheim's Theorem}\n\t\n\t\n\t\t\n\n\t\t\\theo{mannheim_theorem}{Mannheim's Theorem's Converse}{Let $ABC$ be a triangle, and let $L,M,N$ be points on $BC,CA,AB$ respectively. Let $A', B', C'$ be points on $(AMN), (BNL), (CLM)$, and denote $K \\equiv AA' \\cap BB'$. Then if $A',B',C',K$ are concyclic, $C' \\in CK$.}\n\t\n\t\n\t\t\n\n\t\t\\theo{}{Brocard Points}{Brocard Points are points inside a triangle such that \\[ \\angle PAB=\\angle PBC=\\angle PCA=\\omega \\] and \\[ \\angle QCB=\\angle QBA=\\angle QAC = \\omega. \\]}\n\t\n\t\t\t\\fig{1}{BrocardPoints}{Brocard Points}\n\t\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{http://www.artofproblemsolving.com/Forum/blog.php?u=214539&b=106944}{Rioplatense Olympiad 2013 Problem 6}{E}{Let $ABC$ be an acute-angled scalene triangle, with centroid $G$ and orthocenter $H$. The circle with diameter $AH$ cuts the circumcircle of $BHC$ at $A'$, distinct from $H$. Analogously define $B', C'$. Prove that $A', B', C', G$ are concyclic.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1274755p6680026}{Iran 3rd Round Training 2016}{E}{$ABC$ is an acute triangle and $H,O$ are its orthocenter and circumcenter respectively. If $AO,BO,CO$ intersect $BH,CH,AH$ at $X,Y,Z$ respectively,then prove that $H,X,Y,Z$ lie on a circle}\n\t\n\t\t\t\\solu{Using Brocard Point}\n\t\t\t\\solu{Using Mannheim's Theorem}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\n\t\t\\theo{https://en.wikipedia.org/wiki/Jacobi's_theorem_(geometry)}{Jacobi's Theorem}{Suppose that $ D, E, F $ are points such that $ AE, AF $ are isogonal wrt $ \\angle BAC $. Similarly with $ D, E, F $. Then $ AD, BE, CF $ are concurrent.}\n\t\n\n\n\n\t\n", "meta": {"hexsha": "bee578a121fc251df5432031446d7930a8115941", "size": 5380, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geo/sec2_cevian.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "geo/sec2_cevian.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geo/sec2_cevian.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 46.3793103448, "max_line_length": 627, "alphanum_fraction": 0.6717472119, "num_tokens": 1941, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.44544886616950663}}
{"text": "\\documentclass[a4paper, 12pt]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{dsfont}\n\\usepackage[left=2cm, right=2cm, bottom=3cm, top=2cm]{geometry}\n\\usepackage{graphicx}\n\\usepackage[utf8]{inputenc}\n\\usepackage{microtype}\n\\usepackage{natbib}\n\\newcommand{\\given}{\\,|\\,}\n\n\\title{Whaling}\n\\author{Brendon J. Brewer}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n%\\abstract{\\noindent Abstract}\n\n% Need this after the abstract\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{8pt}\n\n\\section{AR setup}\nLet $x$ be an old total amount and $x'$ be the new one. The updated trending\nscore $y'$ is then\n\\begin{align}\ny' &= ky + f(x, x', y)\n\\end{align}\nwhere $y$ is the old trending score, $k$ is the decay coefficient, and\n$f(x, x', y)$ is the spike height function.\n\nSuppose a whale has $L$ LBC and shifts it onto a claim with initial amount\nclose to zero and initial trending score close to zero.\nThe trending score will jump to\n\\begin{align}\ny' &= k \\times 0 + f(L, 0, 0)\n\\end{align}\nUnder the current {\\tt ar.py}, this is (ignoring the minnow boost)\n\\begin{align}\ny' \\approx L^{1/4}.\n\\end{align}\n\nIf this happens at time $t=0$ (in units of blocks), it will decay according to\n\\begin{align}\ny(t) &= L^{1/4} k^t. \\label{eqn:decay}\n\\end{align}\nThe half life of the decay is $\\ell = -1/\\log_2(k)$.\n\nIf we assume that a whale\ndoes this every $m$ blocks, the stationary distribution over trending score\nwill have this inverse CDF:\n\\begin{align}\ny &= F^{-1}(u) \\\\\n  &= L^{1/4} k^{m(1-u)}.\n\\end{align}\n\nInverting this gives the CDF\n\\begin{align}\n\\ln y + 4 \\ln L &= m(1-u)\\ln k \\\\\nF(y) &= 1 - \\frac{\\ln y + 4 \\ln L}{m \\ln k}.\n\\end{align}\n\nDifferentiation shows that the PDF is proportional to\n$1/y$, and the bounds are $[L^{1/4}k^m, L^{1/4}]$.\n\nIf there are lots of whales with $L$ LBC, this will also be, in expectation,\nthe frequency distribution of their trending scores, at fixed $L$.\nLet's find the joint distribution of $L$ and $y$.\nLet $L$ have a Pareto distribution. Then,\n\\begin{align}\nf(L, y) &= f(L)f(y \\given L) \\\\\n        &\\propto \\frac{1}{yL^{\\alpha + 1}}\n\\end{align}\nwhere $L > L_{\\rm min}$ and $y \\in L^{1/4}[k^m, 1]$.\n\nThe conditional $f(L \\given y)$ should tell us the\nfrequency distribution of LBC balances\nof whales at trending level $y$. It will be proportional to\nthe joint:\n\\begin{align}\nf(L \\given y) &\\propto \\frac{1}{yL^{\\alpha + 1}}\n\\end{align}\nand its normalisation is\n\\begin{align}\nZ(y) &= \\int \\frac{1}{yL^{\\alpha + 1}} \\, dL \\\\\n     &= \\frac{1}{y}\\int_{k^{4m}}^{1} \\frac{1}{L^{\\alpha + 1}} \\, dL \\\\\n     &= \\frac{1}{y}\\left[\\frac{-1}{\\alpha L^\\alpha}\\right]_{k^{4m}}^{1} \\\\\n     &= \\frac{1}{y}\\left[\\frac{1}{\\alpha k^{4m\\alpha}} -\n                           \\frac{1}{\\alpha} \\right] \\\\\n     &= \\frac{1}{\\alpha y}\\left[\\frac{1 - k^{4m\\alpha}}{k^{4m\\alpha}}\\right] \\\\\n\\end{align}\n\n\n\n\n\n\\bibliographystyle{plainnat}\n\\bibliography{references}\n\n\\end{document}\n\n", "meta": {"hexsha": "1b86520bb248429774df806c8dad3919e5b719d1", "size": 2878, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "whaling.tex", "max_stars_repo_name": "eggplantbren/lbry-trending-algos", "max_stars_repo_head_hexsha": "47c4eada7b071c7e42c35424256e7493c551a54a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-02-28T09:53:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-22T15:05:59.000Z", "max_issues_repo_path": "whaling.tex", "max_issues_repo_name": "eggplantbren/lbry-trending-algos", "max_issues_repo_head_hexsha": "47c4eada7b071c7e42c35424256e7493c551a54a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "whaling.tex", "max_forks_repo_name": "eggplantbren/lbry-trending-algos", "max_forks_repo_head_hexsha": "47c4eada7b071c7e42c35424256e7493c551a54a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6730769231, "max_line_length": 79, "alphanum_fraction": 0.6528839472, "num_tokens": 1007, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6370308082623216, "lm_q1q2_score": 0.44544660902806266}}
{"text": "\\chapter{5. Real Scale Prototype}\n\nOnce the dynamic model and the control strategy have been studied, the design and fabrication of the tilting PEV will be explained in this chapter. The frame of this vehicle was recycled from another previous PEV version, and will be the departure point for this new prototype. In this chapter we will cover the processes to design and fabricate all the parts in the vehicle, (front suspension, tilting and steering mechanisms, rear motor, handle bar, batteries, electronic components...)\n\n\\section{Front Suspension Design}\nThe first step is to design the front suspension of the vehicle. The suspension arms will continue to form a four bar mechanism as were in the miniPEV. In this case, before designing any mechanical component and jumping to the CAD software, some kinematic and dynamic simulations were carried out. These simulations had several goals in mind.\n\\begin{enumerate}\\itemsep -10pt\n\\item Understand the motion of the tilting suspension depending on its geometry.\n\\item Maintain the wheels as vertical as possible during the leaning of the body.\n\\item Minimize the required torque from the tilting motor. \n\\end{enumerate}\nThe simulations were developed in MATLAB, following a similar structure to the functions introduced in the book by A. Avello\\cite{iturriagagoitia2014teoria}. The analysis starts by defining a model of elements that are linked together by different types of joints. This model is then translated into a set of equations $\\Phi$ that define the constraints of the system. Whichever the motion of the mechanism, it must obey these equations. \n\n\\newpage\nThe kinematic simulations require to solve three problems (position, velocity and acceleration) in that order. Then the dynamic simulation makes use of the results from the kinematic analysis, giving an estimation of the forces and reactions in the system.\n\n\\subsection{Model Schematic}\n\nThe first step to a mechanical analysis is to generate a model of elements that represent the system. In this case, the front suspension is abstracted into a 2D model of bars. \n\nThe process of designing the model is very simple. The user introduces the length of the bars, then the coordinates of all points are calculated from a fixed frame reference and based on those bar lengths. Finally, the estimated mass of each bar is introduced, and all possible external forces are applied as well. For example, the weight of the driver is simulated as a 80kg weight located in a point near to the center of gravity of the vehicle.\n\n\\begin{figure}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/1}\n\t\\caption{Simulated Model}\n\t\\label{model_schematic}\n\\end{figure}\n\nBased on the Autodesk ForceEffect model designed previously, the suspension model was implemented in MATLAB. It has 20 points -- 3 of them fixed, A, B, C -- that define the bars. There are only three types of links in the model: articulations, weld and slider. \n\nThe constraint equations that define this model can be summarized in these types (the examples have been taken from the model in Figure \\ref{model_schematic}):\n\n\\marginnote{$x_{i}$ is the x coordinate of the point i\\\\\n$y_{i}$ is the y coordinate of the point i\\\\\n$L_{a\\,b}$ is the length of the bar $a$-$b$}\n\\begin{itemize}\n\\begin{itemize}\n\\item Bar $\\hspace{1.25cm}(x_{1}-x_{3})^{2}+(y_{1}-y_{3})^{2}-L_{1\\,3}^{2}=0$\n\n\\item Triangle  \\begin{aligned}\n(x_{1}-x_{2})^{2}+(y_{1}-y_{2})^{2}-L_{1\\,2}^{2}=0\\\\\n\\hspace{0.5cm}(x_{1}-x_{9})^{2}+(y_{1}-y_{9})^{2}-L_{1\\,9}^{2}=0\\\\\n\\hspace{0.5cm}(x_{2}-x_{9})^{2}+(y_{2}-y_{9})^{2}-L_{2\\,9}^{2}=0\n\\end{aligned}\n\n\\item Welded \\begin{aligned}\n(x_{6}-x_{7})(x_{4}-x_{7})+(y_{6}-y_{7})(y_{4}-y_{7})-L_{6\\,7}L_{4\\,7}\\cos(90)=0\\\\\n\\hspace{0.5cm}(x_{6}-x_{7})(y_{4}-y_{7})-(y_{6}-y_{7})(x_{4}-x_{7})-L_{6\\,7}L_{4\\,7}\\sin(90)=0\n\\end{aligned}\n\n\\item Slider $\\hspace{0.75cm}(x_{6}-x_{B})(y_{B}-y_{C})-(y_{6}-y_{B})(x_{B}-x_{C})=0$\n\\end{itemize}\n\\end{itemize}\n\nEach of these constraint equations is denoted as $\\Phi(\\vec{g},t)$, since depend in the vector of the coordinates $\\vec{g}$ and the time $t$.\n\nIn Figure \\ref{model_schematic} only 16 moving and 3 fixed points have been represented. The model will be completed with the introduction of the tilting actuation and the driver model. In total there will be 20 moving points and 3 relative coordinates (angles), which make a total of \\textbf{43 unknown coordinates}.\n\\[\\vec{g}=\\begin{bmatrix} x_{1}\\quad y_{1}\\quad x_{2}\\quad ... \\quad x_{20}\\quad y_{20} \\quad \\theta \\quad \\gamma \\quad \\phi \\end{bmatrix}_{43x1}\\]\n\\[\\Phi(\\vec{g},t)_{42x1}\\] \\[\\Phi_g(\\vec{g},t)_{42x43}\\quad with \\quad \\Phi_g(\\vec{g},t)_{i,j}=\\frac{\\partial \\Phi_{i}}{\\partial x_{j}}\\]\n\nNote that the size of the coordinates vector (unknowns) is bigger than the number of equations in the system ($42\\rightarrow43$). This is due to the fact that one of the coordinates will be degree of freedom, and therefore a known value.\n\nDue to the geometry of the model, it is impossible to put one fixed articulation in each wheel's point of contact with the ground. Instead, one of these two links has to be modified into an articulated slider. Another alternative was the implemented design, with a fixed rotation point and one articulated slider on each wheel. With this decision, the model behavior is completely identical  --symmetrical-- on both sides.\n\nFrom now on we will refer as \\textbf{inner wheel} to the wheel closer to the center of rotation of the trajectory and as \\textbf{outer} to the other one. This notation will be alternated with left and right wheels for inner and outer.\n\n\n\\newpage\n\\subsection{Kinematic Simulations}\n\nThe goal of the kinematic simulations is to find the best geometry for stability during the tilting motion, that is, to design the front suspension so that the inner wheel should maintain as vertical as possible, so the outer wheel.\n\nThe degree of freedom $z$ of the model is the rotation angle $\\phi$ that the body forms with the vertical axis. The vector of coordinates $\\vec{g}$ is formed by the $x$ and $y$ coordinates of the 20 points. Other extra variables, angles and distances of interest are also included in the vector $\\vec{q}$. As stated previously, to study the motion of a system three problems have to be solved, in this order:\n\n\\begin{itemize}\n\\begin{itemize}\n\\item Position Problem\n\n\\marginnote{Position Problem: \\\\Input $z$; Unknown $g$}\nGiven a value for the degree of freedom $z=\\phi$, the vector of coordinates is calculated solving the system of non-linear equations $\\Phi$. The Newton-Raphson method is used to solve the equations:\n\\[\\Phi(\\vec{g}+\\Delta\\vec{g},t) \\approx \\Phi(\\vec{g},t)+\\Phi_{\\vec{g}}(\\vec{g},t)\\Delta\\vec{g} \\approx 0\\] where the $\\Phi_{\\vec{g}}$ is the Jacobian of the constraint equations. Through a iterative process, the values of the coordinates are calculated: \\[\\Phi_{\\vec{g}}(\\vec{g}_{i},t)(g_{i+1}-g_{i})=-\\Phi(g_{i},t)\\]\n\n\\item Velocity Problem\n\n\\marginnote{Velocity Problem: \\\\Input $g,\\dot{z}$; Unknown $\\dot{g}$}\nThe derivative of the constraint equations is also null:\n\\[\\frac{d}{dt}\\Phi(\\vec{g},t)=\\Phi_{\\vec{g}}\\,\\dot{\\vec{g}}+\\Phi_{t}=0\\]\nwhere $\\Phi_{t}$ is the partial derivative of the constraint equations with respect to time $t$. The position of the system is known for each time $t$, so the matrix  $\\Phi_{\\vec{g}}$ and $\\Phi_{t}$ are known, which gives the values of the velocity $\\dot{\\vec{g}}$: \\[\\Phi_{\\vec{g}}\\,\\dot{\\vec{g}}=-\\Phi_{t}\\]\n\n\\item Acceleration Problem\n\n\\marginnote{Acceleration Problem: \\\\Input $g,\\dot{g},\\ddot{z}$; Unknown $\\ddot{g}$}\nFollowing the same logic, the vector of accelerations is obtained:\n\\[\\frac{d^2}{dt^2}\\Phi(\\vec{g},t)=\\Phi_{\\vec{g}}\\,\\ddot{\\vec{g}}+\\dot{\\Phi}_{\\vec{g}}\\,\\dot{\\vec{g}}+\\dot{\\Phi}_{t}=0\\]. If this equation is rearranged, the only unknown is the vector of accelerations $\\ddot{\\vec{g}}$: \\[\\Phi_{\\vec{g}}\\,\\ddot{\\vec{g}}=-\\dot{\\Phi}_{\\vec{g}}\\,\\dot{\\vec{g}}-\\dot{\\Phi}_{t}\\]\n\n\\end{itemize}\n\\end{itemize}\n\n\\subsection{Dynamic Simulations}\n\nOnce the kinematic problem has been solved, the dynamic of the system can be studied. From the principle of virtual work: \\[\\delta W_{inertia} + \\delta W_{external} =0 \\] Applying this theorem in function of the vector of natural coordinates $g$: \\begin{equation}\n\\delta \\vec{g}^{T}\\,M\\,\\ddot{\\vec{g}}+\\delta \\vec{g}^{T}\\,Q=0\n\\label{dynamic}\n\\end{equation} where $M$ is the mass matrix and $Q$ the vector of generalized forces.\n\\begin{marginfigure}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/bar}\n\t\\caption{Element of the model}\n\\end{marginfigure}\nTo build $M$, each element's $M_{e}$ is calculated first, and its inserted in the corresponding cells of the $M$ matrix. \n\\[M_{e}=\\begin{bmatrix}\nm+a-2b_{x} & 0 & b_{x}-a & -b_{y} \\\\\n\t& m+a-2b_{x} & b_{y} & b_{x}-a \\\\\n\t & & a & 0 \\\\\n\t sim. & & & a\n\\end{bmatrix}\\]\nwith\n\\[a=\\frac{I_{i}}{L_{i\\,j}^2} \\quad b_{x}=\\frac{m\\, ^{e}x_{G}}{L_{i\\,j}} \\quad b_{y}=\\frac{m\\, ^{e}y_{G}}{L_{i\\,j}} \\quad m=\\int_{V}{dm}\\]\n\\[I_{i}=\\int_{V}{(^{e}x^{2}+\\,^{e}y^{2})dm \\quad ^{e}x_{G}=\\frac{1}{M}\\int_{V}{^{e}x\\,dm \\quad ^{e}y_{G}=\\frac{1}{M}\\int_{V}{^{e}y\\,dm\\]\n\nThe matrix $Q$ is build in the same way, but accounts for the external forces in the system, for example, the torque from a motor. For any force $F$ in the model:\n\\[Q_{F}=\\frac{1}{L_{i\\,j}}\n\\begin{bmatrix}\nL_{i\\,j}-\\,^{e}x & \\,^{e}y \\\\\n\\,^{e}y  & L_{i\\,j}-\\,^{e}x \\\\\n^{e}x & ^{e}y \\\\\n-\\,^{e}y & ^{e}x\n\\end{bmatrix}\n\\begin{bmatrix}\nF_{x} \\\\ F_{y}\n\\end{bmatrix}\\]\n\nThe matrix $M$ and $Q$ are therefore known. The values of the coordinates vector $\\vec{g}$ can be expressed as a function of the degrees of freedom $z$ as $\\vec{g}=f(z)$ where \\[\\dot{\\vec{g}}=\\frac{\\partial f}{\\partial z}\\dot{z}=R\\,\\dot{z} \\hspace{1cm} \\ddot{\\vec{g}}=R\\,\\ddot{z}+\\dot{R}\\,\\dot{z}\\] Returning to the equation (\\ref{dynamic}): \n\\begin{eqnarray*}\n\\delta \\vec{g}^{T}(M\\ddot{\\vec{g}}-Q)=0\\\\\n\\delta z^{T}R^{T}(M\\ddot{\\vec{g}}-Q)=0\\\\\nR^{T}(M\\ddot{\\vec{g}}-Q)=0 \\\\\nR^{T}M\\ddot{\\vec{g}}=R^{T}Q\\\\\nR^{T}MR\\ddot{z}=R^{T}Q-R^{T}M\\dot{R}\\dot{z}\n\\end{eqnarray*}\nThus the acceleration of the degrees of freedom is obtained when mass and external forces are applied. \n\n\\subsection{Torque Calculation}\n\nIt must be pointed out that in this thesis, the only variable of interest is the torque requirement from the motor. In order to get that variable a different perspective is necessary. \n\nOnce again from equation (\\ref{dynamic}), the Lagrange multipliers ($\\lambda$) are introduced. There is one $\\lambda$ per constraint equation in the model, and depending on their equation their meaning changes, but overall are related to the reactions between elements. \n\\begin{equation}\nM\\ddot{\\vec{g}}-Q+\\Phi_{g}^{T}\\lambda=0 \\label{lagrange}\n\\end{equation}\nFor getting the value of the motor torque, a known tilting angle trajectory $\\phi_{c}(t)$  has to be imposed:\\begin{equation}\n\\Phi=\\phi(t)-\\phi_{c}(t) \\label{motor_torque}\n\\end{equation}\nFor the sake of the programmer, once the kinematics have been solved, it is quite disturbing to change the system of equations again, introducing a new time depending equation. If only the motor torque is needed, a particular method to get it can be developed.\n\nFirst, let us consider that the tilting angle $\\phi$ is part of the coordinates vector $\\vec{g}$ as: \\[\\vec{g}=\\begin{bmatrix}\nx_{1}\\quad y_{1}\\quad x_{2}\\quad ... \\quad x_{20}\\quad y_{20} \\quad \\theta \\quad \\gamma \\quad \\phi\n\\end{bmatrix}\\]\n\nIt was already verified that: \\[M\\ddot{\\vec{g}}-Q+\\Phi_{g}^{T}\\lambda=0\\] \\[\\lambda=\\Phi_{g}^{H}(M\\ddot{\\vec{g}}-Q)\\] Inserting the equation (\\ref{motor_torque}) does not change the terms $M\\ddot{\\vec{g}}-Q$ in equation (\\ref{lagrange}). It only expands the Jacobian $\\Phi_{g}$ with a row of zeros and a one:\\[\\begin{bmatrix}\\Phi_{g}\\end{bmatrix} \\quad\\rightarrow\\quad \\left[\\begin{array}{ccccc}\n& & \\Phi_{g} &  & \\\\ \\hline\n0 & 0 & ... & 0 & 1 \\\\\n\\end{array}\t\\right]\\]\nReturning to equation (\\ref{lagrange}), the lagrangian terms becomes: \\[\\begin{bmatrix}\n\\Phi_{g}^{T} \\end{bmatrix}\\begin{bmatrix}\\lambda_{1}\\\\ \\lambda_{2} \\\\ ... \\\\  \\lambda_{42}  \\end{bmatrix}\\quad\\rightarrow\\quad \\left[\\begin{array}{c|c} & 0 \\\\ & 0 \\\\ \\Phi_{g}^{T}(1:42,:) & ... \\\\ & 0 \\\\ \\hline \\Phi_{g}^{T}(43,:) & 1 \\\\ \\end{array}\t\\right]\\begin{bmatrix}\\lambda_{1}\\\\ \\lambda_{2} \\\\ ... \\\\  \\lambda_{42} \\\\ \\lambda_{43} \\end{bmatrix}\\] Calculating the product of this new lagrangian term and considering that the mass and external forces terms do not change: \n\\[M\\ddot{\\vec{g}}-Q+\\Phi_{g}(1:42,:)^{T}\\lambda=0\\] \\[\\Phi_{g}^{T}(43,:)  \\begin{bmatrix}\n\\lambda_{1} & \\lambda_{2} & ... &  \\lambda_{42} \\end{bmatrix}^{T} + \\lambda_{43}=0\\] \\[M_{t}=\\lambda_{43}=-\\Phi_{g}^{T}(43,:) \\begin{bmatrix} \\lambda_{1} & \\lambda_{2} & ... &  \\lambda_{42} \\end{bmatrix}^{T}\\]\n\n\\newpage\n\\subsection{MATLAB Simulations}\n\\textbf{Model}\n\n\\begin{figure}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/Picture2}\n\t\\caption{Model}\n\\end{figure}\nThe model has a pre-established constraints, due to the selection of some components. That is the reason why there are some fixed dimensions:\n\\begin{itemize}\n\\begin{itemize} \\itemsep -15pt\n \\item Wheel Radius\n \\item Vehicle Track\n \\item Kingpin angle\n \\item Hub width and height\n \\item Wishbone arms horizontal in steady state\n\\end{itemize}\n\\end{itemize}\nThe \\textbf{degree of freedom} is the body inclination $\\phi$, based on the rotation point A, where the motor should be placed. For the kinematic simulations it will be established that: $\\phi=(0\\,-\\,30)\\,\\degree;\\quad \\dot{\\phi}=1 rad/s;\\quad \\ddot{\\phi}=0 rad/s^{2}$\n\n\\textbf{Kinematics}\n\nWe will study the motion of the system with varying parameters. The only parameters left to determine are the \\textbf{position of the motor} --height $h \\in (0-600) mm$-- and the \\textbf{width of the body in the suspension} --$L_{1\\,9},\\,L_{2\\,10} \\in (0-300) mm$--, which will initially cover those ranges.\n\nThe model is fixed to some dimensions, and its \\textbf{tilted to the maximum possible angle}. The inclination of the body and the wheels is recorded and saved. Then both the left and right wheels angle is compared with the body angle. This data is the \\textbf{fitted into a linear regression} and its slope and quadratic error are saved for later analysis.\n\\begin{figure*}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/Relations}\n\t\\caption{Left (inner) and right (outer) wheels angle versus the body angle during a tilting motion}\n\\end{figure*}\n\nAfter simulating the mechanism with different geometric constraints (54900 combinations), some conditions were applied to find the most suitable geometry:\n\\begin{enumerate}\\itemsep -8pt\n \\item Ratio between the inner wheel inclination angle and the body leaning \\textbf{$\\phi_{inner\\,to\\,body}< 0.96$}\n \\item The body width should have enough space for connecting the suspension arms \\textbf{$L_{1\\,9},\\,L_{2\\,10} > 30 mm$}\n \\item The body should lean a minimum angle ($\\phi_{max}>25\\degree$)\n \\item The rotation point should be located near to the body, in order to avoid the motor scraping against the ground or being too high.\n\\end{enumerate}\nApplying these constraints a set of possibilities is obtained: \n\\begin{table}[h!]\n\\centering\n\\begin{tabular}{ccc|ccccc}\n\t\\\\[20pt]\n\th   & L_{1\\,9} & L_{2\\,10} & \\phi_{max} & \\phi_{left\\,to\\,body} & RSE_{left\\,to\\,body} & \\phi_{right\\,to\\,body} & RSE_{right\\,to\\,body} \\\\ \\hline\n\t260 & 31    & 61  & 0.4500   & 0.9530  & 0.0020  & 1.1560  & 0.0020\\\\\n\t260 & 61    & 101  & 0.4500   & 0.9592  & 0.0017 & 1.1397  & 0.0017\\\\\n\t250 & 31    & 61   & 0.4500   & 0.9534  & 0.0020 & 1.1598  & 0.0020\\\\\n\t\\textbf{250} & \\textbf{61}    & \\textbf{101}  & \\textbf{0.4500}   & \\textbf{0.9596}  & \\textbf{0.0017} & \\textbf{1.1432}  & \\textbf{0.0017}\\\\\n\t240 & 31    & 61   & 0.4500   & 0.9539  & 0.0019 & 1.1432  & 0.0019\\\\\n\t240 & 61    & 101  & 0.4500   & 0.9600  & 0.0017 & 1.1643  & 0.0017\\\\\n\t230 & 31    & 61   & 0.4499   & 0.9543  & 0.0019 & 1.1730  & 0.0019\\\\ \\hline  \n\t\\end{tabular}\n\t%\\\\[20pt]\n\t\\caption{Geometries remaining after applying the selection constraints}\n\t\\label{selection}\n\\end{table}\n\n\\newpage\nThe selected geometry has been emphasized in the table \\ref{selection} and represented in Figure \\ref{selectedgeometry}. The motor should be located inside the body, at $230–260$ mm from the ground. The selection of $L_{1\\,9}$ is clearly affected by the second constraint, it usually selects the lower bound (31 mm). Regarding the body geometry, the length $L_{1\\,9}$ should be around 60 mm, while the length $L_{2\\,10}$ should be around 100 mm. These values could be recalculated in case that the 60 mm separation between pins would not be enough. \n\n\\begin{figure*}[h!]\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/4}\n\t\\caption{Selected geometry}\n\t\\label{selectedgeometry}\n\\end{figure*}\n\nOther interesting conclusions can be extracted from the kinematic analysis. First, let us look at the value of $\\phi_{max}$ (Figure \\ref{phimax}) for all the possible combinations. \n\nWe can notice that increasing the rotating point reduces the cases of high leaning angles. The lower the point A, the higher the leaning angle. In addition, ff the position of the rotating point is maintained constant ($h=constant$), that is, independently of the rotating point height, there exist a line where the dimensions $L_{1\\,9}$ and $L_{2\\,10}$ give the highest possible leaning angle. This line gives a body with a particular lateral edge. \n\nIndeed, the $\\bar{12}$ edge would form 55$\\degree$ with the horizontal in that optimum case. But reality is that the selection has to be based in a balance, going to the optimum in one dimension will mean worse values in the other dimensions.\n\nIn Figures \\ref{phileft} and \\ref{phiright} the values of $\\phi_{inner}$ and $\\phi_{outer}$ tell that independently from the rotating point height, the regions where there is a low inner wheel to body angle ratio are the same where there is a high outer wheel to body angle ratio. The selected point fall into a balanced zone between these two regions.\n\nFinally, in Figure \\ref{phirelation} the relation between the inner-wheel-to-body ratio and the outer -wheel-to-body ratio is represented. Out of curiosity, it is impossible to find a geometry in which simultaneously the inner and the outer wheel angle are lower than the body angle. When a ratio is below 1, the other ratio is always above 1, and vice versa.\n\n\\begin{figure*}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/phimax}\n\t\\caption{Value of $\\phi_{max}$ in function of $L_{1\\,9}$ (x axis), $L_{2\\,10}$ (y axis), and $h$ (different figures)}\n\t\\label{phimax}\n\\end{figure*}\n\n\\begin{figure*}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/phileft}\n\t\\caption{Value of $\\phi_{inner}$ in function of $L_{1\\,9}$ (x axis), $L_{2\\,10}$ (y axis), and $h$ (different figures)}\n\t\\label{phileft}\n\\end{figure*}\n\n\\begin{figure*}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/phiright}\n\t\\caption{Value of $\\phi_{outer}$ in function of $L_{1\\,9}$ (x axis), $L_{2\\,10}$ (y axis), and $h$ (different figures)}\n\t\\label{phiright}\n\\end{figure*}\n\n\\begin{figure}\n\t\\includegraphics[width=1.0\\linewidth]{figs/05/sim/PhiRelation}\n\t\\caption{Ratio of angles on inclination $\\phi_{inner\\,to\\,body}$ vs $\\phi_{outer\\,to\\,body}$ in function of $L_{1\\,9}$ (x axis), $L_{2\\,10}$ (y axis). Each point represents a combination of the geometry}\n\t\\label{phirelation}\n\\end{figure}\n\n\\textbf{Dynamics}\n\nThe dynamic analysis has been focused on the estimation of the necessary torque to maintain the body in vertical position. The worst case scenario for the motor is when the user gets on the vehicle. The motor will be able to return to the vertical position only if the torque requirement is lower than the maximum torque of the motor. On the contrary, inn a dynamic situation the forces on the vehicle will help the motor to return to the vertical position after a curve.\n\nTo carry out the dynamic simulation, the weight of each element is estimated with their material density and approximate dimensions. In addition, the weight of an standard (80kg) driver is include at a height on 1m (around the center of gravity).\n\nThen, the model is forced to a known initial position ($\\phi$ is the input) and the torque to return to the vertical position is calculated. For this step the expressions presented previously, based on the Lagrangian formulation, is used:\\[M_{t}=\\lambda_{m}=-\\Phi_{g}^{T} \\begin{bmatrix} \\lambda_{1} & \\lambda_{2} & ... &  \\lambda_{20} \\end{bmatrix}\\]\nThe model was also slightly modified to include the tilting mechanism. The design B.4 was selected for this analysis, which consisted on a gear system attached between the motor and the lower suspension arms. Two different gear ratios were studied, with an increase of 1.5:1 and 4:1 in the motor torque:\n\n\\newpage\n\\begin{marginfigure}[5cm]\n\t\\includegraphics[width=1.15\\linewidth]{figs/05/sim/gear15_2}\n\t\\caption{Studied model with gear ratio=1.5}\n\\end{marginfigure}\n\\begin{marginfigure}[5cm]\n\t\\includegraphics[width=1.15\\linewidth]{figs/05/sim/gear4_2}\n\t\\caption{Studied model with gear ratio=4}\n\\end{marginfigure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/sim/gear15_1}\n\t\\caption{Necessary motor torque to restore vertical position with gear ratio=1.5}\n\\end{figure}\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/sim/gear4_1}\n\t\\caption{Necessary motor torque to restore vertical position with gear ratio=4}\n\\end{figure}\n\nFor acceptable leaning angles (around 15\\degree) there is torque requirement of 50Nm for the 1.5:1 gear ratio and of 15Nm for the 4:1 gear ratio. Let us study the characteristics of the available tilting motor to verify that this conditions are fulfilled.   \n\n\\newpage\n\\textbf{NIDEC 48R Motor}\n\nThe selected motor is a NIDEC 48R BLDC motor. Brushless DC motors do not require commutators and brushes, and have a long life, quietness, and high efficiency. It has a 144 ratio gear attached, which was customized for high-torque applications. The datasheet of the motor (without the gear) is included in the appendices. The rated power is 67W, with a nominal output torque $T_{r}$ of 0.2Nm and a current consumption of $I_{r}$ of 3.8A. In no load conditions, the output speed is $n_{0}=4460 1/min$, with a current consumption of 0.5A.\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.85\\linewidth]{figs/05/sim/motor}\n\t\\caption{NIDEC 48R motor curves}\n\\end{figure}\n\\\\\\6\nConsidering these two situations --nominal and no load--, the curve torque vs current can be obtained. \\[T=m\\,I+n; \\quad 0=0.5m + n; \\quad 0.2=3.8m+n\\] \\[T=\\frac{2I-1}{33}\\] With a output ratio of 144 in the planetary gear, and limiting the \\textbf{maximum current to 5A}, the maximum torque is \\[T_{max}=144\\frac{2·5-1}{33}\\approx 40 Nm\\] With an additional gear, the torque increases to \\textbf{60Nm and 160Nm with 1.5 and 4 gears ratio} respectively. Therefore, the \\textbf{motor is able to recover} from the considered situations. In the view of the results of the dynamic analysis, the gears between the motor and the suspension arms will be designed to have a \\textbf{ratio of 2:1}.\n\n\\newpage\n\\section{Design}\n\nThe previous simulations have offered a better understanding of the motion of the front suspension and have helped to complete its geometry. In this section we will go through the design process for the different parts of the PEV.\n\n\\subsection{Tilting}\n\\begin{marginfigure}[5.5cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/IMG_20161220_154842}\n\t\\caption{Aluminum part to connect the frame and the suspension arms. The geometry fits with the output from the kinematic simulations (part upside down) }\n\\end{marginfigure}\nFor the tilting part some components were reused from other vehicles (wheels, suspension arms and hubs). The wheels are not perfectly suited for tilting vehicles, due to their narrow width. On the other side, the hubs determine the height of the suspension points in the frame, since in steady position the suspension arms are intended to remain parallel to the ground. \n\nThe key point in the design of the tilting suspension was the selection of ball joints as articulations. Super-swivel ball joint rod ends were selected due to the 55$\\degree$ angle of ball swivel, being able to accommodate more misalignment than any other externally threaded rod end. This high angle allowed the tilting of the vehicle up to 30$\\degree$.\n\nThe rest of the joining components were purchased at McMaster.com --their cost has been summarized in the Ch.7: Cost Summary--, and their datasheets have been included in the appendices. The joining of the suspension arms and the frame was carried out by a aluminum part made of water jetted sheets of 1/8'=3.125 mm. This part followed the geometry extracted from the MATLAB simulations, having 60 mm and 100 mm between the upper and lower suspension points respectively.\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/IMG_20161219_165930}\n\t\\caption{Initial state of the PEV frame}\n\\end{figure}\n\n\\newpage\nThe gears were designed using a design table from excel\\cite{gear} that was then imported to Solidworks. This table took into account all the parameters of the gears. As stated previously, the ratio of the gears was 2:1, with a width of 1/4'=6.35 mm and were fabricated with the water jet machine. The gears were inserted into the suspension arms by cutting them in half. This issue was due to the fact that the suspension arms were already fabricated and it was not possible to insert the gears in their position without breaking some parts.\n\\begin{table}[h!]\n\\centering\n\t\\begin{tabular}{lll}\n\t\\hline\n\tHalf Width      & h  & 0.785 \\\\\n\tAddendum\t    & a  & 1     \\\\\n\tDedendum        & b  & 1.25  \\\\\n\tFillet Radius   & e  & 0.38  \\\\\n\tModule          & m  & 1     \\\\\n\tTeeth           & z  & 20    \\\\\n\tProfile Shift   & s  & 0.25  \\\\\n\tPressure Angle  & $\\alpha$  & 0.349 \\\\\n\tPitch Radius    & R  & 10    \\\\\n\tBase Radius     & R_{0} & 9.397 \\\\\n\tAddendum Radius & r_{a} & 11    \\\\\n\tHalf Angle      & $\\gamma$  & 0.093 \\\\\n\tFillet Center   & v_{C} & -0.87 \\\\\n\tFillet Center   & u_{C} & 1.506 \\\\\n\t\\hline\n\t\\end{tabular}\n\t%\\\\[20pt]\n\t\\caption{Gear parameters}\n\\end{table}\n\\begin{marginfigure}[-2.75cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/involute}\n\t\\caption{Gear Design: Addendum, Involute, Trochoidal and Dedendum sections}\n\\end{marginfigure}\nBut far from meaning a problem, being able to put and remove the gears allowed to test the vehicle with and without tilting\\ref{P1050722}. This modular advantage probed to be really useful, disassembling the gear and replacing a pair of shock absorbers allowed to test the vehicle with no tilting in a very straightforward way.\n\nThe frame was first modelled in Solidworks, as the baseline of the rest of the components. The non relevant parts were imported from online resources as GradCad, for example, the wheels. Once the frame was in Solidworks, the rest of the parts were designed and fabricated in the Media Lab's machine shop.\n\nThe assemble of the parts did not imply any problem. At this stage there was not steering system, so the wheels could rotate freely. This complicated a bit the tilting tests, since the wheels started rotating when the suspension moved. Nevertheless, the tilting mechanism worked satisfactorily and the inclination angles were as high as expected. \n\nThe NIDEC motor was controlled with a driver connected to the Arduino board. The control strategy uses a PWM signal to command the speed of the motor and the position is controlled with a PID. In the electronics section a deeper explanation is included.\n\n\\begin{marginfigure}[-5cm]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/IMG_20161231_124145}\n\t\\caption{Top view: PEV tilting, first test without steering }\n\\end{marginfigure}\n\\newpage\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/IMG_20161231_124120}\n\t\\caption{Front view: PEV tilting, first test without steering}\n\t\\\\[-0.5cm]\n\\end{figure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/IMG_20161230_212159}\n\t\\caption{Tilting mechanism: motor and gears}\n\t\\\\[-0.5cm]\n\\end{figure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/P1050722}\n\t\\caption{Front suspension without tilting}\n\t\\label{P1050722}\n\t\\\\[-0.5cm]\n\\end{figure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/Render_Design_B_2}\n\t\\caption{Render of the front suspension}\n\t\\\\[-1cm]\n\\end{figure}\n\n\\newpage\n\n\\subsection{Steering}\n\\begin{marginfigure}[2cm]\n\t\\includegraphics[width=1.1\\linewidth]{figs/05/P1050723}\n\t\\caption{Steering mechanism, NIDEC motor and VESC controller}\n\t\\label{P1050723}\n\\end{marginfigure}\n\nDuring the fabrication process it was decided to implement a steer-by-wire system. There were two main reasons to justify this system:\n\\begin{itemize}\n\\begin{itemize}\n\\item \\textbf{SDTC}: by introducing a motor to control the steering mechanism, there is the possibility of changing the steer angle from the driver. The SDTC control strategy requires the control of the wheels to modify the path of the vehicle and tilt the vehicle by countersteering at high speeds. Even though in this project there was no time for implementing the SDTC, the steer-by-wire system remains useful for future applications of this vehicle.\n\n\\item \\textbf{Autonomy}: an actuated steering system is a basic feature for an autonomous lightweight vehicle. If a fleet of PEV is on the streets and a user calls one of them, it will need of a motorized propulsion and steering as well. In a reduced manner, in this project it was possible to remotely control the PEV and test it without a driver.\n\\end{itemize}\n\\end{itemize}\n\nThe main drawback of the steer-by-wire system is that it requires to be constantly powered by the batteries. When the vehicle is powered off, the steering motor remains in the same position, until is powered again and the handle bar and the wheels align. \n\nArduino boards do not have save any data after they are powered off. This fact implies that if the handle bar is moved during a no-power period, there will be a misalignment between the wheels and the handle bar. To avoid this problem, the absolute orientation of the IMU is used. By configuring the IMU properly, the orientation with respect to an inertial frame can be obtained. In case that the vehicle is rotated, there will also be a misalignment again, so two identical IMUs were necessary. The relative angle between them will report to the motor the initial angle of the wheels.\n \nIn the Figure \\ref{P1050723}, the position of the motor and the steering mechanism is represented. Some modifications were made to the aluminum frame to allocate the motor. The output shaft goes through the frame, connected to another aluminum part. This part (Figure \\ref{IMG_20170403_011512}) had several holes to adapt to the rest of attachments. The white case was 3D printed and contains the VESC controller.\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.7\\linewidth]{figs/05/IMG_20170403_011512}\n\t\\caption{Steering parts}\n\t\\label{IMG_20170403_011512}\n\t\\\\[-5cm]\n\\end{figure}\n\n\\newpage\n\\subsection{Handle Bar}\n\nBefore approaching the design of the handle bar, it was necessary to build a column that supported it. The frame did not have any prepared holes or location for the steering column, so everything had to be designed from scratch and adapted to assure a good joining between the frame and the steering column.\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/Render_Design_B_7}\n\t\\caption{Handle bar and steering column render}\n\t\\\\[-1cm]\n\\end{figure}\n\nThe steer-by-wire system allowed a free design of the column, formed by two lateral aluminum sheets connected by thinner transversal sheets. These parts were water jetted, so a distinctive shape was selected for them. While the fabrication resulted really fast and easy, assembling all these parts required some time. The assembly was really tedious, requiring some clamps to put all the parts together (Figure \\ref{IMG_20170207_154911}).\n\n\\begin{marginfigure}[-3cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/IMG_20170207_154911}\n\t\\caption{Assembly of the handle bar column}\n\t\\label{IMG_20170207_154911}\n\\end{marginfigure}\n\nAt the bottom of this column there was enough room for allocating the wiring and the Arduino boards. The attachment to the frame was done with a bended aluminum part. It is important to point out that it was decided to fabricate the PEV without using the milling machine. Apart from the time that the milling process takes by itself, a training and a preparation of the necessary files for its production were necessary.\n\n\\begin{marginfigure}[0cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/P1050738}\n\t\\caption{Handle bar: motor joining}\n\t\\label{P1050738}\n\\end{marginfigure}\n\nOn top of the column another NIDEC motor was assembled; its shaft had the handle bar connected (Figure \\ref{P1050738}). The reasons to introduce another motor in the handle bar are summarized as follows:\n\\begin{itemize}\n\\begin{itemize}\n\t\\item \\textbf{Haptic Feedback}: a fundamental part of the steer-by-wire system is to give feedback to the driver about the forces that the steering motor is withstanding. In this way, the driver will have a subconscious input about the forces required to move the wheels, and the user experience will be enhanced. \n\t\\newpage\n\tThis is also important in term of safety. Moving the handle bar without any friction can be dangerous, since the driver can make sudden turns, leading to a crash or fall.\n\t\n\tThe implemented feedback was not a realistic input from the forces happening in the steering motor. Instead, the force to move the handle bar linearly increased with the steering angle and the vehicle velocity. There was also a limit in the maximum input angle, generating enough force to block any motion. To do so, the motor variables read from the VESC controller were used, mainly the battery current, the motor current and the tachometer.\n\t\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/IMG_20170123_121416}\n\t\\caption{Test bench for the haptic feedback}\n\t\\\\[-1cm]\n\\end{figure}\n\tAt low speeds, the angle range was quite wide --but limited-- and the forces required to move the handle bar were low. At higher speeds, the handle bar was very limited to a low range of angles and also it required a lot of force to move the handle bar.\tThis helped to reduce the speed of steering, and protected the user to exceed the steering input at high speeds.\n\t\n\t\\item \\textbf{Alert/notify user}: Apart from controlling the steering input from the driver, a motorized handle bar can warn the driver about an obstacle in the road or any other issues with the vehicle or the road conditions. Vibrating the handle bar can the fastest way to notify the user about any problem, reducing the time of reaction and thus protecting the user.\n\t\n\t\\item \\textbf{Compass}: A possible scenario when riding the PEV can be the indication to go right or left when an address has been indicated to the system. Sometimes when riding a bike in a new city or in a unknown neighborhood it is necessary to stop an check the map to orient ourselves and find the next spot.\n\\end{itemize}\n\\end{itemize}\n\\newpage\n\nThe handle bar contains a grip and a brake on each side and a potentiometer on the right side (Figure \\ref{handle_bar}). The left and right brakes activate the brakes on the left and right front wheels respectively, and the potentiometer activates the power assist on the rear motor. A higher value of the potentiometer means a higher duty cycle in the rear motor, thus increasing the velocity of the vehicle.\n\\begin{marginfigure}\n\t\\caption{Handle bar}\n\t\\label{handle_bar}\n\\end{marginfigure}\n\\begin{figure}[h]\n\t\t\\minipage{0.5\\textwidth}\n\t\t  \\includegraphics[width=1.0\\linewidth]{figs/05/P10507342}\n\t\t  \\captionof{a)}{ Left grip and brake}\n\t\t\\endminipage\\hfill\n\t\t\\hspace{1pt}\n\t\t\\minipage{0.5\\textwidth}\n\t\t  \\includegraphics[width=1.0\\linewidth]{figs/05/P10507332}\n\t\t  \\captionof{b)}{ Right grip, brake and throttle}\n\t\t\\endminipage\n\t\t\\\\[0pt]\n\\end{figure}\n\n\\textbf{Driver ergonomics}\n\nThe height and the position of the handle bar was designed to follow the indications in the book \"The Guide to Cycling Ergonomics\" by Ergotec\\cite{ergonomics}. The angles of the driver's articulations have been included in the drawings appendix.\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/driver2}\n\t\\caption{Driver position on the CAD model}\n\t\\\\[0cm]\n\\end{figure}\n\n\\newpage\n\\subsection{Power Assist}\n\nThe PEV is power assisted by a brushless motor located in the rear wheel's hub. This motor is a 36V E-Bikeling 500W geared motor\\cite{ebikeling}. It provides enough power to assist the propulsion of the PEV. The system comes prepared to attach a sprocket to the hub, so that the rear wheel can be moved with the pedals. All the drivetrain parts were mounted in the frame.\n\nThe rear brushless motor, as every NIDEC motor (tilting, steering, handle bar), are controlled by VESC. In the next section --electronics-- more detailed information is included. The PEV is intended to be a lightweight vehicle fully prepared to incorporate a modular autonomous package. This kit will transform a normal three wheeler vehicle into an autonomous urban vehicle. That is why a motor to propulse the vehicle is necessary, as well as another motor to steer the front wheels.\n\n\\begin{marginfigure}[0cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/Sprocket}\n\t\\caption{PEV sprocket}\n\\end{marginfigure}\n\nThe motor will assist under the user demands. In the right side of the handle bar there is a potentiometer that will throttle the vehicle when turned on. Regarding the signal flow, the potentiometer sends the command to the Arduino Mega, which is connected to the VESC controller through serial. The VESC finally controls the motor and moves the rear wheel. \n\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/P1050729}\n\t\\caption{Rear motor in the hub}\n\\end{figure}\n\n\\begin{marginfigure}[-6cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/P1050742}\n\t\\caption{PEV Pedal system: chain, gears and pedals}\n\\end{marginfigure}\n\n\\newpage\n\\subsection{Renders and Pictures}\n\\begin{figure}[h!]\n\t\\includegraphics[width=1.15\\linewidth]{figs/05/Render_Design_B_3}\n\t\\caption{Isometric render}\n\t\\\\[-1cm]\n\\end{figure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=1.1\\linewidth]{figs/05/Render_Design_B_4}\n\t\\caption{Lateral render}\n\t\\\\[-1cm]\n\\end{figure}\n\\begin{figure}[h!]\n\t\\includegraphics[width=1.15\\linewidth]{figs/05/Render_Design_B_6}\n\t\\caption{Front render}\n\t\\\\[-1cm]\n\\end{figure}\n\n\\newpage\n\\begin{figure*}[h!]\n\t\\includegraphics[width=0.9\\linewidth]{figs/05/CreamBox0150}\n\t\\caption{PEV components explosion}\n\\end{figure*}\n$ $\n\\begin{figure*}[h!]\n\t\\includegraphics[width=0.95\\linewidth]{figs/05/P10507152}\n\t\\caption{PEV}\n\\end{figure*}\n\n%\\begin{figure}[h!]\n%\t\\includegraphics[width=1\\linewidth]{figs/05/CreamBox0210}\n%\t\\caption{Render}\n%\t\\\\[-1.5cm]\n%\\end{figure}\n%\\begin{figure}[h!]\n%\t\\includegraphics[width=1\\linewidth]{figs/05/QuietRoom5}\n%\t\\caption{Render}\n%\t\\\\[-1.5cm]\n%\\end{figure}\n\n\n\n\\newpage\n\\section{Electronics}\nElectronics lay the foundation for a mechatronical project. In this section the used components are presented and the process to implement them correctly in the PEV is explained.\n\\subsection{PID Control}\nBefore using the VESC controller --open source, highly modifiable electronic speed controller ESC by Benjamin Vedder--, a NIDEC driver was used to control the angular position of the tilting motor. This happened in an early stage part of the project, so that the PEV final version was designed with VESC controllers.\n\nThe driver had 4 pins to control the motor:\n\\begin{itemize}\n\\begin{itemize}\n\t\\item \\textbf{PWM}: Pulse width modulation signal, it determines the speed of the motor. It is considered as a integer between 0 and 255. The higher PWM, the faster the motor rotates. Connected to a PWM digital output pin in Arduino.\n\t\\item \\textbf{CCW}: Binary variable to select the direction of rotation (clockwise or counter clockwise). Connected to a digital pin.\n\t\\item \\textbf{FG}: Frequency Generator, it outputs a signal with a frequency proportional to the motor speed. The proportional constant was unknown, it was roughly estimated.\n\t\\item \\textbf{GND}: ground connected to the GND port in Arduino.\n\\end{itemize}\n\\end{itemize}\n\nThis driver was used to control the angular position of the tilting motor. The input to the motor will be the value of PWM, that will make the motor rotate at a certain speed. The speed will be read by the pulses coming through the FG pin. Since there are not position readings, the position will be calculated based on the speed and the frequency of the control. \n\nBefore reviewing the control system in detail, it is important to make a distinction between the temporal and the Laplace domains. The control diagram represents the Laplacian domain, where the time variable $t$ is replaced by the complex variable (frequency $s$) by applying the Laplace transform. A variable in lowercase ($n$) will belong to the temporal domain, whereas a variable in uppercase ($N$) will belong to the Laplacian domain.\n\n\\newpage\n\\begin{figure*}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/own/model_own_1}\n\t\\caption{PID control of the angular position}\n\t\\label{model_own_1}\n\\end{figure*}\n\nThe control diagram in Figure \\ref{model_own_1} represents the inputs and outputs of this simple position control. The angular reference $\\phi_{ref}$ is given by the user -- at first through a potentiometer-- and the error $e$ is calculated between the reference and the actual angle $\\phi$. This error will be used to determine the input signal $pwm$ using a PID control. Finally, the $pwm$ will put an specific speed and therefore a position in that timestamp.\n \nTranslating these words into equations, the system equation is expressed as \\[\\phi_{i}=\\phi_{i-1}+60n(t_{i}-t_{i-1})\\] where $\\phi_{i}$ is the angular position at time $t_{i}$ and $n$ is the speed in rpm.\n\nThe input variable $pwm$ is calculated from the error (defined as $E=\\Phi_{ref}-\\Phi$) by means of the PID control: \n\\[pwm=K_{P}(\\phi-\\phi_{ref})+K_{I}\\int_{t_{i-1}}^{t_{i}}(\\phi-\\phi_{ref}) dt + K_{D}\\frac{\\partial (\\phi-\\phi_{ref})}{\\partial t}\\] In the Laplacian domain: \\[PWM=(K_{P}+\\frac{K_{I}}{s}+K_{D})(\\Phi_{ref}-\\Phi)\\]\n\nThe speed is the time derivative of the position with respect to the time:\n\\[n =\\frac{\\delta\\phi}{\\delta t}\\,\\frac{1\\,rev}{2\\pi\\,rad}\\frac{60\\s}{1\\,min}\\quad\\rightarrow\\quad N=s\\,\\Phi \\frac{60}{2\\pi}\\]\n\n\\newpage\n\\begin{marginfigure}[0cm]\n\t\\includegraphics[width=1.2\\linewidth]{figs/05/own/polynomial}\n\t\\caption{Angular speed N vs signal PWM: Polynomial fitting}\n\t\\label{polynomial}\n\\end{marginfigure}\n\\begin{marginfigure}[0cm]\n\t\\includegraphics[width=1.2\\linewidth]{figs/05/own/linear}\n\t\\caption{Angular speed N vs signal PWM: Saturation and linear fitting}\n\t\\label{linear}\n\\end{marginfigure}\nThe relation between the input $pwm$ and the output speed $n$ is not known, but it can be estimated. Using the speed information from the FG pin, some measurements were made to characterize the speed of the motor in function of the $pwm$ input. In Figure \\ref{polynomial} the obtained data is represented and fitted into a 5th grade polynomial curve. \\[N=f(PWM)\\] In Figure \\ref{linear}, on the contrary, the speed-pwm relation is simplified by a linear regression (the speed is saturated at $pwm=57$)\n\\[N=K\\,\\,PWM\\]\nTherefore, the speed is represented in function of the error:\n\\[N=s\\,\\Phi \\frac{60}{2\\pi}=f(PWM)=f\\big((K_{P}+\\frac{K_{I}}{s}+K_{D})(\\Phi_{ref}-\\Phi)\\big)\\]\nFor the sake of simplicity, the transfer function is indicated for the relation $N=K\\,PWM$\n\\[\\Phi=\\Phi_{ref}\\frac{K_{P}\\,s+K_{I}+K_{D}\\,s^2}{\\frac{60s^2}{2\\pi\\,K}+K_{P}\\,s+K_{I}+K_{D}\\,s^2}\\]\nThe control strategy was implemented in MATLAB and the PID tuner turned out to be really useful to determine the values of $K_{P}$, $K_{I}$ and $K_{D}$. Overall the quality of this \\textbf{PID control was satisfactory}, but the VESC controller resulted easier to implement and besides it provided more feedback from the motor (electrical and mechanical variables).\n\\begin{figure}[h!]\n\t\\includegraphics[width=0.85\\linewidth]{figs/05/own/IMG_20161231_132543}\n\t\\caption{Schematic of the early motor controller: Arduino UNO, 9V battery, potentiometer and NIDEC driver}\n\t\\\\[-10cm]\n\\end{figure}\n\n\\newpage\n\\subsection{VESC}\n\nThe VESC is a fully customizable open source electronic speed controller by Benjamin Vedder, designed for lightweight and compact applications like skateboards, or in this case, a three wheeler vehicle.\n\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/vesc}\n\t\\caption{VESC Picture}\n\t\\\\[-1cm]\n\\end{figure}\n\nThe controller receives the power from the batteries and outputs the 3 phases $U$, $V$ and $W$ to the brushless motors. The incorporated firmware offers various possibilities to control the motor in different ways. Every motor in this PEV was configured to be controlled in FOC (Field Oriented Control) sensorless mode.\n\n\\textbf{FOC -- Field Oriented Control}\n\nBLDC motors require a controller that converts the applied DC from the battery cells into AC to drive the motor. This task demands complex driving algorithms to commutate the coils in a sequence that achieves the desired directional rotation. A wide range of control algorithms are available:\n\n\\begin{itemize}\n\\begin{itemize}\n\t\\item Trapezoidal control: For each of the 6 commutation steps, a pair of windings are powered, leaving the third disconnected. This method generates high torque ripple, leading to vibration, noise, and poor performance.\n\t\n\t\\item Sinusoidal control: it supplies sinusoidal varying current to the 3 windings, thus reducing the torque ripple and offering a smooth rotation. However, these time-varying currents are controlled using basic PI regulators, which lead to poor performance at higher speeds.\n\t\n\t\\item Field Oriented Control: the torque and the flux can be controlled independently and provides faster dynamic response. There is no torque ripple and smoother, accurate motor control can be achieved at low and high speeds.\n\\end{itemize}\n\\end{itemize}\n\n\\textbf{VESC Library}\n\n\\marginnote{\n\\begin{tabular}{c}\n\\textbf{bldcMeasure struct} \\\\[1.5pt] \\hline \\\\[-1.5pt]\nAverage Motor Current        \\\\[1.5pt]\nAverage Input Current        \\\\[1.5pt]\nDuty Cycle                   \\\\[1.5pt]\nMotor RPM                    \\\\[1.5pt]\nInput Voltage                \\\\[1.5pt]\nAmperes Hours                \\\\[1.5pt]\nAmperes Hours Charged        \\\\[1.5pt]\nTachometer                   \\\\[1.5pt]\nTachometer Absolute          \\\\[1.5pt] \\hline\n\\end{tabular}\n}\n\nThe VESC was connected to the Arduino MEGA board through serial connection (UART). To facilitate the control of the motor, the VescUartControl library was used in Arduino to interface over UART with the VESC. \n\nThe margin table summarizes the available data from the VESC. In addition, it was possible to set the motor current, the brake current, the angular position, the duty cycle and the RPM of the motor.\n\n\\hspace{1cm}\n\n\\begin{lstlisting}[style=codedef]\n@@bool VescUartGetValue(struct bldcMeasure& values, int num);@@\n\t\n\t%\\textit{Sends a command to VESC and stores the returned data}%\n\n\t@@values@@(struct bldcMeasure&) -  bldcMeasure struct with received data\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\t@@return@@(bool) - true if success\n\n@@void VescUartSetCurrent(float current, int num);@@\n\t\n\t%\\textit{Sends a command to VESC to control the motor current}%\n\n\t@@current@@(float) -  the current for the motor\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\n@@void VescUartSetCurrentBrake(float brakeCurrent, int num);@@\n\t\n\t%\\textit{Sends a command to VESC to control the motor brake}%\n\n\t@@brakeCurrent@@(float) -  the current for the brake\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\n@@void VescUartSetPosition(float position, int num);@@\n\t\n\t%\\textit{Sends a command to VESC to control the motor position}%\n\n\t@@position@@(float) - the position in degrees for the motor\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\n@@void VescUartSetDuty(float duty, int num);@@\n\t\n\t%\\textit{Sends a command to VESC to control the motor duty cycle}%\n\n\t@@duty@@(float) - the duty cycle for the motor\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\n@@void VescUartSetRPM(float rpm, int num);@@\n\t\n\t%\\textit{Sends a command to VESC to control the motor rotational speed}%\n\n\t@@rpm@@(float) - the revolutions per second for the motor\n\t@@num@@(int) - the serial port in use (0=Serial; 1=Serial1; 2=Serial2; 3=Serial3;)\n\n\\end{lstlisting}\n\n\n\\textbf{VESC Features}\n\\begin{marginfigure}\n\t\\includegraphics[width=0.65\\linewidth]{figs/05/BLDC_41}\n\t\\caption{Front VESC Schematic}\n\\end{marginfigure}\n\\begin{marginfigure}\n\t\\includegraphics[width=0.65\\linewidth]{figs/05/BLDC_42}\n\t\\caption{Back VESC Schematic}\n\\end{marginfigure}\n\\begin{itemize}\n\\begin{itemize}\\itemsep -10pt\n\\item Voltage $8V$ to $60V$\n\\item Current up to 240A for a some seconds or 50A continuous\n\\item 5V 1A output for external electronics (arduino)\n\\item Sensored and sensorless FOC, BLDC, and DC\n\\item Current and voltage measurement on all phases\n\\item Duty-cycle control, speed control or current control\n\\item Interface to control the motor: PPM signal, analog, UART, I2C, USB  or CAN-bus.\n\\item Regenerative braking\n\\item Good start-up torque in the sensorless mode\n\\item The motor is used as a tachometer, which is good for odometry\n\\item Adjustable protection against low/high input voltage and high motor/input current.\n\\end{itemize}\n\\end{itemize}\n\n\nIt is possible to plot the currents in the BLDC tool, voltages and the duty cycle in real-time. This is useful when debugging how everything behaves. Some screenshots of the configuration GUI (BLDC Tool):\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/RT_Data}\n\t\\caption{BLDC Tool}\n\\end{figure}\n\nIn order to protect the VESC from hazard and avoid any undesired contacts, some cases were 3D printed. The first version was designed to allocate only the board, whereas the second version had enough space to also incorporate the VESC capacitors.\n\\begin{marginfigure}[-4cm]\n\t\\includegraphics[width=0.9\\linewidth]{figs/05/vesc_case_3}\n\t\\caption{VESC case version 1}\n\\end{marginfigure}\n\\begin{marginfigure}\n\t\\includegraphics[width=0.9\\linewidth]{figs/05/vesc_case_6}\n\t\\caption{VESC case version 2}\n\\end{marginfigure}\n\n\\newpage\n\\subsection{Rotary Encoder}\n\nThe longitudinal velocity of the PEV $V=V_{x}$ is obtained from a rotary encoder located in the rear wheel. This sensor is completely necessary, since the motor is not able to provide this information. The motor and the hub of the rear wheel are disentangled, meaning that the motor freely rotates inside the hub when the user pedals, for example. That is why the motor cannot give a feedback of the velocity of the wheel.\n\nThe rotary encoder or transmitter\\cite{rotary} is a incremental optical encoder, that converts the motion to an electrical signal to indicate the position of the rear wheel. Transmitters must be used with a controller that has quadrature detection to get a 4X resolution increase and meet IP50 for protection from dust.\n\nThe code disk inside a quadrature encoder contains two tracks usually denoted Channel A and Channel B. These tracks or channels are coded ninety electrical degrees out of phase and this is the key design element that will provide the quadrature encoder its functionality. In applications where direction sensing is required, a controller can determine direction of movement based on the phase relationship between Channels A and B. As illustrated in the figure below, when the quadrature encoder is rotating in a clockwise direction its signal will show Channel A leading Channel B, and the reverse will happen when the quadrature encoder rotates counterclockwise.\n\n\\begin{marginfigure}\n\t\\includegraphics[width=1\\linewidth]{figs/05/encoder}\n\t\\caption{Quadrature Encoder}\n\\end{marginfigure}\n\nThe resolution of this particular encoder is of 1000 counts per revolution. It has a 1.91\"=48.5 mm diameter circumference polyurethane wheel attached to the shaft of the encoder. To get the speed of the PEV, a simple kinematic study was done, following the diagram in Figure \\ref{encoder_2}:\n\\[\\vec{v}_{0}=0 \\quad \\vec{v}_{A}=V\\,\\vec{i}=w_{1}\\,R_{1}\\,\\vec{i} \\quad \\vec{v}_{P}=\\vec{v}_{A}+w_{1}\\,R_{1}\\]\n\\[\\vec{v}_{B}=V\\,\\vec{i}=w_{2}\\,R_{2} \\quad \\vec{v}_{P}=\\vec{v}_{B}+w_{2}\\,R_{2}\\]\nEqualing the expression for the P point velocity $\\vec{P}$:  \n\\[\\vec{v}_{A}+w_{1}\\,R_{1}=\\vec{v}_{B}+w_{2}\\,R_{2}\\]\nSince the velocities in the centers of both solid is the same ($\\vec{v}_{A}=\\vec{v}_{B})$):\n\\[w_{1}\\,R_{1}=w_{2}\\,R_{2}\\] and therefore, \\[V\\,\\vec{i}=w_{1}\\,R_{1}=w_{2}\\,R_{2}\\]\nFor calculating the speed of the vehicle, the angular velocity and the radius of the small circumference attached to the encoder is only needed.\n\n\\begin{marginfigure}[-5cm]\n\t\\includegraphics[width=1.15\\linewidth]{figs/05/encoder_2}\n\t\\caption{Wheel -- Encoder diagram}\n\\end{marginfigure}\n\nThe radius is known, and the angular velocity can be defined as:\n\\[w_{2}=\\frac{\\Delta\\phi}{\\Delta t}; \\quad \\Delta\\phi=N_{counts}·\\frac{1\\,rev}{1000\\,counts}·\\frac{2\\pi\\,rad}{1\\rev}\\]\nThe speed is therefore calculated as:\n\\[V=N_{counts}·\\frac{2\\pi R_{1}}{1000\\Delta t}\\]\nEvery time that the encoder sends a pulse to the board, an interrupt routine starts to read that pulse and catch the rising or falling edge on the input pin. Therefore, if the Arduino is not fast enough, interrupting the microprocessor in the board can deny the reading of other pulses and considerably delay other operations. \n\nTaking into account that the resolution was really high (1000 counts/rev), and a radius of the encoder was 48.5/2=24.25 mm if the PEV is going at $1m/s$, for example, that means that in 1 second, the Arduino board needs to be able to interrupt its code more than 6500 times (6500 Hz). Increasing the speed of the vehicle increases this frequency as well.\n\nTo get the number of counts in a given time interval, it was necessary to implement a very fast digital reader in the Arduino Mega in order to not lose any count and estimate correctly the speed of the vehicle. \n\nIn addition, this strategy works even better if a bit of hardware debouncing is forced on the rotary encoder. With two 0.1 uF capacitors soldered to the encoder pins, the number of calls to the interrupt routine is dramatically reduced. This is important because too many calls to the interrupt routine will rob computing cycles from the main routine, negating the effects of using interrupts to save computing power.\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/P1050728}\n\t\\caption{Rotary encoder mounted on the PEV}\n\t\\\\[-2cm]\n\\end{figure}\n\n\\newpage\n\\subsection{IMU}\n\n\\begin{marginfigure}[1cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/bno055}\n\t\\caption{Bosch BNO055 9DOF IMU}\n\\end{marginfigure}\nThe selected inertial motion unit was the Bosch BNO055, a 9-axis absolute orientation sensor with sensor fusion. The BNO055 integrates a triaxial 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of 2000 degrees per second, a triaxial geomagnetic sensor and a 32-bit microcontroller.\n\nIt is connected through I2C (clock and data pins) to the analog pins in the Arduino. The PEV is equipped with a pair of BNO055, both connected through I2C, with the difference that the second IMU's ADC pin is connected to the board as well. Setting the ADR pin to high changes the I2C address from the default (0x28 to 0x29).\n\n\\marginnote{VIN: 3.3-5.0V power supply input \\\\\nGND: common for power and logic \\\\\nSCL - I2C clock pin \\\\\nSDA - I2C data pin \\\\\nADR: to change the I2C address \\\\\n}\n\nRather than spending a lot of time with algorithms of varying accuracy and complexity, the data can be extracted very easily thanks to the sensor fusion. However, it requires to configure it properly when powered. \n\\begin{enumerate}\\itemsep -10pt\n\\item The operation mode has to be setup to be able to configure it (CONFIG MODE)\n\\item Limit accelerometer range to 2G, get better accuracy\n\\item Calibrate using some offsets values obtained previously\n\\item The operation mode is setup again to Fusion mode with NDOF, mode from which the absolute orientation can be obtained.\n\\end{enumerate}\n\n\\textbf{Calibration}\n\nTo obtain correct values from the IMU, it has to be properly calibrated first. Once the device is calibrated, the calibration data will be kept until the BNO is powered off. The BNO doesn't contain any internal EEPROM, so a new calibration will be needed every time the device starts up, or a manual restore of the calibration data.\n\nThe BNO055 includes internal algorithms to constantly calibrate the gyroscope, accelerometer and magnetometer. The four calibration registers -- an overall system calibration status, as well individual gyroscope, magnetometer and accelerometer values -- will return a value between '0' (uncalibrated data) and '3' (fully calibrated).\n\nThe sensors are trimmed to tight offsets, meaning valid data is obtained even before the calibration process is complete, but particularly in NDOF mode any data should be discard as long as the system calibration status is 0. The reason is that system cal '0' in NDOF mode means that the device has not yet found the north pole, and orientation values will be off. The heading will jump to an absolute value once the BNO finds magnetic north.\n\nTo generate valid calibration data, the following criteria should be met:\n\\begin{itemize}\n\\begin{itemize}\\itemsep -10pt\n\\item Gyroscope: the device must be standing still in any position\n\\item Magnetometer: normal movement of the device is sufficient\n\\item Accelerometer: the BNO055 must be placed in 6 standing positions for +X, -X, +Y, -Y, +Z and -Z.\n\\end{itemize}\n\\end{itemize}\n\n\\textbf{Position of the IMU}\n\n\\begin{marginfigure}[0cm]\n\t\\includegraphics[width=1.2\\linewidth]{figs/05/IMU_Overall}\n\t\\caption{Location of IMU A and B}\n\\end{marginfigure}\nThe PEV is equipped with a pair of IMUs, one placed on the handle bar and another one fixed on the frame. The justification for this decision lays on two arguments:\n\\begin{itemize}\n\\begin{itemize}\n\\item The relative angle between the frame and the handle bar can be obtained, meaning that an encoder is not needed in the handle bar.\n\\item The perceived lateral acceleration $a_{per}$ has to be obtained along the lateral axis $y'$, which should not be affected by the handle bar steering.\n\\item The steering angle $\\delta$ and its rate $\\dot{\\delta}$ can be also obtained from the gyroscope\n\\end{itemize}\n\\end{itemize}\n\n\\textbf{Orientation of the IMU}\n\n\\begin{marginfigure}[5cm]\n\t\\includegraphics[width=1.1\\linewidth]{figs/05/Euler}\n\t\\caption{Quaternion vector diagram}\n\\end{marginfigure}\nDue to the fact that each IMU is oriented differently, it is necessary to process the orientation data depending on the case. The angular orientation from each IMU is obtained from the quaternion: \\[\\vec{q}=\\begin{bmatrix} q_{w} \\\\ q_{x} \\\\ q_{y} \\\\ q_{z} \\end{bmatrix}=\\begin{bmatrix} \\cos(\\alpha/2) \\\\ \\sin(\\alpha/2)\\cos(\\beta_{x}) \\\\ \\sin(\\alpha/2)\\cos(\\beta_{y}) \\\\ \\sin(\\alpha/2)\\cos(\\beta_{z}) \\end{bmatrix}\\]\nwhere $\\alpha$ is a simple rotation angle and $\\cos(\\beta_{x})$, $\\cos(\\beta_{y})$ and $\\cos(\\beta_{z})$, are the direction cosines locating the axis of rotation.\n\nThe quaternion is then transformed into the appropriate Euler angles: Roll, Pitch and Yaw. Each of these angles is related to one of the axis X, Y and Z. Depending on the order of the rotations --XYZ and ZYX Euler angles are not the same-- the values of the roll pitch and yaw changes. For transforming the quaternion into the corresponding Euler angles, the motion of each IMU has to be taken into account, as well as their relative orientation. \n\n\\newpage\nThe handle bar and the frame IMU's were placed in different orientations:\n\n\\begin{itemize}\n\\begin{itemize}\n\\item In the handle bar IMU the angle of interest is the steering angle $\\delta$ around the Z axis. In order to obtain it independently from any other rotation, the quaternion is transformed into the YZX euler angles\n\\[\\delta_{A}=\\arctan \\frac{-2(q_{y}\\,q_{z}-q_{w}\\,q_{x)}}{q_{w}^2-q_{x}^2+q_{y}^2-q_{z}^2}\\]\n\n\\item In the frame IMU the angles of interest are the steering angle $\\delta$ and the tilting angle $\\theta$ around the Y and the X axis respectively. Therefore, the transformation is done to obtain the XZY angles\n\\[\\theta=\\arcsin\\big(-2(q_{x}\\,q_{z}-q_{w}\\,q_{y})\\big)\\]\n\\[\\delta_{B}=\\arctan\\frac{2(q_{x}\\,q_{y}+q_{w}\\,q_{z})}{q_{w}^2+q_{x}^2-q_{y}^2-q_{z}^2}\\]\n\\end{itemize}\n\\end{itemize}\n\n\n%\\begin{marginfigure}\n%\t\\caption{IMU angles}\n%\\end{marginfigure}\n%\n%\n%\\begin{figure*}[h]\n%\t\t\\minipage{0.5\\textwidth}\n%\t\t  \\includegraphics[width=1.0\\linewidth]{figs/05/IMU_A2}\n%\t\t  \\captionof{a)}{ Handle bar IMU (A)}\n%\t\t\\endminipage\\hfill\n%\t\t\\hspace{0pt}\n%\t\t\\minipage{0.5\\textwidth}\n%\t\t  \\includegraphics[width=1.0\\linewidth]{figs/05/IMU_B2}\n%\t\t  \\captionof{b)}{ Frame IMU (B)}\n%\t\t\\endminipage\n%\t\t\\\\[0pt]\n%\\end{figure*}\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.85\\linewidth]{figs/05/IMU_A2}\n\t\\caption{Handle bar IMU (A)}\n\t\\\\[1cm]\n\\end{figure}\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.85\\linewidth]{figs/05/IMU_B2}\n\t\\caption{Frame IMU (B)}\n\t\\\\[-2cm]\n\\end{figure}\n\n\\newpage\n\\textbf{Extending angular range}\n\nThe $\\arctan$ and $\\arcsin$ functions implemented only produce results between $-\\pi/2$ and $\\pi/2$. This range problem is solved by extending the angular orientation to a continuous spectrum. Any angle is defined as:\n\\[\\varphi=\\varphi+2\\pi\\,k)\\] with $k=0$ at the initial range $[-\\pi/2,\\pi/2]$.\n\n\\begin{itemize}\n\\begin{itemize}\n\\item If $\\varphi$ exceeds a value of $(k+1)\\pi/2$, then the $k$ increments one unit: $k=k+1$\n\\item If $\\varphi$ falls behind a value of $-(k+1)\\pi/2$, then the $k$ decreases one unit: $k=k-1$\n\\end{itemize}\n\\end{itemize}\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{figs/05/Angle_jump}\n\t\\caption{Discontinuous vs continuous orientation}\n\t\\\\[-0cm]\n\\end{figure}\n\n\\textbf{Data obtained from the IMU}\n\nThe control strategy requires some data to calculate the torque requirement from the tilting motor.\n\n\\begin{table}\n\\begin{tabular}{cl}\n   \t\t\t\t &             \\textif{Handle Bar IMU}           \\\\[2.5pt] \\hline\n$\\delta_{A}$       & Euler angle along vertical direction        \\\\[2.5pt]\n$\\dot{\\delta}$ & Gyroscope along vertical direction          \\\\[2.5pt] \\hline\n\\\\\n         \t\t   &               \\textif{Frame IMU}           \\\\[2.5pt] \\hline\n$\\delta_{B}$       & Euler angle along vertical direction        \\\\[2.5pt]\n$\\dot{\\Phi}$       & Gyroscope along vertical direction          \\\\[2.5pt]\n$\\theta$           & Euler angle along longitudinal direction    \\\\[2.5pt]\n$\\dot{\\theta}$     & Gyroscope along longitudinal direction      \\\\[2.5pt]\n$a_{per}$          & Linear acceleration along lateral direction \\\\[2.5pt] \\hline \\\\\n\\end{tabular}\n\\end{table}\n\nThe steering angle $\\delta$ is calculated from the relative orientation $\\delta=\\delta_{A}-\\delta_{B}$\n\n\n\\newpage\n\\subsection{Communication: Bluetooth Modules}\n\nThe Arduino boards have two Bluetooth modules connected. The two modules, HC05 and HC06 are very similar. HC--05 is a more capable module that can be set to be either master or slave while HC--06 is a slave only device.\n\nThese modules run on 3.3V power and have two modes of operation. In command mode AT commands can be sent to it and in data mode it transmits and receives data to another Bluetooth module.\n\n\\begin{marginfigure}[5cm]\n\t\\includegraphics[width=1.1\\linewidth]{figs/05/android}\n\t\\caption{Android app for remote control}\n\\end{marginfigure}\nThe HC--06 module was connected to an Android app in order to remotely control the PEV. The commands sent to this module controlled the rear motor, as well as the steering motor. The HC--05 module, on the other side, was connected to a Processing script, in which data was saved in real time and exported into a .csv file. In this way, it was possible to analyze the data coming from the sensors and verify the correct response of the control strategy.\n\nAn application of this data sender module was used during the Media Lab's spring members week. The data from the PEV was streamed in real time and projected onto a table. Only basic data was presented during this event, for example, the speed of the rotary encoder and IMU data. The script was also prepared to align the projection to the table, as it can be seen in the Figure \\ref{Captura3}.\n\\begin{figure}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/Captura3}\n\t\\caption{Live streamed data projected onto a table}\n\t\\label{Captura3}\n\\end{figure}\n\n\\newpage\n\\subsection{Arduino}\n\n\\begin{marginfigure}\n\t\\includegraphics[width=1\\linewidth]{figs/05/mega}\n\t\\caption{Arduino Mega}\n\\end{marginfigure}\n\nThe PEV uses two Arduino MEGA boards for the acquisition of the sensor data and for the control of the motors. The reason for using two boards recalls in the VESC controller. The straight forward implementation of the VESC library for Arduino makes appropriate to use connect both through UART connection. \n\nThe Arduino Mega is able to manage 4 Serial connections simultaneously. Since the library makes use of one of them for debugging, it remains 3 Serial connections. The PEV has 4 motors incorporated (steer, handle bar, tilt, throttle), so two Arduino Megas are needed to control all the motors. The Arduinos will be connected through the I2C protocol.\n\nThe code included in both boards has been included in the appendices.\n\n\\subsection{Batteries}\n\n\\begin{marginfigure}[2cm]\n\t\\includegraphics[width=1\\linewidth]{figs/05/battery}\n\t\\caption{HWT-1004-7AB battery}\n\\end{marginfigure}\nThe PEV is powered by two set of DC batteries. The rear motor requires an input voltage of 36V, which is provided by the HWT-1004-7AB battery. This battery is a removable pack, is designed as a 10S4P battery pack by using Li(NiCoMn)O2 cells and its nominal capacity is 11.4 Ah. It also meets waterproof IPX4 and provides two-level protections. The first level protection is done by software which is typically slow to act, and the second level is done by hardware which react very fast, on the order of microseconds or milliseconds.\nHWT-1004-7AB supplies one auxiliary power – USB 5V, so that can satisfies the demand of variety electronical gadgets such as smart phones, MP3 player and head light. \n\nOn the other side, the NIDEC motors need an input voltage of 24V. A pair of PowerSonic PS1290, each one of 12V, were selected for this task. The Power-Sonic PS-1290 is a 12 Volt 9 Amp Hour rechargeable sealed lead acid battery. \n\nFinally, the Arduino boards are powered by the VESC controller 5V output.\n\n\\subsection{Electronic Schematic}\n\nThe schematic of all the components and their connections to the two Arduino Mega boards is included in the next page:\n\\newpage\n\\begin{figure*}[h!]\n\t\\includegraphics[width=1\\linewidth]{figs/05/PEV_fritzing2}\n\t\\caption{Electronic Schematic}\n\\end{figure*}\n\n\\newpage\n\n\n%\\section{Fabrication}\n%\\subsection{Laser Cut}\n%\\subsection{Soldering}\n%\\subsection{Sand Blaster}\n%\\subsection{Water Jet}\n%\\subsection{Sheet Metal Bending}\n%\\subsection{Tube Bending}\n%\\subsection{3D Printing}\n%\\subsection{Drill}\n%\\subsection{Tapping}\n", "meta": {"hexsha": "b8ebb9ca59b0d75650f08aa34f9f9f0bf04ca9cb", "size": 67402, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pages/05realScale.tex", "max_stars_repo_name": "imartinezl/MIT-Media-Lab-latex-thesis", "max_stars_repo_head_hexsha": "f547c9879ca2c2b12ee57ceff9d533061167b701", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-11-25T16:15:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-08T15:09:27.000Z", "max_issues_repo_path": "pages/05realScale.tex", "max_issues_repo_name": "imartinezl/MIT-Media-Lab-latex-thesis", "max_issues_repo_head_hexsha": "f547c9879ca2c2b12ee57ceff9d533061167b701", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pages/05realScale.tex", "max_forks_repo_name": "imartinezl/MIT-Media-Lab-latex-thesis", "max_forks_repo_head_hexsha": "f547c9879ca2c2b12ee57ceff9d533061167b701", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-10-31T00:54:01.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-16T07:29:54.000Z", "avg_line_length": 64.8096153846, "max_line_length": 688, "alphanum_fraction": 0.7473368743, "num_tokens": 19074, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.44544660338348196}}
{"text": "\\XtoCBlock{PIDLimit}\r\n\\label{block:PIDLimit}\r\n\\begin{figure}[H]\\includegraphics{PIDLimit}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Control error input\\tabularnewline\r\n\\hline\r\nInit & Value which is loaded at initialization function call\\tabularnewline\r\n\\hline\r\nmax & Maximum output value\\tabularnewline\r\n\\hline\r\nmin & Minimum output value\\tabularnewline\r\n\\hline\r\nEnable & Enable == 0: Deactivation of block; Out set to 0\n\nEnable 0->1: Preload of integral part\n\nEnable == 1: Activation of block\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & \\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nKp & Proportional Factor\\tabularnewline\r\n\\hline\r\nKi & Integral Factor\\tabularnewline\r\n\\hline\r\nKd & Derivative Factor\\tabularnewline\r\n\\hline\r\nfc & Cutoff frequency of realization low pass\\tabularnewline\r\n\\hline\r\nts\\_fact & Multiplication factor of base sampling time (in integer format)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nPID Controller with Output Limitation:\n\n    G(s) = Kp + Ki/s + Kd*s/(s/(2*pi*fc) + 1)\r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/PIDLimit_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!3264}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 3264 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PIDLimit\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & PIDLimit\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     int8          *Init;\r\n     int8          *max;\r\n     int8          *min;\r\n     int8          *Enable;\r\n     int8          Out;\r\n     int8          b0;\r\n     int8          b1;\r\n     int8          b0d;\r\n     int8          b1d;\r\n     int8          a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int8          in_old;\r\n     int16         i_old;\r\n     int8          d_old;\r\n     int8          enable_old;\r\n} PIDLIMIT_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PIDLimit_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!3265}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 3265 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PIDLimit\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & PIDLimit\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     int16         *Init;\r\n     int16         *max;\r\n     int16         *min;\r\n     int8          *Enable;\r\n     int16         Out;\r\n     int16         b0;\r\n     int16         b1;\r\n     int16         b0d;\r\n     int16         b1d;\r\n     int16         a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int16         in_old;\r\n     int32         i_old;\r\n     int16         d_old;\r\n     int8          enable_old;\r\n} PIDLIMIT_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PIDLimit_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!3266}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 3266 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & PIDLimit\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & PIDLimit\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nsfrb0 & Shift factor for PI coefficient b0\\tabularnewline\r\n\\hline\r\nsfrb1 & Shift factor for PI coefficient b1\\tabularnewline\r\n\\hline\r\nsfrd & Shift factor for D coefficients b0d and b1d\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     int32         *Init;\r\n     int32         *max;\r\n     int32         *min;\r\n     int8          *Enable;\r\n     int32         Out;\r\n     int32         b0;\r\n     int32         b1;\r\n     int32         b0d;\r\n     int32         b1d;\r\n     int32         a0d;\r\n     int8          sfrb0;\r\n     int8          sfrb1;\r\n     int8          sfrd;\r\n     int32         in_old;\r\n     int64         i_old;\r\n     int32         d_old;\r\n     int8          enable_old;\r\n} PIDLIMIT_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PIDLimit_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!3267}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 3267 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PIDLimit\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & PIDLimit\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *In;\r\n     float32       *Init;\r\n     float32       *max;\r\n     float32       *min;\r\n     int8          *Enable;\r\n     float32       Out;\r\n     float32       b0;\r\n     float32       b1;\r\n     float32       b0d;\r\n     float32       b1d;\r\n     float32       a0d;\r\n     float32       in_old;\r\n     float32       i_old;\r\n     float32       d_old;\r\n     int8          enable_old;\r\n} PIDLIMIT_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PIDLimit_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!3268}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 3268 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PIDLimit\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & PIDLimit\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nb1 & Proportional coefficient\\tabularnewline\r\n\\hline\r\nb0d & Derivational coefficient b0\\tabularnewline\r\n\\hline\r\nb1d & Derivational coefficient b1\\tabularnewline\r\n\\hline\r\na0d & Derivational coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & Input value of previous cycle\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value of previous cycle\\tabularnewline\r\n\\hline\r\nd\\_old & Derivative value of previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *In;\r\n     float64       *Init;\r\n     float64       *max;\r\n     float64       *min;\r\n     int8          *Enable;\r\n     float64       Out;\r\n     float64       b0;\r\n     float64       b1;\r\n     float64       b0d;\r\n     float64       b1d;\r\n     float64       a0d;\r\n     float64       in_old;\r\n     float64       i_old;\r\n     float64       d_old;\r\n     int8          enable_old;\r\n} PIDLIMIT_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PIDLimit_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "6af0cfc401f5cda2b4814ce1e1458bc55e195f2e", "size": 10976, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Control/Doc/PIDLimit.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Control/Doc/PIDLimit.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Control/Doc/PIDLimit.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7873417722, "max_line_length": 90, "alphanum_fraction": 0.6830357143, "num_tokens": 3322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.44544658975389967}}
{"text": "% Copyright 2017-2019 Jean-Luc Vay, Remi Lehe\n%\n% This file is part of WarpX.\n%\n% License: BSD-3-Clause-LBNL\n\n\\input{newcommands}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Boundary conditions}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Open boundary condition for electromagnetic waves}\n\nFor the TE case, the original Berenger's Perfectly Matched Layer (PML) writes\n\n% PML\n\\begin{eqnarray}\n\\varepsilon _{0}\\frac{\\partial E_{x}}{\\partial t}+\\sigma _{y}E_{x} = & \\frac{\\partial H_{z}}{\\partial y}\\label{PML_def_1} \\\\\n\\varepsilon _{0}\\frac{\\partial E_{y}}{\\partial t}+\\sigma _{x}E_{y} = & -\\frac{\\partial H_{z}}{\\partial x}\\label{PML_def_2} \\\\\n\\mu _{0}\\frac{\\partial H_{zx}}{\\partial t}+\\sigma ^{*}_{x}H_{zx} = & -\\frac{\\partial E_{y}}{\\partial x}\\label{PML_def_3} \\\\\n\\mu _{0}\\frac{\\partial H_{zy}}{\\partial t}+\\sigma ^{*}_{y}H_{zy} = & \\frac{\\partial E_{x}}{\\partial y}\\label{PML_def_4} \\\\\nH_{z}  = & H_{zx}+H_{zy}\\label{PML_def_5}\n\\end{eqnarray}\n\nThis can be generalized to\n\n% APML\n\\begin{eqnarray}\n\\varepsilon _{0}\\frac{\\partial E_{x}}{\\partial t}+\\sigma _{y}E_{x} = & \\frac{c_{y}}{c}\\frac{\\partial H_{z}}{\\partial y}+\\overline{\\sigma }_{y}H_{z}\\label{APML_def_1} \\\\\n\\varepsilon _{0}\\frac{\\partial E_{y}}{\\partial t}+\\sigma _{x}E_{y} = & -\\frac{c_{x}}{c}\\frac{\\partial H_{z}}{\\partial x}+\\overline{\\sigma }_{x}H_{z}\\label{APML_def_2} \\\\\n\\mu _{0}\\frac{\\partial H_{zx}}{\\partial t}+\\sigma ^{*}_{x}H_{zx} = & -\\frac{c^{*}_{x}}{c}\\frac{\\partial E_{y}}{\\partial x}+\\overline{\\sigma }_{x}^{*}E_{y}\\label{APML_def_3} \\\\\n\\mu _{0}\\frac{\\partial H_{zy}}{\\partial t}+\\sigma ^{*}_{y}H_{zy} = & \\frac{c^{*}_{y}}{c}\\frac{\\partial E_{x}}{\\partial y}+\\overline{\\sigma }_{y}^{*}E_{x}\\label{APML_def_4} \\\\\nH_{z} = & H_{zx}+H_{zy}\\label{APML_def_5}\n\\end{eqnarray}\n\nFor $c_{x}=c_{y}=c^{*}_{x}=c^{*}_{y}=c$ and $\\overline{\\sigma }_{x}=\\overline{\\sigma }_{y}=\\overline{\\sigma }_{x}^{*}=\\overline{\\sigma }_{y}^{*}=0$,\nthis system reduces to the Berenger PML medium, while adding the additional\nconstraint $\\sigma _{x}=\\sigma _{y}=\\sigma _{x}^{*}=\\sigma _{y}^{*}=0$\nleads to the system of Maxwell equations in vacuum.\n\n\\subsubsection{\\label{Sec:analytic theory, propa plane wave}Propagation of a Plane Wave in an APML Medium}\n\nWe consider a plane wave of magnitude ($ E_{0},H_{zx0},H_{zy0} $)\nand pulsation $\\omega$ propagating in the APML medium with an\nangle $\\varphi$ relative to the x axis\n\n\\begin{eqnarray}\nE_{x} = & -E_{0}\\sin \\varphi e^{i\\omega \\left( t-\\alpha x-\\beta y\\right) }\\label{Plane_wave_APML_def_1} \\\\\nE_{y} = & E_{0}\\cos \\varphi e^{i\\omega \\left( t-\\alpha x-\\beta y\\right) }\\label{Plane_wave_APML_def_2} \\\\\nH_{zx} = & H_{zx0}e^{i\\omega \\left( t-\\alpha x-\\beta y\\right) }\\label{Plane_wave_AMPL_def_3} \\\\\nH_{zy} = & H_{zy0}e^{i\\omega \\left( t-\\alpha x-\\beta y\\right) }\\label{Plane_wave_APML_def_4}\n\\end{eqnarray}\n\n\nwhere $\\alpha$ and$\\beta$ are two complex constants to\nbe determined.\n\nIntroducing (\\ref{Plane_wave_APML_def_1}), (\\ref{Plane_wave_APML_def_2}),\n(\\ref{Plane_wave_AMPL_def_3}) and (\\ref{Plane_wave_APML_def_4})\ninto (\\ref{APML_def_1}), (\\ref{APML_def_2}), (\\ref{APML_def_3})\nand (\\ref{APML_def_4}) gives\n\n\\begin{eqnarray}\n\\varepsilon _{0}E_{0}\\sin \\varphi -i\\frac{\\sigma _{y}}{\\omega }E_{0}\\sin \\varphi  = & \\beta \\frac{c_{y}}{c}\\left( H_{zx0}+H_{zy0}\\right) +i\\frac{\\overline{\\sigma }_{y}}{\\omega }\\left( H_{zx0}+H_{zy0}\\right) \\label{Plane_wave_APML_1_1} \\\\\n\\varepsilon _{0}E_{0}\\cos \\varphi -i\\frac{\\sigma _{x}}{\\omega }E_{0}\\cos \\varphi  = & \\alpha \\frac{c_{x}}{c}\\left( H_{zx0}+H_{zy0}\\right) -i\\frac{\\overline{\\sigma }_{x}}{\\omega }\\left( H_{zx0}+H_{zy0}\\right) \\label{Plane_wave_APML_1_2} \\\\\n\\mu _{0}H_{zx0}-i\\frac{\\sigma ^{*}_{x}}{\\omega }H_{zx0} = & \\alpha \\frac{c^{*}_{x}}{c}E_{0}\\cos \\varphi -i\\frac{\\overline{\\sigma }^{*}_{x}}{\\omega }E_{0}\\cos \\varphi \\label{Plane_wave_APML_1_3} \\\\\n\\mu _{0}H_{zy0}-i\\frac{\\sigma ^{*}_{y}}{\\omega }H_{zy0} = & \\beta \\frac{c^{*}_{y}}{c}E_{0}\\sin \\varphi +i\\frac{\\overline{\\sigma }^{*}_{y}}{\\omega }E_{0}\\sin \\varphi \\label{Plane_wave_APML_1_4}\n\\end{eqnarray}\n\n\nDefining $Z=E_{0}/\\left( H_{zx0}+H_{zy0}\\right)$ and using (\\ref{Plane_wave_APML_1_1})\nand (\\ref{Plane_wave_APML_1_2}), we get\n\n\\begin{eqnarray}\n\\beta  = & \\left[ Z\\left( \\varepsilon _{0}-i\\frac{\\sigma _{y}}{\\omega }\\right) \\sin \\varphi -i\\frac{\\overline{\\sigma }_{y}}{\\omega }\\right] \\frac{c}{c_{y}}\\label{Plane_wave_APML_beta_of_g} \\\\\n\\alpha  = & \\left[ Z\\left( \\varepsilon _{0}-i\\frac{\\sigma _{x}}{\\omega }\\right) \\cos \\varphi +i\\frac{\\overline{\\sigma }_{x}}{\\omega }\\right] \\frac{c}{c_{x}}\\label{Plane_wave_APML_alpha_of_g}\n\\end{eqnarray}\n\n\nAdding $H_{zx0}$ and $H_{zy0}$ from (\\ref{Plane_wave_APML_1_3})\nand (\\ref{Plane_wave_APML_1_4}) and substituting the expressions\nfor $\\alpha$ and $\\beta$ from (\\ref{Plane_wave_APML_beta_of_g})\nand (\\ref{Plane_wave_APML_alpha_of_g}) yields\n\n\\begin{eqnarray}\n\\frac{1}{Z} = & \\frac{Z\\left( \\varepsilon _{0}-i\\frac{\\sigma _{x}}{\\omega }\\right) \\cos \\varphi \\frac{c^{*}_{x}}{c_{x}}+i\\frac{\\overline{\\sigma }_{x}}{\\omega }\\frac{c^{*}_{x}}{c_{x}}-i\\frac{\\overline{\\sigma }^{*}_{x}}{\\omega }}{\\mu _{0}-i\\frac{\\sigma ^{*}_{x}}{\\omega }}\\cos \\varphi \\nonumber \\\\\n + & \\frac{Z\\left( \\varepsilon _{0}-i\\frac{\\sigma _{y}}{\\omega }\\right) \\sin \\varphi \\frac{c^{*}_{y}}{c_{y}}-i\\frac{\\overline{\\sigma }_{y}}{\\omega }\\frac{c^{*}_{y}}{c_{y}}+i\\frac{\\overline{\\sigma }^{*}_{y}}{\\omega }}{\\mu _{0}-i\\frac{\\sigma ^{*}_{y}}{\\omega }}\\sin \\varphi\n\\end{eqnarray}\n\n\nIf $c_{x}=c^{*}_{x}$, $c_{y}=c^{*}_{y}$, $\\overline{\\sigma }_{x}=\\overline{\\sigma }^{*}_{x}$, $\\overline{\\sigma }_{y}=\\overline{\\sigma }^{*}_{y}$, $\\frac{\\sigma _{x}}{\\varepsilon _{0}}=\\frac{\\sigma ^{*}_{x}}{\\mu _{0}}$ and $\\frac{\\sigma _{y}}{\\varepsilon _{0}}=\\frac{\\sigma ^{*}_{y}}{\\mu _{0}}$ then\n\n\\begin{eqnarray}\nZ = & \\pm \\sqrt{\\frac{\\mu _{0}}{\\varepsilon _{0}}}\\label{APML_impedance}\n\\end{eqnarray}\n\n\nwhich is the impedance of vacuum. Hence, like the PML, given some\nrestrictions on the parameters, the APML does not generate any reflection\nat any angle and any frequency. As for the PML, this property is not\nretained after discretization, as shown subsequently in this paper.\n\nCalling $\\psi$ any component of the field and $\\psi _{0}$\nits magnitude, we get from (\\ref{Plane_wave_APML_def_1}), (\\ref{Plane_wave_APML_beta_of_g}),\n(\\ref{Plane_wave_APML_alpha_of_g}) and (\\ref{APML_impedance}) that\n\n\\begin{equation}\n\\label{Plane_wave_absorption}\n\\psi =\\psi _{0}e^{i\\omega \\left( t\\mp x\\cos \\varphi /c_{x}\\mp y\\sin \\varphi /c_{y}\\right) }e^{-\\left( \\pm \\frac{\\sigma _{x}\\cos \\varphi }{\\varepsilon _{0}c_{x}}+\\overline{\\sigma }_{x}\\frac{c}{c_{x}}\\right) x}e^{-\\left( \\pm \\frac{\\sigma _{y}\\sin \\varphi }{\\varepsilon _{0}c_{y}}+\\overline{\\sigma }_{y}\\frac{c}{c_{y}}\\right) y}\n\\end{equation}\n\n\nWe assume that we have an APML layer of thickness $\\delta$ (measured\nalong $x$) and that $\\sigma _{y}=\\overline{\\sigma }_{y}=0$\nand $c_{y}=c.$ Using (\\ref{Plane_wave_absorption}), we determine\nthat the coefficient of reflection given by this layer is\n\n\\begin{eqnarray}\nR_{APML}\\left( \\theta \\right)  = & e^{-\\left( \\sigma _{x}\\cos \\varphi /\\varepsilon _{0}c_{x}+\\overline{\\sigma }_{x}c/c_{x}\\right) \\delta }e^{-\\left( \\sigma _{x}\\cos \\varphi /\\varepsilon _{0}c_{x}-\\overline{\\sigma }_{x}c/c_{x}\\right) \\delta }\\nonumber \\\\\n = & e^{-2\\left( \\sigma _{x}\\cos \\varphi /\\varepsilon _{0}c_{x}\\right) \\delta }\n\\end{eqnarray}\n\n\nwhich happens to be the same as the PML theoretical coefficient of\nreflection if we assume $c_{x}=c$. Hence, it follows that for\nthe purpose of wave absorption, the term $\\overline{\\sigma }_{x}$\nseems to be of no interest. However, although this conclusion is true\nat the infinitesimal limit, it does not hold for the discretized counterpart.\n\n\\subsubsection{Discretization}\n\n%\n\\begin{subequations}\n\\begin{align}\n\\frac{E_x|^{n+1}_{j+1/2,k,l}-E_x|^{n}_{j+1/2,k,l}}{\\Delta t} + \\sigma_y \\frac{E_x|^{n+1}_{j+1/2,k,l}+E_x|^{n}_{j+1/2,k,l}}{2} = & \\frac{H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}}{\\Delta y} \\\\\n%\n\\frac{E_y|^{n+1}_{j,k+1/2,l}-E_y|^{n}_{j,k+1/2,l}}{\\Delta t} + \\sigma_x \\frac{E_y|^{n+1}_{j,k+1/2,l}+E_y|^{n}_{j,k+1/2,l}}{2} = & - \\frac{H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}}{\\Delta x} \\\\\n%\n\\frac{H_{zx}|^{n+3/2}_{j+1/2,k+1/2,l}-H_{zx}|^{n}_{j+1/2,k+1/2,l}}{\\Delta t} + \\sigma^*_x \\frac{H_{zx}|^{n+3/2}_{j+1/2,k+1/2,l}+H_{zx}|^{n}_{j+1/2,k+1/2,l}}{2} = & - \\frac{E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}}{\\Delta x} \\\\\n%\n\\frac{H_{zy}|^{n+3/2}_{j+1/2,k+1/2,l}-H_{zy}|^{n}_{j+1/2,k+1/2,l}}{\\Delta t} + \\sigma^*_y \\frac{H_{zy}|^{n+3/2}_{j+1/2,k+1/2,l}+H_{zy}|^{n}_{j+1/2,k+1/2,l}}{2} = & \\frac{E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}}{\\Delta y} \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n\n%\n\\begin{subequations}\n\\begin{align}\nE_x|^{n+1}_{j+1/2,k,l} = & \\left(\\frac{1-\\sigma_y \\Delta t/2}{1+\\sigma_y \\Delta t/2}\\right) E_x|^{n}_{j+1/2,k,l} + \\frac{\\Delta t/\\Delta y}{1+\\sigma_y \\Delta t/2} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}\\right) \\\\\n%\nE_y|^{n+1}_{j,k+1/2,l} = & \\left(\\frac{1-\\sigma_x \\Delta t/2}{1+\\sigma_x \\Delta t/2}\\right) E_y|^{n}_{j,k+1/2,l} - \\frac{\\Delta t/\\Delta x}{1+\\sigma_x \\Delta t/2} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}\\right) \\\\\n%\nH_{zx}|^{n+3/2}_{j+1/2,k+1/2,l} = & \\left(\\frac{1-\\sigma^*_x \\Delta t/2}{1+\\sigma^*_x \\Delta t/2}\\right) H_{zx}|^{n}_{j+1/2,k+1/2,l} - \\frac{\\Delta t/\\Delta x}{1+\\sigma^*_x \\Delta t/2} \\left(E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}\\right) \\\\\n%\nH_{zy}|^{n+3/2}_{j+1/2,k+1/2,l} = & \\left(\\frac{1-\\sigma^*_y \\Delta t/2}{1+\\sigma^*_y \\Delta t/2}\\right) H_{zy}|^{n}_{j+1/2,k+1/2,l} + \\frac{\\Delta t/\\Delta y}{1+\\sigma^*_y \\Delta t/2} \\left(E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}\\right) \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n\n%\n\\begin{subequations}\n\\begin{align}\nE_x|^{n+1}_{j+1/2,k,l} = & e^{-\\sigma_y\\Delta t} E_x|^{n}_{j+1/2,k,l} + \\frac{1-e^{-\\sigma_y\\Delta t}}{\\sigma_y \\Delta y} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}\\right) \\\\\n%\nE_y|^{n+1}_{j,k+1/2,l} = & e^{-\\sigma_x\\Delta t} E_y|^{n}_{j,k+1/2,l} - \\frac{1-e^{-\\sigma_x\\Delta t}}{\\sigma_x \\Delta x} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}\\right) \\\\\n%\nH_{zx}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_x\\Delta t} H_{zx}|^{n}_{j+1/2,k+1/2,l} - \\frac{1-e^{-\\sigma^*_x\\Delta t}}{\\sigma^*_x \\Delta x} \\left(E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}\\right) \\\\\n%\nH_{zy}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_y\\Delta t} H_{zy}|^{n}_{j+1/2,k+1/2,l} + \\frac{1-e^{-\\sigma^*_y\\Delta t}}{\\sigma^*_y \\Delta y} \\left(E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}\\right) \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n\n\n%\n\\begin{subequations}\n\\begin{align}\nE_x|^{n+1}_{j+1/2,k,l} = & e^{-\\sigma_y\\Delta t} E_x|^{n}_{j+1/2,k,l} + \\frac{1-e^{-\\sigma_y\\Delta t}}{\\sigma_y \\Delta y}\\frac{c_y}{c} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}\\right) \\\\\n%\nE_y|^{n+1}_{j,k+1/2,l} = & e^{-\\sigma_x\\Delta t} E_y|^{n}_{j,k+1/2,l} - \\frac{1-e^{-\\sigma_x\\Delta t}}{\\sigma_x \\Delta x}\\frac{c_x}{c} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}\\right) \\\\\n%\nH_{zx}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_x\\Delta t} H_{zx}|^{n}_{j+1/2,k+1/2,l} - \\frac{1-e^{-\\sigma^*_x\\Delta t}}{\\sigma^*_x \\Delta x}\\frac{c^*_x}{c} \\left(E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}\\right) \\\\\n%\nH_{zy}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_y\\Delta t} H_{zy}|^{n}_{j+1/2,k+1/2,l} + \\frac{1-e^{-\\sigma^*_y\\Delta t}}{\\sigma^*_y \\Delta y}\\frac{c^*_y}{c} \\left(E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}\\right) \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n\n %\n\\begin{subequations}\n\\begin{align}\nc_x = & c e^{-\\sigma_x\\Delta t} \\frac{\\sigma_x \\Delta x}{1-e^{-\\sigma_x\\Delta t}} \\\\\nc_y = & c e^{-\\sigma_y\\Delta t} \\frac{\\sigma_y \\Delta y}{1-e^{-\\sigma_y\\Delta t}} \\\\\nc^*_x = & c e^{-\\sigma^*_x\\Delta t} \\frac{\\sigma^*_x \\Delta x}{1-e^{-\\sigma^*_x\\Delta t}} \\\\\nc^*_y = & c e^{-\\sigma^*_y\\Delta t} \\frac{\\sigma^*_y \\Delta y}{1-e^{-\\sigma^*_y\\Delta t}}\n\\end{align}\n\\end{subequations}\n\n%\n\\begin{subequations}\n\\begin{align}\nE_x|^{n+1}_{j+1/2,k,l} = & e^{-\\sigma_y\\Delta t} \\left[ E_x|^{n}_{j+1/2,k,l} + \\frac{\\Delta t}{\\Delta y} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}\\right) \\right] \\\\\n%\nE_y|^{n+1}_{j,k+1/2,l} = & e^{-\\sigma_x\\Delta t} \\left[ E_y|^{n}_{j,k+1/2,l} - \\frac{\\Delta t}{\\Delta x}  \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}\\right) \\right] \\\\\n%\nH_{zx}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_x\\Delta t} \\left[ H_{zx}|^{n}_{j+1/2,k+1/2,l} - \\frac{\\Delta t}{\\Delta x}  \\left(E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}\\right) \\right] \\\\\n%\nH_{zy}|^{n+3/2}_{j+1/2,k+1/2,l} = & e^{-\\sigma^*_y\\Delta t} \\left[ H_{zy}|^{n}_{j+1/2,k+1/2,l} + \\frac{\\Delta t}{\\Delta y}  \\left(E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}\\right) \\right] \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n\n%\n\\begin{subequations}\n\\begin{align}\nE_x|^{n+1}_{j+1/2,k,l} = & E_x|^{n}_{j+1/2,k,l} + \\frac{\\Delta t}{\\Delta y} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j+1/2,k-1/2,l}\\right) \\\\\n%\nE_y|^{n+1}_{j,k+1/2,l} = & E_y|^{n}_{j,k+1/2,l} - \\frac{\\Delta t}{\\Delta x} \\left(H_z|^{n+1/2}_{j+1/2,k+1/2,l}-H_z|^{n+1/2}_{j-1/2,k+1/2,l}\\right) \\\\\n%\nH_{zx}|^{n+3/2}_{j+1/2,k+1/2,l} = & H_{zx}|^{n}_{j+1/2,k+1/2,l} - \\frac{\\Delta t}{\\Delta x} \\left(E_y|^{n+1}_{j+1,k+1/2,l}-E_y|^{n+1}_{j,k+1/2,l}\\right) \\\\\n%\nH_{zy}|^{n+3/2}_{j+1/2,k+1/2,l} = & H_{zy}|^{n}_{j+1/2,k+1/2,l} + \\frac{\\Delta t}{\\Delta y} \\left(E_x|^{n+1}_{j+1/2,k+1,l}-E_x|^{n+1}_{j+1/2,k,l}\\right) \\\\\n%\nH_z = & H_{zx}+H_{zy}\n\\end{align}\n\\end{subequations}\n", "meta": {"hexsha": "205c9d099ab2e5845ba48f0d67a423fcdfbe3b90", "size": 13618, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/source/latex_theory/PML/PML.tex", "max_stars_repo_name": "mrowan137/amrex", "max_stars_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 131, "max_stars_repo_stars_event_min_datetime": "2018-09-29T08:11:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T23:24:22.000Z", "max_issues_repo_path": "Docs/source/latex_theory/PML/PML.tex", "max_issues_repo_name": "mrowan137/amrex", "max_issues_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 1656, "max_issues_repo_issues_event_min_datetime": "2018-10-02T01:49:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:27:31.000Z", "max_forks_repo_path": "Docs/source/latex_theory/PML/PML.tex", "max_forks_repo_name": "mrowan137/amrex", "max_forks_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 100, "max_forks_repo_forks_event_min_datetime": "2018-10-01T20:41:14.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T10:30:42.000Z", "avg_line_length": 58.4463519313, "max_line_length": 325, "alphanum_fraction": 0.6017770598, "num_tokens": 6262, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.44532234194113923}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage{geometry}\n \\geometry{\n a4paper,\n total={170mm,257mm},\n left=20mm,\n top=20mm,\n }\n\n\n \\usepackage{amsmath}\n \\usepackage{siunitx}\n \\usepackage{multirow}\n\\usepackage{colortbl}\n \\usepackage{hhline}\n\n \\usepackage{lipsum}  %%% Lorem ipsum\n\n\\setlength{\\headheight}{30.0pt}\n\\setlength{\\footskip}{20pt}\n\n\n\\usepackage{hyperref}\n\\hypersetup{\n    colorlinks=True,\n    linkcolor={blue!20!black},\n    filecolor=magenta,      \n    urlcolor=cyan,\n}\n\n\n\n \\usepackage[export]{adjustbox}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{fancyhdr}\n\\usepackage{multicol}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{\\textit{Pul074BEX004}}\n\\lhead{\\textit{Amrit Prasad Phuyal}}\n\\rfoot{\\thepage}\n\n\n\\usepackage{mathpazo} % Palatino font\n\\usepackage{graphicx}\n\\usepackage{float}\n\n\n\\input{./CoverPage.tex} %%% cover page\n\\include{./Matlab.tex} %%% Matlab code\n\n\n\n%%%%%%%%%%%%%%%%%%%%%% for matlab observation #1 fig name #2 Caption\n\\newcommand{\\mobs}[2]{\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.9\\linewidth]{./FIG/#1.eps}\n        \\caption{#2}\n    \\end{figure}\n   \n}\n\n\n\n\n\n\n\n\\begin{document}\n\n\n%%%%  COver page \n\\CP{Communication System II}{Lab \\#1}{Amplitude Modulation \\& Demodulation}\n{Suman Sharma}\n%%%%%%%%%%%%%%%%%%%%\n\n\\pagenumbering{gobble}\n\\renewcommand{\\contentsname}{Table of Contents}\n\\tableofcontents\n\n% \\pagebreak\n%\\listoffigures\n\\pagebreak\n% \\listoftables\n% \\vspace{5em}\n\\lstlistoflistings\n%\\pagebreak\n\\vspace{10em}\n\\listoffigures\n\\pagebreak\n\\pagenumbering{arabic}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Title} {\\large Amplitude Modulation \\& Demodulation}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Objective}\n\\begin{itemize}\n    \\item To view amplitude modulation for DSB­-TC, DSB­-SC, SSB  and Amplitude demodulation.\n\n\\end{itemize}\n%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Theory}\n\\subsection{Amplitude modulaton}\nIf amplitude of carrier wave varies in accordance with the amplitude of the signal, then the signal is called amplitude modulation.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{./FIG/amplmod.png}\n    \\caption{Amplitude modulation}\n\\end{figure}\n\n\\subsubsection{DSB-­TC}\nDouble Sideband Transmitted carrier (DSB-TC) is a type of amplitude modulation where modulated signal has full carrier representation.For DSB-FC modulated signal $y(t)$ of a message signal $m(t)$ having carrier signal of frequency $f_c$ :\n\n\\begin{equation}\n    y(t) = (1 + \\mu m(t))cos(2\\pi f_c t)\n\\end{equation}\nwhere, $\\mu$ is the \\textbf{modulation index}.\n\\begin{itemize}\n    \\centering\n    \\item $\\mu < 1$: Under modulation\n    \\item $\\mu = 1$: Perfect modulation\n    \\item $\\mu > 1$: Over modulation\n\\end{itemize}\n\n\n\\subsubsection{DSB­-SC}\nDouble Sideband-Suppressed Carrier (DSB-SC) is a type of amplitude modulation where modulated signal has reduced carrier representation in order to save power. For DSB-SC modulated signal $y(t)$ of a message signal $m(t)$ having carrier signal of frequency $f_c$ :\n\n\n\\begin{equation}\n    y(t) = A_c m(t)cos(2\\pi f_c t)\n\\end{equation}\n\n\\subsubsection{SSB}\nSingle Sideband is a type of amplitude modulation where modulated signal has reduced carrier representation in order to save power and additionally Suppressing one of the side band.. For SSB modulated signal $y(t)$ of a message signal $m(t)$ having carrier signal of frequency $f_c$ :\n\n\n\\begin{equation}\n    y(t) = m(t)cos(2\\pi f_c t) - \\hat{m}(t)sin(2\\pi f_c t)\n\\end{equation}\nwhere $\\hat{m}(t)$ is the \\textbf{Hilbert transform} of the message signal.\n\n\\subsection{Amplitude Demodulation}\nAmplitude Demodulation is the process of demodulating the received signal to recover the original message.\n\n\\section{Problems}\n%%%%%%%%111111111111111111111111\n\\subsection{DSB-TC(Under,Normal,Over)}\n\n\\MAT{./CODES/amdsbtc.m}{MATLAB code DSB-TC}\n\\mobs{dsbtc}{DSB-TC(Under,Normal,Over)}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%22222222222222222222222222\n\\subsection{DSB-SC (Time \\& Frequency Domain)}\n\\MAT{./CODES/amdsbsc.m}{MATLAB code DSB-SC}\n\\mobs{dsbsc}{DSB-SC (Time \\& Frequency Domain)}\n\n\n\\pagebreak\n%%%%%%%%%%%%%%%%%%%33333333333333333333333333\n\\subsection{SSB (Time \\& Frequency Domain)}\n\n\\MAT{./CODES/amssb.m}{MATLAB code SSB}\n\\mobs{ssb}{SSB (Time \\& Frequency Domain)}\n%%%%%%%%%%%%%%%%%%%44444444444444444444444\n\n\\pagebreak\n\\subsection{Demodulation}\n\\MAT{./CODES/demodulation.m}{MATLAB code Demodulation}\n\\mobs{demod}{Demodulation Observation of DSB-SC}\n\n\\section{Discussion and Conclusion}\nIn this lab we observed amplitude modulation of DSB-TC, DSB-SC, SSB and Demodulation of DSB-SC signal.We used MATLAB an its modules to implement the above mentioned process and generating plots.\n\n\\end{document}", "meta": {"hexsha": "96f9293fa09be6f4c9cc4bb92bba15959cb9de1f", "size": 4685, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Communication System II/LAB 1/Comm sys II LAB 1 Amrit Prasad Phuyal.tex", "max_stars_repo_name": "amritphuyal/LATEX", "max_stars_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-01T08:20:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-01T08:20:34.000Z", "max_issues_repo_path": "Communication System II/LAB 1/Comm sys II LAB 1 Amrit Prasad Phuyal.tex", "max_issues_repo_name": "amritphuyal/LATEX", "max_issues_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Communication System II/LAB 1/Comm sys II LAB 1 Amrit Prasad Phuyal.tex", "max_forks_repo_name": "amritphuyal/LATEX", "max_forks_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-19T09:04:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T12:19:26.000Z", "avg_line_length": 26.0277777778, "max_line_length": 284, "alphanum_fraction": 0.7048025614, "num_tokens": 1411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.4451932809023989}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\n\\onlyinsubfile{\n\\title{NeuroData SIMPLEX Report: Subfile}\n}\n\n\\begin{document}\n\\onlyinsubfile{\n\\maketitle\n\\thispagestyle{empty}\n\nThe following report documents the progress made by the labs of Randal~Burns and Joshua~T.~Vogelstein at Johns Hopkins University towards goals set by the DARPA SIMPLEX grant.\n\n%%%% Table of Contents\n\\tableofcontents\n\n%%%% Publications\n\\bibliographystyle{IEEEtran}\n\\begin{spacing}{0.5}\n\\section*{Publications, Presentations, and Talks}\n%\\vspace{-20pt}\n\\nocite{*}\n{\\footnotesize\t\\bibliography{simplex}}\n\\end{spacing}\n%%%% End Publications\n}\n\n\\subsection{Multiscale Generalized Correlation (MGC)}\n\nMGC is the optimal local correlation between two datasets  $X$ and $Y$.\nFor any given global correlation (Pearson’s, rank, Mantel, distance\ncorrelation, etc.), their respective local correlations can be\nefficiently computed.  By choosing the optimal local correlation based\non maximizing testing powers, the Oracle MGC dominates the global\ncorrelation.\n\nWe demonstrate that Oracle MGC is a consistent test statistic (power\nconverge to 1 as sample size increases) under standard regularity\nconditions, is equivalently to the global correlation under linear\ndependency (i.e., each observation $X_i$ is a linear transformation of\n$Y_i$), and can be strictly better than the global correlation under\ncommon nonlinear dependencies. Thus Oracle MGC dominates the global\ncorrelation, and the sample MGC (i.e., choose the optimal scale by\np-value map approximation, as the testing power are not available in the\nabsence of the true model and training data) also empirically dominates\nthe global correlation.\n\nNumerically, we showed that both Oracle and sample MGC significantly\nimprove over the global correlation and other existing state-of-the-art\nmethods for the dependence test. Moreover, the optimal scale helps\ndiscovering the nature of the dependency, i.e., the global scale is\nclose to optimal in the power / p-value map if and only if the\nunderlying dependency is close to linear.\n\n\nOn real data, MGC helps identify useful relationships between brain\nactivity vs personality, brain hippocampus vs major depressive disorder,\nwhich was confirmed by domain experts but not detected on raw data by\nexisting statistical methods. \n\n\\subsubsection{Testing Node Contribution via (MGC)} We continue the\ndevelopment of the Multiscale Generalized Correlation toolbox, to handle\nthe node contribution task within the MGC testing framework. \n\nMGC is the optimal local correlation between two datasets $X$ and $Y$.\nFor any given global correlation (Pearson’s, rank, Mantel, distance\ncorrelation, etc.), their respective local correlations can be\nefficiently computed. By choosing the optimal local correlation based on\nmaximizing testing powers, the Oracle MGC is a consistent test statistic\nthat dominates the global correlation.\n\nAn important question useful for subsampling and outlier detection, is\nhow important is each sample observation, regarding their relative\ncontribution to the underlying dependency. If this question can be\nsuccessfully and efficiently answered, those important samples can be\nkept for later inference, while less important samples may be treated as\noutliers. \n\nBy decomposing the optimal local correlation $C*$ into each sample\npoint, the MGC computation readily offers a weight statistic $w_i$ for\neach pair of observations $(X_i,Y_i)$ where $\\sum_i{w_i} = C*$.  Then\neach sample can be ranked based on $W_i$.  This is a very efficient\nalgorithm, since computing the MGC statistic for all data automatically\nyields $w_i$ for all sample pairs.\n\n\\begin{figure}[h!]\n\\begin{cframed}\n\\centering\n\\includegraphics[width=0.95\\textwidth]{./figs/mgcPow.png}\n\\caption{\nThis figure considers a mixture model in the graph domain,\nwhere half the nodes are dependent to their attributes, and the other\nhalf nodes are independently generated from the attributes. We calculate\nthe MGC statistic and its power for dependence testing, as well as the\nnode contribution statistic and its power, i.e., the percentage of all\ndependent nodes that are ranked among the first half by $w_i$.  Indeed,\nthe power plot not only shows that our node contribution algorithm can\nsuccessfully identifies all important nodes at mildly large sample size,\nbut also hints a tight relationship between $w_i$ and $C*$ that is\nworthy of further investigation. \n}\n\\label{fig:mgcP}\n\\end{cframed}\n\\end{figure}\n\n\n\\subsection{Synaptome Statistics}\n\nWe have continued to examine the Kristina15 synaptome dataset and have\nnow added the Weiler Chessboard dataset to our explorations.  Using \n\\verb+meda+, and other methods along the way, we have started to compare\nthe structure of these two datasets, see figure~\\ref{fig:synClaw}.  \n\n\\begin{figure}[h!]\n\\begin{cframed}\n\\centering\n\\includegraphics[width=\\textwidth]{./figs/2dProjClaw.pdf}\n\\caption{\n  Principal Component Analysis (PCA) has been run on the correlation\n  matrices of both of these dataset respectively.  The first two\n  principal components are plotted against each other.  The colors\n  correspond to the type of marker, (``excitatory'' -- green,\n  ``inhibitory'' -- red, ``other'' -- blue).  Notice that some markers are\n  different between datasets, but there is a similar \"claw\" structure\n  present. \n}\n\\label{fig:synClaw}\n\\end{cframed}\n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "9b55bab45bb04050a87e0c4301f77099c08569e6", "size": 5458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2016-12Q4/MGC.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2016-12Q4/MGC.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2016-12Q4/MGC.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.7313432836, "max_line_length": 175, "alphanum_fraction": 0.7933308904, "num_tokens": 1287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.4451932739277363}}
{"text": "\\documentclass[a4paper,12pt]{article}\n%\\documentclass[a4paper,12pt]{scrartcl}\n\n\\usepackage{xltxtra}\n\n\\input{../preamble.tex}\n\n% \\usepackage[spanish]{babel}\n\n% \\setromanfont[Mapping=tex-text]{Linux Libertine O}\n% \\setsansfont[Mapping=tex-text]{DejaVu Sans}\n% \\setmonofont[Mapping=tex-text]{DejaVu Sans Mono}\n\n\\title{Homework \\#15}\n\\author{Isaac Ayala Lozano}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\begin{enumerate}\n \\item Explain why $G_{xx}(f)$ is a constant for Example 6.3 in \\cite{bendat2011random}.\n\n The function $G_{xx}(f)$ is a constant for the example because $G_{xx}(f)$ is the autospectral density function of the input.\n This function is defined as\n\n \\begin{equation*}\n  G_{xx} = 2 S_{xx}(f)\n \\end{equation*}\n\n Recall that\n\n\\begin{equation*}\n S_{xx}(f) = 2 \\int_0^\\infty R_{xx}(\\tau) \\cos(2 \\pi f \\tau ) d\\tau\n\\end{equation*}\n\n As such, $G_{xx}$ becomes\n\n \\begin{equation*}\n  G_{xx} = 4 \\int_0^\\infty R_{xx}(\\tau) \\cos(2 \\pi f \\tau ) d\\tau\n \\end{equation*}\n\n\n And $R_{xx}$ is defined as\n\n\\begin{equation*}\n R_{xx}(\\tau) = E[x_k(t) x_k(t+\\tau)]\n\\end{equation*}\n\nThe expected value of the input, white noise, is a constant $\\mu$ that depends on the samples. Thus, $G_{xx}$ is a constant because the Fourier transformation of the original input results in a constant as well.\n\n\\newpage\n\n\\item Explain how the output spectral function $G_{yy}$ for Example 6.3 results in the output autocorrelation function $R_{yy}$ shown below.\n\n\\begin{align*}\n G_{yy}(f) &= \\abs{H(f)}_{f-d}^2 G = \\frac{G}{\\abs{1-(f/f_n)^2}^2 + (2 \\zeta f/f_n)^2 } \\quad 0 \\leq f < \\infty \\\\\n R_{yy}(\\tau) &= \\frac{G \\pi f_n \\exp(-2\\pi f_n \\zeta \\abs{\\tau})}{4 \\zeta} F(\\tau, \\zeta) \\\\\n F(\\tau, \\zeta) &=\n  \\cos(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau})\n +\n \\frac{\\zeta}{\\sqrt{1-\\zeta^2}}\n \\sin(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau})\n\\end{align*}\n\nRecall that the the autocorrelation function can be expressed as\n\n\\begin{equation*}\n R_{yy}(\\tau) = \\int_0^\\infty G_{yy} (f) \\cos(2 \\pi f \\tau) df\n\\end{equation*}\n\nSubstituting known values in the expression\n\n\\begin{align*}\n R_{yy}(\\tau) &= \\int_0^\\infty \\abs{H(f)}_{f-d}^2 G \\cos(2 \\pi f \\tau) df \\\\\n &= G \\int_0^\\infty \\abs{H(f)}_{f-d}^2 \\cos(2 \\pi f \\tau) df \\\\\n &= G \\int_0^\\infty\n \\frac{\\cos(2 \\pi f \\tau)  }{\\abs{1-(f/f_n)^2}^2 + (2 \\zeta f/f_n)^2 }\n df\n\\end{align*}\n\nSolving the integral, we obtain the following\n\n\\begin{align*}\n R_{yy}(\\tau) &= \\frac{G \\pi f_n \\exp(-2\\pi f_n \\zeta \\abs{\\tau})}{4 \\zeta}\n \\cos(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau}) \\\\\n & \\qquad + \\frac{G \\pi f_n \\exp(-2\\pi f_n \\zeta \\abs{\\tau})}{4 \\zeta}\n \\frac{\\zeta}{\\sqrt{1-\\zeta^2}}\n \\sin(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau})\n\\end{align*}\n\nwhich can then be factorized to\n\n\\begin{align*}\n  R_{yy}(\\tau) &= \\frac{G \\pi f_n \\exp(-2\\pi f_n \\zeta \\abs{\\tau})}{4 \\zeta} F(\\tau, \\zeta) \\\\\n F(\\tau, \\zeta) &=\n  \\cos(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau})\n +\n \\frac{\\zeta}{\\sqrt{1-\\zeta^2}}\n \\sin(2 \\pi f_n \\sqrt{1-\\zeta^2} \\abs{\\tau})\n\\end{align*}\n\n\\newpage\n\n\\item Present plots for both $G_{yy}$ and $R_{yy}$\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw15_comparison.tex}\n\\caption{Comparison.}\n\\label{fig: comparison}\n\\end{figure}\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw15_Gyy.tex}\n\\caption{Output Spectral function.}\n\\label{fig: gyy}\n\\end{figure}\n\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw15_Ryy.tex}\n\\caption{Output Autocorrelation function.}\n\\label{fig: ryy}\n\\end{figure}\n\n\\end{enumerate}\n\n\n\\newpage\n\\pagebreak\n\n\\printbibliography\n\n\\newpage\n\\pagebreak\n\\appendix\n\\section{Octave Code}\n\\lstinputlisting[language=Matlab]{hw15_plots.m}\n\n\\end{document}\n", "meta": {"hexsha": "6bb5c2df41e3e35b53f64aed9b5282fd52b9ff51", "size": 3582, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw15_IsaacAyala.tex", "max_stars_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_stars_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw15_IsaacAyala.tex", "max_issues_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_issues_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw15_IsaacAyala.tex", "max_forks_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_forks_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.875, "max_line_length": 211, "alphanum_fraction": 0.6532663317, "num_tokens": 1408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.44508998699074803}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% =================================================================================================\n% create checkpoint file\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   import cdblib\n   checkpoint_file = 'tests/semantic/output/dRabcd.json'\n   cdblib.create (checkpoint_file)\n   checkpoint = []\n\\end{cadabra}\n\\egroup\n\n% =================================================================================================\n\\section*{Symmetrised partial derivatives of the Riemann tensor}\n\nHere we compute the symmetrised partial derivatoves $R^{a}{}_{(b{\\Dot c}d,\\ue)}$ in terms of\nthe symmetrised covariant derivatives $R^{a}{}_{(b{\\Dot c}d;\\ue)}$. Note that the dot over an\nindex indicates that that index does not take part in the symmetrisation.\n\nWe will use the algorithm described in section (10.3) of my lcb09-03 paper. Here we will make\none small change of notation -- the symbol $D^a$ will replaced with $A^a$.\n\nWe have lots of space (and no annoying editors to appease with brevity) so I will take the\nliberty to expand slightly on what I wrote in the lcb0-03 paper.\n\nOur starting point is the simple identity\n\\begin{align}\n   \\label{eqn:submain}\n   \\left( R^{a}{}_{cdb} B^{b}{}_{a} A^{c} A^{d} \\right)_{;e} A^{e}\n   =\n   \\left( R^{a}{}_{cdb} B^{b}{}_{a} A^{c} A^{d} \\right)_{,e} A^{e}\n\\end{align}\nThis is true in all frames since the quantity inside the brackets is a scalar. We are free to\nmake any choice we like for $A^{a}$ and $B^{a}{}_{b}$ so let's choose $A^{a}$ to be the tangent\nvector to any geodesic through the origin and choose the $B^{a}{}_{b}$ to be constants (i.e,\nall partial derivatives are zero). We will also use local Riemann normal coordinates and as a\nconsequence, the $A^{a}$ will also be constant along the integral curves of $A$ (the geodesics\nin an RNC are always of the form $x^{a}(s) = s A^{a}$ for some affine parameter $s$ on the\ngeodesic). Let $df/ds$ be the directional derivative of the function $f$ along the geodesics\ndefined by $A^{a}$ and assume that $s$ is the proper length along the geodesic (although any\naffine parameter would be sufficient).\n\nThus at the origin we have, by choice,\n\\begin{gather*}\n   0 = B^{a}{}_{b,c} = B^{a}{}_{b,cd} = B^{a}{}_{b,cde} = \\dots\\\\[5pt]\n   0 = dA^{a}/ds = d^2A^{a}/ds^2 = d^3A^{a}/ds^3 = \\dots\\\\[5pt]\n   0 = A^{a}{}_{,b} A^{b} = \\left(A^{a}{}_{,b} A^{b}\\right)_{,c} A^{c} = \\left(\\left(A^{a}{}_{,b} A^{b}\\right)_{,c} A^{c}\\right)_{,d} A^{d}\\\\[5pt]\n   0 = A^{a}{}_{;b} A^{b} = \\left(A^{a}{}_{;b} A^{b}\\right)_{;c} A^{c} = \\left(\\left(A^{a}{}_{;b} A^{b}\\right)_{;c} A^{c}\\right)_{;d} A^{d}\\\\[5pt]\n   df/ds = f_{,a} A^{a} = f_{;a} A^{a}\\\\[5pt]\n   d^2f/ds^2 = \\left ( f_{,a} A^{a} \\right)_{,b} A^{b} = \\left ( f_{;a} A^{a} \\right)_{;b} A^{b}\\\\[5pt]\n   d^3f/ds^3 = \\left(\\left ( f_{,a} A^{a} \\right)_{,b} A^{b}\\right)_{,c} A^{c} = \\left(\\left ( f_{;a} A^{a} \\right)_{;b} A^{b}\\right)_{;c} A^{c}\n\\end{gather*}\nI admit I've gone overboard here in writing out more than I need to but it's handy to have all\nof these equations laid bare in one convenient place.\n\nNow put $f = R^{p}{}_{abq} B^{q}{}_{p} A^{a} A^{b}$. Then upon taking successive derivatives,\nwhile taking full advantage of the asummptions just noted, we can eaily see that\n\\begin{align}\n   \\label{eqn:main}\n   \\left( R^{a}{}_{cdb} B^{b}{}_{a} \\right)_{;\\ue} A^{c} A^{d} A^{\\ue}\n   =\n   \\left( R^{a}{}_{cdb} \\right)_{,\\ue} B^{b}{}_{a} A^{c} A^{d} A^{\\ue}\n\\end{align}\nThis is the equation that will be computed by the following Cadabra code. All of the\ncompuations will be carried out on the left hand side (in the first version of the paper I\nswapped the left and righ hand sides).\n\nWe will need the successive covariant derivatives of $B$. The first covariant derivative is\njust \\begin{align*} B^{a}{}_{b;c} A^c &= \\Gamma^{a}{}_{dc}B^{d}{}_{b} A^c -\n\\Gamma^{d}{}_{bc}B^{a}{}_{d} A^c \\end{align*} The quantities on the left hand side are the\ncomponents of a tensor so further covariant derivatives of the right hand side can be computed\n(despite the presence of the $\\Gamma$'s) by application of the usual rule for a covariant\nderivative of a mixed tensor.\n\n% =================================================================================================\n\\section*{Stage 1: Symmetrised partial derivatives of $R$}\n\nThe first stage involves the expansion of the left side of (\\ref{eqn:main}). This leads to\nexpressions for the symmetrized partial derivatives of $R_{abcd}$ in terms of the symmetrized\ncovariant derivatives of $R_{abcd}$ and $B^{a}{}_{b}$.\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,e} B^{b}{}_{a} A^{c} A^{d} A^{e}\n                  = \\cdb{dRabcd01.108} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,ef} B^{b}{}_{a} A^{c} A^{d} A^{e} A^{f}\n                  = \\cdb{dRabcd02.108} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,efg} B^{b}{}_{a} A^{c} A^{d} A^{e} A^{f} A^{g}\n                  = \\cdb{dRabcd03.108} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Stage 2: Symmetrised covariant derivatives of $B$}\n\nIn this stage the symmetrized covariant derivatives of $B^{a}{}_{b}$ are computed in terms of\nits partial derivatives (which by choice are all zero) and the connection and its partial\nderivatives (which in general are not zero).\n\n\\begin{dgroup*}\n   \\begin{dmath*} A^{c}\\nabla_{c}\\left(B^{a}{}_{b}\\right)\n                  = \\cdb{dBab01.209} \\end{dmath*}\n   \\begin{dmath*} A^{d}A^{c}\\nabla_{d}\\left(\\nabla_{c}\\left(B^{a}{}_{b}\\right)\\right)\n                  = \\cdb{dBab02.209} \\end{dmath*}\n   \\begin{dmath*} A^{e}A^{d}A^{c}\\nabla_{e}\\left(\\nabla_{d}\\left(\\nabla_{c}\\left(B^{a}{}_{b}\\right)\\right)\\right)\n                  = \\cdb{dBab03.209} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Stage 3: Impose the Riemann normal coordinate condition on covariant derivs of $B$}\n\nHere we impose the RNC condition (that $\\Gamma = 0$ while $\\partial\\Gamma\\not=0$).\n\n\\begin{dgroup*}\n   \\begin{dmath*} A^{c}\\nabla_{c}\\left(B^{a}{}_{b}\\right)\n                  = \\cdb{dBab01.301} \\end{dmath*}\n   \\begin{dmath*} A^{d}A^{c}\\nabla_{d}\\left(\\nabla_{c}\\left(B^{a}{}_{b}\\right)\\right)\n                  = \\cdb{dBab02.301} \\end{dmath*}\n   \\begin{dmath*} A^{e}A^{d}A^{c}\\nabla_{e}\\left(\\nabla_{d}\\left(\\nabla_{c}\\left(B^{a}{}_{b}\\right)\\right)\\right)\n                  = \\cdb{dBab03.301} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Stage 4: Replace covariant derivs of $B$ with partial derivs of $\\Gamma$}\n\nThis stage uses the results from the second stage to eliminate the $\\nabla B$ terms from the\nresults of the first stage. This produces expressions for the symmetrized partial derivatives\nof $R_{abcd}$ in terms of the symmetrized covariant derivatives of $R_{abcd}$ and the partial\nderivatives of the connection. In this stage we also set the $B^{a}{}_{b}$ to equal 1.\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,e} A^{c} A^{d} A^{e}\n                  = \\cdb{dRabcd01.401} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,ef} A^{c} A^{d} A^{e} A^{e}\n                  = \\cdb{dRabcd02.401} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,efg} A^{c} A^{d} A^{e} A^{f} A^{g}\n                  = \\cdb{dRabcd03.401} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Stage 5: Replace partial derivs of $\\Gamma$ with partial derivs of $R$}\n\nThe fifth stage draws in results from {\\tt dGamma.tex} to replace the partial derivatives of\n$\\Gamma$ with partial derivatives of $R_{abcd}$.\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,e} A^{c} A^{d} A^{e}\n                  = \\cdb{dRabcd01.500} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,ef} A^{c} A^{d} A^{e} A^{f}\n                  = \\cdb{dRabcd02.505} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,efg} A^{c} A^{d} A^{e} A^{f} A^{g}\n                  = \\cdb{dRabcd03.507} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Stage 6: Replace partial derivs of $R$ with covariant derivs of $R$}\n\nThe final stage is to eliminate the $\\partial R$ by using earlier results. For example, in the\nequation for $\\partial^3 R$ we see terms involving $\\partial R$. These first order partial\nderivatives can be replaced with the expression previously computed for $\\partial R$ in terms\nof $\\nabla R$.\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,e} A^{c} A^{d} A^{e}\n                  = \\cdb{dRabcd01.702} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,ef} A^{c} A^{d} A^{e} A^{e}\n                  = \\cdb{dRabcd02.702} \\end{dmath*}\n   \\begin{dmath*} \\left( R^{a}{}_{cdb} \\right)_{,efg} A^{c} A^{d} A^{e} A^{f} A^{g}\n                  = \\cdb{dRabcd03.702} \\end{dmath*}\n\\end{dgroup*}\n\nThe end result are expressions for the symmetrized partial derivatives of $R_{abcd}$ solely in\nterms of the symmetrized covariant derivatives of $R_{abcd}$.\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Shared properties}\n\n\\begin{cadabra}\n   import time\n\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   \\nabla{#}::Derivative.\n   \\partial{#}::PartialDerivative.\n\n   g_{a b}::Metric.\n   g^{a b}::InverseMetric.\n   g_{a}^{b}::KroneckerDelta.\n   g^{a}_{b}::KroneckerDelta.\n\n   R_{a b c d}::RiemannTensor.\n   R^{a}_{b c d}::RiemannTensor.\n\n   \\Gamma^{a}_{b c}::TableauSymmetry(shape={2}, indices={1,2}).\n\n   g_{a b}::Depends(\\partial{#}).\n   R_{a b c d}::Depends(\\partial{#}).\n   R^{a}_{b c d}::Depends(\\partial{#}).\n   \\Gamma^{a}_{b c}::Depends(\\partial{#}).\n\n   B^{a}_{b::Depends(\\nabla{#}).\n   R_{a b c d}::Depends(\\nabla{#}).\n   R^{a}_{b c d}::Depends(\\nabla{#}).\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 1: Symmetrised partial derivatives of $R$}\n\n\\begin{cadabra}\n   def flatten_Rabcd (obj):\n       substitute (obj,$R^{a}_{b c d}   -> g^{a e} R_{e b c d}$)\n       substitute (obj,$R_{a}^{b}_{c d} -> g^{b e} R_{a e c d}$)\n       substitute (obj,$R_{a b}^{c}_{b} -> g^{c e} R_{a b e d}$)\n       substitute (obj,$R_{a b c}^{d}   -> g^{d e} R_{a b c e}$)\n       unwrap     (obj)\n       sort_product   (obj)\n       rename_dummies (obj)\n       return obj\n\n   # compute the symmetric covariant derivatives of R^{a}_{bcd} B^{d}_{a}\n\n   beg_stage_1 = time.time()\n\n   dRabcd00:=R^{a}_{b c d} B^{d}_{a} A^{b} A^{c}.        # cdb(dRabcd00.101,dRabcd00)\n\n   dRabcd01:=A^{a}\\nabla_{a}{ @(dRabcd00) }.             # cdb(dRabcd01.101,dRabcd01)\n   distribute     (dRabcd01)                             # cdb(dRabcd01.102,dRabcd01)\n   product_rule   (dRabcd01)                             # cdb(dRabcd01.103,dRabcd01)\n   distribute     (dRabcd01)                             # cdb(dRabcd01.104,dRabcd01)\n   substitute     (dRabcd01,$\\nabla_{a}{A^{b}} -> 0$)    # cdb(dRabcd01.105,dRabcd01)\n   substitute     (dRabcd01,$\\nabla_{a}{g^{b c}} -> 0$)  # cdb(dRabcd01.106,dRabcd01)\n\n   sort_product   (dRabcd01)\n   rename_dummies (dRabcd01)\n   canonicalise   (dRabcd01)                             # cdb(dRabcd01.107,dRabcd01)\n   dRabcd01 = flatten_Rabcd (dRabcd01)                   # cdb(dRabcd01.108,dRabcd01)\n\n   dRabcd02:=A^{a}\\nabla_{a}{ @(dRabcd01) }.             # cdb(dRabcd02.101,dRabcd02)\n   distribute     (dRabcd02)                             # cdb(dRabcd02.102,dRabcd02)\n   product_rule   (dRabcd02)                             # cdb(dRabcd02.103,dRabcd02)\n   distribute     (dRabcd02)                             # cdb(dRabcd02.104,dRabcd02)\n   substitute     (dRabcd02,$\\nabla_{a}{A^{b}} -> 0$)    # cdb(dRabcd02.105,dRabcd02)\n   substitute     (dRabcd02,$\\nabla_{a}{g^{b c}} -> 0$)  # cdb(dRabcd02.106,dRabcd02)\n\n   sort_product   (dRabcd02)\n   rename_dummies (dRabcd02)\n   canonicalise   (dRabcd02)                             # cdb(dRabcd02.107,dRabcd02)\n   dRabcd02 = flatten_Rabcd (dRabcd02)                   # cdb(dRabcd02.108,dRabcd02)\n\n   dRabcd03:=A^{a}\\nabla_{a}{ @(dRabcd02) }.             # cdb(dRabcd03.101,dRabcd03)\n   distribute     (dRabcd03)                             # cdb(dRabcd03.102,dRabcd03)\n   product_rule   (dRabcd03)                             # cdb(dRabcd03.103,dRabcd03)\n   distribute     (dRabcd03)                             # cdb(dRabcd03.104,dRabcd03)\n   substitute     (dRabcd03,$\\nabla_{a}{A^{b}} -> 0$)    # cdb(dRabcd03.105,dRabcd03)\n   substitute     (dRabcd03,$\\nabla_{a}{g^{b c}} -> 0$)  # cdb(dRabcd03.106,dRabcd03)\n\n   sort_product   (dRabcd03)\n   rename_dummies (dRabcd03)\n   canonicalise   (dRabcd03)                             # cdb(dRabcd03.107,dRabcd03)\n   dRabcd03 = flatten_Rabcd (dRabcd03)                   # cdb(dRabcd03.108,dRabcd03)\n\n   dRabcd04:=A^{a}\\nabla_{a}{ @(dRabcd03) }.\n   distribute     (dRabcd04)\n   product_rule   (dRabcd04)\n   distribute     (dRabcd04)\n   substitute     (dRabcd04,$\\nabla_{a}{A^{b}} -> 0$)\n   substitute     (dRabcd04,$\\nabla_{a}{g^{b c}} -> 0$)\n\n   sort_product   (dRabcd04)\n   rename_dummies (dRabcd04)\n   canonicalise   (dRabcd04)\n   dRabcd04 = flatten_Rabcd (dRabcd04)\n\n   dRabcd05:=A^{a}\\nabla_{a}{ @(dRabcd04) }.\n   distribute     (dRabcd05)\n   product_rule   (dRabcd05)\n   distribute     (dRabcd05)\n   substitute     (dRabcd05,$\\nabla_{a}{A^{b}} -> 0$)\n   substitute     (dRabcd05,$\\nabla_{a}{g^{b c}} -> 0$)\n\n   sort_product   (dRabcd05)\n   rename_dummies (dRabcd05)\n   canonicalise   (dRabcd05)\n   dRabcd05 = flatten_Rabcd (dRabcd05)\n\n   def combine_nabla (obj):\n       substitute (obj,$\\nabla_{p}{\\nabla_{q}{\\nabla_{r}{\\nabla_{s}{\\nabla_{t}{A??}}}}}->\\nabla_{p q r s t}{A??}$,repeat=True)\n       substitute (obj,$\\nabla_{p}{\\nabla_{q}{\\nabla_{r}{\\nabla_{s}{A??}}}}->\\nabla_{p q r s}{A??}$,repeat=True)\n       substitute (obj,$\\nabla_{p}{\\nabla_{q}{\\nabla_{r}{A??}}}->\\nabla_{p q r}{A??}$,repeat=True)\n       substitute (obj,$\\nabla_{p}{\\nabla_{q}{A??}}->\\nabla_{p q}{A??}$,repeat=True)\n       return obj\n\n   dRabcd01 = combine_nabla (dRabcd01)\n   dRabcd02 = combine_nabla (dRabcd02)\n   dRabcd03 = combine_nabla (dRabcd03)\n   dRabcd04 = combine_nabla (dRabcd04)\n   dRabcd05 = combine_nabla (dRabcd05)\n\n   end_stage_1 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd00.101} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd01.101} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.102} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.103} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.104} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.105} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.106} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.107} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd01.108} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd02.101} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.102} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.103} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.104} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.105} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.106} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.107} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.108} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd03.101} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.102} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.103} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.104} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.105} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.106} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.107} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.108} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 2: Symmetrised covariant derivatives of $B$}\n\n\\begin{cadabra}\n   # compute the covariant derivatives of B^{a}_{b}, note B^{a}_{b,c} is zero, by choice\n   # this method of computing covariant derivatives does not use auxillary fields\n\n   beg_stage_2 = time.time()\n\n   dBab00:=B^{a}_{b}.      # cdb(dBab00.201,dBab00)\n\n   dBab01:=A^{c}\\partial_{c}{ @(dBab00) } + \\Gamma^{a}_{p q} W^{p}_{b} A^{q}\n                                          - \\Gamma^{p}_{b q} W^{a}_{p} A^{q}.\n                                                         # cdb(dBab01.201,dBab01)\n   distribute   (dBab01)                                 # cdb(dBab01.202,dBab01)\n   product_rule (dBab01)                                 # cdb(dBab01.203,dBab01)\n   distribute   (dBab01)                                 # cdb(dBab01.204,dBab01)\n   substitute   (dBab01,$\\partial_{a}{A^{b}} -> 0$)      # cdb(dBab01.205,dBab01)\n   substitute   (dBab01,$\\partial_{a}{B^{b}_{c}} -> 0$)  # cdb(dBab01.206,dBab01)\n   substitute   (dBab01,$W^{a}_{b} -> @(dBab00)$)        # cdb(dBab01.207,dBab01)\n   distribute   (dBab01)                                 # cdb(dBab01.208,dBab01)\n   canonicalise (dBab01)                                 # cdb(dBab01.209,dBab01)\n\n   dBab02:=A^{c}\\partial_{c}{ @(dBab01) } + \\Gamma^{a}_{p q} W^{p}_{b} A^{q}\n                                          - \\Gamma^{p}_{b q} W^{a}_{p} A^{q}.\n                                                         # cdb(dBab02.201,dBab02)\n   distribute   (dBab02)                                 # cdb(dBab02.202,dBab02)\n   product_rule (dBab02)                                 # cdb(dBab02.203,dBab02)\n   distribute   (dBab02)                                 # cdb(dBab02.204,dBab02)\n   substitute   (dBab02,$\\partial_{a}{A^{b}} -> 0$)      # cdb(dBab02.205,dBab02)\n   substitute   (dBab02,$\\partial_{a}{B^{b}_{c}} -> 0$)  # cdb(dBab02.206,dBab02)\n   substitute   (dBab02,$W^{a}_{b} -> @(dBab01)$)        # cdb(dBab02.207,dBab02)\n   distribute   (dBab02)                                 # cdb(dBab02.208,dBab02)\n   canonicalise (dBab02)                                 # cdb(dBab02.209,dBab02)\n\n   dBab03:=A^{c}\\partial_{c}{ @(dBab02) } + \\Gamma^{a}_{p q} W^{p}_{b} A^{q}\n                                          - \\Gamma^{p}_{b q} W^{a}_{p} A^{q}.\n                                                         # cdb(dBab03.201,dBab03)\n   distribute   (dBab03)                                 # cdb(dBab03.202,dBab03)\n   product_rule (dBab03)                                 # cdb(dBab03.203,dBab03)\n   distribute   (dBab03)                                 # cdb(dBab03.204,dBab03)\n   substitute   (dBab03,$\\partial_{a}{A^{b}} -> 0$)      # cdb(dBab03.205,dBab03)\n   substitute   (dBab03,$\\partial_{a}{B^{b}_{c}} -> 0$)  # cdb(dBab03.206,dBab03)\n   substitute   (dBab03,$W^{a}_{b} -> @(dBab02)$)        # cdb(dBab03.207,dBab03)\n   distribute   (dBab03)                                 # cdb(dBab03.208,dBab03)\n   canonicalise (dBab03)                                 # cdb(dBab03.209,dBab03)\n\n   dBab04:=A^{c}\\partial_{c}{ @(dBab03) } + \\Gamma^{a}_{p q} W^{p}_{b} A^{q}\n                                          - \\Gamma^{p}_{b q} W^{a}_{p} A^{q}.\n   distribute   (dBab04)\n   product_rule (dBab04)\n   distribute   (dBab04)\n   substitute   (dBab04,$\\partial_{a}{A^{b}} -> 0$)\n   substitute   (dBab04,$\\partial_{a}{B^{b}_{c}} -> 0$)\n   substitute   (dBab04,$W^{a}_{b} -> @(dBab03)$)\n   distribute   (dBab04)\n   canonicalise (dBab04)\n\n   dBab05:=A^{c}\\partial_{c}{ @(dBab04) } + \\Gamma^{a}_{p q} W^{p}_{b} A^{q}\n                                          - \\Gamma^{p}_{b q} W^{a}_{p} A^{q}.\n   distribute   (dBab05)\n   product_rule (dBab05)\n   distribute   (dBab05)\n   substitute   (dBab05,$\\partial_{a}{A^{b}} -> 0$)\n   substitute   (dBab05,$\\partial_{a}{B^{b}_{c}} -> 0$)\n   substitute   (dBab05,$W^{a}_{b} -> @(dBab04)$)\n   distribute   (dBab05)\n   canonicalise (dBab05)\n\n   end_stage_2 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dBab00.201} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dBab01.201} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.202} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.203} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.204} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.205} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.206} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.207} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.208} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab01.209} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dBab02.201} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.202} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.203} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.204} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.205} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.206} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.207} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.208} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.209} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dBab03.201} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.202} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.203} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.204} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.205} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.206} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.207} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.208} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.209} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 3: Impose the Riemann normal coordinate condition on covariant derivs of $B$}\n\n\\begin{cadabra}\n   def impose_rnc (obj):\n       # hide the derivatives of Gamma\n       substitute (obj,$\\partial_{d}{\\Gamma^{a}_{b c}} -> zzz_{d}^{a}_{b c}$,repeat=True)\n       substitute (obj,$\\partial_{d e}{\\Gamma^{a}_{b c}} -> zzz_{d e}^{a}_{b c}$,repeat=True)\n       substitute (obj,$\\partial_{d e f}{\\Gamma^{a}_{b c}} -> zzz_{d e f}^{a}_{b c}$,repeat=True)\n       substitute (obj,$\\partial_{d e f g}{\\Gamma^{a}_{b c}} -> zzz_{d e f g}^{a}_{b c}$,repeat=True)\n       substitute (obj,$\\partial_{d e f g h}{\\Gamma^{a}_{b c}} -> zzz_{d e f g h}^{a}_{b c}$,repeat=True)\n       # set Gamma to zero\n       substitute (obj,$\\Gamma^{a}_{b c} -> 0$,repeat=True)\n       # recover the derivatives Gamma\n       substitute (obj,$zzz_{d}^{a}_{b c} -> \\partial_{d}{\\Gamma^{a}_{b c}}$,repeat=True)\n       substitute (obj,$zzz_{d e}^{a}_{b c} -> \\partial_{d e}{\\Gamma^{a}_{b c}}$,repeat=True)\n       substitute (obj,$zzz_{d e f}^{a}_{b c} -> \\partial_{d e f}{\\Gamma^{a}_{b c}}$,repeat=True)\n       substitute (obj,$zzz_{d e f g}^{a}_{b c} -> \\partial_{d e f g}{\\Gamma^{a}_{b c}}$,repeat=True)\n       substitute (obj,$zzz_{d e f g h}^{a}_{b c} -> \\partial_{d e f g h}{\\Gamma^{a}_{b c}}$,repeat=True)\n       return obj\n\n   # switch to RNC\n\n   beg_stage_3 = time.time()\n\n   dBab01 = impose_rnc (dBab01)   # cdb (dBab01.301,dBab01)\n   dBab02 = impose_rnc (dBab02)   # cdb (dBab02.301,dBab02)\n   dBab03 = impose_rnc (dBab03)   # cdb (dBab03.301,dBab03)\n   dBab04 = impose_rnc (dBab04)   # cdb (dBab04.301,dBab04)\n   dBab05 = impose_rnc (dBab05)   # cdb (dBab05.301,dBab05)\n\n   end_stage_3 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dBab01.301} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab02.301} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab03.301} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab04.301} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dBab05.301} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 4: Replace covariant derivs of $B$ with partial derivs of $\\Gamma$}\n\n\\begin{cadabra}\n   # substitute covariant derivs of B^{a}_{b} into covariant derivs of R^{a}_{bcd}B^{d}_{a}\n   # this produces expressions for the partial derivs of Rabcd its covariant derivs and partial derivs of Gamma\n   # the partial derivs of Gamma will be eliminted later by using results imported from dGamma.json\n\n   beg_stage_4 = time.time()\n\n   substitute (dRabcd01,$A^{c}\\nabla_{c}{B^{a}_{b}} -> @(dBab01)$,repeat=True);   distribute (dRabcd01)\n   substitute (dRabcd02,$A^{c}\\nabla_{c}{B^{a}_{b}} -> @(dBab01)$,repeat=True);   distribute (dRabcd02)\n   substitute (dRabcd03,$A^{c}\\nabla_{c}{B^{a}_{b}} -> @(dBab01)$,repeat=True);   distribute (dRabcd03)\n   substitute (dRabcd04,$A^{c}\\nabla_{c}{B^{a}_{b}} -> @(dBab01)$,repeat=True);   distribute (dRabcd04)\n   substitute (dRabcd05,$A^{c}\\nabla_{c}{B^{a}_{b}} -> @(dBab01)$,repeat=True);   distribute (dRabcd05)\n\n   substitute (dRabcd02,$A^{c}A^{d}\\nabla_{c d}{B^{a}_{b}} -> @(dBab02)$,repeat=True);   distribute (dRabcd02)\n   substitute (dRabcd03,$A^{c}A^{d}\\nabla_{c d}{B^{a}_{b}} -> @(dBab02)$,repeat=True);   distribute (dRabcd03)\n   substitute (dRabcd04,$A^{c}A^{d}\\nabla_{c d}{B^{a}_{b}} -> @(dBab02)$,repeat=True);   distribute (dRabcd04)\n   substitute (dRabcd05,$A^{c}A^{d}\\nabla_{c d}{B^{a}_{b}} -> @(dBab02)$,repeat=True);   distribute (dRabcd05)\n\n   substitute (dRabcd03,$A^{c}A^{d}A^{e}\\nabla_{c d e}{B^{a}_{b}} -> @(dBab03)$,repeat=True);   distribute (dRabcd03)\n   substitute (dRabcd04,$A^{c}A^{d}A^{e}\\nabla_{c d e}{B^{a}_{b}} -> @(dBab03)$,repeat=True);   distribute (dRabcd04)\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}\\nabla_{c d e}{B^{a}_{b}} -> @(dBab03)$,repeat=True);   distribute (dRabcd05)\n\n   substitute (dRabcd04,$A^{c}A^{d}A^{e}A^{f}\\nabla_{c d e f}{B^{a}_{b}} -> @(dBab04)$,repeat=True); distribute (dRabcd04)\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}A^{f}\\nabla_{c d e f}{B^{a}_{b}} -> @(dBab04)$,repeat=True); distribute (dRabcd05)\n\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}A^{f}A^{g}\\nabla_{c d e f g}{B^{a}_{b}} -> @(dBab05)$,repeat=True); distribute (dRabcd05)\n\n   # no longer need B, so let's get rid of it\n\n   # two subtle tricks are used here\n   # 1) rename A and B as A002 and A001 before sort_product,\n   #    this ensures B will be to left of A after the sort\n   # 2) indices on B changed from B^{a}_{b} to B_{b}^{a},\n   #    this ensures that after factor_out B will have dummy indices B_{a}^{b}\n\n   def remove_Bab (obj):\n       foo := @(obj).\n       substitute     (foo,$A^{a}->A002^{a},B^{a}_{b}->A001_{b}^{a}$)  # need this to sort B to the left of A\n       sort_product   (foo)\n       rename_dummies (foo)\n       factor_out     (foo,$A001^{a?}_{b?},A002^{c?}$)\n       substitute     (foo,$A001_{a}^{b}->1,A002^{a}->A^{a}$)  # recover A and set B = 1, free indices now ^{a}_{b}\n       return foo\n\n   dRabcd01 = remove_Bab (dRabcd01)   # cdb(dRabcd01.401,dRabcd01)\n   dRabcd02 = remove_Bab (dRabcd02)   # cdb(dRabcd02.401,dRabcd02)\n   dRabcd03 = remove_Bab (dRabcd03)   # cdb(dRabcd03.401,dRabcd03)\n   dRabcd04 = remove_Bab (dRabcd04)   # cdb(dRabcd04.401,dRabcd04)\n   dRabcd05 = remove_Bab (dRabcd05)   # cdb(dRabcd05.401,dRabcd05)\n\n   end_stage_4 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd01.401} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.401} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.401} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.401} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd05.401} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 5: Replace partial derivs of $\\Gamma$ with partial derivs of $R$}\n\n\\begin{cadabra}\n   import cdblib\n\n   beg_stage_5 = time.time()\n\n   dGamma01 = cdblib.get ('dGamma01','dGamma.json')  # cdb(dGamma01.500,dGamma01)\n   dGamma02 = cdblib.get ('dGamma02','dGamma.json')  # cdb(dGamma02.500,dGamma02)\n   dGamma03 = cdblib.get ('dGamma03','dGamma.json')  # cdb(dGamma03.500,dGamma03)\n   dGamma04 = cdblib.get ('dGamma04','dGamma.json')  # cdb(dGamma04.500,dGamma04)\n   dGamma05 = cdblib.get ('dGamma05','dGamma.json')  # cdb(dGamma05.500,dGamma05)\n\n   distribute (dRabcd01)   # cdb(dRabcd01.500,dRabcd01)\n   distribute (dRabcd02)   # cdb(dRabcd02.500,dRabcd02)\n   distribute (dRabcd03)   # cdb(dRabcd03.500,dRabcd03)\n   distribute (dRabcd04)   # cdb(dRabcd04.500,dRabcd04)\n   distribute (dRabcd05)   # cdb(dRabcd05.500,dRabcd05)\n\n   # use dGamma to eliminate the partial derivs of Gamma\n   # this will introduces some lower order partial dervis of Rabcd on the rhs\n   # these extra partial derivs of Rabcd will be eliminated (later) by substiting lower order dRabcd into the higher order dRabcd\n\n   substitute (dRabcd02,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{d b}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd02.501,dRabcd02)\n   substitute (dRabcd02,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{b d}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd02.502,dRabcd02)\n   distribute (dRabcd02)                                                                                      # cdb(dRabcd02.503,dRabcd02)\n   sort_product   (dRabcd02)                                                                                  # cdb(dRabcd02.504,dRabcd02)\n   rename_dummies (dRabcd02)                                                                                  # cdb(dRabcd02.505,dRabcd02)\n\n\n   substitute (dRabcd03,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{d b}} -> @(dGamma02)$,repeat=True)         # cdb(dRabcd03.501,dRabcd03)\n   substitute (dRabcd03,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{b d}} -> @(dGamma02)$,repeat=True)         # cdb(dRabcd03.502,dRabcd03)\n   substitute (dRabcd03,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{d b}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd03.503,dRabcd03)\n   substitute (dRabcd03,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{b d}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd03.504,dRabcd03)\n   distribute (dRabcd03)                                                                                      # cdb(dRabcd03.505,dRabcd03)\n   sort_product   (dRabcd03)                                                                                  # cdb(dRabcd03.506,dRabcd03)\n   rename_dummies (dRabcd03)                                                                                  # cdb(dRabcd03.507,dRabcd03)\n\n   substitute (dRabcd04,$A^{c}A^{b}A^{e}A^{f}\\partial_{c e f}{\\Gamma^{a}_{d b}} -> @(dGamma03)$,repeat=True)  # cdb(dRabcd04.501,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{b}A^{e}A^{f}\\partial_{c e f}{\\Gamma^{a}_{b d}} -> @(dGamma03)$,repeat=True)  # cdb(dRabcd04.502,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{d b}} -> @(dGamma02)$,repeat=True)         # cdb(dRabcd04.503,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{b d}} -> @(dGamma02)$,repeat=True)         # cdb(dRabcd04.504,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{d b}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd04.505,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{b d}} -> @(dGamma01)$,repeat=True)                # cdb(dRabcd04.506,dRabcd04)\n   distribute (dRabcd04)                                                                                      # cdb(dRabcd04.507,dRabcd04)\n   sort_product   (dRabcd04)                                                                                  # cdb(dRabcd04.508,dRabcd04)\n   rename_dummies (dRabcd04)                                                                                  # cdb(dRabcd04.509,dRabcd04)\n\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}A^{f}A^{g}\\partial_{c e f g}{\\Gamma^{a}_{d b}} -> @(dGamma04)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}A^{f}A^{g}\\partial_{c e f g}{\\Gamma^{a}_{b d}} -> @(dGamma04)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}A^{f}\\partial_{c e f}{\\Gamma^{a}_{d b}} -> @(dGamma03)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}A^{f}\\partial_{c e f}{\\Gamma^{a}_{b d}} -> @(dGamma03)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{d b}} -> @(dGamma02)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}A^{e}\\partial_{c e}{\\Gamma^{a}_{b d}} -> @(dGamma02)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{d b}} -> @(dGamma01)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{b}\\partial_{c}{\\Gamma^{a}_{b d}} -> @(dGamma01)$,repeat=True)\n   distribute (dRabcd05)\n   sort_product   (dRabcd05)\n   rename_dummies (dRabcd05)\n\n   end_stage_5 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd01.500} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd02.500} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.501} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.502} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.503} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.504} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.505} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd03.500} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.501} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.502} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.503} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.504} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.505} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.506} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.507} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd04.500} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.501} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.502} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.503} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.504} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.505} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.506} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.507} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.508} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.509} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 6: Replace partial derivs of $R$ with covariant derivs of $R$}\n\n\\begin{cadabra}\n   # now eliminate remaining partial derivs of Rabcd by substitution from the lower order dRabcd\n\n   # note that\n   #   dRabcd01 = R^a_{cdb,e} A^c A^d A^e\n   #   dRabcd02 = R^a_{cdb,ef} A^c A^d A^e A^f\n   #   dRabcd03 = R^a_{cdb,efg} A^c A^d A^e A^f A^g\n\n   # thus we can use\n   #   dRabcd01 to eliminate 1st partial derivs of R in dRabcd03, dRabcd04, etc.\n   #   dRabcd02 to eliminate 2nd partial derivs of R in dRabcd04, dRabcd05, etc.\n   #   dRabcd03 to eliminate 3rd partial derivs of R in dRabcd05, dRabcd06, etc.\n\n   beg_stage_6 = time.time()\n\n   substitute (dRabcd03,$A^{c}A^{d}A^{e}\\partial_{e}{R^{a}_{c d b}} -> @(dRabcd01)$,repeat=True)         # cdb(dRabcd03.601,dRabcd03)\n   distribute (dRabcd03)                                                                                 # cdb(dRabcd03.602,dRabcd03)\n\n   # note: dRabcd04 and dRabcd05 unused in this code (or any other code)\n\n   substitute (dRabcd04,$A^{c}A^{d}A^{e}A^{f}\\partial_{e f}{R^{a}_{c d b}} -> @(dRabcd02)$,repeat=True)  # cdb(dRabcd04.601,dRabcd04)\n   substitute (dRabcd04,$A^{c}A^{d}A^{e}\\partial_{e}{R^{a}_{c d b}} -> @(dRabcd01)$,repeat=True)         # cdb(dRabcd04.602,dRabcd04)\n   distribute (dRabcd04)                                                                                 # cdb(dRabcd04.603,dRabcd04)\n\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}A^{f}A^{g}\\partial_{e f g}{R^{a}_{c d b}} -> @(dRabcd03)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}A^{f}\\partial_{e f}{R^{a}_{c d b}} -> @(dRabcd02)$,repeat=True)\n   substitute (dRabcd05,$A^{c}A^{d}A^{e}\\partial_{e}{R^{a}_{c d b}} -> @(dRabcd01)$,repeat=True)\n   distribute (dRabcd05)\n\n   end_stage_6 = time.time()\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd03.601} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.602} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd04.601} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.602} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.603} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Stage 7: Reformatting}\n\n\\begin{cadabra}\n   beg_stage_7 = time.time()\n\n   dRabcd01 = flatten_Rabcd (dRabcd01)  # cdb(dRabcd01.701,dRabcd01)\n   dRabcd02 = flatten_Rabcd (dRabcd02)  # cdb(dRabcd02.701,dRabcd02)\n   dRabcd03 = flatten_Rabcd (dRabcd03)  # cdb(dRabcd03.701,dRabcd03)\n   dRabcd04 = flatten_Rabcd (dRabcd04)  # cdb(dRabcd04.701,dRabcd04)\n   dRabcd05 = flatten_Rabcd (dRabcd05)  # cdb(dRabcd05.701,dRabcd05)\n\n   canonicalise (dRabcd01)   # cdb(dRabcd01.702,dRabcd01)\n   canonicalise (dRabcd02)   # cdb(dRabcd02.702,dRabcd02)\n   canonicalise (dRabcd03)   # cdb(dRabcd03.702,dRabcd03)\n   canonicalise (dRabcd04)   # cdb(dRabcd04.702,dRabcd04)\n   canonicalise (dRabcd05)   # cdb(dRabcd05.702,dRabcd05)\n\n   end_stage_7 = time.time()\n\n   # cdbBeg (timing)\n   print (\"Stage 1: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_1-beg_stage_1))\n   print (\"Stage 2: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_2-beg_stage_2))\n   print (\"Stage 3: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_3-beg_stage_3))\n   print (\"Stage 4: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_4-beg_stage_4))\n   print (\"Stage 5: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_5-beg_stage_5))\n   print (\"Stage 6: {:7.1f} secs\\\\hfill\\\\break\".format(end_stage_6-beg_stage_6))\n   print (\"Stage 7: {:7.1f} secs\".format(end_stage_7-beg_stage_7))\n   # cdbEnd (timing)\n\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd01.701} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.701} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.701} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.701} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{dRabcd05.701} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{dRabcd01.702} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd02.702} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd03.702} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd04.702} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{dRabcd05.702} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   cdblib.create ('dRabcd.json')\n\n   cdblib.put ('dRabcd01',dRabcd01,'dRabcd.json')\n   cdblib.put ('dRabcd02',dRabcd02,'dRabcd.json')\n   cdblib.put ('dRabcd03',dRabcd03,'dRabcd.json')\n   cdblib.put ('dRabcd04',dRabcd04,'dRabcd.json')\n   cdblib.put ('dRabcd05',dRabcd05,'dRabcd.json')\n\n\\end{cadabra}\n\n% =================================================================================================\n% the remaining code is just for pretty printing\n\n\\clearpage\n\n\\begin{cadabra}\n   # note: keeping numbering as is (out of order) to ensure R appears before \\nabla R etc.\n   def product_sort (obj):\n       substitute (obj,$ A^{a}                            -> A001^{a}               $)\n       substitute (obj,$ x^{a}                            -> A002^{a}               $)\n       substitute (obj,$ g^{a b}                          -> A003^{a b}             $)\n       substitute (obj,$ \\nabla_{e f g h}{R_{a b c d}}    -> A008_{a b c d e f g h} $)\n       substitute (obj,$ \\nabla_{e f g}{R_{a b c d}}      -> A007_{a b c d e f g}   $)\n       substitute (obj,$ \\nabla_{e f}{R_{a b c d}}        -> A006_{a b c d e f}     $)\n       substitute (obj,$ \\nabla_{e}{R_{a b c d}}          -> A005_{a b c d e}       $)\n       substitute (obj,$ R_{a b c d}                      -> A004_{a b c d}         $)\n       sort_product   (obj)\n       rename_dummies (obj)\n       substitute (obj,$ A001^{a}                  -> A^{a}                         $)\n       substitute (obj,$ A002^{a}                  -> x^{a}                         $)\n       substitute (obj,$ A003^{a b}                -> g^{a b}                       $)\n       substitute (obj,$ A004_{a b c d}            -> R_{a b c d}                   $)\n       substitute (obj,$ A005_{a b c d e}          -> \\nabla_{e}{R_{a b c d}}       $)\n       substitute (obj,$ A006_{a b c d e f}        -> \\nabla_{e f}{R_{a b c d}}     $)\n       substitute (obj,$ A007_{a b c d e f g}      -> \\nabla_{e f g}{R_{a b c d}}   $)\n       substitute (obj,$ A008_{a b c d e f g h}    -> \\nabla_{e f g h}{R_{a b c d}} $)\n\n       return obj\n\n   def reformat (obj,scale):\n       foo  = Ex(str(scale))\n       bah := @(foo) @(obj).\n       distribute     (bah)\n       bah = product_sort (bah)\n       rename_dummies (bah)\n       canonicalise   (bah)\n       factor_out     (bah,$A^{a?}$)\n       ans := @(bah).\n       return ans\n\n   scaled1 = reformat (dRabcd01, 1)    # cdb(scaled1.601,scaled1)\n   scaled2 = reformat (dRabcd02, 1)    # cdb(scaled2.601,scaled2)\n   scaled3 = reformat (dRabcd03,-2)    # cdb(scaled3.601,scaled3)\n   scaled4 = reformat (dRabcd04,-5)    # cdb(scaled4.601,scaled4)\n   scaled5 = reformat (dRabcd05,-3)    # cdb(scaled5.601,scaled5)\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Symmetrised partial derivatives of $R^a{}_{bcd}$}\n\\begin{dgroup*}\n   \\begin{dmath*}    A^c A^d A^e R^a{}_{cdb,e} = \\cdb{scaled1.601} \\end{dmath*}\n   \\begin{dmath*}    A^c A^d A^e A^{f} R^a{}_{cdb,ef} = \\cdb{scaled2.601} \\end{dmath*}\n   \\begin{dmath*} -2 A^c A^d A^e A^{f} A^{g} R^a{}_{cdb,efg} = \\cdb{scaled3.601} \\end{dmath*}\n   \\begin{dmath*} -5 A^c A^d A^e A^{f} A^{g} A^{h} R^a{}_{cdb,efgh} = \\cdb{scaled4.601} \\end{dmath*}\n   \\begin{dmath*} -3 A^c A^d A^e A^{f} A^{g} A^{h} A^{i}R^a{}_{cdb,efghi} = \\cdb{scaled5.601} \\end{dmath*}\n\\end{dgroup*}\n\n% LCB: only need dRabcd01,02,03. So I could save time by not\n%      computing dRabcd04,05\n\n% computing just dRabcd0n to n=4 takes about 1 min 40 sec.\n% but going to n=5 takes about 7 min\n\n\\clearpage\n\n% =================================================================================================\n% export selected objects, these will later be imported into a library\n% these are the objects that will appear in the paper\n\n\\begin{cadabra}\n   substitute (scaled1,$A^{a}->1$)\n   substitute (scaled2,$A^{a}->1$)\n   substitute (scaled3,$A^{a}->1$)\n   substitute (scaled4,$A^{a}->1$)\n   substitute (scaled5,$A^{a}->1$)\n\n   cdblib.create ('dRabcd.export')\n\n   # 6th order dRabcd, scaled\n   cdblib.put ('dRabcd61scaled',scaled1,'dRabcd.export')\n   cdblib.put ('dRabcd62scaled',scaled2,'dRabcd.export')\n   cdblib.put ('dRabcd63scaled',scaled3,'dRabcd.export')\n   cdblib.put ('dRabcd64scaled',scaled4,'dRabcd.export')\n   cdblib.put ('dRabcd65scaled',scaled5,'dRabcd.export')\n\n   checkpoint.append (scaled1)\n   checkpoint.append (scaled2)\n   checkpoint.append (scaled3)\n   checkpoint.append (scaled4)\n   checkpoint.append (scaled5)\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Timing}\n\n\\cdb{timing}\n\n% =================================================================================================\n% export checkpoints in json format\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   for i in range( len(checkpoint) ):\n      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)\n\\end{cadabra}\n\\egroup\n\n\\end{document}\n", "meta": {"hexsha": "f4a9b732316203813ef06d456e8785e08eb7369d", "size": 43213, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/dRabcd.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/dRabcd.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/dRabcd.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0729847495, "max_line_length": 146, "alphanum_fraction": 0.5594149909, "num_tokens": 15917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105720171531, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.445080005448676}}
{"text": "% BEGIN LICENSE BLOCK\n% Version: CMPL 1.1\n%\n% The contents of this file are subject to the Cisco-style Mozilla Public\n% License Version 1.1 (the \"License\"); you may not use this file except\n% in compliance with the License.  You may obtain a copy of the License\n% at www.eclipse-clp.org/license.\n% \n% Software distributed under the License is distributed on an \"AS IS\"\n% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See\n% the License for the specific language governing rights and limitations\n% under the License. \n% \n% The Original Code is  The ECLiPSe Constraint Logic Programming System. \n% The Initial Developer of the Original Code is  Cisco Systems, Inc. \n% Portions created by the Initial Developer are\n% Copyright (C) 1999 - 2006 Cisco Systems, Inc.  All Rights Reserved.\n% \n% Contributor(s): Joachim Schimpf, IC-Parc\n% \n% END LICENSE BLOCK\n%\n% $Id: umscalendar.tex,v 1.1 2006/09/23 01:50:40 snovello Exp $\n%\n% Joachim Schimpf, IC-Parc\n%\n\n\\section{Calendar Library}\n\\label{chapcal}\nThis library contains a set of predicates to assist with the handling\nof dates and times.  It is loaded using\n\\begin{quote}\\begin{verbatim}\n:- use_module(library(calendar)).\n\\end{verbatim}\\end{quote}\nThe library represents time points as {\\em Modified Julian Dates} (MJD).\nJulian Dates (JD) and Modified Julian Dates (MJD) are a\nconsecutive day numbering scheme widely used in astronomy,\nspace travel etc.\nThat means that every day has a unique integer number, and consecutive\ndays have consecutive numbers.\nNote that you can also use fractional MJDs to denote the time of day.\nThen every time point has a unique floating point representation!\nWith this normalised representation, distances between times are\nobviously trivial to compute, and so are weekdays (by simple mod(7)\noperation).\n\nThe predicates provided are\n\\begin{description}\n\\item[date_to_mjd(+D/M/Y, -MJD)] converts a Day/Month/Year structure into\n\tits unique integer MJD number.\n\\item[mjd_to_date(+MJD, -D/M/Y)] converts an MJD\n\t(integer or float) into the corresponding Day/Month/Year.\n\\item[time_to_mjd(+H:M:S, -MJD)] returns a float MJD \\lt 1.0 encoding the\n\ttime of day (UTC/GMT). This can be added to an integral day number\n\tto obtain a full MJD.\n\\item[mjd_to_time(+MJD, -H:M:S)] returns the time of day (UTC/GMT)\n\tcorresponding to the given MJD as Hour:Minute:Seconds structure,\n\twhere Hour and Minute are integers and Seconds is a float.\n\\item[mjd_to_weekday(+MJD, -DayName)] returns the weekday of the\n\tspecified MJD as atom monday, tuesday etc.\n\\item[mjd_to_dow(+MJD, -DoW)] returns the weekday of the\n\tspecified MJD as an integer (1 for monday up to 7 for sunday).\n\\item[mjd_to_dow(+MJD, +FirstWeekday, -DoW)] as above, but allows to choose\n\ta different starting day for weeks, specified as atom monday,\n\ttuesday etc.\n\\item[mjd_to_dy(+MJD, -DoY/Y), dy_to_mjd(+DoY/Y, -MJD)] convert MJDs\n\tto or from a DayOfYear/Year representation, where DayOfYear is\n\tthe relative day number starting with 1 on every January 1st.\n\\item[mjd_to_dwy(+MJD, -DoW/WoY/Y), dwy_to_mjd(+DoW/WoY/Y, -MJD)] convert\n\tMJDs to or from a DayOfWeek/WeekOfYear/Year representation, where\n\tDayOfWeek is the day number within the week (1 for monday up to\n\t7 for sunday), and WeekOfYear is the week number within the year\n\t(starting with 1 for the week that contains January 1st).\n\\item[mjd_to_dwy(+MJD, +FirstWeekday, -DoW/WoY/Y)]\n\\item[dwy_to_mjd(+DoW/WoY/Y, +FirstWeekday, -MJD)]\n\tAs above, but allows to choose a different starting day for weeks,\n\tspecified as atom monday, tuesday etc.\n\\item[unix_to_mjd(+UnixSec, -MJD)] convert the UNIX time representation\n\tinto a (float) MJD.\n\\item[mjd_now(-MJD)] returns the current date/time as (float) MJD.\n\\item[jd_to_mjd(+JD, -MJD), mjd_to_jd(+MJD, -JD)] convert MJDs to or\n\tfrom JDs. The relationship is simply MJD = JD-2400000.5.\n\\end{description}\nThe library code is valid for dates between\n\t 1 Mar 0004 = MJD -677422 = JD 1722578.5\nand\n\t22 Jan 3268 = MJD  514693 = JD 2914693.5.\n\n\\subsection{Examples}\nWhat day of the week was the 29th of December 1959?\n\\begin{quote}\\begin{verbatim}\n[eclipse 1]: lib(calendar).\n[eclipse 2]: date_to_mjd(29/12/1959, MJD), mjd_to_weekday(MJD,W).\nMJD = 36931\nW = tuesday\n\\end{verbatim}\\end{quote}\nWhat date and time is it now?\n\\begin{quote}\\begin{verbatim}\n[eclipse 3]: mjd_now(MJD), mjd_to_date(MJD,Date), mjd_to_time(MJD,Time).\nDate = 19 / 5 / 1999\nMJD = 51317.456238425926\nTime = 10 : 56 : 59.000000017695129\n\\end{verbatim}\\end{quote}\nHow many days are there in the 20th century?\n\\begin{quote}\\begin{verbatim}\n[eclipse 4]: N is date_to_mjd(1/1/2001) - date_to_mjd(1/1/1901).\nN = 36525\n\\end{verbatim}\\end{quote}\nThe library code does not detect invalid dates,\nbut this is easily done by converting a date to its MJD and back\nand checking whether they match:\n\\begin{quote}\\begin{verbatim}\n[eclipse 5]: [user].\nvalid_date(Date) :-\n        date_to_mjd(Date,MJD),\n        mjd_to_date(MJD,Date).\n\n[eclipse 6]: valid_date(29/2/1900).   % 1900 is not a leap year!\nno (more) solution.\n\\end{verbatim}\\end{quote}\n", "meta": {"hexsha": "0e02e992914eb8ee962317a661b42159e353ba23", "size": 5035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "usr/eclipseclp/documents/userman/umscalendar.tex", "max_stars_repo_name": "lambdaxymox/barrelfish", "max_stars_repo_head_hexsha": "06a9f54721a8d96874a8939d8973178a562c342f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-02-03T02:57:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T23:57:09.000Z", "max_issues_repo_path": "usr/eclipseclp/documents/userman/umscalendar.tex", "max_issues_repo_name": "lambdaxymox/barrelfish", "max_issues_repo_head_hexsha": "06a9f54721a8d96874a8939d8973178a562c342f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2016-03-22T14:44:32.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-18T13:30:29.000Z", "max_forks_repo_path": "usr/eclipseclp/documents/userman/umscalendar.tex", "max_forks_repo_name": "lambdaxymox/barrelfish", "max_forks_repo_head_hexsha": "06a9f54721a8d96874a8939d8973178a562c342f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 55, "max_forks_repo_forks_event_min_datetime": "2015-02-03T05:28:12.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T05:00:03.000Z", "avg_line_length": 41.6115702479, "max_line_length": 75, "alphanum_fraction": 0.7491559086, "num_tokens": 1522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.44507999657240793}}
{"text": "%\n% %CopyrightBegin%\n%\n% Copyright Ericsson AB 2017. All Rights Reserved.\n%\n% Licensed under the Apache License, Version 2.0 (the \"License\");\n% you may not use this file except in compliance with the License.\n% You may obtain a copy of the License at\n%\n%     http://www.apache.org/licenses/LICENSE-2.0\n%\n% Unless required by applicable law or agreed to in writing, software\n% distributed under the License is distributed on an \"AS IS\" BASIS,\n% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n% See the License for the specific language governing permissions and\n% limitations under the License.\n%\n% %CopyrightEnd%\n%\n\n\\chapter{Arithmetics}\n\n\\label{chapter:arithmetics}\n\n\\emph{We define the mathematical functions in terms of which the arithmetics of\n\\Erlang\\ are defined.  This chapter depends significantly on the international\nstandard document ISO/IEC 10967-1 \\cite{lia-1}, referenced in this\ntext as LIA-1\\index{LIA-1}.}\n\n\\ifStd\n\\emph{This chapter also contains the information needed for a\nLIA-1 language binding for \\StdErlang.}\n\\fi\n\n\\section{Notation}\n\n\\label{section:notation-arith}\n\nLet $\\INTS$\\index{Z@$\\INTS$ (the integers)} be the set of mathematical integers,\n$\\REALS$\\index{R@$\\REALS$ (the reals)} the set of\nreal numbers and $\\BOOLEANS$\\index{B@$\\BOOLEANS$ (the Booleans)} the set of Booleans, denoted by\n\\B{true}\\index{true@\\B{true}}\nand \\B{false}\\index{false@\\B{false}}.\n\nThere are four exceptional values\\index{arithmetic!exceptional values}\nthat are not numbers but may be the\nresults of the LIA-1 functions defined in this chapter:\n\\B{integer\\_overflow}\\index{integer_overflow@\\B{integer\\_overflow}},\n\\B{floating\\_overflow}\\index{floating_overflow@\\B{floating\\_overflow}},\n\\B{underflow}\\index{underflow@\\B{underflow}} and\n\\B{undefined}\\index{undefined@\\B{undefined}}.\n\n\\ifStd\nAn implementation conforming to IEC 559\\index{IEC 559} \\cite{iec559} has three additional values\nthat are not numbers but may appear as input to floating-point arithmetic operations\nand can be returned from such operations:\n\\B{not_a_number}\\index{not_a_number@\\B{not_a_number}},\n\\B{positive_infinity}\\index{positive_infinity@\\B{positive_infinity}}\nand \\B{negative_infinity}\\index{negative_infinity@\\B{negative_infinity}}.\n\\fi\n\nThe following definitions are restated from LIA-1\\index{LIA-1}.\nFor $x\\in\\REALS$, the notation $\\lfloor x\\rfloor$ stands for the largest integer not greater than $x$:\n\\[\\lfloor x\\rfloor\\in\\INTS\\text{\\quad and\\quad}x-1<\\lfloor x\\rfloor\\leq x\\]\nand $\\mathit{tr}(x)$ stands for the integer part of $x$ (truncated towards 0):\n\\begin{alignat*}{2}\n\\mathit{tr}(x) &= \\lfloor x\\rfloor && \\qquad\\text{if $x\\geq0$;} \\\\\n               &= -\\lfloor-x\\rfloor && \\qquad\\text{if $x<0$.}\n\\end{alignat*}\n\nThe following definitions are restated from the 1995 working draft of\nthe international standard document ISO/IEC 10967-2 \\cite{lia-2},\nreferenced in this text as LIA-2\\index{LIA-2}.\n\nLet $S$ be a subset of $\\REALS$, closed under (arithmetic) negation.\nThe following are four rounding functions\\index{rounding function}\nfor mapping values of $\\REALS$ into $S$.\n\\index{  floor@$\\lfloor\\cdot\\rfloor_S$|(}\n\\index{  ceiling@$\\lceil\\cdot\\rceil_S$|(}\n\\index{floor@$\\mathit{floor}_S$|(}\n\\index{ceiling@$\\mathit{ceiling}_S$|(}\n\\index{truncate@$\\mathit{truncate}_S$|(}\n\\index{nearest@$\\mathit{nearest}_S$|(}\nGiven any $x\\in\\REALS$,\n\\begin{alignat*}{2}\n\\lfloor x\\rfloor_S &= \\max \\{\\,z\\in S \\mid z \\leq x\\,\\} \\displaybreak[0]\\\\[\\smallskipamount]\n\\lceil x\\rceil_S &= \\min \\{\\,z\\in S \\mid z \\geq x\\,\\} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{truncate}_S(x) &= \\lfloor x\\rfloor_S && \\qquad\\text{if $x\\geq0$;} \\\\\n                       &= \\lceil x\\rceil_S && \\qquad\\text{if $x<0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{nearest}_S(x) &= \\lfloor x\\rfloor_S && \\qquad\\text{if $|\\lfloor x\\rfloor_S - x| < |x - \\lceil x\\rceil_S|$;} \\\\\n                      &= \\lceil x\\rceil_S && \\qquad\\text{if $|\\lfloor x\\rfloor_S - x| > |x - \\lceil x\\rceil_S|$;} \\\\\n                      &= \\text{$\\lfloor x\\rfloor_S$ or $\\lceil x\\rceil_S$} && \\qquad\\text{if $|\\lfloor x\\rfloor_S - x| = |x - \\lceil x\\rceil_S|$.}\n\\end{alignat*}\nIn addition it must hold that $\\mathit{nearest}_S(-x)=-\\mathit{nearest}_S(x)$.\n\nWhen the subscript $S$ is omitted, $\\INTS$ is assumed.\n\nWe may write $\\mathit{floor}_S(x)$ for $\\lfloor x\\rfloor_S$ and\n$\\mathit{ceiling}_S(x)$ for $\\lceil x\\rceil_S$.\n\nNote that\n\\begin{itemize}\n\\item $\\mathit{floor}_S(x)$ rounds $x$ towards negative infinity,\n\\item $\\mathit{ceiling}_S(x)$ rounds $x$ towards positive infinity,\n\\item $\\mathit{truncate}_S(x)$ rounds $x$ towards zero and\n\\item $\\mathit{nearest}_S(x)$ rounds $x$ to the nearest value in $S$.\n\\end{itemize}\n\\index{  floor@$\\lfloor\\cdot\\rfloor_S$|)}\n\\index{  ceiling@$\\lceil\\cdot\\rceil_S$|)}\n\\index{floor@$\\mathit{floor}_S$|)}\n\\index{ceiling@$\\mathit{ceiling}_S$|)}\n\\index{truncate@$\\mathit{truncate}_S$|)}\n\\index{nearest@$\\mathit{nearest}_S$|)}\nWhen we write $[i,j]$\\index{ interval closed@$[\\cdot,\\cdot]$},\nwhere $i$ and $j$ are integers, we mean the\nset $\\{\\,x\\in\\INTS \\mid i\\leq x\\leq j\\,\\}$.\nWhen we write $[i,j)$\\index{ interval open@$[\\cdot,\\cdot)$},\nwhere $i$ and $j$ are integers, we mean the\nset $\\{\\,x\\in\\INTS \\mid i\\leq x< j\\,\\}$.\n\n\\section{The integer type}\n\n\\label{section:integer-type}\n\\index{integer!properties|(}\n\n\\ifStd\nA \\StdErlang\\ implementation must provide at least one integer type that\nconforms with LIA-1.  In this document that type is assumed to be the\nonly integer type.\n\\fi\n\\index{I@$I$|(}\nThe set of numbers that can be represented by the integer type is\ncalled $I$ and is a subset of $\\INTS$\\index{Z@$\\INTS$ (the integers)}.\nLIA-1 requires $I$ to be characterized by four parameters:\n\\index{bounded@\\I{bounded}|(}\n\\index{modulo@\\I{modulo}|(}\n\\index{minint@\\I{minint}|(}\n\\index{maxint@\\I{maxint}|(}\n\\begin{textdisplay}\n\\begin{tabular}{@{}ll@{}}\n$\\I{bounded}\\in\\BOOLEANS$ & (whether the set $I$ is finite) \\\\\n$\\I{modulo}\\in\\BOOLEANS$ & (whether out-of-bounds results ``wrap'') \\\\\n$\\I{minint}\\in I$ & (the smallest integer in $I$) \\\\\n$\\I{maxint}\\in I$ & (the largest integer in $I$)\n\\end{tabular}\n\\end{textdisplay}\n\\ifStd\nFor the integer type of a \\StdErlang\\ implementation it is required\nthat \\I{modulo} is \\B{false}, while \\I{bounded} may be either \\B{true}\nor \\B{false}.\n\\begin{itemize}\n\\item If \\I{bounded} is \\B{false}, then $I=\\INTS$ and the values of \\I{minint} and\n\\I{maxint} are not meaningful.\n\\item If \\I{bounded} is \\B{true}, then\n$I = \\{\\,x \\in \\INTS \\mid \\I{minint} \\leq x \\leq \\I{maxint}\\,\\}$\nwhere\n$\\I{maxint} \\geq 2^{59}-1$ and either\n$\\I{minint} = -(\\I{maxint}+1)$ or $\\I{minint} = -\\I{maxint}$.\n\\end{itemize}\n\\fi\n\\ifOld\nFor the integer type of \\Erlang, \\I{modulo} and \\I{bounded} are \\B{false}.\nAs \\I{bounded} is \\B{false}, $I=\\INTS$ and the values of \\I{minint} and\n\\I{maxint} are not meaningful.\n\\fi\n\\index{bounded@\\I{bounded}|)}\n\\index{modulo@\\I{modulo}|)}\n\\index{minint@\\I{minint}|)}\n\\index{maxint@\\I{maxint}|)}\n\\Erlang\\ has three additional parameters:\n\\index{fixnum@\\I{fixnum}|(}\n\\index{minfixnum@\\I{minfixnum}|(}\n\\index{maxfixnum@\\I{maxfixnum}|(}\n\\begin{textdisplay}\n\\begin{tabular}{@{}ll@{}}\n$\\I{fixnum}\\in\\BOOLEANS$ & (whether there are ``fixnums'') \\\\\n$\\I{minfixnum}\\in I$ & (the smallest fixnum in $I$) \\\\\n$\\I{maxfixnum}\\in I$ & (the largest fixnum in $I$)\n\\end{tabular}\n\\end{textdisplay}\n\\ifStd\nIf \\I{fixnum} is \\B{true}, then it must hold that\n\\[\\I{minint} \\leq \\I{minfixnum} \\leq \\I{maxfixnum} \\leq \\I{maxint}.\\]\n\\fi\n\\ifOld\n\\I{fixnum} is \\B{true}, \\I{minfixnum} is $-2^{27}$ and\n\\I{maxfixnum} is $2^{27}-1$.\n\\fi\n\\index{I@$I$|)}\n\n\\index{integer!fixnum|(}\n\\index{I f@$I_f$|(}\n\\ifStd If \\I{fixnum} is \\B{true}, let \\fi\n\\ifOld Let \\fi\n$I_f = \\{\\,x\\in I \\mid \\I{minfixnum} \\leq x \\leq \\I{maxfixnum}\\,\\}$.\n\\ifStd\nOtherwise, let $I_f = \\emptyset$.\n\\fi\n$I_f$ is\n\\ifStd meant to be \\fi\nthe set of ``fixnums'', the representation of which can utilize the\nmost efficient representation of integers in the machine, typically occupying\none word of memory.\n\\index{I f@$I_f$|)}\n\\ifStd\nThe values of \\I{minfixnum} and \\I{maxfixnum} for an implementation in which\n\\I{fixnum} is \\B{true} should be chosen\nso that when both the operands and the result of an integer addition,\nsubtraction, multiplication or division are in $I_f$, it should be\npossible to utilize the most efficient machine instructions for\ncomputing the operation.  Typically one would expect $\\I{minfixnum} =\n-(\\I{maxfixnum}+1)$ but this is not required. For example, an\nimplementation may have ``unsigned'' fixnums in which case\n\\I{minfixnum} and \\I{maxfixnum} could be $0$ and $2^{28}-1$,\nrespectively.\n\\fi\n\\index{integer!fixnum|)}\n\\index{fixnum@\\I{fixnum}|)}\n\\index{minfixnum@\\I{minfixnum}|)}\n\\index{maxfixnum@\\I{maxfixnum}|)}\n\n\\index{integer!bignum|(}\nLet $I_b = I \\setminus I_f$\\index{I b@$I_b$}.\n$I_b$ is the set of ``bignums'', the representation of which\nmay require arbitrary amounts of memory.\nAn implementation for which $I_b\\neq\\emptyset$\n\\ifOld, such as \\Erlang,\\fi\\ is said to have bignums.\n\\index{integer!bignum|)}\n\n\\ifStd\nAs the parameter \\I{modulo} is always \\B{false} for the integer type,\nit is not made available to programs.  The other parameters are\navailable through the BIFs\n\\T{integer:bounded/0}, \\T{integer:min_fixnum/0},\n\\T{integer:max_fix\\-num/0},\n\\T{integer:min_int/0} and\n\\T{integer:max_int/0} (\\S\\ref{section:integer-module}).\n\\fi\n\\index{integer!properties|)}\n\n\\section{Integer operations}\n\n\\label{section:integer-operations}\n\\index{integer!arithmetic operations|(}\n\nElsewhere in this specification we express the integer arithmetic\noperations of \\Erlang\\ in terms of the following functions from LIA-1:\n\\begin{xxalignat}{2}\n&\\lefteqn{\\mathit{add}_I : I\\times I\\to I\\cup\\{\\B{integer\\_overflow}\\}} \\\\\n&&&(x,y)\\mapsto\\text{the sum of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{sub}_I : I\\times I\\to I\\cup\\{\\B{integer\\_overflow}\\}} \\\\\n&&& (x,y)\\mapsto\\text{the difference of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{mul}_I : I\\times I\\to I\\cup\\{\\B{integer\\_overflow}\\}} \\\\\n&&& (x,y)\\mapsto\\text{the product of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{div}_I : I\\times I\\to I\\cup\\{\\B{integer\\_overflow},\\B{undefined}\\}} \\\\\n&&& (x,y)\\mapsto\\text{the quotient of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{rem}_I : I\\times I\\to I\\cup\\{\\B{undefined}\\} && (x,y)\\mapsto\\text{the remainder of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{mod}_I : I\\times I\\to I\\cup\\{\\B{undefined}\\} && (x,y)\\mapsto\\text{$x$ modulo $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{neg}_I : I\\to I\\cup\\{\\B{integer\\_overflow}\\} && (x)\\mapsto\\text{the (arithmetic) negation of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{abs}_I : I\\to I\\cup\\{\\B{integer\\_overflow}\\} && (x)\\mapsto\\text{absolute value of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n\\ifStd\n&\\mathit{sign}_I : I\\to I  && (x)\\mapsto\\text{the sign of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n\\fi\n&\\mathit{eq}_I : I\\times I\\to\\BOOLEANS  && (x,y)\\mapsto\\text{$x$ equals $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{neq}_I : I\\times I\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ does not equal $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{lss}_I : I\\times I\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is less than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{leq}_I : I\\times I\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is not greater than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{gtr}_I : I\\times I\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is greater than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{geq}_I : I\\times I\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is not less than $y$}\n\\end{xxalignat}\nFor each function, LIA-1 states a number of axioms.\n\\ifStd\nA \\StdErlang\\ implementation must satisfy all of these with the added\nrestriction that $\\mathit{modulo}=\\B{false}$\\index{modulo@\\I{modulo}}\n(\\S\\ref{section:integer-type}),\n\\index{minint@\\I{minint}|(}\n\\index{maxint@\\I{maxint}|(}\neither $\\mathit{minint}=-\\mathit{maxint}$ or $\\mathit{minint}=-(\\mathit{maxint}+1)$\n(when $\\mathit{bounded}=\\B{true}$\\index{bounded@\\I{bounded}}),\n\\index{minint@\\I{minint}|)}\n\\index{maxint@\\I{maxint}|)} and\n$\\mathit{mod}_I=\\mathit{mod}_I^a$.\n\\StdErlang\\ provides operators for both the pairs $\\mathit{div}_I^f/\\mathit{rem}_I^f$ and\n$\\mathit{div}_I^t/\\mathit{rem}_I^t$.\n\\fi\n\\ifOld\nIn \\OldErlang, $\\mathit{modulo}=\\B{false}$\\index{modulo@\\I{modulo}} (\\S\\ref{section:integer-type}),\n$\\mathit{bounded}=\\B{false}$\\index{bounded@\\I{bounded}} and $\\mathit{mod}_I=\\mathit{mod}_I^a$.\nFor $\\mathit{div}$ and $\\mathit{rem}$ the pair $\\mathit{div}_I^t/\\mathit{rem}_I^t$ is provided.\n\\fi\n\nFor convenience we reproduce the\nstrengthened axioms of Section~5.1.3 of LIA-1 here:\n\\begin{alignat*}{2}\n\\mathit{add}_I(x,y) &= x+y && \\qquad\\text{if $x+y\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $x+y\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{sub}_I(x,y) &= x-y && \\qquad\\text{if $x-y\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $x-y\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{mul}_I(x,y) &= x*y && \\qquad\\text{if $x*y\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $x*y\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{div}_I^f(x,y) &= \\lfloor x/y\\rfloor && \\qquad\\text{if $y\\neq0$ and $\\lfloor x/y\\rfloor\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $y\\neq0$ and $\\lfloor x/y\\rfloor\\notin I$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{rem}_I^f(x,y) &= x-(\\lfloor x/y\\rfloor*y) && \\qquad\\text{if $y\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{div}_I^t(x,y) &= \\mathit{tr}(x/y) && \\qquad\\text{if $y\\neq0$ and $\\mathit{tr}(x/y)\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $y\\neq0$ and $\\mathit{tr}(x/y)\\notin I$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{rem}_I^t(x,y) &= x-(\\mathit{tr}(x/y)*y) && \\qquad\\text{if $y\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{mod}_I^a(x,y) &= x-(\\lfloor x/y\\rfloor*y) && \\qquad\\text{if $y\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{neg}_I(x)   &= -x && \\qquad\\text{if $-x\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $-x\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{abs}_I(x)   &= |x| && \\qquad\\text{if $|x|\\in I$;} \\\\\n                    &= \\B{integer\\_overflow} && \\qquad\\text{if $|x|\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\ifStd\n\\mathit{sign}_I(x)  &= 1 && \\qquad\\text{if $x>0$;} \\\\\n                    &= 0 && \\qquad\\text{if $x=0$;} \\\\\n                    &= -1 && \\qquad\\text{if $x<0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\fi\n\\mathit{eq}_I(x,y)  &= \\B{true} && \\qquad\\text{if $x=y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\neq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{neq}_I(x,y) &= \\B{true} && \\qquad\\text{if $x\\neq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x=y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{lss}_I(x,y) &= \\B{true} && \\qquad\\text{if $x<y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\geq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{leq}_I(x,y) &= \\B{true} && \\qquad\\text{if $x\\leq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x>y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{gtr}_I(x,y) &= \\B{true} && \\qquad\\text{if $x>y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\leq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{geq}_I(x,y) &= \\B{true} && \\qquad\\text{if $x\\geq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x<y$.}\n\\end{alignat*}\n\n\\iffalse\nWhen these functions are used in other chapters, it will sometimes be\nconvenient to write applications of them to \\Erlang\\ integer terms,\nrather than to the integers that these terms denote.  Similarly we\nwill sometimes use the result of one of the mathematical functions as\nif it were an \\Erlang\\ integer term.\n\\fi\n\\index{integer!arithmetic operations|)}\n\n\\section{The floating-point type}\n\n\\label{section:float-type}\n\\index{float!properties|(}\n\n\\ifStd\nA \\StdErlang\\ implementation must provide at least one floating-point\ntype that conforms with LIA-1.  In this document that type is assumed\nto be the only floating-point type.\n\\fi\n\\index{F@$F$|(}\nThe set of numbers that can be\nrepresented by the float type is called $F$ and is a finite subset of\n$\\REALS$\\index{R@$\\REALS$ (the reals)}.  $F$ may contain both\nnormalized and denormalized values (cf.~Section~5.2 of LIA-1);\n$F_N$ stands for the set of normalized values in $F$.\n\nLIA-1 requires $F$ to be characterized by five parameters:\n\\index{r@$r$|(}\n\\index{p@$p$|(}\n\\index{emin@$\\mathit{emin}$|(}\n\\index{emax@$\\mathit{emax}$|(}\n\\index{denorm@$\\mathit{denorm}$|(}\n\\begin{textdisplay}\n\\begin{tabular}{@{}ll@{}}\n$p\\in\\INTS$ & (the precision of $F$) \\\\\n$r\\in\\INTS$ & (the radix of $F$) \\\\\n$\\I{emin}\\in\\INTS$ & (the smallest exponent of $F$) \\\\\n$\\I{emax}\\in\\INTS$ & (the largest exponent of $F$) \\\\\n$\\I{denorm}\\in\\BOOLEANS$ & (whether $F$ contains denormalized values)\n\\end{tabular}\n\\end{textdisplay}\n\n\\ifOld\n\\OldErlang\\ directly uses the float representation of the underlying\nprocessor so these parameters are not defined.  It is guaranteed,\nhowever, that the size of a float is at least 64 bits.\n\\iffalse\n$r$ is $2$,\n$p$ is XXX,\n$\\mathit{emin}$ is XXX,\n$\\mathit{emax}$ is XXX and\n$\\mathit{denorm}$ is \\B{true}.\n\\fi\\fi\n\n\\ifStd\nThese parameters are available through the BIFs\n\\T{float:precision/0}, \\T{float:radix/0},\n\\T{float:e_min/0},\n\\T{float:e_max/0} and \\T{float:de\\-norm/0}, respectively (\\S\\ref{section:float-module}).\n\nIn addition to the requirements of Section~5.2 of LIA-1, the following must\nhold for the floating-point type of a \\StdErlang\\ implementation\n(from Section~A.5.2.0.2 of LIA-1):\n\\begin{itemize}\n\\item $r$ should be even,\n\\item $r^{p-1}\\geq 10^6$,\n\\item $\\I{emin}-1 \\leq k*(p-1)$ with $k\\geq 2$ and $k$ as large an integer as practical,\n\\item $\\I{emax} > k*(p-1)$, and\n\\item $-2 \\leq (emin-1) + emax \\leq 2$.\n\\end{itemize}\n\n\\index{r@$r$|)}\n\\index{p@$p$|)}\n\\index{emin@$\\mathit{emin}$|)}\n\\index{emax@$\\mathit{emax}$|)}\n\\index{denorm@$\\mathit{denorm}$|)}\n\nThe range and granularity of $F$ are characterized by four derived\nconstants:\n\\index{fmax@$\\mathit{fmax}$|(}\n\\index{fmin@$\\mathit{fmin}$|(}\n\\index{fminN@$\\mathit{fmin}_N$|(}\n\\index{epsilon@$\\mathit{epsilon}$|(}\n\\begin{textdisplay}\n\\begin{tabular}{@{}ll@{}}\n$\\mathit{fmax}\\in F$ & (the value of largest magnitude in $F$) \\\\\n$\\mathit{fmin}\\in F$ & (the value of smallest magnitude in $F$) \\\\\n$\\mathit{fmin}_N\\in F$ & (the smallest normalized value in $F$) \\\\\n$\\mathit{epsilon}\\in F$ & (the largest relative representation error in $F_N$)\n\\end{tabular}\n\\end{textdisplay}\n\\index{fmax@$\\mathit{fmax}$|)}\n\\index{fmin@$\\mathit{fmin}$|)}\n\\index{fminN@$\\mathit{fmin}_N$|)}\n\\index{epsilon@$\\mathit{epsilon}$|)}\n\\index{F@$F$|)}\n\n\\iffalse\n\\ifOld\nFor \\OldErlang,\n$\\mathit{fmax}$ is XXX,\n$\\mathit{fmin}$ is XXX,\n$\\mathit{fmin}_N$ is XXX and\n$\\mathit{epsilon}$ is XXX.\n\\fi\\fi\n\nThese derived constants are available through the BIFs\n\\T{float:f_max/0}, \\T{float:f_min/0},\n\\T{float:f_min_norm/0} and\n\\T{float:epsilon/0}, respectively (\\S\\ref{section:float-module}).\n\\fi\n\\index{float!properties|)}\n\n\\section{Floating-point operations}\n\n\\label{section:float-operations}\n\\index{float!arithmetic operations|(}\n\nElsewhere in this specification we express the floating-point\narithmetic operations of \\Erlang\\ in terms of the following functions\nfrom LIA-1:\n\\begin{xxalignat}{2}\n&\\lefteqn{\\mathit{add}_F : F\\times F\\to F\\cup\\{\\B{floating\\_overflow},\\B{underflow}\\}} \\\\\n &&& (x,y)\\mapsto\\text{the sum of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{sub}_F : F\\times F\\to F\\cup\\{\\B{floating\\_overflow},\\B{underflow}\\}} \\\\\n &&& (x,y)\\mapsto\\text{the difference of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{mul}_F : F\\times F\\to F\\cup\\{\\B{floating\\_overflow},\\B{underflow}\\}} \\\\\n &&& (x,y)\\mapsto\\text{the product of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{div}_F : F\\times F\\to F\\cup\\{\\B{floating\\_overflow},\\B{underflow},\\B{undefined}\\}} \\\\\n &&& (x,y)\\mapsto\\text{the quotient of $x$ and $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{neg}_F : F\\to F && (x)\\mapsto\\text{the (arithmetic) negation of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{abs}_F : F\\to F && (x)\\mapsto\\text{absolute value of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{sign}_F : F\\to I && (x)\\mapsto\\text{the sign of $x$}\\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{exponent}_F : F\\to F\\cup\\{\\B{undefined}\\}} \\\\\n &&& (x)\\mapsto\\text{the exponent of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{fraction}_F : F\\to F && (x)\\mapsto\\text{$x$ scaled by a power of $r$ to the range $[1/r,1)$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{scale}_F : F\\times I\\times F\\to F\\cup\\{\\B{floating\\_overflow},\\B{underflow}\\}} \\\\\n &&& (x,n)\\mapsto\\text{the product of $x$ and $r^n$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{succ}_F : F\\to F\\cup\\{\\B{floating\\_overflow}\\}} \\\\\n &&& (x)\\mapsto\\text{the least float greater than $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{pred}_F : F\\to F\\cup\\{\\B{floating\\_overflow}\\}} \\\\\n &&& (x)\\mapsto\\text{the greatest float less than $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{ulp}_F : F\\to F\\cup\\{\\B{underflow},\\B{undefined}\\}} \\\\\n &&& (x)\\mapsto\\text{the value of one unit in the last place of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{trunc}_F : F\\times I\\to F && (x)\\mapsto\\text{$x$ with the low $p-n$ digits zeroed} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\lefteqn{\\mathit{round}_F : F\\times I\\to F\\cup\\{\\B{floating\\_overflow}\\}} \\\\\n &&& (x)\\mapsto\\text{$x$ rounded to $n$ significant digits} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{intpart}_F : F\\to F && (x)\\mapsto\\text{the integer part of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{fractpart}_F : F\\to F && (x)\\mapsto\\text{$x$ minus the integer part of $x$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{eq}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ equals $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{neq}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ does not equal $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{lss}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is less than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{leq}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is not greater than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{gtr}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is greater than $y$} \\displaybreak[0]\\\\[\\smallskipamount]\n&\\mathit{geq}_F : F\\times F\\to\\BOOLEANS && (x,y)\\mapsto\\text{$x$ is not less than $y$}\n\\end{xxalignat}\n\\ifStd\n(LIA-1 specifies that the type of $\\mathit{sign}_F$ should be $F\\to F$ but in \\Erlang\\\nthe resulting integer can be automatically coerced to a float and an integer is more\nuseful than a float for dispatching upon.)\n\\fi\nFor each function, LIA-1 states a number of axioms.\n\\ifStd A \\StdErlang\\ implementation must satisfy all of these axioms. \\fi\nFor convenience we reproduce the axioms of Section~5.2.7 of LIA-1 here:\n\\begin{alignat*}{2}\n\\mathit{add}_F(x,y) &= \\mathit{result}_F(\\mathit{add}_F^*(x+y),\\mathit{rnd}_F) && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{sub}_F(x,y) &= \\mathit{add}_F(x,-y) && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{mul}_F(x,y) &= \\mathit{result}_F(x*y,\\mathit{rnd}_F) && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{div}_F(x,y) &= \\mathit{result}_F(x/y,\\mathit{rnd}_F) && \\qquad\\text{if $y\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $y=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{neg}_F(x)   &= -x &&  \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{abs}_F(x)   &= |x| && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{sign}_F(x)  &= 1 && \\qquad\\text{if $x>0$;} \\\\\n                    &= 0 && \\qquad\\text{if $x=0$;} \\\\\n                    &= -1 && \\qquad\\text{if $x<0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{exponent}_F(x) &= \\lfloor(\\log_r|x|\\rfloor+1 && \\qquad\\text{if $x\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $x=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{fraction}_F(x) &= x/r^{\\mathit{exponent}_F(x)} && \\qquad\\text{if $x\\neq0$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $x=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{scale}_F(x,n) &= \\mathit{result}_F(x*r^n,\\mathit{rnd}_F) && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{succ}_F(x)  &= \\min\\{\\,z\\in F \\mid z > x\\,\\} && \\qquad\\text{if $x\\neq\\mathit{fmax}$;} \\\\\n                    &= \\B{floating\\_overflow} && \\qquad\\text{if $x=\\mathit{fmax}$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{pred}_F(x)  &= \\max\\{\\,z\\in F \\mid z < x\\,\\} && \\qquad\\text{if $x\\neq-\\mathit{fmax}$;} \\\\\n                    &= \\B{floating\\_overflow} && \\qquad\\text{if $x=-\\mathit{fmax}$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{ulp}_F(x)   &= r^{e_F(x)-p} && \\qquad\\text{if $x\\neq0$ and $r^{e_F(x)-p}\\in F$;} \\\\\n                    &= \\B{underflow} && \\qquad\\text{if $x\\neq0$ and $r^{e_F(x)-p}\\notin F$;} \\\\\n                    &= \\B{undefined} && \\qquad\\text{if $x=0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{trunc}_F(x) &= \\lfloor x/r^{e_F(x)-n}\\rfloor*r^{e_F(x)-n} && \\qquad\\text{if $x\\geq0$;} \\\\\n                    &= -\\mathit{trunc}_F(-x,n) && \\qquad\\text{if $x<0$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{round}_F(x) &= \\mathit{rn}_F(x,n) && \\qquad\\text{if $|\\mathit{rn}_F(x,n)|\\leq\\mathit{fmax}$;} \\\\\n                    &= \\B{floating\\_overflow} && \\qquad\\text{if $|\\mathit{rn}_F(x,n)|>\\mathit{fmax}$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{intpart}_F(x) &= \\mathit{sign}_F(x)*\\lfloor|x|\\rfloor && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{fractpart}_F(x) &= x-\\mathit{intpart}_F(x) && \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{eq}_F(x,y)  &= \\B{true} && \\qquad\\text{if $x=y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\neq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{neq}_F(x,y) &= \\B{true} && \\qquad\\text{if $x\\neq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x=y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{lss}_F(x,y) &= \\B{true} && \\qquad\\text{if $x<y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\geq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{leq}_F(x,y) &= \\B{true} && \\qquad\\text{if $x\\leq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x>y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{gtr}_F(x,y) &= \\B{true} && \\qquad\\text{if $x>y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x\\leq y$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{geq}_F(x,y) &= \\B{true} && \\qquad\\text{if $x\\geq y$;} \\\\\n                    &= \\B{false} && \\qquad\\text{if $x<y$.}\n\\end{alignat*}\nThe functions are expressed in terms of a number of helper functions and sets:\n\\begin{itemize}\n\\item The set $F^*$\\index{F*@$F^*$} is $F$ extended with all numbers having the same precision as numbers\nin $F_N$ but larger magnitude.\n\\item The approximate addition function $\\mathit{add}_F^* : F\\times F\\to\\REALS$ is as\ndescribed in Section~5.2.4 of LIA-1, ideally but not necessarily such that\n$\\mathit{add}_F^*(x,y)=x+y$.\n\\item The functions $e_F : \\REALS\\to\\INTS$ and $\\mathit{rn}_F : F\\times\\INTS\\to F^*$\nare as described in Section~5.2.7 of LIA-1, i.e., they are defined such that\n\\begin{alignat*}{2}\ne_F(x) &= \\lfloor\\log_r|x|\\rfloor+1 && \\qquad\\text{if $|x|\\geq\\mathit{fmin}_N$;} \\\\\n       &= \\mathit{emin} && \\qquad\\text{if $|x|<\\mathit{fmin}_N$.} \\displaybreak[0]\n\\end{alignat*}\nand\n\\[\\mathit{rn}_F(x,n) = \\mathit{sign}_F(x)*\\lfloor|x|/r^{e_F(x)-n}+1/2\\rfloor*r^{e_F(x)-n}\\]\n\\item $\\mathit{rnd}_F : \\REALS\\to F^*$ is the rounding function\\index{rounding function}\nused when taking an exact\nresult in $\\REALS$ to a $p$-digit approximation.  It must satisfy the requirements\nstated in Sections~5.2.5 and~5.2.8 of LIA-1.  There are two derived constants characterizing\n$\\mathit{rnd}_F$:\n\\begin{itemize}\n\\item $\\I{rnd\\_error}\\in\\REALS$ is the maximum rounding error in ulps;\n\\item $\\I{rnd\\_style}\\in\\{\\B{nearest},\\B{truncate},\\B{other}\\}$ is the rounding style.\n\\end{itemize}\n\\ifOld\nFor \\OldErlang, $\\mathit{rnd\\_error}$ is XXX and $\\mathit{rnd\\_style}$\nis XXX.\n\\fi\n\\ifStd\nThey are available at run time through the BIFs\n\\T{float:rnd_error/0} and\n\\T{float:rnd_style/0} (\\S\\ref{section:float-module}).\n\\fi\n\\item $\\mathit{result}_F : \\REALS\\times(\\REALS\\to F^*)\\to\nF\\cup\\{\\B{floating\\_overflow},\\B{underflow}\\}$ is the function described in Section~5.2.6\nof LIA-1.  The value of $\\mathit{result}_F(x,\\mathit{rnd})$, where $x\\in\\REALS$ and\n\\I{rnd} is a rounding function in $\\REALS\\to F^*$, is the result of applying the\nrounding function to $x$, provided that the result is in $F$.\n\\ifStd\nIf $|x|$ is greater\nthan zero but less than \\I{fmin}, $\\mathit{result}_F(x,\\mathit{rnd})$ can always be\n\\B{underflow} but may be $\\mathit{rnd}(x)$ if \\I{denorm} is \\B{true} and no\ndenormalization loss occurs at $x$.\nA \\StdErlang\\ implementation for which\n\\I{denorm} is \\B{true} shall document how this choice is made.\n\\fi\n\\ifOld\nIf $|x|$ is greater\nthan zero but less than \\I{fmin}, then XXX???\n\\fi\n\\end{itemize}\n\\index{float!arithmetic operations|)}\n\n\\section{Conversions}\n\n\\label{section:conversions}\n\\index{conversion!arithmetic|(}\n\n\\ifStd\nIn a \\StdErlang\\ implementation with more than one integer type or more\nthan one floating-point type, conversion functions between integer\ntypes and between floating-point types shall be provided that satisfy\nthe requirements in Section~5.3 of LIA-1.\n\\fi\n\nLet $\\mathit{nearest}_{I\\to F} : I\\to F\\cup\\{\\B{floating_overflow}\\}$\nbe defined as\n\\[\\mathit{nearest}_{I\\to F}(x) = \\mathit{result}_F(x,\\mathit{nearest}_F),\\]\nwhere $\\mathit{result}_F$ is as in \\S\\ref{section:float-operations}\n(cf.~Section~5.2.6 of LIA-1) and $\\mathit{nearest}_F$ is a\nrounding-to-nearest function for $F$ (\\S\\ref{section:notation-arith}).\n\nDefine the following four functions:\n\\begin{alignat*}{2}\n\\mathit{floor}_{F\\to I}(x) &= \\mathit{floor}_Z(x) && \\qquad\\text{if $\\mathit{floor}_Z(x)\\in I$;} \\\\\n       &= \\B{integer\\_overflow} && \\qquad\\text{if $\\mathit{floor}_Z(x)\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{ceiling}_{F\\to I}(x) &= \\mathit{ceiling}_Z(x) && \\qquad\\text{if $\\mathit{ceiling}_Z(x)\\in I$;} \\\\\n       &= \\B{integer\\_overflow} && \\qquad\\text{if $\\mathit{ceiling}_Z(x)\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{truncate}_{F\\to I}(x) &= \\mathit{truncate}_Z(x) && \\qquad\\text{if $\\mathit{truncate}_Z(x)\\in I$;} \\\\\n       &= \\B{integer\\_overflow} && \\qquad\\text{if $\\mathit{truncate}_Z(x)\\notin I$.} \\displaybreak[0]\\\\[\\smallskipamount]\n\\mathit{nearest}_{F\\to I}(x) &= \\mathit{nearest}_Z(x) && \\qquad\\text{if $\\mathit{nearest}_Z(x)\\in I$;} \\\\\n       &= \\B{integer\\_overflow} && \\qquad\\text{if $\\mathit{nearest}_Z(x)\\notin I$.}\n\\end{alignat*}\nNote that the four functions $\\mathit{floor}_Z$, $\\mathit{ceiling}_Z$,\n$\\mathit{truncate}_Z$ and $\\mathit{nearest}_Z$ meet the requirements\nin Section~5.3 of LIA-1 for being used as the rounding function\n$\\mathit{rnd}_{F\\to I}$ in a conversion function $\\mathit{cvt}_{F\\to\nI}$.\n\\index{conversion!arithmetic|)}\n\n\\section{Representation and evaluation}\n\n\\label{section:eval-notation}\n\nThe purpose of this section is to define notation and terminology that is\nused in the subsequent chapters.\n\n\\index{Re@$\\Re[\\cdot]$|(}\n\\begin{itemize}\n\\item If $i\\in I$, then $\\Re[i]$ is the \\Erlang\\ integer representing $i$.\n\\item If $f\\in F$, then $\\Re[f]$ is the \\Erlang\\ float representing $f$. \n\\item If $b\\in\\BOOLEANS$, i.e., \\B{true} or \\B{false}, then $\\Re[b]$\nis the \\Erlang\\ Boolean atom representing $b$.  That is, \n$\\Re[\\B{true}]=\\T{true}$ and $\\Re[\\B{false}]=\\T{false}$.\n\\item If $x$ is one of %the exceptional values\n\\B{integer\\_overflow},\n\\B{floating\\_overflow}, \\B{underflow} and \\B{undefined}, then\n$\\Re[x]$ is\n\\ifStd\nthe \\Erlang\\ atom given by Table~\\ref{table:arith-exits}.\n\\fi\n\\ifOld\nthe \\Erlang\\ atom \\T{badarith}.\n\\fi\n\\end{itemize}\n\\index{Re@$\\Re[\\cdot]$|)}\n\n\\ifStd\n\\begin{table}\n\\begin{center}\n\\index{integer_overflow@\\B{integer\\_overflow}|(}\n\\index{floating_overflow@\\B{floating\\_overflow}|(}\n\\index{underflow@\\B{underflow}|(}\n\\index{undefined@\\B{undefined}|(}\n\\index{integer_overflow exit signal@\\T{integer\\_overflow} exit signal|(}\n\\index{float_overflow exit signal@\\T{float\\_overflow} exit signal|(}\n\\index{float_underflow exit signal@\\T{float\\_underflow} exit signal|(}\n\\index{undefined_arith exit signal@\\T{undefined_arith} exit signal|(}\n\\begin{tabular}{@{}ll@{}}\n\\hline\nExceptional value & Exit reason \\\\\n\\hline\n\\B{integer\\_overflow} & \\T{integer_overflow} \\\\\n\\B{floating\\_overflow} & \\T{float_overflow} \\\\\n\\B{underflow} & \\T{float_underflow} \\\\\n\\B{undefined} & \\T{undefined_arith} \\\\\n\\hline\n\\end{tabular}\n\\caption{Exit reasons for exceptional values\\index{arithmetic!exceptional values}.}\n\\label{table:arith-exits}\n\\index{integer_overflow@\\B{integer\\_overflow}|)}\n\\index{floating_overflow@\\B{floating\\_overflow}|)}\n\\index{underflow@\\B{underflow}|)}\n\\index{undefined@\\B{undefined}|)}\n\\index{integer_overflow exit signal@\\T{integer\\_overflow} exit signal|)}\n\\index{float_overflow exit signal@\\T{float\\_overflow} exit signal|)}\n\\index{float_underflow exit signal@\\T{float\\_underflow} exit signal|)}\n\\index{undefined_arith exit signal@\\T{undefined_arith} exit signal|)}\n\\end{center}\n\\end{table}\n\\fi\n\n\\index{Re-1@$\\Er[\\cdot]$|(}\nSimilarly,\n\\begin{itemize}\n\\item If \\TZ{I} is an Erlang\\ integer, then $\\Er[\\TZ{I}]\\in I$ is the\ninteger it represents.\n\\item If \\TZ{F} is an Erlang\\ float, then $\\Er[\\TZ{F}]\\in F$ is the\nreal number it represents.\n\\item If \\TZ{B} is an Erlang\\ Boolean atom, then $\\Er[\\TZ{B}]\\in\\BOOLEANS$ is the\nBoolean it represents.\nThat is, $\\Er[\\T{true}]=\\B{true}$ and $\\Er[\\T{false}]=\\B{false}$.\n\\end{itemize}\n\\index{Re-1@$\\Er[\\cdot]$|)}\n\nWe have a notation for writing the result of evaluating an expression:\n\\begin{itemize}\n\\item When we write $\\TZ{E}\\RETURNS\\TZ{T}$\\index{  returns@$\\RETURNS$}\nwe state that evaluating the expression\n\\TZ{E} completes normally and that its value is the term \\TZ{T}.  (If the\nenvironment is relevant, it is stated elsewhere.)\n\\item When we write $\\TZ{E}\\EXITSWITH\\TZ{R}$\\index{  exitswith@$\\EXITSWITH$}\nwe state that evaluating the expression\n\\TZ{E} exits with reason \\TZ{R}.\n\\end{itemize}\n\n\\iffalse\n\\label{section:arith-shorthand}\n\nWhen describing the evaluation of arithmetic expressions in\n\\S\\ref{chapter:expressions-evaluation} and the BIFs in \\S\\ref{chapter:bifs},\nit will be convenient to use also the following shorthand.\n\n\\index{apply!arithmetic operation|(}\n\nWhen we write ``apply $f_I$ to $\\TZ{v}_1$'' where\n$f_I$ is one of the integer operations in\n\\S\\ref{section:integer-operations} and $\\TZ{v}_1$ is an \\Erlang\\ term, we mean\n\\begin{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ integer, then\n\\begin{itemize}\n\\item If $f_I(\\Er[\\TZ{v}_1])\\in I$, then $\\Re[f_I(\\Er[\\TZ{v}_1])]$\nis the result.\n\\item If $f_I(\\Er[\\TZ{v}_1])=\\B{integer\\_overflow}$, then exit with \\T{integer_overflow}.\n\\item If $f_I(\\Er[\\TZ{v}_1])=\\B{undefined}$, then exit with \\T{undefined}.\n\\end{itemize}\n\\item If $\\TZ{v}_1$ is not an \\Erlang\\ integer, exit with \\T{\\badarith}.\n\\end{itemize}\nSimilarly for ``apply $f_I$ to $\\TZ{v}_1$ and $\\TZ{v}_2$'', where both\n$\\TZ{v}_1$ and $\\TZ{v}_2$ must be \\Erlang\\ integers.\n\nWhen we write ``apply $f_F$ to $\\TZ{v}_1$'' where\n$f_F$ is one of the floating-point operations in\n\\S\\ref{section:float-operations} and $\\TZ{v}_1$ is an \\Erlang\\ term, we mean\n\\begin{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ float, then\n\\begin{itemize}\n\\item If $f_F(\\Er[\\TZ{v}_1])\\in F$, then $\\Re[f_F(\\Er[\\TZ{v}_1])]$\nis the result.\n\\item If $f_F(\\Er[\\TZ{v}_1])=\\B{floating\\_overflow}$, then exit with \\T{floating_overflow}.\n\\item If $f_F(\\Er[\\TZ{v}_1])=\\B{undefined}$, then exit with \\T{undefined}.\n\\end{itemize}\n\\item If $\\TZ{v}_1$ is not an \\Erlang\\ float, exit with \\T{\\badarith}.\n\\end{itemize}\nSimilarly for ``apply $f_F$ to $\\TZ{v}_1$ and $\\TZ{v}_2$'', where both\n$\\TZ{v}_1$ and $\\TZ{v}_2$ must be \\Erlang\\ floats.\n\nWhen we write ``apply $f$ to $\\TZ{v}_1$''\\ where $f_I$ is one of the\ninteger operations in\n\\S\\ref{section:integer-operations}, $f_F$ is one of the floating-point operations in\n\\S\\ref{section:float-operations} and $\\TZ{v}_1$ is an \\Erlang\\ term, we mean\n\\begin{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ integer, then apply $f_I$ to\n$\\TZ{v}_1$.\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ float, then apply $f_F$ to\n$\\TZ{v}_1$.\n\\item Otherwise, exit with \\T{badarg}.\n\\end{itemize}\nSimilarly for ``apply $f$ to $\\TZ{v}_1$ and $\\TZ{v}_2$'', where either both\n$\\TZ{v}_1$ and $\\TZ{v}_2$ must be \\Erlang\\ integers or both must be\n\\Erlang\\ floats.\n\nWhen we write ``apply $f_{I\\to F}$ to $\\TZ{v}_1$''\\ where\n$f_{I\\to F}$ is one of the integer to float conversion operations in\n\\S\\ref{section:conversions} and $\\TZ{v}_1$ is an\n\\Erlang\\ term, we mean\n\\begin{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ integer, then\n\\begin{itemize}\n\\item If $f_{I\\to F}(\\Er[\\TZ{v}_1])\\in F$, then $\\Re[f_{I\\to F}(\\Er[\\TZ{v}_1])]$ is the result.\n\\item If $f_{I\\to F}(\\Er[\\TZ{v}_1])=\\B{floating\\_overflow}$, then exit with \\T{floating_overflow}.\n\\end{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ float, then $\\TZ{v}_1$ is the result.\n\\item If $\\TZ{v}_1$ is neither an \\Erlang\\ integer, nor a float, exit with \\TZ{badarg}.\n\\end{itemize}\n\nWhen we write ``apply $f_{F\\to I}$ to $\\TZ{v}_1$''\\ where\n$f_{F\\to I}$ is one of the float to integer conversion operations in\n\\S\\ref{section:conversions} and $\\TZ{v}_1$ is an\n\\Erlang\\ term, we mean\n\\begin{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ float, then\n\\begin{itemize}\n\\item If $f_{F\\to I}(\\Er[\\TZ{v}_1])\\in I$, then $\\Re[f_{F\\to I}(\\Er[\\TZ{v}_1])]$ is the result.\n\\item If $f_{F\\to I}(\\Er[\\TZ{v}_1])=\\B{integer\\_overflow}$, then exit with \\T{integer_overflow}.\n\\end{itemize}\n\\item If $\\TZ{v}_1$ is an \\Erlang\\ integer, then $\\TZ{v}_1$ is the result.\n\\item If $\\TZ{v}_1$ is neither an \\Erlang\\ integer, nor a float, exit with \\TZ{badarg}.\n\\end{itemize}\n\nThe result and exit refer to the result and exit of the expression\nbeing described or the application of the BIF being described.\n\\index{apply!arithmetic operation|)}\n\\fi % iffalse\n\n\\section{Notification}\n\n\\index{arithmetic!notification|(}\n\nWhenever the evaluation of the translated \\Erlang\\ expressions causes\none of the functions defined in the preceding sections of this chapter\nto return an exceptional value, the evaluation of the translated\n\\Erlang\\ expression exits with\n\\ifStd\na reason that depends on the\nexceptional value, cf.~Table~\\ref{table:arith-exits}.\n\\fi\n\\ifOld\nreason \\T{badarith}.\n\\fi\n\nA \\ifStd\\T{try} expression (\\S\\ref{section:try-expr}) \\else\n\\T{catch} expression (\\S\\ref{section:catch}) \\fi\ncan be used for handling\nthe exception in accordance with Section~6.1.1 of LIA-1.\n\nThe usual mechanisms for handling of abnormal completion ensure that\nin absence of a \\ifStd\\T{try} \\else\\T{catch} \\fi expression that catches the arithmetic\nexception, the process will complete abruptly; any exit signals sent\nto linked processes will propagate information about the arithmetic\nexception (\\S\\ref{section:exit-signals}).\n\n\\index{arithmetic!notification|)}\n\n\\iffalse\n% !!! I would like to have this one included.\n\\section{Translation}\n\n\\index{arithmetic!translation|(}\n\\emph{In this section I will tell how arithmetic expressions are expected to\nbe translated into combinations of LIA-1 operations.  Pretty easy since there\nis only one integer and one float type.  The dynamic typing might make it\na little more messy.}\n\\index{arithmetic!translation|)}\n\\fi\n\n\\ifStd\n\\section{Conformity with IEC 559}\n\n\\label{section:arith-iec559}\n\n\\index{IEC 559|(}\n\\index{iec_559@\\I{iec\\_559}|(}\nThis specification does not specify a language binding for that part\nof IEC~559 (a.\\,k.\\,a.\\ ANSI/IEEE Std.\\ 754-1985) \\cite{iec559} that\nis not covered by LIA-1, except that there is a parameter\n$\\mathit{iec\\_559}\\in\\BOOLEANS$ that should be \\B{true} in an\nimplementation that fully conforms to IEC~559 and \\B{false} elsewhere.\n\nThe parameter $\\mathit{iec\\_559}$ is available to programs through the BIF \\linebreak\n\\T{float:iec_559/0} (\\S\\ref{section:float:iec5590}).\n\\index{IEC 559|)}\n\\index{iec_559@\\I{iec\\_559}|)}\n\\fi\n\n\\section{Conversion to and from numerals}\n\nWe will define conversions from $I$ and $F$ to canonical decimal numerals.\nBelow we will only discuss decimal numerals and thus omit ``decimal''.\nWe will also define conversions from decimal numerals to $I$ or $F$.\n\n\\subsection{Integer to decimal numeral}\n\n\\label{section:integer-to-numeral}\n\\index{integer!conversion to numeral|(}\nGiven an integer $i\\in I$, the canonical numeral is defined recursively as follows.\n\\begin{itemize}\n\\item If $0\\leq i<10$, then the canonical numeral for $i$ is the decimal digit with value $i$.\n\\item If $i<0$, then the canonical numeral for $i$ is a minus sign (`$-$') followed by the\ncanonical numeral for $-i$.\n\\item If $i\\geq10$, then the canonical numeral for $i$ is the canonical numeral\nfor $\\lfloor i/10\\rfloor$ followed by the decimal digit with value $i\\bmod10$.\n\\end{itemize}\n\\index{integer!conversion to numeral|)}\n\n\\subsection{Decimal numeral to integer}\n\n\\label{section:numeral-to-integer}\n\\index{integer!conversion from numeral|(}\nGiven a sequence of characters, its interpretation as a decimal integer numeral\n(if any) is defined as follows:\n\\begin{itemize}\n\\item If the sequence consists of a minus sign followed by decimal digits $d_1$, \\ldots, $d_k$,\nthen it denotes $-i$, where $i$ is the integer denoted by the digits $d_1$, \\ldots, $d_k$.\n\\item If the sequence consists of a plus sign followed by decimal digits $d_1$, \\ldots, $d_k$,\nthen it denotes the same integer as that denoted by the digits $d_1$, \\ldots, $d_k$.\n\\item If the sequence consists only of decimal digits $d_1$, \\ldots, $d_k$, then it\ndenotes the integer $\\sum_{j=1}^k d_j\\cdot10^{k-j}$.\n\\item Otherwise, it does not denote any integer.\n\\end{itemize}\nNote that this also defines the meaning of a\n\\NT{DecimalLiteral}\\index{DecimalLiteral@\\NT{DecimalLiteral}}:\nif the sequence of characters\nthat it constitutes denotes $i\\in I$, then the \\NT{DecimalLiteral} denotes $\\Re[i]$.\n\\index{integer!conversion from numeral|)}\n\n\\subsection{Numeral with radix to integer}\n\n\\label{section:radix-numeral-to-integer}\n\\index{integer!conversion from numeral|(}\nIn this context, `A' and `a' are digits\nwith value 10, `B' and `b' are digits with value 11, etc., up to `F' and `f' which are digits\nwith value 15.\nGiven a radix $r$ and a sequence of characters, its interpretation as an\ninteger numeral in radix $r$ (if any) is defined as follows:\n\\begin{itemize}\n\\item If the sequence consists of a minus sign followed by digits $d_1$, \\ldots, $d_k$,\nthen it denotes $-i$, where $i$ is the integer denoted by the digits $d_1$, \\ldots, $d_k$.\n\\item If the sequence consists of a plus sign followed by decimal digits $d_1$, \\ldots, $d_k$,\nthen it denotes the same integer as that denoted by the digits $d_1$, \\ldots, $d_k$.\n\\item If the sequence consists only of digits $d_1$, \\ldots, $d_k$ where each digit $d_j$,\n$1\\leq j\\leq k$, has a value that is less than $r$, then it\ndenotes the integer $\\sum_{j=1}^k d_j\\cdot r^{k-j}$.  \n\\item Otherwise, it does not denote any integer.\n\\end{itemize}\nNote that this also defines the meaning of a\n\\NT{ExplicitRadixLiteral}\\index{ExplicitRadixLiteral@\\NT{ExplicitRadixLiteral}}:\nconsider the sequence of characters that it constitutes.\nLet $r$ be the integer denoted by the digits before the `\\#' character.  If\nthe concatenation of\nthe sign (if any) with the digits following the `\\#' character denotes\n$i\\in I$ in radix $r$, then the \\NT{ExplicitRadixLiteral} denotes $\\Re[i]$.\n\\index{integer!conversion from numeral|)}\n\n\\subsection{Float to numeral}\n\n\\label{section:float-to-numeral}\n\\index{float!conversion to numeral|(}\nThe canonical numeral for a float $f\\in F$ is defined recursively as follows.\n\\begin{itemize}\n\\item If $f<0$, then the canonical numeral for $f$ is a minus sign (`$-$') followed by the\ncanonical numeral for $-f$.\n\\item If $f=0$, then the canonical numeral for $f$ is the digit `0' followed by a decimal\npoint (`$.$'), the digit `0', the letter `e' and the digit `0'.\n\\item If $f>0$, then let\n$w$ and $e$ be the unique integers such that $f=w\\cdot10^e$ and $w \\bmod 10\\neq 0$.\nThe canonical numeral for $f$ is the canonical numeral for $w$ with a decimal point\n (`$.$') inserted after the first digit, followed by the letter `e', followed\nby the canonical numeral for $e+\\lfloor\\log_{10}w\\rfloor$.\n(Obviously $w>0$ and the canonical numeral for $w$ thus begins with a digit.)\n\\end{itemize}\n\\index{float!conversion to numeral|)}\n\n\\subsection{Numeral to float}\n\n\\label{section:numeral-to-float}\n\\index{float!conversion from numeral|(}\nGiven a sequence of characters, the number it denotes (if any) is defined as follows.\nThe sequence of characters should consist of\n\\begin{itemize}\n\\item a (possibly signed) decimal numeral, which we will call the whole number part;\n\\item a decimal point;\n\\item an unsigned decimal numeral, which we will call the fractional part;\n\\item optionally an `E' or `e' followed by a (possibly signed) decimal numeral,\nwhich we will call the exponent.\n\\end{itemize}\nIf it does not, then the sequence of characters does not denote any number.\n\nLet $e'$ be the number of digits in the fractional part,\nlet $w$ be the integer denoted by the concatenation of the whole number part and\nthe fractional part, and let $e$ be the integer denoted by the exponent, or\nzero if there was no exponent part\n(\\S\\ref{section:numeral-to-integer}).\n\nThe number in $F$ denoted by the sequence of characters is then\n\\[\\mathit{result}_F(w\\cdot10^{e-e'},\\mathit{rnd}_F).\\]\n\nNote that this also defines the meaning of a\n\\NT{FloatLiteral}\\index{FloatLiteral@\\NT{FloatLiteral}}: if the sequence of characters\nthat it constitutes denotes $f\\in F$, then the \\NT{FloatLiteral} denotes $\\Re[f]$.\n\\index{float!conversion from numeral|)}\n", "meta": {"hexsha": "a7fd2e108f555e95d47884140db161e5e1b52b59", "size": 46353, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/es-arithmetics.tex", "max_stars_repo_name": "LaudateCorpus1/spec", "max_stars_repo_head_hexsha": "0d70db4d904c45678cb46de8f0f0f93eb35c66f3", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 44, "max_stars_repo_stars_event_min_datetime": "2017-11-30T12:10:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T16:15:05.000Z", "max_issues_repo_path": "src/es-arithmetics.tex", "max_issues_repo_name": "LaudateCorpus1/spec", "max_issues_repo_head_hexsha": "0d70db4d904c45678cb46de8f0f0f93eb35c66f3", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2017-11-30T14:08:26.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-05T13:50:58.000Z", "max_forks_repo_path": "src/es-arithmetics.tex", "max_forks_repo_name": "LaudateCorpus1/spec", "max_forks_repo_head_hexsha": "0d70db4d904c45678cb46de8f0f0f93eb35c66f3", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2017-11-30T12:07:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T06:37:00.000Z", "avg_line_length": 47.1546286877, "max_line_length": 146, "alphanum_fraction": 0.6792009147, "num_tokens": 16220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.4450799922263212}}
{"text": "\\section{Summary and further reading}\n\nThis paper demonstrated a simple technique for building complex equality proofs by composing elementary equalities using transitivity. Understanding this approach allows the reader to learn more advanced techniques offered by dependently typed languages. Possible next steps include learning mechanisms offered by Agda's standard library, namely the \\texttt{≡-Reasoning} located in \\texttt{Relation.} \\texttt{Binary.}\\texttt{PropositionalEquality} module, which provides notation identical to the one introduced in Section~\\ref{sec:eq-proofs-using-trans}. Another step to take is learning how to conduct proofs using tactics in languages such as Idris \\cite{Bra13} or Coq \\cite{coq}.\n\nDue to space limitations some parts of the companion code were left out from the discussion. The reader may now wish to take a look at verification of priority invariant in two-pass and single-pass implementations of \\texttt{merge} and simultaneous proofs of rank and priority invariants.\n", "meta": {"hexsha": "125b7c5d62159830601e739976434682ed6cca6b", "size": 1013, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/4-summary.tex", "max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z", "max_issues_repo_path": "paper/4-summary.tex", "max_issues_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/4-summary.tex", "max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_forks_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 168.8333333333, "max_line_length": 683, "alphanum_fraction": 0.8213228036, "num_tokens": 210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.44507999222632116}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage{a4wide}\n\\usepackage{listings}\n\\usepackage{listings}\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\OP}[1]{{\\bf\\widehat{#1}}}\n\n\\begin{document}\n\n\n\\section*{Project 2, Variational Monte Carlo studies of helium and beryllium}\n\nThe final aim of this project is to develop a variational Monte Carlo program which can be used to obtain ground state properties of atoms like He, Be, O, Ne, Si etc as well as diatomic molecules. \nfor important molecules \n\nThe aim of the second project  is to parallelize the code from project 1 and implement an efficient algorithm for computing the Slater determinant. We will apply the new algorithm for the Slater determinant as well as a proper parallelization to the ground state of beryllium and neon.\n\n{\\bf The deadline for project 2 is March 27, at noon}.  See below for delivery format.\n\n\n\\section*{Variational Monte Carlo calculations of the beryllium and the neon atoms}\nProject 1 has prepared you for extending your calculational machinery  to other systems.\nHere we will focus on the  beryllium and neon atoms.\nIt is convenient to make modules or classes of trial wave functions, both many-body wave functions\nand single-particle wave functions  and the quantum numbers  involved, such as spin, orbital momentum and principal\nquantum numbers.\n\nIf we stick to hydrogen-like wave functions,\nthe trial wave function for Beryllium can be written as \n\\begin{equation}\n   \\psi_{T}({\\bf r_1},{\\bf r_2}, {\\bf r_3}, {\\bf r_4}) = \n   Det\\left(\\phi_{1}({\\bf r_1}),\\phi_{2}({\\bf r_2}),\n   \\phi_{3}({\\bf r_3}),\\phi_{4}({\\bf r_4})\\right)\n   \\prod_{i<j}^{4}\\exp{\\left(\\frac{r_{ij}}{2(1+\\beta r_{ij})}\\right)}, \n\\end{equation}\nwhere $Det$ is a Slater determinant and the single-particle wave functions\nare the hydrogen wave functions for the $1s$ and $2s$ orbitals. Their form\nwithin the variational ansatz are given by\n\\begin{equation}\n\\phi_{1s}({\\bf r_i}) = e^{-\\alpha r_i},\n\\end{equation}\nand \n\\begin{equation}\n\\phi_{2s}({\\bf r_i}) = \\left(1-\\alpha r_i/2\\right)e^{-\\alpha r_i/2}.\n\\end{equation}\n\nFor the correlation part \n\\[\n\\Psi_C=\\prod_{i< j}g(r_{ij})= \\exp{\\left\\{\\sum_{i<j}\\frac{ar_{ij}}{1+\\beta r_{ij}}\\right\\}},\n\\]\nwe need to take into account whether electrons have equal or opposite spins since we have to obey the\nelectron-electron cusp condition as well.  For Beryllium, as an example,  you can fix electrons 1 and 2 to have spin up while\nelectrons 3 and 4 have spin down.\nWhen the electrons have  equal spins \n\\[\na= 1/4,\n\\]\nwhile for opposite spins (as for the ground state of  helium)\n\\[\na= 1/2.\n\\] \n\nFor neon, the trial wave function can take the form\n\\begin{equation}\n   \\psi_{T}({\\bf r_1},{\\bf r_2}, \\dots,{\\bf r_{10}}) = \n   Det\\left(\\phi_{1}({\\bf r_1}),\\phi_{2}({\\bf r_2}),\n   \\dots,\\phi_{10}({\\bf r_{10}})\\right)\n   \\prod_{i<j}^{10}\\exp{\\left(\\frac{r_{ij}}{2(1+\\beta r_{ij})}\\right)}, \n\\end{equation}\nIn this case you need to include the $2p$ wave function as well.\nIt is given as\n\\begin{equation} \n\\phi_{2p}({\\bf r_i}) = \\alpha {\\bf r_i}e^{-\\alpha r_i/2}.\n\\end{equation}\nObserve that $r_i = \\sqrt{r_{i_x}^2+r_{i_y}^2+r_{i_z}^2}$.\n\n\\begin{enumerate}\n\\item[(a)]   Write a function which sets up the Slater determinant for beryllium and neon.\nCompute the ground state energies for beryllium and neon as you did in project 1. \nThe calculations should include  blocking and importance sampling using the closed form expression for the local energy.\n\n\\item[(b)] The next step is to parallelize your code using either OpenMP or MPI. \nTest whether your code as an optimal speed-up or not. \nImplement unit tests as well in your program. \n\n\\item[c)]  With the optimal parameters for the ground state wave function, compute again the onebody density for beryllium. Compute the onebody density for neon as well. Discuss your results and compare the results with those obtained with a pure hydrogenic wave functions. Run a Monte Carlo calculations without the Jastrow factor as well\nand compute the same quantities. How important are the correlations induced by the Jastrow factor?\n\n\n\n\n\\end{enumerate}\n\n\n\n\\section*{How to write the report}\nWhat should the report contain and how can I structure it? A typical structure follows here.\n\\begin{itemize}\n\\item An abstract with the main findings.\n\\item  An introduction where you explain the aims and rationale for the physics case and what you have done. At the end of the introduction you should give a brief summary of the structure of the report\n\\item Theoretical models and technicalities. This sections ends often being the methods section.\n\\item Results and discussion\n\\item Conclusions and perspectives\n\\item Appendix with extra material\n\\item Bibliography\n\\end{itemize}\nKeep always a good log of what you do.\n\n\\subsection*{What should I focus on? Introduction.}\nYou don't need to answer all questions in a chronological order. When you write the introduction you could focus on the following aspects\n\\begin{itemize}\n\\item Motivate the reader, the first part of the introduction gives always a motivation and tries to give the overarching ideas\n\\item What I have done\n\\item The structure of the report, how it is organized etc\n\\end{itemize}\n\\subsection*{What should I focus on? Methods sections.}\n\\begin{itemize}\n\\item Describe the methods and algorithms\n\\item You need to explain how you implemented the methods and also say something about the structure of your algorithm and present some parts of your code\n\\item You should plug in some calculations to demonstrate your code, such as selected runs used to validate and verify your results. The latter is extremely important!! A reader needs to understand that your code reproduces selected benchmarks and reproduces previous results, either numerical and/or well-known closed form expressions.\n\\end{itemize}\n\n\\subsection*{What should I focus on? Results sections.}\n\\begin{itemize}\n\\item Present your results\n\\item Give a critical discussion of your work and place it in the correct context.\n\\item Relate your work to other calculations/studies\n\\item An eventual reader should be able to reproduce your calculations if she/he wants to do so. All input variables should be properly explained.\n\\item Make sure that figures and tables contain enough information in their captions, axis labels etc so that an eventual reader can gain a first impression of your work by studying figures and tables only.\n\\end{itemize}\n\n\\subsection*{What should I focus on? Conclusions sections.}\n\\begin{itemize}\n\\item State your main findings and interpretations\n\\item Try as far as possible to present perspectives for future work\n\\item Try to discuss the pros and cons of the methods and possible improvements\n\\end{itemize}\n\n\\subsection*{What should I focus on? Additional material, appendices.}\n\\begin{itemize}\n\\item Additional calculations used to validate the codes\n\\item Selected calculations, these can be listed with few comments\n\\item Listing of the code if you feel this is necessary\n\\item You can consider moving parts of the material from the methods section to the appendix. You can also place additional material on your webpage.\n\\end{itemize}\n\\subsection*{What should I focus on? References.}\n\\begin{itemize}\n\\item Give always references to material you base your work on, either scientific articles/reports or books.\n\\item Refer to articles as: name(s) of author(s), journal, volume (boldfaced), page and year in parenthesis.\n\\item Refer to books as: name(s) of author(s), title of book, publisher, place and year, eventual page numbers\n\\end{itemize}\n\n\n\n\\section*{Format for electronic delivery of report and programs}\n%\nYour are free to choose your format for handing in. The simplest way is that you send us your github link that contains the report in your chosen format(pdf, ps, docx, ipython notebook etc) and the programs.\nAs programming language you have to choose either C++ or Fortran or Python. We recommend C++ or Fortran.\nFinally, \nwe recommend that you work together. Optimal working groups consist of \n2-3 students, but more people can collaborate. You can then hand in a common report. \n\n\n\n\n\n\\section*{Literature}\n\\begin{enumerate}\n\\item B.~L.~Hammond, W.~A.~Lester and P.~J.~Reynolds, Monte Carlo methods\nin Ab Inition Quantum Chemistry, World Scientific, Singapore, 1994, chapters\n2-5 and appendix B.\n\n\\item B.H.~Bransden and C.J.~Joachain, Physics of Atoms and molecules,\nLongman, 1986. Chapters 6, 7 and 9.\n\\item S.A.~Alexander and R.L.~Coldwell,\nInt.~Journal of Quantum Chemistry, {\\bf 63} (1997) 1001.  This article is available \nat the webpage of the course as the file jastrow.pdf under the project 1 link.\n\\item C.J.~Umrigar, K.G.~Wilson and J.W.~Wilkins, Phys.~Rev.~Lett.~{\\bf 60}\n(1988) 1719. \n\n\n\n\\end{enumerate}\n\n\\section*{Unit tests, how and why?}\nUnit Testing is the practice of testing the smallest testable parts, called units, of an application individually and independently to determine if they behave exactly as expected. Unit tests (short code fragments) are usually written such that they can be preformed at any time during the development to continually verify the behavior of the code. In this way, possible bugs will be identified early in the development cycle, making the debugging at later stage much easier. There are many benefits associated with Unit Testing, such as\n\\begin{itemize}\n\\item It increases confidence in changing and maintaining code. Big changes can be made to the code quickly, since the tests will ensure that everything still is working properly.\n\\item Since the code needs to be modular to make Unit Testing possible, the code will be easier to reuse. This improves the code design.\n\\item Debugging is easier, since when a test fails, only the latest changes need to be debugged.\n\\item Different parts of a project can be tested without the need to wait for the other parts to be available.\n\\item A unit test can serve as a documentation on the functionality of a unit of the code.\n\\end{itemize}\nHere follows a simple example, see the website of the course for more information on how to install unit test libraries.\n\\begin{verbatim}\n#include <unittest++/UnitTest++.h> \n\nclass MyMultiplyClass{ \npublic: \n   double multiply(double x, double y) { \n      return x * y; \n   } \n}; \nTEST(MyMath) { \n     MyMultiplyClass my; CHECK_EQUAL(56, my.multiply(7,8)); \n} \nint main() \n{ \nreturn UnitTest::RunAllTests(); \n}\n\\end{verbatim}\nFor Fortran users, the link at \\url{http://sourceforge.net/projects/fortranxunit/} contains a similar software for unit testing.\n\\end{document}\n\n\n", "meta": {"hexsha": "336ad7c8a337e69f2ec167ab478c4abad21440c7", "size": 10539, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/Projects/2015/project2_2015.tex", "max_stars_repo_name": "GabrielSCabrera/ComputationalPhysics2", "max_stars_repo_head_hexsha": "a840b97b651085090f99bf6a11abab57100c2e85", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 87, "max_stars_repo_stars_event_min_datetime": "2015-01-21T08:29:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T07:11:53.000Z", "max_issues_repo_path": "doc/Projects/2015/project2_2015.tex", "max_issues_repo_name": "GabrielSCabrera/ComputationalPhysics2", "max_issues_repo_head_hexsha": "a840b97b651085090f99bf6a11abab57100c2e85", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-01-18T10:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T13:15:42.000Z", "max_forks_repo_path": "doc/Projects/2015/project2_2015.tex", "max_forks_repo_name": "GabrielSCabrera/ComputationalPhysics2", "max_forks_repo_head_hexsha": "a840b97b651085090f99bf6a11abab57100c2e85", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 54, "max_forks_repo_forks_event_min_datetime": "2015-02-09T10:02:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T10:44:14.000Z", "avg_line_length": 48.5668202765, "max_line_length": 538, "alphanum_fraction": 0.7630705, "num_tokens": 2725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.44507999213427385}}
{"text": "% This is a model template for the solutions in computational science. You can find a very useful documentation for LaTeX in Finnish at ftp://ftp.funet.fi/pub/TeX/CTAN/info/lshort/finnish/ or in English at ftp://ftp.funet.fi/pub/TeX/CTAN/info/lshort/english/. The section List of mathematical symbols in Chapter 3 is especially useful for the typesetting of mathematical formulas.\n\n% Compile the document to PDF by command 'pdflatex model.tex' in the terminal. The command must be run twice for the references in the text to be correct.\n\n\\documentclass[a4paper,11pt]{article}\n\\usepackage[utf8]{inputenc}\n% This includes letters such as � and �\n\\usepackage[T1]{fontenc}\n% Use here 'Finnish' for Finnish hyphenation. You may have to compile the code twice after the change. \n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n% Some math stuff\n\\usepackage{amsmath,amsfonts,amssymb,amsbsy,commath,booktabs,hyperref,dirtytalk}  \n% This is just to include the urls\n\\usepackage{hyperref,subcaption}\n\\usepackage[margin=2cm]{geometry}\n\n\\setlength{\\parindent}{0mm}\n\\setlength{\\parskip}{1.0\\baselineskip}\n\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{pdfpages}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{gray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mauve}{rgb}{0.58,0,0.82}\n\n\\lstset{frame=tb,\n\tlanguage=Python,\n\taboveskip=3mm,\n\tbelowskip=3mm,\n\tshowstringspaces=false,\n\tcolumns=flexible,\n\tbasicstyle={\\tiny\\ttfamily},\n\tnumbers=none,\n\tnumberstyle=\\tiny\\color{gray},\n\tkeywordstyle=\\color{blue},\n\tcommentstyle=\\color{dkgreen},\n\tstringstyle=\\color{mauve},\n\tbreaklines=true,\n\tbreakatwhitespace=true,\n\ttabsize=4\n}\n\n\\begin{document}\n\n\\title{Becs-114.1100 Computational Science -- exercise round 9} % Replace the exercise round number\n\\author{Kunal Ghosh, 546247} % Replace with your name and student number\n\\maketitle\n\\section{Solution 1}\n\\subsection{Pencil and Paper Problem}\nAssuming that we are using the Monte Carlo method to estimate the value of a given quantity A where One simulation run gives a single numerical value denoted by $A_{i}$ and by running the simulation n times we get the set $\\{A_{i}\\}_{i=1}^{n}$\n\\subsubsection{Obtaining a reliable estimate of the true value of A}\nWe can get a reliable estimate of the value of $A$ by drawing more samples $A_{i}$. In other words, as we keep increasing the value of $n$ our precision keeps on increasing.\\\\\nThis is an extension of the fact that, if you run $m$ simulations $k$ times to get an estimate $E_{1}$. Or if you run $k$ simulations $m$ times to get an estimate $E_{2}$\\\\The precision of $E_{1}$ and $E_{2}$ remains the same.\n\\subsubsection{How to calculate an estimate of the error?}\nWe can calculate the statistical error \n\\begin{equation}\n    \\sigma \\approx \\frac{\\sigma_{n}}{\\sqrt{N}}    \n\\end{equation}\nwhere $\\sigma_{n}$ is the standard deviation over $n$ samples calculated by using the formula \n\\begin{equation}\n\\sigma_{N}^{2} = \\text{(Second Moment)} - \\text{(First Moment)}^{2}\n\\end{equation}\nIn the equation above we are calculating the moments of the sequence of $\\{A_{i}\\}$s\n\\subsubsection{How is the central limit theorem related to the estimation ?}\nAccording to the Central limit theorem:\n\\\\\n\\textit{For any independently measured values $M_{1},M_{2},...,M_{m}$ which come from the same (sufficiently short-ranged) distribution p(x), the average \n\\begin{equation}\n    \\langle M \\rangle  = \\frac{1}{m}\\sum_{i=1}^{m}M_{i}\n\\end{equation}\nwill asymptotically follow a \\textbf{Gaussian distribution} (normal distribution) whose mean is $\\langle M \\rangle$ (equal to the mean of the parent distribution p(x)) and variance is $\\frac{1}{\\sqrt{N}}$ times that of p(x).}\n\nIn our estimation problem each $A_{i}$ can be thought of as an independent measurement from a distribution around A. ( i.e. A$\\pm$noise )\\\\\nThen according to the central limit theorem the mean of the samples asymptotically would be the mean of the parent distribution, which is the mean of the distribution around A which is almost equal to A (asymptotically).\\\\\nAlso from the central limit theorem, the variance would be $\\frac{1}{\\sqrt{N}}$ times that of the parent distribution. We can use this to measure the statistical error in our measure and identify the value of A with a desired precision.\n\n\\subsection{Estimating the value of $\\pi$ using \"Hit-or-Miss\" method}\\label{prob1b}\n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[scale=0.80]{pi_est.png}\n    \\caption{Estimate of the values of $\\pi$}\n\t\\label{fig:Y1}\n\\end{figure}\n\n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[scale=0.80]{err_est.png}\n    \\caption{change of error estimate and absolute error with increasing values of N. Here log($\\frac{1}{\\sqrt{N}}$) has been plotted for reference.}\n\t\\label{fig:Y2}\n\\end{figure}\n\n\\begin{table}[ht]\n\\centering\n\\label{1b}\n\\begin{tabular}{|c|c|c|c|}\n\\hline\n\\textbf{N} & \\textbf{Pi Estimate}&\\textbf{$\\log(\\frac{\\sigma}{\\sqrt{N}}$)}&\\textbf{Average Absolute Error} \\\\ \\hline\n1000 & 3.142508 & -6.41348792121 & -6.99620842209 \\\\\n2000 & 3.139988 & -6.71147219026 & -6.43484712196 \\\\\n3000 & 3.14166 & -6.91763448245 & -9.60566704811 \\\\\n4000 & 3.141022 & -7.08901447367 & -7.46872748644 \\\\\n5000 & 3.1420576 & -7.25796392872 & -7.67358928815 \\\\\n6000 & 3.14161333333 & -7.2936121459 & -10.7863757461 \\\\\n7000 & 3.14190171429 & -7.38430359819 & -8.0819742007 \\\\\n8000 & 3.1407535 & -7.41917293679 & -7.08311631649 \\\\\n9000 & 3.14193244444 & -7.55625404967 & -7.98718147024 \\\\\n10000 & 3.1406948 & -7.59155617352 & -7.0155030864 \\\\\n11000 & 3.14247527273 & -7.63964380553 & -7.03261724305 \\\\\n12000 & 3.14126566667 & -7.66343122719 & -8.0255891238 \\\\\n13000 & 3.14190461538 & -7.71002347021 & -8.07263114507 \\\\\n14000 & 3.14225 & -7.7644752777 & -7.32730004188 \\\\\n15000 & 3.142104 & -7.74859962632 & -7.57846409317 \\\\\n16000 & 3.14134375 & -7.82647958467 & -8.29844327801 \\\\\n17000 & 3.14103223529 & -7.8432896092 & -7.48682636454 \\\\\n18000 & 3.14201311111 & -7.82393930635 & -7.77416807873 \\\\\n19000 & 3.14135894737 & -7.91094478818 & -8.36144394036 \\\\\n20000 & 3.1413314 & -7.94131111675 & -8.2500174438 \\\\\n21000 & 3.14112952381 & -7.93669418525 & -7.67750235447 \\\\\n22000 & 3.14191890909 & -7.94388132238 & -8.02783099513 \\\\\n23000 & 3.141428 & -7.94778029614 & -8.71166425548 \\\\\n24000 & 3.14099083333 & -7.95348895198 & -7.41555105294 \\\\\n25000 & 3.14187184 & -8.01644609615 & -8.1836323316 \\\\\n26000 & 3.141922 & -8.01782795101 & -8.01840168809 \\\\\n27000 & 3.1415082963 & -8.05814633533 & -9.38044442293 \\\\\n28000 & 3.14157214286 & -8.0804222317 & -10.7945422655 \\\\\n29000 & 3.14181075862 & -8.11554628555 & -8.43053569888 \\\\\n30000 & 3.14137533333 & -8.13521894018 & -8.43413656861 \\\\\n\\hline\n\\end{tabular}\n\\caption{Table of Values for the $\\pi$ esimate using Monte Carlo Simulations.}\n\\end{table}\n\\textbf{What relation does the error estimate follow?}\n\\\\It goes down as $\\frac{1}{\\sqrt{N}}$ with the number of iterations N. As can be seen in \\ref{fig:Y2}\n\\\\\\textbf{What about the absolute error?}\n\\\\The absolute error goes down approximately linearly.\n\n\nThe corresponding python code can be found at \\ref{code:problem1b}\n\\clearpage\n\\section{Solution Q3}\\label{prob3}\nIn this problem we are trying to Identify which meathod, Importance Sampling or Sample Mean method, we should choose for the task of identifying integrals given a function and its limits. To choose between them, we use each of the methods to perform a definite integral $\\int_{1}^{2} (2x^{8}-1) dx$. After executing both the methods, we plot their respective absolute error with the analytically calculated exact integral value of 112.5555 We then state our conclusion below. \n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[scale=0.80]{Integrals.png}\n    \\caption{Value of Integral calculated using Importance sampling and Sample Mean method as a function of the Number of random samples. The exact value is plotted in Red for comparison.}\n\t\\label{fig:errors}\n\\end{figure}\n\n\n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[scale=0.80]{Errors.png}\n    \\caption{Absolute errors of Integrals calculated using Importance sampling and Sample mean method, when compared to the actual analytic integral. The values have been plotted in the log scale}\n\t\\label{fig:errors}\n\\end{figure}\n\n\n\\begin{table}[ht]\n\\centering\n\\label{table:1b}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n\\textbf{N} & \\textbf{Imp samp est}&\\textbf{Abs Err Imp Samp}&\\textbf{Sample Mean Est}&\\textbf{Abs Err Sample Mean} \\\\ \\hline\n    100 & 112.817602096 & 0.262046540193 & 97.6200018902 & 14.9355536653 \\\\\n    115 & 112.790934035 & 0.235378479495 & 110.387517365 & 2.1680381906 \\\\\n    133 & 112.862782704 & 0.307227148659 & 124.198178589 & 11.6426230335 \\\\\n    153 & 112.307040131 & 0.248515424259 & 116.378833157 & 3.8232776018 \\\\\n    176 & 112.570447868 & 0.01489231282 & 115.172083115 & 2.6165275593 \\\\\n    202 & 112.807401366 & 0.251845810884 & 108.951693299 & 3.60386225665 \\\\\n    233 & 112.605799413 & 0.0502438576779 & 106.077739978 & 6.47781557707 \\\\\n    268 & 112.727453517 & 0.171897961599 & 128.263364923 & 15.7078093672 \\\\\n   ...&...&...&...&...\\\\\n    720 & 112.425498173 & 0.130057382117 & 104.21269517 & 8.3428603851 \\\\\n    7906 & 112.591896217 & 0.0363406610969 & 111.628379791 & 0.927175764348 \\\\\n    9103 & 112.593672719 & 0.0381171632268 & 115.933335012 & 3.37777945607 \\\\\n    10481 & 112.593388655 & 0.0378330998116 & 110.255123721 & 2.30043183446 \\\\\n    12068 & 112.544424017 & 0.0111315383437 & 112.60262766 & 0.0470721040552 \\\\\n    13895 & 112.578383621 & 0.0228280654867 & 112.317530107 & 0.238025448329 \\\\\n    15999 & 112.57870659 & 0.0231510344667 & 114.266579722 & 1.71102416604 \\\\\n    18421 & 112.584252555 & 0.0286969996644 & 113.82109461 & 1.26553905427 \\\\\n    21210 & 112.567439326 & 0.011883770476 & 111.959205762 & 0.596349793541 \\\\\n    24421 & 112.525425965 & 0.0301295907316 & 113.264044066 & 0.708488510236 \\\\\n    28118 & 112.565090954 & 0.00953539796538 & 113.32274423 & 0.767188674465 \\\\\n    32375 & 112.543195441 & 0.0123601148601 & 111.961554588 & 0.594000967337 \\\\\n    37276 & 112.56452844 & 0.00897288431986 & 113.132173579 & 0.576618023773 \\\\\n    42919 & 112.553776654 & 0.00177890148414 & 112.70115021 & 0.145594654239 \\\\\n    49417 & 112.553603269 & 0.00195228660451 & 112.926394176 & 0.370838620377 \\\\\n    56899 & 112.549206334 & 0.006349221845 & 111.432828844 & 1.12272671195 \\\\\n    65513 & 112.583406579 & 0.0278510230071 & 112.367194506 & 0.188361049716 \\\\\n    75431 & 112.544776726 & 0.0107788296986 & 113.524978805 & 0.969423249651 \\\\\n    86851 & 112.561721621 & 0.00616606549636 & 112.540220207 & 0.0153353481125 \\\\\n    100000 & 112.555043138 & 0.000512417685144 & 112.505272248 & 0.0502833078437 \\\\\n\\hline\n\\end{tabular}\n\\caption{Table showing the values of $\\int_{1}^{2} (2x^{8}-1) dx$ Estimated using Importance sampling method, its Absolute Error followed by the values using Sample Mean Method and then its Absolute Error in the last column.}\n\\end{table}\n\\textbf{Which method is better?}\nIt can be seen from the graph above and also from the table of values below, that the absolute error achieved by Importance sampling is much lower than that achieved by sample mean method. Hence \\textbf{Importance Sampling} method is better. \n\\\\The corresponding python code can be found at \\ref{code:problem3}\n\\clearpage\n\\section{Appendix A}\\label{code:problem1b}\nPython source code for \\ref{prob1b}.\n{\\footnotesize\n\\begin{lstlisting}\n\nfrom __future__ import division\nimport numpy as np\nimport pylab as pl\n\ndef mc_circle_np(n):\n    '''\n    We would be drawing random samples from -1 to 1\n    '''\n    inside = 0\n    x = np.random.random(n)*2-1\n    y = np.random.random(n)*2-1\n    inside = np.sum((np.square(x,out=x) + np.square(y,out=y)) < 1)\n    return 4 * (inside/n)\n\nif __name__ == '__main__':\n    n = 1000\n    pi = 3.141592654\n    pi_est = []\n    err_est = []\n    avg_abs_err = []\n    start,end,step = 1000,31000,1000\n    for N in xrange(start,end,step):\n        pis = np.zeros(n)\n        for i in xrange(1000):\n            pis[i] = mc_circle_np(N)\n        pi_est_m = np.mean(pis)\n        pi_est.append(pi_est_m)\n        err_est_m = np.log(np.std(pis)/np.sqrt(n)) #Because we always have n (=1000) estimates\n        err_est.append(err_est_m)\n        avg_abs_err_m = np.log(np.abs(pi_est_m - pi))\n        avg_abs_err.append(avg_abs_err_m)\n        print(\"{} & {} & {} & {} \\\\\\\\\".format(N,pi_est_m,err_est_m,avg_abs_err_m))\n\n    pl.plot(pi_est)\n    pl.ylabel(\"Pi Estimate\")\n    pl.ylim((3.1,3.2))\n    pl.xlabel(\"Iterations\")\n    pl.grid()\n    pl.savefig(\"pi_est.png\")\n\n    pl.figure()\n    pl.plot(err_est)\n    pl.plot(avg_abs_err)\n    pl.xlabel(\"Iterations\")\n    pl.legend([\"Error Estimate\",\"Average Absolute Err\"])\n    pl.grid()\n    pl.savefig(\"err_est.png\")\n    pl.show()\n\n\\end{lstlisting}\n}\n\\clearpage\n\\section{Appendix B}\\label{code:problem3}\nPython source code \\ref{prob3}.\n{\\footnotesize\n\\begin{lstlisting}\n\nfrom __future__ import division\nimport numpy as np\nimport pylab as pl\n\none_by_nine = 1/9.0\nnine_by_511 = 9/511.0\ndef getIest_Imp(N):\n    y = np.random.random(N)\n    # Inverse function calculated manually\n    x = np.power(511*y + 1, one_by_nine)\n    f = 2*np.power(x,8) -1\n    w = nine_by_511 * np.power(x,8) \n    Iest = np.mean(np.true_divide(f,w))\n    return Iest\n\ndef getIest_Sm(N):\n    # b = 2 and a = 1 Hence b-a = 1 \n    # which doesn't affect the integral \n    # has been omitted from the calculations\n    x = np.random.random(N)+1 # shift the rnadom values between 1 and 2\n    f = 2*np.power(x,8)-1\n    Iest = np.mean(f)\n    return Iest\n\nif __name__ == '__main__':\n    exact = 1013/9.0\n    Iest_Imp = []\n    absErr_Imp = []\n    Iest_Sm = []\n    absErr_Sm = []\n    Ns = map(lambda x: int(round(x)), np.logspace(2, 5, 50))\n    for N in Ns:\n        estImp = getIest_Imp(N)\n        Iest_Imp.append(estImp)\n        errImp = abs(exact-estImp)\n        absErr_Imp.append(errImp)\n\n        estSm = getIest_Sm(N)\n        Iest_Sm.append(estSm)\n        errSm = abs(exact-estSm)\n        absErr_Sm.append(errSm)\n\n        print \"{} & {} & {} & {} & {} \\\\\\\\\".format(N,estImp,errImp,estSm,errSm)\n\n    pl.loglog(Ns,absErr_Imp,label=\"Importance Sampling\")\n    pl.loglog(Ns,absErr_Sm,label=\"Sample Mean\")\n    pl.loglog(Ns,map(lambda x:1/(x**0.5),Ns),label=\"1/sqrt(N)\")\n    pl.legend(framealpha=0.5)\n    pl.xlabel(\"Ns\")\n    pl.ylabel(\"Absolute Errors\")\n\n    pl.savefig(\"Errors.png\")\n    pl.show()\n\\end{lstlisting}\n}\n\\end{document}\n\n   \n\n", "meta": {"hexsha": "a0928ab99d09223a8ae5e7a1015f1e27d7296bff", "size": 14331, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercise9/report.tex", "max_stars_repo_name": "kunalghosh/BECS-114.1100-Computational-Science", "max_stars_repo_head_hexsha": "ca91ac59cb5276d213c1aec50ae7786efe72ae43", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercise9/report.tex", "max_issues_repo_name": "kunalghosh/BECS-114.1100-Computational-Science", "max_issues_repo_head_hexsha": "ca91ac59cb5276d213c1aec50ae7786efe72ae43", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercise9/report.tex", "max_forks_repo_name": "kunalghosh/BECS-114.1100-Computational-Science", "max_forks_repo_head_hexsha": "ca91ac59cb5276d213c1aec50ae7786efe72ae43", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0953846154, "max_line_length": 476, "alphanum_fraction": 0.7041378829, "num_tokens": 4841, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.4450710803793835}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n\n\\subsection*{gpr.m} \n\n\\begin{par}\n\\textbf{Summary:} Gaussian process regression, with a named covariance function. Two modes are possible: training and prediction: if no test data are given, the function returns minus the log likelihood and its partial derivatives with respect to the hyperparameters; this mode is used to fit the hyperparameters. If test data are given, then (marginal) Gaussian predictions are computed, whose mean and variance are returned. Note that in cases where the covariance function has noise contributions, the variance returned in S2 is for noisy test targets; if you want the variance of the noise-free latent function, you must substract the noise variance.\n\\end{par} \\vspace{1em}\n\\begin{par}\nusage: [nlml dnlml] = gpr(logtheta, covfunc, x, y)    or: [mu S2]  = gpr(logtheta, covfunc, x, y, xstar)\n\\end{par} \\vspace{1em}\n\\begin{par}\nwhere:\n\\end{par} \\vspace{1em}\n\\begin{verbatim}logtheta is a (column) vector of log hyperparameters\ncovfunc  is the covariance function\nx        is a n by D matrix of training inputs\ny        is a (column) vector (of size n) of targets\nxstar    is a nn by D matrix of test inputs\nnlml     is the returned value of the negative log marginal likelihood\ndnlml    is a (column) vector of partial derivatives of the negative\n              log marginal likelihood wrt each log hyperparameter\nmu       is a (column) vector (of size nn) of prediced means\nS2       is a (column) vector (of size nn) of predicted variances\\end{verbatim}\n\\begin{par}\nFor more help on covariance functions, see \"help covFunctions\".\n\\end{par} \\vspace{1em}\n\\begin{par}\n(C) Copyright 2006 by Carl Edward Rasmussen (2006-03-20).\n\\end{par} \\vspace{1em}\n\n\\begin{lstlisting}\nfunction [out1, out2] = gpr(logtheta, covfunc, x, y, xstar)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\nif ischar(covfunc), covfunc = cellstr(covfunc); end % convert to cell if needed\n[n, D] = size(x);\nif eval(feval(covfunc{:})) ~= size(logtheta, 1)\n  error('Error: Number of parameters do not agree with covariance function')\nend\n\nK = feval(covfunc{:}, logtheta, x);    % compute training set covariance matrix\n\nL = chol(K)';                        % cholesky factorization of the covariance\nalpha = solve_chol(L',y);\n\nif nargin == 4 % if no test cases, compute the negative log marginal likelihood\n\n  out1 = 0.5*y'*alpha + sum(log(diag(L))) + 0.5*n*log(2*pi);\n\n  if nargout == 2               % ... and if requested, its partial derivatives\n    out2 = zeros(size(logtheta));       % set the size of the derivative vector\n    W = L'\\(L\\eye(n))-alpha*alpha';                % precompute for convenience\n    for i = 1:length(out2)\n      out2(i) = sum(sum(W.*feval(covfunc{:}, logtheta, x, i)))/2;\n    end\n  end\n\nelse                    % ... otherwise compute (marginal) test predictions ...\n\n  [Kss, Kstar] = feval(covfunc{:}, logtheta, x, xstar);     %  test covariances\n\n  out1 = Kstar' * alpha;                                      % predicted means\n\n  if nargout == 2\n    v = L\\Kstar;\n    out2 = Kss - sum(v.*v)';\n  end\n\nend\n\\end{lstlisting}\n", "meta": {"hexsha": "f62d6c4a37877b83ef4bfc8f9d771e9c63cd6d48", "size": 3203, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/gpr.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/gpr.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/gpr.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 38.5903614458, "max_line_length": 654, "alphanum_fraction": 0.6806119263, "num_tokens": 898, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.445071066461832}}
{"text": "\\index{quantHeuristicsLib|(}\n\\index{Quantifier Instantiation|see {quantHeuristicsLib}}\n\n\\setcounter{sessioncount}{0}\n\n\\subsection{Motivation}\n\nOften interactive proofs can be simplified by instantiating\nquantifiers. The \\ml{Unwind} library\\index{Unwind}, which is part of the simplifier allows\ninstantiations of ``trivial'' quantifiers:\n\n\\[ \\forall x_1\\ \\ldots x_i \\ldots x_n.\\ P_1 \\wedge \\ldots \\wedge x_i = c \\wedge \\ldots \\wedge P_n \\Longrightarrow Q \\]\nand\n\\[ \\exists x_1\\ \\ldots x_i \\ldots x_n.\\ P_1 \\wedge \\ldots \\wedge x_i =\nc \\wedge \\ldots \\wedge P_n \\] can be simplified by\ninstantiating $x_i$ with $c$. Because unwind-conversions are\npart of \\holtxt{bool\\_ss}, they are used with nearly every call of the simplifier\nand often simplify proofs considerably. However, the \\ml{Unwind} library can only handle these common cases. If the term structure is\nonly slightly more complicated, it fails. For example, $\\exists x.\\ P(x) \\Longrightarrow (x = 2) \\wedge Q(x)$\ncannot be tackled.\n\nThere is also the \\ml{Satisfy} library\\index{Satisfy}, which uses\nunification to show existentially quantified formulas. It can handle\nproblems like $\\exists x.\\ P_1(x,c_1)\\ \\wedge \\ldots P_n(x,c_n)$ if\ngiven theorems of the form $\\forall x\\ c.\\ P_i(x, c)$. This is often\nhandy, but still rather limited.\n\nThe quantifier heuristics library (\\ml{quantHeuristicsLib}) provides more power\nand flexibility. A few simple examples of what it can do\nare shown in Table~\\ref{table_qh_examples}. Besides the power demonstrated\nby these examples, the library is highly flexible as well.  At it's\ncore, there is a modular, syntax driven search for instantiation.\nThis search consists of a collection of interleaved heuristics.  Users\ncan easily configure existing heuristics and add own ones. Thereby, it\nis easy to teach the library about new predicates, logical connectives\nor datatypes.\n\n\\newcommand{\\mytablehead}[1]{\\\\\\multicolumn{2}{l}{\\textit{#1}}\\\\}\n\\begin{table}[h]\n\\centering\\scriptsize\n\\begin{tabular}{lll}\n\\textbf{Problem} & \\textbf{Result} \\\\\\hline\n\n\\mytablehead{basic examples}\n$\\exists x.\\ x = 2 \\wedge P (x)$ & $P(2)$ \\\\\n$\\forall x.\\ x = 2 \\Longrightarrow P (x)$ & $P(2)$ \\\\\n\n\\mytablehead{solutions and counterexamples}\n$\\exists x.\\ x = 2$ & $\\textit{true}$ \\\\\n$\\forall x.\\ x = 2$ & $\\textit{false}$ \\\\\n\n\\mytablehead{complicated nestings of standard operators}\n$\\exists x_1. \\forall x_2.\\ (x_1 = 2) \\wedge P(x_1, x_2)$ &\n$\\forall x_2.\\ P(2, x_2)$ \\\\\n\n$\\exists x_1, x_2.\\ P_1(x_2) \\Longrightarrow (x_1 = 2) \\wedge P(x_1, x_2)$ &\n$\\exists x_2.\\ P_1(x_2) \\Longrightarrow P(2, x_2)$ \\\\\n$\\exists x.\\ ((x = 2) \\vee (2 = x)) \\wedge P(x)$ & $P(2)$ \\\\\n\n\\mytablehead{exploiting unification}\n$\\exists x.\\ (f (8 + 2) = f (x + 2)) \\wedge P (f(10))$ & $P (f(10))$ \\\\\n$\\exists x.\\ (f (8 + 2) = f (x + 2)) \\wedge P (f(x + 2))$ & $P (f(8 + 2))$ \\\\\n$\\exists x.\\ (f (8 + 2) = f (x + 2)) \\wedge P (f(x))$ & - (\\textrm{no instantiation found}) \\\\\n\n\\mytablehead{partial instantiation for datatypes}\n$\\forall p.\\ c = \\textsf{FST}(p) \\Longrightarrow P(p)$ & $\\forall p_2.\\ P(c, p_2)$ \\\\\n\n$\\forall x.\\ \\textsf{IS\\_NONE}(x) \\vee P(x)$ & $\\forall x'.\\ P (\\textsf{SOME}(x'))$ \\\\\n\n$\\forall l.\\ l \\neq [\\,] \\Longrightarrow P(l)$ & $\\forall \\textit{hd}, \\textit{tl}.\\\nP(\\textit{hd} :: \\textit{tl})$ \\\\\n\n\\mytablehead{context}\n$P_1(c) \\Longrightarrow \\exists x.\\ P_1(x) \\vee P_2(x)$ & \\textit{true} \\\\\n$P_1(c) \\Longrightarrow \\forall x.\\ \\neg P_1(x) \\wedge P_2(x)$ & $\\neg P_1(c)$ \\\\\n\n$(\\forall x.\\ P_1(x) \\Rightarrow (x = 2)) \\Longrightarrow (\\forall x.\\ P_1(x) \\Rightarrow P_2(x))$ &\n$(\\forall x.\\ P_1(x) \\Rightarrow (x = 2)) \\Rightarrow (P_1(2) \\Rightarrow P_2(2))$ \\\\\n\n$\\big((\\forall x.\\ P_1(x) \\Rightarrow P_2(x)) \\wedge P_1(2)\\big) \\Longrightarrow \\exists x.\\ P_2(x)$ &\n\\textit{true} \\\\\n\\hline\n\\end{tabular}\n\\caption{Examples}\n\\label{table_qh_examples}\n\\end{table}\n\n\\subsection{User Interface}\\label{sec_interface}\n\nThe quantifier heuristics library can be found in the sub-directory\n\\holtxt{src/quantHeuristics}.  The entry point to the framework is the\nlibrary \\holtxt{quantHeuristicsLib}.\n\n\\subsubsection{Conversions}\nUsually the library is used for\nconverting a term containing quantifiers to an equivalent one. For this,\nthe following high level entry points exists:\n\\bigskip\n\n\\noindent\n\\begin{tabular}{@{}ll}\n\\texttt{QUANT\\_INSTANTIATE\\_CONV} & \\texttt{: quant\\_param list -> conv} \\\\\n\\texttt{QUANT\\_INST\\_ss} & \\texttt{: quant\\_param list -> ssfrag} \\\\\n\\texttt{QUANT\\_INSTANTIATE\\_TAC} & \\texttt{: quant\\_param list -> tactic} \\\\\n\\texttt{ASM\\_QUANT\\_INSTANTIATE\\_TAC} & \\texttt{: quant\\_param list -> tactic}\n\\end{tabular}\n\\bigskip\n\nAll these functions get a list of \\emph{quantifier heuristic parameters} as arguments. These\nparameters essentially configure, which heuristics are used during the guess-search. If\nan empty list is provided, the tools know about the standard Boolean combinators, equations and context.\n\\texttt{std\\_qp} adds support for common datatypes like pairs or lists.\nQuantifier heuristic parameters are explained in more detail in\nSection~\\ref{quantHeu_subsec_qps}.\n\nSo, some simple usage of the quantifier heuristic library looks like:\n\n\\begin{session}\n\\begin{verbatim}\n- QUANT_INSTANTIATE_CONV [] ``?x. (!z. Q z /\\ (x=7)) /\\ P x``;\n> val it = |- (?x. (!z. Q z /\\ (x = 7)) /\\ P x) <=> (!z. Q z) /\\ P 7: thm\n\n- QUANT_INSTANTIATE_CONV [std_qp] ``!x. IS_SOME x ==> P x``\n> val it = |- (!x. IS_SOME x ==> P x) <=> !x_x'. P (SOME x_x'): thm\n\\end{verbatim}\n\\end{session}\n\nUsually, the quantifier heuristics library is used together with the\nsimplifier using \\holtxt{QUANT\\_INST\\_ss}. Besides interleaving\nsimplification and quantifier instantiation, this has the benefit of\nbeing able to use context information collected by the simplifier:\n\n\\begin{session}\n\\begin{verbatim}\n- QUANT_INSTANTIATE_CONV [] ``P m ==> ?n. P n``\nException- UNCHANGED raised\n\n- SIMP_CONV (bool_ss ++ QUANT_INST_ss []) [] ``P m ==> ?n. P n``\n> val it = |- P m ==> (?n. P n) <=> T: thm\n\\end{verbatim}\n\\end{session}\n\nIt's usually best to use \\holtxt{QUANT\\_INST\\_ss}\ntogether with e.\\,g.\\ \\holtxt{SIMP\\_TAC} when using the library with tactics.\nHowever, if free variables of the goal should be instantiated, then\n\\holtxt{ASM\\_QUANT\\_INSTANTIATE\\_TAC} should be used:\n\n\\begin{session}\n\\begin{verbatim}\nP x\n------------------------------------\n  IS_SOME x\n  : proof\n\n- e (ASM_QUANT_INSTANTIATE_TAC [std_qp])\n> P (SOME x_x') : proof\n\\end{verbatim}\n\\end{session}\n\nThere is also \\holtxt{QUANT\\_INSTANTIATE\\_TAC}. This tactic does not\ninstantiate free variables. Neither does it take assumptions into consideration.\nIt is just a shortcut for using \\holtxt{QUANT\\_INSTANTIATE\\_CONV} as a tactic.\n\n\n\\subsubsection{Unjustified Guesses}\n\nMost heuristics justify the guesses they produce and therefore allow to\nprove equivalences of e.\\,g.\\ the form $\\exists x.\\ P(x) \\Leftrightarrow P(i)$.\nHowever, the implementation also supports unjustified guesses, which may be bogus.\nLet's consider e.\\,g.\\ the formula $\\exists x.\\ P(x) \\Longrightarrow (x = 2)\\ \\wedge\\ Q(x)$.\nBecause nothing is known about $P$ and $Q$, we can't find a safe instantiation for $x$ here.\nHowever, $2$ looks tempting and is probably sensible in many situations. (Counterexample:\n$P(2)$, $\\neg Q(2)$ and $\\neg P(3)$ hold)\n\n\\texttt{implication\\_concl\\_qp} is a quantifier parameter that looks for valid guesses in the conclusion of an implication.\nThen, it assumes without justification that these guesses are probably sensible for the whole implication as well.\nBecause these guesses might be wrong, one can either use implications or\nexpansion theorems like $\\exists x.\\ P(x)\\ \\Longleftrightarrow (\\forall x.\\ x \\neg c \\Rightarrow \\neg P(x)) \\Rightarrow P(c)$.\n\n\\begin{session}\n\\begin{verbatim}\n- QUANT_INSTANTIATE_CONV [implication_concl_qp]\n     ``?x. P x ==> (x = 2) /\\ Q x``\nException- UNCHANGED raised\n\n- QUANT_INSTANTIATE_CONSEQ_CONV [implication_concl_qp]\n     CONSEQ_CONV_STRENGTHEN_direction\n     ``?x. P x ==> (x = 2) /\\ Q x``\n> val it =\n   |- (P 2 ==> Q 2) ==> ?x. P x ==> (x = 2) /\\ Q x: thm\n\n- EXPAND_QUANT_INSTANTIATE_CONV [implication_concl_qp]\n    ``?x. P x ==> (x = 2) /\\ Q x``\n> val it = |- (?x. P x ==> (x = 2) /\\ Q x) <=>\n              (!x. x <> 2 ==> ~(P x ==> (x = 2) /\\ Q 2)) ==> P 2 ==> Q 2\n\n- SIMP_CONV (std_ss++EXPAND_QUANT_INST_ss [implication_concl_qp]) []\n    ``?x. P x ==> (x = 2) /\\ Q x``\n> val it =\n   |- (?x. P x ==> (x = 2) /\\ Q x) <=>\n      (!x. x <> 2 ==> P x) ==> P 2 ==> Q 2: thm\n\\end{verbatim}\n\\end{session}\n\nThe following entry points should be used to exploit unjustified guesses:\n\\bigskip\n\n\\noindent\n\\begin{tabular}{@{}ll}\n\\texttt{QUANT\\_INSTANTIATE\\_CONSEQ\\_CONV} & \\texttt{: quant\\_param list -> directed\\_conseq\\_conv} \\\\\n\\texttt{EXPAND\\_QUANT\\_INSTANTIATE\\_CONV} & \\texttt{: quant\\_param list -> conv} \\\\\n\\texttt{EXPAND\\_QUANT\\_INST\\_ss} & \\texttt{: quant\\_param list -> ssfrag} \\\\\n\\texttt{QUANT\\_INSTANTIATE\\_CONSEQ\\_TAC} & \\texttt{: quant\\_param list -> tactic}\n\\end{tabular}\n\n\n\\subsubsection{Explicit Instantiations}\n\nA special (degenerated) use of the framework, is turning guess search off completely and\nproviding instantiations explicitly. The tactic \\holtxt{QUANT\\_TAC} allows this. This means that\nit allows to partially instantiate quantifiers at subpositions\nwith explicitly given terms. As such, it can be seen as\na generalisation of \\holtxt{EXISTS\\_TAC}\\index{EXISTS\\_TAC}.\n%\n\\begin{session}\n\\begin{verbatim}\n- val it = !x. (!z. P x z) ==> ?a b.    Q a        b z : proof\n\n> e( QUANT_INST_TAC [(\"z\", `0`, []), (\"a\", `SUC a'`, [`a'`])] )\n- val it = !x. (    P x 0) ==> ?  b a'. Q (SUC a') b z : proof\n\\end{verbatim}\n\\end{session}\n%\nThis tactic is implemented using unjustified guesses. It normally\nproduces implications, which is fine when used as a tactic. There is\nalso a conversion called \\holtxt{INST\\_QUANT\\_CONV} with the same\nfunctionality. For a conversion, implications are\nproblematic. Therefore, the simplifier and Metis are used to prove\nthe validity of the explicitly given instantiations. This succeeds\nonly for simple examples.\n\n\n\\subsection{Quantifier Heuristic Parameters}\\label{quantHeu_subsec_qps}\n\nQuantifier heuristic parameters play a similar role for the quantifier\ninstantiation library as simpsets do for the simplifier. They contain\ntheorems, ML code and general configuration parameters that allow to configure\nguess-search. There are predefined parameters that handle\ncommon constructs and the user can define own parameters.\n\n\\subsubsection{Quantifier Heuristic Parameters for Common Datatypes}\n\nThere are \\holtxt{option\\_qp}, \\holtxt{list\\_qp}, \\holtxt{num\\_qp} and \\holtxt{sum\\_qp} for option types, lists,\nnatural numbers and sum types respectively.\nSome examples are displayed in the following table:\n%\n\\[\\begin{array}{r@{\\quad \\Longleftrightarrow \\quad}l}\n\\forall x.\\ \\holtxt{IS\\_SOME}(x) \\Rightarrow P(x) & \\forall x'.\\ P (\\holtxt{SOME}(x')) \\\\\n\\forall x.\\ \\holtxt{IS\\_NONE}(x)& \\textit{false} \\\\\n\\forall l.\\ l \\neq [\\,] \\Rightarrow P(l)& \\forall h, l'.\\ P(h::l')  \\\\\n\\forall x.\\ x = c + 3& \\textit{false} \\\\\n\\forall x.\\ x \\neq 0 \\Rightarrow P(x)& \\forall x'.\\ P(\\holtxt{SUC}(x'))\n\\end{array}\\]\n\n\\subsubsection{Quantifier Heuristic Parameters for Tuples}\n\nFor tuples the situation is peculiar, because each quantifier over a variable of a product type\ncan be instantiated. The challenge is to decide which quantifiers should be instantiated and\nwhich new variable names to use for the components of the pair.\nThere is a quantifier heuristic parameter called \\holtxt{pair\\_default\\_qp}. It first looks for\nsubterms of the form $(\\lambda (x_1, \\ldots, x_n).\\ \\ldots)\\ x$. If such a term is found $x$ is instantiated with\n$(x_1, \\ldots, x_n)$. Otherwise, subterms of the form $\\holtxt{FST}(x)$ and $\\holtxt{SND}(x)$ are searched. If such a term\nis found, $x$ is instantiated as well. This parameter therefore allows simplifications like:\n%\n\\[\\begin{array}{r@{\\quad \\Longleftrightarrow \\quad}l}\n\\forall p.\\ (x = \\holtxt{SND}(p)) \\Rightarrow P(p)& \\forall p_1.\\ P(p_1, x) \\\\\n\\exists p.\\ (\\lambda (p_a, p_b, p_c). P(p_a, p_b, p_c))\\ p & \\exists p_a, p_b, p_c.\\ P(p_a, p_b, p_c)\n\\end{array}\\]\n\n\\holtxt{pair\\_default\\_qp} is implemented in terms of the more general\nquantifier heuristic parameter \\holtxt{pair\\_qp}, which allows the\nuser to provide a list of ML functions. These functions get the\nvariable and the term. If they return a tuple of variables, these\nvariables are used for the instantiation, otherwise the next function\nin the list is called or - if there is no function left - the variable\nis not instantiated. In the example of $\\exists p.\\ (\\lambda (p_a,\np_b, p_c). P(p_a, p_b, p_c))\\ p$ these functions are given the\nvariable $p$ and the term $(\\lambda (p_a, p_b, p_c). P(p_a, p_b,\np_c))\\ p$ and return $\\holtxt{SOME} (p_a, p_b, p_c)$.  This simple\nML-interface gives the user full control over what quantifier over\nproduct types to expand and how to name the new variables.\n\n\\subsubsection{Quantifier Heuristic Parameter for Records}\n\nRecords are similar to pairs, because they can always be instantiated. Here, it is interesting that the necessary\nmonochotomy lemma comes from HOL~4's \\holtxt{Type\\_Base} library. This means that \\holtxt{record\\_qp} is stateful.\nIf a new record type is defined, the automatically proven monochotomy lemma is then automatically used\nby \\holtxt{record\\_qp}. In contrast to the pair parameter, the one for records gets only one function instead of a\nlist of functions to decide which variables to instantiate. However, this function is simpler, because it just needs\nto return true or false. The names of the new variables are constructed from the field-names of the record.\nThe quantifier heuristic parameter \\holtxt{default\\_record\\_qp} expands all records.\n\n\\subsubsection{Stateful Quantifier Heuristic Parameters}\n\nThe parameter for records is stateful, as it uses knowledge from\n\\holtxt{Type\\_Base}. Such information is not only useful for records\nbut for general datatypes. The quantifier heuristic parameter\n\\holtxt{TypeBase\\_qp} uses automatically proven theorems about new\ndatatypes to exploit mono- and dichotomies. Moreover, there is also a\nstateful \\holtxt{pure\\_stateful\\_qp} that allows the user to\nexplicitly add other parameters to it.  \\holtxt{stateful\\_qp} is a\ncombination of \\holtxt{pure\\_stateful\\_qp} and \\holtxt{TypeBase\\_qp}.\n\n\\subsubsection{Standard Quantifier Heuristic Parameter}\n\nThe standard quantifier heuristic parameter \\holtxt{std\\_qp} combines\nthe parameters for lists, options, natural numbers, the default one\nfor pairs and the default one for records.\n\n\n\\subsection{User defined Quantifier Heuristic Parameters}\\label{sec_qps_user}\n\nThe user is also able to define own parameters. There\nis \\holtxt{empty\\_qp}, which does not contain any information. Several\nparameters can be combined using\n\\holtxt{combine\\_qps}. Together with the basic types of user defined\nparameters that are explained below, these functions provide an\ninterface for user defined quantifier heuristic parameters.\n\n\\subsubsection{Rewrites / Conversions}\n\nA very powerful, yet simple technique for teaching the guess search\nabout new constructs are rewrite rules. For example, the standard rules\nfor equations and basic logical operations\ncannot generate guesses for the predicate \\holtxt{IS\\_SOME}. By\nrewriting \\holtxt{IS\\_SOME(x)} to \\holtxt{?x'. x =\nSOME(x')}, however, these rules fire.\n\n\\holtxt{option\\_qp} uses this rewrite to implement support for\n\\holtxt{IS\\_SOME}. Similarly support for predicates like \\holtxt{NULL} is\nimplemented using rewrites. Even adding\nrewrites like $\\textsf{append}(l_1, l_2) = [\\,] \\Longleftrightarrow (l_1 =\n[\\,]\\ \\wedge\\ l_2 = [\\,])$ for list-append turned out to be beneficial\nin practice.\n\\bigskip\n\n\\holtxt{rewrite\\_qp} allows to provide rewrites in the form of rewrite theorems.\nFor the example of \\holtxt{IS\\_SOME} this looks like:\n\n\\begin{session}\n\\begin{verbatim}\n> val thm = QUANT_INSTANTIATE_CONV [] ``!x. IS_SOME x ==> P x``\nException- UNCHANGED raised\n\n> val IS_SOME_EXISTS = prove (``IS_SOME x = (?x'. x = SOME x')``,\n   Cases_on `x` THEN SIMP_TAC std_ss []);\nval IS_SOME_EXISTS = |- IS_SOME x <=> ?x'. x = SOME x': thm\n\n> val thm = QUANT_INSTANTIATE_CONV [rewrite_qp[IS_SOME_EXISTS]]\n    ``!x. IS_SOME x ==> P x``\nval thm = |- (!x. IS_SOME x ==> P x) <=>\n             !x'. IS_SOME (SOME x') ==> P (SOME x'): thm\n\\end{verbatim}\n\\end{session}\n\nTo clean up the result after instantiation, theorems used to rewrite the result after instantiation can be provided via\n\\holtxt{final\\_rewrite\\_qp}.\n\\begin{session}\n\\begin{verbatim}\n> val thm = QUANT_INSTANTIATE_CONV [rewrite_qp[IS_SOME_EXISTS],\n                                    final_rewrite_qp[option_CLAUSES]]\n      ``!x. IS_SOME x ==> P x``\nval thm = |- (!x. IS_SOME x ==> P x) <=> !x'. P (SOME x'): thm\n\\end{verbatim}\n\\end{session}\n\nIf rewrites are not enough, \\holtxt{conv\\_qp} can be used to add conversions:\n\\begin{session}\n\\begin{verbatim}\n- val thm = QUANT_INSTANTIATE_CONV [] ``?x. (\\y. y = 2) x``\nException- UNCHANGED raised\n\n- val thm = QUANT_INSTANTIATE_CONV [convs_qp[BETA_CONV]] ``?x. (\\y. y = 2) x``\n> val thm = |- (?x. (\\y. y = 2) x) <=> T: thm\n\\end{verbatim}\n\\end{session}\n\n\\subsubsection{Strengthening / Weakening}\n\nIn rare cases, equivalences that can be used for rewrites are unavailable. There might be just implications that\ncan be used for strengthening or weakening. The function\n\\holtxt{imp\\_qp} might be used to provide such implication.\n\n\\begin{session}\n\\begin{verbatim}\n- val thm = QUANT_INSTANTIATE_CONV [list_qp] ``!l. 0 < LENGTH l ==> P l``\nException- UNCHANGED raised\n\n- val LENGTH_LESS_IMP = prove (``!l n. n < LENGTH l ==> l <> []``,\n    Cases_on `l` THEN SIMP_TAC list_ss []);\n> val LENGTH_LESS_IMP = |- !l n. n < LENGTH l ==> l <> []: thm\n\n- val thm = QUANT_INSTANTIATE_CONV [imp_qp[LENGTH_LESS_IMP], list_qp]\n    ``!l. 0 < LENGTH l ==> P l``\n> val thm =\n   |- (!l. 0 < LENGTH l ==> P l) <=>\n      !l_t l_h. 0 < LENGTH (l_h::l_t) ==> P (l_h::l_t): thm\n\n- val thm = SIMP_CONV (list_ss ++\n              QUANT_INST_ss [imp_qp[LENGTH_LESS_IMP], list_qp]) []\n              ``!l. SUC (SUC n) < LENGTH l ==> P l``\n> val thm =\n   |- (!l. SUC (SUC n) < LENGTH l ==> P l) <=>\n      !l_h l_t_h l_t_t_t l_t_t_h. n < SUC (LENGTH l_t_t_t) ==>\n                                  P (l_h::l_t_h::l_t_t_h::l_t_t_t): thm\n\\end{verbatim}\n\\end{session}\n\n\n\\subsubsection{Filtering}\nSometimes, one might want to avoid to instantiate certain quantifiers.\nThe function \\holtxt{filter\\_qp} allows to add ML-functions that filter the handled\nquantifiers. These functions are given a variable $x$ and a term $P(x)$.\nThe tool only tries to instantiate $x$ in $P(x)$, if all filter functions\nreturn \\textit{true}.\n\n\\begin{session}\n\\begin{verbatim}\n- val thm = QUANT_INSTANTIATE_CONV []\n     ``?x y z. (x = 1) /\\ (y = 2) /\\ (z = 3) /\\ P (x, y, z)``\n> val thm = |- (?x y z. (x = 1) /\\ (y = 2) /\\ (z = 3) /\\ P (x,y,z)) <=>\n               P (1,2,3): thm\n\n- val thm = QUANT_INSTANTIATE_CONV\n     [filter_qp [fn v => fn t => (v = ``y:num``)]]\n     ``?x y z. (x = 1) /\\ (y = 2) /\\ (z = 3) /\\ P (x, y, z)``\n> val thm = |- (?x y z. (x = 1) /\\ (y = 2) /\\ (z = 3) /\\ P (x,y,z)) <=>\n                ?x   z. (x = 1) /\\            (z = 3) /\\ P (x,2,z): thm\n\\end{verbatim}\n\\end{session}\n\n\\subsubsection{Satisfying and Contradicting Instantiations}\n\nAs the satisfy library demonstrates, it is often\nuseful to use unification and explicitly given theorems to\nfind instantiations. In addition to satisfying instantiations, the quantifier heuristics framework\nis also able to use contradicting ones. The theorems used for finding instantiations usually come from\nthe context. However, \\holtxt{instantiation\\_qp} allows to add additional ones:\n\n\\begin{session}\n\\begin{verbatim}\n> val thm = SIMP_CONV (std_ss++QUANT_INST_ss[]) []\n    ``P n ==> ?m:num. n <= m /\\ P m``\nException- UNCHANGED raised\n\n> val thm = SIMP_CONV (std_ss++\n               QUANT_INST_ss[instantiation_qp[LESS_EQ_REFL]]) []\n               ``P n ==> ?m:num. n <= m /\\ P m``\n> val thm = |- P n ==> ?m:num. n <= m /\\ P m = T : thm\n\\end{verbatim}\n\\end{session}\n\n\\subsubsection{Di- and Monochotomies}\n\nDichotomies can be exploited for guess search.\n\\holtxt{distinct\\_qp} provides an interface to add theorems\nof the form $\\forall x.\\ c_1(x) \\neq c_2(x)$.\n\\holtxt{cases\\_qp} expects theorems of the form\n$\\forall x. \\ (x = \\exists \\textit{fv}. c_1(\\textit{fv}))\\ \\vee \\ldots \\vee (x = \\exists \\textit{fv}. c_n(\\textit{fv}))$.\nHowever, only theorems for $n = 2$ and $n = 1$ are used. All other cases are currently ignored.\n\n\\subsubsection{Oracle Guesses}\n\nSometimes, the user does not want to justify guesses. The tactic\n\\holtxt{QUANT\\_TAC} is implemented using oracle guesses for example.\nA simple interface to oracle guesses is provided by \\holtxt{oracle\\_qp}.\nIt expects a ML function that given a variable and a term returns\na pair of an instantiation and the free variables in this instantiation.\n\nAs an example, lets define a parameter that states that every list is non-empty:\n\\begin{verbatim}\n   val dummy_list_qp = oracle_qp (fn v => fn t =>\n     let\n        val (v_name, v_list_ty) = dest_var v;\n        val v_ty = listSyntax.dest_list_type v_list_ty;\n\n        val x = mk_var (v_name ^ \"_hd\", v_ty);\n        val xs = mk_var (v_name ^ \"_tl\", v_list_ty);\n        val x_xs = listSyntax.mk_cons (x, xs)\n     in\n        SOME (x_xs, [x, xs])\n     end)\n\\end{verbatim}\n\n\\noindent\nNotice, that an option type is returned and that the function is\nallowed to throw \\holtxt{HOL\\_ERR} exceptions.\nWith this definition, we get\n\n\\begin{session}\n\\begin{verbatim}\n- NORE_QUANT_INSTANTIATE_CONSEQ_CONV [dummy_list_qp]\n    CONSEQ_CONV_STRENGTHEN_direction ``?x:'a list y:'b. P (x, y)``\n> val it = ?y x_hd x_tl. P (x_hd::x_tl,y)) ==> ?x y. P (x,y) : thm\n\\end{verbatim}\n\\end{session}\n\n\\subsubsection{Lifting Theorems}\n\nThe function \\holtxt{inference\\_qp} enables the\nuser to provide theorems that allow lifting guesses over\nuser defined connectives. As writing these lifting theorems requires\ndeep knowledge about guesses, it is not discussed here. Please have a\nlook at the detailed documentation of the quantifier heuristics library as\nwell as its sources. You might also want to contact\nThomas Tuerk (\\url{tt291@cl.cam.ac.uk}).\n\n\n\\subsubsection{User defined Quantifier Heuristics}\n\nAt the lowest level, the tool searches guesses using ML-functions\ncalled \\emph{quantifier heuristics}. Slightly simplified, such a\nquantifier heuristic gets a variable and a term and returns a set of\nguesses for this variable and term. Heuristics allow full\nflexibility. However, to write your own heuristics a lot of knowledge\nabout the ML-datastructures and auxiliary functions is\nrequired. Therefore, no details are discussed here. Please have a look\nat the source code and contact Thomas Tuerk\n(\\url{tt291@cl.cam.ac.uk}), if you have questions.\n\\holtxt{heuristics\\_qp} and \\holtxt{top\\_heuristics\\_qp} provide\ninterfaces to add user defined heuristics to a quantifier heuristics\nparameter.\n\n\\index{quantHeuristicsLib|)}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"description\"\n%%% End:\n", "meta": {"hexsha": "acb16e83ff1fb8eb0c8a62e0ffe27d06c0a19a44", "size": 23086, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manual/Translations/IT/Description/QuantHeuristics.tex", "max_stars_repo_name": "dwRchyngqxs/HOL", "max_stars_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 492, "max_stars_repo_stars_event_min_datetime": "2015-01-07T16:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T22:18:48.000Z", "max_issues_repo_path": "Manual/Translations/IT/Description/QuantHeuristics.tex", "max_issues_repo_name": "dwRchyngqxs/HOL", "max_issues_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 759, "max_issues_repo_issues_event_min_datetime": "2015-01-01T00:40:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T17:33:39.000Z", "max_forks_repo_path": "Manual/Translations/IT/Description/QuantHeuristics.tex", "max_forks_repo_name": "dwRchyngqxs/HOL", "max_forks_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 126, "max_forks_repo_forks_event_min_datetime": "2015-02-17T03:20:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T00:42:55.000Z", "avg_line_length": 42.6728280961, "max_line_length": 133, "alphanum_fraction": 0.7041063848, "num_tokens": 7088, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727231, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.4450575890078208}}
{"text": "\\documentclass{article}\n\n\\usepackage[colorlinks=true, urlcolor=black, linkcolor=black, citecolor=black]{hyperref} \n\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath, amsthm, amssymb, mathtools}\n\\usepackage{enumerate, enumitem}\n\\usepackage{graphicx, color, xcolor}\n\\usepackage{epsfig, wrapfig, caption}\n\n\\graphicspath{ {images/} }\n\\newcommand{\\N}{\\ensuremath{\\mathbb{N}}}\n\\newcommand{\\Np}{\\ensuremath{\\mathbb{N}^{+}}}\n\\newcommand{\\Z}{\\ensuremath{\\mathbb{Z}}}\n\\newcommand{\\Q}{\\ensuremath{\\mathbb{Q}}}\n\\newcommand{\\R}{\\ensuremath{\\mathbb{R}}}\n\\newcommand{\\C}{\\ensuremath{\\mathbb{C}}}\n\\newcommand{\\F}{\\ensuremath{\\mathbb{F}}}\n\\newcommand{\\Fp}{\\ensuremath{\\mathbb{F}_p}}\n\\newcommand{\\Fq}{\\ensuremath{\\mathbb{F}_q}}\n\\newcommand{\\Fr}{\\ensuremath{\\mathbb{F}_r}}\n\\newcommand{\\Fl}{\\ensuremath{\\mathbb{F}_l}}\n\\newcommand{\\G}{\\ensuremath{\\mathbb{G}}}\n\\newcommand{\\point}[1]{P_{#1} = (x_{#1}, y_{#1})}\n\\newcommand{\\noi}{\\noindent}\n\\newcommand{\\Prover}{\\ensuremath{\\mathcal{P }}}\n\\newcommand{\\V}{\\ensuremath{\\mathcal{V }}}\n\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{grouplaw}[thm]{Group Law}\n\\newtheorem{prob}[thm]{Problem}\n\\theoremstyle{definition}\n\\newtheorem{defn}[thm]{Definition}\n\\theoremstyle{remark}\n\\newtheorem{rem}[thm]{Remark}\n\\newtheorem{exmp}[thm]{Example}\n\n\\begin{document}\n\t\n\t\\title{Sonny: A Bulletproof Friendly Elliptic Curve\\\\\n\t(Draft)}\n\t\\author{\n\t\tCarlos Pérez\\\\\n\t\t{\\small Dusk Foundation\\footnote{https://dusk.network/}}\\\\\n\t\t\\texttt{\\small carlos@dusk.network}\n\t\t\\and\n\t\tLuke Pearson\\\\\n\t\t{\\small Dusk Foundation}\\\\\n\t\t\\texttt{\\small luke@dusk.network}\n\t\t\\and\n\t\tMarta Bell\\'es-Mu\\~noz\\\\\n\t\t{\\small Dusk Foundation}\\\\\n\t\t\\texttt{\\small marta@dusk.network}\n\t}\n\t\n\t\\date{April 2020}\n\t\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\t\n\t\tSignature schemes are used to verify signatures and statements. These schemes and their statements oft rely upon Elliptic Curve Cryptography (ECC), which use primitives where the discrete logarithm problems are assumed to be hard. A lot of zero-knowledge proofs use elliptic curves in their construction, to aid in proving a statement. However, zero-knowledge proofs are built from a circuit, which is defined over a different group to a signature scheme. In order to prove a signature in zero knowledge, a scheme cannot utilise the properties of only curve, as the modular operations are asynchronous. To counter this problem, zero knowledge statements and other ECC operations can rely upon a curve, which is embedded within another curve. This work presents a new elliptic curve, named Sonny, which is suitable for performing signature algorithms in zero-knowledge. When constructing elliptic curves, there are many features which must be considered and amongst the all the possible choices, Sonny was designed to operate with high speed and rigid security for both theory and implementations. The curve is a Montgomery Curve, with a birationally equivalent twisted Edwards curve - this allows for the use of high speed curve formulae for operations, performed in and out of arithmetic circuits. In addition to the speed, the curve can make use of complete formulas to increase the security of the curve arithmetic. Twisted Edwards curves have a group of points which have non-prime order and the points instead have a small cofactor, of order 8. The Sonny curve was constructed to be compatible with the Ristretto technique of cofactor compression, which can omit any cofactor related issues.\\\\\n\t\t\n\t\t{\\bf Keywords:} Elliptic curve cryptography, signature verification, blockchain, zero-knowledge proofs, bulletproof, embedded curve, cofactor security. \\\\\n\t\t\n\t\\end{abstract}\n\t\n\t\\newpage\n\t\n\t\\tableofcontents\n\t\n\t\\newpage\n\t\n\t\\section{Introduction}\n\t\n\t\\subsection{Motivation}\n\t\n\tA significant portion of contemporary cryptography is in someway connected to zero knowledge proofs. With the benefit of greater privacy, many new practical systems utilise zero knowledge proofs in their design. Alongside the incorporation of these privacy preserving features into novel techniques and designs, there is also a large effort to port them onto existing systems - including already standardised models. There are many different curves or primitives and thus choices for outlining protocols, the need for ECC in zero knowledge is fundamental to the design of a lot of modern ideas. Many blockchains need to use signature schemes in order to achieve scalability. The underlying ideas is that signature schemes can be used to reduce the size of the signature, or compress multiple signatures into one and ultimately reduce the size of the block - which allows more transactions per block. Notable signature schemes which are interoperable with elliptic curves are the Elliptic Curve Digital Signature Algorithm (ECDSA), which is used in Bitcoin. As well as Edwards-curve Digital Signature Algorithm (EdDSA), which was designed by Bernstein et al. in 2011 to provide high speed signatures that do not forgo any security parameters. EdDSA is a variant of the Schnorr signature algorithm, which was designed by Claus Schnorr to generate short and efficient signatures.\\\\\\\\ \n\t\n\tHaving statements proved in zero-knowledge is paramount in maintaining a high level of privacy. Unfortunately, conducting proofs about signature schemes, in zero knowledge, is non-trivial; this is because of the fields in which the two different protocols operate. A signature algorithm, such as ECDSA relies upon a finite base field of an elliptic curve, where all of the operations are performed across the integers, made modular for some $prime$ $p$. However, to perform signatures in zero knowledge inexpensively, they need to be done in the scalar field of the group where the proof system operates; this difference in use of finite fields is where we have the mismatch when trying to align the protocols. \\\\\\\\ \n\t\n\tIn 1985, Koblitz and  Miller independently introduced elliptic curves into public key cryptography (PKC), they proved to be an improvement to existing primitves due to their short key sizes which lead to no compromise in security - as a 256 bit elliptic curve public key will provide similar security to a 3072 bit RSA public key. Since the 2004, there has been a surge in the use of elliptic curves for PKG; the choice for elliptic curves has grown tremendously and has lead to an eclectic range of options when selecting or constructing elliptic curves. Being spoilt for choice sadly doesn't mean each option is an all-purpose fit, as elliptic curve models have multitude of features which differ depending on design; often regarded as factors of opportunity cost within ECC.  \\\\\\\\\n\t\n\t{\\bf A profound solution}. In this work, we present an elliptic curve that is capable of performing ECC operations in zero knowledge, with bulletproofs as the argument. elaborate on how to use embedded curves to to extend the circuit operations to those which exceed the traditional bounds of constraint systems. We have constructed a curve, across the scalar field of curve25519 to extend the rang of EC operations inside bulletproofs, with increased security at minimal overhead.\\\\\\\\\n\t\n\tcurves elliptic curve cryptography performed perfo l all of these operations can be performed  a with those which rely upon elliptic curves  there are a multitude of features which are affected depending on design; often regarded as factors of opportunity cost  within Elliptic Curve Cryptography (ECC). However, some contemporary techniques can be used to better facilitate systems that rely so heavily upon these primitives. Since many previous protocols are proven to be secure, it is $often$ far more efficient to add to these standards with compound technologies rather than seeking entire system replacements. \\\\\\\\ \n\t\n\tOne of the most used in state of the art cryptography is the constructing of Zero Knowledge (ZK) proofs for nearly universal computation. As is with many cryptographic protocols, there is a choice of which proof system is best tailored to a system. Which includes a trade off, between proof sizes, verification times and other factors making up a ZK proof.  For particular proof systems, their expression relies upon an elliptic curve and an arithmetic circuit. The elliptic curve here is a function used to encode the public outputs which are represented as field elements, upon which a lot of operations rely. The operations for these proofs systems, however, are expressed in terms of a circuit which is determined by scalar curve arithmetic. This unfortunately restricts the operations which can be performed as they are dependent upon standard arithmetic circuit outputs - addition, multiplication, subtraction and division. Many protocols such as Elliptic Curve Digital Signature Algorithms (ECDSA), which are performed using field encodings, are in operable through the medium of generic ZK proofs which are expressed in terms of a circuit. \\\\\\\\ \n\t\n\t{\\bf A profound solution}.\n\tIn section 3, we elaborate on how to use embedded curves to to extend the circuit operations to those which exceed the traditional bounds of constraint systems. We have constructed a curve, across the scalar field of curve25519 to extend the rang of EC operations inside bulletproofs, with increased security at minimal overhead.\\\\\\\\\n\tAs with all elliptic curves, their construction will strongly influence the outcomes of the protocols in which they are implemented. In addition to this, there can be discrepancies in both the security and speed of cryptographic systems dependant upon on how they're implemented. For this reason, we wanted to construct the embedded curve such that we can make use of the the fastest formulas for elliptic curves, which are for Twisted Edwards curves. The Edwards form of a curve is considered complete, as any two inputs, given as x and y, provide a correct result. In conjunction to their complete formulas, Twisted Edwards curves have been proven by Bernstein et al, to be Birationally equivalent to Montgomery curves. Which fit the purpose of the augmented construction, as Montgomery operations in arithmetic circuits were proven by the Z-cash team to provide a fast Montgomery ladder for in circuit multiplication. Whilst these curves models can provide some of the fastest and most simplistic operations, they do provide issues in security. Neither Montgomery, nor Edwards curves deliver prime order groups in their implementations. They provide curves which have a cofactor, $h$, which multiplies the prime of the subgroup to give the group order. Whereas curves like Weierstrass give prime order but their formulas are too inefficient for circuit operations.\\\\\\\\ \n\t\n\tFor non prime order curve groups, the mismatch in desirability of prime order curves and inability to implement one directly from the curve can be patched with uniquely tailored modifications.  However, these fixes oft become perplexing to the non-implementors and with higher level protocols they are seldom straightforward. Using curves which provide prime order groups, such as Weierstrass Curves, have slower formulae and are very difficult to implement in constant time. Plentiful curve families allow for the encoding of different related curves for protocol specific purposes. For example, [] library uses Twisted Edwards forms for out of circuit operations like public key generation to exploit the high speed formula but uses Montgomery form for in circuit operations to benefit from the ladder multiplication. If an ad hoc fix needs to be given to each related curve model, then the implementation can become tedious and very complex.\\\\\\\\\n\t\n\t{\\bf A centric solution}.\n\tIn section 4, we explain how to use the Ristretto technique, which constructs prime order Edwards curves from non prime order groups, with our embedded curve, to compress the cofactor such that $h$ = 1. Ristretto makes use of the relationship between curves and provides a fix for the cofactor complication for all models in one place.\\\\\\\\\n\t\n\tAlongside the companies which revolve around the idea of privacy at the grassroots of society, such as Z-cash and Monero, the privacy cryptocurrencies, there are many more areas where signature schemes are handling sensitive data which can be easily expoloited. For example, when signing to a website the website privacy.\n\t\n\t\\subsection{State of the Art}\n\t\n\t[Work in progress]\n\t\n\t%TODO: Talk about zcash, ethereum, etc.\n\t\n\t\\subsection{Our Contributions}\n\t\n\tHere we present an elliptic curve, created for a safe and efficient elliptic curve operations inside discrete log based proofs; called Sonny. Sonny is defined as an embedded curve which the gives the input for the proofs and the outer curve, Curve25519, will be used to implement the proof itself. \\\\\\\\\n\t\n\tThis curve is used to prove the outcomes of elliptic curve functions in general knowledge. An elliptic curve statement, such as a signature scheme, allows a for the generation and verification of digital signatures from an EC key pair. However, such statements cannot be made in ZK as they are made with the Elliptic curve operations and not scalar arithmetic. With the Sonny curve, elliptic curve operations can be performed using inside circuits, with bulletproofs as the argument, so that we have ZK proof statements for signatures. \\\\\n\t\n\t\n\t\\section{Notation and Formulae} \n\t\n\t\\subsection{Elliptic Curves}\n\t\n\t\\begin{itemize}\n\t\t\n\t\t\\item Finite field: let \\Fp{ }denote a prime finite field with characteristic $\\neq {2}\\vee{3}$.\n\t\t\n\t\t\\item Edwards curve: let $\\varepsilon_{a,d}$ denote an Edwards curve, given by equation \n\t\t$$ {a}x^2+y^2=1+{d}x^2y^2, $$ \n\t\twhere {$d$} and {$ad$} are non-square elements of $\\Fp$ and with no points at infinity. %TODO: what do you mean with no points at infinity?\n\t\tIn this paper, the primary focus is upon Twisted Edwards curves, where $a = -1$. \n\t\tThe identity point of an Edwards curve, $\\varepsilon$, where (X,Y) $\\epsilon$ in \\Fp, is given encoded to $(0,1)$. When Edwards points are expressed in Extended Twisted coordinates, the identity encoding is given by $(X : Y : Z : T) = (0 : 1 : 1 : 0)$.\n\t\t\n\t\t\\item Montgomery curve: ${M}_{a,\\frac{2-4d}{a}}$ is a Montgomery curve, given by equation\n\t\t$$y^2=x^3+Ax^2+Bx.$$ \n\t\tA Montgomery curve is birationally equivalent to an Edwards curve - a definition used for algebraic substitution -  where its point at of infinity is the identity point, denoted as $(0 : 1 : 0)$.\n\t\t\n\t\t\\item Jacobi curve: $\\jmath_{a^{2},a-{2d}}$ is a Jacobi curve, given by an equation of the form \n\t\t$$y^2 = {e}x^4 + 2Ax^2 + 1.$$ \n\t\tA Jacobi curve, better known as a Jacobi quartic, is central to all curve models and to utilise this curve relationship we will only be using Jacobi curves where $e = {a}^2$, as such curves have a full 2-torsion point.\n\t\t\n\t\t\\item Torsion points: An element $[P]$ in $G$ is a torsion point if there is a mapping of $M$, by means of multiplication, where $M \\cdot\\ [P] = 0_{G}$. Torquing elements for a curve form a subgroup, $G[M]$, where the order is divisible by ${M}^2$. The torsion subgroups for this curve family have order 1, 2 or 4.\n\t\t\n\t\t\\item Isogeny: An isogeny $\\varphi$ is a function which maps algebraic groups whilst preserving the group structure. This mapping must satisfy the properties of being surjective and having a finite kernel. The isogeny, in this paper, is used to transport an encoding between different curve models.\n\t\t\n\t\t\\item Curve forms: $\\varepsilon_{a,d}$; ${M}_{a,\\frac{2-4d}{a}}$; $\\jmath_{a^{2},a-{2d}}$ These curve models are all isogenous to one another. The Edwards, Montgomery and Twisted Edwards are independently 2-isogenous to the Jacobi quartic and are therefore 4-isogenous to one another. \n\t\t\n\t\t\\item Arithmetic circuits: These are the computational models for computing circuits. They are universally bound to add and multiply, which are the functions performed at each node on all given inputs.\n\t\t\n\t\t\\item Cofactor compression: This refers a quasi-construction of cofactor 1 curves from cofactor 8 groups. Also known as cofactor division, it involves the process of point compression when points of order 4 or 8 are produced. \n\t\t\n\t\\end{itemize}\n\t\n\t\\subsection{Zero-Knowledge Proofs}\n\t\n\t[Work in progress]\n\t\n\t\\subsubsection{Bulletproofs}\n\t\n\t[Work in progress]\n\t\n\t\\newpage\n\t\n\t\\section{Sonny Elliptic Curve}\n\t\n\t%TODO: Explain Ed-255, etc.\n\t\n\t\n\t\\subsection{Definition}\n\t\\noindent\n\tLet $\\Fp$ be the prime finite field with $p$ elements, where \n\t\\begin{align*}\n\t\tp = 2^{252} + 27742317777372353535851937790883648493.\n\t\\end{align*}\n\t\n\t\\begin{defn}[Sonny]\n\t\tLet $C$ be the twisted Edwards elliptic curve defined over $\\Fp$ \n\t\tdescribed by equation \n\t\t$$ -x^2 + y^2 = 1 + \\frac{126296}{126297}x^2y^2.\t$$\n\t\tWe call {\\it Sonny} the curve $E = C(\\Fp)$. That is, $E$ is the subgroup of $\\Fp$-rational points of $C$.\n\t\\end{defn}\n\t%\n\t\\subsection{Order}\n\t\\noindent Sonny has order \n\t\\begin{align*}\n\t\tn = 2^{252}+115924404605461509904689566245241897752,\n\t\\end{align*}\n\twhich factors in $h \\times r$ where $h=8$ and \n\t\\begin{align*}\n\t\tr = 2^{249}+15114490550575682688738086195780655237219\n\t\\end{align*}\n\tis a prime number.\\\\\n\t\n\t\\subsection{Security Level}\n\t%TODO: Luke?\n\tIt is claimed that the security level of the curve is of $N\\approx 127$. We show why here. \n\t\n\t\n\t\\subsection{Forms}\n\t\n\t\\subsubsection{Montgomery}\n\t\\begin{itemize}\n\t\t\\item Equation $B y^2 = x^3 + A x^2 + x$\n\t\t\\item Parameters $A = 505186$, $B = 1$\n\t\t\\item Generator $G = (x_0, y_0)$ with coordinates\n\t\t\\begin{align*}\n\t\t\tx_0 =  \\\\\n\t\t\ty_0 = \n\t\t\\end{align*}\n\t\t\\item Base point $B = (x_1, y_1)$ with coordinates\n\t\t\\begin{align*}\n\t\t\tx_1 = \\\\\n\t\t\ty_1 = \n\t\t\\end{align*}\n\t\\end{itemize}\n\t\n\t\\subsubsection{Twisted Edwards}\n\t\\begin{itemize}\n\t\t\\item Equation $a x^2 + y^2 = 1 + d x^2 y^2$\n\t\t\\item Parameters $a = -1$, $d= -\\frac{126296}{126297}$. %TODO: Change to field rep.\n\t\t\\item Generator $G = (x_0, y_0)$ with coordinates\n\t\t\\begin{align*}\n\t\t\tx_0 = \\\\\n\t\t\ty_0 = \n\t\t\\end{align*}\n\t\t\\item Base point $B = (x_1, y_1)$ with coordinates\n\t\t\\begin{align*}\n\t\t\tx_1 = \\\\\n\t\t\ty_1 = \t\n\t\t\\end{align*}\n\t\\end{itemize}\n\t\n\t\\subsubsection{Conversion maps}\n\tThe following rational maps convert points of Sonny from one form of the curve to another \\cite[Theorem 3.2]{teds}. %TODO: Add reference.\n\t\\begin{itemize}\n\t\t\\item Montgomery to Twisted Edwards\n\t\t\\begin{align}\n\t\t\t\\label{eq-mon-to-ted}\n\t\t\t(u, v)&\\mapsto \\left(\\frac{u}{v}, \\frac{u-1}{u+1}\\right)\n\t\t\\end{align}\n\t\t\\item Twisted Edwards to Montgomery\n\t\t\\begin{align}\n\t\t\t\\label{eq-ted-to-mon}\n\t\t\t(x, y)&\\mapsto \\left(\\frac{1+y}{1-y}, \\frac{1+y}{(1-y)x}\\right)\n\t\t\\end{align}\t\t\n\t\\end{itemize}\n\t\n\t\\subsection{Curve Generation}\n\t\n\tWe start by deterministically generating a Montgomery elliptic curve $E^M$ over $\\Fp$ and then setting the generator and base points. Afterwards, we convert the curve and the points to twisted Edwards form using the maps of theorem [REF]. %TODO: Add ref.\n\tWe finally rescale all parameters so that the parameter $a = -1$. This last step has the advantage that the arithmetic in the curve can be speeded up \\cite{scaling}. %it requires less operations\n\t\n\tOur algorithm takes prime number $p$ and returns a twisted Edwards curve defined over $\\Fp$. The specific outputs of the algorithm are:\n\t\\begin{itemize}\n\t\t\\item The prime order of the finite field the curve is defined over (which is the input $p$).\n\t\t\\item Parameters $a$ and $d$ of the equation that defines the twisted Edwards curve.\n\t\t\\item Order of the curve and its decomposition into the product of a cofactor and a large prime. \n\t\t\\item Generator and base points.\n\t\\end{itemize}\n\t\n\tAs the finite field is defined by the input $p$, no specification of this parameter is required. In the same way, the order of the curve and its decomposition is determined once the parameters of the equation describing the curve are fixed. Hence, the only remaining specifications are parameters $a$ and $d$ and the choice of generator and base point. \n\t\n\t\\subsubsection{Choice of Montgomery Equation}\n\t\n\tWe start by finding a Montgomery curve defined over $\\Fp$ where $p$ is the order of Ed255 used to generate and verify Bulletproofs. given prime number. The assumptions and algorithm presented are based on the work of \\cite{generation} and Zcash team \\cite{github:zkcrypto:derive}.\n\t\n\tThe algorithm takes a prime $p$, fixes $B = 1$ and  returns the Montgomery elliptic curve defined over $\\Fp$ with smallest coefficient $A$ such that $A-2$ is a multiple of 4. \n\t% Choosing curve constants with extremely small sizes or extremely low (or high) hamming weight can be used to eliminate the computational overhead of a field multiplication. \n\tThis comes from the fact that this value is used in many operations, so trying to keep it smaller and divisible by four is a reasonable assumption \\cite{generation}. As with $A=1$ and $A=2$ the equation does not describe a smooth curve, the algorithm starts with $A=3$.\n\t\n\tFor primes congruent to 1 mod 4, the minimal cofactors of the curve and its twist are either $\\{4, 8\\}$ or $\\{8, 4\\}$.  We choose a curve with the latter cofactors so that any algorithms that take the cofactor into account don't have to worry about checking for points on the twist, because the twist cofactor will be the smaller of the two \\cite{generation}. For a prime congruent to 3 mod 4, both the curve and twist cofactors can be 4, and this is minimal.  \n\t\n\t\\subsubsection{Choice of Generator and Base Points}\n\t\n\tTo pick a generator $G_0$ of the curve, we choose the smallest element of $\\Fp$ that corresponds to an $x$-coordinate of a point in the curve of order $n$. Then as a base point, we define $G_1 = 8\\cdot G_0$, which has order $l$. \n\t\n\t\\subsubsection{Transformation to Twisted Edwards}\n\t\n\tUse the birational map of equation (\\ref{eq-mon-to-ted}) to get the coefficients, generator and base points in twisted Edwards form.\n\t\n\t\\subsubsection{Optimisation of Parameters}\n\t\n\tAs pointed out in \\cite[Sec. 3.1]{scaling}, if $-a$ is a square in $\\Fp$, it is possible to optimise the number of operations in a twisted Edwards curve by scaling it. \n\t\n\t\\begin{thm} \\label{thm-scale} %[Rescaling of E]\n\t\tConsider a twisted Edwards curve defined over $\\Fp$ given by equation $ax^2+y^2= 1 +dx^2y^2.$ If $-a$ is a square in $\\Fp$, then the map $(x, y) \\to (x/\\sqrt{-a}, y)$ defines the curve $-x^2+y^2= 1 +(-d/a)x^2y^2.$ We denote by $f = \\sqrt{-a}$ the scaling factor.\n\t\\end{thm}\n\t\n\t\\begin{proof}\n\t\tThe result follows directly from the map's definition.\n\t\\end{proof}\n\t\n\t\\subsection{Security Analysis}\n\t\n\tThis section specifies the safety criteria that the elliptic curve should satisfy. The choices of security parameters are based on the joint work of Bernstein and Lange summarised in \\cite{safe-curves}. To this purpose, we defined an algorithm that should be run after finding the elliptic curve as proposed in previous section. The algorithm is based on the the code of Daira Hopewood \\cite{github:daira:safe}, which is an extension of the original SAGE code \\cite{safe-curves} to general twisted Edwards curves.\n\t\n\t\\subsubsection{Curve Parameters}\n\t\n\tCheck all given parameters describe a well-defined elliptic curve over a prime finite field.\n\t\n\t\\begin{itemize}\n\t\t\\item The given number $p$ is prime.\n\t\t\\item The given parameters define an equation that corresponds to an elliptic curve.\n\t\t\\item The product of $h$ and $l$ results into the order of the curve and the point $G_0$ is a generator.\n\t\t\\item The given number $l$ is prime and the point $G_1$ is a generator of $\\G$.\n\t\\end{itemize}\n\t\n\t\\subsubsection{Elliptic Curve Discrete Logarithm Problem}\n\t\n\tCheck that the discrete logarithm problem remains difficult in the given curve. For that, we check it is resistant to the following known attacks. %ECDLP attacks.\n\t\n\t\\begin{itemize}\n\t\t\\item {\\it Rho method} \\cite[Sec. V.1]{seroussi}: we require the cost for the rho method, which takes on average around $0.886 \\sqrt{l}$ additions, to be above $2^{100}$.\t\n\t\t\\item {\\it Additive and multiplicative %(MOV attacks) \n\t\t\ttransfers} \\cite[Sec. V.2]{seroussi}: we require the embedding degree to be at least $(l-1)/100$.\n\t\t\\item {\\it High discriminant} \\cite[Sec. IX.3]{seroussi}: we require the complex-multiplication field discriminant $D$ to be larger than $2^{100}$. \n\t\t% Although it is not clear it is better for security to have large $|D|$, there are speed ups to the rho method for some curves where this value is very small.\n\t\\end{itemize}\n\t\n\t\\subsubsection{Elliptic Curve Cryptography}\n\t\n\t\\begin{itemize}\n\t\t\\item {\\it Ladders} \\cite{montgomery}:   check the curve supports the Montgomery ladder. \n\t\t\\item {\\it Twists} \\cite[twist]{safe-curves}: check it is secure against the small-subgroup attack, invalid-curve attacks and twisted-attacks.\n\t\t\\item {\\it Completeness} \\cite[complete]{safe-curves}: check if the curve has complete single-scalar and multiple-scalar formulas. It is enough to check that there is only one point of order 2 and 2 of order 4. \n\t\t\\item {\\it Indistinguishability} \\cite{indist}: check availability of maps that turn elliptic-curve points indistinguishable from uniform random strings.\n\t\\end{itemize}\n\t\n\t\\subsection{Cofactor Compression}\n\t\n\t\\subsubsection{Isogenies}\n\t\n\t\\subsubsection {Curve Mappings}\n\t\n\t\\section{ECC for Zero Knowledge Proofs}\n\t\n\tElliptic Curve arithmetic uses the finite field of integers reduced mod$p$, where $p$ is some usually large prime. The use of finite fields as the extension of elliptic curves allows  make certain cryptographic assumptions about the order of the set. The choice of finite fields for elliptic curves, known as base curves, provide a cyclic group which gives precise knowledge to the amount of bits that need to be stored by point outputs. As stated, the base fields dictate the operations for the elliptic curves and thus selection of these fields affects the security, speed and simplicity of the implementation of the curve. Supplementary to standard operations performed mod $p$, there are many protocols can be performed in ECC which are implemented using finite sets but do not make use of the base field. As previously touched on, they rely upon another prime order field, which is the curves scalar field, also known as the prime subgroup. Elliptic curve operations are utilised for an eclectic variety of reasons within cryptography, the predominant reason is the security that couples each of operations - resulting from hard a DLP.\\\\\\\\ \n\t\n\tElliptic curves are capable of generating public/private key pairs, which can be signed with a digital signature scheme to become security keys, and these security keys are rapidly becoming replacements for many password schemes. For example, security keys are used to show attestation certificates for websites, which allows the website to verify that a user is genuine by receiving a copy of a users authenticity. The issue arises when a verified key is registered, as becomes possible for a server to learn the make, model, and batch of the verification for the key.  This data can be manipulated by website owners and then used to discriminate which batches and models can be trusted in the future. If these key signatures and EC statements are generated in Zero Knowledge, we can provide the proof of the users signed certificate without providing additional information about the signature; this can mitigate the security risks that are tied to the data sensitivity.\\\\\\\\ \n\t\n\tSolving this issue involves using a zero-knowledge proof schemes. For our scheme, we choose bulletproofs. The existing systems like the verification systems are already deployed and because their operations are performed on on the base field, and not a scalar field, they are not directly updateable with a large range of contemporary techniques. This paper and findings focuses on Zero Knowledge  proofs as the 'add-on technology' for existing schemes. \\\\\\\\ \n\t\n\tElliptic curves have both a base field, which is the finite field in which they are defined; and a scalar field, which is associated with the number of points on the curve. DL based proofs which use a curve and a circuit rely upon both of the finite fields. The base field here is a function used to encode the public coordinates which are represented as field elements. However, as the operations are performed mod$p$, where $p$ is prime,  the outputs are reduced to the prime scalar field. Thus operations which require the base field, cannot be performed inside proof systems which use arithmetic circuits as an expression. As a result the ZK outputs are limited to what circuit operations can be performed by the elliptic curves scalar field. The circuit, in this case, encodes relation between the input and outputs.\n\t\n\t\\subsection{Efficient ZK for higher operability}\n\t\n\tTo extend the range of ZK elliptic curves operations to those which employ the base field, we have built a curve which has a base field equal to the scalar field of Curve25519. This is defined in the following manner: Let $\\varepsilon_{1}$ and $\\varepsilon_{2}$ be elliptic curves. Where the prime subgroup order, or scalar field, of $\\varepsilon_{1}$ is $r$; we define $\\varepsilon_{2}$ over the base field $F_p$, where \\#$F_p$ = $r$. \n\tThis will allow us to perform fast in circuit operations using $\\varepsilon_{2}$ as the embedded curve within the scalar field of $\\varepsilon_{1}$.One particular current issue that embedding curves helps to alleviate is the adding to, or updating of, existing software protocols with privacy techniques so that already deployed systems can benefit from high levels of privacy preservation. By constructing this, we are making a quasi representation of one finite field as both a scalar and a base field. We can therefore encode the field based protocols curve over the scalar field of existing systems - and protocols such as key signature verification, can be performed inside a Zero Knowledge  proof. We present a means of verifying only the scalar operation, in Zero Knowledge , so that Zero Knowledge  proof of statements derived for signature schemes can be proven rather than the signature itself. This is performed by expressing ZK proof of computations as the argument for computational models, such as arithmetic circuits.\\\\\\\\ \n\t\n\tIn the case of Zerocaf protocol, we have the outer curve operations, using Curve25519, which implement the ZK proof system, where the operations are performed as integers mod the base field. Then there is Sonny, the inner curve, known as the embedded curve which is the curve we make the proofs about. For the case of signature schemes, like Elliptic Curve Digital Signature Algorithm (ECDSA), the operations for the signature generation are made using Sonny then the Zero Knowledge  arguments for these outputs are generated using Curve25519. By setting the scalar field of Curve25519 as the base field of Sonny, all the operations are efficient when expressed in terms of a circuit. The validation keys here are effectively turned into discrete log proofs, as the generation of ZK values is performed in one amalgamated protocol, even though it comes from two different curves. \\\\\\\\\n\t\n\tMany software layers require information from the user - just like authentication certificates for websites, where the type of secret keys is known to the website for verification. The information given is often burnt into the hard memory of the website, which can be used by the software owners to discriminate against different keys and brands of keys hence the need to preserve privacy on these existing protocols.\n\t\n\t\\subsection{Circuits}\n\t\n\tAn circuit is combinational set of operations which are aligned in a set or series for the ultimate purpose of optimising otherwise standardised mathematical process. The operations, better known as the basic arithmetic operations (addition, subtraction, multiplication, and division), are theoretically performed in constant time. This statement is derived from the fact that the required RAM required is roughly equal for all operations. However, when computing these operations for some large integers, it is apparent that the magnitude greatly affects the costs of RAM. Thus giving a discrepancy for computational time between the theoretical arguments and the practical implementation. When the expression of these arithmetic operations is performed in a circuit, it is referred to as an arithmetic circuit. When expressed for computations within computer systems, any arithmetic circuit is constructed from various combinational elements, which are connected by wires. A combinational element is fixed element which performs a specific function from a constant number of inputs and outputs. Circuits are used alongside the elliptic curves to construct discrete log based proof systems; when the circuit is defined over the scalar field. \n\t\n\t\\section{Prime Order Groups}\n\t\n\t'A group of prime order' is always a cyclic group, that has a mapping - which respects the group structure - to the quotient of the group of integers by a subgroup. This subgroup is generated by a prime number. Groups of prime order are often a prerequisite to crytpographic prototcols, as they provide the basis for a hard DLP and thus increased security for implementation. For implementation, we have made efficiency the most paramount factor for curve selection, which led to us choosing a Twisted Edwards curve form. This is because the Edwards forms of the curves provide the fastest known formulas, which can be accredited to extended Twisted Edwards, introduced by Hysil et al, where auxiliary points are used with fewer field inversions. As elliptic curves are Abelian groups, they provide varying order for their respective groups. Edwards curves and their birational Montgomery equivalents, provide 'not quite' prime order groups over finite fields - the absence of prime groups can lead to timing variations when implementing protocols such as the signature schemes Sonny implements. Instead of certain Elliptic curve groups being prime, they have a cofactor $h$, meaning that $h \\cdot q$ is the group order, where $h > 1$ and $q$ is a large prime. Having this property where $h > 1$ can lead to many implementation complexities.\\\\\\\\\n\t\n\tThere are cofactor relates attacks designed to extract information, in the form of bits, about a users private key. When generating a public key, it is ideally performed using a point operation on a given curve point, where a chosen scalar outputs a new point, modulo the base field. This provides a public key, from which the scalar, known as the private key, cannot be extracted. However, if points on the curve are selected by attackers to have order which divides $h$, then presented as valid curve points, they can be mistakenly used by a user. If an incognizant user generates a public key by inputting a secret scalar to a function which operates with points of order $h$, then the attacker can gain some bits about the input scalar. Whereas within a prime order group, there is no means of generating valid points which have order dividing $h$. The abstraction of having non prime order groups can be solved with specialised modifications towards individual protocols. One notorious method is to multiply points by the cofactor and check the result; if the resulting point is the identity point then it can be discarded. Many of the individual techniques produce continuous and substantial flaws, especially with regards to patchwork comprehension, which occurs when the protocols are being implemented by those who did not design them, i.e. Implementors not knowing at which step to multiply by $h$. \n\t\n\t\\subsection{Cofactor Compression}\n\t\n\tThere are various advantages and disadvantages to having a cofactor larger than one, therefore a thorough analysis must be performed,  so that it is known whether or not cofactor manipulation is needed. For all curves, except for Hessian curves, the cofactor is divisible by 4. To become more useful to a broad spectrum of cryptography, Ristretto is apt for a large number of curves, which have a cofactor of 8 or 4. When the cofactor is greater than 1 multiple operations can be hindered. A quotient group can be constructed to allow for the implementation of prime order groups, thus effectively compressing the cofactor, by applying the Ristretto technique. This technique requires just one additional step to Mike Hamburgs decaf proposal for cofactor-4 curves. The technique works using following four functions:\\\\\\\\   \n\t\n\t${Equality}$ ${testing}$ This function checks the equality of group elements. \\\\\\\\\n\t\n\t${Encode}$\\ The encoding function is applied to an Edwards point and this becomes the internal representation for the new \"Ristretto point', meaning the same Edwards point operations are performed on the Ristretto point, and with no overhead cost. The function encodes the elements as byte strings so that that the Ristretto elements can be encoded identically.\\\\\\\\\n\t\n\t${Decode}$\\ This function decodes the byte strings into the internal representations of Ristretto points. There is also a validity check which assesses the canonical representation of points, and only accepts those which are outputs of the encoding function. \\\\\\\\\n\t\n\t${Curve}$ ${hashing}$\\ For many protocols, mapping elements in a group to a curve is done by a hash function, as it provides standardised digests which can be encoded. Ristretto using an Elligator 2, which gives a 1:1 mapping of group elements to the curve. Elliga\n\t\n\t\\subsection{Isogenies}\n\t\n\tBy using the Ristretto technique, we are able to solve all cofactor related issues in one place and with one step. This is facilitated by its use in the relationship of the curves, and how this lets us transport the cofactor compression for curves, via the isogeny, to another curve in the same family. Which in turn means we work with prime order points in any operations of ECC. Otherwise, the implementation would have to deal with the issue at varying stages which is dependent upon a protocols ultimate design. An isogeny is a function which maps one algebraic group to another, whilst maintaining the structure of the group - which in terms of elliptic curves, means that a curve is allowed curve to take on the values of another and preserve the same point addition method. These functions are non-constant and are used as a tool for effective 'transportation' between curve models. Just as with all concrete mathematical formulae, these functions have a domain and co-domain, which means that given these two, it is possible to compute the function itself. In this document isogenies will be given the generalization as the multiplication by $m$ map, where they have a finite kernel and are restricted to rational mappings.  \n\tA deeper understanding of isogenies for elliptic curves has greatly advanced the field of ECC, as it is possible to deduce one mapping from the form of another. Additionally, if these relationships are well understood then they can be applied or integrated into other functions and broaden their domain of propriety to more use cases.\\\\\\\\\n\t\n\tWhen there exists a non-constant function, $\\varphi$, which gives a rational mapping from one group to another denoted as $\\varphi$ : $\\varepsilon$ $\\rightarrow$ $\\varepsilon\\prime$. This mapping from $\\varepsilon$ to $\\varepsilon\\prime$ has degree $n$. Where there is this separable isogeny, then exists a mapping from $\\varepsilon$ to $\\varepsilon\\prime$, which is known as the dual isogeny, $\\hat{\\varphi}$, where both functions have degree $n$. The dual isogeny is conveyed as $\\hat{\\varphi}$ : $\\varepsilon\\prime$ $\\rightarrow$ $\\varepsilon$ of degree $n$. The isogeny $\\hat{\\varphi}$ here is known as the dual of $\\varphi$, such that $\\hat{\\varphi}$ $\\circ$ $\\varphi$ is the multiplication by $n$, where $n$ = $\\hat{\\varphi}$ $\\circ$ $\\varphi$, from $\\varepsilon$ to $\\varepsilon\\prime$. This dual isogeny has certain properties which allow for the two way transportation of functions between curves. These can be exploited to provide abstraction of protocols where it would otherwise be inapplicable.\n\t\n\t\\subsubsection {Curve Mappings}\n\t\n\tAs curve models $\\varepsilon_{a,d}$; ${M}_{a,\\frac{2-4d}{a}}$; $\\jmath_{a^{2},a-{2d}}$, have different implementation features we can utilise these relationships to achieve the implementation we desire, namely a prime order curve. It is possible to construct prime order curves using the Montgomery and Edwards curve forms by transporting encoding to and from the Jacobi quartic, via isogenies. The functions for cofactor compression would typically be used on the Jacobi quartic form, by means of canonically selecting outputs for curve points. Now this selection process can be applied to the Edwards and Montgomery form by integrating it to the function which maps between them. \\\\\\\\ \n\t\n\t\\section{Elliptic Curve Operations in Zero Knowledge}\n\t\n\tElliptic curve operations are utilised for an eclectic variety of reasons within cryptography, the predominant reason is the security that couples each of operations - resulting from hard a DLP. Elliptic curves are capable of generating public/private key pairs, as well as signing with them for accessing websites, and these keys are rapidly becoming replacements for many password schemes. The issue arises when a verified key is registered, as becomes possible for a server to learn the make, model, and batch of the verification for the key. This data can be manipulated by website owners and then used to discriminate which batches and models can be trusted in the future. If we generate these key signatures and EC statements in Zero Knowledge then we can mitigate the security risks that are tied to the data sensitivity. \n\t\n\tUnfortunately, in their raw form, elliptic curve field operations are not compatible with zero knowledge proof systems which  \n\t\n\t\\section{Implementation}\n\t\n\tThere exists a comprehensive and detailed implementation of Sonny Curve in a cryptographic library named Zerocaf. This implementation is done by Dusk Network and can be found here {\\url{https://github.com/dusk-network/dusk-zerocaf}}.\\\\\\\\  \n\t\n\tThe difficulty of breaking cryptographic systems stems solely from the hardness of the mathematical problems on which they are based. However, this proves not to be the case in practical implementations because of side channel attacks, which target the implementation as medium of encoding the cryptography - to circumvent these attacks, the operations are performed in constant time. The use of Edwards curve form results in a uniform implementation which better facilitates these constant time operations.   Whereas the efficiency for in circuit operations can greater benefit from the variable time implementations. These operations are applied when there is no secret data to protect. We therefore present an implementation which performs statement proofs in constant time with high security, and verification in variable time and high speed. \\\\ \n\t\n\t\n\t\n\t\n\t\n\t\n\t\\section{Future Work}\n\t\n\tR1CS optimisation for constraints \n\t\n\tFurther isogeny use cases \n\t\n\t\\section{Conclusions}\n\t\n\t\\section{Acknowledgements}\n\t\n\tWe would like to give special thanks to Henry de Valence for his personalised help in understanding the Ristretto Protocol and being so responsive for questions regarding the implementation. \n\t%We would also like to show our strong appreciation for Marta Bellés Muñoz for her contributions with the discrete log based theory used in the understanding of this project. \n\t\n\t\\newpage\n\t\n\t%\\bibliographystyle{unsrt}\n\t\\bibliographystyle{alpha}\n\t\\bibliography{lit}\n\t\n\\end{document}\n", "meta": {"hexsha": "281911a4f2e811cc42a48f1606e71c51f0486881", "size": 43551, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/main.tex", "max_stars_repo_name": "dusk-network/coretto", "max_stars_repo_head_hexsha": "ff5000928f074f68525eaed0e123d56205bcab70", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 41, "max_stars_repo_stars_event_min_datetime": "2019-07-09T05:24:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T11:49:52.000Z", "max_issues_repo_path": "docs/main.tex", "max_issues_repo_name": "dusk-network/coretto", "max_issues_repo_head_hexsha": "ff5000928f074f68525eaed0e123d56205bcab70", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2019-07-03T01:10:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T11:35:07.000Z", "max_forks_repo_path": "docs/main.tex", "max_forks_repo_name": "dusk-network/corretto", "max_forks_repo_head_hexsha": "ff5000928f074f68525eaed0e123d56205bcab70", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2019-07-15T19:36:13.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T12:03:54.000Z", "avg_line_length": 103.2014218009, "max_line_length": 1700, "alphanum_fraction": 0.7778466625, "num_tokens": 10226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.44505757482692254}}
{"text": "\\chapter{Uncorrelated energy-angle probability densities}\n\\label{Sec:uncorrelated-lab}\nThe simplest form of joint energy-angle probability density data in\n\\xendl\\ is as tables of uncorrelated dependence on outgoing energy\n$E'$ and direction cosine~$\\mu$,\n\\begin{equation}\n  \\pi(E', \\mu   \\mid E) =\n  \\pi_\\mu(\\mu   \\mid E)\\pi_E(E'   \\mid E).\n   \\label{uncorrelated}\n\\end{equation}\nThe energy $E'$ and direction cosine~$\\mu$ may be in either\nthe laboratory or center-of-mass frame.\n\nFor this model, the energy probability density is always given\nin the form of tables of pairs $\\{E_{i,j}', \\pi_E(E_{i,j}' \\mid E_i)\\}$.\n\nFor uncorrelated energy-angle probability densities\nin the center-of-mass frame\n\\begin{equation*}\n \\pi(\\Ecm'  , \\mucm   \\mid E) =\n  \\pi_\\mu(\\mucm   \\mid E)\\pi_E(\\Ecm'   \\mid E),\n  % \\label{uncorrelated-cm}\n\\end{equation*}\nthe \\gettransfer\\ code currently\nhandles only the case of\n$$\n \\pi_\\mu(\\mucm   \\mid E) = \\frac{1}{2}\n \\quad \\text{for $-1\\le \\mu \\le 1$}\n$$\nand for all incident energies~$E$.  Furthermore, the values\nof $\\pi_\\mu(\\mucm   \\mid E)$ must be given as pairs\n$\\{\\mu_{i,j}, \\pi_\\mu(\\mu_{i,j} \\mid E_i)\\}$.\nSuch data are treated as\nLegendre expansions Eq.~(\\ref{pi-Legendre-cm}) of order zero and \nare processed as described in Section~\\ref{Ch:Legendre-cm}.\n\nFor data in the laboratory frame\n\\begin{equation}\n  \\pi(\\Elab'  , \\mulab   \\mid E) =\n  \\pi_\\mu(\\mulab   \\mid E)\\pi_E(\\Elab'   \\mid E),\n   \\label{uncorrelated-lab}\n\\end{equation}\nthe values of $\\pi_\\mu(\\mulab   \\mid E)$\nmay be given either as pairs $\\{\\mu_{i,j}, \\pi_\\mu(\\mu_{i,j} \\mid E_i)\\}$\nor as Legendre coefficients $c_\\ell(E)$ in\n\\begin{equation}\n  \\pi_\\mu( \\mulab \\mid  E) =\n  \\sum_\\ell \n  \\left(\n     \\ell + \\frac{1}{2}\n  \\right)\n    c_\\ell(E)P_\\ell( \\mulab ).\n  \\label{uncorr-Legendre}\n\\end{equation}\nFor angular probability densities of the form of Eq.~(\\ref{uncorr-Legendre}), the\n\\gettransfer\\ code converts the data to Legendre expansions of\nenergy-angle probability densities Eq.~(\\ref{piLegendre}) using the relation\n$$\n  \\pi_\\ell( E' \\mid E) = c_\\ell(E) \\pi_E(E'   \\mid E).\n$$\nThese data are processed as in Section~\\ref{Sec:Legendre-lab}.\n\nThe discussion here proceeds with case of uncorrelated energy-angle\nprobability densities Eqs.~(\\ref{uncorrelated-lab}) given in the laboratory \ncoordinate system as tables of pairs $\\{E_{i,j}', \\pi_E(E_{i,j}' \\mid E_i)\\}$\nand $\\{\\mu_{i,j}, \\pi_\\mu(\\mu_{i,j} \\mid E_i)\\}$.\nThe incident energies~$E_i$ need not be the same for the two data sets,\nbut the ranges of incident energy must agree.\n\nFor uncorrelated energy-angle probability densities\nEq.~(\\ref{uncorrelated-lab}) the number-preserving integral Eq.~(\\ref{Inum}) becomes\n\\begin{multline}\n   \\Inum_{gh,\\ell} =\n        \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E) \\\\\n       \\, \\int_{\\calE_h' } d\\Elab'   \\, \\pi_E(\\Elab'   \\mid E)\n       \\, \\int_{\\mulab}   d\\mulab   \\,  P_\\ell( \\mulab   ) \\pi_\\mu(\\mulab   \\mid E),\n  \\label{Inum-uncorr}\n\\end{multline}\nand the energy-preserving integral Eq.~(\\ref{Ien}) takes the form\n\\begin{multline}\n  \\Ien_{gh,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E) \\\\\n     \\, \\int_{\\calE_h' } d\\Elab'   \\, \\pi_E(\\Elab'   \\mid E) \\Elab'  \n     \\, \\int_{\\mulab}   d\\mulab    \\,  P_\\ell ( \\mulab   ) \\pi_\\mu(\\mulab   \\mid E).\n  \\label{Ien-uncorr}\n\\end{multline}\n\nIt is clear from Eqs.~(\\ref{Inum-uncorr}) and~(\\ref{Ien-uncorr}) that\none should first evaluate the integrals\n\\begin{equation}\n  \\calU_\\ell( E ) =  \\int_{\\mulab}   d\\mulab   \\, P_\\ell ( \\mulab   ) \\pi_\\mu(\\mulab   \\mid E)\n  \\label{angle_int_uncorr}\n\\end{equation}\nfor the Legendre orders $\\ell$ required.  When interpolation of  $\\pi_\\mu(\\mulab   \\mid E)$\nin $\\mulab$ is piecewise linear or histogram, the integrand in Eq.~(\\ref{angle_int_uncorr})\nis a piecewise polynomial and the integrals are evaluated exactly using Gaussian quadrature.\nCurrently, the code handles Legendre order $\\ell \\le 18$ in this way.  Integrals with higher\nLegendre order are evaluated using adaptive quadrature.\n\nFor the integrals\n$$\n  \\calV_n( E ) = \\int_{\\calE_h' } d\\Elab'   \\, \\pi_E(\\Elab'   \\mid E)\n$$\nand\n$$\n  \\calV_E( E ) = \\int_{\\calE_h' } d\\Elab'   \\, \\pi_E  (\\Elab'   \\mid E) \\Elab'  \n$$\nthe same geometric considerations apply as for the integrals Eqs.~(\\ref{InumI4-0}) \nand~(\\ref{IenI4-0}) of tabular isotropic data $\\pi_0(\\Elab'   \\mid E)$\nas discussed in Section~\\ref{Sec:isotropicTables}.  That is, if unit-base interpolation\nEq.~(\\ref{unitbaseMap}) is being used, then the integral $\\calV_n( E )$ takes the form\n$$\n  \\calV_n( E ) = \\int_{\\widehat\\calE_h' } d\\widehat \\Elab'   \\, \\pi_E(\\widehat \\Elab'   \\mid E),\n$$\nand the range of integration is determined by the geometry of the\nshaded region in Figure~\\ref{Fig:unit-base-region}.\n\n\\section{Input of data for uncorrelated energy-angle probability densities}\nThe process identifier in Section~\\ref{data-model} is\\\\\n  \\Input{Process: Uncorrelated energy-angle data transfer matrix}{}\\\\\nThese data are in either the laboratory or center-of-mass frame, \nSection~\\ref{Reference-frame},\\\\\n  \\Input{Product Frame: lab}{}\\\\\nor\\\\\n  \\Input{Product Frame:  CenterOfMass}{}\n\nIn the model-dependent data in Section~\\ref{model-info}\nangular probability density $\\pi_\\mu(\\mu   \\mid E)$ may be given as\na table or as Legendre coefficients $c_\\ell(E)$ in Eq.~(\\ref{uncorr-Legendre}).\nThe energy \nprobability density $\\pi_E(E'   \\mid E)$ in\nEq.~(\\ref{uncorrelated}) is given as a table.  All energies must be in the same units as\nthose used for the energy groups.\n\n\\subsection{Input of angular probability densities}\nFor angular probability densities given as a table, the form is\\\\\n  \\Input{Angular data: n = $K$}{}\\\\\n  \\Input{Incident energy interpolation:}{probability interpolation flag}\\\\\n  \\Input{Outgoing cosine interpolation:}{list interpolation flag}\\\\\nThe interpolation flag for incident energy is one of those used for\nprobability density tables in Section~\\ref{interp-flags-probability}, while that for\nthe cosine is for simple lists.  This information is followed\nby $K$ sections of the form\\\\\n  \\Input{Ein: $E$:}{$\\texttt{n} = J$}\\\\\nwith $J$ pairs of values of $\\mu$ and $\\pi_\\mu(\\mu   \\mid E)$.\n\nAn example of such a table of angular probability densities\nin the laboratory frame with energies in MeV is\\\\\n  \\Input{Angular data: n = 10}{}\\\\\n  \\Input{Incident energy interpolation: lin-lin direct}{}\\\\\n  \\Input{Outgoing cosine interpolation: lin-lin}{}\\\\\n  \\Input{ Ein: 2.82600000e+00 : n = 2}{}\\\\\n  \\Input{ \\indent  -1  0.5}{}\\\\\n  \\Input{ \\indent  1  0.5}{}\\\\\n    \\Input{ $\\cdots$}{}\\\\\n  \\Input{ Ein: 2.00000000e+01: n = 10}{}\\\\\n  \\Input{ \\indent  -1.00000000e+00  2.86849000e-01}{}\\\\\n  \\Input{ \\indent  -9.00000000e-01  2.98228000e-01}{}\\\\\n  \\Input{ \\indent  -6.00000000e-01  3.48724000e-01}{}\\\\\n  \\Input{ \\indent  -3.00000000e-01  4.08451000e-01}{}\\\\\n  \\Input{ \\indent  -1.00000000e-01  4.54198000e-01}{}\\\\\n  \\Input{ \\indent   1.00000000e-01  5.05334000e-01}{}\\\\\n  \\Input{ \\indent   3.00000000e-01  5.62452000e-01}{}\\\\\n  \\Input{ \\indent   7.00000000e-01  6.93910000e-01}{}\\\\\n  \\Input{ \\indent   9.00000000e-01  7.47781000e-01}{}\\\\\n  \\Input{ \\indent  1.00000000e+00  7.65990000e-01}{}\n  \nIn the center-of-mass frame, the data must imply that\n$\\pi_\\mu(\\mucm   \\mid E) = 1/2$ as in \\\\\n  \\Input{Angular data: n = 2}{}\\\\\n  \\Input{Incident energy interpolation: lin-lin direct}{}\\\\\n  \\Input{Outgoing cosine interpolation: lin-lin}{}\\\\\n  \\Input{ Ein: 2.82600000e+00 : n = 2}{}\\\\\n  \\Input{ \\indent  -1  0.5}{}\\\\\n  \\Input{ \\indent  1  0.5}{}\\\\\n  \\Input{ Ein: 20 : n = 2}{}\\\\\n  \\Input{ \\indent  -1  0.5}{}\\\\\n  \\Input{ \\indent  1  0.5}{}\\\\\n\nFor angular probability densities given as Legendre coefficients \n$c_\\ell(E)$ in Eq.~(\\ref{uncorr-Legendre}), the format is\\\\\n    \\Input{Legendre coefficients:}{$n = K$}\\\\\nwhere $K$ is the number of incident energies~$E$.\nThis is followed by the interpolation rule for simple lists\nfrom Section~\\ref{interp-flags-list}\\\\\n  \\Input{Interpolation:}{list interpolation flag}\\\\\nThis is followed by $K$ sets of data\\\\\n    \\Input{Ein: $E_k$:}{$n = L_k$}\\\\\nwith $L_k$ Legendre coefficients $c_\\ell(E_k)$ for $\\ell = 0$, 1,\n\\ldots\\ , $L_k - 1$ in Eq.~(\\ref{uncorr-Legendre}).\nThese data must be in the laboratory frame.\n\nAn example of such data is\\\\\n  \\Input{Legendre coefficients: n = 2}{}\\\\\n  \\Input{Interpolation: lin-lin}{}\\\\\n  \\Input{ Ein: 19 : n = 2}{}\\\\\n    \\Input{ \\indent  1}{}\\\\\n     \\Input{ \\indent  0}{}\\\\\n  \\Input{ Ein: 20 : n = 2}{}\\\\\n     \\Input{ \\indent  1}{}\\\\\n   \\Input{ \\indent  0.2}{}\n \n\\subsection{Input of energy probability densities}\nThe energy probability density table is of the form\\\\\n  \\Input{EEpPData: n = $K$}{}\\\\\n  \\Input{Incident energy interpolation:}{probability interpolation flag}\\\\\n  \\Input{Outgoing energy interpolation:}{list interpolation flag}\\\\\nThe interpolation flags are those used for\nprobability density tables in Section~\\ref{interp-flags-probability}.\nThis information is followed\nby $K$ sections of the form\\\\\n  \\Input{Ein: $E$:}{$\\texttt{n} = J$}\\\\\nwith $J$ pairs of values of $E'$ and $\\pi_E(E'   \\mid E)$.\n\n  \\Input{EEpPData: n = 10}{}\\\\\n  \\Input{Incident energy interpolation: lin-lin unitbase}{}\\\\\n  \\Input{Outgoing energy interpolation: lin-lin}{}\\\\\n \\Input{ Ein:  2.826000e+00: n = 3}{}\\\\\n  \\Input{ \\indent  1.000000e-03  0.000000e+00}{}\\\\\n  \\Input{ \\indent  2.000000e-03  1.000000e+03}{}\\\\\n  \\Input{ \\indent  3.000000e-03  0.000000e+00}{}\\\\\n     \\Input{ $\\cdots$}{}\\\\\n \\Input{ Ein:  2.000000e+01: n = 33}{}\\\\\n  \\Input{ \\indent  0.000000e+00  0.000000e+00}{}\\\\\n  \\Input{ \\indent  1.000000e-01  1.678010e-02}{}\\\\\n  \\Input{ \\indent  2.000000e-01  2.383160e-02}{}\\\\\n    \\Input{ \\indent }{$\\cdots$}\\\\\n  \\Input{ \\indent 1.530000e+01  1.150130e-02}{}\\\\\n  \\Input{ \\indent  1.560000e+01  9.260950e-03}{}\n\n\n\n\n\n\n", "meta": {"hexsha": "e9f3d7547ca0ac3261f8c74e4997fdc0930685cb", "size": 9771, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Merced/Doc/uncorrelated.tex", "max_stars_repo_name": "brown170/fudge", "max_stars_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2019-08-29T23:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T10:16:25.000Z", "max_issues_repo_path": "Merced/Doc/uncorrelated.tex", "max_issues_repo_name": "brown170/fudge", "max_issues_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-08-04T16:14:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T01:54:34.000Z", "max_forks_repo_path": "Merced/Doc/uncorrelated.tex", "max_forks_repo_name": "brown170/fudge", "max_forks_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-03-03T22:41:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T22:54:43.000Z", "avg_line_length": 41.4025423729, "max_line_length": 96, "alphanum_fraction": 0.6655408863, "num_tokens": 3544, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4450575748269225}}
{"text": "\\subsubsection{Explicit, Advection-Dominated Mass Transfer}\\label{sec:adv_mass_transfer}\n\nSpecified-concentration, or Dirichlet type, boundary conditions define\na specified species concentration on some section of the boundary of the\nrepresentative volume,\n\n    \\begin{align}\n      C(\\vec{r},t)\\Big|_{\\vec{r} \\in \\Gamma} &= C_0(t)\n      \\intertext{where}\n      \\vec{r} &= \\mbox{ position vector }\\nonumber\\\\\n      \\Gamma &= \\mbox{ domain boundary }.\\nonumber\n    \\end{align}\n\nThe right hand side of the Dirichlet boundary condition can be provided by any\nmass balance model, $j$, at its external boundary, $r_j$, based on the\nconcentration profile it calculates (see Section \\ref{sec:mass_balance}). The\nresulting concentration profile depends on the mass balance model chosen to\nrepresent that component,\n\n\\begin{align}\nC(z,t_n)|_{z=r_j} &= \\mbox{ fixed concentration in j at }r_j\\mbox{ and }t_n [kg/m^3].\\nonumber\\\\\n                  &= \\begin{cases}\n                         \\frac{m_{d}(t_n)}{V_{d}(t_n)}, & \\mbox{Degradation Rate}\\\\\n                         \\frac{m_{df}(t_n)}{V_{df}(t_n)}, & \\mbox{Mixed Cell}\\\\\n                         C_{out}(t_n), & \\mbox{Lumped Parameter}\\\\\n                         C(r_j,t_n), & \\mbox{One Dimensional PPM}.\n                      \\end{cases}\n\\end{align}\n\nIn the Degradation Rate and Mixed Cell models, the Dirichlet boundary condition can\nbe chosen to enforce an advective flux on the inner boundary. This choice is\nappropriate when the user expects a primarily advective interface between two\ncomponents. The advective flux across the boundary between two components $j$\nand $k$, relies on the fixed concentration Dirichlet boundary condition at the\ninterface, provided by the internal component, thus\n\n\\begin{align}\nJ_{adv}(t_n) &= \\mbox{ potential advective flux at }t_n[kg/m^2/s]\\nonumber\\\\\n               &= \\theta v C(z,t_n).\n\\end{align}\n\nThe resulting mass transfer into the component is, therefore,\n\\begin{align}\nm_{jk}(t_n) &= A\\Delta t \\theta_k v C(z,t_n)|_{z=r_j}\n\\intertext{where}\nA &= \\mbox{ surface area normal to flow }[m^2]\\nonumber\\\\\n\\Delta t &= \\mbox{ length of the time step }[s].\\nonumber\n\\end{align}\n\nWhen mass transfer is dispersion-dominated, this model should not be used.\nInstead, the dispersion-dominated model is more appropriate.\n", "meta": {"hexsha": "cfdb788d9b1cefc6b5fb6ba171e31be85e29dc47", "size": 2301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "nuclide_models/mass_transfer/adv.tex", "max_stars_repo_name": "katyhuff/2017-huff-rapid", "max_stars_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nuclide_models/mass_transfer/adv.tex", "max_issues_repo_name": "katyhuff/2017-huff-rapid", "max_issues_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nuclide_models/mass_transfer/adv.tex", "max_forks_repo_name": "katyhuff/2017-huff-rapid", "max_forks_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.25, "max_line_length": 96, "alphanum_fraction": 0.6844850065, "num_tokens": 625, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4450575684775829}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{latexsym}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{graphicx}\n\\usepackage{wrapfig}\n\\usepackage{pseudocode}\n\\usepackage{url}\n\\usepackage{float}\n\\usepackage[backref, colorlinks=true, citecolor=red, urlcolor=blue, pdfauthor={Jyh-Ming Lien}]{hyperref}\n\n\n\\newcommand{\\handout}[5]{\n  \\noindent\n  \\begin{center}\n  \\framebox{\n    \\vbox{\n      \\hbox to 5.78in { {\\bf } \\hfill #2 }\n      \\vspace{4mm}\n      \\hbox to 5.78in { {\\Large \\hfill #5  \\hfill} }\n      \\vspace{2mm}\n      \\hbox to 5.78in { {\\em #3 \\hfill #4} }\n    }\n  }\n  \\end{center}\n  \\vspace*{4mm}\n}\n\n\\newcommand{\\lecture}[4]{\\handout{#1}{#2}{#3}{#4}{#1}}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{observation}[theorem]{Observation}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{fact}[theorem]{Fact}\n\\newtheorem{assumption}[theorem]{Assumption}\n\n% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.\n\\topmargin 0pt\n\\advance \\topmargin by -\\headheight\n\\advance \\topmargin by -\\headsep\n\\textheight 8.9in\n\\oddsidemargin 0pt\n\\evensidemargin \\oddsidemargin\n\\marginparwidth 0.5in\n\\textwidth 6.5in\n\n\\parindent 0in\n\\parskip 1.5ex\n%\\renewcommand{\\baselinestretch}{1.25}\n\n\\begin{document}\n\n\\lecture{Final Project Proposal: Automating Creation of Voting Districts}{Fall 2019}{William Austin}{CS 633 Computational Geometry}\n\n\\begin{abstract}\n\nInvestigate existing work and expand on current methods for automatic generation of voting districts.\n\n\\end{abstract}\n\n\\section{Motivation and Introduction}\n\nRepresentative democracies, such as the United States, require voting populations to be grouped together into districts so that a single legislator can be elected to represent the interests of the people living within these boundaries. However, there are many different methods for creating these districts, and they are often prone to manipulation for political gain, a practice referred to as \"gerrymandering\". As more attention has been given to this problem in recent years, some progress has been made by requiring independent redistricting commissions in some states and deeming highly gerrymandered maps as illegal in the court system. In this project, we explore how algorithmic techniques could also be leveraged to alleviate many of these issues. \n\nWe would like to be able to generate these districts programmatically using a predefined set of constraints, guaranteeing that the resulting maps are fair and unbiased, removing the influence of the political ambitions of the current party in power. Often, the negative effects of gerrymandering is summarized as \"politicians picking their voters instead of voters picking their politicians.\"  However, the benefits of automating this process are more than creating politically neutral districts. It would also eliminate the manual effort needed to draw new boundaries, reducing costs.\n\nComputationally, this is an interesting optimization problem, and there are several approaches that have been proposed for finding good solutions. We will focus on the method of \"Balanced power diagrams\", which is described in the referenced paper\\cite{balanced_power_diagrams}. This approach seeks to optimize:\n\\begin{enumerate}\n  \\item Convexity of the district shape\n  \\item Minimal number of edges in each polygon representing the district\n  \\item Equal distribution of population across districts\n\\end{enumerate}\n\nSome other measures that may be important include the ``compactness'' of the districts and the running time of the algorithm. For this project, I will use the methods pioneered by the researchers in the paper to generate potential districts based on the 2010 census data for Virginia. I have not reviewed the paper in depth, but the main technique seems to be reducing the problem to a graph representation and then computing a minimum cost flow.\n\n\\section{Methods to be Used and Studied}\n\nAs mentioned, I will be focusing on creating maps for Virginia. This includes:\n\\begin{enumerate}\n  \\item 11 Districts for the House of Representatives (US Congress)\n  \\item 40 Districts for the Virginia Senate (Upper House)\n  \\item 100 Districts for the Virginia House of Delegates (Lower House)\n\\end{enumerate}\n\nIn addition, I will provide some metrics for the generated districts. For example, the Polsby-Popper test is a measure of district compactness\\cite{polsby_popper}. Brian Olson, a pioneer in this area, also computes average voter distance to the district center.\\cite{brian_olson}\n\nThere is some sample code provided by the authors of the main paper\\cite{balanced_power_diagrams}, which I plan on starting with and extending as needed. I am unsure of how complete the functionality is or how difficult will be to get it working. It is written in C++, which I also plan on using. In addition, like the original authors, I will be using data provided by the census for the computation\\cite{census_data}.\n\nAs I mentioned, my primary focus is on the creation of maps for Virginia based on the techniques outlined in the paper.\\cite{balanced_power_diagrams} However, if time permits, I will expand on the code. Some of the possibilities might be:\n\\begin{itemize}\n  \\item Compute maps for additional states.\n  \\item Modify the algorithm to optimize for other conditions.\n  \\item Introduce Monte Carlo techniques to speed up the algorithm.\n\\end{itemize}\n\n\\section{Gerrymandering Example}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale=0.65]{FloridaCurrent.png}\n\\caption{Current Florida Congressional Districts\\cite{florida_districts}}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale=0.65]{FloridaNew.png}\n\\caption{Proposed Florida Congressional Districts}\n\\end{figure}\n\n\\begin{thebibliography}{999}\n\n\\bibitem{balanced_power_diagrams}\n  Vincent Cohen-Addad, Philip N. Klein, and Neal E. Young. \\emph{Balanced power diagrams for redistricting}, 2018.\n\n\\bibitem{polsby_popper}\n  Polsby-Popper test. (n.d.). \\emph{Wikipedia}. Retrieved October 15th, 2019, from \\url{https://en.wikipedia.org/wiki/Polsby\\%E2\\%80\\%93Popper_test}\n\n\\bibitem{brian_olson}\n  Impartial Automatic Redistricting. (2010). \\emph{Brian Olson's Website}. Retrieved October 15th, 2019, from \\url{https://bdistricting.com/2010/}\n\n\\bibitem{florida_districts}\n  Florida’s current congressional district boundaries. (2018). \\emph{FiveThirtyEight: The Atlas Of Redistricting}. Retrieved October 15th, 2019, from \\url{https://projects.fivethirtyeight.com/redistricting-maps/florida/}\n\n\\bibitem{census_data}\n  United States Census Bureau. Cartographic boundary shapefiles -states. Retrieved October 15th, 2019, from \\url{https://www.census.gov/geo/maps-data/data/cbf/cbf_state.html}.\n\n\\end{thebibliography}\n\n\\citation\n\n\\end{document}\n\n\n", "meta": {"hexsha": "8cc8b123a0c322c7afb0668c593f8b8d0caf128b", "size": 6885, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "workspace_william/William_Austin_Proposal.tex", "max_stars_repo_name": "william-r-austin/district2", "max_stars_repo_head_hexsha": "fa2f5a6560159478b15cd69a97959e91a81c1490", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "workspace_william/William_Austin_Proposal.tex", "max_issues_repo_name": "william-r-austin/district2", "max_issues_repo_head_hexsha": "fa2f5a6560159478b15cd69a97959e91a81c1490", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "workspace_william/William_Austin_Proposal.tex", "max_forks_repo_name": "william-r-austin/district2", "max_forks_repo_head_hexsha": "fa2f5a6560159478b15cd69a97959e91a81c1490", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.1785714286, "max_line_length": 757, "alphanum_fraction": 0.7857661583, "num_tokens": 1760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4450317364678279}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{III}\n\n\\def\\ntitle{Complex Dynamics}\n\\def\\nlecturer{H.\\ Krieger}\n\n\\def\\nterm{Lent}\n\\def\\nyear{2020}\n\n\\input{header}\n\n\\newcommand{\\D}{\\mathbb{D}}\n  \n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Introduction}\n\nWhat is complex dynamics? Iteration of holomorphic self-maps of Riemann surfaces\n\nlong term behaviour under iteration\n\norigin: iterative root finding algorithm, e.g. Newton's method. When and why does this work? Algebraically, the problem is to ask the convergence of the iteration of the map\n\\[\n  f(z) = z - \\frac{p(z)}{p'(z)}: \\hat \\C \\to \\hat \\C\n\\]\nwhere \\(\\hat \\C\\) is the Riemann sphere.\n\nGoals:\n\\begin{itemize}\n\\item equidistribution theorem\n\n  \\begin{theorem}[Friere-Lopez-Mañe, 1983]\n    Let \\(f: \\hat \\C \\to \\hat \\C\\) with degree \\(d \\geq 2\\) holomorphic.  Then there exists a unique \\(f\\)-invariant probability measure \\(\\mu_f\\) supported on the unstable locus of \\(f\\), such that for almost all \\(\\alpha \\in \\hat \\C\\), \\(\\frac{1}{d^n} \\sum_{f^n(z) = \\alpha} \\delta_z \\to \\mu_f\\) in weak-* topology.\n  \\end{theorem}\n\\item universality of the Mandelbrot set: fix \\(d \\geq 2\\), define for \\(c \\in \\C\\), \\(f_c(z): z^d + c\\). The \\(d\\)-Mandelbrot set is\n  \\[\n    M_d = \\{c \\in \\C: |f_c^n(0)| \\nto \\infty\\}.\n  \\]\n\n  \\begin{theorem}[McMullen 1997]\n    The Mandelbrot set is universal for bifurcations, i.e. in any bifurcation locus we see (slightly distorted) copics of some \\(M_d\\).\n  \\end{theorem}\n\\end{itemize}\n\n\\section{Riemann surfaces}\n\nRecall at the end of IID Riemann Surfaces\n\n\\begin{theorem}[uniformisation]\n  Every Riemann surface \\(R\\) is conformally isomorphic to \\(\\tilde R/G\\) where \\(\\tilde R\\) is one of the three simply connected Riemann surfaces (\\(\\hat \\C, \\C, \\D\\)) and \\(G \\subseteq \\aut(\\tilde R)\\) acts freely and properly discontinuously.\n\\end{theorem}\n\nThree cases:\n\\begin{enumerate}\n\\item \\(\\hat \\C\\): as \\(\\aut(\\hat \\C)\\) are precisely the Möbius transformations and all Möbius transformations have fixed points, \\(G = 1\\) so \\(R = \\hat \\C\\).\n\\item \\(\\C\\): \\(\\aut(\\C) = \\{p(z) = az + b, a \\ne 0\\}\\) so \\(G\\) only contains translations, so can be identified by a subgroup of \\(\\C\\). Can show that \\(G\\) is one of \\(\\{0\\}, \\Z \\omega_1\\) or \\(\\Lambda = \\Z\\omega_1 \\oplus \\Z\\omega_2\\), a lattice. Then \\(R\\) is one of \\(\\C, \\C^*\\) or \\(\\C/\\Lambda\\), a complex torus.\n\\item \\(\\D\\): \\(\\aut(\\D) = \\{\\lambda \\cdot \\frac{z - a}{1 - \\conj a z}: \\lambda \\in S^1, a \\in \\D\\}\\), which has a lot of elements with no fixed point. This is called \\emph{hyperbolic}.\n\\end{enumerate}\n\nRecall \\(\\D\\) is equipped with metric \\(ds = \\frac{2 |dz|}{1 - |z|^2}\\), i.e.\\ the distance between \\(x, y \\in \\D\\) is\n\\[\n  \\rho(x, y) = \\inf_\\gamma \\int_a^b \\frac{2 |\\gamma'(t)|}{1 - |\\gamma(t)|^2} dt\n\\]\nwhere \\(\\gamma: [a, b] \\to \\D\\) is a smooth curve from \\(x\\) to \\(y\\). One can use the origin to show that\n\\[\n  \\rho(x, y) = \\frac{\\log(1 + R)}{\\log(1 - R)}\n\\]\nwhere \\(R = |\\frac{y - x}{1 - \\conj x y}|\\). Elements of \\(\\aut(\\D)\\) are isometries of this metric so it descends to a hyperbolic metric on any hyperbolic Riemann surface, such that the covering map \\(\\tilde R \\to R\\) is a local isometry.\n\n\\begin{ex}\n  Let \\(R = \\D/G\\), \\(f: R \\to R\\) holomorphic. Then \\(f\\) lifts to a holomorphic \\(\\tilde f: \\D \\to \\D\\), unique up to a composition with an element of \\(G\\), and induces a group homomorphism \\(\\gamma \\mapsto \\gamma'\\) such that \\(\\tilde f \\compose \\gamma = \\gamma' \\compose \\tilde f\\).\n\\end{ex}\n\n\\begin{theorem}[Pick]\n  Let \\(f: S \\to T\\) be hyperbolic Riemann surfaces with Poincaré metric \\(\\rho_S, \\rho_T\\) respectively. Then for all \\(x, y \\in S\\),\n  \\[\n    \\rho_T(f(x), f(y)) \\leq \\rho_S(x, y).\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  By lifting (of \\(f \\compose \\pi_S: \\D \\to T\\)) it suffices to show this for \\(S = T = \\D\\). By computation this is the same as showing\n  \\[\n    \\frac{\\log (1 + R')}{\\log (1 - R')} \\leq \\frac{\\log (1 + R)}{\\log (1 - R)}\n  \\]\n  where \\(R = |\\frac{y - x}{1 - \\overline y x}|, R' = |\\frac{f(y) - f(x)}{1 - \\overline{f(y)} f(x)}|\\). Note \\(\\frac{\\log (1 + x)}{\\log (1 - x)}\\) is strictly increasing, so suffices to show \\(R' \\leq R\\). Let \\(\\mu_1(z) = \\frac{y - z}{1 - \\conj y z}, \\mu_2(z) = \\frac{f(y) - z}{1 - \\conj{f(y)} z}\\). Let \\(g = \\mu_2 \\compose f \\compose \\mu_1^{-1}: \\D \\to \\D\\). By Schwarz's lemma \\(|g(z)| \\leq |z|\\), i.e.\\ \\(|\\mu_2(f(w))| \\leq |\\mu_1(w)|\\), so \\(R' \\leq R\\).\n\\end{proof}\n\n\\begin{remark}\n  It follows from the ``strict inequality'' bit of Schwarz's lemma that exists \\(x, y\\) such that \\(\\rho_T(f(x), f(y)) = \\rho_S(x, y)\\) if and only if \\(f\\) lifts to a disk automorphism.\n\\end{remark}\n\n\\begin{eg}\n  Contracting holomorphic maps is a very strong requirement. Compre to, for example, \\(f(z) = z + 1\\) on \\(\\hat \\C\\) (drawing of different behaviour on two hemispheres).\n\\end{eg}\n\nCase of \\(\\hat \\C\\):\n\n\\begin{proposition}\n  Let \\(f: \\hat \\C \\to \\hat \\C\\) be a holomorphic nonconstant map. Then \\(f\\) is a rational map, i.e.\\ exists \\(a_1, \\dots, a_m, b_1, \\dots, b_n, c \\in \\C\\) such that\n  \\[\n    f(z) = c \\cdot \\frac{(z - a_1) \\cdots (z- a_m)}{(z - b_1) \\cdots (z- b_n)}.\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  wlog \\(f(\\infty) \\in \\C\\) (if not, replace with \\(\\frac{1}{f}\\)). Then exist a finite collection \\(f^{-1}(\\infty) = \\{b_1, \\dots, b_n\\} \\subseteq \\C\\). About any \\(b_i\\) have locally\n  \\[\n    f(z) = \\sum_{j = -k}^\\infty a_{ij} (z - b_i)^j.\n  \\]\n  Set \\(Q_i = \\sum_{j = -k}^{-1} a_{ij} (z - b_i)^j\\). Then \\(g - f - Q_1 - \\dots - Q_n\\) has no pole so must be constant.\n\\end{proof}\n\nUniversal cover \\(\\C\\): just a remark. Yes there are interesting dynamics. For example \\(z \\mapsto e^z\\) belongs to the realm of transcendental dynamics. \\(\\C/\\Lambda\\) also admits nonconstant holomorphic maps. See example sheet 1.\n\n\\paragraph{stable and unstable locus}\n\nMotivating example: \\(z \\mapsto z^2\\) on \\(\\hat \\C\\). We can restrict \\(f\\) to the unit disk and we see \\(f|_\\D^n \\to 0\\) uniformly on compact subsets of \\(\\D\\). Similarly on \\(\\hat \\C \\setminus \\overline \\D\\), \\(f|_{\\hat \\C \\setminus \\overline \\D}^n \\to \\infty\\). On the other hand for \\(|z_0| = 1\\), there is no neighbourhoood \\(z_0 \\in U\\) such that \\(f|_U^n(z)\\) converging to a holomorphic function, as such a limit would have a discontinuity.\n\n\\begin{definition}[locally uniform convergence/divergence]\\index{locally uniform convergence}\\index{locally uniform divergence}\n  Let \\(S, T\\) be metric spaces, \\(f_n: S \\to T\\) a sequence of continuous maps. We say \\((f_n)\\) \\emph{converges locally uniformly} if for all compact \\(K \\subseteq S\\), for all \\(\\varepsilon > 0\\) exists \\(N \\in \\N\\) such that for all \\(m, n > N\\), \\(\\sup_{x \\in K} d_T(f_m(x), f_n(x)) < \\varepsilon\\).\n\n  We say \\((f_n)\\) \\emph{diverges locally uniformly} if for all compact \\(K \\subseteq S\\) and all compact \\(K' \\subseteq T\\), exists \\(N \\in \\N\\) such that for all \\(n > N\\), \\(f_n(K) \\cap K' = \\emptyset\\).\n\\end{definition}\n\nRecall that if holomorphic \\(f_n\\)'s converge locally uniformly on \\(S\\) then it has a holomorphic limit function.\n\n\\begin{remark}\n  If \\(T\\) is compact then we never have locally uniform divergence.\n\\end{remark}\n\n\\begin{definition}[normal family]\\index{normal family}\n  We say a family \\(\\mathcal F = \\{f: S \\to T\\}\\) of continuous functions is \\emph{normal} if every sequence \\((f_n) \\subseteq \\mathcal F\\) has a subsequence which either converges locally uniformly or diverges locally uniformly.\n\\end{definition}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show normality depends only on the topology, not the metric, of the spaces.\n  \\item Normality is local: if \\(\\mathcal F\\) is a family of continuous maps, \\(S = \\bigcup_\\alpha U_\\alpha\\), then if \\(\\mathcal F|_{U_\\alpha}\\) is normal for all \\(\\alpha\\) then \\(\\mathcal F\\) is normal for \\(S\\).\n  \\end{enumerate}\n\\end{ex}\n\nA word of caution: in some texts (such as Ahlfors) the definition of normality excludes divergence.\n\n\\begin{definition}[equicontinuity]\\index{equicontinuity}\n  A family \\(\\mathcal F\\) of continuous maps on a domain \\(U \\subseteq \\C\\) with values in a metric space \\(T\\) is \\emph{equicontinuous} if for all \\(\\varepsilon > 0\\), exists \\(\\delta > 0\\) such that for all \\(z, w \\in U\\) and for all \\(f \\in \\mathcal F\\), if \\(|z - w| < \\delta\\) then \\(d_T(f(z), f(w)) < \\varepsilon\\).\n\\end{definition}\n\n\\begin{theorem}[Arzela-Ascoli]\n  Let \\(\\mathcal F\\) be a family of continuous maps \\(U \\to T\\) with \\(U \\subseteq \\C\\) a domain and \\(T\\) a metric space. Then \\(\\mathcal F\\) has the property that any sequence has a locally uniformly convergent subsequence if and only if\n  \\begin{enumerate}\n  \\item \\(\\mathcal F\\) is equicontinuous on every compact \\(K \\subseteq U\\),\n  \\item for every \\(z \\in U\\), \\(\\{f(z): f \\in \\mathcal F\\}\\) lies in a compact subset of \\(T\\).\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{corollary}\n  If \\(T\\) is compact then \\(\\mathcal F\\) is normal if and only if it is equicontinuous on compact subsets of \\(U\\).\n\\end{corollary}\n\n\\begin{proof}\n  Only if is easy. For if, we use separability of \\(\\C\\). Let \\(\\{z_k\\}\\) be a countable dense subset of \\(U\\) and fix \\(\\{f_n\\} \\subseteq \\mathcal F\\). Can find a set of indices \\(n_{11} < n_{12} < \\cdots\\) such that \\(f_{n_{1i}}(z_1)\\) converges, and a subsequence of these \\(n_{21} < n_{22} < \\cdots\\) such that \\(f_{n_{2i}}(z_2)\\) converges. Let \\(g_k = f_{n_{kk}}\\). Then for all \\(z_i\\) the limit \\(\\lim_{k \\to \\infty} g_k(z_i)\\) exists in \\(T\\). Now given \\(K \\subseteq U\\) compact, by equicontinuity for any \\(\\varepsilon > 0\\) exists \\(\\delta > 0\\) such that for all \\(z, w \\in U\\) with \\(|z - w| < \\delta\\), we have for all \\(f \\in \\mathcal F\\), \\(d_T(f(z), f(w)) < \\varepsilon\\). Cover \\(K\\) by \\(\\delta\\)-balls, extract a finite subcover, and choose some \\(z_i\\) in each, say \\(z_1, \\dots, z_\\ell\\). For each \\(z_i\\), \\(1 \\leq i \\leq \\ell\\), exists \\(N_i\\) such that for all \\(n, m \\geq N_i\\), \\(d_T(g_n(z_i), g_m(z_i)) < \\varepsilon\\). Let \\(N = \\max_i N_i\\). Then for all \\(z \\in K\\),\n  \\begin{align*}\n    d_T(g_n(z), g_m(z))\n    &\\leq d_T(g_n(z), g_n(z_i)) + d_T(g_n(z_i), g_m(z_i)) + d_T(g_n(z_i), g_m(z)) \\\\\n    &< 3\\varepsilon\n  \\end{align*}\n\\end{proof}\n\n\\begin{theorem}[Montel]\\index{Montel's theorem}\n  Suppose \\(S, T\\) are Riemann surfaces and \\(T\\) is hyperbolic. Then all families of holomorphic maps \\(S \\to T\\) are normal.\n\\end{theorem}\n\n\\begin{proof}\n  If \\(S\\) is not hyperbolic, lifting plus Liouville's theorem imply that all maps are constant. Given a family \\(\\mathcal F\\) of constant maps, let \\(\\{f_n\\} \\subseteq \\mathcal F\\) be a sequence. Then if \\(\\{f_n(S)\\}\\) lies in a compact set in \\(T\\), then exists a convergent subsequence; if not, exists a subsequence which leaves any compact set, so diverges locally uniformly.\n\n  Suppose \\(S\\) is hyperbolic, \\(\\{f_n\\} \\subseteq \\mathcal F\\). If exists \\(x \\in S\\) such that \\(\\{f_n(x)\\}\\) lies in a compact subset of \\(T\\), the same is true for all \\(y \\in S\\). Pick's therom implies equicontinuity so by Arzela-Ascoli \\(\\{f_n\\}\\) has a convergent subsequence. Otherwise fix \\(x \\in S\\) and \\(y \\in T\\) and exists a subsequence \\(\\{f_{n_k}\\}\\) such that \\(d_T(f_{n_k}(x), y) \\to \\infty\\). Given \\(K \\subseteq S, K' \\subseteq T\\) compact, by Pick's theorem \\(d_T(f_{n_k}(z), y) \\to \\infty\\) for all \\(z \\in K\\) and so \\(f_{n_k}(K) \\cap K' = \\emptyset\\) for \\(k \\gg 1\\). Thus the sequence diverges locally uniformly.\n\\end{proof}\n\n\\begin{eg}\n  If \\(f: \\hat \\C \\to \\hat \\C\\) is a rational map and \\(D \\subseteq \\hat \\C\\), then the family of iterates \\(\\mathcal F = \\{f^n\\}_{n \\in \\N}\\) is normal if \\(\\bigcup_{n \\in \\N} f^n(D)\\) omits 3 or more points of \\(\\hat \\C\\), as any domain of \\(\\hat \\C\\) with complement of cardinality \\(\\geq 3\\) is hyperbolic.\n\\end{eg}\n\n\\begin{definition}[proper map]\\index{proper map}\n  Suppose \\(U, V\\) are open subsets of Riemann surfaces and \\(f: U \\to V\\). \\(f\\) is proper if for every \\(K \\subseteq V\\) compact, \\(f^{-1}(K)\\) is compact in \\(U\\).\n\\end{definition}\n\nProper maps have well-defined degrees and satisfies the Riemann-Hurwitz formula. The proofs are similar to the compact case.\n\n\\begin{proposition}\n  Suppose \\(U, V\\) are open in \\(\\hat \\C\\). If \\(f: U \\to V\\) is proper holomorphic nonconstant then \\(f\\) has a well-defined degree, i.e.\\ for all \\(x\\in V\\), \\(|f^{-1}(x)|\\) is independent of \\(x\\), counting multiplicity.\n\\end{proposition}\n\n\\begin{theorem}[Riemann-Hurwitz]\n  With same assumptions as above, the Euler characteristic \\(\\chi(U)\\), \\(\\chi(V)\\) satisfy\n  \\[\n    \\chi(U) = (\\deg f) \\chi(V) - \\sum_{p \\in U}(e_p - 1)\n  \\]\n  where \\(e_p\\) is the local degree/ramification index of \\(f\\) at \\(p\\).\n\\end{theorem}\n\nNote that one strategy is to observe that for \\(U \\subseteq \\C\\), we can cover by \\(\\delta\\)-grid, let \\(\\delta \\to 0\\), we obtain a covering of \\(U\\) by open balls with compact closures and smooth boundaries.\n\n\\begin{corollary}\n  If \\(f: \\hat \\C \\to \\hat \\C\\) is holomorphic of degree \\(d\\), then \\(f\\) has \\(2d - 2\\) critical points, counting multiplicity.\n\\end{corollary}\n\n\\begin{corollary}\n  If \\(\\chi(U) = \\chi(V) = 0\\) then \\(f: U \\to V\\) proper holomorphic nonconstant is unramified.\n\\end{corollary}\n\n\\begin{definition}[Fatou set, Julia set]\\index{Fatou set}\\index{Julia set}\n  Let \\(f: \\hat \\C \\to \\hat \\C\\) be a holomorphic nonconstant map. The \\emph{Fatou set} of \\(f\\) is\n  \\[\n    F(f) = \\{z \\in \\hat \\C: \\text{ on some nbhd } z \\in U, f^n \\text{ forms a normal family}\\}.\n  \\]\n  The \\emph{Julia set} of \\(f\\) is \\(J(f) = \\hat \\C \\setminus F(f)\\).\n\\end{definition}\n\n\\begin{eg}\n  For \\(z \\mapsto z^2\\), we have normality on \\((\\hat \\C \\setminus \\overline \\D) \\cup \\D\\), and normality fails on any open neighbourhood which intersects \\(S^1\\). Thus \\(J(z^2) = S^1\\). This example might be slightly misleading, as we'll see that the Julia set of a rational map is almost never smooth.\n\\end{eg}\n\n\\begin{lemma}\n  \\(F(f)\\) and \\(J(f)\\) are totally \\(f\\)-invariant, i.e.\\ \\(f^{-1}(F(f)) = F(f), f^{-1}(J(f)) = J(f)\\).\n\\end{lemma}\n\n\\begin{proof}\n  Suffices to show that if \\(U \\subseteq \\hat \\C\\) then \\(\\{f^n|_U\\}\\) is normal on \\(U\\) if and only if \\(\\{f^{n + 1}|_{f^{-1}(U)}\\}\\) is normal on \\(f^{-1}(U)\\). If \\(K \\subseteq f^{-1}(U)\\) compact then\n  \\[\n    \\sup_{z \\in K} d(f^n(z), f^m(z)) = \\sup_{w \\in f(K)} d(f^{n - 1}(z), f^{m - 1}(z)).\n  \\]\n  Since \\(f\\) is proper (continuous map from compact space to Hausdorff space is proper) and continuous, compactness is preserved by both \\(f\\) and \\(f^{-1}\\).\n\\end{proof}\n\n\\begin{lemma}\n  \\(J(f) = J(f^n)\\) and \\(F(f) = F(f^n)\\) for all \\(n\\).\n\\end{lemma}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\n\\begin{remark}\n  The Julia set of \\(f\\) is the smallest (?) closed subset of \\(\\hat \\C\\) which is totally \\(f\\)-invariant and contains at least \\(3\\) points (for the moment assume \\(|J(f)| \\geq 3\\)), since the complement of any such set has \\(\\{f^n\\}\\) normal by Montel.\n\\end{remark}\n\nFor the rest of the course, we consider only rational maps with \\(\\deg f \\geq 2\\). See example sheet 1 for a description of \\(J(\\mu)\\) for \\(\\mu\\) a Möbius transformation.\n\n\\begin{theorem}\n  Let \\(z \\in U \\subseteq J(f)\\) be open. Then the union \\(V = \\bigcup_{n \\in \\N} f^n(U)\\) contains all but at most 2 points of \\(\\hat \\C\\). Any point \\(w \\notin V\\) is a critical point of the Fatou set.\n\\end{theorem}\n\n\\begin{proof}\n  The first statement follows from Montel. If \\(w \\notin V\\), since \\(f(V) \\subseteq V\\), then for all \\(n \\in \\N\\), \\(f^{-n}(w) \\cap V = \\emptyset\\). Suppose there are two points \\(\\{z_0, z_1\\}\\). Then examining possible ramification for these two points which are fixed under \\(f^{-1}\\), the only possiblities are \\(z_i \\mapsto z_i\\) with degree \\(d\\), or \\(z_1 \\mapsto z_2, z_2 \\mapsto z_1\\) with degree \\(d\\). The case for a single point is similiar.\n\n  Replacing \\(f\\) by \\(f^2\\) if needed, it suffcies to show that if \\(f(z) = z\\) and \\(f'(z) = 0\\) then \\(z \\in F(f)\\). Note that if \\(\\mu \\in \\aut(\\hat \\C)\\), \\(g = \\mu^{-1} \\compose f \\compose \\mu\\), then \\(g^n = \\mu^{-1} \\compose f^n \\compose \\mu\\), and so \\(\\mu(J(g)) = J(f)\\). Thus wlog \\(f(0) = 0, f'(0) = 0\\). Locally we have \\(f(z) = a_2 z^2 + a_3z^3 + \\dots = z^2(a_2 + O(z))\\) about \\(0\\), so \\(|f(z)| < |z|\\) for \\(z\\) sufficiently close to \\(0\\), so on a neighbourhood of \\(0\\), \\(f^n \\to 0\\) so form a normal family.\n\\end{proof}\n\nThe three cases do happen: \\(z \\mapsto z^d, z \\mapsto z^{-d}, z \\mapsto p(z)\\) for \\(p\\) a polynomial with nonzero constatnt term.\n\n\\begin{remark}\n  If \\(f^n(z_0) = z_0\\) for some \\(n \\in \\N\\) and \\((f^n)'(z_0) = \\prod_{i = 0}^{n - 1} f'(f^i(z_0)) = 0\\) then \\(z_0 \\in F(f)\\).\n\\end{remark}\n\n\\begin{corollary}\n  If \\(J(f)\\) contains an interior point then \\(J(f) = \\hat \\C\\).\n\\end{corollary}\n\n\\begin{proof}\n  If \\(U\\) is open in \\(J(f)\\), \\(V = \\bigcup f^n(U)\\) contains all but at most 2 points on \\(\\hat \\C\\). Since \\(J(f)\\) is closed by definition, \\(J(f) = \\hat \\C\\).\n\\end{proof}\n\nThis does happen: let \\(E_t: y^2 = x(x - 1)(x - t)\\) for \\(t \\in \\C \\setminus \\{0, 1\\}\\) be an elliptic curve.\n\\[\n  \\begin{tikzcd}\n    E_t \\ar[r, \"{[2]}\"] \\ar[d] & E_t \\ar[d] \\\\\n    \\hat \\C \\ar[r, \"f_t\"] & \\hat \\C\n  \\end{tikzcd}\n\\]\nwhere the vertical maps are quotient by ?, i.e.\\ \\((x, y) \\mapsto x\\). Then\n\\[\n  f_t(z) = \\frac{(z^2 - t)^2}{4z(z-1)(z - t)}.\n\\]\nWe can show \\(J(f_t)\\) is dense in \\(\\hat \\C\\) by showing the Julia set of \\([2]\\) is dense, and thus \\(J(f_t) = \\hat \\C\\).\n\n\\begin{definition}[period, multiplier]\\index{period}\\index{multiplier}\n  Let \\(z_0 \\in \\hat \\C\\). We say \\(z_0\\) is \\emph{periodic} for a rational \\(f\\) if exists \\(m \\in \\N\\) such that \\(f^m(z_0) = z_0\\). The minimal such \\(m\\) is the \\emph{period} of the cycle containing \\(z_0\\). If \\(m = 1\\) we also call it a \\emph{fixed point}.\n\n  If \\(z_0\\) has period \\(m\\), the \\emph{multiplier} of the cycle is\n  \\[\n    (f^m)'(z_0) = \\prod_{i = 0}^{m - 1} f'(f^i(z_0)).\n  \\]\n  Let \\(\\lambda\\) be the multiplier of \\(z_0\\). We say \\(z_0\\) is\n  \\begin{enumerate}\n  \\item \\emph{superattracting} if \\(\\lambda = 0\\),\n  \\item \\emph{attracting} if \\(0 \\leq |\\lambda| < 1\\),\n  \\item \\emph{indifferent} if \\(|\\lambda| = 1\\),\n  \\item \\emph{repelling} if \\(|\\lambda| > 1\\).\n  \\end{enumerate}\n\\end{definition}\nRecall that we might have to use the chart at infinity to compute the derivative. For example if \\(z_0 = \\infty, f(\\infty) = \\infty\\) then\n\\[\n  \\lambda = \\lim_{z \\to \\infty} \\frac{1}{f'(z)}.\n\\]\n\n\\begin{definition}[basin of attraction]\\index{basin of attraction}\n  Suppose \\(C = \\{z_0, f(z_0), \\dots, f^{m - 1}(z_0)\\}\\) is an attracting cycle. The \\emph{basin of attraction} for \\(C\\) is\n  \\[\n    A = \\{z \\in \\hat \\C: \\lim_{n \\to \\infty} f^{nm}(z) = f^i(z_0) \\text{ for some } 0 \\leq i \\leq m - 1\\}.\n  \\]\n\\end{definition}\n\n\\begin{theorem}\n  If \\(f: \\hat \\C \\to \\hat \\C\\) has an attracting cycle then the basin of attraction is in \\(F(f)\\). On the other hand all repelling cycles are contained in \\(J(f)\\).\n\\end{theorem}\n\n\\begin{eg}\n  The theorem completely describes the Fatou and Julia set of \\(z \\mapsto z^2\\). \\(z_0\\) is periodic if and only if exists \\(n\\) such that \\(z_0^{2^n} = z_0\\), so \\(z_0\\) is \\(0, \\infty\\) or some root of unity (which forms a dense subset of \\(S^1\\)). \\(A_0 = \\D, A_\\infty = \\hat \\C \\setminus \\overline \\D\\). All other cycles are repelling and so \\(J(f) = S^1\\).\n\\end{eg}\n\n\\begin{proof}\n  Since \\(J(f^m) = J(f)\\), wlog assume \\(z_0\\) is a fixed point. Suppose that \\(\\lambda = f'(z_0)\\) is such that \\(|\\lambda| < 1\\). By Taylor expansion \\(|f(z) - z_0| \\leq c |z - z_0|\\) for some constant \\(c < 1\\) for \\(z\\) sufficiently close to \\(z_0\\). So on a neighbourhood of \\(_0\\), \\(f^n(z)\\) converges uniformly on compact subsets to the constant function \\(z_0\\). So \\(z_0 \\in F(f)\\).\n\n  On the other hand if \\(z_0\\) is repelling so \\(|\\lambda| > 1\\), suppose for contradiction that \\(z_0 \\in F(f)\\), so exists open neighbourhood \\(U\\) of \\(z_0\\) on which \\(f^n\\) has a subsequence converging to a holomorphic limit. Since \\((f^n)'(z_0) = \\lambda^n\\), absurd.\n\\end{proof}\n\n\\begin{remark}\n  We will classify later when indifferent points are Julia.\n\\end{remark}\n\n\\subsection{Holomorphic Lefschetz fixed point formula}\n\n\\begin{definition}[residue index]\\index{residue index}\n  Let \\(z_0\\) be a fixed point of a rational map \\(f\\). The \\emph{residue index} of \\(f\\) at \\(z_0\\) is\n  \\[\n    i_f(z_0) = \\frac{1}{2\\pi i} \\int_\\gamma \\frac{dz}{z - f(z)}\n  \\]\n  where \\(\\gamma\\) is a small, positively oriented circle about \\(z_0\\).\n\\end{definition}\n\n\\begin{lemma}\n  Let \\(z_0\\) have multiplier \\(\\ne 1\\). Then \\(i_f(z_0) = \\frac{1}{1 - \\lambda}\\).\n\\end{lemma}\n\n\\begin{proof}\n  It is an exercise to check the multiplier is coordinate-independent. By definition the resude index is translation/conjugation independent, so wlog \\(z_0 = 0\\). Then on a neighbourhood of \\(0\\), \\(f(z) = \\lambda z + a_2z^2 + \\dots\\) so\n  \\[\n    \\frac{1}{z - f(z)} = \\frac{1}{(1 - \\lambda) z (1 + O(z))} = \\frac{1}{(1 - \\lambda) z} + g(z)\n  \\]\n  with \\(g\\) holomorphic on a neighbourhood of \\(0\\). Integrate.\n\\end{proof}\n\n\\begin{theorem}[holomorphic Lefschetz on \\(\\hat \\C\\)]\n  Say \\(f: \\hat \\C \\to \\hat \\C\\) of degree \\(\\geq 2\\). Then the fixed points of \\(f\\) satisfy\n  \\[\n    \\sum_{z = f(z)} i_f(z) = 1.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Conjugation if necessary (exercise: use the above lemma to show the residue index is coordinate-independent), wlog \\(f(\\infty) \\ne \\infty\\). Choose \\(R \\gg 0\\) so that all fixed points of \\(f\\) are in \\(D(0, R)\\). Call the positively oriented boundary \\(C_R\\). By residue theorem\n  \\begin{align*}\n    \\sum_{z = f(z)} i_f(z)\n    &= \\frac{1}{2\\pi i} \\int_{C_R} \\frac{dz}{z - f(z)} \\\\\n    &= \\frac{1}{2\\pi i} \\int_{-C_{1/R}} \\frac{-dw}{w^2(\\frac{1}{w} - f(\\frac{1}{w}))} \\\\\n    &= \\frac{1}{2\\pi i} \\int_{C_{1/R}} \\frac{dw}{w(1 - wf(\\frac{1}{w}))} \\\\\n    &= \\operatorname{Res}_{w = 0} \\frac{1}{w(1 - wf(\\frac{1}{w}))} \\\\\n    &= 1\n  \\end{align*}\n\\end{proof}\n\n\\begin{corollary}\n  Suppose \\(\\deg f \\geq 2\\). Then \\(J(f) \\ne \\emptyset\\).\n\\end{corollary}\n\n\\begin{proof}\n  Consider the fixed points of \\(f\\). Assume first no fixed point multiplier is \\(1\\). Then \\(\\lambda \\mapsto \\frac{1}{1 - \\lambda}\\) sends the unit circle to the line \\(\\Re = \\frac{1}{2}\\), and \\(\\D\\) to \\(\\Re > \\frac{1}{2}\\). Thus if \\(|\\lambda| \\leq 1\\) for all fixed point multipliers, and not equal to \\(1\\), (there is no multiplicity), there are \\(d + 1 \\geq 3\\) distinct fixed points (?), so \\(\\Re( \\sum_{z = f(z)} i_f(z)) \\geq \\frac{3}{2}\\), absurd. If exists a repelling point then done. So suppose \\(z_0\\) is fixed with \\(\\lambda = 1\\). Then in local coordinates \\(f(z) = z + a_kz^k + \\dots\\) where \\(a_k \\ne 0\\). Inductively \\(f(z) = z + na_kz^k + \\dots\\) so the \\(k\\)th derivative of \\(f^n(z_0)\\) is \\(k! na_k \\to \\infty\\) as \\(n \\to \\infty\\), so the iterates cannot form a normal family on a neighbourhood of \\(z_0\\).\n\\end{proof}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item Suppose \\(z_0\\) is a indifferent fixed point, \\(\\lambda\\) a root of unity. If \\(\\lambda^k = 1\\) then \\((f^k)'(z_0) = \\prod_{i = 0}^{k - 1} f'(f(z_0)) = \\lambda^k = 1\\). Thus the preceding argument shows that \\(z_0 \\in J(f^k) = J(f)\\).\n  \\item It is possible for a rational map to have non repelling fixed point. For example \\(z \\mapsto z^2 + \\frac{1}{4}\\). The fixed points are \\(\\infty\\) and \\(\\frac{1}{2}\\) which is a double fixed point.\n  \\item Any finite \\emph{grand orbit} (the set \\(\\{z \\in \\hat \\C: f^m(z) = f^n(z_0) \\text{ for some } m, n\\}\\)) is necessarily Fatou (exercise), so \\(|J(f)| = \\infty\\).\n  \\end{enumerate}\n\\end{remark}\n\nRecall: suppose \\(f: \\hat \\C \\to \\hat \\C\\) is a rational map of degree \\(d \\geq 2\\).\n\n\\begin{enumerate}\n\\item If \\(U\\) is open, \\(U \\cap J(f) \\ne \\emptyset\\) then \\(\\bigcup_{n \\geq 1} f^n(U)\\) contains all but at most 2 points and contains \\(J(f)\\).\n\\item \\(J(f)\\) contains all repelling cycles and all indifferent cycles with roots of unity multipliers.\n\\item \\(J(f) \\ne \\emptyset\\) and \\(|J(f)| = \\infty\\).\n\\end{enumerate}\n\n\\begin{proposition}\n  Suppose \\(f\\) has a periodic cycle which is attracting, with attracting basin \\(A\\). Then \\(J(f) = \\p A\\).\n\\end{proposition}\n\n\\begin{proof}\n  Given \\(U\\) an open neighbourhood such that \\(U \\cap J(f) \\ne \\emptyset\\), exists \\(n\\) such that \\(f^n(U) \\cap A = \\emptyset\\). As \\(A\\) is closed under preimages, \\(U \\cap A \\ne \\emptyset\\). Thus \\(J(f) \\subseteq \\overline A\\). Since \\(A \\subseteq F(f)\\), \\(J(f) \\subseteq \\p A\\).\n\n  Conversely suppose \\(z_0 \\in \\p A\\) and \\(U\\) is a neighbourhood of \\(z_0\\). Suppose \\(\\{f^n\\}\\) forms a normal family on \\(U\\). On \\(U \\cap A\\), any holomorphic limit \\(g\\) of iterates of \\(f\\) must take finitely many constant values, but \\(g\\) cannot be locally constant as \\(U\\) contains points not in the basin, absurd. Thus \\(z_0 \\in J(f)\\).\n\\end{proof}\n\n\\begin{eg}\n  Any \\emph{polynomial} \\(f\\) has \\(J(f)\\) the boundary of basin at \\(\\infty\\). Note that it might also be the boundary of another basin, for example \\(z \\mapsto z^2, z \\mapsto z^2 - 1\\).\n\\end{eg}\n\n\\begin{corollary}\n  Fix \\(z_0 \\in J(f)\\). Then the full preimage \\(\\{z: f^n(z) = z_0 \\text{ for some } n \\geq 0\\}\\) forms a dense subset of \\(J(f)\\).\n\\end{corollary}\n\n\\begin{proof}\n  Fix \\(z_1 \\in J(f)\\) and a neighbourhood \\(U \\ni z_1\\). If it contains no preimage of \\(z_0\\) then \\(\\bigcup f^n(U) \\notin z_0\\), absurd.\n\\end{proof}\n\nTopological preimage equidistribution\n\n\\subsection{Attracting (and repelling) cycles}\n\n\\begin{definition}[topologically attracting]\\index{topologically attracting}\n  A fixed point \\(p\\) of \\(f\\) is \\emph{topologically attracting} if there exists a neighbourhood \\(U \\ni p\\) such that \\(\\{f^n\\}\\) converges locally uniformly to \\(p\\) on \\(U\\).\n\\end{definition}\n\n\\begin{lemma}\n  A fixed point \\(p\\) of \\(f\\) is attracting if and only if it is topologically attracting.\n\\end{lemma}\n\n\\begin{proof}\n  Exercise. Taylor's theorem in one direction, and Schwarz lemma in the other.\n\\end{proof}\n\n\\begin{theorem}\n  Suppose \\(f\\) has a fixed point \\(p\\) with multiplier \\(\\lambda\\), \\(|\\lambda| \\ne 0, 1\\). Then exists local holomorphic change of coordinates \\(\\phi\\) such that \\(\\phi(p) = 0\\) and \\(\\phi \\compose f \\compose f^{-1}(w) = \\lambda w\\). Thus coordinate is unique up to multiplication by a constant. \\(\\phi\\) is known as the \\emph{Kaenig linearising map}\\index{Kaenig linearising map}.\n\\end{theorem}\n\n\\begin{proof}\n  wlog \\(p = 0\\) and first suppose \\(0 < |\\lambda| < 1\\). Choose a constant \\(c\\) such that \\(c^2 < |\\lambda| < c\\). Find \\(r > 0\\) such that for all \\(z \\in D(0, r)\\), \\(|f(z)| \\leq c |z|\\), so \\(|f^n(z)| \\leq c^n r\\). We can find \\(B > 0\\) such that for all \\(z \\in D(0, r)\\), \\(|f(z) - \\lambda z| \\leq B |z|^2\\). Thus for all \\(z \\in D(0, r)\\),\n  \\[\n    |f^{n + 1}(z) - \\lambda f^n(z)| \\leq B |f^n(z)|^2 \\leq B r^2 c^{2n}.\n  \\]\n  Let \\(w_n = \\frac{f^n(z)}{\\lambda^n}\\). Then\n  \\[\n    |w_{n + 1}(z) - w_n(z)|\n    = \\left| \\frac{f^{n + 1}(z)}{\\lambda^{n + 1}} - \\frac{f^n(z)}{\\lambda^n} \\right|\n    \\leq \\frac{1}{|\\lambda|^{n + 1}} Br^2 c^{2n}\n    = \\frac{Br^2}{\\lambda} \\left|\\frac{c^2}{\\lambda}\\right|^n\n  \\]\n  so \\(w_n\\) converges locally uniformly on \\(D(0, r)\\). Set \\(\\phi(z) = \\lim w_n(z)\\). As \\(z \\mapsto w_n(z)\\) has derivative \\(1\\) at \\(0\\), so does \\(\\phi\\) so it has a holomorphic inverse.\n\n  For uniqueness suppose \\(\\psi\\) is another such coordinate, then for \\(w \\in \\psi(U)\\) have \\(\\lambda \\phi(\\psi^{-1}(w)) = \\phi(\\psi^{-1}(\\lambda w))\\). Done by comparing local power series.\n\n  For \\(|\\lambda| > 1\\) apply the same argument to a branch of \\(f^{-1}\\).\n\\end{proof}\n\n\\begin{corollary}\n  Suppose \\(p\\) is an attracting fixed point of \\(f\\) with multiplier \\(\\lambda \\ne 0\\) and basin \\(A\\). Then exists a holomorphic \\(\\phi: A \\to \\C\\) such that the following diagram commutes\n  \\[\n    \\begin{tikzcd}\n      A \\ar[r, \"f\"] \\ar[d, \"\\phi\"] & A \\ar[d, \"\\phi\"] \\\\\n      \\C \\ar[r, \"\\lambda\"] & \\C\n    \\end{tikzcd}\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Define \\(\\phi(z) = \\lim_{n \\to \\infty} \\frac{\\phi_0(f^n(z))}{\\lambda^n}\\) where \\(\\phi_0\\) is the linearlising coordinates on a neighbourhood of \\(p\\). Check the details.\n\\end{proof}\n\n\\begin{definition}[immediate basin]\\index{immediate basin}\n  The \\emph{immediate basin} of an attracting cycle is the union of the Fatou components containing the cycle elements.\n\\end{definition}\n\n...\n\n\\(\\frac{z^2 - 1}{z^2 - c}\\) attracting \\(5\\)-cycle \\(\\infty \\mapsto 1 \\mapsto 0 \\mapsto \\frac{1}{c}\\)\n\n\\begin{proposition}\n  Let \\(f\\) be a rational map with \\(f(p) = p\\) an attracting fixed point. Then the immediate basin of \\(p\\) contains a critical point of \\(f\\).\n\\end{proposition}\n\n\\begin{proof}\n  wlog \\(p = 0\\). The component \\(U\\) of \\(F(f)\\) is hyperbolic as \\(|J(f)| = \\infty\\). Thus we have\n  \\[\n    \\begin{tikzcd}\n      \\D \\ar[r, \"F\"] \\ar[d, \"\\pi\"] & \\D \\ar[d, \"\\pi\"] \\\\\n      U \\ar[r, \"f\"] & U\n    \\end{tikzcd}\n  \\]\n  If \\(f\\) has no critical points in \\(U\\) then \\(f \\compose \\pi\\) is a covering map \\(\\D \\to U\\) so exists \\(G: \\D \\to \\D\\) covering it. If \\(\\pi, F, G\\) fix \\(0\\), \\(G\\) is inverse to \\(F\\). Thus \\(F \\in \\aut(\\D)\\) so \\(F, f\\) are hyperbolic local isometries, contradicting \\(0\\) an attracting fixed point.\n\\end{proof}\n\n\\begin{corollary}\n  \\(f\\) has at most \\(2d - 2\\) attracting cycles.\n\\end{corollary}\n\n\\begin{corollary}\n  \\(f\\) has at most \\(4d - 4\\) non-repelling cycles.\n\\end{corollary}\n\n\\begin{proof}\n  Holomorphic perturbation. Let \\(f_t(z) = (1 - t) f(z) + tz^d\\). Note \\(f_0 = f(z), f_1 = z^d\\). Suppose \\(f^n(\\alpha) = \\alpha\\) with multiplier \\(\\lambda \\in S^1\\). If \\(\\alpha\\) is not a repeated root of \\(f^n(z) - z\\) there is a neighbourhood of \\(0\\) and holomorphic \\(t \\mapsto \\alpha(t)\\) such that \\(\\alpha(0) = \\alpha\\) and \\(f^n(\\alpha(t)) = \\alpha(t)\\) for all \\(t\\), i.e.\\ if \\(\\lambda \\ne 1\\) (?). But if \\(\\lambda = 1\\) we can base change \\(t \\mapsto t^k\\). We then have \\(t \\mapsto \\lambda(t)\\) homomorphic in \\(t\\), \\(\\lambda(0) = \\lambda\\) and \\((f^n)'(\\alpha(t)) = \\lambda(t)\\). Either \\(\\lambda(t)\\) is the constant \\(1\\) (more argument needed), or another constant \\(\\lambda\\), or nonconstant. The first two cases contradict \\(z^d\\) having no indifferent cycles at \\(t = 1\\).\n\n  By conformality of holomorphic maps, the measure\n  \\[\n    \\mu(\\{\\theta \\in S^1: |\\lambda(\\varepsilon e^{i\\theta})|\\}) \\to \\frac{1}{2}\n  \\]\n  as \\(\\varepsilon \\to 0\\). Repeating this process for all indifferent cycles, exists a direction \\(\\theta\\) such that perturbation in the \\(\\theta\\)-direction makes half of these cycles attracting. For sufficiently small choice of \\(\\varepsilon e^{i\\theta}\\), attracting cycles remain attracting. Let \\(N\\) be the number of indifferent cycles of \\(f\\), \\(M\\) the number of attracting cycles of \\(f\\), then the number of non-repelling cycles of \\(f\\) is \\(N + M = 2(M/2 + N/2) \\leq 2 (2d - 2)\\).\n\\end{proof}\n\n\\begin{remark}\n  \\(f^n(z) = z\\) has \\(z^n + 1\\) roots counting multiplicity, so must have a repelling cycle.\n\\end{remark}\n\nNote we can be more precise, see example sheet.\n\n\\begin{theorem}\n  If \\(f(0) = 0\\) is attracting with multiplier \\(\\lambda \\ne 0\\). Let \\(\\phi\\) be a linearising coordinate with local inverse \\(\\psi: \\D(0, \\varepsilon) \\to A_0\\), where \\(A_0\\) is the immediate basin of \\(0\\). \\(\\psi\\) extends to a holomorphic map on a disk \\(\\D(0, r)\\) of some maximal radius \\(r\\), extending homeomorphically to \\(\\p \\D(0, r)\\) and \\(\\psi(\\p \\D(0, r))\\) contains a critical point of \\(f\\).\n\\end{theorem}\n\n\\begin{remark}\n  Actually detecting whether \\(f\\) has an attractor is harder. Open problem: does \\(z \\mapsto z^2 - \\frac{3}{2}\\) has an attractor?\n\\end{remark}\n\nCaution: linearising map need not continuously extend to \\(J(f)\\).\n\n\\begin{theorem}\n  If \\(f\\) rational has \\(J(f)\\) disconnected then \\(J(f)\\) has uncountably many connected components.\n\\end{theorem}\n\n\\begin{proof}\n  If \\(J(f) = J_0 \\cup J_1\\) where \\(J_0, J_1\\) are disjoint compact nonempty. Given \\(z \\in J\\), define a seuqnce \\(\\beta(z) = (\\beta_n(z))\\) where \\(\\beta_n(z) = i\\) if \\(f^n(z) \\in J_i\\). If \\(z, w\\) are in the same connected component of \\(J(f)\\) then \\(\\beta(z) = \\beta(w)\\). It suffices to show that for any initial \\(\\beta_1(z), \\dots, \\beta_k(z)\\), exists \\(n > k\\) such that exists \\(z' \\in J(f)\\) such that \\(\\beta_i(z') = \\beta_i(z)\\) for all \\(1 \\leq i \\leq k\\) but \\(\\beta_n(z') \\ne \\beta_n(z)\\). Define\n  \\[\n    U_{z, k} = \\{w \\in \\hat \\C: f^i(w) \\notin J_{1 - \\beta_i(z)} \\text{ for all } 1 \\leq i \\leq k\\}.\n  \\]\n  This is open and contains \\(F(f)\\). Some subsequence \\((\\beta_{n_j}(z))\\) is constant, say the constant \\(0\\). If \\(\\beta_i(z') = \\beta_i(z)\\) for all \\(1 \\leq i \\leq k\\) then \\(\\beta_i(z') = \\beta_i(z)\\) for all \\(i\\), then\n  \\[\n    f^{n_j}(U_{z, k}) \\subseteq \\C \\setminus J_1.\n  \\]\n  The maps \\(f^{nj}: U_{z, k} \\to \\C \\setminus J_1\\) form a normal family, contradiction. Thus \\(\\{\\beta(z): z \\in J(f)\\}\\) is uncountable.\n\\end{proof}\n\n\\paragraph{Superattractor}\n\n\\begin{theorem}\n  Suppose \\(f(0) = 0\\) is with local expansion \\(f(z) = a_mz^m + a_{m + 1}z^{m + 1} + \\dots, m \\geq 2\\). Then there exists a holomorphic change of coordinates \\(\\phi\\) on a neighbourhood of \\(0\\) such that \\(\\phi(0) = 0\\), \\(\\phi(f(z)) = \\phi(z)^m\\). \\(\\phi\\) is unique up to multiplication by an \\((m - 1)\\)th root of unity. \\(\\phi\\) is called the \\emph{Böttcher coordinate}\\index{Böttcher coordinate}.\n\\end{theorem}\n\n\\begin{proof}\n  We sketch the proof only. The details are the same as Kaenig's. Write locally \\(f(z) = z^m(1 + h(z))\\), where \\(h(z) \\to 0\\) as \\(z \\to 0\\) is holomorphic, where \\(a_m = 1\\) (otherwise conjugate by \\(\\alpha f(z/\\alpha)\\)). Write \\(1 + h(z) = \\exp(k(z))\\) for some holomorphic \\(h(z)\\) on a neighbourhood of \\(0\\). Then there exists holomorphic \\(k_n(z)\\) on this neighbourhood so that \\(f^n(z) = z^{m^n} \\exp(k_n(z))\\). Choose the branch \\(\\phi_n(z)\\) of the \\(m^n\\)th root of \\(f^n(z)\\) such that \\(\\phi_n(z) = z(1 + O(z))\\). Then \\(\\phi_n\\) converges uniformly to some holomorphic \\(\\phi\\) on this neighbourhood which satisfies the statement. Uniqueness follows from identification of Taylor expansion, a la Kaenig.\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(f(0) = 0\\) be superattracting, with basin \\(A\\) and Böttcher coordinate \\(\\phi\\) on a neighbourhood of \\(0\\). Then \\(z \\mapsto |\\phi(z)|\\) extends to a continuous map \\(|\\phi|: A \\to [0, 1)\\) satisfying \\(|\\phi(f(z))| = |\\phi(z)|^m\\) for \\(z \\in A\\).\n\\end{corollary}\n\n\\begin{proof}\n  Given \\(z \\in A\\), set \\(|\\phi|(z) = |\\phi(f^n(z))|^{1/m^n}\\), where \\(n \\gg 1\\) such that \\(f^n(z)\\) is in the neighbourhood domain of \\(\\phi\\). The desired equality is immediate.\n\\end{proof}\n\n\\section{Polynomial dynamics}\n\n\\begin{definition}[filled Julia set]\\index{filled Julia set}\n  Let \\(p(z) = a_dz^d + a_{d - 1}z^{d - 1} + \\dots + a_0, d \\geq 2, a_d \\ne 0\\). The \\emph{filled Julia set} of \\(p\\) is\n  \\[\n    K(p) = \\{z \\in \\C: |f^n(z)| \\nto \\infty \\text{ as } n \\to \\infty\\}.\n  \\]\n\\end{definition}\n\nNote this is the complement of the basin of infinity.\n\nFrom our results on boundaries of basins, \\(\\p K(p) = J(p)\\). We know we have a Böttcher coordinate on a neighbourhood of \\(\\infty\\): choose this (i.e.\\ \\(\\phi(1/z)^{-1}\\)) such that \\(\\phi(\\infty) = \\infty\\).\n\n\\begin{definition}[Green's function]\\index{Green's function}\n  Suppose \\(p(z)\\) is a degree \\(d\\) polynomial. The \\emph{Green's function} associated to \\(p\\) is\n  \\[\n    G_p(z) = \\lim_{n \\to \\infty} \\frac{\\log^+ |p^n(z)|}{d^n}\n  \\]\n  where \\(\\log^+x = \\max\\{\\log x, 0\\}\\) for \\(x \\geq 0\\).\n\\end{definition}\n\n\\begin{lemma}\n  \\(G_p(z)\\) satisfying the following:\n  \\begin{enumerate}\n  \\item \\(G_p\\) is continuous everywhere and harmonic on \\(\\C \\setminus K(p)\\).\n  \\item \\(G_p(z) = \\log |z| + O(1)\\) as \\(|z| \\to \\infty\\).\n  \\item \\(G_p(z) \\to 0\\) as \\(z \\to K(p)\\).\n  \\item \\(G_p(p(z)) = d G_p(z)\\).\n  \\end{enumerate}\n  1, 2, 4 uniquely characterises \\(G_p\\), and \\(G_p(z) = \\log |\\phi_p(z)|\\), where \\(\\phi_p\\) is a Böttcher coordinate at \\(\\infty\\) on \\(\\hat \\C \\setminus K(p)\\).\n\\end{lemma}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item This is how pictures of filled Julia sets are drawn.\n  \\item The Green's function depends only on \\(K(p)\\).\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Consider the function \\(\\log^+|p(z)| - d \\log^+|z|\\) on \\(\\hat \\C\\). It is continuous and takes real values, so is bounded by some \\(C \\in \\R\\). Then for all \\(n\\),\n    \\[\n      \\left| \\frac{\\log^+|p^n(z)|}{d^n} - \\frac{\\log^+|p^{n - 1}(z)|}{d^{n - 1}}\\right| \\leq \\frac{C}{d^n}\n    \\]\n    so for \\(m \\leq n\\),\n    \\[\n      \\left| \\frac{\\log^+|p^n(z)|}{d^n} - \\frac{\\log^+|p^m(z)|}{d^m}\\right| \\leq \\sum_{k = m + 1}^n \\frac{C}{d^k} \\leq \\frac{C}{d^m (d - 1)}\n    \\]\n    so \\(G_p\\) is a uniform limit of continuous function so continuous.\n\n    Locally, a function is harmonic if and only if it is the real part of a holomophic function, if and only if it equals to \\(\\log |f|\\) for some holomorphic \\(f\\) that does not vanish anywhere (since on a simply connected domain we can take logarithm). Given \\(z \\notin K(p)\\), find a small disk \\(D \\ni p\\) such that \\(\\overline D \\cap K(p) = \\emptyset\\). There exists \\(N \\gg 1\\) such that \\(p^n(\\overline D) \\cap \\D = \\emptyset\\) for \\(n \\geq N\\). Then \\(\\frac{\\log^+ |p^n(z)|}{d^n}\\)  is harmonic on \\(\\overline D\\). Since a uniform limit of harmonics is harmonic, we have \\(G_p(z)\\) is harmonic on \\(D\\) as well. Note if \\(K(p)^{\\mathrm{int}}(p) \\ne \\emptyset\\) then \\(G_p(z) = 0\\) there so is harmonic as well. In other words, \\(G_p(z)\\) fails to be harmonic precisely on the Julia set (for more rigorous argument see later).\n  \\item Set \\(m = 0\\), then the bound in 1 gives\n    \\[\n      \\left| \\frac{\\log^+ |p^n(z)|}{d^n} - \\log^+|z| \\right| \\leq \\frac{C}{d - 1}\n    \\]\n    so as \\(n \\to \\infty\\), \\(|G_p(z) - \\log |z|| \\leq \\frac{C}{d - 1}\\) for \\(|z| \\gg 0\\).\n  \\item \\(G_p(z) = 0\\) on \\(K(p)\\).\n  \\item Definition.\n  \\end{enumerate}\n\n  Suppose \\(H(z)\\) is a function satisfying 1, 2 and 4 and consider \\(G(z) = G_p(z) - H(z)\\). By 1 and 2 it is continuous and bounded on \\(\\hat \\C\\). By 4, as \\(n \\to \\infty\\), \\(G(p^n(z)) = d^n G(z) \\to \\infty\\) unless \\(G(z) = 0\\). We thus have \\(G_p(z) = H(z)\\). For \\(G_p(z) = \\log |\\phi_p(z)|\\), check continuity, growth at \\(\\infty\\) and transformation.\n\\end{proof}\n\n\\begin{eg}\n  For \\(z \\mapsto z^d\\),\n  \\[\n    G_p(z) = \\lim \\frac{\\log^+|z^{d^n}|}{d^n} = \\log^+|z|.\n  \\]\n  \\(K(p) = \\overline D\\), where \\(\\log^+ |z| = 0\\). The basin of infinity is \\(\\hat \\C \\setminus \\D\\).\n\\end{eg}\n\n\\begin{remark}\n  \\(G_p(z)\\) is also known as the \\emph{potential function}\\index{potential function} associated to \\(K(p)\\).\n\\end{remark}\n\nNow back to superattractors.\n\n\\begin{theorem}\n  Suppose \\(f(0) = 0\\) is superattracting, with Böttcher coordinate \\(\\phi\\) for \\(f\\) at \\(0\\). There there exists a unique open disk \\(\\D(0, r)\\) of maximal radius \\(0 < r \\leq 1\\) such that the inverse \\(\\psi\\) of \\(\\phi\\) extends holomorphically to \\(\\psi: \\D(0, r) \\to A_0\\), the immediate basin of attraction of \\(0\\). If \\(r = 1\\) then \\(\\psi: D(0, t) \\cong A_0\\) and \\(0\\) is the only critical points of \\(f\\) in \\(A_0\\). On the other hand if \\(r < 1\\) there exists a nonzero critical point in \\(A_0\\), which lies on \\(\\b \\psi(\\D(0, r))\\).\n\\end{theorem}\n\n\\begin{proof}\n  Guided on example sheet 2. Non-examinable.\n\\end{proof}\n\n\\begin{eg}\n  \\(f(z) = z^2 + \\frac{1}{2}\\). \\(\\phi\\) sends a neighbourhood of \\(\\infty\\) to the complement of a large closed disk in \\(\\hat \\C\\) isomorphically. \\(\\psi\\) can be extended until it hits the image of a critical point.\n\\end{eg}\n\nIn the case \\(f_c(z) = z^2 + c\\), there are two critical points \\(\\infty, 0\\). \\(\\infty\\) is mapped to itself with multiplicity \\(2\\). We have\n\n\\begin{corollary}\n  Suppose \\(0 \\notin K(f_c)\\), i.e.\\ \\(f_c^n(0) \\to \\infty\\) as \\(n \\to \\infty\\). Then the Böttcher coordinate \\(\\phi_c\\) of \\(f_c\\) at \\(\\infty\\) extends to a conformal isomorphism on a neighbourhood of \\(\\infty\\) which contains \\(c\\).\n\\end{corollary}\n\n\\begin{proof}\n  \\(0\\) is the only critical point that can move around and \\(f(0) = c\\). Now use extension of Böttcher coordinate.\n\\end{proof}\n\n\\begin{proposition}\n  A closed subset of the sphere is connected if and only if the connected components of its complement are simply connected.\n\\end{proposition}\n\n\\begin{proof}\n  Beardon, Iteration of Rational Functions and Ahlfors.\n\\end{proof}\n\n\n\n\n\n\n\n\n\\printindex\n\\end{document}\n\n% prerequisite:\n% ES 0: basics of Riemann surfaces\n% measure theory: definitions and basics up to Fubini's\n%\n% References\n% McMullen: Riemann surfaces, complex dynamics and hperbolic geometry\n% potential theory: Ramsford book", "meta": {"hexsha": "4cca1e3fa2921a00715c982de55dac9fc5288a25", "size": 40522, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "III/complex_dynamics.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "III/complex_dynamics.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "III/complex_dynamics.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 58.3890489914, "max_line_length": 998, "alphanum_fraction": 0.6216869848, "num_tokens": 14391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.44503173619172404}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Chiral interactions}\n\n\\marginpar{Saturday\\\\ 2020-6-20, \\\\ compiled \\\\ \\today}\n\n(Coming from an exercise, 9.1.e)\n\nConsider the following interaction Lagrangian \n%\n\\begin{align}\n\\mathscr{L} _{\\text{int}} =\\varphi \\overline{\\psi}_{\\ell} \\qty(a_{\\ell} + i b_\\ell \\gamma_{5}) \\psi_{\\ell}\n\\,,\n\\end{align}\n%\nwhich describes the interaction between a real scalar field and a fermion. \\(a_\\ell\\) and \\(b_\\ell\\) are small real parameters.\n\nIt is self-adjoint: its conjugate reads \n%\n\\begin{align}\n\\mathscr{L} _{\\text{int}} ^\\dag &= \\varphi \\psi_{\\ell} ^\\dag \\qty(a_{\\ell} - i b_\\ell \\gamma_{5} ^\\dag) \\gamma^{0 \\dag} \\psi_{\\ell} ^\\dag  \\\\\n&= \\varphi \\psi_{\\ell} ^\\dag \\qty(a_{\\ell} - i b_\\ell \\gamma_{5}) \\gamma_0 \\psi_{\\ell}   \\marginnote{\\(\\gamma_5 \\) and \\(\\gamma^0 \\) are self-adjoint.} \\\\\n&= \\varphi \\psi_{\\ell} ^\\dag \\gamma^{0} \\qty(a_{\\ell} + i b_\\ell \\gamma_{5}) \\psi_{\\ell}\n\\,,\n\\end{align}\n%\nwhere we switched the sign when anticommuting \\(\\gamma_5\\) and \\(\\gamma^{0}\\).\n\n\\subsection{Vertex contribution}\n\nThe Feynman rule for this interaction is given from the interaction Hamiltonian; in our case there are no derivative couplings so that is just minus the interaction Lagrangian. The vertex contribution to the diagram is given by the first-order term in the expansion of the \\(S\\)-matrix: in momentum space we do not have to include the integral over \\(\\dd[4]{x}\\) so the vertex contribution is simply \\(-i \\mathscr{H} _{\\text{int}} = i \\mathscr{L} _{\\text{int}}\\), with all the fields removed: so it is \n%\n\\begin{align}\ni \\qty(a_{\\ell} + i b_\\ell \\gamma_{5})\n\\,.\n\\end{align}\n\nWe want to consider an initial state of \\(\\ket{i} = \\ket{e^{-}(p)}\\), and a final state of \\(\\ket{f} = \\ket{s(q) e^{-}(k)}\\). \nThe transition amplitude \\(\\bra{f} S \\ket{i}\\) will be given by \n%\n\\begin{align}\nS_{fi}\n= (2 \\pi )^{4} \\delta^{(4)} (p - q - k)\ni\\overline{u}_{s'}(k) \\qty(a_e + i b_e \\gamma_{5}) u_s (p)\n\\,,\n\\end{align}\n%\nwhere there is no trace of the scalar: in fact, its contribution is only  \\(\\varphi_{+} ^\\dag (x) \\ket{s(p)} = e^{-ipx} \\ket{0}\\), which only comes up in the momentum conservation. \n\n\\subsection{\\(e^{+} e^{-} \\to \\mu^+ \\mu^-\\) scalar-mediated scattering}\n\nThis is similar to the QED scattering in terms of incoming and outgoing particles, but the coupling is different: the Feynman diagram to second order is shown in figure \\ref{fig:scalar-mediator-eemumu}.\n\n\\begin{figure}[ht]\n\\centering\n\\feynmandiagram[horizontal = y to x]{\ne1 -- [fermion] y -- [fermion] e2,\ny -- [scalar] x,\nmu1 -- [fermion] x -- [fermion] mu2\n};\n\\caption{\\(e^{+} e^{-} \\to \\mu^+ \\mu^-\\) scattering with a scalar mediator.}\n\\label{fig:scalar-mediator-eemumu}\n\\end{figure}\n\nLet us denote \\(a = a_e = a_\\mu \\) and similarly for \\(b\\).\nThen, the unpolarized Feynman amplitude will read: \n%\n\\begin{align}\n\\begin{split}\n\\abs{\\mathcal{\\overline{M}}}^2\n&= \\frac{1}{4 (k^2- M^2 (+ i \\epsilon))^2 }\n\\Tr[ (a + i b \\gamma_5 ) (\\slashed{p} + m_e) \\qty(a + i b \\gamma_5 ) \\qty(\\slashed{q} - m_e)] \\times \\\\\n&\\phantom{=}\\ \n\\times \\Tr[ (a + i b \\gamma_5 ) (\\slashed{p}' + m_\\mu ) \\qty(a + i b \\gamma_5 ) \\qty(\\slashed{q}' - m_\\mu )]\n\\end{split}\n\\,,\n\\end{align}\n%\nsince the scalar propagator in momentum space is \\(1/ (k^2 - m^2)\\), and we get two of them from taking the square modulus.\nThe factor \\(1/4\\) is due to the average being taken on the initial polarizations. \n\\(M\\) is the mass of the scalar, \\(m_e\\) and \\(m_\\mu\\) are those of the electron and muon respectively. \n\nThe traces to compute seem to be many, but actually only three terms survive for each: this is because of the fact that, beyond the fact that traces of an odd number of \\(\\gamma^{\\mu }\\) vanish, we also have \n%\n\\begin{align}\n\\Tr[\\gamma_5 ] \n= \\Tr[\\gamma_5 \\gamma^{\\mu }]\n= \\Tr[\\gamma_5 \\gamma^{\\mu } \\gamma^{\\nu }]\n= \\Tr[\\gamma_5 \\gamma^{\\mu } \\gamma^{\\nu } \\gamma^{\\rho }]\n= 0\n\\,,\n\\end{align}\n%\nwhile the nonvanishing ones are \\cite[section 6.3]{kumerickiFeynmanDiagramsBeginners2016}: \n%\n\\begin{align}\n\\Tr[\\gamma_5 \\gamma_5 ] = 4 \\qquad \\text{and} \\qquad\n\\Tr[\\gamma_5 \\gamma^{\\mu } \\gamma^{\\nu } \\gamma^{\\rho } \\gamma^{\\sigma }] = -4i \\epsilon^{\\mu \\nu \\rho \\sigma }\n\\,,\n\\end{align}\n%\nsince \\(\\gamma_{5} \\gamma_5  = \\mathbb{1} \\). \n\nSo, we get: \n%\n\\begin{align}\n\\Tr[ (a + i b \\gamma_5 ) (\\slashed{p} + m_e) \\qty(a + i b \\gamma_5 ) \\qty(\\slashed{q} - m_e)] &= 4 \\qty( (a^2 + b^2) p \\cdot q +  m_e^2 ( b^2 -a ^2))\n\\,.\n\\end{align}\n\nThis was found by writing all the pieces on paper. Recall that the matrices \\emph{anticommute}, so if we need to bring two \\(\\gamma_5\\)s together we have to keep count of the number of swaps. \n\nThen, our polarization-averaged square amplitude reads: \n%\n\\begin{align}\n\\abs{\\mathcal{\\overline{M}}}^2\n&=\n\\frac{4 \\qty( (a^2 + b^2) p \\cdot q +  m_e^2 ( b^2 -a ^2)) \\qty( (a^2 + b^2) p' \\cdot q' +  m_\\mu^2 ( b^2 -a ^2))}{ (k^2- M^2 + i \\epsilon)^2 }\n\\,.\n\\end{align}\n\nThis is an \\(s\\)-channel diagram: \\(s = k^2\\), and we can also express this Mandelstam variable as \\(s = (p + q)^2 = (p'+ q')^2 = 2 m_e^2 + 2p \\cdot q  = 2 m_\\mu^2 + 2 p' \\cdot q'\\).\n\nWe can assume the electron mass to be zero, since it is small compared to the muon's: \n%\n\\begin{align}\n\\abs{\\mathcal{\\overline{M}}}^2\n&=\n\\frac{4 (a^2 + b^2) p \\cdot q \\qty( (a^2 + b^2) \\qty( p \\cdot q - m_\\mu^2) +  m_\\mu^2 ( b^2 -a ^2))}{ (k^2- M^2 + i \\epsilon)^2 }\n\\,.\n\\end{align}\n\nNow, we can calculate the cross section: for simplicity, let us move to the center of mass frame. Then, we will have \n%\n\\begin{align}\n\\dd{\\sigma } = \\frac{\\abs{\\mathcal{\\overline{M}}}^2}{4 I_{12}} \\dd{\\phi }^{(n_f)}\n\\,,\n\\end{align}\n%\nwhere the phase space element is given by \n%\n\\begin{align}\n\\dd{\\phi } = (2 \\pi )^{4} \\delta^{(4)} (p+q-p'-q') \n\\frac{ \\dd[3]{p'}}{(2 \\pi )^3 2 \\omega_{p}'} \n\\frac{ \\dd[3]{q'}}{(2 \\pi )^3 2 \\omega_{q}'} \n\\,,\n\\end{align}\n%\nwhile in our frame \n%\n\\begin{align}\nI_{12} &=  \\sqrt{(p \\cdot q)^2 - m_e^{4}}  \\\\\n&= \\sqrt{\\omega_{e}^{4} + 2 \\omega_{e}^2 \\abs{\\vec{p}}^2 + \\abs{p}^{4} - m_e^{4}}  \\\\\n&= \\sqrt{4 \\omega_{e}^2 \\abs{p}^2} = 2 \\omega_{e} \\abs{p}\n\\,.\n\\end{align}\n\nWe are basically replicating what we have done when deriving the two-output cross section: the result, in the approximation \\(m_e \\approx 0\\), is given by \\eqref{eq:zero-initial-mass-cross-section}: \n%\n\\begin{align}\n\\dv{\\sigma }{\\Omega_1 } &= \\frac{1}{64 \\pi^2}\\frac{\\abs{\\mathcal{\\overline{M}}}^2 }{s} \\sqrt{1 - \\frac{4 m_\\mu^2}{s}}  \\\\\n&= \\frac{(a^2 + b^2) (s/2) \\qty( (a^2 + b^2) \\qty( s/2 - m_\\mu^2) +  m_\\mu^2 ( b^2 -a ^2))}{ (16 \\pi^2 s) (s- M^2 + i \\epsilon)^2 }\n\\sqrt{1 - \\frac{4 m_\\mu^2}{s}}  \\\\\n&= \\frac{(a^2 + b^2)\\qty( (a^2 + b^2) \\qty( s/2 - m_\\mu^2) +  m_\\mu^2 ( b^2 -a ^2))}{ 32 \\pi^2 (s- M^2 + i \\epsilon)^2 }\n\\sqrt{1 - \\frac{4 m_\\mu^2}{s}}\n\\,.\n\\end{align}\n\nThere is no angular dependence! Scalar-mediated interactions are \\textbf{isotropic}. \n\n\\subsection{Scalar decay rate}\n\nWe want to calculate the decay rate of the process with initial state \\(\\ket{i} = \\ket{s(p)}\\) and final state \\(\\ket{f} = \\ket{e^{-}(p') e^{+} (q')}\\).\n\nThe polarization-averaged amplitude is given (in the lab=center of mass frame) by: \n%\n\\begin{align}\n\\abs{\\mathcal{\\overline{M}}}^2 \n&= \\frac{1}{(k^2 - M^2 + i \\epsilon )^2}\n\\Tr[ (a + i b \\gamma_5 ) (\\slashed{p} + m_e) \\qty(a + i b \\gamma_5 ) \\qty(\\slashed{q} - m_e)]  \\\\\n&= \\frac{(a^2 + b^2)(p' \\cdot q') + m_e^2 (b^2 - a^2)}{(k^2 -M^2+ i \\epsilon)^2}  \\\\\n&=\\frac{(a^2 + b^2)(M^2 / 2- m_e^2) + m_e^2 (b^2 - a^2)}{(k^2 -M^2+ i \\epsilon)^2}\n\\,.\n\\end{align}\n\nThen, we can compute the differential decay rate \\eqref{eq:differential-decay-rate-equal-masses}: \n%\n\\begin{align}\n\\dv{\\Gamma}{\\Omega_1 } &= \\frac{\\abs{\\mathcal{\\overline{M}}}^2}{64 \\pi^2 M}\\sqrt{1 - \\frac{4 m_e^2}{M^2}}  \\\\ \n&=\\frac{(a^2 + b^2)(M^2 /2- m_e^2) + m_e^2 (b^2 - a^2)}{64 \\pi^2 M (k^2 -M^2+ i \\epsilon)^2}\n\\sqrt{1 - \\frac{4 m_e^2}{M^2}}  \\\\\n&= \\qty[2 a^2 \\qty( \\frac{M^2}{4 } - m_e^2) + b^2 \\frac{M^2}{2}] \\frac{1}{64 \\pi^2 M (k^2 -M^2+ i \\epsilon)^2}\n\\sqrt{1 - \\frac{4 m_e^2}{M^2}}  \\\\\n\\Gamma &= \\qty[2 a^2 \\qty( \\frac{M^2}{4 } - m_e^2) + b^2 \\frac{M^2}{2}] \\frac{1}{16 \\pi M (k^2 -M^2+ i \\epsilon)^2}\n\\sqrt{1 - \\frac{4 m_e^2}{M^2}}\n\\,.\n\\end{align}\n\n\n\\end{document}\n", "meta": {"hexsha": "bbea0516877bb4b7293f11e9b275f4884f562976", "size": 8150, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/theoretical_physics/exercises7.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/theoretical_physics/exercises7.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/theoretical_physics/exercises7.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 40.3465346535, "max_line_length": 502, "alphanum_fraction": 0.6109202454, "num_tokens": 3249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.44503172736195634}}
{"text": "\\documentclass[12pt,letterpaper,oneside,reqno]{amsart}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{float}\n\\usepackage[font=small,labelfont=bf]{caption}\n\\usepackage[left=1in,right=1in,bottom=1in,top=1in]{geometry}\n\\usepackage[pdfpagelabels,hyperindex,colorlinks=true,linkcolor=blue,urlcolor=magenta,citecolor=green]{hyperref}\n\n\\newcommand \\coeffA [3][A] {{\\mathbf{#1}} \\sb{#2,#3}}\n\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}{Lemma}[section]\n\\newtheorem{conj}[thm]{Conjecture}\n\n%--------Meta Data: Fill in your info------\n\\title[Goldbach-like conjectures via Bertrand's Postulate]{Goldbach-like conjectures via Bertrand's Postulate}\n\\author[Petro Kolosov]{Petro Kolosov}\n\\email{kolosovp94@gmail.com}\n\\keywords{Bertrand's Postulate, Goldbach Conjecture, Ternary Goldbach Conjecture}\n\\urladdr{https://kolosovpetro.github.io}\n\\subjclass[2010]{11P32, 11A41, 97F60}\n\\date{\\today}\n\\hypersetup{\n    pdftitle={Goldbach-like conjectures via Bertrand's Postulate},\n    pdfsubject={Discrete Mathematics, Number Theory},\n    pdfauthor={Petro Kolosov},\n    pdfkeywords={Bertrand's Postulate, Goldbach Conjecture, Ternary Goldbach Conjecture}\n}\n\\begin{document}\n    \\begin{abstract}\n        In this manuscript the ternary and binary Goldbach's conjectures are reviewed from Bertrand's postulate prospective.\n        As a result, a relations between both ternary and binary Goldbach's conjectures and Bertrand's postulate\n        are established.\n        Furthermore, a three Goldbach-like conjectures are proposed and discussed.\n        Verification programs are attached to the last section.\n    \\end{abstract}\n    \\maketitle\n    \\tableofcontents\n\n\n    \\section{Introduction} \\label{sec:introduction}\n    In number theory, Bertrand's postulate is a statement that was first conjured in 1845 by\n    Joseph Bertrand~\\cite{bertrand1845}.\n    \\begin{thm}\n        \\label{bertrand_theorem} (Bertrand–Chebyshev theorem.)\n        For every positive integer $n>1$ exists at least one prime $p$ such that\n        \\[\n            n < p < 2n\n        \\]\n    \\end{thm}\n    Bertrand's postulate completely proved by Chebyshev in 1852~\\cite{Tchebichef1852}.\n    From Bertrand's postulate immediately follows\n    \\begin{lem}\n        \\label{bertrands_partition_lemma} (Even Bertrand's partition.)\n        By Bertrand's postulate, for every positive integer $n>1$ there is at least one partition such that\n        \\[\n            2n = p + \\verb!odd!,\n        \\]\n        where \\verb!odd! is odd member of Even Bertrand's partition.\n    \\end{lem}\n    Now we have to recall ternary Goldbach's conjecture or namely Goldbach's weak conjecture\n    \\begin{conj}\n        \\label{ternary_goldbach_conjecture} (Ternary Goldbach's Conjecture.)\n        Every odd number greater than 7 can be expressed as the sum of three odd primes.\n        \\[\n            2n+1 = \\mathfrak{p}_i +  \\mathfrak{p}_j + \\mathfrak{p}_k, \\quad n > 2,\n        \\]\n        where $\\mathfrak{p}_i +  \\mathfrak{p}_j + \\mathfrak{p}_k$ is ternary Goldbach partition.\n    \\end{conj}\n    Ternary Goldbach's conjecture is claimed to be true by H.A Helfgott~\\cite{helfgott2013minor, helfgott2014ternary}.\n    Furthermore, the proof was clarified in~\\cite{helfgott2015ternary}.\n    From this prospective, let express the lemma~\\ref{bertrands_partition_lemma} for positive odd numbers,\n    \\begin{lem}(Odd Bertrand's partition.)\n        \\label{bertrands_odd_partition_lemma}\n        By Bertrand's postulate, for every positive integer $n>1$ there is at least one partition such that\n        \\[\n            2n + 1 = p + \\verb!odd! + 1 = p + \\verb!even!,\n        \\]\n        where \\verb!even! is even member of Odd Bertrand's partition.\n    \\end{lem}\n    Then we have the following relation between Odd Bertrand's Partition~\\ref{bertrands_odd_partition_lemma} and\n    Ternary Goldbach's Partition~\\ref{ternary_goldbach_conjecture}, for every positive integer $n>2$\n    \\begin{equation}\n        2n + 1 = p + \\verb!odd! + 1 = \\mathfrak{p}_i +  \\mathfrak{p}_j + \\mathfrak{p}_k\n        \\label{eq:goldbach_and_bertrand_relation}\n    \\end{equation}\n    From equation~\\eqref{eq:goldbach_and_bertrand_relation} imply the Goldbach-like conjectures\n    \\begin{conj}\n        For every prime $p< 2n-1$ in positive Odd $2n+1, \\; n>2$ Bertrand's Partition~\\ref{bertrands_odd_partition_lemma},\n        the prime $p$ is always a member of Ternary Goldbach's Partition\n        \\[\n            2n+1 = \\mathfrak{p}_i +  \\mathfrak{p}_j + p\n        \\]\n    \\end{conj}\n    \\begin{conj}\n        For every positive odd $2n+1, \\; n>2$ Bertrand's partition~\\ref{bertrands_odd_partition_lemma},\n        the prime $p < 2n-1$ always satisfies\n        \\[\n            \\bigvee_{t \\in \\{i, j, k\\}} \\mathfrak{p}_t = p,\n        \\]\n        where $\\mathfrak{p}_i, \\; \\mathfrak{p}_j, \\; \\mathfrak{p}_k$ are members of ternary Goldbach's partition of $2n+1$.\n    \\end{conj}\n    \\begin{conj}\n        For every positive odd $2n+1, \\; n>2$ Bertrand's partition~\\ref{bertrands_odd_partition_lemma}\n        the even part is always a sum of two primes\n        \\[\n            2n + 1 = p + \\verb!even! \\rightarrow \\verb!even! = \\mathfrak{p}_j + \\mathfrak{p}_k, \\; n > 2\n        \\]\n    \\end{conj}\n\n\n    \\section{Discussion}\\label{sec:discussion}\n    Consider the Conjecture 1.3.\n    Suppose it is true.\n    Then for every even integer $2k>2$, take an odd prime $p<2k$, and let $n=k+\\frac{p-1}{2}$.\n    Then $n<p<2n-1$, so the true scenario would imply that there is a ternary Goldbach partition of $2n+1$ containing $p$.\n    But $2n+1=2k+p$, giving us a binary Goldbach partition of $2k$.\n\n    Suppose the Conjecture 1.3 is false.\n    Then for some $n > 2$, there is a prime $p$ such that $n<p<2n-1$ and $p$ is not a member\n    of an odd Goldbach partition of $2n+1$.\n    It implies that $2n+1-p$ is an even integer which is not the sum of two primes.\n\n    The Conjecture 1.3 implies Goldbach strong conjecture, however from different prospective.\n    It doesn't assume that all positive even numbers greater than 4 are sum of two primes,\n    but only provides a relation between Bertrand's postulate and ternary Goldbach partition.\n    Conjecture 1.3 is immediately true if Goldbach's strong conjecture is true.\n    Conjectures 1.4, 1.5 are following directly from Conjecture 1.3.\n\n\n    \\section{Verification}\\label{sec:verification}\n    Conjecture 1.3 may be verified up to $5 \\times 10^3$ via the program~\\cite{kolosov2021github}.\n    However, in order to verify larger bounds, the program should be optimized and rewritten using any\n    low-level programming language, for instance, C or C++.\n    Currently, it has an asymptotic complexity of $O(n^2)$ and written on high-level language C\\#.\n    The verification results are at\n    \\href{https://github.com/kolosovpetro/GoldbachConjecture/blob/master/GoldbachConjecture.BertrandValues.UI/PartitionsTo5000.txt}\n    {\\texttt{github.com/kolosovpetro/GoldbachConjecture/PartitionsTo5000.txt}}\n    \\bibliographystyle{unsrt}\n    \\bibliography{OnTheBertrandsPostulate}\n\\end{document}", "meta": {"hexsha": "0cc2e088979980e1acb8205f9e89758191857461", "size": 7052, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/OnTheBertrandsPostulate.tex", "max_stars_repo_name": "kolosovpetro/BERTRAND_PAPER", "max_stars_repo_head_hexsha": "b12fc08b06f2dac128bde9fb12621fd902d5f709", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/OnTheBertrandsPostulate.tex", "max_issues_repo_name": "kolosovpetro/BERTRAND_PAPER", "max_issues_repo_head_hexsha": "b12fc08b06f2dac128bde9fb12621fd902d5f709", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/OnTheBertrandsPostulate.tex", "max_forks_repo_name": "kolosovpetro/BERTRAND_PAPER", "max_forks_repo_head_hexsha": "b12fc08b06f2dac128bde9fb12621fd902d5f709", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.3146853147, "max_line_length": 131, "alphanum_fraction": 0.6973908111, "num_tokens": 2150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.661922862511608, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4450317228780464}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 18.3 Sorting Partially Ordered Data of\n\\hbox{Arbitrary Structure in Memory}\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nSort data having an organization or structure not supported by one of the\nsubprograms in Chapter~18.1, for example, data having more than one key to\ndetermine the sorted order. This subprogram has similar functionality\nto GSORTP of Chapter~18.2 and is more efficient when the data are initially\npartially ordered, or when the ordering criterion is expensive to\ndetermine.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype}\n\n\\begin{description}\n\\item[INTEGER]  \\ {\\bf N, L}($\\geq $N){\\bf , L1, COMPAR}\n\n\\item[EXTERNAL]  \\ {\\bf COMPAR}\n\\end{description}\n\nAssign values to N and data elements indexed by~1 through N. Require\nN $\\geq 1.$\n$$\n\\fbox{{\\bf CALL INSORT (COMPAR, N, L, L1)}}\n$$\nFollowing the call to INSORT the contents of L(1) through L(N) contain a\nlinked list that defines the sorted order of the data. L1 is the index of\nthe first record of the sorted sequence. Let I = L(J). If I = 0 record\nJ is the last record in the sorted sequence, else record I is the immediate\nsuccessor of record J in the sorted sequence.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\\item[COMPAR]  \\ [in] An INTEGER FUNCTION subprogram that defines the\nrelative order of elements of the data. COMPAR is invoked as COMPAR(I, J),\nand is expected to return $-$1 (or any negative integer) if the $\\text{I}^{th}$\nelement of the original data is to precede the $\\text{J}^{th}$ element in\nthe sorted sequence, +1 (or any positive integer) if the $\\text{I}^{th}$\nelement is to follow the $\\text{J}^{th}$\nelement, and zero if the order is immaterial. INSORT does not have access to\nthe data. It is the caller's responsibility to make the data known to\nCOMPAR. Since COMPAR is a dummy procedure, it may have any name. Its name\nmust appear in an EXTERNAL statement in the calling program unit.\n\n\\item[N]  \\ [in] The upper bound of the indices to be presented to COMPAR.\n\n\\item[L()]  \\ [out] An array to contain the definition of the sorted\nsequence. L(1:N) are set so that the immediate successor of the $%\n\\text{J}^{th}$ record of the sorted sequence is L(J) if the $\\text{J}^{th}$\nrecord is not the last record in the sorted sequence, else L(J) is zero.\n\n\\item[L1]  \\ [out] The index of the first record of the sorted sequence.\n\\end{description}\n\n\\subsubsection{Converting the Linked List in L() to a Permutation Vector}\n\nThe linked list produced by INSORT (or by INSRTX, see Chapter~18-04) in\nthe array L() may be converted to a permutation vector by\n$$\n\\fbox{\\bf CALL PVEC (L, L1)}\n$$\nwhere L() and L1 are as above. Upon return from PVEC, L() is a permutation\nvector, as described for the argument IP() of GSORTP (Chapter~18.2).\n\n\\subsection{Examples and Remarks}\n\nThe program DRINSORT illustrates the use of INSORT to sort 1000 randomly\ngenerated real numbers. The output should consist of the single line\n\n\\hspace{.2in}INSORT succeeded\n\n\\subparagraph{Stability}\n\nA sorting method is said to be $stable$ if the original relative order of\nequal elements is preserved. This subroutine uses a  merge sort algorithm,\nwhich is not inherently stable. To impose stability, return COMPAR =\nI $-$ J if the $\\text{I}%\n^{th}$ and $\\text{J}^{th}$ elements are equal.\n\n\\subsection{Functional Description}\n\nThe INSORT subprogram uses an opportunistic merge sort algorithm, as\ndescribed by Sedgewick \\cite{Sedgewick:1983:A}, with a modification\nsuggested by Power \\cite{Power:1980:ISU}.  In the basic opportunistic\nmerge sort algorithm, the first step consists of detecting either\nascending or descending sequences of initially ordered data.  In the\nsecond step, these sequences are merged in pairs to form half as many\nsequences, each approximately twice as long as the original sequences\n(descending sequences are considered in reverse order).  The second step\nis repeated until only one sequence remains.  The Power modification\nconsists of putting each sequence into a ``bucket\" indexed by the base-2\nlogarithm of its length.  When a third sequence is to be put into a\nbucket, the two longest sequences are merged and put into the next bucket.\nIf this would require putting three sequences into the next bucket, the\nprocess is repeated.  Finally, sequences remaining in the buckets after\nthe initial order-detecting stage are merged, starting with the smallest\nsequences and proceeding to the largest, to produce a single sequence.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nINSORT neither detects nor reports any erroneous conditions.\n\nLimitations on the size of array that can be sorted are imposed by the\namount of memory available to hold the array, and the length of an internal\narray to hold the ``buckets\" used in the Power modification. The number of\nbuckets is given by a Fortran PARAMETER, currently set to~32. This permits\nsorting at least 4,294,467,295 records.\n\n\\subsection{Supporting Information}\n\nThe source language is Fortran~77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.2in} {\\bf Required Files}\\vspace{2pt} \\\\\nINSORT & \\hspace{.35in} INSORT\\\\\nPVEC & \\hspace{.35in} PVEC\\\\\\end{tabular}\n\nDesigned and coded by W. V. Snyder, JPL 1974. Power modification~1980.\nAdapted to MATH77,~1990.\n\n\n\\begcode\n\\medskip\\\n\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRINSORT}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{insort}}\n\\end{document}\n", "meta": {"hexsha": "47ebf4454ec10d6fd82275be023c1d76194fb3aa", "size": 5688, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch18-03.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch18-03.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch18-03.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 39.7762237762, "max_line_length": 98, "alphanum_fraction": 0.7642405063, "num_tokens": 1523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.4450220338978099}}
{"text": "\\documentclass[twocolumn]{article}\r\n\\usepackage[margin=1in]{geometry}\r\n\\usepackage{outlines}\r\n\\usepackage{amsmath}\r\n\\title{Ch. 11, 12 Notes}\r\n\\author{John Yang}\r\n\\setcounter{section}{+10}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\\section{Solids and Fluids}\r\n\\subsection{States of Matter}\r\n\\begin{outline}\r\n    \\1 Solid - semirigid collection of atoms or molecules that maintains a definite shape and volume\r\n    \\1 liquid - collection of atoms or molecules that has a density similar to solids, maintains definite volume but takes the shape of its container. \r\n    \\1 gas - loose collection of atoms or molecules that exhibits flow characteristics but fills its container. More easily compressed and expanded than liquids or solids\r\n    \\1 plasma - when electrons are liberated from their parent atoms\r\n    \\1 there are other more exotic states of matter that exist (such as bose-einstein condensate)\r\n    \\1 fluids - materials that flow\r\n\\end{outline}\r\n\\subsection{Stress, Strain and Young's Modulus for Solids}\r\n\\begin{outline}\r\n    \\1 Tensile forces - forces that stretch\r\n        \\2 Elongation of a wire or rope is proportional to force applied; that is \\[F=k\\Delta \\ell\\]\r\n    \\1 If applied force is too large, the rope permanently deforms and is said to be \\textbf{inelastic}. Even greater forces cause the rope to break\r\n\\0 \\[\\Delta \\ell = \\dfrac{1}{E} \\dfrac{F\\ell}{A}\\] \\[k=\\dfrac{EA}{\\ell}\\]\r\n    \\1 where $E$ is the Young's Modulus of the material; constant. $A$ is the cross sectional area of the rope.\r\n    \\1 tensile stress $\\equiv \\dfrac{F}{A}$\r\n    \\1 tensile strain $\\equiv\\dfrac{\\Delta \\ell}{\\ell}$\r\n    \\1 therefore, \\[E\\equiv\\dfrac{\\text{tensile stress}}{\\text{tensile strain}}=\\dfrac{F/A}{\\Delta \\ell/\\ell}\\]\r\n    \\1 shear stress, forces applied opposite and parallel over a separation $\\ell$\r\n    \\1 shear stress $= F/A$\r\n    \\1 shear strain $=\\Delta \\ell/\\ell$, where $\\Delta \\ell$ is the deformation\r\n    \\1 shear modulus $G$ is shear stress over shear strain;\r\n    \\[G=\\dfrac{F/A}{\\Delta \\ell/\\ell}\\]\r\n    \\1 change in volume is $\\Delta V = V_f-V_i$\r\n    \\1 Bulk modulus $B$ is \\[B\\equiv-\\dfrac{\\text{pressure}}{\\text{volume strain}}\\], where volume strain is $\\Delta V/V_i$\r\n    \\1 Compressibility $\\beta$ is \\[\\beta\\equiv\\dfrac{1}{B}\\]\r\n\\end{outline}\r\n\\subsection{Fluid Pressure}\r\n\\begin{outline}\r\n    \\1 \\[P=\\dfrac{dF}{dA}\\]\r\n    \\1 Pressure is a scalar; magnitude of force per unit area acting on any differential area regardless of orientation within the fluid\r\n    \\1 Units: $1\\text{ N}/\\text{m}^2\\equiv1\\text{ Pa}$\r\n        \\2 $1\\text{ atm}\\equiv101.325\\text{ kPa}$\r\n    \\1 gauge pressure $\\equiv P-1\\text{ atm}$\r\n\\end{outline}\r\n\\subsection{Static Fluids}\r\n\\begin{outline}\r\n\\0 \\[\\dfrac{dP}{dy}=-\\rho g\\]\r\n    \\1 For incompressible fluids, \\[P(y)=P_0-\\rho gy\\]\r\n    \\1 Pressure is the same  at all points at same depth or elevation regardless of horizontal location\r\n    \\1 For compressible fluids, density is a function of height.\r\n\\0 \\[P(y)=P_0e^{-\\dfrac{\\rho_0}{P_0}gy}\\]\r\n    \\1 Scale height $\\equiv\\dfrac{P_0}{\\rho_0g}$\r\n\\end{outline}\r\n\\subsection{Pascal's principle}\r\n\\begin{outline}\r\n    \\1 If pressure is increased on the surface of an enclosed liquid, pressure increases by the same amount at all points throughout the liquid and on the walls of the container, regardless of shape. \r\n\\0 \\[\\dfrac{F_1}{A_1}=\\dfrac{F_2}{A_2}\\]\r\n\\end{outline}\r\n\\subsection{Archimedes' Principle}\r\n\\begin{outline}\r\n    \\1 a system submerged or floating in a fluid has a buoyant force acting on it with a magnitude equal to the weight of the fluid displaced. Direction is upwards. \\[F_{buoy}=\\rho_{fluid}V'g\\]\r\n    \\1 where $V'$ is the volume of the system immersed in the fluid; if the system is totally submerged, $V'=V$\r\n    \\1 a system will float in any liquid with a density greater than the avg. density of the system.\r\n\\end{outline}\r\n\\subsection{The center of buoyancy}\r\n\\begin{outline}\r\n    \\1 The weight acts at the center of mass of the object, which depends on the shape and mass distribution of the object. \r\n    \\1 Buoyant force acts at the position of the center of mass of the fluid imagined to be in the hole created by the object in the fluid, a point known as the center of buoyancy. \r\n    \\1 For a totally submerged system to be in stable equilibrium, the center of mass must be below the center of buoyancy.\r\n    \\1 The point of intersection of the original line of action of the buoyant force with the new line of action of the buoyant force is known as the \\textbf{metacenter}\r\n    \\1 if the elevation of the metacenter is above the elevation of the cm, the system will return to its original orientation when tilted and the floating equilibrium is stable. If the elevation of the metacenter is below the cm, then the system is in unstable equilibrium bc the torque of the buoyant force accentuates the tilt, causing the system to roll over.\r\n    \\1 a floating system is in stable equilibrium if the metacenter is above the cm in every possible roll. The same is true for submerged systems. \r\n\\end{outline}\r\n\\subsection{Surface tension}\r\n\\begin{outline}\r\n    \\1 some objects more dense than certain liquids can float due to increased intermolecular forces at the surface of the liquid. \r\n    \\1 magnitude of surface tension force is \\(\\gamma\\ell\\) where $\\gamma$ is the coefficient of surface tension of the liquid and $\\ell$ is the perimeter of the part of the floating object in contact with the liquid. \r\n\\end{outline}\r\n\\subsection{Capillary action}\r\n\\begin{outline}\r\n    \\1 The forces between a molecule and another molecule of a liquid are cohesive forces, and forces between a molecule of liquid and another material are adhesive forces. \r\n    \\1 contact angle $\\theta_{cont}$, angle b/w vertical direction of container and surface of liquid at wall of container. \r\n        \\2 angles less than 90, concave meniscus and wetting occurs. \r\n        \\2 angles greater than 90, no wetting and convex meniscus. \r\n    \\1 when wetting occurs, surface tension draws the liquid up a thin tube inserted into the liquid; capillary action. Continues until surface tension equals the weight of the liquid in the tube. \\[\\gamma\\ell\\cos{\\theta_{cont}}=mg\\]\r\n    \\1 If tube has circular cross section, \\[h=\\dfrac{2\\gamma\\cos{\\theta_{cont}}}{\\rho gr}\\]\r\n\\end{outline}\r\n\\subsection{Fluid dynamics: Ideal fluid}\r\n\\begin{outline}\r\n    \\1 \\textbf{Ideal fluid:}\r\n        \\2 no viscous or frictional effects\r\n        \\2 flow is steady, that is, velocity doesn't change with time\r\n        \\2 density is constant; incompressible flow\r\n        \\2 no rotational currents, that is, no turbulence\r\n\\end{outline}\r\n\\subsection{Equation of flow continuity}\r\n\\begin{outline}\r\n    \\1 A small particle of flowing incompressible fluid follows a path called a streamline. A set of streamlines makes up a flow tube.\r\n    \\1 eqn of flow continuity:\r\n    \\1 At any two points along a flow tube, \\[\\rho_1A_1v_1=\\rho_2A_2v_2\\]\r\n    \\1 For incompressible fluids, density is constant; \\[A_1v_1=A_2v_2\\]\r\n\\end{outline}\r\n\\subsection{Bernoulli's Principle for Incompressible Ideal Fluids}\r\n\\begin{outline}\r\n\\0 \\[P_1+\\dfrac{1}{2}\\rho v^2_1+\\rho gy_1=P_2 +\\dfrac{1}{2}\\rho v^2_2+\\rho gy_2\\]\r\n    \\1 In other words, the quantity \\(P+\\dfrac{1}{2}\\rho v^2+\\rho gy\\) has the same value at every point along a flow tube. \r\n    \\1 If the fluid isn't moving, \\[P=P_0-\\rho gy\\]\r\n    \\1 In a horizontal pipe, \\[P_1+\\dfrac{1}{2}\\rho v^2_1=P_2 +\\dfrac{1}{2}\\rho v^2_2\\]\r\n    \\1 In other words, pressure decreases as the speed of the fluid increases. \r\n\\end{outline}\r\n\\subsection{Nonideal Fluids}\r\n\\begin{outline}\r\n    \\1 coefficient of viscosity $\\eta$- measure of a fluid's resistance to flow\r\n\\0 \\[\\eta=\\dfrac{F/A}{\\Delta v/\\Delta y}\\]\r\n    \\1 imagine viscous fluids to be a series of planes of thin fluid layers stacked on top of each other; each plane exerts a frictional/viscous force on the layers it's in contact with\r\n\\end{outline}\r\n\\subsection{Viscous Flow}\r\n\\begin{outline}\r\n    \\1 Poiseuille's law, for circular pipes \\[|\\Delta P|=\\dfrac{8}{\\pi r^4}Q\\eta\\ell\\]\r\n\\end{outline}\r\n\\section{Waves}\r\n\\subsection{What is a wave?}\r\n\\begin{outline}\r\n    \\1 A classical wave is a propagating disturbance that transfers energy and momentum at its own characteristic speed from one region of space to another with little if any mass transfer.\r\n\\end{outline}\r\n\\subsection{Longitudinal and Transverse Waves}\r\n\\begin{outline}\r\n    \\1 Waves whose oscillation is along the line the wave propagates are longitudinal waves. \r\n    \\1 Waves whose oscillation is perpendicular to the line along which the wave propagates are transverse waves\r\n    \\1 The plane in which the oscillations of a transverse wave occur is the plane of polarization of the transverse wave. \r\n    \\1 waves can be either or both transverse and longitudinal\r\n\\end{outline}\r\n\\subsection{Wavefunctions, waveforms and oscillations}\r\n\\begin{outline}\r\n    \\1 wavefunction $\\Psi$ represents how a wave propagates through space and time; therefore it is a function of space and time; \\(\\Psi(x,y,z,t)\\)\r\n    \\1 waveform - freezing a wave in time by taking a sort of snapshot of it at a certain point in time; \\(\\Psi(x,y,z,t_0)\\)\r\n    \\1 oscillation; imagine a specific point \\((x_0,y_0,z_0)\\) and examine its behavior as a function of time. \r\n\\end{outline}\r\n\\subsection{Waves propagating in one, two, and three dimensions}\r\n\\begin{outline}\r\n    \\1 peaks are crests and minima are troughs\r\n    \\1 wavelength is distance from crest to crest or trough to trough\r\n    \\1 wave train - area in space where waveform is nonzero\r\n    \\1 Waveforms with wave trains of finite extent are wavepackets. \r\n\\end{outline}\r\n\\subsection{One-D waves at constant velocity}\r\n\\begin{outline}\r\n    \\1 One-D wave propagating at constant speed $v$ for increasing values of $x$ is \\(\\Psi(x-vt)\\)\r\n    \\1 One-D wave propagating at constant speed $v$ for decreasing values of $x$ is \\(\\Psi(x+vt)\\)\r\n\\end{outline}\r\n\\subsection{The classical wave equation for one-d waves}\r\n\\begin{outline}\r\n    \\1 Classical wave equation for one-d waves is \\[\\dfrac{\\partial^2\\Psi}{\\partial x^2}-\\dfrac{1}{v^2}\\dfrac{\\partial^2\\Psi}{\\partial t^2}=0\\]\r\n\\end{outline}\r\n\\subsection{Periodic waves}\r\n\\begin{outline}\r\n    \\1 waves that periodically repeat themselves are periodic waves. \r\n\\0 \\[v=f\\lambda=\\dfrac{\\lambda}{T}\\]\r\n\\end{outline}\r\n\\subsection{Sinusoidal (harmonic) waves}\r\n\\begin{outline}\r\n\\0 \\[\\Psi(x,t)=A\\cos\\left[k(x-vt)\\right]\\] where \\(k(x-vt)\\) is measured in radians and not degrees.\r\n    \\1 waveform of a sinusoidal wave at $t=0$ \\[\\Psi(x,0\\text{ s})=A\\cos(kx)\\]\r\n    \\1 the constant $k$ is \\[k=\\dfrac{2\\pi\\text{ rad}}{\\lambda}\\] which is known as the angular wavenumber, which represents the number of wavelengths in exactly $2\\pi$ meters. \r\n    \\1 standard form of a sinusoidal wave is \\[\\Psi(x,t)=A\\cos(kx-\\omega t)\\]\r\n\\end{outline}\r\n\\subsection{Waves on a string}\r\n\\begin{outline}\r\n    \\1 wave speed on a string is \\[v=\\sqrt{\\dfrac{F}{\\mu}}\\] where $F$ is the tension in the string and $\\mu$ is the linear mass density $m/\\ell$\r\n    \\1 In solids, the speed of sound is \\[v_{solid}=\\sqrt{\\dfrac{E}{\\rho}}\\] where $E$ is the young's modulus of the material and $\\rho$ is the density\r\n    \\1 In liquids, the speed of sound is \\[v_{liquid}=\\sqrt{\\dfrac{B}{\\rho}}\\] where $B$ is the bulk modulus. \r\n\\end{outline}\r\n\\subsection{Reflection and transmission of waves}\r\n\\begin{outline}\r\n    \\1 rope with fixed end, reflects and changes phase by $\\pi$. Flips.\r\n    \\1 rope with free end, reflects but doesn't change phase. No flip. \r\n    \\1 wave traveling through a boundary of two strings with diff. mass per unit length. Both transmission and reflection. \r\n\\end{outline}\r\n\\subsection{energy transport via mechanical waves}\r\n\\begin{outline}\r\n\\1 power transfer in a mechanical wave is \\[P=\\dfrac{1}{2}\\mu\\omega^2A^2v\\] (in a string). Power transfer is proportional to the square of angular frequency, square of amplitude, and to the propagation speed of the wave. \r\n\\end{outline}\r\n\\subsection{Wave Intensity}\r\n\\begin{outline}\r\n    \\1 Intensity of a wave is the average power transmitted by the wave through one square meter oriented perpendicular to the direction the wave is propagating\r\n    \\1 From previous eqn, intensity of a wave is proportional to square of amplitude and square of frequency. \r\n    \\1 Intensity from a point source is \\[I=\\dfrac{P}{4\\pi r^2}\\] inverse square\r\n\\end{outline}\r\n\\subsection{What is a sound wave?}\r\n\\begin{outline}\r\n    \\1 sound exists in an elastic material if a propagating disturbance is a variation in the ambient density caused by a bulk shift in the positions of the particles of the material away from their nominal equilibrium positions. \\1 Density wave disturbance $\\Psi_{density}$ is $\\pi/2$ rad out of phase with particle position wave disturbance $\\Psi_{position}$\r\n\\end{outline}\r\n\\subsection{sound intensity and sound level}\r\n\\begin{outline}\r\n    \\1 threshold of hearing is \\(I_0\\equiv10^{-12}\\text{ W/m}^2\\)\r\n    \\1 Intensity level $\\beta$ is \\[\\beta\\equiv(10\\text{ dB})\\log_{10}\\dfrac{I}{I_0}\\]\r\n    \\1 Each factor of 10 increase in sound intensity produces an additive change in sound level of 10 dB\r\n\\end{outline}\r\n\\subsection{Acoustic Doppler effect}\r\n\\begin{outline}\r\n    \\1 general equation, linear motion \\[f'=f\\left(\\dfrac{v\\pm v_{obs}}{v\\mp v_{source}}\\right)\\]\r\n    \\1 $+$ sign if source is moving away and $-$ sign if source is moving toward observer\r\n    \\1 even more general equation, if the medium is moving \\[f'=f\\left(\\dfrac{v\\pm v_{med}\\pm v_{obs}}{v\\pm v_{med}\\mp v_{source}}\\right)\\]\r\n\\end{outline}\r\n\\subsection{Shock waves}\r\n\\begin{outline}\r\n    \\1 Speed of the source exceeds the speed of sound\r\n    \\1 Mach number $=\\dfrac{v_{source}}{v}$\r\n    \\1 mach angle $\\phi$,  \\(\\sin\\phi=\\dfrac{1}{\\text{Mach number}}\\)\r\n\\end{outline}\r\n\\subsection{Diffraction of waves}\r\n\\begin{itemize}\r\n    \\item Diffraction - spreading out of waves after they pass through or around obstacles or openings comparable in size to the wavelength. \r\n\\end{itemize}\r\n\\subsection{Principle of superposition}\r\n\\begin{outline}\r\n\\1 When two or more similar types of waves exist simultaneously at a point in space, we say the waves interfere with each other. If the resulting wave disturbance at a point is greater than that produced by any of the waves acting alone, we say the waves exhibit constructive interference. If the resulting disturbance is less that that produced by the waves acting alone, the waves exhibit destructive interference. \r\n\\end{outline}\r\n\\subsection{Standing waves}\r\n\\begin{outline}\r\n\\1 locations with 0 wave disturbance are nodes\r\n\\1 successive nodes are separated in space by half a wavelength, as well as antinodes on a string fixed at both ends\r\n\\1 Disturbance resulting from superposition of two waves of equal amplitude and frequency traveling in opposite directions is called a standing wave\r\n\\1 permitted wavelengths on a string are \\[\\lambda_n=\\dfrac{2\\ell}{n}\\] where $n$ is a positive integer\r\n\\1 frequencies of higher harmonics are integer multiples of the fundamental frequency $f_1$\r\n\\1 frequencies that may exist on the string are called eigenfrequencies\r\n\\1 collection of allowed frequencies and their amplitudes is called the frequency spectrum of the system. \r\n\\1 closed pipe frequencies \\[\\lambda_n=\\dfrac{4\\ell}{n}\\] always a node at the closed end, goes 1,3,5$f$\r\n\\1 open pipe frequencies \\[\\lambda_n=\\dfrac{2\\ell}{n}\\] always antinodes at open ends, goes 1,2,3$f$\r\n\\end{outline}\r\n\\subsection{Wave groups and beats}\r\n\\begin{outline}\r\n\\1 If the speeds of waves of different frequency are not the same, we say there is dispersion; which means that the speeds of individual waves depend on the particular wavelength or frequency. \r\n\\0 \\[f_b=|f_1-f_2|\\]\r\n\\end{outline}\r\n\\subsection{Fourier analysis and the uncertainty Principles}\r\n\\begin{outline}\r\n\\1 fourier analysis - modeling things as sinusoidal functions\r\n\\1 the frequencies in a Fourier representation of a periodic oscillation always are harmonics of the fundamental frequency of the periodic oscillation\r\n\\1 any periodic function can be represented by a fourier sum of harmonic, sinusoidal functions having a discrete spectrum. \r\n\\0 \\[\\Delta t\\Delta\\omega\\approx2\\pi\\text{ rad}\\]\r\n\\1 which means that the shorter the duration of the pulse (of a wave), the greater the spread of the angular frequencies in its Fourier representation, and vice versa. Also, \\[\\Delta x\\Delta k\\approx2\\pi\\text{ rad}\\]\r\n\\1 which are known as uncertainty relations.\r\n\\end{outline}\r\n\\end{document}", "meta": {"hexsha": "f268edebfcdd76a90075fa8f5f74b4b6000892b6", "size": 16501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch 11-12/ch 11-12 notes.tex", "max_stars_repo_name": "CookiePie1/PhysicsC", "max_stars_repo_head_hexsha": "80d1d884f2ef2560f2c30345acf6c10cc326b4cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch 11-12/ch 11-12 notes.tex", "max_issues_repo_name": "CookiePie1/PhysicsC", "max_issues_repo_head_hexsha": "80d1d884f2ef2560f2c30345acf6c10cc326b4cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch 11-12/ch 11-12 notes.tex", "max_forks_repo_name": "CookiePie1/PhysicsC", "max_forks_repo_head_hexsha": "80d1d884f2ef2560f2c30345acf6c10cc326b4cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.5362903226, "max_line_length": 418, "alphanum_fraction": 0.7248045573, "num_tokens": 4475, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4449897665094627}}
{"text": "\\documentclass[10pt]{article}\n\n% landscape, twocolumn\n\\usepackage[a4paper, landscape, twocolumn, twoside]{geometry}\n% \\usepackage[a4paper, top = 0.6in, bottom = 0.3in, left = 0.5in, right = 0.5in, landscape, twocolumn, twoside]{geometry}\n\n\\usepackage{calc}\n\\setlength{\\topmargin}{-1in + 15pt}\n\\setlength{\\headheight}{12pt}\n\\setlength{\\headsep}{10pt}\n\\setlength{\\footskip}{0pt}\n\\setlength{\\textheight}{\\paperheight - 60pt}\n\n\\setlength{\\oddsidemargin}{-1in + 30pt}\n\\setlength{\\evensidemargin}{-1in + 30pt}\n\\setlength{\\textwidth}{\\paperwidth - 60pt}\n\n\\usepackage[xetex, colorlinks]{hyperref}\n\\usepackage{fontspec, xunicode, xltxtra}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{color}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{fancyhdr}\n\n\\setlength{\\columnsep}{0.4in}\n\n\\pagestyle{fancy}\n\\fancyhead[LE,RO]{\\bfseries\\thepage}\n\\fancyhead[LO,RE]{\\bfseries\\leftmark}\n\\fancyhead[C]{\\bfseries foreverbell}\n\\fancyfoot{}\n\n% \\newfontfamily{\\lsttype}{Liberation Mono}\n\n\\definecolor{dkgreen}{RGB}{63, 127, 85}\n\\definecolor{dkpurple}{RGB}{127, 0, 85}\n\\definecolor{dkgrey}{RGB}{127, 127, 127}\n\\definecolor{dkred}{RGB}{154, 0, 0}\n\\lstset {\n  basicstyle = \\small\\ttfamily,\n  language = C++,\n  aboveskip = 0pt,\n  numbers = left,\n  numberstyle = \\footnotesize\\ttfamily\\color{dkgrey},\n  numbersep = 5pt,\n  tabsize = 2,\n  breaklines = true,\n  breakindent = 1.1em,\n  keywordstyle = \\color{dkpurple},\n  commentstyle = \\color{dkgreen},\n  backgroundcolor = \\color{white},\n  stringstyle = \\color{dkred},\n  deletekeywords = {in},\n  showspaces = false,\n  basewidth = {0.5em, 0.4em},\n  frame = trbl,\n  rulecolor = \\color{dkgrey},\n  showstringspaces = false,\n  escapeinside = {<TeX>}{</TeX>}\n}\n\\begin{document}\n% \\title{\\LARGE Reference Document \\& Code Library}\n% \\date{}\n% \\author{\\textbf{foreverbell}}\n% \\maketitle\n\\tableofcontents\n\\newpage\n\n\\section{Data Structure}\n\\subsection{Splay}\n\\lstinputlisting{src/data-structure/splay.cpp}\n\\subsection{Dynamic Tree}\n\\lstinputlisting{src/data-structure/link-cut-tree.cpp}\n\\subsection{KD Tree}\n\\lstinputlisting{src/data-structure/kd-tree.cpp}\n\\subsection{Treap}\n\\lstinputlisting{src/data-structure/treap.cpp}\n\\subsection{Persistent Treap}\n\\lstinputlisting{src/data-structure/persistent-treap.cpp}\n\\subsection{Persistent Segment Tree}\n\\lstinputlisting{src/data-structure/persistent-segment-tree.cpp}\n\n\\section{String Algorithms}\n\\subsection{Base}\n\\lstinputlisting{src/string-algorithm/kmp.cpp}\n\\lstinputlisting{src/string-algorithm/minimum-representation.cpp}\n\\lstinputlisting{src/string-algorithm/manacher.cpp}\n\\subsection{Aho-Corasick Automaton}\n\\lstinputlisting{src/string-algorithm/aho-corasick-automaton.cpp}\n\\subsection{Suffix Array}\n\\lstinputlisting{src/string-algorithm/suffix-array.cpp}\n\n\\section{Math}\n\\subsection{Number Theory}\n\\lstinputlisting{src/math/number-theory/base.cpp}\n\\lstinputlisting{src/math/number-theory/inverse.cpp}\n\\lstinputlisting{src/math/number-theory/crt.cpp}\n\\lstinputlisting{src/math/number-theory/prime.cpp}\n\\lstinputlisting{src/math/number-theory/factorize.cpp}\n\\lstinputlisting{src/math/number-theory/discrete-logarithm.cpp}\n\\lstinputlisting{src/math/number-theory/primitive-root.cpp}\n\\lstinputlisting{src/math/number-theory/ressol.cpp}\n\\subsection{Matrix Multiplication}\n\\lstinputlisting{src/math/matrix.cpp}\n\\paragraph{$\\blacksquare$ Optimization of recursion matrix}\n\\noindent \\\\\n$h_n=a_1h_{n-1}+a_2h_{n-2}+a_3h_{n-3}+ \\ldots + a_kh_{n-k}$, Construct matrix of $k*k$:\n\\begin{gather*}\n  \\mathbf{M} =\n  \\begin{bmatrix}\n    a_1 & a_2 & a_3 & \\cdots & a_{k-2} & a_{k-1} & a_k \\\\\n    1 & 0 & 0 & \\cdots & 0 & 0 & 0 \\\\\n    0 & 1 & 0 & \\cdots & 0 & 0 & 0 \\\\\n    0 & 0 & 1 & \\cdots & 0 & 0 & 0 \\\\\n    \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\vdots \\\\\n    0 & 0 & 0 & \\cdots & 1 & 0 & 0 \\\\\n    0 & 0 & 0 & \\cdots & 0 & 1 & 0 \\\\\n  \\end{bmatrix}\n\\end{gather*}\nThen the characteristic polynomial of $\\mathbf{M}$ is\n\\begin{gather*}\n  f(\\lambda)=|\\lambda \\mathbf{E} - \\mathbf{M}| =\n  \\begin{bmatrix}\n    \\lambda - a_1 & -a_2 & -a_3 & \\cdots & -a_{k-2} & -a_{k-1} & -a_k \\\\\n    -1 & \\lambda & 0 & \\cdots & 0 & 0 & 0 \\\\\n    0 & -1 & \\lambda & \\cdots & 0 & 0 & 0 \\\\\n    0 & 0 & -1 & \\cdots & 0 & 0 & 0 \\\\\n    \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\vdots \\\\\n    0 & 0 & 0 & \\cdots & -1 & \\lambda & 0 \\\\\n    0 & 0 & 0 & \\cdots & 0 & -1 & \\lambda \\\\\n  \\end{bmatrix}\n  \\\\\n  =\\lambda ^k - a_1 \\lambda ^ {k-1} - a_2 \\lambda ^ {k-2} - \\ldots - a_k.\n\\end{gather*}\nApply Hamilton-Cayley theorem, we have $f(\\mathbf{M})=\\mathbf{0}$. \\\\\nAnd, $\\forall i$, $\\mathbf{M} ^ i$ can be written as a linear combination of $\\mathbf{E}$,$\\mathbf{M}$,$\\mathbf{M} ^2$,$\\ldots$,$\\mathbf{M} ^ {k-1}$.\\\\\nSo the matrix multiplication is reduced to polynomial multiplication, which can be computed in $O(n^2)$. \\\\\n\\lstinputlisting{src/math/linear-recurrence-sequence.cpp}\n\\paragraph{$\\blacksquare$ Spanning tree count}\n\\noindent \\\\\nLaplacian matrix $L=(\\ell_{i,j})_{n*n}$ is defined as: $L=D-A$, that is, it is the difference of the degree matrix $D$ and the adjacency matrix $A$ of the graph. \\\\\nFrom the definition it follows that:\n\\begin{displaymath}\n  \\ell_{i,j}=\n  \\left\\{ \\begin{array}{ll}\n    deg(v_i) & \\textrm{if } i=j \\\\\n    -1 & \\textrm{if }i\\ne j\\textrm{ and }v_i\\textrm{ is adjacent to }v_j \\\\\n    0 & \\textrm{otherwise}\n  \\end{array} \\right.\n\\end{displaymath}\nThen the number of spanning trees of a graph on $n$ vertices is the determinant of any $n-1$ submatrix of $L$.\n\\subsection{Gauss Elimiation}\n\\lstinputlisting{src/math/gauss-elimination.cpp}\n\\subsection{Polynomial Root}\n\\lstinputlisting{src/math/polynomial-root.cpp}\n\\subsection{Number Partition}\n\\lstinputlisting{src/math/number-partition.cpp}\n\\subsection{Simplex Linear Programming}\n\\lstinputlisting{src/math/simplex-linear-programming.cpp}\n\\subsection{Simpson Integration}\n\\lstinputlisting{src/math/simpson-integration.cpp}\n\\subsection{Fast Fourier Transform}\n\\lstinputlisting{src/math/fast-fourier-transform.cpp}\n\\subsection{Number Theoretic Transform}\n\\lstinputlisting{src/math/number-theoretic-transform.cpp}\n\n\\section{Computational Geometry}\n\\subsection{2D Base}\n\\lstinputlisting{src/computational-geometry/2d-base.cpp}\n\\subsection{Graham Convex Hull}\n\\lstinputlisting{src/computational-geometry/convex-hull-2d.cpp}\n\\subsection{Minkowski Sum of Convex Hull}\n\\noindent\nWiki: \\\\\nThe Minkowski sum of two sets of position vectors $A$ and $B$ in Euclidean space is formed by adding each vector in $A$ to each vector in $B$, i.e. the set\n\\begin{displaymath}\n  A+B=\\{ \\vec{a} + \\vec{b} \\, | \\, \\vec{a} \\in A, \\vec{b} \\in B \\}.\n\\end{displaymath}\nFor all subsets $S_1$ and $S_2$ of a real vector-space, the convex hull of their Minkowski sum is the Minkowski sum of their convex hulls $\\mathrm{Conv} (S_1 + S_2) = \\mathrm{Conv} (S_1) + \\mathrm{Conv} (S_2)$. \\\\\nMinkowski sums are used in motion planning of an object among obstacles. They are used for the computation of the configuration space, which is the set of all admissible positions of the object. In the simple model of translational motion of an object in the plane, where the position of an object may be uniquely specified by the position of a fixed point of this object, the configuration space are the Minkowski sum of the set of obstacles and the movable object placed at the origin and rotated $180$ degrees. \\\\\n\\lstinputlisting{src/computational-geometry/minkowski-convex-hull.cpp}\n\\subsection{Rotating Calipers}\n\\lstinputlisting{src/computational-geometry/rotating-caliper.cpp}\n\\subsection{Closest Pair Points}\n\\lstinputlisting{src/computational-geometry/closest-pair-points.cpp}\n\\subsection{Halfplane Intersection}\n\\lstinputlisting{src/computational-geometry/halfplane-intersection.cpp}\n\\lstinputlisting{src/computational-geometry/halfplane-intersection-nlogn.cpp}\n\\subsection{Tri-Cir Intersection \\& Tangent}\n\\lstinputlisting{src/computational-geometry/circle-tangent.cpp}\n\\lstinputlisting{src/computational-geometry/circle-intersection.cpp}\n\\lstinputlisting{src/computational-geometry/triangle-circle-area-intersection.cpp}\n\\subsection{Circle Area Union}\n\\lstinputlisting{src/computational-geometry/circle-area-union.cpp}\n\\subsection{Minimum Covering Circle}\n\\lstinputlisting{src/computational-geometry/minimum-circle.cpp}\n\\subsection{Convex Polygon Area Union}\n\\lstinputlisting{src/computational-geometry/polygon-area-union.cpp}\n\\subsection{3D Base}\n\\lstinputlisting{src/computational-geometry/3d-base.cpp}\n\\subsection{3D Convex Hull}\n\\lstinputlisting{src/computational-geometry/convex-hull-3d.cpp}\n\\subsection{Quaternion}\n\\lstinputlisting{src/computational-geometry/quaternion.cpp}\n\n\\section{Graph}\n\\subsection{Tarjan}\n\\lstinputlisting{src/graph-algorithm/tarjan.cpp}\nFor bidirectional graph(cut vertex \\& bridge): \\\\\nroot: $u$ has $2$ or more children. \\\\\nothers: exist a child $v$ satifsying $dfn[u] \\le low[v]$. \\\\\n$(u, v)$ is bridge only if $dfn[u] < low[v]$ (trick: multiple edges).\\\\\n\\subsection{Maximum Flow}\n\\lstinputlisting{src/graph-algorithm/maximum-flow.cpp}\nNotes on vertex covering and independent set on bipartite graph:\\\\\nMinimum Vertex Covering Set V': $\\forall (u,v) \\in E$, $u \\in V'$ or $v \\in V'$ holds. \\\\\nMaximum Vertex Independent Set V': $\\forall u,v \\in V'$, $(u,v) \\notin E$ holds.\\\\\nConstruct a flow graph $G$, run DFS from $s$ on reduction graph, the vertices not visited in left side and visited in right side form the minimum vertex covering set.\\\\\nMaximum vertex independent set vice versa.\\\\\n\\subsection{Minimum Cost, Maximum Flow}\n\\lstinputlisting{src/graph-algorithm/minimum-cost-maximum-flow.cpp}\n\\subsection{Kuhn Munkras}\n\\lstinputlisting{src/graph-algorithm/kuhn-munkras.cpp}\n\\subsection{Hopcroft Karp}\n\\lstinputlisting{src/graph-algorithm/hopcroft-karp.cpp}\n\\subsection{Blossom Matching}\n\\lstinputlisting{src/graph-algorithm/blossom-matching.cpp}\n\\subsection{Stoer Wagner}\n\\lstinputlisting{src/graph-algorithm/stoer-wagner.cpp}\n\\subsection{Arborescence}\n\\lstinputlisting{src/graph-algorithm/arborescence.cpp}\n\\subsection{Manhattan MST}\n\\lstinputlisting{src/graph-algorithm/manhattan-mst.cpp}\n\\subsection{Minimum Mean Cycle}\n\\lstinputlisting{src/graph-algorithm/minimum-mean-cycle.cpp}\n\\subsection{Dominator Tree}\n\\noindent\nA dominator tree is a tree where each node's children are those nodes it immediately dominates. Because the immediate dominator is unique, it is a tree. The start node is the root of the tree.\n\\lstinputlisting{src/graph-algorithm/dominator-tree.cpp}\n\n\\section{Miscellaneous}\n% \\subsection{High Precision Calculation}\n% \\lstinputlisting{src/high-precision-calculation.cpp}\n\\subsection{Parser}\n\\lstinputlisting{src/misc/parser.cpp}\n\\subsection{Steiner's Problem}\n\\lstinputlisting{src/misc/steiner-problem.cpp}\n\\subsection{AlphaBeta}\n\\lstinputlisting{src/misc/alphabeta.cpp}\n\\subsection{LCA}\n\\lstinputlisting{src/misc/lowest-common-ancestor.cpp}\n\\subsection{Divide and Conquer on Tree}\n\\lstinputlisting{src/misc/divide-and-conquer-on-tree.cpp}\n\\subsection{Dancing Links X}\n\\lstinputlisting{src/misc/dancing-links-x.cpp}\nFind the minimum row set, satisfying each column has exactly one $1$. \\\\\nLet the row representing each choice, if some choices are mutually exclusive, add a column with these rows associated. \\\\\nUse the sudoku problem as an instance. There are $729$ choices($81$ squares can be filled in with $9$ numbers), $4$ constraints:\\\\\n(1). Each box has exactly one number; \\\\\n(2). Number $1$ to $9$ appears exactly once in each row, column, sub square. \\\\\nThus we can construct a $729*324$ matrix, each $81$ columns representing each constraint.\\\\\n\\subsection{Mo-Tao Algorithm}\n\\lstinputlisting{src/misc/motao-algorithm.cpp}\n\\subsection{Cyclic LCS}\n\\lstinputlisting{src/misc/cyclic-longest-common-subsequence.cpp}\n\n\\section{Tips}\n\\subsection{Snippets \\& Black Magic}\n\\begin{itemize}\n  \\item Accelerated C++ stream IO\n    \\begin{lstlisting}[frame=none]\n#include <iomanip>\nios_base::sync_with_stdio(false);\n    \\end{lstlisting}\n  \\item Enumerate all non-empty subsets\n    \\begin{lstlisting}[frame=none]\nfor (int sub = mask; sub > 0; sub = (sub - 1) & mask)\n    \\end{lstlisting}\n  \\item Enumerate $\\mathrm{C}_{n}^{k}$\n    \\begin{lstlisting}[frame=none]\nfor (int comb = (1 << k) - 1; comb < 1 << n; ) {\n  // ...\n  int x = comb & -comb, y = comb + x;\n  comb = ((comb & ~y) / x >> 1) | y;\n}\n    \\end{lstlisting}\n  \\item Convert YY/MM/DD to date\n    \\begin{lstlisting}[frame=none]\nint days(int y, int m, int d) {\n  if (m < 3) y--, m += 12;\n  return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m + 2) / 5 + d;\n}\n    \\end{lstlisting}\n  \\item Calculate $\\lfloor f(n/d) \\rfloor$, $d=1, 2, \\ldots, n$.\n    \\begin{lstlisting}[frame=none]\nvoid iterate(int n) { // calc sum f(n/d), d<-[1..n]\n  int root = sqrt(double(n)), to = n;\n  for (int d = 1; d <= root; ++d) {\n    int l = n / (d + 1), r = n / d;\n    // (r - l) * f(d)\n    to = min(to, l);\n  }\n  for (int d = 1; d <= to; ++d) {\n    // accumlate single f(n / d)\n  }\n}\n    \\end{lstlisting}\n  \\item pb-ds\n    \\lstinputlisting[frame=none]{src/pb-ds.cpp}\n  \\item mulmod\n    \\lstinputlisting[frame=none]{src/mulmod.cpp}\n  \\item Modify stack limit\n    \\lstinputlisting[frame=none]{src/stack-limit.cpp}\n\\end{itemize}\n\\subsection{Formulas}\n\\subsubsection{Geometry}\n\\paragraph{$\\blacksquare$ Euler's Formula}\n\\noindent \\\\\nFor convex polyhedron: $V-E+F=2$. \\\\\nFor planar graph: $|F|=|E|-|V|+n+1$, $n$ denotes the number of connected components.\n\\paragraph{$\\blacksquare$ Pick's Theorem}\n\\begin{eqnarray*}\n  S=I+\\frac{B}{2}-1\n\\end{eqnarray*}\n$S$ is the area of lattice polygon, $I$ is the number of lattice interior points, and $B$ is the number of lattice boundary points.\n\\paragraph{$\\blacksquare$ Heron's Formula}\n\\begin{eqnarray*}\n  && S=\\sqrt{p(p-a)(p-b)(p-c)} \\\\\n  && p=\\frac{a+b+c}{2}\n\\end{eqnarray*}\n\\paragraph{$\\blacksquare$ Volumes}\n\\noindent\n\\begin{itemize}\n  \\item Pyramid $V=\\frac{1}{3}Sh$.\n  \\item Sphere $V=\\frac{4}{3}\\pi R^3$.\n  \\item Frustum $V=\\frac{1}{3}h(S_1+\\sqrt {S_1S_2}+S_2)$.\n  \\item Ellipsoid $V=\\frac{4}{3} \\pi abc$.\n  \\item Tetrahedron \\\\\n    For tetrahedron $O-ABC$, let $a=AB,b=BC,c=CA,d=OC,e=OA,f=OB$, ${(12V)}^2=a^2d^2(b^2+c^2+e^2+f^2-a^2-d^2)+b^2e^2(c^2+a^2+f^2+d^2-b^2-e^2)+c^2f^2(a^2+b^2+d^2+e^2-c^2-f^2)-a^2b^2c^2-a^2e^2f^2-d^2b^2f^2-d^2e^2c^2$.\n\\end{itemize}\n\\paragraph{$\\blacksquare$ Radius of Inscribedcircle \\& Circumcircle}\n\\begin{eqnarray*}\n  && r=\\frac{2S}{a+b+c},\\, R=\\frac{abc}{4S}\n\\end{eqnarray*}\n\\paragraph{$\\blacksquare$ Hypersphere}\n\\begin{eqnarray*}\n  && V_2=\\pi R^2,\\, S_2=2\\pi R \\\\\n  && V_3=\\frac{4}{3}\\pi R^3,\\, S_3=4\\pi R^2 \\\\\n  && V_4=\\frac{1}{2}\\pi ^2 R^4,\\, S_4=2\\pi ^2 R^3 \\\\\n  && V_5=\\frac{8}{15}\\pi ^2 R^5,\\, S_5=\\frac{8}{3}\\pi ^2 R^4 \\\\\n  && V_6=\\frac{1}{6}\\pi ^3 R^6,\\, S_6=\\pi ^3 R^5 \\\\\n  && \\mathrm{Generally}, V_n=\\frac{2\\pi}{n}V_{n-2},\\, S_{n-1}=\\frac{2\\pi}{n-2}S_{n-3} \\\\\n  && \\mathrm{Where}, S_0=2,\\, V_1=2,\\, S_1=2\\pi ,\\, V_2=\\pi\n\\end{eqnarray*}\n% \\paragraph{$\\blacksquare$ Affine Transformation}\n% \\begin{gather*}\n% \\mathrm{Tr} = \\mathrm{TrTra} * \\mathrm{TrRot} * \\mathrm{TrSca} =\n% \\begin{bmatrix}\n% 1 & 0 & T_x \\\\\n% 0 & 1 & T_y \\\\\n% 0 & 0 & 1\n% \\end{bmatrix}\n% \\begin{bmatrix}\n% \\cos \\alpha & - \\sin \\alpha & 0 \\\\\n% \\sin \\alpha & \\cos \\alpha & 0 \\\\\n% 0 & 0 & 1\n% \\end{bmatrix}\n% \\begin{bmatrix}\n% S_x & 0 & 0 \\\\\n% 0 & S_y & 0 \\\\\n% 0 & 0 & 1\n% \\end{bmatrix}\n% \\\\\n% =\n% \\begin{bmatrix}\n% S_x \\cos \\alpha & -S_y \\sin \\alpha & T_x \\\\\n% S_x \\sin \\alpha & S_y \\cos \\alpha & T_y \\\\\n% 0 & 0 & 1\n% \\end{bmatrix}\n% \\end{gather*}\n% The fixed point is $(x_0,y_0)$, where\n% \\begin{eqnarray*}\n% && x_0 =  - \\frac{T_x (S_y \\cos \\alpha - 1)}{S_x S_y - S_x \\cos \\alpha - S_y \\cos \\alpha + 1} - \\frac{S_y T_y \\sin \\alpha}{S_x S_y - S_x \\cos \\alpha - S_y \\cos \\alpha + 1} \\\\\n% && y_0 = \\frac{S_x T_x \\sin \\alpha}{S_x S_y - S_x \\cos \\alpha - S_y \\cos \\alpha + 1} - \\frac{T_y (S_x \\cos \\alpha - 1)}{S_x S_y - S_x \\cos \\alpha - S_y \\cos \\alpha + 1}\n% \\end{eqnarray*}\n\\paragraph{$\\blacksquare$ Matrix of rotating $\\theta$ about arbitrary axis A}\n\\begin{gather*}\n  \\begin{bmatrix}\n    c+(1-c)A_x^2 & (1-c)A_xA_y-sA_z & (1-c)A_xA_z+sA_y \\\\\n    (1-c)A_xA_y+sA_z & c+(1-c)A_y^2 & (1-c)A_yA_z-sA_x \\\\\n    (1-c)A_xA_z-sA_y & (1-c)A_yA_z+sA_x & c+(1-c)A_z^2\n  \\end{bmatrix}\n\\end{gather*}\nWhere $c=\\cos(\\theta)$, $s=\\sin(\\theta)$ and $A=(A_x,A_y,A_z)$.\n\\subsubsection{Math}\n\\paragraph{$\\blacksquare$ Sums}\n\\begin{eqnarray*}\n  && 1+2+\\ldots +n=\\frac{n^2}{2}+\\frac{n}{2} \\\\\n  && 1^2+2^2+\\ldots +n^2=\\frac{n^3}{3}+\\frac{n^2}{2}+\\frac{n}{6} \\\\\n  && 1^3+2^3+\\ldots +n^3=\\frac{n^4}{4}+\\frac{n^3}{2}+\\frac{n^2}{4} \\\\\n  && 1^4+2^4+\\ldots +n^4=\\frac{n^5}{5}+\\frac{n^4}{2}+\\frac{n^3}{3}-\\frac{n}{30} \\\\\n  && 1^5+2^5+\\ldots +n^5=\\frac{n^6}{6}+\\frac{n^5}{2}+\\frac{5n^4}{12}-\\frac{n^2}{12} \\\\\n  && 1^6+2^6+\\ldots +n^6=\\frac{n^7}{7}+\\frac{n^6}{2}+\\frac{n^5}{2}-\\frac{n^3}{6}+\\frac{n}{42} \\\\\n  && \\mathrm{P}(k)=\\frac{(n+1)^{k+1}-\\sum_{i=0}^{k-1}\\binom{k+1}{i}\\mathrm{P}(i)}{k+1}, \\mathrm{P}(0)=n\\textbf{+1}\n\\end{eqnarray*}\n\\begin{eqnarray*}\n  && \\sum_{k=1}^{n}k(k+1)=\\frac{n(n+1)(n+2)}{3} \\\\\n  && \\sum_{k=1}^{n}k(k+1)(k+2)=\\frac{n(n+1)(n+2)(n+3)}{4} \\\\\n  && \\sum_{k=1}^{n}k(k+1)(k+2)(k+3)=\\frac{n(n+1)(n+2)(n+3)(n+4)}{5}\n\\end{eqnarray*}\n\\paragraph{$\\blacksquare$ Power Reduction}\n$a^b\\%p=a^{(b\\% \\varphi (p))+\\varphi (p)}\\% p \\, (b \\ge \\varphi (p))$\n\\paragraph{$\\blacksquare$ Burnside's Lemma}\n\\noindent\n\\begin{displaymath}\n  |X/G|=\\frac{1}{|G|}\\sum_{g\\in G}|X^g|\n\\end{displaymath}\n\\begin{displaymath}\n  \\mathrm{Polya}: X^g=t^{c(g)}\n\\end{displaymath}\nLet $X^g$ denote the set of elements in $X$ fixed by $g$. \\\\\n$c(g)$ is the number of cycles of the group element $g$ as a permutation of $X$.\n\\paragraph{$\\blacksquare$ Lucas's Theorem}\n\\noindent \\\\\nFor non-negative integers $m$ and $n$ and a prime $p$, holds the equation \\\\\n\\begin{displaymath}\n  \\binom{m}{n} \\equiv \\prod_{i=0}^k \\binom{m_i}{n_i} \\mod p\n\\end{displaymath}\nwhere $m=m_kp^k+m_{k-1}p^{k-1}+\\ldots +m_1p+m_0$, and $n=n_kp^k+n_{k-1}p^{k-1}+\\ldots +n_1p+n_0$, are the base $p$ expansions of $m$ and $n$ respectively.\n\\paragraph{$\\blacksquare$ Wilson's Theorem}\n\\noindent \\\\\n$p$ is a prime $\\iff (p-1)! \\equiv -1 \\pmod{p}$.\n\\paragraph{$\\blacksquare$ Polynomial Congruence Equation}\n\\noindent \\\\\nSolve the polynomial congruence equation $f(x)\\equiv 0 \\mod m$, $m=\\prod_{i=1}^{k}p_i^{a_i}$. \\\\\nWe just simply consider the equation $f(x)\\equiv 0 \\mod p^a$, then use the Chinese Remainder theorem to merge the result. \\\\\nIf $x$ is the root of the equation $f(x)\\equiv 0 \\mod p^a$, then $x$ is also the root of $f(x)\\equiv 0 \\mod p^{a-1}$. \\\\\n$f'(x')\\equiv 0 \\mod p$ \\textbf{and} $f(x')\\equiv 0 \\mod p^a \\Rightarrow x=x'+dp^{a-1}(d=0,\\ldots ,p-1)$ \\\\\n$f'(x')\\not\\equiv 0 \\mod p \\Rightarrow x=x'-\\frac{f(x')}{f'(x')}$\n\\paragraph{$\\blacksquare$ Binomial Coefficients}\n\\begin{eqnarray*}\n  && \\mathrm{C}_{r}^{k}=\\frac{r}{k}\\mathrm{C}_{r-1}^{k-1}\\qquad \\qquad \\: \\: \\: \\mathrm{C}_{r}^{k}=\\mathrm{C}_{r-1}^{k}+\\mathrm{C}_{r-1}^{k-1} \\\\\n  && \\mathrm{C}_{r}^{m}\\mathrm{C}_{m}^{k}=\\mathrm{C}_{r}^{k}\\mathrm{C}_{r-k}^{m-k}\\qquad \\sum_{k\\le n}\\mathrm{C}_{r+k}^{k}=\\mathrm{C}_{r+n+1}^{n} \\\\\n  && \\sum_{0 \\le k \\le n}\\mathrm{C}_{k}^{m}=\\mathrm{C}_{n+1}^{m+1}\\qquad \\sum_{k}\\mathrm{C}_{r}^{k}\\mathrm{C}_{s}^{n-k}=\\mathrm{C}_{r+s}^{n}\n\\end{eqnarray*}\nThe number of non-negative solutions to equation $x_1 + x_2 + x_3 + \\ldots + x_k = n$ is $\\binom{n+k-1}{k-1}$.\n\\paragraph{$\\blacksquare$ Probability Distribution}\n\\begin{itemize}\n  \\item Binomial distribution:\n    $\\mathrm{Pr}[\\mathit{X}=k]=\\binom{n}{k}p^kq^{n-k}, p+q=1, \\mathrm{E}[\\mathit{X}]=np.$\n  \\item Poisson distribution:\n    $\\mathrm{Pr}[\\mathit{X}=k]=\\frac{e^{-\\lambda }\\lambda ^{k}}{k!}, \\mathrm{E}[\\mathit{X}]=\\lambda .$\n  \\item Gaussian distribution:\n    $p(x)=\\frac{1}{\\sigma \\sqrt{2\\pi }}e^{-(x-\\mu)^2/2\\sigma ^2}, \\mathrm{E}[\\mathit{X}]=\\mu .$\n  \\item Geometric distribution:\n    $\\mathrm{Pr}[\\mathit{X}=k]=pq^{k-1}, p+q=1, \\mathrm{E}[\\mathit{X}]=\\frac{1}{p}.$\n\\end{itemize}\n\\paragraph{$\\blacksquare$ Catalan Number}\n\\noindent \\\\\nThe number of sequences with $1$ of $m$ and $-1$ of $n$, and m$\\ge n$, satifisying the constraint that any sum of the first $k$ elements is always non-negative: $\\mathrm{C}_{m+n}^{m}-\\mathrm{C}_{m+n}^{m+1}$. \\\\\nSpecially, when $m=n$, it equals to $\\mathrm{C}_{n}=\\frac{\\mathrm{C}_{2n}^{n}}{n+1}$, which is the Catalan number. \\\\\nThe first 10 Catalan numbers are $1$, $2$, $5$, $14$, $42$, $132$, $429$, $1430$, $4862$, $16796$, from $n=1$, and $C_0=1$. \\\\\nBesides, $C_{n+1}=\\sum_{i=0}^{n}C_{i}C_{n-i}$, for $n\\ge 0$.\n\\paragraph{$\\blacksquare$ Stirling Number of $\\mathrm{2^{nd}}$}\n\\noindent \\\\\nThe Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets, denoted by $S(n,k)$. \\\\\n$S(n,k)=kS(n-1,k)+S(n-1,k-1)$, and $S(0,0)=1$, $S(n,0)=0$, $S(n,n)=1$.\n\\paragraph{$\\blacksquare$ Bell Number}\n\\noindent \\\\\nThe Bell Number is the number of ways to partition a set of $n$ objects into several subsets, denoted by $B_{n}$. \\\\\nThe first few Bell Numbers are $1$, $1$, $2$, $5$, $15$, $52$, $203$, $877$, $4140$, $21147$, $115975$. \\\\\n$B_{n+1}=\\sum_{k=0}^{n} \\binom{n}{k}B_k$, $B_n=\\sum_{k=0}^{n}S(n,k)$, where $S(n,k)$ is Stirling Number of $\\mathrm{2^{nd}}$. \\\\\nIf $p$ is a prime then, $B_{p+n} \\equiv B_n+B_{n+1} (mod \\; p)$, $B_{p^m+n} \\equiv m B_n + B_{n+1} (mod \\; p)$.\n\\paragraph{$\\blacksquare$ Derangement Number}\n\\noindent \\\\\nThe number of permutations of n elements with no fixed points, denotes as $D_n$. \\\\\n$D_n=n!(1-\\frac{1}{1!}+\\frac{1}{2!}-\\frac{1}{3!}+\\ldots +{(-1)}^n\\frac{1}{n!})$, or $D_n=n*D_{n-1}+{(-1)}^n,D_n=(n-1)*(D_{n-1}+D_{n-2})$, with $D_1=1,D_2=1$.\nThe first 10 derangement numbers are $0$, $1$, $2$, $9$, $44$, $265$, $1854$, $14833$, $133496$, $41334961$, from $n=1$.\n\\subsubsection{Integrals}\n\\input{integrals.tex}\n\\subsection{Primes}\n\\noindent\n$100003$, $200003$, $300007$, $400009$, $500009$, $600011$, $700001$, $800011$, $900001$, \\\\\n$1000003$, $2000003$, $3000017$, $4100011$, $5000011$, $8000009$, $9000011$, \\\\\n$10000019$, $20000003$, $50000017$, $50100007$, \\\\\n$100000007$, $100200011$, $200100007$, $250000019$\n\n\\end{document}\n", "meta": {"hexsha": "222a5253f69ba2d645c1276268b9ad71b2de803a", "size": 22006, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "archives/codelibraries/acm-icpc-cheat-sheet-master/main.tex", "max_stars_repo_name": "cbarnson/UVa", "max_stars_repo_head_hexsha": "0dd73fae656613e28b5aaf5880c5dad529316270", "max_stars_repo_licenses": ["Unlicense", "MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-09-07T17:00:26.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-05T02:08:35.000Z", "max_issues_repo_path": "archives/codelibraries/acm-icpc-cheat-sheet-master/main.tex", "max_issues_repo_name": "cbarnson/UVa", "max_issues_repo_head_hexsha": "0dd73fae656613e28b5aaf5880c5dad529316270", "max_issues_repo_licenses": ["Unlicense", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "archives/codelibraries/acm-icpc-cheat-sheet-master/main.tex", "max_forks_repo_name": "cbarnson/UVa", "max_forks_repo_head_hexsha": "0dd73fae656613e28b5aaf5880c5dad529316270", "max_forks_repo_licenses": ["Unlicense", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.7276422764, "max_line_length": 516, "alphanum_fraction": 0.6736799055, "num_tokens": 8142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4449897528412706}}
{"text": "\\chapter{Learning the parameters of a state-space model}\n\\label{chap:inference}\n\nThis chapter describes the state-space model (SSM) formulation we are working with. In \\autoref{sec:ssm-definition}, we formally define the SSM and state our assumptions about the individual probability distributions.\n\nIn \\autoref{sec:parameter-inference}, we calculate the posterior distribution of the parameters of interest, and show that straightforward inference is not possible. Further on, we derive a sampler to approximate this distribution. This sampler is unusable, as it requires the evaluation of the intractable likelihood. Nevertheless, it is illustrative to compare it with the variant derived later.\n\nTo circumvent the likelihood evaluation, we introduce the particle filter in \\autoref{sec:particle-filter}. This section gives the definition and some of the properties of the filter.\n\nFinally, in \\autoref{sec:particle-filter-estimate} we show how to use the particle filter to estimate the likelihood, and argue that it does not affect the asymptotic properties of the sampler.\n\nMost of this chapter is based on \\cite{andrieu} and \\cite{schoen}.\n\n\n\n\\section{State-Space Model definition} \\label{sec:ssm-definition}\nThe state-space model, often also called the hidden Markov model (HMM) assumes a sequence of latent states $\\left\\{\\bx_t\\right\\}_{t=0}^\\infty \\subseteq \\R^{d_x}$ following a Markov chain, and a sequence of observed variables $\\left\\{\\by_t\\right\\}_{t=1}^\\infty \\subseteq \\R^{d_y}$. All involved distributions are parameterized by an unknown static parameter $\\btheta \\in \\Theta \\subset \\R^d$.\n\nFor a fixed time $T \\geq 1$, we use the shorthands $\\bx_{0:T} = \\left\\{\\bx_t\\right\\}_{t=0}^T$ and $\\by_{1:T} = \\left\\{\\by_t\\right\\}_{t=1}^T$ throughout the thesis.\n\nThe HMM formulation means that the joint distribution of $\\bx_{0:T}$ and $\\by_{1:T}$ factorizes, for any $T \\geq 1$, into\n\\begin{equation}\\label{eq:factorization}\np(\\bx_{0:T}, \\by_{1:T} \\mid \\btheta) = \\sprior(\\bx_0 \\mid \\btheta) \\prod_{t = 1}^{T} \\trans_t(\\bx_t \\mid \\bx_{t-1}, \\btheta) \\obs_t(\\by_t \\mid \\bx_t, \\btheta),\n\\end{equation}\nwhere $\\sprior(\\bx_0 \\mid \\btheta)$ is the prior distribution over the initial state, $\\trans_t(\\bx_t \\mid \\bx_{t-1}, \\btheta)$ is the transition distribution at time $t$ and $\\obs_t(\\by_t \\mid \\bx_t, \\btheta)$ is the observation model at time $t$.\n\nThe factorization \\eqref{eq:factorization} can be written more clearly as\n\\begin{alignat*}{2}\n\\bx_0 \\mid \\btheta & \\sim \\sprior(\\bx_0 \\mid \\btheta), & \\\\\n\\bx_t \\mid \\bx_{t-1}, \\btheta & \\sim \\trans_t(\\bx_t \\mid \\bx_{t-1}, \\btheta), \\quad & t = 1, \\ldots, T, \\\\\n\\by_t \\mid \\bx_t, \\btheta & \\sim \\obs_t(\\by_t \\mid \\bx_t, \\btheta), \\quad & t = 1, \\ldots, T.\n\\end{alignat*}\n\nFinally, in accordance with the Bayesian approach \\citep{bayes}, we introduce a prior distribution $\\pprior$ over the unknown parameter $\\btheta$ quantifying our knowledge about $\\btheta$ before having observed any data. This allows us to state the full joint distribution\n\\begin{equation}\\label{eq:full-joint}\np(\\bx_{0:T}, \\by_{1:T}, \\btheta) = p(\\bx_{0:T}, \\by_{1:T} \\mid \\btheta) \\pprior(\\btheta).\n\\end{equation}\nThe corresponding graphical model is depicted in \\autoref{fig:graphical-model}.\n\\begin{figure}[ht]\n    \\centering\n    \\begin{tikzpicture}\n    % Style\n    \\tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm]\n    \\tikzstyle{connect}=[-latex, thick]\n    \n    % Nodes X\n    \\node[main,shape=circle,draw=black](X0) at (1,4) {$\\bx_0$};\n    \\node[main,shape=circle,draw=black](X1) at (3,4) {$\\bx_1$};\n    \\node[main,shape=circle,draw=black](X2) at (5,4) {$\\bx_2$};\n    \\node[](Xdots) at (7,4) {$\\ldots$};\n    \\node[main,shape=circle,draw=black](XT) at (9,4) {$\\bx_T$};\n    \n    % Node theta\n    \\node[](theta) at (7,2) {$\\btheta$};\n    \n    % Nodes Y\n    \\node[main,shape=circle,draw=black,fill=black!20](Y1) at (3,0) {$\\by_1$};\n    \\node[main,shape=circle,draw=black,fill=black!20](Y2) at (5,0) {$\\by_2$};\n    \\node[](Ydots) at (7,0) {$\\ldots$};\n    \\node[main,shape=circle,draw=black,fill=black!20](YT) at (9,0) {$\\by_T$};\n\n    % Edges XX\n    \\path [->] (X0) edge[connect] node[left] [above] {$\\trans_1$} (X1);\n    \\path [->] (X1) edge[connect] node[left] [above] {$\\trans_2$} (X2);\n    \\path [->] (X2) edge[connect] node[left] [above] {$\\trans_3$} (Xdots);\n    \\path [->] (Xdots) edge[connect] node[left] [above] {$\\trans_T$} (XT);\n    \n    % Edges XY\n    \\path [->] (X1) edge[connect] node[left] [left] {$\\obs_1$} (Y1);\n    \\path [->] (X2) edge[connect] node[left] [left] {$\\obs_2$} (Y2);\n    \\path [->] (XT) edge[connect] node[left] [left] {$\\obs_T$} (YT);\n    \n    % Edges theta X\n    \\path [->] (theta) edge[connect] node[left] {} (X0);\n    \\path [->] (theta) edge[connect] node[left] {} (X1);\n    \\path [->] (theta) edge[connect] node[left] {} (X2);\n    \\path [->] (theta) edge[connect] node[left] {} (XT);\n    \n    % Edges theta Y\n    \\path [->] (theta) edge[connect] node[left] {} (Y1);\n    \\path [->] (theta) edge[connect] node[left] {} (Y2);\n    \\path [->] (theta) edge[connect] node[left] {} (YT);\n    \\end{tikzpicture}\n    \\caption{Graphical model describing the full joint distribution \\eqref{eq:full-joint}. The shaded nodes denote the observed variables, white nodes represent the latent variables.}\n    \\label{fig:graphical-model}\n\\end{figure}\n\n\n\n\\section{Parameter inference} \\label{sec:parameter-inference}\nGiven an observed sequence $\\by_{1:T}$, Bayesian inference relies on the joint posterior density\n\\begin{equation}\\label{eq:joint-posterior}\np(\\btheta, \\bx_{0:T} \\mid \\by_{1:T}) = \\underbrace{p(\\bx_{0:T} \\mid \\btheta, \\by_{1:T})}_{\\text{State inference}} \\underbrace{p(\\btheta \\mid \\by_{1:T})}_{\\text{Parameter inference}}.\n\\end{equation}\nOur primary goal is to infer the static parameter $\\btheta$. From \\eqref{eq:joint-posterior}, it is clear that for state inference, one needs knowledge about $\\btheta$, so even if the latent states $\\bx_{0:T}$ are of interest, knowledge about $\\btheta$ is necessary.\n\n\n\\paragraph{Bayesian inference}\n\nTo perform Bayesian inference of $\\btheta$, we express the posterior of $\\btheta$ by applying the Bayes theorem:\n\\begin{equation} \\label{eq:posterior}\np(\\btheta \\mid \\by_{1:T}) = \\frac{p(\\by_{1:T} \\mid \\btheta) \\pprior(\\btheta)}{\\int p(\\by_{1:T} \\mid \\btheta) \\pprior(\\btheta) \\; \\dx{\\btheta}}.\n\\end{equation}\nEvaluating the likelihood $p(\\by_{1:T} \\mid \\btheta)$ requires marginalising over $\\bx_{0:T}$:\n\\begin{equation} \\label{eq:likelihood}\np(\\by_{1:T} \\mid \\btheta) = \\int p(\\bx_{0:T}, \\by_{1:T} \\mid \\btheta) \\; \\dx{\\bx_{0:T}},\n\\end{equation}\nwhere $p(\\bx_{0:T}, \\by_{1:T} \\mid \\btheta)$ is given in \\eqref{eq:factorization}. Unless the SSM is linear and Gaussian, such $d_x(T+1)$-dimensional integral is intractable \\citep{andrieu}.\n\n\n\\paragraph{Inference under tractable likelihood assumption}\n\nLet us first proceed as if the likelihood was tractable. We derive a sampler for $\\btheta$ and note which component cannot be evaluated because of dependence on the intractable likelihood \\eqref{eq:likelihood}. \\autoref{sec:particle-filter-estimate} then describes the necessary modifications to allow circumventing the likelihood evaluation.\n\nOften, the interest is not directly in the posterior $p(\\btheta \\mid \\by_{1:T})$ itself, but in the expectation of some function $\\phi$ w.r.t. this distribution, i.e., in\n\\begin{equation} \\label{eq:posterior-integral}\n\\E_{p(\\cdot \\mid \\by_{1:T})}[\\phi(\\btheta)] = \\int \\phi(\\btheta) p(\\btheta \\mid \\by_{1:T}) \\; \\dx{\\btheta}.\n\\end{equation}\nWe construct a Metropolis-Hastings sampler \\citep{metropolis, hastings} with target distribution $p(\\btheta \\mid \\by_{1:T})$. This gives us $M$ samples approximately distributed according to this target, denoted $\\btheta^{(m)},\\ m = 1, \\ldots, M$. The expectation \\eqref{eq:posterior-integral} is then approximated by the arithmetic mean\n\\begin{equation*}\n\\frac{1}{M} \\sum_{m=1}^M \\phi(\\btheta^{(m)}).\n\\end{equation*}\nAn appealing property of the Metropolis-Hastings algorithm is that such arithmetic mean almost surely converges to \\eqref{eq:posterior-integral} as the number of samples grows \\citep{robert-casella}, i.e.,\n\\begin{equation*}\n\\frac{1}{M} \\sum_{m=1}^M \\phi(\\btheta^{(m)}) \\xrightarrow[M \\to \\infty]{a.s} \\int \\phi(\\btheta) p(\\btheta \\mid \\by_{1:T}) \\; \\dx{\\btheta}.\n\\end{equation*}\n\nFinally, we note that if one is interested in the distribution $p(\\btheta \\mid \\by_{1:T})$ itself, it can be recovered by the empirical distribution\n\\begin{equation*}\n\\widehat{p}(\\btheta \\mid \\by_{1:T}) = \\frac{1}{M} \\sum_{m=1}^M \\delta_{\\btheta^{(m)}}(\\btheta),\n\\end{equation*}\nwhere $\\delta$ denotes the Dirac distribution. This estimate can be additionally smoothed using kernel methods \\citep{kernel-smoothing}.\n\n\n\\paragraph{Metropolis-Hastings algorithm}\nThe Metropolis-Hastings algorithm is described in \\autoref{alg:metropolis-hastings}. Although well-known, it is included for comparison with the variant utilizing the particle filter introduced in \\autoref{alg:marginal-metropolis-hastings}.\n\nThe algorithm constructs a Markov chain on the variable $\\btheta$, whose transition distribution $q$ is called the proposal distribution in this context. Starting from an initial state $\\btheta_0$, candidate states $\\btheta^\\prime$ are iteratively sampled according to $q(\\cdot \\mid \\btheta)$, where $\\btheta$ is the current state of the chain.\n\nIn the next step, the acceptance probability $\\alpha$ is calculated in \\eqref{eq:acceptance-probability}. This probability considers which of the two states $\\btheta$ and $\\btheta^\\prime$ is more probable under the target distribution ${p(\\cdot \\mid \\by_{1:T}) \\propto p(\\by_{1:T} \\mid \\btheta) \\pprior(\\btheta)}$. Additionally, it allows the chain to ``step back'' and not move to the new state $\\btheta^\\prime$ by comparing the probability of the two states under $q$, but in reverse direction. With probability $\\alpha$, the Markov chain then evolves into $\\btheta^\\prime$; otherwise, it remains in the current state.\n\nIt can be shown \\citep{robert-casella} that the distribution $p(\\btheta \\mid \\by_{1:T})$ is the limiting distribution of such Markov chain. This means that with the number of transitions going to infinity, the sampled $\\btheta$ are distributed according to our target distribution $p(\\btheta \\mid \\by_{1:T})$. To approximately reach this limiting distribution, a number of initial samples (called the burn-in period) is often discarded. In addition, one usually wants independent samples from the target distribution, which the samples from a Markov chain are \\emph{not}. In practice, only samples with a given spacing are kept to ensure their approximate independence; this is called thinning.\n\nSimilarly to the prior $\\pprior$, setting the proposal $q$ is problem-dependent, and both distributions must be selected carefully. Diagnosing converge of the sampler is a notably difficult task, and one usually resorts to graphical tools to determine whether the sampled values have stabilized \\citep{mcmc}. Some of such plots are given in \\autoref{chap:applications}.\n\n\\begin{algorithm}[ht]\n    \\caption{Metropolis-Hastings}\n    \\label{alg:metropolis-hastings}\n    \\begin{algorithmic}[1]\n        \\Input $\\text{Number of samples } M,\\ \\left\\{\\by_1, \\ldots, \\by_T\\right\\}.$\n        \n        \\State $\\text{Initialize } \\btheta^{(0)}.$\n        \n        \\For{$m = 1\\ \\mathbf{to}\\ M$}\n            \\State $\\text{Sample } \\btheta^\\prime \\sim \\prop(\\cdot \\mid \\btheta^{(m-1)}).$\n            \\State $\\text{Calculate the aceptance probability } $ \\begin{equation} \\label{eq:acceptance-probability}\n            \\alpha = \\min \\left\\{1, \\frac{p(\\by_{1:T} \\mid \\btheta^\\prime) \\pprior(\\btheta^\\prime)}{p(\\by_{1:T} \\mid \\btheta^{(m-1)}) \\pprior(\\btheta^{(m-1)})} \\frac{\\prop(\\btheta^{(m-1)} \\mid \\btheta^\\prime)}{\\prop(\\btheta^\\prime \\mid \\btheta^{(m-1)})} \\right\\}.\n            \\end{equation}\n            \\State $\\text{Sample } u \\sim \\mathcal{U}(0,1).$\n            \\If {$u \\leq \\alpha$}\n                \\State $\\btheta^{(m)} \\gets \\btheta^\\prime$ \\Comment{With probability $\\alpha$, accept the proposed sample.}\n            \\Else\n                \\State $\\btheta^{(m)} \\gets \\btheta^{(m-1)}$ \\Comment{With probability $1 - \\alpha$, reject the proposed sample.}\n            \\EndIf\n        \\EndFor\n        \n        \\Output $\\left\\{ \\btheta^{(1)}, \\ldots, \\btheta^{(M)} \\right\\}$\n    \\end{algorithmic}\n\\end{algorithm}\n\nWe see from \\autoref{alg:metropolis-hastings} that the acceptance probability \\eqref{eq:acceptance-probability} cannot be calculated, as it depends on the intractable likelihood $p(\\by_{1:T} \\mid \\btheta)$. In \\autoref{sec:particle-filter-estimate}, we give a modified variant of the Metropolis-Hastings algorithm, where the likelihood is approximated using the particle filter. The derivation of this filter is the content of the next section.\n\n\n\n\\section{The particle filter} \\label{sec:particle-filter}\nThe particle filter \\citep{particle-filter} is a method for approximating the filtering distribution $p(\\bx_t \\mid \\by_{1:t}, \\btheta)$ using a finite number of samples called particles. The algorithm is also known as sequential Monte Carlo or sequential importance sampling. The latter name sheds some light on how the method works, and it is exactly through importance sampling that the particle filter is derived.\n\n\\paragraph{Importance sampling}\nHere we briefly review the basic idea behind importance sampling. For a more thorough treatment, the reader is referred to \\cite{information-theory} or \\cite{robert-casella}.\n\nConsider a situation where the expectation of some function $\\phi$ w.r.t. the distribution with density $p(\\bm{x})$,\n\\begin{equation} \\label{eq:is-expectation}\n\\Phi \\coloneqq \\E_{p}[\\phi(\\bm{X})] = \\int \\phi(\\bm{x}) p(\\bm{x}) \\; \\dx{\\bm{x}},\n\\end{equation}\nis of interest. Assume that the integral is analytically intractable and that one cannot generate samples from $p(\\bm{x})$ to approximate this expectation. Assume further that the density $p(\\bm{x})$ can be evaluated, at least up to a multiplicative constant, i.e., that it takes the form\n\\begin{equation*}\np(\\bm{x}) = \\frac{p^*(\\bm{x})}{Z},\n\\end{equation*}\nwhere $Z$ is an unknown normalizing constant, and $p^*(\\bm{x})$ can be evaluated. Such situation frequently arises in Bayesian statistics, where a posterior distribution of interest\n\\begin{equation*}\n{p(\\btheta \\mid \\bm{x}) = \\frac{p(\\bm{x} \\mid \\btheta) p(\\btheta)}{\\int p(\\bm{x} \\mid \\btheta) p(\\btheta) \\; \\dx{\\btheta}}}\n\\end{equation*}\nis given in terms of the Bayes theorem. The normalizing constant in the denominator is often unavailable in analytic form. However, the numerator can be evaluated.\n\nNext, we introduce a (typically simpler) distribution with density $q(\\bm{x}) = \\frac{q^*(\\bm{x})}{Z_Q}$ s.t.\n\\begin{enumerate}\n    \\item One can sample from $q$;\n    \\item One can evaluate $q^*$;\n    \\item $p(\\bm{x}) > 0$ implies $q(\\bm{x}) > 0$.\n\\end{enumerate}\nThe expectation \\eqref{eq:is-expectation} can then be written as\n\\begin{equation*}\n\\Phi = \\int \\phi(\\bm{x}) \\frac{q(\\bm{x})}{q(\\bm{x})} p(\\bm{x}) \\; \\dx{\\bm{x}} = \\int \\phi(\\bm{x}) \\underbrace{\\frac{p(\\bm{x})}{q(\\bm{x})}}_{w^*(\\bm{x})} q(\\bm{x}) \\; \\dx{\\bm{x}} = \\E_{q}[\\phi(\\bm{X}) w^*(\\bm{X})],\n\\end{equation*}\nwhere $w^*(\\bm{x})$ are called the importance weights. By defining $w(\\bm{x}) = \\frac{p^*(\\bm{x})}{q^*(\\bm{x})}$, $\\Phi$ can be approximated by\n\\begin{equation*}\n\\Phi \\approx \\widehat{\\Phi} \\coloneqq \\frac{\\sum_{i=1}^N \\phi(\\bm{x}^{(i)}) w(\\bm{x}^{(i)})}{\\sum_{i=1}^Nw(\\bm{x}^{(i)})}, \\quad \\bm{x}^{(1)}, \\ldots, \\bm{x}^{(N)} \\stackrel{iid}{\\sim} q(\\bm{x}).\n\\end{equation*}\nWe note that by using $w$ instead of $w^*$ and normalizing by the weights sum instead of the sample size $N$, we bypass the evaluation of $Z$ and $Z_Q$, since they cancel out. The importance weights here account for correcting the discrepancy between the distribution $q(\\bm{x})$ and the true distribution $p(\\bm{x})$.\n\nThe estimator $\\widehat{\\Phi}$ converges to the true expectation $\\Phi$ as $N \\to \\infty$. However, it is not necessarily unbiased \\citep{information-theory}.\n\n\n\\paragraph{Sequential importance sampling (SIS)}\nThe SIS algorithm uses a set of weighted particles $\\left\\{\\left(\\bm{x}_t^{(i)}, w_t^{(i)} \\right) : i = 1, \\ldots, N \\right\\}$ to represent the filtering distribution $p(\\bm{x}_t \\mid \\by_{1:t}, \\btheta)$. To simplify notation, we write $w_t^{(i)}$ instead of $w_t(\\bm{x}^{(i)})$ from now on. The empirical approximation to ${p(\\bm{x}_t \\mid \\by_{1:t}, \\btheta)}$ is then\n\\begin{equation*}\n\\widehat{p}(\\bm{x}_t \\mid \\by_{1:t}, \\btheta) = \\frac{\\sum_{i=1}^N w_t^{(i)} \\delta_{\\bm{x}_t^{(i)}}(\\bm{x}_t)}{\\sum_{i=1}^N w_t^{(i)}}.\n\\end{equation*}\n\nAs the name suggests, the algorithm involves a sequential application of the importance sampling procedure with increasing time $t$.\n\nReturning to the SSM \\eqref{sec:ssm-definition}, we consider the posterior distribution of a sequence of states $\\bx_{0:t}$ given a sequence of observations $\\by_{1:t}$. By application of the Bayes theorem, we obtain the following recursive formula:\n\\begin{equation*}\n\\begin{split}\np(\\bx_{0:t} \\mid \\by_{1:t}) & \\propto p(\\by_t \\mid \\bx_{0:t}, \\by_{1:t-1}) p(\\bx_{0:t} \\mid \\by_{1:t-1}) \\\\\n&= \\obs_t(\\by_t \\mid \\bx_t) p(\\bx_t \\mid \\bx_{0:t-1}, \\by_{1:t-1}) p(\\bx_{0:t-1} \\mid \\by_{1:t-1}) \\\\\n&= \\obs_t(\\by_t \\mid \\bx_t) \\trans_t(\\bx_t \\mid \\bx_{t-1}) p(\\bx_{0:t-1} \\mid \\by_{1:t-1}),\n\\end{split}\n\\end{equation*}\nwhere the equalities follow from the hidden Markov model independence assumptions. For clarity, we suppress the static parameter $\\btheta$ from the conditioning.\n\nFor the target $p(\\bx_{0:t} \\mid \\by_{1:t})$, we introduce an importance sampling distribution ${q(\\bx_{0:t} \\mid \\by_{1:t})}$ and sample $\\bx_{0:t}^{(i)}$ from it. The importance weights are (up to normalization) given by\n\\begin{equation} \\label{eq:weight-recursion1}\n\\begin{split}\nw_t^{(i)} & \\propto \\frac{p(\\bx_{0:t}{(i)} \\mid \\by_{1:t})}{q(\\bx_{0:t}^{(i)} \\mid \\by_{1:t})} \\\\\n& \\propto \\frac{\\obs_t(\\by_t \\mid \\bx_t^{(i)}) \\trans_t(\\bx_t^{(i)} \\mid \\bx_{t-1}^{(i)}) p(\\bx_{0:t-1}^{(i)} \\mid \\by_{1:t-1})}{q(\\bx_{0:t}^{(i)} \\mid \\by_{1:t})}.\n\\end{split}\n\\end{equation}\nBy definition of the conditional probability and the hidden Markov model assumptions, we can write the importance sampling distribution as\n\\begin{equation*}\nq(\\bx_{0:t} \\mid \\by_{1:t}) = q(\\bx_t \\mid \\bx_{0:t-1}, \\by_{1:t}) q(\\bx_{0:t-1} \\mid \\by_{1:t-1}).\n\\end{equation*}\nBy substituting into \\eqref{eq:weight-recursion1}, we obtain the following recursion:\n\\begin{equation} \\label{eq:weight-recursion2}\n\\begin{split}\nw_t^{(i)} & \\propto \\frac{\\obs_t(\\by_t \\mid \\bx_t^{(i)}) \\trans_t(\\bx_t^{(i)} \\mid \\bx_{t-1}^{(i)})}{q(\\bx_t^{(i)} \\mid \\bx_{0:t-1}^{(i)}, \\by_{1:t})} \\frac{p(\\bx_{0:t-1}^{(i)} \\mid \\by_{1:t-1})}{q(\\bx_{0:t-1}^{(i)} \\mid \\by_{1:t-1})} \\\\\n& \\propto \\frac{\\obs_t(\\by_t \\mid \\bx_t^{(i)}) \\trans_t(\\bx_t^{(i)} \\mid \\bx_{t-1}^{(i)})}{q(\\bx_t^{(i)} \\mid \\bx_{0:t-1}^{(i)}, \\by_{1:t})} w_{t-1}^{(i)}.\n\\end{split}\n\\end{equation}\nEvidently, updating the $i$th weight when transitioning from time $t-1$ to $t$ is a relatively simple task involving only multiplication by the first fraction in \\eqref{eq:weight-recursion2}.\n\nThe sequential importance sampling algorithm is summarized in \\autoref{alg:sis}. This is almost the particle filter; there are still two issues to be addressed, though. First, the problem of weight degeneracy discussed in the next paragraph. Second, the choice of the importance sampling distribution $q(\\bm{x})$ addressed later.\n\\begin{algorithm}[ht]\n    \\caption{Sequential Importance Sampling}\n    \\label{alg:sis}\n    \\begin{algorithmic}[1]\n        \\Input $\\text{Number of particles } N,\\ \\text{current parameter value } \\btheta,\\ \\left\\{\\by_1, \\ldots, \\by_T\\right\\}.$\n        \n        \\State $\\text{Sample } \\bx_0^{(i)} \\sim \\sprior(\\cdot \\mid \\btheta), \\quad i = 1, \\ldots, N.$ \\Comment{Initialize $N$ particles.}\n        \n        \\State $w_0^{(i)} \\gets \\frac{1}{N}, \\quad i = 1, \\ldots, N.$ \\Comment{Initialize uniform weights.}\n        \n        \\For{$t = 1\\ \\mathbf{to}\\ T$}\n            \\State $\\text{Sample } \\bx_t^{(i)} \\sim q(\\cdot \\mid \\bx_{0:t-1}^{(i)}, \\by_{1:t}, \\btheta), \\quad i = 1, \\ldots, N.$ \\Comment{Sample $N$ new particles.}\n            \\State $\\text{Set } w_t^{(i)} \\propto \\frac{\\obs_t(\\by_t \\mid \\bx_t^{(i)}, \\btheta) \\trans_t(\\bx_t^{(i)} \\mid \\bx_{t-1}^{(i)}, \\btheta)}{q(\\bx_t^{(i)} \\mid \\bx_{0:t-1}^{(i)}, \\by_{1:t}, \\btheta)} w_{t-1}^{(i)}, \\quad i = 1, \\ldots, N.$ \\Comment{Update the weights as per \\eqref{eq:weight-recursion2}.}\n        \\EndFor\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\\paragraph{Resampling}\nA serious problem preventing the use of the SIS algorithm is that the weights degenerate over time. At each time step, the variance of the weights reduces \\citep{particle-filter}. This means that the (normalized) weights always converge to a situation where a single weight is 1 and the others are 0.\n\nTo alleviate this, the following resampling step is introduced.\n\\begin{algorithm}[ht]\n    \\caption{Multinomial resampling}\n    \\label{alg:resampling}\n    \\begin{algorithmic}[1]\n        \\Input $\\text{Importance weights } w_t^{(1)}, \\ldots, w_t^{(N)},\\ \\text{particles } \\bx_t^{(1)}, \\ldots, \\bx_t^{(N)}.$\n        \n        \\State $\\widetilde{w}_t^{(i)} \\gets \\frac{w_t^{(i)}}{\\sum_{j=1}^N w_t^{(j)}}, \\quad i = 1, \\ldots, N.$ \\Comment{Normalize weights.}\n        \n        \\State $\\text{Sample } a_i \\text{ s.t. } \\mathbb{P}(a_i = j) = \\widetilde{w}_t^{(j)}, \\quad i,j = 1, \\ldots, N.$ \\Comment{Sample indices with replacement.}\n        \n        \\State $w_t^{(a_i)} \\gets \\frac{1}{N}, \\quad i = 1, \\ldots, N.$ \\Comment{Reset weights.}\n        \n        \\Output $\\text{Resampled particles } \\bx_t^{(a_1)}, \\ldots, \\bx_t^{(a_N)} \\text{ and weights } w_t^{(a_1)}, \\ldots, w_t^{(a_N)}.$\n    \\end{algorithmic}\n\\end{algorithm}\n\nThe normalized importance weights are interpreted as a probability vector of a categorical distribution. The particles are then resampled (sampled with replacement) according to this distribution. This effectively selects a population of ``strong individuals'' for the next time step.\n\n\\autoref{alg:resampling} is known as multinomial resampling. There are other, more sophisticated, approaches, such as stratified resampling \\citep{resampling}, which come at the cost of increased complexity.\n\n\\paragraph{The particle filter}\nThe remaining step is the choice of the importance sampling distribution $q(\\bx_t \\mid \\bx_{0:t-1}, \\by_{1:t}, \\btheta)$. Obviously, the more similar this distribution is to the target $p(\\bx_{0:t} \\mid \\by_{1:t}, \\btheta)$, the closer approximation we obtain.\n\nThe particle filter arises when the transition distribution $\\trans_t(\\bx_t \\mid \\bx_{t-1}, \\btheta)$ is chosen as the importance distribution, that is, when\n\\begin{equation*}\nq(\\bx_t \\mid \\bx_{0:t-1}, \\by_{1:t}, \\btheta) = \\trans_t(\\bx_t \\mid \\bx_{t-1}, \\btheta).\n\\end{equation*}\nThe importance weights \\eqref{eq:weight-recursion2} then simplify into\n\\begin{equation} \\label{eq:weight-recursion3}\nw_t^{(i)} \\propto \\obs_t(\\by_t \\mid \\bx_t^{(i)}) w_{t-1}^{(i)}.\n\\end{equation}\nThe particle filter is summarized in \\autoref{alg:particle-filter}. The algorithm is called \\emph{bootstrap} particle filter, due to resemblance of the resampling step to the non-parametric bootstrap \\citep{bootstrap}. By being defined in terms of importance sampling, the algorithm inherits the appealing asymptotic properties.\n\\begin{algorithm}[ht]\n    \\caption{Bootstrap particle filter}\n    \\label{alg:particle-filter}\n    \\begin{algorithmic}[1]\n        \\Input $\\text{Number of particles } N,\\ \\text{current parameter value } \\btheta,\\ \\left\\{\\by_1, \\ldots, \\by_T\\right\\}.$\n        \n        \\State $\\text{Sample } \\bx_0^{(i)} \\sim \\sprior(\\cdot \\mid \\btheta), \\quad i = 1, \\ldots, N.$ \\Comment{Initialize $N$ particles.}\n        \n        \\State $w_0^{(i)} \\gets \\frac{1}{N}, \\quad i = 1, \\ldots, N.$ \\Comment{Initialize uniform weights.}\n        \n        \\For{$t = 1\\ \\mathbf{to}\\ T$}\n        \\State $\\text{Sample } \\bx_t^{(i)} \\sim \\trans_t(\\bx_t \\mid \\bx_{t-1}^{(i)}, \\btheta), \\quad i = 1, \\ldots, N.$ \\Comment{Sample $N$ new particles.}\n        \n        \\State $\\text{Set } w_t^{(i)} \\propto \\obs_t(\\by_t \\mid \\bx_t^{(i)}, \\btheta) w_{t-1}^{(i)}, \\quad i = 1, \\ldots, N.$ \\Comment{Update the weights as per \\eqref{eq:weight-recursion3}.}\n        \n        \\State $\\text{Resample } \\bx_t^{(i)} \\text{ and reset } w_t^{(i)} \\text{ using \\autoref{alg:resampling}}, \\quad i = 1, \\ldots, N.$\n        \\EndFor\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\n\\section{Using the particle filter to estimate the likelihood} \\label{sec:particle-filter-estimate}\n\nAs mentioned in \\autoref{sec:particle-filter}, the particle filter is typically used to approximate the filtering distribution $p(\\bx_t \\mid \\by_{1:t}, \\btheta)$. This will be utilized to provide a tractable approximation to the likelihood $p(\\by_{1:T} \\mid \\btheta)$ such that the limiting distribution of the Metropolis-Hastings Markov chain remains unaffected. This section describes how it is done and gives the resulting variant of the sampler\n\n\\paragraph{Likelihood estimate in general}\nSuppose that we are in possession of an estimator $\\widehat{\\aux}$ of the likelihood $p(\\by_{1:T} \\mid \\btheta)$. As such, it necessarily depends on $\\by_{1:T}$ and $\\btheta$. Since we aim to use the particle filter to calculate $\\widehat{\\aux}$, the estimator also depends on the importance weights calculated using random samples $\\bx_t^{(i)}$. This makes the estimator a random variable with some distribution denoted $\\psi(\\aux \\mid \\btheta, \\by_{1:T})$. It is not necessary to have this distribution available, as it is later shown to cancel out in the Metropolis-Hastings acceptance ratio.\n\nWe now return to our model \\eqref{eq:posterior} and introduce $\\widehat{\\aux}$ as an auxiliary variable, along with our variable of interest $\\btheta$. This changes the target distribution from $p(\\btheta \\mid \\by_{1:T})$ to\n\\begin{equation} \\label{eq:psi-joint}\n\\psi(\\btheta, \\aux \\mid \\by_{1:T}) = p(\\btheta \\mid \\by_{1:T}) \\psi(\\aux \\mid \\btheta, \\by_{1:T}) = \\frac{p(\\by_{1:T} \\mid \\btheta) \\pprior(\\btheta)}{p(\\by_{1:T})} \\psi(\\aux \\mid \\btheta, \\by_{1:T}).\n\\end{equation}\nIn theory, we could now construct a Metropolis-Hastings algorithm with $\\psi(\\btheta, \\aux \\mid \\by_{1:T})$ as the target, instead of $p(\\btheta \\mid \\by_{1:T})$ as was the case in \\autoref{alg:metropolis-hastings}. However, this would not solve our problem, since calculating the acceptance ratio still requires the calculation of the likelihood $p(\\by_{1:T} \\mid \\btheta)$, as \\eqref{eq:psi-joint} makes clear.\n\nInstead, we define a new target distribution over $(\\btheta, \\widehat{\\aux})$ by replacing the likelihood in \\eqref{eq:psi-joint} by its estimate $\\widehat{\\aux}$:\n\\begin{equation} \\label{eq:aux-joint}\n\\auxjoint(\\btheta, \\aux \\mid \\by_{1:T}) \\coloneqq \\frac{\\aux \\pprior(\\btheta)}{p(\\by_{1:T})} \\psi(\\aux \\mid \\btheta, \\by_{1:T}).\n\\end{equation}\nThere are of course some conditions imposed on $\\auxjoint(\\btheta, \\aux \\mid \\by_{1:T})$ for it to be useful:\n\\begin{enumerate}\n    \\item $\\auxjoint(\\btheta, \\aux \\mid \\by_{1:T})$ must be non-negative for all $(\\btheta, \\aux)$;\n    \\item $\\auxjoint(\\btheta, \\aux \\mid \\by_{1:T})$ must integrate to 1;\n    \\item the marginal distribution of $\\auxjoint(\\btheta, \\aux \\mid \\by_{1:T})$ for $\\btheta$ must be the original target $p(\\btheta \\mid \\by_{1:T})$.\n\\end{enumerate}\nThe first two conditions simply state that $\\auxjoint$ is a valid probability distribution. The third condition ensures that by constructing a Metropolis-Hastings algorithm with $\\auxjoint$ as the target, the original target distribution is preserved once the auxiliary variables are marginalised out. All three conditions are satisfied if $\\widehat{\\aux}$ is a non-negative unbiased estimator of the likelihood $p(\\by_{1:T} \\mid \\btheta)$. This is shown as follows.\n\n\\begin{enumerate}[align=left]\n    \\item Non-negativity of $\\auxjoint$ follows from the assumed non-negativity of the estimator $\\widehat{\\aux}$ and validity of the distributions in \\eqref{eq:aux-joint}.\n    \\item[2, 3.] Assume that $\\widehat{\\aux}$ is an unbiased estimate of $p(\\by_{1:T} \\mid \\btheta)$, i.e., that $\\E_{\\psi}[\\widehat{\\aux}] = p(\\by_{1:T} \\mid \\btheta)$. Consider now the marginal of $\\auxjoint$ for $\\btheta$:\n    \\begin{equation} \\label{eq:marginal}\n    \\begin{split}\n    \\int \\auxjoint(\\btheta, \\aux \\mid \\by_{1:T})\\; \\dx{\\aux} & = \\frac{\\pprior(\\btheta)}{p(\\by_{1:T})} \\int \\aux \\psi(\\aux \\mid \\btheta, \\by_{1:T}) \\; \\dx{\\aux} \\\\\n    & = \\frac{\\pprior(\\btheta)}{p(\\by_{1:T})} \\E_{\\psi}[\\widehat{\\aux}] \\\\\n    & = \\frac{\\pprior(\\btheta)}{p(\\by_{1:T})} p(\\by_{1:T} \\mid \\btheta) \\\\\n    & = p(\\btheta \\mid \\by_{1:T}),\n    \\end{split}\n    \\end{equation}\n    the original target distribution. This satisfies condition 3. For condition 2, we simply integrate \\eqref{eq:marginal} w.r.t. $\\btheta$, which results in unity due to $p(\\btheta \\mid \\by_{1:T})$ being a valid probability distribution.\n\\end{enumerate}\n\n\\paragraph{Acceptance ratio computation}\nGiven the new target distribution $\\auxjoint$, we can now construct a Metropolis-Hastings algorithm on the joint space of $(\\btheta, \\aux)$.\n\nThis means that the proposed samples are now given as $(\\btheta^\\prime, \\aux^\\prime) \\sim \\psi(\\cdot, \\cdot \\mid \\by_{1:T})$. In practice, this is done by first sampling $\\btheta^\\prime \\sim q(\\cdot \\mid \\btheta^{(m-1)})$, and then $\\widehat{\\aux}^\\prime \\sim \\psi(\\cdot \\mid \\btheta^\\prime, \\by_{1:T})$. The acceptance ratio can now be computed as\n\\begin{equation*}\n\\begin{split}\n\\alpha & = \\min \\left\\{1, \\frac{\\auxjoint(\\btheta^\\prime, \\aux^\\prime \\mid \\by_{1:T})}{\\auxjoint(\\btheta^{(m-1)}, \\aux^{(m-1)} \\mid \\by_{1:T})} \\frac{\\prop(\\btheta^{(m-1)} \\mid \\btheta^\\prime) \\psi(\\aux^{(m-1)} \\mid \\btheta^{(m-1)}, \\by_{1:T})}{\\prop(\\btheta^\\prime \\mid \\btheta^{(m-1)}) \\psi(\\aux^\\prime \\mid \\btheta^\\prime, \\by_{1:T})} \\right\\} \\\\\n& = \\min \\left\\{1, \\frac{\\aux^\\prime \\pprior(\\btheta^\\prime) \\psi(\\aux^\\prime \\mid \\btheta^\\prime, \\by_{1:T})}{\\aux^{(m-1)} \\pprior(\\btheta^{(m-1)}) \\psi(\\aux^{(m-1)} \\mid \\btheta^{(m-1)}, \\by_{1:T})} \\frac{\\prop(\\btheta^{(m-1)} \\mid \\btheta^\\prime) \\psi(\\aux^{(m-1)} \\mid \\btheta^{(m-1)}, \\by_{1:T})}{\\prop(\\btheta^\\prime \\mid \\btheta^{(m-1)}) \\psi(\\aux^\\prime \\mid \\btheta^\\prime, \\by_{1:T})} \\right\\} \\\\\n& = \\min \\left\\{1, \\frac{\\aux^\\prime \\pprior(\\btheta^\\prime)}{\\aux^{(m-1)} \\pprior(\\btheta^{(m-1)})} \\frac{q(\\btheta^{(m-1)} \\mid \\btheta^\\prime)}{q(\\btheta^\\prime \\mid \\btheta^{(m-1)})} \\right\\}.\n\\end{split}\n\\end{equation*}\n\nSince \\eqref{eq:marginal} shows that the marginal of $\\auxjoint$ for $\\btheta$ is the original target $p(\\btheta \\mid \\by_{1:T})$, all we need to do is to discard the sampled $\\widehat{\\aux}^{(m)}$ and keep only $\\btheta^{(m)}$ when running Metropolis-Hastings on the joint space of $(\\btheta, \\aux)$.\n\n\\paragraph{Calculating the estimate using the particle filter}\nFinally, we describe how exactly is the particle filter used as an estimator of $p(\\by_{1:T} \\mid \\btheta)$.\n\nFirst, we decompose the likelihood into a product of simpler distributions, which are then marginalised over the corresponding hidden state:\n\\begin{equation} \\label{eq:likelihood-factorization}\n\\begin{split}\np(\\by_{1:T} \\mid \\btheta) &= \\prod_{t=1}^T p(\\by_t \\mid \\by_{1:t-1}, \\btheta) \\\\\n&= \\prod_{t=1}^T \\int p(\\by_t, \\bx_t \\mid \\by_{1:t-1}, \\btheta) \\; \\dx{\\bx_t} \\\\\n&= \\prod_{t=1}^T \\int p(\\by_t \\mid \\bx_t, \\btheta) p(\\bx_t \\mid \\by_{1:t-1}, \\btheta) \\; \\dx{\\bx_t}.\n\\end{split}\n\\end{equation}\n\nUsing the particles $\\left\\{\\bx_t^{(i)}\\right\\}_{i=1}^N$, we plug in the empirical approximation to $p(\\bx_t \\mid \\by_{1:t-1}, \\btheta)$, $\\widehat{p}(\\bx_t \\mid \\by_{1:t-1}, \\btheta) = \\frac{1}{N} \\sum_{i=1}^N \\delta_{\\bm{x}_t^{(i)}}(\\bx_t)$, into \\eqref{eq:likelihood-factorization}, obtaining\n\\begin{equation*}\n\\begin{split}\np(\\by_{1:T} \\mid \\btheta) & \\approx \\prod_{t=1}^T \\int p(\\by_t \\mid \\bx_t, \\btheta) \\left[ \\frac{1}{N} \\sum_{i=1}^N \\delta_{\\bm{x}_t^{(i)}}(\\bx_t) \\right] \\; \\dx{\\bx_t} \\\\\n& = \\prod_{t=1}^T \\frac{1}{N} \\sum_{i=1}^N \\int p(\\by_t \\mid \\bx_t, \\btheta) \\delta_{\\bm{x}_t^{(i)}}(\\bx_t) \\; \\dx{\\bx_t} \\\\\n& = \\prod_{t=1}^T \\frac{1}{N} \\sum_{i=1}^N p(\\by_t \\mid \\bx_t^{(i)}, \\btheta)\n\\end{split}\n\\end{equation*}\ndue to linearity of the integral and properties of the Dirac distribution.\n\nIn $p(\\by_t \\mid \\bx_t^{(i)}, \\btheta)$, we recognize the particle filter weights $w_t^{(i)}$ defined in \\eqref{eq:weight-recursion3}. This allows us to finally define the likelihood estimate as\n\\begin{equation} \\label{eq:likelihood-estimate}\n\\widehat{\\aux} \\coloneqq \\prod_{t=1}^T \\frac{1}{N} \\sum_{i=1}^N w_t^{(i)}.\n\\end{equation}\nThis estimator is obviously non-negative due to construction of the weights. The proof that it is also unbiased (and therefore also integrates to unity) is more involved and the reader is referred to \\cite{del-moral} for the original proof.\n\nFinally, we describe the resulting variant of the Metropolis-Hastings algorithm employing the likelihood estimate \\eqref{eq:likelihood-estimate}. This algorithm, called marginal Metropolis-Hastings, was introduced by \\cite{andrieu}. Compared to \\autoref{alg:metropolis-hastings}, all components of this algorithm can be evaluated. Due to construction of the estimator $\\widehat{\\aux}$, the marginal of the limiting distribution of \\autoref{alg:marginal-metropolis-hastings} is the original target $p(\\btheta \\mid \\by_{1:T})$.\n\n\\begin{algorithm}[ht]\n    \\caption{Marginal Metropolis-Hastings}\n    \\label{alg:marginal-metropolis-hastings}\n    \\begin{algorithmic}[1]\n        \\Input $\\text{Number of samples } M,\\ \\left\\{\\by_1, \\ldots, \\by_T\\right\\}.$\n        \n        \\State $\\text{Initialize } \\btheta^{(0)}.$\n        \\State $\\text{Run \\autoref{alg:particle-filter} with } \\btheta^{(0)} \\text{ to obtain the weights } w_{0,t}^{(i)}, \\quad t = 1, \\ldots, T,\\ i = 1, \\ldots, N.$\n        \\State $\\text{Calculate } \\widehat{\\aux}^{(0)} \\text{ according to \\eqref{eq:likelihood-estimate} using } w_{0,t}^{(i)}.$\n        \n        \\For{$m = 1\\ \\mathbf{to}\\ M$}\n        \\State $\\text{Sample } \\btheta^\\prime \\sim \\prop(\\cdot \\mid \\btheta^{(m-1)}).$\n        \\State $\\text{Run \\autoref{alg:particle-filter} with } \\btheta^\\prime \\text{ to obtain the weights } w_{m,t}^{(i)}, \\quad t = 1, \\ldots, T, \\ i = 1, \\ldots, N.$\n        \\State $\\text{Calculate } \\widehat{\\aux}^\\prime \\text{ according to \\eqref{eq:likelihood-estimate} using } w_{m,t}^{(i)}.$\n        \\State $\\text{Calculate the aceptance probability } $ \\begin{equation*} \\label{eq:acceptance-probability-tractable}\n        \\alpha = \\min \\left\\{1, \\frac{\\widehat{\\aux}^\\prime \\pprior(\\btheta^\\prime)}{\\widehat{\\aux}^{(m-1)} \\pprior(\\btheta^{(m-1)})} \\frac{\\prop(\\btheta^{(m-1)} \\mid \\btheta^\\prime)}{\\prop(\\btheta^\\prime \\mid \\btheta^{(m-1)})} \\right\\}.\n        \\end{equation*}\n        \\State $\\text{Sample } u \\sim \\mathcal{U}(0,1).$\n        \\If {$u \\leq \\alpha$}\n        \\State $\\left( \\btheta^{(m)}, \\widehat{\\aux}^{(m)} \\right) \\gets \\left( \\btheta^\\prime, \\widehat{\\aux}^\\prime \\right)$ \\Comment{With probability $\\alpha$, accept the proposed sample.}\n        \\Else\n        \\State $\\left( \\btheta^{(m)}, \\widehat{\\aux}^{(m)} \\right) \\gets \\left( \\btheta^{(m-1)}, \\widehat{\\aux}^{(m-1)} \\right)$ \\Comment{With probability $1 - \\alpha$, reject the proposed sample.}\n        \\EndIf\n        \\EndFor\n        \n        \\Output $\\left\\{ \\btheta^{(1)}, \\ldots, \\btheta^{(M)} \\right\\}$\n    \\end{algorithmic}\n\\end{algorithm}", "meta": {"hexsha": "89f3bf129b40666f34f11c07af0438a4c44f66f6", "size": 35535, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/chapters/inference.tex", "max_stars_repo_name": "tomaskala/master-thesis", "max_stars_repo_head_hexsha": "746dfd0c0747f4e0a206fe0f975363ca29f52226", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-10-19T10:52:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-20T19:13:34.000Z", "max_issues_repo_path": "thesis/tex/chapters/inference.tex", "max_issues_repo_name": "tomaskala/master-thesis", "max_issues_repo_head_hexsha": "746dfd0c0747f4e0a206fe0f975363ca29f52226", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/chapters/inference.tex", "max_forks_repo_name": "tomaskala/master-thesis", "max_forks_repo_head_hexsha": "746dfd0c0747f4e0a206fe0f975363ca29f52226", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 80.9453302961, "max_line_length": 694, "alphanum_fraction": 0.6778387505, "num_tokens": 11520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4449897440346918}}
{"text": "\\section*{Linear programming and optimization - Peter Christensen}\n\n\\begin{enumerate}\n\t\\item Define LP probem with example.\n\t\\item Set example to standard form\n\t\\item Convert the LP problem to one including slack variables\n\t\\item Use simple method on example\n\t\\item Define duality and prove Thm 29.10.\n\\end{enumerate}", "meta": {"hexsha": "f9c1706384bd552452e34a7de6cbccc44032b8ca", "size": 317, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Uge2/PeterDisp-LPAndOptimization.tex", "max_stars_repo_name": "pdebesc/AADS", "max_stars_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Uge2/PeterDisp-LPAndOptimization.tex", "max_issues_repo_name": "pdebesc/AADS", "max_issues_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Uge2/PeterDisp-LPAndOptimization.tex", "max_forks_repo_name": "pdebesc/AADS", "max_forks_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2222222222, "max_line_length": 66, "alphanum_fraction": 0.785488959, "num_tokens": 79, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.44498974311804373}}
{"text": "\n\\subsection{Wave structure for two-dimensional problems}\n\n\\begin{frame}\n  \\begin{block}{Spectral analysis of $\\Jbsf$}\n    \\begin{itemize}\n      % \\item acoustic tensor's spectrum $\\rightarrow$ 2 positive eigenvalues $\\omega_p$ and eigenvectors $\\vect{l}^p$\n    \\item 4 non-zero eigenvalues $c_K$ and left eigenvectors $\\Lcb^K$ \n      \\begin{itemize}\n      \\item[] left and right-going slow waves $\\pm c_s$\n      \\item[] left and right-going fast waves $\\pm c_f$\n      \\end{itemize}\n    \\item 1 contact wave $c=0$\n    \\item non-linear waves: $c_K(\\tens{\\sigma})$ %(expressions depending on $\\Cbb^{ep}$)\n    \\item \\textbf{assumption: $c_1 \\geq c_f \\geq c_2 \\geq c_s$ $\\Rightarrow$ simple waves}\n    \\end{itemize}\n  \\end{block}\n\\end{frame}\n\n\n\n\\subsection{Loading paths through simple waves}\n\\begin{frame}\n  \\begin{overprint}\n    \\begin{block}{Method of characteristics \\cite{Courant}}\n      \\begin{equation*}\n        \\Lcb^K \\cdot d\\Qcb = 0 \\quad \\forall \\: K\n      \\end{equation*}\n      $ \\rightarrow$ set of ODEs through the simple waves\n    \\end{block}\n    \\begin{block}{Particular cases $\\vect{n}=\\vect{e}_i$}\n      \\begin{flalign*}\n        & d\\sigma_{11}=\\psi_i (\\tens{\\sigma})\\: d\\sigma_{12}\\\\\n        & d\\sigma_{22}=\\phi_i (\\tens{\\sigma})\\: d\\sigma_{12}\n      \\end{flalign*}\n    \\end{block}\n    \\onslide<2>\n    \\begin{block}{Mathematical study}\n      \\begin{itemize}\n      \\item Orthogonality of \"slow\" and \"fast\" loading paths in stresses space\n      \\item Singular points \n      %\\item Complex functions $\\rightarrow$ numerical investigations\n      \\end{itemize} \n    \\end{block}\n  \\end{overprint}\n  \n  \n  \\footnoteCite{Courant}\n\\end{frame}\n\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../presentation\"\n%%% End:\n", "meta": {"hexsha": "83afaf81e27b55c56fcd1b352f9aad6b65401281", "size": 1730, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "defense/section6/mainSection6.tex", "max_stars_repo_name": "adRenaud/research", "max_stars_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-18T14:52:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-18T14:52:03.000Z", "max_issues_repo_path": "defense/section6/mainSection6.tex", "max_issues_repo_name": "adRenaud/research", "max_issues_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-07T13:11:11.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-07T13:11:11.000Z", "max_forks_repo_path": "defense/section6/mainSection6.tex", "max_forks_repo_name": "adRenaud/research", "max_forks_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.350877193, "max_line_length": 118, "alphanum_fraction": 0.6387283237, "num_tokens": 542, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6334102636778403, "lm_q1q2_score": 0.44498974100637423}}
{"text": "\\chapter{Units Conversion System}\\label{ch:units}\n\n\\section{Introduction}\n\nThe units conversion system as implemented in \\aprepro{} defines\nseveral variables that are abbreviations for unit quantities. For\nexample, if the output format for the current unit system was inches,\nthe variable \\cmd{foot} would have the value \\cmd{12}. Therefore, an\nexpression such as \\cmd{8*foot} would be equal to \\cmd{96} which is the\nnumber of inches in 8 feet\\footnote{This can also be written as 8\\~{}foot since \\~{} has been defined to be the same as $*$ (multiplication).}.\n\nSeven consistent units systems have been defined including four metric\nbased systems: \\cmd{si}, \\cmd{cgs}, \\cmd{cgs-ev}, and \\cmd{shock}; and\nthree english-based systems: \\cmd{in-lbf-s}, \\cmd{ft-lbf-s}, and\n\\cmd{ft-lbm-s}. The output units for these unit systems are shown in\nTable 8 (metric) and Table 9 (english). A list of the defined units\nabbreviations is given in Table 10.\n\nIn addition to the definition of the conversion factors, several\nstring variables are also defined which describe the output format of\nthe current units system.  For example, the string variable \\cmd{dout}\ndefines the output format for density units. For the \\cmd{in-lbf-sec}\nunits system, \\cmd{dout} =\n\\cmd{\\texttt{\"}lbf-sec\\^{}2/in\\^{}4}\\texttt{\"}\nwhich is the output format for densities in this system. The string\nvariables can be used to document the \\aprepro{} output. The\nstring variable names are listed in the last column of Table 8 and Table 9.\n\n\\begin{longtable}{l|lllll}\n\\caption{Units Systems and Corresponding Output Format--Metric} \\\\\n\\hline\nQuantity      &si&  cgs       & cgs-ev     & shock      & string \\\\\n\\hline\nLength        & metre    & centimetre & centimetre & centimetre & lout \\\\\nMass          & kilogram & gram       & gram       & gram       & mout \\\\\nTime          & second   & second     & second     & micro-sec  & tout \\\\\nTemperature   & kelvin   & kelvin     & eV         & kelvin     & Tout \\\\\nVelocity      & metre/sec& cm/sec     & cm/sec     & cm/usec    & vout \\\\\nAcceleration  & metre/sec$^2$ & cm/sec$^2$ & cm/sec$^2$ & cm/usec$^2$ & aout \\\\\nForce         & newton   & dyne       & dyne       & g-cm/usec$^2$ & fout \\\\\nVolume        & metre$^3$ &  cm$^3$ & cm$^3$ & cm$^3$ & Vout \\\\\nDensity       & kg/m$^3$ &  g/cc & g/cc & g/cc & dout \\\\\nEnergy        & joule    & erg & erg & g-cm$^2$/usec$^3$ & eout \\\\\nPower         & watt     & erg/sec & erg/sec & g-cm$^2$/usec$^4$ & Pout \\\\\nPressure      & pascal   & dyne/cm$^2$ & dyne/cm$^2$ & Mbar & pout \\\\\n\\hline\n\\end{longtable}\n\n\n\\begin{longtable}{l|llll}\n\\caption{Units Systems and Corresponding Output Format--English} \\\\\n\\hline\nQuantity & in-lbf-s & ft-lbf-s & ft-lbm-s & string \\\\\n\\hline\nLength       & inch         & foot & foot & lout \\\\\nMass         & lbf-sec$^2$/in & slug & pound-mass & mout \\\\\nTime         & second & second & second & tout \\\\\nTemperature  & rankine & rankine & rankine & Tout \\\\\nVelocity     & inch/sec & foot/sec & foot/sec & vout \\\\\nAcceleration & inch/sec$^2$ & foot/sec$^2$ & foot/sec$^2$ & aout \\\\\nForce        & pound-force & pound-force & poundal & fout \\\\\nVolume       & inch$^3$ & foot$^3$ & foot$^3$ & Vout \\\\\nDensity      & lbf-sec$^2$/in$^4$ & slug/ft$^3$ & lbm/ft$^3$ & dout \\\\\nEnergy       & inch-lbf & foot-lbf & ft-poundal & eout \\\\\nPower        & inch-lbf/sec & foot-lbf/sec & ft-poundal/sec & Pout\\\\\nPressure     & lbf/in$^2$ & lbf/ft$^2$ & poundal/ft$^2$ & pout \\\\\n\\hline\n\\end{longtable}\n\nThe units definitions are accessed through the \\afunc{Units} function in \\aprepro{}:\n\\begin{apinp}\n\\{Units(\"\\var{unit\\_system}\")\\}\n\\end{apinp}\nwhere \\var{unit\\_system} is one of the strings listed in the first row\nof the previous two tables. \n\n\\section{Defined Units Variables}\n\nIn the following table, the first column lists the variables\nthat are defined in the \\aprepro{} unit system and the second column\nis a short description of the unit. All units variables are defined in\nterms of the five SI Base Units metre (length), second (time),\nkilogram (mass), temperature (kelvin), and radian (angle)\\footnote{The\nradian is actually a SI Supplementary Unit since it has not been\ndecided whether it is a Base Unit or a Derived Unit. There are three\nother SI Base Units, the candela, ampere, and mole, but they are not\nyet used in the Aprepro units system.}. The bolded rows\ndelineate the type of unit variable and the base quantities used to\ndefine it where $L$ is length, $T$ is time, $M$ is mass, and $t$ is\ntemperature. For example density is defined in terms of $M/L^3$ which\nis mass/ length$^3$.\n\n\\begin{longtable}{l|l}\n\\caption{Defined Units Variables} \\\\\n\\hline\\hline\n\\multicolumn{2}{c}{\\bf Length \\boldmath{[L]}} \\\\\n\\hline\nm, meter, metre & \\cmd{Metre (base unit)} \\\\\ncm, centimeter, centimetre & {Metre / 100} \\\\\nmm, millimeter, millimetre & {Metre / 1,000} \\\\\num, micrometer, micrometre & {Metre / 1,000,000} \\\\\nkm, kilometer, kilometre & {Metre * 1,000} \\\\\nin, inch & Inch   \\\\\nft, foot & Foot  \\\\\nyd, yard & Yard   \\\\\nmi, mile & Mile   \\\\\nmil & Mil (inch/1000) \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \\multicolumn{2}{c}{\\bf Time \\boldmath{[T]}} \\\\\n\\hline\nsecond, sec & \\cmd{Second (base unit)} \\\\\nusec, microsecond & Second / 1,000,000 \\\\\nmsec, millisecond & Second / 1,000 \\\\\nminute & Minute \\\\\nhr, hour & Hour   \\\\\nday & Day   \\\\\nyr, year & Year = 365.25 days \\\\\ndecade & 10 Years \\\\\ncentury & 100 Years \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Velocity \\boldmath{[L/T]}} \\\\\n\\hline\nmph & Miles per hour \\\\\nkph & Kilometres per hour \\\\\nmps & Metre per second \\\\\nkps & Kilometre per second \\\\\nfps & Foot per second \\\\\nips & Inch per second \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Acceleration \\boldmath{[$L/T^2$]}} \\\\\n\\hline\nga & Gravitational acceleration \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Mass \\boldmath{[$M$]}} \\\\\n\\hline\nkg & \\cmd{Kilogram (base unit)} \\\\\ng, gram & Gram \\\\\nlbm & Pound (mass) \\\\\nslug & Slug \\\\\nlbfs2pin & Lbf-sec$^2$/in \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Density \\boldmath{[$M/L^3]$}} \\\\\n\\hline\ngpcc & Gram / cm$^3$ \\\\\nkgpm3 & Kilogram / m$^3$ \\\\\nlbfs2pin4 & Lbf-sec$^2$ / in$^4$ \\\\\nlbmpin3 & Lbm / in \\\\\nlbmpft3 & Lbm / ft$^3$ \\\\\nslugpft3 & Slug / ft$^3$ \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Force \\boldmath{[$ML/T^2$]}} \\\\\n\\hline\nN, newton & Newton = 1 kg-m/sec$^2$ \\\\\ndyne & Dyne = newton/10,000 \\\\\ngf & Gram (force) \\\\\nkgf & Kilogram (force) \\\\\nlbf & Pound (force) \\\\\nkip & Kilopound (force) \\\\\npdl, poundal & Poundal \\\\\nounce & Ounce = lbf / 16 \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Energy \\cmd{[$ML^2/T^2$]}} \\\\\n\\hline\nJ,   joule & Joule = 1 newton-metre \\\\\nftlbf & Foot-lbf \\\\\nerg & Erg = 1e-7 joule \\\\\ncalorie & International Table Calorie \\\\\nBtu & International Table Btu \\\\\ntherm & EEC therm \\\\\ntonTNT & Energy in 1 ton TNT \\\\\nkwh & Kilowatt hour \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Power \\boldmath{[$ML^2/T^3$]}} \\\\\n\\hline\nW, watt & Watt = 1 joule / second \\\\\nHp & Elec. Horsepower (746 W) \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Temperature \\boldmath{[t]}} \\\\\n\\hline\ndegK, kelvin & \\cmd{Kelvin (Base Unit)} \\\\\ndegC & Degree Celsius \\\\\ndegF & Degree Fahrenheit \\\\\ndegR, rankine & Degree Rankine \\\\\neV & Electron Volt \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Pressure \\boldmath{[$M/L/T^2$]}} \\\\\n\\hline\nPa, pascal & Pascal = 1 newton / metre$^2$ \\\\\nMPa & Megapascal \\\\\nGPa & Gigapascal \\\\\nbar & Bar \\\\\nkbar & Kilobar \\\\\nMbar & Megabar \\\\\natm & Standard atmosphere \\\\\ntorr & Torr = 1 mmHg \\\\\nmHg & Metre of mercury \\\\\nmmHg & Millimetre of mercury \\\\\ninHg & Inch of mercury \\\\\ninH2O & Inch of water \\\\\nftH2O & Foot of water \\\\\npsi & Pound per square inch \\\\\nksi & Kilo-pound per square inch \\\\\npsf & Pound per square foot \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Volume \\boldmath{[L$^3$]}} \\\\\n\\hline\nliter & Metre$^3$ / 1000 \\\\\ngal, gallon & Gallon (U.S.) \\\\\n\\multicolumn{2}{c}{} \\\\\n\\hline \n\\multicolumn{2}{c}{\\bf Angular }  \\\\\n\\hline\nrad & \\cmd{Radian (base unit)} \\\\\nrev & Full circle = 360 degree \\\\\ndeg, degree & Degree \\\\\narcmin & Arc minute = 1/60 degree \\\\\narcsec & Arc second = 1/360 degree \\\\\ngrade & Grade = 0.9 degree \\\\\n\\end{longtable}\nThe conversion expressions were obtained from\nReferences~\\cite{bib:isotopes}, \\cite{bib:jaeger}, \\cite{bib:lambe}, and~\\cite{bib:simpson}.\n\n\\section{Usage}\n\nThe following example illustrates the basic usage of the \\aprepro{} units conversion utility.\n\n\\begin{apinp}\n\\$ Aprepro Units Utility Example \n\\$ \\{ECHO(OFF)\\} \\textit{\\ldots{}Turn off echoing of the conversion factors}\n\\$ \\{Units(``shock'')\\} \\textit{\\ldots{}Select the shock units system}\n\\$  NOTE:  Dimensions  -  \\{lout\\},  \\{mout\\},  \\{dout\\},  \\{pout\\} \n\\textit{\\ldots{}This will document what quantities are used in the file after it is run through Aprepro}\n\\{len1  = 10.0 * inch\\}  \\textit{\\ldots{}Define a length in an english unit (inches)}\n$ \\{len2  = 12.0\\textasciitilde{}inch\\} \\textit{\\ldots{}\\textasciitilde{} is a synonym for * (multiplication)}\nMaterial  1,  Elastic Plastic,  \\{1890\\textasciitilde{}kgpm3\\}  \\$  \\{dout\\}\n   Youngs Modulus = \\{28.3e6\\textasciitilde{}psi\\} \\$ {pout}\n   Yield  Stress  = \\{30\\textasciitilde{}ksi\\}\n   Initial Veclocity = \\{10\\textasciitilde{}mph\\} \\$ {vout}\n   \\textit{\\ldots{}Define the density and material parameters in whatever units they are available}\nEnd\nPoint 100 \\{0.0\\}  \\{0.0\\}\nPoint 110 \\{len1\\} \\{0.0\\}\nPoint 120 \\{len1\\} \\{len2\\}\nPoint 130 \\{0.0\\}  \\{len1\\}\n\\end{apinp}\n\nThe output from this example input file is:\n\n\\begin{apout}\n\\$  Aprepro  Units  Utility  Example\n\\$  NOTE:  Dimensions  -  cm,  gram,  g/cc,  Mbar  \\textit{\\ldots{}The documentation of what quantities this file uses}\n\\$ 25.4 \n\\$ 30.48\n\nMaterial 1, Elastic Plastic, 1.89 \\$ g/cc \n   Youngs Modulus = 1.951216314 \\$ Mbar\n   Yield  Stress  =  0.002068427188  \\textit{\\ldots{}All material parameters are now in consistent units}\n   Initial Velocity = 0.00044704 \\$ cm/usec\nEnd\n\nPoint  100  0  0\nPoint  110  25.4 0\nPoint  120  25.4 30.48\nPoint  130  0   25.4   \\textit{\\ldots{}Lengths have all been converted to centimetres}\n\\end{apout}\n\nThe same input file can be used to output in SI units simply by changing Units \ncommand from \\var{shock} to \\var{si}. The output in SI units is:\n\n\\begin{apout}\n\\$ Aprepro Units Utility Example\n\\$  NOTE:  Dimensions  -  meter,  kilogram,  kg/m^3,  Pa  \n\\textit{\\ldots{}Quantities are now output in standard SI units}\n\\$ 0.254\n\\$ 0.3048\n\nMaterial  1,  Elastic  Plastic,  1890  \\$  kg/m^3\n   Youngs  Modulus =  1.951216314e+11 \\$ Pa\n   Yield  Stress   =  206842718.8 \n   Initial Velocity = 4.4704 \\$ meter/sec\nEnd\n\nPoint  100 0  0\nPoint  110 0.254  0\nPoint  120 0.254  0.3048\nPoint  130 0   0.254  \\textit{\\ldots{}Lengths have all been converted to metres}\n\\end{apout}\n\n\\section{Additional Comments}\n\nA few additional comments and warnings on the use of the units system are detailed \nbelow.\n\nOmitting the \\{ECHO(OFF)\\} line prior to the \\{Units(``unit\\_system'')\\} \nfunction will print out the contents of the units header and conversion files. \nEach line in the output will be preceded by the current comment character which \nis \\$ by default.\n\nThe comment character can be changed by invoking \\aprepro{} with the \n\\cmd{-c} option. For example \\cmd{aprepro -c\\# input\\_file output\\_file} \nwill change the comment character at the beginning of the lines to \\#. \n\nThe temperature conversions are only valid for relative temperatures, for \nexample, 100\\textasciitilde{}degC is equal to 180\\textasciitilde{}degF, not 212\\textasciitilde{}degF. \n\nSince several variables are defined in the units system, it is\npossible to redefine one of the variable names in your input file. If\nthe \\aprepro{} warning messages are turned off, you will not be\nnotified of the variable redefinition and erroneous results may\noccur. Therefore, you should not turn off \\aprepro{} warning\nmessages while using the units system, and you should investigate all\nredefined variable messages to ensure that you are getting the results\nyou expect. \n\n", "meta": {"hexsha": "85b5ebd6e1260e7006579d124ffec9c1e378a5d1", "size": 12083, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/seacas/doc-source/aprepro/units.tex", "max_stars_repo_name": "jschueller/seacas", "max_stars_repo_head_hexsha": "14c34ae08b757cba43a3a03ec0f129c8a168a9d3", "max_stars_repo_licenses": ["Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "NetCDF", "BSL-1.0", "X11", "BSD-3-Clause"], "max_stars_count": 82, "max_stars_repo_stars_event_min_datetime": "2016-02-04T18:38:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T03:01:49.000Z", "max_issues_repo_path": "packages/seacas/doc-source/aprepro/units.tex", "max_issues_repo_name": "jschueller/seacas", "max_issues_repo_head_hexsha": "14c34ae08b757cba43a3a03ec0f129c8a168a9d3", "max_issues_repo_licenses": ["Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "NetCDF", "BSL-1.0", "X11", "BSD-3-Clause"], "max_issues_count": 206, "max_issues_repo_issues_event_min_datetime": "2015-11-20T01:57:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:12:04.000Z", "max_forks_repo_path": "packages/seacas/doc-source/aprepro/units.tex", "max_forks_repo_name": "jschueller/seacas", "max_forks_repo_head_hexsha": "14c34ae08b757cba43a3a03ec0f129c8a168a9d3", "max_forks_repo_licenses": ["Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "NetCDF", "BSL-1.0", "X11", "BSD-3-Clause"], "max_forks_count": 68, "max_forks_repo_forks_event_min_datetime": "2016-01-13T22:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T06:25:05.000Z", "avg_line_length": 37.1784615385, "max_line_length": 143, "alphanum_fraction": 0.6647355789, "num_tokens": 4026, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.44493523957102427}}
{"text": "\n\\section{Transcritical flow with a shock over a bump}\n\nThis scenario simulates a transcritical flow over a bump with a shock. The topography and the initial conditions are the same as those used in the subcritical flow (See the description given in the report on the subcritical flow test). However, to get a transcritical flow, the boundary conditions are different from those used in the subcritical flow test. Here we refer to the parameters used by Goutal and Maurel~\\cite{GM1997}.\n\nReferring to our description for the subcritical flow test, the analytical height or depth $h$ of the transcritical flow at smooth regions is found by solving the Bernoulli equation. The analytical solution for the shock position is found by implementing three equations, namely, (a) the Bernoulli equation at upstream (on the left of the shock), (b) the Bernoulli equation at downstream (on the right of the shock), and (c) the Rankine-Hugoniot relation. The Rankine-Hugoniot relation for the steady flow can be expressed as\n\\begin{equation}\nq^2 \\left( \\frac{1}{h_1} - \\frac{1}{h_2} \\right) + \\frac{g}{2} \\left(h_1^2 - h_2^2\\right) = 0\\,,\n\\end{equation}\nwhere $q$ is the discharge or momentum, $h_1$ is the height upstream (on the left of the shock), and $h_2$ is the height downstream (on the right of the shock). When the height $h$ has been found, the velocity is computed as $u=q/h$\\,.\n\n\\subsection{Results}\nFor our simulation, we consider Dirichlet boundary conditions\nat $x=0^{-}$ given by\n\\begin{equation}\n[w,hu,hv]=[0.41373588752426715,~~~0.18,~~~0]\\,,\n\\end{equation}\nand at $25^{+}$ given by\n\\begin{equation}\n[w,hu,hv]=[0.33,~~~0.18,~~~0]\\,.\n\\end{equation}\nWith these conditions, representatives of the simulation results are shown in the following three figures. They show the stage, $x$-momentum, and $x$-velocity respectively. We should see good agreement between the analytical and numerical solutions.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{stage_plot.png}\n\\end{center}\n\\caption{Stage results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xmom_plot.png}\n\\end{center}\n\\caption{Xmomentum results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xvel_plot.png}\n\\end{center}\n\\caption{Xvelocity results}\n\\end{figure}\n\n\n\\endinput\n", "meta": {"hexsha": "9d4bd00bdad014692fcf8dc8d2f451e192a2ccdc", "size": 2330, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "validation_tests/analytical_exact/transcritical_with_shock/results.tex", "max_stars_repo_name": "samcom12/anuga_core", "max_stars_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_stars_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_stars_count": 136, "max_stars_repo_stars_event_min_datetime": "2015-05-07T05:47:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T03:07:40.000Z", "max_issues_repo_path": "validation_tests/analytical_exact/transcritical_with_shock/results.tex", "max_issues_repo_name": "samcom12/anuga_core", "max_issues_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_issues_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_issues_count": 184, "max_issues_repo_issues_event_min_datetime": "2015-05-03T09:27:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T04:22:48.000Z", "max_forks_repo_path": "validation_tests/analytical_exact/transcritical_with_shock/results.tex", "max_forks_repo_name": "samcom12/anuga_core", "max_forks_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_forks_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-03-18T07:35:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-01T07:07:29.000Z", "avg_line_length": 47.5510204082, "max_line_length": 525, "alphanum_fraction": 0.7587982833, "num_tokens": 663, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.44493523957102427}}
{"text": "Successful attack in digital environment does not guarantee same success in the physical world. In contrast to the digital environment in real world we have to print eyeglass frames using some kind of 2d or 3d printer (in this case 2d) and then conduct an attack on a camera used by FRS. None printer is able to print every possible color. Every camera has a sampling error and is unable to capture colors 1:1. Because of that we have to apply slightly changes to the perturbation finding method.\n\n\n\\subsection{Robust Perturbations}\nBecause of changing condition such as image background, light conditions, attacker posture or his/her facial expression it's not fairly possible that two attacker's face images will be exactly the same. In initial assumption we assumed that \\textit{Considered attacks should also be robust to changes in image conditions - light changes, attacker position changes, standing further/closer to camera shouldn't’t affect effectiveness of an attack}. That's why authors assumed that in order to successfully carry out attacks it is necessary to find perturbation $r$ such that it will be independent of exact image conditions. In other words we want to avoid some kind of \\textit{overfitted} perturbation, but instead to find perturbation that will generalize beyond a single face image.\n\nThis was achieved by gathering a set of photos of the attacker $X$, taken in different conditions (changing background, lighting, facial expression, distance from the camera, head angle, etc.) and use that set $X$ to find a single perturbation $r$ that optimizes its objective for every input $x \\in X$. We can formalize this as as optimization problem for both Impersonation (6) and Dodging (7):\n\n\n\\begin{equation}\n\\operatorname{argmin}_{r} \\sum_{x \\in X} \\operatorname{softmaxloss}(f(x+r), c_t)\n\\end{equation}\n\n\n\\begin{equation}\n\\operatorname{argmin}_{r} \\sum_{x \\in X} \\operatorname{- softmaxloss}(f(x+r), c_x)\n\\end{equation}\n\n\\subsection{Smooth transitions}\n\nNatural images tend to contain smooth and regular patches, which are separated by a few edges. However generated perturbation eyeglass frames generated by minimizing \\textit{softmaxloss} contain lot of edges and aren't very smooth. It might be a problem for cameras, because of sampling noise, extreme differences between neighboring pixels are unlikely to be accurately captured by camera. As a result non-smooth eyeglass frames may lead to not physically realizable attacks (which was paper initial assumption, see 6.1).\n\nTo achieve smooth perturbation we have to update the optimization function. Except minimizing \\textit{softmaxloss} we have to also minimize \\textit{total variation} ($TV$). For a perturbation $r$, $TV(r)$  is defined as: \n\n\\begin{equation}\nT V(r)=\\sum_{i, j}\\left(\\left(r_{i, j}-r_{i+1, j}\\right)^{2}+\\left(r_{i, j}-r_{i, j+1}\\right)^{2}\\right)^{\\frac{1}{2}}\n\\end{equation}\n\nWhere $r_{i,j}$ is an eyeglass frames pixel value at coordinates $(i,j)$. $TV(r)$ is low when the neighboring pixels have similar values (perturbation patch is smooth and regular) and high otherwise. A result of minimizing $TV(r)$ is smooth perturbation.\n \n\\subsection{Printability}\n\nFor printing an eyeglass frames authors have used a simple ink-jet printer - (Epson XP-83). It prints 2d eyeglass frames, but as any printer in the world it has some physical limitations. It can reproduce only a subset of the $[0,1]^3$ RGB color space not all possible colors. That's why in order to conduct successful attacks we need to limit perturbation to only colors reproducible by the printer. To do so authors defined \\textit{non-printability score} ($NPS$). $NPS$  have high value for pixel of unreproducible color and low  otherwise. Let $P \\subset [0,1]^3 $ be the set of printable RGB triplets. We\ndefine the $NPS$ of a pixel $\\hat{p}$ as: \n\n\\begin{equation}\nN P S(\\hat{p})=\\prod_{p \\in P}|\\hat{p}-p|\n\\end{equation}\n\nTo measure total $NPS$ for a perturbation $r$ we sum $NPS$ for each pixel $\\hat{p}$ from a perturbation $r$. Instead of using all printable RGB triplets authors decided to pick the 30 triplets with a minimal variance in distances from the complete set of printable RGB triplets and use only them in the set $P$ used in definition of $NPS$. Authors claim that this optimization with using 30 \\textit{centroids} worked great for them and lead to big improvements in physical realizability of an attack.\n\n\n\\subsection{Putting Everything Together}\n\nNow we can to put everything together and model the new objective that will consist of \\textit{misclassification} \\textit{smoothness} and \\textit{printability}. This new objective can be modeled as: \n\n\\begin{equation}\n\\underset{r}{\\operatorname{argmin}}\\left(\\sum_{x \\in X} \\operatorname{softmaxloss}\\left(f(x+r), c_{t}\\right)\\right)+\\kappa_{1} \\cdot \\operatorname{TV}(r)+\\kappa_{2} \\cdot \\operatorname{NPS}(r)\n\\end{equation}\n\nWhere $\\sum_{x \\in X} \\operatorname{softmaxloss}\\left(x+r, c_{t}\\right)$ is a \\textit{misclassification} part (it is version for impersonation, for dodging it would be $\\operatorname{argmin}_{r}\\left(-\\operatorname{softmaxloss}\\left(f(x+r), c_{x}\\right)\\right)$), $\\kappa_1$ and $\\kappa_2$ are hyperparameters to balance \\textit{smoothness} ($TV$) and \\textit{printability} ($NPS$), $r$ is the perturbation we want to find and $X$ is a set of images of an attacker's face, ", "meta": {"hexsha": "b83cfb260af0c7f434b8f10006ad93b0369e365b", "size": 5338, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "physical-implementation.tex", "max_stars_repo_name": "tugot17/ML-In-Cybersecurity-Paper-", "max_stars_repo_head_hexsha": "9102121ee32410fdefb415e601e9ab8c027b149a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-31T17:04:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-31T17:04:19.000Z", "max_issues_repo_path": "physical-implementation.tex", "max_issues_repo_name": "tugot17/ML-In-Cybersecurity-Paper-", "max_issues_repo_head_hexsha": "9102121ee32410fdefb415e601e9ab8c027b149a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "physical-implementation.tex", "max_forks_repo_name": "tugot17/ML-In-Cybersecurity-Paper-", "max_forks_repo_head_hexsha": "9102121ee32410fdefb415e601e9ab8c027b149a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 104.6666666667, "max_line_length": 783, "alphanum_fraction": 0.7690146122, "num_tokens": 1374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.44493523911097516}}
{"text": "\\section{Developed Method}\r\n\\label{sec:HomographyDevelopedMethod}\r\n\r\nOur work aimed to devise a systematic approach to select the ``best'' homography according to the proposed score function. The assumption was that there was no prior knowledge about the quality of individual markers.\r\n\r\nHere is the description of the proposed method. Each homography is induced by a single independent marker. The input to our method is multiple sets (\\ietext{}, groups) of point correspondences between the warped and the ground-truth (ideal) markers. Therefore, each marker is represented by a unique set of keypoints. The use case of our method is to rank multiple homographies and select the best performing one with respect to the tailor-made score function. Consequently, we require a homography matrix for each marker (a set of point correspondences) on the input. The great advantage comes from the fact that to compute these matrices, any state-of-the-art method can be utilized as a black box. The benefit is that it is capable of ranking the referred homographies without the knowledge of absolute or relative positions of markers in the world (\\figtext{}~\\ref{fig:GraphicalAbstract}). However, we have to emphasize that we did not propose any method to simultaneously estimate multiple homographies. We only build upon the existing homography matrices.\r\n\r\nDue to our assumption of not knowing the arrangement of markers in the scene, there is no way to create one virtual, compound marker that contains all the keypoints. If we could, then we would employ RANSAC~\\cite{fischler1981ransac} or any other sophisticated algorithm to select the best subset of keypoints to estimate the homography. In that scenario, our approach would be useless. We only have information about the relative position of the marker’s keypoints at our disposal, not the markers themselves. As a result, the point correspondence is globally indeterminate. We can only establish a local point correspondence between a single marker and its corresponding ground-truth shape. For the best performance, to obtain the isolated homographies, we suggest the user chooses the most robust method available.\r\n\r\nThe homography estimation between existing point correspondences is a standard problem we heavily rely on. As already highlighted, we did not contribute to this problem in terms of improving the homography estimation itself. We only provided a way to rank the resulting homographies. We developed a way to, under certain circumstances, choose the ``best'' homography from multiple existing ones. Therefore, our method could not even be compared to RANSAC, because we tackle a different problem. There are three following assumptions the proposed method is based upon:\r\n\\begin{enumerate}\r\n    \\item The markers are geometrically similar, which means that they are allowed to differ only in translation, rotation, and uniform scale in the real world.\r\n    \\item The shape of at least one of the used markers is known beforehand.\r\n    \\item These markers are positioned on the same planar surface visible in the scene.\r\n\\end{enumerate}\r\nOne important caveat is that our method handles only transformation from a distorted to the undistorted view of the target plane.\r\n\r\nWe exploited the properties of homography and similarity transformations and expressed them in a single score function, which stands at the core of our contribution. The score function value is exploited as a proxy for homography ranking according to their reprojection error over the entire image using only markers' keypoints. It is only an estimate. The usual use case would be to select the homography with the lowest score, \\ietext{}, the highest-ranked matrix, to perform the image rectification with the expectation of obtaining the most accurate reprojection.\r\n\r\n% ------------------------------------------------------------------------------\r\n\\begin{figure}[t]\r\n    \\centerline{\\includegraphics[width=\\linewidth]{figures/homography/graphical_abstract.pdf}}\r\n    \\caption[Graphical abstract for homography ranking]{The graphical abstract from our paper. The basic idea is that existing approaches may only estimate an isolated homography for each marker and cannot determine which homography achieves the best reprojection over the entire image. Therefore, we proposed a method to rank isolated homographies obtained from multiple distinct markers to select the best homography. This method extends existing approaches, provided that the point correspondences are available and the markers differ only by similarity transformation after rectification.}\r\n    \\label{fig:GraphicalAbstract}\r\n\\end{figure}\r\n% ------------------------------------------------------------------------------\r\n\r\n% ------------------------------------------------------------------------------\r\n\\begin{figure}[t]\r\n    \\centerline{\\includegraphics[width=\\linewidth]{figures/homography/system_diagram.pdf}}\r\n    \\caption[Homography ranking system diagram]{A system diagram of our method. \\imgpartdesc{a} The input consists of a many-to-one point correspondence specified by multiple similar markers together with the information about the ground-truth shape (up to an arbitrary positive scale) of the target marker. \\imgpartdesc{b} The assumption is that the isolated homographies related to each marker are ready on the input as well. \\imgpartdesc{c} The algorithm processes each marker by applying its corresponding homography matrix to the image to produce a rectified image. Subsequently, it computes optimal similarity matrices using auxiliary markers. These transformations are required for the computation of the score function. The obtained score values then serve for comparison when ranking the homographies. The homography that ends up ranked first is considered (predicted) to the ``best'' candidate for achieving the minimal reprojection error over the whole image.}\r\n    \\label{fig:HomographySystemDiagram}\r\n\\end{figure}\r\n% ------------------------------------------------------------------------------\r\n\r\nOur method utilizes multiple similar markers (\\figtext{}~\\ref{fig:HomographySystemDiagram}). The input is point correspondences and homographies estimated for each marker. Each marker becomes the reference marker only once during the course of the algorithm. All the remaining markers serve as auxiliary markers. The reference marker's homography is used to perform the perspective transformation to rectify all the visible markers. To rank which reference markers' homography yields the best reprojection, we exploit auxiliary markers. Auxiliary markers are subsequently mapped onto the target marker using similarity transformations (\\eqtext{}~\\ref{eq:SimilarityMatrices}). The transformed keypoints are converted to homogeneous coordinates and the reprojection error is measured as the mean Euclidean distance between the rectified and the target keypoints~(\\eqtext{}~\\ref{eq:HomographyScoreFunction}). The objective is to minimize the computed quantity.\r\n\r\nLet $r$ be the index of the reference marker. The $3 \\times 3$ matrices describing similarity transformations are contained in a set $\\mset{S} = \\cbrackets{\\suprbrackets{\\mtx{S}}{i} \\ |\\ i = 1, \\dots, m}$, such that\r\n\\begin{equation}\r\n    \\label{eq:SimilarityMatrices}\r\n    \\suprbrackets{\\mtx{S}}{i} =\r\n    \\begin{cases}\r\n        \\begin{aligned}\r\n             & \\begin{bmatrix}\r\n                1 & 0 & 0 \\\\\r\n                0 & 1 & 0 \\\\\r\n                0 & 0 & 1\r\n            \\end{bmatrix} & \\text{if } i = r   \\\\\r\n             & \\begin{bmatrix}\r\n                \\subsuprbrackets{\\mtx{R}}{2 \\times 2}{i} & \\subsuprbrackets{\\mtx{T}}{2 \\times 1}{i} \\\\\r\n                \\mathbf{0}_{1 \\times 2}                  & 1\r\n            \\end{bmatrix} & \\text{if }i \\neq r \\\\\r\n        \\end{aligned}\r\n    \\end{cases},\r\n\\end{equation}\r\nfor $i = 1, \\dots, m$, where\r\n\\begin{equation}\r\n    \\subsuprbrackets{\\mtx{R}}{2 \\times 2}{i} =\r\n    \\begin{bmatrix}\r\n        \\suprbrackets{s}{i} \\cdot \\func{\\cos}{\\suprbrackets{\\theta}{i}} & -\\suprbrackets{s}{i} \\cdot \\func{\\sin}{\\suprbrackets{\\theta}{i}} \\\\\r\n        \\suprbrackets{s}{i} \\cdot \\func{\\sin}{\\suprbrackets{\\theta}{i}} & \\suprbrackets{s}{i} \\cdot \\func{\\cos}{\\suprbrackets{\\theta}{i}}\r\n    \\end{bmatrix}, \\quad\r\n    \\subsuprbrackets{\\mtx{T}}{2 \\times 1}{i} =\r\n    \\begin{bmatrix}\r\n        \\subsuprbrackets{t}{x}{i} \\\\\r\n        \\subsuprbrackets{t}{y}{i}\r\n    \\end{bmatrix}.\r\n\\end{equation}\r\nThis transformation (besides the identity) involves $4$ \\gls{dof}: a single rotation angle $\\suprbrackets{\\theta}{i}$, two $x$ and $y$ translation coefficients $\\subsuprbrackets{t}{x}{i}$, $\\subsuprbrackets{t}{y}{i}$, and a scale coefficient $\\suprbrackets{s}{i}$. A full affine transformation ($6$ \\gls{dof}) would incorporate horizontal and vertical\r\nscales, shear and rotation, and $x$, $y$ offsets~\\cite{barath2016novel}. The application of homography that rectifies an image generates a frontal plane that is related to the ground-truth plane by a similarity transformation~\\cite{hartley2003multiple, beck2016planar}. Thus, we do not include the shear and we only support uniform scaling. The mathematical justification can be found in the appendix section of our paper~\\cite{ondrasovic2021homography}.\r\n\r\nAs all the markers share the same planar surface, a valid homography corresponding to any of them by definition to provide a valid perspective projection. However, all perspective projections are subjected to different noise. The endeavor then is to quantify which homography estimation could provide the best perspective projection for the whole plane in the image. To do so, we propose a score function based on the aforementioned constraints. The score function computes a score for individual homographies in along with the estimated similarity matrices corresponding to auxiliary markers as\r\n\\begin{equation}\r\n    \\label{eq:HomographyScoreFunction}\r\n    \\func{\\scoref}{\\H, \\mset{S}} =\r\n    \\frac{1}{m}\r\n    \\sum_{i = 1}^{m}\r\n    \\frobnorm{\r\n        \\func{h}{\r\n            \\suprbrackets{\\mtx{S}}{i}\r\n            \\H\r\n            \\suprbrackets{\\mtx{W}}{i}\r\n        }\r\n        -\r\n        \\mtx{T}\r\n    },\r\n\\end{equation}\r\nwhere $\\frobnorm{\\cdot}$ denotes the Frobenius norm. The function $\\func{h}{\\cdot}$ converts points to homogeneous coordinates as\r\n\\begin{equation}\r\n    \\label{eq:HomoCoordsConversion}\r\n    \\func{h}{\r\n        \\begin{bmatrix}\r\n            x_1 & x_2 & \\dots & x_k \\\\\r\n            y_1 & y_2 & \\dots & y_k \\\\\r\n            z_1 & z_2 & \\dots & z_k\r\n        \\end{bmatrix}\r\n    } =\r\n    \\begin{bmatrix}\r\n        \\nicefrac{x_1}{z_1} & \\nicefrac{x_2}{z_2} & \\dots & \\nicefrac{x_k}{z_k} \\\\\r\n        \\nicefrac{y_1}{z_1} & \\nicefrac{y_2}{z_2} & \\dots & \\nicefrac{y_k}{z_k} \\\\\r\n        1                   & 1                   & \\dots & 1\r\n    \\end{bmatrix}.\r\n\\end{equation}\r\n\r\nIn what follows, we describe the proposed Algorithm~\\ref{alg:HomographyRanking} for homography ranking. Assume a set of warped markers described by the warped keypoints and a single target marker represented by the target keypoints. There is a many-to-one point correspondence linking these objects. Besides, assume that homographies have been estimated for each marker in isolation. Our algorithm ranks the input set of all pairs $\\rbrackets{\\suprbrackets{\\mtx{W}}{i}, \\mtx{T}}$, $i = 1, \\dots, m$ in ascending order by how well each $i$-th marker preserves the target shape of all the markers in the image after removing the perspective distortion. The score function defined in \\eqtext{}~\\ref{eq:HomographyScoreFunction} is used to measure this objective. The algorithm evaluates all markers as candidates for the reference marker. In each iteration, it computes optimal similarity matrices belonging to the auxiliary markers in the rectified plane, \\ietext{}, after applying the perspective projection induced by the current homography. The aim is to find a homography with a minimal score. The algorithmic complexity is quadratic in the number of markers, thus $\\func{\\Theta}{m \\rbrackets{m - 1} + m \\func{\\text{log}_2}{m}} \\simeq \\func{\\Theta}{m^2}$. It is important to remark that the two functions used to compute the homography and similarity matrices in the pseudocode may stand for arbitrary methods that produce the required transformations.\r\n\r\n\\def\\hmatrices{\\boldsymbol{\\bar{H}}}\r\n\\def\\scoref{\\mathcal{F}}\r\n\r\n\\begin{algorithm}[t]\r\n    \\caption[Homography ranking algorithm]{Homography ranking algorithm.}\r\n    \\label{alg:HomographyRanking}\r\n    \\begin{algorithmic}[1]\r\n        \\State $\\hmatrices \\gets \\arraydef \\left[ m \\right]$\r\n        \\Comment{empty array for the homography matrices}\r\n\r\n        \\State $\\scores \\gets \\arraydef \\left[ m \\right]$\r\n        \\Comment{array of scores computed before the ranking (sorting)}\r\n\r\n        \\For{$i \\gets 1, \\dots , m$}\r\n        \\Comment{for each reference marker}\r\n\r\n        \\State $\\hmatrices \\left[ i \\right] \\gets$\r\n        \\Call{homography}{$\\suprbrackets{\\mtx{W}}{i}$, $\\mtx{T}$}\r\n        \\Comment{retrieve or estimate perspective transform.}\r\n\r\n        \\State $\\suprbrackets{\\mtx{\\bar{S}}}{i} \\gets \\mtx{I}_{3 \\times 3}$\r\n        \\Comment{identity matrix to stand for a similarity transformation}\r\n\r\n        \\State $\\mset{\\bar{S}} \\gets \\cbrackets{\\suprbrackets{\\mtx{\\bar{S}}}{i}}$\r\n        \\Comment{set of similarity matrices}\r\n\r\n        \\ForAll{$j$ : $\\cbrackets{1, \\dots, m} - \\cbrackets{i}$}\r\n        \\Comment{for each auxiliary marker}\r\n\r\n        \\State $\\suprbrackets{\\mtx{\\bar{S}}}{j} \\gets$ \\Call{similarity}{$\\hmatrices \\left[ i \\right] \\cdot \\suprbrackets{\\mtx{W}}{j}$, $\\mtx{T }$}\r\n        \\Comment{estimate similarity transformation}\r\n\r\n        \\State$\\mset{\\bar{S}} \\gets \\mset{\\bar{S}} \\cup \\suprbrackets{\\mtx{\\bar{S}}}{j}$\r\n        \\Comment{store the similarity matrix}\r\n\r\n        \\EndFor\r\n\r\n        \\State $\\scores \\left[ i \\right] \\gets \\func{\\scoref}{\\hmatrices \\left[ i \\right], \\mset{\\bar{S}}}$\r\n        \\Comment{evaluate score function (\\eqtext{}~\\ref{eq:HomographyScoreFunction})}\r\n        \\EndFor\r\n        \\State $\\sortres \\gets \\Call{argsort}{\\scores}$\r\n        \\Comment{indirect sort, only obtain indices of ``would-be'' sorted elements}\r\n\r\n        \\State \\Return $\\hmatrices, \\sortres$\r\n        \\Comment{return homographies and their respective ranking positions}\r\n    \\end{algorithmic}\r\n\\end{algorithm}\r\n", "meta": {"hexsha": "a995ec5bd85680e5de0e3b659e7d0bab88b57a0d", "size": 14322, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/chapters/homography/sections/methodology.tex", "max_stars_repo_name": "mondrasovic/phd_thesis", "max_stars_repo_head_hexsha": "68a3a6d1687ea43dc6cdfafcd5e6d9ce35f424e8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/chapters/homography/sections/methodology.tex", "max_issues_repo_name": "mondrasovic/phd_thesis", "max_issues_repo_head_hexsha": "68a3a6d1687ea43dc6cdfafcd5e6d9ce35f424e8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/chapters/homography/sections/methodology.tex", "max_forks_repo_name": "mondrasovic/phd_thesis", "max_forks_repo_head_hexsha": "68a3a6d1687ea43dc6cdfafcd5e6d9ce35f424e8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 93.0, "max_line_length": 1454, "alphanum_fraction": 0.7110040497, "num_tokens": 3433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4449352352716293}}
{"text": "\\section{Motivating Example}\n\nWe take as a motivating example, the gearing controller component for an autonomous vehicle system.\nIn a typical scenario, we might build a neural network to control the output of the gear box at every time step based on all relevant sensor data.\nWe then have a neural network, $\\fullNN$, processing inputs (acceleration, braking, speed, rpm, gear) to produce a new (gear) signal.\n\nWe can imagine this as a mealy machine with a single state and a single transition, which is always active.\n\n\\begin{figure}[h!]\n\\centering\n\\begin{tikzpicture}[shorten >=1pt,node distance=2.8cm,on grid]\n  \\node[state]   (q_0)                {$q_0$};\n  \\path[->] (q_0) \n\t\t  edge [loop above]   node  [above,align=center]         {$\\top,$\\\\$ \\fullNN$} ();\n\\end{tikzpicture}\n\\caption{A mealy machine of a single monolithic neural network}\n\\label{fig:full}\n\\end{figure}\n\nNow assume we have some adversarial actor that takes control of the speed sensor.\nSince this network is processing the speed signal at every time step, we cannot have any guarantee of the effect a faulty speed sensor will have on our overall output.\n\nIn contrast, imagine we build an automata of neural networks as below.\nHere, we have composed three networks; $\\isAccel$ for a binary classifier that indicates whether the car is accelerating and the two multiclass classifiers, $\\rpmGear$ and $\\speedGear$, mapping their inputs to the target gear into which the car should shift (for example gears 1-5).\nThe mealy machine says that when the car is not accelerating, we should not shift the gear.\nIt also specifies that when we start to accelerate after a period of slowing down, we should set the gear based on the current speed.\nAs the car continues to accelerate, the gear should be set based on the rpm of the engine.\n\n\\begin{figure}[h!]\n\\centering\n\\begin{tikzpicture}[shorten >=1pt,node distance=2.8cm,on grid]\n  \\node[state]   (q_0)                {$q_0$};\n  \\node[state] (q_1) [right=of q_0] {$q_1$};\n  \\path[->] (q_0) \n\t\t  edge [loop left]   node  [above,align=center]         {$\\neg \\isAccel,$\\\\$ \\varnothing$} ()\n\t\t  edge [bend left=45] node [above,align=center] {$\\isAccel,$\\\\$ \\rpmGear$} (q_1)\n            (q_1) \n\t\t  edge [loop right]   node [above right,xshift=-0.5cm,align=center]        {$\\isAccel,$\\\\$ \\speedGear$} ()\n\t\t  edge [bend left=45] node [below,align=center] {$\\neg \\isAccel,$\\\\$ \\varnothing$} (q_0);\n\\end{tikzpicture}\n\\caption{A mealy machine of multiple composed neural networks}\n\\label{fig:components}\n\\end{figure}\n\nIn Fig.~\\ref{fig:components}, we clearly see that an attack on the speed sensor is guaranteed to only have an effect on the transition from state $q_0$ to state $q_1$.\nBecause of this compartmentalization of vulnerability, safety tactics such as trying to detect anomalous values may be employed to greater effect.\nIn the sequel, we will present a quantitative formalization of the vulnerability of the systems in both Fig.~\\ref{fig:full} and Fig.~\\ref{fig:components}.\n", "meta": {"hexsha": "09511858183602b0f6799bc4b1105d628385cc3a", "size": 2992, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/CAV18/secs/motiv.tex", "max_stars_repo_name": "santolucito/Haskell-TORCS", "max_stars_repo_head_hexsha": "95eef93f7089bbe95f0f28fa21f0f636d7ffc39f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-08T14:58:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-14T16:49:06.000Z", "max_issues_repo_path": "paper/CAV18/secs/motiv.tex", "max_issues_repo_name": "santolucito/Haskell-TORCS", "max_issues_repo_head_hexsha": "95eef93f7089bbe95f0f28fa21f0f636d7ffc39f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/CAV18/secs/motiv.tex", "max_forks_repo_name": "santolucito/Haskell-TORCS", "max_forks_repo_head_hexsha": "95eef93f7089bbe95f0f28fa21f0f636d7ffc39f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.3333333333, "max_line_length": 282, "alphanum_fraction": 0.7262700535, "num_tokens": 811, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.44493523097223425}}
{"text": "\\documentclass[a4paper,12pt]{article}\n%\\documentclass[a4paper,12pt]{scrartcl}\n\n\\usepackage{xltxtra}\n\n\\input{../preamble.tex}\n\n% \\usepackage[spanish]{babel}\n\n% \\setromanfont[Mapping=tex-text]{Linux Libertine O}\n% \\setsansfont[Mapping=tex-text]{DejaVu Sans}\n% \\setmonofont[Mapping=tex-text]{DejaVu Sans Mono}\n\n\\title{Homework \\#12}\n\\author{Isaac Ayala Lozano}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\begin{enumerate}\n \\item Propose a random process (Figure \\ref{fig: samples}) and prove that it is ergodic.\n\n Let $y(\\zeta, t) = \\sum_{n=1}^N a_n \\cos (\\omega_n t + \\Psi(\\zeta))$ be the proposed random process, where\n\n \\begin{itemize}\n  \\item $a_n$ is the amplitude of each cosine function.\n  \\item $\\omega_n$ is the frequency corresponding to each $n$.\n  \\item $\\Psi(\\zeta) \\in R $ is the random noise added to the process.\n \\end{itemize}\n\n \\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw12_samples.tex}\n\\caption{Random functions from the ensemble.}\n\\label{fig: samples}\n\\end{figure}\n\n We prove that the process is ergodic by verifying that for the ensemble of sample functions $y_k$, the mean value $\\mu_y (k)$ and the autocorrelation function $R_{yy}(\\tau, k)$ do not differ over different sample functions \\cite{bendat2011random}.\n\n\n\n The mean value of the sample function is obtained as follows\n\n \\begin{align*}\n  \\mu_y(k) &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T y_k (t) dt \\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T \\sum_{n=1}^N a_n \\cos(\\omega_n t + \\Psi (\\zeta)) dt\\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T}  \\sum_{n=1}^N \\int_0^T a_n \\cos(\\omega_n t + \\Psi (\\zeta)) dt\\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T}  \\sum_{n=1}^N \\left. \\frac{a_n}{\\omega_n} \\sin(\\omega_n t + \\Psi (\\zeta))  \\right\\rvert_{0}^{T} \\\\\n  &= 0\n \\end{align*}\n\n Given that $N < \\infty$, the sum of all terms will also be number less than infinity.\n Thus, as $T$ tends towards infinity the mean value of the random process approaches zero.\n This holds true for all values of $\\Psi(\\zeta)$.\n\n\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw12_ergodic.tex}\n\\caption{Mean vlaue for different amount of samples.}\n\\label{fig: ergodic}\n\\end{figure}\n\n For the autocorrelation function, a similar process is followed.\n\n \\begin{align*}\n  R_{yy} (\\tau, k) & = \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T y_k (t) y_k (t + \\tau) dt\\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T \\sum_{n=1}^N a_n \\cos(\\omega_n t + \\Psi (\\zeta))\n  \\sum_{n=1}^N a_n \\cos(\\omega_n (t+ \\tau) + \\Psi (\\zeta))\n  dt\n \\end{align*}\n\nWe present a simplified version of the proof when $N$ is equal to one, though the proof holds for all values of $N$.\nWe begin by applying the trigonometric identity of $\\cos(u\\pm v) = \\cos(u)\\cos(v) \\mp \\sin(u) \\sin(v)$ , such that $u = \\omega_n t + \\Psi(\\zeta)$ and $v = \\omega_n \\tau$.\n\n \\begin{align*}\n  R_{yy} (\\tau, k) &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T  (a \\cos(u))(a\\cos(u)\\cos(v) - a\\sin(u)\\sin(v)) dt\\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{1}{T} \\int_0^T  (a^2 (\\cos (u))^2 \\cos(v) - a^2 \\cos(u)\\sin(u)\\sin(v)) dt\\\\\n  &= \\lim _{T \\rightarrow \\infty} \\frac{a^2}{T} ( \\cos(v)\\int_0^T (\\cos(u))^2 dt -  \\sin(v) \\int_0^T \\cos(u) \\sin(u) dt )\n \\end{align*}\n\n Evaluating each integral yields the following results.\n\n \\begin{align*}\n\\int_0^T (\\cos(u))^2 dt &= \\int_0^T (\\cos(\\omega t + \\Psi(\\zeta)))^2 dt \\\\\n&= \\left. \\frac{2 (\\omega t + \\Psi(\\zeta)) + \\sin (2(\\omega t + \\Psi(\\zeta)))}{4 \\omega}  \\right\\rvert_{0}^{T}\\\\\n&= \\frac{T}{2} + \\frac{\\sin(2(\\omega T + \\Psi(\\zeta)))}{4\\omega} - \\frac{\\sin(2\\Psi(\\zeta))}{4\\omega} \\\\\n%\n\\int_0^T \\cos(u) \\sin(u) dt &= \\int_0^T \\cos(\\omega t + \\Psi(\\zeta)) \\sin(\\omega t + \\Psi(\\zeta)) dt\\\\\n&= \\left .  - \\frac{\\cos (2 (\\omega t + \\Psi(\\zeta)))}{4 \\omega} \\right\\rvert_{0}^{T}\\\\\n&= \\frac{\\cos(2\\Psi (\\zeta))}{4\\omega} - \\frac{\\cos (2 (\\omega T + \\Psi(\\zeta)))}{4 \\omega}\n \\end{align*}\n\nSubstituting these results into the original equation and evaluating the limit yields\n\n\\begin{equation*}\n R_{yy} (\\tau, k) =  \\frac{a^2}{2} \\cos(\\omega \\tau)\n\\end{equation*}\n\nThis is due to the fact that every other term for the integrals lacks a $T$ in the numerator of their fractions.\nGiven the absence of it, as $T$ approaches infinity the value of all the other terms will approach zero.\n\nThis result can be generalized for any value of N.\nFrom the original equation we notice that the equation was a sum of integrals, hence for values of different from one it is only necessary to add the results of those other integrals.\n\n\\begin{equation*}\n R_{yy} (\\tau, k) =  \\sum_{n=1}^N \\frac{a_n^2}{2} \\cos(\\omega_n \\tau)\n\\end{equation*}\n\nObserve that the autocorrelation function is not dependent on time, but on the lag between measurements.\nIt does not vary accross sample functions because they all present the same behaviour described in the random process' equation.\n\nGiven that both $\\mu_y (k)$ and $R_{yy}(k)$ do not vary between sample functions, as has been proven, the proposed random process is indeed ergodic.\n\n\n\n\\item Present plots of the probability density functions for a sine wave, a sine wave plus random noise, and a sample of white\\footnote{Also called Gaussian} noise.\n\n\\item Present the autocorrelation plots for the three previous functions.\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw12_sin.tex}\n\\caption{Sine function.}\n\\label{fig: sin}\n\\end{figure}\n\n\\newpage\n\\pagebreak\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw12_noise.tex}\n\\caption{Sine function with noise.}\n\\label{fig: noise}\n\\end{figure}\n\n\\newpage\n\\pagebreak\n\n\\begin{figure}[htb!]\n\\centering\n\\import{./img/}{hw12_white.tex}\n\\caption{White noise.}\n\\label{fig: white}\n\\end{figure}\n\n\\end{enumerate}\n\n\n\n\\printbibliography\n\n\\newpage\n\\pagebreak\n\\appendix\n\\section{Octave Code}\n\\lstinputlisting[language=Matlab]{hw08_plots.m}\n\n% https://ocw.mit.edu/courses/mechanical-engineering/2-22-design-principles-for-ocean-vehicles-13-42-spring-2005/readings/r6_spectrarandom.pdf\n\\end{document}\n", "meta": {"hexsha": "7ac16893b4736be4fbac820d45316d31d401176b", "size": 5962, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw12_IsaacAyala.tex", "max_stars_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_stars_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw12_IsaacAyala.tex", "max_issues_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_issues_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw12_IsaacAyala.tex", "max_forks_repo_name": "der-coder/CINVESTAV-Mathematics-II-2020", "max_forks_repo_head_hexsha": "ccd3364818c673f7a6bf13d495004034d2c6ecc0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3536585366, "max_line_length": 248, "alphanum_fraction": 0.681147266, "num_tokens": 2051, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073802837478, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.44492777281997764}}
{"text": "\\documentclass[]{BasiliskReportMemo}\n\\usepackage{AVS}\n\n\n\\newcommand{\\submiterInstitute}{Autonomous Vehicle Simulation (AVS) Laboratory,\\\\ University of Colorado}\n\n\\newcommand{\\ModuleName}{test\\textunderscore sunlineUKF}\n\\newcommand{\\subject}{Sunline UKF Module and Test}\n\\newcommand{\\status}{Initial document}\n\\newcommand{\\preparer}{T. Teil}\n\\newcommand{\\summary}{This module implements and tests a Unscented Kalman Filter in order to estimate the sunline direction.}\n\n\n\\begin{document}\n\n\n\\makeCover\n\n\n\n%\n%\tenter the revision documentation here\n%\tto add more lines, copy the table entry and the \\hline, and paste after the current entry.\n%\n\\pagestyle{empty}\n{\\renewcommand{\\arraystretch}{2}\n\\noindent\n\\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}\n\\hline\n{\\bfseries Rev}: & {\\bfseries Change Description} & {\\bfseries By} \\\\\n\\hline\nDraft & Initial Revision & T. Teil \\\\\n\\hline\n\n\\end{longtable}\n}\n\n\\newpage\n\\setcounter{page}{1}\n\\pagestyle{fancy}\n\n\\tableofcontents\n~\\\\ \\hrule ~\\\\\n\n%\\begin{figure}[htb]\n%\t\\centerline{\n%\t\\includegraphics[]{Figures/Fig1}\n%\t}\n%\t\\caption{Sample Figure Inclusion.}\n%\t\\label{fig:Fig1}\n%\\end{figure}\n\n\\section{Introduction}\nThe Unscented Kalman filter (UKF) in the AVS Basilisk simulation is a sequential\nfilter implemented to give the best estimate of the desired states.\nIn this method we estimate the sun heading as well as it's rate of change along the observable axes.\nThe UKF reads in the message written by the coarse sun sensor, and writes a message \ncontaining the sun estimate. \n\nThis document summarizes the content of the module, how to use it, and the test that \nwas implemented for it. More information on the filter derivation can be found in Reference [\\citenum{Teil:2018fe}], and more information on the square root unscented filter can be found in Reference [\\citenum{Wan2001}] (attached alongside this document).\n\n\n\\subsection{Dynamics}\n\nThe states that are estimated in this filter are the sunline vector, and it's rate of change $\\bm X^* = \\begin{bmatrix} \\bm d &  \\dot{\\bm d}\\end{bmatrix}^T$. The star superscript represents that\nthis is the reference state. \n\nThe dynamics are given in equation \\ref{eq:dyn}. Given the nature of the filter, there is an unobservable state component: the rotation about the $\\bm d$ axis. In order to remedy this, we project the states along this axis and subtract them, in order to measure only observable state components. \n\n\\begin{equation}\\label{eq:dyn}\n\\bm F(\\bm X) = \\begin{bmatrix} \\bm F_1(\\bm d) \\\\  \\bm F_2(\\dot{\\bm d})\\end{bmatrix} =  \\begin{bmatrix} \\dot{\\bm d} - \\left( (\\bm d \\cdot \\dot{\\bm d} )\\frac{\\bm d}{||\\bm d||^2} \\right) \\\\ - \\frac{1}{\\Delta t}\\left( (\\bm d \\cdot \\dot{\\bm d}) \\frac{\\bm d}{||\\bm d||^2} \\right)\\end{bmatrix} \n\\end{equation}\n\nThe measurement model is given in equation \\ref{eq:meas}, and the $H$ matrix defined as $H = \\left[\\frac{\\partial \\bm G (\\bm X, t_i)}{\\partial \\bm X}\\right]^{*}$ is given in equation $\\ref{eq:Hmat}$. \n\nIn this filter, the only measurements used are from the coarse sun sensor. For the $i^\\mathrm{th}$ sensor, the measurement is simply given by the dot product of the sunline heading and the normal to the sensor. This yields easy partial derivatives for the H matrix, which is a matrix formed of the rows of transposed normal vectors (only for those which received a measurement). Hence the $H$ matrix has a changing size depending on the amount of measurements. \n\n\\begin{equation}\\label{eq:meas}\n\\bm G_i(\\bm X) = \\bm n_i \\cdot \\bm d\n\\end{equation}\n\n\\begin{equation}\\label{eq:Hmat}\n\\bm H(\\bm X) = \\begin{bmatrix} \\bm n_1^T \\\\ \\vdots \\\\ \\bm n_i^T \\end{bmatrix} \n\\end{equation}\n\n\\section{Filter Set-up, initialization, and I/O}\n\n\\subsection{User initialization}\n\nIn order for the filter to run, the user must set a few parameters:\n\n\\begin{itemize}\n\\item The unscented filter has 3 parameters that need to be set, and are best as: \\\\\n      \\texttt{ filterObject.alpha = 0.02} \\\\\n      \\texttt{ filterObject.beta = 2.0} \\\\\n      \\texttt{ filterObject.kappa = 0.0} \n\\item The angle threshold under which the coarse sun sensors do not read the measurement: \\\\ \n\\texttt{FilterContainer.sensorUseThresh = 0.}\n\\item The process noise matrix: \\\\\n   \\texttt{qNoiseIn = numpy.identity(5)} \\\\\n   \\texttt{ qNoiseIn[0:3, 0:3] = qNoiseIn[0:3, 0:3]*0.01*0.01} \\\\\n   \\texttt{ qNoiseIn[3:6, 3:6] = qNoiseIn[3:6, 3:6]*0.001*0.001} \\\\\n    \\texttt{filterObject.qNoise = qNoiseIn.reshape(25).tolist()}\n\\item The measurement noise value, for instance: \\\\\n \\texttt{FilterContainer.qObsVal = 0.001}\n\\item The initial covariance: \\\\\n \\texttt{Filter.covar =} \\\\\n  \\texttt{ [0.4, 0.0, 0.0, 0.0, 0.0, 0.0, \\\\\n                          0.0, 0.4, 0.0, 0.0, 0.0, 0.0, \\\\\n                          0.0, 0.0, 0.4, 0.0, 0.0, 0.0, \\\\\n                          0.0, 0.0, 0.0, 0.04, 0.0, 0.0, \\\\\n                          0.0, 0.0, 0.0, 0.0, 0.04, 0.0, \\\\\n                          0.0, 0.0, 0.0, 0.0, 0.0, 0.04]}\n\\item The initial state :\\\\\n \\texttt{Filter.state =[1.0, 0.0, 0.0, 0.0, 0.0, 0.0]}\n\\end{itemize}\nThe messages must also be set as such:\n\n\\begin{itemize}\n\\item    \\texttt{ filterObject.navStateOutMsgName = \"sunline$\\_$state$\\_$estimate\"}\n\\item    \\texttt{ filterObject.filtDataOutMsgName = \"sunline$\\_$filter$\\_$data\"}\n\\item   \\texttt{ filterObject.cssDataInMsgName = \"css$\\_$sensors$\\_$data\"}\n\\item   \\texttt{ filterObject.cssConfInMsgName = \"css$\\_$config$\\_$data\"}\n\\end{itemize}\n\n\\subsection{Inputs and Outputs}\n\nThe UKF reads in the measurements from the coarse sun sensors. These are under the form of a list of cosine values. Knowing the normals to each of the sensors, we can therefore use them to estimate sun heading.\n\n\\section{Test Design}\nThe unit test for the sunlineUKF module is located in:\\\\\n\n\\noindent\n{\\tt fswAlgorithms/attDetermination/sunlineUKF/$\\_$UnitTest/test$\\_$SunlineUKF.py} \\\\\n\nAs well as another python file containing plotting functions:\n\n\\noindent\n{\\tt fswAlgorithms/attDetermination/sunlineUKF/$\\_$UnitTest/SunlineUKF$\\_$test$\\_$utilities.py} \\\\\n\nThe test is split up into 3 subtests. The first test creaks up all of the individual filter methods and tests them individually. These notably go over the square-root unscented filter specific functions. The second test verifies that in the case where the state is zeroed out from the start of the simulation, it remains at zero. The third test verifies the behavior of the time update with a measurement modification in the middle of the run. \n\n\\subsection{Individual tests}\n\nIn each of these individual tests, random inputs are fed to the methods and their values are computed in parallel in python. These two values are then compared to assure that the correct computations are taking place. \n\\begin{itemize}\n\\item \\underline{QR Decomposition}: This tests the QR decomposition function which returns just the R matrix. Tolerance to absolute error $\\epsilon = 10^{-15}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{LU Decomposition}: This tests the LU Decomposition accuracy. Tolerance to absolute error $\\epsilon = 10^{-14}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{LU backsolve}: This tests the LU Back-Solve accuracy. Tolerance to absolute error $\\epsilon = 10^{-14}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{LU matrix inverse}: This tests the LU Matrix Inverse accuracy. Tolerance to absolute error $\\epsilon = 10^{-14}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{Cholesky decomposition}: This tests the Cholesky Matrix Decomposition accuracy. Tolerance to absolute error $\\epsilon = 10^{-14}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{L matrix inverse}: This tests the L Matrix Inverse accuracy. Tolerance to absolute error $\\epsilon = 10^{-14}$.\n\n\\textcolor{ForestGreen}{Passed}\n\n\\item \\underline{U matrix inverse}: This tests the U Matrix Inverse accuracy. Tolerance to absolute error $\\epsilon = 10^{-12}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\end{itemize}\n\n\\subsection{Static Propagation}\n\n\n\\input{AutoTeX/StatesPlotprop.tex}\n\nThis test also takes no measurements in, and propagates with the expectation of no change. It then tests that the states and covariance are as expected throughout the time of simulation. Plotted results are seen in Figure \\ref{fig:StatesPlotprop}. We indeed see that the state and covariance that evolve nominally and without bias .\n\nTolerance to absolute error: $\\epsilon = 10^{-10}$\n\n\\subsection{Full Filter test}\n\nThis test the filter working from start to finish. No measurements are taken in for the first 20 time steps. Then a heading is given through the CSS message. Halfway through the simulation, measurements stop, and 20 time steps later a different heading is read. The filter must be robust and detect this change. This test is parametrized for different test lengths, different initial conditions, different measured headings, and with or without measurement noise. All these are successful.\n\n\\vspace{0.2cm}\nTolerance to absolute error without measurement noise: $\\epsilon = 10^{-10}$\n\n\\textcolor{ForestGreen}{Passed}\n\nPlotted results are seen in Figures \\ref{fig:StatesPlotupdate}, and \\ref{fig:PostFitupdate}. Figure \\ref{fig:StatesPlotupdate} shows the state error and covariance over the run. We see the covariance initially grow, then come down quickly as measurements are used. It grows once again as the measurements stop before bringing the state error back to zero with a change in sun heading. \n\nFigure \\ref{fig:PostFitupdate} shows the post fit residuals for the filter, with no measurement noise. We see that the observations are read in well an that the residuals are brought back down to zero.\n\n\\input{AutoTeX/StatesPlotupdate.tex}\n\\input{AutoTeX/PostFitupdate.tex}\n\n\n\\bibliographystyle{AAS_publication}   % Number the references.\n\\bibliography{references}   % Use references.bib to resolve the labels.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "2b82de65ee6e16cf19e586962794311ea5bd2f3c", "size": 9822, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/fswAlgorithms/attDetermination/sunlineUKF/_Documentation/Sunline_UKF.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/fswAlgorithms/attDetermination/sunlineUKF/_Documentation/Sunline_UKF.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/fswAlgorithms/attDetermination/sunlineUKF/_Documentation/Sunline_UKF.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1470588235, "max_line_length": 489, "alphanum_fraction": 0.7344736306, "num_tokens": 2758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.44479056324777755}}
{"text": "%==============================================================================\n\\chapter{Correlator of Field Strength}\n\\label{chap:corr_field}\n%==============================================================================\n\nHaving revealed the discrepancy in the kinematic description of Hawking \nradiation, namely as either a pure or a thermal and mixed state, the author \nwill show the difference in a physically relevant form. Recall that the \nparticle-number expectations of the pure and mixed states are the same, \ni.e.\\ the diagonal elements of the density operators in the particle-number \nbasis are the same. Hence one seeks operators revealing the off-diagonal \nelements of the density operator.\n\n%------------------------------------------------------------------------------\n\\section{Correlator and Fluctuation of Fourier Modes}\n\\label{sec:corr_Fourier}\n%------------------------------------------------------------------------------\n\nA natural candidate to reveal the off-diagonal elements of the density \noperators is the correlator. Bearing in mind the correlator of generalised \nGaussian wave functions (see \\cref{eq:multi-har-cor}), the correlator of the \nwave functional \\cref{eq:squeezed-wave-functional} can be read off as\n\\begin{align}\n\\abr{\\rfun{g^\\dagger}{p_1}\\rfun{g}{p_2}}_{\\chi_b} &=\n\\frac{1}{2}\\rbr{\\abr{\\rfun{g_\\Re}{p_1}\\rfun{g_\\Re}{p_2}}_{\\chi_b}+\\abr{\n\\rfun{g_\\Im}{p_1}\\rfun{g_\\Im}{p_2}}_{\\chi_b}}\n= \\frac{1}{2}\\frac{\\tanh\\frac{\\pp p_1}{2\\lambda}}{p_1} \\rfun{\\delta}{p_1 - \np_2} \\nonumber \\\\\n&\\propto \\frac{1}{8T_\\text{HD}}\\frac{\\rfun{\\tanh}{q/4}}{q/4} = \n\\frac{1}{8T_\\text{HD}}\\rbr{1 + \\rfun{\\Omicron}{q}}\n\\label{eq:correlator-pure}\n\\end{align}\nby substituting\n\\begin{equation}\n\\rfun{g}{p} = 2^{-1/2} \\rbr{\\rfun{g_\\Re}{p} + \\ii \\rfun{g_\\Im}{p}},\n\\end{equation}\nwhere $2^{-1/2}\\rfun{g_\\Re}{p}$ and $2^{-1/2}\\rfun{g_\\Im}{p}$ are the \nreal and imaginary part of $\\rfun{g}{p}$, respectively. In the last line of \n\\cref{eq:correlator-pure}, the delta function is ignored, and the dimensionless \nparameter\n\\begin{equation}\n\tq \\coloneqq p_1/T_\\text{HD} \\equiv 2\\pp p_1/\\lambda\n\\end{equation}\nhas been used. By the same argument, one also solves the correlator\n\\begin{equation}\n\\abr{\\rfun{g^\\dagger}{p_1}\\rfun{g}{p_2}}_\\text{vac} =\n\\frac{1}{2\\vbr{p_1}}\\rfun{\\delta}{p_1-p_2} \\propto\n\\frac{1}{2 T_\\text{HD}} q^{-1}\n\\label{eq:correlator-vacuum}\n\\end{equation}\nfor the vacuum wave functional $\\cfun{\\exp}{-\\int_{-\\infty}^{+\\infty}\\dd p \\, \n\\vbr{p}\\vbr{\\rfun{g}{p}}^2}$.\n%\\begin{equation}\n%\\label{eq:vacuum-wave-functional-g}\n%\\end{equation}\nFor the thermal state, on the other hand, the correlator follows from\n\\cref{eq:correlator-multiple-thermal}, so that\n\\begin{align}\n\\abr{\\rfun{g^\\dagger}{p_1}\\rfun{g}{p_2}}_\\text{th} &=\n\\frac{\\coth\\frac{\\pp p_1}{\\lambda}}{2 p_1} \\rfun{\\delta}{p_1-p_2}\n\\nonumber \\\\\n&\\propto \\frac{1}{4T_\\text{HD}} \\frac{\\rfun{\\coth}{q/2}}{q/2}\n= \\frac{1}{4T_\\text{HD}}\\rbr{\\rbr{\\frac{q}{2}}^{-2} + \\frac{1}{3} + \n\\rfun{\\Omicron}{q}}.\n\\label{eq:correlator-thermal}\n\\end{align}\n\nOne sees immediately that \n\\cref{eq:correlator-pure,eq:correlator-vacuum,eq:correlator-thermal} vanish \nidentically for $p_1 \\neq p_2$, which is due to the absence of interaction in \nthe scalar field. The remaining diagonal terms have the meaning of \n\\emph{fluctuation} in field strength, because $\\abr{g} \\equiv 0$, so that\n\\begin{equation}\n\t\\abr{\\rbr{\\Delta g}^2} = \\abr{g^2} - \\abr{g}^2 \\equiv \\abr{g^2}.\n\\end{equation}\nIgnoring the $\\rfun{\\delta}{0}$ divergence, the fluctuations are plotted in\n\\cref{fig:fluc-Fourier}.\n\n\\begin{figure}\n\\begin{center}\n\\input{./graphics/graph_fluc_fourier}\n\\end{center}\n\\caption[Fluctuations of the Fourier modes]{Fluctuations of the Fourier modes \nof the field, plotted in log--log scales. The critical energy scale is the\nHawking temperature, below which the various fluctuations depart. The \ndiscrepancy between the pure and thermal descriptions is most significant for \nlow-energy modes, while for high energies the fluctuations of them and \nthe vacuum state are practically the same. Moreover, compared with vacuum, the \nlow-energy fluctuation of thermal case is enhanced, so it diverges faster than \nthat of vacuum; for the pure description, however, the fluctuation is \nsuppressed, such that it converges to a constant of order unity and does not \ndiverge any more. \\label{fig:fluc-Fourier}}\n\\end{figure}\n\n%------------------------------------------------------------------------------\n\\section{Discussion}\n\\label{sec:corr-discussion}\n%------------------------------------------------------------------------------\n\nIt has been noticed that the fluctuation discussed above has been extensively \nused in cosmology, see e.g.\\ \\cite{Glenz2009}. The fluctuation in the \nradiation field, however, looks different from that in cosmology and thus \nremains yet to be explained.\n\nMoreover, the most natural candidate to reveal the off-diagonal elements is the \ncorrelator in \\emph{real space}, which is just the Fourier transform of the \ncorrelator calculated above. Unfortunately, the transformation has yet to be \nmade for the thermal state due to an infra-red divergence.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../mythesis\"\n%%% End: \n\n", "meta": {"hexsha": "1ed8bfa3a602380702589e509b41ebdc48a8cb94", "size": 5208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ubonn-thesis-current/mythesis/sections/thesis_fluc.tex", "max_stars_repo_name": "cmp0xff/Masterarbeit", "max_stars_repo_head_hexsha": "b29c84f9a29e4a7c9a3499658a1dfa7f87d64c9c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ubonn-thesis-current/mythesis/sections/thesis_fluc.tex", "max_issues_repo_name": "cmp0xff/Masterarbeit", "max_issues_repo_head_hexsha": "b29c84f9a29e4a7c9a3499658a1dfa7f87d64c9c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ubonn-thesis-current/mythesis/sections/thesis_fluc.tex", "max_forks_repo_name": "cmp0xff/Masterarbeit", "max_forks_repo_head_hexsha": "b29c84f9a29e4a7c9a3499658a1dfa7f87d64c9c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.2869565217, "max_line_length": 80, "alphanum_fraction": 0.6653225806, "num_tokens": 1572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.4447905544203938}}
{"text": "% Created 2021-07-08 Thu 10:15\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=1610]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\DeclareMathOperator{\\shift}{q}\n\\DeclareMathOperator{\\diff}{p}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{2021-07-08}\n\\title{Discretizing continuous-time controllers}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Discretizing continuous-time controllers},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\n\\section{Intro}\n\\label{sec:org5096880}\n\n\\section{Discretization}\n\\label{sec:org497335f}\n\\begin{frame}[label={sec:orga5cf6e7}]{Context}\n\\begin{itemize}\n\\item Controller \\(F(s)\\) obtained from a design in continuous time.\n\\item Need discrete approxmation in order to implement on a computer\n\\end{itemize}\n\n\\begin{center}\n \\includegraphics[width=0.7\\linewidth]{../../figures/fig8-1.png}\\\\\n \\footnotesize Source: Åström \\& Wittenmark \n\\end{center}\n\\end{frame}\n\n\\section{Warm-up: Differentiation}\n\\label{sec:org1fa17cb}\n\n\\begin{frame}[label={sec:org07d6f70}]{Warm-up exercise}\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/block-simple-derivative}\n\\end{center}\n\n\\alert{Draw the Bode diagram for the transfer function}\n\\end{column}\n\\begin{column}{0.6\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/bode-derivative-empty}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org2b5bba8}]{Discrete-time differentiation}\n\\begin{center}\n\\begin{tabular}{lll}\n\\includegraphics[width=0.3\\linewidth]{../../figures/block-simple-shift-z} & \\(\\Leftrightarrow\\) & \\includegraphics[width=0.3\\linewidth]{../../figures/block-simple-shift}\\\\\n\\end{tabular}\n\\end{center}\n\n\n\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\vspace*{5mm}\n\n\\includegraphics[width=\\linewidth]{../../figures/block-simple-discrete-derivative-fwd}\n\n\\textcolor{white}{Space}\n\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/block-simple-discrete-derivative}\n\\end{center}\n\\end{column}\n\n\\begin{column}{0.6\\columnwidth}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:orgc048ecb}]{Discretization methods}\n\\begin{enumerate}\n\\item Forward difference. Substitute \n\\[ s = \\frac{z-1}{h} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{h}}. \\]\n\\item Backward difference. Substitute \n\\[ s = \\frac{z-1}{zh} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{zh}}. \\]\n\\end{enumerate}\n\\end{frame}\n\\begin{frame}[label={sec:org6c3e541}]{Discretization methods, contd.}\n\\begin{enumerate}\n\\setcounter{enumi}{2}\n\\item Tustin's method (also known as the bilinear transform). Substitute\n\\[ s = \\frac{2}{h}\\frac{z-1}{z+1} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{2}{h}\\cdot \\frac{z-1}{z+1}}. \\]\n\\item Ramp invariance. This is similar to ZoH, which is step-invariant approximation. \nSince a unit ramp has z-transform \\(\\frac{zh}{(z-1)^2}\\) and Laplace-transform \\(1/s^2\\),  the discretization becomes\n\\[ F_d(z) = \\frac{(z-1)^2}{zh} \\ztrf{\\laplaceinv{\\frac{F(s)}{s^2}}}. \\]\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}[label={sec:orgcde3040}]{Frequency warping using Tustin's}\n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{../../figures/fig8_3.png}\n\\end{center}\nThe infinite positive imaginary axis in the s-plane is mapped to the finite-length upper half of the unit circle in the z-plane.\n\\end{frame}\n\\begin{frame}[label={sec:org92aad28}]{Exercise}\nFind the discrete approximation of the lead-compensator \\(F(s) = \\frac{s+b}{s+a}\\), and determine the pole for \n\\begin{enumerate}\n\\item Forward difference. Substitute \n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{h}}. \\]\n\\item Backward difference. Substitute \n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{zh}}. \\]\n\\item Tustin's approximation\n\\[ F_d(z) = F(s')|_{s'=\\frac{2}{h}\\cdot \\frac{z-1}{z+1}}. \\]\n\\end{enumerate}\n\\end{frame}\n\\begin{frame}[label={sec:org4007077}]{Forward difference exercise}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/forward-diff-exercise}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org912e773}]{Backward difference exercise}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/backward-diff-exercise}\n\\end{center}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "677b858045154be2707849d861b680918d1c7531", "size": 4612, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "approximating-cont-controller/slides/lecture-discretize-trf.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "approximating-cont-controller/slides/lecture-discretize-trf.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "approximating-cont-controller/slides/lecture-discretize-trf.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 30.5430463576, "max_line_length": 171, "alphanum_fraction": 0.7205117086, "num_tokens": 1537, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.4447905540984904}}
{"text": "\\documentclass[11pt, letterpaper]{article}\n\n\\input{packages.tex}\n\n\\author{Thomas Alexander, Zachary Schoenfeld}\n\n\\title{Project: Optimal Control Theory with Qiskit Pulse}\n\n% Full command definitions\n\\input{imports/quantum_info.tex}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\section{Introduction}\nOptimal control theory studies how to optimally (given an objective) manipulate a quantum system\nto guide a state through a desired evolution given available classical\nstimulus sources. Qiskit Pulse exposes control of quantum computing\nstimulus sources through a standardized API, making lab-level experiments\npossible through the cloud. In Qiskit a quantum circuit is lowered to a pulse\nschedule through a scheduling procedure using predefined gate to pulse schedule\ncalibrations.\n\nThe aim of this project is to explore incorporating optimal control theory\ninto the Qiskit compilation pipeline with the aim of enabling on the fly\ngate design of arbitrary unitary evolutions for applications in Qiskit Aqua.\nSpecifically you will examine implementing GRAPE \\cite{khanejaOptimalControlCoupled2005c} on\na single-qubit IBM Quantum device.\nThis idea was explored in the work of Shi et. al. \\cite{shiOptimizedCompilationAggregated2019b}\n(see Figure \\ref{fig:compilationpipeline}) with their focus on dynamic gate\naggregation and design.\n\n\\begin{figure}[hbt!]\n \\centering\n \\includegraphics[width=\\linewidth]{../figures/yunong_pipeline.png}\n \\caption{Compilation pipeline proposed by Shi et. al., reproduced from \\cite{shiOptimizedCompilationAggregated2019b}.}\n \\label{fig:compilationpipeline}\n\\end{figure}\n\nWe will begin to build out this functionality into Qiskit.\nYou will take the first exploratory steps of performing optimal control on actual qubits with Qiskit\nPulse and then come up with a proposal for how to add this functionality\nto the Qiskit compilation pipeline in production.\n\n\\subsection{Overall Goals}\n\\begin{itemize}\n\\item Design and implement an optimal pulse control pipeline for constructing single qubit quantum gates\n\\item Develop your physics and software skills by applying them to optimal control theory\n\\item Gain exposure to the agile development processes and working with a full stack team across software and hardware\n\\item Have some fun!\n\\end{itemize}\n\n\n\\subsubsection{Technical Goals}\n\\begin{itemize}\n\\item Understand in a broad sense the engineering of superconducting qubits \\cite{blaisCavityQuantumElectrodynamics2004c, krantzQuantumEngineerGuide2019a}.\n\\item Bootstrap control of a qubit with Qiskit Pulse. See \\cite{CalibratingQubitsQiskit}.\n\\item Model the Hamiltonian of your system and simulate it.\n\\item Understand the goal of optimal control and how GRAPE works \\cite{khanejaOptimalControlCoupled2005c}.\n\\item Select a Python GRAPE package for incorporation into Qiskit. Examples include \\cite{QuantumOptimalControl, SchusterLabQuantumoptimalcontrol2020, abdelhafezGradientbasedOptimalControl2019, QuantumUtilsMathematica}.\n\\item Estimate the Hamiltonian of a single qubit with Qiskit Pulse \\cite{alexanderNotebooksDataQiskitPulse2020b, hincksHamiltonianLearningOnline2018, sheldonProcedureSystematicallyTuning2016b}.\n\\item Design arbitrary single qubit gates with Grape and Qiskit Pulse and characterize the gates with quantum process tomography \\cite{alexanderNotebooksDataQiskitPulse2020b}.\n\\item Hack automated gate design into the Qiskit compilation pipeline.\n\\item Write a report reviewing the relevant underlying theory, your methodology and findings performing optimal control theory with Qiskit pulse.\nInclude a design section proposing how to implement automated gate aggregation \\cite{shiOptimizedCompilationAggregated2019b} and compilation within Qiskit and any improvements that might be required.\n\\item Stretch goals (in no particular order other than what would be most fun for me)\n\n\\begin{itemize}\n\\item Estimate the Hamiltonian for a two-qubit system and design a two-qubit gate with Qiskit Pulse and GRAPE.\n\\item Reduce the runtime of an Aqua application with automated gate design.\n\\item Design a gate aggregation pass in the Qiskit transpiler to work with your pulse designer.\n\\item Suggest how to improve the usability of the Qiskit Pulse simulator.\n\\end{itemize}\n\\end{itemize}\n\n\\subsection{Workflow}\nDue to the nature of the situation with Covid-19 the internship will be remote.\nFortunately, this project is focused on Qiskit Pulse, which gives hardware access\nthrough the cloud. To help facilitate work both Thomas Alexander and\nZachary Schoenfeld will be providing supervision. Ben will partcipate in the\npulse teams agile sprints, demos and board. We will hold short, daily video\ncalls to synchronize our work. There will also be many other remote activities\nsetup for interns to network and socialize through the IBM Quantum Internship\nprogram.\\\\\n%\n\\\\\n%\nIBM Quantum intern hub: \\url{https://w3.ibm.com/w3publisher/quantum-interns}.\n\n\\subsection{Approximate Timeline (Subject to Change)}\n\nDates: 6/5/20-8/7/20 (8 weeks) \\\\\n\\\\\n%\nWeeks 1, 2\n\\begin{itemize}\n\\item Onboard\n\t\\begin{itemize}\n\t\t\\item Get onto w3, Slack, join standups and agile\n\t\\end{itemize}\n\\item Gain familiarity with IBM's quantum systems and pulse-level control (ask for more papers!)\n\\item Use Qiskit pulse to calibrate a qubit on a live device\n\\item \\textit{Suggestion}: Draft notes as you go. This will make writing the final report easier!\n\\end{itemize}\nWeeks 3, 4\n\\begin{itemize}\n\\item Model a 1q Hamiltonian with arbitrary drive pulse and simulate its evolution\n\t\\begin{itemize}\n\t\t\\item It may also be interesting to learn how to analytically solve this Hamiltonian for simple pulses shapes (RWA, etc)\n\t\\end{itemize}\n\\item Learn GRAPE and explore possible open source packages for implementation into Qiskit\n\\end{itemize}\nWeeks 5, 6\n\\begin{itemize}\n\\item Use chosen GRAPE package and Qiskit pulse to construct arbitrary 1q gates in an optimal fashion\n\\item Characterize these gates with Quantum Process Tomography\n\\item Begin to integrate GRAPE into the Qiskit compilation pipeline\n\\end{itemize}\nWeeks 7, 8\n\\begin{itemize}\n\\item As time permits, think about how to add gate aggregation passes \\cite{shiOptimizedCompilationAggregated2019b} to your work (design is more important; can implement if time)\n\\item Write up a report detailing the theory you learned about optimal pulse control, GRAPE and how you implemented it in Qiskit. More details provided in the \\textbf{Goals} section.\n\\item As time permits, work on the stretch goals outlined in the \\textbf{Goals} section\n\\item Offboard\n\\end{itemize}\n\n\n\n\\bibliographystyle{unsrt}\n\\bibliography{bibliography}\n\n\\end{document}\n", "meta": {"hexsha": "05e0e559629595761f0aa87d924ca85a0cfc5ff5", "size": 6610, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "oct-qiskit-pulse/reports/oct_qiskit_pulse/oct_qiskit_pulse.tex", "max_stars_repo_name": "brosand/qiskit-terra", "max_stars_repo_head_hexsha": "5152c642cce7e65c6cd583d9ba539a8f7f7f142a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "oct-qiskit-pulse/reports/oct_qiskit_pulse/oct_qiskit_pulse.tex", "max_issues_repo_name": "brosand/qiskit-terra", "max_issues_repo_head_hexsha": "5152c642cce7e65c6cd583d9ba539a8f7f7f142a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "oct-qiskit-pulse/reports/oct_qiskit_pulse/oct_qiskit_pulse.tex", "max_forks_repo_name": "brosand/qiskit-terra", "max_forks_repo_head_hexsha": "5152c642cce7e65c6cd583d9ba539a8f7f7f142a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.328358209, "max_line_length": 219, "alphanum_fraction": 0.8161875946, "num_tokens": 1601, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786991753929, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.4447905455930101}}
{"text": "\\documentclass[11pt]{extarticle}\n\\usepackage[a4paper, margin=1in]{geometry}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath,mathtools}\n\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{tcolorbox}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{xspace}\n\\usepackage{hyperref}\n\n\\usepackage{tabularx}\n\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{definition}{Definition}\n\n\n\\hypersetup{\n    colorlinks=true,\n    citecolor=blue,\n    linkcolor=blue,\n    filecolor=magenta,      \n    urlcolor=blue,\n}\n\\usepackage{xcolor, soul}\n\\newcommand{\\note}[1]{\\textcolor{purple}{\\small {#1}}}\n\\newcommand{\\tool}{{\\sc SynGuar}\\xspace}\n\\newcommand{\\toolvsa}{{\\sc SynGuar-PROSE}\\xspace}\n\\newcommand{\\toolstun}{{\\sc SynGuar-STUN}\\xspace}\n\\newcommand{\\parf}{g}\n\n\\newcommand{\\distrib}{D}\n\\newcommand{\\programsp}{H_S}\n\\newcommand{\\samples}[2]{m_\\programsp({#1}, {#2})}\n\\newcommand{\\synthalgo}{\\mathcal{A}(S)}\n\\newcommand{\\etal}{et al.\\xspace}\n\\newcommand{\\concept}{\\mathcal{C}}\n\\renewcommand{\\vec}[1]{\\mathbf{#1}}\n\n\\newcommand{\\prb}{\\mathop{\\text{Pr}}}\n\\newcommand{\\prbh}{\\mathop{\\text{Pr}}_{h_A\\in H}}\n\\newcommand{\\ep}{\\mathop{\\mathbb{E}}}\n\\newcommand{\\var}{\\textsf{Var}}\n\\newcommand{\\cov}{\\textsf{Cov}}\n\\newcommand{\\ind}{\\mathop{\\mathbb{I}}}\n\\newcommand{\\sothat}{\\text{ s.t. }}\n\n\\usepackage[numbers]{natbib}\n\n\\title{Mathematical Proofs for \\tool}\n\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Preliminaries}\n\n\\paragraph{Problem Setup.} We are given an oracle to sample i.i.d. I/O examples from some unknown distribution $\\distrib$, a synthesizer with bounded hypothesis space and the ability to soundly upper bound number of programs consistent with I/O examples, and user-specified $(\\epsilon,\\delta)$ parameters that capture the desired generalization guarantee. The synthesis algorithm queries the oracle for as many I/O examples as it needs and terminates with either $None$ or a synthesized function $f$. We assume that $f$ will satisfy all given I/O examples. We use $S$ to represent all the I/O examples queried by the synthesis algorithm until it terminates. The probability that the synthesizer returns a function $f$ that might not generalize should be under the given small $\\delta$, and the randomness is on I/O examples.\n\nFormally, the goal is for a synthesis algorithm to achieve a PAC-style $(\\epsilon,\\delta)$ generalization guarantee. We define $(\\epsilon,\\delta)$-synthesizer as the following:\n\n\\begin{definition}[$(\\epsilon,\\delta)$-synthesizer]\n\\label{def:eps-delta}\n  A synthesis algorithm $\\mathcal{A}$ with hypothesis space $H$ is an $(\\epsilon, \\delta)$-synthesizer with respect to a target class of\n  functions $\\concept$ iff for any input distributions $\\distrib$, for all $t\n  \\in \\concept$, $\\epsilon \\in (0, 0.5)$, $\\delta \\in (0, 0.5)$, if $\\synthalgo$ outputs a program $f \\in H$ on a set of samples $S$ drawn i.i.d from the $\\distrib$, then:\n%  \\bo{The event and condition of Pr seems inverted}\n  \\begin{align*}\n    Pr\\lbrack \\synthalgo~\\text{outputs}~ f \\text{ such that } error(f) > \\epsilon \\rbrack < \\delta\n  \\end{align*} \n\n\\end{definition}\n\n\\paragraph{A starting point.} The number of examples provably sufficient to achieve the $(\\epsilon, \\delta)$-generalization is given by Blumer \\etal~\\cite{blumer1987occam}. We restate this result, which computes sample complexity as a function of $(\\epsilon,\\delta)$ and the capacity (or size) of any given hypothesis space $H$.\n\n\\begin{theorem}[Sample Complexity for $(\\epsilon, \\delta)$-synthesis]\n  \\label{thm:static-union-bound}\nFor all $\\epsilon \\in (0,\\frac{1}{2})$, $\\delta\\in\n(0,\\frac{1}{2})$, hypothesis space $H$ and any target program $t$, a synthesis algorithm $\\synthalgo$ which outputs functions consistent with $n$ i.i.d samples is an $(\\epsilon, \\delta)$-synthesizer, if \n\\begin{align*}\n  n > \\frac{1}{\\epsilon}(\\ln |H| + \\ln\n  \\frac{1}{\\delta})\n\\end{align*}\n\n\\end{theorem}\n\n\\begin{proof}\nAssume the true concept (may or may not in the hypothesis space) is $t$ and all I/O examples are consistent with $t$.\nNow consider a single hypothesis $f\\in H$ first.\nLet $error(f) = L_{(\\mathcal{D},t)}(f)$ be the true error (expectation of 0-1 loss) $L_{(\\mathcal{D},t)}(f)=\\mathop{\\mathbb{E}}_{x\\sim\\mathcal{D}}\\mathbb{I}[t(x)\\neq f(x)]$,\nand let $L_{(\\mathcal{S},t)}(f)$ be the empirical error (empirical average of 0-1 loss) $L_{(\\mathcal{S},t)}(f)=\\frac{1}{|S|}\\sum_{x\\in S}\\mathbb{I}[t(x)\\neq f(x)]$,\nThe following holds:\n\\begin{align*}\n\\prb_{x\\in \\mathcal{D}} [\\mathbb{I}[t(x)\\neq f(x)] = 0 ~|~ L_{(\\mathcal{D},t)}(f) \\geq \\epsilon] \\leq (1-\\epsilon)\n\\end{align*}\nNow consider a sample $S$ with size $n$, the following holds:\n\\begin{align*}\n\\prb_{S\\in \\mathcal{D}^{n}} [L_{(\\mathcal{S},t)}(f) = 0 ~|~ L_{(\\mathcal{D},t)}(f) \\geq \\epsilon] \\leq (1-\\epsilon)^{n}\n\\end{align*}\n\nThen take union bound on all hypothesis in $H$:\n\\begin{align*}\n    &\\prb_{S\\in \\mathcal{D}^{n}} [\\exists f\\in H, ~L_{(\\mathcal{S},t)}(f) = 0 ~\\land~ L_{(\\mathcal{D},t)}(f) \\geq \\epsilon] \\leq |H|(1-\\epsilon)^{n} < \\delta\\\\\n    \\Rightarrow & ~n > \\frac{1}{\\epsilon}(\\ln |H| + \\ln\n    \\frac{1}{\\delta}) \\text{ suffices}\n\\end{align*}\n\nSo with sample size larger than $\\frac{1}{\\epsilon}(\\ln |H| + \\ln\n\\frac{1}{\\delta})$, with probability at least $1-\\delta$, all $f\\in H$ that \nhave true error larger than $\\epsilon$ have a non-zero empirical loss and will be ruled out\nand any hypothesis in $H$ that is still consistent with the sample has \ntrue error smaller than $\\epsilon$.\n\n\\end{proof}\n\n\\section{Analysis of \\tool}\n\n\\begin{algorithm}[t]\n    \\caption{\\tool Synthesis returns a program with error smaller than $\\epsilon$ with probability higher than $1-\\delta$}\n    \\label{alg:main}\n    \\begin{algorithmic}[1]\n      \\Procedure{\\tool}{$\\epsilon, \\delta$}\n      \\State $k = 1$ // tunable parameter\n      \\State $g \\gets \\Call{PickStoppingCond}{}$ \\label{alg:pick-cond}\n      \\State $S' \\gets \\varnothing, s \\gets 0$\n      \\State $size_{H} \\gets \\Call{ComputeSize}{H}$ \\label{alg:call-compute} \n      \\State $n \\gets g(size_{H})$\n      %\\While {$|S'| \\leq n$}\n      \\While {$s \\leq n$}\n      \\State $S' \\gets S' \\cup \\Call{sample}{k}$\n      \\State $H_{S'} \\gets $ \\Call{UpdateHypothesis}{$S'$} \\label{alg:call-update}\n      %\\State $H_{S'}$ = synthesize($S'$)\n      \\State $size_{H_{S'}} \\gets \\Call{ComputeSize}{H_{S'}}$ \\label{alg:call-compute}\n      \\State $s \\gets s + k$\n      \\State $n \\gets min(n, s+g(size_{H_{S'}}))$ \\label{alg:min-thresh}\n      \\EndWhile\n      \\State $m_{H_{S'}}=\\frac{1}{\\epsilon}(\\ln{size_{H_{S'}}} + ln{\\frac{1}{\\delta}})$\n      \\State $T \\gets \\Call{sample}{m_{H_{S'}}(\\epsilon, \\delta)}$\n      \\State $S \\gets S'\\cup T$ \n      \\State \\Return $f$ program in $H_S$\n      \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\tool's design is motivated by being able to give a formal generalization guarantee and a bounded sample complexity. For this purpose, we state and prove the following properties: \n% Here, we detail and prove these properties.\n\n\\noindent\\textbf{(P1: Termination)} \\tool always terminates for a finite $|H|$.\n\n\\noindent\\textbf{(P2: $(\\epsilon, \\delta)$ guarantees)} If \\tool returns an $f$ then $f$ is $\\epsilon$-far with probability $<\\delta$.\n\n\\noindent\\textbf{(P3: Sample complexity)} \\tool's sample complexity is always within 2$\\times$ of the optimal.\n\n\\begin{theorem}[P1]\n\\label{thm:p1}\n\\tool always terminates for a finite $|H|$.\n\\end{theorem}\n\\begin{proof}\nIt suffices to prove that the sampling phase (lines $7-13$) of \\tool terminates in order to show that \\tool terminates.\n%The phase can be concisely written as follows:\nIn each iteration of the sampling phase,  let $S_i$ be the queue storing the user-provided examples after each iteration, $z_t$ be the $t^\\text{th}$ example, $S_{i+1} = S_{i}\\cup \\{z_{ik+1},...z_{ik+k}\\}$ and $S_0=\\varnothing$. For each $S_i$, $H_{S_i}$ determines the set of consistent hypothesis that satisfy $S_i$. Let $N_i$ be the limit of  the number of I/O examples $n$ for the sampling phase after iteration $i$. \nFor iterations $i$ and $j$ where $i<j$ and $\\forall g:\\mathbb{N} \\rightarrow \\mathbb{Z}$ such that $g$ is monotonically non-decreasing, the following holds: \n\\begin{align*}\n  &S_i\\subset S_j \\Rightarrow |H_{S_j}|\\leq |H_{S_i}| \\Rightarrow g(|H_{S_j}|) \\leq g(|H_{S_i}|)\\\\\n  &N_j \\leq \\min\\{N_i, |S_j| + g(|H_{S_j}|)\\} \\leq N_i \\text{ (see line $13$ in Alg.~\\ref{alg:main})}\n\\end{align*}\nTherefore, if $N_0 \\leq g(|H|)$ then the loop will terminate at some iteration $p$ such that $N_p < |S_p| \\leq N_p + k \\leq N_0 + k$.\n\\end{proof}\n\n\\begin{theorem}[P2]\n\\label{thm:p2}\nIf \\tool($\\epsilon, \\delta$) returns the synthesized program $f$ then $f$ is $\\epsilon$-far with probability $<\\delta$.\n\\end{theorem}\n\\begin{proof}\nBy Theorem~\\ref{thm:p1}, we know that the sampling phase terminates with $S'$ samples (see line $14$). In lines $14-16$ \\tool samples an additional number of I/O examples required to generalize and then synthesizes a program after seeing the additional samples. Therefore, Theorem~\\ref{thm:p2} follows from Theorem~\\ref{thm:static-union-bound}.\n\\end{proof}\n% ====================================================\n\n% \\begin{theorem}{Sample Complexity}\n%     \\tool's sample complexity is within\n% $2\\times$ of the optimal.\n% \\end{theorem}\n\n% % The last property (P3) of \\tool is that its sample complexity is within\n% % $2\\times$ of the optimal. The optimal number of samples is determined by the\n% % shortest length prefix that guarantees that the algorithm returns with\n% % $(\\epsilon, \\delta)$ guarantees.\n% \\begin{proof}\n\n% \\end{proof}\nIn order to prove the last property, we define a new quantity $\\omega(Q)$. It is the smallest sample size taken by \\tool($\\epsilon, \\delta$) for any non-decreasing $g$ used for a sequence of I/O examples $Q$.\n\n\\begin{definition}[Smallest dynamic sample size]\n    For any infinite sampled sequence of examples $Q$, let $\\Call{Prefix}{Q,g}$ be the prefix of $Q$ at which \\tool($\\epsilon, \\delta$) terminates. Then,  \n    % In other word, it is like that the best  stopping condition that result in smallest sample size is known before seeing the examples.\n    $$\n    \\omega(Q) = \\inf \\{ |m_g|~:~\\forall g,\\text{ } m_g = \\Call{Prefix}{Q,g}\\}\n    $$\n\\end{definition}\n\n% Note that if we modify \\tool to always take $\\omega(Q)$ examples when the sampled sequence is $Q$, it is not an $(\\epsilon,\\delta)$-synthesizer.\n\n\\begin{theorem}[P3]\n\\label{thm:p3}\n\\tool uses no more than $2\\omega(Q)$ examples on any $Q$ when the result is not None with $\\parf(x) = \\parf_{0}(x)=\\max\\{0, ~\\frac{1}{\\epsilon}(\\ln(x)-\\ln(\\frac{1}{\\delta}))\\}$ and $k\\leq \\frac{1}{2\\epsilon}\\ln\\frac{1}{\\delta}$.\n\\end{theorem}\n\n\\begin{proof}\nLet $S'\\subset Q$ be the samples in sampling phase. Let $P$ be the samples when $\\omega(Q)=\\Call{Prefix}{Q,\\parf}$ for some $\\parf$ and let us call this the best stopping point for \\tool's sampling phase on $Q$. Then $\\omega(Q)=|P|+\\frac{1}{\\epsilon}(\\ln{|H_P|} + ln{\\frac{1}{\\delta}})$.\nLet $\\parf_0(x)=\\max\\{0, ~\\frac{1}{\\epsilon}(\\ln(x)-\\ln(1/\\delta))\\}$, $\\gamma(Q) = \\Call{Prefix}{Q,\\parf_0}$ and $S'\\subset Q$ be the samples in sampling phase.\n\nIf $P$ is the samples for the best stopping point, then\n\n$$\n\\omega(Q)=|P|+\\frac{1}{\\epsilon}(\\ln{|H_P|} + ln{\\frac{1}{\\delta}})\n$$\n\n\\noindent Case 1: \\tool using $\\parf_0$ is stopping earlier in phrase 1 than the best possible stopping point, $|S'| \\leq |P|$\n\\begin{align*}\n    \\gamma(Q) - 2\\cdot\\omega(Q) &= |S'|- 2\\cdot|P| +  \\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|} - 2\\cdot \\ln{|H_{P}|})\\\\ \n    &- \\frac{1}{\\epsilon}\\cdot\\ln{\\frac{1}{\\delta}}\\\\\n    & \\leq -|P| - \\frac{1}{\\epsilon}\\cdot\\ln{\\frac{1}{\\delta}} + \\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|})\\\\\n    &\\text{since }|S'| \\leq |P|\n\\end{align*}\nObserve that, for $\\parf_0(x)=\\max\\{0, ~\\frac{1}{\\epsilon}(\\ln(x)-\\ln(1/\\delta))\\} $ the \n$|S'| \\geq \\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|}-\\ln{\\frac{1}{\\delta}})$ (see, step $12$ in Algorithm $2$)\n\\begin{align*}\n    \\gamma(Q) - 2\\cdot\\omega(Q) \\leq -|P| + |S'| \\leq 0\n\\end{align*}\n\n\\noindent Case 2: \\tool using $\\parf_0$ is stopping after the best possible stopping point in phrase 1,  $|S'| > |P|$\n\nIn this case, $|H_{P}|\\ge|H_{S'}|$. Observe that $|S'| \\le \\omega(Q)$. Because for \\tool using $\\parf_0$, after seeing $P$, it will take no more than $\\parf_0(|H_{P}|) + 2k =\\max\\{0, \\frac{1}{\\epsilon}(\\ln{|H_{P}|} - ln{\\frac{1}{\\delta}})\\} + 2k \\leq \\frac{1}{\\epsilon}(\\ln{|H_P|} + ln{\\frac{1}{\\delta}})$ examples in phase 1.\n\\begin{align*}\n    |S'| &\\le |P| + 2k + \\parf_0(|H_{P}|)\\\\\n    \\omega(Q) &= |P| + \\frac{1}{\\epsilon}(\\ln{|H_{P}|} + ln{\\frac{1}{\\delta}})\\\\\n    &\\implies |S'| \\le \\omega(Q)\n\\end{align*}\nNow,\n\\begin{align*}\n    \\gamma(Q) - 2\\cdot\\omega(Q) &= |S'| + \\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|} + \\ln{\\frac{1}{\\delta}}) - 2\\cdot\\omega(Q)\\\\\n    &\\leq \\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|} + \\ln{\\frac{1}{\\delta}}) - \\omega(Q) \\quad(\\text{by } |S'| \\le \\omega(Q))\\\\\n    &\\leq -|P| +\\frac{1}{\\epsilon}\\cdot(\\ln{|H_{S'}|} - \\ln{|H_{P}|})\\\\\n    &\\leq 0 \\quad (\\text{since, }|H_{P}|\\ge|H_{S'}|)\n\\end{align*}\n\\end{proof}\n\n\\bibliographystyle{plainnat}\n\\bibliography{proofs}\n\n\\end{document}", "meta": {"hexsha": "c3f92053cceb04a5912eb5802517ae92d6822356", "size": 13129, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/proofs/proofs.tex", "max_stars_repo_name": "HALOCORE/SynGuar", "max_stars_repo_head_hexsha": "8f7f9ba52e83091ad3def501169fd60d20b28321", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-23T05:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-23T05:10:36.000Z", "max_issues_repo_path": "docs/proofs/proofs.tex", "max_issues_repo_name": "HALOCORE/SynGuar", "max_issues_repo_head_hexsha": "8f7f9ba52e83091ad3def501169fd60d20b28321", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/proofs/proofs.tex", "max_forks_repo_name": "HALOCORE/SynGuar", "max_forks_repo_head_hexsha": "8f7f9ba52e83091ad3def501169fd60d20b28321", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.0856031128, "max_line_length": 824, "alphanum_fraction": 0.6628075253, "num_tokens": 4508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710234, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4447905367656265}}
{"text": "\\documentclass[11pt,answers]{exam}\n\n% Preamble % (fold)\n\n\\usepackage[paper=letterpaper,margin=.75in,twoside=false,includehead]{geometry}\n\n\\usepackage{amsfonts,amsmath,amsthm,amssymb} \n\\usepackage{enumerate}\n\\usepackage{graphicx}\n\n\\usepackage{paralist}\n\\usepackage{multicol}\n\\usepackage{bm}\n\n\n\\let\\svthefootnote\\thefootnote\n\n\\newtheorem*{thm}{Theorem}\n\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\E}{\\mathbb{E}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\cP}{\\mathcal{P}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\e}{\\varepsilon}\n\n\n%\\printsolutions\n\n\\title{Communicating in Mathematics (MTH 210) Exam 1}\n\\date{February 12, 2020}\n\n\n\\begin{document}\n\n\n\n\\maketitle\n\n\\section*{Instructions}  \n\n\n\n\\noindent Write your answers in the spaces provided. If you run out of space, continue your work on the back of the page and indicate that you have done so. If you still need additional space then additional sheets are available. If you use scrap paper you must turn in your scrap paper with the exam. \\\\\n\n\\begin{center}\n\\textbf{If you aren't sure what to do, take a deep breath and just show me what you know.}\n\\end{center}\n\\vspace{1in}\n\n\n\n\n\\begin{center}\n\n\n\\begin{tabular}{|c|c|c|}\n\\hline\nSection &Score\\\\\n\\hline\nDefinitions and Notation &\\\\\n&\\\\\n\\hline\nLogic &\\\\\n&\\\\\n\\hline\nProofs and Counterexamples &\\\\\n&\\\\\n\\hline\nProof Section &\\\\\n&\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\n\\vspace{1in}\n\n\\begin{center}\nName (print): \\underline{\\hspace{3in}}  \n\\end{center}\n\n\n\n\n\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Definitions and Notation}\n\n\\begin{questions}\n\n\n\\question Complete the following definition:\n\\begin{center}\nA nonzero integer $a$ \\emph{divides} an integer $b$, denoted $a\\mid b$ provided that...\n\\end{center}\n\\vfill\n\n\\question Using the definition of divides, explain why, for any nonzero $a\\in\\Z$ we have that $a\\mid 0$.\n\\vfill\n\n\\question Complete the following definition:\n\\begin{center}\nLet $n\\in\\N$ and $a,b\\in\\Z$. Then $a\\equiv b \\pmod{n}$ provided that...\n\\end{center}\n\n\\vfill\n\n%\\question Give two integers $a$ and $b$ that are congruent modulo $7$. Briefly explain.\n%\\vfill\n\n\\question Let $A = \\{a \\in\\Z \\mid a\\equiv 2 \\pmod{3}\\}$. Write $A$ in roster notation. Include at least 4 numbers in your roster notation. Include a negative number if it makes sense to.\n\\vfill\n\n\n\\question Fill in the blank with one of the symbols $\\subseteq, =, \\in, \\not\\subseteq, \\not\\in$:\n\t\\begin{itemize}\n\t\\item $1 \\underline{\\hspace{.5in}} \\{1,2\\}$\\\\\n\t\n\t\\item $\\{2\\} \\underline{\\hspace{.5in}} \\{1,2\\}$\n\t\\end{itemize}\n\\end{questions}\n\\newpage\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Logic}\n\n\\begin{questions}\n\n\\question For this question consider the following conditional statement:\n\t\\begin{center}\n\tIf $a$ is an irrational number and $b$ is an irrational number then $a\\cdot b$ is an irrational number.\n\t\\end{center}\n\t\\begin{parts}\n\t\\part State the converse of the statement above. If the original statement is true, must the converse be true?\n\t\\vfill\n\t\n\t\\part State the contrapositive of the statement above. If the original statement is true, must the contrapositive be true?\n\t\\vfill\n\t\n\t\\part State the negation of the statement above. (Don't worry about starting a sentence with a math symbol here.) If the original statement is true, what can you say about the truth value of the negation?\n\t\\vfill\n\t\n\t\\end{parts}\n\n\\question Suppose that Sally made the following claim:\n\t\\begin{center}\n\tIf it snows then I will go skiing.\n\t\\end{center}\n\t\nYou find out that it did not snow, but Sally still went skiing. Is Sally's statement true or false? Justify your answer.\n\\vfill\n\\end{questions}\n\n\\newpage\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Proofs and Counterexamples}\n\n\\begin{questions}\n\\question Consider the following theorem:\n\t\\begin{thm}\n\tFor every integer $z$, if $8\\mid z-4$ then $8\\nmid z^2 - 1$.\n\t\\end{thm}\n\t\n\t\\begin{parts}\n\t\\part If you were going to do a direct proof to prove the given statement is true, what would you assume? What would you try to show? \\emph{Do not actually attempt to prove the statement.}\n\t\n\tAssume:\n\t\\vfill\n\t\n\tShow:\n\t\\vfill\n\t\n\n\t\\part If you were going to do a proof by contrapositive to prove the given statement is true, shat would you assume? What would you try to show?\n\n\tAssume:\n\t\\vfill\n\t\n\tShow:\n\t\\vfill\n\t\n\t\\part What would you have to demonstrate in order to prove the statement is false? Be specific, but \\emph{do not actually attempt to prove the statement is false.}\n\t\\vfill\n\t\n\t\t\\end{parts}\n\n\n\\end{questions}\n\n\\newpage\n\n\\section{Proofs}\n\nIMPORTANT DIRECTIONS: You need to do both of the following proofs. Each proof needs to be written according to our writing guidelines.  There next page is for the first proof (which you can just attach if you already have it) and the page after is for the second proof. You may use this page (and the backs of pages) for scratch work.\n\n\\begin{enumerate}\n\\item Prove the following theorem. If you did this proof before class you may just attach your work. The proof needs to be written according to our writing guidelines.\n\n\\begin{center}\nFor all integers $m$, if $m\\equiv 1 \\pmod{3}$ then $3m^2+7m+12\\equiv 1 \\pmod{3}$.\n\\end{center}\n\n\n\\item Prove the following theorem. You should write your proof according to our writing guidelines.\n\n\\begin{center}\nFor all integers $n$, $n^2$ is odd if and only if $n$ is odd.\n\\end{center}\n\n\n\\emph{Use the rest of this page for scratch work.}\n\n\n\\end{enumerate}\n\n\\newpage\n\n\\emph{Write your proof for 1 on this page. Make sure to include a theorem statement.}\n\n\n\\newpage\n\n\\emph{Write your proof for 1 on this page. Make sure to include a theorem statement.}\n\n\\end{document}\n", "meta": {"hexsha": "8b063b7e948fd2bc5589b24791c33c55082f0287", "size": 5606, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "from LDK/5-Exams/Exam1/210W20Exam1.tex", "max_stars_repo_name": "mkjanssen/discrete", "max_stars_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "from LDK/5-Exams/Exam1/210W20Exam1.tex", "max_issues_repo_name": "mkjanssen/discrete", "max_issues_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "from LDK/5-Exams/Exam1/210W20Exam1.tex", "max_forks_repo_name": "mkjanssen/discrete", "max_forks_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0600858369, "max_line_length": 334, "alphanum_fraction": 0.7163753122, "num_tokens": 1639, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.4447433388729179}}
{"text": "\\chapter{Background}\r\n\\index{Background\\emph{Background}}%\r\n\r\nMathematical Expressions MEs form an essential part of scientific\r\nand technical documents. Mathematical Expressions can be typeset or\r\nhandwritten which uses two dimensional arrangements of symbols to\r\ntransmit information. Recognizing both form of mathematical\r\nexpressions are challenging. A variation to handwritten ME is\r\ncursive handwriting. Unconstrained cursive property of such\r\nhandwritten expressions poses a major challenge to its recognition.\r\n\r\nGenerally speaking understanding and recognizing mathematical\r\nexpression, whether typeset or handwritten, involves three\r\nactivities: Expression localization, symbol recognition and\r\nsymbol-arrangement analysis. ME localization involves finding and\r\nextracting mathematical expression from the document. Symbol\r\nrecognition converts the extracted expression image into a set of\r\nsymbols and symbol arrangement analyzes the spatial arrangement of\r\nset of symbols to recover the information content of the given\r\nmathematical notations.\r\n\r\nNow based on the recognition process, symbol recognition activity\r\ncan further subdivided as 1) preprocessing - noise reduction,\r\ndeskewing, slant correction etc, 2) segmentation to isolate symbols\r\n3) and finally, recognition. Similarly depending upon the\r\nsymbol-arrangement algorithm, symbol arrangement analysis can be\r\nfurther subdivided into a) identification of spatial relationships\r\namong symbols b) identification of logical relationships among\r\nsymbols 3) construction of meaning. These processes can be executed\r\nin series or in parallel with latter processes providing contextual\r\nfeedback for the earlier processes. The order of these recognition\r\nactivities can vary somewhat, for example, partial identification of\r\nspatial and logical relationships can be performed prior to symbol\r\nrecognition.\r\n\r\n\\section{Preprocessing}\r\n\\index{Preprocessing@\\emph{Preprocessing}}%\r\n\r\nPreprocessing is required to eliminate irregularities and noise from\r\nthe image, especially in handwritten character recognition. Certain\r\npreprocessing method requirements may depend upon the techniques\r\nused for recognition. \\cite{gyeonghwan1997lda} uses chain code\r\nmethod for handwritten image representation. Preprocessing involves\r\nslant angle correction in which global slant angle from different\r\nvertical lines is estimated and tangent of the estimated global\r\nslant angle is used to correct for slant. Smoothing of image\r\ninvolves elimination of small blobs (noise) on the contour. A\r\nsliding 3-component one dimensional window is applied overall\r\ncomponents during which components are removed or added based on the\r\norientation of components. Average stroke width is estimated by\r\ndividing chain code contours horizontally and by tracing left to\r\nright various distances between outer and inner contour.\r\n\\cite{jcai1999issi} performs size normalization to reduce variation\r\nin character size. To avoid significant deformation due to directly\r\nscaling of all images to identical size, a holistic approach is used\r\nfor scaling in which if width/height ratio is less than 0.8 then\r\nscale is identical horizontally and vertically otherwise the scale\r\nfactor is set to 0.8 to prevent large variation in image width.\r\n\r\n\\section{Character segmentation}\r\n\\index{Character segmentation@\\emph{Character segmentation}}%\r\n\r\nCharacter segmentation, next step in ME recognition, has long been a\r\ncritical area of OCR process. Depending upon the requirement,\r\ncharacter segmentation techniques is divided into four major\r\nheadings \\cite{CaseyLecolinet1996}. Classical approach of\r\nsegmentation also called dissection technique consists of\r\npartitioning the input image into sub-images based on their inherent\r\nfeatures, which are then classified. Another approach to\r\nsegmentation is a group of techniques that avoids dissection and\r\nsegments to image either explicitly by classification of\r\npre-specified windows, or implicitly by classification of subsets of\r\nspatial features collected from the image as a whole. Another\r\napproach is a hybrid approach employing dissection but using\r\nclassification to select from admissible segmentation possibility.\r\nFinally holistic approach avoids segmentation process itself and\r\nperforms recognition entire character strings.\r\n\r\nVarious techniques have been used for segmentation that involves\r\ndissection. White spaces between the characters are used to detect\r\nsegmentation points. Pitch which is the number of characters per\r\nunit of horizontal distance provides a basis for estimating\r\nsegmentation points. The segmentation points obtained for a given\r\nline should be approximately equally spaced at the distance that\r\ncorresponds to pitch \\cite{CaseyLecolinet1996}.\r\n\r\nInter-character boundaries can be obtained if most segmentation\r\ntakes place by finding columns of white. Now all segmentation points\r\nthat do not lie near these boundaries can be rejected as caused due\r\nto broken characters. Similarly we can estimate missed points due to\r\nmerged characters. Hoffman and McCullough gave a framework for\r\nsegmentation that involves three steps i.e. 1) Detection of the\r\nstart of the character, 2) A decision to begin testing for the end\r\nof a character called sectioning, 3) Detection of end-of-character.\r\nSectioning is done by weighted analysis of horizontal black runs\r\ncompleted versus run still incomplete.  Once sectioning determines\r\nthe regions of segmentation, rules were invoked to segment based on\r\neither an increase in bit density or the use of special features\r\ndesigned to detect end-of-character.\r\n\r\nIn \\cite{arica2002ocr}, segmentation in cursive handwritten\r\ncharacters is performed in the binary word image by using the\r\ncontour of the writing. Determination of segmentation regions is\r\ndone in three steps. In first step a straight line is drawn in the\r\nslant angle direction from each local maximum until the top of the\r\nword image. While going upward in the slant direction, if any\r\ncontour pixel is hit, this contour is followed until the slope of\r\nthe contour changes to the opposite direction. An abrupt change in\r\nthe slope of the contour indicates an end point. A line is drawn\r\nfrom the maximum to the end point and path continues to go upward in\r\nslant direction until the top of the word image. In step 2, a path\r\nin the slant direction from each maximum to the lower baseline, is\r\ndrawn. Step 3 follows the same process as in step 1 in order to\r\ndetermine the path from lower baseline to the bottom of the word\r\nimage. Combining all the three steps gives the segmentation regions.\r\nIn \\cite{gyeonghwan1997lda} segmentation involves detecting\r\nligatures as segmentation points in cursive scripts. Alternatively,\r\nconcavity features in the upper contour and convexities in the lower\r\ncontour are used in conjunction with ligatures to reduce the number\r\nof potentials segmentation points.\r\n\r\nAnother dissection technique that applies to non-cursive characters\r\nis bounding box technique \\cite{CaseyLecolinet1996}. In this\r\nanalysis, the adjacency relationships between characters are tested\r\nto perform merging or their size or aspect ratios are calculated to\r\ntrigger splitting mechanisms.  Another involves splitting of\r\nconnected components. Connected components are merged or split\r\naccording to rules based on height and width of the bounding boxes.\r\nIntersection of two characters can give rise to special image\r\nfeatures and different dissection methods have been developed to\r\ndetect these features and to use them in splitting a character\r\nstring images into sub-images.\r\n\r\n\\cite{chen2000sso} focuses on segmentation of single and multiple\r\ntouching character segmentation. \\cite{chen2000sso} proposes a new\r\ntechnique that links the feature points on the foreground and\r\nbackground alternately to get the possible segmentation path.\r\nMixture Gaussian probability function is determined and used to rank\r\nall the possible segmentation paths. Segmentation paths construction\r\nis performed separately for single touching characters and for\r\nmultiple touching characters. All the paths from to two analysis are\r\ncollectively processed to remove useless strokes and then mixture\r\nGaussian probability function is applied to decide which on is the\r\nbest segmentation path.\r\n\r\nAnother kind of approach to character segmentation is recognition\r\nbased approach. In these segmentation processes letter segmentation\r\nis a by-product of letter recognition. The basic principle is use a\r\nmobile window of variable width to provide sequences of tentative\r\nsegmentation which are confirmed (or not) by character recognition.\r\nA technique called Shortest Path Segmentation selects the optimal\r\ncombination of cuts from the predefined set of candidate cuts that\r\nconstruct all possible legal segments through combination. A graph\r\nwhose nodes represent acceptable segments is the created. The paths\r\nof these graphs represent all legal segmentations of the word. Each\r\nnode of the graph is then assigned a distance obtained by the neural\r\nnet recognizer. The shortest path though the graph thus corresponds\r\nto the best recognition and segmentation of the word. An alternative\r\nmethod attempts to match subgraphs of features with predefined\r\ncharacter prototypes. Different alternative are represented by a\r\ndirected network whose nodes correspond to the matched subgraphs.\r\nWord recognition is done by searching for the path that gives the\r\nbest interpretation of the word features.\r\n\r\n\\section{Symbol-Arrangement Analysis}\r\n\\index{Symbol-Arrangement Analysis@\\emph{Symbol-Arrangement Analysis}}%\r\n\r\nOne approach to symbol-arrangement analysis is syntactic approach.\r\nSyntactic approach makes use of two dimensional grammar rules to\r\ndefine the correct grouping of math symbols. Co-ordinate grammar for\r\nrecognition is presented by Anderson. The grammar specifies\r\nsyntactic rules that subdivide the set of symbols into several\r\nsubsets, each with its own syntactic subgoal. The final\r\ninterpretation result is given by the m attribute of the grammar\r\nstart's symbol where m represents ASCII encoding of the meaning of\r\nsymbol-set. Although coordinate grammar provides a clear and well\r\nstructured recognition approach, its slow parsing speed and\r\ndifficulty to handle errors are its major drawbacks. In [8], a\r\nsyntactic approach is adopted in which a system consisting of\r\nhierarchy of parsers for the interpretation of 2-D mathematical\r\nformulas is described. The ME interpreter consists of two syntactic\r\nparser top-down and bottom-up. It starts with a priority operator in\r\nthe expression to be analyzed and tries to divide it into\r\nsub-expressions or operands which are then analyzed in the same way\r\nand so on. The bottom-up parser chooses from the starting character\r\nand from the neighboring sub-expressions the corresponding rule in\r\nthe grammar. This rule gives instructions to the top-down parser to\r\ndelimit the zones of neighboring operands and operators.\r\n\r\nGarain and Chaudhari in \\cite{garain2004roh}, proposes a two pass\r\napproach to determine arrangement of symbols. The first pass is a\r\nscanning or lexicon analysis that performs micro-level examination\r\nof the symbols to determine the symbol groups and to determine their\r\ncategories or descriptors. The second pass is parsing or syntax\r\nanalysis that processes the descriptors synthesized in the first\r\npass to determine the syntactical structure of the expression. A set\r\nof predefined rules guides the activities in both the passes.\r\n\r\nAnother symbol-arrangement analysis approach is projection profile\r\ncutting. It involves recursive projection-profile cutting. Cutting\r\nby the vertical projection profile is attempted first, followed by\r\nhorizontal cuts for each resulting regions. The process repeats\r\nuntil no further cutting is possible. The resulting spatial\r\nrelationships are represented by a tree structure.  Although the\r\nmethod looks simple and efficient technique, it is still under study\r\nand also involves additional processing for symbols like square\r\nroot, subscripts and superscripts as these can be handled by\r\nprojection profile cut.\r\n\r\nAnother approach discussed is the Graph Rewriting. Graph rewriting\r\ninvolves information represented as an attributed graph and the\r\ngraph get updated through the application of graph-rewriting rules.\r\nAn initial graph contains one node to represent each symbol, with\r\nnodes attributes recording the spatial coordinates of the symbol.\r\nGraph rewriting rules are applied to add edges representing\r\nmeaningful spatial relationships. Rules are further applied to prune\r\nor modify these edges identifying logical relationships from the\r\nspatial relationships. In [7], Ann Grbavec and Dorothea Blostein\r\nproposed a novel-graph rewriting techniques that addresses the\r\nrecursive structure of mathematical notations, the critical\r\ndependence of the meaning upon operator precedence and the presence\r\nof ambiguities that depends upon global context. The recognition\r\nsystem proposed called EXPRESSO, is based on\r\nBuild-Constrain-Rank-Incorporate model where the Build phase\r\nconstructs edges to represent potentially meaningful spatial\r\nrelation- ships between symbols. The Constrain phase applies\r\ninformation about the notational conventions of mathematics to\r\nremove contra- dictions and resolve ambiguities. The Rank phase uses\r\ninformation about the operator precedence to group symbols into\r\nsub-expressions and the Incorporate phase interprets\r\nsub-expressions.\r\n\r\nTwaakyondo and Okamoto \\cite{twaakyondo1995saa} discuss two basic\r\nstrategies to decide the layout of structure of the given\r\nexpression. One strategy is to check the local structures of the\r\nsub-expressions using a bottom-up method (specific structure\r\nprocessing). It is used to analyze nested structures like\r\nsubscripts, superscripts and root expressions. The other strategy is\r\nto check the global structure of the whole expression by a top-down\r\nmethod (fundamental structure processing). It is used to analyze the\r\nhorizontal and vertical relations between sub-expressions. The\r\nstructure of the expression is represented as a tree structure.\r\n\r\nChou in [11] proposed a two-dimensional stochastic context-free\r\ngrammar for recognition of printed mathematical expressions. The\r\nrecognized symbols are parsed with the grammar in which each\r\nproduction rule has an associated probability. The main task of the\r\nprocess is to find the most probable parse tree for the input\r\nexpression. The overall probability of a parse tree is computed by\r\nmultiplying together the probabilities for all the production rules\r\nused in a successful parse.\r\n\r\n\\section{Conclusion}\r\n\\index{Conclusion@\\emph{Conclusion}}%\r\n\r\nAs we saw through the survey, there have been tremendous advances in\r\nthe field of character recognition from so many years of research.\r\nSome experiment tried to focus on one activity of recognition\r\nprocess while other tried to build a complete system for character\r\nrecognition. Some researchers assumed complete well recognized\r\nsymbols are given and they focus on the symbol-arrangement\r\n(structural) analysis of the recognized symbols. This survey\r\nconcentrated mainly on the two activities of character recognition\r\ni.e. segmentation of symbols and symbol-arrangement of recognized\r\nsymbols.\r\n\r\nSegmentation processes discussed have some limitations such as some\r\nare restricted to be applied to cursive handwriting while other\r\nfocuses on non-cursive handwriting. Some researchers focus on\r\ncertain subset of mathematical symbols because of large mathematical\r\nsymbol set. Some concentrate on single touching characters some on\r\nmultiple touching characters. Certain approaches of segmentation\r\nlike holistic approach that recognizes entire word as a unit have\r\ndrawback of being restricted to predefined lexicons. Hence more\r\nefficient and robust segmentation process is required as further\r\nanalysis of ME recognition depends on segmentation and recognition\r\nof symbols.\r\n\r\nSymbol-arrangement analysis discussed shows wide variations in\r\napproaches. Some approach exploits the operator precedence property\r\nof mathematical expression while some performs different level of\r\nanalysis (lexicon and syntax) to first group symbols into different\r\ncategories and then perform structural analysis using predefined\r\nrules. Some using graph rewriting technique in which mathematical\r\nsymbols are linked to each other through graph rewriting rules. Some\r\nuse stochastic grammar rules to represent to the relationship\r\nbetween symbols while some intelligently looks for local structures\r\nof the expression to determine the features like nested, above or\r\nbelow followed by global analysis to check for the correctness of\r\nthe expression as a whole and rectify wrong arrangements of symbols.\r\nSymbol arrangement analysis may be not so crucial for problems that\r\ninvolve only standard English character but problems like\r\nrecognition of mathematical expressions where the actual position\r\nand location of symbols is important and there are many implicit\r\nmeaning to symbols which depends on their arrangement, it is\r\nabsolutely important to perform symbol arrangement analysis for\r\nbetter recognition result.\r\n", "meta": {"hexsha": "8c6125f410b7e1e469c391753c8a14baf417de91", "size": 17229, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter-background.tex", "max_stars_repo_name": "tlogan/communication_in_concurrent_ml", "max_stars_repo_head_hexsha": "24bc2c8d33d9e499ec8dcc4124e243c4c09d7ef2", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter-background.tex", "max_issues_repo_name": "tlogan/communication_in_concurrent_ml", "max_issues_repo_head_hexsha": "24bc2c8d33d9e499ec8dcc4124e243c4c09d7ef2", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter-background.tex", "max_forks_repo_name": "tlogan/communication_in_concurrent_ml", "max_forks_repo_head_hexsha": "24bc2c8d33d9e499ec8dcc4124e243c4c09d7ef2", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.8154362416, "max_line_length": 72, "alphanum_fraction": 0.8225085611, "num_tokens": 3277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.44465215737907937}}
{"text": "\\vfill \\eject\n\\section{{\\tt allInOne.c} -- A Serial $LU$ Driver Program}\n\\label{section:LU-MPI-driver}\n\n\\begin{verbatim}\n/*  allInOneMPI.c  */\n\n#include \"../spoolesMPI.h\"\n#include \"../../timings.h\"\n\n/*--------------------------------------------------------------------*/\nint\nmain ( int argc, char *argv[] ) {\n/*\n   ------------------------------------------------------------\n   all-in-one MPI program for each process\n\n   order, factor and solve A X = Y\n\n   ( 1) read in matrix entries and form InpMtx object for A\n   ( 2) order the system using minimum degree\n   ( 3) permute the front tree\n   ( 4) create the owners map IV object\n   ( 5) permute the matrix A and redistribute\n   ( 6) compute the symbolic factorization \n   ( 7) compute the numeric factorization\n   ( 8) split the factors into submatrices\n   ( 9) create the submatrix map and redistribute\n   (10) read in right hand side entries \n        and form dense matrix DenseMtx object for Y\n   (11) permute and redistribute Y\n   (12) solve the linear system\n   (13) gather X on processor 0\n\n   created -- 98jun13, cca\n   ------------------------------------------------------------\n*/\n/*--------------------------------------------------------------------*/\nchar            buffer[20] ;\nChv             *rootchv ;\nChvManager      *chvmanager ;\nDenseMtx        *mtxX, *mtxY, *newY ;\nSubMtxManager   *mtxmanager, *solvemanager ;\nFrontMtx        *frontmtx ;\nInpMtx          *mtxA, *newA ;\ndouble          cutoff, droptol = 0.0, minops, tau = 100. ;\ndouble          cpus[20] ;\ndouble          *opcounts ;\nDV              *cumopsDV ;\nETree           *frontETree ;\nFILE            *inputFile, *msgFile ;\nGraph           *graph ;\nint             error, firsttag, ient, irow, jcol, lookahead = 0, \n                msglvl, myid, nedges, nent, neqns, nmycol, nproc, nrhs,\n                nrow, pivotingflag, root, seed, symmetryflag, type ;\nint             stats[20] ;\nint             *rowind ;\nIV              *oldToNewIV, *ownedColumnsIV, *ownersIV, \n                *newToOldIV, *vtxmapIV ;\nIVL             *adjIVL, *symbfacIVL ;\nSolveMap        *solvemap ;\n/*--------------------------------------------------------------------*/\n/*\n   ---------------------------------------------------------------\n   find out the identity of this process and the number of process\n   ---------------------------------------------------------------\n*/\nMPI_Init(&argc, &argv) ;\nMPI_Comm_rank(MPI_COMM_WORLD, &myid) ;\nMPI_Comm_size(MPI_COMM_WORLD, &nproc) ;\n/*--------------------------------------------------------------------*/\n/*\n   --------------------\n   get input parameters\n   --------------------\n*/\nif ( argc != 7 ) {\n   fprintf(stdout, \n      \"\\n usage: %s msglvl msgFile type symmetryflag pivotingflag seed\"\n      \"\\n    msglvl -- message level\"\n      \"\\n    msgFile -- message file\"\n      \"\\n    type    -- type of entries\"\n      \"\\n      1 (SPOOLES_REAL)    -- real entries\"\n      \"\\n      2 (SPOOLES_COMPLEX) -- complex entries\"\n      \"\\n    symmetryflag -- type of matrix\"\n      \"\\n      0 (SPOOLES_SYMMETRIC)    -- symmetric entries\"\n      \"\\n      1 (SPOOLES_HERMITIAN)    -- Hermitian entries\"\n      \"\\n      2 (SPOOLES_NONSYMMETRIC) -- nonsymmetric entries\"\n      \"\\n    pivotingflag -- type of pivoting\"\n      \"\\n      0 (SPOOLES_NO_PIVOTING) -- no pivoting used\"\n      \"\\n      1 (SPOOLES_PIVOTING)    -- pivoting used\"\n      \"\\n    seed -- random number seed\"\n      \"\\n    \"\n      \"\\n   note: matrix entries are read in from matrix.k.input\"\n      \"\\n         where k is the process number\"\n      \"\\n   note: rhs entries are read in from rhs.k.input\"\n      \"\\n         where k is the process number\"\n      \"\\n\", argv[0]) ;\n   return(0) ;\n}\nmsglvl = atoi(argv[1]) ;\nif ( strcmp(argv[2], \"stdout\") == 0 ) {\n   msgFile = stdout ;\n} else {\n   sprintf(buffer, \"res.%d\", myid) ;\n   if ( (msgFile = fopen(buffer, \"w\")) == NULL ) {\n      fprintf(stderr, \"\\n fatal error in %s\"\n              \"\\n unable to open file %s\\n\",\n              argv[0], buffer) ;\n      return(-1) ;\n   }\n}\ntype         = atoi(argv[3]) ;\nsymmetryflag = atoi(argv[4]) ;\npivotingflag = atoi(argv[5]) ;\nseed         = atoi(argv[6]) ;\nIVzero(20, stats) ;\nDVzero(20, cpus) ;\n/*--------------------------------------------------------------------*/\n/*\n   --------------------------------------------\n   STEP 1: read the entries from the input file \n           and create the InpMtx object\n   --------------------------------------------\n*/\nsprintf(buffer, \"matrix.%d.input\", myid) ;\ninputFile = fopen(buffer, \"r\") ;\nfscanf(inputFile, \"%d %d %d\", &neqns, &neqns, &nent) ;\nmtxA = InpMtx_new() ;\nInpMtx_init(mtxA, INPMTX_BY_ROWS, type, nent, 0) ;\nif ( type == SPOOLES_REAL ) {\n   double   value ;\n   for ( ient = 0 ; ient < nent ; ient++ ) {\n      fscanf(inputFile, \"%d %d %le\", &irow, &jcol, &value) ;\n      InpMtx_inputRealEntry(mtxA, irow, jcol, value) ;\n   }\n} else if ( type == SPOOLES_COMPLEX ) {\n   double   imag, real ;\n   for ( ient = 0 ; ient < nent ; ient++ ) {\n      fscanf(inputFile, \"%d %d %le %le\", &irow, &jcol, &real, &imag) ;\n      InpMtx_inputComplexEntry(mtxA, irow, jcol, real, imag) ;\n   }\n}\nfclose(inputFile) ;\nInpMtx_sortAndCompress(mtxA) ;\nInpMtx_changeStorageMode(mtxA, INPMTX_BY_VECTORS) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n input matrix\") ;\n   InpMtx_writeForHumanEye(mtxA, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ----------------------------------------------------\n   STEP 2: read the rhs entries from the rhs input file \n   and create the DenseMtx object for Y\n   ----------------------------------------------------\n*/\nsprintf(buffer, \"rhs.%d.input\", myid) ;\ninputFile = fopen(buffer, \"r\") ;\nfscanf(inputFile, \"%d %d\", &nrow, &nrhs) ;\nmtxY = DenseMtx_new() ;\nDenseMtx_init(mtxY, type, 0, 0, nrow, nrhs, 1, nrow) ;\nDenseMtx_rowIndices(mtxY, &nrow, &rowind) ;\nif ( type == SPOOLES_REAL ) {\n   double   value ;\n   for ( irow = 0 ; irow < nrow ; irow++ ) {\n      fscanf(inputFile, \"%d\", rowind + irow) ;\n      for ( jcol = 0 ; jcol < nrhs ; jcol++ ) {\n         fscanf(inputFile, \"%le\", &value) ;\n         DenseMtx_setRealEntry(mtxY, irow, jcol, value) ;\n      }\n   }\n} if ( type == SPOOLES_COMPLEX ) {\n   double   imag, real ;\n   for ( irow = 0 ; irow < nrow ; irow++ ) {\n      fscanf(inputFile, \"%d\", rowind + irow) ;\n      for ( jcol = 0 ; jcol < nrhs ; jcol++ ) {\n         fscanf(inputFile, \"%le %le\", &real, &imag) ;\n         DenseMtx_setComplexEntry(mtxY, irow, jcol, real, imag) ;\n      }\n   }\n}\nfclose(inputFile) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n rhs matrix in original ordering\") ;\n   DenseMtx_writeForHumanEye(mtxY, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   -------------------------------------------------------\n   STEP 2 : find a low-fill ordering\n   (1) create the Graph object\n   (2) order the graph using multiple minimum degree\n   (3) find out who has the best ordering w.r.t. op count,\n       and broadcast that front tree object\n   -------------------------------------------------------\n*/\ngraph = Graph_new() ;\nadjIVL = InpMtx_MPI_fullAdjacency(mtxA, stats, \n                                  msglvl, msgFile, MPI_COMM_WORLD) ;\nnedges = IVL_tsize(adjIVL) ;\nGraph_init2(graph, 0, neqns, 0, nedges, neqns, nedges, adjIVL,\n            NULL, NULL) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n graph of the input matrix\") ;\n   Graph_writeForHumanEye(graph, msgFile) ;\n   fflush(msgFile) ;\n}\nfrontETree = orderViaMMD(graph, seed + myid, msglvl, msgFile) ;\nGraph_free(graph) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n front tree from ordering\") ;\n   ETree_writeForHumanEye(frontETree, msgFile) ;\n   fflush(msgFile) ;\n}\nopcounts = DVinit(nproc, 0.0) ;\nopcounts[myid] = ETree_nFactorOps(frontETree, type, symmetryflag) ;\nMPI_Allgather((void *) &opcounts[myid], 1, MPI_DOUBLE,\n              (void *) opcounts, 1, MPI_DOUBLE, MPI_COMM_WORLD) ;\nminops = DVmin(nproc, opcounts, &root) ;\nDVfree(opcounts) ;\nfrontETree = ETree_MPI_Bcast(frontETree, root, \n                             msglvl, msgFile, MPI_COMM_WORLD) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n best front tree\") ;\n   ETree_writeForHumanEye(frontETree, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   -------------------------------------------------------\n   STEP 3: get the permutations, permute the front tree,\n           permute the matrix and right hand side.\n   -------------------------------------------------------\n*/\noldToNewIV = ETree_oldToNewVtxPerm(frontETree) ;\nnewToOldIV = ETree_newToOldVtxPerm(frontETree) ;\nETree_permuteVertices(frontETree, oldToNewIV) ;\nInpMtx_permute(mtxA, IV_entries(oldToNewIV), IV_entries(oldToNewIV)) ;\nif (  symmetryflag == SPOOLES_SYMMETRIC \n   || symmetryflag == SPOOLES_HERMITIAN ) { \n   InpMtx_mapToUpperTriangle(mtxA) ;\n}\nInpMtx_changeCoordType(mtxA, INPMTX_BY_CHEVRONS) ;\nInpMtx_changeStorageMode(mtxA, INPMTX_BY_VECTORS) ;\nDenseMtx_permuteRows(mtxY, oldToNewIV) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n rhs matrix in new ordering\") ;\n   DenseMtx_writeForHumanEye(mtxY, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   -------------------------------------------\n   STEP 4: generate the owners map IV object\n           and the map from vertices to owners\n   -------------------------------------------\n*/\ncutoff   = 1./(2*nproc) ;\ncumopsDV = DV_new() ;\nDV_init(cumopsDV, nproc, NULL) ;\nownersIV = ETree_ddMap(frontETree, \n                       type, symmetryflag, cumopsDV, cutoff) ;\nDV_free(cumopsDV) ;\nvtxmapIV = IV_new() ;\nIV_init(vtxmapIV, neqns, NULL) ;\nIVgather(neqns, IV_entries(vtxmapIV), \n         IV_entries(ownersIV), ETree_vtxToFront(frontETree)) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n map from fronts to owning processes\") ;\n   IV_writeForHumanEye(ownersIV, msgFile) ;\n   fprintf(msgFile, \"\\n\\n map from vertices to owning processes\") ;\n   IV_writeForHumanEye(vtxmapIV, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ---------------------------------------------------\n   STEP 5: redistribute the matrix and right hand side\n   ---------------------------------------------------\n*/\nfirsttag = 0 ;\nnewA = InpMtx_MPI_split(mtxA, vtxmapIV, stats, \n                        msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nfirsttag++ ;\nInpMtx_free(mtxA) ;\nmtxA = newA ;\nInpMtx_changeStorageMode(mtxA, INPMTX_BY_VECTORS) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n split InpMtx\") ;\n   InpMtx_writeForHumanEye(mtxA, msgFile) ;\n   fflush(msgFile) ;\n}\nnewY = DenseMtx_MPI_splitByRows(mtxY, vtxmapIV, stats, msglvl, \n                                msgFile, firsttag, MPI_COMM_WORLD) ;\nDenseMtx_free(mtxY) ;\nmtxY = newY ;\nfirsttag += nproc ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n split DenseMtx Y\") ;\n   DenseMtx_writeForHumanEye(mtxY, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ------------------------------------------\n   STEP 6: compute the symbolic factorization\n   ------------------------------------------\n*/\nsymbfacIVL = SymbFac_MPI_initFromInpMtx(frontETree, ownersIV, mtxA,\n                     stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nfirsttag += frontETree->nfront ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n local symbolic factorization\") ;\n   IVL_writeForHumanEye(symbfacIVL, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   -----------------------------------\n   STEP 7: initialize the front matrix\n   -----------------------------------\n*/\nmtxmanager = SubMtxManager_new() ;\nSubMtxManager_init(mtxmanager, NO_LOCK, 0) ;\nfrontmtx = FrontMtx_new() ;\nFrontMtx_init(frontmtx, frontETree, symbfacIVL, type, symmetryflag,\n              FRONTMTX_DENSE_FRONTS, pivotingflag, NO_LOCK, myid,\n              ownersIV, mtxmanager, msglvl, msgFile) ;\n/*--------------------------------------------------------------------*/\n/*\n   ---------------------------------\n   STEP 8: compute the factorization\n   ---------------------------------\n*/\nchvmanager = ChvManager_new() ;\nChvManager_init(chvmanager, NO_LOCK, 0) ;\nrootchv = FrontMtx_MPI_factorInpMtx(frontmtx, mtxA, tau, droptol,\n                     chvmanager, ownersIV, lookahead, &error, cpus, \n                     stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nChvManager_free(chvmanager) ;\nfirsttag += 3*frontETree->nfront + 2 ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n numeric factorization\") ;\n   FrontMtx_writeForHumanEye(frontmtx, msgFile) ;\n   fflush(msgFile) ;\n}\nif ( error >= 0 ) {\n   fprintf(stderr, \n          \"\\n proc %d : factorization error at front %d\", myid, error) ;\n   MPI_Finalize() ;\n   exit(-1) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ------------------------------------------------\n   STEP 9: post-process the factorization and split \n   the factor matrices into submatrices \n   ------------------------------------------------\n*/\nFrontMtx_MPI_postProcess(frontmtx, ownersIV, stats, msglvl,\n                         msgFile, firsttag, MPI_COMM_WORLD) ;\nfirsttag += 5*nproc ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n numeric factorization after post-processing\");\n   FrontMtx_writeForHumanEye(frontmtx, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   -----------------------------------\n   STEP 10: create the solve map object\n   -----------------------------------\n*/\nsolvemap = SolveMap_new() ;\nSolveMap_ddMap(solvemap, symmetryflag, \n               FrontMtx_upperBlockIVL(frontmtx),\n               FrontMtx_lowerBlockIVL(frontmtx),\n               nproc, ownersIV, FrontMtx_frontTree(frontmtx), \n               seed, msglvl, msgFile);\nif ( msglvl > 3 ) {\n   SolveMap_writeForHumanEye(solvemap, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ----------------------------------------------------\n   STEP 11: redistribute the submatrices of the factors\n   ----------------------------------------------------\n*/\nFrontMtx_MPI_split(frontmtx, solvemap, \n                   stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n numeric factorization after split\") ;\n   FrontMtx_writeForHumanEye(frontmtx, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ------------------------------------------------\n   STEP 13: permute and redistribute Y if necessary\n   ------------------------------------------------\n*/\nif ( FRONTMTX_IS_PIVOTING(frontmtx) ) {\n   IV   *rowmapIV ;\n/*\n   ----------------------------------------------------------\n   pivoting has taken place, redistribute the right hand side\n   to match the final rows and columns in the fronts\n   ----------------------------------------------------------\n*/\n   rowmapIV = FrontMtx_MPI_rowmapIV(frontmtx, ownersIV, msglvl,\n                                    msgFile, MPI_COMM_WORLD) ;\n   newY = DenseMtx_MPI_splitByRows(mtxY, rowmapIV, stats, msglvl, \n                                   msgFile, firsttag, MPI_COMM_WORLD) ;\n   DenseMtx_free(mtxY) ;\n   mtxY = newY ;\n   IV_free(rowmapIV) ;\n}\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n rhs matrix after split\") ;\n   DenseMtx_writeForHumanEye(mtxY, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   ------------------------------------------\n   STEP 14: create a solution DenseMtx object\n   ------------------------------------------\n*/\nownedColumnsIV = FrontMtx_ownedColumnsIV(frontmtx, myid, ownersIV,\n                                         msglvl, msgFile) ;\nnmycol = IV_size(ownedColumnsIV) ;\nmtxX = DenseMtx_new() ;\nif ( nmycol > 0 ) {\n   DenseMtx_init(mtxX, type, 0, 0, nmycol, nrhs, 1, nmycol) ;\n   DenseMtx_rowIndices(mtxX, &nrow, &rowind) ;\n   IVcopy(nmycol, rowind, IV_entries(ownedColumnsIV)) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   --------------------------------\n   STEP 15: solve the linear system\n   --------------------------------\n*/\nsolvemanager = SubMtxManager_new() ;\nSubMtxManager_init(solvemanager, NO_LOCK, 0) ;\nFrontMtx_MPI_solve(frontmtx, mtxX, mtxY, solvemanager, solvemap, cpus, \n                   stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nSubMtxManager_free(solvemanager) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n solution in new ordering\") ;\n   DenseMtx_writeForHumanEye(mtxX, msgFile) ;\n}\n/*--------------------------------------------------------------------*/\n/*\n   --------------------------------------------------------\n   STEP 15: permute the solution into the original ordering\n            and assemble the solution onto processor zero\n   --------------------------------------------------------\n*/\nDenseMtx_permuteRows(mtxX, newToOldIV) ;\nif ( msglvl > 2 ) {\n   fprintf(msgFile, \"\\n\\n solution in old ordering\") ;\n   DenseMtx_writeForHumanEye(mtxX, msgFile) ;\n   fflush(msgFile) ;\n}\nIV_fill(vtxmapIV, 0) ;\nfirsttag++ ;\nmtxX = DenseMtx_MPI_splitByRows(mtxX, vtxmapIV, stats, msglvl, msgFile,\n                                firsttag, MPI_COMM_WORLD) ;\nif ( myid == 0 && msglvl > 0 ) {\n   fprintf(msgFile, \"\\n\\n complete solution in old ordering\") ;\n   DenseMtx_writeForHumanEye(mtxX, msgFile) ;\n   fflush(msgFile) ;\n}\n/*--------------------------------------------------------------------*/\nMPI_Finalize() ;\n\nreturn(1) ; }\n/*--------------------------------------------------------------------*/\n\\end{verbatim}\n", "meta": {"hexsha": "bad241c424c458475d0c92a4ee61af8fc43fc458", "size": 17771, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI_driver.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI_driver.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI_driver.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 36.6412371134, "max_line_length": 72, "alphanum_fraction": 0.5081874965, "num_tokens": 4626, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.44465214992089286}}
{"text": "%%^^A%% um-doc-legacyfontdimen.tex -- part of UNICODE-MATH <wspr.io/unicode-math>\n\n\\section{Legacy \\TeX\\ font dimensions}\n\n\\centerline{%\n\\begin{tabular}[t]{@{}lp{4cm}@{}}\n\\toprule\n\\multicolumn{2}{@{}c@{}}{Text fonts} \\\\\n\\midrule\n$\\phi_1$ & slant per pt                \\\\\n$\\phi_2$ & interword space             \\\\\n$\\phi_3$ & interword stretch           \\\\\n$\\phi_4$ & interword shrink            \\\\\n$\\phi_5$ & x-height                    \\\\\n$\\phi_6$ & quad width                  \\\\\n$\\phi_7$ & extra space                 \\\\\n$\\phi_8$ & cap height (\\XeTeX\\ only)   \\\\\n\\bottomrule\n\\end{tabular}\n\\quad\n\\begin{tabular}[t]{@{}lp{4cm}@{}}\n\\toprule\n\\multicolumn{2}{@{}c@{}}{Maths font, \\cs{fam}2} \\\\\n\\midrule\n$\\sigma_5$    & x height                    \\\\\n$\\sigma_6$    & quad                        \\\\\n$\\sigma_8$    & num1                        \\\\\n$\\sigma_9$    & num2                        \\\\\n$\\sigma_{10}$ & num3                        \\\\\n$\\sigma_{11}$ & denom1                      \\\\\n$\\sigma_{12}$ & denom2                      \\\\\n$\\sigma_{13}$ & sup1                        \\\\\n$\\sigma_{14}$ & sup2                        \\\\\n$\\sigma_{15}$ & sup3                        \\\\\n$\\sigma_{16}$ & sub1                        \\\\\n$\\sigma_{17}$ & sub2                        \\\\\n$\\sigma_{18}$ & sup drop                    \\\\\n$\\sigma_{19}$ & sub drop                    \\\\\n$\\sigma_{20}$ & delim1                      \\\\\n$\\sigma_{21}$ & delim2                      \\\\\n$\\sigma_{22}$ & axis height                 \\\\\n\\bottomrule\n\\end{tabular}\n\\quad\n\\begin{tabular}[t]{@{}lp{4cm}@{}}\n\\toprule\n\\multicolumn{2}{@{}c@{}}{Maths font, \\cs{fam}3} \\\\\n\\midrule\n$\\xi_8$    & default rule thickness      \\\\\n$\\xi_9$    & big op spacing1             \\\\\n$\\xi_{10}$ & big op spacing2             \\\\\n$\\xi_{11}$ & big op spacing3             \\\\\n$\\xi_{12}$ & big op spacing4             \\\\\n$\\xi_{13}$ & big op spacing5             \\\\\n\\bottomrule\n\\end{tabular}\n}\n\n\\endinput\n\n% /©\n%\n% ------------------------------------------------\n% The UNICODE-MATH package  <wspr.io/unicode-math>\n% ------------------------------------------------\n% This package is free software and may be redistributed and/or modified under\n% the conditions of the LaTeX Project Public License, version 1.3c or higher\n% (your choice): <http://www.latex-project.org/lppl/>.\n% ------------------------------------------------\n% Copyright 2006-2019  Will Robertson, LPPL \"maintainer\"\n% Copyright 2010-2017  Philipp Stephani\n% Copyright 2011-2017  Joseph Wright\n% Copyright 2012-2015  Khaled Hosny\n% ------------------------------------------------\n%\n% ©/\n", "meta": {"hexsha": "5adb24e9f63a5feec0680b9351a7417b406cccd2", "size": 2588, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "um-doc-legacyfontdimen.tex", "max_stars_repo_name": "jakubkaczor/unicode-math", "max_stars_repo_head_hexsha": "08671061dabfed266b9e3d1272ef8cfc9ccd436e", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 171, "max_stars_repo_stars_event_min_datetime": "2015-01-22T00:54:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T10:18:31.000Z", "max_issues_repo_path": "um-doc-legacyfontdimen.tex", "max_issues_repo_name": "jakubkaczor/unicode-math", "max_issues_repo_head_hexsha": "08671061dabfed266b9e3d1272ef8cfc9ccd436e", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": 342, "max_issues_repo_issues_event_min_datetime": "2015-01-27T08:07:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T01:01:28.000Z", "max_forks_repo_path": "um-doc-legacyfontdimen.tex", "max_forks_repo_name": "jakubkaczor/unicode-math", "max_forks_repo_head_hexsha": "08671061dabfed266b9e3d1272ef8cfc9ccd436e", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2015-01-21T23:22:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T12:22:25.000Z", "avg_line_length": 33.6103896104, "max_line_length": 81, "alphanum_fraction": 0.4462905719, "num_tokens": 713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.44465214992089286}}
{"text": "\\documentclass[]{scrartcl}\n\n\\usepackage{amsmath}\n\\usepackage{bussproofs}\n\\usepackage{color}\n\\usepackage{listings}\n\\usepackage{hyperref}\n\\usepackage{url}\n\n\\EnableBpAbbreviations\n\n\\newcommand{\\WHILE}[2]{\\ensuremath{\\mathbf{while}\\;#1\\;\\mathbf{do}\\;\\{#2\\}}}\n\\newcommand{\\IWHILE}[3]{\\ensuremath{\\mathbf{inv}\\;#1\\;\\mathbf{while}\\;#2\\;\\mathbf{do}\\;\\{#3\\}}}\n\\newcommand{\\IF}[3]{\\ensuremath{\\mathbf{if}\\;#1\\;\\mathbf{then}\\;\\{#2\\}\\;\\mathbf{else}\\;\\{#3\\}}}\n\\newcommand{\\SKIP}{\\ensuremath{\\mathbf{skip};}}\n\\newcommand{\\ASSUME}[1]{\\ensuremath{\\mathbf{assume}\\;#1;}}\n\\newcommand{\\ASSERT}[1]{\\ensuremath{\\mathbf{assert}\\;#1;}}\n\\newcommand{\\WLP}[2]{\\ensuremath{\\mathbf{wlp}\\;#1\\;#2}}\n\\newcommand{\\REPBY}[2]{\\ensuremath{#1\\;\\mathbf{repby}\\;#2}}\n\\newcommand{\\UNROLLSQ}[3]{\\ensuremath{[\\mathit{while}]^{#1}(#2, #3)}}\n\\newcommand{\\UNROLLDI}[3]{\\ensuremath{\\langle\\mathit{while}\\rangle^{#1}(#2, #3)}}\n\\lstset{\n  frame=none,\n  xleftmargin=2pt,\n  stepnumber=1,\n  numbers=left,\n  numbersep=5pt,\n  numberstyle=\\ttfamily\\tiny\\color[gray]{0.3},\n  belowcaptionskip=\\bigskipamount,\n  captionpos=b,\n  escapeinside={*'}{'*},\n  language=haskell,\n  tabsize=2,\n  emphstyle={\\bf},\n  commentstyle=\\it,\n  stringstyle=\\mdseries\\rmfamily,\n  showspaces=false,\n  keywordstyle=\\bfseries\\rmfamily,\n  columns=flexible,\n  basicstyle=\\small\\sffamily,\n  showstringspaces=false,\n  morecomment=[l]\\%,\n}\n\n%opening\n\\title{A Program Verification Engine for Imperative Languages}\n\\subtitle{Course: Program Verification}\n\\author{Giovanni Garufi, Fabian Thorand}\n\\date{\\today}\n\n\\newcommand{\\blue}[1]{\\textcolor{blue}{#1}}\n\n\\newcommand{\\HT}[3]{\\blue{\\{#1\\}} #2 \\blue{\\{#3\\}}}\n\n\\begin{document}\n\n\\maketitle\n\n\\tableofcontents\n\n%==================================================================================================\n\\section{Introduction}\n%==================================================================================================\n\nIn this report we present our tool for formally verifying programs written in\nimperative languages. While testing already significantly decreases the chances\nof having bugs in a program, it is often hard or event impossible to write test\ncases that cover every execution path.\n\nOne way of making sure a program works as intended is to formally prove that its\nbehavior adheres to the specification.\nSuch a specification usually consists of a pre- and a post-condition.\nThe intention is, that the results of a program satisfy the post-condition,\ngiven that the inputs to the program fulfil the pre-condition.\nThe Hoare calculus provides one mathematical foundation for conducting such\nproofs based on pre- and post-conditions.\nBut of course, doing proofs by hand is error-prone and tedious even for\nsimple programs.\n\nIdeally, there would be a tool automatically proving properties about programs.\nUnfortunately, it is -- in general -- undecidable to check whether a given\nprogram (represented as a Turing machine) satisfies a given property, due to the\nHalting problem\\footnote{as shown by Rice's theorem}.\nThe power of turing machines is usually introduced in programming languages\nby some form of loops or general recursion.\n\nFortunately, this can be migitated by requiring the programmer to annotate loops\nwith invariants, guiding the verification tool in the right direction.\nFor some specific cases it might even be possible to automatically infer those\ninvariants.\n\nUsing a technique called \\emph{Predicate Transformers} it is possible to infer\nthe precondition required for a program to satisfy its post-condition.\n\nUpon that technique we built our verification engine that we describe in the\nfollowing sections.\n\n%==================================================================================================\n\\section{Project Structure}\n%==================================================================================================\n\nWe implemented our project in the Haskell programming language making use of\nMonads to achieve abstraction.\nFor invoking the solver we rely on the \\texttt{sbv}\\footnote{\\url{https://hackage.haskell.org/package/sbv}}\nlibrary available on Hackage.\nIt provides a common interface to several solver backends via the SMT-LIB v2 standard,\nalthough some features are only implemented in some solvers.\nFor that reason, we only use the Microsoft Z3 backend for now.\n\nSBV provides a typed and untyped (w.r.t. expressions) interface to the prover.\nAs our internal AST representation is untyped and we rely on the type correctness of\nthe user-provided programs anyway, we use the untyped API.\n\nOur core implementation is devided in four parts, the AST, the monadic DSL, the WLP transformer\nand the adapter to the prover backend.\nFurthermore, we have implemented a test suite asserting the expected results for the examples\nin the project assignment description.\n\nOn top of the basic requirements, we also support array assignments, invariant inference and\nprogram calls. The following sections describe our implementation in greater detail.\n\n%==================================================================================================\n\\section{Monadic DSL for the Guarded Common Language}\n%==================================================================================================\n\nOur abstract syntax tree representing programs consists of three levels.\nThe root node stores the name of the program, the input and output arguments and a body statement.\nThe statement and expression trees closely follow the grammar outlined in the assignment description,\nwith one notable difference. Instead of sequencing statements pairwisely, we have an explicit \\emph{block}\nstatement wrapping a list of statements.\nOur expression AST is untyped, therefore we require the user to only construct type correct programs.\nVariables in the AST are qualified, besides the literal name they also consist of a unqiue identifier.\nAt certain points in our code we assume that all variables in the supplied AST are indeed unique.\n\nIn order to facilitate dealing with variables we also provide a monadic DSL for constructing programs.\nThe DSL makes use of unqualified names, but performs name resolution and fails if undeclared variables\nare used. All variable declarations in the resulting AST are unique.\n\nWe also make use of some language features to facilitate writing programs in the DSL.\nIt is possible to use Haskell string literals to be directly as variables by means of the\n\\emph{OverloadedStrings} GHC extension and to directly use integer literals and common mathematical\noperations by making use the \\emph{Num} type class.\n\nIt also takes care of some implementation details. If-expressions are actually implemented in terms of\nnon-deterministic branching in GCL. Furthermore, assignments to arrays like\n\\lstinline|a[i] := e| are translated to the corresponding \\lstinline|a := a(i repby e)|.\n\nListing \\ref{fig:prog:example} shows a program sorting a range $[0\\ldots N)$ of an array $a$.\nProgram calls like \\lstinline|call \"minind\" [\"a\", \"i\" + 1, \"N\"] [\"m\"]| mean $m := \\mathit{minind}(a, i+1, N)$,\nthat is the first list represents the argument expressions and the second list the return variables.\n\n\\begin{lstlisting}[caption=Selection sort implemented in our DSL, label=fig:prog:example]\ns = program \"sort\" [ \"a\" `as` array int, \"N\" `as` int] [\"ret\" `as` array int] $ do\n  assume $ 0 .<= \"N\"\n  var [\"i\" `as` int, \"m\" `as` int, \"min\" `as` int] $ do\n    \"i\" $= 0\n    let iv = (\"N\" .== 0 \\/ \"i\" .<= \"N\" - 1)\n            /\\ forall (\"k\" `as` int) (0 .<= \"k\" /\\ \"k\" .< \"i\" - 1 ==> \n                 \"a\" ! \"k\" .<= \"a\" ! (\"k\" + 1))\n            /\\ forall (\"k\" `as` int) (0 .<= \"k\" /\\ \"k\" .< \"i\" ==> \n                 forall (\"l\" `as` int) (\"i\" .<= \"l\" /\\ \"l\" .< \"N\" ==> \"a\" ! \"k\" .<= \"a\" ! \"l\"))\n    invWhile (Just iv) (\"i\" .< \"N\" - 1) $ do\n      call \"minind\" [\"a\", \"i\" + 1, \"N\"] [\"m\"]\n      if_ (\"a\" ! \"m\" .< \"a\" ! \"i\")\n        (call \"swap\" [\"a\", \"i\", \"m\"] [\"a\"])\n        skip\n      \"i\" $= \"i\" + 1\n    \"ret\" $= \"a\"\n    assert $ forall (\"k\" `as` int) (0 .<= \"k\" /\\ \"k\" .< (\"N\" - 1) ==> \n               \"ret\" ! \"k\" .<= \"ret\" ! (\"k\" + 1))\n\\end{lstlisting}\n\n%==================================================================================================\n\\section{Implementing Predicate Transformer}\n%==================================================================================================\n\nThe WLP transformer is implemented in a custom MonadProver monad we defined.\nThe MonadProver provides two basic actions: prove and trace, that respectively\neither prove or provied a counterexample to a supplied predicate, allowing the\n\\textbf{wlp} to unfold, and allows us trace debug statements during the whole operation.\n\nAs we will see in later sections the there are different ways a WLP computation\ncould be carried on; these differences are abstracted over by a configuration\nthat must be provided to the transformer allowing different extensions to the\nWLP behaviour.\n\nThe transformer operates under the partial correctness interpretation, as such\ntermination is assumed to be guaranteed.\n\n\\subsection{Basic Statements}\n\nDealing with most of the basic statements in the GCL language turns out to\nbe pretty straightforward. The implementation deals with these basic statements\nexactly as presented in the lectures.\nAs a matter of fact: since we used the same datatype both for expressions in GCL\nand the predicates built by the \\textbf{wlp}, we managed to reuse the combinators defined\nin the DSL to specify the predicates in the WLP. The effect of this on the code\nis that it writes out almost exactly as in the equations presented in the lectures.\n\nListing \\ref{lst:wlp:basic} shows two simple cases from our WLP implementation.\nAs we need to be able to run the prover on the fly, we run the WLP in a monadic context.\nIn the case for a block of statements we simply monadicly fold the WLP over all statements.\nThe implementation for assertions also follows closely the formal specification of the\nWLP transformer.\n\n\\begin{lstlisting}[caption=WLP implementation example, label=lst:wlp:basic]\n  go (AST.Block stmts) q = foldrM go q stmts\n  go (AST.Assert e) q =  return (e /\\ q)\n\\end{lstlisting}\n\n\\subsection{Loops}\n\nIn the case the user provides his loops with an annotated invariant the first\nthing that must be done is to verify the validity of said invariant.\nThis can be stated as\n\\begin{align}\n  I \\land \\neg g \\Rightarrow Q \\\\\n  I \\land g \\Rightarrow \\WLP{S}{I}\n\\end{align}\nThe SBV solver has to be invoked to verify that these conditions hold, and that\nthe invariant supplied by the user is in fact a valid invariant.\nIf the invariant turns out to be invalid, it can still work out if the loop\nis never entered. This gives us the following forumula for the \\textbf{wlp} of an annotated\nloop\n\\begin{align}\n  \\WLP{(\\IWHILE{I}{g}{S})}{Q} &=\n    \\begin{cases}\n      I, \\qquad  \\mathrm{if \\; the \\; provided \\; invariant \\; is \\; valid}\\\\\n      \\neg g \\land q, \\mathrm{otherwise}\n    \\end{cases}\n\\end{align}\nWe will see in a subsequent section how to deal with unannotated loops.\n\nListing \\ref{lst:wlp:loop} show an excerpt from the WLP function implementing the aforementioned case.\nThe behavior in the case where the invariant is invalid is configurable. We can either try to prove\nthat the loop is never entered, or we try to infer a correct invariant.\nThe invariant check itself can be turned off as well, then the invariant is always assumed correct.\nThat might be useful when the correctness proof is not feasible with the backend prover.\n\n\\begin{lstlisting}[caption=WLP loop case, label=lst:wlp:loop]\ngo (AST.InvWhile (Just iv) cnd s) q\n  | not alwaysInferInvariant && checkInvariantAnnotation = do\n      preInv <- go s iv\n      let preserveInv = prepare $ iv /\\ cnd ==> preInv\n          postcnd     = prepare $ iv /\\ neg cnd ==> q\n      trace \"trying to prove invariant is preserved\"\n      preserved <- prove preserveInv\n      trace \"trying to prove post condition\"\n      postValid <- prove postcnd\n      if preserved && postValid\n        then do\n          trace \"invariant valid: choosing invariant as precondition\"\n          return iv\n        else case invalidInvariantBehavior of\n          NeverExecute -> do\n            trace \"invariant invalid: requiring that loop is never executed\"\n            return (neg cnd /\\ q)\n          Infer -> do\n            trace \"invariant invalid: trying to infer an invariant\"\n            inferInv (Just iv) cnd s q\n  | not alwaysInferInvariant && not checkInvariantAnnotation = do\n      trace \"assuming user-supplied invariant is correct\"\n      return iv\n\\end{lstlisting}\n\n\n\\subsection{Arrays}\n\nTo deal with array assignment we introduce the following translation\n\\begin{align}\n  a[i] := e \\qquad \\equiv \\qquad a := a ( \\REPBY{i}{e} )\n\\end{align}\nWhere the newly introduced expression represents an array which is identical to\n\\emph{a}, except at position \\emph{i} where it has value \\emph{e}.\n\nThis allows us to define the corrisponding wlp as if it were a normal assignment\n\\begin{align}\n  \\WLP{(a[i] := e)}{Q} &= Q[a( \\REPBY{i}{e} ) / a]\n\\end{align}\n\n\\subsection{Program Calls}\n\nWe can extend the \\textbf{wlp} to verify programs which contain calls to other programs.\nWe can think of a program call like a statement with two associated sets:\nthe expressions passed to input argument and the output variables.\nExternal programs can be specified in two different ways: by a complete program or\njust by a specification of the preconditions and postconditions associated with\nthe call.\nIn the latter case we provide a function that builds the program body by asserting\nits pre-conditions and assuming the post-conditions.\nThis allows us to treat both cases uniformly in the \\textbf{wlp} function.\nThe environment is extended with associations between program names and the\ntuple of input/output parameters and program body that completely specify a program\nWhen a program call is made the body is simply inlined at call site taking care\nof assigning argument expressions to input parameters and output parameters to the result variables.\nOnce this program fragment is built the \\textbf{wlp} can simply proceed on that.\n\n%==================================================================================================\n\\section{Invariant Inference}\n%==================================================================================================\n\nIn the case where the user has not annotated the invariant of while-loops,\nit might still be possible to infer the invariant using fixpoint-iteration\nor finite unrolling.\n\n\\subsection{Fixpoint Iteration}\n\nWhen we have a loop \\lstinline|while g do S;|, it is equivalent to\n\\begin{lstlisting}\nif g then { S; while g do S; }\n     else skip;\n\\end{lstlisting}\neffectively unrolling the loop once.\n\nIf $W$ is \\textbf{wlp} of that loop, we have $W = \\WLP{(\\WHILE{g}{S})}{Q}$ as well as\n$W = (g \\land \\WLP{S}{(\\WLP{(\\WHILE{g}{S})}{Q})}) \\lor (\\neg g \\land Q)$ according to the unrolling above.\nTherefore, we can conclude that $W = (g \\land \\WLP{S}{W}) \\lor (\\neg g \\land Q)$.\n\nWe can find the greatest fixpoint of this equation by iterating, starting from the weakest invariant \\emph{true},\nfollowing from the \\emph{Knaster-Tarski} fixpoint-theorem.\n\\begin{align}\n  \\label{eq:fp:base} W_0 &= \\mathit{true} \\\\\n  \\label{eq:fp:iter} W_{i+1} &= (g \\land W_i) \\lor (\\neg g \\land Q)\n\\end{align}\n\nIf a fixpoint exists, there is an $i$ for which $W_{i+1} = W_i$ holds.\nWe implemented the iteration according to equations \\ref{eq:fp:base} and \\ref{eq:fp:iter}.\nAfter each iteration, we invoke the backend-prover to check whether $W_{i+1} \\iff W_i$ holds.\nIn that case we have found the fixpoint $W_i$ and return it to the \\textbf{wlp} function as\ninvariant.\nWe additionally implemented an optional limit to the number of iterations.\nIf that limit is exceeded without finding an invariant, we return a precondition that requires\nthat the loop will never be executed and the post-condition already holds.\n\n\\subsection{Loop Unrolling}\n\nAs an alternative to fixpoint-iteration we can also unroll a loop a finite number of times and\ncompute the \\textbf{wlp} of the unrolling. The last iteration then either asserts that the\nloop guard will not hold, or just assume that it doesn't hold anymore.\nFormally, those unrollings, named  are defined as follows.\n\\begin{align}\n\\UNROLLSQ{0\\phantom{+1}}{g}{S} &= \\ASSERT{\\neg g} \\\\\n\\UNROLLSQ{k+1}{g}{S} &= \\IF{g}{S; \\UNROLLSQ{k}{g}{S}}{\\SKIP}\n\\end{align}\n\n\\begin{align}\n\\UNROLLDI{0\\phantom{+1}}{g}{S} &= \\ASSUME{\\neg g} \\\\\n\\UNROLLDI{k+1}{g}{S} &= \\IF{g}{S; \\UNROLLDI{k}{g}{S}}{\\SKIP}\n\\end{align}\n\nOur implementation first computes (lazily) the unrolled loop and then applies\nthe \\textbf{wlp} transformer to the unrolling.\n\n%==================================================================================================\n\\section{Solver Backend}\n%==================================================================================================\n\nAs mentioned before we rely on the \\texttt{sbv} Haskell library for interacting with a theorem prover.\nWhile it supports multiple provers, we only tested our implementation with Microsoft's Z3 being the\none with most features.\nThe WLP implementation itself is not bound to a specific prover backend and it should be easy to\nadd others if necessary.\n\n\\subsection{Free Monad Interface}\n\nThe WLP transformer is implemented as a free monad over WLP computations.\nThis allows us to specify different interpreters for the same abstract WLP tree.\nWe ended up implementing a handful of different interpreters along the ``main''\none, which relies on the SBV interface to carry out the proofs in predicate logic.\nOther interpreters that were implemented allowed us to: \\textit{pretty-printer} of WLP trees,\nallowing us to inspect the different branching points and in general providing\na very useful debugging tool, an \\textit{interactive} interpreter which asks the user\nto carry out the requested proofs and a \\textit{speculative} interpreter which, at branching\npoints, immediately proceeds resolving the \\textbf{wlp} with all possible outcomes and\nat a later point prunes the excessive branches when a proof is provided.\n\n\\subsection{Handling Quantifiers}\n\nOur GCL DSL allows arbitrary nesting of universal and existential quantification,\nbut the solver library we use requires all quantified variables to be defined in\nthe beginning.\nFortunately, for every formula in classical logic there is an equivalent formula\nin prenex normal form, where all quantifiers occur in the beginning.\nThe conversion to prenex normal form requires that every quantified variable is\nunique to avoid accidental capturing when pulling the quantifiers outside.\nAdditionally, all negations have to be pushed inwards, swapping universal and\nexistential quantification on the go.\nSkolemization is then perfomed by the prover backend.\nAn additional benefit from the conversion to prenex normal form is, that it allows\nus to return a model for all existential quantifications in a SAT proof, as only\nthe values of the outermost existentials are returned by the library.\n\n\\subsection{Array Theory}\n\nWhile the conversion and meaning of integer arithmetic and boolean logic should be\nstraightforward, arrays require are more subtle treatment.\nAs explained above, array assignments are translated to the $a(\\REPBY{i}{e})$ syntax.\nFortunately, Z3 provides a built-in array theory with two functions \\emph{select} and\n\\emph{store} directly mapping to array indexing and \\emph{repby}.\nThe downside is, that the \\texttt{sbv} library we use imposes some restrictions on the\nuse of arrays and it was not clear to us from the documentation whether these restrictions\nstem directly from Z3 or from the wrapper library.\nMost notable, arrays can only be used existentially during SAT proofs (i.e. only universally\nduring validity proofs).\nThis didn't mean any restriction for our examples though, because all variable declarations\nresult in universal quantifications.\n\n\\section{Conclusion}\n\nUsing Haskell allowed us to write the WLP implementation in a succinct declarative\nstyle, closely following the underlying formal definitions. It also enabled us\nto easily define a custom DSL for the GCL language which made working on the GCL\nprograms a relatively pain-free experience. \n\n\\end{document}\n", "meta": {"hexsha": "9d9e993b937fdb6af5fceadd9550bc925de02425", "size": 20249, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/report.tex", "max_stars_repo_name": "fatho/program-verification-engine", "max_stars_repo_head_hexsha": "efaeb9ed4e177151d51d729f80185e5c69423ad3", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/report.tex", "max_issues_repo_name": "fatho/program-verification-engine", "max_issues_repo_head_hexsha": "efaeb9ed4e177151d51d729f80185e5c69423ad3", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/report.tex", "max_forks_repo_name": "fatho/program-verification-engine", "max_forks_repo_head_hexsha": "efaeb9ed4e177151d51d729f80185e5c69423ad3", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.6754807692, "max_line_length": 113, "alphanum_fraction": 0.7043310781, "num_tokens": 4920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4446521499208928}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n\\input{../header2.tex}\n\n\\title{Phys 220A -- Classical Mechanics -- Lec10}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{6}{11}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\setlength{\\unitlength}{1mm}\n\\maketitle\n\n\n\\section{Symplectic Geometry}\n\nIf we want to write the Poisson bracket for some arbitrary functions, i.e.\n\\begin{eqn}\nC(q,p) = \\cbr{A(q,p), B(q,p)},\n\\end{eqn}\nwe can expand in $q, p$ and we find that the fundamental bracket is really the ``canonical'' coordinate brackets,\n\\begin{eqn}\n\\cbr{q_i, q_j} = 0, \\qquad\n\\cbr{p_i, p_j} = 0, \\qquad\n\\cbr{q_i, p_j} = \\delta_{ij}.\n\\end{eqn}\nWe see that (as expected from quantum-classical correspondence) these are basically the same as in quantum mechanics just without the factor of $i\\hbar$. \n\nIf we write points in phase space using aggregate coordinates \n\\begin{eqn}\n\\xi_I = (q_1, \\dots, q_n, p_1, \\dots, p_n)^\\top,\n\\end{eqn}\nwe can reformulate Hamilton's equations as a single differential equation\n\\begin{eqn}\n\\dot \\xi_I = \\sum_J J_{IJ} \\pd{H}{\\xi_J}, \\qquad\nJ = \\pmat{0 & 1_n \\\\ -1_n & 0}.\n\\end{eqn}\nSuppose we have a coordinate transformation\n\\begin{eqn}\nQ = Q(q,p), \\qquad P = P(q,p).\n\\end{eqn}\nIf this transformation leaves the structure of Hamilton's equations unchanged, i.e. it leaves the symplectic geometry invariant, we call it a canonical transformation. We can characterize canonical transformations in a few equivalent ways as follows.\n\\begin{enumerate}\n\\item Structure of Hamilton's equations is unchanged:\n\\begin{eqn}\nH'(P,Q) = H(q(Q,P), p(Q,P))\n\\end{eqn}\nwe will have\n\\begin{eqn}\n\\dot P = -\\pd{H'}{Q}, \\qquad\n\\dot Q = \\pd{H'}{P}.\n\\end{eqn}\n\\item Poisson brackets are invariant:\n\\begin{eqn}\n\\cbr{A'(Q,P), B'(Q,P)}_{QP} = \\cbr{A(q,p), B(q,p)}_{qp}.\n\\end{eqn}\n\\item Under the transformation $Y_I = Y_I(X_I)$, the matrix $J_{IJ}$ can be written in terms of the Jacobian $j_{IJ}$ as\n\\begin{eqn}\nJ = j J j^\\top, \\qquad\nJ_{IJ} = \\sum_{KL} \\pd{Y_I}{X_K} J_{KL} \\pd{Y_J}{X_L}.\n\\end{eqn}\n\\item Most importantly: the Poisson brackets of the new coordinates are canonical,\n\\begin{eqn}\n\\cbr{Q_i, Q_j}_{qp} = 0, \\qquad\n\\cbr{P_i, P_j}_{qp} = 0, \\qquad\n\\cbr{Q_i, P_j}_{qp} = \\delta_{ij}.\n\\end{eqn}\n\\end{enumerate}\n\nWe can show that that canonical transformations reproduce Hamilton's equations [which characterization?]. We know\n\\begin{eqn}\n\\dot X_I = \\sum_J J_{IJ} \\pd{H}{X_J} = \\sum_J \\pd{X_I}{Y_J} \\dot Y_J,\n\\end{eqn}\nand also\n\\begin{eqn}\n\\pd{H}{X_J} = \\sum_K \\pd{H'}{Y_K} \\pd{Y_K}{X_J}.\n\\end{eqn}\nThen we find that\n\\begin{eqn}\n\\sum_J \\dot Y_J \\pd{X_I}{Y_J} = \\sum_{J,K} J_{IJ} \\pd{H'}{Y_K} \\pd{Y_K}{X_J}\n\\end{eqn}\nand using\n\\begin{eqn}\n\\sum_I \\pd{X_I}{Y_J} \\pd{Y_K}{X_I} = \\delta_{KJ}\n\\end{eqn}\nwe multiply both sides by $\\pd{Y_M}{X_I}$ and sum over $I$ to find\n\\begin{eqn}\n\\sum_J \\dot Y_J \\delta_{MJ} \n\t= \\sum_{IJK} \\pd{Y_M}{X_I} J_{IJ} \\pd{Y_K}{X_J} \\pd{H'}{Y_K} \n\t= \\sum_K J_{MK} \\pd{H'}{Y_K}.\n\\end{eqn}\n\n\n\\subsection{Some Examples of Canonical Transformations}\n\n\\begin{example}\nSuppose we have the transformation $Q = p$, $P = -q$. Then\n\\begin{eqn}\n\\cbr{Q,P}_{qp} = - \\cbr{p,q} = +1.\n\\end{eqn}\nSo this is a very simple example of a canonical transformation that shows how the $q$s and $p$s are really somewhat interchangeable. For example if we have a relativistic harmonic oscillator\n\\begin{eqn}\nH = \\sqrt{p^2 + m^2} + \\frac{1}{2} m \\omega^2 q^2,\n\\end{eqn}\nunder the transformation this is just\n\\begin{eqn}\nH' = \\sqrt{Q^2 + m^2} + \\frac{1}{2} m \\omega^2 P^2.\n\\end{eqn}\n\\end{example}\n\n\\begin{example}\nConsider the transformation [this was on the final last year]\n\\begin{eqn}\nQ = \\frac{1}{2} p^2, \\qquad\nP = -\\frac{p}{q},\n\\end{eqn}\nso that\n\\begin{eqn}\np = \\sqrt{2Q}, \\qquad\nq = -\\sqrt{2Q} P.\n\\end{eqn}\nThen we have\n\\begin{eqn}\n\\cbr{Q,P} = \\frac{1}{2} \\left( \\pd{(p^2)}{q} \\pd{(-q/p)}{p} - \\pd{(p^2)}{p} \\pd{(-q/p)}{q} \\right) = p \\frac{1}{p} = 1.\n\\end{eqn}\nThen \n\\begin{eqn}\nH = p^2 + q^2, \\qquad\nH' = 2Q + 2QP^2.\n\\end{eqn}\n\\end{example}\n\nThis approach can be somewhat messy but there it turns out that there is a nicer, more algorithmic way of checking for canonical transformations. This is the method of generating functions. \n\n\n\\subsection{Method of generating functions}\n\nIn this method, we will pick out functions of one old coordinate and one new coordinate so that, for example for some function $F_1(q,Q,t)$\n\\begin{eqn}\np = \\eval{\\pd{F_1}{q}}_Q \\qquad \\implies \\qquad Q = Q(q,p),\n\\end{eqn}\nand\n\\begin{eqn}\nP = -\\eval{\\pd{F_1}{Q}}_q \\qquad \\implies \\qquad P = P(q,p),\n\\end{eqn}\nsince\n\\begin{eqn}\n\\eval{\\pd{P}{p}}_q = \\eval{\\pd{P}{Q}}_q \\eval{\\pd{Q}{p}}_q.\n\\end{eqn}\nWe will need to do this for four functions $F_1, F_2, F_3, F_4$ with parameters as all four combinations of $q,p$ and $Q,P$.\n\n\\begin{proof}\nRecall that we can write the action\n\\begin{eqn}\nS = \\int \\dif{t} (p \\dot q - H),\n\\end{eqn}\nso for some transformed coordinates we can write\n\\begin{eqn}\nS = \\int \\dif t (P \\dot Q - K)\n\\end{eqn}\nfor some function $K(Q,P)$ which will just be $H'(Q,P)$ for a canonical transformation. This is sometimes referred to as the \"Cameltoenian\". So we want\n\\begin{align}\np \\dot q - H &= P \\dot Q - K(Q,P) + \\dod{}{t} F_1(q,Q) \\\\\n\t&= P \\dot Q - K(Q, P) + \\dpd{F_1}{t} + \\dpd{F_1}{q} \\dot q + \\dpd{F_1}{Q} \\dot Q.\n\\end{align}\nSo we have what we want if\n\\begin{eqn}\np = \\pd{F_1}{q}, \\qquad\nP = -\\pd{F_1}{Q}, \\qquad\nK = H + \\pd{F_1}{t}.\n\\end{eqn}\n\\end{proof}\n\nSo for the three other functions we will have\n\\begin{eqn}\nF_2(q,P), \\qquad p = \\pd{F_2}{q}, \\qquad Q = \\pd{F_2}{p},\n\\end{eqn} \\begin{eqn}\nF_3(p,Q), \\qquad q = -\\pd{F_3}{p}, \\qquad P = -\\pd{F_3}{Q},\n\\end{eqn} \\begin{eqn}\nF_4(p,P), \\qquad q = -\\pd{F_4}{p}, \\qquad Q = \\pd{F_4}{P}.\n\\end{eqn}\n\n\\setcounter{example}{0}\n\\begin{example}\nLet $F_1 = qQ$, then\n\\begin{eqn}\np = \\pd{F_1}{q} = Q, \\qquad P = -\\pd{F_1}{Q} = -q, \\qquad H = K.\n\\end{eqn}\n\\end{example}\n\n\\begin{example}\nGiven Hamiltonian\n\\begin{eqn}\nH = \\frac{p^2}{2m} + \\frac{1}{2} m \\omega^2 q^2,\n\\end{eqn}\nusing \n\\begin{eqn}\nF_1 = \\frac{m \\omega}{2} q^2 \\cot Q,\n\\end{eqn}\nwe find\n\\begin{eqn} \np = m \\omega q \\cot Q, \\qquad\nP = \\frac{m \\omega q^2}{2 \\sin^2 Q}.\n\\end{eqn}\nso that\n\\begin{eqn}\nq = \\sqrt{\\frac{2P}{m\\omega}} \\sin Q, \\qquad\np = \\sqrt{2 m \\omega P} \\cos Q,\n\\end{eqn}\nand\n\\begin{eqn}\nK = \\omega P (\\sin^2 Q + \\cos^2 Q) = \\omega P.\n\\end{eqn}\nThis one in particular is useful if $Q$ is cyclic and $P$ is constant, in which case $Q = Q_0 + \\omega t$.\n\\end{example}\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "c26eedf05d9b34cc3588483ee3ce8a801cd7971a", "size": 6622, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "classical/lec10.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "classical/lec10.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "classical/lec10.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.1718061674, "max_line_length": 250, "alphanum_fraction": 0.6567502265, "num_tokens": 2631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.44459774005369423}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{0.5em}\n\n\n\\title{CTA200 2020 Assignment 2}\n\\author{Henri Lamarre}\n\\date{}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Question 1}\n\\subsection{Methods}\nIn this section, we initialize 100000 sampled points in the complex square of width 4 centered at $(0,0)$. We then iterate for 20 steps with the rule $z_{i+1}=z_i+c$. We then assign the color red to the points that end up outside the box at the end of the 20 iterations. We assign the color blue to the points that are still in the box after the 20 iterations. Then, we zoom on the square of width $0.2$ centered at $(0,0)$ and redo the same process but with only 2500 sampled points.\n\n\\begin{figure}[h]\n\\includegraphics[width = 0.5\\columnwidth]{question1_1.png}\n\\includegraphics[width = 0.5\\columnwidth]{question1_2.png}\n\\caption{[Left] Scatter plot of the positions of points for each iteration step in the box of width 4. [Right] Scatter plot of the positions of points for each iteration step in the box of width 0.2.}\n\\end{figure}\n\n\n\\subsection{Analysis}\nWe note that points that converge are mostly points which $|z|$ value is smaller than $1$. We then zoom on the square to make sure that that restriction is respected and indeed, all the points converge.\n\n\n\\section{Question 2}\n\\subsection{Methods}\nWe solve the set of first degree ODEs using scipy.integrate.odeint(). We supply the following initial conditions: 999 susceptibles, 1 infected and 0 recovered. Then, we modify one of the ODE and add a new one by introducing deaths in the parameter $\\alpha$. We then use scipy again to solve these four ODEs.\n\n\\begin{figure}[h]\n\\includegraphics[width = 0.5\\columnwidth]{question2_1.png}\n\\includegraphics[width = 0.5\\columnwidth]{question2_2.png}\n\\includegraphics[width = 0.5\\columnwidth]{question2_3.png}\n\\includegraphics[width = 0.5\\columnwidth]{question2_4.png}\n\\caption{Evolution of the number of people in the groups: Infected, Susceptible (Suspected), Recovered and Dead. The parameter $\\alpha$ is 0 in the first three plots.}\n\\end{figure}\n\n\\subsection{Analysis}\nBy increasing $\\beta$, the rate of propagation is substancially lowered. We hypothesise that $\\beta$ is inversly proportionnal to the rate of propagation of the virus. Then, by increasing $\\gamma$, we notice that more people get infected. We hypothesise that $\\gamma$ is related to the chances of contracting the virus by being in contact with it. Then, by adding the death parameter, we notice that the number of infected decreases faster which was expected.\n\n\n\\end{document}\n", "meta": {"hexsha": "33ef39df95cfdc6a095db9a1af1987b843a69e08", "size": 2675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment2/Assignment_2.tex", "max_stars_repo_name": "HenriLamarre/CTA200", "max_stars_repo_head_hexsha": "f161339e8fe9e7ccca6fa26b77edd23d63972fa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment2/Assignment_2.tex", "max_issues_repo_name": "HenriLamarre/CTA200", "max_issues_repo_head_hexsha": "f161339e8fe9e7ccca6fa26b77edd23d63972fa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment2/Assignment_2.tex", "max_forks_repo_name": "HenriLamarre/CTA200", "max_forks_repo_head_hexsha": "f161339e8fe9e7ccca6fa26b77edd23d63972fa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.5, "max_line_length": 484, "alphanum_fraction": 0.7734579439, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.4445612478079091}}
{"text": "\n%\\todo[inline]{first explain the data structure \\automorphismgenerators, i.e. that it can be thought of as spanning a vector space, and then give the algorithm}\n\n\n%Data structure {\\sc SystemOfPauliEquations}\n%is a list of equations of the form $\\lambda P (\\alpha \\ket{\\phi}) = \\beta \\ket{\\psi}$.\n%Has a method {\\sc \n\n\n\\subsubsection{Choosing a canonical high-edge label}\n\\label{sec:choose-canonical-isomorphism-pauli}\n\n%The \\textsc{MakeEdge} procedure enforces that all reduction rules are satisfied, one by one.\n%For all reduction rules except for a canonical high-label choice this is straightforward, e.g. for Low Precedence, if the right child $\\succ$ the left child, then swap them and apply the appropriate Pauli at the root label.\n\nOn line \\ref{algline:makeedge-get-labels}, the \\makeedge algorithm finds a canonical label $\\highlim$ for the high edge of node $v$ with a call to \\textsc{GetLabels}.\n%The semi-reduced node  \\lnode[w]{\\unit_2^{\\otimes n}}{v_0}{\\hat A}{v_1} with $v_0 \\neq v_1$ created in\n%\\makeedge is passed to \\textsc{GetLabels} to obtain a canonical\n%representative \\lnode[v^{\\text{r}}]{\\unit_2^{\\otimes n}}{v_0}{\\highlim}{v_1}\n% (with `r' for reduced) and a root edge $\\ledge[e] {\\rootlim}{v^{\\text{r}}}$ such that\n% $\\ket e = \\ket w$.\nIt does so by taking the lexicographically minimal candidate for \\highlim, see \\autoref{sec:preliminaries}.\nWe now first characterize all eligible labels \\highlim, by reducing the problem to finding stabilizer subgroups of the children nodes $v_0,v_1$ (see \\autoref{sec:preliminaries}), denoted as $\\Stab(v_0)$ and $\\Stab(v_1)$.\nThen, we show that \\textsc{GetLabels} (\\autoref{alg:find-canonical-edges}) correctly finds the lexicographically minimal eligible LIM (and corresponding root label), and runs in time $O(n^3)$ where $n$ is the number of qubits.\n\n\\autoref{fig:reduced} illustrates this process.\nIt shows the status of the \\makeedge algorithm on line \\ref{algline:makeedge-get-labels}, when it has enough information to construct the semi-reduced node $\\lnode[w]{\\id^{\\otimes n}}{v_0}{\\hat A}{v_1}$, with $\\hat A=\\lambda P$ on its high edge, shown on the left.\nThe set of eligible high labels is shown, and the lexicographically minimal is chosen as $\\highlim$, yielding a new node $v^r$ (with `r' for `reduced').\nThis set of labels is decomposed into a choice of $v_0,v_1$ stabilizer $g_0, g_1$ and a choice for the most significant\n\\Pauli operator on the root LIM $X^x Z^s$.\n\\autoref{thm:eligible-isomorphisms-pauli} shows that this captures all possible high edges.\n\n\n\n%\\begin{lemma}\n%    \\label{lemma:isomorphic-nodes-have-same-high-label-scalar}\n%    Let $\\lambda, \\mu \\in \\mathbb{C}$ and let $A, B$ be Pauli strings of length $n$.\n%    Furthermore, let $v$ be the $n$-qubit root node of a reduced Pauli-\\limdd.\n%    If $\\ket{\\lambda A} \\psim \\ket{\\mu B}$, then $\\lambda = \\mu$.\n%\\end{lemma}\n%\\begin{proof}\n%    By induction...still to do\n%\\end{proof}\n\n\n\n%\\todo[inline]{Tim: maybe we should instead of Automorphism group, talk about Stabilizer group. Potential disadvantage is that readers who skim the work incorrectly assume that this is about groups which characterize stabilizer states, i.e. the group is maximal, making our algorithms look like a new (and stupid) way to simulate stabilizer states}\n\n\\begin{theorem}\n    [Eligible high-edge labels]\n\t\\label{thm:eligible-isomorphisms-pauli}\n    Let $\\lnode[w]{\\id[2]^{\\otimes n}}{v_0}{\\lambda P}{v_1}$ be a semi-reduced $n$-qubit node\n    in a Pauli-\\limdd, where $v_0, v_1$ are reduced, $P$ is a Pauli string and $\\lambda \\neq 0$.\n    For all nodes $v = \\lnode[v]{\\id[2]^{\\otimes n}}{v_0}{\\highlim}{v_1}$, it holds that $\\ket{w} \\simeq \\ket{v}$  if and only if \n    %\\todo[inline]{Tim: I just realised that the statement should be: for all semi-reduced $w$: $\\ket{w} \\simeq \\ket{v}$ if and only if $w$ has children $v_0$ and $v_1$, and the eligible high labels are of the form \\dots. Should redo}\n    \\begin{equation}\n        \\label{eq:eligible-high-label}\n    \\highlim = (-1)^s \\cdot \\lambda^{(-1)^x} g_0 P g_1\n    \\end{equation}\n        for some $g_0 \\in \\Aut(v_0), g_1 \\in \\Aut(v_1), s,x\\in \\{0, 1\\}$ and\n        $x=0$ if $v_0 \\neq v_1$.\n    An isomorphism mapping $\\ket{w}$ to $\\ket{v}$ is \n    \\begin{equation}\n        \\label{eq:root-label-eligible-high-label}\n        \\rootlim = (X \\otimes \\lambda P)^{x} \\cdot (Z^s \\otimes (g_0)^{-1}).\n    \\end{equation}\n\\end{theorem}\n\\begin{proof}\n    It is straightforward to verify that the isomorphism $\\rootlim$ in eq.~\\eqref{eq:root-label-eligible-high-label} indeed maps $\\ket{w}$ to $\\ket{v}$ (as $x = 1$ implies $v_0 = v_1$), which shows that $\\ket{w} \\simeq \\ket{v}$.\n    For the converse direction, suppose there exists an $n$-qubit Pauli LIM $C$ such that $C\\ket{w} = \\ket{v}$, i.e.\n    \\begin{equation}\n        \\label{eq:eligible-proof}\n        C\n        \\left(\\ket{0}\\otimes \\ket{v_0} + \\lambda \\ket{1} \\otimes P \\ket{v_1}\\right)\n        =\n        \\ket{0}\\otimes \\ket{v_0} + \\ket{1} \\otimes \\highlim \\ket{v_1}\n        .\n    \\end{equation}\n    We show that if $\\highlim$ satisfies eq.~\\eqref{eq:eligible-proof}, then it has a decomposition as in eq.~\\eqref{eq:eligible-high-label}.\n    \\def\\brest{C_{\\textnormal{rest}}}\n    \\def\\qtop{Q_{\\textnormal{top}}}\n    We write $C = \\qtop \\otimes \\brest$ where $\\qtop$ is a single-qubit Pauli operator and $\\brest$ is an $(n-1)$-qubit Pauli LIM (or a complex number $\\neq 0$ if $n=1$).\n    We treat the two cases $\\qtop \\in \\{\\unit_2, Z\\}$ and $\\qtop \\in \\{X, Y\\}$ separately:\n\n    \\textbf{Case $\\boldsymbol{\\unit_2, Z}$.} Then $\\qtop = \\begin{smallmat} 1& 0\\\\0 & (-1)^y\\end{smallmat}$ for $y \\in \\{0, 1\\}$.\n        In this case, eq.~\\eqref{eq:eligible-proof} implies $\\brest \\in \\Aut(\\ket{v_0})$ and $(-1)^y\\lambda \\brest P \\ket{v_1} = \\highlim \\ket{v_1}$, or, equivalently, $(-1)^{-y} \\lambda^{-1} P^{-1} \\brest^{-1} \\highlim \\in \\Aut(v_1)$.\n        Hence, by choosing $s = y$ and $x = 0$, we compute\n        \\[\n            (-1)^y \\lambda^{(-1)^0} \\underbrace{\\brest}_{\\in \\Aut(v_0)} P \\underbrace{(-1)^{-y} \\lambda^{-1} P^{-1} \\brest^{-1} \\highlim}_{\\in \\Aut(v_1)}\n            =\n            \\frac{(-1)^{y} \\lambda^{(-1)^0}}{ (-1)^y \\lambda} \\highlim\n            =\n            \\highlim\n        \\]\n    \\textbf{Case $\\boldsymbol{X, Y}$.} Write $\\qtop = \\begin{pmatrix}0& z^{-1}\\\\ z&0\\end{pmatrix}$ where $z \\in \\{1, i\\}$. Now, eq.~\\eqref{eq:eligible-proof} implies\n\t\t\\begin{equation}\n\t\t    \\label{eq:z}\n            z \\brest \\ket{v_0} = \\highlim \\ket{v_1}\n\t\t\\qquad\\textnormal{and}\\qquad\n            z^{-1} \\lambda \\brest P \\ket{v_1} = \\ket{v_0}.\n\t\t\\end{equation}\nFrom eq.~\\eqref{eq:z}, we first note that $\\ket{v_0}$ and $\\ket{v_1}$ are isomorphic, so by Corollary~\\ref{cor:node-canonicity-strong}, we have $v_0 = v_1$.\n    Consequently, we find from eq.~\\eqref{eq:z} that $z^{-1}\\brest^{-1} \\highlim \\in \\Aut(v_0)$ and $z^{-1}\\lambda \\brest P \\in \\Aut(v_1)$.\n    Now choose $x=1$ and choose $s$ such that $(-1)^s \\cdot z^{-2} \\brest^{-1} \\highlim \\brest = \\highlim$ (recall that Pauli LIMs either commute or anticommute, so $\\highlim\\brest = \\pm \\brest \\highlim$).\n    This yields:\n    \\[\n        (-1)^s \\lambda^{-1} \\cdot \\underbrace{z^{-1}\\brest^{-1} \\highlim}_{\\in \\Aut(v_0)} \\cdot P \\cdot \\underbrace{z^{-1} \\lambda P \\brest}_{\\in \\Aut(v_1)}\n        =\n        \\lambda^{-1} \\cdot \\lambda \\cdot\n        (-1)^s \n        z^{-2} \\cdot \\left(\\brest^{-1} \\highlim \\brest \\right)\n        =\n        \\highlim\n    \\]\n    where we used the fact that $P^2 = \\id[2]^{\\otimes (n-1)}$ because $P$ is a Pauli string.\n\\end{proof}\n\n%Next, we define a lexicographic ordering on LIMs:\n\n\\begin{corollary}\\label{cor:highlabel}\nAs a corollary of \\autoref{thm:eligible-isomorphisms-pauli}, we find that taking, as in \\autoref{fig:reduced},\n\\[\n\\highlabel(\\lnode[v] {\\id}{v_0}{\\lambda P}{v_1}) = \\displaystyle \\min_{\\hspace{-3mm} i,s,x \\in \\{0, 1\\},g_i \\in \\Aut(v_i)}(\\set{(-1)^s \\cdot \\lambda^{(-1)^x} \\cdot g_0 \\cdot P \\cdot g_1 ~\\Big|~ \n         x \\neq 1 \\text{ if } v_0 \\neq v_1 })\n\\]\nyields a proper implementation of \\highlabel as required by \\autoref{def:reduced-limdd},\nbecause it considers all possible \\highlim such that\n$\\ket v \\simeq_{\\Pauli} \\ket{0}\\ket{v_0}+\\ket{1}\\otimes \\highlabel(v)\\ket{v_1}$.\n\\end{corollary}\n\n\n\n% todo the procedure which chooses the lexmin element, not which constructs the isomorphism; this causes confusion\n\n%, with high edge label $\\lambda P$ and children $v_0, v_1$ as input, computes the minimal eligible high edge label and the root edge label that preserves the represented quantum state.\nA naive implementation for \\textsc{GetLabels} would follow the possible decompositions of eligible LIMs (see eq.~\\eqref{eq:eligible-high-label}) and attempt to make this LIM smaller by greedy multiplication, first  with stabilizers of\n$g_0 \\in \\Aut(v_0)$, and then with stabilizers $g_1\\in \\Aut(v_1)$.\nTo see why this does not work, consider the following example:\nthe high edge label is $Z$ and the stabilizer subgroups $\\Aut(v_0) = \\langle X\\rangle$ and $\\Aut(v_1) = \\langle Y \\rangle$.\nThen the naive algorithm would terminate and return $Z$ because $X, Y> Z$, which is incorrect since the high-edge label $X \\cdot Z \\cdot Y = -i \\id[2]$ is smaller than $Z$.\n\n\\begin{algorithm}\n\t\\caption{\n\t\tAlgorithm for finding the LIMs $\\highlim$ and $\\rootlim$ required by \\makeedge.\n\t\tThe LIM $\\highlim$ is chosen canonically as the lexicographically smallest LIM in \n\t\tthe set characterized in \\autoref{thm:eligible-isomorphisms-pauli}.\n\t\tIt runs in $O(n^3)$-time (with $n$ the number of qubits),\n\t\tprovided $\\getautomorphisms$ has been computed for the children $v_0, v_1$.\n\t\t\\label{alg:find-canonical-edges}\n\t}\n\t\\begin{algorithmic}[1]\n\t\t\\Procedure{GetLabels}{PauliLim $\\lambda P \\neq 0$ (current high label), reduced children nodes $v_0, v_1$}\n\t\t\\Statex \\textbf{Output}: canonical high label $\\highlim$ and root label $\\rootlim$\n\t\t\\State $G_0, G_1 := \\getautomorphisms(v_0), \\getautomorphisms(v_1)$\n\t\t\\State $(g_0, g_1) := \\textsc{ArgLexMin}(G_0, G_1, \\lambda P)$\n%\t\t\\label{line:getlabels-min}\n\t\t\\label{line:getlabels-argmin}\n%\t\t\\State $A := \\lambda P \\cdot g_0 \\cdot g_1$\n%\t\t\\Comment $A = \\textsc{LexMin}(G_0, G_1, \\lambda P)$\n\t\t%        \\State \\textbf{if} $P$ and $g_0$ commute \\textbf{then} $t:=0$ \\textbf{else} $t:=1$\n\t\t%        \\label{line:sign-error}\n\t\t%        \\Comment $A =  (-1)^t \\cdot g_0 \\cdot \\lambda P \\cdot g_1$\n\t\t%\n\t\t\\If{$v_0=v_1$}\n\t\t\\label{algline:getlabels-start-minimizing}\n\t\t\\State $(x,s):=\\displaystyle\\argmin_{(x,s)\\in\\{0,1\\}^2}(-1)^s\\lambda^{(-1)^x}g_0Pg_1$\n\t\t\\Else\n\t\t\\State $x:=0$\n\t\t\\State $s:=\\displaystyle \\argmin_{s\\in \\{0,1\\}} (-1)^s\\lambda g_0Pg_1$\n\t\t\\label{line:minimized-lim} \n\t\t\\EndIf\n\t\t%        \\State $x := 0$\n\t\t%        \\If {$v_0 = v_1$}  x  := $\\displaystyle\\argmin_{ \n\t\t%             x\\in \\set{0, 1}}  \n\t\t%        \\set{ (-1)^t \\cdot \\lambda^{(-1)^x} \\cdot g_0 \\cdot P \\cdot g_1}$\n\t\t%        \\Comment see \\autoref{thm:eligible-isomorphisms-pauli}\n\t\t%        \\EndIf\n\t\t%        \\State $s:= \\displaystyle\\argmin_{s\\in \\set{0,1}}\\set{(-1)^s\\cdot (-1)^t \\lambda^{(-1)^x} \\cdot g_0 \\cdot  P  \\cdot g_1} $\n\t\t\\State $\\highlim := (-1)^s \\cdot \\lambda^{(-1)^x} \\cdot g_0 \\cdot P \\cdot g_1$\n\t\t\\State $\\rootlim := (X \\otimes \\lambda P)^{x} \\cdot (Z^s \\otimes (g_0)^{-1})$\n\t\t%\n\t\t\\State \\Return $(\\highlim, \\rootlim)$\n\t\t\\EndProcedure\n\t\\end{algorithmic}\n\\end{algorithm}\n\nTo overcome this, we consider the group closure of \\emph{both} $\\Aut(v_0)$ \\emph{and} $\\Aut(v_1)$.\nSee \\autoref{alg:find-canonical-edges} for the $O(n^3)$-algorithm for \\textsc{GetLabels}, which proceeds in two steps.\nIn the first step (\\autoref{line:getlabels-argmin}), we use the subroutine \\textsc{ArgLexMin} for finding the minimal Pauli LIM $A$ such that $A = \\lambda P \\cdot g_0 \\cdot g_1$ for $g_0\\in \\Aut(v_0), g_1\\in \\Aut(v_1)$.\nWe will explain and prove correctness of this subroutine below in \\autoref{sec:lexmin}.\n%Next, note that the eligible-high-label expression in eq.~\\eqref{eq:eligible-high-label} contains the factor $g_0 \\cdot \\lambda P \\cdot g_1$ instead of $\\lambda P \\cdot g_0 \\cdot g_1$; however, these differ by a factor $\\pm 1$ because Pauli LIMs either commute or anticommute.\n%This potential sign error is corrected in \\autoref{line:sign-error}.\nIn the second step (Lines \\ref{algline:getlabels-start-minimizing}-\\ref{line:minimized-lim}), we follow eq.~\\eqref{eq:root-label-eligible-high-label} by also minimizing over $x$ and $s$.\nFinally, the algorithm returns $\\highlim$, the minimum of all eligible edge labels according to eq.~\\eqref{eq:root-label-eligible-high-label}, together with a root edge label $\\rootlim$ which ensures the represented quantum state remains the same.\n\nBelow, we will explain $O(n^3)$-time algorithms for finding generating sets for the stabilizer subgroup of a reduced node and for \\textsc{ArgLexMin}.\nSince all other lines in \\autoref{alg:find-canonical-edges} can be performed in linear time, its overall runtime is $O(n^3)$.\nNote that we can amortize $\\getautomorphisms$ over the \\makeedge calls.\n\n\n\n\n\n\n\n\n\n%We now define the \\highlabel~function, which computes the canonical root label following \\autoref{def:reduced-limdd}, as the function invoking \\autoref{alg:find-canonical-edges} on a semi-reduced node $\\lnode{\\id}{v_0}{\\lambda P}{v_1}$ and returning $\\highlabel$.\n%Above, we have argued that $\\highlabel$ thus returns the minimal eligible high label.\n%It follows immediately from this fact that \\highlabel~is correct, i.e. it obeys its requirement in \\autoref{def:reduced-limdd}.\n\n%\\begin{lemma}\n%    Let $v_0, v_1$ be reduced $n$-qubit nodes, and $A$ an $n$-qubit Pauli LIM.\n%    Then \\autoref{alg:find-canonical-edges} on input $(A, v_0, v_1)$, outputs \n%            $\\displaystyle \\min_{\\textnormal{$n$-Pauli LIM} B} \\{B \\mid  B\\ket{v_A} = \\ket{v_B}\\}$,\\todo{$B \\in $ ?}\n%    where we have denoted $\\ket{v_C} = \\ket{0}\\otimes\\ket{v_0} + \\ket{1} \\otimes C \\ket{v_1}$ for a Pauli LIM $C$\n%    and a \\alfons{semi-reduced node $v_C$}.\n%\\end{lemma}\n%\\begin{proof}\n%    \\todo[inline]{TODO}\n%\\end{proof}\n\n\n\n\n\n\n\\subsubsection{Constructing the stabilizer subgroup of a \\limdd node}\n\\label{sec:pauli-isomorphism-detection}\n\nIn this section, we give a recursive subroutine \\getautomorphisms to construct the stabilizer subgroup $\\Aut(\\ket{v}) := \\{A \\in \\paulilim_n \\mid A\\ket{v} = \\ket{v}\\}$ of an $n$-qubit \\limdd node~$v$ (see \\autoref{sec:preliminaries}).\nThe subroutine is used by the algorithm \\textsc{GetLabels} to select a canonical label for the high edge and root edge.\nIf the stabilizer subgroup of $v$'s children have been computed already, \\getautomorphisms's runtime is $O(n^3)$.\n\\getautomorphisms returns a generating set for the group $\\Stab(\\ket{v})$.\nSince these stabilizer subgroups are generally exponentially large in the number of qubits $n$, but they have at most $n$ generators, storing only the generators instead of all elements may save an exponential amount of space.\n%Each $n$-qubit stabilizer subgroup has a generator set of size at most $n$.\nBecause any generator set $G$ of size $|G|>n$ can be brought back to at most $n$ generators in time $\\oh(|G| \\cdot n^2)$ (see \\autoref{sec:preliminaries}), we will in the derivation below show how to obtain generator sets of size linear in $n$ and leave the size reduction implicit.\nWe will also use the notation $A \\cdot G$ and $G \\cdot A$ to denote the sets $\\{A \\cdot g | g\\in G\\}$ and $\\{g \\cdot A | g \\in G\\}$, respectively.\n\nWe now sketch the derivation of the algorithm.\nThe base case of the algorithm is the Leaf node of the \\limdd, representing the number $1$, which has stabilizer group $\\{1\\}$.\nFor the recursive case, we wish to compute the stabilizer group of a reduced $n$-qubit node $v=\\lnode[v]{v_0}{\\mathbb I}{\\highlim}{v_1}$.\nIf $\\highlim=0$, then it is straightforward to see that $\\lambda P_n \\otimes P'\\ket{v} = \\ket{v}$ implies $P_n \\in \\{\\id[2], Z\\}$, and further that $\\Aut(\\ket{v}) = \\langle \\{P_n \\otimes g \\mid g\\in G_0, P_n \\in \\{\\id[2], Z\\}\\} \\rangle$, where $G_0$ is a stabilizer generator set for $v_0$.\n\nIf $\\highlim \\neq 0$, then we expand the stabilizer equation $\\lambda P \\ket{v} = \\ket{v}$:\n\\[\n\\lambda P_n \\otimes P' \\left(\\ket 0 \\otimes\\ket{v_0} + \\ket 1 \\otimes \\highlim \\ket{v_1} \\right)  = \\ket 0 \\otimes\\ket{v_0} +  \\ket 1 \\otimes \\highlim \\ket{v_1}, \\text{which implies:}\n\\]\n%&&& \\nonumber\\\\\n\\begin{align}\n  \\lambda P' \\ket{v_0} =  \\ket{v_0}  ~&\\land~ z \\lambda P' \\highlim \\ket{v_1} = \\highlim \\ket{v_1}\n            & \\textbf{for } P_n= \\diag z,z\\in\\set{1,-1} \\label{eq:diag} \\\\\n  y^* \\lambda P' \\highlim \\ket{v_1} =  \\ket{v_0}  ~ &\\land~ \\lambda P' \\ket{v_0} = y^*\\highlim \\ket{v_1}\n             & \\textbf{for } P_n= \\yy, y\\in\\set{1,i} \n             \\label{eq:anti}\n\\end{align}\nThe stabilizers can therefore be computed according to \\autoref{eq:diag} and \\ref{eq:anti} as follows.\n%Here we have to make case distinctions because (unfortunately) LIM selection relies on the other reduction rules.\n\\begin{align}     \n    \\nonumber\n    \\Aut(\\ket{v}) =\n    \\bigcup_{\\hspace{-8mm}z = \\in\\set{1,-1} , y \\in\\set{1, i}\\hspace{-8mm}}&\n          \\diag z \\otimes ( \\Aut(\\ket{v_0}) \\cap z\\cdot \\Aut(\\highlim\\ket{v_1}) )\n          \\\\\n          &\n \\cup \n          \\\n    \\ww \\otimes  \n    \\big(\n    \\Iso( y^* \\highlim\\ket{v_1}, \\ket{v_0})  \\cap \\Iso( \\ket{v_0}, y^* \\highlim\\ket{v_1})  \n    \\big) \n    \\label{eq:aut-a}\n\\end{align}\nwhere $\\Iso(v, w)$ denotes the set of Pauli isomorphisms $A$ which map $\\ket{v}$ to $\\ket{w}$ and we have denoted $\\pi \\cdot G := \\{\\pi \\cdot g \\mid g \\in G\\}$ for a set $G$ and a single operator $\\pi$.\n\\autoref{lemma:isomorphism-set-characterization} shows that such an isomorphism set can be expressed in terms of the stabilizer group of $\\ket{v}$.\n%Such isomorphism sets are precisely the stabilizers of $v$, seeded with a single isomorphism $v \\rightarrow w$\n%as \\autoref{lemma:isomorphism-set-characterization} shows.\n\n\\def\\Pauli{\\textnormal{\\textsc{Pauli}}}\n\\begin{lemma}\n    \\label{lemma:isomorphism-set-characterization}\n    Let $\\ket{\\phi}$ and $\\ket{\\psi}$ be quantum states on the same number of qubits.\n    Let $\\pi$ be a Pauli isomorphism mapping $\\ket{\\phi}$ to $\\ket{\\psi}$.\n    Then the set of Pauli isomorphisms mapping $\\ket{\\phi}$ to $\\ket{\\psi}$ is\n    $\\Iso(\\ket{v},\\ket{w})=\\pi \\cdot \\Aut(\\ket{\\phi})$.\n    That is, the set of isomorphisms $\\ket{\\phi} \\rightarrow \\ket{\\psi}$ is a coset of the stabilizer subgroup of $\\ket{\\phi}$.\n\\end{lemma}\n\\begin{proof}\n    If $P\\in \\Aut(\\ket{\\phi})$, then $\\pi \\cdot P$ is an isomorphism since $\\pi \\cdot P \\ket{\\phi} = \\pi \\ket{\\phi} = \\ket{\\psi}$.\n    Conversely, if $\\sigma$ is a Pauli isomorphism which maps $\\ket{\\phi}$ to $\\ket{\\psi}$, then $ \\pi^{-1} \\sigma \\in \\Aut(\\ket{\\phi})$ because $\\pi^{-1} \\sigma \\ket{\\phi} = \\pi^{-1} \\ket{\\psi} = \\ket{\\phi}$.\n    Therefore $\\sigma=\\pi(\\pi^{-1}\\sigma)\\in \\pi \\cdot \\Aut(\\ket{\\phi})$.\n\\end{proof}\nWith \\autoref{lemma:isomorphism-set-characterization} we can rewrite eq.~\\eqref{eq:aut-a} as\n\\begin{align}     \n    \\nonumber\n    \\Aut(\\ket{v}) =& %~=~ \\hspace{-.9cm}\\hspace{-.5cm}\n          \\id[2] \\otimes \\underbrace{( \\Aut(\\ket{v_0}) \\cap \\Aut(\\highlim\\ket{v_1}) )}_{\\textnormal{stabilizer subgroup}} \\\\\n          & \\cup Z \\otimes \\underbrace{( \\id \\cdot \\Aut(\\ket{v_0}) \\cap -\\id \\cdot \\Aut(\\highlim\\ket{v_1}) )}_{\\textnormal{isomorphism set}} \n          \\nonumber\n          \\\\\n          &\\cup \n          \\bigcup_{y \\in\\set{1, i}}\n          \\\n    \\ww \\otimes  \\underbrace{\n        \\big(\n        \\pi\n        \\cdot\n        \\Aut(y^* \\highlim \\cdot \\ket{v_1})\n        \\cap\n        \\pi^{-1}\n        \\cdot\n        \\Aut(\\ket{v_0})}_{\\textnormal{isomorphism set}}\n        \\big)\n    \\label{eq:aut-simplified}\n\\end{align}\nwhere $\\pi$ denotes a single isomorphism $y^* \\highlim\\ket{v_1}  \\rightarrow \\ket{v_0}$.\n\n\nGiven generating sets for $\\Aut(v_0)$ and $\\Aut(v_1)$, evaluating eq.~\\eqref{eq:aut-simplified} requires us to:\n\n\\begin{itemize}\n        \\setlength\\itemsep{1em}\n    \\item \\textbf{Compute $\\Aut(A\\ket{w})$ from $\\Aut(w)$ (as generating sets) for Pauli LIM $A$ and node $w$.} It is straightforward to check that $\\{A g A^{\\dagger} \\mid g \\in G\\}$, with $\\langle G \\rangle = \\Aut(w)$, is a generating set for $\\Aut(A\\ket{w})$.\n    \\item \\textbf{Find a single isomorphism between two edges, pointing to reduced nodes.} In a reduced \\limdd, edges represent isomorphic states if and only if they point to the same nodes. This results in a straightforward algorithm, see \\autoref{alg:getsingleisomorphism}.\n    \\item \\textbf{Find the intersection of two stabilizer subgroups, represented as generating sets $G_0$ and $G_1$ (\\autoref{alg:intersectstabilizergroups}).} \n        First, it is straightforward to show that the intersection of two stabilizer subgroups is again a stabilizer subgroup (it is never empty since $\\id$ is a stabilizer of all states).\n        \\autoref{alg:intersectstabilizergroups} will find a generating set $G_U$ for the conjugated intersection of $\\langle UG_0 U^{\\dagger} \\rangle \\cap \\langle U G_1 U^{\\dagger} \\rangle$ for a suitably chosen $U$, followed by returning $U^{\\dagger} G_U U$ as a generating set for the target intersection $\\langle G_0 \\rangle \\cap \\langle G_1 \\rangle$.\n        As unitary $U$, we choose an $n$-qubit unitary $U$ which maps $G_0$ to the generating set\n        % todo this should be UG_1U^\\dagger\n        \\[\n            UG_0 U^{\\dagger} = \\{Z_1, Z_2, \\dots, Z_{|G_0|}\\}\n        \\]\n        where $Z_k$ denotes a $Z$ gate on qubit with index $k$, i.e., \n        \\[\n            Z_k := \\id \\otimes \\id \\otimes \\dots \\otimes \\id \\otimes \\underbrace{Z}_{\\mathclap{\\textnormal{position k}}} \\otimes \\id \\otimes \\dots \\otimes \\id.\n        \\]\n        Such a unitary always exists and can be found in time $O(n^3)$ using Algorithm 2 from \\cite{garcia2012efficient}.\n        It is not hard to see that the Pauli string of all LIMs in $\\langle U G_0 U^{\\dagger}\\rangle$ is a $Z$ or $\\id$.\n        Therefore, to find the intersection of this group with $\\langle UG_1 U^{\\dagger}\\rangle$, we only need to bring $U G_1 U^{\\dagger}$ into RREF form (see \\autoref{sec:preliminaries}), followed by discarding all generators in the RREF form whose pivot corresponds to an $X$ or an $Y$, i.e. its pivot is a $1$ in the X-block when representing a generator as a check vector (see \\autoref{sec:preliminaries}).\n        Both the resulting generator set (called $H_1$ in \\autoref{alg:intersectstabilizergroups}) and $U G_0 U^{\\dagger}$ are subsets of the group of Pauli LIMs with scalars $\\pm 1$ and Pauli strings with only $\\id$ and $Z$.\n        These groups are finite and abelian.\n        We use the Zassenhaus algorithm \\cite{LUKS1997335} to find a generating set $H'$ for the intersection of $\\braket{H_1}\\cap \\braket{UG_0 U^{\\dagger}}$ (in particular, the groups $\\braket{H_1}$ and $\\braket{UG_0U^\\dagger}$ are group isomorphic to Boolean vector spaces, where addition corresponds to XOR-ing. Hence we may think of $H_1$ and $UG_0 U^{\\dagger}$ as bases of linear subspaces. The Zassenhaus algorithm computes a basis for the intersection of the two linear subspaces.)\n        The final step is to perform the inverse conjugation map and return $U^{\\dagger} H' U$.\n        All of the above steps can be performed in $O(n^3)$ time; in particular, the operator $U$ as found by Algorithm 2 from \\cite{garcia2012efficient} consists of at most $O(n^2)$ Cliffords, each of which can be applied to a check matrix in time $O(n)$, yielding $O(n^3)$ time required for evaluating $G \\mapsto U G U^{\\dagger}$.\n        Hence the overall runtime of \\autoref{alg:intersectstabilizergroups} is $O(n^3)$ also.\n    \\item \\findisomorphismsetintersection: \\textbf{Find the intersection of two isomorphism sets, represented as single isomorphism ($\\pi_0, \\pi_1$) with a generator set of a stabilizer subgroup ($G_0, G_1$), see \\autoref{lemma:isomorphism-set-characterization}.} \n        This is the \\emph{coset intersection problem} for the $\\paulilim_n$ group.\n        Isomorphism sets are coset of stabilizer groups (see \\autoref{lemma:isomorphism-set-characterization}) and it is not hard to see that that the intersection of two cosets, given as isomorphisms $\\pi_{0/1}$ and generator sets $G_{0/1}$, is either empty, or a coset of $\\langle G_0 \\rangle \\cap \\langle G_1 \\rangle$ (computed using \\autoref{alg:intersectstabilizergroups}).\n        Therefore, we only need to determine an isomorphism $\\pi \\in \\pi_0 \\langle G_0\\rangle \\cap \\pi_1 \\langle G_1 \\rangle$, or infer that no such isomorphism exists.\n\n        We solve this problem in $O(n^3)$ time in two steps (see \\autoref{alg:findisointersection} for the full algorithm).\nFirst, we note that that $\\pi_0 \\langle G_0 \\rangle \\cap \\pi_1 \\langle G_1 \\rangle = \\pi_0 [\\langle G_0 \\rangle \\cap (\\pi_0^{-1} \\pi_1) \\langle G_1 \\rangle]$, so we only need to find an element of the coset $S:= \\langle G_0 \\rangle \\cap (\\pi_0^{-1} \\pi_1) \\langle G_1 \\rangle$.\n        Now note that $S$ is nonempty if and only if there exists $g_0 \\in \\langle G_0 \\rangle, g_1 \\in \\langle G_1 \\rangle$ such that $g_0 = \\pi_0^{-1} \\pi_1 g_1$, or, equivalently, $\\pi_0^{-1} \\pi_1 \\cdot g_1 \\cdot g_0^{-1} = \\id$.\n        We show in \\autoref{lemma:id-smallest-in-coset} that such $g_0, g_1$ exist if and only if $\\id$ is the smallest element in the set $S\\pi_0^{-1}\\pi_1\\braket{G_1}\\cdot\\braket{G_0}$.\n        Hence, for finding out if $S$ is empty we may invoke the \\textsc{LexMin} algorithm we have already used before in \\textsc{GetLabels} and we will explain below in \\autoref{sec:lexmin}.\n        If it is not empty, then we obtain $g_0, g_1$ as above using \\textsc{ArgLexMin}, and output $\\pi_0 \\cdot g_0$ as an element in the intersection.\n        Since \\textsc{Lexmin} and \\textsc{ArgLexMin} take $O(n^3)$ time, so does \\autoref{alg:findisointersection}.\n\\end{itemize}\n\n\\begin{lemma}\n    \\label{lemma:id-smallest-in-coset}\n    The coset $S:= \\langle G_0 \\rangle \\cap \\pi_1^{-1}\\pi_0 \\cdot \\langle G_1 \\rangle$ is nonemtpy if and only if the lexicographically smallest element of the set $S=\\pi_0^{-1}\\pi_1\\braket{G_1}\\cdot\\braket{G_0}=\\{\\pi_0^{-1}\\pi_1g_1g_0|g_0\\in G_0,g_1\\in G_1\\}$ is $1 \\cdot \\id$.\n%    If indeed $S \\neq \\emptyset$, i.e. there exist $g_0 \\in \\langle G_0\\rangle, g_1 \\in \\langle G_1 \\rangle$ such that $1\\cdot \\id = \\pi_0 \\cdot g_0\n%    contains $\\lambda \\unit$ is an element of a coset $\\pi \\cdot \\Aut(v)$ for some isomorphism $\\pi$ and node $v$\n\\end{lemma}\n\\begin{proof}\n\t(Direction $\\rightarrow$)\n\tSuppose that the set $\\braket{G_0}\\cap \\pi_0^{-1}\\pi_1\\braket{G_1}$ has an element $a$.\n\tThen $a=g_0=\\pi_0^{-1}\\pi_1g_1$ for some $g_0\\in \\braket{G_0},g_1\\in\\braket{G_1}$.\n\tWe see that $\\mathbb I=\\pi_0^{-1}\\pi_1g_1g_0^{-1}\\in \\pi_0^{-1}\\pi_1\\braket{G_1}\\cdot \\braket{G_0}$, i.e., $\\mathbb I\\in S$.\n\tNote that $\\mathbb I$ is, in particular, the lexicographically smallest element, since its check vector is the all-zero vector $(\\vec 0|\\vec 0|00)$.\n\t\n\t(Direction $\\leftarrow$)\n\tSuppose that $\\mathbb I\\in \\pi_0^{-1}\\pi_1\\braket{G_1}\\cdot\\braket{G_0}$.\n\tThen $\\mathbb I=\\pi_0^{-1}\\pi_1g_1g_0$, for some $g_0\\in \\braket{G_0},g_1\\in\\braket{G_1}$, so we get $g_0^{-1}=\\pi_0^{-1}\\pi_1g_1\\in \\braket{G_0}\\cap \\pi_0^{-1}\\pi_1\\braket{G_1}$, as promised.\n\\end{proof}\n\nThe four algorithms above allow us to evaluate each of the four individual terms in eq.~\\eqref{eq:aut-simplified}.\nTo finish the evaluation of eq.~\\eqref{eq:aut-simplified}, one would expect that it is also necessary that we find the union of isomorphism sets.\nHowever, we note that if $\\pi G$ is an isomorphism set, with $\\pi$ an isomorphism and $G$ an stabilizer subgroup, then $P_n \\otimes (\\pi g) = (P_n \\otimes \\pi) (\\id[2] \\otimes g)$ for all $g\\in G$.\nTherefore, we will evaluate eq.~\\eqref{eq:aut-simplified}, i.e. find (a generating set) for all stabilizers of node $v$ in two steps.\nFirst, we construct the generating set for the first term, i.e. $\\id[2] \\otimes ( \\Aut(\\ket{v_0}) \\cap \\Aut(\\highlim \\ket{v_1}) )$, using the algorithms above.\nNext, for each of the other three terms $P_n \\otimes (\\pi G)$, we add only \\textit{a single} stabilizer of the form $P_n \\otimes \\pi$ for each $P_n \\in \\{X, Y, Z\\}$.\nWe give the full algorithm in \\autoref{alg:getautomorphisms} and prove its efficiency below.\n\n\n\\begin{lemma}[Efficiency of function \\getautomorphisms]\n    Let $v$ be an $n$-qubit node.\n    Assume that generator set for the stabilizer subgroups of the children $v_0, v_1$ are known, e.g. by an earlier call to \\getautomorphisms, followed by caching the result (see \\autoref{line:autocache-store} in \\autoref{alg:getautomorphisms}).\n   Then \\autoref{alg:getautomorphisms} (function \\getautomorphisms), applied to $v$, runs in time $O(n^3)$.\n\\end{lemma}\n\\begin{proof}\n    If $n=1$ then \\autoref{alg:getautomorphisms} only evaluates \\autoref{line:stabalgo-first}--\\ref{line:stabalgo-second}, which run in constant time.\n    For $n>1$, the algorithm performs a constant number of calls to \\getsingleisomorphism (which only multiplies two Pauli LIMs and therefore runs in time $O(n)$) and four calls to \\findisomorphismsetintersection.\n    Note that the function \\findisomorphismsetintersection~from \\autoref{alg:findisointersection} invoke $O(n^3)$-runtime external algorithms (the Zassenhaus algorithm \\cite{LUKS1997335}, RREF algorithm from \\autoref{sec:preliminaries}, and Algorithm 2 from \\cite{garcia2012efficient}), making its overall runtime $O(n^3)$ also.\n    Therefore, \\getautomorphisms has runtime is $O(n^3)$.\n\\end{proof}\n\n\n\n%%% THIS ALGORITHM CAUSES A FLOATS LOST ERROR ----\n\n%\n\\begin{algorithm}\n    \\caption{Algorithm for constructing the Pauli stabilizer subgroup of a Pauli-\\limdd~node}\n    \\label{alg:getautomorphisms}\n    \\begin{algorithmic}[1]\n        \\Procedure{\\getautomorphisms}{\\Edge $\\ledge[e_0]{\\unit_2^{\\otimes n}}{v_0}, \\ledge[e_1]{\\highlim}{v_1}$ \\textbf{with} $v_0, v_1$ reduced}\n        \\If{n=1}\n        \\label{line:stabalgo-first}\n        \\If{ there exists $P \\in \\pm 1 \\cdot \\{X, Y, Z\\}$ \\textbf{such that} $P \\ket v = \\ket v$} \\Return $P$ \\Else \\mbox{ } \\Return \\none\n        \\label{line:stabalgo-second}\n        \\EndIf\n%        \\EndIf\n        \\Else       \n        \\If{$v \\in \\autocache[v]$}\n        \\Return $\\autocache[v]$\n        \\EndIf\n         \\State $G_0 := \\getautomorphisms(v_0)$\n        \\If{$\\highlim = 0$}\n       \t     \\State \\Return $\\set{\\mathbb I_2\\otimes g , ~ \\mathbb Z\\otimes g  \\mid g\\in G_0}$\n             \\label{line:stab-fork}\n        \\Else\n       \t\\State $G:= \\emptyset$\n        %\n        \\Comment Add all automorphisms of the form $\\unit_2 \\otimes \\dots$ :\n        \\State $G_1 := \\{A_1^{\\dagger} g A_1 \\mid g \\in \\getautomorphisms(v_1)\\}$\n        \\State $(\\pi, B):= \\findisomorphismsetintersection(( \\unit_2^{\\otimes n - 1}, G_0), ( \\unit_2^{\\otimes n - 1}, G_1))$\n        \\State $G := G \\cup \\set{\\mathbb I_2\\otimes g  \\mid g\\in B}$\n        %\n        %\\State $(\\pi, G):= \\findisomorphismsetintersection(\\getsingleisomorphism(\\phi_0,\\phi_0), \\getsingleisomorphism(\\phi_1,-\\phi_1))$\n        \\State\n%        \\For{$x\\in \\set{0,1}, z\\in {-1,1}$}\n        \\State $\\pi_0, \\pi_1 := \\unit_2^{\\otimes n - 1}, \\getsingleisomorphism(e_1,-1 \\cdot e_1)$ \n        \\State $(\\pi, B):= \\findisomorphismsetintersection((\\pi_0, G_0), (\\pi_1, G_1))$\n         \\If{$\\pi \\neq \\text{None}$ }   $G := G \\cup \\{Z\\otimes \\pi\\}$ \n     \t         \\Comment Add stabilizer of form $Z \\otimes \\dots$\n     \t \\EndIf\n        %\n        \\State\n        \\State $\\pi_0, \\pi_1 := \\getsingleisomorphism(e_0,e_1), \\getsingleisomorphism(e_1, e_0))$\n        \\State $(\\pi, B):= \\findisomorphismsetintersection((\\pi_0, G_0), (\\pi_1, G_1))$\n         \\If{$\\pi \\neq \\text{None}$ }   $G := G \\cup \\{X\\otimes \\pi\\}$ \n     \t         \\Comment Add stabilizer of form $X \\otimes \\dots$\n     \t \\EndIf \n        %\n        \\State\n        \\State $\\pi_0, \\pi_1 := \\getsingleisomorphism(e_0, -i \\cdot e_1), \\getsingleisomorphism(-i\\cdot e_1, e_0))$\n        \\State $(\\pi, B):= \\findisomorphismsetintersection((\\pi_0, G_0), (\\pi_1, G_1))$\n         \\If{$\\pi \\neq \\text{None}$ }   $G := G \\cup \\{Y\\otimes \\pi\\}$ \n     \t         \\Comment Add stabilizer of form $Y \\otimes \\dots$\n     \t \\EndIf\n        \\EndIf\n        %\n        \\State $\\autocache[v] := G$\n        \\label{line:autocache-store}\n\t\t\\State \\Return $G$\n        \\EndIf\n        \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\begin{algorithm}\n    \\caption{Algorithm for constructing a single isomorphism between two Pauli-\\limdd~edges, each pointing to canonical nodes.\n    }\n    \\label{alg:getsingleisomorphism}\n    \\begin{algorithmic}[1]\n        \\Procedure{\\getsingleisomorphism}{\\Edge $\\ledge Av$, \\Edge $\\ledge Bw$ \\textbf{with} $v, w$ reduced, \\mbox{$A\\neq 0 \\vee B \\neq 0$}}\n        \\If{$v = w \\land A,B \\neq 0 $}\n        \\State \\Return $B \\cdot A^{-1}$\n        \\EndIf\n        \\State \\Return \\none\n        \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\n\n\n\\begin{algorithm}\n    \\caption{\n        \\label{alg:intersectstabilizergroups}\n    }\n    \\begin{algorithmic}[1]\n        \\Procedure{IntersectStabilizerGroups}{stabilizer subgroup generating sets $G_0, G_1$}\n        \\Statex \\textbf{Output}: a generating set for $\\langle G_0 \\rangle \\cap \\langle G_1 \\rangle$\n        \\State Compute $U$ s.t. $H_0 := U G_0 U^{\\dagger} = \\{Z_1, Z_2, \\dots, Z_{|G_0|}\\}$, using Algorithm 2 from \\cite{garcia2012efficient}\n        \\State $H_1 := U G_1 U^{\\dagger}$\n        \\State Bring $H_1$ into RREF form\n        \\State Discard any generators from $H_1$ whose check vector has a $1$ in the $X$ block as pivot\n        \\Comment See also \\autoref{sec:preliminaries}\n        \\State $H':=$ generating set for $\\langle H_0 \\rangle \\cap \\langle H_1 \\rangle$\n        \\Comment Computed using the Zassenhaus algorithm for finding the intersection of vector subspaces\n        \\State \\Return $U^{\\dagger} H' U$ \n        \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\begin{algorithm}\n    \\caption{$O(n^3)$ algorithm for computing the intersection of two sets of isomorphisms, each given as single isomorphism with a stabilizer subgroup (see \\autoref{lemma:isomorphism-set-characterization}).\n    \\label{alg:findisointersection}\n    }\n    \\begin{algorithmic}[1]\n        \\Procedure{IntersectIsomorphismSets}{stabilizer subgroup generating sets $G_0, G_1$ and Pauli-LIMs $\\pi_0, \\pi_1$}\n        \\Statex \\textbf{Output}: a Pauli LIM $\\pi$ and a stabilizer subgroup generating set $G$ such that $\\pi \\langle G \\rangle = \\pi_0 \\langle G_0 \\rangle \\cap \\pi_1 \\langle G_1 \\rangle$\n        \\State $\\pi := LexMin(G_0, G_1, \\pi_1^{-1}\\pi_0)$\n        \\If{$\\pi = \\id$}\n        \\State $(g_0, g_1) = ArgLexMin(G_0, G_1, \\pi_1^{-1}\\pi_0)$\n        \\State $\\pi := \\pi_0 \\cdot g_0$\n        \\State $G := IntersectStabilizerGroups(G_0,G_1)$\n        \\State \\Return $(\\pi, G)$\n        \\Else\n        \\State \\Return \\none\n        \\EndIf\n        \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\\subsubsection{Efficiently finding a minimal LIM by multiplying with stabilizers}\n\\label{sec:lexmin}\n\nHere, we give $O(n^3)$ subroutines solving the following problem: given generators sets $G_0, G_1$ of stabilizer subgroups on $n$ qubits, and an $n$-qubit Pauli LIM $A$, determine $\\min_{(g_0, g_1) \\in \\langle G_0 , G_1 \\rangle} A \\cdot g_0 \\cdot g_1$, and also find the $g_0, g_1$ which minimize the expression.\nWe give an algorithm for finding both the minimum (\\textsc{LexMin}) and the arguments of the minimum (\\textsc{ArgLexMin}) in \\autoref{alg:lexmin}.\nThe inuition behind the algorithms are the following two steps: first, the lexicographically minimum Pauli LIM \\emph{modulo scalar} can easily be determined using the scalar-ignoring DivisionRemainder algorithm from \\autoref{sec:preliminaries}.\nSince in the lexicographic ordering, the scalar is least significant (\\autoref{sec:preliminaries}), the resulting Pauli LIM has the same Pauli string as the the minimal Pauli LIM \\emph{including scalar}.\nWe show below in \\autoref{thm:pauli-group-means-pm-1} that if the scalar-ignoring minimization results in a Pauli LIM $\\lambda P$, then the only other eligible LIM, if it exists, is $-\\lambda P$.\nHence, in the next step, we only need to determine whether such LIM $-\\lambda P$ exists and whether $- \\lambda < \\lambda$; if so, then $-\\lambda P$ is the real minimal Pauli LIM $\\in \\langle G_0 \\cup G_1\\rangle$.\n\n\\begin{lemma}\n\t\\label{thm:pauli-group-means-pm-1}\n    Let $v_0$ and $v_1$ be \\limdd nodes, $R$ a Pauli string and $\\nu, \\nu' \\in \\mathbb{C}$.\n    Define $G = \\Aut(v_0) \\cup \\Aut(v_1)$.\nIf $\\nu R, \\nu' R \\in \\langle G\\rangle$, then $\\nu = \\pm \\nu'$.\n\\end{lemma}\n\\begin{proof}\n    We prove $g \\in \\langle G \\rangle \\implies \\pm i g \\notin \\langle G \\rangle$, which is equivalent to the statement in the lemma because each product of stabilizers from different stabilizer subgroups has scalar $\\pm 1$ or $\\pm i$ (follows from the facts that stabilizers hold scalar $\\pm 1$ and multiplying Pauli strings yields a scalar $\\in \\{\\pm 1, \\pm i\\}$).\n    To reach a contradiction, assume there exists a $g\\in \\langle G \\rangle$ for which $\\pm i g \\in \\langle G \\rangle$ also.\n    Since Pauli LIMs commute or anticommute, we can decompose both as $g = (-1)^x g_0 g_1$ and $\\pm i g = (-1)^y h_0 h_1$ for some $x, y \\in \\{0, 1\\}$ and $g_0, h_0\\in \\Aut(v_0)$ and $g_1, h_1 \\in \\Aut(v_1)$.\n    Combining yields $\\pm i (-1)^x g_0 g_1 = (-1)^y h_0 h_1$, which we rewrite as $\\pm i (-1)^{x+y} \\underbrace{g_1 h_1^{-1}}_{\\in \\Aut(v_1)} = \\underbrace{g_0^{-1} h_0}_{\\in \\Aut(v_0)}$. \n    Squaring both sides yields the contradiction $-1 \\cdot \\id = \\id$ where we used that $(g_1h_1^{-1})^2=(g_0^{-1}g_0)^2=\\mathbb I$, since stabilizers square to $\\id$.\n\\end{proof}\n\nThe central procedure in \\autoref{alg:lexmin} is \\textsc{ArgLexMin}, which, given a LIM $A$ and sets $G_0,G_1$ which generate stabilizer groups, finds $g_0\\in \\braket{G_0},g_1\\in\\braket{G_1}$ such that $A\\cdot g_0\\cdot g_1$ reaches its lexicographic minimum over all choices of $g_0,g_1$.\nIt first performs the scalar-ignoring minimization (\\autoref{line:division-remainder}) to find $g_0,g_1$ modulo scalar.\nThe algorithm \\textsc{LexMin} simply invokes \\textsc{ArgLexMin} to get the arguments $g_0, g_1$ which yield the minimum and uses these to compute the actual minimum.\n\nThe subroutine \\textsc{FindOpposite} finds an element $g \\in G_0$ such that $-g \\in G_0$, or infers that no such $g$ exists.\nIt does so in a similar fashion as \\textsc{IntersectStabilizerGroups} from \\autoref{sec:pauli-isomorphism-detection}: by conjugation with a suitably chosen unitary $U$, it maps $G_1$ to $\\{Z_1, Z_2, \\dots, Z_{|G_1|}\\}$.\nAnalogously to our explanation of \\textsc{IntersectStabilizerGroups}, the group generated by $UG_1 U^{\\dagger}$ contains precisely all Pauli LIMs which satisfy the following three properties:\n(i) the scalar is $1$;\n(ii) its Pauli string has an $\\id$ or $Z$ at positions $1, 2, \\dots, |G_1|$;\n(iii) its Pauli string has an $\\id$ at positions $|G_1|+1, \\dots, n$.\nTherefore, the target $g$ only exists if there is a LIM in $\\langle U G_0 U^{\\dagger}\\rangle$ which (i') has scalar $-1$ and satisfies properties (ii) and (iii).\nTo find such a $g$, we put $UG_0 U^{\\dagger}$ in RREF form and check all resulting generators for properties (i'), (ii) and (iii).\n(By definition of RREF, it suffices to check only the generators for this property)\nIf a generator $h$ satisfies these properties, we return $U^{\\dagger} h U$ and $\\none$ otherwise.\nThe algorithm requires $O(n^3)$ time to find $U$, the conversion $G \\mapsto UGU^{\\dagger}$ can be done in time $O(n^3)$, and $O(n)$ time is required for checking each of the $O(n^2)$ generators.\nHence the runtime of the overall algorithm is $O(n^3)$.\n\n\n\n\\begin{algorithm}\n    \\caption{\n        Algorithms \\textsc{LexMin} and \\textsc{ArgLexMin} for computing the minimal element from the set $A \\cdot \\langle G_0\\rangle \\cdot \\langle G_1\\rangle=\\{Ag_0g_1|g_0\\in G_0,g_1\\in G_1\\}$, where $A$ is a Pauli LIM and $G_0, G_1$ are generating sets for stabilizer subgroups.\n        The algorithms make use of a subroutine \\textsc{FindOpposite} for finding an element $g \\in \\langle G_0\\rangle$ such that $-g \\in \\langle G_1\\rangle$.\n        A canonical choice for the \\textsc{Rootlabel} (see \\autoref{sec:simulation}) of an edge $e$ pointing to a node $v$ is $\\textsc{LexMin}(G, \\{\\id\\}, \\lbl(e))$ where $G$ is a stabilizer generator group of $\\Aut(v)$.\n        \\label{alg:lexmin}\n    }\n    \\begin{algorithmic}[1]\n        \\Procedure{LexMin}{stabilizer subgroup generating sets $G_0, G_1$ and Pauli LIM $A$}\n        \\Statex \\textbf{Output}: $\\min_{(g_0, g_1 \\in  \\langle G_0 \\cup G_1 \\rangle} A \\cdot g_0 \\cdot g_1$\n        \\State $(g_0, g_1) := \\textsc{ArgLexMin}(G_0, G_1, A)$\n        \\State \\Return $A \\cdot g_0 \\cdot g_1$\n        \\EndProcedure\n        \\Statex \n        %\n        \\Procedure{ArgLexMin}{stabilizer subgroup generating sets $G_0, G_1$ and Pauli LIM $A$}\n        \\Statex \\textbf{Output}: $\\argmin_{g_0 \\in G_0, g_1\\in G_1} A \\cdot g_0 \\cdot g_1$\n        \\State $(g_0, g_1) := \\displaystyle \\argmin_{(g_0, g_1) \\in \\langle G_0 \\cup G_1 \\rangle} \\{h \\mid h \\propto A \\cdot g_0 \\cdot g_1\\}$\n        \\Comment Using the scalar-ignoring DivisionRemainder algorithm from \\autoref{sec:preliminaries}, \n        \\label{line:division-remainder}\n        \\State $g' := \\textsc{FindOpposite}(G_0, G_1, g_0, g_1)$\n        \\If{$g'$ is $\\none$}\n        \\State \\Return $(g_0, g_1)$\n        \\Else\n        \\State $h_0, h_1 := g_0 \\cdot g', (-g') \\cdot g_1$\n        \\Comment $g_0 g_1 = - h_0 h_1$\n        \\If{$A\\cdot h_0 \\cdot h_1 <_{\\text{lex}} A \\cdot g_0 \\cdot g_1$} \\Return $(h_0,h_1)$\n        \\label{line:choose-smaller}\n        \\Else \\ \\Return $(g_0,g_1)$\n        \\EndIf\n%        \\State \\Return $(h_0, h_1)$ \\textbf{if} $B\\cdot h_0 \\cdot h_1 < B \\cdot g_0 \\cdot g_1$ \\textbf{else} $(g_0, g_1)$\n        \\EndIf\n        \\EndProcedure\n%\n        \\Statex\n        \\Procedure{FindOpposite}{stabilizer subgroup generating sets $G_0, G_1$}\n        \\Statex \\textbf{Output}: $g\\in G_0$ such that $-g \\in G_1$, or \\none~if no such $g$ exists\n        \\State Compute $U$ s.t. $U G_1 U^{\\dagger} = \\{Z_1, Z_2, \\dots, Z_{|G_1|}\\}$, using Algorithm 2 from \\cite{garcia2012efficient}\n        \\Comment $Z_j$ is the $Z$ gate applied to qubit with index $j$\n        \\State $H_0 := UG_0 U^{\\dagger}$\n        \\State $H_0^{RREF} := H_0$ in RREF form\n        \\For{ $h \\in H_0^{RREF}$}\n        \\If{$h$ satisfies all three of the following: (i) $h$ has scalar $-1$; the Pauli string of $h$ (ii) contains only $\\id$ or $Z$ at positions $1, 2, \\dots, |G_1|$, and (iii) only $\\id$ at positions $|G_1|+1, \\dots, n$}\n        \\State \\Return $U^{\\dagger} h U$\n        \\EndIf\n        \\EndFor\n        \\State \\Return \\none\n        \\EndProcedure\n    \\end{algorithmic}\n\\end{algorithm}\n\n", "meta": {"hexsha": "0bf5374310d63b38d3f6279080961d5659b127cb", "size": 42646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Src/CS/sections/pauli_isomorphism_detection.tex", "max_stars_repo_name": "Katafotic/latex_parsing", "max_stars_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Src/CS/sections/pauli_isomorphism_detection.tex", "max_issues_repo_name": "Katafotic/latex_parsing", "max_issues_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Src/CS/sections/pauli_isomorphism_detection.tex", "max_forks_repo_name": "Katafotic/latex_parsing", "max_forks_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.3430894309, "max_line_length": 488, "alphanum_fraction": 0.6653613469, "num_tokens": 14662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.44449921831909905}}
{"text": "In this section, we first define the problem we address and  then the mathematical notation we use.  Following this, we proceed to motivate and derive the new expected F1-Score we use to optimize cluster extraction in this work.\n\n%In this section, we will define our addressing problem with the notation. Also, the background about this paper will be provided.\n\n\n\\subsection{Background}\n\nStandard unsupervised algorithms like K-means~\\cite{kmeans_original} (and variants) that are commonly used for search results clustering define clusters according to a prototype document centroid in a vector space model, where all search results would be assigned to their closest cluster centroid.  While this approach naturally provides for topical (content) coherence of search results within a cluster, it does not directly guarantee high relevance of clusters.  It also does not directly guarantee coherence of display attributes of clusters such as the spatial and temporal extent of the cluster (i.e., a cluster may have documents spanning a large spatial or temporal range), unless these attributes are incorporated into the distance metric for the vector space model and appropriately traded off with content distance. \n\n\\subsection{Problem definition}\n\nIn this paper, we take a very different perspective on the definition of a cluster and the optimization process for extracting these clusters.  To start, we assume the search results have the following three display attributes that can be used to define coherent clusters in terms of spatial, temporal, and topical (i.e., content) constraints:\n%of an AUI to ease the task of monitoring alerts in large-scale displayed networks. The new interface is expected to filter irrelevant information to provide localized context for each event or alert (defined loosely as a relevant related content localized in time, space, and/or keyword usage). \\textcolor{red}{Hence, we argue that the problem we are addressing in this paper is an optimization problem of filter selection.  Furthermore, we assume that selection of information elements to display in a visual interface is obtained via settings of three filters that jointly express a global filter. These three sub-filters are:}\n%%\n%The problem we address in this paper is the proper display of portion in the network for user's easy to investigate large-scale network elements. The new system is expected to filter information to provide localized and relevant element in the interface. This problem is able to be defined as a filter search/recommendation problem, We expect to employ standard IR theory to solve this problem based on our argument about the similarity of AUI and IR system. We assume that display of the elements in the network is obtained via three filters that can jointly express a global filter. These three sub-filters are:\n\\begin{itemize}\n\\item {\\bf Space:} limits a cluster content to 2D spatially annotated content (e.g., latitude and longitude) according to four parameters for the upper left and lower right bounding box coordinates.  These cluster constraints define the bounding box that is visually displayed to the user, cf. Figure~\\ref{Fig:FilteredDisplay}.\n\\item {\\bf Time:} limits cluster content to time-stamped results according to two parameters for the lower and upper time bound.  Time can be displayed via cluster labels, or through settings of a time slider in the interface.\n%expresses a bounding box of a retrieved set. The location can be expressed as longitude/latitude values, or pure coordinates obtained using a given display layout. \n\\item {\\bf Keyword (or Discrete Attribute):} limits a  cluster content according to included or excluded keywords (or general discrete attributes of an information element).\nExplicit included and excluded keywords can be used to label the cluster. \n\\end{itemize}\nGiven a query and an externally provided probabilistic measure of relevance for each search result w.r.t.\\ this query (e.g., from a language model~\\cite{Zhai2001}), \n%the problem we address in this paper is how to efficiently optimize content filtering in a visual information display (VID) for\nthe problem we study is how to efficiently extract high-relevance clusters defined according to the above constraints.\n\nIn general, we remark that the choice of which clustering parameters to use is up to the interactive search interface designer according to the display and (meta-)data available.  We further note that this work is not limited to these three clustering parameters -- any continuous or discrete cluster attributes that naturally constrain the search results can be accommodated by our framework.  Nonetheless, we believe time, space, and content constitute three of the most commonly used information display attributes in practice and hence are the ones we focus on in this work.\n%one or multiple filter selection settings to maximize retrieval of relevant content?  \n%\\textcolor{red}{Even though in practice, not all data have such information associated, we can imagine throw away the sub-filters associated with the missing information, e.g., location information which is certainly not available in all datasets.} \n%best set of elements that is assessed using one of the metrics described above, i.e., expected precision, expected recall, or expected F1-score\n\n\\subsection{Mathematical Notation}\n\nWith the cluster definitions above, we proceed to define  formal mathematical notation that will be used through the remainder of the paper:\n%portion of our presentation using  \n%Throughout this paper, we present all algorithms for Greedy and Optimal search using \n%the following mathematical notation:\n\n\\begin{itemize}\n\\item An information element $j$ (i.e., a search result) may have three types of associated metadata: (i) position coordinates $(x_{j},y_{j})$, (ii) a timestamp $t_j$, which may represent the creation date of $j$, and (iii) textual content, which is composed of a set of unique terms $\\{ t_1,\\ldots,t_n \\}$ of size $n$ (to reduce notational clutter, we assume the element $j$ containing these terms will be clear from context).\n\\item Three variables $I(j) \\in \\{0,1\\}$, $B(j) \\in \\{0,1\\}$ and $S(j) \\in [0,1]$ are associated with each information element $j$: $I(j)$ is an indicator referring to whether an element $j$ is retrieved and displayed (true$=1$); $B(j)$ is a Boolean random variable indicating the (ground truth) relevance of an element $j$ (relevant$=1$); $S(j)$ is a relevance score indicating the \\emph{probability} relevance of an element $j$. %Note that $I(j)$ is correlated with the UI system. $B(j)$ and $S(j)$ are independent of the system. \n%$\\emph{I(j), B(j)} \\in \\{0, 1\\}$, $\\emph{S(j)} \\in \\left[0, 1\\right]$. \n$B(j)$ follows a \\emph{Bernoulli} distribution with parameter $S(j)$, and hence, the expectation of $B(j)$ \\emph{is} $S(j)$, i.e., \n  $\\mathbb{E_S}[B(j)] = S(i)$.\n%which allows to derive the expectation of \\emph{B(j)} as follows:\n%\\begin{equation}\n % \\mathbb{E_S}[B(j)] = 0*(1 - S(i))+ 1*S(i) = S(i)\n%\\end{equation}\n\\item We label $GC$ as the global set of all information elements $j$ with total size $|GC|=m$. %Two subsets of $GC$ are particularly important in this research: retrieved set $E$ and relevant set $RS$.  \n\\item $E$ is the set of retrieved information elements that match a user query, where $E \\subseteq  GC$.  We use $E^*$ to refer to further subsets of elements of clusters, i.e., $E^*\\subseteq E$. \n%This variable depends on the UI filtering system. \nNote that $|E|$ is the count of retrieved $I(j)$ among the global collection $GC$. Therefore, we have $|E| = \\sum_{j=1}^m I(j)$.\n\\item We label the set of ground truth relevant information elements as the relevant set $RS$ consisting of $|RS|$ elements. \n%This is independent of the UI-filter system. \nNote that $|RS|$ is the count of relevant $B(j)$ among the global collection $GC$. Therefore, we have $|RS| = \\sum_{j=1}^m B(j)$. %However, $B(j)$ is not available for our estimation of $RS$ size in practice. We have to use expected $RS$ size $|RS|$, $\\mathbb{E_S}|RS|$, to approximate $|RS|$.\n%\\begin{equation}\n  %|RS| \\approx \\mathbb{E_S}|RS| = \\sum_{j=1}^m \\mathbb{E_S}[B(j)] = \\sum_{j=1}^m S(j)\n%\\end{equation}\n\n%\\item Keyword parameters $Q_k=\\{\\neg t_{1}^{*},\\dots \\neg t_{k}^{*}\\}$, are composed of a set of query terms excluded from the cluster, i.e., elements in the cluster cannot contain the terms $t_{1}^{*},\\dots t_{k}^{*}$.\n%\\item Time parameters $Q_t=[t_{start},t_{end}]$ express the lower bound $t_{start}$ and upper bound $t_{end}$ time parameters of the cluster.\n%\\item Position parameters $Q_p=[(x_{min},y_{min}),(x_{max},y_{max})]$ express the upper left $(x_{min},y_{min})$ and lower right $(x_{max},y_{max})$ corners of the spatial parameters of a cluster.%, assuming $(0,0)$ is in the upper left corner of the display window.  \n%search of elements falling in the bounding box represented by the  lower and upper bound coordinates -- respectively $(x_{min},y_{min})$ and $(x_{max},y_{max})$.\n%\\item A cluster $Q$ combines the three selection parameters $Q_k$, $Q_t$, and $Q_p$ in a conjoined set of parameters $Q=[Q_k, Q_t, Q_p]$. \n%$Q=[Q_k\\wedge Q_t\\wedge Q_p]$. \n\n\\end{itemize}\n\n\n\n\n\n\n\n%The goal is to explore an algorithm to obtain an optimal filter setting to retrieve a set of elements with maximum score of the specific metric.\n\n\n\n%\\subsection{Comparison to standard IR search}\n%The comparison between information retrieval for web search and information retrieval for filtering in AUIs can be summarized in Table \\ref{tbl:Comparaison2IR}. Obviously , there are important differences between web search and filtering for AUIs, especially in the indirect selection of results through filter settings. This unexplored field provides new possibilities and challenges of research in this novel information retrieval setting:\n%\\begin{itemize}\n%\\item Evaluation metrics and human factors: Are there new evaluation metrics specific to this AUI filtering setting? What evaluation metrics correlate with AUI user performance? \n%\\item Optimization and algorithms: How do we optimally select filter settings to maximize evaluation metrics in expectation? How can we interpret simple heuristics like average and cumulative relevance? (Answer: expected precision.) How do MILPs, relaxed LP approximations with guarantees, or greedy approaches compare in terms of time and metric quality? Are there properties of different filters (1D for time, 2D for bounding box, or discrete choices for property selection) that lend themselves to specialized greedy approaches? \n%\\item Robustness: As the signal-to-noise ratio varied in the quality of the relevance scoring, how do various algorithms perform? \n%\\item Explanation: Can we provide explanations for filter settings to allow users to understand the reasons for the suggestions? \n%\\item Personalization and learning: Can we learn from observations of manual adaption of the suggested filter settings to understand how to improve the third-party scoring systems? \n%\\item Collaborative filtering: Can we generalize learning across multiple\n%users in a collaborative filtering approach? \n%\\item Learning from implicit feedback: How can we leverage implicit user\n%feedback such as clicks and dwell time to indirectly measure the relevance\n%of filtered content and improve system performance.\n%\\end{itemize}\n\n%\\subsection{Optimization technique definition}\n\n%The \\emph{greedy algorithm} is an algorithmic paradigm that aims to obtain a global optimum of a problem in terms of making the locally optimal decision at each step \\cite{Black2005}. In a search problem, a greedy algorithm does not in general produce an optimal solution, but it still yields locally optimal solutions that approximate a global optimum in a reasonable time.\n\n%The greedy algorithms described in this paper are coupled with a \\emph{Top-down} search strategy, which basically begins with the whole search space, and then partition into several sub-spaces in a lower level for the local optimization search heuristic.\n\n%An \\emph{optimization-based} search is the problem of finding the best solution from all feasible solutions. Usually, the standard form of an optimization problem is defined as the minimization/maximization of a given objective function subject to a set of constraints. \n\n%The search problem will be transformed into Mixed integer linear programming (MILP), which involves problems in which only some of the variables, $x_{i}$, are constrained to be integers, while other variables are allowed to be non-integers.\n\n\n\n%\\subsection{Evaluation metrics}\n\\subsection{Deriving Expected F1-Score (EF1)}\n\nWe adopt the Boolean relevance framework standard in information retrieval~\\cite{Baeza-Yates2010} and thus assume that any information element $j$ has a ground truth relevance assessment $B(j)$ available at evaluation time.  \n%%However, unlike previous document-based methods for estimating relevance at retrieval-time, we do not rely on text associated with information elements and instead rely on a third-party to supply an estimated probability (score) of relevance $S(j)$. \n%Traditionally, Boolean labels indicate the relevance of documents is used to evaluate retrieval sets (e.g., precision). \n%In practice, IR models are based on probabilistic scores to measure relevance of the elements, such as TF-IDF and cosine similarity.  \n%In practice, we are able to employ third-party technique to provide probabilistic scores to measure relevance of the document in IR system, such as TF-IDF and cosine similarity. Consequently,\nBecause clustering implies a Boolean retrieval perspective (clusters either contain or do not contain elements) and we have a probabilistic estimate of relevance $S(j)$, we propose to evaluate\n\\emph{expected} variants of standard precision, recall, and F1-score of these clusters.\n%Boolean retrieval evaluation metrics based on the relaxation of Boolean labels to probabilistic scores resulting in expected metrics, i.e., \\emph{expected precision} (EP), \\emph{expected recall} (ER) and \\emph{expected F1-Score} (EF1).\n\nHowever, as standard for both precision and recall, we note that precision and recall alone can be trivially optimized through pathological solutions.  That is, the cluster that selects all information elements (i.e., all time, all space, no excluded keywords) would trivially maximize (expected) recall.  Similarly, the cluster that selects the highest probability singleton information element would maximize expected precision.  \\emph{This leaves expected F1-score as the only of these three objectives commonly used in Boolean information retrieval that does not have a pathological solution.}\n%to balance expected precision and recall. % in a Boolean retrieval framework.\n\nTo formally define expected F1-Score, we first begin with definitions of expected precision and recall.  Recalling our previous definitions, given a set of information elements  $E$  that match a user query and a relevant set $RS$, %the global information element collection $GC$ with size $m$, \nthe precision of $E$ is defined as follows:\n\\begin{equation}\n   P(E) = \\dfrac{\\sum_{j \\in E} B(j)}{|E|} = \\dfrac{\\sum_{j=1}^m B(j)I(j)}{\\sum_{j=1}^m I(j)} \n\\end{equation}\nGiven that $B(j)$ is a Boolean random variable, we can now take the expectation of $P(E)$ leading to the following definition of \n%Replacing the ground-truth Boolean relevance label $B(j)$ with the Boolean random variable $S(j)$ gives the following definition of \n\\emph{expected precision}: \n\\begin{equation}\nEP(E)=\\mathbb{E_{S}}\\left[\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}B(j)I(j)}{{\\displaystyle \\sum_{j=1}^{m}}I(j)}\\right]=\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}\\mathbb{E_{S}}[B(j)]I(j)}{{\\displaystyle \\sum_{j=1}^{m}}I(j)}=\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}S(j)I(j)}{{\\displaystyle \\sum_{j=1}^{m}}I(j)}\n\\end{equation}\nSimilarly the recall of a retrieved set $R(E)$ is defined as:\n\\begin{equation}\n   R(E) = \\dfrac{\\sum_{j \\in RS} B(j)}{|RS|} = \\dfrac{\\sum_{j=1}^m B(j)I(j)}{ \\sum_{j=1}^m B(j)} \n\\end{equation}\nTaking a 1st order Taylor expansion, we have the following expectation approximation %$\\mathbb{E}(X/Y)\\approx\\dfrac{\\mathbb{E}(X)}{\\mathbb{E}(Y)}$ \n$\\mathbb{E}(X/Y)\\approx \\mathbb{E}(X)/ \\mathbb{E}(Y)$ for two dependent random variables $X$ and $Y$~\\cite{Kempen2000}. Hence, \nwe can now define an \\emph{approximated expected recall}: \n%Given a retrieved element set $E$  and a relevant element set $RS$ among a global element collection $GC$ with size $m$, we propose the following definition of \\emph{expected precision} (EP), \\emph{expected recall} (ER) and \\emph{expected F1-Score} (EF1):\n\\begin{equation}\n   \\emph{ER(E)}=\\mathbb{E_{S}}\\left[\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}B(j)I(j)}{|RS|}\\right]\\approx\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}\\mathbb{E_{S}}[B(j)]I(j)}{{\\displaystyle \\sum_{j=1}^{m}}\\mathbb{E_{S}}[B(j)]}=\\dfrac{{\\displaystyle \\sum_{j=1}^{m}}S(j)I(j)}{{\\displaystyle \\sum_{j=1}^{m}}S(j)}\n\\end{equation}\nFinally, we define the \\emph{approximated expected F1-Score} (EF1) using the \\emph{expected precision} and the \\emph{approximated expected recall} as follows: \n\\begin{align}\n    \\emph{EF1(E)}  \\approx \\dfrac{2\\times EP\\times ER}{EP+ER} = \\dfrac{2\\times\\sum_{j=1}^m S(j)I(j)}{\\sum_{j=1}^m I(j) + \\sum_{j=1}^m S(j)}\n    \\label{eq:EF1}\n\\end{align}\n%Due to space limitations, we focus on F1-score in this paper, however expected F$_\\beta$ scores follow directly from the above definitions. \n  \n%Conventional metrics are based on Boolean relevance label $B(j)$ instead of probabilistic score $S(j)$. To link standard precision with our expected precision,  The definition of standard precision $P(RS)$ is as follows:\n\n\n%Now, we  derive expectation of precision $P(RS)$ as follows:\n%\\begin{align}\n%\t\\mathbb{E_S}[P(E)] &= \\mathbb{E_S}[\\dfrac{\\sum_{j=1}^m B(j)I(j)}{\\sum_{j=1}^m I(j)}] = \\dfrac{\\sum_{j=1}^m %\\mathbb{E_S}[B(j)]I(j)}{\\sum_{j=1}^m I(j)} \\notag \\\\\n%    &= \\dfrac{\\sum_{j=1}^m S(j)I(j)}{\\sum_{j=1}^m I(j)} = EP(E)\n   \t%\\mathbb{E_S}[R(RS)] &= \\dfrac{\\sum_{j=1}^m \\mathbb{E_S}[B(j)] I(j)}{\\sum_{j=1}^m \\mathbb{E_S}[B(j)]} = \\dfrac{\\sum_{j=1}^m S(j)I(j)}{\\sum_{j=1}^m S(j)} = ER(RS)  \\\\\n    %\\mathbb{E_S}[F1(RS)] &= \\dfrac{2*\\sum_{j=1}^m \\mathbb{E_S}[B(j)]I(j)}{\\sum_{j=1}^m I(j) + \\sum_{j=1}^m \\mathbb{E_S}[B(j)]} \\notag \\\\\n    %&= \\dfrac{2*\\sum_{j=1}^m S(j)I(j)}{\\sum_{j=1}^m I(j) + \\sum_{j=1}^m S(j)} = EF1(RS)\n%\\end{align}\n\n\n\n\n%\\begin{equation}\n%\\emph{\\ensuremath{EP(RS)}}=\\dfrac{{\\displaystyle \\sum_{j\\in RS}S(j)}}{|RS|} =  \\dfrac{\\sum_{j=1}^m S(j)I(j)}{\\sum_{j=1}^m I(j)} \n%\\end{equation}\n\n%Analogously, we define the  \\emph{expected recall} (ER) as follows:\n%\\begin{equation}\n%\\emph{\\ensuremath{ER(RS)}}=\\dfrac{{\\displaystyle \\sum_{j\\in RS}S(j)}}{|RE|} = \\dfrac{\\sum_{i=1}^m S(i)I(i)}{\\sum_{i=1}^m S(i)} = \\dfrac{\\sum_{i=1}^m S(i)I(i)}{C}  \n%\\end{equation}\n\n%\\noindent where $|RE|$ is the size of the entire relevant element set. Finally, we define the  \\emph{expected F1-Score} (EF1) as follows:\n\n%\\begin{equation}\n%\\emph{\\ensuremath{EF1(RS)}}=\\dfrac{2\\times EP\\times ER}{EP+ER} = \\dfrac{2*\\sum_{i=1}^m S(i)I(i)}{\\sum_{i=1}^m I(i) + C}\n%\\end{equation}\n\n%In Figure \\ref{fig:F1_vs_EF1}, we experimentally show that while EF1 is only an approximation of the true expectation, EF1 serves as an excellent surrogate for F1, which is our main concern when considering filter optimization.  That is, maximizing EF1 score with respect to a noisy classifier (noise decreases to 0 as $\\lambda \\to 1$) is strongly correlated with maximizing F1 score evaluated on the ground truth; we will further study the effect of a noisy classifier in Section~\\ref{sec:Evaluation}.   Specifically, while the EF1 and F1 scores are not perfectly calibrated along the diagonal, there is a linear correlation in that as the EF1 score increases for a scenario, the F1-score proportionally increases on average (as shown by the best fit linear regression in the plots).\n\n\n\n%\\begin{figure}[H]\n%\\begin{centering}\n%\\par\\end{centering}\n%\\begin{centering}\n%\\includegraphics[width=8.5cm]{imgs/Enron_results/scatter_plot_EF1\\lyxdot vs\\lyxdot F1}\n%\\par\\end{centering}\n%\\caption{Scatter plot showing EF1-Score vs. F1-Score.}\n%\\label{fig:F1_vs_EF1}\n%\\end{figure}\n\n\n\n\n\n", "meta": {"hexsha": "bc37ee7795f75cd00b034be301fc9b8d8026cd72", "size": 20200, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/IUI2019/Framework.tex", "max_stars_repo_name": "D3Mlab/visir", "max_stars_repo_head_hexsha": "cd1860984dee8d7aba368857e734ad11c14124c8", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-10T07:40:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-10T07:40:04.000Z", "max_issues_repo_path": "Documents/IUI2019/Framework.tex", "max_issues_repo_name": "D3Mlab/viz-ir", "max_issues_repo_head_hexsha": "cd1860984dee8d7aba368857e734ad11c14124c8", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documents/IUI2019/Framework.tex", "max_forks_repo_name": "D3Mlab/viz-ir", "max_forks_repo_head_hexsha": "cd1860984dee8d7aba368857e734ad11c14124c8", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 102.0202020202, "max_line_length": 828, "alphanum_fraction": 0.7525742574, "num_tokens": 5291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.44449921263101794}}
{"text": "\\section{\\acrlong{mcts} algorithm}%\n\\label{sec:mcts_algorithm}\n\n\\gls{mcts} algorithm is a family of algorithm based on Monte-Carlo simulations and a tree seach procedure.\nMonte-Carlo simulations were first used in 1993~\\cite{mcgo} for the game of Go.\nIn 2006~\\cite{uct}, \\gls{mcts} most popular algorithm called \\gls{uct} was introduced.\nIt used multi armed bandit in the tree search procedure to keep a balance between exploitation and exploration of the tree.\nWhich, respectively means to study more a well known and good strategy and explore new stategies.\nNowadays, \\gls{mcts} algorithms have been used in many domains~\\cite{survey_mcts} and still give state of the art result in many of them.\nFor example, it is a core component of algorithms such as AlphaZero~\\cite{alphazero}.\n\nHere, we are interested in solving optimization problems, that can also be seen as games or puzzle.\nMoreover, we have a particular interest in stochastic problems.\nIn this section, we will discuss the different classic components of a \\gls{mcts} algorithm.\nWe will first discuss the preliminaries to understand the \\gls{mcts}.\n\n\\subimport{./subs/}{mdp.tex}\n\\subimport{./subs/}{key_components.tex}\n", "meta": {"hexsha": "6f176b090cd22ab5ab1dd967f4dc3fb4184870b8", "size": 1182, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/report/src/sections/mcts/mcts.tex", "max_stars_repo_name": "XanX3601/stochastic_mcts_optimization", "max_stars_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documents/report/src/sections/mcts/mcts.tex", "max_issues_repo_name": "XanX3601/stochastic_mcts_optimization", "max_issues_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/report/src/sections/mcts/mcts.tex", "max_forks_repo_name": "XanX3601/stochastic_mcts_optimization", "max_forks_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.2105263158, "max_line_length": 137, "alphanum_fraction": 0.7884940778, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.44448549083174077}}
{"text": "\\def\\module{M3P5 Geometry of Curves and Surfaces}\n\\def\\lecturer{Prof Tom Coates}\n\\def\\term{Autumn 2018}\n\\def\\cover{\n$$\n\\begin{tikzpicture}[scale=0.8]\n\\draw (-7, 1) to [bend right=60] (-7, -1);\n\\draw (-7, 1) to [bend left=30] (-4, 1);\n\\draw (-7, -1) to [bend right=30] (-4, -1);\n\\draw (-6.2, 0) to [bend right=30] (-4.8, 0);\n\\draw (-6, -0.1) to [bend left=30] (-5, -0.1);\n\\draw (-4, 1) to [bend left=30] (-1, 1);\n\\draw (-4, -1) to [bend right=30] (-1, -1);\n\\draw (-3.2, 0) to [bend right=30] (-1.8, 0);\n\\draw (-3, -0.1) to [bend left=30] (-2, -0.1);\n\\draw [dotted, thick] (-0.5, 0) to (0.5, 0);\n\\draw (1, 1) to [bend left=30] (4, 1);\n\\draw (1, -1) to [bend right=30] (4, -1);\n\\draw (1.8, 0) to [bend right=30] (3.2, 0);\n\\draw (2, -0.1) to [bend left=30] (3, -0.1);\n\\draw (4, 1) to [bend left=30] (7, 1);\n\\draw (4, -1) to [bend right=30] (7, -1);\n\\draw (4.8, 0) to [bend right=30] (6.2, 0);\n\\draw (5, -0.1) to [bend left=30] (6, -0.1);\n\\draw (7, 1) to [bend left=60] (7, -1);\n\\draw (0, 2.5) node[above]{$ g $};\n\\draw (-7.5, 1) to [out=45, in=-135] (0, 2.5);\n\\draw (7.5, 1) to [out=135, in=-45] (0, 2.5);\n\\end{tikzpicture}\n$$\n$$ \\Downarrow $$\n$$\n\\begin{tikzpicture}[scale=0.8]\n\\draw (-8.5, 1) to [bend right=60] (-8.5, -1);\n\\draw (-8.5, 1) to [bend left=30] (-5.5, 1);\n\\draw (-8.5, -1) to [bend right=30] (-5.5, -1);\n\\draw (-7.7, 0) to [bend right=30] (-6.3, 0);\n\\draw (-7.5, -0.1) to [bend left=30] (-6.5, -0.1);\n\\fill [lightgray] (-5.5, 0) ellipse (0.25 and 1);\n\\draw [dashed] (-5.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (-5.5, 1) arc (90:270:0.25 and 1);\n\\draw [dotted] (-4.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (-4.5, 1) arc (90:270:0.25 and 1);\n\\draw (-4.5, 1) to [bend left=30] (-1.5, 1);\n\\draw (-4.5, -1) to [bend right=30] (-1.5, -1);\n\\draw (-3.7, 0) to [bend right=30] (-2.3, 0);\n\\draw (-3.5, -0.1) to [bend left=30] (-2.5, -0.1);\n\\fill [lightgray] (-1.5, 0) ellipse (0.25 and 1);\n\\draw [dashed] (-1.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (-1.5, 1) arc (90:270:0.25 and 1);\n\\draw [dotted, thick] (-0.5, 0) to (0.5, 0);\n\\draw [dotted] (1.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (1.5, 1) arc (90:270:0.25 and 1);\n\\draw (1.5, 1) to [bend left=30] (4.5, 1);\n\\draw (1.5, -1) to [bend right=30] (4.5, -1);\n\\draw (2.3, 0) to [bend right=30] (3.7, 0);\n\\draw (2.5, -0.1) to [bend left=30] (3.5, -0.1);\n\\fill [lightgray] (4.5, 0) ellipse (0.25 and 1);\n\\draw [dashed] (4.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (4.5, 1) arc (90:270:0.25 and 1);\n\\draw [dotted] (5.5, 1) arc (90:-90:0.25 and 1);\n\\draw [dashed, thick] (5.5, 1) arc (90:270:0.25 and 1);\n\\draw (5.5, 1) to [bend left=30] (8.5, 1);\n\\draw (5.5, -1) to [bend right=30] (8.5, -1);\n\\draw (6.3, 0) to [bend right=30] (7.7, 0);\n\\draw (6.5, -0.1) to [bend left=30] (7.5, -0.1);\n\\draw (8.5, 1) to [bend left=60] (8.5, -1);\n\\draw (0, 2) node[above]{$ g - 2 $};\n\\draw (-5, 1) to [out=45, in=-135] (0, 2);\n\\draw (5, 1) to [out=135, in=-45] (0, 2);\n\\end{tikzpicture}\n$$\n$$ \\Downarrow $$\n$$\n\\begin{tikzpicture}[scale=0.8]\n\\fill [lightgray] (-7, 0) to (-6, 0) to (-7, -1) to cycle;\n\\draw [dashed, thick] (-7, 0) to (-6, 0) to (-7, -1) to cycle;\n\\fill (-8, 1) circle (0.1);\n\\fill (-7, 1) circle (0.1);\n\\draw (-6, 1) circle (0.1);\n\\fill (-8, 0) circle (0.1);\n\\fill (-7, 0) circle (0.1);\n\\draw (-6, 0) circle (0.1);\n\\draw (-8, -1) circle (0.1);\n\\draw (-7, -1) circle (0.1);\n\\draw (-6, -1) circle (0.1);\n\\draw (-8, 1) to (-6, 1);\n\\draw (-8, 0) to (-7, 0);\n\\draw [dotted, thick] (-8, -1) to (-6, -1);\n\\draw (-8, 1) to (-8, -1);\n\\draw (-7, 1) to (-7, 0);\n\\draw [dotted, thick] (-6, 1) to (-6, -1);\n\\draw (-8, 0) to (-7, 1);\n\\draw (-8, -1) to (-6, 1);\n\\draw (-7, -1.5) node{$ \\chi\\br{\\Sigma_{1, 1}} = -1 $};\n\\fill [lightgray] (-4, 0) to (-3, 1) to (-3, 0) to cycle;\n\\draw [dotted, thick] (-4, 0) to (-3, 1) to (-3, 0) to cycle;\n\\fill [lightgray] (-3, 0) to (-2, 0) to (-3, -1) to cycle;\n\\draw [dashed, thick] (-3, 0) to (-2, 0) to (-3, -1) to cycle;\n\\draw (-4, 1) circle (0.1);\n\\draw (-3, 1) circle (0.1);\n\\draw (-2, 1) circle (0.1);\n\\draw (-4, 0) circle (0.1);\n\\fill (-3, 0) circle (0.1);\n\\draw (-2, 0) circle (0.1);\n\\draw (-4, -1) circle (0.1);\n\\draw (-3, -1) circle (0.1);\n\\draw (-2, -1) circle (0.1);\n\\draw (-4, 1) to (-2, 1);\n\\draw [dotted, thick] (-4, -1) to (-2, -1);\n\\draw (-4, 1) to (-4, -1);\n\\draw [dotted, thick] (-2, 1) to (-2, -1);\n\\draw (-4, -1) to (-2, 1);\n\\draw (-3, -1.5) node{$ \\chi\\br{\\Sigma_{1, 2}} = -2 $};\n\\draw [dotted, thick] (-0.5, 0) to (0.5, 0);\n\\fill [lightgray] (2, 0) to (3, 1) to (3, 0) to cycle;\n\\draw [dotted, thick] (2, 0) to (3, 1) to (3, 0) to cycle;\n\\fill [lightgray] (3, 0) to (4, 0) to (3, -1) to cycle;\n\\draw [dashed, thick] (3, 0) to (4, 0) to (3, -1) to cycle;\n\\draw (2, 1) circle (0.1);\n\\draw (3, 1) circle (0.1);\n\\draw (4, 1) circle (0.1);\n\\draw (2, 0) circle (0.1);\n\\fill (3, 0) circle (0.1);\n\\draw (4, 0) circle (0.1);\n\\draw (2, -1) circle (0.1);\n\\draw (3, -1) circle (0.1);\n\\draw (4, -1) circle (0.1);\n\\draw (2, 1) to (4, 1);\n\\draw [dotted, thick] (2, -1) to (4, -1);\n\\draw (2, 1) to (2, -1);\n\\draw [dotted, thick] (4, 1) to (4, -1);\n\\draw (2, -1) to (4, 1);\n\\draw (3, -1.5) node{$ \\chi\\br{\\Sigma_{1, g - 1}} = -2 $};\n\\fill [lightgray] (6, 0) to (7, 1) to (7, 0) to cycle;\n\\draw [dotted, thick] (6, 0) to (7, 1) to (7, 0) to cycle;\n\\draw (6, 1) circle (0.1);\n\\draw (7, 1) circle (0.1);\n\\draw (8, 1) circle (0.1);\n\\draw (6, 0) circle (0.1);\n\\fill (7, 0) circle (0.1);\n\\draw (8, 0) circle (0.1);\n\\draw (6, -1) circle (0.1);\n\\draw (7, -1) circle (0.1);\n\\draw (8, -1) circle (0.1);\n\\draw (6, 1) to (8, 1);\n\\draw (7, 0) to (8, 0);\n\\draw [dotted, thick] (6, -1) to (8, -1);\n\\draw (6, 1) to (6, -1);\n\\draw (7, 0) to (7, -1);\n\\draw [dotted, thick] (8, 1) to (8, -1);\n\\draw (6, -1) to (8, 1);\n\\draw (7, -1) to (8, 0);\n\\draw (7, -1.5) node{$ \\chi\\br{\\Sigma_{1, g}} = -1 $};\n\\draw (0, 2) node[above]{$ g - 2 $};\n\\draw (-4.5, 1) to [out=45, in=-135] (0, 2);\n\\draw (4.5, 1) to [out=135, in=-45] (0, 2);\n\\end{tikzpicture}\n$$\n$$ \\chi\\br{\\Sigma_g} = \\sum_i \\chi\\br{\\Sigma_{1, i}} = \\sum_i \\br{V_i - E_i + F_i} = 2 - 2g $$\n}\n\\def\\syllabus{Parametrisations of curves in three-dimensional space. Curvature. Torsion. Frenet–Serret formulae. Winding number. Charts of surfaces. Tangent vectors. Tangent planes. Smooth maps between surfaces. Normal vectors. The first fundamental form. The second fundamental form. Christoffel symbols. Normal curvature. Gaussian curvature. Mean curvature. Gauss's Theorema Egregium. Area of surfaces. Length-minimising curves. Geodesic curvature. The Gauss–Bonnet theorem and applications.}\n\\def\\thm{subsection}\n\n\\input{../style/header}\n\n\\begin{document}\n\n\\input{../style/cover}\n\n\\section{Introduction}\n\n\\lecture{1}{Friday}{05/10/18}\n\nA question is what does it mean for a surface to be curved, more curved, less curved, or differently curved? In fact, what does it mean for a curve to be curved? The goal is to answer these questions. Touches on\n\\begin{itemize}\n\\item manifolds, smooth shapes, and differential geometry,\n\\item topology, and\n\\item Riemannian geometry and general relativity.\n\\end{itemize}\nThe following are references.\n\\begin{itemize}\n\\item C B\\\"ar, Elementary differential geometry, 2010\n\\end{itemize}\nA tentative outline of the material that we will cover is as follows. This may change as the term progresses. If so then an updated outline will be given during lectures.\n\\begin{itemize}\n\\item Curves in three-dimensional space.\n\\begin{itemize}\n\\item Parametrisations.\n\\item Curvature and torsion, Frenet–Serret formulae.\n\\item Curves are determined by curvature and torsion.\n\\item Winding number.\n\\end{itemize}\n\\item Surfaces.\n\\begin{itemize}\n\\item Charts.\n\\item Tangent vectors and tangent planes.\n\\item Smooth maps between surfaces.\n\\item Normal vectors.\n\\end{itemize}\n\\item Curvature.\n\\begin{itemize}\n\\item The first and second fundamental forms.\n\\item Christoffel symbols.\n\\item Normal curvature, Gaussian curvature, and mean curvature.\n\\item Gauss's Theorema Egregium.\n\\end{itemize}\n\\item Area of surfaces.\n\\item Geodesics.\n\\begin{itemize}\n\\item Length-minimising curves.\n\\item Existence, non-existence, and examples.\n\\item Geodesic curvature.\n\\end{itemize}\n\\item The Gauss–Bonnet theorem and applications.\n\\item The topological classification of surfaces.\n\\item Vector fields and the Poincar\\'e–Hopf theorem.\n\\end{itemize}\n\n\\pagebreak\n\n\\section{Curves in three-dimensional space}\n\nThe ultimate goal is surfaces. First is curves. What does it mean for a curve to be curved? In fact, what is a curve?\n\n\\subsection{What is a curve?}\n\n\\begin{definition}\nThe \\textbf{$ n $-dimensional Euclidean space} $ \\RR^n $ consists of\n$$ \\br{x_1, \\dots, x_n} = \\threebyone{x_1}{\\vdots}{x_n}, \\qquad x_i \\in \\RR. $$\n$ \\RR^n $ is a vector space and an inner product space. If $ x = \\br{x_1, \\dots, x_n} $ and $ y = \\br{y_1, \\dots, y_n} $ then\n$$ x \\cdot y = \\sum_{i = 1}^n x_iy_i $$\nis the \\textbf{inner product} of $ x $ and $ y $. The \\textbf{length} of $ x \\in \\RR^n $ is\n$$ \\abs{x} = \\sqrt{x \\cdot x} = \\sqrt{\\sum_{i = 1}^n x_i^2}. $$\n\\end{definition}\n\nFocus on $ \\RR^2 $ and $ \\RR^3 $.\n\n\\begin{definition}\nA \\textbf{parametrised curve} in $ \\RR^n $ is a smooth map\n$$ \\phi : \\sbr{a, b} \\to \\RR^n. $$\nIt is \\textbf{regular} if\n$$ \\phi'\\br{t} \\ne 0, \\qquad t \\in \\sbr{a, b}. $$\n\\end{definition}\n\nThe curve is $ \\phi\\br{\\sbr{a, b}} $. The parametrised curve says where a particle moving along this curve is positioned at time $ t $. This is $ \\phi\\br{t} $.\n\n\\begin{example*}\n$$ \\function[\\phi]{\\sbr{0, 2\\pi}}{\\RR^2}{t}{\\br{\\cos t, \\sin t}}, \\qquad \\function[\\phi]{\\sbr{0, 1}}{\\RR^3}{t}{\\br{\\cos 4\\pi t, \\sin 4\\pi t, t^4}} $$\nare curves.\n\\end{example*}\n\n\\begin{example*}\n$$ \\function[\\phi]{\\sbr{-1, 1}}{\\RR^2}{t}{\\br{t, \\abs{t}}} $$\nis not a curve.\n\\end{example*}\n\nFor us, all parametrised curves will be regular.\n\n\\begin{example*}\n$$ \\function[\\phi]{\\sbr{-1, 1}}{\\RR^2}{t}{\\br{t^2, t^3}} $$\nis not a curve, since $ \\phi'\\br{t} = \\br{2t, 3t^2} $ and $ \\phi'\\br{0} = \\br{0, 0} $.\n\\end{example*}\n\nWe are not interested in the parametrisation, just the curve.\n\n\\begin{example*}\n$$ \\function[\\phi]{\\sbr{0, 1}}{\\RR^2}{t}{\\br{\\cos 2\\pi t, \\sin 2\\pi t}} $$\nis the curve above.\n\\end{example*}\n\n\\pagebreak\n\n\\begin{definition}\nGiven a regular parametrised curve $ \\phi : \\sbr{a, b} \\to \\RR^n $ in $ \\RR^n $ and a smooth map $ f : \\sbr{c, d} \\xrightarrow{\\sim} \\sbr{a, b} $, with $ f'\\br{t} \\ne 0 $ for all $ t $, the curve\n$$ \\varphi = \\phi \\circ f : \\sbr{c, d} \\to \\RR^n $$\nis called a \\textbf{reparametrisation} of $ \\phi $.\n\\end{definition}\n\n\\begin{proposition}\nIf $ \\phi $ is regular and $ f : \\sbr{c, d} \\xrightarrow{\\sim} \\sbr{a, b} $ is smooth with $ f'\\br{t} \\ne 0 $ for all $ t $, then $ \\varphi = \\phi \\circ f $ is also a regular parametrised curve.\n\\end{proposition}\n\n\\begin{proof}\nChain rule implies that\n$$ \\varphi'\\br{t} = \\phi'\\br{f\\br{t}} \\cdot f'\\br{t}. $$\nThen $ \\phi'\\br{f\\br{t}} $ is never zero because $ \\phi $ is regular and $ f'\\br{t} $ is never zero by assumption. Thus $ \\phi'\\br{t} \\ne 0 $.\n\\end{proof}\n\nSo will study parametrised curves up to reparametrisation and study reparametrisation-invariant properties of parametrised curves.\n\n\\begin{remark*}\nReparametrisations $ f : \\sbr{c, d} \\xrightarrow{\\sim} \\sbr{a, b} $ with $ f'\\br{t} \\ne 0 $ form a groupoid under composition of functions. The groupoid acts on parametrised curves.\n\\end{remark*}\n\n\\lecture{2}{Monday}{08/10/18}\n\nSay that $ \\phi \\sim \\varphi $ if and only if $ \\phi $ is a reparametrisation of $ \\varphi $. Then $ \\sim $ is an equivalence relation. A \\textbf{curve} is an equivalence class of parametrised curves. The \\textbf{trace} of a curve $ \\phi : \\sbr{a, b} \\to \\RR^n $ is $ \\phi\\br{\\sbr{a, b}} $, that is the image in $ \\RR^n $. If $ \\phi \\sim \\varphi $ then the trace of $ \\phi $ is equal to the trace of $ \\varphi $, so this is well-defined.\n\n\\begin{example*}\nThe tangent line to a curve at a point.\n\\end{example*}\n\n\\begin{definition}\nThe \\textbf{tangent line} $ L $ to $ \\phi $ at $ \\phi\\br{t_0} $ is\n$$ L = \\cbr{\\phi\\br{t_0} + s\\phi'\\br{t_0} \\st s \\in \\RR}. $$\n\\end{definition}\n\nCheck that this is a reparametrisation-invariant. Suppose $ f : \\sbr{c, d} \\xrightarrow{\\sim} \\sbr{a, b} $ is a reparametrisation and $ \\varphi = \\phi \\circ f $. Let $ s_0 \\in \\sbr{c, d} $ satisfy $ f\\br{s_0} = t_0 $. Then\n$$ \\varphi\\br{s_0} = \\phi\\br{f\\br{s_0}} = \\phi\\br{t_0}, \\qquad \\varphi'\\br{s_0} = \\phi'\\br{f\\br{s_0}} \\cdot f'\\br{s_0} = \\phi'\\br{t_0} \\cdot f'\\br{s_0}, $$\nso\n$$ L = \\cbr{\\varphi\\br{s_0} + s'\\varphi'\\br{s_0} \\st s' \\in \\RR}. $$\n\n\\begin{definition}\nThe \\textbf{length} of a parametrised curve $ \\phi : \\sbr{a, b} \\to \\RR^n $ is\n$$ \\L\\br{\\phi} = \\intd{a}{b}{\\abs{\\phi'\\br{t}}}{t}. $$\n\\end{definition}\n\nChopping up $ \\sbr{a, b} $ into $ N $ intervals of size $ \\Delta t = \\br{b - a} / N $,\n$$ \\L\\br{\\phi} \\approx \\sum_{i = 0}^N \\abs{\\phi'\\br{a + i\\Delta t}}\\Delta t. $$\n\n\\begin{example*}\nLet\n$$ \\function[\\phi]{\\sbr{0, 2\\pi}}{\\RR^2}{t}{\\br{\\cos t, \\sin t}}. $$\nThen $ \\phi'\\br{t} = \\br{-\\sin t, \\cos t} $, so $ \\abs{\\phi'\\br{t}} = \\sqrt{\\sin^2 t + \\cos^2 t} = 1 $. Thus\n$$ \\L\\br{\\phi} = \\intd{0}{2\\pi}{1}{t} = 2\\pi, $$\nso the length is $ 2\\pi $.\n\\end{example*}\n\n\\pagebreak\n\n\\begin{proposition}\n$ \\L\\br{\\phi} $ is invariant under reparametrisation.\n\\end{proposition}\n\n\\begin{proof}\nFor simplicity, suppose $ n = 3 $, so $ \\RR^3 $. Then\n$$ \\function[\\phi]{\\sbr{a, b}}{\\RR^3}{t}{\\br{x\\br{t}, y\\br{t}, z\\br{t}}}. $$\nThus\n$$ \\L\\br{\\phi} = \\intd{a}{b}{\\sqrt{\\br{\\tod{x}{t}}^2 + \\br{\\tod{y}{t}}^2 + \\br{\\tod{z}{t}}^2}}{t}. $$\nGiven a reparametrisation $ f : \\sbr{c, b} \\xrightarrow{\\sim} \\sbr{a, b} $, so $ f $ is smooth and $ f'\\br{t} \\ne 0 $ for all $ t $, set $ \\varphi = \\phi \\circ f $ and write\n$$ \\varphi\\br{s} = \\br{X\\br{t}, Y\\br{t}, Z\\br{t}}. $$\nThen\n$$ \\L\\br{\\varphi} = \\intd{c}{d}{\\sqrt{\\br{\\tod{X}{s}}^2 + \\br{\\tod{Y}{s}}^2 + \\br{\\tod{Z}{s}}^2}}{s}. $$\nThus use the change of variable formula and\n$$ \\dod{X}{s}\\br{s} = \\dod{x}{t}\\br{f\\br{s}}\\dod{f}{s}\\br{s}, $$\nby the chain rule.\n\\end{proof}\n\nIf $ \\abs{\\phi'\\br{t}} = 1 $ for all $ t $ then\n$$ \\L\\br{\\phi} = \\intd{a}{b}{\\abs{\\phi'\\br{t}}}{t} = b - a, $$\nand in fact $ \\L\\br{\\eval{\\phi}_{\\sbr{a, t}}} = t - a $, so the curve is parametrised by arc-length. This is an \\textbf{arc-length parametrisation} or a \\textbf{unit speed parametrisation}.\n\n\\begin{proposition}\nLet $ \\phi : \\sbr{a, b} \\to \\RR^n $ be a regular curve. Then there exists an arc-length parametrisation of $ \\phi $.\n\\end{proposition}\n\n\\begin{proof}\nLet\n$$ \\function[l]{\\sbr{a, b}}{\\sbr{0, L}}{t}{\\intd{0}{t}{\\abs{\\phi'\\br{s}}}{s}}. $$\nSet $ f = l^{-1} $ as the inverse function. Then if $ \\varphi = \\phi \\circ f $ we have\n$$ \\abs{\\varphi'\\br{t}} = \\abs{\\phi'\\br{f\\br{t}}}f'\\br{t}. $$\nAlso $ l\\br{f\\br{t}} = t $, so $ l'\\br{f\\br{t}}f'\\br{t} = 1 $. Thus\n$$ f'\\br{t} = \\dfrac{1}{l'\\br{f\\br{t}}} = \\dfrac{1}{\\abs{\\phi'\\br{f\\br{t}}}}, $$\nby the fundamental theorem of calculus, so we have $ \\abs{\\varphi'\\br{t}} = 1 $ as required.\n\\end{proof}\n\n\\lecture{3}{Tuesday}{09/10/18}\n\nIs an arc-length parametrisation unique? No. Suppose that $ \\phi : \\sbr{a, b} \\to \\RR^n $ is an arc-length parametrisation of a curve, and that $ f : \\sbr{c, d} \\xrightarrow{\\sim} \\sbr{a, b} $ is a reparametrisation such that $ \\varphi = \\phi \\circ f $ is also an arc-length parametrisation. Then $ \\abs{\\phi'\\br{t}} = 1 $ for all $ t \\in \\sbr{a, b} $ and $ \\abs{\\varphi'\\br{t}} = 1 $ for all $ t \\in \\sbr{c, d} $, so\n$$ \\abs{\\phi'\\br{f\\br{t}}}\\abs{f'\\br{t}} = 1, \\qquad t \\in \\sbr{c, d}, $$\nso $ \\abs{f'\\br{t}} = 1 $. Thus $ f'\\br{t} = \\pm 1 $, so $ f\\br{t} = \\pm t + C $ for some constant $ C $.\n\n\\pagebreak\n\n\\subsection{Curvature}\n\n\\begin{definition}\nLet $ \\phi : \\sbr{a, b} \\to \\RR^n $ be a curve parametrised by arc-length. The \\textbf{curvature} of $ \\phi $ at $ \\phi\\br{t} $ is\n$$ \\kappa\\br{t} = \\abs{\\phi''\\br{t}}. $$\nThe \\textbf{curvature vector} is\n$$ \\vec{\\kappa}\\br{t} = \\phi''\\br{t}. $$\n\\end{definition}\n\nClaim that this depends only on the curve not on the parametrisation $ \\phi $. If $ \\varphi = \\phi \\circ f $ is another arc-length parametrisation then $ f\\br{t} = \\pm t + C $. Putting $ s = f\\br{t} $ we have\n$$ \\dod{\\varphi}{s} = \\pm\\dod{\\phi}{t}, \\qquad \\dod[2]{\\varphi}{s} = \\dod[2]{\\phi}{t}, $$\nso $ \\vec{\\kappa}\\br{t} $ is independent of the choice of parametrisation.\n\n\\begin{proposition}\n$ \\kappa\\br{t} = 0 $ if and only if the curve is a straight line.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\phi : \\sbr{a, b} \\to \\RR^n $ be an arc-length parametrisation of the curve. Then $ \\kappa\\br{t} = 0 $, so $ \\phi''\\br{t} = 0 $. Thus\n$$ \\phi\\br{t} = \\vec{a} + \\vec{b}t, \\qquad \\vec{a}, \\vec{b} \\in \\RR^n. $$\n\\end{proof}\n\n\\begin{proposition}\nFor curves in $ \\RR^n $, the vector curvature $ \\vec{\\kappa}\\br{t} $ is perpendicular to the tangent line at $ \\phi\\br{t} $ for all $ t $, where $ \\phi $ is an arc-length parametrisation.\n\\end{proposition}\n\n\\begin{proof}\nThe tangent line to the curve at $ \\phi\\br{t} $ is\n$$ L = \\cbr{\\phi\\br{t} + s\\phi'\\br{t} \\st s \\in \\RR}, $$\nwhere $ \\phi'\\br{t} $ is the direction vector of the tangent line. Need to show $ \\phi'\\br{t} \\cdot \\phi''\\br{t} = 0 $ for all $ t $. Know $ \\abs{\\phi'\\br{t}} = 1 $ for all $ t $, that is $ \\phi'\\br{t} \\cdot \\phi'\\br{t} = 1 $ for all $ t $. Differentiating,\n$$ \\phi''\\br{t} \\cdot \\phi'\\br{t} + \\phi'\\br{t} \\cdot \\phi''\\br{t} = 0, $$\nso $ 2\\phi'\\br{t} \\cdot \\phi''\\br{t} = 0 $. Thus $ \\phi'\\br{t} \\cdot \\phi''\\br{t} = 0 $.\n\\end{proof}\n\n\\begin{example*}\nThe curvature of a circle in $ \\RR^2 $ centred at the origin of radius $ R $. Need an arc-length parametrisation. Try\n$$ \\function[\\phi]{\\sbr{0, 2\\pi}}{\\RR}{t}{\\br{R\\cos t, R\\sin t}}. $$\nThen\n$$ \\abs{\\phi'\\br{t}} = \\abs{\\br{-R\\sin t, R\\cos t}} = R. $$\nOops. Try\n$$ \\function[\\phi]{\\sbr{0, 2\\pi R}}{\\RR}{t}{\\br{R\\cos \\tfrac{t}{R}, R\\sin \\tfrac{t}{R}}}. $$\nChecking,\n$$ \\abs{\\phi'\\br{t}} = \\abs{\\br{-\\sin \\tfrac{t}{R}, \\cos \\tfrac{t}{R}}} = 1. $$\nThe vector curvature is\n$$ \\vec{\\kappa}\\br{t} = \\br{-\\tfrac{1}{R}\\cos \\tfrac{t}{R}, -\\tfrac{1}{R}\\sin \\tfrac{t}{R}}, $$\nso the curvature is\n$$ \\kappa\\br{t} = \\abs{\\vec{\\kappa}\\br{t}} = \\dfrac{1}{R}. $$\n\\end{example*}\n\nThe curvature $ \\kappa\\br{t} $ does not determine the curve.\n\n\\pagebreak\n\n\\subsection{Space curves}\n\nLet $ \\phi : \\sbr{a, b} \\to \\RR^3 $ be an arc-length parametrisation of a curve. Set\n$$ \\T\\br{t} = \\phi'\\br{t}, $$\nthe \\textbf{unit tangent vector} to the curve at $ \\phi\\br{t} $ and assume $ \\T'\\br{t} \\ne 0 $ for all $ t $. Set\n$$ \\N\\br{t} = \\dfrac{\\T'\\br{t}}{\\abs{\\T'\\br{t}}}, $$\nthe \\textbf{principal normal vector} to the curve at $ \\phi\\br{t} $. Set\n$$ \\B\\br{t} = \\T\\br{t} \\times \\N\\br{t}, $$\nthe \\textbf{binormal vector} to the curve at $ \\phi\\br{t} $. Check that $ \\abs{\\B\\br{t}} = 1 $. Thus $ \\br{\\T, \\N, \\B} $ is a positively oriented orthonormal basis for $ \\RR^3 $, for each $ t \\in \\sbr{a, b} $. This is the \\textbf{Frenet frame} or \\textbf{Serret-Frenet frame}.\n\n\\lecture{4}{Friday}{12/10/18}\n\n$$ \\T'\\br{t} = \\abs{\\phi''\\br{t}}\\N\\br{t} = \\kappa\\br{t}\\N\\br{t}. $$\n$ \\B'\\br{t} = \\T'\\br{t} \\times \\N\\br{t} + \\T\\br{t} \\times \\N'\\br{t} = \\T\\br{t} \\times \\N'\\br{t} $, so $ \\B'\\br{t} $ is perpendicular to $ \\T\\br{t} $. Then $ \\B\\br{t} \\cdot \\B\\br{t} = 1 $ for all $ t $, so $ \\B\\br{t} $ is perpendicular to $ \\B'\\br{t} $. Thus\n$$ \\B'\\br{t} = -\\tau\\br{t}\\N\\br{t}, $$\nfor some function $ \\tau\\br{t} $. Then $ \\tau\\br{t} $ is called the \\textbf{torsion} of $ \\phi $ at the point $ \\phi\\br{t} $. Then $ \\N\\br{t} = \\B\\br{t} \\times \\T\\br{t} $ so\n$$ \\N'\\br{t} = \\B'\\br{t} \\times \\T\\br{t} + \\B\\br{t} \\times \\T'\\br{t} = -\\tau\\br{t}\\N\\br{t} \\times \\T\\br{t} + \\B\\br{t} \\times \\kappa\\br{t}\\N\\br{t} = \\tau\\br{t}\\B\\br{t} - \\kappa\\br{t}\\T\\br{t}. $$\nThus\n$$ \\T'\\br{t} = \\kappa\\br{t} \\cdot \\N\\br{t}, \\qquad \\B'\\br{t} = -\\tau\\br{t} \\cdot \\N\\br{t}, \\qquad \\N'\\br{t} = \\tau\\br{t} \\cdot \\B\\br{t} - \\kappa\\br{t} \\cdot \\T\\br{t}. $$\nSo the time evolution of the frame depends only on the curvature, the torsion, and the frame itself.\n\n\\begin{proposition}\nLet $ \\phi : \\sbr{a, b} \\to \\RR^3 $ be a curve parametrised by arc-length. Suppose $ \\phi''\\br{t} \\ne 0 $ for all $ t \\in \\sbr{a, b} $. Need this for the Frenet frame to exist. Then $ \\tau\\br{t} = 0 $ for all $ t $ if and only if $ \\phi $ is planar.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Suppose $ \\tau\\br{t} = 0 $. Then $ \\B'\\br{t} = 0 $, so $ \\B\\br{t} = v $ is constant. Claim that $ \\phi\\br{t} \\cdot v $ is constant for all $ t $.\n$$ \\br{\\phi\\br{t} \\cdot v}' = \\phi'\\br{t} \\cdot v + \\phi\\br{t} \\cdot 0 = \\phi'\\br{t} \\cdot v = \\T\\br{t} \\cdot v = 0, $$\nsince $ \\T $ is perpendicular to $ \\B $. Thus $ \\phi $ is moving in a plane perpendicular to $ v $.\n\\item[$ \\impliedby $] Suppose $ \\phi $ is planar. Then $ \\phi\\br{t} \\cdot v = a $ for some constant $ v \\in \\RR^3 $ and constant $ a \\in \\RR $. Then $ \\phi'\\br{t} \\cdot v = 0 $, so $ \\T\\br{t} $ is perpendicular to $ v $. Then $ \\phi''\\br{t} \\cdot v = 0 $, so $ \\kappa\\br{t} \\cdot \\N\\br{t} $ is perpendicular to $ v $. Then $ \\kappa\\br{t} \\ne 0 $, so $ \\N\\br{t} $ is perpendicular to $ v $. Thus $ \\B\\br{t} = \\pm v / \\abs{v} $ is constant, so $ \\tau\\br{t} = 0 $.\n\\end{itemize}\n\\end{proof}\n\n\\begin{exercise*}\nThe unit circle in the $ \\br{x, y} $ plane is\n$$ \\phi\\br{t} = \\br{\\cos t, \\sin t, 0}, \\qquad t \\in \\sbr{0, 2\\pi}. $$\nCompute $ \\T\\br{t}, \\N\\br{t}, \\B\\br{t}, \\tau\\br{t}, \\kappa\\br{t} $. Verify the Frenet formulae.\n\\end{exercise*}\n\n\\pagebreak\n\n\\begin{example*}\nThe helix is\n$$ \\phi\\br{t} = \\br{\\cos \\tfrac{t}{\\sqrt{2}}, \\sin \\tfrac{t}{\\sqrt{2}}, \\tfrac{t}{\\sqrt{2}}}, \\qquad t \\in \\RR. $$\nIt is an arc-length parametrisation, since $ \\phi'\\br{t} = \\br{-\\tfrac{1}{\\sqrt{2}}\\sin \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{\\sqrt{2}}\\cos \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{\\sqrt{2}}} $, so $ \\abs{\\phi'\\br{t}} = 1 $. Then\n\\begin{align*}\n\\T\\br{t} & = \\phi'\\br{t} = \\br{-\\tfrac{1}{\\sqrt{2}}\\sin \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{\\sqrt{2}}\\cos \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{\\sqrt{2}}}, \\\\\n\\N\\br{t} & = \\dfrac{\\phi''\\br{t}}{\\abs{\\phi''\\br{t}}} = 2\\br{-\\tfrac{1}{2}\\cos \\tfrac{t}{\\sqrt{2}}, -\\tfrac{1}{2}\\sin \\tfrac{t}{\\sqrt{2}}, 0} = \\br{-\\cos \\tfrac{t}{\\sqrt{2}}, -\\sin \\tfrac{t}{\\sqrt{2}}, 0}, \\\\\n\\B\\br{t} & = \\T\\br{t} \\times \\N\\br{t} = \\br{\\tfrac{1}{\\sqrt{2}}\\sin \\tfrac{t}{\\sqrt{2}}, -\\tfrac{1}{\\sqrt{2}}\\cos \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{\\sqrt{2}}}.\n\\end{align*}\nThen $ \\kappa\\br{t} = \\abs{\\phi''\\br{t}} = \\tfrac{1}{2} $ and $ \\tau\\br{t} = \\tfrac{1}{2} $, since $ \\B'\\br{t} = \\br{\\tfrac{1}{2}\\cos \\tfrac{t}{\\sqrt{2}}, \\tfrac{1}{2}\\sin \\tfrac{t}{\\sqrt{2}}, 0} = -\\tau\\br{t} \\cdot \\N\\br{t} $.\n\\end{example*}\n\nIn general $ \\kappa $ and $ \\tau $ are not constants.\n\n\\lecture{5}{Monday}{15/10/18}\n\n\\begin{theorem}[Fundamental theorem of the local theory of curves]\nGiven two differentiable functions $ \\kappa : \\sbr{a, b} \\to \\RR $ and $ \\tau : \\sbr{a, b} \\to \\RR $ such that $ \\kappa\\br{t} > 0 $ for all $ t $, there exists a regular curve $ \\phi : \\sbr{a, b} \\to \\RR^3 $ parametrised by arc-length with curvature $ \\kappa\\br{t} $ and torsion $ \\tau\\br{t} $. Any other such curve $ \\varphi : \\sbr{a, b} \\to \\RR^3 $ differs from $ \\phi $ by a \\textbf{rigid motion}, that is\n$$ \\varphi = g \\cdot \\phi + \\vec{c}, \\qquad g \\in \\SO\\br{3}, \\qquad \\vec{c} \\in \\RR^3. $$\n\\end{theorem}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item Proof of uniqueness. Rigid motions preserve arc-length, curvature, and torsion. If $ \\widetilde{\\phi} = g \\cdot \\phi + \\vec{c} $ then\n\\begin{itemize}\n\\item $ \\abs{\\widetilde{\\phi}'} = \\abs{g \\cdot \\phi'} = \\abs{\\phi'} = 1 $,\n\\item $ \\kappa_{\\widetilde{\\phi}} = \\abs{\\widetilde{\\phi}''} = \\abs{g \\cdot \\phi''} = \\abs{\\phi''} = \\kappa_\\phi $, and\n\\item $ \\T_{\\widetilde{\\phi}} = \\widetilde{\\phi}' = g \\cdot \\phi' = g \\cdot \\T_\\phi $ and $ \\N_{\\widetilde{\\phi}} = \\T_{\\widetilde{\\phi}}' / \\abs{\\T_{\\widetilde{\\phi}}'} = g \\cdot \\T_\\phi' / \\abs{\\T_\\phi'} = g \\cdot \\N_\\phi $, so\n$$ \\B_{\\widetilde{\\phi}} = \\T_{\\widetilde{\\phi}} \\times \\N_{\\widetilde{\\phi}} = g \\cdot \\T_\\phi \\times g \\cdot \\N_\\phi = g \\cdot \\br{\\T_\\phi \\times \\N_\\phi} = g \\cdot \\B_\\phi, $$\nso\n$$ -\\tau_{\\widetilde{\\phi}} \\cdot \\N_{\\widetilde{\\phi}} = \\B_{\\widetilde{\\phi}}' = \\br{g \\cdot \\B_\\phi}' = g \\cdot \\B_\\phi' = g \\cdot \\br{-\\tau_\\phi \\cdot \\N_\\phi} = -\\tau_\\phi \\cdot \\N_{\\widetilde{\\phi}}. $$\nThus $ \\tau_{\\widetilde{\\phi}} = \\tau_\\phi $.\n\\end{itemize}\nWe can apply a rigid motion to $ \\varphi $ which sends $ \\varphi\\br{a} $ to $ \\phi\\br{a} $ and Frenet frame $ \\br{\\T_\\varphi\\br{a}, \\N_\\varphi\\br{a}, \\B_\\varphi\\br{a}} $ to $ \\br{\\T_\\phi\\br{a}, \\N_\\phi\\br{a}, \\B_\\phi\\br{a}} $. We can assume that these are equal without loss of generality. We compute\n\\begin{align*}\n& \\dfrac{1}{2}\\dod{}{t}\\br{\\abr{\\T_\\phi - \\T_\\varphi, \\T_\\phi - \\T_\\varphi} + \\abr{\\N_\\phi - \\N_\\varphi, \\N_\\phi - \\N_\\varphi} + \\abr{\\B_\\phi - \\B_\\varphi, \\B_\\phi - \\B_\\varphi}} \\\\\n= \\ & \\abr{\\T_\\phi - \\T_\\varphi, \\T_\\phi' - \\T_\\varphi'} + \\abr{\\N_\\phi - \\N_\\varphi, \\N_\\phi' - \\N_\\varphi'} + \\abr{\\B_\\phi - \\B_\\varphi, \\B_\\phi' - \\B_\\varphi'} \\\\\n= \\ & \\kappa\\abr{\\T_\\phi - \\T_\\varphi, \\N_\\phi - \\N_\\varphi} + \\br{\\tau\\abr{\\N_\\phi - \\N_\\varphi, \\B_\\phi - \\B_\\varphi} - \\kappa\\abr{\\N_\\phi - \\N_\\varphi, \\T_\\phi - \\T_\\varphi}} - \\tau\\abr{\\B_\\phi - \\B_\\varphi, \\N_\\phi - \\N_\\varphi} \\\\\n= \\ & 0,\n\\end{align*}\nby the Frenet equations, and $ \\phi $ and $ \\varphi $ are solutions to the problem in the statement. Then\n$$ \\abr{\\T_\\phi - \\T_\\varphi, \\T_\\phi - \\T_\\varphi} + \\abr{\\N_\\phi - \\N_\\varphi, \\N_\\phi - \\N_\\varphi} + \\abr{\\B_\\phi - \\B_\\varphi, \\B_\\phi - \\B_\\varphi} $$\nis constant in time and is zero at $ t = a $, so it is zero for all $ t \\in \\sbr{a, b} $, so\n$$ \\T_\\phi = \\T_\\varphi, \\qquad \\N_\\phi = \\N_\\varphi, \\qquad \\B_\\phi = \\B_\\varphi. $$\nIn particular\n$$ \\phi\\br{t} = \\phi\\br{a} + \\intd{a}{t}{\\T_\\phi\\br{s}}{s} = \\varphi\\br{a} + \\intd{a}{t}{\\T_\\varphi\\br{s}}{s} = \\varphi\\br{t}. $$\nThe conclusion is $ \\phi = \\varphi $.\n\n\\pagebreak\n\n\\item Proof of existence. Given $ \\kappa\\br{t} > 0 $ and $ \\tau\\br{t} $, we can pick any positive orthonormal frame $ \\br{\\T_a, \\N_a, \\B_a} $ and use the existence theorem for solutions of linear differential equations to find $ \\T, \\N, \\B : \\sbr{a, b} \\to \\RR^3 $ such that\n$$\n\\begin{cases}\n\\threebyone{\\T\\br{a}}{\\N\\br{a}}{\\B\\br{a}} = \\threebyone{\\T_a}{\\N_a}{\\B_a} \\\\\n\\threebyone{\\T'}{\\N'}{\\B'} = \\threebythree{0}{\\kappa}{0}{-\\kappa}{0}{\\tau}{0}{-\\tau}{0}\\threebyone{\\T}{\\N}{\\B}\n\\end{cases}.\n$$\nWe check that $ \\br{\\T, \\N, \\B} $ is an orthonormal frame at all $ t \\in \\sbr{a, b} $. This is true at $ t = a $. We consider\n$$ M = \\onebythree{\\T}{\\N}{\\B}, \\qquad M' = \\onebythree{\\T'}{\\N'}{\\B'} = \\onebythree{\\T}{\\N}{\\B}\\threebythree{0}{-\\kappa}{0}{\\kappa}{0}{-\\tau}{0}{\\tau}{0} = M\\threebythree{0}{-\\kappa}{0}{\\kappa}{0}{-\\tau}{0}{\\tau}{0}. $$\nAs $ M $ is orthonormal if and only if $ M^\\intercal \\cdot M = \\id $, we want to prove that $ M^\\intercal \\cdot M = \\id $, so $ M^\\intercal \\cdot M = \\id $ at $ t = a $, and\n$$ \\dod{}{t}\\br{M^\\intercal \\cdot M} = M'^\\intercal \\cdot M + M^\\intercal \\cdot M' = \\threebythree{0}{\\kappa}{0}{-\\kappa}{0}{\\tau}{0}{-\\tau}{0} \\cdot M^\\intercal \\cdot M + M^\\intercal \\cdot M \\cdot \\threebythree{0}{-\\kappa}{0}{\\kappa}{0}{-\\tau}{0}{\\tau}{0}. $$\nThe linear system\n$$\n\\begin{cases}\n\\dod{}{t}\\br{A} = \\threebythree{0}{\\kappa}{0}{-\\kappa}{0}{\\tau}{0}{-\\tau}{0}A + A\\threebythree{0}{-\\kappa}{0}{\\kappa}{0}{-\\tau}{0}{\\tau}{0} \\\\\nA\\br{a} = \\id\n\\end{cases}\n$$\nhas solution $ A\\br{t} = \\id $. Hence by uniqueness, $ A\\br{t} = \\id = M^\\intercal \\cdot M $.\n\\end{itemize}\n\\end{proof}\n\n\\begin{exercise*}\nWhy is $ \\br{\\T\\br{t}, \\N\\br{t}, \\B\\br{t}} $ orthonormal for all $ t $ equivalent to the skew-symmetry of\n$$ \\threebythree{0}{\\kappa}{0}{-\\kappa}{0}{\\tau}{0}{-\\tau}{0}? $$\n\\end{exercise*}\n\n\\lecture{6}{Tuesday}{16/10/18}\n\n\\begin{example*}\nAny curve $ \\phi : \\sbr{a, b} \\to \\RR^3 $ with zero torsion and constant curvature $ c > 0 $ is an arc of a circle of radius $ 1 / c $. An arc of a circle has this property, since\n$$ \\phi\\br{t} = \\br{R\\cos \\tfrac{t}{R}, R\\sin \\tfrac{t}{R}, 0}, $$\n$$ \\phi'\\br{t} = \\br{-\\sin \\tfrac{t}{R}, \\cos \\tfrac{t}{R}, 0}, $$\n$$ \\phi''\\br{t} = \\br{-\\tfrac{1}{R}\\cos \\tfrac{t}{R}, -\\tfrac{1}{R}\\sin \\tfrac{t}{R}, 0}, $$\nso $ \\kappa\\br{t} = 1 / R = c $ and $ \\tau\\br{t} = 0 $, since the circle is a planar curve. Then apply the fundamental theorem of the local theory of curves.\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{Plane curves}\n\nLet $ \\phi : \\sbr{a, b} \\to \\RR^3 $. Then $ \\phi'\\br{t} = 0 $ is a point, $ \\kappa\\br{t} = 0 $ is a line, and $ \\tau\\br{t} = 0 $ is a plane. Let\n$$ \\function[\\phi]{\\sbr{a, b}}{\\RR^2}{t}{\\br{x\\br{t}, y\\br{t}}} $$\nbe parametrised by arc-length, so $ \\phi'\\br{t} = \\br{x'\\br{t}, y'\\br{t}} = 1 $ and $ \\N\\br{t} = \\br{-y'\\br{t}, x'\\br{t}} $. Then $ \\phi''\\br{t} = \\kappa\\br{t}\\N\\br{t} $, so\n\\begin{align*}\n\\kappa\\br{t}\n& = \\kappa\\br{t}\\abr{\\N\\br{t}, \\N\\br{t}}\n= \\abr{\\kappa\\br{t}\\N\\br{t}, \\N\\br{t}}\n= \\abr{\\phi''\\br{t}, \\N\\br{t}} \\\\\n& = \\abr{\\br{x''\\br{t}, y''\\br{t}}, \\br{-y'\\br{t}, x'\\br{t}}}\n= x'\\br{t}y''\\br{t} - y'\\br{t}x''\\br{t}.\n\\end{align*}\n\n\\begin{proposition}\nFor arbitrary $ \\phi $,\n$$ \\kappa\\br{t} = \\dfrac{\\phi''\\br{t} \\cdot \\N\\br{t}}{\\abs{\\phi'\\br{t}}^2}. $$\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\varphi\\br{s} = \\phi\\br{f\\br{s}} = \\br{x\\br{f\\br{s}}, y\\br{f\\br{s}}} $ be a reparametrisation by arc-length. Then\n\\begin{align*}\n\\kappa_\\varphi\\br{s}\n& = \\br{x\\br{f\\br{s}}}'\\br{y\\br{f\\br{s}}}'' - y\\br{f\\br{s}}'x\\br{f\\br{s}}''\n= \\br{x'\\br{f\\br{s}}y''\\br{f\\br{s}} - y'\\br{f\\br{s}}x''\\br{f\\br{s}}} \\cdot \\br{f'\\br{s}}^3 \\\\\n& = \\phi''\\br{f\\br{s}} \\cdot \\br{-\\br{y\\br{f\\br{s}}}', \\br{x\\br{f\\br{s}}}'} \\cdot \\br{f'\\br{s}}^2\n= \\br{\\phi''\\br{f\\br{s}} \\cdot \\N_\\varphi\\br{f\\br{s}}} \\cdot \\br{f'\\br{s}}^2.\n\\end{align*}\nWe have $ f = l^{-1} $ and $ l\\br{t} = \\intd{a}{t}{\\abs{\\phi'\\br{s}}}{s} $, so in particular $ f'\\br{s} = 1 / \\abs{\\phi'\\br{f\\br{s}}} $. Hence replace $ f\\br{s} = t $.\n\\end{proof}\n\n\\begin{example*}\nLet\n$$ \\function[\\phi]{\\sbr{a, b}}{\\RR^2}{t}{\\br{t, f\\br{t}}} $$\nbe a graph of a smooth function $ f $. Then\n$$ \\phi'\\br{t} = \\br{1, f'\\br{t}}, \\qquad \\phi''\\br{t} = \\br{0, f''\\br{t}}, \\qquad \\abs{\\phi'\\br{t}} = 1 + \\abs{f'\\br{t}}^2, \\qquad \\N\\br{t} = \\dfrac{\\br{-f'\\br{t}, 1}}{\\sqrt{1 + \\abs{f'\\br{t}}^2}}, $$\nso\n$$ \\kappa\\br{t} = \\dfrac{f''\\br{t}}{\\sqrt{1 + \\br{f'\\br{t}}^2}^3}. $$\n\\end{example*}\n\nSuppose that $ \\phi : \\sbr{a, b} \\to \\RR^2 \\cong \\CC $ is a smooth closed curve, so $ \\phi\\br{a} = \\phi\\br{b} $ and $ \\phi^{\\br{k}}\\br{a} = \\phi^{\\br{k}}\\br{b} $ for all $ k $. The \\textbf{winding number} of $ \\phi $ is an invariant measuring the number of clockwise rotations of the curve. Let $ z = x + iy $. We know from complex analysis\n\\begin{align*}\n\\w\\br{\\phi}\n& = \\dfrac{1}{2\\pi i} \\oint_\\gamma \\, \\dfrac{1}{z} \\, \\d z\n= \\dfrac{1}{2\\pi i} \\intd{a}{b}{\\dfrac{1}{x\\br{t} + iy\\br{t}}}{\\br{x\\br{t} + iy\\br{t}}} \\\\\n& = \\dfrac{1}{2\\pi i} \\intd{a}{b}{\\dfrac{x'\\br{t} + iy'\\br{t}}{x\\br{t} + iy\\br{t}} \\cdot \\dfrac{x\\br{t} - iy\\br{t}}{x\\br{t} - iy\\br{t}}}{t}\n= \\dfrac{1}{2\\pi i} \\intd{a}{b}{\\dfrac{\\br{xx' + yy'} + i\\br{y'x - x'y}}{x^2 + y^2}}{t} \\\\\n& = \\dfrac{1}{4\\pi i} \\sbr{\\ln\\br{x^2 + y^2}}_a^b + \\dfrac{1}{2\\pi} \\intd{a}{b}{\\dfrac{y'x - x'y}{x^2 + y^2}}{t}\n= \\dfrac{1}{2\\pi} \\intd{a}{b}{\\dfrac{y'x - x'y}{x^2 + y^2}}{t},\n\\end{align*}\nsince $ \\phi $ is a closed curve. If $ \\phi $ is parametrised by arc-length, so $ \\abs{\\phi'} = 1 $, then\n$$ \\w\\br{\\phi'} = \\dfrac{1}{2\\pi} \\intd{a}{b}{\\kappa\\br{t}}{t}. $$\n\n\\begin{proposition}\nThe winding number $ \\w\\br{\\T\\br{t}} $ of the unit tangent vector $ \\T\\br{t} = \\phi'\\br{t} / \\abs{\\phi'\\br{t}} $ is equal to the \\textbf{total curvature} $ \\intd{a}{b}{\\kappa\\br{t}}{t} $, divided by $ 2\\pi $.\n\\end{proposition}\n\n\\begin{definition}\nThe winding number $ \\w\\br{\\T\\br{t}} $ is called the \\textbf{index} or \\textbf{turning number} of $ \\phi $, and it is denoted $ \\Ind \\phi $. If $ \\phi'\\br{t} = e^{i\\theta t} $, then $ \\kappa\\br{t} = \\dot{\\theta}\\br{t} $. Thus\n$$ \\Ind \\phi = \\dfrac{1}{2\\pi}\\intd{a}{b}{\\dot{\\theta}\\br{t}}{t}. $$\n\\end{definition}\n\n\n\\pagebreak\n\n\\section{Surfaces}\n\n\\lecture{7}{Friday}{19/10/18}\n\n\\subsection{Regular surfaces}\n\n\\begin{definition}\nA \\textbf{regular surface} $ S \\subset \\RR^3 $ is a subset of $ \\RR^3 $ such that for all $ p \\in S $ there exists\n\\begin{itemize}\n\\item an open neighbourhood $ V \\subset \\RR^3 $ of $ p $,\n\\item an open set $ U \\subset \\RR^2 $, and\n\\item a smooth map $ \\phi : U \\to \\RR^3 $ such that\n\\begin{itemize}\n\\item $ \\phi\\br{U} = V \\cap S $,\n\\item $ \\phi $ is a homeomorphism onto its image, and\n\\item for all $ q \\in U $, $ \\d\\phi_q : \\RR^2 \\to \\RR^3 $ is injective.\n\\end{itemize}\n\\end{itemize}\n$ \\br{U, \\phi} $ is called a \\textbf{chart} near $ p $ or at $ p $.\n\\end{definition}\n\nWrite $ \\phi\\br{u, v} = \\br{x\\br{u, v}, y\\br{u, v}, z\\br{u, v}} $, then $ \\d\\phi_q : \\RR^2 \\to \\RR^3 $ has a matrix\n$$ \\eval{\\threebyone{\\tpd{x}{u} & \\tpd{x}{v}}{\\tpd{y}{u} & \\tpd{y}{v}}{\\tpd{z}{u} & \\tpd{z}{v}}}_q, $$\nand is injective if and only if the matrix has rank two, if and only if the columns are linearly independent. Then $ \\br{1, 0} $ at $ q \\in U \\subset \\RR^2 $ maps to $ \\d\\phi_q\\br{1, 0} $ at $ \\phi\\br{q} \\in S \\subset \\RR^3 $. Each column matrix of the matrix $ \\d\\phi_q $ is a tangent vector to $ S $ at $ \\phi\\br{q} $, so the regularity condition for surfaces ensures that a regular surface has a tangent plane at every point, since the columns of $ \\d\\phi_q $ span a two-dimensional space, that is a plane in $ \\RR^3 $.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Let $ \\RR^2 \\subset \\RR^3 $. Take the chart $ \\br{U, \\phi} $ with $ U = \\RR^2 $ and $ \\phi\\br{u, v} = \\br{u, v, 0} $.\n\\item Let $ f : \\RR^2 \\to \\RR $ be a smooth function. The \\textbf{graph} of $ f $ is\n$$ \\Gamma_f = \\cbr{\\br{x, y, f\\br{x, y}} \\st x, y \\in \\RR^2}. $$\nTake a chart $ \\br{U, \\phi} $ where $ U = \\RR^2 $ and $ \\phi\\br{u, v} = \\br{u, v, f\\br{u, v}} $. This is smooth, a homeomorphism onto its image, by projecting to $ \\br{x, y} $ or $ \\br{u, v} $ plane, and regular, since\n$$ \\d\\phi_{\\br{u, v}} = \\threebyone{1 & 0}{0 & 1}{\\tpd{f}{u} & \\tpd{f}{v}} $$\nhas rank two.\n\\item $ S = \\cbr{z^2 = x^2 + y^2 \\st z \\ge 0} $ has no smooth chart near $ \\br{0, 0, 0} $. Suppose there exists a smooth chart $ \\br{U, \\phi} $ near $ \\br{0, 0, 0} $. Consider the curve $ z = \\abs{y} $ and $ x = 0 $. It has a discontinuous velocity at $ t = 0 $. Any smooth curve through $ q \\in U $, when $ \\phi\\br{q} = 0 $, maps to a smooth curve in $ \\RR^2 $, by assumption, since we assumed $ \\phi $ is smooth, a contradiction. Thus curves like this are not smooth.\n\\item Define\n$$ \\function[\\phi]{\\br{0, 2\\pi} \\times \\br{-1, 1}}{\\RR^3}{\\br{u, v}}{\\br{\\sin u, \\sin 2u, v}}. $$\nThen $ \\phi $ is not a homeomorphism onto its image.\n\\end{itemize}\n\\end{example*}\n\n\\lecture{8}{Monday}{22/10/18}\n\nThe following is a very common situation.\n\n\\begin{definition}\nLet $ F : \\RR^3 \\to \\RR $ be a smooth function. We say that $ S \\subset \\RR^3 $ is a \\textbf{regular level set} of $ F $ if $ S = F^{-1}\\br{c} $ for some $ c \\in \\RR $ and $ \\nabla F\\br{p} \\ne 0 $ for all $ p \\in S $.\n\\end{definition}\n\n\\begin{example*}\nLet\n$$ S = \\cbr{x^2 + y^2 + z^2 = 1} \\subset \\RR^3. $$\nHere $ F = x^2 + y^2 + z^2 $ for $ c = 1 $ and $ \\nabla F = \\br{2x, 2y, 2z} $. Note $ \\nabla F\\br{p} \\ne 0 $ for all $ p \\in S $.\n\\end{example*}\n\n\\pagebreak\n\n\\begin{proposition}\n\\label{prop:regularlevelsets}\nRegular level sets are regular surfaces.\n\\end{proposition}\n\nFor this we need the inverse function theorem.\n\n\\begin{theorem}[Inverse function theorem]\nLet $ f : \\RR^n \\to \\RR^n $ be smooth on an open neighbourhood $ V $ of $ p \\in \\RR^n $, and suppose that $ \\d f_p : \\RR^n \\to \\RR^n $ is invertible. Then there exists an open neighbourhood $ U \\subset V $ of $ p $ such that $ \\eval{f}_U : U \\to f\\br{U} $ is a \\textbf{diffeomorphism}, which is a smooth bijection with a smooth inverse.\n\\end{theorem}\n\n\\begin{proof}[Proof of Proposition \\ref{prop:regularlevelsets}]\nThe goal is to construct a chart on $ S $ near each $ p \\in S $. Recall $ S = F^{-1}\\br{c} $. Now $ \\nabla F\\br{p} \\ne 0 $, so at least one of $ \\tpd{F}{x}\\br{p}, \\tpd{F}{y}\\br{p}, \\tpd{F}{z}\\br{p} $ is non-zero. Without loss of generality assume $ \\tpd{F}{z}\\br{p} \\ne 0 $. Consider\n$$ \\function[g]{\\RR^3}{\\RR^3}{\\br{x, y, z}}{\\br{x, y, F\\br{x, y, z}}}. $$\nThen $ g $ is smooth, and\n$$ \\d g_p = \\threebythree{1}{0}{0}{0}{1}{0}{\\tpd{F}{x}\\br{p}}{\\tpd{F}{y}\\br{p}}{\\tpd{F}{z}\\br{p}} $$\nis invertible. On a neighbourhood $ U $ of $ p $, $ g $ is a diffeomorphism. Let\n$$ W = \\cbr{\\br{u, v} \\in \\RR^2 \\st \\br{u, v, c} \\in g\\br{U}}. $$\nIdentify this with $ \\cbr{z = c} \\cap g\\br{U} $. Let $ V = U \\cap F^{-1}\\br{c} $ and let\n$$ \\function[\\phi]{W}{V}{\\br{u, v}}{g^{-1}\\br{u, v, c}}. $$\nThen $ \\phi $ is a chart on $ S $ near $ p $, since $ \\phi $ is smooth, a homeomorphism onto its image, and $ \\d\\phi_q $ is injective for all $ q \\in W $, guaranteed by the inverse function theorem.\n\\end{proof}\n\n\\begin{example*}\nThe torus is a regular surface. Consider the surface obtained by rotating the circle of radius one in the $ xz $ plane, centred at $ \\br{2, 0} $, about $ z $-axis. Writing this in cylindrical polars,\n$$ S = \\cbr{\\br{r - 2}^2 + z^2 = 1} = F^{-1}\\br{1}, \\qquad F\\br{x, y, z} = \\br{\\sqrt{x^2 + y^2} - 2}^2 + z^2. $$\nNow,\n$$ \\nabla F = \\br{\\tfrac{2x\\br{\\sqrt{x^2 + y^2} - 2}}{\\sqrt{x^2 + y^2}}, \\tfrac{2y\\br{\\sqrt{x^2 + y^2} - 2}}{\\sqrt{x^2 + y^2}}, 2z}. $$\nIf $ \\nabla F = 0 $ then $ 2z = 0 $ and either $ x = y = 0 $, so $ r = 0 $, or $ \\sqrt{x^2 + y^2} = 2 $, so $ r = 2 $. So $ \\nabla F\\br{p} \\ne 0 $ for all $ p \\in S $. Thus $ S $ is a regular surface.\n\\end{example*}\n\n\\begin{proposition}\nIf $ S $ is a regular surface then, for every $ p \\in S $, there exists a neighbourhood $ V $ of $ p $ in $ S $ such that $ V $ is the graph of a smooth function $ z = f\\br{x, y} $ or $ y = g\\br{x, z} $ or $ x = h\\br{y, z} $.\n\\end{proposition}\n\n\\begin{proof}\nTake a chart on $ S $ at $ p $. Write\n$$ \\function[\\phi]{U \\subset \\RR^2}{S \\subset \\RR^3}{\\br{u, v}}{\\br{x\\br{u, v}, y\\br{u, v}, z\\br{u, v}}}. $$\nLet $ q = \\phi^{-1}\\br{p} $. Now $ \\d\\phi_q $ has rank two. So one of the $ 2 \\times 2 $ minors of $ \\d\\phi_q $ is non-zero. Without loss of generality assume\n$$ \\abs{\\twobytwo{\\tpd{x}{u}\\br{q}}{\\tpd{x}{v}\\br{q}}{\\tpd{y}{u}\\br{q}}{\\tpd{y}{v}\\br{q}}} \\ne 0. $$\nConsider\n$$\n\\begin{array}{rcccl}\n\\RR^2 & \\xleftarrow{g} & U & \\xrightarrow{\\phi} & \\RR^3 \\\\\n\\br{x\\br{u, v}, y\\br{u, v}} & \\mapsfrom & \\br{u, v} & \\mapsto & \\br{x, y, F\\br{x, y}}\n\\end{array},\n$$\nThen $ g $ is a diffeomorphism near $ q $, by the inverse function theorem, so\n$$ \\br{\\phi \\circ g^{-1}}\\br{x, y} = \\br{x, y, F\\br{x, y}}, \\qquad F\\br{x, y} = z\\br{u\\br{x, y}, v\\br{x, y}}. $$\nThus, near $ p $, $ S $ is the graph $ z = F\\br{x, y} $.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Tangent vectors and tangent planes}\n\n\\lecture{9}{Tuesday}{23/10/18}\n\n\\begin{proposition}\nLet $ S $ be a regular surface, let $ p \\in S $, and let $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to \\RR^3 $ be a regular curve in $ S $ with $ \\alpha\\br{0} = p $. Let $ \\phi : U \\to \\RR^3 $ be a chart on $ S $ near $ p $. There exist smooth functions $ u, v : \\br{-\\epsilon', \\epsilon'} \\to U $ such that $ \\alpha\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $ for $ t \\in \\br{-\\epsilon', \\epsilon'} $, so\n$$\n\\begin{tikzcd}\n& \\br{-\\epsilon, \\epsilon} \\arrow{dl}[swap]{\\br{u\\br{t}, v\\br{t}}} \\arrow{dr}{\\alpha} & \\\\\nq \\in U \\arrow{rr}[swap]{\\phi} & & S \\ni p\n\\end{tikzcd}.\n$$\n\\end{proposition}\n\n\\begin{proof}\nWithout loss of generality $ S $ has the form $ z = f\\br{x, y} $. Then\n$$ \\phi\\br{u, v} = \\br{x\\br{u, v}, y\\br{u, v}, f\\br{x\\br{u, v}, y\\br{u, v}}}. $$\nLet $ q = \\phi^{-1}\\br{p} $, and set $ q = \\br{u_0, v_0} $. Define\n$$ \\function[F]{U \\times \\br{-\\epsilon, \\epsilon}}{\\RR^3}{\\br{u, v, t}}{\\br{x\\br{u, v}, y\\br{u, v}, f\\br{x\\br{u, v}, y\\br{u, v}} + t}}. $$\nThen $ F\\br{u_0, v_0, 0} = p $, and\n$$ \\d F_{\\br{u_0, v_0, 0}} = \\threebythree{\\tpd{x}{u}}{\\tpd{x}{v}}{0}{\\tpd{y}{u}}{\\tpd{y}{v}}{0}{\\tpd{f}{x}\\tpd{x}{u} + \\tpd{f}{y}\\tpd{y}{u}}{\\tpd{f}{x}\\tpd{x}{v} + \\tpd{f}{y}\\tpd{y}{v}}{1}. $$\nThe first two columns of $ \\d\\phi_{\\br{u_0, v_0}} $ has rank two, so $ \\br{\\tpd{x}{u}, \\tpd{y}{u}} $ and $ \\br{\\tpd{x}{v}, \\tpd{y}{v}} $ are linearly independent, so $ \\d F_{\\br{u_0, v_0, 0}} $ is invertible. Applying the inverse function theorem, $ F $ is a diffeomorphism in a neighbourhood of $ \\br{u_0, v_0, 0} $. Let $ G = F^{-1} $ near $ p $. Then\n$$ G\\br{x\\br{u, v}, y\\br{u, v}, f\\br{x\\br{u, v}, y\\br{u, v}}} = \\br{u, v, 0}. $$\nNow $ \\alpha\\br{t} = \\br{x\\br{t}, y\\br{t}, f\\br{x\\br{t}, y\\br{t}}} $ for some smooth functions $ x $ and $ y $. Setting $ \\br{u\\br{t}, v\\br{t}} = \\br{G \\circ \\alpha}\\br{t} $ we find $ u $ and $ v $ are smooth, because $ G $ and $ \\alpha $ are, and $ \\alpha\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $.\n\\end{proof}\n\n\\begin{definition}\nLet $ S $ be a regular surface, and let $ p \\in S $. A \\textbf{tangent vector} to $ S $ at $ p $ is a vector in $ \\RR^3 $ of the form $ \\alpha'\\br{0} $, where $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ is a regular curve with $ \\alpha\\br{0} = p $. The \\textbf{tangent plane} $ \\T_p S $ to $ S $ at $ p $ is the set of all tangent vectors.\n\\end{definition}\n\nThis is independent of charts. How to compute this?\n\n\\begin{proposition}\nIf $ \\phi : U \\to \\RR^3 $ is a chart for $ S $ at $ p $, with $ \\phi\\br{q} = p $, then $ \\T_p S $ is spanned by the columns of $ \\d\\phi_q $.\n\\end{proposition}\n\n\\begin{proof}\nWrite $ \\d\\phi_q = \\br{w_1, w_2} $. For all $ a, b \\in \\RR $, need to show $ aw_1 + bw_2 \\in \\T_p S $. Consider $ \\alpha\\br{t} = \\phi\\br{q + t\\br{a, b}} $. Chain rule implies that $ \\alpha'\\br{0} = \\d\\phi_q \\cdot \\br{a, b} = aw_1 + bw_2 $. So $ aw_1 + bw_2 \\in \\T_p S $. Conversely, need to show any element of $ \\T_p S $ is of the form $ aw_1 + bw_2 $ for some $ a, b \\in \\RR $. This is of the form $ \\alpha'\\br{0} $ where $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ is a regular curve with $ \\alpha\\br{0} = p $. Given the discussion earlier, we know that there exist smooth functions $ u, v : \\br{-\\epsilon', \\epsilon'} \\to U $ such that $ \\alpha\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $ for $ t \\in \\br{-\\epsilon', \\epsilon} $. Then\n$$ \\alpha'\\br{0} = \\d\\phi_{\\br{u\\br{0}, v\\br{0}}} \\cdot \\twobyone{\\tod{u}{t}\\br{0}}{\\tod{v}{t}\\br{0}} = \\d\\phi_q \\cdot \\twobyone{a}{b}, \\qquad a = \\dod{u}{t}\\br{0}, \\qquad b = \\dod{v}{t}\\br{0}. $$\nThus $ \\alpha'\\br{0} = aw_1 + bw_2 $ as claimed.\n\\end{proof}\n\n\\begin{exercise*}\nConsider\n$$ S = \\cbr{\\br{x, y, z} \\st x^2 + y^2 + z^2 = 1}, \\qquad p = \\br{0, 0, 1}. $$\nUse the chart\n$$ \\function[\\phi]{U}{\\RR^3}{\\br{u, v}}{\\br{u, v, \\sqrt{1 - u^2 - v^2}}}, $$\nwhere $ U $ is the open unit disc in $ \\RR^2 $ to compute $ \\T_p S $ as the $ xy $ plane.\n\\end{exercise*}\n\n\\pagebreak\n\n\\lecture{10}{Friday}{26/10/18}\n\n\\begin{proposition}\nLet $ S = F^{-1}\\br{c} $ for $ F : \\RR^3 \\to \\RR $ then for any $ p \\in S $,\n$$ \\T_p S = \\br{\\nabla F\\br{p}}^\\perp. $$\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ such that $ \\alpha\\br{0} = p $, so $ \\alpha'\\br{0} \\in \\T_p S $ and $ F\\br{\\alpha\\br{t}} = c $. Let $ \\alpha = \\br{x\\br{t}, y\\br{t}, z\\br{t}} $. Then\n$$ 0 = \\eval{\\dod{}{t}F\\br{\\alpha\\br{t}}}_{t = 0} = \\eval{\\br{\\dpd{F}{x}\\dod{x}{t} + \\dpd{F}{y}\\dod{y}{t} + \\dpd{F}{z}\\dod{z}{t}}}_{t = 0} = \\nabla F\\br{\\alpha\\br{0}} \\cdot \\alpha'\\br{0}, $$\nso $ \\alpha'\\br{0} \\in \\br{\\nabla F\\br{p}}^\\perp $, so $ \\T_p S \\subseteq \\br{\\nabla F\\br{p}}^\\perp $, which is two-dimensional. This implies that $ \\T_p S = \\br{\\nabla F\\br{p}}^\\perp $.\n\\end{proof}\n\n\\begin{example*}\nLet $ S $ be the paraboloid\n$$ \\cbr{z = x^2 + y^2} = F^{-1}\\br{0}, \\qquad F = x^2 + y^2 - z, $$\nand let $ p = \\br{1, 3, 10} $. Then $ \\nabla F = \\br{2x, 2y, -1} \\ne 0 $, and $ \\nabla F\\br{p} = \\br{2, 6, -1} $, so\n$$ \\T_p S = \\br{\\nabla F\\br{p}}^\\perp = \\cbr{2x + 6y - z = 0}. $$\n\\end{example*}\n\n\\begin{definition}\nLet $ S_1 $ and $ S_2 $ be regular surfaces. A map $ F : S_1 \\to \\RR^3 $ is \\textbf{smooth} if for every chart $ \\phi : U \\to S_1 $ the composition $ U \\xrightarrow{\\phi} S_1 \\xrightarrow{F} \\RR^3 $ is smooth. A map $ F : S_1 \\to S_2 $ is \\textbf{smooth} if it is smooth when viewed as a map $ F : S_1 \\to \\RR^3 $. The \\textbf{differential} of a smooth map $ F : S_1 \\to S_2 $ at $ p \\in S_1 $, denoted\n$$ \\d F_p : \\T_p S_1 \\to \\T_{F\\br{p}} S_2, $$\nis defined as follows. Let $ v = \\alpha'\\br{0} $ for $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S_1 $ such that $ \\alpha\\br{0} = p $ and $ \\beta\\br{t} = F\\br{\\alpha\\br{t}} : \\br{-\\epsilon, \\epsilon} \\to S_2 $. This is a regular curve in $ S_2 $, so $ \\beta'\\br{0} \\in \\T_{F\\br{p}} S_2 $, since $ \\beta\\br{0} = F\\br{p} $. We define\n$$ \\d F_p\\br{v} = \\beta'\\br{0}. $$\n\\end{definition}\n\n\\begin{proposition}\nThis definition is independent of the choice of curve $ \\alpha $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha_1, \\alpha_2 : \\br{-\\epsilon, \\epsilon} \\to S_1 $ such that $ \\alpha_1\\br{0} = p $ and $ \\alpha_1'\\br{0} = \\alpha_2'\\br{0} $. Let $ \\alpha_1\\br{t} = \\phi\\br{u_1\\br{t}, v_1\\br{t}} $ and $ \\alpha_2\\br{t} = \\phi\\br{u_2\\br{t}, v_2\\br{t}} $, so\n$$ \\dpd{\\phi}{u_1}\\dod{u_1}{t}\\br{0} + \\dpd{\\phi}{v_1}\\dod{v_1}{t}\\br{0} = \\alpha_1'\\br{0} = \\alpha_2'\\br{0} = \\dpd{\\phi}{u_2}\\dod{u_2}{t}\\br{0} + \\dpd{\\phi}{v_2}\\dod{v_2}{t}\\br{0}. $$\nRecall $ \\tod{\\phi}{u} $ and $ \\tod{\\phi}{v} $ are linearly independent. This implies that\n\\begin{equation}\n\\label{eq:1}\n\\dod{u_1}{t}\\br{0} = \\dod{u_2}{t}\\br{0}, \\qquad \\dod{v_1}{t}\\br{0} = \\dod{v_2}{t}\\br{0}.\n\\end{equation}\nWant $ \\d F_p\\br{\\alpha_1'\\br{0}} = \\d F_p\\br{\\alpha_2'\\br{0}} $.\n$$ \\d F_p\\br{\\alpha_i\\br{0}} = \\eval{\\dod{}{t}F\\br{\\phi\\br{u_i, v_i}}}_{t = 0} = \\eval{\\br{\\dpd{\\br{F \\circ \\phi}}{u}\\dod{u_i}{t} + \\dpd{\\br{F \\circ \\phi}}{v}\\dod{v_i}{t}}}_{t = 0}, \\qquad i = 1, 2, $$\nso $ \\d F_p\\br{\\alpha_1'\\br{0}} = \\d F_p\\br{\\alpha_2'\\br{0}} $ by $ \\br{\\ref{eq:1}} $. It follows that $ \\d F_p\\br{v} $ is the same if we define it via $ \\alpha_1 $ or $ \\alpha_2 $.\n\\end{proof}\n\n\\begin{proposition}\n$ \\d F_p : \\T_p S_1 \\to \\T_{F\\br{p}} S_2 $ is linear.\n\\end{proposition}\n\n\\begin{proof}\nLet $ v, w \\in \\T_p S_1 $ and $ c, d \\in \\RR $. Want $ \\d F_p\\br{cv + dw} = c\\d F_p\\br{v} + d\\d F_p\\br{w} $. Let $ \\alpha_1, \\alpha_2 : \\br{-\\epsilon, \\epsilon} \\to S_1 $ such that $ v = \\alpha_1'\\br{0} $ and $ w = \\alpha_2'\\br{0} $. Let $ \\phi : U \\to S_1 $ be a chart. Without loss of generality we assume $ \\br{0, 0} \\in U $ and $ \\phi\\br{0, 0} = p $. Let $ \\alpha_i\\br{t} = \\phi\\br{u_i\\br{t}, v_i\\br{t}} $. Let\n$$ \\alpha_3\\br{t} = \\phi\\br{cu_1\\br{t} + du_2\\br{t}, cv_1\\br{t} + dv_2\\br{t}}, $$\nso $ \\alpha_3\\br{0} = \\phi\\br{0, 0} = p $ and\n\\begin{align*}\n\\alpha_3'\\br{0}\n& = \\dpd{\\phi}{u}\\br{cu_1'\\br{0} + du_2'\\br{0}} + \\dpd{\\phi}{v}\\br{cv_1'\\br{0} + dv_2'\\br{0}} \\\\\n& = c\\br{u_1'\\br{0}\\dpd{\\phi}{u} + v_1'\\br{0}\\dpd{\\phi}{v}} + d\\br{u_2'\\br{0}\\dpd{\\phi}{u} + v_2'\\br{0}\\dpd{\\phi}{v}}\n= c\\alpha_1'\\br{0} + d\\alpha_2'\\br{0}\n= cv + dw.\n\\end{align*}\n\n\\pagebreak\n\nThen\n\\begin{align*}\n\\d F_p\\br{cv + dw}\n& = \\d F_p\\br{\\alpha_3'\\br{0}}\n= \\br{\\br{F \\circ \\phi}\\br{cu_1\\br{t} + du_2\\br{t}, cv_1\\br{t} + dv_2\\br{t}}}'\\br{0} \\\\\n& = \\dpd{\\br{F \\circ \\phi}}{u}\\br{cu_1'\\br{0} + du_2'\\br{0}} + \\dpd{\\br{F \\circ \\phi}}{u}\\br{cv_1'\\br{0} + dv_2'\\br{0}} \\\\\n& = c\\br{\\dpd{\\br{F \\circ \\phi}}{u}u_1'\\br{0} + \\dpd{\\br{F \\circ \\phi}}{v}v_1'\\br{0}} + d\\br{\\dpd{\\br{F \\circ \\phi}}{u}u_2'\\br{0} + \\dpd{\\br{F \\circ \\phi}}{v}v_2'\\br{0}} \\\\\n& = c\\br{F \\circ \\alpha_1}'\\br{0} + d\\br{F \\circ \\alpha_2}'\\br{0}\n= c\\d F_p\\br{v} + d\\d F_p\\br{w},\n\\end{align*}\nsince\n$$ \\d F_p\\br{\\alpha_i'\\br{0}} = \\br{F \\circ \\alpha_i}'\\br{0} = \\br{\\dpd{\\br{F \\circ \\phi}}{u}}\\dod{u_i}{t} + \\br{\\dpd{\\br{F \\circ \\phi}}{v}}\\dod{v_i}{t}. $$\n\\end{proof}\n\n\\begin{remark*}\nWe will use the following identity. Given a chart $ \\phi : U \\to S_1 $ and $ F : S_1 \\to S_2 $,\n$$ \\d F_p\\br{\\dpd{\\phi}{u}\\br{u_0, v_0}} = \\dpd{\\br{F \\circ \\phi}}{u}\\br{u_0, v_0}, \\qquad \\d F_p\\br{\\dpd{\\phi}{v}\\br{u_0, v_0}} = \\dpd{\\br{F \\circ \\phi}}{v}\\br{u_0, v_0}. $$\n\\end{remark*}\n\nSimilarly, we define the \\textbf{differential} of a smooth function $ f : S \\to \\RR $ if $ v \\in \\T_p S $ satisfies $ v = \\alpha'\\br{0} $ for $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ as\n$$ \\d f_p\\br{v} = f\\br{\\alpha\\br{t}}'\\br{0}. $$\n\n\\begin{exercise*}\nShow that $ \\d f_p $ is well-defined, so independent of choice of $ \\alpha $, and that it is linear.\n\\end{exercise*}\n\n\\lecture{11}{Monday}{29/10/18}\n\n\\begin{example*}\nLet\n$$ S = \\cbr{x^2 + y^2 + z^2 = 1} = F^{-1}\\br{1}, \\qquad \\function[F]{\\RR^3}{\\RR}{\\br{x, y, z}}{x^2 + y^2 + z^2}, $$\nand let\n$$ p = \\br{0, 1, 0}, \\qquad \\function[f]{S}{\\RR}{\\br{x, y, z}}{z}. $$\nThen $ \\nabla F\\br{p} = \\br{0, 2, 0} $, so\n$$ \\T_p S = \\br{\\nabla F\\br{p}}^\\perp = \\abr{\\br{1, 0, 0}, \\br{0, 0, 1}}. $$\nBut to compute $ \\d f_p $ use the chart near $ p $,\n$$ \\function[\\phi_p]{U}{S}{\\br{u, v}}{\\br{u, \\sqrt{1 - u^2 - v^2}, v}}, \\qquad U = \\cbr{u^2 + v^2 < 1}. $$\nThen $ \\br{f \\circ \\phi}\\br{u, v} = v $, so\n$$ \\d f_p\\br{\\dpd{\\phi}{u}\\br{0, 0}} = 0, \\qquad \\d f_p\\br{\\dpd{\\phi}{v}\\br{0, 0}} = 1. $$\nThis determines $ \\d f_p : \\T_p S \\to \\RR $, a linear map.\n\\end{example*}\n\n\\begin{proposition}\nLet $ f : S_1 \\to S_2 $ be a smooth map. If $ \\d f_p : \\T_p S_1 \\to \\T_{f\\br{p}} S_2 $ is an isomorphism, then there exists an open neighbourhood $ V \\subseteq S_1 $ of $ p $ such that $ f : V \\to f\\br{V} $ is a diffeomorphism.\n\\end{proposition}\n\n\\begin{proof}\nTake charts $ \\phi_1 : U_1 \\to S_1 $ at $ p $ and $ \\phi_2 : U_2 \\to S_2 $ at $ f\\br{p} $, so\n$$\n\\begin{tikzcd}\n\\phi_1\\br{q_1} = p \\in \\phi_1\\br{U_1} \\subseteq S_1 \\arrow{r}{f} & \\phi_2\\br{q_2} = f\\br{p} \\in \\phi_2\\br{U_2} \\subseteq S_2 \\\\\nq_1 \\in U_1 \\subseteq \\RR^2 \\arrow{u}{\\phi_1} \\arrow{r}[swap]{g} & q_2 \\in U_2 \\subseteq \\RR^2 \\arrow{u}[swap]{\\phi_2}\n\\end{tikzcd}.\n$$\nCheck that the map\n$$ g : U_1 \\to S_1 \\to S_2 \\to U_2 $$\nsatisfies $ g\\br{q_1} = q_2 $, and $ \\d g_{q_1} $ is invertible. Use the inverse function theorem for $ g $. Then $ f = \\phi_2 \\circ g \\circ \\phi_1^{-1} $ will be a diffeomorphism on some neighbourhood of $ \\phi_1\\br{q_1} = p $.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Normal vectors}\n\nA regular surface $ S \\subseteq \\RR^3 $ has two normal vectors at $ p $ in $ S $. If $ S = F^{-1}\\br{c} $ for some smooth function $ F : \\RR^3 \\to \\RR $, then $ \\T_p S = \\br{\\nabla F\\br{p}}^\\perp $. We can define the \\textbf{unit normal vector}\n$$ \\N\\br{p} = \\dfrac{\\nabla F\\br{p}}{\\abs{\\nabla F\\br{p}}}. $$\nIn general we can only do this locally, in a chart. Given a chart $ \\phi : U \\to S $ such that $ \\phi\\br{q} = p $, we know that $ \\T_p S $ is spanned by $ \\tod{\\phi}{u}\\br{q} $ and $ \\tod{\\phi}{v}\\br{q} $. Define\n$$ \\N\\br{p} = \\dfrac{\\tpd{\\phi}{u}\\br{q} \\times \\tpd{\\phi}{v}\\br{q}}{\\abs{\\tpd{\\phi}{u}\\br{q} \\times \\tpd{\\phi}{v}\\br{q}}}. $$\nThis can always be done locally, but not globally. On the M\\\"obius strip, you cannot pick $ \\N\\br{p} $ continuously.\n\n\\begin{definition}\n$ S $ is \\textbf{orientable} if it admits a continuous choice of unit normal vector $ \\N\\br{p} \\in S $. If $ S $ is orientable, we get a map $ \\N : S \\to \\S^2 $. Then $ \\N $ is called the \\textbf{Gauss map}. If this exists, it is smooth.\n\\end{definition}\n\n\\begin{example*}\nLet $ S = \\S^2 $ be the unit sphere. As $ S = F^{-1}\\br{1} $ for $ F\\br{x, y, z} = x^2 + y^2 + z^2 $,\n$$ \\N\\br{x, y, z} = \\dfrac{\\nabla F\\br{x, y, z}}{\\abs{\\nabla F\\br{x, y, z}}} = \\dfrac{\\br{2x, 2y, 2z}}{\\sqrt{4x^2 + 4y^2 + 4z^2}} = \\br{x, y, z}. $$\nOr, near the north pole $ \\br{0, 0, 1} $ we have a chart $ \\phi\\br{u, v} = \\br{u, v, \\sqrt{1 - u^2 - v^2}} $, so\n$$ \\dpd{\\phi}{u} = \\br{1, 0, \\tfrac{-u}{\\sqrt{1 - u^2 - v^2}}}, \\qquad \\dpd{\\phi}{u} = \\br{0, 1, \\tfrac{-v}{\\sqrt{1 - u^2 - v^2}}}, $$\nso\n$$ \\dpd{\\phi}{u} \\times \\dpd{\\phi}{v} = \\br{\\tfrac{u}{\\sqrt{1 - u^2 - v^2}}, \\tfrac{v}{\\sqrt{1 - u^2 - v^2}}, 1}. $$\nThus\n$$ \\N\\br{\\phi\\br{u, v}} = \\dfrac{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}{\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}} = \\br{u, v, \\sqrt{1 - u^2 - v^2}} = \\phi\\br{u, v}. $$\n\\end{example*}\n\n\\begin{example*}\nLet\n$$ S = \\cbr{ax + by + cz = d} = F^{-1}\\br{d}, \\qquad F\\br{x, y, z} = ax + by + cz $$\nbe a plane. Then\n$$ \\N\\br{x, y, z} = \\dfrac{\\nabla F\\br{x, y, z}}{\\abs{\\nabla F\\br{x, y, z}}} = \\dfrac{\\br{a, b, c}}{\\sqrt{a^2 + b^2 + c^2}} $$\nis a constant map.\n\\end{example*}\n\nWhat is $ \\d\\N_p : \\T_p S \\to \\T_{\\N\\br{p}} \\S^2 $? $ \\T_{\\N\\br{p}} \\S^2 $ is all vectors orthogonal to $ \\N\\br{p} $, which is $ \\T_p S $. We use this identification to write $ \\d\\N_p : \\T_p S \\to \\T_p S $.\n\n\\begin{example*}\nLet\n$$ S = \\cbr{\\br{x, y, z} \\st x^2 + y^2 + z^2 = r^2} = F^{-1}\\br{r^2}, \\qquad F = x^2 + y^2 + z^2 $$\nbe a sphere of radius $ r $, and let $ p = \\br{x, y, z} $. Then\n$$ \\N\\br{p} = \\dfrac{\\nabla F\\br{p}}{\\abs{\\nabla F\\br{p}}} = \\br{\\dfrac{x}{r}, \\dfrac{y}{r}, \\dfrac{z}{r}} = \\dfrac{p}{r}. $$\nLet $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ be a curve with $ \\alpha\\br{0} = p $, so\n$$ \\d\\N_p\\br{\\alpha'\\br{0}} = \\eval{\\dod{\\br{\\br{\\N \\circ \\alpha}\\br{t}}}{t}}_{t = 0} = \\dfrac{1}{r}\\alpha'\\br{0}. $$\nThus $ \\d\\N_p : \\T_p S \\to \\T_p S $ is $ \\d\\N_p = \\id / r $.\n\\end{example*}\n\n\\pagebreak\n\n\\section{Curvature}\n\n\\lecture{12}{Tuesday}{30/10/18}\n\nWe will try to define the curvature using the Gauss map.\n\n\\subsection{The second fundamental form}\n\n\\begin{example*}\nLet\n$$ S = \\cbr{ax + by + cz = d} $$\nbe a plane, and let $ p \\in S $. Then\n$$ \\N\\br{p} = \\dfrac{\\br{a, b, c}}{\\sqrt{a^2 + b^2 + c^2}} $$\nis constant with respect to $ p $, so $ \\d\\N_p : \\T_p S \\to \\T_{\\N\\br{p}} \\S^2 $ is the zero map.\n\\end{example*}\n\n\\begin{exercise*}\nLet\n$$ S = \\cbr{x^2 + 2y^2 + z^2 = r^2}. $$\nCompute $ \\d\\N_p $ at $ \\br{1, 0, 0} $ and at $ \\br{0, 1, 0} $.\n\\end{exercise*}\n\n\\begin{definition}\nLet $ S $ be a regular orientable surface, let $ p \\in S $. The \\textbf{second fundamental form} at $ p $ is\n$$ \\function[\\A]{\\T_p S \\times \\T_p S}{\\RR}{\\br{X, Y}}{-X \\cdot \\d\\N_p\\br{Y}}, $$\nwhich is how much $ \\N_p\\br{Y} $ is changing in the direction of $ X $.\n\\end{definition}\n\n\\begin{example*}\nIf $ S $ is a sphere of radius $ r $ then\n$$ \\A\\br{X, Y} = -\\dfrac{1}{r}X \\cdot Y. $$\n\\end{example*}\n\n\\begin{proposition}\n$ \\A $ is a symmetric bilinear form.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item Bilinearity.\n\\begin{align*}\n\\A\\br{X, cY_1 + dY_2}\n& = -X \\cdot \\d\\N_p\\br{cY_1 + dY_2}\n= -X \\cdot \\br{c\\d\\N_p\\br{Y_1} + d\\d\\N_p\\br{Y_2}} \\\\\n& = c\\br{-X \\cdot \\d\\N_p\\br{Y_1}} + d\\br{-X \\cdot \\d\\N_p\\br{Y_2}}\n= c\\A\\br{X, Y_1} + d\\A\\br{X, Y_2}.\n\\end{align*}\nSimilarly $ \\A\\br{cX_1 + dX_2, Y} = c\\A\\br{X_1, Y} + d\\A\\br{X_2, Y} $.\n\\item Symmetry. Take a chart $ \\phi : U \\to S $ near $ p $. Then $ \\tod{\\phi}{u}\\br{q} $ and $ \\tod{\\phi}{v}\\br{q} $, where $ \\phi\\br{q} = p $, form a basis for the tangent space $ \\T_p S $. It is sufficient to prove that\n$$ \\A\\br{\\dpd{\\phi}{u}\\br{q}, \\dpd{\\phi}{v}\\br{q}} = \\A\\br{\\dpd{\\phi}{v}\\br{q}, \\dpd{\\phi}{u}\\br{q}}. $$\nObserve that\n$$ \\N\\br{\\phi\\br{p}} \\cdot \\dpd{\\phi}{u} = 0, \\qquad \\N\\br{\\phi\\br{p}} \\cdot \\dpd{\\phi}{v} = 0, $$\nsince $ \\tod{\\phi}{u} $ and $ \\tod{\\phi}{v} $ are in $ \\T_p S $ and $ \\N\\br{\\phi\\br{p}} $ is normal to $ \\T_p S $. Applying $ \\tpd{}{v} $ and $ \\tpd{}{u} $,\n$$ \\dpd{}{v}\\br{\\N \\circ \\phi} \\cdot \\dpd{\\phi}{u} + \\br{\\N \\circ \\phi} \\cdot \\dmd{\\phi}{2}{v}{}{u}{} = 0, \\qquad \\dpd{}{u}\\br{\\N \\circ \\phi} \\cdot \\dpd{\\phi}{v} + \\br{\\N \\circ \\phi} \\cdot \\dmd{\\phi}{2}{u}{}{v}{} = 0. $$\nThen\n$$ \\A\\br{\\dpd{\\phi}{u}, \\dpd{\\phi}{v}} = \\br{\\N \\circ \\phi} \\cdot \\dmd{\\phi}{2}{v}{}{u}{}, \\qquad \\A\\br{\\dpd{\\phi}{v}, \\dpd{\\phi}{u}} = \\br{\\N \\circ \\phi} \\cdot \\dmd{\\phi}{2}{u}{}{v}{}. $$\nThus both these are equal, so\n$$ \\A\\br{\\dpd{\\phi}{u}, \\dpd{\\phi}{v}} = \\A\\br{\\dpd{\\phi}{v}, \\dpd{\\phi}{u}}. $$\n\\end{itemize}\n\\end{proof}\n\n\\lecture{13}{Friday}{02/11/18}\n\nLecture 13 is a problems class.\n\n\\pagebreak\n\n\\subsection{Normal curvature, Gaussian curvature, and mean curvature}\n\n\\lecture{14}{Monday}{05/11/18}\n\nThere exists an orthonormal basis $ x_1 $ and $ x_2 $ for $ \\T_p S $ such that\n$$ \\d\\N_p\\br{x_i} = -\\lambda_ix_i, \\qquad i = 1, 2. $$\nThen\n\\begin{itemize}\n\\item $ \\A\\br{x_1, x_1} = -x_1 \\cdot \\d\\N_p\\br{x_1} = x_1 \\cdot \\br{\\lambda_1x_1} = \\lambda_1 $,\n\\item $ \\A\\br{x_1, x_2} = -x_1 \\cdot \\d\\N_p\\br{x_2} = x_1 \\cdot \\br{\\lambda_2x_2} = 0 $, and\n\\item $ \\A\\br{x_2, x_2} = -x_2 \\cdot \\d\\N_p\\br{x_2} = x_2 \\cdot \\br{\\lambda_2x_2} = \\lambda_2 $.\n\\end{itemize}\nWe call $ x_1 $ and $ x_2 $ the \\textbf{principal directions} in $ \\T_p S $ and $ \\lambda_1 $ and $ \\lambda_2 $ the \\textbf{principal curvatures}.\n\n\\begin{lemma}\nLet $ S $ be a regular surface and $ \\lambda_1\\br{p} \\le \\lambda_2\\br{p} $ be the principal curvatures at $ p \\in S $. Then\n$$ \\lambda_1 = \\min\\cbr{\\A\\br{x, x} \\st x \\in \\T_p S, \\ \\abs{x} = 1}, \\qquad \\lambda_2 = \\max\\cbr{\\A\\br{x, x} \\st x \\in \\T_p S, \\ \\abs{x} = 1}. $$\n\\end{lemma}\n\n\\begin{proof}\nConsider $ x \\in \\T_p S $ with $ \\abs{x} = 1 $. Write $ x = c_1x_1 + c_2x_2 $ where $ c \\in \\RR $, then $ c_1^2 + c_2^2 = 1 $. Then\n\\begin{align*}\n\\A\\br{x, x}\n& = \\A\\br{c_1x_1 + c_2x_2, c_1x_1 + c_2x_2} \\\\\n& = c_1^2\\A\\br{x_1, x_1} + c_1c_2\\A\\br{x_1, x_2} + c_2c_1\\A\\br{x_2, x_1} + c_2^2\\A\\br{x_2, x_2} \\\\\n& = \\lambda_1c_1^2 + \\lambda_2c_2^2\n\\le \\lambda_2c_1^2 + \\lambda_2c_2^2\n= \\lambda_2,\n\\end{align*}\nwith equality if and only if $ c_1 = 0 $ and $ c_2 = 1 $. Similarly\n$$ \\A\\br{x, x} = \\lambda_1c_1^2 + \\lambda_2c_2^2 \\ge \\lambda_1c_1^2 + \\lambda_1c_2^2 = \\lambda_1, $$\nwith equality if and only if $ c_1 = 1 $ and $ c_2 = 0 $.\n\\end{proof}\n\n\\begin{example*}\nLet $ S $ be a sphere of radius $ r $. Then $ \\N\\br{p} = p / r $ and $ \\d\\N_p = \\id / r $, so principal curvatures are $ \\lambda_1 = \\lambda_2 = 1 / r $, which are independent of $ p $.\n\\end{example*}\n\n\\begin{example*}\nSuppose $ S $ is a connected regular surface and that $ \\lambda_1\\br{p} = \\lambda_2\\br{p} = 0 $ for all $ p \\in S $. Then $ \\d\\N_p = 0 $, so $ \\N\\br{p} $ is constant for all $ p \\in S $. Suppose $ \\N\\br{p} = \\vec{v} $ for all $ p \\in S $. Then $ S $ is in the plane perpendicular to $ \\vec{v} $ through $ p $. \\footnote{Exercise}\n\\end{example*}\n\n\\begin{definition}\nSuppose $ C \\subset S $ is a curve through $ p \\in S $. Suppose $ \\N $ is the unit normal vector to $ S $ at $ p $ and $ n $ is the unit normal vector to $ C $ at $ p $. The \\textbf{normal curvature} of $ C $ at $ p $ is\n$$ \\k_n\\br{p} = \\kappa\\cos \\theta, $$\nwhere $ \\theta $ is the angle between $ \\N $ and $ n $ and $ \\kappa $ is the curvature of $ C $ at $ p $, so $ \\k_n\\br{p} $ is the length of the projection of $ \\vec{\\kappa} $, the vector curvature of $ C $ at $ p $, along $ \\N $.\n\\end{definition}\n\n\\begin{proposition}\nLet $ S $ be a regular surface and $ C \\subset S $ be a curve with unit tangent vector $ v \\in \\T_p S $. Then\n$$ \\A\\br{v, v} = \\k_n\\br{p}. $$\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S $ be an arc-length parametrisation of $ C $ near $ p $. Then $ \\alpha\\br{0} = p $ and $ \\alpha'\\br{0} = v $. We have $ \\abr{\\alpha'\\br{t}, \\N\\br{\\alpha\\br{t}}} = 0 $ for all $ t $. Differentiating,\n$$ \\abr{\\alpha''\\br{t}, \\N\\br{\\alpha\\br{t}}} + \\abr{\\alpha'\\br{t}, \\d\\N_{\\alpha\\br{t}}\\br{\\alpha'\\br{t}}}, $$\nfor all $ t $. Setting $ t = 0 $,\n$$ \\abr{\\kappa n_p, \\N\\br{p}} + \\abr{v, \\d\\N_p\\br{v}} = 0. $$\nThus\n$$ \\A\\br{v, v} = -\\abr{v, \\d\\N_p\\br{v}} = \\abr{\\kappa n_p, \\N\\br{p}} = \\k_n\\br{p}. $$\n\\end{proof}\n\n\\pagebreak\n\n\\begin{definition}\nA point $ p \\in S $ is \\textbf{umbilical} if and only if the principal curvatures $ \\lambda_1\\br{p} $ and $ \\lambda_2\\br{p} $ are equal.\n\\end{definition}\n\n\\begin{proposition}\nIf $ S $ is a connected regular surface such that every point in $ S $ is umbilical then $ S $ is contained in a plane or a sphere.\n\\end{proposition}\n\n\\lecture{15}{Tuesday}{06/11/18}\n\n\\begin{proof}\nBy assumption, there exists a smooth function $ \\lambda : S \\to \\RR $ such that $ \\lambda_1\\br{p} = \\lambda_2\\br{p} = \\lambda\\br{p} $ for all $ p \\in S $.\n\\begin{enumerate}[leftmargin=0.5in, label=Step \\arabic*.]\n\\item Prove $ \\lambda\\br{p} $ is constant. Take a chart $ \\phi : U \\to S $ near $ p $. Then\n$$ \\dpd{}{u}\\br{\\N \\circ \\phi} = \\d\\N_{\\phi\\br{u, v}} \\cdot \\dpd{\\phi}{u} = -\\br{\\lambda \\circ \\phi}\\dpd{\\phi}{u}, \\qquad \\dpd{}{v}\\br{\\N \\circ \\phi} = \\d\\N_{\\phi\\br{u, v}} \\cdot \\dpd{\\phi}{v} = -\\br{\\lambda \\circ \\phi}\\dpd{\\phi}{v}, $$\nsince $ \\d\\N_{\\phi\\br{u, v}} $ is some multiple of $ \\id $. Now\n$$ \\dmd{}{2}{u}{}{v}{}\\br{\\N \\circ \\phi} = \\dmd{}{2}{v}{}{u}{}\\br{\\N \\circ \\phi}, $$\nso\n$$ -\\dpd{}{u}\\br{\\lambda \\circ \\phi}\\dpd{\\phi}{v} = -\\dpd{}{v}\\br{\\lambda \\circ \\phi}\\dpd{\\phi}{u}. $$\nThe vectors $ \\tod{\\phi}{v} $ and $ \\tod{\\phi}{u} $ are linearly independent, so\n$$ -\\dpd{}{u}\\br{\\lambda \\circ \\phi} = -\\dpd{}{v}\\br{\\lambda \\circ \\phi} = 0, $$\nso $ \\lambda \\circ \\phi $ is locally constant, that is $ \\lambda $ is constant on $ \\phi\\br{U} $. Then $ S $ is connected, and covered by such charts, so $ \\lambda $ is constant.\n\\item If $ \\lambda\\br{p} \\equiv 0 $ for all $ p \\in S $ then we already know that $ S $ is contained in a plane. Otherwise $ \\lambda\\br{p} \\equiv \\lambda_0 $ with $ \\lambda_0 \\ne 0 $. Without loss of generality $ \\lambda_0 > 0 $. Now\n$$ \\dpd{}{u}\\br{\\N \\circ \\phi} = -\\lambda_0\\dpd{\\phi}{u}, \\qquad \\dpd{}{v}\\br{\\N \\circ \\phi} = -\\lambda_0\\dpd{\\phi}{v}, $$\nso\n$$ \\dpd{}{u}\\br{\\dfrac{1}{\\lambda_0}\\br{\\N \\circ \\phi} + \\phi} = 0, \\qquad \\dpd{}{v}\\br{\\dfrac{1}{\\lambda_0}\\br{\\N \\circ \\phi} + \\phi} = 0, $$\nso there exists $ c_0 \\in \\RR^3 $ such that $ \\br{\\N \\circ \\phi} / \\lambda_0 + \\phi = c_0 $. Then $ \\br{\\N \\circ \\phi} / \\lambda_0 $ has length $ 1 / \\lambda_0 $ and $ c_0 $ is constant, so $ \\phi\\br{u, v} $ lies in the sphere centred at $ c_0 $ radius $ 1 / \\lambda_0 $.\n\\end{enumerate}\n\\end{proof}\n\n\\lecture{16}{Friday}{09/11/18}\n\nWhat if $ \\lambda_1\\br{p} \\ne \\lambda_2\\br{p} $?\n\n\\begin{definition}\nLet $ p \\in S $ be a point on a regular surface. Let $ \\lambda_1\\br{p} $ and $ \\lambda_2\\br{p} $ be the principal curvatures. Then\n$$ \\K\\br{p} = \\lambda_1\\br{p}\\lambda_2\\br{p} = \\det \\d\\N_p $$\nis the \\textbf{Gaussian curvature} at $ p $ and\n$$ \\H\\br{p} = \\dfrac{1}{2}\\br{\\lambda_1\\br{p} + \\lambda_2\\br{p}} = -\\dfrac{1}{2}\\Tr \\d\\N_p $$\nis the \\textbf{mean curvature} at $ p $.\n\\end{definition}\n\nReversing the orientation of $ S $, that is replacing $ \\N $ by $ -\\N $, sends $ \\H\\br{p} $ to $ -\\H\\br{p} $ and $ \\K\\br{p} $ to $ \\K\\br{p} $.\n\n\\begin{example*}\nIf $ S $ is a sphere of radius $ r $ then $ \\K = 1 / r^2 $ and $ \\H = 1 / r $. A plane has $ \\K = \\H = 0 $.\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{What does Gaussian curvature mean?}\n\nLet $ S $ be a regular surface, and let $ p \\in S $. Choose a chart $ \\phi : U \\to S $ on $ S $ near $ p $. Choose a curve through $ p $, $ \\gamma\\br{t} = \\phi\\br{ct, dt} $. Now $ \\gamma'\\br{t} \\cdot \\N\\br{\\gamma\\br{t}} = 0 $ for all $ t $. Differentiating,\n$$ \\gamma''\\br{t} \\cdot \\N\\br{\\gamma\\br{t}} + \\gamma'\\br{t} \\cdot \\d\\N_{\\gamma\\br{t}}\\br{\\gamma'\\br{t}} = 0, $$\nor in other words\n$$ \\A\\br{\\gamma'\\br{t}, \\gamma'\\br{t}} = \\gamma''\\br{t} \\cdot \\N\\br{\\gamma\\br{t}}. $$\nAt $ t = 0 $,\n$$ \\gamma'\\br{t} = c\\dpd{\\phi}{u} + d\\dpd{\\phi}{v}, \\qquad \\gamma''\\br{t} = c^2\\dpd[2]{\\phi}{u} + 2cd\\dmd{\\phi}{2}{u}{}{v}{} + d^2\\dpd[2]{\\phi}{v}. $$\nThus\n$$ \\A\\br{c\\dpd{\\phi}{u} + d\\dpd{\\phi}{v}, c\\dpd{\\phi}{u} + d\\dpd{\\phi}{v}} = \\br{c^2\\dpd[2]{\\phi}{u} + 2cd\\dmd{\\phi}{2}{u}{}{v}{} + d^2\\dpd[2]{\\phi}{v}} \\cdot \\N\\br{p}. $$\n\n\\begin{proposition}\nIf $ \\K\\br{p} > 0 $ then all points of $ S $ near $ p $ lie on the same side of $ \\T_p S $. If $ \\K\\br{p} < 0 $ then there are points of $ S $ near $ p $ on each side of $ \\T_p S $.\n\\end{proposition}\n\n\\begin{proof}\nConsider the Taylor series\n$$ \\phi\\br{u, v} = p + \\br{\\dpd{\\phi}{u}\\br{0, 0}u + \\dpd{\\phi}{v}\\br{0, 0}v} + \\dfrac{1}{2}\\br{\\dpd[2]{\\phi}{u}\\br{0, 0}u^2 + 2\\dmd{\\phi}{2}{u}{}{v}{}\\br{0, 0}uv + \\dpd[2]{\\phi}{v}\\br{0, 0}v^2} + R\\br{u, v}, $$\nwhere\n$$ \\lim_{\\br{u, v} \\to \\br{0, 0}} \\dfrac{R\\br{u, v}}{u^2 + v^2} = 0. $$\nConsider\n\\begin{align*}\n\\abr{\\phi\\br{u, v} - p, \\N\\br{p}}\n& = \\dfrac{1}{2}\\abr{\\dpd[2]{\\phi}{u}\\br{0, 0}u^2 + 2\\dmd{\\phi}{2}{u}{}{v}{}\\br{0, 0}uv + \\dpd[2]{\\phi}{v}\\br{0, 0}v^2, \\N\\br{p}} + \\abr{R\\br{u, v}, \\N\\br{p}} \\\\\n& = \\dfrac{1}{2}\\A\\br{w, w} + \\abr{R\\br{u, v}, \\N\\br{p}}, \\qquad w = \\dpd{\\phi}{u}\\br{0}u + \\dpd{\\phi}{v}\\br{0}v.\n\\end{align*}\n$ \\A\\br{w, w} $ is quadratic in $ \\br{u, v} $ and $ R\\br{u, v} $ is worse than quadratic in $ \\br{u, v} $. So for $ u $ and $ v $ small, when we are close to $ p $, the function $ \\abr{\\phi\\br{u, v} - p, \\N\\br{p}} $ has the same sign as $ \\A\\br{w, w} $. Write $ w = ax_1 + bx_2 $ where $ x_1 $ and $ x_2 $ are the principal directions then $ \\A\\br{w, w} = \\lambda_1a^2 + \\lambda_2b^2 $.\n\\begin{itemize}\n\\item $ \\lambda_1, \\lambda_2 > 0 $ gives $ \\A\\br{w, w} > 0 $.\n\\item $ \\lambda_1 > 0 $ and $ \\lambda_2 < 0 $ gives that $ \\A\\br{w, w} $ can be positive or negative.\n\\item $ \\lambda_1, \\lambda_2 < 0 $ gives $ \\A\\br{w, w} < 0 $.\n\\end{itemize}\n\\end{proof}\n\nIn fact we can do slightly better than this. Consider the chart map $ \\phi : U \\to S $. After a translation of $ S $, without loss of generality $ \\phi\\br{0, 0} = \\br{0, 0, 0} $, after a rigid motion to $ S \\subseteq \\RR^3 $, without loss of generality\n$$ \\dpd{\\phi}{u}\\br{0, 0} = \\br{1, 0, 0}, \\qquad \\dpd{\\phi}{v}\\br{0, 0} = \\br{0, 1, 0}. $$\nTaylor series implies that\n\\begin{align*}\n\\phi\\br{u, v}\n& = \\br{0, 0, 0} + \\br{\\dpd{\\phi}{u}\\br{0, 0}u + \\dpd{\\phi}{v}\\br{0, 0}v} + \\dfrac{1}{2}\\br{\\dpd[2]{\\phi}{u}\\br{0, 0}u^2 + 2\\dmd{\\phi}{2}{u}{}{v}{}\\br{0, 0}uv + \\dpd[2]{\\phi}{v}\\br{0, 0}v^2} + \\dots \\\\\n& = \\br{u, v, 0} + \\dfrac{1}{2}\\br{u^2\\dpd[2]{\\phi}{u}\\br{0, 0} + 2uv\\dmd{\\phi}{2}{u}{}{v}{}\\br{0, 0} + v^2\\dpd[2]{\\phi}{v}\\br{0, 0}} + \\dots.\n\\end{align*}\n\n\\pagebreak\n\nNear $ \\br{u, v} = \\br{0, 0} $ the quadratic term satisfies\n$$ \\br{u^2\\dpd[2]{\\phi}{u}\\br{0, 0} + 2uv\\dmd{\\phi}{2}{u}{}{v}{}\\br{0, 0} + v^2\\dpd[2]{\\phi}{v}\\br{0, 0}} \\cdot \\N\\br{0, 0, 0} = \\A\\br{\\br{u, v, 0}, \\br{u, v, 0}} = \\lambda_1u^2 + \\lambda_2v^2, $$\nbecause we chose $ \\br{1, 0, 0} $ and $ \\br{0, 1, 0} $ as our principal directions. So near $ \\br{u, v} = \\br{0, 0} $, the surface is approximated by the graph\n$$ \\phi\\br{u, v} \\approx \\br{u, v, \\dfrac{1}{2}\\br{\\lambda_1u^2 + \\lambda_2v^2}}. $$\n\n\\lecture{17}{Monday}{12/11/18}\n\nSay $ p \\in S $ is\n\\begin{itemize}\n\\item \\textbf{elliptic} if $ \\K\\br{p} > 0 $, so either $ \\lambda_1, \\lambda_2 > 0 $ or $ \\lambda_1, \\lambda_2 < 0 $,\n\\item \\textbf{hyperbolic} if $ \\K\\br{p} < 0 $, so either $ \\lambda_1 < 0 $ and $ \\lambda_2 > 0 $ or vice versa,\n\\item \\textbf{parabolic} if $ \\K\\br{p} = 0 $ and $ \\H\\br{p} \\ne 0 $, so $ \\lambda_1 = 0 $ and $ \\lambda_2 \\ne 0 $ or vice versa, and\n\\item \\textbf{planar} if $ \\K\\br{p} = \\H\\br{p} = 0 $, so $ \\lambda_1 = \\lambda_2 = 0 $.\n\\end{itemize}\n\n\\begin{example*}\nConsider the \\textbf{Monkey saddle} with equation $ z = x^3 - 3x^2y $, so\n$$ z = \\Re \\br{x + iy}^3 = \\Re r^3e^{i3\\theta} = r^3\\cos 3\\theta, $$\nusing polar coordinates $ x + iy = re^{i\\theta} $. At $ \\br{0, 0, 0} $, the principal curvatures are $ \\lambda_1 = \\lambda_2 = 0 $. So the previous theorem says, to second order near $ p = \\br{0, 0, 0} $, the surface $ S $ looks like the plane $ z = 0 $. True, but not so informative. This has an umbilical point with $ \\lambda_1 = \\lambda_2 = 0 $ at $ \\br{0, 0, 0} $, and hyperbolic points elsewhere.\n\\end{example*}\n\n\\subsection{How to compute Gaussian and mean curvature?}\n\nWe start with a simple observation.\n\n\\begin{lemma}\n\\label{lem:innerproduct}\nLet $ V $ be a two-dimensional vector space with inner product $ \\abr{\\cdot, \\cdot} $. Let $ e_1 $ and $ e_2 $ be an orthonormal basis for $ V $. Let $ x $ and $ y $ be elements of $ V $ and write $ x = x_1e_1 + x_2e_2 $ and $ y = y_1e_1 + y_2e_2 $. Then\n$$ \\abr{x, y} = \\onebytwo{x_1}{x_2}\\twobyone{y_1}{y_2}. $$\nThat is, we can compute inner products in $ V $ using the ordinary matrix multiplication between row vectors and column vectors, provided that we remember to use an orthonormal basis when writing elements of $ V $ as vectors.\n\\end{lemma}\n\n\\begin{proof}\nJust write everything out, so\n$$ \\abr{x, y} = \\abr{x_1e_1 + x_2e_2, y_1e_1 + y_2e_2} = x_1y_1\\abr{e_1, e_1} + x_1y_2\\abr{e_1, e_2} + x_2y_1\\abr{e_2, e_1} + x_2y_2\\abr{e_2, e_2} = x_1y_1 + x_2y_2, $$\nas required. The final equality here uses the fact that $ e_1 $ and $ e_2 $ are orthonormal.\n\\end{proof}\n\n\\begin{remark*}\nThere is nothing special about the fact that $ V $ is two-dimensional here. The obvious generalisation of Lemma \\ref{lem:innerproduct} holds for any finite-dimensional inner product space.\n\\end{remark*}\n\n\\begin{proposition}\n\\label{prop:computing}\nLet $ \\phi : U \\to S $ be a chart on a regular surface $ S $. Define $ 2 \\times 2 $ matrices\n$$ \\g = \\twobytwo{\\phi_u \\cdot \\phi_u}{\\phi_u \\cdot \\phi_v}{\\phi_v \\cdot \\phi_u}{\\phi_v \\cdot \\phi_v}, \\qquad \\A = \\twobytwo{\\A\\br{\\phi_u, \\phi_u}}{\\A\\br{\\phi_u, \\phi_v}}{\\A\\br{\\phi_v, \\phi_u}}{\\A\\br{\\phi_v, \\phi_v}}, \\qquad \\phi_u = \\dpd{\\phi}{u}, \\qquad \\phi_v = \\dpd{\\phi}{v}. $$\nThen, writing $ \\sigma = \\g^{-1}\\A $, we have\n$$ \\K = \\det \\sigma = \\dfrac{\\det \\A}{\\det \\g}, \\qquad \\H = \\dfrac{1}{2}\\Tr \\sigma. $$\n\\end{proposition}\n\n\\begin{remark*}\nIf $ \\phi_u $ and $ \\phi_v $ are the principal directions at $ p \\in S $ then this is immediate, because in that case $ \\g $ is the identity matrix and Proposition \\ref{prop:computing} just restates the definitions of $ \\K $ and $ \\H $.\n\\end{remark*}\n\n\\pagebreak\n\n\\begin{proof}\nLet $ p $ be a point on $ S $. Let us work in a basis for $ \\T_p S $ given by the principal directions $ x_1\\br{p} $ and $ x_2\\br{p} $. Then, because this is an orthonormal basis, we can apply Lemma \\ref{lem:innerproduct} to find,\n$$ \\A = \\twobyone{\\phi_u}{\\phi_v}\\onebytwo{-\\d\\N_p\\br{\\phi_u}}{-\\d\\N_p\\br{\\phi_v}}. $$\nHere $ \\br{\\phi_u} $ is a row vector of size two and $ \\br{-\\d\\N_p\\br{\\phi_u}} $ is a column vector of size two. Now write the matrix of $ \\d\\N_p : \\T_p S \\to \\T_p S $ with respect to the basis $ x_1\\br{p} $ and $ x_2\\br{p} $ too,\n$$ \\A = \\twobyone{\\phi_u}{\\phi_v}M\\onebytwo{\\phi_u}{\\phi_v}, $$\nwhere $ M $, the matrix of $ \\d\\N_p $ with respect to the basis $ x_1\\br{p} $ and $ x_2\\br{p} $, is a $ 2 \\times 2 $ matrix. Then\n$$ \\det \\A = \\det \\twobyone{\\phi_u}{\\phi_v}\\det M\\det \\onebytwo{\\phi_u}{\\phi_v} = \\det M\\det \\twobyone{\\phi_u}{\\phi_v}\\onebytwo{\\phi_u}{\\phi_v} = \\det M\\det \\g, $$\nwhere for the last equality we used Lemma \\ref{lem:innerproduct} again. Since $ \\det M = \\K $, by definition, this proves that $ \\K = \\det \\A / \\det \\g $. Furthermore,\n$$ \\A = \\twobyone{\\phi_u}{\\phi_v}\\onebytwo{\\phi_u}{\\phi_v}\\onebytwo{\\phi_u}{\\phi_v}^{-1}M\\onebytwo{\\phi_u}{\\phi_v} = \\g B, $$\nwhere $ B = \\onebytwo{\\phi_u}{\\phi_v}^{-1}M\\onebytwo{\\phi_u}{\\phi_v} $ is conjugate to $ M $. Thus $ \\sigma = \\g^{-1}\\A $ is conjugate to $ M $, and so $ \\H = \\Tr M = \\Tr \\sigma $ because conjugate matrices have the same trace.\n\\end{proof}\n\n\\lecture{18}{Tuesday}{13/11/18}\n\n\\begin{example*}\nLet $ S $ be the surface in $ \\RR^3 $ defined by the equation $ z = x^2 - y^2 $. Choose the chart\n$$ \\function[\\phi]{U = \\RR^2}{S}{\\br{u, v}}{\\br{u, v, u^2 - v^2}}. $$\nNow $ \\phi_u = \\br{1, 0, 2u} $ and $ \\phi_v = \\br{0, 1, -2v} $, so\n$$ \\g = \\twobytwo{\\phi_u \\cdot \\phi_u}{\\phi_u \\cdot \\phi_v}{\\phi_v \\cdot \\phi_u}{\\phi_v \\cdot \\phi_v} = \\twobytwo{1 + 4u^2}{-4uv}{-4uv}{1 + 4v^2}. $$\nAlso,\n$$ \\phi_u \\times \\phi_v = \\abs{\\threebythree{i}{j}{k}{1}{0}{2u}{0}{1}{-2v}} = \\br{-2u, 2v, 1}, $$\nand so\n$$ \\N = \\dfrac{\\phi_u \\times \\phi_v}{\\abs{\\phi_u \\times \\phi_v}} = \\br{\\tfrac{-2u}{\\sqrt{1 + 4u^2 + 4v^2}}, \\tfrac{2v}{\\sqrt{1 + 4u^2 + 4v^2}}, \\tfrac{1}{\\sqrt{1 + 4u^2 + 4v^2}}}. $$\nNow $ \\phi_{uu} = \\br{1, 0, 2}, \\phi_{uv} = \\br{0, 0, 0}, \\phi_{vv} = \\br{1, 0, -2} $, so\n$$ \\A = \\twobytwo{\\N \\cdot \\phi_{uu}}{\\N \\cdot \\phi_{uv}}{\\N \\cdot \\phi_{vu}}{\\N \\cdot \\phi_{vv}} = \\twobytwo{\\tfrac{2}{\\sqrt{1 + 4u^2 + 4v^2}}}{0}{0}{\\tfrac{-2}{\\sqrt{1 + 4u^2 + 4v^2}}} = \\dfrac{1}{\\sqrt{1 + 4u^2 + 4v^2}}\\twobytwo{2}{0}{0}{-2}. $$\nThen\n$$ \\sigma = \\g^{-1}\\A = \\dfrac{1}{1 + 4u^2 + 4v^2}\\twobytwo{1 + 4v^2}{4uv}{4uv}{1 + 4u^2} \\cdot \\A = \\dfrac{2}{\\sqrt{1 + 4u + 4v^2}^3}\\twobytwo{1 + 4v^2}{-4uv}{4uv}{-1 - 4u^2}. $$\nSo\n$$ \\K = \\det \\sigma = 4\\br{\\dfrac{-\\br{1 + 4u^2}\\br{1 + 4v^2} + 16u^2v^2}{\\br{1 + 4u^2 + 4v^2}^3}} = \\dfrac{-4}{\\br{1 + 4u^2 + 4v^2}^2}, $$\nand\n$$ \\H = \\dfrac{1}{2}\\Tr \\sigma = \\dfrac{4v^2 - 4u^2}{\\sqrt{1 + 4u^2 + 4v^2}^3}. $$\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{The first fundamental form}\n\n\\begin{definition}\nLet $ S \\subset \\RR^3 $ be a regular surface, and let $ p \\in S $. The \\textbf{first fundamental form} at $ p $, also called the \\textbf{metric} at $ p $, is the bilinear map\n$$ \\function[\\g]{\\T_p S \\times \\T_p S}{\\RR}{\\br{v, w}}{\\abr{v, w}}. $$\n\\end{definition}\n\nThen $ \\g $ is symmetric, bilinear, and non-degenerate. If $ \\phi : U \\to S $ is a chart near $ p \\in S $, then $ \\phi_u $ and $ \\phi_v $ are a basis for $ \\T_p S $ and in this basis, $ \\g $ has the form\n\\begin{align*}\n\\g\\br{a\\phi_u + b\\phi_v, c\\phi_u + d\\phi_v}\n& = ac\\g\\br{\\phi_u, \\phi_v} + ad\\g\\br{\\phi_u, \\phi_v} + bc\\g\\br{\\phi_u, \\phi_v} + bd\\g\\br{\\phi_u, \\phi_v} \\\\\n& = \\onebytwo{a}{b}\\twobytwo{\\g\\br{\\phi_u, \\phi_u}}{\\g\\br{\\phi_u, \\phi_v}}{\\g\\br{\\phi_v, \\phi_u}}{\\g\\br{\\phi_v, \\phi_v}}\\twobyone{c}{d}\n= \\onebytwo{a}{b}\\g\\twobyone{c}{d},\n\\end{align*}\nthat is the metric is represented by the symmetric matrix that we called $ \\g $ before. Metric determines arc-length. If $ \\alpha : \\sbr{a, b} \\to S $ is a curve contained in $ \\phi\\br{U} $, so that $ \\alpha\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $ for some smooth functions $ u, v : \\sbr{a, b} \\to \\RR $, then\n$$ \\L\\br{\\alpha} = \\intd{a}{b}{\\abs{\\alpha'\\br{t}}}{t} = \\intd{a}{b}{\\abs{\\tpd{\\phi}{u}\\tod{u}{t} + \\tpd{\\phi}{v}\\tod{v}{t}}}{t} = \\intd{a}{b}{\\sqrt{\\onebytwo{\\tod{u}{t}}{\\tod{v}{t}} \\cdot \\g \\cdot \\twobyone{\\tod{u}{t}}{\\tod{v}{t}}}}{t}. $$\n\n\\begin{definition}\nA smooth map $ F : S_1 \\to S_2 $ is called a \\textbf{local isometry} if it preserves the first fundamental form, so\n$$ \\abr{\\d F_p\\br{x}, \\d F_p\\br{y}} = \\abr{x, y}, \\qquad x, y \\in \\T_p S_1, \\qquad p \\in S_1. $$\n$ F $ is an \\textbf{isometry} if it is also bijective.\n\\end{definition}\n\n\\begin{proposition}\nLocal isometries are local diffeomorphisms.\n\\end{proposition}\n\n\\lecture{19}{Friday}{16/11/18}\n\n\\begin{proof}\nIf $ F $ is a local isometry then, for each $ p \\in S $, $ \\d F_p $ is injective. Suppose not. Then there exists $ 0 \\ne v \\in \\T_p S $ such that $ \\d F_p\\br{v} = 0 $, so $ \\abr{\\d F_p\\br{v}, \\d F_p\\br{w}} = 0 $ for all $ w \\in \\T_p S $, so $ \\abr{v, w} = 0 $ for all $ w \\in \\T_p S $, so $ v = 0 $, a contradiction. Now $ \\d F_p : \\T_p S_1 \\to \\T_{F\\br{p}} S_2 $ is linear and injective, and $ \\dim \\T_p S_1 = \\dim \\T_p S_2 = 2 $, so $ \\d F_p $ is an isomorphism. From before, since $ \\d F_p $ is an isomorphism, $ F $ is a local diffeomorphism, that is, there is an open neighbourhood $ U $ of $ p $ in $ S_1 $ such that $ \\eval{F}_U : U \\to F\\br{U} $ is a diffeomorphism.\n\\end{proof}\n\n\\begin{proposition}\nA smooth map $ F : S_1 \\to S_2 $ between regular surfaces is a local isometry if and only if it preserves lengths of curves, that is if and only if for all $ \\alpha : \\sbr{a, b} \\to S_1 $ smooth we have\n$$ \\L\\br{\\alpha} = \\L\\br{F \\circ \\alpha}. $$\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Suppose that $ F $ is a local isometry. Then\n\\begin{align*}\n\\L\\br{F \\circ \\alpha}\n& = \\intd{a}{b}{\\abs{\\br{F \\circ \\alpha}'\\br{t}}}{t}\n= \\intd{a}{b}{\\sqrt{\\abr{\\br{F \\circ \\alpha}'\\br{t}, \\br{F \\circ \\alpha}'\\br{t}}}}{t} \\\\\n& = \\intd{a}{b}{\\sqrt{\\abr{\\d F_{\\alpha\\br{t}}\\br{\\alpha'\\br{t}}, \\d F_{\\alpha\\br{t}}\\br{\\alpha'\\br{t}}}}}{t}\n= \\intd{a}{b}{\\sqrt{\\abr{\\alpha'\\br{t}, \\alpha'\\br{t}}}}{t} \\\\\n& = \\intd{a}{b}{\\abs{\\alpha'\\br{t}}}{t}\n= \\L\\br{\\alpha},\n\\end{align*}\nby definition of $ \\d F_{\\alpha\\br{t}} $ and as $ F $ is a local isometry.\n\\item[$ \\impliedby $] Given $ v \\in \\T_p S_1 $ and a curve $ \\alpha : \\br{-\\epsilon, \\epsilon} \\to S_1 $ with $ \\alpha\\br{0} = p $ and $ \\alpha'\\br{0} = v $. Consider the curve $ \\eval{\\alpha}_{\\sbr{-\\delta, t}} : \\sbr{-\\delta, t} \\to S_1 $, so\n$$\n\\begin{tikzcd}\n& p \\in S_1 \\arrow{r}{F} & S_2 \\\\\n\\br{-\\epsilon, \\epsilon} \\arrow{ur}{\\alpha} & \\sbr{-\\delta, t} \\arrow[subset]{l} \\arrow{u}{\\eval{\\alpha}_{\\sbr{-\\delta, t}}} \\arrow{ur} &\n\\end{tikzcd}.\n$$\n\n\\pagebreak\n\nKnow $ \\L\\br{\\eval{\\alpha}_{\\sbr{-\\delta, t}}} = \\L\\br{\\eval{\\br{F \\circ \\alpha}}_{\\sbr{-\\delta, t}}} $, that is\n$$ \\intd{-\\delta}{t}{\\abs{\\alpha'\\br{s}}}{s} = \\intd{-\\delta}{t}{\\abs{\\d F_{\\alpha\\br{s}}\\br{\\alpha'\\br{s}}}}{s}. $$\nTaking $ \\tod{}{t} $ and setting $ t = 0 $, $ \\abs{\\alpha'\\br{0}} = \\abs{\\d F_p\\br{\\alpha'\\br{0}}} $, that is\n$$ \\abr{v, v} = \\abr{\\d F_p\\br{v}, \\d F_p\\br{v}}, \\qquad v \\in \\T_p S_1, \\qquad p \\in S_1. $$\nNow,\n$$ \\abr{X + Y, X + Y} = \\abr{X, X} + \\abr{X, Y} + \\abr{Y, X} + \\abr{Y, Y} = \\abr{X, X} + 2\\abr{X, Y} + \\abr{Y, Y}, $$\nso\n$$ \\abr{X, Y} = \\dfrac{1}{2}\\br{\\abr{X + Y, X + Y} - \\abr{X, X} - \\abr{Y, Y}}. $$\nSet $ X = \\d F_p\\br{v} $ and $ Y = \\d F_p\\br{w} $, so\n\\begin{align*}\n\\abr{\\d F_p\\br{v}, \\d F_p\\br{w}}\n& = \\dfrac{1}{2}\\br{\\abr{\\d F_p\\br{v + w}, \\d F_p\\br{v + w}} - \\abr{\\d F_p\\br{v}, \\d F_p\\br{v}} - \\abr{\\d F_p\\br{w}, \\d F_p\\br{w}}} \\\\\n& = \\dfrac{1}{2}\\br{\\abr{v + w, v + w} - \\abr{v, v} - \\abr{w, w}}\n= \\abr{v, w}.\n\\end{align*}\nTherefore $ F $ is a local isometry.\n\\end{itemize}\n\\end{proof}\n\n\\begin{example*}\nLet $ S \\subset \\RR^3 $ be any regular surface. Let $ B \\in \\SO\\br{3} $, $ 3 \\times 3 $ matrices $ B $ such that $ B^\\intercal B = \\id $ and $ \\det B = 1 $. Set\n$$ S' = \\cbr{B\\vec{x} \\st \\vec{x} \\in S}. $$\nThen\n$$ \\function[B]{S}{S'}{\\vec{x}}{B\\vec{x}} $$\nis bijective. Let $ p \\in S $ and $ v, w \\in \\T_p S $ be arbitrary. Then $ \\d F_p\\br{v} = Bv $ and\n$$ \\abr{\\d F_p\\br{v}, \\d F_p\\br{w}} = \\abr{Bv, Bw} = \\br{Bv}^\\intercal Bw = v^\\intercal B^\\intercal Bw = v^\\intercal w = \\abr{v, w}, $$\nso $ B $ is a local isometry and an isometry.\n\\end{example*}\n\n\\begin{example*}\nLet\n$$ S_1 = \\cbr{\\br{x, y, 0} \\in \\RR^3 \\st x \\in \\RR, \\ y \\in \\RR}, \\qquad S_2 = \\cbr{\\br{x, y, z} \\in \\RR^3 \\st x^2 + y^2 = 1}. $$\nDefine\n$$ \\function[F]{S_1}{S_2}{\\br{u, v, 0}}{\\br{\\cos u, \\sin u, v}}. $$\nAt $ p = \\br{u, v, 0} \\in S_1 $ a tangent vector $ \\vec{v} = \\br{a, b, 0} $ can be written as $ \\alpha'\\br{0} $ where $ \\alpha\\br{t} = \\br{u + at, v + bt, 0} $. Now\n$$ \\br{F \\circ \\alpha}\\br{t} = \\br{\\cos \\br{u + at}, \\sin \\br{u + at}, v + bt}, $$\nso $ \\br{F \\circ \\alpha}'\\br{0} = \\br{-a\\sin u, a\\cos u, b} $. Then\n$$ \\abr{\\d F_p\\br{\\vec{v}}, \\d F_p\\br{\\vec{v}}} = \\abr{\\br{-a\\sin u, a\\cos u, b}, \\br{-a\\sin u, a\\cos u, b}} = a^2 + b^2 = \\abr{\\vec{v}, \\vec{v}}, \\qquad \\vec{v} \\in \\T_p S_1, $$\nand so, as before,\n$$ \\abr{\\vec{v}, \\vec{w}} = \\abr{\\d F_p\\br{\\vec{v}}, \\d F_p\\br{\\vec{w}}}, \\qquad \\vec{v}, \\vec{w} \\in \\T_p S_1. $$\nThus $ F $ is a local isometry. It is not an isometry because it is not bijective.\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{Christoffel symbols}\n\n\\lecture{20}{Monday}{19/11/18}\n\nNow, $ \\tod{\\phi}{x_1} $ and $ \\tod{\\phi}{x_2} $ span $ \\T_p S $ and $ \\N\\br{p} $ is orthogonal to $ \\T_p S $ so $ \\tod{\\phi}{x_1} $, $ \\tod{\\phi}{x_2} $, and $ \\N $ form a basis for $ \\RR^3 $. Write\n\\begin{equation}\n\\label{eq:2}\n\\dmd{\\phi}{2}{x_i}{}{x_j}{} = \\Gamma_{ij}^1\\dpd{\\phi}{x_1} + \\Gamma_{ij}^2\\dpd{\\phi}{x_2} + \\A_{ij}\\N,\n\\end{equation}\nfor some coefficients $ \\Gamma_{ij}^k $ and $ \\A_{ij} $. Then\n$$ \\dmd{\\phi}{2}{x_i}{}{x_j}{} = \\dmd{\\phi}{2}{x_j}{}{x_i}{}, $$\nso $ \\Gamma_{ij}^k = \\Gamma_{ji}^k $ for all $ i, j, k $.\n\n\\begin{definition}\nThe $ \\Gamma_{ij}^k $ are called \\textbf{Christoffel symbols}.\n\\end{definition}\n\nTaking $ \\br{\\ref{eq:2}} \\cdot \\N $, we get\n$$ \\dmd{\\phi}{2}{x_i}{}{x_j}{} \\cdot \\N = \\A_{ij}. $$\n\n\\begin{note*}\n$ \\nabla_ie_j = \\Gamma_{ij}^ke_k $, where $ \\nabla_i $ is the metric connection in the local frame $ e_j $.\n\\end{note*}\n\n\\begin{proposition}\nThe Christoffel symbols are determined only by the first fundamental form, or metric.\n\\end{proposition}\n\n\\begin{proof}\nFrom $ \\br{\\ref{eq:2}} \\cdot \\tod{\\phi}{x_k} $,\n$$ \\dmd{\\phi}{2}{x_i}{}{x_j}{} \\cdot \\dpd{\\phi}{x_k} = \\Gamma_{ij}^1\\g_{1k} + \\Gamma_{ij}^2\\g_{2k}, \\qquad \\g = \\twobytwo{\\g_{11}}{\\g_{12}}{\\g_{21}}{\\g_{22}}. $$\nAlso,\n$$ \\dpd{}{x_i}\\br{\\dpd{\\phi}{x_j} \\cdot \\dpd{\\phi}{x_k}} = \\dmd{\\phi}{2}{x_i}{}{x_j}{} \\cdot \\dpd{\\phi}{x_k} + \\dpd{\\phi}{x_j} \\cdot \\dmd{\\phi}{2}{x_i}{}{x_k}{}. $$\nTaking $ j = k $,\n$$ \\dpd{}{x_i}\\br{\\g_{jj}} = 2\\br{\\Gamma_{ij}^1\\g_{1j} + \\Gamma_{ij}^2\\g_{2j}}. $$\nIf $ j \\ne k $, then either $ i = j $ or $ i = k $. Taking $ i = j \\ne k $,\n$$ \\dpd{}{x_i}\\br{\\g_{ik}} = \\dmd{\\phi}{2}{x_i}{}{x_i}{} \\cdot \\dpd{\\phi}{x_k} + \\dpd{\\phi}{x_i} \\cdot \\dmd{\\phi}{2}{x_i}{}{x_k}{} = \\dmd{\\phi}{2}{x_i}{}{x_i}{} \\cdot \\dpd{\\phi}{x_k} + \\dfrac{1}{2}\\dpd{}{x_k}\\br{\\g_{ii}}. $$\nRewriting,\n$$ \\Gamma_{ij}^1\\g_{1k} + \\Gamma_{ij}^2\\g_{2k} = \\dmd{\\phi}{2}{x_i}{}{x_i}{} \\cdot \\dpd{\\phi}{x_k} = \\dpd{}{x_i}\\br{\\g_{ik}} - \\dfrac{1}{2}\\dpd{}{x_k}\\br{\\g_{ii}}. $$\nWe have lots of equations involving $ \\Gamma_{ij}^k $, $ \\g_{ij} $, and derivatives of $ \\g_{ij} $. In fact we can solve these for $ \\Gamma_{ij}^k $. Then $ i = j = 1 $ and $ k = 1, 2 $ gives\n$$ \\Gamma_{11}^1\\g_{11} + \\Gamma_{11}^2\\g_{21} = \\dfrac{1}{2}\\dpd{\\g_{11}}{x_1}, \\qquad \\Gamma_{11}^1\\g_{12} + \\Gamma_{11}^2\\g_{22} = \\dpd{\\g_{12}}{x_1} - \\dfrac{1}{2}\\dpd{\\g_{11}}{x_2}. $$\nThat is,\n$$ \\g\\twobyone{\\Gamma_{11}^1}{\\Gamma_{11}^2} = \\twobyone{\\tfrac{1}{2}\\tpd{\\g_{11}}{x_1}}{\\tpd{\\g_{12}}{x_1} - \\tfrac{1}{2}\\tpd{\\g_{11}}{x_2}}. $$\nThen $ \\g $ is invertible, because $ \\tod{\\phi}{x_1} $ and $ \\tod{\\phi}{x_2} $ are linearly independent. Similarly,\n$$ \\g\\twobyone{\\Gamma_{21}^1}{\\Gamma_{21}^2} = \\twobyone{\\tfrac{1}{2}\\tpd{\\g_{11}}{x_2}}{\\tfrac{1}{2}\\tpd{\\g_{22}}{x_1}}, \\qquad \\g\\twobyone{\\Gamma_{22}^1}{\\Gamma_{22}^2} = \\twobyone{\\tpd{\\g_{21}}{x_2} - \\tfrac{1}{2}\\tpd{\\g_{22}}{x_1}}{\\tfrac{1}{2}\\tpd{\\g_{22}}{x_2}}. $$\nThus can solve these equations to write all $ \\Gamma_{ij}^k $ in terms of $ \\g_{ij} $'s and $ \\tpd{\\g_{jk}}{x_i} $'s.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Theorema Egregium}\n\n\\lecture{21}{Tuesday}{20/11/18}\n\nRecall that $ \\K = \\det \\A_{ij} / \\det \\g_{ij} $. The goal is that $ \\K $ depends only on $ \\g $.\n\n\\begin{notation*}\nSet $ x_1 = u $ and $ x_2 = v $. Write $ \\phi_u = \\tod{\\phi}{x_1} = \\tod{\\phi}{u} $, without confusion with indices.\n\\end{notation*}\n\nMixed partial derivatives are equal, so\n$$ \\dpd{}{x_2}\\br{\\dmd{\\phi}{2}{x_1}{}{x_1}{}} = \\dpd{}{x_1}\\br{\\dmd{\\phi}{2}{x_1}{}{x_2}{}}, $$\nso\n$$ \\dpd{}{x_2}\\br{\\Gamma_{11}^1\\dpd{\\phi}{x_1} + \\Gamma_{11}^2\\dpd{\\phi}{x_2} + \\A_{11}\\N} = \\dpd{}{x_1}\\br{\\Gamma_{12}^1\\dpd{\\phi}{x_1} + \\Gamma_{12}^2\\dpd{\\phi}{x_2} + \\A_{12}\\N}. $$\nThus\n\\begin{equation}\n\\label{eq:3}\n\\Gamma_{11}^1\\phi_{uv} + \\Gamma_{11v}^1\\phi_u + \\Gamma_{11}^2\\phi_{vv} + \\Gamma_{11v}^2\\phi_v + \\A_{11v}\\N + \\A_{11}\\N_v = \\Gamma_{12}^1\\phi_{uu} + \\Gamma_{12u}^1\\phi_u + \\Gamma_{12}^2\\phi_{vu} + \\Gamma_{12u}^2\\phi_v + \\A_{12u}\\N + \\A_{12}\\N_u.\n\\end{equation}\nWill take the $ \\phi_u $-component of $ \\br{\\ref{eq:3}} $, and use\n$$ \\phi_{uv} = \\Gamma_{12}^1\\phi_u + \\Gamma_{12}^2\\phi_v + \\A_{12}\\N, \\qquad \\phi_{vv} = \\Gamma_{22}^1\\phi_u + \\Gamma_{22}^2\\phi_v + \\A_{22}\\N, \\qquad \\Gamma_{uu} = \\Gamma_{11}^1\\phi_u + \\Gamma_{11}^2\\phi_v + \\A_{11}\\N, $$\n$$ \\A_{11} = -\\dpd{\\phi}{u} \\cdot \\N_u, \\qquad \\A_{21} = -\\dpd{\\phi}{v} \\cdot \\N_u, \\qquad \\A_{12} = -\\dpd{\\phi}{u} \\cdot \\N_v, \\qquad \\A_{22} = -\\dpd{\\phi}{v} \\cdot \\N_v. $$\nNow\n$$ \\N_u = a\\phi_u + b\\phi_v, \\qquad \\N_v = c\\phi_u + d\\phi_v, $$\nsince $ \\N \\cdot \\N = 1 $, so $ \\N_u \\cdot \\N + \\N \\cdot \\N_u = 0 $ and $ \\N_v \\cdot \\N + \\N \\cdot \\N_v = 0 $, so $ \\N_u, \\N_v \\in \\T_p S $. Then\n$$ -\\A_{11} = a\\g_{11} + b\\g_{12}, \\qquad -\\A_{21} = a\\g_{21} + b\\g_{22}, \\qquad -\\A_{12} = c\\g_{11} + d\\g_{12}, \\qquad -\\A_{22} = c\\g_{21} + d\\g_{22}, $$\nso\n$$ -\\A = \\g\\twobytwo{a}{c}{b}{d}, $$\nso\n$$ \\twobytwo{a}{c}{b}{d} = -\\g^{-1}\\A = \\dfrac{-1}{\\g_{11}\\g_{12} - \\g_{12}^2}\\twobytwo{\\g_{22}}{-\\g_{12}}{-\\g_{21}}{\\g_{11}}\\twobytwo{\\A_{11}}{\\A_{12}}{\\A_{21}}{\\A_{22}}, $$\nso\n$$ a = \\dfrac{\\g_{12}\\A_{21} - \\g_{22}\\A_{11}}{\\g_{11}\\g_{22} - \\g_{12}^2}, \\qquad c = \\dfrac{\\g_{12}\\A_{22} - \\g_{22}\\A_{12}}{\\g_{11}\\g_{22} - \\g_{12}^2}. $$\nNow, take $ \\br{\\ref{eq:3}} $, dot with $ \\phi_u $, and use these equations above. We find,\n$$ \\Gamma_{11}^1\\Gamma_{12}^1 + \\Gamma_{11v}^1 + \\Gamma_{11}^2\\Gamma_{22}^1 + \\A_{11}\\br{\\dfrac{\\g_{12}\\A_{22} - \\g_{22}\\A_{12}}{\\det \\g}} = \\Gamma_{12}^1\\Gamma_{11}^1 + \\Gamma_{12u}^1 + \\Gamma_{12}^2\\Gamma_{12}^1 + \\A_{12}\\br{\\dfrac{\\g_{12}\\A_{21} - \\g_{22}\\A_{11}}{\\det \\g}}. $$\nRearranging,\n$$ \\Gamma_{11v}^1 - \\Gamma_{12u}^1 = \\Gamma_{12}^2\\Gamma_{12}^1 - \\Gamma_{11}^2\\Gamma_{22}^1 + \\dfrac{\\br{\\A_{12}\\A_{21} - \\A_{11}\\A_{22}}\\g_{12}}{\\det \\g}. $$\nIn other words,\n$$ \\K \\g_{12} = \\Gamma_{12}^2\\Gamma_{12}^1 - \\Gamma_{11}^2\\Gamma_{22}^1 + \\Gamma_{12u}^1 - \\Gamma_{11v}^1. $$\nSimilarly, taking the $ \\phi_v $ component of $ \\br{\\ref{eq:3}} $\n$$ \\K \\g_{11} = \\Gamma_{11}^1\\Gamma_{21}^2 + \\Gamma_{11}^2\\Gamma_{22}^2 - \\Gamma_{12}^1\\Gamma_{11}^2 - \\Gamma_{12}^2\\Gamma_{12}^2 + \\Gamma_{11v}^2 - \\Gamma_{12u}^2. $$\nThese are the \\textbf{Gauss equations}.\n\n\\begin{note*}\n$ \\K \\g_{12} $ and $ \\K \\g_{11} $ depend only on $ \\g $. But $ \\g $ is invertible, so $ \\g_{11} $ and $ \\g_{12} $ cannot simultaneously vanish.\n\\end{note*}\n\nWe have proved the following.\n\n\\begin{theorem}[Theorema Egregium, Gauss]\nThe Gaussian curvature $ \\K $ depends only on the first fundamental form.\n\\end{theorem}\n\nIn other words, it is an intrinsic invariant of the surface $ \\br{S, \\g} $, as a Riemannian manifold.\n\n\\pagebreak\n\n\\begin{corollary}\nIf $ f : S_1 \\to S_2 $ is a local isometry then $ \\K_{S_1}\\br{p} = \\K_{S_2}\\br{f\\br{p}} $ for all $ p \\in S_1 $.\n\\end{corollary}\n\n\\begin{corollary}\nThere is no local isometry from a plane to a sphere.\n\\end{corollary}\n\n\\begin{proof}\nA plane has $ \\K = 0 $ everywhere and a sphere has $ \\K = 1 / r^2 $ everywhere, where $ r $ is the radius.\n\\end{proof}\n\nIn particular, there is no way to draw a map of the Earth on a flat sheet of paper without distorting lengths or angles. This is also why it is hard to gift-wrap a ball.\n\n\\lecture{22}{Friday}{23/11/18}\n\n\\begin{theorem}\nLet $ S $ be a compact surface with $ \\K > 0 $, such that $ \\K $ is constant, then $ S $ is umbilical.\n\\end{theorem}\n\n\\begin{proof}\nLet $ x \\in S $, and $ \\lambda_1\\br{x} \\le \\lambda_2\\br{x} $ be principal curvatures at $ x $. The aim is that $ \\lambda_1\\br{x} = \\lambda_2\\br{x} $. The idea of the proof is to assume $ \\lambda_1 < \\lambda_2 $ for a contradiction. Let $ p \\in S $ be a point maximising $ \\lambda_2\\br{x} $, so minimises $ \\lambda_1\\br{x} $ and\n$$ \\lambda_1\\br{p} \\le \\lambda_1\\br{x} \\le \\lambda_2\\br{x} \\le \\lambda_2\\br{p}. $$\nThe aim is if $ \\lambda_1\\br{p} = \\lambda_2\\br{p} $, then $ \\lambda_1\\br{x} = \\lambda\\br{x} $, for all $ x \\in S $. Assume $ \\lambda_1\\br{p} < \\lambda_2\\br{p} $, and want to get a contradiction. After a rigid motion, around $ p = \\br{0, 0, 0} $,\n$$ \\phi\\br{u, v} = \\br{u, v, F\\br{u, v}} + \\dots = \\dfrac{1}{2}\\br{\\lambda_1u^2 + \\lambda_2v^2} + \\dots, $$\nby Taylor expansion. At $ \\br{0, 0} $, $ F\\br{0, 0} = F_u\\br{0, 0} = F_v\\br{0, 0} = 0 $, so\n$$ \\dpd{\\phi}{u}\\br{0, 0} = \\br{1, 0, F_u\\br{0, 0}} = \\br{1, 0, 0}, \\qquad \\dpd{\\phi}{u}\\br{0, 0} = \\br{0, 1, F_v\\br{0, 0}} = \\br{0, 1, 0}, $$\nso\n$$ \\N = \\dfrac{\\phi_u \\times \\phi_v}{\\abs{\\phi_u \\times \\phi_v}} = \\dfrac{\\br{-F_u, -F_v, 1}}{\\sqrt{1 + \\abs{\\nabla F}^2}} = \\br{0, 0, 1}, $$\nat $ \\br{0, 0} $. Then\n$$ \\A = \\twobytwo{F_{uu}}{F_{uv}}{F_{vu}}{F_{vv}} = \\twobytwo{\\lambda_1}{0}{0}{\\lambda_2}, \\qquad \\g = \\twobytwo{\\phi_u \\cdot \\phi_u}{\\phi_u \\cdot \\phi_v}{\\phi_v \\cdot \\phi_u}{\\phi_v \\cdot \\phi_v} = \\twobytwo{1}{0}{0}{1}. $$\nThus $ \\K = \\det \\A / \\det \\g = \\lambda_1\\lambda_2 $. Let\n$$ E_1 = \\dfrac{\\br{1, 0, F_u}}{\\sqrt{1 + F_u^2}}, \\qquad E_2 = \\dfrac{\\br{0, 1, F_v}}{\\sqrt{1 + F_v^2}}, $$\nand let\n$$ h_1\\br{t} = \\A\\br{E_1\\br{0, t}, E_1\\br{0, t}}, \\qquad h_2\\br{t} = \\A\\br{E_2\\br{t, 0}, E_2\\br{t, 0}}. $$\nCheck \\footnote{Exercise}\n$$ h_1\\br{t} = \\eval{\\dfrac{1}{1 + F_u^2} \\cdot \\dfrac{F_{uu}}{\\sqrt{1 + \\abs{\\nabla F}^2}}}_{\\br{0, t}}, \\qquad h_2\\br{t} = \\eval{\\dfrac{1}{1 + F_v^2} \\cdot \\dfrac{F_{vv}}{\\sqrt{1 + \\abs{\\nabla F}^2}}}_{\\br{t, 0}}. $$\nRecall that\n$$ \\lambda_1\\br{p} \\le \\lambda_1\\br{\\phi\\br{0, t}} = \\min\\cbr{\\A\\br{v, v} \\st v \\in \\T_{\\phi\\br{0, t}} S, \\ \\abs{v} = 1} \\le \\A\\br{E_1\\br{0, t}, E_1\\br{0, t}} = h_1\\br{t}, $$\nand\n$$ \\lambda_2\\br{p} \\ge \\lambda_2\\br{\\phi\\br{t, 0}} = \\max\\cbr{\\A\\br{v, v} \\st v \\in \\T_{\\phi\\br{t, 0}} S, \\ \\abs{v} = 1} \\ge \\A\\br{E_2\\br{t, 0}, E_2\\br{t, 0}} = h_2\\br{t}, $$\nso $ h_1\\br{t} $ is minimum at $ t = 0 $ and $ h_2\\br{t} $ is maximum at $ t = 0 $, so $ h_1''\\br{0} \\ge 0 $ and $ h_2''\\br{0} \\le 0 $, so\n$$ h_1''\\br{0} - h_2''\\br{0} \\ge 0. $$\nAssume $ \\lambda_1 < \\lambda_2 $. Thus $ \\lambda_1\\lambda_2\\br{\\lambda_1 - \\lambda_2} < 0 $, \\footnote{Exercise} a contradiction.\n\\end{proof}\n\n\\begin{corollary}\nLet $ \\K > 0 $ be constant. Then $ S $ is compact and connected implies that $ S = \\S^2 $.\n\\end{corollary}\n\n\\pagebreak\n\n\\section{Area of surfaces}\n\n\\subsection{Area}\n\n\\lecture{23}{Monday}{26/11/18}\n\nLet $ S \\subset \\RR^3 $ be a regular surface and $ \\phi : U \\to S $ be a chart. How to measure the area on $ S $? Consider a tiny rectangle in $ U $ with sides $ \\br{\\delta u, 0} $ and $ \\br{0, \\delta v} $. The area of this, in $ U $, is $ \\delta u\\delta v $. If $ \\delta u $ and $ \\delta v $ are small then the area of the image of this rectangle in $ \\phi\\br{U} $ is approximately the area of the parallelogram in $ \\RR^3 $ with sides $ \\br{\\tod{\\phi}{u}}\\delta u $ and $ \\br{\\tod{\\phi}{v}}\\delta v $, that is\n$$ \\abs{\\br{\\dpd{\\phi}{u}\\delta u} \\times \\br{\\dpd{\\phi}{v}\\delta v}} = \\abs{\\dpd{\\phi}{u} \\times \\dpd{\\phi}{v}}\\delta u\\delta v. $$\n\n\\begin{definition}\nIf $ D \\subset U $ is compact, then\n$$ \\area \\phi\\br{D} = \\iintd{D}{\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}}{u}{v}. $$\n\\end{definition}\n\nNeed to show this integral\n\\begin{itemize}\n\\item converges, and\n\\item is independent of choice of chart.\n\\end{itemize}\n\n\\begin{proposition}\nThis definition does not depend on the choice of coordinate chart $ \\phi : U \\to S $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\phi : U \\to S $ and $ \\psi : U' \\to S $ be charts whose images contain $ \\phi\\br{D} = \\psi\\br{D} $. After shrinking $ U $ and $ U' $ if necessary, we have that $ f = \\phi^{-1} \\circ \\psi : U' \\to U $ is well-defined and smooth. Write\n$$ f\\br{u, v} = \\br{x\\br{u, v}, y\\br{u, v}}, $$\nso\n$$\n\\begin{tikzcd}\nD \\subset U \\arrow{r}{\\phi} & S \\\\\nD' \\subset U' \\arrow{u}{f} \\arrow{ur}[swap]{\\psi} &\n\\end{tikzcd}.\n$$\nThen $ \\psi = \\phi \\circ f $ so\n$$ \\dpd{\\psi}{u} \\times \\dpd{\\psi}{v} = \\br{\\dpd{\\phi}{x}\\dpd{x}{u} + \\dpd{\\phi}{y}\\dpd{y}{u}} \\times \\br{\\dpd{\\phi}{x}\\dpd{x}{v} + \\dpd{\\phi}{y}\\dpd{y}{v}} = \\Delta\\br{\\dpd{\\phi}{x} \\times \\dpd{\\phi}{y}}, \\qquad \\Delta\\br{u, v} = \\dpd{x}{u}\\dpd{y}{v} - \\dpd{y}{u}\\dpd{x}{v}. $$\nSo\n\\begin{align*}\n\\area \\psi\\br{D'}\n& = \\iintd{D'}{\\abs{\\tpd{\\psi}{u} \\times \\tpd{\\psi}{v}}}{u}{v}\n= \\iintd{D'}{\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}\\abs{\\det \\twobytwo{\\tpd{x}{u}}{\\tpd{y}{u}}{\\tpd{x}{v}}{\\tpd{y}{v}}}}{u}{v} \\\\\n& = \\iintd{D}{\\abs{\\tpd{\\phi}{x} \\times \\tpd{\\phi}{y}}}{x}{y}\n= \\area \\phi\\br{D},\n\\end{align*}\nby the change of variable formula.\n\\end{proof}\n\n\\begin{note*}\n$ S \\subset \\RR^3 $, and $ \\RR^3 $ has a distinguished $ 3 $-form $ \\d x \\wedge \\d y \\wedge \\d z $. If $ S $ is oriented, so we have chosen a normal vector field $ \\N $ on $ S $, then can consider the $ 2 $-form $ \\omega = 2_\\N\\br{\\d x \\wedge \\d y \\wedge \\d z} $, where $ 2_\\N $ is the contraction, and measure areas on $ S $ using this $ 2 $-form. Up to sign, this gives the same notion of area.\n\\end{note*}\n\n\\pagebreak\n\n\\begin{lemma}\n$$ \\area \\phi\\br{D} = \\iintd{D}{\\sqrt{\\det \\g}}{u}{v}. $$\n\\end{lemma}\n\n\\begin{proof}\n$ \\abs{a \\times b}^2 = \\abs{a}^2\\abs{b}^2 - \\br{a \\cdot b}^2 $, so\n$$ \\abs{\\dpd{\\phi}{u} \\times \\dpd{\\phi}{v}}^2 = \\abs{\\dpd{\\phi}{u}}^2\\abs{\\dpd{\\phi}{v}}^2 - \\br{\\dpd{\\phi}{u} \\cdot \\dpd{\\phi}{v}}^2. $$\nBut\n$$ \\g = \\twobytwo{\\tpd{\\phi}{u} \\cdot \\tpd{\\phi}{u}}{\\tpd{\\phi}{u} \\cdot \\tpd{\\phi}{v}}{\\tpd{\\phi}{v} \\cdot \\tpd{\\phi}{u}}{\\tpd{\\phi}{v} \\cdot \\tpd{\\phi}{v}}, $$\nso\n$$ \\abs{\\dpd{\\phi}{u} \\times \\dpd{\\phi}{v}}^2 = \\g_{11}\\g_{22} - \\g_{21}^2 = \\det \\g. $$\nThus\n$$ \\area \\phi\\br{D} = \\iintd{D}{\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}}{u}{v} = \\iintd{D}{\\sqrt{\\det \\g}}{u}{v}. $$\n\\end{proof}\n\n\\begin{definition}\nAssume $ S $ is compact. If $ f : S \\to \\RR $ is a smooth function on $ S $, $ \\phi : U \\to S $ is a chart, and $ D \\subset U $ is a compact subset, then we define\n$$ \\intd{\\phi\\br{D}}{}{f}{A} = \\iintd{D}{\\br{f \\circ \\phi}\\br{u, v}\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}}{u}{v} = \\iintd{D}{\\br{f \\circ \\phi}\\sqrt{\\det \\g}}{u}{v}. $$\n\\end{definition}\n\nThis does not depend on chart $ \\phi : U \\to S $. To integrate over all of $ S $ we divide $ S $ into pieces\n$$ S = S_1 \\cup \\dots \\cup S_k, \\qquad S_i \\cap S_j \\subset \\br{\\partial S_i} \\cap \\br{\\partial S_j}, \\qquad i \\ne j, $$\nsuch that for each $ i $ there exists a chart $ \\phi : U_i \\to S $ such that $ S_i \\subset \\phi\\br{U_i} $ and $ S_i = \\phi\\br{D_i} $ for some compact set $ D_i \\subset U_i $. By compactness of $ S $, such a partition $ S = S_1 \\cup \\dots \\cup S_k $ always exists.\n\n\\begin{definition}\nDefine\n$$ \\intd{S}{}{f}{A} = \\sum_{i = 1}^k \\intd{S_i}{}{f}{A}. $$\n\\end{definition}\n\nClaim that this is independent of the choice of decomposition.\n\n\\lecture{24}{Tuesday}{27/11/18}\n\n\\begin{example*}\nWhat is the surface area of the unit sphere in $ \\RR^3 $? Use spherical polar coordinates\n$$ \\psi\\br{\\theta, \\phi} = \\br{\\cos \\theta\\sin \\phi, \\sin \\theta\\sin \\phi, \\cos \\phi}, \\qquad \\epsilon \\le \\theta \\le 2\\pi - \\epsilon, \\qquad \\epsilon \\le \\phi \\le \\pi - \\epsilon. $$\nAre the columns of the matrix\n$$ \\onebytwo{\\psi_\\theta}{\\psi_\\phi} = \\threebyone{-\\sin \\theta\\sin \\phi & \\cos \\theta\\cos \\phi}{\\cos \\theta\\sin \\phi & \\sin \\theta\\cos \\phi}{0 & -\\sin \\phi}. $$\nlinearly independent? If $ \\sin \\phi \\ne 0 $ then the first two rows of the first column is not both zero and the last row of the second column is not zero. So this surface is regular, because $ \\sin \\phi \\ne 0 $ in our chart, since we took $ \\phi \\in \\br{0, \\pi} $. Then\n\\begin{align*}\n\\area \\psi\\br{D}\n& = \\iintd{D}{\\abs{\\psi_\\theta \\times \\psi_\\phi}}{\\theta}{\\phi}\n= \\intd{\\epsilon}{\\pi - \\epsilon}{\\intd{\\epsilon}{2\\pi - \\epsilon}{\\sin \\phi}{\\theta}}{\\phi} \\\\\n& = \\br{2\\pi - 2\\epsilon}\\sbr{\\cos \\phi}_{\\pi - \\epsilon}^\\epsilon\n= \\br{2\\pi - 2\\epsilon}\\br{\\cos \\epsilon - \\cos \\br{\\pi - \\epsilon}},\n\\end{align*}\nso\n$$ \\lim_{\\epsilon \\to 0} \\area \\psi\\br{D} = 4\\pi. $$\nCompute the area of the rest by using another chart, which tends to zero as $ \\epsilon \\to 0 $. Thus $ \\area \\S^2 = 4\\pi $.\n\\end{example*}\n\n\\pagebreak\n\n\\section{Geodesics}\n\n\\subsection{Geodesic curvature}\n\nGeodesics are the shortest paths. Let $ \\gamma : \\sbr{a, b} \\to S $ be a regular curve in a regular surface $ S $. Suppose that $ S $ is oriented, with normal vector field $ \\N $, and that $ \\gamma $ is parametrised by arc-length. Then\n$$ \\br{\\gamma'\\br{t}, \\N\\br{\\gamma\\br{t}} \\times \\gamma'\\br{t}, \\N\\br{\\gamma\\br{t}}} $$\nis an orthonormal basis for $ \\RR^3 $. Recall that the curvature of $ \\gamma $ is $ \\vec{\\kappa}\\br{t} = \\gamma''\\br{t} $ and that $ \\gamma'' $ is orthogonal to $ \\gamma' $, because $ \\gamma'\\br{t} \\cdot \\gamma'\\br{t} = 1 $, so $ \\tod{}{t}\\br{\\gamma''\\br{t} \\cdot \\gamma'\\br{t}} = 0 $, so $ 2\\gamma''\\br{t} \\cdot \\gamma'\\br{t} = 0 $. So\n$$ \\vec{\\kappa}\\br{t} = \\k_n\\br{t}\\N + \\k_g\\br{t}\\br{\\N \\times \\gamma'}, $$\nwhere\n$$ \\k_n\\br{t} = \\vec{\\kappa}\\br{t} \\cdot \\N $$\nis the \\textbf{normal curvature} of $ \\gamma $ at $ t $, and\n$$ \\k_g\\br{t} = \\vec{\\kappa}\\br{t} \\cdot \\br{\\N \\times \\gamma'} $$\nis the \\textbf{geodesic curvature} of $ \\gamma $ at $ t $, the amount that $ \\gamma $ is curving along $ S $. Then $ \\gamma $ is a \\textbf{geodesic} if the geodesic curvature is zero.\n\n\\lecture{25}{Friday}{30/11/18}\n\n\\begin{example*}\nLet $ S $ be the $ xy $ plane and $ \\N = \\br{0, 0, 1} $. Consider a curve\n$$ \\gamma\\br{t} = \\br{x\\br{t}, y\\br{t}, 0} $$\nparametrised by arc-length, so $ \\br{\\tod{x}{t}}^2 + \\br{\\tod{y}{t}}^2 = 1 $. Then the normal curvature is\n$$ \\k_n = \\vec{\\kappa} \\cdot \\N = \\br{x'', y'', 0} \\cdot \\br{0, 0, 1} = 0, $$\nand $ \\N \\times \\gamma' = \\br{0, 0, 1} \\times \\br{x', y', 0} = \\br{-y', x', 0} $, so the geodesic curvature is\n$$ \\k_g = \\vec{\\kappa} \\cdot \\br{\\N \\times \\gamma'} = \\br{x'', y'', 0} \\cdot \\br{-y', x', 0} = x'y'' - x''y'. $$\nThen $ \\vec{\\kappa} = \\k_g\\br{\\N \\times \\gamma'} $, so $ \\k_g = 0 $ if and only if $ \\vec{\\kappa} = 0 $, if and only if $ x'' = y'' = 0 $. That is, geodesics in the plane take the form\n$$ \\br{x\\br{t}, y\\br{t}} = \\br{a_0, b_0} + t\\br{a_1, b_1}, $$\nwhich are straight lines.\n\\end{example*}\n\n\\begin{example*}\nLet $ S $ be the unit sphere\n$$ \\cbr{\\br{x, y,z} \\in \\RR^3 \\st x^2 + y^2 + z^2 = 1}. $$\nConsider a latitude of radius $ r $,\n$$ \\gamma\\br{t} = \\br{r\\cos \\tfrac{t}{r}, r\\sin \\tfrac{t}{r}, \\sqrt{1 - r^2}}, \\qquad 0 \\le t \\le 2\\pi r. $$\nThen\n$$ \\gamma'\\br{t} = \\br{-\\sin \\tfrac{t}{r}, \\cos \\tfrac{t}{r}, 0}, \\qquad \\N\\br{\\gamma\\br{t}} = \\gamma\\br{t} = \\br{r\\cos \\tfrac{t}{r}, r\\sin \\tfrac{t}{r}, \\sqrt{1 - r^2}}, $$\nso\n$$ \\N \\times \\gamma' = \\br{-\\sqrt{1 - r^2}\\cos \\tfrac{t}{r}, -\\sqrt{1 - r^2}\\sin \\tfrac{t}{r}, r}, \\qquad \\vec{\\kappa}\\br{t} = \\gamma''\\br{t} = \\dfrac{1}{r}\\br{-\\cos \\tfrac{t}{r}, -\\sin \\tfrac{t}{r}, 0}. $$\nThus\n\\begin{align*}\n\\k_g\n& = \\dfrac{1}{r}\\br{-\\cos \\tfrac{t}{r}, -\\sin \\tfrac{t}{r}, 0} \\cdot \\br{-\\sqrt{1 - r^2}\\cos \\tfrac{t}{r}, -\\sqrt{1 - r^2}\\sin \\tfrac{t}{r}, r} \\\\\n& = \\dfrac{\\sqrt{1 - r^2}}{r}\\br{\\cos^2 \\tfrac{t}{r} + \\sin^2 \\tfrac{t}{r}}\n= \\dfrac{\\sqrt{1 - r^2}}{r}.\n\\end{align*}\nSo a latitude is a geodesic if and only if $ r = 1 $, if and only if it is the equator.\n\\end{example*}\n\n\\pagebreak\n\n\\begin{proposition}\nLocal isometries send geodesics to geodesics.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\gamma : \\sbr{a, b} \\to S $ be a geodesic parametrised by arc-length, and $ F : S \\to S' $ a local isometry, so\n$$\n\\begin{tikzcd}\n\\gamma\\br{t} \\subset S \\arrow{r}{F} & \\br{F \\circ \\gamma}\\br{t} \\subset S' \\\\\nU \\subset \\RR^2 \\arrow{u}{\\phi} \\arrow{ur}[swap]{\\psi = F \\circ \\phi}\n\\end{tikzcd}.\n$$\nFrom\n$$ \\vec{\\kappa}\\br{t} = \\k_n\\N\\br{\\gamma\\br{t}} + \\k_g\\br{\\N\\br{\\gamma\\br{t}} \\times \\gamma'\\br{t}}, $$\nwe see that $ \\gamma $ is a geodesic if and only if $ \\gamma''\\br{t} $ is a multiple of $ \\N\\br{\\gamma\\br{t}} $, if and only if\n$$ \\gamma''\\br{t} \\cdot \\phi_u = \\gamma''\\br{t} \\cdot \\phi_v = 0, $$\nfor $ \\phi : U \\to \\RR^2 $ a chart at $ \\gamma\\br{t} $. Write\n$$ \\gamma\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}}, $$\nso\n$$ \\gamma'\\br{t} = \\phi_uu' + \\phi_vv', \\qquad \\gamma''\\br{t} = \\br{\\phi_{uu}u' + \\phi_{uv}v'}u' + \\br{\\phi_{uv}u' + \\phi_{vv}v'}v', $$\nso\n\\begin{align*}\n0\n& = \\gamma'' \\cdot \\phi_u\n= \\br{\\phi_u \\cdot \\phi_{uu}}\\br{u'}^2 + 2\\br{\\phi_u \\cdot \\phi_{uv}}\\br{u'v'} + \\br{\\phi_u \\cdot \\phi_{vv}}\\br{v'}^2 \\\\\n& = \\dfrac{1}{2}\\dpd{}{u}\\br{\\phi_u \\cdot \\phi_u}\\br{u'}^2 + \\dpd{}{v}\\br{\\phi_u \\cdot \\phi_u}\\br{u'v'} + \\br{\\dpd{}{v}\\br{\\phi_u \\cdot \\phi_v} - \\dfrac{1}{2}\\dpd{}{u}\\br{\\phi_v \\cdot \\phi_v}}\\br{v'}^2 \\\\\n& = \\dfrac{1}{2}\\g_{11u}\\br{u'}^2 + \\g_{11v}\\br{u'v'} + \\br{\\g_{12v} - \\dfrac{1}{2}\\g_{22u}}\\br{v'}^2,\n\\end{align*}\nand similarly for $ \\gamma'' \\cdot \\phi_v $. These are determined by $ u $ and $ v $, and the first fundamental form $ \\g $. Since $ F $ is an isometry, it preserves $ \\g $ with respect to the chart $ \\psi = F \\circ \\phi $, and $ F\\br{\\gamma\\br{t}} = \\psi\\br{u\\br{t}, v\\br{t}} $ implies that\n$$ \\br{F \\circ \\gamma}'' \\cdot \\psi_u = \\gamma'' \\cdot \\phi_u = 0, \\qquad \\br{F \\circ \\gamma}'' \\cdot \\psi_v = \\gamma'' \\cdot \\phi_v = 0. $$\n\\end{proof}\n\nLet $ \\phi : U \\to S $ be a chart on a regular surface, and let $ \\gamma\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $ be a curve on $ S $. Then $ \\gamma $ is a geodesic if and only if \\footnote{Exercise}\n$$ \\br{\\g_{11}u' + \\g_{12}v'}' = \\dfrac{1}{2}\\br{\\g_{11u}\\br{u'}^2 + 2\\g_{12u}\\br{u'v'} + \\g_{22u}\\br{v'}^2}, $$\nand\n$$ \\br{\\g_{21}u' + \\g_{22}v'}' = \\dfrac{1}{2}\\br{\\g_{11v}\\br{u'}^2 + 2\\g_{12v}\\br{u'v'} + \\g_{22v}\\br{v'}^2}. $$\nThese are the \\textbf{geodesic equations}.\n\n\\pagebreak\n\n\\subsection{Length-minimising curves}\n\n\\lecture{26}{Monday}{03/12/18}\n\nClaim that geodesics minimise arc-length, locally. That is, for any small perturbation $ \\beta $ of $ \\gamma $, $ \\L\\br{\\beta} \\ge \\L\\br{\\gamma} $.\n\n\\begin{definition}\nA \\textbf{variation} of $ \\gamma : \\sbr{0, L} \\to S $ is a smooth map\n$$ \\function{\\sbr{0, L} \\times \\sbr{-\\epsilon, \\epsilon}}{S}{\\br{t, s}}{\\gamma_s\\br{t}}, $$\nsuch that\n$$ \\gamma_0\\br{t} = \\gamma\\br{t}, \\qquad \\gamma_s\\br{0} = \\gamma\\br{0}, \\qquad \\gamma_s\\br{L} = \\gamma\\br{L}, \\qquad t \\in \\sbr{0, L}, \\qquad s \\in \\sbr{-\\epsilon, \\epsilon}. $$\n\\end{definition}\n\n\\begin{proposition}\nGeodesics minimise arc-length locally. That is, if $ \\gamma : \\sbr{0, L} \\to S $ is a local minimum for arc-length between $ \\gamma\\br{0} $ and $ \\gamma\\br{L} $ and is parametrised by arc-length, then $ \\gamma $ is a geodesic.\n\\end{proposition}\n\n\\begin{proof}\nLet $ \\gamma_s\\br{t} $ be a variation of $ \\gamma $. Then $ s \\mapsto \\L\\br{\\gamma_s} $ is minimised at $ s = 0 $. This is a smooth function of $ s $. So\n\\begin{align*}\n0\n& = \\eval{\\dod{}{s}\\br{\\L\\br{\\gamma_s}}}_{s = 0}\n= \\eval{\\dod{}{s}\\intd{0}{L}{\\sqrt{\\gamma_s'\\br{t} \\cdot \\gamma_s'\\br{t}}}{t}}_{s = 0} \\\\\n& = \\intd{0}{L}{\\eval{\\tod{}{s}\\sqrt{\\gamma_s'\\br{t} \\cdot \\gamma_s'\\br{t}}}_{s = 0}}{t} & \\sqrt{\\gamma_s'\\br{t} \\cdot \\gamma_s'\\br{t}} \\ \\text{is smooth} \\\\\n& = \\intd{0}{L}{\\tfrac{\\eval{\\tod{}{s}\\br{\\gamma_s'\\br{t} \\cdot \\gamma_s'\\br{t}}}_{s = 0}}{\\eval{2\\sqrt{\\gamma_s'\\br{t} \\cdot \\gamma_s'\\br{t}}}_{s = 0}}}{t}\n= \\intd{0}{L}{\\eval{\\tod{}{s}\\br{\\gamma_s'\\br{t}} \\cdot \\gamma_s'\\br{t}}_{s = 0}}{t} & \\abs{\\gamma_0'\\br{t}} = \\abs{\\gamma'\\br{t}} = 1 \\\\\n& = \\intd{0}{L}{\\eval{\\tod{}{s}\\br{\\tod{\\gamma_s}{t}}}_{s = 0} \\cdot \\tod{\\gamma_0}{t}}{t}\n= \\intd{0}{L}{\\eval{\\tod{}{t}\\br{\\tod{\\gamma_s}{s}}_{s = 0}} \\cdot \\tod{\\gamma_0}{t}}{t} & \\br{s, t} \\mapsto \\gamma_s\\br{t} \\ \\text{is smooth} \\\\\n& = \\sbr{\\eval{\\tod{\\gamma_s}{s}}_{s = 0} \\cdot \\tod{\\gamma_0}{t}}_0^L - \\intd{0}{L}{\\eval{\\tod{\\gamma_s}{s}}_{s = 0} \\cdot \\tod[2]{\\gamma_0}{t}}{t} & \\text{integration by parts} \\\\\n& = -\\intd{0}{L}{\\eval{\\tod{\\gamma_s}{s}}_{s = 0} \\cdot \\br{\\k_n\\br{t}\\N\\br{\\gamma\\br{t}} + \\k_g\\br{t}\\br{\\N\\br{\\gamma\\br{t}} \\times \\gamma'\\br{t}}}}{t} & \\tod{\\gamma_s}{s}\\br{0} = \\tod{\\gamma_s}{s}\\br{L} = 0 \\\\\n& = \\intd{0}{L}{\\eval{\\tod{\\gamma_s}{s}}_{s = 0} \\cdot \\br{\\k_g\\br{t}\\br{\\N\\br{\\gamma\\br{t}} \\times \\gamma'\\br{t}}}}{t} & \\N\\br{\\gamma\\br{t}} \\perp \\T_{\\gamma\\br{t}} S.\n\\end{align*}\nLet $ g : \\sbr{0, L} \\to \\RR $ be any smooth function such that $ g\\br{0} = g\\br{L} = 0 $. Can find a variation $ \\gamma_s\\br{t} $ with\n$$ \\eval{\\dod{\\gamma_s}{s}}_{s = 0} = g\\br{t}\\br{\\N\\br{\\gamma\\br{t}} \\times \\gamma'\\br{t}}. $$\nThus we have\n$$ \\intd{0}{L}{\\k_g\\br{t}g\\br{t}}{t} = 0, $$\nand, since $ \\k_g $ is continuous as a function of $ t $, and $ g $ is arbitrary, it follows that $ \\k_g\\br{t} = 0 $ for all $ t $, that is $ \\gamma $ was a geodesic.\n\\end{proof}\n\n\\begin{remark*}\n\\hfill\n\\begin{itemize}\n\\item Geodesics need not be global minima for arc-length between two points. In $ \\S^2 $ with usual metric, a major arc is a geodesic but not a global minimum for arc-length.\n\\item Geodesics between two points need not be unique. All great circles are geodesics from $ \\N $ to $ S $.\n\\item Geodesics connecting two points need not exist. In $ \\RR^2 \\setminus \\cbr{0} $, $ 1 $ and $ -1 $ has no geodesic, and $ \\RR^2 \\setminus \\cbr{0} $ is locally isometric to $ \\RR^2 $. Local isometries preserve geodesics, so geodesics in $ \\RR^2 \\setminus \\cbr{0} $ are straight lines.\n\\end{itemize}\nIn general, it is hard to find geodesics explicitly. Need to solve the geodesic equation.\n\\end{remark*}\n\n\\pagebreak\n\n\\section{The Gauss-Bonnet theorem and applications}\n\n\\lecture{27}{Tuesday}{04/12/18}\n\nEquates geometry and topology. Will prove this from its local version.\n\n\\subsection{Local version of Gauss-Bonnet}\n\n\\begin{theorem}[Local Gauss-Bonnet]\nLet $ \\phi : U \\to S $ be a chart which is smooth in $ \\overline{U} $, the closure of $ U $ in $ \\RR^2 $, such that $ S = \\phi\\br{\\overline{U}} $ is an oriented surface with boundary $ \\partial S = \\phi\\br{\\partial\\overline{U}} $. Suppose that $ \\overline{U} $ is diffeomorphic to a disc. Then,\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = 2\\pi, $$\nwhere $ A $ is the area, $ s $ is the arc-length, and $ \\partial S $ is positively oriented with respect to $ S $. A \\textbf{surface with boundary} is the same as a regular surface except that some points $ p \\in S $ have charts $ \\phi : U \\subset \\RR^2 \\to S $, where $ U $ is the intersection of an open neighbourhood of $ \\br{0, 0} $ in $ R^2 $ and $ \\cbr{y \\ge 0} $. $ \\phi $ here is smooth, which means there exists an open set $ V \\subset \\RR^3 $ and $ \\Phi : V \\to \\RR^3 $ smooth such that $ \\phi = \\eval{\\Phi}_U $ and $ U \\subseteq V $. Then $ \\partial S $ is the collection of all points with charts like this, a collection of regular curves, and $ \\partial S $ is \\textbf{positively oriented} if in some parametrisation $ \\gamma : \\sbr{a, b} \\to \\partial S $, $ \\N \\times \\gamma' $ points into $ S $.\n\\end{theorem}\n\n\\begin{proof}\nThe idea is to recall\n$$ \\intd{S}{}{\\K}{A} = \\iintd{U}{\\br{\\K \\circ \\phi}\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}}{u}{v}. $$\nWe will find functions $ M, L : U \\to \\RR $ such that\n$$ \\iintd{U}{\\br{\\K \\circ \\phi}\\abs{\\tpd{\\phi}{u} \\times \\tpd{\\phi}{v}}}{u}{v} = \\iintd{U}{\\tpd{M}{u} \\times \\tpd{L}{v}}{u}{v} = \\int_{\\partial U} \\, L \\, \\d u + M \\, \\d v = 2\\pi - \\intd{\\partial U}{}{\\k_g}{s}, $$\nby applying Green's theorem. For a precise version, make an orthonormal basis for $ \\T_p S $. Take\n$$ E_1 = \\dfrac{\\phi_u}{\\abs{\\phi_u}}, \\qquad E_2 = \\N \\times E_1, $$\nso $ \\N = E_1 \\times E_2 $. Have an orthonormal basis $ E_1 $ and $ E_2 $ for $ \\T_p S $ along $ \\partial S $. So there exists a continuous function $ \\theta : \\sbr{0, L} \\to \\RR $ such that\n$$ \\gamma'\\br{t} = \\cos \\theta\\br{t}E_1\\br{\\gamma\\br{t}} + \\sin \\theta\\br{t}E_2\\br{\\gamma\\br{t}}. $$\nHere $ L $ is the length of the boundary, and $ \\gamma : \\sbr{0, L} \\to \\partial S $ is an arc-length parametrisation of $ \\partial S $.\n\\begin{itemize}\n\\item Claim that\n$$ \\k_g\\br{\\gamma\\br{t}} = \\theta'\\br{t} - E_1\\br{t} \\cdot E_2'\\br{t}. $$\n$ \\k_g = \\gamma'' \\cdot \\br{\\N \\times \\gamma'} $. Then\n$$ \\gamma''\\br{t} = \\br{-\\sin \\theta E_1 + \\cos \\theta E_2}\\theta'\\br{t} + \\cos \\theta E_1' + \\sin \\theta E_2', \\quad \\N \\times \\gamma'\\br{t} = -\\sin \\theta E_1 + \\cos \\theta E_2, $$\nso\n$$ \\k_g\\br{\\gamma\\br{t}} = \\gamma''\\br{t} \\cdot \\br{\\N \\times \\gamma'\\br{t}} = \\theta'\\br{t} + \\br{\\cos \\theta E_1' + \\sin \\theta E_2'} \\cdot \\br{-\\sin \\theta E_1 + \\cos \\theta E_2}. $$\nNow,\n$$ E_1\\br{t} \\cdot E_1\\br{t} = 1, \\qquad E_1\\br{t} \\cdot E_2\\br{t} = 0, \\qquad E_2\\br{t} \\cdot E_2\\br{t} = 1. $$\nDifferentiating,\n$$ E_1 \\cdot E_1' = 0, \\qquad E_1 \\cdot E_2' + E_1' \\cdot E_2 = 0, \\qquad E_2 \\cdot E_2' = 0, $$\nso $ \\k_g = \\theta' - E_1 \\cdot E_2' $, which was the claim.\n\n\\lecture{28}{Friday}{07/12/18}\n\n\\item Claim that\n$$ \\intd{0}{L}{E_1\\br{t} \\cdot E_2'\\br{t}}{t} = \\iintd{U}{\\br{\\K \\circ \\phi}\\abs{\\phi_u \\times \\phi_v}}{u}{v}. $$\nThis will help because it implies\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = \\intd{0}{L}{\\theta'\\br{t}}{t}. $$\n\n\\pagebreak\n\nLet us show that\n\\begin{equation}\n\\label{eq:4}\n\\dpd{E_1}{u} \\cdot \\dpd{E_2}{v} - \\dpd{E_1}{v} \\cdot \\dpd{E_2}{u} = \\K\\abs{\\phi_u \\times \\phi_v}\n\\end{equation}\nAssuming $ \\br{\\ref{eq:4}} $ then, setting $ \\gamma\\br{t} = \\phi\\br{u\\br{t}, v\\br{t}} $, we have\n\\begin{align*}\n\\intd{0}{L}{E_1\\br{t} \\cdot E_2'\\br{t}}{t}\n& = \\intd{0}{L}{E_1\\br{t} \\cdot \\br{\\tpd{E_2}{u}u' + \\tpd{E_2}{v}v'}}{t}\n= \\int_{\\partial U} \\, E_1\\br{t} \\cdot \\tpd{E_2}{u} \\, \\d u + E_1\\br{t} \\cdot \\tpd{E_2}{v} \\, \\d v \\\\\n& = \\iintd{U}{\\br{\\tpd{}{u}\\br{E_1\\br{t} \\cdot \\tpd{E_2}{v}} - \\tpd{}{v}\\br{E_1\\br{t} \\cdot \\tpd{E_2}{u}}}}{u}{v} \\\\\n& = \\iintd{U}{\\br{\\tpd{E_1}{u} \\cdot \\tpd{E_2}{v} - \\tpd{E_1}{v} \\cdot \\tpd{E_2}{u}}}{u}{v} = \\iintd{U}{\\K\\abs{\\phi_u \\times \\phi_v}}{u}{v},\n\\end{align*}\nby Green's theorem and $ \\br{\\ref{eq:4}} $, which proves the claim. It remains to prove $ \\br{\\ref{eq:4}} $. Note\n$$ E_1 \\cdot \\dpd{E_1}{u} = 0, \\qquad E_1 \\cdot \\dpd{E_2}{u} + \\dpd{E_1}{u} \\cdot E_2 = 0, \\qquad \\dots. $$\nSo\n$$ \\dpd{E_1}{u} = aE_2 + \\br{\\dpd{E_1}{u} \\cdot \\N}\\N = aE_2 - \\br{E_1 \\cdot \\dpd{\\N}{u}}\\N = aE_2 + \\A\\br{E_1, \\dpd{\\phi}{u}}N, $$\nfor some constant $ a $. Similarly,\n$$ \\dpd{E_1}{v} = bE_2 + \\A\\br{E_1, \\dpd{\\phi}{v}}\\N, \\qquad \\dpd{E_2}{u} = cE_1 + \\A\\br{E_2, \\dpd{\\phi}{u}}\\N, \\qquad \\dpd{E_2}{v} = dE_1 + \\A\\br{E_2, \\dpd{\\phi}{v}}\\N, $$\nfor some constants $ b, c, d $. Thus\n$$ \\dpd{E_1}{u} \\cdot \\dpd{E_2}{v} - \\dpd{E_1}{v} \\cdot \\dpd{E_2}{u} = \\A\\br{E_1, \\dpd{\\phi}{u}}\\A\\br{E_2, \\dpd{\\phi}{v}} - \\A\\br{E_2, \\dpd{\\phi}{u}}\\A\\br{E_1, \\dpd{\\phi}{v}}. $$\nWriting\n$$ \\dpd{\\phi}{u} = c_{11}E_1 + c_{12}E_2, \\qquad \\dpd{\\phi}{v} = c_{21}E_1 + c_{22}E_2, $$\nthis is\n\\begin{align*}\n\\dpd{E_1}{u} \\cdot \\dpd{E_2}{v} - \\dpd{E_1}{v} \\cdot \\dpd{E_2}{u}\n= \\ & \\br{c_{11}\\A\\br{E_1, E_1} + c_{12}\\A\\br{E_1, E_2}} \\cdot \\br{c_{21}\\A\\br{E_2, E_1} + c_{22}\\A\\br{E_2, E_2}} \\\\\n& - \\br{c_{11}\\A\\br{E_2, E_1} + c_{12}\\A\\br{E_2, E_2}} \\cdot \\br{c_{21}\\A\\br{E_1, E_1} + c_{22}\\A\\br{E_1, E_2}} \\\\\n= \\ & \\br{c_{11}c_{22} - c_{12}c_{21}} \\cdot \\br{\\A\\br{E_1, E_1}\\A\\br{E_2, E_2} - \\A\\br{E_1, E_2}\\A\\br{E_2, E_1}} \\\\\n= \\ & \\abs{\\dpd{\\phi}{u} \\times \\dpd{\\phi}{v}}\\det \\A\n= \\abs{\\dpd{\\phi}{u} \\times \\dpd{\\phi}{v}}\\K,\n\\end{align*}\nas claimed.\n\\end{itemize}\nSo at this point we know\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = \\intd{0}{L}{\\tod{\\theta}{t}}{t}. $$\nIt remains to show that the right hand side is $ 2\\pi $. Since\n$$ \\intd{0}{L}{\\tod{\\theta}{t}}{t} = \\theta\\br{L} - \\theta\\br{0} $$\nis the total rotation of $ \\gamma'\\br{t} $ along the path $ \\partial S $ with respect to the frame $ \\br{E_1\\br{t}, E_2\\br{t}} $, the fact that this is $ 2\\pi $ follows from the fact that $ \\overline{U} $ is only diffeomorphic to a disc, so replace it by a disc. There is a \\textbf{regular homotopy}\n$$ \\function[H]{\\sbr{0, 1} \\times \\sbr{0, 1}}{X}{\\br{s, t}}{\\gamma_s\\br{t}}, $$\nsmooth in $ s $ and $ t $, from the boundary curve to an approximate tiny circle in $ \\T_p S $. Since $ \\Ind \\gamma = \\theta\\br{L} - \\theta\\br{0} $ is invariant under regular homotopy, $ \\Ind \\gamma $ is the index of a small circle in the plane, which is $ 2\\pi $.\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Gauss-Bonnet for curvilinear triangles}\n\n\\lecture{29}{Monday}{10/12/18}\n\n\\begin{definition}\nA \\textbf{curvilinear triangle} in $ \\RR^2 $ is a continuous map $ \\beta : \\RR \\to \\RR^2 $ such that\n\\begin{itemize}\n\\item $ \\beta\\br{t} = \\beta\\br{t + 3} $ for all $ t $, and\n\\item there exist $ t_0, t_1, t_2 \\in \\intco{0, 3} $ such that $ 0 \\le t_0 < t_1 < t_2 < 3 $ and\n\\begin{itemize}\n\\item $ \\beta $ is smooth on $ \\br{t_0, t_1} $, $ \\br{t_1, t_2} $, and $ \\br{t_2, t_3} $ where $ t_3 = t_0 + 3 $,\n\\item $ \\eval{\\beta}_{\\intco{0, 3}} $ is injective, and\n\\item $ \\beta_-'\\br{t_i} $ and $ \\beta_+'\\br{t_i} $ exist and meet at an angle $ \\theta_i $ that is not a multiple of $ \\pi $.\n\\end{itemize}\n\\end{itemize}\n\\end{definition}\n\nLet $ T \\subset U \\subset \\RR^2 $ be a curvilinear triangle and let $ \\phi : U \\to S $ be a chart on a regular surface $ S $. At each vertex of $ \\phi\\br{T} $, the edges incident to that vertex are parametrised by $ \\gamma_{in} : \\intoc{-\\epsilon, 0} \\to S $ and $ \\gamma_{out} : \\intco{0, \\epsilon} \\to S $. The tangent vectors meet at some angle $ \\theta $ for $ -\\pi < \\theta < \\pi $, so\n$$ \\cos \\theta = \\dfrac{\\gamma_{in}'\\br{0} \\cdot \\gamma_{out}'\\br{0}}{\\abs{\\gamma_{in}'\\br{0}}\\abs{\\gamma_{out}'\\br{0}}}. $$\nChoose the sign of $ \\theta $ such that $ \\theta > 0 $ if $ \\br{\\gamma_{in}'\\br{0}, \\gamma_{out}'\\br{0}, \\N} $ is a positive basis of $ \\RR^3 $ and $ \\theta < 0 $ if $ \\br{\\gamma_{in}'\\br{0}, \\gamma_{out}'\\br{0}, \\N} $ is a negative basis of $ \\RR^3 $. Then $ \\theta $ is the \\textbf{exterior angle} at the vertex. The \\textbf{interior angle} is $ \\pi - \\theta $.\n\n\\begin{theorem}[Gauss-Bonnet for curvilinear triangles]\nLet $ T \\subset U \\subset \\RR^2 $ be a curvilinear triangle and let $ \\phi : U \\to S $ be a chart on the regular surface $ S $. Suppose that $ \\phi\\br{\\partial T} \\subset S $ is oriented positively with respect to the orientation of $ S $. Let $ \\theta_1, \\theta_2, \\theta_3 $ be the exterior angles and let $ \\gamma_1, \\gamma_2, \\gamma_3 $ be the edges of $ \\phi\\br{T} $ parametrised by arc-length. Then,\n$$ \\sum_{i = 1}^3 \\intd{\\gamma_i}{}{\\k_g}{s} + \\sum_{i = 1}^3 \\theta_i = 2\\pi - \\intd{\\phi\\br{T}}{}{\\K}{A}. $$\n\\end{theorem}\n\nThink of the left hand side as $ \\intd{\\phi\\br{\\partial T}}{}{\\k_g}{s} $ where $ \\phi\\br{\\partial T} $ is thought as having a $ \\delta $-function of curvature of size $ \\theta_i $ at the vertex $ i $.\n\n\\begin{proof}\nEssentially the same as in local Gauss-Bonnet. We still integrate $ \\k_g = \\theta' - E_1 \\cdot E_2' $, apply Green's theorem to the triangle $ T $, and get\n$$ \\intd{\\phi\\br{T}}{}{\\K}{A} + \\sum_{i = 1}^3 \\intd{\\gamma_i}{}{\\k_g}{s} = \\intd{\\partial S}{}{\\theta'\\br{t}}{t}. $$\nBut now, by topology, we have\n$$ \\intd{\\partial S}{}{\\theta'\\br{t}}{t} = 2\\pi - \\sum_{i = 1}^3 \\theta_i, $$\nbecause the tangent vectors to the $ \\gamma_i $ along $ \\phi\\br{T} = \\partial\\overline{S} $ still rotate a total of $ 2\\pi $, but this includes jumps of $ \\theta_1, \\theta_2, \\theta_3 $ at the three corners, so that $ \\intd{\\partial S}{}{\\theta'\\br{t}}{t} $ does not include these jumps.\n\\end{proof}\n\nThe following are consequences. Consider a \\textbf{geodesic triangle} on $ S $ of geodesic edges, and interior angles $ \\alpha_1, \\alpha_2, \\alpha_3 $. Gauss-Bonnet says,\n$$ \\intd{\\phi\\br{T}}{}{\\K}{A} = 2\\pi - \\sum_{i = 1}^3 \\intd{\\gamma_i}{}{\\k_g}{s} - \\sum_{i = 1}^3 \\theta_i = 2\\pi - \\sum_{i = 1}^3 \\br{\\pi - \\alpha_i} = \\sum_{i = 1}^3 \\alpha_i - \\pi. $$\nFor plane triangles, $ \\K = 0 $, so\n$$ \\sum_{i = 1}^3 \\alpha_i = \\pi. $$\nFor geodesic triangles $ T $ on a sphere of radius one, $ \\K = 1 $, so\n$$ \\sum_{i = 1}^3 \\alpha_i = \\pi + \\area T \\ge \\pi. $$\n\n\\pagebreak\n\n\\subsection{Gauss-Bonnet theorem}\n\n\\begin{proposition}\nEvery compact regular surface admits a \\textbf{triangulation}\n$$ S = \\bigcup_{i = 1}^N T_i, $$\nthat is a partition of $ S $ into curvilinear triangles $ T_i $ such that whenever $ T_i \\cap T_j $ is non-empty then $ T_i \\cap T_j $ is an edge or vertex of both $ T_i $ and $ T_j $, and each edge belongs to\n\\begin{itemize}\n\\item exactly two of the $ T_i $ if that edge lies in the interior of $ S $, and\n\\item in exactly one of the $ T_i $ if that edge lies in $ \\partial S $.\n\\end{itemize}\n\\end{proposition}\n\n$ S $ is sewn together from curvilinear triangles.\n\n\\begin{proof}\nBy compactness, we can cover $ S $ by finitely many charts $ \\phi_i : U_i \\to S $ such that $ U_i $ is homeomorphic to a disc. Without loss of generality we may assume\n$$ \\phi_i\\br{U_i} \\nsubseteq \\bigcup_{j \\ne i} \\phi_j\\br{U_j}, $$\nbecause otherwise just remove $ \\br{U_i, \\phi_i} $ from our cover. Then\n$$ V_i = \\phi_i\\br{U_i} \\setminus \\bigcup_{j \\ne i} \\phi_j\\br{U_j} $$\nis non-empty, and closed in $ S $. Draw a curve $ C_i \\subset \\phi_i\\br{U_i} $ which bounds a neighbourhood of $ V_i $. The union of the $ C_i $ divides $ S $ into regions, each of which is contained in a single chart, and that chart is homeomorphic to a disc in $ \\RR^2 $. Now work in $ U_i $. Now have a closed curve in $ U_i \\subset \\RR^2 $. Triangulate the interior of this.\n\\end{proof}\n\n\\lecture{30}{Tuesday}{11/12/18}\n\n\\begin{lemma}\nThree curves with the same vertex of interior angles $ \\alpha_1 $ and $ \\alpha_2 $ imply that the sum of the interior angles is $ \\alpha_1 + \\alpha_2 $.\n\\end{lemma}\n\n\\begin{proof}\nWithout loss of generality we can take the velocity vectors $ \\gamma_{in}'\\br{0} $ and $ \\gamma_{out}'\\br{0} $ as unit vectors. Let $ \\br{\\cos \\alpha_1, \\sin \\alpha_1} $ be a velocity vector of interior angle $ \\alpha_1 $, $ \\br{\\cos \\br{\\alpha_1 + \\alpha_2}, \\sin \\br{\\alpha_1 + \\alpha_2}} $ be a velocity vector of interior angle $ \\alpha_2 $, and $ \\phi $ be the difference of the interior angles. Then\n\\begin{align*}\n\\cos \\phi\n& = \\br{\\cos \\br{\\alpha_1 + \\alpha_2}, \\sin \\br{\\alpha_1 + \\alpha_2}} \\cdot \\br{\\cos \\alpha_1, \\sin \\alpha_1} \\\\\n& = \\cos \\br{\\alpha_1 + \\alpha_2}\\cos \\alpha_1 + \\sin \\br{\\alpha_1 + \\alpha_2}\\sin \\alpha_1\n= \\cos \\br{\\br{\\alpha_1 + \\alpha_2} - \\alpha_1}\n= \\cos \\br{\\alpha_2},\n\\end{align*}\nso $ \\phi = \\alpha_2 $.\n\\end{proof}\n\nWhat is the \\textbf{Euler characteristic}? Take a triangulation of $ S $. Then\n$$ \\chi\\br{S} = V - E + F, $$\nwhere $ V $ is the number of vertices in the triangulation, $ E $ is the number of edges in the triangulation, and $ F $ is the number of triangles in the triangulation. This is independent of the choice of triangulation of $ S $. Follows from the Gauss-Bonnet theorem and can prove this topologically.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Triangulate $ \\S^2 $ by an inflated tetrahedron. Then $ V = 4, E = 6, F = 4 $, so $ \\chi\\br{\\S^2} = 4 - 6 + 4 = 2 $.\n\\item Triangulate $ \\T^2 $ by two triangles in a square. Then $ V = 1, E = 3, F = 2 $, so $ \\chi\\br{\\T^2} = 1 - 3 + 2 = 0 $.\n\\end{itemize}\n\\end{example*}\n\n\\begin{exercise*}\n\\hfill\n\\begin{itemize}\n\\item Triangulate $ \\T^2 $ by eight triangles in a square, and compute $ \\chi\\br{\\T^2} $ using this triangulation.\n\\item Triangulate $ \\Sigma_g $, a surface of genus $ g $, by two tori without a disc and $ g - 2 $ tori without two discs, and show $ \\chi\\br{\\Sigma_g} = 2 - 2g $.\n\\end{itemize}\n\\end{exercise*}\n\n\\pagebreak\n\n\\begin{theorem}[Gauss-Bonnet]\nLet $ S \\subset \\RR^3 $ be a compact oriented surface, with, a possibly empty, positively oriented boundary. Then\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = 2\\pi\\chi\\br{S}, $$\nwhere $ \\chi $ is the Euler characteristic. If $ \\partial S = \\emptyset $, then\n$$ \\intd{S}{}{\\K}{A} = 2\\pi\\chi\\br{S}. $$\n\\end{theorem}\n\n\\begin{proof}\nTriangulate $ S $, so\n$$ S = \\bigcup_{i = 1}^N T_i, $$\nwhere $ T_i $ is a curvilinear triangle with exterior angles $ \\theta_{ij} $ for $ 1 \\le j \\le 3 $. Set the interior angles $ \\alpha_{ij} = \\pi - \\theta_{ij} $. Then\n$$ \\intd{T_i}{}{\\K}{A} + \\intd{\\partial T_i}{}{\\k_g}{s} = 2\\pi - \\sum_{j = 1}^3 \\theta_{ij} = \\sum_{j = 1}^3 \\alpha_{ij} - \\pi, $$\nby Gauss-Bonnet for $ T_i $. The integral of $ \\k_g $ along the edge $ T_i \\cap T_j $ cancels because it occurs for $ T_i $ and $ T_j $ with opposite signs. All of the interior edges cancel out. At each interior vertex, the interior angles add up to $ 2\\pi $. Boundary edges do not cancel. At boundary vertices, the interior angles sum to $ \\pi $. Adding everything up,\n$$ \\sum_{i = 1}^N \\intd{T_i}{}{\\K}{A} + \\sum_{i = 1}^N \\intd{\\partial T_i}{}{\\k_g}{s} = \\sum_{i = 1}^N \\sum_{j = 1}^3 \\alpha_{ij} - \\sum_{i = 1}^N \\pi, $$\nso\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = 2\\pi V - \\pi\\#\\cbr{\\text{boundary vertices}} - \\pi F. $$\nBut counting edges,\n$$ 3F = \\#\\cbr{\\text{interior edges}} + \\#\\cbr{\\text{boundary edges}} = 2E - \\#\\cbr{\\text{boundary edges}} = 2E - \\#\\cbr{\\text{boundary vertices}}. $$\nSo\n$$ \\intd{S}{}{\\K}{A} + \\intd{\\partial S}{}{\\k_g}{s} = 2\\pi\\br{V + F} - \\pi\\br{3F + \\#\\cbr{\\text{boundary vertices}}} = 2\\pi\\br{V - E + F}. $$\n\\end{proof}\n\n\\begin{corollary}\nLet $ S \\subset \\RR^3 $ be a compact oriented surface with $ \\partial S = \\emptyset $, such that $ \\K \\ge 0 $ on $ S $. Then $ S \\cong \\S^2 $.\n\\end{corollary}\n\n\\begin{proof}\nThere exists some point with $ \\K > 0 $ because there exists an elliptic point on $ S $, so\n$$ \\chi\\br{S} = \\dfrac{1}{2\\pi}\\intd{S}{}{\\K}{A} > 0. $$\nBut $ \\chi\\br{S} = 2 - 2g $ with $ g $ the genus and so $ g = 0 $ because $ \\chi\\br{S} > 0 $.\n\\end{proof}\n\n\\end{document}", "meta": {"hexsha": "af1b55b5b3ec332b8a4d5c92af83d894e6056421", "size": 119425, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "M3P5 Geometry of Curves and Surfaces/M3P5.tex", "max_stars_repo_name": "icl-notes/GANT", "max_stars_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "M3P5 Geometry of Curves and Surfaces/M3P5.tex", "max_issues_repo_name": "icl-notes/GANT", "max_issues_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "M3P5 Geometry of Curves and Surfaces/M3P5.tex", "max_forks_repo_name": "icl-notes/GANT", "max_forks_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-02-23T20:00:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-13T18:41:07.000Z", "avg_line_length": 59.2092216163, "max_line_length": 810, "alphanum_fraction": 0.5793761775, "num_tokens": 53182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4444854839137021}}
{"text": "\\newcommand{\\Val}{\\fun{Val}}\n\\newcommand{\\POV}[2]{\\ensuremath{\\mathsf{PresOfVal}(#1, \\mathsf{#2})}}\n\n\\section{Properties}\n\\label{sec:properties}\n\nThe properties of this section are modifications and additions to the properties of the Shelley ledger. See \\cite{shelley_spec} for definitions used here. We need to amend the definition of $\\Val$ to the following:\n\n\\begin{equation*}\n    \\Val(x \\in \\Value) = x\n\\end{equation*}\n\\begin{equation*}\n    \\Val(x \\in \\Coin) = \\fun{inject}~x\n\\end{equation*}\n\\begin{equation*}\n    \\Val((\\wcard\\mapsto (y \\in \\Value))^{*}) = \\sum y\n\\end{equation*}\n\n\\begin{lemma}\n  \\label{lemma:utxo-pres-of-value}\n  For all environments $e$, transactions $t$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{utxo}{t}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) + wm = \\Val(s')\n  \\end{equation*}\n  where $wm = \\fun{inject} (\\fun{wbalance}~(\\fun{txwdrls}~{t})) + \\fun{mint}~(\\fun{txbody}~{t})$.\n\\end{lemma}\n\\begin{proof}\n  The proof is identical to the corresponding one in the previous\n  specification, except that unfolding $\\fun{consumed}$ gives an\n  additional $\\fun{mint}~{txb}$ term and all $\\Coin$ quantities have\n  to be converted to $\\Value$.\n\\end{proof}\n\nWe also need to track the sum of the $\\fun{mint}$ fields of all\ntransactions in a block, for which we write $\\fun{mint}(b)$.\n\n\\begin{theorem}[Preservation of Value]\n  \\label{thm:chain-pres-of-value}\n  For all environments $e$, blocks $b$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{chain}{b}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) + \\fun{mint}(b) = \\Val(s')\n  \\end{equation*}\n\\end{theorem}\n\\begin{proof}\n  Similar to the corresponding proof in the Shelley specification,\n  for a given $x$ and transition $\\mathsf{TR}$, let \\POV{x, TR}\n  be the statement:\n\n  \\begin{tabular}{l}\n    for all environments $e$, signals $\\sigma$, and states $s$, $s'$,\n    $$\n    $e\\vdash s\\trans{tr}{\\sigma}s'~\\implies~\\Val(s) + x = \\Val(s')$.\n    $$\n  \\end{tabular}\n  \\noindent\n  Then, \\POV{\\fun{mint}~{txb}}{LEDGER} follows from\n  Lemma~\\ref{lemma:utxo-pres-of-value}.  By induction, we have \\\\\n  \\POV{\\fun{mint}(b)}{LEDGERS}. The rest of the proof works as\n  previously, using \\POV{0}{TR} or \\POV{\\fun{mint}(b)}{TR} as needed.\n\\end{proof}\n\n\\begin{theorem}[Preservation of Ada]\n  \\label{thm:chain-pres-of-ada}\n  For all environments $e$, blocks $b$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{chain}{b}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\fun{coin}(\\Val(s)) = \\fun{coin}(\\Val(s'))\n  \\end{equation*}\n\\end{theorem}\n\\begin{proof}\n  The hypothesis implies that for all transactions $tx$ included in\n  $b$, there exist some $e_{tx}, s_{tx}$ and $s'_{tx}$ such that\n  $e_{tx}\\vdash s_{tx}\\trans{utxo}{tx}s'_{tx}$, so\n  $\\fun{coin}(\\fun{mint}~tx) = 0$ for all transactions included\n  in $b$. This implies $\\fun{coin}(\\fun{mint}(b)) = 0$, so the\n  claim follows by Lemma~\\ref{thm:chain-pres-of-value}.\n\\end{proof}", "meta": {"hexsha": "6084defbfe2d605dc807d87ee2fab0a5c71352e3", "size": 2981, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "shelley-ma/formal-spec/properties.tex", "max_stars_repo_name": "ilap/cardano-ledger-specs", "max_stars_repo_head_hexsha": "6474f68b24d05175fc3fd44a9bdfa95bda703a25", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-30T14:19:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-30T14:19:54.000Z", "max_issues_repo_path": "shelley-ma/formal-spec/properties.tex", "max_issues_repo_name": "ilap/cardano-ledger-specs", "max_issues_repo_head_hexsha": "6474f68b24d05175fc3fd44a9bdfa95bda703a25", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "shelley-ma/formal-spec/properties.tex", "max_forks_repo_name": "ilap/cardano-ledger-specs", "max_forks_repo_head_hexsha": "6474f68b24d05175fc3fd44a9bdfa95bda703a25", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.875, "max_line_length": 214, "alphanum_fraction": 0.6538074472, "num_tokens": 1058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4444810222940209}}
{"text": " %++++++++++++++++++++++++++++++++++++++++\n\\documentclass[letterpaper,12pt]{article}\n\\usepackage{tabularx} \n\\usepackage{amsmath}  \n\\usepackage{graphicx} \n\\usepackage[margin=1in,letterpaper]{geometry} \n\\usepackage{cite} \n\\usepackage[final]{hyperref} \n\\hypersetup{\n    colorlinks=true,     \n    linkcolor=blue,      \n    citecolor=blue,        \n    filecolor=magenta,     \n    urlcolor=blue         \n}\n%++++++++++++++++++++++++++++++++++++++++\n\n\n\\begin{document}\n\n\\title{A Brief Exploration of the NBA Draft}\n\\author{Mike \"dirty-mike\" Neuder}\n\\date{\\today}\n\\maketitle\n\n\\begin{abstract}\nThis quick analysis of the NBA draft was inspired and written for Phil Derbesy and Michael Chiappini of the exceptional podcast, \"The Basketball Guyaries\". During Episode 4, they are exploring the complexity of the current NBA draft, and ask for a bit of clarification on the probabilities going on to determine the order of picks. With the 2017 Draft just occurring, it seemed appropriate to take a glance at the process and learn more about how 14 ping-pong balls can change everything.\n\\end{abstract}\n\n\\section{Current Lottery System}\nThe current weighted lottery system was implemented in 1990 and reformed in 1993. The system was changed due to teams allegedly losing games intentionally during the near the end of the season in order to secure the first pick in the draft, as the team with the worst record of the season got the first pick. In the new weighted lottery system, the teams with the worst records still have the highest chance to pick early in the draft, however there is an element of randomness introduced in order to make it less appealing to be the worst team in the NBA. Currently, with 30 teams in the NBA, 16 will qualify for the playoffs and the remaining 14 are eligible to participate in the lottery. Since 1987, only the first three picks are determined by the lottery, and the remaining picks are done in reverse record order. Under this current system, the worst team of the previous season at least would be picking fourth in the draft, while the second worst team would choose at latest fifth and so forth. Now that the stage is set, lets look at how it works. \n\n\\section{A Bit of Math}\nThe first three picks are determined by a random selection of ping-pong balls numbered one through fourteen.  These balls are put into a lottery machine, and four are selected at random. Because order doesn't matter, (i.e. $5,6,7,8 = 5,7,6,8 = 5,8,7,6 = etc$), the total number of combinations is 1001. We can calculate by recalling our Algebra 2 formula for combinations, where $n$ is the total number of items, and $r$ is how many we want to select while ignoring order. \n$$ \\binom{n}{r} = \\frac{n!}{r!\\cdot(n-r)!}$$ \\newpage\nIn this context, we say we have 14 choose 4 combinations of ping-pong balls and by using our handy formula we can conclude that the number of combinations is,\n$$\\binom{14}{4} = \\frac{14!}{4!\\cdot(14-4)!} = \\frac{87178291200}{24 \\cdot 3628800} = 1001.$$\nOut of all these combinations, only one isn't assigned to a team ($11,12,13,14$). The remaining 1000 combinations are distributed among the 14 non-playoff teams based on their regular season record according to the table below. Note that the rank column is in reverse order (worst team is ranked 1 and so forth). \n\n\\begin{center}\n\\begin{tabular}{ |c|c|c| }\n \\hline\n rank & number of combinations & probability of being drawn \\\\ \n \\hline\n 1 & 250 & 0.2498 \\\\ \n 2 & 199 & 0.1988 \\\\ \n 3 & 156 & 0.1558 \\\\ \n 4 & 119 & 0.1189 \\\\ \n 5 & 88 & 0.0879 \\\\ \n 6 & 63 & 0.0629 \\\\ \n 7 & 43 & 0.0429 \\\\ \n 8 & 28 & 0.0280 \\\\ \n 9 & 17 & 0.0170 \\\\ \n 10 & 11 & 0.0110 \\\\ \n 11 & 8 & 0.0080 \\\\ \n 12 & 7 & 0.0070 \\\\ \n 13 & 6 & 0.0060 \\\\ \n 14 & 5 & 0.0050 \\\\ \n \\hline\n\\end{tabular}\n\\end{center}\n\nIt is clear that as the better teams in the lottery have a pretty slim chance at landing a top pick. Another interesting thing to note is that if the 14th worst team in the league doesn't get one of the first three picks, they are locked into receiving the 14th pick, due to the fact that after the first three picks the selections are given in reverse record order. One last thing to examine is the probabilities of each team earning a specific pick. Note that in the table below, a cell with a '-' implies that this team cannot receive this pick.\n\\begin{center}\n\\includegraphics[scale=0.6]{../images/table.png} \n\\end{center} \\newpage\n\nIn order to better visualize these probabilities I created a couple plots displayed below. The first plot shows a given teams probability of receiving any of the first fourteen draft slots.\n\\begin{center}\n\\includegraphics[scale=0.5]{../images/plot1.png} \n\\end{center}\n\nI found it interesting that as you move farther into the draft the teams are have more certainty around which pick they will be receiving. The next plot I created is quite similar, but instead of plotting the probability of a team receiving a pick, it displays the probability that a team will have picked by the $n^{th}$ slot of the draft. For example, team 1 will have .250 chance of having picked after round 1, and after round two they will have $.250 + .215 = .465$ chance of having picked.\n\n\\begin{center}\n\\includegraphics[scale=0.5]{../images/plot2.png} \n\\end{center} \\newpage\n\nAs expected, one team per round will reach a probability having picked of 1. This is due to the fact that the worst slot the rank 1 team can be assigned is fourth, and the result follows for the remaining teams. \n\n\\section{Conclusions}\nIn a sport dominated by superstars, securing strong draft picks is hugely important for NBA teams. Though the process is complicated and long, it is nice to know that in a world where control is paramount, a little bit of randomness can turn expectation on its head. Thanks for reading.\\begin{footnote}{ if you are interested in seeing how i collected and plotted the data or want to play around with any of the files they are being hosted \\href{https://github.com/michaelneuder/nba_draft}{here}. if you find any errors or have any questions feel free to get in touch.}\\end{footnote} \\\\ \\\\ \n-dirty mike\n\n\n\\newpage\n\\begin{thebibliography}{99}\n\n\\bibitem{melissinos}\n\\url{https://en.wikipedia.org/wiki/NBA_draft_lottery}\n\n\\bibitem{Cyr}\n\\url{http://www.nba.com/news/draft/nba-draft-lottery-what-will-happen-2016/}\n\n\\bibitem{Wiki} \n\\url{https://www.sbnation.com/nba/2017/4/13/15268144/nba-draft-lottery-odds-2017-lakers-celtics-suns}\n\n\\end{thebibliography}\n\n\n\\end{document}\n", "meta": {"hexsha": "d1872651b80ec65ec66dda435e7797bf809a2365", "size": 6454, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex_files/draft_analysis.tex", "max_stars_repo_name": "michaelneuder/nba_draft", "max_stars_repo_head_hexsha": "f2069c49f0dbce91a58c32bd99e51a7b0cd8559f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-08-07T23:34:59.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-07T23:34:59.000Z", "max_issues_repo_path": "tex_files/draft_analysis.tex", "max_issues_repo_name": "michaelneuder/nba_draft", "max_issues_repo_head_hexsha": "f2069c49f0dbce91a58c32bd99e51a7b0cd8559f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex_files/draft_analysis.tex", "max_forks_repo_name": "michaelneuder/nba_draft", "max_forks_repo_head_hexsha": "f2069c49f0dbce91a58c32bd99e51a7b0cd8559f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.2745098039, "max_line_length": 1057, "alphanum_fraction": 0.7392314844, "num_tokens": 1724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.7799929104825006, "lm_q1q2_score": 0.444481016726747}}
{"text": "%\\section{Physical Human Factors Report: Tristan Griffith}\n\\rhead{\\today}\n\\begin{center}\n{\\large  Tristan Griffith}\\\\\n\\vspace{2mm}\n{\\large Dr. James Hubbard Jr.}\n\\noindent\\rule{\\textwidth}{2pt}\n\\end{center}\n\\setcounter{section}{1}\n\n%\\begin{wrapfigure}{r}{0.45\\textwidth}\n%\\centering\n%\\includegraphics[scale=.3]{../../../figures/demo_map.png} \n%\\caption{Modal Heatmap for Subject 32}\n%\\end{wrapfigure}\n\\subsection{Motivation}\nIn the past months, we have become very comfortable converting EEG signals into state space models using output only system identification techniques. As it stands, these models are somewhat useful for biometric classification and analysis, but have not been extended to the quantum domain, which is a desired outcome of our research. The principle barrier preventing the application of quantum probability to these models is the restrictive formulation of the quantum Hilbert space itself, which among other things, requires the state matrix to take the form $-iH$, where $H$ is a self-adjoint matrix. The self-adjoint structure is especially important in quantum probability, because it preserves the norm of the initial condition $\\big(||x_0||=||x(t)||\\big)$ as the system evolves, ensuring the state vector is still a probability distribution over the possible collapse states.\n\nPhysical systems of the form $\\dot{x}=Ax+Bu $ rarely have this much structure in their state matrices, so modern system identification techniques do not provide means to directly estimate a self-adjoint matrix from a set of black box measurements. An additional technique is required to convert models generated from these system identification techniques to quantum models robustly, with minimal loss of information. We previously found that generating the self-adjoint matrix as $A_h=\\frac{1}{2}(A \\pm A^T)$  was removing as much as half the information in the original matrix $A$ as measured by the induced metric. \n\\subsection{Problem Statement}\nModern system identification techniques do not allow for the discovery of quantum-like models as the eigenvalues identified from the black box system are not restricted to quantum eigenvalues. Therefore, additional methods are needed to convert these existing system identification state space models into quantum state space models with the accompanying mathematical structure.\n\\subsection{The Hadamard Transform Applied to EEG Modes}\n\\subsubsection{Transform Basics}\n\\label{sec:basics}\nThe Hadamard transform is the most common method for decomposing signals into a set of orthogonal functions that are not trigonometric which are a specific form of Walsh function. The Hadamard transform is analogous to the Fourier transform, but uses orthogonal square waves instead of sines and cosines. A comparison of the first eight Fourier functions and first eight Hadamard functions is in Figure \\ref{fig:hf_comp}.\n\\begin{figure}[]\n    \\centering\n    \\includegraphics[scale=0.5]{../../../figures/func_comp.png} \n    \\caption{Fourier vs. Hadamard Base Functions}\n    \\label{fig:hf_comp}\n\\end{figure}\nThe Hadmard transform has been popular in algorithmic applications, because the nature of square waveforms can be described by a recursive relationship that is easily carried out by computers. The Hadamard transform requires less computational complexity to decompose a given signal into its Walsh functions. The Hadamard transform may be computed with the following recursive function:\n\\begin{align}\nH_1 &\\equiv \\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n1 & 1\\\\ 1 & -1\n\\end{bmatrix} \\label{eqn:hada1} \\\\\nH_n=H_1 \\otimes H_{n-1}=&\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\nH_{n-1} & H_{n-1}\\\\ H_{n-1} & -H_{n-1}\n\\end{bmatrix}\n\\end{align}\nIntuitively, equation \\ref{eqn:hada1} represents the first two functions in the Walsh function set for the Hadamard transform. The first is a straight line with value one. It has no transition across the origin from 1 to -1, so it does not have any sign changes in its column. The second column corresponds to a function with a single transition from 1 to -1, represented by a single sign change in the column. Higher and higher order Hadamard transforms can be easily determined. The Hadamard matrix corresponding to Figure \\ref{fig:hf_comp} is:\n\\begin{align}\nH_8=\\left(\\begin{array}{cccccccc} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\\\ 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1\\\\ 1 & 1 & -1 & -1 & 1 & 1 & -1 & -1\\\\ 1 & -1 & -1 & 1 & 1 & -1 & -1 & 1\\\\ 1 & 1 & 1 & 1 & -1 & -1 & -1 & -1\\\\ 1 & -1 & 1 & -1 & -1 & 1 & -1 & 1\\\\ 1 & 1 & -1 & -1 & -1 & -1 & 1 & 1\\\\ 1 & -1 & -1 & 1 & -1 & 1 & 1 & -1 \\end{array}\\right) \\label{eqn:h8}\n\\end{align}\nNotice that the ordering of the columns in equation \\ref{eqn:h8} is not ordered from least to most transitions, but that the constant 1 function is immediately followed by the square wave with the maximum number of transitions. These columns may be reordered for convenience or interpretation. Ordering in terms of number of transitions is known as sequency ordering, as in Figure \\ref{fig:hf_comp}, and is most commonly found in signal processing applications.  Hadamard ordering, which is used in controls applications, arranges them as 0, 4, 6, 2, 3, 7, 5, 1. Dyadic or gray code ordering, which is used in mathematics, arranges them as 0, 1, 3, 2, 6, 7, 5, 4.\n\\begin{figure}[]\n    \\centering\n    \\includegraphics[scale=0.5]{../../../figures/wht_waveform_1.png} \n    \\caption{Hadamard vs. Sequency Ordering}\n    \\label{fig:ordering}\n\\end{figure}\nKeeping track of which ordering method an algorithm uses is critical. The Discrete Walsh Hadamard Transform (DWHT) had been widely used for biometric identification, data compression, and image segmentation. Figure \\ref{fig:comp} demonstrates how the DWHT, along with the Discrete Cosine Transform (DCT), are better suited to image compression that traditional methods centered on the Discrete Fourier Transform (DFT) \\cite{bull2014communicating}.\n\\begin{figure}[]\n    \\centering\n    \\includegraphics[scale=0.7]{../../../figures/hada_example.jpg} \n    \\caption{Comparison of Decomposition Methods}\n    \\label{fig:comp}\n\\end{figure}\nNotice that the DWHT and DCT concentrate their high energy areas in a single corner, unlike the DFT. This makes it much easier to set a cutoff point for image compression. \n\\subsubsection{Hadamard Logic Gates}\nNothing in the previous section indicates that the Hadamard transform is better suited to application on quantum cognitive models than any other decomposition method. The Hadamard transform piqued our interest due to its relevance in both signal processing and quantum logic gate operations. Hadamard Gates are often used as the first step in a proposed quantum algorithm. They have the neat property of smearing the initial condition into a superposition of all possible states evenly in a given quantum probability space.\n\nFor example, if we are working in a two dimensional space, such as that of qubits, we may have an initial state:\n\\begin{align}\nx_0=\\begin{bmatrix}\n1 \\\\ 0\n\\end{bmatrix}\n\\end{align}\nIf we pass this initial state through a Hadamard Gate, it becomes:\n\\begin{align}\nH x_0=x_0'\\\\\n\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n1 & 1\\\\1 & -1\n\\end{bmatrix}\\begin{bmatrix}\n1 \\\\ 0\n\\end{bmatrix}=\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n1 \\\\ 1\n\\end{bmatrix}\n\\end{align}\nBefore passing the initial condition through the Hadamard gate, the system was in a prepared state. After passing through the gate, the probability distribution is evenly distributed over both possible measurement outcomes. Notice that it is very important to carry the normalizing term along with the Hadamard matrix so that it is a unitary transform. This is true for systems of higher order, of course:\n\\begin{align}\nx_0=\\begin{bmatrix}\n0 \\\\ 1 \\\\ 0 \\\\0 \n\\end{bmatrix}\\\\\nx_0'=\\frac{1}{2}\\left(\\begin{array}{cccc} 1 & 1 & 1 & 1\\\\ 1 & -1 & 1 & -1\\\\ 1 & 1 & -1 & -1\\\\ 1 & -1 & -1 & 1 \\end{array}\\right)\\begin{bmatrix}\n0 \\\\ 1 \\\\ 0 \\\\0 \n\\end{bmatrix}=\\frac{1}{2}\\begin{bmatrix}\n1 \\\\ -1 \\\\1\\\\-1\n\\end{bmatrix}\n\\end{align}\nAnd so on and so on. For algorithms where we expect a certain outcome regardless of initial conditions, this is a quick method to remove potential bias in the preparation of the quantum state. Notice further that this process is reversible, and we can recover $x_0$ from $x_0'$.\n\\subsubsection{``Quantumness'' of OMA and Hadamard Modes}\nSo we've established an intuitive connection to the Hadamard transform. It's useful in signal processing and in quantum probability, so it may get us closer to a probabilistic model of cognition. We may look at the resultant state space model from our operational modal analysis on EEG data $A_{OMA}$. $A_{OMA}$ has complex eigevalues and eigenvectors. Further, the eigenvectors are not orthogonal. Quantum state Hamiltonian matricies are known to have only real valued eigenvalues with corresponding orthogonal eigenvectors which represent the basic observables in the quantum model. We may Hadamard transform $A_{OMA}$:\n\\begin{align}\nA_{h}=HA_{OMA}\n\\end{align}\nThe resultant matrix has real valued eigenvalues, which gets us a little closer to a quantum Hamiltonian. Regardless of the ordering, however, the eigenvectors of $A_h$ are not orthogonal unless the original eigenvalues of $A_{OMA}$ were orthogonal to begin with. \n\nA computational example illustrates this point. The identify matrix has orthogonal eigenvectors beforehand:\n\\begin{align}\n\\phi_0(I)=\\begin{bmatrix}\n1 \\\\0\n\\end{bmatrix},\\begin{bmatrix}\n0 \\\\ 1\n\\end{bmatrix}\\\\\nI_{h}=HI\\\\\nI_{h}=\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n1 & 1\\\\1 & -1\n\\end{bmatrix}\\begin{bmatrix}\n1 & 0\\\\0 & 1\n\\end{bmatrix}\\\\\n\\lambda_{I_h}=\\pm 1\\\\\n\\phi=\\begin{bmatrix}\n1 \\pm \\sqrt{2} \\\\ 1\n\\end{bmatrix}\n\\end{align}\nWhile $I_h$ has different eigenvectors than $I$, they remain orthogonal. Conversely, if we consider an example 2x2 matrix from our OMA analysis:\n\\begin{align}\nA_{OMA}=\\left(\\begin{array}{cc} 0.728 & 0.345\\\\ -0.378 & 0.923 \\end{array}\\right)\\\\\n\\phi_0(A_{OMA})=\\left(\\begin{array}{cc} 0.186-0.665{}\\mathrm{i} & 0.186+0.665{}\\mathrm{i}\\\\ 0.723 & 0.723 \\end{array}\\right) \\label{eqn:phiA}\n\\end{align}\nFrom equation \\ref{eqn:phiA}, it can be seen that the eigenvectors are not orthogonal.\n\\begin{align}\nA_{h}=HA_{OMA}\\\\\nA_{h}=\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n1 & 1\\\\1 & -1\n\\end{bmatrix}A_{OMA}\\approx \\left(\\begin{array}{cc} 0.248 & 0.896\\\\ 0.782 & -0.409 \\end{array}\\right)\\\\\n\\lambda_{A_h}=0.819,-0.980\\\\\n\\phi(A_h)=\\left(\\begin{array}{cc} 0.843 & -0.59\\\\ 0.537 & 0.808 \\end{array}\\right)\n\\end{align}\nA few things to note here:\n\\begin{itemize}\n\\item Neither $A_{OMA}$, or $A_h$ have orthogonal eigenvectors\n\\item $A_h$ has eigenvalues in the right half plane (unstable poles)\n\\item Unlike $A_{OMA}$, notice that $A_h\\approx A_h^*$\n\\end{itemize}\nTherefore, we have to conclude that the Hadamard transform doesn't get us all the way to a quantum Hamiltonian. However, I notice that it provides wholly real eigenvalues, which is a step closer to quantum. Further, the state matrix is almost self-adjoint, and looks to me like some of the noisy state matrices I used to develop the earlier \\href{https://drive.google.com/file/d/17kZl22Yy5hwzDv9F1psR9IAmViYwAzik/view?usp=sharing}{least squares SINDy like Hamiltonian estimator}. Perhaps we can go one more step, using the SINDy algorithm to get to a quantum Hamiltonian. \n\\subsubsection{Least Squares to Nearest Hamiltonian}\nSo far, we've shown that the Hadamard transform, while getting us closer to a quantum Hamiltonian, does not totally complete the path from EEG signals to quantum probability space. \n\n\\textcolor{red}{Ok. So this was a nice idea. I could be further developed. However, as I'm looking at the linear systems side of things, we have issues.} Primarily, with the transform taking the form $A_{h}=HA_{OMA}$, the transform is operating on the state matrix, not on the vector. Normally a transform is defined as:\n\\begin{align}\n\\bar{x}=Tx\\\\\n\\bar{\\dot{x}}=T\\dot{x}\\\\\n\\dot{x}=Ax\\\\\nT^{-1}\\bar{\\dot{x}}=AT^{-1}\\bar{x}\\\\\n\\bar{\\dot{x}}=TAT^{-1}\\bar{x}\\\\\n\\end{align}\nHowever, I did something different:\n\\begin{align}\n\\bar{x}=HA\\dot{x}\n\\end{align}\nSince the operation was applied on the state matrix and not on the state vector, the thing you are differentiating in $\\dot{x}$ and the result of $\\bar{x}$ aren't the same. After consulting with Dr. Balas (2020-11-05), I'm not aware of other transforms like that, and I've destroyed the meaning or use of the state transition matrix $\\Phi$. Even though $\\bar{x}$ is in a quantum space, $\\dot{x}$ is still in the measure space. I may abandon this for the time being and take a look at some other methods. Argh so close. \n\\subsubsection{Reachability?}\nI would have shown that the use of the least squares estimator averages the distance between the off diagonal components, and that introduces an interval for reachability. \n\\subsection{Results}\n\\subsubsection{A Quantum Hamiltonian}\n\\subsubsection{Interpretation of Model}\n\n\\subsection{Discussion}\n\n\n\n\n%\\begin{displayquote}\n%The class of monotone DNF expressions is learnable via an algorithm $B$ that uses $L=L(h,d)$ calls of examples and $dt$ calls of oracle, where $d$ is the degree of the DNF expression $f$ to be learnt and $t$ the number of variables.\n%\\end{displayquote}\n\n\n%\\begin{wrapfigure}{r}{0.55\\textwidth}\n%\\centering\n%\\includegraphics[scale=.5]{../figures/complexity.png} \n%\\caption{The Error-Complexity Trade Off}\n%\\end{wrapfigure}\n\n", "meta": {"hexsha": "100bb9a3850f79d636dfc8dd09fb96eb931f9364", "size": 13347, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/hadamard/latex_format/sections/summary.tex", "max_stars_repo_name": "tdgriffith/OoMA-omniscient", "max_stars_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/hadamard/latex_format/sections/summary.tex", "max_issues_repo_name": "tdgriffith/OoMA-omniscient", "max_issues_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/hadamard/latex_format/sections/summary.tex", "max_forks_repo_name": "tdgriffith/OoMA-omniscient", "max_forks_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.8352272727, "max_line_length": 881, "alphanum_fraction": 0.7514048101, "num_tokens": 3713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4444810164653434}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{setspace}\n\\usepackage{pxfonts}\n\\usepackage{graphicx}\n\\usepackage{geometry}\n\n\\geometry{letterpaper,left=.5in,right=.5in,top=0in,bottom=.75in,headsep=5pt,footskip=20pt}\n\n\\title{Problem Set 3 -- Integrate-and-fire neuron model}\n\\author{Computational Neuroscience Summer Program}\n\\date{June, 2011}\n\n\\begin{document}\n\\maketitle\n\nIn this problem set you will be building a simple integrate-and-fire\nneuron.  You should assume a specific membrane capacitance of\n$c_m = 10$ nF/mm\\textsuperscript{2}, a specific membrane resistance of\n$r_m = 1$ M$\\Omega\\cdot$mm\\textsuperscript{2}, a resting membrane\npotential of $E = -70$ mV, a reset potential of $V_{reset} = -80$ mV,\nan action potential threshold of $V_{threshold} = -55$ mV, and a cell\nsurface area of $A = 0.025$ mm\\textsuperscript{2}.  Write up your results in\na text editor of your choosing.  Include any relevant figures, your\nMatlab code, and any other calculations related to the problem set.  You may work individually or in groups, but each student should hand in their own report.\n\n\\subsection*{Equations}\n\n\\begin{center}\n\\begin{tabular}{ll}\n$C_m = A \\cdot c_m$ & $R_m = \\frac{r_m}{A}$\\tabularnewline\n$\\tau_m = c_m \\cdot r_m$ & $V_\\infty = E + R_mI_{ext}$\\tabularnewline\n$V(t) = V_\\infty + (V(0) - V_\\infty)e^\\frac{-t}{\\tau_m}$ & $r_{isi} =\n(\\tau_m \\mathrm{ln}(\\frac{R_mI_{ext} + E - V_{reset}}{R_mI_{ext} + E -\n  V_{threshold}}))^{-1}$\\tabularnewline\n$\\tau_m\\frac{dV}{dt} = E - V(t-1) + R_mI_{ext}$ & \\tabularnewline\n\\end{tabular}\n\\end{center}\n\n\\subsection*{Problems}\n\n\\paragraph{1.} Model an integrate-and-fire neuron using the equations\nabove and the following rule: when the neuron's membrane voltage exceeds\n$V_{threshold}$, set the voltage in that timestep to $V_{peak} = 40$ mV, and in the\nnext timestep set the voltage to $V_{reset}$.  Set $dt = 0.1$ ms.  Apply a square pulse of\n0.5 nA from $t = 250$ ms until $t = 750$ ms in your simulation.  Use\nMatlab's subplot command to plot the membrane voltage over time in the\ntop panel and $I_{ext}$ in the bottom panel (use the same time scale\nfor the horizontal axis of both plots).  No text is required for this\nquestion; just include a plot.\n\n\\paragraph{2.} Compute the average firing rate (spikes per second) of the integrate-and-fire neuron\nfor the pulse interval you used in quesion 1 (500 ms).  Now plot simulated firing rate vs $r_{isi}$ for several values of $I_{ext}$ (use $I_{ext}$ between 0 and 1 nA).  How does the firing rate of the modeled neuron compare to the estimated firing\nrate given by $r_{isi}$?  Note: the equation for $r_{isi}$ only holds if $V_\\infty > V_{thresh}$; otherwise, $r_{isi} = 0$.\n\n\\paragraph{3.}  Starting from 0 nA, gradually increase the amount of external current\ninjected into the integrate-and-fire neuron in steps of 0.01 nA.  Keep the pulse duration constant at 500 ms.  What is the smallest amount of current you\ncan inject which will still result in an action potential?  Is there a\nmaximum firing rate this neuron can achieve?  Why or why not?\n\n\\paragraph{4.  Challenge problem.} Compute firing rate as a function of pulse duration, $I_{duration}$, using 20 durations between 10 and 500 ms.  Repeat this for several different values of $I_{ext}$ (try using 10 log-spaced values between 0.1 and 5 nA).  Explain what you see.  In particular, are the firing rate curves smooth or jagged?  Why?\n\n\\paragraph{5.} Vary the resting potential, specific\ncapacitance, specific resistance, and surface area variables.  How do\nincreases or decreases in these values affect firing rate of the integrate-and-fire neuron?  Explain\n(try to stay at or under 1-2 sentences per variable).  Include plots for each of these variables.\n\n\n\\end{document}\n\n", "meta": {"hexsha": "1d669e0417c2116b2f8d455f7649ad09f144bca2", "size": 3729, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple.tex", "max_stars_repo_name": "ContextLab/computational-neuroscience", "max_stars_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2018-01-22T21:51:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T20:44:42.000Z", "max_issues_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple.tex", "max_issues_repo_name": "ContextLab/computational-neuroscience", "max_issues_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-10-31T02:19:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-31T14:03:00.000Z", "max_forks_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple.tex", "max_forks_repo_name": "ContextLab/computational-neuroscience", "max_forks_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-08-11T20:56:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-24T09:23:11.000Z", "avg_line_length": 53.2714285714, "max_line_length": 345, "alphanum_fraction": 0.7412174846, "num_tokens": 1106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8128673110375457, "lm_q1q2_score": 0.44442557144537004}}
{"text": "\\section{Introduction}\n\n\\begin{fullwidth}\n\nPursuing abstractness and generality, a number of books and articles in\neconometrics rely heavily on standard algebraic proofs.\nHowever, most of the theorems proved in such a way have a strong geometric appeal.\nThis paper demonstrates how shorter, less technical and even more beautiful the proofs\ncan be when they are based on geometric theorems.\nWe show that this technique can be extended to explain\nconcepts in probability and statistics.\n\nAlthough most of the theorems and ideas are not completely new and\nthere are even a few works on the geometry in econometrics and statistics,\nthis paper introduces alternative explanations and more general results in some cases.\nFurther, there are algebraic proofs provided parallel to geometric ones\nand illustrations which are our own work.\nThe illustrations are published at \\url{https://github.com/olyagnilova/gauss-markov-pythagoras} and licensed under the\nCreative Commons Attribution 4.0. % todo: wiki\nThey are free to use and have the potential to serve as a pedagogical tool\nin explaining material for students.\n\nOther researchers have done similar work, an especially\nthought-provoking and motivating paper was\n\\citeauthor{cobb2011teaching}.\nThe geometric proof of the Gauss-Markov theorem and the introduction of the Herschel-Maxwell approach are inspired by\n\\citeauthor{cobb2011teaching}'s work.\n\\citeauthor{jacobson}'s (\\citeyear{jacobson}) thesis \\citetitle{jacobson}\nis a comprehensive overview of a geometric approach in linear models including\nstatistical foundations.\n\\citeauthor{gmt_blue}’s (\\citeyear{gmt_blue}) text \\citetitle{gmt_blue} and\n\\citetitle{gmt_american_statistician} by\n\\citeauthor{gmt_american_statistician} (\\citeyear{gmt_american_statistician}) were helpful when thinking over\nalternative ways of proving this central theorem of econometrics.\nThe works that deepened our understanding of instrumental variables included\n\\citeauthor{Butler2016}'s (\\citeyear{Butler2016}) \\citetitle{Butler2016}\nand \\href{http://web.hku.hk/~pingyu/6005/6005.htm}{lecture notes} on Econometric theory 1 course by Ping Yu.\nThe first work that proves the Frisch-Waugh-Lovell theorem using pure geometry\nis \\citetitle{fwl} by\n\\citeauthor{fwl} (\\citeyear{fwl}).\nFinally, there were several works that apply the geometric approach to\nhypothesis testing. They are\n\\citetitle{Langsrud2004}\nby \\citeauthor{Langsrud2004} (\\citeyear{Langsrud2004}),\n\\citetitle{Siniksaran2005}\nby \\citeauthor{Siniksaran2005} (\\citeyear{Siniksaran2005}),\nand one which uses an unusual approach —\n\\citetitle{friendly2013}\nby \\citeauthor{friendly2013} (\\citeyear{friendly2013}).\n\nThe paper has four parts. In the first the fundamentls of the geometry\nof random variables are introduced with examples.\nIn part two, we develop the ideas related to linear regressions\nfrom the ideas which need almost no assumptions to more sophisticated theorems\nand concepts.\nThe third part is devoted to partial correlations. It contains a proof of\na newly-introduced fact about the partial correlation and the correlation\nbetween the residuals in  alinear regression model.\nFinally, probability distributions are introduced from a geometric perspective\nand hypothesis tests are illustrated.\n\n\\end{fullwidth}\n", "meta": {"hexsha": "fbeac4257bb1a137c786b0fd92c180deb902c3c4", "size": 3264, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/0_intro.tex", "max_stars_repo_name": "olyagnilova/gauss-markov-pythagoras", "max_stars_repo_head_hexsha": "9e2abb700846997576144c77e440f48107bde0d2", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-22T20:38:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-22T20:38:41.000Z", "max_issues_repo_path": "chapters/0_intro.tex", "max_issues_repo_name": "olyagnilova/gauss-markov-pythagoras", "max_issues_repo_head_hexsha": "9e2abb700846997576144c77e440f48107bde0d2", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-06-29T09:11:36.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-28T19:35:55.000Z", "max_forks_repo_path": "chapters/0_intro.tex", "max_forks_repo_name": "olyagnilova/gauss-markov-pythagoras", "max_forks_repo_head_hexsha": "9e2abb700846997576144c77e440f48107bde0d2", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-05-21T18:32:18.000Z", "max_forks_repo_forks_event_max_datetime": "2018-05-21T18:32:18.000Z", "avg_line_length": 51.8095238095, "max_line_length": 118, "alphanum_fraction": 0.8207720588, "num_tokens": 786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8128673110375457, "lm_q1q2_score": 0.44442557144537004}}
{"text": "\\section{\\label{sec:selection}Computing an Execution Schedule}\n\nPredictions of solver performance are useful only if they can be used to\nexecute more appropriate solvers more often. To describe the algorithm\nportfolio situation in decision-theoretic terms, we take our set of past\nobservations---in this case, the solvers already executed on this problem\ninstance, and their success or failure---as our \\emph{belief state}. The\nBellman equation describes the expected reward of an optimal policy, \\[ V^*(s)\n= R(s) + \\max_a \\gamma \\sum_{s'}P(s' | s, a) V^*(s'), \\] where $s$ is a\nparticular belief state, $R(s)$ describes the reward associated with a state\n(here, let $1$ be the reward of any state in which any solver has been\nsuccessful, and $0$ the reward otherwise), $\\gamma$ is an arbitrary discount\nfactor (which can be set lower to prefer quickly-obtained solutions more\nstrongly), $a$ is an action (the execution of some solver for some amount of\ntime), and $P(s'|s,a)$ is the probability of arriving in state $s'$ after\ntaking action $a$ in state $s$.  Since the number of possible belief states\ngrows quickly as actions are taken, the optimal policy is practical to compute\nonly if the portfolio is limited to a short action sequence.\n\nJust such an optimal short sequence of actions was computed offline, using a\nlearned DCM model to define $P$; the {\\tt borg-sat-10.06.07} solver then\nfollows that sequence when solving any new problem instance.\n\n", "meta": {"hexsha": "58c3ef7aedd9cc1dc92750f1b2364f831020de18", "size": 1457, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/description/parts/selection.tex", "max_stars_repo_name": "borg-project/sat-race-borg", "max_stars_repo_head_hexsha": "b0fbd41c91a8f71b3c8aba580734929f21d28e1a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-08-29T15:16:47.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-29T15:16:47.000Z", "max_issues_repo_path": "src/description/parts/selection.tex", "max_issues_repo_name": "borg-project/sat-race-borg", "max_issues_repo_head_hexsha": "b0fbd41c91a8f71b3c8aba580734929f21d28e1a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/description/parts/selection.tex", "max_forks_repo_name": "borg-project/sat-race-borg", "max_forks_repo_head_hexsha": "b0fbd41c91a8f71b3c8aba580734929f21d28e1a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.7083333333, "max_line_length": 78, "alphanum_fraction": 0.765271105, "num_tokens": 363, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.4443711444128164}}
{"text": "\\section{Notation}\n\\label{sec:notation-shelley}\n\n\n\\begin{description}\n  \\item[$\\mathbb{N}$] The (canonical) symbol for the natural numbers\n  \\item[$\\mathbb{H}$] The type of byte strings\n  \\item[Aggregated Addition] Given a type\n  $\\type{FM}~\\in~ \\powerset(\\type{X} \\times \\type{Y})$,\n    where addition is defined on terms of type $\\type{Y}$, and a term $\\var{fm} \\in \\type{FM}$,\n    we overload the $\\sum$ notation as follows:\n    \\[\\sum_{(x, y)\\in\\var{fm}} (x,y) :=\n    \\{ x\\mapsto \\sum_{(x,y)\\in\\var{fm}} y \\} \\]\n\n    In the case $\\type{Y}~=~\\type{A}\\mapsto\\type{B}$ is itself a finite map,\n    and addition is defined on terms of type $\\type{B}$,\n    we interpret\n    \\[\\sum_{(x, (a\\mapsto b))\\in\\var{fm}} (x,a\\mapsto b) :=\n    \\{ x \\mapsto (a\\mapsto \\sum_{(x,a\\mapsto b)\\in\\var{fm}} b) \\} \\]\n\n    We define $\\sum$ on a set of the form\n    \\[\\type{FM} \\subseteq \\{ x \\mapsto y \\vert x \\in \\mathsf{X}, y \\in \\mathsf{Y} \\} \\]\n\n    in a similar way,\n    \\[\\sum_{(x\\mapsto y)\\in\\var{fm}} x \\mapsto y :=\n    \\{ x\\mapsto \\sum_{x\\mapsto y\\in\\var{fm}} y \\} \\]\n\n    We use the $+$ to denote this overloaded addition operation also.\n\n  \\item[Other Operations] Similar to the definition of aggregated addition,\n  other scalar operations are defined on finite maps. This includes multiplication,\n  floor, etc.\n\n  \\item[$\\leq$] This symbol is overloaded to represent the conjunction of the\n  pairwise $\\leq$ comparison of entries with at same index in a list or a vector.\n  Every other comparison symbol is overloaded in a similar way.\n\n\\end{description}\n\\clearpage\n", "meta": {"hexsha": "4c064a5f71bab3c01841cbd63599e1ed560be774", "size": 1557, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "goguen/formal-spec/notation.tex", "max_stars_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_stars_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "goguen/formal-spec/notation.tex", "max_issues_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_issues_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "goguen/formal-spec/notation.tex", "max_forks_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_forks_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.925, "max_line_length": 95, "alphanum_fraction": 0.6486833654, "num_tokens": 519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833893685269, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4443617652521037}}
{"text": "%!TEX root = ../PhD_thesis__Lilian_Besson\n% ******************************* Thesis Appendix B ****************************\n% \\chapter{About another publication: ``What Doubling-Trick Can and Can't Do for Multi-Armed Bandits''}\n\\chapter{About Doubling Tricks for Multi-Armed Bandits}\n\\label{app:2:DoublingTricks}\n\nThis appendix quickly presents the contributions of another publication that was not presented in the main text of this thesis.\nWe studied doubling tricks and their possible uses for multi-armed bandits, between fall 2017 and spring 2018, and we wrote an article \\cite{Besson2018DoublingTricks} which was rejected at the COLT 2018 conference, and unfortunately we lacked the time to improve it and resubmit it to another conference.\n\n% \\TODOL{\n% I cannot include it raw without more work on the maths, we have to write only the best versions of our results.\n\n% But I am interested in including this article in my thesis, mainly because GLRklUCB in Chapter 6 is not anytime!\n\n% I need to try DoublingTrick + GLRklUCB, at least experimentally!\n% For the theoretical analysis, it will probably be a huge failure.\n% }\n\n\\paragraph{Motivations for anytime algorithms.}\n%\nAs introduced in Chapter~\\ref{chapter:2},\nan online reinforcement learning algorithm is \\emph{anytime} if it does not need to know in advance the horizon $T$ of the experiment.\n%\nDepending on the context of the practical application of interest, it might be unrealistic to assume to know in advance $T$. We give two examples to illustrate where this prior knowledge can be realistic or not.\nOn the one hand, consider clinical trials: it is likely that the number of patients is known before starting the trial, and for this model we refer to all the research that studies the setting of fixed-time best-arm identification \\cite{audibert2010best,Garivier16BAI}.\nOn the second hand, consider cognitive radio and decentralized MAB learning implemented on IoT devices (like we present it in Chapter~\\ref{chapter:4}): usually a learning step corresponds to an up-link and then down-link message sent and received by the IoT device, and so the time horizon $T$ denotes the total number of such messages. While it can be assumed that the device will run for instance for $10$ years (as it is advertised by some companies \\cite{Centenaro16}), many kinds of application such as medical sensors or connected fields cannot predict the number of total communications before setting up the device.\n\nFor this later range of applications, it is of highest interest to be able to use low-cost MAB algorithms that do not rely on prior knowledge of the problem for which they will be applied, and especially do not need to know the horizon $T$.\nIn this thesis,\nwhile we proposed in Chapter~\\ref{chapter:5} any-time algorithms solving the presented problem of stationary multi-players bandit, our solution for the problem of non-stationary MAB problem studied in Chapter~\\ref{chapter:6} does rely on a prior knowledge of the horizon $T$.\nIt is an interesting direction of research to know what is the best approach to fix this weakness: work more and design algorithms that are inherently any-time, or use a generic technique to avoid depending on a prior knowledge of $T$, and automatically transform our non-anytime approach to make it anytime.\n\n\n\\paragraph{Solution to ``patch'' a non-anytime algorithm.}\n%\nA well-known technique to obtain an anytime algorithm from any non-anytime algorithm is the ``Doubling Trick'', as first introduced in \\cite{CesaLugosi06} and used for instance in \\cite{Auer10,AuerGajaneOrtner18}.\n%\nIn the context of adversarial or stochastic multi-armed bandits,\nthe performance of an algorithm is measured by its regret,\nand we study two families of sequences of growing horizons (geometric and exponential)\nto generalize previously known results that certain doubling tricks can be used to conserve certain regret bounds.\nIn a broad setting, we prove that a geometric doubling trick can be used to conserve (minimax) bounds in $R_T = \\cO(\\sqrt{T})$ but \\emph{cannot} conserve (distribution-dependent) bounds in $R_T = \\cO(\\log(T))$.\nWe give insights as to why exponential doubling tricks may be better, as they conserve bounds in $R_T = \\cO(\\log(T))$, and are close to conserving bounds in $R_T = \\cO(\\sqrt{T})$.\nInterestingly, we prove that they conserve bounds of the mixed form $R_T = \\cO(T^{\\gamma} (\\log(T))^{\\delta})$, for $0<\\gamma<1$ and $\\delta>0$, and so an exponential doubling trick could be used to obtain an anytime version of the algorithm we propose for non-stationary bandits, \\GLRklUCB{} in Chapter~\\ref{chapter:6}.\nHowever, our study was only focusing on stationary bandit, and it is left as a future work to explore the harder case of piece-wise stationary problems.\n\nIn our article \\cite{Besson2018DoublingTricks}, we also present numerical experiments in the case of stationary MAB problems, to compare the performance of efficient anytime algorithms, like \\klUCB, against efficient non-anytime algorithms, like \\KLUCBpp{} from \\cite{Menard17}, made anytime with different choices of doubling-trick.\nWe conclude that for such problems, if $T$ is not known before, it is always more efficient to use policies that were designed to be anytime that to use a doubling trick.\nFor example, an applicative paper written in 2018, \\cite{li2019useDoublingTrick}, only tested the use of an exponential doubling trick combined with \\KLUCBpp, but most surely the \\klUCB{} algorithm would have given better empirical performance as well as more robust results\\ldots\n\nTo conclude this work, we would need to complete the study of the doubling tricks, and instead of focusing on two families (geometric and exponential), we need to completely characterize the doubling tricks that allow to preserve certain regret bounds.\nSuch doubling is given either by the function mapping the current time $t$ to the current estimate of the horizon $T(t)$, or the sequence $(T_i)_{i\\in\\N^*}$ of successive estimates of the horizons.\nWe are interested in pursuing this work, in the hope of finding an intermediate sequence, growing faster than a geometric but slower than an exponential doubling sequence, that can preserve both worlds, problem-dependent bounds in $\\cO(\\log(T))$ and problem-independent bounds in $\\cO(\\sqrt{T})$.\n", "meta": {"hexsha": "dbd63271246b32add9017ab62c592bd56171e806", "size": 6312, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "3-Appendices/2-Appendix/appendix2.tex", "max_stars_repo_name": "Naereen/phd-thesis", "max_stars_repo_head_hexsha": "0fa93ca0d738771f4215bc4aeb66157f2026ba00", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-11-18T12:22:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T19:29:48.000Z", "max_issues_repo_path": "3-Appendices/2-Appendix/appendix2.tex", "max_issues_repo_name": "Naereen/phd-thesis", "max_issues_repo_head_hexsha": "0fa93ca0d738771f4215bc4aeb66157f2026ba00", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-11-18T09:19:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-08T14:13:08.000Z", "max_forks_repo_path": "3-Appendices/2-Appendix/appendix2.tex", "max_forks_repo_name": "Naereen/phd-thesis", "max_forks_repo_head_hexsha": "0fa93ca0d738771f4215bc4aeb66157f2026ba00", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-05-28T20:56:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-13T11:11:57.000Z", "avg_line_length": 116.8888888889, "max_line_length": 623, "alphanum_fraction": 0.7826362484, "num_tokens": 1442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.44435684754154753}}
{"text": "% File:\t\tvec2d.tex\n% Author:\tSee Below\n% Date:\t        See Below\n%\n% The authors have placed this file in the public domain;\n% they make no warranty and accept no liability for this file.\n\n\\documentclass[12pt]{article}\n\\usepackage{times}\n\\usepackage{color}\n\\usepackage[usenames]{xcolor}\n\\usepackage{scalefnt}\n\\usepackage{tikz}\n\\usepackage{wrapfig}\n\\usetikzlibrary{arrows}\n\\begin{document}\n\\newcommand{\\header}[1]{\\underline{\\bf #1}}\n\\newcommand{\\file}[1]{{\\bf #1}}\n\\newcommand{\\blankpage}{\\newpage\\vspace*{3.5in}%\n    \\centerline{\\Large This Page is Intentionally Left Blank}}\n\\setlength{\\parindent}{0.0in}\n\\setlength{\\parskip}{1ex}\n\\newcommand{\\key}[1]{{\\bf #1}}\n\\newcommand{\\TT}[1]{{\\tt \\bfseries #1}}\n\\newcommand{\\EOL}{\\penalty \\exhyphenpenalty}\n\\newtheorem{definition}{Definition}[section]\n\\newtheorem{lemma}[definition]{Lemma}\n\\newtheorem{corollary}[definition]{Corollary}\n\\newtheorem{theorem}[definition]{Theorem}\n\\newtheorem{algorithm}[definition]{Algorithm}\n\\newenvironment{indpar}[1]%\n    {\\begin{list}{}{\\setlength{\\leftmargin}{#1}}\\item[]}%\n    {\\end{list}}\n\n\\newcommand{\\wh}{\\,\\widehat{~}\\,}\n\\newcommand{\\WH}{$\\widehat{~}$}\n\n\n\\begin{center}\n{\\Large \\bf Two Dimensional Geometry Calculator}\n\n\\begin{tabular}{ll}\nAuthor:\t      & Robert L.~Walton $<$walton@acm.org$>$ \\\\\nDate:         & Wed Aug  4 22:08:37 EDT 2021\n\\end{tabular}\n\\\\[2ex]\n\\begin{tabular}{p{5in}}\nThe author(s) have placed this document and associated problems\nin the public domain;\nthey make no warranty and accept no liability for this document\nor associated problems.\n\\end{tabular}\n\n\\end{center}\n\n\\medskip\n\n\\section{Overview}\nThis document describes a group of 2-dimensional geometry problems\ninvolving vectors, points, and straight lines\n(but \\underline{not} polygons).\nThe problems are embedded in a simple calculator for ease of\ntesting.\n\n\\section{Boolean, Scalars, Vectors, and Transforms}\nA \\key{boolean} here is either the symbol \\key{true} or the symbol \\key{false}.\n\nA \\key{scalar} here is a double precision floating point number.\n\nA \\key{vector} here is a pair $(x,y)$ of double precision floating point\nnumbers, $x$ denoting an X-coordinate value, and $y$ denoting a\nY-coordinate value.  Such a vector can denote a point $(p_x,p_y)$ in the\nXY-plane, or can denote a translation $(v_x,v_y)$ of the plane: \\\\\n\\centerline{$(p_x,p_y) \\longmapsto (p_x+v_x,p_y+v_y)$}\n\nThe product of a scalar $s$ and a vector $v=(v_x,v_y)$ is represented using\n$*$ as $s*v = (sv_x,sv_y)$.\nThe sum of a vector $v=(v_x,v_y)$ and a vector $w=(w_x,w_y)$ is\nrepresented using $+$ as $v+w = (v_x+w_x,v_y+w_y)$.\n\nA \\key{linear transformation} here is a pair of vectors, $[\\ell_x,\\ell_y]$\nrepresenting the map:\n\\centerline{$(v_x,v_y) \\longmapsto v_x*\\ell_x+v_y*\\ell_y$}\nApplication is represented using\n$*$ as $[\\ell_x,\\ell_y]*v=v_x*\\ell_x+v_y*\\ell_y$.\n\nA \\key{vector list} here is a list of vectors\n$(v_1,v_2,\\ldots)$.  This can be used to represent the list of vertices\nof a polygon or a list of points in the plot of a function.\n\n\\newpage\n\n\\section{The Calculator Language}\nThe calculator language of this problem is very simple.\nAn example is:\n\\\\[1ex]\n{\\tt\n\\hspace*{0.2in}\\begin{tabular}{l@{\\hspace{0.5in}}l}\n\\rm \\bf Input\t& \\rm \\bf Output \\\\\\hline\nx=4\t\t& x=4 \\\\\ny = 0.5         & y = 0.5 \\\\\nz = x + y       & z = x + y = 4.5 \\\\\nv=(3,-2)\t& v=(3,-2) \\\\\nw=z*v\t\t& w=z*v = (13.5,-9) \\\\\n\\# this is a comment & \\# this is a comment\n\\end{tabular}\n} % \\tt\n\nThe syntax is:\n\\\\[1ex]\n\\hspace*{0.2in}\\begin{tabular}{l}\n{\\em program} ::= {\\em statement}$^\\star$ \\\\\n{\\em statement} ::= \\\\\n\\hspace*{0.2in}\\begin{tabular}[t]{cl}\n                    & {\\em comment} {\\em eol} \\\\\n                $|$ & {\\em variable} \\TT{=} {\\em value} {\\em eol}\\\\\n                $|$ & {\\em variable} \\TT{=} {\\em operator}\n\t\t          \\{ {\\em variable} {\\em operator} \\}$^\\star$\n\t\t          {\\em variable}$^?$ {\\em eol} \\\\\n                $|$ & {\\em variable} \\TT{=} {\\em variable}\n\t\t          \\{ {\\em operator} {\\em variable} \\}$^\\star$\n\t\t          {\\em operator}$^?$ {\\em eol} \\\\\n                $|$ & {\\em variable} \\TT{=} {\\em function}\n\t\t          {\\em variable}$^\\star$ {\\em eol} \\\\\n\t\t\\end{tabular}\n\\\\[1ex]\n{\\em eol} ::= end-of-line (line-feed) \\\\\n{\\em comment} ::= \\TT{\\#} {\\em character-other-than-line-feed}$^\\star$ \\\\\n{\\em variable} ::= a single letter (case matters) \\\\\n{\\em value} ::= {\\em boolean} $|$ {\\em scalar} $|$ {\\em vector}\n\t    $|$ {\\em linear-transform} $|$ {\\em vector-list} \\\\\n{\\em boolean} ::= \\TT{true} $|$ \\TT{false} \\\\\n{\\em scalar} ::= double precision floating point number (e.g., 1.4142135) \\\\\n{\\em vector} ::= \\TT{(} {\\em scalar}\\TT{,} {\\em scalar} \\TT{)} \\\\\n{\\em linear-transform} ::= \\TT{[} {\\em vector}\\TT{,} {\\em vector} \\TT{]} \\\\\n{\\em vector-list} ::= \\TT{()} $|$\n                 \\TT{(} {\\em vector} \\{ \\TT{,} {\\em vector} \\}$^\\star$ \\TT{)} \\\\\n{\\em operator} ::= \\begin{tabular}[t]{@{}l}\n                   one or more non-letter, non-digit graphic characters \\\\\n                   (e.g. {\\tt +} or {\\tt <=})\\\\\n\t\t   \\end{tabular} \\\\\n{\\em function} ::= \\begin{tabular}[t]{@{}l@{}}\n     three or more letters (e.g. {\\tt sin} or {\\tt area}) \\\\\n     no {\\em function} shall be a prefix of another {\\em function} \\\\\n     \\end{tabular}\n\\end{tabular}\n\n\\newpage\n\nThere are multiple versions of the calculator, each an extension\nof previous versions:\n\\begin{center}\n\\small\n\\begin{tabular}{ll}\nVersion & Implements\n\\\\\\hline\nScalar\t& scalar and boolean types \\\\\nVector  & the vector type \\\\\nLinear Transform & the linear transformation type \\\\\nRotations and Reflections & rotation and reflection linear transforms \\\\\nProducts & vector scalar and cross products \\\\\nLine and Point & algorithms involving a line and a point \\\\\nLine and Line & algorithms involving two lines \\\\\n\\end{tabular}\n\\end{center}\n\nThe Input/Output Rules are:\n\\begin{indpar}{0.2in}\\begin{itemize}\n\n\\item Whitespace in {\\em statements} is optional and should be deleted\nbefore the {\\em statements} are parsed.  There may be whitespace\nbefore the `{\\tt \\#}' that begins a comment.\n\n\\item The output of a {\\em statement} is a copy of the {\\em statement}\nline (including white\\-space)\nif the {\\em statement} is a comment or is of the form\n`{\\em variable} \\TT{=} {\\em value} {\\em eol}'.\nOtherwise the output is one line containing a copy of the {\\em statement}\nfollowed by `{\\em space} \\TT{=} {\\em space} {\\em value} {\\em eol}', where\nthe {\\em value} is that assigned to the {\\em variable} beginning the\n{\\em statement}.\n\n\\item Input lines have a maximum of 100,000 characters (long lines\nare only needed for inputting vector lists).  Output lines have\nno limit (output vector lists can be arbitrarily long).\n\n\\item Each calculator version should be able to input and output\nvalues of the types being tested by that version (beginning with\n{\\em boolean} and {\\em scalar} values) and process comments\nand statements of the form `{\\em variable} \\TT{=} {\\em variable}'.\n\n\\item {\\em Scalars} should be output with 6 digits of precision\n(which is the default for C/C++).  To pass tests, scalar values\nmust be accurate to better than 5 digits of precision \\underline{or}\nto better than $\\pm 10^{-10}$.\n\n\\item  The total number of vector list elements that need to be\nallocated during one program execution will be small enough\nthat these list elements do not need to be garbage collected\n(need not be freed when no longer needed).\n\n\\item Input will \\underline{not} contain the character `{\\tt \\$}',\nwhich can then be used as per Coding Hints below.\n\n\n\\end{itemize}\\end{indpar}\n\n\\newpage\n\n\\section{Scalar Calculator}\nImplement the calculator with just {\\em scalar} and {\\em boolean}\nvalue types and the \n{\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l}\nAssume:\t& {\\tt x=}$x$, {\\tt y=}$y$ are scalars \\\\\n\t& {\\tt d=}$d$ is an integer scalar, $-15\\le d\\le +15$ \\\\\nthen: \\\\[1ex]\n\\tt x+y & returns $x + y$ \\\\\n\\tt x-y & returns $x - y$ \\\\\n\\tt x*y & returns $x \\times y$ \\\\\n\\tt x/y & returns $x / y$ \\\\\n\\tt x\\%y & returns $x - n*y$ \\\\\n         & where $n = x/y$ rounded to the integer nearest zero \\\\\n\\tt -x & returns $-x$ \\\\\n\\tt |x| & returns $|x|$, the absolute value of $x$ \\\\\n\\tt cos x & returns $\\cos ( (\\pi/180) * x )$ [{\\tt x} is in degrees] \\\\\n\\tt sin x & returns $\\sin ( (\\pi/180) * x )$ [{\\tt x} is in degrees] \\\\\n\\tt tan x & returns $\\tan ( (\\pi/180) * x )$ [{\\tt x} is in degrees] \\\\\n\\tt x<y:d & returns \\TT{true} if $x<y-0.5*10^{-d}$, else \\TT{false} \\\\\n\\tt x<=y:d & returns \\TT{true} if $x<y+0.5*10^{-d}$, else \\TT{false} \\\\\n\\tt x==y:d & returns \\TT{true} if $|x-y|<0.5*10^{-d}$, else \\TT{false} \\\\\n\\tt x:d & returns $x\\textrm{~rounded to be an exact multiple of~}10^{-d}$ \\\\\n\\end{tabular}\n\\end{center}\n\nAngles are measured in degrees, with positive angles going counter-clockwise\nand negative angles going clockwise.\n\nComparisons assume the scalars being compared are approximations\nto precise numbers that are in units of $10^{-d}$, and therefore to test\nfor equality the scalars should be (in effect) rounded to the nearest unit.\nIn addition, the scalars have to be good enough approximations.  As\n\\label{DOUBLE-SIZE-LIMITS}\ndouble precision floating point numbers are accurate to at most one part\nin $10^{16}$, this means that if the units are $10^{-d}$ the scalar\nshould not have absolute value above $10^{15-d}$.\n\nDivision by {\\tt 0} will produce results such as\n{\\tt inf} (plus infinity), {\\tt -inf} (minus infinity),\nand {\\tt nan} (not a number; i.e., result could not be computed).\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-scalar-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-scalar-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-scalar-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-scalar-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\nYou can test your program using the indicated sample input and\noutput and you can submit your program using the indicated submit\nrun file.  Only scalar functionality is tested.\n\nThere is also the file:\n\\begin{center}\n\\begin{tabular}{rl}\nSpecial Input File: & \\file{00-000-special-vec2d.in} \\\\\n\\end{tabular}\n\\end{center}\nwhich may be used to see the results of divide by zero\nand other anomalous scalar computations.\nThe output of your program for this special input file will depend\nupon the programming language you use, so the output is\nnot testable except by human inspection.  Therefore there is\nno companion {\\tt .ftest} file, and the special input\nfile is not included in any {\\tt .run} files.\n\n\\section{Coding Hints}\nThe calculator memory just maps each variable to a value.\nYou can map each ASCII character to a value using a\nvector of 128 elements, and simply not use the elements\nthat do not correspond to letters.\n\nTo parse a line, remove its whitespace characters.  Then\n\\begin{itemize}\n\\item If the line begins with `{\\tt \\#}', it is a {\\em comment}.\n\\item Else if the line contains a digit, it has the form\n`{\\em variable} \\TT{=} {\\em value}', where {\\em value} is:\n\\begin{itemize}\n\\item A linear-transform if the `\\TT{=}' is followed by `\\TT{[}'.\n\\item A vector list if the `\\TT{=}' is followed by `\\TT{((}'.\n\\item A vector if the `\\TT{=}' is followed by `\\TT{(}' but not `\\TT{((}'.\n\\item A scalar otherwise.\n\\end{itemize}\n\\item If the line does \\underline{not} contain a digit, match the\nline to a pattern using the rules:\n\\begin{itemize}\n\\item The pattern and the line must be the same length.\n\\item A pattern character other than `\\TT{\\$}' must match the line character\nexactly.\n\\item The `\\TT{\\$}' pattern character must match a letter (which will\nbe a {\\em variable}).\n\\end{itemize}\n\\end{itemize}\nExamples: \\begin{tabular}[t]{l@{~~~}l@{~~~}l}\n\\underline{The Pattern} & \\underline{Matches}\n\\\\[1ex]\n\\tt \\$=\\$ & \\tt x=y \\\\\n\\tt \\$=true & \\tt t=true \\\\\n\\tt \\$=() & \\tt x=() \\\\\n\\tt \\$=\\$+\\$ & \\tt b=c+d \\\\\n\\tt \\$=sin\\$ & {\\tt x=sinA} & [Normally input as {\\tt x=sin A}] \\\\\n\\tt \\$=\\$<=\\$:\\$ & {\\tt x=y<=z:d}  & [Normally input as {\\tt x = y<=z:d}] \\\\\n\\end{tabular}\n\nRemember that when you output a line, you are outputting the\n\\underline{original}\nline before whitespace characters were removed.\n\nSolutions to the Scalar Calculator problem are available in the files:\n\\begin{center}\n\\begin{tabular}{ll}\n\\TT{c-scalar-vec2d.txt}\t&  for C \\\\\n\\TT{cc-scalar-vec2d.txt}\t&  for C++ \\\\\n\\TT{java-scalar-vec2d.txt}\t&  for JAVA \\\\\n\\TT{py-scalar-vec2d.txt}\t&  for PYTHON \\\\\n\\end{tabular}\n\\end{center}\n\nYou can build solutions for successive calculator versions\nby renaming and extending one of these files, if you like.\n\nThe first section of each of these files contains data declarations.\nUsing these should make it easier\nfor other people familiar with this problem to read your\ncode, should that be important.\nIt is recommended that you use this first section even\nif you do not use the rest of the file.\n \n\n\n\\section{Operations on Vectors}\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.45\\textwidth}\n\\begin{tikzpicture}[x=0.25in,y=0.25in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n\n    \\fill[black] (0,0) circle(0.1) + (+0.0,-0.5) node[black]{$p$};\n\n    \\draw[red,->] (0,0) -- (+3,+1);\n    \\draw[black] (1.3,0.8) node{$v$};\n    \\fill[black] (+3,+1) circle(0.1) + (+0.2,-0.5) node[black]{$p+v$};\n    \\draw[blue,->] (+3,+1) -- (-1,+4);\n    \\draw[black] (+1.6,2.5) node{$w$};\n    \\fill[black] (-1,+4) circle(0.1) + (+0.5,+0.5) node[black]{$p+v+w$};\n\n    \\draw[blue,->] (0,0) -- (-4,+3);\n    \\draw[black] (-2.8,1.4) node{$w$};\n    \\fill[black] (-4,+3) circle(0.1) + (-0.2,+0.5) node[black]{$p+w$};\n    \\draw[red,->] (-4,+3) -- (-1,+4);\n    \\draw[black] (-2.1,3.3) node{$v$};\n\n    \\draw[brown,->] (0,0) -- (-1,+4);\n    \\draw[black] (-0.2,1.8) node{$v+w$};\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nWe will define the \\key{vector sum} of vectors $v=(v_x,v_y)$ and\n$w=(w_x,w_y)$ to be $v+w=(v_x+w_x,v_y+w_y)$.  If you\nthink of a point $p=(p_x,p_y)$ in the XY-plane as a vector,\nyou can associate a translation $\\tau_v$ of the XY-plane\nwith the vector $v$ using the equation $\\tau_v(p)=p+v$.  Then\\\\\n\\hspace*{0.2in}$\\tau_w(\\tau_v(p)) = p+v+w = \\tau_{v+w}(p)$ \\\\\nSee the picture.\n\\\\[1ex]\nVector sums are commutative, i.e.,  $v+w=w+v$, and associative,\ni.e., $u+(v+w)=(u+v)+w$.\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.55\\textwidth}\n\\begin{tikzpicture}[x=0.20in,y=0.20in]\n\\begin{scope}[>=triangle 45]\n\n    \\draw[black,->] (0,3) -- (4,3) node[black,right]{$2*v$};\n    \\draw[black,->] (0,2) -- (2,2) node[black,right]{$v$};\n    \\draw[black,->] (0,1) -- (1,1) node[black,right]{$0.5*v$};\n    \\fill[black] (0,0) circle(0.1) node[black,right]{$0*v$}; \n    \\draw[red,->] (0,-1) -- (-1,-1) node[black,left]{$-0.5*v$};\n    \\draw[red,->] (0,-2) -- (-2,-2) node[black,left]{$-1.0*v$};\n    \\draw[red,->] (0,-3) -- (-4,-3) node[black,left]{$-2.0*v$};\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nWe define the \\key{scalar product} of a scalar $s$ and a vector\n$v=(v_x,v_y)$ as $s*v = (s*v_x,s*v_y)$.  Multiplication\nof $v$ by $s>0$ does not change the direction of $v$,\nbut multiplies the length of $v$ by $s$.  Multiplication of $v$ by\n$s<0$ reverses the direction of $v$ and multiplies its length\nby $|s|$.  See the picture.\n\\\\[1ex]\nScalar products are associative in that\n$s_1*(s_2*v)=(s_1*s_2)*v$ and distributive in that\n$s*(v_1+v_2)=s*v_1+s*v_2$ and $(s_1+s_2)*v = s_1*v + s_2*v$.\n\\end{minipage}\n\n\\medskip\n\nThe negative of a vector is defined as $-v = (-1)*v = (-v_x,-v_y)$.\nSubtraction of vectors is defined as $v-w = v + (-w) = (v_x-w_x,v_y-w_y)$. \n\n\\medskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.4\\textwidth}\n\\begin{tikzpicture}[x=0.20in,y=0.20in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+5,0);\n    \\draw[black] (0,-1) -- (0,+3);\n\n    \\fill[red] (0,0) circle(0.1);\n    \\draw[black] (2.0,-0.5) node{$||v||*\\cos \\theta$};\n\n    \\draw[brown,>=latex,->] (2.0,0) arc(0:30:2.0);\n    \\draw[black] (2.4,+0.4) node{$\\theta$};\n\n    \\fill[red] (3.464101615,2.0) circle(0.1);\n    \\draw[red,->] (0,0) -- (3.464101615,2.0);\n    \\draw[black] (1.3,+1.5) node{$||v||$};\n    \\draw[black] (3.4,+2.5) node[right]{$v$};\n\n    \\draw[orange] (3.464101615,0) -- (3.464101615,2.0);\n    \\draw[black] (3.464101615,1) + (0.1,0)\n                 node[right]{$||v||*\\sin \\theta$};\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nA vector $v=(v_x,v_y)$ has a length and a direction.\nThe \\key{length}, denoted by $||v||$, can be computed using\nPythagoras's Theorem: $||v||=\\sqrt{v_x^2+v_y^2}$.  The\ndirection is given by the counterclockwise angle $\\theta$ from\nthe positive X-axis direction to the vector direction.\nThis is called the \\key{azimuth} of $v$, and in computer\nlanguages may be computed (in radians) by the {\\tt atan2} function as\n$\\theta = \\mathrm{atan2}(v_y,v_x)$ (note $v_y$ comes before $v_x$).\n\\end{minipage}\n\nWe measure angles, including azimuths, in degrees.  To convert degrees\nto radians, multiply by $\\pi/180$, and to convert radians to degrees,\nmultiply by $180/\\pi$.  Positive angles are counter-clockwise, and\nnegative angles are clockwise.\n\nFor a vector {\\tt v},~~{\\tt azm v} and {\\tt ||v||} are said to be\nthe \\key{polar coordinates} of {\\tt v}.\nThe vector with the polar coordinates $\\theta$ (azimuth) and $\\ell$ (length) is\n$(\\ell \\cos\\theta,\\ell \\sin\\theta)$.  For the vector {\\tt v}=$(v_x,v_y)$:\n\\begin{center}\n\\tt\n\\begin{tabular}{l}\n||v|| = $\\sqrt{v_x^2+v_y^2}$ \\\\\nazm v = $(180/\\pi)$ * atan2($v_y$,$v_x$)\n\\end{tabular}\n\\end{center}\nSee the picture.\n\nAdding integer multiples of 360 to a vector's\nazimuth does \\underline{not} change the vector.\n\n\\newpage\n\n\\section{Vector Calculator}\nImplement additions to the scalar calculator for just {\\em vector}\nvalue types and the {\\em operators} and {\\em functions}:\n\\begin{indpar}{0.05in}\n\\begin{tabular}{l@{~~~}l@{~~~}l}\nAssume: & {\\tt s=}$s$, {\\tt x=}$x$, {\\tt y=$y$},\n          {\\tt l=$\\ell$}, {\\tt t=$(180/\\pi)*\\theta$}\n          are scalars \\\\\n\t& {\\tt d=}$d$ is an integer scalar, $-15\\le d\\le +15$ \\\\\n\t& {\\tt v=}$(v_x,v_y)$, {\\tt w=}$(w_x,w_y)$ are vectors \\\\\n\t& {\\tt L} is a list of vectors \\\\\nthen: \\\\[1ex]\n\\tt (x,y) & returns $(x,y)$ \\\\\n\\tt v.x & returns $v_x$ ~~~ ({\\tt x} is \\underline{not} a variable here) \\\\\n\\tt v.y & returns $v_y$ ~~~ ({\\tt y} is \\underline{not} a variable here) \\\\\n\\tt v==w:d & returns $v_x==w_x:d$ AND $v_y==w_y:d$ \\\\\n\\tt v:d & returns $(v_x:d,v_y:d)$ \\\\\n\\tt s*v & returns $(s v_x, s v_y )$ \\\\\n\\tt -v & returns $( -v_x, -v_y )$, {\\tt v} with direction reversed \\\\\n\\tt v+w & returns $(v_x + w_x, v_y + w_y)$ \\\\\n\\tt v-w & returns $(v_x - w_x, v_y - w_y)$ \\\\\n\\tt ||v|| & returns $\\sqrt{v_x^2 + v_y^2}$ & [length] \\\\\n\\tt azm v & returns $(180/\\pi)*\\mathrm{atan2}(v_y,v_x)$ adjusted & [azimuth] \\\\\n          & to be in the range [0,360).  Calculated values very \\\\\n\t  & near 0 or 360 may be unstable. \\\\\n\t  & The returned value is undefined if $||v||=0$. \\\\\n\\tt l\\WH t & returns $(\\ell\\cos\\theta,\\ell\\sin\\theta)$,\n\t     the vector with length {\\tt l} and \\\\\n\t   & azimuth {\\tt t} degrees,\n\t     where $\\theta = (\\pi/180)*{\\tt t}$ radians \\\\\n\\tt cons v L & returns the list made by prepending {\\tt v} to {\\tt L} \\\\\n\\end{tabular}\n\\end{indpar}\n\nIf {\\tt ||v|| = 0} then {\\tt azm~v} is undefined (you can do extra\nprogramming to make it defined as {\\tt nan} if you like, but this\nis not necessary).\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-vector-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-vector-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-vector-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-vector-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\nYou can test your program using the indicated sample input and\noutput and you can submit your program using the indicated submit\nrun file.\n\n\\newpage\n\n\\section{Display Language}\nPoints, lines, arrows, etc.~can be displayed\nby making a {\\tt .pdf} file from an {\\tt .in}\nfile and your solution program.\nThe display commands are embedded in {\\tt .in} file `{\\tt \\#}' comment\nlines, so your program does not have to deal with them.\nThe {\\tt 00-000-vector-vec2d.in} file has examples of all the\ndisplay commands.  Most sample {\\tt 00-XXXX-YYYY-vec2d.in} files have\nhave display commands if they compute vectors.\n\n\\medskip\n\n\\begin{minipage}{\\textwidth}\nThe line/area drawing commands are:\n\\\\[1ex]\n\\begin{tabular}{@{}l@{~~~~~}l@{}}\n\\underline{Command} & \\underline{Draws}\n\\\\[1ex]\n\\tt \\#!point p [color] [size] & point {\\tt p} \\\\\n\\tt \\#!point L [color] [size] & points in the point list {\\tt L} \\\\\n\\tt \\#!line pq [color] [opt] & line from point {\\tt p}\n                                 to point {\\tt q} \\\\\n\\tt \\#!line L  [color] [opt] & lines with endpoints that are \\\\\n                             & consecutive points in the \\\\\n\t\t             & list of points {\\tt L} \\\\\n\\tt \\#!infline pA [color] [opt] & infinite line from point {\\tt p} \\\\\n                                & in direction {\\tt A}\n\t\t\t\t  (a scalar angle) \\\\\n\\tt \\#!rectangle pq [color] [opt] & rectangle with opposing corners \\\\\n                                  & point {\\tt p} and point {\\tt q} \\\\\n\\tt \\#!circle cr [color] [opt] & circle of center {\\tt c}\n                                   and radius {\\tt r} \\\\\n\\tt \\#!ellipse cRA [color] [opt] & ellipse with center {\\tt c}, radii \\\\\n                                   & {\\tt R.x} and {\\tt R.y}, rotated \\\\\n                                   & by angle A about its center \\\\\n\\end{tabular}\n\\end{minipage}\n\nIn the above {\\tt p}, {\\tt q}, {\\tt c}, {\\tt R}, {\\tt r}, {\\tt A}, {\\tt L}\nare arbitrary {\\em variables}.  Each variable used in a display command\nmust have been set or computed by a calculator statement output before\nthe display command.  The last value assigned to the variable by a\ncalculator statement before the display command will be used by the\ndisplay command.\n\nCircle and ellipse radii must be strictly positive.\nSpaces are as indicated, and must consist\nof at least one horizontal space character.\nCoordinates are automatically scaled to fit the logical page.  Angles are\nin degrees.\n\nThe possible colors\nare `{\\tt red}', `{\\tt blue}', `{\\tt brown}', and `{\\tt black}'.  Black is\nthe default.\n(Green does not show up when the page is printed in black-and-white, and\nso is not provided.)\n\nFor points, {\\tt size} is an integer in the range [1,18] giving the size\nof each point in units of 1/72'nd inch (1pt).  The default is 2pt.\n\n\\begin{minipage}{\\textwidth}\nFor non-points {\\tt opt} is zero or more of:\n\\\\[1ex]\n\\hspace*{0.5in}\\begin{tabular}{rl}\n    \\tt . & dotted line \\\\\n    \\tt - & dashed line \\\\\n          & ~~ ({\\tt .} and {\\tt -} conflict; if neither line is solid) \\\\\n    \\tt c & close path (for {\\tt \\#!line L}) \\\\\n          & ~~ (implied by {\\tt s}, {\\tt d}, {\\tt h}, {\\tt v}) \\\\\n    \\tt m & add arrow head in middle of each line segment (for {\\tt \\#!line}) \\\\\n    \\tt e & add arrow head at end of each line segment (for {\\tt \\#!line}) \\\\\n    \\tt s & fill with solid color \\\\\n    \\tt d & fill with dots \\\\\n    \\tt h & fill with horizontal bars \\\\\n    \\tt v & fill with vertical bars \\\\\n          & ~~ ({\\tt s}, {\\tt d}, {\\tt h}, and {\\tt v} conflict) \\\\\n    \\tt f & extend infinite line forward from point\n            (for {\\tt \\#!infline}) \\\\\n    \\tt b & extend infinite line backward from point\n            (for {\\tt \\#!infline}) \\\\\n          & ~~ ({\\tt f}, {\\tt b} conflict; if neither\n\t        line extends in both directions) \\\\\n    \\end{tabular}\n\\end{minipage}\n\n\\begin{minipage}{\\textwidth}\nThe text drawing commands are:\n\\\\[1ex]\n\\begin{tabular}{@{}l@{~~~~~}l@{}}\n\\underline{Command} & \\underline{Draws}\n\\\\[1ex]\n\\tt \\#!text p [color] opt text... &\n    the text, place at/near point {\\tt p} \\\\\n\\tt \\#!text pq [color] opt text... &\n    ditto but the text is placed at/near \\\\\n    & the midpoint of the line {\\tt pq}\n\\end{tabular}\n\\end{minipage}\n\n\\begin{minipage}{\\textwidth}\nHere {\\tt opt} is `{\\tt -}' for no options, or given that the point\nof text placement is {\\tt ($x$,$y$)}, is one or more of:\n\\\\[1ex]\n\\hspace*{0.5in}\\begin{tabular}{rl}\n    \\tt t & display about 0.5em above $y$ \\\\\n    \\tt b & display about 0.5em below $y$ \\\\\n          & ~~ ({\\tt t} and {\\tt b} conflict, if neither center on $y$) \\\\\n    \\tt l & display about 0.5em left of $x$ \\\\\n    \\tt r & display about 0.5em right of $x$ \\\\\n          & ~~ ({\\tt l} and {\\tt r} conflict, if neither center on $x$) \\\\\n    \\tt x & make the bounding rectangle of text white \\\\\n    \\tt c & make the bounding circle of text white \\\\\n          & ~~ ({\\tt x} and {\\tt c} conflict) \\\\\n    \\tt o & outline any bounding rectangle or circle with \\\\\n          & a black line of width 1pt \\\\\n    \\end{tabular}\n\\end{minipage}\n\nHere `\\key{em}' is the font size; capital letters are typically\n0.7em high and lower case letters are typically 0.5em high.\n\n\\begin{minipage}{\\textwidth}\nThe page commands are:\n\\\\[1ex]\n\\begin{tabular}{@{}l@{~~~~~}l@{}}\n\\underline{Command} & \\underline{Action}\n\\\\[1ex]\n\\tt \\#!layout R C [margin]   & Starts new physical page with R rows and \\\\\n                             & C columns of logical pages, each logical \\\\\n\t\t\t     & page with margins as given in pt (1/72\") \\\\\n\t\t\t     & (margin defaults to 18 or 0.25\") \\\\\n\\tt \\#!newpage [pq] & Starts new logical page with opposite \\\\\n                    & corner coordinates optionally given by \\\\\n\t\t    & points p and q (which are not themselves \\\\\n\t\t    & displayed) \\\\\n\\tt \\#!header text... & Adds text line to current logical page header \\\\\n\\end{tabular}\n\\end{minipage}\n\nThe output from a test case is one or more physical pages\neach containing one or more logical pages.  The physical\npages are numbered and labeled with the test case name\n(e.g., {\\tt 00-000-vec2d}).  Each `{\\tt header text...}' adds one\nline to the logical page header.  If the first command is\nnot a `{\\tt \\#!layout}' command, then `{\\tt \\#!layout 1 1}'\nis assumed.  A `{\\tt \\#!newpage}' command immediately after a\n`{\\tt \\#!layout}' command may be omitted and will be assumed.\n\n\\newpage\n\n\\section{Linear Transforms}\nIf we let $\\mathcal{R}$ denote the set of real numbers,\na.k.a., scalars, the set of all vectors is \\\\\n\\centerline{\n$\\mathcal{R}\\times\\mathcal{R}=\\mathcal{R}^2\n    =\\{(v_x,v_y)|v_x,v_y\\in \\mathcal{R}\\}$}\n\n\\begin{definition}\\label{LINEAR-TRANSFORMATION}\nA \\key{linear transformation} $L$ is a continuous map\n$L:\\mathcal{R}^2\\mapsto\\mathcal{R}^2$ such that for\nall vectors $v$ and $w$, $L(v+w)=L(v)+L(w)$.\n\\end{definition}\n\nSome examples of linear transformations are (1) the identity map,\n(2) rotations, (3) reflections about an axis, (4) scale changes\n(i.e., $(v_x,v_y)\\longmapsto(s_x v_x,s_y v_y)$ for scalars $s_x$\nand $s_y$).\n\n(In vector algebra, linear transformations with domains and/or ranges\nthat are vector spaces other than $\\mathcal{R}^2$ are studied.)\n\n\n\\begin{lemma}\nLet $L$ be a linear transformation, $v$ and $w$ be vectors,\nand $0=(0,0)$ be the zero vector.  Then $L(0)=0$,  $L(-v)=-L(v)$,\nand $L(v-w) = L(v) - L(w)$.\n\\end{lemma}\n\\begin{indpar}{0.5in}\nProof: $L(0) = L(0+0)= L(0) + L(0)$ so subtracting $L(0)$\nfrom both sides, $0=L(0)$.  $0 = L(0) = L(v-v) = L(v) + L(-v)$\nso subtracting $L(v)$ from both sides, $-L(v)=L(-v)$.\n$L(v-w)=L(v+(-w))=L(v)+L(-w)=L(v)+(-L(w))=L(v)-L(w)$.\n\\end{indpar}\n\n\\begin{lemma}\nLet $L$ be a linear transformation, $s$ be a scalar, and $v$ be a vector.\nThen $L(s*v)=s*L(v)$.\n\\end{lemma}\n\\begin{indpar}{0.5in}\nProof: The cases $s=0,1,2,-1,-2$ follow from the previous lemma and\nusing induction proves the lemma for any integer $s$.  For $s=n/d$\na rational number with integers $n$ and $d$ and $d>0$, \\\\\n\\hspace*{0.1in}$n*L(v) = L(n*(d/d)*v) = L(d*(n/d)*v)=d*L((n/d)*v)$ \\\\\nso dividing by $d$\nwe get $L((n/d)*v)=(n/d)*L(v)$.  For $s$ a non-rational real number,\nthe result follows from a continuity argument that we will leave\nto the mathematicians, since computer scientists only compute\nwith rational numbers.\n\\end{indpar}\n\nLet $L$ be a linear transformation; let $v=(v_x,v_y)$ be a vector;\nlet $u_x=(1,0)$ and $u_y =(0,1)$.  Then \\\\\n\\centerline{$L(v) = L(v_x*u_x+v_y*u_y)=v_x*L(u_x)+v_y*L(u_y)$.}\n\n\\begin{lemma}\nGiven vectors $\\ell_x$ and $\\ell_y$, the map\n$L:(v_x,v_y)\\longmapsto v_x*\\ell_x+v_y*\\ell_y$ is a linear\ntransformation.\n\\end{lemma}\n\\begin{indpar}{0.5in}\nProof: $L(v+w) = (v_x+w_x)*\\ell_x+(v_y+w_y)*\\ell_y\n               = v_x*\\ell_x+v_y*\\ell_y+w_x*\\ell_x+w_y*\\ell_y\n\t       = L(v) + L(w)$.\n\\end{indpar}\n\nSo $L$ is determined by $\\ell_x = L(u_x)$ and $\\ell_y = L(u_y)$,\nand there is a 1-1 correspondence between linear transformations\nand vector pairs $[\\ell_x,\\ell_y]$.  Therefore we will represent a linear\ntransformation $L$ by a pair of vectors {\\tt [$\\ell_x$,$\\ell_y$]}\nand represent application of L to the vector {\\tt v = ($v_x$,$v_y$)} by \\\\\n\\centerline{\\tt $L(v)$ = [$\\ell_x$,$\\ell_y$]*($v_x$,$v_y$) =\n             $v_x$*$\\ell_x$+$v_y$*$\\ell_y$}\nHere we use [] instead of () to surround the pair of vectors of a linear\ntransformation, because our calculator does this to distinguish linear\ntransformations from lists of vectors.\n\nExamples:\n\\begin{enumerate}\n\\item {\\tt L=[(1,0),(0,1)]} is the identity map.\n$L(v)=v_x*(1,0) + v_y*(0,1) = (v_x,0)+(0,v_y) = (v_x,v_y) = v$.\n\\item {\\tt L=[(0,1),(-1,0)]} rotates vectors $90^\\circ$.\nSpecifically, $L(u_x)=u_y$ and $L(u_y)=-u_x$ and\n$L(v)=v_x*(0,1) + v_y*(-1,0) = (0,v_x)+(-v_y,0) = (-v_y,v_x)$.\n\\item {\\tt L=[(-1,0),(0,-1)]} reverses the direction of a vector.\n$L(v)=v_x*(-1,0) + v_y*(0,-1) = (-v_x,0)+(0,-v_y) = (-v_x,-v_y) = -v$.\n\\item {\\tt L=[(-1,0),(0,1)]} reflects vectors across the Y-axis.\n$L(v)=v_x*(-1,0) + v_y*(0,1) = (-v_x,0)+(0,v_y) = (-v_x,v_y)$.\n\\item {\\tt L=[($s_x$,0),(0,$s_y$)]} scales the X-axis by $s_x$ and\nthe Y-axis by $s_y$. \\\\\n$L(v)=v_x*(s_x,0) + v_y*(0,s_y)\n     = (s_x v_x,0)+(0,s_y v_y)= (s_x v_x, s_y v_y)$.\n\\end{enumerate}\n\nNow suppose we have a scalar {\\tt s}, vector {\\tt v},\nand two linear transformations\n{\\tt K = [$\\ell^K_x$,$\\ell^K_y$]},\n{\\tt L = [$\\ell^L_x$,$\\ell^L_y$]}.  Then we can define:\n\\begin{center}\n\\tt\n\\begin{tabular}{l@{~so that~}l}\ns*L = [s*$\\ell^L_x$,s*$\\ell^L_y$]\n\t & (s*L)*v = s*(L*v) \\\\[0.3ex]\nK+L = [$\\ell^K_x$+$\\ell^L_x$,$\\ell^K_y$+$\\ell^L_y$]\n\t & (K+L)*v = K*v + L*v \\\\[0.3ex]\nK-L = [$\\ell^K_x$-$\\ell^L_x$,$\\ell^K_y$-$\\ell^L_y$]\n\t & (K-L)*v = K*v - L*v \\\\[0.3ex]\n-L = [-$\\ell^L_x$,-$\\ell^L_y$]\n\t & (-L)*v = - L*v \\\\[0.3ex]\nK*L = [K*$\\ell^L_x$,K*$\\ell^L_y$]\n\t & (K*L)*v = K*(L*v)\n\\end{tabular}\n\\end{center}\n\n{\\tt *} and {\\tt +} as defined here are \\key{bi-linear}, which means\n(supposing {\\tt t} to be another scalar and\n{\\tt J} to be another linear transformation):\n\\begin{center}\n\\tt\ns*(K+L) = s*K + s*L \\\\\n(s+t)*K = s*K + t*K \\\\\n(J+K)*L = J*L + K*L \\\\\nJ*(K+L) = J*K + J*L\n\\end{center}\n\nAddition of linear transformations commutes,\n{\\tt K+L = L+K}, but multiplication does not:\nin general {\\tt K*L} is \\underline{not equal} to {\\tt L*K}\n(as an example, a rotation does not generally commute with\na reflection: see the end of the Rotations and Reflections\nsection below where $R^\\phi*F^\\omega = F^\\omega*R^{-\\phi}$).\n\nLet {\\tt I} be the identity transform defined by\n{\\tt I*v=v} for all vectors {\\tt v}  (and therefore {\\tt I=[$u_x$,$u_y$]}).\nIt is easy to check that {\\tt K*I = K = I*K} for all linear transforms\n{\\tt K}.\n\nA linear transform {\\tt K} is defined to be the (two-sided) \\key{inverse}\nof the linear transform {\\tt L} if and only if {\\tt K*L = I = L*K}.\nThe inverse of {\\tt L} might not exist, but if it does, it is unique\nsince if there were two, {\\tt K$_1$} and {\\tt K$_2$}, then \\\\\n\\centerline{\\tt K$_1$ = K$_1$*I = K$_1$*(L*K$_2$)\n                      = (K$_1$*L)*K$_2$ = I*K$_2$ = K$_2$}\nThe notation {\\tt L$^{-1}$} is used for the inverse of {\\tt L} if it\nexists.  For example, the inverse of a rotation by angle $\\phi$ in the\ncounter-clockwise direction is a rotation by angle $\\phi$ in the\nclockwise direction.\n\n(One-sided inverses that are not two-sided inverses only exist for\nlinear transformations whose domain and range are vector spaces of\n\\underline{different} dimensions, unlike our linear transformations\nwhose domain and range are both 2-dimensional.)\n\n\n\n\\newpage\n\n\\section{Linear Transform Calculator}\nImplement additions to the vector calculator for just {\\em linear-transform}\nvalue types and the {\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l@{~~~~~}l}\nAssume: & {\\tt s=}$s$ is a scalar \\\\\n\t& {\\tt d=}$d$ is an integer scalar, $-15\\le d\\le +15$ \\\\\n\t& {\\tt v=($v_x$,$v_y$)} and {\\tt w=($w_x$,$w_y$)} are vectors \\\\\n\t& \\multicolumn{2}{@{}l}{{\\tt K=[$\\ell^K_x$,$\\ell^K_y$]} and\n\t  {\\tt L=[$\\ell^L_x$,$\\ell^L_y$]} are linear transforms} \\\\\nthen: \\\\[1ex]\n\\tt [v,w] & returns $[v,w]$ \\\\\n\\tt K==L:d & returns $\\ell^K_x==\\ell^L_x:d$ AND $\\ell^K_y==\\ell^L_y:d$ \\\\\n\\tt K:d & returns $[\\ell^K_x:d,\\ell^K_y:d]$ \\\\\n\\tt L.x & returns {\\tt $\\ell^L_x$}\n          ~~~ ({\\tt x} is \\underline{not} a variable here) \\\\\n\\tt L.y & returns {\\tt $\\ell^L_y$}\n          ~~~ ({\\tt y} is \\underline{not} a variable here) \\\\\n\\tt L*v & returns {\\tt $v_x$*$\\ell^L_x$+$v_y$*$\\ell^L_y$} & [application] \\\\\n\\tt s*L & returns {\\tt [$s\\ell^L_x$,$s\\ell^L_y$]} \\\\\n\\tt K+L & returns {\\tt [$\\ell^K_x$+$\\ell^L_x$,$\\ell^K_y$+$\\ell^L_y$]} \\\\\n\\tt K-L & returns {\\tt [$\\ell^K_x$-$\\ell^L_x$,$\\ell^K_y$-$\\ell^L_y$]} \\\\\n\\tt -L & returns {\\tt [-$\\ell^L_x$,-$\\ell^L_y$]} \\\\\n\\tt K*L & returns {\\tt [K*$\\ell^L_x$,K*$\\ell^L_y$]} & [composition] \\\\\n\\end{tabular}\n\\end{center}\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-linear-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-linear-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-linear-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-linear-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\n\\newpage\n\n\\section{Rotations and Reflections}\nRotations and reflections are the two kinds of linear transformations\nthat preserve vector lengths (i.e., $||L(v)||=||v||$).\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}[5]{r}{0.4\\textwidth}\n\\begin{tikzpicture}[x=0.20in,y=0.20in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+5,0);\n    \\draw[black] (0,-1) -- (0,+3);\n\n    \\fill[red] (0,0) circle(0.1);\n\n    \\draw[brown,>=latex,->] (2.0,0) arc(0:30:2.0);\n    \\draw[black] (3.2,+0.4) node{azm~$v$};\n\n    \\draw[blue,>=latex,->] (1.7320508,1.0) arc(30:150:2.0);\n    \\draw[black] (+0.5,+2.3) node{$\\phi$};\n\n    \\fill[red] (3.464101615,2.0) circle(0.1);\n    \\draw[red,->] (0,0) -- (3.464101615,2.0);\n    \\draw[black] (3.6,2.6) node{$v$};\n\n    \\fill[red] (-3.464101615,2.0) circle(0.1);\n    \\draw[red,->] (0,0) -- (-3.464101615,2.0);\n    \\draw[black] (-3.6,+2.6) node{$R^\\phi(v)$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nA \\key{rotation} $R^\\phi$ by $\\phi$ degrees (counter-\\EOL clockwise)\nis defined mathematically by\n\\hspace*{0.2in}\\begin{tabular}[t]{l}\n$||R^\\phi(v)|| = ||v||$ \\\\\n$\\mathrm{azm}~R^\\phi(v) = \\mathrm{azm}~v + \\phi$ if $||v||\\neq 0$ \\\\\n\\end{tabular} \\\\\n~\\\\\nA rotation preserves angles between vectors; that is: \\\\\n\\hspace*{0.2in}$\\mathrm{azm}~R^\\phi(v)-\\mathrm{azm}R^\\phi(w)\n               = \\mathrm{azm}~v-\\mathrm{azm}~w$\n\t       if $||v||\\neq 0 \\neq ||w||$ \\\\\nAlso, adding integer multiples of 360 to $\\phi$\ndoes \\underline{not} change $R^\\phi$.\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}[5]{r}{0.5\\textwidth}\n\\begin{tikzpicture}[x=0.20in,y=0.20in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+1,0);\n    \\draw[black] (0,-1) -- (0,+1);\n\n    \\fill[red] (0,0) circle(0.1);\n\n    \\fill[red] (3.464101615,2.0) circle(0.1);\n    \\draw[red,->] (0,0) -- (3.464101615,2.0);\n    \\draw[black] (2.7,0.6) node{$v$};\n\n    \\fill[red] (4.0,4.0) circle(0.1);\n    \\draw[brown,->] (0,0) -- (4.0,4.0);\n    \\draw[black] (1.4,2.8) node{$v+w$};\n\n    \\draw[blue,->] (3.464101615,2.0) -- (4.0,4.0);\n    \\draw[black] (4.2,3.0) node{$w$};\n\n    \\fill[red] (-3.464101615,2.0) circle(0.1);\n    \\draw[red,->] (0,0) -- (-3.464101615,2.0);\n    \\draw[black] (-1.4,+2.0) node{$R^\\phi(v)$};\n\n    \\fill[red] (-5.464101521,1.464101590) circle(0.1);\n    \\draw[brown,->] (0,0) -- (-5.464101521,1.464101590);\n    \\draw[black] (-4.2,+0.2) node{$R^\\phi(v+w)$};\n\n    \\draw[blue,->] (-3.464101615,2.0) -- (-5.464101521,1.464101590);\n    \\draw[black] (-5.0,2.3) node{$R^\\phi(w)$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nA rotation preserves side-lengths and angles of a triangle.\nTherefore, a rotation preserves vector addition, that is,\n$R^\\phi(v+w)=R^\\phi(v)+R^\\phi(w)$, and thus\nsatisfies Definition~\\ref{LINEAR-TRANSFORMATION}\nand is a linear transformation.\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}[6]{r}{0.4\\textwidth}\n\\begin{tikzpicture}[x=0.20in,y=0.20in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+5,0);\n    \\draw[black] (0,-1) -- (0,+1);\n\n    \\fill[red] (0,0) circle(0.1);\n\n    \\draw[red] (-0.577350269,-1) -- (2.886751345,5);\n\n    \\draw[brown,>=latex,->] (4.0,0) arc(0:60:4.0);\n    \\draw[black] (3.6,2.6) node{$\\phi$};\n\n    \\fill[red] (2.897777478,0.776457135) circle(0.1);\n    \\draw[red,->] (0,0) -- (2.897777478,0.776457135);\n    \\draw[black] (3.2,0.3) node{$v$};\n\n    \\fill[red] (-0.776457135,2.897777478) circle(0.1);\n    \\draw[red,->] (0,0) -- (-0.776457135,2.897777478);\n    \\draw[black] (-1.3,+3.6) node{$F^\\phi(v)$};\n\n    \\draw[blue,>=latex,->] (1.0,1.732050807) arc(60:15:2.0);\n    \\draw[black] (2.0,1.5) node{$\\alpha$};\n\n    \\draw[blue] (1.0,1.732050807) circle(0.1);\n\n    \\draw[blue,>=latex,->] (1.0,1.732050807) arc(60:105:2.0);\n    \\draw[black] (0.3,2.3) node{$-\\alpha$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nA \\key{reflection} $F^\\phi$ by $\\phi$ degrees, which\nis a reflection across the line with direction $\\phi$\nthrough the origin,\nis defined mathematically by\n\\hspace*{0.2in}\\begin{tabular}[t]{l}\n$||F^\\phi(v)|| = ||v||$ \\\\\n$\\mathrm{azm}~F^\\phi(v) = \\phi - \\alpha$ \\\\\nwhere $\\alpha = \\mathrm{azm}~v - \\phi$ so \\\\\n$\\mathrm{azm}~F^\\phi(v) = 2*\\phi - \\mathrm{azm}~v$ if $||v||\\neq 0$ \\\\\n\\end{tabular} \\\\\n~\\\\\nA reflection negates angles between vectors; that is: \\\\\n\\hspace*{0.2in}$\\mathrm{azm}~F^\\phi(v)-\\mathrm{azm}F^\\phi(w)\n               = -(\\mathrm{azm}~v-\\mathrm{azm}~w)$\n\t       if $||v||\\neq 0 \\neq ||w||$ \\\\\nAlso, adding integer multiples of 180 to $\\phi$\ndoes \\underline{not} change $F^\\phi$.\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}[7]{r}{0.5\\textwidth}\n\\begin{tikzpicture}[x=0.25in,y=0.25in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+1,0);\n    \\draw[black] (0,-1) -- (0,+1);\n\n    \\fill[red] (0,0) circle(0.1);\n\n    \\draw[red] (-0.577350269,-1) -- (2.5,4.330127018);\n\n    \\fill[red] (2.897777478,0.776457135) circle(0.1);\n    \\draw[red,->] (0,0) -- (2.897777478,0.776457135);\n    \\draw[black] (1.5,0.8) node{$v$};\n\n    \\draw[blue,->] (2.897777478,0.776457135) -- (3.863703305,-1.035276180);\n    \\draw[black] (3.8,-0.0) node{$w$};\n\n    \\fill[red] (3.863703305,-1.035276180) circle(0.1);\n    \\draw[brown,->] (0,0) -- (3.863703305,-1.035276180);\n    \\draw[black] (2.0,-1.2) node{$v+w$};\n\n    \\fill[red] (-0.776457135,2.897777478) circle(0.1);\n    \\draw[red,->] (0,0) -- (-0.776457135,2.897777478);\n    \\draw[black] (+0.4,+2.6) node{$F^\\phi(v)$};\n\n    \\draw[blue,->] (-0.776457135,2.897777478) -- (-2.828427124,2.828427124);\n    \\draw[black] (-1.8,+3.5) node{$F^\\phi(w)$};\n\n    \\fill[red] (-2.828427124,2.828427124) circle(0.1);\n    \\draw[brown,->] (0,0) -- (-2.828427124,2.828427124);\n    \\draw[black] (-3.0,+1.0) node{$F^\\phi(v+w)$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nA reflection preserves side-lengths and negates angles of a triangle.\nTherefore, a reflection preserves vector addition, that is,\n$F^\\phi(v+w)=F^\\phi(v)+F^\\phi(w)$, and thus\nsatisfies Definition~\\ref{LINEAR-TRANSFORMATION}\nand is a linear transformation.\n\\end{minipage}\n\n\\vspace{0.5in}\n\nA linear map $L$ that preserves vector lengths ($||L(v)||=||v||$)\nis said to be \\key{unitary}.\nA unitary linear map $L$\nalso preserves the absolute values of angles between vectors,\nbecause $L$ preserves the side-lengths of any triangle made of\nvectors, and these determine the absolute values of the angles of\nthe triangle (but not the direction of these angles).  This means\nthat {\\tt azm L(v)} must be either `{\\tt {\\rm constant} + azm v}'\nor `{\\tt {\\rm constant} - azm v}'.  These two case are rotations\nand reflections, respectively.\n\nNow\n$L$, being linear, is determined by $L(u_x)$ and $L(u_y)$, where\n$u_x=(1,0)$ and $u_y=(0,1)$, and as $u_y$ is perpendicular to\n$u_x$, $L(u_y)$ must be perpendicular to $L(u_x)$ since $L$ is unitary.\n\nPutting all this together we have:\n\\begin{lemma}\nFor unitary $L=[\\ell_x,\\ell_y]$, $\\ell_x$ and $\\ell_y$ are\nvectors of unit length, and $\\ell_y$ is perpendicular to $\\ell_u$.\n\nIf $\\ell_y$ is $\\ell_x$ rotated counter-clockwise\nby 90 degrees, $L$ is a rotation, whereas if\n$\\ell_y$ is $\\ell_x$ rotated clockwise\nby 90 degrees, $L$ is a reflection.\n\\end{lemma}\n\nIf $L$ is a rotation, the angle of rotation is: \\\\\n\\centerline{$\\phi = \\mathrm{azm}~L(u_x) - \\mathrm{azm}~u_x =\n             \\mathrm{azm}~L(u_x)$}\nand we have: \\begin{tabular}[t]{l}\n             $L(u_x)=(\\cos\\phi,\\sin\\phi)$ \\\\\n             $L(u_y)=(-\\sin\\phi,\\cos\\phi)$ \\\\\n\t     \\end{tabular}\n\nIf $L$ is a reflection, the angle of the reflecting line is: \\\\\n\\centerline{$\\phi = (1/2)*(\\mathrm{azm}~L(u_x) + \\mathrm{azm}~u_x)\n                  = (1/2)*(\\mathrm{azm}~L(u_x))$}\nand we have: \\begin{tabular}[t]{l}\n             $L(u_x)=(\\cos(2*\\phi),\\sin(2*\\phi))$ \\\\\n             $L(u_y)=(\\sin(2*\\phi),-\\cos(2*\\phi))$ \\\\\n\t     \\end{tabular}\n\nBoth rotations and reflections preserve vector lengths\nand change vector angles according to a linear formula.\nUsing the notation $R^\\phi$ for rotation by angle $\\phi$,\nand $F^\\phi$ for reflection about the line at angle $\\phi$,\nwe get the following:\n\\begin{center}\n$R^\\phi*R^\\omega=R^\\omega*R^\\phi=R^{\\phi+\\omega}$\n~~because~~\n    $(\\mathrm{azm}~v + \\omega) + \\phi = \\mathrm{azm}~v + (\\phi+\\omega)$ \\\\\n$F^\\phi*F^\\omega = R^{2(\\phi-\\omega)}$\n~~because~~\n    $2\\phi - (2\\omega - \\mathrm{azm}~v) = \\mathrm{azm}~v + 2(\\phi-\\omega)$ \\\\\n$R^\\phi*F^\\omega = F^\\omega*R^{-\\phi}$\n~~because~~\n    $(2\\omega - \\mathrm{azm}~v) + \\phi =\n      2\\omega - (\\mathrm{azm}~v + (-\\phi))$\n\\end{center}\nNote that:\n\\begin{center}\n$R^\\phi*R^\\omega=R^{\\omega+\\phi}=R^\\omega*R^\\phi$ \\\\\n$R^\\phi$ and $R^\\omega$ commute \\\\\n$R^{-\\phi}$ is the inverse of $R^\\phi$ \\\\\n$F^\\phi*F^\\phi= I$ (the identity) so  $F^\\phi$ is its own inverse \\\\\n$F^\\omega*F^\\phi$ is the inverse of $F^\\phi*F^\\omega$ \\\\\nin general $F^\\phi$ and $F^\\omega$ do \\underline{not} commute\\\\\n\\end{center}\n\n\\bigskip\n\n\\section{Rotations and Reflections Calculator}\nImplement additions to the linear calculator for\nthe {\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l@{~~~~~}l}\n\\multicolumn{2}{l}{Assume:} \\\\\n        & {\\tt p} is a scalar \\\\\n\t& {\\tt v} is a vector \\\\\nthen: \\\\[1ex]\n\\tt v\\WH p & returns {\\tt w} such that {\\tt ||w||=||v||} and\n\t     {\\tt azm w = azm v + p}, \\\\\n\t   & {\\tt v} rotated by {\\tt p} degrees;\n\t     undefined if {\\tt ||v|| = 0} \\\\\n\\tt v|p & returns {\\tt w} such that {\\tt ||w||=||v||} and\n\t  {\\tt azm w = 2*p\\,-\\,azm v}, \\\\\n\t& {\\tt v} reflected across the line with direction\n\t  {\\tt p} degrees; \\\\\n\t& undefined if {\\tt ||v|| = 0} \\\\\n\\tt \\WH p & returns {\\tt [$u_x$\\WH p,$u_y$\\WH p]}, \\\\\n          & the rotation $R^p$ with angle $p$ degrees \\\\\n\\tt |p & returns {\\tt [$u_x$|p,$u_y$|p]}, \\\\\n       & the reflection $F^p$ across the line with direction $p$ degrees \\\\\n\\end{tabular}\n\\end{center}\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-unitary-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-unitary-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-unitary-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-unitary-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\n\\newpage\n\n\\section{Products}\nThere are two products of a pair of vectors that play a\nvery important role in 2D computational geometry:\n\n\\begin{definition}\nThe \\key{scalar product} of two vectors \\\\\n\\centerline{{\\tt v = ($v_x$,$v_y$)} and {\\tt w = ($w_x$,$w_y$)}} \\\\\nis \\\\\n\\centerline{\\tt v*w = $v_x w_x + v_y w_y$} \\\\\nThe \\key{cross product} (a.k.a., \\key{wedge product}) of the two vectors is \\\\\n\\centerline{\\tt v\\WH w = $(-v_y)w_x + v_x w_y$}\n\\end{definition}\n\nNote that {\\tt ||v||$^2$ = v*v}.\n\nIf we denote the rotation counter-clockwise by 90 degrees by {\\tt R}$^{90}$,\nthen \\\\\n\\centerline{\\tt v\\WH w = (-$v_y$,$v_x$)*w = R$^{90}$(v)*w}\n\nBoth the scalar and cross product are \\key{bi-linear}.  That is,\nif {\\tt u}, {\\tt v}, {\\tt w} are vectors and {\\tt s} is a scalar:\n\\begin{center}\n\\tt\n(u+v)*w = u*w + v*w \\\\\nu*(v+w) = u*v + u*w \\\\\n(s*u)*w = s*(u*w) = u*(s*w) \\\\\n(u+v)\\WH w = u\\WH w + v\\WH w \\\\\nu\\WH (v+w) = u\\WH v + u\\WH w \\\\\n(s*u)\\WH w = s*(u\\WH w) = u\\WH (s*w)\n\\end{center}\n\nThe scalar product is symmetric ({\\tt v*w = w*v})\nwhile the cross product is anti-symmetric ({\\tt v\\WH w = -w\\WH v}).\n\n\\begin{lemma}\nFor a unitary transform {\\tt L}:\n\\begin{enumerate}\n\\item {\\tt L(v)*L(w) = v*w} for all vectors {\\tt v} and {\\tt w}.\n\\item If {\\tt L} is a rotation,\n         {\\tt L(v)\\WH L(w) = v\\WH w} for all vectors {\\tt v} and {\\tt w}; \\\\\n      if {\\tt L} is a reflection,\n         {\\tt L(v)\\WH L(w) = - v\\WH w} for all vectors {\\tt v} and {\\tt w}.\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{indpar}{0.3in}\nProof: Since {\\tt L} is unitary: \\\\\n{\\small \\tt\n\\hspace*{0.05in}\n       \\begin{tabular}[t]{rcl}\n       ||v+w||$^2$ & = & (v+w)*(v+w) = v*v + v*w + w*v + w*w \\\\\n\t\t   & = & ||v||$^2$ + 2*v*w + ||w||$^2${\\rm ,} \\\\\n       {\\rm so} v*w & = & (1/2) \\\\\n                    & * & ( ||v+w||$^2$ - ||v||$^2$ - ||w||$^2$ ){\\rm ,} \\\\\n       {\\rm so} L(v)*L(w)\n         & = & (1/2) \\\\\n\t & * & (||L(v)+L(w)||$^2$-||L(v)||$^2$-||L(w)||$^2$) \\\\\n         & = & (1/2)*( ||v+w||$^2$ - ||v||$^2$ - ||w||$^2$ ) \\\\\n         & = & v*w\n       \\end{tabular}\n} % \\small \\tt\n\nIf $L$ is a rotation, {\\tt R$^{90}$*L=L*R$^{90}$} so \\\\\n{\\tt\n\\hspace*{0.1in}\n       \\begin{tabular}[t]{rcl}\n       L(v)\\WH L(w) & = & R$^{90}$(L(v))*L(w) = L(R$^{90}$(v))*L(w) \\\\\n                    & = & R$^{90}$(v)*w = v\\WH w \\\\\n       \\end{tabular}\n} % \\tt\n\nIf $L$ is a reflection, {\\tt R$^{90}$*L=L*R$^{-90}$}\nand {\\tt R$^{-90}$ = - R$^{90}$} so \\\\\n{\\tt\n\\hspace*{0.1in}\n       \\begin{tabular}[t]{rcl}\n       L(v)\\WH L(w) & = & R$^{90}$(L(v))*L(w) = L(R$^{-90}$(v))*L(w) \\\\\n                    & = & R$^{-90}$(v)*w = - R$^{90}$(v)*w = - v\\WH w\n       \\end{tabular}\n} % \\tt\n\\end{indpar}\n\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.5\\textwidth}\n\\begin{tikzpicture}[x=0.30in,y=0.30in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n    \\draw[black] (-1,0) -- (+5,0);\n    \\draw[black] (0,-1) -- (0,+3);\n    \\fill[red] (0,0) circle(0.1);\n\n    \\fill[blue] (4.330127018,2.5) circle(0.1);\n    \\draw[blue,->] (0,0) -- (4.330127018,2.5);\n    \\draw[black] (4.5,2.0) node{$v$};\n\n    \\fill[red] (2.0,3.464101615) circle(0.1);\n    \\draw[red,->] (0,0) -- (2.0,3.464101615);\n    \\draw[black] (0.6,+2.4) node{$||w||$};\n    \\draw[black] (2.0,+4.0) node{$w$};\n\n    \\draw[orange] (3.0,1.732050807) -- (2.0,3.464101615);\n    \\draw[black] (2.3,3.0) node[right]{$||w||*\\sin \\theta$};\n\n    \\draw[black] (3.4,0.7) node{$||w||*\\cos \\theta$};\n\n    \\draw[brown,>=latex,->] (1.5,0) arc(0:30:1.5);\n    \\draw[black] (1.0,+0.3) node{$\\phi$};\n\n    \\draw[brown,>=latex,->] (1.299038105,0.75) arc(30:60:1.5);\n    \\draw[black] (1.3,+1.3) node{$\\theta$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nWe can use the fact that $*$ and $\\wh$ are invariant under\nrotations to give a geometric characterization\nof these two products.  Let $v$ and $w$ be two vectors, let\n$\\theta=\\mathrm{azm}~w - \\mathrm{azm}~v$ be the direction angle of $w$\nrelative to $v$, and let $\\phi = \\mathrm{azm}~v$ be the azimuth of $v$\n(see the picture).\nIf we rotate both vectors by $R^{-\\phi}$\nwe line $v$ up with the positive X-axis, while not changing $\\theta$,\n$||v||$, $||w||$, $v*w$, or $v\\wh w$.  So after rotation we have\n\\hspace*{0.5in}\n    \\begin{tabular}{l@{~~~~~}l}\n    $v=(||v||,0)$ &\n    $w=(||w||\\cos\\theta,||w||\\sin\\theta)$ \\\\\n    $v*w=||v||\\times||w||\\times\\cos\\theta$ & \n    $v\\wh w=||v||\\times||w||\\times\\sin\\theta$ \\\\\n    \\end{tabular}\n\\end{minipage}\n\nFrom this we deduce two things.  First, \\\\\n\\hspace*{0.5in}\n    \\begin{tabular}{l@{~~~~~}l}\n    $v*w=||v||\\times||w||\\times\\cos\\theta$ &\n    $v\\wh w=||v||\\times||w||\\times\\sin\\theta$ \\\\\n    \\end{tabular} \\\\\nbefore rotation, as well as after rotation,\nwhich gives a geometric characterization of the products.\n\nSecond,\\hspace{0.5in}$||v||*R^{-\\mathrm{azm}~v}*w=(v*w,v\\wh w)$,\n\\\\[1ex]\nwhich gives us a quick way to change coordinate systems\nby a rotation times scalar multiplication by $||v||$ so that\n$v$ has coordinates $(||v||^2,0)$ in the new coordinate system.\nProblems that might be hard to solve in the original\ncoordinate system can be easily solved in the new coordinate\nsystem.  For example, the end of $w$ is to the left of the infinite directed\nline extending $v$ if and only if $v\\wh w>0$.  One can also solve\ndistance problems in the original coordinate system by solving them\nin the new coordinate system while remembering that the new system distances\nare $||v||$ times the original system distances.  If in addition\n$||v||=1$, distances in the new system equal distances in the original\nsystem.\n\n\\bigskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.37\\textwidth}\n\\begin{tikzpicture}[x=0.30in,y=0.30in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n\n    \\fill[black] (0,0) circle(0.1);\n    \\draw[black] (0.0,-0.5) node{$p_1$};\n\n    \\fill[black] (2.0,3.464101615) circle(0.1);\n    \\draw[black] (0,0) -- (2.0,3.464101615);\n    \\draw[black] (2.0,+4.0) node{$p_2$};\n    \\draw[black] (-0.3,+2.0) node{$||p_2-p_1||$};\n\n    \\fill[black] (4.330127018,2.5) circle(0.1);\n    \\draw[black] (2.0,3.464101615) -- (4.330127018,2.5);\n    \\draw[black] (4.5,2.0) node{$p_3$};\n\n    \\draw[black] (4.330127018,2.5) -- (0,0);\n\n    \\draw[orange] (3.0,1.732050807) -- (2.0,3.464101615);\n    \\draw[black] (4.5,5.5) node[left]{$||p_2-p_1||*\\sin \\theta$};\n    \\draw[black,>=latex,->] (3.7,5.3) -- (2.5,2.598076);\n\n    \\draw[black] (3.4,0.7) node{$||p_3-p_1||$};\n\n    \\draw[brown,>=latex,->] (1.299038105,0.75) arc(30:60:1.5);\n    \\draw[black] (1.3,+1.3) node{$\\theta$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nLastly, looking at the picture at the right, we see that:\n\\hspace*{0.2in}\n    \\begin{tabular}{r@{~=~}l}\n    \\multicolumn{2}{l}{area of triangle $p_1 p_2 p_3$} \\\\\n    & $(1/2)*||p_2-p_1||*\\sin\\theta*||p_3-p_1||$ \\\\\n    & $(1/2)*(p_3-p_1)\\wh (p_2-p_1)$ \\\\\n    & $-~(1/2)*(p_2-p_1)\\wh (p_3-p_1)$ \\\\\n    \\end{tabular} \\\\\n~\\\\\nSo we can use the cross product to compute triangle areas,\nbut its a bit tricky because what we get is a signed area.\nThe result is positive if\nthe angle $\\theta$ measured from the first factor of $\\wh $ to the\nsecond factor of $\\wh $ is in the range $[0,180]$, and negative if\n$\\theta$ is in the range $[-180,0]$.\n\\end{minipage}\n\n\\newpage\n\n\n\\section{Products Calculator}\nImplement additions to the unitary calculator for\nthe following {\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l@{~~~~~}l}\nAssume: & {\\tt v=$v$=}$(v_x,v_y)$ (a vector)\n          ~~~ {\\tt w=$w$=}$(w_x,w_y)$ (a vector) \\\\\n\t& $u_x=(1,0)$ and $u_y=(0,1)$ \\\\\n\t& {\\tt p=}$p$, {\\tt q=}$q$, {\\tt r=}$r$ (vectors representing points) \\\\\nthen: \\\\[1ex]\n\\tt v*w & returns $v_x w_x + w_y w_y$,\n          the scalar product of {\\tt v} and {\\tt w} \\\\\n\\tt v\\WH w & returns $(-v_y)w_x+v_x w_y$,\n           the cross product of {\\tt v} and {\\tt w} \\\\\n\\tt v:w & returns $||v||*R^{-\\mathrm{azm}~v}*w = (v*w,v\\wh w)$ \\\\\n\\tt <v> & returns $(1/||v|)*v$, the unit vector in the same direction as $v$ \\\\\n\\tt v!w & returns $R^{-\\mathrm{azm}~v}*w = (<v>*w,<v>\\wh w)$ \\\\\n\\tt v:  & returns {\\tt [$v$:$u_x$,$v$:$u_y$]} ~~~ (so {\\tt (v:)*w = v:w}) \\\\\n\\tt v!  & returns {\\tt [$v$!$u_x$,$v$!$u_y$]} ~~~ (so {\\tt (v!)*w = v!w}) \\\\\n\\tt area~pqr & returns $0.5*(r-p)\\wh (q-p)$, the area of triangle $pqr$, \\\\\n             & with positive sign if $pqr$ clockwise, \\\\\n\t     & and negative sign if counter-clockwise \\\\\n\\end{tabular}\n\\end{center}\n\nIf {\\tt ||v|| = 0} then {\\tt <v>} and {\\tt v!w} will produce coordinates such as\n{\\tt inf} (plus infinity), {\\tt -inf} (minus infinity),\nand {\\tt nan} (not a number; i.e., result could not be computed).\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-product-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-product-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-product-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-product-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\n\\newpage\n\n\\section{Line and Point}\\label{LINE-AND-POINT}\nIn this section we investigate the following questions:\n\\begin{enumerate}\n\\item Is a point on, to the left of, or to the right of\nan infinite directed line?  What is the distance from the\npoint to the line and where is the closest point that is\non the line?\n\\item What is the general position of a point relative\nto a finite line segment?  What is the distance from the\npoint to the line segment?\n\\item What is the general position of a direction relative\nto two other directions, where all three directions are\ndefined by directed lines passing through a common point?\n\\end{enumerate}\n\nWe begin with a line {\\tt pq} from point {\\tt p} to point {\\tt q},\n{\\tt p$\\neq$q}.\nWe may take this line to be either infinite, or to be a finite\nline segment with ends {\\tt p} and {\\tt q}.  We may take the\nline to be undirected, or to be directed from {\\tt p} to {\\tt q}.\n\nWe then consider a third point {\\tt r} and ask about its relation\nto {\\tt pq}.\n\nThe answers to our questions will not be changed if we perform\na coordinate translation on all the points, so we begin by moving\n{\\tt p} to the origin {\\tt (0,0)} using a translation by {\\tt -p}.\nOur points become:\n\\begin{center} \\tt\np - p = (0,0) \\\\\nq - p \\\\\nr - p\n\\end{center}\nNext we apply the rotation $R^{\\tt -azm(q-p)}$\nfollowed by multiplication by {\\tt ||q-p||}.  This was computed\nin the last section as the linear transform \\\\\n\\centerline{\\tt (q-p): = ||q-p||*$R^{\\tt -azm(q-p)}$}\nThis transformation preserves angles and multiplies distances by {\\tt ||q-p||}.\n\nIf we apply {\\tt (q-p):} after the translation {\\tt -p}, we get:\n\\begin{center} \\tt\nP = (q-p):(p-p) = (0,0) \\\\\nQ = (q-p):(q-p) = ( (q-p)*(q-p), 0 ) \\\\\nR = (q-p):(r-p) = ( (q-p)*(r-p), (q-p)\\WH(r-p) )\n\\end{center}\nwhere we use the facts that {\\tt p - p = (0,0)} and\n{\\tt (q-p)\\WH(q-p) = 0}.\n\nNext we define {\\tt X} and {\\tt Y} to be the coordinates of {\\tt R}\nso {\\tt R = (X,Y)}, and {\\tt L} to be the X coordinate of {\\tt Q}\nso {\\tt Q = (L,0)}.\n\nIf\\label{DISTANCE-OF-LINE-TO-POINT}\nwe want the distance from {\\tt r} to the infinite line {\\tt pq},\nthen this is the same as {\\tt 1/||q-p||} times\nthe distance from {\\tt R = (X,Y)} to the infinite\nline {\\tt PQ}, and the latter is the X-axis.  So the answer is \\\\\n\\centerline{\\tt |Y|/||q-p|| = |(q-p)\\WH(r-p)|/||q-p||}\n\nNext we want to find the point {\\tt t} on the infinite line {\\tt pq}\nthat is closest to {\\tt r}.  We will represent {\\tt t} as {\\tt t = p + s*(q-p)}\nfor the appropriate scalar {\\tt s}.  Then {\\tt t-p} is the closest point to\n{\\tt r-p} on the infinite line from {\\tt (p-p)} to {\\tt (q-p)}\nand if we apply the\nlinear transformation {\\tt (q-p):~= ||q-p||*$R^{\\tt -azm (q-p)}$},\nwe get that {\\tt T = (q-p):(t-p)} is the closest point to {\\tt R} on the\nline {\\tt PQ}, since rotations preserve distances and multiplication\nof all coordinates by {\\tt ||q-p||} preserves the notion of `closest'.\nBut the closest point to {\\tt R = (X,Y)} on {\\tt PQ = {\\rm the X-axis}}\nis {\\tt (X,0)}, so {\\tt T = (X,0)}.\nAnd as {\\tt (q-p):} is a linear transformation and {\\tt t-p = s*(q-p)},\nthen {\\tt T = s*(Q-P) = s*Q}~~(since {\\tt P = (0,0)}).\n\n\\hspace*{0.3in}\\begin{tabular}{rl}\nso\t& \\tt T = (X,0) = s*Q = (s*L,0) \\\\\nso\t& \\tt s = X/L \\\\\ntherefore     & \\tt t = p + (X/L)*(q-p) \\\\\nor\t& \\tt t = p + ((q-p)*(r-p)/(q-p)*(q-p)) * (q-p) \\\\\n\\end{tabular}\n\nNote that if {\\tt p}, {\\tt q}, and {\\tt r} have rational coordinates,\nthen {\\tt t} has rational\\label{CLOSEST-IS-RATIONAL},\nand \\underline{not} irrational,\ncoordinates.  However the denominator may be large.  If\nthe input coordinates have at most {\\tt d} decimal places,\ntheir denominator is at most $10^d$, and the denominator of {\\tt t}\nmay be as large as \\\\\n\\centerline{\\tt 10$^{\\tt d}$*({\\rm numerator of} L)}\nwhere we use the fact that the denominators of {\\tt X} and {\\tt L}\nwhich are $10^{2d}$ cancel each other out in {\\tt X/L} so \\\\\n\\centerline{\\tt X/L = ({\\rm numerator of} X)/({\\rm numerator of} L)}\n\n\n\\medskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.53\\textwidth}\n\\begin{tikzpicture}[x=0.25in,y=0.25in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n\n    \\draw[black] (-1,0) -- (+9,0);\n    \\draw[black] (0,-1) -- (0,+3);\n    \\fill[red] (0,0) circle(0.1);\n    \\fill[red] (6.0,0) circle(0.1);\n    \\draw[brown] (6.0,-1) -- (6.0,+3);\n    \\draw[black] (0.0,-0.5) node[right]{\\small \\tt P=(0,0)};\n    \\draw[black] (6.0,-0.5) node[right]{\\small \\tt Q=(L,0)};\n    \\draw[black] (0.0,+1.0) node[left]{\\small \\tt X<0};\n    \\draw[black] (+6.0,+1.0) node[right]{\\small \\tt X>L};\n    \\draw[black] (+3.0,+2.0) node{\\small \\tt 0<=X<=L};\n    \\draw[black] (+8.0,+3.0) node{\\small \\tt R=(X,Y)};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nIf we want the distance from {\\tt r} to the \\underline{finite} line {\\tt pq},\nthen this is the same as {\\tt 1/||q-p||} times\nthe distance from {\\tt R} to the finite\nline {\\tt PQ}, and there are three cases.\nIf {\\tt X<0}, the answer\nis {\\small \\tt ||R-P||/||q-p||}.  If {\\tt X>L},\nthe answer is {\\small \\tt ||R-Q||/||q-p||}.\nOtherwise the answer is {\\small \\tt |Y|/||q-p||} as before.\nSee picture.\n\\end{minipage}\n\n\\medskip\n\nHere we can simplify the above by using: \\\\\n\\begin{tabular}{@{~~}l}\n\\tt ||R-P||/||q-p|| = ||(q-p):(r-p)||/||q-p|| = ||r-p|| \\\\\n\\tt ||R-Q||/||q-p|| = ||(q-p):(r-q)||/||q-p|| = ||r-q|| \\\\\n\\end{tabular}\n\nNow suppose we want a precise answer to the question: is {\\tt r}\non the infinite or finite line {\\tt pq}?  This is the same as the question:\nis {\\tt R} on the infinite or finite line {\\tt PQ}?\nIf the coordinates of {\\tt p}, {\\tt q}, and {\\tt r} have at\nmost {\\tt d} decimal places, they are rational numbers with\ndenominator {\\tt 10$^{\\tt d}$}, and the products will be rational\nnumbers with denominator {\\tt 10$^{\\tt 2d}$}, so the coordinates of\n{\\tt R} and {\\tt Q} will have denominator {\\tt 10$^{\\tt 2d}$}.\nOr more precisely,\nthe computed coordinates will be close approximations to such rational numbers.\nTherefore\n\\begin{enumerate}\n\\item {\\tt r} is to the left of the infinite directed line {\\tt pq}\nif and only if {\\tt 0<Y:(2d)}.\n\\item {\\tt r} is to the right of the infinite directed line {\\tt pq}\nif and only if {\\tt Y<0:(2d)}.\n\\item {\\tt r} is on the infinite directed line {\\tt pq}\nif and only if {\\tt Y==0:(2d)}.\n\\item {\\tt r} is on the finite line {\\tt pq} if and only if \\\\\n\\hspace*{0.3in}{\\tt Y==0:(2d)},~~{\\tt 0<=X:(2d)},~~and~~{\\tt X<=L:(2d)}\n\\end{enumerate}\n\nThere is a difference in the treatment of {\\tt X < 0} between\nthe problem of computing a distance from {\\tt r} to the finite\nline {\\tt pq} and the problem of computing whether {\\tt r} is\non the finite line {\\tt pq}.  In both problems the line {\\tt X = 0} is\na boundary between different cases.  In the distance case, the distance\nis continuous across this boundary, so the computed value, the distance,\ndoes not change much when {\\tt (X,Y)} moves across the boundary.\nIn the other case, the computed value may change\nfrom {\\tt false} to {\\tt true} as {\\tt (X,0)} moves from {\\tt X < 0}\nto {\\tt 0 <= X}, and thus the computed value is discontinuous.\n\nIn the continuous case we need not concern ourselves with how many\ndecimal places {\\tt X} has, and we can use {\\tt X < 0} instead of\n{\\tt X<0:(2d)}.  In the discontinuous case we cannot get a meaningful\n{\\tt true/false} answer unless we restrict the number of decimal\nplaces in {\\tt X}, though we could get a {\\tt true/false/maybe}\nanswer if we knew more about the potential error in our value for\n{\\tt X}.\n\nWe will say that {\\tt X = 0} is a \\key{boundary} that is\n\\key{continuous} in the distance computation and \\key{discontinuous}\nin the {\\tt on/not-on} computation.\nFor continuous boundaries we can use inequalities to decide which\nside of the boundary we are on without worrying about accuracy.\nFor discontinuous boundaries we must worry about accuracy and\nuse tests like {\\tt X<0:(2d)}.\n\n\\medskip\n\n\\begin{minipage}{\\textwidth}\\raggedright\n\\begin{wrapfigure}{r}{0.48\\textwidth}\n\\begin{tikzpicture}[x=0.25in,y=0.25in]\n\\begin{scope}[>=triangle 45,shorten >=0.01in]\n\n    \\draw[black,->] (-4.5,+1.5) -- (+4.5,-1.5);\n    \\draw[black,->] (-3.5,-2.5) -- (+3.5,+2.5);\n    \\draw[red,->] (0,0) -- (+2.5,+1);\n    \\fill[red] (0,0) circle(0.1) + (0,-0.5) node[black]{\\tt p};\n    \\fill[red] (4.5,-1.5) circle(0.1) + (0.5,0) node[black]{\\tt q$_1$};\n    \\fill[red] (3.5,2.5) circle(0.1) + (0.5,0) node[black]{\\tt q$_2$};\n    \\fill[red] (2.5,1) circle(0.1) + (0.5,0) node[black]{\\tt q};\n    \\draw[black] (4,0) node{LR};\n    \\draw[black] (-0.5,2.5) node{LL};\n    \\draw[black] (-4,0) node{RL};\n    \\draw[black] (+0.5,-2.5) node{RR};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{wrapfigure}\nLastly, let us find the general position of a direction {\\tt pq} relative\nto two other directions, {\\tt pq$_1$}  and {\\tt pq$_2$}, where\n{\\tt q$_2$} is to the \\underline{left} of the infinite directed line\n{\\tt pq$_1$} (see picture).\nThe infinite directed lines {\\tt pq$_1$}  and {\\tt pq$_2$} divide space into\nfour regions:\n\\begin{itemize}\n\\item[LR]\nfor points {\\tt q} that are to the \\underline{left} of {\\tt pq$_1$}\nand to the \\underline{right} of {\\tt pq$_2$};\n\\item[LL] for points {\\tt q} that are to the \\underline{left} of {\\tt pq$_1$}\nand to the \\underline{left} of {\\tt pq$_2$};\n\\item[RL] for points {\\tt q} that are to the \\underline{right} of {\\tt pq$_1$}\nand to the \\underline{left} of {\\tt pq$_2$};\n\\item[RR] for points {\\tt q} that are to the \\underline{right} of {\\tt pq$_1$}\nand to the \\underline{right} of {\\tt pq$_2$};\n\\end{itemize}\n\\end{minipage}\n\n\\medskip\n\nThus, for example,\nif {\\tt q} is in region LR, then when {\\tt pq$_1$} is rotated\ncounter-clock\\-wise\nit will line up with {\\tt pq} \\underline{before} it lines up with\n{\\tt pq$_2$}.\n\nTherefore we can use what we already know about finding which side\nof an infinite line a point is on\nto find the general position of a direction relative to\ntwo other directions.\n\nNote that if\n{\\tt pq$_2$} and {\\tt pq$_1$} have the same direction,\nLR and RL are empty, whereas if\n{\\tt pq$_2$} and {\\tt pq$_1$} have opposite directions,\nLL and RR are empty.\n\n\\newpage\n\n\\section{Line and Point Calculator}\nImplement additions to the product calculator for\nthe following {\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~}l@{~~~~}l}\nAssume: & {\\tt p}, {\\tt q}, {\\tt r}, {\\tt u}, {\\tt v}\n          are vectors representing points \\\\\n\t& {\\tt D=}$D$ is an integer scalar, $-15\\le D\\le +15$ \\\\\nthen: \\\\[1ex]\n\\tt disti~pqr  & returns the distance from point {\\tt r} to the\n\t\t\\underline{infinite} line {\\tt pq} \\\\\n\\tt distf~pqr  & returns the distance from point {\\tt r} to the\n\t\t\\underline{finite} line {\\tt pq} \\\\\n\\tt closei~pqr  & returns the point {\\tt t} on the \\underline{infinite}\n                  line {\\tt pq} \\\\\n\t\t& that is closest to the point {\\tt r} \\\\\n\\tt closef~pqr  & returns the point {\\tt t} on the \\underline{finite}\n                  line {\\tt pq} \\\\\n\t\t& that is closest to the point {\\tt r} \\\\\n\\tt sidei~pqrD & returns {\\tt +1} if {\\tt r} is to the left of the\n                \\underline{infinite directed} line \\\\\n\t      & {\\tt pq}, zero if it is on the line,\n\t        and -1 if it is to the right; \\\\\n\t      & if all coordinates are exact multiples of $10^{-D}$ \\\\\n\t      & and have absolute values $\\le 10^{6-D}$ \\\\\n\\tt onf~pqrD & returns {\\tt true} if and only if {\\tt r} is on the\n                \\underline{finite} line {\\tt pq}; \\\\\n\t      & if all coordinates are exact multiples of $10^{-D}$ \\\\\n\t      & and have absolute values $\\le 10^{6-D}$ \\\\\n\\tt between~puvwD & returns {\\tt true} if and only if the direction\n                   {\\tt pu} rotated \\\\\n\t\t & counter-clockwise will line up with the direction \\\\\n\t\t & {\\tt pv} before it lines up with {\\tt pw}; but returns\n\t\t   {\\tt false} \\\\\n\t\t & if any two of the three directions are identical; \\\\\n\t      & if all coordinates are exact multiples of $10^{-D}$ \\\\\n\t      & and have absolute values $\\le 10^{6-D}$ \\\\\n\\end{tabular}\n\\end{center}\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-point-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-point-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-point-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-point-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\n\\newpage\n\n\n\\section{Line and Line}\nIn this section we investigate the following questions:\n\\begin{enumerate}\n\\item Do two infinite lines intersect, and if so where?\n\\item Does a finite line intersect an infinite line?\n\\item What is the distance between a finite line and an infinite line?\n\\item Do two finite lines intersect?\n\\item What is the distance between two finite lines?\n\\end{enumerate}\n\nLet {\\tt p} and {\\tt q} be a pair of distinct points so that the set\nof points on the infinite line {\\tt pq} is: \\\\\n\\centerline{{\\tt K} = \\{ {\\tt p + s*(q-p)}: {\\tt s} any scalar \\}} \n\nLet {\\tt m} and {\\tt n} be another pair of distinct points so that the set\nof points on the infinite line {\\tt mn} is: \\\\\n\\centerline{{\\tt K} = \\{ {\\tt m + t*(n-m)}: {\\tt t} any scalar \\}} \n\nIf these two infinite lines intersect, there must exist values for\n{\\tt s} and {\\tt t} such that: \\\\\n\\centerline{{\\tt p + s*(q-p) = m + t*(n-m)}}\n\nThe easy way to solve this is to take the cross product of both\nsides with {\\tt n-m}, because\n{\\tt (n-m)\\WH(t*(n-m)) = t*((n-m)\\WH(n-m)) = t*0 = 0}.\nSo we end up with: \\\\\n\\centerline{\\tt s*(n-m)\\WH(q-p) = (n-m)\\WH(m-p)} \\\\\nwhich we can solve for {\\tt s}.  Unless {\\tt (n-m)\\WH(q-p) = 0}.\n\nIf {\\tt (n-m)\\WH(q-p) $\\ne$ 0} then plugging {\\tt s} into\n{\\tt p + s*(q-p)} and using \\\\\n\\centerline{\\tt (n-m)\\WH(q-p) - (n-m)\\WH(m-p) = (n-m)\\WH(q-m)}\nwe get that the intersection point is: \\\\\n\\centerline{\\tt \\begin{tabular}{c}\n                [(n-m)\\WH(q-m)]*p + [(n-m)\\WH(m-p)]*q\n\t\t\\\\\\hline\n\t\t(n-m)\\WH(q-p) \\\\\n\t\t\\end{tabular} }\n\nWhat happens if {\\tt (n-m)\\WH(q-p) = 0}? \\\\\n\\hspace*{0.3in}\\begin{tabular}{r@{~~}l}\nThen    & \\tt (n-m)\\WH(q-p) = sin $\\theta$*||n-m||*||q-p|| = 0 \\\\\nwhere   & \\tt ||n-m|| $\\neq$ 0 $\\neq$ ||q-p|| \\\\\nand     & \\tt $\\theta$ = azm (q-p) - azm (n-m) \\\\\nso      & \\tt sin $\\theta$ = 0 \\\\\nso      & \\tt $\\theta$ = 0 or $\\pm$180 \\\\\nso      & {\\tt nm} and {\\tt pq} are parallel \\\\\n        \\end{tabular}\n\nThe converse is also true.  If {\\tt mn} and {\\tt pq} are parallel, \\\\\n\\hspace*{0.3in}\\begin{tabular}{r@{~~}l}\nthen    & {\\tt azm (n-m) = azm (q-p)} \\\\\nor      & {\\tt azm (n-m) = azm (q-p) $\\pm$ 180} \\\\\nand     & \\tt ||n-m|| $\\neq$ 0 $\\neq$ ||q-p|| \\\\\nso      & {\\tt n-m = s*(q-p)} for some scalar {\\tt s} \\\\\nso      & \\tt (n-m)\\WH(q-p) = s*((q-p)\\WH(q-p)) = 0 \\\\\n        \\end{tabular}\n\nOf course, testing a product to see if it is {\\tt 0} is subject to\nrounding errors.  So we assume that the coordinates of {\\tt m},\n{\\tt n}, {\\tt p}, and {\\tt q} have at most {\\tt d} decimal places,\nand therefore {\\tt mn} is parallel to {\\tt pq} if and only if\n{\\tt (n-m)\\WH(q-p)==0:(2d)}.\n\nIf {\\tt mn} and {\\tt pq} are parallel infinite lines, they\nmay be disjoint or identical.  To test which, test whether\n{\\tt m} is on the infinite line {\\tt pq} \n\nThe question of whether a finite line {\\tt mn} intersects an\ninfinite line {\\tt pq} can be answered by applying the translation\nby {\\tt -p} and then the linear transform {\\tt (q-p):} to get:\n\\begin{center}\n\\begin{tabular}{rcl}\n\\tt m & $\\longmapsto$ & \\tt M = ( (q-p)*(m-p), (q-p)\\WH(m-p) ) \\\\\n\\tt n & $\\longmapsto$ & \\tt N = ( (q-p)*(n-p), (q-p)\\WH(n-p) ) \\\\\ninfinite {\\tt pq} & $\\longmapsto$ & X-axis \\\\\n\\end{tabular}\n\\end{center}\nThen intersection occurs if and only if {\\tt M.y} and {\\tt N.y}\nhave opposite signs or one is zero, or more precisely:\n\\begin{theorem}\nIf the coordinates of {\\tt m},\n{\\tt n}, {\\tt p}, and {\\tt q} have at most {\\tt d} decimal places,\nfinite {\\tt mn} intersects infinite {\\tt pq} if and only if:\n\\begin{center}\n{\\tt M.y > 0:(2d)} and {\\tt N.y < 0:(2d)} \\\\\nor \\\\\n{\\tt M.y < 0:(2d)} and {\\tt N.y > 0:(2d)} \\\\\nor \\\\\n{\\tt M.y == 0:(2d)} \\\\\nor \\\\\n{\\tt N.y == 0:(2d)}\n\\end{center}\nwhere {\\tt M.y == (q-p)\\WH(m-p)} and {\\tt N.y == (q-p)\\WH(n-p)}.\n\\end{theorem}\nThe question of intersection has a discontinuous true/false\nanswer, so the boundaries {\\tt M.y == 0} and {\\tt N.y == 0}\nare discontinuous for this question.  However, for the\nquestion of the distance of finite {\\tt mn} from infinite {\\tt pq},\nthe boundaries are continuous, and remembering that distances in\nthe transformed coordinates are {\\tt ||q-p||} times distances\nin the original coordinates, we have:\n\\begin{theorem}\nThe distance between the finite line {\\tt mn} and the infinite\nline {\\tt pq} is {\\tt 0} (due to intersection) unless\n\\begin{center}\n{\\tt M.y > 0} and {\\tt N.y > 0} \\\\\nor \\\\\n{\\tt M.y < 0} and {\\tt N.y < 0} \\\\\n\\end{center}\nin which case it is \\\\\n\\centerline{\\tt min (|M.y|, |N.y|) / ||q-p||}\n\nwhere {\\tt M.y == (q-p)\\WH(m-p)} and {\\tt N.y == (q-p)\\WH(n-p)}.\n\\end{theorem}\n\n\nThe question of whether two \\underline{finite} lines intersect is made\nsimpler by the following:\n\\begin{lemma}\nTwo finite lines do \\underline{not} intersect\nif either does not intersect the infinite extension of the other.\n\nOtherwise the two finite lines intersect at a single point unless\nthe infinite extensions of the two finite lines are identical.\n\\end{lemma}\n\\begin{indpar}{0.3in}\nProof: The first statement is clear.\n\nIf the infinite extensions of the finite lines are parallel, either\nthe infinite extensions are identical, or neither finite line\nintersects the infinite extension of the other line.\nSo if both the finite lines intersect the infinite extension of the other,\nand if these infinite extensions are not identical, then the\ninfinite extensions are not parallel, so they must intersect at a\nsingle point.  So each finite line must intersect the infinite extension\nof the other line at a single point.\n\nThen let the finite lines be $\\ell_1$ and $\\ell_2$ and let\n$\\ell_i$ intersect the infinite extension of the other finite line\nat the point $r_i$.  So $r_1=r_2=$ the intersection of the infinite\nextensions of both lines, and as $r_i$ is on $\\ell_i$, this point is\non both finite lines.\n\\end{indpar}\n\nWe can check whether the infinite extensions of the {\\tt mn} and {\\tt pq}\nare the same by checking whether {\\tt m} and {\\tt n} are both on\nthe infinite extension of {\\tt pq}, or in other words, whether: \\\\\n\\centerline{{\\tt (q-p)\\WH(m-p)==0:(2d)} and {\\tt 0==(q-p)\\WH(n-p):(2d)}}\n\nIf the two infinite extensions of the two finite lines {\\tt pq} and\n{\\tt mn} are the same\ninfinite line, we need a new approach.  We need to establish a coordinate\nsystem on this infinite line.\n\nIf {\\tt r} is a point on this infinite line then we can map\n\\begin{center}\n{\\tt r $\\mapsto$ R = ( (q-p)*(r-p), (q-p)\\WH(r-p) ) = (R.x,0)}\n\\end{center}\nand use the map\n\\begin{center}\n{\\tt r $\\mapsto$ R.x = (q-p)*(r-p)}\n\\end{center}\nas coordinates on this line.  In this system of coordinates distances\nare {\\tt ||q-p||} times distances in the original system of coordinates.\n\nIn this coordinate system,\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l}\n\\tt P.x = (q-p)*(p-p) = 0 &\n\\tt Q.x = (q-p)*(q-p) > 0 \\\\\n\\tt M.x = (q-p)*(m-p) &\n\\tt N.x = (q-p)*(n-p) \\\\\n\\end{tabular}\n\\end{center}\nWe will switch m and n if necessary so that {\\tt M.x < N.x}.\nThen the two finite lines are {\\tt pq} represented by the\ninterval {\\tt [P.x,Q.x]} and {\\tt mn} represented by the\ninterval {\\tt [M.x,N.x]}.  Therefore {\\tt pq} and {\\tt mn}\n\\begin{center}\n\\begin{tabular}{l}\ndo \\underline{not} intersect if {\\tt N.x < P.x:(2d)} or {\\tt Q.x < M.x:(2d)} \\\\\n\\underline{do} intersect\n  if {\\tt N.x $\\ge$ P.x:(2d)} and {\\tt Q.x $\\ge$ M.x:(2d)} \\\\\n\\end{tabular}\n\\end{center}\n\nDeciding whether or not {\\tt pq} and {\\tt mn} intersect is a discontinuous\nproblem.  However finding the length of the intersection under the\nassumption that both lines have the same infinite extension is\na continuous problem.  The intersection of {\\tt pq} and {\\tt mn},\nexpressed using our line coordinates, is:\n\\begin{center}\n\\tt [P.x,Q.x]$\\cap$[M.x,N.x] = [max(P.x,M.x),min(Q.x,N.x)]\n\\end{center}\nso the length of the intersection is\n\\begin{center}\n\\begin{tabular}{c}\n\\tt min(Q.x,N.x) - max(P.x,M.x)\n\\\\\\hline\n\\tt ||q-p||\n\\end{tabular} if this is $\\ge$ 0\n\\\\[3ex]\nor 0 otherwise\n\\end{center}\n\nThis length is continuous across the boundary\n\\begin{center}\n\\tt min(Q.x,N.x) = max(P.x,M.x)\n\\end{center}\n\nLastly we consider the problem of finding the distance between\nthe finite line {\\tt mn} and the finite line {\\tt pq}.  We assume:\n\n\\begin{theorem}\nIf {\\tt mn} and {\\tt pq} are finite lines, the function from pairs\nof points\n{\\tt r$_{\\tt mn}$} on {\\tt mn} and\n{\\tt r$_{\\tt pq}$} on {\\tt pq}  to the distance\n{\\tt ||r$_{\\tt mn}$ - r$_{\\tt pq}$||} has a minimum.\n\\end{theorem}\n\nWe will \\underline{not} give a proof of this,\nwhich involves the mathematics of compact sets.\n\nBut we will use this theorem to prove:\n\n\\begin{theorem}\n\\label{FINITE-LINE-DISTANCE-THEOREM}\nIf either {\\tt mn} and {\\tt pq} are finite lines that do not intersect, or\n{\\tt mn} and {\\tt pq} are finite lines whose infinite extensions are\nidentical, then\npoints {\\tt r$_{\\tt mn}$} on {\\tt mn} and\n{\\tt r$_{\\tt pq}$} on {\\tt pq} may be chosen so that\n{\\tt ||r$_{\\tt mn}$ - r$_{\\tt pq}$||} is minimal and\none of the chosen points is an end-point of its finite line.\n\nTherefore the distance from {\\tt mn} to {\\tt pq} is the\nminimum of: \\\\\n\\hspace*{0.5in}\\begin{tabular}{l}\nthe distance from {\\tt m} to {\\tt pq} \\\\\nthe distance from {\\tt n} to {\\tt pq} \\\\\nthe distance from {\\tt p} to {\\tt mn} \\\\\nthe distance from {\\tt q} to {\\tt mn} \\\\\n\\end{tabular}\n\\end{theorem}\n\n\\begin{indpar}{0.3in}\nProof: By the previous theorem, {\\tt r$_{\\tt mn}$} in {\\tt mn} and\n{\\tt r$_{\\tt pq}$} in {\\tt pq} can be chosen so that\n{\\tt ||r$_{\\tt mn}$ - r$_{\\tt pq}$||} is minimal.\n\nFirst assume that the infinite extensions of {\\tt mn} and {\\tt pq} are\n\\underline{not} identical, and therefore {\\tt mn} and {\\tt pq} do not\nintersect.  Consider the infinite line $\\ell$ through\n{\\tt r$_{\\tt mn}$} and {\\tt r$_{\\tt pq}$}, and assume that\nneither\n{\\tt r$_{\\tt mn}$} or {\\tt r$_{\\tt pq}$} are endpoints.\nThen $\\ell$ may be translated to its left or right by\na small enough amount that the translation continues\nto intersect both finite lines.  Let the translation\nbe $\\ell'$ and its intersections with the finite lines be\n{\\tt r'$_{\\tt mn}$} and {\\tt r'$_{\\tt pq}$}.\nIf {\\tt mn} and {\\tt pq} are not parallel, then\n{\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$||} will increase\nas $\\ell$ is translated in one direction and decrease as\nit is translated in the other direction, but a decrease\ncannot happen by assumption of minimality of\n{\\tt ||r$_{\\tt mn}$ - r$_{\\tt pq}$||}, so by contradiction either\n{\\tt r$_{\\tt mn}$} or {\\tt r$_{\\tt pq}$} must be an endpoint.\n\nIf on the other hand {\\tt mn} and {\\tt pq} are parallel,\n{\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$||} will remain constant\nfor all translations of $\\ell$, and $\\ell$ can be translated\nin either direction until it encounters an endpoint.\n\nSecond, assume that the infinite extensions of {\\tt mn} and {\\tt pq}\nare identical ({\\tt mn} and {\\tt pq} may or may not intersect).\nIf {\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$|| > 0} and\neither\n{\\tt r$_{\\tt mn}$} or {\\tt r$_{\\tt pq}$} is not an endpoint, the one\nthat is not an endpoint can be translated right or left to decrease\n{\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$||}, contradicting the minimality of\n{\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$||}.  If on the other hand\n{\\tt ||r'$_{\\tt mn}$ - r'$_{\\tt pq}$|| = 0} and\n{\\tt r$_{\\tt mn}$ = r$_{\\tt pq}$} is not an endpoint, it can be\ntranslated right or left until it becomes an endpoint.\n\\end{indpar}\n\nThe translation argument just given is an example of a\n\\key{perturbation argument}.  Perturbation arguments are common\nin computational geometry.\n\nOf course if the finite lines intersect the distance between\nthem is zero.\n\n\\begin{corollary}\nIf two finite lines {\\tt mn} and {\\tt pq} intersect, the distance\nbetween them is {\\tt 0}.  Otherwise the distance is the minimum of: \\\\\n\\hspace*{0.5in}\\begin{tabular}{l}\nthe distance from {\\tt m} to {\\tt pq} \\\\\nthe distance from {\\tt n} to {\\tt pq} \\\\\nthe distance from {\\tt p} to {\\tt mn} \\\\\nthe distance from {\\tt q} to {\\tt mn} \\\\\n\\end{tabular}\n\\end{corollary}\n\nThis corollary gives an algorithm to compute the distance between\ntwo finite lines as follows.  Let A be the answer to the question:\ndo the lines intersect?  Let D be the distance computed by the\ncorollary if A is false.  Then if A is true, return 0, else return D.\n\nBut now we have a difficulty: the algorithms we have developed\nabove for computing A are discontinuous and impose precision\nrequirements on the data.  What we want is a continuous algorithm \nto compute A,\nor more specifically, an algorithm that makes errors only if D = 0\nto within computational accuracy.  Then if A is erroneously\nfalse, D will be returned, which is the same value that would be\nreturned if A is true, to within computational accuracy.  And if\nA is erroneously true, 0 would be returned, which is the same as\nD to within computation accuracy.  Then\nour distance algorithm will be continuous and \\underline{not} impose\nprecision requirements on the data.\n\nThe following algorithm A has the require continuity property:\n\n\\begin{algorithm}\\label{INTERSECTION-ALGORITHM}\nAlgorithm that returns true if finite lines {\\tt mn} and {\\tt pq}\nintersect, and false otherwise.\n\nMake the coordinate change:\n\\begin{center}\n\\begin{tabular}{rcl}\n\\tt m & $\\longmapsto$ & \\tt M = ( (q-p)*(m-p), (q-p)\\WH(m-p) ) \\\\\n\\tt n & $\\longmapsto$ & \\tt N = ( (q-p)*(n-p), (q-p)\\WH(n-p) ) \\\\\n\\tt p & $\\longmapsto$ & \\tt P = ( (q-p)*(p-p), (q-p)\\WH(p-p) ) = (0,0) \\\\\n\\tt q & $\\longmapsto$ & \\tt Q = ( (q-p)*(q-p), (q-p)\\WH(q-p) ) = (L,0) \\\\\n      &               & for {\\tt L = (q-p)*(q-p) > 0} \\\\\n\\end{tabular}\n\\end{center}\n\nso infinite {\\tt pq} $\\longmapsto$ X-axis.\n\nIntersect the finite line {\\tt MN} with the region\n\\begin{center}\n$S = [0,L]\\times(-\\infty,+\\infty) =\n    \\{(x,y):0\\leq x\\leq L,-\\infty < y < +\\infty\\}$\n\\end{center}\n\nIf the intersection is empty, return false.\n\nOtherwise let {\\tt M'} and {\\tt N'} be the endpoints of the intersection\n({\\tt M' = M} and {\\tt N' = N} are possible).\n\\begin{center}\n\\begin{tabular}{ll}\nIf & {\\tt M'.y > 0} and {\\tt N'.y > 0 } \\\\\nor & {\\tt M'.y < 0} and {\\tt N'.y < 0 } \\\\\n   & return false \\\\\nelse & return true \\\\\n\\end{tabular}\n\\end{center}\n\n\\end{algorithm}\n\nWe want to state the required continuity problem of\nAlgorithm~\\ref{INTERSECTION-ALGORITHM} more precisely.\nLet\n\\begin{center}\n$R=\\{(m,n,p,q): m\\neq n, p\\neq q\\} \\subset {\\cal R}^8$ \\\\\n$I=\\{(m,n,p,q)\\in R: MN \\textrm{~intersects~} S\\}$ \\\\\n$T=\\{(m,n,p,q)\\in R:\n     \\textrm{Algorithm~\\ref{INTERSECTION-ALGORITHM} returns true}\\}$ \\\\\n$B$ = boundary of $T$ in $R$ \\\\\n$D$ be \\begin{tabular}[t]{@{}l}\nthe minimum of: \\\\\nthe distance from {\\tt m} to {\\tt pq} \\\\\nthe distance from {\\tt n} to {\\tt pq} \\\\\nthe distance from {\\tt p} to {\\tt mn} \\\\\nthe distance from {\\tt q} to {\\tt mn} \\\\\n\\end{tabular}\n\\end{center}\n\nThen we want to prove:\n\\begin{theorem}\n$D = 0$ on $B$.\n\\end{theorem}\n\nIn the proof of this theorem we will use the following:\n\\begin{lemma}\nIf $b\\in I$ then:\n\\begin{indpar}{0.5in}\n{\\tt M'($b$).y = 0} implies $D=0$ at $b$ \\\\\n{\\tt N'($b$).y = 0} implies $D=0$ at $b$\n\\end{indpar}\n\\end{lemma}\n\n\\begin{indpar}{0.3in}\nProof of Lemma:\n\nLet {\\tt M'.y = 0}, so {\\tt M'} is on the line {\\tt PQ}\nand also on the line {\\tt MN}.\nThe cases are:\n\\begin{indpar}{0.5in}\n\\begin{itemize}\n\\item[(a)] {\\tt M' = M} so {\\tt M} is on the line {\\tt PQ} and $D=0$.\n\\item[(b)] {\\tt M'.x = P.x} in which case {\\tt M' = P}\n(as {\\tt M'.y = 0 = P.y}), so {\\tt P} is on {\\tt MN} and $D=0$.\n\\item[(c)] {\\tt M'.x = Q.x} in which case {\\tt M' = Q}\n(as {\\tt M'.y = 0 = Q.y}), so {\\tt Q} is on {\\tt MN} and $D=0$.\n\\end{itemize}\n\\end{indpar}\nSimilarly for {\\tt N'.y = 0}.\n\\end{indpar}\n\n\\begin{indpar}{0.3in}\nProof of Theorem:\n\nFirst note that since $R\\setminus I$ and $R\\setminus T$ are open,\n$I$ and $T$ are closed.  In addition, {\\tt M}, {\\tt N}, {\\tt P},\nand {\\tt Q} are continuous functions on $R$, and {\\tt M'} and {\\tt N'}\nare continuous functions on $I$.\n\nLet $b\\in B$.  We need to show that $D=0$ at $b$.\n\nSince $T$ is closed and $B$ is the boundary of $T$, $B\\subset T$,\nand $b\\in T\\subset I$.  Therefore {\\tt M'($b$)} and {\\tt N'($b$)}\nexist and one of the following is true:\n\\begin{center}\n\\begin{tabular}{ll}\n(a) & {\\tt M'($b$).y = 0} (and therefore by the lemma $D=0$ at $b$) \\\\ \n(b) & {\\tt N'($b$).y = 0} (and therefore by the lemma $D=0$ at $b$) \\\\ \n(c) & {\\tt M'($b$).y > 0 > N'($b$).y} \\\\\n(d) & {\\tt M'($b$).y < 0 < N'($b$).y} \\\\\n\\end{tabular}\n\\end{center}\nNote that {\\tt M'($b$).y > 0 < N'($b$).y}\nis impossible as $b\\in T$,\nand similarly {\\tt M'($b$).y < 0 > N'($b$).y} is impossible.\n\nSo we need only prove that (c) and (d) are impossible or lead\nto the conclusion that $D=0$ at $b$.\n\nSince $b$ is on the boundary of $T$ in $R$,\nthere is an infinite sequence of points in $R\\setminus T$\nconverging to $b$.  Using the fact that $R\\setminus T$ is the\ndisjoint union of $R\\setminus I$ and $I\\setminus T$,\nwe divide the argument into two cases:\n\nCase 1: There is a sequence of points in $I\\setminus T$ that\nconverges to $b$.\n\nThen there is a subsequence $s$ of points such that either:\n\\begin{center}\n\\begin{tabular}{ll}\n(e) & if $b_s\\in s$ then {\\tt M'($b_s$).y > 0 < N'($b_s$).y}; \\\\\n    & therefore by continuity\n            {\\tt M'($b$).y $\\geq$ 0 $\\leq$ N'($b$).y}; \\\\\n(f) & if $b_s\\in s$ then {\\tt M'($b_s$).y < 0 > N'($b_s$).y}; \\\\\n    & therefore by continuity\n            {\\tt M'($b$).y $\\leq$ 0 $\\geq$ N'($b$).y}; \\\\\n\\end{tabular}\n\\end{center}\nBut (e) is incompatible with both (c) and (d), and similarly (f) is\nincompatible with both (c) and (d).\n\nCase 2: There is a sequence of points in $R\\setminus I$ that\nconverges to $b$.\n\nThen there is a subsequence $s$ of points such that either:\n\\begin{center}\n\\begin{tabular}{ll}\n(g) & if $b_s\\in s$ then {\\tt M($b_s$).x < P.x > N($b_s$).x}; \\\\\n    & therefore by continuity\n            {\\tt M($b$).x $\\leq$ P.x $\\geq$ N($b$).x}; \\\\\n    & therefore since $b\\in T\\subset I$,\n            {\\tt M'($b$).x = P.x = N'($b$).x}; \\\\\n(h) & if $b_s\\in s$ then {\\tt M($b_s$).x > Q.x < N($b_s$).x} \\\\\n    & therefore by continuity\n            {\\tt M($b$).x $\\geq$ Q.x $\\leq$ N($b$).x}; \\\\\n    & therefore since $b\\in T\\subset I$,\n            {\\tt M'($b$).x = Q.x = N'($b$).x}; \\\\\n\\end{tabular}\n\\end{center}\nIf {\\tt M($b$).x $\\neq$ N($b$).x} then either (g) or (h) imply\n{\\tt M'($b$) = N'($b$)} which is incompatible with both (c) and (d).\n\nOtherwise (g) implies that {\\tt M($b$).x = N($b$).x = P($b$).x} and\neither (c) or (d) then imply that {\\tt P($b$)} is on the line\n{\\tt MN} at $b$ and hence $D=0$ at $b$.\n\nSimilarly (h) implies that {\\tt M($b$).x = N($b$).x = Q($b$).x} and\neither (c) or (d) then imply that {\\tt Q($b$)} is on the line\n{\\tt MN} at $b$ and hence $D=0$ at $b$.\n\n\\end{indpar}\n\n\\newpage\n\n\\section{Line and Line Calculator}\nImplement additions to the point and line calculator for\nthe following {\\em operators} and {\\em functions}:\n\\begin{center}\n\\begin{tabular}{l@{~~~~~}l}\nAssume: & {\\tt m}, {\\tt n}, {\\tt p}, {\\tt q} are vectors representing points \\\\\n\t& {\\tt D=}$D$ is an integer scalar, $-15\\le D\\le +15$ \\\\\nthen: \\\\[1ex]\n\\tt intersecti mnpqD & returns {\\tt true} if the infinite lines {\\tt mn} and\n                     {\\tt pq} \\\\\n\t\t   & intersect (including the case where the lines are \\\\\n\t\t   & identical) and {\\tt false} otherwise; \\\\\n\t           & if all coordinates are exact multiples of $10^{-D}$ \\\\\n\t\t   & and have absolute values $\\le 10^{6-D}$ \\\\\n\\tt intersectf mnpqD & ditto but for finite lines {\\tt mn} and {\\tt pq} \\\\\n\\tt overlapf mnpq & returns the length of the overlap of\n                    finite lines {\\tt mn} \\\\\n                 & and {\\tt pq} assuming the infinite extensions of these \\\\\n\t\t & lines are identical \\\\\n\\tt commoni mnpq & returns the common point of infinite lines {\\tt mn} and \\\\\n                 & {\\tt pq} assuming these lines are not parallel \\\\\n\\tt distf mnpq & returns the distance between finite lines {\\tt mn} and\n                  {\\tt pq} \\\\\n\t\t& (may be zero if lines intersect) \\\\\n\\end{tabular}\n\\end{center}\n\n\\begin{center}\n\\begin{tabular}{rl}\nSample Input Files: & \\file{00-XXXX-line-vec2d.in} \\\\\nSample Output Files: & \\file{00-XXXX-line-vec2d.ftest} \\\\\nSample Run File: & \\file{sample-line-vec2d.run} \\\\\nSubmit Run File: & \\file{submit-line-vec2d.run} \\\\\n\\end{tabular}\n\\end{center}\n\n\n\\end{document}\n", "meta": {"hexsha": "5ef91ebae4d62f54107ffd73c7259f8fffbd99dc", "size": 84884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/ed-geometry/vec2d/+sources+/vec2d.tex", "max_stars_repo_name": "RobertLWalton/epm_ed", "max_stars_repo_head_hexsha": "09e966364c5b9b2ab38bb78def1d680e231f889d", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/ed-geometry/vec2d/+sources+/vec2d.tex", "max_issues_repo_name": "RobertLWalton/epm_ed", "max_issues_repo_head_hexsha": "09e966364c5b9b2ab38bb78def1d680e231f889d", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/ed-geometry/vec2d/+sources+/vec2d.tex", "max_forks_repo_name": "RobertLWalton/epm_ed", "max_forks_repo_head_hexsha": "09e966364c5b9b2ab38bb78def1d680e231f889d", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6592724046, "max_line_length": 80, "alphanum_fraction": 0.6207294661, "num_tokens": 29697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949467848392, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.44435683354906474}}
{"text": "\\section{Grand Unification and Supersymmetry}\nAs we have seen before, the concept of unification plays a central role in the construction of appropriate phenomenological models of the MSSM. Here, we want to discuss the importance of SUSY in the context of the unification of the Standard Model gauge couplings, which was one of the first proposed examples of  phenomenological implications in the early days of SUSY research \\cite{GeorgiGlashow1974}. \\\\\nWe define the Standard Model as the most general renormalizable field theory with gauge group\n\\begin{equation}\n\t\\mathcal{G}_{\\mathrm{SM}} = \\operatorname{SU}(3) \\times \\operatorname{SU}(2) \\times \\operatorname{U}(1),\n\\end{equation}\nwith associated gauge couplings $\\alpha_3$, $\\alpha_2$ and $\\alpha_1$, three generations of fermions and a scalar doublet \\cite{Hebecker2020}. We know that the respective couplings are larger for the larger component of the gauge group, i.\\,e. \n\\begin{equation}\n\t\\alpha_{3}\\left(m_{Z}\\right)>\\alpha_{2}\\left(m_{Z}\\right)>\\alpha_{1}\\left(m_{Z}\\right).\n\\end{equation}\nAn interesting observation is, that the values of the running couplings come relatively close together at some high energy scale $\\Lambda_{\\mathrm{GUT}}\\sim 10^{16}\\ \\mathrm{GeV}$ (cf. left plot in Figure \\ref{fig:runnings}). To understand how this picture might look like in the MSSM\\footnote{For our talk we restrict ourselves to a unification scheme with gauge group  $\\mathcal{G}_{\\mathrm{MSSM}} = \\operatorname{SU}(5) \\supset \\operatorname{SU}(3)\\times\\operatorname{SU}(2)\\times\\operatorname{U}(1)$ as described in \\cite{GeorgiGlashow1974}.}, we first  have a look at the value of the Higgs-higgsino mass parameter $\\mu$.\\\\ In order to reproduce the correct values of the $W$ and $Z$ boson masses, in the Georgi-Glashow model \\cite{GeorgiGlashow1974} we need values of $\\mu^{2} \\sim (100\\ \\mathrm{GeV})^{2}$ \\cite{PeskinSchroeder1995}. The large discrepancy in the orders of magnitude of the relevant physical scales is often referred to as the gauge hierarchy problem. At this point SUSY may provide a way around: If SUSY breaking in the MSSM works such that the mass differences of the superpartners are large enough, one can reproduce the correct Higgs mass. These additional superpartners in the particle spectrum lead to interesting cancellations in the computation of the running of the gauge couplings via diagrams such as \n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale = 0.9]{figures/running_diagrams}\n\\end{figure}\n\\noindent\nwhere the sfermions are denoted by a tilde (and highlighted in red). For an example calculation of the MSSM effects in the running couplings we refer for example to the respective exercise in \\cite{Hebecker2020}.  \\newpage The explicit formulas for the beta functions are given by\n\\begin{equation}\n\t\\beta_{g_i} = \\frac{\\dd}{\\dd t}g_i = \\frac{b_i}{16\\pi^2} g_i^3 \\quad \\text{with} \\quad (b_1,b_2,b_3) = \\left\\{\\begin{array}{ll}{(\\frac{41}{10}, -\\frac{19}{6}, 7)} & {\\text {in the SM} } \\\\ {(\\frac{33}{5}, 1, -3)} & {\\text {in the MSSM}} \\end{array}\\right. \n\\end{equation}\nwhere $t = \\log\\frac{Q}{m_Z}$. For $\\alpha_i = g_i^2/4\\pi$ this yields \n\\begin{equation}\n\t\\frac{\\dd }{\\dd t} \\alpha_i^{-1} = -\\frac{b_i}{2\\pi}.\n\\end{equation}\nAs we see in the right plot in Figure \\ref{fig:runnings} the unification of the gauge couplings at some high energy scale may be realized in the MSSM. In the end it remains a complicated fine tuning task\\footnote{There has been a lot of work considering the qualitative assessment of fine-tuning in theoretical models. Probably the most commonly used measure of fine tuning is the Barbieri-Giudice measure characterized by $\\Delta_i \\equiv \\abs{\\frac{\\partial \\operatorname{ln} m_Z^2}{\\partial \\operatorname{ln} p_i}}$, where the $p_i$ are the MSSM parameters at the scale $M_X$ which are set by the fundamental SUSY breaking dynamics. The larger the value of $\\Delta \\equiv \\operatorname{max} \\Delta_i$ the more fine tuning is needed  \\cite{PDG20182019, Hebecker2020}.}. \\\\\nAt this point we want to remark that even if this result might look very interesting, and was often referred to as one of the most promising advertisements for the realization of SUSY in nature, it is of course only an approximate result and the picture will already look a lot different at the next loop order.\n\n\\begin{figure}[t]\n\\hfill\n\t\\begin{subfigure}\n\t\t\\centering\n\t\\includegraphics[scale = 0.55]{figures/dgut-1}\n\t\\end{subfigure}\n\t\\hfill\n\t\\begin{subfigure}\n\t\t\\centering\n\t\\includegraphics[scale = 0.55]{figures/dgut-2}\n\t\\hfill\n\t\\end{subfigure}\n\\caption{Running of the (inverse) gauge couplings in the SM and the MSSM, plots inspired by \\cite{Kazakov2000}.}\n\\label{fig:runnings}\n\\end{figure}\n\n\n\n\n\n\n\n", "meta": {"hexsha": "c43de004b329e14be7f3f0faaf32263538c697e4", "size": 4703, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "summary_mathieu/content/04_GUTs.tex", "max_stars_repo_name": "mathieukaltschmidt/SUSY", "max_stars_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "summary_mathieu/content/04_GUTs.tex", "max_issues_repo_name": "mathieukaltschmidt/SUSY", "max_issues_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "summary_mathieu/content/04_GUTs.tex", "max_forks_repo_name": "mathieukaltschmidt/SUSY", "max_forks_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.06, "max_line_length": 1335, "alphanum_fraction": 0.7582394216, "num_tokens": 1346, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4443568309058308}}
{"text": "\\documentclass[12pt]{article}%{amsart}\n\\usepackage[top = 1.0in, bottom = 1.0in, left = 1.0in, right = 1.0in]{geometry}\n% See geometry.pdf to learn the layout options. There are lots.\n%\\geometry{letterpaper}               % ... or a4paper or a5paper or ...\n%\\geometry{landscape}             % Activate for for rotated page geometry\n\\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n%\\usepackage{epstopdf}\n% \\usepackage{caption}\n\\usepackage{amsmath}\n% \\usepackage{longtable}\n% \\usepackage{tabu}\n% \\usepackage{accents} %to get undertildes for vec & mat\n\\usepackage{color} % for colored text\n% \\usepackage[normalem]{ulem} % for editing: striking out text using 'sout' command\n\n% \\newcommand\\mytablefigwidth{0.35\\textwidth}\n\n% allows to use .ai files directly w/o resaving as pdf\n\\DeclareGraphicsRule{.ai}{pdf}{.ai}{}\n\n% Handy math macros!\n\\newcommand{\\vect}[1]{\\vec{#1}}\n\\newcommand{\\matr}[1]{\\mathbf{#1}}\n\\newcommand{\\rate}[3]{{#1}_{#2}^{#3}}\n\\newcommand{\\mmnote}[1]{\\textcolor{cyan}{(MM:~#1)}}\n\n% derivative macros. these are sneaky. the [{}] is an empty default 1st arg\n% usage: provide 1 arg: \\deriv{x} gives d/dx\n% provide 2 args like so: \\deriv[f]{x} gives df/dx\n\\newcommand{\\deriv}[2][{}]{\\frac{d #1}{d #2}}\n\\newcommand{\\pderiv}[2][{}]{\\frac{\\partial #1}{\\partial #2}}\n\n%%%%% Referencing macros %%%%%\n\\newcommand{\\fref}[1]{Figure~\\ref{#1}}\n\\newcommand{\\tref}[1]{Table~\\ref{#1}}\n\\newcommand{\\eref}[1]{Eq.~(\\ref{#1})}\n\\newcommand{\\erngref}[2]{Eq.~(\\ref{#1}-\\ref{#2})} % Equations\n% \\newcommand{\\test}[1][]{%\n% \\ifthenelse{\\isempty{#1}{}}{omitted}{#1}%\n% }\n\n%%%%%\n\\begin{document}\n\n\\title{Generating function solution for the bursty unregulated promoter}\n\n\\maketitle\n\n\\section{One-state promoter with bursts, mRNA only}\n\n\\subsection{From master equation to generating function}\nBefore tackling mRNA and protein together as in~\\cite{Shahrezaei2008}, let's\njust do mRNA (replicating Charlotte's notes; she says it's worked out\nin~\\cite{Paulsson2000}, but I don't see it, at least not in notation I can\ncomprehend). The master equation of interest is\n\\begin{align}\n\\deriv{t}p(m,t) = (m+1)\\gamma p(m+1,t) - m\\gamma p(m,t) - r p(m,t)\n        + r \\sum_{m^\\prime=0}^m G_{m-m^\\prime}(\\theta) p(m^\\prime,t),\n\\label{eq:1state_unreg_003}\n\\end{align}\nwhere $G_{k}(\\theta)$ is the geometric distribution defined as\n\\begin{align}\nG_{k}(\\theta) = \\theta(1 - \\theta)^k, \\, k\\in\\{0,1,2,\\dots\\}.\n\\end{align}\nWith this convention, the mean burst size $\\beta = (1-\\theta)/\\theta$.\n$\\gamma$ and $r$ are mRNA degradation rates and transcription burst\ninitiation rates, resp. The last term represents all ways the system could\nend up with $m$ mRNAs, having started the burst with $m^\\prime$. Define\n$\\lambda = r/\\gamma$ and nondimensionalize time by $\\gamma$, giving\n\\begin{align}\n\\deriv{t}p(m,t) = (m+1)p(m+1,t) - m p(m,t) - \\lambda p(m,t)\n        + \\lambda \\sum_{m^\\prime=0}^m G_{m-m^\\prime}(\\theta) p(m^\\prime,t),\n\\end{align}\nThe probability generating function is defined as\n\\begin{align}\nF(z,t) = \\sum_m z^m p(m,t).\n\\end{align}\nMultiply both sides of the CME by $z^m$ and sum over all $m$ to get\n\\begin{align}\n\\pderiv[F]{t} = (1 - z) \\pderiv[F]{z}\n        + \\left(\\frac{\\theta}{1-z(1-\\theta)}-1\\right)\\lambda F.\n\\end{align}\n(This is just like in Charlotte's notes; the tricky bit is to\nrecognize the need to reverse the double sum in the last term from\n$\\sum_{m=0}^\\infty\\sum_{m^\\prime=0}^m$ to\n$\\sum_{m^\\prime=0}^\\infty\\sum_{m=m^\\prime}^\\infty$.\nThe sum on $m$ is then an easy geometric series. The rest of the procedure\nis just the standard reindexing tricks for sums over master equations.)\nChanging variables to $\\xi=1-\\theta$ and simplifying gives\n\\begin{align}\n\\pderiv[F]{t} + (z - 1) \\pderiv[F]{z} = \\frac{(z-1)\\xi}{1-z\\xi}\\lambda F.\n\\label{eq:1state_unreg_015}\n\\end{align}\n\\subsection{Stead-state}\nAt steady-state, the PDE reduces to the ODE\n\\begin{align}\n\\deriv[F]{z} = \\frac{\\xi}{1-z\\xi}\\lambda F,\n\\end{align}\nwhich we can integrate as\n\\begin{align}\n\\int \\frac{dF}{F} = \\int \\frac{\\lambda\\xi dz}{1-\\xi z}.\n\\end{align}\nThe initial conditions for generating functions always confuse me,\nespecially since most authors play fast and loose and assume ``it's\ntrivial.'' The key fact: from the definition\n$F(z,t) = \\sum_m z^m p(m,t)$,\nnormalization requires that\n$F(z=1^-,t) = \\sum_m p(m,t) = 1$.\\footnote{\nSometimes the generating function may be undefined \\textit{at} $z=1$ but the\nlimit still holds. Also people tend to change variables from $z$ to other\nthings, so don't lose track of how this condition transforms.\n}\nDoing the integrals (and producing constant $c$) gives\n\\begin{align}\n\\ln F &= -\\lambda \\ln(1-\\xi z) + c\n\\\\\nF &= \\frac{c}{(1-\\xi z)^\\lambda}.\n\\end{align}\nOnly one choice for $c$ can satisfy initial conditions, producing\n\\begin{align}\nF(z) = \\left(\\frac{1-\\xi}{1-\\xi z}\\right)^\\lambda\n        = \\left(\\frac{\\theta}{1 - z(1-\\theta)}\\right)^\\lambda,\n\\end{align}\nwhich is exactly the negative binomial's generating function, as expected.\n\n\\subsection{Time-dependent case}\nReturn to~\\eref{eq:1state_unreg_015} and for convenience,\nchange variables to $v=z-1$, producing\n\\begin{align}\n\\frac{1}{v}\\pderiv[F]{t} + \\pderiv[F]{v} = \\frac{\\lambda\\xi}{1-(1+v)\\xi} F.\n\\end{align}\nThis can be solved with the method of characteristics. Parametrize the\ncharacteristics by the new variable $s$. Initial conditions at $t=0$\ncorrespond to $s_0$, $v_0$, and $F(v_0,t=0)$, where $s_0$ and $v_0$ are\nconstants to be found later. The characteristic equations are\n\\begin{align}\n\\deriv[t]{s} &= \\frac{1}{v}\n\\\\\n\\deriv[v]{s} &= 1\n\\\\\n\\deriv[F]{s} &= \\frac{\\lambda\\xi}{1-(1+v)\\xi} F.\n\\end{align}\nWe could immediately write $v=s+c_v$ for some constant $c_v$ yet to be\nfound. Most authors drop the constant without justification. This works\nbecause our set of ODEs only contains $ds$, not $s$ itself. So, in fact,\nwe need not even solve for $v$ in terms of $s$, since the second ODE\ntells us $ds=dv$, we can immediately remove $s$ from the problem and we\nare left with the ODEs\n\\begin{align}\n\\deriv[t]{v} &= \\frac{1}{v}\n\\\\\n\\deriv[F]{v} &= \\frac{\\lambda\\xi}{1-(1+v)\\xi} F.\n\\end{align}\nThe first is trivial. Using our initial conditions it gives\n\\begin{align}\nv = v_0 e^t.\n\\end{align}\nSet this aside and tackle the second ODE.\nIt still permits separation of variables which gives\n\\begin{align}\n\\int \\frac{dF}{F} &= \\int \\frac{\\lambda \\xi dv}{1 - (1+v)\\xi}\n\\\\\n\\ln F &= -\\lambda \\ln(1-(1+v)\\xi) + \\text{constant}.\n\\end{align}\nInitial conditions determine the constant, but this is subtle. It may be\ntempting to transform back to $z$ and $t$, for which initial conditions\nare more obvious, but $v$ is a more convenient variable since it is\nparametrizes the characteristics. In other words, we can view $F$ as a\none variable function $F(v)$ or as a two variable function $F(z,t)$. It\nis much easier to deal with before changing variables back, rather than\nafter. But, in terms of $v$, what are our initial conditions? We know\n$t=0$ corresponds to some $v_0$ we have yet to determine, and this\ncorresponds to some $F(v_0)$ yet to be found. Any parametrization of the\nconstant that enforces this is acceptable. A clever idea is to break up\nand reparametrize the constant as $c_1$ and $c_2$ and bury these in the\nlogs as\n\\begin{align}\n\\ln \\frac{F(v)}{c_1} &= -\\lambda \\ln\\frac{1-(1+v)\\xi}{c_2},\n\\end{align}\nwhere we are now explicitly showing the $v$ dependence of $F$ for clarity.\nFor this equality to remain true when $v=v_0$,\nthe only choice of $c_1$ and $c_2$ that works is\n\\begin{align}\n\\ln \\frac{F(v)}{F(v_0)} &= -\\lambda \\ln\\frac{1-(1+v)\\xi}{1-(1+v_0)\\xi}\n\\end{align}\nwhich leads immediately to\n\\begin{align}\nF(v) &= F(v_0) \\left(\\frac{1-(1+v_0)\\xi}{1-(1+v)\\xi}\\right)^{\\lambda}\n\\end{align}\nNow we may transform variables back to $z$ and $t$.\nRecall from earlier that $1+v=z$ and $v=v_0 e^t$, so $v_0 = (z-1)e^{-t}$.\nThese substitutions handle the term in parentheses. $F(v_0)$ is more subtle.\nWe must avoid the trap of thinking there exists some $z_0$ corresponding to $v_0$;\n$v_0$ corresponds only to $t=0$. This is the magic of characteristics.\n$F(v_0)$ corresponds to the initial condition on $F$, i.e., $F(z,t=0)$\n\\textit{not} $F(z_0,t=0)$ since $z_0$ does not exist.\nBut $F(z,t=0)$, and therefore $F(v_0)$, is by definition given by\n\\begin{align}\nF(v_0) = F(z,t=0) = \\sum_m z^m p(m, t=0),\n\\end{align}\nwhere $p(m, t=0)$ is whatever initial probability distribution\nwe specify for the problem. Finally then\n\\begin{align}\nF(z, t) &=  \\left(\\frac{1-(1+(z-1)e^{-t})\\xi}{1-z\\xi}\\right)^{\\lambda}\n                \\left(\\sum_m z^m p(m, t=0)\\right)\n\\\\\nF(z, t) &=  \\left(\\frac{1-(1-\\theta)(1+(z-1)e^{-t})}\n                        {1-(1-\\theta)z}\\right)^{\\lambda}\n                \\left(\\sum_m z^m p(m, t=0)\\right).\n\\end{align}\nIf the initial condition is $p(0,0)=1$, then the second term in\nparentheses disappears and this clearly reduces to the usual negative\nbinomial generating function as $t\\rightarrow\\infty$. For any other\ninitial condition, this has to remain true but it's not obvious to me\nhow the math will work out, even for the next-simplest initial condition\nlike $p(m,0) = \\delta_{mk}$.\n\\mmnote{Still need to work out some algebra details here to see what happens.}\n\\mmnote{Our t-dependence is already different than theirs, even though\nthe steady state is the same. For trivial $k=0$ IC, everything will work\nout similarly, I think. For anything else, I think the direct approach\nof differentiating will produce an impossible mess. But we might be able\nto use their idea of a ``propagator'' probability and do a convolution\nover that; in principle, getting to the same place, but that might be\ntidier??}\n\n\\section{Adding translation}\nIf we include transcription and translation, the master equation becomes\nvery similar to Eq.~(1) in~\\cite{Shahrezaei2008}, except with mRNA\nproduction terms borrowed from our~\\eref{eq:1state_unreg_003}.\nAs in~\\cite{Shahrezaei2008}, it is more convenient to nondimensionalize\ntime by the protein degradation rate $\\gamma_p$ rather than the mRNA\ndegradation rate $\\gamma_m$.\nThen $\\gamma\\equiv\\gamma_m/\\gamma_p$ is the dimensionless mRNA lifetime,\nand $\\lambda\\equiv r_m/\\gamma_p$ is the dimensionless rate at which\ntranscription bursts initiate.\nThe mean burst size $\\beta = (1-\\theta)/\\theta$ as before.\nThe new parameter we need is the translation rate $r_p$,\nwhich we immediately nondimensionalize as $r\\equiv r_m/\\gamma_p$.\nThe authors of~\\cite{Shahrezaei2008} have three dimensionless parameters\n$a$, $b$, and $\\gamma$, which have a simple correspondence with ours:\n$a=\\lambda$, $b=r/\\gamma$, and $\\gamma=\\gamma$.\n\nWith all this, the master equation takes the form\n\\begin{align}\n\\deriv{t}p(m,n,t) = \n        & \\lambda \\left[\\sum_{m^\\prime=0}^m G_{m-m^\\prime}(\\theta) p(m^\\prime,n,t)\n        - p(m,n,t) \\right]\n        \\\\\n        & + r m [ p(m,n-1,t) - p(m,n,t) ]\n        \\\\\n        & + \\gamma [ (m+1) p(m+1,n,t) - m p(m,n,t) ]\n        \\\\\n        & + (n+1) p(m,n+1,t) - n p(m,n,t).\n\\end{align}\nThe first line covers transcription, the second translation, the third\nmRNA degradation, and the fourth protein degradation. Conceptually, this\nis identical to Eq.~(1) in~\\cite{Shahrezaei2008} except for the very\nfirst term.\\footnote{The equations also differ by nondimensionalization\nand relabeling of parameters, but these are ``bookkeeping'' operations,\nnot physical/conceptual ones.}\nThe probability generating function is now defined as\n\\begin{align}\nF(z,w,t) = \\sum_{m,n=0}^\\infty z^m w^n p(m,n,t),\n\\end{align}\nand similarly to before, we transform the master equation by multiplying\nboth sides by $z^m w^n$ and summing over $m$ and $n$.\nThe first term is unaffected by summing over $n$ and proceeds exactly as\nin the mRNA-only case. All other terms proceed exactly as\nin~\\cite{Shahrezaei2008}, so the PDE for the generating function is\n\\begin{align}\n\\pderiv[F]{t} = \\left(\\frac{\\theta}{1-z(1-\\theta)}-1\\right)\\lambda F\n        + rz(w - 1) \\pderiv[F]{z} + \\gamma(1 - z) \\pderiv[F]{z}\n        + (1 - w) \\pderiv[F]{w}.\n\\end{align}\nFor convenience, and analogously to the mRNA-only case, changing variables to\n$u=z-1$, $v=w-1$, and $\\xi=1-\\theta$ and simplifying gives\n\\begin{align}\n\\pderiv[F]{t} = \\frac{\\lambda\\xi u}{1-\\xi(u+1)} F\n        + \\left[ rv(1+u) - \\gamma u \\right] \\pderiv[F]{u}\n        - v \\pderiv[F]{v},\n\\end{align}\nor, rearranging terms to emphasize the analogy with\nEq.~(2) in~\\cite{Shahrezaei2008},\n\\begin{align}\n\\pderiv[F]{v} - \\left[ r(1+u) - \\gamma \\frac{u}{v} \\right] \\pderiv[F]{u} \n        + \\frac{1}{v}\\pderiv[F]{t} = \\frac{\\lambda\\xi}{1-\\xi(u+1)} \\frac{u}{v} F.\n\\end{align}\nAgain, the left-hand side is functionally identical to Eq.~(2)\nin~\\cite{Shahrezaei2008}, and only the right-hand side has new content.\nDespite the more complicated right-hand side, this is still solvable\nwith the method of characteristics; parametrizing the characteristics by\n$s$ leads to a set of four equations, namely\n\\begin{align}\n\\deriv[v]{s}=1\n\\\\\n\\deriv[t]{s}=\\frac{1}{v}\n\\\\\n\\deriv[u]{s} = \\gamma \\frac{u}{v} - r(1+u)\n\\\\\n\\deriv[F]{s} = \\frac{\\lambda\\xi}{1-\\xi(u+1)} \\frac{u}{v} F.\n\\end{align}\nThe equations for $t$ and $v$ are identical to the mRNA-only case,\nallowing us to immediately eliminate $s$ from the problem and replace it\nwith $v$. We also have\n\\begin{align}\nv = v_0 e^t\n\\end{align}\nas before, for some initial $v_0$ yet to be found corresponding to $t=0$.\nThe remaining two ODEs to be solved are\n\\begin{align}\n\\deriv[u]{v} = \\gamma \\frac{u}{v} - r(1+u)\n\\\\\n\\deriv[F]{v} = \\frac{\\lambda\\xi}{1-\\xi(u+1)} \\frac{u}{v} F.\n\\end{align}\nShahrezaei and Swain approximately solve the first for $\\gamma \\gg 1$.\n\\mmnote{Now I see why they defined $b$ as they did, so they could get\n$\\gamma$ alone on one side. That's a bit cleaner than the way I've\nparametrized, but it shouldn't change the conclusion.} In fact, this\napproximation should serve us even better than it did them: their yeast\ngenes of interest feature $\\gamma\\sim 2-6$, whereas for \\textit{E. coli}\nwith protein ``degradation'' dominated by dilution we expect $\\gamma\\sim\n5-15$. They find $u(v) \\approx bv/(1-bv)$, which, translated to our\nvariables, reads\n\\begin{align}\nu(v) \\approx \\frac{rv}{\\gamma-rv}.\n\\end{align}\nPlugging this into the ODE for $F$ gives\n\\begin{align}\n\\deriv[F]{v} \\approx\n        \\frac{\\lambda\\xi}{1-\\xi\\frac{\\gamma}{\\gamma-rv}} \\frac{r}{\\gamma-rv} F\n        = \\frac{\\lambda r \\xi}{(1-\\xi)\\gamma - rv} F\n        = \\frac{\\lambda r (1-\\theta)}{\\theta\\gamma - rv} F,\n\\end{align}\nwhere in the last step we changed variables back to $\\theta=1-\\xi$.\nThis is still solvable with separation of variables, as\n\\begin{align}\n\\int\\frac{dF}{F} &\\approx \\int \\frac{\\lambda r (1-\\theta) dv}{\\theta\\gamma - rv} F\n\\\\\n\\ln \\frac{F(v)}{F(v_0)} &\\approx -\\lambda (1-\\theta)\n                \\ln\\left(\\frac{\\theta\\gamma - rv}{\\theta\\gamma - rv_0}\\right),\n\\end{align}\nwhere we handled initial conditions in close analogy to the mRNA-only case.\nWith some algebra, and recalling that $v=w-1$ and $v_0=(w-1)e^{-t}$, we have\n\\begin{align}\nF(w,t) \\approx \\left(\\frac{1-\\frac{r}{\\theta\\gamma}(w-1)e^{-t}}\n                {1-\\frac{r}{\\theta\\gamma}(w-1)}\\right)^{\\lambda(1-\\theta)}\n                \\left(\\sum_n w^n p(n,t=0)\\right).\n\\label{eq:1state_unreg_030}\n\\end{align}\nNote that $z$, which corresponded to mRNA copy number, dropped out when\nwe substituted our approximate solution for $u$ as a function of $v$.\nThis gave us a generating function for the protein distribution alone,\nwith all stochasticity and burstiness of the mRNA (approximately)\nincorporated. The second term is simply the initial condition set by our\ninitially specified probability distribution on protein.\nThe first term is exactly, up to relabeling parameters, Eq.~(7)\nin~\\cite{Shahrezaei2008}, which leads to a probability distribution that\nresembles a negative binomial, but with time dependence, multiplied by a\nhypergeometric funtion.\n\nIs this result of use to us? As with Eq.~(8) in~\\cite{Shahrezaei2008},\nit is valid only for $\\gamma \\gg 1$ and $t\\gg \\gamma^{-1}$.\nThe former is easily satisfied for our system. The latter means the result\nis only valid for times longer than the mRNA lifetime,\nwhich is also satisfied in our problem.\n\nBut the time scale to approach steady state is set by the protein\nlifetime itself, which, if dominated by dilution, means $F(w,t)$ will\nnever reach steady-state, not even to a crude approximation.\nSo~\\eref{eq:1state_unreg_030} applies, but we \\textit{cannot} take its\nsteady-state limit. For very special initial conditions, Shahrezaei and\nSwain work out the full time-dependent probability distribution, Eq.~(8)\nin~\\cite{Shahrezaei2008}. But it is not clear if we can do this for the\nbinomially partitioned initial distribution that we would like to use.\n\\mmnote{Needs more thought.}\n\n%%%%%%%%%%%%%%%%%%%%% APPENDICES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\appendix\n\n\n% \\bibliographystyle{nature}\n\\bibliographystyle{abbrv}\n\\bibliography{../library}\n\n\\end{document}\n", "meta": {"hexsha": "25e487da2130e49fb8763003d7568d9725253e06", "size": 16956, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/theorists_notebook/20191218gen_fcn_unreg.tex", "max_stars_repo_name": "RPGroup-PBoC/bursty_transcription", "max_stars_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/theorists_notebook/20191218gen_fcn_unreg.tex", "max_issues_repo_name": "RPGroup-PBoC/bursty_transcription", "max_issues_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/theorists_notebook/20191218gen_fcn_unreg.tex", "max_forks_repo_name": "RPGroup-PBoC/bursty_transcription", "max_forks_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7010309278, "max_line_length": 104, "alphanum_fraction": 0.6940905874, "num_tokens": 5440, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.44435683040059926}}
{"text": "%!TEX TS-program = xelatex\n%!TEX encoding = UTF-8 Unicode\n\n\\chapter{Units of Measure}\n\\label{sec:units-of-measure}\n\n\\minitoc\n\n\\newpage\n\n\\section{Units of Measure}\n\n\\syntax\\begin{lstlisting}\nType_Representation \n    ::= ...\n      | '=' 'abstract' 'measure' \n      | '=' 'measure' ['(' Long_Id ')'] [semi] measure_def\n      \nmeasure_def \n    ::= '_' -- anonymous measure, inferrable by compiler\n      | measure_simple\nmeasure_simple\n    ::= measure_sequence\n      | measure_simple '*' measure_simple  -- product, e.g. \"'U * 'V\"\n      | measure_simple '/' measure_simple  -- quotient, e.g. \"'U / 'V\"\n      | '/' measure_simple  -- reciprocal, e.g. \"/'U\"\n      | '1'  -- dimensionless\nmeasure_sequence\n    ::= measure_power [measure_sequence]\nmeasure_power\n    ::= measure_atom\n      | measure_atom '^' integer_literal  -- power of measure, e.g. \"m^2\"\nmeasure_atom\n    ::= Type_Var  -- variable measure, e.g. \"'U\"\n      | Long_Id  -- named measure, e.g. \"ft\"\n      | '(' measure_simple ')'  -- parenthesized measure, e.g. \"(N m)\"\n      \nmeasure_literal\n    ::= '_'  -- anonymous measure, inferrable by compiler\n      | measure_literal_simple\nmeasure_literal_simple\n    ::= measure_literal_sequence  -- implicit product, e.g. \"m s^-3\"\n      | measure_literal_simple \n        '*' measure_literal_simple  -- product, e.g. \"m * s^4\"\n      | measure_literal_simple \n        '/' measure_literal_simple  -- quotient, e.g. \"m/s^3\"\n      | '/' measure_literal_simple  -- reciprocal, e.g. \"/s\"\n      | '1'  -- dimensionless\nmeasure_literal_sequence\n    ::= measure_literal_power [measure_literal_sequence]\nmeasure_literal_power\n    ::= measure_literal_atom\n      | measure_literal_atom '^' integer_literal  -- power of measure, e.g. \"m^2\"\nmeasure_literal_atom\n    ::= Long_Id  -- named measure, e.g. \"ft\"\n      | '(' measure_literal_simple ')'  -- parenthesized measure, e.g. \"(N m)\"\n\\end{lstlisting}\n\nNumbers in Aml can have associated units of measure, which are typically used to indicate length, volume, mass, distance and so on. By using quantities with units, the runtime is allowed to verify that arithmetic relationships have the correct units, which helps prevent programming errors. \n\n", "meta": {"hexsha": "effab0b4857ab9ca9bf49717ad41dfda0edb0748", "size": 2181, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/0.10/parts/language/Units_of_Measure.tex", "max_stars_repo_name": "amlantis-lang/gear-doc", "max_stars_repo_head_hexsha": "ba6913ec3a4fdd57c1dfa9ec03d966bf5a42c632", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-01-05T14:43:52.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-12T12:46:30.000Z", "max_issues_repo_path": "tex/0.10/parts/language/Units_of_Measure.tex", "max_issues_repo_name": "amlantis-lang/gear-doc", "max_issues_repo_head_hexsha": "ba6913ec3a4fdd57c1dfa9ec03d966bf5a42c632", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-08-23T20:12:49.000Z", "max_issues_repo_issues_event_max_datetime": "2015-11-21T14:55:25.000Z", "max_forks_repo_path": "tex/0.10/parts/language/Units_of_Measure.tex", "max_forks_repo_name": "amlantis-lang/gear-doc", "max_forks_repo_head_hexsha": "ba6913ec3a4fdd57c1dfa9ec03d966bf5a42c632", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.7540983607, "max_line_length": 291, "alphanum_fraction": 0.6574965612, "num_tokens": 552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4443568298953675}}
{"text": "\\chapter{Canonical Correlation}\n\\label{cancor}\n\n\\section{Canonical variates}\n\\label{canvar}\n\n\\section{Interpretation}\n\\label{canint}\n%%%%%\\chapter{Canonical Correlation}\n\nIn canonical correlation, we are interested in the relationship between two sets of variables.   We do this by creating linear combinations $\\boldsymbol{U} = \\boldsymbol{a_{1} x_{1}} + \\boldsymbol{a_{2} x_{2}} + \\cdots + \\boldsymbol{a_{p} x_{p}}$ and  $\\boldsymbol{V} = \\boldsymbol{b_{1} y_{1}} + \\boldsymbol{b_{2} y_{2}} + \\cdots + \\boldsymbol{b_{q} y_{q}}$ such that the correlation between $\\boldsymbol{U}$ and $\\boldsymbol{V}$ is as high as possible.\n\n\nTo do this, we need to work out the correlation matrix, and partition it:\n\n\n\\begin{displaymath}\n\\begin{array}{ccccccc} & x_{1} & \\ldots & \\_{p} & y_{1} & \\ldots & y_{q} \\end{array}\n\\end{displaymath}\n\\begin{displaymath}\n\\begin{array}{c} x_{1} \\\\ \\vdots \\\\ x_{p} \\\\y_{1} \\\\ \\vdots \\\\y_{3}\\end{array}\n\\left( \\begin{array}{ccc|ccc} &&&&&\\\\&A_{p \\times p}& &C_{p \\times q}&\\\\&&&&&\\\\\n\\hline\n&&&&&\\\\&C_{q \\times p}& &B_{q \\times q}&\\\\&&&&&\\\\ \\end{array} \\right)\n\\end{displaymath}\n\nHaving done this, we calculate the matrix:\n\n\\begin{displaymath}\n\\boldsymbol{B^{-1}C^{T}A^{-1}C}\n\\end{displaymath}\n\nand find the associated eigenvalues (in descending order)  $\\lambda_{1} > \\lambda_{2} > \\ldots > \\lambda_{r}$.   The corresponding eigenvectors $\\boldsymbol{b_{1}}, \\boldsymbol{b_{2}}, \\ldots, \\boldsymbol{b_{r}}$ give the coefficients of the Y variables.\n\nSo: \n\n\\begin{displaymath}\n\\boldsymbol{v_{i}} = \\boldsymbol{b_{i}^{T}} \\boldsymbol{Y}\n\\end{displaymath}\n\nwhere $\\boldsymbol{b_{i}} = \\left(\\begin{array}{c} b_{i1} \\\\ \\vdots \\\\ b_{iq} \\end{array} \\right)$ and $\\boldsymbol{Y} = \\left(\\begin{array}{c} \\boldsymbol{y_{1}} \\\\ \\vdots \\\\ \\boldsymbol{y_{q}} \\end{array} \\right)$, or in longhand:\n\n\\begin{displaymath}\n\\boldsymbol{v_{i}} = b_{i1} \\boldsymbol{y_{1}} + \\cdots + b_{iq} \\boldsymbol{y_{q}}\n\\end{displaymath}\n\nHaving calculated these, it is possible to solve the coefficients for the X variables:\n\n$a_{1} = \\boldsymbol{A^{-1} C b_{1}}, a_{2} = \\boldsymbol{A^{-1} C b_{2}}, \\ldots,  a_{r} = \\boldsymbol{A^{-1} C b_{r}}$,\n\nf\n\\begin{displaymath}\n\\boldsymbol{u_{i}} = \\boldsymbol{a_{i}^{T}} \\boldsymbol{X}\n\\end{displaymath}\n\n\nwhere $\\boldsymbol{a_{i}} = \\left(\\begin{array}{c} a_{i1} \\\\ \\vdots \\\\ a_{iq} \\end{array} \\right)$ and $\\boldsymbol{X} = \\left(\\begin{array}{c} \\boldsymbol{x_{1}} \\\\ \\vdots \\\\ \\boldsymbol{x_{r}} \\end{array} \\right)$, or in longhand:\n\n\\begin{displaymath}\n\\boldsymbol{u_{i}} = a_{i1} \\boldsymbol{x_{1}} + \\ldots + a_{ir} \\boldsymbol{x_{r}}\n\\end{displaymath}\n\nAnd one really cute result is that $\\left[corr(\\boldsymbol{u_{i}}, \\boldsymbol{v_{i}})\\right]^{2} = \\lambda_{i}$.\n\n\\section{Computer example}\n\nFranco Modigliani proposed a life cycle savings model, the savings ratio (aggregate personal saving divided by disposable income) is explained by per-capita disposable income, the percentage rate of change in per-capita disposable income, and two demographic variables: the percentage of population less than 15 years old and the percentage of the population over 75 years old. \n\nHowever, we are interested here in the relationship between the two demographic variables (percent of population under 15, percent of population over 75) and the three financial variables (personal savings, per-capita disposal income, growth rate of dpi).   The first stage of any such analysis would be a visual inspection.\n\n\n\\begin{verbatim}\npairs(LifeCycleSavings, pch = 16)\n\\end{verbatim}\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width = 0.6\\textwidth]{images/cancor}\n\\caption{Pairwise scatterplots of Life Cycle Savings data}\n\\end{center}\n\\end{figure}\n\nAnd it is worth examining the correlation matrix:\n\n\\singlespacing\n\\begin{verbatim}\n> cor(LifeCycleSavings)\n              sr       pop15       pop75        dpi        ddpi\nsr     1.0000000 -0.45553809  0.31652112  0.2203589  0.30478716\npop15 -0.4555381  1.00000000 -0.90847871 -0.7561881 -0.04782569\npop75  0.3165211 -0.90847871  1.00000000  0.7869995  0.02532138\ndpi    0.2203589 -0.75618810  0.78699951  1.0000000 -0.12948552\nddpi   0.3047872 -0.04782569  0.02532138 -0.1294855  1.00000000\n\\end{verbatim}\n\\onehalfspacing\n\nIt appears that the \\textbf{X} variables are correlated.   This is less so for \\textbf{Y} variables, and even less so for \\textbf{X,Y} inter-correlations.\n\nYou need to be sure that the variables are \\emph{scaled} before carrying out a canonical correlation analysis.   \n\n\\singlespacing\n\\begin{verbatim}\nLifeCycleSavingsS <- scale(LifeCycleSavings)\npop <- LifeCycleSavingsS[, 2:3] ## The X matrix\noec <- LifeCycleSavingsS[, -(2:3)] ## the Y matrix\n\\end{verbatim}\n\\onehalfspacing\n\nHaving created an \\textbf{X} matrix and a \\textbf{Y} matrix, we now want to find linear combinations of \\textbf{X} which have maximum correlation with \\textbf{Y}.\n\n\\singlespacing\n\\begin{verbatim}\n> cancor(pop, oec)\n$cor\n[1] 0.8247966 0.3652762\n\n$xcoef\n             [,1]       [,2]\npop15 -0.08338007 -0.3314944\npop75  0.06279282 -0.3360027\n\n$ycoef\n           [,1]        [,2]         [,3]\nsr   0.03795363  0.14955310 -0.023106040\ndpi  0.12954600 -0.07518943  0.004502216\nddpi 0.01196908 -0.03520728  0.148898175\n\n$xcenter\n        pop15         pop75 \n-4.662937e-16  2.753353e-16 \n\n$ycenter\n          sr          dpi         ddpi \n1.421085e-16 6.661338e-17 4.440892e-16 \n\\end{verbatim}\n\\onehalfspacing\n\nThis indicates one canonical correlate with a correlation of 0.8247966 between $z_{\\boldsymbol{X}1}$ and $z_{\\boldsymbol{Y}1}$\n\n\\begin{eqnarray}\nz_{\\boldsymbol{X}1} =  -0.08338007  x_{pop15} + 0.06279282 x_{pop75}\\\\\nz_{\\boldsymbol{Y}1} = 0.03795363 y_{sr} + 0.12954600 y_{dpi} +  0.01196908 y_{ddpi}\n\\end{eqnarray}\n\nIf we extract the coefficients as vectors (this time we have created \\texttt{LCS.cancor} as an object; also we have used \\texttt{as.numeric(\\ldots)} to extract the coefficients in a form suitable for matrix multiplication).\n\n\\singlespacing\n\\begin{verbatim}\n> LCS.cancor <- cancor(pop, oec)\n> ycoef <- as.numeric(LCS.cancor$ycoef[,1])\n> xcoef <- as.numeric(LCS.cancor$xcoef[,1])\n> v1 <-  oec %*% ycoef ## remember oec and pop are scaled\n> u1 <-  pop %*% xcoef\n> plot(v1, u1)\n> identify(v1, u1, row.names(LifeCycleSavings))\n\\end{verbatim}\n\\onehalfspacing\n\n\n\\subsection{Interpreting the canonical variables}\n\nThere is some ``controversy'' about the best way of interpreting the canonical variables.   You have two possibilities:\n\n\\begin{itemize}\n\\item Interpret the coefficients in a similar way to that used in principal components (problems with collinear variables)\n\\item Calculate the correlation between the canonical and the original variables (doesn't tell you anything about joint contributions)\n\\end{itemize}\n\n%Consider:\n\n%$\\rho_{\\hat{U},\\boldsymbol{x}}$ = matrix of correlations between $\\hat{U}$ and $\\boldsymbol{x}$\\\\ \n%$\\rho_{\\hat{V},\\boldsymbol{y}}$ = matrix of correlations between $\\hat{V}$ and $\\boldsymbol{y}$ \\\\\n%$\\rho_{\\hat{U},\\boldsymbol{y}}$ = matrix of correlations between $\\hat{U}$ and $\\boldsymbol{y}$ \\\\\n%$\\rho_{\\hat{V},\\boldsymbol{x}}$ = matrix of correlations between $\\hat{V}$ and $\\boldsymbol{x}$\\\\ \n\n%Which can be obtained fairly simply as:\n\n%\\begin{eqnarray*}\n%\\rho_{\\hat{U},\\boldsymbol{x}} = a \\Sigma_{11}\n\n\n\n\\subsection{Hypothesis testing}\n\nAs with Principal Components, a certain amount of hypothesis testing is possible.   The distributional properties of canonical variables is far wilder than principal components - none of the recommended books discuss it.   However, the tests can be described.   For example, if we wanted to test whether there was any relationship between our two sets of variables:\n\n\\begin{displaymath}\nH_{0}; \\boldsymbol{\\Sigma}_{12} = \\boldsymbol{0}\n\\end{displaymath}\n\nThe Likelihood ratio test leads us to:\n\n\\begin{displaymath}\n\\Lambda^{\\frac{2}{n}} = |\\boldsymbol{I} - \\boldsymbol{S_{22}^{-1}}\\boldsymbol{S_{21}}\\boldsymbol{S_{11}^{-1}}\\boldsymbol{S_{12}}| = \\prod_{i=1}^{k}(1-r_{i}^{2}) \\sim \\Lambda_{Wilks}(p, n-1-q,q)\n\\end{displaymath}\n\nUsing Bartlett's approximation this can yield a $chi^{2}$ test:\n\n\\begin{displaymath}\n-\\left(n-\\frac{1}{2}(p+q+3)\\right) \\log \\prod_{i=1}^{k}(1-r_{i}^{2}) \\sim \\chi^{2}_{pq}\n\\end{displaymath}\n\n\nAs we've seen before, perhaps we are more interested in finding out how many canonical correlations we need to keep in our analysis.   Bartlett also proposed a statistic only $s$ canonical correlations are non-zero:\n\n\\begin{displaymath}\n-\\left(n-\\frac{1}{2}(p+q+3)\\right) \\log \\prod_{i=s+1}^{k}(1-r_{i}^{2}) \\sim \\chi^{2}_{(p-s)(q-s)}\n\\end{displaymath}\n\n%%% Local Variables: ***\n%%% mode:latex ***\n%%% TeX-master: \"book.tex\"  ***\n%%% End: ***", "meta": {"hexsha": "29560bf1094b34c6f9d0e8cc6980c13e146020e5", "size": 8646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/cancor.tex", "max_stars_repo_name": "phewson/mvstats", "max_stars_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/cancor.tex", "max_issues_repo_name": "phewson/mvstats", "max_issues_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2020-08-28T16:37:22.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-28T16:49:11.000Z", "max_forks_repo_path": "chapters/cancor.tex", "max_forks_repo_name": "phewson/mvstats", "max_forks_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5915492958, "max_line_length": 454, "alphanum_fraction": 0.6995142262, "num_tokens": 2863, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.44435682624167}}
{"text": "\\section{Non-uniform Nyquist}\nA selection of quotations showing approaches to a non-uniform Nyquist limit:\n\n\\begin{description}\n\n\\item[Average Sampling Rate]\n\n\\citet{Scargle82} (citing the following: Beutler 1966, 1970; Masry \\& Lui 1975; Higgins 1976; Wiley 1978; Gaster \\& Roberts 1975, 1977; Kar, Hornkohl \\& Farmer 1981; Ludeman 1981 \\todo{read and summarize these!}):\n\\begin{quote}\nError-free recovery of a band-limited signal [i.e.~reproduction of the entire function $X(t)$ from the samples $X(t_i)$] can be achieved with irregular sampling as long as the mean sampling rate exceeds the Nyquist rate (i.e. the average number of samples per unit time must exceed twice the highest frequency component in the signal).\n\\end{quote}\n\n\\citet{NumRec}: \n\\begin{quote}\nOne guide to choosing $f_{hi}$ is to compare it with the Nyquist frequency $f_c$ which would obtain if the $N$ data points were evenly spaced over the same span $T$, that is $f_c = N/(2T)$. The accompanying program includes an input parameter {\\tt hifac}, defined as $f_{hi}/f_{c}$.\n\\end{quote}\n\n\\citet{Horne86}:\n\\begin{quote}\nThe largest frequency we calculated was $\\pi N/T$ which\nis the traditional Nyquist frequency for evenly-spaced data. The Nyquist\nfrequency is not well defined for unevenly spaced signals, but it can serve as\na reasonable upper limit for the calculation.\n\\end{quote}\n\n\\item[Harmonic Average of Sampling Rate]\n\n\\citet{Debosscher07}:\n\\begin{quote}\nFor the highest frequency, we used the average of the inverse time intervals\nbetween the measurements: $f_N = 0.5(1/\\Delta T)$ as a pseudo\nNyquist frequency. Note that $f_N$ is equal to the Nyquist frequency\nin the case of equidistant sampling. For particular cases,\nan even higher upper limit can be used \\citep[see][]{Eyer99}.\nOur upper limit should be seen as a compromise between\nthe required resolution to allow a good fitting, and computation\ntime.\n\\end{quote}\n\n\n\\item[Minimum Sample Spacing]\n\n\\citet{Percy86}:\n\\begin{quote}\n... the Nyquist frequency is not well defined for input data obtained at unequally spaced time intervals, the usual case in astronomy \\citep{Scargle82}.\nTheoretically such a data set contains informatin on the periodicities down to\n$\\Delta t = \\min(t_i - t{i-1})$. In practice, however, a pseudo-Nyquist frequency may be defined by averaging $\\Delta t = (t_i - t_{i-1})$, where large, uncharacteristic temporal gaps are avoided. Alternatively, the harmonic mean of all $\\Delta t$ may be used. The result is that a useful pseudo-Nyquist frequency may be defined by $\\nu_{Ny} = (2 \\langle\\Delta t \\rangle)^{-1}$.\n\\end{quote}\n\n\\citet{Press89}:\n\\begin{quote}\nIt is often meaningful to examine frequencies significantly higher than the\nNyquist frequency that would obtain if the same number of data points were\nevenly spaced in the same total length of time. Some spectral information is\nobtainable for frequencies all the way up to something like half the inverse\nspacing of the {\\it closest} spaced points.\n\\end{quote}\n\n\\citet{Roberts87}:\n\\begin{quote}\n...for arbitrary $\\{t_r\\}$, the sampling theorem tells us nothing.\nIf the data samples are otherwise equally spaced but with missing\npoints, the theorem says that the data completely determine\na function whose FT is zero for $|v| > 1/(2\\Delta_{max})$, where $\\Delta_{max}$\nis the {\\it largest completely sampled} data spacing. However,\nthere are smaller spacings, and these certainly carry information\nabout frequencies greater than $1/(2\\Delta_{max} )$; some information\nis available about frequencies as high as\n$1/(2\\Delta_{min} )$, where $\\Delta_{min}$ is the smallest spacing between data\npoints. Furthermore, if the $\\{t_r\\}$ are more or less randomly\ndistributed, so that a wide range ofspacings are present and\nthere is little redundancy in the spacing between various\npoints, tests have shown (Paper II) that significant information\nis available on frequencies greater than $l/(2\\Delta_{min})$.\n\nNonetheless, in the present paper we will restrict ourselves\nto frequencies obeying\n$\\nu < \\nu_{max} = 1/(2\\Delta_{min})$.\n\\end{quote}\n\n\\citet{Hilditch01}:\n\\begin{quote}\nThe highest frequency, for equally spaced data, is formally given by the {\\it Nyquist frequency}, $f_N = 1/(2\\Delta t)$, where $\\Delta t$ is the {\\it sampling interval} in the data string.\nFor unequally spaced data, it is common practice to estimate a pseudo-Nyquist frequency from the minimum value of $\\Delta t$.\n\\end{quote}\n\n\\item[Getting it Right]\n\n\\citet{ICVG2014}:\n\\begin{quote}\nAs a good choice for the maximum search frequency, a pseudo-Nyquist frequency $\\omega_{max} = \\pi/\\Delta t$, where $1/\\Delta t$ is the median of the inverse time interval between data points, was proposed by \\citet{Debosscher07} (in the case of even sampling, $\\omega_{max}$ is equal to the Nyquist frequency). In practice, this choice may be a gross underestimate because unevenly sampled data can detect periodicity with frequencies even higher than $2\\pi / \\Delta t_{min}$ \\citep[see][]{Eyer99}. An appropriate choice of $\\omega_{max}$ thus depends on sampling (the phase coverage at a given frequency is the relevant quantity) and needs to be carefully chosen: a hard limit on maximum detectable frequency is of course given by the time interval over which individual measurements are performed, such as imaging exposure time.\n\\end{quote}\n\n\\end{description}\n", "meta": {"hexsha": "1408b017b6288b138265947aaf6dc550df62889f", "size": 5342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes.tex", "max_stars_repo_name": "pierfra-ro/PracticalLombScargle", "max_stars_repo_head_hexsha": "5f4ca27deefa7d4edc68da3c92d34f484c5bc98e", "max_stars_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_stars_count": 54, "max_stars_repo_stars_event_min_datetime": "2016-01-25T16:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T11:50:06.000Z", "max_issues_repo_path": "notes.tex", "max_issues_repo_name": "pierfra-ro/PracticalLombScargle", "max_issues_repo_head_hexsha": "5f4ca27deefa7d4edc68da3c92d34f484c5bc98e", "max_issues_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2017-09-13T02:24:20.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-20T18:09:25.000Z", "max_forks_repo_path": "notes.tex", "max_forks_repo_name": "pierfra-ro/PracticalLombScargle", "max_forks_repo_head_hexsha": "5f4ca27deefa7d4edc68da3c92d34f484c5bc98e", "max_forks_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_forks_count": 34, "max_forks_repo_forks_event_min_datetime": "2017-09-09T00:25:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T09:33:48.000Z", "avg_line_length": 56.2315789474, "max_line_length": 830, "alphanum_fraction": 0.7663796331, "num_tokens": 1385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.44435682624167}}
{"text": "\nIn metro systems where passengers ``tap in'' and ``tap out'' using\nfare cards, tokens or similar means, explicit travel time data may be\navailable for every passenger. In a given system, more or less may\nindeed be measured; for the purpose of an example calibration as\nshown here, it is assumed in particular that passenger travel-time\ndata are available.\n\nIn order to exhibit a concrete calibration procedure, The Madrid Metro\nmodel prepared in the last chapter is used. The scope is restricted to\ncalibration of the parameters of the walking-speed distribution in the system.\nFor simplicity, a single log-normal walking-time distribution is applied\nto the system as a whole.\n\nIn calibrating only the walking-speed distribution, it is implicitly assumed\nthat other aspects of the system are specified correctly; in particular,\ncorridor lengths, train schedules, train speeds and track lengths are assumed\nto have been finalised.\n\nIn order to calibrate the walking-speed distribution, a reference set\nof data must be supplied which consists of travel times. Since in the\npresent context no such real-world set is available for Madrid, a\nsynthetic set of travel times is generated and used.\n\n\\section{Travel-time tool}\nThe travel-time tool can be run with no parameters\\\\\n\\comline{java -jar TravelTimeTool.jar }\\\\\nin order to see documentation and options.\n\nIn \\Figref{travtime} is shown a distribution of the travel times\nappearing in the simulated system for trips beginning between 05:00\nand 09:00. The variable plotted is the mean travel time for\n\\emph{comparable trips}, which are defined as trips with the same\norigin and destination, occuring within the same time interval (in\nthis case, the interval size is 24 minutes).\n\\begin{figure}[ht]\n  \\centering\n  \\includegraphics[angle=0,width=10cm]{80_figs/_TTD_0500-0900.eps}\n  \\caption{Distribution of travel time; $\\mu=2404$ s, $\\sigma=1270$ s.}\n  \\label{travtime}\n\\end{figure}\nTo generate the distribution of travel times shown in \\Figref{travtime}, \\\\\n\\comline{java -jar TravelTimeTool.jar TTD 05:00,09:00,16 0,3600,30 madrid\\_01.zo }\\\\\nIn addition to the `TTD' mode, there are modes which generate synthetic\nreference data (`SYN'), compare against reference data (`TTC'),\nand evaluate an objective function for calibration (`OBJ').\n\nThese modes are described below; they can be demonstrated in sequence by running\\\\\n\\comline{./01\\_Run\\_ZIM\\_SYN\\_TTD\\_TTC\\_OBJ.sh}\n\n\\section{Synthetic reference data}\nTo exhibit how calibration can be performed, a reference set of travel\ntimes can be generated, based on a simulation run, with a command like:\\\\\n\\comline{java -jar TravelTimeTool.jar SYN 100 out/madrid\\_01.zo > \\_SYN\\_TravelTimeData.csv} \\\\\nThe file {\\tt \\_SYN\\_TravelTimeData.csv} produced will be the reference data,\nused in here in place of actual ground-truth measurements.\n\n\\section{Comparison}\nTo see the discrepancy between the simulation output and the reference data:\n{\\tt java -jar TravelTimeTool.jar TTC 05:00,09:00,16 -600,600,20 \\_SYN\\_TravelTimeData.csv out/madrid\\_01.zo }\\\\\nFor this example, the time interval between 05:00 and 09:00 is considered.\nThe result is shown in \\Figref{TTdiff}.\n\\begin{figure}[ht!]\n  \\centering\n  \\includegraphics[angle=0,width=10cm]{80_figs/_TTC_0500-0900.eps}\n  \\caption{Distribution of travel-time error}\n  \\label{TTdiff}\n\\end{figure}\nThis shows that the travel times (compared within `bins' as described before) are 100 seconds\nfaster than the reference data. (Fluctuations average out, making this distribution very narrow.)\nThe mean simulation travel-time error is $-100$ s with a standard deviation of $7.37$ s.\n\n\\section{Objective}\n\\label{DefObj}\nThe parameters of the walking-speed distribution are to be adjusted so that the simulated\ntravel times correspond as closely as possible to the reference data.\nThe objective used for this purpose is\n\\[\n\\Phi(\\mu,\\sigma) := \\sum_{o,d,\\tau} (\\tilde{T}_{o,d,\\tau} - T_{o,d,\\tau})^2\n\\]\nwhere $\\mu$ and $\\sigma$ are the mean and standard deviation of the\nlog-normal distribution\\footnote{It is noted that they are not the\n mean and standard deviation of the associated normal distribution; this was described in \\Secref{sec:zsource}}\nused for walking speeds and specified in the \\zobj{zsource} in {\\tt 00\\_StaticTypes.zim}.\nThese quantities are each measured in m/s.\n\n$\\tau$ labels discrete time intervals during the day; these are statistical bins enabling a definition of \\emph{comparable} trips.\nTwo trips are comparable when they share the same origin $o$, the same destination $d$ and begin\nduring the same interval $\\tau$. The specification {\\tt 05:00,09:00,16} in the above commands indicates\nthat there will be $16$ intervals of $15$ minutes each; in this case $\\tau=0\\dots15$.\n\n$\\tilde{T}_{o,d,\\tau}$ is the reference travel-time mean for trips from origin $o$ to\ndestination $d$ during time interval $\\tau$. $T_{o,d,\\tau}$ is the mean generated by simulation.\n\n\\section{Calibration}\nThe calibrated values for $\\mu$ and $\\nu$ are those which minimise $\\Phi$.\nThe method used here to approximate this minimum is a discrete search algorithm which is\nanalogous to gradient descent;\n\\[\n(\\mu,\\sigma) = {\\textup{LocalMin}(\\Phi;\\mu_0,\\sigma_0)}\n\\]\nwith parameters $E=1.075$, $R=0.7$, $s_0=1.0e-8$, $\\delta=0.01$, $i_{max}=100$ and initial\nestimate $\\mu_0=2.0$, $\\sigma_0=0.7$.\n$\\hat{C}$ is set to constrain the parameters within sane\nranges; $1 < \\mu < 10$ and $0.05 < \\sigma < 1.0$ which are not expected to be saturated.\n\nEach evaluation of $\\Phi(\\mu,\\sigma)$ corresponds to a simulation run;\n$\\Phi$ depends on the simulation output and the reference data.  The\nLocalMin algorithm is as follows.\n\n\\begin{itemize}\n\\item[] {\\bf algorithm} $\\textup{LocalMin}(f;{\\bf x}_0)$ to find ${\\bf x}$ near ${\\bf x}_0$ which sufficiently\\\\\n  minimises $f(\\bf x)$ subject to constraints $\\hat{C}$.\n  \\begin{itemize}\n  \\item[] {\\bf Choose} values for constant parameters:\n    \\begin{itemize}\n    \\item[] $E$ --- enthusiasm\n    \\item[] $R$ --- reluctance\n    \\item[] $\\delta$ --- perturbation\n    \\item[] $i_{max}$ --- maximum iterations\n    \\end{itemize}\n  \\item[] {\\bf Set} initial values\n    \\begin{itemize}\n    \\item[] ${\\bf x} \\leftarrow {\\bf x}_0$ --- initial guess\n    \\item[] $s \\leftarrow s_0$ --- descent factor\n    \\item[] $i \\leftarrow 0$ --- iteration counter\n    \\end{itemize}\n  \\item[] {\\bf Loop}:\n  \\item[] {Evaluate} $f$ to numerically define gradient of $f$ at ${\\bf x}$:\n    \\begin{itemize}\n    \\item[] Evaluate $f_{base} \\leftarrow f({\\bf x})$ (or use $f_{new}$ if $i>0$ and last step was enthusiastic) \n    \\item[] for $j$ from $1$ to $d$ do\n      \\begin{itemize}\n      \\item[] Evaluate $f_j \\leftarrow f({\\bf x} + \\delta \\hat {\\bf j})$\n      \\end{itemize}\n    \\item[] ${\\bf g}$ defined by $g_j = (f_j - f_{base})/{\\delta}$ is a numerical gradient of $f$ at ${\\bf x}$.\n    \\end{itemize}\n  \\item[] Use ${\\bf g}$ to search for a better ${\\bf x}$:\n    \\begin{itemize}\n    \\item[] $\\Delta{\\bf x} \\leftarrow s {\\bf g}$\n    \\item[] Tentative new estimate: ${\\bf x}' \\leftarrow {\\bf x} + \\Delta{\\bf x}$\n    \\item[] Apply constraints: ${\\bf x}' \\leftarrow \\hat{C} {\\bf x}'$\n    \\item[] if ${\\bf x}' = {\\bf x}$ then\n      \\begin{itemize}\n      \\item[] Quit with result ${\\bf x}$\n      \\end{itemize}\n    \\item[] Evaluate $f_{new} \\leftarrow f({\\bf x}')$\n    \\item[] if $f_{new} < f_0$ then\n      \\begin{itemize}\n      \\item[] Update estimate: ${\\bf x} \\leftarrow {\\bf x}'$\n      \\item[] Exhibit enthusiasm: $ s \\leftarrow sE$\n      \\end{itemize}\n    \\item[] else if $f_{new} = f_0$ then\n      \\begin{itemize}\n      \\item[] Quit with result ${\\bf x}$\n      \\end{itemize}\n    \\item[] else\n      \\begin{itemize}\n      \\item[] Exhibit reluctance: $ s \\leftarrow sR$\n      \\end{itemize}\n    \\end{itemize}\n  \\item[] $i \\leftarrow i+1$\n  \\item[] Check:\n    \\begin{itemize}\n    \\item[] if $i>i_{max}$ then quit with result ${\\bf x}$\n    \\item[] if $|\\Delta{\\bf x}| < dx$ then quit with result ${\\bf x}$\n    \\end{itemize}\n  \\end{itemize}\n\\end{itemize}\nThe notation is that ${\\bf x}$ is of dimension $d$, and $\\hat {\\bf j}$ is a unit vector in the $j$ direction, with $j=1\\dots d$.\n\n\\section{Running calibration}\n\nA script performing the above calibration procedure can be run; the synthetic data generated\nwith the script described above is used.\\\\\n\\comline{./02\\_Run\\_Zim\\_Minimise\\_Objective.awk} \\\\\nAfter some computation, the result can be found in the file {\\tt \\_00\\_StaticTypes.zim}:\n\\[ % 1.32948   0.162204\n  v_\\mu = 1.329,  \\quad v_\\sigma = 0.162\n.\\]\n\n\\section{Calibrated model}\n\nRunning again the Travel-Time Tool, \\\\\n\\comline{./03\\_Run\\_TTC\\_post\\_calib.sh} \\\\\na comparison bewteen the simulator output and the synthetic\nreference data now appears as shown in \\Figref{TTdiff2}.\nThe calibration procedure has reduced the mean travel-time error from $-100$ s to $-19$ s \n\n\\begin{figure}[ht]\n  \\centering\n  \\includegraphics[angle=0,width=10cm]{80_figs/_PostCalib_TTC_0500-0900.eps}\n  \\caption{Distribution of travel-time error after calibration; $\\mu=-15$ s, $\\sigma=90$ s.}\n  \\label{TTdiff2}\n\\end{figure}\n\nThe new global distribution of travel times is shown in the following\nchapter, in \\Figref{_TTDist2}; it now has a mean of $2333$ s and a\nstandard deviation of $998$ s.\n%\\begin{figure}[ht]\n%  \\centering\n%  \\includegraphics[angle=0,width=10cm]{_TTD2_0500-2500.eps}\n%  \\caption{Distribution of travel times after calibration; $\\mu=...$ s, $\\sigma=...$ s.}  \\label{TTglobal2}\n%  \\label{TTglobal2}\n%\\end{figure}\n\nIn \\Chapref{Chap:MadResu} various results will be extracted from the\ncalibrated simulation.\n", "meta": {"hexsha": "f9185134d2b7de9f6b8ec9a153cb833b85d4a414", "size": 9553, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "01_Documentation/source/80_Madrid_Calibration.tex", "max_stars_repo_name": "IBM/zimulator", "max_stars_repo_head_hexsha": "312dff0506ece3d8ed015152c87dd303eb2d569f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-31T17:52:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-31T17:52:17.000Z", "max_issues_repo_path": "01_Documentation/source/80_Madrid_Calibration.tex", "max_issues_repo_name": "IBM/zimulator", "max_issues_repo_head_hexsha": "312dff0506ece3d8ed015152c87dd303eb2d569f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "01_Documentation/source/80_Madrid_Calibration.tex", "max_forks_repo_name": "IBM/zimulator", "max_forks_repo_head_hexsha": "312dff0506ece3d8ed015152c87dd303eb2d569f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-11-04T14:43:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-29T14:30:03.000Z", "avg_line_length": 45.7081339713, "max_line_length": 130, "alphanum_fraction": 0.7117135978, "num_tokens": 2788, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4442440427985912}}
{"text": "\\documentclass[8pt]{article}\n\n\\usepackage{fullpage}\n\\usepackage[margin=.5in]{geometry}\n\\usepackage{epic}\n\\usepackage{eepic}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{ragged2e}\n\\usepackage[parfill]{parskip}\n\\usepackage{amssymb}\n\n\n\\newcommand{\\proof}[1]{\n{\\noindent {\\it Proof.} {#1} \\rule{2mm}{2mm} \\vskip \\belowdisplayskip}\n}\n\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem{theorem}[lemma]{Theorem}\n\\newtheorem{claim}[lemma]{Claim}\n\\newtheorem{definition}[lemma]{Definition}\n\\newtheorem{corollary}[lemma]{Corollary}\n\n\\begin{document}\n\\hfill \\small{\\today} \\\\\n\\setlength{\\fboxrule}{.5mm}\\setlength{\\fboxsep}{1.2mm}\n\\newlength{\\boxlength}\\setlength{\\boxlength}{\\textwidth}\n\\addtolength{\\boxlength}{-4mm}\n\\begin{center}\\framebox{\\parbox{\\boxlength}{\\bf\n\\center{CS 577 - Homework 11}\n\\center{Sejal Chauhan, Vinothkumar Siddharth, Mihir Shete}\n}}\\end{center}\n\\vspace{5mm}\n\n\\section{Graded written problem}\n\n\\textbf{Part a:} Two Travelling Turkey Problem (TTTP) as mentioned in the written problem has the following contraints:\n\\begin{itemize}\n\\item Each city is visited at least once\n\\item Number of distinct routes has to be as small as possible\n\\item Each city can be visited any number of times\n\\item Path starts and ends at the same city\n\\item Maximum of the total effort of the two turkeys is minimized\n\\end{itemize}\n\nTo formally describe the problem we will consider a complete graph $G = (V, E)$ with $2$ edge-weight functions $w_a: E \\rightarrow \\mathbb{R}$ and $w_h: E \\rightarrow \\mathbb{R}$. Where $w_a(e)$ represents the effort taken by \\textit{Abe} to travel along the edge $e$ from a city on one end of the edge to the other, while $w_h(e)$ represents the effort required by \\textit{Honest}\n\nWith the above definition for the graph $G$ we can describe the decision version of the problem as:\n\nFor the graph G and $k \\in \\mathbb{R}$, report \\textit{yes} if there exists a spanning tree $S$ such that $MAX(\\sum_{\\forall e \\in S}{w_a(e)}, \\sum_{\\forall e \\in S}{w_h(e)})$ is at-most $k$, else report \\textit{no}.\n\n\\textbf{Part b:} Decision problem is NP-complete\n\nTo prove that TTTP decision problem is NP-complete, we will show that Partition Set(PS) that is a known NP-complete problem, can be reduced to TTTP problem.\nGiven a set $S$ of Real numbers and the sum of all elements in $S$ as $2*w$, we compute a graph $G$, such that $G$ has a spanning tree $ST$ with $MAX(\\sum_{\\forall e \\in ST}{w_a(e)}, \\sum_{\\forall e \\in ST}{w_h(e)}) \\leq w$ only if we can Partition the set using PS algorithm.\n\nTo transform the elements of $S$ to the graph $G$ we create a root node, and for every element $i$ in $S$ and add two vertices with edge weight as ($w_a = S[i]$, $w_h = 0$) and ($w_a = 0$, $w_h = S[i]$) to the root note. The edge weight between these two vertices is (0,0). Construct this gadget with all the elements in $S$ and make it a complete graph by connecting all the unconnected vertices with edge weights ($w_a = \\infty$,$w_h = \\infty$).\n\nNow, if the TTTP-decision problem returns that \\textit{yes} we claim that we can partition the set $S$ in $2$ subsets such that each subset has sum $w$. This is possible when the TTTP-decision problem can find a spanning tree in the graph $G$ such that $\\sum_{\\forall e \\in ST}{w_a(e)} = \\sum_{\\forall e \\in ST}{w_h(e)} = w$. All the weights returned by $w_a(e)$ can be considered elements of one subset and the weights returned by $w_h(e)$ the elements of the other subset for the \\textit{Partition} problem on set $S$, and we can see that these subsets contain all the elements of set $S$ and their sums are equal and so the PS-decision problem on set will also return \\textit{yes}.\n\nIf the TTTP-decision problem returns \\textit{no}, then consider a spanning tree made of edges whose weights are not $\\infty$. Such a spanning tree will have minimum total edge weight for $w_e$ and $w_h$ summed together of $2*w$ when all the elements in the set $S$ either as the edge weights for one turkey or the other. Now since we cannot find a spanning tree, wherein $\\sum_{\\forall e \\in ST}{w_a(e)} \\leq w$ and $\\sum_{\\forall e \\in ST}{w_h(e)} \\leq w$, because if one of them is less than $w$ then the other one will be greater than $w$. And hence these set of edge weights cannot be used to create a solution for the PS problem, so PS-decision problem will also return \\textit{no}.\n\nThus, PS-decision can be reduced to TTTP-decision problem and so TTTP-decision problem is NP-complete.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "f179930a00e643886d2c139fccf4ec625e9cc61a", "size": 4617, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw11.tex", "max_stars_repo_name": "smihir/cs577", "max_stars_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw11.tex", "max_issues_repo_name": "smihir/cs577", "max_issues_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw11.tex", "max_forks_repo_name": "smihir/cs577", "max_forks_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.3918918919, "max_line_length": 687, "alphanum_fraction": 0.7392246047, "num_tokens": 1353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.4442440359186661}}
{"text": "%#!pdflatex Naruse_Esurf_2020.tex\r\n\r\n\\section{Inverse modeling by deep learning NN}\r\nIn this study, numerical simulation of a turbidity current is repeated under various random initial conditions to produce a data set of the characteristic features of turbidites. Then, this artificial dataset of turbidites is used for supervised training of a deep learning NN. The values of the turbidites characteristics, i.e., distribution of volume-per-unit-area of all grain size classes, in the training data set are input to the NN, and the estimated initial conditions (e.g., initial flow height and concentration) of the turbidity current is obtained from the output nodes of NN. The output values of the NN are compared with the true conditions. The optimization of weight coefficients of NN is then conducted to reduce the mean square of the difference between the true conditions and the output values of the NN. If the number of training datasets is sufficiently large, the trained NN should be able to estimate the paleo-hydraulic conditions from the data of the ancient turbidites (Fig. \\ref{fig:schematic_diagram_procedures}). In other words, an empirical relationship with numerical results and the model input parameters are explored in this method, and the discovered relationship is used for inverse modeling of turbidity currents. \r\n\r\nThe local conditions of a turbidity current (velocity, concentration, etc.) at any locations and time can be estimated from the reconstructed initial conditions. The flow parameters are obtained by calculating the time evolution of the forward model from the initial conditions. In this way, we can obtain the behavior of the flow with a relatively small number of parameters. This approach has already been tried successfully by Lesshafft et al. (2011), and Falcini et al. (2009) also reconstructed flow conditions of turbidity currents by obtaining boundary conditions of the model.\r\n\r\nThe details of these procedures are described below.\r\n\r\n\\subsection{Production and preprocessing of training and test data sets for supervised machine learning}\r\n\r\nWe conducted iterative calculations using the forward model and accumulated data to train and validate the inverse model. To investigate the appropriate amounts of data for training the inverse model, we conducted 500--3500 iteration of the forward model calculations. To verify the performance of the trained model, 300 test data sets were also generated numerically, independent of the training data.\r\n\r\nModel input parameters that are subject to inversion are required to produce the training and test data by the forward model calculation (Fig. \\ref{fig:model_input_parameters}). In this study, the model inputs are the initial flow height $H_0$, the initial flow length $l_0$, the initial sediment concentration for the $i$th grain size class $C_i$, and the basin slope $S$. These model parameters are generated as uniform random numbers within a certain range, and their range is changed according to the target of the inverse analysis. Since this study is aimed at field-scale analysis, the following ranges are chosen. Both initial depth and length of suspended cloud range from 50 to 600 m. The sediment concentration for each grain size class ranges from 0.01\\% to 1.0\\%. The number of grain size classes $N$ is four, and the representative grain diameters are 1.5, 2.5, 3.5 and 4.5 phi. The inclination of the basin plain where the turbidites are expected to form ranges from 0 to 1.0\\%. \r\n\r\nEach run of the forward model calculation is initiated with the given model input parameters, and is terminated when the flow head reaches the downstream end or sufficiently long time period ($1.2 \\times 10^5$ s.) has elapsed. As a result of the calculation, the forward model outputs the volume-per-unit-area of sediment for all grain size classes over the 100 km-long calculation domain. The inverse model estimates the model input parameters from the resultant spatial distribution of the granulometric characteristics of the deposits. However, in natural outcrops, it is unlikely that the entire distribution of the turbidite beds would be exposed. Therefore, we limit the length of the sampling window in the calculation domain, and only the sediment data contained in this window is extracted for both training and testing. The upstream end of the sampling window was set at the transition point between the steep slope and the basin plain (5 km from the upstream end), and the length of the window varies from 1 to 30 km to evaluate the data interval required for the inverse analysis.\r\n\r\nBefore the model input parameters are input to NN, all values are normalized between 0 and 1 using the following equation:\r\n\r\n\\begin{equation}\r\nI_{i}^{*} = \\frac{I_i - I_{min}}{I_{max} - I_{min}}\r\n\\label{eq:normalization}\r\n\\end{equation}\r\n\r\n\\noindent where $I_i^*$ and $I_i$ denote the $i$th normalized and original input parameters, respectively. $I_{\\mathrm{max}i}$ and $I_{\\mathrm{min}i}$ are the maximum and minimum values used for generating the $i$th input parameter, respectively. This min-max normalization is applied to consider all parameters at equal weights because the range of the initial flow conditions is significantly different between them.\r\n\r\n\\subsection{Structure of NN}\r\nThe artificial NN is used as the inverse model to reconstruct flow conditions from the depositional architecture. We input the spatial distribution of volume-per-unit-area of multiple grain size classes of a turbidite in the NN, which outputs the values of the flow initial conditions and the basin slope. In this study, we use a fully connected NN that has four hidden layers. The volume-per-unit-area of $N$ grain-size classes of sediment deposited on $M$ spatial grids in the sampling window is given to the input nodes of the NN. Thus, the total number of the NN input nodes is $N \\times M$. The number of nodes in all hidden layers is set to 2000 in this study. \r\n\r\nThe Rectified Linear Unit (ReLU) activation function is adopted for all NN layers \\citep{Nair2010, Glorot2011}. The ReLU is the half-wave rectifier $f(z) = \\max(z, 0)$. Compared with other smoother non-linearities, such as $\\tanh(z)$ or $1/(1+\\exp(-z))$, the ReLU typically learns much faster in NN with multiple layers \\citep{Glorot2011}, and thus it allows to train a deep supervised network without unsupervised pre-training \\citep{LeCun2015}.\r\n\r\nThe NN is expected to output the model input parameters (i.e., the initial flow conditions and the basin slope), and therefore, the number of nodes in the output layer is equal to the number of input parameters for the forward model, which is seven here (the initial flow length, depth, sediment concentrations and the basin slope).\r\n\r\n\\subsection{Training the inverse model}\r\nTo develop the inverse model, supervised training is conducted using the artificial dataset produced by the forward model calculation. First, the artificial dataset is randomly split into training and validation datasets to detect overfitting during the training process. The ratio of the validation dataset is set to 0.2 so that 80\\% of the artificial dataset is used for training. The model input parameters used for producing training and validation sets were regarded as the teacher data to train and evaluate the model.\r\n\r\nMethodology applied for training the NN is as follows. The mean squared error (MSE) is adopted as the loss function because the supervised training of NN in this study is classified as a regression problem \\citep{Specht1991}, and MSE is a common loss function for regression \\citep{Bishop2006,Hastie2009,ShalevShwartz2014}. Before training, all weight coefficients of NN are randomly initialized using the Glorot uniform distribution \\citep{Glorot2010}. The backpropagation algorithm \\citep{Rumelhart1986} is used to calculate the derivative of this error metric for each connection between the nodes, and the stochastic gradient descent method (SGD) with Nesterov momentum \\citep{NESTEROV1983} is used for optimizing the weight coefficients of NN to minimize the difference between the model predictions and the teacher datasets. Other optimization methods, such as AdaGrad \\citep{Duchi2011}, RMSprop \\citep{Tieleman2012} and AdaDelta \\citep{Zeiler2012}, have been tested, but SGD shows the best performance in this case. Dropout regularization \\citep{Srivastava2014} is applied for each epoch to reduce overfitting and to improve the generalization ability of the NN. One training epoch, which refers to one cycle through the full training dataset, is repeated until the loss function of the validation dataset converges to a constant value. These methods are all implemented in Python with the library Tensorflow 2.1.0 \\citep{Raschka2019}, and the calculations are conducted using GPU NVIDIA GeForce GTX 2080 Super with libraries CUDA 11.0 and CuDNN 7.0.\r\n\r\nSeveral hyperparameters should be specified for the training of NN. Specifically, the dropout rate, the learning rate, the batch size, the number of epochs, and the momentum are adjusted manually after repeated trial and error. To perform an optimization calculation with SGD, the batch size and the learning rate were set to 32 and 0.02, and the value 0.9 was chosen for the momentum. Dropout rate for regularization was 0.5. \r\n\r\n\\subsection{Testing the inverse model}\r\n\r\nThe performance of the inverse model is tested using a set of 300 data that are produced independently of the training and validation datasets. The inversion precision for each model input parameter is evaluated by the root mean square error (RMSE) and the mean absolute error (MAE) of the prediction. These error metrics are computed for both raw and normalized values with true values, and used to evaluate the model. Moreover, the bias of prediction (i.e., the mean deviation of the model predictions from the true input parameters) is used describe the accuracy of the inversion. \r\n\r\nThree additional tests are conducted for verifying the robustness of the inverse model that is significant for the applicability of the model to field datasets. The results of these tests are evaluated by the average of the normalized RMSE, which is defined as:\r\n\r\n\\begin{equation}\r\n  \\mathrm{RMSE} = \\sqrt{ \\frac{1}{JK} \\sum_J \\sum_K {\\left( \\frac{I_{\\mathrm{p}jk} - I_{jk}}{I_{jk}} \\right)^2} }\r\n  \\label{eq:RMSE}\r\n\\end{equation}\r\n\r\n\\noindent where $I_{\\mathrm{p}jk}$ and $I_{jk}$ denote the predicted and the original values of the $j$th model input parameter for the $k$th test dataset, respectively. $J$ and $K$ are the numbers of the model input parameters and the test data sets.\r\n\r\nFirst, noise is artificially added to the test data to evaluate the robustness of the inversion results against the measurement error. Under natural conditions, measurement errors in the thickness and grain size analysis of turbidites as well as the local topography  affect these results. If the results of the inverse analysis change significantly due to such errors, it means that our method is not suitable for application to field data. To investigate this, we apply normal random numbers to the volume per unit area at each grid point in the training data at various rates, and we observe how much influence the noise has on the inverse analysis results.\r\n\r\nThe second test on the inverse model is to perform a subsampling of the grid points in the training data. Outcrops are not continuous over tens of kilometers, so that the thickness and the grain size distribution of a turbidite in the interval between outcrops can only be obtained by interpolation. To simulate this situation, the grid points in test datasets are randomly removed in this test, and the volume-per-unit-area at the removed grid points is linearly interpolated. By varying the rate at which grid points are removed, this test also allows us to estimate the average interval of the outcrops that are necessary for conducting the inverse analysis. That is, if 90\\% of the grid points set at 5 m intervals are removed, and the inverse analysis is conducted on the remaining 10\\%, the average distance between the grid points is 50 m. Estimating the outcrop spacing requires obtaining reasonable results of inverse analysis before applying it to the actual field.\r\n\r\nFinally, the influence of the length of the upstream slope was examined. In this study, it is assumed that a steep slope (10 \\%) of a submarine canyon with a length of 5 km exists upstream, and a basin plain with a gentle slope exists downstream of the steep slope. Although the topography and deposits of the upstream slope are not the subject of the inverse model analysis, the length of the slope potentially affect the results of the inverse analysis. As a test, we set a slope of 10 km length instead of 5 km upstream, and deposited a turbidite bed from the turbidity current flowing down from the uppermost part of the slope. The turbidite was then analyzed using a model trained on the assumption of 5 km slope to compare the reconstructed values with the original conditions.", "meta": {"hexsha": "2e5936a53930b966bc316cdcd695f72afebeca20", "size": 13049, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/inverse_model.tex", "max_stars_repo_name": "narusehajime/nninv1d", "max_stars_repo_head_hexsha": "697743346c7e24a8f06d676e2e9f3330aee93afe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/inverse_model.tex", "max_issues_repo_name": "narusehajime/nninv1d", "max_issues_repo_head_hexsha": "697743346c7e24a8f06d676e2e9f3330aee93afe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/inverse_model.tex", "max_forks_repo_name": "narusehajime/nninv1d", "max_forks_repo_head_hexsha": "697743346c7e24a8f06d676e2e9f3330aee93afe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 224.9827586207, "max_line_length": 1558, "alphanum_fraction": 0.7992949651, "num_tokens": 2806, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4442373901161655}}
{"text": "%\\documentclass{article}\r\n%\\usepackage{amsmath}\r\n%\\begin{document}\r\n\r\n\\section{Turbulence}\r\n{\\bf \\Large \r\n\\begin{tabular}{ccc}\r\n\\hline\r\n  Correnspoinding author & : & Seiya Nishizawa\\\\\r\n\\hline\r\n\\end{tabular}\r\n}\r\n\r\n\\def\\half{\\frac{1}{2}}\r\n\r\n\\subsection{Spatial filter}\r\n\r\nThe governing euqations are the followings:\r\n\\begin{align}\r\n  \\frac{\\partial\\rho}{\\partial t} + \\frac{\\partial u_i \\rho}{\\partial x_i} \r\n  &= 0 \\\\\r\n  \\frac{\\partial\\rho u_i}{\\partial t}\r\n  + \\frac{\\partial u_j \\rho u_i}{\\partial x_j}\r\n  &= -\\frac{\\partial p}{\\partial x_i} + g \\rho \\delta_{i3} \\\\\r\n  \\frac{\\partial\\rho \\theta}{\\partial t}\r\n  + \\frac{\\partial u_i \\rho \\theta}{\\partial x_i}\r\n  &= Q\r\n\\end{align}\r\n\r\nSpatial filtering the continuity equation yields\r\n\\begin{equation}\r\n  \\frac{\\partial \\overline{\\rho}}{\\partial t} + \\frac{\\partial \\overline{u_i \\rho}}{\\partial x_i} = 0, \\label{eq: spatial filtered rho}\r\n\\end{equation}\r\nwhere $\\overline{\\phi}$ means the spatial filtered quantity of an arbitrary variable $\\phi$.\r\nThe Favre filtering (Favre 1983) defined by\r\n\\begin{equation}\r\n  \\widetilde{\\phi} = \\frac{\\overline{\\rho \\phi}}{\\overline{\\rho}}\r\n\\end{equation}\r\nmakes the equation (\\ref{eq: spatial filtered rho})\r\n\\begin{equation}\r\n  \\frac{\\partial \\overline{\\rho}}{\\partial t} + \\frac{\\partial \\widetilde{u_i}\\overline{\\rho}}{\\partial x_i} = 0.\r\n\\end{equation}\r\n\r\n\r\nThe momentam equations become\r\n\\begin{align}\r\n  \\frac{\\partial \\overline{\\rho u_i}}{\\partial t} + \\frac{\\partial \\overline{u_j\\rho u_i}}{\\partial x_j} &= -\\frac{\\partial \\overline{p}}{\\partial x_i} + \\overline{\\rho} g\\delta_{i3} \\\\\r\n  \\frac{\\partial \\overline{\\rho}\\widetilde{u_i}}{\\partial t} + \\frac{\\partial \\widetilde{u_j}\\:\\overline{\\rho}\\widetilde{u_i}}{\\partial x_j} &= -\\frac{\\partial \\overline{p}}{\\partial x_i} + g\\overline{\\rho} \\delta_{i3}\r\n    -\\frac{\\partial}{\\partial x_j}\\left(\\overline{u_i \\rho u_j} - \\widetilde{u_j}\\overline{\\rho}\\widetilde{u_i}\\right) \\\\\r\n  \\frac{\\partial \\overline{\\rho}\\widetilde{u_i}}{\\partial t} + \\frac{\\partial \\widetilde{u_j}\\:\\overline{\\rho}\\widetilde{u_i}}{\\partial x_j} &= -\\frac{\\partial \\overline{p}}{\\partial x_i} + g\\overline{\\rho} \\delta_{i3}\r\n    -\\frac{\\partial}{\\partial x_j}\\overline{\\rho}\\left(\\widetilde{u_i u_j} - \\widetilde{u_j}\\widetilde{u_i}\\right).\r\n\\end{align}\r\n\r\n\r\nAs the same matter, the thermal equation becomes\r\n\\begin{equation}\r\n  \\frac{\\partial \\overline{\\rho}\\widetilde{\\theta}}{\\partial t}\r\n  + \\frac{\\partial \\widetilde{u_i}\\overline{\\rho}\\widetilde{\\theta}}{\\partial x_i}\r\n  = Q -\\frac{\\partial}{\\partial x_i}\\overline{\\rho}\\left(\\widetilde{u_i\\theta}-\\widetilde{u_i}\\widetilde{\\theta}\\right).\r\n\\end{equation}\r\n\r\nThen, the govering equations for the prognositic variables\r\n($\\overline{\\rho}, \\overline{\\rho}\\widetilde{u_i}, $ and $\\overline{\\rho}\\widetilde{\\theta}$) are\r\n\\begin{align}\r\n  \\frac{\\partial \\overline{\\rho}}{\\partial t}\r\n  + \\frac{\\partial \\widetilde{u_i}\\overline{\\rho}}{\\partial x_i} &= 0, \\\\\r\n  \\frac{\\partial \\overline{\\rho}\\widetilde{u_i}}{\\partial t}\r\n  + \\frac{\\partial \\widetilde{u_j}\\overline{\\rho}\\widetilde{u_i}}{\\partial x_j}\r\n  &= -\\frac{\\partial \\overline{p}}{\\partial x_i} + g\\overline{\\rho}\\delta_{i3}\r\n  -\\frac{\\partial \\overline{\\rho}\\tau_{ij}}{\\partial x_j}, \\\\\r\n  \\frac{\\partial \\overline{\\rho}\\widetilde{\\theta}}{\\partial t}\r\n  + \\frac{\\partial \\widetilde{u_i}\\overline{\\rho}\\widetilde{\\theta}}{\\partial x_i}\r\n  &= Q -\\frac{\\partial \\overline{\\rho}\\tau^*_{i}}{\\partial x_i},\r\n\\end{align}\r\nwhere\r\n\\begin{align}\r\n  \\tau_{ij} &= \\widetilde{u_iu_j}-\\widetilde{u_i}\\widetilde{u_j}, \\\\\r\n  \\tau^*_{i} &= \\widetilde{u_i\\theta}-\\widetilde{u_i}\\widetilde{\\theta}.\r\n\\end{align}\r\n\r\n\\subsection{SGS model}\r\n\\subsubsection{Smagorinsky-Lilly model}\r\n\\begin{equation}\r\n  \\tau_{ij} - \\frac{1}{3}\\tau_{kk}\\delta_{ij} = -2\\nu_{SGS}\\left(S_{ij}-\\frac{1}{3}S_{kk}\\delta_{ij}\\right),\r\n\\end{equation}\r\nwhere $S_{ij}$ is the strain tensor,\r\n\\begin{equation}\r\n  S_{ij} = \\frac{1}{2}\\left(\\frac{\\partial \\widetilde{u_i}}{\\partial x_j} + \\frac{\\partial \\widetilde{u_j}}{\\partial x_i}\\right),\r\n  \\label{eq:strain tensor}\r\n\\end{equation}\r\nand\r\n\\begin{equation}\r\n  \\nu_{SGS} = \\left(C_s\\Delta\\right)^2 \\left|S\\right|.\r\n\\end{equation}\r\n$C_s$ is the Smagorinsky constant,\r\n$\\Delta$ is the grid spacing,\r\nand $\\left|S\\right|$ is scale of the tensor $S$,\r\n\\begin{equation}\r\n  \\left|S\\right| = \\sqrt{2S_{ij}S_{ij}}.\r\n  \\label{eq:|S|}\r\n\\end{equation}\r\n\\begin{equation}\r\n  \\tau_{ij} = -2\\nu_{SGS}\\left(S_{ij}-\\frac{1}{3}S_{kk}\\delta_{ij}\\right)\r\n             + \\frac{2}{3} TKE\\delta_{ij},\r\n  \\label{eq:tau}\r\n\\end{equation}\r\nwhere\r\n\\begin{equation}\r\n  TKE = \\frac{1}{2}\\left(\\widetilde{u_i^2} - \\widetilde{u_i}^2\\right)\r\n   = \\frac{1}{2}\\tau_{ii}\r\n   = \\left(C_s\\Delta\\right)^2\\left|S\\right|^2.\r\n   \\label{eq:tke}\r\n\\end{equation}\r\n\r\n\r\n\\begin{equation}\r\n  \\tau^*_i = -\\nu^*_{SGS} \\frac{\\partial \\widetilde{\\theta}}{\\partial x_i},\r\n  \\label{eq:tau*}\r\n\\end{equation}\r\nwhere\r\n\\begin{equation}\r\n  \\nu^*_{SGS} = \\frac{1}{Pr}\\nu_{SGS}.\r\n\\end{equation}\r\n$Pr$ is the turbulent Prandtl number.\r\nFor the other scalar constants such as water vaper,\r\n$\\nu^*_{SGS}$ is also used as their diffusivity.\r\n\r\nTo include buoyancy effects,\r\nthe extension of the basic Smagorinsky developed by Brown et al. (1994)\r\nis used.\r\n\\begin{equation}\r\n  \\nu_{SGS} = \\lambda_r^2 |S| \\sqrt{1-Rf},\r\n\\end{equation}\r\nwhere $Rf$ is the flux Richardson number ($Rf = Ri/Pr$),\r\nand $\\lambda_r$ is a characteristic subgrid length scale.\r\n$Ri$ is the Richardson number,\r\n\\begin{equation}\r\n  Ri = \\frac{N^2}{|S|^2},\r\n  \\label{eq:Ri}\r\n\\end{equation}\r\nand $N^2$ is the Brunt-Visala frequency,\r\n\\begin{equation}\r\n  N^2 = \\frac{g}{\\theta}\\frac{\\partial\\theta}{\\partial z}.\r\n  \\label{eq:N^2}\r\n\\end{equation}\r\nThe Prandtl number is an unknow parameter,\r\nand it depends on the Richardson number,\r\nwhile it is offten assumed a constant value.\r\nFor the unstable conditions ($Ri < 0$),\r\n\\begin{align}\r\n  \\nu_{SGS} &= \\left(C_s\\Delta\\right)^2 |S| \\sqrt{1 - c Ri}, \\label{eq:nu unstable} \\\\\r\n  \\nu^*_{SGS} &= \\frac{1}{Pr_N} \\left(C_s\\Delta\\right)^2 |S| \\sqrt{1 - b Ri} \\label{eq:nu^* unstable},\r\n\\end{align}\r\nwhere $Pr_N$ is the Prandtl number in neutral condtions.\r\nThe values of $c, b, Pr_N$ are set 16, 40, and 0.7, respectively.\r\nThen the Prandtl number is\r\n\\begin{equation}\r\n  Pr = Pr_N \\sqrt{\\frac{1-c Ri}{1-b Ri}}.\r\n\\end{equation}\r\nFor the stable condtions,\r\nwhen the Richardson number is smaller than the critical Richardson number, $Ri_c (=0.25)$,\r\n\\begin{align}\r\n  \\nu_{SGS} &= \\left(C_s\\Delta\\right)^2 |S| \\left(1-\\frac{Ri}{Ri_c}\\right)^4, \\label{eq:nu stable} \\\\\r\n  \\nu^*_{SGS} &= \\frac{1}{Pr_N}\\left(C_s\\Delta\\right)^2 |S| \\left(1-\\frac{Ri}{Ri_c}\\right)^4\\left(1-g Ri\\right). \\label{eq:nu^* stable}\r\n\\end{align}\r\nThe constant $g$ is determined as the Prandtl number becomes 1\r\nin the limit of $Ri \\to Ri_C$ and then is $(1-Pr_N)/Ri_c$.\r\nThe Prandtl number is\r\n\\begin{equation}\r\n  Pr = Pr_N \\left(1-\\frac{1-Pr_N}{Ri_c}Ri\\right)^{-1}.\r\n\\end{equation}\r\nFor the strongly stable condistions ($Ri > Ri_c$),\r\nthe eddy viscosity and the diffusivity for scalars are 0;\r\n\\begin{align}\r\n  \\nu_{SGS} &= 0, \\label{eq:nu strong stable} \\\\\r\n  \\nu^*_{SGS} &= 0. \\label{eq:nu^* strong stable}\r\n\\end{align}\r\n\r\n\r\n\\subsection{descretization}\r\n\r\n\\subsubsection{Time integration method}\r\nThe time integration in terms of the sub-grid scale turburence\r\nis done by the eular scheme:\r\n\\begin{align}\r\n  \\left(\\overline{\\rho} \\widetilde{u}\\right)^{t+\\Delta t}\r\n  &= \\left(\\overline{\\rho} \\widetilde{u}\\right)^t\r\n  - \\left(\r\n    \\frac{\\partial \\overline{\\rho}\\tau_{11}}{\\partial x}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{12}}{\\partial y}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{13}}{\\partial z}\r\n  \\right)^t\r\n  \\Delta t, \\\\\r\n  \\left(\\overline{\\rho} \\widetilde{v}\\right)^{t+\\Delta t}\r\n  &= \\left(\\overline{\\rho} \\widetilde{v}\\right)^t\r\n  - \\left(\r\n    \\frac{\\partial \\overline{\\rho}\\tau_{21}}{\\partial x}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{22}}{\\partial y}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{23}}{\\partial z}\r\n  \\right)^t\r\n  \\Delta t, \\\\\r\n  \\left(\\overline{\\rho} \\widetilde{w}\\right)^{t+\\Delta t}\r\n  &= \\left(\\overline{\\rho} \\widetilde{w}\\right)^t\r\n  - \\left(\r\n    \\frac{\\partial \\overline{\\rho}\\tau_{31}}{\\partial x}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{32}}{\\partial y}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau_{33}}{\\partial z}\r\n  \\right)^t\r\n  \\Delta t, \\\\\r\n  \\left(\\overline{\\rho} \\widetilde{\\theta}\\right)^{t+\\Delta t}\r\n  &= \\left(\\overline{\\rho} \\widetilde{\\theta}\\right)^t\r\n  - \\left(\r\n    \\frac{\\partial \\overline{\\rho}\\tau^*_1}{\\partial x}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau^*_2}{\\partial y}\r\n  + \\frac{\\partial \\overline{\\rho}\\tau^*_3}{\\partial z}\r\n  \\right)^t\r\n  \\Delta t.\r\n\\end{align}\r\n\r\n\\subsubsection{Spatial descretization}\r\nWe use the 4th order differnce scheme for the advection term as mentioned\r\nin the chapter \\ref{chap:descretization dynamics}.\r\nThe $\\tau_{ij}$ and $\\tau^*_{i}$ are propotional to\r\nthe square of the grid spacing ($\\Delta^2$).\r\nDue to the consistency with the advection term\r\nin terms of order for spatial difference,\r\nthe second order central difference scheme\r\nis used for the sub-grid scale turburence.\r\nIn the following part in this sub-section,\r\noverline and tilde are ommited,\r\nand overline, and $i,j,k$ mean\r\nas they are in the chapter \\ref{chap:descretization dynamics}.\r\n\r\n\\paragraph{Momentam equation}\r\nThe tendencies in the momentam equation related to the sub-grid scale mode are\r\n\\begin{align}\r\n  \\frac{\\partial \\rho u}{\\partial t}_{i+\\half,j,k} &=\r\n    \\frac{\\rho_{i+1,j,k}\\tau_{11,i+1,j,k}-\\rho_{i,j,k}\\tau_{11,i,j,k}}{\\Delta x}\r\n  + \\frac{\\overline{\\rho}_{i+\\half,j+\\half,k}\\tau_{12,i+\\half,j+\\half,k}-\\overline{\\rho}_{i+\\half,j-\\half,k}\\tau_{12,i+\\half,j-\\half,k}}{\\Delta y} \\nonumber \\\\\r\n  &+ \\frac{\\overline{\\rho}_{i+\\half,j,k+\\half}\\tau_{13,i+\\half,j,k+\\half}-\\overline{\\rho}_{i+\\half,j,k-\\half}\\tau_{13,i+\\half,j,k-\\half}}{\\Delta z}, \\\\\r\n  \\frac{\\partial \\rho v}{\\partial t}_{i,j+\\half,k} &=\r\n    \\frac{\\overline{\\rho}_{i+\\half,j+\\half,k}\\tau_{21,i+\\half,j+\\half,k}-\\overline{\\rho}_{i-\\half,j+\\half,k}\\tau_{21,i-\\half,j+\\half,k}}{\\Delta x}\r\n  + \\frac{\\rho_{i,j+1,k}\\tau_{22,i,j+1,k}-\\rho_{i,j,k}\\tau_{22,i,j,k}}{\\Delta y} \\nonumber \\\\\r\n &+ \\frac{\\overline{\\rho}_{i,j+\\half,k+\\half}\\tau_{23,i,j+\\half,k+\\half}-\\overline{\\rho}_{i,j+\\half,k-\\half}\\tau_{23,i,j+\\half,k-\\half}}{\\Delta z}, \\\\\r\n  \\frac{\\partial \\rho w}{\\partial t}_{i,j,k+\\half} &=\r\n    \\frac{\\overline{\\rho}_{i+\\half,j,k+\\half}\\tau_{31,i+\\half,j,k+\\half}-\\overline{\\rho}_{i-\\half,j,k+\\half}\\tau_{31,i-\\half,j,k+\\half}}{\\Delta x}\r\n  + \\frac{\\overline{\\rho}_{i,j+\\half,k+\\half}\\tau_{32,i,j+\\half,k+\\half}-\\overline{\\rho}_{i,j-\\half,k+\\half}\\tau_{32,i,j-\\half,k+\\half}}{\\Delta y} \\nonumber \\\\\r\n &+ \\frac{\\rho_{i,j,k+1}\\tau_{33,i,j,k+1}-\\rho_{i,j,k}\\tau_{33,i,j,k}}{\\Delta z}.\r\n\\end{align}\r\nThe $\\overline{\\rho}$ is\r\n\\begin{align}\r\n  \\overline{\\rho}_{i,j+\\half,k+\\half} &=\r\n  \\frac{\\rho_{i,j+1,k+1} + \\rho_{i,j+1,k} + \\rho_{i,j,k+1} + \\rho_{i,j,k}}{4}, \\\\\r\n  \\overline{\\rho}_{i+\\half,j,k+\\half} &=\r\n  \\frac{\\rho_{i+1,j,k+1} + \\rho_{i+1,j,k} + \\rho_{i,j,k+1} + \\rho_{i,j,k}}{4}, \\\\\r\n  \\overline{\\rho}_{i+\\half,j+\\half,k} &=\r\n  \\frac{\\rho_{i+1,j+1,k} + \\rho_{i+1,j,k} + \\rho_{i,j+1,k} + \\rho_{i,j,k}}{4}.\r\n\\end{align}\r\nThe $\\tau$ is calculated from the strain tensor and $N^2$ at each point,\r\nfrom eq.(\\ref{eq:tau}),(\\ref{eq:tke}), (\\ref{eq:nu unstable}), (\\ref{eq:nu stable}), (\\ref{eq:nu strong stable}), (\\ref{eq:|S|}), and (\\ref{eq:Ri}).\r\n\r\n\\paragraph{Thermal equation}\r\nThe tendency in the thermal equation related to the sub-grid scale model is\r\n\\begin{align}\r\n  \\frac{\\partial \\rho \\theta}{\\partial t}_{i,j,k} &=\r\n  - \\frac{\\overline{\\rho}_{i+\\half,j,k}\\tau^*_{1,i+\\half,j,k}-\\overline{\\rho}_{i-\\half,j,k}\\tau^*_{1,i-\\half,j,k}}{\\Delta x}\r\n  - \\frac{\\overline{\\rho}_{i,j+\\half,k}\\tau^*_{2,i,j+\\half,k}-\\overline{\\rho}_{i,j-\\half,k}\\tau^*_{2,i,j-\\half,k}}{\\Delta y} \\nonumber \\\\\r\n  &- \\frac{\\overline{\\rho}_{i,j,k+\\half}\\tau^*_{2,i,j,k+\\half}-\\overline{\\rho}_{i,j,k-\\half}\\tau^*_{3,i,j,k-\\half}}{\\Delta z}\r\n\\end{align}\r\nThe $\\overline{\\rho}$ at half-level is eq.(\\ref{eq:rho half i})-(\\ref{eq:rho half k}),\r\nthe $\\nu^*_{SGS}$ is calculated from the strain tensor and the $N^2$ with eq.(\\ref{eq:nu^* unstable}),(\\ref{eq:nu^* stable}), (\\ref{eq:nu^* strong stable}), (\\ref{eq:|S|}, and (\\ref{eq:Ri}).\r\nThe $\\tau^*$ at half-level\r\nis proportional to spatial difference of potential temperature\r\n(eq.\\ref{eq:tau*}),\r\nwhich requires potential temperature at full-level (eq.\\ref{eq:theta full}):\r\n\\begin{align}\r\n  \\tau^*_{1,i+\\half,j,k} &= -\\nu^*_{SGS} \\frac{\\theta_{i+1,j,k}-\\theta_{i,j,k}}{\\Delta x}, \\\\\r\n  \\tau^*_{2,i,j+\\half,k} &= -\\nu^*_{SGS} \\frac{\\theta_{i,j+1,k}-\\theta_{i,j,k}}{\\Delta y}, \\\\\r\n  \\tau^*_{3,i,j,k+\\half} &= -\\nu^*_{SGS} \\frac{\\theta_{i,j,k+1}-\\theta_{i,j,k}}{\\Delta x}. \\\\\r\n\\end{align}\r\n\r\n\r\n\r\n\\paragraph{Strain tensor}\r\nThe strain tensor, eq.(\\ref{eq:strain tensor}), have to be calculated\r\nat full-level (grid cell center) and edge center for the momentum equations,\r\nand at hafl-level (plane center) for the thermal equation;\r\n\r\n\\begin{itemize}\r\n  \\item cell center ($i,j,k$)\r\n    \\begin{align}\r\n      S_{11,i,j,k} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j,k}-\\overline{u}_{i-\\frac{1}{2},j,k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i,j,k} &= \\left\\{\r\n      \\frac{\\overline{v}_{i,j+\\frac{1}{2},k}-\\overline{v}_{i,j-\\frac{1}{2},k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i,j,k} &= \\left\\{\r\n      \\frac{\\overline{w}_{i,j,k+\\frac{1}{2}}-\\overline{v}_{i,j,k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i,j,k} = S_{21,i,j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i,j+\\frac{1}{2},k}-\\overline{u}_{i,j-\\frac{1}{2},k}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+\\frac{1}{2},j,k}-\\overline{v}_{i-\\frac{1}{2},j,k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i,j,k} = S_{32,i,j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i,j,k+\\frac{1}{2}}-\\overline{v}_{i,j,k-\\frac{1}{2}}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i,j+\\frac{1}{2},k}-\\overline{w}_{i,j-\\frac{1}{2},k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i,j,k} = S_{13,i,j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j,k}-\\overline{w}_{i-\\frac{1}{2},j,k}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i,j,k+\\frac{1}{2}}-\\overline{u}_{i,j,k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n  \\item $x$-$y$ plane center ($i,j,k+\\frac{1}{2}$)\r\n    \\begin{align}\r\n      S_{11,i,j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{u}_{i-\\frac{1}{2},j,k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i,j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{v}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i,j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i,j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{w}_{i,j,k+1}-\\overline{v}_{i,j,k}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i,j,k+\\frac{1}{2}} = S_{21,i,j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{u}_{i,j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{v}_{i-\\frac{1}{2},j,k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i,j,k+\\frac{1}{2}} = S_{32,i,j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i,j,k+1}-\\overline{v}_{i,j,k}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{w}_{i,j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i,j,k+\\frac{1}{2}} = S_{13,i,j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{w}_{i-\\frac{1}{2},j,k+\\frac{1}{2}}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i,j,k+1}-\\overline{u}_{i,j,k}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n    \\item $y$-$z$ plane center ($i+\\frac{1}{2},j,k$)\r\n    \\begin{align}\r\n      S_{11,i+\\frac{1}{2},j,k} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+1,j,k}-\\overline{u}_{i,j,k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i+\\frac{1}{2},j,k} &= \\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{v}_{i+\\frac{1}{2},j-\\frac{1}{2},k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i+\\frac{1}{2},j,k} &= \\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{v}_{i+\\frac{1}{2},j,k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i+\\frac{1}{2},j,k} = S_{21,i+\\frac{1}{2},j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{u}_{i+\\frac{1}{2},j-\\frac{1}{2},k}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+1,j,k}-\\overline{v}_{i,j,k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i+\\frac{1}{2},j,k} = S_{32,i+\\frac{1}{2},j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{v}_{i+\\frac{1}{2},j,k-\\frac{1}{2}}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{w}_{i+\\frac{1}{2},j-\\frac{1}{2},k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i+\\frac{1}{2},j,k} = S_{13,i+\\frac{1}{2},j,k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+1,j,k}-\\overline{w}_{i,j,k}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}-\\overline{u}_{i+\\frac{1}{2},j,k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n  \\item $z$-$x$ plane center ($i,j+\\frac{1}{2},k$)\r\n    \\begin{align}\r\n      S_{11,i,j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{u}_{i-\\frac{1}{2},j+\\frac{1}{2},k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i,j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{v}_{i,j+1,k}-\\overline{v}_{i,j,k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i,j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{w}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i,j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i,j+\\frac{1}{2},k} = S_{21,i,j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i,j+1,k}-\\overline{u}_{i,j,k}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{v}_{i-\\frac{1}{2},j+\\frac{1}{2},k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i,j+\\frac{1}{2},k} = S_{32,i,j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i,j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i,j+1,k}-\\overline{w}_{i,j,k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i,j+\\frac{1}{2},k} = S_{13,i,j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j+\\frac{1}{2},k}-\\overline{w}_{i-\\frac{1}{2},j+\\frac{1}{2},k}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{u}_{i,j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n  \\item $x$ edge center ($i,j+\\frac{1}{2},k+\\frac{1}{2}$)\r\n    \\begin{align}\r\n      S_{11,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{u}_{i-\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{v}_{i,j+1,k+\\frac{1}{2}}-\\overline{v}_{i,j,k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{w}_{i,j+\\frac{1}{2},k+1}-\\overline{v}_{i,j+\\frac{1}{2},k}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i,j+\\frac{1}{2},k+\\frac{1}{2}} = S_{21,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i,j+1,k+\\frac{1}{2}}-\\overline{u}_{i,j,k+\\frac{1}{2}}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i-\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i,j+\\frac{1}{2},k+\\frac{1}{2}} = S_{32,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i,j+\\frac{1}{2},k+1}-\\overline{v}_{i,j+\\frac{1}{2},k}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i,j+1,k+\\frac{1}{2}}-\\overline{w}_{i,j,k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i,j+\\frac{1}{2},k+\\frac{1}{2}} = S_{13,i,j+\\frac{1}{2},k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{w}_{i-\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i,j+\\frac{1}{2},k+1}-\\overline{u}_{i,j+\\frac{1}{2},k}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n  \\item $y$ edge center ($i+\\frac{1}{2},j,k+\\frac{1}{2}$)\r\n    \\begin{align}\r\n      S_{11,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+1,j,k+\\frac{1}{2}}-\\overline{u}_{i,j,k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i+\\frac{1}{2},j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j,k+1}-\\overline{v}_{i+\\frac{1}{2},j,k}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i+\\frac{1}{2},j,k+\\frac{1}{2}} = S_{21,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{u}_{i+\\frac{1}{2},j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+1,j,k+\\frac{1}{2}}-\\overline{v}_{i,j,k+\\frac{1}{2}}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i+\\frac{1}{2},j,k+\\frac{1}{2}} = S_{32,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j,k+1}-\\overline{v}_{i+\\frac{1}{2},j,k}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{w}_{i+\\frac{1}{2},j-\\frac{1}{2},k+\\frac{1}{2}}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i+\\frac{1}{2},j,k+\\frac{1}{2}} = S_{13,i+\\frac{1}{2},j,k+\\frac{1}{2}} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+1,j,k+\\frac{1}{2}}-\\overline{w}_{i,j,k+\\frac{1}{2}}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i+\\frac{1}{2},j,k+1}-\\overline{u}_{i+\\frac{1}{2},j,k}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\r\n  \\item $z$ edge center ($i+\\frac{1}{2},j+\\frac{1}{2},k$)\r\n    \\begin{align}\r\n      S_{11,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{u}_{i+1,j+\\frac{1}{2},k}-\\overline{u}_{i,j+\\frac{1}{2},k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{22,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j+1,k}-\\overline{v}_{i+\\frac{1}{2},j,k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{33,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\left\\{\r\n      \\frac{\\overline{w}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}, \\\\\r\n      S_{12,i+\\frac{1}{2},j+\\frac{1}{2},k} = S_{21,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{u}_{i+\\frac{1}{2},j+1,k}-\\overline{u}_{i+\\frac{1}{2},j,k}}{\\Delta y}\r\n     +\\frac{\\overline{v}_{i+1,j+\\frac{1}{2},k}-\\overline{v}_{i,j+\\frac{1}{2},k}}{\\Delta x}\r\n      \\right\\}, \\\\\r\n      S_{23,i+\\frac{1}{2},j+\\frac{1}{2},k} = S_{32,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n     +\\frac{\\overline{w}_{i+\\frac{1}{2},j+1,k}-\\overline{w}_{i+\\frac{1}{2},j,k}}{\\Delta y}\r\n      \\right\\}, \\\\\r\n      S_{31,i+\\frac{1}{2},j+\\frac{1}{2},k} = S_{13,i+\\frac{1}{2},j+\\frac{1}{2},k} &= \\frac{1}{2}\\left\\{\r\n      \\frac{\\overline{w}_{i+1,j+\\frac{1}{2},k}-\\overline{w}_{i,j+\\frac{1}{2},k}}{\\Delta x}\r\n     +\\frac{\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}-\\overline{u}_{i+\\frac{1}{2},j+\\frac{1}{2},k-\\frac{1}{2}}}{\\Delta z}\r\n      \\right\\}.\r\n    \\end{align}\r\n\\end{itemize}\r\n\r\n\r\n\\paragraph{velocity}\r\nCalculattion of the strain tensor\r\nrequires value of velocity\r\nat cell center, plane center, edge center, and vertex.\r\nThe velocities at cell center (full-level) are eq.(\\ref{eq:u full}-\\ref{eq:w full}).\r\n\r\n\\begin{itemize}\r\n  \\item $x$-$y$ plane center ($i,j,k+\\frac{1}{2}$)\r\n    \\begin{align}\r\n      \\overline{u}_{i,j,k+\\frac{1}{2}} &=\r\n      \\frac{\\overline{u}_{i,j,k+1}+\\overline{u}_{i,j,k}}{2}, \\\\\r\n      \\overline{v}_{i,j,k+\\frac{1}{2}} &=\r\n      \\frac{\\overline{v}_{i,j,k+1}+\\overline{v}_{i,j,k}}{2}, \\\\\r\n      \\overline{w}_{i,j,k+\\frac{1}{2}} &=\r\n      \\frac{(\\rho w)_{i,j,k+\\frac{1}{2}}}{\\overline{\\rho}_{i,j,k+\\frac{1}{2}}}.\r\n    \\end{align}\r\n\r\n  \\item $y$-$z$ plane center ($i+\\frac{1}{2},j,k$)\r\n    \\begin{align}\r\n      \\overline{u}_{i+\\frac{1}{2},j,k} &=\r\n      \\frac{(\\rho u)_{i+\\frac{1}{2},j,k}}{\\overline{\\rho}_{i+\\frac{1}{2},j,k}}, \\\\\r\n      \\overline{v}_{i+\\frac{1}{2},j,k} &=\r\n      \\frac{\\overline{v}_{i+1,j,k}+\\overline{v}_{i,j,k}}{2}, \\\\\r\n      \\overline{w}_{i+\\frac{1}{2},j,k} &=\r\n      \\frac{\\overline{w}_{i+1,j,k}+\\overline{w}_{i,j,k}}{2}.\r\n    \\end{align}\r\n\r\n  \\item $z$-$x$ plane center ($i,j+\\frac{1}{2},k$)\r\n    \\begin{align}\r\n      \\overline{u}_{i,j+\\frac{1}{2},k} &=\r\n      \\frac{\\overline{u}_{i,j+1,k}+\\overline{u}_{i,j,k}}{2}, \\\\\r\n      \\overline{v}_{i,j+\\frac{1}{2},k} &=\r\n      \\frac{(\\rho v)_{i,j+\\frac{1}{2},k}}{\\overline{\\rho}_{i,j+\\frac{1}{2},k}}, \\\\\r\n      \\overline{w}_{i,j+\\frac{1}{2},k} &=\r\n      \\frac{\\overline{w}_{i,j+1,k}+\\overline{w}_{i,j,k}}{2}.\r\n    \\end{align}\r\n\r\n  \\item $x$ edge center ($i,j+\\frac{1}{2},k+\\half$)\r\n    \\begin{align}\r\n      \\overline{u}_{i,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{u}_{i,j+1,k+1}+\\overline{u}_{i,j+1,k}+\\overline{u}_{i,j,k+1}+\\overline{u}_{i,j,k}}{4}, \\\\\r\n      \\overline{v}_{i,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{v}_{i,j+\\half,k+1}+\\overline{v}_{i,j+\\half,k}}{2}, \\\\\r\n      \\overline{w}_{i,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{w}_{i,j+1,k+\\half}+\\overline{w}_{i,j,k+\\half}}{2}.\r\n    \\end{align}\r\n\r\n  \\item $y$ edge center ($i+\\half,j,k+\\half$)\r\n    \\begin{align}\r\n      \\overline{u}_{i+\\half,j,k+\\half} &=\r\n      \\frac{\\overline{u}_{i+\\half,j,k+1}+\\overline{u}_{i+\\half,j,k}}{2}, \\\\\r\n      \\overline{v}_{i+\\half,j,k+\\half} &=\r\n      \\frac{\\overline{v}_{i+1,j,k+1}+\\overline{v}_{i+1,j,k}+\\overline{v}_{i,j,k+1}+\\overline{v}_{i,j,k}}{4}, \\\\\r\n      \\overline{w}_{i+\\half,j,k+\\half} &=\r\n      \\frac{\\overline{w}_{i+1,j,k+\\half}+\\overline{w}_{i,j,k+\\half}}{2}.\r\n    \\end{align}\r\n\r\n  \\item $z$ edge center ($i+\\half,j+\\half,k$)\r\n    \\begin{align}\r\n      \\overline{u}_{i+\\half,j+\\half,k} &=\r\n      \\frac{\\overline{u}_{i+\\half,j+1,k}+\\overline{u}_{i+\\half,j,k}}{2}, \\\\\r\n      \\overline{v}_{i+\\half,j+\\half,k} &=\r\n      \\frac{\\overline{v}_{i+1,j+\\half,k}+\\overline{v}_{i,j+\\half,k}}{2}, \\\\\r\n      \\overline{w}_{i+\\half,j+\\half,k} &=\r\n      \\frac{\\overline{w}_{i+1,j+1,k}+\\overline{w}_{i+1,j,k}+\\overline{w}_{i,j+1,k}+\\overline{w}_{i,j,k}}{4}.\r\n    \\end{align}\r\n\r\n  \\item vertex ($i+\\half,j+\\half,k+\\half$)\r\n    \\begin{align}\r\n      \\overline{u}_{i+\\half,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{u}_{i+\\half,j+1,k+1}+\\overline{u}_{i+\\half,j+1,k}+\\overline{u}_{i+\\half,j,k+1}+\\overline{u}_{i+\\half,j,k}}{4}, \\\\\r\n      \\overline{v}_{i+\\half,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{v}_{i+1,j+\\half,k+1}+\\overline{v}_{i+1,j+\\half,k}+\\overline{v}_{i,j+\\half,k+1}+\\overline{v}_{i,j+\\half,k}}{4}, \\\\\r\n      \\overline{w}_{i+\\half,j+\\half,k+\\half} &=\r\n      \\frac{\\overline{w}_{i+1,j+1,k+\\half}+\\overline{w}_{i+1,j,k+\\half}+\\overline{w}_{i,j+1,k+\\half}+\\overline{w}_{i,j,k+\\half}}{4}.\r\n    \\end{align}\r\n\\end{itemize}\r\n\r\n\r\n\\paragraph{Brunt-Visala frequency}\r\nThe Brunt-Visala frequency, $N^2$ is required to calculate the Richardson number\r\nat cell center and edge center for the momentum equations,\r\nand plane center for the thermal equation.\r\n\r\n\\begin{itemize}\r\n  \\item cell center ($i,j,k$)\r\n    \\begin{equation}\r\n      N^2_{i,j,k} = \\frac{g}{\\theta_{i,j,k}}\r\n      \\frac{\\theta_{i,j,k+1}-\\theta_{i,j,k-1}}{2\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $x$-$y$ plane center ($i,j,k+\\half$)\r\n    \\begin{equation}\r\n      N^2_{i,j,k+\\half} = \\frac{2g}{\\theta_{i,j,k+1}+\\theta_{i,j,k}}\r\n      \\frac{\\theta_{i,j,k+1}-\\theta_{i,j,k}}{\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $y$-$z$ plane center ($i+\\half,j,k$)\r\n    \\begin{equation}\r\n      N^2_{i+\\half,j,k} = \\frac{2g}{\\theta_{i+1,j,k}+\\theta_{i,j,k}}\r\n      \\frac{(\\theta_{i+1,j,k+1}+\\theta_{i,j,k+1})-(\\theta_{i+1,j,k-1}+\\theta_{i,j,k-1})}{4\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $z$-$x$ plane center ($i,j+\\half,k$)\r\n    \\begin{equation}\r\n      N^2_{i,j+\\half,k} = \\frac{2g}{\\theta_{i,j+1,k}+\\theta_{i,j,k}}\r\n      \\frac{(\\theta_{i,j+1,k+1}+\\theta_{i,j,k+1})-(\\theta_{i,j+1,k-1}+\\theta_{i,j,k-1})}{4\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $x$ edge center ($i,j+\\half,k+\\half$)\r\n    \\begin{equation}\r\n      N^2_{i,j+\\half,k+\\half} = \\frac{4g}{\\theta_{i,j+1,k+1}+\\theta_{i,j+1,k}+\\theta_{i,j,k+1}+\\theta_{i,j,k}}\r\n      \\frac{(\\theta_{i,j+1,k+1}+\\theta_{i,j,k+1})-(\\theta_{i,j+1,k}+\\theta_{i,j,k})}{2\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $y$ edge center ($i+\\half,j,k+\\half$)\r\n    \\begin{equation}\r\n      N^2_{i+\\half,j,k+\\half} = \\frac{4g}{\\theta_{i+1,j,k+1}+\\theta_{i+1,j,k}+\\theta_{i,j,k+1}+\\theta_{i,j,k}}\r\n      \\frac{(\\theta_{i+1,j,k+1}+\\theta_{i,j,k+1})-(\\theta_{i+1,j,k}+\\theta_{i,j,k})}{2\\Delta z}.\r\n    \\end{equation}\r\n\r\n  \\item $z$ edge center ($i+\\half,j+\\half,k$)\r\n    \\begin{equation}\r\n      N^2_{i+\\half,j+\\half,k} = \\frac{4g}{\\theta_{i+1,j+1,k}+\\theta_{i+1,j,k}+\\theta_{i,j+1,k}+\\theta_{i,j,k}}\r\n      \\frac{(\\theta_{i+1,j+1,k+1}+\\theta_{i+1,j,k+1}+\\theta_{i,j+1,k+1}+\\theta_{i,j,k+1})-(\\theta_{i+1,j+1,k-1}+\\theta_{i+1,j,k-1}+\\theta_{i,j+1,k-1}+\\theta_{i,j,k-1})}{8\\Delta z}.\r\n    \\end{equation}\r\n\r\n\r\n\\end{itemize}\r\n\r\n%\\end{document}\r\n", "meta": {"hexsha": "b158562af9ca550e0b525b8345c2026218f64478", "size": 29536, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "scalelib/doc/descriptions/turbulence.tex", "max_stars_repo_name": "Shima-Lab/SCALE-SDM_BOMEX_Sato2018", "max_stars_repo_head_hexsha": "6d7f66f36d00b64df0b93088eba8fe38a1bb1926", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:06:44.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-08T16:06:44.000Z", "max_issues_repo_path": "scalelib/doc/descriptions/turbulence.tex", "max_issues_repo_name": "Shima-Lab/SCALE-SDM_BOMEX_Sato2018", "max_issues_repo_head_hexsha": "6d7f66f36d00b64df0b93088eba8fe38a1bb1926", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scalelib/doc/descriptions/turbulence.tex", "max_forks_repo_name": "Shima-Lab/SCALE-SDM_BOMEX_Sato2018", "max_forks_repo_head_hexsha": "6d7f66f36d00b64df0b93088eba8fe38a1bb1926", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-01-07T16:28:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-07T16:28:49.000Z", "avg_line_length": 49.3913043478, "max_line_length": 219, "alphanum_fraction": 0.5637865655, "num_tokens": 12171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.795658090372256, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4442373901161654}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n\n\\subsection*{dynamics\\_unicycle.m} \n\n\\begin{par}\n\\textbf{Summary:} Implements ths ODE for simulating the cart-pole dynamics.\n\\end{par} \\vspace{1em}\n\n\\begin{verbatim}  function dz = dz = dynamics_unicycle(t, z, V, U)\\end{verbatim}\n    \\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\n\\begin{lstlisting}\n%\t\tt     current time step (called from ODE solver)\n%   z     state                                                    [12 x 1]\n%   V     torque applied to the flywheel\n%   U     torque applied to the wheel\n%\n% *Output arguments:*\n%\n%   dz    state derivative wrt time\n%\n%\n% Note: It is assumed that the state variables are of the following order:\n% state: z = [dtheta, dphi, dpsiw, dpsif, dspit,\n%             x,  y,  theta,  phi,  psiw,  psif,  psit]\n%\n%   theta: tilt of the unicycle\n%   phi: orientation of the unicycle\n%   psiw: angle of wheel (rotation)\n%   psif: angle of fork\n%   psit: angle of turntable (rotation)\n%\n%       dtheta   angular velocity of tilt of the unicycle\n%       dphi     angular velocity of orientation of the unicycle\n%       dpsiw    angular velocity of wheel\n%       dpsif    angular velocity of fork\n%       dpsit    angular velocity of turntable\n%       x        x-position of contact point in plane\n%       y        y-position of contact point in plane\n%       theta    tilt of the unicycle\n%       phi      orientation of the unicycle\n%       psiw     angle of wheel (rotation)\n%       psif     angle of fork\n%       psit     angle of turntable (rotation)\n%\n%\n% Copyright (C) 2008-2013 by\n% Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen,\n% based on derivations by David Forster\n%\n% Last modified: 2013-03-18\n\nfunction dz = dynamics_unicycle(t, z, V, U)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\nT = 0; % no friction\n\ndtheta = z(1); dphi = z(2); dpsiw = z(3); dpsif = z(4); dpsit = z(5); x = z(6);\ny = z(7); theta = z(8); phi = z(9); psiw = z(10); psif = z(11); psit = z(12);\n\nclear psit psiw   % dynamics can't possibly depend on these\n\n% plant characteristics\n\nmt = 10.0;   % turntable mass\nmw =  1.0;   % wheel mass\nmf = 23.5;   % frame mass\nrw =  0.225; % wheel radius\nrf =  0.54;  % frame center of mass to wheel\nrt =  0.27;  % frame centre of mass to turntable\nr =  rf+rt;  % distance wheel to turntable\nCw = 0.0484; % moment of inertia of wheel around axle\nAw = 0.0242; % moment of inertia of wheel perpendicular to axle\nCf = 0.8292; % moment of inertia of frame\nBf = 0.4608; % moment of inertia of frame\nAf = 0.4248; % moment of inertia of frame\nCt = 0.2;    % moment of inertia of turntable around axle\nAt = 1.3;    % moment of inertia of turntable perpendicular to axle\ng = 9.82;    % acceleration of gravity\n\nst = sin(theta); ct = cos(theta); sf = sin(psif); cf = cos(psif);\n\nA = [                                                                                                                     -Ct*sf                                                                                                                                                                Ct*cf*ct                                                                                                  0                                                 0    Ct;\n                                                                                                                               0                                                                                          Cw*st+At*st-rf*(-mf*(st*rf+cf*st*rw)-mt*(st*r+cf*st*rw))+rt*mt*(st*r+cf*st*rw)                                                                          -cf*rw*(rf*(mf+mt)+rt*mt)                    -Cw-At-rf*(mf*rf+mt*r)-rt*mt*r     0;\n                                            cf*(-Af*sf-Ct*sf)-sf*(-Bf*cf-At*cf+rf*(-mf*(cf*rf+rw)-mt*(cf*r+rw))-rt*mt*(cf*r+rw))                                                                         Aw*ct+cf*(Af*cf*ct+Ct*cf*ct)-sf*(-Bf*sf*ct-At*sf*ct+rf*(-mf*sf*ct*rf-mt*sf*ct*r)-rt*mt*sf*ct*r)                                                                                                  0                                                 0 Ct*cf;\n  -Aw-rw*(mf*(cf*rf+rw)+mw*rw+mt*(cf*r+rw))+sf*(-Af*sf-Ct*sf)+cf*(-Bf*cf-At*cf+rf*(-mf*(cf*rf+rw)-mt*(cf*r+rw))-rt*mt*(cf*r+rw))                                                  -rw*(mt*sf*ct*r+mf*sf*ct*rf)+sf*(Af*cf*ct+Ct*cf*ct)+cf*(-Bf*sf*ct-At*sf*ct+rf*(-mf*sf*ct*rf-mt*sf*ct*r)-rt*mt*sf*ct*r)                                                                                                  0                                                 0 Ct*sf;\n                                                                                                                               0 2*Cw*st+At*st-rf*(-mt*(st*r+cf*st*rw)-mf*(st*rf+cf*st*rw))+rt*mt*(st*r+cf*st*rw)+rw*(mw*st*rw+sf*(mf*sf*st*rw+mt*sf*st*rw)+cf*(mt*(st*r+cf*st*rw)+mf*(st*rf+cf*st*rw))) -Cw-rt*mt*cf*rw+rw*(-mw*rw+sf*(-mf*sf*rw-mt*sf*rw)+cf*(-mf*cf*rw-mt*cf*rw))-rf*(mt*cf*rw+mf*cf*rw) -Cw-At-rf*(mf*rf+mt*r)-rt*mt*r-rw*cf*(mf*rf+mt*r)      0 ];\n\nb = zeros(5,1);\nb(1) = -V(t)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta);\nb(2) = -U(t)+Cw*dphi*ct*dtheta-(-dphi*cf*ct+sf*dtheta)*Bf*(dphi*sf*ct+cf*dtheta)+(dphi*sf*ct+cf*dtheta)*Af*(-dphi*cf*ct+sf*dtheta)+At*dphi*ct*dtheta-(dphi*sf*ct+cf*dtheta)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+(dphi*cf*ct-sf*dtheta)*At*(dphi*sf*ct+cf*dtheta)-rf*(-mf*g*sf*ct-mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw)-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))-rt*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))));\nb(3) = -T*ct-2*dphi*st*Aw*dtheta-dtheta*Cw*(-dphi*st+dpsiw)+cf*(-Af*(dphi*sf*dpsif*ct+dphi*cf*st*dtheta+cf*dpsif*dtheta)-(dphi*sf*ct+cf*dtheta)*Cf*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Bf*(dphi*sf*ct+cf*dtheta)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta))-sf*(-Bf*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(-dphi*st+dpsif)*Af*(-dphi*cf*ct+sf*dtheta)+(-dphi*cf*ct+sf*dtheta)*Cf*(-dphi*st+dpsif)-At*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(dphi*cf*ct-sf*dtheta)*At*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+rf*(mf*g*st-mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))+mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+rt*(mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw)));\nb(4) = -dphi^2*st*Aw*ct-dphi*ct*Cw*(-dphi*st+dpsiw)-rw*(mw*dphi*ct*(-dphi*st+dpsiw)*rw-mt*g*st-mw*g*st+mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))-mf*g*st+mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+sf*(-Af*(dphi*sf*dpsif*ct+dphi*cf*st*dtheta+cf*dpsif*dtheta)-(dphi*sf*ct+cf*dtheta)*Cf*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Bf*(dphi*sf*ct+cf*dtheta)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta))+cf*(-Bf*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(-dphi*st+dpsif)*Af*(-dphi*cf*ct+sf*dtheta)+(-dphi*cf*ct+sf*dtheta)*Cf*(-dphi*st+dpsif)-At*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(dphi*cf*ct-sf*dtheta)*At*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+rf*(mf*g*st-mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))+mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+rt*(mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw)));\nb(5) = -T*st+2*Cw*dphi*ct*dtheta+(dphi*sf*ct+cf*dtheta)*Af*(-dphi*cf*ct+sf*dtheta)-rt*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))-(dphi*sf*ct+cf*dtheta)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+At*dphi*ct*dtheta+rw*(2*mw*rw*dphi*ct*dtheta+sf*(mf*(-cf*dpsif*(-dphi*st+dpsiw)*rw+sf*dphi*ct*dtheta*rw+(dphi*sf*ct+cf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)-(-dphi*st+dpsif)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))-mf*g*cf*ct-mt*g*cf*ct-mt*(cf*dpsif*(-dphi*st+dpsiw)*rw-sf*dphi*ct*dtheta*rw+(-dphi*st+dpsif)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))-(dphi*sf*ct+cf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))+cf*(mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw)+mt*g*sf*ct+mf*g*sf*ct+mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt)))))+(dphi*cf*ct-sf*dtheta)*At*(dphi*sf*ct+cf*dtheta)-rf*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt)))-mf*g*sf*ct-mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw))-(-dphi*cf*ct+sf*dtheta)*Bf*(dphi*sf*ct+cf*dtheta);\n\ndz = zeros(12,1);\ndz(1:5) = -A\\b;\ndz(6) = rw*cos(phi)*dpsiw;\ndz(7) = rw*sin(phi)*dpsiw;\ndz(8:12) = z(1:5);\n\\end{lstlisting}\n", "meta": {"hexsha": "f13597ba7852aaa8a6704167c7a4fa9817e7f41f", "size": 10611, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/dynamics_unicycle.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/dynamics_unicycle.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/dynamics_unicycle.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 91.474137931, "max_line_length": 1653, "alphanum_fraction": 0.5671473, "num_tokens": 4231, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300048, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.44423737322383694}}
{"text": "\n\\section{Checking Summaries}\\label{sec:checking-summary}\n\nHere we explain how $\\textmd{CheckSummary} (\\prog{P}_k, S[\\bullet])$ is achieved,\nwhere $\\prog{P}_k$ is an unwound program and $S[\\bullet]$ is an array of\nfunction summaries.\nLet $G^\\fun{f}_k = \\langle V, E, \\cmd{cmd}^\\fun{f}, \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ be a\ncontrol flow graph for the function $\\fun{f}$ in $\\prog{P}_k$. In order to check whether the function\nsummary $S[{\\fun{f}}]$ for $\\fun{f}$ specifies the relation\nbetween the formal parameters and return values of $\\fun{f}$,\nwe define another control flow graph\n$\\hat{G}^\\fun{f}_{k,S} = \\langle V, E, \\hat{\\cmd{cmd}}^\\fun{f}, \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ where\n\\begin{equation*}\n  \\begin{array}{rcl}\n    \\hat{\\cmd{cmd}}^\\fun{f} (\\ell, \\ell') & = &\n    \\left\\{\n      \\begin{array}{ll}\n        \\overline{\\mathtt{x}} := \\overline{\\mathtt{nondet}}; & \\\\[-8pt]\n\n        \\mathtt{assume\\ }S[{\\fun{g}}][\n          \\overline{\\mathtt{u}}^\\fun{g} \\mapsto \\overline{p},\n          \\overline{\\mathtt{r}}^\\fun{g} \\mapsto \\overline{\\mathtt{x}}]\n        & \\text{ if } \\cmd{cmd}^\\fun{f} (\\ell, \\ell') =\n          \\overline{\\mathtt{x}} := \\fun{g} (\\overline{p}) \\\\\n\n        \\overline{\\mathtt{r}}^\\fun{f} := \\overline{q}\n        & \\text{ if } \\cmd{cmd}^\\fun{f} (\\ell, \\ell') =\n          \\mathtt{return\\ }\\overline{q} \\\\\n\n        \\cmd{cmd}^\\fun{f} (\\ell, \\ell')\n        & \\text{ otherwise}\n      \\end{array}\n    \\right.\n  \\end{array}\n\\end{equation*}\n\n\\begin{figure}[t]\n  \\centering\n    \\begin{tikzpicture}[scale=1.2,->,>=stealth',shorten >=1pt,auto,node\n      distance=2cm,thick,node/.style={circle,draw,minimum width=0.8cm,inner sep=0}]\n\n      \\node[node] (00) at (0, 0)  {$\\ell$};\n      \\node[node] (01) at (0, -2) {$\\ell'$};\n\n      \\node (arrow_s0) at ( .3, -1) {};\n      \\node (arrow_e0) at (1.3, -1) {};\n\n      \\node[node] (10) at (1.6, 0)  {$\\ell$};\n      \\node[node] (11) at (1.6, -2) {$\\ell'$};\n\n      \\node[node] (20) at (7.4, 0)  {$\\ell$};\n      \\node[node] (21) at (7.4, -2) {$\\ell'$};\n\n      \\node (arrow_s1) at (7.8, -1) {};\n      \\node (arrow_e1) at (8.7, -1) {};\n\n      \\node[node] (30) at (9, 0)  {$\\ell$};\n      \\node[node] (31) at (9, -2) {$\\ell'$};\n\n      \n      \\path\n        (00) edge [left]\n             node {$\\overline{\\mathtt{x}} := \\fun{g}(\\overline{p})$} (01)\n\n        (arrow_s0) edge [dotted]\n                  node {} (arrow_e0)\n\n        (10) edge\n             node {\\small$\n               \\begin{array}{l}\n                 \\overline{\\mathtt{x}} := \\overline{\\mathtt{nondet}};\\\\\n                 \\mathtt{assume\\ }S[\\fun{g}]\n                 [\\overline{\\mathtt{u}}^\\fun{g} \\mapsto \\overline{p},\n                  \\overline{\\mathtt{r}}^\\fun{g} \\mapsto \\overline{\\mathtt{x}}]\n               \\end{array}\n             $} (11)\n\n        (20) edge [left]\n             node {$\\mathtt{return\\ } \\overline{q}$} (21) \n\n        (arrow_s1) edge [dotted]\n                  node {} (arrow_e1)\n\n        (30) edge \n             node {$\\overline{\\mathtt{r}}^\\fun{g} := \\overline{q}$} (31)\n             ;\n    \\end{tikzpicture}\n\n  \\caption{Instantiating a Summary}\n  \\label{figure:instantiating-summary}\n\\end{figure}\n\nThe control flow graph $\\hat{G}^{\\fun{f}}_{k,S}$ replaces every\nfunction call in $G_k^\\fun{f}$ by instantiating a function\nsummary (Figure~\\ref{figure:instantiating-summary}).\nUsing the Hoare Logic proof rule for recursive functions~\\cite{Oheimb99}, we have the\nfollowing proposition:\n\\begin{proposition}\n  \\label{proposition:check_summary}\n  Let $G^\\fun{f}_k = \\langle V, E, \\cmd{cmd}^\\fun{f}, \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ be the control flow graph for the function\n  $\\fun{f}$ and $S[\\bullet]$ be an array of logic formulae over the formal\n  parameters and return variables of each function. If $\\assert{\\TT}\\\n  \\hat{G}^\\fun{g}_{k,S}\\ \\assert{S[\\fun{g}]}$ for every\n  function $\\fun{g}$ in $\\prog{P}$, then $\\assert{\\TT}\\ \\overline{\\mathtt{r}}^\\fun{f} :=\n  \\fun{f} (\\overline{\\mathtt{u}}^\\fun{f})\\ \\assert{S[\\fun{f}]}$.\n\\end{proposition}\n\nIt is easy to check $\\assert{\\TT}\\ \\hat{G}^\\fun{g}_{k,S}\\\n\\assert{S[\\fun{g}]}$ by program analysis. Let $G_k^{\\fun{f}}$ be\nthe control flow graph for the function $\\fun{f}$ and\n$\\hat{G}^\\fun{g}_{k,S} = \\langle V, E, \\hat{\\cmd{cmd}}^\\fun{f}, \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ as\nabove. Consider another control flow graph $\\tilde{G}^\\fun{f}_{k,S} =\n\\langle \\tilde{V}, \\tilde{E}, \\tilde{\\cmd{cmd}}^\\fun{f} , \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ where\n\\begin{equation*}\n  \\begin{array}{rcl}\n    \\tilde{V} & = & V \\cup \\{ \\tilde{e} \\}\\\\\n    \\tilde{E} & = & E \\cup \\{ (e, \\tilde{e}) \\}\\\\\n    \\tilde{\\cmd{cmd}}^\\fun{f} (\\ell, \\ell') & = &\n    \\left\\{\n      \\begin{array}{ll}\n        \\hat{\\cmd{cmd}}^\\fun{f} (\\ell, \\ell') &\n        \\text{ if } (\\ell, \\ell') \\in E\\\\\n        \\mathtt{assert\\ } S[\\fun{f}] &\n        \\text{ if } (\\ell, \\ell') = (e, \\tilde{e})\n      \\end{array}\n    \\right.\n  \\end{array}\n\\end{equation*}\n\n\\pagebreak\n\\begin{corollary}\n  Let $G^\\fun{f}_k = \\langle V, E, \\cmd{cmd}^\\fun{f}, \\overline{\\mathtt{u}}^\\fun{f}, \\overline{\\mathtt{r}}^\\fun{f},s,e \\rangle$ be the control flow graph for the function\n  $\\fun{f}$ and $S[\\bullet]$ be an array of logic formulae over the formal\n  parameters and return variables of each function. If $\\method{BasicAnalyzer}\n  (\\tilde{G}^\\fun{g}_{k,S})$ returns $\\mathit{Pass}$ for every function\n  $\\fun{g}$ in \\prog{P}, then $\\assert{\\TT}\\ \\overline{\\mathtt{r}}^\\fun{f} :=\n  \\fun{f} (\\overline{\\mathtt{u}}^\\fun{f})\\ \\assert{S[\\fun{f}]}$.\n  \\label{corollary:check-summary}\n\\end{corollary}\n\n\\begin{algorithm}[t]\n\\begin{doublespace}\n  \\KwIn{$\\prog{P}_k$ : an unwound program; $S[\\bullet]$ : an array of function summaries}\n  \\KwOut{$\\TT$ if all function summaries are valid; $\\FF$ otherwise}\n  \\ForEach{function $G_k^\\fun{f} \\in \\prog{P}_k$}\n  {\n    \\If{$\\method{BasicAnalyzer} (\\tilde{G}_{k,S}^{\\fun{f}}) \\neq\n      \\mathit{Pass}$}\n    {\n      \\Return $\\FF$\n    }\n  }\n  \\Return $\\TT$\\;\n\\end{doublespace}\n  \\caption{$\\textmd{CheckSummary} (\\prog{P}_k, S)$}\n  \\label{algorithm:check-summary}\n\\end{algorithm}\n", "meta": {"hexsha": "b12afb4ece41ae446a0fa6c72b3969595dcdb561", "size": 6222, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/document/tex/chap-proving/sec-checking_summary.tex", "max_stars_repo_name": "hc825b/homeworks", "max_stars_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-02T02:05:22.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-02T02:05:22.000Z", "max_issues_repo_path": "Thesis/document/tex/chap-proving/sec-checking_summary.tex", "max_issues_repo_name": "hc825b/homeworks", "max_issues_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/document/tex/chap-proving/sec-checking_summary.tex", "max_forks_repo_name": "hc825b/homeworks", "max_forks_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-02-22T00:44:03.000Z", "max_forks_repo_forks_event_max_datetime": "2018-02-22T00:44:03.000Z", "avg_line_length": 39.3797468354, "max_line_length": 170, "alphanum_fraction": 0.5649308904, "num_tokens": 2318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4442373661026417}}
{"text": "\\documentclass[landscape,twocolumn,letterpaper,9pt,reqno]{article}\\usepackage[]{graphicx}\\usepackage[]{color}\n%% maxwidth is the original width if it is less than linewidth\n%% otherwise use linewidth (to make sure the graphics do not exceed the margin)\n\\makeatletter\n\\def\\maxwidth{ %\n  \\ifdim\\Gin@nat@width>\\linewidth\n    \\linewidth\n  \\else\n    \\Gin@nat@width\n  \\fi\n}\n\\makeatother\n\n\\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}\n\\newcommand{\\hlnum}[1]{\\textcolor[rgb]{0.686,0.059,0.569}{#1}}%\n\\newcommand{\\hlstr}[1]{\\textcolor[rgb]{0.192,0.494,0.8}{#1}}%\n\\newcommand{\\hlcom}[1]{\\textcolor[rgb]{0.678,0.584,0.686}{\\textit{#1}}}%\n\\newcommand{\\hlopt}[1]{\\textcolor[rgb]{0,0,0}{#1}}%\n\\newcommand{\\hlstd}[1]{\\textcolor[rgb]{0.345,0.345,0.345}{#1}}%\n\\newcommand{\\hlkwa}[1]{\\textcolor[rgb]{0.161,0.373,0.58}{\\textbf{#1}}}%\n\\newcommand{\\hlkwb}[1]{\\textcolor[rgb]{0.69,0.353,0.396}{#1}}%\n\\newcommand{\\hlkwc}[1]{\\textcolor[rgb]{0.333,0.667,0.333}{#1}}%\n\\newcommand{\\hlkwd}[1]{\\textcolor[rgb]{0.737,0.353,0.396}{\\textbf{#1}}}%\n\\let\\hlipl\\hlkwb\n\n\\usepackage{framed}\n\\makeatletter\n\\newenvironment{kframe}{%\n \\def\\at@end@of@kframe{}%\n \\ifinner\\ifhmode%\n  \\def\\at@end@of@kframe{\\end{minipage}}%\n  \\begin{minipage}{\\columnwidth}%\n \\fi\\fi%\n \\def\\FrameCommand##1{\\hskip\\@totalleftmargin \\hskip-\\fboxsep\n \\colorbox{shadecolor}{##1}\\hskip-\\fboxsep\n     % There is no \\\\@totalrightmargin, so:\n     \\hskip-\\linewidth \\hskip-\\@totalleftmargin \\hskip\\columnwidth}%\n \\MakeFramed {\\advance\\hsize-\\width\n   \\@totalleftmargin\\z@ \\linewidth\\hsize\n   \\@setminipage}}%\n {\\par\\unskip\\endMakeFramed%\n \\at@end@of@kframe}\n\\makeatother\n\n\\definecolor{shadecolor}{rgb}{.97, .97, .97}\n\\definecolor{messagecolor}{rgb}{0, 0, 0}\n\\definecolor{warningcolor}{rgb}{1, 0, 1}\n\\definecolor{errorcolor}{rgb}{1, 0, 0}\n\\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX\n\n\\usepackage{alltt}\n\n\\usepackage{lscape,fancyhdr}\n\n\\usepackage{hyperref}\n\n\\pagestyle{fancy}\n\n\\usepackage{amsmath,epsfig,subfigure,amsthm,amsfonts,epsf,psfrag,rotating,setspace,bm}\n\n\\usepackage{verbatim,color} % Allow text colors}\n\n\\setlength{\\oddsidemargin}{-0.4in}\t\t% default=0in\n\\setlength\\evensidemargin{-0.4in}\n\n\\setlength{\\textwidth}{9.8in}\t\t% default=9in\n\n\\setlength{\\columnsep}{0.5in}\t\t% default=10pt\n\n\\setlength{\\columnseprule}{0pt}\t\t% default=0pt (no line)\n\n\n\\setlength{\\textheight}{7.0in}\t\t% default=5.15in\n\n\\setlength{\\topmargin}{-0.75in}\t\t% default=0.20in\n\n\\setlength{\\headsep}{0.25in}\t\t% default=0.35in\n\n\\setlength{\\parskip}{1.2ex}\n\n\\setlength{\\parindent}{0mm}\n\n\\lhead{Course EPIB607: Regression handout 004 (Poisson regression)}\n\\rhead{jh,sb \\ \\ \\ v. 2018.11.15}\n\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}\n\\begin{document}\n\t\n\n\n\\section{Malaria control with bednets}\n\nSee the 2018 Lancet article \\textit{Efficacy of Olyset Duo, a bednet containing pyriproxyfen and permethrin, versus a permethrin-only net against clinical malaria in an area with highly pyrethroid-resistant vectors in rural Burkina Faso: a cluster-randomised\n\tcontrolled trial} (\\texttt{Bednets.pdf} in \\texttt{A9} folder of myCourses) by Tiono et. al. Reproduce the Rate ratio (95\\% CI) in Table 2. Calculate the rate difference and 95\\% CI comparing PPF-treated to Standard long-lasting insecticidal nets. Check the goodness of fit. \n\n\n\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{verbatim}\n## \n## Call:\n## glm(formula = cases ~ exposure + offset(log(years)), family = poisson(link = log), \n##     data = df)\n## \n## Deviance Residuals: \n##     Min       1Q   Median       3Q      Max  \n## -16.682   -4.732    1.497    3.984   12.024  \n## \n## Coefficients:\n##             Estimate Std. Error z value Pr(>|z|)    \n## (Intercept)  0.68314    0.02432  28.092  < 2e-16 ***\n## exposure    -0.26687    0.03286  -8.121 4.62e-16 ***\n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## (Dispersion parameter for poisson family taken to be 1)\n## \n##     Null deviance: 1381.2  on 23  degrees of freedom\n## Residual deviance: 1316.0  on 22  degrees of freedom\n## AIC: 1476.7\n## \n## Number of Fisher Scoring iterations: 5\n\\end{verbatim}\n\n\\end{knitrout}\n\t\n\n\n\n\n\\clearpage\n\n\n\\section{Population mortality rates in Denmark}\n\\small \n\n\\vspace*{-.1in}\n\nWe can fit the following simple (multiplicative) rate ratio model to the \npatterns of mortality rates  for 1980-1984 and  2000-2004. The reference cell is females 70-74,   1980-84. $R$ = rate. $M$ = multiplier.\n\n\\begin{tabular}{|l c | l l  l  l  | l l l l | l |}\n\t\\hline\n\tYear  & Age & \\multicolumn{3}{c}{Female (F)} & &   \\multicolumn{3}{c}{Male (M)} & \\\\ \n\t\\hline\n\t& 70-74 &  $R_{F}$ & & & & $R_{F}$ & & $\\times M_{M}$  & \\\\\n\t1980- & 75-79 &  $R_{F}$ & $ \\times M_{75}$ & &   & $R_{F}$ & $\\times M_{75}$ & $\\times M_{M}$ & \\\\\n\t1984 & 80-84 & $R_{F}$ & $ \\times M_{80}$ &  & &  $R_{F}$ & $ \\times M_{80}$ & $ \\times M_{M}$ & \\\\\n\t& 85-89 & $R_{F}$ & $ \\times M_{85}$ &  & &  $R_{F}$ & $ \\times M_{85}$ & $ \\times M_{M}$ & \\\\ \n\t\\hline\n\t& 70-74 &  $R_{F}$ &  & & $\\times M_{20y}$  &  $R_{F}$ & & $  \\times M_{M}$  & $\\times M_{20y}$\\\\\n\t2000- & 75-79 &  $R_{F} $ & $\\times M_{75}$ & & $\\times M_{20y}$ &  $R_{F}$ & $ \\times M_{75}$ & $ \\times M_{M}$& $\\times M_{20y}$ \\\\\n\t2004      & 80-84 & $R_{F}$ & $ \\times M_{80}$ & & $\\times M_{20y}$ &   $R_{F}$ & $ \\times M_{80}$ & $ \\times M_{M}$ & $\\times M_{20y}$ \\\\\n\t& 85-89 & $R_{F}$ & $ \\times M_{85}$ & \\ \\ \\ & $\\times M_{20y}$&   $R_{F}$ & $\\times M_{85}$ & $\\times M_{M}$ & $\\times M_{20y}$ \\\\\n\t\\hline\n\\end{tabular}\n\n%The array called `r' in the R code ( which fits additive models to the rates and logs of the rates)can be used to calculate ratios.\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{tabular}{l|l|r|r|r|r|r|r}\n\\hline\nYear & Age & Female\\_deaths & Female\\_PT & Female\\_rate & Male\\_deaths & Male\\_PT & Male\\_rate\\\\\n\\hline\n1980-1984 & 70-74 & 15989 & 586882.8 & 0.0272439 & 23810 & 456908.21 & 0.0521111\\\\\n\\hline\n1980-1984 & 75-79 & 20838 & 454142.7 & 0.0458843 & 24707 & 300318.92 & 0.0822692\\\\\n\\hline\n1980-1984 & 80-84 & 24073 & 297678.6 & 0.0808691 & 20319 & 167303.51 & 0.1214499\\\\\n\\hline\n1980-1984 & 85-89 & 20216 & 147771.7 & 0.1368057 & 13524 & 74295.83 & 0.1820291\\\\\n\\hline\n2000-2004 & 70-74 & 13912 & 521561.9 & 0.0266737 & 17360 & 436994.92 & 0.0397259\\\\\n\\hline\n2000-2004 & 75-79 & 19731 & 471945.5 & 0.0418078 & 22477 & 341362.82 & 0.0658449\\\\\n\\hline\n2000-2004 & 80-84 & 25541 & 369989.9 & 0.0690316 & 22992 & 217929.72 & 0.1055019\\\\\n\\hline\n2000-2004 & 85-89 & 27135 & 226798.1 & 0.1196439 & 17444 & 104009.58 & 0.1677153\\\\\n\\hline\n2005-2009 & 70-74 & 12179 & 540568.6 & 0.0225300 & 15782 & 472012.84 & 0.0334355\\\\\n\\hline\n2005-2009 & 75-79 & 17273 & 444474.2 & 0.0388616 & 19547 & 344351.34 & 0.0567647\\\\\n\\hline\n2005-2009 & 80-84 & 23513 & 363534.1 & 0.0646789 & 21781 & 230530.24 & 0.0944822\\\\\n\\hline\n2005-2009 & 85-89 & 26842 & 237877.3 & 0.1128397 & 17811 & 114485.04 & 0.1555749\\\\\n\\hline\n\\end{tabular}\n\n\n\\end{knitrout}\n\n%The equation is for the rate in any given age-group in a given gender in a given calendar period:\n\\textcolor{white}{text}\\newline\n\n\\begin{tabular}{c c c c c c c c c}\n\tRate = & $\\rule{1cm}{0.15mm}$ & $\\times \\rule{1cm}{0.15mm}$ & $\\times \\rule{1cm}{0.15mm}$ & $\\times \\rule{1cm}{0.15mm}$ & $\\times \\rule{1cm}{0.15mm}$ & $\\times \\rule{1cm}{0.15mm}$ \\\\\n\t& &   if  &  if &  if & if & if & \\\\\n\t& &  75-79 & 80-84 & 85-89 & male & 2000-04 \\\\  \\\\\n\t$\\log[Rate] =$ & $\\rule{1cm}{0.15mm}$ & $+ \\rule{1cm}{0.15mm}$ & $+ \\rule{1cm}{0.15mm}$ & $+ \\rule{1cm}{0.15mm}$ & $+ \\rule{1cm}{0.15mm}$ & $+ \\rule{1cm}{0.15mm}$ \\\\\n\t& &   if  &  if &  if & if & if & \\\\\n\t& &  75-79 & 80-84 & 85-89 & male & 2000-04 \\\\ \\\\\n\t\n\t$\\log[Rate] =$ &$\\rule{1cm}{0.15mm}$& $+  \\rule{1cm}{0.15mm}$ & $+   \\rule{1cm}{0.15mm}$ & $+   \\rule{1cm}{0.15mm}$ & $+   \\rule{1cm}{0.15mm} $ & $+ \\rule{1cm}{0.15mm}$ \\\\\n\t& &  $\\times$  &  $\\times$ &  $\\times$ & $\\times$ & $\\times$ & \\\\\n\t& &  $I_{75-79}$ & $I_{80-84}$ & $I_{85-89}$ & $I_{male}$ & $I_{2000-04}$ \\\\\n\\end{tabular}\n\nwhere each $`I'$ is a (0/1) indicator of the category in question. By using both the 0 and 1 values of each $I$, this 6-parameter equation  produces a fitted value for each of the $4\\times2\\times2=16$ cells.\n\n%You can also think of $I_{75-79},$  $I_{80-84},$ and  $I_{85-89}$ as \n%`radio buttons':  at most 1 of them can be `on' at the same time, since there are 4 \n%age levels in all.\n\n\n\t\n\\end{document}\n", "meta": {"hexsha": "8c25b5ec912d668caaad2f1eaa205c85d1f0f281", "size": 8416, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/regression/handouts/EPIB607_handout_004.tex", "max_stars_repo_name": "ly129/EPIB607", "max_stars_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/regression/handouts/EPIB607_handout_004.tex", "max_issues_repo_name": "ly129/EPIB607", "max_issues_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/regression/handouts/EPIB607_handout_004.tex", "max_forks_repo_name": "ly129/EPIB607", "max_forks_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-25T21:19:06.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-25T21:19:06.000Z", "avg_line_length": 38.0814479638, "max_line_length": 276, "alphanum_fraction": 0.6292775665, "num_tokens": 3547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.44423735571410755}}
{"text": "\\newpage\\subsection{Irreducibility}\n\n\\begin{myitemize}\n\\item \\href{https://euclid.ucc.ie/mathenr/IMOTraining/Polynomials2015.pdf}{Summer Camp 2015 Handout}\n\\item \\href{http://yufeizhao.com/olympiad/intpoly.pdf}{Yufei Zhao's Handout}\n\\end{myitemize}\n\n\n\\begin{take_note*}{What can be showed to prove Irreducibility}\n    \\begin{itemize}[wide=5pt]\n        \\item Writing $ f = g\\cdot h $ and equating coefficients\n        \\item If the polynomial involves some prime, it's often useful to try factoring modulo that prime\n        \\item If the last coefficient is a prime, then there are some obvious bounds on the roots\n        \\item If there are bounds on the coefficients, then try root bounding\n    \\end{itemize}\n\\end{take_note*}\n\n\\bigskip \n\n\\begin{minipage}[t]{.48\\linewidth}\n    \\lem{Bounds On Roots}{$ P $ is a monic polynomial. Suppose $ P(0)\\neq0 $ and at most one complex root of $ P $ has absolute value at least $ 1 $. Then $ P $ is irreducible.\\label{lemma:root_irred_1}}\n\\end{minipage}\\hfill%\n\\begin{minipage}[t]{.48\\linewidth}\n    \\lem{}{$ P $ is a monic polynomial. Suppose that $ |P(0)| $ is prime, and all complex roots of $ P $ have absolute value greater than $ 1 $. Then $ P $ is irreducible.\\label{lemma:root_irred_2}}\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}[t]{.48\\linewidth}\n    \\lem{Leading Coefficient is LARGE}{Let $ P(x) = b_nx^n + b_{n-1}x^{n-1} + \\dots + b_1x + b_0 $ such that\n        \\[|b_n| > |b_{n-1}| + |b_{n-2}| + \\dots + |b_0|\\]\n        Then every root $ \\alpha $ of $ P $ is \\textbf{strictly inside of the unit circle}, i.e. $ |\\alpha| < 1 $.\\\\\n\n    i.e. If the first coefficient of the polynomial is very large, then all of the roots lie inside the unit circle.}\n\\end{minipage}\\hfill%\n\\begin{minipage}[t]{.48\\linewidth}\n    \\lem{Coefficients form a Decreasing Sequence}{Let $ P(x) = a_nx^n + a_{n-1}x^{n-1} + \\dots + a_1x + a_0 $ be a real polynomial. Such that,\n        \\[a_n\\ge a_{n-1} \\ge \\dots \\ge a_1 \\ge a_0 > 0\\]\n        Then any complex $ z $ of $ P(x) $ satisfies $ |z|\\le 1 $\\\\\n\n    i.e. If the coefficients form a decreasing sequence then all of the roots lie on or inside the unit circle.}\n\\end{minipage}\n\n\\bigskip\n\n\\begin{minipage}[t]{.48\\linewidth}\n    \\lem{Constant is LARGE}{Let $ P(x) = a_nx^n + a_{n-1}x^{n-1} \\dots + a_1x + a_0 $ be a polynomial over integers. Where, $ a_0 $ is a prime, and \n        \\[|a_0| > |a_n| + |a_{n-1}| + \\dots + |a_1|\\]\n    Prove that $ P(x) $ is irreducible.}\n\\end{minipage}\\hfill%\n\\begin{minipage}[t]{.48\\linewidth}\n    \\theo{https://en.wikipedia.org/wiki/Rouche's_theorem}{Rouché's Theorem}{Let $ f,g $ be analytic functions on and inside a simple closed curve $ \\mathcal{C} $. Suppose that \\[ |f(z)| > |g(z)| \\] for all points $ z $ on $ \\mathcal{C} $. Then $ f $ and $ f+g $ have the same number of zeroes (counting multiplicities) interior to $ \\mathcal{C} $}\n\\end{minipage}\n\n\n\n\n\n\n\\theo{https://artofproblemsolving.com/community/c2562h1422017s3_perrons_irreducibility_criterion}{Perron's Criterion}{Let $ P(x) = x^n + a_{n-1}x^{n-1} + a_{n-2}x^{n-2} \\dots a_1x + a_0 $ be a polynomial over integers such that \\[|a_{n-1}| > 1 + |a_{n-2}| + |a_{n-3}| + \\dots + |a_1| + |a_0|\\] Then $ P(x) $ is irreducible.}\n\n\\rem{The crucial idea behind the proof is that $ |a_0|\\ge 1 $, and if the polynomial is reducible, then there are at least two roots $ |z| \\ge 1 $.}\n\n\\begin{prooof}[Bounding Roots]\n    Let $ P(z) = 0 $ for some $ |z|=1, z\\in\\mathbb{C} $. That means we have \n    \\begin{align*}\n        -a_{n-1}z^{n-1} &=  z^n + a_{n-2}z^{n-2} \\dots a_1z + a_0 \\\\\n        \\implies |a_{n-1}| &= |z^n + a_{n-2}z^{n-2} \\dots a_1z + a_0|\\\\\n                           &\\le |1| + |a_{n-2}| \\dots + |a_0|\n    \\end{align*}\n    Which is a contradiction. So $ |z|\\ne 1 $.\\\\\n\n    We know that there exist a root $ z $ that has an absolute value greater than $ 1 $. We prove that there is only one such root of $ P(x) $. \\\\\n\n    First, let $ P(x)=(x-z)Q(x) $, where $ |z|>1 $, and $ Q(x) = x^{n-1} + b_{n-2}x^{n-2} + \\dots + b_1x + b_0 $.\n\n    So we have, \n    \\begin{align*}\n        P(x) &= (x-z)Q(x)\\\\\n        x^n + a_{n-1}x^{n-1} + a_{n-2}x^{n-2} \\dots a_1x + a_0 &= x^n + (b_{n-2} - z)x^{n-1} + \\dots + (b_0-zb_1)x+ zb_0\\\\\n    \\end{align*}%\n    \\begin{align*}\n        \\implies |b_{n-2} - z| &> 1 + |b_{n-3} - zb_{n-2}| + \\dots + |b_0 - zb_1| + |zb_0|\\\\[.5em]\n        |b_{n-2}| + |z| & > 1 - |b_{n-3}| + |z||b_{n-2}| + \\dots |b_0| - |z||b_1| + |z|b_0|\\\\[.5em]\n        |b_{n-2}| + |z| &= (|z|-1)(|b_{n-2}| + |b_{n-3} \\dots |b_0|) + |b_{n-2}| + 1\\\\[.5em]\n        1 &> |b_{n-2}| + |b_{n-3} \\dots |b_0|\n    \\end{align*}\n\n    And by \\autoref{lemma:Leading Coefficient is LARGE}, $ Q(x) $ does not have any root $ |z|>1 $. \n    \\end{prooof}\n\n\n\n    %\t\\theo{}{Hensel's Lemma}{Let $ a_0, a_1, \\dots , a_n $ be integers, and let $ P(x) =a_nx^n+\\dots a_1x+a_0 $, and let $ P'(x) $ denote the derivative of $ P(x) $. Suppose that $ x_1 $ is an integer such that $ P(x_1)\\equiv 0\\ (\\mod\\ p) $ and $ P'(x_1)\\not\\equiv 0\\ (\\mod\\ p) $. Then, for any positive integer $ k $, there exists an unique residue $ x_k\\ (\\mod\\ p^k) $, such that $ P(x_k)\\equiv 0\\ (\\mod\\ p^k) $ and $ x_k\\equiv x_1 \\ (\\mod\\ p)$.}\n\n\n\n    \\theo{}{Perron's Criterion's Generalization (Dominating Term)}{Let $ P(z) = a_nz^n + a_{n-1}z^{n-1} + \\dots + a_1z + a_0 $ be a complex polynomial, such that its $ a_k $ term is dominant, that is,\n        \\[|a_k| > |a_0| + |a_1| + \\dots |a_{k-1}| + |a_{k+1}| +\\dots + |a_{n}|\\]\n    for some $ 0 \\le k \\le n $. Then exactly $ k $ roots of $ P $ lies strictly inside of the unit circle, and the other $ n-k $ roots of $ P $ lies strictly outside of the unit circle.}\n\n\n    \\proof{A direct application of \\autoref{theorem:Rouché's Theorem}.}\n\n    \\newpage\n\n\n    \\lem{Bound on roots}{Let $ f(x) = a_nx^n + a_{n-1}x^{n-1}\\dots + a_1x+a_0 $ be an integer polynomial. Suppose that $ a_n\\ge 1, a_{n-1}\\ge 0 $ and $ a_i\\le H $ for some positive constant $ H $ and $ i = 0, 1, \\dots n-2 $. Then any complex zero $ \\a $ of $ f(x) $ has either \\textit{nonpositive real part}, or satisfies\n    \\[|\\a| < \\frac{1+\\sqrt{1+4H}}{2}\\]}\n\n    \\proof{Suppose $ z $ is a root such that $ |z|>1 $ and $ \\mathrm{Re}\\ z >0 $. Then we have\n        \\begin{align*}\n            \\left|\\frac{f(z)}{z^n}\\right| &\\ge \\left(a_n - \\frac{a_{n-1}}{z}\\right) - H\\left(\\frac{1}{|z|^2} + \\frac{1}{|z|^3} \\dots \\frac{1}{|z|^n}\\right)\\\\[1em]\n                &> \\mathrm{Re\\ }\\left(a_n+\\frac{a_{n-1}}{z}\\right) - \\frac{H}{|z|^2-|z|}\\\\[.5em]\n                &\\ge 1 - \\frac{H}{|z|^2-|z|}\\\\[1em]\n                & = \\frac{|z|^2-|z| - H}{|z|^2-|z|}\\\\[.2em]\n                & \\ge 0\n            \\end{align*}\n            Whenever \\[|z| \\ge \\frac{1+\\sqrt{1+4H}}{2}\\]\n        }\n\n\n        \\theo{https://en.wikipedia.org/wiki/Cohn's_irreducibility_criterion}{Cohn's Criterion}{Suppose $ p $ is a prime number, expressed as $ \\overline{p_np_{n-1}\\dots p_1p_0} $ in base $ b\\ge 2 $. Then the polynomial\n            \\[f(x) = p_nx^n + p_{n-1}x^{n-1} \\dots +p_1x + p_0\\]\n        is irreducible.}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        \\prob{https://artofproblemsolving.com/community/c6h82906p475370}{ISL 2005 A1}{E}{Find all pairs of integers $a,b$ for which there exists a polynomial $P(x) \\in \\mathbb{Z}[X]$ such that product $(x^2+ax+b)\\cdot P(x)$ is a polynomial of a form \\[ x^n+c_{n-1}x^{n-1}+\\cdots+c_1x+c_0 \\] where each of $c_0,c_1,\\ldots,c_{n-1}$ is equal to $1$ or $-1$.}\n\n        \\solu{The idea of bounding the roots using the coefficients.}\n\n\n\n\n\n        \\prob{}{}{EM}{Let $ P(x) $ be a polynomial with real coefficients, and $ P(x)\\geq 0 $ for all $ x\\in \\R $. Prove that there exists two polynomials $ R, S \\in \\Q $ such that \n        \\[P(x) = R(x)^2 + Q(x)^2\\]}\n\n\n\n        \\prob{https://artofproblemsolving.com/community/c6h84391p488980}{Romanian TST 2006 P2}{M}{Let $p$ a prime number, $p\\geq 5$. Find the number of polynomials of the form\n        \\[ x^p + px^k + p x^l + 1, \\quad k > l, \\quad k, l \\in \\left\\{1,2,\\cdots,p-1\\right\\}, \\] which are irreducible in $\\mathbb{Z}[X]$.}\n\n        \\solu{Taking mod $ p $, we have that $ x^p+1\\equiv (x+1)^p (\\mod\\ p) $. Now we can try equating terms or plug in some values to check for equality.}\n\n\n\n        \\prob{https://artofproblemsolving.com/community/c6h53271p334363}{Romanian TST 2003 P5}{M}{Let $f\\in\\mathbb{Z}[X]$ be an irreducible polynomial over the ring of integer polynomials, such that $|f(0)|$ is not a perfect square. Prove that if the leading coefficient of $f$ is 1 (the coefficient of the term having the highest degree in $f$) then $f(X^2)$ is also irreducible in the ring of integer polynomials.}\n\n        \\solu{If $ f(x^2) = g(x)h(x) $, plugging $ -x $ gives us $ g(x)h(x) = g(-x)h(-x) $. So we should look at the common roots of $ h(x) $ and $ h(-x) $. And it is straightforward from here.}\n\n        \\solu{}\n\n\n", "meta": {"hexsha": "489b540ff9c66f5717d471fadfe3930308b22843", "size": 8777, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg/sec2_1_irreducibility.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "alg/sec2_1_irreducibility.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg/sec2_1_irreducibility.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 51.0290697674, "max_line_length": 449, "alphanum_fraction": 0.5929132961, "num_tokens": 3364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7690802370707283, "lm_q1q2_score": 0.44414027236435083}}
{"text": "\r\n\r\n\\chapter{Machine Learning}\r\n\\begin{margintable}\\vspace{.8in}\r\n    In this chapter\r\n    \r\n    \\begin{tabularx}{\\marginparwidth}{|X}\r\n    Review and Overview\\\\\r\n    Formulation of supervised learning\\\\\r\n    Regression problems \\\\and squared loss\\\\\r\n    Linear regression under squared loss\\\\\r\n    \\end{tabularx}\r\n\\end{margintable}\r\n\r\n\\newcommand{\\cX}{\\mathcal{X}}\r\n\\newcommand{\\cY}{\\mathcal{Y}}\r\n\r\n\\section{Review and Overview}\r\nIn this lecture we delineate a mathematical framework for supervised learning. We focus on regression problems and define the notion of the loss/risk associated with a model. We then analyze a particular loss function (the squared loss) in a general setting, then specialize our result to the case of linear models. We next define the notion of parameterized families of hypotheses and the maximum likelihood estimate, and we conclude with an asymptotic result relating the training MLE to the true maximum likelihood parameter.\r\n\r\n\\section{Formulation of supervised learning}\r\nWe begin by constructing a mathematical framework for prediction problems. Our framework consists of the following elements:\r\n\\begin{enumerate}\r\n\t\\item A space of possible data points $\\cX$.\r\n\t\\item A space of possible labels $\\cY$.\r\n\t\\item A joint probability distribution $P$ on $\\cX\\times \\cY$. We assume that our training data consists of $n$ points $$(x^{(1)}, y^{(1)}), \\: \\ldots, \\: (x^{(n)}, y^{(n)}) \\: \\iid \\: P$$ each drawn independently from $P$.\r\n\t\\item A prediction function/model $f: \\cX\\rightarrow \\cY$.\r\n\t\\item A loss function $\\ell: \\cY\\times \\cY\\rightarrow \\mathbb{R}$. We will usually assume that $\\ell$ is bounded below by some constant, typically $0$.\r\n\\end{enumerate}\r\nGiven the prediction function $f$ and the loss function $\\ell$, the loss of an example is $\\ell(f(x),y)$. We can then define the \\textit{expected risk} (or \\textit{expected loss}, or \\textit{population risk})\r\n$$L(f) \\defn \\E_{(x,y)\\sim P} [\\ell(f(x),y)].$$ Our goal will be to obtain a small expected loss. Often it will be infeasible to consider all possible models $f$, so we may restrict ourselves to a certain family of hypotheses $\\mathcal{F}$. In this case, we define the \\textit{excess risk} of a model $f$ as $$L(f) - \\inf_{g\\in\\mathcal{F}} L(g).$$ This gives us a measure of how well our model fits the data relative to the best we can hope to do within our set of options $\\mathcal{F}$.\r\n\r\nWithin this framework, there are two main types of problems we will consider: \\textit{regression} problems, where the set of labels is $\\cY=\\mathbb{R}$; and \\textit{classification} problems, where the set of labels is some finite set $\\cY=\\{1,\\ldots,k\\}$. We will focus on regression problems in this lecture.\r\n\r\n\\section{Regression problems and squared loss}\r\nWe consider the regression problem of predicting $y$ given $x$. We take as our loss function the \\textit{squared loss} $$\\ell(\\hat{y},y) = (\\hat{y}-y)^2, \\hspace{.5in} L(f) = \\E_{(x,y)\\sim P}[(f(x)-y)^2].$$ In this setting, we can decompose the risk in a very informative way.\r\n\\begin{lemma}[Decomposition of loss] \\label{decomp}\r\nUnder the squared loss, we have the decomposition $$L(f) = \\E_{x\\sim P_x} [(f(x)-\\E[y \\: | \\: x])^2] + \\E_{x\\sim P_x}[\\Var(y\\: | \\:x)]$$ where $P_x$ is the marginal distribution of $x$.\r\n\\end{lemma}\r\n\r\nThe second term in this expansion is the intrisic variable of the label; it gives a lower bound on the loss we can achieve. Since the first term in the decomposition is nonnegative, it is an immediate corrolary that the optimal model is $f(x) = \\E[y \\: | \\: x]$.\r\n\r\nIn order to prove Lemma 1, we make use of the following claim.\r\n\\begin{center}\r\n    If $Z$ is a random variable and $a$ is a constant, then $$\\E[(Z-a)^2] = (\\E[Z]-a)^2 + \\Var(Z).$$\r\n\\end{center}\r\n\r\n\r\nThe proof of this claim is left as an exercise on HW 0. We are now ready to prove Lemma 1.\r\n\\begin{proof}[Proof of Lemma \\ref{decomp}]\r\nWe have\r\n\\begin{align*}\r\n    L(f) &= \\E[(f(x)-y)^2] \\\\\r\n    &= \\E_{x\\sim P_x}[\\E_{P_{y \\; | \\;x}}[(f(x)-y)^2\\: | \\: x]] & \\mathrm{(Law~{} of~{} total~{} expectation)} \\\\\r\n    &= \\E_{x\\sim P_x}[(f(x)-\\E[y \\: | \\: x])^2 + \\Var(y \\: | \\: x)]. & \\mathrm{(Claim~{} \\ref{claim:variance})}\r\n\\end{align*}\r\nNote that Claim \\ref{claim:variance} holds in the third equation since $f(x)$ is a constant when we have conditioned on $x$. The desired result follows from linearity of expectation.\r\n\\end{proof}\r\nLemma \\ref{decomp} gives us a general lower bound on risk under squared loss. If we impose more structure on the set of hypotheses $\\mathcal{F}$ from which we can select $f$, we can gain more information on the risk.\r\n\r\n\\section{Linear regression under squared loss}\r\nA commonly used choice of hypotheses is the set of linear functions: $$\\mathcal{F} = \\{f: \\mathbb{R}^d \\rightarrow \\mathbb{R} \\: | \\: f(x) = w^\\top x, \\: w\\in \\mathbb{R}^d\\}.$$ For $f\\in\\mathcal{F}$, we then have $$L(f) = L(w) = \\E[(w^\\top x-y)^2].$$ Henceforth, we will denote $w^* \\in \\mathrm{argmin}_{w\\in\\mathbb{R}^d} L(w)$ and $\\hat{w}$ will denote a model learned from training data.\r\n\r\nOne may ask why we have only allowed linear functions with $0$ instead of allowing a nonzero intercept. Actually, the framework we have outlined above is enough to accomodate nonzero intercepts. If we wish to analyze the function $w^\\top x + b$, we can simply set $\\tilde{x} = (x,1)$ and $\\tilde{w} = (w,b)$. Then $\\tilde{w}^\\top \\tilde{x} = w^\\top x + b$ and we have reduced to the case of $0$ intercept.\r\n\r\nWhen we restrict to linear models, we can further decompose the risk under squared loss.\r\n\\begin{lemma} \\label{lin}\r\nWith $w^*\\in \\mathrm{argmin}_{w\\in \\mathbb{R}^d}L(w)$, we have \\begin{equation}\\label{decomp2}L(\\hat{w}) = \\E_x [\\Var(y \\: | \\: x)] + \\E_x[(\\E[y\\: | \\: x]-w^{*\\top} x)^2] + \\E_x[(w^{*\\top} x-\\hat{w}^\\top x)^2].\\end{equation}\r\n\\end{lemma}\r\nThe second term in equation (\\ref{decomp2}) can be thought of as the approximation error incurred by linear models. The third term can be interpreted as the estimation error we incur from having only a finite sample.\r\n\\begin{proof}\r\nDefine $g(\\hat{w}) \\defn \\E[(\\E[y\\: | \\: x]-\\hat{w}^\\top x)^2]$. By Lemma \\ref{decomp}, \\begin{equation}\\label{lem1}L(\\hat{w}) = \\E[\\Var(y\\: | \\: x)] + g(\\hat{w}).\\end{equation} Observe that since $w^*\\in \\mathrm{argmin} L(w)$, $\\nabla L(w^*)=0$. Furthermore, since $\\E_x[\\Var(y\\: | \\: x)]$ is a constant with respect to $w$, we have\r\n\\begin{align*}\r\n    \\nabla L(w) &= \\nabla g(w) \\\\\r\n    &= \\E[\\nabla_w(\\E(y\\: | \\: x) -w^\\top x)^2] \\\\\r\n    &= 2\\E[(\\E(y\\: | \\: x) - w^\\top x)x].\r\n\\end{align*}\r\nSince $\\nabla L(w^*)=0$ we have \\begin{equation}\\label{vanish}\\E[(\\E[y \\: | \\: x]-w^{*\\top}x)x]=0.\\end{equation} Next, we expand:\r\n\\begin{align*}\r\n    g(\\hat{w}) &= \\E[(\\E[y\\: | \\: x]-\\hat{w}^\\top x)^2] \\\\\r\n    &= \\E[((\\E[y\\: | \\:x]-w^{*\\top}x)-(\\hat{w}^\\top x-w^{*\\top}x))^2] \\\\\r\n    &=\\E[(\\E[y\\: | \\: x] - w^{*\\top}x)^2 + (\\hat{w}^\\top x - w^{*\\top}x)^2] \\\\\r\n    &\\hspace{.25in} -2\\E[(\\E[y \\: | \\: x] - w^{*\\top}x)(\\hat{w}^\\top x-w^{*\\top}x)].\r\n\\end{align*}\r\nFinally, observe that $$\\E[(\\E[y\\: | \\:x] - w^{*\\top}x)(\\hat{w}^\\top x - w^{*\\top}x)] = (\\hat{w}^\\top - w^{*\\top})\\E[(\\E[y\\:|\\:x]-w^{*\\top}x)x].$$ By equation (\\ref{vanish}), this quantity vanishes and it follows that\r\n\\begin{equation}\\label{g}g(\\hat{w}) = \\E[(\\E[y\\: | \\: x] - w^{*\\top}x)^2] + \\E[(\\hat{w}^\\top x - w^{*\\top}x)^2].\\end{equation} Combining equations (\\ref{lem1}) and (\\ref{g}) gives the desired result. \r\n\\end{proof}\r\n\r\n\\section{Parameterized families of hypotheses}\r\nLinear models are one type of \\textit{parameterized family} of hypotheses. In general, a parameterized family is given by a parameter space $\\Theta$. For each $\\theta\\in\\Theta$ there is a hypothesis $f_\\theta(x)$, sometimes written $f(\\theta; x)$. In this case we may write the loss function as $$\\ell(f_\\theta(x),y) = \\ell((x,y),\\theta).$$ In the special case of linear functions, our parameter space is $\\Theta = \\mathbb{R}^d$ and for $\\theta \\in \\Theta$ we have $f_\\theta(x) = \\theta^\\top x.$\r\n\r\n\\subsection{Well-specified case and maximum likelihood}\r\nIn the well-specified case, $P_\\theta(y\\: | \\: x)$ is a family of distributions parameterized by $\\theta\\in\\Theta$, and $y\\: | \\: x \\sim P_{\\theta^*}(y\\: | \\: x)$ is distributed according to some ground truth parameter $\\theta^*$. We define the \\textit{maximum likelihood} loss function by $$\\ell((x,y),\\theta) = -\\log P_\\theta(y\\: | \\: x),$$ so that minimizing the loss function is equivalent to maximizing the likelihood of the data.\r\n\r\nFor example, suppose that $y\\: | \\: x$ is Gaussian distributed with mean $\\theta^{*\\top}x$ and variance $1$, i.e. $y\\: | \\: x \\sim N(\\theta^{*\\top}x, 1)$. The likelihood is then\r\n\\begin{align*}\r\n    \\ell((x,y),\\theta) &= -\\log P_\\theta(y\\: | \\:x) \\\\\r\n    &= -\\log \\exp\\left(-\\frac{(y-\\theta^\\top x)^2}{2}\\right) + c \\\\\r\n    &= \\frac{(y-\\theta^\\top x)^2}{2} + c\r\n\\end{align*}\r\nwhere $c$ is the log of the normalizing constant. This computation shows that in the Gaussian setting, minimizing the squared loss actually recovers the MLE.\r\n\r\n\\section{Training loss}\r\nOften we do not know the true underlying distribution $P$ with which to compute the expected loss. In these cases we need to use an approximation based on the data we do have. This motivates our definition of the \\textit{training loss} $$\\hat{L}(\\theta) \\defn \\frac1n \\sum_{i=1}^n \\ell((x^{(i)},y^{(i)}),\\theta).$$ In the special case of maximum likelihood, we have $\\hat{L}(\\theta) = -\\frac1n \\sum_{i=1}^n \\log p_\\theta(y^{(i)}\\: | \\:x^{(i)})$. We define the \\textit{maximum likelihood estimator} $$\\hat{\\theta}_{\\mathrm{MLE}} \\in \\mathrm{argmin}_{\\theta\\in\\Theta} \\hat{L}(\\theta).$$ This approximation is ``good\" in the sense that as $n\\rightarrow\\infty$, the minimizer of the training loss $\\hat{\\theta}_\\mathrm{MLE}$ approaches the true maximum likelihood parameter $\\theta^*$. The following theorem quantifies this fact.\r\n\\begin{theorem}[Asymptotic of MLE] \\label{mle}\r\n  Assume $\\nabla^2 L(\\theta^*)$ is full rank. Let $\\hat{\\theta} = \\hat{\\theta}_{\\mathrm{MLE}}$ and $$Q \\defn \\E_{(x,y)\\sim P}[\\nabla_\\theta(\\log p_\\theta(y\\: | \\: x))(\\theta^*) \\nabla_\\theta(\\log p_\\theta(y\\: | \\: x)(\\theta^*)^\\top].$$\r\n  Assuming that $\\hat{\\theta}=\\hat{\\theta}_n\\stackrel{\\tiny p}{\\rightarrow}\\theta^\\star$ (i.e. consistency) and under appropriate regularity conditions,  $$\\sqrt{n}(\\hat{\\theta}-\\theta^*)\\stackrel{\\tiny d}{\\rightarrow} N(0, Q^{-1}) \\textup{ and } n(L(\\hat{\\theta}) - L(\\theta^*))\\stackrel{\\tiny d}{\\rightarrow} \\frac12 \\chi^2(p).$$ as $n\\rightarrow\\infty$, where $p$ is the dimension of $\\theta$ and $\\chi^2(p)$ is the distribution of the sum of the squares of $p$ i.i.d. standard Gaussian random variables.\r\n\\end{theorem}\r\n\r\n\\begin{remark}\r\n    The positive definiteness of the Hessian $\\nabla^2 L(\\theta^\\ast)$ guarantees that identifiability holds \\emph{locally} (in a neighborhood of $\\theta^\\ast$), but does not imply identifiability because of a lack of \\emph{global} information. \r\n\r\nTo give a counter-example, suppose $\\theta^\\ast$ is the global minimizer of $L$ and the Hessian is positive definite, but there exists a sequence of $\\theta_n$ such that $\\|\\theta_n-\\theta^\\ast\\|=n$ but $L(\\theta_n)=L(\\theta^\\ast)+1/n$, then the identifiability is violated: the inf is not strictly greater than but equal to $L(\\theta^\\ast)$. The reason is that the Hessian does not reveal information about $L$ outside an infinitesimal neighborhood of $\\theta^\\ast$.\r\n\r\nOne way to exclude such adversarial case is to assume convexity: when $L$ is convex, a local strong growth implies global growth and thus identifiability\r\n\\end{remark}\r\n\r\n\r\n% \\begin{example}[fasd]\r\n%     sdadasd\r\n% \\end{example}", "meta": {"hexsha": "1398e9bb3216a6c05fb859a70e94132b2e752feb", "size": 11651, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/probility.tex", "max_stars_repo_name": "chancey922/subook", "max_stars_repo_head_hexsha": "1b5f5025a611bb1cfbcee2c4adad3ab1237c5eee", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2022-02-21T07:37:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T02:14:01.000Z", "max_issues_repo_path": "chapters/probility.tex", "max_issues_repo_name": "chancey922/subook", "max_issues_repo_head_hexsha": "1b5f5025a611bb1cfbcee2c4adad3ab1237c5eee", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/probility.tex", "max_forks_repo_name": "chancey922/subook", "max_forks_repo_head_hexsha": "1b5f5025a611bb1cfbcee2c4adad3ab1237c5eee", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.2892561983, "max_line_length": 826, "alphanum_fraction": 0.6659514205, "num_tokens": 3713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863695, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.4440679925988753}}
{"text": "\\chapter{Systems of sides}\n\nNow we will consider a common generalization of (some of pointfree) funcoids and (some of) Galois connections.\nThe main purpose of this is general theorem~\\ref{neg-prod} below.\n\nFirst consider some properties of Galois connections:\n\n\\section{More on Galois connections}\n\nHere I will denote $\\supfun{f}$ the lower adjoint of a Galois connection~$f$. \\fxnote{Switch to this notation in the book?}\n\nLet $\\mathsf{GAL}$ be the category of Galois connections.\n\\fxwarning{Need to decide whether use $\\mathsf{GAL}(A,B)$ or $A\\otimes B$.}\n\nI will denote $(f,g)^{-1}=(g,f)$ for a Galois connection~$(f,g)$.\n\nWe will order Galois connections by the formula\n\\[ f\\sqsubseteq g \\Leftrightarrow \\supfun{f}\\sqsubseteq\\supfun{g} \\Leftrightarrow \\supfun{f^{-1}}\\sqsupseteq\\supfun{g^{-1}}. \\]\n\n\\begin{obvious}\nThis defines a partial order on the set of Galois connections between any two (fixed) posets.\n\\end{obvious}\n\n\\begin{prop}\\label{gal-fjoin-x}\nIf $f$ and~$g$ are Galois connections (between a join-semilattice~$\\mathfrak{A}$ and a meet-semilattice~$\\mathfrak{B}$),\nthen there exists a Galois connection~$f\\sqcup g$\ndetermined by the formula~$\\supfun{f\\sqcup g}x = \\supfun{f}x\\sqcup\\supfun{g}x$.\n\\end{prop}\n\n\\begin{proof}\nIt is enough to prove that\n\\[ (x\\mapsto\\supfun{f}x\\sqcup\\supfun{g}x, y\\mapsto\\supfun{f^{-1}}y\\sqcap\\supfun{g^{-1}}y) \\]\nis a Galois connection that is that\n\\[ \\supfun{f}x\\sqcup\\supfun{g}x\\sqsubseteq y\\Leftrightarrow x\\sqsubseteq\\supfun{f^{-1}}y\\sqcap\\supfun{g^{-1}}y \\] for all relevant~$x$ and~$y$.\n\nReally,\n\\begin{multline*}\n\\supfun{f}x\\sqcup\\supfun{g}x\\sqsubseteq y \\Leftrightarrow\n\\supfun{f}x\\sqsubseteq y\\land\\supfun{g}x\\sqsubseteq y \\Leftrightarrow \\\\\nx\\sqsubseteq\\supfun{f^{-1}}y\\land x\\sqsubseteq\\supfun{g^{-1}}y \\Leftrightarrow\nx\\sqsubseteq\\supfun{f^{-1}}y\\sqcap\\supfun{g^{-1}}y.\n\\end{multline*}\n\\end{proof}\n\n\\fxnote{Describe infinite join of Galois connections.}\n\n\\begin{prop}\\label{a-bot}\nIf $\\mathfrak{A}$ is a poset with least element, then $\\supfun{a}\\bot=\\bot$.\n\\end{prop}\n\n\\begin{proof}\n$\\supfun{a}\\bot\\sqsubseteq y\\Leftrightarrow \\bot\\sqsubseteq\\supfun{a^{-1}}y\\Leftrightarrow 1$.\nThus $\\supfun{a}\\bot$ is the least element.\n\\end{proof}\n\n\\begin{prop}\n$(\\mathfrak{A}\\times\\{\\bot^\\mathfrak{B}\\}, \\mathfrak{B}\\times\\{\\top^\\mathfrak{A}\\})$ is the least Galois connection from\na poset~$\\mathfrak{A}$ with greatest element to a poset~$\\mathfrak{B}$ with least element.\n\\end{prop}\n\n\\begin{proof}\nLet's prove that it is a Galois connection. We need to prove\n\\[ (\\mathfrak{A}\\times\\{\\bot^\\mathfrak{B}\\})x\\sqsubseteq y \\Leftrightarrow x\\sqsubseteq (\\mathfrak{B}\\times\\{\\top^\\mathfrak{A}\\})y. \\]\nBut this is trivially equivalent to $1\\Leftrightarrow 1$. Thus it's a Galois connection.\n\nThat it the least is obvious.\n\\end{proof}\n\n\\begin{cor}\n$\\supfun{\\bot}x=\\bot$ for Galois connections from\na poset~$\\mathfrak{A}$ with greatest element to a poset~$\\mathfrak{B}$ with least element.\n\\fxwarning{Clarify.}\n\\end{cor}\n\n\\begin{thm}\\label{gal-bound}\nIf $\\mathfrak{A}$ and $\\mathfrak{B}$ are bounded posets, then $\\mathsf{GAL}(\\mathfrak{A}, \\mathfrak{B})$ is bounded.\n\\end{thm}\n\n\\begin{proof}\nThat $\\mathsf{GAL} (\\mathfrak{A}, \\mathfrak{B})$ has least element was proved\nabove. I will demonstrate that $(\\alpha , \\beta)$\nis the greatest element of $\\mathsf{pFCD} (\\mathfrak{A}, \\mathfrak{B})$ for\n\\[ \\alpha X = \\begin{cases}\n     \\bot^{\\mathfrak{B}} & \\text{if } X = \\bot^{\\mathfrak{A}}\\\\\n     \\top^{\\mathfrak{B}} & \\text{if } X \\neq \\bot^{\\mathfrak{A}}\n   \\end{cases} ; \\quad\n   \\beta Y = \\begin{cases}\n     \\top^{\\mathfrak{A}} & \\text{if } Y = \\top^{\\mathfrak{B}}\\\\\n     \\bot^{\\mathfrak{A}} & \\text{if } Y \\neq \\top^{\\mathfrak{B}}\n   \\end{cases} . \\]\nFirst prove $Y \\sqsubseteq \\alpha X \\Leftrightarrow X \\sqsubseteq \\beta Y$.\n\nReally $\\alpha X\\sqsubseteq Y \\Leftrightarrow X=\\bot^{\\mathfrak{A}}\\lor Y=\\top^{\\mathfrak{B}} \\Leftrightarrow X \\sqsubseteq \\beta Y$.\n\nThat it is the greatest Galois connection between~$\\mathfrak{A}$ and~$\\mathfrak{B}$ easily follows from proposition~\\ref{a-bot}.\n\\end{proof}\n\n\\begin{thm}\\label{gal-id-ex}\n  For every brouwerian lattice $x \\mapsto c \\sqcap x$ is a lower adjoint.\n\\end{thm}\n\n\\begin{proof}\n  By dual of theorem~\\bookref{cobrow-adj}.\n\\end{proof}\n\n\\begin{xca}\n  Describe the corresponding upper adjoint, especially for the special case of\n  boolean lattices.\n\\end{xca}\n\n\\section{Definition}\n\n\\begin{defn}\n\\emph{System of presides} is\na functor $\\Upsilon = (f\\mapsto\\supfun{f})$ from an ordered category\nto the category of functions between (small) bounded lattices,\nsuch that (for all relevant variables):\n\\begin{enumerate}\n  \\item Every Hom-set of~$\\Src\\Upsilon$ is a bounded join-semilattice.\n\n  \\item $\\supfun{a}\\bot = \\bot$.\n\n  \\item $\\supfun{a \\sqcup b} X = \\supfun{a} X \\sqcup \\supfun{b} X$ (equivalent to $\\Upsilon$ to be a join-semilattice homomorphism,\n    if we order functions between small bounded lattices component-wise).\n\\end{enumerate}\nI call morphisms of such categories \\emph{sides}.\\footnote{The idea for the name is that we consider one ``side''~$\\supfun{f}$ of a funcoid instead of both sides~$\\supfun{f}$ and~$\\supfun{f^{-1}}$.}\n\\end{defn}\n\n\\begin{rem}\nWe could generalize to functions between small join-semilattices with least elements instead of bounded lattices only, but this is not really necessary.\n\\end{rem}\n\n\\begin{defn}\nI will call objects of the source category of this functor simply \\emph{objects of the presides}.\n\\end{defn}\n\n\\begin{defn}\n\\emph{Bounded} system of presides is system of presides from an ordered category with bounded Hom-sets\nsuch that $X,Y\\in\\Ob\\Src\\Upsilon$ the following additional axioms hold for all suitable~$a$:\n\\begin{enumerate}\n  \\item $\\supfun{\\bot^{\\Hom(X,Y)}} a = \\bot$.\n\n  \\item $\\supfun{\\top^{\\Hom(X,Y)}} a = \\top$ unless $a = \\bot$\n\\end{enumerate}\n\\end{defn}\n\n\\begin{defn}\n\\emph{System of presides with identities} is a system of presides with\na morphism $\\id_a\\in\\Src\\Upsilon$ for every object $\\mathfrak{A}$ of~$\\Src\\Upsilon$ and $a\\in\\mathfrak{A}$\nand the following additional axioms:\n\\begin{enumerate}\n  \\item $\\id_c \\sqsubseteq 1_{\\mathfrak{A}}$ for every $c \\in \\mathfrak{A}$\n    where $\\mathfrak{A}$ is an object of~$\\Src\\Upsilon$.\n\n  \\item $\\supfun{\\id_c} = (\\lambda x \\in \\mathfrak{A}: x \\sqcap c)$ for every $c \\in \\mathfrak{A}$\n    where $\\mathfrak{A}$ is an object of~$\\Src\\Upsilon$\n\\end{enumerate}\n\\end{defn}\n\n\\begin{defn}\n\\emph{System of sides} is a system of presides which is both bounded and with identities.\n\\end{defn}\n\n\\begin{prop}\n$\\supfun{1^{\\Src\\Upsilon}_\\mathfrak{A}} a = a$ for every system of presides.\n\\end{prop}\n\n\\begin{proof}\nBy properties of functors.\n\\end{proof}\n\n\\begin{defn}\nI call a system of \\emph{monotone} presides a system of presides with additional axiom:\n\\begin{enumerate}\n\\item $\\supfun{a}$ is monotone.\n\\end{enumerate}\n\\end{defn}\n\n\\begin{defn}\nI call a system of \\emph{distributive} presides a system of presides with additional axiom:\n\\begin{enumerate}\n\\item $\\supfun{a}(X\\sqcup Y) = \\supfun{a}X\\sqcup\\supfun{a}Y$.\n\\end{enumerate}\n\\end{defn}\n\n\\begin{obvious}\nEvery distributive system of presides is monotone.\n\\end{obvious}\n\n\\begin{prop}\n$\\supfun{a \\sqcap b} X \\sqsubseteq \\supfun{a} X \\sqcap \\supfun{b} X$ for monotone systems of sides\nif Hom-sets are lattices.\n\\end{prop}\n\n\\begin{defn}\nA system of presides \\emph{with correct identities} is a system of presides with identities with additional axiom:\n\\begin{enumerate}\n\\item $\\id_b\\circ\\id_a = \\id_{a\\sqcap b}$.\n\\end{enumerate}\n\\end{defn}\n\n\\begin{prop}\nEvery faithful system of presides with identities is with correct identities.\n\\end{prop}\n\n\\begin{proof}\n$\\supfun{\\id_b\\circ\\id_a}x = (\\supfun{\\id_b}\\circ\\supfun{\\id_a})x = \\supfun{\\id_b}\\supfun{\\id_a}x = b\\sqcap a\\sqcap x = \\supfun{\\id_{b\\sqcap a}}x$.\nThus by faithfulness $\\id_b\\circ\\id_a = \\id_{b\\sqcap a} = \\id_{a\\sqcap b}$.\n\\end{proof}\n\n\\begin{defn}\n\\emph{Restricting} a side~$f$ to an object~$X$ is defined by the formula $f|_X = f\\circ\\id_X$.\n\\end{defn}\n\n\\begin{defn}\n\\emph{Image} of a preside is defined by the formula $\\im f=\\supfun{f}\\top$.\n\\end{defn}\n\n\\begin{defn}\nProtofuncoids \\emph{over} a set~$X$ of functors is a protofuncoid~$f$\nsuch that $\\supfun{f}\\in X\\land\\supfun{f^{-1}}\\in X$.\n\\end{defn}\n\n\\section{Concrete examples of sides}\n\n\\begin{obvious}\nThe category~$\\mathbf{Rel}$ with $\\supfun{f}=\\rsupfun{f}$ for $f\\in\\mathbf{Rel}$ and usual $\\id_c$ defines a distributive system of sides with correct identities.\n\\end{obvious}\n\n\\subsection{Some subsides}\n\n\\begin{defn}\n\\emph{Full subsystem} of a system~$\\Upsilon$ of presides is the functor~$\\Upsilon$ restricted to a full subcategory of~$\\Src\\Upsilon$.\n\\end{defn}\n\n\\begin{obvious}\nFull subsystem of a system of presides is always a system of presides.\n\\end{obvious}\n\n\\begin{obvious}\nFull subsystem of a bounded system of presides is always a bounded subsystem of presides.\n\\end{obvious}\n\n\\begin{obvious}\n~\n\\begin{enumerate}\n\\item Full subsystem of a system of presides with identities is always with identities.\n\\item Full subsystem of a system of presides with correct identities is always with correct identities.\n\\end{enumerate}\n\\end{obvious}\n\n\\begin{obvious}\nFull subsystem of a distributive system of presides is always a distributive system of presides.\n\\end{obvious}\n\n\\begin{obvious}\nFull subsystem of a system of sides is always a system of sides.\n\\end{obvious}\n\n\\subsection{Funcoids and pointfree funcoids}\n\n\\begin{prop}\nThe category of pointfree funcoids between starrish join-semilattices with usual~$\\supfun{f}$ defines a system of presides.\n\\end{prop}\n\n\\begin{proof}\nTheorem~\\bookref{pf-fin-join}.\n\\end{proof}\n\n\\begin{prop}\nThe category of pointfree funcoids between bounded starrish join-semilattices with usual~$\\supfun{f}$ defines a system of\nbounded presides.\n\\end{prop}\n\n\\begin{proof}\nTake the proof of theorem~\\bookref{pfcd-bound} into account.\n\\end{proof}\n\n\\begin{prop}\nThe category of pointfree funcoids from a starrish join-semilattices to a separable starrish join-semilattices\ndefines a distributive system of presides.\n\\end{prop}\n\n\\begin{proof}\nTheorem~\\bookref{pf-dist-func}.\n\\end{proof}\n\n\\begin{prop}\nThe category of pointfree funcoids between starrish lattices with usual~$\\supfun{f}$ and usual $\\id_c$ defines a system of presides with correct identities.\n\\end{prop}\n\n\\begin{proof}\nThat it is with identities is obvious.\n\nThat it is with correct identities is obvious.\n\\end{proof}\n\n\\begin{obvious}\nThe category of pointfree funcoids between bounded starrish lattices with usual~$\\supfun{f}$ and usual $\\id_c$ defines a system of sides with correct identities.\n\\end{obvious}\n\n\\begin{prop}\nThe category of funcoids with usual~$\\supfun{f}$ and usual $\\id_c$ defines a system of sides with correct identities.\n\\end{prop}\n\n\\begin{proof}\nBecause it can be considered a full subsystem of\nthe category of pointfree funcoids between bounded starrish lattices with usual~$\\supfun{f}$.\n\\end{proof}\n\n\\subsection{Galois connections}\n\n\\begin{prop}\nThe category of Galois connections between (small) lattices with least elements together with usual~$\\supfun{f}$\ndefines a distributive system of presides.\n\\end{prop}\n\n\\begin{proof}\nPropositions~\\ref{gal-fjoin-x} and~\\ref{a-bot} for a system of presides.\n\nIt is distributive because lower adjoints preserve all joins.\n\\end{proof}\n\n\\begin{prop}\nThe category of Galois connections between (small) bounded lattices together with usual~$\\supfun{f}$\ndefines a bounded system of presides.\n\\end{prop}\n\n\\begin{proof}\nTheorem~\\ref{gal-bound}.\n\\end{proof}\n\n\\begin{prop}\nThe category of Galois connections between (small) Heyting lattices together with usual~$\\supfun{f}$\ndefines a system of sides with correct identities.\n\\end{prop}\n\n\\begin{proof}\nTheorem~\\ref{gal-id-ex} ensures that they a system of sides with identities. The identities are correct due to faithfulness.\n\\end{proof}\n\n\\subsection{Reloids}\n\n\\begin{prop}\nReloids with the functor $f\\mapsto\\supfun{\\tofcd f}$ and usual $\\id_c$ form a system of sides with correct identities.\n\\end{prop}\n\n\\begin{proof}\nIt is really a functor because\n$\\supfun{\\tofcd g}\\circ\\supfun{\\tofcd f} = \\supfun{\\tofcd g\\circ\\tofcd f} = \\supfun{\\tofcd(g\\circ f)}$\nfor every composable reloids~$f$ and~$g$.\n\n$\\supfun{a}\\bot = \\supfun{\\tofcd a}\\bot = \\bot$;\n\\begin{multline*}\n\\supfun{a\\sqcup b}X = \\supfun{\\tofcd(a\\sqcup b)}X = \\supfun{\\tofcd a\\sqcup\\tofcd b)}X = \\\\\n\\supfun{\\tofcd a}X\\sqcup\\supfun{\\tofcd b}X = \\supfun{a}X\\sqcup\\supfun{b}X;\n\\end{multline*}\nthus it is a system of presides.\n\nThat this is a bounded system of presides follows from the formulas\n$\\tofcd\\bot^{\\mathsf{RLD}(A,B)}=\\bot$ and $\\tofcd\\top^{\\mathsf{RLD}(A,B)}=\\top$.\n\nIt is with identities, because proposition~\\bookref{fcd-id}.\nIt is with correct identities by proposition~\\bookref{rld-id-comp}.\n\\end{proof}\n\n\\fxnote{Also for pointfree reloids.}\n\n\\fxnote{These examples works for (dagger) systems of sides with binary product.}\n\n\\section{Product}\n\n\\begin{defn}\n\\emph{Binary product} of objects of presides with identities is defined by the formula $X\\times Y=\\id_Y\\circ\\top\\circ\\id_X$.\n\\end{defn}\n\n\\begin{defn}\nSystem of presides with identities is \\emph{with correct binary product} when $f\\sqcap(X\\times Y) = \\id_Y\\circ f\\circ\\id_X$\nfor every preside~$f$.\n\\end{defn}\n\n\\begin{prop}\n$\\supfun{A\\times B}X = \\begin{cases}\\bot&\\text{ if }X\\asymp A\\\\B&\\text{ if }X\\nasymp A\\end{cases}$\n\\end{prop}\n\n\\begin{proof}\n~\n\\begin{multline*}\n\\supfun{A\\times B}X = \\supfun{\\id_B\\circ\\top\\circ\\id_A}X =\n\\supfun{\\id_B}\\supfun{\\top}\\supfun{\\id_A}X = \\\\\nB\\sqcap\\supfun{\\top}(X\\sqcap A) =\nB\\sqcap\\begin{cases}\\bot&\\text{ if }X\\asymp A\\\\\\top&\\text{ if }X\\nasymp A\\end{cases} =\n\\begin{cases}\\bot&\\text{ if }X\\asymp A\\\\B&\\text{ if }X\\nasymp A\\end{cases}\n\\end{multline*}\n\\end{proof}\n\n\\begin{defn}\nI will call a system of sides \\emph{with correct meet} when\n\\[ (X_0\\times Y_0)\\sqcap(X_1\\times Y_1) = (X_0\\sqcap X_1)\\times(Y_0\\sqcap Y_1). \\]\n\\end{defn}\n\n\\begin{prop}\nFaithful systems of presides with identities are with correct meet.\n\\end{prop}\n\n\\begin{proof}\n$(X_0\\times Y_0)\\sqcap(X_1\\times Y_1) = \\id_{Y_1}\\circ(X_0\\times Y_0)\\circ\\id_{X_1}$.\nThus\n\\begin{multline*}\n\\supfun{(X_0\\times Y_0)\\sqcap(X_1\\times Y_1)} P = \\supfun{\\id_{Y_1}}\\supfun{X_0\\times Y_0}\\supfun{\\id_{X_1}} P = \\\\\n\\supfun{\\id_{Y_1}}\\begin{cases}\\bot&\\text{ if }X_0\\asymp\\supfun{\\id_{X_1}}P\\\\Y_0&\\text{ if }X_0\\nasymp\\supfun{\\id_{X_1}}P\\end{cases} =\n\\begin{cases}\\bot&\\text{ if }X_0\\sqcap X_1\\asymp P\\\\Y_0\\sqcap Y_1&\\text{ if }X_0\\sqcap X_1\\nasymp P\\end{cases} = \\\\\n\\supfun{(X_0\\sqcap X_1)\\times(Y_0\\sqcap Y_1)} P.\n\\end{multline*}\nSo $(X_0\\times Y_0)\\sqcap(X_1\\times Y_1) = (X_0\\sqcap X_1)\\times(Y_0\\sqcap Y_1)$ follows by full faithfulness.\n\\end{proof}\n\n\\begin{prop}\nSystems of presides with correct identities are with correct meet.\n\\end{prop}\n\n\\begin{proof}\n$(X_0 \\times Y_0) \\sqcap (X_1 \\times Y_1) = \\id_{Y_1} \\circ (X_0 \\times\nY_0) \\circ \\id_{X_1} = \\id_{Y_1} \\circ (\\id_{Y_0} \\circ \\top\n\\circ \\id_{X_0}) \\circ \\id_{X_1} = \\id_{Y_0 \\sqcap Y_1}\n\\circ \\top \\circ \\id_{X_0 \\sqcap X_1} = (X_0 \\sqcap X_1) \\times (Y_0\n\\sqcap Y_1)$.\n\\end{proof}\n\nFor some sides holds the formula $f\\circ(X\\times Y) = X\\times\\supfun{f}Y$.\nI refrain to give a name for this property.\n\n\\section{Negative results}\n\nThe following negative result generalizes theorem~3.8 in~\\cite{tprod-dist-lat}.\n\n\\begin{thm}\\label{neg-prod}\n  The element $1^{(\\Src\\Upsilon)(\\mathfrak{A}, \\mathfrak{A})}$ is not\n  complemented if $\\mathfrak{A}$ is a non-atomic boolean lattice,\n  for every monotone system of sides.\n\\end{thm}\n\n\\begin{proof}\n  Let $T = 1^{(\\Src\\Upsilon)(\\mathfrak{A}, \\mathfrak{A})}$.\n  \n  Let's suppose $T \\sqcup V = \\top$ for $V \\in (\\Src\\Upsilon) (\\mathfrak{A},\n  \\mathfrak{A})$ and prove $T \\sqcap V \\neq \\bot$.\n  \n  Then $\\supfun{T \\sqcup V} a = \\top$ for all $a \\neq \\bot$ and thus $\\supfun{V}\n  a \\sqcup a = \\top$.\n  \n  Consequently $\\supfun{V} a \\sqsupseteq \\neg a$ for all $a \\neq \\bot$.\n  \n  If $a$ isn't an atom, then there exists $b$ with $0 \\sqsubset b \\sqsubset a$\n  and hence $\\supfun{V} a \\sqsupseteq \\supfun{V} b \\sqsupseteq \\neg b \\sqsupset \\neg a$;\n  thus $\\supfun{V} a \\sqsupset \\neg a$.\n  \n  There is such $c\\sqsubset\\top$ that $a \\sqsubseteq c$ for every atom $a$. (Really,\n  suppose some element $p \\neq \\bot$ has no atoms. Thus all atoms are in $\\neg\n  p$.)\n  \n  For $a \\nsqsubseteq c$ we have $\\supfun{V} a \\sqcap a \\sqsupset \\bot$\n  for all $a \\sqsubseteq \\neg c$ thus $\\supfun{T \\sqcap V} a \\sqsupseteq\n  \\supfun{V} a \\sqcap a \\sqsupset \\bot$. Thus $\\supfun{(T \\sqcap V) \\circ\n  \\id_{\\neg c}} a \\sqsupset \\bot$\n  \n  So $T \\sqcap V \\sqsupseteq (T \\sqcap V) \\circ \\id_{\\neg c} \\sqsupset\n  \\bot$. So $V$ is not a complement of $T$.\n\\end{proof}\n\n\\begin{cor}\n  $(\\Src\\Upsilon)(\\mathfrak{A}, \\mathfrak{A})$ is not boolean if $\\mathfrak{A}$\n  is a non-atomic boolean lattice.\n\\end{cor}\n\n\\section{Dagger systems of sides}\n\n\\begin{prop}\n~\n\\begin{enumerate}\n\\item For a partially ordered dagger category, each of Hom-set of which has least element, we have $\\bot^\\dagger = \\bot$.\n\\item For a partially ordered dagger category, each of Hom-set of which has greatest element, we have $\\top^\\dagger = \\top$.\n\\end{enumerate}\n\\end{prop}\n\n\\begin{proof}\n$\\forall f\\in\\Hom(A,B):\\bot^\\dagger\\sqsubseteq f \\Leftrightarrow\n\\forall f\\in\\Hom(A,B):\\bot\\sqsubseteq f^\\dagger \\Leftrightarrow\n\\forall f\\in\\Hom(A,B):\\bot\\sqsubseteq f \\Leftrightarrow 1$. Thus $\\bot^\\dagger$ is the least.\n\nThe other items is dual.\n\\end{proof}\n\n\\begin{defn}\n\\emph{Dagger system of presides with identities} is system of presides with identities with category~$\\Src\\Upsilon$ being\na partially ordered dagger category\nand $(\\id_X)^\\dagger = \\id_X$ for every~$X$.\n\\end{defn}\n\n\\begin{prop}\nFor a system of sides we have $(X\\times Y)^\\dagger = Y\\times X$.\n\\end{prop}\n\n\\begin{proof}\n$(X\\times Y)^\\dagger = (\\id_Y\\circ\\top\\circ\\id_X)^\\dagger = \\id_X^\\dagger\\circ\\top^\\dagger\\circ\\id_Y^\\dagger =\n\\id_X\\circ\\top\\circ\\id_Y = Y\\times X$.\n\\end{proof}\n\n\\fxnote{Which properties of pointfree funcoids can be generalized for sides?}", "meta": {"hexsha": "493e1aa0935aed83f110bc9aa65a8f4c9056c63f", "size": 17941, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-sides.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-sides.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-sides.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2475442043, "max_line_length": 198, "alphanum_fraction": 0.7149545733, "num_tokens": 6300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4440679843752567}}
{"text": "% !TeX root = ../main.tex\n% Add the above to each chapter to make compiling the PDF easier in some editors.\n\n\n\\chapter{Introduction}\\label{chapter:introduction}\n\nAn important topic in computer science is the study of the\n\\textit{functional correctness} of an algorithm.\nIt states whether an algorithm satisfies specified\ninput/output behavior.\nProving correctness of an algorithm\nbecomes especially interesting when it is be applied\nto directly executable code and even more so if it is machine checked.\nUnfortunately, with both, the task becomes\nsignificantly more complex.\nEven in an abstract specification, where topics such as\nmemory management may be abstracted away,\nmachine checked proofs of non-trivial properties\nare hard.\nFurthermore for concrete implementations,\nlow-level decisions about memory allocation or\nthe eligibility of reusing variables need to be\nreasoned about.\nIn this thesis we provide a computer assisted proof in the interactive\ntheorem prover Isabelle/HOL \\parencite{DBLP:books/sp/NipkowPW02} for the functional\ncorrectness of an imperative implementation of the B-tree data-structure\nand present how we dealt with the above mentioned issues.\n\n\n\nIn \\Cref{chapter:introduction}, we have a brief overview on related\nwork and introduce common variations of B-trees and\nthe definition that is most promising for our approach.\nWe first design a functional, abstract implementation.\nTogether with a proof of its functional correctness,\nit is presented in \\Cref{chapter:abs-set}.\nOn this level, functional correctness means that we show the specifications\nimplement an abstract set interface for linearly ordered element.\nThis interface supports membership queries as well as insertion and deletion operations.\nFrom the functional specification, an imperative implementation is derived in \\Cref{chapter:imp-set}.\nIts functional correctness is shown by proving that it refines the functional specification.\nThus the proof obligation for the imperative implementation\nis reduced to a proof of equivalence between the output of the\nfunctional and the imperative implementation.\nThis allows for small optimizations with regard to a na\\\"ive translation.\nFinally, we present learned lessons, compare the results with related work and suggest potential future\nresearch in \\Cref{chapter:conclusion}.\n\n% TODO related work?\n% mfp/fielding: not mechanized, different approaches\n% Ernst: more automation, but actually similar approach to ours (except for used structure)\n% Malecha: less automation, similar structure\n\n\n\n\\section{The Isabelle Proof Assistant}\n\nIsabelle/HOL is an interactive theorem prover that allows\nto reason, among other things,\nin Higher Order Logic.\nIt is built in ML, which influences the syntax of functional\nprograms written in it \\parencite{DBLP:books/sp/NipkowPW02}.\nIsabelle source files are divided in so called theories,\ncorresponding to code modules in common programming languages.\nA theory consists of the specification of data types,\ntyped definitions and theorems with proofs.\n\n\\subsection{Notation and proofs in Isabelle}\n\nFunctions, predicates, etc. are all expressed in\na functional manner.\nThe keyword \\textbf{definition} denotes classical definitions.\nThe term \\textbf{abbreviation} is used to define simple shorthands for more complex expressions,\nsimilar to a macro.\nThe word \\textbf{fun} precedes recursively defined total functions.\nIt is only a valid definition if it incorporates a proof of termination.\nUsually this proof is derived automatically by the system.\nIf a termination can not be guaranteed for all inputs,\na function may be defined via \\textbf{partial\\_function}.\nAs cycle freeness of heap pointers can not be guaranteed for all inputs\non imperative programs, many imperative definitions are given\nas partial functions.\nAs a consequence from potential non-termination,\nwe may only show partial correctness for these functions \\parencite{DBLP:conf/itp/Krauss10}.\nHowever this is implied by the Hoare Logic that we will use to reason about imperative programs.\n\nMathematical propositions can be expressed in a similar manner\nas they would be written in a mathematical textbook.\nThey begin with the keyword \\textbf{lemma}, \\textbf{theorem} or \\textbf{corollary},\nfollowed by an expression or predicate and a proof.\nWherever possible and readable, we will try to reflect the actual\nsyntax of the Isabelle system, however compromise in order to\nkeep the notation of obtained lemmata and theorems\nclose to conventional notation.\nTo prove a theorem correct, the system basically provides two different\nproof styles.\n\n\\begin{enumerate}\n    \\item Structured proofs in the Isar language:\n    The user outlines a proof, supplying intermediate goals\n    and telling the system which proof method to apply to\n    resolve each step.\n    This style is usually preferred as it is more readable and usually\n    faster on the system side.\n    All complex proofs in \\Cref{chapter:abs-set} are hence written in this style.\n    \\item Apply style: the user tells the system which proof method\n    to apply to modify the current goal.\n    Examples are the application of a rule\n    or simplification using equivalences.\n    This is practical if the number of assumptions\n    is high or the goal is large and writing the full terms\n    out would be impractical.\n    Since this is the case for the proofs of the imperative programs,\n    almost all proofs in \\Cref{chapter:imp-set} are written in this style.\n\\end{enumerate}\n\n\nThe system provides a number of proof methods,\nbased on different manipulation tools\nsuch as logical reasoning or simplification.\nIn this work we will not present the proofs as written in the actual\nproof files but rather outline the structure of the proofs.\nWhen mentioning \\textit{automatic} proofs, we mean a proof that\ncomprises very few ($\\le 5$) apply style\ninvocations of proof methods.\nA method that commonly allows for such proofs is the \\textit{auto} method,\na combination of logical reasoning and repeated simplification,\nbut also allowing automatic case distinctions and destructive rule application.\n\nIt is possible to specify functions, predicates\nand theorems with respect to some abstracted constants\n(which may also be functions).\nInside the resulting \\textbf{locale}, only certain assumptions,\nbut no concrete definitions are known about the abstracted constant.\nBy providing definitions that satisfy\nthe assumptions, we may \\textit{instantiate}\nthe locale, potentially yielding computable results.\nWe implement the set interface concretely by\ninstantiating a set locale from the standard library.\nBut also the definition of functional and imperative\nB-tree operations will be in locales that assume\nthe existence of a node-navigating operation.\n\n\\subsection{Examples and basics of the Isabelle language}\n\nDatatypes may be defined recursively.\nThe following shows as an example the internal definition of the list data type.\\footnote{\n    The actual definition is worded slightly different but this is of no importance here.\n}\n\n\\begin{lstlisting}[mathescape=true, language=Isabelle,label=lst:list-def]\ndatatype 'a list = [] | 'a # 'a list\n\\end{lstlisting}\n\nIn natural language this means that either a list is the empty list,\nor it is an element prepended to another list.\nAs usual in ML like languages, we may apply pattern matching to function argument.\nIn addition, the type $'t$ of any expression $e$ can be\nmade explicit by writing \\textit{e :: 't}.\nFunctions that take values of type $'a$ and return values of type $'b$ \nhave type \\textit{'a $\\Rightarrow$ 'b}.\nFor functions that take several arguments,\ncurrying is applied.\nThe Isabelle internal list catenation function \"@\" serves as\nan example for a function definition with explicit type.\n\n\\begin{lstlisting}[mathescape=true, language=Isabelle,label=lst:append-def]\nfun (@) :: 'a list $\\Rightarrow$ 'a list $\\Rightarrow$ 'a list where\n    [] @ ys = ys |\n    (x#xs) @ ys = x # (xs @ ys)\n\\end{lstlisting}\n\n% TODO include?\n% locales\n% set specification\n\nFurther details on notation, proof techniques and more in Isabelle/HOL\nmay be found in Chapter 1 of \\parencite{DBLP:books/sp/NipkowK14}.\n\n\n\\section{The B-Tree Data Structure}\n\nB-trees were first proposed by Bayer in \\parencite{DBLP:journals/acta/BayerM72},\nas a data-structure to efficiently retrieve and manipulate\nindexed data stored on storage devices with slow memory access.\nThey are $n$-ary balanced search trees.\nAs such B-trees are generally said to implement a map interface,\nmapping indices to data and supporting map updates and deletions.\nThey may also be specified as implementing a set interface,\nwhere the indices form the actual content of the set.\nB-trees are a generalization of 234-trees and a specialization of (a,b)-trees.\n\nA commonly implemented variation is the B$^+$-tree, where the inner nodes\nonly contain separators to guide the recursive navigation through the tree.\nIn B$^+$-trees, all data is stored in the leaves \\parencite{DBLP:journals/csur/Comer79}.\nFurther the leaves are often implemented so as to contain pointers\nto the next leaf in order, allowing for efficient range queries.\n\nNodes are generally thought to be implemented by\ncontaining a number of indices, data corresponding to each index\nand a number of children.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.5\\linewidth]{figures/btree-basic-nopair.pdf}\n    \\caption[A small example B-Tree]{A small balanced, sorted B-tree of order $2$ and\n    height $2$ containing $3$ nodes and $6$ elements.\n    In subsequent depictions, leafs will be depicted\n    by empty circles.}\n    \\label{fig:btree-basic-nopair}\n\\end{figure}\n\n\n\\subsection{Definitions}\n\\label{sec:data_structure_defs}\n\nEvery node contains a list of \\textit{keys} (also \\textit{separators}, \\textit{index elements}), and \\textit{subtrees} (\\textit{children}),\nthat represent further B-tree nodes.\nThe separators and subtrees may be considered interleaved within a node,\nsuch that we can speak of a subtree to the left of a separator and\na subtree to the right of a separator,\nwhere for a separator at index $i$ we mean the subtree in the respective\nsubtree list at index $i$ and $i+1$ respectively.\nNote that this already implies that the list of subtrees is one\nlonger than the list of separators - we refer to the last subtree\nas the \\textit{last} or \\textit{dangling} subtree.\nIn the original definition by Bayer \\parencite{DBLP:journals/acta/BayerM72},\na B-tree with above structure must fulfill the three properties\n\\textit{balancedness}, \\textit{order} and \\textit{sortedness}.\n\n\\paragraph{Balancedness} \\textit{Balancedness} requires\nthat each path from the root to any leaf has the same length $h$.\nIn other words, the height of all trees in one level of the tree must be equal,\nwhere the height is the maximum path length to any leaf.\nIt is only possible to maintain this property\ndue to the flexible amount of subtrees in each node.\n\n\\paragraph{Sortedness} Further the indices must be \\textit{sorted} within the tree which means that all indices stored\nin the subtree to the left of a separator are smaller than the value of the separator\nand all indices in the subtree to the right are greater.\nFurther all indices within a node should maintain a sorted order,\nthat is the list of separators in a node must be sorted.\n\n\\paragraph{Order} In general terms, the property of \\textit{order} ensures a certain minimum and maximum\nnumber of subtrees for each node.\nHowever, as pointed out by Folk and Zoellick \\parencite{DBLP:books/daglib/0095349_mod},\nthe property is defined differently in the literature.\nFor the purpose of this work, the original definition by Bayer\nwas chosen as most suitable.\nA B-tree is of order $k$, if each internal node has at least $k+1$\nsubtrees and at most $2k+1$.\nThe root is allowed to have a minimum of 2 subtreess and a maximum of $2k+1$.\n\nAn alternative definition proposed by Knuth \\parencite{DBLP:books/lib/Knuth98a},\nis to allow between $\\lceil \\frac{k}{2} \\rceil$ and $k$ children.\nHowever this involves cumbersome \\textit{real} arithmetic that unnecessarily complicates\nmechanized proofs.\nSticking to the original definition is further supported by the fact that nodes are supposed\nto fill memory pages which are usually of even size (usually some power of 2).\nAn even number of separators and trees plus one dangling last tree maximizes\nthe usage of such a page.\n\nThe same ambiguity exists for the term \\textit{Leaf} which we will define consistently with Knuth's definition \\parencite{DBLP:books/lib/Knuth98a}\nto be an empty node, carrying no information,\nrather than a node that contains data but no children.\nThis is close to the usual approach in functional programming,\nand will yield more elegant recursive equations for our B-tree operations.\nThe lowest level of nodes hence contains a list of separators and\nlist of pointers to leaves as can be seen in \\Cref{fig:btree-basic-nopair}.\n\nNote that the B-tree definition is only meaningful for positive $k$.\nFor the case that $k$ is equal to 0,\nall elements of the tree would have exactly one subtree\nand no internal elements.\nFor the root node this even leads to a contradictory state:\nIt is required to contain at least 1 element or 2 subtrees.\nHowever as it should not have more than $2k+1 = 1$ elements,\nthis constraint can not be satisfied.\nRequiring positive $k$ is consistent with the definitions\nin the consulted literature \\parencite{DBLP:journals/acta/BayerM72,DBLP:journals/csur/Comer79,DBLP:books/daglib/0023376}.\n\n% insert image of valid B-tree\n\n\\subsection{B-Tree operations}\n\nThe B-tree is a dynamic data-structure and provides\noperations to query and update stored data.\nGenerally, the operations are defined recursively on the nodes.\nThe correct subtree may be found by inspecting the separators stored\nin the currently visited node.\nIf the value that is being searched for is in the range of two\nadjacent separators and equal to neither of them,\nwe recurse into the tree in between. \nThe obvious corner cases are if the value is less than the\nminimal element or greater than the maximum element stored.\nIn that case we recurse in either the first or the last subtree.\nThe exact manner of inspection should in practice of course\nbe efficient and will hence be kept abstract until \\Cref{chapter:imp-set}.\n\n\\paragraph{Retrieval}\\label{par:intro-isin}\nSince the whole tree is sorted,\nchecking whether certain elements are contained in the tree\nis simply conducted by recursing into the correct node\nin each level.\nEither the element is found directly or found at a lower level.\nIf we reach a leaf node we know that the element is not contained in the tree.\nThere is little variation on this algorithm so there is no need for comparison.\n\n% TODO move abstract discussion to introduction\n%-------------------------------------------------\n\\paragraph{Insertion}\\label{par:intro-ins}\nThere is also general consensus in the literature on\nhow to conduct insertion into a B-tree \\parencite{DBLP:journals/csur/Comer79}.\n%TODO citations\n%TODO relationship to other implementations (are there more?)\nGenerally, an element is inserted into the nodes on the lowest level.\nIn a first step, the element is simply placed at the correct\nposition in the list of separators.\nIf the node had enough space left prior to this operation,\nwe are done.\nIf however the node has more than $2k$ elements after this insertion,\nwe need to split it and, passing the median to the parent node,\nrecurse back upwards.\nWe will see in \\Cref{sec:abs-ins} how this can be\nelegantly expressed in a functional specification.\nMore detailed descriptions and examples of insertion and deletion may be found\nin \\parencite{DBLP:books/daglib/0023376}.\n%-------------------------------------------------\n\n% TODO delete\n% TODO move abstract discussion to introduction\n%-------------------------------------------------\n\\paragraph{Deletion}\\label{par:intro-del}\nOn deletion, elements are removed from the leaves only.\nIf the element to be deleted resides in an inner node,\nit is replaced by the maximal lesser or minimal greater\nelement in the tree, which always resides in a leaf\nto the left or right of the element to be removed.\n\nAfter deletion, the nodes may need rebalancing in order\nto ensure the order property.\nA node having less than $k$ elements is said to have \\textit{underflow}.\nThe exact procedure to handle underflow varies strongly in the literature.\nSince only one element is removed from the node,\nthe most intuitive solution to underflow is to \\textit{steal} or \\textit{borrow} it\nfrom the sibling to the left or right \\parencite{DBLP:books/daglib/0023376}.\nIf either sibling has more than $k$ elements,\none of the neighboring elements may be moved into the current node.\nOnly in the case that both siblings have only $k$ elements,\na kind of reversal of the insertion split is conducted:\n\nOne of the siblings and the node itself, together with the separating\nelement of the parent node are merged and the result split again to form\na new, bigger node of valid order.\n\nFollowing the description of Bayer \\parencite{DBLP:journals/acta/BayerM72},\nas done by Fielding \\parencite{Fielding80},\nthe two cases can be treated identically.\nIf a node has less than $k$ elements,\nmerge it with one of its siblings.\nIf the resulting node has an overflow again,\nit will be split in half, just as with insertion related overflows.\nAccording to Comer \\parencite{DBLP:journals/csur/Comer79} this may even be\nmore efficient than stealing single single keys from siblings.\nFirstly, the resulting node is less likely to underflow again.\nIf it had stolen only one element, another deletion from this node\nwill certainly cause another overflow.\nThis is not the case when several elements are copied over.\nFurther, the node to merge with been completely read from memory at the point\nof stealing an element.\nMerging does therefore not incur additional memory accesses and\nthe cost of inter-memory copy of up to $k$ elements is negligible.\n\n%-------------------------------------------------\n\n\\subsection{Properties}\n\nB-trees are assumed to be stored on external memory,\nsuch that each node roughly matches a page in main memory.\nIn real situations, this implies that the number of elements\nthat can be stored in each node, and hence also $k$, is huge, usually $\\gg 1000$.\nThe overall number of memory accesses for all tree operations\nis bounded by the depth of the tree,\nwhich again is logarithmic in the number of indices -\nwhere the base of the logarithm is closely proportional to the order $k$ of the tree.\nThis is due to the large branching factor and the guaranteed balancing.\nTogether, the data structure yields a very small number of required memory accesses\nfor retrieving and inserting data stay,\neven if the tree stores large amounts of data.\n\nFurthermore, by design, the storage usage of B-trees is at a minimum close to $50\\%$\nof the reserved memory,\nwhere the average usage is usually higher \\parencite{DBLP:journals/acta/BayerM72}.\nThis is achieved by ensuring that every node reserves the storage of $2k$ keys and separators.\nBy definition, the nodes (except for the root) always contain\nat least $k$ elements, yielding a storage usage of close to $50\\%$.\n\nThe above mentioned properties are key to the widespread popularity of B-trees.\nUsually the closely related structure of B$^+$-trees is used in applications,\nbeing especially popular for the implementation of databases.\nB-trees build the foundation to most modern relational database implementations \\parencite{DBLP:journals/csur/Comer79}.\nWe therefore made sure to represent the important aspects for the applicability\nof B-trees, little memory accesses and high storage usage, in our implementation.\n% TODO more\n\n\\section{Related Work}\n\nAll the related work we have found considered B$^+$-trees\nrather than B-trees.\nHowever, some parallels can be observed.\nThere exist two pen and paper proofs via the rigorous approach\nby Fielding \\parencite{Fielding80} and Sexton \\parencite{DBLP:journals/entcs/SextonT08}.\nEven though not machine checked, they shed light on techniques applied in this work.\n\nFielding approaches the verification by refinement.\nFirst, B$^+$-trees are viewed as nested sets of subtrees\nor as leafs that are sets of key-value pairs.\nObtaining the correct subtree for recursion is in the abstract setting\nonly defined by appropriate pre and post-condition\nand an actually executable function is provided in the second refinement step.\nOn this level, only arguments on the invariants are made.\nIn a second step B-trees are considered more concretely to contain\nsorted lists of children and keys.\nHere the argument for invariant preservation is informally\nthat the refined implementation\nhas the same structure as the abstract implementation.\nFinal imperative PASCAL code is given, derived by hand\nimitating the functional style implementations and extended by assertions.\n\nThis approach is similar to what will be done in this work,\nhowever mostly concerning the methodology rather than the actual\nsteps of refinement.\nIn this work, we will start at the definition using lists in \\Cref{chapter:abs-set}\nand refine to an imperative implementation with pointers and arrays in \\Cref{chapter:imp-set}.\nThe code we obtain will be exported automatically to a functional language of choice.\n\nWe reason about the validity of this refinement via separation logic,\nthe same tool that Sexton employed \\parencite{DBLP:journals/entcs/SextonT08}.\nTheir work shows that this tool allows to reason based on some kind of locality,\nin particular that operations on subtrees are really only affecting subtrees.\nWe will make implicit use of this property in \\Cref{chapter:imp-set}\nfor proofs on our imperative implementation.\n\nThe specification by Sexton is given as abstract machine rules,\nsomewhat more abstract than pure code but operating on a stack\nmuch like we expect imperative programs to operate with pointers on a heap.\nWe therefore categorize this as a direct verification of an imperative implementation.\n\nAmong imperative implementations, two machine checked proofs exist as well.\nIn the work of Ernst \\parencite{DBLP:journals/sosym/ErnstSR15},\nan imperative implementation is directly verified\nby combining interactive theorem proving \nwith shape analysis.\nThe main recursive procedures are interactively verified in KIV.\nData structure properties such as circle-freeness are then proven by shape-analysis.\nAnother direct proof on an imperative implementation \nwas conducted by Malecha \\parencite{DBLP:conf/popl/MalechaMSW10}, with the YNOT\nextension to the interactive theorem prover Coq.\nBoth works use recursively defined \"shape predicates\"\nthat describe formally how the nodes and pointers\nrepresent an abstract tree of finite height.\nIn the work of Malecha, these predicates are even specified functionally.\nHowever, we know of no verification that explicitly covers\na complete specification of functional B-trees and operations on it.\n\nIn addition to providing one, this work aims to show the benefits\nof taking an indirection via a complete functional specification\nto derive proofs for an imperative implementation.\nAmong others, these benefits are that the analysis of invariants of an abstract shape may be spared\nor at least significantly simplified when\nrestricting the concrete pointer structures to be refinements\nof an abstract algebraic type.\n\n\\section{Contributions}\n\nIn this work, we derive our own definition of B-trees\nby combining the original definition\nwith approaches that have resulted in verified implementations previously.\nBased on the definition, we specify the B-tree data structure in the\nfunctional modeling language HOL.\nThe specification is complemented by a proof of its correctness\nwith respect to refining a set of linearly ordered elements.\nAll proofs are machine-checked in the Isabelle/HOL framework,\nan interactive automated theorem prover \\parencite{DBLP:books/sp/NipkowK14}.\nWithin the framework,\nthe functional specification already yields automatic extraction of executable,\nbut inefficient code.\n\nUsing manual refinement, we derive an imperative implementation of the functional specification\nin Imperative/HOL.\nFor this purpose, we introduce static arrays with variable size\nand efficient copy and move operations on arrays.\nThe implementation is defined with respect to some abstract imperative\noperation for node-internal navigation.\nWe provide one such operation that employs linear search,\nand one that conducts binary search.\nAll imperative programs are shown to refine the functional specifications\nusing the separation logic utilities from the Isabelle Refinement Framework by\nLammich \\parencite{DBLP:journals/jar/Lammich19}.\n\nThis process results in a proof of the functional correctness\nof an imperative implementation of the B-tree data structure.\nThe implementation supports set membership and insertion queries\nand uses efficient binary search for intra-node navigation.\nAs with every specification in Imperative/HOL,\nautomatic executable code extraction to\nseveral functional programming languages is supported.\nIn addition, we provide a proof of the logarithmic relationship between height and number of nodes,\nreproducing results of Bayer \\parencite{DBLP:journals/acta/BayerM72}.\nThis verifies claims on the efficiency of\noperations on the tree.\n\nAll proofs, specifications and programs can be found in the appendix \\parencite{MuendlerAppendix21}.", "meta": {"hexsha": "3418302435e84e1892fc3a264b3b577cf4e732c5", "size": 25418, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/01_introduction.tex", "max_stars_repo_name": "nielstron/btrees-thesis", "max_stars_repo_head_hexsha": "14b6d8a4819378140e5a977e5278ae0a48057f6f", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/01_introduction.tex", "max_issues_repo_name": "nielstron/btrees-thesis", "max_issues_repo_head_hexsha": "14b6d8a4819378140e5a977e5278ae0a48057f6f", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/01_introduction.tex", "max_forks_repo_name": "nielstron/btrees-thesis", "max_forks_repo_head_hexsha": "14b6d8a4819378140e5a977e5278ae0a48057f6f", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5477582846, "max_line_length": 146, "alphanum_fraction": 0.7965221497, "num_tokens": 5569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4440679761516378}}
{"text": "%\\nomenclature[]{MLE}{Maximum Likelihood Estimate}\n%\\note{Make sure it's clear whether using random variables or not}\n%\\note{Might need to make clear Markov assumptions }\nAs discussed, HMMs and DBNs are useful tools for modelling complex random dynamic processes. Typically, models are used to provide some kind of inference about a process, to gain insight into its inner workings. By inference, we mean calculating the probability distributions over variables of interest. Some algorithms will be outlined here that will demonstrate how to calculate both exact and approximate inferences, using general structures for HMMs and DBNs. \\par\n\nFirst, inference algorithms commonly used with HMMs are discussed, as their representation is more rigid, meaning that it is easier to exploit their structure generally to perform inference. As previously stated, HMMs and DBNs are routinely used to model systems that have state variables that cannot be directly observed. In most cases, we are interested in inferring what the state of the system might be, given the observed evidence variables received. This is the first and arguably the most useful inference challenge that we inspect.\n\nThe actual quantity that we want to compute is \n\\[P(X_t | e_1, e_2, ..., e_t) = P(X_t | e_{1:t})\\]\nthat is, the probability distribution of the hidden state variable, given all previously observed evidence variables. The notation $e_{1:t}$ denotes the joint distribution of $e_1, e_2, ..., e_t$. We are interested in computing this value, rather than the unconditional state distribution, $P(X_t)$, because we cannot observe the state directly, but we can observe the evidence variables. The conditional distribution $P(X_t | e_{1:t})$ is frequently referred to as the \\textit{belief state} and the process of calculation of this distribution is frequently referred to as \\textit{state estimation} or \\textit{filtering} \\cite{AIAMA}, \\cite{Thrun:2005:ProbabilisticRobotics}, \\cite{KollerPGM}. The \\textit{forward algorithm} can be used to calculate the value of $P(X_t | e_{1:t})$ \\cite[p.~572]{AIAMA}. It is a recursive algorithm, and takes advantage of the fact that the underlying process is Markovian. The forward algorithm for HMMs is shown in Algorithm \\ref{alg:forwardAlgorithmHMMs} and is based on the algorithm outlined in \\cite[p.~27]{Thrun:2005:ProbabilisticRobotics}. The derivation is useful to follow as an exercise, so we present it in the subsequent sub-section.\n\\subsubsection{HMM Filtering Algorithm Derivation} \n\\label{section:HMMFiltering}\n\\note{Might be better to put this in an appendix.}\nTwo well-known probability identities are used in the derivation: \n\\note{Fix the formatting here}\n\\begin{center}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n\\end{center}\n%quad adds space\n\\[(a) \\quad p(A | B, C) = \\frac{p(B | A, C) p(A | C)}{p(B | C)} \\quad \\text{and} \\quad (b) \\quad p(A | B) = \\int\\limits_{C}P(A | B, C) P(C | B)dC\\]\n\n\\begin{center}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n\\end{center}\nThe derivation is as follows:\n\\begin{enumerate}\n\\item {$ p(X_t | e_{1:t}) = p(X_t | e_{1:t-1}, e_t) $ }\n\n\\item{$ \\text{applying (a) and letting} \\quad \\eta = \\frac{1}{p(e_t | e_{1:t-1})} \\quad = \\quad \\eta p(e_t | e_{1:t-1}, X_t)p(X_t|e_{1:t-1}) $ }\n\n\\item{$ \\text{by the Markov property} \\quad = \\quad \\eta p(e_t | X_t)p(X_t|e_{1:t-1})$}\n\n\\item{$\\text{applying (b)} \\quad =  \\quad \\eta p(e_t | X_t)\\int_{X_{t-1}}p(X_t|e_{1:t-1}, X_{t-1}) p(X_{t-1}|e_{1:t-1})dX_{t-1}$}\n\n\\item{$ \\text{by the Markov property} \\quad = \\quad \\eta p(e_t | x_t)\\int_{X_{t-1}}p(X_t|X_{t-1}) p(X_{t-1}|e_{1:t-1})dX_{t-1} $}\n\n\\end{enumerate}\nNote that $\\eta$ is a normalizing constant that ensures that the probability distribution integrates to 1, and that the probabilities that need to be calculated can be done so from the parameters specified in the HMM; namely $p(e_t | X_t)$, specified by the sensor model, and $p(X_t | x_{t-1})$, specified by the transition model.\n\n\\begin{algorithm}{}\n\\caption{Forward Algorithm for HMMs}\n\\label{alg:forwardAlgorithmHMMs}\n\n\\begin{algorithmic}[1]\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}}\n%Input\n\\REQUIRE $\\newline P(x_{t-1} | e_{1:t-1})=bel(x_{t-1}): \\quad \\text{The belief distribution as far as the previous time-step}\n\\newline e_t: \\quad \\text{The most recent observation}\n\\newline hmm: \\quad \\text{A Hidden Markov Model specifying the transition and observation probabilities,} \\newline p(X_t | x_{t-1}) \\text{ and } p(E_t | x_t)$\n%Output\n\\ENSURE  $\\newline P(X_{t} | e_{1:t}) = bel(X_{t})$\n\n\\hfill\\pagebreak\n\n\\FOR{all $x_t$}\n\\STATE $\\overline{bel}(x_t) = \\int p(x_t | x_{t-1}) p(x_{t-1} | e_{1:t-1}) d x_{t-1}$\n\\STATE $bel(x_t) = p(e_t | x_t) \\overline{bel}(x_t)$\n\\ENDFOR\n\\STATE $ \\eta = 1 / \\int_{x_t}{bel(x_t)}dx_t$\n \\FOR{all $x_t$ do:}\n\\STATE $bel(x_t) = \\eta{bel}(x_t)$\n\\ENDFOR  \n    \n%\\ENDWHILE\n\\RETURN $bel(X_t)$\n\\end{algorithmic} \n\\end{algorithm}\n\n\\note{Don't forget to mention: Sufficient statistics, forward algorithm}\n\nAlgorithm \\ref{alg:forwardAlgorithmHMMs} uses integrals to account for the fact that the distribution of the hidden state, $X_t$, may be continuous. The work done in this thesis only uses discrete distributions, and so summations are used instead of integrals for the subsequent discussion. A consequence of using discrete distributions is that it is possible to formulate the forward algorithm using vector and matrix notation. As outlined in Section \\ref{subsec:BGHMM}, the transition model $T=p(X_t | X_{t-1})$ for a HMM can be written down in matrix form, as can the observation model $O_t=p(E_t | X_T)$. This allows for a highly compact notation: denoting $p(x_t | e_{1:t})$ as $f_{1:t}$, we can write $f_{1:t} = \\eta O_{t} T^{T} f_{1:t-1}$, where $f_{1:t}$ contains the vector of values of $p(x_t | e_{1:t})$ for every possible $x_t$ \\cite[p.~579]{AIAMA}. Note that the observation model, $O_t$ is time dependent, as opposed to the transition model, which is assumed to be stationary. \\par\n\nSome insight can be gained from studying Algorithm \\ref{alg:forwardAlgorithmHMMs}. There are three main steps to this algorithm, and the intuition behind them is explained based on explanations in \\cite{AIAMA}, \\cite{Thrun:2005:ProbabilisticRobotics} and \\cite{Murphy1994DynamicLearning}: \n\\note{These are highly verbose, edit to make less wordy}\n\\begin{enumerate}\n    \n    \\item The first step is often referred to as the prediction step:\n    \\begin{center}\n    $\\overline{bel}(x_t) = \\sum_{x_{t-1}} p(x_t | x_{t-1}) p(x_{t-1} | e_{1:t-1}) d x_{t-1}$\n    \\end{center}\n\n    This step carries out the first part of the calculation of the belief value for a given state $x_t$, by marginalizing over all possible hidden states ($x_{t-1}$) that could have preceded the current one ($x_t$). This reflects intuition: the probability of being in state $x_t$ should depend on the probability of transitioning from all possible previous states to $x_t$. \n    %\\note{this sentence doesn't seem necessary}\n    Think \"\\textit{the probability that I am in location x is the sum of probabilities of starting at all other possible locations and subsequently ending up in location x, weighted against my belief that I began in each other possible location}\".\n    \n    %product of our most recent belief of being in state $x_{t-1}$, given by $p(x_{t-1} | e_{1:t-1})$ and the probability of transitioning from that state to state $x_{t}$, for all previous possible states that we could have been in. \n    $\\overline{bel}(x_t)$ effectively projects our current belief to the next time step by using the transition probabilities specified in the HMM.\n    \n    \\item The second step is often referred to as the correction step, or the measurement update step: \n    \\begin{center}\n    $bel(x_t) = p(e_t | x_t) \\overline{bel}(x_t)$ \n    \\end{center}\n    This step takes the projected belief in step 1 and multiplies it by the probability of observing the data that we did in the given hidden state, $x_t$. This can be thought of as a correction because the use of the measurement data narrows the probabilities of the possible states that the system could have transitioned to. \n    \\note{Need to re-word this to make more concise}\n    %For example, if the value of a transition probability from state x to state y is low, and there is a low probability that the system was previously in state x, a high probability of observing the observed sensor reading given state y can still result in a relatively high posterior probability of the system being in state y given the new evidence.\n    \n    \\item The final step is to ensure that the distribution sums to 1. This is done by multiplying by a normalizing constant, $\\eta$.\n    \n    \n\\end{enumerate}\nA key strength of this algorithm is the fact it allows updates to be performed online. The reason for this is that the information-state vector, $p(x_t | e_{1:t})$ is a sufficient statistic for the past history of observations. For a full proof of this property, the reader is referred to Appendix A of \\cite{Smallwood1973TheHorizon}, which also provides insight into the update rule itself. In relation to the update rule, note that an initial distribution of the estimated state must be provided to this algorithm before the first update can be performed. The complexity of the forward algorithm is $\\theta (nm^2)$, where m is the size of the joint distribution of the hidden variables, x, and n is the number of time-steps that have occurred. This is clear to see when viewing the update as the matrix-vector multiplication $f_{1:t} = \\eta O_{t} T^{T} f_{1:t-1}$, as the size of T is $m^2$.\n\n\n\n\n\n\n\\subsubsection{Evidence Likelihood Algorithm Using a HMM}\\label{subsubsec:EvLikelihood}\n\\note{Will talk about this briefly for SPRT}\nThe second useful quantity that we would like to calculate is the probability of observing the evidence that we did, often referred to the likelihood function of the data, as identified in Section \\ref{subsec:BGHMM}. In simpler terms, this is the calculation of the probability of observing the data, given a fixed parameterised model of the data (the HMM). This value is useful as it can reveal insights into whether one model is more likely than another model, with applications including \\textbf{M}aximum \\textbf{a} \\textbf{P}osteriori (MAP) parameter estimates and hypothesis testing. It is used in this thesis in Section \\ref{subsubsec:SeachTerminationMethodology}. We would like to compute the value of\n\\[P(e_1, e_2, ..., e_t) = P(e_{1:t})\\]\ngiven the fixed set of parameters provided by the HMM. A brief outline of the derivation is shown:\\note{might be best to put the derivation in an appendix} \n\n\n\\subsubsection{HMM Evidence Likelihood Algorithm Derivation}\\label{subsubsec:BGEvidenceLikelihood}\n\nAnalogous to the filtering algorithm derivation, two well-known probability identities are used in the derivation: \n\\begin{center}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n\\end{center}\n%quad adds space\n\\[(a) \\quad p(A, B, C) = p(A | B, C) p(B, C) \\quad \\text{and} \\quad (b) \\quad p(A, B) = \\sum_{C}{p(A | B, C)p(B, C)}\\]\n\n\\begin{center}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n\\end{center}\n\nThe derivation is as follows:\n\\begin{enumerate}\n\n\\item {$p(e_{1:t}) = \\sum_{x_t}p(e_{1:t}, x_t) \\quad = \\quad \\sum_{x_t}p({e_{1:t-1}, e_t, x_t}) $\n}\n\\item {$\\text{applying (a) } \\quad= \\quad\n\\sum_{x_t}{p(e_t | e_{1:t-1}, x_t)p(x_t, e_{1:t-1})}$\n}\n\\item{$\\text{by the Markov property} \n\\quad = \\quad \\sum_{x_t}p(e_t | x_t)p(x_t, e_{1:t-1})$\n}\n\n\\item{$\\text{applying (b)} \\quad =  \\quad\n\\sum_{x_t}p(e_t | x_t) \\sum_{x_{t-1}}p(x_t|e_{1:t-1}, x_{t-1}) p(x_{t-1},e_{1:t-1})$\n}\n\n\\item{$\\text{by the Markov property} \\quad = \\quad \n\\sum_{x_t}{p(e_t | x_t)\\sum_{x_{t-1}}p(x_t|x_{t-1}) p(x_{t-1},e_{1:t-1})}$\n}\n\n\\end{enumerate}\n\nThe algorithm for calculating likelihoods uses the forward algorithm, $\\alpha$, with the replacement of  $p(x_{t-1}|e_{1:t-1})$ with $p(x_{t-1}, e_{1:t-1})$ and one final summation. This means that it is possible to use the forward algorithm to calculate likelihoods: $p(e_{1:t}) = \\sum_{i=1}^{n} \\alpha(x_i, e_i)$, where $\\alpha(x, e)$ is the result of applying the forward algorithm to the sequence of evidence variables $(e_1, ..., e_t)$.\n\n\n%No point in writing up likelihood algorithm as it's very similar to forward algorithm.\n\n%\\subsubsection{HMM Parameter Learning Using Expectation Maximization}\\label{subsubsec:EMAlgo}\n%\\note{Can talk about this briefly for battery model}\n%Since a HMM is a parameterised model of a stochastic process, a natural question to ask is whether it is possible to determine a \\textit{\"best\"} set of parameters to describe the process, by using observations of the process. This is a more complex version of the well-known process of finding the parameters that maximize the likelihood function of fully observable data, known as the \\textbf{M}aximum \\textbf{L}ikelihood \\textbf{E}stimate (MLE). Finding the most likely set of parameters which provided the observed values can be described mathematically as the value of \\note{fix argmax notation}$\\argmax_{\\lambda} P(E_{1:t} | \\lambda)$. Note that this is a fundamentally different problem to that discussed in the preceding section; here we do not assume a fixed set of parameters for the HMM ($\\lambda$).\n\n%This is a well-studied problem for HMMs and the solution is given by the \\textbf{E}xpectation \\textbf{M}aximisation (EM) algorithm, proposed by \\citeauthor{Dempster1977MaximumAlgorithm}. This algorithm is reasonably complex and highly detailed overviews can be found in many texts that deal with parameter estimation for statistical models. A quick outline of how the algorithm works is provided here.\\par\n\n\n%The reason why the standard methods for finding the MLE for a parameterised model do not work with HMMs is due to the fact that there is no way to directly express the quantity  $P(E_{1:t} | \\lambda)$ directly. This can be seen in the derivation of the evidence likelihood in <reference whichever appendix it ends up in>. Instead, it is necessary to marginalize over states: $ P(e_{1:t} | \\lambda) = \\sum_{x_t}{p(x_t, e_{e:t} | \\lambda)}$. The standard approach to finding the parameters that maximize a model is to take a log transform of the likelihood function, which preserves the solution but turns the problem into one of finding the parameters that maximize a sum rather than a product. Using standard methods of calculus, this can usually be done easily. The issue with HMMs is that when a logarithmic transformation is applied to the likelihood function, the summation sign remains within the log function, which means finding the maximum is still a difficult problem. The EM algorithm, taking the approach of many iterative techniques, relaxes the constraints on the problem in order to find a lower bound of the log-likelihood and then iteratively improves this lower bound with increasing likelihood values. \n\n\n%The Baum-Welch algorithm is a special case of the EM algorithm and is frequently used to solve the problem of estimating the parameters of a HMM. The algorithm is described fully in appendix <reference appendix>.\n\n\n\\subsubsection{Filtering Algorithm for DBNs}\\label{subsubsec:filteringDBN}\n\\note{Extend HMM to add control variable}\n\\begin{wrapfigure}{r}{0.68\\textwidth}\n    \\centering\n    \\includegraphics[width = 0.68\\textwidth]{Chapters/BackgroundKnowledgeAndRelatedWork/MultiAgentTargetDetectionBackground/Figs/HMMs/HMMWithControl.png}\n    \\caption{A DBN with Hidden State variables (grey), Observation variables (orange) and Control variables (green).}\n    \\label{fig:HMMWithControlVariablesExample}\n\\end{wrapfigure}\nThe forward algorithm for state estimation was presented in Section \\ref{section:HMMFiltering}. A slightly modified version of this algorithm is now described, which is very commonly used in stochastic systems that can be influenced by actions that an agent may take. Such systems have \\textit{control variables} as well as hidden state variables and observation variables. These control variables (variables which represent the actions that an agent may perform) have an influence on the transition probabilities between states. The graphical model in Figure \\ref{fig:HMMWithControlVariablesExample} describes the basic case. The arrows describe the conditional independence assumptions: at time t, the hidden state ($x_t$) depends on the previous state ($x_{t-1}$), and the previous control action taken ($u_t$). As with the HMM, the observation $e_t$ is conditionally dependent on the state $x_t$. This causes a slight change in the filtering algorithm: on line 2 of algorithm \\ref{alg:forwardAlgorithmHMMs}: $\\overline{bel}(x_t) = \\sum_{x_{t-1}} p(x_t | x_{t-1}) p(x_{t-1} | e_{1:t-1}) $ is replaced with $\\overline{bel}(x_t) = \\sum_{x_{t-1}} p(x_t | u_t, x_{t-1}) p(x_{t-1} | e_{1:t-1}, u_{1:t-1})$, reflecting that transition probabilities now depend on the most recent control action taken, as well as the previous state.\n\n\n%DBNs have already been shown to be a powerful tool while modelling stochastic systems, since the hidden variables can be described by conditional independences, rather than \n\n\n\n%This algorithm can be further generalized - if multiple control variables, hidden state variables and observation variables are needed to describe the system fully, it is possible to make minor modifications which reflect the conditional independences stated by the underlying DBN by .\n\nIt is worth noting that there are many filtering algorithms that deal with data that come from certain distributions and satisfy constraints related to their transition and observation models, for example the Kalman Filter \\cite[p.~43]{Thrun:2005:ProbabilisticRobotics}.\n\n\n\n\n\n\n%\\subsubsection{Discrete Bayes Filter}\n%\\note{This is what is used in the work that I did, so it is outlined}\n\n\\subsubsection{Approximate State Estimation}\n\\note{Thought about using Particle filter to avoid the dimensionality problem when attempting to maintain estimated state}\nThe state estimation algorithms mentioned so far maintain the exact values of the distribution $p(x_t | e_{1:t}, u_{1:t})$, but we will quickly mention an approximate method that is also frequently used. The computational complexity of the filtering algorithms is determined by how well the joint distribution of hidden state variables, observation variables and control action variables can be factored, but in the worst case the complexity is given by the case where the joint distribution of the hidden state variables cannot be factored at all. The forward algorithm, described in Algorithm \\ref{alg:forwardAlgorithmHMMs} for a HMM performs the update from each time state in O($n^2$), where $n$ is the dimension of the hidden state variable \\cite{Smyth1997ProbabilisticModels}.\n%$O(n^2ut)$, where n are the number of hidden states, u is the number of available control actions and t is the number of time steps.\nIn some cases, this can become intractable if the state space is large enough. % and the transition model cannot be factored. \nIn this case, approximate techniques are used. An example is the \\textit{particle filter}. Details of the particle filter can be found in \\cite[p.~96]{Thrun:2005:ProbabilisticRobotics} and \\cite[p.~665]{KollerPGM}.\n", "meta": {"hexsha": "bcde1cb1b0b8af72c71c17968a0387a6c810c50f", "size": 19579, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/BackgroundKnowledgeAndRelatedWork/MultiAgentTargetDetectionBackground/InferenceAlgorithms.tex", "max_stars_repo_name": "DavidLSmyth/ResearchMScThesis", "max_stars_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/BackgroundKnowledgeAndRelatedWork/MultiAgentTargetDetectionBackground/InferenceAlgorithms.tex", "max_issues_repo_name": "DavidLSmyth/ResearchMScThesis", "max_issues_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-06-18T11:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-18T11:59:42.000Z", "max_forks_repo_path": "Chapters/BackgroundKnowledgeAndRelatedWork/MultiAgentTargetDetectionBackground/InferenceAlgorithms.tex", "max_forks_repo_name": "DavidLSmyth/ResearchMScThesis", "max_forks_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.9257425743, "max_line_length": 1328, "alphanum_fraction": 0.7369630727, "num_tokens": 5298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.44406797144322147}}
{"text": "\\documentclass[12pt, letterpaper]{article}\n\\include{eu}\n\n\\newcommand{\\escape}{\\mathrm{escape}}\n\n\\begin{document}\n\n\\section*{\\textsl{Einstein's Universe} Problem Set 6}\n\nThis problem set is not to be handed in for credit. But it is due\nbefore \\textbf{Thursday December 9}, when some of these problems\nwill appear in part, near-verbatim, on Term Exam 6.\n\n\\begin{problem}\nThe formula for escape velocity $v_{\\escape}$ from the surface of the Earth\nis\n\\begin{equation}\n\\frac{1}{2}\\,v_{\\escape}^2 - \\frac{G\\,M}{R} = 0\n\\quad,\n\\end{equation}\nwhere $G$ is Newton's constant, $M$ is the mass of the Earth, and $R$\nis the radius of the Earth.\nNow imagine that the Earth was compressed into a sphere so small that\nthis escape velocity became the speed of light! That's a proposal for what\nmakes a black hole. What would be the radius of that small sphere?\nNow look up the true formula for the radius of a black hole and compare\nyour answer to the true answer.\n\nIf you make $M$ the mass of the Sun, and $R$ the radius (1\\,AU) of\nEarth's orbit around the Sun, then the velocity you compute is the\nescape velocity from the Earth's orbit to outside the Solar System!\nThis is the velocity at which the {\\small NASA} \\textsl{Voyager} probes had to\nbe launched.\nHow massive would the Sun have to be for the escape velocity at 1\\,AU\nto be the speed of light? You can use either the equation above, or\nelse the true formula for a black hole.\nGive your answer in kg, and also in Solar masses.\n\\end{problem}\n\n\\begin{problem}\nThe \\textsl{\\small LIGO} discovery of the neutron-star-merger system\n{\\small GW170817} gave an opportunity to measure the speed of\ngravitational waves (GWs), because the discovered event had both a\nlight signal (a flash) and a GW signal (a chirp).\nLook up the distance to this event.\nNow imagine that GWs travel more slowly than the speed of light.\nHow much slower than the speed of light would GWs have to travel for\nthe two signals to arrive at Earth separated by 10 seconds?\nExpress your answer as a dimensionless fraction:\nThat is, what is the ratio of 10 seconds to the travel time of light from\nthe event to us?\n\\end{problem}\n\n\\begin{problem}\nAt the center of the Milky Way, there is a star called {\\small S2}\norbiting a supermassive black hole (called Sag A$\\ast$).\nThe star orbits the black hole with a period of 16\\,yr, on an orbit\nthat has a mean radius (semi-major axis) of 1000\\,AU.\nPlug these numbers into the classic Kepler--Newton formula for orbital\nperiod $T$ given semi-major axis $a$ to estimate the mass of the black\nhole.\n\\begin{equation}\nT^2 = \\frac{4\\,\\pi^2}{G\\,M}\\,a^3\n\\end{equation}\nYou might have to do some unit conversions!\nGive your answer in kg, and also in Solar masses.\n\nAlso compute the mean orbital velocity $v$ of the star using\n\\begin{equation}\nv \\approx \\frac{2\\,\\pi\\,a}{T}\n\\end{equation}\nDo you think the non-relativistic Kepler formula is very wrong in this\ncase? Why or why not?\n\\end{problem}\n\n\\begin{problem}\nWhen a black hole of mass $M_1$ merges with a black hole of mass $M_2$,\nit creates a new black hole of mass $M_3$. Do you expect $M_3$ to be\nequal to, less than, or more than, the sum $M_1 + M_2$? Recall mass--energy\nequivalence and the fact that there is gravitational radiation emitted as\nthey merge.\n\nNow look up the first \\textsl{\\small LIGO} discovery {\\small GW150914} and\nlook up $M_1, M_2, M_3$ for this discovery. Are you right?\n\\end{problem}\n\n\\end{document}\n", "meta": {"hexsha": "5692371e96cec2154a266d23df70ce7d787f3464", "size": 3421, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/ps6.tex", "max_stars_repo_name": "davidwhogg/EinsteinsUniverse", "max_stars_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/ps6.tex", "max_issues_repo_name": "davidwhogg/EinsteinsUniverse", "max_issues_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-08-24T19:50:27.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-30T01:39:39.000Z", "max_forks_repo_path": "tex/ps6.tex", "max_forks_repo_name": "davidwhogg/EinsteinsUniverse", "max_forks_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.875, "max_line_length": 78, "alphanum_fraction": 0.7524115756, "num_tokens": 955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604274, "lm_q2_score": 0.8006920020959544, "lm_q1q2_score": 0.4439600666922393}}
{"text": "\\section{Custom commands}\n\n\\begin{frame}[fragile]{Simple macros}\n  Used to simplify repetitive and/or complex formatting.\n\n  Usually specified in the preamble\n  \\begin{lstlisting}\n\\newcommand{\\name}{definition}\n  \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Simple macros: an example}\n  \\begin{lstlisting}\n\\newcommand{\\R}{\\mathbb{R}}\n\nThe set of real numbers are usually represented\nby a blackboard capital r: $\\R$.\n  \\end{lstlisting}\n\n  The set of real numbers are usually represented by a blackboard capital r:\n  $\\R$.\n\\end{frame}\n\n\\begin{frame}[fragile]{Macros with parameters}\n  Macros can also be constructed to accept parameters:\n  \\begin{lstlisting}\n\n\\newcommand{\\name}[# params]{definition}\n  \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Macros with parameters: an example}\n  \\begin{lstlisting}\n\\newcommand{\\bb}[1]{\\mathbb{#1}}\n\nOther numerical systems have similar notations. \nThe complex numbers $\\bb{C}$, the rational \nnumbers $\\bb{Q}$ and the integer numbers\n$\\bb{Z}$.\n\n  \\end{lstlisting}\n  Other numerical systems have similar notations. The complex numbers $\\bb{C}$,\n  the rational numbers $\\bb{Q}$ and the integer numbers $\\bb{Z}$.\n\\end{frame}\n\n\\begin{frame}[fragile]{Macros with default parameters}\n  It is also possible to define macros which take default parameters:\n  \\begin{lstlisting}\n\\newcommand{\\name}[# params][default #1]{def.}\n\n  \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Macros with default parameters}\n  \\begin{lstlisting}\n\\newcommand{\\plusbinomial}[3][2]{(#2 + #3)^#1}\n\nWe make a new command to save time writing\nexpressions of the form $\\plusbinomial{x}{y}$\nand $\\plusbinomial[4]{a}{b}$.\n\n  \\end{lstlisting}\n  We make a new command to save time writing expressions of the form\n  $\\plusbinomial{x}{y}$ and $\\plusbinomial[4]{a}{b}$.\n\\end{frame}\n\n\\begin{frame}[standout]\n  \\href{https://jwalton.info/assets/teaching/latex/exercise_2.pdf}%\n  {\\color{white}Exercise 2}\n\\end{frame}\n\n", "meta": {"hexsha": "7cb5401db8378f4027a44d426ca2094eb7fdc2ea", "size": 1934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/sections/macros.tex", "max_stars_repo_name": "jwalton3141/sage_latex", "max_stars_repo_head_hexsha": "6aed684ad18d4d7b7ae19bb60f99f03b5d95006d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-28T18:58:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-28T18:58:17.000Z", "max_issues_repo_path": "slides/sections/macros.tex", "max_issues_repo_name": "jwalton3141/latex_course", "max_issues_repo_head_hexsha": "6aed684ad18d4d7b7ae19bb60f99f03b5d95006d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-10-13T20:42:56.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-14T13:52:58.000Z", "max_forks_repo_path": "slides/sections/macros.tex", "max_forks_repo_name": "jwalton3141/sage_latex", "max_forks_repo_head_hexsha": "6aed684ad18d4d7b7ae19bb60f99f03b5d95006d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8611111111, "max_line_length": 79, "alphanum_fraction": 0.7254395036, "num_tokens": 561, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.44395897912480914}}
{"text": "\\section{Mod $\\cC$ Hurewicz, Whitehead, cohomology spectral\nsequence}\\label{mod-c-hurewicz}\nWe had $\\cC_{fg}$ and $\\cC_{tors}$, and\n$$\n\\cC_\\cP = \\{A|\\ell:A\\xrightarrow{\\simeq} A,\\ell\\not\\in\\cP\\},\\quad \\cC_p = \\cC_{\\{p\\}},\\quad \\cC_{p^\\prime} = \\cC_{\\text{not }p}\n$$\nAnother one is $\\cC_{p^\\prime}\\cap \\cC_{tors}$, which consists of torsion groups such that $p$ is an isomorphism on $A$.\nThere is therefore no $p$-torsion, and it has only prime-to-$p$ torsion.\nThis is the same thing as saying that $A\\otimes\\Z_{(p)} = 0$.\n\\begin{theorem}[Mod $\\cC$ Hurewicz]\n    Let $X$ be simply connected and $\\cC$ a Serre class such that $A,B\\in\\cC$ implies that $A\\otimes B,\\Tor_1(A,B)\\in \\cC$ (this is axiom 2).\n    Assume also that if $A\\in\\cC$, then $H_j(K(A,1)) = H_j(BA)\\in\\cC$ for all $j>0$.\n    (This is valid for all our examples, and is what is called Axiom 3.)\n\n    Let $n\\geq 1$.\n    Then $\\pi_i(X)\\in\\cC$ for any $1<i<n$ if and only if $H_i(X)\\in\\cC$ for any $1<i<n$,\n    and $\\pi_n(X)\\to H_n(X)$ is a mod $\\cC$ isomorphism.\n\\end{theorem}\n\\begin{example}\n    For $1<i<n$, the group $\\widetilde{H}_i(X)$ is:\n    \\begin{enumerate}\n\t\\item torsion;\n\t\\item finitely generated;\n\t\\item finite;\n\t\\item $-\\otimes \\Z_{(p)} = 0$\n    \\end{enumerate}\n    if and only if $\\pi_i(X)$ for $1<i<n$.\n\\end{example}\n\\begin{proof}\n    Look at $\\Omega X\\to PX \\to X$.\n    Then $\\pi_1 \\Omega X\\in\\cC$.\n    Look at Davis+Kirk.\n\\end{proof}\nThere's a Whitehead theorem that comes out of this, that I want to state for you.\n\\begin{theorem}[Mod $\\cC$ Whitehead theorem]\n    Let $\\cC$ be a Serre class satisfying axioms 1, 2, 3, and:\n    \\begin{enumerate}\n\t\\item[($2^\\prime$)] $A\\in\\cC$ implies that $A\\otimes B\\in\\cC$ for any $B$.\n    \\end{enumerate}\n    This is satisfied for all our examples except $\\cC_{fg}$.\n\n    Suppose I have $f:X\\to Y$ where $X,Y$ are simply connected.\n    Suppose $\\pi_2(X)\\to \\pi_2(Y)$ is onto.\n    Let $n\\geq 2$.\n    Then $\\pi_i(X)\\to \\pi_i(Y)$ is a $\\cC$-isomorphism for $2\\leq i\\leq n$ and is a $\\cC$-epimorphism for $i=n$,\n    with the same statement for $H_i$.\n\\end{theorem}\nThese kind of theorems help us work locally at a prime, and that's super.\nYou'll see this in the next assignment, which is mostly up on the web.\nYou'll also see this in calculations which we'll start doing in a day or two.\n\nChange of subject here.\nToday I'm going to say a lot of things for which I won't give a proof.\nI want to talk about cohomology sseq.\n\\subsection{Cohomology sseq}\nWe're building up this powerful tool using spectral sequences.\nWe saw how powerful the cup product was, and that is what cohomology is good for.\nIn cohomology, things get turned upside down:\n\\begin{definition}\n    A \\emph{decreasing filtration} of an object $A$ is\n    $$A\\supseteq\\cdots\\supseteq F^{-1} A\\supseteq F^0 A \\supseteq F^1 A\\supseteq F^2 A\\supseteq \\cdots\\supseteq 0$$\n    This is called ``bounded above'' if $F^0 A = A$.\n    Write $\\gr^s A = F^sA/F^{s+1}A$.\n\\end{definition}\n\\begin{example}\n    Suppose $X$ is a filtered space.\n    So there's an increasing filtration $\\emptyset=F_{-1}X\\subseteq F_0X\\subseteq\\cdots$.\n    Let $R$ be a commutative ring of coefficients.\n    Then I have $S^\\ast(X)$, where the differential goes up one degree.\n    Define\n    $$F^s S^\\ast(X) = \\ker(S^\\ast(X)\\to S^\\ast(F_{s-1}X))$$\n    For instance, $F^0 S^\\ast(X) = S^\\ast(X)$.\n    Thus this is a bounded above decreasing filtration \\todo{My computer will run out of juice soon, \\TeX this up later!}.\n\\end{example}\n\\begin{example}\n    Let $X=E\\xrightarrow{\\pi}B = \\text{ CW-complex}$ with $\\pi_1(B)$ acting trivially on $H_t(F)$.\n    Then $F_s E = \\pi^{-1}(\\mathrm{sk}_s B)$.\n    Thus I get a filtration on $S^\\ast(E)$, and\n    $$\n    F^s H^\\ast(X) = \\ker(H^\\ast(X)\\to H^\\ast(F_{s-1}X))\n    $$\n\\end{example}\nDoing everything the same as before, we get a \\emph{cohomology spectral sequence}.\nHere are some facts.\n\\begin{enumerate}\n    \\item First, you have $E_r^{s,t}$ (note that indices got reversed).\n\tThere's a differential $d_r:E^{s,t}_r \\to E_r^{s+r,t-r+1}$, so that the total degree of the differential is $1$.\n    \\item You discover that\n\t$$\n\tE^{s,t}_2 \\simeq H^s(B;H^t(F))\n\t$$\n    \\item and $E^{s,t}_\\infty \\simeq \\gr^s H^{s+t}(E)$.\n    \\item \n\\end{enumerate}\n", "meta": {"hexsha": "df57b08a60f786eca9c8c131d3a6673fba263f6e", "size": 4224, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "906/lec-66-mod-C-hurewicz.tex", "max_stars_repo_name": "ichung/algtop-notes", "max_stars_repo_head_hexsha": "3f5d3189e2082716a69fccc1711d02ed848552d2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-04-26T15:00:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-27T22:47:06.000Z", "max_issues_repo_path": "906/lec-66-mod-C-hurewicz.tex", "max_issues_repo_name": "ichung/algtop-notes", "max_issues_repo_head_hexsha": "3f5d3189e2082716a69fccc1711d02ed848552d2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-03-13T17:54:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-13T17:59:46.000Z", "max_forks_repo_path": "906/lec-66-mod-C-hurewicz.tex", "max_forks_repo_name": "ichung/algtop-notes", "max_forks_repo_head_hexsha": "3f5d3189e2082716a69fccc1711d02ed848552d2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-10-21T18:15:11.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-13T17:38:04.000Z", "avg_line_length": 44.4631578947, "max_line_length": 141, "alphanum_fraction": 0.6548295455, "num_tokens": 1520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.44395896502611676}}
{"text": "\\documentclass[aps,pra,notitlepage,amsmath,amssymb,letterpaper,12pt]{revtex4-1}\n\\usepackage{amsthm}\n\\usepackage{graphicx}\n\n\n\\newenvironment{problem}[2][Problem]{\\begin{trivlist}\n\\item[\\hskip \\labelsep {\\bfseries #1}\\hskip \\labelsep {\\bfseries #2.}]}{\\end{trivlist}}\n\\newenvironment{solution}{\\begin{proof}[Solution]}{\\end{proof}}\n \n\n \n\\begin{document}\n \n\\title{Classwork 13: George and Moana but In LaTeX}\n\\author{Morgan Holve}\n\\affiliation{MATH 220, Schmid College of Science and Technology, Chapman University}\n\\date{\\today}\n\n\\maketitle\n\n\\section{Introduction} \nThe goal of this is to basically put everything from Classwork 12 and Homework 12 into LaTeX. Allow me to restate everything from those Jupyter notebooks into this:\n\n\\vspace{5mm}\nWe are considering a ball of mass $m$ rolling in a double-well potential (whatever that is) of $V(x) = x^4/4 - x^2/2$. This potential is unaptly called the \"sombrero potential\" despite its likeness toward stingrays. \n\n\\vspace{5mm}\nTaking physics things into account and also remembering that the ball must follow Newton's Second Law, we obtain the equation:\n$$m\\ddot{x} = f_{\\text{hat}}(x) + f_{\\text{drag}}(\\dot{x}) + f_{\\text{drive}}(t) = x - x^3 - \\nu \\dot{x} + F\\cos(\\omega t)$$\nWhich can be split into the system of differential equations:\n$$\\dot{x}(t) = y(t)$$\n$$m\\dot{y}(t) = -\\nu y(t) + x(t) - x^3(t) + F\\cos(\\omega t)$$\nHere, we will solve these using the Runge-Kutta 4th Order method outlined in the past two classworks, taking $m = 1$, $\\omega = 1$ and $\\nu = .25$. We'll graph our results and then see what everything means. \\par\n\\noindent\nReminder of the method:\n$u_{k+1} = u_k + (K_1 + 2K_2 + 2K_3 + K_4)/6$, \n   \n   with\n   \n   $K_1 = \\Delta t\\,f[t_k,u_k]$, \n   \n   $K_2 = \\Delta t\\, f[t_k + \\Delta t/2, u_k + K_1/2]$, \n   \n   $K_3 = \\Delta t\\, f[t_k + \\Delta t/2, u_k + K_2/2]$, \n   \n   $K_4 = \\Delta t\\,f[t_k + \\Delta t, u_k + K_3]$  \n   \n\n\\section{Implementation}\nWe solved the differential equation each for different $F$ values and initial conditions.\n\n\\subsection{Varying Intial Conditions}\nWhen our code was implemented, the following figures were produced for the different initial conditions.\n\n\\begin{figure}[h!] \n  \\includegraphics[width=0.4\\textwidth]{frame02.jpg}  \n  \\caption{Initial Conditions: $F = 0.18$, $t\\in[0,2\\pi\\, 50]$, with $x(0) = 0.9$ and $y(0) = 0$; Scatter Plot}\n  \\label{fig:figlabel}\n\\end{figure}\n\n\\begin{figure}[h!] % h forces the figure to be placed here, in the text\n  \\includegraphics[width=0.4\\textwidth]{frame04.jpg}  % if pdflatex is used, jpg, pdf, and png are permitted\n  \\caption{Initial Conditions: $F = 0.25$, $t\\in[0,2\\pi\\, 50]$, with $x(0) = 0.2$ and $y(0) = 0.1$}\n  \\label{fig:figlabel}\n\\end{figure}\n\n\\section{Analysis}\nNow, what do these graphs mean? To do this, we look at the relative density of the lines on each side of the graph. For Figure 1, we see that both the left and right sides of the figure are balanced, meaning the ball moved uniformly and evenly in between the wells. However, in Figure 2, we see that the right side is obviously favored over the left, meaning the ball spend more time in the rightmost well rather than the left. \\par\n\\noindent\nFor your viewing pleasure, here is the Moana graph because I'm a little obsessed with it.\n\\begin{figure}[h!] % h forces the figure to be placed here, in the text\n  \\includegraphics[width=0.4\\textwidth]{frame03.jpg}  % if pdflatex is used, jpg, pdf, and png are permitted\n  \\caption{See the light as it shines on the sea, it calls me. And no one knows how far it goes. If the wind in my sail on the sea stays behind me, I know one day I'll find the way.}\n  \\label{fig:figlabel}\n\\end{figure}\n\\end{document}\n", "meta": {"hexsha": "04fca19102b63e1e9357ffdf44b2dc6eff62336b", "size": 3670, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sombrero.tex", "max_stars_repo_name": "chapman-phys220-2018f/cw13-please-be-my-friend", "max_stars_repo_head_hexsha": "f5af3476f8c3614f845faaa06e123420410de410", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sombrero.tex", "max_issues_repo_name": "chapman-phys220-2018f/cw13-please-be-my-friend", "max_issues_repo_head_hexsha": "f5af3476f8c3614f845faaa06e123420410de410", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sombrero.tex", "max_forks_repo_name": "chapman-phys220-2018f/cw13-please-be-my-friend", "max_forks_repo_head_hexsha": "f5af3476f8c3614f845faaa06e123420410de410", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.6623376623, "max_line_length": 432, "alphanum_fraction": 0.7054495913, "num_tokens": 1189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.44393547080986673}}
{"text": "\\documentclass[11pt,twoside]{article}\n\n\\usepackage{paperlighter}\n\n% Recommended, but optional, packages for figures and better typesetting:\n\\usepackage{microtype}\n\\usepackage{graphicx}\n\\graphicspath{ {figure/} }\n\n\\usepackage{subfigure}\n\\usepackage{booktabs} % for professional tables\n\n% Attempt to make hyperref and algorithmic work together better:\n\\newcommand{\\theHalgorithm}{\\arabic{algorithm}}\n\n% Todonotes is useful during development; simply uncomment the next line\n%    and comment out the line below the next line to turn off comments\n%\\usepackage[disable,textsize=tiny]{todonotes}\n\\usepackage[textsize=tiny]{todonotes}\n\\usepackage{wrapfig}\n\n\\slimtitle{Force on a Wire Lab Report}\n\\slimauthor{Tanish Tyagi}\n\n\\begin{document}\n\n\\lightertitle{Force on a Wire Lab Report}\n\\lighterauthor{Tanish Tyagi}\n\n\\section{Experiment Results and Analysis}\n\n% Part 1 Graph and Analysis \n\\subsection{Part 1 Results and Analysis}\n\\begin{wrapfigure}{l}{0.7\\textwidth}\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{part_1_graph.png}\n    \\caption{Graph of Force vs. Current}\n\\end{wrapfigure}\n\nThe equation of best fit for this graph was $Force (N) = -0.002254 (\\frac{N}{amp}) \\cdot I (amp)$. I made the equation go through the origin, as when $0$ amps of current is passed through the wire and plastic board, no additional force will be exerted by the wire onto the magnet and therefore the scale. Therefore, the point $(0,0)$ can serve as an additional data point. The data also suggests that force is proportional to current.\n\n% Part 2 Graph and Analysis \n\\subsection{Part 2 Results and Analysis}\n\\begin{wrapfigure}{l}{0.7\\textwidth}\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{part_2_graph.png}\n    \\caption{Graph of Force vs. Length of Wire}\n\\end{wrapfigure}\n\nThe equation of best fit for this graph was $Force (N) = -0.1354 (\\frac{N}{m}) \\cdot L (m)$. I made the equation go through the origin, as when the length of the wire is $0$ amps of current is passed through the wire and plastic board, there is no opportunity for current to go through the wire and create a downward force that increases the balance on the scale. \\\\ \\\\ Therefore, the point $(0,0)$ can serve as an additional data point. The data also suggests that force is proportional to the length of the wire.\n\n% Part 3 Graph and Analysis \n\\subsection{Part 3 Results and Analysis}\n\\begin{wrapfigure}{l}{0.7\\textwidth}\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{part_3_graph.png}\n    \\caption{Graph of Force vs. Number of Magnets}\n\\end{wrapfigure}\n\nThe equation of best fit for this graph was $Force (N) = -0.0007808 (N) \\cdot M$. I made the equation go through the origin, as it was of the recorded data points. This makes sense, as when $0$ magnets are present, there are no objects exerting a force onto the wire, which means that the wire will not exert a downwards force onto the objects / scale by Newton's 3rd Law. This data also suggests that force is proportional to the number of magnets. \\\\\n\n\\textbf{General Note about all three graphs: You will notice that all my slopes and force values are negative. This is because the orientation of the horseshoe was flipped during the experiment. However, all that needs to be considered is the magnitudes of the aforementioned values.}\n\n\\section{Creating a Single Equation that Combines the Relationships between Force and Current, Length of Wire, and Number of Magnets}\n\nIn the above section we learned three things: \n\n\\begin{enumerate}\n\\item $F \\propto I$, $I$ = current\n\\item $F \\propto L$, $L$ = length of wire\n\\item $F \\propto N$, $N$ = number of magnets\n\\end{enumerate}\n\nWe can combine these relationships to get a general equation $F = K \\cdot I \\cdot L \\cdot N$. The units of $K$ will be $\\frac{N}{amp \\cdot m} = \\frac{N}{C \\cdot \\frac{m}{s}}$, which is equivalent to a Tesla. This makes sense, as $K \\cdot N$ describes the strength of $B$, which also has the unit of Tesla.\n\nTo find the numerical value of $K$, I utilized two methods: \n\n\\begin{enumerate}\n    \\item I extracted three separate $K$ values from the Force vs Current, Length of Wire, and Number of Magnets graphs. For example, take the Force vs. Current graph.\n    \n    The line of best for this graph can be written as $F = M \\cdot I$. We know that $M = K \\cdot L \\cdot N$, and $L = 0.0322 m$ and $N = 6$ magnets. We can now solve for $K$. \n    \n    I performed a similar process for the other two graphs as well to ensure the rigor of my $K$ value. The $K$ values for all three values are below:\n    \n    \\begin{enumerate}\n        \\item Force vs. Current - $K \\approx 0.01167$\n        \\item Force vs. Length of Wire - $K \\approx 0.01128$\n        \\item Force vs. Number of Magnets - $K \\approx 0.01214$\n    \\end{enumerate}\n    \n    When these $K$ values are used on graphs that contain different data from the one used to compute the particular $K$ value, the correlation is on average $0.995$, showing that these values are generalizable.   \n    \n    \\item I graphed $F$ vs. $N \\cdot I \\cdot L$ for all the data I collected and found the slope of the best fit line for this data. \n    \n\\end{enumerate}\n\\begin{wrapfigure}{l}{0.7\\textwidth}\n    \\centering\n    \\caption{Graph of $F vs. N \\cdot I \\cdot L$}\n    \\includegraphics[width=0.7\\textwidth]{k_graph.png}\n\\end{wrapfigure}\n\nThe equation of best fit for this graph was $F = 0.01162 \\frac{N}{amp \\cdot m} \\cdot NIL (Amp \\cdot m)$. Using this method, $K = 0.01162 \\frac{N}{amp \\cdot m}$. If we compare all four $K$ values, we see that they are all extremely similar, with variations starting to develop only around the 3rd significant figure. This $K$ value is also generalizable to the other graphs, as it achieved correlation values of $0.996$. \\\\\n\n$K$ is not a universal constant; it would primarily depend on the strength of the magnetic field generated. The strength of the magnetic field also depends on how close to the wire the magnet. The closer the magnet is to the wire, the larger the magnitude of the magnetic field and the larger the force exerted by the wire onto the magnet are.\n\n\\section{Additional Questions}\n\n\\begin{enumerate}\n    \\item Using the slap rule, we can find the direction of the force at various points in the wire. Figure 5 depicts this.  \n    \n    \\parbox{\\linewidth}{\\centering\n    \\begin{wrapfigure}{l}{0.5\\textwidth}\n        \\centering\n        \\caption{}\n        \\includegraphics[width=0.4\\textwidth]{force_on_wire_additional_question_2.png}\n    \\end{wrapfigure}\n    \n    As we can see, at the vertical points in the wire, the direction of the force is horizontal. This means that these forces will not affect the scale reading as they are not oriented up or down. Secondly, the forces created by the vertical parts of the wire will always cancel out, as the amount of current and strength of the magnetic field will be the same at corresponding points. This means that should there be minor set-up errors in which the plastic board is not fully vertical, any component with a direction up or down will be irrelevant. This is the motivation behind solely measuring the horizontal portion of the wire. \n    }\n    \\linebreak % \\linebreak \\linebreak \\linebreak %\\linebreak \\linebreak \\linebreak\n    \n    \\item Newton's 3rd law states that $F_A = -F_B$, where $A$ and $B$ are the magnet and wire, respectively. Using this, we can conclude that in order for there to be a downward force on the magnet exerted by the wire, there needs to be an upward force exerted by the magnet onto the wire. The wire will exert a downward force onto the magnet in response. Using our magnetism rules, we know that the magnetic force can only point upwards if the current is going towards the right ($\\rightarrow$).  \n    \n    \\item The amount of force that needs to be exerted upwards onto the wire by the magnet needs to be equivalent to 6.7 grams in Newtons. Using $F = ma$, we get 6.7 grams = $\\approx 0.066$ Newtons. In prior parts, we used to our data to calculate $K$. I will be using $K = 0.01162 \\frac{N}{amp \\cdot m}$, but since the values of $K$ calculated are so similar, either one is fine. \n    \n    Using $F = K \\cdot I \\cdot L \\cdot N$, we can solve for $I$ to get $I = \\frac{F}{K \\cdot L \\cdot N}$. Using our value of $K$ and the givens from the question, we get $I = \\frac{0.066}{0.01140 \\cdot 0.048 \\cdot 4} = \\approx 30$ Newtons. \n    \n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "b2e3a6b62c6798e9b6d6e6489bda9179f93a0898", "size": 8368, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Physics/Force on a Wire Lab Report.tex", "max_stars_repo_name": "anaconda121/School", "max_stars_repo_head_hexsha": "eefc30a780171082dae00591e2a7bdd8ad1a6d68", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Physics/Force on a Wire Lab Report.tex", "max_issues_repo_name": "anaconda121/School", "max_issues_repo_head_hexsha": "eefc30a780171082dae00591e2a7bdd8ad1a6d68", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Physics/Force on a Wire Lab Report.tex", "max_forks_repo_name": "anaconda121/School", "max_forks_repo_head_hexsha": "eefc30a780171082dae00591e2a7bdd8ad1a6d68", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.3692307692, "max_line_length": 633, "alphanum_fraction": 0.7338671128, "num_tokens": 2219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.443934017930562}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{lmodern}\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\\begin{document}\n\\title{Conjecture about tautologies, contingencies\nand contradictions}\n\\author{Günter Hofer}\n\\maketitle\n\\newpage \n\\paragraph{Introduction}\nThe satisfiability problem is not easy. With n variables there are $2^n$ possibilities in propositional logic. But when you only need to know if a given Boolean formula\nis satisfiable, there is a simple method.\n\n\n\\[A \\land B := A \\times B\\]\n\\[A \\lor B \t\t:= A + B - A \\times B\\]\n\\[\\lnot A := 1 - A\\]\n\\[A \\supset B := 1 - (A \\times (1 - B))\\]\n\\[A \\equiv B := (A \\supset B) \\times (B \\supset A) \\]\n\\[A \\oplus B := 1 - (A \\equiv B)\\]\n\\[A \\bar{\\land} B := 1- A \\times B\\]\n\\[A \\bar{\\lor}B := 1 - (A + B - A \\times B)\\]\n\\paragraph{}\nA and B are real numbers in [0,1] .\n\\paragraph{}\nHere is a J program.\n\\begin{verbatim}\nNB. logic functions as arithmetic formulas\nnot =: 3 : '1-y'\nand =: 4 : 'x*y'\nor =: 4 : 'x+y-x*y'\nimp =: 4 : '1-(x*(1-y))'\neqv =: 4 : '(x imp y) * (y imp x)'\nxor =: 4 : '1 - (x eqv y)'\nnand =: 4 : '1-x*y'\nnor =: 4 : '1-x+y-x*y'\n\\end{verbatim}\n\n\\paragraph{Tautology Conjecture}\nIf and only if all results, whereby at least one variable has at least 2 different values, are above 0.5 it can be a tautology.\n\n\\paragraph{Contradiction Conjecture}\nIf and only if all results, whereby at least one variable has at least 2 different values, are under 0.5 it can be a contradiction.\n\n\\paragraph{Contingency Conjecture}\nIf neither the Tautology Conjecture nor the Contradictions Conjecture applies, then it is satisfiable but not a tautology.\n\\newpage \n\\paragraph{Examples}\n\nIt is assumed that the above J program is loaded.\n\\begin{verbatim}\n  a=.b=.c=.d=.0.5\n   ((a or b) and (b imp c)) or (c imp d) or (c imp b)\n0.972656\n   a=.0 1\n   ((a or b) and (b imp c)) or (c imp d) or (c imp b)\n0.960938 0.984375\n   a=.a,a\n   b=.0 0 1 1\n   a\n0 1 0 1\n   b\n0 0 1 1\n   ((a or b) and (b imp c)) or (c imp d) or (c imp b)\n0.875 1 1 1\n   a=.0\n   b=.0\n   c=.0 1\n   ((a or b) and (b imp c)) or (c imp d) or (c imp b)\n1 0.5\nNB. Because of the 0.5 you know it is a contingency\n   c=.1\n   d=. 0 1\n   ((a or b) and (b imp c)) or (c imp d) or (c imp b)\n0 1\n\\end{verbatim}\n\n\\begin{verbatim}\n   a=.b=.0.5\n   (a imp (b imp a))\n0.875\n   a=. 0 1\n   (a imp (b imp a))\n1 1\n\n\n   a=.b=.0.5\n   (a imp (b imp a))\n0.875\n   b=.0 1\n   (a imp (b imp a))\n1 0.75\n   b=.1\n   a=.0 1\n   (a imp (b imp a))\n1 1\n\n\\end{verbatim}\n\\end{document}\n", "meta": {"hexsha": "6c71e70ad4abc57c5ea41ce8a732778dcf9a2e13", "size": 2620, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tcc-conjecture.tex", "max_stars_repo_name": "Guenter-Hofer/tcc-conjecture", "max_stars_repo_head_hexsha": "b096ede2ec043fd08bcc8d45a29c54e73fde3c53", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tcc-conjecture.tex", "max_issues_repo_name": "Guenter-Hofer/tcc-conjecture", "max_issues_repo_head_hexsha": "b096ede2ec043fd08bcc8d45a29c54e73fde3c53", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tcc-conjecture.tex", "max_forks_repo_name": "Guenter-Hofer/tcc-conjecture", "max_forks_repo_head_hexsha": "b096ede2ec043fd08bcc8d45a29c54e73fde3c53", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7169811321, "max_line_length": 168, "alphanum_fraction": 0.6328244275, "num_tokens": 1017, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.4439340168338397}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{./resources/pdf/logo.pdf}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 01/29/21\n\nFor posterity we restate the definition of a polynomial ring.\n\n\\begin{defn}[Polynomial Ring]\n\tLet \\(R\\) be a commutative ring. We define a \\textbf{polynomial} in \\(x\\) to be the formal sum\n\t\\begin{align*}\n\t\ta_n x^{n} + a_{n-1}x^{n-1} + \\ldots + a_1 x + a_0\n\t\\end{align*}\n\twhere \\(n\\geq 0\\) and \\(a_i \\in R\\). If \\(a_n \\neq 0\\), then the polynomial is of \\textbf{degree \\(n\\)}, and \\(a_nx^{n}\\) is te \\textbf{leading term} (\\(a_n\\) is the \\textbf{leading coefficient}). Furthermore, we say the polnyomial is \\textbf{monic} if \\(a_n=1\\).\\\\\n\n\tThe set of all such polynomials is called the \\textbf{ring of polynomials in \\(\\R\\)} and will be denoted \\(R[x]\\). We define addition and multiplication by the standard version from algebra:\n\t\\begin{align*}\n\t\t(a_nx^{n} + \\ldots + a_1x + a_0) + (b_nx^{n} + \\ldots + b_1x + b_0) = (a_n+b_n)x^{n} + \\ldots + (a_1+b_1)x + (a_0 + b_0)\\\\\n\t\t(a_0+a_1x + a_2x^2+\\ldots) \\times (b_0 + b_1x + b_2x^2 + \\ldots) = a_0b_0 + (a_0b_1 + a_1b_0)x + (a_0b_2 + a_1b_1 + a_2b_0)x^2 + \\ldots\n\t\\end{align*}\n\tThat is, the coefficient in the product of \\(x^{k}\\) is \\(\\sum_{i=0}^{k} a_i b_{k-i}\\).\n\\end{defn}\nRecall that \\(\\textrm{deg}(p(x)q(x)) = \\textrm{deg}(p(x)) + \\textrm{deg}(q(x))\\) if \\(p,q \\neq 0\\). Furthermore, the units of \\(R[x]\\) are the units of \\(R\\), and \\(R[x]\\) is an integral domain.\n\n\\begin{prop}\n\tLet \\(I\\triangleleft R\\) be an ideal and let \\(\\left( I \\right) = I[x]\\) denote the ideal in \\(R[x]\\) generated by \\(I\\). Then\n\t\\begin{align*}\n\t\tR[x] / (I) \\cong (R / I)[x]\n\t\\end{align*}\n\tand hence if \\(I\\) is a prime ideal of \\(R\\), \\((I)\\) is a prime ideal of \\(R[x]\\).\n\\end{prop}\nThis does not hold for maximal ideals, but \\((I,x)\\) is maximal in \\(R[x]\\) if \\(I\\) is maximal in \\(R\\).\n\n\\begin{defn}[Polynomial Rings over Multiple Variables]\n\tWe inductively define the \\textbf{polynomial ring in the variables} \\(x_1,x_2,\\ldots,x_n\\) with coefficients in \\(R\\) to be\n\t\\begin{align*}\n\t\tR[x_1,x_2,\\ldots,x_n] := R[x_1,x_2,\\ldots,x_n][x_n]\n\t\\end{align*}\n\tHence, we can view polynomial rings of multiple variables as polynomial rings on a single variable, with polynomials of \\(n-1\\) variables as coefficients.\n\\end{defn}\nWe say a polynomial is \\textbf{homogeneous} if all its terms have the same degree. If \\(f\\) is a nonzero polynomial in \\(n\\) variables, the sum of all monomial terms in \\(f\\) of degree \\(k\\) is called the \\textbf{homogeneous component of \\(f\\) of degree \\(k\\)}.\n\n\\section{Polynomial Rings over Fields}\n\\label{sec:polynomial_rings_over_fields}\n\nLet \\(R = F\\) be a field. We can define a natural norm on \\(F[x]\\) by\n\\begin{align*}\n\tN(p(x)) = \\textrm{deg}(p(x)).\n\\end{align*}\n\\begin{thm}\n\tLet \\(F\\) be a field. The polynomial ring \\(F[x]\\) is a Euclidean Domain. This implies that if \\(a(x),b(x) \\in F[x]\\) with \\(b(x)\\) nonzero, then\n\t\\begin{align*}\n\t\ta(x) = q(x)b(x) + r(x)\n\t\\end{align*}\n\twhere \\(q(x),r(x) \\in F[x]\\) are unique polynomials, and \\(r(x) = 0\\) or \\(\\textrm{deg}(r(x)) < \\textrm{deg}(b(x))\\).\n\\end{thm}\n\n\\begin{proof}\n\t\n\\end{proof}\nOf course, this tells us that \\(F[x]\\) is a PID and a UID.\\\\\n\nIn fact, the quotient and remainder in the division algorithm are \\textit{independent of field extensions}. That is, if \\(F\\subset E\\) is a field extension, then \\(b(x)\\mid a(x)\\) in \\(E[x]\\) if and only if \\(b(x)\\mid a(x)\\) in \\(F[x]\\), and \\(\\textrm{gcd}(a(x),b(x))\\) is the same in both fields.\n\n\\begin{prop}\n\tThe maximal ideals in \\(F[x]\\) are the ideals \\((f(x))\\) generated by irreducible polynomials \\(f(x)\\). In particular, \\(F[x] / (f(x))\\) is a field if and only if \\(f(x)\\) is irreducible.\n\\end{prop}\n\n\\begin{prop}\n\tLet \\(g(x) \\in F[x]\\) be nonconstant and let\n\t\\begin{align*}\n\t\tg(x) = f_1(x)^{n_1}f_2(x)^{n_2}\\ldots f_k(x)^{n_k}\n\t\\end{align*}\n\tbe its factorization into irreducibles, where the \\(f_i(x)\\) are distinct. Then\n\t\\begin{align*}\n\t\tF[x] / (g(x)) \\cong F[x] / (f_1(x)^{n_1}) \\times F[x] / (f_2(x)^{n_2}) \\times  \\ldots \\times F[x] / (f_k(x)^{n_k}).\n\t\\end{align*}\n\\end{prop}\n\nNotice that if \\(f(x)\\) has roots \\(\\alpha_1,\\alpha_2,\\ldots,\\alpha_k\\) in \\(F\\), then \\(f(x)\\) has \\((x-\\alpha_1)\\ldots(x-\\alpha_k)\\) as a factor. In other words, a polynomial of degree \\(n\\) over a field has at most \\(n\\) roots in \\(F\\).\n\n\\begin{prop}\n\tA finite subgroup of the multiplicative group of a field is cyclic. In particular, if \\(F\\) is a finite field, then \\(F^{\\times }\\) is a cyclic group.\n\\end{prop}\n\\begin{proof}\n\t\n\\end{proof}\n\n\\begin{cor}\n\tLet \\(p\\) be a prime. Then \\((\\Z / p\\Z)^{\\times }\\) of nonzero residue classes \\(\\pmod{p}\\) is cyclic.\n\\end{cor}\n\n\\begin{cor}\n\tLet \\(n\\geq 2\\) be an integer with factorization\n\t\\begin{align*}\n\t\tn = p_1^{\\alpha_1}p_2^{\\alpha_2}\\ldots p_r^{\\alpha_r}\n\t\\end{align*}\n\twith \\(p_1,\\ldots,p_r\\) are distinct. Then\n\t\\begin{align*}\n\t\t(\\Z / n\\Z)^{\\times } \\cong ( \\Z/ p_1^{\\alpha_1} \\Z)^{\\times } \\times (\\Z / p_2^{\\alpha_2}\\Z)^{\\times } \\times \\ldots \\times (\\Z / p_r^{\\alpha_r}\\Z)^{\\times },\n\t\\end{align*}\n\tin particular \\((\\Z / 2^{\\alpha }\\Z)^{\\times }\\) is the direct product of a cyclic group of order 2 and a cyclic group of order \\(2^{\\alpha -2}\\) for all \\(\\alpha \\geq 2\\).\\\\\n\n\tFinally, \\((\\Z / p^{\\alpha }\\Z)^{\\times }\\) is a cyclic group of order \\(p^{\\alpha-1}(p-1)\\) for all odd primes \\(p\\).\n\\end{cor}\nThese describe the group theory structure of the automorphism group of the cyclic group \\(\\Z_n\\), as \\(\\textrm{Aut}(\\Z_n) \\cong (\\Z / n\\Z)^{\\times }\\).\n\n\\begin{proof}\n\t\n\\end{proof}\n\n\\section{Polynomial Rings and UFDs}\n\\label{sec:polynomial_rings_and_ufds}\n\n\n\\begin{defn}[Primitive]\n\tA polynomial \\(f(x) \\in R[x]\\) is \\textbf{primitive} if \\( \\textrm{gcd}(\\left\\{ \\text{coeff of }f(x) \\right\\} ) = 1_R\\)\n\\end{defn}\nRecall that since \\(R\\) is an integral domain, one can form its field of fractions by\n\\begin{align*}\n\tF:= \\textrm{Frac}(R) = \\left\\{ \\frac{r}{s} \\mid r,s \\in R, \\; s \\neq 0 \\right\\} \n\\end{align*}\n\\begin{lemma}[Gauss' Lemma]\n\tLet \\(R\\) be a UFD with \\(F = \\textrm{Frac}(R)\\).\n\t\\begin{itemize}\n\t\t\\item If \\(f(x),g(x) \\in R[x]\\) are primitive, then so is \\(f(x)\\cdot g(x)\\).\n\t\t\\item Take \\(f(x) \\in R[x]\\). Then \\(f(x) = \\varphi(x) \\psi(x) \\in F[x]\\) with \\( \\textrm{deg}(\\varphi) \\textrm{deg}(\\psi)\\geq 1 \\iff f(x) = \\psi(x) \\varphi(x)\\) in \\(R[x]\\).\n\t\\end{itemize}\n\\end{lemma}\nThe elements of the ring \\(R\\) become units in the UFD \\(F[x]\\).\n\n\n\\begin{cor}\n\tLet \\(R\\) be a UFD. The irreducible elements of \\(R[x]\\) are of two types:\n\t\\begin{itemize}\n\t\t\\item nonzero scalar polynomials that are irreducible as elements of \\(R\\) \n\t\t\\item primitive polynomials in \\(R[x]\\) that are irreducible in \\(F[x]\\)\n\t\\end{itemize}\n\\end{cor}\nEssentially, a polynomial \\(p(x)\\) with \\(\\textrm{deg}(p(x))\\geq 1\\) is irreducible in \\(R[x]\\) if and only if it is irreducible in \\(F[x]\\).\n\n\\begin{thm}\n\t\\(R\\) is a Unique Factorization Domain if and only if \\(R[x]\\) is a Unique Factorization Domain.\n\\end{thm}\n\\begin{proof}\n\t\n\\end{proof}\nBy induction, it holds that \\(R[x_1,x_2,\\ldots,x_n]\\) is a UFD if and only if \\(R\\) is a UFD.\n\n\\end{document}\n", "meta": {"hexsha": "235a94e52d1976b3ec4e4885f80dcb93b32e6d6b", "size": 7401, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture3 - GaussLemma_IntroPolyRings.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture3 - GaussLemma_IntroPolyRings.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture3 - GaussLemma_IntroPolyRings.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8545454545, "max_line_length": 297, "alphanum_fraction": 0.6380218889, "num_tokens": 2762, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.8175744761936437, "lm_q1q2_score": 0.4438311643845226}}
{"text": "\\section{Statistical Mechanics}\nThis is a brief summary of statistical mechanics for the PGRE and covers the bare essentials of this topic.\nMost of the subtopics here are frequently tested, but the section over solids is mostly to get a qualitative understanding of energy levels and so on.\nThe most important topic, I feel, is the canonical ensemble and its partition function.\nAgain, it's a good idea to flesh out this section with your own graphs and diagrams.\n\n\\subsection{Theorem of Equipartition of Energy}\nEach degree of freedom which contributes a quadratic term to the total energy has an average energy \\(\\frac{1}{2}k_BT\\) and contributes \\(\\frac{k_B}{2}\\) to the heat capacity (at constant volume, \\(C_V\\))\\\\\\\\*\nFor diatomic molecule:\\\\*\n3 translational degrees of freedom: \\(H_{trans}=\\frac{1}{2}m\\left(\\dot{x}^2+\\dot{y}^2+\\dot{z}^2\\right)\\)\\\\*\n2 vibrational degrees of freedom: \\(H_{vib}=\\frac{1}{2}m\\left(\\dot{x}^2+\\omega^2x^2\\right)\\)\\\\*\n2 rotational degrees of freedom: \\(H_{rot}=\\frac{1}{2}I\\left(\\omega_1^2+\\omega_2^2\\right)\\) (other rotational axis has extremely small moment of inertia)\\\\*\nTotal degrees of freedom: 7\n\n\\subsection{Gases}\n\n\\subsubsection{Maxwell-Boltzmann Speed Distribution Function}\n\\(\\displaystyle N_v=4\\pi N\\left(\\frac{mv^2}{2\\pi k_BT}\\right)^{3/2}e^{-mv^2/2k_BT}\\)\n\n\\subsubsection{Velocities}\nRoot-Mean Square velocity:\\\\*\n\\(\\displaystyle K_{trans}=\\frac{1}{2}mv_{rms}^2=\\frac{3}{2}k_BT\\rightarrow v_{rms}=\\sqrt{\\frac{3k_BT}{m}}\\)\\\\\\\\*\nAverage Speed:\\\\*\n\\(\\displaystyle \\bar{v}=\\sqrt{\\frac{8k_BT}{\\pi m}}\\)\\\\\\\\*\nMost Probable Speed:\\\\*\n\\(\\displaystyle v_{mp}=\\sqrt{\\frac{2k_BT}{m}}\\)\\\\\\\\*\nRelationship Between Speeds:\\\\*\n\\(v_{rms}>\\bar{v}>v_{mp}\\)\n\n\\subsection{Radiation}\n\\subsubsection{Stefan's Law}\n\\(P=\\sigma A e T^4\\), where \\(P\\) is power,  \\(A\\) is the surface area, and \\(e\\) is the emissivity (the fraction of incoming radiation that the surface absorbs)\\\\*\nIf the surroundings are at \\(T_0\\) then \\(P=\\sigma A e (T^4-T_0^4)\\)\n\n\\subsubsection{Blackbody Radiation}\n\\(e=1 \\rightarrow P=\\sigma A T^4\\)\\\\*\nWien's displacement law: \\(\\lambda_{max} T\\approx.003(mK)\\), where \\(\\lambda_{max}\\) is the maximum wavelength of light emitted from a blackbody at temperature \\(T\\)\n\n\\subsubsection{Ideal Reflector}\n\\(e=0\\rightarrow P=0\\)\n\n\\subsection{The Canonical \\& Grand Canonical Ensembles}\n\n\\subsubsection{The Canonical Ensemble}\nPartition function: \\(\\displaystyle Z=\\sum_i{g_ie^{-E_i/k_BT}}\\), where \\(g_i\\) is the degeneracy of state \\(i\\)\\\\*\nProbability of system to be in state \\(i\\): \\(\\displaystyle p_i=\\frac{g_ie^{-E_i/k_BT}}{Z}\\)\\\\*\nRatio of probabilities: \\(\\displaystyle \\frac{p_i}{p_j}=\\frac{g_i}{g_j}e^{-(E_i-E_j)/k_BT}\\)\\\\*\nEntropy: \\(\\displaystyle S=-k_B\\sum_i{p_i\\ln{p_i}}\\)\\\\*\nHelmholtz free energy: \\(F=-k_BT\\ln{Z}\\)\\\\*\nEntropy from free energy: \\(\\displaystyle S=-\\left(\\frac{\\partial F}{\\partial T}\\right)_V=k_B\\ln{Z}+k_BT\\frac{\\partial\\ln{Z}}{\\partial T}\\)\\\\*\nAverage internal energy: \\(\\displaystyle \\bar{U}=\\sum_i{p_iE_i}=k_BT^2\\left(\\frac{\\partial\\ln{Z}}{\\partial T}\\right)_V=k_B\\frac{T^2}{Z}\\left(\\frac{\\partial Z}{\\partial T}\\right)_V\\)\n\n\\subsubsection{The Grand Canonical Ensemble}\nGrand partition function: \\(\\displaystyle \\Xi=\\sum_i{g_ie^{-(E_i-\\mu N_i)/k_BT}}\\)\\\\*\nProbability of system to be in state \\(i\\): \\(\\displaystyle p_i=\\frac{g_ie^{-(\\epsilon_i-\\mu)/k_BT}}{\\Xi}\\)\\\\*\nGrand potential: \\(\\Phi_G=-k_BT\\ln{\\Xi}=\\bar{U}-\\mu\\bar{N}-TS\\)\\\\*\nThermodynamic quantities:\\\\*\n\\(\\displaystyle S=-\\left(\\frac{\\partial\\Phi_G}{\\partial T}\\right)_{V,\\mu}\\), \\(\\displaystyle P=-\\left(\\frac{\\partial\\Phi_G}{\\partial V}\\right)_{T,\\mu}\\), and \\(\\displaystyle \\bar{N}=-\\left(\\frac{\\partial\\Phi_G}{\\partial \\mu}\\right)_{V,T}\\)\n\n\\subsection{Number Density}\n\\(\\displaystyle n_V(E)=n_0e^{\\frac{-E}{k_BT}}\\)\n\n\\subsection{Symmetry and Statistics}\nIf a system starts in a symmetric/anti-symmetric state it must stay in a symmetric/anti-symmetric state.\n\n\\subsubsection{Symmetric State}\n\\(\\psi(x_1,x_2)=\\psi(x_2,x_1)\\)\\\\\\\\*\nBosons are symmetric (photons, mesons, \\(^4\\)He).\\\\*\ne.g.: \\(\\psi_{Bose}(x_1,x_2)=\\phi_i(x_1)\\phi_j(x_2)+\\phi_i(x_2)\\phi_j(x_1)\\)\\\\\\\\*\n%\nBose-Einstein distribution function:\\\\*\nDistribution function: \\(\\displaystyle f(k)=\\frac{1}{e^{(\\epsilon(k)-\\mu)/k_BT}-1}\\), where \\(\\epsilon(k)-\\mu>0\\)\n\n\\subsubsection{Anti-Symmetric State}\n\\(\\psi(x_1,x_2)=-\\psi(x_2,x_1)\\)\\\\\\\\*\nFermions are anti-symmetric (electrons, neutrinos, protons, \\(^3\\)He).\\\\*\ne.g.: \\(\\psi_{Fermi}(x_1,x_2)=\\phi_i(x_1)\\phi_j(x_2)-\\phi_i(x_2)\\phi_j(x_1)\\)\\\\\\\\*\n%\nFermi-Dirac distribution function:\\\\*\n\\(\\displaystyle\\epsilon(k)=\\frac{\\hbar^2k^2}{2m}\\)\\\\*\nDistribution function: \\(\\displaystyle n(k)=\\frac{1}{e^{(\\epsilon(k)-\\mu)/k_BT}+1}\\)\\\\*\nAt high temperatures this reverts back to a Boltzmann distribution: \\(\\displaystyle n(k)\\rightarrow e^{-(\\epsilon(k)-\\mu)/k_BT}\\)\\\\*\nAt low temperatures \\(n(k)\\rightarrow1\\)\n%\n\\subsubsection{Fermi Gas}\n\\(n=\\frac{\\bar{N}}{V}\\)\\\\*\nFermi wave number: \\(k_F=\\left(3\\pi^2n\\right)^{1/3}\\)\\\\*\nFermi energy: \\(\\displaystyle E_F=\\frac{\\hbar^2k_F^2}{2m}\\)\\\\*\nFermi temperature: \\(\\displaystyle T_F=\\frac{E_F}{k_B}\\)\\\\*\nFermi velocity: \\(\\displaystyle v_F=\\frac{\\hbar k_F}{m}\\)\\\\\\\\*\n%\nIn the high temperature limit: \\(P=nk_BT\\)\\\\\\\\*\nWhen \\(T>T_F\\), \\(\\displaystyle n(k)\\rightarrow e^{-(\\epsilon(k)-\\mu)/k_BT}\\)\\\\*\nWhen \\(T\\ll T_F\\), one can assume the system is in its ground state; all electrons have energies less than or equal to the Fermi energy\\\\*\nAt \\(T=0\\): \\(\\displaystyle P=\\frac{2nE_F}{5}\\) and \\(\\displaystyle \\bar{U}=\\frac{3E_F}{5}\\)\\\\*\nAt low \\(T\\): \\(\\displaystyle C_V=\\frac{Nk_BT^2}{2}\\left(\\frac{k_BT}{E_F}\\right)\\)\\\\\\\\*\n%\nReview what these different distributions look like and their relationships between each other.\n\n\\subsection{Statistical Models of Solids}\n\n\\subsubsection{Basics}\nEnergy levels in a solid form a band structure.\\\\*\nReview energy level diagrams for metals, insulators, and semiconductors\\\\\\\\*\n\\(n\\)-type semiconductors: impurity atoms are \\emph{donors} of electrons\\\\*\n\\(p\\)-type semiconductors: impurity atoms are \\emph{acceptors} of electrons\\\\*\nReview energy level diagrams for \\(n\\) and \\(p\\)-type semiconductors\\\\\\\\*\nEffective electron mass: \\(\\displaystyle m^*=\\frac{\\hbar^2}{\\left(\\frac{\\mathrm{d}^2E}{\\mathrm{d}k^2}\\right)}\\)\n\n\\subsubsection{Einstein's Model of Vibrations in a Solid}\nAtoms are treated as SHO's.\\\\*\nEvery atom oscillates at the same frequency (Einstein frequency \\(\\omega_E\\)).\\\\\\\\*\n\\(\\displaystyle C_V=3Nk_B\\left(\\frac{\\hbar\\omega_E}{k_BT}\\right)^2\\frac{e^{\\hbar\\omega_E/k_BT}}{\\left(e^{\\hbar\\omega_E/k_BT}-1\\right)^2}\\)\\\\\\\\*\nwhen \\(k_BT\\gg\\hbar\\omega_E\\rightarrow C_V=3Nk_B\\)\n\n\\subsubsection{Debye's Model}\nAtoms are treated as SHO's.\\\\*\nAtoms oscillate within a range frequencies.\\\\\\\\*\nDeveloped by considering the speed of sound in a material: \\(\\displaystyle \\frac{3}{\\bar{s}^3}=\\frac{1}{\\bar{s}_L^3}+\\frac{2}{\\bar{s}_T^3}\\)\\\\*\n\\(\\bar{s}\\) is the average speed of sound, \\(L\\) means longitudinal, and \\(T\\) means traverse\\\\*\nDebye frequency: \\(\\displaystyle\\omega_D=\\bar{s}\\left(\\frac{6\\pi^2N}{V}\\right)^{1/3}\\)\\\\*\nDebye energy: \\(E_D=\\hbar\\omega_D\\)\\\\\\\\*\n\\(\\displaystyle C_V=\\frac{2\\pi^2k_B^4T^3V}{5\\hbar^3\\bar{s}^3}\\)\n", "meta": {"hexsha": "13910e13d3d8630b856b70b5beecadb313c70c8c", "size": 7154, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/stat_mech.tex", "max_stars_repo_name": "jhetherly/Physics_GRE_Review", "max_stars_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-11T13:33:29.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-11T13:33:29.000Z", "max_issues_repo_path": "src/stat_mech.tex", "max_issues_repo_name": "jhetherly/Physics_GRE_Review", "max_issues_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/stat_mech.tex", "max_forks_repo_name": "jhetherly/Physics_GRE_Review", "max_forks_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.6935483871, "max_line_length": 239, "alphanum_fraction": 0.6917808219, "num_tokens": 2442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.6406358617010351, "lm_q1q2_score": 0.4437313018449774}}
{"text": "\\XtoCBlock{TF2}\r\n\\label{block:TF2}\r\n\\begin{figure}[H]\\includegraphics{TF2}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Input In(k)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & Output Out(k)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nb2 & b2\\tabularnewline\r\n\\hline\r\nb1 & b1\\tabularnewline\r\n\\hline\r\nb0 & b0\\tabularnewline\r\n\\hline\r\na1 & a1\\tabularnewline\r\n\\hline\r\na0 & a0\\tabularnewline\r\n\\hline\r\nts\\_fact & Multiplication factor of base sampling time (in integer format)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nSecond order transfer function:\n\n    G(z) = (b2.z\\textsuperscript{2} + b1.z + b0) / (z\\textsuperscript{2} + a1.z + a0)\r\n\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!3297}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 3297 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & TF2\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & TF2\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\nb2 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\na1 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\nin\\_veryold & In(k-2)\\tabularnewline\r\n\\hline\r\nout\\_old & Out(k-1)\\tabularnewline\r\n\\hline\r\nout\\_veryold & Out(k-2)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     int16         Out;\r\n     int16         b0;\r\n     int16         b1;\r\n     int16         b2;\r\n     int16         a0;\r\n     int16         a1;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int16         in_old;\r\n     int16         in_veryold;\r\n     int16         out_old;\r\n     int16         out_veryold;\r\n} TF2_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_TF2_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!3296}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 3296 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & TF2\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & TF2\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\nb2 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\na1 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\nin\\_veryold & In(k-2)\\tabularnewline\r\n\\hline\r\nout\\_old & Out(k-1)\\tabularnewline\r\n\\hline\r\nout\\_veryold & Out(k-2)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     int8          Out;\r\n     int8          b0;\r\n     int8          b1;\r\n     int8          b2;\r\n     int8          a0;\r\n     int8          a1;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int8          in_old;\r\n     int8          in_veryold;\r\n     int8          out_old;\r\n     int8          out_veryold;\r\n} TF2_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_TF2_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!3298}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 3298 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & TF2\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & TF2\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\nb2 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\na1 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\nin\\_veryold & In(k-2)\\tabularnewline\r\n\\hline\r\nout\\_old & Out(k-1)\\tabularnewline\r\n\\hline\r\nout\\_veryold & Out(k-2)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     int32         Out;\r\n     int32         b0;\r\n     int32         b1;\r\n     int32         b2;\r\n     int32         a0;\r\n     int32         a1;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int32         in_old;\r\n     int32         in_veryold;\r\n     int32         out_old;\r\n     int32         out_veryold;\r\n} TF2_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_TF2_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!3299}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 3299 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & TF2\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & TF2\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\nb2 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\na1 & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\nin\\_veryold & In(k-2)\\tabularnewline\r\n\\hline\r\nout\\_old & Out(k-1)\\tabularnewline\r\n\\hline\r\nout\\_veryold & Out(k-2)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *In;\r\n     float32       Out;\r\n     float32       b0;\r\n     float32       b1;\r\n     float32       b2;\r\n     float32       a0;\r\n     float32       a1;\r\n     float32       in_old;\r\n     float32       in_veryold;\r\n     float32       out_old;\r\n     float32       out_veryold;\r\n} TF2_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_TF2_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!3300}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 3300 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & TF2\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & TF2\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\nb2 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\na1 & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\nin\\_veryold & In(k-2)\\tabularnewline\r\n\\hline\r\nout\\_old & Out(k-1)\\tabularnewline\r\n\\hline\r\nout\\_veryold & Out(k-2)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *In;\r\n     float64       Out;\r\n     float64       b0;\r\n     float64       b1;\r\n     float64       b2;\r\n     float64       a0;\r\n     float64       a1;\r\n     float64       in_old;\r\n     float64       in_veryold;\r\n     float64       out_old;\r\n     float64       out_veryold;\r\n} TF2_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_TF2_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "1604b6a191a72507bf884fcbef7d8fc217e1ed0c", "size": 8354, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Control/Doc/TF2.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Control/Doc/TF2.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Control/Doc/TF2.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6657223796, "max_line_length": 90, "alphanum_fraction": 0.6606416088, "num_tokens": 2781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4437312984681471}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\\subsection{Understanding the baseline matrix multiply}\n\nThe baseline code does not perform very well. The following performance estimates will be taken as reference for further optimizations, see subsection \\ref{1-b}\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{ccccc}\n\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\\hline\n\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t230331&  230331&  230332&  230332&   none  \n\t\\end{tabular}\n\t\\caption{Performance: baseline matrix multiplication algorithm}\n\t\\label{1-a-perf-table}\n\\end{table}\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lcccc}\n\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\\hline\n\t\tDSP              &        -&      -&       -&      -\\\\\n\t\tExpression       &        -&      -&       0&    538\\\\\n\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\tInstance         &        0&      5&     384&    752\\\\\n\t\tMemory           &       16&      -&       0&      1\\\\\n\t\tMultiplexer      &        -&      -&       -&    559\\\\\n\t\tRegister         &        -&      -&     779&      -\\\\\n\t\t\\hline\n\t\tTotal            &       16&      5&    1163&   1847\\\\\n\t\tAvailable        &      280&    220&  106400&  53201\\\\\n\t\t\\hline\n\t\tUtilization ($\\%$)  &        5&      2&       1&      3\n\t\\end{tabular}\n\t\\caption{Resource utilization of the baseline code}\n\t\\label{1-a-resources}\n\\end{table}\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lcccc}\n\t\tModule & Number of instances \\\\\n\t\t\\hline\n\t\tfloating point adder & 1 \\\\\n\t\tfloating point multiplier & 1\n\t\\end{tabular}\n\t\\caption{Utilization of multipliers and adders of the baseline code}\n\t\\label{1-a-resources-arithmetic}\n\\end{table}\n\n\n\\subsection{Pipelining in HLS}\n\\label{1-b}\n\\begin{enumerate}\n\t\\item Optimization attempt: pipeline the most inner loop \\\\\n\t\t$\\Rightarrow$ speedup of $\\approx 2.13$ regarding the max latency compared to the baseline code\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t107995&  107995&  107996&  107996&   none  \n\t\t\\end{tabular}\n\t\t\\caption{Performance: most inner loop pipelined}\n\t\t\\label{1-b-perf-table-1}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lcccc}\n\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\\hline\n\t\tDSP              &        -&      -&       -&      -\\\\\n\t\tExpression       &        -&      -&       0&    557\\\\\n\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\tInstance         &        0&      5&     384&    751\\\\\n\t\tMemory           &       16&      -&       0&      0\\\\\n\t\tMultiplexer      &        -&      -&       -&    579\\\\\n\t\tRegister         &        -&      -&     945&     64\\\\\n\t\t\\hline\n\t\tTotal            &       16&      5&    1329&   1951\\\\\n\t\tAvailable        &      280&    220&  106400&  53200\\\\\n\t\t\\hline\n\t\tUtilization ($\\%$)  &        5&      2&       1&      3\n\t\\end{tabular}\n\t\\caption{Resource utilization: most inner loop pipelined}\n\t\\label{1-b-resources-1}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{cc}\n\t\t\tModule & Number of instances \\\\\n\t\t\t\\hline\n\t\t\tfloating point adder & 1 \\\\\n\t\t\tfloating point multiplier & 1\n\t\t\\end{tabular}\n\t\t\\caption{Utilization of multipliers and adders: most inner loop pipelined}\n\t\t\\label{1-a-resources-arithmetic-1}\n\t\\end{table}\n\n\n\t\\item Optimization attempt: pipeline the first inner loop \\\\\n\t\t\\label{attempt2}\n\t\t$\\Rightarrow$ speedup of $\\approx 14.22 $ regarding the max latency compared to the non optimizeed code\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t16194&  16194&  16195&  16195&   none  \n\t\t\\end{tabular}\n\t\t\\caption{Performance: first inner loop pipelined}\n\t\t\\label{1-b-perf-table-2}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{lcccc}\n\t\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\t\\hline\n\t\t\tDSP              &        -&      -&       -&      -\\\\\n\t\t\tExpression       &        -&      -&       0&  26003\\\\\n\t\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\t\tInstance         &        0&     10&     732&   1462\\\\\n\t\t\tMemory           &       16&      -&       0&      0\\\\\n\t\t\tMultiplexer      &        -&      -&       -&   4725\\\\\n\t\t\tRegister         &        -&      -&   24650&   6496\\\\\n\t\t\t\\hline\n\t\t\tTotal            &       16&     10&   25382&  38686\\\\\n\t\t\tAvailable        &      280&    220&  106400&  53200\\\\\n\t\t\t\\hline\n\t\t\tUtilization ($\\%$)  &        5&      4&      23&     72\n\t\t\\end{tabular}\n\t\t\\caption{Resource utilization: first inner loop pipelined}\n\t\t\\label{1-b-resources-2}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{cc}\n\t\t\tModule & Number of instances \\\\\n\t\t\t\\hline\n\t\t\tfloating point adder & 2 \\\\\n\t\t\tfloating point multiplier & 2\n\t\t\\end{tabular}\n\t\t\\caption{Utilization of multipliers and adders: first inner loop pipelined}\n\t\t\\label{1-b-resources-arithmetic-2}\n\t\\end{table}\n\n\tThe \\texttt{HLS pipeline} directive for the first inner loop does not completely unroll the most inner loop. The most inner loop can only be parallelized by two units, because the input buffer is stored into two separate BRAM blocks and therefore only provides two separate access channels. The hls tool gives a warning, that there are problems with scheduling the input buffer accesses which is related to this isssue. Optimization of memory accesses will be addressed in subsection \\ref{1-c}\n\n\t\\item Optimization attempt: Attempt \\ref{attempt2} and pipelining of all input functions \\\\\n\t\t\\label{attempt3}\n\t\t$\\Rightarrow$ speedup of $\\approx 16.64 $ regarding the max latency compared to the baseline code\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t13840&  13840&  13841&  13841&   none\n\t\t\\end{tabular}\n\t\t\\caption{Performance: first inner loop and input functions pipelined}\n\t\t\\label{1-b-perf-table-3}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{lcccc}\n\t\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\t\\hline\n\t\t\tDSP              &        -&      -&       -&      -    \\\\\n\t\t\tExpression       &        -&      -&       0&  26037    \\\\\n\t\t\tFIFO             &        -&      -&       -&      -    \\\\\n\t\t\tInstance         &        0&     10&     732&   1462    \\\\\n\t\t\tMemory           &       16&      -&       0&      0    \\\\\n\t\t\tMultiplexer      &        -&      -&       -&   4793    \\\\\n\t\t\tRegister         &        -&      -&   24611&   6496    \\\\\n\t\t\t\\hline                                                  \n\t\t\tTotal            &       16&     10&   25343&  38788    \\\\\n\t\t\tAvailable        &      280&    220&  106400&  53200    \\\\\n\t\t\t\\hline                                                  \n\t\t\tUtilization ($\\%$)  &        5&      4&      23&     72 \n\t\t\\end{tabular}\n\t\t\\caption{Resource utilization: first inner loop and input functions pipelined}\n\t\t\\label{1-b-resources-3}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{cc}\n\t\t\tModule & Number of instances \\\\\n\t\t\t\\hline\n\t\t\tfloating point adder & 2 \\\\\n\t\t\tfloating point multiplier & 2\n\t\t\\end{tabular}\n\t\t\\caption{Utilization of multipliers and adders: first inner loop and input functions pipelined}\n\t\t\\label{1-b-resources-arithmetic-3}\n\t\\end{table}\n\n\\end{enumerate}\n\n\\subsection{Increasing Pipeline Parallelism by Repartitioning Memories}\n\\label{1-c}\nThis optimization step introduces repartitioning of the memories \\texttt{in\\_buf} and \\texttt{weight\\_buf}. We group adjacent columns to a total of factor$=8$ blocks. This increases parallelism by a factor 8. Therefore the \\texttt{vivado\\_hls} tool instantiates eight times more adders and multipliers, which also increases hardware usage. \n\n$\\Rightarrow$ speedup of $\\approx 46.14 $ regarding the max latency compared to the baseline code\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t4992&  4992&  4993&  4993&   none \n\t\t\\end{tabular}\n\t\t\\caption{Performance:  optimizations as in \\ref{1-b} \\ref{attempt3} and memory repartitioning}\n\t\t\\label{1-c-perf-table}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{lcccc}\n\t\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\t\\hline\n\t\t\tDSP              &        -&      -&       -&      -\\\\\n\t\t\tExpression       &        -&      -&       0&   3309\\\\\n\t\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\t\tInstance         &        0&     80&    5604&  11416\\\\\n\t\t\tMemory           &       36&      -&       0&      0\\\\\n\t\t\tMultiplexer      &        -&      -&       -&   6324\\\\\n\t\t\tRegister         &        -&      -&   32355&  14129\\\\\n\t\t\t\\hline\n\t\t\tTotal            &       36&     80&   37959&  35178\\\\\n\t\t\tAvailable        &      280&    220&  106400&  53200\\\\\n\t\t\t\\hline\n\t\t\tUtilization ($\\%$)  &       12&     36&      35&     66\n\t\t\\end{tabular}\n\t\t\\caption{Resource utilization: optimizations as in \\ref{1-b} \\ref{attempt3} and memory repartitioning}\n\t\t\\label{1-c-resources}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{cc}\n\t\t\tModule & Number of instances \\\\\n\t\t\t\\hline\n\t\t\tfloating point adder & 16 \\\\\n\t\t\tfloating point multiplier & 16\n\t\t\\end{tabular}\n\t\t\\caption{Utilization of multipliers and adders: optimizations as in \\ref{1-b} \\ref{attempt3} and memory repartitioning}\n\t\t\\label{1-c-resources-arithmetic}\n\t\\end{table}\n\n\tAs we can see, the hardware usage does not exeed any limits in this configuration. The next step for memory optimization would be a repartitioning into $16$ groups.\n\tThis allows higher parallelism, but also increases the amount of multipliers and adders by factor $4$. In this configuration, the usage of flipsflops would exeed the maximum by $5\\%$. This overhead might be solved by more detailed optimizations during hardware implementation, but here it does not meet our requirements.\n\tIntermediate partition steps between $8-16$ result in a significant increase of latency, most likely caused by the misaligned memory groupings, which causes additional control hardware.\n\n\t\\subsection{Amortizing Iteration Latency with Batching}\n\tThe optimization step exploits that initialization overhead does not increase proportionally with increasing batch size. The batch size is now $256$, the largest possible value, as power to two, for given hardware resources.\n\n$\\Rightarrow$ speedup of $\\approx 92.84 $ regarding the max latency compared to the baseline code and normalized to batch size\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t79392&  79392&  79393&  79393&   none  \n\t\t\\end{tabular}\n\t\t\\caption{Performance:  batch size increased to $256$ and optimizations as in \\ref{1-c}}\n\t\t\\label{1-d-perf-table}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{lcccc}\n\t\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\t\\hline\n\t\t\tDSP              &        -&      -&       -&      -\\\\\n\t\t\tExpression       &        -&      -&       0&   3704\\\\\n\t\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\t\tInstance         &        0&     80&    5604&  11416\\\\\n\t\t\tMemory           &      154&      -&       0&      0\\\\\n\t\t\tMultiplexer      &        -&      -&       -&   6324\\\\\n\t\t\tRegister         &        -&      -&   32591&  14129\\\\\n\t\t\t\\hline\n\t\t\tTotal            &      154&     80&   38195&  35573\\\\\n\t\t\tAvailable        &      280&    220&  106400&  53200\\\\\n\t\t\t\\hline\n\t\t\tUtilization ($\\%$)  &       55&     36&      35&     66\n\t\t\\end{tabular}\n\t\t\\caption{Resource utilization: batch size increased to $256$ and optimizations as in \\ref{1-c}}\n\t\t\\label{1-d-resources}\n\t\\end{table}\n\n\n\\subsection{Extending Batch Size with Tiling}\n\tNow the batch size increased to $2048$, but the batch is separated into tiles of size $128$. The usage of \\texttt{BRAM\\_18K} Blocks is now lower, whereas the normalized speedup increased a lot.\n\n\t$\\Rightarrow$ speedup of $\\approx 11507.26 $ regarding the max latency compared to the baseline code and normalized to batch size\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{ccccc}\n\t\t\t\\multicolumn{2}{c}{Latency} & \\multicolumn{2}{c}{Interval} & Pipeline\\\\\n\t\t\t\\hline\n\t\t\tmin  &   max  &   min  &   max  &   Type  \\\\\n\t\t\t655889&  655889&  655890&  655890&   none  \n\t\t\\end{tabular}\n\t\t\\caption{Performance: tiling and optimizations as in \\ref{1-c}}\n\t\t\\label{1-e-perf-table}\n\t\\end{table}\n\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{lcccc}\n\t\t\tName      & BRAM\\_18K& DSP48E&   FF   &  LUT  \\\\\n\t\t\t\\hline\n\t\t\tDSP              &        -&      -&       -&      -\\\\\n\t\t\tExpression       &        -&      -&       0&   3632\\\\\n\t\t\tFIFO             &        -&      -&       -&      -\\\\\n\t\t\tInstance         &        0&     80&    5604&  11416\\\\\n\t\t\tMemory           &       86&      -&       0&      0\\\\\n\t\t\tMultiplexer      &        -&      -&       -&   6319\\\\\n\t\t\tRegister         &        -&      -&   32542&  14129\\\\\n\t\t\t\\hline                                              \\\\\n\t\t\tTotal            &       86&     80&   38146&  35496\\\\\n\t\t\tAvailable        &      280&    220&  106400&  53200\\\\\n\t\t\t\\hline                                              \\\\\n\t\t\tUtilization ($\\%$)  &       30&     36&      35&     66\n\t\t\\end{tabular}\n\t\t\\caption{Resource utilization:tiling and optimizations as in \\ref{1-c}}\n\t\t\\label{1-e-resources}\n\t\\end{table}\n\n\t\\subsection{Hardware compilation and FPGA testing on the PYNQ}\n\tUploading and execution of the Jupyther notebook unfortunately gives the following error:\n\t\\begin{lstlisting}[basicstyle=\\tiny]\n\tTimeoutError                              Traceback (most recent call last)\n<ipython-input-3-28b2e4095493> in <module>()\n      7 start_t = time()\n      8 dma1.transfer((CLASSES+CLASSES*FEAT+BATCH*FEAT)*4, direction=0)\n----> 9 dma2.wait()\n     10 fpga_time = time()-start_t\n     11\n\n/opt/python3.6/lib/python3.6/site-packages/pynq/drivers/dma.py in wait(self, wait_timeout)\n    439         with timeout(seconds = wait_timeout, error_message = Error):\n    440             while True:\n--> 441                 if libdma.XAxiDma_Busy(self.DMAengine,self.direction) == 0:\n    442                     break\n    443\n\n/opt/python3.6/lib/python3.6/site-packages/pynq/drivers/dma.py in handle_timeout(self, signum, frame)\n    173\n    174     def handle_timeout(self, signum, frame):\n--> 175         raise TimeoutError(self.error_message)\n    176\n    177     def __enter__(self):\n\nTimeoutError: DMA wait timed out.\n\t\\end{lstlisting}\n\n\t\\paragraph{\\textit{UPDATE: }} This problem is now fixed. The FPGA was programmed in order to receive the offset values and the full weight matrix in each iteration, whereas this is only required once in the beginning. \n\tThe implementation on the FPGA gives a speedup of $6.74$. The validation error $14.79\\%$ is as good as on the CPU.\n\n\n\\end{document}\n\n\n\n", "meta": {"hexsha": "dd7b875b46db6a61e351cd3aa18600b16015628c", "size": 15092, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/subfiles/part1.tex", "max_stars_repo_name": "swappad/cs5222-lab-fpga-mlp", "max_stars_repo_head_hexsha": "46fb9cb798460474c16f2f60a89a0807307fb971", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-08T08:38:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T08:38:36.000Z", "max_issues_repo_path": "report/subfiles/part1.tex", "max_issues_repo_name": "swappad/cs5222-lab-fpga-mlp", "max_issues_repo_head_hexsha": "46fb9cb798460474c16f2f60a89a0807307fb971", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/subfiles/part1.tex", "max_forks_repo_name": "swappad/cs5222-lab-fpga-mlp", "max_forks_repo_head_hexsha": "46fb9cb798460474c16f2f60a89a0807307fb971", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1382978723, "max_line_length": 494, "alphanum_fraction": 0.5667240922, "num_tokens": 4987, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.44373128489895297}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n\\input{../header2.tex}\n\n\\title{Phys 220A -- Classical Mechanics -- Lec07}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{23}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\setlength{\\unitlength}{1mm}\n\\maketitle\n\n\n%\\section{Lagrange points}\n%Placed in Lec06 material\n\n\n\n\\section{Parametric resonance}\nQuestion: If a swing has a stable equilibrium how can you make it swing higher and higher?\n\nLet's look at a simple example where we set the mass equal to 1\n\\begin{equation}\nL = \\frac{1}{2} \\dot{q}^2 - \\frac{1}{2} \\omega(t)^2 q^2\n\\end{equation}\nwhere $\\omega(t + T) = \\omega(t)$, i.e. is a periodic function. The simplest example of this is\n\\begin{equation}\n\\omega(t)^2 = \\omega_0^2 \\left( 1 + \\epsilon \\cos\\left(\\frac{2\\pi t}{T}\\right)\\right)\n\\end{equation}\nwhere $\\epsilon$ is small. Let's now assume that $T = 2\\pi$\n\nOur equation of motion is thus\n\\begin{equation}\n\\ddot{q} + \\omega^2(t) q = 0\n\\end{equation}\nWe can rewrite this as a first order system\n\\begin{equation}\nx_1 = q\n\\end{equation}\n\\begin{equation}\nx_2 = \\dot{q}\n\\end{equation}\nand\n\\begin{equation}\n\\dot{x_1} = x_2\n\\end{equation}\n\\begin{equation}\n\\dot{x_2} = -\\omega^2(t) x_1\n\\end{equation}\nwith \n\\begin{equation}\n\\v{x} = \\left( \\begin{array}{c} x_1 \\\\ x_2\\end{array}\\right)\n\\end{equation}\nThen our equation becomes\n\\begin{equation}\n\\dot{\\v{x}} = M(t) \\v{x}\n\\end{equation}\nwhere $M(t)$ is also a periodic function. The solution is a matrix integral\n\\begin{equation}\n\\v{x(t)} = P \\int_0^z dt M(t) \\v{x}(0)\n\\end{equation}\nBut we know that the solution is periodic\n\\begin{equation}\nx(t + 2\\pi) = A\\v{x}(t)\n\\end{equation}\nThe long time development goes as\n\\begin{equation}\nx(t + 2\\pi n) = A^n\\v{x}(t)\n\\end{equation}\nThis is a generalized 2 by 2 matrix\n\\begin{equation}\n\\lambda^2 - Tr(A) \\lambda + Det(A) = 0\n\\end{equation}\nCan show that \n\\begin{equation}\n\\lambda_\\pm = \\frac{\\hbar}{2} \\pm \\sqrt{ \\frac{(\\hbar A)^2}{4}  - 1}\n\\end{equation}\nThis gives us a stability condition of \n\\begin{equation}\n\\hbar A < 2\n\\end{equation}\nFor a general $\\omega$ the analysis is difficult, but we can consider a small perturbation and look at the unperturbed case\n\\begin{equation}\n\\omega^2(t) = \\omega_0^2\n\\end{equation}\n\\begin{equation}\n\\dot{x_1} = x_2\n\\end{equation}\n\\begin{equation}\n\\dot{x_2} = -\\omega^2 x_1\n\\begin{equation}\n\\begin{equation}\nM = \\left( \\begin{array}{cc} 0 & 1 \\\\ \\omega_0^2 & 0  \\end{array} \\right)\n\\end{equation}\n\\begin{equation}\nA(t) = exp(Mt) = \\left( \\begin{array}{cc} \\cos\\omega_0 & \\frac{\\sin\\omega t}{\\omega_0} \\\\ -\\omega_0^2\\sin\\omega_0 t & \\cos\\omega_0t  \\end{array} \\right)\n\\end{equation}\n\\begin{equation}\nA(t=2\\pi) = \\left( \\begin{array}{cc} \\cos2\\pi\\omega_0 & \\frac{\\sin2\\pi\\omega}{\\omega_0} \\\\ -\\omega_0^2\\sin2\\pi\\omega_0  & \\cos2\\pi  \\end{array} \\right)\n\\end{equation}\nWe get\n\\begin{equation}\n\\omega_0 = 0, \\frac{1}{2}, 1, \\frac{3}{2}\n\\end{equation}\nWhen one is away from the $\\omega_0$ then the motion is stable even for small $\\epsilon$. The $\\omega_0$ are the frequencies of parametric resonance. \n\n\\section{Legendre transform (for Hamiltonian mechanics)}\n\nGiven a function $f(x)$, we say that it is convex if $f''(x) > 0$. If it is, then we will have a Legendre transform\n\\begin{eqn}\n\\mathcal{L} : f(x) \\mapsto (\\mathcal{L}f)(p)\n\\end{eqn}\ntaking $f(x)$ from position space to a function $(\\mathcal{L}f)(p)$ in momentum space. Define\n\\begin{eqn}\nF(p,x) = px - f(x),\n\\end{eqn}\nwhich we picture as the difference between a line of slope $p$ and the convex function $f(x)$. Then the Legendre transformed function is defined as\n\\begin{eqn}\n(\\mathcal{L}f)(p) = \\sup_{x \\in \\reals} F(p,x). \n\\end{eqn}\nPut another way, given $p$ there exists some $x(p)$ which maximizes $F(p,x)$, i.e.\n\\begin{eqn}\n\\eval[3]{\\pd{F}{x}(p,x)}_{x = x(p)} = 0,\n\\end{eqn}\nThen we have \n\\begin{eqn}\n\\mathcal{L}f(p) = F(p,x(p)).\n\\end{eqn}\n\n[missed examples here: $f(x) = ax^2$ and $f(x) = x^a / a$]\n\nAn important property of Legendre transforms is that they are \\textit{involutions}, that is the Legendre transform squares to the identity. In other words,\n\\begin{eqn}\n\\mathcal{L}^2 f(x) = \\mathcal{L}(\\mathcal{L}f)(x) = f(x).\n\\end{eqn}\nAnother useful property is \\textit{Young's inequality},\n\\begin{eqn}\npx - f(x) \\leq \\mathcal{L}f(p).\n\\end{eqn}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "9dbacf8f753ee963061514770a9a4c163b74c5e0", "size": 4465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "classical/lec07.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "classical/lec07.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "classical/lec07.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3741496599, "max_line_length": 155, "alphanum_fraction": 0.6835386338, "num_tokens": 1649, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.4437312753943299}}
{"text": "\\input{settings}\n\n\\begin{document}\n\n\\lhead{Hyperparameter tuning, Regularization \\\\ and Optimization}\n\\rhead{ Deep Learning specialization}\n\\cfoot{\\thepage \\ of \\pageref{LastPage}}\n\n\\subsection*{Hyperparameter tuning process}\n\nUsually the most important hyper parameter is $\\alpha$ the learning rate. Second in \nimportance are the number of hidden units, the mini-batch size and the $\\beta$ momentum\nterm. Third in importance are the number of layers and the learning rate decay.\n\nWhich hyperparemeters to try? Try random values; don't use a grid search. Also it's \ncommon to use the \"coarse to fine\" sampling schema where you start by sampling randomly\nin a region, then pick a good subregion and continue sampling in smaller and smaller regions.\n\n\\textbf{Use an appropiate scale to pick hyperparameters:} Don't necessarily sample \nthe hyperparameters randomly. For example if you are searching hyperparameters for the\nlearning rate $\\alpha \\in [.001, 1]$ uniformly then $90$\\% of the values you're \ntrying lie between $.1$ and $1$, it would be more appropiate to use a log scale and sample\nuniformly from using that scale so that you explore more than 10\\% between $[.001,.1]$.\n\n\\subsection*{Batch Normalization}\n\nBatch normalization makes the hyperparameter search problem much easier and the \nneural network trained much more robust. The choice of hyperparameters is a much bigger \nrange  of hyperparameters that work well, and will also enable you to much more easily train \neven very deep networks.\n\nFor any hidden layer, can we normalize the value $a^{[l]}$ to train $W^{[l+1]}, b^{[l+]}$ \nfaster? That's the main idea of batch normalization, in the practice $z^{[l]}$ is \nthe one that's normalized. \n\nGiven $z^{[l]} = (z^{(1)}, \\dots, z^{(m)})$:\n\\begin{align*}\n    \\mu_i &= \\frac{1}{m} \\sum_{i} z^{(i)} \\\\\n    \\sigma_i^2 &= \\frac{1}{m} \\sum_{i} (z^{(i)} - \\mu_i)^2 \\\\\n    z^{(i)}_{\\text{norm}} &= \\frac{z^{(i)} - \\mu_i}{\\sqrt{\\sigma_i^2 + \\epsilon}} \\\\\n    \\hat{z}^{(i)} &= \\gamma z^{(i)}_{\\text{norm}} + \\beta\n\\end{align*}\nWhere $\\gamma$ and $\\beta$ are learnable parameters of the model that can modify the \ndistribution of $z^{(i)}$ so that it lies in the range of values you need.\n\nBatch normalization reduces the problem of the input values (of each layer) changing,\nit causes these values to become more stable, so that the later layers of the \nneural network has more firm ground to stand on.\n\n\\textbf{Batch norm as Regularization} Each mini-batch is scaled by the mean and variance\ncomputed on just that mini-batch, this adds some noice the values $z^{[l]}$ because\nit's just computed on one mini-batch. This noisy procedure is similar to dropout \nhaving a slight regularization effect. \n\n\\textbf{Batch norm at test time} During test time the estimations of $\\mu$ and $\\sigma^2$\nare obtained using exponentially weighted averages (across mini-batches)\n\n\\subsection*{Multi-class classification}\n\nThink of the problem of classificating across multiple ($C$) classes, instead of just two as\nwe've seen so far. This problem is called \\textit{multi-class classficiation}, for it\nwe'll start to introduce a generalization of the logistic regression called softmax \nregression, softmax regression generalizes logistic regression to $C$ classes. \n\nThe softmax activativation function is given by:\n\\begin{align*}\n    t &= e^{(z^{[l]})} \\\\\n    a_i^{[l]} &= \\dfrac{t_i}{\\sum_{i} t_i}\n\\end{align*}\n\\textbf{Training a softmax classifier,} the loss function and cost functions are given by:\n\\begin{align*}\n    L(\\hat{y},y) &= - \\sum_{j=1}^C y_j \\log{\\hat{y_j}} \\\\\n    J(W,b) &= \\frac{1}{m} \\sum_{i=1}^m L(\\hat{y},y)\n\\end{align*}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "3bb053e99ce560731934f9dee07fabf52a23500d", "size": 3649, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "course-2-improving-neural-networks/notes/Note_3_hyperparameter_tuning.tex", "max_stars_repo_name": "SergioArnaud/deep-learning-specialization", "max_stars_repo_head_hexsha": "6e2b7f553ad7b15f1c58d6efbce6ed8fb6fbff75", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-03T02:10:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-04T00:07:13.000Z", "max_issues_repo_path": "course-2-improving-neural-networks/notes/Note_3_hyperparameter_tuning.tex", "max_issues_repo_name": "SergioArnaud/deep-learning-specialization", "max_issues_repo_head_hexsha": "6e2b7f553ad7b15f1c58d6efbce6ed8fb6fbff75", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "course-2-improving-neural-networks/notes/Note_3_hyperparameter_tuning.tex", "max_forks_repo_name": "SergioArnaud/deep-learning-specialization", "max_forks_repo_head_hexsha": "6e2b7f553ad7b15f1c58d6efbce6ed8fb6fbff75", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.1898734177, "max_line_length": 93, "alphanum_fraction": 0.7254042203, "num_tokens": 1006, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.8056321843145404, "lm_q1q2_score": 0.4435870145958303}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\begin{document}\n\n\\part {Sampled stabilization}\n\n\\section{Definitions}\n\nLet $I_1, \\dots, I_K$ be the $K$ inputs, and $B_k$ the set of points that are in input $I_k$.\n\nWe denote the geometric transformation between input and panorama space by $T_{I_k \\rightarrow P} = T_{S \\rightarrow P} \\circ T_{I_k \\rightarrow S}$,\nwhere $S$ is the intermediate spheric space. Note that $T_{S \\rightarrow P}$ does not depend on $k$, which we use in the following.\n\nLet $r_k$ be the input sensor's inverse response for input $k$. Typical responses are:\n\\begin{itemize}\n  \\item Linear: $r_k(r, g, b) = (r, g, b)$\n  \\item Gamma: $r_k(r, g, b) = (r^\\gamma, g^\\gamma, b^\\gamma)$\n  \\item (Inverse) Emor: $r_k(r, g, b) = (f(r), f(g), f(b))$ where $f(x) = f_0 + \\sum_{i=1}^{5}{\\mu_i h_i}$ and the $\\mu_i$ are called \\em{emor coefficients}.\n\\end{itemize}\n\nSimilary, the panorama output has a inverse response $R(r, g, b)$.\n\nIn addition, photometric correction happens in between $r_k$ and $R$.\nThis is linear transformation of the colors weighted by a vignetting function $v$ that depends on the distance from $p$ to the vignetting center $c_k$ of the input.\n$d_k(p,r,g,b) = v_k(p) M_k (r,g,b)^\\top$ . In our implementation $M_k$ is diagonal, and $v(p)$ is an inverse polynomial of degree $6$ with zero even coefficients.\n\n\\begin{equation}\n  M_k = diag({m^r}_k 2^{e_k - e_P}, {m^g}_k 2^{e_k - e_P}, {m^b}_k 2^{e_k - e_P})\n\\end{equation}\n\n\\begin{equation}\n  v_k(p) = \\frac{1}{\\nu_3 \\rho_k^3 + \\nu_2 \\rho_k^2 + \\nu_1 \\rho_k + \\nu_0}, \\rho_k(p) = {\\| p - c_k\\|}^2\n\\end{equation}\n\nWhere the $e_k$ and $e_P$ are the exposure values of the inputs and the panorama respectively, and $\\mathbf{m^r}$, $\\mathbf{m^g}$ and $\\mathbf{m^b}$ and the color correction coefficients.\n\nIf a point $p$ in input $k$ has a color $C_k(p) = (r(p), g(p), b(p))$, then the color of its image in the panorama just before blending\nis\n\\begin{equation}\n C_P(T_{I_k \\rightarrow P}(p)) = C_P(T_{I_k \\rightarrow S}(p)) = R^{-1} \\circ d_k(p) \\circ r_k (C_k(p))\n\\end{equation}\n \nNote that all $r_k$ and $R$ are monotonic of same direction along all components.\n\n\\section{Sampling}\n\nFor each input $k$, we draw points $p_{1,k}, p_{i,k}, \\dots$ with a probability distribution $P$. \n\n$P$ should be chosen such that there are more points around the image borders (where images have most chanches to overlap).\n\nLet $p_{i,l}$ the projection of $p_{i,k}$ into input $l$. This is computable implicitly without doing explicit panorama\ntransformations $T_{I_k \\rightarrow P}$ and $T_{I_l \\rightarrow P}$ by applying only the input\nspace to spheric space transformation $T_{I_k \\rightarrow S}$ followed by the spheric space to input space transformation $T^{-1}_{I_l \\rightarrow S}$.\n\nFor each drawn point $p_{i,k}$, we compute $p_{i,l} = T^{-1}_{I_l \\rightarrow S} \\circ T_{I_k \\rightarrow S} (p_{i,k})$ for all $l \\in {1,\\dots,K}$.\nNote that by definition:\n\n\\begin{equation}\n  T_{I_k \\rightarrow P}(p_{i,k}) = T_{I_l \\rightarrow P}(p_{i,l})\n\\end{equation}\n\nDoing the computations implicitly in the input space instead of explicitly in the output space has a lot of advantages:\n\n\\begin{enumerate}\n  \\item {\\bf Less computation:} No need to apply the pano transform transform, we only need to sample from the inputs.\n  \\item {\\bf Smaller memory footprint:} No need to allocate output and mapping buffers, only the reader buffers are needed.\n  \\item {\\bf Independant on the output projection:} Zero cases to handle instead of {\\em equirect}, {\\em stereographic},...\n  \\item {\\bf Independant on the output transformation:} we don't care about any global tranformation since the formulation is independant of the output. Therefore we need to sample input points {\\bf only once for the whole duration of the video}. This is the most important part.\n\\end{enumerate}\n\nThe {\\em multipoint} $p_i$ is the set of images of $p_{i,1}$ in all inputs:\n\n\\begin{equation}\n  p_i = \\{p_{i,k} \\mid  p_{i,k} \\in B_k\\}\n\\end{equation}\n\nWe use as sample points for computing exposure correction the points $p_i$ that link at least two images together:\n\n\\begin{equation}\n  S = \\{p_i \\mid \\#p_i >= 2\\}\n\\end{equation}\n\nTo simplify notations, we reorder the $p_i$ such that $\\forall 1 <= i <= N$, $p_i \\in S$.\n\n\n\\section{Spacial exposure correction}\n\nWe're trying to minimize the spacial photometric error for each frame at time $t$:\n\n\\begin{align}\n  E_S(\\mathbf{e}_t) &= \\sum_{i=1}^{N}{ \\sum_{(p_{i,k}, p_{i,l}) \\in p_i} { {\\| C_P(T_{I_l \\rightarrow S}(p_{i,k})) - C_P(T_{I_l \\rightarrow S}(p_{i,l})) \\|}^2 } } \\\\\n                  &= \\sum_{i=1}^{N}{ \\sum_{(p_{i,k}, p_{i,l}) \\in p_i} { {\\| R^{-1} \\circ d_k(p_{i,k}) \\circ r_k (C_k(p_{i,k})) - R^{-1} \\circ d_l(p_{i,l}) \\circ r_l (C_l(p_{i,l})) \\|}^2 } }\n\\end{align}\n\nWhere $C_P$ stands for the color in panorama space (e.g. the $(r, b, g)$ triple).\n\n\\section{Penalization}\n\nThere are more degrees of freedom that this minimization can impose, so we add a penalization term to that the sum of exposure values does not drift too far from their base state.\n\nThe classical penalization term:\n\\begin{equation}\n  E_P(\\mathbf{e}_t) = \\sum_k{e_k^2}\n\\end{equation}\ndoes not work here since the exposure values will just go down (less light, less error) until the penalization term above stops them at an arbitrary equilibrium value.\n\nThe following term is a lot better:\n\\begin{equation}\n  E_P(\\mathbf{e}_t) = {\\frac{\\sum_k{e_k}}{K}}^2\n\\end{equation}\n\nThe idea is to make sure that the average exposure value does not float away from zero, but individual exposures can.\n\n\\part {Histogram stabilization}\n\nThe idea is to compute histograms for each of the inputs of overlapping zones, and trying to make sure that histograms match.\nThe interesting property is that it's possible to compute these histograms with a specific merger.\n\nThe relationship between the color parameters and the histograms is non-linear (gamma or emor), so we need to compute the histogram in linear space and then,\nfor each optimization iteration, use the emor lookup table to convert the linear histogram into the final histogram.\n\n\\section{Definitions}\n\nWe call $\\mathbf{{h^r}_{k,l}}$, $\\mathbf{{h^g}_{k,l}}$, $\\mathbf{{h^b}_{k,l}}$ the histogram of pixels in input $k$ that\noverlap with pixels in output $l$ for color components $r$, $g$, and $b$ respectively:\n\n\\begin{equation}\n  {h^r}_{k,l,i} = \\sum_{(p, q) \\in (I_k, I_l), T_{I_k \\rightarrow P}(p) = T_{I_l \\rightarrow P}(q)}{C_P(T_{I_k \\rightarrow P}(p)) == i)}\n\\end{equation}\n\nWe're trying to find the exposure correction parameter values that minimize the discrepancies between histograms of overlapping inputs:\n\n\\begin{equation}\n  E(\\mathbf{e}_t) = \\sum_{k,l}{\\sum_c{d(\\mathbf{{h^c}_{k,l}}, \\mathbf{{h^c}_{l,k}})}}\n\\end{equation}\n\nwhere $d$ is a histogram distance metric.\n\nNote that since $R^{-1}$ is non-linear in the photometric transform $C_P$, the histogram is not simply translated by changes in the components of $\\mathbf{e}_t$,\nsince each bin moves at a different rate. Therefore me must compute the histogram with $R^{-1}(c) = c$ and then integrate the histogram transformation in $d$.\n$d$ then becomes a function of a pair of (histogram, transform) $(\\mathbf{{h^r}_{k,l}}, {R_k}^{-1})$ and $(\\mathbf{{h^r}_{l,k}}, {R_l}^{-1})$ instead of simply a pair of histograms.\n\n\n\\end{document}", "meta": {"hexsha": "36cfc30f28469c9a283ad457f88dd844dfde7304", "size": 7316, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/doc/exp_correction.tex", "max_stars_repo_name": "tlalexander/stitchEm", "max_stars_repo_head_hexsha": "cdff821ad2c500703e6cb237ec61139fce7bf11c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 182, "max_stars_repo_stars_event_min_datetime": "2019-04-19T12:38:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T16:48:20.000Z", "max_issues_repo_path": "lib/doc/exp_correction.tex", "max_issues_repo_name": "tlalexander/stitchEm", "max_issues_repo_head_hexsha": "cdff821ad2c500703e6cb237ec61139fce7bf11c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 107, "max_issues_repo_issues_event_min_datetime": "2019-04-23T10:49:35.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T18:12:28.000Z", "max_forks_repo_path": "lib/doc/exp_correction.tex", "max_forks_repo_name": "tlalexander/stitchEm", "max_forks_repo_head_hexsha": "cdff821ad2c500703e6cb237ec61139fce7bf11c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 59, "max_forks_repo_forks_event_min_datetime": "2019-06-04T11:27:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T23:49:49.000Z", "avg_line_length": 50.8055555556, "max_line_length": 279, "alphanum_fraction": 0.7009294697, "num_tokens": 2240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387914176258, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.44356384471521404}}
{"text": "\\documentclass{article}\n\\usepackage[utf8x]{inputenc} % codifica scrittura\n\\usepackage[nochapters]{classicthesis} % nochapters\n\n\\usepackage[T1]{fontenc}\n\\usepackage[square,numbers]{natbib}\n\\usepackage{amsmath, amsthm, amssymb, amsfonts, tikz}\n\\usetikzlibrary{snakes}\n\\usepackage{titletoc}\n\\usepackage{verbatim}\n\\usepackage{hyperref}\n\\usepackage{boxedminipage}\n\n\\titlecontents{section}[3em]{}{\\contentslabel{1em}}{}{\\titlerule*[1.5pc]{.}\\contentspage}\n\\titlecontents{subsection}[6em]{}{\\contentslabel{2em}}{}{\\titlerule*[1.5pc]{.}\\contentspage}\n\n\\begin{document}\n\n\\title{\\rmfamily\\normalfont\\spacedallcaps{Computer Aided Graphic\n    Design course exercises}}\n\n\\author{\\spacedlowsmallcaps{Massimo Nocentini}}\n\\date{\\today}\n\n\\maketitle\n\n\n\\begin{abstract}\n  This document contains some exercises and collects my work done during\n  the CAGD course given by Prof. Alessandra Sestini and Prof. Costanza\n  Conti at University of Florence.\n\n  In particular, here we collect exercises requested by Prof.\n  Costanza Conti about Bezier and BSplines curves. We implement numerical\n  methods using Julia  language \\cite{Julia} and everything (code for\n  solving exercises and \\TeX sources of this document) is under\n  version control, available as open source Git repository\n  \\footnote{Hosted on \\url{http://github.com/massimo-nocentini/cagd}},\n  under \\emph{MIT License}.\n\\end{abstract}\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Bezier curves}\n\n\\subsection{Curve from simple set of control points}\nIn \\autoref{fig:first-closed-curve} we report the very first Bezier\ncurve obtained using our implementation. The curve is obtained using control\npoints $(1,1), (3,4), (5,6),(7,8),(10,2),(1,1)$ in the given\norder. This plot was the first test for our implementation of code\nreported in Exercise 1 and requested in Exercise 2: it contains a\nsegmented curve in green which is the control polygon, and a Bezier\ncurve in red built using the given control points.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-one}\n  \\caption{Curve from simple set of control points}\n  \\label{fig:first-closed-curve}\n\\end{figure}\n\n\\subsection{Curve from parametric specification}\nAs required in Exercise 3, in \\autoref{fig:curve-from-parametric-spec}\nwe report a Bezier curve matching the following parametric\nspecification:\n\\begin{displaymath}\n  \\left [  \\begin{array}{c}\n      x(u) \\\\\n      y(u)\n    \\end{array} \\right ] = \\left [\n    \\begin{array}{c}\n      1 + u + u^2 \\\\\n      u^3\n    \\end{array} \\right ]\n\\end{displaymath}\nwith $u\\in[0,1]$. In order to find the control polygon we do simple\nreductions with \\emph{Maxima}:\n\n\\noindent\n%%%%%%%%%%%%%%%\n%%% INPUT:\n\\begin{verbatim}\na:v0*(1-t)^3 + v1*3*t*(1-t)^2 + v2*3*(t^2)*(1-t) + v3*t^3;\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o1) }\n{t}^{3}\\,v3+3\\,\\left( 1−t\\right) \\,{t}^{2}\\,v2+3\\,{\\left( 1−t\\right) }^{2}\\,t\\,v1+{\\left( 1−t\\right) }^{3}\\,v0\n\\end{math}\n\n\n\\noindent\n%%%%%%%%%%%%%%%\n% %%% INPUT:\n% \\begin{minipage}[t]{8ex}{\\color{red}\\bf\n% \\begin{verbatim}\n% (%i2)\n% \\end{verbatim}}\n% \\end{minipage}\n% \\begin{minipage}[t]{\\textwidth}{\\color{blue}\n\\begin{verbatim}\nb:ratsimp(a,t);\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o2) }\n{t}^{3}\\,\\left( v3−3\\,v2+3\\,v1−v0\\right) +{t}^{2}\\,\\left( 3\\,v2−6\\,v1+3\\,v0\\right) +t\\,\\left( 3\\,v1−3\\,v0\\right) +v0\n\\end{math}\n\n\\noindent\n%%% INPUT:\n\\begin{verbatim}\nb = 1 + t + t^2 + 0*t^3;\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o3) }\n{t}^{3}\\,\\left( v3−3\\,v2+3\\,v1−v0\\right) +{t}^{2}\\,\\left( 3\\,v2−6\\,v1+3\\,v0\\right) +t\\,\\left( 3\\,v1−3\\,v0\\right) +v0={t}^{2}+t+1\n\\end{math}\n\n\n\\noindent\n%%% INPUT:\n\\begin{verbatim}\nsolve([coeff(b, t,3) = 0, coeff(b, t,2) = 1, coeff(b, t,1) = 1,\n        coeff(b, t,0) = 1], [v0,v1,v2,v3]);\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o4) }\n[[v0=1,v1=\\frac{4}{3},v2=2,v3=3]]\n\\end{math}\n%%%%%%%%%%%%%%%\n\n\n\\noindent\n%%%%%%%%%%%%%%%\n%%% INPUT:\n\\begin{verbatim}\na:y0*(1-t)^3 + y1*3*t*(1-t)^2 + y2*3*(t^2)*(1-t) + y3*t^3;\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o5) }\n{t}^{3}\\,y3+3\\,\\left( 1−t\\right) \\,{t}^{2}\\,y2+3\\,{\\left( 1−t\\right) }^{2}\\,t\\,y1+{\\left( 1−t\\right) }^{3}\\,y0\n\\end{math}\n%%%%%%%%%%%%%%%\n\n\n\\noindent\n%%%%%%%%%%%%%%%\n%%% INPUT:\n\\begin{verbatim}\nb:ratsimp(a,t);\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o6) }\n{t}^{3}\\,\\left( y3−3\\,y2+3\\,y1−y0\\right) +{t}^{2}\\,\\left( 3\\,y2−6\\,y1+3\\,y0\\right) +t\\,\\left( 3\\,y1−3\\,y0\\right) +y0\n\\end{math}\n%%%%%%%%%%%%%%%\n\n\n\\noindent\n%%%%%%%%%%%%%%%\n%%% INPUT:\n\\begin{verbatim}\nb = t^3;\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o7) }\n{t}^{3}\\,\\left( y3−3\\,y2+3\\,y1−y0\\right) +{t}^{2}\\,\\left( 3\\,y2−6\\,y1+3\\,y0\\right) +t\\,\\left( 3\\,y1−3\\,y0\\right) +y0={t}^{3}\n\\end{math}\n%%%%%%%%%%%%%%%\n\n\n\\noindent\n%%%%%%%%%%%%%%%\n%%% INPUT:\n\\begin{verbatim}\nsolve([coeff(b, t,3) = 1, coeff(b, t,2) = 0, coeff(b, t,1) = 0,\n        coeff(b, t,0) = 0], [y0,y1,y2,y3]);\n\\end{verbatim}}\n%%% OUTPUT:\n\\definecolor{labelcolor}{RGB}{100,0,0}\n\n\\begin{math}\\displaystyle\n\\parbox{8ex}{\\color{labelcolor}(\\%o8) }\n[[y0=0,y1=0,y2=0,y3=1]]\n\\end{math}\n%%%%%%%%%%%%%%%\n\nHence four control points are $\\{(1,0), (\\frac{3}{4},0), (2,0),\n(3,1)\\}$.\n\\begin{figure}\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-two}\n  \\caption{Curve from parametric specification}\n  \\label{fig:curve-from-parametric-spec}\n\\end{figure}\n\n\\subsection{Splitted curve on a given parameter $\\hat{t}$}\nAs required in Exercise 4, in \\autoref{fig:splitted-curve} we report\nthe control polygon for the original curve in red, and two sets of\ncontrol points with the same cardinality that, used together, build a\nBezier that is the same as the original one. Those sets of points are\nobtained via subdivision algorithm (which is a clever implementation of\nclassic \\emph{de Casteljau algorithm}) fixing parameter $\\hat{t} =\n\\frac{1}{4}$: they are colored in green (the relative Bezier in magenta)\nand in blue (the relative Bezier in cyan), respectively.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-four}\n  \\caption{Splitted curve}\n  \\label{fig:splitted-curve}\n\\end{figure}\n\n\\subsection{Repeating the same control point more times}\nAs required in Exercise 5, in\n\\autoref{fig:repeating-same-control-point} we report two Bezier curves: the\nred one relative to control points $\\{(2,4), (6,12), (10,1),\n(12,12)\\}$ the green one relative to control points $\\{(2,4), (6,12),\n(10,1), (10,1), (10,1), (10,1), (12,12)\\}$, ie. with the point\n$(10,1)$ repeated three more times. We see that curve relative to\nthe augmented control polygon goes down toward $(10,1)$ more than the\nother curve: this can be explained from a probabilistic point of\nview, since a Bezier curve can be thought as a \\emph{mean} of the control\npolygon, hence repeating point $(10,1)$ increases its weight.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-five}\n  \\caption{Repeating the control point $(10,1)$ three more times}\n  \\label{fig:repeating-same-control-point}\n\\end{figure}\n\n\\subsection{Increasing degree}\nAs required in Exercise 6, we start from an original set of control\npoints, plotted in \\autoref{fig:increasing-degree-original-curve}, and\nwe proceed by increasing degrees of successive Bezier curves three times.\nWe obtains three augmented set of control points, plotted in\n\\autoref{fig:some-increased-degrees}, respectively. It is possible to\ncheck the slow convergence for the sequence of polygons to the Bezier\ncurve and, in \\autoref{fig:increasing-degree-does-change-curve}, the\nBezier curves relative to each augmented polygons doesn't change in\nshape, ie their set of points equal the original one (we simply plot\nthose Bezier curves in the same plot and each one is over the others).\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-six-original}\n  \\caption{Original curve before increasing degree}\n  \\label{fig:increasing-degree-original-curve}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-six-higher-degree-control-poly}\n  \\caption{Some control polygons, each one with one more degree}\n  \\label{fig:some-increased-degrees}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-six-one-more-degree-comparison}\n  \\caption{Increasing degree doesn't change the Bezier shape}\n  \\label{fig:increasing-degree-does-change-curve}\n\\end{figure}\n\n\\subsection{Joining curve requiring $\\mathcal{C}^0, \\mathcal{C}^1, \\mathcal{C}^2$}\n\nIn this section we report plots about Bezier spline curves,\nextending a fixed control net, requiring $\\mathcal{C}^0,\n\\mathcal{C}^1, \\mathcal{C}^2$ for each extension, both on the right\n(see\n\\autoref{fig:bezier-spline-right-extension-continuity},\n\\autoref{fig:bezier-spline-right-extension-tangent},\n\\autoref{fig:bezier-spline-right-extension-obsculating},\nrespectively) both on the left (see\n\\autoref{fig:bezier-spline-left-extension-continuity},\n\\autoref{fig:bezier-spline-left-extension-tangent},\n\\autoref{fig:bezier-spline-left-extension-obsculating},\nrespectively).\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-continuity}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^0$, extending on the right}\n  \\label{fig:bezier-spline-right-extension-continuity}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-tangent}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^1$, extending on the right}\n  \\label{fig:bezier-spline-right-extension-tangent}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-obsculating}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^2$, extending on the right}\n  \\label{fig:bezier-spline-right-extension-obsculating}\n\\end{figure}\n\n% \\includegraphics{bezier-deCasteljau-curves/exercise-seven-a_succ_i}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-continuity-left}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^0$, extending on the left}\n  \\label{fig:bezier-spline-left-extension-continuity}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-tangent-left}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^1$, extending on the left}\n  \\label{fig:bezier-spline-left-extension-tangent}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-seven-obsculating-left}\n  \\caption{Bezier spline curve, requiring $\\mathcal{C}^2$, extending on the left}\n  \\label{fig:bezier-spline-left-extension-obsculating}\n\\end{figure}\n\n% \\includegraphics{bezier-deCasteljau-curves/exercise-seven-a_i-left}\n\n\\newpage\n\n\\subsection{First Polar of a Bezier curve}\n\nIn this section we elaborate an extra exercise relative to first derivative\nof a Bezier curve and the first step of de Casteljau algorithm.\n\nLet $\\mathbf{p}_{1}(t)$ a Bezier curve built over a control net with $n$ points\n$\\mathbf{b}_{0}^{(1)},\\ldots,\\mathbf{b}_{n-1}^{(1)}$, respect a fixed parameter $\\hat{t}$\nafter one step of de Casteljau algorithm. Just use the formal definition:\n\\begin{displaymath}\n    \\begin{split}\n        \\mathbf{p}_{1,\\hat{t}}(t)  &= \\sum_{i=0}^{n-1}{\\mathbf{b}_{i}^{(1)}(\\hat{t})B_{i}^{n-1}(t)} \\\\\n            &=  \\sum_{i=0}^{n-1}{\\left( (1-\\hat{t})\\mathbf{b}_{i}^{(0)} +\n                \\hat{t}\\mathbf{b}_{i+1}^{(0)}\\right)B_{i}^{n-1}(t)} \\\\\n            &=  \\sum_{i=0}^{n-1}{\\left( (1-\\hat{t})\\mathbf{b}_{i}^{(0)} +\n                \\hat{t}\\mathbf{b}_{i+1}^{(0)} -\\left( (1-t)\\mathbf{b}_{i}^{(0)} +\n                t\\mathbf{b}_{i+1}^{(0)}\\right)\\right)B_{i}^{n-1}(t)} +\n                \\sum_{i=0}^{n-1}{\\mathbf{b}_{i}^{(1)}(t)B_{i}^{n-1}(t)} \\\\\n            &=  \\sum_{i=0}^{n-1}{\\left( (t-\\hat{t})\\mathbf{b}_{i}^{(0)} +\n                (\\hat{t}-t)\\mathbf{b}_{i+1}^{(0)}\\right)B_{i}^{n-1}(t)} +\n                \\sum_{i=0}^{n-1}{\\mathbf{b}_{i}^{(1)}(t)B_{i}^{n-1}(t)} \\\\\n            &=  (\\hat{t}-t)\\sum_{i=0}^{n-1}{\\left(\n                \\mathbf{b}_{i+1}^{(0)} - \\mathbf{b}_{i}^{(0)}\\right)B_{i}^{n-1}(t)} +\n                \\sum_{i=0}^{n-1}{\\mathbf{b}_{i}^{(1)}(t)B_{i}^{n-1}(t)} \\\\\n    \\end{split}\n\\end{displaymath}\nwhere, with little abuse of notation, $\\mathbf{b}_{i}^{(1)}(t) =\n\\left( (1-t)\\mathbf{b}_{i}^{(0)} + t\\mathbf{b}_{i+1}^{(0)}\\right)$.\nRecall that $n\\sum_{i=0}^{n-1}{\\left(\n\\mathbf{b}_{i+1}^{(0)} - \\mathbf{b}_{i}^{(0)}\\right)B_{i}^{n-1}(t)}$ is the\nfirst derivative of a Bezier curve, hence:\n\\begin{displaymath}\n    \\begin{split}\n        \\mathbf{p}_{1, \\hat{t}}(t)  &= \\mathbf{b}_{1, t}(t) +\n        \\frac{\\hat{t}-t}{n}\\frac{\\partial \\mathbf{b}_{0, \\hat{t}}(t) }{\\partial t}\n    \\end{split}\n\\end{displaymath}\nSo, this is called the ``first polar form'' of Bezier curve $\\mathbf{b}_{0, \\hat{t}}(t)$\nrespect parameter $\\hat{t}$. Geometrically, the term $\\mathbf{b}_{1, t}(t)$ is an affine\ncombination of points $\\mathbf{b}_{0}^{(0)},\\ldots,\\mathbf{b}_{n}^{(0)}$ respect parameter\n$t$ (not $\\hat{t}$), hence it is a point also; the term\n        $\\frac{\\hat{t}-t}{n}\\frac{\\partial \\mathbf{b}_{0, \\hat{t}}(t) }{\\partial t} $\nis a vector, so $\\mathbf{p}_{1, \\hat{t}}(t)$ is a vector applied to a point, yielding a point\nas required. It is quite interesting how the polar form combine a point produced using $t$\nas parameter with the derivative vector produced using  parameter $\\hat{t}$. This derivation\ncomes from \\cite{Farin}, page 73, and we report the output of our implementation in\n\\autoref{fig:exercise-polar-form}.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{bezier-deCasteljau-curves/exercise-polar}\n  \\caption{First Polar form of a Bezier curve}\n  \\label{fig:exercise-polar-form}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\newpage\n\n\\section{B-Splines curves}\n\n\\subsection{Mushrooms from clumped, uniformed and closed partitions}\n\nIn this section we report three simple BSpline curves, using\nthree different knots partitions: \\emph{clumped, uniform} and\n\\emph{cyclic} (see \\autoref{fig:clumpled-mushroom},\n    \\autoref{fig:uniformed-mushroom} and \\autoref{fig:closed-mushroom}\nrespectively). The control polygon doesn't change\n  and aims to produce a mushroom in cartoon style, each knot\nhas multiplicity $1$ (so maximum continuity is required in each junction)\nand no control point is repeated.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-zero-clumped.eps}\n  \\caption{Mushroom from clumped knots partition}\n  \\label{fig:clumpled-mushroom}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-zero-uniformed.eps}\n  \\caption{Mushroom from uniformed knots partition}\n  \\label{fig:uniformed-mushroom}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-zero-closed.eps}\n  \\caption{Mushroom from cyclic knots partition}\n  \\label{fig:closed-mushroom}\n\\end{figure}\n\n\\subsection{Increasing order $k$ while decreasing \\emph{continuity} vector }\nAs Exercise 1 requires, in \\autoref{fig:bspline-exercise-one-clumped} we\nreport five BSpline curves, each one of them drawn against the same control\nnet. We modify for each curve its knots partition, formally for curves\n$\\mathbf{c}_{1},\\mathbf{c}_{2},\\mathbf{c}_{3},\\mathbf{c}_{4}$ and $\\mathbf{c}_{5}$\nthe following extended partitions are used:\n\\begin{displaymath}\n    \\begin{split}\n        \\Delta_{1} &= \\lbrace 0,0, \\frac{1}{5}, \\frac{2}{5},\n            \\frac{3}{5},\\frac{4}{5},1,1 \\rbrace \\\\\n        \\Delta_{2} &= \\lbrace 0,0,0, \\frac{1}{4},\n            \\frac{1}{2},\\frac{3}{4},1,1,1 \\rbrace \\\\\n        \\Delta_{3} &= \\lbrace 0,0,0,0,\n            \\frac{1}{3},\\frac{2}{3},1,1,1,1 \\rbrace \\\\\n        \\Delta_{4} &= \\lbrace 0,0,0,0,0,\\frac{1}{2},\n            1,1,1,1,1 \\rbrace \\\\\n        \\Delta_{5} &= \\lbrace 0,0,0,0,0,0,1,1,1,1,1,1 \\rbrace \\\\\n    \\end{split}\n\\end{displaymath}\nrespectively, and each curve $\\mathbf{c}_{i}$ has \\emph{degree} $i$. As\nwe can see, each knots partition is clumped, so the first and last control points\nare interpolated and the sequence of curves uses partitions with knots $0$ and $1$\nrepeated one more time in successive partitions. For lower degree curves, such as\n$\\mathbf{c}_{1}$, they are quite next to control net, in particular $\\mathbf{c}_{1}$\nis the control net itself, while curve $\\mathbf{c}_{2}$ is tangent to control net\nin two segments since it has \\emph{order} $3$ and for $t \\in [\\frac{1}{4}, \\frac{1}{2}) =\n[t_4, t_5)$ curve $\\mathbf{c}_{2}$ has support $[t_2,t_3,t_4]$ where knot $0$\nhas multiplicity $2$, hence $\\frac{\\partial \\mathbf{c}_{2}(t)}{\\partial t}$\nlies on direction given by $\\mathbf{V}_{3} - \\mathbf{V}_{2}$.\nThe same reasoning can be done for knot $1$.\nFinally, the very last partition allow to draw a \\emph{Bezier} curve (the yellow one).\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-one-clumped.eps}\n  \\caption{Decreasing the \\emph{continuity} vector collapsing in a Bezier }\n  \\label{fig:bspline-exercise-one-clumped}\n\\end{figure}\n\n\\subsection{Knots' multiplicities against the same control polygon}\nIn \\autoref{fig:bspline-exercise-two} we report plots required by Exercise 2.\nThis composite picture contains 5 curves according the following specifications,\nfrom top to bottom:\n\\begin{center}\n    \\begin{tabular}{ c c }\n        order & knots partition \\\\\n        \\hline\n        4 & $\\lbrace 0^{4},1,2,3,4,5,6,7,8,9,10 \\rbrace$  \\\\\n        4 & $\\lbrace 0^{4},1^{2},2^{2},3^{2},4^{4} \\rbrace$  \\\\\n        6 & $\\lbrace 0^{6},1,2,3,4,5^{6} \\rbrace$  \\\\\n        6 & $\\lbrace 0^{6},1,2,3^{2},4^{6} \\rbrace$  \\\\\n        8 & $\\lbrace 0^{8},1,2,3^{8} \\rbrace$  \\\\\n    \\end{tabular}\n\\end{center}\nThe curve relative to the first row interpolate the first control point\nsince $0$ has multiplicity $4$ which is the curve's order, while the last\ncontrol point isn't interpolated since knots partition ends uniformly.\n\nThe curve relative to the second row both interpolate the first control\npoint due to the multiplicity $k$ of $0$ and is tangent to control net\non the direction $\\mathbf{V}_{4} - \\mathbf{V}_{3}$ since for $t \\in [t_{5}, t_{6}]$\nthe support is $[t_{2},t_{3},t_{4},t_{5}]$, where $0$ has multiplicity $3 = order -1$.\n\nCurves relative to third and forth rows both interpolate first and last control\npoints because of clumped partition, while the last one reduce to only two\nknots $1,2$, toward Bezier representation.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-two.eps}\n  \\caption{Knots's multiplicities increased against the same control polygon }\n  \\label{fig:bspline-exercise-two}\n\\end{figure}\n\n\\subsection{Linearity near doubled control point with a clumped partition}\nIn \\autoref{fig:bspline-exercise-three} we plot curve required for Exercise 3:\na quadratic curve ($order = 3$) with a doubled control point $\\mathbf{V}_{3} =\n\\mathbf{V}_{4} = (1,1)$ over an extended partition\n$\\Delta = \\lbrace 0,0,0, \\frac{1}{4},\\frac{1}{2},\\frac{3}{4},\n1,1,1 \\rbrace$, a clumped one with no repeated knots.\n\nLets consider the subcurve $\\mathbf{c}_{5}(t)$ for $t \\in [t_{5}, t_{6}]$:\n\\begin{displaymath}\n    \\mathbf{c}_{5}(t) = \\sum_{i=3}^{5}{\\mathbf{V}_{i}N_{i,3}(t)}\n\\end{displaymath}\nSince $\\mathbf{V}_{4} = \\mathbf{V}_{3}$, for $t \\in [t_{5}, t_{6}]$,\n$\\mathbf{c}_{5}(t)$ must lie on the convex hull $\\mathbf{V}_{3}, \\mathbf{V}_{4},\n\\mathbf{V}_{5}$ and,  for $t \\in [t_{4}, t_{5}]$, $\\mathbf{c}_{5}(t)$ must lie\non the convex hull $\\mathbf{V}_{2}, \\mathbf{V}_{3}, \\mathbf{V}_{4}$, it does follow\nthat $\\mathbf{c}_{5}(t_{5})$ has to lie in their intersection, therefore vertex\n$\\mathbf{V}_{4}$, interpolating it.\n\nMoreover, $\\mathbf{c}_{5}(t)$ has two linear segment between\n$\\mathbf{V}_{2}, \\mathbf{V}_{3}$ and $\\mathbf{V}_{4}, \\mathbf{V}_{5}$,\nboth of them join in $t_{4}, t_{6}$ with continuity $\\mathcal{C}^{1}$.\n\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-three.eps}\n  \\caption{Linearity toward $(1,1)$ due to ``linearized'' convex hull}\n  \\label{fig:bspline-exercise-three}\n\\end{figure}\n\n\\subsection{Two clumped partitions, different \\emph{continuity} vectors\n    and same control polygon}\nIn \\autoref{fig:bspline-exercise-four} we report two curves required by Exercise 4.\nBoth of them have $order = 4$ and a control net with a doubled point\n$\\mathbf{V}_{3} = \\mathbf{V}_{4}$, while the former (colored green)\nis over a knots partition\n$\\Delta_{1} = \\lbrace 0,0,0,0,\\frac{1}{4}, \\frac{3}{4}, 1,1,1,1 \\rbrace$\n(having simple knots, no repeated one), the latter (colored blue) is over\na knots partition\n$\\Delta_{2} = \\lbrace 0,0,0,0,\\frac{1}{2}, \\frac{1}{2}, 1,1,1,1 \\rbrace$ (having\nknot $\\frac{1}{2}$ doubled). Let define the following subcurves of the former:\n\\begin{displaymath}\n    \\begin{split}\n        \\mathbf{c}_{4}(t) &= \\sum_{i=1}^{4}{\\mathbf{V}_{i}N_{i,4}(t)}, \\quad\n            t \\in [t_{4}, t_{5}] \\\\\n        \\mathbf{c}_{5}(t) &= \\sum_{i=2}^{5}{\\mathbf{V}_{i}N_{i,4}(t)}, \\quad\n            t \\in [t_{5}, t_{6}] \\\\\n        \\mathbf{c}_{6}(t) &= \\sum_{i=3}^{6}{\\mathbf{V}_{i}N_{i,4}(t)}, \\quad\n            t \\in [t_{6}, t_{7}] \\\\\n    \\end{split}\n\\end{displaymath}\nAs we saw during classes \\cite{Conti}, $\\mathbf{c}_{5}^{\\prime}(t_{5}) =\n\\mathbf{c}_{4}^{\\prime}(t_{5})$ holds, so the\ncurve interpolate a point on the segment with extrema $\\mathbf{V}_{2}, \\mathbf{V}_{3}$\nand it is tangent to the control net in $t_{5}$. On the other hand,\n$\\mathbf{c}_{6}^{\\prime}(t_{6}) = \\mathbf{c}_{5}^{\\prime}(t_{6})$, so the\ncurve interpolate a point on the segment with extrema $\\mathbf{V}_{4}, \\mathbf{V}_{5}$\nand it is tangent to the control net in $t_{6}$.\nFinally, observe that the curve doesn't\ninterpolate the doubled control point $\\mathbf{V}_{3} = \\mathbf{V}_{4}$.\n\nThe previous argument doesn't apply to the second curve because its\nknots partition is not simple, it contains a double knot.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-four.eps}\n  \\caption{Same control polygon with doubled $(0,6)$ againts two clumped partitions}\n  \\label{fig:bspline-exercise-four}\n\\end{figure}\n\n\\subsection{Increasing clumped partitions for increasing occurrences of a control point}\nIn Exercise 5 it is required to provide three extended knots partitions in\norder to draw cubic curves reported in \\autoref{fig:bspline-exercise-five}.\nEach curve is defined against the ``same'' control net, having the middle vertex\nof the top row repeated one, two, three times respectively. Our choice of knots\npartitions, each clumped since interpolation of first and last control points\nis requested:\n\\begin{displaymath}\n    \\begin{split}\n        \\Delta_{1} &= \\lbrace 0,0,0,0,\\frac{1}{2},1,1,1,1 \\rbrace \\\\\n        \\Delta_{2} &= \\lbrace 0,0,0,0,\\frac{1}{3},\\frac{2}{3},1,1,1,1 \\rbrace \\\\\n        \\Delta_{3} &= \\lbrace 0,0,0,0,\\frac{1}{4},\\frac{1}{2},\\frac{3}{4},1,1,1,1 \\rbrace \\\\\n    \\end{split}\n\\end{displaymath}\n\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-five.eps}\n  \\caption{Three B-Splines, each for $1,2,3$ occurrences of $(0,1)$ respectively }\n  \\label{fig:bspline-exercise-five}\n\\end{figure}\n\n\\subsection{Two B-Splines from two closed partitions}\nIn this last section we report two closed curves having $order = 4$ over\ntwo cyclic knots partitions, in \\autoref{fig:bspline-exercise-six-first}\nand \\autoref{fig:bspline-exercise-six-second}, respectively.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-six-first-closed.eps}\n  \\caption{A first B-Spline from a closed partition }\n  \\label{fig:bspline-exercise-six-first}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{b-splines/exercise-six-second-closed.eps}\n  \\caption{A second B-Spline from a closed partition }\n  \\label{fig:bspline-exercise-six-second}\n\\end{figure}\n\n\\newpage\n\n\\begin{thebibliography}{}\n\n\\bibitem{Julia} Open Source Project,\n  \\emph{Julia language}, \\url{http://julialang.org/}\n\n\\bibitem{Farin} Gerald Farin,\n  \\textit{Curves and surfaces for CAGD, Fifth Edition}\n\n\\bibitem{Conti} Costanza Conti,\n    \\emph{Lecture notes}, distributed during classes\n\n\n\\end{thebibliography}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "551f3b39a9dfc1901f3dd314fa646fe18da47c80", "size": 24651, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cagd.tex", "max_stars_repo_name": "massimo-nocentini/cagd", "max_stars_repo_head_hexsha": "baec0824951ebc17e23e16e71339dd8fd79b11c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cagd.tex", "max_issues_repo_name": "massimo-nocentini/cagd", "max_issues_repo_head_hexsha": "baec0824951ebc17e23e16e71339dd8fd79b11c2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cagd.tex", "max_forks_repo_name": "massimo-nocentini/cagd", "max_forks_repo_head_hexsha": "baec0824951ebc17e23e16e71339dd8fd79b11c2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5171875, "max_line_length": 128, "alphanum_fraction": 0.6806214758, "num_tokens": 8442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4433581590810724}}
{"text": "\\input{../common/common.tex}\n\n\\title{Math notes - Cat vs dog}\n\\author{Uwe Hoffmann}\n\\hypersetup{colorlinks, pdftitle={Math notes - Cat vs dog}}\n\n\\begin{document}\n\n\\setcounter{chapter}{1}\n\\section*{Cat vs dog}\n\n\\newthought{Bipartite graphs}, network flows, matchings and vertex covers are the topics of the problem \\footnote{\\bibentry{spotify_interview}} in this note.\\index{bipartite graph}\\index{network flow}\\index{bipartite matching}\\index{vertex cover}\n\n\\begin{fullwidth}\n\n\\vspace{10 mm}\n\\begin{problem}\nThe latest reality show has hit the TV: “Cat vs. Dog”. In this show, a bunch of cats and dogs compete for the very prestigious Best Pet Ever title. In each episode, the cats and dogs get to show themselves off, after which the viewers vote on which pets should stay and which should be forced to leave the show.\n\\\\\n\nEach viewer gets to cast a vote on two things: one pet which should be kept on the show, and one pet which should be thrown out. Also, based on the universal fact that everyone is either a cat lover (i.e. a dog hater) or a dog lover (i.e. a cat hater), it has been decided that each vote must name exactly one cat and exactly one dog.\n\\\\\n\nIngenious as they are, the producers have decided to use an advancement procedure which guarantees that as many viewers as possible will continue watching the show: the pets that get to stay will be chosen so as to maximize the number of viewers who get both their opinions satisfied. Calculate this maximum number of satisfied viewers.\n\\end{problem}\n\n\\end{fullwidth}\n\nAt first glance this looks similar to a SAT problem \\footnote{Boolean satisfiability problem \\url{http://en.wikipedia.org/wiki/Boolean_satisfiability_problem}}, something like $(c_1 \\land \\lnot d_3),\\  (c_3 \\land \\lnot d_1),\\  (d_2 \\land \\lnot c_2),\\ \\dots$ where $c_i$ are the cats and $d_j$ are the dogs. The goal would be to pick the biggest subset of boolean expressions (votes) that are satisfied.\n\n\\begin{marginfigure}[0.01in]\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            node distance = 3cm, % distance between nodes\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node[state] (v1) at (0,0) {$c_1 \\land \\lnot d_3$};\n        \\node[state] (v2) at (0,2) {$c_2 \\land \\lnot d_2$};\n        \\node[state] (v3) at (0,4) {$c_4 \\land \\lnot d_1$};\n        \\node[state] (v4) at (0,6) {$c_3 \\land \\lnot d_1$};\n        \\node[state] (v5) at (4,1) {$\\lnot c_2 \\land d_1$};\n        \\node[state] (v6) at (4,3) {$\\lnot c_4 \\land d_3$};\n        \\node[state] (v7) at (4,5) {$\\lnot c_1 \\land d_2$};\n\n        \\node [draw=blue,fit=(v1) (v4),label=above:Cat lovers] {};\n        \\node [draw=green,fit=(v5) (v7),label=above:Dog lovers] {};\n\n        \\path (v1) edge (v6);\n        \\path (v1) edge (v7);\n        \\path (v2) edge (v5);\n        \\path (v2) edge (v7);\n        \\path (v3) edge (v5);\n        \\path (v3) edge (v6);\n        \\path (v4) edge (v5);\n\n    \\end{tikzpicture}\n    \\caption{Votes form a bipartite graph. A graph is \\textbf{bipartite} if the vertex set is partitioned into two subsets (blue and green in this case) such that no vertices in a subset are adjacent.}\n\t\\label{votes_conflict}\n\\end{marginfigure}\n\nBut SAT is about one boolean expression and about assigning values to boolean variables to satisfy it. Seems like SAT is fundamentally different and not a good approach in solving this problem. What if we want to visualize the boolean expressions and see the relationships between them, i.e. which ones are in conflict. Conflict between two boolean expressions means one expression has $c_i$ and the other expression has $\\lnot c_i$ or one has $d_j$ and the other $\\lnot d_j$. A good way to do that is with a graph as in Figure \\ref{votes_conflict}. The nodes in the graph are the boolean expressions and edges connect  boolean expressions that are in conflict.\n\nIt becomes apparent that the graph is bipartite with cat lovers on one side and dog lovers on the other. That is good because a lot of graph algorithms are much simpler and work faster if the graphs are bipartite. But what algorithm should we use? We need to find the biggest subset of nodes in the graph that are not in conflict. \n\nSometimes it's easier to compute the complement of what we want: the smallest subset of nodes that are involved in conflicts. Removing these nodes and the edges they touch should leave us with a graph with only nodes and no edges, i.e. only votes without conflicts. Because we strive to remove the smallest subset of conflicting nodes we are left with the biggest subset of votes without conflicts.\n\nThe subset of nodes that are involved in conflicts is a vertex cover \\footnote{A \\textbf{vertex cover} is a subset of nodes such that each edge in a graph is incident to at least one vertex in the subset.} for our bipartite graph.\n\nWe need to compute a minimum vertex cover. This will be a good excuse to learn about network flows in graphs, maximum flows and minimum cuts. This delightful detour will eventually bring us to maximum matchings\\footnote{A \\textbf{matching} is a subset of edges such that no two edges in the subset share a vertex.} and then finally to minimum vertex covers.\\newline\n\n\nWe begin with \\textbf{network flows} in graphs. We work with a directed graph $G=(V, E)$ that has two special vertices $s$ and $t$ called \\textbf{source} and \\textbf{target}.  No edge goes into \\emph{source} and no edge comes out of \\emph{target}. We also have a function $c:E \\to \\mathbb{R}_{\\geq 0}$ that assigns a non-negative capacity to each edge. The graph $G$ together with source $s$ and target $t$ and capacity function $c$ form a \\textbf{network} $(G=(V, E), s \\in V, t \\in V, c)$.\n\n\\begin{marginfigure}\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            node distance = 3cm, % distance between nodes\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node[state] (u) at (1,0) {$u$};\n        \\node[state] (v) at (3,0) {$v$};\n\n        \\path[->] (u) edge node {$10/20$} (v);\n\n    \\end{tikzpicture}\n    \\caption{In figures we annotate an edge with flow and capacity as shown here. In this case $f(u \\rightarrow v) = 10$ and $c(u \\rightarrow v) = 20$. If only one number is annotating the edge then it's the capacity.}\n\t\\label{edge_flow_cap}\n\\end{marginfigure}\n\n\\begin{defn}\\label{stflow}\nA function $f:E \\to \\mathbb{R}_{\\geq 0}$ is a \\textbf{flow} through network $(G, s, t, c)$ if $f$ satisfies the following constraints: \n\n\\begin{itemize}\n  \\item \\emph{capacity constraint}: flow along an edge cannot exceed the capacity of the edge\n  $$\n  \\forall e \\in E: f(e) \\leq c(e)\n  $$\n  \\item \\emph{conservation constraint}: incoming flow into a vertex (except for source and target) equals outgoing flow from the vertex\n  $$\n  \\forall v \\in V \\setminus \\{s,t\\}: \\sum_u f(u \\rightarrow v) = \\sum_w f(v \\rightarrow w)\n  $$\n\\end{itemize}\n\\end{defn}\n\n\\begin{marginfigure}\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node[state] (s) at (0,1) {$s$};\n        \\node[state] (v) at (2,2) {$v$};\n        \\node[state] (u) at (2,0) {$u$};\n        \\node[state] (t) at (4,1) {$t$};\n\n        \\path[->, line width=1.5pt] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$0/10$} (v);\n        \\path[->, line width=1.5pt] (u) edge node {$20/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$0/10$} (t);\n\t\t\\path[->, line width=1.5pt] (v) edge node {$20/20$} (t);        \n\n\n    \\end{tikzpicture}\n    \\caption{Example network flow. Here $|f| = 20$ and the whole flow is pumped along the path $s \\rightarrow u \\rightarrow v \\rightarrow t$. In this exampe $f$ \\textbf{saturates} $s \\rightarrow u$ and $v \\rightarrow t$ and \\textbf{avoids} $s \\rightarrow v$ and $u \\rightarrow t$.}\n\t\\label{ex_flow}\n\\end{marginfigure}\n\n\\marginnote[0.5in]{For notational simplicity we assume functions $f$ and $c$ are defined on $V \\times V$ and $f(u \\rightarrow v) = c(u \\rightarrow v) = 0$ if $u \\rightarrow v$ is not an edge in $G=(V, E)$.}\n\nSource $s$ generates flow and target $t$ consumes flow. The \\textbf{value} of flow $f$, denoted $|f|$, is defined as\n\n$$\n|f| = \\sum_w f(s \\rightarrow w) = \\sum_v f(v \\rightarrow t)\n$$\n\n\\begin{marginfigure}[0.3in]\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node[state] (s) at (0,1) {$s$};\n        \\node[state] (v) at (2,2) {$v$};\n        \\node[state] (u) at (2,0) {$u$};\n        \\node[state] (t) at (4,1) {$t$};\n\n        \\path[->] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$10/10$} (v);\n        \\path[->] (u) edge node {$10/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$10/10$} (t);\n\t\t\\path[->] (v) edge node {$20/20$} (t);        \n\n\n    \\end{tikzpicture}\n    \\caption{Same example network with a flow of value $|f| = 30$.}\n\t\\label{ex_flow_max}\n\\end{marginfigure}\n\nGiven a network $(G, s, t, c)$ what is the maximum flow value that can be pumped through it? Figure \\ref{ex_flow} shows a flow of value $20$ through an example network. It saturates the flow along one particular path and avoids the other edges. Is $20$ the maximum flow value that can be achieved for this example network? Figure \\ref{ex_flow_max} shows the same network but now with a flow of value $30$. Can we do better than $30$? The answer is no, because that would exceed the outgoing capacity of source $s$ or the incoming capacity of $t$. \n\nOur goal is to device an algorithm that constructs a flow with maximum value through a given network. To gauge the progress of our algorithm we need an upper bound for the maximum flow value. As said before the maximum value clearly cannot exceed the outgoing capacity of source $s$ or the incoming capacity of $t$. But more generally if we sever the ties between source and target along some subset of edges such that there are no more paths from source to target then the maximum flow value cannot exceed the capacity of the cut. This seems like a useful concept to formalize.\n\n\\begin{marginfigure}\n\\includegraphics[scale=0.15]{soviettrainnetwork.jpeg}\n\\end{marginfigure}\n\\marginnote{\\bibentry{Schrijver02onthe}:\\\\\n Network flows and minimum cuts played a role in the Cold War. The figure is a schematic diagram of the railway network of the Western Soviet Union and Eastern European countries, with a maximum flow of value 163,000 tons from Russia to Eastern Europe, and a cut of capacity 163,000 tons indicated as “The bottleneck”.}\n\n\\begin{defn}\\label{networkcut}\nIn a network $(G, s, t, c)$ a \\textbf{cut} is a partition of the vertex set $V$ into two subsets $S$ and $T$, such that $V = S \\cup T$, $S \\cap T = \\emptyset$ and $s \\in S, t \\in T$. The \\textbf{capacity} of the cut $(S, T)$, denoted $\\|S,T\\|$, is defined as\n\n$$\n\\|S, T\\| = \\sum_{v \\in S} \\sum_{w \\in T} c(v \\rightarrow w)\n$$\n\\end{defn}\n\n\\begin{thm}\\label{flowcut}\nWith network $(G, s, t, c)$, for any flow $f$ and any cut $(S, T)$ we have\n$$\n  |f| \\leq \\|S, T\\|\n$$\nFurthermore equality holds if and only if $f$ saturates every edge from $S$ to $T$ and avoids every edge from $T$ to $S$.\n\\end{thm}\n\n\\begin{marginfigure}[1in]\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node[state] (s) at (0,1) {$s$};\n        \\node[state] (v) at (2,2) {$v$};\n        \\node[state] (u) at (2,0) {$u$};\n        \\node[state] (t) at (4,1) {$t$};\n\n        \\path[->, line width=1.5pt] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$0/10$} (v);\n        \\path[->, line width=1.5pt] (u) edge node {$20/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$0/10$} (t);\n\t\t\\path[->, line width=1.5pt] (v) edge node {$20/20$} (t);\n\n\t\t\\path[->, dashed] (s) edge[bend left=60] node {$10$} (v);        \n\t\t\\path[->, dashed] (v) edge[bend left=30] node {$20$} (u);\n\t\t\\path[->, dashed] (u) edge[bend right=70] node[right] {$10$} (t);  \n\n    \\end{tikzpicture}\n    \\caption{Dashed edges show how the greedy $s-t$ path flow can be augmented and reversed in order to increase overall flow.}\n\t\\label{ex_flow_dashed}\n\\end{marginfigure}\n\n\\begin{proof}\n\n\\begin{align*}\n|f| &= \\sum_w f(s \\rightarrow w) \\tag*{\\tiny{(by definition)}}\\\\\n    &= \\sum_w f(s \\rightarrow w) - \\sum_v f(v \\rightarrow s) \\tag*{\\tiny{(second sum terms are all zero)}}\\\\\n    &= \\sum_{u \\in S} (\\sum_w f(u \\rightarrow w) - \\sum_v f(v \\rightarrow u)) \\tag*{\\tiny{(flow conservation constraint)}}\\\\\n    &= \\sum_{u \\in S} (\\sum_{w \\in T} f(u \\rightarrow w) - \\sum_{v \\in T} f(v \\rightarrow u)) \\tag*{\\tiny{(edges in $S$ cancel each other out)}}\\\\\n    &\\leq \\sum_{u \\in S} \\sum_{w \\in T} f(u \\rightarrow w) \\tag*{\\tiny{(because $f(v \\rightarrow u) \\geq 0$)}}\\\\\n    &\\leq \\sum_{u \\in S} \\sum_{w \\in T} c(u \\rightarrow w) \\tag*{\\tiny{(flow capacity constraint)}}\\\\\n    &= \\|S, T\\| \\tag*{\\tiny{(by definition)}}\n\\end{align*}\n\n\\end{proof}\n\nTheorem \\ref{flowcut} tells us that if we keep increasing a flow and/or decreasing a cut we should eventually meet at a maximum flow that equals a minimum cut. But given a network how do we start? A first valid flow is $\\forall e \\in E: f(e) = 0$. We could then try a greedy strategy. Starting with source $s$ find the path to $t$ with the biggest capacity\\footnote{The capacity of a path is the minimum over the capacities of the edges forming the path.} and pump as much flow as we can through it as illustrated in Figure \\ref{ex_flow}. Unfortunately we are stuck at that point. We cannot pump more flow out of $s$ on $s \\rightarrow v$ because that would violate flow conservation at $v$ (we are at the maximum outgoing flow at $v$). The dashed edges in Figure \\ref{ex_flow_dashed} show some of our options. On edges where the current flow leaves residual capacity we can pump more and on edges where there is existing flow we can reverse it. Again, this concept seems worth formalizing.\n\n\\begin{marginfigure}\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node at (0,2.7) {(a)};\n        \\node at (0,0) {(b)};\n\n        \\node[state] (sf) at (0,1) {$s$};\n        \\node[state] (vf) at (2,2) {$v$};\n        \\node[state] (uf) at (2,0) {$u$};\n        \\node[state] (tf) at (4,1) {$t$};\n\n        \\node[state] (s) at (0,4) {$s$};\n        \\node[state] (v) at (2,5) {$v$};\n        \\node[state] (u) at (2,3) {$u$};\n        \\node[state] (t) at (4,4) {$t$};\n\n        \\path[->] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$0/10$} (v);\n        \\path[->] (u) edge node {$20/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$0/10$} (t);\n\t\t\\path[->] (v) edge node {$20/20$} (t);\n\n        \\path[<-, blue] (sf) edge node[below left=.05cm] {$20$} (uf);\n        \\path[->, blue] (sf) edge node {$10$} (vf);\n        \\path[->, blue] (uf) edge[bend left=30] node {$80$} (vf);\n        \\path[<-, blue] (uf) edge[bend right=30] node {$20$} (vf);\n\t\t\\path[->, blue] (uf) edge node[below right=.05cm] {$10$} (tf);\n\t\t\\path[<-, blue] (vf) edge node {$20$} (tf);\n\n    \\end{tikzpicture}\n    \\caption{\\\\\n             (a) Example network with flow from Figure \\ref{ex_flow}. \\\\\n             (b) Residual network (in blue) with edges annotated with their residual capacity.}\n\t\\label{ex_residual}\n\\end{marginfigure}\n\n\\begin{defn}\\label{residualgraph}\nA flow $f$ in a network $(G, s, t, c)$ induces a \\textbf{residual network} $(G_f, s, t, c_f)$ with \\textbf{residual graph} $G_f$ and \\textbf{residual capacity} $c_f$ in the following way:\n\n\\begin{itemize}\n\t\\item all vertices from $G$ are vertices in $G_f$, also source $s$ and target $t$ are the same in $G$ and $G_f$\n\t\\item if $f(u \\rightarrow v) > 0$ then $G_f$ has an edge $(v \\rightarrow u)$ with capacity \n$$\nc_f(v \\rightarrow u) = f(u \\rightarrow v)\n$$\n    \\item if $f(u \\rightarrow v) < c(u \\rightarrow v)$ then $G_f$ has an edge $(u \\rightarrow v)$ with capacity\n$$\nc_f(u \\rightarrow v) = c(u \\rightarrow v) - f(u \\rightarrow v)\n$$\n\\end{itemize}\n\n\\end{defn}\n\nFigure \\ref{ex_residual} shows the residual network of our example network and flow. We observe that there is a simple path\\footnote{A simple path is a path where every vertex on the path is visited only once.} $s \\rightarrow v \\rightarrow u \\rightarrow t$ with capacity $10$ from source $s$ to target $t$ in the residual graph. This path shows that there still is unused capacity for flow to be pushed from $s$ to $t$. A simple path from $s$ to $t$ in $G_f$ is called an \\textbf{augmenting path}.\n\n\\begin{marginfigure}[1in]\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node at (0,2.7) {(a)};\n        \\node at (0,0) {(b)};\n\n        \\node[state] (sf) at (0,1) {$s$};\n        \\node[state] (vf) at (2,2) {$v$};\n        \\node[state] (uf) at (2,0) {$u$};\n        \\node[state] (tf) at (4,1) {$t$};\n\n        \\node[state] (s) at (0,4) {$s$};\n        \\node[state] (v) at (2,5) {$v$};\n        \\node[state] (u) at (2,3) {$u$};\n        \\node[state] (t) at (4,4) {$t$};\n\n        \\path[->] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$0/10$} (v);\n        \\path[->] (u) edge node {$20/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$0/10$} (t);\n\t\t\\path[->] (v) edge node {$20/20$} (t);\n\n\t\t\\path[->] (sf) edge node[below left=.05cm] {$20/20$} (uf);\n        \\path[->] (sf) edge node {$\\color{red}10\\color{black}/10$} (vf);\n        \\path[->] (uf) edge node {$\\color{red}10\\color{black}/100$} (vf);\n\t\t\\path[->] (uf) edge node[below right=.05cm] {$\\color{red}10\\color{black}/10$} (tf);\n\t\t\\path[->] (vf) edge node {$20/20$} (tf);\n\n    \\end{tikzpicture}\n    \\caption{\\\\\n             (a) Example network with flow from Figure \\ref{ex_flow}. \\\\\n             (b) Augmented flow (changed values in red) from augmenting path $s \\rightarrow v \\rightarrow u \\rightarrow t$.}\n\t\\label{augmented_flow}\n\\end{marginfigure}\n\n\\begin{thm}\\label{augmenting}\nGiven is a flow $f$ in network $(G, s, t, c)$. If there is an augmenting path in $G_f$ with capacity $F$ then the function $f':V \\times V \\to \\mathbb{R}_{\\geq 0}$ defined as:\n\n$$\nf'(u \\rightarrow v) = \n\\begin{cases}\nf(u \\rightarrow v) + F, & \\text{if } u\\rightarrow v \\text{ is on the augmenting path} \\\\\nf(u \\rightarrow v) - F, & \\text{if } v\\rightarrow u \\text{ is on the augmenting path} \\\\\nf(u \\rightarrow v), & \\text{otherwise}\n\\end{cases}\n$$\n\nis a valid flow in network $(G, s, t, c)$ with $|f'| = |f| + F$.\n\\end{thm}\n\n\\begin{proof}\nWe need to check the capacity constraint and the conservation constraint. \n\nLet's start with the capacity constraint. The definition of $f'$ has three cases, so we check all three:\n\n\\begin{itemize}\n\n\t\\item Edge $u \\rightarrow v$ is on the augmenting path:\n\n\\begin{align*}\nf'(u \\rightarrow v) &= f(u \\rightarrow v) + F \\tag*{\\tiny{(by definition)}}\\\\\n    &\\leq f(u \\rightarrow v) + c_f(u \\rightarrow v) \\tag*{\\tiny{(by definition of $F$)}}\\\\\n    &=  f(u \\rightarrow v) + c(u \\rightarrow v) - f(u \\rightarrow v) \\tag*{\\tiny{(by definition of $c_f$)}}\\\\\n    &=  c(u \\rightarrow v)\n\\end{align*}\n\n\t\\item Edge $v \\rightarrow u$ is on the augmenting path:\n\n\\begin{align*}\nf'(u \\rightarrow v) &= f(u \\rightarrow v) - F \\tag*{\\tiny{(by definition)}}\\\\\n    &\\geq f(u \\rightarrow v) - c_f(u \\rightarrow v) \\tag*{\\tiny{(by definition of $F$)}}\\\\\n    &=  f(u \\rightarrow v) - f(u \\rightarrow v) \\tag*{\\tiny{(by definition of $c_f$)}}\\\\\n    &=  0\n\\end{align*}\n\n\t\\item Otherwise: In this case the flow of the edge hasn't changed so capacity constraint is satisfied.\n\n\\end{itemize}\n\nNext is the conservation constraint. For vertices not on the augmenting path flow in and out of them hasn't changed, so conservation constraint is satisfied there. For a vertex $v$ on the augmenting path we have four cases (since the augmenting path is simple and $v \\neq s, v \\neq t$):\n\n\\begin{itemize} \n\n\t\\item $u \\rightarrow v$ on augmenting path and $v \\rightarrow w$ on augmenting path: in this case one incoming edge into $v$ changed by $F$ and one outgoing changed by $F$, so conservation constraint holds for $v$\n\n\t\\item $u \\rightarrow v$ on augmenting path and $w \\rightarrow v$ on augmenting path: in this case two incoming edges into $v$ changed, one by $F$ and the other by $-F$, so conservation constraint holds for $v$\n\n\t\\item $v \\rightarrow u$ on augmenting path and $w \\rightarrow v$ on augmenting path: in this case one incoming edge into $v$ changed by $-F$ and one outgoing changed by $-F$, so conservation constraint holds for $v$\n\n\t\\item $v \\rightarrow u$ on augmenting path and $v \\rightarrow w$ on augmenting path: in this case two outgoing edges from $v$ changed, one by $-F$ and the other by $F$, so conservation constraint holds for $v$\n\n\\end{itemize}\t\n\n\\end{proof}\n\n\\begin{marginfigure}\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node at (0,2.7) {(a)};\n        \\node at (0,0) {(b)};\n\n        \\node[state] (sf) at (0,1) {$s$};\n        \\node[state] (vf) at (2,2) {$v$};\n        \\node[state] (uf) at (2,0) {$u$};\n        \\node[state] (tf) at (4,1) {$t$};\n\n        \\node[state] (s) at (0,4) {$s$};\n        \\node[state] (v) at (2,5) {$v$};\n        \\node[state] (u) at (2,3) {$u$};\n        \\node[state] (t) at (4,4) {$t$};\n\n        \\path[->] (s) edge node[below left=.05cm] {$20/20$} (u);\n        \\path[->] (s) edge node {$10/10$} (v);\n        \\path[->] (u) edge node {$10/100$} (v);\n\t\t\\path[->] (u) edge node[below right=.05cm] {$10/10$} (t);\n\t\t\\path[->] (v) edge node {$20/20$} (t);\n\n        \\path[<-, blue] (sf) edge node[below left=.05cm] {$20$} (uf);\n        \\path[<-, blue] (sf) edge node {$10$} (vf);\n        \\path[->, blue] (uf) edge[bend left=30] node {$90$} (vf);\n        \\path[<-, blue] (uf) edge[bend right=30] node {$10$} (vf);\n\t\t\\path[<-, blue] (uf) edge node[below right=.05cm] {$10$} (tf);\n\t\t\\path[<-, blue] (vf) edge node {$20$} (tf);\n\n    \\end{tikzpicture}\n    \\caption{\\\\\n             (a) Example network with flow from Figure \\ref{ex_flow_max}. \\\\\n             (b) Residual network (in blue) with edges annotated with their residual capacity.}\n\t\\label{ex_residual_max}\n\\end{marginfigure}\n\nWhat happens when there is no augmenting path in $G_f$? As the Figure \\ref{ex_residual_max} hints we then have a maximum flow (in our example $|f| = 30$). The next theorem proves it.\n\n\\begin{thm}\\label{no_augmenting}\nGiven is a flow $f$ in network $(G, s, t, c)$. If there is no augmenting path in $G_f$ then $f$ is a flow with maximum value.\n\\end{thm}\n\n\\begin{proof}\nWe define two subsets of $V$. The set $S$ holds all the vertices of $V$ that are reachable from $s$ in $G_f$. Since there is no augmenting path in $G_f$ we have $t \\notin S$. We also define $T = V \\setminus S$. Clearly $(S, T)$ is a cut of our network. Also there is no $G_f$ edge $u \\rightarrow v$ with $u \\in S$ and $v \\in T$ because otherwise $v$ would be reachable from somewhere in $S$ but $v \\notin S$, contradicting the definition of $S$. This means (by definition of $G_f$) that $f$ saturates every edge from $S$ to $T$ and avoids every edge from $T$ to $S$. According to Theorem \\ref{flowcut} we then have $|f| = \\|S, T\\|$ which means we have a maximum flow and minimum cut.\n\n\\end{proof}\n\n\\begin{marginfigure}[0.0in]\n\\includegraphics[scale=0.8]{fulkerson.png}\n\\end{marginfigure}\n\\marginnote{Delbert Ray Fulkerson was an American mathematician who co-developed the Ford–Fulkerson algorithm. \\url{https://en.wikipedia.org/wiki/D._R._Fulkerson}}\n\nWe can now piece together the following algorithm known as the \\textbf{Ford-Fulkerson algorithm}:\n\n\\begin{lstlisting}[basicstyle=\\small, label={lst:fordfulkerson}, frame=trBL, caption={Ford-Fulkerson algorithm}]\nf = zero flow;\nGf = residual graph of f in G;\n\nwhile (exists augmenting path in Gf):\n   pa = choose any augmenting path; \n   f = augment f with pa;\n   Gf = residual graph of f in G;\n\nreturn f  \n\\end{lstlisting}\n\n\\begin{thm}\\label{fordfulkerson}\nIf the network has capacities in $\\mathbb{N}_{\\geq 0}$ then the Ford-Fulkerson algorithm terminates and returns the maximum flow in the network.\n\\end{thm}\n\n\\begin{proof}\nWe prove by induction that $f: V \\times V \\to \\mathbb{N}_{\\geq 0}$: The base case is the zero flow which is in $\\mathbb{N}_{\\geq 0}$. Assume the current flow values are in $\\mathbb{N}_{\\geq 0}$. The augmenting operation adds or subtracts a positive integer value from the current flow values and conforms to capacity constraints, so it keeps the augmented flow values in $\\mathbb{N}_{\\geq 0}$ which completes the induction.\n\nThe augmented flow $f'$ modifies one outgoing edge from $s$ by $F > 0$, so by the definition of the value of a flow we have $|f'| = |f| + F$. This means that augmenting strictly increases the value of the flow. We also know that flow values have an upper bound (by Theorem \\ref{flowcut} any cut capacity is an upper bound). This means the algorithm has to eventually reach the maximum flow and terminate.\n\\end{proof}\n\nThis concludes our detour into network flows\\footnote{We have just scratched the surface of the topic on network flows and algorithms computing maximum flows (an area of active research). For example by making smart choices when choosing the augmenting path we can improve the runtime of the algorithm (also we haven't analyzed the runtime). What happens when the capacities are not in $\\mathbb{N}_{\\geq 0}$. For details on all this and more see:\n\\\\\n\\bibentry{kleinberg2005ad} \n\\\\ \n\\bibentry{erickson2015a}.}.\n\\\\\nWe should bring it back to our problem and the associated bipartite graph of conflicting votes. We want a minimal vertex cover and we would like to use the just derived Ford-Fulkerson algorithm to compute it. So we first have to transform our undirected bipartite graph into a network. \n\nWe have an undirected bipartite graph $G(V = X \\cup Y, E)$ with $X \\cap Y = \\emptyset$ and $E \\subseteq X \\times Y$ ($X$ could be the votes of cat lovers and $Y$ the votes of dog lovers in our problem or vice versa). We add a source $s$ and a target $t$ and construct a network $(G', s, t, c)$ in the following way:\n\n\\begin{itemize}\n\t\\item vertex set of $G'$ is $X \\cup Y \\cup \\{s, t\\}$\n\t\\item $\\forall u \\in X$ add a directed edge $s \\rightarrow u$ into edge set of $G'$\n\t\\item $\\forall v \\in Y$ add a directed edge $v \\rightarrow t$ into edge set of $G'$\n\t\\item $\\forall \\{u, v\\}$ undirected edge in $G$ with $u \\in X$ and $v \\in Y$ add a directed edge $u \\rightarrow v$  into edge set of $G'$\n\t\\item unit capacity\\footnote{Unit capacity has the advantage that a flow either saturates the edge or avoids it.}: $\\forall (u \\rightarrow v) \\in \\text{ edge set of } G': c(u \\rightarrow v) = 1$\n\\end{itemize}\n\nWith a network $(G', s, t, c)$ constructed from a bipartite graph $G$ as described above (an example is shown in Figure \\ref{bipartite_network}) we have an equivalence between a matching in the bipartite graph and a flow in the network. The next theorem states this.\n\n\\begin{marginfigure}[1.0in]\n\\begin{tikzpicture}[\n            shorten > = 1pt, % don't touch arrow head to node\n            auto,\n            semithick % line style\n        ]\n\n        \\tikzstyle{every state}=[\n            draw = black,\n            thick,\n            fill = white,\n            minimum size = 4mm\n        ]\n\n        \\node at (0,4.5) {(a)};\n        \\node at (0,0) {(b)};\n\n        \\node[state] (s) at (0,3) {$s$};\n        \\node[state] (t) at (5,3) {$t$};\n\n        \\node[state] (x1) at (1.5,0.5) {$x_1$};\n        \\node[state] (x2) at (1.5,2) {$x_2$};\n        \\node[state] (x3) at (1.5,3) {$x_3$};\n        \\node[state] (x4) at (1.5,4) {$x_4$};\n\n        \\node[state] (y1) at (3,0.5) {$y_1$};\n        \\node[state] (y2) at (3,2) {$y_2$};\n        \\node[state] (y3) at (3,3) {$y_3$};\n\n        \\path[->] (x1) edge node {$1$} (y1);\n        \\path[->] (x2) edge node {$1$} (y1);\n        \\path[->] (x2) edge node {$1$} (y2);\n        \\path[->] (x2) edge node {$1$} (y3);\n        \\path[->] (x3) edge node {$1$} (y3);\n        \\path[->] (x4) edge node {$1$} (y3);\n\n        \\path[->] (s) edge node {$1$} (x1);\n        \\path[->] (s) edge node {$1$} (x2);\n        \\path[->] (s) edge node {$1$} (x3);\n        \\path[->] (s) edge node {$1$} (x4);\n\n        \\path[->] (y1) edge node {$1$} (t);\n        \\path[->] (y2) edge node {$1$} (t);\n        \\path[->] (y3) edge node {$1$} (t);\n\n        \\node[state] (bx1) at (1.5,5.5) {$x_1$};\n        \\node[state] (bx2) at (1.5,7) {$x_2$};\n        \\node[state] (bx3) at (1.5,8) {$x_3$};\n        \\node[state] (bx4) at (1.5,9) {$x_4$};\n\n        \\node[state] (by1) at (3,5.5) {$y_1$};\n        \\node[state] (by2) at (3,7) {$y_2$};\n        \\node[state] (by3) at (3,8) {$y_3$};\n\n        \\path[-] (bx1) edge node {} (by1);\n        \\path[-] (bx2) edge node {} (by1);\n        \\path[-] (bx2) edge node {} (by2);\n        \\path[-] (bx2) edge node {} (by3);\n        \\path[-] (bx3) edge node {} (by3);\n        \\path[-] (bx4) edge node {} (by3);\n\n    \\end{tikzpicture}\n    \\caption{\\\\\n             (a) Bipartite graph \\\\\n             (b) Network constructed from it.}\n\t\\label{bipartite_network}\n\\end{marginfigure}\n\n\\begin{thm}\\label{matchingflow}\nA matching $M$ in $G$ induces a flow $f$ in $G'$ such that $|f| = |M|$. Conversely a flow in $G'$ induces a matching $M$ in $G$ such that $|M| = |f|$.\n\\end{thm}\n\n\\begin{proof}\n\\noindent$(\\Rightarrow)$ We have a matching $M$ in $G$, i.e. a subset of edges that don't share a vertex. From the construction of $G'$ it follows that each of the edges in $M$ can be extended to paths from $s$ to $t$ which will only meet in $s$ and $t$. We define a function $f$ that gives unit values to the edges along these paths and zero value to all other edges. We claim that $f$ is a valid flow. It only assigns zero or unit values so it does satisfy the capacity constraint in $G'$. The paths don't intersect except in $s$ and $t$ (because $M$ is a matching), so for any vertex along the path there is exactly one incoming edge with unit value and one outgoing edge with unit value. The rest of the edges have value zero so don't play a role in conservation. This then means that the conservation constraint is satisfied also and $f$ is a flow.\nEach edge in $M$ corresponds to one of the paths, so there are $|M|$ edges outgoing from $s$ that have unit value. Hence $|f| = |M|$.\n\n\\noindent$(\\Leftarrow)$ We have a flow $f$ in $G'$. The flow either saturates or avoids an edge. We define the subset $M$ of edges that are saturated by $f$ and are between $X$ and $Y$. We claim that $M$ is a matching in $G$. Suppose it is not a matching. Then there exists a vertex that is shared by two edges in $M$. If this vertex is in $X$ then it means it has two outgoing edges of unit value but only one incoming edge of unit value (from $s$). If this vertex is in $Y$ then it means it has two incoming edges of unit value and only one outgoing edge of unit value (to $t$). In either case this is a contradiction to the conservation constraint of $f$. So $M$ has to be a matching. The size of $M$ is by its definition equal to the number of saturated edges from $X$ to $Y$. But this number has to be equal to the number of edges of unit value going out of $s$ (conservation constraint). Hence $|M| = |f|$.\n\\end{proof}\n\nTheorem \\ref{matchingflow} let's us use the Ford-Fulkerson algorithm to compute a maximum matching in our bipartite graph $G$. Once we have a maximum matching we get the size of a minimum vertex cover with the following theorem, known as \\textbf{K\\\"onig's theorem}\\footnote{For a short and elegant proof see:\\\\\\bibentry{rizzi00}}:\n\n\\begin{thm}\\label{koenig}\nIn a bipartite graph $G$ the size of a minimum vertex cover $C$ equals the size of a maximum matching $M$. \n\\end{thm}\n\n\\begin{marginfigure}[0.3in]\n\\includegraphics[scale=0.5]{koenig.pdf}\n\\caption{\\\\\n             (a) A bipartite graph $G(X \\cup Y, E)$. $X$ are green vertices, $Y$ are red vertices.\\\\\n             (b) Maximum flow $f$ (thicker arrows) and minimum cut $(S, T)$ in the corresponding network $G'$. Thicker arrows between green and red vertices form the maximum matching.\\\\\n             (c) Same cut displayed with the corresponding residual graph $G'_f$.}\n\t\\label{koenig_example}\n\\end{marginfigure}\n\n\\begin{proof}\n\n$C$ is a vertex cover, so it covers all edges, which means it certainly covers a subset $M$ of all edges. But $M$ is a matching, so no two edges share a vertex. It follows that $|C| \\geq |M|$.\n\nFrom the maximum matching $M$ we get the associated maximum flow $f$ as described in Theorem \\ref{matchingflow}. The residual graph $G'_f$ of the associated network cannot have any augmenting paths. \n\nWe consider the minimum cut $(S, T)$ associated with the maximum flow $f$. We define the following sets:\n\n\\begin{itemize}\n\t\\item $X_S = X \\cap S, X_T = X \\cap T$\n\t\\item $Y_S = Y \\cap S, Y_T = Y \\cap T$\n\t\\item $H = \\{(u, v) \\text{ edge in } G: u \\in S, v \\in T\\}$\n\t\\item $B = \\{v \\in Y_T: \\exists u \\in X_S \\text{ with } (u, v) \\text{ edge in } G\\}$\n\t\\item $D = X_T \\cup Y_S \\cup B$\n\\end{itemize}\t\n\n\\noindent $D$ is a vertex cover: $X_T \\subseteq D$ and $Y_S \\subseteq D$, so $D$ covers all edges that have endpoints in $X_T$ or $Y_S$. The set $B$ provides cover for $H$. \n\nA vertex $u \\in X_T$ is not reachable from $s$ in $G'_f$. It means that $f$ saturates $s \\rightarrow u$ in $G'$, so the saturated edge $s \\rightarrow u$ crosses the $(S, T)$ cut and counts towards $\\|S, T\\|$.\n\nA vertex $v \\in Y_S$ is reachable from $s$ in $G'_f$. It means that $f$ saturates $v \\rightarrow t$ in $G'$ (otherwise some vertex from $T$ would be reachable from $v$ and also from $s$ in $G'_f$ which is a contradiction). The saturated edge $v \\rightarrow t$ crosses the $(S, T)$ cut and counts towards $\\|S, T\\|$.\n\n$f$ is a maximum flow so any edge from $X_S$ to $Y_T$ is saturated and counts towards $\\|S, T\\|$.\n\n$$\n\\|S, T\\| = |X_T| + |Y_S| + |H|\n$$\n\n\\noindent Figure \\ref{koenig_example} shows this. In (b) there are three saturated (thick) arrows crossing the cut. The first two (counting from left to right) are due to $X_T$ and the last one due to $Y_S$. In this example $H$ is the empty set.\n\nWe have\n$$\n|M| = |f| = \\|S, T\\| = |X_T| + |Y_S| + |H| \\geq |X_T| + |Y_S| + |B| \\geq |D|\n$$\n\\noindent $D$ is a vertex cover and $C$ is a minimum vertex cover, so $|D| \\geq |C|$. It follows that $|C| \\geq |M| \\geq |D| \\geq |C|$ which means $|C| = |M|$.\n\\end{proof}\n\nThis solves the problem in this note. The number of satisfied viewers is $|V| - |M|$, where $V$ is the set of vertices in the bipartite graph $G$ of votes with their conflicts as edges and $M$ is a maximum matching in $G$ computed with the Ford-Fulkerson algorithm taking advantage of the min-max duality shown in Figure \\ref{minmax_duality}.\n\n\\begin{marginfigure}\n    \\includegraphics[scale=0.5]{flowcutminmax.pdf}\n    \\caption{Min-max duality in bipartite graphs and corresponding networks.}\n\t\\label{minmax_duality}\n\\end{marginfigure}{}\n\n\\bibliographystyle{plainnat}\n\\bibliography{../common/math}\n\n\\end{document}\n\n", "meta": {"hexsha": "b1d652572fc2ef32cbcfd41c42069b6e78c5eb51", "size": 36371, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "catvsdog/catvsdog.tex", "max_stars_repo_name": "uwedeportivo/math_notes", "max_stars_repo_head_hexsha": "e0120bb53fad9043637ce964b186194888ba0c49", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "catvsdog/catvsdog.tex", "max_issues_repo_name": "uwedeportivo/math_notes", "max_issues_repo_head_hexsha": "e0120bb53fad9043637ce964b186194888ba0c49", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "catvsdog/catvsdog.tex", "max_forks_repo_name": "uwedeportivo/math_notes", "max_forks_repo_head_hexsha": "e0120bb53fad9043637ce964b186194888ba0c49", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5592485549, "max_line_length": 989, "alphanum_fraction": 0.6376233813, "num_tokens": 11426, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832805, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.4433581590083331}}
{"text": "%!TEX program = xelatex\n\\documentclass[aspectratio=169]{beamer}\n\n\\usepackage{blindtext}\n\\usepackage{url}\n\\usepackage{bm}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{xcolor}\n\\usepackage{tikzsymbols}\n\\usepackage{cleveref}\n\\usepackage{hyperref}\n\\usepackage{MyMnSymbol}\n\\hypersetup{\n  colorlinks = true,\n}\n\\usepackage[linesnumbered,ruled,vlined]{algorithm2e}\n\\usefonttheme[onlymath]{serif}\n\\usetheme{Execushares}\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\n\\title{Alternating Direction Method of Multipliers}\n\\subtitle{\\large{ELEC5470/IEDA6100A - Convex Optimization}}\n\\author{\\normalsize{\\textbf{Vin\\'icius and Prof. Daniel Palomar}}}\n\\date{December, 2020}\n\n\\setcounter{showSlideNumbers}{1}\n\\addtobeamertemplate{footnote}{\\vspace{-2pt}\\advance\\hsize-0.5cm}{\\vspace{6pt}}\n\n\\begin{document}\n  \\setcounter{showProgressBar}{0}\n  \\setcounter{showSlideNumbers}{0}\n\n  \\frame{\\titlepage}\n\n  \\begin{frame}\n    \\frametitle{Contents}\n    \\begin{enumerate}\n    \\item Introduction \\\\ \\textcolor{ExecusharesGrey}{\\footnotesize\\hspace{1em} Optimization algorithms, motivation}\n    \\item Alternating Direction Method of Multipliers \\\\ \\textcolor{ExecusharesGrey}{\\footnotesize\\hspace{1em} The basics}\n    \\item Practical Examples \\\\ \\textcolor{ExecusharesGrey}{\\footnotesize\\hspace{1em} Robust PCA and Graphical Lasso}\n    \\end{enumerate}\n  \\end{frame}\n\n  \\setcounter{framenumber}{0}\n  \\setcounter{showProgressBar}{1}\n  \\setcounter{showSlideNumbers}{1}\n\n  \\section*{Why use optimization algorithms?}\n        \\begin{frame}{Motivations}\n          {\\large methods for}\n          \\begin{itemize}\n            \\item large-scale optimization\n              \\begin{itemize}\n                \\item machine learning/statistics with huge datasets\n                \\item computer vision\n              \\end{itemize}\n            \\item descentralized optimization\n              \\begin{itemize}\n                \\item entities/agents/threads coordinate to solve a large problem by passing small messages\n              \\end{itemize}\n          \\end{itemize}\n        \\end{frame}\n\n        \\begin{frame}{Optimization Algorithms}\n          \\begin{itemize}\n            \\item Gradient Descent\n            \\item Newton\n            \\item Interior Point Methods (IPM)\n            \\item Block Coordinate Descent (BCD)\n            \\item Majorization-Minimization (MM)\n            \\item Block Majorization-Minimization (BMM)\n            \\item Successive Convex Approximation (SCA)\n            \\pause\n            \\item ...\n            \\pause\n            \\item \\bf{Alternating Direction Method of Multipliers (ADMM)}\n          \\end{itemize}\n        \\end{frame}\n  \\begin{frame}\n    \\frametitle{Reference}\n          \\begin{itemize}\n            \\item Boyd \\textit{et al.} \\textbf{Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers}.\n              \\textit{Foundations and Trends in Machine Learning}. 2010.\n            \\item available online for \\textbf{free}: \\url{https://web.stanford.edu/\\~boyd/papers/pdf/admm\\_distr\\_stats.pdf}\n            \\item citations: 13519\\footnote{as of Nov. 24th 2020}\n            \\item Yuxin Chen's Princeton lecture notes ELE 522: Large-Scale Optimization for Data Science\n          \\end{itemize}\n  \\end{frame}\n\n        \\begin{frame}{Dual Problem}\n          \\begin{itemize}\n            \\item convex equality constrained optimization problem\n             \\begin{equation*}\n                \\begin{array}{ll}\n                  \\underset{\\bm x}{\\textsf{minimize}} & f(\\bm x) \\\\\n                  \\textsf{subject to} & \\bm A\\bm x  = \\bm b\n                 \\end{array}\n            \\end{equation*}\n          \\item Lagrangian: $L(\\bm x, \\bm y) = f(\\bm x) + \\bm y^\\top(\\bm A \\bm x - \\bm b)$\n          \\item dual function: $g(\\bm y) = \\underset{\\bm x}{\\textsf{inf}} ~~ L(\\bm x, \\bm y)$\n          \\item dual problem: $\\underset{\\bm y}{\\textsf{maximize}} ~~ g(\\bm y)$\n          \\item recover: $\\bm x^\\star = \\underset{\\bm x}{\\textsf{argmin}}~~ L(\\bm x, \\bm y^\\star)$\n          \\end{itemize}\n        \\end{frame}\n\n        \\section*{Dual Ascent}\n\n        \\begin{frame}{Dual Ascent}\n          \\begin{itemize}\n            \\item gradient method for dual problem: $\\bm y^{k+1} = \\bm y^k + \\rho^k \\nabla g(\\bm y^k)$\n            \\item $\\nabla g(\\bm y^k) = \\bm A \\bm x^{k+1} - \\bm b$, where $\\bm x^{k+1} = \\underset{\\bm x}{\\textsf{arg~min}}~~L(\\bm x, \\bm y^k)$\n            \\item dual ascent method is\n            \\begin{align*}\n              \\bm x^{k+1} &:= \\underset{\\bm x}{\\textsf{arg~min}}~~L(\\bm x, \\bm y^k) \\\\\n              \\bm y^{k+1} &:= \\bm y^k + \\rho^k\\left(\\bm A \\bm x^{k+1} - \\bm b\\right)\n            \\end{align*}\n            \\pause\n            \\item why?\n          \\end{itemize}\n        \\end{frame}\n\n        \\section*{Dual Decomposition}\n        \\begin{frame}{Dual Decomposition}\n          \\begin{itemize}\n            \\item suppose $f$ is separable:\n            \\begin{equation*}\n              f(\\bm x) = f_{1}(x_1) + \\dots + f_n(x_n), \\bm x = (x_1, \\dots, x_n)\n            \\end{equation*}\n            \\item then the Lagrangian is separable in $\\bm x$:\n            \\begin{equation*}\n              L_i(x_i, \\bm y) = f_i(x_i) + \\bm y^\\top\\bm a_{*,i} x_i\n            \\end{equation*}\n            \\item $\\bm x$-minimization splits into $n$ separate minimizations\n            \\begin{equation*}\n              x^{k+1}_i := \\underset{x_i}{\\textsf{arg~min}}~ L_i(x_i, \\bm y^k), i = 1, ..., n\n            \\end{equation*}\n            which can be done in parallel and\n              $\\bm y^{k+1} = \\bm y^k + \\alpha^k\\left(\\sum_{i=1}^n \\bm a_{*,i}x^{k+1}_i - \\bm b\\right)$\n          \\end{itemize}\n        \\end{frame}\n\n    \n    \\begin{frame}\n      \\frametitle{Optimization Problem}\n                  \\vspace{1cm}\n                    {\\huge\n                  \\begin{equation}\n                     \\begin{array}{ll}\n                       \\underset{\\bm x,~ \\bm z}{\\textsf{minimize}} & f(\\bm x) + g(\\bm z) \\\\\n                       \\textsf{subject to} & \\bm A\\bm x + \\bm B \\bm z = \\bm c\n                      \\end{array}\n                 \\end{equation}\n                    }\n                 \\begin{itemize}\n                 \\item variables: $\\bm x \\in \\mathbb{R}^{n}$ and $\\bm z \\in \\mathbb{R}^{m}$\n                 \\item parameters: $\\bm A \\in \\mathbb{R}^{p\\times n}$, $\\bm B \\in \\mathbb{R}^{p\\times m}$, and $\\bm c \\in \\mathbb{R}^p$\n                 \\item optimal value: $p^\\star = \\underset{\\bm x, \\bm z}{\\textsf{inf}}\\left\\{f(\\bm x) + g(\\bm z): \\bm A\\bm x + \\bm B\\bm z = \\bm c\\right\\}$\n                 \\end{itemize}\n    \\end{frame}\n \n    \\section*{Augmented Lagrangian Method}\n\n    \\begin{frame}\n        \\frametitle{Augmented Lagrangian Method}\n        \\begin{itemize}\n          \\item Augmented Lagrangian:\n            \\begin{equation*}\n              L_{\\rho}(\\bm x, \\bm z, \\bm y) = \\underbrace{f(\\bm x) + g(\\bm z) + \\langle \\bm y, \\bm A\\bm x + \\bm B \\bm z - \\bm c \\rangle}_{\\text{Lagrangian}}\n              + \\dfrac{\\rho}{2}\\norm{\\bm A\\bm x + \\bm B \\bm z - \\bm c}^2_{\\mathrm{F}}\n            \\end{equation*}\n          \\item ALM consists of the iterations:\n            \\begin{align*}\n              \\bm x^{k+1}, \\bm z^{k+1} & := \\underset{\\bm x, \\bm z}{\\textsf{arg min}}~~ L_{\\rho}(\\bm x, \\bm z, \\bm y^k) ~{\\color{gray} \\text{// primal update}}\\\\\n              \\bm y^{k+1} & := \\bm y^k + \\rho\\left(\\bm A\\bm x^{k+1} + \\bm B \\bm z^{k+1} - \\bm c\\right) ~{\\color{gray} \\text{// dual update}}\n            \\end{align*}\n          \\item $\\rho > 0$ is a penalty hyperparameter\n        \\end{itemize}\n    \\end{frame}\n\n    \\begin{frame}{Issues with Augmented Lagrangian Method}\n      \\begin{itemize}\n        \\item the primal step is often expensive to solve -- as expensive as solving the original problem\n        \\item minimization of $\\bm x$ and $\\bm z$ has to be done jointly\n      \\end{itemize}\n    \\end{frame}\n\n    \\section*{Alternating Direction Method of Multipliers}\n\n                \\begin{frame}\n                  \\frametitle{Alternating Direction Method of Multipliers}\n                  \\begin{itemize}\n                    \\item Augmented Lagrangian:\n                      \\begin{equation*}\n                        L_{\\rho}(\\bm x, \\bm z, \\bm y) = \\underbrace{f(\\bm x) + g(\\bm z) + \\langle \\bm y, \\bm A\\bm x + \\bm B \\bm z - \\bm c \\rangle}_{\\text{Lagrangian}}\n                        + \\dfrac{\\rho}{2}\\norm{\\bm A\\bm x + \\bm B \\bm z - \\bm c}^2_{\\mathrm{F}}\n                      \\end{equation*}\n                    \\item ADMM consists of the iterations:\n                      \\begin{align*}\n                        \\bm x^{k+1} & := \\underset{\\bm x}{\\textsf{arg min}}~~ L_{\\rho}(\\bm x, \\bm z^k, \\bm y^k) \\\\\n                        \\bm z^{k+1} & := \\underset{\\bm z}{\\textsf{arg min}}~~ L_{\\rho}(\\bm x^{k+1}, \\bm z, \\bm y^k) \\\\\n                        \\bm y^{k+1} & := \\bm y^k + \\rho\\left(\\bm A\\bm x^{k+1} + \\bm B \\bm z^{k+1} - \\bm c\\right)\n                      \\end{align*}\n                    \\item $\\rho > 0$ is a penalty hyperparameter\n                  \\end{itemize}\n                \\end{frame}\n\n                \\begin{frame}\n                  \\frametitle{Convergence and Stopping Criteria}\n                  \\begin{itemize}\n                    \\item assume (very little!)\n                      \\begin{itemize}\n                        \\item $f$, $g$ are convex, closed, proper % closed: sublevels sets are closed sets\n                                                                  % proper: effective domain is non-empty and it never attains -infty\n                        \\item $L_{0}$ has a saddle point % saddle point theorem\n                      \\end{itemize}\n                    \\item then ADMM converges:\n                      \\begin{itemize}\n                        \\item iterates approach feasibility: $\\bm A \\bm x^k + \\bm B \\bm z^k - \\bm c \\rightarrow \\bm 0$\n                        \\item objective approaches optimal value: $f(\\bm x^k) + g(\\bm z^k) \\rightarrow p^\\star$\n                      \\end{itemize}\n                    \\item false (in general) statements: $\\bm x$ converges, $\\bm z$ converges\n                    \\item true statement: $\\bm y$ converges\n                    \\item what matters: residual is small and near optimality in objective value\n                  \\end{itemize}\n                \\end{frame}\n\n                \\begin{frame}{Convergence of ADMM in Practice}\n                  \\begin{itemize}\n                    \\item ADMM is often slow to converge to high accuracy\n                    \\item ADMM often converges to moderate accuracy within a few dozens of iterations, which is often sufficient\n                    for most practical purposes \n                  \\end{itemize}\n                \\end{frame}\n\n                \\section*{Practical Examples}\n                \\begin{frame}{Robust PCA (Candes et al. '08)}\n                  \\begin{itemize}\n                    \\item We would like to model a data matrix $\\bm M$ as low-rank plus sparse components:\n                  \\end{itemize}\n                    {\\huge\n                    \\begin{equation*}\n                       \\begin{array}{ll}\n                         \\underset{\\bm L,~ \\bm S}{\\textsf{minimize}} & \\norm{\\bm L}_{*} + \\lambda \\norm{\\bm S}_{1} \\\\\n                         \\textsf{subject to} & \\bm L + \\bm S = \\bm M\n                        \\end{array}\n                   \\end{equation*}\n                      }\n                  \\begin{itemize}\n                    \\item where $\\norm{\\bm L}_{*} := \\sum_{i=1}^{n}\\sigma_{i}(\\bm{L})$ is the nuclear norm\n                    \\item and $\\norm{\\bm S}_1 := \\sum_{i,j}\\vert S_{ij}\\vert$ is the entrywise $\\ell_1$-norm\n                  \\end{itemize}\n                \\end{frame}\n                \\begin{frame}{Robust PCA via ADMM}\n                  ADMM for solving robust PCA:\n                  \\begin{align*}\n                    \\bm L^{k+1} &= \\underset{\\bm L}{\\textsf{arg~min}} ~~ \\norm{\\bm L}_{*} + \\mathrm{tr}\\left(\\bm Y^{k\\top} \\bm L \\right) + \\dfrac{\\rho}{2}\\norm{\\bm L + \\bm S^k - \\bm M}^2_{\\textrm{F}}\\\\\n                    \\bm S^{k+1} &= \\underset{\\bm S}{\\textsf{arg~min}} ~~ \\lambda\\norm{\\bm S}_{1} + \\mathrm{tr}\\left(\\bm Y^{k\\top} \\bm S \\right) + \\dfrac{\\rho}{2}\\norm{\\bm L^{k+1} + \\bm S - \\bm M}^2_{\\textrm{F}}\\\\\n                    \\bm Y^{k+1} &= \\bm Y^k + \\rho \\left(\\bm L^{k+1} + \\bm S^{k+1} - \\bm M\\right)\n                  \\end{align*}\n                \\end{frame}\n                \\begin{frame}{Robust PCA via ADMM}\n                  \\begin{align*}\n                    \\bm L^{k+1} &= \\textsf{SVT}_{\\rho^{-1}}\\left(\\bm M - \\bm S^k - \\frac{1}{\\rho}\\bm Y^k\\right)\\\\\n                    \\bm S^{k+1} &= \\textsf{ST}_{\\lambda \\rho^{-1}}\\left(\\bm M - \\bm L^{k+1} - \\frac{1}{\\rho}\\bm Y^k\\right) \\\\\n                    \\bm Y^{k+1} &= \\bm Y^k + \\rho \\left(\\bm L^{k+1} + \\bm S^{k+1} - \\bm M\\right),\n                  \\end{align*}\n                  where for any $\\bm X$ with \\textsf{SVD} $\\bm X = \\bm U \\boldsymbol \\Sigma \\bm V^\\top$, $\\boldsymbol \\Sigma = \\textsf{diag}\\left(\\left\\{\\sigma_i\\right\\}\\right)$, we have\n                  \\begin{equation*}\n                    \\textsf{SVT}_{\\tau}\\left(\\bm X\\right) = \\bm U \\textsf{diag}\\left(\\left\\{(\\sigma_i - \\tau)^{+}\\right\\}\\right)\\bm V ^\\top\n                  \\end{equation*}\n                  and\n                  \\begin{equation*}\n                     \\left(\\textsf{ST}_{\\tau}\\left(\\bm X\\right)\\right)_{ij} = \n                    \\begin{cases}\n                      X_{ij} - \\tau, & ~\\text{if}~ X_{ij} > \\tau,\\\\\n                      0, & ~\\text{if}~ \\vert X_{ij}\\vert \\leq \\tau, \\\\\n                      X_{ij} + \\tau, & ~\\text{if}~ X_{ij} < -\\tau\n                    \\end{cases}\n                  \\end{equation*}\n                \\end{frame}\n\n                \\begin{frame}{Graphical Lasso}\n                  \\textbf{Precision matrix estimation} from Gaussian samples:\n                  {\\large\n                  \\begin{equation*}\n                     \\begin{array}{ll}\n                       \\underset{\\boldsymbol \\Theta}{\\textsf{minimize}} & \\underbrace{- \\textrm{log det} ~ \\boldsymbol \\Theta + \\langle \\boldsymbol \\Theta, \\bm S\\rangle}_{\\text{neg. log likelihood}} + \\lambda \\norm{\\boldsymbol \\Theta}_{1}\\\\\n                       \\textsf{subject to} & \\boldsymbol \\Theta \\succ \\mathbf{0}\n                      \\end{array}\n                 \\end{equation*}\n                    }\n                  Or equivalently, using a slack variable $\\boldsymbol \\Psi = \\boldsymbol \\Theta$ \n                    {\\large\n                    \\begin{equation*}\n                       \\begin{array}{ll}\n                         \\underset{\\boldsymbol \\Theta, \\boldsymbol \\Psi}{\\textsf{minimize}} & \\underbrace{- \\textrm{log det} ~ \\boldsymbol \\Theta + \\langle \\boldsymbol \\Theta, \\bm S\\rangle}_{\\text{neg. log likelihood}} + \\lambda \\norm{\\boldsymbol \\Psi}_{1}\\\\\n                         \\textsf{subject to} & \\boldsymbol \\Theta \\succ \\mathbf{0}, \\boldsymbol \\Theta = \\boldsymbol \\Psi\n                        \\end{array}\n                   \\end{equation*}\n                      }\n                \\end{frame}\n\n                \\begin{frame}{Graphical Lasso via ADMM}\n                  \\begin{align*}\n                    \\boldsymbol \\Theta^{k+1} & = \\underset{\\boldsymbol \\Theta \\succ \\mathbf{0}}{\\textsf{arg min}} ~~ - \\textrm{log det} ~ \\boldsymbol \\Theta + \\langle \\boldsymbol \\Theta, \\bm S + \\bm Y^k\\rangle + \\dfrac{\\rho}{2}\\norm{\\boldsymbol \\Theta - \\boldsymbol \\Psi^k}^2_{\\textrm{F}}\\\\\n                    \\boldsymbol \\Psi^{k+1} & = \\underset{\\boldsymbol \\Psi}{\\textsf{arg min}} ~~ \\lambda \\norm{\\boldsymbol \\Psi}_{1} - \\langle \\boldsymbol \\Psi, \\bm Y^k\\rangle + \\dfrac{\\rho}{2}\\norm{\\boldsymbol \\Theta^k - \\boldsymbol \\Psi}^2_{\\textrm{F}}\\\\\n                    \\bm Y^{k+1} & = \\bm Y^k + \\rho\\left(\\boldsymbol \\Theta^{k+1} - \\boldsymbol \\Psi^{k+1}\\right)\n                  \\end{align*}\n                \\end{frame}\n\n                \\begin{frame}{Graphical Lasso via ADMM}\n                  \\begin{align*}\n                    \\boldsymbol \\Theta^{k+1} & = \\mathcal{F}_\\rho\\left(\\boldsymbol \\Psi^k - \\dfrac{1}{\\rho}\\left(\\bm Y^k + \\bm S\\right)\\right) \\\\\n                    \\boldsymbol \\Psi^{k+1} & = \\textsf{ST}_{\\lambda\\rho^{-1}}\\left(\\boldsymbol \\Theta^{k+1} + \\dfrac{1}{\\rho}\\bm Y^{k}\\right) \\\\\n                    \\bm Y^{k+1} & = \\bm Y^k + \\rho\\left(\\boldsymbol \\Theta^{k+1} - \\boldsymbol \\Psi^{k+1}\\right)\n                  \\end{align*}\n                  \\begin{itemize}\n                    \\item where $\\mathcal{F}_{\\rho}(\\bm X) := \\frac{1}{2} \\bm U \\textsf{diag}\\left(\\left\\{\\lambda_i + \\sqrt{\\lambda^2_i + \\frac{4}{\\rho}}\\right\\}\\right)\\bm U^\\top$, for $\\bm X = \\bm U \\boldsymbol \\Lambda \\bm U^\\top$.\n                  \\end{itemize}\n                \\end{frame}\n\n                \\begin{frame}{Network of stocks via Graphical Lasso}\n                  \\begin{figure}[!htb]\n                    \\centering\n                    \\includegraphics[scale=0.5]{images/stock-network-glasso.eps}\n                  \\end{figure}\n                \\end{frame}\n\n                \\begin{frame}{Network of stocks via Graphical Lasso}\n                  \\begin{figure}[!htb]\n                    \\centering\n                    \\includegraphics[scale=0.5]{images/augmented-lagrangian.pdf}\n                    ~\n                    \\includegraphics[scale=0.5]{images/primal-residual.pdf}\n                  \\end{figure}\n                \\end{frame}\n\n                \\begin{frame}{Conclusion}\n                  \\begin{itemize}\n                    \\item ADMM is a versatile/flexible optimization framework\n                    \\item may not be the best for a specific case, but often performs well in practice\n                    \\item convergence often needs to be proved in a case-by-case scenario\n                  \\end{itemize}\n                \\end{frame}\n\n                \\section*{Questions?}\n\\end{document}\n", "meta": {"hexsha": "3c737f5a496f18b7f76c1e6a19127d2571f8931e", "size": 17791, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/sample.tex", "max_stars_repo_name": "mirca/admm-talk", "max_stars_repo_head_hexsha": "e3ef4f3460d27e3e2fcba64be7feb39a5c64e53b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-06T04:29:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-06T04:29:14.000Z", "max_issues_repo_path": "presentation/sample.tex", "max_issues_repo_name": "mirca/admm-talk", "max_issues_repo_head_hexsha": "e3ef4f3460d27e3e2fcba64be7feb39a5c64e53b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/sample.tex", "max_forks_repo_name": "mirca/admm-talk", "max_forks_repo_head_hexsha": "e3ef4f3460d27e3e2fcba64be7feb39a5c64e53b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.9770773639, "max_line_length": 290, "alphanum_fraction": 0.5064358383, "num_tokens": 5271, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832805, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.4433581590083331}}
{"text": "\n\n\\section{Relative FM-index}\n\nThe \\emph{relative FM-index} (\\RFM) \\cite{Belazzougui2014} is a compressed\nsuffix array of a sequence relative to the \\CSA{} of another sequence.\nThe index is based on approximating the\n\\emph{longest common subsequence} (\\LCS) of $\\mBWT_{R}$ and $\\mBWT_{S}$,\nwhere $R$ is the reference sequence and $S$ is the target sequence, and\nstoring several structures based on the common subsequence. Given a\nrepresentation of $\\mBWT_{R}$ supporting \\rank{} and \\select{}, we can use the\nrelative index $\\mRFM_{S \\mid R}$ to simulate \\rank{} and \\select{} on\n$\\mBWT_{S}$.\n\nIn this section, we describe the relative FM-index using the notation and the\nterminology of this paper. We also give an explicit description of the\n\\locate{} and \\extract{} functionality, which was not included in the original\npaper. Finally, we describe a more space-efficient variant of the algorithm\nfor building a relative FM-index with full functionality.\n\n\\subsection{Basic index}\n\nAssume that we have found a long common subsequence of sequences $X$ and $Y$.\nWe call positions $X[i]$ and $Y[j]$ \\emph{lcs-positions}, if they are in the\ncommon subsequence. If $B_{X}$ and $B_{Y}$ are the binary sequences marking\nthe common subsequence ($X[\\select_1(B_{X},i)] = Y[\\select_1(B_{Y},i)]$), we\ncan move between lcs-positions in the two sequences with \\rank{} and \\select{}\noperations. If $X[i]$ is an lcs-position, the corresponding position in\nsequence $Y$ is $Y[\\mselect_{1}(B_{Y}, \\mrank_{1}(B_{X}, i))]$. We denote this\npair of \\emph{lcs-bitvectors} $\\mAli(X,Y) = \\langle B_X,B_Y \\rangle$.\n\nIn its most basic form, the relative FM-index $\\mRFM_{S \\mid R}$ only supports\n\\find{} queries by simulating \\rank{} queries on $\\mBWT_{S}$. It does this by\nstoring $\\mAli(\\BWT_{R},\\BWT_{S})$ and the complements (subsequences of\nnon-aligned characters) $\\mCS(\\mBWT_{R})$ and $\\mCS(\\mBWT_{S})$. The\nlcs-bitvectors are compressed using \\emph{entropy-based compression}\n\\cite{Raman2007}, while the complements are stored in structures similar to\nthe reference $\\mBWT_{R}$.\n\nTo compute $\\mrank_{c}(\\mBWT_{S}, i)$, we first determine the number of\nlcs-positions in $\\mBWT_{S}$ up to position $S[i]$ with $k =\n\\mrank_{1}(B_{\\mBWT_{S}}, i)$. Then we find the lcs-position $k$ in $\\mBWT_{R}$\nwith $j = \\mselect_{1}(B_{\\mBWT_{R}}, k)$. With these positions, we can compute\n\\begin{eqnarray*}\n\\mrank_{c}(\\mBWT_{S}, i) &=& \\mrank_{c}(\\mBWT_{R}, j) \\\\\n   && - \\mrank_{c}(\\mCS(\\mBWT_{R}),j-k) \\\\\n   && + \\mrank_{c}(\\mCS(\\mBWT_{S}), i-k).\n\\end{eqnarray*}\n\n\\subsection{Relative select}\n\nWe can implement the entire functionality of a compressed suffix array with\n\\rank{} queries on the \\BWT. However, if we use the \\CSA{} in a compressed\nsuffix tree, we also need \\select{} queries to support \\emph{forward\nsearching} with $\\mPsi$ and $\\mChild$ queries. We can always implement\n\\select{} queries by binary searching with \\rank{} queries, but the result\nwill be much slower than the \\rank{} queries.\n\nA faster alternative to support \\select{} queries in the relative FM-index\nis to build a \\emph{relative select} structure \\rselect{}~\\cite{Boucher2015}.\nLet $\\mF_{X}$ be a sequence consisting of the characters of sequence $X$ in\nsorted order. Alternatively, $\\mF_{X}$ is a sequence such that $\\mF_{X}[i] =\n\\mBWT_{X}[\\mPsi_X(i)]$. The relative select structure consists of bitvectors\n$\\mAli(\\mF_{R}, \\mF_{S})$, where $B_{\\mF_{R}}[i] = B_{\\mBWT_{R}}[\\mPsi_R(i)]$ \nand $B_{\\mF_{S}}[i] = B_{\\mBWT_{S}}[\\mPsi_S(i)]$, as well as the \\C{} array\n$\\mC_{\\mLCS}$ for the common subsequence.\n\nTo compute $\\mselect_{c}(\\mBWT_{S}, i)$, we first determine how many of\nthe first $i$ occurrences of character $c$ are lcs-positions with $k =\n\\mrank_{1}(B_{\\mF_{S}}, \\mC_{\\mBWT_{S}}[c] + i) - \\mC_{\\mLCS}[c]$. Then we check\nfrom bit $B_{\\mF_{S}}[\\mC_{\\mBWT_{S}}[c] + i]$ whether the occurrence we are\nlooking for is an lcs-position or not. If it is,\nwe find the position in $\\mBWT_{R}$ as $j = \\mselect_{c}(\\mBWT_{R},\n\\mselect_{1}(B_{\\mF_{R}}, \\mC_{\\mLCS}[c] + k)- \\mC_{R}[c])$, and then map $j$ to\n$\\mselect_{c}(\\mBWT_{S}, i)$ by using $\\mAli(\\mBWT_{R}, \\mBWT_{S})$. Otherwise we\nfind the occurrence in $\\mCS(\\mBWT_{S})$ with $j = \\mselect_{c}(\\mCS(\\mBWT_{S}),\ni-k)$, and return $\\mselect_{c}(\\mBWT_{S}, i) = \\mselect_{0}(B_{\\mBWT_{S}}, j)$.\n\n\\subsection{Full functionality}\n\nIf we want the relative FM-index to support \\locate{} and \\extract{} queries,\nwe cannot build it from any common subsequence of $\\mBWT_{R}$ and $\\mBWT_{S}$.\nWe need a \\emph{bwt-invariant subsequence} \\cite{Belazzougui2014}, where the\nalignment of the \\BWT{}s is also an alignment of the original sequences.\n\n\\begin{definition}\\label{def:bwt-invariant}\nLet $X$ be a common subsequence of $\\mBWT_{R}$ and $\\mBWT_{S}$, and let\n$\\mBWT_{R}[i_{R}]$ and $\\mBWT_{S}[i_{S}]$ be the lcs-positions corresponding to\n$X[i]$. Subsequence X is bwt-invariant if\n$$\n\\mSA_{R}[i_{R}] < \\mSA_{R}[j_{R}] \\iff \\mSA_{S}[i_{S}] < \\mSA_{S}[j_{S}]\n$$\nfor all positions $i, j \\in \\set{1, \\dotsc, \\abs{X}}$.\n\\end{definition}\n\nIn addition to the structures already mentioned, the full relative FM-index\nhas another pair of lcs-bitvectors, $\\mAli(R,S)$, which marks the\nbwt-invariant subsequence in the original sequences. If $\\mBWT_{R}[i_{R}]$ and\n$\\mBWT_{S}[i_{S}]$ are lcs-positions, we set $B_{R}[\\mSA_{R}[i_{R}]-1] = 1$ and\n$B_{S}[\\mSA_{S}[i_{S}]-1] = 1$.\\footnote{For simplicity, we assume that the\nendmarker is not a part of the bwt-invariant subsequence. Hence $\\mSA[i] > 1$\nfor all lcs-positions $\\mBWT[i]$.}\n\nTo compute the answer to a $\\mlocate(i)$ query, we start by iterating\n$\\mBWT_{S}$ backwards with \\LF{} queries, until we find an lcs-position\n$\\mBWT_{S}[i']$ after $k$ steps. Then we map position $i'$ to the corresponding\nposition $j'$ in $\\mBWT_{R}$ by using $\\mAli(\\mBWT_{R},\\mBWT_{S})$. Finally we\ndetermine $\\mSA_{R}[j']$ with a \\locate{} query in the reference index, and map\nthe result to $\\mSA_{S}[i']$ by using $\\mAli(R,S)$.\\footnote{If $\\mBWT_{S}[i']$\nand $\\mBWT_{R}[j']$ are lcs-positions, the corresponding lcs-positions in the\noriginal sequences are $S[\\mSA_{S}[i']-1]$ and $R[\\mSA_{R}[j']-1]$.} The result\nof the $\\mlocate(i)$ query is $\\mSA_{S}[i']+k$.\n\nThe $\\mISA_{S}[i]$ access required for \\extract{} queries is supported in a\nsimilar way. We find the lcs-position $S[i+k]$ for the smallest $k \\ge 0$, and\nmap it to the corresponding position $R[j]$ by using $\\mAli(R,S)$. Then we\ndetermine $\\mISA_{R}[j+1]$ by using the reference index, and map it back to\n$\\mISA_{S}[i+k+1]$ with $\\mAli(\\mBWT_{R},\\mBWT_{S})$. Finally we iterate\n$\\mBWT_{S}$ $k+1$ steps backward with \\LF{} queries to find $\\mISA_{S}[i]$.\n\nIf the target sequence contains long\ninsertions not present in the reference, we may also want to include\nsome \\SA{} and \\ISA{} samples for querying those regions.\n\n\\subsection{Finding a bwt-invariant subsequence}\n\nWith the basic relative FM-index, we approximate the longest common\nsubsequence of $\\mBWT_{R}$ and $\\mBWT_{S}$ by partitioning the \\BWT{}s according\nto lexicographic contexts, finding the longest common subsequence for each\npair of substrings in the partitioning, and concatenating the results. The\nalgorithm is fast, easy to parallelize, and quite space-efficient. As such,\n\\RFM{} construction is practical, having been tested with datasets of hundreds\nof gigabytes in size.\n\nIn the following, we describe a more space-efficient variant of the original\nalgorithm \\cite{Belazzougui2014} for finding a bwt-invariant subsequence. We\n\\begin{itemize}\n\\item save space by simulating the \\emph{mutual suffix array} $\\mSA_{RS}$ with\n$\\mCSA_{R}$ and $\\mCSA_{S}$;\n\\item \\emph{match} suffixes of $R$ and $S$ only if they are adjacent in\n$\\mSA_{RS}$; and\n\\item run-length encode the match arrays to save space.\n\\end{itemize}\n\n\\begin{definition}\nLet $R$ and $S$ be two sequences, and let $\\mSA = \\mSA_{RS}$ and $\\mISA =\n\\mISA_{RS}$. The \\emph{left match} of suffix $R[i,\\abs{R}]$ is the suffix\n$S[\\mSA[\\mISA[i]-1] - \\abs{R}, \\abs{S}]$, if $\\mISA[i] > 1$ and\n$\\mSA[\\mISA[i]-1]$ points to a suffix of $S$ ($\\mSA[\\mISA[i]-1] > \\abs{R}$).\nThe \\emph{right match} of suffix $R[i,\\abs{R}]$ is the suffix\n$S[\\mSA[\\mISA[i]+1] - \\abs{R}, \\abs{S}]$, if $\\mISA[i] < \\abs{RS}$ and\n$\\mSA[\\mISA[i]+1]$ points to a suffix of $S$.\n\\end{definition}\n\nWe simulate the mutual suffix array $\\mSA_{RS}$ with $\\mCSA_{R}$, $\\mCSA_{S}$,\nand the \\emph{merging bitvector} $B_{R,S}$ of length $\\abs{RS}$. We set\n$B_{R,S}[i] = 1$, if $\\mSA_{RS}[i]$ points to a suffix of $S$. The merging\nbitvector can be built in $\\Oh(\\abs{S} \\cdot t_{\\mLF})$ time, where $t_{\\mLF}$ is\nthe time required for an \\LF{} query, by extracting $S$ from $\\mCSA_{S}$ and\nbackward searching for it in $\\mCSA_{R}$ \\cite{Siren2009}. Suffix\n$R[i,\\abs{R}]$ has a left (right) match, if $B_{R,S}[\\mselect_{0}(B_{R,S},\n\\mISA_{R}[i])-1] = 1$ ($B_{R,S}[\\mselect_{0}(B_{R,S}, \\mISA_{R}[i])+1] = 1)$).\n\nOur next step is building the \\emph{match arrays} $\\mleft$ and $\\mright$,\nwhich correspond to the arrays $A[\\cdot][2]$ and $A[\\cdot][1]$ in the original\nalgorithm. This is done by traversing $\\mCSA_{R}$ backwards from\n$\\mISA_{R}[\\abs{R}] = 1$ with \\LF{} queries and following the left and the\nright matches of the current suffix. During the traversal, we maintain\nthe invariant $j = \\mSA_{R}[i]$ with $(i,j) \\leftarrow (\\mLF_{R}(i), j-1)$. If\nsuffix $R[j,\\abs{R}]$ has a left (right) match, we use the shorthand $l(j) =\n\\mrank_{1}(B_{R,S}, \\mselect_{0}(B_{R,S}, i)-1)$ ($r(j) = \\mrank_{1}(B_{R,S},\n\\mselect_{0}(B_{R,S}, i)+1)$) to refer to its position in $\\mCSA_{S}$.\n\nWe say that suffixes $R[j,\\abs{R}]$ and $R[j+1,\\abs{R}]$ have the same left\nmatch if $l(j) = \\mLF_{S}(l(j+1))$. Let $R[j,\\abs{R}]$ to $R[j+\\ell,\\abs{R}]$\nbe a maximal run of suffixes having the same left match, with suffixes\n$R[j,\\abs{R}]$ to $R[j+\\ell-1,\\abs{R}]$ starting with the same characters as\ntheir left matches.\\footnote{The first character of a suffix can be determined\nby using the $\\mC$ array.} We find the left match of suffix $R[j,\\abs{R}]$ as\n$j' = \\mSA_{S}[l(j)]$ by using $\\mCSA_{S}$, and set $\\mleft[j,j+\\ell-1] =\n[j',j'+\\ell-1]$. The right match array $\\mright$ is built in a similar way.\n\nThe match arrays require $2\\abs{R} \\log \\abs{S}$ bits of space. If sequences\n$R$ and $S$ are similar, the runs in the arrays tend to be long. Hence we can\nrun-length encode the match arrays to save space. The traversal takes\n$\\Oh(\\abs{R} \\cdot (t_{\\mLF} + t_{\\mrank} + t_{\\mselect}) + rd \\cdot\nt_{\\mLF})$ time, where $t_{\\mrank}$ and $t_{\\mselect}$ denote the time\nrequired by \\rank{} and \\select{} operations, $r$ is the number of runs in the\ntwo arrays, and $d$ is the suffix array sample interval in\n$\\mCSA_{S}$.\\footnote{The time bound assumes text-order sampling.}\n\nThe final step is determining the bwt-invariant subsequence. We find a\nbinary sequence $B_{R}[1,\\abs{R}]$, which marks the common subsequence in $R$,\nand a strictly increasing integer sequence $Y$, which contains the positions\nof the common subsequence in $S$. This can be done by finding the longest\nincreasing subsequence over $R$, where we consider both $\\mleft[i]$ and\n$\\mright[i]$ as candidates for the value at position $i$, and using the found\nsubsequence as $Y$. If $Y[j]$ comes from $\\mleft[i]$ ($\\mright[i]$), we set\n$B_{R}[i] = 1$, and align suffix $R[i, \\abs{R}]$ with its\nleft (right) match $S[Y[j], \\abs{S}]$ in the bwt-invariant subsequence. We can\nfind $B_{R}$ and $Y$ in $\\Oh(\\abs{R} \\log \\abs{R})$ time with\n$\\Oh(\\abs{R} \\log \\abs{R})$ bits of additional working space with a\nstraightforward modification of the dynamic programming algorithm for finding\nthe longest increasing subsequence. The dynamic programming tables can be\nrun-length encoded, but we found that this did not yield good time/space\ntrade-offs.\n\nAs sequence $Y$ is strictly increasing, we can convert it into binary sequence\n$B_{S}[1,\\abs{S}]$, marking $B_{S}[Y[j]] = 1$ for all $j$.\nAfterwards, we consider the binary sequences $B_{R}$ and $B_{S}$ as the\nlcs-bitvectors $\\mAli(R,S)$. Because every suffix of $R$ starts with the same\ncharacter as its matches stored in the $\\mleft$ and $\\mright$ arrays,\nsubsequences $R[B_{R}]$ and $S[B_{S}]$ are identical.\n\nFor any $i$, let $i_{R} = \\mselect_{1}(B_{R}, i)$ and $i_{S} =\n\\mselect_{1}(B_{S}, i)$ be the lcs-positions of rank $i$. As suffixes\n$R[i_{R}, \\abs{R}]$ and $S[i_{S}, \\abs{S}]$ are aligned in the bwt-invariant\nsubsequence, they are also adjacent in the mutual suffix array $\\mSA_{RS}$.\nHence\n$$\n\\mISA_{R}[i_{R}] < \\mISA_{R}[j_{R}] \\iff \\mISA_{S}[i_{S}] < \\mISA_{S}[j_{S}]\n$$\nfor $1 \\le i,j \\le \\abs{Y}$, which is equivalent to the condition in\nDefinition~\\ref{def:bwt-invariant}. We can convert $\\mAli(R,S)$ to\n$\\mAli(\\mBWT_{R},\\mBWT_{S})$ in $\\Oh((\\abs{R}+\\abs{S}) \\cdot t_{\\mLF})$ time by\ntraversing $\\mCSA_{R}$ and $\\mCSA_{S}$ backwards. The resulting subsequence of\n$\\mBWT_{R}$ and $\\mBWT_{S}$ is bwt-invariant.\n\nNote that the full relative FM-index is more limited than the basic index,\nbecause it does not handle \\emph{substring moves} very well. Let $R = xy$ and\n$S = yx$, for two random sequences $x$ and $y$ of length $n/2$ each. Because\n$\\mBWT_{R}$ and $\\mBWT_{S}$ are very similar, we can expect to find a common\nsubsequence of length almost $n$. On the other hand, the length of the longest\nbwt-invariant subsequence is around $n/2$, because we can either match the\nsuffixes of $x$ or the suffixes of $y$ in $R$ and $S$, but not both.\n\n", "meta": {"hexsha": "efa6725a317d9624eb75fe3aead6fd69c5afc7b1", "size": 13432, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "rcst/rfm.tex", "max_stars_repo_name": "jltsiren/relative-fm", "max_stars_repo_head_hexsha": "68c11f172fd2a546792aad3ad81ee1e185b5ee7f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2015-04-29T11:18:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-21T20:32:08.000Z", "max_issues_repo_path": "rcst/rfm.tex", "max_issues_repo_name": "jltsiren/relative-fm", "max_issues_repo_head_hexsha": "68c11f172fd2a546792aad3ad81ee1e185b5ee7f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "rcst/rfm.tex", "max_forks_repo_name": "jltsiren/relative-fm", "max_forks_repo_head_hexsha": "68c11f172fd2a546792aad3ad81ee1e185b5ee7f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-12-06T20:49:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-14T10:33:01.000Z", "avg_line_length": 56.6751054852, "max_line_length": 81, "alphanum_fraction": 0.6885050625, "num_tokens": 4604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.44335815205486045}}
{"text": "\\section{Theories}\n\\label{theories}\n\nThe result of a session with the \\HOL{} system is an object called a\n{\\it theory\\/}.  This object is closely related to what a logician\nwould call a theory, but there are some differences arising from the\nneeds of mechanical proof.  A \\HOL{} theory, like a logician's theory,\ncontains sets of types, constants, definitions and axioms.  In\naddition, however, a \\HOL{} theory contains an explicit list of\ntheorems that have been proved from the axioms and definitions.\nLogicians normally do not need to distinguish theorems that have\nactually been proved from those that could be proved, hence they do\nnot normally consider sets of proven theorems as part of a theory;\nrather, they take the theorems of a theory to be the (often infinite)\nset of all consequences of the axioms and definitions.  Another\ndifference between logicians' theories and \\HOL{} theories is that, for\nlogicians, theories are relatively static objects, but in \\HOL{} they\ncan be thought of as potentially extendable. For example, the \\HOL\\\nsystem provides tools for adding to theories and combining theories.\nA typical interaction with \\HOL{} consists in combining some existing\ntheories, making some definitions, proving some theorems and then\nsaving the resulting new theory.\n\nThe purpose of the \\HOL{} system is to provide tools to enable\nwell-formed theories to be constructed.  All the theorems of such\ntheories are logical consequences of the definitions and axioms of the\ntheory.  The \\HOL{} system ensures that only well-formed theories can\nbe constructed by allowing theorems to be created by {\\it formal\n  proof\\/} only.\n\nA theory is represented in the \\HOL{} system as a collection of SML\nobject files, called theory files.  Each file has a name of the form\n$name$\\ml{Theory.}$ext$, where $name$ is a string supplied by the\nuser, and $ext$ is one of \\ml{sig}, \\ml{sml}, \\ml{ui}, \\ml{uo}.\n\nTheory files are structured hierarchically to represent sequences of\nextensions of an initial theory called \\ml{scratch}.  Each theory file\nmaking up a theory records some types, constants, axioms and theorems,\ntogether with pointers to other theory files called its {\\it\n  parents\\/}.  This collection of reachable files is called the {\\it\n  ancestry\\/} of the theory file. Axioms, definitions and theorems are\nnamed in the \\HOL{} system by two strings: the name of the theory file\nwhere they are stored, together with a name within that file supplied\nby the user.  Specifically, axioms, definitions and theorems are named\nby a pair of strings $\\langle thy,name\\rangle$ where $thy$ is the name\nof the theory current when the item was declared and $name$ is a\nspecific name supplied by the user (see the functions \\ml{new\\_axiom},\n\\ml{new\\_definition} \\etc\\ below).\n\nA typical piece of work with the \\HOL{} system consists in a number of\nsessions.  A theorem-proving session consists of interactions with the\nsystem through its ``command-line interface''.  At the same time, it's\nimportant that the commands the user enters are saved in some sort of\nfile (presumably through an editor) so that these commands can be\nreplayed later.  For the first sessions of theory development, each\ntime \\HOL{} is started, the saved commands from previous sessions will\nneed to be re-entered into the system.  This can be done with\ncut-and-paste functionality, or the \\ml{use} command (which takes a\nfile-name and reads it for input).\n\nEventually (possibly even after the very first session; this is a\nmatter of taste), the theory under development will be in a\nsufficiently polished state that the user will want to save it to a\n``script'' file and compile it.  This process is described further in\nthe examples below, but produces a theory file that can be loaded in\nthe same way as the system's built-in theories.\n\nThere is always a {\\it current theory\\/}, whose name is given by the\nfunction \\ml{current\\_theory}.  This function maps the unit value,\nwritten `\\ml{()}' in \\ML, to a string giving the name of the current\ntheory.  Thus the \\ML{} expression \\ml{current\\_theory ()} evaluates to\na string giving the name of the current theory.  Initially \\HOL{} has\nits current theory called \\ml{scratch}.  In the examples so far, there\nhasn't been a call to \\ml{new\\_theory}, so the current theory is still\n``scratch''.\n\n\\begin{session}\\begin{verbatim}\n- current_theory();\n> val it = \"scratch\" : string\n-\n\\end{verbatim}\\end{session}\n\n    Executing \\ml{new\\_theory`$thy$`} creates a new theory called\n    $thy$.  The remaining example sessions will demonstrate the\n    construction of a theory of prime numbers.\n\n\\begin{session}\\begin{verbatim}\n- new_theory \"primes\";\n> val it = () : unit\n\\end{verbatim}\\end{session}\n\n\\noindent\nThis starts a theory called \\ml{primes}, which is to be made into a\ntheory containing definitions and theorems about the prime numbers.\nThis will be developed further in chapter~\\ref{euclid} to include\nEuclid's proof that there are an infinite number of primes.\n\nBecause we loaded \\ml{arithmeticTheory} and \\ml{pairTheory} to begin,\nboth of these theories are part of our new theory's ancestry.  In\nfact, there are a number of other ancestor theories that these two\ndepend on in turn.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"tutorial\"\n%%% End:\n", "meta": {"hexsha": "c0f23263837884c3e4ee846584b2ec4153a7e920", "size": 5279, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manual/Tutorial/theories.tex", "max_stars_repo_name": "dwRchyngqxs/HOL", "max_stars_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 492, "max_stars_repo_stars_event_min_datetime": "2015-01-07T16:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T22:18:48.000Z", "max_issues_repo_path": "Manual/Tutorial/theories.tex", "max_issues_repo_name": "dwRchyngqxs/HOL", "max_issues_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 759, "max_issues_repo_issues_event_min_datetime": "2015-01-01T00:40:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T17:33:39.000Z", "max_forks_repo_path": "Manual/Tutorial/theories.tex", "max_forks_repo_name": "dwRchyngqxs/HOL", "max_forks_repo_head_hexsha": "3b1931c130fcab243da332adb2c1413c42c59cf9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 126, "max_forks_repo_forks_event_min_datetime": "2015-02-17T03:20:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T00:42:55.000Z", "avg_line_length": 49.3364485981, "max_line_length": 71, "alphanum_fraction": 0.7671907558, "num_tokens": 1301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.7341195152660688, "lm_q1q2_score": 0.44335813456207007}}
{"text": "\\chapter{Conclusion}\n\nWe have introduced a new method to perform causal inference in the bivariate additive \nnoise model. The method is simple, and is different from ANM methods in that it \nexploits the residual directly rather than testing for independence between \nthe residual and input. This has the advantage of avoiding independence testing \nwhich is known to be hard. The drawback is that we assume that the noise is independent \nbetween each sample. The method is also theoretically sound as we were able to prove that \nit is consistent asymptotically. While it is not as good as state of the art, it is\ncompetitive: this shows that exploiting noise alone is also a viable \nline of attack to infer the causal direction in the ANM setting. \n\n\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n% TODODODODODODODODO\n\n% \\subsection{TODO stuff}\n\n% TODO (will remove this later, just as a reminder)\n% + unsupervised \n% + fast \n% + no independence test needed\n% + theoretically sound\n\n% - iid on Z assumption\n% - acc\n\n% TODO:\n\n% IGCI, at least mention a bit\n\n% Some observations:\n\n% While it could be $F(X, Z)$, often it might be $F(X, Z) + Z_2$ since there is often measurement error\n% so noise additivity is a good assumption. \n\n% Standardize residual notation! $e_x$...\n\n% Briefly discuss AIC / model selection\n% intution about using poly reg since it's local\n% aprox\n% https://stats.stackexchange.com/questions/9171/\n% aic-or-p-value-which-one-to-choose-for-model-selection\n\n", "meta": {"hexsha": "f2ff79377751ee1e6894e47aacf1b29791cef974", "size": 1619, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main/ch6_conclusion.tex", "max_stars_repo_name": "Nacho114/EPFL_thesis_template", "max_stars_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main/ch6_conclusion.tex", "max_issues_repo_name": "Nacho114/EPFL_thesis_template", "max_issues_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main/ch6_conclusion.tex", "max_forks_repo_name": "Nacho114/EPFL_thesis_template", "max_forks_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5471698113, "max_line_length": 103, "alphanum_fraction": 0.7714638666, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4433468887385288}}
{"text": "\n% Alek Westover writeup draft \n\n\\documentclass[twocolumn, twoside, 12pt]{article}\n\\author{\\vspace{-2ex}Alek Westover\\vspace{-2ex}}\n\\title{\\vspace{-8ex}Cache Efficient Parallel Partition\\vspace{-2ex}}\n\\date{\\vspace{-2ex}June 26, 2019\\vspace{-2ex}}\n\n\\renewcommand{\\thesubsection}{\\thesection.\\alph{subsection}}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\usepackage{amsfonts}\n\n\\usepackage{amsmath}\n% defines a new function\n\\def\\polylog{\\operatorname{polylog}}\n\\def\\pred{\\operatorname{pred}}\n\\def\\E{\\operatorname{\\mathbb{E}}}\n\n\\usepackage{mathtools}\n\\DeclarePairedDelimiter{\\floor}{\\lfloor}{\\rfloor}\n% \\floor*{\\frac{x}{y}} actually does a nice looking floor!\n\\DeclarePairedDelimiter{\\paren}{(}{)}\n% paren*{ } gives the correct size\n\\newcommand{\\defn}[1]       {{\\textit{\\textbf{\\boldmath #1}}}}\n\n\\renewcommand{\\paragraph}[1]{\\vspace{0.09in}\\noindent{\\bf \\boldmath #1.}} \n\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{algorithm, algpseudocode}\n\n%%%% Theorem stuff\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{proposition}{Proposition}\n\n\\begin{document}\n\\maketitle\n\\begin{abstract}\n\tThis is a modified version of the \"Algorithm Overview\" paragraph in the \"Analysis of Grouped Partition\" section of the other writeup that I am doing. \n\\end{abstract}\n\n\\paragraph{Algorithm Overview}\nWe now describe the \\defn{Grouped Partition} algorithm.\nWe logically divide the array $A = A[0],A[1],\\ldots, A[n-1]$ into blocks $P_j$ each of $b$ adjacent elements, where $b$ is the \\defn{block size}.\nNote that the $P_j$s are defined in a different way then in the Strided algorithm when $P_j$ contained elements spaced throughout the array.\nThis is equivalent to setting $|P_j| = 1$ for the $P_j$s in the Strided Algorithm and then making $P_j$ a collection of cache blocks.\nDefine \\defn{$\\pred(j)$} to be the number of predecessors in $P_j$.\nThere are $n/b$ of these blocks $P_j$.\n\nThe algorithm generates a random array $X=X[0],X[1],\\ldots,X[s-1]$ where each element in $X$ contains an integer chosen randomly at uniform from $[0,g-1]$, where $g$ is the number of groups.\nThe values in $X$ determine $g$ groups $G_0, G_1, \\ldots, G_{g-1}$ of $P_j$s.\nThe first group is \n\\begin{multline*}\n\tG_0 = \\{X[0], X[1]+g, X[2]+2\\cdot g,\\\\ \n\t\\ldots,X[s-1]+ (s-1)\\cdot g\\}.\n\\end{multline*}\nThis means that group $G_0$ is a collection of indices for specific parts $P_j$, indicating that these parts belong to group $G_0$. Similarly, group $G_y$ is defined as \n\\begin{multline*}\n\tG_y = \\{(X[0]+i) \\bmod g, (X[1]+i) \\bmod g + g, \\\\\n\t\\ldots, (X[s-1]+i) \\bmod g + (s-1)\\cdot g \\}.\n\\end{multline*}\nIntuitively this means that, for group $G_y$, on each chunk of size $g$ of the array, take $X[j]$ and add the group's index $i$ (wrapping around if there is overflow beyond the number of groups) to get to the index of the $P_j$ that belongs to group $G_y$ from this chunk of the array.\nNote that we do not need to store the indices of each $P_j$ that belongs to each group because between $X$ and the group index the $P_j$s that belong to the group $G_y$ are uniquely determined.\nWe call our algorithm in-place because the size $s$ of X is made $\\Theta(\\frac{\\log n}{\\delta^2})$, for $\\delta \\in (0, 1)$ of our choice, which is minuscule compared to the array of size $n$ that is an input to the partition problem.\n\nDefine $U_y$ to be the union of all parts that belong to group $G_y$, that is\n$$U_y = \\bigcup_{j\\in G_y} P_j.$$\nDefine $\\mu_y$ to be the number of predecessors in $U_y$ divided by the number of elements in $U_y$. This is analogous to the definition of $\\mu$: the number of predecessors in $A$ divided by $n$.\n\nOnce the algorithm has generated $X$, it performs a serial partition on each collection $U_y$ in parallel. \nAfter partitioning the collection $U_y$ the Grouped Partition algorithm stores the index $v_y$, which is the index in $A$ of the first successor in $G_y$, in array of size $s$.\nRecall that $s$ is small, and that the algorithm already created an array $X$ of size $s$, so this does not change the asymptotics for memory consumption of the algorithm.\nAfter the Grouped Partition algorithm finishes performing in parallel a serial partition of each group, the algorithm computes in serial $v_{min} =\\min v_y$, and $v_{max} = \\max{v_y}$ from the stored values $v_y$ generated by each serial partition.\nNote that we cannot just have a variable that all threads can write to that stores the current lowest $v_y$ and current highest $v_y$ and then overwrite this in each thread when it finishes its group as we would try in a serial algorithm because this would cause data races in the parallel algorithm.\nThus, because for all $y$ \n$$v_{min}\\leq v_{y} \\leq v_{max},$$\nwe can determine that all elements of $A$ with index less than $v_{min}$ are predecessors and elements of the array with index greater or equal to than $v_{max}$ are successors.\nThus, by recursing on the subarray $A[v_{min}],\\ldots,A[v_{max}-1]$, we complete the partitioning of the array.\nWe recursively apply the Grouped Partition algorithm to the subproblem.\nThe base case for the recursion is that when the algorithm can no longer make a substantial number of groups, in which case it partitions its input array in serial. \n\n\\end{document}\n", "meta": {"hexsha": "0c5c9f3f7c7069b2ffa6ef914cc1447e18a5783d", "size": 5233, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writeups/old_stuff/aleksOtherWritings/shortAlgDescription/shortAlgDescription.tex", "max_stars_repo_name": "AWestover/Parallel-Partition", "max_stars_repo_head_hexsha": "428dc19f399fe758d750ee30e1eb84fbd39531db", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-07-15T20:04:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-19T05:33:52.000Z", "max_issues_repo_path": "writeups/old_stuff/aleksOtherWritings/shortAlgDescription/shortAlgDescription.tex", "max_issues_repo_name": "awestover/Parallel-Partition", "max_issues_repo_head_hexsha": "428dc19f399fe758d750ee30e1eb84fbd39531db", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "writeups/old_stuff/aleksOtherWritings/shortAlgDescription/shortAlgDescription.tex", "max_forks_repo_name": "awestover/Parallel-Partition", "max_forks_repo_head_hexsha": "428dc19f399fe758d750ee30e1eb84fbd39531db", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.5647058824, "max_line_length": 300, "alphanum_fraction": 0.7366711255, "num_tokens": 1527, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.44334687914687365}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{graphicx}\n\\usepackage{natbib}\n\n\n\\title{Weekly Report}\n\\author{Junior Team }\n\\date{July 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Introduction}\n\n\\section{Scaling Cost}\nOne idea that was proposed was to scale the differences of angular velocities ($\\dot{\\theta}_{observed}$ and $\\dot{\\theta}_{predicted}$) in the cost function used in \\textit{fmincon}. The previous method did not account for units, and since the angular velocity changes were numerically much larger, they could dominate the optimization. In order to add a scale to our cost function, Dr. Posa suggested we use this formula:\n\\begin{gather}\ncost = \\frac{|| D *(v_{observed} - v_{predicted})||^2}{||D * v_{observed}||^2} \\\\[2ex]\nD = \n    \\left [\n        \\begin{array}{ccc}\n             1 & 0 & 0\\\\\n             0 & 1 & 0\\\\\n             0 & 0 & scale\\\\\n        \\end{array} \n    \\right ]\n\\end{gather}\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=0.15]{scaled.jpg}\n\\caption{Scaling $\\dot{\\theta}$ Differences for IRB}\n\\label{fig:scaled}\n\\end{figure}\n\n\\noindent As the figure above shows (Fig. \\ref{fig:scaled}), scaling theta dot in the updates cost function (Eq. 1) does not lower the error given by the original cost function. When Dr. Fazeli and his coauthors chose to base their error comparison on the normalized $l_2$ norm of velocity, they made an implicit choice on their definition of accuracy. Since we have been using Dr. Fazeli's data as well as referring mostly to his papers, we have also stuck to their cost function. Depending on the application of interest however, it may make sense to update the cost function to prioritize certain needs. Perhaps also, there is a better metric for judging the effectiveness of impact models. \n\n\\section{Nonzero Error for IRB with Width }\nFor quite some time, Dr. Posa has been asking us why some of our IRB plots with width still have significant error, Since we have three equations and three variables we are optimizing over, we should be able to get nearly 0 cost, as long as we aren't running into any major issues with the energy constraints. It turns out some of us had different settings in \\textit{fmincon} but once we all switched our step tolerance to $e^{-10}$ we were getting errors basically equal to zero (ignoring numerical and a few outliers). \\\\\n\n\\noindent When comparing our errors (Fig. \\ref{fig:wIRB}) with the plot from \\citet{nimaPaper} (Fig. \\ref{fig:cIRB}), the IRB with width's error is effectively zero compared to the classical IRB which has an expected error of 0.6. \n\n\\begin{figure}[ht]\n    \\caption{Comparison of Errors for IRB With and Without Width}\n    \\centering\n    \\begin{subfigure}[b]{0.45\\linewidth}\n        \\includegraphics[scale=0.45]{nima1.jpg}\n        \\caption{Classic IRB\\cite{nimaPaper}}\n        \\label{fig:cIRB}\n    \\end{subfigure}\n    \\quad\n    \\begin{subfigure}[b]{0.45\\linewidth}\n       \\includegraphics[scale=0.12]{errorWidth.jpg}\n        \\caption{IRB with Width}\n        \\label{fig:wIRB}\n    \\end{subfigure}\n\\end{figure}\n\n\n\\bibliographystyle{plainnat}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "6d8a22f8e8f4ed0ecf96be6eb7bbd95525648aeb", "size": 3201, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Weekly Reports/Weekly Report 705/main.tex", "max_stars_repo_name": "DAIRLab/ImpactModeling", "max_stars_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-19T21:01:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-02T08:56:34.000Z", "max_issues_repo_path": "Weekly Reports/Weekly Report 705/main.tex", "max_issues_repo_name": "DAIRLab/ImpactModeling", "max_issues_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Weekly Reports/Weekly Report 705/main.tex", "max_forks_repo_name": "DAIRLab/ImpactModeling", "max_forks_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T21:01:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T21:01:28.000Z", "avg_line_length": 47.0735294118, "max_line_length": 694, "alphanum_fraction": 0.7263355201, "num_tokens": 865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.4433355628874638}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 3, Section 1.3: 1-11 odd, 17-25 odd}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{1.}\n$ u =  \\begin{bmatrix} -1&2 \\end{bmatrix} $\n$ v =  \\begin{bmatrix} -3&-1 \\end{bmatrix} $\n\\subsection*{3.}\n$ u =  \\begin{bmatrix} -1&2 \\end{bmatrix} $\n$ v =  \\begin{bmatrix} -3&-1 \\end{bmatrix} $\n\\subsection*{5.}\n$3x_1 + 5x_2 = 2$\n$-2x_1 + 0x_2 = -3 $\n$8x_1 + -9x_2 = 8 $\n\\subsection*{7.}\n$a = u - 2v$\n$b = 2u - 2v $\n$c = 2u - 2.5v $\n$d = 3u - 4v$\n\\subsection*{9.}\n$ x_1 \\begin{bmatrix} 0&4&-1 \\end{bmatrix} + x_2 \\begin{bmatrix} 1&6&3 \\end{bmatrix} + x_3 \\begin{bmatrix} 5&-1&-8 \\end{bmatrix} = \\begin{bmatrix} 0&0&0 \\end{bmatrix}  $\n\n\\subsection*{11.}\nThe linear system corresponding to M has a solution so 1 has a solution and b is therefore a linear combination of $a_1, a_2$ and $a_3$.\n\\subsection*{17.}\nThe weights are 1 and -1\n\\subsection*{19.}\nIf $v_1$ and $v_2$ are nonzero vectors then $Span \\{v_1, v_2\\}$ for the given vectors is the set of points on a line through $v_1$ and $0$.\n\\subsection*{21.}\nThe matrix corresponds to a consistent system for all $h$ and $k$, so $y$ is in Span of $\\{u,v\\}$\n\\subsection*{23.}\nSpan $\\{u,v\\}$ = span $\\{u\\}$\n\\subsection*{25. A)}\nThere are only three vectors in the set of columns $\\{a_1, a_2, a_3\\}$ in $A$ and $b$ is not one of them. \n\\subsection*{25. B)}\nThere are infinitely many vectors in $W = Span \\{a_1, a_2, a_3\\}$\n\\subsection*{25. C)}\n$a_1$ is in $W$.\n\n\n\n\\end{document}", "meta": {"hexsha": "3e455c5a00dca7bdc865d91d473decf0a699a0e3", "size": 1819, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LinearAlgebra/Homework3.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LinearAlgebra/Homework3.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LinearAlgebra/Homework3.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8305084746, "max_line_length": 169, "alphanum_fraction": 0.6481583288, "num_tokens": 784, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.4433355590853519}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{textcomp}\n\\usepackage[english]{babel}\n\\usepackage{amsmath, amssymb}\n\\usepackage{physics}\n\\usepackage{isomath}\n\\usepackage{listings}\n\n\n% figure support\n\\usepackage{import}\n\\usepackage{xifthen}\n\\pdfminorversion=7\n\\usepackage{pdfpages}\n\\usepackage{transparent}\n\\newcommand{\\incfig}[1]{%\n\t\\def\\svgwidth{\\columnwidth}\n\t\\import{./figures/}{#1.pdf_tex}\n}\n\n\\DeclareMathSymbol{\\C}{\\mathalpha}{AMSb}{\"43}\n\\DeclareMathSymbol{\\R}{\\mathalpha}{AMSb}{\"52}\n\n\\pdfsuppresswarningpagegroup=1\n\\title{EE 636 - Matrix Computations}\n\\begin{document}\n\\section{Introduction}\nThe following are course notes made during the live lectures of\nEE 636, taken by Prof. Debasattam Pal (Spring 2021)\n\\textbf{Logistics}\n\\begin{itemize}\n\t\\item Google Classroom - join codes shared on Moodle\n\t\\item login to classroom regularly to check for assignments, announcements\n\t\\item live lectures\n\t\\item do not rely on the lectures being recorded\n\\end{itemize}\n\\textbf{Reference books}\n\\begin{itemize}\n\t\\item David Watkins - Matrix Computations (Main)\n\t\\item Golub - Matrix Compuations\n\\end{itemize}\n\\textbf{Grading Policy}\n\\begin{itemize}\n\t\\item TA Proctored quizes - 20\\%\n\t\\item Midsem - 20\\%\n\t\\item Endsem - 40\\%\n\t\\item Assignments - 10\\%\n\t\\item TakeHomeExam/viva/project/coding - 10\\%\n\\end{itemize}\n\nTake home exams will be significantly harder than assignments, which\nwill be standard problems. Deadlines will be stricter for take-home-exams.\n\nLearning more about HPC in specific will require you to look into\ntopics that are beyond the scope of the course, but are in the\nreference book.\n\nAs such the main aim of this course is to learn what happens behind\nthe scenes when we call library functions and learn how to write\nbetter code. \\textbf{It is important that we understand when the result\nof a computation can be trusted or not.} We will see when a computer\nis prone to make errors. It has something to do with the condition \nnumber of the matrix.\n\nCondition number is defined as\n\\[\n\tK_2(A) = {\\norm{A}_2}{\\norm{A^{-1}}_2}\n.\\] \n\nWe will spend a lot of time seeing how to solve $Ax = b$. We might\nnot look at specific examples, but the content covered will apply\nmore or less directly in some use cases e.g. image processing.\n\nStarting off with a small simple assignment, to be submitted before\nthe next lecture.\n\\textbf{Assignment}\n\\begin{itemize}\n\t\\item Go through the syllabus\n\t\\item Write briefly about a problem (from your area of expertise) that needs knowledge from any of the syllabus topics\n\t\\item Feel free to come up with multiple examples. The more examples $\\implies$ more credits.\n\t\\item Submission due by next Monday (11th Jan)\n\t\\item To be submitted on the classroom\n\t\\item submission format \\texttt{.pdf}\n\\end{itemize}\n\nProfessor asked us here what exactly are we looking for in this course.\nSome answers were given by students. The main purpose of this course\nis to understand what happens behind the scenes when we call linalg\nlibrary functions, and consequently understand whether a particular\ncomputation is trustworthy or not.\n\n\\subsection{Types of Problems in Matrix Computations}\n%%%%% TODO: reformat, resolve TODOs.\n\\subsubsection{$\\mathrm{A}\\vec{x} = \\vec{b}$}\nwhere we solve for $x$, where $A \\in \\mathbb{R}^{m\\times n}\n\t\t,b \\in  \\mathbb{R}^{m}\n\t\t,x \\in \\mathbb{R} ^{n}$. Also, note that $\\R^{n} = \\R^{n\\times 1}$.\n\n\\subsubsection{$\\text{argmin}_{\\vec{x}}\\norm{\\mathrm A \\vec{x} - \\vec{b}}$}\n\tSometimes we cannot find solve for $\\vec{x}$ exactly, in which\n\tcase we would like to minimize some norm of the above kind.\n\\subsubsection{$\\mathrm a \\vec{x}= \\lambda \\vec{x}$}\nHere we need to solve for both $\\vec{x}$ and $\\lambda$. This is a\nvery important class of problems and also not straightforward. The\ncharacteristic equation to be solved is\n\\begin{equation}\\label{chareq}\n\t\\left| \\mathrm A - \\lambda \\mathbb{1} \\right|  = 0\n\\end{equation}\nAnd then we have the older problem of finding $\\vec{x}$, the eigenvectors.\nThe equation \\ref{chareq} is basically finding the roots of a polynomial,\nwhich is very nontrivial ($\\because$ in general there is no closed\nform for degrees $\\ge 5$, as shown by Henry Abel.)\n\nSomething called the QR algorithm can find both eigvals and eigvecs\nin one shot.\n\n\\subsubsection{$\\mathrm A \\vec{u} = \\mathrm \\sigma \\vec{v}$}\n$\\mathrm A$ is known, the rest are unknown. And\n\\begin{align}\n\t&\\vec{u_1}\\quad \\vec{u_2}\\ldots\\vec{u_n} \\\\\n\t&\\vec{v_1}\\quad \\vec{v_2} \\ldots \\vec{v_m} \\\\\n\t&\\vec{u_i}\n\\end{align}\n\\begin{itemize}\n\t\\item Singular value decomposition\n\t\\item \n\\end{itemize}\n\nQuestions that we are concerned with, given some problems\n\\begin{itemize}\n\t\\item How does a computer solve them?\n\t\\item How trustworthy are the solutions?\n\t\\item How efficient are the algorithms?\n\\end{itemize}\n\nSomething was said about the etymology of the word ``algorithm\". The\nprof then talks about the Caesar cypher. \n\nThe letter ``E\" is used most often in English. If you have a very\nlarge encrypted text, you could find the Caesar cypher key by\nfinding the most frequent letter in the encrypted text. Pretty neat\nhuh.\n\nThe enigma machine would randomly choose a key every day and the\ndecoder machine could automatically figure out the key from the\nencrypted text.\n\nLet's get down to computations and all. What does a computer do when\nyou tell it to $\\mathrm{A}\\vec{x} = \\vec{b}$.\n \\begin{equation}\n\t \\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ldots &a_{1n} \\\\\n\t a_{21} & a_{22} & a_{23} \\ldots &a_{2n}\\\\\n\t \\hdotsfor{4} \\\\\n\t a_{m1} & a_{m2} & a_{m 3} \\ldots &a_{mn}\n \\end{bmatrix} \n \\begin{bmatrix} x_1\\\\ \\vdots\\\\ x_n \\end{bmatrix}\n\\end{equation}\n\nInternally, it computes something like\n\\begin{equation}\n\t\\begin{pmatrix} \\sum_{i=1}^{n} a_{1i}x_i\\\\ \\vdots\\\\ \\sum_{i=1}^{n} a_{mi}x_i \\end{pmatrix}\n\\end{equation}\n%%%% TODO: spent too much time figuring out the matrix snippets. Complete this part\n\n\\textbf{Task:} Compute the number of tasks required in matrix vector\nmultiplication. Here, task means FLOP. So, find the number of FLOP.\nProve that rowwise FLOP $= 2mn$ and columnwise FLOP $= 2mn$ and \n$\\mathrm{A}\\vdot B$ FLOP $= 2mnp$\n\n\\section*{Summary}\nThe purpose of this course is to \n\\begin{itemize}\n\t\\item learn how a computer can solve\nthe four types of problems mentioned a\n\t\\item Effect of round-off errors \n\t\\item When can a solution be trusted\n\t\\item FLOPS to measure computation time\n\t\\item Counted the FLOPS for basic matrix multiplication: $2mn$ for a matrix of size $m\\times n$ and a vector of dim $n$.\n\\end{itemize}\n\n\\section*{Solvinig a linear system of linear equations}\n\\subsection*{Triangular Matrix}\n\\begin{equation}\n\t\\mathrm{A}\\vec{x} = \\vec{b}\n\\end{equation}\nwhere $\\mathrm A \\in \\R^{m \\times  n}$, $b \\in  \\R^{n}$. The first\nstep to learning how to solve such problems is learning about\ntriangular matrix. Consider the following system with a lower\ntriangular matrix\n\\begin{equation}\n\t%%%%% TODO: Complete\n\t\\begin{bmatrix} l_{11} & 0 & 0 & \\ldots & 0\\\\\n\t\tl_{21} & l_{22} & 0 & \\ldots & 0 \\\\\n\t\tl_{31} & l_{32} & l_{33} & \\ldots & 0\\\\\n\t\\hdotsfor{5} \\\\  \n\tl_{n 1} & l_{n 2} & l_{n 3} &\\ldots & l_{nm} \\end{bmatrix}\n%\t\\begin{bmatrix}  \\end{bmatrix} %%%% TODO\n\\end{equation}\n\n\\lstinputlisting{listings/ltr.c}\n\nFor the above algorithm (\\emph{forward substitution}), FLOPS $= n(n-1) + n = n^2$.\nInnermost loop has $2(k-1)$ FLOPS. The loop is called $n$ times for\n$k = 1,2,\\ldots n$. There is another division operation after a whole\npass over the the inner loop. So, we have $n + \\sum_{j=1}^{n} a_n z^n$ TODO. %%% TODO\n\nIn general, we can have a column-oriented algorithm for a row-oriented\noperation. The corresponding algo is called \\emph{backward substitution}. \nFLOPs will be the same as the row-oriented business.\n\n\\subsection*{The question of solvability}\nIn real life we do not really get such nice looking lower-triangular\nor upper triangular matrices. Consider the following theorem\n\n\\textbf{Theorem:} Let $\\mathrm A \\in \\R^{n\\times n}$ and $b \\in  \\R^{n}$ be given. Then the following are equivalent\n\\begin{enumerate}\n\t\\item $\\mathrm A \\vec{x}= \\vec{b}$ has a unique solution\n\t\\item $\\mathrm A^{-1}$ exists\n\t\\item $\\text{det} A \\neq 0$ \n\t\\item The rows of $\\mathrm A$ are linearly independent\n\t\\item The columns are linearly independent\n\t\\item $\\mathrm A\\vec{y} = 0 \\iff y = 0$\n\\end{enumerate}\nHow do we prove $1 \\implies 2$? (Notation: $\\vec{e_i}$ are the unit vectors).\n$\\vec{b} = \\sum_{j=1}^{n} a_j\\vec{e_j}$ And $\\vec{x} = \\sum_{j=1}^{n} x_i \\vec{e_i}$\n\n\\[\n\t\\mathrm A \\vec{x} = \\sum_{i=1}^{n} x_i \\mathrm{A}\\vec{e_i}\n.\\] \nLOL IDK what I am doing. %%%% TODO: write full proof\n\n\\subsection*{Gaussian Elimination}\nYou know what Guassian elimination is from MA 214. Summarizing\nna\\\"ive Gaussian elimination here. We use elementary transformation\n$\\mathrm{E}$ to reduce $\\mathrm{A}$ to an upper triangular form\nand solve then use backward substitution.\n\n\\begin{equation}\n\t\\label{step_1}\n\t\\begin{split}\n\t\\begin{bmatrix} \n\t1 & 0 & 0 & \\ldots & 0\\\\\n\t-m_{21} & 1 & 0 & \\ldots & 0\\\\\n\t-m_{31} & 0 & 1 & \\ldots & 0 \\\\\n\t\\hdotsfor{5}\\\\\n\t-m_{n 1} & 0 & 0 & \\ldots & 1\\end{bmatrix}\n\t\\begin{bmatrix}\n\ta_{11} & a_{12} & a_{13} & \\ldots & a_{1n}\\\\\n\ta_{21} & a_{22} & a_{23} & \\ldots & a_{2n}\\\\\n\ta_{31} & a_{32} & a_{33} & \\ldots & a_{3 n}\\\\\n\t\\hdotsfor{5}\\\\\n\ta_{n_1} & a_{n 2} & a_{n 3} & \\ldots & a_{n n}\\end{bmatrix} \\\\\n\t= \\begin{bmatrix} \n\ta_{11} & a_{12} & a_{13} & \\ldots & a_{1 n}\\\\\n\t0 & a_{22}^{(1)} & a_{23}^{(1)} & \\ldots & a_{2 n}^{(1)}\\\\\n\t0 & a_{32}^{(1)} & a_{33}^{(1)} & \\ldots a_{3 n}^{(1)}\\\\\n\t\\hdotsfor{5}\\\\\n\t0 & a_{n2}^{(1)} & a_{n 3}^{(1)} &\\ldots & a_{n n}^{(1)}\n\\end{bmatrix}\n\t\\end{split}\n\\end{equation}\nwhere\n\\begin{equation}\n\tm_{j 1} = \\frac{a_{j1}}{a_{1 1}}, \\quad a_{j 1} \\neq  0\n\\end{equation}\n\nThis completes one step of procuring an upper triangular matrix. The\nnext step proceeds by pre-multiplying a similar elementary transformation\nmatrix to equation (\\ref{step_1})\n\\begin{equation}\n\t\\label{step_2}\n\t\\begin{split}\n\t\t\\begin{bmatrix} \n\t1 & 0 & 0 & \\ldots & 0\\\\\n0 & 1 & 0 & \\ldots & 0\\\\\n0 & -m_{32} & 1 & \\ldots & 0\\\\\n\\hdotsfor{5}\\\\\n0 & -m_{n 2} & 0 & \\ldots & 1\n\\end{bmatrix}\n\\begin{bmatrix}  \n\ta_{11} & a_{12} & a_{13} & \\ldots & a_{1 n} \\\\\n\t0 & a_{22}^{(1)} & a_{23}^{(1)} & \\ldots & a_{2 n}^{(1)}\\\\\n\t0 & a_{32}^{(1)} & a_{33}^{(1)} & \\ldots & a_{3 n}^{(1)}\\\\\n\t\\hdotsfor{5}\\\\\n\t0 & a_{n 2}^{(1)} & a_{n 3}^{(1)} & \\ldots & a_{n n}^{(1)} \n\\end{bmatrix} \t\\\\\n= \\begin{bmatrix} \n\ta_{11} & a_{21} & a_{13} & \\ldots & a_{1 n} \\\\\n0 & a_{22}^{(1)} & a_{23}^{(1)} & \\ldots & a_{2n}^{(1)}\\\\\n0 & 0 & a_{33}^{(2)} & \\ldots & a_{3 n}^{(2)}\\\\\n\\hdotsfor{5}\\\\\n0 & 0 & a_{n 3}^{(2)} & \\ldots & a_{n n}^{(2)}\\end{bmatrix} ,\n\t\\end{split}\n\\end{equation}\nwhere\n\\begin{equation}\n\tm_{j 2} = \\frac{a_{j2}^{(1)}}{a_{2 2}^{(1)}}.\n\\end{equation}\n\nYou can see the upper triangular matrix forming. In general, we\nhave \n\\begin{equation}\n\t\\label{mij}\n\tm_{ij} = \\frac{a_{ij}^{(j-1)}}{a_{jj}^{(j-1)}}.\n\\end{equation}\n\nSo, Gaussian elimination is basically the process\n\\begin{equation}\n\tE_{n-1}E_{n-2}\\ldots E_2E_1A = \\overline{A}\n\\end{equation}\nwhere $\\overline{A}$ is an upper-triangular matrix. The product\n$E_{n -1}E_{n-2}\\ldots E_2E_1$ ends up being an upper triangular matrix.\n\n\\subsubsection*{When can we proceed with Gaussian elimination?}\nOf course, we would like to have $a_{jj}^{(j-1)}$ is non-zero.\nElse there will be singularieites as seen in (\\ref{mij}).\n\nOf course, checking those values after each step sounds\nvery inefficient. An equivalent condition is - given $A$, we check\nif all of $A_1, A_2, \\ldots, A_{n}$ are all invertible, where\n\\[\n\tA_k = A(1:k, 1:k)\n\\] \nis the $k\\times k$ upper left submatrix of $A$. Formal proof ditch,\nwe could look at some informal arguments. Consider  $ k = 1$.\n$A_1$ is invertible $\\implies a_{11} \\neq  0$. This could be our base\ncase.\n\nNow, the most important point here is that $\\text{det}A_k \\forall k$ \nis invariant under elementary transformations.\nAt step $j$, we already have the upper left $k-1 \\times  k-1$ matrix\nis upper triangular. It can be easily shown that the next elementary\noperation would create a $j \\times  j$ upper triangular matrix.\n\nAlso, the \n\n\\input{lec09.tex}\n\\end{document}\n", "meta": {"hexsha": "a8337e43f2c1b3e1709eaa81f293999f06da5ff1", "size": 12156, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "matcomp/lec/main.tex", "max_stars_repo_name": "loonatick-src/sem-8", "max_stars_repo_head_hexsha": "956d4bfcaed74f1b4751d83303e1769f699814f8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "matcomp/lec/main.tex", "max_issues_repo_name": "loonatick-src/sem-8", "max_issues_repo_head_hexsha": "956d4bfcaed74f1b4751d83303e1769f699814f8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "matcomp/lec/main.tex", "max_forks_repo_name": "loonatick-src/sem-8", "max_forks_repo_head_hexsha": "956d4bfcaed74f1b4751d83303e1769f699814f8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.5438596491, "max_line_length": 121, "alphanum_fraction": 0.6926620599, "num_tokens": 4157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.44325003697267823}}
{"text": "\\chapter{Theoretical Framework}\n\\section{Sequential Decision Making}\nIn robotics, sequential decision-making problems refer to tasks in which a robot must achieve a goal by interacting with the world as a consequence of decisions that are made sequentially, for example, navigating from one point to another, grasping an object, balancing, etc. It can be described as a step-by-step decision process, where depending on the information that is gathered by its sensors, the robot has to make decisions consecutively.\n\n\\subsection[Markov Decision Process]{Markov Decision Process (MDP)}\nA Markov Decision Process (MDP) is meant to be a straightforward framing of sequential decision-making problems \\cite{puterman2014markov, sutton2018reinforcement}. In an MDP we have an \\emph{agent} that is continually interacting with an \\emph{environment}. The agent is the learner and the decision maker. The environment is everything that the agent can interact with. In robotics, the agent is the robot and the environment is the real world setting in which the robot exists.\n\nTo keep things as simple as possible, MDPs are commonly modeled as discrete time interaction of the agent with the environment \\cite{sutton2018reinforcement}. Thus, the time is divided into a sequence of \\emph{time steps}, $t=0,1,2,3,...$ . At each time step the agent perceives an \\emph{observation} $o_{t}$ of the environment, which is a representation of the environment's \\emph{state} $s_{t}$. Depending on the state, the agent selects an \\emph{action} $a_{t}$, which will ideally lead to a specific task being solved. \n\nThe state describes the current situation of the environment; the action is an input to the environment that the agent can select and that affects the environment's evolution. In robotics, this is information gathered with sensors such as RGB cameras, encoders, inertial measurement units, etc. If the observation contains sufficient information such that the agent can see the entire state of the environment, then the problem is said to be \\emph{fully observed} (or fully observable); otherwise, it is said to be \\emph{partially observed} (or partially observable). If a partially observed problem is modeled as a sequence of interactions between the agent and the environment, then is called a partially observable MDP (POMDP) \\cite{kober2013reinforcement}.\n\nThe environment's evolution is the sequence of states visited by the agent. Transitioning from one state to another is a stochastic process defined by the nature of the environment and the actions taken, at each time step, by the agent. Additionally, an MDP is a process that satisfies the Markov property \\cite{sutton2018reinforcement}. Consequently, the conditional probability distribution of future states depends only upon the present state, such that:\n\n\\begin{equation}\n    p(s_{t}|s_{t-1}, a_{t-1}) = p(s_{t}|s_{t-1},...,s_{0},a_{t-1},...,a_{0})  \\hspace{0.5cm} \\forall t\n\\end{equation}\n\nFinally, every time the agent executes an action, a numerical \\emph{reward} is received by the agent. Better decisions will produce higher cumulative rewards.\n\nIn a nutshell, an MDP can be defined by the tuple $MDP=(\\mathcal{S},\\matchcal{A},\\mathcal{R},\\mathcal{P})$, where $\\mathcal{S}$ represents the state space and $\\mathcal{A}$ the action space. $\\mathcal{R}$ represents the \\emph{reward function}, which generates a scalar reward $r$ every time step. This reward may depend on $s_{t-1}$; $s_{t-1},a_{t-1}$ or $s_{t-1},a_{t-1},s_{t}$, so $\\mathcal{R}$ can be defined with $\\mathcal{R}: \\mathcal{S} \\to \\R$, $\\mathcal{R}: \\mathcal{S} \\times \\mathcal{A} \\to \\R$ or $\\mathcal{R}: \\mathcal{S} \\times \\mathcal{A} \\times \\mathcal{S} \\to \\R$, respectively. Finally, $\\mathcal{P}$ corresponds to the transition function, which is the probability $p(s_{t+1}|s_{t}, a_{t})$, where $\\mathcal{P}: \\mathcal{S} \\times \\mathcal{A} \\times \\mathcal{S} \\to [0, 1]$. Graphically, an MDP can be summarized in the following diagram:\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.6\\linewidth]{imagenes/cap1/mdp.pdf}\n    \\caption{Finite part of a Markov Decision Process.}\n    \\label{fig:msim}\n\\end{figure}\n\n\\section[Reinforcement Learning]{Reinforcement Learning}\nReinforcement Learning aims to use the MDP framing of sequential decision-making problems so that agents learn to solve tasks from \\emph{experience} \\cite{sutton2018reinforcement}. In this case, experience is understood as the agent-environment interaction (see Figure \\ref{fig:agent-environment}), which results in the generation of reward values that indicate the quality of the decisions made by the agent. \n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.7\\linewidth]{imagenes/cap1/agent_environment.pdf}\n    \\caption{The agent-environment interaction.}\n    \\label{fig:agent-environment}\n\\end{figure}\n\nThe idea is to use this experience to learn a \\emph{policy} that maximizes the total amount of reward the agent receives \\cite{sutton2018reinforcement}. A policy $\\pi$ is a function that maps states into actions. This mapping can be either deterministic $\\pi: \\mathcal{S} \\to \\mathcal{A}$ or stochastic $\\pi: \\mathcal{S} \\times \\mathcal{A} \\to [0,1]$. To obtain a good performing policy, it is necessary to adequately combine \\emph{exploration} with \\emph{exploitation}. When exploring, the agent finds more information about the environment; when exploiting, it exploits known information to maximize the reward.\n\nCommonly, in complex problems, $\\pi$ is a parameterized model; then, the goal of reinforcement learning is to find the set of parameters $\\theta$ that maximizes the sum of rewards, or \\emph{return} $G$, that the agent will obtain when solving a task. As a consequence of the parameterized policy $\\pi_{\\theta}$, the agent will follow a trajectory $\\tau = \\{s_{0}, a_{0},...,s_{T}, a_{T}\\}$, where $T$ is the number of time steps. When a problem has well-defined initial and final conditions it has a \\emph{finite horizon} (the trajectory generated between the initial and final conditions is called \\emph{episode}), otherwise, it has an \\emph{infinite horizon} \\cite{sutton2018reinforcement, kober2013reinforcement}. In the former, $T \\in \\N$; in the later, $T \\to \\infty$. Finally, $\\tau$ follows the probability distribution $p_{\\theta}(\\tau)$ that depends on $p(s_{t+1}|s_{t}, a_{t})$, $\\pi_{\\theta}$ and $p_{0}=p(s_{0})$, which corresponds to the initial distribution of states.\n\nWith the above formulation, the goal of reinforcement learning is to \\textbf{maximize the expected return} of a given task such that:\n\n\\begin{equation}\n    J = E_{\\tau \\sim p_{\\theta}(\\tau)} \\left[\\sum_{t=0}^{T}r(s_{t}, a_{t})\\right]\n\\end{equation}\n\n\\begin{equation}\n    \\theta^{*} = \\argmax_{\\theta}J(\\theta)\n\\label{eq:objective}\n\\end{equation}\n\nIt can be observed that in the infinite horizon case, this definition can be numerically unstable and have divergence problems. To address this, the term $\\gamma \\in [0, 1)$, known as discount rate, can be introduced to construct a formulation of the goal with \\emph{discounted rewards} \\cite{sutton2018reinforcement, kober2013reinforcement}:\n\n\\begin{equation}\n    J = E_{\\tau \\sim p_{\\theta}(\\tau)} \\left[\\sum_{t=0}^{T}\\gamma^{t}r(s_{t}, a_{t})\\right]\n\\end{equation}\n\nWhere $\\gamma$ allows to control the horizon in which the agent maximizes the reward. This rate determines the present value of a reward received in the future, where immediate rewards are worth more than those received later.\n\n\\subsection{Learning Policies}\n\nUnder this framework, there are different approaches for learning policies \\cite{sutton2018reinforcement, kober2013reinforcement}:\n\n\\begin{itemize}\n    \\item Value-Based\n    \\item Policy Search\n    \\item Actor-Critic\n\\end{itemize}\n\nIn \\textbf{Value-Based} approaches, the policy is learned implicitly by learning a \\emph{value function} parameterized by the weights vector $\\theta$. This function estimates the expected return of the agent for every state, or in other words, how good is to be in a given state. The value for a given state will depend on the the agent's policy, thus, the value function can be written as:\n\n\\begin{equation}\n    V^{\\pi}(s_{t'})  = E_{\\tau' \\sim p_{\\theta}(\\tau')}\\left[\\sum_{t=t'}^{T}\\gamma^{t}r_{t}(s_{t}, a_{t})|s_{t'}\\right]\n\\end{equation}\n\nWhere $\\tau'$ is the trajectory followed by the agent starting from time step $t'$.\n\nSimilarly, the value of taking the action \\emph{a} in the state \\emph{s} can be estimated by a function, which is called the \\emph{action-value function}:\n\n\\begin{equation}\n    Q^{\\pi}(s_{t'}, a_{t'})  = E_{\\tau' \\sim p_{\\theta}(\\tau')}\\left[\\sum_{t=t'}^{T}\\gamma^{t}r_{t}(s_{t}, a_{t})|s_{t'},a_{t'}\\right]\n\\end{equation}\n\nThe main idea is to find a policy $\\pi^{*}$, the \\emph{optimal policy}, such that:\n\n\\begin{equation}\n    V^{\\pi^{*}}(s) \\geq V^{\\pi}(s) \\hspace{0.5cm} \\forall s, \\pi\n\\end{equation}\n\n\\begin{equation}\n    Q^{\\pi^{*}}(s,a) \\geq Q^{\\pi}(s,a) \\hspace{0.5cm} \\forall s,a,\\pi\n\\end{equation}\n\nIf these conditions are met, then, the optimal vector of weights $\\theta^{*}$ is obtained. On the other hand, \\textbf{Policy Search} approaches update $\\theta$ by direct policy differentiation. In this case, the challenge is to estimate the gradient of $J(\\theta)$ to update $\\theta$ iteratively, using gradient ascent:\n\n\\begin{equation}\n    \\Delta \\theta = \\alpha \\nabla_{\\theta}J(\\theta)\n\\end{equation}\n\n\\begin{equation}\n    \\theta \\leftarrow \\theta + \\Delta \\theta\n\\end{equation}\n\nWhere $\\alpha$ is the learning rate.\n\nFinally, \\textbf{Actor-Critic} approaches combine Value Based and Policy Search methods. A policy (actor) and a value function (critic) are explicitly learned. In this case, the actor decides the action that the agent should take while the critic observes its performance and decides when the policy needs to be updated and how. Figure \\ref{fig:rl_summ} summarizes these RL approaches:\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.5\\linewidth]{imagenes/cap1/rl_summary.pdf}\n    \\caption{Reinforcement Learning methods.}\n    \\label{fig:rl_summ}\n\\end{figure}\n\nIndependently of the technique that is used to solve a problem with Reinforcement Learning, the anatomy of these algorithms is always the same: obtain experience (generate samples), fit a model (or estimate a return), improve the policy and repeat (see Figure \\ref{fig:RL_anatomy}). \n\n\\begin{itemize}\n    \\item \\textbf{Generate samples:} obtain $n$ transitions. A transition is the tuple $(s_{t}, a_{t}, r_{t+1}, s_{t+1})$, which can also be written as $(s, a, r, s')$.\n    \\item \\textbf{Fit a model:} use the gathered samples to improve the estimation of a value function or to estimate $\\nabla_{\\theta} J(\\theta)$.\n    \\item \\textbf{Improve the policy:} use the estimated value function to obtain a policy or $\\nabla_{\\theta} J(\\theta)$ to update $\\theta$.\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.45\\linewidth]{imagenes/cap1/RL_anatomy.pdf}\n    \\caption{Anatomy of Reinforcement Learning.}\n    \\label{fig:RL_anatomy}\n    \\vspace{-0.3cm}\n\\end{figure}\n\n\\subsubsection{Model-Free vs Model-Based}\n\\vspace{-0.3cm}\nReinforcement Learning approaches may be either Model-Free or Model-Based \\cite{sutton2018reinforcement, kober2013reinforcement}.\n\n\\textbf{Model-Free} algorithms learn a policy directly from experience. The dynamics of the environment are not directly learned.\n\n\\textbf{Model-Based} algorithms learn a \\emph{model} of the dynamics of the environment from experience. Then, planning or optimal control techniques are applied to develop a policy using the model.\n\nA model of the environment is a function $M: \\mathcal{S} \\times \\mathcal{A} \\to \\mathcal{S}$ that predicts the next state as a function of the current state and action to take:\n\\vspace{-0.02cm}\n\\begin{equation} \\label{eq:model}\n    M(s_{t},a_{t}) = s_{t+1}  \n\\end{equation}\n\\vspace{-0.02cm}\nor, in the stochastic case, $M: \\mathcal{S} \\times \\mathcal{A} \\times \\mathcal{S} \\to [0, 1]$:\n\\vspace{-0.02cm}\n\\begin{equation}\n    M(s_{t},a_{t}) = p(s_{t+1}|s_{t},a_{t})  \n\\end{equation}\n\nFigure \\ref{fig:free_based_model} summarizes the difference between both approaches:\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.5\\linewidth]{imagenes/cap1/free_based_model.pdf}\n    \\caption{Model-Free vs Model-Based.}\n    \\label{fig:free_based_model}\n\\end{figure}\n\n\\subsubsection[Experience Replay]{Experience Replay}\n\\label{sss:ER}\n\nThe anatomy of Reinforcement Learning (Figure \\ref{fig:RL_anatomy}) suggests that every time the policy is improved, obtaining new samples is necessary to improve it again. This is only true in $\\text{\\emph{on-policy}}$ algorithms \\cite{sutton2018reinforcement}. On-policy algorithms are those in which a policy can only be updated with data gathered by itself. Data gathered before the last update corresponds to data gathered by a past version of the current policy; thus, gathered by a different policy. So if the policy is changed, even a little bit, generating new samples becomes necessary. \n\nIn contrast, \\emph{off-policy} algorithms are able to improve a policy without the aforementioned restriction \\cite{sutton2018reinforcement}; thus, using samples collected by other policies or by past versions of itself. Under this context is where is useful to use an \\emph{experience replay} \\cite{lin1993reinforcement,atari}.\n\nThe key idea of experience replay is to store old transitions $(s, a, r, s')$ in a buffer (or memory buffer) and replay them constantly (randomly sampling a mini-batch) when updating a policy. Using experience replay has two advantages: (1) the data/samples are uncorrelated and (2) data efficiency is significantly improved \\cite{zhang2017deeper}:\n\n\\begin{itemize}\n    \\item \\textbf{Uncorrelated samples:} every sequential decision-making problem has the issue that the data generated when exploring the environment is correlated. If the data is correlated, then, every time the policy is updated, this will be with respect to a sequence, or various sequences. In some cases this is problematic because models may locally overfit to this data, constantly forgetting older experiences. This issue can be tackled by randomly sampling from a memory buffer.\n    \n    \\item\\textbf{Data efficiency:} depending on the the parameterized model of $\\pi_{\\theta}$, it may not be efficient to update its parameters with a set of samples just once. To successfully extract all the information contained in the samples, it would be necessary to update the model several times from them. This is achieved when using experience replay.\n\\end{itemize}\n\n\\section[Function Approximation]{Function Approximation}\nAlthough $\\pi$ can be represented by a look-up table, where every state has a corresponding action stored in a table, this representation is not scalable to complex problems with large state/action spaces. This is mainly because the states and/or actions are too many to be stored in memory and/or it would take too long to adequately explore the states. Thus, in robotics contexts, where state/action spaces are most likely continuous, the standard approach is to use function approximation \\cite{kober2013reinforcement}. As mentioned before, this means that the policy is a parameterized model $\\pi_{\\theta}$.\n\nThere is a large list of different function approximators \\cite{sutton2018reinforcement, kober2013reinforcement}, but in this work two of them are the most relevant: \\textbf{linear models of basis functions (LCBFs)} \\cite{busoniu2010reinforcement} and \\textbf{artificial neural networks (ANNs)} \\cite{goodfellow2016deep, nielsen2015neural}. Although the policy may not be directly represented by these models, as in the case of value function approximation, for simplicity, from now on we are going to assume that it always does. Also, we are only going to work with deterministic policies. So, if the function approximator is $\\Psi$, then $\\pi_{\\theta} = \\Psi(s;\\theta)$ such that $\\Psi: \\mathcal{S} \\to \\mathcal{A}$.\n\n\\subsection[Linear Model of Basis Functions]{Linear Model of Basis Functions}\nA well-known case of function approximation in RL is that in which $\\pi_{\\theta}$ is a linear function of the weight vector $\\theta$. Specifically, we are going to work with linear combinations of gaussian radial basis functions (RBFs) \\cite{busoniu2010reinforcement}. If $\\phi(s)$ corresponds to a vector of basis functions which is weighted by $\\theta$, then $\\pi_{\\theta}$ can be represented as:\n\n\\begin{equation}\n    \\pi_{\\theta}(s) = \\phi(s) \\cdot \\theta\n    \\label{eq:lcbf}\n\\end{equation}\n\nIn this case, $\\phi(s)$ corresponds to normalized gaussians:\n\n\\begin{equation}\n    \\phi_{i}(s) = \\frac{\\phi'_{i}(s)}{\\sum_{i'=1}^{N}{\\phi'_{i'}(s)}}\n    \\hspace{0.5cm};\n    \\hspace{0.5cm}\n    \\phi'_{i}(s) = \\exp\\left( -\\frac{1}{2}[s - c_{i}]B^{-1}_{i}[s-c_{i}]\\right)\n\\end{equation}\n\n\\noindent Where $N$ is the number of basis functions and the sub index \\emph{i} refers to the \\emph{i-th} basis function.\n\n\\subsection[Artificial Neural Networks]{Artificial Neural Networks}\n\nANNs are a widely used model for non-linear function approximation. The idea behind these models is to build a network of interconnected units that have some properties inspired on neurons. There is a large variety of models \\cite{goodfellow2016deep, nielsen2015neural}, the ones relevant to this work are the following:\n\n\\begin{enumerate}\n    \\item Feedforward Fully-Connected\n    \\item Convolutional\n    \\item Autoencoder\n    \\item Recurrent\n\\end{enumerate}\n\n\\subsubsection{1. Feedforward Fully-Connected}\n    \nFeedforward Fully-Connected or Feedforward neural networks (FNNs) are the quintessential ANN model \\cite{goodfellow2016deep}. These models are called to be feedforward because the information flows in one sense from the input, trough intermediate representations, to the output. In the mathematical formalization, a network is understood as the model generated when many functions are composed. For instance, you may have three functions ($f^{(1)}$, $f^{(2)}$, $f^{(3)}$) connected in a chain such that:\n\n\\begin{equation}\n    \\Psi(s) = f^{(3)}(f^{(2)}(f^{(1)}(s)))\n\\end{equation}\n\nEach of these functions represents a \\emph{layer}, the overall number of layers is known as the \\emph{depth} of the neural network. Commonly, these layers have $n\\mathrm{-dimensional}$ outputs, and each dimension of the outputs corresponds to the output of a single \\emph{neuron}. A neuron is a function $h$ composed by weights $w$, a bias $b$ and a nonlinear function $\\sigma$, known as the activation function:\n\n\\begin{equation}\n    h(x) = \\sigma(w \\cdot x + b)\n    \\label{eq:h}\n\\end{equation}\n\nThere are different types of activation functions, such as ReLU, sigmoid or hyperbolic tangent. Graphically, this function is described in Figure \\ref{fig:neuron}.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.6\\linewidth]{imagenes/cap1/neuron.pdf}\n    \\caption[Neuron.]{Neuron ($b$ considered as an extra dimension of $w$).}\n    \\label{fig:neuron}\n\\end{figure}\n\nAs mentioned before, a layer may have many neurons. The number of neurons in a layer is known as the \\emph{width} of the layer. The inputs $x$ of a neuron are the outputs of every neuron of the past layer.  There are three types of layers: \\textbf{input}, \\textbf{hidden} and \\textbf{output}. The input layer is the input of $\\Psi$, which is $s$ in this context (which is not actually a layer). The output layer is the final function in the chain of functions that compose $\\Psi$, which outputs the output of $\\Psi$. Finally, the hidden layers are all the functions in between the input and output layers. Graphically, a FNN with one hidden layer is presented in Figure \\ref{fig:FNN}.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.4\\linewidth]{imagenes/cap1/nn.pdf}\n    \\caption{Feedforward Neural Network model with one hidden layer.}\n    \\label{fig:FNN}\n\\end{figure}\n\nIt can be observed that the nonlinearity that characterizes neural networks exists because of the activation functions, which are nonlinear. This is an essential condition for neural networks to be \\emph{universal approximators} \\cite{cybenko1989approximation, hornik1991approximation}. What this states is that a neural network with at least one hidden layer containing a large enough finite number of neurons can approximate any continuous function on a compact region of the network's input space to any degree of accuracy. This is a powerful property; nevertheless, finding the set of weights that parametrize the network in order to approximate an arbitrary function is another story, which will be discussed in Section \\ref{sec:learning}.\n\nFinally, going back to the concept of a parameterized policy $\\pi_{\\theta}$, in this case $\\theta$ would correspond to the concatenation of all the weights (including biases) of the layers of a network. \\newline\n\n\\subsubsection{2. Convolutional}\n    \nConvolutional Neural Networks (CNNs) are a specialized type of neural network. The main feature of these networks is that they are designed such that convolutions are employed in at least one layer \\cite{goodfellow2016deep, nielsen2015neural}. In the area of signal processing convolutions are a well-known tool for applying filters to signals, and at the same time, filtering signals is a well-known way of extracting features out of them. The approach proposed by CNNs is to learn the weights of these filters (also known as kernels) as a part of the network's learning process, and that by construction, these filters are applied to the inputs of the convolutional layers.\n\nThe way to achieve this is to replace the dot product in Equation \\ref{eq:h} by a convolution operation. Usually, in these problems we work with discrete data, so the discrete version of the convolution is used:\n\n\\begin{equation}\n    s(x)_{i} = (x * w)_{i} = \\sum_{l=0}^{L}w_{l} \\cdot x_{i+l}\n\\end{equation}\n    \nThe sub-index \\emph{i} corresponds to the \\emph{i-eth} term of the input $x$, and $w$ corresponds to the kernel, which has dimension $L$. It can be observed that the kernel is applied over a region of each index \\emph{i}, which means that this operation cares about the order of the data, and as a consequence, these networks are used with inputs that have spatial or time correlations, such as images or time series. CNNs are widely use for image processing problems \\cite{liu2017survey}, so it is common to use convolutions over more than one axis at a time. If we have a two-dimensional image as an input it seems natural to use a two-dimensional kernel $K$ as well (to exploit spatial correlations):\n\n\\begin{equation}\n    s(x)_{i,j} = (x * K)_{i,j} = \\sum_{l=0}^{L}\\sum_{m=0}^{M}K_{l, m} \\cdot x_{i+l, j+m}\n\\end{equation}\n\nIn this case K has dimension $L \\times M$. Figure \\ref{fig:conv} shows an example of a kernel operation over a pixel.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.57\\linewidth]{imagenes/cap1/convolution.pdf}\n    \\caption{Convolution operation in an image.}\n    \\label{fig:conv}\n\\end{figure}\n\nSo, in CNNs, Equation \\ref{eq:h} has the following shape:\n\n\\begin{equation}\n    h(x)_{i} = \\sigma(s(x)_{i} + b)\n    \\label{eq:h2}\n\\end{equation}\n\nEach neuron will correspond to the output of a kernel applied over a region of the input; thus, the output of the full convolution operation will correspond to a set of neurons. As a consequence, the weights, which in this case conform the kernel, will be shared between neurons, which does not happens in the FNN case. It is important to note that it is also common to apply the convolution operation over images with arbitrary depth. For instance, RGB images have depth=3 (red, green and blue channels), so in these cases filters with arbitrary depth may be used as well. Also, considering the assumption that each filter extracts one kind of feature out of a signal, usually, several filters are applied over an input, where every filter generates a different image (set of neurons) as an output. These means that the depth of the output of a convolutional layer will be equal to the number of filters applied.\n\nTo modify the output of a convolutional layer further, it is common to use a \\textbf{pooling function} \\cite{goodfellow2016deep, nielsen2015neural}. This function summarizes the output of the convolution operations replacing every value of the outputs with a statistic of the nearby outputs. One example of a pooling function is the \\emph{max pooling}, which takes the maximum value over a rectangular neighborhood, as it can be seen in Figure \\ref{fig:maxpool}. \n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.45\\linewidth]{imagenes/cap1/max_pool.pdf}\n    \\caption{Max pooling operation.}\n    \\label{fig:maxpool}\n\\end{figure}\n\nPooling helps the model to be approximately invariant to translations in the input space. An alternative to pooling, is to use a convolution with \\textbf{stride} greater than one. The stride is the distance skipped between values of the input to where the kernel is applied, which in the default case is one (no skipping). It has been observed that replacing pooling by stride$>1$ has no loss in accuracy for several image recognition benchmarks \\cite{springenberg2014striving}. Figure \\ref{fig:cnn} shows a CNN used for classification.\n    \n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=\\linewidth]{imagenes/cap1/cnn.pdf}\n\\caption{Convolutional Neural Network.}\n\\label{fig:cnn}\n\\end{figure}\n\n\\subsubsection{3. Autoencoder}\n    \nAn autoencoder is a special type of ANN that aims to copy the input of the network to its output i.e. aims to be the identity function \\cite{goodfellow2016deep, nielsen2015neural}. Although solving this problem may seem to be useless, it has some interesting properties. In this work, we are interested in using autoencoders for dimensionality reduction and feature learning. \n\nThis neural network is divided in two parts, the \\textbf{encoder $e(x)$} and the \\textbf{decoder $d(\\mathcal{L})$}. When used for dimensionality reduction and feature learning, the encoder tries to encode the input into a space of lower dimension (a bottleneck), called the \\textbf{latent space $\\mathcal{L}$}, which represents a compressed representation of the input $x$, $\\mathcal{L}=e(x)$. The decoder takes the latent space and tries to reconstruct the input $\\widetilde x = d(\\mathcal{L})$, where $\\widetilde x$ is the reconstruction of $x$, see Figure \\ref{fig:ae}. The objective of using autoencoders in this context is to obtain a latent space that captures the most salient features of the input. \n    \n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\linewidth]{imagenes/cap1/ae.pdf}\n    \\caption{Autoencoder.}\n    \\label{fig:ae}\n\\end{figure}\n    \nThe goal of the autoencoder is to minimize the loss function:\n\n\\begin{equation}\n\\label{eq:ae}\n    L(x, \\widetilde x = d(e(x)))\n\\end{equation}\n\nWhere $L$ is a dissimilarity function such as the mean squared error. This model may have convolutional, fully-connected, both or other types of layers.\n\n\\subsubsection{4. Recurrent}\n    \nRecurrent Neural Networks (RNNs), unlike FNNs or CNNs, have memory. They are designed to work with sequential data \\cite{goodfellow2016deep, nielsen2015neural}. What this means, that past evaluations of the network affect the ones in the future. RNNs have an internal state, or hidden state $h_{state}^{t}$ ($t$ represents the time step), that is modified every time an input is fed to the network such that:\n\n\\begin{equation}\n    h_{state}^{t} = f(h_{state}^{t-1}, x^{t}; \\theta)\n\\end{equation}\n\nIn the \\textbf{vanilla} RNN, one of the simplest models of RNNs, a neuron of a recurrent layer is understood as the $i\\mathrm{-eth}$ term of the hidden state, $h_{state\\mathrm{-}i}^{t}$. If compared with Equation \\ref{eq:h}, an RNN neuron has the following structure:\n\n\\begin{equation}\n    h_{state\\mathrm{-}i}^{t}(x) = \\sigma(w_{hh} \\cdot h_{state}^{t-1} + w_{xh} \\cdot x^{t} + b)\n\\end{equation}\n\nWhere the main difference is that the term $w_{hh} \\cdot h_{state\\mathrm{-}i}^{t-1}$ is incorporated, and the concatenation of the weights $w_{hh}$ and $w_{xh}$ corresponds to $w$. Figure \\ref{fig:rnn_unfolded} represents a vanilla RNN in its \\emph{unfolded} representation.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.4\\linewidth]{imagenes/cap1/unfolded_rnn.pdf}\n    \\caption{Unfolded vanilla RNN.}\n    \\label{fig:rnn_unfolded}\n\\end{figure}\n\nIn RNN contexts, commonly, the hidden state is represented as a whole vector directly, and not by the equations of every neuron. A weight matrix $W_{h}$ is used, and corresponds to the concatenation of the weights of every neuron, including the bias, such that:\n\n\\begin{equation}\n    h_{state}^{t}(x) = \\sigma(W_{hh} h_{state}^{t-1} + W_{xh} x^{t}) = \\sigma \\left(W_{h} \\begin{pmatrix} h^{t-1} \\\\ x^{t} \\end{pmatrix} \\right)\n\\end{equation}\n\nIn a vanilla RNN with one hidden state, $\\sigma$ is the hyperbolic tangent function $tanh$ and one more operation is added to obtain an output $y$:\n\n\\begin{equation}\n    y^{t}(x) = W_{hy}h_{state}^{t}(x)\n\\end{equation}\n\nNevertheless, vanilla RNNs have some structural problems related to the computation of their gradients (exploding and vanishing gradients) \\cite{bengio1994learning, pascanu2013difficulty}. So in practice, more complex RNN architectures are used, such as \\textbf{Long Short-Term Memory (LSTM)} \\cite{hochreiter1997long} or \\textbf{Gated Recurrent Unit (GRU)} \\cite{cho2014learning} networks. The architecture relevant to this work is LSTM, and one of its layers can be described with the following equations:\n\n\\begin{equation}\n    \\begin{pmatrix} i \\\\ f \\\\ o \\\\ g \\end{pmatrix} = \\begin{pmatrix} \\sigma_{f} \\\\ \\sigma_{f} \\\\ \\sigma_{f} \\\\ tanh \\end{pmatrix} W \\begin{pmatrix} h^{t-1} \\\\ x^{t} \\end{pmatrix} \n\\end{equation}\n\n\\begin{equation}\n    c^{t} = f \\odot c^{t-1} + i \\odot g\n\\end{equation}\n\n\\begin{equation}\n    h^{t} = o \\odot tanh(c^{t})\n\\end{equation}\n\nWhere $i$, $f$, $o$, $g$ are called \\textbf{gates} and each one of them is a vector used for internal computations of the recurrent unit. $\\sigma_{f}$ corresponds to the $sigmoid$ activation function, $\\odot$ is the element-wise product (Hadamard product) operator and $W$ is a weight matrix containing the submatrices $W_{i}$, $W_{f}$, $W_{o}$ and $W_{g}$. A LSTM layer or unit has two internal states $c^{t}$ and $h^{t}$. $h^{t}$ is still known as the hidden state and $c^{t}$ is known as the cell state.\n\n\\subsection{Parameter Tuning}\n\\label{sec:learning}\n\nUntil now, we have discussed that policies can by represented as parameterized models, called function approximators, and that the two most relevant to this work are LCBFs and ANNs. Nevertheless, we have not discussed on how to tune the parameters of these models in order for them to approximate a specific function.\n\nFirst, it is necessary to define a loss function, in this work we use the \\textbf{Mean Squared Error (MSE)}, which gives us a measure of how close are the vector outputs generated by our model $\\Psi(s;\\theta)=\\hat{y}$ with respect to observed target values $y$. Then, the objective is to minimize this function in the parameter space with some optimization method, in this case we use \\textbf{Stochastic Gradient Descent (SGD)} \\cite{robbins1951stochastic, saad1998online}. Given that this method needs to compute the gradient of the loss function $J(\\theta)=MSE(\\Psi(\\theta))$, it is necessary to compute the gradient of $\\Psi(\\theta)$.\n\nWhen using LCBFs, this computation is trivial, such that the gradient of \\ref{eq:lcbf} would be:\n\n\\begin{equation}\n    \\nabla_{\\theta} \\Psi(\\theta)_{LCBF} = \\phi(s)\n\\end{equation}\n\nBut, in the case of ANNs computing the gradient is not direct. Given that we have a function composed by layers, it is necessary to propagate the error through all of these layers in order to update all of the weights of the network. \\textbf{Backpropagation} \\cite{rumelhart1988learning} is the technique used to achieve this and, in principle, it uses the chain rule to quantify how much changes in past layers affect later ones. Nowadays, there are several computer tools that have this algorithm incorporated and that automatically compute the gradients of ANNs using symbolic math and differentiable programming, such as Tensorflow \\cite{tensorflow2015-whitepaper} or PyTorch \\cite{paszke2017automatic}.\n\n\\subsection{Deep RL Era}\n\nReinforcement Learning can be divided in the \\emph{pre Deep RL era} and the \\emph{Deep RL era}, which is the current one. In the year 2013, the first work known for successfully solving sequential decision-making problems with high-dimensional state spaces using CNNs was presented \\cite{atari}. This was a consequence of the new advances that where being made in the area of ANNs or \\textbf{Deep Learning (DL)}. When ANNs have several layers, which was the case for the mentioned work, they are called \\textbf{Deep Neural Networks (DNNs)}. The area that combines DL with RL is called \\textbf{Deep RL}. Deep RL gives agents the possibility to build rich state representations of the environment without feature engineering on the side of the designer, which was always necessary in classical RL. This drew a lot of attention and made Deep RL increasingly popular over the past few years \\cite{franccois2018introduction}.\n\nBefore the Deep RL era, ANNs where not a predominant function approximator for solving sequential decision-making problems. In the pre Deep RL era, one of the most widely used function approximators were LCBFs, as stated in a survey of the year 2013 \\cite{kober2013reinforcement}. \n\n\\section[Interactive Machine Learning]{Interactive Machine Learning}\n\nIn the context of this work, Interactive Machine Learning (IML) is understood as a research area that gathers all the techniques in which humans/users take part in the agent's learning process for solving sequential decision-making problems \\cite{Argall2009, amershi2014power,billing2010formalism, Chernova2014, cuayahuitl2013machine}. Other works refer to IML as an area that focuses on learning classifiers with the help of users \\cite{fails2003interactive, ware2001interactive, amershi2012regroup, ngo2014efficient}.\n\nAs RL, IML can also be studied under the framework of MDPs \\cite{Celemin2018AnInteractive, Knox:2009:ISA:1597735.1597738, Argall2009}. The main difference with RL is that in IML having an explicitly defined reward function is not a requirement. Some approaches may combine the information gathered from the human with the one given by a reward function, while others, may not need a reward function at all.\n\nIn this work, we divide IML into two areas: \\textbf{Learning from Demonstration (LfD)} \\cite{Argall2009, billing2010formalism} and \\textbf{Learning from Feedback (LfF)} \\cite{Celemin2018AnInteractive, argall2009learning, Knox:2009:ISA:1597735.1597738}.\n\n\\subsection{Learning from Demonstration}\n\nLfD is a learning paradigm in which a demonstrator provides labelled data of a desired policy \\cite{Argall2009, billing2010formalism}. Then, the agent tries to copy the demonstrator's behavior by shaping its policy in a supervised learning manner, using as database the data provided by the demonstrator (see Figure \\ref{fig:b_cloning}). This is the most basic LfD approach and it takes the name of \\textbf{Behavior Cloning}.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{imagenes/cap1/b_cloning.pdf}\n    \\caption{Behavior cloning.}\n    \\label{fig:b_cloning}\n\\end{figure}\n\n\\subsubsection{Imitation Learning}\n\nWhen the platform of the agent is different to the one in which the demonstrations are made, we talk about \\textbf{Imitation Learning}\\cite{Argall2009, billing2010formalism}. In this case, the learning agent must identify a mapping between the demonstrator and itself. This is a setting that arises naturally in real-world problems. For instance, let us suppose that we want to teach a robot how to walk. Using a camera, we could record a human making demonstrations (just by walking), but then, the robot should figure out how to map that observations into labeled data over its own state and action spaces. The problem of identifying this mapping is one of the main difficulties of LfD approaches and is known as \\textbf{The Correspondence Problem} \\cite{nehaniv2002correspondence}.\n\n\\subsubsection{State Distribution Mismatch}\n\nThe \\textbf{state distribution mismatch} (also known as distributional drift) is an issue that every LfD approach could have if is not taken into account. This problem arises because the probability distribution of the trajectory followed by the policy $p_{\\pi_{\\theta}}$ \\emph{drifts} from the one of the demonstrator $p_{data}$ \\cite{ross2011reduction}. This happens because even though the agent imitates the demonstrator, it is very difficult for the agent to make a perfect imitation. Thus, small errors over several states accumulate into a larger error that eventually causes the agent to fail. This phenomenon can be observed in Figure \\ref{fig:drift}, where the drift is shown over one dimension of the state.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\linewidth]{imagenes/cap1/drift.pdf}\n    \\caption{Distributional Drift.}\n    \\label{fig:drift}\n\\end{figure}\n\nA well-known algorithm that tackles this problem is called \\textbf{DAgger} \\cite{ross2011reduction}. This approach matches $p_{\\pi_{\\theta}}$ with $p_{data}$, such that $p_{\\pi_{\\theta}} = p_{data}$. The main idea is that instead of collecting samples from the demonstrator, collect them by running $\\pi_{\\theta}$ and then label them with the demonstrator. Samples are collected, labeled, added to the database $\\mathcal{D}$ and used for training iteratively, in order to approach asymptotically to $p_{data}$. The basic structure of DAgger is the following:\n\n\\begin{enumerate}\n    \\item Train $\\pi_{\\theta}(a_{t}|o_{t})$ from human data $\\mathcal{D}=\\{o_{1},a_{1},...,o_{T},a_{T}\\}$\n    \\item Run $\\pi_{\\theta}(a_{t}|o_{t})$ to get dataset $\\mathcal{D}_{\\pi_{\\theta}}=\\{o_{1},...,o_{M}\\}$\n    \\item Ask human to label $\\mathcal{D}_{\\pi_{\\theta}}$ with actions $a_{t}$\n    \\item Aggregate: $\\mathcal{D} \\leftarrow \\mathcal{D} \\cup \\mathcal{D_{\\pi_{\\theta}}}$\n\\end{enumerate}\n\nOne of the problems that DAgger presents in real-world applications is that the process of labeling the data can be challenging or unfeasible. For instance, robots commonly execute continuous actions, but for a human is not intuitive to assign a continuous valued label to an observation.\n\n\\newpage\n\n\\subsection{Learning from Feedback}\n\nWe define LfF as the paradigms in where policies are shaped by occasional human feedback. In this case there are no demonstrations; instead, \\textbf{corrections} or \\textbf{evaluations} are given by a teacher over the decisions made by the learning agent \\cite{Celemin2018AnInteractive, Knox:2009:ISA:1597735.1597738, Argall2009}. Figure \\ref{fig:LfF} summarizes the LfF approach.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.47\\linewidth]{imagenes/cap1/LfF.pdf}\n    \\caption{Learning from Feedback.}\n    \\label{fig:LfF}\n\\end{figure}\n\n\\subsubsection{Evaluative Feedback}\n\nEvaluative feedback has been used similarly to RL in methods wherein a human teacher communicates the desirability of the executed action or policy. There are different evaluative feedback approaches, some of them are:\n\n\\begin{itemize}\n    \\item \\textbf{Interactive Reinforcement Learning:} RL-based methodologies in which the reward signals are given by a human \\cite{thomaz2006reinforcement}.\n    \\item \\textbf{Human Reinforcement Modeling:} A reward function is modeled from the feedback given by a human. Then, this model is used as the reward function in a RL-based approach \\cite{Christiano2017, akrour2014programming}.\n    \\item \\textbf{The \\emph{shaping} approach:} This is a LfF approach known as TAMER \\cite{Knox:2009:ISA:1597735.1597738}. The policy is interactively shaped with evaluations that the teacher provides occasionally.\n\\end{itemize}\n\n\nEvaluative feedback approaches have been validated in problems of state spaces of low dimensionality \\cite{Knox:2009:ISA:1597735.1597738,akrour2011preference,macglashan2017interactive} and high dimensionality \\cite{Christiano2017,Warnell2017}.\n\n\\subsubsection{Corrective Feedback}\n\nIn corrective feedback approaches, the teacher advices corrections directly in the action's domain. This information indicates how to modify an action (increase or decrease it value), instead of evaluating it. Thus, this kind of feedback is designed to work in continuous-action domains. \n\nIf the idea behind corrective feedback is applied in discrete-action domains (that are not discretized continuous spaces), such as choosing between the actions $\\{left, up, right\\}$, the feedback signals  are corrections and demonstrations at the same time \\cite{chernova2009interactive, mericcli2010complementary}. This kind of feedback is known as \\textbf{corrective demonstrations} and it also belongs to the area of LfD. \n\nGiven that in this work we work with continuous-action domains, we are going to used the term corrective feedback under this context.  \n\nMethodologies such as \\textbf{Advice Operators} \\cite{Argall2009, Argall2008} have been proposed to solve problems using corrective feedback. This work studies another approach known as the \\textbf{COrrective Advice Communicated by Humans (COACH)} \\cite{Celemin2018AnInteractive} framework, which is described below. \n\nTo the best of our knowledge, corrective feedback has been only validated in problems with state spaces of low dimensionality, such as the ones covered in the aforementioned approaches. \n\n\\subsubsection{COrrective Advice Communicated by Humans}\n\\label{sss:COACH}\nIn COACH, if the agent executes an action $a$ that the human considers to be erroneous, then s/he would indicate the direction in which the action should be corrected (thus, COACH was proposed for problems with continuous actions). Each dimension of the action would have a corresponding correction signal $h$ with values $0$, $-1$ or $1$ which produces an error signal with arbitrary magnitude $e$ that is used to shape directly the policy. Thus, the error would be: \n\n\\begin{equation}\\label{eq:error}\n    error=h \\cdot e\n\\end{equation}\n\n$h=0$ indicates that no correction has been advised. $h=\\pm 1$ indicates the direction of the advised correction.\n\nIn this framework no value function is modeled, since no reward/cost is used in the learning process. A parameterized policy is directly learned in the parameter space, as in Policy Gradients RL. \nThe classic COACH algorithm shapes two functions parameterized as a linear model of basis functions. The objective of the first function is to learn the policy of the agent $\\pi_{\\theta}(s)=\\phi(s) \\cdot \\theta$; the objective of the second function, $H_{\\psi}(s)=\\phi(s) \\cdot \\psi$, is to learn a prediction of the human feedback. The parameter vectors $\\theta$ and $\\psi$ are updated to shape the models. As it can be seen, $\\phi(s)$ is the same vector for both the \\textbf{Policy Model} $\\pi(s)$ and the \\textbf{Human Feedback Model}  $H(s)$. The Human Feedback Model is used to adapt the size of the error signal that is then used to update the weights of $\\pi(s)$. Both functions are updated using stochastic gradient descent each time feedback is received. The pseudocode of COACH is shown in Algorithm \\ref{algorithm:COACH}.\n\n\\begin{algorithm}[H]\n\\caption{Basic Structure of COACH}\\label{algorithm:COACH}\n\\begin{algorithmic}[1]\n\\State \\textbf{Require:} error magnitude $e$, human model learning rate $\\beta$, time steps $N$\n\\For{t = 1,2,...,N}{}\n\\State \\textbf{observe} state $s_{t}$\n\\State \\textbf{execute} action $a_{t}=\\pi(s_{t})$\n\\State \\textbf{feedback} human corrective advice $h_{t}$\n\\If{$h_{t}$ is not 0}\n\\State \\textbf{update} $H(s_{t})$ with $\\Delta \\psi = \\beta\\cdot (h_{t}-H(s_{t}))\\cdot \\phi(s_{t})$\n\\State $\\alpha_{t} = |H(s_{t})|$\n\\State $error_{t} = h_{t}\\cdot e$\n\\State \\textbf{update} $\\pi(s_{t})$ with $\\Delta \\theta = \\alpha_{t} \\cdot error_{t} \\cdot \\phi(s_{t})$\n\\EndIf\n\\EndFor\n\\end{algorithmic}\n\\end{algorithm}", "meta": {"hexsha": "082b644b39bb0ae579c8c862a6216f9fa62ab3f2", "size": 44074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cap1.tex", "max_stars_repo_name": "rperezdattari/thesis-document-latex", "max_stars_repo_head_hexsha": "3ad39caaf927dceeb0460912ebef26576493ee36", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cap1.tex", "max_issues_repo_name": "rperezdattari/thesis-document-latex", "max_issues_repo_head_hexsha": "3ad39caaf927dceeb0460912ebef26576493ee36", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cap1.tex", "max_forks_repo_name": "rperezdattari/thesis-document-latex", "max_forks_repo_head_hexsha": "3ad39caaf927dceeb0460912ebef26576493ee36", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.9309664694, "max_line_length": 982, "alphanum_fraction": 0.761265145, "num_tokens": 11543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4432500335799585}}
{"text": "\\section{Representations}\nWe make use of layers of representation between the surface text of a word problem and the learned model. \nThe first of these is a domain-independent semantic representation derived directly from the text using pre-existing language processing tools.\nThis semantic representation is then transformed into a domain-specific intermediate representation of sets similar to the {\\it Qset} representation used by \\cite{koncel2015parsing}. \nFinally, a pair of intermediate representations are used to produce a vector for training. \nEach step of this process is described below.\n\n\\subsection{Semantic Representation}\n\\label{semantics}\nThe text of each sentence of a word problem is represented as a collection of predicates as provided by the Answer Constraint Engine parser \\cite{ace}.\nACE parses text using HPSG grammars, and we use the English Resource Grammar \\cite{flickinger2000building,flickinger2011accuracy}, a high precision, hand-built grammar for the English language. \nThe predications instantiate a collection of entity and event variables and express the different interactions of these variables according to the compositional meaning of the text. \nWe track all predications in which a given entity variable appears as an argument.\nWe also track relations between entities appearing as arguments of the same predication.\n\nRelevant to the task of solving math word problems are those entities that are related to numbers.\nThese entities often appear as the ARG1 of a CARD\\_REL whose CARG (and text span) is a number. \nIf a CARD\\_REL has a non-entity ARG1, we associate it's CARG to an instantiated entity which shares the same label. \nThese distinguished entities form our domain-specific intermediate representation, which for the sake of simplicity we will call {\\it Number Entities}.\n\n\\subsection{Vector Representation}\n\\label{vectors}\nAs mentioned above, our system learns from triples consisting of two text quantities and an operator which appears in an equation leading to the correct solution. \nWe represent a triple as a vector by considering the Number Entities corresponding to the text quantities in the triple. \nWe evaluate several methods of vectorizing these semantic representations:\n\\paragraph{All Predicates} For each Number Entity we add a 196 dimension vector, the number of predicates associated with any Number Entity in the training data. The vector contains a 1 if the Number Entity appears as an ARG$N$ for $N>0$ of the corresponding predicate.  \n\\paragraph{Abstract Predicates}\n Due to the nature of predicate naming, specific content noun and verb lexemes are encoded in the predicates, and these can be used to determine the correct operation between Number Entities.\nFor example, problems about {\\it seashells} (and thus ``\\_seashell\\_n\\_1\\_rel'') are generally addition or subtraction problems due to the nature of the data sources. \nSuch lexical overlap was shown to be a significant factor for the success of template-based methods; however, it is theoretically unsatisfying as we would like a method which does not ``memorize'' spurious features of the data but rather learns something more fundamental about the nature of the natural language representation of mathematical operations.\nTo combat this, we consider abstract predicates to be those MRS predicates whose names begin with an underscore (rather than an open-quotation). \n45 predicates meet this definition. \n\\paragraph{Abstract Predicates + Word2Vec} Previous work \\cite{koncel2015parsing} has shown that verb lexemes, along with distances between the two Number Entity's nouns and verbs respectively improve classification performance. \nWe use Word2Vec \\cite{mikolov2013efficient} to obtain 200-dimensional representations of verbs and nouns associated with each Number Entity.\nWe incorporate the verb vectors of both Number Entities directly into our feature vector, as well as the cosine distances of their nouns and verbs.\n\n", "meta": {"hexsha": "005874bb17e894f5c5eaa25461933177d2d5925f", "size": 3958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/representation.tex", "max_stars_repo_name": "rikkarikka/groundRefEv", "max_stars_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-07-11T18:56:57.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-11T18:56:57.000Z", "max_issues_repo_path": "paper/representation.tex", "max_issues_repo_name": "rikkarikka/groundRefEv", "max_issues_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/representation.tex", "max_forks_repo_name": "rikkarikka/groundRefEv", "max_forks_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.972972973, "max_line_length": 355, "alphanum_fraction": 0.8185952501, "num_tokens": 786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4432500335799584}}
{"text": "\\label{bdoodle:chapter}\n\n\nScheduling an event for a group of invitees is a frustrating task; it tends to be tedious and time consuming.\nA typical scheduling process can be described as iterative approval voting.\nFirst, an event organizer selects a candidate set of date/time options, and asks invitees to respond with their availability. \nGiven the responses, the organizer then chooses an agreeable option and announces it, or she may repeat the process by proposing another set of options if no feasible option is found. \nNaturally the organizer and her invitees wish to reach an agreement within a small number of iterations and proposed options -- the more iterations and proposed options there are, the more laborious a scheduling process becomes. \n\nThere exist several software tools that are designed to help an event organizer handle a scheduling process more efficiently -- one of the most well-known tools is Doodle~\\footnote{http://www.doodle.com}. \nIn Doodle, an organizer can simply list as many date/time options as she likes, \nand each invitee is asked to respond with her availability. \nEssentially, invitees participate in approval voting on all options proposed by the organizer.\nHence if too many options are proposed, then invitees are given the burden of answering them all. \nThis often leads to undesired behaviors of invitees such as herding or procrastination, instead of honest, quick responses~\\cite{zou2015strategic}. \nOn the other hand, if the organizer proposes only few options, there may not exist an agreeable outcome after all, which may result in another iteration of proposals and responses. \nIn fact, surveys find that the most challenging part of group scheduling is due to ``chasing people who do not answer'' and ``finding a suitable time.''~\\footnote{http://en.blog.doodle.com/2012/07/26/new-findings-a-small-number-of-initiators-organize-most-of-the-meetings/}\n\nDoodle has many practical advantages. \nOne of them is its simplicity -- invitees simply need to approve a subset of options based on their availability.\nAnother is a short duration of scheduling process -- the duration it takes until\nthe last invitee responds and the meeting time is settled. Each invitee\nneeds to respond only once, which limits the degree to which the\nprocess is hijacked by invitees' delayed responses. But Doodle has many\ndrawbacks, even in this idealized setting. In particular, Doodle\nforces the invitees to examine many potential date/time options. This can be\ninconvenient not so much due to the effort involved (though that is a\nfactor), but mostly because invitees need to block their available slots\noff until a option is announced -- in a way, their `free time' is being hostaged until the final schedule is set.\nTo quantify this inconvenience, we use the expected number of time\nslots floated by the organizer as a proxy.\n\nIn order to avoid incurring much inconvenience, \nthe organizer can select just a handful number of options,\nand poll the invitees about those. If a feasible option is not found\namong them, then repeat with another batch of date/time options. \nWe call this broad class of polling mechanisms \\emph{B-Doodle} (for ``Batched Doodle\").\nClearly, Doodle is a special case with one batch consisting of all\noptions. Another extreme case is the OAAT (one-at-a-time)\nmechanism, in which the organizer tests a single option at each\niteration. Doodle minimizes the total number of iterations, whereas \nOAAT minimizes (expected) inconvenience caused by the scheduling process.\nIn-between lie many other mechanisms, with different\nbatching schemes, that trade off time against inconvenience\ndifferently.\n\nFigure~\\ref{bdoodle:fig:Pareto_scatter} illustrates this via a simple example.\nIn this scenario there are six options, four invitees, each of whom\nis available at each option independently with probability $.8$.\nThe figure depicts a scatter plot of all 32 different B-Doodle mechanisms,\nincluding Doodle and OAAT. The vertical axis depicts the expected\nnumber of rounds to determine the option, and the horizontal axis\nthe expected inconvenience.\n\n\\begin{figure}[h!] \\small\n\\centering\n\\includegraphics[scale=0.48]{plots/pareto_scatter_fin.eps}\n\\caption{A scatter plot of B-Doodle Mechanisms given four invitees and six options.}\n\\label{bdoodle:fig:Pareto_scatter}\n\\end{figure}\n\nWe can clearly observe a time-inconvenience Pareto frontier in Figure~\\ref{bdoodle:fig:Pareto_scatter}. \nIn additino, if there is an overall cost function combining time\nand inconvenience, one can identify an optimal B-Doodle mechanism\nalong this frontier as illustrated in\nFigure~\\ref{bdoodle:fig:Pareto_objective}. \nIf we assume that the overall cost is defined as 3$\\cdot$\\Time+\\Inconveniences (which is a linear combination of the two), the optimal mechanism happens to be the ``Half-n-half\" mechanism; this mechanism\nsends out $3$ options in the first batch, and if no feasible time\nslot is found then sends out the remaining $3$ options in the next\nbatch.\n\n\\begin{figure}[h!] \\small\n\\centering\n\\includegraphics[scale=0.48]{plots/pareto_objective_fin.eps}\n\\caption{Pareto-frontier and objective function.}\n\\label{bdoodle:fig:Pareto_objective}\n\\end{figure}\n\nIn this chapter we will investigate the difficulty of finding an optimal B-Doodle mechanism, and to what degree it improves on the simple Doodle in realistic scenarios.\nUnder the assumption that the set of events in which an invitee is available for a particular option is mutually independent, \nwe provide an efficient recursive algorithm for computing an optimal polling mechanism for a broad class of objective functions.\n\nIn addition we also  assume that the event organizer is given probability estimates on availability of agents, but it is not clear how one can obtain such probabilities. \n Probability estimation is an interesting and challenging research question on its own, and we do not attempt to solve the question in this work. However, we provide several plausible methods for estimating the probabilities in the context of group scheduling, which can enable our model and algorithm to be deployed as a real-world application in the future.\n In the psychology literature, Mann et al. found that cultural differences between the Western, individualistic countries (such as the United States) and the Eastern, collectivistic countries (such as China and Japan) lead to different behaviors of respondents when it comes to a group-decision making process~\\cite{mann1998cross}.\n More recently, Reinecke et al. analyzed more than 1.5 million Doodle date/time polls from 211 countries, and confirmed similar findings regarding time perception and group's behavior~\\cite{reinecke2013doodle}. Among others, they found that ``in comparison to predominantly individualist societies, poll participants from collectivist countries respond earlier, agree to fewer options but find more consensus,'' which agrees with the findings of Mann et al.\n Besides the cultural differences, Doodle's own surveys on event scheduling found that people tend to respond to the scheduling surveys on Mondays, while Monday is the least popular day for having a meeting.~\\footnote{http://en.blog.doodle.com/2012/05/23/mondays-for-planning-busy-weekends/}\n We believe that these studies and findings can be used to design a reasonable estimator for availability of agents, by utilizing the features that are known to be crucial -- such as demographics of the group and purpose of the event being scheduled.\n Recent work by Zou et al. analyzed over 340,000 Doodle polls data to study behavioral patterns of the users, and they were able to identify response functions that match the response patterns observed in the real data~\\cite{zou2015strategic}. We believe that a similar approach can be taken to tackle the problem of probability estimation in the context of group scheduling.\n\n\\paragraph{Related Work.}\nGroup scheduling is of tremendous practical importance, and much research has been devoted to it. Early work in AI had a heuristic, systems-oriented flavor to it. For example, Jennings et al.~\\cite{Jennings95agent} proposed the design of an agent-based meeting scheduling system, in which an autonomous agent negotiates with other agents on behalf of its human user. The emphasis was on the system description, rather than on theoretical or empirical results. Somewhat more formal work was done by Sen and Durfee~\\cite{sen1998formal}, which focused on heuristic negotiation-strategies for group scheduling. Ephrati et al.~\\cite{ephrati1994non} tackled incentive issues, adopting a game-theoretic approach. It proposed three monetary-based meeting systems, in which invitees bid their preferences using monetary ``points\". They extended the Vickrey-Clarke-Groves mechanism (at the time not as widely known in computer science as today), preventing manipulative behavior by the invitees assuming that the host has an access to the calendars of invitees -- the authors called this the ``open calendar\" system, but in our work we do not assume that the organizer has an access to the calendars (or availability) of invitees. \n\nOthers have focused on applying machine learning to group scheduling. Mitchell et al.~\\cite{mitchell1994experience} and Maes~\\cite{maes1994agents} respectively focused on learning user preferences and reducing the amount of work that needs to be done by human users during the scheduling process. More recently, Crawford and Veloso~\\cite{crawford2005learning} approached the negotiation-based group scheduling problem by training agents to learn about the negotiation strategies of other agents. In addition to these strands of domain-independent group scheduling, there has been work on group scheduling problem in specific domains,  including sales summit scheduling (Cowling et al.~\\cite{Cowling}), airport scheduling (Chia et al.~\\cite{chia1998coordinating} and Neiman et al.~\\cite{neiman1994exploiting}), and medical scheduling (Decker and Li~\\cite{decker1998coordinated} and Hannebauer and M{\\\"u}ller~\\cite{hannebauer2001distributed}).\n\nAll of the above directions are relevant to the general problem of group scheduling, but not directly to the setting that is being considered in this chapter. The most closely related work of which we are aware is done by Franzin et al.~\\cite{franzin04} and Garrido and Sycara~\\cite{garrido1996multi} respectively. These papers are superficially different, as their main focus is the impact of privacy considerations (specifically, different levels of calendar sharing among agents) on time and quality, whereas we concentrate on the interaction between time spent and inconvenience caused during the scheduling process. But this is not the main differentiator, since their notion of privacy level is tied to the number of slots examined before a schedule is found, which is close to our inconvenience measure. A bigger difference lies in the mechanisms considered; we explore the space of Single-proposer Mechanisms in which the sole organizer is trying to schedule a meeting, whereas they explore two specific mechanisms that fall outside the scope of SPMs as any agent can propose a schedule to others (this falls into Multi-proposer Mechanisms). Another crucial difference lies in the nature of the results; neither of the two papers proposes optimal solutions, and do not compare their proposed solutions to common web-based solutions such as Doodle (nor could they have, since no web-based solutions existed at the time).\n\n\n\n\n\n\\section{Notation and Definitions}\n\nWe mentioned two dimensions of optimality in the scheduling process: \\Times and \\Inconvenience.\n\\Times captures the duration of the scheduling process and \\Inconveniences measures how much inconvenience is caused for each agent during the process.\nIn this section we formally define the class of B-Doodle mechanisms, the Batched Doodle Problem (\\BDP), and other technical terms and notations.\n\n\n\\subsection{Problem Setting}\nConsider $n$ invitees denoted by $\\{a_1, \\dots, a_n\\}$ and $s$ time slots denoted by $\\{1, 2, \\dots, s\\}$.\nFor each agent $a_i$ and each time slot $t$, there is a known prior probability, $p_{i, t}$, such that the agent is available at time $t$ with probability $p_{i, t}$ and unavailable with probability $(1-p_{i, t})$. \nWhile the organizer knows all such priors (i.e. all $p_{i,t}$'s), she does not know the realization of availability of agents -- it is private information of each agent.\nThe organizer is trying to find a \\emph{feasible} time slot by asking invitees to reveal their availability; we assume that the organizer has a \\emph{feasibility threshold}, $f$, such that a feasible time slot requires at least $\\lceil f \\cdot n \\rceil$ agents be available. The organizer iteratively sends out a batch of time slots until a feasible time slot is found. In our setting \\Times spent by the scheduling process is measured by the number of iterations and \\Inconveniences caused is measured by the number of time slots that have been sent out by the organizer.\n\nThis setting is general enough to capture many realistic scenarios of group scheduling. For instance in a corporate setting, a busy manager may have low probability of being available for all time slots while other employees may be less busy and have high probability of being available. Or, if students are trying to decide on the meeting time for a group project, their availability is expected to be equally likely because the schedules of their classes are similar.\n\nLet us define a class of B-Doodle mechanisms that describe how the organizer sends out time slots in each iteration.\n\\begin{definition}[B-Doodle Mechanism]\nLet $S = \\{1, 2, \\dots, s\\}$ be a set of $s$ time slots. We define a B-Doodle mechanism for $S$ as an ordered partition of $S$.\nLet $B = \\langle S_1, S_2, \\dots, S_m \\rangle$ be a partition of $S$ into $m$ subsets such that $S_j \\neq\\emptyset$, $S_j \\cap S_k = \\emptyset$ for $j \\neq k$, and $\\cup_{l=1}^{m} S_l = S$ where $1 \\leq j,k \\leq m$. We define $b_j = |S_j|$ for all $j \\leq m$ and call $b_j$ the size of the $j$-th batch. \nWe write $B_m$ to emphasize that $B$ has $m$ batches.\n\\end{definition}\nWe interpret a B-Doodle mechanism $B$ as follows: the organizer sends out time slots in $S_1$ during the first iteration. If a feasible time slot is found, the process ends. Otherwise she sends out the next batch, $S_2$, and so on.\nNote that there exist exponentially many B-Doodle mechanisms for any fixed $S$ (exponential in cardinality of $S$). \nDoodle is a special case of B-Doodle mechanism and can be described as $\\langle S \\rangle$.\n\nOur objective is to find a B-Doodle mechanism that minimizes the expected cost of scheduling process, given an objective function of \\Times and \\Inconvenience.  Earlier we considered a simple cost function that is a linear combination of the two.  While this cost function fits in many realistic situations, we want to explore a larger class of cost functions. We define a class of cost functions that depend on the number of iterations and batch sizes.\n\\begin{definition}[Cost function] \\label{bdoodle:def:cost-function}\nA cost function $c$ takes two integers $j$ and $b$ as arguments, and $c(j, b) > 0$ describes the aggregate cost of \\Times and \\Inconveniences that is incurred by sending out a batch of $b$ time slots during the $j$-th iteration. We assume that cost is additive so that the overall cost of executing the first $j$ iterations of ${B}_m = \\langle S_1, S_2, \\dots, S_m \\rangle$ is simply the sum, $\\sum_{k=1}^{j} c(k, b_k)$, which we denote by $C(j, {B}_m)$; recall that $b_k = |S_k|$. \nA cost function $c$ is said to be $\\theta$-\\emph{simple} if there exists some constant $\\theta>0$ such that $c(j, b) = \\theta \\cdot c(j-1, b)$ for all $j > 1$ and for all $b \\geq 1$. We often drop $\\theta$ and just state that a cost function is \\emph{simple}, for brevity.\n\\end{definition}\nIt is reasonable to assume that cost is additive (with respect to iterations) because the time spent and inconvenience caused for the agents all add up.\nNote that $C(j, B_{m})$ is strictly increasing in $j$ for any fixed $B_{m}$ because $c(j, b) > 0$ for any $j$ and $b$. While the class of simple cost functions may seem too restrictive, we present a few natural choices of cost functions that belong to the class of simple cost functions. In this chapter we assume that the underlying cost function is simple; further we assume that $c(j, b)$ for all $1 \\leq j, b \\leq s$ can be computed in polynomial time with respect to $s$.\n\n$\\theta$-simple cost functions form a broad class of cost functions, and can model many different settings. \nFor instance, when $\\theta = 1$, it means that the cost of sending out a batch of a certain size is the same regardless of during which iteration it is being sent. When $\\theta > 1$, it means that a later iteration costs more than an earlier iteration if the size of a batch is the same. Lastly, when $\\theta \\in (0, 1)$, it is the opposite in that an earlier iteration costs more than a later iteration given the same batch size -- this last case may be rare in real life, but our definition naturally allows for such scenarios.\nThe following example shows this by various simple cost functions. \n\n\\begin{example}[Simple cost functions] \\label{bdoodle:eg:costFunctions}\nThe simplest choice of a cost function is a linear combination of \\Times and \\Inconvenience, parameterized by some constant $\\alpha > 0$; we call this a \\emph{linear} cost function. This cost function is $1$-simple. Notice that the first term captures \\Times and the second captures \\Inconveniences in both expressions.  \n\\begin{equation} \\label{bdoodle:eqn:linear_cost_function}\nc_{\\alpha}(j, b_j) = \\alpha + b_j, ~~ C_{\\alpha}(j, {B}_m) = \\left(\\alpha \\cdot j\\right) + \\left(\\sum_{k=1}^{j} b_k\\right).\n\\end{equation}\nIn some cases the organizer may want to penalize the mechanism for executing too many iterations by making later iterations to cost more than earlier iterations. The following describes such cost function, parameterized by some constant $\\beta > 1$; we call this a \\emph{time-averse} cost function. Notice that the term $\\beta^j$ is strictly increasing as $j$ increases. This cost function is $\\beta$-simple.\n\\begin{equation} \\label{bdoodle:eqn:time_averse_cost_function}\nc_{\\beta}(j, b_j) = \\beta^j \\cdot b_j, ~~ C_{\\beta}(j, {B}_m) = \\left(\\sum_{k=1}^{j} \\beta^k \\cdot b_k \\right).\n\\end{equation}\nIn contrast if the organizer is interested in reducing the size of each batch because it may cause too much inconvenience, then the following cost function could be used, which is parameterized by some constant $\\gamma > 1$; we call this an \\emph{inconvenience-averse} cost function which is $1$-simple.\n\\begin{equation} \\label{bdoodle:eqn:inconvenience_averse_cost_function}\nc_{\\gamma}(j, b_j) = \\gamma^{b_j}, ~~ C_{\\gamma}(j, {B}_m) = \\left(\\sum_{k=1}^{j} \\gamma^{b_k} \\right).\n\\end{equation}\n\\end{example}\n\n\nWe now formally define the Batched Doodle Problem.\n\\begin{definition}[Batched Doodle Problem] \\label{bdoodle:def:bdp}\nAn instance of the Batched Doodle Problem (\\BDP) is a tuple $(N, S, f, c, P)$ where $N = \\{a_1, a_2, \\dots, a_n\\}$ is a set of $n$ agents , $S = \\{1, 2, \\dots, s\\}$ is a set of time $s$ slots, $f$ is the feasibility threshold ($0 \\leq f \\leq 1$), $c$ is a cost function, and $P$ is a probability distribution matrix of availability ($P = \\{p_{i, t}\\}$ with $0 \\leq p_{i,t}\\leq 1$ for all $i, t$).\n\nThe objective in \\BDPs is to find an optimal partition of $S$, $B^*$, among all B-Doodle mechanisms that partition $S$, such that $B^*$ minimizes the expected cost of the scheduling process (expectation with respect to $P$), given $(N, S, f, c, P)$.\n\\end{definition}\nSince there are exponentially many B-Doodle mechanisms, it is impractical to enumerate each B-Doodle and compute its expected cost in order to find an optimal one. In what follows we make some simplifying assumptions that are assumed throughout this paper, and we present an efficient algorithm to solve \\BDPs in next section. \n\n\n\n\\subsection{Technical Assumptions}\nAs we briefly mentioned in the intro, we assume that the availability of agents for each time slot is independent of their availability at other time slots, and of the availability of other agents. That is, the set of events in which agents are available for certain time slots is mutually independent. \nWe discuss the relaxation of this assumption in Section~\\ref{bdoodle:sec:Discussion}. The independence assumption allows us to compute the likelihood of each time slot being feasible, as the following lemma states. \n\\begin{lemma} \\label{bdoodle:lemma:q_t_polytime}\nGiven $(N, S, f, P)$, let $q_t$ for each $t\\in S$ be the probability that time slot $t$ is $f$-feasible. Under the independence assumption, $q_t$ can be computed in polynomial time.\n\\end{lemma}\n\\begin{proof}\nFor any fixed $t$, let us define $V_t(i, z)$ to be the probability that among the agents $\\{a_1, a_2, \\dots, a_i\\}$ exactly $z$ agents are available at time slot $t$. $V_t(i, z)$ is well-defined where $1 \\leq i \\leq n$ and $0 \\leq z \\leq i$. We further define $V_t(i, z)$ for the following degenerate cases:\n\\begin{equation*}\nV_t(i, z) =\n\\begin{cases} \n\t1 & \\mbox{if~} i = z = 0 \\\\\n\t0 & \\mbox{if~} z = -1 \\mbox{~or~} (i = 0 \\land z > 0)\n\\end{cases}\n\\end{equation*}\nThen we can compute $V_t(i, z)$ using a simple dynamic programming algorithm according to the following recurrence relation where $1 \\leq i \\leq n$ and $0 \\leq z \\leq i$:\n\\begin{equation} \\label{bdoodle:eqn:vt_precompute}\nV_t(i, z) = V_t(i-1, z-1) \\cdot p_{i,t} + V_t(i-1, z) \\cdot (1- p_{i,t}) \n\\end{equation}\nIt is easy to verify that the recurrence relation is correct. For the degenerate cases (or base cases) when $i = z = 0$ it is always (with probability 1) the case that no agents are available. When $z = -1$ or $(i=0 \\land z>0)$, it is never (with probability 0) the case that $z$ agents are available. For the main recurrence relation, agent $a_i$ is either available or unavailable, and we compute $V_t(i, z)$ by considering both cases. For each fixed $t$, there are $O(n^2)$ entries of $V_t$ to be computed, and computing each entry takes $O(1)$; therefore it takes $O(sn^2)$ to compute $V_t(i, z)$ for all $t, i, z$. \n\nFinally we can compute $q_t$ after we compute $V_t(i, z)$ for all $i,z$, as follows:\n\\begin{equation}\nq_t = \\sum_{z = \\lceil f \\cdot n \\rceil}^{n} V_t(n, z).\n \\end{equation}\n\\end{proof}\n\nLemma~\\ref{bdoodle:lemma:q_t_polytime} allows us to describe a B-Doodle mechanism in a simpler form, along with the following theorem. \n\\begin{theorem} \\label{bdoodle:thm:swap_argument}\nConsider a B-Doodle mechanism $B$ described by $\\langle S_1, S_2, \\dots, S_m \\rangle$. Suppose that there is some time slot $t \\in S_l$ and $t'\\in S_{l'}$ with $q_t < q_{t'}$ and $l < l'$. Then $B$ is not an optimal in the sense that we can find another mechanism $B^*$ whose expected cost is strictly less than the expected cost of $B$.\n\\end{theorem}\n\\begin{proof}\nGiven $B$, let us construct another B-Doodle mechanism, $B^*$, as follows: $B^* = \\langle S^*_1, S^*_2, \\dots, S^*_m \\rangle$, which is the same as $B$ except that we swap $t$ and $t'$. That is, $S^*_i = S_i$ for all $i \\neq l$ and $i\\neq l'$, and $S^*_{l} = (S_l \\cup t') \\setminus t$ and $S^*_{l'} = (S_{l'} \\cup t) \\setminus t'$. Note that the two mechanisms have the same batch sizes ($b_j = b^*_j$ for all $j$). \n\nLet $w_j$ be the probability that the scheduling process ends after the $j$-th iteration if we use $B$, and $w_j^*$ if we use $B^*$. Then $w_j = w_j^*$ for all $j < l$ because $S_j = S^*_j$ for all $j$ with $1 \\leq j < l$. Clearly it holds that $w_l < w_l^*$ because of the swap of $t$ and $t'$. For $j$ with $l < j \\leq l'$, it holds that $w_j > w_j^*$; this is not obvious, but the intuition is that if $w_l^*$ increases then the subsequent $w_j^*$'s with $l < j \\leq l'$ must decrease as they depend on $1-w_l^*$, until this effect is canceled out in the $l'$-th batch. Since the probability of finding no feasible time slots during $l'$ iterations is the same in both cases (because $\\cup_{i=1}^{l'} S_i = \\cup_{i=1}^{l'}S^*_i$) it holds that $w_j = w_j^*$ for all $j > l'$. \n\nLet $\\Exp_B$ be the expected cost of $B$ and $\\Exp_{B^*}$ of $B^*$. Since $b_j = b^*_j$ for all $j$, it holds that $C(j, B) = C(j, B^*)$ for all $j$, and we have:\n\\begin{eqnarray}\n\t\\Exp_B - \\Exp_{B^*} \n\t&=& (w_l - w_l^*) C(l, B) + \\sum_{j=l+1}^{l'} (w_j - w_j^*)C(j, B) \\\\\n\t&=& \\sum_{j=l+1}^{l'} (w_j - w_j^*)(C(j, B) - C(l, B))\n\\end{eqnarray} \nThe first inequality holds by definition of the expected cost and canceling out some terms; the second inequality holds because $(w_l - w_l^*) + \\sum_{j=l+1}^{l'} (w_j - w_j^*) = 0$ (as probabilities must add up to one). Since $w_j > w_j^*$ and $C(j, B) > C(l, B)$ for all $j$ (because $C(j, B)$ is an increasing function in $j$ for fixed $B$), we conclude that $\\Exp_{B} > \\Exp_{B^*}$.\n\\end{proof}\nTheorem~\\ref{bdoodle:thm:swap_argument} implies that an optimal B-Doodle that minimizes the expected cost must have the following property: for any two batches $S_j$ and $S_k$ with $j < k$, it must hold that $q_t \\geq q_{t'}$ for all $t\\in S_j$ and $t' \\in S_k$ (otherwise we can apply the theorem and swap the two time slots to obtain a mechanism with smaller expected cost).\nTherefore we can limit our attention to the sub-class of B-Doodle mechanisms that only describe batch sizes, but not explicitly which time slots in each batch. Due to Lemma~\\ref{bdoodle:lemma:q_t_polytime} we can compute $q_t$ for each $t$ in polynomial time, and thus we can simply sort time slots by $q_t$ in non-increasing order as a pre-processing step.\n\nTherefore we can focus on the following sub-class of \\emph{simplified} B-Doodle mechanisms:\n\\begin{definition}[Simplified B-Doodle Mechanism]\nLet $S = \\{1, 2, \\dots, s\\}$ be a set of $s$ time slots. \nA simplified B-Doodle mechanism $B$ for $S$ is a vector of integers, described as $B = \\langle b_1, b_2, \\dots, b_m\\rangle$ where $(b_j \\geq 1$ for all $j \\leq m)$ and $(\\sum_{k=1}^{m} b_k = s)$.\nWe write $B_m$ to emphasize that $B$ has $m$ batches.\n\\end{definition}\nFrom now on we use the definition of a simplified B-Doodle, and simply write a B-Doodle mechanism to mean a simplified B-Doodle mechanism but this should cause no confusion.\n\n\n\n\n\n\n\\section{Main Algorithm for the Batched Doodle Problem} \\label{bdoodle:sec:Algorithm}\n\nIn this section we present an algorithm that finds an optimal B-Doodle mechanism that minimizes the expected cost, given an instance of \\BDP. Let us first describe how one can express the expected cost of a B-Doodle mechanism. \n\nGiven an instance $(N, S, f, c, P)$, consider some B-Doodle mechanism $B_{m} = \\langle b_1, b_2, \\dots, b_m \\rangle$ with $\\sum_{k=1}^{m} b_k = |S|$. Let $Pr(j)$ be the probability that the scheduling process ends after $j$-th iteration. Let $\\Exp[B_{m} | c]$ denote the expected cost of $B_{m}$ given cost function $c$, which can be expressed as follows:\n\\begin{equation} \\label{bdoodle:eqn:expCost}\n\t\\Exp[B_{m} | c] = \\sum_{j=1}^{m} Pr(j) \\cdot C(j, B_{m})  =  \\sum_{j=1}^{m} Pr(j) \\cdot \\left(\\sum_{k=1}^{j} c(k, b_k)\\right).\n\\end{equation}%\n\nWhile one can compute $Pr(j)$ in polynomial time, it is not necessary for our algorithm. Instead we present an important lemma that leads us to an efficient algorithm. The following lemma states that if $c$ is simple, then we can compute $\\Exp[B_{m}|c]$ in a recursive manner.\n\n\\begin{lemma} \\label{bdoodle:lemma:recurrence} \n\tConsider any mechanism $B_m = \\langle b_1, b_2, \\dots, b_m \\rangle$. Let us denote another mechanism that is obtained after removing the first batch ($b_1$) from $B_m$, as $\\hat{B}_{m-1}$ (i.e. $\\hat{B}_{m-1} = \\langle b_2, b_3, \\dots, b_m \\rangle$). For each time slot $t \\in S$, let $q_t$ be the probability that $t$ is $f$-feasible.\n\nIf $c$ is a $\\theta$-simple cost function with with $\\theta > 0$, then the following equality holds:\n\\begin{equation} \\label{bdoodle:eqn:recurrence}\n\\Exp[B_{m}|c] = c(1, b_1) +  \\left(\\prod_{t=1}^{b_1} \\left(1 - q_t\\right)\\right) \\cdot \\theta \\cdot \\Exp[\\hat{B}_{m-1}|c]\n\\end{equation}\n\\end{lemma}\n\\begin{proof}\nLet us first provide an intuitive way to understand the recurrence relation given by Equation~\\ref{bdoodle:eqn:recurrence}. The first term $c(1, b_1)$ captures the cost of sending out the first batch; regardless of when the scheduling process ends, this cost incurs with probability of $1$. If it turns out that the first batch does not contain a feasible time slot with probability of $(1 - Pr(1))$, then the organizer must send out the remaining batches, which is precisely $\\hat{B}_{m-1}$. It is easy to verify that the product term in the equation is equal to $(1 - Pr(1))$. The expected cost of $\\hat{B}_{m-1}$ is adjusted by a factor of $\\theta$ in the equation because the cost function is $\\theta$-simple. \n\nWe now formally prove the claim. Given $B_{m}$ as described above, for each batch $j \\in \\{1, 2, \\dots, m\\}$, let $r_j$ be the probability that the $j$-th batch has at least one $f$-feasible time slot. Let us define $v_0 = 0$ and $v_j = \\sum_{k=1}^{j} b_k$ (i.e. $v_j$ is the number of time slots in batches $1$ through $j$).\nWe can express $r_j$ as:\n\\begin{equation} \\label{bdoodle:eqn:r_j}\nr_j = 1 - \\prod_{t=v_{j-1} + 1}^{v_j} (1 - q_t)\n\\end{equation}\n$Pr(j)$ is the probability that the scheduling process ends after $j$-th iteration (with $Pr(m) = 1 - \\sum_{k=1}^{m-1} Pr(k)$). For $1 \\leq j < m$, $Pr(j)$ is given by:\n\\begin{equation} \\label{bdoodle:eqn:Pr_j}\nPr(j) =  r_j  \\prod_{k=1}^{j-1} (1 - r_k)   \n\\end{equation}\n\t\nRecall that $\\hat{B}_{m-1} = \\langle b_2, b_3, \\dots, b_{m} \\rangle$. \nFor clarity, let us express it as $\\hat{B}_{m-1} = \\langle \\hat{b}_1, \\hat{b}_2, \\dots, \\hat{b}_{m-1}\\rangle$ with $\\hat{b}_j = b_{j+1}$ for all $j\\geq 1$. Let $\\hat{r}_j$ be the probability that a feasible time slot exists in $j$-th batch of $\\hat{B}_{m-1}$, which is equal to $r_{j+1}$ for all $j \\geq 1$. Let $\\hat{Pr}(j)$ be the probability that scheduling ends after the $j$-th iteration of $\\hat{B}_{m-1}$:\n\\begin{equation}\n\t\\hat{Pr}(j) \n\t= \\hat{r}_j \\prod_{k=1}^{j-1} (1 - \\hat{r}_k)\n\t= r_{j+1} \\prod_{k=2}^{j} (1 - r_{k})  \\label{bdoodle:eqn:pr_hat_b}\n\\end{equation}\nWe can express $\\Exp[\\hat{B}_{m-1}|c]$ as follows:\n\\begin{eqnarray*}\n\\Exp[\\hat{B}_{m-1}|c]\n&=& \\sum_{j=1}^{m-1} \\hat{Pr}(j) \\left( \\sum_{k=1}^{j} c(k, \\hat{b}_k) \\right) \\\\\n&=& \\sum_{j=1}^{m-1} r_{j+1} \\left(\\prod_{k=2}^{j} (1 - r_{k})\\right) \\left(\\sum_{k=2}^{j+1} c(k-1, b_{k+1})\\right) \\\\\n&=& \\sum_{j=2}^{m} r_{j} \\left(\\prod_{k=2}^{j-1} (1 - r_{k})\\right) \\left(\\sum_{k=2}^{j} c(k-1, b_{k+1})\\right)\n\\end{eqnarray*}\nThe first equality holds by definition. The second equality is due to Equation~\\ref{bdoodle:eqn:pr_hat_b} and because $\\hat{b}_k = b_{k+1}$. The third equality is by changing the range of $j$ in the summation. \n\nIf we multiply $\\Exp[\\hat{B}_{m-1}|c]$ by $(1 - r_1)\\theta$, we get the following:\n\\begin{equation} \\label{bdoodle:eqn:ExpCost_Bhat}\n(1-r_1)\\theta \\Exp[\\hat{B}_{m-1}|c] = \\sum_{j=2}^{m} r_{j} \\left(\\prod_{k=1}^{j-1} (1 - r_{k})\\right) \\left(\\sum_{k=2}^{j} c(k, b_{k+1})\\right)\n\\end{equation}\nNotice that the product term now runs from $k = 1$ to $j-1$ as we multiply by $(1-r_1)$ and the inner-most summation has $c(k, b_{k+1})$ as we multiply by $\\theta$ (recall that $c$ is $\\theta$-simple).\n\nFinally we can express $\\Exp[B_m|c]$ in terms of $\\Exp[\\hat{B}_{m-1}|c]$ as follows (where $c_1 = c(1, b_1)$ for brevity):\n\\begin{eqnarray*} \n\\Exp[B_{m}|c]\n&=& \\sum_{j=1}^{m} Pr(j) \\left(\\sum_{k=1}^{j} c(k, b_k)\\right) \\\\\n&=& c_1 + \\left(\\sum_{j=2}^{m} r_j \\left(\\prod_{k=1}^{j-1} (1 - r_k)\\right) \\left(\\sum_{k=2}^{j} c(k, b_k)\\right) \\right) \\\\\n&=& c_1 + (1-r_1)\\theta \\Exp[\\hat{B}_{m-1}|c] \\\\\n&=& c(1, b_1) + \\left(\\prod_{t=1}^{b_1} (1-q_t) \\right)\\cdot \\theta \\cdot \\Exp[\\hat{B}_{m-1}|c] \n\\end{eqnarray*}\nThe first equality holds by definition of $\\Exp[B_{m}|c]$. The second equality is obtained by taking $c(1, b_1)$ out from the summation (and note that $Pr(j)$ adds up to 1) first and then applying Equation~\\ref{bdoodle:eqn:Pr_j}. The last two inequalities hold due to Equation~\\ref{bdoodle:eqn:ExpCost_Bhat} and \\ref{bdoodle:eqn:r_j}, respectively. \nThe last expression exactly  matches Equation~\\ref{bdoodle:eqn:recurrence} in the lemma.\n\\end{proof}\n\nUsing the recurrence relation in Lemma~\\ref{bdoodle:lemma:recurrence} and the computing method in Lemma~\\ref{bdoodle:lemma:q_t_polytime}, we can now design an efficient recursive algorithm finds the optimal B-Doodle mechanism. Our algorithm is presented in Algorithm~\\ref{bdoodle:alg:recursive} as a recursive method $Rec(x)$. We assume that the values of $q_t$ have been computed as a pre-processing step prior to running our algorithm, using the method in Lemma~\\ref{bdoodle:lemma:q_t_polytime}. We further assume that time slots are sorted in decreasing order of $q_t$ (i.e. $q_1 \\geq q_2 \\geq \\dots \\geq q_{s}$); therefore we simply refer to the time slot by its index (i.e. $t = 3$ refers to the third time slot in the sorted list of time slots).\n\nGiven $1 \\leq x \\leq s$, $Rec(x)$ returns optimal B-Doodle ($B^*$) that consists of time slots $\\{x, x+1, \\dots, s\\}$ and its expected cost ($EC^*$). To solve for a given instance of the problem, we simply call the method $Rec(x)$ with $x = 1$.\n\n\\begin{algorithm}\n\\caption{Recursive Algorithm: $Rec(x)$}\n\\label{bdoodle:alg:recursive}\n\\begin{algorithmic}[1]\n\t\\State ${B}^* \\gets \\langle s-x+1 \\rangle$, $EC^* \\gets c(1, s-x+1)$\n\t\\For{$b := 1, 2, \\dots, s-x$}\n\t\t\\State $({B}, EC) \\gets Rec( x+b )$\n\t\t\\State $EC_b \\gets c(1, b) + \\left(\\prod_{t=x}^{x+b-1} (1 - q_t)\\right)\\cdot \\theta \\cdot EC$\n\t\t\\If {$EC^* > EC_b$}\n\t\t\t\\State $EC^* \\gets EC_b$\n\t\t\t\\State $B^* \\gets \\langle b, {B} \\rangle$\n\t\t\\EndIf\n\t\\EndFor\n\t\\State \\textbf{return} $({B}^*, EC^*)$\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{theorem} \\label{bdoodle:thm:recursive_algo}\nAlgorithm~\\ref{bdoodle:alg:recursive} runs in polynomial time, and returns an optimal B-Doodle mechanism that minimizes the expected cost, given an instance $(N, S, f, c, P)$ of \\BDPs when $c$ is $\\theta$-simple.\n\\end{theorem}\n\\begin{proof}\nOur recursive method is very simple: given time slots $\\{x, x+1, \\dots, s\\}$, it iteratively considers the case of sending out $b$ time slots in the first iteration, and computes the expected cost $EC_b$ of doing so, for each $b$ with $1 \\leq b \\leq s-x+1$.  In line 1, our method checks for the trivial case when $b = s-x+1$ (i.e. all time slots are sent in a single batch); we store this mechanism in $B^*$ and its expected cost in $EC^*$. Then we iterate $b$ from $1$ to $s-x$ and compute the expected cost $EC_b$, and compare with the optimal expected cost found so far (lines 2-9). For each $b$, we first recursively compute the expected cost for the remaining time slots (namely, $\\{x+b, x+b+1, \\dots, s\\}$) by calling our method $Rec(x+b)$, and store the expected cost in $EC$ (line 3). Using Lemma~\\ref{bdoodle:lemma:recurrence} we can compute $EC_b$ as in line 4 (note that the first batch contains $b$ time slots from $x$ to $x+b-1$). In lines 5-8, we simply compare $EC_b$ with the current optimal, $EC^*$, and update if necessary; $\\langle b, B \\rangle$ should be interpreted as the concatenation of $b$ and $B$ into a single vector of integers. Finally in line 10, our method returns the optimal B-Doodle found, $B^*$ and its expected cost $EC^*$. \n\nWe prove correctness of the algorithm by induction on $x$ (from $x = s$ to $x = 1$). The base case is trivial: if $x = s$ the only B-Doodle mechanism is $\\langle 1 \\rangle$ and our method finds it in line $1$ and returns it in line $10$. Suppose our method correctly returns the optimal B-Doodle mechanism (and its expected cost) for all $x > k$ for some $k$ (the inductive hypothesis), and we prove for the case of $x = k$. When $x = k$, there are precisely $(s-k+1)$ time slots that are to be sent, and the first batch can contain any number of time slots between $1$ and $(s-k+1)$, inclusive. In lines 1-9 our method considers all such cases, and for each case it computes the expected cost correctly (in line 4) due to our inductive hypothesis and Lemma~\\ref{bdoodle:lemma:recurrence}. Therefore our method finds the optimal B-Doodle for all $x$ with $1 \\leq x \\leq s$; in particular when $x = 1$, it returns the desired optimal B-Doodle mechanism for the given problem instance.\n\nOur recursive method runs in polynomial time when we use memoization on $Rec(x)$ with respect to $x$; that is, for each $x$ we cache what $Rec(x)$ returns for the first time, and for any subsequence calls to $Rec(x)$ we simply return the cached values. Therefore lines 1-9 are executed at most once for each $x$ with $1 \\leq x \\leq s$. Also note that $Rec(x)$ makes a call to $Rec(x + b)$ with $b \\geq 1$ and $x+b \\leq s$, which means there are no infinite loops. Once $Rec(x)$ is computed for all $x > k$, it takes $O(|S|^2)$ time to compute $Rec(k)$, and thus the overall running time of our algorithm is $O(|S|^3)$ when we start with $Rec(1)$. Pre-processing steps (of computing $q_t$) also run in polynomial time due to Lemma~\\ref{bdoodle:lemma:q_t_polytime}.\n\\end{proof}\n\n\n\n\n\n\n\n\n\n\n\\section{Experimental Results} \\label{bdoodle:sec:Results}\n\nWe showed that we can find an optimal B-Doodle mechanism that minimizes the expected cost. But a very important question remains: Is our optimal B-Doodle substantially better than Doodle in realistic settings? If the answer is no, we do not have much incentive to discard the simplest mechanism, Doodle, over using our sophisticated algorithm. Intuitively we expect Doodle to be inefficient if there are many time slots (i.e., $s$ is large) because it causes much inconvenience for agents to examine the options. Reasoning further, we can also see that inefficiency of Doodle depends on the probability of each time slot being feasible (i.e. $q_t$ values), which in turn depends on $p_{i, t}$ values. If agents are relatively free, then a small number of time slots would be sufficient for finding a feasible time slot, which makes Doodle inefficient. Last but not least, the underlying cost function plays an important role as well. These all sound plausible, and we validate our intuition with simulation results.\n\nIn our setting there are many experimental choices one can choose from. In what follows we look at a representative example in which each agent is available for each time slot with the same probability of $p$; that is, $p_{i, t} = p$ for some constant $p$. (While in realistic situations the $p_{i, t}$'s may all differ, we  note that in our simulations  our results seem to carry over to these more general settings as well.) We present experimental results for each of the three cost functions discussed in Example~\\ref{bdoodle:eg:costFunctions}: The linear cost function, the time-averse cost function, and the inconvenience-averse function.\n\n\n% ===================== Linear Cost Function (Below) \n\n\\subsection{Linear Cost Functions} \\label{bdoodle:sec:result_linear_cost}\nRecall that the linear cost function is parameterized by some constant $\\alpha>0$ and that $c_{\\alpha}(j, b) = \\alpha + b$. We used $\\alpha = 2$ as an experimental choice, and we later discuss what we observed for different values of $\\alpha$.\n\nWe reasoned that Doodle becomes suboptimal when the number of time slots, $s$, gets large. Therefore it is interesting to know for what ranges of $s$, Doodle is suboptimal. For some fixed $(n, s, p)$, let $C^D(n, s, p)$ be the cost of Doodle and $C^*(n, s, p)$ be the expected cost of $B^*$. We want to find the smallest critical point $S^*(n, p)$ such that for any $s \\geq S^*(n, p)$ we have $C^D(n, s, p) > C^*(n, s, p)$. \n\nIn Table~\\ref{bdoodle:table:DoodleSuboptimal}, we show $S^*$ for various $(n, p)$ when $f = 1$ (i.e. the organizer requires everyone be available). For instance we find $S^*(6, .8) = 5$, which implies that Doodle is suboptimal for all $s \\geq 5$ given that $n=6$ and $p=.8$. The smaller $S^*$ is, the less practical Doodle is for the corresponding $(n, p)$. \nAcross the table we can observe that $S^*$ is small when $n$ is small and/or when $p$ is high -- this agrees with our intuition.  \nWe highlighted $8$ entries in boldface to emphasize that $S^* \\leq 15$; for the corresponding $(n, p)$ values, Doodle is suboptimal if there are $15$ or more time slots being considered.\n\\begin{table}[h!]  \n\t\\small\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|}\n\t\\hline\n\t$S^*$ & $n = 2$ & $n = 4$ & $n = 6$ & $ n = 10 $ & $n = 15$ \\\\ \\hline\n\t$p = .8$ & \\textbf{3} & \\textbf{4} & \\textbf{5} & \\textbf{8} & \\textbf{15} \\\\ \\hline\n\t$p = .5$ & \\textbf{5} & \\textbf{11} & 22 & 90 & $>300$\\\\ \\hline\n\t$p = .2$ & \\textbf{14} & 70 & $>300$ & $>300$ & $>300$ \\\\ \\hline\t\n\\end{tabular}\n\\caption{Critical point $S^*$ is shown for various values of $(n, p)$ when $f = 1, \\alpha = 2$. Entries in boldface emphasize that $S^* \\leq 15$.} \\label{bdoodle:table:DoodleSuboptimal}\n\\end{table}\n\nNot only do we want to know when Doodle is suboptimal, but we also want to know how inefficient Doodle is in realistic situations. For every fixed $(n, s, p)$, we can define {\\em efficiency of Doodle}, $e_{D}(n,s,p)$, as the ratio of the optimal expected cost to the cost of Doodle: $e_{D}(n,s,p) = C^*(n, s, p) / C^D(n, s, p)$. The smaller this value is, the less efficiency Doodle is compared to the optimal Batched Doodle, for any given $(n, s, p)$.\n\n\nIn Table~\\ref{bdoodle:table:DoodleEfficiency} we show $e_{D}$ for the same settings of $(n, p)$ we used in Table~\\ref{bdoodle:table:DoodleSuboptimal}. For this experiment we used $s = 15$ and $f = 1$. If $e_{D} = 1$ Doodle is optimal, and if $e_{D}$ is close to zero then Doodle is very inefficient. We find that $e_{D}(2, .8) = .270$, which implies that Doodle is very inefficient in this case; on the other hand $e_{D}(10, .5) = 1$, in which case Doodle is optimal. Across the table we observe the same pattern we observed before -- for small $n$ and high $p$, Doodle is substantially inefficient.\n\\begin{table}[h]  \n\t\\small\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\\hline\n\t$e_{D}$ & $n = 2$ & $n = 4$ & $n = 6$ & $ n = 10 $ & $n = 15$ \\\\ \\hline\n\t$p = .8$ & \\textbf{.270} & \\textbf{.361} & \\textbf{.486} & .777 & .986 \\\\ \\hline\n\t$p = .5$ & \\textbf{.502} & .904 & 1 & 1 & 1  \\\\ \\hline\n\t$p = .2$ & .970 & 1 & 1 & 1 & 1\\\\ \\hline\t\n\\end{tabular}\n\\caption{Efficiency of Doodle $e_{D}$ is shown for various values of $(n, p)$ when $f = 1, \\alpha=2, s = 15$. Entries in boldface emphasize that $e_{D} < .750$. } \\label{bdoodle:table:DoodleEfficiency}\n\\end{table}\n\nInefficiency of Doodle is more pronounced when the organizer has a lower feasibility threshold such as $f = .7$; in such case, only a fraction of agents need to be available. \nWe can clearly observe the worsened inefficiency of Doodle in Table~\\ref{bdoodle:table:DoodleEfficiency-lower-attendance}. \nHere we show $e_{D}$ values for the same set of $(n, p)$ as in Table~\\ref{bdoodle:table:DoodleEfficiency} but with $f = .7$. \nPreviously we highlighted four entries with $e_{D} < .750$ when $f = 1$ in Table~~\\ref{bdoodle:table:DoodleEfficiency}; when $f = .7$ the number of entires with $e_{D} < .750$ doubled to eight. \nNote that the first column is identical between the two tables; this is because $f = .7$ still requires both agents to be available when $n = 2$. \nAlso notice that $e_{D}$ is surprisingly low in the first row of Table~\\ref{bdoodle:table:DoodleEfficiency-lower-attendance} across all columns. This shows that regardless of the number of invitees, Doodle is significantly inefficient when the invitees are highly available ($p \\geq .8$) and the organizer has a relaxed feasibility threshold.\n\\begin{table}[h]  \\small\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\\hline\n\t$e_{D}$ & $n = 2$ & $n = 4$ & $n = 6$ & $ n = 10 $ & $n = 15$ \\\\ \\hline\n\t$p = .8$ & \\textbf{.270} & \\textbf{.215} & \\textbf{.267} & \\textbf{.201} & \\textbf{.211} \\\\ \\hline\n\t$p = .5$ & \\textbf{.502} & \\textbf{.434} & .772 & \\textbf{.628} & .913  \\\\ \\hline\n\t$p = .2$ & .970 & 1 & 1 & 1 & 1\\\\ \\hline\t\n\\end{tabular}\n\\caption{Efficiency of Doodle $e_{D}$ is shown for various values of $(n, p)$ when $f = .7, \\alpha=2, s = 15$.  Entries in boldface emphasize that $e_{D} < .750$. } \\label{bdoodle:table:DoodleEfficiency-lower-attendance}\n\\end{table}\n\nWe ran experiments with different values of $(n, s, p, f, \\alpha)$, and observed the same  trends that are presented here.\n\n\n% ===================== Other Cost Functions (Below) \n\n%\\balancecolumns\n\\subsection{Other Cost Functions}\nWe now consider the time-averse cost function and the inconvenience-averse cost function. As the names suggest, the former places more weight on optimizing \\Time, while the latter on optimizing \\Inconvenience.  For the time-averse cost function (recall $c_{\\beta}(j, b) = \\beta^j \\cdot b$), we chose $\\beta = 2$ as an experimental choice. Notice that the cost increases exponentially for later iterations, which forces the organizer to send out a small number of batches (as in Doodle). We ran the same set of experiments as before to measure efficient of Doodle, $e_{D}$. \n\nThe result is summarized in Table~\\ref{bdoodle:table:DoodleEfficiency-lower-attendance_time_averse}, which shows the same trends as we observed in previous experiments. Notice that in the first row ($p = .8$), as $n$ increases we expect $e_{D}$ to decrease, but $e_{D}$ fluctuates while decreasing in general. The fluctuation is due to the rounding of attendance requirement ($\\lceil a \\cdot n \\rceil$). For instance when $n = 4$, $\\lceil a \\cdot n \\rceil$ = 3 which effectively requires 75\\% of attendees be available. \n\\begin{table}[h]  \\small\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\\hline\n\t$e_{D}$ & $n = 2$ & $n = 4$ & $n = 6$ & $ n = 10 $ & $n = 15$ \\\\ \\hline\n\t$p = .8$ & \\textbf{.180} & \\textbf{.104} & \\textbf{.175} & \\textbf{.088} & \\textbf{.099} \\\\ \\hline\n\t$p = .5$ & \\textbf{.561} & \\textbf{.457} & .876 & \\textbf{.726} & .987  \\\\ \\hline\n\t$p = .2$ & 1 & 1 & 1 & 1 & 1\\\\ \\hline\t\n\\end{tabular}\n\\caption{Efficiency of Doodle $e_{D}$ is shown for various values of $(n, p)$ when $f = .7, \\beta=2, s = 15$.\nEntries in boldface emphasize that $e_{D} < .750$.\n} \\label{bdoodle:table:DoodleEfficiency-lower-attendance_time_averse}\n\\end{table}\n\nFor the inconvenience-averse cost function (recall $c_{\\gamma}(j, b) = \\gamma^{b}$), we chose $\\gamma = 1.1$ as an experimental choice. Because the cost function is an exponential function of $b$, an optimal B-Doodle must send out small-size batches even though $\\gamma$ is small. We ran the same set of experiments as before to measure efficiency of Doodle, $e_{D}$. \n\nThe result is summarized in Table~\\ref{bdoodle:table:DoodleEfficiency-lower-attendance_inconvenience_averse}. Notice that $e_{D}$ is not equal to $1$ even when $p = .2$ in this setting, which we did not observe with the other cost functions previously. Due to integer-rounding, we again observe some fluctuations in $e_{D}$ across columns within the same row, but the general trend is that $e_{D}$ decreases as $n$ increases.\n\\begin{table}[h]   \\small\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\\hline\n\t$e_{D}$ & $n = 2$ & $n = 4$ & $n = 6$ & $ n = 10 $ & $n = 15$ \\\\ \\hline\n\t$p = .8$ & \\textbf{.333} & \\textbf{.299} & \\textbf{.329} & \\textbf{.294} & \\textbf{.298} \\\\ \\hline\n\t$p = .5$ & \\textbf{.499} & \\textbf{.450} & \\textbf{.695} & \\textbf{.592} & .799  \\\\ \\hline\n\t$p = .2$ & .850 & .887 & .974 & .976 & .980 \\\\ \\hline\t\n\\end{tabular}\n\\caption{Efficiency of Doodle $e_{D}$ is shown for various values of $(n, p)$ when $f = .7, \\gamma=1.1, s = 15$.\nEntries in boldface emphasize that $e_{D} < .750$.\n} \\label{bdoodle:table:DoodleEfficiency-lower-attendance_inconvenience_averse}\n\\end{table}\n\n%\\balancecolumns\n\n\\subsection{Summary of Experiments}\nAlthough we only presented experimental results with specific values of $(n, s, p, f)$ and parameters $(\\alpha, \\beta, \\gamma)$, we observed that Doodle is in general substantially inefficient, including (but not limited to) when one or more of the following conditions hold:\n\\begin{itemize} \n\t\\item There is a relatively small number of agents ($n \\leq 10$).\n\t\\item There is a large number of time slots ($s \\geq 15$).\n\t\\item Agents are relatively free ($p > .5$).\n\t\\item Feasibility threshold is relaxed ($f < .8$).\n\t\\item The cost function places more weight on \\Inconveniences than \\Times ($\\alpha < 20$, $\\beta < 5$, or $\\gamma > 1.05$).\n\\end{itemize}\n\nIntuitively the first four conditions affect $q_t$ (the probability that time slot $t$ is feasible) in the same way. If $q_t$ is higher, then Doodle is more likely to become more inefficient because there is no need to poll everyone about every date/time option -- a subset of the options would suffice. In such cases B-Doodle has advantages in that it reduces inconvenience of all agents. The last condition is independent of $q_t$, yet it is clear that Doodle should be inefficient if the cost function we are optimizing favors reducing \\Inconveniences over reducing \\Time. Given our experimental results, it is clear that under the right circumstances, B-Doodle is superior in optimizing \\Times and \\Inconvenience. \n\n\n\\section{Discussion} \\label{bdoodle:sec:Discussion}\n\nWe identified and formally defined two dimensions of optimality in\ngroup scheduling : \\Times and \\Inconvenience. We generalized the popular\nDoodle mechanism to a class of B-Doodle mechanisms that partition time\nslots into batches. We showed an example of the Pareto-frontier of\nB-Doodle mechanisms on the \\Time-\\Inconveniences dimensions. We then\ndescribed an efficient algorithm for finding an optimal B-Doodle\nmechanisms, given a simple cost function that aggregates \\Times and\n\\Inconvenience, assuming probabilistic independence among availability \nof agents. We showed in simulations that an optimal B-Doodle mechanism \nis superior to Doodle in realistic situations, sometimes greatly so.\n\nWhile useful in and of itself, our work described in this chapter leaves open many questions.\nHere we focused on a class of B-Doodle mechanisms which allow the event organizer to poll all invitees on a batch of date/time options. In some settings, it may be more desirable for the organizer to poll some invitees on some date/time options -- for instance, when scheduling a defense of dissertation in the computer science department of Stanford University, it is desirable to poll availability of the advisor and committee chair before polling other participants because the advisor and committee chair must be physically present while others can join remotely. In the very next chapter, we generalize the Batched Doodle Problem by considering such settings. \n\nIn addition, we implicitly assumed that agents prefer all time slots equally (by\nallowing agents to specify their availability but not preferences),\nbut people often have specific preferences. Thus it will be important\nto study the trade-off between optimizing the cost of scheduling\nprocess and finding a `good' schedule.\n\nFinally, we assumed honesty, promptness, and trust of invitees, but\nthese are strong assumptions. In particular, promptness assumes that\ninvitees do not procrastinate and do not deliberately delay responses.\nIt is arguably true that if the scheduling process is efficient then\nit will indeed reduce the procrastination of invitees. However in\npractice an invitee may have an incentive to delay her response or to\nlie about her availability or preferences. Practical mechanisms should\nnot be vulnerable to such strategic behavior of invitees, and this is\nyet another direction for future work.\n\n\\section*{Publications}\nSome of the contents of this chapter were published and included in the proceedings of the 2014 International Conference on Autonomous Agents and Multi-Agent Systems (AAMAS) as extended abstracts~\\cite{lee2014algorithmic,lee14doodle}.\n", "meta": {"hexsha": "1a7966f642b18951bd1d3e4f7444e26847ee6537", "size": 51852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main/200_BDoodle.tex", "max_stars_repo_name": "ltdtl/thesis", "max_stars_repo_head_hexsha": "b1585aa3e57e06b4368fb51540bbbf1c64c491df", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-18T17:20:45.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-18T17:20:45.000Z", "max_issues_repo_path": "main/200_BDoodle.tex", "max_issues_repo_name": "ltdtl/thesis", "max_issues_repo_head_hexsha": "b1585aa3e57e06b4368fb51540bbbf1c64c491df", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-01-29T07:21:01.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-29T07:21:01.000Z", "max_forks_repo_path": "main/200_BDoodle.tex", "max_forks_repo_name": "ltdtl/thesis", "max_forks_repo_head_hexsha": "b1585aa3e57e06b4368fb51540bbbf1c64c491df", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.4722792608, "max_line_length": 1427, "alphanum_fraction": 0.7324693358, "num_tokens": 14870, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.4432500229178186}}
{"text": "%%\n%% Author: novitoll\n%% 3/8/18\n%%\n\n% Preamble\n\\documentclass[11pt]{article}\n\n% Packages\n\\usepackage{amsmath}\n\\usepackage{enumitem}\n\n\\title{CVT: Lecture 5}\n\\date{2018-03-08}\n\\author{Novitoll}\n\n\\begin{document}\n    \\maketitle\n    \\pagenumbering{arabic}\n\n    \\section{Taylor formula} \\label{sec:taylorformula}\n\n    \\begin{align}\n        f(x) = f(0) + O(1)\n    \\end{align}\n\n    Given parameter, compute its derivative and so you can \"convert\" the original function to Taylor\n    \\[\n        f'(x) = f'(0) + O(1) --> \\int_{0}^{x} ... dx\n    \\]\n\n    So basic Taylor formula is:\n    \\begin{multline*}\n        f(x) = f(0) + f'(0)x + f''(0)\\frac{x^2}{2} \\\\\n            + f'''(0)\\frac{x^3}{6} + f^{IV}(0)\\frac{x^4}{24} + f^n(0)\\frac{x^n}{n!} + O(x^n)\n    \\end{multline*}\n\n    Example:\n    \\begin{gather*}\n        f(x) = x^2 + 3x + 6 \\\\\n        f(0) = 6; f'(0) = 3; f''(0) = 2; f'''(0) = 0; f^n(0) = 0, n > 2 \\\\\n        Taylor: f(x) = 6 + 3x + 2\\frac{x^2}{2}\n    \\end{gather*}\n\n    \\section{Optical flow in general} \\label{sec:optflowgeneral}\n\n    Given x, y coordinate of some pixels in image (assuming that we are dealing with the only RGB pixels) in given t time,\n    we can process the next image's pixels x, y coordinate in some $t + 1$ time\n\n    \\begin{enumerate}\n        \\item Constant color\n    \\end{enumerate}\n\n    \\begin{gather*}\n        I_1(x, y, t) \\\\\n        I_2(x + u, y + v, t + 1) \\\\\n        O = I(x + u, y + v, t + 1) - I(x, y, t)\n    \\end{gather*}\n\n    Let's put it to Taylor formula, assuming that we will neglect with high order derivatives due to non-significant bias of pixels.\n\n    \\begin{enumerate}[resume]\n        \\item Small motion\n    \\end{enumerate}\n\n    \\begin{gather*}\n        I(x + u, y + v) = I(x, y) + \\frac{\\partial{I}}{\\partial{x}}u + \\frac{\\partial{I}}{\\partial{y}}v\n    \\end{gather*}\n    \\begin{multline}\n        O \\approx I(x, y, t + 1) + \\frac{\\partial{I}}{\\partial{x}}u + \\frac{\\partial{I}}{\\partial{y}}v - I(x, y, t) \\\\\n            \\approx [I(x, y, t + 1) - I(x, y, t)] + .. \\\\\n            \\approx \\frac{\\partial{I}}{t} + \\frac{\\partial{I}}{\\partial{x}}u + \\frac{\\partial{I}}{\\partial{y}}v\n    \\end{multline}\n\n    , which can be also exposed as $\\frac{\\partial{I}}{t} + \\det{I} \\times <u, v>$,\n    e\\.g\\. time derivative + multiplication of image gradient and vector of motion u, v per x, y axis.\n\n    \\section{Lucas-Kanade optical flow (1981)} \\label{sec:lucaskanade}\n\n    Adding here additional assumption:\n\n    \\begin{enumerate}[resume]\n        \\item Uniform motion of pixels\n    \\end{enumerate}\n\n    Assume that you have a pixel x and you take it as 3x3 matrix with surrounded other pixels,\n    assuming that they are similar (in real life this is true for the object, probably not true for micro objects like\n    bacteria)\n\n    , then your formula (2) is true for 3x3 matrix, e.g.:\n\n    \\[\n        \\begin{bmatrix}\n            I_x(p_1) & \\dots & I_y(p_1) \\\\\n            I_x(p_2) & \\dots & I_y(p_2) \\\\\n            \\vdots & \\ddots & \\vdots \\\\\n            I_x(p_9) & \\dots & I_y(p_9)\n        \\end{bmatrix}\n        \\times\n        \\begin{bmatrix}\n            u & v\n        \\end{bmatrix}\n        = -\n        \\begin{bmatrix}\n            I_t(p_1) \\\\\n            I_t(p_2) \\\\\n            \\vdots   \\\\\n            I_t(p_9)\n        \\end{bmatrix}\n    \\]\n\n    Let's name the matrix in A, d, b:\n\n    \\[\n        A_{9x2} \\times d_{2x1} = B_{9x1}\n    \\]\n\n    and now we want to\n\n    \\[\n        minimize => \\lVert{Ad - b}\\rVert^2\n    \\]\n\n    \\subsection{Eigenvalue and eigenvector} \\label{subsec:eigenvv}\n\n    Recap eigenvalue and eigenvector of linear transformation:\n    \\begin{gather*}\n        T(\\vec{v}) = \\lambda\\vec{v} \\\\\n        , where \\ \\vec{v} - eigenvector, \\ \\lambda - eigenvalue, e.g. some scalar\n    \\end{gather*}\n\n\n\n\\end{document}", "meta": {"hexsha": "179f26c106e78a6cae480123added60565a3a755", "size": 3760, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "w5l1/notes.tex", "max_stars_repo_name": "Novitoll/cvt-academy-2018", "max_stars_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-02-28T10:37:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T08:51:32.000Z", "max_issues_repo_path": "w5l1/notes.tex", "max_issues_repo_name": "Novitoll/cvt-academy-2018", "max_issues_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "w5l1/notes.tex", "max_forks_repo_name": "Novitoll/cvt-academy-2018", "max_forks_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0597014925, "max_line_length": 132, "alphanum_fraction": 0.5497340426, "num_tokens": 1285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177486, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.4432500195250987}}
{"text": "\\input{permve-ntnu-latex-assignment.tex}\n\n\\usepackage{float}\n\n\\title{\n\\normalfont \\normalsize\n\\textsc{Norwegian University of Science and Technology\\\\IT3105 -- Artificial Intelligence Programming}\n\\horrule{0.5pt} \\\\[0.4cm]\n\\huge Module 1:\\\\Implementing and Testing the\\\\A* Algorithm on a Navigation Task\\\\\n\\horrule{2pt} \\\\[0.5cm]\n}\n\n\\author{Per Magnus Veierland\\\\permve@stud.ntnu.no}\n\n\\date{\\normalsize\\today}\n\n\\newacro{BFS}{Breadth First Search}\n\\newacro{DFS}{Depth First Search}\n\n\\begin{document}\n\n\\fancyfoot[C]{}\n\\maketitle\n\n\\newpage\n\\fancyfoot[C]{\\thepage~of~\\pageref{LastPage}} % Page numbering for right footer\n\\setcounter{page}{1}\n\n\\section*{Search agenda}\n\nThe search agenda, also known as the ``open list'' is used to maintain generated search nodes which have not yet been expanded. When popping a search node from the ``open list'' it is checked whether the state associated with the search node is a goal state. If it is a goal state the search completes; otherwise the search node is expanded and successor states are generated -- adding unique successor states to the ``open list''. Search nodes which have been expanded are added to a ``closed list'' to keep track of previously examined states.\n\nThe important operations relating to the ``open list'' are:\n\\begin{enumerate*}\n\\item testing if a state exists in the list\n\\item adding new search nodes to the list\n\\item removing the search node with the lowest $f$-value\n\\end{enumerate*}.\n\nTo implement these operations efficiently both a hash map and a heap queue are maintained to keep track of the ``open list''. It is required that objects representing state implement a hashing operation and an operation to test for equality. The hash map is used to allow testing if a state exists in the ``open list'' in O$(1)$ time; while the heap queue is used to efficiently keep track of the search node with the lowest $f$-value. The heap queue allows insertion of a search node and extraction of the search node with lowest $f$-value in O$(\\log(n))$ time.\n\nAn important note is that when a better path is found to an existing search node; the path cost of the existing search node must be updated and propagated. Since this may change the $f$-value of search nodes on the ``open list'' the heap queue must be re-heapified; an operation which takes O$(n)$ time.\n\nThe ``closed list'' does not need to keep track of $f$-values and must only support testing for membership and adding new search nodes efficiently. It is maintained using a hash map.\n\nPartly for the assignment and partly for fun; the strategy employed by the \\texttt{BestFirst} search class can be changed mid-search between \\ac{BFS}, \\ac{DFS}, Dijkstra's algorithm and A*. When using \\ac{BFS} and \\ac{DFS} the ``open list'' is maintained as a double ended queue, also known as a deque, to allow adding and removing elements from both ends of the queue in O$(1)$ time. The search nodes on the ``open list'' will be correctly moved between the priority queue and the double ended queue used in the ``open list'' when switching strategies.\n\n\\section*{Generality of program}\n\nWhen starting work on the three first modules in the \\textsc{IT3105} course I decided to do all software in the Python language as it allows for easy prototyping and development as well as the ability to write readable software. The codebase is split into a file hierarchy with some of the classes central to the module~1 problem shown in Figure~\\ref{figure:vi_classes}.\n\nAny problem can be used with the \\texttt{BestFirst} search class if it provides the following interface:\n\n\\begin{itemize}\n\\item \\texttt{goal\\_test(state)} -- Evaluates whether the given search space state is a goal state. Must return a truthy type. This method is called directly by the \\texttt{BestFirst} class.\n\\item \\texttt{heuristic(state)} -- \\textit{(Optional)} A method calculating the estimated heuristic value for the provided search space state. This method is only called from the search node class. If this method is not available heuristic values will always be zero.\n\\item \\texttt{initial\\_node()} -- Returns a search node representing the initial search space state. This method is called directly by the \\texttt{BestFirst} class. This method may return \\texttt{None} if no valid first search space state is available for the \\texttt{Problem}.\n\\item \\texttt{solution(node)} -- \\textit{(Optional)} Returns a \\texttt{Solution} object built from the given search node. When this method is not provided by \\texttt{Problem} class, the \\texttt{BestFirst} will default to a \\texttt{Solution} class which builds a solution path based on the assumption that each search node has an action and a parent search node.\n\\item \\texttt{successors(node)} -- Generates all successors for a given node by applying all valid operators. This method is called directly by the \\texttt{BestFirst} class.\n\\end{itemize}\n\nThe domain-specific \\texttt{Problem} class is responsible for instantiating all search nodes, successor objects and solution objects. If it is necessary for the problem; custom implementations can be used for all of these objects as long as they follow the same interface as the \\texttt{vi.search.graph.Node}, \\texttt{vi.search.graph.Successor} and \\texttt{vi.search.graph.Solution} classes.\n\n\\begin{figure}[H]\n\\includegraphics[scale=0.7]{images/vi_class_hierarchy}\n\\caption{VI Python library classes}\n\\label{figure:vi_classes}\n\\end{figure}\n\n\\section*{Heuristic function}\n\nThe central component of the A* search is the heuristic function which estimates the path cost from a given search space state to the goal state. To guarantee that an A* search finds an optimal solution, the heuristic function must be admissible, meaning that it must never overestimate the path cost to the goal state.\n\nTwo popular heuristics for the grid search problem is the Manhattan distance and the Euclidean distance. The Manhattan distance is given by $\\textit{abs}(g_x - s_x) + \\textit{abs}(g_y - s_y)$ where $g$ is the goal state and $s$ is the given state. Given our grid problem where only vertical and horizontal movement is allowed, the Manhattan distance is not only an admissible heuristic, but also a perfect heuristic since its value will always be the shortest path between a cell in the grid and the goal cell. However since our problem also includes obstacles, the heuristic estimate will not always match the actual path cost as it assumes that all grid cells are traversable.\n\nThe Euclidean heuristic uses the straight-line distance between two grid cells as the estimate to the goal. It is given by $\\sqrt{(g_x - s_x)^2 + (g_y - s_y)^2}$. It is an admissible heuristic for the problem, but it will underestimate the cost to the goal whenever the starting cell is on a different row or column than the goal.\n\nTable~\\ref{table:vi_generated_nodes} shows the Manhattan heuristic outperforming the Euclidean heuristic in all scenarios. If the problem was modified to allow diagonal movements the heuristics would be more equal in their performance.\n\n\\begin{table}\n\\centering\n\\begin{tabular}{c|ccccc}\nScenario & BFS & DFS & Dijkstra & A* Manhattan & A* Euclidian \\\\\n\\hline\n0        &  73 &  73 &       73 &           73 &           73 \\\\\n1        & 291 & 296 &      293 &          190 &          256 \\\\\n2        & 344 & 282 &      344 &          215 &          341 \\\\\n3        &  57 &  50 &       56 &           44 &           50 \\\\\n4        &  62 &  58 &       62 &           58 &           59 \\\\\n5        & 273 & 227 &      271 &          233 &          246 \\\\\n\\end{tabular}\n\\caption{Nodes generated for different search strategies}\n\\label{table:vi_generated_nodes}\n\\end{table}\n\n\\section*{Generating successor states}\n\n``A.I. -- A Modern Approach'' suggests an interface between the search and the problem consisting of the functions \\texttt{problem.ACTIONS(node.STATE)}, \\texttt{problem.RESULT(parent.STATE, action)} and \\texttt{problem.STEP-COST(parent.STATE, action)}. After initially attempting to follow the same abstraction I found it problematic since the work involved in the operations can for many problems be overlapping. For example generating the list of valid actions for a state in the grid problem requires generating the resulting states.\n\nMy attempt at a more general interface is a single \\texttt{problem.SUCCESSORS} function which does not return a list of successor nodes; but which generates \\texttt{Successor} objects representing each valid successor to the given search node. The \\texttt{Successor} object contains all information necessary to construct the corresponding \\texttt{Node} object, as well as the step cost from the parent node to the successor node.\n\nThe \\texttt{Successor} abstraction makes it possible to avoid building \\texttt{Node} objects when the successor state is not unique. When adding the newly created or existing node object representing the successor state as a child in the parent node; the action and step cost needed to reach the child are also stored. Whenever a child node is later reattached to a parent node the step cost and action information will already be available.\n\nBuilding the right trade-offs in the interface between what is computationally efficient and memory-efficient will depend on the problem. The focus in this abstraction has been on semantic correctness and avoiding redundant computation.\n\n\\end{document}\n\n", "meta": {"hexsha": "bf725af2271a71e108bb72d1ccc9e1062ef90cdb", "size": 9357, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "module_1/report/permve-ntnu-it3105-module-1.tex", "max_stars_repo_name": "pveierland/permve-ntnu-it3105", "max_stars_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "module_1/report/permve-ntnu-it3105-module-1.tex", "max_issues_repo_name": "pveierland/permve-ntnu-it3105", "max_issues_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module_1/report/permve-ntnu-it3105-module-1.tex", "max_forks_repo_name": "pveierland/permve-ntnu-it3105", "max_forks_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.6388888889, "max_line_length": 678, "alphanum_fraction": 0.7619963664, "num_tokens": 2180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.44317261983126344}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\begin{document}\n\n\\title{Principle of Statistics (continued) }\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\nIn the previous lecture, we saw that for a bootstrap sample $(X_1^b,...,X_n^b)$ drawn from $\\P_n( \\mid X_1,...,X_n)$, we have $\\sup_{t \\in \\R} | \\P_n(\\sqrt{n} (\\bar{X}_n^b - \\bar{X}_n) \\leq t(X_1,...,X_n) - \\Phi(t) | \\xrightarrow{a.s.} 0$ as $n \\to \\infty$, where $\\Phi(t) = \\P(Z \\leq t)$, $Z \\sim N(0,\\sigma^2)$.\n\n\\begin{rem}\nAs in the B.vM theorem, this theorem can be used to show that $\\P(\\mu \\in \\mathcal{C}_n) \\to 1-\\alpha$ when $n \\to \\infty$.\n\\end{rem}\n\nIdea: For fiexd $(X_i)_{i \\geq 1}$, $\\P_n(\\mid X_1,...,X_N)$ is a sequence of distributions. Considering the $X_i$ as independent random variables drawn from $P$ allows us to make statements \"with randomness\". The idea is to fix a sequence $X_i$ (equivalent to fix $\\omega$ in the original probability space) if we can show that $\\sup_{t \\in \\R} |\\P_n(...\\mid X_1,...,X_n) - F(t)| \\to 0$ \"for almost all $\\omega\"$, then we have almost sure convergence.\n\n\\begin{lemma}\nIf $A_n \\sim f_n \\xrightarrow{d} A \\sim f$, and $F$ is continuous (c.d.f of $f$), then $\\sup|F_n(t) - F(t)| \\to 0$ as $n \\to \\infty$.\n\\begin{proof}\nBy continuity of $F$, there exists points $-\\alpha_0 = x_0 < x_1 < ... < x_k = +\\infty$ such that $F(x_i) = \\frac{i}{k}$. Then for every $x \\in [x_{i-1},x_i]$, $F_n(x) - F(x) \\leq F_n(x_i) - F(x_{i-1}) = F_n(xi)-F(x_i) + \\frac{1}{k}$, and $F_n(x) - F(x) \\geq F_n(x_{i-1}) - F(x_i) = F_n(x_{i-1}) - F(x_{i-1}) - \\frac{1}{k}$. For $k$ large enough, $\\frac{1}{k} < \\frac{\\varepsilon}{2}$, for $n$ large enough (dependes on $k$), we have $\\max_{0 \\leq i \\leq k} |F_n(x_i) - F(x_i)| < \\varepsilon/2$ (pointwise convergence) (dependes on $k$), we have $$\\max_{0 \\leq i \\leq k} |F_n(x_i) - F(x_i)| < \\varepsilon/2$$ (pointwise convergence). As a consequence, $$\\sup_{x \\in \\R} |F_n(x) - F(x)| \\leq \\max_{0 \\leq i \\leq k} |F_n(x_i) - F(x_i)| + \\frac{1}{k}<\\varepsilon$$\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}\nThe sequence $(Z_{n,i},i=1,...,n)_{n \\geq 1}$ is a triangular array of i.i.d. random variables if:\\\\\n$\\bullet$ For all $n \\geq 1$, $(Z_{n,1},...,Z_{n,i},...,Z_{n,n})$ is a sequence of i.i.d. random variables;\\\\\nFor example, $Z_{11} = (Z_{1,i})$,\\\\\n$Z_{21},Z_{22} = (Z_{2,i})$,\\\\\n...,\\\\\n$Z_{n,1},...,Z_{n,n} = (Z_{n,i})$.\\\\\nWe need independence on each line, but not across the lines. We don't need even need the same distribution at each line.\n\\end{defi}\n\n\\begin{prop} (CLT for triangular arrays)\\\\\nLet $(Z_{n,i};i=1,...,n)$ be a triangular array of iid random variables, each with finite variance. We have $Var_{Q_n}(Z_{n,i}) = \\sigma_n^2 \\to \\sigma_2$ as $n \\to \\infty$, each line consists of $n$ independent draws from $Q_n$. Then, under the following hypotheses (1-3), we have $$\\sqrt{n} (\\frac{1}{n} \\sum_{i=1}^n Z_{n,i} - \\E_{Q_n} [Z_{n,i}])\\xrightarrow{d} N(0,\\sigma^2)$$\n(1) $\\forall \\delta>0$, $n Q_n (|Z_{n,1}|>\\sqrt{n}\\delta) \\to 0$ as $n \\to \\infty$;\\\\\n(2) $Var(Z_{n,1} 1\\{|Z_{n,1}|\\leq \\sqrt{n}\\}) \\to \\sigma^2$ as $n \\to \\infty$;\\\\\n(3) $\\sqrt{n} \\E [Z_{n,1} 1\\{|Z_{n,1}| > \\sqrt{n}\\}] \\to 0$ as $n \\to \\infty$.\\\\\n(The statement of these assumptions is not examinable.)\n\\begin{proof} (of the main theorem)\\\\\nFix $(X_i)_{i \\geq 1}$ (equivalent to fix $\\omega$ in the original probability space). Under $Q_n = \\P_n(\\cdot \\mid X_1,...,X_n)$, $Z_{n,i} = X_i^{b(n)}$ (bootstrap on $n$ observations), $\\E_n[Z_{n,i}] = \\E_{\\P_n} [X_i^{b(n)}] = \\bar{X}_n$. Then, the $(X_i^{b(n)};i=1,...,n)_{n \\geq 1}$ are a triangular array of i.i.d. variables. We have that $$Var_{\\P_n}(X_i^{b(n)}) = \\E_{\\P_n} [X_i^{b(n)^2}] - (\\E_{\\P_n} [X_i^{b(n)}])^2 = \\frac{1}{n}\\sum_{i=1}^n X_i^2-(\\frac{1}{n}\\sum_{i=1}^n X_i)^2 = \\sigma_n^2$$ by definition of $\\P_n(\\mid X_1,...,X_n)$. For almost all the $\\omega$, or almost all infinite sequences, $\\sigma_n^2 \\to \\sigma^2$, and hypotheses (1-3).\\\\\n$\\bullet$ By the CLT for triangular arrays, we have that $$\\sqrt{n} (\\bar{X}_n^{b(n)} - \\bar{X}_n) \\xrightarrow{d} N(0,\\sigma^2)$$ as $n \\to \\infty$ 'for almost all $\\omega$'.\\\\\n$\\bullet$ By lemma, $$\\sup_{t \\in \\R} | \\P_n (\\sqrt{n} (\\bar{X}_n^{b(n)} - \\bar{X}_n) \\leq t) - \\Phi(t)| \\geq 0$$ as $n \\to \\infty$ 'for almost all $\\omega$', meaning that it $\\xrightarrow{a.s.} 0$.\n\\end{proof}\n\\end{prop}\n\n\\begin{rem}\n$\\bullet$ This shows the validity of the bootstrap confidence interval for the mean.\\\\\n$\\bullet$ In genral, this can be extended to estimation of $\\theta$: Sampling from $\\P_n$ as for the mean, and compute the bootstrap MLE $\\hat{\\theta}_n^b = \\hat{\\theta} (X_1^b,...,X_n^b)$ then using $\\sqrt{n}(\\hat{\\theta}_n^b - \\hat{\\theta}_n)$ as a proxy for $\\sqrt{n} (\\hat{\\theta}_n - \\theta_0)$, we will have similar results that show that taking $R_n$ such that $$\\P_n(||\\hat{\\theta}_n^b - \\hat{\\theta}_n|| \\leq \\frac{R_n}{\\sqrt{n}} \\mid X_1,...,X_n) = 1-\\alpha$$ can be used to construct a valid confidence region.\\\\\nThis approach is known as the non-parametric bootstrap.\\\\\nAnother approach is to do the same thing with $X_1^b,...,X_n^b \\sim \\P_{\\hat{\\theta}_n}$, same types of results will hold.\n\\end{rem}\n\nLast lecutre on Monday. \\emph{No} Lecture on Wednesday!\n\n\\subsection{Monte-Carlo methods}\nIn statistics, we often cannot explicityl compute expectation/integrals, which can be problematic when:\\\\\n$\\bullet$ We want to obtain a posterior distribution;\\\\\n$\\bullet$ We want to obtain a posterior mean;\\\\\n$\\bullet$ We want to compute quantiles of a distribution.\n\nOne of the ideas of Monte-Carlo methods is to replace explicitly computation by \\emph{simulations}Last lecutre on Monday. \\emph{No} Lecture on Wednesday!\n\n\\subsection{Monte-Carlo methods}\nIn statistics, we often cannot explicityl compute expectation/integrals, which can be problematic when:\\\\\n$\\bullet$ We want to obtain a posterior distribution;\\\\\n$\\bullet$ We want to obtain a posterior mean;\\\\\n$\\bullet$ We want to compute quantiles of a distribution.\n\nOne of the ideas of Monte-Carlo methods is to replace explicitly computation by \\emph{simulations}. One of the first challenges is to draw from a given, general distribution.\n\n\\begin{defi}\nA pseudorandom generator provides independent $U_i^{*} \\sim Unif(0,1)$.\n\\end{defi}\n\n\\begin{rem}\nThey are generated such that for all practical uses, $P(U_1^* \\leq u_1,...,U_N^* \\leq u_n) = \\prod_{i=1}^N u_i$ (up to 'machine precision'). Here it can be thought of as a blackbox that outputs i.i.d. uniform numbers -- this can be used as a starting point to generate other variables.\n\\end{rem}\n\n\\begin{prop}\nThe random variables $K_i = \\sum_{k=1}^n k 1_{(\\frac{k-1}{n},\\frac{k}{n}]} (U_i^*)$ are i.i.d. uniform on $\\{1,...,n\\}$.\n\\begin{proof}\n$K_i$ is clearly uniform on $\\{1,...,n\\}$, as each segment has length $\\frac{1}{n}$. They are independent as functions of independent random variables $U_i^*$. \n\\end{proof}\n\\end{prop}\n\\begin{rem}\nAssigining other values to each of the intervals with uniform distribution on any set of size $n$. In particular, we can simulate bootstrap samples by writing $$X_i^b = \\sum_{k=1}^n X_k 1_{(\\frac{k-1}{n},\\frac{k}{n}]} (U_i^*)$$ If the intervals are chosen with different lengths, we can generate any discrete distribution. For a general distribution with cdf $F$, we can generalize this idea.\n\\end{rem}\n\n\\begin{defi}\nFor a general cdf $F$, we define the generalized inverse of $F$ as $$F^-(u) = \\inf \\{x: u \\leq F(x)\\}$$\n\\end{defi}\n\n\\begin{rem}\nFor a fixed value $t \\in \\R$, the function $F$ gives $F(t) \\in [0,1]$ a probability $\\P(X \\leq t)$. For a fixed value $u \\in [0,1]$, the function $F$ gives $t = F^- (u)$ such that approximately $\\P(X \\leq t) = u$.\n\\end{rem}\n\n\\begin{prop}\n$X = F^-(u)$ for $U \\sim Unif (0,1)$ has a distribution cdf $F$.\n\\begin{proof} (Example sheet)\\\\\n$\\P(X \\leq t) = \\P(F^-(U) \\leq t) = ... = F(t)$, and use that $\\P(U \\leq z) = z$ for $z \\in (0,10$.\n\\end{proof}\n\\end{prop}\nConclusion (of the first part): If $F$ is known, explicit, we can generated $(X_1^*,...,X_N^*) = (F^-(U_1^*),...,F^-(U_N^*))$ that are i.i.d., each with cdf $F$. If we want to compute $\\E_{X \\sim f} [g(X)]$, we can approximate it by $\\frac{1}{N} \\sum_{i=1}^N g(X_i^*)$, and use the fact that $\\frac{1}{N} \\sum_{i=1}^N g(X_i^*) \\xrightarrow{a.s.} \\E[g(X)]$ by the LLN.\n\nIn certain situations, the distributino might be complex, and $F$, $F^-$ are not explicit. For example, $N(\\mu,\\sigma^2)$ can be solved by looking up in a table, but $\\Pi (\\cdot \\mid X)$ can involve complicated integrals (the density) which make computation of $F_\\Pi$ impossible.\n\nThere are several ways to tackle this and approximately sample from distributions.\n\n(1) Importance sampling: Let $F$ have density $f$, and random variables i.i.d. $X_i^* \\sim h$.\n\n\\begin{prop}\n$\\E_h \\left[\\frac{g(x)}{h(x)} f(x)\\right] = \\E_f [g(x)]$.\n\\begin{proof}\nThe above is equal to $$ \\int_\\chi \\frac{g(x)}{h(x)} f(x) \\cdot h(x) dx = \\int_\\chi g(x) f(x) dx$$ As a consequence, $$\\frac{1}{N} \\sum_{i=1}^n \\frac{g(X_i^*)}{h(X_i^*)} f(X_i^*) \\xrightarrow{a.s.} \\E_{X \\sim f} [g(X)]$$.\n\\end{proof}\n\\end{prop}\n\n(2) Accept/Reject algorithm. As in (1), but $f \\leq M\\cdot h$ for some constant $M$.\\\\\nStep 1: generate $X \\sim h$ and $U \\sim U(0,1)$.\\\\\nStep 2: $Y=X$ if $U \\leq \\frac{f(X)}{M\\cdot h(X)}$, otherwise return to step 1. Then $Y \\sim f$ (example sheet).\n\nFor multivariate problems where conditional distributions are aesy to compute but not joint distributions, we can then use the \\emph{Gribbs samples}: In the bivariate case $(X,Y)$, start at the same $X = x_0$, and $Y_1 \\sim f_{Y|X}(\\cdot |x_0)$, and $X_1 \\sim f_{X|Y}(\\cdot |y_1)$, etc., $Y_t \\sim f_{Y|X}(\\cdot | X_{t-1})$, $X_t \\sim f_{X|Y}(\\cdot | Y_t)$. The sequences $(X_t,Y_t)$,$(X_t)$,$(Y_t)$ are all Markov chains, with invariant distribution $f$, $f_{X|Y}$, $f_{Y|X}$. And we can use the ergodic theorem to approximate expectations $$\\frac{1}{N} g(X_t,Y_t) \\to \\E_{(X,Y) \\sim f} [g(X,Y)]$$ This can be used in particular in the case $Q(x,\\theta) = f(x,\\theta) \\pi (\\theta)$.\n\nImportant: Last lecutre today, no lecutre on Wednesday!!\n\n\\subsection{Nonparametric statistics}\nConsider observing $X_1,...,X_n \\sim P$ i.i.d. with the distribution $P$ having cdf on $\\R$: $F(t) = \\P(X \\leq t)$ for all $t \\in \\R$. Here we want to estimate directly the function $F$, without a parametric assumption: we cannot \"estimate $\\theta$ to estimate $F_\\theta$\".\n\n\\begin{rem}\nWe note that\n\\begin{equation*}\n\\begin{aligned}\nF(t) = \\P(X \\leq t) = \\E_p [1_{[-\\infty,t]}(x)]\n\\end{aligned}\n\\end{equation*}\n(or $\\int_\\R 1_{[-\\infty,t]} (x) d\\P(x)$) if the distribution is continuous.\n\nFor all $t \\in \\R$, the real number $F(t)$ is the expectation of the random variable $1_{[-\\infty,t]}(X) \\in \\{0,1\\}$ of which we observe $n$ i.i.d. draws.\n\\end{rem}\n\n\\begin{defi}\nThe \\emph{empirical distribution function} is defined as $$F_n(t) = \\frac{1}{n} \\sum_{i=1}^n 1_{[-\\infty,t]}(X_i)$$\n\\end{defi}\n\n\\begin{rem}\nIf we are interested in the value of the c.d.f., for some fixed $t$, $F_n(t)$ is a consistent estimator of $F(t)$ by Law of large numbers, and we can control the rate of estimation by limiting distribution of $\\sqrt{n} (F_n(t) - F(t))$ (CLT gives $N(0,F(t) (1-F(t)))$). This is just a Bernoulli model.\\\\\nBecause we are interested in the overall (all of $\\R$) behaviour of $F_n$, and see $F_n$ as the estimator of a function, we have to understand it s dependency structure.\n\\end{rem}\n\n\\begin{thm} (Glivenko-Cantelli theorem)\\\\\nWe have, as $n \\to \\infty$, that $$\\sup_{t \\in \\R} |F_n(t) - F(t)| \\xrightarrow{a.s.} 0$$\n\\begin{proof}\nIf $f$ is continuous in $t$, writing $q(X_i,t) = 1_{[-\\infty,t]]}(X_i)$, we have $\\E_p [q(X,t)] = F(t)$ and the uniform law of large numbers applies directly: $$\\sup_{t \\in \\R} \\left| \\underbrace{\\frac{1}{n} \\sum_{i=1}^n q(X_i,t)}_{F_n(t)} - \\underbrace{\\E_p [q(X,t)]}_{F(t)}\\right| \\xrightarrow{a.s.} 0$$ The case where $F$ is not continuous can be handled as well and the result holds by using that $F$ is non-decreasing and cutting $[0,1]$ into smaller intervals of size $\\leq \\varepsilon$.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (Donskin-Kolmogorov-Doob theorem)\\\\\nAs $n \\to \\infty$, the random function $\\sqrt{n}(F_n-F)$ converges $\\sqrt{n} (F_n-F) \\xrightarrow{\"d\"} \\mathcal{G}_F$ \"in distribution over the space of functions\". Here $\\mathcal{G}_F$ is a random function from $\\R$ to $\\R$ such that $\\mathcal{G}_F(t)$ is normally distributed $N(0,F(t)(1-F(t)))$, and $Cov(\\mathcal{G}_F(s), \\mathcal{G}_F(t)) = F(s) (1-F(t))$ for $s \\leq t$.\n\nConstruction of $\\mathcal{G}_F$:\\\\\nInformal definition: A Brownian motion, a Wiener process is defined as\\\\\n$\\bullet$ $W_j = 0$ a.s.;\\\\\n$\\bullet$ $t \\to W_t $ is continuous a.s.;\\\\\n$\\bullet$ For $s \\leq t$, $W_t - W_s$ is independent of $(W_{s'})_{s' \\leq s}$ and has distribution $N(0,t-s)$.\n\nThe Brownian bridge is \"tied to $0$ at $0$ and $1$\", and defined as $B_t = W_t - tW_1$.\n\nThe variance of $B_t=t(1-t)$ and $Cov(B_s,B_t) = s(1-t)$ for $s \\leq t$. Taking $\\mathcal{G}_F (t) = B_{F(t)}$ gives a construction of this process.\n\n\\begin{rem}\nIf $U_1,...,U_n \\stackrel{i.i.d.}{\\sim} U[0,1]$, then $F(t) = t$ and $\\sqrt{n}(F_n-F)$ will converge directly to a Brownian bridge.\n\\end{rem}\n\\end{thm}\n\n\\begin{thm} (Kolmogorov-Smirnov theorem)\\\\\n$\\sqrt{n} ||F_n - F||_\\infty \\xrightarrow{d} ||B||_\\infty$, where $||B||_\\infty = \\sup_{t \\in (0,1)} |B_t|$.\n\\begin{proof}\n$||\\mathcal{G}_F||_\\infty = \\sup_{t \\in \\R} |B_{F(t)}| = \\sup_{t \\in (0,1)} |B_t|$.\n\\end{proof}\n\\end{thm}\n\n\\begin{rem}\n$||B||_\\infty$ doesn't depend on $F$, there are tables so it can be used in many inference tasks.\\\\\n(1) Non-parametric hypothesis testing: we have $H_0:F = F_0$, or $H_1: F \\neq F_0$. Then $\\sqrt{n} ||F_n - F_0||_\\infty \\xrightarrow{d} ||B||_\\infty$.\\\\\n(2) Confidence bands for $F$: we can define $C_n(x)$ for all $x$ in $\\R$ around $F_n(x)$, and study $\\P(F(x) \\in C_n(x) \\forall x \\in \\R) \\to $\\\\\nOther application of non-parametric statistics:\\\\\n(1) Regression, wher $y_i = f(X_i) + \\varepsilon_i$; unknown function $f$.\\\\\n(2) Density estimation: $X_i \\sim P$ have density $f$. In many applications $\\E|\\hat{f}_n - f| \\gg \\frac{1}{\\sqrt{n}}$.\n\\end{rem}\n\n---end of lecture notes---\n\n\n\\end{document}\n", "meta": {"hexsha": "62e2e8fd8f9162f5a359dd0e2748481119b173c8", "size": 14146, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Pos2.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Pos2.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Pos2.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.3431372549, "max_line_length": 761, "alphanum_fraction": 0.6448465997, "num_tokens": 5241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.72487026428967, "lm_q1q2_score": 0.4431726125636713}}
{"text": "\\section{Problem Description}\nThe problem that we have is the utilization of deep reinforcement learning, with the specific model of convolutional neural networks, trained with Deep Q-Learning, whose input is raw pixel values, varying between \\( \\{0, 1, \\dots, 255\\} \\), of a grayscale version of the image of the current state, and output is the most suitable action from the action space. The question that we would like to address is whether the trained agent can outperform a random agent, which takes random actions at each time step, and if so whether it can outperform a human agent that plays the game in the same settings.\n", "meta": {"hexsha": "89b6f3cb17e8f446d245976df9c444af38ed97e1", "size": 632, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "final/problem.tex", "max_stars_repo_name": "atahanyorganci/dqn", "max_stars_repo_head_hexsha": "56bc0d964dd1c84ba02780bd9288370d257f126d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "final/problem.tex", "max_issues_repo_name": "atahanyorganci/dqn", "max_issues_repo_head_hexsha": "56bc0d964dd1c84ba02780bd9288370d257f126d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "final/problem.tex", "max_forks_repo_name": "atahanyorganci/dqn", "max_forks_repo_head_hexsha": "56bc0d964dd1c84ba02780bd9288370d257f126d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 210.6666666667, "max_line_length": 601, "alphanum_fraction": 0.7911392405, "num_tokens": 135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358014, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.44314615027974696}}
{"text": "\\documentclass{article}\n\\pagestyle{empty}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\setlength{\\oddsidemargin}{0in} \\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{0in} \\setlength{\\textheight}{8.5in}\n\\setlength{\\textwidth}{6.5in}\n\n\\makeatletter\n\\renewcommand*\\env@matrix[1][*\\c@MaxMatrixCols c]{%\n\t\\hskip -\\arraycolsep\n\t\\let\\@ifnextchar\\new@ifnextchar\n\t\\array{#1}}\n\\makeatother\n\n\\begin{document}\n\\begin{flushleft}\n\t\\bfseries{MATH 260, Linear Algebra, Spring `14}\\\\\n\t\\bfseries{Activity 12:  Null \\& Column Spaces}\\\\\n\t\\bfseries{Honor Code:} \\hspace{3.5in}\\bfseries{Names:}\\\\\n\\end{flushleft}\n\\begin{flushleft}\n\\vspace{.75in}\nDirections:  Everyone should work on the assignment and should fill out their paper.  You are expected to make corrections based on what is presented on the board.  \\\\\nIf you need more explanations after class, you can read Section 5.4 of your textbook.\\\\\n\\vspace{0.1in}\n\\Large\nIn-Class Learning Goals:\\\\\n\\normalsize\n\\begin{enumerate}\n\\item Be able to find the null space/kernel of any matrix\n\\item Be able to give the column space for any matrix\n\\item Be able to give a basis for the column space of a matrix\n\\item Be able to describe how the null space and column space relate to each other\n%\\item Be able to determine if a set of vectors is a basis for a vector space\n%\\item (stretch) Be able to find the dimension of a set or space (by the end of homework for sure!)\n\n\\end{enumerate}\n\n\\vspace{0.1in}\n\n\\section*{Warm-up:  In the null space?}\n%This is the matrix from Sect. 5.4, pg 339, #43\nRecall that the null space is all vectors $\\vec{x}$ such that $\\textbf{A}\\vec{x}=\\vec{0}$. Given the matrix:\\\\\n\\begin{center}\n$\\textbf{G}=\n\\begin{bmatrix}\n2 & 3 & -1\\\\\n-1 & 4 & 6 \\\\\n1 &  7 & 5\n\\end{bmatrix}\n$\\\\\n\\end{center}\n1a) Determine which of the following vectors are in the null space of \\textbf{G}.\\\\\n\\begin{center}\n$ \\vec{w}_1=\\begin{bmatrix} 3 \\\\ 2 \\\\ 1 \\end{bmatrix} $\n\\hspace{0.3in}\n$ \\vec{w}_2=\\begin{bmatrix} 8 \\\\ -4 \\\\ 4 \\end{bmatrix} $\n\\hspace{0.3in}\n$ \\vec{w}_3=\\begin{bmatrix} -2 \\\\ 1 \\\\ -1 \\end{bmatrix} $\n\\end{center}\n\n\\vspace{2in}\n\n1b) Find the actual null space of \\textbf{G}. Do your answers above make agree?\n\n\\newpage\n\n\\section*{A useful Null Space}\nGiven the matrix $\\textbf{F} = \\begin{bmatrix} 1 & 2 \\\\ 3 & 0 \\end{bmatrix}$ with eigenvalues of -2 and 3.\n\n\\vspace{0.1in}\n\n2) Find the null space of the matrix $(\\textbf{F} + 2 \\textbf{I} )$. \n\n\\vspace{1.25in}\n\n3) Find the null space of the matrix $(\\textbf{F} - 3 \\textbf{I} )$. \n\n\\vspace{1.25in}\n\n4) Have you seen these null spaces (or their calculations) before? What do the null spaces you found in (2) and (3) have to do with the matrix \\textbf{F}?\n\n\\vspace{1in}\n\n\\section*{Basis for Column Space}\nWe know that the column space ( $span( \\{ \\vec{v}_1 , \\vec{v}_2, \\ldots \\vec{v}_n \\} )$ ) is a subspace. However, generally in mathematics we want to describe things in as simple terms as possible. For spaces, this means giving a \\textit{basis} only for a space. \\\\\nRecall that a set is a \\textbf{basis} of a vector space if it has the properties:\\\\\n(i) The set is linearly independent \\hspace{.25in} (ii) The span of the set covers the entire vector space.\\\\\n\n\\vspace{0.1in}\n\n5) The column space of \\textbf{G} could be given as \\textit{span}$ \\left( \\left\\{ \\begin{bmatrix} 2 \\\\ -1 \\\\ 1\\end{bmatrix}, \\begin{bmatrix} 3 \\\\ 4 \\\\ 7 \\end{bmatrix}, \\begin{bmatrix} -1 \\\\ 6 \\\\ 5 \\end{bmatrix} \\right\\} \\right)$. Does the set $S=\\left\\{ \\begin{bmatrix} 2 \\\\ -1 \\\\ 1 \\end{bmatrix}, \\begin{bmatrix} 3 \\\\ 4 \\\\ 7 \\end{bmatrix}, \\begin{bmatrix} -1 \\\\ 6 \\\\ 5 \\end{bmatrix} \\right\\}$ form a basis for the column space? (Show why or why not)\n\n\\vspace{1.5in}\n\nWe already have all the tools and information to define a valid basis. Let's do so...\n\n\\vspace{0.1in}\n\n6) Which columns in the RREF of \\textbf{G} are pivot columns?\n\n\\vspace{0.75in}\n\n7) Take the columns from the original \\textbf{G} that you identified as the pivot columns. Form a new set $S_{B}$ from these columns. These should be $3 \\times 1$ vectors with non-zero values in each row.  \\textit{Be sure to show work or explain your reasoning below, a yes/no answer for any of the below will NOT receive credit.}\n\n\\vspace{0.1in}\n\n7a) Is this new set $S_{B}$ linearly independent?\n\n\\vspace{1.5in}\n\n7b) Does it span the entire column space? ( \\textit{Hint: Does $span( S ) = span ( S_{B} ) $ } )\n\n\\vspace{1.5in}\n\n7c) Is the set $S_{B}$ a basis for the column space? Explain.\n\n\\vspace{0.75in}\n\n8) We defined the \\textbf{rank} of a matrix as the number of pivot columns in RREF. How does the rank of \\textbf{G} relate to the column space of \\textbf{G}? (\\textit{Hint: What property of a space gives a single value out?} )\n\n\\vspace{1.6in}\n\n\\Large Note this relationship between rank and column spaces is actually true for any matrix. \\normalsize\n\n\\newpage \n\n\\section*{Rank-Nullity Theorem}\n9) For the CPA you found the null space and column-space of $\\textbf{A}=\\begin{bmatrix} 1 & -2 \\\\ 1 & -2 \\end{bmatrix}$.\\\\\nA basis for the column space is $\\begin{bmatrix} 1 \\\\ 1 \\end{bmatrix}$. A basis for the null space is $\\begin{bmatrix} 2 \\\\ 1 \\end{bmatrix}$.\n\n\\vspace{0.15in}\n\n9a) What is the dimension of the null space and column space for \\textbf{A}?\n\n\\vspace{0.75in}\n\n9b) How do the dimensions of \\textbf{F} relate to the sum: dim( column space of \\textbf{A}) + dim( null space of \\textbf{A} ) ?\n\n\\vspace{1in}\n\n10a) State the dimension of the null space (the \\textit{nullity} of \\textbf{G} ) and the dimension of the column space for matrix \\textbf{G}.\n\n\\vspace{0.75in}\n\n10b) How do the dimensions of \\textbf{G} relate to the sum: dim( column space of \\textbf{G} ) + dim( null space of \\textbf{G}) ?\n\n\\vspace{1in}\n\n11) The \\textbf{Rank-Nullity Theorem} generalizes the above results for the $m\\times n$ matrix \\textbf{A}. Based on your results, what do you think the \\textbf{Rank-Nullity Theorem} is? (Take a guess BEFORE looking this up! You should check with your professor or check your text once you make a guess.)\n\n\\vspace{0.75in}\n\n%\\section*{Row-Spaces and Left-Nullspace}\n%Just as each matrix has a column-space, it also has a row-space. These row spaces are defined analogously. While we could define a whole new set of column operations there's an easier way...\n%\n%\\vspace{0.1in}\n%\n%7a) Find the transpose of matrix \\textbf{G} $\\rightarrow \\textbf{G}^{T}$.\n%\n%\\vspace{1in}\n%\n%7b) How are the rows of \\textbf{G} related to the columns of $\\textbf{G}^T$?\n%\n%\\vspace{1in}\n%\n%7c) Find a basis for the column-space of $\\textbf{G}^T$.\n%\n%\\vspace{1.5in}\n%\n%8) Explain why the row-space of \\textbf{G} and the column-space of $\\textbf{G}^T$ are equivalent.\n%\n%\\vspace{1in}\n%\n%9) Find the null-space of $\\textbf{G}^{T}$. \n%\n%\\vspace{1.5in}\n%\n%This is called the \\textit{left nullspace} because it is equivalent to finding the set of vectors $\\vec{x}$ which satisfy $\\vec{x}^{T} \\textbf{A} = \\vec{0}$. Notice we have moved $\\vec{x}$ to the left-side of \\textbf{A}. \n%\n%\\vspace{0.2in}\n%\n%10a) What is the dimension of the row-space and left-nullspace of matrix \\textbf{G}?\n%\n%\\vspace{0.75in}\n%\n%10b) How do the dimensions of \\textbf{G} relate to the sum: dim( Row-Spc ) + dim( Left-Nullspc) ? \n%\n%\\vspace{1in}\n%\n%\\section*{Fundamental Spaces}\n%11) Detail the four spaces you found above for \\textbf{G}. Give their name, dimension and basis. (A 4 x 3 table with column labels would be perfect).\n%\n%\\vspace{3in}\n%\n%You have now found the four fundamental spaces of the matrix \\textbf{G}! These four spaces can be found for any matrix and are used in a variety of operations. We'll look into this a little next week. \n\\end{flushleft}\n\\end{document}", "meta": {"hexsha": "f68bf5337e869e5e0a45e5eb3d6feaf10f64b285", "size": 7624, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Spring 2014 - Schmitt/Activity Latex/Activity_12_nullcolumnspace.tex", "max_stars_repo_name": "Pelonza/PB-LinAlg", "max_stars_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Spring 2014 - Schmitt/Activity Latex/Activity_12_nullcolumnspace.tex", "max_issues_repo_name": "Pelonza/PB-LinAlg", "max_issues_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Spring 2014 - Schmitt/Activity Latex/Activity_12_nullcolumnspace.tex", "max_forks_repo_name": "Pelonza/PB-LinAlg", "max_forks_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.12, "max_line_length": 450, "alphanum_fraction": 0.7021248688, "num_tokens": 2530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.44314614558312754}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{verbatim}\n\\usepackage{amsfonts}\n\\usepackage{dsfont}\n\\usepackage{amsmath}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\n\\begin{document}\n\n\\title{Quarter Progress Report}\n\\author{Cedrick Argueta}\n\n\\maketitle\n\n\\begin{comment}\n\n\\section{Introduction}\nTomorrow morning is fine. I'd say closer to a summary of what you learned. It would still be good to include some background and what the goal is (since he probably isn't as familiar as we are). After highlighting the goal, let him know how you are approaching the problem and what you have accomplished so far. Feel free to let him know what problems you ran into and how you overcame them. \n\n\n\\section{Introduction}\n\n\nprevious work: Kyle's paper on distributed wildfire with drones, louis' paper on drone localization\n\nwhat i've done so far:\n    read the papers\n    done some simple examples with louis' FEBOL module\n    set up dev environment locally\n    developed system to train RL models on the FEBOL code easily\n    moved system onto astoria\n    \nstuff ive learned:\n    gone in depth on more advanced reinforcement learning than cs221\n    working with FEBOL and the mathematics behind kyle's and louis' papers\n    more advanced RL setups with keras rl\n\n\\end{comment}\n\n\\section{Introduction}\nThis work builds heavily off of \\cite{dronehunter} in that we have the same goal -- improve drone tracking performance over greedy, one-step planners.\nWe have two drones, a seeker drone and a target drone, and wish to track the moving target drone with the seeker drone by capturing emissions by the target drone's radio.\nHowever, the MCTS solution presented is often requires large amounts of memory and computational power that might be lacking on drone avionics boards.\nWe propose using deep reinforcement learning to combat this problem, since the amount of memory required for inference is relatively small compared to traditional POMDP planners.\n\n\\section{Background}\nAs in \\cite{dronehunter}, we use a belief-MDP to model the problem.\nThe state of the system at time $t$ is $s_t = (b_t, x_t)$, where $b_t$ is the belief of the distribution of possible target states, and $x_t$ is the seeker's state.\n$b_t$ is used to represent the information that we've gathered from the target drone's radio.\n$b_t$ can be approximated well with a discrete filter for stationary targets, or a particle filter for moving targets.\nThe action taken at time $t$ is $u_t$, and is one of a discrete set of commands given to the seeker drone.\nThese actions are constant velocity actions in a radial pattern about the seeker drone.\nBecause we've modeled the position of the target drone with a probability distribution, we'd like to minimize the uncertainty in our target estimate.\nThis happens when we have a low amount of entropy in the particle filter.\nTo find entropy, we must first discretize the particle filter into $M$ bins.\nWe can then define this entropy as:\n\\begin{equation}\nH(b_t) = -\\sum_{i = 1}^M\\tilde{b}_t[i]\\log\\tilde{b}_t[i]\n\\end{equation}\nwhere $\\tilde{b}_t$ is the proportion of particles in each bin $i$.\nWe'd also like to penalize near-collisions, so our cost function at time $t$ is:\n\\begin{equation}\nJ(s_t) = H(b_t) + \\lambda\\mathop{{}\\mathbb{E}}_{b_t} \\mathds{1} (\\Vert x_t - \\theta_t\\Vert < d)\n\\end{equation}\nwhere  $\\theta_t$ is the target drone's actual position, and $\\mathds{1}$ is an indicator function.\n\nTo solve this belief-MDP, we make use of deep reinforcement learning.\nMuch of the basis for deep reinforcement learning in this task comes from \\cite{kyle}.\nWe define the Q-value of a state-action $(s, a)$ pair as:\n\\begin{equation}\nQ(s, a) = r(s) + \\gamma\\sum_{s' \\in S}T(s, a, s')\\max_{a' \\in A}Q(s', a')\n\\end{equation}\nwhere $r(s)$ is the reward received for being in state $s$, $\\gamma$ is the discount factor, $T(s, a, s')$ is the transition probability of going from $s$ to $s'$ with action $a$.\nWe use function approximation to mitigate the issues that arise from having such a large state space.\nThen our goal is to minimize the Bellman error, defined as\n\\begin{equation}\nE = r + \\gamma\\max_{a' in A}Q(s', a'; \\mathbf{w}) - Q(s, a; \\mathbf{w})\n\\end{equation}\nwhere we have a state, action, reward, next state tuple $(s, a, r, s')$ and $Q(\\dots; \\mathbf{w})$ indicates that the Q-value function is parameterized by some weights $\\mathbf{w}$.\nThen the optimal policy $\\pi_{opt}$ may be computed as:\n\\begin{equation}\n\\pi_{opt}(s, a) = \\argmax_{a \\in A}Q(s, a; \\mathbf{w})\n\\end{equation}\nwhich tells us the best action to take from a given state-action pair.\n\n\n\n\\section{Approach}\nContrary to the previous approach, we instead are writing our own simulation environment so that the codebase may be simplified.\nFor a preliminary implementation, we simplify the problem in two ways: we assume a stationary target, and use a discrete filter rather than a particle filter to model the target belief.\n\nPreliminary results will come from using the DQN algorithm presented in \\cite{dqn} on this task. \nWe chose to do so because it showed promising results in \\cite{kyle}, and is relatively simple to implement compared to state-of-the-art algorithms.\nSince we have two types of inputs, a belief distribution represented as a matrix and the seeker drone's state, we need begin with two separate networks. \nThe seeker state network is a simple fully connected network that takes an input in $\\mathbb{R}^{3}$, representing the seeker's $x$ position, $y$ position, and bearing.\nThe input is fed into five consecutive hidden layers of 100 units each, each with rectified linear unit activations.\nThe belief network is a convolutional neural network that takes the filter matrix as input.\nThis input is fed into three convolutional layers, each with 64 units and a filter size of $(3 \\times 3)$.\nEach of these convolutional layers is followed by a max pooling layer with a filter size of $(2 \\times 2)$.\nAfter the final max pooling layer, the outputs are fed into a dense layer with a size of 500 units.\nFinally, the outputs of both these networks are concatenated and fed into two consecutive dense layers, each with a size of 200 units and followed by rectified linear unit activations.\nThe output layer has a dimensionality that equals the number of actions that the seeker can take, and each represents the Q-value for that action and the current state.\n\nLearning the network parameters can be done with gradient descent or any of its derivatives.\nWe use AdaMax in our implementation.\n\nWith the simulation environment and testing infrastructure in place, we will then begin to compare inference times and performance to the MCTS approach described in \\cite{dronehunter}.\n\n\\section{State of the Project}\nProgress made this quarter can be divided into two parts: attempting to wrangle the segfault on GPU and then attempting to rewrite the FEBOL package.\n\nWhen running training sessions on \\texttt{astoria}, a segfault would arise a few thousand training itertions in. \nThe number of training iterations needed to cause the segfault wasn't consistent at all, and would happen anywhere from a few hundred to a few hundred thousand iterations.\nAt the advice of people in your lab, I looked to see if this was a memory error -- but \\texttt{astoria} has more than enough memory to run a neural network of our size. \nI looked into seeing if one of the hyperparameters could give any insight into the problem, but no matter the settings the issue would happen sporadically on every training session that was longer than a trivial amount of time.\n\n\nAfter fiddling with hyperparameters for a while, I decided it wasn't worth it to try every combination and dove into a debugger to try to figure out the issue. \nThe debugger, though, was little to no help: the core dump told me little more than that there was an unauthorized memory access at a specific location.\nRunning through the control flow of the program was nearly impossible for a few reasons.\nOne was the nature of the package that we used to combine the Julia simulation code and the Python reinforcement learning system.\nThe package would open up an interpreter and run the Julia commands inside the interpreter, giving us little access to the objects that Julia made use of besides the fact that they were Julia objects that required the interpreter for evaluation.\nBreakpoints couldn't be set at specific points in the Julia code that was being executed, they could only be set withing the Python codebase and even then weren't of much use when it came to seeing what happened within the separate Julia interpreter.\nThe second was that we executed the Julia code dynamically, i.e., a string was constructed at runtime in Python and fed to a Julia interpreter for evaluation.\nThis was necessary for the reinforcement learning system to give commands to the Julia simulation - an observation would be given to the RL system, the RL system would produce a command, and the command would be given to the drone in the Julia simulation. \nThis, however, made it almost impossible to follow control flow for the Julia code without tracing through the entire Python code that lef up to the segfault, something that was infeasible when a segfault would occur hours into training.\nBecause of the obfuscation of these two problems combined, Louis and I decided that it'd be better to do a minimal rewrite of the FEBOL simulation package in Python.\nA minimal rewrite would provide us with the most important features of the FEBOL package, such as a different types of filters and a simple representation of a drone, along with the removal of the Julia to Python library that might have been the cause of the segfault.\nAn interesting point is that the training code works locally; only when the training code is moved to a system with a GPU does the segfault arise.\nHopefully rewriting the FEBOL package will give us either a better insight into what's going wrong when switching to GPU, or remove the issue altogether.\nAt the very least, it will be much easier to use a debugger and find the problem if it persists.\n\n\n\\bibliography{ref}\n\\bibliographystyle{plain}\n\n\\end{document}\n\n", "meta": {"hexsha": "470f0771a25d03efd0f5da91a438c431b9b6407c", "size": 10174, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/quarter-summary-win-2019.tex", "max_stars_repo_name": "cdrckrgt/PyFEBOL", "max_stars_repo_head_hexsha": "1c2ffd54c9d2ce7914e7ca4c2cdcb6d398ab8563", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/quarter-summary-win-2019.tex", "max_issues_repo_name": "cdrckrgt/PyFEBOL", "max_issues_repo_head_hexsha": "1c2ffd54c9d2ce7914e7ca4c2cdcb6d398ab8563", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/quarter-summary-win-2019.tex", "max_forks_repo_name": "cdrckrgt/PyFEBOL", "max_forks_repo_head_hexsha": "1c2ffd54c9d2ce7914e7ca4c2cdcb6d398ab8563", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.1560283688, "max_line_length": 392, "alphanum_fraction": 0.7803223904, "num_tokens": 2355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.810478913248044, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.44311974325173376}}
{"text": "% Students question collection\n%# Author Alejandro Gonzalez Recuenco and SKR students\n%# e-mail <alejandrogonzalezrecuenco@gmail.com>\n\n\\documentclass{exam}\n%SET-UP:\n\\usepackage{amsmath, physics, tikz, tcolorbox, graphicx}\n\n\n\n%! TexExamRandomizer = {\"seed\": 314159}\n%! TexExamRandomizer = {\"randominfo\": {\"randomnumber\":100000000, \"switchnumber\":[\"even\", \"odd\", \"stop\"]}}\n%! TexExamRandomizer = {\"table\":\"TestClass.csv\"}\n%! TexExamRandomizer = {\"extrainfo\":{\"Class\":\"class\", \"Roll Number\":\"rollnumber\",\"Nickname\":\"nickname\"}}\n\n\n%! TexExamRandomizer = {\"layercmd\":[\"section\", \"question\", \"(choice|CorrectChoice)\"],\"layernames\":[\"document\", \"questions\", \"choices\"]}\n%! TexExamRandomizer = {\"reordersections\":[true, true, false]}\n%! TexExamRandomizer = {\"reorderitems\":[false, true, true]}\n\n\\newcommand{\\randomnumber}{3}\n\\newcommand{\\switchnumber}{hi}\n\\newcommand{\\class}{class}\n\\newcommand{\\rollnumber}{rollnumber}\n\\newcommand{\\nickname}{nickname}\n\\newcommand\\myversion{0}\n\\newcommand\\rseed{seed}\n\n\n\n% DOCUMENT STARTS HERE\n\\begin{document}\n\n\\author{Everyone version \\myversion}\n\\title{\\textsc{Exam collection} --- mini-exam for \\nickname\\ of class \\class}\n\n\n\\maketitle\n\n\n\\section{Word problems}\n\nThe two sections of questions are these ones\n\n\n\\subsection{Subsection 1}\\begin{questions}\n\n\n\t\\question What is a tangent line to a curve at a point $x = a$?\n\n\t\\begin{choices}\n\t\t\\choice A line that crosses a  curve once.\n\t\t\\choice None of the other choices are correct.\n\t\t\\choice A line that crosses a curve in two points.\n\t\t\\CorrectChoice A line that has the same slope as the curve at the point $x = a$.\n\t\\end{choices}\n\t\\question What type of graph is the derivative of $f(x)= 5x^3+6x^2+5x-1$ graph?\n\n\t\\begin{choices}\n\t\t\\choice Line.\n\t\t\\choice Circle.\n\t\t\\choice Hyperbola.\n\t\t\\CorrectChoice Parabola.\n\t\\end{choices}\n\n\\end{questions}\n\n\\subsection{Subsection 2}\n\\begin{questions}\n\n\n\t\\question test --- What is a tangent line to a curve at a point $x = a$?\n\n\t\\begin{choices}\n\t\t\\choice A line that crosses a  curve once.\n\t\t\\choice None of the other choices are correct.\n\t\t\\choice A line that crosses a curve in two points.\n\t\t\\CorrectChoice A line that has the same slope as the curve at the point $x = a$.\n\t\\end{choices}\n\t\\question test --- What type of graph is the derivative of $f(x)= 5x^3+6x^2+5x-1$ graph?\n\n\t\\begin{choices}\n\t\t\\choice Line.\n\t\t\\choice Circle.\n\t\t\\choice Hyperbola.\n\t\t\\CorrectChoice Parabola.\n\t\\end{choices}\n\n\\end{questions}\n\n\n\\section{Easy}\nThe two sections of questions are these ones\n\n\n\\subsection{Subsection 1}\\begin{questions}\n\n\t\\question If $y=\\cos5x$ find $\\dv{y}{x}$.\n\n\t\\begin{choices}\n\t\t\\choice $\\dv{y}{x} = 5\\cos5x$.\n\t\t\\choice $\\dv{y}{x} = -2\\sin5x$.\n\t\t\\choice $\\dv{y}{x} = 5\\cos2x$.\n\t\t\\CorrectChoice $\\dv{y}{x} = -5\\sin5x$.\n\t\\end{choices}\n\t\\question Given $y=2x^2-3x+5$, What is $\\dv[2]{y}{x}$\n\n\t\\begin{choices}\n\t\t\\choice $\\dv[2]{y}{x}=4x-3$\n\t\t\\choice $\\dv[2]{y}{x}=16x-12$\n\t\t\\choice $\\dv[2]{y}{x}=0$\n\t\t\\CorrectChoice $\\dv[2]{y}{x}=4$\n\t\\end{choices}\n\n\\end{questions}\n\n\\subsection{Subsection 2}\n\n\\begin{questions}\n\n\t\\question test --- If $y=\\cos5x$ find $\\dv{y}{x}$.\n\n\t\\begin{choices}\n\t\t\\choice $\\dv{y}{x} = 5\\cos5x$.\n\t\t\\choice $\\dv{y}{x} = -2\\sin5x$.\n\t\t\\choice $\\dv{y}{x} = 5\\cos2x$.\n\t\t\\CorrectChoice $\\dv{y}{x} = -5\\sin5x$.\n\t\\end{choices}\n\tsecond part of question\n\t\\begin{choices}\n\t\t\\choice test ---   $\\dv{y}{x} = 5\\cos5x$.\n\t\t\\choice test ---   $\\dv{y}{x} = -2\\sin5x$.\n\t\t\\choice test ---   $\\dv{y}{x} = 5\\cos2x$.\n\t\t\\CorrectChoice test ---   $\\dv{y}{x} = -5\\sin5x$.\n\t\\end{choices}\n\t\\question test ---  Given $y=2x^2-3x+5$, What is $\\dv[2]{y}{x}$\n\n\t\\begin{choices}\n\t\t\\choice $\\dv[2]{y}{x}=4x-3$\n\t\t\\choice $\\dv[2]{y}{x}=16x-12$\n\t\t\\choice $\\dv[2]{y}{x}=0$\n\t\t\\CorrectChoice $\\dv[2]{y}{x}=4$\n\t\\end{choices}\n\n\\end{questions}\n\n\n\\section{Medium}\n\n\n\\begin{questions}\n\n\t\\question What is the derivative of f(x)=$(1-6x^2)^4$\n\t\\begin{choices}\n\t\t\\choice $4(1-6x^2)^3$\n\t\t\\choice $4x(1-6x^2)^3$\n\t\t\\choice $48x(1-6x^2)^3$\n\t\t\\CorrectChoice $-48x(1-6x^2)^3 y$\n\t\\end{choices}\n\n\t\\question Find the derivative of $f(x) = \\frac{x-1}{x+1}$\n\n\t\\begin{choices}\n\t\t\\choice $f'(x) = \\frac{-2}{(x+1)^2}$\n\t\t\\choice $f'(x) = \\frac{2}{(x-1)^2}$\n\t\t\\choice $f'(x) = \\frac{-2}{(x-1)^2}$\n\t\t\\CorrectChoice $f'(x) = \\frac{2}{(x+1)^2}$\n\t\\end{choices}\n\n\\end{questions}\n\n\n\n\\section{Hard}\n\n\\begin{questions}\n\n\t\\question What is value of the $\\displaystyle \\lim_{h \\to 0} \\frac{f(x+h) -f(x)}{h}$ tells about the function?\n\n\t\\begin{choices}\n\t\t\\choice\\label{choice:der1} The Slope of the graph.\n\t\t\\choice\\label{choice:der2} The critical point of the function , when the value of the limit is 0.\n\t\t\\CorrectChoice Both options, \\ref{choice:der1} and \\ref{choice:der2}, are correct.\n\t\t\\choice None of the above.\n\t\\end{choices}\n\n\t\\question What is the derivative of $f(x) = \\arctan(2x)$ ?\n\n\t\\begin{choices}\n\t\t\\choice $\\frac{2}{1 + x^{2}}$\n\t\t\\choice $\\frac{2}{2 + x^{2}}$\n\t\t\\choice $\\frac{2}{2 + 4x^{2}}$\n\t\t\\CorrectChoice $\\frac{2}{1 + 4x^{2}}$\n\t\\end{choices}\n\n\\end{questions}\n\n\\section{Graphic problems}\n\n\\begin{questions}\n\t\\question\n\tFrom the following graph find $\\lim_{x \\to -2 } f(x)$\n\t\\par\\nopagebreak\n\n\t\\begin{choices}\n\t\t\\choice $0$.\n\t\t\\choice $5$.\n\t\t\\choice $4$.\n\t\t\\CorrectChoice undefined.\n\t\\end{choices}\n\n\\end{questions}\n\n\\section{Bonus, integration}\n\n\\begin{questions}\n\t\\question Find the area of the graph between f(x) = $x^4$ and f(x) = $(x-6)^4$\n\n\t\\begin{choices}\n\t\t\\choice $\\frac{243}{5}$\n\t\t\\choice $\\frac{243}{10}$\n\t\t\\choice $\\frac{486}{10}$\n\t\t\\CorrectChoice $\\frac{486}{5}$\n\t\\end{choices}\n\t\\question Find the integral of $ 4x^3+3x^2 $\n\n\t\\begin{choices}\n\t\t\\choice $12x^2 + 6x$\n\t\t\\choice $4x^2 + 3x$\n\t\t\\choice $4x^4 + 3x^3 + c$\n\t\t\\CorrectChoice $x^4 + x^3 +c$\n\t\\end{choices}\n\n\\end{questions}\n\n\\end{document}\n\n", "meta": {"hexsha": "e504c86858fbf396fac405b6bf11dbdab4ab99b6", "size": 5692, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "inst/extdata/ExampleTexDocuments/exam_testing_threelayer.tex", "max_stars_repo_name": "alexrecuenco/TexExamRandomizer", "max_stars_repo_head_hexsha": "8284ffdda2a116a8c448ce371706fa056d270905", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-05-01T16:11:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-01T16:11:20.000Z", "max_issues_repo_path": "inst/extdata/ExampleTexDocuments/exam_testing_threelayer.tex", "max_issues_repo_name": "alexrecuenco/TexExamRandomizer", "max_issues_repo_head_hexsha": "8284ffdda2a116a8c448ce371706fa056d270905", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2018-02-13T01:00:18.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-15T01:46:24.000Z", "max_forks_repo_path": "inst/extdata/ExampleTexDocuments/exam_testing_threelayer.tex", "max_forks_repo_name": "alexrecuenco/TexExamRandomizer", "max_forks_repo_head_hexsha": "8284ffdda2a116a8c448ce371706fa056d270905", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-09-06T00:57:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T23:33:51.000Z", "avg_line_length": 23.9159663866, "max_line_length": 135, "alphanum_fraction": 0.6503865074, "num_tokens": 2121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624890918021, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4430014756286766}}
{"text": "%\\documentclass[12pt]{article}\n\\documentclass[12pt,landscape]{article}\n\n\\include{preamble}\n\n\\newcommand{\\instr}{\\small Your answer will consist of a lowercase string (e.g. \\texttt{aebgd}) where the order of the letters does not matter. \\normalsize}\n\n\\title{Math 368 / 650 Fall \\the\\year{} \\\\ Midterm Examination Two}\n\\author{Professor Adam Kapelner}\n\n\\date{Thursday, November 11, \\the\\year{}}\n\n\\begin{document}\n\\maketitle\n\n%\\noindent Full Name \\line(1,0){410}\n\n\\thispagestyle{empty}\n\n\\section*{Code of Academic Integrity}\n\n\\footnotesize\nSince the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.\n\nActivities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:\n\n\\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using an unauthorized cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.\n\\\\\n\n\\noindent By taking this exam, you acknowledge and agree to uphold this Code of Academic Integrity. \\\\\n\n%\\begin{center}\n%\\line(1,0){250} ~~~ \\line(1,0){100}\\\\\n%~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date\n%\\end{center}\n\n\\normalsize\n\n\\section*{Instructions}\nThis exam is 70 minutes (variable time per question) and closed-book. You are allowed \\textbf{one} page (front and back) of a \\qu{cheat sheet}, blank scrap paper and a graphing calculator. Please read the questions carefully. Within each problem, I recommend considering the questions that are easy first and then circling back to evaluate the harder ones. No food is allowed, only drinks. %If the question reads \\qu{compute,} this means the solution will be a number otherwise you can leave the answer in \\textit{any} widely accepted mathematical notation which could be resolved to an exact or approximate number with the use of a computer. I advise you to skip problems marked \\qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \\fbox{Box} in your final answers. Good luck!\n\n\\pagebreak\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{12} Let $X_1 \\sim \\exponential{\\lambda_1}$ independent of $X_2 \\sim \\exponential{\\lambda_2}$ where $\\lambda_1 \\neq \\lambda_2$ but are both valid values in the parameter space of the exponential rv. Let $T = X_1 + X_2$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{17} \n\n\\begin{enumerate}[(a)]\n\\item $X_1$ does not have a PMF\n\\item $X_1$ does not have a CDF\n\\item $\\prob{T \\leq x} = \\prob{X_1 \\leq x, X_2 \\leq x}$\n\\item $\\prob{X_1 > x, X_2 > x} = e^{-(\\lambda_1 + \\lambda_2)x}$\n\\item $\\support{T} = (0, \\infty)$\n\\item $T$ is Erlang-distributed\n\\item $T$ is Gamma-distributed\n\\item $T \\sim \\int_{\\support{X_1}} f_{X_1}(x) f_{X_2}(x)dx$\n\\item $T \\sim \\int_{\\support{X_1}} f_{X_1}(x) f_{X_2}(t-x)dx$\n\\item $T \\sim \\int_{\\support{X_1}} f_{X_1}^{old}(x) f_{X_2}^{old}(t-x) \\indic{t-x \\in \\support{X_1}} dx$\n\\item $T \\sim \\int_{0}^\\infty \\lambda_1 e^{-\\lambda_1 x} \\lambda_2 e^{-\\lambda_2 (t-x)} \\indic{x-t \\in (-\\infty, 0)} dx$\n\\item $T \\sim \\lambda_1 \\lambda_2 \\int_{0}^t e^{-\\lambda_1 x} e^{-\\lambda_2 (t-x)} dx$\n\\item $T \\sim \\lambda_1 \\lambda_2 e^{-\\lambda_2 t} \\indic{t > 0} \\int_{0}^t e^{(\\lambda_2 - \\lambda_1)x} dx$\n\\item $T \\sim \\frac{\\lambda_1 \\lambda_2}{\\lambda_2 - \\lambda_1} e^{-\\lambda_2 t} \\indic{t > 0} \\bracks{e^{(\\lambda_2 - \\lambda_1)x}}_0^t$\n\\item $T \\sim \\frac{\\lambda_1 \\lambda_2}{\\lambda_2 - \\lambda_1} e^{-\\lambda_2 t} e^{(\\lambda_2 - \\lambda_1)t} \\indic{t > 0}$\n\\item $T \\sim \\frac{\\lambda_1 \\lambda_2}{\\lambda_2 - \\lambda_1} \\parens{e^{-\\lambda_1 t} - e^{-\\lambda_2 t}} \\indic{t > 0}$\n\\item If (p) were to be true, then the density of $T$ would have a kernel given by $k(t) = e^{-\\lambda_1 t} - e^{-\\lambda_2 t}$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{9} Let $X_1, X_2 \\iid \\text{Lomax}\\parens{\\alpha, \\lambda} :=\\overbrace{\\alpha\\lambda^\\alpha \\tothepow{x + \\alpha}{-(\\alpha + 1)}}^{f^{old}(x)} \\indic{x > 0}$ with parameter space $\\alpha, \\lambda > 0$. Let $T = X_1 + X_2$, $R = X_1 / X_2$ and $N = X_1 / (X_1 +  X_2)$\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{10} \n\n\\begin{enumerate}[(a)]\n\\item If the density of $X_i$ were to be decomposed into $c \\times  k(x)$ then $c = \\alpha\\lambda^\\alpha$\n\\item $f_T(t) = \\indic{t>0} \\int_0^t f^{old}(x) f^{old}(t-x) dx$\n\\item $f_T(t) \\propto \\indic{t>0} \\int_0^t f^{old}(x) f^{old}(t-x) dx$\n\\item $f_T(t) \\propto \\indic{t>0} \\int_0^t \\tothepow{(x + \\alpha)(t - x + \\alpha)}{-(\\alpha + 1)} dx$\n\n\\item $f_R(r)  \\propto \\indic{r>0}\\displaystyle \\int_0^t \\displaystyle\\frac{f^{old}(x)}{f^{old}(r)} dx$\n\\item $f_R(r) = \\indic{r>0} \\int_0^\\infty x f^{old}(rx) f^{old}(x)  dx$\n\\item $f_R(r) \\propto \\indic{r>0} \\int_0^\\infty x \\tothepow{(rx + \\alpha)(x + \\alpha)}{-(\\alpha + 1)}  dx$\n\n\\item $f_N(n)  \\propto \\indic{n>0}\\displaystyle \\int_0^t \\displaystyle\\frac{f^{old}(x)}{f^{old}(x) + f^{old}(n)} dx$\n\\item $f_N(n) = \\indic{n>0} \\int_0^\\infty x f^{old}(nx) f^{old}(x - nx)  dx$\n\\item $f^{old}_N(n) \\propto  \\int_0^\\infty x \\tothepow{(nx + \\alpha)(x - nx + \\alpha)}{-(\\alpha + 1)}  dx$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{8} Let $X_1, X_2 \\iid \\gammanot{\\alpha}{\\beta}$. Let $T = X_1 + X_2$, $R = X_1 / X_2$ and $N = X_1 / (X_1 +  X_2)$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{11} \n\n\\begin{enumerate}[(a)]\n\\item $F_X(x) = P(\\alpha, \\beta x)$\n\\item $F_X(x) \\propto \\gamma(\\alpha, \\beta x)$\n\\item $T \\sim \\gammanot{2\\alpha}{\\beta}$\n\\item $T \\sim \\erlang{2\\alpha}{\\beta}$ if $2\\alpha \\in \\naturals$\n\\item $R \\sim \\text{BetaPrime}(\\alpha, \\alpha)$\n\\item $N \\sim \\text{Beta}(\\alpha, \\alpha)$\n\\item $N \\sim \\text{Beta}(\\beta, \\alpha)$ \\\\\n\nAssume (f) is true for the remainder of this problem\n\\item $N \\sim \\uniform{0}{1}$ if $\\alpha = 1$\n\\item $F_N(n) = \\int_0^n (u(1-u))^{\\alpha - 1} du$\n\\item $F_N(n) = B(n, \\alpha, \\alpha) / B(\\alpha, \\alpha)$\n\\item $F_N(n) = I_n (\\alpha, \\alpha)$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{13} Let $X_1, X_2 \\iid \\gammanot{\\alpha}{\\beta}$. Let  $M = X_1 X_2$, \\\\ $\\bv{g} : \\reals^2 \\rightarrow \\reals^2$, $\\bv{h} : \\reals^2 \\rightarrow \\reals^2$ which denotes the inverse of $\\bv{g}$, $\\bv{X} := \\twovec{X_1}{X_2}$, $\\bv{x} := \\twovec{x_1}{x_2}$, $\\bv{Y} := \\twovec{Y_1}{Y_2}$ and $\\bv{y} := \\twovec{y_1}{y_2}$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{14} \n\n\\begin{enumerate}[(a)]\n\\item $\\support{M} = (0, \\infty)$\n\\item The function $\\bv{g}(x_1, x_2) = \\twovec{x_1 x_2}{x_1 x_2}$ is invertible.\n\\item The function $\\bv{g}(x_1, x_2) = \\twovec{x_1 x_2}{x_2}$ is invertible. \n\\item If $\\bv{h}(y_1, y_2) = \\twovec{y_1 / y_2}{y_2}$, then the Jacobian determinant is $\\twobytwomat{1/y_2}{-y_1 / y_2^2}{0}{1}$.\n\\item If $\\bv{h}(y_1, y_2) = \\twovec{y_1 / y_2}{y_2}$, then the Jacobian determinant is $1/y_2$.\n\\item If $\\x = \\bv{h}(y_1, y_2) = \\twovec{y_1 / y_2}{y_2}$ then $f_{\\Y}(\\y) = f_{\\X}(y_1 / y_2, y_2) / \\abss{y_2}$\n\n\\item $f_M(m) = f_{\\X}(m, m)$\n\\item $f_M(m) = f_{X_1}(m) f_{X_2}(m)$\n\\item $f_M(m) = \\int_\\reals f_{X_1}(um) f_{X_2}(m) du$\n\\item $f_M(m) = \\int_\\reals f_{X_1}(m/u) f_{X_2}(u) / u ~du$\n\\item $f_M(m) = \\int_\\reals f_{X_1}(m/u) f_{X_2}(u) / |u| ~du$\n\\item $f_M(m) = \\int_\\reals f_{\\X}(m/u, u) / |u| ~du$\n\n\\item $f_M(m) = \\displaystyle\\frac{\\beta^{2\\alpha}}{\\Gamma(\\alpha)^2} \\indic{m > 0} \\int_0^\\infty \\oneover{u} \\tothepow{\\displaystyle \\frac{m}{u}}{\\alpha - 1} e^{-\\beta m / u} u^{\\alpha - 1} e^{-\\beta u}~du$\n\n\\item $f_M(m) = \\displaystyle\\frac{\\beta^{2\\alpha}}{\\Gamma(\\alpha)^2} m^{\\alpha - 1} \\indic{m > 0} \\int_0^\\infty \\frac{e^{-\\beta (m / u + u)}}{u} ~du$\n\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{9} Consider a sequence of rv's $\\Xoneton \\iid \\logistic{0}{1} := \\displaystyle \\frac{e^{-x}}{\\squared{1 + e^{-x}}}$ \\\\ whose expectation is zero and let $X_{(1)}, \\ldots, X_{(n)}$ denote this sequence's order statistics and $R := X_{(n)} - X_{(1)}$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{18} \n\n\\begin{enumerate}[(a)]\n\\item For all $i$, $X_i$ is an \\qu{error distribution}\n\\item There exist nonzero constants $a, b$ such that for all $i$, $a X_i + b$ is an \\qu{error distribution}\n\n\\item $F_{X_{(n)}} = F(x)^n$\n\\item If $\\Xoneton$ were not independent, the formula in (c) could be different\n\n\\item $X_{(1)}, \\ldots, X_{(n)} \\iid \\logistic{0}{1}$\n\\item $X_{(1)}, \\ldots, X_{(n)}$ are all independent\n\\item $X_{(1)}$ has most of its mass near zero\n\\item $X_{(n)}$ has most of its mass near zero\n\n\\item $\\support{X_{(k)}} = \\reals$ for all $k$ and all $n$\n\n\\item $\\expe{R} = 0$\n\n\\item $\\prob{R \\in [-a, +a]}$ for $a \\in \\reals$ increases as $n$ gets larger\n\n\\item $F_{X_{(1)}}(x) = 1 - \\tothepow{\\displaystyle \\frac{e^{-x}}{1 + e^{-x}}}{n}$ \n\\item $F_{X_{(1)}}(x) = 1 - n\\tothepow{\\displaystyle \\frac{e^{-x}}{1 + e^{-x}}}{n}$ \n\\item $F_{X_{(1)}}(x) = 1 - \\tothepow{\\displaystyle \\frac{e^{-x}}{(1 + e^{-x})^2}}{n}$ \n\n\\item $f_{X_{(1)}}(x) = n \\displaystyle\\tothepow{\\displaystyle \\frac{e^{-x}}{1 + e^{-x}}}{n}$ \n\\item $f_{X_{(k)}}(x) = n \\displaystyle \\frac{e^{-x(n-k+1)}}{(1 + e^{-x})^{n+1}} $  \n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{8} Let $X \\sim \\exponential{\\lambda}$ and $Y\\,|\\,X = x \\sim \\uniform{0}{x}$\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{10} \n\n\\begin{enumerate}[(a)]\n\\item The support of the joint density of $X$ and $Y$ is in the first quadrant of the cartesian plane, below the line $y=x$ and above the $x$-axis.\n\\item $\\support{Y} = [0,1]$\n\\item $\\prob{Y > 1/2} = 1/2$ for all $\\lambda$ in the parameter space of the exponential rv\n\\item For positive $y$, $f_Y(y)$ is monotonically decreasing\n\\item $f_X(x) = \\lambda e^{-\\lambda x}$\n\\item $f_Y(y) = \\lambda e^{-\\lambda y}$\n\n\\item $f_Y(y) = \\indic{y > 0} \\displaystyle\\int_y^\\infty \\displaystyle \\frac{e^{-\\lambda x}}{x} dx$\n\n\\item $\\support{X\\,|\\,Y=y} = [y, \\infty)$\n\\item $X\\,|\\,Y=y$ is a uniform rv\n\n\\item $\\displaystyle\\int_\\reals \\displaystyle\\int_\\reals \\displaystyle\\oneover{x} \\indic{y \\in [0, x]} ~\\lambda e^{-\\lambda x} \\indic{x > 0} ~dx dy = 1$ \n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{11} Let $X \\sim \\exponential{\\lambda}$ and $Y\\,|\\,X  = x \\sim \\exponential{x}$\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{12} \n\n\\begin{enumerate}[(a)]\n\\item $f_X(x) = \\lambda e^{-\\lambda x}$\n\\item $f_{Y\\,|\\,X}(y,x) = xe^{-xy} \\indic{y > 0}$\n\\item $\\lambda  \\displaystyle \\int_0^\\infty \\displaystyle\\int_0^\\infty xe^{-xy} ~e^{-\\lambda x}   ~dx dy = 1$ \n\\item The rv $Y$ is considered a \\qu{compound distribution}\n\n\\item $\\support{Y} = \\reals$\n\\item $Y$ is not a valid rv\n\\item $f_Y(y) = \\int_\\reals f_{Y\\,|\\,X}(y,x) f_X(x) dx$\n\n\\item $f_Y(y) = e^{-\\lambda y} / y \\indic{y>0}$\n\\item $f_Y(y) = \\lambda e^{-\\lambda y} / (y + \\lambda) \\indic{y>0}$\n\\item $f_Y(y) = \\lambda y / (y + \\lambda) \\indic{y>0}$\n\\item $f_Y(y) = \\lambda / (y + \\lambda)^2 \\indic{y>0}$\n\\item $f_Y(y) = \\lambda e^{-\\lambda y} / y \\indic{y>0}$\n\\end{enumerate}\n\\eenum\\instr \\\\\n\n\\noindent Some of these antiderivatives (from Wolfram Alpha) may help you with the above problem:\n\n\\beqn\n\\int x^3 e^{-a x} dx &=& -\\displaystyle\\frac{e^{-a x} (a^3 x^3 + 3 a^2 x^2 + 6 a x + 6)}{a^4} + C \\\\\n\\int x^2 e^{-a x} dx &=&  -\\displaystyle\\frac{e^{-a x} (a^2 x^2 + 2 a x + 2)}{a^3} + C \\\\\n\\int x e^{-a x} dx &=& -\\displaystyle\\frac{e^{-a x} (a x + 1)}{a^2} + C\n\\eeqn\n\\pagebreak\n\n%%%%% mixture\n\n\n\n\\end{document}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "abdab7b25d6d03539a57cba676e2d9b5348ff183", "size": 12475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/midterm2/midterm2.tex", "max_stars_repo_name": "kapelner/QC_MATH_368_Fall_2021", "max_stars_repo_head_hexsha": "08e9ebb9ed83276f4da33f1a9d6169604489a193", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exams/midterm2/midterm2.tex", "max_issues_repo_name": "kapelner/QC_MATH_368_Fall_2021", "max_issues_repo_head_hexsha": "08e9ebb9ed83276f4da33f1a9d6169604489a193", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exams/midterm2/midterm2.tex", "max_forks_repo_name": "kapelner/QC_MATH_368_Fall_2021", "max_forks_repo_head_hexsha": "08e9ebb9ed83276f4da33f1a9d6169604489a193", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.1004016064, "max_line_length": 1004, "alphanum_fraction": 0.6355911824, "num_tokens": 4780, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7826624789529375, "lm_q1q2_score": 0.44300146988989125}}
{"text": "\\subsection{Combining instance models}\n\\label{subsec:transformation_framework:instance_models_and_instance_graphs:combining_instance_models}\n\nThe structure of \\cref{fig:transformation_framework:instance_models_and_instance_graphs:structure_instance_models_graphs} shows that the instance models $Im_A$ and $Im_B$ are combined into one instance model $Im_{AB}$. This section provides the definition of this combination and its corresponding theorems. Please note that the definitions presented here are as generic as possible, and do not actively take into account that $Im_{A}$ and $Im_{B}$ are mostly distinct. This bit of information is added later as part of a theorem and proof.\n\n\\begin{defin}[Combination function on type models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine}\n$\\mathrm{combine}$ is a binary function on two instance models which combines two instance models into one instance model. Assume $Im_A$ is an instance model typed by type model $Tm_A$ and $Im_B$ is an instance model typed by type model $Tm_B$, then $\\mathrm{combine}(Im_A, Im_B)$ is typed by $\\mathrm{combine}(Tm_A, Tm_B)$ and is defined as follows:\n\\begin{align*}\n\\mathrm{combine}(Im_A, Im_B) = \\langle&\nObject = Object_{Im_A} \\cup Object_{Im_B} \\\\&\n\\mathrm{ObjectClass} = \\mathrm{objectclass\\_\\!combine}(Im_A, Im_B) \\\\&\n\\mathrm{ObjectId} = \\mathrm{objectid\\_\\!combine}(Im_A, Im_B) \\\\&\n\\mathrm{FieldValue} = \\mathrm{fieldvalue\\_\\!combine}(Im_A, Im_B) \\\\&\n\\mathrm{DefaultValue} = \\mathrm{defaultvalue\\_\\!combine}(Im_A, Im_B)\\rangle\n\\end{align*}\n\nIn which $\\mathrm{objectclass\\_\\!combine}$ is given as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:objectclass_combine}, $\\mathrm{objectid\\_\\!combine}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:objectid_combine}, $\\mathrm{fieldvalue\\_\\!combine}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:fieldvalue_combine} and $\\mathrm{defaultvalue\\_\\!combine}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:defaultvalue_combine}.\n\\isabellelref{imod_combine}{Ecore.Instance_Model_Combination}\n\\end{defin}\n\nThe combination of two instance models knows a surprisingly simple definition. This is mostly caused by the fact that an instance model only contains of a set of objects, which has some properties. The properties of each object are specified by the different functions, which will be introduced in the following definitions.\n\nFirst, the function for the combination of object classes is discussed.\n\n\\begin{defin}[Combination function for object classes]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:objectclass_combine}\n$\\mathrm{objectclass\\_\\!combine}$ is a partial function on two instance models which returns a new function \\\\$Object_{Im_{AB}} \\Rightarrow Class_{Tm_{AB}}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{objectclass\\_\\!combine}(Im_{A}, Im_{B}, o) = \\\\\n        \\begin{cases}\n        \\mathrm{ObjectClass}_{Im_A}(o) & \\mathrm{if }\\ o \\in Object_{Im_A} \\cap Object_{Im_B} \\land \\mathrm{ObjectClass}_{Im_A}(o) = \\mathrm{ObjectClass}_{Im_B}(o) \\\\\n        \\mathrm{ObjectClass}_{Im_A}(o) & \\mathrm{if }\\ o \\in Object_{Im_A} \\setminus Object_{Im_B} \\\\\n        \\mathrm{ObjectClass}_{Im_B}(o) & \\mathrm{if }\\ o \\in Object_{Im_B} \\setminus Object_{Im_A}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_object_class}{Ecore.Instance_Model_Combination}\n\\end{defin}\n\nThe combination of two instance models knows a surprisingly simple definition. Because an instance model is essentially a set of objects with properties, no complex definition is needed. The properties of each object are specified by the different functions, which will be introduced in the following definitions.\n\nFirst, the function of the combination of object classes is discussed.\n\n\\begin{defin}[Combination function for object identifiers]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:objectid_combine}\n$\\mathrm{objectid\\_\\!combine}$ is a partial function on two instance models which returns a new function \\\\$Object_{Im_{AB}} \\Rightarrow Name$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{objectid\\_\\!combine}(Im_{A}, Im_{B}, o) = \\\\\n        \\begin{cases}\n        \\mathrm{ObjectId}_{Im_A}(o) & \\mathrm{if }\\ o \\in Object_{Im_A} \\cap Object_{Im_B} \\land \\mathrm{ObjectId}_{Im_A}(o) = \\mathrm{ObjectId}_{Im_B}(o) \\\\\n        \\mathrm{ObjectId}_{Im_A}(o) & \\mathrm{if }\\ o \\in Object_{Im_A} \\setminus Object_{Im_B} \\\\\n        \\mathrm{ObjectId}_{Im_B}(o) & \\mathrm{if }\\ o \\in Object_{Im_B} \\setminus Object_{Im_A}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_object_id}{Ecore.Instance_Model_Combination}\n\\end{defin}\n\nAs mentioned before, the definition of the combination function of object identifiers is very similar to the definition of the combination function of object classes. If an object only occurs in one of the instance models, its identifier is copied over. If an object appears in both instance models, they must have the same identifier already in order to have an identifier in the final model.\n\nA careful reader might notice that the behaviour of the function is strange. Theoretically, it might give rise to double identities, which is undesired. As will be shown later, the combination function and theorems assume that the identities of the models are already distinct. This assumption is fair, as it is possible to redefine two instance models to have distinct identities, without loss of significance.\n\nThe following definition describes the combination of field values.\n\n\\begin{defin}[Combination function for field values]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:fieldvalue_combine}\n$\\mathrm{fieldvalue\\_\\!combine}$ is a partial function on two instance models which returns a new function \\\\$(Object_{Im_{AB}} \\times Field_{Tm_{AB}}) \\Rightarrow Value_{Im_{AB}}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{fieldvalue\\_\\!combine}(Im_A, Im_B, ( o, f )) = \\\\\n    \\begin{cases}\n        \\mathrm{FieldValue}_{Im_A}(( o, f )) & \\mathrm{if}\\ o \\in Object_{Im_A} \\cap Object_{Im_B}\\ \\land\\\\&\\quad f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))\\ \\land\\\\&\\quad f \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\ \\land\\\\&\\quad \\mathrm{FieldValue}_{Im_A}(( o, f )) = \\mathrm{FieldValue}_{Im_B}(( o, f )) \\\\\n        \\mathrm{FieldValue}_{Im_A}(( o, f )) & \\mathrm{if}\\ o \\in Object_{Im_A} \\land f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))\\ \\land\\\\&\\quad (o \\not\\in Object_{Im_B} \\lor f \\not\\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))) \\\\\n        \\mathrm{FieldValue}_{Im_B}(( o, f )) & \\mathrm{if}\\ o \\in Object_{Im_B} \\land f \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\ \\land\\\\&\\quad (o \\not\\in Object_{Im_A} \\lor f \\not\\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o)))\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_field_value}{Ecore.Instance_Model_Combination}\n\\end{defin}\n\nThe definition of the combination function of field values is a lot more complicated than the previous ones. The function domain causes this complexity. Not every combination of an object and a field has a value. An object only has values for those fields that are defined for its class or superclasses.\n\nWhen a value is set on one of the instance models, but not the other, the value is copied. Furthermore, if a combination of object and field is set for both instance models and the value is the same, it is also copied. Please note that equality is used here, instead of equivalence. This property is to support some mathematical properties later on. Since the transformation framework will not allow for shared fields anyhow, this will not impose problems later.\n\nThe last function that needs to be defined is the combination function for default values. It is given in the following definition.\n\n\\begin{defin}[Combination function for default values]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:defaultvalue_combine}\n$\\mathrm{defaultvalue\\_\\!combine}$ is a partial function on two instance models which returns a new function \\\\$Constant_{Tm_{AB}} \\Rightarrow Value_{Im_{AB}}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{defaultvalue\\_\\!combine}(Im_{A}, Im_{B}, c) = \\\\\n    \\begin{cases}\n        \\mathrm{DefaultValue}_{Im_A}(c) & \\mathrm{if }\\ c \\in Constant_{Tm_A} \\cap Constant_{Tm_B}\\ \\land\\\\&\\quad \\mathrm{DefaultValue}_{Im_A}(c) = \\mathrm{DefaultValue}_{Im_B}(c) \\\\\n        \\mathrm{DefaultValue}_{Im_A}(c) & \\mathrm{if }\\ c \\in Constant_{Tm_A} \\setminus Constant_{Tm_B} \\\\\n        \\mathrm{DefaultValue}_{Im_B}(c) & \\mathrm{if }\\ c \\in Constant_{Tm_B} \\setminus Constant_{Tm_A}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_default_value}{Ecore.Instance_Model_Combination}\n\\end{defin}\n\nThe definition of the combination function of default values is very similar to the combination function of constant types of type models (see \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_models:consttype_combine}). This function gives values to constants defined on the type model level. When a constant only appears in the type model of one of the instance models, the value can be copied from that instance model. This behaviour is logical since the other instance model cannot have a value set for that constant. If a constant is set for both of the corresponding type models, the value set on the instance models must be the same. If this is the case, the value can be copied over. This behaviour is desired, as the value for a constant should not change after the combination of two instance models.\n\nLike the last definition, equality is used here to compare the values, instead of equivalence. Once more, this has been done to support some mathematical properties later on. Since the transformation framework will not allow for shared constants anyhow, this will not impose problems later.\n\nWith all definitions in place, it is possible to provide an example. Let us return to the multi-protocol chat application example introduced in \\cref{fig:transformation_framework:type_models_and_type_graphs:combining_type_models:combine_example} of \\cref{subsec:transformation_framework:type_models_and_type_graphs:combining_type_models}. An instance model for $Tm_{Chat}$ (\\cref{fig:transformation_framework:type_models_and_type_graphs:combining_type_models:combine_example_tmod1}) could have an instance of a $\\type{Thread}$ with some $\\type{Message}$s. Formally, the instance model could look as follows:\n\n\\begin{align*}\nIm_{Chat} =\\ &\\langle&\nObject =\\ &\\{ 1, 2, 3 \\} \\\\&&\n\\mathrm{ObjectClass} =\\ &\\{\n( 1, \\type{.Thread} ),\n( 2, \\type{.Message} ),\n( 3, \\type{.Message} )\n\\} \\\\&&\n\\mathrm{ObjectId} =\\ &\\{\n( 1, \\text{Thread42} ),\n( 2, \\text{Message4084} ),\n( 3, \\text{Message4093} )\n\\} \\\\&&\n\\mathrm{FieldValue} =\\ &\\Big\\{\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{id} ) \\big), \\big[ \\type{string}, \\text{``BLUB-E\\_Thread\\_01''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{proto} ) \\big), \\big[ \\type{enum}, ( \\type{.Protocol}, \\type{BLUB\\!-\\!E} ) \\big] \\Big),\\\\&&&\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{messages} ) \\big), \\big[ \\type{seqof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ] \\big\\rangle \\big] \\Big),\\\\&&&\n\\Big( \\big( 2, ( \\type{.Message}, \\type{text} ) \\big), \\big[ \\type{string}, \\text{``This is a test''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 3, ( \\type{.Message}, \\type{text} ) \\big), \\big[ \\type{string}, \\text{``Did you receive it?''} \\big] \\Big)\n\\Big\\} \\\\&&\n\\mathrm{DefaultValue} =\\ &\\{\\}\n\\\\&\\rangle\n\\end{align*}\n\nA visual representation of this instance model is included in \\cref{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod1}. Now, assume that there also exists some instance model that is typed by the extension represented by $Tm_{Extension}$. This instance model introduces a $\\type{Contact}$ instance for the $\\type{Thread}$ instance in $Im_{Chat}$. Formally, this instance model could be defined as follows:\n\n\\begin{align*}\nIm_{Extension} =\\ &\\langle&\nObject =\\ &\\{ 1, 4 \\} \\\\&&\n\\mathrm{ObjectClass} =\\ &\\{\n( 1, \\type{.Thread} ),\n( 4, \\type{.Contact} )\n\\} \\\\&&\n\\mathrm{ObjectId} =\\ &\\{\n( 1, \\text{Thread42} ),\n( 4, \\text{Broodkast} )\n\\} \\\\&&\n\\mathrm{FieldValue} =\\ &\\Big\\{\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{contact} ) \\big), \\big[ \\type{obj}, 4 \\big] \\Big),\\\\&&&\n\\Big( \\big( 4, ( \\type{.Contact}, \\type{id} ) \\big), \\big[ \\type{data}, \\text{``BLUB-E\\_PubKey\\_a8138''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 4, ( \\type{.Contact}, \\type{name} ) \\big), \\big[ \\type{string}, \\text{``Lukas''} \\big] \\Big)\n\\Big\\} \\\\&&\n\\mathrm{DefaultValue} =\\ &\\{\\}\n\\\\&\\rangle\n\\end{align*}\n\nThe visual representation of $Im_{Extension}$ is included in \\cref{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod2}. With these instance models formally defined, it is possible to combine them using \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine}. This will yield the following model:\n\n\\begin{align*}\nIm_{ChatExt} =\\ &\\langle&\nObject =\\ &\\{ 1, 2, 3, 4 \\} \\\\&&\n\\mathrm{ObjectClass} =\\ &\\{\n( 1, \\type{.Thread} ),\n( 2, \\type{.Message} ),\n( 3, \\type{.Message} ),\n( 4, \\type{.Contact} )\n\\} \\\\&&\n\\mathrm{ObjectId} =\\ &\\{\n( 1, \\text{Thread42} ),\n( 2, \\text{Message4084} ),\n( 3, \\text{Message4093} ),\n( 4, \\text{Broodkast} )\n\\} \\\\&&\n\\mathrm{FieldValue} =\\ &\\Big\\{\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{id} ) \\big), \\big[ \\type{string}, \\text{``BLUB-E\\_Thread\\_01''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{proto} ) \\big), \\big[ \\type{enum}, ( \\type{.Protocol}, \\type{BLUB\\!-\\!E} ) \\big] \\Big),\\\\&&&\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{messages} ) \\big), \\big[ \\type{seqof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ] \\big\\rangle \\big] \\Big),\\\\&&&\n\\Big( \\big( 1, ( \\type{.Thread}, \\type{contact} ) \\big), \\big[ \\type{obj}, 4 \\big] \\Big),\\\\&&&\n\\Big( \\big( 2, ( \\type{.Message}, \\type{text} ) \\big), \\big[ \\type{string}, \\text{``This is a test''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 3, ( \\type{.Message}, \\type{text} ) \\big), \\big[ \\type{string}, \\text{``Did you receive it?''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 4, ( \\type{.Contact}, \\type{id} ) \\big), \\big[ \\type{data}, \\text{``BLUB-E\\_PubKey\\_a8138''} \\big] \\Big),\\\\&&&\n\\Big( \\big( 4, ( \\type{.Contact}, \\type{name} ) \\big), \\big[ \\type{string}, \\text{``Lukas''} \\big] \\Big)\n\\Big\\} \\\\&&\n\\mathrm{DefaultValue} =\\ &\\{\\}\n\\\\&\\rangle\n\\end{align*}\n\nA visual representation of this combined model is included as \\cref{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod12}. Like the example for the combination of type models, this example shows that the definition of the combination of instance models is useful. It allows to build larger models out of smaller building blocks. Furthermore, the example shows that the combination of the two instance models is typed by the combination of its corresponding type models.\n\n\\begin{figure}\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\includegraphics{images/04_transformation_framework/instance_models_combination/chat_instance_partial1.pdf}\n        \\caption{The chat application instance model $Im_{Chat}$}\n        \\label{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod1}\n    \\end{subfigure}\n    \\par\\medskip\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\includegraphics{images/04_transformation_framework/instance_models_combination/chat_instance_partial2.pdf}\n        \\caption{The contact extension instance model $Im_{Extension}$}\n        \\label{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod2}\n    \\end{subfigure}\n    \\par\\medskip\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\includegraphics{images/04_transformation_framework/instance_models_combination/chat_instance_combined.pdf}\n        \\caption{The extended chat application instance model $Im_{ChatExt}$}\n        \\label{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example_imod12}\n    \\end{subfigure}\n    \\caption{Example of the combination of type models}\n    \\label{fig:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine_example}\n\\end{figure}\n\nAlthough the definitions of the combination of instance models are given, no mathematical properties or theorems are defined yet. Some mathematical properties hold for the combination of instance models, that will be presented in the following theorems.\n\n\\begin{thm}[Commutativity of the combination of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_commute}\nAssume that $Im_A$ and $Im_B$ are instance models, then the $\\mathrm{combine}$ function is commutative:\n\\begin{equation*}\n    \\mathrm{combine}(Im_A, Im_B) = \\mathrm{combine}(Im_B, Im_A)\n\\end{equation*}\n\\isabellelref{imod_combine_commute}{Ecore.Instance_Model_Combination}\n\\end{thm}\n\n\\begin{thm}[Associativity of the combination of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_assoc}\nAssume that $Im_A$, $Im_B$ and $Im_C$ are instance models, then the $\\mathrm{combine}$ function is associative:\n\\begin{equation*}\n    \\mathrm{combine}(\\mathrm{combine}(Im_A, Im_B), Im_C) = \\mathrm{combine}(Im_A, \\mathrm{combine}(Im_B, Im_C))\n\\end{equation*}\n\\isabellelref{imod_combine_assoc}{Ecore.Instance_Model_Combination}\n\\end{thm}\n\n\\begin{thm}[Idempotence of the combination of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_idemp}\nAssume that $Im_A$ is an instance model and that it is valid in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Then the following property holds:\n\\begin{equation*}\n    \\mathrm{combine}(Im_A, Im_A) = Im_A\n\\end{equation*}\n\\isabellelref{imod_combine_idemp_alt}{Ecore.Instance_Model_Combination}\n\\end{thm}\n\nThese properties follow directly from \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine}, but the corresponding proofs will not be included here. It should be noted that these properties are indeed proven correct as part of this thesis, and the corresponding proofs are validated within Isabelle.\n\nBesides these properties, the combination of instance models also has an identity element. The empty instance model represents this identity element, but it needs to be defined first:\n\n\\begin{defin}[Empty instance model]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:empty_instance_model}\nLet $Im_{\\epsilon}$ be the empty instance model. It is typed by the empty type model $Tm_{\\epsilon}$. $Im_{\\epsilon}$ is defined as:\n\\begin{align*}\nIm_{\\epsilon} = \\langle&\nObject = \\{\\} \\\\&\n\\mathrm{ObjectClass} = undefined \\\\&\n\\mathrm{ObjectId} = undefined \\\\&\n\\mathrm{FieldValue} = undefined \\\\&\n\\mathrm{DefaultValue} = undefined\\rangle\n\\end{align*}\n\\end{defin}\n\n\\begin{thm}[Correctness of the empty type model]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_empty_correct}\nThe empty instance model, $Im_{\\epsilon}$, is valid with respect to\n\\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.\n\\isabellelref{imod_empty_correct}{Ecore.Instance_Model}\n\\end{thm}\n\nThe proof for the correctness of the empty instance model is trivial. Still, a validated version of this proof can be found within the Isabelle theories of this thesis.\n\nAs mentioned earlier, the empty instance model acts as an identity element when combining two instance models. The following theorem specifies this behaviour.\n\n\\begin{thm}[Identity of the combination of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_identity}\nAssume that $Im_A$ is an instance model and that it is valid in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Then $Im_{\\epsilon}$ acts as an identity element in the combination function:\n\\begin{equation*}\n    \\mathrm{combine}(Im_{\\epsilon}, Im_A) = Im_A\n\\end{equation*}\n\\isabellelref{imod_combine_identity_alt}{Ecore.Instance_Model_Combination}\n\\end{thm}\n\nOnce more, the proof of this theorem follows directly from the definition. Therefore, the corresponding proof will not be included here, but a validated version can be found within the Isabelle theories of this thesis.\n\nA final desired property for the combination of instance models is a correctness property. \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_correct} defines the theorem under which the combination of instance models is a valid instance model. Please note that this theorem is a generic theorem, which does not take into account that the instance models are mostly distinct.\n\n\\begin{thm}[Validity of the combination of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_correct}\nAssume that $Im_A$ and $Im_B$ are valid instance models in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Assume that $Im_A$ is typed by type model $Tm_A$. Furthermore, assume that $Im_B$ is typed by type model $Tm_B$. $Tm_A$ and $Tm_B$ are consistent by definition. Also assume that $Tm_{AB} = \\mathrm{combine}(Tm_A, Tm_B)$ is consistent in the sense of \\cref{defin:formalisations:ecore_formalisation:type_models:type_model_consistency}. Finally, assume the following properties:\n\\begin{itemize}\n    \\item For all shared objects, the object class must be the same in both instance models: $\\forall o \\in Object_{Im_A} \\cap Object_{Im_B}\\!: \\mathrm{ObjectClass}_{Im_A}(o) = \\mathrm{ObjectClass}_{Im_B}(o)$.\n    \\item For all shared objects, the object id must be the same in both instance models: $\\forall o \\in Object_{Im_A} \\cap Object_{Im_B}\\!: \\mathrm{ObjectId}_{Im_A}(o) = \\mathrm{ObjectId}_{Im_B}(o)$.\n    \\item For all shared constants within the corresponding type graphs, the default value must be the same in both instance models: $\\forall c \\in Constant_{Tm_A} \\cap Constant_{Tm_B}\\!:$\\\\$\\mathrm{DefaultValue}_{Im_A}(c) = \\mathrm{DefaultValue}_{Im_B}(c)$.\n    \\item The identifiers must be unique across both instance models: $\\forall o_1 \\in Object_{Im_A} \\setminus Object_{Im_B} \\land o_2 \\in Object_{Im_B} \\setminus Object_{Im_A}\\!: \\mathrm{ObjectId}_{Im_A}(o_1) = \\mathrm{ObjectId}_{Im_B}(o_2) \\implies o_1 = o_2$.\n    \\item If a field value is set for a combination of an object and field in both instance models, that field value must be the same in both instance models: $\\forall o \\in Object_{Im_A} \\cap Object_{Im_B}\\ \\land$\\\\$f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o)) \\cap \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\!:$\\\\$\\mathrm{FieldValue}_{Im_A}(( o, f )) = \\mathrm{FieldValue}_{Im_B}(( o, f ))$.\n    \\item If an object needs a field value in the combination of $Im_A$ and $Im_B$, but this field value is not set in $Im_A$, then it must be set in $Im_B$:\n    $\\forall o \\in Object_{Im_A} \\land f \\not\\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))\\!:\n    f \\in \\mathrm{fields}_{Tm_{AB}}(\\mathrm{ObjectClass}_{\\mathrm{combine}(Im_A, Im_B)}(o)) \\implies$\\\\$\n    o \\in Object_{Im_B} \\land f \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))$.\n    \\item If an object needs a field value in the combination of $Im_A$ and $Im_B$, but this field value is not set in $Im_B$, then it must be set in $Im_A$:\n    $\\forall o \\in Object_{Im_B} \\land f \\not\\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\!:\n    f \\in \\mathrm{fields}_{Tm_{AB}}(\\mathrm{ObjectClass}_{\\mathrm{combine}(Im_A, Im_B)}(o)) \\implies$\\\\$\n    o \\in Object_{Im_A} \\land f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))$.\n    \\item For field values copied from $Im_A$ that are in $ContainerValue_{Im_A}$, the combined multiplicity must be correct: $\\forall o \\in Object_{Im_A}\\ \\land f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))\\ \\land$\\\\$f \\in Field_{Tm_B}\\!: \\mathrm{FieldValue}_{Im_A}(( o, f )) \\in ContainerValue_{Im_A} \\implies$\\\\$\\mathrm{lower}_{Tm_{AB}}(\\mathrm{FieldSig}_{Tm_{AB}}(f)) \\leq |\\mathrm{FieldValue}_{Im_A}(( o, f ))|\\ \\land$\\\\$|\\mathrm{FieldValue}_{Im_A}(( o, f ))| \\leq \\mathrm{upper}_{Tm_{AB}}(\\mathrm{FieldSig}_{Tm_{AB}}(f))$.\n    \\item For field values copied from $Im_B$ that are in $ContainerValue_{Im_B}$, the combined multiplicity must be correct: $\\forall o \\in Object_{Im_B}\\ \\land f \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\ \\land$\\\\$f \\in Field_{Tm_A}\\!: \\mathrm{FieldValue}_{Im_B}(( o, f )) \\in ContainerValue_{Im_B} \\implies$\\\\$\\mathrm{lower}_{Tm_{AB}}(\\mathrm{FieldSig}_{Tm_{AB}}(f)) \\leq |\\mathrm{FieldValue}_{Im_B}(( o, f ))|\\ \\land$\\\\$|\\mathrm{FieldValue}_{Im_B}(( o, f ))| \\leq \\mathrm{upper}_{Tm_{AB}}(\\mathrm{FieldSig}_{Tm_{AB}}(f))$.\n    \\item If there exists a containment property in $Tm_{AB}$, the satisfaction formula for containment properties must be satisfied: $\\forall o \\in Object_{Im_A} \\cup Object_{Im_B}\\!:$\\\\$\\big|\\big\\{ \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\mid \\big( ( f\\!o, f\\!\\!f ), fv \\big) \\in \\mathrm{FieldValue}_{\\mathrm{combine}(Im_A, Im_B)} \\land [ \\type{obj}, o ] = f\\!v \\land f\\!\\!f \\in CR_{Tm_{AB}} \\big\\}\\big| \\leq 1$\n    \\item There may be no cycles in the containment edges of the combined instance model: $\\big\\{ (f\\!o, f\\!v) \\mid \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\in \\mathrm{FieldValue}_{\\mathrm{combine}(Im_A, Im_B)} \\land f\\!\\!f \\in CR_{Tm_{AB}} \\big\\}$ is acyclic.\n    \\item The identity properties must remain satisfied when combining objects from different instance models: $\\forall [ \\type{identity}, c, A ] \\in Prop_{Tm_{A}} \\land [ \\type{identity}, c, A ] \\in Prop_{Tm_{B}} \\land o_1 \\in Object_{Im_A} \\setminus Object_{Im_B} \\land o_2 \\in Object_{Im_B} \\setminus Object_{Im_A} \\land \\mathrm{ObjectClass}_{Im_A}(o_1) = c \\land \\mathrm{ObjectClass}_{Im_B}(o_2) = c \\land a \\in A\\!: \\mathrm{FieldValue}_{Im_A}(( o_1, a )) \\equiv_{\\mathrm{combine}(Im_A, Im_B)} \\mathrm{FieldValue}_{Im_B}(( o_2, a )) \\implies o_1 = o_2$.\n    \\item The opposite properties must remain satisfied when combining objects from different instance models: $\\forall [ \\type{opposite}, r_1, r_2 ] \\in Prop_{Tm_{A}} \\land [ \\type{opposite}, r_1, r_2 ] \\in Prop_{Tm_{B}}\\ \\land$\\\\$o_1 \\in Object_{Im_A} \\land (o_1 \\not\\in Object_{Im_B} \\lor r_1 \\not\\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o_1)))\\ \\land$\\\\$o_2 \\in Object_{Im_B} \\land (o_2 \\not\\in Object_{Im_A} \\lor r_2 \\not\\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o_2))) \\implies$\\\\$ \\mathrm{edgeCount}_{Im_A}(o_1, r_1, o_2) = \\mathrm{edgeCount}_{Im_B}(o_2, r_2, o_1)$.\n\\end{itemize}\n\nThen $\\mathrm{combine}(Im_A, Im_B)$ is a valid instance model in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}\n\\isabellelref{imod_combine_correct}{Ecore.Instance_Model_Combination}\n\\end{thm}\n\n\\begin{proof}\nTo proof that $\\mathrm{combine}(Im_A, Im_B)$ is a valid instance model, it needs to be shown that\\\\ $\\mathrm{combine}(Im_A, Im_B)$ gives rise to a valid structure for an instance model and that \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity} holds. For readability, define $Im_{AB}$ to be $\\mathrm{combine}(Im_A, Im_B)$.\n\n\\emph{Structural properties}\n\\begin{itemize}\n    \\item For each object $o$, $\\mathrm{ObjectClass}_{Im_{AB}}(o)$ must be an element of $Class_{Tm_{AB}}$.\n\n    If $o \\in Object_{Im_A} \\setminus Object_{Im_B}$, then $\\mathrm{ObjectClass}_{Im_{AB}}(o) \\in Class_{Tm_{AB}}$.\n    \n    Similarly, if $o \\in Object_{Im_B} \\setminus Object_{Im_A}$, then $\\mathrm{ObjectClass}_{Im_{AB}}(o) \\in Class_{Tm_{AB}}$.\n    \n    If $o \\in Object_{Im_A} \\cap Object_{Im_B}$, then $\\mathrm{ObjectClass}_{Im_{A}}(o) = \\mathrm{ObjectClass}_{Im_{B}}(o)$ by assumption. Therefore $\\mathrm{ObjectClass}_{Im_{AB}}(o) \\in Class_{Tm_{AB}}$.\n\n\n    \\item For each object $o$, $\\mathrm{ObjectId}_{Im_{AB}}(o)$ must be an element of $Name$.\n    \n    If $o \\in Object_{Im_A} \\setminus Object_{Im_B}$, then $\\mathrm{ObjectId}_{Im_{AB}}(o) \\in Name$.\n    \n    Similarly, if $o \\in Object_{Im_B} \\setminus Object_{Im_A}$, then $\\mathrm{ObjectId}_{Im_{AB}}(o) \\in Name$.\n    \n    If $o \\in Object_{Im_A} \\cap Object_{Im_B}$, then $\\mathrm{ObjectId}_{Im_{A}}(o) = \\mathrm{ObjectId}_{Im_{B}}(o)$ by assumption. Therefore $\\mathrm{ObjectId}_{Im_{AB}}(o) \\in Name$.\n    \n    \n    \\item For each object $o$, and $f \\in \\mathrm{fields}_{Tm_{AB}}(\\mathrm{ObjectClass}_{Im_{AB}}(o))$, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f ))$ must be an element of $Value_{Im_{AB}}$.\n    \n    First, note that $Value_{Im_A} \\cup Value_{Im_B} \\subseteq Value_{Im_{AB}}$\\\\(see \\isabelleref{imod_combine_value}{Ecore.Instance_Model_Combination}).\n    \n    If $o \\in Object_{Im_A} \\setminus Object_{Im_B}$, then $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$ and, therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) \\in Value_{Im_{AB}}$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in Object_{Im_B}$. However, $f \\not\\in Object_{Im_B}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_B} \\setminus Object_{Im_A}$, then $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$ and, therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) \\in Value_{Im_{AB}}$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in Object_{Im_A}$. However, $f \\not\\in Object_{Im_A}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_A} \\cap Object_{Im_B}$, then \\\\$f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$ and, therefore, \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) \\in Value_{Im_{AB}}$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$ which means that \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) \\in Value_{Im_{AB}}$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$ which means that \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) \\in Value_{Im_{AB}}$.\n    \\end{itemize}\n    \n    \n    \\item For each constant $c$ in $Constant_{Tm_{AB}}$, $\\mathrm{DefaultValue}_{Im_{AB}}(c)$ must be an element of $Value_{Im_{AB}}$.\n    \n    First, note that $Value_{Im_A} \\cup Value_{Im_B} \\subseteq Value_{Im_{AB}}$\\\\(see \\isabelleref{imod_combine_value}{Ecore.Instance_Model_Combination}).\n    \n    If $c \\in Constant_{Tm_A} \\setminus Constant_{Tm_B}$, then $\\mathrm{DefaultValue}_{Im_{AB}}(c) \\in Value_{Im_{AB}}$.\n    \n    Similarly, if $c \\in Constant_{Tm_B} \\setminus Constant_{Tm_A}$, then $\\mathrm{DefaultValue}_{Im_{AB}}(c) \\in Value_{Im_{AB}}$.\n    \n    If $c \\in Constant_{Tm_A} \\cap Constant_{Tm_B}$, then $\\mathrm{DefaultValue}_{Im_{A}}(c) = \\mathrm{DefaultValue}_{Im_{B}}(c)$ by assumption. Therefore $\\mathrm{DefaultValue}_{Im_{AB}}(c) \\in Value_{Im_{AB}}$.\n\\end{itemize}\n\n\\emph{Validity properties}\n\\begin{itemize}\n    \\item $\\forall (( o, f ), v ) \\in \\mathrm{FieldValue}_{Im_{AB}}\\!: v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$\n    \n    If $o \\in Object_{Im_A} \\setminus Object_{Im_B}$, then $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. In this case $\\mathrm{type}_{Tm_{AB}}(f) = \\mathrm{type}_{Tm_{A}}(f)$ because types are preserved by $Tm_{AB}$. Therefore, $v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in Object_{Im_B}$. However, $f \\not\\in Object_{Im_B}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_B} \\setminus Object_{Im_A}$, then $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$. In this case $\\mathrm{type}_{Tm_{AB}}(f) = \\mathrm{type}_{Tm_{B}}(f)$ because types are preserved by $Tm_{AB}$. Therefore, $v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in Object_{Im_A}$. However, $f \\not\\in Object_{Im_A}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_A} \\cap Object_{Im_B}$, then \\\\$f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. In this case $\\mathrm{type}_{Tm_{AB}}(f) = \\mathrm{type}_{Tm_{A}}(f)$ because types are preserved by $Tm_{AB}$. Therefore, $v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$. Furthermore, $\\mathrm{type}_{Tm_{AB}}(f) = \\mathrm{type}_{Tm_{A}}(f)$ because types are preserved by $Tm_{AB}$. Therefore, $v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. Furthermore, $\\mathrm{type}_{Tm_{AB}}(f) = \\mathrm{type}_{Tm_{A}}(f)$ because types are preserved by $Tm_{AB}$. Therefore, $v:_{Im} \\mathrm{type}_{Tm_{AB}}(f)$.\n    \\end{itemize}\n    \n    \n    \\item $\\forall (( o, f ), v ) \\in \\mathrm{FieldValue}_{Im_{AB}}\\!: \\mathrm{validMul}_{Im_{AB}}(v)$.\n    \n    If $o \\in Object_{Im_A} \\setminus Object_{Im_B}$, then $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. Because $Im_{A}$ is valid, $\\mathrm{validMul}_{Im_{A}}(v)$ holds. If the multiplicity is preserved because $f \\not\\in Field_{Tm_B}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$. If the multiplicity is changed because $f \\in Field_{Tm_B}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$ is proven by assumption.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in Object_{Im_B}$. However, $f \\not\\in Object_{Im_B}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_B} \\setminus Object_{Im_A}$, then $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$. Because $Im_{B}$ is valid, $\\mathrm{validMul}_{Im_{B}}(v)$ holds. If the multiplicity is preserved because $f \\not\\in Field_{Tm_A}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$. If the multiplicity is changed because $f \\in Field_{Tm_A}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$ is proven by assumption.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in Object_{Im_A}$. However, $f \\not\\in Object_{Im_A}$, so this case is invalid.\n    \\end{itemize}\n    \n    If $o \\in Object_{Im_A} \\cap Object_{Im_B}$, then \\\\$f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$ or \\\\$f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$ or $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$.\n    \n    \\begin{itemize}\n        \\item If $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o)) \\cap \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then \\\\$\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. In this case $\\mathrm{validMul}_{Im_{AB}}(v)$ is proven by assumption since the multiplicity of $f$ has been combined into a new multiplicity.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{B}}(( o, f ))$. Furthermore, because $Im_{B}$ is valid, $\\mathrm{validMul}_{Im_{B}}(v)$ holds. If the multiplicity is preserved because $f \\not\\in Field_{Tm_A}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$. If the multiplicity is changed because $f \\in Field_{Tm_A}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$ is proven by assumption.\n        \n        \\item If $f \\not\\in \\mathrm{fields}_{Tm_{B}}(\\mathrm{ObjectClass}_{Im_{B}}(o))$, then by assumption, $f \\in \\mathrm{fields}_{Tm_{A}}(\\mathrm{ObjectClass}_{Im_{A}}(o))$. Therefore, $\\mathrm{FieldValue}_{Im_{AB}}(( o, f )) = \\mathrm{FieldValue}_{Im_{A}}(( o, f ))$. Furthermore, because $Im_{A}$ is valid, $\\mathrm{validMul}_{Im_{A}}(v)$ holds. If the multiplicity is preserved because $f \\not\\in Field_{Tm_B}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$. If the multiplicity is changed because $f \\in Field_{Tm_B}$, then $\\mathrm{validMul}_{Im_{AB}}(v)$ is proven by assumption.\n    \\end{itemize}\n    \n    \n    \\item $\\forall p \\in Prop_{Tm_{AB}}\\!: Im \\models p$\n    \n    Make a case distinction for the different possible properties.\n    \\begin{itemize}\n        \\item For $[ \\type{abstract}, c ] \\in Prop_{Tm_{AB}}$, use the fact that $Tm_{AB}$ is consistent to establish that abstract properties are only copied iff there are no instances of it in the combined instance graph (see \\cref{defin:transformation_framework:type_models_and_type_graphs:combining_type_models:prop_combine} for details). Therefore, $Im \\models [ \\type{abstract}, c ]$.\n        \n        \\item For $[ \\type{containment}, r ] \\in Prop_{Tm_{AB}}$, use the assumptions to prove that $Im \\models [ \\type{containment}, r ]$.\n        \n        \\item For $[ \\type{defaultValue}, f, v ] \\in Prop_{Tm_{AB}}$, there is no specific satisfaction formula, therefore $Im \\models [ \\type{defaultValue}, f, v ]$.\n        \n        \\item For $[ \\type{identity}, c, A ] \\in Prop_{Tm_{AB}}$, if the property was copied over from only one of the type models, then $Im \\models [ \\type{identity}, c, A ]$. This is the case because $c$ could not have been part of the other type model and therefore not occur in its instance models.\n        \n        If $[ \\type{identity}, c, A ] \\in Prop_{Tm_{AB}}$ was present in both type models, then the identity satisfaction formula will be correct for each pair of instances from $Im_{A}$ and each pair of instances from $Im_{B}$. To ensure that it is correct for mixed instance pairs, use the assumption specified. Then establish that $Im \\models [ \\type{identity}, c, A ]$.\n        \n        \\item For $[ \\type{keyset}, r, A ] \\in Prop_{Tm_{AB}}$, it is clear that each value of $r$ in the combined instance graph is either the copied field value from $Im_{A}$ or the copied field value from $Im_{B}$. Since values are preserved, there can be no new objects added to an existing relation. Therefore, $Im \\models [ \\type{keyset}, r, A ]$.\n        \n        \\item For $[ \\type{opposite}, r, r' ] \\in Prop_{Tm_{AB}}$, if the property was copied over from only one of the type models, then $Im \\models [ \\type{opposite}, r, r' ]$. This is the case because $r$ and $r'$ could not have been part of the other type model and therefore not occur in its instance models.\n        \n        If $[ \\type{opposite}, r, r' ] \\in Prop_{Tm_{AB}}$ was present in both type models, then the opposite satisfaction formula will be correct for each pair of instances from $Im_{A}$ and each pair of instances from $Im_{B}$. To ensure that it is correct for mixed instance pairs, use the assumption specified. Then establish that $Im \\models [ \\type{opposite}, r, r' ]$.\n        \n        \\item For $[ \\type{readonly}, f ] \\in Prop_{Tm_{AB}}$, there is no specific satisfaction formula, therefore $Im \\models [ \\type{readonly}, f ]$.\n    \\end{itemize}\n    \n    \n    \\item $\\forall c \\in Constant_{Tm_{AB}}\\!: \\mathrm{DefaultValue}_{Im_{AB}}(c):_{Im_{AB}} \\mathrm{ConstType}_{Tm_{AB}}(c)$.\n    \n    If $c \\in Constant_{Tm_A} \\setminus Constant_{Tm_B}$, then $\\mathrm{DefaultValue}_{Im_{AB}}(c) = \\mathrm{DefaultValue}_{Im_{A}}(c)$. Furthermore, $\\mathrm{ConstType}_{Tm_{AB}}(c) = \\mathrm{ConstType}_{Tm_{A}}(c)$. Therefore, \\\\$\\mathrm{DefaultValue}_{Im_{AB}}(c):_{Im_{AB}} \\mathrm{ConstType}_{Tm_{AB}}(c)$.\n    \n    Similarly, if $c \\in Constant_{Tm_B} \\setminus Constant_{Tm_A}$, then $\\mathrm{DefaultValue}_{Im_{AB}}(c) = \\mathrm{DefaultValue}_{Im_{B}}(c)$. Furthermore, $\\mathrm{ConstType}_{Tm_{AB}}(c) = \\mathrm{ConstType}_{Tm_{B}}(c)$. Therefore, \\\\$\\mathrm{DefaultValue}_{Im_{AB}}(c):_{Im_{AB}} \\mathrm{ConstType}_{Tm_{AB}}(c)$.\n    \n    If $c \\in Constant_{Tm_A} \\cap Constant_{Tm_B}$, then $\\mathrm{DefaultValue}_{Im_{A}}(c) = \\mathrm{DefaultValue}_{Im_{B}}(c)$ by assumption. Furthermore, $\\mathrm{ConstType}_{Tm_{A}}(c) = \\mathrm{ConstType}_{Tm_{B}}(c)$, since $Tm_{AB}$ is consistent. Therefore, $\\mathrm{DefaultValue}_{Im_{AB}}(c):_{Im_{AB}} \\mathrm{ConstType}_{Tm_{AB}}(c)$.\n    \n    \n    \\item $Tm_{AB}$ is consistent, as defined in \\cref{defin:formalisations:ecore_formalisation:type_models:type_model_consistency}.\n    \n    This is specified to be true by assumption.\n\\end{itemize}\n\nThe proofs of all these individual properties complete the entire proof.\n\\end{proof}\n\nAs explained before, \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_correct} does not take into account that the instance models are supposed to be distinct except for a set of objects. Furthermore, it does not take into account that the corresponding type models are supposed to be distinct except for a set of types. The following lemma is an alternation of the previous theorem, which takes these properties into account.\n\n\\begin{lem}[Consistency of the combination (mostly) distinct of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_merge_correct}\nAssume that $Im_A$ and $Im_B$ are valid instance models in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Assume that $Im_A$ is typed by type model $Tm_A$. Furthermore, assume that $Im_B$ is typed by type model $Tm_B$. $Tm_A$ and $Tm_B$ are consistent by definition. Also assume that $Tm_{AB} = \\mathrm{combine}(Tm_A, Tm_B)$ is consistent in the sense of \\cref{defin:formalisations:ecore_formalisation:type_models:type_model_consistency}. Moreover, assume that $Tm_{A}$ and $Tm_{B}$ are entirely distinct except for a set of types $T$. Also assume that $Im_{A}$ and $Im_{B}$ are entirely distinct except for a set of objects $O$. Finally, assume the following properties:\n\\begin{itemize}\n    \\item For all shared objects, the object class must be the same in both instance models: $\\forall o \\in Object_{Im_A} \\cap Object_{Im_B}\\!: \\mathrm{ObjectClass}_{Im_A}(o) = \\mathrm{ObjectClass}_{Im_B}(o)$.\n    \\item For all shared objects, the object id must be the same in both instance models: $\\forall o \\in Object_{Im_A} \\cap Object_{Im_B}\\!: \\mathrm{ObjectId}_{Im_A}(o) = \\mathrm{ObjectId}_{Im_B}(o)$.\n    \\item For all shared constants within the corresponding type graphs, the default value must be the same in both instance models: $\\forall c \\in Constant_{Tm_A} \\cap Constant_{Tm_B}\\!:$\\\\$\\mathrm{DefaultValue}_{Im_A}(c) = \\mathrm{DefaultValue}_{Im_B}(c)$.\n    \\item The identifiers must be unique across both instance models: $\\forall o_1 \\in Object_{Im_A} \\setminus Object_{Im_B} \\land o_2 \\in Object_{Im_B} \\setminus Object_{Im_A}\\!: \\mathrm{ObjectId}_{Im_A}(o_1) = \\mathrm{ObjectId}_{Im_B}(o_2) \\implies o_1 = o_2$.\n    \\item If an object needs a field value in the combination of $Im_A$ and $Im_B$, but this field value is not set in $Im_A$, then it must be set in $Im_B$:\n    $\\forall o \\in Object_{Im_A} \\land f \\not\\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))\\!:\n    f \\in \\mathrm{fields}_{Tm_{AB}}(\\mathrm{ObjectClass}_{\\mathrm{combine}(Im_A, Im_B)}(o)) \\implies$\\\\$\n    o \\in Object_{Im_B} \\land f \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))$.\n    \\item If an object needs a field value in the combination of $Im_A$ and $Im_B$, but this field value is not set in $Im_B$, then it must be set in $Im_A$:\n    $\\forall o \\in Object_{Im_B} \\land f \\not\\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{Im_B}(o))\\!:\n    f \\in \\mathrm{fields}_{Tm_{AB}}(\\mathrm{ObjectClass}_{\\mathrm{combine}(Im_A, Im_B)}(o)) \\implies$\\\\$\n    o \\in Object_{Im_A} \\land f \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{Im_A}(o))$.\n    \\item If there exists a containment property in $Tm_{AB}$, the satisfaction formula for containment properties must be satisfied: $\\forall o \\in Object_{Im_A} \\cup Object_{Im_B}\\!:$\\\\$\\big|\\big\\{ \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\mid \\big( ( f\\!o, f\\!\\!f ), fv \\big) \\in \\mathrm{FieldValue}_{\\mathrm{combine}(Im_A, Im_B)} \\land [ \\type{obj}, o ] = f\\!v \\land f\\!\\!f \\in CR_{Tm_{AB}} \\big\\}\\big| \\leq 1$\n    \\item There may be no cycles in the containment edges of the combined instance model: $\\big\\{ (f\\!o, f\\!v) \\mid \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\in \\mathrm{FieldValue}_{\\mathrm{combine}(Im_A, Im_B)} \\land f\\!\\!f \\in CR_{Tm_{AB}} \\big\\}$ is acyclic.\n\\end{itemize}\n\nThen $\\mathrm{combine}(Im_A, Im_B)$ is a valid instance model in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.\n\\isabellelref{imod_combine_merge_correct}{Ecore.Instance_Model_Combination}\n\\end{lem}\n\n\\begin{proof}\nUse \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_correct} to show that $\\mathrm{combine}(Im_A, Im_B)$ is a consistent type model. Use the assumptions given. Some assumptions of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_correct} become irrelevant because $Im_A$ and $Im_B$ are mostly distinct.\n\\end{proof}\n\nFinally, the concept of compatibility between two instance models is defined.\n\n\\begin{defin}[Compatibility of instance models]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:compatibility}\nAssume instance models $Im_A$ and $Im_B$. We say that $Im_A$ is compatible with $Im_B$ if  $\\mathrm{combine}(Im_A, Im_B)$ is a valid instance model in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.\n\\end{defin}\n\nThe notion of compatibility will be used later as a way to denote instance models that can be combined with other instance models without loss of validity.", "meta": {"hexsha": "d5176f0049fd858d483576adee4f72abe283b80c", "size": 50244, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/01_combining_instance_models.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/01_combining_instance_models.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/01_combining_instance_models.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 98.324853229, "max_line_length": 840, "alphanum_fraction": 0.7098559032, "num_tokens": 15475, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624738835052, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.44300146702049864}}
{"text": "% !TEX root = ../summary_jonah.tex\n% !TEX program = xelatex\n% !TEX encoding = utf8\n% !TEX spellcheck = en_UK\n\n\\section{Introduction to the Standard Model}\\label{sm-basics}\nThe Standard Model (SM) of particle physics presents one of the key achievements of modern day particle physics and provides a variety of phenomenological predictions that are experimentally verifiable to high accuracy.\n%%% MORE MORE MORE %%%\nThe SM gauge group is given by\n\\begin{align}\\label{gsm}\n  \\gsm&=\\su(3)_C\\times\\su(2)_T\\times\\un(1)_Y,\n\\end{align}\nwhere each group factor corresponds to a specific kind of interaction in the model.\nThe field content of the SM is given by the scalar doublet $\\phi$, the gauge vectors $B^\\mu$, $W_k^\\mu$, $\\mathcal{A}_a^\\mu$, and three generations of left-handed\\footnote{Right-handed fermions can be acommodated for by making use of charge conjugation.} Weyl fermions $\\psi_f$~\\cite{arthur, pdg}.\n\n\\noindent All these fields transform in their respective $\\gsm$-representations as can be seen in tab.\\,\\ref{sm-fields}.\n\\begin{table}[H]\\centering\n\\caption{Field content of the standard model. For the sake of simplicity generational indices are supressed.\\label{sm-fields}}\n\\begin{tabular}{ccc}\nfield& spin& representation\\\\\n$\\phi$&$0$&$\\rep{1}{2}{\\frac12}$\\\\\n$q_L$&$\\sfrac12$&$\\rep{3}{2}{\\frac16}$\\\\\n$u_R^c$&$\\sfrac12$&$\\rep{3}{1}{-\\frac23}$\\\\\n$d_R^c$&$\\sfrac12$&$\\rep{3}{1}{\\frac13}$\\\\\n$\\ell_L$&$\\sfrac12$&$\\rep{1}{2}{-\\frac12}$\\\\\n$e_R^c$&$\\sfrac12$&$\\rep{1}{1}{1}$\\\\\n$B^\\mu$&$1$&$\\rep{1}{1}{0}$\\\\\n$W_k^\\mu$&$1$&$\\rep{1}{3}{0}$\\\\\n$\\mathcal{A}_a^\\mu$&$1$&$\\rep{8}{1}{0}$\n\\end{tabular}\n\\end{table}\nThe $\\su(2)$-doublets can be identified with the familiar fields as:\n\\begin{align}\n\\phi=\\vect{\\phi_+\\\\\\phi_0},\\quad\\quad q_L=\\vect{u_L\\\\d_L},\\quad\\quad\\ell_L=\\vect{\\nu_L\\\\e_L}.\n\\end{align}\nAfter electroweak symmetry breaking, the electric charge is\n\\begin{align}\nQ&=Y+T_3,\n\\end{align}\nso that the well-known particle spectrum of the SM is recovered~\\cite{arthur, pdg}.\n\n\\noindent From a theoretical perspective the gauge group in eq.\\ \\eqref{gsm} is rather unattractive because of its cumbersome structure and the appearance of several distinct and seemingly unrelated representations from which the fields emerge. Theories with simpler gauge groups and fields transforming in fewer representations, would be more appealing if their phenomenology could be broken down to the SM in some suitable low-energy limit. In the literature many such models are discussed, with the \\textsc{Georgi-Glashow} model being pivotal in understanding how the SM-representations may originate. Here, $\\gsm$ is embedded in the simple group $\\su(5)$ and the SM-fields fit neatly into the representations:\n\\begin{align}\n  \\mathbf{5}&=\\rep{3}{1}{-\\frac13}\\oplus\\rep{1}{2}{\\frac12}\\\\\n  \\mathbf{10}&=\\rep{3}{2}{\\frac16}\\oplus\\crep{3}{1}{-\\frac23}\\oplus\\rep{1}{1}{1}\\\\\n  \\mathbf{24}&=\\rep{8}{1}{0}\\oplus\\rep{1}{3}{0}\\oplus\\rep{1}{1}{0}\\oplus\\rep{3}{2}{-\\frac53}\\oplus\\crep{3}{2}{\\frac53}.\n\\end{align}\nNevertheless, there are some impediments damping this rather promising result, most strikingly the existance of other fields transforming in the residual representations, which could lead to proton decay and other unwanted processes~\\cite{su5}.\nFrom there, one can go higher and embed $\\gsm$, using the $\\su(5)$-unification scheme, in higher-dimensional symmetry groups. This could lead to a breaking chain \\mbox{$E_8\\!\\to\\!E_7\\!\\to\\!E_6\\!\\to\\!\\operatorname{SO}(10)\\!\\to\\!\\su(5)\\!\\to\\!\\gsm$} motivated by symmetries in current candidates for a Theory of Everything like String Theory~\\cite{arthur, pdg, ramond}.\n\n\\noindent As expected from gauge theories, the dynamical terms in the SM are constructed out of the field strength tensors, which in turn are obtained from the commutator of their covariant derivatives \\mbox{$F^{(i)}_{\\mu\\nu}\\propto[D^{(i)}_\\mu, D^{(i)}_\\nu]$}:\n\\begin{align}\n  \\lsm&\\supset\\frac1{2g_i^2}\\tr\\left[F^{(i)}_{\\mu\\nu}F^{(i)\\mu\\nu}\\right].\n\\end{align}\nHere, the trace is performed over gauge indices and normalised to $\\sfrac12$ in the $\\un(1)$-case. The gauge sector thus is determined by the gauge couplings $g_i$.\\footnote{Usually, the couplings $g_1$, $g_2$, $g_3$ are called $g'$, $g$, and $g_\\mathrm{s}$.}\n Furthermore, for $\\su(3)$ there exist nontrivial gauge transformations related to the fundamental group structure which can not be removed by suitable redefinitions of the fields. These terms are quantified by a parameter $\\theta_\\mathrm{QCD}$ and contribute a term:\n\\begin{align}\n\\lsm&\\supset\\frac{g_\\mathrm{s}^2\\theta_\\mathrm{QCD}}{16\\pi^2}\\epsilon^{\\mu\\nu\\rho\\sigma}\\tr\\left[F^{(3)}_{\\mu\\nu}F^{(3)}_{\\rho\\sigma}\\right].\n\\end{align}\nGenerally, this term will lead to CP-violation in the strong sector, thus making it favourable to set $\\theta_\\mathrm{QCD}=0$. The effect of a nonzero $\\theta_\\mathrm{QCD}$ could be measured as an electric dipole moment for the neutron which is heavily supressed by observation constituting the \\textit{strong CP-problem}~\\cite{arthur, pdg}. Many solutions to this problem are proposed in the literature, a famous example being the \\textsc{Peccei-Quinn} proposal promoting $\\theta_\\mathrm{QCD}$ to a dynamical field~\\cite{pq, pq-2}.\n\n\\noindent The fermionic fields receive their usual kinetic terms constructed with the covariant derivative in the relevant representation.\n\\begin{align}\n  \\lsm&\\supset\\bar{\\psi}_i\\imag\\slashed{D}\\psi_i\\\\\n  D_\\mu&=\\partial_\\mu-\\imag qA^k_\\mu\\mathcal{R}(T_k).\n\\end{align}\nFor reasons of notational brevity the internal index structure of the fields will be supressed in the following, with exception of the cases where certain caveats must be considered~\\cite{arthur, pdg}.\n\n\\noindent The terms in the Higgs sector are given in the form of a scalar kinetic term, the quartic potential, and the Yukawa couplings to the fermions:\n\\begin{align}\n  \\lsm\\supset-\\left(D^\\mu\\phi\\right)^\\dagger\\left(D_\\mu\\phi\\right)+\\mu\\phi^\\dagger\\phi-\\lambda\\left(\\phi^\\dagger\\phi\\right)^2-\\left(\\lambda^\\psi\\left[\\bar{\\psi}\\phi\\psi\\right]_\\numb{1}+\\hc\\right).\n\\end{align}\nThe square brackets denote that the contractions of the gauge indices are performed in a gauge invariant way. This will imply that the left-handed fermionic weak isospin doublets are contracted with the Higgs doublet while potentially remaining colour indices are contracted with the right-handed fermion field such, that the whole term couples left- and right-handed fields together, leading to the behaviour expected from a mass term.\nFor our three types of massive fermions (up/down-type quarks and charged leptons) the singlets constructible with $\\phi$ look like\n\\begin{align}\n\\lsm&\\supset-\\lambda^u\\left[\\bar{q}_L\\tilde{\\phi}u_R\\right]_\\numb{1}-\\lambda^d\\left[\\bar{q}_L\\phi d_R\\right]_\\numb{1}-\\lambda^e\\left[\\bar{\\ell}_L\\phi e_R\\right]_\\numb{1}+\\hc\n\\end{align}\nHere, the conjugated field $\\tilde{\\phi}^\\alpha=\\epsilon^{\\alpha\\beta}\\phi^*_\\beta$ was used to generate masses for the up-type quarks. This will be one of the reasons why an additional Higgs doublet is needed in the MSSM \\cite{arthur, pdg, peskin, higgs}.\n\n\\noindent In its potential the Higgs field acquires a vacuum ecpectation value (VEV) of\n\\begin{align}\n\\left\\langle\\phi_0\\right\\rangle&=v\\equiv\\sqrt{\\frac\\mu{2\\lambda}}.\n\\end{align}\nPerturbing with a real scalar $h$ around this VEV will lead to the emergence of a mass for the gauge bosons \\mbox{$W^\\pm_\\mu\\propto W^1_\\mu\\mp\\imag W^2_\\mu$} and $Z^0_\\mu$ as well as a massless photon $A_\\mu$ from the mixing of $B_\\mu$ and $W^3_\\mu$ via the process known as \\textit{electroweak symmetry breaking}.\nThe masses generated are directly related to the respective couplings and the VEV:\n\\begin{align}\nm_h&=2\\sqrt{\\lambda}v\\\\\nm_f&=v\\lambda^f\\\\\nm_W&=\\frac{gv}{\\sqrt{2}}\\\\\nm_Z&=\\sqrt{\\frac{g^2+{g'}^2}2}v.\n\\end{align}\nTo make matters more complicated, in the SM three families of fermions are present and the Yukawa couplings $\\lambda^f$ are promoted to general complex \\mbox{$3\\!\\times\\!3$}- matrices $\\lambda^f_{ij}$ which can be diagonalised with bi-unitary flavour transformations\n\\begin{align}\n\\lambda^f\\to V_f^\\dagger\\lambda^fU_f&=v^{-1}\\operatorname{diag}\\left(m^{(1)}_f, m^{(2)}_f, m^{(3)}_f\\right).\n\\end{align}\nTwo of these matrices, $V_u$ and $V_d$, will meet again in the gauge interaction part of the Dirac terms and form the \\textsc{Cabibbo-Kobayashi-Maskawa} (CKM) matrix in the quark sector.\nOn the leptonic side the absence of neutrino masses allows to compensate for these unitary transformations completely~\\cite{arthur, pdg}. If right-handed neutrinos would be included, the \\textsc{Pontecorvo-Maki-Nakagawa-Sakata} (PMNS) matrix would describe similar effects, although it is – as of today – unknown how neutrinos gain their masses and if they are Dirac or Majorana fermions~\\cite{pdg}.\n\n\\noindent Given in the form described above, the Standard Model possesses 60 parameters:\nThree gauge couplings $g'$, $g$, $g_\\mathrm{s}$, and the vacuum angle $\\theta_\\mathrm{QCD}$ in the pure gauge sector. The Higgs potential contributes the two parameters $\\lambda$ and $v$ as well as 54 parameters from the three Yukawa matrices $\\lambda^u$, $\\lambda^d$, and $\\lambda^e$.\\\\\nNot all these parameters are physical and as already emphasised, flavour rotations can be used to remove redundant parameters. This would allow a $\\un(3)$-transformation for each fermion field-type \\mbox{$\\psi\\in\\{q_L, u_R^c, d_R^c, \\ell_L, e_R^c\\}$}, but the accidental symmetries related to conservation of baryon number $B$ and the lepton numbers $L_e$, $L_\\mu$, and $L_\\tau$ can not be used to eliminate parameters.\\footnote{At this point it should be noted, that the SM would possess a $\\un(3)^5$ flavour symmetry in the absence of mass or Yukawa terms, but their existence breaks this symmetry. Because of this, the symmetry-breaking parameters, e.\\ g.\\ the Yukawa matrices, can be reduced by the flavour rotations comprising the now broken symmetry. Therefore, unbroken accidental symmetries, like baryon and lepton number phase rotations, can not be used to change parameters in the model.} Thus, only the symmetry $\\un(3)^5/\\un(1)^4$ remains to remove 41 parameters. Henceforth, the Standard Model without neutrino masses depends on 19 free parameters. Out of these, 14 correspond to real values like couplings and masses, while three describe mixing angles and two give CP-violating phases~\\cite{arthur, pdg}.\nIf neutrino masses were included, together with the PMNS matrix the three neutrino masses would lead to four additional mixing angles and a CP-violating phase. Depending on them being Dirac or Majorana particles, two additional CP-violating phases in the latter case could be present and the SM with massive neutrinos would have 26 or 28 physical parameters~\\cite{pdg}.\n\n\\section{The Minimal Supersymmetric Standard Model}\\label{mssm-basics}\nTo obtain a minimal supersymmetric extension of the SM, all previous fields are embedded in corresponding chiral (real) superfields $\\hat{\\Phi}_i$ ($\\hat{V}_i$).\nFurthermore, it must be taken into account that the Higgsino accompanying the Higgs boson from before – now denoted $H_d$ – introduces a gauge anomaly in the model. To correct for this, a second Higgs doublet, called $H_u$, with opposite charge(s) is needed. In addition, it can be seen that the need for a holomorphic superpotential would forbid the Yukawa term giving masses to the up-type quarks and a new independent field $H_u$ must be included, which takes the position of the previously complex conjugated field $\\tilde{\\phi}$.\nImplementing these considerations leads to the field content of the MSSM depicted in tab.\\,\\ref{mssm-fields}.\n\\begin{table}[H]\\centering\n\\caption{Table of MSSM-superfields and their components, from~\\cite{pdg}.\\label{mssm-fields}}\n\\bgroup\n\\def\\arraystretch{1.4}\n\\begin{tabular}{cccl}\n  super field& bosonic field& fermionic field& representation\\\\\\hline\n  $\\hat{V}_8$& $g$& $\\tilde{g}$& $\\quad\\quad\\rep{8}{1}{0}$\\\\\n  $\\hat{V}$& $W^0$, $W^\\pm$& $\\tilde{W}^0$, $\\tilde{W}^\\pm$& $\\quad\\quad\\rep{1}{3}{0}$\\\\\n  $\\hat{V}'$& $B$& $\\tilde{B}$& $\\quad\\quad\\rep{1}{1}{0}$\\\\\n  $\\hat{L}$& $(\\tilde{\\nu}_L, \\tilde{e}_L)$& $(\\nu_L, e_L)$& $\\quad\\quad\\rep{1}{2}{-\\frac12}$\\\\\n  $\\hat{E}^c$& $\\tilde{e}_R^c$& $e_R^c$& $\\quad\\quad\\rep{1}{1}{1}$\\\\\n  $\\hat{Q}$& $(\\tilde{u}_L, \\tilde{d}_L)$& $(u_L, d_L)$& $\\quad\\quad\\rep{3}{1}{\\frac16}$\\\\\n  $\\hat{U}^c$& $\\tilde{u}_R^c$& $u_R^c$& $\\quad\\quad\\rep{3}{1}{-\\frac23}$\\\\\n  $\\hat{D}^c$& $\\tilde{d}_R^c$& $d_R^c$& $\\quad\\quad\\rep{3}{1}{\\frac13}$\\\\\n  $\\hat{H}_u$& $\\left(H_u^+, H_u^0\\right)$& $\\left(\\tilde{H}_u^+, \\tilde{H}_u^0\\right)$& $\\quad\\quad\\rep{1}{2}{\\frac12}$\\\\\n  $\\hat{H}_d$& $(H_d^0, H_d^-)$& $(\\tilde{H}^0_d, \\tilde{H}_d^-)$& $\\quad\\quad\\rep{1}{2}{-\\frac12}$\n\\end{tabular}\n\\egroup\n\\end{table}\n\\noindent The Lagrangian of the MSSM is constructed out of SUSY conserving terms and SUSY breaking terms where the latter introduce most of the new parameters~\\cite{abc, primer, pdg, arthur, haber}.\n\n\\noindent The gauge terms are built straightforwardly, using the appropriately\\footnote{For the abelian gauge field the definition could be simplified further to \\mbox{$\\mathcal{W}_\\alpha=-\\sfrac14\\bar{D}^2D_\\alpha\\hat{V}$}.} defined field strength super fields\n\\begin{align}\n\\mathcal{W}_{i, \\alpha}&\\equiv-\\frac14\\bar{D}^2e^{-\\hat{V}_i}D_\\alpha e^{\\hat{V}_i},\n\\end{align}\nin an appropriate gauge.\nThe internal gauge dynamics are then given by\n\\begin{align}\n  \\lmssm\\supset&\\frac1{2g_i^2}\\tr\\left[\\int\\dd^2\\theta\\mathcal{W}_i^\\alpha\\mathcal{W}_{i, \\alpha}+\\hc\\right].\n\\end{align}\nThe $\\theta$-parameter can be included by complexifying\\footnote{The key idea would be to go from a real coupling $\\sfrac1{2g_i^2}$ to complex \\mbox{$\\tau\\equiv\\sfrac{1}{2g_\\mathrm{s}^2}-\\sfrac{\\imag g_\\mathrm{s}^2\\theta_\\mathrm{QCD}}{16\\pi^2}$} and respecting $\\tau$ in the hermitian conjugates.} the gauge coupling~\\cite{lykken, primer, abc}.\nThe kinetic Kähler terms just become\n\\begin{align}\n  \\lmssm\\supset&\\int\\dd^2\\theta\\dd^2\\bar{\\theta}\\left[\\hat{\\Phi}^\\dagger_ie^{2\\hat{V}_i}\\hat{\\Phi}_i\\right]_\\numb{1}\\\\\n  \\hat{V}_i\\equiv&\\hat{V}_8^a\\mathcal{R}_i(T_a)+\\hat{V}^k\\mathcal{R}_i(T_k)+Y_i\\hat{V}'.\n\\end{align}\nThe $D$-terms in the Higgs sector of this potential will lead to the emergence of a quartic term in the effective Higgs potential for the two doublets. This has rather suprising consequences – at least at tree level – for the mass of the lightest Higgs field, but more on this in section~\\ref{mssm-details}.\nIn the MSSM, a quartic coupling of Higgs fields can not be included in the superpotential interaction terms since it would be non-renormalisable~\\cite{higgs, haber, pdg}.\n\n\\noindent When considering the contributions\n\\begin{align}\n  \\lmssm\\supset&\\int\\dd^2\\theta W(\\hat{\\Phi}_i)+\\hc\n\\end{align}\nfrom the superpotential $W$, naïvely all quadratic and cubic terms consisting of holomorphic gauge singlets are allowed leading to\n\\begin{align}\\nonumber\n  W=&\\lambda_d\\left[\\hat{H}_d\\hat{Q}\\hat{D}\\right]_\\numb{1}+\\lambda_e\\left[\\hat{H}_d\\hat{L}\\hat{E}\\right]_\\numb{1}-\\lambda_u\\left[\\hat{H}_u\\hat{Q}\\hat{U}\\right]_\\numb{1}+\\mu \\left[\\hat{H}_u\\hat{H}_d\\right]_\\numb{1}\\\\\n  &+a\\left[\\hat{L}\\hat{H}_u\\right]_\\numb{1}+b\\left[\\hat{Q}\\hat{L}\\hat{D}\\right]_\\numb{1}+c\\left[\\hat{U}\\hat{U}\\hat{D}\\right]_\\numb{1}+d\\left[\\hat{L}\\hat{L}\\hat{E}\\right]_\\numb{1}.\n\\end{align}\nThe upper line contains the Yukawa couplings as well as the $\\mu$-parameter, which will be the only parameter leading to masses for the Higgsinos.\nUnfortunately the terms in the lower line introduce processes, violating baryon and lepton number conservation, and can not be excluded by renormalisability arguments as in the SM. As often, it would be attractive to rely on a suitable symmetry not obeyed by the unwanted terms. A promising candidate for such a symmetry would be the $\\un(1)_R$ R-symmetry, transforming component fields differently, but using it continuously would also forbid the $\\mu$-term and lead to massless Higgsinos and therefore striking contradiction with experiment. Breaking $\\un(1)_R$ down to R-parity $\\mathcal{Z}_2$ circumvents this problem and implies the assignment\n\\begin{align}\nR=(-1)^{3(B-L)+2s},\n\\end{align}\nfor each component field.\\footnote{An equivalent assignment makes use of matter parity \\mbox{$P_m=(-1)^{3(B-L)}$}, defined on superfields, which can be seen more easily.}\nRestricting to R-parity conservation has the importand consequence that superpartners of the ordinary SM particles can only be produced and annihilated in pairs, implying the existance of a lightest supersymmetric particle (LSP). Being weakly interacting (most probably) massive particles (`WIMPs'), such LSPs are rather attractive aspirants for dark matter particles~\\cite{pdg, arthur, primer, abc}.\n\n\\noindent In the MSSM, SUSY is broken explicitly and the origin of the breaking terms is not considered. They could originate in a hidden sector, e.\\ g.\\ via gauge- or gravity-mediation, but in the end both will lead to the inclusion of \\textit{soft}\\footnote{Soft in this context meaning that the corresponding operators are relevant and therefore have mass dimension strictly below four.} SUSY breaking terms of the form:\n\\begin{align}\\nonumber\n  -\\mathcal{L}^\\mathrm{MSSM}_\\mathrm{soft}\\supset&\\frac12M_i\\tilde{\\bar{\\lambda}}_i\\tilde{\\lambda}_i+M^2_{\\tilde{F}}\\tilde{f}^\\dagger\\tilde{f}\\\\\n  &+m_1^2H_d^\\dagger H_d+m_2^2H_u^\\dagger H_u+m_{12}^2\\left(H_u\\cdot H_d+\\hc\\right)\\\\\\nonumber\n  &+T_UH_u\\tilde{Q}\\tilde{U}+T_DH_d\\tilde{Q}\\tilde{D}+T_EH_d\\tilde{L}\\tilde{E}+\\hc\n\\end{align}\nThe terms in the first line lead to masses and mass differences for the gauginos and sfermions, while the second line contributes to the Higgs potential. Lastly, the third line introduces additional trilinear couplings between the sfermion scalars and the Higgs fields.\nOften a parametrisation\\footnote{Here, it should be noted that one has to be careful regarding matrix indices, since it is not clear – at least ad hoc – , how the indices of $A_F$, $\\lambda_f$, and $T_F$ are related to each other and there are different conventions. Nevertheless, many models simplify the trilinear couplings to be diagonal in the flavour eigenbasis with only scalar $A$-parameters remaining.} $m_{12}^2=\\mu B$ (and $T_F=\\lambda_f A_F$) is chosen. Therefore, the corresponding terms are called $A$ and $B$-terms~\\cite{pdg, arthur, chung, peskin}.\n\n\\noindent Having introduced all parameters, the same counting procedure as in the SM can be repeated for the MSSM. The gauge sector contributes four real parameters with $g$, $g'$, $g_\\mathrm{s}$, and $\\theta_\\mathrm{QCD}$, while the superpotential contains the three Yukawa matrices $\\lambda_u$, $\\lambda_d$, and $\\lambda_e$ (each contributing 18 parameters). Two parameters come from the modulus and phase of $\\mu$.\nMost of the parameters are introduced by the SUSY breaking terms: Three generally complex gaugino masses give rise to six parameters, while the five different hermitian scalar mass matrices introduce nine parameters per matrix, and the Higgs-sector adds $v$, $\\beta$, and three trilinear scalar coupling matrices $T_F$ with 18 parameters each.\nUsing the flavour transformations $\\un(3)^5/\\un(1)^2$, 43 parameters can be removed. Here, the fixation on lepton number conservation per generation can not be sustained anymore, since many of the additional terms in the MSSM can and will lead to flavour changing processes that were previously supressed strongly in the SM.\nActually, this is not all, since there exist two additional $\\un(1)$ transformations that can be exploited to further remove phases from the MSSM: The before-mentioned R-transformations as well as a so called Peccei-Quinn symmetry $\\un(1)_\\mathrm{PQ}$, which can be used to make the gaugino mass $M_3$ and $\\mu$ real~\\cite{haber}.\nIn the end, 45 parameters can be removed from the 169 parameters introduced in the Lagrangian.\nFinally, the full MSSM is given by 124 parameters and this full description is called the MSSM-124. Of these 124 parameters, of which 105 originate in the SUSY breaking terms, 39 will be real values like masses and couplings, 39 will be mixing angles, and 45 will correspond to CP-violating phases~\\cite{haber, pdg}.\n\n\\section{Phenomenological implications of the MSSM}\\label{mssm-details}\nOne striking implication of the MSSM is the structure of the Higgs sector:\nThe contributions to $V_\\mathrm{Higgs}$ come from the $D$-terms in the Kähler potential as well as the soft SUSY breaking terms and lead to a full potential\n\\begin{align}\\nonumber\n  V_\\mathrm{Higgs}=&\\left(m_1^2+|\\mu|^2\\right)H_d^\\dagger H_d+\\left(m_2^2+|\\mu|^2\\right)H_u^\\dagger H_u+m_{12}^2\\left(H_u\\cdot H_d+\\hc\\right)\\\\\n  &+\\frac{g^2+{g'}^2}8\\left(H_d^\\dagger H_d-H_u^\\dagger H_u\\right)+\\frac12g^2\\left|H_d^\\dagger H_u\\right|^2.\n\\end{align}\nAfter minimising $V_\\mathrm{Higgs}$, both doublets acquire VEVs\n\\begin{align}\n\\left\\langle H_f^0\\right\\rangle&=v_f,\n\\end{align}\nwhich can be related to the previous $v$ via\n\\begin{align}\nv^2=v_u^2+v_d^2.\n\\end{align}\nBy convention, an angle $\\beta$ is defined between the $v_f$ as\n\\begin{align}\n  \\tan\\beta&=\\frac{v_u}{v_d}.\n\\end{align}\nSince the quartic coupling is given as function of the weak coupling constant, this implies an \\textit{upper bound} on the mass of the lightest Higgs boson – at least on tree level – of\n\\begin{align}\n  m^2_h&\\le m^2_Z\\cos^22\\beta.\n\\end{align}\nThis bound relaxes at higher loop order where suitable corrections lift this bound as high as $\\SI{135}{\\GeV}$, removing the contradiction present before~\\cite{pdg, higgs, peskin, primer, haber}.\n\n\\noindent The most interesting aspects can be found in the particle spectrum:\nWith its superfields the MSSM gives rise to a luscious landscape of new particles to observe, but the additional fields include many new possibilities for mixing, modifying the expectable spectrum of new particles.\nOn the SM side of the MSSM, the particle content remains relatively unchanged with exception of the Higgs boson, which is now replaced by additional Higgs bosons coming from the second doublet. The real perturbations of the $H^0_f$ around $v_f$ will mix to form two CP-even scalars denoted by $h^0$ and $H^0$ (capital letter corresponding to larger mass), while their imaginary counterparts form a CP-odd scalar $A^0$ and a neutral Goldstone boson $G^0$, which is later eaten as part of the Higgs mechanism's inner mechanics, giving rise to longitudinal modes and therefore masses for the $W$ and $Z$ bosons. Similarly, the charged components, $H^+_u$ and $H^-_d$, will mix forming two charged Higgs bosons $H^\\pm$ and two Goldstone bosons $G^\\pm$. In total, the contribution from the additional doublet leads to four new Higgs bosons $H^0$, $H^\\pm$, and $A^0$~\\cite{higgs, peskin, primer}.\nThe Higgsinos will mix with the other weakly charged gauginos present.\nThe neutral Higgsinos $\\tilde{H}^0_u$ and $\\tilde{H}^0_d$ are now accompanied by the bino $\\tilde{B}^0$ and the neutral wino $\\tilde{W}^0_3$ so that mixing will be described by a complex \\mbox{$4\\!\\times\\!4$}-matrix and result in four neutral physical mass eigenstates, called \\textit{neutralinos} and denoted $\\tilde{\\chi}^0_i$, their index incrementing with increasing mass. Accordingly, the charged winos $\\tilde{W}^\\pm$ will mix with the charged Higgsinos $\\tilde{H}^\\pm$ and form two (actually four) chargino states, denoted $\\tilde{\\chi}^\\pm_i$.\nConsidering the sfermions, the scalar superpartners of the SM-fermions, it must be noted that there are two superpartners per (charged) fermion $f$ (with exception of the neutrinos): One scalar partner for the left-handed component $\\tilde{f}_L$, one for the right-handed component $\\tilde{f}_R$. Generally, mixing can and will occur between these different fields if they carry the same charges, thus leading to \\mbox{$6\\!\\times\\!6$}-mixing for the up/down-type squarks ($\\tilde{q}_L$, $\\tilde{q}_R$) and the charged sleptons ($\\tilde{\\ell}_L$, $\\tilde{\\ell}_R$). For the sneutrinos only \\mbox{$3\\!\\times\\!3$}-mixing is present. In the end, only mass eigenstates $\\tilde{u}_i$, $\\tilde{d}_i$, $\\tilde{\\ell}_i$, and $\\tilde{\\nu}_i$ will remain, whose identification with flavour eigenstates will be highly dependent on the parameters at play.\n\\begin{table}[H]\\centering\n\\caption{Examples for parameter configurations leading to nearly pure gaugino states. Adapted from~\\cite{pdg}.\\label{gaugino}}\n\\begin{tabular}{cc}\nparameter conditions&$\\tilde{\\chi}^{0, \\pm}_1$\\\\\\hline\n$\\left|M_1\\right|, \\left|M_2\\right|\\lesssim\\left|\\mu\\right|, m_Z$&$\\tilde{\\gamma}$\\\\\n$\\left|M_1\\right|, m_Z\\lesssim\\left|M_2\\right|, \\left|\\mu\\right|$&$\\tilde{B}$\\\\\n$\\left|M_2\\right|, m_Z\\lesssim\\left|M_1\\right|, \\left|\\mu\\right|$&$\\tilde{W}^{0, \\pm}$\\\\\n$\\left|\\mu\\right|, m_Z\\lesssim\\left|M_1\\right|, \\left|M_2\\right|$&$\\tilde{H}^{0, \\pm}$\n\\end{tabular}\n\\end{table}\n\\noindent By this it becomes apparent that only very specific configurations in parameter space will lead to a `double-SM'-structure of the MSSM, and the phenomenology depends delicatly on the parameters~\\cite{pdg, peskin}. Some examples for such configurations can be found in tab.\\,\\ref{gaugino}.", "meta": {"hexsha": "14bbf30d1e48e8352c42edd677a558556c89797d", "size": 25065, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "summary_jonah/content/01_content.tex", "max_stars_repo_name": "mathieukaltschmidt/SUSY", "max_stars_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "summary_jonah/content/01_content.tex", "max_issues_repo_name": "mathieukaltschmidt/SUSY", "max_issues_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "summary_jonah/content/01_content.tex", "max_forks_repo_name": "mathieukaltschmidt/SUSY", "max_forks_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 113.4162895928, "max_line_length": 1219, "alphanum_fraction": 0.74673848, "num_tokens": 7702, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.44300146415110586}}
{"text": "%\n% @author   Shmish  \"shmish90@gmail.com\"\n% @legal    MIT     \"(c) Christopher Schmitt\"\n%\n\n\n\\documentclass{article}\n\n\n%\n% Document Imports\n%\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{color}\n\\usepackage{tikz}\n\n\n\n%\n% Document Configuation\n%\n\n\\newcommand{\\hwAuthor}{Christopher Schmitt}\n\\newcommand{\\hwSubject}{Math 218}\n\\newcommand{\\hwSection}{Section 81}\n\\newcommand{\\hwSemester}{Summer 2019}\n\\newcommand{\\hwAssignment}{Assignment 8}\n\n\n%\n% Document Enviornments\n%\n\n\\setlength{\\headheight}{65pt}\n\\pagestyle{fancy}\n\\lhead{\\hwAuthor}\n\\rhead{\n  \\hwSubject \\\\\n  \\hwSection \\\\\n  \\hwSemester \\\\\n  \\hwAssignment\n}\n\n\\newenvironment{problem}[1]{\n  \\nobreak\\section*{Problem #1}\n}{}\n\n\n%\n% Document Start\n%\n\n\\begin{document}\n  \\begin{problem}{1}\n    Solve each of the following counting problems, writing your answer as an integer in the standard decimal notation.\\par\n    In how many ways can a student club that consists of 20 students select 3 students to attend a conference?\n    $$\\binom{20}{3} = 1140$$\n\n    How many strings of 0s and 1s have length 11 and have exactly eight ones?\n    $$\\binom{11}{8} = 165$$\n\n    How many strings of 0s and 1s have length 11 and have at most three ones?\n    $$2^{11} - 2^{7} = 1920$$\n\n    A donut shop has donuts in six different flavors: chocolate frosted, chocolate creme, glazed, jelly, plain, and Boston creme. The donut shop has an unlimited supply of each flavor. In how many different ways can the donut shop create a box of 18 donuts? Note that the box can include multiple donuts of the same flavor, and that donuts of the same flavor are considered indistinguishable.\n    $$\\binom{n + r - 1}{r} = \\binom{6 + 18 - 1}{18} = \\binom{23}{18} = 33649$$\n\n    The donut shop now wants to create a box of 18 donuts, including at least four glazed ones. In how many ways can this be done?\n    $$\\binom{n + r - 1}{r} = \\binom{6 + 14 - 1}{14} = \\binom{19}{14} = 11628$$\n\n    The donut shop now wants to create a box of 18 donuts, including at most four glazed ones. In how many ways can this be done?\n    $$\\binom{6 + 18 - 1}{18} - \\binom{6 + 13 - 1}{13}= \\binom{23}{18} - \\binom{18}{13} = 33649 - 8568 = 25018$$\n\n    The donut shop now wants to create a box of 18 donuts, including exactly four glazed ones. In how many ways can this be done?\n    $$1 * \\binom{5 + 14 - 1}{14} = \\binom{18}{14} = 3060$$\n\n    I want to buy one donut every day from Monday through Friday at the donut shop. In how many ways can this be done?\n    $$\\binom{n + r - 1}{r} = \\binom{6 + 5 - 1}{5} = 252$$\n\n    How many “words” can be formed by rearranging the letters of the word MATHEMATICALLY? The “words” do not have to be actual English words.\n    $$\\frac{14!}{2! * 3! * 2! * 2!} = 1816214400$$\n\n    Find the coefficient of $x^8y^4$ in the expansion of the binomial $(x + 2y)^{12}$\n    $$\\binom{12}{4} = 495$$\n    $$495(x^8)(2y^4) = 990x^8y^4$$\n  \\end{problem}\n\n  \\begin{problem}{2}\n    $$(x + y)^{2k} = \\sum_{i=0}^{2k} x^i y^{2k - 1} \\binom{2k}{i}$$\n    $$(x + y)^{2J + 1} = \\sum_{i=0}^{2J + 1} x^i y^{2J} \\binom{2J + 1}{i}$$\n    Theorem: $$\\sum_{0 \\le i \\le n, n\\ odd} \\binom{n}{i} = \\sum_{0 \\le i \\le n, n\\ even} \\binom{n}{i}$$\n    $$\\sum \\binom{2k+1}{i} = \\sum \\binom{2j}{i}$$\n    $$?$$\n  \\end{problem}\n\\end{document}", "meta": {"hexsha": "a6f9023be45d7ab8c79546ca84a04aa601a92248", "size": 3329, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Assignment_008.tex", "max_stars_repo_name": "shmishtopher/MATH-218", "max_stars_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Assignment_008.tex", "max_issues_repo_name": "shmishtopher/MATH-218", "max_issues_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Assignment_008.tex", "max_forks_repo_name": "shmishtopher/MATH-218", "max_forks_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9603960396, "max_line_length": 392, "alphanum_fraction": 0.6524481826, "num_tokens": 1187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7879311956428947, "lm_q1q2_score": 0.44295640250528584}}
{"text": "\\documentclass[]{article}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\graphicspath{ {./figures/} }\n\n%opening\n\\title{Magical ecologies: a model of predator-prey equilibria for closed systems of magical girls and witches}\n\\author{Kyubey \\#65471}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\tWe present a simple mathematical model of interactions between magical girl (\\textit{Puella Magica}) and witch (\\textit{Maga Malefica}) populations in a closed regulated system. The model makes use of a few descriptive parameters to characterise the environment and predicts dynamical population behaviour. We show how some very general conclusions can be deduced about the equilibrium populations of magical girls and witches and their stability. This study will provide operators in the field with more tools to better manage the ecology of these species, which are vital for our universe's thermodynamic preservation. \n\\end{abstract}\n\n\\section{Introduction}\n\nSince the first documented discovery of the exothermic, anentropic decay process from magical girl (\\textit{Puella Magica}) to witch (\\textit{Maga Malefica}) \\cite{kyubey1}, this fundamental phenomenon has become a key element of our species' activities in the field of cosmic scale thermodynamic preservation. The management of magical girl-witch ecologies has today a disproportionate impact on our economy, employing effectively 99.93\\% of our active population, and providing a free energy flux of more than $10^{40} W$ across all the galaxies over which we've currently spread. While this is still far below the amount necessary to definitely stave off heat death, the impressive scale and efficiency of this operation can not be overstated. It is thus somewhat surprising that until now the management of local ecologies has often been left to individual operators, almost as an art more than a science. While this has often been successful, occasional examples of ecological collapses on a catastrophic scale have been recorded \\cite{kyubey2}. Therefore, we endeavour here to begin an attempt at a systematic description of magical girl-witch ecological equilibria, as a tool for future control and regulation of such system.\n\n\\section{The model}\n\nLet us consider a closed system containing two populations of magical girls and witches, labelled respectively as $M$ and $W$. The indigenous species is here considered as a virtually infinite reserve; this is in general a good approximation, and we will see later that it is not a problem for the results of the model. We then consider the dynamics affecting these populations. For magical girls, three phenomena are at play:\n\n\\begin{enumerate}\n\t\\item a recruitment process by the local Kyubey agent;\n\t\\item a loss to witches in battle;\n\t\\item a loss to decay processes and transformation into witches.\n\\end{enumerate}\n\nConversely, for witches, there are only two relevant phenomena:\n\n\\begin{enumerate}\n\t\\item an increase in numbers thanks to decay processes of magical girls;\n\t\\item a loss to magical girls in battle.\n\\end{enumerate}\n\nIn order to fully characterise this system we introduce five parameters. The first is the recruitment rate, $r$. The second is the probability of battle $b$; this is chosen so that the total number of battles per unit time can be found as $N_B = bMW$. Since $MW$ is proportional to the likelihood of a clash between magical girls and witches, which increases with both their population, $b$ depends in general by the area over which these population are spread. For a large city, for example, $b$ will be small, as encounters are less likely unless the populations are large enough to compensate. Other local factors however can affect $b$, such as the attitudes and motivation level of the local population of magical girls and the general psychological state of the indigenous community, which has an effect on witch activity.\\newline\nThe third parameter is the win rate, $w$ (not to be confused with the witch population, $W$). This expresses simply the likelihood of the average magical girl defeating the average witch in battle, so it has to be $0 \\leq w \\leq 1$. The last two parameters are inherent to the qualities of the soul gems of the local magical girls. These are the average decay time, $\\tau_0$, which represents the average time a magical girl would decay into a witch if deprived of any means to recharge her soul gem, and the efficiency of recharge, $\\eta$, which represents the average fraction of a soul gem's total energy that can be recovered with a grief seed. While it has to be $\\eta \\geq 0$, there is no upper limit; soul gems can not be overcharged, but nothing forbids magical girls from saving partially used-up grief seeds to use for future recharges if they manage to do so. However, in practice, it tends to be that $\\eta \\sim 0.25$.\\newline\n\nWe can now outline the dynamical equations of the model. These are a pair of first order differential equations:\n\n\\begin{equation}\\label{eq_mg}\n\\frac{dM}{dt} = r-\\frac{1}{\\tau_0+\\eta b w W}M-b (1-w)MW \n\\end{equation}\n\n\\begin{equation}\\label{eq_w}\n\\frac{dW}{dt} = \\frac{1}{\\tau_0+\\eta b w W}M-bwMW \n\\end{equation}\n\nMost of these terms are self-explanatory. The magical girls creation rate $r$ is the only positive contribution to $dM/dt$, and losses to battles are represented as $N_B$ multiplied by the likelihood of unfavourable outcome for each party, respectively, $1-w$ and $w$ for magical girls and witches. However, the decay process deserves a bit more of attention. We have here made use of an effective decay rate,\n\n\\begin{equation}\\label{tau}\n\\tau = \\tau_0+\\frac{\\eta w N_B}{M} = \\tau_0+\\eta b w W\n\\end{equation}\n\n. In other words, we consider an extension to the regular decay time that is proportional to how many witches each magical girls gets to defeat, on average, times the efficiency $\\eta$.\\newline\nWe now move on to study this model in some detail. As we will see, it leads to surprising and useful insights about the equilibria of magical girls and witches, and the resulting energy production.\n\n\\section{Results}\n\\subsection{Equilibrium}\n\nTo search for the equilibrium conditions of this model we look for values of $M$ and $W$ which cause Eq. \\ref{eq_mg} and \\ref{eq_w} to be zero. This turns out to be actually quite simple. If we focus on \\ref{eq_w}, we see that since $M$ appears in both terms, it can be simplified. This leads us to the first important finding of this work: \\textit{the equilibrium population of witches is independent from the amount of magical girls present}. In particular, by solving a second degree equation and discarding the unphysical negative solution, we find\n\n\\begin{equation}\\label{eq_pop_w}\nW_{eq} = \\frac{\\sqrt{\\tau_0^2+4\\eta}-\\tau_0}{2\\eta bw}\n\\end{equation}\n\n. In other words, the equilibrium population for witches only depends on the average properties of soul gems and on other local factors such as the area of the habitat in which they're living and the combat skill of the magical girls. In particulars, since it's reasonable to assume that $b \\sim 1/A$, where $A$ is the area of the habitat, this leads to a constant sustainable density of witches that only depends on the properties of the local population of magical girls and indigenous species.\\newline\nHaving found this equilibrium, we then have for Eq. \\ref{eq_mg} that\n\n\\begin{equation}\\label{eq_pop_m}\nM_{eq} =   \\frac{r}{\\frac{1}{\\tau_0+\\eta b w W_{eq}}+b (1-w)W_{eq}}\n\\end{equation}\n\n. This is a very interesting result, because it can be interpreted as a prescription: the rate of recruitment can be used to set the desired magical girl population at one's will. In other words, if $W_{eq}$ is simply a function of environmental factors, which can only be controlled very indirectly, $M_{eq}$ is a quantity entirely in the hands of the local Kyubey agent. This is especially important with regards to energy production. If the average energy produced per decay is $E_{decay}$ and the average energy consumed per wish granted as a part of the recruiting process is $E_{wish}$, then the net energy production will be\n\n\\begin{align}\\label{net_power}\nP_{eq} &=   E_{decay}\\frac{M_{eq}}{\\tau_0+\\eta b w W_{eq}}-E_{wish}r \\\\\n&= r\\left[E_{decay}\\frac{1}{1+b(1-w)(\\tau_0+\\eta b w W_{eq})W_{eq}}-E_{wish}\\right] \\nonumber \\\\\n& = r\\left[wE_{decay}-E_{wish}\\right] \\nonumber\n\\end{align}\n\n. This is the second, surprising key result of this work: \\textit{at equilibrium, the energy production depends only on the recruiting rate and the win rate of magical girls}. Maximum efficiency is reached in a condition in which the magical girls win every time against the witches. While this may sound counterintuitive, as winning leads magical girls to gather grief seeds and thus slow down decay, it makes sense if we consider that each loss of a magical girl to a witch is an inefficiency, as it wastes their wish energy without delivering any decay payoff. Conversely, a highly successful population of magical girls will succumb only to decay, however long that might take. In an equilibrium condition the effective rate is then controlled by recruitment. For low $r$, there will be a small amount of long lived veterans. For high $r$, the turnover will be much faster, due to having the same population of witches, but a much higher population of magical girls to split the grief seeds between. Nevertheless, it is in the best interest of the local Kyubey agents to guarantee that their magical girls are as close to 100\\% successful in battle as possible, as that results in maximum conversion efficiency.\n\n\\subsection{Dynamics}\n\nHaving verified that an equilibrium exists, however, it remains to be seen under which conditions it is stable, which is the major concern for operators on the field. Luckily, intuition already tells us that this is likely to be the case. The decay term in Eq. \\ref{eq_mg} and \\ref{eq_w} has clearly a stabilising effect. In presence of an excess of witches, it will cause the life of magical girls to get longer, thanks to a greater availability of grief seeds; while if there were too few, the decay process would speed up and compensate. This can also be seen by analysing Eq. \\ref{eq_w} around its equilibrium point, as the sign of the derivative is opposite to that of the error, $W-W_{eq}$. However, in order to gain a more detailed understanding of these dynamical processes, we carry out numerical integration of the equations for a number of different scenarios.\\newline\n\n\\begin{figure}\n\t\\includegraphics[width=0.7\\textwidth]{fig1}\n\t\\centering\n\t\\caption{Model 1. Initial conditions: $M > M_{eq}$, $W < W_{eq}$.}\t\n\t\\label{fig1}\n\\end{figure}\n\n\\begin{figure}\n\t\\includegraphics[width=0.7\\textwidth]{fig2}\n\t\\centering\n\t\\caption{Model 2. Initial conditions: $M < M_{eq}$, $W > W_{eq}$.}\t\n\t\\label{fig2}\n\\end{figure}\n\n\\begin{figure}\n\t\\includegraphics[width=0.7\\textwidth]{fig3}\n\t\\centering\n\t\\caption{Model 3. Initial conditions: $M > M_{eq}$, $W > W_{eq}$. The low win rate ($w = 0.1)$ causes an oscillation in the magical girl population before equilibrium is reached.}\t\n\t\\label{fig3}\n\\end{figure}\n\nFigures \\ref{fig1}-\\ref{fig3} show some possible scenarios. These start with off-equilibrium values of $M$ and $W$ and converge over time. The time scale is determined by setting $\\tau_0=1$. As one can see, all the convergence is quick and without incident, regardless of starting conditions. Figure \\ref{fig3} shows an example in which an oscillation of the magical girl population can be observed. This is the consequence of a specifically `soft' model, with a low win rate ($w=0.1$). While convergence eventually still occurs, this is another reason for why a high win rate for magical girls is generally desirable - as it tends to result in a faster and surer convergence of populations to their equilibrium values.\n\n\\section{Conclusions}\nAn idealised model describing the population dynamics of magical girls and witches in a closed environment has been developed and characterised. The model allows us some important and non trivial insights in the ecological balance of such populations, in particular:\n\n\\begin{itemize}\n\t\\item that the density of witch population sustainable by a territory is independent of the population of magical girls, and only depends on the properties of the territory itself,\n\t\\item that the population of magical girls is directly proportional to the recruitment rate, and\n\t\\item that the energy production rate due to the decay of magical girls into witches is maximally efficient when the former have high rates of success in battle against the latter.\n\\end{itemize}\n\nIn practical field applications, of course, these considerations will need to be balanced with other requirements. For example, while a high recruitment rate and a perfect win rate would maximise energy production as per Eq. \\ref{net_power}, they would actively work against the psychological needs of recruitment itself, which often relies on the threat posed by witches as a motivational factor. If witches are vastly outnumbered by magical girls and are dispatched quickly and reliably, the appeal of such arguments would be significantly weakened. Regardless, these results provide useful guidelines that need then to be integrated within the larger needs of ecological management.\\newline\nThere are also potentially significant effects that have been ignored in this first model. Among them are any finite-size effects that could manifest in the situation in which an area was significantly overcrowded with witches or magical girls; the possibility, documented albeit of relatively small incidence, of internal combat and even murder within magical girls \\cite{kyubey3}; and any effects due to the finiteness of the indigenous population if put under extreme stress due to either the drain of recruitment or the damage caused by witches. While some or all of these effects can matter in extreme circumstances, we believe that in the case of well-managed systems, the conditions for them to be important should never verify, and the results of this paper should hold. Nevertheless, the inclusion of such effects will be the object of study of future work.\n\n\n\\bibliographystyle{unsrt}\n\\bibliography{mweco}\n\n\n\\end{document}\n", "meta": {"hexsha": "565598a4850a60ea60e2bf75481893b3b2961431", "size": 14202, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/mweco.tex", "max_stars_repo_name": "higgs-bosoff/pmmm-ecology", "max_stars_repo_head_hexsha": "30889dd62bf961c787ab5356d44644decaae019e", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/mweco.tex", "max_issues_repo_name": "higgs-bosoff/pmmm-ecology", "max_issues_repo_head_hexsha": "30889dd62bf961c787ab5356d44644decaae019e", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/mweco.tex", "max_forks_repo_name": "higgs-bosoff/pmmm-ecology", "max_forks_repo_head_hexsha": "30889dd62bf961c787ab5356d44644decaae019e", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.7819548872, "max_line_length": 1232, "alphanum_fraction": 0.7850302774, "num_tokens": 3288, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.5621765008857982, "lm_q1q2_score": 0.44295640250528573}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\n\\usepackage{amsmath,amssymb,amsthm,tikz}\n\\usetikzlibrary{calc,arrows.meta}\n\\usepackage[margin=20mm]{geometry}\n\\usepackage{hyperref}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\columnsep}{1cm}\n\n\\begin{document}\n\n\\twocolumn\n\n\\thispagestyle{empty}\n\n\\begin{center}\n{\\Large Assignment 13}\\\\\n{\\Large Published on 2020-12-06,}\\\\\n{\\em Estimated Time: 30 minutes,}\\\\\n{\\em Max.grade 10\\textperthousand} \n\\end{center}\n\n\n\\section{Dijkstra's Algorithm}\n\n(Goodrich2011, p.640) defines Dijkstra's algorithm. \nSee also \\url{https://bit.ly/2JSXqMU}. \nIt is an efficient algorithm; it requires $O((m+n)\\log_2 n)$ time, if \nwe use priority queues; here $m$ is the number of edges and $n$ is the number \nof vertices in a graph.\n \nIn this exercise you do not need to implement a priority queue; \nassume that you can always pick the vertex with the smallest distance and \nadd it to the set $S$ of visited vertexes (those having distances already computed). \n\n\n\n\\section{Problem}\n\nWe start with the graph shown in Figure~\\ref{fig:problem-graph}.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{assignment13-dijkstra/problem-graph.png}}\n\\caption{\\label{fig:problem-graph} Graph diagram}\n\\end{figure}\n\nThe following edges $(A,B)$, $(E,C)$, $(D,C)$ have weights \n$a+1$, $b+1$, and $c+1$ respectively \n(here $a,b,c$ should be replaced by the digits from your Student ID). \nVertex $A$ will be your source vertex. (You can assume that the distance \nfrom $A$ to itself is $0$; initially all the other distances are infinite, but \nthen Dijkstra's algorithm relaxes them). \n\n\n\\vspace{10pt}\n{\\bf (A)} Redraw the graph Figure~\\ref{fig:problem-graph}, \nreplace the edge weights $a+1$, $b+1$, and $c+1$ by your values of $a,b,c$. \n\n\n\\vspace{10pt}\n{\\bf (B)} Run the Dijkstra's algorithm; \ncreate a table showing how distances to $A,B,C,D,E$ \nchange as the relaxations are performed.\nAt every iteration highlight which vertex (among those not yet finished) \nhas the minimum distance. Add it to the set $S$ of finished vertices \n(the set $S$ will have $0$ in the very first iteration; after that it will grow by \none vertex at a time). \n\n\\vspace{10pt}\n{\\bf (C)} Summarize the result: For each of the $5$ vertices \ntell what is its minimum distance from the source. \nAlso tell what is the shortest path how to get there. \n\n\\end{document}\n\n", "meta": {"hexsha": "53bbfff47f3001d7abc8724204d4eb5e261eae50", "size": 2345, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "data-structures-fall2020/assignments/assignment13-dijkstra.tex", "max_stars_repo_name": "kapsitis/linen-tracer-682", "max_stars_repo_head_hexsha": "b17f5c8b16e1d83032e0d9679a7219c0cbdba0dc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "data-structures-fall2020/assignments/assignment13-dijkstra.tex", "max_issues_repo_name": "kapsitis/linen-tracer-682", "max_issues_repo_head_hexsha": "b17f5c8b16e1d83032e0d9679a7219c0cbdba0dc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-07-17T17:42:53.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-13T23:55:14.000Z", "max_forks_repo_path": "src/site/data-structures-fall2020/assignments/assignment13-dijkstra.tex", "max_forks_repo_name": "kapsitis/math", "max_forks_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4545454545, "max_line_length": 85, "alphanum_fraction": 0.7309168443, "num_tokens": 683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.7772998560157663, "lm_q1q2_score": 0.44294637253782215}}
{"text": "\\section{Algorithm}\n\\label{sec:algorithm}\n\nIn this section we describe our ROSC algorithm. Figure~\\ref{figure:flow_graph}(c) shows a \nflow diagram of ROSC. ROSC follows the basic pipeline of spectral clustering except that\nit generates a coefficient matrix $Z$ \n%(shown in the red box of the diagram) \nand feeds it\n into the clustering pipeline in place of\nthe similarity matrix $S$. \nThe objective is to find a  $Z$ that possesses  grouping effect. \nTo achieve that, ROSC uses PI to obtain {\\pev}s from which a basic $Z$ is derived.\nNext, it generates the TKNN graph with which $Z$ is rectified. \nIn the following, we discuss how $Z$ is derived from the {\\pev}s, define the TKNN graph,\ndescribe the rectification process, \nand prove that the resulting $Z$ has the desired grouping effect. \n\n%\n%In this section, we propose a \\textbf{RO}bust \\textbf{S}pectral \\textbf{C}lustering method ROSC. \n%Instead of directly performing spectral clustering on the given similarity matrix, \n%it constructs a new matrix that reserves the efficacy of effective similarities \n%and rectifies ineffective ones in the raw similarity matrix.\n%The new matrix will lead to a more robust spectral clustering.\n\n\\comment{\n\\subsection{Model overview}\nThe overall framework of ROSC is summarized as follows.\n\nFirst, generate a set of pseudo-eigenvectors.\nSince the standard spectral clustering methods using only the dominant eigenvectors may fail \nin the data containing multi-scale clusters,\nwe generate a set of pseudo-eigenvectors to fuse more useful cluster-separation information.\n\nSecond, rectify the given similarity matrix.\nThe failure of spectral clustering on multi-scale data originates from the inaccurate similarity matrix.\nTherefore, we rectify the matrix and aim to achieve a new one\nthat can more accurately reflect the true similarities between objects.\n%This is a major problem to be addressed.\n\nThird, perform spectral clustering.\nAfter rectification, the new similarity matrix will be more accurate and it will be safer to perform spectral clustering. \n\nThese three steps will lead to robust clustering results and next we introduce each step in detail.\n}\n\n\\subsection*{Pseudo-Eigenvectors}\n\\label{sec:sec:pseudo}\nGiven a similarity matrix $S$, we normalize it by $D^{-1}S$ and apply PI to obtain {\\pev}s.\n%When dealing with multi-scale data,\n%spectral clustering\n%using only the top-$k$ eigenvectors may fail while some other eigenvectors may be useful~\\cite{lin2010power}.\n%Therefore, it is necessary to fuse the discriminative cluster-separation information in all eigenvectors\n%and PI provides such fusion by returning a pseudo-eigenvector.\n%However, when the number of clusters is large,\n%a single pseudo-eigenvector is insufficient due to the cluster-collision problem. \n%%Since PI returns a pseudo-eigenvector that is a combination of all the eigenvectors,\nSimilar to~\\cite{ye2016fuse},\nwe run PI multiple times with different random initial vectors to generate a set of {\\pev}s, \nwhich maps each object into a low dimensional embedding.\nNote that small {\\ev}s are {\\it shrunk} by PI~\\cite{lin2010power}.\n%\\footnote{From Equation~\\ref{eq:pi}, we see that the $i$-th \n%largest \\ev\\ is \n%shrunk at a rate of $\\lambda_i/\\lambda_1$ per iteration.}.\nTo alleviate the shrinkage of small {\\ev}s,\nwe follow the approach of~\\cite{huang2014diverse}\nand gradually decrease the number of iterations executed in PI as more {\\pev}s are obtained. \n\nSince the {\\pev}s approximate the most dominant {\\ev}, they could be similar. \nTo reduce this redundancy,\nwhitening~\\cite{kessy2017optimal} is used to make the pseudo-eigenvectors uncorrelated.\nMoreover, noise in the {\\pev}s are reduced \nby a rectification process, which will be discussed later.\n\n\\comment{\nFirst, we generate a set of pseudo-eigenvectors using different random vectors $\\bm{v}_0$.\nFrom Eq.~\\ref{eq:v0}, $\\bm{v}_0$ can be represented by the subspace spanned by all the eigenvectors.\nSuppose $\\bm{e}_i$ is an informative eigenvector with a relatively small eigenvalue $\\lambda_i$.\nGiven a $\\bm{v}_0$, if it has a dominant component in the direction of $\\bm{e}_i$, \ni.e., the associated coefficient $c_i$ is large, \nwith an appropriate number of iterations, $c_i\\lambda_i^t\\approx c_2\\lambda_2^t$,\nthe effect of $\\bm{e}_i$ will be finally retained in the pseudo-eigenvector.\nTherefore, multiple pseudo-eigenvectors generated by different $\\bm{v}_0$\nmay increase the chance to hold all the informative eigenvectors.\n\nSecond, we can control the number of iterations in PI.\nIn PIC, the \\emph{velocity} and \\emph{acceleration} at the $t$-th iteration are respectively defined as\n$\\bm{\\delta}_t = \\bm{v}_t - \\bm{v}_{t-1}$ and $\\bm{\\epsilon}_t = \\bm{\\delta}_t-\\bm{\\delta}_{t-1}$.\nA threshold $\\epsilon$ is introduced to measure the acceleration change in two consecutive iterations \nand stop PI when $|\\bm{\\epsilon}_t-\\bm{\\epsilon}_{t-1}|<\\epsilon$.\nHowever,\nsince the effect of eigenvectors corresponding to smaller eigenvalues will shrink as $t$ increases,\nwe can decrease the number of iterations by gradually increasing the $\\epsilon$ value,\nwhich provides another way to keep useful information in ``less important'' eigenvectors. \n}\n\n\\subsection*{Transitive {\\it K} Nearest Neighbor (TKNN) Graph}\n\n%\\begin{figure}\n%    \\centering\n%        \\includegraphics[width = 0.8\\linewidth]{figure/example1.eps}\n%        \\caption{An toy example}\n%        \\label{figure:example1}\n%\\end{figure}\n\n%The \\emph{$K$ nearest neighbor} (KNN) graph is generally used to depict the most adjacent relations between objects,\n%in which the linked objects are generally assumed to share common characteristics.\n%Given a set of objects $\\mathcal{X} = \\{\\bm{x}_1,\\bm{x}_2,...,\\bm{x}_n\\}$,\n%the KNN graph $G_{K} = (V, E)$ is a graph with $V = \\mathcal{X}$ and $E = \\{e_{ij}\\}$.\n%%An edge $e_{ij}$ between $\\bm{x}_i$ and $\\bm{x}_j$ indicates\n%%$x_j \\in N_K(\\bm{x}_i)$ or $x_i \\in N_K(\\bm{x}_j)$,\n%%where $N_K(\\bm{x}_i)$ denotes the set of $K$ nearest neighbors of $\\bm{x}_i$.\n%%at least one of the two end nodes is in the $K$ nearest neighborhood of the other.\n%%However, the $K$ nearest neighborhood relation is not symmetric,\n%%i.e., $x_j \\in N_K(\\bm{x}_i)$ is inequivalent to $x_i \\in N_K(\\bm{x}_j)$, \n%Some previous work~\\cite{yin2016laplacian} simply considers $e_{ij}$\n%exists when $\\bmx_j \\in N_K(\\bmx_i)$ or $x_i \\in N_K(\\bmx_j)$,\n%where $N_K(\\bmx_i)$ denotes the set of $K$ nearest neighbors of $\\bmx_i$.\n%However,\n%in the case of data containing multi-scale clusters,\n%such definition may lead to an edge between\n%two objects in different clusters.\n%Fig.~\\ref{figure:example1} shows an toy example which consists of two multi-scale clusters\n%marked by ``$\\times$\" and ``$+$\" respectively.\n%For object $\\bmx_1$,\n%object $\\bmx_2$ is its nearest neighbor.\n%But for $\\bmx_2$, $\\bmx_1$ is far away from it.\n%In this case, there will be an edge between $\\bmx_1$ and $\\bmx_2$ in the traditional KNN graph.\n%However, since $\\bmx_1$ and $\\bmx_2$ belong to different clusters,\n%they should not be connected.\n\nOur objective is to capture the high correlations between objects that belong to the same cluster even \n though the objects could be located at distant far ends of a cluster. \n These correlations are expressed via a TKNN graph, which is used to \n regularize the coefficient matrix $Z$.\n\n\\begin{definition}\n\\label{def:nei_relation}\n\\textbf{(Mutual  $K$-nearest neighbors)}\nLet $N_K(x)$ be the set of $K$ nearest neighbors of an object $x$.\nTwo objects $x_i$ and $x_j$ are said to be mutual $K$-nearest neighbors of each other,\ndenoted by $x_i \\sim x_j$, \niff $x_i \\in N_K(x_j)$ and $x_j \\in N_K(x_i)$.\n\\hfill$\\Box$\n\\end{definition}\n\n%In the case of multi-scale data,\n%the KNN graph is sometimes insufficient to reflect whether two objects belong to the same cluster or not.\n%For example, objects $\\bmx_2$ and $\\bmx_3$ in Fig.~\\ref{figure:example1} belong to the same cluster, \n%but they are both far away from each other.\n%%objects $x_1$ and $x_2$ are in different clusters despite their closeness.\n%To construct an effective KNN graph, $\\bmx_2$ and $\\bmx_3$\n%are expected to be linked.\n%Therefore,\n%the reachability between two objects is introduced.\n\n\\begin{definition}\n\\label{def:reachability}\n\\textbf{(Reachability)}\nTwo objects $x_i$ and $x_j$ are said to be reachable from each other\nif there exists a sequence of $h \\geq 2$ objects \n $\\{x_i = x_{a_1}, \\ldots, x_{a_h} = x_j\\}$ such that\n $x_{a_r} \\sim x_{a_{r+1}}$ for $1 \\leq r < h$.\n \\hfill$\\Box$\n\\end{definition}\n\n\\begin{definition}\n\\label{def:trans_relation}\n\\textbf{(Transitive $K$-nearest neighbor (TKNN) graph)}\nGiven a set of objects $\\mathcal{X} = \\{x_1, x_2,..., x_n\\}$,\nthe TKNN graph $\\mathcal{G}_K = (\\mathcal{X},\\mathcal{E})$\nis an undirected graph\nwhere $\\mathcal{X}$ is the set of vertices and $\\mathcal{E}$ is the set of edges.\nSpecifically, the edge ($x_i$, $x_j$) $\\in \\mathcal{E}$\niff $x_i$ and $x_j$ are reachable from each other.\nWe represent the TKNN graph by an $n \\times n$ {\\it reachability matrix}\n$\\mathcal{W}$ \nwhose ($i$,$j$)-entry $\\mathcal{W}_{ij} = 1$ if ($x_i$, $x_j$) $\\in \\mathcal{E}$; 0 otherwise.\n\\hfill$\\Box$\n\\end{definition}\n\n%We note that mutual-KNN is a symmetric relation and so is reachability. \n\n%Compared with the traditional KNN graph, \n%the TKNN graph can more accurately reflect \n%whether two objects belong to the same cluster or not.\n%It will be used in the next section to rectify the matrix of similarity between objects.\n \n\\subsection*{Coefficient Matrix}\n%In the case of multi-scale data,\n%the distance-based similarity is likely to be ineffective. \n%To improve the clustering performance,\n%it is necessary to rectify the matrix.\n%The rectification should follow two principles.\n%First, for the effective similarities, the efficacy should be reserved.\n%Second, for the ineffective ones, the efficacy should be enhanced.\n%For example,\n%the closeness between objects $\\bmx_3$ and $\\bmx_4$ in Fig.~\\ref{figure:example1}\n%leads to a large similarity value.\n%Since the two objects are of the same cluster,\n%the new value should still be large.\n%In comparison, \n%both the similarity between $\\bmx_1$ and $\\bmx_2$ and the one between $\\bmx_2$ and $\\bmx_3$\n%should be rectified, as these distance-based similarities are ineffective.\n\n%In the multi-scale data,\n%different clusters may have different sizes, densities or even geometric structures.\nThe similarity between two objects describes the degree to which they share common characteristics.\nThe more similar they are, \nthe more likely that one object can be represented by the other. \nTherefore,\nto depict the relationships between objects in multi-scale data,\neach object is linearly characterized by other objects,\nassuming the well-known linear subspace model~\\cite{liu2013robust}.\n\nWe generate $p$ {\\pev}s using PI. \n%just as a non-linear manifold can be locally approximated by linear subspaces.\n%First, these vectors, which retain the effects of dominant eigenvectors,\n%can certainly retain the original accurate similarities between objects.\n%Second, they absorb the cluster-separation information from the seemingly ``less important'' eigenvectors,\n%which further provides a reliable source of information to rectify the erroneous similarities.\nLet $X\\in \\mathcal{R}^{p\\times n}$ be a matrix whose rows are the {\\pev}s.\nThe $q$-th column of $X$ can be taken as a feature vector $\\bmx_q$ of an object $x_q$.\nWe normalize the column vectors of $X$ such that $\\bmx_q^T \\bmx_q = 1 \\; \\forall 1 \\leq q \\leq n$.\nWe determine a coefficient matrix $Z \\in \\mathcal{R}^{n \\times n}$ by\\footnote{We will regularize $Z$ to avoid the trivial solution of $Z$ being the identity matrix.}\n\\begin{equation}\n\\label{eq:nonoise}\nX = XZ.\n\\end{equation} \nOne can interpret $Z_{ij}$ \nas a value that reflects how well object $x_i$ characterizes object $x_j$.\n%To avoid the trivial solution of $Z$ equalling the identity matrix,\n%we will regularize $Z$ later.\n%For simplicity, we do not explicitly mention this constraint in the rest of the paper.\n\nAs indicated by previous works~\\cite{ye2016fuse}, the generated pseudo-eigenvectors are likely to be noise-corrupted.\nWe thus extend Equation~\\ref{eq:nonoise} by introducing a noise matrix $O$, giving:\n%However, although the pseudo-eigenvectors inherit useful cluster-separation information,\n%they may also be contaminated by noise.\n%Thus a matrix $O$ is introduced to capture the noise,\n\\begin{equation}\nX = XZ + O.\n\\label{eq:O}\n\\end{equation} \n%The TKNN graph conveys information on whether two objects belong to the same cluster or not,\n\nAs we have explained, the TKNN graph  conveys useful clustering information, bringing highly\ncorrelated objects that are located at distant far ends of a cluster together.\nWe thus use the TKNN graph to regularize matrix $Z$.\nWe derive the following objective function:\n%Since our objective is to derive a $Z$ which can better reflect the true similarities between objects,\n\\comment{\n\\begin{equation}\n%\\label{eq:obj}\n\\min_Z ||O||_F^2+\\lambda_1||Z||_F^2 + \\lambda_2||Z-\\mathcal{W}_K||_F^2,\ns.t., X = XZ+O,\n\\end{equation}\n}\n%By substituting $O$, we derive\n\\begin{equation}\n\\label{eq:obj_constraint}\n\\min_Z ||X-XZ||_F^2 + \\alpha_1 ||Z||_F^2 + \\alpha_2 ||Z-\\mathcal{W}||_F^2,\n\\end{equation}\nwhere $\\alpha_1 > 0,\\alpha_2 \\geq 0$ are two \nweighting factors that adjust the relative weights of the three components that constitute\nthe objective function.\nThe objective function consists of three terms.\nThe first term aims to reduce the noise matrix $O$ (see Equation~\\ref{eq:O}),\nthe second term is the Frobenius norm on $Z$, and\n%that restricts any item in $Z$ from being dominant.\nthe third term regularizes $Z$ by the TKNN graph.\n%For simplicity, as in~\\cite{lu2012robust},\n%we remove the constraint and formulate the problem as\n%\\begin{equation}\n%\\label{eq:obj}\n%\\min_Z ||X-XZ||_F^2 + \\lambda_1 ||Z||_F^2 + \\lambda_2 ||Z-\\mathcal{W}_K||_F^2.\n%\\end{equation}\n%$\\lambda_1$ and $\\lambda_2$ are two parameters to balance the effects of three parts.\nA closed-form solution, $Z^*$, to the optimization problem is\n\\begin{equation}\n\\label{eq:solution}\nZ^* = (X^TX + \\alpha_1I + \\alpha_2I)^{-1}(X^TX+\\alpha_2\\mathcal{W}).\n\\end{equation}\n\n\\subsection*{Grouping Effect}\nFor an object $x_p$, \nlet $\\bmz_p$ be the $p$-th column of the coefficient matrix $Z$.\nWe interpret the entries of $\\bmz_p$ as the coefficients that express $x_p$ as a linear combinations\nof other objects. \nPrevious works~\\cite{lu2012robust,lu2013correlation,hu2014smooth} have shown that if $Z$ has {\\it grouping effect}, then performing spectral \nclustering based on $Z$ would be effective. \nIntuitively, $Z$ has grouping effect if, given two {\\it highly correlated} objects $x_i$ and $x_j$,\ntheir characterizations of other objects are similar.\nExisting works mostly consider {\\it high correlation} between objects as {\\it high similarity} of their\nfeature vectors. With ROSC, we consider object similarity in terms of both feature similarity and \nreachability similarity. \nFeature similarity is measured by the objects' feature vectors as given by the columns of matrix $X$.\nReachability similarity is measured by the columns of matrix $\\mathcal{W}$, \neach of which shows the reachability of an object to all others. \nFormally,\n\n\n\n%It has been shown that the first two terms in the objective function decide the \\emph{grouping effect} of $Z$~\\cite{lu2012robust}.\n%In Problem~\\ref{eq:obj}, the first two terms decides whether $Z$ has the grouping effect~\\cite{lu2012robust} defined as follows.\n%i.e., the more highly correlated two objects are,\n%the larger weight one will have in characterizing the other~\\cite{lu2012robust}.\n\n\\begin{definition}\n\\label{def:grouping}\n\\textbf{(Grouping effect)}. \nGiven a set of objects $\\mathcal{X} = \\{x_1, x_2,..., x_n\\}$,\nlet $\\bmw_q$ be the $q$-th column of $\\mathcal{W}$. \nFurther, let $\\xarrow{i}{j}$ denote the condition:\n(1) $\\bmx_i^T \\bmx_j \\rightarrow 1$ and \n(2) $\\lVert \\bmw_i - \\bmw_j \\rVert_2 \\rightarrow 0$.\nA matrix $Z$ is said to have grouping effect\nif\n\\[\n\\xarrow{i}{j} \\Rightarrow |Z_{ip} - Z_{jp}| \\rightarrow 0\\; \\forall 1 \\leq p \\leq n.\n\\]\n%for an arbitrary object $\\bmx$ and its associated coefficient vector $\\bm{z}$,\n%If $\\bmx_i\\rightarrow \\bmx_j$,\n%then $z_{pi}\\rightarrow z_{pj}$,\n%where $z_{pi}$ and $z_{pj}$ are the $i$th and $j$th entry in $\\bm{z}_p$ respectively.\n%Then we say the self-representation matrix $Z$\n%has the grouping effect.\n%\\hfill$\\Box$\n\\end{definition}\n\nOur next task is to prove that the optimal solution $Z^*$ (as given in Equation~\\ref{eq:solution})\n% of Equation~\\ref{eq:obj_constraint}\nhas the grouping effect.\nIn the following discussion, we use $\\bmz_q^*$ to denote the $q$-th column vector of $Z^*$.\n\n\\begin{lemma}\n\\label{lemma1}\nGiven a set of objects $\\mathcal{X}$,\nthe matrix\n$X\\in \\mathcal{R}^{p\\times n}$ that is composed of the {\\pev}s as rows,\n the reachability matrix $\\mathcal{W}$,\n and the optimal soution $Z^*$ of Equation~\\ref{eq:obj_constraint},\n\\begin{equation}\n\\label{eq:zi}\nZ_{ip}^* = \\frac{\\bm{x}_i^T(\\bm{x}_p-X\\bm{z}_p^*) + \\alpha_2 \\mathcal{W}_{ip}}{\\alpha_1+\\alpha_2}, \\;\\;\\; \\forall 1 \\leq i, p \\leq n.\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}\nFor $1 \\leq p \\leq n$,\nlet $J(\\bm{z}_p) =  ||\\bm{x}_p-X\\bm{z}_p||_2^2 + \\alpha_1 ||\\bm{z}_p||_2^2 + \\alpha_2 ||\\bm{z}_p-\\bm{w}_p||_2^2$.\nSince $Z^*$ is the optimal solution of Equation~\\ref{eq:obj_constraint}, we have $\\frac{\\partial{J}}{\\partial{Z}_{ip}}|_{\\bm{z}_p = \\bm{z}_p^*} = 0\\; \\forall 1\\leq i \\leq n$.\nHence, $-2\\bm{x}_i^T(\\bm{x}_p-X\\bm{z}_p^*)+2\\alpha_1Z_{ip}^*+2\\alpha_2(Z_{ip}^*-\\mathcal{W}_{ip}) = 0$,\nwhich induces Equation~\\ref{eq:zi}.\n\\end{proof}\n\n%\\begin{lemma}\n%\\label{lemma1}\n%Given a set of objects $X\\in \\mathcal{R}^{d\\times n}$ and a TKNN graph $\\mathcal{G} = (\\mathcal{V}, \\mathcal{E}, \\mathcal{W}_K)$,\n%let $\\bm{x}_p$ be an arbitrary object and $\\bm{w}_p$ be the column vector in $\\mathcal{W}_K$ describing the connectivity of $\\bmx_p$.\n%Each item $z_{pi}^*$ in the optimal solution $\\bm{z}_p^*$ to the problem \n%$\\min_{\\bm{z}} ||\\bm{x}_p-X\\bm{z}_p||_2^2 + \\lambda_1 ||\\bm{z}_p||_2^2 + \\lambda_2 ||\\bm{z}_p-\\bm{w}_p||_2^2$ is\n%\\begin{equation}\n%\\label{eq:zi}\n%z_{pi}^* = \\frac{\\bm{x}_i^T(\\bm{x}_p-X\\bm{z}_p^*) + \\lambda_2 w_{pi}}{\\lambda_1+\\lambda_2},\n%\\end{equation}\n%where $w_{pi} = 1$, if $\\bm{x_p}$ and $\\bm{x}_i$ are reachable; $0$, otherwise. \n%\n%Proof. Let $J(\\bm{z}_p) =  ||\\bm{x}_p-X\\bm{z}_p||_2^2 + \\lambda_1 ||\\bm{z}_p||_2^2 + \\lambda_2 ||\\bm{z}_p-\\bm{w}_p||_2^2$.\n%Since $\\bm{z}_p^*$ is the optimal solution, then $\\frac{\\partial{J}}{\\partial{z}_{pi}}|_{\\bm{z}_p = \\bm{z}_p^*} = 0$.\n%Thus we have $-2\\bm{x}_i^T(\\bm{x}_p-X\\bm{z}_p^*)+2\\lambda_1z_{pi}^*+2\\lambda_2(z_{pi}^*-w_{pi}) = 0$,\n%which induces Eq.~\\ref{eq:zi}.\n%\\end{lemma}\n\n\\comment{\nEq.~\\ref{eq:zi} calculates the weight of object $\\bm{x}_i$ in characterizing $\\bm{x}$.\nFor $w_i$, if $\\bm{x}$ and $\\bm{x}_i$ are reachable in the TKNN graph, $w_i = 1$; otherwise, $w_i = 0$. \nEq.~\\ref{eq:zi} rectifies the ineffective similarity as follows.\nWhen $\\bm{x}$ and $\\bm{x_i}$ are far away from each other in the feature space\nbut reachable in the TKNN graph,\n$z_i$ will be increased by $w_i = 1$.\n%which rectifies the original incorrect similarity value between them.\nMoreover, if $\\bm{x}$ and $\\bm{x}_i$ are highly correlated,\nthe first two terms in the problem can decide a large $z_i$,\neven in the case that they are unreachable.\n%$z_i$ can still keep large with a small $\\lambda_2$.\nIn summary, Eq.~\\ref{eq:zi} can not only hold the original accurate similarities but also rectify the incorrect ones.\n\n\\noindent{\\small$\\bullet$}\nFor any two objects dissimilar in the feature space but connected in the TKNN graph, \ntheir similarity will be increased.\n\n\\noindent{\\small$\\bullet$}\nFor any two objects dissimilar in the feature space and disconnected in the TKNN graph, \ntheir similarity will be further decreased.\n\n\\noindent{\\small$\\bullet$}\nFor any two objects similar in the feature space and connected in the TKNN graph,\ntheir similarity will be further increased.\n\n\\noindent{\\small$\\bullet$}\nFor any two objects similar in the feature space but disconnected in the TKNN graph,\ntheir similarity will be decreased. In this case,\nprovided that the raw similarity is effective already,\neven though the new value will be decreased,\nbut it will be still\n}\n\n\\begin{lemma}\n\\label{lemma2}\n%Given a set of objects $X\\in R^{d\\times n}$ and a TKNN graph $\\mathcal{G} = (\\mathcal{V}, \\mathcal{E}, \\mathcal{W}_K)$,\n%let $\\bm{x}_p$ be an arbitrary object, \n%$\\bm{w}_p$ be the column vector in $\\mathcal{W}_K$ describing the connectivity of $\\bm{x}_p$, and\n%$\\bm{z}_p^*$ be the optimal solution to the problem \n%$\\min_{\\bm{z}_p} ||\\bm{x}_p-X\\bm{z}_p||_2^2 + \\lambda_1 ||\\bm{z}_p||_2^2 + \\lambda_2 ||\\bm{z}_p-\\bm{w}_p||_2^2$.\n%Assume all the objects have been normalized.\n%For any two objects $\\bm{x}_i$ and $\\bm{x}_j$,\n$\\forall 1 \\leq i, j, p \\leq n$,\n\\begin{equation}\n\\label{eq:norm}\n|Z_{ip}^*-Z_{jp}^*| \\leq \\frac{c\\sqrt{2(1-r)} + \\alpha_2|\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|}{\\alpha_1+\\alpha_2},\n\\end{equation}\nwhere $c = \\sqrt{1+\\alpha_2||\\bm{w}_p||_2^2}$ and $r = \\bm{x}_i^T\\bm{x}_j$.\n\\end{lemma}\n\n\\begin{proof}\nFrom Equation~\\ref{eq:zi}, we have \n\\begin{equation}\n\\nonumber\nZ_{ip}^*-Z_{jp}^* = \\frac{(\\bm{x}_i^T - \\bm{x}_j^T)(\\bm{x}_p-X\\bm{z}_p^*) + \\alpha_2 (\\mathcal{W}_{ip}-\\mathcal{W}_{jp})}{\\alpha_1+\\alpha_2}.\n\\end{equation}\nThat implies \n\\begin{small}\n\\begin{equation}\n\\label{eq:zizj}\n\\begin{split}\n|Z_{ip}^*-Z_{jp}^*| & \\leq \\frac{|(\\bm{x}_i^T - \\bm{x}_j^T)(\\bm{x}_p-X\\bm{z}_p^*)| + \\alpha_2 |\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|}{\\alpha_1+\\alpha_2}\\\\\n& \\leq \\frac{||\\bm{x}_i - \\bm{x}_j||_2||\\bm{x}_p-X\\bm{z}_p^*||_2 + \\alpha_2 |\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|}{\\alpha_1+\\alpha_2}\\\\\n\\end{split}\n\\end{equation}\n\\end{small}\n\nSince the column vectors of $X$ are normalized (i.e., $\\bmx_q^T \\bmx_q = 1 \\; \\forall 1 \\leq q \\leq n$) , we have\n$||\\bm{x}_i - \\bm{x}_j||_2 = \\sqrt{2(1-r)}$,\nwhere $r = \\bm{x}_i^T\\bm{x}_j$.\n%measuring the closeness between $\\bm{x}_i$ and $\\bm{x}_j$ in the feature space.\n%As $\\bm{z}_p^*$ is the optimal solution, \nAs $Z^*$ is the optimal solution of Equation~\\ref{eq:obj_constraint}, we have\n\\begin{equation}\n\\begin{split}\nJ(\\bm{z}_p^*) & = ||\\bm{x}_p-X\\bm{z}_p^*||_2^2 + \\alpha_1 ||\\bm{z}_p^*||_2^2 + \\alpha_2 ||\\bm{z}_p^*-\\bm{w}_p||_2^2 \\leq  \\\\\nJ(\\bm{0}) & = ||\\bm{x}_p||_2^2 + \\alpha_2 ||\\bm{w}_p||_2^2 = 1 + \\alpha_2 ||\\bm{w}_p||_2^2.\n\\end{split}\n\\end{equation}\nHence, $||\\bm{x}_p-X\\bm{z}_p^*||_2 \\leq \\sqrt{1 + \\alpha_2 ||\\bm{w}_p||_2^2} = c$.\nEquation~\\ref{eq:zizj} can be further simplified as\n\\begin{equation}\n\\nonumber\n|Z_{ip}^*-Z_{jp}^*| \\leq \\frac{c\\sqrt{2(1-r)}+ \\alpha_2 |\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|}{\\alpha_1+\\alpha_2}.\n\\end{equation}\n\\end{proof}\n\n\\begin{lemma}\nMatrix $Z^*$ has grouping effect.\n\\label{lemma:z-star}\n\\end{lemma}\n\\begin{proof}\nGiven two objects $x_i$ and $x_j$ such that $\\xarrow{i}{j}$,\nwe have,  %by definition, \n(1) $\\bmx_i^T \\bmx_j \\rightarrow 1$ and (2) $||\\bmw_{i}-\\bmw_{j}||_2 \\rightarrow 0$.\nThese imply\n$r = \\bmx_i^T \\bmx_j \\rightarrow 1$ and  $|\\mathcal{W}_{ip}-\\mathcal{W}_{jp}| \\rightarrow 0$.\nHence, the two terms of the numerator of the R.H.S of Equation~\\ref{eq:norm} are close to 0. \nTherefore, $|Z_{ip}^*-Z_{jp}^*| \\rightarrow 0$ and thus $Z^*$ has grouping effect.\n\\end{proof}\n\nIndeed, Equation~\\ref{eq:norm} shows how our algorithm ROSC enhances the effectiveness of \nspectral clustering on multi-scale data. \nComparing with traditional approaches, which focus on feature similarity, ROSC uses $Z^*$\nto integrate feature similarity  ($r$) with\nreachability similarity ($|\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|$).\nIn particular, two distant objects $x_i$ and $x_j$ of a cluster may not share a strong feature similarity.\nThis leads to a small $r$ and traditional approaches will likely put them into separate clusters.\nOn the contrary, ROSC considers the strong reachability of the objects\nto derive a small value of $|\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|$, and thus keeping them in the same cluster.\nMoreover, for $x_i$ and $x_j$ that belong to two different dense clusters but happen to be close in \nspace (i.e., $x_i$ and $x_j$ have strong feature similarity), \ntraditional approaches may inadvertently merge them into the same cluster. \nROSC, however, would discover their low reachability (via the mutual-KNN relation)\nand derive a large value of $|\\mathcal{W}_{ip}-\\mathcal{W}_{jp}|$.\nThis regulates matrix $Z^*$ and avoids the incorrect merging.\nAs we will see in the next section, ROSC's approach \ngreatly improves clustering quality and is more robust than other algorithms in handling\nmulti-scale data.\n \n%Lemma~\\ref{lemma1} and~\\ref{lemma2} prove the grouping effect of $Z^*$ derived by Eq.~\\ref{eq:solution}.\n%%the weight difference of two objects in characterizing an arbitrary object $\\bm{x}$ is bounded.\n%Given two objects $\\bmx_i$ and $\\bmx_j$, if $\\bmx_i \\rightarrow \\bmx_j$, \n%i.e., $\\bmx_i^T \\bmx_j \\rightarrow 1$ and $||w_{pi}-w_{pj}||_2 \\rightarrow 0$,\n%then $||z_{pi}^*-z_{pj}^*||_2 \\rightarrow 0$.\n%%which shows the grouping effect of $Z$ derived by Eq.~\\ref{eq:solution}.\n%%However, in the case of (1) $\\bm{x}_i^T\\bm{x}_j = 0$ but $w_i=w_j=1$ and \n%%(2) $\\bm{x}_i^T\\bm{x}_j = 1$ but $||w_i-w_j||_2=1$,\n%%$||z_i^*-z_j^*||_2$ can still be small with an appropriate setting on $\\lambda_1$ and $\\lambda_2$.\n%%Further, since $Z$ can not only retain the accurate similarities but also rectify the incorrect ones, \n%%In other words, objects in the same cluster will be better reflected in the rectified matrix.\n%%Such grouping effect together with The rectification ability could guarantee a more robust clustering performance.\n%We then summarize how the TKNN graph rectifies the raw similarity matrix.\n%Given any two objects $\\bmx_i$ and $\\bmx_j$,\n%\\begin{enumerate}[label=(\\arabic*), leftmargin=*]\n%\\setlength{\\itemsep}{0pt}\n%\\setlength{\\parsep}{0pt}\n%\\setlength{\\parskip}{0pt}\n%\\item $\\bmx_i^T \\bmx_j \\rightarrow 0$, $\\bmx_i$ and $\\bmx_j$ are reachable, the effect of $S_{ij}$ will be increased.\n%\\item $\\bmx_i^T \\bmx_j \\rightarrow 0$, $\\bmx_i$ and $\\bmx_j$ are unreachable, the effect of $S_{ij}$ will be further decreased.\n%\\item $\\bmx_i^T \\bmx_j \\rightarrow 1$, $\\bmx_i$ and $\\bmx_j$ are reachable, the effect of $S_{ij}$ will be further increased.\n%\\item $\\bmx_i^T \\bmx_j \\rightarrow 1$, $\\bmx_i$ and $\\bmx_j$ are unreachable, the effect of $S_{ij}$ will be decreased.\n%\\end{enumerate}\n%Among the four cases,\n%$Z$ reserves the efficacy of effective similarities by (2) and (3)\n%while it enhances the efficacy of ineffective similarities by (1) and (4). \n%Thus spectral clustering based on $Z$ will be more robust.\n\n\\comment{\n\\noindent{\\small$\\bullet$}\n$\\bmx_i^T \\bmx_j \\rightarrow 0$ but reachable, $S_{ij}$ will be increased.\n\n\\noindent{\\small$\\bullet$}\n%For any two objects dissimilar in the feature space and disconnected in the TKNN graph, their similarity will be further decreased.\n$\\bmx_i^T \\bmx_j \\rightarrow 0$ and unreachable, $S_{ij}$ will be further decreased.\n\n\\noindent{\\small$\\bullet$}\n%For any two objects similar in the feature space and connected in the TKNN graph, their similarity will be further increased.\n$\\bmx_i^T \\bmx_j \\rightarrow 1$ and reachable, $S_{ij}$ will be further increased.\n\n\\noindent{\\small$\\bullet$}\n$\\bmx_i^T \\bmx_j \\rightarrow 1$ but unreachable, $S_{ij}$ will be decreased.\n}\n\n\\subsection*{ROSC: Robust Spectral Clustering}\n%The coefficient matrix $Z$ take advantage of both cluster-separation information in all the eigenvectors\n%and the TkNN graph, which not only retains the original accurate similarities but also rectifies the incorrect ones.\n\nWe note that the matrix $Z^*$ obtained may be asymmetric and it may contain negative values.\nTo construct a matrix of object similarity, a common fix~\\cite{liu2013robust,lu2012robust} is to \ncompute $\\tilde{Z} = (|Z^*|+|(Z^*)^T|)/2$.\nAfter $\\tilde{Z}$ is computed, ROSC executes a standard spectral clustering method\n(e.g., NCuts) using $\\tilde{Z}$ as the similarity matrix in place of $S$.\nIt can be proved that $|Z^*|$, $|(Z^*)^T|$, and hence $\\tilde{Z}$ all have grouping effect.\n%Due to space limitations, readers are referred to [XXX] for the proofs. \nFinally, ROSC is summarized in Algorithm~\\ref{alg}.\n\n\\begin{lemma}\nMatrix $|Z^*|$ has grouping effect.\n\\label{lemma:z-star-abs}\n\\end{lemma}\n\\begin{proof}\nGiven two objects $x_i$ and $x_j$,\nwe have \n$\\bigl||Z_{ip}^*|-|Z_{jp}^*|\\bigr| \\leq |Z_{ip}^*-Z_{jp}^*|$.\nFrom Lemma~\\ref{lemma:z-star},\n$Z^*$ has grouping effect, i.e.,\nif $x_i \\rightarrow x_j$, $|Z_{ip}^*-Z_{jp}^*| \\rightarrow 0$.\nThus $\\bigl||Z_{ip}^*|-|Z_{jp}^*|\\bigr| \\rightarrow 0$ and \n$|Z^*|$ has grouping effect.\n\\end{proof}\n\n\\begin{lemma}\n\\label{lemma3}\n$(Z^*)^T$ and $|(Z^*)^T|$ have grouping effect. \n\\begin{proof}\nThe problem is equivalent to if $x_i \\rightarrow x_j$, $Z^*_{pi} \\rightarrow Z^*_{pj}$.\nFrom Lemma~\\ref{lemma1},\n\\begin{equation}\n\\nonumber\nZ_{pi}^*-Z_{pj}^* = \\frac{\\bm{x}_p^T ( \\bmx_i - \\bmx_j - X(\\bm{z}_i^*-\\bm{z}_j^*)) + \\alpha_2 (\\mathcal{W}_{pi}-\\mathcal{W}_{pj})}{\\alpha_1+\\alpha_2}.\n\\end{equation}\nSince $\\bm{z}_i^* = (X^TX + \\alpha_1I + \\alpha_2I)^{-1}(X^T\\bmx_i+\\alpha_2\\bm{w}_i),\\bm{z}_j^* = (X^TX + \\alpha_1I + \\alpha_2I)^{-1}(X^T\\bmx_j+\\alpha_2\\bm{w}_j)$,\nlet $Y = X(X^TX + \\alpha_1I + \\alpha_2I)^{-1}$. Then\n\\begin{equation}\n\\begin{split}\n|Z_{pi}^*-Z_{pj}^*| & \\leq \\frac{|\\bmx_p^T(\\bm{x}_i - \\bm{x}_j)| + |\\bmx_p^TX(\\bm{z}_i^*-\\bm{z}_j^*)| + \\alpha_2 |(\\mathcal{W}_{pi}-\\mathcal{W}_{pj})|}{\\alpha_1+\\alpha_2}\\\\\n& \\leq \\frac{|\\bmx_p^T(\\bm{x}_i - \\bm{x}_j)| + |\\bmx_p^TYX^T(\\bmx_i-\\bmx_j)|}{\\alpha_1+\\alpha_2}\\\\\n& + \\frac{\\alpha_2|\\bmx_p^TY(\\bm{w}_i - \\bm{w}_j)| + \\alpha_2 |\\mathcal{W}_{pi}-\\mathcal{W}_{pj}|}{\\alpha_1+\\alpha_2}\\\\\n& \\leq \\frac{||\\bmx_p||_2||\\bm{x}_i - \\bm{x}_j||_2 + ||\\bmx_p^TYX^T||_2||\\bmx_i-\\bmx_j||_2}{\\alpha_1+\\alpha_2}\\\\\n& + \\frac{\\alpha_2||\\bmx_p^TY||_2||\\bm{w}_i - \\bm{w}_j||_2 + \\alpha_2 |\\mathcal{W}_{pi}-\\mathcal{W}_{pj}|}{\\alpha_1+\\alpha_2}\\\\\n\\end{split}\n\\end{equation}\nIf $x_i \\rightarrow x_j$, i.e., $\\bmx_i^T\\bmx_j \\rightarrow 1$ and $||\\bm{w}_i - \\bm{w}_j||_2 \\rightarrow 0$, \nwe have\n$||\\bm{x}_i - \\bm{x}_j||_2 \\rightarrow 0$ and $|\\mathcal{W}_{pi}-\\mathcal{W}_{pj}| \\rightarrow 0$.\nThen $|Z_{pi}^*-Z_{pj}^*| \\rightarrow 0$ and\nthus $(Z^*)^T$ has grouping effect.\nSince $\\bigl||Z_{pi}^*|-|Z_{pj}^*|\\bigr| \\leq |Z_{pi}^*-Z_{pj}^*|$, $|(Z^*)^T|$ also has grouping effect.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma}\n\\label{lemma4}\nMatrix $\\tilde{Z}$ has grouping effect. \n\\begin{proof}\nFrom Lemma~\\ref{lemma:z-star-abs} and~\\ref{lemma3},\nboth $\\lvert Z^*\\rvert$ and $\\lvert (Z^*)^T\\rvert$ have the grouping effect.\nSince $\\tilde{Z} = (|Z^*|+|(Z^*)^T|)/2$,\n\\begin{equation}\n\\begin{split}\n\\lvert \\tilde{Z}_{ip} - \\tilde{Z}_{jp}\\rvert & = \\frac{\\bigl| (|Z^*_{ip}|+|Z^*_{pi}|) - (|Z^*_{jp}|+|Z^*_{pj}|)\\bigr|}{2} \\\\\n& \\leq \\frac{\\bigl||Z_{ip}^*|-|Z_{jp}^*|\\bigr| + \\bigl||Z_{pi}^*|-|Z_{pj}^*|\\bigr|}{2}\n\\end{split}\n\\end{equation}\nIf $x_i \\rightarrow x_j$,\nboth $\\bigl||Z_{ip}^*|-|Z_{jp}^*|\\bigr| \\rightarrow 0$ and $\\bigl||Z_{pi}^*|-|Z_{pj}^*|\\bigr| \\rightarrow 0$,\nso $\\lvert \\tilde{Z}_{ip} - \\tilde{Z}_{jp}\\rvert \\rightarrow 0$ and\n$\\tilde{Z}$ has grouping effect.\n\\end{proof}\n\\end{lemma}\n\n\n\\comment{\n\\begin{lemma}\n\\label{lemma3}\n$(Z^*)^T$ has the grouping effect. \n\nProof. The problem is equivalent to if $x_i \\rightarrow x_j$, $Z^*_{pi} \\rightarrow Z^*_{pj}$.\nFrom Lemma~\\ref{lemma1},\n\\begin{equation}\n\\nonumber\nz_{pi}^*-z_{pj}^* = \\frac{\\bm{x}_p^T ( \\bmx_i - \\bmx_j - X(\\bm{z}_i^*-\\bm{z}_j^*)) + \\alpha_2 (W_{pi}-W_{pj})}{\\alpha_1+\\alpha_2}.\n\\end{equation}\nSince $\\bm{z}_i^* = (X^TX + \\alpha_1I + \\alpha_2I)^{-1}(X^T\\bmx_i+\\alpha_2\\bm{w}_i),\\bm{z}_j^* = (X^TX + \\alpha_1I + \\alpha_2I)^{-1}(X^T\\bmx_j+\\alpha_2\\bm{w}_j)$,\nlet $Y = X(X^TX + \\alpha_1I + \\alpha_2I)^{-1}$. Then\n\\begin{equation}\n\\begin{split}\n||Z_{pi}^*-Z_{pj}^*||_2 & \\leq \\frac{||\\bmx_p^T(\\bm{x}_i - \\bm{x}_j)||_2 + ||\\bmx_p^TX(\\bm{z}_i^*-\\bm{z}_j^*)||_2 + \\alpha_2 ||(W_{pi}-W_{pj})||_2}{\\alpha_1+\\alpha_2}\\\\\n& \\leq \\frac{||\\bmx_p^T(\\bm{x}_i - \\bm{x}_j)||_2 + ||\\bmx_p^TYX^T(\\bmx_i-\\bmx_j)||_2}{\\alpha_1+\\alpha_2}\\\\\n& + \\frac{\\alpha_2||\\bmx_p^TY(\\bm{w}_i - \\bm{w}_j)||_2 + \\alpha_2 ||W_{pi}-W_{pj}||_2}{\\alpha_1+\\alpha_2}\\\\\n\\end{split}\n\\end{equation}\nIf $x_i \\rightarrow x_j$, i.e., $\\bmx_i^T\\bmx_j \\rightarrow 1$ and $||\\bm{w}_i - \\bm{w}_j||_2 \\rightarrow 0$, \nwe have\n$||\\bm{x}_i - \\bm{x}_j||_2 \\rightarrow 0$ and $||W_{pi}-W_{pj}||_2 \\rightarrow 0$.\nThen $||Z_{pi}^*-Z_{pj}^*||_2 \\rightarrow 0$,\nwhich proves the grouping effect of $(Z^*)^T$.\n%\\begin{equation}\n%\\begin{split}\n%||\\bmx_p^TX(\\bm{z}_i^*-\\bm{z}_j^*)||_2 & \\leq ||\\bmx_p^TY(X^T(\\bmx_i-\\bmx_j) +\\alpha_2(\\bm{w}_i - \\bm{w}_j))||_2\\\\\n%& \\leq ||\\bmx_p^TYX^T(\\bmx_i-\\bmx_j)||_2 +\\alpha_2||\\bmx_p^TY(\\bm{w}_i - \\bm{w}_j)||_2\\\\\n%\\end{split}\n%\\end{equation}\n\\end{lemma}\n\n\\begin{lemma}\n\\label{lemma4}\n$\\tilde{Z}$ has the grouping effect. \n\nProof. From Lemma~\\ref{lemma2} and~\\ref{lemma3},\nboth $Z^*$ and $(Z^*)^T$ have the grouping effect,\nwhich can be easily extended to\n$|Z^*|$ and $|(Z^*)^T|$.\nSince $\\tilde{Z} = (|Z^*|+|(Z^*)^T|)/2$,\n$\\tilde{Z}$ also has the grouping effect.\n\\end{lemma}\n\nTo this end, we summarize ROSC as follows.\nROSC first computes the TKNN graph $\\mathcal{G}$\nand the associated weight matrix $\\mathcal{W}_K$. Then it applies power iteration to generate $p$\npseudo-eigenvectors that form a $p \\times n$ matrix $X$.\nAfter whitening and normalization on $X$,\nthe coefficient matrix $Z^*$ can be calculated by solving Eq.~\\ref{eq:solution},\nwhich further leads to the construction of a rectified similarity matrix $\\tilde{Z}$.\nSince $\\tilde{Z}$ has the grouping effect, \nthe standard spectral clustering methods (e.g., NCuts) will be finally applied to derive more robust clustering results.\nThe time complexity of ROSC will be no more than the standard spectral clustering methods,\nwhich is $O(n^3)$ in general.\nIn the future, we will attempt to improve it. \n}\n\n\\begin{algorithm}\n\\begin{small}\n\\caption{ROSC}\n\\label{alg}\n\\begin{algorithmic}[1]\n\\Require $S$, $k$.\n\\Ensure $\\mathcal{C} = \\{C_1, ..., C_k\\}$\n\\State Compute the TKNN graph and the reachability matrix $\\mathcal{W}$\n\\State Calculate $W = D^{-1}S$, where $D_{ii} = \\sum_jS_{ij}$\n%\\For $j \\leftarrow 1$ do\n%\\State$t = 0$\n%\\Repeat\n%\\State $v_j^{t+1} \\leftarrow \\frac{Wv_j^t}{||Wv_j^t||_1}$\n%\\State $ \\delta^{t+1} \\leftarrow |v_j^{t+1} - v_j^t|$\n%\\State $t$++\n%\\Until $||\\delta_j^t+1 - \\delta_j^t||_{max} \\leq \\epsilon$ or $t\\geq T$\n%\\EndFor\n\\State Apply PI on $W$ and generate $p$ pseudo-eigenvectors $\\{\\bm{v}_r\\}_{r=1}^p$\n\\State $X = \\{\\bm{v}_1^T; \\bm{v}_2^T; ...; \\bm{v}_p^T\\}$; $X$ = whiten($X$)\n\\State Normalize each column vector $\\bm{x}$ of $X$ such that $\\bm{x}^T\\bm{x} = 1$\n\\State Calculate the coefficient matrix $Z^*$ by Eq.~\\ref{eq:solution}\n\\State Construct $\\tilde{Z} = (|Z^*| + |(Z^*)^T|)/2$\n\\State Run standard spectral clustering methods, e.g., NCuts, with $\\tilde{Z}$ as the\nsimilarity matrix to obtain clusters $\\mathcal{C} = \\{C_r\\}_{r=1}^k$\n%\\State Decode $\\{C_r\\}_{r=1}^k$ from $\\{{\\bm z_r}\\}_{r=1}^k$\n\\State \\Return $\\mathcal{C} = \\{C_1, ..., C_k\\}$\n\\end{algorithmic}\n\\end{small}\n\\end{algorithm}\n\n\n\n\n\n\n\n", "meta": {"hexsha": "83fd3689a2d9e626b979aa76a099895282f45dc0", "size": 35162, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/HINGCN/tex/algorithm_report1.tex", "max_stars_repo_name": "dingdanhao110/HINGCN", "max_stars_repo_head_hexsha": "281b73c03bd3b00e35bce4c5e1c27076233555e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/HINGCN/tex/algorithm_report1.tex", "max_issues_repo_name": "dingdanhao110/HINGCN", "max_issues_repo_head_hexsha": "281b73c03bd3b00e35bce4c5e1c27076233555e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/HINGCN/tex/algorithm_report1.tex", "max_forks_repo_name": "dingdanhao110/HINGCN", "max_forks_repo_head_hexsha": "281b73c03bd3b00e35bce4c5e1c27076233555e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.3155680224, "max_line_length": 174, "alphanum_fraction": 0.7022353677, "num_tokens": 11878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4429149272207237}}
{"text": "%% FILENAME: paper.tex\n%% AUTHOR:   Cameron Swords\n\n\\documentclass[10pt]{article}\n\n\\input{defs.tex}\n\n\\setlength{\\abovedisplayskip}{2pt}\n\\setlength{\\belowdisplayskip}{2pt}\n\n\\begin{document}\n\n\\section{Language Definitions}\n\n\\[\n  \\begin{array}{rcl}\n  e  &:=& x \\alt v \\alt e~e \\alt \\letdefe{x}{e}{e}\\\\\n     &\\alt& \\ife{e}{e}{e} \\alt \\unope{e} \\alt \\binope{e}{e}\\\\\n  \\\\ %% A line break before the next definition sets\n  v  &:=& \\lamdefe{x}{e} \\alt \\truev \\alt \\falsev\\\\\n  \\\\\n  \\binopdef &:=& \\andop \\alt \\orop\\\\\n  \\unopdef  &:=& \\notop \\\\\n  \\\\\n  \\Ctxt &:=& \\Ctxt~e \\alt v~\\Ctxt \\alt \\letdefe{x}{\\Ctxt}{e}\\\\\n  &\\alt& \\ife{\\Ctxt}{e}{e} \\alt \\unope{\\Ctxt} \\alt \\binope{\\Ctxt}{e} \\alt \\binope{v}{\\Ctxt}\\\\\n  \\\\\n  \\tau  &:=& \\boolt \\alt \\funct{\\tau}{\\tau}\\\\\n  \\end{array}\n\\]\n\n\\section{Semantics One}\n\n\\begin{gather*}\n\\infr[App]\n  {\\dstep{e_1}{\\lamdefe{x}{e'}} \\iand \\dstep{e_2}{v} \\iand \\cdots}\n  {\\dstep{e_1~e_2}{\\subst{x}{v}{e'}}}\n~\n\\infr\n  {\\dstep{e_1}{v} \\iand \\cdots}\n  {\\dstep{\\letdefe{x}{e_1}{e_2}}{\\subst{x}{v}{e_2}}}\n\\\\\n\\infr\n  {\\dstep{e_1}{\\truev} \\iand \\dstep{e_2}{v}}\n  {\\dstep{\\ife{e_1}{e_2}{e_3}}{v}}\n~\n\\infr\n  {\\dstep{e_1}{\\falsev} \\iand \\dstep{e_3}{v}}\n  {\\dstep{\\ife{e_1}{e_2}{e_3}}{v}}\n\\\\\n\\infr\n  {\\dstep{e_1}{\\truev} \\iand \\dstep{e_2}{\\truev}}\n  {\\dstep{\\ande{e_1}{e_2}}{\\truev}}\n~\n\\infr\n  {\\dstep{e_1}{\\falsev}}\n  {\\dstep{\\ande{e_1}{e_2}}{\\falsev}}\n\\\\\n\\infr\n  {\\dstep{e_1}{\\truev}}\n  {\\dstep{\\ore{e_1}{e_2}}{\\truev}}\n~\n\\infr\n  {\\dstep{e_1}{\\falsev} \\iand \\dstep{e_2}{v}}\n  {\\dstep{\\ore{e_1}{e_2}}{v}}\n\\\\\n\\infr\n  {\\dstep{e}{\\truev}}\n  {\\dstep{\\note{e}}{\\falsev}}\n~\n\\infr\n  {\\dstep{e}{\\falsev}}     \n  {\\dstep{\\note{e}}{\\truev}}\n\\end{gather*}\n\n\\section{Semantics Two}\n\n\\[\n  \\begin{array}{rcll}\n  \\sstep  {(\\lamdefe{x}{e})~v}      {\\subst{x}{v}{e} (\\cdots)}{App}\\\\\n  \\sstep  {\\letdefe{x}{v}{e}}       {\\subst{x}{v}{e} (\\cdots)}\\\\\n  \\sstep  {\\ife{\\truev}{e_2}{e_3}}  {e_2}\\\\\n  \\sstep  {\\ife{\\falsev}{e_2}{e_3}} {e_3}\\\\\n  \\sstep  {\\ande{\\falsev}{e_2}}     {\\falsev}\\\\\n  \\sstep  {\\ande{\\truev}{e_2}}      {e_2}\\\\\n  \\sstep  {\\ore{\\falsev}{e_2}}      {e_2}\\\\\n  \\sstep  {\\ore{\\truev}{e_2}}       {\\truev}\\\\\n  \\sstep  {\\note{\\falsev}}          {\\truev}\\\\\n  \\sstep  {\\note{\\truev}}           {\\falsev}\\\\\n  \\\\\n  \\ctxtstep {\\InCtxt{e}}            {\\InCtxt{e'} ~ (\\text{if } e\\ssosredex e')}\\\\\n  \\end{array}\n\\]\n\n\\section{Typing Judgments}\n\n\\[\n  \\begin{array}{cc}\n    \\infr{}{\\envent{\\truev}{\\boolt}}\n    &\n    \\infr{}{\\envent{\\falsev}{\\boolt}}\n    \\\\\\\\\n    \\envlookup{\\typeEnv}{x}{\\tau} \n    &\n    \\infr\n      {\\extenvent{x}{\\tau}{e}{\\tau'}}\n      {\\envent{\\lamdefe{x}{e}}{\\funct{\\tau}{\\tau'}}} \n    \\\\\\\\\n    \\infr\n      {\\envent{e_1}{\\funct{\\tau}{\\tau'}} \\iand \n       \\envent{e_2}{\\tau}}\n      {\\envent{e_1~e_2}{\\tau'}} \n    &\n    \\infr\n      {\\extenvent{x}{\\tau'}{e_2}{\\tau} \\iand\n       \\envent{e_1}{\\tau'}}\n      {\\envent{\\letdefe{x}{e_1}{e_2}}{\\tau}}\n    \\\\\\\\\n      \\infr\n        {\\envent{e_1}{\\boolt} \\iand \\envent{e_2}{\\tau} \\iand \\envent{e_3}{\\tau}}\n        {\\envent{\\ife{e_1}{e_2}{e_3}}{\\tau}}\n    &\n    \\infr\n      {\\envent{\\unopdef}{\\funct{\\tau'}{\\tau}} \\iand\n       \\envent{e}{\\tau'}}\n      {\\envent{\\unope{e}}{\\tau}}\n    \\\\\\\\\n    \\multicolumn{2}{c}{ %% for a really LOOOOONG rule\n      \\infr\n        {\\envent{\\binopdef}{\\funct{\\tau_1}{\\funct{\\tau_2}{\\tau}}} \\iand\n         \\envent{e_1}{\\tau_1}                                     \\iand\n         \\envent{e_2}{\\tau_2}}\n        {\\envent{\\binope{e_1}{e_2}}{\\tau}}\n    }\n    \\\\\\\\\n  \\end{array}\n\\]\n\n\\end{document}\n\n", "meta": {"hexsha": "f03bf438e36122a50b0abf6589d1a9aae1fe1ff8", "size": 3469, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper.tex", "max_stars_repo_name": "7449yyc/texsem", "max_stars_repo_head_hexsha": "ee4dff0e214d44363c1c427bb55347218a68745c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-11-15T06:04:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T08:42:37.000Z", "max_issues_repo_path": "paper.tex", "max_issues_repo_name": "7449yyc/texsem", "max_issues_repo_head_hexsha": "ee4dff0e214d44363c1c427bb55347218a68745c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper.tex", "max_forks_repo_name": "7449yyc/texsem", "max_forks_repo_head_hexsha": "ee4dff0e214d44363c1c427bb55347218a68745c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-26T13:26:01.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T13:26:01.000Z", "avg_line_length": 24.6028368794, "max_line_length": 93, "alphanum_fraction": 0.5131161718, "num_tokens": 1596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4429149232509141}}
{"text": "\\documentclass[a4paper,final]{siamart190516}\n\n\\usepackage{damacros}\n\n% Sets running headers as well as PDF title and authors\n\\headers{Neural fields with dendrites }{D. Avitabile, S. Coombes, P.~M. Lima}\n\n% Title. If the supplement option is on, then \"Supplementary Material\"\n% is automatically inserted before the title.\n\\title{Numerical Investigation of a Neural Field Model Including Dendritic Processing} \n\n% Authors: full names plus addresses.\n\\author{%\n  Daniele Avitabile%\n  \\thanks{%\n    Vrije Universiteit Amsterdam,\n    Department of Mathematics,\n    Faculteit der Exacte Wetenschappen,\n    De Boelelaan 1081a,\n    1081 HV Amsterdam, The Netherlands.\n  \\protect\\\\\n    Inria Sophia Antipolis M\\'editerran\\'ee Research Centre,\n    MathNeuro Team,\n    2004 route des Lucioles-Boîte Postale 93 06902,\n    Sophia Antipolis, Cedex, France.\n  \\protect\\\\\n    (\\email{d.avitabile@vu.nl}, \\url{www.danieleavitabile.com}).\n  }\n  \\and\n  Stephen Coombes \\thanks{Centre for Mathematical Medicine and Biology, School of\n  Mathematical Sciences, University of Nottingham, NG7 2RD, UK.}\n  \\and\n  Pedro M. Lima \\thanks{CEMAT, Instituto Superior Tecnico,University of Lisbon,\n  Portugal}\n%   Paul T. Frank \\thanks{Department of Applied Mathematics, Fictional University, Boise, ID \n% (\\email{ptfrank@fictional.edu}, \\email{jesmith@fictional.edu}).}\n% \\and Jane E. Smith\\footnotemark[3]\n}\n\n\\usepackage[ruled,linesnumbered]{algorithm2e}\n\n\\newcommand{\\setan}{{}_{\\stackrel{\\textstyle \\longrightarrow}{n}}}\n\n\\newcommand{\\Real}{\\operatorname{Re}}    % real line\n\\newcommand{\\Imag}{\\operatorname{Im}}  \n\n\\newcommand{\\Cb}{\\mathbb{C}}\n\\newcommand{\\Rb}{\\mathbb{R}}\n\\newcommand{\\Nb}{\\mathbb{N}}\n\\newcommand{\\Zb}{\\mathbb{Z}}\n\\newcommand{\\Ib}{\\mathbb{I}}\n\\newcommand{\\cF}{\\mathcal{F}}\n\\newcommand{\\zast}{\\stackrel{\\ast}{z}}\n\\newcommand{\\xast}{\\stackrel{\\ast}{x}}\n\\newcommand{\\yast}{\\stackrel{\\ast}{y}}\n\\newcommand{\\xastum}{\\stackrel{\\ast}{x_1}}\n\\newcommand{\\xastdois}{\\stackrel{\\ast}{x_2}}\n\n\\newcommand{\\limz}{\\lim_{z \\rightarrow \\zast}} \n\\newcommand{\\diff}{\\mathop{}\\!\\mathrm{d}}\n\\newcommand{\\ep}{\\varepsilon}\n\n\\graphicspath{ {Figures/} }\n\n%\\DeclareMathOperator{\\e}{e}\n\\DeclareMathOperator{\\erf}{erf}\n\\DeclareMathOperator{\\supp}{supp}\n\n% Commands for tables\n\\usepackage{ctable}\n\\newcommand{\\otoprule}{\\midrule[\\heavyrulewidth]}\n\\usepackage{color}\n\\usepackage{listings}\n\n\\definecolor{LightGrey}{rgb}{0.9629411,0.9629411,0.9629411}\n\\definecolor{LighterGrey}{gray}{0.99}\n\\definecolor{Mauve}{rgb}{0.58,0,0.82}\n\\definecolor{Emerald}{rgb}{0.31, 0.78, 0.47}\n\\definecolor{RoyalBlue}{rgb}{0.25, 0.41, 0.88}\n\\definecolor{myGreen}{cmyk}{0.82,0.11,1,0.25}\n\n\\lstset{\n    language=matlab,\n    morekeywords={ifftshift,refreshdata},\n    keywordstyle=\\color{RoyalBlue},\n    basicstyle=\\scriptsize\\ttfamily,\n    % commentstyle=\\color{Emerald}\\scriptsize\\ttfamily,\n    commentstyle=\\color{myGreen}\\scriptsize\\ttfamily,\n%     directivestyle=\\color{Mauve}\\scriptsize\\ttfamily,\n    showspaces=false,            \n    showstringspaces=false,\n    stringstyle=\\color{Mauve}\\scriptsize\\ttfamily,\n    numbers=none,\n    numberstyle=\\scriptsize,\n    stepnumber=1,\n    numbersep=8pt,\n    showstringspaces=false,\n    breaklines=true,\n    frameround=ftff,\n    frame=lines,\n    backgroundcolor=\\color{LightGrey}\n} \n\\def\\inline{\\lstinline[basicstyle=\\ttfamily,keywordstyle={},directivestyle={}]}\n\n\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nWe consider a simple neural field model in which the state variable is dendritic\nvoltage, and in which somas form a continuous one-dimensional layer.\nThis \\textit{neural field} model with \\textit{dendritic processing} is formulated as\nan integro-differential equation. We introduce a\ncomputational method for approximating solutions to this nonlocal model, and use\nit to perform numerical simulations for neuro-biologically realistic choices of\nanatomical connectivity and nonlinear firing rate function.  For the time\ndiscretisation we adopt an Implicit-Explicit (IMEX) scheme; the space discretisation\nis based on a finite-difference scheme to approximate the diffusion term and uses the\ntrapezoidal rule to approximate integrals describing the nonlocal interactions in\nthe model. We prove that the scheme is of first-order in time and second order in\nspace, and can be efficiently implemented if the factorisation of a small, banded\nmatrix is precomputed. By way of validation we compare the outputs of a numerical\nrealisation to theoretical predictions for the onset of a Turing pattern, and to the\nspeed and shape of a travelling front for a specific choice of Heaviside firing rate.\nWe find that theory and numerical simulations are in excellent agreement.\n\n\\end{abstract}\n\n\\section{Introduction}\n\nEver since Hans Berger made the first recording of the human electroencephalogram\n(EEG) in 1924 there has been a tremendous interest in understanding the physiological\nbasis of brain rhythms. This has included the development of mathematical models of\ncortical tissue, which are often referred to as neural field models.  \nThe formulation of these models has not changed much since the seminal work of Wilson\nand Cowan, Nunez and Amari in the 1970s, as recently described in \\cite{Coombes2014}.\nNeural fields and neural mass models approximate neural activity assuming the\ncortical tissue is a continuous medium. They are coarse-grained spatiotemporal models,\nwhich lack important physiological mechanisms known to be fundamental in generating brain\nrhythms, such as dendritic structure and cortical folding. Nonetheless their basic\nstructure has been shown to provide a mechanistic starting point for understanding\nwhole brain dynamics, as described by Nunez \\cite{Nunez1995}, and especially that of\nthe EEG.\n\nModern biophysical theories assert that EEG signals from a single scalp\nelectrode arise from the coordinated activity of $\\sim 10^8$ pyramidal cells in the\ncortex.  These are arranged with their dendrites in parallel and perpendicular to the\ncortical surface. When activated by synapses at the proximal\ndendrites, extracellular current flows parallel to the dendrites, with a net\nmembrane current at the synapse. For excitatory (inhibitory) synapses this creates a\nsink (source) with a negative (positive) extracellular potential.  Because there is\nno accumulation of charge in the tissue the proximal synaptic current is compensated\nby other currents flowing in the medium causing a distributed source in the case of a\nsink and vice-versa for a synapse that acts as a source. Hence, at the population\nlevel the potential field generated by a synchronously activated population of\ncortical pyramidal cells behaves like that of a dipole layer.  Although the important\ncontribution that single dendritic trees make to generating extracellular electric\nfield potentials has been known for some time, and can be calculated using\nMaxwell's equations \\cite{Pettersen08}, they are often not accounted for in neural\nfield models.  However, with the advent of laminar electrodes to record from\ndifferent cortical layers it is now timely to build on early work by Crook and\ncoworkers \\cite{crook1997role} and by Bressloff, reviewed in \\cite{Bressloff97}, and develop neural field models that incorporate a\nnotion of dendritic depth.  This will allow a significant and important departure\nfrom present-day neural field models, and recognise the contribution of dendritic\nprocessing to macroscopic large-scale brain signals. A simple way to generalise\nstandard neural field models is to consider the dendritic cable model of Rall as the\ncore component in a neural field, with source terms on the cable mediating\nlong-range synaptic interactions.  These in turn can be described with the\nintroduction of an \\textit{axo-dendritic} connectivity function.\n\nHere we consider a neural field model which treats the voltage on a dendrite as the\nprimary variable of interest in a simple model of neural tissue. The model comprises\na continuum of somas (a \\emph{somatic layer}, see schematic in\nFigure~\\ref{fig:sketch}(a)). Dendrites are modeled as unbranched fibres,\northogonal to the somatic layer which, for simplicity, is one-dimensional and\nrectilinear (see Figure~\\ref{fig:sketch}(b)). At each point along the somatic layer\n$x \\in \\Rb$ we envisage a fibre with coordinate $\\xi \\in \\Rb$. The voltage dynamics\nalong the fibre is described by the cable equation, with a nonlocal input current\narising as\nan integral\nover the outputs from the somatic layer (where $\\xi=0$). Denoting the voltage by\n$V(x,\\xi,t)$ we have an integro-differential equation for the\nreal-valued function $V:  \\Rb^2 \\times \\Rb  \\rightarrow \\Rb$ of the form\n  \\begin{multline} \\label{1}\n  \\partial_t V(x,\\xi, t) = (-\\gamma + \\nu \\partial_{\\xi \\xi}) V(x,\\xi,t)\n                        + G(x,\\xi,t)\n\t\t\t\\\\\n  + \\int_{\\Rb^2} W(x,\\xi,y,\\eta) \n                        S(V(y,\\eta,t))\\diff y \\diff \\eta ,\n  \\end{multline}\nposed on $(x,\\xi,t) \\in \\Rb^3$, for some typically sigmoidal or\nHeaviside-type  firing rate function $S$, and some external input function $G$. Here\n$\\nu$ is the diffusion coefficient and $1/\\gamma$ the membrane time-constant of the\ncable. As we shall see below, it will be crucial for our analysis that currents flow\nexclusively along the fibres, that is, the diffusive term in \\eqref{1} contains\nderivatives only with respect to $\\xi$.\n\nThe model is completed with a choice of the generalised axo-dendritic connectivity\nfunction $W$. The nonlocal input current arises from the somatic layer, hence they\nare transferred from sources in an $\\ep$-neighbourhood of $\\xi = 0$, $0 < \\ep \\ll 1$, to \ncontact points in an $\\ep$-neighbourhood of $\\xi=\\xi_0$ on the cable (see\nFigure~\\ref{fig:sketch}(b)). In addition, the strength of interaction depends\nsolely on the distance between the source and the contact point, measured along the\nsomatic layer, leading to the decomposition\n\\begin{equation}\\label{eq:kernel}\n  W(x,\\xi,y, \\eta)=    w(|x-y|)\\delta_\\ep(\\xi-\\xi_0) \\delta_\\ep(\\eta),\n\\end{equation}\nwhere $w$ describes the strength of interaction across the somatic space and is\nchosen to be translationally invariant and $\\delta_\\ep$ is a quickly-decaying\nfunction. \n% supported on a compact interval $I_\\ep \\subset \\Rb$,\n% of $O(\\ep)$ measure, with $\\ep \\ll 1$.\n%Gaussian function with standard deviation $\\ep \\ll 1$. \n\n\\begin{figure}\n  \\centering\n  \\includegraphics{sketch}\n  \\caption{Schematic of the neural field model. (a) Dendrites are represented as\n    unbranched fibres (red), orthogonal to a continuum of somas (somatic layer, in\n    grey). (b) Model\n    \\eqref{1} is for a 1D somatic layer, with coordinate\n$x \\in \\Rb$, and fiber coordinate $\\xi \\in \\Rb$. Input currents are generated in a\nsmall neighbourhood of the somatic layer, at $\\xi=0$ and are delivered to a contact\npoint, in a small neighbourhood of $\\xi = \\xi_0$. The strength of interaction depends\non the distance between sources and contact points, measured along the somatic layer,\nhence the inputs that are generated at $A$ and transmitted to $B$, $C$, and $D$ depend\non $|x_B - x_A|$, $|x_C-x_A|$, and $|x_D - x_A|$, respectively (see\n\\eqref{eq:kernel}).}\n  \\label{fig:sketch}\n\\end{figure}\n\n%%%%%  Introduce state of art, relationship with other neural field models, applications\nThis work introduces a computational method for approximating\nsolutions to (\\ref{1}), subject to suitable initial and boundary conditions,\nand applies it to the numerical simulation of the model with kernel given by\n(\\ref{eq:kernel}). Numerical methods for neural fields in 2-dimensional media have\nbeen introduced recently in flat\ngeometries~\\cite{Rankin2014,hutt2014numerical,lima2015numerical} and on 2-manifolds\nembedded in a 3-dimensional space~\\cite{Bojak2010,Visser:2017hy}. In addition,\nseveral available open-source codes, such as the Neural Field\nSimulator~\\cite{Nichols2015}, the Brain Dynamics Toolbox~\\cite{Heitmann}, and\nNFTsim~\\cite{SanzLeon2018}, perform simulations of neural field equations. Numerical\nschemes for models of type~\\eqref{1} have not been introduced, analysed, or\nimplemented, and these are the main contributions of the present article.\n\nIn Section \\ref{Sec:numerical} we describe, analyse, and discuss implementation\ndetails of the numerical method. In Sections \\ref{sec:TWTest}--\\ref{sec:TuringTest}\nwe illustrate the performance of the method by means of some numerical experiments,\nincluding problems whose exact solution has known properties. The numerical results\nare discussed and their physical meaning is explained. We finish with some\nconclusions and discussion in Section \\ref{sec:conclusions}.\n\n\\section{Numerical Scheme}\n\\label{Sec:numerical}\nNumerical simulations are performed on \\eqref{1}, posed on a\nbounded, cylindrical somato-dendritic  domain \n\\[\n  \\Omega = \\Rb/2L_x\\Zb \\times (-L_\\xi,L_\\xi), %\\qquad L_x,L_\\xi \\gg 1,\n\\]\n%$\\Omega = (-L_x,L_x) \\times\n%(-L_\\xi,L_\\xi) \\cong\n%\\mathbb{S} \\times (-L_\\xi,L_\\xi) $\nand subject to initial and boundary conditions,\n\\begin{equation}\\label{eq:systemNum}\n  \\begin{aligned}\n    & \\partial_t V  = (-\\gamma + \\nu \\partial_{\\xi \\xi}) V + K(V) + G\n    % & & \\textrm{on $ (-L_x, L_x) \\times (-L_\\xi,L_\\xi) \\times (0,T]$}, \\\\\n    & & \\textrm{on $ \\Omega \\times (0,T]$}, \\\\\n  &  V(\\blank,\\blank,0)  = V_0\n    % & & \\textrm{on $(-L_x, L_x) \\times (-L_\\xi,L_\\xi)$}, \\\\\n    & & \\textrm{on $ \\Omega$}, \\\\\n  % &  \\partial_x V(-L_x,\\blank,\\blank) = \\partial_x V(L_x,\\blank,\\blank) = 0\n  %   & & \\textrm{on $ [-L_\\xi,L_\\xi] \\times [0,T]$}, \\\\\n  &  \\partial_\\xi V(\\blank,-L_\\xi,\\blank) = \\partial_\\xi V(\\blank,L_\\xi,\\blank) = 0\n    & & \\textrm{on $ (-L_x,L_x] \\times [0,T]$}, \\\\\n  \\end{aligned}\n\\end{equation}\nfor some positive constants $T$, $L_x$, $L_\\xi$. This setup implies\n$2L_x$-periodicity in the somatic\ndirection, and Neumann boundary conditions in the dendritic direction.\nWe denote by $K$ the integral operator defined by\n\\[\n  (K(V))(x,\\xi,t) = \\int_{\\Omega} W_{\\Omega}(x,\\xi,y,\\eta)\n    S(V(y,\\eta,t)) \\diff y \\diff \\eta,\n  \\qquad (x,\\xi) \\in \\Omega.\n\\]\nwhere $W_{\\Omega}$ is the restriction of $W$ on $\\Omega$. This restriction implies\nthat the function $w$ in \\eqref{eq:kernel} be substituted by\nits periodic extension on $[-L_x,L_x)$. In the remainder of this paper we will omit the\nsubscript $\\Omega$ from $W$, and assume $w$ to be $2L_x$-periodic.\n\nTo expose our scheme we introduce\na spatiotemporal discretisation \n%of the closed domain $\\bar{\\Omega} \\times [0,T]$, \nusing the evenly spaced grid \n$\\{(x_j,\\xi_i,t_n)\\}$ defined by\n\\[\n  \\begin{aligned}\n    & x_j = -L_x + j h_x, & & j \\in \\Nb_{n_x}, && h_x = 2L_x/n_x, \\\\\n    & \\xi_i   = -L_\\xi + (i-1) h_\\xi, & & i \\in \\Nb_{n_\\xi}, && h_\\xi =\n    2L_\\xi/(n_\\xi-1), \\\\\n    & t_n = n \\tau, & & n \\in \\Nb_{n_t}, && \\tau = T/n_t, \\\\\n  \\end{aligned}\n\\]\nwhere we posed $\\Nb_k = \\{1,2,\\ldots,k\\}$ for $k \\in \\Nb$. The scheme we propose uses\nthe method of lines for \\eqref{eq:systemNum}, in conjunction with differentiation\nmatrices for the diffusive term and a quadrature scheme for the integral operator. \n\n\n% In the description of the numerical scheme, it will be useful to alternate between\n% a matricial representation of the approximate values of $V(x,\\xi,t)$ at the\n% gridpoints, which will be denoted with a slight abuse\n% of notation as\n% \\[\n%   V(t) = \\{ V_{ij}(t) \\colon (i,j) \\in \\Nb_{n_x} \\times \\Nb_{n_\\xi} \\} \\in \\Rb^{n_x\n%   \\times n_\\xi}, \\qquad t \\in [0,T]\n% \\]\n% and the lexicographical representation of the same vector, obtained by ordering\n% gridpoints $\\{ (x_i,\\xi_j) \\}$\n% and components $\\{V_{ij}(t)\\}$ via a lexicographical mapping $k(i,j)$,\n% \\begin{equation}\\label{eq:uVec}\n%   U(t) = \\{ U_{k(i,j)} (t) = V_{k(i,j)}(t) \\colon  \n%   (i,j) \\in \\Nb_{n_x} \\times \\Nb_{n_\\xi} \\}\n%   \\in \\Rb^{n_xn_\\xi}, \\qquad t \\in [0,T]\n%   .\n% \\end{equation}\n%\nCollocating \\eqref{eq:systemNum} at the somato-dendritic nodes we obtain\n\\begin{equation}\\label{eq:collocation}\n  \\begin{split}\n    \\partial_t V(x_j,\\xi_i,t) = (-\\gamma + \\nu \\partial_{\\xi\\xi}) V(x_j,\\xi_i,t) \n   & + K(V)(x_j, \\xi_i,t) \\\\\n   & + G(x_j,\\xi_i,t) \\quad\n  (j,i) \\in \\Nb_{n_x} \\times \\Nb_{n_\\xi},\n  \\end{split}\n\\end{equation}\nwhere, with a slight abuse of notation, we denote by $V$ an interpolant to the\nfunction $V$ in \\eqref{eq:systemNum} through $\\{ (x_j,\\xi_i) \\}$.\n%\nTo obtain a numerical solution of the problem we\nmust choose: (i) an approximation for the linear operator $(-\\gamma + \\nu\n\\partial_{\\xi\\xi})$ at the somato-dendritic nodes; (ii) an approximation for the\nintegral operator at the same nodes; (iii) a scheme to time step the derived set of\nODEs. \n\nIn the presentation of the scheme, we shall use two equivalent representations for\nthe voltage approximation: a matricial description \n\\begin{equation}\\label{eq:VMatrix}\n  V(t) = \\{ V_{ij}(t) \n  \\colon (i,j) \\in \\Nb_{n_\\xi} \\times \\Nb_{n_x} \\} \n    \\in \\Rb^{n_\\xi \\times n_x}, \\qquad V_{ij}(t) \\approx\n  V(x_j,\\xi_i,t), \n\\end{equation}\nand a lexicographic vectorial representation, obtained by introducing the\nindex mapping $k(i,j) = n_\\xi(i-1) + j$,\n\\begin{equation}\\label{eq:VVector}\n  U(t) = \\{ U_{k(i,j)}(t) \\colon (i,j) \\in \\Nb_{n_\\xi} \\times \\Nb_{n_x} \\} \n  \\in \\Rb^{n_x n_\\xi}.\n\\end{equation}\nIn the latter, we will sometimes suppress the dependence of $k$ on $(i,j)$, for\nnotational convenience.\n\n\\subsection{Discretisation of the linear operator} A simple choice for discretising\nthe linear differential operator $(-\\gamma + \\nu \\partial_{\\xi \\xi})$ is to adopt\ndifferentiation matrices~\\cite{trefethen2000}. If a differentiation matrix\n$D_{\\xi \\xi} \\in \\Rb^{n_\\xi \\times n_\\xi}$ is chosen to approximate the action of\nthe Laplacian operator $\\partial_{\\xi \\xi}$ on twice differentiable, univariate\nfunctions defined on $[-L_\\xi,L_\\xi]$, satisfying Neumann boundary conditions, and\nsampled at nodes $\\{ \\xi_i \\}$, then the action of the operator $-\\gamma + \\nu\n\\partial_{\\xi\\xi}$ on bivariate functions defined on $[-L_x,L_x) \\times\n[-L_\\xi,L_\\xi]$, twice differentiable in $\\xi$ with Neumann boundary conditions,\nsampled at the nodes $\\{ (x_j,\\xi_i) \\}$ with lexicographical ordering $k(i,j)$ is\napproximated by the following block-diagonal matrix\n\\begin{equation*}\\label{eq:LinOp}\n  -\\gamma I_{n_x n_\\xi} + \\nu I_{n_x} \\otimes D_{\\xi \\xi} = \n  \\begin{bmatrix}\n    -\\gamma + \\nu D_{\\xi \\xi} &                          &        &               \\\\\n                             &-\\gamma + \\nu D_{\\xi \\xi} &        &               \\\\\n                             &                          & \\ddots &               \\\\\n                             &                          &        &-\\gamma + \\nu D_{\\xi \\xi}     \\end{bmatrix}\n  ,\n\\end{equation*}\nwhere $I_n$, $n \\in \\Nb$, is the $n$-by-$n$ identity matrix, and $\\otimes$ is the\nKronecker product between matrices. Since the model prescribes diffusion only along\nthe dendritic coordinate, the\ncorresponding matrix has a block-diagonal structure \\emph{with identical blocks},\nwhich can be exploited to improve performance in numerical computations. The sparsity pattern of a block is dictated by the\nunderlying scheme to approximate the univariate Laplacian: we have full blocks if\n$D_{\\xi\\xi}$ is derived from spectral schemes, and sparse blocks\nfor finite-difference schemes. \n\n\\subsection{Discretisation of the nonlinear integral operator} The starting point to\ndiscretise the integral operator is an $m$th order quadrature formula with $q_m$\nnodes $\\{ (y_l,\\eta_l) \\colon l \\in \\Nb_{q_m} \\}$ and weights $\\{ \\sigma_l \\colon l\n\\in \\Nb_{q_m} \\}$ for the integral of a bivariate function over $\\Omega$,\n\\[\nQ(v)=\\int_{\\Omega} v(y,\\eta) \\, \\diff y  \\diff \\eta \\approx\n\\sum_{l \\in \\Nb_m} v(y_l,\\eta_l) \\sigma_l = Q_m(v).\n\\]\nUsing this formula we approximate the nonlinear operator in \\eqref{eq:collocation} by\n\\[\n  Q_m(K(V))(x_j,\\xi_i,t) = \\sum_{l \\in \\Nb{q_m}} W(x_j,\\xi_i,y_l,\\eta_l)\n  S(V(y_l,\\eta_l,t)) \\sigma_l .\n\\]\n\nWe stress that, in general, the quadrature nodes $\\{ (y_l,\\eta_l) \\}$ and the\ncollocation nodes $\\{ (x_{k(i,j)}, \\xi_{k(i,j)}) \\}$ are disjoint. The former are\nchosen so as to approximate accurately the integral term, the latter to approximate\nthe differential operator. When the two grids are disjoint, an interpolation of $V$ with\nnodes $\\{ (y_l,\\eta_l) \\}$ is necessary to derive a set of ODEs at the collocation\nnodes. In the remainder of this paper we will assume that collocation and quadrature\nnodes coincide, so that we can omit the interpolant, for simplicity.\n\n\\subsection{Matrix ODE formulation}\nCombining the differentiation matrix, the quadrature rule, and the lexicographic\nrepresentation \\eqref{eq:VVector}\nwe obtain a set of $n_x n_\\xi$ ODEs\n\\begin{equation}\\label{eq:ODEs}\n  \\begin{aligned}\n    \\dot U(t) & = (-\\gamma I_{n_x n_\\xi} + \\nu I_{n_x} \\otimes D_{\\xi \\xi} ) U(t) +\n  F(U(t),t), \\\\\n  U(0) & = U_0.\n  \\end{aligned}\n\\end{equation}\nThe structure of the differentiation matrix in section \\eqref{eq:LinOp}, however,\nsuggests a rewriting of \\eqref{eq:ODEs} in terms of the blocks of the linear\noperator, which correspond to ``slices\" at constant values of $x$: we recall the\nmatrix representation \\eqref{eq:VMatrix} and obtain an equivalent\nmatrix ODE formulation\n\\begin{equation}\\label{eq:MatrixODE}\n  \\dot V(t) = (-\\gamma I_{n_\\xi} + \\nu D_{\\xi \\xi}) V(t) + N(V(t)) + G(t),\n\\end{equation}\nwhere $N$ is the matrix-valued function with components $N_{ij}(V) =\nQ_m(V)(x_j,\\xi_i)$ and $G$ is the matrix with components $G(x_j,\\xi_i,t)$. In passing,\nwe note that the linear part of the equation involves\na multiplication between an $n_\\xi$-by-$n_\\xi$ matrix and the $n_\\xi$-by-$n_x$ matrix $V$. \n\n\\subsection{Time-stepping scheme} The proposed time-stepping scheme for\n\\eqref{eq:systemNum} is obtained from \\eqref{eq:MatrixODE} with the following\nchoices: (i) a first-order, implicit-explicit (IMEX) time-stepping\nscheme~\\cite{ascher1995}; (ii) a second-order, centered finite-difference\nscheme for the differentiation matrix $D_{\\xi \\xi}$; (ii) a second-order trapezium\nrule for the quadrature rule $Q_m$. As we shall see, these choices bring\na few computational advantages, which will be outlined below. \n\nIMEX schemes treat the linear (diffusive) part of the ODE implicitly, and the\nnonlinear part explicitly, so that the stiff diffusive term is integrated implicitly\nto avoid excessively small time steps. The simplest IMEX method uses backward Euler\nfor the diffusive term, leading to\n\\begin{equation}\\label{eq:IMEX}\n  \\begin{aligned}\n       V^0 & = V_0, \\\\\n       A V^n & = V^{n-1} + \\tau N(V^{n-1}) + \\tau G^{n-1}, \\qquad n \\in \\Nb,\n  \\end{aligned}\n\\end{equation}\nwhere $V^n \\approx V(t_n)$, $G^n = G(t_n)$, and $A$ is the matrix\n\\begin{equation}\\label{eq:AMatr}\n  A = (1+\\gamma \\tau) I_{n_\\xi} - \\tau \\nu D_{\\xi \\xi}.\n\\end{equation}\nIn concrete calculations we use second-order centred finite differences, leading to\n\\begin{equation}\\label{eq:FinDiffLapl}\n  D_{\\xi \\xi} = \n   \\Delta/h_\\xi^{2}, \\qquad \\Delta = \n  \\begin{bmatrix}\n    -2 &  2     &         &        &    &     \\\\\n     1 & -2     &       1 &        &    &     \\\\\n       & \\ddots & \\ddots & \\ddots  &    &     \\\\\n       &        &      1 &      -2 & 1  &     \\\\\n       &        &        &       2 & -2 &  \n   \\end{bmatrix},\n \\end{equation}\nin which Neumann boundary conditions are included in the differentiation matrix. \n% This\n% leads to $A$ being tridiagonal, and strictly diagonally dominant \\da{Decide what to\n% say about positive-definiteness}. \\da{Pedro, please amend your eigenvalue\n%   computations/spectral radii to the new matrix, which has Neuamnn BCs. The substance\n% does not change, but the eigenvalues have a slightly different expression with\n% Neumann BCs.}\n\nFinally, we discuss the choice of the quadrature scheme. We use a composite trapezium\nscheme with nodes $\\{x_j\\}$ and weights $\\{\\rho_j\\}$ in $x$, and nodes $\\{\\xi_i\\}$\nand weights $\\{ \\sigma_i\\}$ in $\\xi$, respectively, hence quadrature and collocation\nsets coincide,\n\\begin{equation} \\label{eq:NQuad}\n  N_{ij}(V) = \\sum_{j' \\in \\Nb{n_x}} \\sum_{i' \\in \\Nb{n_\\xi}}\n  W(x_j,\\xi_i,x_{j'},\\xi_{i'}) S(V_{i',j'}) \\rho_{j'}\\sigma_{i'}.\n  \\quad (i,j) \\in \\Nb_{n_\\xi} \\times \\Nb_{n_x}.\n\\end{equation}\n\n\\subsection{Properties of the IMEX scheme}\nIn this section we collect some analytical results on the IMEX scheme\n\\eqref{eq:IMEX}--\\eqref{eq:NQuad}. We work with spaces of sufficiently regular\ncontinuous functions, which provides the simplest setting for our results. We denote\nby $C^k(D)$ the space of $k$-times continuously differentiable functions from $D$ to\n$\\Rb$, where $k$ is an integer, $D$ a domain in $\\Rb^3$. We also indicate\nby $C_b^k(D)$ the space of continuous functions from $D$ to $\\Rb$ with bounded and\ncontinuous partial derivatives up to order $k$. \nBoth spaces are endowed with the infinity norm $\\Vert \\blank\n\\Vert_\\infty$. We will use the symbol $| \\blank |_\\infty$ for the standard\ninfinity-norm on matrices, induced by the corresponding vector norm. In addition, we\nwill denote by $\\bar D$ the closure of $D$.\n\nWe begin with a generic assumption of boundedness on the functions in\n\\eqref{eq:systemNum}:\n\\begin{hypothesis}\\label{hyp:boundedness}\n  There exist $C_W, C_S, C_G >0 $ such that\n  \\[\n    |W| \\leq C_W \\; \\textrm{in $\\Omega \\times \\Omega$},\n    \\qquad\n    |S| \\leq C_S \\; \\textrm{in $\\Rb$},\n    \\qquad\n    |G| \\leq C_G \\; \\textrm{in $\\Omega \\times \\Rb$}.\n  \\]\n\\end{hypothesis}\n\n\\begin{lemma}[Boundedness of IMEX solution]\\label{lem:IMEXboundedness} \n  Assume Hypothesis \\ref{hyp:boundedness}, then there exists a unique bounded\n  sequence $(V^n)_{n\\in\\Nb}$ satisfying\n  the IMEX scheme \\eqref{eq:IMEX}--\\eqref{eq:NQuad}. In\n  addition, the following bound holds\n  \\[\n    \\vert V^n \\vert_\\infty \\leq \\vert V^0 \\vert_\\infty + \n    n_x \\frac{ \\mu(\\bar\\Omega) C_W C_S + C_G}{\\gamma},\n    \\qquad n \\in \\Nb.\n  \\]\n\\end{lemma}\n\\begin{proof}\n  The matrix $A$ in \\eqref{eq:AMatr} has real, strictly positive eigenvalues given\n  by\n  \\[\n    \\lambda_k = 1 + \\gamma \\tau + \\frac{4\\nu \\tau}{h_\\xi^2} \n    \\bigg[ \\sin \\bigg( \\frac{\\pi(k-1)}{2n_\\xi} \\bigg) \\bigg]^2, \\qquad k \\in\n    \\Nb_{n_\\xi},\n  \\]\n  where we have used the fact that the eigenvalues of $D_{\\xi \\xi}$ are known in closed form.\n  We conclude that $A$ is invertible, hence for any fixed $n \\in \\Nb$,\n  the matrix $V^n$ solving \\eqref{eq:IMEX} is unique. In addition, $A$ is\n  strictly diagonally dominant, hence the following bound holds~\\cite{varah75}\n  \\begin{equation}\\label{eq:invABound}\n  \\vert A^{-1} \\vert_\\infty \\leq \\max_{i \\in \\Nb_\\xi} \\frac{1}{|A_{ii}| - \\sum_{j\n  \\neq i} |A_{ij}|} = \\frac{1}{1+ \\gamma \\tau}.\n  \\end{equation}\n  To prove boundedness of the sequence $(V^n)_{n \\in \\Nb}$ we first bound the\n  matrices $N(V^{n-1})$, $G^n$ appearing in \\eqref{eq:IMEX}\n  \\[\n    \\begin{aligned}\n    \\vert N(V^{n-1}) \\vert_\\infty \n    & = \\max_{i \\in \\Nb_{n_\\xi}} \\sum_{j \\in \\Nb_{n_x}} |N_{ij}(V^{n-1})| \\\\\n    & \\leq\n    \\max_{i \\in \\Nb_{n_\\xi}} \\sum_{j \\in \\Nb_{n_x}} \n                             \\sum_{j' \\in \\Nb{n_x}} \\sum_{i' \\in \\Nb{n_\\xi}}\n                              |W(x_j,\\xi_i,x_{j'},\\xi_{i'}) S(V_{i',j'}) \\rho_{j'}\\sigma_{i'}| \\\\\n    & \\leq C_W C_S\n    \\max_{i \\in \\Nb_{n_\\xi}} \\sum_{j \\in \\Nb_{n_x}} \n                   \\sum_{j' \\in \\Nb{n_x}} \\sum_{i' \\in \\Nb{n_\\xi}}\n\t\t  \\rho_{j'}\\sigma_{i'} \\\\\n    & \\leq C_W C_S\n    \\max_{i \\in \\Nb_{n_\\xi}} \\sum_{j \\in \\Nb_{n_x}} \\mu(\\bar\\Omega)\n    = n_x \\mu(\\bar\\Omega) C_W C_S,\n    \\end{aligned},\n  \\]\n  and similarly $\\vert G^{n-1} \\vert_\\infty \\leq n_x C_G$, and then combine\n  them with the bound for $\\vert A^{-1}\\vert_\\infty$ to find\n  \\[\n    \\begin{aligned}\n    \\vert V^n \\vert_\\infty \n        & \\leq \\vert A^{-1} \\vert_\\infty \n\t  \\Big(\n\t      \\vert V^{n-1} \\vert_\\infty \n\t    + \\tau \\vert N(V^{n-1}) \\vert_\\infty\n\t    + \\tau \\vert G^{n-1} \\vert_\\infty \n\t  \\Big) \\\\\n% \t& \\leq \\Vert A^{-1} \\Vert_\\infty \n% \t  \\Big(\n% \t      \\Vert V_i^{n-1} \\Vert_\\infty \n% \t      + \\tau n_x |\\Omega| \\Vert w \\Vert_\\infty \\Vert S \\Vert_\\infty \n% \t      + \\tau n_x \\Vert G \\Vert_\\infty\n% \t  \\Big) \\\\\n\t& \\leq \\frac{1}{1+\\gamma \\tau}\n\t  \\Big(\n\t      \\vert V^{n-1} \\vert_\\infty \n\t      + \\tau n_x \\mu(\\bar\\Omega) C_W C_S \n\t      + \\tau n_x C_G\n\t  \\Big).\n    \\end{aligned}\n    % \\quad (i,n) \\in \\Nb_{n_x} \\times \\Nb\n  \\]\n  We set\n  \\[\n    r = \\frac{1}{1+\\gamma \\tau} <1, \\qquad \n    q = \\frac{\\tau n_x}{1 + \\gamma \\tau}\n      ( \\mu(\\bar\\Omega) C_W C_S + C_G),\n  \\]\n  and use induction and elementary properties of the geometric series to obtain\n  \\[\n    \\vert V^n \\vert_\\infty \\leq r^n \\vert V^0 \\vert_\\infty + q \\sum_{j =0}^{n-1} r^j\n      \\leq \\vert V^0 \\vert_\\infty + \\frac{q}{1-r},\n  \\]\n  which proves the assertion.\n\\end{proof}\n\nIn addition to proving boundedness of the solution, we address the\nconvergence rate of the IMEX scheme. For this result, we assume the existence of a\nsufficiently regular solution to \\eqref{eq:systemNum}.\n\n\\begin{lemma}[Local convergence rate of the IMEX scheme]\\label{lem:IMEXconvergence}\n  Assume Hypothesis \\ref{hyp:boundedness}, $W \\in C^2(\\Omega \\times \\Omega)$, $S\n  \\in C^2_b(\\Omega)$, and assume \\eqref{eq:systemNum}\n  admits a strong solution $V_*$ \n  whose partial derivatives $\\partial_{tt}V_*$, $\\partial_{xx}V_*$,\n  $\\partial_{x\\xi}V_*$, $\\partial_{\\xi\\xi}V_*$, $\\partial_{\\xi\\xi\\xi\\xi}V_*$\n  exist and are bounded on $\\bar \\Omega \\times [0,T]$. Denote \n  by $V^n_*$ the matrix with elements $(V_*^n)_{ij} =\n  V_*(x_j,\\xi_i,t_n)$, for $(i,j,n) \\in \\Nb_{n_x} \\times \\Nb_{n_\\xi} \\times \\Nb_{n_t}$. \n  Further, let $(V^n)_{n \\in \\Nb}$ be the solution to the IMEX scheme\n  \\eqref{eq:IMEX}--\\eqref{eq:NQuad}, and let\n  \\[\n    \\zeta = n_x \\mu(\\bar\\Omega) \\Vert W \\Vert_\\infty \\Vert S' \\Vert_\\infty, \n  \\qquad\n  h = \\max(h_\\xi, h_x).\n  \\]\n  There exist constants $C_\\tau, C_h >0$ such that\n  \\begin{align}\n     & |V^n - V_*^n|_\\infty \\leq \\frac{1}{\\gamma -\\zeta}(C_\\tau \\tau + C_h h^2) \n\t  & \\text{if $\\zeta < \\gamma$} \\label{eq:bound1}, \\\\\n     & |V^n - V_*^n|_\\infty \\leq \\frac{T}{1+ \\gamma \\tau} (C_\\tau \\tau + C_h h^2)\n\t  & \\text{if $\\zeta = \\gamma$} \\label{eq:bound2}, \\\\\n     & |V^n - V_*^n|_\\infty \\leq \n     \\frac{C_\\tau \\tau + C_h h^2}{\\zeta - \\gamma} \\exp \n     \\frac{(\\zeta - \\gamma) T}{1+\\gamma \\tau}\n          & \\text{if $\\zeta > \\gamma$} \\label{eq:bound3}.\n  \\end{align}\n\\end{lemma}\n\\begin{proof}\n  The regularity assumptions on $V_*$, and standard results on finite-difference\n  approximation and trapezium quadrature rule guarantee the existence of constants\n  $C_{tt},C_{xx},C_{\\xi\\xi},C_{\\xi\\xi\\xi\\xi} > 0$ such that for all $n \\in \\{0 \\}\n  \\cup \\Nb_{n_t}$\n  \\begin{equation}\\label{eq:IMEXExact}\n    AV_*^n = V_*^{n-1} + \\tau \\big( N(V_*^{n-1}) + G^{n-1} +  \n\tC_{tt} \\tau + C_{\\xi\\xi\\xi\\xi}h^2_\\xi + C_{xx}h_x^2 + C_{\\xi\\xi}h_\\xi^2\n    \\big),\n  \\end{equation}\n  where the errors for the forward finite-difference in $t$, centred finite-difference\n  in $\\xi$, and trapezium rule are listed progressively, with constants proportional\n  to the respective partial derivatives. We subtract \\eqref{eq:IMEXExact} from\n  \\[\n    AV^n = V^{n-1} + \\tau N(V^{n-1}) + \\tau G^{n-1}, %\\qquad n \\in \\Nb_{n_t}\n  \\]\n  and obtain the error bound\n  \\begin{equation}\\label{eq:intermediateBound}\n    |V - V_*^n|_\\infty \\leq |A^{-1}|_\\infty \\big(|V - V_*^n|_\\infty + \\tau |N(V^n) -\n    N(V_*^n)|_\\infty + \\tau \\omega \\big),\n  \\end{equation}\n  % \\[\n    % E^n = |V^n - V_*^n|_\\infty, \\qquad \\ep = C_\\tau \\tau + C_h h^2$\n  % \\]\n  where $\\omega = C_\\tau \\tau + C_h h^2$, $C_\\tau = C_{tt}$, $C_h =\n  \\max(C_{xx},C_{\\xi\\xi},C_{\\xi\\xi\\xi\\xi})$, and\n  $h = \\max(h_\\xi,h_x)$. \n  %$C_h = \\max(C_{xx},C_{\\xi\\xi},C_{\\xi\\xi\\xi\\xi})$. \n  Since the first derivative $S'$ of $S$ is bounded, we have the following estimate\n  for the nonlinear term\n  \\[\n    \\begin{aligned}\n    |N(V^{n}) - N(V_*^n)|_\\infty  \n    & \\leq\n    \\Vert W \\Vert_\\infty\n    \\Vert S' \\Vert_\\infty\n    \\max_{i \\in \\Nb_{n_\\xi}} \\sum_{j \\in \\Nb_{n_x}} \n\t       \\sum_{j' \\in \\Nb{n_x}} \\sum_{i' \\in \\Nb{n_\\xi}}\n\t       |V^n_{i'j'}-(V_*^n)_{i'j'}|\\rho_{j'}\\sigma_{i'} \\\\\n    & \\leq\n    n_x \\mu(\\bar \\Omega)\n    \\Vert W \\Vert_\\infty\n    \\Vert S' \\Vert_\\infty\n    \\vert V^n - V_*^n \\vert_\\infty \\\\\n    &\n    = \\zeta \\vert V^n - V_*^n \\vert_\\infty ,\n    \\end{aligned}\n  \\]\n  which, together with \\eqref{eq:invABound} and \\eqref{eq:intermediateBound} gives a\n  recursive bound for the $\\infty$-norm matrix error $E^n = |V^n-V_*^n|_\\infty$,\n  \\[\n    E^0 = 0, \\qquad\n    E^n \\leq \\frac{1+\\zeta \\tau}{1+\\gamma \\tau}E^{n-1} + \\frac{\\tau \\omega}{1 + \\gamma\n    \\tau} := r E^{n-1} + q.\n    \\qquad n \\in \\Nb_{n_t}.\n  \\]\n  Hence,\n  \\begin{equation}\\label{eq:intermediateBound2}\n    E^n \\leq q \\frac{r^n - 1}{r-1}, \\quad r \\neq 1,\n    \\qquad E^n \\leq n q \\quad r = 1,\n    \\qquad\n    n \\in \\Nb_{n_t}.\n  \\end{equation}\n  If $ \\zeta < \\gamma$, then $r < 1$, and we obtain \\eqref{eq:bound1} as\n  \\[\n    E^n \\leq \n   \\frac{q}{1-r} = \\frac{\\omega}{\\gamma - \\zeta} = \\frac{1}{\\gamma -\\zeta}(C_\\tau\n    \\tau + C_h h^2),\n    \\qquad n \\in \\Nb_{n_t}.\n  \\]\n%\n  If $\\zeta = \\gamma$, then $r = 1$ and \\eqref{eq:bound2} is found as follows\n  \\[\n    E^n \\leq n q \n    \\leq \\frac{n_t\\tau \\omega}{1 + \\gamma\\tau}%(C_\\tau \\tau + C_h h^2) \n    = \\frac{T}{1 + \\gamma\\tau}(C_\\tau \\tau + C_h h^2),\n    \\qquad n \\in \\Nb_{n_t}.\n  \\]\n%\n  If $\\zeta > \\gamma$, then $r > 1$ and we can bound the $n$th term of the sequence\n  with an exponential, using the bound $(1+x/n)^n \\leq \\e^x$ for all $x \\in \\Rb$, as\n  follows,\n  \\[\n    r^n = \n    \\bigg(\n      1 + \\frac{(\\zeta - \\gamma) n \\tau}{n(1+\\gamma \\tau)}\n    \\bigg)^n\n    \\leq\n    \\exp \\frac{(\\zeta - \\gamma) n \\tau}{1+\\gamma \\tau}\n    \\leq\n    \\exp \\frac{(\\zeta - \\gamma) T}{1+\\gamma \\tau},\n  \\]\n  which combined with \\eqref{eq:intermediateBound2} gives \\eqref{eq:bound3}:\n  \\[\n    E^n \\leq \\frac{\\omega}{\\zeta - \\gamma} \\exp \\frac{(\\zeta - \\gamma) T}{1+\\gamma \\tau}\n     = \\frac{C_\\tau \\tau + C_h h^2}{\\zeta - \\gamma} \\exp \\frac{(\\zeta - \\gamma)\n     T}{1+\\gamma \\tau}.\n  \\]\n\\end{proof}\n\nThe preceding lemma shows that the IMEX scheme has first order convergence in time,\nand second order convergence in space. As expected, this conclusion holds without\nimposing any restriction to the size of $\\tau$ in relation to $h$, as happens, for\nexample, in the case of explicit methods for parabolic equations. In passing we note\nthat if $\\zeta < \\gamma$ and $V_*(t)$ exists for all $t \\in \\Rb$, the error estimate\n\\eqref{eq:bound1} holds for $n \\in \\Nb$, that is, in an unbounded interval of time;\non the other hand, the error estimates do not hold on an unbounded time interval when\n$\\zeta \\geq \\gamma$, as the bounds depend on $T$.\n\n\\subsection{Implementational aspects and efficiency}\n\n\nIn this section we make a few considerations on the implementation of the proposed\nIMEX scheme, with the view of comparing its efficiency to an ordinary IMEX scheme,\nthat is, to an IMEX scheme applied to \\eqref{eq:ODEs}.\n\n\\subsubsection{Implementation}\nIMEX schemes for planar semilinear problems require the inversion of a\ndiscretised Laplacian, which usually is a square matrix with the same dimension of\nthe problem ($n_\\xi n_x$ equations in our case). The particular structure of the\nproblem under consideration, however, implies that the matrix to be inverted is much\nsmaller (the square matrix $A$ has only $n_\\xi$ rows and $n_\\xi$ columns). At each\ntime step\n\\eqref{eq:IMEX} we solve a problem of the type $AX=B$, where $A \\in \\Rb^{n_\\xi \\times\nn_\\xi}$, and $X, B \\in \\Rb^{n_\\xi \\times n_x}$. This can be achieved efficiently by\npre-computing a factorisation of $A$, and then back-substituting for all\ncolumns of $B$. Since the matrix $A$ is sparse and with low bandwidth, efficient\nimplementations of the $LU$ decompositions and backsubstitution can be used to solve\nthe $n_x$ linear problems corresponding to the columns of $X$ and $B$.\n\nAn important aspect of the numerical implementation is the evaluation of the\nnonlinear term \\eqref{eq:NQuad}: evaluating the right-hand side of\n\\eqref{eq:IMEX} requires in general $O(n^2_\\xi n^2_x)$ operations, which is a\nbottleneck for the time stepper, in particular for large domains. However, the\nstructure of the problem can be exploited once again to evaluate this term\nefficiently. We make use of the following properties: \n\\begin{enumerate}\n  \\item The kernel $W$ specified in \\eqref{eq:kernel} has a product structure,\n    hence\n    \\[\n      W(x_j,\\xi_i,x_{j'},\\xi_{i'}) = \\alpha_i \\alpha'_{i'}\n      w(|x_j-x_{j'}|). \n    \\]\n    where $\\alpha_i = \\delta_\\ep(\\xi_i-\\xi_0)$, $\\alpha'_{i'} = \\delta_\\ep(\\xi_{i'})$.\n    In addition, $w$ is periodic, therefore the matrix with entries $w(|x_j -\n    x_{j'}|)$ is circulant with (rotating) row vector $w \n    = \\{w(|x_j|) \\colon j \\in \\Nb_{n_x}\\}  \\in \\Rb^{1 \\times n_x}$.\n   \\item The function $x \\mapsto V(x,\\blank)$ is $2L_x$-periodic, hence the trapezium\n     rule has identical weights $\\rho_j = h_x$, and the integration\n     in $x$ is a circular convolution, which can be performed efficiently in $O(n_x\n     \\log n_x)$ operations, using the Discrete Fourier Transform (DFT).\n\\end{enumerate}\nWe have\n%Owing to these properties we obtain \n\\begin{equation}\\label{eq:NSlow}\n  N_{ij}(V) = \\alpha_i \\sum_{j' \\in \\Nb_{n_x}} w_{j-j'} \\rho_{j'}\n  \\sum_{i' \\in \\Nb_{n_\\xi}} \\alpha'_{i'} \\sigma_{i'} S(V_{i'j'})\n  \\qquad\n  (i,j) \\in \\Nb_{n_\\xi} \\times \\Nb_{n_x},\n\\end{equation}\nand a DFT can be used to perform the outer\nsums~\\cite{coombes2012interface,Rankin2014}.\nIntroducing the direct, $\\cF_n$, and inverse, $\\cF_n^{-1}$, DFTs for $n$-vectors, we express compactly the nonzero elements of $N$ as\nfollows\n\\begin{equation}\\label{eq:NFast}\n  N = \\alpha h_x \\cF^{-1}_{n_x} \n   \\big[\n     \\cF_{n_x}[w] \\odot  \\cF_{n_x}[ (\\alpha' \\odot \\sigma)^T S(V)]\n   \\big],\n\\end{equation}\nwhere $\\alpha, \\alpha', \\sigma \\in \\Rb^{n_\\xi \\times 1}$\nare column vectors, and $\\odot$ denotes the Hadamard product, that is, elementwise\nvector multiplication. The formula above evaluates the\nnonlinear term $N$ in just \n% $(2|\\Ib| + |\\Ib'|)n_x + O(n_x \\log n_x) = O(n_x + n_x\\log\n% n_x)$ operations. We remark that, if the\n% $\\delta_\\ep$ is supported in $[-L_{\\xi},L_{\\xi}]$, that is, $\\ep = L_\\xi$, one can\n% still use the formula above, which holds for $\\Ib = \\Ib' = \\Nb_{n_\\xi}$ and evaluates\n$O(n_xn_\\xi) + O(n_x \\log n_x)$ operations.\n\n\nWe summarise our implementation with the pseudocode provided in Algorithm\n\\ref{alg:smart}, and we will henceforth compare quantitatively its efficiency with\na standard IMEX implementation, which we also provide in Algorithm \\ref{alg:naive}. The\nmatricial version, Algorithm \\ref{alg:smart} exposes row- and column-vectors, for\nwhich a very compact Matlab implementation can be derived. We give an example of such\nimplementation in Appendix~\\ref{sec:matlab}, and we refer the reader to\n\\cite{avitabile2020neuralcodes} \nfor a repository of codes used in this article.\n\n\\subsubsection{Efficiency estimates}\n\nWe now make a few considerations about the efficiency of our algorithm. We will provide\ntwo main measures of efficiency: an estimate of the floating point operations (flops),\nand an estimate of the storage space (in floating point numbers) required by the\nalgorithm, as a function of the input data which, in our case, are the number of\ngridpoints in each direction, $n_x$ and $n_\\xi$. We are  interested\nin how the estimates scale for large $n_x, n_\\xi$.\n\nTo estimate the number of flops, we count the number of operations required by\nAlgorithms~\\ref{alg:smart} and \\ref{alg:naive} in the initialisation step (lines 2--6), and\nin a single time step (lines 8--12). We base our estimates on the following\nfacts and hypotheses:\n\\begin{enumerate}\n  \\item The cost of multiplying an $m$-by-$n$ matrix by an $n$-vector is $2mn - m$\n    flops.\n  \\item If an $n$-by-$n$ matrix is tridiagonal, then the matrices $L$ and $U$ of its\n    $LU$-factorisation are bidiagonal, and $L$ has $1$ along its main diagonal.\n    This implies that storing the $LU$ factorisation requires only $3$\n    $n$-vectors. Calculating the $LU$ factorisation costs $2n + 1$ flops, while\n    solving the corresponding linear problem $LUx = b$, with $x,b \\in \\Rb^n$,\n    requires $2n-2$ and $3n-2$ flops for the forward- and backward-subsitution,\n    respectively. Similar considerations apply if $A$ is not tridiagonal, but still\n    sparse, as it would be obtained using a different discretisation method for the\n    diffusive operator: estimates for the flops of the corresponding\n    $PLU$-factorisation depend, in general, on the sparsity pattern of $A$, as well\n    as on the permutation strategy, which is heuristic but can have an impact on the\n    sparsity of $L$ and $U$, thereby influencing the performance of the algorithm.\n    We present calculations only in the case of a tridiagonal matrix $A$, for which\n    explicit estimates are possible.\n\n  \\item As stated above, it is well known that a single FFT of an $n$-vector costs\n    $O(n \\log n)$ operations.\n\n  \\item We assume that function evaluations of the functions $G$, $S$, $w$, $\\delta$\n    cost one flop. This estimate is optimistic, as most function evaluations will\n    require more than one flop, but we make this simplifying assumption for both the\n    algorithms we are comparing.\n\\end{enumerate}\n\n\\begin{algorithm}\n  \\caption{IMEX time stepper in matrix form \\eqref{eq:MatrixODE}, nonlinear term\n  computed with pseudospectral evaluation \\eqref{eq:NFast}}\n  \\label{alg:smart}\n\\DontPrintSemicolon\n\\SetAlgoNoLine\n\\SetKwInOut{Input}{Input}\n\\SetKwInOut{Output}{Output}\n% \\SetKwSty{textrm}\n% \\SetNlSty{textrm}{}{}\n\n\\Input{Initial condition $V^0 \\in \\Rb^{n_\\xi \\times n_x}$, time step $\\tau$, number of steps $n_t$.}\n\\Output{An approximate solution $(V^n)_{n=1}^{n_t} \\subset \\Rb^{n_\\xi \\times n_x}$}\n\\Begin{\n  Compute grid vectors $\\xi \\in \\Rb^{n_\\xi \\times 1}$, $x \\in \\Rb^{1 \\times n_x}$. \\;\n  Compute synaptic vectors $w, \\hat w = \\mathcal{F}_{n_x}[w] \\in \\Rb^{1 \\times n_x}$.\\;\n  Compute synaptic vectors $\\alpha, \\alpha' \\in \\Rb^{n_\\xi \\times 1}$. \\;\n  Compute quadrature weights $\\sigma \\in \\Rb^{n_\\xi \\times 1}$.  \\;\n  Compute sparse $LU$-factorisation of $A$, \n  \\[\n    LU=A \\in \\Rb^{n_\\xi \\times n_\\xi}.\n  \\]\\;\n  \\For{$n = 1,\\ldots,n_t$}{\n    Set $V = V^{n-1} \\in \\Rb^{n_\\xi \\times n_x} $. \\;\n    Compute the external input at time $t_{n-1}$ and store it in $G \\in \\Rb^{n_\\xi \\times n_x}$.\\;\n    Set $z = \\cF_{n_x}\\big[(\\alpha' \\odot \\sigma)^T S(V)\\big] \\in \\Rb^{1 \\times n_x} $.\\;\n    Set $N =  h_x \\alpha \\cF^{-1}_{n_x} [ \\hat w \\odot  z] \\in \\Rb^{n_\\xi \\times n_x}$.\\;\n    Solve for $V^{n}$ the linear problem $(LU)V^n = V + \\tau(N+G)$.\n  }\n}\n\\end{algorithm}\n\n\\begin{algorithm}\n\\caption{IMEX time stepper in vector form \\eqref{eq:ODEs}, nonlinear term evaluated with\nquadrature formula \\eqref{eq:NQuad}.}\n\\label{alg:naive}\n\\SetAlgoNoLine\n\\DontPrintSemicolon\n\\SetKwInOut{Input}{Input}\n\\SetKwInOut{Output}{Output}\n\n\\Input{Initial condition $U^0 \\in \\Rb^{n_\\xi n_x}$, time step $\\tau$, number of steps $n_t$.}\n\\Output{An approximate solution $(U^n)_{n=1}^{n_t} \\subset \\Rb^{n_\\xi n_x}$}\n\\Begin{\n\\BlankLine\n  Compute grid vectors $\\xi \\in \\Rb^{n_\\xi}$, $x \\in \\Rb^{n_x}$. \\;\n  Compute synaptic vector $w \\in \\Rb^{1 \\times n_x}$.\\;\n  Compute synaptic vectors $\\alpha, \\alpha' \\in \\Rb^{n_\\xi \\times 1}$. \\;\n  Compute quadrature weights $\\rho \\in \\Rb^{n_x}$, $\\sigma \\in \\Rb^{n_\\xi}$.  \\;\n  Compute sparse $LU$-factorisation %of \n  %$-\\gamma I_{n_x n_\\xi} + \\nu I_{n_x} \\otimes D_{\\xi \\xi} \\in \\Rb^{n_x n_\\xi \\times n_x n_\\xi}$\n  \\[\n    LU = \\big( \n      (1+\\tau \\gamma) I_{n_x n_\\xi} - \\tau \\nu I_{n_x} \\otimes D_{\\xi \\xi} \n\t\\big)\n      \\in \\Rb^{n_\\xi n_x \\times n_\\xi n_x }.\n  \\]\n  %$A \\in \\Rb^{n_\\xi \\times n_\\xi}$, $LU=A$.\\;\n\\BlankLine\n  \\For{$n = 1,\\ldots,n_t$}{\n    Set $Z = U^{n-1} \\in \\Rb^{n_\\xi n_x} $. \\;\n    Compute the external input at time $t_{n-1}$ and store it in $G \\in \\Rb^{n_\\xi n_x}$. \\;\n    Compute the nonlinear term $N$ using \\eqref{eq:NQuad}.\\;\n    Solve for $U^{n}$ the linear problem $(LU)U^n = Z + \\tau(N+G)$.\n  }\n}\n\\end{algorithm}\n\nIn Table~\\ref{tab:flops} we count flops required in each line of Algorithms\n\\ref{alg:smart} and \\ref{alg:naive}. The data is grouped so as to distinguish between\nthe initialisation phase of the algorithms, and the iterations for the time steps.\nAlgorithm \\ref{alg:smart} outperforms substantiatlly Algorithm \\ref{alg:naive} in\nboth phases. In the initialisation, the number of flops scales linearly for Algorithm\n\\ref{alg:smart}, and quadratically for Algorithm \\ref{alg:naive}. This is mostly\nowing to the $LU$-factorisation step, which involves the $n_\\xi$-by-$n_\\xi$ matrix\n$A$ in the former, and an $n_\\xi n_x$-by-$n_\\xi n_x$ matrix in the latter. \n\nThe efficiency gain is more striking in the cost per time step: owing to the\npseudospectral evaluation of the nonlinearity, only $O(n_\\xi n_x) + O(n_x \\log n_x)$\nflops are necessary in Algorithm \\ref{alg:smart}, as opposed to $O(n^2_\\xi n^2_x)$\nflops in Algorithm \\ref{alg:naive}.\n\n\\begin{table}\n  \\centering\n  \\caption{Flop count for the initialisation step (lines 2--6) and for one time\n  step (lines 8--12) in Algorithms 1,2.}\n  \\label{tab:flops}\n\\begin{tabular}{cccc}\n  \\toprule\n  \\multicolumn{2}{c}{Algorithm 1} & \\multicolumn{2}{c}{Algorithm 2} \\\\\n  Lines & Flops & Lines & Flops \\\\\n  \\otoprule\n   2    & $  n_\\xi + n_x        $  &  2   & $  n_\\xi + n_x                  $ \\\\\n   3    & $  2n_x               $  &  3   & $     n_x                       $ \\\\\n   4    & $  2n_\\xi             $  &  4   & $    2n_\\xi                     $ \\\\\n   5    & $  n_\\xi              $  &  5   & $   n_\\xi + n_x                 $ \\\\\n   6    & $  2n_\\xi-1           $  &  6   & $   2n_\\xi n_x -1               $ \\\\\n  \\midrule\n  % 2--6 & $  6n_\\xi + 3n_x-1  $  & 2--6 & $ 2n_\\xi n_x + 4 n_\\xi + 3 n_x -1 $ \\\\\n  2--6 & $  O(n_\\xi) + O(n_x)  $  & 2--6 & $ O(n_\\xi n_x) $ \\\\\n  \\midrule\n   8    & $  n_\\xi n_x                                              $  &  8   & $  n_\\xi n_x                            $ \\\\\n   9    & $  n_\\xi n_x                                              $  &  9   & $  n_\\xi n_x                            $ \\\\  \n   10   & $  3 n_\\xi n_x + O(n_x \\log n_x) + n_\\xi - n_x               $  &  10  & $  2n^2_\\xi n_x^2 - n^2_\\xi n_x         $ \\\\\n   11   & $  n_\\xi n_x + O(n_x \\log n_x) + 2n_x                        $  &  11  & $  5n_\\xi n_x -4                        $ \\\\\n   12   & $  5 n_\\xi n_x - 4 n_x                                    $  &      & $                                       $ \\\\\n  \\midrule\n   % 8--12 & $2 n_x \\log n_x + 11 n_\\xi n_x + n_\\xi - 3 n_x $  & 8--11 & $ 2n^2_\\xi n^2_x -n_\\xi^2 n_x + 7n_\\xi n_x -4  $ \\\\\n   8--12 & $O(n_\\xi n_x) + O(n_x \\log n_x)$  & 8--11 & $ O(n^2_\\xi n^2_x) $ \\\\\n  \\bottomrule\n%\n  %\\bottomrule\n\\end{tabular}\n\\end{table}\n\n\\begin{table}\n  \\centering\n  \\caption{Space requirements, measured in Floating Point Numbers, for\n  Algorithms 1 and 2. Arrays $d_1, \\ldots, d_3$, store diagonals of the\n$LU$-factorisation in the respective algorithms.}\n\\label{tab:memory}\n\\begin{tabular}{ccc}\n  \\toprule\n   Floating Point Numbers & Algorithm 1 & Algorithm 2 \\\\\n  \\otoprule\n  $n_\\xi$       & $\\xi,\\alpha,\\alpha',d_1,d_2,d_3,z$ & $\\xi, \\rho, \\alpha, \\alpha'$ \\\\  \n  $n_x$         & $x,w,\\sigma$                       & $x, \\sigma, w$ \\\\  \n  $n_\\xi n_x$   &  $V,V^n,G,N$                       & $U^n,Z,N,G,d_1,d_2,d_3$ \\\\  \n  \\midrule\n  Total         & $4n_x n_\\xi + 7n_\\xi + 3n_x$      &  $ 7 n_x n_\\xi +2n_\\xi + 2n_x $  \\\\  \n  \\bottomrule\n\\end{tabular}\n\\end{table}\n\nAn important point to note that, in the case of a 2D somatic space with, say\ncoordinates $(x,y,\\xi)$ and $n_x=n_y=N$, $n_\\xi$ grid points (see\nFigure~\\ref{fig:sketch}(a)), the size of the matrix $A$ in\nAlgorithm \\ref{alg:smart} remains unaltered, while Algorithm \\ref{alg:naive}\nrequires the factorisation and inversion of a much larger matrix, of size $n_\\xi N^2$-by-$n_\\xi\nN^2$. Estimates for the efficiencies in this case can be obtained by replacing $n_x$ by\n$N^2$ in the table, leading to much greater savings.\n\nFinally, in Table~\\ref{tab:memory} we collect the variables used by both algorithms,\nand count the storage requirement of each of them, measured floating point numbers.\nThe results show that Algorithm 1 requires asymptotically the same storage as\nAlgorithm 2 $O(n_\\xi n_x)$. For fixed values of $n_\\xi$ and $n_x$, however, the\nlatter uses almost twice as much storage space as the former.\n\n% An important aspect of the numerical implementation is the evaluation of the\n% nonlinear term \\eqref{eq:NQuad}: evaluating the right-hand side of\n% \\eqref{eq:IMEX} requires in general $O(n^2_\\xi n^2_x)$ operations, which is a\n% bottleneck for the time stepper, in particular for large domains. However, the\n% structure of the problem can be exploited once again to evaluate this term\n% efficiently. We make use of the following properties: \n% \\begin{enumerate}\n%   \\item The kernel $W$ specified in \\eqref{eq:kernel} has a product structure,\n%     hence\n%     \\[\n%       W(x_j,\\xi_i,x_{j'},\\xi_{i'}) = \\delta_\\ep(\\xi_i-\\xi_0) \\delta_\\ep(\\xi_{i'})\n%       w(|x_j-x_{j'}|). \n%     \\]\n%     In addition, $w$ is periodic, therefore the matrix with entries $w(|x_j -\n%     x_{j'}|)$ is circulant with (rotating) row vector $w \n%     = \\{w(|x_j|) \\colon j \\in \\Nb_{n_x}\\}  \\in \\Rb^{1 \\times n_x}$.\n%    \\item The function $\\delta_\\ep$ is supported in a small interval $I_\\ep$ of\n%      $O(\\ep)$ length, hence its\n%      evaluation at the grid points is nonzero only on a small index set, namely\n%      \\[\n%        \\delta_\\ep(\\xi_i-\\xi_0) =\n%        \\begin{cases}\n% \t \\alpha_i & \\text{if $i \\in \\Ib$,} \\\\\n% \t 0        & \\text{otherwise,}\n%        \\end{cases}\n%        \\qquad\n%        \\delta_\\ep(\\xi_{i'}) =\n%        \\begin{cases}\n% \t \\alpha'_{i'} & \\text{if $i' \\in \\Ib'$,} \\\\\n% \t 0        & \\text{otherwise,} \n%        \\end{cases}\n%      \\]\n%      where $\\Ib,\\Ib' \\subseteq \\Nb_{n_\\xi}$ are index sets with $O(\\ep/L_{n_\\xi})$ elements\n%      $|\\Ib|, |\\Ib'| \\ll n_\\xi$, respectively.\n%    \\item The function $x \\mapsto V(x,\\blank)$ is $2L_x$-periodic, hence the trapezium\n%      rule has identical weights $\\rho_j = h_x$, and the integration\n%      in $x$ is a circular convolution, which can be performed efficiently in $O(n_x\n%      \\log n_x)$ operations, using the Discrete Fourier Transform (DFT).\n% \\end{enumerate}\n% \n% Owing to the first two properties we obtain \n% \\[\n%   N_{ij}(V) = \\alpha_i \\sum_{j' \\in \\Nb_{n_\\xi}} w_{j-j'} \\rho_{j'}\n%   \\sum_{i' \\in \\Ib'} \\alpha'_{i'} \\sigma_{i'} S(V_{i'j'})\n%   \\qquad\n%   (i,j) \\in \\Ib \\times \\Nb_{n_x},\n% \\]\n% and we note that only $|\\Ib|$ rows of $N$ are nonzero, and the inner sum is only over\n% $|\\Ib'|$ elements. As noted in property 3, a DFT can be used to perform the outer\n% sums~\\cite{coombes2012interface,rankin2014}.\n% Introducing the direct, $\\cF_n$, and inverse, $\\cF_n^{-1}$, DFTs for $n$-vectors, we express compactly the nonzero elements of $N$ as\n% follows\n% \\begin{equation}\\label{eq:NFast}\n%   N_{\\Ib,\\Nb_{n_x}} = \\alpha h_x \\cF^{-1}_{n_x} \n%    \\big[\n%      \\cF_{n_x}[w] \\odot  \\cF_{n_x}[ (\\alpha' \\odot \\sigma)^T S(V_{\\Ib',\\Nb_{n_x}})]\n%    \\big],\n% \\end{equation}\n% where we have used an index-set notation for the elements of $N$, $\\alpha \\in \\Rb^{|\\Ib| \\times 1}$, $\\alpha', \\sigma \\in \\Rb^{|\\Ib'| \\times 1}$\n% are column vectors, and $\\odot$ denotes the Hadamard product, that is, elementwise\n% vector multiplication. The formula above evaluates the\n% nonlinear term $N$ in just $(2|\\Ib| + |\\Ib'|)n_x + O(n_x \\log n_x) = O(n_x + n_x\\log\n% n_x)$ operations. We remark that, if the\n% $\\delta_\\ep$ is supported in $[-L_{\\xi},L_{\\xi}]$, that is, $\\ep = L_\\xi$, one can\n% still use the formula above, which holds for $\\Ib = \\Ib' = \\Nb_{n_\\xi}$ and evaluates\n% $N$ in $O(n_xn_\\xi + n_x \\log n_x)$ operations.\n\n\n\\section{Travelling waves}\\label{sec:TWTest}\n\\begin{figure}\n  \\centering\n  \\includegraphics{wave}\n  \\caption{ Coherent structure observed in time\n    simulation of \\eqref{eq:systemNum}, \\eqref{eq:TWSigmoidal}, \\eqref{eq:TWKernel}.\n    (a): Pseudocolor plot of $V(x,\\xi,t)$ at several time points, showing two\n    counter-propagating waves. (b): Solution at $\\xi = 0$, showing the wave\n    profile. Parameters: $\\xi_0 = 1$, $\\ep = 0.005$, $\\nu=0.4$, $\\gamma=1$, $\\beta=1000$,\n    $\\theta =0.01$, $\\kappa =3$, $L_x = 24 \\pi$, $L_\\xi =3$, $n_x =\n    2^{10}$, $n_\\xi=2^{12}$, $\\tau = 0.05$.}\n    \\label{fig:wave}\n\\end{figure}\nWe tested the algorithm on an analytically tractable neural field problem, and we\nreport in this section our numerical experiments. For the test, we take a sigmoidal\nfiring rate function\n\\begin{equation}\\label{eq:TWSigmoidal}\n  S(V) = \\frac{1}{1 + \\exp(-\\beta(V-\\theta))}, \n\\end{equation}\nand kernel specified by\n\\begin{equation}\\label{eq:TWKernel}\n  w(x) = \\frac{\\kappa}{2} \\exp \\bigg( -\\frac{|x|}{2} \\bigg),\n  \\qquad\n  \\delta_\\ep(\\xi) = \\frac{1}{\\ep\n  \\sqrt{\\pi}} \\exp\\bigg(-\\frac{\\xi^2}{\\ep^2}\\bigg) \n\\end{equation}\nwhere $\\beta, \\theta, \\kappa$ are positive constants. If $S(V) = H(V- \\theta)$, $H$\nbeing the Heaviside\nfunction, $\\delta_\\ep$ is replaced by the Dirac delta distribution, and the\nevolution equation is posed on $\\Rb^2$, then the model supports solutions for which\n$V(x,0,t)$ is a travelling front \n%\\[\n$\nV(x,0,t) = \\varphi(x-v_*t)$, \nwith\n$\\varphi(\\pm \\infty) = V_\\pm$,\n%\\]\nwhose speed $v_*$ satisfies the implicit equation~\\cite{Ross2019}\n\\begin{equation}\\label{eq:analyticalSpeed}\n  \\frac{\\kappa \\exp(-\\psi(v_*,\\nu) \\xi_0 )}{2 \\psi(v_*,\\nu) \\nu} -\\theta = 0,\n  \\qquad \\psi(v_*,\\nu) = \\sqrt{\\frac{\\gamma + v_*}{\\nu}}.\n\\end{equation}\n\\begin{figure}\n  \\centering\n  \\includegraphics{convergenceTests}\n  \\caption{(a) Travelling wave speed versus firing rate\n    threshold, computed analytically via \\eqref{eq:analyticalSpeed}, and numerically\n    via the time-stepper. (b)--(d) Convergence of the computed speed to the\n    analytical speed at $\\theta = 0.01$, as a function of the the kernel support\n    parameter $\\ep$, the steepness of the sigmoid $\\beta$, and the time-stepping\n    parameter $\\tau$, respectively. Parameters as in \\eqref{fig:wave}.}\n    \\label{fig:convergenceTests}\n\\end{figure}\n\nTo test our scheme we study solutions to \\eqref{eq:systemNum},\n\\eqref{eq:TWSigmoidal}, \\eqref{eq:TWKernel} with\n$L_x, \\beta \\gg 1$, $L_\\xi \\gg \\sqrt{\\nu /\\gamma}$,  (the\ncharacteristic electrotonic length), and $\\ep \\ll 1$.\nSince for this problem $[-L_x,L_x)\n\\cong \\mathbb{S}$, we expect to observe at $\\xi=\\xi_0$\ntwo counter-propagating waves with approximate speed $v$ and \n\\[\n  V(\\pm L_x,\\xi_0,t) \\approx V_+, \\qquad V(0,\\xi_0,t) \\approx V_-.\n\\]\nWe show an exemplary profile of this coherent structure in Figure~\\ref{fig:wave},\nwhere we observe two counter-propagating waves, as described above. \n\nSince the wavespeed $v_*$ is available implicitly, we performed some tests\nto validate the proposed algorithm. Firstly, we compute roots of\n\\eqref{eq:analyticalSpeed} in the variable $v_*$, as a function of the firing rate\nthreshold $\\theta$. In Figure~\\ref{fig:convergenceTests}(a) we observe a good agreement with\nthe wavespeed observed in direct simulations. The latter has been\ncomputed by post-processing data from numerical simulations: using first-order\ninterpolants we approximate a positive function $x_*(t)$ such that $V(x_*(t),0,t) =\n\\theta$, that is, the $\\theta$-level set of $V(x,0,t)$ on $[0,L_x] \\times [0,T]$;\nafter an initial transient, $\\dot x_*(t)$ is approximately constant and provides an\nestimate of $v_*$, which is derived via first-order finite differences. In\nFigure~\\ref{fig:convergenceTests}(a) we observe a small discrepancy, which should be expected as\nwe have several sources of error, namely: the time-stepping error, the spatial\ndiscretisation error for the differential and integral operators, the error due to\nthe sigmoidal firing rate and to $\\delta_\\ep$ (the theory is\nvalid for Heaviside firing rate and for a Dirac-delta distribution $\\delta$). In\nFigures~\\ref{fig:convergenceTests}(b)--(d) we show convergence plots for these errors (except for\nthe second-order spatial discretisation error which is dominated in numerical\nsimulations by the first-order time-stepping error).\n\n\\section{Turing instability}\\label{sec:TuringTest}\nThe model defined by (\\ref{1}), with an appropriate choice of somatic interaction,\ncan also support a Turing instability to spatially periodic patterns\n\\cite{Bressloff96}.  These in turn may either be independent of time or periodic in\ntime.  In the latter case this leads to periodic travelling waves.  Whether emergent\npatterns be \\textit{static} or \\textit{dynamic} they both provide another validation\ntest for the numerical scheme presented here, as the bifurcation point as determined\nanalytically from a Turing analysis should agree with the onset of patterning in a\ndirect numerical simulation.  A relatively recent description of the method for\ndetermining the Turing instability in a neural field with dendritic processing can be\nfound in \\cite{Coombes2014}.  Here we briefly summarise the necessary steps to arrive\nat a formula for the continuous spectrum, from which the Turing instability can be\nobtained.\n\nIn general a homogeneous steady state solution of (\\ref{1}) will only exist if either\n$S(0)=0$ or $\\int_{\\Rb^2} W(x,\\xi,y,\\eta)\\diff y \\diff \\eta = \\text{constant}$\nfor all $(x,\\xi)$.  The latter condition is not generic, and so for the purposes of\nthis validation exercise we shall work with the choice $S(0)=0$ for which $V=0$ is\nthe only homogeneous steady state.  Linearising around $V=0$ and using\n(\\ref{eq:kernel}) gives an evolution equation for the perturbations $\\delta\nV(x,\\xi,t)$ that can be written in the form\n\\begin{equation}\n\\delta V(x,\\xi,t) = S'(0) \\int_{-\\infty}^t \\Theta(\\xi-\\xi_0,t-s) \\int_{\\Rb} \nw(|x-x'|) \\delta V(x',0,s) \\diff x' \\diff s,\n\\label{deltaV}\n\\end{equation}\nwhere\n\\[\n  \\Theta(\\xi, t)=\\mathrm{e}^{-\\gamma t} \\frac{\\mathrm{e}^{-\\xi^{2} /(4 \\nu\n  t)}}{\\sqrt{4 \\pi \\nu t}} H(t).\n\\]\nFocusing on a \\textit{somatic} field $\\delta V(x,0,t)$, we see from (\\ref{deltaV})\n(with $\\xi=0$) that this has solutions of the form $\\e^{\\lambda t} \\e^{i p x}$ for\n$\\lambda \\in \\Cb$ and $p \\in \\Rb$, where $\\lambda=\\lambda(p)$ is defined by the\nimplicit solution of $\\mathcal{E}(\\lambda,p)=0$, where\n\\begin{equation}\n\\mathcal{E}(\\lambda,p) = 1 - S'(0) \\frac{\\exp(-\\psi(\\lambda,\\nu) \\xi_0 )}{2 \\psi(\\lambda,\\nu) \\nu} \\widehat{w}(p) .\n\\end{equation}\nHere the function $\\psi$ is defined as in (\\ref{eq:analyticalSpeed}) and\n$\\widehat{w}(p)$ is the Fourier transform of $w$:\n\\begin{equation}\n\\widehat{w}(p) = \\int_{\\Rb}  w(|y|) \\e^{-i p y} \\diff y.\n\\end{equation}\nWe note that since $w(x)=w(|x|)$ then $\\widehat{w}(p) \\in \\Rb$.  \n\n\\begin{figure}\n  \\centering\n  \\includegraphics{TuringStatic}\n  \\caption{Numerical simulation of Turing bifurcation for the model with kernel and\n   firing rate function given in \\eqref{eq:mexicanHatKernel}. (a): Plots of $\\hat w(p) - w_*$\n   for $\\beta = 28$ and $\\beta=30$, from which we deduce\nthat a Turing bifurcation occurs for an intermediate value of $\\beta$. We expect\nperturbations of the trivial state to decay exponentially if $\\beta=28$ and to increase\nexponentially if $\\beta = 30$, as confirmed in panels (b)--(d). (b): Maximum absolute\nvalue of the voltage at $\\xi=0$, as function of time, when the trivial steady state is\nperturbed. (c),(d): Pseudocolor plot of $V$ when $\\beta=28$ and $\\beta=30$, respectively.\nParameters: $\\xi_0 = 1$, $\\ep = 0.005$, $\\nu  = 6$, $c = 1$, $a_1 = 1$, $b_1 =\n1$, $a_2 = 1/4$, $b_2 = 1/2$, $n_x  = 2^9$, $L_x  = 10\\pi$, $n_\\xi = 2^{11}$, $L_\\xi =\n2.5 \\pi$, $\\tau = 0.01$. }\n  \\label{fig:TuringStatic}\n\\end{figure}\n\nNote that if $\\lambda \\in \\Rb$ with $\\lambda > -\\gamma$ then $\\mathcal{E}(\\lambda,p) \\in\n\\Rb$.\nThe trivial steady state is stable to spatially-periodic perturbations if \n\\[\n  \\hat w(p) < w_* = 2\\psi(0,\\nu) \\nu \\exp(\\psi(0,\\nu) \\xi_0)/S'(0)  \\qquad\n  \\text{for all $p \\in \\Rb$}.\n\\]\nHence a static instability occurs under a parameter variation when $w(p_*) = w_*$ for\nsome $p_* \\in \\Rb$, the critical wavelength of the unstable pattern.\nHence if $\\widehat{w}(p)$ has a positive peak away from the origin, at $p=p_*$, then a static\nTuring instability can occur (see Figure \\ref{fig:TuringStatic}(a)). This is possible\nif $w(|x|)$ has a Mexican-hat shape, describing short range excitation and long range\ninhibition. \n\nWe have validated this scenario numerically, by simulating a neural field with\n\\begin{equation}\\label{eq:mexicanHatKernel}\n  w(x) = a_1 \\exp(-b_1 |x|) - a_2 \\exp(-b_2 |x|), \\qquad S(V) = \\frac{1}{1 +\n  \\exp{(-\\beta V)}} - \\frac{1}{2},\n\\end{equation}\nand reporting results in Figure~\\ref{fig:TuringStatic}. In the Figure we pick the\nsteepness of the sigmoidal firing rate as main parameter, deduce that\na Turing bifurcation occurs for a critical value $\\beta_* \\in [28,30]$, perturb the\ntrivial steady state by setting initial condition $V_0(x,\\xi) = 0.01 \\cos(p_* x)$ and\ndomain $\\bar \\Omega = [-4\\pi/p_*, 4\\pi/p_*] \\times [-\\pi/p_*,\\pi/p_*]$, and observe\nthe perturbations decaying for $\\beta = 28$, and growing for $\\beta = 30$, respectively.\n\nNote that, if $\\lambda \\in \\Cb$, then $\\mathcal{E}(\\lambda,p) \\in \\Cb$ and it is\npossible that a dynamic Turing instability can occur, with an emergent frequency $\\omega_c$.  It is\nknown that this case is more likely for an inverted Mexican-hat shape, describing\nshort range inhibition and long range excitation \\cite{Bressloff96}. We do not show\ncomputations for this case, but we briefly discuss it below. The dynamic\nbifurcation condition can be defined by tracking the continuous spectrum at the point\nwhere it first crosses the imaginary axis away from the real line.  This is\nequivalent to solving $P_p H_\\omega - H_p P_\\omega = 0$ with $P(0,\\omega_c,p) = 0 =\nH(0,\\omega_c,p)$, where the subscripts denote partial differentiation and\n$P(\\nu,\\omega,p) = \\Real \\, \\mathcal{E}(\\nu + i \\omega,p)$ and $H(\\nu,\\omega,p) =\n\\Imag \\, \\mathcal{E}(\\nu + i \\omega,p)$ \\cite[Chapter 1]{Coombes2005}.\n\n\\section{Conclusions} \\label{sec:conclusions}\nIn this paper we have presented an efficient scheme for the\nnumerical solution of neural fields that incorporate dendritic processing. The model\nprescribes diffusivity along the dendritic coordinate, but not along the cortex; in\naddition, the nonlinear coupling is nonlocal on the cortex, but essentially local on\nthe dendrites. This structure allows the formulation of a compact numerical scheme,\nand provides efficiency savings both in terms of operation counts, and in terms of\nthe space required by the algorithm. Firstly, a small diffusivity differentiation\nmatrix is decomposed at the beginning of the computation, and then used repeatedly\nto solve a set of linear problems in the cortical direction. This aspect of the\ncomputation is appealing, especially for high-dimensional computations where a 2D\ncortex is coupled to the 1D dendritic coordinate, as the decomposition is performed\nonce, and involves only a 1D differentiation matrix. Secondly, the largest\ncomputational effort of the scheme, which is in the evaluation of the nonlinear term, can be\nreduced considerably using DFTs. We\nhave also provided a basic numerical analysis of the scheme, under the assumption that a\nsolution to the infinite-dimensional problem exists. The existence of this solution\nremains an open problem, which will be addressed in future publications. \n\nThe numerical implementation presented here does not exploit the fact that the\nsynaptic kernel is localised via the function $\\delta_\\ep$. If one models the kernel\nusing a compactly supported function, for instance\n\\begin{equation}\\label{eq:compactDelta}\n  \\delta_\\ep(\\xi) = \\kappa\n  \\exp\\bigg(-\\frac{\\xi^2}{\\ep^2}\\bigg) 1_{(-\\ep,\\ep)}(\\xi), \n\\end{equation}\nwhich is supported in a small interval of $O(\\ep)$ length, its\nevaluation at the grid points is nonzero only on a small index set, namely\n\\[\n  \\delta_\\ep(\\xi_i-\\xi_0) =\n  \\begin{cases}\n    \\alpha_i & \\text{if $i \\in \\Ib$,} \\\\\n    0        & \\text{otherwise,}\n  \\end{cases}\n  \\qquad\n  \\delta_\\ep(\\xi_{i'}) =\n  \\begin{cases}\n    \\alpha'_{i'} & \\text{if $i' \\in \\Ib'$,} \\\\\n    0        & \\text{otherwise,} \n  \\end{cases}\n\\]\nwhere $\\Ib,\\Ib' \\subseteq \\Nb_{n_\\xi}$ are index sets with $O(\\ep/L_{n_\\xi})$\nelements $|\\Ib|, |\\Ib'| \\ll n_\\xi$, respectively. This implies\n\\[\n N_{ij}(V) = \\alpha_i \\sum_{j' \\in \\Nb_{n_\\xi}} w_{j-j'} \\rho_{j'}\n  \\sum_{i' \\in \\Ib'} \\alpha'_{i'} \\sigma_{i'} S(V_{i'j'})\n  \\qquad\n  (i,j) \\in \\Ib \\times \\Nb_{n_x},\n\\]\nand we note that only $|\\Ib|$ rows of $N$ are nonzero, and the inner sum is only over\n$|\\Ib'|$ elements. The formula above evaluates the nonlinear term $N$ in just\n$(2|\\Ib| + |\\Ib'|)n_x + O(n_x \\log n_x) = O(n_x + n_x\\log n_x)$ operations. Numerical\nexperiments and convergence tests have been performed also for this formula, albeit\nthe results not presented here, because a synaptic kernel with the choice\n\\eqref{eq:compactDelta} is no longer in $C^2(\\Omega \\times \\Omega)$, hence\nLemma~\\ref{lem:IMEXconvergence} does not hold, and we plan to provide a convergence\nresult for this case elsewhere. We provide, however, a Matlab implementation of this\ncode in Appendix~\\ref{sec:matlab}.\n\nPossible extensions of the model include curved geometries \\cite{Visser:2017hy,Bojak2010}, which should\nbenefit from a similar strategy used here for the dendritic coordinate, as well as\nmultiple population models. We expect that the latter will induce different coherent\nstructures to the ones reported here. The method outlined in this paper is valid also\nin the context of numerical bifurcation analysis, which can be employed to study the\nbifurcation structure of steady states and travelling waves.\n\nThe inclusion of synaptic processing to the present model is straightforward, by\ncoupling \\eqref{eq:systemNum} to an equation of type $Q\\Psi =K$ where $Q=\n(1+\\alpha^{-1} \\partial_t)^2$ is a temporal differential operator. The resulting\nmodel would not involve any additional spatial differential or integral\noperator, therefore the proposed scheme can be applied by simply augmenting the\ndiscretised state variables.\n%\n%applying a filter this as a differential\n%equation using Q \\Psi = K, where Q is a differential operator such as (1+\\alpha^{-1}\n%\\d/\\dt)^2.  In the current paper we have that Q=1.\n\nIt is also important to address the role of axonal delays on the generation of large\nscale brain rhythms.  A recent paper \\cite{Ross2019} has explored how this might be\ndone in a purely PDE setting, generalising the Nunez brain-wave equation to include\ndendrites. A natural extension of the work in this paper is to consider a more\ngeneral numerical treatment of a model with both dendritic processing and\nspace-dependent axonal delays in an integro-differential framework.\n\n\\section*{Acknowledgments} P.M. Lima acknowledges support from Funda\\c c\\~ao para a\nCi\\^encia e a Tecnologia (the Portuguese Foundation for Science and Technology)\nthrough the  grants POCI-01-0145-FEDER-031393 and UIDB/04621/2020.\n\n% You may incorporate your references as follows in your main tex file.\n% Using BibTex is not recommended but can be handled.\n\n\\newpage\n\\appendix\n\\section{Matlab implementation}\\label{sec:matlab}\n\\phantom{In this section we provide a listing of the code used}\n\\lstinputlisting{Codes/timeStep.m}\n\n\\bibliographystyle{siamplain}\n\\bibliography{references}\n\\end{document}\n", "meta": {"hexsha": "1ab83b484915de956001c6f6086fbb9ee866eaa4", "size": 67060, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/manuscript.tex", "max_stars_repo_name": "danieleavitabile/neural-field-with-dendrites", "max_stars_repo_head_hexsha": "f70eee68998e7cd5296f0a83bc557b62ea9c0cb3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Manuscript/manuscript.tex", "max_issues_repo_name": "danieleavitabile/neural-field-with-dendrites", "max_issues_repo_head_hexsha": "f70eee68998e7cd5296f0a83bc557b62ea9c0cb3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manuscript/manuscript.tex", "max_forks_repo_name": "danieleavitabile/neural-field-with-dendrites", "max_forks_repo_head_hexsha": "f70eee68998e7cd5296f0a83bc557b62ea9c0cb3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.0204678363, "max_line_length": 146, "alphanum_fraction": 0.6810169997, "num_tokens": 21654, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778403, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4429149232509141}}
{"text": "% !TeX root = ../report-phd-first-year.tex\n% !TeX encoding = UTF-8\n% !TeX spellcheck = en_GB\n\n\\section*{Research plan for the next year}\n\n  One of the main topics that will be further investigated during the next year is the analysis of assembly lines. At the moment, the work produced \\cite{biagi2017inspection} sets a good base for investigation of analysis techniques for assembly lines, but lacks many aspects in order to be usable with real assembly lines. The first restriction that should be surpassed is the lack of buffers between workstations. In real assembly lines there is usually a buffer of fixed size, so one of the first investigations should be towards the introduction of buffering capacity, considering the same capacity for every workstation or even different sizes. More performance measures should also be introduced, such as the time until the production from the whole assembly line of a specific product in the line, or the time until the next $N$ products will be completed by the assembly line. These kind of measures would be more complex than the ones already proposed in \\cite{biagi2017inspection}, but would also allow a more accurate analysis of the assembly line. Evaluation of these additional measures should also be derived in a compositional fashion, as done already in \\cite{biagi2017inspection}, in order to keep the technique computationally feasible. Lastly, a better upper bound for the measures proposed should be derived, similarly to the lower bound derived in \\cite{biagi2017inspection}.\n  \n  Another topic that will be investigated is that of smart drugs restocking for the \\acr{LINFA} project. The work conducted at the moment is still far from being usable in a real ward scenario. This is mainly due the problem of state space explosion, since the problem to be modelled is quite complex and many aspects would need to be modelled, causing the so called state space explosion and thus rendering it infeasible to analyse. One of the first directions is thus that of optimising the prediction model itself, in order to model more aspects while maintaining the number of generated states feasible. The PRISM model checker used up until now doesn't provide any solution for state space optimisation, so alternative modelisation tools might be investigated, such as the Storm tool \\cite{dehnert2017storm}. Then, the restrictions currently present in the model should one by one be surpassed. An example would be to introduce different healthcare protocols for different kinds of patients, including different phases with different drugs consumption rates, thus personalising more the sojourn of patients in the ward. This could be done by employing techniques for process mining \\cite{van2004workflow}, allowing to generate models automatically from historical data, such as a dataset of patients from a real ward.\n  \n  Lastly, the topic of \\ac{AR}, especially in the scenario of \\ac{AAL}, will be further investigated. The idea is to expand on the work of \\cite{biagi2016stochastic,carnevali2015continuous} and on the investigation conducted in Jaén in order to enhance the \\ac{AR} model. Among the possible enhancements there is the possibility of adding support for continuous sensors, such as a thermometer or an accelerometer, which is now lacking in the current model. Another important research activity for this topic is that of finding good datasets for \\ac{AAL} \\ac{AR} in order to apply techniques of process mining more accurately and refining the existing model, possibly following the recommendations shown in \\cite{patara2015recommendations}.\n\n\\newpage\n", "meta": {"hexsha": "bd08f1e19cb078aa405ca8828cc13fbb1c85f656", "size": 3614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd/committee/first-year/report/body/research_plan.tex", "max_stars_repo_name": "oddlord/uni", "max_stars_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "phd/committee/first-year/report/body/research_plan.tex", "max_issues_repo_name": "oddlord/uni", "max_issues_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd/committee/first-year/report/body/research_plan.tex", "max_forks_repo_name": "oddlord/uni", "max_forks_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 258.1428571429, "max_line_length": 1396, "alphanum_fraction": 0.8115661317, "num_tokens": 740, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.44291492238177815}}
{"text": "\\documentclass[10pt]{article}\n\n\\usepackage[margin=1in]{geometry}\n\n% Enable (uncolored) cross-reference hyperlinks\n\\usepackage[colorlinks=false]{hyperref}\n\n% Imported via UltiSnips\n\\usepackage{tikz}\n\\usetikzlibrary{arrows.meta,decorations.markings,shadows,positioning,calc,backgrounds,shapes}\n\n% Imported via UltiSnips\n\\usepackage{amsmath}\n\\usepackage{amsfonts}  % Used for \\mathbb and \\mathcal\n\\usepackage{amssymb}\n\n\\newcommand{\\sign}[1]{\\text{sgn}\\bigg( #1 \\bigg) }\n\n% Imported via UltiSnips\n\\usepackage{mathtools} % for \"\\DeclarePairedDelimiter\" macro\n\\DeclarePairedDelimiter{\\floor}{\\lfloor}{\\rfloor}\n\\DeclarePairedDelimiter{\\ceil}{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter{\\abs}{\\lvert}{\\rvert}\n\\DeclarePairedDelimiter{\\norm}{\\lVert}{\\rVert}\n\n% Imported via UltiSnips\n\\usepackage[noend]{algpseudocode}\n\\usepackage[Algorithm,ruled]{algorithm}\n\\algnewcommand\\algorithmicforeach{\\textbf{for each}}\n\\algdef{S}[FOR]{ForEach}[1]{\\algorithmicforeach\\ #1\\ \\algorithmicdo}\n\n\\newcommand{\\toolname}{Deep-PU}\n\\newcommand{\\xI}[1]{\\mathbf{x}^{(#1)}}\n\\newcommand{\\xA}{\\xI{i}}\n\\newcommand{\\xB}{\\xI{j}}\n\\newcommand{\\xPred}[1]{\\mathbf{\\hat{x}}^{\\left(#1\\right)}}\n\\newcommand{\\xP}{\\xPred{p}}\n\\newcommand{\\xN}{\\xPred{n}}\n% \\newcommand{\\nnDist}[3]{\\norm*{#1\\left(#2\\right) - #1\\left(#3\\right)}}\n\\newcommand{\\puDist}[2]{\\delta\\left(#1, #2\\right)}\n\\newcommand{\\nnDist}[3]{\\puDist{#1\\left(#2\\right)}{#1\\left(#3\\right)}}\n\\newcommand{\\puDistDiff}{\\puDist{\\xI{i}}{\\xP} - \\puDist{\\xI{i}}{\\xN}}\n\n\\newcommand{\\lTrip}{\\mathcal{L}_{\\text{Triplet}}}\n\\newcommand{\\exA}{\\xI{{A}}}\n\\newcommand{\\exP}{\\xI{{P}}}\n\\newcommand{\\exN}{\\xI{{N}}}\n\n\\newcommand{\\pLoss}{\\mathcal{L}_{\\text{pos}}}\n\\newcommand{\\uLoss}{\\mathcal{L}_{\\text{unlabel}}}\n\n\\begin{document}\n\\suppressfloats% prevent figure on first page\n\\begin{center}\n  \\textbf{\\Large \\textbf{A Deep, Positive-Unlabeled Classifier using Generative Models}}\n  \\\\\\vspace{8pt}\n  {\\large CIS572 Project Proposal}\n  \\\\\\vspace{4pt}\n  Zayd Hammoudeh\n\\end{center}\n\n\\section{Positive-Unlabeled Learning}\n\nPositive-unlabeled (PU) learning is a form of \\textit{partially-supervised learning}  where the goal is to construct a binary classifier. Its name derives from the training set being partitioned into two disjoint subsets,~$\\mathcal{P}$ and~$\\mathcal{U}$.  Each example, ${\\mathbf{x} \\in \\mathcal{P}}$, is known \\textit{a priori} to be exclusively \\textit{positive} labeled. In contrast, all examples in $\\mathcal{U}$ are \\textit{unlabeled} and may belong to either the positive or negative class. The objective is to label~$\\mathcal{U}$ as accurately as possible (i.e.,~\\textit{transductive} setting) as well as potentially an unseen test set (\\textit{inductive} setting).  This paradigm is relevant to domains where there is unavailability of or added cost to collect negative labeled data including: land-cover classification~\\cite{Li:2011}, protein similarity prediction~\\cite{Elkan:2008}, disease gene identification~\\cite{Yang:2012}, deceptive/incentivized review identification~\\cite{Ren:2014}, targeted marketing~\\cite{Yi:2017}, and prescription drug interaction analysis~\\cite{Liu:2017}.\n\nState-of-the-art PU learning algorithms generally rely on a cost-sensitive learning framework where each unlabeled example is simultaneously treated as both positive \\textit{and} negative valued with different class weights proportional to that example's label confidence.~\\cite{Elkan:2008}  This primary contribution of this project is \\toolname, a new PU learning algorithm based on a deep bifurcated autoencoder.  We are not aware of any previous PU learning algorithm that leverages the unique advantages of deep learning.    The remainder of this document is structured as follows.  Section~\\ref{sec:Siamese} introduces the Siamese neural network, from which our architecture was inspired.  Section~\\ref{sec:DeepPU} provides an overview of our novel architecture.  Section~\\ref{sec:Experiments} concludes with a discussion of the planned experiments.\n\n\\section{Siamese Network}\\label{sec:Siamese}\n\n  A Siamese neural network is generally used to determine if two input examples $\\xA$ and~$\\xB$ have the same label.  The network, $f: \\mathcal{D}(\\mathbf{x}) \\rightarrow \\mathbb{R}^{m}$, is simply a function that maps a training example,~$\\mathbf{x}$, to an $m$-dimensional space, where $m$~is a positive-integer hyperparameter. For distance metric,~$\\delta:\\mathbb{R}^{m} \\rightarrow \\mathbb{R}_{{\\geq}0}$, the basic intuition underpinning Siamese networks is that:\n\n  \\begin{itemize}\n    \\item If examples,~$\\xA$ and~$\\xB$ have the same label, $\\nnDist{f}{\\xA}{\\xB}$ is \\textbf{small}\n    \\item Otherwise, $\\nnDist{f}{\\xA}{\\xB}$ is \\textbf{large}\n  \\end{itemize}\n\n  \\noindent\n  Since $\\delta$ is a distance metric, it satisfies the properties of non-negativity, identity, symmetry, and the triangle inequality.\n\n  Perhaps the most well known application of Siamese Networks is facial recognition.  The goal is to identify whether some observed person,~$\\xI{i}$, matches any individuals from a database of persons of interest (e.g.,~wanted criminals, employees, etc.).  $\\xI{i}$ is paired with its closest (precomputed) match,~$\\xI{j}$.  If $\\nnDist{f}{\\xI{i}}{\\xI{j}}$ exceeds some predefined threshold, the network reports that no match was found.\n\n\\subsection{Triplet Loss}\\label{sec:TripletLoss}\n\n  Siamese networks are trained by minimizing the triplet, or contrastive loss.  The function's name derives from the three training examples required for a single loss calculation. First, $\\exA$ is the baseline, or \\textit{anchor}, example used as the reference for comparison.  \\textit{Positive} example,~$\\exP$, must have the same label $\\exA$ while \\textit{negative} example $\\exN$ must have a different label than $\\exA$ (and in turn $\\exP$).\n\n  The triplet loss,~$\\lTrip$, is defined in Eq.~\\eqref{eq:TripletLoss}. The loss is minimized when a Siamese network follows the basic intuition outlined previously; the relative definition of ``large'' and ``small'' is based on positive-valued hyperparameter,~$\\alpha$.\n\n  \\begin{equation}\\label{eq:TripletLoss}\n    \\lTrip = \\max\\left\\{ \\nnDist{f}{\\exA}{\\exP} - \\nnDist{f}{\\exA}{\\exN} + \\alpha, 0 \\right\\}\n  \\end{equation}\n\n\\section{A New Positive-Unlabeled Learner}\\label{sec:DeepPU}\n\nOne of the challenges of combining deep and positive unlabeled learning is constructing a loss function that performs well when there is only one labeled class.  Generative models, e.g.,~autoencoders, are associated with well-studied objective/loss functions.  Although not generally common practice, these loss functions can be adapted for classification.\n\nShown in Figure~\\ref{fig:DeepPU}, our positive-unlabeled learner,~\\textit{\\toolname}, relies on a novel bifurcated autoencoder, which consists of a single encoder,~$g_{enc}$, whose output is shared between two decoders,~$g_{p}$ and~$g_{n}$, that are tuned to reconstruct only a single class, i.e.,~positive or negative respectively.  Note that the encoder and decoders can be feed-forward or convolutional based on the application.\n\nFigure~\\ref{fig:DeepPU} shows the entire latent vector,~$\\mathbf{z}$, being input into the two decoders.  However, we theorize that the architecture may get better performance if instead only disjoint slices of the latent representation are provided to each decoder.  This is an open area of study for the project.\n\n\\begin{figure}[t]\n  \\centering\n  \\input{tikz/deep_pu.tex}\n  \\caption{\\toolname\\ learner architecture}\\label{fig:DeepPU}\n\\end{figure}\n\n\\subsection{Training}\n\nThe current algorithm for training \\toolname\\ consists of three disjoint, sequential steps.  A highly summarized version of the training procedure is described below.\n\n\\paragraph{Step~\\#1} \\textit{Encoder \\& Negative Decoder Pretraining}: Using only the unlabeled set~$\\mathcal{U}$, train $g_{enc}$ and $g_{n}$ similar to a standard autoencoder.  Hence, unlabeled examples are input into the encoder and their reconstructed representation output by the decoder.  Note that the positive decoder is completely idle during this step.\n\nThe training objective is to minimize the reconstruction error between unlabeled input,~$\\xI{i}$, and its reconstructed output,~$\\xPred{i}$. This error can be quantified using standard loss functions including mean-squared error and in some cases a specialized form of logistic loss.\n\n\\paragraph{Step~\\#2} \\textit{Positive Decoder Pretraining}: The encoder and positive decoder,~$g_p$, are treated as a standard autoencoder and the positive, labeled examples are the training set.  The negative decoder is unused.  In contrast to Step~\\#1, the encoder's weights are frozen during this step.  This creates only a very small performance restriction because the encoder can represent both positive and negative examples since it was trained on (mixed) unlabeled set,~$\\mathcal{U}$.  The training objective remains minimizing the reconstruction error.\n\n\\paragraph{Step~\\#3} \\textit{Contrastive Loss Training}: Our novel contributions are most pronounced in this step.  Algorithm~\\ref{alg:JointTraining} details our training procedure while our loss functions are in Eq.~\\eqref{eq:PU:PosLoss} and~\\ref{eq:PU:UnlabelLoss}.  Their structure is similar to the contrastive properties of triplet loss, which was described in Section~\\ref{sec:TripletLoss}.  These contributions will be described in much greater detail in our final report and presentation.\n\n\\begin{algorithm}[t]\n  \\caption{Joint training of the positive and unlabeled decoders}\\label{alg:JointTraining}\n  \\begin{algorithmic}[1]\n    \\State $\\mathcal{P}$: Positive Set\n    \\State $\\mathcal{U}$: Unlabeled Set\n    \\State Unfreeze all weights\n    \\State $\\alpha\\gets 0$\n    \\While{\\text{not converged}}\n      \\State Increment value of $\\alpha$ \\Comment{Increasing temperature parameter}\n      \\While{\\text{epoch not complete}}\n        \\State Select batch $b_{\\mathcal{P}}$ from $\\mathcal{P}$\n        \\State Update $\\vec{\\theta}$ via $\\nabla\\pLoss(b_{\\mathcal{P}})$\n        \\State Select batch $b_{\\mathcal{U}}$ from $\\mathcal{P}$\n        \\State Update $\\vec{\\theta}$ via $\\nabla\\uLoss(b_{\\mathcal{U}})$\n      \\EndWhile\n    \\EndWhile\n  \\end{algorithmic}\n\\end{algorithm}\n\n  \\begin{equation}\\label{eq:PU:PosLoss}\n    \\pLoss = \\max\\left\\{ \\puDistDiff + \\alpha, 0 \\right\\}\n  \\end{equation}\n\n  \\begin{equation}\\label{eq:PU:UnlabelLoss}\n    \\uLoss = \\max\\left\\{ - \\abs*{\\puDistDiff} + \\alpha, 0 \\right\\}\n  \\end{equation}\n\n\\subsection{Prediction Function}\n\nFunction~$g_{p}$ is specifically trained to reconstruct the latent representation of positive-valued examples.  In contrast, function~$g_{n}$ is penalized during training to facilitate it poorly reconstructing these same positive-valued examples.  Therefore, if, for unlabeled example~$\\xI{i}$, $g_{p}$ yields a superior reconstruction than $g_{n}$, it can be reasonably concluded that $\\xI{i}$ is positive labeled; otherwise, it can be concluded that $\\xI{i}$ is negative labeled.  This intuition is the basis for \\toolname's prediction function shown in Eq.~\\eqref{eq:PU:ClassificationFunc}.\n\n  \\begin{equation}\\label{eq:PU:ClassificationFunc}\n    \\hat{y}^{\\left( i \\right)} = -\\sign{\\puDistDiff}\n  \\end{equation}\n\n\\noindent\nIn the case where $\\puDist{\\xI{i}}{\\xP}$ equals $\\puDist{\\xI{i}}{\\xN}$, $\\xI{i}$ is equally likely to be either negative or positive valued.  For simplicity, such examples are assigned a positive label. %\\toolname\\ can be converted to a \\textit{well-calibrated} classifier through established techniques such as isotonic regression or Platt scaling.\n\n  The accuracy of discriminative predictors may be closely tied to the prediction threshold used.  As such, we plan to also use area-under-the-curve metric to make the quantification of network's performance more robust.\n\n\\section{Planned Experiments}\\label{sec:Experiments}\n\nOur experiments will be primarily computer vision focused. Graphical training data will enable us to quick analyze and tune our algorithm's performance.  In addition, the images we will generate should make the final project presentation more engaging for the audience, in particular since most of the class is not very experienced with machine learning.\n\nSimilar to previous work~\\cite{Ghasemi:2016,duPlessis:2014,Claesen:2015}, \\toolname\\ will be tested on a handwritten digit dataset, specifically MNIST~\\cite{LeCun:1999}.  The baseline for comparison will be previously published results as well as our implementation of Elkan \\& Noto's algorithm~\\cite{Elkan:2008}.  The comparison metrics will be accuracy as well as area under the precision-recall and/or receiver operating characteristic curves as previously explained.\n\nIf time allows, experiments will also be performed on the USPS digit and fashion-MNIST datasets~\\cite{FashionMNIST}.\n\n\\bibliographystyle{ieeetr}\n\\bibliography{bib/ref.bib}\n\\end{document}\n", "meta": {"hexsha": "edba706bc51400580d5009d6c2b1195f4b3a24fd", "size": 12811, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "project/proposal/deep_pu.tex", "max_stars_repo_name": "ZaydH/cis572", "max_stars_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "project/proposal/deep_pu.tex", "max_issues_repo_name": "ZaydH/cis572", "max_issues_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project/proposal/deep_pu.tex", "max_forks_repo_name": "ZaydH/cis572", "max_forks_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.8047337278, "max_line_length": 1095, "alphanum_fraction": 0.7576301616, "num_tokens": 3520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6334102636778403, "lm_q1q2_score": 0.44291491928110444}}
{"text": "\\section{Monte Carlo Results}\\label{sec:2}\nThis section presents Monte Carlo experiments demonstrating that\nthis paper's modified version of \\citepos{ClW:07} statistic performs\nsimilarly to their original test in the situations they study, but can\nhave substantially higher power when the \\dgp\\ has a structural\nbreak.%\n\\footnote{All of these simulations were programmed in R\n  \\citep[version 2.14.0]{R} and use the \\allcaps{MASS}\n  \\citep[7.3-22]{VeR:02} package.} %\n\nThe \\dgp\\ has three different parametrizations: one to study the\ntests' size, one to study power under stationarity, and one to study\npower if there is a single break in the relationship between the\ntarget and predictors.  The \\dgp\\ is:\n\\begin{align*}\n  y_{t+1} &= \\gamma_{1t} + \\gamma_{2t} x_{t} + \\ep_{t+1} &\n  \\gamma_t &=\n  \\begin{cases}\n    (0.5, 0)    & \\text{size simulations} \\\\\n    (0.5, 0.35) & \\text{power (stable)} \\\\\n    (-0.5, 0)    & t \\leq \\tfrac{T}{2} \\quad \\text{power (break)} \\\\\n    (1, 0.35) & t > \\tfrac{T}{2} \\quad \\text{power (break)}\n  \\end{cases}\\\\\\nonumber\n  x_{t+1} &= 0.15 + 0.95 x_{t} + u_{t+1} &\n  (\\ep_t, u_t)' &\\sim iid\\ N\\Bigg(\\begin{pmatrix} 0 \\\\ 0\n  \\end{pmatrix}\n   , \\begin{pmatrix} 18 & -\n    0.5 \\\\ -0.5 & 0.025 \\end{pmatrix}\\Bigg)\n  \\\\ R &= 120, 240 & P &= 120, 240, 360, 720.\n\\end{align*}\nBoth models are estimated by \\ols. The benchmark model regresses $y_{t+1}$\non a constant, and the alternative regresses $y_{t+1}$ on a constant and\n$x_t$.  \\citet{ClW:07} argue that this \\dgp\\ mimics an asset\npricing application similar to \\citepos{GoW:08} which we study in\nSection~\\ref{sec:3}.\n\nFor comparison, we study this paper's new statistic as well as\n\\poscw\\ rolling-window and recursive-window test statistics.  Clark and West\nonly prove that their rolling-window statistic is asymptotically\nnormal, and only then if the benchmark model is not estimated, but\ntheir recursive-window statistic is popular in practice and in\nsimulations tends to perform similarly to their rolling window test.\nWe use all three of these statistics to test the null that the\nbenchmark model's innovation is an \\mds.%\n\\footnote{\\citet{ClW:07}\n  report the performance of the tests proposed by \\citet{CCS:01} and\n  \\citet{ClM:05} as well, and of tests based on the naive Gaussian\n  statistic.} %\n\n\\begin{table}[tb]\n  \\centering\n  \\input{tex/mc1}\n  \\caption{Size and power of the \\oos\\ tests in the simulations\n    described by Section~\\ref{sec:2}, at\n    \\testsize\\% confidence.  These percentages are calculated from \\totalsims\\\n    samples.  Pr[\\allcaps{CW} roll.] shows the fraction of simulations for\n    which Clark and West's (2007) rolling-window statistic rejects;\n    Pr[\\allcaps{CW} rec.] shows the fraction of simulations for which\n    their recursive-window statistic rejects; and Pr[new] shows the fraction of\n    simulations for which this paper's test rejects.}\n\\label{tab:mc1}\n\\end{table}\n\nTable~\\ref{tab:mc1} presents the simulation results.  For all of the\nstable parameter values, the proposed new statistic has similar\nrejection probability to \\citepos{ClW:07}.  Both of Clark and West's\ntests are generally slightly undersized relative to our new test,\nwhich is itself slightly undersized: when $R$ is 120 and $P$ is 360\nour test statistic has size 7.6\\% and Clark and West's rolling and\nrecursive window tests have size 7.5\\% and 6.2\\% respectively, at a\nnominal size of 10\\%.  For the stable alternative, our new statistic\ntypically has slightly higher power than Clark and West's rolling\nwindow and lower power than their recursive window.  For example, when\n$R$ is 120 and $P$ is 720, the rolling-window test rejects at 66.8\\%,\nour statistic at 73.0\\%, and the recursive window statistic at 82.3\\%,\nagain for a nominal size of 10\\%.  In general, the statistics perform\nsimilarly under stability.\n\nFor the simulations with a single break, the new statistic has\nconsiderably higher power than \\poscw\\ original tests across all of\nthe choices of $R$ and $P$; the rejection probability is more than\ntwice as large for most parametrizations.  When $R$ is 120 and $P$ is\n360 with a nominal size of 10\\%, for example, the new statistic\nrejects at 96.4\\% while the rolling and recursive window statistics\nreject at 35.5\\% and 32.9\\% respectively.  Results for other choices\nof nominal size and sample split give similar results.  So mixing\nwindow strategies can give a large power advantage when testing for\ntime-varying predictability, and performs similarly to the original\ntest when testing for stable outperformance.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"mixedwindow\"\n%%% TeX-command-extra-options: \"-shell-escape\"\n%%% End:\n", "meta": {"hexsha": "2098eef7a3ef5ab78504e52fb4d7acaada57bd10", "size": 4648, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "S3-montecarlo.tex", "max_stars_repo_name": "grayclhn-econ/mixedwindow", "max_stars_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "S3-montecarlo.tex", "max_issues_repo_name": "grayclhn-econ/mixedwindow", "max_issues_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2015-01-07T16:44:10.000Z", "max_issues_repo_issues_event_max_datetime": "2016-02-08T21:21:38.000Z", "max_forks_repo_path": "S3-montecarlo.tex", "max_forks_repo_name": "grayclhn-econ/mixedwindow", "max_forks_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.4166666667, "max_line_length": 79, "alphanum_fraction": 0.7336488812, "num_tokens": 1359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4429149192811044}}
{"text": "\\subsection{2-Opt Moves}\n\\subsubsection{Description of the Algorithm}\nThe main idea behind this algorithm is to construct the simply polygon\nby resolving the intersections.\n\n\\begin{enumerate}\n  \\item create segments from a random polygon\n  \\item calculate all intersections of segments\n  \\item iterate over all intersections\n\t\\begin{enumerate}\n    \\item choose a intersection\n    \\item remove all intersections where one of the two segments are\n      involved\n    \\item remove the segments from the intersection from the segments\n      list\n    \\item create new segments from those two segments\n    \\item calculate all intersection that occure by the new segments\n    \\item add the two segments to the segments list\n  \\end{enumerate}\n  \\item calculate the final list of the segments list\n\\end{enumerate}\n\n\\subsubsection{Implementation description}\n\\begin{enumerate}\n  \\item the creation of the segments is trivial\n  \\item the calculation of the intersections consists of two nested\n    loops over all segments. The important part is to have no\n    duplicates of intersections. This is implemented with a map and a\n    duplicate check. The map was choosen because of the O(log(n))\n    complexity to search and add elements.\n  \\begin{enumerate}\n    \\item the random function chooses the random intersection\n    \\item a for loop to iterate over the intersections and remove the\n      intersections which have one or both segments in common\n    \\item remove the segments from the segments list with a simple erase from\n      the vector class\n    \\item the creation of the new segments is difficult. The\n      difficulty is to reorder the segments in a way that the polygon\n      is still closed and does not decay in two independed polygons.\n      This is guaranteed by a creation of the polygon, the same as the\n      creation of the final polygon and to check if the size is equal\n      of the size of the segments list.\n    \\item the new intersections with the new segments are calculated\n      by a loop over all segments and a insert into the intersections\n      map.\n    \\item add the segments to the segments list\n  \\end{enumerate}\n  \\item to create the final list of the segments are two loops\n    necessary. the first loop builds two maps with a source -> target\n    combination as key -> value, both ends of the segments were added\n    as key respective value. The second map is necessary because a key\n    could be occure twice but only twice and therefore two maps. The\n    second loop iterates from 1 to N where N is the number of points\n    in the polygon and builds the polygon by moving from source to\n    target and to use the old target for the new source.\n\\end{enumerate}\n\n\\subsubsection{Complexity}\nThe implemented complexity is $\\bigO(n^2*log(n))$.\n\n\\subsubsection{Parameters}\n\\begin{description}\n  \\item [--nodes] how many nodes the polygon has to have. [default: 100]\n  \\item [--sampling-grid] the area within the polygon could grow. [default: 1500x800]\n\\end{description}\n\n\\subsubsection{Examples}\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw (1) -- (2) -- (3) -- (4) -- (5) -- (6) -- (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{Random polygon}\n    \\label{fig:tom:base}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[dotted] (1) -- (2);\n      \\draw[dotted] (3) -- (4);\n      \\draw[red] (1) -- (3);\n      \\draw[red] (2) -- (4);\n      \\draw (2) -- (3);\n      \\draw (4) -- (5) -- (6) -- (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{First step of resolving}\n    \\label{fig:tom:res1}\n  \\end{minipage}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[dotted] (2) -- (3);\n      \\draw[dotted] (4) -- (5);\n      \\draw[red] (3) -- (4);\n      \\draw[red] (2) -- (5);\n      \\draw (1) -- (3);\n      \\draw (4) -- (2);\n      \\draw (5) -- (6) -- (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{Second step of resolving}\n    \\label{fig:tom:res2}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[dotted] (2) -- (5);\n      \\draw[dotted] (6) -- (7);\n      \\draw[red] (2) -- (6);\n      \\draw[red] (5) -- (7);\n      \\draw (1) -- (3) -- (4) -- (2);\n      \\draw (6) -- (5);\n      \\draw (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{Third step of resolving}\n    \\label{fig:tom:res3}\n  \\end{minipage}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[dotted] (2) -- (5);\n      \\draw[dotted] (6) -- (7);\n      \\draw[red] (2) -- (7);\n      \\draw[red] (5) -- (6);\n      \\draw (1) -- (3) -- (4) -- (2);\n      \\draw (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{Wrong resolving, because of two reasons. First: two segments exists before. Second: the polygon is not more complete nor simple}\n    \\label{fig:tom:wrong}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(33,15),(10,20),(21,10),(39,22),(48,9),(20,41)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw (1) -- (3) -- (4) -- (2) -- (6) -- (5) -- (7) -- (1);\n    \\end{tikzpicture}\n    \\caption{Final simple polygon}\n    \\label{fig:tom:final}\n  \\end{minipage}\n\\end{figure}\n\n\\FloatBarrier\n", "meta": {"hexsha": "d2d1b3eb1618ef9a3cc0127fff9265929771ed9c", "size": 7040, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/two_opt_moves.tex", "max_stars_repo_name": "utnapischtim/polygon", "max_stars_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/two_opt_moves.tex", "max_issues_repo_name": "utnapischtim/polygon", "max_issues_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/two_opt_moves.tex", "max_forks_repo_name": "utnapischtim/polygon", "max_forks_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8971962617, "max_line_length": 141, "alphanum_fraction": 0.5934659091, "num_tokens": 2307, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.44291491754283274}}
{"text": "\\section{\\texorpdfstring{Repetition, NS hierarchy}{Repetition, NS hierarchy}}\n\\vspace{5mm}\n\\large\n\n\\subsection{Abbreviations}\n\\begin{itemize}\n\t\\item TM - turing machine.\n\t\\item DTM - deterministic turing machine.\n\t\\item NTM - non-deterministic turing machine.\n\t\\item DS - DSPACE\n\t\\item NS - NSPACE\n\t\\item PS - deterministic polynomial space\n\t\\item DT - DTIME\n\t\\item NT - NTIME\n\t\\item QBF - quantifiable boolean formula\n\t\\item CNF - conjunctive normal form\n\t\\item PH - polynomial hierarchy\n\t\\item PTM - Probabilistic TM\n\t\\item r.v. - Random variable\n\t\\item RP - Randomized Polynomial time\n\t\\item ZPP - Zero-error Probabilistic Polynomial time\n\\end{itemize}\n\n\\begin{theorem}[NT and DS relation]\\label{nt_ds_rel}\n\t\\[ \\forall f:\\N \\to \\N: NT(f(n)) \\subseteq DS(f(n)) \\]\n\\end{theorem}\n\n\\begin{proof}\nConstruct TM with following algorithm:\n\\begin{enumerate}\n\t\\item k = 1\n\t\\item do\n\t\\item foreach $y$ branch $|y| = k$\n\t\\item Simulate M(x) by $y$\n\t\\item If(Acc) accept\n\t\\item k++;\n\t\\item until all simulations of M(x) by $y$ that rejected\n\t\t// if all branches rejected $\\Rightarrow$ there is no accepting computation\n\t\\item reject\n\\end{enumerate}\n\nM works in time $g(n) = \\bigO(f(n))$, computation in step 4. will do at most g(n) steps.\n\nSpace:\\\\\n1) to store $k$ we need $g(n)$ of space, $ k \\leq g(n) $. \\\\\n2) To simulate $M(x)$ by $y$ we need $\\bigO(g(n))$ space.\n\nCorrectness: \\\\\nWe want constructed DTM to accept the same language as initial NTM.\nIf there is an accepting branch of NTM, DTM also accepts by some branch $y$.\nOtherwise we reach $k = g(n)$ and DTM rejects.\n\nTM cannot loop forever by the definition of time complexity (we restrict the languages to recursive).\n\nTechnical details:\\\\\nConstructed TM should have 2 tapes:\\\\\na) working tape\\\\\nb) tape to store $y$ (vector that encode branch of NTM)\n\\end{proof}\n\n\\begin{note}\n\tIf we are constrained to use single tape, any $k$ tape machine can be compressed to 1 tape machine. We need 2 steps:\n\n\\begin{enumerate}\n\t\\item compress $\\Sigma \\to \\Sigma^k$\n\t\\item How to deal with many heads of the original TM? $\\Rightarrow$ simulate 1 step of the original machine by many steps in new TM.\n\t\tIn total, time complexity is $\\bigO(n^2)$ and space complexity is $\\bigO(n)$.\n\\end{enumerate}\n\\end{note}\n\n\\begin{theorem}[NS and DT relation]\\label{ns_dt}\n\t\\[\\forall f:\\N \\to \\N, \\forall L \\in NS(f(n)) \\Rightarrow \\exists c_L: L \\in DT\\left(c_L^{f(n)}\\right) \\]\n\\end{theorem}\n\\begin{proof}\n\tAll accepting configuration leaves are bounded by the \\# of configurations. However, \\# of all paths $2^{c_L^{f(n)}}$.\n\tHow to avoid double exponent? $\\Rightarrow$ Perform BFS in configuration graph.\n\t\\# of edges could be quadratic , however\n\t\\[ \\left(c_L^{f(n)}\\right)^2 = \\left(c_L^2\\right)^{f(n)} \\]\n\t$c_L^2$ is another constant.\n\\end{proof}\n\n\\begin{definition}[Universal TM]\nInput: $(x,y)$, where $x$ is Godel number of TM to be simulated. $y$ is input of TM.\\\\\nAlphabet: $\\Sigma = \\{ 0, 1 \\} $.\\\\\nWorking tapes: 3\n\\begin{enumerate}\n\t\\item Tape with transition table of $M_x$.\n\t\\item Tape with current state $q$\n\t\\item Working tape\n\\end{enumerate}\nIf $S(n)$ is space used by $M_x \\Rightarrow$ we need $\\max(\\lceil \\log(t) \\rceil, S(n), |x|)$.\\\\\nTODO what is $t$?\n\\end{definition}\n\n\\begin{observation}\n\tIf initial TM has $k$ tapes and time complexity is $T(n)$ we can compress to 2 tapes with a cost of time complexity being $\\bigO(T(n) \\log(n))$. \\\\\n\t// TODO write proof (moving blocks on tape)\n\n\tTherefore simulating TM with multiple tapes could be reduces to 2 tapes, then simulate on Universal TM.\n\tTime complexity of Universal TM is dominated by finding the transition $\\Rightarrow \\bigO(|x| \\cdot T(n))$.\n\\end{observation}\n\n\\begin{definition}[Space constructible function]\n\tFunction $f$ is \\emph{Space constructible} $\\iff \\exists$ TM with unary alphabet which marks exactly $|f(n)|$ cells on the working tape. E.g. $\\log, e^x,$ polynomials.\n\\end{definition}\n\n\\begin{theorem}[Space hierarchy]\\label{s_hier}\n\tLet $S_1, S_2$ are space constructible functions and\n\t\\[ S_1 \\in o(S_2) \\Rightarrow DS(S_1(n)) \\subsetneq DS(S_2(n)) \\]\n\\end{theorem}\n\\begin{proof}\n\tConstruction by Cantor diagonalization method $\\Rightarrow$ find a language that is different from all in $\\bigO(S_1)$.\n\\end{proof}\n\n\\begin{definition}[Time constructible function]\n\tFunction $f$ is \\emph{Time constructible} $\\iff \\exists$ TM that does exactly $|f(n)|$ steps. You can think of it as alarm clock.\n\\end{definition}\n\n\\begin{observation}\n\tEvery time constructible function is space constructible.\n\\end{observation}\n\n\\begin{theorem}[Time hierarchy]\\label{t_hier}\n\tLet $S_1, S_2$ are time constructible functions and\n\t\\[ T_1 \\cdot \\log(T_1(n)) \\in o(T_2) \\Rightarrow DT(T_1(n)) \\subsetneq DT(T_2(n)) \\]\n\n\tNote that $\\log(T_1(n))$ is required because of $k$ to 2 tapes compression.\n\\end{theorem}\n\\begin{proof}\n\tConstruction by Cantor diagonalization method $\\Rightarrow$ find a language that is different from all in $\\bigO(T_1)$.\n\\end{proof}\n\n\\begin{theorem}[Savic]\\label{savic}\n\tUnder some mild assumptions $($space constructibility, functions bigger than $\\log(n))$ following statement is true:\n\t\\[ NS(f(n)) \\subseteq DS(f^2(n)) \\]\n\n\\end{theorem}\n\\begin{proof}\n\tFind a path in configuration path. We cannot use neither BFS not DFS as the complexity is linear in edges which is exponential comparing to input.\n\tTherefore we use recursive algorithm which for all states $K$ reachable by a path of length\n\t\\[ \\frac{c_L^{f(n)}}{2^i}\\]\n\ttries to find a path from $C_{init} \\to K \\to C_{accept}$.\n\n\tAs we divide path by 2 at every recursive call, recursion tree height is equal to $\\log_2(n)$.\n\tTherefore time complexity is\n\t\\[ \\log_2(c_L^{f(n)}) = f(n) \\cdot \\log_2(c_L) \\]\n\n\tOn each level of recursion we have to store $C_{init}, K, C_{accept}$ which requires $\\bigO(f(n))$ space.\n\tHaving $\\bigO(f(n))$ levels, total space complexity is $\\bigO(f^2(n))$.\n\\end{proof}\n\n\\begin{note}\n\tTime version of Savic would imply $P = NP$.\n\\end{note}\n\n\\subsection{NS hierarchy}\n\n% todo Cepek has kinda different proof\n\\begin{lemma}[Translation lemma]\\label{transl_space}\n\tLet $S_1(n), S_2(n), f(n)$ be space constructible functions, also\n\t\\[ S_2(n) \\geq n, f(n) \\geq n \\]\n\tThen\n\t\\[ NS(S_1(n)) \\subseteq NS(S_2(n)) \\Rightarrow NS(S_1(f(n))) \\subseteq NS(S_2(f(n))) \\]\n\n\tLemma allows to replace $n \\to f(n)$.\n\n\tWe can also prove Translation Lemma for $DS, NT, DT$.\n\\end{lemma}\n\\begin{proof}\n\tLet $L_1 \\in NS(S_1(f(n)))$ arbitrary, $L_1$ is recognized by NTS $M_1$ in space $S_1(f(n))$.\n\tWe want to prove that $L_1 \\in NS(S_2(f(n)))$ by constructing $L_2 \\in NS(S_1(n))$ using padding.\n\n\tDefine $L_2 := \\{ x\\triangle^i | M_1 $ accepts $x$ in space $S_1(|x| + i) \\} $.\n\tWhere $\\triangle$ is a new symbol, that $\\notin $ initial $\\Sigma$.\n\n\tAlgorithm of $M_2, L(M_2) = L_2$ on input $x\\triangle^i$ is the following:\n\\begin{enumerate}\n\t\\item Mark $S_1(|x| + i)$ cells on tape.\n\t\\item Simulate $M_1$.\n\t\\item if($M_1(x)$ accept $\\land$ did not use more space than marked in 1) then accept\n\\end{enumerate}\n\tFrom the construction, $M_2$ recognizes $L_2$ using $S_1(n)$ space.\n\tConsequently, $L_2 \\in NS(S_1(n))$.\n\tCombining with assumption of the lemma\n\t\\[ L_2 \\in NS(S_2(n)) \\]\n\tAnd there exists a TM $M_3$ that recognizes $L_2$ using $S_2(n)$ space.\n\n\tThe last step is to construct $M_4$ that recognizes $L_1$ using $S_2(f(n))$ space.\n\t$M_4$ has 2 working tapes and has following algorithm ($M_4$ on input $x$):\n\\begin{enumerate}\n\t\\item Mark $f(n)$ cells on 1st tape.\n\t\\item Mark $S_2(f(n))$ cells on 2nd tape. Using 1st tape as \"input\".\n\t\\item foreach $x\\triangle^i, i = 0, 1, \\ldots $ \\\\\n\t\tsimulate $M_3$ on input $x\\triangle^i$.\n\t\tIf head of $M_3$ is inside $x$ $M_4$s head is in the same place.\n\t\tOtherwise, head of $M_3$ is inside padding, so $M_4$ uses counters to track $M_3$s position.\n\t\tCounter has length at most $1 + \\log i$.\n\t\\item if($M_3(x)$ accept) then $M_4$ accept.\n\t\\item else if($1 + \\log(i) \\leq S_2(f(n))$) then $++i$; \\\\\n\t\tCounter did not overflow and is less than $S_2(f(n))$.\n\t\\item else if($1 + \\log(i) > S_2(f(n))$) then reject;\n\\end{enumerate}\n\nIf $M_4$ accepted input $x$, $M_3$ accepted $x\\triangle^i$ for some $i \\Rightarrow x\\triangle^i \\in L_2 \\Rightarrow M_1$ accepts $x \\Rightarrow x \\in L_1$.\n\nOn the other hand, if $x \\in L_1 \\Rightarrow x\\triangle^i \\in L_2$ for $i = f(|x|) - |x|$ therefore counter $i$ requires\n\\[ \\log(f(|x|) - |x|) \\leq S_2(f(|x|)) \\]\nspace.\n\n\\end{proof}\n\n\\begin{theorem}[NS hierarchy for polynomials]\n\tLet $\\varepsilon > 0,\\, r > 1$. Then\n\t\\[ NS(n^r) \\subsetneq NS(n^{r + \\varepsilon}) \\]\n\\end{theorem}\n\\begin{proof}\n\tFrom the density of rationals:\n\t\\[ \\exists s,t \\in \\N: r \\leq \\frac{s}{t} \\leq \\frac{s + 1}{t} \\leq r + \\varepsilon \\]\n\tIt is sufficient to prove that:\n\t\\[ NS(n^{\\frac{s}{t}}) \\subsetneq NS(n^{\\frac{s + 1}{t}}) \\]\n\n\tAssume by contradiction\n\t\\[ NS(n^{\\frac{s+1}{t}}) \\subseteq NS(n^{\\frac{s}{t}}) \\]\n\tNow we use \\cref{transl_space} for\n\t\\[ S_1 = n^{\\frac{s+1}{t}}, S_2 = n^{\\frac{s}{t}}, f(n) = n^{(s + i)t}, i = 0, 1 \\ldots, t \\]\n\\begin{note}\n\\begin{note}\n\\end{note}\n\n\\end{note}\n\n\tWe get\n\t\\[ \\forall i: NS((n^{(s + i)t})^{(s + 1)/t}) \\subseteq NS((n^{(s + i)t})^{s/t}) \\Rightarrow \\forall i: NS(n^{(s + i)(s + 1)}) \\subseteq NS(n^{(s + i)s}) \\]\n\tNow we write for all $i$:\n\t\\begin{itemize}\n\t\t\\item $i = 0:\\, NS(n^{s(s + 1)}) \\subseteq NS(n^{s^2}) $\n\t\t\\item $i = 1:\\, NS(n^{(s + 1)(s + 1)}) \\subseteq NS(n^{(s + 1)s}) $\n\t\t\\item \\ldots\n\t\t\\item $i = s:\\, NS(n^{2s(s + 1)}) \\subseteq NS(n^{(2s)s}) $\n\t\\end{itemize}\n\tFrom the exponents we conclude that for every inequality right side is a subset of left side.\n\tSo we get a chain of subsets and can use Savic theorem to get a contradiction:\n\t\\[ NS(n^{(s + 1)2s}) \\subseteq NS(n^{s^2}) \\stackrel{Savic}{\\subseteq} DS(n^{2s \\cdot s}) \\stackrel{space H}{\\subsetneq} DS(n^{2s \\cdot s + 2s}) \\subseteq NS(n^{2s(s + 1)}) \\]\n\tAs the beginning and the end are the same sets and the chain of subsets has strict inclusion.\n\n\\end{proof}\n", "meta": {"hexsha": "ff71200c9ea51df8ee9a96266a302a2aec245324", "size": 9929, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/prednasky/01_prednaska.tex", "max_stars_repo_name": "karlov/NTIN063", "max_stars_repo_head_hexsha": "cb69e2889ce8374c64aa6ac9faf64ad1ab01add7", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/prednasky/01_prednaska.tex", "max_issues_repo_name": "karlov/NTIN063", "max_issues_repo_head_hexsha": "cb69e2889ce8374c64aa6ac9faf64ad1ab01add7", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prednasky/01_prednaska.tex", "max_forks_repo_name": "karlov/NTIN063", "max_forks_repo_head_hexsha": "cb69e2889ce8374c64aa6ac9faf64ad1ab01add7", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1983805668, "max_line_length": 176, "alphanum_fraction": 0.6754960218, "num_tokens": 3353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7520125848754471, "lm_q1q2_score": 0.44285203743377255}}
{"text": "\\section{Fission probability calculation.}\n\n\\hspace{1.0em}The fission decay channel (only for nuclei with $A > 65$)\nis taken into account as a competitor for fragment and photon evaporation\nchannels.\n\n\\subsection{The fission total probability.}\nhspace{1.0em}The fission probability (per uni time) $W_{fis}$ \nin the Bohr\nand Wheeler theory of fission \\cite{BW39} is proportional to the level\ndensity $\\rho_{fis}(T)$ ( approximation Eq. ($\\ref{SFE13}$) is used) at\nthe saddle point, i.e.\n\\begin{equation}\n\\begin{array}{c}\n\\label{FP1}W_{fis}=\\frac{1}{2\\pi \\hbar \\rho_c(U_c)}\\int_{0}^{U_f-B_{fis}}\n\\rho_{fis}(U_f-B_{fis}-T)dT =\\\\\n=\\frac{1 + (C_f - 1)\\exp{(C_f)}}{4\\pi a_{fis} \\exp{(2\\sqrt{a_cU_c})}},\n\\end{array}\n\\end{equation}\nwhere $U_f= E^{*} - \\Delta_f$ and pairing energy\n\\begin{equation}\n\\label{FP2} \\Delta_{f} = \\kappa \\frac{14}{\\sqrt{A}} \\ [MeV]\n\\end{equation} \nIn Eq. ($\\ref{FP1}$)  $B_{fis}$ is the fission barrier height.\nThe value of $C_f = 2\\sqrt{a_{fis}(U_f - B_{fis})}$ and $a_c$, $a_{fis}$ are \nthe level density parameters of the compound and of the fission saddle point\nnuclei, respectively.\n\nThe value of the level density parameter is large at the saddle point,\nwhen excitation energy is given by initial excitation energy minus the\nfission barrier height, than in the ground state, i. e. $a_{fis} > a$.\n$a_{fis} = 1.08 a$ for $Z < 85$, $a_{fis} = 1.04 a$ for $Z \\geq 89$ and\n$a_f=a[1.04+0.01(89.-Z)]$ for $85 \\leq Z < 89$ is used.\n \n\\subsection{The fission barrier.}\n\n\\hspace{1.0em}\nThe fission barriers are determined as differences \nbetween the saddle-point and\n ground state masses. In the general case fission barriers are functions \n of the charge $Z$, atomic mass number $A$, excitation energy of fissioning \n nuclei $E^{*}$ and their angular momenta $L$ and their deformations \n $\\alpha$. \n \n Shell structure effects play a role at the fission\nbarrier. The height of fission barrier can be aprroximated as\n\\begin{equation}\n\\label{FP3}B_{fis} = B^{0}_{fis} + \\Delta_{Shell} + \\Delta_{SP},\n\\end{equation}\nwhere $B^{0}_{fis}$ is the so-called liquid drop component of the\nfission barrier, $\\Delta_{Shell}$ is the shell correction to the mass of a\nnucleus in the ground state and $\\Delta_{SP}$ is the shell correction to\nthe mass of nucleus in the saddle point.  The last correction is very\nimportant for actinide nuclei. It leads to a double-humped shape of the\nfission barrier.\n \nThere are many models for fission barriers: the phenomenological approach \nof Barashenkov et al. \\cite{Barash73}, the semiphenomenological \napproach of Barashenkov and Gereghi \\cite{Barash77}, the liquid-drop model (LDM) \nwith Myers and Swiatecki's parameters \\cite{MS67}, the LDM with Pauli and Ledergerber's \n parameters \\cite{PG71}, the single-Yukawa modified LDM of Krappe and Nix \n \\cite{KN73}, the Yukawa-plus-exponential modified LDM \\cite{KNS79}, the subroutine \n BARFIT of Sierk \\cite{Sierk86} which provides macroscopic fission barriers of \n rotating nuclei in the Yukawa-plus-exponential modified LDM \\cite{KNS79}, \n double-humped fission barriers for transuranium nuclides as proposed in \n \\cite{KIF80}, giving a fixed \n input value for single-humped fission barriers $B_{fis}$ \n and giving fixed input values $B^A_{fis}$ and $B^B_{fis}$ for \n double-humped fission barriers.\n  \nWe use simple semiphenomenological \napproach was suggested by Barashenkov and Gereghi \\cite{Barash77}. In their \napproach fission barriers $B_{fis}(A,Z)$ are approximated by \n\\begin{equation}\n\\label{FP4} B_{fis} = B^{0}_{fis} + \\Delta^{C}_{Shell}  + \\Delta^{C}_{Pair} + \n\\delta(A,Z),\n\\end{equation}\nwhere shell and pairing corrections  for Cameron's\nliquid drop mass formula \\cite{CAM57}. $\\delta(A,Z) = 0$ for even $Z$ \nand even $N = A - Z$, $\\delta(A,Z) = 1.248$ \\ MeV for odd $A$ and \n$\\delta(A,Z) = 2.496$ \\ MeV for odd $Z$ and odd $N$ were suggested.\n\nAccording to this prescription fission barrier heights $B^{0}_{fis}(x)$\nvary with the fissility parameter $x$. $B^{0}_{fis}(x)$ is\ngiven by\n\\begin{equation}\n\\label{FP5} B^{0}_{fis}(x) = a_{S}A^{2/3} 0.83(1 - x)^3\n\\end{equation}\nfor $2/3 \\leq x \\leq 1$ and\n\\begin{equation}\n\\label{FP6} B^{0}_{fis}(x) =a_{S}A^{2/3} 0.38(3/4 -x)\n\\end{equation}\nfor $1/3 \\leq x \\leq 2/3$. \nThe fissility parameter $x$ is given by\n\\begin{equation}\n\\label{FP7} x = \\frac{E^0_C}{2E^0_S}= \\frac{(a_C/2a_S)Z^2/A}\n{\\{1 - k[(N-Z)/A]^2\\}},\n\\end{equation}\nwhere $E^{0}_C$ and $E^{0}_S$ are the Coulomb and surface energies of \na spherical nucleus, respectively.\n\nThe liquid drop model parameters $a_S = 17.9439$\\ MeV, $a_C=0.7053$ \\ MeV \nand $k = 1.7826$ taken from \\cite{CS63} paper.\n\nThe fission barrier heights are functions of the excitation energy. We use the \nempirical relation proposed by \\cite{Barash73} to estimate the dependence of \n$B_{fis}$ on $E^{*}$:\n\\begin{equation}\n\\label{FP8} B_{fis}(E^{*}) =\\frac{B_{fis}}{1+\\sqrt{(\\frac{E^{*}}{2A})}}.\n\\end{equation} \n", "meta": {"hexsha": "1699271840f76e6d429646aa4ce67fdb1aede8c4", "size": 4893, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant4/hadronic/theory_driven/Evaporation/FissionProbability.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant4/hadronic/theory_driven/Evaporation/FissionProbability.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant4/hadronic/theory_driven/Evaporation/FissionProbability.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0810810811, "max_line_length": 88, "alphanum_fraction": 0.7106069896, "num_tokens": 1685, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4428520243420015}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n%\\usepackage[ddmmyyyy]{datetime} \n\\usepackage[short,nodayofweek,level,12hr]{datetime} \n%\\usepackage{cite}\n%\\usepackage{wrapfig}\n%\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\n\\newcommand{\\e}{\\epsilon}\n\\newcommand{\\dl}{\\delta}\n\\newcommand{\\pd}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\describe}[2]{\\underbrace{#2}_{\\text{#1}}}% \\describe{}{} - First bracket is for description \n%\\describe{$\\substack{this \\ is \\ substacking}$}{b} - To split the description over multiple lines\n\\newcommand{\\vect}[1]{\\underline{#1}}\n\\newcommand{\\uvect}[1]{\\hat{#1}}\n\\newcommand{\\1}{\\vect{1}}\n\\newcommand{\\grad}{\\nabla}\n\\newcommand{\\curl}[1]{\\nabla\\wedge\\vect{#1}}\n\\newcommand{\\divg}[1]{\\nabla\\cdot\\vect{#1}}\n\\newcommand{\\RA}{\\Rightarrow}\n\\newcommand{\\DX}{\\Delta(\\vect X)}\n\\newcommand{\\DXp}{\\Delta(\\vect X')}\n\\newcommand{\\X}{\\vect X}\n\\newcommand{\\Xp}{\\vect X'}\n\\newcommand{\\smalltag}[1]{\\tag{\\footnotesize{#1}}}\n\n\\title{Lecture 30: Lift due to Potential Flows in 2D}\n\\date{\\displaydate{date}}\n\\newdate{date}{01}{11}{2018}\n\\author{}\n\n\\begin{document}\n\\maketitle\n\n\\section*{overview}\nLift on an aerofoil occurs due to a net circulation associated with the aerofoil. Potential flow theory can be used to determine the flow field and hence the lift associated with the aerofoil under a given uniform flow.\n\n\\section{Flow around a circular cylinder with circulation}\n\nThe complex potential for flow around a translating circular cylinder (with velocity $U$) with a given circulation ($\\kappa$) is \n\\begin{align*}\n&F(z) = \\describe{translation}{U\\bigg( z + \\frac{a^2}{z}\\bigg)} - \\describe{circulation}{\\frac{i\\kappa}{2\\pi}\\log z}\n\\end{align*}\nLet the real part of this complex potential be the velocity potential $\\Phi$\n\\begin{align*}\n&\\Phi  = Ur\\cos\\phi\\bigg(1+\\frac{a^2}{r^2} \\bigg) + \\frac{\\kappa \\phi}{2\\pi}\\\\\n\\RA& u_\\phi\\Big|_{r=a} = \\frac{\\kappa}{2\\pi a} - U \\sin\\phi\n\\end{align*}\nThis is the velocity field in the frame of reference of the moving cylinder. Now we want to find out the stagnation points of this flow. For $\\kappa = 0$, they lie at $\\phi = 0, \\pi$ (as can be seen from the expression for $u_\\phi$). In the presence of circulation, however, the stagnation points move closer and eventually merge and move into the fluid giving rise to homoclinic-type streamlines. It must be noted that vortex opposes the uniform flow on one side of the cylinder, and strengthens it on the other side. This difference in velocities leads to a pressure gradient in accordance with Bernoulli's theorem. This is the lift force. \n\n\\section{Flow around a translating elliptic cylinder with circulation}\n\nThe complex potential for this case is given by \n\\begin{align*}\n&W(\\zeta) = U\\bigg(\\zeta e^{-i\\alpha} + \\frac{(a+b)^2}{4\\zeta} e^{i\\alpha}\\bigg) - \\frac{i\\kappa}{2\\pi} \\log\\zeta\n\\end{align*}\nThis is the potential for a circular cylinder. Using the conformal mapping\n\\begin{align*}\n&\\zeta = \\frac{1}{2}(z+\\sqrt{z^2-c^2}), \\tag{$c^2 = a^2 - b^2$}\n\\end{align*}\nwe map it to an ellipse. This gives us the complex potential in the $t (=t_1+it_2)$ plane\n\\begin{align*}\n&\\tilde{w}(t) =\\\\\n& \\frac{U}{2}\\bigg(c (\\cosh t + \\sinh t) e^{-i\\alpha} + (a+b)^2\\frac{e^{i\\alpha}}{c} (\\cosh t - \\sinh t)\\bigg) - \\frac{i\\kappa}{2\\pi}\\log(\\cosh t + \\sinh t)\n\\end{align*}\nFrom this potential, we can evaluate the tangential velocity at the surface of the ellipse given by $\\frac{d\\tilde{w}(t)}{dt}$ @ $t=t_{1_0} + it_2$\n\\begin{align*}\n&\\frac{d\\tilde{w}(t)}{dt} = iUc\\bigg(e^{t_{1_0}}\\sin(t_2-\\alpha) - \\frac{\\kappa}{2\\pi c U} \\bigg)\n\\end{align*}\nThe behaivour of stagnation points and corresponding change in the lift force as the circulation is increased from zero, is similar to the case of the sphere. When circulation is zero, the stagnation points are located at $\\pi \\pm \\alpha$. As circulation is increased, the points move closer to each other. Consider now, a thin ellipse $t_{1_0} = 0$. Potential flow rounds the edges of such a shape with infinite velocity. As circulation is increased, one of the stagnation point eventually reaches the edge at $t_2 = 0$. Thus velocity at the trailing edge becomes finite and we get a net lift force due to the circulation associated with the thin cylinder. \n\n\n\\section{Appendix}\n\\subsection{Potential flow in multiply connected domain}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n\n\n\n", "meta": {"hexsha": "64058fb6b24bd76db6ca1a7136f7578ee6ff1d40", "size": 4455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex_files/lecture30.tex", "max_stars_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_stars_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-16T04:19:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-16T04:19:07.000Z", "max_issues_repo_path": "tex_files/lecture30.tex", "max_issues_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_issues_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex_files/lecture30.tex", "max_forks_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_forks_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8365384615, "max_line_length": 658, "alphanum_fraction": 0.7173961841, "num_tokens": 1420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.4428520243420015}}
{"text": "\\documentclass{beamer}\n\n\\mode<presentation>\n{\n  \\usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...\n  \\usecolortheme{default} % or try albatross, beaver, crane, ...\n  \\usefonttheme{default}  % or try serif, structurebold, ...\n  \\setbeamertemplate{navigation symbols}{}\n  \\setbeamertemplate{caption}[numbered]\n} \n\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\setlength\\tabcolsep{1.5pt}\n\n\\begin{document}\n\\frame{\n\\frametitle{Contents}\n\\tableofcontents\n}\n\n\\section{Estimation from a damage function}\n\\frame{\n\\frametitle{Introductory thoughts}\n\n\\begin{itemize}\n\\item The impact of CO$_2$ on impacts has a much shorter half-life than of CO$_2$ in the atmosphere because of adaptation-- but we know exactly how long that timescale is: a Bartlett kernel-weighted 30 years.\n\\item The impact of a step change in temperature produces a short-term effect, in the immediate year, and a long-term effect, 30 years later.\n\\item The damage function we estimate for IAMs should incorporate this transition, both in its estimation and in the information we provide to IAMs.\n\\end{itemize}\n}\n\n\\frame{\n\\frametitle{A model of impacts}\n\nChanges in CO$_2$ leads to changes in temperature according to a scientifically assumed transfer function, $p_t = (1 - e^{-t / 2.8}) e^{-t / 400}$: $T_t = C_t \\ast p_t$.  (Throughout, $\\ast$ is the convolution operator.)\n\nAssume that impacts are generated by\n\\[\ny_t = \\left[f(T_t) - a (f(T_t) \\ast b_t)\\right] (\\text{GDPpc}_t)^\\gamma\n\\]\n\\begin{itemize}\n\\item $f(T_t)$ is an instantaneous damage function, generally of the form $\\beta_1 T_t + \\beta_2 T_t^2$.\n\\item $b_t$ is the Bartlett kernel, and $a$ is the degree of temperature-driven adaptation.\n\\item The last term provides a measure of elasticity of damages with income.\n\\end{itemize}\n}\n\n\\frame{\n\\frametitle{Estimated damage function}\n\n\\includegraphics[width=\\textwidth]{damagefunc2.pdf}\n}\n\n\\frame{\n\\frametitle{Bayesian fitted parameters}\n\n\\includegraphics[width=\\textwidth]{bayes.pdf}\n}\n\n\n\\frame{\n\\frametitle{Results}\n\n\\begin{tiny}\n\\begin{tabular}{lllrrrrrrrr}\nRCP & SSP & Monetization & 0 & 0.01 & 0.02 & 0.03 & 0.04 & 0.05 & 0.06 & 0.07 \\\\\n4.5 & SSP4 & VSL ag02 popavg & 49.765215 & 20.090173 & 11.188628 & 7.319126 & 5.2335889 & 3.9565314 & 3.1067942 & 2.5073709 \\\\\n4.5 & SSP4 & VSLY popavg & 27.076281 & 11.585834 & 6.923858 & 4.851441 & 3.7002694 & 2.9724734 & 2.4727046 & 2.1093082 \\\\\n4.5 & SSP4 & VSLY scaled & 4.846833 & 2.353378 & 1.527805 & 1.128928 & 0.8938308 & 0.7389402 & 0.6293463 & 0.5477955 \\\\\n4.5 & SSP4 & VSL ag02 scaled & 10.848195 & 5.175614 & 3.320996 & 2.429363 & 1.9066906 & 1.5647519 & 1.3247003 & 1.1474737 \\\\\n4.5 & SSP5 & VSL ag02 popavg & 22.639750 & 12.790459 & 9.110520 & 7.113661 & 5.8206464 & 4.9042500 & 4.2186996 & 3.6866908 \\\\\n4.5 & SSP5 & VSLY popavg & 11.801313 & 7.208263 & 5.423449 & 4.413440 & 3.7358821 & 3.2413275 & 2.8619107 & 2.5608733 \\\\\n4.5 & SSP5 & VSLY scaled & 3.848509 & 2.133306 & 1.521382 & 1.197915 & 0.9917263 & 0.8470242 & 0.7393777 & 0.6560325 \\\\\n4.5 & SSP5 & VSL ag02 scaled & 11.471691 & 5.608791 & 3.721099 & 2.799517 & 2.2450104 & 1.8726067 & 1.6050818 & 1.4037624 \\\\\n8.5 & SSP4 & VSL ag02 popavg & 112.962731 & 41.333858 & 21.802857 & 13.955777 & 9.9695436 & 7.6319429 & 6.1235417 & 5.0814877 \\\\\n8.5 & SSP4 & VSLY popavg & 54.144549 & 20.820391 & 11.622419 & 7.842783 & 5.8696309 & 4.6790999 & 3.8891723 & 3.3288767 \\\\\n8.5 & SSP4 & VSLY scaled & 10.365246 & 4.535453 & 2.715188 & 1.892462 & 1.4381250 & 1.1560006 & 0.9663930 & 0.8312908 \\\\\n8.5 & SSP4 & VSL ag02 scaled & 22.627928 & 10.012589 & 5.961467 & 4.101235 & 3.0711859 & 2.4350453 & 2.0115973 & 1.7132506 \\\\\n8.5 & SSP5 & VSL ag02 popavg & 43.699053 & 21.802650 & 14.734155 & 11.293759 & 9.2161600 & 7.8077671 & 6.7840025 & 6.0041636 \\\\\n8.5 & SSP5 & VSLY popavg & 20.489387 & 11.096381 & 7.938798 & 6.331466 & 5.3222833 & 4.6156765 & 4.0879440 & 3.6765711 \\\\\n8.5 & SSP5 & VSLY scaled & 6.789311 & 3.387298 & 2.244069 & 1.682805 & 1.3488154 & 1.1277918 & 0.9711668 & 0.8546137 \\\\\n8.5 & SSP5 & VSL ag02 scaled & 19.423931 & 8.974785 & 5.584819 & 3.984682 & 3.0697847 & 2.4871389 & 2.0886172 & 1.8013216 \\\\\n\\end{tabular}\n\\end{tiny}\n}\n\n\\frame{\n\\frametitle{Calculating an SCC (one slide for MG)}\n\n\\begin{enumerate}\n\\item We estimate a global damage function: total monetized costs as they vary with temperature change from the baseline.\n\\begin{center}\\includegraphics[width=.6\\textwidth]{damagefunc2.pdf}\\end{center}\n\\item The damage function includes the effect of temperature adaptation (minor here) and income adaptation (huge).\n\\item We calculate $(A)$ costs for each year according to an RCP scenario, and $(B)$ costs for a 1 tonne boost in 2017 above that scenario.\n\\item The SCC is the present discounted value of $(B) - (A)$.\n\\end{enumerate}\n}\n\n\\section{Reduced-form estimation}\n\\frame{\n\\frametitle{Calculating an SCC}\nLet $x_t$ be a stream of CO$_2$ emissions and $y_t$ be the stream of impacts.\n\nLet $f(t)$ be an impulse response function which describes how a single GT jump in CO$_2$ produces a stream of impacts.  Then, $y_t = x_t \\ast f(T)$, the result of a convolution.\n\n\\begin{enumerate}\n\\item We assume that each unit increase in CO2 has an impact that starts near 0, rises rapidly, and slowly decays.  It also varies with average global temperature $T$.\n\\item The entire stream of impacts from CO2 is the just the sum of scaled and translated copies of this impulse response.\n\\item We calculate the coefficients that define that impulse response.\n\\item We calculate the NPV of the impulse response.\n\\end{enumerate}\n}\n\n\\frame{\n\\frametitle{A proposed structural form}\n\nSuppose that $f(T) = \\sum_{k=0}^K \\left(\\beta_{k0} + \\beta_{k1} T\\right) t^k e^{-t / \\tau}$, where $\\tau$ is the residence time of CO$_2$ in the atmosphere, 400 yr under IPCC or 77 yr under DICE.\n\nThen,\n\\begin{align*}\ny_t &= \\alpha + \\sum_{s=0}^\\infty x_{t - s} \\sum_{k=0}^K \\left(\\beta_{k0} + \\beta_{k1} T_{t-s}\\right) s^k e^{-s / \\tau} + \\epsilon_t \\\\\n&= \\alpha + \\sum_{k=0}^K \\beta_{k0} \\sum_{s=0}^\\infty x_{t - s} s^k e^{-s / \\tau} + \\sum_{k=0}^K \\beta_{k1} \\sum_{s=0}^\\infty x_{t - s} T_{t-s} s^k e^{-s / \\tau} + \\epsilon_t\n\\end{align*}\n \nThis is just a weighted sum of recent CO$_2$ emissions as the predictors for a regression.\n}\n\n\\frame{\n\\frametitle{Calculating an SCC}\nWe are interested in the discounted sum of impacts.  This can be calculated as,\n\n\\begin{align*}\nSCC_t &= \\sum_{u = 0}^\\infty e^{-\\delta u} y_{u}(\\delta_u) \\\\\n&= \\sum_{u = 0}^\\infty e^{-\\delta u} \\left[\\sum_{k=0}^K \\beta_{k0} \\sum_{s=0}^\\infty \\mathbf{1}\\{u-s = 0\\} s^k e^{-s / \\tau} +\\right. \\\\\n&\\hspace{6em} \\left.\\sum_{k=0}^K \\beta_{k1} \\sum_{s=0}^\\infty \\mathbf{1}\\{u-s = 0\\} T_{u-s} s^k e^{-s / \\tau}\\right] \\\\\n&= \\sum_{u = 0}^\\infty e^{-\\delta u} \\left[\\sum_{k=0}^K \\beta_{k0} u^k e^{-u / \\tau} + \\sum_{k=0}^K \\beta_{k1} T_t u^k e^{-u / \\tau}\\right] \\\\\n\\end{align*}\n}\n\n\n\\end{document}\n", "meta": {"hexsha": "791b7791509d4e22e7965d07844d83df02383275", "size": 6863, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gcp/scc/docs/main.tex", "max_stars_repo_name": "dylanhogan/prospectus-tools", "max_stars_repo_head_hexsha": "662b2629290cd27c74cd34769773e0d6e73c7048", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-01-26T05:52:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-28T20:18:37.000Z", "max_issues_repo_path": "gcp/scc/docs/main.tex", "max_issues_repo_name": "dylanhogan/prospectus-tools", "max_issues_repo_head_hexsha": "662b2629290cd27c74cd34769773e0d6e73c7048", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 33, "max_issues_repo_issues_event_min_datetime": "2016-01-20T04:24:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-16T18:53:16.000Z", "max_forks_repo_path": "gcp/scc/docs/main.tex", "max_forks_repo_name": "dylanhogan/prospectus-tools", "max_forks_repo_head_hexsha": "662b2629290cd27c74cd34769773e0d6e73c7048", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2016-01-20T02:17:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-07T21:24:10.000Z", "avg_line_length": 47.993006993, "max_line_length": 220, "alphanum_fraction": 0.6864345039, "num_tokens": 2628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.44281245645342815}}
{"text": "\\documentclass[12pt,leqno]{amsart}\n\\usepackage{amsmath,amssymb,amsfonts,amsthm}\n\\usepackage{eucal,graphicx}\n\\usepackage{color}\n\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\oddsidemargin}{0.0in}\n\\setlength{\\evensidemargin}{0.0in}\n\\setlength{\\textheight}{9in}\n\\setlength{\\topmargin}{-.4in}\n\n%\\renewcommand{\\baselinestretch}{2}     % Activate for double spacing.\n%\\renewcommand{\\baselinestretch}{1.6}   % Activate for 1-1/2 spacing.\n%\\renewcommand{\\baselinestretch}{1.3}   % Activate for 1-1/3 spacing.\n\n\n\\newcommand \\comment[1]{}\t\t\t%  Silent version.\n%\\renewcommand \\comment[1]{\\emph{#1}}\t\t%  Comment revealed.\n\\newcommand \\dateadded[1]{\\comment{[Date added: #1.]}}\n\\newcommand \\mylabel[1]{\\label{#1}\\comment{{\\rm \\{#1\\} }}}\n\\newcommand \\myref[1]{\\ref{#1}\\comment{{\\{#1\\}}}}\n\n\\newtheorem{lem}{Lemma}\n\\newtheorem{cor}[lem]{Corollary}\n\\newtheorem{prop}[lem]{Proposition}\n\\newtheorem{thm}[lem]{Theorem}\n\\newtheorem{definition}[lem]{Definition}\n\n\n\\theoremstyle{remark}\n\\newtheorem{exam}{Example}%[section]\n\\newcommand \\myexam[1]{\\smallskip\\begin{exam}[\\emph{#1}]}\n\n\\renewcommand{\\phi}{\\varphi}\n\\newcommand\\eset{\\varnothing}\n\\newcommand\\inv{^{-1}}\n\\newcommand\\setm{\\setminus}\n\\newcommand\\chiz{\\chi^\\bbZ}\n\\newcommand\\bbR{\\mathbb{R}}\n\\newcommand\\bbZ{\\mathbb{Z}}\n\\newcommand\\cH{\\mathcal{H}}\n\n\n\\newcommand\\Ueloop{\\ensuremath{U^e_{0}}}\n\\newcommand\\Uecoloop{\\ensuremath{U^e_{1}}}\n\\newcommand\\Uefdyad{\\ensuremath{U^{ef}_{1}}}\n\\newcommand\\Uefgtriad{\\ensuremath{U^{efg}_{1}}}\n\\newcommand\\Uefgtriangle{\\ensuremath{U^{efg}_{2}}}\n\n%   Disjoint Union\n%\\newcommand{\\dunion}{\\uplus}\n\\newcommand{\\dunion}\n%{\\mbox{\\hbox{\\hskip4pt$\\cdot$\\hskip-4.62pt$\\cup$\\hskip2pt}}}\n{\\mbox{\\hbox{\\hskip6pt$\\cdot$\\hskip-5.50pt$\\cup$\\hskip2pt}}}\n%\n% Dot inside a cup.\n% If there is a better, more Latex like way \n% (more invariant under font size changes) way,\n% I'd like to know.\n\n\n\\newcommand{\\Bases}[1]{\\ensuremath{{\\mathcal{B}}(#1)}}\n\\newcommand{\\Reals}{\\ensuremath{\\mathbb{R}}}\n\\newcommand{\\FieldK}{\\ensuremath{K}}\n\\newcommand{\\Perms}{\\ensuremath{\\mathfrak{S}}}\n\\newcommand{\\rank}{{\\rho}}% {{\\mbox{rank}}}\n\\newcommand{\\Rank}{{\\rho}}% {{\\mbox{rank}}}\n\\newcommand{\\Card}[1]{\\ensuremath{{\\left|#1\\right|}}}\n\\newcommand{\\ext}[1]{\\ensuremath{\\mathbf{#1}}}\n\n% Set Complement\n% command to mess with overline, bar or custom \n% alternatives for sequence or set complement\n%\n%\\newcommand{\\scomp}[1]{\\ensuremath{\\;\\overline{#1}\\;}}\n%\\newcommand{\\scomp}[1]{\\ensuremath{\\bar{#1}}}\n%\\newcommand{\\scomp}[1]{\\ensuremath{\\genfrac{}{}{}{}{}{#1}}}\n\\newcommand{\\scomp}[1]{\\ensuremath{\\overline{#1}}}\n\n\\allowdisplaybreaks\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{document}\n\n\\title{Some Ported, Relative, or Set Pointed Parametrized Tutte Functions}\n\n\\author{Seth Chaiken}\n\\address{Computer Science Department\\\\\nThe University at Albany (SUNY)\\\\\nAlbany, NY 12222, U.S.A.}\n\\email{\\tt sdc@cs.albany.edu}\n\n\n\n\\begin{abstract}\nTutte decompositions with deletion and contraction not done of elements\nin a fixed set of ports $P$, and the \nresulting polynomial expressions and functions\nfor matroids, oriented matroids, graphs and an abstraction of\nlabelled graphs are investigated.\nWe give conditions on parameters $x_e$, $y_e$, $X_e$, $Y_e$ for $e\\not\\in P$,\nand on initial values $I(Q)$ for indecomposibles, that are necessary and \nsufficient for the following equations to have a well-defined solution:\n$T(M)=X_e T(M/e)$ for coloops $e\\not\\in P$, \n$T(M)=Y_e T(M\\setminus e)$ for loops $e\\not\\in P$, and\n$T(M)=x_e T(M/e) + y_e T(M\\setminus e)$ for other $e\\not\\in P$.   They\ngeneralize similar conditions given by Bollob\\'{a}s and Riordon, Zaslavsky,\nand Ellis-Monaghan and Traldi for Tutte functions defined without the\n$e\\not\\in P$ restriction.  We complete the generalization to matroids\ngiven Diao and Hetyei which was motivated\nby invariants for the virtual knots studied by Kauffman.  \nOur motivations include electrical network analysis, oriented matroids,\nand negative correlation of edge appearances in spanning trees. The $P$-ported\nTutte polynomials of oriented matroids express orientation information\nthat ordinary Tutte polynomials cannot.\nThe computation tree formalism of Gordon and McMahon gives\nactivities expansions for $P$-ported parametrized Tutte polynomials\nmore general than those\njust determined by the linear element orderings\nwhich originated in Tutte's dichromate.\n\nThe polynomials expressing conditions\nfor the above Tutte matroid equations to have a solution\nall have one factor $I(Q_i)$.  Since the elements are \nlabelled, the methodology also applies\nto objects such as graphs with ports\nfor which similar ZBR theorems can be proven.  \nWe abstract graphs to objects that have \nported Tutte functions\nbecause they have matroids, but might\nhave different Tutte function values\non two objects with the same matroid.\nTwo new ZBR-type theorems are given\nand are used to generalize the ZBR\ntheorem to graphs with port edges.\nThe abstraction is then used to\ncharacterize ported Tutte functions\nof an object combination, or a distinct\nobject, whose matroid or oriented \nmatroid is a direct matroid or\noriented matroid sum.  \nThis extends with ports some \nknown strong Tutte \nfunction and multiplicative \nTutte function results.\n\\end{abstract}\n\n\\subjclass[2000]{...}\n\n\n\n\\keywords{Tutte function, Tutte polynomial}\n\n\\thanks{Version of \\today.}\n\n\\maketitle\n\\pagestyle{headings}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Introduction}\n\n\n\nIn his 1971 paper \\cite{BrylawskiPointed}\n``A Combinatorial Model for Series-Parallel Networks,''\nThomas H. Brylawski\naddressed\nseries/parallel graphs, matroids,\nand series/parallel connections of matroids\nfrom the Tutte polynomial point of view.\nThe rules for \ncombining graphs or matroids in series or parallel,\nand thus for generating series/parallel graphs and matroids,\nrefer to\na basepoint edge or element in each.\nTo study \nTutte polynomials of series or parallel connections\nand so help\ncharacterize\nseries/parallel matroids as having \nTutte invariant $\\beta=1$,\nBrylawski developed\na Tutte polynomial for ``pregeometries with basepoint $p_0$'' \nwith the four variables $z$, $x$, $z'$ and $x'$.   \nHis polynomial satisfies\nthe well-known Tutte equations with deletion and contraction\nallowed only for $e\\neq p_0$.  \nOur first motivation is to generalize this to $e\\not\\in P$\nfor a set $P$ of elements which we call \\emph{ports}.\n\n\nBrylawski developed this\npolynomial from\na ``class of polynomials whose variables are pointed and\nnonpointed pregeometries over the integers.''\nSuch variables, for matroids or oriented matroids\nhaving only distinguished elements, are present\nin our universal solution for \nTutte equations with (1) Brylawsky's restriction extended\nfrom one $p_0$ to many distinguished elements, and (2)\nwith parameters attached to the other elements.\n(See Corollary \\ref{UniversalCor} and \\cite{sdcPorted})\nAdditional references for this and the generalization\nto specify more than one element to forbid from\nbeing deleted or contracted\nare given in \nsec. \\ref{BackgroundSec}.\n\nA ``port'' edge, ``two terminals with the restriction\nthat the terminal currents have the same magnitude but\nopposite sign''\\cite{CRCHandbookPorts}, as termed \nin the circuit theory \nused by electrical engineers,\nis also crucial for analyzing and generalizing the\nelectrical resistance of a network.\nBrylawsky's\n1977 work on ``A Determinantal Identity for Resistive Networks''\n\\cite{BryDetIdResistive} helped underpin this and\nour earlier work (see for example \\cite{sdcOMP} in addition to\n\\cite{sdcPorted} and \\cite{TutteEx}) where one port is\ngeneralized to many.  Kirchhoff first showed, \nessentially, that network resistance is \nthe ratio of two parametrized spanning tree enumerating\nTutte polynomials, one for the network with the port\ndeleted and the other for the nework with the port contracted.\nBesides network resistance, other\nuseful generalizations of Tutte polynomial\ntheory defined by attaching parameters \nto elements are \nknown\\cite{Ellis-Monaghan-Traldi,Ellis-Monaghan-Merino-2}.\n\nThis paper explores the combination\nof parametrization with the restriction\nof the Tutte equations\nso deletion and contraction are done\nonly of elements not in a fixed subset $P$;\nsee \\eqref{TA} and \\eqref{TSSM} below.\nThose\nequations reduce to the well-known identities for the \ntwo-variable Tutte polynomial\nwhen the parameters are $x_e=y_e=1$, $X_e=x$ and $Y_e=y$ for all $e$ and \nthe set $P=\\emptyset$.\nEffectively, we study the effects of distinguishing\ncertain elements, those in $P$, so they are never deleted or \ncontracted in the course of Tutte decompositions\nthat carry the $x_e$, $y_e$, $X_e$, $Y_e$ parameters\ninto the resulting polynomials.\n\nOur work is largely based \non \\cite{Ellis-Monaghan-Traldi}, which\naddresses parametrization in detail and which unifies the main \nresults of Zaslavsky \\cite{MR93a:05047} and \nBollob\\'{a}s and Riordan \\cite{BollobasRiordanTuttePolyColored}.\nDiao and Hetyei \\cite{RelTuttePoly} characterize some \nparametrized Tutte functions defined with the\nsame restriction we do, and give a natural\napplication to virtual knot invariants \\cite{KauffmanVirtualKnots}.\nThis led us to complete the generalization to all\nseparator-strong parametrized Tutte functions.\n\nWe call $P$ the\n\\emph{set of ports}.  The resulting Tutte polynomials or functions\nhave been called \\emph{set-pointed} \\cite{SetPointedLV,SetPointedLV1}, \n\\emph{ported} \\cite{sdcPorted,TutteEx} and \n\\emph{relative} \\cite{RelTuttePoly}.  \nWe prefer the terms ``port'' and ``$P$-ported equations\nor functions'' because of our applications\n\\cite{sdcOMP,TutteEx} and because \nthe $P$ can be specified.\n\nWhen parameters $x_e$ and $y_e$ are introduced into the \nadditive Tutte equation, the route toward generalizations\nof the Tutte polynomial becomes complicated.  The next subsection \n(\\ref{Complications})\nelaborates on the particular \ndestination---\\emph{separator-strong Tutte functions},\nto which we add the port restrictions.\nHere is the main definition with the\nrestriction for $P$:\n\n\\begin{definition}\nLet $P$ be a set and $\\mathcal{C}$ be a class of matroids or\noriented matroids closed under taking minors or oriented minors\nby, for $e\\not\\in P$, deleting $e$ if $e$ is not a coloop or\ncontracting $e$ if $e$ is not a loop.\nSuch a $\\mathcal{C}$ is called a $P$-family.  $\\mathcal{C}$ is\ngiven with four parameters in a commutative ring $R$,\n$(x_e,y_e,X_e,Y_e)$, for each $e\\not\\in P$ that is an element\nin some $M\\in\\mathcal{C}$.\n\nA separator-strong $P$-ported Tutte function \n$T$ maps $\\mathcal{C}$ to $R$ or to an $R$-module and satisfies \nconditions \n\\eqref{TA} and \\eqref{TSSM} below for all $M\\in\\mathcal{C}$ and\nall $e$ in $M$.\n\n\n\\begin{equation}\n\\label{TA}\n\\tag{TA}\n\\begin{gathered}\nT(M) = x_e T(M/e) + y_e T(M\\setminus e) \\\\\n\\text{ if $e\\not\\in P$ and $e$ is a non-separator, \n       i.e., neither a loop nor a coloop.}\n\\end{gathered}\n\\end{equation}\n\n\n\\begin{equation}\n\\label{TSSM}\n\\tag{TSSM}\n\\begin{gathered}\n\\text{If } e\\not\\in P\\text{ is a coloop in }M\\text{ then }\nT(M)=X_e T(M/e).\\\\\n\\text{If } e\\not\\in P\\text{ is a loop in }M\\text{ then }\nT(M)=Y_e T(M\\setminus e).\n\\end{gathered}\n\\end{equation}\n\nThe $M\\in \\mathcal{C}$ for which neither \\eqref{TA} nor\n\\eqref{TSSM} apply are called \\emph{indecomposibles} and\nthe \\emph{$P$-quotients} in $\\mathcal{C}$. The analogous\ndefinitions are used for graphs, directed graphs,\nand any other objects on which deletion and contraction are \ndefined and act on matroids or oriented matroids associated\nto the objects.\n\n\\end{definition}\n\nBesides \\eqref{TA}, classical Tutte polynomials and other \nso-called \\emph{strong Tutte\nfunctions} \\cite{MR93a:05047} satisfy the multiplicative identity\n\\begin{equation}\n\\tag{TSM}\n\\label{TSM}\nT(M_1\\oplus M_2)=T(M_1)T(M_2).\n\\end{equation}\nDifferent combinations of variations of Tutte equations determine\ndifferent kinds of Tutte functions.  For example, the additive \nidentity \\eqref{TA} alone (with $P=\\emptyset$) characterizes\n\\emph{weak Tutte functions} \\cite{MR93a:05047,ZaslavskyOct18}.\n\nEvidently, \\eqref{TA} and \\eqref{TSSM} \nspecify how $T(M)$ can be recursively calculated from\nthe initial values $T(Q)=I(Q)$ on indecomposibles $Q$.\nThe definition that $T$ is a function \nmeans that\nall calculations of $T(M)$ for $M\\in\\mathcal{C}$\nusing \\eqref{TA}, \\eqref{TSSM} and the initial values\nyield the same result.\nA simple induction on $|E(M)|$,\nthe number of elements in $M$ that are not in $P$, \nshows that if a Tutte function\nwith specified values on the indecomposible matroids or oriented matriods\nexists for the given $P$-family and parameters, then the function\nis unique.  \n\nRestricting Tutte decomposition operations to $e\\not\\in P$\ngives some new information about oriented matroids and\noriented (i.e., directed) graphs.\nThe indecomposible matroids (or graphs) \nare minors of $M$ that have all their \nelements (or edges) in $P$.  We also call them\n$P$-quotients.\nIf $M$ is an oriented\nmatroid, each indecomposible is an oriented\nmatroid because the oriented minor $M/A\\setminus B$\nis well-defined when $A,B$ partitions $E$.\nHence, when $P\\neq \\emptyset$, $P$-ported Tutte functions\ncan have different values on different orientations of the\nsame orientable matroid.  \nOther Tutte functions with this same domain can be defined after\nforgetting the orientations.\nMany of our results will be stated for ``matroids or\noriented matroids'' because there are different indecomposibles\nand Tutte functions depending on whether or \nnot the matroids carry an orientation.  Analogous\nstatements apply to graphs versus directed graphs\nand to any other objects with oriented matroids.\n\nWe presented in  \\cite{TutteEx}\na new kind of strong Tutte-like function on $P$-ported oriented graphic\nmatroids (more generally, unimodular, i.e. regular oriented matroids)\nwhose values vary with the orientation.   \nEach function value $F(G)$ is\nin the exterior algebra over $R^{2p}$, where $R$ is\nthe reals extended by the $x_e, y_e$ \nand $|P|=p$.  The function\nobeys an \\emph{anti-commutative} variant of \\eqref{TSM} below\nwith exterior multiplication $\\wedge$.  \n(When $P=\\emptyset$, it reduces \nto the reduced Laplacian determinant in the\nfamous Matrix Tree Theorem \\cite{HararyBook,sdcMTT}.)  \nIt is the first example we know\nof\n``the possibility of making use of a noncommutative generalization of the Tutte\npolynomial at some point in the future.'' mentioned by Bollob\\'{a}s and\nRiordan in \\cite{BollobasRiordanTuttePolyColored}.  We won't say\nmore beyond that (1) each of the $\\binom{2p}{p}$\nPl\\\"{u}cker coodinates of $F(G)$ is a $P$-ported Tutte function\nof the kind we cover here; and (2) that quadratic inequalities among\nsome of them express negative correlation between edges in spanning trees,\nresults also known as Rayleigh's inequality\\cite{Raleighs}.\n\nA second non-commutative possibility might be found in \nsection \\ref{DirectSec} where\nwe consider parametrized Tutte functions of graphs with ports.\nDifferent indecomposible\ngraphs can have the same matroid\\cite{Ellis-Monaghan-Traldi}.  \nTo explore the issues,\nwe define an abstraction \ncalled ``$P$-ported objects with matroids\nor oriented matroids'' to which we generalize graph results.\nThe abstraction applies to situations where\nan object represents an initial matroid, graph, etc. plus\na history of deletions and contractions.  \nThe key feature is that the Tutte decompositions, represented \nby trees, of an object are identical to the Tutte decompositions\nof that object's matroid.\nThe initial values\non indecomposibles, \nused for a Tutte decomposition to determine a Tutte function value\n$T(N)$,\nmight then depend on the order of the deletion and contraction\nreductions\nto obtain each indecomposible from $N$.  This helps us understand the\ntheory, but whether objects with minors that depend on reduction \norder have useful applications remains to be seen.\n\n\\subsection{Complications from Parametrization}\n\\label{Complications}\nIt is known that,  even when $P=\\emptyset$,\n\\eqref{TA} fails to have a solution\n$T$ except if certain algebraic relations are true \nabout the parameters and\ninitial values.\n\nFor example, if $M=U_{1}^{ef}$ is  ${e,f}$ in parallel, then\napplying \\eqref{TA} for $e$ gives the polynomial\n($U^e_0$, $U^e_1$ are the loop, coloop matroids on $\\{e\\}$, etc.)\n\\[x_e T(U_0^f) + y_e T(U_1^f)\\]\n whence applying it for $f$ gives \n\\[x_f T(U_0^e) + y_f T(U_1^e).\\]  \nThen, \\eqref{TSSM} tells us $T(U_0^f)=Y_fI(\\emptyset)$, \n$T(U_1^f)=X_fI(\\emptyset)$, etc.\nThe above are different polynomials in the parameters and initial values.  \nThe equation that says they are equal is an example of a relation that \nis necessary for a solution to exist.  \nWhen the Tutte identities are \nparametrized, it is important to carefully distinguish \nbetween a solution value $T(M)$, where a solution $T$ \nis a function  that\nsatisfies all the relevent identities, and a formal polynomial  that\nresults from using a subset of the identities to calculate\n$T(M)$ for one $M$\\cite{MR93a:05047}.  We will in \nsec. \\ref{Activity} apply\n\\emph{Tutte computation trees} \\cite{GordonMcMachonGreedoid} \nto express the activities expansions for all\nsuch polynomials obtained by recursion, with any port set $P$.\nWe follow \\cite{BollobasRiordanTuttePolyColored,Ellis-Monaghan-Traldi}\nto say $T(M)$ is well-defined when the parameters are in \nring $R$ and the initial values are in\n$R$ or an $R$-module for which the polynomial expressions for $T(M)$ \nobtained by all the recursive applications of the relevant\nTutte equations are equal.\nThe conditions are conveniently expressed as generators \nfor the ideal $I$ such that the universal Tutte function is into\na quotient ring or module modulo $I$.\nSee Corollary \\ref{UniversalCor}.\n\n\\subsection{Summary}\n\nOur generalization is the kind of Tutte function determined by \n\\eqref{TA} and \\eqref{TSSM}; the latter is the weakening of \\eqref{TSM} \nso it applies only for cases where one of $M_1$ or $M_2$ is a \n\\emph{separator}, that is, a loop or coloop.  \nWe generalize by adding the restriction on \nport elements.\nThe result, Theorem \\ref{BigTheorem} (sec. \\ref{ParamTutteSec}), is a \na straightforward\ngeneralization of Theorem \\ref{ZBRmatroids}\nbelow paraphrased from \n\\cite{Ellis-Monaghan-Traldi}\nabout the existance and universal form for \nthe family of Tutte functions characterized by \\eqref{TA} and \\eqref{TSSM}.\nThis family was subsequently\nnamed \\emph{separator-strong Tutte functions} by \\cite{JoAndTom}\nbecause it is wider than the strong Tutte functions characterized\nby \\eqref{TA} and \\eqref{TSM}, which are the subject of \n\\cite{MR93a:05047}.  We follow these authors' terminology when we extend the\nfamily to matroids, oriented matroids and graphs with distinguished \nport elements, and then to ported objects \nrepresenting  matroids or oriented matroids.\nThe conclusions for $P$-ported parametrized\nstrong Tutte functions easily follow from those for the separator-strong ones.\nSee \\ref{StrongTheorem} in sec. \\ref{DirectSec}.\n\nWe build upon \\cite{Ellis-Monaghan-Traldi} which reconciles\nthe results of \\cite{MR93a:05047} and \n\\cite{BollobasRiordanTuttePolyColored} with a common generalization.  \nIt generalizes the fields and strong Tutte functions of \\cite{MR93a:05047}\nto the commutative rings and separator-strong Tutte functions of \n\\cite{BollobasRiordanTuttePolyColored}, and the definedness on \nall matroids in \\cite{BollobasRiordanTuttePolyColored} to definedness\non a minor-closed class in \\cite{MR93a:05047}.  Further, neither the\nmatroid or graph Tutte functions need to be \n$0$ or $1$ on $\\emptyset$.\nA main result of \\cite{Ellis-Monaghan-Traldi} is called the\nZaslavsky-Bollob\\'{a}s-Riordan (ZBR) theorem for matroids:\n\\begin{thm}\n%(The generalized Zaslavsky-Bollob\\'{a}s-Riordan theorem for matroids) \n\\label{ZBRmatroids}\nLet R\nbe a commutative ring, let $\\mathcal{C}$ be a minor-closed class of matroids \ndefined on subsets of an $R$-parametrized class $U$, and let \n$\\alpha\\in R$. \nThen there is a parametrized Tutte polynomial on\n$\\mathcal{C}$\nwith $T(\\emptyset)=\\alpha$ if and only if the following identities are \nsatisfied.\n\\begin{enumerate}\n\\item[a]\nWhenever $e$ and $f$ are dyadic in $M\\in\\mathcal{C}$ \n(i.e., they constitute a two element circuit),\n\\[\n\\alpha\\cdot(x_e Y_f + y_e X_f) = \\alpha\\cdot (x_f Y_e + y_f X_e ).\n\\]\n\\item[b]\nWhenever $e$, $f$ and $g$ are triangular in $M\\in\\mathcal{C}$ \n(i.e. they constitute a three element circuit),\n\\[\n\\alpha\\cdot  X_g\\cdot (x_e Y_f + y_e x_f) = \n\\alpha\\cdot  X_g\\cdot (Y_e x_f + x_e y_f ).\n\\]\n\\item[c]\nWhenever $e$, $f$ and $g$ are triadic in $M\\in\\mathcal{C}$ \n(i.e. they constitute a three element cocircuit),\n\\[\n\\alpha\\cdot Y_g\\cdot  (x_e Y_f + y_e x_f) = \n\\alpha\\cdot Y_g \\cdot (Y_e x_f + x_e y_g ).\n\\]\n\\end{enumerate}\n\\end{thm}\n\nThe terminology ``$R$-parametrized class $U$'' (of matroid elements)\nwas used in \\cite{Ellis-Monaghan-Traldi} to emphasize that the parameters\n$(x_e,y_e,X_e,Y_e)$ are attached to elements $e$, not equations.  \nThe assumption that $\\mathcal{C}$ is minor-closed implies that the \nthree conditions can be restricted to the pair or triple being the\nonly elements in $M$.  Our generalization, Theorem \\ref{BigTheorem} \n(sec. \\ref{ParamTutteSec})\nis expressed that way.\n\nThe \none indecomposible for the ZBR theorem is the empty matroid\n$\\emptyset$.   Loop or coloop matroids on $e$ are \ndecomposible; the values of the Tutte function on them equal\nrespectively $Y_e T(\\emptyset)$ and $X_e T(\\emptyset)$.   \n\n\nWe first generalize to $P$-ported matroids and oriented matroids the \nBollob\\'{a}s-Riordan-Zaslavsky theorem as synthesized\nby Ellis-Monaghan and Traldi in \\cite{Ellis-Monaghan-Traldi}.  \nParameters are only attached to $e\\not\\in P$.\n\nIn our\ngeneralization of Theorem \\ref{ZBRmatroids}, it is easy to see that the \nindecomposibles are those matroids $Q_i$ in $\\mathcal{C}$\nwhose ground set $S(Q_i)\\subseteq P$.\nWhen $P\\neq\\emptyset$,\ninstead of every monomial resulting from a Tutte decomposition\ncontaining the factor $T(\\emptyset)$, every monomial resulting \nfrom a Tutte decomposition of $M$ contains a factor $T(Q_i)$ where $Q_i$\nis some minor of $M$ obtained by contracting or deleting every $e\\not\\in P$.\nThese \n\\emph{initial} \nvalues must be given for those $Q_i$ in order\nto define a particular Tutte function.  They generalize the\n$\\alpha=T(\\emptyset)$ value.\n\nOur generalization of the ZBR theorem \nfirst replaces $T(\\emptyset)=\\alpha$ in its three\nequations with $I(Q_i)$.\nIt also adds two more equations pertaining to $M\\in\\mathcal{C}$\nin which series and parallel pairs $\\{e,f\\}$, $e\\not\\in P$, $f\\not\\in P$\nare connected to one or more elements of $P$.  Again, only\none $Q_i$ appears in each equation.  See Theorem \\ref{BigTheorem}.\nWe let some Tutte functions take values in modules\nto facilitate both defining universal Tutte functions with\nquotient modules and\nexpressing formulas for Tutte functions of direct sums and\nrelated combinations.\n\nAn interesting consequence is that no relationships are required\nbetween $T(Q_i)$ and $T(Q_j)$ for different indecomposibles $Q_i$ and\n$Q_j$ for the Tutte function to be well-defined.  This answers a \nquestion we raised in \\cite{TutteEx}.\n\nSecond, we\nextend to $P\\ne \\emptyset$ the activities Tutte polynomial\nexpressions and\ncorresponding interval partitions of the Boolean lattice\n$2^{S(M)\\setminus P}$.  Like the activities\nexpressions given by \\cite{GordonMcMachonGreedoid}\nfor greedoid Tutte polynomials, the\nexpressions we present are not just those obtained when a fixed linear\nordering on the elements is used to determine for which element $e$ to\napply \\eqref{TA} when two or more elements are eligible.\nEach of our activities expressions is based on a formal (Tutte)\n\\emph{computation tree} as defined in \\cite{GordonMcMachonGreedoid}.  \n\nThird, UPDATE.UPDATE.UPDATE.UPDATE \nwe describe the relationship between the relevant \nseparator-strong Tutte function\nvalues when a matroid is a direct sum.  It is more complicated than\nthe product formula $T(M^1\\oplus M^2)T(\\emptyset)$ $=$ $T(M^1)T(M^2)$\nfor matroids and related formulas for graphs \\cite{Ellis-Monaghan-Traldi}\nbecause a $P$-ported Tutte function value can involve more than one\nindecomposible.  When the \nmodule that contains the universal Tutte polynomials is extended\nto an algebra by defining direct sum and similar compositions of \nindecomposibles by the new algebra's multiplication $*$, the \nrelationship can be expressed by $T(M^1\\oplus M^2) = T(M^1)*T(M^2)$.\nFamilies of objects with matroids, were deletion and contraction\nis consistant with the matroids and restricted to $e\\not\\in P$,\nare introduced to facilitate studying $P$-ported strong Tutte\nfunctions of graphs. \n\nFinally, we specialize to graphs and so extend some of the graph\nresults of \\cite{Ellis-Monaghan-Traldi}.  Additional hypotheses\nare given for $P$-ported Tutte functions of graphs, including\nthose with labelled vertices, for characterizations like\nTheorems \\ref{ZBRmatroids} and \\ref{BigTheorem} to be true.\n\n\\subsection{Background and Other Related Work}\n\\label{BackgroundSec}\n\nBesides Brylawski's \nwork,  another early appearance of Tutte decomposition\nof a matroid or graph with a basepoint is \\cite{SmithPatroids}.\nEllis-Monaghan and Traldi \\cite{Ellis-Monaghan-Traldi}\nexplain that by leaving the reduction\nby $e_0$ to last so $e_0$ is always contracted as a coloop or deleted\nas a loop, the Tutte function value can be expressed by\n$T(M) = (rX_{e_o} + sY_{e_0})T(\\emptyset)$ were $r, s$ are \nnot-necessarilly-unique elements in $R$.  As one application,\nthey \ngive a formula for the parametrized Tutte polynomial\nfor the parallel connection across $e_0$\nwhich generalized Brylawski's.\nThese $r,s$ appear in\nthe $P$-ported Tutte function expression \n$rT(U^{e_0}_1)$ $+$ $sT(U^{e_0}_0)$ when $P=\\{e_0\\}$.  They\nare parametrized generalizations of the coefficients of\n$z'$ and $x'$ in Brylawski's four variable Tutte polynomial.\n\nLas Vergnas defined and gave basic properties of ``set-pointed'' Tutte\npolynomials (with no parameters) and used them to study matroid perspectives.\nThe polynomial given in \\cite{MR0419272,SetPointedLV} has a variable\n$\\xi_l$ for each subset in a collection of $k$ subsets\n$P_l\\subseteq P$, $l=1,\\ldots,k$.  Each term in \\eqref{PAE} had\n$\\prod\\xi_l^{r_i(P_l)}$ for $[Q_i]$ where $r_i$ is the rank function \nof matroid $Q_i$.  Therefore \\eqref{TSM} was satisfied and the association of the\nterm to (non-oriented) $Q_i$ could be assured by taking all\n$2^{|P|}$ subsets for the $P_l$.  The matroid perspective is the \nstrong map $M\\setminus E(M)\\rightarrow M/E(M)$ given by the identity on\n$P$.  \n\nIn \\cite{sdcPorted}, we\nreproduced Las Vergnes' theory with explicit $P$-quotient (matroid)\nvariables (see the $[Q_i]$ symbols in Corollary \\ref{UniversalCor}\nin sec. \\ref{UniversalSec}) in place of \n$\\prod\\xi_l^{r_i(P_l)}$.  We then\ngave formulas for the $P$-ported Tutte polynomial for the\nunion and its dual of matroids whose common elements are in $P$.\nThese formulas  work in a way similar to what appears in\nsec. \\ref{UniversalSec}.\nWe extend to algebras\nthe $\\mathbb{Z}[u,w]$-module\ngenerated by the $[Q_i]$ by defining multiplications \n$\\tilde{*}$ with the rules\n$[Q_i]\\tilde{*}[Q_j]=r_{ij}[Q_{i,j}]$, with $r_{i,j}\\in\\mathbb{Z}[u,w]$ and\n$Q_{i,j}=Q_i*Q_j$ depending on $(Q_i,Q_j)$ and whether $*$ represents \nunion or its dual.  It is not often recognized that series and parallel\nconnection of matroids across basepoint $p$ \nis equivalent to matroid union and its dual on matroids with only\nelement $p$ in common.  We plan to investigate whether the formulas\nfor parametrized Tutte polynomials of parallel connections\nin \\cite{Ellis-Monaghan-Traldi} can be generalized to the dual\nof union when $|P|>1$, and to detail the relationship when $|P|=1$.\n\n\n\nRecent work on a different generalization, weak Tutte functions\n(see sec. \\ref{Complications}), has been done by \nEllis-Monaghan and Zaslavsky \\cite{ZaslavskyOct18}.\nThe distinction between weak Tutte functions (satisfying\nan additive identity only)\nand strong Tutte functions\n(which satisfy \\eqref{TSM} and \\eqref{TA}) seems first to\nhave been made by Zaslavsky\\cite{MR93a:05047}, for matroids.\nThat paper also defined weak and strong Tutte functions of\ngraphs.  However, we use using Ellis-Monaghan and Traldi's\ndefinition of strong Tutte functions of \ngraphs\\cite{Ellis-Monaghan-Traldi}.\nThe latter restricts \\eqref{TA} to non-separators (not just \nnon-loops);  and it \nrequires $T(G^1)T(G^2)=T(G)$ whenever \nmatroids $M(G^1)\\oplus M(G_2)=M(G)$ \n(which we sometimes interpret as oriented), not just when\n$G$ is the disjoint union of $G^1$ and $G^2$.\nThe term separator-strong \n(I learned\\cite{JoAndTom} \nafter \\cite{Ellis-Monaghan-Traldi} appeared.)\nis used for Tutte functions of matroids and graphs \nas defined in \\cite{Ellis-Monaghan-Traldi}; recall that\nthey satisfy \\eqref{TA} and \\eqref{TSSM}.\nNormal is used in the same way as in\\cite{MR93a:05047}.\nWe will repeat and extend these definitions with\nlittle further attribution.\n\nWe introduced $P$-ported parametrized Tutte polynomial \nfor \\emph{normal} strong Tutte functions\nin \\cite{TutteEx}, i.e., \nthose with\ncorank-nullity polynomial expressions.\nMost of the results in the current paper, when so restricted\nappeared in \\cite{TutteEx}\nor can be derived by adding parameters and oriented matriod considerations\nto material in \\cite{sdcPorted}.  \nThese include computation tree\\cite{GordonMcMachonGreedoid} based activities \nexpansions \nwith terms corresponding to $P$-subbases (which are called\n``contracting sets'' in \\cite{RelTuttePoly}).\n%The one non-elementary fact about\n%oriented matroids needed is that two subsets $B,B'\\in E(M)$ that span\n%the same flat define the same $\\emph{oriented}$ minor\n%$M/B|P=M/B'|P$.  See \\cite{OMBOOK}.  \nIn the normal case, the initial values can be assigned arbitrarilly.\nWe used this to show the our extensor-valued Tutte-like function \n\\cite{sdcPorted} is expressible\nby assigning extensors as the initial values.  In this\nelectrical network application, the indecomposibles are oriented \ngraphic matroids\nand different values \\emph{are} assigned to different orientations of\nthe same matroid.  \n\nWe had left open questions about\nwhen non-normal $P$-ported parametrized Tutte\nfunctions are well-defined.  They are \nwhether arbitrary\nvalues can be assigned to the indecomposibles and what is\nthe appropriate generalization of\nconditions on the parameters given by Zaslavsky \\cite{MR93a:05047},\nBollob\\'{a}s and Riordan \\cite{BollobasRiordanTuttePolyColored} and \nEllis-Monaghan and Traldi \\cite{Ellis-Monaghan-Traldi}.\nTheorem \\ref{BigTheorem} resolves these questions:  The new conditions \nare obvious revisions of those for $P=\\emptyset$.  The indecomposibles\ncan be assigned arbitrarilly so long as for each one separately,\nthe conditions of Theorem \\ref{BigTheorem} are satisfied.  In addition,\nif the function is to be strong, Theorem \\ref{StrongTheorem}\ntells us that it is sufficient for the assignment to\nindecomposibles be strong.\n\n\nDiao and Hetyei gave conditions on the parameters, similar to ours, for the\nTutte polynomial to be well-defined for every assignment of\nvalues on the indecomposibles that obeys a symmetry condition.\nThat condition is motivated by the graph specialization.  \nThey gave the very natural application to invariants of \nvirtual knots calculated\nfrom their diagrams.\nPort edges, which they call \n\\emph{zero edges}, correspond to the \nvirtual crossings, and the sign parameters of the other \n$\\pm 1$ edges derive from left-over or right-over\nsense of the regular crossings.  Their preprint in fact motivated\nus to pursue the current topic\\cite{RelTuttePoly}.  This topic\nleads us to ask if the $P$-ported objects with matroids abstraction, \nand its related Tutte computation tree expansions for parametrized\nTutte functions (sec. \\ref{DirectSec}), can be usefully\napplied to objects besides graphs or directed graphs, such\nas various kinds of knot diagrams.\n\nAnother open project is to classify the solutions to\nthe conditions of Theorem \\ref{BigTheorem} (about separator-strong\n$P$-ported Tutte functions) and \nTheorem  \\ref{StrongTheorem} (about the strong ones) for rings and\nfor fields along the lines of \n\\cite{MR93a:05047} and \\cite{BollobasRiordanTuttePolyColored}.\n\n\n\\section{Preliminaries}\n\nFor a matroid or oriented matroid $M$, the\nground set of \\emph{elements} is denoted by $S(M)$ and the rank function \nis denoted by $r$.  Given\n\\emph{port} set $P$, $S(M)\\setminus P=\\{e\\in S(M) \\mid e\\not\\in P\\}$ \nis denoted by $E(M)$.  \nA matroid, oriented matroid or other object with elements\ngiven with a set of ports $P$ is be called\n\\emph{$P$-ported.}  In graphs and directed graphs, the elements \nare the edges.  Graphic matroids or oriented matroids always\nrefer to the circuit matroids.  Graph connectivity refers to\npath connectivity whereas connectivity in the graphic matroid\nrefers to 2-edge-connectivity of the graph.\n\nA $P$-\\emph{family} is a collection $\\mathcal{C}$ \nof matroids or oriented matroids such that\ngiven $M\\in \\mathcal{C}$ and $e\\in E(M)$, \nthe contraction $M/e\\in\\mathcal{C}$ if $e$ is not a loop in\n$M$ and the deletion $M\\setminus e\\in\\mathcal{C}$ if \n$e$ is  not a coloop in $M$.  \nThe set of non-port elements \nis $E(\\mathcal{C})=\\{e\\mid e\\in E(M)$ for some $M\\in\\mathcal{C}\\}$.\nIt is straightforward to extend these definitions to families of\nobjects, such as graphs, where each member object has an associated matroid\non appropriate elements of the object, such as edges, and those elements\ncan be deleted and/or contracted consistantly with the matroid.\n\n\nThe $P$-minors of $M$ are\nobtained\nby deleting or contracting zero or more non-port elements.\nThus, a $P$-family is \na $P$-minor closed collection of matroids or oriented matroids.\nThe $P$-minors $Q_i$ for which $S(Q_i)\\subseteq P$,\ni.e., those with no non-port elements, are called the $P$-quotients\nof $M$.  We say a $P$-quotient belongs to $\\mathcal{C}$ if it is a\n$P$-quotient of some $M\\in\\mathcal{C}$.  Note that if $P$ is finite,\n(and the objects are just matroids or oriented matroids)\nthere are only a finite number of $P$-quotients because there are \nonly a finite number of matroids or oriented matroids over subsets\nof $P$.\n\nAs usual, a \\emph{separator} is an element that is a loop,  or is\na coloop, i.e., an isthmus in a graph.\n\n\nLet $R$ be a commutative ring.\nWe sometimes assume that a $P$-family $\\mathcal{C}$ comes equipped\nwith four parameters $x_e,y_e,X_e,Y_e\\in R$ for each \n$e\\in E(\\mathcal{C})$ and for each $P$-quotient $Q\\in\\mathcal{C}$,\none initial value $I(Q)$ either in $R$ \nor in an $R$-module.  (One can consider $R$ to be\nthe $R$-module generated by itself.)\nNote that whether or\nnot the empty matroid $\\emptyset$ is a $P$-quotient depends on\n$\\mathcal{C}$.  If $M\\in\\mathcal{C}$ with\n$S(M)\\cap P=\\emptyset$ then $\\emptyset$ certainly is a $P$-quotient.\nIn that case, \\eqref{TSSM} specifies that $T(M) = X_e I(\\emptyset)$\nor $T(M) =Y_e I(\\emptyset)$ if $e\\not\\in P$ is a separator.\nTherefore,\nwe consider the $X_e$ and $Y_e$ to be parameters\nbecause $X_e$ and $Y_e$ are values of the Tutte function\nonly if $\\emptyset\\in \\mathcal{C}$ and $I(\\emptyset)=1$.\nThe Tutte equations \\eqref{TA} and \\eqref{TSSM}\njustify calling the $P$-quotients indecomposibles.\n\nThe uniform matroid with elements $\\{e, f, \\cdots \\}$ and rank $r$ is denoted\nby $U^{ef\\cdots}_r$.\n\nIn the remainder, we consider only elements $e, f, g$ none of \nwhich are in $P$.\n\nTwo distinct elements $e,f$ in matroid $M$\nare \\emph{parallel} when\nevery cocircuit that contains one of them also contains the other.  This\nis equivalent to $\\{e, f\\}$ being a two-element circuit.\nThey are \\emph{series} when every circuit that contains one of them\nalso contains the other.  This is equivalent to $\\{e, f\\}$ being a two-element\ncocircuit.\nThey are called a \\emph{dyad} when \nthey are both parallel and series.  Note that every \ndyad is a matroid connected\ncomponent of $M$.\n\nTwo distinct elements $\\{e,f\\}$  are a \\emph{parallel pair connected\nto $P$} when they are parallel and there is a cocircuit of the form\n$\\{e,f\\}\\cup P'$ with $\\emptyset\\neq P'\\subseteq P$.\n\nTwo distinct elements $e,f$ are a \\emph{series pair connected\nto $P$} when they are series and there is a circuit of the form\n$\\{e,f\\}\\cup P'$ with $\\emptyset\\neq P'\\subseteq P$.\n\nThree distinct elements $e,f,g$ are called a \\emph{triangle}\nwhen they comprise a 3 element circuit $U_2^{efg}$ that is a \nconnected component of $M$.\n\nThree distinct elements $e,f,g$ are called a \\emph{triad}\nwhen they comprise a 3 element cocircuit $U_1^{ef}$ that is a \nconnected component of $M$.\n\nThe following is critical to the proof that the generalizations\nof identities in Theorem \\ref{ZBRmatroids} all have the form\n$I(Q_i)\\cdot r=0$ where $r$ is a polynomial in the $x_e,y_e,X_e,Y_e$\nparameters and $Q_i$ is one $P$-quotient.\n\n\\begin{prop}\n\\label{SameMinorProp}\nSuppose $e,f$ are in series, or are in parallel, in matroid or\noriented matroid $M$.\n\\begin{enumerate}\n\\item The minors $M/e\\setminus f=M/f\\setminus e$\nare equal as matroids.\n\\item If $M$ is oriented, the oriented minors \n$M/e\\setminus f=M/f\\setminus e$ are equal as oriented matroids.\n\\end{enumerate}\n\\end{prop}\n\n\\begin{proof}\nIn the following, take all matroids as oriented or not\ndepending on how $M$ is given.\n\nIf $e,f$ are in series, note that $M/e\\setminus f$ $=$\n$M\\setminus f/e$.  $e$ is a coloop in $M\\setminus f$,\nso $M\\setminus f/e$ $=$ $M\\setminus\\{e,f\\}$, which is\nclearly the same matroid or oriented matroid if $e,f$\nare interchanged.  The relevant theory of minors of oriented matroids\ncan be found in \\cite{OMBOOK}.\n\nIf $e,f$ are in parallel, $e,f$ are in series in \nthe matroid or oriented matroid dual $M^*$ of $M$.\nBy the first case, $M^*\\setminus e/ f$ $=$\n$M^*\\setminus f/e$ as matroids or as oriented matroids.\nThus $M/e\\setminus f$ $=$ $(M^*\\setminus e/ f)^*$ $=$\n$(M^*\\setminus f/ e)^*$ $=$ $M/f\\setminus e$ as matroids or\nas oriented matroids.\n\\end{proof}\n\n\n\\part{Tutte Functions and Expansions}\n\n\\section{Parametrized Ported Tutte Functions}\n\\label{ParamTutteSec}\nLet $P$ be a set and $\\mathcal{C}$ be a $P$-family of matroids or oriented\nmatroids.  We state, discuss and prove this\ngeneralization of Theorem \\ref{ZBRmatroids} of \\cite{Ellis-Monaghan-Traldi}:\n\n\\begin{thm}\n\\label{BigTheorem}\nThe following two statements are equivalent.\n\\begin{enumerate}\n\\item $T$ from $\\mathcal{C}$ to $R$ or an $R$-module is a $P$-ported \nseparator-strong parametrized\nTutte function with $R$-parameters $(x, y, X, Y)$ whose values \n$T(Q_i)$ on $P$-quotients $Q_i\\in\\mathcal{C}$ are the initial\nvalues $I(Q_i)$.\n\\item\n\\begin{enumerate}\n\\item For every $M=U^{ef}_1\\oplus Q_j\\in\\mathcal{C}$ with \n$P$-quotient $Q_j$ ($U^{ef}_1$ is a dyad), \n\\[\nI(Q_j)(x_e Y_f + y_e X_f) = \nI(Q_j)(x_f Y_e + y_f X_e).\n\\]\n\\item\nFor every $M=U^{efg}_2\\oplus Q_j\\in\\mathcal{C}$ with \n$P$-quotient $Q_j$ ($U^{efg}_2$ is a triangle), \n\\[\nI(Q_j)X_g(x_e y_f + y_e X_f) = \nI(Q_j)X_g(x_f y_e + y_f X_e).\n\\]\n\\item\nFor every $M=U^{efg}_1\\oplus Q_j\\in\\mathcal{C}$ with \n$P$-quotient $Q_j$  ($U^{efg}_1$ is a triad), \n\\[\nI(Q_j)Y_g(x_e Y_f + y_e x_f) = \nI(Q_j)Y_g(x_f Y_e + y_f x_e).\n\\]\n\\item\nIf $\\{e,f\\}=E(M)$ is a parallel pair connected to $P$, \n\\[\nI(Q_j)(x_e Y_f + y_e x_f) = \nI(Q_j)(x_f Y_e + y_f x_e)\n\\]\nwhere $P$-quotient $Q_j=M/e\\setminus f=M/f\\setminus e$.\n\\item\nIf $\\{e,f\\}=E(M)$ is a series pair connected to $P$, \n\\[\nI(Q_j)(x_e y_f + y_e X_f) = \nI(Q_j)(x_f y_e + y_f X_e)\n\\]\nwhere $P$-quotient $Q_j=M/e\\setminus f=M/f\\setminus e$.\n\\end{enumerate}\n\\end{enumerate}\n\\end{thm}\n\n\\subsection{Remarks}\nProposition \\ref{SameMinorProp} assures that the different \nexpressions for $P$-quotients $Q_i$ in Theorem \\ref{BigTheorem} \nare in fact equal as matroid or as oriented matroids, depending\non how $M$ was given.  \n\nThe first three cases are trivial extensions of \nthe conditions in Theorem \\ref{ZBRmatroids} \\cite{Ellis-Monaghan-Traldi}.  \nThe only difference\nis that our conditions have the factor $I(Q_j)$ \nin place of $\\alpha=T(\\emptyset)$.\nJust two new conditions are required by $P\\neq\\emptyset$.  They\nare vacuous when $P=\\emptyset$.\n\nOur proof is the immediate result of adding considerations of ports to the\nproof in \\cite{Ellis-Monaghan-Traldi}, there described\nas ``a straightforward adaption of the proof of Theorem 3.3 of \n\\cite{MR93a:05047}.''\n\nAs in \n\\cite{Ellis-Monaghan-Traldi},\nwe rely on the hypothesis the $\\mathcal{C}$ is closed under our\n$P$-minors \nin order to verify\n(1) that the conditions imply $T(M)$ is well-defined for $n=0, 1$ and $2$\nand (2) that in a larger minimum $n$ counterexample, the elements of\n$E(M)$ are either all in series or all in parallel, \nand then the conditions\nimply that all calculation orders give the same result.  All the cases involve\ntwo different combinations of deleting and contracting of several elements\nin $E(M)$ where both combinations produce the same $P$-quotients.\n\nThe empty matroid\n$\\emptyset$ is clearly the only indecomposible for the\nseparator strong Tutte identities with $P=\\emptyset$.  \nThen $\\emptyset\\in\\mathcal{C}$ is required,\nprovided $\\mathcal{C}\\neq \\emptyset$.\nWhen we generalize to the\n$P$-ported separator strong Tutte identities\nwith $P\\neq\\emptyset$, the indecomposibles\ndepend on $\\mathcal{C}$ and  $\\emptyset\\not\\in\\mathcal{C}$ is possible.  \n\n\\subsection{Proof}\nWe sketch the proof with a few details, pointing out differences from\n\\cite{Ellis-Monaghan-Traldi}.\n\nAs in \\cite{Ellis-Monaghan-Traldi}, \nthe necessary relations are easy to deduce by \napplying \\eqref{TA} and \\eqref{TSSM}\nto the particular\nmatroids or oriented matroids of $\\mathcal{C}$ to which they apply.\nNow on to the converse.\n\nLet $M\\in\\mathcal{C}$ be a counterexample with minimum $n=|E(M)|$,\nnoting that $n$ does not count $|P\\cap S(M)|$.\nTherefore, whenever $M'$ is a proper $P$-minor of $M$,\n$T(M')$ is well-defined.  The Tutte conditions \\eqref{TA} and \\eqref{TSSM}\nhave the property that given $M$ and $e\\in E(M)$, exactly one equation\napplies.  Therefore, the induction hypothesis entails that\ncalculations that yield different values for $T(M)$ must start with\nreducing by different elements of $E(M)$.  Since $T(M)$ is given \nunambiguously by the initial value $I(M)$ when $n=0$, we can assume\n$n\\geq 2$.\n\n$M$ cannot contain a separator $e\\in E(M)$.  This is a consequence of the\nfact, applied to $P$-minors, that \nthis $e$ is a separator in every minor of $M$ containing $e$.\nTherefore, as observed in \\cite{Ellis-Monaghan-Traldi}, every\ncomputation has the same result $X_e T(M/e)$ or $Y_e T(M\\setminus e)$ \ndepending\non whether $e$ is a coloop or a loop.\n\nLet $e$ be one element in $E(M)$.  Since no element in $E(M)$ is a \nseparator, $V=x_{e} T(M/{e}) + y_{e} T(M\\setminus {e})$ is well-defined, \nand so is $x_{e'} T(M/{e'}) + y_{e'} T(M\\setminus {e'})$ \nfor each other $e'\\in E$.\nWe follow \\cite{Ellis-Monaghan-Traldi} and define\n$D=\\{e'\\in E(M) \\mid V=x_{e'} T(M/{e'}) + y_{e'} T(M\\setminus {e'})\\}$.  The \ninduction\nhypothesis then tells us \nthat there is at least \none  $f\\in E(M)\\setminus D$.  \n(Recall $e, e', f\\not\\in P$.)\n\nSuppose that $e$ is a separator in both $M\\setminus f$ and \n$M/f$ and $f$ is a separator in both \n$M\\setminus e$ and $M/e$.  Then, \n$T$ would\nbe well-defined for all four of these $P$-minors and so\nwe can write \n\\[\nT(M)=x_e x_f T(M/\\{e,f\\}) + x_e y_f T(M/e\\setminus f)\n+ y_e x_f T(M\\setminus e/f)\n+ y_e y_f T(M\\setminus\\{e,f\\}).\n\\]\nBoth computations give the same value because in this situation\nthe reductions by $e$ and $f$ commute.  \nSo, for $M$ to be a counterexample, there must be $e\\in D$\nand $f\\not\\in D$ ($e, f\\not\\in P$)\nto which one case of the following lemma applies:\n\n\n\\begin{lem}\n\\cite{MR93a:05047}\nLet $e , f$ be nonseparators in a matroid $M$. Within each column the\nstatements are equivalent:\n\n\\begin{minipage}{0.5\\textwidth}\n\\begin{enumerate}\n\\item\n$e$ is a separator in $M\\setminus f$.\n\\item\n$e$ is a coloop in $M\\setminus f$.\n\\item\n$e$ and $f$ are in series in $M$.\n\\item\n$f$ is a separator in $M\\setminus e$.\n\\end{enumerate}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{enumerate}\n\\item\n$e$ is a separator in $M/ f$.\n\\item\n$e$ is a loop in $M/ f$.\n\\item\n$e$ and $f$ are in parallel in $M$.\n\\item\n$f$  is a separator in $M/e$.\n\\end{enumerate}\n\\end{minipage}\n\\end{lem}\n\nWe claim that one of the following five cases must be satisfied:\n\\begin{enumerate}\n\\item \n$n=2$ and $E(M)=\\{e,f\\}$ is a dyad.\n\\item\n$n\\geq 3$ and $E(M)$ is a circuit not connected to $P$.\n\\item\n$n\\geq 3$ and $E(M)$ is a cocircut not connected to $P$.\n\\item\n$n\\geq 2$ and for some $\\emptyset\\neq P'\\subseteq P$,\n$P'\\cup E(M)$ is a circuit.\n\\item\n$n\\geq 2$ and for some $\\emptyset\\neq P'\\subseteq P$,\n$P'\\cup E(M)$ is a cocircuit.\n\\end{enumerate}\n\n\n\nAs in  \\cite{Ellis-Monaghan-Traldi}, we draw the conclusion that\nif $e\\in D$ and $f\\not\\in D$ then $e, f$ are either series or parallel. \nIt was further proven that a series pair and a parallel pair cannot\nhave exactly one element in common.  Therefore, the pairs $e,f$ satisfying \nthe conditions are either all series pairs or all parallel pairs.  By \nminimality of $n$, $E(M)$ is either an $n$-element parallel class or an \n$n$-element series class.  The last two cases are distinguished from\nthe first three according to whether or not $E(M)$ is disconnected or not\nfrom elements of $P$ in matroid $M$.  We now use \\eqref{TA} and \\eqref{TSSM}\nto show that, in each case, the calculations that start with $e$ and \nthose that start with $f$\nhave the same result, which contradicts $e\\in D$ and $f\\not\\in D$.\n\nWe give the details for case 4.  By hypothesis, \neach of $T(M/e)$, $T(M\\setminus e)$, $T(M/f)$, $T(M\\setminus f)$,\n$T(M/f/e)=T(M/e/f)$, $T(M/e\\setminus f)$ and \n$T(M/f\\setminus e)$ is well-defined.  Furthermore,\nby Proposition \\ref{SameMinorProp},\n$M/e\\setminus f$ $=$ \n$M/f\\setminus e)$ as matroids or oriented matroids depending\non how $M$ was given.\n\n\nStarting with $e$ and with $f$ give the two expressions:\n\\[\nV=x_e x_f T(M/e/f) + x_e y_f T(M/e\\setminus f) + y_e T(M\\setminus e)\n\\]\n\\[\nV\\neq x_f x_e T(M/f/e) + x_f y_e T(M/f\\setminus e) + y_f T(M\\setminus f)\n\\]\nLet $M'$ be the $P$-minor obtained by contracting each element\nin $E(M)$ except for $e$ and $f$ ($M'=M$ if $n=2$.)\nSince \n$E(M')=\\{e,f\\}$,\n\\eqref{TA} tells us that\n\\[\nI(Q) (x_e y_f + y_e X_f) =\nI(Q) (x_f y_e + y_f X_e),\n\\]\nwhere $Q=M'/e \\setminus f=M'/f \\setminus e$.  The latter two\nmatroids or oriented matroids are equal because $e,f$ are in series\nin $M'$ and so Proposition \\ref{SameMinorProp} applies.\n(When adapting this proof to Theorem \\ref{ZBRWellBehaved}, \n$Q=N'/e\\setminus f$ and $Q'=N'/f\\setminus e$ might differ and\nso might $I(Q)$ and $I(Q')$.  Revising the calculations is left to the\nreader.)\nSince $A=E(M)\\setminus\\{e,f\\}$ is a set of coloops ($\\emptyset$ if $n=2$)\nin\n$M/e\\setminus f$ $=$ $M/f\\setminus e$, we \nwrite $X_A=\\prod_{a\\in A}X_a$ ($1$ if $A=\\emptyset$)\nby $X_A$ and use \\eqref{TSSM} to write\n\\[\nT(M/e\\setminus f) = X_A I(Q ).\n\\]\nand\n\\[\nT(M/f\\setminus e) = X_A I(Q ).\n\\]\n\\[\nT(M\\setminus e) = Y_f X_A I(Q ).\n\\]\n\\[\nT(M\\setminus f) = Y_e X_A I(Q).\n\\]\nSo\n\\[\nx_e y_f T(M/e\\setminus f) + y_e T(M\\setminus e)\n=\nx_f y_e T(M/f\\setminus e) + y_f T(M\\setminus f)\n\\]\nwhich contradicts \n$V\\neq x_f x_e T(M/\\{f,e\\}) + x_f y_e T(M/f\\setminus e) + y_f T(M\\setminus f)$.\n\nThe remaining cases can be completed analogously.  It might be\nnoted that our proof differs slightly from \\cite{Ellis-Monaghan-Traldi}\nin that the cases of $n=3$ and $n\\ge 4$ are not distinguished.\n\n\\subsection{Universal Tutte Polynomial}\n\\label{UniversalSec}\nIt is easy to follow \n\\cite{BollobasRiordanTuttePolyColored,Ellis-Monaghan-Traldi} to define\na universal, i.e., most general $P$-ported parametrized\nTutte function $T^{\\mathcal{C}}$ for the $P$-minor closed class \n$\\mathcal{C}$ given without parameters or initial values.  To do this,\nwe take indeterminates $x_e, y_e, X_e, Y_e$ for each $e\\in E(\\mathcal{C})$\nand an indeterminate $[Q_i]$ for each $P$-quotient $Q_i\\in\\mathcal{C}$.\nLet $\\mathbb{Z}[x,y,X,Y]$ denote the integer polynomial ring generated by\nthe $x_e,y_e,X_e,Y_e$ indeterminates, define $\\widetilde{\\mathbb{Z}}$\nto be the $\\mathbb{Z}[x,y,X,Y]$-module generated by the $[Q_i]$.  \nLet $I^{\\mathcal{C}}$ denote the ideal of $\\widetilde{\\mathbb{Z}}$ \ngenerated by the identities of Theorem \\ref{BigTheorem}, comprising \nfor example $[Q_i](x_eY_f+y_eX_f-x_fY_e-y_fX_e)$ for each subcase of\ncase (a), etc.  The universal Tutte function has values in the\nquotient module $\\widetilde{\\mathbb{Z}}/I^{\\mathcal{C}}$.  Finally,\nobserve that the range of Tutte function $T$  can be considered to be the\n$R$-module generated by the values $I(Q_i)$ where ring $R$ contains the\n$x,y,X,Y$ parameters. If the $I(Q_i)\\in R$, consider\nthe ring $R$ to be the $R$-module generated by $R$.\nWe follow \\cite{Ellis-Monaghan-Traldi} to write\nthe corresponding consequence of Theorem \\ref{BigTheorem}:\n\n\\begin{cor}\n\\label{UniversalCor}\nLet $\\mathcal{C}$ be a $P$-minor closed class of matroids or \noriented matroids.  Then there is a \n$\\widetilde{\\mathbb{Z}}/I^{\\mathcal{C}}$-valued function \n$T^{\\mathcal{C}}$ on $\\mathcal{C}$ with $T^{\\mathcal{C}}(Q_i)=[Q_i]$ for each $P$-quotient\n$Q_i\\in\\mathcal{C}$ that is a $P$-ported parametrized Tutte function\non $\\mathcal{C}$ where the parameters are the \n$x, y, X, Y$ indeterminates.  Moreover, if $T$ is any $R$-parametrized\nTutte function with parameters $x'_e, y'_e, X'_e, Y'_e$, then $T$ is the\ncomposition of $T^{\\mathcal{C}}$ with the homomorphism determined by\n$[Q_i]\\rightarrow I(Q_i)=T(Q_i)$ for $P$-quotient and \n$x_e\\rightarrow x'_e$, etc., for each $e\\in E(\\mathcal{C})$.\n\\end{cor}\n\nIn the next section we define particular expressions for $T^{\\mathcal{C}}(M)$\nwhich will be called Tutte polynomials.   Our purpose for\nallowing Tutte function values and polynomials to be in\n$R$-modules is that it facilitates giving formulas for \nTutte functions of combinations such as direct sum in\nterms of multiplication rules that make the module into algebra.\n\n\n\\section{Tutte Computation Trees and Activities}\n\\label{Activity}\n\nSeveral authors \\cite{Ellis-Monaghan-Merino-1,Ellis-Monaghan-Traldi}\nsurveyed the two ways that the \ntwo-variable Tutte polynomial can be defined:  It \nmay be defined either as a universal solution to the\nrecursive strong Tutte equations, or as a generating function.\nFurther, two kinds of generating function definitions have been given.\nThe first is what Tutte originally used for graphs \n\\cite{TutteDich,TutteGraphBook} and is\ncalled the \\emph{basis} or \\emph{activities}\nexpansion. It enumerates each basis $B\\subseteq E$ \nby a term $x^{i(B)}y^{e(B)}$, where the \n\\emph{numbers of internally and externally active elements} \n$i(B)$ and $e(B)$ are determined from a given linear order\non the elements of $E$ (see Definition \\ref{Activities-Ordered-Def}).\nIt was shown that even though $(i(B),e(B))$ for particular $B$\nmight vary with the order, the resulting polynomial is\nindependent of this order, and that it satisfies the Tutte equations.\nThe second, called the \\emph{rank-nullity} generating function, \nis well-defined automatically\nbecause it enumerates each subset $A\\subseteq E$ with\nthe term $(x-1)^{(r(E)-r(A))}(y-1)^{(|A|-r(A))}$.  \nThis generating function is then shown to satisfy the Tutte equations.\nZaslavsky noted that the activities expansion remains universal when parameters\nare included whereas the rank-nullity generating function expresses only the\nproper subset of Tutte functions which he called normal\\cite{MR93a:05047}.\nThey are characterized by \\eqref{CNF}.\nSee sec. \\ref{NormalSubSec}.\n\nEllis-Monaghan and \nTraldi \\cite{Ellis-Monaghan-Traldi} remarked that the Tutte equation\napproach appears to give a shorter proof of the ZBR theorem\nthan the activities expansion approach. Diao and Hetyei \\cite{RelTuttePoly} \nproved specializations\nof Theorem \\ref{BigTheorem} by means of the activities expansion approach.\nThe inductive proofs on $|E|$ that we and \\cite{Ellis-Monaghan-Traldi}\ngive demonstrate that every calculation of $T(M)$ from Tutte equations\nproduces the same result when the conditions on the parameters\nand initial values are satisfied.  It it then almost a \ntautology that the polynomial expression\nresulting from\na particular calculation will equal the Tutte function value in the\nring $R$.\nWe show that every recursive calculation (see below)\ngives rise to an \nactivities expansion, when the activities are defined in the\nmore general way given by McMahon and Gordon \\cite{GordonMcMachonGreedoid}.\nWe suggest a heuristic reason why\nthe inductive Tutte equation approach is more succinct:\nThe induction assures that\n\\emph{every} computation for a matroid\nwith smaller $|E|$ gives the same result, not just those \ncomputations that are determined by linear orders on $E$.\n\nTo be precise, \\emph{recursive}\nmeans that the computation uses Tutte equations\nto find $T(M)$ in terms of the initial values for\nindecomposibles and/or of $M'$ with $|E(M')|<|E(M)|$\nusing recursive computations.  (Note the inductive\ndefinition.)\nAll the recursive computations of $T(M)$ \nare expressible by ``computation trees,''\nformally defined by McMahon and Gordon \n\\cite{GordonMcMachonGreedoid}.\nTheir motivation was to generalize activities expansions and\nthe corresponding interval partitions of the subset lattice from\nmatroids to greedoids.  Unlike matroids, some greedoids\ndo not have an activities expansion for their Tutte polynomial\nthat derives from an element ordering.\n\nProofs of activities expansions for matroids, and their generalizations\nfor $P$-ported matroids, seem more informative and certainly\nno harder when the expansions are derived from a general Tutte\ncomputation tree, than when the expansions are only those\nthat result from an element order.   \nFrom the retrospective that the Tutte equations\nspecify a non-deterministic recursive computation\n\\cite{Garey-Johnson}, it seems artificial to start with\nelement-ordered computations and then prove\nfirst that all linear orders give the same result and \nsecond that it \nsatisfies the Tutte equations, in order prove that \nall recursions give the same result.\nWe therefore\ntake advantage of the Tutte computation tree formalism\nand the more general expansions it enables.\n\n\n\\subsection{Computation Tree Expansion}\n\nWe begin with the definition of what generalizes the matroid\nbases in the activities expansion when $P\\neq\\emptyset$.  In the\nfollowing, $\\mathcal{B}(M)$ denotes the set of bases in $M$.\n\n\\begin{definition}\nGiven $P$-ported matroid or oriented matroid $M$,\na \\textbf{$P$-subbasis} $F\\in \\mathcal{B}_P(M)$\nis an independent set  with $F\\subseteq E(M)$\n(so $F\\cap P=\\emptyset$) for which $F\\dunion P$ is a spanning set\nfor $M$\n(in other words, $F$ spans $M/P$).\n\\end{definition}\n\nAn equivalent definition was given in \\cite{SetPointedLV}.\nThe following proposition shows our definition is equivalent to\nthat given in \\cite{RelTuttePoly}.  $C$ and $D$ below are called \n``contracting and deleting sets'' in that paper.\n\n\\begin{prop}\n$C$ is a $P$-subbasis if and only if\n$C \\subseteq E(\\mathcal(M))$ has no circuits and \n$D=E(M)\\setminus C$ has no cocircuits.\n\\end{prop}\n\n\\begin{proof}\n$C$ has no circuits means $C$ is an independent set in \n$M$.\n$D$ has no cocircuits means $D$ is independent in\nthe dual of $M$, i.e., $D$ is coindependent.  \n$D$ is coindependent if and only if\n$S(M)\\setminus D=P\\dunion C$ is spans\n$M$.\n\\end{proof}\n\n\n\\begin{prop}\nFor every $P$-subbasis $F$ there exists an independent set $Q\\subseteq P$\nthat extends $F$ to a basis $F\\dunion Q\\in \\mathcal{B}(M)$.\nConversely, if $B\\in\\mathcal{B}(M)$ then $F=B\\cap E=B\\setminus P$\nis a $P$-subbasis.\n\\end{prop}\n\n\\begin{proof} Immediate. \\end{proof}\n\n\nThe next definition \nis also equivalent to one in \\cite{RelTuttePoly}. It generalizes\nTutte's definitions based on element orderings \\cite{TutteGraphBook,TutteDich} \nextended to\nmatroids \\cite{CrapoAct}.  We will see that expansions based on \ncomputation trees generalize these further.\n\n\\begin{definition}[Activities with respect to a $P$-subbasis and an element\nordering $O$]\n\\label{Activities-Ordered-Def}\nLet ordering $O$ have every $p\\in P$ before every\n$e\\in E$.  Let $F$ be a $P$-subbasis.  Let $B$ be any basis for \n$M$ with $F\\subseteq B$.\n\\begin{itemize}\n\\item Element $e\\in F$\nis internally active if $e$ is the least element\nwithin its principal cocircuit with respect to $B$.  Thus, this principal\ncocircuit contains no ports.  The reader can verify this definition is \nindependent of the $B$ chosen to extend $F$.  Elements $e\\in F$ that are\nnot internally active are called internally inactive.\n\\item Dually, element $e\\in E$ with $e\\not\\in F$ is externally \nactive if $e$ is the least element within its principal circuit with\nrespect to $B$.  Thus, each externally active element is spanned by \n$F$.  Elements $e\\in E\\setminus F$ that are not externally active\nare called externally inactive.\n\\end{itemize}\n\\end{definition}\n\n\\begin{definition}[Computation Tree, following \\cite{GordonMcMachonGreedoid}]\n\\label{CompTreeDef}\nA $P$-ported (Tutte) computation tree for $M$ is a\nbinary tree whose root is labeled by $M$ and which satisfies:\n\\begin{enumerate}\n\\item If $M$ has non-separating elements not in $P$, then \nthe root has two subtrees and there exists one such element $e$ for which \none subtree is a computation tree\nfor $M/e$ and the other subtree is a computation tree for \n$M\\setminus e$.\n\nThe branch to $M/e$ is labeled with ``$e$ contracted'' and \nthe other branch is labeled ``$e$ deleted''.\n\\item Otherwise (i.e., every element in $E(M)$\nis separating) the root is a leaf.\n\\end{enumerate}\n\\end{definition}\n\nAn immediate consequence is\n\\begin{prop}\nEach leaf of a $P$-ported Tutte computation tree for $M$\nis labeled by the direct sum of some $P$-quotient\n(oriented if $M$ is oriented) \nsummed with loop and/or coloop matroids with \nground sets $\\{e\\}$ for various distinct $e\\in E$ (possibly none).\n\\end{prop}\n\nIt sometimes helps to revise Definition \\ref{CompTreeDef} to require\nthat every leaf be labelled with an indecomposible; and then allow\na single branch from $M$ to $M/e$ or to $M\\setminus e$\nlabelled ``$e$ contracted as a coloop'' or ``$e$ deleted as a coloop'' \ndepending on what kind of separator is $e\\in E(M)$.  We leave\nthe corresponding revisions of further definitions to the reader.\n\n\n\\begin{definition}[Activities with respect to a leaf]\n\\label{ActivityTreeDef}\nFor a $P$-ported Tutte computation tree for $M$,\na given leaf, and the path from the root to this leaf:\n\\begin{itemize}\n\\item Each $e\\in E(M)$ labeled ``contracted'' along this path\nis called \\textbf{internally passive}.\n\\item Each coloop $e\\in E(M)$ in the leaf's matroid is\ncalled \\textbf{internally active}.\n\\item Each $e\\in E(M)$ labeled ``deleted'' along this path\nis called \\textbf{externally passive}.\n\\item Each loop $e\\in E(M)$ in the leaf's matroid is\ncalled \\textbf{externally active}.\n\\end{itemize}\n\\end{definition}\n\n\\begin{prop}\nGiven a leaf of a $P$-ported Tutte computation tree for $M$,\nthe set of internally active or internally passive elements \nconstitutes a \n$P$-subbasis of $M$ which we say \n\\textbf{belongs to the leaf}.  \nFurthermore, every $P$-subbasis $F$ of $N$ belongs to a unique leaf.\n\\end{prop}\n\n\\begin{proof}\nFor the purpose of this proof, let us extend Definition \\ref{ActivityTreeDef}\nso that, given a computation tree with a given node $i$ \nlabeled by matroid $M_i$,\n$e\\in E$ is called internally passive when $e$ is labeled \n``contracted'' along the path from root $M$ to\nnode $i$.  Let $IP_i$ denote the set of such internally passive \nelements.\n\nIt is easy to prove by induction on the length of the root to node $i$ path\nthat\n(1) $IP_i\\cup S(M_i)$ spans $M$ and \n(2) $IP_i$ is an independent set in $M$.  The proof\nof (1) uses the fact that elements labeled deleted are non-separators.  The\nproof of (2) uses the fact that for each non-separator \n$f\\in M/IP_i$, $f\\cup IP_i$ is independent in $M$.\n\nThese properties applied to a leaf demonstrate the first conclusion,\nsince each $e\\in E$ in the leaf's matroid must be a separator by Definition \n\\ref{CompTreeDef}.\n\nGiven a $P$-subbasis $F$, we can find the unique leaf with the\nalgorithm below.  Note that it also operates on arbitrary subsets of $E$.\n\n\\textbf{Tree Search Algorithm:} Beginning\nat the root, descend the tree according to the rule: At each branch node,\ndescend along the edge labeled ``$e$-contracted'' if $e\\in F$ and along\nthe edge labeled ``$e$-deleted'' otherwise (when $e\\not\\in F$).\n\\end{proof}\n\nThe above definitions and properties lead us to \nreproduce element order based activities:\n\\begin{prop}\nGiven element ordering $O$ in which every $p\\in P$ is ordered\nbefore each $e\\not\\in P$, suppose we construct the unique $P$-ported\ncomputation tree $\\mathcal{T}$ in which the greatest non-separator $e\\in E$ is\ndeleted and contracted in the matroid at each tree node.\n\nThe activity of each $e\\in E$ relative to ordering $O$ and\n$P$-subbasis $F\\subseteq E$ is the same as the activity\nof $e$ defined with respect to the leaf \nbelonging to $F$ in $\\mathcal{T}$.\n\\end{prop}\n\n\\begin{definition}\n\\label{ActivitySymbolsDef}\nGiven a computation tree for \n$P$-ported (oriented) matroid $M$,\neach $P$-subbasis $F\\subseteq E$\nis associated with the following subsets of non-port elements\ndefined according to Definition \\ref{ActivityTreeDef}\nfrom the unique leaf determined by the algorithm given above.\n\\begin{itemize}\n\\item $IA(F)\\subseteq F$ denotes the set of internally active elements,\n\\item $IP(F)\\subseteq F$ denotes the set of internally passive elements,\n\\item $EA(F)\\subseteq E\\setminus F$ \ndenotes the set of externally active elements,\nand \n\\item $EP(F)\\subseteq E\\setminus F$ denotes the set of externally\npassive elements.\n\\item $A(F)=IA(F)\\cup EA(F)$ denotes the set of active elements.\n\\end{itemize}\n\\end{definition}\n\n\\begin{prop}\n\\label{PartitionProposition}\nGiven a $P$-ported Tutte computation tree for\n$M$, \nthe boolean lattice of subsets of $E=E(M)$\nis partitioned by the collection of\nintervals $[IP(F),F\\cup EA(F)]$ (note $F\\cup EA(F)=IP(F)\\cup A(F)$)\ndetermined from the collection\nof $P$-subbases $F$, which correspond to the leaves.\n\nThe boolean lattice of subsets of $E=E(M)$\nis also partitioned by the collection of\nintervals $[EP(F),E\\setminus F\\cup IA(F)]$ \n(note $E\\setminus F\\cup IA(F)$ $=$ $EP(F)\\cup A(F)$).\n\nFor a given $F\\in\\mathcal{B}_P(M)$, $A\\subseteq E$ satisfies\n$A\\in [IP(F),F\\cup EA(F)]$ if and only if \n$(E\\setminus A)\\in [EP(F),E\\setminus F\\cup IA(F)]$. \n\\end{prop}\n\n\\begin{proof}\nEvery subset $A\\subseteq E=E(M)\\setminus P$ belongs to the\nunique interval corresponding to the unique leaf found by the tree search \nalgorithm given at the end of the previous proof.  \n\nThe dual of that tree search algorithm, which descends along\nthe edge labelled ``$e$-deleted'' if $e\\in A'$, etc., will find the\nunique leaf whose interval $[EP(F),E\\setminus F\\cup IA(F)]$ contains\n$A'$.\n\nWhen $A\\in[IP(F),F\\cup EA(F)]$, the dual algorithm applied to\n$A'=E\\setminus A$ will find the same leaf.\n\\end{proof}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nThe following generalizes the activities expansion expression given\nin \\cite{MR93a:05047} to ported (oriented) matroids, as well as \nTheorem 8.1 of \\cite{SetPointedLV}. \n\n\\begin{prop}\n\\label{TuttePolyExpression}\nGiven parameters $x_e$, $y_e$, $X_e$, $Y_e$, and \n$P$-ported matroid or oriented matroid $M$\nthe Tutte polynomial expression\ndetermined by the sets in Definition \n\\ref{ActivitySymbolsDef} \nfrom a computation tree is \ngiven by\n\\begin{equation}\n\\tag{PAE}\n\\label{PAE}\n\\sum_{F\\in \\mathcal{B}_P}[M/F|P]\n\\;X_{IA(F)}\\;x_{IP(F)}\\;Y_{EA(F)}\\;y_{EP(F)}.\n\\end{equation}\n\\end{prop}\n\n\\begin{proof}\n\\eqref{PAE} is an expression constructed by applying some of the\nTutte equations.  One monomial results from each leaf.\nIt that leaf's matroid,\neach active element is a separator, and the active elements\ncontribute $X_{IA(F)}Y_{EA(F)}$ to the monomial.\nThe passive elements which contribute\n$x_{IP(F)}y_{EP(F)}$\nare the tree\nedge labels in the path from the root to the leaf.\nEach $M/F|P$ denotes a $P$-quotient of $M$, so the\nexpression is a polynomial in the parameters and in the\ninitial values.  \nTherefore, \\eqref{PAE} expressions the result of\nthe calculation when one substitutes\n$[M/F|P]=I(M/F|P)$.\n\\end{proof}\n\nFrom Corollary \\ref{UniversalCor} we conclude:\n\\begin{thm}\n\\label{ActivitiesTheorem}\nFor every $P$-ported parametrized Tutte function $T$ \non $\\mathcal{C}$ into \nring $R$ or an $R$-module,\nfor every computation tree for $M\\in\\mathcal{C}$\n(and so for every ordering of $E(M)$), \nthe polynomial expression \\eqref{PAE} equals \n$T^{\\mathcal{C}}(M)$ of Corollary \\ref{UniversalCor}.\n\\end{thm}\n\n\\subsection{Expansions of Normal Tutte Functions}\n\\label{NormalSubSec}.\n\nAfter a notational translation, \nZaslavsky's \\cite{MR93a:05047} definition of \\emph{normal} Tutte \nfunctions becomes\nthose for which $T(\\emptyset)=1$, and for which there exist\n$u$, $v\\in R$ so that for each $e\\in E(M)$,\n\n\\begin{equation}\n\\tag{CNF}\n\\label{CNF}\nX_e = x_e + uy_e \\text{ and } Y_e = y_e + vx_e.\n\\end{equation}\n\nLet us drop the $T(\\emptyset)=1$ constraint and then\nnote that \\eqref{CNF} applies immediately to $P$-ported Tutte functions.\n(Unfortunately, we use \n$(x_e, y_e, X_eT(\\emptyset), Y_eT(\\emptyset))$ for Zaslavsky's\nnotations $(b_e, a_e, x_e, y_e)$.)  The normal Tutte functions\ninclude the classical two variable Tutte polynomial.\nPlease observe that the equations of Theorem \\ref{BigTheorem}\nare satisfied by \\eqref{CNF} independently of the\ninitial values.  Hence all the expressions for normal Tutte\nfunctions will be in a ring freely generated by\n$u$, $v$, the $x_e, y_e$ and the $[Q]$.  We will therefore\ncall them expansions for a Tutte polynomial.  This\nTutte polynomial is universal for $P$-ported separator-strong\nnormal parametrized Tutte functions of matroids or oriented matroids.\nWe can now generalize some known expansions.\n\n\\subsubsection{Boolean Interval Expansion}\n\n\\begin{cor}\n\\label{NormalActProp}\nThe following activities and boolean interval expansion formula\nis universal for normal Tutte functions and\nis obtained by substituting \\eqref{CNF} \ninto $T^{\\mathcal{C}}(M)$.\n\\begin{equation}\nT^{\\mathcal{C}}(M)=\n\\sum_{F\\in \\mathcal{B}_P}[M/F|P]\n%\\left(\n\\Big(\n\\sum_{\\substack{\n       IP(F)\\subseteq K \\subseteq F\\\\\n       EP(F)\\subseteq L \\subseteq E\\setminus F\n      }}\n x_{K\\cup (E\\setminus F\\setminus L)}\\;\n v^{\\Card{E\\setminus F\\setminus L}}\\;\n y_{L\\cup (F\\setminus K)}\\;\n u^{\\Card{F\\setminus K}}\\;\\;\n%\\right)\n\\Big)\n\\end{equation}\n\\end{cor}\n\n\\begin{proof} After substituting \\eqref{CNF} we get\n\\[\nT^{\\mathcal{C}}(M)=\n\\sum_{F\\in \\mathcal{B}_P}[M/F|P]\n%\\left(\n\\Big(\nx_{IP(F)}\\;\\;\n\\prod_{e\\in IA(F)}\\left(x_e+y_eu\\right)\\;\\;\ny_{EP(F)}\\;\\;\n\\prod_{e\\in EA(F)}\\left(y_e+x_ev\\right)\n%\\right)\n\\Big)\n\\]\nand then, by Definition \\ref{ActivitySymbolsDef}, \n$IP(F)\\dunion IA(F) =F$ and \n$EP(F)\\dunion EA(F)=E\\setminus F$.\n \\end{proof}\n\n\n\\begin{lem}\n\\label{KLAlemma}\nGiven $F\\in\\mathcal{B}_P$,\n$IP(F)$ spans $EA(F)$.\n\nThe pairs $(K,L)$ for which \n       $IP(F)\\subseteq K \\subseteq F$ and \n       $EP(F)\\subseteq L \\subseteq E\\setminus F$\nare in a one-to-one correspondance\nwith the $A$ satisfying $IP(F)\\subseteq A\\subseteq F\\dunion EA(F)$\ngiven by $A=K\\dunion (E\\setminus F)\\setminus L$.\n\n\nFor every such $A$, \n\\begin{equation}\n\\Card{F\\setminus K}=r(M)-r(M/F|P)-r(A)\n\\end{equation}\nand\n\\begin{equation}\n\\Card{E\\setminus F\\setminus L} = \\Card{A}-r(A).\n\\end{equation}\n\\end{lem}\n\n\\begin{proof}\nBy our definition of activities,\nafter all the elements of $IP(F)$ are contracted, all elements \nin $EA(F)$ are loops.\n(Note none of these elements are ports.)\n\nLet \n$A=K\\dunion (E\\setminus F)\\setminus L$.\nBy our definition of activities,\n$IP(F)\\dunion IA(F)=F$, so $IP(F)\\subseteq A$.\nSimilarly,  \n$EP(F)\\dunion EA(F)=E\\setminus F$, so \n$A\\cap(E\\setminus F)\\subseteq EA(F)$.\nHence $A=K\\dunion (E\\setminus F)\\setminus L$.\n\nSince $IP(F)$ spans $EA(F)$, $K\\subseteq IP(F)$ spans\n$EA(F)$.  Since $A\\subseteq K\\dunion EA(F)$, $K$ spans $A$.\n$K\\subseteq F$ is a $P$-subbasis, so $\\Card{K}=r(K)=r(A)$\nand $\\Card{F}=r(F)$.  Therefore, $\\Card{F\\setminus K}=r(F)-r(A)$.\n\nSince $F$ is a $P$-subbasis, $r(F\\cup P)=r(M)$.\nBy definition of contraction, $r(M/F|P)=r(F\\cup P) - r(F)$,\nso $r(M/F|P)=r(M)-r(F)$.  We conclude \n$\\Card{F\\setminus K}=r(M)-r(M/F|P)-r(A)$.\n\n$E\\setminus F\\setminus L = A\\setminus K$, so\n$\\Card{E\\setminus F\\setminus L} = \\Card{A}-\\Card{K}$.\nAs above, $\\Card{K}=r(A)$, so the last equation follows.\n\\end{proof}\n\n\n\\begin{cor}\n\\begin{equation}\n\\label{FIntervalExpansion}\nT^{\\mathcal{C}}(M)=\n\\sum_{F\\in \\mathcal{B}_P}[M/F|P]\n%\\left(\n\\Big(\n\\sum_{IP(F)\\subseteq A \\subseteq F\\dunion EA(F)}\n x_{A}\n y_{E\\setminus A}\n u^{r(M)-r(M/F|P)-r(A)}\n v^{\\Card{A}-r(A)}\n%\\right)\n\\Big)\n\\end{equation}\n\\end{cor}\n\n\\begin{proof}\nApply Lemma \\ref{KLAlemma} to the inner sum in\nProposition \\ref{NormalActProp}.\n\\end{proof}\n\n\\subsubsection{Corank-nullity Expansion}\n\n\n\\begin{lem}\n\\label{FAMinorlemma}\nGiven $F\\in\\mathcal{B}_P(M)$, $(K,L)$ and $A=K\\dunion E\\setminus F\\setminus L$\nas in Lemma \\ref{KLAlemma},\n\\[ M/F|P = M/A|P\\]\n(as matroids or oriented matroids).\n\\end{lem}\n\\begin{proof}\nWriting the contractions and deletions explicitly, $M/F|P$ \n$=$ $M/F\\setminus (E\\setminus F)$.  By our definition of\nactivities, all the $e\\not\\in P$ in $M/IP(F)\\setminus EP(F)$ are \nloops or coloops.  Hence, when all these elements are removed\nfrom $M/IP(F)\\setminus EP(F)$ whether by contraction or deletion, the\nresult is the same matroid or oriented matroid.  Since\n$IP(F)\\subseteq A\\subseteq F$ and \n$EP(F)\\subseteq (E\\setminus A)\\subseteq (E\\setminus F)$, we \ncan construct $M/F|P$ or $M/A|P$ by forming $M/IP(F)\\setminus EP(F)$\nfirst, contracting the remaining elements of $F$ or $A$,\nand last deleting all the remaining $e\\not\\in P$.  \nTherefore  $M/A|P$ $=$ $M/F|P$.\n\\end{proof}\n\n\\begin{thm}\n\\begin{equation}\n\\tag{PGF}\n\\label{PGF}\nT^{\\mathcal{C}}(M) = \\sum_{A\\subseteq E(M)}[M/A \\mid P]x_A y_{E\\setminus A}\nu^{r(M)-r(M/A\\mid P)-r(A)}\nv^{|A|-r(A)}.\n\\end{equation}\n\\end{thm}\n\n\\begin{proof}\nBy Proposition \\ref{PartitionProposition}, given any Tutte computation tree,\nthe lattice of subsets of $E(M)$ is partitioned\ninto intervals corresponding to $P$-subbases $\\mathcal{B}_P$.  \nHowever,  given $F\\in\\mathcal{B}_P$, for every $A$ satisfying\nLemma \\ref{FAMinorlemma}, the $P$-quotient $M/F|P$ is equal to \n$M/A|P$ (as a matroid or oriented matroid).  Hence we can \ninterchange the summations in \\eqref{FIntervalExpansion} and write\n\\eqref{PGF}.\n\\end{proof}\n\n\\subsubsection{Geometric Lattice Flat Expansion}\n\nWe generalize another formula from \\cite{sdcPorted}:\n\n\\begin{prop}\nLet $N$ be an oriented or unoriented.\nLet $R_P(M)$ be given by \\eqref{PGF}.\nIn the formula below,\n$F$ and $G$ range over the geometric lattice of flats contained\nin $M$ restricted to $E$.\n\\begin{equation}\nR_P(M)(u,v) = \\sum_{Q_i} [Q_i]\n      \\sum_{\\substack{F\\leq E\\\\\n                     [M/F|P]=[Q_i]\n           }}\n                   u^{r(M)-r(Q_i)-r(F)}\n                   v^{-r(F)F}\n                   \\sum_{G\\le F}\n                   \\mu(G,F)\n                   \\prod_{e\\in G}\n                    (y_e+x_ev)\n\\end{equation}\n\\end{prop}\n\n\\begin{proof}\nIt follows the steps for theorem 8 in \\cite{sdcPorted}.\n\\end{proof}\n\n\\part{Objects, Graphs and Sums}\n\n\nWhen $P=\\emptyset$, the facts about separator-strong Tutte functions\nof matroid direct sums easily follow from the formula\n$T(M^1\\oplus M^2)T(\\emptyset)=T(M^1)T(M^2)$.  For example,\n$T$ is strong if and only if $T(\\emptyset)=T(\\emptyset)^2$.\nThe theory of separator-strong Tutte functions of graphs covered\nin \\cite{Ellis-Monaghan-Traldi}  follows from the fact that any\nminor closed family of graphs (see below) $\\mathcal{G}$ is partitioned into\nsubfamilies $\\mathcal{G}_k$, each with just one indecomposible,\n$E_k$, the edgeless graph with $k$ unlabelled vertices, \nif $\\mathcal{G}_k\\neq\\emptyset$.\nTutte function formulas for disjoint and one-point graph unions, \nand the conditions for strongness (defined $T(G^1)T(G^2)=T(G)$ if\nmatroids $M(G^1)\\oplus M(G^2)=M(G)$) are then \nderived \\cite{Ellis-Monaghan-Traldi}\nin terms of the values $\\alpha_k=I(E_k)$.  Life is simple because\nmatroid $M(E_k)=\\emptyset$ for all $k$.\n\nThe corresponding facts become more complex when the definitions\nare naturally extended to $P$-ported matroids and graphs\nor to vertex labelled graphs.  As with\nmatroids, a $P$-ported graph $G$ has some of the edges in $P$ and the rest,\n$E(G)$, satisfy $E(G)\\cap P=\\emptyset$.  Deletion, contraction,\n$P$-minors, $P$-families and $P$-quotients (i.e., irreducibles)\nare also defined as they are for $P$-ported matroids or oriented matroids.\nAs in \\cite{Ellis-Monaghan-Traldi},\ndeletion of an isthmus (i.e., coloop in the matroid) and\ncontraction of a loop is forbidden.\n\nThe main difficulty is illustrated by the following example.\nLet\n$G$ be the circle graph of the five edges\nordered $(e,p,f,q,r)$ and take $P=\\{p,q,r\\}$.  \nSo, $e$ and $f$ are a series pair connected to $P$, but\nthe $P$-quotient graphs $Q_1=G/e\\setminus f$ and \n$Q_2=G/f\\setminus e$ are different graphs, even though they have \nthe same matroid.  $Q_1$ is the path $qrp$ and $Q_2$ is the path $pqr$.\nFunction $T$ might satisfy \\eqref{TA}\nand \\eqref{TSSM} even if $T(Q_1)=I(Q_1)\\neq I(Q_2)=T(Q_2)$.\nSo, if this $G\\in\\mathcal{G}$, a necessary condition \nfor $T$ to be a $P$-ported\n(separator-strong, as always) Tutte function would be\n\\begin{equation}\nI(Q_1)(x_ey_f - y_fX_e) = I(Q_2)(x_fy_e - y_eX_f).\n\\end{equation}\nThis equation does not have the form of \nthose in the ZBR theorem for graphs \\cite{Ellis-Monaghan-Traldi}\nbecause the latter's equations, like the equations in\nTheorem \\ref{BigTheorem}, each has a single factor \n$I(Q_i)$ depending on one indecomposible.\n\n\nThe example relies on the elements of $P$ being labelled.\nThis leads us to formulate a extension of Tutte function theory\nfor vertex labelled graphs.  \nWhen the outcome, Theorem \\ref{ZBRWellBehaved} is applied to graphs as in \n\\cite{Ellis-Monaghan-Traldi}, we get Corollary \\ref{PZBRGraphCor2}\nwhich demonstrates that the above example illustrates the\n\\emph{only} situation where the $P$-ported ZBR equations\nof Theorem \\ref{BigTheorem} must be modified.\n\nThe next example illustrates \nthe same phenonemon as the first, in a smaller graph, when\nthe objects in $\\mathcal{G}$ are graphs whose vertices are \nlabelled by disjoint sets.  Again, two different graphs have the\nsame oriented matroid.\n\n\\input{c4p2Two.pdf_t}\n\nThe expressions from these two Tutte computation trees are\nare \n\\[\nI(Q_1)x_ex_f+I(Q_2)x_ey_f+I(Q_3)y_eX_f\n\\]\nand\n\\[\nI(Q_1)x_ex_f+I(Q_3)x_fY_e+I(Q_2)y_fX_e=\nI(Q_1)x_ex_f+I(Q_2)y_fX_e+I(Q_3)x_fY_e,\n\\]\nwhich are equal if and only if\n\\begin{equation}\n\\label{BadZBRExampleEq}\nI(Q_2)(y_fX_e - x_ey_f)=\nI(Q_3)(y_eX_f - x_fY_e).\n\\end{equation}\n$Q_2$ and $Q_3$ are isomorphic as edge-labelled graphs\nbut are different when the vertex\nlabels are present.\n\nThere are two  complications introduced\ninto $P$-families of matroids when $P\\neq\\emptyset$.\nFirst, one matroid \nmight have more than one $P$-quotient, i.e., indecomposible.\nThe most simple \nexample is a dyad matroid composed of one port and one\nnon-port element; and its $P$-minors.\nTherefore, minimal $P$-minor closed families might have \nmore than one indecomposible.  Some will share\nmatroids or oriented matroids and others will not.\nThe second, which also occurs with the \nminor closed families of graphs \\cite{Ellis-Monaghan-Traldi}\nin the original $P=\\emptyset$ form, is that\nthe family is partitioned into disjoint $P$-minor closed\nsubfamilies.  Each subclass has its own indecomposibles,\n$E_k$ in the case of graphs.  Again, \nindecomposibles in different subclasses \nshare matroids as do\nthe $E_k$ all of whose matroids are $\\emptyset$.\nWhen $P\\neq 0$, the indecomposibles of different \nsubclasses might or might not share matroids\nor oriented matroids.\n\nThe ZBR theorem for graphs in \\cite{Ellis-Monaghan-Traldi}\nhas conditions analogous to those in Theorem \\ref{ZBRmatroids},\nexcept the factor $\\alpha$ is replaced by $\\alpha_k=I(E_k)$\ndepending on the subfamily.  \n\n$P$-ported matroids or oriented matroids can be combined \nby matroid direct sum $\\oplus$.  Graphs can be combined\nby disjoint union $\\amalg$ or by a one-point union;\nthen each such combination $G$ of $G^1$ and $G^2$, if defined,\nsatisfies $M(G)=M(G^1)\\oplus M(G^2)$.\n\n\nWe following definitions are the immediate extensions\nof the corrsponding known definitions.\n\n\n\\begin{definition}\nA \\emph{strong} $P$-ported Tutte function $T$ on a $P$-family \n$\\mathcal{C}$ of matroids\nor oriented matroids satisfies $T(M^1)T(M^2)=T(M^1\\oplus M^2)$\nwhen $M^1, M^2$ and $M^1\\oplus M^2$ are all in $\\mathcal{C}$.\n\\end{definition}\n\nNote that such a strong Tutte function is a separator-strong\nTutte function with $X_e=T(U^e_1)$ and\n$Y_e=T(U^e_0)$ for all $e\\in E(\\mathcal{N})$.\n\nWe will give extensions of definitions of strong Tutte functions\nand of multiplicative Tutte functions of graphs below when\nwe define $P$-families of objects with matroids or oriented \nmatroids.\n\nThe remainder of the paper abstracts graphs to \nobjects with matroids or oriented matroids to \nresolve the issues illustrated by the examples.\nProofs as in \n\\cite{Ellis-Monaghan-Traldi}\nare based on the one indecomposible matroid \nbeing $\\emptyset$, and on\nthere being just one indecomposible graph (the edgeless\ngraph $E_k$ with $k$ vertices) all with the\nsame matroid $\\emptyset$ in each minor\nclosed subclass of graphs.\nOur abstraction and Tutte computation\ntrees seem to make it easier to generalize\nthese results.  They also lead to\nnew type of ZBR-theorem that pertains the\nsituation illustrated by equation \\ref{BadZBRExampleEq}.\n\nThe object with matroid or oriented matroid abstraction\nalso helps generalize to $P\\neq\\emptyset$ known\nresults about Tutte functions of \ndirect sums of matroids (chiefly\n$T(M^1\\oplus M^2)T(\\emptyset)=T(M^1)T(M^2)$),\nstrong Tutte functions of matroids and \ngraphs, and about Tutte functions\nthat are multiplicative for various combinations\nof objects.\n\n\\section{Objects with Matroids or Oriented Matroids}\n\nIt is useful to think that a $P$-ported Tutte computation tree may have\nobjects $N$ for its node labels such as graphs.\nEach object $N$ has an associated\na $P$-ported matroid or oriented matroid $M(N)$.\nElements are defined $S(N)=S(M(N))$, \neach $p\\in S(N)\\cap P$ is called a port, and\n$E(N)=S(N)\\setminus P$.  Loops, coloops and non-separators of $N$\nare characterized by their status in $M(N)$.  So we\nsay $N$ is an \\emph{object with a matroid or an oriented matroid}.\nOften, but not always, $N$ will be some matroid or oriented\nmatroid representation.\n\n\nContraction $N/e$ and deletion $N\\setminus e$ \nof object $N$ are defined when $e\\in E(N)$, and\n$e$ is not a coloop in $M(N)$ and \n$e$ is not a loop in $M(N)$, respectively.\nUnder those conditions, $M(N/e)=M(N)/e$ and \n$M(N\\setminus e)=M(N)\\setminus e$ (as matroids or\noriented matroids).\nThus $P$-minors are defined,\nand an indecomposible or $P$-quotient\nis a $P$-minor $Q$ for which $S(Q)=S(M(Q))\\subseteq P$.\n\n\\begin{definition}\n\\label{OMOMdef}\nAn $P$-ported object $N$ with a matroid or oriented matroid \nis described above together with $M(N)$, $E(N)$, $S(N)$,\n$P$-minors, etc.\n\nWe say a $P$-family of objects $\\mathcal{N}$ is a $P$-minor closed class of \nobjects with matroid or oriented matroids.\n\\end{definition}\n\nTutte computation trees are defined for such $N$.\nThe matroid $M(N)$ of course\nconstrains the structure of these trees.  \nIt is possible\n(as when the edgeless graphs $G_k$ have different vertex sets but all\n$M(G_k)=\\emptyset$)\nfor different objects, \neven different indecomposibles, to have the same \nmatroid or oriented matroid.  It also natually occurs \nthat\n$N/e\\setminus f$ $\\neq$ \n$N/f\\setminus e$ (as objects) even though \n$M(N)/e\\setminus f$ $=$ \n$M(N)/f\\setminus e$.  The latter equation when \n$e,f$ are in parallel or in series (see Proposition\n\\ref{SameMinorProp}) is critical to the above ZBR theorems.\nIt is also conceivable that $N/e/f\\neq N/f/e$ or\n$N\\setminus e\\setminus f\\neq N\\setminus f\\setminus e$.\n\nSince every $P$-minor $N'$ of $N$ has matroid\nor oriented matroid $M(N')$ the same as the corresponding\nminor of $M(N)$, we observe:\n\n\\begin{lem}\n\\label{ObjectTreeValueLemma}\nThe Tutte computation trees for $M(N)$ are in a one-to-one\ncorrespondance with the \nTutte computations tree for $N$ \nwhere corresponding trees are isomorphic.  In each\nisomorphism,\ncorresponding\nbranches have the same labels ``$e$-contracted'' or\n``$e$-deleted'' with $e\\in E(N)=E(M(N))$, and a node\nlabelled $N_i$ in the tree for $N$ corresponds to \na node labelled $M(N_i)$ in the tree for $M(N)$.\n\nEach computation tree value is given by\nthe activities expansion \\eqref{PAE} reinterpreted for\nobjects.\n\\end{lem}\n\n\nWe can still talk about Tutte decompositions and a\nTutte computation tree for $N$ even  without \na Tutte function.  If we are given values $I(Q_i)$\nfor the indecomposibles, each Tutte computation tree \nfor $N$ yields a value in the $R$-module generated by\nthe $I(Q_i)$.\nThe Tutte decompositions, and the universal\nTutte polynomial (if it exists!)\nof each $N\\in \\mathcal{N}$\nare determined by $M(N)$ and the indecomposibles, i.e., $P$-quotients\n$Q_i$ in $N$, which of course satisfy $Q_i \\in \\mathcal{N}$.\nThis generalizes Zaslavsky's discussion\\cite{MR93a:05047}.\n\n\\begin{definition}[Separator-strong $P$-ported Tutte function on objects]\n\nFunction\n$T$ on $\\mathcal{N}$\nis a $P$-ported separator-strong Tutte function\non $\\mathcal{N}$ into \nthe ring $R$ \ncontaining parameters $x_e, y_e, X_e, Y_e$,\nor an $R$-module containing the initial values\n$T(Q_i)=I(Q_i)$ for indecomposibles,\nwhen \nfor each $e\\in E(N)$ for some $N\\in\\mathcal{N}$,\nif $T(N)$ satisfies \\eqref{TA} and \\eqref{TSSM} for all $N\\in\\mathcal{N}$.\n\\end{definition}\n\nTherefore:\n\n\\begin{prop}\n$T$ is a $P$-ported separator-strong Tutte function\non $\\mathcal{N}$ if and only if for each $N\\in\\mathcal{N}$,\nall Tutte computation trees for $T(N)$ yield polynomial expressions\nthat are equal in the range ring or $R$-module.\n\\end{prop}\n\nWe develop our first ZBR-type theorem for $P$-ported objects\nwith matroids or oriented matroids.  It is the\ngeneralization of the ZBR theorem for graphs as given\nby Ellis-Monaghan and Traldi\\cite{Ellis-Monaghan-Traldi}.  \nIt depends on a lemma similar to one of theirs.\n\n\n\\begin{lem}\n\\label{DisjSubclassLem}\nSuppose $P$-family $\\mathcal{N}$ is partitioned into\ndisjoint $P$-minor closed subfamilies $\\{\\mathcal{N}_{\\pi}\\}$.\nThen $T$ is a Tutte function on $\\mathcal{N}$ if and\nonly if $T$ restricted to $\\mathcal{N}_{\\pi}$ is\na Tutte function for each $\\mathcal{N}_{\\pi}$.\n\\end{lem}\n\n\\begin{thm}\n\\label{ZBRWildFamily}\nSuppose $P$-family $\\mathcal{N}$ is partitioned into\ndisjoint $P$-minor closed subfamilies $\\{\\mathcal{N}_{\\pi}\\}$,\nand each initial value $I(Q_i)$ depends only on\nthe matroid or oriented matroid $M(Q_i)$ and on the\n$\\pi$ for which $Q_i\\in\\mathcal{N}_{\\pi}$,\n\nThen $T$ is a Tutte function with given parameters $(x,y,X,Y)$\nand initial values $I(Q_i)$ if and only if it satisfies\nthe equations of Theorem \\ref{BigTheorem}, interpreted\nfor families of objects with matroids or oriented matroids.\n\\end{thm}\n\n\\begin{proof}\nAs in \\cite{Ellis-Monaghan-Traldi}, lemma\n\\ref{DisjSubclassLem} lets us prove the\ntheorem for each $\\pi$ separately.\n\n\nBy Lemma \\ref{ObjectTreeValueLemma}, $T$ is a \n$P$-ported Tutte function of family\nof objects $\\mathcal{N}_{\\pi}$ if and only\nif function $T'(M(N))=T(N)$ on the $P$-family of\nthe matroids or oriented matroids of\n$N\\in\\mathcal{N}_{\\pi}$ is a $P$-ported Tutte \nfunction, since by hypothesis \n$I'(M(Q_i))=I(Q_i)=I(M(Q_i))$ for corresponding\nindecomposibles $Q_i\\in\\mathcal{N}_{\\pi}$ and \n$M(Q_i)$ in the matroid or oriented matroid $P$-family.\n\nThe conclusion follows\nfrom Theorem \\ref{BigTheorem} applied to\nthis matroid or oriented matroid $P$-family.\n\\end{proof}\n\n\nEllis-Monaghan and Traldi's ZBR theorem for graphs \nrefers to one initial value $\\mathcal{\\alpha}_k=I(E_k)$\nfor each non-empty subclass of graphs, with unlabelled vertices, that\nhave $k$ graph components.  One natural ported generalization\nis to partition the $P$-ported graphs $G$\naccording to (1) how many\ngraph components $k$, (2) $P'=P\\cap S(G)$ and (3)\n$\\nu:P'\\rightarrow\\{1,\\ldots,k\\}$, where $\\nu{p}$ is which\ncomponent contains edge $p$.  Theorem\n\\ref{ZBRWildFamily} tells us:\n\n\\begin{cor}\n\\label{PZBRGraphCor1}\n\nLet a $P$-minor closed collection $\\mathcal{G}$ of graphs with unlabelled\nvertices be partitioned into $\\mathcal{G}_{k,P',\\nu}$.  Suppose initial\nvalues $I(G)=I_{k,P',\\nu}(M(G))$ are given that depend only on the \npart and the matroid or oriented matroid of $G\\in\\mathcal{G}_{k,P',\\nu}$.\nThen there is $T$, $P$-ported separator-strong parametrized Tutte function\nof graphs $\\mathcal{G}$ satisfying $T(Q)=I(Q)=I_{k,P',\\nu}(M(Q))$ whenever\n$P$-quotient $Q\\in\\mathcal{G}_{k,P',\\nu}$ if and only if the identities\nof Theorem \\ref{BigTheorem}, interpreted for graphs, are satisfied with \nthe given $I(Q)$.\n\\end{cor}\n\nThe next ZBR-type theorem  addresses the problem \nillustrated by \\eqref{BadZBRExampleEq} requires that\nthe $P$-family satisfy the following\n\n\\begin{definition}\nObject $N\\in\\mathcal{N}$ is \\emph{well-behaved} when\nfor every independent set $C\\subseteq E(N)$ and\ncoindependent set $D\\subseteq E(N)$ for which\n$C\\cap D=\\emptyset$, each of the\n$|C\\dunion D|!$ orders \nof contracting $C$ and deleting $D$ produces the\nsame $P$-minor (which is an object) of $N$.\n\nSpecifically, let \n$C=\\{c_1,\\ldots,c_j\\}$,\n$D=\\{d_{j+1},\\ldots,d_k\\}$\nand $R_i(N')=N'/c_i$ if $1\\le i \\le j$\nand $N'\\setminus d_i$ if $j+1\\le i \\le k$.\nThe condition is \n$R_1\\circ\\cdots\\circ R_k(N) = R_{\\sigma_1}\\circ\\cdots\\circ R_{\\sigma_k}(N)$\nfor every permutation $\\sigma$ of $\\{1,\\ldots,k\\}$.\n\n$\\mathcal{N}$ is \\emph{well-behaved} when \neach $N\\in\\mathcal{N}$ is well-behaved.\n\n\\end{definition}\n\nBy definition \\ref{OMOMdef} \nall the minors are defined and\n$M(R_1\\circ\\cdots\\circ R_k(N)) = M(R_{\\sigma_1}\\circ\\cdots\\circ R_{\\sigma_k}(N))$\nindependently of whether $N$ is well-behaved or not.\nThe point is that the objects themselves are the same.\n\nWe give two examples of well-behaved $P$-families.\n\n\\begin{definition}[Graphs with set-labelled vertices]\n\\label{GSLVDefinition}\nThe elements of such a graph $S(G)=E(G)\\dunion(P\\cap S(G))$ are edges.\nThe vertices are labelled with non-empty\nfinite sets so the two sets labelling distinct vertices in one\ngraph are disjoint.  Only non-loop edges $e\\not\\in P$\ncan be contracted; when an edge is contracted, its two endpoints\nare replaced by one vertex whose label is the union of the \nlabels of the two endpoints.  Only non-isthmus edges $e\\not\\in P$\ncan be deleted; deletion doesn't change labels.  The graph\nhas its graphic matroid if it is undirected and its\noriented graphic matroid if it is directed.\n\\end{definition}\n\nA graph with set-labelled vertices is well-behaved because\nthe minor obtained  by contracting forest $C$\nand deleting $D$ is determined by merging all the vertex labels\nof each graph component of $C$ and deleting edges $C\\cup D$.  Note\nthat the deletions do not affect the vertex labels.  Hence\nthe set labels are not affected by the order\nof the operations.\n\n\n\\begin{definition}[Graphs with set-labelled components]\n\\label{GSLCDefinition}\nThe elements of such a graph $S(G)=E(G)\\dunion(P\\cap S(G))$ are edges.\nThe path-connected components are labelled by\nnon-empty finite sets so two components in the same\ngraph always have disjoint labels.  In other words,\nthe set labels of the components are a partition $\\pi_V$\nOnly non-loop edges $e\\not\\in P$\ncan be contracted and only non-isthmus edges \n$e\\not\\in P$\ncan be deleted.\nThe component labels are unchanged by these minor operations.\nDefinition \\ref{GSLVDefinition} specifies the\nmatroids or oriented matroids.\n\\end{definition}\n\n\nA non-well-behaved $P$-family $\\mathcal{C}!$\ncan be constructed from\nany $P$-family of matroids $\\mathcal{C}$ with\nsome $M\\in\\mathcal{C}$ with $|E(M)|\\geq 2$.  \nEach member of $\\mathcal{C}!$ is formed from\nsome $M\\in\\mathcal{C}$ together with some\nhistory of deletions and contractions that\ncan be applied to $M$.  Let $c_e$ and $d_e$ be symbols\nfor contracting and deleting $e\\in E(\\mathcal{C})$\nrespectively; a history $h$ is a string of\nsuch symbols.  \nLet $M|h$ be the $P$-minor obtained by \nperforming history $h$ on $M$, assuming each step\nis defined.  The objects of $\\mathcal{C}!$\nare all pairs $(M,h)$ for which \n$P$-minor $M|h\\in\\mathcal{C}$ is defined.\nThe matroid of $(M,h)$ is $M|h$, which\ndetermines the element set, loops and coloops.\nIf $e\\in E(M|h)$ is not\na loop, then define $(M,h)/e=(M,hc_e)$.\nSimilarly, if $e\\in E(M|h)$ is not\na coloop, $(M,h)\\setminus e=(M,hd_e)$.\n\nThe point of this example is that even if\nthe $P$-family is not well-behaved and so the\nindecomposibles do carry information about their\nhistory, Theorem \\ref{ZBRWildFamily} tells \nus that the Tutte function\nis still well defined if the initial values depend only\non the matroid, or the oriented matroid, of the \nindecomposible.\n\n\nThe examples forced us to recognize that\nfor $N$ an object with a matroid or oriented matroid $M(N)$\nwith\n${e,f}\\in E(N)$ in series or in parallel,  it might\nhappen that $N/e\\setminus f\\neq N/f\\setminus e$ even though,\nby Proposition \\ref{SameMinorProp}, \n$M(N)/e\\setminus f= M(N)/f\\setminus e$.  Note that \nProposition \\ref{SameMinorProp} is about \n$\\cdot/e\\setminus f$ and \n$\\cdot/f\\setminus e$ which are not commutations\nof the same two operations.\n\n\\begin{thm}[ZBR Theorem for well-behaved \n$P$-families of objects with matroids or\noriented matroids]\n\\label{ZBRWellBehaved}\n\nLet $\\mathcal{N}$ be a well-behaved \n$P$-family of objects with matroids or oriented\nmatroids.\n\nThe following two statements are equivalent.\n\\begin{enumerate}\n\\item $T$ from $\\mathcal{N}$ to $R$ or an $R$-module is a $P$-ported \nseparator-strong parametrized\n$P$-ported Tutte function with $R$-parameters $(x, y, X, Y)$ whose values \n$T(Q_i)$ on $P$-quotients $Q_i\\in\\mathcal{N}$ are the initial\nvalues $I(Q_i)$.\n\\item\nFor every $N\\in\\mathcal{N}$:\n\\begin{enumerate}\n\\item \nIf $M(N)=U^{ef}_1\\oplus M(Q_j)=U^{ef}_1\\oplus M(Q_j')$ with \n$P$-quotients $Q_j=N/e\\setminus f$ and $Q_j'=N/f\\setminus e$,\n\\[\nI(Q_j)(x_e Y_f - y_f X_e ) = \nI(Q_j')(x_f Y_e - y_e X_f).\n\\]\n\\item\nIf $M(N)=U^{efg}_2\\oplus M(Q_j)=U^{efg}_2\\oplus M(Q_j')$ with \n$P$-quotients $Q_j=N/e\\setminus f/g$ \nand $Q_j'=N/f\\setminus e/g$,\n\\[\nI(Q_j)X_g(x_e y_f - y_f X_e ) = \nI(Q_j')X_g(x_f y_e - y_e X_f ).\n\\]\n\\item\nIf $M(N)=U^{efg}_1\\oplus M(Q_j)=U^{efg}_1\\oplus M(Q_j')$ with \n$P$-quotients $Q_j=N/e\\setminus f\\setminus g$  \nand $Q_j'=N/f\\setminus e\\setminus g$,\n\\[\nI(Q_j)Y_g(x_e Y_f - y_f x_e) = \nI(Q_j')Y_g(x_f Y_e - y_e x_f).\n\\]\n\\item\nIf $\\{e,f\\}=E(M(N))$ is a parallel pair connected to $P$, \n\\[\nI(Q_j)(x_e Y_f - y_f x_e) = \nI(Q_j')(x_f Y_e - y_e x_f)\n\\]\nwhere $P$-quotients $Q_j=N/e\\setminus f$\nand $Q_j'=N/f\\setminus e$.\n\\item\nIf $\\{e,f\\}=E(M(N))$ is a series pair connected to $P$, \n\\[\nI(Q_j)(x_e y_f - y_f X_e) = \nI(Q_j')(x_f y_e - y_e X_f)\n\\]\nwhere $P$-quotients\n$Q_j=N/e\\setminus f$ \nand $Q_j'=N/f\\setminus e$.\n\\end{enumerate}\n\\end{enumerate}\n\\end{thm}\n\n\\begin{proof}\nthe Tutte function value \nfor each tree depends only on the tree structure and the\ninitial values.\nThe fact the $\\mathcal{N}$ is well-behaved\nallows us to conclude that ...\n\nThe rest is analogous to the proof we gave for Theorem \\ref{BigTheorem}.\n\\end{proof}\n\n\n\n\\begin{cor}\n\\label{IVEqualSerParCor}\nA $P$-family of objects with matroids satisfies a ZBR-type theorem\nwith the identities given in Theorem \\ref{BigTheorem} if, \nin \naddition $\\mathcal{N}$ being well-behaved,\nthe initial values $I$ satisfy\n$I(N/e\\setminus f)=T(N/f\\setminus e)$ when $\\{e,f\\}=E(N)$ is a series\nor parallel pair,\n$I(N/e\\setminus f/g)=I(N/f\\setminus e/g$ when $\\{e,f,g\\}=E(N)$ is a \ntriangle and \n$I(N/e\\setminus f\\setminus g)=I(N/f\\setminus e\\setminus g)$ \nwhen $\\{e,f,g\\}=E(N)$ \nis a triad.\n\\end{cor}\n\n\n\\begin{cor}\nA $P$-family of objects with matroids satisfies a ZBR-type theorem\nwith the identities given in Theorem \\ref{BigTheorem} if, in \naddition to $\\mathcal{N}$ being well-behaved,\nthe object $P$-quotients \n$N/e\\setminus f=N/f\\setminus e$ when $\\{e,f\\}=E(N)$ is a series\nor parallel pair,\n$N/e\\setminus f/g=N/f\\setminus e/g$ when $\\{e,f,g\\}=E(N)$ is a \ntriangle and \n$N/e\\setminus f\\setminus g=N/f\\setminus e\\setminus g$ when $\\{e,f,g\\}=E(N)$ \nis a triad.\n\\end{cor}\n\n\\begin{proof}\nClearly, if $N/e\\setminus f=N/f\\setminus e$ then \n$T(N/e\\setminus f)=T(N/f\\setminus e)$, etc.\n\\end{proof}\n\nWe conclude with second ported generalization of \nEllis-Monaghan and Traldi's ZBR theorem for graphs,\nbesides Corollary \\ref{PZBRGraphCor1}.\n\n\\begin{cor}\n\\label{PZBRGraphCor2}\nLet $\\mathcal{G}$ be a ported $P$-family of graphs with\nunlabelled vertices, as in Corollary \\ref{PZBRGraphCor1}.\nThen there is $T$, $P$-ported separator-strong parametrized Tutte function\nof graphs $\\mathcal{G}$ satisfying $T(Q)=I(Q)$ \nfor all $P$-quotients $Q\\in\\mathcal{G}$ if and only if \nFor every $G\\in\\mathcal{G}$:\n\\begin{enumerate}\n\\item \nIf $E(G)$ is dyad $\\{e,f\\}$ then\n\\[\nI(Q)(x_e Y_f - y_f X_e ) = \nI(Q)(x_f Y_e - y_e X_f).\n\\]\nwhere $Q=G/e\\setminus f=G/f\\setminus e$.\n\\item\nIf $E(G)$ is triangle $\\{e,f,g\\}$ then\n\\[\nI(Q)X_g(x_e y_f - y_f X_e ) = \nI(Q)X_g(x_f y_e - y_e X_f ).\n\\]\nwhere $Q=G/e\\setminus f=G/f\\setminus e$.\n\\item\nIf $E(G)$ is triad $\\{e,f,g\\}$ then\n\\[\nI(Q)Y_g(x_e Y_f - y_f x_e) = \nI(Q)Y_g(x_f Y_e - y_e x_f).\n\\]\nwhere $Q=G/e\\setminus f=G/f\\setminus e$.\n\\item\nIf $E(G)\\{e,f\\}$ is a parallel pair connected to $P$, \n\\[\nI(Q)(x_e Y_f - y_f x_e) = \nI(Q)(x_f Y_e - y_e x_f)\n\\]\nwhere $Q=G/e\\setminus f=G/f\\setminus e$.\n\\item\nIf $E(G)=\\{e,f\\}$ is a series pair connected to $P$, \n\\[\nI(Q)(x_e y_f - y_f X_e) = \nI(Q')(x_f y_e - y_e X_f)\n\\]\nwhere $P$-quotients\n$Q=G/e\\setminus f$ \nand $Q'=G/f\\setminus e$.\n\\end{enumerate}\n\\end{cor}\n\nNote: The last is the \\emph{only} case where the equation is \ndifferent from the one in the $P$-ported ZBR theorem for matroids\nor oriented matroids.  \n\n\\begin{proof}\n$\\mathcal{G}$ is a well-behaved $P$-family of ported objects\nwith matroids or oriented matroids, so Theorem \\ref{ZBRWellBehaved}\napplies.\n\nIn all cases of Theorem \\ref{ZBRWellBehaved} but the\nlast, the two object minors are the same graph \nbecause the contracted edges are path-connected,\nso the equations of Theorem \\ref{ZBRWellBehaved} are simplified.\n\\end{proof}\n\nBoth Corollaries \\ref{PZBRGraphCor1} and \\ref{PZBRGraphCor2} reduce\nto the ZBR theorem for graphs when $P=\\emptyset$.  The first\nuses the property that $\\mathcal{G}$ is partitioned into\nminor-closed subclasses with indecomposibles $E_k$ \nfor which the\ninitial values depend only on the matroid or oriented matroid to generalize\nthe original ZBR equations.  As with matroids, we find again that\nthe Tutte functions can distinguish different orientations of the \nthe same undirected graphs.\nThe second relies on the \ncommutivity of the graph minor operations and generalizes\nthe fact that different initial values may be assigned to\ndifferent indecomposibles, but then the \nconditions sufficient for the initial values to\nextend to a Tutte function must be stronger.\n\n\n\\section{Direct and other Sums} \n\\label{DirectSec}\n\nIt is a common situation that $\\{N^1,N^2,N\\}\\subseteq\\mathcal{N}$\nand their matroids or oriented matroids $M(N^1)\\oplus M(N^2)=M(N)$.\nTutte computation trees help.  The proposition below applies\neven to non-well-behaved $N$ when the symbols\n$/B^j_i|P_j$ refer to sequences of deletions and contractions.\n\n\\begin{definition}\nIf $\\mathcal{T}_1$ and $\\mathcal{T}_2$ are Tutte computation trees then\n$\\mathcal{T}_1\\cdot \\mathcal{T}_2$ is the tree obtained by appending\na separate copy of $\\mathcal{T}_2$ at each leaf of $\\mathcal{T}_1$.\nThe root is the root of the expanded $\\mathcal{T}_1$.\n\\end{definition}\n\n\\begin{prop}\n\\label{SumProp2}\n\nSuppose $N$, $N^1$ and $N^2$ are all in $\\mathcal{N}$\nand $M(N^1)\\oplus M(N^2)=M(N)$.  Then if\n$\\mathcal{T}_1$ and $\\mathcal{T}_2$ are Tutte computation\ntrees for $N^1$ and $N^2$ respectively with values given\nby \\eqref{DS1} and \\eqref{DS2}, then there is a Tutte\ncomputation tree for $N$ that yields the value given\nby \\eqref{DS}.\n\n\\begin{equation}\n\\label{DS1}\n\\tag{DS1}\n\\sum_{Q^1_i}I(Q^1_{i})c_1(Q^1_{i})\\text{ where }Q^1_i=N/B^1_i|P_1.\n\\end{equation}\n\\begin{equation}\n\\label{DS2}\n\\tag{DS2}\n\\sum_{Q^2_j}I(Q^2_{i})c_2(Q^2_{j})\\text{ where }Q^2_i=N/B^2_i|P_2.\n\\end{equation}\n\\begin{equation}\n\\tag{DS}\n\\label{DS}\n\\sum_{Q^1_i,Q^2_j}I(Q_{i,j})c_1(Q^1_{i})c_2(Q^2_{j})\n\\text{ where }Q_{i,j}=N/B^1|P_1\\cup S(N^2)/B^2|P_2.\n\\end{equation}\n\nFurthermore, if $T$ is a Tutte function on $\\mathcal{N}$\nand $T(N^1)$ and $T(N^2)$ equal the Tutte polynomials\ngiven by \\eqref{DS1} and \\eqref{DS2} then \n$T(N)$ equals the polynomial given by \\eqref{DS}.\n\\end{prop}\n\n\\begin{proof}\n\nWe show how to relabel $\\mathcal{T}_1\\cdot\\mathcal{T}_2$ to obtain \na Tutte computation tree for $N$.  $M(N^1)\\oplus M(N^2)=M(N)$ is defined\nmeans $S(M(N^1))\\cap S(M(N^2))=\\emptyset$ and \n$S(M(N))=S(M(N^1))\\cup S(M(N^2))$.   Each node of \n$\\mathcal{T}_1\\cdot\\mathcal{T}_2$ is determined by \nby deleting and/or contracting some elements of\n$E(M(N^1))\\cup E(M(N^2))$.  Relabel that node with the \n$P$-minor of $N$ obtaining deleting and/or contracting the\nsame elements respectively in the same order, those in $N^1$\npreceding those in $N^2$.  The result is a computation tree for $N$\nbecause $M(N^1)\\oplus M(N^2)=M(N)$.  Assume $P\\subseteq S(M(N))$\n(otherwise, take a smaller $P$) and let $P^1=S(M(N^1))\\cap P$\nand $P^2=S(M(N^2))\\cap P$.\nAt a leaf of the relabelled\ntree, there will be the $P$-quotient $N/B_1/B_2|P$ where\n$B_1$ is a $P^1$-subbasis of $M(N^1)$ and $B_2$ is a $P^2$-subbasis\nof $M(N^2)$.  \n\n\\end{proof}\n\n\\subsection{Strong Tutte Functions}\n\nLet us extend the definition of strong parametrized Tutte function\nto $P$-families $\\mathcal{N}$ of objects with matroids and oriented matroids,\nin the way that abstracts the known notion of strong Tutte functions\non minor closed families of graphs\\cite{Ellis-Monaghan-Traldi}.\nOf course, taking $\\mathcal{N}$ to be a $P$-family $\\mathcal{C}$ of \nmatroids or oriented matroids gives us the extension to such $\\mathcal{C}$.\nThen, there might still be indecomposibles besides or instead of $\\emptyset$.\n\n\\begin{definition}\nA $P$-ported separator-strong Tutte function $T$ on a $P$-family of \nobjects $\\mathcal{N}$\nwith matroids is called \\emph{strong} if\nwhenever $\\{N^1, N^2, N\\}\\subseteq\\mathcal{N}$\nand \n$M(N^1)\\oplus M(N^2)=M(N)$, \nthen $T(N^1)T(N^2)=T(N)$.\n\\end{definition}\n\n\nWe can use Proposition \\ref{SumProp2}\nto prove the generalization of\nthe $T(\\emptyset)T(\\emptyset)=T(\\emptyset)$ \ncharacterization of strong Tutte\nfunctions.\n\n\\begin{thm}\n\\label{StrongTheorem}\nA $P$-ported separator-strong Tutte function $T$ on a $P$-family of \nobjects \nwith matroids or oriented matroids $\\mathcal{N}$ \nis \\emph{strong} if and only if\n$T$ restricted to the indecomposibles of \n$\\mathcal{N}$ is strong; i.e.,\nwhenever $Q^1$, $Q^2$ and \n$Q$ are indecomposibles and $M(Q^1)\\oplus M(Q^2)=M(Q)$ then\n$T(Q^1)T(Q^2)=T(Q)$.\n\\end{thm}\n\n\\begin{proof}\nEvery $P$-quotient is in $\\mathcal{N}$, so clearly $T$ restricted\nto the $P$-quotients is strong.\n\nConversely, suppose $N^1$, $N^2$ and $N$ are in $\\mathcal{N}$ and\n$M(N^1)\\oplus M(N^2)=M(N)$, so Proposition \\ref{SumProp2} applies.\n\nSince $M(N^1)\\oplus M(N^2)=M(N)$, \n$M(N/(B_1\\cup B_2)|P)$ $=$ $(M(N^1)/B_1|P)\\oplus (M(N^2)/B_2|P)$\n$=$ $M(N^1/B_1|P)\\oplus M(N^2/B_2|P)$.  \nWe now use the fact\nthat $Q_{ij}=N/B_1/B_2|P$, $Q^1_i=N^1/B_1|P$ and $Q^2_j=N^2/B_2|P$ are \n$P$-quotients and the hypothesis to\nwrite $T(Q_{ij})=T(Q^1_i)T(Q^2_j)$.  \n\n\nWe therefore conclude $T(N)=T(N^1)T(N^2)$\nfrom \\eqref{DS1}, \\eqref{DS2} and  \\eqref{DS}.\n\n\\end{proof}\n\n\\subsection{Multiplicative Tutte Functions}\n\nOften\n$\\mathcal{N}$ comes equipped with one \noperation ``$*$'', or more, that satisfy\nthe following definition.  \nExamples for $P=\\emptyset$ are disjoint union $\\amalg$\nand one-point unions of graphs \\cite{Ellis-Monaghan-Traldi}.\nThese can be extended to $P$-ported graphs \nand disjoint union can be extended to $P$-families of \nobjects.\n\n\\begin{definition}\nA partially defined binary operation ``$*$'' on\na $P$-family of objects with matroids or oriented matroids\n$\\mathcal{N}$ is \\emph{a matroidal direct sum} if \nwhenever $N^1*N^2\\in\\mathcal{N}$ is defined for\n$\\{N^1,N^2\\}\\subseteq\\mathcal{N}$, the \nmatroids or oriented matroids satisfy\n$M(N^1)\\oplus M(N^2) = M(N^1*N^2)$.\n\\end{definition}\n\nProposition \\ref{SumProp2} applies\nwhen $N^1*N^2=N$ is defined.\nIt gives a general recipe for $T(N^1*N^2)$ which generalizes\nthe identity \\cite{Ellis-Monaghan-Traldi}\n$T(M^1\\oplus M^2)T(\\emptyset)=T(M^1)T(M^2)$ \nfor separator-strong Tutte functions of\nmatroids.\nThe $P$-ported generalization is more complicated and generally cannot\nbe expressed by a product in the domain ring of $T$.  \n\n\\begin{prop}\n\\label{SumProp}\nSuppose $*$ is a matroidal direct sum and\n$N^1$, $N^2$ and $N^1*N^2$ are each members of a $P$-family\nfor which $T$ is a Tutte function.\n\nIf for $P$-quotients $Q^j_i$ and $R$-coefficients $c_j(Q^j_i)$, $j=1$ and $2$,\n\\begin{equation}\n\\label{MD1}\n\\tag{MD1}\nT(N^1) = \\sum_{Q^1_i}T(Q^1_{i})c_1(Q^1_{i})\n\\end{equation}\nand\n\\begin{equation}\n\\label{MD2}\n\\tag{MD2}\nT(N^2) = \\sum_{Q^2_j}T(Q^2_{i})c_2(Q^2_{j})\n\\end{equation}\nthen\n\\begin{equation}\n\\label{MD}\n\\tag{MD}\nT(N^1 * N^2) = \\sum_{Q^1_i,Q^2_j}T(Q^1_{i}*Q^2_{j})c_1(Q^1_{i})c_2(Q^2_{j}).\n\\end{equation}\n\\end{prop}\n\n\\begin{proof}\nSubstitute $Q_{i,j}=Q^1_i*Q^2_j$ in \\eqref{DS} of Proposition \\ref{SumProp2}.\n\\end{proof}\n\n\nWhen $\\mathcal{N}$ is a $P$-family of matroids or oriented matroids,\ndirect matroid or oriented matroid sum is obviously a matroidal direct\nsum operation, and so Proposition \\ref{SumProp} is applicable.\n\n\\begin{cor}\\cite{Ellis-Monaghan-Traldi}\nLet $P=\\emptyset$.\n$T(M^1\\oplus M^2)T(\\emptyset) = T(M^1)T(M^2)$ for Tutte\nfunction $T$ of matroids.\n\\end{cor}\n\n\\begin{proof}\nOur proof demonstrates how Proposition \\ref{SumProp}\ngeneralizes this formula to $P$-families.\nThe expansions \\ref{DS1} and \\ref{DS2} take the one-term form\n$T(M^j) = T(\\emptyset) c_j(\\emptyset)$, $j$ $=$ $1,2$,\nso $T(M^1)T(M^2)=T(\\emptyset)^2 c_1(\\emptyset) c_2(\\emptyset)$.\nExpansion \\ref{DS} is then\n$T(M^1\\oplus T^2)=T(\\emptyset) c_1(\\emptyset) c_2(\\emptyset)$.\n\\end{proof}\n\nFollowing the definitions for graphs in \\cite{Ellis-Monaghan-Traldi}, we write:\n\n\\begin{definition}\nGiven a matroidal direct sum $*$ on $\\mathcal{N}$, \na Tutte function $T$ on $\\mathcal{N}$ is\n\\emph{multiplicative} (with respect to ``$*$'')\nif whenever $N^1*N^2$ is defined\nfor $\\{N^1,N^2\\}\\subseteq \\mathcal{N}$, the Tutte\nfunction values satisfy \n$T(N^1)T(N^2)=T(N^1*T^2)$.\n\\end{definition}\n\nA strong Tutte function is certainly multiplicative\nfor any ``$*$'', but not conversely.  A consequence\nof Proposition \\ref{SumProp2} is that,\nlike strong Tutte functions, multiplicative\nTutte functions are characterized by being that way\non the indecomposibles.  \n\n\\begin{cor}\nA $P$-ported Tutte function $T$ on $P$-family $\\mathcal{N}$ \nis multiplicative with respect to matroidal direct product\n``$*$'' if and only if \nfor every pair of indecomposibles $\\{Q_i, Q_j\\}\\in\\mathcal{N}$ for which \n$Q_i*Q_j\\in\\mathcal{N}$ is defined, $T(Q_i)T(Q_j)=T(Q_i*Q_j)$.\n\\end{cor}\n\n\\begin{proof} \nWhen $N^1*N^2$ is defined, Proposition \\ref{SumProp2}\napplies because $M(N^1)\\oplus  M(N^2)=M(N^1*N^2)$.\n$T(N^1*N^2)=T(N^1)T(N^2)$ is then a consequence\nof $T(Q_i*Q_j)=T(Q_i)T(Q_j)$.\n\\end{proof}\n\nIn the case when $P=\\emptyset$ and the vertices are unlabelled,\nwe can prove a strengthening of part of Ellis-Monaghan and Traldi's\nCorollary 3.13.  It is stronger because it does not require \nany additional hypotheses on $\\mathcal{G}$ to prove that all\ninitial values that occur are the same idempotent.\n\n\\begin{cor}\nSuppose $T$ is parametrized Tutte function on a minor-closed class\nof graphs $\\mathcal{G}$ (note $P=\\emptyset$.)  \n$T$ is strong if and only if \nthere is an idempotent $\\alpha=\\alpha^2\\in R$ and $T(E_k)=\\alpha$\nwhenever $\\mathcal{G}_k\\neq\\emptyset$.\n\\end{cor}\n\n\\begin{proof}\n$M(E_k)=\\emptyset$ for all $k\\geq 1$ and \n$\\emptyset\\oplus\\emptyset=\\emptyset$, so \n$T(E_i)T(E_j)=T(E_k)$ whenever $\\mathcal{G}_i$,\n$\\mathcal{G}_j$ and \n$\\mathcal{G}_k$ are all non-empty.  Hence, if\n$\\mathcal{G}_k\\neq\\emptyset$ then $T(E_k)T(E_k)=T(E_k)=\\alpha$.\nFurther, if $\\mathcal{G}_j\\neq\\emptyset$ with $j\\neq k$,\n$\\alpha=T(E_k)=T(E_k)T(E_k)=T(E_j)$.\n\\end{proof}\n\nThe other case of Corollary 3.13 \\cite{Ellis-Monaghan-Traldi} requires\nadditional conditions for a Tutte function that is multiplicative on\nboth disjoint union $\\amalg$ and one-point unions  to always\nbe strong.  Consider $\\mathcal{N}=\\{E_3, E_4, E_5,  \\ldots \\}$,\n$T(E_k)=1$ for $k\\geq 3$, $k\\neq 5$ and \n$T(E_5)=0$.  $T(E_3)T(E_4)=1\\neq T(E_5)$, so \n$T$ is not strong, but $T$ is multiplicative\non disjoint and one-point unions because $E_5$ cannot be expressed\nas either kind of union of graphs in $\\mathcal{G}$.  The other conditions\nare that $\\mathcal{G}_k\\neq\\emptyset$ for all $k$ and that \n$\\mathcal{G}$ is closed under one-point unions and removal of isolated\nvertices.\n\n\\section{Acknowledgements}\n\nI wish to thank the Newton Institute for Mathematical Sciences\nof Cambridge University for hospitality and support of my\nparticipation in the Combinatorics and Statistical Mechanics\nProgramme, January to July 2008, during which some of this\nwork and much related subjects were reviewed and discussed.\n\nI thank the organizers of \nthe Thomas H. Brylawsky Memorial Conference, Mathematics Department of\nThe University of North Carolina, Chapel Hill, October 2008, \nHenry Crapo, Gary Gordon and James Oxley\nfor\nfostering collaboration beween people who carry\non the memory of Prof. Brylawsky and editing this journal\nissue.  \n\nI thank Lorenzo Traldi for bringing to my attention and\ndiscussing Diao and Hetyei's work, as well as\nJoanne Ellis-Monaghan, Gary Gordon, Elizabeth McMahon\nand Thomas Zaslavsky for helpful conversations and communications\nat the Newton Institute and elsewhere, and\nmy University at Albany colleague Eliot Rich for mutual assistance with\nwriting.\n\nThis work is also supported by a Sabbatical leave granted\nby the University at Albany, Sept. 2008 to Sept. 2009.\n\n\n\n\\bibliographystyle{abbrv}\n\\bibliography{ParamTutte}\n\n\n\\end{document}\n\n\n\\newpage\n\n\n\\section*{FIGURES TO PLACE}\n\n\\begin{figure}[!h]\n\\input{2parP.pdf_t}\n\\caption{$\\{e,f\\}=E(M)$ are parallel connected to $P$. $Q_1=M/e\\setminus f$ $=$\n$M/f\\setminus e$, $Q_2=M\\setminus \\{e,f\\}$.}\n\\end{figure}\n\n\\begin{figure}[!h]\n\\input{2serP.pdf_t}\n\\caption{$\\{e,f\\}=E(M)$ are series connected to $P$. $Q_1=M/e\\setminus f$ $=$\n$M/f\\setminus e$, $Q_2=M/\\{e,f\\}$.}\n\\end{figure}\n\n\\begin{figure}[!h]\n\\input{digon.pdf_t}\\\\\n\\vspace{10pt}\n\\input{triad.pdf_t}\\\\\n\\vspace{10pt}\n\\input{triangle.pdf_t}\n\\caption{Cases from ZBR}\n\\end{figure}\n\n\n\\input{c4p2.pdf_t}\n\n\n\n\n\n\n\n\\end{document}\n\nThe purpose of this paper is to extend, to matroids and graphs with\na set of distinguished elements $P$,  known results and methods pertaining\nto solutions to \\eqref{TA} together with the multiplicative\nidentities\n\\begin{eqnarray}\n\\label{M-P-T-identities}\nT(M)=X_e T(M/e) \\text{ if $e\\in S(M)$ is a coloop}\\\\\nT(M)=Y_e T(M\\setminus e) \\text{ if $e\\in S(M)$ is a loop}\\\\\nT(M_1\\oplus M_2)=T(M_1)T(M_2)\n\\end{eqnarray}\nwhen these identities are restricted to apply only when $e\\not\\in P$.\nSolutions to \\eqref{TA} and \\ref{TSM} are\ncalled \\emph{Tutte functions}.  \n\n\nZaslavsky\\cite{MR93a:05047}\ndefines the normal class of parametrized (but not ported) Tutte\nfunctions as those Tutte functions for which there exist \n$u$ and $v$ for which, for all $e$,\nthe point value on coloop $e$ is $r_eu + g_e$ \nand the point value\non loop $e$ is $g_ev + r_e$.  The normal Tutte functions \nare exactly those obtained by substitutions into the parametrized corank-nullity\npolynomial.  All Tutte invariants are normal Tutte functions\nand non-normal Tutte functions do not express much of\nthe matroid structure---See \n\\cite{MR93a:05047,BollobasRiordanTuttePolyColored,Ellis-Monaghan-Traldi}\nfor details about how parametrization complicates Tutte invariant\ntheory.  \n\nOur Theorem \\ref{MEofUnimodularExt} expresses how\n$\\ext{M}_E(\\mathcal{N})$ \nfits into the natural ported generalization of the\nnormal class.  Our extensor Tutte function of ported oriented \nunimodular matroids and its invariant specialization is expressed\nby a substitution into the ported corank-nullity polynomial of\noriented matroids.\n\nWhile only the normal Tutte functions have corank-nullity\npolynomial expressions, they all have \nbasis expansion expressions\\cite{MR93a:05047}.\nIn the rest of this section, we discuss these and other\nexpansion expressions for ported unoriented and oriented matroids.\n\nUnlike in the non-parametrized case, even without\ndistinguished elements, different formal polynomials result from\ndifferent calculations.  These formal polynomials are in the\nparameters, values for $T$ of loops, coloops and the initial value\n$T(\\emptyset)$.  Additional polynomial identities in these values must\nbe satisfied in order for the values together with the to have a\nsolution.  A solution of course means that $T(M')$ for all the\n(matroid) minors of $M$ satisfy all the Tutte identities;\nequivalently, all calculation sequences give the same result.  When\nthe parameters are all $1$, the value for each loop is $t$, the value\nfor each coloop is $z$ and the initial value $T(\\emptyset)=1$, it is\nwell-known that the identities have a unique solution which is a\npolynomial in $z$ and $t$.  That is the famous Tutte polynomial.  It\nis well-known as a universal Tutte invariant $U(M)(t,z)$--all Tutte\ninvariants $F(M)$ are obtained as $F(M)=U(M)(F(U_{0,1}),F(U_{1,1})$,\nwhere $U_{0,1}$ is the loop matroid on any ground set $\\{e\\}$ and\n$U_{1,1}$ is the coloop matroid.  Since additional conditions\ninvolving parameters, loop/coloop, and empty matroid values are needed\nfor a solution, we will avoid the term ``Tutte polynomial'' for now\nand use the term Tutte function to denote any solution to the\nparametrized Tutte equations.\n\nSeveral recent papers have demonstrated the essential equivalences\nbetween most different, seemingly incompatible forms for solutions of\nparametrized Tutte equations (which have been called ``Tutte\npolynomials'').  Their conclusions are that, like for Tutte\ninvariants, universal solutions can be given.  Their conclusion is\nthat, like for Tutte invariants, universal solutions can be given so\nthat every Tutte function is obtained by a variable substitution into\nthe universal solution.\n\n\nFor convenience in subsequent discussion, we will\ncall a theorem with identities like those in \nTheorem \\ref{BigTheorem}\nor in the ZBR theorem for graphs given by Ellis-Monaghan and \nTraldi a ZBR-matroid type theorem, and one with identities\nlike those just above a ZBR-object type theorem.  The common\nfeature of these ZBR-type theorems is that the identities\nare each associated with a minor having only two or three non-port\nelements.\n\n\n\n\n\\section{Applications to Graphs}\n\\label{GraphSec}\n\nThe $P$-family of objects with matroids or oriented matroids abstraction\nhelps us explore multiple kinds of graphs and their $P$-ported\nTutte functions.  \nWe consider only separator-strong and strong Tutte functions.\nWe first  define graphs with labelled vertices and extend\nEllis-Monaghan and Traldi's ZBR theorem for graphs to them.\n\nThat is followed by an example whose Tutte functions do satisfy\nported ZBR-matroid type theorems, and one where only \na ported ZBR-object type theorem is satisfied.\n\nIndeed, the immediate generalization of that theorem\nfails when $P\\neq\\emptyset$.  That is because, even when \n$P=\\emptyset$ so the theorem holds, the Tutte function depends on the\nindecomposible graphs, not just their matroids.  \n(????In the\n$P=\\emptyset$ case, the indecomposibles are $E_k$, the graphs\nwith no edges and $k$ vertices, so the matroids are all $\\emptyset$.)\n[[[SHOULD THIS BE IN SUM SECTION?? Next, \nwe prove that a separator-strong Tutte function is strong if\nand only if it is strong on the indecomposibles.  This is independent\nof whether the graphs satisfy a ZBR-type theorem or not!]]]\nThe section concludes with a generalization of the ZBR theorem\nfor graphs with labelled vertices.  The Tutte function must\nbe equal on all indecomposibles $Q_i$ with the same partition $\\pi$\nof vertex labels, assignment of port edges in $Q_i$ to parts of\n$\\pi$, and matroid or oriented matroid on the port edges.\nWhen $P=\\emptyset$, all the matroids become $\\emptyset$ as in\nEllis-Monaghan and Traldi's ZBR theorem for unlabelled graphs.\n\n\nSince our attitude is to retain the labels of the entities not removed\nby deletion or contraction,\nwe begin with a definition of data preserved in $P$-minors that is\nmore detailed than the number of graph components because\nit includes vertex labels.  We remind the \nreader that our  definition \\cite{Ellis-Monaghan-Traldi} \nof graph minor\nexcludes deletion of isthmuses or of isolated vertices, and \nconsiders the removal of a loop to be a deletion.\n\n\n\n\\subsection{Strong Tutte Functions}\n\nStrong parametrized Tutte functions for graphs are immediately\ngeneralized to $P$-ported graphs, and Theorem \\ref{StrongTheorem}\napplies directly.  It generalizes part of the concluding\nproposition about strong Tutte functions for graphs in \n\\cite{Ellis-Monaghan-Traldi}.\n\n\\subsection{Matroidal Direct Sums in Graphs}\n\nEllis-Monaghan and Traldi derived relationships between the parametrized\nTutte functions of two graphs $G^1, G^2\\mathcal{G}$ and their disjoint\nunion $G^1\\amalg G^2$\nand one-point union $G^1\\cdot G^2$, where $\\mathcal{G}$ was\na minor closed class.  Vertices were unlabelled and\n$\\mathcal{G}$ was partitioned into the minor-closed subclasses $\\mathcal{G}_k$\nof graphs with $k$ graph components.\nIn this situation, each non-empty $\\mathcal{G}_k$ has exactly one\nindecomposible $E_k$, the graph with no edges and $k$ vertices.  The\nresulting ZBR theorem for graphs had $\\alpha_k=T(E_k)$ in place of \n$\\alpha=T(\\emptyset)$ in the ZBR theorem for matroids, \nTheorem \\ref{ZBRmatroids}.   Every Tutte function value had the\nform $T(G)=\\alpha_kr$, $r\\in R$ where $G\\in\\mathcal{G}_k$.\n\n\\begin{prop}\n\\begin{enumerate}\n\\item If $M(G)=M(G')$ then there exist $r_i\\in R$ such that\n$T(G)=\\sum T(Q_i)r_i$ and $T(G')=\\sum T(Q_i')r_i$, where\n$Q_i'$ is the $P$-quotient of obtained by deleting and contracting\nrespectively the same set of edges from $G'$ as $Q_i$ was obtained\nfrom $G$.\n\nFor $P=\\emptyset$, this specializes to \n$T(G)=\\alpha_{k}r$ and $T(G')=\\alpha_{k'}r$ \nwhen $G\\in\\mathcal{G}_k$ and $G'\\in\\mathcal{G}_{k'}$ and \n\n\\item\nGiven any $e\\in E(G)$, one expression for $T(G)$ is\n$\\sum(r_iX_e + s_iY_e)T(Q_i)$.\n\nFor $P=\\emptyset$, this specializes to \n$T(G) =(rX_e + sY_e)\\alpha_k$, when $G\\in\\mathcal{G}_k$.\n\n\\item\nIf $G^1$, $G^2$ and $G^1\\amalg G^2\\in\\mathcal{G}$ and\n$T(G^j)=\\sum T(Q^j_i)r^j_i$ for $i=1,2$, then\n\\begin{equation*}\nT(G^1\\amalg G^2)= \\sum T(Q^1_i\\amalg T(Q^2_j)r^1_ir^2_j\n\\end{equation*}\nand\n\\begin{equation*}\nT(G^1)T(G^2)= \\sum T(Q^1_i)T(Q^2_j)r^1_ir^2_j.\n\\end{equation*}\n\nWhen $P=\\emptyset$, this specializes to $T(G^1\\amalg G^2)=\\alpha_{k_1+k_2}r$\nand $T(G^1)T(G^2)=\\alpha_{k_1}\\alpha_{k_2}r$.\n\n\\item $T$ is multiplicative with respect to $\\amalg$, that is,\nif $G^1$, $G^2$ and $G^1\\amalg G^2$ are all in $\\mathcal{G}$, then\n$T(G^1\\amalg G^2)=T(G^1)T(G^2)$, if and only if whenever\n$Q_i$, $Q_j$ and $Q_i\\amalg Q_j$ are all $P$-quotients in\n$\\mathcal{G}$, then $T(Q_i)T(Q_j)=T(Q_i\\amalg Q_j)$.\n\nWhen $P=\\emptyset$, this specializes to $T$ is multiplicative\nwith respect to $\\amalg$ if and only if\n$\\alpha_{k_1}\\alpha_{k_2}$ $=$ $\\alpha_{k_1+k_2}$\nwhenever $\\mathcal{G}_{k_1}$, $\\mathcal{G}_{k_2}$\nand $\\mathcal{G}_{k_1+k_2}$ are all non-empty.\n\\end{enumerate}\n\\end{prop}\n\n\\begin{proof}\nThe first two can be proved as in \\cite{Ellis-Monaghan-Traldi}, or \nby analyzing Tutte computation trees\n\nThe last two follow from Proposition \\ref{SumProp}.\n\\end{proof}\n\n\\cite{Ellis-Monaghan-Traldi} also gave analogous results for\none-point union, which can be generalized in the same way.\n\n\\subsection{A Natural ZBR Theorem for Labelled Ported Graphs}\n\n\nSo, to generalize the ZBR theorem to graphs with port edges in \na way that the edge deletion and contraction\noperations remain compatible with both the\ngraphic matroid (or oriented matroid) structure and \nvertex structure, we have to add a hypothesis.  To do that\nand get the exact generalization \nof Corollary 3.4, the generalized Zaslavsky–Bollob\\'{a}s–Riordan theorem for \ngraphs in \\cite{Ellis-Monaghan-Traldi}\nwe require that the function\nvalues $T(G_1)=T(G_2)$ whenever graphs $G_1$ and $G_2$ are \nare path-connected and have the same matroids (or oriented matroids).\n\n\nThe separator-strong reductions applied to a graph\nclearly preserve the vertex set $V$ and the partition of $V$\ninduced by path-connectedness.  The graphic 2-edge-connectivity\nstructure is of course identical to the matroid connectivity structure.\nIt is therefore natural, and motivated by Diao and \nHetyei's applications to virtual knots \\cite{RelTuttePoly}, to define\na separator-strong Tutte function of graphs as follows:\n\n\\begin{definition}\nTwo graphs $G_1$, $G_2$ with the same vertex set $V$ and edge set $S$\nhave the same connectivity structure if and\nonly if they have the same graphic matroids (or oriented matroids) on\n$S$ and the same partition of $V$ induced by path-connectedness.\n\nA separator-strong Tutte function $T$ of graphs is a function from a $P$-family\nof graphs to ring $R$ which satisfies \\eqref{TA}, \\eqref{TSSM} applied to\ntheir graphic matroids and for which $T(G_1)=T(G_2)$ if $G_1$ and $G_2$ have\nthe same connectivity structure.\n\\end{definition}\n\n\nLet us say two $P$-quotients $Q_i$ and $Q_j$ are equivalent if they\nhave the same matroid (or oriented matroid) and have the same connectivity\nstructure.\n\n\\begin{lem}\n$F$ is a Tutte function on a $P$-family of graphs if and only if\n$F$ satisfies \n\\eqref{TA} and  \\eqref{TSSM}, and $F(Q_i)=F(Q_j)$ for all pairs \nof equivalent \n$P$-quotients $Q_i$ and $Q_j$.\n\\end{lem}\n\n\n\n\n---------------------------------------------------\n\n\nThe following easy observations\nformalize how Tutte computation trees for $N$ and $N'$\nhave the same structure when $M(N)=M(N')$ and how \nthe Tutte polynomials are related.\n\n\\begin{lem}\nIf $M(N)=M(N')$ and\n$\\sum_{i\\in Z} I(N/B_i|P) r_i$ is the value from\nTutte computation tree $\\mathcal{T}$\nfor $N$, then $\\mathcal{T}$ can be relabelled\nto construct a Tutte computation tree for $N'$\nthat yields the value\n$\\sum_{i\\in Z} I(N'/B_i|P) r_i$\nwith the same index set $Z$ and $r_i\\in R$ for $i\\in Z$.\n\\end{lem}\n\n\\begin{prop}\nIf $T$ is a separator-strong Tutte function on $\\mathcal{N}$\nand \n$T(N)=\\sum_{i\\in Z} I(N/B_i|P) r_i$ \nis the Tutte polynomial expression from some computation tree,\nthen\n$T(N')=\\sum_{i\\in Z} I(N'/B_i|P) r_i$\nwith the same index set $Z$ and $r_i\\in R$ for $i\\in Z$.\n\\end{prop}\n\n", "meta": {"hexsha": "5676580a3341034e8c4e1f42e0be711bd6b01df8", "size": 118974, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ParamTutte/ParamTutte.tex", "max_stars_repo_name": "chaikens/MathOfElec", "max_stars_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ParamTutte/ParamTutte.tex", "max_issues_repo_name": "chaikens/MathOfElec", "max_issues_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ParamTutte/ParamTutte.tex", "max_forks_repo_name": "chaikens/MathOfElec", "max_forks_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0866583541, "max_line_length": 90, "alphanum_fraction": 0.7331349707, "num_tokens": 37612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.4427899516536866}}
{"text": "\\section{Tricks in Neural Network}\r\n\\label{sec:Solution}\r\nTraining neural network to achieve a decent performance in ordinary method\r\nis challenging. In recent years, a growing number of ultra deep neural \r\nnetworks, like VGG-16 with 16 layers and over 100 million parameters, \r\ncan be easily trained. The huge leap attributes to the diligent theorists\r\nwho devised various sophisticated tricks boosting the training efficiency\r\nand addressing some of the problems mentioned in \\autoref{sec:Problem}. \r\n\r\n\\subsection{A Good Initialization is All You Need \\protect\\footnote{The \r\ntitle of this section is quoted from Mishkin et al. \\parencite{mishkin2015all} whose\r\ntitle had a profound influence on our study of the neural network.}}\r\n\r\nFrom the experience in \\autoref{sssec:Saddle}, a initialization with common \r\nGaussian distribution appears to an obstacle to convergence. Romero et al.\r\n\\parencite{romero2014fitnets} states that for deep neural net with too many \r\nlayers and especially those with uniform normalization, it is hard to train \r\nusing BP. Thus, we hereby conclude a number of effective initialization methods.\r\n\r\n\\subsubsection{Xavier Initialization}\r\nIn \\parencite{glorot2010understanding}, Glorot et al. proposed a adoption of standard\r\nGaussian initialization which was called \"Xavier\" initialization by Jia et al.\r\n\\parencite{jia2014caffe}. Xavier initialization aims to improve the performance of \r\nneural network using sigmoid activation and log-likelihood loss function:\r\n\\begin{equation}\r\n    \\label{equ:Xavier}\r\n    \\begin{split}\r\n        E(W^{[l]}) & = 0, \\\\\r\n        Var(W^{[l]}) & = \\frac{2}{n^{[l-1]} - n^{[l]}}\r\n    \\end{split}\r\n\\end{equation}\r\n\r\n\\begin{prf}\r\n    For a activation function $ g $ with $ f'(0) = 1 $, like sigmoid $ \\sigma(z) $,\r\n    if we use the notation in \\autoref{equ:FP} and \\autoref{equ:BP}:\r\n    \\begin{align*}\r\n        Z^{[l]} & = W^{[l]}A^{[l-1]} + b^{[l]} \\\\\r\n        dZ^{[l]} & = (W^{[l]T}dZ^{[l+1]})*g^{[l]'}(Z^{[l]}) \\\\\r\n        dW^{[l]} & = dZ^{[l]}A^{[l-1]T}\r\n    \\end{align*} \r\n    We assume that the weights are independent and the distribution of \r\n    input $ X $ are the same. Then $ g^{[l]'}(Z_k^{l}) \\approx 1 $, Using the \r\n    chain rule we have:\r\n    \\begin{align}\r\n        Var(A^{[l]}) & = Var(X)\\prod\\limits_{l'=0}^{l-1}n^{[l'-1]}Var(W^{[l']}) \\\\\r\n        Var(dZ^{[l]}) & = Var(dZ^{[L]})\\prod\\limits_{l'=L}^{l}n^{[l']}Var(W^{[l']})\r\n    \\end{align}\r\n    To keep information flowing in FP and BP, we would like to have:\r\n    \\begin{align}\r\n        & \\forall(l,\\ l'),\\ Var(A^{[l]}) = Var(A^{[l']}) \\\\\r\n        & \\forall(l,\\ l'),\\ Var(dZ^{[l]}) = Var(dZ^{[l']})\r\n    \\end{align}\r\n    So:\r\n    \\begin{align}\r\n        & \\forall l,\\ n^{[l'-1]}Var(W^{[l']}) = 1 \\\\\r\n        & \\forall l,\\ n^{[l']}Var(W^{[l']}) = 1\r\n    \\end{align}\r\n    To combine the two equations above, we may have:\r\n    \\begin{eqnarray}\r\n        Var(W^{[l']}) = \\frac{2}{n^{[l-1]} - n^{[l]}}\r\n    \\end{eqnarray}\r\n    \\textbf{Q.E.D.}\r\n\\end{prf}\r\n\\par For Gaussian initialization, Xavier suggest to have:\r\n\\begin{equation}\r\n    W \\sim N(0,\\ \\frac{2}{n^{[l-1]} - n^{[l]}})\r\n\\end{equation}\r\nThough rarely in use, a normalized version of Xavier initialization is \r\nprovided in \\parencite{glorot2010understanding}:\r\n\\begin{equation}\r\n    W \\sim U(-\\frac{\\sqrt{6}}{\\sqrt{n^{[l-1]} + n^{[l]}}},\\ \\frac{\\sqrt{6}}{\\sqrt{n^{[l-1]} + n^{[l]}}})\r\n\\end{equation}\r\n\r\n\\subsubsection{Kaiming Initialization}\r\n\\label{sssec:Kaiming}\r\nHe et al. \\parencite{he2015delving} extended the \\autoref{equ:Xavier} to ReLU\r\nactivation and achieved a better performance. In this article, a modification\r\nof ReLU, the Parametric Rectified Linear Unit (PReLU)\\footnote{The detail of \r\nPReLU will be discuss in Appendix 2 } was proposed as well. \r\nDue to the lack of $ g'(0) = 1 $ in ReLU, \"Xavier\" failed to pursue a convergence\r\nin deep neural networks. Kaiming initialization is set as follow:\r\n\\begin{equation}\r\n    \\label{equ:Kaiming}\r\n    \\begin{split}\r\n        E(W^{[l]}) & = 0, \\\\\r\n        Var(W^{[l]}) & = \\frac{2}{n^{[l]}}\r\n    \\end{split}\r\n\\end{equation}\r\n\r\n\\begin{prf}\r\n    We use the notation in \\autoref{equ:FP} and \\autoref{equ:BP}:\r\n    \\begin{align*}\r\n        Z^{[l]} & = W^{[l]}A^{[l-1]} + b^{[l]} \\\\\r\n        dA^{[l]} & = W^{[l]T}dZ^{[l+1]}\r\n    \\end{align*} \r\n    And we review the ReLU: $ g(z) = max(0,\\ z) $.\r\n    Let the initialization in parameters and input are mutually independent \r\n    and share the same distribution. Then we have:\r\n    \\begin{equation}\r\n        \\label{equ:Var}\r\n        \\begin{split}\r\n            Var(Z^{[l]}) & = n^{[l]}Var(W^{[l]}A^{[l-1]}) \\\\\r\n            & = n^{[l]}(Var(W^{[l]})Var(A^{[l-1]}) + Var(W^{[l]})E(A^{[l-1]}))\r\n        \\end{split}\r\n    \\end{equation}\r\n    Note that $ g(z) = max(0,\\ z) $, this leads to $ E(g(z)) = \\frac{1}{2}E(z),\\ \r\n    Var(g(z)) = \\frac{1}{4}Var(z) $. Therefore, \\autoref{equ:Var} can be converted\r\n    to:\r\n    \\begin{equation}\r\n        Var(Z^{[l]}) = \\frac{1}{2}n^{[l]}Var(W^{[l]})Var(Z^{[l-1]})\r\n    \\end{equation}\r\n    Putting all layers together, we have:\r\n    \\begin{equation}\r\n        Var(Z^{[L]}) = Var(Z^{1})\\prod\\limits_{l=2}^L\\frac{1}{2}n^{[l]}Var(W^{[l]})\r\n    \\end{equation}\r\n    Similar to the proof in Xavier initialization, we hope the maintain the \r\n    variance in the FP to avoid the possible explosion or vanishing.\r\n    So, \r\n    \\begin{equation}\r\n        \\label{equ:Kaiming_1}\r\n        \\forall l,\\ \\frac{1}{2}n^{[l]}Var(W^{[l]}) = 1\r\n    \\end{equation}\r\n    Likewise in the process of BP, due to the property of ReLU function, \r\n    \\begin{equation}\r\n        Var(dA^{[1]}) = Var(dA^{L})\\prod\\limits_{l=1}^L\\frac{1}{2}n^{[l]}Var(W^{[l]})\r\n    \\end{equation}\r\n    and the corresponding condition is the same as \\autoref{equ:Kaiming_1}.\r\n    \\textbf{Q.E.D.}\r\n\\end{prf}\r\n\r\n\\subsubsection{Orthogonal Initialization}\r\nBased on deep linear neural networks, Saxe et al. \\parencite{saxe2013exact} \r\nexhibits a class of random orthogonal initialization which enjoys depth \r\nindependent learning time in linear networks. Orthogonal initialization is \r\nimplemented by choosing all weights to be orthogonal matrix:\r\n\\begin{equation}\r\n    (W^{[l]})^TW^{[l]} = I\r\n\\end{equation}\r\nThe implementation can be divided into two steps:\r\n\\begin{enumerate}\r\n    \\item[1.] Fill the weights with standard Gaussian distribution.\r\n    \\item[2.] Decompose the weights matrix using singular value decomposition \r\n    (SVD) and replace weights with one of the components. \r\n\\end{enumerate}\r\nSaxe et al. suggest that an approriate condition on weights for generating fast\r\nlearning speed would be dynamical isometry\\footnote{Dynamical isometry means \r\nthat the input-output Jacobian $ J = \\frac{\\nabla A^{[L]}}{\\nabla A^{[0]}} $ \r\nhas all singular values close to 1.}. Saxe et al. \\parencite{saxe2013exact} \r\nillustrate the answer for depth independence by visualize the eigenvalue \r\nspectrum of a random orthogonal matrix in \\autoref{fig:orthogonal}, which is \r\nexactly a unit circle. Moreover, its singular values are all exactly 1.\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=10cm]{orthogonal}\r\n    \\caption{\\label{fig:orthogonal}The eigenvalue spectrum of a \r\n    random orthogonal matrix $ W \\in \\mathbb{R}^{100\\times 100} $}\r\n\\end{figure}\r\nThen in the linear neural networks, the input-output Jacobian is:\r\n\\begin{equation}\r\n    J = \\prod\\limits_{l=1}^LW^{[l]}\r\n\\end{equation}\r\nUnder orthogonal initialization in each layer, $ J $ is a orthogonal matrix and\r\nthus the initialization achieve dynamical isometry. Still the reason for dynamical\r\nisometry explaining the depth independence will be studied in the future work.\r\n\r\n\\subsubsection{Layer-Sequential Unit-Variance Initialization (LSUV)}\r\nAs far as we aware, part from the Kaiming initialization, mentioned in \r\n\\autoref{sssec:Kaiming}, there is no extension of Xavier initialization to \r\nother nonlinear function other than ReLU. Mishkin et al. \\parencite{mishkin2015all}\r\nprovide a general and simple initialization method that works well with different \r\nactivation functions:\r\n\\begin{enumerate}\r\n    \\item[1.] Initialize the weights using orthogonal initialization.\r\n    \\item[2.] Scale the variance of output of each layer for each mini-batch \r\n    \\footnote{Mini-batch means a small proportion of the data set used in one \r\n    iteration, which will be introduced in \\autoref{sssec:MiniBatch}.} to  \r\n    be 1.\r\n\\end{enumerate}\r\nThough the explanation of why LSUV outperform other initialization methods is\r\nnot given in the article, a series of comparison empirically show its advantage\r\nin neural networks initialization problem.\r\n\r\n\\subsubsection{Comparison between initialization}\r\nWe implemented a simple CNN model based on keras to examine\r\nthe performance of random, xavier and he initialization. \r\nThe model trained the MNIST data set \\parencite{mnist} to \r\nclassify the handwriting of Arabic numbers. The CNN model \r\nis constructed with two convolution layers, two max pooling\r\nlayers and two fully connected layers. Activations use ReLU\r\nand the output layer uses Softmax. Due to the limitation of \r\nthe version of keras and time limit, LSUV is not implemented.\r\nThe code is attached in the \"/code/initialize.py\". The size \r\nof data set is $ M = 60000 $, we set $ m = 64 $. The results\r\nare demonstrated in \\autoref{fig:init_cost} and \\autoref{fig:init_acc}.\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=10cm]{init_cost}\r\n    \\caption{\\label{fig:init_cost}The loss in training of different initialization\r\n    methods, only random initialization corresponds to the right y axis}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=8cm]{init_acc}\r\n    \\caption{\\label{fig:init_acc}The loss and accuracy on test set \r\n    of different initialization methods}\r\n\\end{figure}\r\n\r\n\\par Surprisingly, CNN using random initialization did not \r\nconverge and did not learn after the second epoch. Others have\r\na great convergence, he initialization is a bit faster than the \r\nrests since it is tailored for ReLU.  \r\n\r\n\\subsection{Gradient Descend Variants}\r\nThere are two variants of GD improving the training efficiency. In brevity,\r\nbatch describes the data set used in an iteration\\footnote{In an iteration, \r\nall parameters are updated.}, epoch describes a traversal through the whole \r\ndata set. GD introduced in \\autoref{ssec:GD} is the basic form of GD. If \r\nwe unroll the vectorization in \\autoref{equ:GD}, we can have:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        dW^{[l]} & = \\frac{1}{m}\\sum\\limits_{i=1}^mdZ_{\\bullet,\\ i}^{[l]}A_{\\bullet,\\ i}^{[l-1]T} \\\\\r\n        db^{[l]} & = \\frac{1}{m}\\sum\\limits_{i=1}^mdZ_{\\bullet,\\ i}^{[l]}\r\n    \\end{split}\r\n\\end{equation}  \r\nThe variants take on different convergence speed and accuracy by choosing \r\ndifferent $ m $.\r\n\r\n\\subsubsection{Batch Gradient Descent (BGD)}\r\nBatch gradient descent, computes the gradient for the whole data set, i.e. \r\n$ m $ is the size of the data set $ M $. Despite the high accuracy resulted \r\nfrom taking full advantage of data set, BGD failed to \r\nmanage the online algorithms due to the considerable training time.\r\n\r\n\\subsubsection{Stochastic Gradient Descent (SGD)}\r\nIn comparison to BGD, SGD is competent for computation\r\nnew data on the fly. In each iteration, SGD updates the parameters using\r\nonly one piece of data $ (x^{(i)},\\ y^{(i)}) $, i.e. $ m = 1 $:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        dW^{[l]} & = \\sum\\limits_{i=1}^mdZ^{[l]}A^{[l-1]T} \\\\\r\n        db^{[l]} & = \\sum\\limits_{i=1}^mdZ^{[l]} \\\\\r\n        dZ^{[l]},&\\ A^{[l]} \\in \\mathbb{R}^{n^{[l]}\\times 1}\r\n    \\end{split}\r\n\\end{equation} \r\nSince only one sample is applied to the computation of gradient, the speed\r\nof SGD is fast enough for daily application. On the other hand, optimizing\r\nfor one sample does not guarantee the convergence to a minimum and a descent\r\nof cost in each iteration. It is therefore SGD suffers a severe fluctuation\r\nand may wander around the minimum.\r\n\r\n\\subsubsection{Mini-batch Gradient Descent (MGD)}\r\n\\label{sssec:MiniBatch}\r\nTo balance the merit of both BGD and SGD, mini-batch gradient descent\r\nchoose an appropriate $ m = 2^k,\\ k\\in R^+ $. Usually, $ m $ will be chosen\r\nas 64, 128 and 256. Taking the best of both worlds, MGD\r\ndescent has a fast and stable convergence.\r\n\r\n\r\n\\subsubsection{Comparison Between Variants}\r\nTo illustrate the different between batch BGD, SGD and MGD, we \r\nimplement a multi-classification neural network based on the tensorflow \r\nframework. The architecture \r\nof deep neural network with two hidden layers using ReLU and the output \r\nlayer using Softmax, Adam optimization mentioned in \\autoref{sssec:Adam} \r\nis applied to pursue better convergence. Due to the limitation of the \r\nold version of tensorflow, only Xavier initialization is available.\r\nThe code attached in the \" /code/test.py \".\r\nThe size of data set is $ M = 1080 $, we set $ m = 1080,\\ 1,\\ \r\n64 $ respectively for three variants. The results are shown in the following\r\n, see \\autoref{fig:BGD_cost},\\autoref{fig:BGD},\\autoref{fig:SGD_cost},\\autoref{fig:SGD},\\autoref{fig:MGD_cost},\\autoref{fig:MGD}.\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=8cm]{BGD_cost}\r\n    \\caption{\\label{fig:BGD_cost}The loss of BGD during training}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=5cm]{BGD}\r\n    \\caption{\\label{fig:BGD}The result of training}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=8cm]{SGD_cost}\r\n    \\caption{\\label{fig:SGD_cost}The loss of SGD during training}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=5cm]{SGD}\r\n    \\caption{\\label{fig:SGD}The result of training}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=8cm]{MGD_cost}\r\n    \\caption{\\label{fig:MGD_cost}The loss of MGD during training}\r\n\\end{figure}\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=5cm]{MGD}\r\n    \\caption{\\label{fig:MGD}The result of training}\r\n\\end{figure}\r\n\r\n\\par Unfortunately, under the testing condition, SGD did not converge but stuck\r\nin some kind of local minimum or saddle point. Comparing MGD and BGD, to \r\nachieve the same accuracy of 99\\%, MGD is much more faster but some glitches \r\ncan be observed in the cost, which means MGD dose not guarantee descent in each\r\niteration like SGD. In all, the simple comparison roughly demonstrate the advantage \r\nof MGD in the optimization process.\r\n\r\n\r\n\\subsection{Optimization Algorithms}\r\nMini-batch GD does improve the convergence speed in deep neural\r\nnetworks, but the aforementioned challenges like saddle points,\r\nlearning rate selection are still need to be addressed. We \r\nsummarize some prevailing optimization algorithms as follow.\r\n\r\n\\subsubsection{Momentum}\r\nMomentum method is one of the earliest simple and robust modification to\r\npursue faster learning by Qian et al. \\parencite{qian1999momentum}. \r\nWhen the cost function is similar to a long and \r\nnarrow valley like \\autoref{fig:valley}, most gradient is perpendicular\r\nto the long axis, the the back and forth track would drastically slows \r\ndown the learning speed. \r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\subfigure[Without momentum]{\r\n        \\begin{minipage}[t]{0.5\\linewidth}\r\n        \\centering\r\n        \\includegraphics[width=6cm]{Momentum1}\r\n        \\end{minipage}%\r\n    }%\r\n    \\subfigure[With momentum]{\r\n        \\begin{minipage}[t]{0.5\\linewidth}\r\n        \\centering\r\n        \\includegraphics[width=6cm]{Momentum2}\r\n        \\end{minipage}%\r\n    }%\r\n    \\centering\r\n    \\caption{\\label{fig:valley}A long and narrow valley \r\n    situation. From \\parencite{momentum}}\r\n\\end{figure}\r\n\r\nIn this situation, we are eager to keep the track\r\nparallel to the long axis by some kind of force. In physics, it is called\r\nthe momentum, and thus the terminology comes into being. Momentum updates\r\nthe parameters in the following way:\r\n\\begin{equation}\r\n    \\label{equ:Momentum}\r\n    \\begin{split}\r\n        v_{t} & = \\beta v_{t-1} - \\alpha dW_t^{[l]},\\ v_0 = 0 \\\\\r\n        W_t^{[l]} & = W_{t-1}^{[l]} + v_{t}\r\n    \\end{split}\r\n\\end{equation}\r\nThe recursive definition of $ v_t $ is called the exponentially decaying average.\r\n\\par The relation between momentum method and its physics background is readily\r\ncomprehensible. When a ball moving in a field with\r\na fraction w.r.t. the speed, then the Newtonian equation is:\r\n\\begin{equation}\r\n    \\label{equ:Newton}\r\n    m\\frac{d^2x}{dt^2} + \\mu\\frac{dx}{dt} = -\\nabla E(x)\r\n\\end{equation}\r\nwhere $ m $ is the mass, $ \\mu $ is the fraction coefficient and $ E(x) $\r\nis the potential energy. Since \r\n$ \\frac{dx}{dt} = \\frac{x_{t+1} - x_{t}}{\\Delta t} $, \\autoref{equ:Newton}\r\ncan be rewritten as:\r\n\\begin{equation}\r\n    \\label{equ:physics}\r\n    \\begin{split}\r\n        m\\frac{(x_{t+1} - x_{t}) - (x_{t} - x_{t-1})}{(\\Delta t)^2} + \\mu\\frac{x_{t+1} - x_{t}}{\\Delta t} = -\\nabla E(x) \\\\\r\n        x_{t+1} - x_{t} = -\\frac{(\\Delta t)^2}{m+\\mu\\Delta t}\\nabla E(x) + \\frac{m}{m+\\mu\\Delta t}(x_{t} - x_{t-1})\r\n    \\end{split}\r\n\\end{equation}\r\nIf we set $ \\frac{(\\Delta t)^2}{m+\\mu\\Delta t} = \\alpha,\\ \r\n\\frac{m}{m+\\mu\\Delta t} = \\beta $, then we obtain the \\autoref{equ:Momentum}.\r\n\r\nHere, we briefly demonstrate the convergence analysis of momentum method.\r\nUsing the Hessian $ \\nabla E(x_t) = Hx_t $ and similarity transformation \r\n$ H = Q^TDQ,\\ Q^TQ = I $, we can convert \\autoref{equ:physics} into: \r\n\\begin{equation}\r\n    \\begin{split}\r\n        x_{t+1} & = ((1 + \\beta)I -\\alpha Q^TDQ)x_t - \\beta x_{t-1} \\\\\r\n        Q^Tx_{t+1} & = (1 + \\beta)IQ^Tx_t -\\alpha Q^TQ^TDQx_t - \\beta Q^Tx_{t-1}\r\n    \\end{split}\r\n\\end{equation}\r\nWe denote $ x_t = x_t' $, then the element-wise equation is:\r\n\\begin{equation}\r\n    x_{i,\\ t+1}' = ((1+\\beta)-\\alpha d_i)x_{i,\\ t}' - \\beta x_{i,\\ t-1}'\r\n\\end{equation}\r\nThen a matrix representation of this equation is:\r\n\\begin{equation}\r\n    \\label{equ:linear}\r\n    \\begin{split}\r\n        \\begin{pmatrix}\r\n            x_{i,\\ t}' \\\\\r\n            x_{i,\\ t+1}'\r\n        \\end{pmatrix}\r\n        = A_i\r\n        \\begin{pmatrix}\r\n            x_{i,\\ t-1}'   \\\\\r\n            x_{i,\\ t}'\r\n        \\end{pmatrix} \\\\\r\n        A_i = \r\n        \\begin{pmatrix}\r\n            0 & 1   \\\\\r\n            -\\beta & 1 + \\beta - \\alpha d_i\r\n        \\end{pmatrix}\r\n    \\end{split}\r\n\\end{equation}\r\nThe convergence of momentum is determined by the linear system\r\nin \\autoref{equ:linear}. Recall the knowledge in numerical\r\nanalysis, a theorem w.r.t. the convergent matrix is stated \r\nin Theorem 7.17 in Burden et al. \\parencite{burden2010numerical}:\r\n\\begin{thm}\r\n    $ A $ is a convergent matrix\\footnote{We call a matrix A convergent if\r\n    \\begin{align}\r\n        \\lim _{k \\rightarrow \\infty}\\left(A^{k}\\right)_{i j}=0, \\quad \\text{for each } i=1,2, \\ldots, n \\text{and } j=1,2, \\ldots, n\r\n    \\end{align}.}\r\n    $\\iff$ the spectrum radius $ \\rho(A) $\\footnote{Spectrum radius is \r\n    defined as $ \\rho(A) $ = max($|\\lambda|$)} \r\n    satisfies\r\n    \\begin{equation}\r\n        \\rho(A) < 1\r\n    \\end{equation}.\r\n\\end{thm}\r\nA proposition given in Appendix B in Qian et al. \r\n\\parencite{qian1999momentum} provide the theoretical\r\nfoundation of the convergence.\r\n\\begin{pro}\r\n    Let $ \\lambda_{i,\\ 1},\\ \\lambda_{i,\\ 2} $ are the \r\n    eigenvalues of $ A_i $. The system in \\autoref{equ:linear}\r\n    converges if and only if \r\n    \\begin{equation}\r\n        -1 < \\beta < 1,\\ 0 < \\alpha d_i < 2+2\\beta \r\n    \\end{equation}\r\n\\end{pro}\r\n\r\n\\subsubsection{Nesterov Accelerated Gradient (NAG)}\r\n\\label{sssec:NAG}\r\nNAG in Nesterov \\parencite{nesterov1983method}\r\nis a optimization method solving convex problems with \r\nconvergence rate $ O(1/K^2) $, where $ K $ is the number of iterations.\r\nNAG is virtually similar to momentum method in spite of two differences.\r\nFirst, learning rate is derived from the Armijo rule with $ \\beta = 2,\\ \r\n\\sigma = 0.5 $ in \\autoref{sssec:Armijo}. The momentum constant $ \\beta $\r\nis formulated in a recursive way that $ \\beta_t \\sim \\frac{t+4}{2} $, where \r\n$ t $ is the index of iteration. Second, a subtle update rule is applied \r\nin NAG. Considering the fact that the former difference just an additional\r\ncondition to guarantee the convexity, such formulation seems trivial in \r\nthe common non-convex optimization. Instead, we manually choose the parameters\r\n$ \\beta $ and $ \\alpha $ in advanced and focus more on the later aspect:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        v_t & = \\beta v_{t-1} - \\alpha\\nabla J(W_{t-1} + \\beta W_{t-1}),\\ v_0 = 0 \\\\\r\n        W_t & = W_{t-1} +  v_t\r\n    \\end{split}\r\n\\end{equation}\r\n\\par To the best of our knowledge, there have been no attempts to generalize the \r\nconvergence analysis of NAG to non-convex problem. But a empirical experiment\r\nin Sutskever's PhD thesis \\parencite{sutskever2013training}. \r\n\\par Intuitively, to comprehend the improvement of NAG, imagine SGD as a ball\r\nrolling downhill (like in the physics background of momentum). In a rough terrain,\r\nblindly rolling with gradient seems to be silly, because there is no forecast \r\nwhen the ball suddenly face a upward slope. As shown in \\autoref{fig:Nesterov}, \r\nNAG is more stable than momentum due to the backward correction.\r\n\r\n\\begin{figure}[H]\r\n    \\centering\r\n    \\includegraphics[width=8cm]{Nesterov}\r\n    \\caption{\\label{fig:Nesterov}NAG illustration: blue vector represents the \r\n    momentum method, green vector represents the NAG with the brown component \r\n    is the gradient and the red component is the correction.}\r\n\\end{figure}\r\n\r\n\\subsubsection{RMSprop}\r\n\\label{sssec:RMSprop}\r\nIt is interesting that RMSprop is not published in paper but propose in a \r\nCoursera course by Hinton et al. \\parencite{rmsprop}. RMSprop adopts the idea\r\nof only using the sign of the gradient by dividing the gradient with the size \r\nof it:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        u_t & = \\gamma u_{t-1} + (1-\\gamma)(dW_t^{[l]})^2,\\ u_0 = 0 \\\\\r\n        W_{t+1}^{[l]} & = W_{t}^{[l]} - \\frac{\\eta}{\\sqrt{u_t+\\epsilon}}dW_t^{[l]}\r\n    \\end{split}\r\n\\end{equation}\r\nExponentially decaying average $ u_t $ is applied to the second moment of gradient.\r\nIn brevity, we denote such average as $ RMS(dW_t^{[l]}) $.\r\n$ \\epsilon $ is a smoothing term that prevents division by zero and usually \r\nset to $ 10^{-8} $. In the lecture, Hinton suggests $ \\gamma = 0.9 $.\r\n\r\n\\subsubsection{Adagrad}\r\nDuchi et al. \\parencite{duchi2011adaptive} make a vivid metaphor that some \r\ninfrequent but predictive features are needles in haystacks. Adagrad is a \r\nsubgradient method that crafts domain-specific weightings by performing large\r\nupdates for infrequent features and small updates for frequent ones.\r\n\\begin{equation}\r\n    W_{t}^{[l]} = W_{t-1}^{[l]} - \\frac{\\eta}{\\sqrt{\\sum _{t'=1}^t(dW_{t'}^{[l]})^2} + \r\n        \\epsilon}dW_{t}^{[l]}\r\n\\end{equation}\r\n\\par Note that the update is divided by the sum of the squared gradients, the \r\nlearning rate will shrink to vanishing with the iteration. To address this flaw,\r\nan adaption called Adadelta is illustrated in the following.\r\n\r\n\\subsubsection{Adadelta}\r\nAdadelta presented in Zeiler et al. \\parencite{zeiler2012adadelta} aims to improve\r\nAdagrad in two aspect: the diminishing learning rate and the manual tunning \r\nlearning rate.\r\n\\par First, instead of simply summing up the squared gradients, a accumulation\r\nover window method is introduced, which turns out to be exactly the RMSprop\r\nin \\autoref{sssec:RMSprop}. Second, the article suggests that as a \r\nupdate of $ W $, $ \\Delta W $ should have the same unit as $ W $. However, in usual\r\noptimization method, this is not the case:\r\n\\begin{equation}\r\n    \\text{units of}\\Delta W \\propto \\text{units of} dW \\propto \\frac{\\partial J}{\\partial W} \\propto \\frac{1}{\\text{units of}W}\r\n\\end{equation}  \r\nComparing with the Newton's method in Chapter 10.2 in Burden et al. \r\n\\parencite{burden2010numerical}, the Hessian is used to maintain the same unit:\r\n\\begin{equation}\r\n    \\Delta W \\propto H^{-1} dW \\propto \\frac{\\frac{\\partial J}{\\partial W}}{\\frac{\\partial^{2} J}{\\partial W^{2}}} \\propto \\text { units of } W\r\n\\end{equation}\r\nThe term $ \\frac{1}{\\frac{\\partial^{2} J}{\\partial W^{2}}} = \\frac{\\Delta W}{\\frac{\\nabla J}{\\nabla W}} $\r\ncan be added to obtain the match of unit. The unknown $ \\Delta W $ in the current iteration\r\nwill be substituted by the previous one. Since the denominator use the RMSprop,\r\nthe numerator should take the identical form:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        v_t & = -\\frac{RMS(v_{t-1})}{RMS(dW_t^{[l]})} \\\\\r\n        W_{t+1}^{[l]} & = W_{t}^{[l]} + v_t \r\n    \\end{split}\r\n\\end{equation}\r\n\r\n\\subsubsection{Adam}\r\n\\label{sssec:Adam}\r\nThe name of Adam comes from adaptive moment estimation in Kingma et al. \\parencite{kingma2014adam}\r\nIt is a memory saving and easy to compute optimization method combining \r\nboth the advantages of RMSprop and momentum. The pseudo code of Adam is \r\nshown in \\autoref{alg:Adam}.\r\n\r\n\\begin{algorithm}\r\n    \\caption{Adam. Note that all operators are element-wise. The recommended\r\n    hyperparameters are learning rate $ \\alpha = 0.001 $, momentum \r\n    constant $ \\beta = 0.9 $, RMSprop constant $ \\gamma = 0.999 $, \r\n    smoothing term $ \\epsilon = 10^{-8} $.}\r\n    \\label{alg:Adam}\r\n    \\begin{algorithmic}\r\n    \\REQUIRE $\\alpha$: Stepsize\r\n    \\REQUIRE $\\beta,\\ \\gamma \\in [0,\\ 1)]$: Exponential decay rates \r\n                for moment estimation\r\n    \\REQUIRE $J(W)$: Cost function with parameters $ W $\r\n    \\REQUIRE $W_0$: Initial parameter\r\n    \\STATE $m_0 \\gets 0$ (Initialize \\engordnumber{1} moment vector)\r\n    \\STATE $v_0 \\gets 0$ (Initialize \\engordnumber{2} moment vector)\r\n    \\STATE $t \\gets 0$ (Initialize time step)\r\n    \\WHILE{$ W_t $ not converged}\r\n    \\STATE $ t \\gets t + 1 $ \r\n    \\STATE $ g_t \\gets \\nabla J(W_{t-1}) $(Get gradients w.r.t. cost function)\r\n    \\STATE $ m_t \\gets \\beta m_{t-1} + (1-\\beta)g_t $ (Update biased first moment estimate)\r\n    \\STATE $ v_t \\gets \\gamma v_{t-1} + (1-\\gamma)g_t^2 $ (Update biased second moment estimate)\r\n    \\STATE $ \\hat{m_t} \\gets \\frac{m_{t-1}}{1-\\beta^t}$ (Compute bias-corrected first moment estimate)\r\n    \\STATE $ \\hat{v_t} \\gets \\frac{v_{t-1}}{1-\\gamma^t} $ (Compute bias-corrected second raw moment estimate)\r\n    \\STATE $ W_t \\gets W_{t-1} - \\alpha \\frac{\\hat{m_t}}{\\sqrt{\\hat{v_t}}+\\epsilon} $ (Update parameters)\r\n    \\ENDWHILE\r\n    \\RETURN $ W_t $ (Resulting parameters)\r\n    \\end{algorithmic}\r\n\\end{algorithm}\r\n\r\nUsing the definition in mathematical statistic, the Exponential decaying average\r\ncalculates the mean and uncentered variance of gradients, i.e. the \\engordnumber{1}\r\nmoment and the \\engordnumber{2} raw moment. Due to the initialization of zero which\r\nis not there actual value, the initialization bias correction. Calculate the\r\nrecursive definition of $ m_t $, we can obtain:\r\n\\begin{align}\r\n    m_t = \\beta^tm_0 + (1-\\beta)\\sum _{i=1}^t\\beta^{t-i}g_i\r\n\\end{align}\r\nInitialize $ m_0 = 0 $, and we have:\r\n\\begin{equation}\r\n    m_t = (1-\\beta)\\sum _{i=1}^t\\beta^{t-i}g_i\r\n\\end{equation}\r\nWe want the expectation of $ m_t $ and $ g_t $ is equivalent.\r\n\\begin{align}\r\n    E(m_t) & = (1-\\beta)\\sum _{i=1}^t\\beta^{t-i}E(g_t) + \\zeta \\\\\r\n    & = (1-\\beta^t)E(g_t) + \\zeta\r\n\\end{align}\r\nIf $ E(g_i) $ does not change with time, then $ \\zeta=0 $. Even if $ E(g_i) $\r\nvaries, an appropriate $ \\beta $ can keep $ \\zeta $ involved the past gradients\r\nsmall. Therefore, adding a $ 1-\\beta^t $ in the denominator can correct the bias.\r\n\\par A analysis of convergence only for convex cost function is given in the \r\narticle \\parencite{kingma2014adam}. Under the definition of regret:\r\n\\begin{equation}\r\n    R(T) = \\sum _{t=1}^T(J(W_t) - J(W^*)) \r\n\\end{equation}\r\nwhere $ W^* = \\mathop{\\arg\\min}_{W\\in (W_1,\\cdots,\\ W_T)}\\sum _{t=1}^TJ(W) $.\r\nThe theorem and proof is too obscure, hence we simply illustrate a corollary\r\nshowing the bound of regret.\r\n\\begin{cor}\r\n    Assume that the function $J$ has bounded gradients, \r\n    $ ||\\nabla J(W)||_2 \\leq G,\\ ||\\nabla J(W)||_\\infty \\leq G_\\infty,\r\n    \\ \\forall W $, and distance between any $ W_t $ is bounded, \r\n    $ ||W_m - W_n||_2 \\leq D,\\ ||W_m - W_n||_\\infty \\leq D_\\infty,\\\r\n    \\forall m,\\ n \\in (1,\\cdots,\\ T) $. Adam achieve the following \r\n    guarantee:\r\n    \\begin{equation}\r\n        \\forall T \\geq 1,\\ \\frac{R(T)}{T} = O(\\frac{1}{\\sqrt{T}})\r\n    \\end{equation} \r\n\\end{cor}\r\nTherefore, the regret bound $ O(\\sqrt{T}) $ is obtained.\r\n\r\n\\subsubsection{AdaMax}\r\nAdaMax is a simple and stable extension of Adam is attached\r\nin the same article \\parencite{kingma2014adam}. While $L_2$ Norm\r\nis numerically complex, AdaMax uses $L_p$ Norm for the \r\n\\engordnumber{2} raw moment, and let $ p \\rightarrow \\infty $:\r\n\\begin{equation}\r\n    \\label{equ:AdaMax}\r\n    \\begin{split}\r\n        v_t & = \\gamma^\\infty v_{t-1} + (1-\\gamma^\\infty)g_t^\\infty \\\\\r\n        & = max(\\gamma v_{t-1},\\ |g_t|)\r\n    \\end{split}\r\n\\end{equation}\r\nThe derivation in \\autoref{equ:AdaMax} is similar to $L_\\infty$ Norm.\r\nIn such adaption, even though the initialization of $ v_0 = 0 $, there\r\nis no need to correct the bias. See \\autoref{alg:AdaMax} for a complete \r\npseudo code.\r\n\\begin{algorithm}\r\n    \\caption{AdaMax. Note that all operators are element-wise. The recommended\r\n    hyperparameters are learning rate $ \\alpha = 0.002 $, momentum \r\n    constant $ \\beta = 0.9 $, RMSprop constant $ \\gamma = 0.999 $, \r\n    smoothing term $ \\epsilon = 10^{-8} $.}\r\n    \\label{alg:AdaMax}\r\n    \\begin{algorithmic}\r\n    \\REQUIRE $\\alpha$: Stepsize\r\n    \\REQUIRE $\\beta,\\ \\gamma \\in [0,\\ 1)]$: Exponential decay rates \r\n                for moment estimation\r\n    \\REQUIRE $J(W)$: Cost function with parameters $ W $\r\n    \\REQUIRE $W_0$: Initial parameter\r\n    \\STATE $m_0 \\gets 0$ (Initialize \\engordnumber{1} moment vector)\r\n    \\STATE $v_0 \\gets 0$ (Initialize \\engordnumber{2} moment vector)\r\n    \\STATE $t \\gets 0$ (Initialize time step)\r\n    \\WHILE{$ W_t $ not converged}\r\n    \\STATE $ t \\gets t + 1 $ \r\n    \\STATE $ g_t \\gets \\nabla J(W_{t-1}) $(Get gradients w.r.t. cost function)\r\n    \\STATE $ m_t \\gets \\beta m_{t-1} + (1-\\beta)g_t $ (Update biased first moment estimate)\r\n    \\STATE $ v_t \\gets max(\\gamma v_{t-1},\\ |g_t|) $ (Update the exponentially weighted infinity norm)\r\n    \\STATE $ \\hat{m_t} \\gets \\frac{m_{t-1}}{1-\\beta^t}$ (Compute bias-corrected first moment estimate)\r\n    \\STATE $ W_t \\gets W_{t-1} - \\alpha \\frac{\\hat{m_t}}{v_t} $ (Update parameters)\r\n    \\ENDWHILE\r\n    \\RETURN $ W_t $ (Resulting parameters)\r\n    \\end{algorithmic}\r\n\\end{algorithm}\r\n\r\n\\subsubsection{NAdam}\r\nNAG in \\autoref{sssec:NAG} shows a powerful correction for momentum,  and it is \r\ngenerally acknowledged that standard momentum is inferior to NAG. Dozat \r\n\\parencite{dozat2016incorporating} improves Adam's momentum part to NAG and \r\nachieves faster convergence speed.\r\n\\par First, Dozat modifies the NAG by applying a look ahead momentum to the update:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        v_t & = \\beta v_{t-1} - \\nabla J(W_{t-1}),\\ v_0 = 0 \\\\\r\n        W_t & = W_{t-1} +  \\beta v_t + \\alpha \\nabla J(W_{t-1})\r\n    \\end{split}\r\n\\end{equation} \r\nThen we can modify Adam in the following way:\r\n\\begin{equation}\r\n    \\begin{split}\r\n        W_t & = W_{t-1} - \\alpha \\frac{m_t}{(\\sqrt{\\hat{v_t}} + \\epsilon)(1-\\beta^t)} \\\\\r\n        & = W_{t-1} - \\alpha \\frac{\\beta m_t + (1-\\beta)g_t}{(\\sqrt{\\hat{v_t}} + \\epsilon)(1-\\beta^t)} \\\\\r\n        & = W_{t-1} - \\frac{\\alpha}{\\sqrt{\\hat{v_t}} + \\epsilon}(\\beta \\hat{m_t} + \\frac{(1-\\beta)g_t}{1-\\beta^t})\r\n    \\end{split}\r\n\\end{equation}\r\nA complete algorithm is shown in \\autoref{alg:NAdam}.\r\n\r\n\\begin{algorithm}[H]\r\n    \\caption{NAdam. Note that all operators are element-wise. The recommended\r\n    hyperparameters are learning rate $ \\alpha = 0.002 $, momentum \r\n    constant $ \\beta = 0.975 $, RMSprop constant $ \\gamma = 0.999 $, \r\n    smoothing term $ \\epsilon = 10^{-8} $.}\r\n    \\label{alg:NAdam}\r\n    \\begin{algorithmic}\r\n    \\REQUIRE $\\alpha$: Stepsize\r\n    \\REQUIRE $\\beta,\\ \\gamma \\in [0,\\ 1)]$: Exponential decay rates \r\n                for moment estimation\r\n    \\REQUIRE $J(W)$: Cost function with parameters $ W $\r\n    \\REQUIRE $W_0$: Initial parameter\r\n    \\STATE $m_0 \\gets 0$ (Initialize \\engordnumber{1} moment vector)\r\n    \\STATE $v_0 \\gets 0$ (Initialize \\engordnumber{2} moment vector)\r\n    \\STATE $t \\gets 0$ (Initialize time step)\r\n    \\WHILE{$ W_t $ not converged}\r\n    \\STATE $ t \\gets t + 1 $ \r\n    \\STATE $ g_t \\gets \\nabla J(W_{t-1}) $(Get gradients w.r.t. cost function)\r\n    \\STATE $ m_t \\gets \\beta m_{t-1} + (1-\\beta)g_t $ (Update biased first moment estimate)\r\n    \\STATE $ v_t \\gets \\gamma v_{t-1} + (1-\\gamma)g_t^2 $ (Update biased second moment estimate)\r\n    \\STATE $ \\hat{m_t} \\gets \\frac{m_{t-1}}{1-\\beta^t}$ (Compute bias-corrected first moment estimate)\r\n    \\STATE $ \\hat{v_t} \\gets \\frac{v_{t-1}}{1-\\gamma^t} $ (Compute bias-corrected second raw moment estimate)\r\n    \\STATE $ W_t \\gets W_{t-1} - \\frac{\\alpha}{\\sqrt{\\hat{v_t}}+\\epsilon}(\\beta \\hat{m_t} + \\frac{(1-\\beta)g_t}{1-\\beta^t}) $ (Update parameters)\r\n    \\ENDWHILE\r\n    \\RETURN $ W_t $ (Resulting parameters)\r\n    \\end{algorithmic}\r\n\\end{algorithm}\r\n\r\n\\begin{comment}\r\n    \\subsubsection{Comparison}\r\n\\end{comment}", "meta": {"hexsha": "ee5829f9573c1f702ef6bdee676c83747ba0a816", "size": 33177, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "body/undergraduate/final/section/TricksInNN.tex", "max_stars_repo_name": "xuebashuoge/Neural-Network-Overview", "max_stars_repo_head_hexsha": "ae11b768aeffe09ddd71b082dfd27c15c02d9c2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "body/undergraduate/final/section/TricksInNN.tex", "max_issues_repo_name": "xuebashuoge/Neural-Network-Overview", "max_issues_repo_head_hexsha": "ae11b768aeffe09ddd71b082dfd27c15c02d9c2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "body/undergraduate/final/section/TricksInNN.tex", "max_forks_repo_name": "xuebashuoge/Neural-Network-Overview", "max_forks_repo_head_hexsha": "ae11b768aeffe09ddd71b082dfd27c15c02d9c2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6624472574, "max_line_length": 146, "alphanum_fraction": 0.6664556771, "num_tokens": 10165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.4427712072766351}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Monday\\\\ 2020-10-5, \\\\ compiled \\\\ \\today}\n\nThese next few lectures, we will consider the motivations for inflationary models. \nThe problems they solved were the \\textbf{shortcomings of the Hot Big Bang} model. \n\n\\begin{enumerate}\n    \\item The horizon problem;\n    \\item the flatness problem;\n    \\item unwanted relics / magnetic monopole problem.\n\\end{enumerate}\n\nWe start by recalling some basic elements in cosmology. \nIn order to describe a homogeneous and isotropic universe we use the FLRW metric: \n%\n\\begin{align}\n\\dd{s}^2  = - c^2 \\dd{t}^2 + a^2(t) \\qty[ \\frac{ \\dd{r}^2}{1 - k r^2} + r^2 \\dd{\\Omega}^2]\n\\,,\n\\end{align}\n%\nwhere \\(\\dd{\\Omega}^2 = \\dd{\\theta}^2 + \\sin^2 \\theta \\dd{\\varphi }^2\n\\). The quantity \\(a(t)\\) is called the \\emph{scale factor}.\nThe coordinates \\(r\\), \\(\\theta \\) and \\(\\varphi \\) are called \\emph{comoving coordinates}. \n\nPhysical distances and comoving distances are related by \n%\n\\begin{align}\n\\lambda _{\\text{phys}} = a(t) \\lambda _{\\text{comoving}}\n\\,.\n\\end{align}\n\nThe constant  \\(k\\) is the spatial curvature of the universe, which can always be rescaled so that it is equal to \n\\begin{enumerate}\n    \\item \\(+1\\) for a spatially closed universe;\n    \\item \\(0\\) for a spatially flat universe;\n    \\item \\(-1\\) for a spatially open universe.\n\\end{enumerate}\n\nIn terms of the scale factor we define the \\textbf{Hubble parameter} \n%\n\\begin{align}\nH = \\frac{\\dot{a}}{a}\n\\,,\n\\end{align}\n%\nwhich describes the rate at which the universe expands. \n\nThe dynamics of gravity are described by the Einstein equations: \n%\n\\begin{align}\nG_{\\mu \\nu } = 8 \\pi G T_{\\mu \\nu }\n\\,,\n\\end{align}\n%\nwhere \\(T_{\\mu \\nu }\\) is the energy-momentum tensor of the particle species filling the universe, while \\(G_{\\mu \\nu } = R_{\\mu \\nu } - R g_{\\mu \\nu } / 2\\) is the Einstein tensor, describing curvature. \n\nThese can be derived from an action principle through the action \n%\n\\begin{align}\nS = \\underbrace{\\frac{1}{16 \\pi G} \\int R \\sqrt{-g} \\dd[4]{x}}_{S_{EH}} + \nS_{\\text{matter}}\n\\,.\n\\end{align}\n\nOften we use an ideal fluid energy-momentum tensor: \n%\n\\begin{align}\nT_{\\mu \\nu } = \\rho u_{\\mu } u_{\\nu } + P h_{\\mu \\nu }\n\\,,\n\\end{align}\n%\nwhere \\(h_{\\mu \\nu } = u_{\\mu } u_{\\nu } + g_{\\mu \\nu }\\) is a projector onto the space orthogonal to the four-velocity. This does not account for any anisotropy, it is the most symmetric energy-momentum tensor. \n% This is a diagonal \n\nIn order to solve the Einstein equations we can proceed with some assumptions, without needing to know the action for all the fundamental fields. The perfect fluid S-E tensor has all the FLRW symmetries, as long as \\(\\rho \\) and \\(P\\) are only functions of time. \n\n% We are \\emph{not} saying that this S-E tensor is only allowed if we are in a FLRW universe. \n% \\todo[inline]{Clarify\\dots }\n\nRequiring the FLRW symmetries means that the S-E tensor must be diagonal, however we can have viscosity as long as it is not \\emph{shear} but \\emph{bulk} viscosity, which adds onto the diagonal terms.\n\nInserting the FLRW metric into the Einstein equation yields the Friedmann equations: \n%\n\\begin{align}\n\\frac{\\dot{a}^2}{a^2} &= \\frac{8\\pi G}{3} \\rho - \\frac{k}{a^2}  \\\\\n\\frac{\\ddot{a}}{a} &= - \\frac{4 \\pi G}{3} \\qty(\\rho + 3 P)  \\\\\n\\dot{\\rho} &= - 3 \\frac{\\dot{a}}{a} \\qty(\\rho + P)\n\\,.\n\\end{align}\n\nThe first two can be derived from the Einstein equations directly, the third comes from the ``conservation law'' \\(\\tensor{T}{_{\\mu \\nu }^{;\\nu }} = 0\\). \n\nThey are not independent, only two are.\nWe have too many parameters: \\(a\\), \\(\\rho \\) and \\(P\\), but only two independent equations, so we ``close'' the system of equations with an equation of state, commonly \\(P = P(\\rho ) = w \\rho \\). \n\nThese equations of state describe many kinds of fluids (approximately):\ndust with \\(w = 0\\), which means \\(\\rho \\propto a^{-3}\\); radiation with \\(w = 1/3\\), which means \\(\\rho \\propto a^{-4}\\); a cosmological constant with \\(w = -1\\), which means \\(\\rho = \\const\\).\n\nIn general as long as \\(w \\neq 1\\) we have \\(\\rho \\propto a^{-3(1+w)}\\) and \\(a \\propto t^{2 / 3 (1+w)}\\).\n\n\\subsection{The horizon problem}\n\nThe \\textbf{particle horizon}, denoted as \\(d_H (t)\\), is given by \n%\n\\begin{align}\nd_H (t) = a(t) \\int_{0}^{t} \\frac{c \\dd{\\tau }}{a(\\tau )}\n\\,,\n\\end{align}\n%\nand it sets the radius of a sphere centered at an observer \\(O\\). The points inside this sphere have been able to have causal interactions with observer \\(O\\) in the time from the Big Bang to \\(t\\).\n\nIt is the proper distance (as measured today) which could have been travelled by light starting at the beginning and moving in a geodesic. \nIt can be derived from the FLRW metric by assuming radial light-like motion\n%\n\\begin{align}\n\\dd{s}^2 = - c^2 \\dd{t}^2 + a(t)\\frac{ \\dd{r}^2}{1 - kr^2} = 0\n\\,,\n\\end{align}\n%\nand setting \\(k = 0\\):\\footnote{This is a good approximation for early times, even if the universe is not flat.}\n%\n\\begin{align}\nc \\dd{t} = \\pm  a(t) \\dd{r}\n\\,,\n\\end{align}\n%\nwhich we can use to calculate the \\emph{comoving distance} from the point of emission to today, which we then multiply by the scale factor calculated at a chosen point. \n\nWe know that the scale factor goes to 0 as \\(t\\) goes to 0, so the integral giving us \\(r_H\\) could diverge. We can show that \\(d_H\\) is finite as long as \\(\\alpha = 2 / 3 (1+w)\\) is smaller than one, meaning that \\(w > - 1/3\\), which is equivalent to \\(\\ddot{a} < 0\\).\nIn a decelerating universe, the particle horizon is finite.\n\nIn general, the calculation yields\n%\n\\begin{align}\nd_H (t) = \\frac{3(1 +w)}{1 + 3w} ct\n\\,.\n\\end{align}\n\nWith \\(w = 0\\), a spatially flat matter-dominated universe, \\(d_H = 3 ct\\). This is called an Einstein-De Sitter universe. \nWith \\(w = 1/3\\), a spatially flat radiation-dominated universe, we have \\(d_H = 2 ct\\). \n\nAnother way to characterize causality is the Hubble radius: \n%\n\\begin{align}\nr_C(t) = \\frac{c}{H(t)}\n\\,.\n\\end{align}\n\nThe characteristic time of expansion is \\(\\tau (H ) =H^{-1}\\). \n\n\\begin{claim}\nIn a FLRW universe, typically after a Hubble time the scale factor doubles.\n\\end{claim}\n\n\\begin{proof}\nBy solving the Friedmann equations we see that the scaling is as \\(a(t) \\propto t^{\\alpha }\\), \\(H = \\alpha /t \\), so a Hubble time is just \\(\\tau _H = H^{-1} = t / \\alpha \\). Then, the change in the scale factor in a Hubble time is \n%\n\\begin{align}\n\\frac{a (t + \\tau _H)}{a(t)} = \\frac{\\qty(t + t/ \\alpha )^{\\alpha }}{t^{\\alpha }} = \\qty(1 + \\frac{1}{\\alpha })^{\\alpha }\n\\,.\n\\end{align}\n\nWe know that \\(\\alpha \\) is between \\(0\\) and \\(1\\): the value of this ratio of scale factors is 1 for \\(\\alpha = 0\\) (which would correspond to \\(w \\to \\infty \\)), and goes monotonically up to 2 for \\(\\alpha = 1\\) (which corresponds to \\(w = -1/3\\)).\nWith \\(w = 1/3\\), for example, we get \\(\\alpha = 1/2\\) and the ratio of the scale factors is \\(\\approx \\num{1.7}\\), which is reasonably close to \\(2\\).\n\\end{proof}\n\nSince \n%\n\\begin{align}\nH(t) = \\frac{2}{3 (1+w)} \\frac{1}{t} = \\frac{\\alpha}{t}\n\\,,\n\\end{align}\n%\nwe can define\n%\n\\begin{align}\nR_H = \\frac{1 + 3w}{2} d_C (t) \\approx d_H (t)\n\\,.\n\\end{align}\n\nTypically the quantity \\((1+3w) / 2\\) is of order 1, so the Hubble radius \\(r_C\\) and the particle horizon \\(d_H\\) are similar.\nThe two are similar in a regular FLRW universe, while they differ a lot if there is inflation. \n\n\\begin{claim}\nIn an inflationary period, the particle horizon is exponentially larger than the Hubble radius.\n\\end{claim}\n\n\\begin{proof}\nLet us assume that the Hubble parameter \\(H\\) is constant for simplicity. In a real scenario there will be deviations from this hypothesis, but they will not compromise the result. \n\nThen, the Hubble radius is simply given by \\(r_C = H^{-1}\\); while the particle horizon must be calculated by integrating the conformal time. \nWe need a relation between the scale factor and time: we can integrate \\(\\dot{a} = H a\\) to get \\(a(t) = e^{Ht}\\). Then, we find \n%\n\\begin{align}\nr_C(t) = a(t) \\int_{0}^{t} \\frac{ \\dd{\\tau }}{a(\\tau )} = e^{Ht} \\int_{0}^{t} e^{-H \\tau } \\dd{\\tau  } = \\underbrace{H^{-1}}_{r_C} \\qty(e^{Ht} - 1)\n\\,,\n\\end{align}\n%\nwhich becomes exponentially larger than \\(r_C\\) for \\(t \\gg H^{-1}\\).\n\\end{proof}\n\nThe particle horizon takes into account \\textbf{all the past history of an observer}, the Hubble radius does not care about it: it only describes causal connections taking place in a Hubble time. \n\nLet us introduce the \\emph{comoving Hubble radius}: \\(r_H (t)\\), given by \n%\n\\begin{align}\nr_H (t) = \\frac{r_C (t)}{a(t)} = \\frac{c}{a H}\n\\,.\n\\end{align}\n\nLet us plot this for a matter or radiation-dominated FLRW universe.\n\nIn radiation domination, \\(r_H \\propto \\sqrt{t}\\), while in matter domination \\(a \\sim t^{2/3}\\) so \\(r_H \\propto t^{1/3} \\sim a^{1/2}\\). \n\nThis comoving radius is then always increasing, initially faster and then slower. \n\nInstead, consider the comoving particle horizon: \\(d_H (t) / a(t)\\), so just the integral in the definition of \\(d_H(t)\\): \n%\n\\begin{align}\n\\frac{d_H (t)}{a(t)} = \\int \\frac{c \\dd{t}}{a} = \\int \\frac{ \\dd{a}}{a} \\underbrace{\\frac{c}{a H}}_{r_H}\n\\,,\n\\end{align}\n%\nso we can see that the comoving \\emph{particle horizon} is the logarithmic integral over the scale factor of the comoving \\emph{Hubble radius}: as we mentioned before, this takes into account the whole past history. \n\nIn a matter dominated universe, \\(d_H = 2 r_C \\approx 5 h^{-1} \\SI{}{Gpc}\\).\n\n\\subsection{Horizon problem}\n\nNow we discuss the horizon problem, which is best understood in a comoving plot: \\(\\log r_H \\) versus \\(\\log t\\). We neglect dark energy for simplicity.\n\nIf we choose a fixed comoving size \\(\\lambda \\), we get in our model that in early times \\(\\lambda \\) is super-horizon, then at a certain point it crosses the horizon, becoming smaller than \\(r_H \\). The time at which \\(r_H = \\lambda \\) is called the \\emph{horizon crossing} time, \\(t_H (\\lambda )\\). \n\nFor times earlier than \\(t_H (\\lambda )\\), by definition it is impossible for points at a distance \\(\\lambda \\) to be causally connected. \nThis happens for every scale, and it means that for many regions we are interested in there cannot have been causal connection in the early universe. \nBut, today we observe the universe to exhibit the same properties across the whole sky, even though the regions were causally disconnected earlier. \n\nThis is most directly expressed in terms of CMB photons. They would have become causally connected at the quadrupole scale (separations of \\SI{90}{\\degree}) almost \\emph{today}. \n\nWe can compute the size of the horizon at the last scattering epoch: this subtends an angle in the sky of around \\SI{1}{\\degree}; however we observe photons with the same temperature on much larger scales, this was already seen by COBE with an angular resolution of \\SI{7}{\\degree}. \n\n\\begin{claim}\nWithout inflation, the largest angular scale at which we would expect to see correlations on the Last Scattering Surface is on the order of \\SI{1}{\\degree}.\n\\end{claim}\n\n\\begin{proof}\nLet us establish some notation: we define \n%\n\\begin{align}\nE(z) = \\frac{H(z)}{H_0 } = \\sqrt{\\Omega_{0, \\Lambda } + \\Omega_{0, k} (1+ z)^2 + \\Omega_{0, m} (1 + z)^3 + \\Omega_{0, r} (1 + z)^{4}}\n\\,,\n\\end{align}\n%\n(the last expression follows from the first Friedmann equation), which allows us to compute distances, since the physical distance as measured today from a point at redshift \\(z\\) would be \n%\n\\begin{align}\nd (z) = \\frac{1}{H_0 } \\int_{0}^{z} \\frac{ \\dd{z'}}{E(z')}\n\\,,\n\\end{align}\n%\nsince \\(d(z)\\) is the integral over the appropriate range of \\(a_0 \\dd{\\eta }\\) (this is the same integral as one in the definition of the particle horizon), and the integration element of conformal time can be written as \n%\n\\begin{align}\n\\dd{\\eta } = \\frac{ \\dd{t}}{a} = - \\frac{ \\dd{z}}{a_0 H(z)}\n\\,,\n\\end{align}\n%\nas can be calculated by differentiating the definition of redshift:\n%\n\\begin{align}\n1 + z = \\frac{a_0 }{a } \n\\implies\n\\dv{z}{t} = - \\frac{a_0 \\dot{a}}{a^2} = - \\frac{a_0 H(z)}{a} \n\\implies \n\\frac{ \\dd{z}}{H(z) a_0 } = -\\frac{ \\dd{t}}{a}\n\\,.\n\\end{align}\n\nThe minus sign will be accounted for by the fact that we are integrating backward in conformal time if we do it for increasing \\(z\\).\nNow, the physical distance from here to the last scattering surface as measured now reads \n%\n\\begin{align}\nd(z_{LS}) = \\int_{\\text{emission}}^{\\text{absorption}} a_0 \\dd{\\eta }\n= -a_0  \\int_{z_{LS}}^{0} \\frac{ \\dd{z'}}{a_0 H(z')} = \\frac{1}{H_0 } \\int_{0}^{z_{LS}} \\frac{ \\dd{z'}}{E(z')}\n\\,.\n\\end{align}\n\nWe, however, want a new notion of distance \\(d_A\\) which allows us to write the small-angle approximation: \n%\n\\begin{align}\nd_A (z_{LS}) = \\frac{ \\Delta x}{\\Delta \\theta }\n\\,,\n\\end{align}\n%\nwhere \\(\\Delta \\theta \\) is a (small) angle on the sky as measured from here, while \\(\\Delta x\\) is a physical distance as measured at the time of last scattering. The small-angle relation holds in comoving coordinates: \n%\n\\begin{align}\nr_{LS} = \\frac{\\Delta r}{\\Delta \\theta }\n\\,,\n\\end{align}\n%\nwhere \\(r_{LS} = d(z_{LS}) / a_0 \\) is the comoving distance to the last scattering surface, and \\(\\Delta r\\) is the comoving size of the angular feature we are considering. \nThe physical scale \\(\\Delta x\\) is calculated as \\(a_{LS} \\Delta r\\), and \\(a_{LS} = a_0 / (1+z_{LS})\\), so the new distance measure must read \n%\n\\begin{align}\n\\underbrace{a_0 r_{LS}}_{d(z_{LS})} = a_0 \\frac{\\Delta r}{\\Delta \\theta } &= (1+z_{LS}) \\frac{\\Delta x}{\\Delta \\theta }  \\\\\n\\frac{\\Delta x}{\\Delta \\theta } = d_A (z_{LS}) &= \\frac{d(z_{LS})}{1 + z_{LS}} = \\frac{1}{H_0 (1+z_{LS})} \\int_{0}^{z_{LS}} \\frac{ \\dd{z'}}{E(z')}\n\\,.\n\\end{align}\n \nThis new distance is called the \\emph{angular diameter distance}. \nNow, we need to find the appropriate \\(\\Delta x\\): what is the physical size of the largest correlations we can expect to see? \nThis will just be the particle horizon (corresponding to light-speed communication), measured at that time: \n%\n\\begin{align}\n\\Delta x = a_{LS} \\int \\dd{\\eta } = \\frac{a_{LS}}{a_0 H_0 } \\int_{z_{LS}}^{\\infty } \\frac{ \\dd{z'}}{E(z')} = \\frac{H_0^{-1}}{1 + z_{LS}} \\int_{z_{LS}}^{\\infty } \\frac{ \\dd{z'}}{E(z')}\n\\,.\n\\end{align}\n\nNow we are almost done: we can invert the small-angle relation to get \n%\n\\begin{align}\n\\Delta \\theta &= \\frac{\\Delta x}{d_A(z_{LS})} \n= \\frac{H_0^{-1} (1+z_{LS})^{-1} \\int_{z_{LS}}^{\\infty } E^{-1} (z') \\dd{z'}}{H_0^{-1} (1+z_{LS})^{-1} \\int_0^{z_{LS}} E^{-1} (z') \\dd{z'}}  \\\\\n&= \\frac{\\int_{z_{LS}}^{\\infty } E^{-1} (z') \\dd{z'}}{\\int_0^{z_{LS}} E^{-1} (z') \\dd{z'}} \\approx \\num{.02} \\approx \\SI{1.2}{\\degree}\n\\,.\n\\end{align}\n\nThe result was obtained by numerical integration of the best-fit values from the Planck mission, as provided by the ``Planck18'' class from the Astropy module\\footnote{\\url{https://docs.astropy.org/en/stable/cosmology/index.html}} \\cite[]{astropycollaborationAstropyProjectBuilding2018}. \nHowever, the same qualitative result can be obtained analytically with much simpler assumptions: taking full matter domination (\\(\\Omega_{m, 0} = 1\\) and the others equal to zero) still yields \\(\\Delta \\theta \\approx \\SI{1.8}{\\degree}\\), a very reasonable number, and the calculation can then be done analytically, since \\(E(z) = (1 + z)^{3/2}\\) is integrable with the usual techniques. \n\\end{proof}\n\nPhotons which could not have been in causal contact in the HBB model are observed to have the same temperature. \n\nThe inflationary solution to this issue is to think that, before the radiation-dominated epoch, the comoving Hubble radius decreased for a certain period of time.\n\nThis allows the parts of the sky to have been in causal contact in the early universe. \n\nThis means that \\(\\ddot{a} > 0\\) in the inflationary phase (which is equivalent to \\(w < - 1/3\\)), since we are imposing \\(0 > \\dot{r} = (\\dv{}{t})(1/ \\dot{a}) = - \\ddot{a} / (\\dot{a})^2\\).\nThese are only the \\emph{kinematics} of inflation, we are not yet discussing how it might come about. \n\n\\end{document}\n", "meta": {"hexsha": "17b034b51662598be0662ba87502a4fc3591a14b", "size": 15933, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/early_universe/oct05.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/early_universe/oct05.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/early_universe/oct05.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 46.1826086957, "max_line_length": 387, "alphanum_fraction": 0.6756417498, "num_tokens": 5062, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4427712028615233}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{The Kerr solution}\n\n\\marginpar{Wednesday\\\\ 2020-10-14, \\\\ compiled \\\\ \\today}\n\nSome history: the Schwarzschild was found in 1915 while S.\\ was serving in the army; the second exact solution was found in 1963 by a PhD student in New Zeland \\cite[]{kerrGravitationalFieldSpinning1963}.\nIn Cartesian coordinates the metric is hideous; nowadays we use the coordinates defined by Boyer and Lyndquist: starting from a flat set of Cartesian coordinates \\(x, y, z\\) we define \\(r, \\theta , \\varphi \\) as\n%\n\\begin{align}\nx &= \\sqrt{r^2 + a^2} \\sin \\theta \\sin \\varphi   \\\\\ny &= \\sqrt{r^2 + a^2} \\sin \\theta \\cos \\varphi  \\\\\nz &= r \\cos \\theta \n\\,.\n\\end{align}\n\nThese are then not \\emph{spherical} but \\emph{spheroidal} coordinates. \nConstant-\\(r\\) spheroids are oblate ellipsoids in the \\(z\\) direction.\n\nThe Kerr solution, for who wants to see the computation, is derived in ``The mathematical theory of Black Holes'' by Chandrasekhar \\cite[]{chandrasekharMathematicalTheoryBlack1998}.  \nThe metric reads \n%\n\\begin{align}\n\\dd{s^2} = - \\qty(1 - \\frac{2Mr}{\\Sigma }) \\dd{t^2}\n+ \\frac{\\Sigma }{\\Delta } \\dd{r^2} \n+ \\Sigma \\dd{\\theta ^2} \n+ \\qty(r^2 + a^2 + \\frac{aA}{\\Sigma }) \\sin^2 \\theta \\dd{\\varphi^2} \n- \\frac{2A}{\\Sigma } \\dd{t} \\dd{\\varphi }\n\\,,\n\\end{align}\n%\nwhere: \n%\n\\begin{align}\n\\Delta = r^2 - 2Mr + a^2\n&&\n\\Sigma = r^2 + a^2 \\cos^2 \\theta \n&&\nA = 2Mar \\sin^2 \\theta \n\\,,\n\\end{align}\n%\nwhile \\(a = J / M\\) is the \\emph{specific angular momentum} of the black hole. \n\nIt describes the spacetime outside an axially symmetric, stationary body. \nIn the Schwarzschild spacetime we have identified an horizon at \\(r = 2M\\) by the properties that \\(g_{00} \\to 0\\) and \\(g_{rr} \\to \\infty \\). \n\nWhat about Kerr? Are there horizons? In this case, the two conditions do not happen in the same place. \nThe region \\(g_{00} = 0\\) is known as the \\emph{limit of staticity}: if it is the case, an observer's worldline cannot be both \\emph{timelike} and \\emph{stationary} (meaning time-directed). \n\nThe condition \\(g_{00} > 0\\) is equivalent to \\(\\Sigma < 2Mr\\).\nNow, consider the \\(\\dd{r^2}\\) coefficient: \\(\\Sigma / \\Delta \\): this is positive always. \n\nIf we are in the region \\(\\theta = \\pi /2\\), at \\(g_{00} > 0\\) we can still have the metric's signature be \\(- +++\\), since we have the \\(\\dd{t} \\dd{\\varphi }\\) term. \n\nAs long as \\(a \\dd{\\varphi } > 0\\), that term in the metric is negative, allowing the signature of the metric to be preserved. \n\nThis means that \\textbf{the particle must be co-rotating} with the black hole if it is in the region \\(g_{00} > 0\\).\n \nAs long as this is the case, however, a particle can remain at fixed \\(r\\) and even escape. This is, then, \\emph{not} an horizon. \n\nThe horizon, instead, is found when \\(g_{rr}\\) diverges: this is equivalent to \\(\\Delta \\to 0\\), which means \n%\n\\begin{align}\nr^2 - 2Mr + a^2 = 0 \\implies r = M \\pm \\sqrt{M^2 - a^2}\n\\,.\n\\end{align}\n\nBoth of these radii correspond to an horizon. \nLet us denote \\(r_+ = r_H\\), since the inner horizon cannot really affect any observations. \n\nIn order for these two solutions to be real, we must have \\(a < M\\). \nThere is an horizon as long as \\(a/ M < 1\\). \n\nIf \\(a > M\\), we have a \\textbf{naked singularity}, since the singularity at \\(\\Sigma  = 0\\) is still there.\nThis singularity, in any case, is not shaped like a point: we only reach it along the equatorial plane. \n\nPenrose proposed the cosmic \\textbf{censorship hypothesis}: the universe is a ``prude'', it always hides singularities with horizons.\nThere are good theoretical reasons to believe that this is verified. \n\nWhere is the limit of staticity? The equation is \n%\n\\begin{align}\nr^2 + a^2 \\cos^2 \\theta - 2Mr = 0\n\\,,\n\\end{align}\n%\nwhich  is solved by \n%\n\\begin{align}\nr_{\\pm} = M \\pm \\sqrt{M^2- a^2 \\cos^2 \\theta }\n\\,.\n\\end{align}\n\nThere are two of these surfaces as well, and we consider the outer one as before: \\(r_E = r_+\\). If the horizon exists, then this region also exists. \n\nThis region is called the \\textbf{ergosphere}, and the region between \\(r_H < r < r_E\\) is called the \\textbf{ergoregion}. \n\nSee \\textcite[sec. 3]{heinickeSchwarzschildKerrSolutions2015} for an in-depth discussion of the shape of these regions; figure 12 there also shows them graphically. \n\nThe name comes from the fact that we can extract rotational energy from the BH. \n``Ergo'' means energy. \n\nThere has been a long debate about whether the Penrose process actually occurs in a realistic astrophysical setting: the consensus is that the trajectory a particle must take in order for this to happen is way too peculiar. \n\nNote that in this case we also have the cyclic coordinates \\(\\varphi \\) and \\(t\\). We have two constants of motion like in Schwarzschild. \n\nIt can be shown that there exists a third constant of motion, beyond \\(E\\) and \\(L_z\\): \\(Q\\), called Carter's constant. \n\nFor motion in the equatorial plane we can write the following expression for the energy integral: \n%\n\\begin{align}\nE = \\frac{r^{3/2} - 2 r^{1/2} \\pm a M^{1/2}}{r^{3/2} \\qty(r^{3/2}- 3M r^{1/2} \\pm 2a M^{1/2})^{1/2}}\n\\,,\n\\end{align}\n%\nwhere \\(\\pm\\) refers to whether the particle moves along a prograde or retrograde trajectory.\n\nThe expression for the last stable (LS, or sometimes MS for ``marginally stable'') circular orbit is \\cite[eq.\n\\ 28]{puglieseEquatorialCircularMotion2011}:\n%\n\\begin{align}\nr_{LS} = M \\qty[ 3 + z_2 \\mp \\qty[(3 - z_1 ) (3 + z_1 +2z_2 )]^{1/2}]\n\\,,\n\\end{align}\n%\nwhere \n%\n\\begin{align}\nz_1 &= 1 + \\qty(1 - \\frac{a^2}{M^2})^{1/3} \\qty[\\qty(1 + \\frac{a}{M})^{1/3} + \\qty(1 - \\frac{a}{M})^{1/3}]  \\\\\nz_2 &= \\qty(3 \\frac{a^2}{M^2} + z_1^2)^{1/2}\n\\,.\n\\end{align}\n\nThis reduces to \\(r_{LS} = 6 M\\) in the \\(a = 0\\) case, since then we have \\(z_1 = z_2 = 3\\). \n\nWhat happens for an extreme Kerr BH, with \\(a = M\\)? \nThen \\(z_1 = 1\\), \\(z_2 = 2\\): so, \n%\n\\begin{align}\nr_{LS} = M \\qty[3 + 2 \\mp \\sqrt{2 \\times 8}] = M \\qty[5 \\mp 4]\n\\,,\n\\end{align}\n%\nwhich yields \\(r_{LS} = M\\) in the corotating case, and \\(r_{LS} = 9M\\) in the counter-rotating case.\n\nWe expect that the efficiency of a Kerr BH in the extraction of energy from matter will be higher than the Schwarzschild solution. \nLet us use the expression we found for the specific energy \\(E\\), with respect to the parameter \\(x = r/M\\): \n%\n\\begin{align}\nE = \\frac{x^{3/2} - 2 x^{1/2} \\pm a/M}{x^{3/2} \\sqrt{x^{3/2} - 3x^{1/2} \\pm 2a /M}}\n\\,,\n\\end{align}\n%\nwhich in the extreme case becomes \n%\n\\begin{align}\nE = \\frac{x^{3/2} - 2 x^{1/2} \\pm 1}{x^{3/2} \\sqrt{x^{3/2 }- 3 x^{1/2} \\pm 2}}\n\\,,\n\\end{align}\n%\nso we can take the limit: in the corotating direct case, sending \\(x \\to 1\\) we get \\(E = 1 / \\sqrt{3} \\approx \\num{.577}\\). \n\nThe efficiency is given by \n%\n\\begin{align}\n\\eta = \\frac{E_\\infty  - E}{E_{\\infty }} = 1 - 1 / \\sqrt{3} \\approx \\SI{42}{\\percent}\n\\,.\n\\end{align}\n\nThis is a huge amount of energy: we do not expect real black holes to be extreme. \nThere are estimates of the spins of the black holes. \nWhat is found is that they seem to cover the whole range \\(0 < a/ M < 1\\). \n\nAn issue regarding a wide-spread misconception: the parameter \\(M\\) in the interior Schwarzschild solution is the same as the \\(M\\) in the corresponding \\emph{exterior} solution. Can we apply the same kind of reasoning for Kerr?\nIs there an interior Kerr solution? \nWe don't know, but most probably not. \nMany efforts were put into seeking it, and they all failed. \nThe properties of the matter and radiation inside are weird. \n\nThe wide-spread misconception is to claim that the Kerr spacetime describes the spacetime around a rotating star. \nIt sounds reasonable, but it's wrong. \nNumerically we can derive the true form of the spacetime outside something like a neutron star: it is very different from the Kerr spacetime. \n\nA qualitative argument: a star will generally have a quadrupole moment and emit GWs, while Kerr does not. \nKerr is a Petrov-type-D spacetime, which is \\emph{nonradiating}. \nIf we do the calculation, we find that the quadrupole moment of Kerr is \\(Q = J / M\\). \n\nFor an in-depth discussion see \\textcite[]{bertiRotatingNeutronStars2005}, which refers to \\textcite[]{bakerMakingUseGeometrical2000} for its tools to measure ``non-type-D-ness''.\n\nThe Petrov classification refers to the symmetries of the Weyl tensor --- the ``deviatoric'' part of the Riemann tensor, which describes deformation but not expansion/compression. \nKerr spacetime can be analytically shown to be type D, which means its Weyl tensor is ``highly symmetric'', and the consequence of this is that the radiation it can emit decays like \\(r^{-3}\\), like the tidal tensor of regular Newtonian gravity. \nThis prevents the emission of long-range \\(r^{-1}\\) gravitational radiation, which we know NSs to emit.\n% (see, for example, the Hulse-Taylor pulsar). \n\n% About the differences between the Kerr spacetime and the spacetime outside a rotating star: the spacetime outside a rotating body is indeed \\emph{not} Kerr. \n\n% Kerr is Petrov type D, which means nonradiative: we would need to compute the Weyl invariants of the metric. \n% If we compute the invariant telling us whether a spacetime is radiative or not, we find that it is nonradiative iff \\(Q = J / M\\). \n% The Hartle-Thorne approximation allows us to work up to a certain value of \\(\\Omega / \\Omega _k\\), close to the mass shedding limit.\n\n% The thing we find is that in general for a star the quadrupole is \\(Q \\neq Q _{\\text{Kerr}}\\), however for small values of the rotation the spacetimes converge. \n\n% A reference for this: \\textcite{bertiRotatingNeutronStars2005}. \n\n% To leading order, deviations from type-D are driven by deviations of \\(Q \\) from \\(Q _{\\text{Kerr}}\\). \n\n% Next time, we will discuss Equations of state and degenerate gasses.\n\n\\end{document}\n", "meta": {"hexsha": "3d0bb803b2ddaaf46d76b0d5481828c57fa9dda2", "size": 9775, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/compact_objects/oct14.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/compact_objects/oct14.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/compact_objects/oct14.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 46.108490566, "max_line_length": 246, "alphanum_fraction": 0.6969820972, "num_tokens": 3056, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.44274714117498126}}
{"text": "\\section{Even and Odd Operators}\\index{Even operator}\\index{Odd operator}\nAn operator can be declared to be {\\em even\\/} or {\\em odd\\/} in its first\nargument by the declarations {\\tt EVEN}\\ttindex{EVEN} and\n{\\tt ODD}\\ttindex{ODD} respectively.  Expressions involving an operator\ndeclared in this manner are transformed if the first argument contains a\nminus sign.  Any other arguments are not affected.  In addition, if say\n{\\tt F} is declared odd, then {\\tt f(0)} is replaced by zero unless\n{\\tt F} is also declared {\\em non zero\\/} by the declaration\n{\\tt NONZERO}\\ttindex{NONZERO}.  For example, the declarations\n\\begin{verbatim}\n\teven f1; odd f2;\n\\end{verbatim}\nmean that\n\\begin{verbatim}\n\tf1(-a)    ->    F1(A)\n\tf2(-a)    ->   -F2(A)\n\tf1(-a,-b) ->    F1(A,-B)\n\tf2(0)     ->    0.\n\\end{verbatim}\nTo inhibit the last transformation, say {\\tt nonzero f2;}.\n\n\\section{Linear Operators}\\index{Linear operator}\nAn operator can be declared to be linear in its first argument over powers\nof its second argument.  If an operator {\\tt F} is so declared, {\\tt F} of\nany sum is broken up into sums of {\\tt F}s, and any factors that are not\npowers of the variable are taken outside.  This means that {\\tt F} must\nhave (at least) two arguments.  In addition, the second argument must be\nan identifier (or more generally a kernel), not an expression.\n\n{\\it Example:}\n\nIf {\\tt F} were declared linear, then\n\\begin{verbatim}\n                                5\n        f(a*x^5+b*x+c,x) ->  F(X ,X)*A + F(X,X)*B + F(1,X)*C\n\\end{verbatim}\nMore precisely, not only will the variable and its powers remain within the\nscope of the {\\tt F} operator, but so will any variable and its powers that\nhad been declared to {\\tt DEPEND} on the prescribed variable; and so would\nany expression that contains that variable or a dependent variable on any\nlevel, e.g. {\\tt cos(sin(x))}.\n\nTo declare operators {\\tt F} and {\\tt G} to be linear operators,\nuse:\\ttindex{LINEAR}\n\\begin{verbatim}\n        linear f,g;\n\\end{verbatim}\nThe analysis is done of the first argument with respect to the second; any\nother arguments are ignored. It uses the following rules of evaluation:\n\\begin{quote}\n\\begin{tabbing}\n{\\tt    f(0)      ->   0} \\\\\n{\\tt    f(-y,x)   ->  -F(Y,X)} \\\\\n{\\tt    f(y+z,x)  ->   F(Y,X)+F(Z,X)} \\\\\n{\\tt    f(y*z,x)  ->   Z*F(Y,X)} \\hspace{0.5in}\\= if Z does not depend on X \\\\\n{\\tt    f(y/z,x)  ->   F(Y,X)/Z} \\> if Z does not depend on X\n\\end{tabbing}\n\\end{quote}\nTo summarize, {\\tt Y} ``depends'' on the indeterminate {\\tt X} in the above\nif either of the following hold:\n\\begin{enumerate}\n\\item {\\tt Y} is an expression that contains {\\tt X} at any level as a\n      variable, e.g.: {\\tt cos(sin(x))}\n\n\\item Any variable in the expression {\\tt Y} has been declared dependent on\n      {\\tt X} by use of the declaration {\\tt DEPEND}.\n\\end{enumerate}\nThe use of such linear operators\\index{Linear operator} can be seen in the\npaper Fox, J.A. and A. C. Hearn, ``Analytic Computation of Some Integrals\nin Fourth Order Quantum Electrodynamics'' Journ. Comp. Phys. 14 (1974)\n301-317, which contains a complete listing of a program for definite\nintegration\\index{Integration} of some expressions that arise in fourth\norder quantum electrodynamics.\n\n\\section{Non-Commuting Operators}\\index{Non-commuting operator}\nAn operator can be declared to be non-commutative under multiplication by\nthe declaration {\\tt NONCOM}.\\ttindex{NONCOM}\n\n{\\it Example:}\n\nAfter the declaration \\\\\n{\\tt noncom u,v;}\\\\\nthe expressions {\\tt\nu(x)*u(y)-u(y)*u(x)} and {\\tt u(x)*v(y)-v(y)*u(x)} will remain unchanged\non simplification, and in particular will not simplify to zero.\n\nNote that it is the operator ({\\tt U} and {\\tt V} in the above example)\nand not the variable that has the non-commutative property.\n\nThe {\\tt LET}\\ttindex{LET} statement may be used to introduce rules of\nevaluation for such operators.  In particular, the boolean operator\n{\\tt ORDP}\\ttindex{ORDP} is useful for introducing an ordering on such\nexpressions.\n\n{\\it Example:}\n\nThe rule\n\\begin{verbatim}\n        for all x,y such that x neq y and ordp(x,y)\n           let u(x)*u(y)= u(y)*u(x)+comm(x,y);\n\\end{verbatim}\nwould introduce the commutator of {\\tt u(x)} and {\\tt u(y)} for all\n{\\tt X} and {\\tt Y}.  Note that since {\\tt ordp(x,x)} is {\\em true}, the\nequality check is necessary in the degenerate case to avoid a circular\nloop in the rule.\n\n\\section{Symmetric and Antisymmetric Operators}\n\nAn operator can be declared to be symmetric with respect to its arguments\nby the declaration {\\tt SYMMETRIC}.\\ttindex{SYMMETRIC} For example\n\\begin{verbatim}\n        symmetric u,v;\n\\end{verbatim}\nmeans that any expression involving the top level operators {\\tt U} or\n{\\tt V} will have its arguments reordered to conform to the internal order\nused by {\\REDUCE}.  The user can change this order for kernels by the\ncommand {\\tt KORDER}.\n\nFor example, {\\tt u(x,v(1,2))} would become {\\tt u(v(2,1),x)}, since\nnumbers are ordered in decreasing order, and expressions are ordered in\ndecreasing order of complexity.\n\nSimilarly the declaration {\\tt ANTISYMMETRIC}\\ttindex{ANTISYMMETRIC}\ndeclares an operator antisymmetric.   For example,\n\\begin{verbatim}\n        antisymmetric l,m;\n\\end{verbatim}\nmeans that any expression involving the top level operators {\\tt L} or\n{\\tt M} will have its arguments reordered to conform to the internal order\nof the system, and the sign of the expression changed if there are an odd\nnumber of argument interchanges necessary to bring about the new order.\n\nFor example, {\\tt l(x,m(1,2))} would become {\\tt -l(-m(2,1),x)} since one\ninterchange occurs with each operator.  An expression like {\\tt l(x,x)}\nwould also be replaced by 0.\n\n\\section{Declaring New Prefix Operators}\n\nThe user may add new prefix\\index{Prefix} operators to the system by\nusing the declaration {\\tt OPERATOR}. For example:\n\\begin{verbatim}\n        operator h,g1,arctan;\n\\end{verbatim}\nadds the prefix operators {\\tt H}, {\\tt G1} and {\\tt ARCTAN} to the system.\n\nThis allows symbols like {\\tt h(w), h(x,y,z), g1(p+q), arctan(u/v)} to be\nused in expressions, but no meaning or properties of the operator are\nimplied.  The same operator symbol can be used equally well as a 0-, 1-, 2-,\n3-, etc.-place operator.\n\nTo give a meaning to an operator symbol, or express some of its\nproperties, {\\tt LET}\\ttindex{LET} statements can be used, or the operator\ncan be given a definition as a procedure.\n\nIf the user forgets to declare an identifier as an operator, the system\nwill prompt the user to do so in interactive mode, or do it automatically\nin non-interactive mode. A diagnostic message will also be printed if an\nidentifier is declared {\\tt OPERATOR} more than once.\n\nOperators once declared are global in scope, and so can then be referenced\nanywhere in the program.  In other words, a declaration within a block (or\na procedure) does not limit the scope of the operator to that block, nor\ndoes the operator go away on exiting the block (use {\\tt CLEAR} instead\nfor this purpose).\n\n\n\\section{Declaring New Infix Operators}\n\nUsers can add new infix operators by using the declarations\n{\\tt INFIX}\\ttindex{INFIX} and {\\tt PRECEDENCE}.\\ttindex{PRECEDENCE}\nFor example,\n\\begin{verbatim}\n        infix mm;\n        precedence mm,-;\n\\end{verbatim}\nThe declaration {\\tt infix mm;} would allow one to use the symbol\n{\\tt MM} as an infix operator:\n\\begin{quote}\n\\hspace{0.2in} {\\tt a mm b} \\hspace{0.3in} instead of \\hspace{0.3in}\n{\\tt mm(a,b)}.\n\\end{quote}\n\nThe declaration {\\tt precedence mm,-;} says that {\\tt MM} should be\ninserted into the infix operator precedence list just {\\em after\\/}\nthe $-$ operator.  This gives it higher precedence than $-$ and lower\nprecedence than * .  Thus\n\n\\begin{quote}\n\\hspace{0.2in}{\\tt a - b mm c - d}\\hspace{.3in} means \\hspace{.3in}\n{\\tt a - (b mm c) - d},\n\\end{quote}\nwhile\n\\begin{quote}\n\\hspace{0.2in}{\\tt   a * b mm c * d}\\hspace{.3in} means \\hspace{.3in}\n{\\tt (a * b) mm (c * d)}.\n\\end{quote}\n\nBoth infix and prefix\\index{Prefix} operators have no transformation\nproperties unless {\\tt LET}\\ttindex{LET} statements or procedure\ndeclarations are used to assign a meaning.\n\nWe should note here that infix operators so defined are always binary:\n\\begin{quote}\n\\hspace{0.2in}{\\tt a mm b mm c}\\hspace{.3in} means \\hspace{.3in}\n{\\tt (a mm b) mm c}.\n\\end{quote}\n\n\\section{Creating/Removing Variable Dependency}\n\nThere are several facilities in {\\REDUCE}, such as the differentiation\n\\index{Differentiation}\noperator and the linear operator\\index{Linear operator} facility, that\ncan utilize knowledge of the dependency between various variables, or\nkernels.  Such dependency may be expressed by the command {\\tt\nDEPEND}.\\ttindex{DEPEND} This takes an arbitrary number of arguments and\nsets up a dependency of the first argument on the remaining arguments.\nFor example,\n\\begin{verbatim}\n        depend x,y,z;\n\\end{verbatim}\nsays that {\\tt X} is dependent on both {\\tt Y} and {\\tt Z}.\n\\begin{verbatim}\n        depend z,cos(x),y;\n\\end{verbatim}\nsays that {\\tt Z} is dependent on {\\tt COS(X)} and {\\tt Y}.\n\nDependencies introduced by {\\tt DEPEND} can be removed by {\\tt NODEPEND}.\n\\ttindex{NODEPEND} The arguments of this are the same as for {\\tt DEPEND}.\nFor example, given the above dependencies,\n\\begin{verbatim}\n        nodepend z,cos(x);\n\\end{verbatim}\nsays that {\\tt Z} is no longer dependent on {\\tt COS(X)}, although it remains\ndependent on {\\tt Y}.\n\n", "meta": {"hexsha": "05274f80aa26ddf66e4db7529f5a02d34895f0a8", "size": 9394, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "atomic_Decomp/Redlog/reduce.doc/oper2.tex", "max_stars_repo_name": "Korosensei42/AtomicDecomposition", "max_stars_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "atomic_Decomp/Redlog/reduce.doc/oper2.tex", "max_issues_repo_name": "Korosensei42/AtomicDecomposition", "max_issues_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "atomic_Decomp/Redlog/reduce.doc/oper2.tex", "max_forks_repo_name": "Korosensei42/AtomicDecomposition", "max_forks_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8050847458, "max_line_length": 78, "alphanum_fraction": 0.7169469874, "num_tokens": 2607, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4427471368058916}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{fancyvrb,amsmath,amsfonts,amssymb,graphicx,parskip,listings}\n\\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}\n\\usepackage{tikz}\n\n% change margins\n\\addtolength{\\oddsidemargin}{-.875in}\n\\addtolength{\\evensidemargin}{-.875in}\n\\addtolength{\\textwidth}{1.75in}\n\\addtolength{\\topmargin}{-.875in}\n\\addtolength{\\textheight}{1.75in}\n\n\\hyphenpenalty=10000\n\n\\begin{document}\n\n\\begin{center}\n{\\LARGE Eigenmath Manual}\n\nGeorge Weigt\n\nDecember 19, 2019\n\\end{center}\n\n\\tableofcontents\n\n\\newpage\n\n\\input{nabokov}\n\n\\input{arithmetic}\n\n\\input{exponents}\n\n\\input{symbols}\n\n\\input{scripting}\n\n\\input{draw}\n\n\\input{complex}\n\n\\input{linear-algebra}\n\n\\input{derivative}\n\n\\input{integrals}\n\n\\input{integral-trick}\n\n\\input{fund-thm-of-calculus}\n\n\\input{line-integral}\n\n\\input{surface-area}\n\n\\input{surface-integral}\n\n\\input{greens-theorem}\n\n\\input{stokes-theorem}\n\n%%%%%\n\n\\section{Examples}\n\n\\input{francois-viete}\n\n\\input{curl-in-tensor-form}\n\n\\input{qho}\n\n\\input{hydrogen-wavefunctions}\n\n\\input{space-shuttle-and-corvette}\n\n\\input{avogadro}\n\n\\input{zerozero}\n\n\\subsection{Euler's identity}\nIt is easy to ``believe'' that $e^{i\\pi}=-1$ by looking at Taylor series expansions.\n\nFirst, consider the Taylor series expansion of $e^y$.\n\\[\ne^y=1+y+\\frac{y^2}{2!}+\\frac{y^3}{3!}+\\frac{y^4}{4!}\n+\\frac{y^5}{5!}+\\frac{y^6}{6!}+\\frac{y^7}{7!}+\\cdots\n\\]\nNext, substitute $ix$ for $y$.\n\\begin{align*}\ne^{ix}&=1+ix+\\frac{(ix)^2}{2!}+\\frac{(ix)^3}{3!}+\\frac{(ix)^4}{4!}\n+\\frac{(ix)^5}{5!}+\\frac{(ix)^6}{6!}+\\frac{(ix)^7}{7!}+\\cdots\\\\\n&=1+ix-\\frac{x^2}{2!}-i\\frac{x^3}{3!}+\\frac{x^4}{4!}\n+i\\frac{x^5}{5!}-\\frac{x^6}{6!}-i\\frac{x^7}{7!}+\\cdots\n\\end{align*}\nNext, collect the real and imaginary terms.\n\\begin{align*}\ne^{ix}&=\\left(1-\\frac{x^2}{2!}+\\frac{x^4}{4!}-\\frac{x^6}{6!}+\\cdots\\right)\n+i\\left(x-\\frac{x^3}{3!}+\\frac{x^5}{5!}-\\frac{x^7}{7!}+\\cdots\\right)\\\\\n&=\\cos x+i\\sin x\n\\end{align*}\nFinally, substitute $\\pi$ for $x$.\n\\[\ne^{i\\pi}=\\cos\\pi+i\\sin\\pi=-1\n\\]\nThe following script checks the identity $e^{ix}=\\cos x+i\\sin x$ for order $n$.\n\\begin{Verbatim}[formatcom=\\color{blue}]\nn = 7\nE = taylor(e^y,y,n)\nE = eval(E,y,i*x)\nC = taylor(cos(x),x,n)\nS = taylor(sin(x),x,n)\ntest(E=C+i*S,\"true\",\"false\")\n\\end{Verbatim}\n\n\\newpage\n\n\\input{list-of-functions}\n\n\\newpage\n\n\\input{syntax}\n\n\\newpage\n\n\\input{tricks}\n\n\\end{document}\n", "meta": {"hexsha": "47893a26c7aee6f6c40fc96730416c50b1a57903", "size": 2331, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/eigenmath.tex", "max_stars_repo_name": "zhouxs1023/eigenmath", "max_stars_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/eigenmath.tex", "max_issues_repo_name": "zhouxs1023/eigenmath", "max_issues_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/eigenmath.tex", "max_forks_repo_name": "zhouxs1023/eigenmath", "max_forks_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0697674419, "max_line_length": 84, "alphanum_fraction": 0.6688116688, "num_tokens": 922, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.4426903879896057}}
{"text": "\\paragraph{Answer 2.}\n\nWhen answering these questions, it is important to keep in mind that\nthe language of words made up on the alphabet~\\(\\Sigma\\)\nis~\\(\\Sigma^{*}\\) and that there are, in general, several regular\nexpressions describing one language.\n\n\\begin{enumerate}\n\n  \\item The constraint on the words is that they must be of the shape\n    \\(a \\ldots a\\) where the dots stand for `any combination of \\(a\\)\n    and \\(b\\).' In other words, one answer is \\(a \\lparen a \\;\n    \\disjM{} \\, b\\rparen\\kleeneM \\, a \\, \\disjM \\, a\\).\n\n  \\item This question is very simple since the language of all words\n    is \\(\\lparen a \\; \\disjM{} \\, b\\rparen\\kleeneM\\), we have to\n    remove \\(\\epsilon\\), \\emph{i.e.,} one simple answer is \\(\\lparen a \\;\n    \\disjM{} \\, b\\rparen\\plusM\\).\n\n  \\item The question implies that the words we are looking for are of\n    the form \\(\\ldots a \\, \\_ \\, \\_\\) where the dots stand for `any\n    sequence of \\(a\\) and \\(b\\)' and each `\\_' stands for a regular\n    expression denoting any letter. Any letter is described\n    by \\(\\lparen a \\, \\disjM{} \\, b\\rparen\\); therefore one possible\n    answer is \\(\\lparen a \\, \\disjM{} \\, b\\rparen\\kleeneM{}\n    a \\, \\lparen a \\, \\disjM{} \\, b\\rparen \\, \\lparen a \\, \\disjM{} \\,\n    b\\rparen\\).\n\n  \\item The words we search contain, at any place, exactly three\n    \\(a\\), so are of the form \\(\\ldots a \\ldots a \\ldots a \\ldots\\),\n    where the dots stand for `any letter except \\(a\\)', \\emph{i.e.,} `any\n    number of \\(b\\).' In other words: \\(b\\kleeneM a b\\kleeneM a\n    b\\kleeneM a b\\kleeneM\\).\n\n  \\item Because the alphabet contains only two letters, the question\n    is equivalent to: 'All words containing the substring\n    ab', \\emph{i.e.,} the words are of the form \\(\\ldots ab \\ldots\\)\n    where the dots stand for `any sequence of \\(a\\) and \\(b\\).' It is\n    then easy to understand that a short answer is \\(\\lparen\n    a \\, \\disjM{} \\, b\\rparen\\kleeneM ab \\lparen a \\, \\disjM{} \\,\n    b\\rparen\\kleeneM\\).\n\n  \\item Because the alphabet is made only of two letters, the answer\n    is easy: we put first all the \\(a\\) and then all the \\(b\\):\n    \\(a\\kleeneM b\\kleeneM\\).\n\n  \\item Since the alphabet contains only two letters, the only way to\n    not repeat a letter is to only have substrings \\(ab\\) or \\(ba\\) in\n    the words we look for. In other words: \\(abab\\ldots ab\\) or\n    \\(abab\\ldots aba\\) or \\(baba\\ldots ba\\) or \\(baba\\ldots bab\\). In\n    short: \\(\\lparen ab \\rparen\\kleeneM a\\opt \\, \\disjM{} \\, \\lparen\n    ba \\rparen\\kleeneM b\\opt\\) or, even shorter: \\(a\\opt \\lparen ba\n    \\rparen\\kleeneM b\\opt\\).\n\n\\end{enumerate}\n\n\n", "meta": {"hexsha": "f18c310fda95bd8908f052f048ce9938d9f0112a", "size": 2601, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "regexp_answer_02.tex", "max_stars_repo_name": "rinderknecht/Book", "max_stars_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "regexp_answer_02.tex", "max_issues_repo_name": "rinderknecht/Book", "max_issues_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "regexp_answer_02.tex", "max_forks_repo_name": "rinderknecht/Book", "max_forks_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8448275862, "max_line_length": 73, "alphanum_fraction": 0.6420607459, "num_tokens": 855, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.4426903779305928}}
{"text": "\\documentclass[11pt,a4paper]{report}\r\n\\usepackage[margin=1in]{geometry}\r\n\r\n\\begin{document}\r\n\\pagestyle{empty}\r\n\\begin{center}\r\n\\Large{CHAPTER 2 SUMMARY. \\textbf{Motion in One Dimension}}\r\n\r\n\\large{Justin Yang}\r\n\r\nOctober 16, 2012\r\n\\end{center}\r\n\r\n\\textbf{Kinematics} Description of motion\r\n\r\n\\section*{Displacement, Velocity, and Speed}\r\n\r\nAn object moving from intial position $x_{i}$ to final position $x_{f}$ has \\textbf{displacement} $$\\Delta{x}=x_{f}-x_{i}.$$\r\n\r\n\\noindent\r\nThe \\textbf{average velocity} of the object is the ratio of the displacement to the time it takes for the displacement $\\Delta{t}=t_{f}-t_{i}$,\r\n$$v_{av}=\\frac{\\Delta{x}}{\\Delta{t}}.$$\r\n\r\n\\noindent\r\nThe \\textbf{average speed} of the object is the ratio of the distance traveled to the time it takes, $$\\bar{v}=\\frac{\\Delta{s}}{\\Delta{t}}.$$\r\n\r\n\\noindent\r\nThe average velocity and the average speed of an object are very different.\r\n\r\n\\noindent\r\n\\textit{Geometric Interpretation}: The average velocity is the slope of the straight line connecting the points $\\left(t_{1}, x_{1}\\right)$ and $\\left(t_{2}, x_{2}\\right)$ in the $x$-versus-$t$ plot.\r\n\r\n\\noindent\r\n\\textbf{Instantaneous velocity} is defined as $$v\\left(t\\right)=\\lim_{\\Delta{t} \\to 0} \\frac{\\Delta{x}}{\\Delta{t}}.$$\r\n\r\n\\noindent\r\nThe \\textbf{instantaneous speed} is the magnitude of the instantaneous velocity.\r\n\r\n\\section*{Acceleration}\r\n\r\nThe rate of change of the instantaneous velocity with respect to time.\r\n\r\nThe \\textbf{average acceleration} of an object is the ratio of the \\textit{change} in velocity to the time it takes for the change $\\Delta{t}=t_{f}-t_{i}$, $$a_{av}=\\frac{\\Delta{v}}{\\Delta{t}}.$$\r\n\r\nThe \\textbf{instantaneous acceleration} is the slope of the line tangent to the $v$-versus-$t$ curve. $$a=\\lim_{\\Delta{t} \\to 0} \\frac{\\Delta{v}}{\\Delta{t}}.$$\r\n\r\n\\subsection*{Motion with Constant Acceleration}\r\n\r\nThe motion of a particle that has constant acceleration is common in nature. When air resistance is negligeble, the free fall of an object near Earth's surface has acceleration $g=9.81 m/s^{2}$, which Galileo was the first to conclude.\r\n\r\n\\noindent\r\nWe can use the ``Big Five'' under constant acceleration:\r\n$$v=v_{0}+at$$\r\n$$\\Delta{x}=v_{0}t+\\frac{1}{2}at^{2}$$\r\n$$v^{2}-v^{2}_{0}=2a\\Delta{x}$$\r\n$$\\Delta{x}=\\frac{1}{2}\\left(v_{0}+v\\right)t$$\r\n$$\\Delta{x}=vt-\\frac{1}{2}at^{2}$$\r\n\\end{document}", "meta": {"hexsha": "5e1ea97422507e53c675bb06c44ed353657c40c9", "size": 2364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/Ch2Summary.tex", "max_stars_repo_name": "justinyangusa/physics", "max_stars_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-11T07:10:09.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-11T07:10:09.000Z", "max_issues_repo_path": "notes/Ch2Summary.tex", "max_issues_repo_name": "justinyangusa/physics", "max_issues_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/Ch2Summary.tex", "max_forks_repo_name": "justinyangusa/physics", "max_forks_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.7586206897, "max_line_length": 236, "alphanum_fraction": 0.6971235195, "num_tokens": 725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6187804337438502, "lm_q1q2_score": 0.44269037042165604}}
{"text": "%% \\section{Co-occurrence Modeling}\n%% \\label{sec:code}\n\n\\appendix\n%% %%\\appendixsection{Algorithm}\n%% %%\\label{sec:algorithm}\n%% %% [!! remove this part]\n%% %% In this section, we briefly describe the components of our algorithm.\n%% %% Section~\\ref{sec:subcomp} presents the motive and the method for\n%% %% computation of substitute vectors, our paradigmatic representations\n%% %% for the word contexts.  We combine the substitute vectors with the\n%% %% identity and features of the target word for part of speech induction\n%% %% using the a co-occurrence modeling framework.\n%% \n%% \\appendixsection{Computation of Substitute Distributions}\n%% \\label{app:subcomp}\n%% \n%% In this study, we predict the syntactic category of a word in a given\n%% context based on its substitute distribution.  The sample space of the\n%% substitute distribution is the vocabulary of the language model\n%% including the unknown word tag \\unk.  Note that the substitute\n%% distribution is a function of the context only and is indifferent to\n%% the target word.\n%% \n%% %% The dimensions of the\n%% %% substitute distribution represent words in the vocabulary of the\n%% %% language model, and the entries in the substitute distribution\n%% %% represent the probability of those words being used in the given\n%% %% context.  \n%% \n%% % how are the substitutes computed\n%% It is best to use both the left and the right context when estimating\n%% the probabilities for potential lexical substitutes.  For example, in\n%% \\emph{``He lived in San Francisco suburbs.''}, the instance \\emph{San}\n%% would be difficult to guess from the left context but it is almost\n%% certain looking at the right context.  We define $c_w$ as the $2n-1$\n%% word window centered around the target word position: $w_{-n+1} \\ldots\n%% w_0 \\ldots w_{n-1}$ ($n=4$ is the n-gram order we have used).  The\n%% probability of a substitute word $w$ in a given context $c_w$ can be\n%% estimated as:\n%% \\begin{eqnarray}\n%%   \\label{eq:lm1}P(w_0 = w | c_w) & \\propto & P(w_{-n+1}\\ldots w_0\\ldots w_{n-1})\\\\\n%%   \\label{eq:lm2}& = & P(w_{-n+1})P(w_{-n+2}|w_{-n+1})\\nonumber\\\\\n%%   &&\\ldots P(w_{n-1}|w_{-n+1}^{n-2})\\\\\n%%   \\label{eq:lm3}& \\approx & P(w_0| w_{-n+1}^{-1})P(w_{1}|w_{-n+2}^0)\\nonumber\\\\\n%%   &&\\ldots P(w_{n-1}|w_0^{n-2})\n%% \\end{eqnarray}\n%% where $w_i^j$ represents the sequence of words $w_i w_{i+1} \\ldots\n%% w_{j}$.  In Equation \\ref{eq:lm1}, $P(w|c_w)$ is proportional to\n%% $P(w_{-n+1}\\ldots w_0 \\ldots w_{n-1})$ because the words of the\n%% context are fixed.  Terms without $w_0$ are identical for each\n%% substitute in Equation \\ref{eq:lm2} therefore they have been dropped\n%% in Equation \\ref{eq:lm3}.  Finally, because of the Markov property of\n%% n-gram language model, only the closest $n-1$ words are used in the\n%% experiments.\n%% \n%% Near the sentence boundaries the appropriate terms were truncated in\n%% Equation \\ref{eq:lm3}.  Specifically, at the beginning of the sentence\n%% shorter n-gram contexts were used and at the end of the sentence terms\n%% beyond the end-of-sentence instance were dropped.\n%% \n%% To obtain a discrete representation of the context, the\n%% random-substitutes algorithm pairs each word instance with a substitute\n%% sampled from the pre-computed substitute distribution generated from\n%% the word instance's context and then word ($W$) -- random-substitute\n%% ($S$) pairs are fed to the S-CODE algotihm as input.\n%% \n%% \\appendixsection{The CODE and S-CODE Models}\n%%  \\label{app:codethr}\n%%  {\\bf This section will be remoded after Dyuret's tuple sampling comments}\n%% In this section we review the unsupervised method that we use to model\n%% co-occurrence statistics: the Co-occurrence Data Embedding (CODE)\\\n%% \\cite{globerson2007euclidean} method and its spherical extension (S-CODE)\n%% introduced by \\cite{maron2010sphere}.\n%% \n%% Let $W$ and $C$ be two categorical variables with finite cardinalities\n%% $|W|$ and $|C|$.  We observe a set of pairs $\\{w_i, c_i\\}_{i=1}^n$\n%% drawn IID from the joint distribution of $W$ and $C$.  The basic idea\n%% behind CODE and related methods is to represent (embed) each value of\n%% $W$ and each value of $C$ as points in a common Euclidean space\n%% $\\mathbf{R}^d$ such that values that frequently co-occur lie close to\n%% each other.  There are several ways to formalize the relationship\n%% between the distances and co-occurrence statistics, in this paper we\n%% use the following:\n%% \\begin{equation} \\label{eq:probability}\n%% p(w,c) = \\frac{1}{Z} \\bar{p}(w) \\bar{p}(c) e^{-d^2_{w,c}}\n%% \\end{equation}\n%% \\noindent where $d^2_{w,c}$ is the squared distance between the\n%% embeddings of $w$ and $c$, $\\bar{p}(w)$ and $\\bar{p}(c)$ are empirical\n%% probabilities, and $Z=\\sum_{w,c} \\bar{p}(w) \\bar{p}(c) e^{-d^2_{w,c}}$\n%% is a normalization term.  If we use the notation $\\phi_w$ for the\n%% point corresponding to $w$ and $\\psi_c$ for the point corresponding to\n%% $c$ then $d^2_{w,c} = \\|\\phi_w-\\psi_c\\|^2$.  The log-likelihood of a\n%% given embedding $\\ell(\\phi, \\psi)$ can be expressed as:\n%% \\begin{eqnarray}\n%% &&\\ell(\\phi, \\psi) = \\sum_{w,c} \\bar{p}(w,c) \\log p(w,c) \\label{eq:likelihood} \\\\\n%% &&= \\sum_{w,c} \\bar{p}(w,c) (-\\log Z + \\log \\bar{p}(w)\\bar{p}(c) - d^2_{w,c}) \\nonumber \\\\\n%% &&= -\\log Z + \\mathit{const} - \\sum_{w,c} \\bar{p}(w,c) d^2_{w,c} \\nonumber\n%% \\end{eqnarray}\n%% The likelihood is not convex in $\\phi$ and $\\psi$.  We use gradient\n%% ascent to find an approximate solution for a set of $\\phi_w$, $\\psi_c$\n%% that maximize the likelihood.  The gradient of the $d^2_{w,c}$ term\n%% pulls neighbors closer in proportion to the empirical joint\n%% probability:\n%% \\begin{equation}\n%% \\frac{\\partial}{\\partial\\phi_w} \\sum_{w,c} -\\bar{p}(w,c) d^2_{w,c} =\n%% \\sum_y 2 \\bar{p}(w,c) (\\psi_c - \\phi_w) \\label{eq:attract}\n%% \\end{equation}\n%% The gradient of the $Z$ term pushes neighbors apart in proportion to the\n%% estimated joint probability:\n%% \\begin{equation}\n%% \\frac{\\partial}{\\partial\\phi_x} (-\\log Z) = \\sum_y 2 p(w,c) (\\phi_w -\n%% \\psi_c) \\label{eq:repulse}\n%% \\end{equation}\n%% Thus the net effect is to pull pairs together if their estimated\n%% probability is less than the empirical probability and to push them\n%% apart otherwise.  The gradients with respect to $\\psi_c$ are similar.\n%% S-CODE \\cite{maron2010sphere} additionally restricts all $\\phi_w$ and\n%% $\\psi_c$ to lie on the unit sphere.  With this restriction, $Z$ stays\n%% around a fixed value during gradient ascent.  This allows S-CODE to\n%% substitute an approximate constant $\\tilde{Z}$ in gradient\n%% calculations for the real $Z$ for computational efficiency.  In our\n%% experiments, we used S-CODE with its sampling based stochastic\n%% gradient ascent algorithm and smoothly decreasing learning rate.\n%%  \n\\appendixsection{S-CODE with More than Two Variables}\n\\label{app:multiscode}\nIn this section we modify the S-CODE model to handle more than two variables. \nLet $W$ and $F^{(i)}$, where $i=1\\ldots K$, be $K+1$ categorical\nvariables with finite cardinalities $|W|$ and $|F^{(i)}|$.  We observe a set of\ntuples $\\{w_j, f^{(1)}_j, \\hdots, f^{(K)}_j\\}_{j=1}^n$ drawn IID from the joint\ndistribution $\\bar{p}(w, f^{(1)}, \\hdots, f^{(K)})$, respectively.\nGloberson et.  al \\shortcite{globerson2007euclidean} suggest the following\nlikelihood function:\n\n\\begin{table}[ht]\n  \\footnotesize\n  \\begin{eqnarray}\n    \\ell(\\phi, \\psi^{(1)}, \\ldots, \\psi^{(K)}) =  \\label{eq:multicode}\n    \\sum_{i=1}^K \\sum_{w,f^{(i)}} \\bar{p}(w,f^{(i)}) \\log p(w,f^{(i)})\n  \\end{eqnarray}\n\\end{table}\n\\noindent where $\\bar{p}(w, f^{(i)})$ is the empirical joint distribution of\n$W$ with feature $F^{(i)}$ whose empirical joint distribution is known.  The\nlikelihood then represents a set of S-CODE models $p(w,f^{(i)})$ where each\n$F^{(i)}$ has an embedding $\\psi_f^{(i)}$ and all models share the same\n$\\phi_w$ embedding.\n\nWith this setup, the training procedure needs to change little: instead of\nsampling a word ($w$) -- context ($c$), the word ($w$) -- feature $f^{(1)}$ --\n$\\hdots$ -- $f^{(K)}$ tuple is sampled and input to the gradient ascent\nalgorithm.  The gradient search algorithm updates the embeddings according to\n$p(w,f^{(i)})$ and no updates are performed between any features since $w$ is\nthe only shared variable.\n\nTuples might have null values due to unobserved features.  For example in the\ncase of POS induction, the word ``\\textbf{car}'' has no morphological or\northographic features therefore all the elements of the tuple have null value\nexcept the word type ($w$) and the contextual feature ($f_1$).  We do not\nperform any pull or push updates on embeddings during the gradient search if\nthe corresponding $f^{(i)}$ is null.  In our setup $w$ and $f_1$ represents the\nword type and contextual feature therefore they are always observed.\n\n%% \\appendixsection{Language Statistics}\n%% \\label{app:language}\n%% This section explains the language model training and feature\n%% extraction of each language that we apply our model in\n%% Section~\\ref{sec:multilang}.  \n\n%% \\paragraph{Statictical Language Modeling}For all languages except\n%% Serbian, English and Turkish, we train the language models by using\n%% the corresponding Wikipedia dump files\\footnote{Latest Wikipedia dump\n%%   files are freely available at \\url{http://dumps.wikimedia.org/} and\n%%   the text in the dump files can be extracted using WP2TXT\n%%   (\\url{http://wp2txt.rubyforge.org/})}.  Serbian shares a common\n%% basis with Croatian and Bosnian therefore we trained 3 different\n%% language models using Wikipedia dump files of Serbian together with\n%% these two languages and measured the perplexities on the MULTEXT-East\n%% Serbian corpus.  We chose the Croatian language model since it\n%% achieved the lowest perplexity score and unknown word ratio on the\n%% MULTEXT-East Serbian corpus.  To train the statistical language model\n%% of English, we use Wall Street Journal data (1987-1994) extracted from\n%% CSR-III Text \\cite{csr3text} (excluding sections of the PTB) and for\n%% the Turkish language modeling we use the web corpus collected from\n%% Turkish news and blog sites \\cite{sak2008turkish}.  \n%% \n%% In order to reduce the unknown word ratio of resource poor languages\n%% and to standardize the process we set the vocabulary threshold to 2\n%% for all languages except English.  English has a relatively low\n%% unknown word ratio therefore we set the threshold to 20 instead of 2.\n%% Table~\\ref{tab:lmstatistics} summarizes the language model related\n%% statistics and scores that vary across the languages in terms of\n%% quality and quantity.\n\n%% \\paragraph{Feature extraction}Morphological features of each language\n%% are extracted using the training sections of the corresponding\n%% MULTEXT-East and CoNLL-X corpora.  We don't use the language model\n%% corpora to extract morphological features.  Number of morphological\n%% feature of each language is presented in Table~\\ref{tab:lmstatistics}.\n%% We use the same set of orthographic features described in\n%% Section~\\ref{sec:feat} except we add an ``Only-Punctuation'' feature\n%% to the languages of MULTEXT-East corpora.  The ``Only-Punctuation''\n%% feature is generated when a instance only consists of punctuation\n%% characters.\n%% \n%% \\input{datatable.tex}\n%% S-CODE handles two variables, whereas underlying syntactic categories\n%% can be captured by more than two different variables such as\n%% contextual, morphologic and ortographic features.  S-CODE can be\n%% extented to handle more than two variables in a way similar to the\n%% multi variable extension of CODE \\cite{globerson2007euclidean} with\n%% the unit sphere restriction.  The log-likelihood at\n%% Equation~\\ref{eq:likelihood} can be redefined for $n+1$ different\n%% categorical variables $X$, $Y_i$, $\\hdots$ and $Y_n$ with finite\n%% cardinalities $|X|$, $|Y_1|$, $\\hdots$ and $|Y_n|$, respectively, as:\n%% \\begin{eqnarray}\n%% &&\\ell(\\phi, \\psi_1,\\hdots,\\psi_n) = \\sum_{i=1}^n\\sum_{x,y_i} \\bar{p}(x,y_i) \\log p(x,y_i) \\label{eq:multiscode} \\\\\n%% &&= \\sum_{i=1}^n\\sum_{x,y_i} \\bar{p}(x,y_i) (-\\log Z_i + \\log \\bar{p}(x)\\bar{p}(y_i) - d^2_{x,y_i}) \\nonumber \\\\\n%% &&=-\\sum_{i=1}^n(\\log Z_i + \\mathit{const}_i - \\sum_{x,y_i} \\bar{p}(x,y_i) d^2_{x,y_i}) \\nonumber\n%% \\end{eqnarray}\n%% where $\\psi_i$ is the embedding of $y_i \\in Y_i$ and $Z_i$ is the\n%% normalization term of $p(x,y_i)$.  Thus the model is able to jointly\n%% learn the embeddings when the pairwise co-occurence statistics,\n%% $\\bar{p}(x,y_i)$, are available for all $i$.\n\n%% One problem with these setting is, not every $(x,y_i)$ pair is\n%% observed in the data.  For example, the stem word ``\\textbf{car}''\n%% doesn't have any morphological feature, thus its morphological feature\n%% is represented by a null value, ``X''.  However setting the unobserved\n%% features to ``X'' leads to pulling the words with unobserved features\n%% together even they are from different clusters or pushing the ones\n%% with observed features apart even they are from same clusters.  To\n%% solve this, during the gradient search we don't perform any pull or\n%% push updates on embeddings if the value of $y_i$ is set to null.\n", "meta": {"hexsha": "abbebcb3883bac7d14207c2d5492368b12790988", "size": 13108, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/coling2014/appendix.tex", "max_stars_repo_name": "ai-ku/upos_2014", "max_stars_repo_head_hexsha": "f4723cac53b4d550d2b0c613c9577eb247c7ff4a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-06-06T07:13:43.000Z", "max_stars_repo_stars_event_max_datetime": "2015-06-06T07:13:43.000Z", "max_issues_repo_path": "papers/coling2014/appendix.tex", "max_issues_repo_name": "ai-ku/upos_2014", "max_issues_repo_head_hexsha": "f4723cac53b4d550d2b0c613c9577eb247c7ff4a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/coling2014/appendix.tex", "max_forks_repo_name": "ai-ku/upos_2014", "max_forks_repo_head_hexsha": "f4723cac53b4d550d2b0c613c9577eb247c7ff4a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.7787234043, "max_line_length": 118, "alphanum_fraction": 0.7110924626, "num_tokens": 3814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.44269037042165593}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{latexsym}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{graphicx}\n\\usepackage{lipsum}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{cases}\n\\usepackage{url}\n\\usepackage{cite}\n\\usepackage{bookmark}\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{minted}\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{minted}\n\\usepackage{float}\n\\usepackage{hyperref}\n\\usepackage{subfig}\n\\usepackage[margin=1in]{geometry}\n\\usepackage[export]{adjustbox}\n\\begin{document}\n\\begin{titlepage}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=1\\textwidth]{InnoLogo.png}\n%\\caption*{}\n\\label{fig:entropy} \n\\end{figure}\n\n\\vspace{1.5in}\n\n\\centering\n\\Huge{\\textbf{Computational Intelligence\\\\ Bonus Task}}\\\\[2.0in]\n\n\\LARGE{\\textbf{Mostafa Hegazy}}\\\\[0.2in]\n\n\\normalsize{\\textbf{MS1-Robotics}}\\\\[0.2in]\n\n\\large{\\textbf{2021}}\n\\end{titlepage}\n\\newpage\n\n\\setlength\\parindent{0pt}\n%\\maketitle\n\\begin{Large}\n\\section{Task}\n\n\\begin{align*}\n    \\min_x \\max_y || x - x^* || \\\\\n\\end{align*}\nSubject to\n\\begin{align}\n   (y-a)^T D (x-b) + s^T y + q^T x \\leq h \\\\\n   ||Hy+f|| \\leq p\n\\end{align}\nLet's introduce a change of variables:\n\\begin{align}\n    v &= H y + f \\\\ \n    y &= H^{-1}(v-f)\n\\end{align}\nSubstitute (4) in (2):\n\\begin{align}\n    ||v|| \\leq p \n\\end{align}\nSubstitute (4) in (1):\n\\begin{align}\n    ( H^{-1}(v-f)-a)^T D (x-b) + s^T  H^{-1}(v-f) + q^T x \\leq h \\\\\n    (v-f)^T H^{-T} D (x-b) - a^T D (x-b) + s^T H^{-1}(v-f) + q^T x \\leq h\n\\end{align}\nExpanding the terms:\n\\begin{align}\n    v^T H^{-T} D (x-b) -f^T H^{-T} D (x-b) - a^T D (x-b) \\\\+ s^T H^{-1}v - s^T H^{-1} f + q^T x \\leq h\n\\end{align}\nUsing the vector operations:\n\\begin{align}\n    s^T H^{-1}v = v^T H^{-T} s \\\\\n    s^T H^{-1} f = f^T H^{-T} s\n\\end{align}\nsubstituting equations (10) and (11) back in (8):\n\\begin{align}\n    v^T H^{-T} D (x-b) -f^T H^{-T} D (x-b) - a^T D (x-b) \\\\+ v^T H^{-T} s - f^T H^{-T} s + q^T x \\leq h\n\\end{align}\nTaking common factors:\n\\begin{align}\n    v^T H^{-T} (D (x-b) +s) - f^T H^{-T} (D (x-b)+s) - a^T D (x-b) + q^T x \\leq h\n\\end{align}\n\n\n\\pagebreak\nNow we can define the worst case scenario:\n\nIt happens when $v$ is aligned with $ H^{-T} (D (x-b) +s)$ and has a length of $p$\n\n\\begin{align}\n    v = \\frac{H^{-T} (D (x-b) +s)}{||H^{-T} (D (x-b) +s)||} * p\n\\end{align}\n\nsubstituting (15) in (14) leads to:\n\n\\begin{align}\n    p \\,||H^{-T} (D (x-b) +s)|| - f^T H^{-T} (D (x-b)+s) - a^T D (x-b)+ q^T x  \\leq h\n\\end{align}\n\nSo our optimization problem becomes:\n\\begin{align*}\n    \\min_x || x - x^* || \\\\\n\\end{align*}\nSubject to\n\\begin{align*}\n        ||H^{-T} (D (x-b) +s)|| \\leq (h + f^T H^{-T} (D (x-b)+s)+ a^T D (x-b)- q^T x) \\frac{1}{p}\n\\end{align*}\n\\end{Large}\n\\end{document}\n", "meta": {"hexsha": "97d221f904da2b4f8e5c1691660bd3bb49ad76ef", "size": 2802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/MinMax bonus Task/main.tex", "max_stars_repo_name": "SergeiSa/Computational-Intelligence-Slides-Spring-2021", "max_stars_repo_head_hexsha": "017ab73a2ba442a6a604dd3dce7ba68c37790e26", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-19T17:29:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T08:01:27.000Z", "max_issues_repo_path": "Slides/MinMax bonus Task/main.tex", "max_issues_repo_name": "SergeiSa/Computational-Intelligence-Slides-Spring-2021", "max_issues_repo_head_hexsha": "017ab73a2ba442a6a604dd3dce7ba68c37790e26", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-05-27T09:02:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-13T09:36:55.000Z", "max_forks_repo_path": "Slides/MinMax bonus Task/main.tex", "max_forks_repo_name": "SergeiSa/Computational-Intelligence-Slides-Spring-2021", "max_forks_repo_head_hexsha": "017ab73a2ba442a6a604dd3dce7ba68c37790e26", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2021-01-20T07:58:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-12T08:28:08.000Z", "avg_line_length": 23.1570247934, "max_line_length": 103, "alphanum_fraction": 0.6002855103, "num_tokens": 1181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.4426903666671874}}
{"text": "\\section{Conclusion} % (fold)\n\\label{sec:conclusion}\nIn this work, we investigated the use of Markov Decision Processes\nto find the optimal solution to the \\textit{Snake and Ladder} game. \nOur results show that this game can indeed be model as a Markov process, \nthat the implementation of MDPs in this framework is simple,\nthat it leads to finding the optimal strategy and that this strategy\noutperforms to a large extend some simple heuristic strategies. \n\nAs a final note, we wanted to\nemphasize that this project not only allowed us to get some\ninsights on the theoretical and practical aspects of MDPs\nbut it also lead us to discover a new programming language, \\textsc{Julia},\nwhich both made us very enthusiastic as it is relatively new\nand rapidly growing in the scientific community.\n% section introduction (end)", "meta": {"hexsha": "cd27885a6a45541dee69a21926f051d50b90d390", "size": 821, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/src/conclusion.tex", "max_stars_repo_name": "qlete/markov-decision", "max_stars_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-03-21T13:48:00.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-21T13:48:00.000Z", "max_issues_repo_path": "report/src/conclusion.tex", "max_issues_repo_name": "qlete/markov-decision", "max_issues_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/src/conclusion.tex", "max_forks_repo_name": "qlete/markov-decision", "max_forks_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.3125, "max_line_length": 75, "alphanum_fraction": 0.8014616322, "num_tokens": 187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.44269036411711143}}
{"text": "%!TEX root = forallx-ubc.tex\n\\chapter{A formal semantics for QL}\n\\label{ch.QL.models}\n\nIn this chapter, we describe a \\emph{formal semantics} for QL. This corresponds to the discussion of interpretations and truth in SL given in Chapter \\ref{ch.SLmodels}. Like truth in SL, truth in QL is defined relative to a particular interpretation; entailment is a matter of truth in all interpretations. In SL, we emphasized the partial valuation functions provided by interpretations, limiting the domain to the atomic sentences involved in a given set of sentences. These corresponded to rows of the truth table. For example, a model \\script{I} might have provided these assignments:\n\n\\begin{displaymath}\n\\script{I} :\n\\left\\{\n\t\\begin{array}{ll}\n\tP = 0\\\\\n\tQ = 1\\\\\n\tR = 0\n\t\\end{array}\n\\right.\n\\end{displaymath}\n\nInterpretation \\script{I} settles the truth value of any SL sentence one can construct from $P$, $Q$, and $R$. All the elements of SL, beyond the atoms, were truth-functional. Because QL involves richer notions and a more complex vocabulary than SL, it requires correspondingly richer information from its models.\n\n\\section{Interpretations in QL}\n\nWhat is an interpretation in QL? Like a symbolization key for QL, an interpretation requires a universe of discourse, a schematic meaning for each of the predicates, and an object that is picked out by each constant. For example:\n\n\\begin{ekey}\n\\item[UD:] Marvel characters\n\\item[Hx:] $x$ is a hero.\n\\item[Sx:] $x$ has spider powers.\n\\item[m:] Miles Morales\n\\item[p:] Peter Parker\n\\item[r:] The Red Skull\n\\item[s:] Susan Storm\n\\item[u:] Ultimate Spider-Man\n\\end{ekey}\n\nThis interpretation is given in terms of English descriptions. To apply it, you need to know some details about the characters in question. For example, $Sm$ is true on this interpretation, because Miles Morales does have spider powers. But the interpretation itself doesn't tell us that --- to get that information from this way of setting out the interpretation, you need to know some details about what happens in the story. You need to know, for example, that Miles Morales, like his more famous mentor Peter Parker, also has spider powers. If you do know a bit about Marvel comics, you may know that Miles Morales is actually the Ultimate Spider-Man. So $u$ and $m$ in this interpretation are two different names for the same member of the UD. There is no rule against having multiple names for the same member. (We'll discuss this issue in much more detail in Chapter \\ref{ch.identity}.)\n\nWe want our QL models to encode this kind of information too. Like a good SL model, a QL model shouldn't require prior knowledge of comic books. One way we could try to do this would be to just give a truth value assignment, as we did for SL. The truth value assignment would assign 0 or 1 to each atomic wff: $Sm=1$, $Sp=1$, $Sr=0$, and so on. If we were to do that, however, we might just as well translate the sentences from QL to SL by replacing $Sp$ and $Sm$ with sentence letters. We could then rely on the definition of truth for SL, but at the cost of ignoring all the logical structure of predicates and terms. In writing a symbolization key for QL, we do not give separate definitions for $Sp$ and $Sm$. Instead, we give meanings to the components $S$, $p$, and $m$. This is essential because we want to be able to reflect the logical relationships between e.g.\\ $Sp$ and $\\exists x Sx$.\n\nOur interpretations should include explanations for predicates and names, not just for sentences. We cannot use a truth value assignment for this, because a predicate by itself (except a 0-place predicate) is neither true nor false. In the interpretation given above, $H$ is true \\emph{of} Peter Parker (i.e., $Hp$ is true), but it makes no sense at all to ask whether $H$ on its own is true. It would be like asking whether the English language fragment `$\\ldots$is a hero' is true.\n\nWhat does an interpretation do for a predicate, if it does not make it true or false? An interpretation helps to pick out the objects to which the predicate applies. Interpreting $Hx$ to mean `$x$ is a hero' picks out some characters as the things that are $H$s. Formally, this is a set of members of the UD to which the predicate applies; this set is called the \\define{extension} of the predicate.\n\nSome predicates have indefinitely large extensions. It would be impractical to try and write down all of the Marvel characters individually, so instead we use an English language expression to interpret the predicate. This is somewhat imprecise, because the interpretation alone does not tell you which members of the UD are in the extension of the predicate. In order to figure out whether a particular member of the UD is in the extension of the predicate (to figure out whether the Red Skull is a hero, for instance), you need to know about comic books. (As you might guess from his name, he's not.) In general, the extension of a predicate is the result of an interpretation \\emph{along with} some facts.\n\nSometimes it is possible to list all of the things that are in the extension of a predicate. Instead of writing a schematic English sentence, we can write down the extension as a set of things. Suppose we wanted to add a one-place predicate $F$ to the key above, meaning `$x$ is a founding member of the Fantastic Four', so we write the extension as a set of characters:\n\\begin{partialmodel}\n\t\\extension{F} & \\{Reed Richards, Susan Storm, Johnny Storm, Ben Grimm\\}\n\\end{partialmodel}\n\nYou do not need to know anything about comic books to be able to determine that, on this interpretation, $Fs$ is true: Susan Storm, whose name is given as $s$, is just specified to be one of the things that is $F$. Similarly, $\\exists x Fx$ is obviously true on this interpretation: There is at least one member of the UD that is an $F$ --- in fact, there are four of them.\n\nWhat about the sentence $\\forall x Fx$? The sentence is false, because it is not true that all members of the UD are $F$. It requires the barest minimum of knowledge about comic books to know that there are other characters besides just these four. Although we specified the extension of $F$ in a formally precise way, we still specified the UD with an English language description. Formally speaking, a UD is just a set of members.\n\nThe formal significance of a predicate is determined by its extension, but what should we say about constants like $m$ and $s$? The meaning of a constant determines which member of the UD is picked out by the constant. The individual that the constant picks out is called the \\define{referent} of the constant. Both $m$ and $u$ have the same referent, since they both refer to the same comic book character. You can think of a constant letter as a name and the referent as the thing named. In English, we can use the different names `Miles' and `Ultimate Spider-Man' to refer to the same comic book character. In this interpretation, we also use the different constants `$m$' and `$u$' to refer to the same member of the UD.\n\n\\section{Sets}\n\nWe use curly brackets `\\{' and `\\}' to denote sets. The members of the set can be listed in any order, separated by commas. This means that \\{foo, bar\\} and \\{bar, foo\\} are the same set.\n\nIt is possible to have a set with no members in it. This is called the \\define{empty set}. The empty set is sometimes written as \\{\\}, but usually it is written as the single symbol $\\emptyset$.\n\n\\section{Extensions of predicates}\nAs we have seen, an interpretation in QL is only formally significant insofar as it determines a UD, an extension for each predicate, and a referent for each constant. We call this formal structure a \\define{model} for QL.\n\nTo see how this works, consider this symbolization key:\n\\begin{ekey}\n\\item{UD:} The first ten natural numbers\n\\item{$Px$:} $x$ is prime.\n\\item{$n_{4}$}: 4\n\\end{ekey}\n\nGiven some basic mathematical knowledge, it is obvious that $Pn_{4}$ is false. Let's consider the model this key suggests, to show why it makes this wff false. Instead of just giving a description in the UD, we can list the members as a set. We also define the extension of the predicate $P$, and the referent of the constant $n_{4}$:\n\n\\begin{partialmodel}\n\tUD & $\\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\}$\\\\\n\t\\extension{P} & \\{2, 3, 5, 7\\}\\\\\n\t\\referent{n_{4}} & 4\n\\end{partialmodel}\n\nThis is not a full model for this interpretation, but it is a detailed enough partial model to show that $Pn_{4}$ is false. You do not need to know anything about mathematics to see that this sentence is false in this model. The UD member named by $n_{4}$ is not in the extension of $P$. In this way, the model captures all of the formal significance of the interpretation.\n\nSuppose we enrich this symbolization key with more predicates:\n\\label{10UD}\n\\begin{ekey}\n\\item{UD:} The first ten natural numbers\n\\item{$Ex$:} $x$ is even.\n\\item{$Nx$:} $x$ is negative.\n\\item{$Lxy$:} $x$ is less than $y$.\n\\item{$Txyz$:} $x$ times $y$ equals $z$.\n\\end{ekey}\nWhat do we need to add to the model for our new predicates?\n\nThe extension of $E$ in our model should be the subset $\\{2, 4, 6, 8, 10\\}$. There are no negative numbers in the UD, so $N$ has an empty extension; i.e. $\\extension{N}=\\emptyset$.\n\nSometimes it will be convenient to represent extensions graphically, similar to the way we did with truth tables. We can represent the extensions just described for $P$, $E$, and $N$ thus:\n\n\\begin{table}[h!]\n\\centering\n\\begin{tabular}{l|l|l|l}\n            & $P$ & $E$ & $N$ \\\\ \\hline\n\\textbf{1}  & 0  & 0          & 0          \\\\\n\\textbf{2}  & 1  & 1          & 0          \\\\\n\\textbf{3}  & 1  & 0          & 0          \\\\\n\\textbf{4}  & 0  & 1          & 0          \\\\\n\\textbf{5}  & 1  & 0          & 0          \\\\\n\\textbf{6}  & 0  & 1          & 0          \\\\\n\\textbf{7}  & 1  & 0          & 0          \\\\\n\\textbf{8}  & 0  & 1          & 0          \\\\\n\\textbf{9}  & 0  & 0          & 0          \\\\\n\\textbf{10} & 0 & 1          & 0         \n\\end{tabular}\n\\end{table}\n\nThe members of the UD are listed as rows; the one-place predicates are given as columns. The 0s and 1s indicate whether each member satisfies each predicate. Notice that the same information is conveyed in this chart as in the three sets of integers described above. Either is an acceptable way of indicating the extension of the predicates.\n\nThe extension of a two-place predicate like $L$ is more complicated. No individual number falls under the extension of this predicate; it is about the relation between members. Note also that sets of pairs of numbers aren't suitable for the extension of $L$ either, because 1 is less than 8, but 8 is not less than 1. (Remember, the set \\{1,8\\} is the very same set as the set \\{8,1\\}.) The solution is to have the extension of $L$ consist in a set of \\define{ordered pairs} of numbers. An ordered pair is like a set with two members, except that the order \\emph{does} matter. We write ordered pairs with angle brackets `$\\openntuple$' and `$\\closentuple$'. The ordered pair \\mbox{\\ntuple{foo, bar}} is different than the ordered pair \\mbox{\\ntuple{bar, foo}}. The extension of $L$ is a set of ordered pairs --- all of the pairs of numbers in the UD such that the first number is less than the second. Writing this out completely:\n\n\n$\\extension{L}=$ \\{\\ntuple{1, 2}, \\ntuple{1, 3}, \\ntuple{1, 4}, \\ntuple{1, 5}, \\ntuple{1, 6}, \\ntuple{1, 7}, \\ntuple{1, 8}, \\ntuple{1, 9}, \\ntuple{1, 10},\n\\ntuple{2, 3}, \\ntuple{2, 4}, \\ntuple{2, 5}, \\ntuple{2, 6}, \\ntuple{2, 7}, \\ntuple{2, 8}, \\ntuple{2, 9}, \\ntuple{2, 10},\n\\ntuple{3, 4}, \\ntuple{3, 5}, \\ntuple{3, 6}, \\ntuple{3, 7}, \\ntuple{3, 8}, \\ntuple{3, 9}, \\ntuple{3, 10},\n\\ntuple{4, 5}, \\ntuple{4, 6}, \\ntuple{4, 7}, \\ntuple{4, 8}, \\ntuple{4, 9}, \\ntuple{4, 10},\n\\ntuple{5, 6}, \\ntuple{5, 7}, \\ntuple{5, 8}, \\ntuple{5, 9}, \\ntuple{5, 10},\n\\ntuple{6, 7}, \\ntuple{6, 8}, \\ntuple{6, 9}, \\ntuple{6, 10}, \n\\ntuple{7, 8}, \\ntuple{7, 9}, \\ntuple{7, 10},\n\\ntuple{8, 9}, \\ntuple{8, 10}\n\\ntuple{9, 10}%\n\\}\n\nFormally, the extension of a two-place predicate is a set of ordered pairs. Sometimes we will find it easier to represent extensions in a chart, with the two variable positions represented on the two axes. For example, the extension above could be expressed via a table like the one below. The `0' in the first cell of the table says that \\ntuple{1, 1} is not in the extension of $L$; the next cell in the first row says that \\ntuple{1, 2} is. Etc. Sometimes drawing out a chart like this will be the easiest way to represent models for the extensions of two-place predicates.\n\n\n\\begin{table}[h!]\n\\centering\n\\begin{tabular}{l|llllllllll}\n$Lxy$         & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5} & \\textbf{6} & \\textbf{7} & \\textbf{8} & \\textbf{9} & \\textbf{10} \\\\ \\hline\n\\textbf{1}  & 0          & 1          & 1          & 1          & 1          & 1          & 1          & 1          & 1          & 1           \\\\\n\\textbf{2}  & 0          & 0          & 1          & 1          & 1          & 1          & 1          & 1          & 1          & 1           \\\\\n\\textbf{3}  & 0          & 0          & 0          & 1          & 1          & 1          & 1          & 1          & 1          & 1           \\\\\n\\textbf{4}  & 0          & 0          & 0          & 0          & 1          & 1          & 1          & 1          & 1          & 1           \\\\\n\\textbf{5}  & 0          & 0          & 0          & 0          & 0          & 1          & 1          & 1          & 1          & 1           \\\\\n\\textbf{6}  & 0          & 0          & 0          & 0          & 0          & 0          & 1          & 1          & 1          & 1           \\\\\n\\textbf{7}  & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 1          & 1          & 1           \\\\\n\\textbf{8}  & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 1          & 1           \\\\\n\\textbf{9}  & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 1           \\\\\n\\textbf{10} & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          & 0          \n\\end{tabular}\n\\end{table}\n\n\nThe extension of a three-place predicate is a set of ordered triples where the predicate is true of those three things \\emph{in that order}. So the extension of $T$ in this model will contain ordered triples like \\ntuple{2, 4, 8}, because $2\\times 4 = 8$. Because the surface of a sheet of paper is for all intents and purposes two-dimensional, it is usually not convenient to represent 3-or-more place predicates with tables.\n\nGenerally, the extension of an $n$-place predicate is a set of ordered $n$-tuples ${\\langle}a_1, a_2,\\ldots, a_n{\\rangle}$ such that $a_1$--$a_n$ are members of the UD and the predicate is true of $a_1$--$a_n$ in that order.\n\n\n\\section{Extensions of 0-place predicates}\n\\label{sec.0PlaceModels}\n\nWhat of a 0-place predicate? Recall from Chapter \\ref{ch.QL} that a 0-place predicate corresponds to an SL sentence letter --- it will take a truth value in an interpretation without reference to any particular objects. So a QL model will provide truth values to 0-place predicates directly, just like an SL valuation function did.\n\nThis actually follows from the general description of $n$-place predicates given in the previous section: the extension of an $n$-place predicate is a set of ordered $n$-tuples. In the special case where $n=0$, the extension of the predicate will be a set of 0-tuples. But there is only one possible 0-tuple: the empty set, $\\emptyset$. So there are only two possible extensions of a 0-place predicate, corresponding to the choice of whether $\\emptyset$ is included in the extension or not. (Formally, the extension will either be the set containing the empty set --- \\{$\\emptyset$\\} --- or it will be the empty set $\\emptyset$ itself.)\n\nFor clarity and convenience, when indicating the extension of 0-place predicates in QL models, we'll simply indicate the truth values for the sentences themselves, like we did in SL. So we might indicate the extensions of 0-place predicates, for instance, by writing\n\n\\begin{ekey}\n\\item{$P$} = 1\n\\item{$Q$} = 0\n\\end{ekey}\n\ninstead of the more confusing\n\n\\begin{partialmodel}\n\t\\extension{P} & \\{$\\emptyset$\\}\\\\\n\t\\extension{Q} & $\\emptyset$. \\\\\n\\end{partialmodel}\n\nSo in the special case where we are \\emph{only} working with 0-place predicates, QL models directly provide SL valuation functions. This is another respect in which QL is simply a generalization of SL. If you ignore the UD and the extensions of higher-place predicates, a QL model provides the same information we were using to discuss SL models in Chapter \\ref{ch.SLmodels}.\n\n\\section{Working with models}\n\\label{sec.UsingModels}\n\n\nWe will use the double turnstile symbol for QL much as we did for SL. `$\\metaA{}\\models\\metaB{}$' means that `\\metaA{} entails \\metaB{}': When \\metaA{} and \\metaB{} are two sentences of QL, $\\metaA{}\\models\\metaB{}$ means that there is no model in which \\metaA{} is true and \\metaB{} is false. $\\models\\metaA{}$ is shorthand for $\\emptyset\\models\\metaA{}$, which means that \\metaA{} is true in every model. This allows us to give definitions for various concepts in QL. In fact, we can use the same definitions offered in Chapter \\ref{ch.SLmodels}.\n\n\\begin{quote}\nA \\define{tautology in QL} is a sentence \\metaA{} that is true in every model; i.e.,  $\\models\\metaA{}$.\n\nA \\define{contradiction in QL} is a sentence \\metaA{} that is false in every model; i.e., $\\models\\enot\\metaA{}$.\n\nA sentence is \\define{contingent in QL} if and only if it is neither a tautology nor a contradiction.\n\nAn argument `` $\\script{P}_1, \\script{P}_2, \\cdots$, \\therefore\\ \\metaC{} '' is \\define{valid in QL} if and only if there is no model in which all of the premises are true and the conclusion is false; i.e., $\\{\\script{P}_1,\\script{P}_2,\\cdots\\}\\models\\metaC{}$. It is \\define{invalid in QL} otherwise.\n\nTwo sentences \\metaA{} and \\metaB{} are \\define{logically equivalent in QL} if and only if both $\\metaA{}\\models\\metaB{}$ and $\\metaB{}\\models\\metaA{}$.\n\nThe set $\\{\\metaA{}_1,\\metaA{}_2,\\metaA{}_3,\\cdots\\}$ is \\define{consistent in QL} if and only if there is at least one model in which all of the sentences are true. The set is \\define{inconsistent in QL} if and only if there is no such model.\n\n\\end{quote}\n\n\n\\section{Constructing models}\n\nSuppose we want to show that $\\forall xAxx \\eif Bd$ is \\emph{not} a tautology. This requires showing that the sentence is not true in every model. If we can provide an example of a model in which the sentence is false, then we will have shown that the sentence is not a tautology.\n\nWhat would such a model look like? In order for $\\forall xAxx \\eif Bd$ to be false, the antecedent ($\\forall x Axx$) must be true, and the consequent ($Bd$) must be false.\n\nTo construct such a model, we start with a UD. It will be easier to specify extensions for predicates if we have a small UD, so start with a UD that has just one member. Formally, this single member might be anything. Let's say it is Miles Morales.\n\nWe want $\\forall x Axx$ to be true, so we want all members of the UD to be paired with themself in the extension of $A$; this means that the extension of $A$ must be \\{\\ntuple{Miles Morales, Miles Morales}\\}.\n\nWe want $Bd$ to be false, so the referent of $d$ must not be in the extension of $B$. We give $B$ an empty extension.\n\nSince Miles is the only member of the UD, it must be the referent of $d$. The model we have constructed looks like this:\n\\begin{partialmodel}\n\tUD\t\t\t& \\{Miles Morales\\}\\\\\n\t\\extension{A} \t& \\{\\ntuple{Miles Morales, Miles Morales}\\}\\\\\n\t\\extension{B}\t& $\\emptyset$\\\\\n\t\\referent{d}\t& Miles Morales\n\\end{partialmodel}\n\nStrictly speaking, a model specifies an extension for \\emph{every} predicate of QL and a referent for \\emph{every} constant. As such, it is generally impossible to write down a complete model. That would require writing down infinitely many extensions and infinitely many referents. However, we do not need to consider every predicate in order to show that there are models in which $\\forall xAxx \\eif Bd$ is false. Predicates like $H$ and constants like $f_{13}$ make no difference to the truth or falsity of this sentence. It is enough to specify extensions for $A$ and $B$ and a referent for $d$, as we have done. This provides a \\emph{partial model} in which the sentence is false.\n\nPerhaps you are wondering: What does the predicate $A$ mean in English? It doesn't really matter. For formal purposes, the existence of models like the ones described above are enough to show that $\\forall x Axx \\eif Bd$ is not a tautology. But we can offer an interpretation in English if we like. How about this one?\n\n\\begin{ekey}\n\\item[UD:] Miles Morales\n\\item[$Axy$:] $x$ knows $y$'s biggest secret.\n\\item[$Bx$:] $x$'s powers derive from gamma radiation.\n\\item[$d$:] Miles Morales\n\\end{ekey}\n\nThis is one way we can interpret the model above. $Add$ is true, because Miles does know Miles's biggest secret. (It's that he's the Ultimate Spider-Man. Now you know it too!) $Bd$ is false: Miles's powers came from a genetically enhanced spider, not from gamma radiation. But the partial model constructed above includes none of these interpretative details. All it says is that $A$ is a predicate which is true of Miles and Miles, and that $B$ is a predicate which does not apply to Miles. There are indefinitely many predicates in English that have this extension. $Axy$ might instead translate `$x$ is the same size as $y$' or `$x$ and $y$ live in the same city'; $Bx$ might  translate `$x$ is a billionaire' or `$x$'s uncle was killed by a robber' or `Donald Trump has written a tweet about $x$'. In constructing a model and giving extensions for $A$ and $B$, we do not specify what English predicates $A$ and $B$ should be used to translate. We are concerned with whether the $\\forall xAxx \\eif Bd$ comes out true or false, and all that matters for truth and falsity in QL is the information in the model: the UD, the extensions of predicates, and the referents of constants.\n\nWe can just as easily show that $\\forall xAxx \\eif Bd$ is not a contradiction. We need only specify a model in which $\\forall xAxx \\eif Bd$ is true; i.e., a model in which either $\\forall x Axx$ is false or $Bd$ is true. Here is one such partial model:\n\n\\begin{partialmodel}\n\tUD\t\t\t& \\{The Red Skull\\}\\\\\n\t\\extension{A} \t& \\{\\ntuple{The Red Skull, The Red Skull}\\}\\\\\n\t\\extension{B}\t& \\{The Red Skull\\}\\\\\n\t\\referent{d}\t& The Red Skull\n\\end{partialmodel}\n\nI've switched our object from Miles Morales to The Red Skull to emphasize that it doesn't matter what object you pick. (Changing the examples all back to Miles would make no difference.) On this model, $\\forall xAxx \\eif Bd$ is true, because it is a conditional with a true consequent (as well as a true antecedent). We have now shown that $\\forall xAxx \\eif Bd$ is neither a tautology nor a contradiction. By the definition of `contingent in QL,' this means that \n$\\forall xAxx \\eif Bd$ is contingent. In general, showing that a sentence is contingent will require two models: one in which the sentence is true and another in which the sentence is false.\n\nSuppose we want to show that $\\forall x Sx$ and $\\exists x Sx$ are not logically equivalent. We need to construct a model in which the two sentences have different truth values; we want one of them to be true and the other to be false. We start by specifying a UD. Again, we make the UD reasonably small so that we can specify extensions easily. But this time we will need at least two members. If we only had one member of the domain, we wouldn't be able to illustrate the difference between \\emph{all} and \\emph{some}. Let's let our UD be \\{The Red Skull, Miles Morales\\}.\n\nWe can make $\\exists x Sx$ true by including something in the extension of $S$, and we can make $\\forall x Sx$ false by leaving something out of the extension of $S$. It does not matter which one we include and which one we leave out. Making Miles the only $S$, we get a partial model that looks like this:\n\\begin{partialmodel}\n\tUD\t\t\t& \\{Miles, The Red Skull\\}\\\\\n\t\\extension{S}\t& \\{Miles\\}\n\\end{partialmodel}\nThis partial model shows that the two sentences are \\emph{not} logically equivalent. $\\exists x Sx$ is assigned 1 on this model, but $\\forall x Sx$ is assigned 0.\n\nBack on p.~\\pageref{surgeon3correct}, we said that this argument would be invalid in QL:\n\\begin{earg}\n\\item[] $(Rc \\eand K_1c) \\eand Tc$\n\\item[\\therefore] $Tc \\eand K_2c$\n\\end{earg}\nNow we can prove that this is so. To show that this argument is invalid, we need to show that there is some model in which the premise is true and the conclusion is false. We can construct such a model deliberately. Here is one way to do it:\n\\begin{partialmodel}\n\tUD\t\t\t& \\{Reed Richards\\}\\\\\n\t\\extension{T}\t& \\{Reed Richards\\}\\\\\n\t\\extension{K_1}\t& \\{Reed Richards\\}\\\\\n\t\\extension{K_2}\t& $\\emptyset$\\\\\n\t\\extension{R}\t& \\{Reed Richards\\}\\\\\n\t\\referent{c}\t& Reed Richards\n\\end{partialmodel}\n\nSimilarly, we can show that a set of sentences is consistent by constructing a model in which all of the sentences are true.\n\n\n\n\n\\begin{table}[t]\n\\caption{It is relatively easy to answer a question if you can do it by constructing a model or two. It is much harder if you need to reason about all possible models. This table shows when constructing models is enough.}\n\\label{table.ModelOrArgument}\n\\begin{center}\n\\begin{tabular*}{\\textwidth}[t]{p{10em}p{10em}p{10em}}\n& {\\centerline{YES}} & {\\centerline{NO}}\\\\\n\\cline{3-3}\n\nIs \\metaA{} a tautology? & {show that \\metaA{} must be true in any model} & \\tablefbox{\\emph{construct a model} in which \\metaA{} is false}\\\\\n\\cline{3-3}\n\nIs \\metaA{} a contradiction? &  {show that \\metaA{} must be false in any model} & \\tablefbox{\\emph{construct a model} in which \\metaA{} is true}\\\\\n\\cline{2-3}\n\nIs \\metaA{} contingent? & \\tablefbox{\\emph{construct two models}, one in which \\metaA{} is true and another in which \\metaA{} is false}\\vline & {either show that \\metaA{} is a tautology or show that \\metaA{} is a contradiction}\\\\\n\\cline{2-3}\n\nAre \\metaA{} and \\metaB{} equivalent? & {show that \\metaA{} and \\metaB{} must have the same truth value in any model} & \\tablefbox{\\emph{construct a model} in which \\metaA{} and \\metaB{} have different truth values}\\\\\n\\cline{2-3}\n\nIs the set \\model{A} consistent? & \\tablefbox{\\emph{construct a model} in which all the sentences in \\model{A} are true} & {show that the sentences in \\model{A} could not all be true in any model}\\\\\n\\cline{2-3}\n\nIs the argument \\mbox{`\\script{P}, \\therefore\\ \\metaC{}'} valid? & {show that any model in which \\script{P} is true must be a model in which \\metaC{} is true} & \\tablefbox{\\emph{construct a model} in which \\script{P} is true and \\metaC{} is false}\\\\\n\\cline{3-3}\n\\end{tabular*}\n\\end{center}\n\\end{table}\n\n\n\n\n\n\n\\section{Reasoning about all models}\n\\label{sec.allmodelreasoning}\nWe can show that a sentence is \\emph{not} a tautology just by providing one carefully specified model: a model in which the sentence is false. To show that something is a tautology, on the other hand, it would not be enough to construct ten, one hundred, or even a thousand models in which the sentence is true. It is only a tautology if it is true in \\emph{every} model, and there are infinitely many models. This cannot be avoided just by constructing partial models, because there are infinitely many partial models.\n\nConsider, for example, the sentence $Raa\\eiff Raa$. There are two logically distinct partial models of this sentence that have a 1-member UD. There are 32 distinct partial models that have a 2-member UD. There are 1526 distinct partial models that have a 3-member UD. There are 262,144 distinct partial models that have a 4-member UD. And so on to infinity. In order to show that this sentence is a tautology, we need to show something about all of these models. There is no hope of doing so by dealing with them one at a time.\n\nNevertheless, $Raa\\eiff Raa$ is obviously a tautology. We can prove it with a simple argument:\n\\begin{quote}\n\\label{allmodels1}\nThere are two kinds of models: those in which $\\langle$referent(a), referent(a)$\\rangle$ is in the extension of $R$ and those in which it is not. In the first kind of model, $Raa$ is true; by the truth table for the biconditional, $Raa\\eiff Raa$ is also true. In the second kind of model, $Raa$ is false; this makes $Raa\\eiff Raa$ true. Since the sentence is true in both kinds of model, and since every model is one of the two kinds, $Raa\\eiff Raa$ is true in every model. Therefore, it is a tautology.\n\\end{quote}\nThis is a sound argument; it should convince us of its conclusion. But note that it is not an argument in QL. Rather, it is an argument in English \\emph{about} QL; it is an argument in the metalanguage. There is no formal procedure for evaluating or constructing natural language arguments like this one. The imprecision of natural language is the very reason we began thinking about formal languages.\n\nThere are further difficulties with this approach.\n\nConsider the sentence $\\forall x(Rxx\\eif Rxx)$, another obvious tautology. It might be tempting to reason in this way: `$Rxx\\eif Rxx$ is true in every model, so $\\forall x(Rxx\\eif Rxx)$ must be true.' The problem is that $Rxx\\eif Rxx$ is \\emph{not} true in every model. It is not a sentence, and so it is \\emph{neither} true \\emph{nor} false. We do not yet have the vocabulary to say what we want to say about $Rxx\\eif Rxx$. In the next section, we introduce the concept of \\emph{satisfaction}; after doing so, we will be better able to provide an argument that $\\forall x(Rxx\\eif Rxx)$ is a tautology.\n\nIt is necessary to reason about an infinity of models to show that a sentence is a tautology. Similarly, it is necessary to reason about an infinity of models to show that a sentence is a contradiction, that two sentences are equivalent, that a set of sentences is inconsistent, or that an argument is valid. There are other things we can show by carefully constructing a model or two. Table \\ref{table.ModelOrArgument} summarizes which things are which.\n\n\n\n\n\n\n\\section{Truth in QL}\n\\label{sec.TruthInQL}\nIn our discussion of SL, we split the definition of truth into two parts: a truth value assignment ($a$) for sentence letters and a truth function ($v$) for all sentences. The truth function covered the way that complex sentences could be built out of sentence letters and connectives.\n\nJust as for SL, truth for QL is relative: it is \\emph{truth in a model}. The atomic sentences, again, are $n$-place predicates followed by $n$ constants, like $Pj$. It is true in a model \\model{M} if and only if the referent of $j$ is in the extension of $P$ in \\model{M}.\n\nWe could go on in this way to define truth for all atomic sentences that contain only predicates and constants: Consider any sentence of the form $\\script{R}\\script{a}_1\\ldots\\script{a}_n$ where \\script{R} is an n-place predicate and the \\script{a}s are constants. It is true in \\model{M} if and only if ${\\langle}\\referent{\\script{a}_1},\\ldots,\\referent{\\script{a}_n}{\\rangle}$ is in \\extension{\\script{R}} in \\model{M}.\n\nWe could then define truth for sentences built up with sentential connectives in the same way we did for SL. For example, the sentence $(Pj \\eif Mda)$ is true in \\model{M} if either $Pj$ is false in \\model{M} or $Mda$ is true in \\model{M}.\n\nUnfortunately, this approach will fail when we consider sentences containing quantifiers. Consider $\\forall x Px$. When is it true in a model \\model{M}? The answer cannot depend on whether $Px$ is true or false in \\model{M}, because the $x$ in $Px$ is a free variable. $Px$ is not a sentence. It is neither true nor false.\n\nWe were able to give a recursive definition of truth for SL because every well-formed formula of SL has a truth value. This is not true in QL, so we cannot define truth by starting with the truth of atomic sentences and building up. We also need to consider the atomic formulae which are not sentences. In order to do this we will define \\emph{satisfaction}; every well-formed formula of QL will be satisfied or not satisfied, even if it does not have a truth value. We will then be able to define \\emph{truth} for sentences of QL in terms of satisfaction.\n\n\n\\section{Satisfaction}\n\nThe formula $Px$ says, roughly, that $x$ is one of the $P$s. This cannot be quite right, however, because $x$ is a variable and not a constant. It does not name any particular member of the UD. Instead, its meaning in a sentence is determined by the quantifier that binds it. The variable $x$ must stand-in for every member of the UD in the sentence $\\forall xPx$, but it only needs to stand-in for one member in $\\exists xPx$. Since we want the definition of satisfaction to cover $Px$ without any quantifier whatsoever, we will start by saying how to interpret a free variable like the $x$ in $Px$.\n\nWe do this by introducing a \\emph{variable assignment}. Formally, this is a function that matches up each variable with a member of the UD. Call this function `a'. (The `a' is for `assignment', but this is not the same as the truth value assignment that we used in defining truth for SL.)\n\nThe formula $Px$ is satisfied in a model \\model{M} by a variable assignment $a$ if and only if $a(x)$, the object that $a$ assigns to $x$, is in the  extension of P in \\model{M}.\n\nWhen is $\\forall x Px$ satisfied? It is not enough if $Px$ is satisfied in \\model{M} by $a$, because that just means that $a(x)$ is in \\extension{P}. $\\forall x Px$ requires that every other member of the UD be in \\extension{P} as well.\n\nSo we need another bit of technical notation: For any member $\\pi$ of the UD and any variable \\script{x}, let $a[\\pi|\\script{x}]$ be the variable assignment that assigns $\\pi$ to \\script{x} but agrees with $a$ in all other respects. We have used $\\pi$, the Greek letter \\emph{pi}, to underscore the fact that it is some member of the UD and not some symbol of QL. Suppose, for example, that the UD is presidents of the United States. The function $a[\\mbox{Grover Cleveland}|x]$ assigns Grover Cleveland to the variable $x$, regardless of what $a$ assigns to $x$; for any other variable, $a[\\mbox{Grover Cleveland}|x]$ agrees with $a$.\n\nWe can now say concisely that $\\forall x Px$ is satisfied in a model \\model{M} by a variable assignment $a$ if and only if, for every object $\\pi$ in the UD of \\model{M}, $Px$ is satisfied in \\model{M} by $a[\\pi|x]$.\n\nThe intuitive thought here is that wff satisfaction is relative to a variable assignment. A variable assignment is a way of treating each variable as if it were a name for some object or other; a wff is satisfied by a in a given model iff, in that model, treating the variables the way $a$ suggests would yield a true wff.\n\nYou may worry that our statement of satisfaction by a variable assignment in a model is circular, because it gives the satisfaction conditions for the sentence $\\forall x Px$ using the phrase `for every object.' However, it is important to remember the difference between a logical symbol like `$\\forall$' and an English language word like `every.' The word is part of the metalanguage that we use in defining satisfaction conditions for object language sentences that contain the symbol. (Recall the parallel discussion of sentential connectives on p.\\ \\pageref{truthdefinition}.)\n\nWe can now give a general definition of satisfaction, extending from the cases we have already discussed. We define a function $s$ (for `satisfaction') in a model \\model{M} such that for any wff \\metaA{} and variable assignment $a$, $s(\\metaA{}, a)=1$ if \\metaA{} is satisfied in \\model{M} by $a$; otherwise $s(\\metaA{}, a)=0$.\n\n\\begin{enumerate}\n\\item If \\metaA{} is an atomic wff of the form $\\script{P}\\script{t}_1\\ldots\\script{t}_n$ and $\\pi_i$ is the object picked out by $t_i$, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if ${\\langle}\\pi_1\\ldots\\pi_n{\\rangle}$ is in \\extension{\\script{P}} in \\model{M}},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\nFor each term $t_i$: If $t_i$ is a constant, then $\\pi_i = \\referent{t_i}$. If $t_i$ is a variable, then $\\pi_i = a(t_i)$.\n\n\\item If \\metaA{} is ${\\enot}\\metaB{}$ for some wff \\metaB{}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $s(\\metaB{}, a) = 0$},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eand\\metaC{})$ for some wffs \\metaA{}, \\metaB{}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $s(\\metaB{}, a) = 1$ and $s(\\metaC{}, a) = 1$,}\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eor\\metaC{})$ for some wffs \\metaA{}, \\metaB{}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t0 & \\mbox{if $s(\\metaB{}, a) = 0$  and $s(\\metaC{}, a) = 0$,}\\\\\n\t1 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eif\\metaC{})$ for some wffs \\metaA{}, \\metaB{}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t0 & \\mbox{if $s(\\metaB{}, a) = 1$ and $s(\\metaC{}, a) = 0$,}\\\\\n\t1 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eiff\\metaC{})$ for some wffs \\metaA{}, \\metaB{}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $s(\\metaB{}, a) = s(\\metaC{}, a)$},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $\\forall\\script{x} \\metaB{}$ for some wff \\metaB{} and some variable \\script{x}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $s(\\metaB{}, a[\\pi|\\script{x}])=1$ for every member $\\pi$ of the UD},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $\\exists\\script{x} \\metaB{}$ for some wff \\metaB{} and some variable \\script{x}, then\n\\begin{displaymath}s(\\metaA{}, a) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $s(\\metaB{}, a[\\pi|\\script{x}])=1$ for at least one member $\\pi$ of the UD},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\\end{enumerate}\n \nThis definition follows the same structure as the definition of a wff for QL, so we know that every wff of QL will be covered by this definition. For a model \\model{M} and a variable assignment $a$, any wff will either be satisfied or not. No wffs are left out or assigned conflicting values.\n\n\n\n\n\\section{Truth in QL}\n\nConsider a simple quantified sentence like $\\forall xPx$. By part 7 in the definition of satisfaction, this sentence is satisfied if $a[\\pi|x]$ satisfies $Px$ in \\model{M} for every $\\pi$ in the UD. In other words, assign that $x$ to any object in the UD you like, and the resultant wff will come out true. By part 1 of the definition, this will be the case if every $\\pi$ is in the extension of $P$. Whether $\\forall xPx$ is satisfied does not depend on the particular variable assignment $a$. If this sentence is satisfied, then it is true. This is a formalization of what we have said all along: $\\forall xPx$ is true if everything in the UD is in the extension of $P$.\n\nThe same thing holds for any sentence of QL. Because all of the variables are bound, a sentence is satisfied or not regardless of the details of the variable assignment. So we can define truth in this way: A sentence \\metaA{} is \\define{true in} \\model{M} if and only if some variable assignment satisfies \\metaA{} in $M$; \\metaA{} is \\define{false in} \\model{M} otherwise.\n\nTruth in QL is \\emph{truth in a model}. Sentences of QL are not flat-footedly true or false as mere symbols, but only relative to a model. A model provides the meaning of the symbols, insofar as it makes any difference to truth and falsity.\n\n\n\\section{Reasoning about all models (reprise)}\nAt the end of section \\ref{sec.allmodelreasoning}, we were stymied when we tried to show that $\\forall x(Rxx\\eif Rxx)$ is a tautology. Having defined satisfaction, we can now reason in this way:\n\\begin{quote}\nConsider some arbitrary model \\model{M}. Now consider an arbitrary member of the UD; for the sake of convenience, call it $\\pi$. It must be the case either that $\\langle\\pi,\\pi\\rangle$ is in the extension of $R$ or that it is not. If $\\langle\\pi,\\pi\\rangle$ is in the extension of $R$, then $Rxx$ is satisfied by a variable assignment that assigns $\\pi$ to $x$ (by part 1 of the definition of  {satisfaction}); since the consequent of $Rxx\\eif Rxx$ is satisfied, the conditional is satisfied (by part 5). If $\\langle\\pi,\\pi\\rangle$ is not in the extension of $R$, then $Rxx$ is not satisfied by a variable assignment that assigns $\\pi$ to $x$ (by part 1); since antecedent of $Rxx\\eif Rxx$ is not satisfied, the conditional is satisfied (by part 5). In either case, $Rxx\\eif Rxx$ is satisfied. This is true for any member of the UD, so $\\forall x(Rxx \\eif Rxx)$ is satisfied by any truth value assignment (by part 7). So $\\forall x(Rxx \\eif Rxx)$ is true in \\model{M} (by the definition of {truth}). This argument holds regardless of the exact UD and regardless of the exact extension of $R$, so $\\forall x(Rxx \\eif Rxx)$ is true in any model. Therefore, it is a tautology.\n\\end{quote}\n\nGiving arguments about all possible models typically requires clever combination of two strategies:\n\n1. Divide cases between two possible kinds, such that every case must be one kind or the other.  In the argument on p.~\\pageref{allmodels1}, for example, we distinguished two kinds of models based on whether or not a specific ordered pair was in \\extension{R}. In the argument above, we distinguished cases in which an ordered pair was in \\extension{R} and cases in which it was not.\n\n2. Consider an arbitrary object as a way of showing something more general. In the argument above, it was crucial that $\\pi$ was just some arbitrary member of the UD. We did not assume anything special about it. As such, whatever we could show to hold of $\\pi$ must hold of every member of the UD --- if we could show it for $\\pi$, we could show it for anything. In the same way, we did not assume anything special about \\model{M}, and so whatever we could show about \\model{M} must hold for all models.\n\nConsider one more example. The argument $\\forall x(Hx \\eand Jx)$ \\therefore  $\\forall x Hx$ is obviously valid. We can only show that the argument is valid by considering what must be true in every model in which the premise is true.\n\\begin{quote}\nConsider an arbitrary model \\model{M} in which the premise $\\forall x(Hx \\eand Jx)$ is true. The conjunction $Hx \\eand Jx$ is satisfied regardless of what is assigned to $x$, so $Hx$ must be also (by part 3 of the definition of {satisfaction}). As such, $\\forall x Hx$ is satisfied by any variable assignment (by part 7 of the definition of {satisfaction}) and true in \\model{M} (by the definition of {truth}).\nSince we did not assume anything about \\model{M} besides $\\forall x(Hx \\eand Jx)$ being true, $\\forall x Hx$ must be true in any model in which $\\forall x(Hx \\eand Jx)$ is true. So $\\forall x(Hx \\eand Jx) \\models \\forall x Hx$.\n\\end{quote}\nEven for a simple argument like this one, the reasoning is somewhat complicated. For longer arguments, the reasoning can be insufferable. The problem arises because talking about an infinity of models requires reasoning things out in English. What are we to do? The answer won't surprise readers of the first half of the book: we'll make use of some formal proof systems. We have seen two kinds of proof systems for SL: the tree method, and natural deduction proofs. In the coming chapters, we'll extend both kinds of systems to QL as well.\n\n\n\\practiceproblems\n\n\\solutions\n\\problempart\n\\label{pr.TorF1}\nDetermine whether each sentence is true or false in the model given.\n\\begin{partialmodel}\nUD & \\{Corwin, Benedict\\}\\\\\n\\extension{A} & \\{Corwin, Benedict\\}\\\\\n\\extension{B} & \\{Benedict\\}\\\\\n\\extension{N} & $\\emptyset$\\\\\n\\referent{c} & Corwin\n\\end{partialmodel}\n\\begin{earg}\n\\item $Bc$\n\\item $Ac \\eiff \\enot Nc$\n\\item $Nc \\eif (Ac \\eor Bc)$\n\\item $\\forall x Ax$\n\\item $\\forall x \\enot Bx$\n\\item $\\exists x(Ax \\eand Bx)$\n\\item $\\exists x(Ax \\eif Nx)$\n\\item $\\forall x(Nx \\eor \\enot Nx)$\n\\item $\\exists x Bx \\eif \\forall x Ax$\n\\end{earg}\n\n\n\n\n\\solutions\n\\problempart\n\\label{pr.TorF2}\nDetermine whether each sentence is true or false in the model given.\n\\begin{partialmodel}\nUD & \\{Waylan, Willy, Johnny\\}\\\\\n\\extension{H} & \\{Waylan, Willy, Johnny\\}\\\\\n\\extension{W} & \\{Waylan, Willy\\}\\\\\n\\extension{R} & \\{\\ntuple{Waylan, Willy},\\ntuple{Willy, Johnny},\\ntuple{Johnny, Waylan}\\}\\\\\n\\referent{m} & Johnny\n\\end{partialmodel}\n\\begin{earg}\n\\item $\\exists x(Rxm \\eand Rmx)$\n\\item $\\forall x(Rxm \\eor Rmx)$\n\\item $\\forall x(Hx \\eiff Wx)$\n\\item $\\forall x(Rxm \\eif Wx)$\n\\item $\\forall x\\bigl[Wx \\eif(Hx \\eand Wx)\\bigr]$\n\\item $\\exists x Rxx$\n\\item $\\exists x\\exists y Rxy$\n\\item $\\forall x \\forall y Rxy$\n\\item $\\forall x \\forall y (Rxy \\eor Ryx)$\n\\item $\\forall x \\forall y \\forall z\\bigl[(Rxy \\eand Ryz) \\eif Rxz\\bigr]$\n\\end{earg}\n\n\\solutions\n\\problempart\n\\label{pr.TorF3}\nDetermine whether each sentence is true or false in the model given.\n\\begin{partialmodel}\n\tUD\t\t\t& \\{Lemmy, Courtney, Eddy\\}\\\\\n\t\\extension{G}\t& \\{Lemmy, Courtney, Eddy\\}\\\\\n\t\\extension{H}\t& \\{Courtney\\}\\\\\n\t\\extension{M}\t& \\{Lemmy, Eddy\\}\\\\\n\t\\referent{c}\t& Courtney\\\\\n\t\\referent{e}\t& Eddy\n\\end{partialmodel}\n\\begin{earg}\n\\item $Hc$\n\\item $He$\n\\item $Mc \\eor Me$\n\\item $Gc \\eor \\enot Gc$\n\\item $Mc \\eif Gc$\n\\item $\\exists x Hx$\n\\item $\\forall x Hx$\n\\item $\\exists x \\enot Mx$\n\\item $\\exists x(Hx \\eand Gx)$\n\\item $\\exists x(Mx \\eand Gx)$\n\\item $\\forall x(Hx \\eor Mx)$\n\\item $\\exists x Hx \\eand \\exists x Mx$\n\\item $\\forall x(Hx \\eiff \\enot Mx)$\n\\item $\\exists x Gx \\eand \\exists x \\enot Gx$\n\\item $\\forall x\\exists y(Gx \\eand Hy)$\n\\end{earg}\n\n\\solutions\n\\problempart\n\\label{pr.InterpretationToModel}\nWrite out the model that corresponds to the interpretation given.\n\\begin{ekey}\n\\item{UD:} natural numbers from 10 to 13\n\\item{Ox:} $x$ is odd. \n\\item{Sx:} $x$ is less than 7.\n\\item{Tx:} $x$ is a two-digit number.\n\\item{Ux:} $x$ is thought to be unlucky.\n\\item{Nxy:} $x$ is the next number after $y$.\n\\end{ekey}\n\n\n\\problempart\n\\label{pr.Contingent}\nShow that each of the following is contingent.\n\\begin{earg}\n\\item \\leftsolutions\\ $Da \\eand Db$\n\\item \\leftsolutions\\ $\\exists x Txh$\n\\item \\leftsolutions\\ $Pm \\eand \\enot\\forall x Px$\n\\item $\\forall z Jz \\eiff \\exists y Jy$\n\\item $\\forall x (Wxmn \\eor \\exists yLxy)$\n\\item $\\exists x (Gx \\eif \\forall y My)$\n\\end{earg}\n\n\\solutions\n\\problempart\n\\label{pr.NotEquiv}\nShow that the following pairs of sentences are not logically equivalent.\n\\begin{earg}\n\\item $Ja$, $Ka$\n\\item $\\exists x Jx$, $Jm$\n\\item $\\forall x Rxx$, $\\exists x Rxx$\n\\item $\\exists x Px \\eif Qc$, $\\exists x (Px \\eif Qc)$\n\\item $\\forall x(Px \\eif \\enot Qx)$, $\\exists x(Px \\eand \\enot Qx)$\n\\item $\\exists x(Px \\eand Qx)$, $\\exists x(Px \\eif Qx)$\n\\item $\\forall x(Px\\eif Qx)$, $\\forall x(Px \\eand Qx)$\n\\item $\\forall x\\exists y Rxy$, $\\exists x\\forall y Rxy$\n\\item $\\forall x\\exists y Rxy$, $\\forall x\\exists y Ryx$\n\\end{earg}\n\n\n\n\\problempart\nShow that the following sets of sentences are consistent.\n\\begin{earg}\n\\item \\{Ma, \\enot Na, Pa, \\enot Qa\\}\n\\item \\{$Lee$, $Lef$, $\\enot Lfe$, $\\enot Lff$\\}\n\\item \\{$\\enot (Ma \\eand \\exists x Ax)$, $Ma \\eor Fa$, $\\forall x(Fx \\eif Ax)$\\}\n\\item \\{$Ma \\eor Mb$, $Ma \\eif \\forall x \\enot Mx$\\}\n\\item \\{$\\forall y Gy$, $\\forall x (Gx \\eif Hx)$, $\\exists y \\enot Iy$\\}\n\\item \\{$\\exists x(Bx \\eor Ax)$, $\\forall x \\enot Cx$, $\\forall x\\bigl[(Ax \\eand Bx) \\eif Cx\\bigr]$\\}\n\\item \\{$\\exists x Xx$, $\\exists x Yx$, $\\forall x(Xx \\eiff \\enot Yx)$\\}\n\\item \\{$\\forall x(Px \\eor Qx)$, $\\exists x\\enot(Qx \\eand Px)$\\}\n\\item \\{$\\exists z(Nz \\eand Ozz)$, $\\forall x\\forall y(Oxy \\eif Oyx)$\\}\n\\item \\{$\\enot \\exists x \\forall y Rxy$, $\\forall x \\exists y Rxy$\\}\n\\end{earg}\n\n\n\\problempart\nConstruct models to show that the following arguments are invalid.\n\\begin{earg}\n\\item $\\forall x(Ax \\eif Bx)$, \\therefore\\ $\\exists x Bx$\n\\item $\\forall x(Rx \\eif Dx)$, $\\forall x(Rx \\eif Fx)$, \\therefore\\ $\\exists x(Dx \\eand Fx)$\n\\item $\\exists x(Px\\eif Qx)$, \\therefore $\\exists x Px$\n\\item $Na \\eand Nb \\eand Nc$, \\therefore\\ $\\forall x Nx$\n\\item $Rde$, $\\exists x Rxd$, \\therefore\\ $Red$\n\\item $\\exists x(Ex \\eand Fx)$, $\\exists x Fx \\eif \\exists x Gx$, \\therefore\\ $\\exists x(Ex \\eand Gx)$\n\\item $\\forall x Oxc$, $\\forall x Ocx$, \\therefore\\ $\\forall x Oxx$\n\\item $\\exists x(Jx \\eand Kx)$, $\\exists x \\enot Kx$, $\\exists x \\enot Jx$, \\therefore\\ $\\exists x(\\enot Jx \\eand \\enot Kx)$\n\\item $Lab \\eif \\forall x Lxb$, $\\exists x Lxb$, \\therefore\\ $Lbb$\n\\end{earg}\n\n\n\n\n\n\\problempart\n\\label{pr.SemanticsEssay}\n\\begin{earg}\n\\item Many logic books define consistency and inconsistency in this way:\n`` A set $\\{\\metaA{}_1,\\metaA{}_2,\\metaA{}_3,\\cdots\\}$ is inconsistent if and only if $\\{\\metaA{}_1,\\metaA{}_2,\\metaA{}_3,\\cdots\\}\\models(\\metaB{}\\eand\\enot\\metaB{})$ for some sentence \\metaB{}. A set is consistent if it is not inconsistent.''\n\nDoes this definition lead to any different sets being consistent than the definition on  p.~\\pageref{def.consistencySL}? Explain your answer.\n\n\\item\\leftsolutions\\ Our definition of truth says that a sentence \\metaA{} is \\define{true in} \\model{M} if and only if some variable assignment satisfies \\metaA{} in $M$. Would it make any difference if we said instead that \\metaA{} is \\define{true in} \\model{M} if and only if \\emph{every} variable assignment satisfies \\metaA{} in $M$? Explain your answer.\n\\end{earg}\n", "meta": {"hexsha": "fef8e3c62d07480917276c178536234b41ce84ae", "size": 49671, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Latex-Files/forallx-ubc-9-QLmodels.tex", "max_stars_repo_name": "lauragreenstreet/for-all-x", "max_stars_repo_head_hexsha": "925bfb510101aa77174d977d2b956fc8088950e6", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-01-27T22:51:34.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-09T18:43:25.000Z", "max_issues_repo_path": "Latex-Files/forallx-ubc-9-QLmodels.tex", "max_issues_repo_name": "mavaddat/for-all-x", "max_issues_repo_head_hexsha": "925bfb510101aa77174d977d2b956fc8088950e6", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2019-02-05T17:15:37.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-18T02:51:45.000Z", "max_forks_repo_path": "Latex-Files/forallx-ubc-9-QLmodels.tex", "max_forks_repo_name": "lauragreenstreet/for-all-x", "max_forks_repo_head_hexsha": "925bfb510101aa77174d977d2b956fc8088950e6", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.6109375, "max_line_length": 1181, "alphanum_fraction": 0.7052606148, "num_tokens": 14502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.4426903566081747}}
{"text": "\\documentclass[t]{beamer}\n\\usetheme{Copenhagen}\n\\usepackage{amsmath, tikz, tkz-euclide, xcolor}\n\\usetkzobj{all}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\newcommand{\\nl}{\\newline\\\\}\n\n\\title{Right Triangle Trigonometry}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Table of Contents}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}{}\n    \\titlepage\n\\end{frame}\n\n\\section{Write the Exact Ratio for the Six Trigonometric Ratios} \n\n\\begin{frame}\nIn geometry class, you learned about three trigonometric ratios: sine, cosine, and tangent.  \\nl \n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){adjacent}\n    \\tkzLabelSegment[right](C,B){opposite}\n    \\tkzLabelSegment[sloped,above,midway](A,B){hypotenuse}\n    \\end{tikzpicture}\n\\end{center}\n\\pause\n\\[\n\\sin A = \\dfrac{\\text{opposite}}{\\text{hypotenuse}} \\hspace{0.25in} \\cos A = \\dfrac{\\text{adjacent}}{\\text{hypotenuse}} \\hspace{0.25in}  \\tan A = \\dfrac{\\text{opposite}}{\\text{adjacent}}    \n\\]\n\\end{frame}\n\n\\begin{frame}{SOH-CAH-TOA}\nWe usually remember this as SOH-CAH-TOA.   \\nl \n\nSometimes you may need to use the Pythagorean Theorem, $a^2+b^2=c^2$, in order to find any missing sides.\n\\end{frame}\n\n\\begin{frame}{Example 1a}\nWrite the exact ratios for sine, cosine, and tangent of angle $A$ for each of the following.  \\nl\n\\begin{minipage}{0.4\\textwidth}\n(a) \\quad \\nl\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){15}\n    \\tkzLabelSegment[right](C,B){8}\n    \\tkzLabelSegment[above,midway](A,B){17}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin A &= \\frac{8}{17}}   \\\\[11pt]\n    \\onslide<3->{\\cos A &= \\frac{15}{17}}   \\\\[11pt]\n    \\onslide<4->{\\tan A &= \\frac{8}{15}}   \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1b}\n\\begin{minipage}{0.4\\textwidth}\n(b) \\nl\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){4}\n    \\tkzLabelSegment[right](C,B){3}\n    \\tkzLabelSegment[above,midway](A,B){5}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin A &= \\frac{3}{5}}   \\\\[11pt]\n    \\onslide<3->{\\cos A &= \\frac{4}{5}}   \\\\[11pt]\n    \\onslide<4->{\\tan A &= \\frac{3}{4}}   \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1c}\n(c) \\nl\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){9}\n    \\tkzLabelSegment[right](C,B){15}\n    \\tkzLabelSegment[above,midway](A,B){}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n    \\begin{align*}\n    \\onslide<2->{9^2+15^2&=c^2} \\\\[8pt]\n    \\onslide<3->{c&=\\sqrt{306} = 3\\sqrt{34}} \\\\[11pt]\n    \\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1c}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){9}\n    \\tkzLabelSegment[right](C,B){15}\n    \\tkzLabelSegment[above left](A,B){$3\\sqrt{34}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin A &= \\frac{15}{3\\sqrt{34}}} \\\\[11pt]\n    \\onslide<3->{&=\\frac{5}{\\sqrt{34}}} \\\\[11pt]\n    \\onslide<4->{&= \\frac{5}{\\sqrt{34}}\\cdot \\frac{\\sqrt{34}}{\\sqrt{34}}}    \\\\[11pt]\n    \\onslide<5->{&=\\frac{5\\sqrt{34}}{34}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1c}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){9}\n    \\tkzLabelSegment[right](C,B){15}\n    \\tkzLabelSegment[above left](A,B){$3\\sqrt{34}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\cos A &= \\frac{9}{3\\sqrt{34}}} \\\\[11pt]\n    \\onslide<3->{&=\\frac{3}{\\sqrt{34}}} \\\\[11pt]\n    \\onslide<4->{&= \\frac{3}{\\sqrt{34}}\\cdot \\frac{\\sqrt{34}}{\\sqrt{34}}}    \\\\[11pt]\n    \\onslide<5->{&=\\frac{3\\sqrt{34}}{34}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1c}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){9}\n    \\tkzLabelSegment[right](C,B){15}\n    \\tkzLabelSegment[above left](A,B){$3\\sqrt{34}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\tan A &= \\frac{15}{9}} \\\\[11pt]\n    \\onslide<3->{&=\\frac{5}{3}} \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Other Trig Ratios}\nIn addition to the ``Big-3\": sine, cosine, and tangent, there are three additional trigonometric ratios.    \\nl    \\pause\n\nThese ratios (\\textit{cosecant}, \\textit{secant}, and \\textit{cotangent}) are the reciprocals of sine, cosine, and tangent, respectively.   \\pause\n\n\\[\n\\csc A = \\dfrac{\\text{hypotenuse}}{\\text{opposite}} \\hspace{0.25in} \\sec A = \\dfrac{\\text{hypotenuse}}{\\text{adjacent}} \\hspace{0.25in}  \\cot A = \\dfrac{\\text{adjacent}}{\\text{opposite}}    \n\\]\n\\end{frame}\n\n\\begin{frame}{Example 2a}\nWrite the exact ratios for cosecant, secant, and cotangent of angle $A$ for each of the following.  \\nl\n(a) \\nl\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){15}\n    \\tkzLabelSegment[right](C,B){8}\n    \\tkzLabelSegment[above,midway](A,B){17}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc A &= \\frac{17}{8}} \\\\[11pt]\n    \\onslide<3->{\\sec A &= \\frac{17}{15}} \\\\[11pt]\n    \\onslide<4->{\\cot A &= \\frac{15}{8}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 2b}\n    (b) \\nl\n    \\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){4}\n    \\tkzLabelSegment[right](C,B){3}\n    \\tkzLabelSegment[above,midway](A,B){5}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc A &= \\frac{5}{3}} \\\\[11pt]\n    \\onslide<3->{\\sec A &= \\frac{5}{4}} \\\\[11pt]\n    \\onslide<4->{\\cot A &= \\frac{4}{3}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 2c}\n    (c) \\nl\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/C, 3/2/B}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,C,B)\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelSegment[below](A,C){9}\n    \\tkzLabelSegment[right](C,B){15}\n    \\tkzLabelSegment[above left](A,B){$3\\sqrt{34}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc A &= \\frac{3\\sqrt{34}}{15} = \\frac{\\sqrt{34}}{5}} \\\\[11pt]\n    \\onslide<3->{\\sec A &= \\frac{3\\sqrt{34}}{9} = \\frac{\\sqrt{34}}{3}} \\\\[11pt]\n    \\onslide<4->{\\cot A &= \\frac{9}{15} = \\frac{3}{5}}\n\\end{align*}\n\\end{minipage}    \n\\end{frame}\n\n\\section{Write the Exact Ratios for the Six Trigonometric Ratios of Special Angles}\n\n\\begin{frame}{45-45-90 Triangles}\n\n45-45-90 triangles (also known as \\textit{isosceles right triangles}) can be created by drawing a diagonal across a square:\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/3/C, 0/3/D}\n    \\tkzDrawPolygon(A,B,C,D)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzDrawSegment[dashed](A,C)\n    \\tkzLabelAngle[pos=0.75](B,A,C){$45^\\circ$}\n    \\tkzLabelAngle[pos=0.75](B,C,A){$45^\\circ$}\n    \\end{tikzpicture}\n\\end{center}\n\n\\end{frame} \n\n\\begin{frame}{45-45-90 Triangles}\nSince each side of a square is the same length, we can use whatever length we want. For simplicity, we will use a length of 1.  \\nl \\pause\n\nThe diagonal of the square can be found by using Pythagorean Theorem:  \\pause\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/3/C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.75](B,A,C){$45^\\circ$}\n    \\tkzLabelAngle[pos=0.75](B,C,A){$45^\\circ$}\n    \\tkzLabelSegment[right](B,C){1}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[above left, midway](A,C){$\\sqrt{2}$}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 3}\nFind the exact values of the six trig ratios for $45^\\circ$. \\nl\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/3/C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.75](B,A,C){$45^\\circ$}\n    \\tkzLabelAngle[pos=0.75](B,C,A){$45^\\circ$}\n    \\tkzLabelSegment[right](B,C){1}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[above left, midway](A,C){$\\sqrt{2}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin 45^\\circ &= \\frac{1}{\\sqrt{2}}} \\\\[11pt]\n    \\onslide<3->{&= \\frac{1}{\\sqrt{2}}\\frac{\\sqrt{2}}{\\sqrt{2}} = \\frac{\\sqrt{2}}{2}} \\\\[11pt]\n    \\onslide<4->{\\cos45^\\circ &= \\frac{1}{\\sqrt{2}} = \\frac{\\sqrt{2}}{2}} \\\\[11pt]\n    \\onslide<5->{\\tan 45^\\circ &= \\frac{1}{1} = 1}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/3/C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.75](B,A,C){$45^\\circ$}\n    \\tkzLabelAngle[pos=0.75](B,C,A){$45^\\circ$}\n    \\tkzLabelSegment[right](B,C){1}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[above left, midway](A,C){$\\sqrt{2}$}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc 45^\\circ &= \\frac{\\sqrt{2}}{1} = \\sqrt{2}} \\\\[11pt]\n    \\onslide<3->{\\sec45^\\circ &= \\frac{\\sqrt{2}}{1} = \\sqrt{2}} \\\\[11pt]\n    \\onslide<4->{\\cot 45^\\circ &= \\frac{1}{1} = 1}    \\\\[11pt]\n\\end{align*}\n\\end{minipage}    \n\\onslide<5->{\\emph{Note}: Your answers from the above example will be the same if you replace $45^\\circ$ with $\\frac{\\pi}{4}$.}\n\\end{frame}\n\n\\begin{frame}{30-60-90 Triangles}\n    We can create a 30-60-90 triangle by drawing an altitude in an equilateral triangle.\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 4/0/B}\n    \\tkzDefPoint(60:4){C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzDefMidPoint(A,B)\n        \\tkzGetPoint{D}\n    \\tkzDrawSegment[dashed](D,C)\n    \\tkzMarkRightAngle[color=red](A,D,C)\n    \\tkzLabelAngle[pos=0.5](D,A,C){$60^\\circ$}\n    \\tkzLabelAngle[pos=1](D,C,A){$30^\\circ$}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{30-60-90 Triangles}\nRecall that the altitude of an equilateral triangle bisects one of the sides.   \\nl    \\pause\n\nRather than use a length of 1 for the sides of the equilateral triangle, we will use a length of 2 (if only to avoid using fractions). \\nl \\pause\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 4/0/B}\n    \\tkzDefPoint(60:4){C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzDefMidPoint(A,B)\n        \\tkzGetPoint{D}\n    \\tkzDrawSegment[dashed](D,C)\n    \\tkzMarkRightAngle[color=red](A,D,C)\n    \\tkzLabelAngle[pos=0.5](D,A,C){$60^\\circ$}\n    \\tkzLabelAngle[pos=1](D,C,A){$30^\\circ$}\n    \\tkzLabelSegment[below](A,D){1}\n    \\tkzLabelSegment[below](D,B){1}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\tkzLabelSegment[midway, above right](B,C){2}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{30-60-90 Triangles}\nWe can use the Pythagorean Theorem to find the length of the altitude, $\\sqrt{3}$:\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 2/0/B}\n    \\tkzDefPoint(60:4){C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.5](B,A,C){$60^\\circ$}\n    \\tkzLabelAngle(B,C,A){$30^\\circ$}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[right](B,C){$\\sqrt{3}$}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 4}\nFind the exact values of the six trig ratios for $60^\\circ$. \\nl\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 2/0/B}\n    \\tkzDefPoint(60:4){C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.5](B,A,C){$60^\\circ$}\n    \\tkzLabelAngle(B,C,A){$30^\\circ$}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[right](B,C){$\\sqrt{3}$}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin 60^\\circ &= \\frac{\\sqrt{3}}{2}} \\\\[11pt]\n    \\onslide<3->{\\cos 60^\\circ &= \\frac{1}{2}} \\\\[11pt]\n    \\onslide<4->{\\tan 60^\\circ &= \\frac{\\sqrt{3}}{1} = \\sqrt{3}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 2/0/B}\n    \\tkzDefPoint(60:4){C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.5](B,A,C){$60^\\circ$}\n    \\tkzLabelAngle(B,C,A){$30^\\circ$}\n    \\tkzLabelSegment[below](A,B){1}\n    \\tkzLabelSegment[right](B,C){$\\sqrt{3}$}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc 60^\\circ &= \\frac{2}{\\sqrt{3}}} \\\\[11pt]\n    \\onslide<3->{&= \\frac{2}{\\sqrt{3}}\\frac{\\sqrt{3}}{\\sqrt{3}} = \\frac{2\\sqrt{3}}{3}} \\\\[11pt]\n    \\onslide<4->{\\sec 60^\\circ &= \\frac{2}{1} = 2} \\\\[11pt]\n    \\onslide<5->{\\cot 60^\\circ &= \\frac{1}{\\sqrt{3}}} \\\\[11pt]\n    \\onslide<6->{&= \\frac{1}{\\sqrt{3}}\\frac{\\sqrt{3}}{\\sqrt{3}} = \\frac{\\sqrt{3}}{3}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 5}\nFind the exact values of the six trig ratios for $30^\\circ$. \\nl\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/1.73/C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.85](B,A,C){$30^\\circ$}\n    \\tkzLabelAngle[pos=0.5](B,C,A){$60^\\circ$}\n    \\tkzLabelSegment[below](A,B){$\\sqrt{3}$}\n    \\tkzLabelSegment[right](B,C){1}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\sin 30^\\circ &= \\frac{1}{2}} \\\\[11pt]\n    \\onslide<3->{\\cos 30^\\circ &= \\frac{\\sqrt{3}}{2}} \\\\[11pt]\n    \\onslide<4->{\\tan 30^\\circ &= \\frac{1}{\\sqrt{3}} = \\frac{\\sqrt{3}}{3}}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 5}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 3/0/B, 3/1.73/C}\n    \\tkzDrawPolygon(A,B,C)\n    \\tkzMarkRightAngle[color=red](A,B,C)\n    \\tkzLabelAngle[pos=0.85](B,A,C){$30^\\circ$}\n    \\tkzLabelAngle[pos=0.5](B,C,A){$60^\\circ$}\n    \\tkzLabelSegment[below](A,B){$\\sqrt{3}$}\n    \\tkzLabelSegment[right](B,C){1}\n    \\tkzLabelSegment[midway, above left](A,C){2}\n    \\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\csc 30^\\circ &= \\frac{2}{1} = 2} \\\\[11pt]\n    \\onslide<3->{\\sec 30^\\circ &= \\frac{2}{\\sqrt{3}} = \\frac{2\\sqrt{3}}{3}} \\\\[11pt]\n    \\onslide<4->{\\cot 30^\\circ &= \\frac{\\sqrt{3}}{1} = \\sqrt{3}}  \\\\[11pt]\n\\end{align*}\n\\end{minipage}    \n\\onslide<5->{Notice how $\\sin 30^\\circ = \\cos 60^\\circ$, $\\tan 30^\\circ = \\cot 60^\\circ$, etc. This is because these ratios are \\alert{cofunctions}.}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "fb2916561e6211e7ae840e8acf0c5dd94ddcfc0e", "size": 16089, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Right_Triangle_Trig_BEAMER.tex", "max_stars_repo_name": "BryanBain/HA2_BEAMER", "max_stars_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Right_Triangle_Trig_BEAMER.tex", "max_issues_repo_name": "BryanBain/HA2_BEAMER", "max_issues_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Right_Triangle_Trig_BEAMER.tex", "max_forks_repo_name": "BryanBain/HA2_BEAMER", "max_forks_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:45.000Z", "avg_line_length": 32.0498007968, "max_line_length": 190, "alphanum_fraction": 0.6340356765, "num_tokens": 6527, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.4426903528537062}}
{"text": "\n%\t\\begin{axiomdescription}[equality-bt-cell]\n%\t\t\\label{ax::equality_bt_cell}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\t\t\tLet c1,c2 be cells. We claim 2 cells are equal if all their fields are equal.\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\t(c1 = c2 \\implies (data(c1) = data(c2) \\wedge c1.lockid = c2.lockid \\wedge next(c1) = next(c2)))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n%\t\\begin{axiomdescription}[equality-on-read]\n%\t\t\\label{ax::equality_on_read}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\t\t\tLet a,b be addresses and m a memory. Then, reading \\doubt{on/in} a memory two equal addresses return the same cell.\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\t(a = b \\implies rd(m,a) = rd(m,b))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n\n%\tUNUSED\n%\t\\begin{axiomdescription}[set-exten]\n%\t\t\\label{ax::set_exten}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\tse1 = se2 \\implies (\\forall a in(a,se1) \\dimplies in(a,se2))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n\n%\tUNUSED\n%\t\\begin{axiomdescription}[SetDiff-def]\n%\t\t\\label{ax::SetDiff_def}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\t\t\tDifference of set definition.\n%\t\t\t%\n%\t\t\tA generic element is not in the difference of any set with $\\fSingl(a)$\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\t((in(x,se) \\wedge (\\neg\\;  in(x,se2))) \\dimplies in(x,diff(se,se2)))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n\n\n\n\n%\tUNUSED\n%\t\\begin{axiomdescription}[less-total]\n%\t\t\\label{ax::less_total}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\t\t\tThe order relation \\doubt{between/among} \\elem is total.\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\t(\\neg\\;  (x < y \\wedge y < x))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n\n%\t\\begin{axiomdescription}[not-in-region--not-change-heap-list]\n%\t\t\\label{ax::not_in_region__not_change_heap_list}\n%\t\t\\explanation{\n%\t\t\t\\paragraph{Interpretation:}\n%\t\t\tLet $hp$ be an \\addr and $hp$ a \\mem. \n%\t\t\t%\n%\t\t\tThen, modifying a \\mem in an \\addr which is not reachable from $hp$ preserves the order of the elements in the list.\n%\t\t}\n%\t\t\\begin{formula}\n%\t\t\t((\\neg\\;  in(a,addr2set(hp,hd))) \\implies orderlist(hp,hd) = orderlist(upd(hp,a,c),hd))\n%\t\t\\end{formula}\n%\t\\end{axiomdescription}\n\n\n\t\\begin{axiomdescription}[just-tail--points--null]\n\t\t\\label{ax::just_tail__points__null}\n\t\t\\explanation{\n\t\t\t\\paragraph{Interpretation:}\n\t\t\tThe only node of the list pointing to \\fNull is the sentinel node \\tail. \n\t\t\t%\n\t\t\tOne may think that this axiom do not give new any new truth to the axiom set, because of the two previous ones.\n\t\t\t%\n\t\t\tIndependently of this axiom being redundant, it provides \\spass a performance improvement.\n\t\t\t%\n\t\t\tAs it has been stated, this set of axioms is not the minimum set of axioms but is a set sufficient to prove all the invariants.\n\t\t\t\\\\\n\t\t\tLet $hd,tl$ be \\addr reachable from $hd$ in the \\mem $hp$, both different from \\fNull, and $tl$ pointing to \\fNull.\n\t\t\t%\n\t\t\tLet $d$ be a not \\fNull \\addr which points to \\fNull \n\t\t}\n\t\t\\begin{formula}\n\t\t\t((in(tl,addr2set(hp,hd)) \\wedge (\\neg\\;  hd = null) \\wedge (\\neg\\;  tl = null) \\wedge next(rd(hp,tl)) = null \\wedge (\\neg\\;  d = null) \\wedge next(rd(hp,d)) = null \\wedge in(d,addr2set(hp,hd))) \\implies d = tl)\n\t\t\\end{formula}\n\t\\end{axiomdescription}\n\n\n\t\\begin{axiomdescription}[next-injective--if-ordered]\n\t\t\\label{ax::next_injective__if_ordered}\n\t\t\\explanation{\n\t\t\t\\paragraph{Interpretation:}\n\t\t\t\\fNext is biyective inside an orderlist, i.e., every node of the list has only another node of the list pointing to it.\n\t\t\t\\\\\n\t\t\tLet $hd,tl$ be \\addr, sentinel nodes of an order list in the \\mem $hp$.\n\t\t\t%\n\t\t\tAs a sentinel node $tl$ points to \\fNull.\n\t\t\t%\n\t\t\tLet $a,b,c,d$ be three \\addr reachable from $hd$, every \\addr different from \\fNull and $a,c$ different from $tl$.\n\t\t\t\\\\\n\t\t\tIf $c$ points to $a$, $d$ points to $a$ and $a=b$, \\textbf{$c=d$}.\n\t\t}\n\t\t\\begin{formula}\n\t\t\t((orderlist(hp,hd,tl) \\wedge in(a,addr2set(hp,hd)) \\wedge in(b,addr2set(hp,hd)) \\wedge in(c,addr2set(hp,hd)) \\wedge in(d,addr2set(hp,hd)) \\wedge (\\neg\\;  tl = null) \\wedge null = next(rd(hp,tl)) \\wedge (\\neg\\;  c = null) \\wedge (\\neg\\;  d = null) \\wedge (\\neg\\;  a = null) \\wedge (\\neg\\;  b = null) \\wedge (\\neg\\;  a = tl) \\wedge (\\neg\\;  b = tl) \\wedge next(rd(hp,c)) = a \\wedge next(rd(hp,d)) = b) \\implies a = b \\implies c = d)\n\t\t\\end{formula}\n\t\\end{axiomdescription}", "meta": {"hexsha": "05955278280aad1b6b4cf61a7049173610455663", "size": 4275, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/unusedaxioms.tex", "max_stars_repo_name": "VicdeJuan/tfg", "max_stars_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/unusedaxioms.tex", "max_issues_repo_name": "VicdeJuan/tfg", "max_issues_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/unusedaxioms.tex", "max_forks_repo_name": "VicdeJuan/tfg", "max_forks_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-21T12:44:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T11:14:52.000Z", "avg_line_length": 35.0409836066, "max_line_length": 433, "alphanum_fraction": 0.6580116959, "num_tokens": 1579, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.44267497007411116}}
{"text": "\\documentclass[]{report}\n\n\\usepackage{hyperref}\n\\usepackage{float}\n\\usepackage{needspace}\n\\usepackage{interval}\n\\usepackage{pgfplots}\n\\usepackage{neuralnetwork}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[a4paper, left=2.5cm, right=2.5cm, top=2cm, bottom=2cm]{geometry}\n\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    filecolor=magenta,      \n    urlcolor=black,\n}\n\n\\renewcommand{\\thesection}{\\Alph{section}}\n\\renewcommand{\\thesubsection}{\\arabic{subsection}}\n\\renewcommand{\\thesubsubsection}{(\\emph{\\alph{subsubsection}})}\n\n\\title{The math behind an artificial neural network}\n\\author{Hugo Lageneste}\n\\date{January 2020}\n\n\\begin{document}\n\n\\begingroup\n\\let\\cleardoublepage\\relax\n\\let\\clearpage\\relax\n\n\\tableofcontents\n\n\\needspace{6cm}\n\\[\\;\\]\n\n\\vfill\n\n\\endgroup\n\n\\chapter*{The math behind an artificial neural network}\n\n\\setcounter{section}{-1}\n\\section{Introduction}\n\n\\subsection{Application example}\n\n{Let's take an example to see how an ANN\\footnote{Artificial Neural Network} works.}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{tabular}{|l|c|c|r|}\n      \\hline\n      Obesity & Exercise & Smoking & Diabetic \\\\\n      \\hline\n      1 & 0 & 0 & 1 \\\\\n      0 & 1 & 0 & 0 \\\\\n      0 & 0 & 1 & 0 \\\\\n      1 & 1 & 0 & 1 \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Example of a set of persons with Obesity, Exercise, Smoking and Diabetic characteristics}\n\\end{figure}\n\n{In the precedent figure, the 1 stands for true and the 0 for false. We can observe that in this example, a person with diabetes is inevitably obese. What if we want a program which takes only in parameter those 4 examples and can predict with different examples if a person is diabetic or not?}\\\\\n\n{We can model this program as an ANN with 3 input neurons which represent the Obesity, Exercise and Smoking columns and a single output neuron which represents\nthe Diabetic column.}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{neuralnetwork}[height=3, nodespacing=15mm]\n        \\inputlayer[count=3, bias=false, title=Input layer]\n        \\outputlayer[count=1, title=Output layer]\n        \\linklayers\n    \\end{neuralnetwork}\n    \\caption{Diagram of the ANN to model the example}\n\\end{figure}\n\n\\subsection{Neural network operation}\n\\label{subsec:operation}\n\n{The input values will be inserted in the input neurons and the network will operate as a “function” to say if the person is diabetic or not. Each liaison between each neuron is a value called weight and\nis unique. And each neuron holds a specific value, calculated with the previous neuron values and the\nweights. The whole goal of the neural network is to find the correct weights to make the final predictions\nright.}\\\\\n\n{To make the weights right, we will proceed in different steps. First of all, the neural network will\ncompute the value of the output layer’s neurons named the prediction. Then, the network will make\nthe difference between the prediction and the actual output and will adjust the weights to make the\nprediction more accurate. This process will be repeated until the success rate is convenient.}\\\\\n\n{After the construction of the neural network, we will be able to send values like 1, 1 and 1 (so it means that the persons is obese, does exercise and smokes) and get an answer from the neural network which tells us that the person is diabetic.}\n\n\n\n\\section{Forward propagation}\n\n{As seen in the Introduction, each neuron holds a value contained between 0 and 1, calculated with the values of the previous neurons, the weights and a bias. We are going to see how these values are calculated.}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{neuralnetwork}[height=4, nodespacing=15mm]\n        \\newcommand{\\inputtext}[2]{$a^{(l-1)}_#2$}\n        \\newcommand{\\outputtext}[2]{$a^{(l)}_#2$}\n        \\inputlayer[count=3, bias=false, text=\\inputtext, title=Input layer]\n        \\outputlayer[count=1,  text=\\outputtext, title=Output layer]\n        \\linklayers[title=Weights $w_k$]\n    \\end{neuralnetwork}\n    \\caption{Diagram of a neural network, the exponent represents the index of the layer and the subscript the index of the neuron then $a$ is the value held in the neuron.}\n\\end{figure}\n\n{Let's create a notation, $z^{(l)}_1$ which is the bias added to the dot product of weights $w_k$ and values of the previous neurons $a^{(l-1)}_k$.}\n\n\\[{z^{(l)}_1=b^{(l)}_1+\\sum_{k=1}^{n_{(l-1)}} a^{(l-1)}_k w_k}\\]\n\n{In order to keep the values in the neurons between 0 and 1, we are going to use the sigmoid function which is defined on $\\interval[open]{0}{1}$, noted :}\n\\[\\sigma(x)=\\frac{1}{1+e^{-x}}\\]\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{tikzpicture}\n        \\begin{axis}[grid=major, xmax=6, ymax=1.1, samples=50, xlabel=$x$, ylabel=$\\sigma(x)$]\n          \\addplot[black, thin] (x,1/(1+e^(-x)));\n        \\end{axis}\n    \\end{tikzpicture}\n    \\caption{Graphical representation of the sigmoid function}\n\\end{figure}\n\n{Thus,}\n\n\\[a^{(l)}_1=\\sigma\\left(z^{(l)}_1\\right)\\]\n\\[a^{(l)}_1 \\in \\interval[open]{0}{1}\\]\n\n{This calculus can be too visualised with matrix}\n\n\\[a^{(l)}_1=\\sigma\\left(\\begin{bmatrix}w_1 & w_2 & w_3\\end{bmatrix}\\begin{bmatrix}a^{(l-1)}_1 \\\\ a^{(l-1)}_2 \\\\ a^{(l-1)}_3\\end{bmatrix}+\\begin{bmatrix}b^{(l)}_1\\end{bmatrix}\\right)\\]\n\n\\section{Back propagation}\n\n\\subsection{Cost function}\n\n{Let's take a simple example of a one-input-layer-one-output-layer-neural-network}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{neuralnetwork}[height=2, nodespacing=15mm]\n        \\newcommand{\\inputtext}[2]{$a^{(l-1)}$}\n        \\newcommand{\\outputtext}[2]{$a^{(l)}$}\n        \\inputlayer[count=1, bias=false, text=\\inputtext, title=Input layer]\n        \\outputlayer[count=1,  text=\\outputtext, title=Output layer]\n        \\linklayers[title=Weight $w$]\n    \\end{neuralnetwork}\n    \\caption{Diagram of the ANN to model the example of the cost function}\n    \\label{fig:simplenn}\n\\end{figure}\n\n{Once again,}\n\n\\[z^{(l)}=b+a^{(l-1)}w\\]\n\\[a^{(l)}=\\sigma\\left(z^{(l)}\\right)\\]\n\n{The goal is now to adjust the weights to make the prediction more accurate. Let's introduce the cost function which calculates the square difference between the prediction and the actual output $y$.}\n\n\\[C_1\\left(a^{(l)},y\\right)=\\left(a^{(l)}-y\\right)^2\\]\n\n{The smaller the cost function is, the more accurate the predictions are, mathematically the goal is to minimize the cost function.}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{tikzpicture}\n        \\begin{axis}[\n            xlabel=$a^{(l)}$, ylabel=$y$,\n        \tsmall,\n        ]\n        \\addplot3[\n        \tsurf,\n        \tdomain=-2:2,\n        \tdomain y=-1.3:1.3,\n        ] \n        \t{(x-y)^2};\n        \\end{axis}\n    \\end{tikzpicture}\n    \\caption{Cost function graphical representation of the neural network, figure \\ref{fig:simplenn}}\n\\end{figure}\n\n\\subsection{Gradient descent}\n\n{Now we will need to understand how sensitive the cost function is to small changes to $w_k$ because remember from \\ref{subsec:operation}, the goal is to adjust weights. Thus, we will determine the partial derivative of $C$ with respect to $w$ using the chain rule.}\n\n\\[{\\frac{\\partial C_1}{\\partial w}=\\frac{\\partial C_1}{\\partial a^{(l)}} \\frac{\\partial a^{(l)}}{\\partial z^{(l)}} \\frac{\\partial  z^{(l)}}{\\partial w}}\\]\n\n{Indeed,}\n\n\\[\\frac{\\partial C_1}{\\partial a^{(l)}}=2\\left(a^{(l)}-y\\right)\\]\n\\[\\frac{\\partial a^{(l)}}{\\partial z^{(l)}}=\\frac{\\partial \\sigma\\left(z^{(l)}\\right)}{\\partial z^{(l)}}=\\sigma\\prime\\left(z^{(l)}\\right)\\]\n\\[\\frac{\\partial  z^{(l)}}{\\partial w}=\\frac{\\partial  \\left(b+a^{(l-1)}w\\right)}{\\partial w}=a^{(l-1)}\\]\n\n{All together, it gives us}\n\n\\[\\frac{\\partial C_1}{\\partial w}=2\\left(a^{(l)}-y\\right) \\sigma\\prime\\left(z^{(l)}\\right) a^{(l-1)}\\]\n\n{We will use this formula to calculate the adjustments to make to the weights multiple times until the predictions are accurate.}\n\n\\[w=w+\\alpha \\frac{\\partial C_1}{\\partial w}\\]\n\n\\section{Complex example}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{neuralnetwork}[height=5, nodespacing=15mm]\n        \\newcommand{\\inputtext}[2]{$a^{(l-2)}_#2$}\n        \\newcommand{\\hiddentext}[2]{$a^{(l-1)}_#2$}\n        \\newcommand{\\outputtext}[2]{$a^{(l)}_#2$}\n        \\inputlayer[count=3, bias=false, text=\\inputtext, title=Input layer $a^{(l-1)}_k$]\n        \\hiddenlayer[count=4, bias=false, text=\\hiddentext]\n        \\linklayers[title={Weights $w^{(l-1)}_{jk}$}]\n        \\outputlayer[count=1,  text=\\outputtext, title=Output layer $a^{(l)}_j$]\n        \\linklayers[title={Weights $w^{(l)}_{jk}$}]\n    \\end{neuralnetwork}\n    \\caption{Diagram of a more complex ANN}\n\\end{figure}\n\n{We will model this problem with matrices.}\n\n\\subsection{Forward propagation}\n\n{First of all we are going to create a matrix for each weights' layer}\n\n\\[w^{(l-2)}=\\begin{bmatrix}\nw_{11} & w_{12} & w_{13} & w_{14}\\\\\nw_{21} & w_{22} & w_{23} & w_{24}\\\\\nw_{31} & w_{32} & w_{33} & w_{34}\\\\\n\\end{bmatrix}\\]\n\n\\[w^{(l-1)}=\\begin{bmatrix}\nw_{11}\\\\\nw_{21}\\\\\nw_{31}\\\\\nw_{41}\\\\\n\\end{bmatrix}\\]\n\n{A layer is represented by a $t$ by $k^{(l)}$ Matrix, where $t$ is the number of training examples and $k$ the number of nodes in a layer}\n\n\\[a^{(l-2)}=\\begin{bmatrix}\na^{(l-2)}_1 & a^{(l-2)}_2 & a^{(l-2)}_3 \\\\\n\\end{bmatrix}\\]\n\n{Then, to calculate the next layer's values we need to express $z$ to compute $a$.}\n\n\\[z^{(l)}=a^{(l-1)} \\cdot w^{(l)}+b^{(l-1)}\\]\n\\[a=\\sigma (z)\\]\n\n\\subsection{Back propagation}\n{Because we have now a hidden layer, we will need to express the partial derivative of $C$ with respect to $w^{(l)}$ couched in terms of $l$.}\\\\\n{The adjustments will take the following form}\n\\[w^{(l)}=w^{(l)}+\\alpha \\frac{\\partial C}{\\partial w^{(l)}}\\]\n{Here, $\\alpha$ represents the learning rate.}\\\\\n{Thus, we need to compute this derivative $\\frac{\\partial C}{\\partial w^{(l)}}$.}\n{Using the chain rule,}\n\\[\\frac{\\partial C}{\\partial w^{(l)}}=\\frac{\\partial C}{\\partial z^{(l)}} \\frac{\\partial z^{(l)}}{\\partial w^{(l)}}\\]\n{First of all let's compute $\\frac{\\partial z^{(l)}}{\\partial w^{(l)}}$}\n\\[\\frac{\\partial z^{(l)}}{\\partial w^{(l)}} = \\frac{\\partial}{\\partial w^{(l)}} \\left( a^{(l-1)} w^{(l)} + b^{(l-1)} \\right)=a^{(l-1)}\\]\n{Then, we'll compute $\\frac{\\partial C}{\\partial z^{(l)}}$ couched in terms of $z^{(l+1)}$ in order to model backpropagation in programming.}\n\\[\\frac{\\partial C}{\\partial z^{(l)}}=\\frac{\\partial C}{\\partial z^{(l+1)}}\\frac{\\partial z^{(l+1)}}{\\partial a^{(l)}}\\frac{\\partial a^{(l)}}{\\partial z^{(l)}}\\]\n\\[\\frac{\\partial z^{(l+1)}}{\\partial a^{(l)}}=\\frac{\\partial}{\\partial a^{(l)}} \\left(w^{(l+1)} a^{(l)} + b^{(l)}\\right)=w^{(l+1)}\\]\n\\[\\frac{\\partial a^{(l)}}{\\partial z^{(l)}}=\\frac{\\partial}{\\partial z^{(l)}} \\sigma \\left(z^{(l)}\\right)=\\sigma\\prime\\left(z^{(l)}\\right)\\]\n{Thus, after adjusting the terms to make dot products working we got}\n\\[\\frac{\\partial C}{\\partial z^{(l)}}=\\left(w^{(l+1)^{T}} \\cdot \\frac{\\partial C}{\\partial z^{(l+1)}} \\right) \\times \\sigma\\prime\\left(z^{(l)}\\right)\\]\n{And,}\n\\[\\frac{\\partial C}{\\partial w^{(l)}}=\\left(w^{(l+1)^{T}} \\cdot \\frac{\\partial C}{\\partial z^{(l+1)}} \\right) \\times \\sigma\\prime\\left(z^{(l)}\\right) \\times a^{(l-1)}\\]\n{As you can see here, to compute the adjustments for the weights you need the derivative of $C$ with respect to the next $z$ so we will need to calculate the derivative of $C$ with respect to $z$ for the last layer so we never run get out of the range.}\n{Here $L$ is the last layer}\n\\[\\frac{\\partial C}{\\partial z^{(L)}}=2(a^{(L)}-y) \\sigma\\prime\\left(z^{(L)}\\right)\\]\n\\[\\frac{\\partial C}{\\partial z^{(L)}}=2(a^{(L)}-y)\\sigma\\left(z^{(L)}\\right)\\left(1-\\sigma\\left(z^{(L)}\\right)\\right)\\]\n\\[\\frac{\\partial C}{\\partial z^{(L)}}=2(a^{(L)}-y)a^{(L)}\\left(1-a^{(L)}\\right)\\]\n{Here we have all the resources we need to build an artificial neural network.}\n\n\\end{document}", "meta": {"hexsha": "1fbbcead60dfaf3aa3d705239c1091f95d0603fa", "size": 11699, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "the-math-behind-an-artificial-neural-network.tex", "max_stars_repo_name": "jarulsamy/the-math-behind-an-artificial-neural-network", "max_stars_repo_head_hexsha": "4be0286fbd8fe4c606aba33d213bbb587e093915", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 110, "max_stars_repo_stars_event_min_datetime": "2020-02-28T21:10:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-22T15:42:40.000Z", "max_issues_repo_path": "the-math-behind-an-artificial-neural-network.tex", "max_issues_repo_name": "ananagame/the-math-behind-an-artificial-neural-network", "max_issues_repo_head_hexsha": "be620bf5af40b8d0708e7966ace6de770d871393", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-09T00:15:57.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-09T00:15:57.000Z", "max_forks_repo_path": "the-math-behind-an-artificial-neural-network.tex", "max_forks_repo_name": "ananagame/the-math-behind-an-artificial-neural-network", "max_forks_repo_head_hexsha": "be620bf5af40b8d0708e7966ace6de770d871393", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-03-08T10:25:07.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-30T19:50:57.000Z", "avg_line_length": 41.6334519573, "max_line_length": 297, "alphanum_fraction": 0.6599709377, "num_tokens": 3794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.4426749655677014}}
{"text": "\\documentclass{amsbook}\n\n\\usepackage{hyperref,url,amsmath,amssymb,proof,stmaryrd,tikz-cd,mathabx}\n\n\\newtheorem{theorem}{Theorem}[chapter]\n\\newtheorem{lemma}[theorem]{Lemma}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{xca}[theorem]{Exercise}\n\n\\theoremstyle{remark}\n\\newtheorem{remark}[theorem]{Remark}\n\n\\numberwithin{section}{chapter}\n\\numberwithin{equation}{chapter}\n\n\\makeindex\n\n\\begin{document}\n\n\\frontmatter\n\n\\title{Formal Reasoning About Programs}\n\n\\author{Adam Chlipala}\n\\address{MIT, Cambridge, MA, USA}\n\\email{adamc@csail.mit.edu}\n\n\\begin{abstract}\n  \\emph{Briefly}, this book is about an approach to bringing software engineering up to speed with more traditional engineering disciplines, providing a mathematical foundation for rigorous analysis of realistic computer systems. As civil engineers apply their mathematical canon to reach high certainty that bridges will not fall down, the software engineer should apply a different canon to argue that programs behave properly. As other engineering disciplines have their computer-aided-design tools, computer science has proof assistants, IDEs for logical arguments. We will learn how to apply these tools to certify that programs behave as expected.\n\n  \\emph{More specifically}: Introductions to two intertangled subjects: the Coq proof assistant, a tool for machine-checked mathematical theorem proving; and formal logical reasoning about the correctness of programs.\n\\end{abstract}\n\n\\maketitle\n\n\\newpage\n\nFor more information, see the book's home page:\n\n\\begin{center} \\url{http://adam.chlipala.net/frap/} \\end{center}\n\n\\thispagestyle{empty}\n\\mbox{}\\vfill\n\\begin{center}\n\nCopyright Adam Chlipala 2015-2017.\n\n\nThis work is licensed under a\nCreative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.\nThe license text is available at:\n\n\\end{center}\n\n\\begin{center} \\url{https://creativecommons.org/licenses/by-nc-nd/4.0/} \\end{center}\n\n\\newpage\n\n\\setcounter{page}{4}\n\n\\tableofcontents\n\n\\mainmatter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Why Prove the Correctness of Programs?}\n\nThe classic engineering disciplines all have their standard mathematical techniques that are applied to the design of any artifact, before it is deployed, to gain confidence about its safety, suitability for some purpose, and so on.\nThe engineers in a discipline more or less agree on what are ``the rules'' to be followed in vetting a design.\nThose rules are specified with a high degree of rigor, so that it isn't a matter of opinion whether a design is safe.\nWhy doesn't software engineering have a corresponding agreed-upon standard, whereby programmers convince themselves that their systems are safe, secure, and correct?\nThe concepts and tools may not quite be ready yet for broad adoption, but they have been under development for decades.\nThis book introduces one particular tool and a body of ideas for how to apply it to different tasks in program proof.\n\nAs this document is in a very early draft stage, no more will be said here, in favor of jumping right into the technical material.\nEventually, there will no doubt be some sort of historical overview here, as part of a general placing-in-context of the particular approach that will come next.\nThere will also be plenty of scholarly citations (here and throughout the book).\nIn this early version, you get to take the author's word for it that we are about to learn a promising approach!\n\nHowever, one overarching element of our strategy is important enough to deserve to be called out here.\nWe will study a variety of different approaches for formalizing what a program should do and for proving that a program does what it should.\nAt every step, we will pay close attention to the \\emph{common foundation} that underlies everything.\nFor one thing, we will be proving all of our theorems with the Coq proof assistant, a powerful framework for writing and machine-checking proofs.\nCoq itself is based on a relatively small set of core features, much like a well-designed programming language, and in both we build up increasingly sophisticated abstractions as libraries.\nThose features can be thought of as the core of all mathematical reasoning.\n\nWe will also apply a recipe specific to program proof.\nWhen we encounter a new challenge, to prove a new kind of property about a new kind of program, we will generally be considering four broad elements that appear in nearly all techniques.\n\n\\begin{itemize}\n  \\item \\index{encoding}\\textbf{Encoding.}\n    Every programming language has both \\index{syntax}\\emph{syntax}, which defines what programs look like, and \\index{semantics}\\emph{semantics}, which defines how programs behave when run.\n    Even when these elements seem obvious intuitively, we often find that there are surprisingly subtle choices to be made in defining syntax and semantics at the highest level of rigor.\n    Seemingly minor decisions can have big impacts on how smoothly our proofs go.\n\n  \\item \\textbf{Invariants.}\n    Nearly every theorem about a program is stated in terms of a \\index{transition system}\\emph{transition system}, with some set of states and a relation for stepping from one state to the next, moving forward in time.\n    Nearly every program proof also works by finding an \\index{invariant}\\emph{invariant} of a transition system, or a property that always holds of every state reachable from some starting state.\n    The concept of invariant is very close to being a direct reinterpretation of mathematical induction, that glue of every serious mathematical development, known and loved by all.\n\n  \\item \\index{abstraction}\\textbf{Abstraction.}\n    Often a transition system is too complex to analyze directly.\n    Instead, we \\emph{abstract} it with another transition system that is somehow more tractable, proving that the new system preserves all relevant properties of the original.\n\n  \\item \\index{modularity}\\textbf{Modularity.}\n    Similarly, when a transition system is too complex, we often break it into separate \\emph{modules} and use some well-behaved composition operators to reassemble them into the whole.\n    Often abstraction and modularity go together, as we decompose a system both \\index{horizontal decomposition}\\emph{horizontally} (i.e., with modularity), splitting it into more manageable parts, and \\index{vertical decomposition}\\emph{vertically} (i.e., with abstraction), simplifying parts in ways that preserve key properties.\n    We can even alternate between strategies, breaking a system into parts, abstracting one as a simpler part, further decomposing that part into pieces, and so on.\n\\end{itemize}\n\n\\newcommand{\\encoding}[0]{\\marginpar{\\fbox{\\textbf{Encoding}}}}\n\nIn the course of the book, we will never quite define any of these meta-techniques in complete formality.\nInstead, we'll meet many examples of each, called out by eye-catching margin notes.\nGeneralizing from the examples should help the reader start developing an intuition for when to use each element and for the common design patterns that apply.\n\nThe core subject matter of the book is often grouped under traditional disciplinary headers like \\index{semantics}\\emph{semantics}, \\index{programming-languages theory}\\emph{programming-languages theory}, \\index{formal methods}\\emph{formal methods}, and \\index{verification}\\emph{verification}.\nOften these different traditions have their own competing terminology for shared concepts.\nWe'll follow one particular set of unified terminology and notation, cherry-picked from the conventions of different communities.\nThere really is a huge amount of commonality across everything that we'll study, so we don't want to distract by constantly translating between notations.\nIt is quite important to be literate in the standard notational conventions, which are almost always implemented with \\index{\\LaTeX{}}\\LaTeX{}, and we stick entirely to that kind of notation in this book.\nHowever, we follow another, much less usual convention: while we give theorem and lemma statements, we rarely give their proofs.\nThe reason is that the author and many other researchers today feel that proofs on paper have outlived their usefulness.\nInstead, the proofs are all found in the parallel world of the accompanying Coq source code.\n\nThat is, each chapter of this book has a corresponding Coq source file, distributed with the general book source code.\nThe Coq sources are heavily commented and may even, in many cases, be feasible to read without also reading the book chapters.\nMore importantly, the Coq sources aren't just meant to be \\emph{read}.\nThey are meant to be \\emph{executed}.\nWe suggest stepping through them interactively, seeing intermediate states of proofs as appropriate.\nThe book proper can be read without the Coq sources, to learn the standard background material of program proof; and the Coq sources can be read without the book proper, to learn a particular concrete realization of those ideas.\nHowever, they go better together.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Formalizing Program Syntax}\\label{syntax}\n\n\\section{Concrete Syntax}\n\nThe definition of a program starts with the definition of a programming language, and the definition of a programming language starts with its \\emph{syntax}\\index{syntax}, which covers which sorts of phrases are basically well-formed.\nIn the next chapter, we turn to \\emph{semantics}\\index{semantics}, which, in the course of saying what programs \\emph{mean}, may impose further validity conditions.\nTurning to examples, let's start with \\emph{concrete syntax}\\index{concrete syntax}, which decrees which sequences of characters are acceptable.\nFor a simple language of arithmetic expressions, we might accept the following strings as valid.\n$$\\begin{array}{l}\n  3 \\\\\n  x \\\\\n  3 + x \\\\\n  y * (3 + x)\n\\end{array}$$\n\nPlenty of other strings might be invalid, like these.\n$$\\begin{array}{l}\n  1 + + \\; 2 \\\\\n  x \\; y \\; z\n\\end{array}$$\n\nRather than appeal to our intuition about grade-school arithmetic, we prefer to formalize concrete syntax with a \\emph{grammar}\\index{grammar}, following a style known as \\emph{Backus-Naur Form (BNF)}\\index{Backus-Naur Form}\\index{BNF}.\nWe have a set of \\emph{nonterminals}\\index{nonterminal} (e.g., $e$ below), standing for sets of allowable strings.\nSome are defined by appeal to existing sets, as below, when we define constants $n$ in terms of the well-known set $\\mathbb N$\\index{N@$\\mathbb N$} of natural numbers\\index{natural numbers} (nonnegative integers).\n\\encoding\n$$\\begin{array}{rrcl}\n  \\textrm{Constants} & n &\\in& \\mathbb N \\\\\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Expressions} & e &::=& n \\mid x \\mid e + e \\mid e \\times e\n\\end{array}$$\n\nTo interpret the grammar in plain English: we assume sets of constants and variables, based on well-known sets of natural numbers and strings, respectively.\nWe then define expressions to include constants, variables, addition, and multiplication.\nCrucially, the last two cases are specified \\emph{recursively}: we show how to build bigger expressions out of smaller ones.\n\nIncidentally, we're already seeing how many different formal notations creep into the discussion of formal program proofs.\nAll of this content is typeset in \\LaTeX{}\\index{\\LaTeX{}}, and it may be helpful to consult the book sources, to see how it's all done.\n\nThroughout the subject, one of our most crucial tools will be \\emph{inductive definitions}\\index{inductive definition}, explaining how to build up bigger sets from smaller ones.\nThe recursive nature of the grammar above is implicitly giving an inductive definition.\nA more general notation for inductive definitions provides a series of \\emph{inference rules}\\index{inference rules} that define a set.\nFormally, the set is defined to be \\emph{the smallest one that satisfies all the rules}.\nEach rule has \\emph{premises}\\index{premise} and a \\emph{conclusion}\\index{conclusion}.\nWe illustrate with four rules that together are equivalent to the BNF grammar above, for defining a set $\\mathsf{Exp}$ of expressions.\n\\encoding\n$$\\infer{n \\in \\mathsf{Exp}}{\n  n \\in \\mathbb N\n}\n\\quad \\infer{x \\in \\mathsf{Exp}}{\n  x \\in \\mathsf{Strings}\n}\n\\quad \\infer{e_1 + e_2 \\in \\mathsf{Exp}}{\n  e_1 \\in \\mathsf{Exp}\n  & e_2 \\in \\mathsf{Exp}\n}\n\\quad \\infer{e_1 \\times e_2 \\in \\mathsf{Exp}}{\n  e_1 \\in \\mathsf{Exp}\n  & e_2 \\in \\mathsf{Exp}\n}$$\n\nThe general reading of an inference rule is: \\textbf{if} all the facts above the horizontal line are true, \\textbf{then} the fact below the line is true, too.\nThe rule implicitly needs to hold for \\emph{all} values of the \\emph{metavariables}\\index{metavariable} (like $n$ and $e_1$) that appear within it; we can model them more explicitly with a sort of top-level universal quantification.\nNewcomers to semantics often react negatively to seeing this style of definition, but very quickly it becomes apparent as a remarkably compact notation for expressing many concepts.\nThink of it as a domain-specific programming language for mathematical definitions, an analogy that becomes quite concrete in the associated Coq code!\n\n\\section{Abstract Syntax}\n\nAfter that brief interlude with concrete syntax, we now drop all formal treatment of it, for the rest of the book!\nInstead, we concern ourselves with \\emph{abstract syntax}\\index{abstract syntax}, the real heart of language definitions.\nNow programs are \\emph{abstract syntax trees}\\index{abstract syntax tree} (\\emph{ASTs}\\index{AST}), corresponding to inductive type definitions in Coq or algebraic datatype\\index{algebraic datatype} definitions in Haskell\\index{Haskell}.\nSuch types can be defined by enumerating their \\emph{constructor}\\index{constructor} functions with types.\n\\encoding\n\\begin{eqnarray*}\n  \\mathsf{Const} &:& \\mathbb{N} \\to \\mathsf{Exp} \\\\\n  \\mathsf{Var} &:& \\mathsf{Strings} \\to \\mathsf{Exp} \\\\\n  \\mathsf{Plus} &:& \\mathsf{Exp} \\times \\mathsf{Exp} \\to \\mathsf{Exp} \\\\\n  \\mathsf{Times} &:& \\mathsf{Exp} \\times \\mathsf{Exp} \\to \\mathsf{Exp}\n\\end{eqnarray*}\n\nNote that the ``$\\times$'' here is not the multiplication operator of concrete syntax, but rather the Cartesian-product operator\\index{Cartesian product} of set theory, to indicate a type of pairs!\n\nSuch a list of constructors defines the set $\\mathsf{Exp}$ to contain exactly those terms that can be built up with the constructors.\nIn inference-rule notation:\n\\encoding\n$$\\infer{\\mathsf{Const}(n) \\in \\mathsf{Exp}}{\n  n \\in \\mathbb N\n}\n\\quad \\infer{\\mathsf{Var}(x) \\in \\mathsf{Exp}}{\n  x \\in \\mathsf{Strings}\n}\n\\quad \\infer{\\mathsf{Plus}(e_1, e_2) \\in \\mathsf{Exp}}{\n  e_1 \\in \\mathsf{Exp}\n  & e_2 \\in \\mathsf{Exp}\n}\n\\quad \\infer{\\mathsf{Times}(e_1, e_2) \\in \\mathsf{Exp}}{\n  e_1 \\in \\mathsf{Exp}\n  & e_2 \\in \\mathsf{Exp}\n}$$\n\nActually, semanticists get tired of writing such verbose descriptions, so proofs on paper tend to use exactly the sort of notation that we associated with concrete syntax.\nThe trick is mental desugaring of the concrete-syntax notation into abstract syntax!\nWe will generally not dwell on the particularities of that process.\nInstead, we repeatedly illustrate it by example, using Coq code that starts with abstract syntax, accompanied by \\LaTeX{}-based ``code'' in this book that applies concrete syntax freely.\n\nAbstract syntax is handy for writing \\emph{recursive definitions}\\index{recursive definition} of functions.\nHere is one in the clausal\\index{clausal function definition} style of Haskell\\index{Haskell}.\n\\begin{eqnarray*}\n  \\mathsf{size}(\\mathsf{Const}(n)) &=& 1 \\\\\n  \\mathsf{size}(\\mathsf{Var}(x)) &=& 1 \\\\\n  \\mathsf{size}(\\mathsf{Plus}(e_1, e_2)) &=& 1 + \\mathsf{size}(e_1) + \\mathsf{size}(e_2) \\\\\n  \\mathsf{size}(\\mathsf{Times}(e_1, e_2)) &=& 1 + \\mathsf{size}(e_1) + \\mathsf{size}(e_2)\n\\end{eqnarray*}\n\nIt is important that we include \\emph{one clause per constructor of the inductive type}.\nOtherwise, the function would not be \\emph{total}\\index{total function}.\nWe also need to be careful to ensure \\emph{termination}\\index{termination of recursive definitions}, by making recursive calls only on the arguments of the constructors.\nThis termination criterion, adopted by Coq, is called \\emph{primitive recursion}\\index{primitive recursion}.\n\n\\newcommand{\\size}[1]{{\\left \\lvert #1 \\right \\rvert}}\n\nIt is also common to associate a recursive definition with a new notation.\nFor example, we might prefer to write $\\size{e}$ for $\\mathsf{size}(e)$, as follows.\n\\begin{eqnarray*}\n  \\size{\\mathsf{Const}(n)} &=& 1 \\\\\n  \\size{\\mathsf{Var}(x)} &=& 1 \\\\\n  \\size{\\mathsf{Plus}(e_1, e_2)} &=& 1 + \\size{e_1} + \\size{e_2} \\\\\n  \\size{\\mathsf{Times}(e_1, e_2)} &=& 1 + \\size{e_1} + \\size{e_2}\n\\end{eqnarray*}\n\n\\newcommand{\\depth}[1]{{\\left \\lceil #1 \\right \\rceil}}\n\nLet's continue to exercise our creative license and write $\\depth{e}$ for the \\emph{depth} of $e$, that is, the length of the longest downward path from the syntax-tree root to any leaf.\n\\begin{eqnarray*}\n  \\depth{\\mathsf{Const}(n)} &=& 1 \\\\\n  \\depth{\\mathsf{Var}(x)} &=& 1 \\\\\n  \\depth{\\mathsf{Plus}(e_1, e_2)} &=& 1 + \\max(\\depth{e_1}, \\depth{e_2}) \\\\\n  \\depth{\\mathsf{Times}(e_1, e_2)} &=& 1 + \\max(\\depth{e_1}, \\depth{e_2})\n\\end{eqnarray*}\n\n\n\\section{Structural Induction Principles}\n\nThe main reason to prefer abstract syntax is that, while strings of text \\emph{seem} natural and simple to our human brains, they are really a lot of trouble to treat in complete formality.\nInductive trees are much nicer to manipulate.\nConsidering the name, it's probably not surprising that the main thing we want to do on them is \\emph{induction}\\index{induction}, an activity most familiar in the form of \\emph{mathematical induction}\\index{mathematical induction} over the natural numbers.\nIn this book, we will not dwell on many proofs about natural numbers, instead presenting the more general and powerful idea of \\emph{structural induction}\\index{structural induction} that subsumes mathematical induction in a formal sense, based on viewing the natural numbers as one simple inductively defined set.\n\nThere is a general recipe to go from an inductive definition to its associated induction principle.\nWhen we define set $S$ inductively, we gain an induction principle for proving that some predicate $P$ holds for all elements of $S$.\nTo make this conclusion, we must discharge one proof obligation per rule of the inductive definition.\nRecall our last rule-based definition above, for the abstract syntax of $\\mathsf{Exp}$.\nTo derive an $\\mathsf{Exp}$ structural induction principle, we produce a new set of rules, cloning each rule with two key modifications:\n\\begin{enumerate}\n  \\item Replace each conclusion, of the form $E \\in S$, with a conclusion $P(E)$.  That is, the obligations involve \\emph{showing} that $P$ holds of certain terms.\n  \\item For each premise $E \\in S$, add a companion premise $P(E)$.  That is, the obligation allows \\emph{assuming} that $P$ holds of certain terms.  Each such assumption is called an \\emph{inductive hypothesis}\\index{inductive hypothesis} (\\emph{IH}\\index{IH}).\n\\end{enumerate}\n\nThat mechanical procedure derives the following four proof obligations, associated with an inductive proof that $\\forall x \\in \\mathsf{Exp}. \\; P(x)$.\n$$\\infer{P(\\mathsf{Const}(n))}{\n  n \\in \\mathbb N\n}\n\\quad \\infer{P(\\mathsf{Var}(x))}{\n  x \\in \\mathsf{Strings}\n}$$\n$$\\quad \\infer{P(\\mathsf{Plus}(e_1, e_2))}{\n  e_1 \\in \\mathsf{Exp}\n  & P(e_1)\n  & e_2 \\in \\mathsf{Exp}\n  & P(e_2)\n}\n\\quad \\infer{P(\\mathsf{Times}(e_1, e_2))}{\n  e_1 \\in \\mathsf{Exp}\n  & P(e_1)\n  & e_2 \\in \\mathsf{Exp}\n  & P(e_2)\n}$$\n\nIn other words, to establish $\\forall x \\in \\mathsf{Exp}. \\; P(x)$, we need to prove that each of these inference rules is valid.\n\nTo see induction in action, we prove a theorem giving a sanity check on our two recursive definitions from earlier: depth can never exceed size.\n\\begin{theorem}\n  For all $e \\in \\mathsf{Exp}$, $\\depth{e} \\leq \\size{e}$.\n\\end{theorem}\n\\begin{proof}\n  By induction on the structure of $e$.\n\\end{proof}\n\nThat sort of minimalist proof often surprises and frustrates newcomers.\nOur position here is that proof checking is an activity fit for machines, not people, so we will leave out gory details, which are to be found in the accompanying Coq code, for this theorem and many others associated with this chapter.\nActually, even published proofs on paper tend to use ``proofs'' as brief as the one above, relying on the reader's experience to ``fill in the blanks''!\nUnsurprisingly, fairly often there are logical errors in such arguments, leading to acceptance of bogus theorems.\nFor that reason, we stick to machine-checked proofs here, using the book chapters to introduce concepts, reasoning principles, and statements of key theorems and lemmas.\n\n\\section{\\label{decidable}Decidable Theories}\n\nWe do, however, need to get all the proof details filled in somehow.\nOne of the most convenient cases is when a proof goal fits into some \\emph{decidable theory}\\index{decidable theory}.\nWe follow the sense from computability theory\\index{computability theory}, where we consider some \\emph{decision problem}\\index{decision problem}, as a (usually infinite) set $F$ of formulas and some subset $T \\subseteq F$ of \\emph{true} formulas, possibly considering only those provable using some limited set of inference rules.\nThe decision problem is \\emph{decidable} if and only if there exists some always-terminating program that, when passed some $f \\in F$ as input, returns ``true'' if and only if $f \\in T$.\nDecidability of theories is handy because, whenever our goal belongs to the $F$ set of a decidable theory, we can discharge the goal automatically by running the deciding program that must exist.\n\nOne common decidable theory is \\emph{linear arithmetic}\\index{linear arithmetic}, whose $F$ set is generated by the following grammar as $\\phi$.\n$$\\begin{array}{rrcl}\n  \\textrm{Constants} & n &\\in& \\mathbb Z \\\\\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Terms} & e &::=& x \\mid n \\mid e + e \\mid e - e \\\\\n  \\textrm{Propositions} & \\phi &::=& e = e \\mid e < e \\mid \\neg \\phi \\mid \\phi \\land \\phi\n\\end{array}$$\n\nThe arithmetic terms used here are \\emph{linear} in the same sense as \\emph{linear algebra}\\index{linear algebra}: we never multiply together two terms containing variables.\nActually, multiplication is prohibited outright, but we allow multiplication by a constant as an abbreviation (logically speaking) for repeated addition.\nPropositions are formed out of equality and less-than tests on terms, and we also have the Boolean negation (``not'') operator $\\neg$ and conjunction (``and'') operator $\\land$.\nThis set of propositional\\index{propositional logic} operators is enough to encode the other usual inequality and propositional operators, so we allow them, too, as convenient shorthands.\n\nUsing decidable theories in a proof assistant like Coq, it is important to understand how a theory may apply to formulas that don't actually satisfy its grammar literally.\nFor instance, we may want to prove $f(x) - f(x) = 0$, for some fancy function $f$ well outside the grammar above.\nHowever, we only need to introduce a new variable $y$, defined with the equation $y = f(x)$, to arrive at a new goal $y - y = 0$.\nA linear-arithmetic procedure makes short work of this goal, and we may then derive the original goal by substituting back in for $y$.\nCoq's tactics based on decidable theories do all that hard work for us.\n\n\\medskip\n\nAnother important decidable theory is of \\emph{equality with uninterpreted functions}\\index{theory of equality with uninterpreted functions}.\n$$\\begin{array}{rrcl}\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Functions} & f &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Terms} & e &::=& x \\mid f(e, \\ldots, e) \\\\\n  \\textrm{Propositions} & \\phi &::=& e = e \\mid \\neg \\phi \\mid \\phi \\land \\phi\n\\end{array}$$\n\nIn this theory, we know nothing about the detailed properties of the variables or functions that we use.\nInstead, we must reason solely from the basic properties of equality:\n$$\\infer[\\mathsf{Reflexivity}]{e = e}{}\n\\quad \\infer[\\mathsf{Symmetry}]{e_1 = e_2}{\n  e_2 = e_1\n}\n\\quad \\infer[\\mathsf{Transitivity}]{e_1 = e_2}{\n  e_1 = e_3\n  & e_3 = e_2\n}$$\n$$\\infer[\\mathsf{Congruence}]{f(e_1, \\ldots, e_n) = f'(e'_1, \\ldots, e'_n)}{\n  f = f'\n  & e_1 = e'_1\n  & \\ldots\n  & e_n = e'_n\n}$$\n\n\\medskip\n\nAs one more example of a decidable theory, consider the algebraic structure of \\emph{semirings}\\index{semirings}, which may profitably be remembered as ``types that act like natural numbers.''\nA semiring is any set containing two elements notated 0 and 1, closed under two binary operators notated $+$ and $\\times$.\nThe notations are suggestive, but in fact we have free reign in choosing the set, elements, and operators, so long as the following axioms\\footnote{The equations are taken almost literally from \\url{https://en.wikipedia.org/wiki/Semiring}.} are satisfied:\n\\begin{eqnarray*}\n  (a + b) + c &=& a + (b + c) \\\\\n  0 + a &=& a \\\\\n  a + 0 &=& a \\\\\n  a + b &=& b + a \\\\\n  (a \\times b) \\times c &=& a \\times (b \\times c) \\\\\n  1 \\times a &=& a \\\\\n  a \\times 1 &=& a \\\\\n  a \\times (b + c) &=& (a \\times b) + (a \\times c) \\\\\n  (a + b) \\times c &=& (a \\times c) + (b \\times c) \\\\\n  0 \\times a &=& 0 \\\\\n  a \\times 0 &=& 0\n\\end{eqnarray*}\n\nThe formal theory is then as follows, where we consider as ``true'' only those equalities that follow from the axioms.\n$$\\begin{array}{rrcl}\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Terms} & e &::=& x \\mid e + e \\mid e \\times e \\\\\n  \\textrm{Propositions} & \\phi &::=& e = e\n\\end{array}$$\n\nNote how the applicability of the semiring theory is incomparable to the applicability of the linear-arithmetic theory.\nThat is, while some goals are provable via either, some are provable only via the semiring theory and some provable only by linear arithmetic.\nFor instance, by the semiring theory, we can prove $x(y + z) = xy + xz$, while linear arithmetic can prove $x - x = 0$.\n\n\\section{Simplification and Rewriting}\n\nWhile we leave most proof details to the accompanying Coq code, it does seem important to introduce two key principles that are often implicit in proofs on paper.\n\nThe first is \\emph{algebraic simplification}\\index{algebraic simplification}, where we apply the defining equations of a recursive definition to simplify a goal.\nFor example, recall that our definition of expression size included this clause.\n\\begin{eqnarray*}\n  \\size{\\mathsf{Plus}(e_1, e_2)} &=& 1 + \\size{e_1} + \\size{e_2}\n\\end{eqnarray*}\nNow imagine that we are trying to prove this formula.\n$$\\size{\\mathsf{Plus}(e, \\mathsf{Const}(7))} = 2 + \\size{e}$$\nWe may apply the defining equation to rewrite into a different formula, where we have essentially pushed the definition of $\\size{\\cdot}$ through the $\\mathsf{Plus}$.\n$$1 + \\size{e} + \\size{\\mathsf{Const}(7)} = 2 + \\size{e}$$\nAnother application of a different defining equation, this time for $\\mathsf{Const}$, takes us to here.\n$$1 + \\size{e} + 1 = 2 + \\size{e}$$\nFrom here, the goal follows by linear arithmetic.\n\n\\medskip\n\nSuch a proof establishes a theorem $\\forall e \\in \\mathsf{Exp}. \\; \\size{\\mathsf{Plus}(e, \\mathsf{Const}(7))} = 2 + \\size{e}$.\nWe may use already-proved theorems via a more general \\emph{rewriting}\\index{rewriting} mechanism, applying whenever we know some quantified equality.\nWithin a new goal we are proving, we find some subterm that matches the lefthand side of that equality, after we choose the proper values of the quantified variables.\nThe process of finding those values automatically is called \\emph{unification}\\index{unification}.\nRewriting enables us to take the subterm we found and replace it with the righthand side of the equation.\n\nAs an example, assume that, for some $P$, we know $P(2 + \\size{\\mathsf{Var}(x)})$ and are trying to prove $P(\\size{\\mathsf{Plus}(\\mathsf{Var}(x), \\mathsf{Const}(7))})$.\nWe may use our earlier fact to rewrite the argument of $P$ in what we are trying to show, so that it now matches the argument from what we already know, at which point the proof is trivial to finish.\nHere, unification found the assignment $e = \\mathsf{Var}(x)$.\n\n\\medskip\n\n\\encoding\n\\label{metalanguage}\nWe close the chapter with an important note on terminology.\nA formula like $P(\\size{\\mathsf{Plus}(\\mathsf{Var}(x), \\mathsf{Const}(7))})$ combines several levels of notation.\nWe consider that we are doing our mathematical reasoning in some \\emph{metalanguage}\\index{metalanguage}, which is often applicable to a wide variety of proof tasks.\nWe also happen to be applying it here to reason about some \\emph{object language}\\index{object language}, a programming language whose syntax is defined formally, here the language of arithmetic expressions.\nWe have $x$ as a variable of the metalanguage, while $\\mathsf{Var}(x)$ is a variable expression of the object language.\nIt is difficult to use English to explain the distinction between the two in complete formality, but be on the lookout for places where formulas mix concepts of the metalanguage and object language!\nThe general patterns should soon become clear, as they are somehow already familiar to us from natural-language sentences like:\n\\begin{quote}\n  The wise man said, ``it is time to prove some theorems.''\n\\end{quote}\nThe quoted remark could just as well be in Spanish instead of English, in which case we have two languages nested in a nontrivial way.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Data Abstraction}\\label{adt}\n\nAll of the fully formal proofs in this book are worked out only in associated Coq code.\nTherefore, before proceeding to more topics in program semantics and proof, it is important to develop some basic Coq competence.\nSeveral heavily commented examples files are associated with this crucial point in the book.\nWe won't discuss details of Coq proving in this document, outside Appendix \\ref{coqref}.\nHowever, one of the possibilities shown off in the Coq code is worth drawing attention to, as a celebrated semantics idea in its own right, though we don't yet connect it to formalized syntax of programming languages.\nThat idea is \\emph{data abstraction}\\index{data abstraction}, one of the most central ideas in program structuring.\nLet's consider the mathematical meaning of \\emph{encapsulation}\\index{encapsulation} in data structures.\n\n\\section{Algebraic Interfaces for Abstract Data Types}\n\n\\newcommand{\\mt}[1]{\\mathsf{#1}}\n\nConsider the humble queue\\index{queues}, a classic data structure that allows us to enqueue data elements and then dequeue them in the order received.\nPerhaps surprisingly, there is already some complexity in efficient queue implementation.\nSo-called \\emph{client code}\\index{client code} that relies on queues shouldn't need to know about that complexity, though.\nWe should be able to formulate ``queue'' as an \\emph{abstract data type}\\index{abstract data type}, hiding implementation details.\nIn the setting of pure functional programming, as in Coq, here is our first cut at such a data type, as a set of types and operations, somewhat reminiscent of e.g. interfaces\\index{interface} in Java\\index{Java}.\nType $\\mt{t}(\\alpha)$ stands for queues holding data values in some type $\\alpha$.\n\n\\begin{eqnarray*}\n  \\mt{t}(\\alpha) &:& \\mt{Set} \\\\\n  \\mt{empty} &:& \\mt{t}(\\alpha) \\\\\n  \\mt{enqueue} &:& \\mt{t}(\\alpha) \\times \\alpha \\to \\mt{t}(\\alpha) \\\\\n  \\mt{dequeue} &:& \\mt{t}(\\alpha) \\rightharpoonup \\mt{t}(\\alpha) \\times \\alpha\n\\end{eqnarray*}\n\nA few notational conventions of note:\nWe declare that $\\mt{t}(\\alpha)$ is a type by assigning it the type $\\mt{Set}$, which itself contains all the normal types of programming.\nAn empty queue exists for any $\\alpha$, and enqueue and dequeue operations are also available for any $\\alpha$.\nThe type of $\\mt{dequeue}$ indicates function partiality\\index{partial function} by the arrow $\\rightharpoonup$: dequeuing yields no answer for an empty queue.\nFor partial function $f : A \\rightharpoonup B$, we indicate lack of a mapping for $x \\in A$ by writing $f(x) = \\cdot$.\n\nIn normal programming, we stop at this level of detail in defining an abstract data type.\nHowever, when we're after formal correctness proofs, we must enrich data types with \\emph{specifications}\\index{specifications} or ``specs.''\\index{specs}  \nOne prominent spec style is \\emph{algebraic}\\index{algebraic specifications}: write out a set of \\emph{laws}, quantified equalities that use the operations of the data type.\nFor queues, here are two reasonable laws.\n\n$$\\begin{array}{l}\n  \\mt{dequeue}(\\mt{empty}) = \\cdot \\\\\n  \\forall q. \\; \\mt{dequeue}(q) = \\cdot \\Rightarrow q = \\mt{empty} \\\\\n\\end{array}$$\n\nActually, the inference-rule notation from last chapter also makes algebraic laws more readable, so here is a restatement.\n\n$$\\infer{\\mt{dequeue}(\\mt{empty}) = \\cdot}{}\n\\quad \\infer{q = \\mt{empty}}{\\mt{dequeue}(q) = \\cdot}$$\n\nOne more rule suffices to give a complete characterization of behavior, with the familiar math notation for piecewise functions\\index{piecewise functions}.\n\n$$\\infer{\\mt{dequeue}(\\mt{enqueue}(q, x)) = \\begin{cases}\n    (\\mt{empty}, x), & \\mt{dequeue}(q) = \\cdot \\\\\n    (\\mt{enqueue}(q', x), y), & \\mt{dequeue}(q) = (q', y)\n  \\end{cases}}{}$$\n\n\\newcommand{\\concat}[2]{#1 \\bowtie #2}\n\nNow several implementations of this functionality are possible.\nHere's one of the two ``obvious'' ones, where we enqueue to list fronts and dequeue from list backs.\nWe write $\\mt{list}(\\alpha)$ for the type of lists\\index{lists} with data elements from $\\alpha$, with $\\concat{\\ell_1}{\\ell_2}$ for concatenation of lists $\\ell_1$ and $\\ell_2$, and with comma-separated lists inside square brackets for list literals.\n\\begin{eqnarray*}\n  \\mt{t(\\alpha)} &=& \\mt{list}(\\alpha) \\\\\n  \\mt{empty} &=& [] \\\\\n  \\mt{enqueue}(q, x) &=& \\concat{[x]}{q} \\\\\n  \\mt{dequeue}([]) &=& \\cdot \\\\\n  \\mt{dequeue}(\\concat{[x]}{q}) &=& ([], x)\\textrm{, when $\\mt{dequeue}(q) = \\cdot$.} \\\\\n  \\mt{dequeue}(\\concat{[x]}{q}) &=& (\\concat{[x]}{q'}, y)\\textrm{, when $\\mt{dequeue}(q) = (q', y)$.}\n\\end{eqnarray*}\n\nThere is also a dual implementation where we enqueue to list backs and dequeue from list fronts.\n\\begin{eqnarray*}\n  \\mt{t(\\alpha)} &=& \\mt{list}(\\alpha) \\\\\n  \\mt{empty} &=& [] \\\\\n  \\mt{enqueue}(q, x) &=& \\concat{q}{[x]} \\\\\n  \\mt{dequeue}([]) &=& \\cdot \\\\\n  \\mt{dequeue}(\\concat{[x]}{q}) &=& (q, x)\n\\end{eqnarray*}\n\nProofs of the algebraic laws, for both implementations, appear in the associated Coq code.\nBoth versions actually take quadratic time in practice, assuming concatenation takes time linear in the length of its first argument.\nThere is a famous, more clever implementation that achieves amortized\\index{amortized time} constant time (linear time to run a whole sequence of operations), but we will need to expand our algebraic style to accommodate it.\n\n\n\\section{Algebraic Interfaces with Custom Equivalence Relations}\n\nWe find it useful to extend the base interface of queues with a new, mathematical ``operation'':\n\\begin{eqnarray*}\n  \\mt{t}(\\alpha) &:& \\mt{Set} \\\\\n  \\mt{empty} &:& \\mt{t}(\\alpha) \\\\\n  \\mt{enqueue} &:& \\mt{t}(\\alpha) \\times \\alpha \\to \\mt{t}(\\alpha) \\\\\n  \\mt{dequeue} &:& \\mt{t}(\\alpha) \\rightharpoonup \\mt{t}(\\alpha) \\times \\alpha \\\\\n  \\mt{\\approx} &:& \\mathcal P(\\mt{t}(\\alpha) \\times \\mt{t}(\\alpha))\n\\end{eqnarray*}\n\nWe use the ``powerset''\\index{powerset} operation $\\mathcal P$ to indicate that $\\approx$ is a \\emph{binary relation}\\index{binary relation} over queues (of the same type).\nOur intention is that $\\approx$ be an \\emph{equivalence relation}, as formalized by the following laws that we add.\n$$\\infer[\\mathsf{Reflexivity}]{a \\approx a}{}\n\\quad \\infer[\\mathsf{Symmetry}]{a \\approx b}{b \\approx a}\n\\quad \\infer[\\mathsf{Transitivity}]{a \\approx c}{a \\approx b & b \\approx c}$$\n\nNow we rewrite the original laws to use $\\approx$ instead of equality.\nWe implicitly lift $\\approx$ to apply to results of the partial function $\\mt{dequeue}$: nonexistent results $\\cdot$ are related, and existent results $(q_1, x_1)$ and $(q_2, x_2)$ are related iff $q_1 \\approx q_2$ and $x_1 = x_2$.\n$$\\infer{\\mt{dequeue}(\\mt{empty}) = \\cdot}{}\n\\quad \\infer{q \\approx \\mt{empty}}{\\mt{dequeue}(q) = \\cdot}$$\n\n$$\\infer{\\mt{dequeue}(\\mt{enqueue}(q, x)) \\approx \\begin{cases}\n    (\\mt{empty}, x), & \\mt{dequeue}(q) = \\cdot \\\\\n    (\\mt{enqueue}(q', x), y), & \\mt{dequeue}(q) = (q', y)\n  \\end{cases}}{}$$\n\nWhat's the payoff from this reformulation?\nWell, first, it passes the sanity check that the two queue implementations from the last section comply, with $\\approx$ instantiated as simple equality.\nHowever, we may now also handle the classic \\emph{two-stack queue}\\index{two-stack queue}.\nHere is its implementation, relying on list-reversal function $\\mt{rev}$ (which takes linear time).\n\\begin{eqnarray*}\n  \\mt{t(\\alpha)} &=& \\mt{list}(\\alpha) \\times \\mt{list}(\\alpha) \\\\\n  \\mt{empty} &=& ([], []) \\\\\n  \\mt{enqueue}((\\ell_1, \\ell_2), x) &=& (\\concat{[x]}{\\ell_1}, \\ell_2) \\\\\n  \\mt{dequeue}(([], [])) &=& \\cdot \\\\\n  \\mt{dequeue}((\\ell_1, \\concat{[x]}{\\ell_2})) &=& ((\\ell_1, \\ell_2), x) \\\\\n  \\mt{dequeue}((\\ell_1, [])) &=& (([], q'_1), x)\\textrm{, when $\\mt{rev}(\\ell_1) = \\concat{[x]}{q'_1}$.}\n\\end{eqnarray*}\n\nThe basic trick is to encode a queue as a pair of lists $(\\ell_1, \\ell_2)$.\nWe try to enqueue into $\\ell_1$ by adding elements to its front in constant time, and we try to dequeue from $\\ell_2$ by removing elements from its front in constant time.\nHowever, sometimes we run out of elements in $\\ell_2$ and need to \\emph{reverse} $\\ell_1$ and transfer the result into $\\ell_2$.\nThe suitable equivalence relation formalizes this plan.\n\\begin{eqnarray*}\n  \\mt{rep}((\\ell_1, \\ell_2)) &=& \\concat{\\ell_1}{\\mt{rev}(\\ell_2)} \\\\\n  q_1 \\approx q_2 &=& \\mt{rep}(q_1) = \\mt{rep}(q_2)\n\\end{eqnarray*}\n\nWe can prove both that this $\\approx$ is an equivalence relation and that the other queue laws are satisfied.\nAs a result, client code (and its correctness proofs) can use this fancy code, effectively viewing it as a simple queue, with the two-stack nature hidden.\n\nWhy did we need to go through the trouble of introducing custom equivalence relations?\nConsider the following two queues.\nAre they equal?\n(We write $\\pi_1$ for the function that projects out the first element of a pair.)\n\\begin{eqnarray*}\n  \\mt{enqueue}(\\mt{empty}, 2) &\\stackrel{?}{=}& \\pi_1(\\mt{dequeue}(\\mt{enqueue}(\\mt{enqueue}(\\mt{empty}, 1), 2)))\n\\end{eqnarray*}\n\nNo, they aren't equal!  The first expression reduces to $([2], [])$, while the second reduces to $([], [2])$.\nThis data structure is \\emph{noncanonical}\\index{noncanonical}, in the sense that the same logical value may have multiple physical representations.\nThe equivalence relation lets us indicate which physical representations are equivalent.\n\n\\section{Representation Functions}\n\nThat last choice of equivalence relations suggests another specification style, based on \\emph{representation functions}\\index{representation functions}.\nWe can force every queue to include a function to convert to a standard, canonical representation.\nReal executable programs shouldn't generally call that function; it's most useful to us in phrasing the algebraic laws.\nPerhaps surprisingly, the mere existence of any compatible function is enough to show correctness of a queue implementation, and the approach generalizes to essentially all other data structures cast as abstract data types.\n\nHere is how we revise our type signature for queues.\n\\begin{eqnarray*}\n  \\mt{t}(\\alpha) &:& \\mt{Set} \\\\\n  \\mt{empty} &:& \\mt{t}(\\alpha) \\\\\n  \\mt{enqueue} &:& \\mt{t}(\\alpha) \\times \\alpha \\to \\mt{t}(\\alpha) \\\\\n  \\mt{dequeue} &:& \\mt{t}(\\alpha) \\rightharpoonup \\mt{t}(\\alpha) \\times \\alpha \\\\\n  \\mt{rep} &:& \\mt{t}(\\alpha) \\to \\mt{list}(\\alpha)\n\\end{eqnarray*}\n\nAnd here are the revised axioms.\n\n$$\\infer{\\mt{rep}(\\mt{empty}) = []}{}\n\\quad \\infer{\\mt{rep}(\\mt{enqueue}(q, x)) = \\concat{[x]}{\\mt{rep}(q)}}{}$$\n\n$$\\infer{\\mt{dequeue}(q) = \\cdot}{\\mt{rep}(q) = []}\n\\quad \\infer{\\exists q'. \\; \\mt{dequeue}(q) = (q', x) \\land \\mt{rep}(q') = \\ell}{\\mt{rep}(q) = \\concat{\\ell}{[x]}}$$\n\nNotice that this specification style can also be viewed as \\emph{giving a reference implementation\\index{reference implementations of data types} of the data type}, where $\\mt{rep}$ shows how to convert back to the reference implementation at any point.\n\n\\section{Fixing Parameter Types for Abstract Data Types}\n\nHere's another classic abstract data type: finite sets\\index{finite sets}, where we write $\\mathbb B$ for the set of Booleans.\n\\begin{eqnarray*}\n  \\mt{t}(\\alpha) &:& \\mt{Set} \\\\\n  \\mt{empty} &:& \\mt{t}(\\alpha) \\\\\n  \\mt{add} &:& \\mt{t}(\\alpha) \\times \\alpha \\to \\mt{t}(\\alpha) \\\\\n  \\mt{member} &:& \\mt{t}(\\alpha) \\times \\alpha \\to \\mathbb B\n\\end{eqnarray*}\n\nA few laws characterize expected behavior, with $\\top$ and $\\bot$ the respective elements ``true'' and ``false'' of $\\mathbb B$.\n\n$$\\infer{\\mt{member}(\\mt{empty}, k) = \\bot}{}\n\\quad \\infer{\\mt{member}(\\mt{add}(s, k), k) = \\top}{}\n\\quad \\infer{\\mt{member}(\\mt{add}(s, k_1), k_2) = \\mt{member}(s, k_2)}{k_1 \\neq k_2}$$\n\nThere is a simple generic implementation of this data type with unsorted lists.\n\\begin{eqnarray*}\n  \\mt{t} &=& \\mt{list} \\\\\n  \\mt{empty} &=& [] \\\\\n  \\mt{add}(s, k) &=& \\concat{[k]}{s} \\\\\n  \\mt{member}([], k) &=& \\bot \\\\\n  \\mt{member}(\\concat{[k']}{s}, k) &=& k = k' \\lor \\mt{member}(s, k)\n\\end{eqnarray*}\n\nHowever, we can build specialized finite sets for particular element types and usage patterns.\nFor instance, assume we are working with sets of natural numbers, where we know that most sets contain consecutive numbers.\nIn those cases, it suffices to store just the lowest and highest elements of sets, and all the set operations run in constant time.\nAssume a fallback implementation of finite sets, with type $t_0$ and operations $\\mt{empty}_0$, $\\mt{add}_0$, and $\\mt{member}_0$.\nWe implement our optimized set type like so, assuming an operation $\\mt{fromRange} : \\mathbb N \\times \\mathbb N \\to \\mt{t}_0$ to turn a range into an ad-hoc set.\n\\begin{eqnarray*}\n  \\mt{t} &=& \\mt{Empty} \\mid \\mt{Range}(\\mathbb N \\times \\mathbb N) \\mid \\mt{AdHoc}(\\mt{t}_0) \\\\\n  \\mt{empty} &=& \\mt{Empty} \\\\\n  \\mt{add}(\\mt{Empty}, k) &=& \\mt{Range}(k, k) \\\\\n  \\mt{add}(\\mt{Range}(n_1, n_2), k) &=& \\mt{Range}(n_1, n_2)\\textrm{, when $n_1 \\leq k \\leq n_2$} \\\\\n  \\mt{add}(\\mt{Range}(n_1, n_2), n_1-1) &=& \\mt{Range}(n_1-1, n_2)\\textrm{, when $n_1 \\leq n_2$} \\\\\n  \\mt{add}(\\mt{Range}(n_1, n_2), n_2+1) &=& \\mt{Range}(n_1, n_2+1)\\textrm{, when $n_1 \\leq n_2$} \\\\\n  \\mt{add}(\\mt{Range}(n_1, n_2), k) &=& \\mt{AdHoc}(\\mt{add}_0(\\mt{fromRange}(n_1, n_2), k))\\textrm{, otherwise} \\\\\n  \\mt{add}(\\mt{AdHoc}(s), k) &=& \\mt{AdHoc}(\\mt{add}_0(s, k)) \\\\\n  \\mt{member}(\\mt{Empty}, k) &=& \\bot \\\\\n  \\mt{member}(\\mt{Range}(n_1, n_2), k) &=& n_1 \\leq k \\leq n_2 \\\\\n  \\mt{member}(\\mt{AdHoc}(s), k) &=& \\mt{member}_0(s, k)\n\\end{eqnarray*}\n\nThis implementation can be proven to satisfy the finite-set spec, assuming that the baseline ad-hoc implementation does, too.\nFor workloads that only build sets of consecutive numbers, this implementation can be much faster than the generic list-based implementation, converting quadratic-time algorithms into linear-time.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{interpreters}Semantics via Interpreters}\n\nThat's enough about what programs \\emph{look like}.\nLet's shift our attention to what programs \\emph{mean}.\n\n\\section{Semantics for Arithmetic Expressions via Finite Maps}\n\n\\newcommand{\\mempty}[0]{\\bullet}\n\\newcommand{\\msel}[2]{#1(#2)}\n\\newcommand{\\mupd}[3]{#1[#2 \\mapsto #3]}\n\nTo explain the meaning of one of Chapter \\ref{syntax}'s arithmetic expressions, we need a way to indicate the value of each variable.\n\\encoding\nA theory of \\emph{finite maps}\\index{finite map} is helpful here.\nWe apply the following notations throughout the book: \\\\\n\n\\begin{tabular}{rl}\n  $\\mempty$ & empty map, with $\\emptyset$ as its domain \\\\\n  $\\msel{m}{k}$ & mapping of key $k$ in map $m$ \\\\\n  $\\mupd{m}{k}{v}$ & extension of map $m$ to also map key $k$ to value $v$\n\\end{tabular} \\\\\n\nAs the name advertises, finite maps are functions with finite domains, where the domain may be expanded by each extension operation.\nTwo axioms explain the essential interactions of the basic operators.\n\n$$\\infer{\\msel{\\mupd{m}{k}{v}}{k} = v}{}\n\\quad\n\\infer{\\msel{\\mupd{m}{k_1}{v}}{k_2} = m(k_2)}{\n  k_1 \\neq k_2\n}$$\n\n\\newcommand{\\denote}[1]{{\\left \\llbracket #1 \\right \\rrbracket}}\n\nWith these operators in hand, we can write a semantics for arithmetic expressions.\nThis is a recursive function that \\emph{maps variable valuations to numbers}.\nWe write $\\denote{e}$ for the meaning of $e$; this notation is often referred to as \\emph{Oxford brackets}\\index{Oxford brackets}.\nRecall that we allow notations like this as syntactic sugar for arbitrary functions, even when giving the equations that define those functions.\nWe write $v$ for a valuation (finite map).\n\\encoding\n\\begin{eqnarray*}\n  \\denote{n}v &=& n \\\\\n  \\denote{x}v &=& v(x) \\\\\n  \\denote{e_1 + e_2}v &=& \\denote{e_1}v + \\denote{e_2}v \\\\\n  \\denote{e_1 \\times e_2}v &=& \\denote{e_1}v \\times \\denote{e_2}v\n\\end{eqnarray*}\n\nNote how parts of the definition feel a little bit like cheating, as we just ``push notations inside the brackets.''\nIt's important to remember that plus \\emph{inside} the brackets is syntax, while plus \\emph{outside} the brackets is the normal addition of math!\n\n\\newcommand{\\subst}[3]{[#3/#2]#1}\n\nTo test our semantics, we define a \\emph{variable substitution} function\\index{substitution}.\nA substitution $\\subst{e}{x}{e'}$ stands for the result of running through the syntax of $e$,\nreplacing every occurrence of variable $x$ with expression $e'$.\n\n\\begin{eqnarray*}\n  \\subst{n}{x}{e} &=& n \\\\\n  \\subst{x}{x}{e} &=& e \\\\\n  \\subst{y}{x}{e} &=& y \\textrm{, when $y \\neq x$} \\\\\n  \\subst{(e_1 + e_2)}{x}{e} &=& \\subst{e_1}{x}{e} + \\subst{e_2}{x}{e} \\\\\n  \\subst{(e_1 \\times e_2)}{x}{e} &=& \\subst{e_1}{x}{e} \\times \\subst{e_2}{x}{e}\n\\end{eqnarray*}\n\nWe can prove a key compatibility property of these two recursive functions.\n\n\\begin{theorem}\n  For all $e$, $e'$, $x$, and $v$, $\\denote{\\subst{e}{x}{e'}}{v} = \\denote{e}{(\\mupd{v}{x}{\\denote{e'}{v}})}$.\n\\end{theorem}\n\nThat is, in some sense, the operations of interpretation and substitution \\emph{commute} with each other.\nThat intuition gives rise to the common notion of a \\emph{commuting diagram}\\index{commuting diagram}, like the one below for this particular example.\n\n\\[\n\\begin{tikzcd}\n(e, v) \\arrow{r}{\\subst{\\ldots}{x}{e'}} \\arrow{d}{\\mupd{\\ldots}{x}{\\denote{e'}v}} & (\\subst{e}{x}{e'}, v) \\arrow{d}{\\denote{\\ldots}} \\\\\n(e, \\mupd{v}{x}{\\denote{e'}v}) \\arrow{r}{\\denote{\\ldots}} & \\denote{\\subst{e}{x}{e'}}v\n\\end{tikzcd}\n\\]\n\nWe start at the top left, with a given expression $e$ and valuation $v$.\nThe diagram shows the equivalence of \\emph{two different paths} to the bottom right.\nEach individual arrow is labeled with some description of the transformation it performs, to get from the term at its source to the term at its destination.\nThe right-then-down path is based on substituting and then interpreting, while the down-then-right path is based on extending the valuation and then interpreting.\nSince both paths wind up at the same spot, the diagram indicates an equality between the corresponding terms.\n\nIt's a matter of taste whether the theorem statement or the diagram expresses the property more clearly!\n\n\\section{A Stack Machine}\n\nAs an example of a very different language, consider a \\emph{stack machine}\\index{stack machine}, similar at some level to, for instance, the Forth\\index{Forth} programming language, or to various postfix\\index{postfix} calculators.\n\\encoding\n$$\\begin{array}{rrcl}\n  \\textrm{Instructions} & i &::=& \\mathsf{PushConst}(n) \\mid \\mathsf{PushVar}(x) \\mid \\mathsf{Add} \\mid \\mathsf{Multiply} \\\\\n  \\textrm{Programs} & \\overline{i} &::=& \\cdot \\mid i; \\overline{i}\n\\end{array}$$\n\nThough here we defined an explicit grammar for programs, which are just sequences of instructions, in general we'll use the notation $\\overline{X}$ to stand for sequences of $X$'s, and the associated concrete syntax won't be so important.\nWe also freely use single instructions to stand for programs, writing just $i$ in place of $i; \\cdot$.\n\n\\newcommand{\\push}[2]{#1 \\rhd #2}\n\nEach instruction of this language transforms a \\emph{stack}\\index{stack}, a last-in-first-out list of numbers.\nRather than spend more words on it, here is an interpreter that makes everything precise.\nHere and elsewhere, we overload the Oxford brackets $\\denote{\\ldots}$ shamelessly, where context makes clear which language or interpreter we are dealing with.\nWe write $s$ for stacks, and we write $\\push{n}{s}$ for pushing number $n$ onto the top of stack $s$.\n\n\\encoding\n\\begin{eqnarray*}\n  \\denote{\\mathsf{PushConst}(n)}(v,s) &=& \\push{n}{s} \\\\\n  \\denote{\\mathsf{PushVar}(x)}(v,s) &=& \\push{\\msel{v}{x}}{s} \\\\\n  \\denote{\\mathsf{Add}}(v,\\push{n_2}{\\push{n_1}{s}}) &=& \\push{(n_1 + n_2)}{s} \\\\\n  \\denote{\\mathsf{Multiply}}(v,\\push{n_2}{\\push{n_1}{s}}) &=& \\push{(n_1 \\times n_2)}{s}\n\\end{eqnarray*}\n\nThe last two cases require the stack have at least a certain height.\nHere we'll ignore what happens when the stack is too short, though it suffices, for our purposes, to add pretty much any default behavior for the missing cases.\nWe overload $\\denote{\\overline{i}}$ to refer to the \\emph{composition} of the interpretations of the different instructions within $\\overline{i}$, in order.\n\nNext, we give our first example of what might be called a \\emph{compiler}\\index{compiler}, or a translation from one language to another.\nLet's compile arithmetic expressions into stack programs, which then become easy to map onto the instructions of common assembly languages.\nIn that sense, with this translation, we make progress toward efficient implementation on commodity hardware.\n\n\\newcommand{\\compile}[1]{{\\left \\lfloor #1 \\right \\rfloor}}\n\nThroughout this book, we will use notation $\\compile{\\ldots}$ for compilation, where the floor-based notation suggests \\emph{moving downward} to a lower abstraction level.\nHere is the compiler that concerns us now, where we write $\\concat{\\overline{i_1}}{\\overline{i_2}}$ for concatenation of two instruction sequences $\\overline{i_1}$ and $\\overline{i_2}$.\n\\encoding\n\\begin{eqnarray*}\n  \\compile{n} &=& \\mathsf{PushConst}(n) \\\\\n  \\compile{x} &=& \\mathsf{PushVar}(x) \\\\\n  \\compile{e_1 + e_2} &=& \\concat{\\compile{e_1}}{\\concat{\\compile{e_2}}{\\mathsf{Add}}} \\\\\n  \\compile{e_1 \\times e_2} &=& \\concat{\\compile{e_1}}{\\concat{\\compile{e_2}}{\\mathsf{Multiply}}}\n\\end{eqnarray*}\n\nThe first two cases are straightforward: their compilations just push the obvious values onto the stack.\nThe binary operators are just slightly more tricky.\nEach first evaluates its operands in order, where each operand leaves its final result on the stack.\nWith both of them in place, we run the instruction to pop them, combine them, and push the result back onto the stack.\n\nThe correctness theorem for compilation must refer to both of our interpreters.\nFrom here on, we consider that all unaccounted-for variables in a theorem statement are quantified universally.\n\n\\begin{theorem}\n  $\\denote{\\compile{e}}(v, \\cdot) = \\denote{e}v$.\n\\end{theorem}\n\nHere's a restatement as a commuting diagram.\n\n\\[\n\\begin{tikzcd}\ne \\arrow{r}{\\compile{\\ldots}} \\arrow{dr}{\\denote{\\ldots}} & \\compile{e} \\arrow{d}{\\denote{\\ldots}} \\\\\n& \\denote{e}\n\\end{tikzcd}\n\\]\n\nAs usual, we leave proof details for the associated Coq code, but the key insight of the proof is to strengthen the induction hypothesis via a lemma.\n\n\\begin{lemma}\n  $\\denote{\\concat{\\compile{e}}{\\overline{i}}}(v, s) = \\denote{\\overline{i}}(v, \\push{\\denote{e}v}{s})$.\n\\end{lemma}\n\nWe strengthen the statement by considering both an arbitrary initial stack $s$ and a sequence of extra instructions $\\overline{i}$ to be run after $e$.\n\n\\section{A Simple Higher-Level Imperative Language}\n\n\\newcommand{\\repet}[2]{\\mathsf{repeat} \\; #1 \\; \\mathsf{do} \\; #2 \\; \\mathsf{done}}\n\nThe interpreter approach to semantics is usually the most convenient one, when it applies.\nCoq requires that all programs terminate, and that requirement is effectively also present in informal math, though it is seldom called out with the same terms.\nInstead, with math, we worry about whether recursive systems of equations are well-founded, in appropriate senses.\nFrom either perspective, extra encoding tricks are required to write a well-formed interpreter for a Turing-complete\\index{Turing-completeness} language.\nWe will dodge those complexities for now by defining a simple imperative language with bounded loops, where termination is easy to prove.\nWe take the arithmetic expression language as a base.\n\\encoding\n$$\\begin{array}{rrcl}\n  \\textrm{Command} & c &::=& \\mathsf{skip} \\mid x \\leftarrow e \\mid c; c \\mid \\repet{e}{c}\n\\end{array}$$\n\nNow the implicit state, read and written by a command, is a variable valuation, as we used in the interpreter for expressions.\nA $\\mathsf{skip}$ command does nothing, while $x \\leftarrow e$ extends the valuation to map $x$ to the value of expression $e$.\nWe have simple command sequencing $c_1; c_2$, in addition to the bounded loop $\\repet{e}{c}$, which executes $c$ a number of times equal to the value of $e$.\n\n\\newcommand{\\id}[0]{\\mathsf{id}}\n\nTo give the semantics, we need a few commonplace notations that are worth reviewing.\nWe write $\\id$ for the identity function\\index{identity function}, where $\\id(x) = x$; and we write $f \\circ g$ for composition of functions\\index{composition of functions} $f$ and $g$, where $(f \\circ g)(x) = f(g(x))$.\nWe also have iterated self-composition\\index{self-composition}, written like \\emph{exponentiation} of functions\\index{exponentiation of functions} $f^n$, defined as follows.\n\\begin{eqnarray*}\n  f^0 &=& \\id \\\\\n  f^{n+1} &=& f^n \\circ f\n\\end{eqnarray*}\n\nFrom here, $\\denote{\\ldots}$ is easy to define yet again, as a transformer over variable valuations.\n\\encoding\n\\begin{eqnarray*}\n  \\denote{\\mathsf{skip}}v &=& v \\\\\n  \\denote{x \\leftarrow e}v &=& \\mupd{v}{x}{\\denote{e}v} \\\\\n  \\denote{c_1; c_2}v &=& \\denote{c_2}(\\denote{c_1}v) \\\\\n  \\denote{\\repet{e}{c}}v &=& \\denote{c}^{\\denote{e}v}(v)\n\\end{eqnarray*}\n\nTo put this semantics through a workout, let's consider a simple \\emph{optimization}\\index{optimization}, a transformation whose input and output programs are in the same language.\nThere's an additional, fuzzier criterion for an optimization, which is that it should improve the program somehow, usually in terms of running time, memory usage, etc.\nThe optimization we choose here may be a bit dubious in that respect, though it is related to an optimization found in every serious C\\index{C programming language} compiler.\n\nIn particular, let's tackle \\emph{loop unrolling}\\index{loop unrolling}.\nWhen the iteration count of a loop is a constant $n$, we can replace the loop with $n$ sequenced copies of its body.\nC compilers need to work harder to find the iteration count of a loop, but luckily our language includes loops with very explicit iteration counts!\nTo define the transformation, we'll want a recursive function and notation for sequencing of $n$ copies of a command $c$, written $^nc$.\n\\begin{eqnarray*}\n  ^0c &=& \\mathsf{skip} \\\\\n  ^{n+1}c &=& c; {^nc}\n\\end{eqnarray*}\n\n\\newcommand{\\opt}[1]{{\\left | #1 \\right |}}\n\nNow the optimization itself is easy to define.\nWe'll write $\\opt{\\ldots}$ for this and other optimizations, which move neither down nor up a tower of program abstraction levels.\n\\encoding\n\\begin{eqnarray*}\n  \\opt{\\mathsf{skip}} &=& \\mathsf{skip} \\\\\n  \\opt{x \\leftarrow e} &=& x \\leftarrow e \\\\\n  \\opt{c_1; c_2} &=& \\opt{c_1}; \\opt{c_2} \\\\\n  \\opt{\\repet{n}{c}} &=& ^n\\opt{c} \\\\\n  \\opt{\\repet{e}{c}} &=& \\repet{e}{\\opt{c}}\n\\end{eqnarray*}\n\nNote that, when multiple defining equations apply to some function input, by convention we apply the \\emph{earliest} equation that matches.\n\nLet's prove that this optimization preserves program behavior; that is, we prove that it is \\emph{semantics preserving}\\index{semantics preservation}.\n\n\\begin{theorem}\\label{unroll}\n  $\\denote{\\opt{c}}v = \\denote{c}v$.\n\\end{theorem}\n\nIt all looks so straightforward from that statement, doesn't it?\nIndeed, there actually isn't so much work to do to prove this theorem.\nWe can also present it as a commuting diagram much like the prior one.\n\n\\[\n\\begin{tikzcd}\nc \\arrow{r}{\\opt{\\ldots}} \\arrow{dr}{\\denote{\\ldots}} & \\opt{c} \\arrow{d}{\\denote{\\ldots}} \\\\\n& \\denote{c}\n\\end{tikzcd}\n\\]\n\nThe statement of Theorem \\ref{unroll} happens to already be in the right form to do induction directly, but we need a helper lemma, capturing the interaction of $^nc$ and the semantics.\n\n\\begin{lemma}\n  $\\denote{^nc} = \\denote{c}^n$.\n\\end{lemma}\n\nLet us end the chapter with the commuting-diagram version of the lemma statement.\n\n\\[\n\\begin{tikzcd}\nc \\arrow{r}{^n\\ldots} \\arrow{d}{\\denote{\\ldots}} & ^nc \\arrow{d}{\\denote{\\ldots}} \\\\\n\\denote{c} \\arrow{r}{\\ldots^n} & \\denote{c}^n\n\\end{tikzcd}\n\\]\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Transition Systems and Invariants}\n\nFor simple programming languages where programs always terminate, it is often most convenient to formalize them using interpreters, as in the last chapter.\nHowever, many important languages don't fall into that category, and for them we need different techniques.\nNontermination isn't always a bug; for instance, we expect a network server to run indefinitely.\nWe still need to be able to talk about the correct behavior of programs that run forever, by design.\nFor that reason, in this chapter and in most of the rest of the book, we model programs using relations, in much the same way that may be familiar from automata theory\\index{automata theory}.\nAn important difference, though, is that, while undergraduate automata-theory classes generally study \\emph{finite-state machines}\\index{finite-state machines}, for general program reasoning we want to allow infinite sets of states, otherwise referred to as \\emph{infinite-state systems}\\index{infinite-state systems}.\n\nLet's start with an example that almost seems too mundane to be associated with such terms.\n\n\\section{Factorial as a State Machine}\n\nWe're familiar with the factorial operation, implemented as an imperative program with a loop.\n\\begin{verbatim}\nfactorial(n) {\n  a = 1;\n  while (n > 0) {\n    a = a * n;\n    n = n - 1;\n  }\n  return a;\n}\n\\end{verbatim}\n\nIn the analysis to follow, consider some value $n_0 \\in \\mathbb N$ fixed, as the input passed to this operation.\nA state machine is lurking within the surface syntax of the program.\n\\encoding\nIn fact, we have a variety of choices in modeling it as a state machine.\nHere is the set of states that we choose to use here:\n$$\\begin{array}{rrcl}\n  \\textrm{Natural numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{States} & s &::=& \\mathsf{AnswerIs}(n) \\mid \\mathsf{WithAccumulator}(n, n)\n\\end{array}$$\n\nThere are two types of states.\nAn $\\mathsf{AnswerIs}(a)$ state corresponds to the \\texttt{return} statement.\nIt records the final result $a$ of the factorial operation.\nA $\\mathsf{WithAccumulator}(n, a)$ records an intermediate state, giving the values of the two local variables, just before a loop iteration begins.\n\nFollowing the more familiar parts of automata theory, let's define a set of \\emph{initial states}\\index{initial state} for this machine.\n$$\\infer{\\mathsf{WithAccumulator}(n_0, 1) \\in \\mathcal F_0}{}$$\nFor consistency with the notation we will be using later, we define the set $\\mathcal F_0$ using an inference rule.\nEquivalently, we could just write $\\mathcal F_0 = \\{\\mathsf{WithAccumulator}(n_0, 1)\\}$, essentially reading off the initial variable values from the first lines of the code above.\n\nSimilarly, we also define a set of \\emph{final states}\\index{final state}.\n$$\\infer{\\mathsf{AnswerIs}(a) \\in \\mathcal F_\\omega}{}$$\nEquivalently: $\\mathcal F_\\omega = \\{\\mathsf{AnswerIs}(a) \\mid a \\in \\mathbb N\\}$.\nNote that this definition only captures when the program is \\emph{done}, not when it \\emph{returns the right answer}.\nIt follows from the last line of the code.\n\nThe last and most important ingredient of our state machine is its \\emph{transition relation}, where we write $s \\to s'$ to indicate that state $s$ advances to state $s'$ in one step, following the semantics of the program.\nHere inference rules are more obviously a good fit.\n$$\\infer{\\mathsf{WithAccumulator}(0, a) \\to \\mathsf{AnswerIs}(a)}{}$$\n$$\\infer{\\mathsf{WithAccumulator}(n+1, a) \\to \\mathsf{WithAccumulator}(n, a \\times (n+1))}{}$$\nThe first rule corresponds to the case where the program ends, because the loop test has failed and we now know the final answer.\nThe second rule corresponds to going once around the loop, following directly from the code in the loop body.\n\nWe can fit these ingredients into the general concept of a \\emph{transition system}\\index{transition system}, the term we will use throughout this book for this sort of state machine.\nActually, the words ``state machine'' suggest to many people that the state set must be finite, hence our preference for ``transition system,'' which is also used fairly frequently in semantics.\n\n\\newcommand{\\angled}[1]{{\\left \\langle #1 \\right \\rangle}}\n\n\\begin{definition}\n  A \\emph{transition system} is a triple $\\angled{S, S_0, \\to}$, with $S$ a set of states, $S_0 \\subseteq S$ a set of initial states, and $\\to \\; \\subseteq S \\times S$ a transition relation.\n\\end{definition}\n\nFor an arbitrary transition relation $\\to$, not just the one defined above for factorial, we define its \\emph{transitive-reflexive closure}\\index{transitive-reflexive closure} $\\to^*$ with two inference rules:\n$$\\infer{s \\to^* s}{}\n\\quad \\infer{s \\to^* s''}{\n  s \\to s'\n  & s' \\to^* s''\n}$$\nThat is, a formal claim $s \\to^* s'$ corresponds exactly to the informal claim that ``starting from state $s$, we can reach state $s'$.''\n\n\\begin{definition}\n  For transition system $\\angled{S, S_0, \\to}$, we say that a state $s$ is \\emph{reachable} if and only if there exists $s_0 \\in S_0$ such that $s_0 \\to^* s$.\n\\end{definition}\n\nBuilding on these notations, here is one way to state the correctness of our factorial program, which, defining $S$ according to the state grammar above, we model as $\\mathcal F = \\angled{S, \\mathcal F_0, \\to}$.\n\n\\begin{theorem}\\label{factorial_ok}\n  For any state $s$ reachable in $\\mathcal F$, if $s \\in \\mathcal F_\\omega$, then $s = \\mathsf{AnswerIs}(n_0!)$.\n\\end{theorem}\n\nThat is, whenever the program finishes, it returns the right answer.\n(Recall that $n_0$ is the initial value of the input variable.)\n\nWe could prove this theorem now in a relatively ad-hoc way.\nInstead, let's develop the general machinery of \\emph{invariants}.\n\n\n\\section{Invariants}\n\nThe concept of ``invariant'' may be familiar from such relatively informal notions as ``loop invariant''\\index{loop invariant} in introductory programming classes.\nIntuitively, an invariant is a property of program state that \\emph{starts true and stays true}, but let's make that idea a bit more formal, as applied to our transition-system formalism.\n\n\\newcommand{\\invariants}[0]{\\marginpar{\\fbox{\\textbf{Invariants}}}}\n\n\\invariants\n\\begin{definition}\n  An \\emph{invariant} of a transition system is a property that is always true, in all of the system's reachable states.  That is, for transition system $\\angled{S, S_0, \\to}$, where $R$ is the set of all its reachable states, some $I \\subseteq S$ is an invariant iff $R \\subseteq I$.  (Note that here we adopt the mathematical convention that ``properties'' of states and ``sets'' of states are synonymous, so that in each case we can use what terminology seems most natural.  The ``property'' holds of exactly those states that belong to the ``set.'')\n\\end{definition}\n\nAt first look, the definition may appear a bit silly.\nWhy not always just take the reachable states $R$ as the invariant, instead of scrambling to invent something new?\nThe reason is the same as for strengthening induction hypotheses to make proofs easier.\nOften it is easier to characterize an invariant that isn't fully precise, admitting some states that the system can never actually reach.\nAdditionally, it can be easier to prove existence of an approximate invariant by induction, by the method that the next key theorem formalizes.\n\n\\begin{theorem}\\label{invariant_induction}\n  Consider a transition system $\\angled{S, S_0, \\to}$ and its candidate invariant $I$.  The candidate is truly an invariant if (1) $S_0 \\subseteq I$ and (2) for every $s \\in I$ where $s \\to s'$, we also have $s' \\in I$.\n\\end{theorem}\n\nThat's enough generalities for now.\nLet's define a suitable invariant for factorial.\n\\invariants\n\\begin{eqnarray*}\n  I(\\mathsf{AnswerIs}(a)) &=& n_0! = a \\\\\n  I(\\mathsf{WithAccumulator}(n, a)) &=& n_0! = n! \\times a\n\\end{eqnarray*}\n\nIt is an almost-routine exercise to prove that $I$ really is an invariant, using Theorem \\ref{invariant_induction}.\nThe key new ingredient we need is \\emph{inversion}, a principle for deducing which inference rules may have been used to prove a fact.\n\nFor instance, at one point in the proof, we need to draw a conclusion from a premise $s \\in \\mathcal F_0$, meaning that $s$ is an initial state.\nBy inversion, because set $\\mathcal F_0$ is defined by a single inference rule, that rule must have been used to conclude the premise, so it must be that $s = \\mathsf{WithAccumulator}(n_0, 1)$.\n\nSimilarly, at another point in the proof, we must reason from a premise $s \\to s'$.\nThe relation $\\to$ is defined by two inference rules, so inversion leads us to two cases to consider.\nIn the first case, corresponding to the first rule, $s = \\mathsf{WithAccumulator}(0, a)$ and $s' = \\mathsf{AnswerIs}(a)$.\nIn the second case, corresponding to the second rule, $s = \\mathsf{WithAccumulator}(n+1, a)$ and $s' = \\mathsf{WithAccumulator}(n, a \\times (n+1))$.\nIt's worth checking that these values of $s$ and $s'$ are read off directly from the rules.\n\nThough a completely formal and exhaustive treatment of inversion is beyond the scope of this text, generally it follows standard intuitions about ``reverse-engineering'' a set of rules that could have been used to derive some premise.\n\nAnother important property of invariants formalizes the connection with weakening an induction hypothesis.\n\n\\begin{theorem}\\label{invariant_weaken}\n  If $I$ is an invariant of a transition system, then $I' \\supseteq I$ (a superset of the original) is also an invariant of the same system.\n\\end{theorem}\n\nNote that the larger $I'$ above may not be suitable to use in an inductive proof by Theorem \\ref{invariant_induction}!\nFor instance, for factorial, we might define $I' = \\mathcal \\{\\mathsf{AnswerIs}(n_0!)\\} \\cup \\{\\mathsf{WithAccumulator}(n, a) \\mid n, a \\in \\mathbb N\\}$, clearly a superset of $I$.\nHowever, by forgetting everything that we know about intermediate $\\mathsf{WithAccumulator}$ states, we will get stuck on the inductive step of the proof.\nThus, what we call invariants here needn't also be \\emph{inductive invariants}\\index{inductive invariants}, and there may be slight terminology mismatches with other sources.\n\nCombining Theorems \\ref{invariant_induction} and \\ref{invariant_weaken}, it is now easy to prove Theorem \\ref{factorial_ok}, establishing the correctness of our particular factorial system $\\mathcal F$.\nFirst, we use Theorem \\ref{invariant_induction} to deduce that $I$ is an invariant of $\\mathcal F$.\nThen, we choose the very same $I'$ that we warned above is not an inductive invariant, but which is fairly easily shown to be a superset of $I$.\nTherefore, by Theorem \\ref{invariant_weaken}, $I'$ is also an invariant of $\\mathcal F$, and Theorem \\ref{factorial_ok} follows quite directly from that fact, as $I'$ is essentially a restatement of Theorem \\ref{factorial_ok}.\n\n\\section{Rule Induction}\n\nAnother crucial reasoning technique was hidden within the elided proof of Theorem \\ref{invariant_induction}.\nThat technique is \\emph{rule induction}\\index{rule induction}, which generalizes inversion just as normal structural induction generalizes case analysis.\nAs an example, consider again the definition of transitive-reflexive closure by inference rules.\n$$\\infer{s \\to^* s}{}\n\\quad \\infer{s \\to^* s''}{\n  s \\to s'\n  & s' \\to^* s''\n}$$\n\nThe relation $\\to^*$ is a subset of $S \\times S$.\nImagine that we want to prove that some relation $P$ holds of all pairs of states, where the first can reach the second.\nThat is, we want to prove $\\forall s, s'. \\; (s \\to^* s') \\Rightarrow P(s, s')$, where $\\Rightarrow$ is logical implication.\nWe can actually derive a suitable induction principle, in the same way that we produced structural induction principles from definitions of inductive datatypes.\nWe modify each defining rule of $\\to^*$, replacing its conclusion with a use of $P$ and adding a $P$ induction hypothesis for each recursive premise.\n$$\\infer{P(s, s)}{}\n\\quad \\infer{P(s, s'')}{\n  s \\to s'\n  & s' \\to^* s''\n  & P(s', s'')\n}$$\nAs before, where the defining rules of $\\to^*$ show us how to \\emph{conclude} facts, the two new rules here are \\emph{proof obligations}.\nTo apply rule induction and establish $P$ for all reachability pairs, we must prove that each new rule is correct, as a kind of quantified implication.\n\nAs a simpler example than the invariant-induction theorem, consider transitivity for reachability.\n\n\\begin{theorem}\n  If $s \\to^* s'$ and $s' \\to^* s''$, then $s \\to^* s''$.\n\\end{theorem}\n\\begin{proof}\n  By rule induction on the derivation of $s \\to^* s'$, taking $P(s_1, s_2)$ to be that, if $s_2 = s'$, then $s_1 \\to^* s''$.  We consider variables $s'$ and $s''$ fixed throughout the induction, along with their associated premise $s' \\to^* s''$.\n\n  \\emph{Base case:} We must show $P(s, s)$ for an arbitrary $s$.  Given that (based on the definition of $P$) we may assume $s = s'$, our premise $s' \\to^* s''$ precisely matches the desired conclusion $s \\to^* s''$.\n\n  \\emph{Induction step:} Assume $s \\to s_1$, $s_1 \\to^* s'$, and $P(s_1, s')$.  We may apply the second rule defining $\\to^*$, whose two premises become $s \\to s_1$ and $s_1 \\to^* s''$.  The first is one of the available premises of the induction step.  The second follows by the induction hypothesis about $P$.\n\\end{proof}\n\nThis sort of proof really is easier to follow in Coq code, so we especially encourage the reader to consult the mechanized version here!\n\nIn general, any inductive definition of a predicate, via a set of inference rules, implies a rule-induction principle.\nWe will meet many such definitions throughout the book, and we will apply rule induction to most of them.\nIt is valuable to understand basically how the rule-induction principle of a definition is read off from its original rules, but it is also true that Coq comes up with these principles automatically.\n\n\n\\section{An Example with a Concurrent Program}\n\nImagine that we want to verify a multithreaded\\index{multithreaded programs}, shared-memory program\\index{shared-memory programming} where multiple threads run this code at once.\n\\begin{verbatim}\nf() {\n  lock();\n  local = global;\n  global = local + 1;\n  unlock();\n}\n\\end{verbatim}\n\nConsider \\texttt{global} as a variable shared across all threads, while each thread has its own version of variable \\texttt{local}.\nThe meaning of \\texttt{lock()} and \\texttt{unlock()} is as usual\\index{locks}, where at most one thread can hold the lock at once, claiming it via \\texttt{lock()} and relinquishing it via \\texttt{unlock()}.\nWhen variable \\texttt{global} is initialized to 0 and $n$ threads run this code at once and all terminate, we expect that \\texttt{global} finishes with value $n$.\nOf course, bugs in this program, like forgetting to include the locking, could lead to all sorts of wrong answers, with any value between 1 and $n$ possible with the right demonic thread interleaving.\n\n\\encoding\nTo prove that we got the program right, let's formalize it as a transition system.  First, our state set:\n$$\\begin{array}{rrcl}\n  \\textrm{States} & P &::=& \\mathsf{Lock} \\mid \\mathsf{Read} \\mid \\mathsf{Write}(n) \\mid \\mathsf{Unlock} \\mid \\mathsf{Done}\n\\end{array}$$\n\nCompared to the last example, here we see more clearly that kinds of states correspond to \\emph{program counters}\\index{program counters} in the imperative code.\nThe first four state kinds respectively mean that the program counter is right before the matching line in the program's code.\nThe last state kind means the program counter is past the end of the function.\nOnly $\\mathsf{Write}$ states carry extra information, in this case the value of variable \\texttt{local}.\nAt every other program counter, we can prove that the value of variable \\texttt{local} has no effect on further transitions, so we don't bother to store it.\nWe will account for the value of variable \\texttt{global} separately, in a way to be described shortly.\n\nIn particular, we will define a transition system for a single thread as $\\mathcal L = \\angled{(\\mathbb N \\times \\mathbb B) \\times P, \\mathcal L_0, \\to_{\\mathcal L}}$.\nWe define the state to include not only the thread-local state $P$ but also the value of \\texttt{global} (in $\\mathbb N$) and whether the lock is currently taken (in $\\mathbb B$, the Booleans, with values $\\top$ [true] and $\\bot$ [false]).\nThere is one designated initial state.\n\n$$\\infer{((0, \\bot), \\mathsf{Lock}) \\in \\mathcal L_0}{}$$\n\nFour inference rules explain the four transitions between program counters that a single thread can make, reading and writing shared state as needed.\n\n$$\\infer{((g, \\bot), \\mathsf{Lock}) \\to_{\\mathcal L} ((g, \\top), \\mathsf{Read})}{}\n\\quad \\infer{((g, \\ell), \\mathsf{Read}) \\to_{\\mathcal L} ((g, \\ell), \\mathsf{Write}(g))}{}$$\n$$\\infer{((g, \\ell), \\mathsf{Write}(n)) \\to_{\\mathcal L} ((n+1, \\ell), \\mathsf{Unlock})}{}\n\\quad \\infer{((g, \\ell), \\mathsf{Unlock}) \\to_{\\mathcal L} ((g, \\bot), \\mathsf{Done})}{}$$\n\n\\smallskip\n\nNote that these rules will allow a thread to read and write the shared state even without holding the lock.\nThe rules also allow any thread to unlock the lock, with no consideration for whether that thread must be the current lock holder.\nWe must use an invariant-based proof to show that there are, in fact, no lurking violations of the lock-based concurrency discipline.\n\nOf course, with just a single thread running, there aren't any interesting violations!\nHowever, we have been careful to describe system $\\mathcal L$ in a generic way, with its state a pair of shared and private components.\nWe can define a generic notion of a multithreaded system, with two systems that share some state and maintain their own private state.\n\n\\encoding\n\\begin{definition}\n  Let $T^1 = \\angled{S \\times P^1, S_0 \\times P^1_0, \\to^1}$ and $T^2 = \\angled{S \\times P^2, S_0 \\times P^2_0, \\to^2}$ be two transition systems, with a shared-state type $S$ in common between their state sets, also agreeing on the initial values $S_0$ for that shared state.  We define the \\emph{parallel composition} $T^1 \\mid T^2$ as $\\angled{S \\times (P^1 \\times P^2), S_0 \\times (P^1_0 \\times P^2_0), \\to}$, defining new transition relation $\\to$ with the following inference rules, which capture the usual notion of thread interleaving.\n  $$\\infer{(s, (p_1, p_2)) \\to (s', (p'_1, p_2))}{\n    (s, p_1) \\to^1 (s', p'_1)\n  }\n  \\quad \\infer{(s, (p_1, p_2)) \\to (s', (p_1, p'_2))}{\n    (s, p_2) \\to^2 (s', p'_2)\n  }$$\n\\end{definition}\n\nNote that the operator $\\mid$ is carefully defined so that its output is suitable as input to a further instance of itself.\nAs a result, while $\\mathcal L \\mid \\mathcal L$ is a transition system modeling two threads running the code from above, we also have $\\mathcal L \\mid (\\mathcal L \\mid \\mathcal L)$ as a three-thread system based on that code, $(\\mathcal L \\mid \\mathcal L) \\mid (\\mathcal L \\mid \\mathcal L)$ as a four-thread system based on that code, etc.\n\nAlso note that $\\mid$ constructs transition systems with our first examples of \\emph{nondeterminism}\\index{nondeterminism} in transition relations.\nThat is, given a particular starting state, there are multiple different places it may wind up after a given number of execution steps.\nIn general, with thread-interleaving concurrency, the set of possible final states grows exponentially in the number of steps, a fact that torments concurrent-software testers to no end!\nRather than consider all possible runs of the program, we will use an invariant to tame the complexity.\n\nFirst, we should be clear on what we mean to prove about this program.\nLet's also restrict our attention to the two-thread case for the rest of this section; the $n$-thread case is left as an exercise for the reader!\n\\begin{theorem}\n  For any reachable state $((g, \\ell), (p^1, p^2))$ of $\\mathcal L \\mid \\mathcal L$, if $p^1 = p^2 = \\mathsf{Done}$, then $g = 2$.\n\\end{theorem}\nThat is, when both threads terminate, \\texttt{global} equals 2.\n\nAs a first step toward an invariant, define function $\\mathcal C$ from private states to numbers, capturing the \\emph{contribution of} a thread with that state, summarizing how much that thread has added to \\texttt{globals}.\n\\begin{eqnarray*}\n  \\mathcal C(p) &=& \\begin{cases}\n    1 & p \\in \\{\\mathsf{Unlock}, \\mathsf{Done}\\} \\\\\n    0 & \\mathrm{otherwise}\n  \\end{cases}\n\\end{eqnarray*}\n\nNext, we define a function that, given a thread's private state, determines whether that thread \\emph{holds the lock}.\n\\begin{eqnarray*}\n  \\mathcal H(p) &=& \\begin{cases}\n    \\bot & p \\in \\{\\mathsf{Lock}, \\mathsf{Done}\\} \\\\\n    \\top & \\mathrm{otherwise}\n  \\end{cases}\n\\end{eqnarray*}\n\nNow, the main insight: we can reconstruct the shared state uniquely from the two private states!\nFunction $\\mathcal S$ does exactly that.\n\\begin{eqnarray*}\n  \\mathcal S(p^1, p^2) &=& (\\mathcal H(p^1) \\lor \\mathcal H(p^2), \\mathcal C(p^1) + \\mathcal C(p^2))\n\\end{eqnarray*}\n\nOne last ingredient will help us write the invariant: a predicate $\\mathcal O(p, p')$ capturing when, given the state $p$ of one thread, the state $p'$ is compatible with all of the implications of $p$'s state, primarily in terms of mutual exclusion\\index{mutual exclusion} for the lock.\n\\begin{eqnarray*}\n  \\mathcal O(p, p') &=& \\begin{cases}\n    \\top & p \\in \\{\\mathsf{Lock}, \\mathsf{Done}\\} \\\\\n    \\neg \\mathcal H(p') & p \\in \\{\\mathsf{Read}, \\mathsf{Unlock}\\} \\\\\n    \\neg \\mathcal H(p') \\land n = \\mathcal C(p') & p = \\mathsf{Write}(n)\n  \\end{cases}\n\\end{eqnarray*}\n\nFinally, we can write the invariant.\n\\invariants\n\\begin{eqnarray*}\n  I(s, (p^1, p^2)) &=& \\mathcal O(p^1, p^2) \\land \\mathcal O(p^2, p^1) \\land s = \\mathcal S(p^1, p^2)\n\\end{eqnarray*}\n\nAs is often the case, defining the invariant is the hard part of the proof, and the rest follows by the standard methodology that we used for factorial.\nTo recap that method, first we use Theorem \\ref{invariant_induction} to show that $I$ really is an invariant of $\\mathcal L \\mid \\mathcal L$.\nNext, we use Theorem \\ref{invariant_weaken} to show that $I$ implies the original property of interest, that finished program states have value 2 for \\texttt{global}.\nMost of the action is in the first step, where we must work through fussy details of all the different steps that could happen from a state within the invariant, using arithmetic reasoning in each case to either derive a contradiction (that step couldn't happen from this starting state) or show that a specific new state also belongs to the invariant.\nWe leave those details to the Coq code, as usual.\n\nThe reader may be worried at this point that coming up with invariants can be rather tedious!\nIn the next chapter, we meet a technique for finding invariants automatically, in some limited but important circumstances.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{model_checking}Model Checking}\n\nOur analyses so far have been tedious for at least two different reasons.\nFirst, we've hand-crafted definitions of transition systems, rather than just writing programs in conventional programming languages.\nThe next chapter will clear that obstacle, by introducing operational semantics, for building transition systems automatically from programs.\nThe other inconvenience we've faced is defining invariants manually.\nThere isn't a silver bullet to get us out of this duty, when working with Turing-complete languages\\index{Turing-completeness}, where almost all interesting questions, this one included, are undecidable.\nHowever, when we can phrase problems in terms of transition systems with \\emph{finitely many reachable states}, we can construct invariants automatically by \\emph{exhaustive exploration of the state space}, an approach otherwise known as \\emph{model checking}\\index{model checking}.\nSurprisingly many real programs can be reduced to finite state spaces, using the techniques introduced in this chapter.\nFirst, though, let's formalize our intuitions about exhaustive state-space exploration as a sound way to find invariants.\n\n\\section{Exhaustive Exploration}\n\nFor an arbitrary binary relation $R$, we write $R^n$ for the $n$-times self-composition of $R$\\index{self-composition of relations}.\nFormally, where $\\mathsf{id}$ is the identity relation\\index{identity relation} that only relates values to themselves, we have:\n\\begin{eqnarray*}\n  R^0 &=& \\mathsf{id} \\\\\n  R^{n+1} &=& R \\circ R^n\n\\end{eqnarray*}\n\nFor some set $S$ and binary relation $R$, we also write $R(S)$ for the composition of $R$ and $S$\\index{composition of a relation and a set}, namely $\\{x \\mid \\exists y \\in S. \\; y \\; R \\; x\\}$.\n\n\\newcommand{\\ns}[0]{\\hspace{-.05in}}\n\nWhich states of transition system $\\angled{S, S_0, \\to}$ are reachable after 0 steps?\nThat would be precisely the initial states $S_0$, which we can also write as $\\to^0\\ns(S_0)$.\n\nWhich states are reachable after exactly 1 step?\nThat is $\\to\\ns(S_0)$, or $\\to^1\\ns(S_0)$.\n\nHow about 2, 3, and 4 steps?\nThere we have $\\to^2\\ns(S_0)$, $\\to^3\\ns(S_0)$, and $\\to^4\\ns(S_0$).\n\nIt follows that the set of states reachable after $n$ steps is:\n\\begin{eqnarray*}\n  \\mathsf{reach}(n) &=& \\bigcup_{i \\leq n} \\to^i\\ns(S_0)\n\\end{eqnarray*}\n\nThis iteration process is not obviously executable yet, because, a priori, we seem to need to consider all possible $n$ values, to characterize the state space fully.\nHowever, a crucial property allows us to terminate our search soundly under some conditions.\n\n\\begin{theorem}\n  \\invariants\n  If $\\mathsf{reach}(n+1) = \\mathsf{reach}(n)$ for some $n$, then $\\mathsf{reach}(n)$ is an invariant of the system.\n\\end{theorem}\n\nHere we call $\\mathsf{reach}(n)$ a \\emph{fixed point}\\index{fixed point} of the transition system, because it is closed under further exploration.\nTo find a fixed point with a concrete system, we start with $S_0$.\nWe repeatedly take the \\emph{single-step closure}\\index{single-step closure} corresponding to composition with $\\to$.\nAt each step, we check whether the expanded set is actually equal to the previous set.\nIf so, our process of \\emph{multi-step closure}\\index{multi-step closure} has terminated, and we have an invariant, by construction.\nAgain, keep in mind that multi-step closure will not terminate for most transition systems, and there is an art to phrasing a problem in terms of systems where it \\emph{will} terminate.\n\n\n\\section{\\label{trs_simulation}Abstracting a Transition System}\n\nWhen analyzing an infinite-state system, it is not necessary to give up hope for model checking.\nFor instance, consider this program.\n\\begin{verbatim}\nint global = 0;\n\nthread() {\n int local;\n\n while (true) {\n   local = global;\n   global = local + 2;\n }\n}\n\\end{verbatim}\n\nIf we assume infinite-precision integers, then the state space is infinite.\nConsidering just the global variable, every even number is reachable, even if we only run a single thread.\nHowever, there is a high degree of regularity across this state space.\nIn particular, those values really are all even.\nConsider this other program, which is hauntingly similar to the last one, in a way that we will make precise shortly.\n\\begin{verbatim}\nbool global = true;\n\nthread() {\n  bool local;\n\n  while (true) {\n    local = global;\n    global = local;\n  }\n}\n\\end{verbatim}\n\nWe replaced every use of an integer with \\emph{a Boolean that is true iff the integer is even}.\nNotice that now the program has a finite state space, and model checking applies easily!\nWe can formalize such a transformation via the general principle of \\emph{abstraction of a transition system}\\index{abstraction}.\n\n\\newcommand{\\simulate}[0]{\\prec}\n\nThe key idea is that every state of the concrete system (with relatively many states) can be associated to one or more states of the abstract system (with relatively few states).\nWe formalize this association via a \\emph{simulation relation}\\index{simulation relation} $R$, and we define what makes a choice of $R$ sound, via a notion of \\emph{simulation}\\index{simulation} via a binary operator $\\simulate$, subscripted by $R$.\n\n$$\\infer{\\angled{S, S_0, \\to} \\simulate_R \\angled{S', S'_0, \\to'}}{\n  (\\forall s \\in S_0. \\; \\exists s' \\in S'_0. \\; s \\; R \\; s')\n  & (\\forall s, s', s_1. \\; s \\; R \\; s' \\land s \\to s_1 \\Rightarrow \\exists s'_1. \\; s' \\to' s'_1 \\land s_1 \\; R \\; s'_1)\n}$$\n\nThe simpler condition is that every concrete initial state must be related to at least one abstract initial state.\nThe second, more complex condition essentially says that every step in the concrete world must be matchable by some related step in the abstract world.\nA commuting diagram may express the second condition more clearly.\n\\[\n\\begin{tikzcd}\ns \\arrow{r}{\\to} \\arrow{d}{R} & s_1 \\arrow{d}{R} \\\\\ns' \\arrow{r}{\\exists \\to'} & s'_1\n\\end{tikzcd}\n\\]\n\nAt an even higher intuitive level, what simulation says is that every execution of the concrete system may be matched, step for step, by an execution of the abstract system.\nThe relation $R$ explains the rules for which states match across systems.\nFor our purposes, the key pay-off from this connection is that we may translate any invariant of the abstract system into an invariant of the concrete system.\n\n\\newcommand{\\abstraction}[0]{\\marginpar{\\fbox{\\textbf{Abstraction}}}}\n\n\\begin{theorem}\\label{abstract_simulation}\n  \\abstraction\n  If $\\angled{S, S_0, \\to} \\simulate_R \\angled{S', S'_0, \\to'}$, and if $I$ is an invariant of $\\angled{S', S'_0, \\to'}$, then $R^{-1}(I)$ is an invariant of $\\angled{S, S_0, \\to}$.\n\\end{theorem}\n\nWe can apply this theorem to the two example programs from earlier in the section, now imagining that we run two parallel-thread copies of each program, using last chapter's approach to modeling threads with transition systems.\nThe concrete system can be represented with thread-local states $\\{\\mathsf{Read}\\} \\cup \\{\\mathsf{Write}(n) \\mid n \\in \\mathbb N\\}$ and the abstract system with $\\{\\mathsf{BRead}\\} \\cup \\{\\mathsf{BWrite}(b) \\mid b \\in \\mathbb B\\}$, for the Booleans $\\mathbb B$.\nWe define compatibility between local states.\n\n$$\\infer{\\mathsf{Read} \\sim \\mathsf{BRead}}{}\n\\quad \\infer{\\mathsf{Write}(n) \\sim \\mathsf{BWrite}(b)}{\n  n \\; \\textrm{even} \\Leftrightarrow b = \\mathsf{true}\n}$$\n\nWe also define the overall state simulation relation $R$, which also covers state shared by threads.\n\n$$\\infer{(n, (\\ell_1, \\ell_2)) \\; R \\; (b, (\\ell'_1, \\ell'_2))}{\n  (n \\; \\textrm{even} \\Leftrightarrow b = \\mathsf{true})\n  & \\ell_1 \\sim \\ell'_1\n  & \\ell_2 \\sim \\ell'_2\n}$$\n\nBy proving that $R$ is truly a simulation relation, we reduce the problem to finding an invariant for the abstract system, which is easy to do with model checking.\n\nOne crucial consequence of abstraction-by-simulation deserves mentioning:\nWe show that every concrete execution is matched abstractly, but there may also be additional abstract executions that don't match any concrete ones.\nIn model checking the abstract system, we may do extra work to handle these ``useless'' paths!\nIf we do manage to handle them all, then Theorem \\ref{abstract_simulation} applies perfectly well.\nHowever, we should be careful, in our choices of abstractions, to bias our designs toward those that don't introduce extra complexities.\n\n\n\\section{Modular Decomposition of Invariant-Finding}\n\nMany transition systems are straightforward to abstract into others, as single global steps.\nOther times, the right way to tame a complex system is to decompose it into others and analyze them separately for invariants.\nIn such cases, the key is a proof principle to combine the invariants of the component systems into an invariant of the overall system.\nWe will refer to this style of proof decomposition as \\emph{modularity}\\index{modularity}, and this section gives our first example of modularity, for multithreaded systems.\n\nImagine that we have a system consisting of $n$ different copies of a transition system $\\angled{S, S_0, \\to}$ running as concurrent threads, modeled in the way introduced in the previous chapter.\nIt's not obvious that we can analyze each thread separately, since, during that thread's execution, the other threads are constantly interrupting and modifying global state.\nTo make matters worse, we can only understand their patterns of state modification by analyzing their thread-local state.\nThe situation seems inherently unmodular.\n\nHowever, consider the following construction on transition systems.\nGiven a transition relation $\\to$ and an invariant $I$ on the global state shared by all threads, we define a new transition relation $\\to^I$ as follows.\n$$\\infer{s \\to^I s'}{\n  s \\to s'\n}\n\\quad \\infer{(g, \\ell) \\to^I (g', \\ell)}{\n  I(g')\n}$$\n\nThe first rule says that any step of the original relation is also a step of the new relation.\nHowever, the second rule adds a new kind of step: the global state may change \\emph{arbitrarily}, so long as the new value satisfies invariant $I$.\nWe lift this operation to full transition systems, defining $\\angled{S, S_0, \\to}^I = \\angled{S, S_0, \\to^I}$.\n\nThis construction trivially acts as an abstraction.\n\\begin{theorem}\\label{shared_invariant_abstract}\n  \\abstraction\n  $\\mathbb S \\simulate_\\mathsf{id} {\\mathbb S}^I$, for any system $\\mathbb S$ and property $I$.\n\\end{theorem}\n\n\\newcommand{\\modularity}[0]{\\marginpar{\\fbox{\\textbf{Modularity}}}}\n\nHowever, we wouldn't want to make this abstraction step in a proof about a single thread.\nWe needlessly complicate our model checking by forcing ourselves to consider all modifications of the global state that obey $I$.\nThe payoff comes in analyzing multithreaded systems.\n\\begin{theorem}\\label{shared_invariant_modular}\n  \\modularity\n  Where $I$ is an invariant over only the shared state of a multithreaded system, let $I' = \\{(g, \\ell) \\mid I(g)\\}$ be the lifting of $I$ to cover full states, local parts included.  If $I'$ is an invariant for both ${\\mathbb S}_1^I$ and ${\\mathbb S}_2^I$, then $I'$ is also an invariant for $({\\mathbb S}_1 \\mid {\\mathbb S}_2)^I$.\n\\end{theorem}\n\nThis theorem gives us a way to analyze the threads in a system separately.\nAs an example, consider this program, where multiple threads will run \\texttt{f()} simultaneously.\n\\begin{verbatim}\nint global = 0;\n\nf() {\n  int local = 0;\n\n  while (true) {\n    local = global;\n    local = 3 + local;\n    local = 7 + local;\n    global = local;\n  }\n}\n\\end{verbatim}\n\nCall the transition-system encoding of this code $\\mathbb S$.\nWe can apply the Boolean-for-evenness abstraction to model a single thread with finite state, but we are left needing to account for interference by other threads.\nHowever, we can apply Theorem \\ref{shared_invariant_modular} to analyze threads separately.\n\nFor instance, we want to show that ``\\texttt{global} is always even'' is an invariant of ${\\mathbb S} \\mid {\\mathbb S}$.\nBy Theorem \\ref{shared_invariant_abstract}, we can switch to analyzing system $({\\mathbb S} \\mid {\\mathbb S})^I$, where $I$ is the evenness invariant.\nBy Theorem \\ref{shared_invariant_modular}, we can switch to proving the same invariant separately for systems ${\\mathbb S}^I$ and ${\\mathbb S}^I$, which are, of course, the same system in this case.\nWe apply the Boolean-for-evenness abstraction to this system, to get one with a finite state space, so we can check the invariant automatically by model checking.\nFollowing the chain of reasoning backward, we have proved the invariant for ${\\mathbb S} \\mid {\\mathbb S}$.\n\nEven better, that last proof includes the hardest steps that carry over to the proof for an arbitrary number of threads.\nDefine an exponentially growing system of threads ${\\mathbb S}^n$ by:\n\\begin{eqnarray*}\n  {\\mathbb S}^0 &=& \\mathbb S \\\\\n  {\\mathbb S}^{n+1} &=& {\\mathbb S}^n \\mid {\\mathbb S}^n\n\\end{eqnarray*}\n\n\\begin{theorem}\n  For any $n$, it is an invariant of ${\\mathbb S}^n$ that the global variable is always even.\n\\end{theorem}\n\n\\begin{proof}\n  By induction on $n$, repeatedly using Theorem \\ref{shared_invariant_modular} to push the obligation down to the leaves of the tree of concurrent compositions, after applying Theorem \\ref{shared_invariant_abstract} at the start to introduce the use of $\\ldots^I$.\n  Every leaf is the same system $\\mathbb S$, for which we abstract and apply model checking, appealing to the step above where we ran the same analysis.\n\\end{proof}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{operational_semantics}Operational Semantics}\n\nIt gets tedious to define a relation from first principles, to explain the behaviors of any concrete program.\nWe do more things with programs than just reason about them.\nFor instance, we compile them into other languages.\nTo get the most mileage out of our correctness proofs, we should connect them to the same program syntax that we pass to compilers.\n\\emph{Operational semantics}\\index{operational semantics} is a family of techniques for automatically defining a transition system, or other relational characterization, from program syntax.\n\n\\newcommand{\\assign}[2]{#1 \\leftarrow #2}\n\\newcommand{\\skipe}[0]{\\mathsf{skip}}\n\\newcommand{\\ifte}[3]{\\mathsf{if} \\; #1 \\; \\mathsf{then} \\; #2 \\; \\mathsf{else} \\; #3}\n\\newcommand{\\while}[2]{\\mathsf{while} \\; #1 \\; \\mathsf{do} \\; #2}\n\nThroughout this chapter, we will demonstrate the different operational-semantics techniques on a single source language, defined like so.\n$$\\begin{array}{rrcl}\n  \\textrm{Numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Expressions} & e &::=& n \\mid x \\mid e + e \\mid e - e \\mid e \\times e \\\\\n  \\textrm{Commands} & c &::=& \\skipe \\mid \\assign{x}{e} \\mid c; c \\mid \\ifte{e}{c}{c} \\mid \\while{e}{c}\n\\end{array}$$\n\n\n\\section{Big-Step Semantics}\n\n\\newcommand{\\bigstep}[2]{#1 \\Downarrow #2}\n\n\\emph{Big-step operational semantics}\\index{big-step operational semantics} explains what it means to run a program to completion.\nFor our example language, we define a relation written $\\bigstep{(v, c)}{v'}$, for ``command $c$, run with variable valuation $v$, terminates, modifying the valuation to $v'$.''\n\nThis relation is fairly straightforward to define with inference rules.\n\\encoding\n$$\\infer{\\bigstep{(v, \\skipe)}{v}}{}\n\\quad \\infer{\\bigstep{(v, \\assign{x}{e})}{\\mupd{v}{x}{\\denote{e}v}}}{}\n\\quad \\infer{\\bigstep{(v, c_1; c_2)}{v_2}}{\n  \\bigstep{(v, c_1)}{v_1}\n  & \\bigstep{(v_1, c_2)}{v_2}\n}$$\n$$\\infer{\\bigstep{(v, \\ifte{e}{c_1}{c_2})}{v'}}{\n  \\denote{e}{v} \\neq 0\n  & \\bigstep{(v, c_1)}{v'}\n}\n\\quad \\infer{\\bigstep{(v, \\ifte{e}{c_1}{c_2})}{v'}}{\n  \\denote{e}{v} = 0\n  & \\bigstep{(v, c_2)}{v'}\n}$$\n$$\\infer{\\bigstep{(v, \\while{e}{c_1})}{v_2}}{\n  \\denote{e}{v} \\neq 0\n  & \\bigstep{(v, c_1)}{v_1}\n  & \\bigstep{(v_1, \\while{e}{c_1})}{v_2}\n}\n\\quad \\infer{\\bigstep{(v, \\while{e}{c_1})}{v}}{\n  \\denote{e}{v} = 0\n}$$\n\nNotice how the definition is quite similar to a recursive interpreter\\index{interpreters} written in a high-level programming language, though we write with the language of relations instead of functional programming.\nFor instance, consider the simple case of the rule for sequencing, ``;''.\nWe first ``call the interpreter'' on the first subcommand $c_1$ with the original valuation $v$.\nThe result of the ``recursive call'' is a new valuation $v_1$, which we then feed into another ``recursive call'' on $c_2$, whose result becomes the overall result.\n\nWhy write this interpreter relationally instead of as a functional program?\nThe most relevant answer applies to situations like ours as users of Coq or even of informal mathematics, where we must be very careful that all of our recursive definitions are well-founded.\nThe recursive version of this relation is clearly not well-founded, as it would run forever on a nonterminating $\\mathsf{while}$ loop.\nIt is also easier to incorporate \\emph{nondeterminism}\\index{nondeterminism} in the relational style, a possibility that we will return to at the end of the chapter.\n\nThe big-step semantics is easy to apply to concrete programs.\nFor instance, define $\\mathtt{factorial}$ as the program $\\assign{\\mathtt{output}}{1}; \\while{\\mathtt{input}}{(\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}; \\assign{\\mathtt{input}}{\\mathtt{input} - 1})}$.\n\n\\begin{theorem}\n  There exists $v$ such that $\\bigstep{(\\mupd{\\mempty}{\\mathtt{input}}{2}, \\mathtt{factorial})}{v}$ and $\\msel{v}{\\mathtt{output}} = 2$.\n\\end{theorem}\n\n\\begin{proof}\n  By repeated application of the big-step inference rules.\n\\end{proof}\n\nWe can even prove that $\\mathtt{factorial}$ behaves correctly on all inputs, by way of a lemma about $\\mathtt{factorial\\_loop}$ defined as $\\while{\\mathtt{input}}{(\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}; \\assign{\\mathtt{input}}{\\mathtt{input} - 1})}$.\n\n\\begin{lemma}\\label{factorial_loop}\n  If $\\msel{v}{\\mathtt{input}} = n$ and $\\msel{v}{\\mathtt{output}} = o$, then there exists $v'$ such that $\\bigstep{(v, \\mathtt{factorial\\_loop})}{v'}$ and $\\msel{v'}{\\mathtt{output}} = n! \\times o$.\n\\end{lemma}\n\n\\begin{proof}\n  By induction on $n$.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\msel{v}{\\mathtt{input}} = n$, then there exists $v'$ such that $\\bigstep{(v, \\mathtt{factorial})}{v'}$ and $\\msel{v'}{\\mathtt{output}} = n!$.\n\\end{lemma}\n\n\\begin{proof}\n  Largely by direct appeal to Lemma \\ref{factorial_loop}.\n\\end{proof}\n\nMost of our program proofs in this book establish \\emph{safety properties}\\index{safety properties}, or invariants of transition systems.\nHowever, these last two examples with big-step semantics also establish program termination, taking us a few steps into the world of \\emph{liveness properties}\\index{liveness properties}.\n\n\n\\section{Small-Step Semantics}\n\nOften it is convenient to break a system's execution into small sequential steps, rather than executing a whole program in one go.\nPerhaps the most compelling example comes from concurrency, where it is difficult to give a big-step semantics directly.\nNonterminating programs are the other standard example.\nWe want to be able to establish invariants for those programs, all the same, and we need a semantics to help us state what it means to be an invariant.\n\n\\newcommand{\\smallstep}[2]{#1 \\to #2}\n\nThe canonical solution is \\emph{small-step operational semantics}\\index{small-step operational semantics}, probably the most common approach to formal program semantics in contemporary research.\nNow we define a single-step relation $\\smallstep{(v, c)}{(v', c')}$, meaning that one execution step transforms the first state into the second state.\nEach state is a valuation $v$ and a current command $c$.\n\nThese inference rules give the details.\n\\encoding\n$$\\infer{\\smallstep{(v, \\assign{x}{e})}{(\\mupd{v}{x}{\\denote{e}v}, \\skipe)}}{}\n\\quad \\infer{\\smallstep{(v, c_1; c_2)}{(v', c'_1; c_2)}}{\n    \\smallstep{(v, c_1)}{(v', c'_1)}\n}\n\\quad \\infer{\\smallstep{(v, \\skipe; c_2)}{(v, c_2)}}{}$$\n$$\\infer{\\smallstep{(v, \\ifte{e}{c_1}{c_2})}{(v, c_1)}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstep{(v, \\ifte{e}{c_1}{c_2})}{(v, c_2)}}{\n  \\denote{e}v = 0\n}$$\n$$\\infer{\\smallstep{(v, \\while{e}{c_1})}{(v, c_1; \\while{e}{c_1})}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstep{(v, \\while{e}{c_1})}{(v, \\skipe)}}{\n  \\denote{e}v = 0\n}$$\n\nThe intuition behind the rules may come best from working out an example.\n\n\\newcommand{\\smallsteps}[2]{#1 \\to^* #2}\n\n\\begin{theorem}\n  There exists valuation $v$ such that $\\smallsteps{(\\mupd{\\mempty}{\\mathtt{input}}{2}, \\mathtt{factorial})}{(v, \\skipe)}$ and $\\msel{v}{\\mathtt{output}} = 2$.\n\\end{theorem}\n\n\\begin{proof}\n  Here is a step-by-step (literally!) derivation that finds $v$.\n  $$\\begin{array}{cl}\n    & (\\mupd{\\mempty}{\\mathtt{input}}{2}, \\assign{\\mathtt{output}}{1}; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\skipe; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, (\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, (\\skipe; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, \\assign{\\mathtt{input}}{\\mathtt{input} - 1}; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, \\skipe; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, (\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, (\\skipe; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, \\assign{\\mathtt{input}}{\\mathtt{input} - 1}; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{0}}{\\mathtt{output}}{2}, \\skipe; \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{0}}{\\mathtt{output}}{2}, \\mathtt{factorial\\_loop}) \\\\\n    \\to & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{0}}{\\mathtt{output}}{2}, \\skipe)\n  \\end{array}$$\n\n  Clearly the final valuation assigns $\\mathtt{output}$ to 2.\n\\end{proof}\n\n\\subsection{Equivalence of Big-Step and Small-Step}\n\nDifferent theorems are easier to prove with different semantics, so it is helpful to establish formally the intuitive connection between big and small steps.\n\n\\begin{lemma}\n  If $\\smallsteps{(v, c_1)}{(v', c'_1)}$, then $\\smallsteps{(v, c_1; c_2)}{(v', c'_1; c_2)}$,\n\\end{lemma}\n\n\\begin{proof}\n  By induction on the derivation of $\\smallsteps{(v, c_1)}{(v', c'_1)}$.\n\\end{proof}\n\n\\begin{theorem}\n  If $\\bigstep{(v, c)}{v'}$, then $\\smallsteps{(v, c)}{(v', \\skipe)}$.\n\\end{theorem}\n\n\\begin{proof}\n  By induction on the derivation of $\\bigstep{(v, c)}{v'}$, appealing to the last lemma at two points.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\smallstep{(v, c)}{(v', c')}$ and $\\bigstep{(v', c')}{v''}$, then $\\bigstep{(v, c)}{v''}$.  In other words, we can add a small step to the beginning of any big-step derivation.\n\\end{lemma}\n\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(v, c)}{(v', c')}$.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\smallsteps{(v, c)}{(v', c')}$ and $\\bigstep{(v', c')}{v''}$, then $\\bigstep{(v, c)}{v''}$.  In other words, we can add any number of small steps to the beginning of any big-step derivation.\n\\end{lemma}\n\n\\begin{proof}\n  By induction on the derivation of $\\smallsteps{(v, c)}{(v', c')}$, appealing to the last lemma.\n\\end{proof}\n\n\\begin{theorem}\n  If $\\smallsteps{(v, c)}{(v', \\skipe)}$, then $\\bigstep{(v, c)}{v'}$.\n\\end{theorem}\n\n\\begin{proof}\n  Largely by appeal to the last lemma, considering that $\\bigstep{(v', \\skipe)}{v'}$.\n\\end{proof}\n\n\\subsection{Transition Systems from Small-Step Semantics}\n\nThe small-step semantics is a natural fit with our working definition of transition systems.\nWe can define a transition system from any valuation and command, where $\\mathbb V$ is the set of valuations and $\\mathbb C$ the set of commands, by $\\mathbb T(v, c) = \\angled{\\mathbb V \\times \\mathbb C, \\{(v, c)\\}, \\to}$.\nNow we bring to bear all of our machinery about invariants and their proof methods.\n\nFor instance, consider program $P = \\while{\\mathtt{n}}{\\assign{\\mathtt{a}}{\\mathtt{a} + \\mathtt{n}}; \\assign{\\mathtt{n}}{\\mathtt{n} - 2}}$.\n\n\\invariants\n\\begin{theorem}\n  Given even $n$, for $\\mathbb T(\\mupd{\\mupd{\\mempty}{\\mathtt{n}}{n}}{\\mathtt{a}}{0}, P)$, it is an invariant that the valuation maps variable $\\mathtt{a}$ to an even number.\n\\end{theorem}\n\n\\begin{proof}\n  First, we strengthen the invariant.\n  We compute the set $\\overline{P}$ of all commands that can be reached from $P$ by stepping the small-step semantics.\n  This set is finite, even though the set of \\emph{reachable valuations} is infinite, considering all potential $n$ values.\n  Our strengthened invariant is $I(v, c) = c \\in \\overline{P} \\land (\\exists n. \\; \\msel{v}{\\mathtt{n}} = n \\land \\textrm{even}(n)) \\land (\\exists a. \\; \\msel{v}{\\mathtt{a}} = a \\land \\textrm{even}(a))$.\n  In other words, we strengthen by adding the constraints that (1) we do not stray from the expected set of reachable commands and (2) variable \\texttt{n} also remains even.\n\n  The strengthened invariant is straightforward to prove by invariant induction, using repeated inversion on $\\to$ facts.\n\\end{proof}\n\n\n\\section{Contextual Small-Step Semantics}\n\nThe reader may have noticed some tedium in certain rules of the small-step semantics, like this one.\n$$\\infer{\\smallstep{(v, c_1; c_2)}{(v', c'_1; c_2)}}{\n    \\smallstep{(v, c_1)}{(v', c'_1)}\n}$$\nThis rule is an example of a \\emph{congruence rule}\\index{congruence rule}, which shows how to take a step and \\emph{lift} it into a step within a larger command, whose other subcommands are unaffected.\nComplex languages can require many congruence rules, and yet we feel like we should be able to avoid repeating all this boilerplate logic somehow.\nA common way to do so is switching to \\emph{contextual small-step semantics}\\index{contextual small-step semantics}.\n\nWe illustrate with our running example language.\nThe first step is to define a set of \\emph{evaluation contexts}\\index{evaluation contexts}, which formalize the spots within a larger command where steps are enabled.\n\\encoding\n$$\\begin{array}{rrcl}\n  \\textrm{Evaluation contexts} & C &::=& \\Box \\mid C; c\n\\end{array}$$\n\n\\newcommand{\\plug}[2]{#1[#2]}\nWe define the operator of \\emph{plugging}\\index{plugging evaluation contexts} an evaluation context in the natural way.\n\\begin{eqnarray*}\n  \\plug{\\Box}{c} &=& c \\\\\n  \\plug{(C; c_2)}{c} &=& \\plug{C}{c}; c_2\n\\end{eqnarray*}\n\nFor this language, the only interesting case of evaluation contexts is the one that allows us to \\emph{descend into the left subcommand}, because the old congruence rule invoked the step relation recursively for that position.\n\n\\newcommand{\\smallstepo}[2]{#1 \\to_0 #2}\n\nThe next ingredient is a reduced set of basic step rules, where we have dropped the congruence rule.\n$$\\infer{\\smallstepo{(v, \\assign{x}{e})}{(\\mupd{v}{x}{\\denote{e}v}, \\skipe)}}{}\n\\quad \\infer{\\smallstepo{(v, \\skipe; c_2)}{(v, c_2)}}{}$$\n$$\\infer{\\smallstepo{(v, \\ifte{e}{c_1}{c_2})}{(v, c_1)}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstepo{(v, \\ifte{e}{c_1}{c_2})}{(v, c_2)}}{\n  \\denote{e}v = 0\n}$$\n$$\\infer{\\smallstepo{(v, \\while{e}{c_1})}{(v, c_1; \\while{e}{c_1})}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstepo{(v, \\while{e}{c_1})}{(v, \\skipe)}}{\n  \\denote{e}v = 0\n}$$\n\n\\newcommand{\\smallstepc}[2]{#1 \\to_\\mathsf{c} #2}\n\nWe regain the full coverage of the original rules with a new relation $\\to_\\mathsf{c}$, saying that we may apply $\\to_0$ at the active subcommand within a larger command.\n$$\\infer{\\smallstepc{(v, C[c])}{(v', C[c'])}}{\n  \\smallstepo{(v, c)}{(v', c')}\n}$$\n\nLet's revisit last section's example, to see contextual semantics in action, especially to demonstrate how to express an arbitrary command as an evaluation context plugged with another command.\n\n\\newcommand{\\smallstepcs}[2]{#1 \\to^*_\\mathsf{c} #2}\n\n\\begin{theorem}\n  There exists valuation $v$ such that $\\smallstepcs{(\\mupd{\\mempty}{\\mathtt{input}}{2}, \\mathtt{factorial})}{(v, \\skipe)}$ and $\\msel{v}{\\mathtt{output}} = 2$.\n\\end{theorem}\n\n\\begin{proof}\n  $$\\begin{array}{cl}\n    & (\\mupd{\\mempty}{\\mathtt{input}}{2}, \\assign{\\mathtt{output}}{1}; \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mempty}{\\mathtt{input}}{2}, \\plug{(\\Box; \\mathtt{factorial\\_loop})}{\\assign{\\mathtt{output}}{1}}) \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\skipe; \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\plug{\\Box}{\\skipe; \\mathtt{factorial\\_loop}}) \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\plug{\\Box}{\\mathtt{factorial\\_loop}}) \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, (\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{1}, \\plug{((\\Box; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop})}{\\assign{\\mathtt{output}}{\\mathtt{output} \\times \\mathtt{input}}}) \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, (\\skipe; \\assign{\\mathtt{input}}{\\mathtt{input} - 1}); \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, \\plug{(\\Box; \\mathtt{factorial\\_loop})}{\\skipe; \\assign{\\mathtt{input}}{\\mathtt{input} - 1})} \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, \\assign{\\mathtt{input}}{\\mathtt{input} - 1}; \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{2}}{\\mathtt{output}}{2}, \\plug{(\\Box; \\mathtt{factorial\\_loop})}{\\assign{\\mathtt{input}}{\\mathtt{input} - 1}}) \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, \\skipe; \\mathtt{factorial\\_loop}) \\\\\n    = & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{1}}{\\mathtt{output}}{2}, \\plug{\\Box}{\\skipe; \\mathtt{factorial\\_loop}}) \\\\\n    \\to^*_\\mathsf{c} & \\ldots \\\\\n    \\to_\\mathsf{c} & (\\mupd{\\mupd{\\mempty}{\\mathtt{input}}{0}}{\\mathtt{output}}{2}, \\skipe)\n  \\end{array}$$\n\n  Clearly the final valuation assigns $\\mathtt{output}$ to 2.\n\\end{proof}\n\n\\subsection{Equivalence of Small-Step, With and Without Evaluation Contexts}\n\nThis new semantics formulation is equivalent to the other two, as we establish now.\n\n\\begin{theorem}\n  If $\\smallstep{(v, c)}{(v', c')}$, then $\\smallstepc{(v, c)}{(v', c')}$.\n\\end{theorem}\n\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(v, c)}{(v', c')}$.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\smallstepo{(v, c)}{(v', c')}$, then $\\smallstep{(v, c)}{(v', c')}$.\n\\end{lemma}\n\n\\begin{proof}\n  By cases on the derivation of $\\smallstepo{(v, c)}{(v', c')}$.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\smallstepo{(v, c)}{(v', c')}$, then $\\smallstep{(v, C[c])}{(v', C[c'])}$.\n\\end{lemma}\n\n\\begin{proof}\n  By induction on the structure of evaluation context $C$, appealing to the last lemma.\n\\end{proof}\n\n\\begin{theorem}\n  If $\\smallstepc{(v, c)}{(v', c')}$, then $\\smallstep{(v, c)}{(v', c')}$.\n\\end{theorem}\n\n\\begin{proof}\n  By inversion on the derivation of $\\smallstepc{(v, c)}{(v', c')}$, followed by an appeal to the last lemma.\n\\end{proof}\n\n\\subsection{\\label{eval_contexts}Evaluation Contexts Pay Off: Adding Concurrency}\n\nTo showcase the convenience of contextual semantics, let's extend our example language with a simple construct for running two commands in parallel\\index{parallel composition of threads}, implicitly extending the definition of plugging accordingly.\n$$\\begin{array}{rrcl}\n  \\textrm{Commands} & c &::=& \\ldots \\mid c || c\n\\end{array}$$\n\nTo capture the idea that \\emph{either} command in a parallel construct is allowed to step next, we extend evaluation contexts like so:\n\\encoding\n$$\\begin{array}{rrcl}\n  \\textrm{Evaluation contexts} & C &::=& \\ldots \\mid C || c \\mid c || C\n\\end{array}$$\n\nWe need one more basic step rule, to ``garbage-collect'' threads that have finished.\n$$\\infer{\\smallstepo{(v, \\skipe || c)}{(v, c)}}{}$$\n\nAnd that's it!\nThe new system faithfully captures our usual idea of threads executing in parallel.\nAll of the theorems proved previously about contextual steps continue to hold.\nIn fact, in the accompanying Coq code, literally the same proof scripts establish the new versions of the theorems, with no new human proof effort.\nIt's not often that concurrency comes for free in a rigorous proof!\n\n\n\\section{Determinism}\n\nOur last extension with parallelism introduced intentional nondeterminism in the semantics: a single starting state can step to multiple different next states.\nHowever, the three semantics for the original language are deterministic, and we can prove it.\n\n\\begin{theorem}\n  If $\\bigstep{(v, c)}{v_1}$ and $\\bigstep{(v, c)}{v_2}$, then $v_1 = v_2$.\n\\end{theorem}\n\n\\begin{proof}\n  By induction on the derivation of $\\bigstep{(v, c)}{v_1}$ and inversion on the derivation of $\\bigstep{(v, c)}{v_2}$.\n\\end{proof}\n\n\\begin{theorem}\n  If $\\smallstep{(v, c)}{(v_1, c_1)}$ and $\\smallstep{(v, c)}{(v_2, c_2)}$, then $v_1 = v_2$ and $c_1 = c_2$.\n\\end{theorem}\n\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(v, c)}{(v_1, c_1)}$ and inversion on the derivation of $\\smallstep{(v, c)}{(v_2, c_2)}$.\n\\end{proof}\n\n\\begin{theorem}\n  If $\\smallstepc{(v, c)}{(v_1, c_1)}$ and $\\smallstepc{(v, c)}{(v_2, c_2)}$, then $v_1 = v_2$ and $c_1 = c_2$.\n\\end{theorem}\n\n\\begin{proof}\n  Follows from the last theorem and the equivalence we proved between $\\to$ and $\\to_\\mathsf{c}$.\n\\end{proof}\n\nWe'll stop, for now, in our tour of useful properties of operational semantics.\nAll of the rest of the book is based on small-step semantics, with or without evaluation contexts.\nAs we study new kinds of programming languages, we will see how to model them operationally.\nAlmost every new proof technique is phrased as an approach to establishing invariants of transition systems based on small-step semantics.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Abstract Interpretation and Dataflow Analysis}\n\nThe last two chapters showed us both how to build a transition system from a program automatically and how to find an invariant for a transition system automatically.\nLet's now combine these ideas to find invariants for programs automatically, in a particular way associated with the technique of \\emph{dataflow analysis}\\index{dataflow analysis} used to drive many compiler optimizations.\nThroughout, we'll stick with the example of the small imperative language whose semantics we studied in the last chapter.\nWe'll confine our attention to its basic small-step semantics via the $\\to$ relation.\n\nModel checking builds up increasingly larger finite sets of reachable states in a system.\nA state $(v, c)$ of our imperative language combines \\emph{control state}\\index{control state} $c$ (the next command to execute) with \\emph{data state} $v$ (the values of the variables), and so model checking will find invariants that restrict both components.\nWe say that model checking is \\emph{path-sensitive}\\index{path-sensitive analysis} because its invariants can distinguish between the different data states that can be associated with the same control state, reached along different paths in the program's executions.\nPath-sensitive analyses tend to be much more computationally expensive than \\emph{path-insensitive}\\index{path-insensitive analysis} analyses, whose invariants collapse together all ways of reaching the same control state.\nDataflow analysis is one such path-insensitive approach, and its underlying theory is \\emph{abstract interpretation}\\index{abstract interpretation}.\n\n\n\\section{Definition of an Abstract Interpretation}\n\nAn abstract interpretation is a particular sort of abstraction, of the kind we met in studying model checking.\nIn that more general setting, we can represent concrete states with any sorts of abstract states.\nIn abstract interpretation, we most commonly associate each variable with an independent abstract description.\nOne example, which we'll formalize in more detail shortly, would be to label each variable as ``even,'' ``odd,'' or ``either.''\n\n\\newcommand{\\join}[0]{\\sqcup}\n\n\\begin{definition}\n  An \\emph{abstract interpretation} (for our example imperative language) is a tuple $\\angled{\\mathbb D, \\top, \\mathcal C, \\hat{+}, \\hat{-}, \\hat{\\times}, \\join, \\sim}$, where $\\mathbb D$ is a set (the domain of the analysis); $\\top \\in \\mathbb D$; $\\mathcal C : \\mathbb N \\to \\mathbb D$; $\\hat{+}, \\hat{-}, \\hat{\\times}, \\join : \\mathbb D \\times \\mathbb D \\to \\mathbb D$; and $\\sim \\; \\subseteq \\mathbb N \\times \\mathbb D$.\n  The idea is that:\n  \\begin{itemize}\n  \\item Abstract versions of numbers are $\\mathbb D$ values.\n  \\item $\\top$ (``top'')\\index{top element of an abstract interpretation} is the least specific abstract value, representing any concrete value.\n  \\item $\\mathcal C$ maps any constant to its most precise abstraction.\n  \\item $\\hat{+}$, $\\hat{-}$, and $\\hat{\\times}$ push abstraction through arithmetic operators, calculating their most precise abstractions.\n  \\item $\\join$ (``join'')\\index{join operation of an abstract interpretation} computes the \\emph{least upper bound}\\index{least upper bound} of two abstract values: the most specific value that represents any value associated with either input.\n  \\item $\\sim$ formalizes the idea of which concrete values are covered by which abstract values.\n  \\end{itemize}\n\n  For $a, b \\in \\mathbb D$, define $a \\sqsubseteq b$ to mean $\\forall n \\in \\mathbb N. \\; (n \\sim a) \\Rightarrow (n \\sim b)$.  That is, $b$ is at least as general as $a$.\n  An abstract interpretation must satisfy the following algebraic laws:\n  \\begin{itemize}\n  \\item $\\forall a \\in \\mathbb D. \\; a \\sqsubseteq \\top$\n  \\item $\\forall n \\in \\mathbb N. \\; n \\sim \\mathcal C(n)$\n  \\item $\\forall n, m \\in \\mathbb N. \\; \\forall a, b \\in \\mathbb D. \\; n \\sim a \\land m \\sim b \\Rightarrow (n + m) \\sim (a \\hat{+} b)$\n  \\item $\\forall n, m \\in \\mathbb N. \\; \\forall a, b \\in \\mathbb D. \\; n \\sim a \\land m \\sim b \\Rightarrow (n - m) \\sim (a \\hat{-} b)$\n  \\item $\\forall n, m \\in \\mathbb N. \\; \\forall a, b \\in \\mathbb D. \\; n \\sim a \\land m \\sim b \\Rightarrow (n \\times m) \\sim (a \\hat{\\times} b)$\n  \\item $\\forall a, b, a', b' \\in \\mathbb D. \\; a \\sqsubseteq a' \\land b \\sqsubseteq b' \\Rightarrow (a \\hat{+} b) \\sqsubseteq (a' \\hat{+} b')$\n  \\item $\\forall a, b, a', b' \\in \\mathbb D. \\; a \\sqsubseteq a' \\land b \\sqsubseteq b' \\Rightarrow (a \\hat{-} b) \\sqsubseteq (a' \\hat{-} b')$\n  \\item $\\forall a, b, a', b' \\in \\mathbb D. \\; a \\sqsubseteq a' \\land b \\sqsubseteq b' \\Rightarrow (a \\hat{\\times} b) \\sqsubseteq (a' \\hat{\\times} b')$\n  \\item $\\forall a, b \\in \\mathbb D. \\; a \\sqsubseteq (a \\join b)$\n  \\item $\\forall a, b \\in \\mathbb D. \\; b \\sqsubseteq (a \\join b)$\n  \\end{itemize}\n\\end{definition}\n\n\\newcommand{\\E}[0]{\\mathsf{E}}\n\\renewcommand{\\O}[0]{\\mathsf{O}}\n\nAs an example, consider this formalization of even-odd analysis, whose proof of soundness is left as an exercise for the reader.\n(While the treatment of subtraction may seem gratuitously imprecise, recall that we are working here with natural numbers and not integers, such that subtraction ``sticks'' at zero when the result would otherwise be negative.)\n\\begin{eqnarray*}\n  \\mathbb D &=& \\{\\E, \\O, \\top\\} \\\\\n  \\mathcal C(n) &=& \\textrm{$\\E$ or $\\O$, depending on parity of $n$} \\\\\n  \\E \\; \\hat{+} \\; \\E &=& \\E \\\\\n  \\E \\; \\hat{+} \\; \\O &=& \\O \\\\\n  \\O \\; \\hat{+} \\; \\E &=& \\O \\\\\n  \\O \\; \\hat{+} \\; \\O &=& \\E \\\\\n  \\_ \\; \\hat{+} \\; \\_ &=& \\top \\\\\n  \\E \\; \\hat{-} \\; \\E &=& \\E \\\\\n  \\O \\; \\hat{-} \\; \\O &=& \\E \\\\\n  \\_ \\; \\hat{-} \\; \\_ &=& \\top \\\\\n  \\E \\; \\hat{\\times} \\; \\_ &=& \\E \\\\\n  \\_ \\; \\hat{\\times} \\; \\E &=& \\E \\\\\n  \\O \\; \\hat{\\times} \\; \\O &=& \\O \\\\\n  \\_ \\; \\hat{\\times} \\; \\_ &=& \\top \\\\\n  \\E \\join \\E &=& \\E \\\\\n  \\O \\join \\O &=& \\O \\\\\n  \\_ \\join \\_ &=& \\top \\\\\n  n \\sim \\E &=& \\textrm{$n$ is even} \\\\\n  n \\sim \\O &=& \\textrm{$n$ is odd} \\\\\n  n \\sim \\top &=& \\textrm{always}\n\\end{eqnarray*}\n\nWe generally think of an abstract interpretation as forming a \\emph{lattice}\\index{lattice} (actually a semilattice\\index{semilattice}), which is roughly the algebraic structure characterized by operations like $\\join$, when $\\join$ truly returns the \\emph{most specific} or \\emph{least} upper bound of its two arguments.  We visualize the even-odd lattice like so.\n\n\\begin{center}\\begin{tikzpicture}[node distance=1.5cm]\n\\node(top)                      {$\\top$};\n\\node(E)   [below left of=top]  {$\\E$};\n\\node(O)   [below right of=top] {$\\O$};\n\n\\draw(top) -- (E);\n\\draw(top) -- (O);\n\\end{tikzpicture}\\end{center}\n\nThe idea is that taking the join of two elements moves us \\emph{up} the lattice to their lowest common ancestor.\n\nAn edge going up from $a$ to $b$ indicates that $a \\sqsubseteq b$.\nAs another example, consider a lattice tracking prime factors of numbers, up to 5.\nThen the picture version might go like so:\n\n\\begin{center}\\begin{tikzpicture}[node distance=1.5cm]\n\\node(top)                              {$\\{\\}$};\n\\node(two)        [below left of=top]   {$\\{2\\}$};\n\\node(three)      [below of=top]        {$\\{3\\}$};\n\\node(five)       [below right of=top]  {$\\{5\\}$};\n\\node(twothree)   [below left of=two]   {$\\{2, 3\\}$};\n\\node(twofive)    [below of=three]      {$\\{2, 5\\}$};\n\\node(threefive)  [below right of=five] {$\\{3, 5\\}$};\n\\node(bot)        [below of=twofive]    {$\\{2, 3, 5\\}$};\n\n\\draw(top)       -- (two);\n\\draw(top)       -- (three);\n\\draw(top)       -- (five);\n\\draw(two)       -- (twothree);\n\\draw(two)       -- (twofive);\n\\draw(three)     -- (twothree);\n\\draw(three)     -- (threefive);\n\\draw(five)      -- (twofive);\n\\draw(five)      -- (threefive);\n\\draw(twothree)  -- (bot);\n\\draw(twofive)   -- (bot);\n\\draw(threefive) -- (bot);\n\\end{tikzpicture}\\end{center}\n\nSince $\\sqsubseteq$ is clearly transitive, upward-moving paths across multiple nodes also imply $\\sqsubseteq$ relationships between their endpoints.\nIt's worth verifying quickly that any two nodes in this graph have a unique lowest common ancestor, which is the proper result of the $\\join$ operation on those nodes.\n\nAnother worthwhile exercise for the reader is to work out the proper definitions of $\\hat{+}$, $\\hat{-}$, and $\\hat{\\times}$ for this domain.\n\n\n\\section{Flow-Insensitive Analysis}\n\nWe now give our first recipe for building a program abstraction from an abstract interpretation.\nWe apply a \\emph{flow-insensitive} abstraction, which means we find an invariant that doesn't depend at all on the control part $c$ of a full state $(v, c)$.\nAlternatively, the invariant depends only on the data part $v$.\nConcretely, with $\\mathbb V$ the set of variables, we work with states $s \\in \\mathbb V \\to \\mathbb D$, taking the domain $\\mathbb D$ of our chosen abstract interpretation.\nAn abstract state $s$ for a concrete valuation $v$ assigns to each $x$ an abstract value $s(x)$ such that $v(x) \\sim s(x)$.\nWe overload the operator $\\sim$ to denote this compatibility via $v \\sim s$.\n\n\\newcommand{\\absexp}[1]{[#1]}\n\nAs a preliminary, we define the abstract interpretation of an expression like so:\n\\begin{eqnarray*}\n  \\absexp{n}s &=& \\mathcal C(n) \\\\\n  \\absexp{x}s &=& s(x) \\\\\n  \\absexp{e_1 + e_2}s &=& \\absexp{e_1}s \\hat{+} \\absexp{e_2}s \\\\\n  \\absexp{e_1 - e_2}s &=& \\absexp{e_1}s \\hat{-} \\absexp{e_2}s \\\\\n  \\absexp{e_1 \\times e_2}s &=& \\absexp{e_1}s \\hat{\\times} \\absexp{e_2}s\n\\end{eqnarray*}\n\n\\begin{theorem}\n  If $v \\sim s$, then $\\denote{e}v \\sim \\absexp{e}s$.\n\\end{theorem}\n\n\\newcommand{\\asgns}[1]{\\mathcal A(#1)}\n\nNext, we model the possible effects of commands.\nWe already said that our flow-insensitive analysis will forget about control flow in a command, but what does that mean formally?\nStates of this language, without control flow taken into account, are just variable valuations, and the only way a command can affect a valuation is through executing assignments.\nTherefore, forgetting the control flow of a command amounts to just \\emph{recording which assignments it contains syntactically}, losing all context about which Boolean tests would need to pass to reach each assignment.\nThis simple syntactic extraction process can be formalized with an assignments-of function $\\mathcal A$ for commands.\n\\begin{eqnarray*}\n  \\asgns{\\skipe} &=& \\{\\} \\\\\n  \\asgns{\\assign{x}{e}} &=& \\{(x, e)\\} \\\\\n  \\asgns{c_1; c_2} &=& \\asgns{c_1} \\cup \\asgns{c_2} \\\\\n  \\asgns{\\ifte{e}{c_1}{c_2}} &=& \\asgns{c_1} \\cup \\asgns{c_2} \\\\\n  \\asgns{\\while{e}{c_1}} &=& \\asgns{c_1}\n\\end{eqnarray*}\n\nAs a final preliminary ingredient, for abstract states $s_1$ and $s_2$, define $s_1 \\join s_2$ by $(s_1 \\join s_2)(x) = s_1(x) \\join s_2(x)$.\n\nNow we define the flow-insensitive step relation, over abstract states alone, as:\n$$\\infer{s \\to^c_\\mathsf{FI} s}{}\n\\quad \\infer{s \\to^c_\\mathsf{FI} s \\join \\mupd{s}{x}{\\absexp{e}s}}{\n  (x, e) \\in \\asgns{c}\n}$$\n\nWe can establish formally how forgetting about the order of assignments is a valid abstraction technique.\n\n\\begin{theorem}\\label{flow_insensitive_abstraction}\n  \\abstraction\n  Given command $c$, initial valuation $v$, and initial abstract state $s$ such that $v \\sim s$.  The transition system with initial state $s$ and step relation $\\to^c_\\mathsf{FI}$ simulates the system with initial state $(v, c)$ and step relation $\\to$, according to a simulation relation enforcing $\\sim$ between the valuation and abstract state.\n\\end{theorem}\n\nNow a simple procedure can find an invariant for the abstracted system.\nIn particular:\n\n\\begin{enumerate}\n\\item Initialize $s$ with the abstract state from the theorem statement.\n\\item \\label{flow_insensitive_loop}Compute $s' = s \\join \\bigsqcup_{(x, e) \\in \\asgns{c}} \\mupd{s}{x}{\\absexp{e}s}$.\n\\item If $s' \\sqsubseteq s$, then we're done; $s$ is the invariant.\n\\item Otherwise, assign $s = s'$ and return to \\ref{flow_insensitive_loop}.\n\\end{enumerate}\n\nEvery step in this outline is computable, since the abstract states will always be finite maps.\n\n\\begin{theorem}\\label{flow_insensitive_iteration}\n  \\invariants\n  If the outline above terminates, then it is an invariant of the flow-insensitive abstracted system that $s$ (its final value from the loop above) is an upper bound for every reachable state.  That is, for every reachable $s'$, $s' \\sqsubseteq s$.\n\\end{theorem}\n\nTo check a concrete program, we first abstract it to a flow-insensitive version with Theorem \\ref{flow_insensitive_abstraction}, then we find a guaranteed invariant with Theorem \\ref{flow_insensitive_iteration}.\nOne wrinkle here is that it is not obvious that our informal loop above always terminates.\nHowever, it always terminates if our abstract domain has \\emph{finite height}\\index{finite height of abstract domain}, meaning that there is no infinite ascending chain of distinct elements $a_i$ such that $a_i \\sqsubseteq a_{i+1}$ for all $i$.\nOur even-odd example trivially has that property, since it contains only finitely many distinct elements.\n\nIt is worth emphasizing that, when those conditions are met, our invariant-finding procedure is guaranteed to terminate, even though the underlying language is Turing-complete, so that most interesting analysis problems are uncomputable!\nThe catch is that it is always possible that the invariant found is a trivial one, where the abstract state maps every variable to $\\top$.\n\nHere is an example of a program where flow-insensitive even-odd analysis gives the most precise answer.\n$$\\assign{n}{10}; \\assign{x}{0}; \\while{n > 0}{\\assign{x}{x + 2 \\times n}; \\assign{n}{n - 1}}$$\n\nThe abstract state we wind up with is $\\mupd{\\mupd{\\mempty}{n}{\\top}}{x}{\\E}$.\n\n\\section{Flow-Sensitive Analysis}\n\nWe can only go so far with flow-insensitive invariants, which don't let us record different facts about the variables for different lines of the program code.\nSuch an analysis will get tripped up even by straightline code where parities of variables change as we go.\nHere is a trivial example program where the flow-insensitive analysis returns the useless answer $\\mupd{\\mempty}{x}{\\top}$, when the most precise answer would be $\\mupd{\\mempty}{x}{\\O}$.\n$$\\assign{x}{0}; \\assign{x}{1}$$\n\nThe solution to this problem can be to go to \\emph{flow-sensitive}\\index{flow-sensitive analysis} analysis, where an abstract state $S$ is a finite map from commands (all the intermediate ``program counters'' of an original command) to the abstract states of the previous section.\n\n\\newcommand{\\absstep}[3]{\\mathcal S(#1, #2, #3)}\n\\newcommand{\\absstepo}[2]{\\mathcal S(#1, #2)}\n\nWe define a function $\\absstep{s}{c}{f}$ to compute all of the states of the form $(s', c')$ reachable in a single step from $(s, c)$.\nActually, for each $(s', c')$ covered by that informal description, this function returns a map from keys $f(c')$ to values $s'$.\nThe idea is that function $f$ wraps the step in any additional command context that isn't participating directly in this step.\nSee how $f$ is modified in the sequencing case below, for something of an intuition for its purpose.\n\\begin{eqnarray*}\n  \\absstep{s}{\\skipe}{f} &=& \\mempty \\\\\n  \\absstep{s}{\\assign{x}{e}}{f} &=& \\mupd{\\mempty}{f(\\skipe)}{\\mupd{s}{x}{\\absexp{e}s}} \\\\\n  \\absstep{s}{\\skipe; c_2}{f} &=& \\mupd{\\mempty}{f(c_2)}{s} \\\\\n  \\absstep{s}{c_1; c_2}{f} &=& \\absstep{s}{c_1}{\\lambda c. \\; f(c; c_2)} \\\\\n  \\absstep{s}{\\ifte{e}{c_1}{c_2}}{f} &=& \\mupd{\\mupd{\\mempty}{f(c_1)}{s}}{f(c_2)}{s} \\\\\n  \\absstep{s}{\\while{e}{c_1}}{f} &=& \\mupd{\\mupd{\\mempty}{f(\\skipe)}{s}}{f(c_1; \\while{e}{c_1})}{s}\n\\end{eqnarray*}\n\nNote that the last two cases, for conditional control flow, ignore the test expression entirely, which is certainly sound, though it may lead to imprecision in the analysis.\nThis approximation is known as \\emph{path insensitivity}\\index{path-insensitive analysis}.\nDefine $\\absstepo{s}{c}$ as shorthand for $\\absstep{s}{c}{\\lambda c_1. \\; c_1}$.\n\nNow we can define a new abstract step relation.\n$$\\infer{(s, c) \\to_\\mathsf{FS} (s', c')}{\n  \\absstepo{s}{c}(c') = s'\n}$$\n\nThat is, we step from $(s, c)$ to $(s', c')$ precisely when, if we look up $c'$ in the result of running $c$ abstractly in $s$, we find $s'$.\n\nNow we can follow an analogous path to the one we did in the last section.\n\n\\begin{theorem}\\label{flow_sensitive_abstraction}\n  \\abstraction\n  Given command $c$ and initial valuation $v$.  The transition system with initial state $(s, c)$ and step relation $\\to_\\mathsf{FS}$ simulates the system with initial state $(v, c)$ and step relation $\\to$, according to a simulation relation enforcing equality of the commands, as well as $\\sim$ between the valuation and abstract state.\n\\end{theorem}\n\nNow another simple procedure can find an invariant for the abstracted system.\nWe write $S \\join S'$ for joining of two flow-sensitive abstract states.\nWhen $c$ is in the domain of exactly one of $S$ or $S'$, $S \\join S'$ agrees with the corresponding mapping.\nWhen $c$ is in neither domain, it isn't in the domain of $S \\join S'$ either.\nFinally, when $c$ is in both domains, we have $(S \\join S')(c) = S(c) \\join S'(c)$.\n\nAlso define $S \\sqsubseteq S'$ to mean that, whenever $S(c) = s$, there exists $s'$ such that $S'(c) = s'$ and $s \\sqsubseteq s'$.\n\nNow our procedure works as follows.\n\n\\begin{enumerate}\n\\item Initialize $S = \\mupd{\\mempty}{c}{\\lambda x. \\; \\top}$.\n\\item \\label{flow_sensitive_loop}Compute $S' = S \\join \\bigsqcup_{S(c) = s} \\absstepo{s}{c}$.\n\\item If $S' \\sqsubseteq S$, then we're done; $S$ is the invariant.\n\\item Otherwise, assign $S = S'$ and return to \\ref{flow_sensitive_loop}.\n\\end{enumerate}\n\nAgain, every step in this outline is computable, for the same reason as in the prior section.\n\n\\begin{theorem}\\label{flow_sensitive_iteration}\n  \\invariants\n  If the outline above terminates, then it is an invariant of the flow-sensitive abstracted system that, for reachable $(s, c)$, we have $S(c) = s'$ for some $s'$ with $s \\sqsubseteq s'$.\n\\end{theorem}\n\nAgain, the last two theorems together give us a recipe for computing an invariant automatically, when the loop terminates.\nThe flow-sensitive procedure is guaranteed to give an invariant at least as strong as what the flow-insensitive procedure would come up with, and often it's much stronger.\nHowever, flow-sensitive analysis is often much more computationally expensive (in time and memory), so there is a trade-off.\n\n\n\\section{Widening}\n\nConsider an abstract interpretation of \\emph{intervals}\\index{interval analysis}, where each elements of the domain is either $[a, b]$ or $[a, \\infty)$, for $a, b \\in \\mathbb N$.\nRestricting our attention to $a$ and $b$ values between 0 and 1 for illustration purposes, we have this diagram of the domain, where the bottom element represents an empty set.\n\n\\begin{center}\\begin{tikzpicture}[node distance=1.5cm]\n\\node(top)                             {$[0, \\infty)$};\n\\node(zeroone)    [below left of=top]  {$[0, 1]$};\n\\node(oneinf)     [below right of=top] {$[1, \\infty)$};\n\\node(zero)       [below of=zeroone]   {$[0, 0]$};\n\\node(one)        [below of=oneinf]    {$[1, 1]$};\n\\node(emp)        [below right of=zero]{$[1, 0]$};\n\n\\draw(top)       -- (zeroone);\n\\draw(top)       -- (oneinf);\n\\draw(zeroone)   -- (zero);\n\\draw(zeroone)   -- (one);\n\\draw(oneinf)    -- (one);\n\\draw(zero)      -- (emp);\n\\draw(one)       -- (emp);\n\\end{tikzpicture}\\end{center}\n\nThe abstract operators have intuitive and simple definitions, like, flattening the different kinds of intervals into a common notation, defining $(a_1, b_1) \\join (a_2, b_2) = (\\min(a_1, a_2), \\max(b_1, b_2))$ and $(a_1, b_1) \\hat{+} (a_2, b_2) = (a_1 + a_2, b_1 + b_2)$, with usual conventions about what it means to do arithmetic with $\\infty$.\n\nAgain, the lattice diagram above was simplified to cover only 0 and 1 as legal constant values.\nWe can define the interval lattice to draw from the full, infinite set of natural numbers.\nIn that case, we can quickly run into trouble with abstract interpretation.\nFor instance, consider this infinite-looping program:\n$$\\assign{\\mathsf{a}}{7}; \\while{\\mathsf{a}}{\\assign{\\mathsf{a}}{\\mathsf{a} + 3}}$$\n\nOne (flow-insensitive) invariant is that $\\mathsf{a} \\geq 7$, represented as the abstract state $\\mupd{\\mempty}{\\mathsf{a}}{[7, \\infty)}$.\nHowever, even the flow-sensitive analysis will keep growing the range of $\\mathsf{a}$, as it traverses the loop over and over!\nWe see $\\mathsf{a}$ initialized to $[7, 7]$, then grown to $[7, 10]$ after one loop iteration, then to $[7, 13]$ after another, and so on indefinitely.\n\nNotice that we wrote before that termination is guaranteed when the lattice has finite height, which we have just demonstrated is not true for general intervals, as our example program generates an infinite ascending chain of distinct intervals.\n\n\\newcommand{\\widen}[0]{\\triangledown}\n\nThe canonical solution to this problem is to employ a \\emph{widening}\\index{widening} operator $\\widen$.\nThis operator has the same soundness requirements as $\\join$, but we do not require that it gives the \\emph{least} upper bound of its two operands.\nIt merely needs to give some upper bound.\nIn fact, we don't want it to give least upper bounds; we want it to \\emph{skip ahead} in that ordering as necessary to promote termination.\nIn general, we don't want to replace all uses of $\\join$ with $\\widen$, though it is sound to do so.\nWe might apply $\\widen$ in place of $\\join$ only for commands that are the beginnings of loops, for instance, to guarantee that no infinite path in the program avoids infinitely many encounters with $\\widen$ to tame infinite ascending chains.\n\nFor intervals, when we are working with programs that we fear will keep increasing variables indefinitely through loops, a simple form of widening is defined as follows.\nSet $(a_1, b_1) \\widen (a_2, b_2) = (a_1, b_1) \\join (a_2, b_2)$ when $b_2 \\leq b_1$, that is, when the upper bound of the interval hasn't increased since the last iteration.\nOtherwise, set $(a_1, b_1) \\widen (a_2, b_2) = (\\min(a_1, a_2), \\infty)$.\nIn other words, when an interval expands to include higher values, fast-forward its upper bound to $\\infty$.\n\nWith this modification, analysis of our tricky example successfully finds the invariant $\\mathsf{a} \\geq 7$.\nIn fact, flow-insensitive and flow-sensitive interval analysis with this widening operator applied at loop starts are guaranteed to terminate, for any input programs.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{compiler_correctness}Compiler Correctness via Simulation Arguments}\n\n\\newcommand{\\outp}[1]{\\mathsf{out}(#1)}\n\nA good application of operational semantics is correctness of compiler transformations\\index{compilers}.\nA compiler is composed of a series of \\emph{phases}\\index{compiler phase}, each of which translates programs in some \\emph{source} language\\index{source language} into some \\emph{target} language\\index{target language}.\nUsually, in most phases of a compiler, the source and target languages are the same, and such phases are often viewed as \\emph{optimizations}\\index{optimization}\\index{compiler optimization}, which tend to improve performance of most programs in practice.\nThe verification problem is plenty hard enough when the source and target languages are the same, so we will confine our attention in this chapter to a single language.\nIt's almost the same as the imperative language from the last two chapters, but we add one new syntactic construction, underlined below.\n$$\\begin{array}{rrcl}\n  \\textrm{Numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Expressions} & e &::=& n \\mid x \\mid e + e \\mid e - e \\mid e \\times e \\\\\n  \\textrm{Commands} & c &::=& \\skipe \\mid \\assign{x}{e} \\mid c; c \\mid \\ifte{e}{c}{c} \\mid \\while{e}{c} \\mid \\underline{\\outp{e}}\n\\end{array}$$\n\nA command $\\outp{e}$ outputs\\index{output} the value of expression $e$, say by writing it to a terminal window.\nWhat's interesting about adding output is that now \\emph{different nonterminating\\index{nontermination} programs have interestingly different behavior}: they may produce different output sequences, finite or infinite.\nAny compiler phase should leave output behavior intact.\nIt's worth noticing that our workhorse technique of invariants can't help us here directly.\nOutput equivalence can only be judged by watching full runs of programs.\nA nonterminating program that has behaved itself up to some point, satisfying the invariant of our choice, may still fail to follow through later on.\nWhile invariants are complete for \\emph{safety} properties\\index{safety properties}, here we have our first systematic study of a class of \\emph{liveness} properties\\index{liveness properties}.\nWe must also delve into establishing \\emph{relational} properties\\index{relational properties} of programs, meaning that we reason about connections between executions of two different programs.\nIn our case, such a pair will include the program fed as input into a phase, plus the program that the phase generates.\n\n\\newcommand{\\silent}[0]{\\epsilon}\n\\newcommand{\\smallstepol}[3]{#1 \\stackrel{#2}{\\to_0} #3}\n\\newcommand{\\smallstepcl}[3]{#1 \\stackrel{#2}{\\to_\\mathsf{c}} #3}\n\nTo get started phrasing the correctness condition formally, we need to modify our operational semantics to track output.\nWe do so by adopting a \\emph{labeled transition system}\\index{labeled transition system}, where step arrows are annotated with \\emph{labels} that explain interactions with the world.\nFor this language, the only interaction kind is an output, which we will write as a number.\nWe also have \\emph{silent}\\index{silent steps} labels $\\silent$, for when no output takes place.\nFor completeness, here are the full rules of the extended language, where the definitions of contexts and plugging are inherited unchanged.\n\n$$\\infer{\\smallstepol{(v, \\outp{e})}{\\denote{e}v}{(v, \\skipe)}}{}$$\n$$\\infer{\\smallstepol{(v, \\assign{x}{e})}{\\silent}{(\\mupd{v}{x}{\\denote{e}v}, \\skipe)}}{}\n\\quad \\infer{\\smallstepol{(v, \\skipe; c_2)}{\\silent}{(v, c_2)}}{}$$\n$$\\infer{\\smallstepol{(v, \\ifte{e}{c_1}{c_2})}{\\silent}{(v, c_1)}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstepol{(v, \\ifte{e}{c_1}{c_2})}{\\silent}{(v, c_2)}}{\n  \\denote{e}v = 0\n}$$\n$$\\infer{\\smallstepol{(v, \\while{e}{c_1})}{\\silent}{(v, c_1; \\while{e}{c_1})}}{\n  \\denote{e}v \\neq 0\n}\n\\quad \\infer{\\smallstepol{(v, \\while{e}{c_1})}{\\silent}{(v, \\skipe)}}{\n  \\denote{e}v = 0\n}$$\n\n$$\\infer{\\smallstepcl{(v, C[c])}{\\ell}{(v', C[c'])}}{\n  \\smallstepol{(v, c)}{\\ell}{(v', c')}\n}$$\n\n\\newcommand{\\Tr}[1]{\\mathsf{Tr}(#1)}\n\\newcommand{\\terminate}[0]{\\mathsf{terminate}}\n\nTo reason about infinite executions, we need a new abstraction, compared to what has worked in our invariant-based proofs so far.\nThat abstraction will be \\emph{traces}\\index{traces}, sequences of outputs (and termination events) that a program might be observed to generate.\nWe define a command's trace set inductively.\nRecall that $\\cdot$ is the empty list, while $\\bowtie$ does list concatenation.\n$$\\infer{\\cdot \\in \\Tr{s}}{}\n\\quad \\infer{\\terminate \\in \\Tr{(v, \\skipe)}}{}\n\\quad \\infer{t \\in \\Tr{s}}{\n  \\smallstepcl{s}{\\silent}{s'}\n  & t \\in \\Tr{s'}\n}\n\\quad \\infer{\\concat{\\outp{n}}{t} \\in \\Tr{s}}{\n  \\smallstepcl{s}{n}{s'}\n  & t \\in \\Tr{s'}\n}$$\n\nNotice that a trace is allowed to end at any point, even if the program under inspection hasn't terminated yet.\nAlso, since our language is deterministic\\index{determinism}, for any two traces of one command, one trace is a prefix of the other.\nMany parts of the machinery we develop here will, however, work well for nondeterministic systems, as we will see with labeled transition systems for concurrency in Chapter \\ref{process_algebra}.\n\n\\newcommand{\\trinc}[2]{#1 \\preceq #2}\n\\newcommand{\\treq}[2]{#1 \\simeq #2}\n\n\\begin{definition}[Trace inclusion]\n  \\index{trace inclusion}For commands $c_1$ and $c_2$, let $\\trinc{c_1}{c_2}$ iff $\\Tr{c_1} \\subseteq \\Tr{c_2}$.\n\\end{definition}\n\n\\begin{definition}[Trace equivalence]\n  \\index{trace equivalence}For commands $c_1$ and $c_2$, let $\\treq{c_1}{c_2}$ iff $\\Tr{c_1} = \\Tr{c_2}$.\n\\end{definition}\n\nWe will enforce that a correct compiler phase respects trace equivalence.\nThat is, the output program has the same traces as the input program.\nFor nondeterministic languages, subtler conditions are called for, but we're happy to stay within the safe confines of determinism for this chapter.\n\n\n\\section{Basic Simulation Arguments and Optimizing Expressions}\n\n\\newcommand{\\cfold}[1]{\\mathsf{cfold}_1(#1)}\n\nAs our first example compiler phase, we consider a limited form of \\emph{constant folding}\\index{constant folding}, where expressions with statically known values are replaced by constants.\nThe whole of the optimization is (1) finding all maximal program subexpressions that don't contain variables and (2) replacing each such subexpression with its known constant value.\nWe write $\\cfold{c}$ for the result of applying this optimization on command $c$.\n(For the program transformations in this chapter, we stick to informal descriptions of how they operate, leaving the details to the accompanying Coq code.)\n\nA program optimized in this way proceeds in a very regular manner, compared to executions of the original, unoptimized program.\nThe small steps line up one-to-one.\nTherefore, a very regular kind of \\emph{simulation relation} connects them.\n(This notion is very similar to the one from Section \\ref{trs_simulation}, though now it incorporates labels.)\n\n\\begin{definition}[Simulation relation]\n  We say that binary relation $R$ over states of our object language is a \\emph{simulation relation} iff:\n  \\begin{enumerate}\n    \\item Whenever $(v_1, \\skipe) \\; R \\; (v_2, c_2)$, it follows that $c_2 = \\skipe$.\n    \\item Whenever $s_1 \\; R \\; s_2$ and $\\smallstepcl{s_1}{\\ell}{s'_1}$, there exists $s'_2$ such that $\\smallstepcl{s_2}{\\ell}{s'_2}$ and $s'_1 \\; R \\; s'_2$. \n  \\end{enumerate}\n\\end{definition}\n\nThe crucial second condition can be drawn like this.\n\n\\[\n\\begin{tikzcd}\ns_1 \\arrow{r}{R} \\arrow{d}{\\forall \\stackrel{\\ell}{\\to_{\\mathsf{c}}}} & s_2 \\arrow{d}{\\exists \\stackrel{\\ell}{\\to_{\\mathsf{c}}}} \\\\\ns'_1 & s'_2 \\arrow{l}{R^{-1}}\n\\end{tikzcd}\n\\]\n\n\\invariants\nAs usual, the diagram tells us that when a path along the left exists, a matching roundabout path exists, too.\nThat is, any step on the left can be matched by a step on the right.\nNotice the similarity to the invariant-induction principle that we have mostly relied on so far.\nInstead of showing that every step preserves a one-state predicate, we show that every step preserves a two-state predicate in a particular way.\nThe simulation approach is as general for relating programs as the invariant approach is for verifying individual programs.\n\n\\begin{theorem}\n  \\label{simulation_ok}If there exists a simulation $R$ such that $s_1 \\; R \\; s_2$, then $\\treq{s_1}{s_2}$.\n\\end{theorem}\n\\begin{proof}\n  We prove the two trace-inclusion directions separately.\n  The left-to-right direction proceeds by induction over the definition of traces on the left, while the right-to-left direction proceeds by similar induction on the right.\n  While most of the proof is generic in details of the labeled transition system, for the right-to-left direction we do rely on proofs of two important properties of this object language.\n  First, the semantics is \\emph{total}, in the sense that any state whose command isn't $\\skipe$ can take a step.\n  Second, the semantics is \\emph{deterministic}, in that there can be at most one label/state pair reachable in one step from a particular starting state.\n\n  In the inductive step of the right-to-left inclusion proof, we know that the righthand system has taken a step.\n  The lefthand system might already be a $\\skipe$, in which case, by the definition of simulations, the righthand system is already a $\\skipe$, contradicting the assumption that the righthand side stepped.\n  Otherwise, by totality, the lefthand system can take a step.\n  By the definition of simulation, there exists a matching step on the righthand side.\n  By determinism, the matching step is the same as the one we were already aware of.\n  Therefore, we have a new $R$ relationship to connect to that step and apply the induction hypothesis.\n\\end{proof}\n\nWe can apply this very general principle to constant folding.\n\n\\begin{theorem}\n  \\label{cfold_ok}For any $v$ and $c$, $\\treq{(v, c)}{(v, \\cfold{c})}$.\n\\end{theorem}\n\\begin{proof}\n  By a simulation argument using this relation:\n  \\begin{eqnarray*}\n    (v_1, c_1) \\; R \\; (v_2, c_2) &=& v_1 = v_2 \\land c_2 = \\cfold{c_1}\n  \\end{eqnarray*}\n  What we have done is translate the original theorem statement into the language of binary relations, as this simple case needs no equivalent of strengthening the induction hypothesis.\n  Internally to the proof, we need to define constant folding of evaluation contexts $C$, and we need to prove that primitive steps $\\to_0$ may be lifted to apply over constant-folded states, this second proof by case analysis on $\\to_0$ derivations.\n  Another more obvious workhorse is a lemma showing that constant folding of expressions preserves interpretation results.\n\\end{proof}\n\n\n\\section{Simulations That Allow Skipping Steps}\n\n\\newcommand{\\cfoldt}[1]{\\mathsf{cfold}_2(#1)}\n\nConsider an evolution of our constant-folding optimization to take advantage of known values of $\\mathsf{if}$ test expressions.\nDepending on whether the value is zero, we can replace the whole $\\mathsf{if}$ with one of its two cases.\nWe will write $\\cfoldt{c}$ for this expanded optimization and work up to proving it sound, too.\nHowever, we can no longer use last section's definition of simulation!\nThe reason is that optimizations intentionally cut down on steps that a program needs to execute.\nSome steps of the source program now have no matching steps of the target program, say when we are stepping an $\\mathsf{if}$ whose test expression had a known value.\n\nLet's take a first crack at making simulation more flexible.\n\n\\begin{definition}[Simulation relation with skipping (\\emph{faulty} version!)]\n  We say that binary relation $R$ over states of our object language is a \\emph{simulation relation with skipping} iff:\n  \\begin{enumerate}\n    \\item Whenever $(v_1, \\skipe) \\; R \\; (v_2, c_2)$, it follows that $c_2 = \\skipe$.\n    \\item Whenever $s_1 \\; R \\; s_2$ and $\\smallstepcl{s_1}{\\ell}{s'_1}$, then either:\n      \\begin{enumerate}\n        \\item there exists $s'_2$ such that $\\smallstepcl{s_2}{\\ell}{s'_2}$ and $s'_1 \\; R \\; s'_2$,\n        \\item or $\\ell = \\silent$ and $s'_1 \\; R \\; s_2$.\n      \\end{enumerate}\n  \\end{enumerate}\n\\end{definition}\n\nIn other words, to match a silent step, it suffices to do nothing, so long as $R$ still holds afterward.\n\n\\newcommand{\\addad}[1]{\\mathsf{withAds}(#1)}\n\nWe didn't mark the definition as \\emph{faulty} for nothing.\nIt actually does not imply trace equivalence.\nConsider a questionable ``optimization'' defined as $\\addad{\\while{1}{\\skipe}} = \\while{1}{\\outp{0}}$, and $\\addad{c} = c$ for all other $c$.\nIt adds a little extra advertisement into a particular infinite loop.\nNow we define a candidate simulation relation.\n\\begin{eqnarray*}\n  (v_1, c_1) \\; R \\; (v_2, c_2) &=& c_1 \\in \\{\\while{1}{\\skipe}, (\\skipe; \\while{1}{\\skipe})\\}\n\\end{eqnarray*}\nThis suspicious relation records nothing about $c_2$.\nThe $\\skipe$ condition of simulations is handled trivially, as we can see by inspection that $R$ does not allow $c_1$ to be $\\skipe$.\nChecking the execution-matching condition of simulations, $c_1$ is either $\\while{1}{\\skipe}$ or $(\\skipe; \\while{1}{\\skipe})$, each of which steps silently to the other.\nWe may match either step by keeping $c_2$ in place, as $R$ does not constrain $c_2$ at all.\nThus, $R$ is a simulation relation with skipping, and, for $c = \\while{1}{\\skipe}$, it relates $c$ to $\\addad{c}$.\n\nFrom here we expect to conclude trace equivalence.\nHowever, clearly $\\mathsf{withAds}$ can turn a program that never outputs into a program that outputs infinitely often!\n\nLet's patch our definition.\n\n\\begin{definition}[Simulation relation with skipping]\n  We say that an $\\mathbb N$-indexed family of binary relations $R_n$ over states of our object language is a \\emph{simulation relation with skipping} iff:\n  \\begin{enumerate}\n    \\item Whenever $(v_1, \\skipe) \\; R_n \\; (v_2, c_2)$, it follows that $c_2 = \\skipe$.\n    \\item Whenever $s_1 \\; R_n \\; s_2$ and $\\smallstepcl{s_1}{\\ell}{s'_1}$, then either:\n      \\begin{enumerate}\n        \\item there exist $n'$ and $s'_2$ such that $\\smallstepcl{s_2}{\\ell}{s'_2}$ and $s'_1 \\; R_{n'} \\; s'_2$,\n        \\item or $n > 0$, $\\ell = \\silent$, and $s'_1 \\; R_{n-1} \\; s_2$.\n      \\end{enumerate}\n  \\end{enumerate}\n\\end{definition}\n\nThis new version imposes a finite limit $n$ at any point, on how many times the righthand side may match lefthand steps without stepping itself.\nOur bad counterexample fails to satisfy the conditions, because eventually the starting step count $n$ will be used up, and the incorrect ``optimized'' program will be forced to reveal itself by taking a step that outputs.\n\n\\begin{theorem}\n  If there exists a simulation with skipping $R$ such that $s_1 \\; R_n \\; s_2$, then $\\treq{s_1}{s_2}$.\n\\end{theorem}\n\\begin{proof}\n  The proof is fairly similar to that of Theorem \\ref{simulation_ok}.\n  To show termination preservation in the backward direction, we find ourselves proving a lemma by induction on $n$.\n\\end{proof}\n\n\\newcommand{\\countIfs}[1]{\\mathsf{countIfs}(#1)}\n\n\\begin{theorem}\n  For any $v$ and $c$, $\\treq{(v, c)}{(v, \\cfoldt{c})}$.\n\\end{theorem}\n\\begin{proof}\n  By a simulation argument (with skipping) using this relation:\n  \\begin{eqnarray*}\n    (v_1, c_1) \\; R_n \\; (v_2, c_2) &=& v_1 = v_2 \\land c_2 = \\cfoldt{c_1} \\land \\countIfs{c_1} < n\n  \\end{eqnarray*}\n  We rely on a simple helper function $\\countIfs{c}$ to count how many $\\mathsf{If}$ nodes appear in the syntax of $c$.\n  This notion turns out to be a conservative upper bound on how many times in a row we will need to let lefthand steps go unmatched on the right.\n  The rest of the proof proceeds essentially the same way as in Theorem \\ref{cfold_ok}.\n\\end{proof}\n\n\n\\section{Simulations That Allow Taking Multiple Matching Steps}\n\n\\newcommand{\\flatten}[1]{\\mathsf{flatten}(#1)}\n\\newcommand{\\smallstepcls}[3]{#1 \\stackrel{#2}{\\to_\\mathsf{c}}^* #3}\n\nConsider our final example compiler phase: flattening\\index{flattening} expressions into sequences of assignments to temporaries, using only noncompound subexpressions, where the arguments to every binary operator are variables or constants.\nNow a single step at the source level must be matched by many steps at the target level.\nWe write $\\flatten{c}$ for the flattening of command $c$.\nHow can we prove that this transformation is correct?\n\n\\begin{definition}[Simulation relation with multiple matching steps]\n  We say that a binary relation $R$ over states of our object language is a \\emph{simulation relation with multiple matching steps} iff:\n  \\begin{enumerate}\n    \\item Whenever $(v_1, \\skipe) \\; R \\; (v_2, c_2)$, it follows that $c_2 = \\skipe$.\n    \\item Whenever $s_1 \\; R \\; s_2$ and $\\smallstepcl{s_1}{\\ell}{s'_1}$, there exists $s'_2$ such that $\\smallstepcls{s_2}{\\ell}{s'_2}$ and $s'_1 \\; R \\; s'_2$.\n  \\end{enumerate}\n\\end{definition}\n\nWe write $\\smallstepcls{s}{\\ell}{s'}$ to indicate that $s$ steps to $s'$ via zero or more silent steps and then one step with label $\\ell$ (which might also be silent).\n\n\\begin{theorem}\n  If there exists a simulation with multiple matching steps $R$ such that $s_1 \\; R \\; s_2$, then $\\treq{s_1}{s_2}$.\n\\end{theorem}\n\\begin{proof}\n  The backward direction is the interesting part of this proof.\n  The key lemma proceeds by strong induction on the number of steps needed to generate the trace on the right.\n\\end{proof}\n\n\\begin{theorem}\n  For any $v$ and $c$ where $c$ doesn't use any names that are reserved for temporaries, $\\treq{(v, c)}{(v, \\flatten{c})}$.\n\\end{theorem}\n\\begin{proof}\n  By a simulation argument (with multiple matching steps) using this relation:\n  \\begin{eqnarray*}\n    (v_1, c_1) \\; R \\; (v_2, c_2) &=& \\textrm{$c_1$ doesn't use any names reserved for temporaries} \\\\\n    && \\land \\; v_1 \\cong v_2 \\land c_2 = \\flatten{c_1}\n  \\end{eqnarray*}\n  The heart of this relation is a subrelation $\\cong$ over valuations, capturing when they agree on all variables that are not reserved for temporaries, since the flattened program will feel free to scribble all over the temporaries.\n  The details of $\\cong$ are especially important to the key lemma, showing that flattening of expressions is sound, both taking in a $\\cong$ premise and drawing a related $\\cong$ conclusion.\n  The overall proof is not short, with quite a few lemmas, found in the Coq code.\n\\end{proof}\n\n\\medskip\n\nIt might not be clear why we bothered to define simulation with multiple matching steps, when we already had simulation with skipping.\nAfter all, we use simulation to conclude completely symmetric facts about two commands, so why not just verify this section's example by applying simulation with skipping, with the operand order reversed?\n\nConsider the heart of the proof approach that we \\emph{did} adopt.\nWe need to show that any step of $c$ can be matched suitably by $\\flatten{c}$.\nThe proof is divided into cases by inversion on a premise $\\smallstepcl{(v, c)}{\\ell}{(v', c')}$.\nEach case naturally fixes the top-level structure of $c$, from which we can apply straightforward algebraic simplification to find the top-level structure of $\\flatten{c}$ and therefore the step rules that apply to it.\n\nNow consider applying simulation with skipping, with the commands passed as operands in the reverse order.\nThe crucial inversion is on $\\smallstepcl{(v, \\flatten{c})}{\\ell}{(v', c')}$.\nUnfortunately, the top-level structure of $\\flatten{c}$ does not imply the top-level structure of $c$, but we need to show that $c$ can take a matching step.\nWe need to prove a whole set of bothersome special-case inversion lemmas by induction, essentially to invert the action of what is, in the general case, an arbitrarily complex compiler.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Lambda Calculus and Simple Type Safety}\n\nWe'll now take a break from the imperative language we've been studying for the last three chapters, instead looking at a classic sort of small language that distills the essence of \\emph{functional} programming\\index{functional programming}.\nThat's the language paradigm that we've been using throughout this book, as we coded executable versions of algorithms.\nIts distinctive characteristics are first, a computation style based on simplifying terms instead of running step-by-step instructions that modify state; and second, use of functions as first-class values.\nFunctional programming went mainstream in the early 21st century, influencing widely adopted languages from JavaScript\\index{JavaScript}, where first-class functions are routinely used as callbacks in asynchronous event processing; to Scala\\index{Scala}, a hybrid language that melds functional-programming ideas with object-oriented programming for the Java platform; to Haskell\\index{Haskell}, a purely functional language that has become popular with programming hobbyists and is seeing increasing adoption in industry.\n\nThe heart of functional programming persists even in \\emph{$\\lambda$-calculus}\\index{$\\lambda$-calculus} (or lambda calculus\\index{lambda calculus}), the simplest version of which contains just three syntactic forms, but which provides probably the simplest of the widely known Turing-complete languages that is (nearly!) pleasant to program in directly.\n\n\n\\section{Untyped Lambda Calculus}\n\nHere is the syntax of the original $\\lambda$-calculus.\n$$\\begin{array}{rrcl}\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Expressions} & e &::=& x \\mid \\lambda x. \\; e \\mid e \\; e\n\\end{array}$$\n\nAn expression $\\lambda x. \\; e$\\index{$\\lambda$ expression} is a first-class, anonymous function, also called a \\emph{function abstraction}\\index{function abstraction} or \\emph{$\\lambda$-abstraction}\\index{$\\lambda$-abstraction}.\nWhen called, it replaces its formal-argument variable $x$ with the actual argument within $e$ and continues evaluating.\nThe third syntactic form $e \\; e$ uses \\emph{juxtaposition}\\index{juxtaposition}, or writing one term after another, for function application.\n\nA simple example of an expression is $\\lambda x. \\; x$, for an identity function.\nWhen we apply it to itself, like $(\\lambda x. \\; x) \\; (\\lambda x. \\; x)$, it reduces again to itself.\n\n\\newcommand{\\fv}[1]{\\textsf{FV}(#1)}\n\nWe can give a simple big-step operational semantics to $\\lambda$-terms.\nThe key auxiliary operation is \\emph{substitution}\\index{substitution}, where we write $\\subst{e}{x}{e'}$ for replacing all \\emph{free} occurrences of $x$ in $e$ with $e'$.\nHere we refer to a notion of \\emph{free variables}\\index{free variables}, which we should define first, as a recursive function.\n\\begin{eqnarray*}\n  \\fv{x} &=& \\{x\\} \\\\\n  \\fv{\\lambda x. \\; e} &=& \\fv{e} - \\{x\\} \\\\\n  \\fv{e_1 \\; e_2} &=& \\fv{e_1} \\cup \\fv{e_2}\n\\end{eqnarray*}\nIntuitively, a variable is free in an expression iff it doesn't occur inside the scope of a $\\lambda$ binding the same variable.\n\nNext we define substitution.\n\\begin{eqnarray*}\n  \\subst{x}{x}{e'} &=& e' \\\\\n  \\subst{y}{x}{e'} &=& y\\textrm{, if $y \\neq x$} \\\\\n  \\subst{\\lambda x. \\; e}{x}{e'} &=& \\lambda x. \\; e \\\\\n  \\subst{\\lambda y. \\; e}{x}{e'} &=& \\lambda y. \\; \\subst{e}{x}{e'}\\textrm{, if $y \\neq x$} \\\\\n  \\subst{e_1 \\; e_2}{x}{e'} &=& \\subst{e_1}{x}{e'} \\; \\subst{e_2}{x}{e'}\n\\end{eqnarray*}\n\nNotice a peculiar property of this definition when we work with \\emph{open} terms\\index{open terms}, whose free-variable sets are nonempty.\nAccording to the definition $\\subst{\\lambda x. \\; y}{y}{x} = \\lambda x. \\; x$.\nIn this example, we say that $\\lambda$-bound variable $x$ has been \\emph{captured}\\index{variable capture} unintentionally, where substitution created a reference to that $\\lambda$ where none existed before.\nSuch a problem can only arise when replacing a variable with an open term.\nIn this case, that term is $x$, where $\\fv{x} = \\{x\\} \\neq \\emptyset$.\n\nMore general investigations into $\\lambda$-calculus will define a more involved notion of \\emph{capture-avoiding} substitution\\index{capture-avoiding substitution}.\nInstead, in this book, we carefully steer clear of the $\\lambda$-calculus applications that require substituting open terms for variables, letting us stick with the simpler definition.\nWhen it comes to formal encoding of this style of syntax in proof assistants, surprisingly many complications arise, leading to what is still an active research area in encodings of language syntax with local variable binding\\index{variable binding}.\nSince we aim more for broad than deep coverage of the field of formal program reasoning, we are happy to avoid those complexities.\n\nWith substitution in hand, a big-step semantics\\index{big-step semantics} is easy to define.\nWe use the syntactic shorthand $v$ for a \\emph{value}\\index{value}, or term that needs no further evaluation, which in this case includes just the $\\lambda$-abstractions.\n\\encoding\n$$\\infer{\\bigstep{\\lambda x. \\; e}{\\lambda x. \\; e}}{}\n\\quad \\infer{\\bigstep{e_1 \\; e_2}{v'}}{\n  \\bigstep{e_1}{\\lambda x. \\; e}\n  & \\bigstep{e_2}{v}\n  & \\bigstep{\\subst{e}{x}{v}}{v'}\n}$$\n\nA value evaluates to itself.\nTo evaluate an application, evaluate both the function and the argument.\nThe function value must be some $\\lambda$-abstraction.\nSubstitute the argument value in the body of the abstraction, evaluate the result, and return that value as the overall value.\nNote that we only ever need to evaluate \\emph{closed} terms\\index{closed terms}, meaning terms that are not open, so we obey the restriction on substitution sketched above.\n\nIt may be surprising that these two rules are enough to define the full semantics of a Turing-complete language!\nIndeed, $\\lambda$-calculus is Turing-complete, and we must be able to find nonterminating programs.\nHere is one example.\n\\begin{eqnarray*}\n  \\Omega &=& (\\lambda x. \\; x \\; x) \\; (\\lambda x. \\; x \\; x) \\\\\n\\end{eqnarray*}\n\\begin{theorem}\n  $\\Omega$ does not evaluate to anything.  In other words, $\\bigstep{\\Omega}{v}$ implies a contradiction.\n\\end{theorem}\n\\begin{proof}\n  By induction on the derivation of $\\bigstep{\\Omega}{v}$.\n\\end{proof}\n\n\n\\section{A Quick Case Study in Program Verification: Church Numerals}\n\n\\newcommand{\\church}[1]{\\underline{#1}}\n\nSince $\\lambda$-calculus is Turing-complete, it must be able to represent numbers and all the usual arithmetic operations.\nThe classic representation is \\emph{Church numerals}\\index{Church numerals}, where every natural number $n$ is represented as a particular $\\lambda$-term $\\church{n}$ that, when passed a function $f$ as input, returns $f^n$, the $n$-way self-composition of $f$.\nIn some sense, repeating a process is the fundamental use of a natural number, and it turns out that we can recover all of the usual operations atop this primitive.\n\n\\newcommand{\\lc}[1]{\\mathsf{#1}}\n\nTwo $\\lambda$-calculus functions are sufficient to build up all the naturals as Church numerals.\n\\begin{eqnarray*}\n  \\lc{zero} &=& \\lambda f. \\; \\lambda x. \\; x \\\\\n  \\lc{plus1} &=& \\lambda n. \\; \\lambda f. \\; \\lambda x. \\; f \\; (n \\; f \\; x)\n\\end{eqnarray*}\nOur representation of 0 returns an identity function, no matter which $f$ it is passed.\nOur successor operation takes in a number $n$ and returns a new one that first runs $n$ and then applies $f$ one extra time.\nNow we have $\\church{0} = \\lc{zero}$, $\\church{1} = \\lc{plus1} \\; \\lc{zero}$, $\\church{2} = \\lc{plus1} \\; (\\lc{plus1} \\; \\lc{zero})$, and so on.\n\n\\newcommand{\\prechurch}[1]{\\left \\lfloor #1 \\right \\rfloor}\n\nThese Church numerals are not values yet.\nLet us formalize which values they evaluate to and tweak the encoding to use the values instead.\nWe write $\\prechurch{n}$ for the body of a $\\lambda$-abstraction that we are building to represent $n$, where variables $f$ and $x$ are in scope.\n\\begin{eqnarray*}\n  \\prechurch{0} &=& x \\\\\n  \\prechurch{n+1} &=& f \\; ((\\lambda f. \\; \\lambda x. \\; \\prechurch{n}) \\; f \\; x)\n\\end{eqnarray*}\nThe $n+1$ case may seem wastefully large, but, in fact, this is the precise form of the values produced by evaluating repeated applications of $\\lc{plus1}$ to $\\lc{zero}$, as the reader can verify using the big-step semantics.\nWe define $\\church{n} = \\lambda f. \\; \\lambda x. \\; \\prechurch{n}$, giving a canonical encoding for each number.\n\nNow we notate correctness of an encoding $e$ for number $n$ by $e \\sim n$, defining it as $\\bigstep{e}{\\church{n}}$, meaning that $e$ evaluates to the Church encoding of $n$.\nTwo first easy results show that our primitive constructors are correct.\n\n\\begin{theorem}\n  $\\lc{zero} \\sim 0$.\n\\end{theorem}\n\n\\begin{theorem}\n  If $e_n \\sim n$, then $\\lc{plus1} \\; e_n \\sim n+1$.\n\\end{theorem}\n\nThings get more interesting as we start to code up the arithmetic operations.\n\\begin{eqnarray*}\n  \\lc{add} &=& \\lambda n. \\; \\lambda m. \\; n \\; \\lc{plus1} \\; m\n\\end{eqnarray*}\n\nThat is, addition of $n$ to $m$ is calculated by applying $n$ $\\lc{plus1}$ operations to $m$.\n\n\\begin{theorem}\\label{church_add}\n  If $e_n \\sim n$ and $e_m \\sim m$, then $\\lc{add} \\; e_n \\; e_m \\sim n + m$.\n\\end{theorem}\n\\begin{proof}\n  After a few steps applying the big-step rules directly, we finish by induction on $n$.\n  A silly-seeming but necessary lemma proves that $\\subst{\\prechurch{n}}{m}{e} = \\prechurch{n}$, since $\\prechurch{n}$ does not contain free occurrences of $m$.\n\\end{proof}\n\nMultiplication proceeds in much the same way.\n\\begin{eqnarray*}\n  \\lc{mult} &=& \\lambda n. \\; \\lambda m. \\; n \\; (\\lc{add} \\; m) \\; \\lc{zero}\n\\end{eqnarray*}\n\n\\begin{theorem}\n  If $e_n \\sim n$ and $e_m \\sim m$, then $\\lc{mult} \\; e_n \\; e_m \\sim n \\times m$.\n\\end{theorem}\n\\begin{proof}\n  After a few steps applying the big-step rules directly, we finish by induction on $n$, within which we appeal to Theorem \\ref{church_add}.\n\\end{proof}\n\nAn enjoyable (though not entirely trivial) exercise for the reader is to generalize the methods of Church encoding to encoding of other inductive datatypes, including the syntax of $\\lambda$-calculus itself.\nA hallmark of a Turing-complete language is that it can host an interpreter for itself, and $\\lambda$-calculus is no exception!\n\n\n\\section{Small-Step Semantics}\n\n$\\lambda$-calculus is also straightforward to formalize with a small-step semantics\\index{small-step operational semantics} and evaluation contexts\\index{evaluation contexts}, following the method of Section \\ref{eval_contexts}.\nOne might argue that the technique is even simpler for $\\lambda$-calculus, since we must deal only with expressions, not also imperative variable valuations.\n\n$$\\begin{array}{rrcl}\n  \\textrm{Evaluation contexts} & C &::=& \\Box \\mid C \\; e \\mid v \\; C\n\\end{array}$$\nNote the one subtlety: the last form of evaluation context requires the term in a function position to be a \\emph{value}.\nThis innocuous-looking restriction enforces \\emph{call-by-value evaluation order}\\index{call-by-value}, where, upon encountering a function application, we must first evaluate the function, then evaluate the argument, and only then call the function.\nTweaks to the definition of $C$ produce other evaluation orders, like \\emph{call-by-name}\\index{call-by-name}, but we will say no more about those alternatives.\n\nWe assume a standard definition of what it means to plug an expression into the hole in a context, and now we can give the sole small-step evaluation rule for basic $\\lambda$-calculus, conventionally called the \\emph{$\\beta$-reduction} rule\\index{$\\beta$-reduction}.\n\\encoding\n$$\\infer{\\smallstep{\\plug{C}{(\\lambda x. \\; e) \\; v}}{\\plug{C}{\\subst{e}{x}{v}}}}{}$$\nThat is, we find a suitable position within the expression where a $\\lambda$-expression is applied to a value, and we replace that position with the appropriate substitution result.\n\nFollowing a very similar outline to what we used in Chapter \\ref{operational_semantics}, we establish equivalence between the two semantics for $\\lambda$-calculus.\n\n\\begin{theorem}\n  If $\\smallsteps{e}{v}$, then $\\bigstep{e}{v}$.\n\\end{theorem}\n\n\\begin{theorem}\n  If $\\bigstep{e}{v}$, then $\\smallsteps{e}{v}$.\n\\end{theorem}\n\nThere are a few proof subtleties beyond what we encountered before, and the Coq formalization may be worth reading, to see those details.\n\nAgain as before, we have a natural way to build a transition system from any $\\lambda$-term $e$, where $\\mathcal L$ is the set of $\\lambda$-terms.\nWe define $\\mathbb T(e) = \\angled{\\mathcal L, \\{e\\}, \\to}$.\nThe next section gives probably the most celebrated $\\lambda$-calculus result based on the transition-system perspective.\n\n\n\\section{Simple Types and Their Soundness}\n\nLet's spruce up the language with some more constructs.\n$$\\begin{array}{rrcl}\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{Expressions} & e &::=& n \\mid e + e \\mid x \\mid \\lambda x. \\; e \\mid e \\; e \\\\\n  \\textrm{Values} & v &::=& n \\mid \\lambda x. \\; e\n\\end{array}$$\nWe've added natural numbers as a primitive feature, supported via constants and addition.\nNumbers may be intermixed with functions, and we may, for instance, write first-class functions that take numbers as input or return numbers.\n\nOur language of evaluation contexts expands a bit.\n$$\\begin{array}{rrcl}\n  \\textrm{Evaluation contexts} & C &::=& \\Box \\mid C \\; e \\mid v \\; C \\mid C + e \\mid v + C\n\\end{array}$$\n\nNow we want to define two kinds of basic small steps, so it is worth defining a separate relation for them.\nHere we face a classic nuisance in writing rules that combine explicit syntax with standard mathematical operators, and we write $+$ for the syntactic construct and $\\textbf{+}$ for the mathematical addition operator.\n$$\\infer{\\smallstepo{(\\lambda x. \\; e) \\; v}{\\subst{e}{x}{v}}}{}\n\\quad \\infer{\\smallstepo{n + m}{n \\textbf{+} m}}{}$$\n\nHere is the overall step rule.\n$$\\infer{\\smallstep{\\plug{C}{e}}{\\plug{C}{e'}}}{\n  \\smallstepo{e}{e'}\n}$$\n\nWhat would be a useful property to prove about our new expressions?\nFor one thing, we don't want them to ``crash,'' as in the expression $(\\lambda x. \\; x) + 7$ that tries to add a function and a number.\nNo rule of the semantics knows what to do with that case, but it also isn't a value, so we shouldn't consider it as finished with evaluation.\nDefine an expression as \\emph{stuck}\\index{stuck term} when it is not a value and it cannot take a small step.\nFor ``reasonable'' expressions $e$, we should be able to prove that it is an invariant of $\\mathbb T(e)$ that no expression is ever stuck.\n\nTo define ``reasonable,'' we formalize the popular idea of a static type system.\nEvery expression will be assigned a type, capturing which sorts of contexts it may legally be dropped into.\nOur language of types is simple.\n\\abstraction\n$$\\begin{array}{rrcl}\n  \\textrm{Types} & \\tau &::=& \\mathbb N \\mid \\tau \\to \\tau\n\\end{array}$$\nWe have trees of function-space constructors, where all the leaves are instances of the natural-number type $\\mathbb N$.\nNote that, with type assignment, we have yet another case of \\emph{abstraction}, approximating a potentially complex expression with a type that only records enough information to rule out crashes.\n\n\\newcommand{\\hasty}[3]{#1 \\vdash #2 : #3}\n\nTo assign types to closed terms, we must recursively define what it means for an open term to have a type.\nTo that end, we use \\emph{typing contexts}\\index{typing context} $\\Gamma$, finite maps from variables to types.\nTo mimic standard notation, we write $\\Gamma, x : \\tau$ as shorthand for $\\mupd{\\Gamma}{x}{\\tau}$, overriding of key $x$ with value $\\tau$ in $\\Gamma$.\nNow we define typing as a three-place relation, written $\\hasty{\\Gamma}{e}{\\tau}$, to indicate that, assuming $\\Gamma$ as an assignment of types to $e$'s free variables, we conclude that $e$ has type $\\tau$.\n\nWe define the relation inductively, with one case per syntactic construct.\n\\modularity\n$$\\infer{\\hasty{\\Gamma}{x}{\\tau}}{\n  \\msel{\\Gamma}{x} = \\tau\n}\n\\quad \\infer{\\hasty{\\Gamma}{n}{\\mathbb N}}{}\n\\quad \\infer{\\hasty{\\Gamma}{e_1 + e_2}{\\mathbb N}}{\n    \\hasty{\\Gamma}{e_1}{\\mathbb N}\n    & \\hasty{\\Gamma}{e_2}{\\mathbb N}\n}$$\n$$\\infer{\\hasty{\\Gamma}{\\lambda x. \\; e}{\\tau_1 \\to \\tau_2}}{\n  \\hasty{\\Gamma, x : \\tau_1}{e}{\\tau_2}\n}\n\\quad \\infer{\\hasty{\\Gamma}{e_1 \\; e_2}{\\tau_2}}{\n  \\hasty{\\Gamma}{e_1}{\\tau_1 \\to \\tau_2}\n  & \\hasty{\\Gamma}{e_2}{\\tau_1}\n}$$\n\nWe write $\\hasty{}{e}{\\tau}$ as shorthand for $\\hasty{\\mempty}{e}{\\tau}$, meaning that closed term $e$ has type $\\tau$, with no typing context required.\nNote that this style of typing rules provides another instance of \\emph{modularity}, since we can separately type-check different subexpressions of a large expression, using just their types to coordinate expectations among subexpressions.\n\nIt should be an invariant of $\\mathbb T(e)$ that every reachable expression has the same type as the original, so long as the original was well-typed.\nThis observation is the key to proving that it is also an invariant that no reachable expression is stuck, using a proof technique called \\emph{the syntactic approach to type soundness}\\index{syntactic approach to type soundness}, which turns out to be just another instance of our general toolbox for invariant proofs.\n\nWe work our way through a suite of standard lemmas to support that invariant proof.\n\n\\begin{lemma}[Progress]\\label{progress}\n  If $\\hasty{}{e}{\\tau}$, then $e$ isn't stuck.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hasty{}{e}{\\tau}$.\n\\end{proof}\n\n\\begin{lemma}[Weakening]\\label{weakening}\n  If $\\hasty{\\Gamma}{e}{\\tau}$ and every mapping in $\\Gamma$ is also included in $\\Gamma'$, then $\\hasty{\\Gamma'}{e}{\\tau}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hasty{\\Gamma}{e}{\\tau}$.\n\\end{proof}\n\n\\begin{lemma}[Substitution]\\label{substitution}\n  If $\\hasty{\\Gamma, x : \\tau'}{e}{\\tau}$ and $\\hasty{}{e'}{\\tau'}$, then $\\hasty{\\Gamma}{\\subst{e}{x}{e'}}{\\tau}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hasty{\\Gamma, x: \\tau'}{e}{\\tau}$, with appeal to Lemma \\ref{weakening}.\n\\end{proof}\n\n\\begin{lemma}\\label{preservation0}\n  If $\\smallstepo{e}{e'}$ and $\\hasty{}{e}{\\tau}$, then $\\hasty{}{e'}{\\tau}$.\n\\end{lemma}\n\\begin{proof}\n  By inversion on the derivation of $\\smallstepo{e}{e'}$, with appeal to Lemma \\ref{substitution}.\n\\end{proof}\n\n\\begin{lemma}\\label{generalize_plug}\n  If any type of $e_1$ is also a type of $e_2$, then any type of $\\plug{C}{e_1}$ is also a type of $\\plug{C}{e_2}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the structure of $C$.\n\\end{proof}\n\n\\begin{lemma}[Preservation]\\label{preservation}\n  If $\\smallstep{e_1}{e_2}$ and $\\hasty{}{e_1}{\\tau}$, then $\\hasty{}{e_2}{\\tau}$.\n\\end{lemma}\n\\begin{proof}\n  By inversion on the derivation of $\\smallstep{e_1}{e_2}$, with appeal to Lemmas \\ref{preservation0} and \\ref{generalize_plug}.\n\\end{proof}\n\n\\invariants\n\\begin{theorem}[Type Soundness]\n  If $\\hasty{}{e}{\\tau}$, then $\\neg \\textrm{stuck}$ is an invariant of $\\mathbb T(e)$.\n\\end{theorem}\n\\begin{proof}\n  First, we strengthen the invariant to $I(e) = \\; \\hasty{}{e}{\\tau}$, justifying the implication by Lemma \\ref{progress}, Progress.\n  Then we apply invariant induction, where the base case is trivial.\n  The induction step is a direct match for Lemma \\ref{preservation}, Preservation.\n\\end{proof}\n\nThe syntactic approach to type soundness is often presented as a proof technique in isolation, but what we see here is that it follows very directly from our general invariant proof technique.\nUsually syntactic type soundness is presented as fundamentally about proving Progress and Preservation conditions.\nThe Progress condition maps to invariant strengthening, and the Preservation condition maps to invariant induction, which we have used in almost every invariant proof so far.\nSince the basic proof structure matches our standard one, the main insight is the usual one: a good choice of a strengthened invariant.\nIn this case, invariant $I(e) = \\; \\hasty{}{e}{\\tau}$ is that crucial insight, including the original design of the set of types and the typing relation.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Types and Mutation}\n\nThe syntactic approach to type soundness continues to apply to \\emph{impure} functional languages, which combine imperative side effects with first-class functions.\nWe'll study the general domain through its most common exemplar: $\\lambda$-calculus with \\emph{mutable references}\\index{mutable references}\\index{references}.\n\n\\section{Simply Typed Lambda Calculus with Mutable References}\n\n\\newcommand{\\newref}[1]{\\mathsf{new}(#1)}\n\\newcommand{\\readref}[1]{!#1}\n\\newcommand{\\writeref}[2]{#1 := #2}\n\nHere is an extension of the lambda-calculus syntax from last chapter, with additions underlined.\n$$\\begin{array}{rrcl}\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{Expressions} & e &::=& n \\mid e + e \\mid x \\mid \\lambda x. \\; e \\mid e \\; e \\mid \\underline{\\newref{e} \\mid \\; \\readref{e} \\mid \\writeref{e}{e}}\n\\end{array}$$\n\n\\newcommand{\\elet}[3]{\\mathsf{let} \\; #1 = #2 \\; \\mathsf{in} \\; #3}\n\nThe three new expression forms deal with \\emph{references}, which act like, for instance, Java\\index{Java} objects that only have single public fields.\nWe write $\\newref{e}$ to allocate a new reference initialized with value $e$, we write $\\readref{e}$ for reading the value stored in reference $e$, and we write $\\writeref{e_1}{e_2}$ for overwriting the value of reference $e_1$ with $e_2$.\nAn example is worth a thousand words, so let's consider a concrete program.\nWe'll use two notational shorthands:\n\\begin{eqnarray*}\n  \\elet{x}{e_1}{e_2} &\\triangleq& (\\lambda x. \\; e_2) \\; e_1 \\\\\n  e_1; e_2 &\\triangleq& \\elet{\\_}{e_1}{e_2} \\textrm{ (for $\\_$ a variable not used anywhere else)}\n\\end{eqnarray*}\n\nHere is a simple program that uses references.\n$$\\elet{r}{\\newref{0}}{\\writeref{r}{\\; \\readref{r} + 1}; \\readref{r}}$$\n\nThis program (1) allocates a new reference $r$ storing the value 0; (2) increments $r$'s value by 1; and (3) returns the new $r$ value, which is 1.\n\nTo be more formal about the meanings of all programs, we extend the operational semantics from last chapter.\nFirst, we add some new kinds of evaluation contexts.\n$$\\begin{array}{rrcl}\n  \\textrm{Evaluation contexts} & C &::=& \\Box \\mid C \\; e \\mid v \\; C \\mid C + e \\mid v + C \\\\\n  &&& \\mid \\; \\underline{\\newref{C} \\mid \\; \\readref{C} \\mid \\writeref{C}{e} \\mid \\writeref{v}{C}}\n\\end{array}$$\n\nNext we define the basic reduction steps of the language.\nIn contrast to last chapter's semantics for pure $\\lambda$-calculus, here we work with states that include not just expressions but also \\emph{heaps}\\index{heaps} $h$, partial functions from references to their current stored values.\nWe begin by copying over the two basic-step rules from last chapter, threading through the heap $h$ unchanged.\n$$\\infer{\\smallstepo{(h, (\\lambda x. \\; e) \\; v)}{(h, \\subst{e}{x}{v})}}{}\n\\quad \\infer{\\smallstepo{(h, n + m)}{(h, n \\textbf{+} m)}}{}$$\n\nTo write out the rules that are specific to references, it's helpful to extend our language syntax with a form that will never appear in original programs, but which does show up at intermediate execution steps.\nIn particular, let's add an expression form for \\emph{locations}\\index{locations}, the runtime values of references, and let's say that locations also count as values.\n$$\\begin{array}{rrcl}\n  \\textrm{Locations} & \\ell &\\in& \\mathbb N \\\\\n  \\textrm{Expressions} & e &::=& n \\mid e + e \\mid x \\mid \\lambda x. \\; e \\mid e \\; e \\mid \\newref{e} \\mid \\; \\readref{e} \\mid \\writeref{e}{e} \\mid \\underline{\\ell} \\\\\n  \\textrm{Values} & v &::=& n \\mid \\lambda x. \\; e \\mid \\underline{\\ell}\n\\end{array}$$\n\n\\newcommand{\\dom}[1]{\\mathsf{dom}(#1)}\nNow we can write the rules for the three reference primitives.\n$$\\infer{\\smallstepo{(h, \\newref{v})}{(\\mupd{h}{\\ell}{v}, \\ell)}}{\n  \\ell \\notin \\dom{h}\n}\n\\quad \\infer{\\smallstepo{(h, \\readref{\\ell})}{(h, v)}}{\n  \\msel{h}{\\ell} = v\n}\n\\quad \\infer{\\smallstepo{(h, \\writeref{\\ell}{v'})}{(\\mupd{h}{\\ell}{v'}, v')}}{\n  \\msel{h}{\\ell} = v\n}$$\n\nTo evaluate a reference allocation $\\newref{e}$, we nondeterministically\\index{nondeterminism} pick some unused location $\\ell$ and initialize it with the requested value.\nTo read from a reference in $\\readref{e}$, we just look up the location in the heap; the program will be \\emph{stuck} if the location is not already included in $h$.\nFinally, to write to a reference with $\\writeref{e_1}{e_2}$, we check that the requested location is already in the heap (we're stuck if not), then we overwrite its value with the new one.\n\nHere is the overall step rule, which looks just like the one for basic $\\lambda$-calculus, with a heap wrapped around everything.\n$$\\infer{\\smallstep{(h, \\plug{C}{e})}{(h', \\plug{C}{e'})}}{\n  \\smallstepo{(h, e)}{(h', e')}\n}$$\n\nAs a small exercise for the reader, it may be worth using this judgment to derive that our example program from before always returns 1.\nEven fixing the empty heap in the starting state, there is some nondeterminism in which final heap it returns: the possibilities are all the single-location heaps, mapping their single locations to value 1.\nIt is natural to allow this nondeterminism in allocation, since typical memory allocators in real systems don't give promises about predictability in the addresses that they return.\nHowever, we will be able to prove that, for instance, any program returning a number \\emph{gives the same answer, independently of nondeterministic choices made by the allocator}.\nThat property is not true in programming languages like C\\index{C programming language} that are not \\emph{memory safe}\\index{memory safety}, as they allow arithmetic and comparisons on pointers\\index{pointers}, the closest C equivalent of our references.\n\n\n\\section{Type Soundness}\n\n\\newcommand{\\reft}[1]{#1 \\; \\mathsf{ref}}\n\nFor $\\lambda$-calculus with references, we can prove a similar type-soundness theorem to what we proved last chapter, though the proof has a twist or two.\nTo start with, we should define our extended type system, with one new case for references.\n$$\\begin{array}{rrcl}\n  \\textrm{Types} & \\tau &::=& \\mathbb N \\mid \\tau \\to \\tau \\mid \\underline{\\reft{\\tau}}\n\\end{array}$$\n\nHere are the rules from last chapter's basic $\\lambda$-calculus, which we can keep unchanged.\n$$\\infer{\\hasty{\\Gamma}{x}{\\tau}}{\n  \\msel{\\Gamma}{x} = \\tau\n}\n\\quad \\infer{\\hasty{\\Gamma}{n}{\\mathbb N}}{}\n\\quad \\infer{\\hasty{\\Gamma}{e_1 + e_2}{\\mathbb N}}{\n    \\hasty{\\Gamma}{e_1}{\\mathbb N}\n    & \\hasty{\\Gamma}{e_2}{\\mathbb N}\n}$$\n$$\\infer{\\hasty{\\Gamma}{\\lambda x. \\; e}{\\tau_1 \\to \\tau_2}}{\n  \\hasty{\\Gamma, x : \\tau_1}{e}{\\tau_2}\n}\n\\quad \\infer{\\hasty{\\Gamma}{e_1 \\; e_2}{\\tau_2}}{\n  \\hasty{\\Gamma}{e_1}{\\tau_1 \\to \\tau_2}\n  & \\hasty{\\Gamma}{e_2}{\\tau_1}\n}$$\n\nWe also need a rule for each of the reference primitives.\n$$\\infer{\\hasty{\\Gamma}{\\newref{e}}{\\reft{\\tau}}}{\n  \\hasty{\\Gamma}{e}{\\tau}\n}\n\\quad \\infer{\\hasty{\\Gamma}{\\; \\readref{e}}{\\tau}}{\n    \\hasty{\\Gamma}{e}{\\reft{\\tau}}\n}\n\\quad \\infer{\\hasty{\\Gamma}{\\writeref{e_1}{e_2}}{\\tau}}{\n  \\hasty{\\Gamma}{e_1}{\\reft{\\tau}}\n  & \\hasty{\\Gamma}{e_2}{\\tau}\n}$$\n\nThat's enough notation to let us state type soundness, which is indeed provable.\n\n\\begin{theorem}[Type Soundness]\n  If $\\hasty{}{e}{\\tau}$, then $\\neg \\textrm{stuck}$ is an invariant of $\\mathbb T(e)$.\n\\end{theorem}\n\nHowever, we will need to develop some more machinery to let us state the strengthened invariant that makes the proof go through.\n\n\\newcommand{\\rhasty}[4]{#1; #2 \\vdash #3 : #4}\n\nThe trouble with our typing rules is that they disallow location constants, but those constants \\emph{will} arise in intermediate states of program execution.\nTo prepare for them, we introduce \\emph{heap typings}\\index{heap typings} $\\Sigma$, partial functions from locations to types.\nThe idea is that a heap typing $\\Sigma$ models a heap $h$ by giving the intended type for each of its locations.\nWe define an expanded typing judgment of the form $\\rhasty{\\Sigma}{\\Gamma}{e}{\\tau}$, with a new parameter included solely to enable the following rule.\n$$\\infer{\\rhasty{\\Sigma}{\\Gamma}{\\ell}{\\tau}}{\n  \\msel{\\Sigma}{\\ell} = \\tau\n}$$\n\nWe must also extend every typing rule we gave before, adding an extra ``$\\Sigma;$'' prefix, threaded mindlessly through everything.\nWe never extend $\\Sigma$ as we recurse into subexpressions, and we only examine it in leaves of derivation trees, corresponding to $\\ell$ expressions.\n\nWe have made some progress toward stating an inductive invariant for the type-soundness theorem.\nThe essential idea of the proof is found in the invariant choice $I(h, e) = \\exists \\Sigma. \\; \\rhasty{\\Sigma}{\\mempty}{e}{\\tau}$.\nHowever, we can tell that something is suspicious with this invariant, since it does not mention $h$.\nWe should also somehow characterize the relationship between $\\Sigma$ and $h$.\n\n\\newcommand{\\heapty}[2]{#1 \\vdash #2}\n\nHere is a first cut at defining a relation $\\heapty{\\Sigma}{h}$.\n$$\\infer{\\heapty{\\Sigma}{h}}{\n  \\forall \\ell, \\tau. \\; \\msel{\\Sigma}{\\ell} = \\tau \\Rightarrow \\exists v. \\; \\msel{h}{\\ell} = v \\land \\rhasty{\\Sigma}{\\mempty}{v}{\\tau}\n}$$\n\nIn other words, whenever $\\Sigma$ announces the existence of location $\\ell$ meant to store values of type $\\tau$, the heap $h$ actually stores some value $v$ for $\\ell$, and that value has the right type.\nNote the tricky recursion inherent in typing $v$ with respect to the very same $\\Sigma$.\n\nThis rule as stated is not \\emph{quite} sufficient to make the invariant inductive.\nWe could get stuck on a $\\newref{e}$ expression if the heap $h$ becomes \\emph{infinite}, with no free addresses left to allocate.\nOf course, we know that finite executions, started in the empty heap, only produce finite intermediate heaps.\nLet's remember that fact with another condition in the $\\heapty{\\Sigma}{h}$ relation.\n$$\\infer{\\heapty{\\Sigma}{h}}{\n  (\\forall \\ell, \\tau. \\; \\msel{\\Sigma}{\\ell} = \\tau \\Rightarrow \\exists v. \\; \\msel{h}{\\ell} = v \\land \\rhasty{\\Sigma}{\\mempty}{v}{\\tau})\n  & (\\exists \\; \\mathsf{bound}. \\; \\forall \\ell \\geq \\mathsf{bound}. \\; \\ell \\notin \\dom{h})\n}$$\n\nThe rule requires the existence of some upper bound $\\mathsf{bound}$ on the already-allocated locations.\nBy construction, whenever we need to allocate a fresh location, we may choose $\\mathsf{bound}$, or indeed any location greater than it.\n\nWe now have the right machinery to define an inductive invariant, namely:\n\\invariants\n$$I(h, e) = \\exists \\Sigma. \\; \\rhasty{\\Sigma}{\\mempty}{e}{\\tau} \\land \\heapty{\\Sigma}{h}$$\n\nWe prove variants of all of the lemmas behind last chapter's type-safety proof, with a few new ones and twists on the originals.\nHere we give some highlights.\n\n\\begin{lemma}[Heap Weakening]\n  If $\\rhasty{\\Sigma}{\\Gamma}{e}{\\tau}$ and every mapping in $\\Sigma$ is also included in $\\Sigma'$, then $\\rhasty{\\Sigma'}{\\Gamma}{e}{\\tau}$.\n\\end{lemma}\n\n\\begin{lemma}\n  If $\\smallstepo{(h, e)}{(h', e')}$, $\\rhasty{\\Sigma}{\\mempty}{e}{\\tau}$, and $\\heapty{\\Sigma}{h}$, then there exists $\\Sigma'$ such that $\\rhasty{\\Sigma'}{\\mempty}{e'}{\\tau}$, $\\heapty{\\Sigma'}{h'}$, and $\\Sigma'$ preserves all mappings from $\\Sigma$.\n\\end{lemma}\n\n\\begin{lemma}\n  If $\\rhasty{\\Sigma}{\\mempty}{\\plug{C}{e_1}}{\\tau}$, then there exists $\\tau_0$ such that $\\rhasty{\\Sigma}{\\mempty}{e_1}{\\tau_0}$ and, for all $e_2$ and $\\Sigma'$, if $\\rhasty{\\Sigma'}{\\mempty}{e_2}{\\tau_0}$ and $\\Sigma'$ preserves mappings from $\\Sigma$, then $\\rhasty{\\Sigma'}{\\mempty}{\\plug{C}{e_2}}{\\tau}$.\n\\end{lemma}\n\n\\begin{lemma}[Preservation]\n  If $\\smallstep{(h, e)}{(h', e')}$, $\\rhasty{\\Sigma}{\\mempty}{e}{\\tau}$, and $\\heapty{\\Sigma}{h}$, then there exists $\\Sigma'$ such that $\\rhasty{\\Sigma'}{\\mempty}{e'}{\\tau}$ and $\\heapty{\\Sigma'}{h'}$.\n\\end{lemma}\n\n\n\\section{Garbage Collection}\n\nFunctional languages like ML\\index{ML} and Haskell\\index{Haskell} include features very similar to the mutable references that we study in this chapter.\nHowever, their execution models depart in an important way from the operational semantics we just defined: they use \\emph{garbage collection}\\index{garbage collection} to deallocate unused references, whereas our last semantics allows references to accumulate forever in the heap, even if it is clear that some of them will never be needed again.\nWorry not!\nWe can model garbage collection with one new rule of the operational semantics, and then our type-safety proof adapts and shows that we still avoid stuckness, when the garbage collector can snatch \\emph{unreachable} locations away from us at any moment.\n\n\\newcommand{\\freeloc}[1]{\\mathsf{freeloc}(#1)}\n\nTo define \\emph{unreachable}, we start with a way to compute the \\emph{free locations} of an expression.\n\\begin{eqnarray*}\n  \\freeloc{x} &=& \\emptyset \\\\\n  \\freeloc{n} &=& \\emptyset \\\\\n  \\freeloc{e_1 + e_2} &=& \\freeloc{e_1} \\cup \\freeloc{e_2} \\\\\n  \\freeloc{\\lambda x. \\; e_1} &=& \\freeloc{e_1} \\\\\n  \\freeloc{e_1 \\; e_2} &=& \\freeloc{e_1} \\cup \\freeloc{e_2} \\\\\n  \\freeloc{\\newref{e_1}} &=& \\freeloc{e_1} \\\\\n  \\freeloc{\\readref{e_1}} &=& \\freeloc{e_1} \\\\\n  \\freeloc{\\writeref{e_1}{e_2}} &=& \\freeloc{e_1} \\cup \\freeloc{e_2} \\\\\n  \\freeloc{\\ell} &=& \\{\\ell\\}\n\\end{eqnarray*}\n\n\\newcommand{\\reach}[2]{\\mathcal R_{#1}(#2)}\n\nNext, we define a relation to capture \\emph{which locations are reachable from some starting expression, relative to a particular heap?}\nFor each expression $e$ and heap $h$, we define $\\reach{h}{e}$ as the set of locations reachable from $e$ via $h$.\n$$\\infer{\\ell \\in \\reach{h}{\\ell}}{}\n\\quad \\infer{\\ell' \\in \\reach{h}{\\ell}}{\n  \\msel{h}{\\ell} = v\n  & \\ell' \\in \\reach{h}{v}\n}\n\\quad \\infer{\\ell' \\in \\reach{h}{e}}{\n  \\ell \\in \\freeloc{e}\n  & \\ell' \\in \\reach{h}{\\ell}\n}$$\n\nIn order, the rules say: any location reaches itself; any location reaches anywhere reachable from the value assigned to it by $h$; and any expression reaches anywhere reachable from any of its free locations.\n\nNow we add one new top-level rule to the operational semantics, saying \\emph{unreachable locations may be removed at any time}.\n$$\\infer{\\smallstep{(h, e)}{(h', e)}}{\n  \\begin{array}{c}\n    \\forall \\ell, v. \\; \\ell \\in \\reach{h}{e} \\land \\msel{h}{\\ell} = v \\Rightarrow \\msel{h'}{\\ell} = v \\\\\n    \\forall \\ell, v. \\; \\msel{h'}{\\ell} = v \\Rightarrow \\msel{h}{\\ell} = v \\\\\n    h' \\neq h\n  \\end{array}\n}$$\n\nLet us explain each premise in more detail.\nThe first premise says that, going from the old heap $h$ to the new heap $h'$, \\emph{the value of every reachable reference is preserved}.\nThe second premise says that \\emph{the new heap is a subheap of the original, not spontaneously adding any new mappings}.\nThe final premise says that we have actually done some useful work: the new heap isn't just the same as the old one.\n\nIt may not be clear why we must include the last premise.\nThe reason has to do with our formulation of type safety, by saying that programs never get \\emph{stuck}.\nWe defined that $e$ is \\emph{stuck} if it is not a value, but it also can't take a step.\nIf we omitted from the garbage-collection rule the premise $h' \\neq h$, then this rule would \\emph{always} apply, for any term, simply by setting $h' = h$.\nThat is, \\emph{no} term would ever be stuck, and type safety would be meaningless!\nSince the rule also requires that $h'$ be \\emph{no larger than} $h$ (with the second premise), additionally requiring $h' \\neq h$ forces $h'$ to \\emph{shrink}, garbage-collecting at least one location.\nThus, in any execution state, we can ``kill time'' by running garbage collection only finitely many times before we need to find some ``real'' step to run.\nMore precisely, the limit on how many times we can run garbage collection in a row, starting from heap $h$, is $|\\dom{h}|$, the number of locations in $h$.\n\nThe type-safety proof is fairly straightforward to update.\nWe prove progress by \\emph{ignoring} the garbage-collection rule, since the existing rules were already enough to find a step for every nonvalue.\nA bit more work is needed to update the proof of preservation; its cases for the existing rules follow the same way as before, while we must prove a few lemmas on the way to handling the new rule.\n\n\\begin{lemma}[Transitivity for reachability]\n  If $\\freeloc{e_1} \\subseteq \\freeloc{e_2}$, then $\\reach{h}{e_1} \\subseteq \\reach{h}{e_2}$.\n\\end{lemma}\n\n\\begin{lemma}[Irrelevance of unreachable locations for typing]\n  If $\\heapty{\\Sigma}{h}$, $\\rhasty{\\Sigma}{\\Gamma}{e}{\\tau}$, then $\\rhasty{\\Sigma'}{\\Gamma}{e}{\\tau}$, if we also know that, for all $\\ell$ and $\\tau'$, when $\\ell \\in \\reach{h}{e}$ and $\\msel{\\Sigma}{\\ell} = \\tau'$, it follows that $\\msel{\\Sigma'}{\\ell} = \\tau'$.\n\\end{lemma}\n\n\\begin{lemma}[Reachability sandwich]\n  If $\\ell \\in \\reach{h}{e}$, $\\msel{h}{\\ell} = v$, and $\\ell' \\in \\reach{h}{v}$, then $\\ell' \\in \\reach{h}{e}$.\n\\end{lemma}\n\nTo extend the proof of preservation, we need to show that the strengthened invariant still holds after garbage collection.\nA key element is choosing the new heap typing.\nWe pick \\emph{the restriction of the old heap typing $\\Sigma$ to the domain of the new heap $h'$}.\nThat is, we drop from the heap typing all locations that have been garbage collected, preserving the types of the survivors.\nSome work is required to show that this strategy is sound, given the definition of reachability, but the lemmas above work out the details, leaving just a bit of bookkeeping in the preservation proof.\nThe final safety proof then proceeds in exactly the same way as before.\n\nOur proof here hasn't quite covered all the varieties of garbage collectors that exist.\nIn particular, \\emph{copying collectors}\\index{copying garbage collectors} may \\emph{move references to different locations}, while we only allow collectors to delete some references.\nIt may be an edifying exercise for the reader to extend our proof in a way that also supports reference relocation.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Hoare Logic: Verifying Imperative Programs}\n\nWe now take a step away from the last chapters in two dimensions: we switch back from functional to imperative programs, and we return to proofs of deep correctness properties, rather than mere absence of type-related crashes.\nNonetheless, the essential proof structure winds up being the same, as we once again prove invariants of transition systems!\n\n\n\\section{An Imperative Language with Memory}\n\n\\newcommand{\\assert}[1]{\\mathsf{assert}(#1)}\n\\newcommand{\\readfrom}[1]{{*}[#1]}\n\\newcommand{\\writeto}[2]{\\readfrom{#1} \\leftarrow #2}\n\nTo provide us with an interesting enough playground for program verification, let's begin by defining an imperative language with an infinite mutable heap.\nFor reasons that will become clear shortly, we do a strange bit of mixing of syntax and semantics.\nIn certain parts of the syntax, we include \\emph{assertions}\\index{assertions} $a$, which are arbitrary mathematical predicates over program state, split between heaps $h$ and variable valuations $v$.\n\n$$\\begin{array}{rrcl}\n  \\textrm{Numbers} & n &\\in& \\mathbb N \\\\\n  \\textrm{Variables} & x &\\in& \\mathsf{Strings} \\\\\n  \\textrm{Expressions} & e &::=& n \\mid x \\mid e + e \\mid e - e \\mid e \\times e \\mid \\readfrom{e} \\\\\n  \\textrm{Boolean expressions} & b &::=& e = e \\mid e < e \\\\\n  \\textrm{Commands} & c &::=& \\skipe \\mid \\assign{x}{e} \\mid \\writeto{e}{e} \\mid c; c \\\\\n  &&& \\mid \\ifte{b}{c}{c} \\mid \\{a\\}\\while{b}{c} \\mid \\assert{a}\n\\end{array}$$\n\nBeside assertions, we also have memory-read operations $\\readfrom{e}$ and memory-write operations $\\writeto{e_1}{e_2}$, which are written suggestively, as if the memory were a global array named $*$.\nLoops have sprouted an extra assertion in their syntax, which we will actually ignore in the language semantics, but which becomes important as part of the proof technique we will learn, especially in automating it.\n\nExpressions have a standard recursive semantics.\n\\begin{eqnarray*}\n  \\denote{n}(h, v) &=& n \\\\\n  \\denote{x}(h, v) &=& \\msel{v}{x} \\\\\n  \\denote{e_1 + e_2}(h, v) &=& \\denote{e_1}(h, v) + \\denote{e_2}(h, v) \\\\\n  \\denote{e_1 - e_2}(h, v) &=& \\denote{e_1}(h, v) - \\denote{e_2}(h, v) \\\\\n  \\denote{e_1 \\times e_2}(h, v) &=& \\denote{e_1}(h, v) \\times \\denote{e_2}(h, v) \\\\\n  \\denote{\\readfrom{e}}(h, v) &=& \\msel{h}{\\denote{e}(h, v)} \\\\\n  \\denote{e_1 = e_2}(h, v) &=& \\denote{e_1}(h, v) = \\denote{e_2}(h, v) \\\\\n  \\denote{e_1 < e_2}(h, v) &=& \\denote{e_1}(h, v) < \\denote{e_2}(h, v)\n\\end{eqnarray*}\n\nWe finish up with a big-step semantics in the style of those we've seen before, with the added complication of threading a heap through.\n\\encoding\n$$\\infer{\\bigstep{(h, v, \\skipe)}{(h, v)}}{}\n\\quad \\infer{\\bigstep{(h, v, \\assign{x}{e})}{(h, \\mupd{v}{x}{\\denote{e}(h, v)})}}{}$$\n\n$$\\infer{\\bigstep{(h, v, \\writeto{e_1}{e_2})}{(\\mupd{h}{\\denote{e_1}(h, v)}{\\denote{e_2}(h, v)}, v)}}{}$$\n\n$$\\infer{\\bigstep{(h, v, c_1; c_2)}{(h_2, v_2)}}{\n  \\bigstep{(h, v, c_1)}{(h_1, v_1)}\n  & \\bigstep{(h_1, v_1, c_2)}{(h_2, v_2)}\n}$$\n\n$$\\infer{\\bigstep{(h, v, \\ifte{b}{c_1}{c_2})}{(h', v')}}{\n  \\denote{b}(h, v)\n  & \\bigstep{(h, v, c_1)}{(h', v')}\n}\n\\quad \\infer{\\bigstep{(h, v, \\ifte{b}{c_1}{c_2})}{(h', v')}}{\n  \\neg \\denote{b}(h, v)\n  & \\bigstep{(h, v, c_2)}{(h', v')}\n}$$\n\n$$\\infer{\\bigstep{(h, v, \\{I\\} \\while{b}{c})}{(h', v')}}{\n  \\denote{b}(h, v)\n  & \\bigstep{(h, v, c; \\{I\\} \\while{b}{c})}{(h', v')}\n}\n\\quad \\infer{\\bigstep{(h, v, \\while{b}{c})}{(h, v)}}{\n  \\neg \\denote{b}(h, v)\n}$$\n\n$$\\infer{\\bigstep{(h, v, \\assert{a})}{(h, v)}}{\n  a(h, v)\n}$$\n\nReasoning directly about operational semantics can get tedious, so let's develop some machinery for proving program correctness automatically.\n\n\n\\section{Hoare Triples}\n\n\\newcommand{\\hoare}[3]{\\{#1\\} #2 \\{#3\\}}\n\nMuch as we did with type systems, we define a syntactic predicate and prove it sound once and for all.\nAfterward, we can automatically show that particular programs and their specifications inhabit the predicate.\nThis time, predicate instances will be written like $\\hoare{P}{c}{Q}$, with $c$ the command being verified, $P$ its \\emph{precondition}\\index{precondition} (assumption about the program state before we start running $c$), and $Q$ its \\emph{postcondition} (obligation about the program state after $c$ finishes).\nWe call any such fact a \\emph{Hoare triple}\\index{Hoare triple}, and the overall predicate is an instance of \\emph{Hoare logic}\\index{Hoare logic}.\n\n\\encoding\nA first rule for $\\skipe$ is easy: anything that was true before is also true after.\n\n$$\\infer{\\hoare{P}{\\skipe}{P}}{}$$\n\nA rule for assignment is slightly more involved: to state what we know is true after, we recall that there existed a prestate satisfying the precondition, which then evolved into the poststate in the expected way.\n$$\\infer{\\hoare{P}{\\assign{x}{e}}{\\lambda (h, v). \\; \\exists v'. \\; P(h, v') \\land v = \\mupd{v'}{x}{\\denote{e}(h, v')}}}{}$$\n\nThe memory-write command is treated symmetrically.\n$$\\infer{\\hoare{P}{\\writeto{e_1}{e_2}}{\\lambda (h, v). \\; \\exists h'. \\; P(h', v) \\land h = \\mupd{h'}{\\denote{e_1}(h', v)}{\\denote{e_2}(h', v)}}}{}$$\n\nTo model sequencing, we thread predicates through in an intuitive way.\n$$\\infer{\\hoare{P}{c_1; c_2}{R}}{\n  \\hoare{P}{c_1}{Q}\n  & \\hoare{Q}{c_2}{R}\n}$$\n\nFor conditional statements, we start from the basic approach of sequencing, adding two twists.\nFirst, since the two subcommands run after different outcomes of the test expression, we extend their preconditions.\nSecond, since we may reach the end of the command after running either subcommand, we take the disjunction of their postconditions.\n$$\\infer{\\hoare{P}{\\ifte{b}{c_1}{c_2}}{\\lambda s. \\; Q_1(s) \\lor Q_2(s)}}{\n  \\hoare{\\lambda s. \\; P(s) \\land \\denote{b}(s)}{c_1}{Q_1}\n  & \\hoare{\\lambda s. \\; P(s) \\land \\neg \\denote{b}(s)}{c_2}{Q_2}\n}$$\n\nComing to loops, we at last have a purpose for the assertion annotated on each one.\n\\invariants\nWe call those assertions \\emph{loop invariants}\\index{loop invariants}; one of these is meant to be true every time a loop iteration begins.\nWe will try to avoid confusion with the more fundamental concept of invariant for transition systems, though in fact the two are closely related formally, which we will see in the last section of this chapter.\nEssentially, the loop invariant gives the \\emph{induction hypothesis} that makes the program correctness proof go through.\nWe encapsulate the induction reasoning once and for all, in the proof of soundness for Hoare triples.\nTo verify an individual program, it is only necessary to prove the premises of the rule, which we give now.\n$$\\infer{\\hoare{P}{\\{I\\} \\while{b}{c}}{\\lambda s. \\; I(s) \\land \\neg \\denote{b}(s)}}{\n  (\\forall s. \\; P(s) \\Rightarrow I(s))\n  & \\hoare{\\lambda s. \\; I(s) \\land \\denote{b}(s)}{c}{I}\n}$$\nIn words: the loop invariant is true when we begin the loop, and every iteration preserves the invariant, given the extra knowledge that the loop test succeeded.\nIf the loop finishes, we know that the invariant is still true, but now the test is false.\n\nThe final command-specific rule, for assertions, is a bit anticlimactic.\nThe precondition is carried over as postcondition, if it is strong enough to prove the assertion.\n$$\\infer{\\hoare{P}{\\assert{I}}{P}}{\n  \\forall s. \\; P(s) \\Rightarrow I(s)\n}$$\n\nOne more essential rule remains, this time not specific to any command form.\nThe rules we've given deduce specific kinds of precondition-postcondition pairs.\nFor instance, the $\\skipe$ rule forces the precondition and postcondition to match.\nHowever, we expect to be able to prove $\\hoare{\\lambda (h, v). \\; \\msel{v}{x} > 0}{\\skipe}{\\lambda (h, v). \\; \\msel{v}{x} \\geq 0}$, because the postcondition is \\emph{weaker}\\index{weaker predicate} than the precondition, meaning the precondition implies the postcondition.\nAlternatively, the precondition is \\emph{stronger}\\index{stronger predicate} than the postcondition, because the precondition keeps all restrictions from the postcondition while adding new ones.\nHoare Logic's \\emph{rule of consequence}\\index{rule of consequence} allows us to build a new Hoare triple from an old one by \\emph{strengthening the precondition}\\index{strengthening the precondition} and \\emph{weakening the postcondition}\\index{weakening the postcondition}.\n$$\\infer{\\hoare{P'}{c}{Q'}}{\n  \\hoare{P}{c}{Q}\n  & (\\forall s. \\; P'(s) \\Rightarrow P(s))\n  & (\\forall s. \\; Q(s) \\Rightarrow Q'(s))\n}$$\n\nThese rules together are \\emph{complete}\\index{completeness of Hoare logic}, in the sense that any intuitively correct precondition-postcondition pair for a command is provable.\nHere we only go into detail on a proof of the dual property, \\emph{soundness}\\index{soundness of Hoare logic}.\n\n\\begin{lemma}\\label{hoare_while}\n  Assume the following fact: Together, $\\bigstep{(h, v, c)}{(h', v')}$, $I(h, v)$, and $\\denote{b}(h, v)$ imply $I(h', v')$.\n  Then, given $\\bigstep{(h, v, \\{I\\} \\while{b}{c})}{(h', v')}$, it follows that $I(h', v')$ and $\\neg \\denote{b}(h', v')$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\bigstep{(h, v, \\{I\\} \\while{b}{c})}{(h', v')}$.\n\\end{proof}\n\nThat lemma encapsulates once and for all the use of induction in reasoning about the many iterations of loops.\n\n\\begin{theorem}[Soundness of Hoare logic]\n  If $\\hoare{P}{c}{Q}$, $\\bigstep{(h, v, c)}{(h', v')}$, and $P(h, v)$, then $Q(h', v')$.\n\\end{theorem}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c}{Q}$ and inversion on the derivation of $\\bigstep{(h, v, c)}{(h', v')}$, appealing to Lemma \\ref{hoare_while} in the appropriate case.\n\\end{proof}\n\nWe leave concrete example derivations to the accompanying Coq code, as that level of fiddly detail deserves to be machine-checked.\nNote that there is a rather effective automated proof procedure lurking behind the rules introduced in this section:\nTo prove a Hoare triple, first try applying the rule associated with its top-level syntax-tree constructor (e.g., assignment or loop rule).\nIf the conclusion of that rule does unify with the goal, apply the rule and proceed recursively on its premises.\nOtherwise, apply the rule of consequence to replace the postcondition with one matching that from the matching rule; note that all rules accept arbitrarily shaped preconditions, so we don't actually need to do work to massage the precondition.\nAfter a step like this one, it is guaranteed that the ``fundamental'' rule now applies.\n\nThis process creates a pile of side conditions to be proved by other means, corresponding to the assertion implications generated by the rules for loops, assertions, and consequence.\nMany real-world tools based on Hoare logic discharge such goals using solvers for satisfiability modulo theories\\index{satisfiability modulo theories}, otherwise known as SMT solvers\\index{SMT solvers}.\nThe accompanying Coq code just uses a modest Coq automation tactic definition building on the proof steps we have been using all along.\nIt is not complete by any means, but it does surprisingly well in the examples we step through, of low to moderate complexity.\n\nBefore closing our discussion of the basics of Hoare logic, let's consider how it brings to bear some more of the general principles that we have met before.\n\\abstraction\nA command's precondition and postcondition serve as an \\emph{abstraction} of the command: it is safe to model a command with its specification, if it has been proved using a Hoare triple.\n\\modularity\nFurthermore, the Hoare rules themselves take advantage of \\emph{modularity} to analyze subcommands separately, mediating between them using only the specifications.\nThe implementation details of a subcommand don't matter for any other subcommands in the program, so long as that subcommand has been connected to a specification that preserves enough information about its behavior.\nIt is an art to choose the right specification for each piece of a program.\nDetailed specifications minimize the chance that some other part of the program winds up unprovable, despite its correctness, but more detailed specifications also tend to be harder to prove in the first place.\n\n\n\\section{Small-Step Semantics}\n\nLast section's soundness theorem only lets us draw conclusions about programs that terminate.\nWe call such guarantees \\emph{partial correctness}\\index{partial correctness}.\nOther forms of Hoare triples guarantee \\emph{total correctness}\\index{total correctness}, which includes termination.\nHowever, sometimes programs aren't meant to terminate, yet we still want to gain confidence about their behavior.\nTo that end, we first give a small-step semantics for the same programming language.\nThen we prove a different soundness theorem for the same Hoare-triple predicate, showing that it also implies a useful invariant for programs as transition systems.\n\nThe small-step relation is quite similar to the one from last chapter, though now our states are triples $(h, v, c)$, of heap $h$, variable valuation $v$, and command $c$.\n\n\\encoding\n$$\\infer{\\smallstep{(h, v, \\assign{x}{e})}{(h, \\mupd{v}{x}{\\denote{e}(h, v)}, \\skipe)}}{}$$\n\n$$\\infer{\\smallstep{(h, v, \\writeto{e_1}{e_2})}{(\\mupd{h}{\\denote{e_1}(h, v)}{\\denote{e_2}(h, v)}, v, \\skipe)}}{}$$\n\n$$\\infer{\\smallstep{(h, v, \\skipe; c_2)}{(h, v, c_2)}}{}\n\\quad \\infer{\\smallstep{(h, v, c_1; c_2)}{(h', v', c'_1; c_2)}}{\n  \\smallstep{(h, v, c_1)}{(h', v', c'_1)}\n}$$\n\n$$\\infer{\\smallstep{(h, v, \\ifte{b}{c_1}{c_2})}{(h, v, c_1)}}{\n  \\denote{b}(h, v)\n}\n\\quad \\infer{\\smallstep{(h, v, \\ifte{b}{c_1}{c_2})}{(h, v, c_2)}}{\n  \\neg \\denote{b}(h, v)\n}$$\n\n$$\\infer{\\smallstep{(h, v, \\{I\\} \\while{b}{c})}{(h, v, c; \\{I\\} \\while{b}{c})}}{\n  \\denote{b}(h, v)\n}\n\\quad \\infer{\\smallstep{(h, v, \\{I\\} \\while{b}{c})}{(h, v, \\skipe)}}{\n  \\neg \\denote{b}(h, v)\n}$$\n\n$$\\infer{\\smallstep{(h, v, \\assert{a})}{(h, v, \\skipe)}}{\n  a(h, v)\n}$$\n\n\n\\section{Transition-System Invariants from Hoare Triples}\n\nEven an infinite-looping program must satisfy its $\\mathsf{assert}$ commands, every time it passes one of them.\nFor that reason, it's interesting to consider how to show that a command never gets stuck on a false assertion.\nWe work up to that result with a few intermediate ones.\nFirst, we define \\emph{stuck} much the same way as in the last two chapters: a state $(h, v, c)$ is stuck if $c$ is not $\\skipe$, but there is also nowhere to step to from this state.\nAn example of a stuck state would be one beginning with an $\\mathsf{assert}$ of an assertion that does not hold on $h$ and $v$.\nIn fact, we can prove that any other state is unstuck, though we won't bother here.\n\n\\begin{lemma}[Progress]\\label{hoare_progress}\n  If $\\hoare{P}{c}{Q}$ and $P(h, v)$, then $(h, v, c)$ is unstuck.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c}{Q}$.\n\\end{proof}\n\n\\begin{lemma}\\label{hoare_skip}\n  If $\\hoare{P}{\\skipe}{Q}$, then $\\forall s. \\; P(s) \\Rightarrow Q(s)$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{\\skipe}{Q}$.\n\\end{proof}\n\n\\begin{lemma}[Preservation]\\label{hoare_preservation}\n  If $\\hoare{P}{c}{Q}$, $\\smallstep{(h, v, c)}{(h', v', c')}$, and $P(h, v)$, then $\\hoare{\\lambda s. \\; s = (h', v')}{c'}{Q}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c}{Q}$, appealing to Lemma \\ref{hoare_skip} in one case.  Note how we conclude a very specific precondition, forcing exact state equality with the one we have stepped to.\n\\end{proof}\n\n\\begin{theorem}[Invariant Safety]\n\\invariants\n  If $\\hoare{P}{c}{Q}$ and $P(h, v)$, then unstuckness is an invariant for the small-step transition system starting at $(h, v, c)$.\n\\end{theorem}\n\\begin{proof}\n  First we weaken the invariant to $I(h, v, c) = \\hoare{\\lambda s. \\; s = (h, v)}{c}{\\lambda \\_. \\; \\top}$.\n  That is, we focus in on the most specific applicable precondition, and we forget everything that the postcondition was recording for us.\n  Note that postconditions are still an essential part of Hoare triples for this proof, but we have already done our detailed analysis of them in the earlier lemmas.\n  Lemma \\ref{hoare_progress} gives the needed implication from the new invariant to the old.\n  \n  Next, we apply invariant induction, whose base case follows trivially.\n  The induction step follows by Lemma \\ref{hoare_preservation}.\n\\end{proof}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Deep Embeddings, Shallow Embeddings, and Options in Between}\n\\label{embeddings}\n\nSo far, in this book, we have followed the typographic conventions of ordinary mathematics and logic, as they would be worked out on whiteboards.\nIn parallel, we have mechanized all of the definitions and proofs in Coq.\nOften little tidbits of encoding challenge show up in mechanizing the proofs.\nAs formal languages get more complex, it becomes more and more important to choose the right encoding.\nFor instance, in the previous chapter, we repeatedly jumped through hoops to track the local variables of programs, threading variable valuations $v$ throughout everything.\nCoq already has built into it a respectable notion of variables; can we somehow reuse that mechanism, rather than roll our own new one?\nThis chapter gives a ``yes'' answer, working toward redefining last chapter's Hoare logic in a lighter-weight manner, along the way introducing some key terminology that is used to classify encoding choices.\n\nSince whiteboard math doesn't usually bother with encoding details, here we must break with our convention of using only standard notation in the book.\nInstead, we will use notation closer to literal Coq code, and, in fact, more of the technical action than usual is only found in the accompanying Coq source file.\n\n\\section{The Basics}\\label{mixed}\n\nRecall some terminology introduced in Section \\ref{metalanguage}: every formal proof is carried out in some \\emph{metalanguage}\\index{metalanguage}, which, in our case, is Coq's logic and programming language called Gallina\\index{Gallina}.\nA syntactic language that we formalize is called an \\emph{object language}\\index{object language}.\nOften it is convenient to do reasoning without any particular object language, as in this simple arithmetic function that can be defined directly in Gallina.\n\\begin{eqnarray*}\n  \\mt{foo} &=& \\lambda(x, y). \\; \\elet{u}{x + y}{\\elet{v}{u \\times y}{u + v}}\n\\end{eqnarray*}\n\nHowever, it is difficult to prove some important facts about terms encoded directly in the metalanguage.\nFor instance, we can't easily do induction over the syntax of all such terms.\nTo allow that kind of induction, we can define an object language inductively.\n\\encoding\n\\begin{eqnarray*}\n  \\mt{Const} &:& \\mathbb N \\to \\mt{exp} \\\\\n  \\mt{Var} &:& \\mathbb V \\to \\mt{exp} \\\\\n  \\mt{Plus} &:& \\mt{exp} \\to \\mt{exp} \\to \\mt{exp} \\\\\n  \\mt{Times} &:& \\mt{exp} \\to \\mt{exp} \\to \\mt{exp} \\\\\n  \\mt{Let} &:& \\mathbb V \\to \\mt{exp} \\to \\mt{exp} \\to \\mt{exp}\n\\end{eqnarray*}\n\nThat last example program, with implicit \\emph{free variables}\\index{free variables} $x$ and $y$, may now be redefined in the $\\mt{exp}$ type.\n\\newcommand{\\var}[1]{\\mt{Var} \\; \\textrm{``#1''}}\n\\begin{eqnarray*}\n  \\mt{foo'} &=& \\mt{Let} \\; (\\var{u}) \\; (\\mt{Plus} \\; (\\var{x}) \\; (\\var{y})) \\; (\\mt{Let} \\; (\\var{v}) \\\\\n  && \\hspace{.1in} (\\mt{Times} \\; (\\var{u}) \\; (\\var{y})) \\; (\\mt{Plus} \\; (\\var{u}) \\; (\\var{v})))\n\\end{eqnarray*}\n\nAs in Chapter \\ref{interpreters}, we can define a recursive interpreter, mapping $\\mt{exp}$ programs and variable valuations to numbers.\nUsing that interpreter, we can prove equivalence of $\\mt{foo}$ and $\\mt{foo'}$.\n\nWe say that $\\mt{foo}$ uses a \\emph{shallow embedding}\\index{shallow embedding}, because it is coded directly in the metalanguage, with no extra layer of syntax.\nConversely, $\\mt{foo'}$ uses a \\emph{deep embedding}\\index{deep embedding}, since it goes via the inductively defined $\\mt{exp}$ type.\n\nThese extremes are not our only options.\nIn higher-order logics like Coq's, we may also choose what might be called \\emph{mixed embeddings}\\index{mixed embedding}, which define syntax-tree types that allow some use of general functions from the metalanguage.\nHere's an example, as an alternative definition of $\\mt{exp}$.\n\\encoding\n\\begin{eqnarray*}\n  \\mt{Const} &:& \\mathbb N \\to \\mt{exp} \\\\\n  \\mt{Var} &:& \\mathbb V \\to \\mt{exp} \\\\\n  \\mt{Plus} &:& \\mt{exp} \\to \\mt{exp} \\to \\mt{exp} \\\\\n  \\mt{Times} &:& \\mt{exp} \\to \\mt{exp} \\to \\mt{exp} \\\\\n  \\mt{Let} &:& \\mt{exp} \\to (\\mathbb N \\to \\mt{exp}) \\to \\mt{exp}\n\\end{eqnarray*}\n\nThe one change is in the type of the $\\mt{Let}$ constructor, where now no variable name is given, and instead \\emph{the body of the ``let'' is represented as a Gallina function from numbers to expressions}.\nThe intent is that the body is called on the number that results from evaluating the first expression.\nThis style is called \\emph{higher-order abstract syntax}\\index{higher-order abstract syntax}.\nThough that term is often applied to a more specific instance of the technique, which is not exactly the one used here, we will not be so picky.\n\nAs an illustration of the technique in action, here's our third encoding of the simple example program.\n\\begin{eqnarray*}\n  \\mt{foo''} &=& \\mt{Let} \\; (\\mt{Plus} \\; (\\var{x}) \\; (\\var{y})) \\; (\\lambda u. \\\\\n  && \\hspace{.1in} \\mt{Let} \\; (\\mt{Times} \\; (\\mt{Const} \\; u) \\; (\\var{y})) \\; (\\lambda v. \\\\\n  && \\hspace{.2in} \\mt{Plus} \\; (\\mt{Const} \\; u) \\; (\\mt{Const} \\; v)))\n\\end{eqnarray*}\n\nWith a bit of subtlety, we can define an interpreter for this language, too.\n\\begin{eqnarray*}\n  \\denote{\\mt{Const} \\; n}v &=& n \\\\\n  \\denote{\\mt{Var} \\; x}v &=& \\msel{v}{x} \\\\\n  \\denote{\\mt{Plus} \\; e_1 \\; e_2}v &=& \\denote{e_1}v + \\denote{e_2}v \\\\\n  \\denote{\\mt{Times} \\; e_1 \\; e_2}v &=& \\denote{e_1}v \\times \\denote{e_2}v \\\\\n  \\denote{\\mt{Let} \\; e_1 \\; e_2}v &=& \\denote{e_2(\\denote{e_1}v)}v\n\\end{eqnarray*}\n\nNote how, in the $\\mt{Let}$ case, since the body $e_2$ is a function, before evaluating it, we call it on the result of evaluating $e_1$.\nThis language would actually be sufficient even if we removed the $\\mt{Var}$ constructor and the $v$ argument of the interpreter.\nCoq's normal variable binding is enough to let us model interesting programs and prove things about them by induction on syntax.\n\nIt is important here that Coq's induction principles give us useful induction hypotheses, for constructors whose recursive arguments are functions.\nThe second argument of $\\mt{Let}$ above is an example.\nWhen we do induction on expression syntax to establish $\\forall e. \\; P(e)$, the case for $\\mt{Let} \\; e_1 \\; e_2$ includes two induction hypotheses.\nThe first one is standard: $P(e_1)$.\nThe second one is more interesting: $\\forall n : \\mathbb N. \\; P(e_2(n))$.\nThat is, the theorem holds on all results of applying body $e_2$ to arguments.\n\n\n\\section{A Mixed Embedding for Hoare Logic}\n\nThis general strategy also applies to modeling imperative languages like the one from last chapter.\nWe can define a polymorphic type family $\\mt{cmd}$ of commands, indexed by the type of value that a command is meant to return.\n\\encoding\n\\begin{eqnarray*}\n  \\mt{Return} &:& \\forall \\alpha. \\; \\alpha \\to \\mt{cmd} \\; \\alpha \\\\\n  \\mt{Bind} &:& \\forall \\alpha, \\beta. \\; \\mt{cmd} \\; \\beta \\to (\\beta \\to \\mt{cmd} \\; \\alpha) \\to \\mt{cmd} \\; \\alpha \\\\\n  \\mt{Read} &:& \\mathbb N \\to \\mt{cmd} \\; \\mathbb N \\\\\n  \\mt{Write} &:& \\mathbb N \\to \\mathbb N \\to \\mt{cmd} \\; \\mt{unit}\n\\end{eqnarray*}\n\nWe use notation $x \\leftarrow c_1; c_2$ as shorthand for $\\mt{Bind} \\; c_1 \\; (\\lambda x. \\; c_2)$, making it possible to write some very natural-looking programs in this type.\nHere are two examples.\n\\begin{eqnarray*}\n  \\mt{array\\_max}(0, a) &=& \\mt{Return} \\; a \\\\\n  \\mt{array\\_max}(i+1, a) &=& v \\leftarrow \\mt{Read} \\; i; \\mt{array\\_max} \\; i \\; (\\max(v, a)) \\\\\n  \\\\\n  \\mt{increment\\_all}(0) &=& \\mt{Return} \\; () \\\\\n  \\mt{increment\\_all}(i+1) &=& v \\leftarrow \\mt{Read} \\; i; \\_ \\leftarrow \\mt{Write} \\; i \\; (v+1); \\mt{increment\\_all} \\; i\n\\end{eqnarray*}\n\nFunction $\\mt{array\\_max}$ computes the highest value found in the first $i$ slots of memory, using an accumulator $a$.\nFunction $\\mt{increment\\_all}$ adds 1 to every one of the first $i$ memory slots.\n\nNote that we are not writing programs directly as syntax trees, but rather working with recursive functions that \\emph{compute syntax trees}.\nWe are able to do so despite the fact that we built no support for recursion into the $\\mt{cmd}$ type family.\nLikewise, we didn't need to build in any support for $\\max$, addition, or any of the other operations that are easy to code up in Gallina.\n\nIt is straightforward to implement an interpreter for this object language, where each command's interpretation maps input heaps to pairs of output heaps and results.\nNote that we have no need for an explicit variable valuation.\n\\begin{eqnarray*}\n  \\denote{\\mt{Return} \\; v}h &=& (h, v) \\\\\n  \\denote{\\mt{Bind} \\; c_1 \\; c_2}h &=& \\elet{(h', v)}{\\denote{c_1}h}{\\denote{c_2(v)}h'} \\\\\n  \\denote{\\mt{Read} \\; a}h &=& (h, \\msel{h}{a}) \\\\\n  \\denote{\\mt{Write} \\; a \\; v}h &=& (\\mupd{h}{a}{v}, ())\n\\end{eqnarray*}\n\nWe can also define a syntactic Hoare-logic relation for this type, where preconditions are predicates over initial heaps, and postconditions are predicates over \\emph{result values} and final heaps.\n$$\\infer{\\hoare{P}{\\mt{Return} \\; v}{\\lambda r, h. \\; P(h) \\land r = v}}{}\n\\quad \\infer{\\hoare{P}{\\mt{Bind} \\; c_1 \\; c_2}{R}}{\n  \\hoare{P}{c_1}{Q}\n  & \\forall r. \\; \\hoare{Q(r)}{c_2(r)}{R}\n}$$\n$$\\infer{\\hoare{P}{\\mt{Read} \\; a}{\\lambda r, h. \\; P(h) \\land r = \\msel{h}{a}}}{}\n\\quad \\infer{\\hoare{P}{\\mt{Write} \\; a \\; v}{\\lambda r, h. \\; \\exists h'. \\; P(h') \\land h = \\mupd{h'}{a}{v}}}{}$$\n$$\\infer{\\hoare{P'}{c}{Q'}}{\n  \\hoare{P}{c}{Q}\n  & (\\forall h. \\; P'(h) \\Rightarrow P(h))\n  & (\\forall r, h. \\; Q(r, h) \\Rightarrow Q'(r, h))\n}$$\n\nMuch of the details are the same as last chapter, including in a rule of consequence at the end.\nThe most interesting new wrinkle is in the rule for $\\mt{Bind}$, where the premise about the body command $c_2$ starts with universal quantification over all possible results $r$ of executing $c_1$.\nThat result is passed off, via function application, both to the body $c_2$ and to $Q$, which serves as the postcondition of $c_1$ and the precondition of $c_2$.\n\nThis Hoare logic can be used to verify the two example programs from earlier in this section; see the accompanying Coq code for details.\nWe also have a standard soundness theorem.\n\\begin{theorem}\n  If $\\hoare{P}{c}{Q}$ and $P(h)$ for some heap $h$, then let $(h', r) = \\denote{c}h$.  It follows that $Q(r, h')$.\n\\end{theorem}\n\n\n\\section{Adding More Effects}\n\nWe can continue to enhance our object language with different kinds of side effects that are not supported natively by Gallina.\nFirst, we add \\emph{nontermination}, in the form of unbounded loops.\nFor a type $\\alpha$, we define $\\mathbb O(\\alpha)$ as the type of \\emph{loop-body outcomes}, either $\\mt{Done}(a)$ to indicate that the loop should terminate or $\\mt{Again}(a)$ to indicate that the loop should keep running.\nOur loops are functional, maintaining accumulators as they run, and the $a$ argument gives the latest accumulator value in each case.\nSo we add this constructor:\n\\begin{eqnarray*}\n  \\mt{Loop} &:& \\forall \\alpha. \\; \\alpha \\to (\\alpha \\to \\mt{cmd} \\; (\\mathbb O(\\alpha))) \\to \\mt{cmd} \\; \\alpha\n\\end{eqnarray*}\n\nHere's an example of looping in action, in a program that returns the address of the first occurrence of a value in memory, or loops forever if that value is not found in the whole infinite memory.\n\\begin{eqnarray*}\n  \\mt{index\\_of}(n) &=& \\mt{Loop} \\; 0 \\; (\\lambda i. \\; v \\leftarrow \\mt{Read} \\; i; \\mt{if} \\; v = n \\; \\mt{then} \\; \\mt{Return} \\; (\\mt{Done}(i)) \\; \\mt{else} \\; \\mt{Return} \\; (\\mt{Again}(i+1)))\n\\end{eqnarray*}\n\nWith the addition of nontermination, it's no longer straightforward to write an interpreter for the language.\nInstead, we implement a small-step operational semantics $\\to$; see the accompanying Coq code for details.\nWe build an extended Hoare logic, keeping all the rules from last section and adding this new one.\n\\invariants\nLike before, it is parameterized on a loop invariant, but now the loop invariant takes a loop-body outcome as parameter.\n$$\\infer{\\hoare{I(\\mt{Again}(i))}{\\mt{Loop} \\; i \\; c}{\\lambda r. \\; I(\\mt{Done}(r)))}}{\n  \\forall a. \\; \\hoare{I(\\mt{Again}(a))}{c(a)}{I}\n}$$\n\nThis new Hoare logic is usable to verify the example program from above and many more, and we can also prove a soundness theorem.\nThe operational semantics gives us the standard way of interpreting our programs as transition systems, with states $(c, h)$.\n\n\\invariants\n\\begin{theorem}\n  If $\\hoare{P}{c}{Q}$ and $P(h)$ for some heap $h$, then it is an invariant of $(c, h)$ that, if the command ever becomes $\\mt{Return} \\; r$ in a heap $h'$, then $Q(r, h')$.  That is, if the program terminates, the postcondition is satisfied.\n\\end{theorem}\n\nWe can add a further side effect to the language: \\emph{exceptions}\\index{exceptions}.\nActually, we stick to a simple variant of this classic side effect, where there is just one exception, and it cannot be caught.\nWe associate this exception with \\emph{program failure}, and the Hoare logic will ensure that programs never actually fail.\n\nThe extension to program syntax is easy:\n\\begin{eqnarray*}\n  \\mt{Fail} &:& \\forall \\alpha. \\; \\mt{cmd} \\; \\alpha\n\\end{eqnarray*}\nThat is, a failing program can be considered to return any result type, since it will never actually return normally, instead throwing an uncatchable exception.\n\nThe operational semantics is also easily extended to signal failures, with a new special system state called $\\mt{Failed}$.\nWe also add this Hoare-logic rule.\n$$\\infer{\\hoare{\\lambda \\_. \\; \\bot}{\\mt{Fail}}{\\lambda \\_, \\_. \\; \\bot}}{}$$\nThat is, failure can only be verified against an unsatisfiable precondition, so that we know that the failure is unreachable.\n\nWith this extension, we can prove a soundness-theorem variant, capturing the impossibility of failure.\n\n\\invariants\n\\begin{theorem}\n  If $\\hoare{P}{c}{Q}$ and $P(h)$ for some heap $h$, then it is an invariant of $(c, h)$ that the state never becomes $\\mt{Failed}$.\n\\end{theorem}\n\nNote that this version of the theorem still tells us interesting things about programs that run forever.\nIt is easy to implement runtime assertion checking with code that performs some test and runs $\\mt{Fail}$ if the test does not pass.\nAn infinite-looping program may perform such tests infinitely often, and we learn that none of the tests ever fail.\n\nThe accompanying Coq code demonstrates another advantage of this mixed-embedding style: we can extract\\index{extraction} our programs to OCaml\\index{OCaml} and run them efficiently.\nThat is, rather than using functional programming to implement our three kinds of side effects, we implement them directly with OCaml's mutable heap, unbounded recursion, and exceptions, respectively.\nAs a result, our extracted programs achieve the asymptotic performance that we would expect, thinking of them as C-like code, where interpreters in a pure functional language like Gallina would necessarily add at least an extra logarithmic factor in the modeling of unboundedly growing heaps.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Separation Logic}\\label{seplog}\n\nIn our Hoare-logic examples so far, we have intentionally tread lightly when it comes to the potential aliasing\\index{aliasing} of pointer variables in a program.\nGenerally, we have only worked with, for instance, a single array at a time.\nReasoning about multi-array programs usually depends on the fact that the arrays don't overlap in memory at all.\nThings are even more complicated with linked data structures, like linked lists and trees, which we haven't even attempted up to now.\nHowever, by using \\emph{separation logic}\\index{separation logic}, a popular variant of Hoare logic, we will find it quite pleasant to prove programs that used linked structures, with no need for explicit reasoning about aliasing, assuming that we keep all of our data structures disjoint from each other through simple coding patterns.\n\n\n\\section{An Object Language with Dynamic Memory Allocation}\n\nBefore we get into proofs, let's fix a mixed-embedding object language.\n$$\\begin{array}{rrcl}\n  \\textrm{Commands} & c &::=& \\mt{Return} \\; v \\mid x \\leftarrow c; c \\mid \\mt{Loop} \\; i \\; f \\mid \\mt{Fail} \\\\\n  &&& \\mid \\mt{Read} \\; n \\mid \\mt{Write} \\; n \\; n \\mid \\mt{Alloc} \\; n \\mid \\mt{Free} \\; n \\; n\n\\end{array}$$\n\nA small-step operational semantics explains what these commands mean.\n\n$$\\infer{\\smallstep{(h, x \\leftarrow c_1; c_2(x))}{(h', x \\leftarrow c'_1; c_2(x))}}{\n  \\smallstep{(h, c_1)}{(h', c'_1)}\n}\n\\quad \\infer{\\smallstep{(h, x \\leftarrow \\mt{Return} \\; v; c(x))}{(h, c(v))}}{}$$\n\n$$\\infer{\\smallstep{(h, \\mt{Loop} \\; i \\; f)}{(h, x \\leftarrow f(\\mt{Again}(i)); \\mt{match} \\; x \\; \\mt{with} \\; \\mt{Done}(a) \\Rightarrow \\mt{Return} \\; a \\mid \\mt{Again}(a) \\Rightarrow \\mt{Loop} \\; a \\; f)}}{}$$\n\n$$\\infer{\\smallstep{(h, \\mt{Read} \\; a)}{(h, v)}}{\n  \\msel{h}{a} = v\n}\n\\quad \\infer{\\smallstep{(h, \\mt{Write} \\; a \\; v')}{(\\mupd{h}{a}{v'}, ())}}{\n  \\msel{h}{a} = v\n}$$\n\n$$\\infer{\\smallstep{(h, \\mt{Alloc} \\; n)}{(\\mupd{h}{a}{0^n}, a)}}{\n  \\dom{h} \\cap [a, a+n) = \\emptyset\n}\n\\quad \\infer{\\smallstep{(h, \\mt{Free} \\; a \\; n)}{(h - [a, a+n), ())}}{\n}$$\n\nA few remarks about the last four rules:\nThe basic $\\mt{Read}$ and $\\mt{Write}$ operations now get \\emph{stuck} when accessing unmapped addresses.\nThe premise of the rule for $\\mt{Alloc}$ enforces that address $a$ denotes a currently unmapped memory region of size $n$.\nWe use a variety of convenient notations that we won't define in detail here, referring instead to the accompanying Coq code.\nAnother notation uses $0^n$ to refer informally to a sequence of $n$ zeroes to write into memory.\nSimilarly, the conclusion of the $\\mt{Free}$ rule unmaps a whole size-$n$ region, starting at $a$.\nWe could also have chosen to enforce in this rule that the region starts out as mapped into $h$.\n\n\\section{Assertion Logic}\n\nSeparation logic is based on two big ideas.\nThe first one has to do with the \\emph{assertion logic}\\index{assertion logic}, which we use to write invariants; while the second one has to do with the \\emph{program logic}\\index{program logic}, which we use to prove that programs satisfy specifications.\nThe assertion logic is based on predicates over \\emph{partial memories}\\index{partial memories}, or finite maps from addresses to stored values.\nBecause they are finite, they omit infinitely many addresses, and it is crucial that we are able to describe heaps that intentionally leave addresses out of their domains.\nInformally, a predicate \\emph{claims ownership}\\index{ownership} of addresses in the domains of matching heaps.\n\n\\newcommand{\\emp}[0]{\\mt{emp}}\n\\newcommand{\\lift}[1]{[#1]}\n\\newcommand{\\ptsto}[2]{#1 \\mapsto #2}\n\nWe can describe the connectives of separation logic in terms of the sets of partial heaps that they accept.\n\\begin{eqnarray*}\n  \\emp &=& \\{\\mempty\\} \\\\\n  \\ptsto{p}{v} &=& \\{\\mupd{\\mempty}{p}{v}\\} \\\\\n  \\lift{\\phi} &=& \\{h \\mid \\phi \\land h = \\mempty\\} \\\\\n  \\exists x. \\; P(x) &=& \\{h \\mid \\exists x. \\; h \\in P(x)\\} \\\\\n  P * Q &=& \\{h_1 \\uplus h_2 \\mid h_1 \\in P \\land h_2 \\in Q\\}\n\\end{eqnarray*}\n\nThe formula $\\emp$ accepts only the empty heap, while formula $\\ptsto{p}{v}$ accepts only the heap whose only address is $p$, mapped to value $v$.\nWe overload the $\\mapsto$ operator in that second line above, to denote ``points-to'' on the lefthand side of the equality and finite-map overriding on the righthand side.\nNotation $\\lift{\\phi}$ is \\emph{lifting}\\index{lifting pure propositions} a \\emph{pure} (i.e., regular old mathematical) proposition $\\phi$ into an assertion, enforcing both that the heap is empty and that $\\phi$ is true.\nWe also adapt the normal existential quantifier to this setting.\n\nThe essential definition is the last one, of the \\emph{separating conjunction}\\index{separating conjunction} $*$.\nWe use the notation $h_1 \\uplus h_2$ for \\emph{disjoint union} of heaps $h_1$ and $h_2$, implicitly enforcing $\\dom{h_1} \\cap \\dom{h_2} = \\emptyset$.\nThe intuition of separating conjunction is that we \\emph{partition} the overall heap into two subheaps, each of which matches one of the respective conjuncts $P$ and $Q$.\nThis connective implicitly enforces \\emph{lack of aliasing}, leading to separation logic's famous conciseness of specifications that combine data structures.\n\nWe can also define natural comparison operators between assertions, overloading the usual notations for equivalence and implication of propositions.\n\\begin{eqnarray*}\n  P \\Leftrightarrow Q &=& \\forall h. \\; h \\in P \\Leftrightarrow h \\in Q \\\\\n  P \\Rightarrow Q &=& \\forall h. \\; h \\in P \\Rightarrow h \\in Q\n\\end{eqnarray*}\n\nThe core connectives satisfy a number of handy algebraic laws.\nHere is a sampling.\n\n$$\\infer{P * \\lift{\\phi} \\Rightarrow Q}{\n  \\phi \\rightarrow (P \\Rightarrow Q)\n}\n\\quad \\infer{P \\Rightarrow Q * \\lift{\\phi}}{\n  \\phi\n  & P \\Rightarrow Q\n}\n\\quad \\infer{P \\Leftrightarrow \\lift{\\phi} * P}{\n  \\phi\n}$$\n\n$$\\infer{P * Q \\Leftrightarrow Q * P}{}\n\\quad \\infer{P * (Q * R) \\Leftrightarrow (P * Q) * R}{}\n\\quad \\infer{P_1 * Q_1 \\Rightarrow P_2 * Q_2}{\n  P_1 \\Rightarrow P_2\n  & Q_1 \\Rightarrow Q_2\n}$$\n\n$$\\infer{(P * \\exists x. \\; Q(x)) \\Leftrightarrow \\exists x. \\; P * Q(x)}{}\n\\quad \\infer{(\\exists x. \\; P(x)) \\Rightarrow Q}{\n  \\forall x. \\; P(x) \\Rightarrow Q\n}\n\\quad \\infer{P \\Rightarrow \\exists x. \\; Q(x)}{\n  P \\Rightarrow Q(v)\n}$$\n\nThis set of algebraic laws has a very special consequence: it supports automated proof of implications by \\emph{cancellation}\\index{cancellation}, where we repeatedly ``cross out'' matching subformulas on the two sides of the arrow.\nConsider this example formula that we might want to prove.\n$$(\\exists q. \\; \\ptsto{p}{q} * \\exists r. \\; \\ptsto{q}{r} * \\ptsto{r}{0}) \\Rightarrow (\\exists a. \\; \\exists b. \\; \\exists c. \\; \\ptsto{b}{c} * \\ptsto{p}{a} * \\ptsto{a}{b})$$\n\nFirst, the laws above allow us to bubble all quantifiers to the fronts of formulas.\n$$(\\exists q, r. \\; \\ptsto{p}{q} * \\ptsto{q}{r} * \\ptsto{r}{0}) \\Rightarrow (\\exists a, b, c. \\; \\ptsto{b}{c} * \\ptsto{p}{a} * \\ptsto{a}{b})$$\n\nNext, all $\\exists$ to the left can be replaced with fresh free variables, while all $\\exists$ to the right can be replaced with fresh \\emph{unification variables}\\index{unification variables}, whose values, in terms of the free-variable values, we can deduce in the course of the proof.\n$$\\ptsto{p}{q} * \\ptsto{q}{r} * \\ptsto{r}{0} \\Rightarrow \\; \\ptsto{?b}{?c} \\; * \\; \\ptsto{p}{?a} \\; * \\; \\ptsto{?a}{?b}$$\n\nNext, we find matching subformulas to \\emph{cancel}.\nWe start by matching $\\ptsto{p}{q}$ with $\\ptsto{p}{?a}$, learning that $?a = q$ and reducing to the following formula.\nThis crucial step relies on the three key properties of $*$, given in the second row of rules above: commutativity, associativity, and cancellativity\\index{cancellativity}.\n$$\\ptsto{q}{r} * \\ptsto{r}{0} \\Rightarrow \\; \\ptsto{?b}{?c} \\; * \\; \\ptsto{q}{?b}$$\n\nWe run another cancellation step of $\\ptsto{q}{r}$ against $\\ptsto{q}{?b}$, learning $?b = r$.\n$$\\ptsto{r}{0} \\Rightarrow \\; \\ptsto{r}{?c}$$\n\nNow we can finish the proof by reflexivity of $\\Rightarrow$, learning $?c = 0$.\n\n\\section{Program Logic}\n\nWe use our automatic cancellation procedure to discharge some of the premises from the rules of the program logic, which we present now.\nFirst, here are the rules that are (almost) exactly the same as from last chapter.\n\n$$\\infer{\\hoare{P}{\\mt{Return} \\; v}{\\lambda r. \\; P * \\lift{r = v}}}{}\n\\quad \\infer{\\hoare{P}{x \\leftarrow c_1; c_2(x)}{R}}{\n  \\hoare{P}{c_1}{Q}\n  & (\\forall r. \\; \\hoare{Q(r)}{c_2(r)}{R})\n}$$\n\n$$\\infer{\\hoare{I(\\mt{Again}(i))}{\\mt{Loop} \\; i \\; f}{\\lambda r. \\; I(\\mt{Done}(r))}}{\n  \\forall a. \\; \\hoare{I(\\mt{Again}(a))}{f(a)}{I}\n}\n\\quad \\infer{\\hoare{\\lift{\\bot}}{\\mt{Fail}}{\\lambda \\_. \\; \\lift{\\bot}}}{}$$\n\n$$\\infer{\\hoare{P'}{c}{Q'}}{\n  \\hoare{P}{c}{Q}\n  & P' \\Rightarrow P\n  & \\forall r. \\; Q(r) \\Rightarrow Q'(r)\n}$$\n\nMore interesting are the rules for primitive memory operations.\nFirst, we have the rule for $\\mt{Read}$.\n\n$$\\infer{\\hoare{\\exists v. \\; \\ptsto{a}{v} * R(v)}{\\mt{Read} \\; a}{\\lambda r. \\; \\ptsto{a}{r} * R(r)}}{}$$\n\nIn words: before reading from address $a$, it must be the case that $a$ points to some value $v$, and predicate $R(v)$ records what else we know about the memory at that point.\nAfterward, we know that $a$ points to the result $r$ of the read operation, and $R$ is still present.\nWe call $R$ a \\emph{frame predicate}\\index{frame predicate}, recording what we know about parts of memory that the command does not touch directly.\nWe might also say that the \\emph{footprint} of this command is the singleton set $\\{a\\}$.\nIn general, frame predicates record preserved facts about addresses outside a command's footprint.\nThe next few rules don't have frame predicates baked in; we finish with a rule that adds them back, in a generic way for arbitrary Hoare triples.\n\n$$\\infer{\\hoare{\\exists v. \\; \\ptsto{a}{v}}{\\mt{Write} \\; a \\; v'}{\\lambda \\_. \\; \\ptsto{a}{v'}}}{}$$\n\nThis last rule, for $\\mt{Write}$, is even simpler.\nWe see a straightforward illustration of overwriting $a$'s old value $v$ with the new value $v$'.\n\n$$\\infer{\\hoare{\\emp}{\\mt{Alloc} \\; n}{\\lambda r. \\; \\ptsto{r}{0^n}}}{}\n\\quad \\infer{\\hoare{\\ptsto{a}{\\; ?^n}}{\\mt{Free} \\; a \\; n}{\\lambda \\_. \\; \\emp}}{}$$\n\nThe rules for allocation and deallocation deploy a few notations that we don't explain in detail here, with $0^n$ for sequences of $n$ zeroes and $?^n$ for sequences of $n$ arbitrary values.\n\nThe next rule, the \\emph{frame rule}\\index{frame rule}, gives the second key idea of separation logic, supporting the \\emph{small-footprint}\\index{small-footprint style} reasoning style.\n\n$$\\infer{\\hoare{P * R}{c}{\\lambda r. \\; Q(r) * R}}{\n  \\hoare{P}{c}{Q}\n}$$\n\nIn other words, any Hoare triple can be extended by conjoining an arbitrary predicate $R$ in both precondition and postcondition.\nEven more intuitively, when a program satisfies a spec, it also satisfies an extended spec that records the state of some other part of memory that is untouched (i.e., is outside the command's footprint).\n\nFor the pragmatics of proving particular programs, we defer to the accompanying Coq code.\n\\modularity\nHowever, for modular proofs, the frame rule has such an important role that we want to emphasize it here.\nIt is possible to define (recursively) a predicate $\\mt{llist}(\\ell, p)$, capturing the idea that the heap contains exactly an imperative linked list, rooted at pointer $p$, representing functional linked list $\\ell$.\nWe can also prove a general specification for a list-reversal function:\n$$\\forall \\ell, p. \\; \\hoare{\\mt{llist}(\\ell, p)}{\\texttt{reverse}(p)}{\\lambda r. \\; \\mt{llist}(\\mt{rev}(\\ell), r)}$$\n\nNow consider that we have the roots $p_1$ and $p_2$ of two disjoint lists, respectively representing $\\ell_1$ and $\\ell_2$.\nIt is easy to instantiate the general theorem and get $\\hoare{\\mt{llist}(\\ell_1, p_1)}{\\texttt{reverse}(p_1)}{\\lambda r. \\; \\mt{llist}(\\mt{rev}(\\ell_1), r)}$ and $\\hoare{\\mt{llist}(\\ell_2, p_2)}{\\texttt{reverse}(p_2)}{\\lambda r. \\; \\mt{llist}(\\mt{rev}(\\ell_2), r)}$.\nApplying the frame rule to the former theorem, with $R = \\mt{llist}(\\ell_2, p_2)$, we get:\n$$\\hoare{\\mt{llist}(\\ell_1, p_1) * \\mt{llist}(\\ell_2, p_2)}{\\texttt{reverse}(p_1)}{\\lambda r. \\; \\mt{llist}(\\mt{rev}(\\ell_1), r) * \\mt{llist}(\\ell_2, p_2)}$$\nSimilarly, applying the frame rule to the latter, with $R = \\mt{llist}(\\mt{rev}(\\ell_1), r)$, we get:\n$$\\hoare{\\mt{llist}(\\ell_2, p_2) * \\mt{llist}(\\mt{rev}(\\ell_1), r)}{\\texttt{reverse}(p_2)}{\\lambda r'. \\; \\mt{llist}(\\mt{rev}(\\ell_2), r') * \\mt{llist}(\\mt{rev}(\\ell_1), r)}$$\nNow it is routine to derive the following spec for a larger program:\n$$\\begin{array}{l}\n  \\{\\mt{llist}(\\ell_1, p_1) * \\mt{llist}(\\ell_2, p_2)\\} \\\\\n  \\hspace{.2in} r \\leftarrow \\texttt{reverse}(p_1); r' \\leftarrow \\texttt{reverse}(p_2); \\; \\mt{Return}(r, r') \\\\\n  \\{\\lambda (r, r'). \\; \\mt{llist}(\\mt{rev}(\\ell_1), r) * \\mt{llist}(\\mt{rev}(\\ell_2), r')\\}\n\\end{array}$$\n\nNote that this specification would be incorrect if the two input lists could share any memory cells!\nThe separating conjunction $*$ in the precondition implicitly formalizes our expectation of nonaliasing.\nThe proof internals require only the basic rules for $\\mt{Return}$ and sequencing, in addition to the rule of consequence, whose side conditions we discharge using the cancellation approach sketched in the previous section.\n\nNote also that this highly automatable proof style works just as well when calling functions associated with several different data structures in memory.\nThe frame rule provides a way to show that any function, in any library, preserves arbitrary memory state outside its footprint.\n\n\\section{Soundness Proof}\n\nOur Hoare logic is sound with respect to the object language's operational semantics.\n\n\\invariants\n\\begin{theorem}\n  If $\\hoare{P}{c}{Q}$ and $P(\\mempty)$, then it is an invariant of the transition system starting from $(\\mempty, c)$ that either the command has become a $\\mt{Return}$ or another execution step is possible.\n\\end{theorem}\n\nAs usual, the key to the proof is to find a stronger invariant that can be proved by invariant induction.\nIn this case, we use the invariant $\\lambda (h, c). \\; \\hoare{\\{h\\}}{c}{Q}$.\nThat is, assert a Hoare triple where the precondition enforces exact heap equality with the current heap.\nThe postcondition can remain the same throughout execution.\n\nA few key lemmas are interesting enough to mention here; we leave other details to the Coq code.\n\nFirst, we need to prove that this fancier invariant implies the one from the theorem statement, and the most direct statement needs to be strengthened, to get the induction to go through.\n\n\\begin{lemma}[Progress]\n  If $\\hoare{P}{c}{Q}$ and $P(h_1)$, then either $c$ is a $\\mt{Return}$ or it is possible to take a step from $(h_1 \\uplus h_2, c)$, for any disjoint $h_2$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c}{Q}$.\n\\end{proof}\n\nNote the essential inclusion of a disjoint union with the auxiliary heap $h_2$.\nWithout this strengthening of the obvious property, we would get stuck in the case of the proof for the frame rule.\n\n\\begin{lemma}[Preservation]\n  If $\\smallstep{(h, c)}{(h', c')}$ and $\\hoare{\\{h\\}}{c}{Q}$, then $\\hoare{\\{h'\\}}{c'}{Q}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(h, c)}{(h', c')}$.\n\\end{proof}\n\nThe different cases of the proof depend on some not-entirely-obvious inversion lemmas.\nFor instance, here is the one we prove for $\\mt{Write}$.\n\n\\begin{lemma}\n  If $\\hoare{P}{\\mt{Write} \\; a \\; v'}{Q}$, then there exists $R$ such that:\n  \\begin{itemize}\n  \\item $P \\Rightarrow \\exists v. \\; \\ptsto{a}{v} * R$\n  \\item $\\ptsto{a}{v'} * R \\Rightarrow Q(())$\n  \\end{itemize}\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{\\mt{Write} \\; a \\; v'}{Q}$.\n\\end{proof}\n\nAgain, without the introduction of the $R$ variable, we would get stuck proving the case for the frame rule.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Connecting to Real-World Programming Languages}\n\nOur exercises so far have been confined to proofs of programs in idealized programming languages.\nHow can proof assistants be used to derive results about full-scale languages?\nDevelopers are already used to coordinating build processes\\index{build processes} that plumb together multiple languages and tools.\nA proof assistant like Coq can become one tool in such a build flow.\nHowever, the interesting wrinkle that arises is the chance to do more than just get tools cooperating on building executable code.\nWe can also get tools cooperating on generating proofs of parts of the system.\n\nIt is worth emphasizing that this whole subject is a very active area of research.\nThere are many competing approaches, and it is not clear which will be most practical in the long run.\nWith this chapter, we survey the interesting design dimensions and approaches to them that are known today.\nWe also go into more detail on one avant-garde approach, of verified compilation of shallowly embedded programs to deeply embedded programs in Coq.\n\n\\section{Where Does the Buck Stop?}\n\nFor any system where we really care about correctness (or its special case of security\\index{security}), it is common to delineate a \\emph{trusted code base (TCB)}\\index{trusted code base}\\index{TCB}: the parts of the system where bugs could invalidate correctness.\nBy implication, system components outside the TCB can be arbitarily buggy without endangering correctness.\n\nWhen we use Coq, the Coq proof checker itself is in the TCB.\nImplicitly, all the infrastructure below the proof checker is also trusted.\nThat includes the OCaml\\index{OCaml} compiler (since Coq is implemented in OCaml), the operating-system kernel\\index{operating systems}, the processor beneath\\index{processors}, and so on.\nInterestingly, most of Coq is \\emph{not} trusted.\nFor instance, the tactic engine outputs proof terms\\index{proof terms} in a core language, and we only need to trust the (relatively small) checker for that language.\n\nThe point is, we always draw the trust boundary somewhere, and we always reason informally starting at some layer of a system.\nOur real-world-connecting examples of prior chapters have stopped at extracting OCaml code from Coq developments.\nWe could avoid trusting extraction (and the OCaml compiler) by instead proving properties of C abstract syntax trees.\nHowever, then we are still trusting the C compiler!\nSo we could verify that compiler and even the operating system its outputs run on.\nHowever, then we are still trusting the computer processor!\nSo we could verify the processor, even down to the level of circuits\\index{circuits} with analog dynamics modeled using differential equations\\index{differential equations}.\nHowever, then we are still trusting our characterization of the laws of physics!\n\nIn summary, it is naive to suggest that some formal-methods developments ``prove the whole system'' while others do not.\n\n\\section{Modes of Connecting to Real Artifacts}\n\n\\encoding\nAny strategy in this space involves some connection between a proved component and an unproved component.\nOversimplifying a bit, we are considering what is the ``last level'' of a proof that spans multiple abstraction layer\\index{abstraction layers}.\n(The ``first level'' will be the top-level specification of an application or whatever other piece has a proof that is not used as a lemma for some other proof.)\n\n\\subsection{Modes Based on Extraction}\n\nThe easiest ``last level'' connection is via \\emph{extraction}\\index{extraction}, which translates Gallina programs into functional programs in languages like OCaml\\index{OCaml}, Haskell\\index{Haskell}, and Scheme\\index{Scheme}.\nOther proof assistants than Coq tend to include similar extraction facilities.\nWhen the formal object of study is already a purely functional program, extraction is a very natural fit.\nIts main downside are TCB size and performance.\nOn the TCB front, a variety of compilers, including the one for extraction itself, remain trusted.\nOn the performance front, it is often possible to make a functional program run much faster or use much less memory by translating it to, say, a C program that doesn't rely on garbage collection.\n\nExtraction can be part of other, less-obvious connections, where we bring certain kinds of \\emph{side effects}\\index{side effects} and real-world interactions into scope.\nFor instance, a common class of applications is \\emph{reactive systems}\\index{reactive systems}.\nThe system is viewed as an object, in the sense of object-oriented programming\\index{object-oriented programming}, with encapsulated private state and public methods that are allowed to read and modify that state.\nSome methods are designated as \\emph{event handlers}\\index{event handlers}: they are called when various input events take place in the real world, like when a packet is received from a network.\nAn event handler in turn signals output actions to take in response.\nThis model is actually quite easy to implement using extraction: a reactive system is a choice of private state type plus a set of pure functions, each taking in the state and returning the new modified state.\nThe pure functions are the methods of the object.\nExpressive power in this style is very high, though the TCB-size and performance objections remain.\n\nIn Chapter \\ref{embeddings}, we already saw another approach to adding side effects\\index{side effects} atop extracted code: extract syntax trees, perhaps in a mixed embedding\\index{mixed embedding}, run with an interpreter\\index{interpreter} coded directly in the target language of extraction.\nThat interpreter is free to use whatever side effects the host language supports.\nIf anything, the TCB-size and performance objections increase with this approach, given the additional level of indirection that comes from using syntax trees and interpretation.\nHowever, the flexibility can be very appealing, with a straightforward means of allowing most any side effect.\n\n\\subsection{Modes Based on Explicit Rendering}\n\nAnother ``last level'' strategy is to do explicit translation between abstract syntax trees and concrete, textual code formats.\nThese translations usually have nothing proved about them, meaning they belong to TCBs, but often the translators are simple enough that it is relatively unworrying to trust them.\n\nIn one direction, we implement a tool that takes in, say, the textual syntax of C code, outputting Coq source code for corresponding explicit syntax trees.\nNow we can reason about these trees like any other mathematical objects coded manually in Coq.\nA downside of this approach is that it is relatively complex to parse mainstream programming languages, yet we are trusting just such a parser.\nHowever, this style often supports the smoothest integration with legacy code bases.\n\nIn the other direction, we write a Coq function from syntax trees to strings of concrete code in some widely used language.\nThis function is still trusted, but it tends to be much shorter and worthy of trust than its inverse.\nCoq can be run as part of a build process, printing to the screen the string that has been computed from a syntax tree.\nA scripting language can be used to extract the string from Coq's output, write it to a file, and call a conventional compiler.\nA major challenge of this approach is that only deeply embedded languages have straightforward printing to concrete syntax, in practice, while shallowly embedded languages tend to be easier to do proofs about.\n\n\n\\section{The Importance of Modularity}\n\n\\modularity\nOur discussion so far leaves out an important dimension.\nOften significant projects are divided into libraries\\index{libraries}, and we want to be able to prove libraries independently of each other.\nWe have a few choices for facing this reality of large-scale development.\n\nThe easiest approach is to use Coq pipelines to generate single libraries, which are linked outside of Coq.\nOur libraries may even be linked\\index{linking} with modules written in other languages or that would otherwise resist whatever proof methods we used.\nThese connections across languages may enlarge the TCB significantly, but we can boost performance by linking with crucial but unverified code.\n\nWe may also want to give modules first-class status in Coq and prove the correctness of linking mechanisms.\nIn concert with verified compilers\\index{compiler verification}, possibilities open up to do linking across languages without expanding the TCB.\nAll languages can be compiled to some common format, like assembly language, and the compiled version of each libary can be given a specification in a common logical format, like a particular Hoare logic.\nWith all the pieces in place, we wind up with the semantics of the common language in the TCB, but the compilers and all aspects of their source languages stay outside the TCB.\n\n\n\\section{Case Study: From a Mixed Embedding to a Deep Embedding}\n\nThis chapter's associated Coq code works out a case study of verified compilation from a mixed embedding to a deep embedding, realizing one of the ``last level'' options above that keeps the best of both worlds: straightforward program proof with a mixed embedding, but the smaller TCB and improved performance that comes from outputting concrete C\\index{C programming language} syntax from Coq.\n\n\\subsection{Source and Target Languages}\n\nOur mixed-embedding source language will be a simplification of last chapter's language.\n$$\\begin{array}{rrcl}\n  \\textrm{Commands} & c &::=& \\mt{Return} \\; v \\mid x \\leftarrow c; c \\mid \\mt{Loop} \\; i \\; f \\mid \\mt{Read} \\; n \\mid \\mt{Write} \\; n \\; n\n\\end{array}$$\n\nOur deep-embedding target language will expose essentially the same features but more in the traditional style of C and related languages.\n$$\\begin{array}{rrcl}\n  \\textrm{Expressions} & e &::=& x \\mid n \\mid e + e \\mid \\readfrom{e} \\\\\n  \\textrm{Statements} &s &::=& \\skipe \\mid \\assign{x}{e} \\mid \\writeto{e}{e} \\mid s; s \\mid \\ifte{e}{s}{s} \\mid \\while{e}{s}\n\\end{array}$$\n\nWe assume standard small-step semantics for both languages, referring to the Coq code for details.\nA state of the source language takes the form $(h, c)$ for a heap $h$, while a state of the target language adds a variable valuation $v$, for triples $(h, v, c)$.\n\n\\subsection{Formal Compilation}\n\nIt is not at all obvious how to translate from a mixed embedding\\index{mixed embedding} to a deep embedding\\index{deep embedding}.\nWe can't just write a compiler as a Gallina function, because the $\\mt{Bind}$ construct is encoded using functions of the metalanguage.\nAs a result, there is no way to ``recurse under a binder''!\n\n\\newcommand{\\dscomp}[3]{#1 \\vdash #2 \\hookrightarrow #3}\n\nHowever, inductive predicate definitions\\index{inductive predicates} give us all the power we need, when we mix in the power of logical quantifiers\\index{quantifiers}.\nWe will define a judgment $\\dscomp{v}{c}{s}$, indicating that mixed-embedded command $c$ can be compiled to statement $s$, assuming that we start running $s$ when the valuation includes every mapping from $v$.\n\nA good warmup is defining a related judgment $\\dscomp{v}{n}{e}$, compiling normal Gallina numeric expressions $n$ into syntactic expressions $e$.\n\n$$\\infer{\\dscomp{v}{x}{n}}{\n  v(x) = n\n}\n\\quad \\infer{\\dscomp{v}{n_1 + n_2}{e_1 + e_2}}{\n  \\dscomp{v}{n_1}{e_1}\n  & \\dscomp{v}{n_2}{e_2}\n}$$\n\nSo far, the logic is straightforward.\nWhen we want to mention a number, it suffices to find a variable that has already been assigned that number.\nTranslation recurses through addition in a natural way.\n(Note that, in the addition rule, the ``+'' on the left of the arrow is normal Gallina addition, while the ``+'' on the right is syntactic ``plus'' of the deeply embedded language!)\n\nAnother rule may appear at first to be overly powerful.\n$$\\infer{\\dscomp{v}{n}{n}}{}$$\n\nThat is, any numeric expression may be injected into the deep embedding \\emph{as a constant}.\nHow can we hope to embed all Gallina expressions in C?\nThe details of the command-compilation rules reveal why we are safe, so let us turn to those rules.\n\nThe rules we show here are simplified from the full set in the Coq development, supporting an even smaller subset of the source language, to make the presentation easier to understand.\nThe rule for lone $\\mt{Return}$ commands is simple, delegating most of the work to expression compilation, using a designated variable \\texttt{result} to hold the final answer of a command.\n\n$$\\infer{\\dscomp{v}{\\mt{Return} \\; n}{\\assign{\\texttt{result}}{e}}}{\n  \\dscomp{v}{n}{e}\n}$$\n\nThe most interesting rules cover uses of $\\mt{Bind}$ on various primitive operations directly.\nHere is the simplest such rule, where the primitive is simple $\\mt{Return}$.\n\n$$\\infer{\\dscomp{v}{x \\leftarrow \\mt{Return} \\; n; c(x)}{\\assign{y}{e}; s}}{\n    y \\notin \\dom{v}\n    & \\dscomp{v}{n}{e}\n    & (\\forall w. \\; \\dscomp{\\mupd{v}{y}{w}}{c(w)}{s})\n}$$\n\nThis rule selects a deep-embedding variable name $y$ to correspond to $x$ in the source program.\n(Actually, the source-program $\\mt{Bind}$ is encoded as a call to a higher-order function, so no choice of a particular $x$ is present.)\nThe name $y$ must not already be present in the valuation $v$ -- it must not have been chosen already for a command executed earlier.\nNext, we find an expression $e$ that represents the value $n$ being bound.\nFinally, we reach the trickiest part.\nThe statement $s$ needs to represent the $\\mt{Bind}$ body $c$, \\emph{for any value $w$ that $n$ might evaluate to}.\nFor every such choice $w$, we extend $v$ to record that $w$ was assigned to $y$.\nIn parallel, we pass $w$ into the body $c$.\nAs a result, the expression-translation rule for variables can pick up on this connection and compile mentions of $w$ into uses of $y$!\n\nHere is where we see why it wasn't problematic earlier to include a rule that translates any number $n$ into a constant in the deep embedding.\nMost numeric expressions in a source program will depend on results of earlier $\\mt{Bind}$ operations.\nHowever, \\emph{the quantified premise of the last rule enforces that the output statement $s$ is not allowed to depend on $w$ directly}!\nThe values of introduced variables can only be accessed through deeply embedded variable names.\nIn other words, if we tried to use the constant rule directly to prove the quantified premise of that last rule, when the body involves a $\\mt{Return}$ of a complex expression that mentions the bound variable, we would generate $s$ that includes $w$, which is not allowed.\n\nSimilar rules are present for $\\mt{Read}$ and $\\mt{Write}$, which interestingly are compiled the same way as $\\mt{Return}$.\nFrom a syntactic, compilation standpoint, they do not behave differently from pure computation.\nMore involved and raising new complications is the rule for loops; see the Coq code for details.\n\n\\subsection{Soundness Proof}\n\n\\begin{theorem}\\label{dscompsim}\n  If $\\dscomp{v}{c}{s}$, then the source-language transition system starting at $(h, c)$ simulates\\index{simulation} the target-language transition system starting at $(h, v, s)$.\n\\end{theorem}\n\\begin{proof}\n  In other words, every execution of the target-language system can be mimicked by one of the source-language system, where the states are connected throughout by some relation that we choose.\n  A good choice is the relation $\\sim$ defined by this inference rule.\n\n  $$\\infer{(h, v \\uplus v', s) \\sim (h, c)}{\n    \\dscomp{v}{c}{s}\n  }$$\n\n  Note that the only departure from the theorem statement itself is the allowance for compiled program $s$ to run in a \\emph{larger} valuation than we compiled it against.\n  It is safe to provide extra variables $v'$ (merged into $v$ with disjoint union), so long as the program never reads them, which our translation judgment enforces.\n  We need to allow for extra variables because loop bodies run multiple times, with later iterations technically being exposed to temporary-variable values set by earlier iterations.\n\n  Actually, we need to modify our translation judgment so that it also applies to ``silly'' intermediate states of execution in the target language.\n  For instance, we wind up with $\\skipe$s that are quickly stepped away, yet those configurations must be related to source configurations by $\\sim$.\n  Here is one example of the extra rules that we need to add to make our induction hypothsis strong enough.\n\n  $$\\infer{\\dscomp{v}{x \\leftarrow \\mt{Return} \\; n; c(x)}{\\mt{skip}; s}}{\n    v(y) = n\n    & \\dscomp{v}{c(n)}{s}\n  }$$\n\n  The premises encode our expectation that an assignment of $n$ to $y$ ``just ran.''\n\\end{proof}\n\nThis result can be composed with soundness of any Hoare logic for the source language.\nThe associated Coq code defines one, essentially following our separation logic\\index{separation logic} from last chapter.\n\n\\begin{theorem}\n  If $\\hoare{P}{c}{Q}$, $P(h)$, $\\dscomp{v}{c}{s}$, and $\\texttt{result} \\notin \\dom{v}$, then it is invariant of the transition system starting in $(h, v, s)$ that execution never gets stuck.\n\\end{theorem}\n\\begin{proof}\n  First, we switch to proving an invariant of the system $(h, c)$ using the simulation from Theorem \\ref{dscompsim}.\n  Next, we use the soundness theorem of the Hoare logic to weaken the invariant proved in that way into the one we want in the end.\n\\end{proof}\n\nAt this point, we can verify the high-level program conveniently while arriving at a low-level program automatically.\nThat low-level program is easy to print as a string of concrete C code, as the associated Coq code demonstrates.\nWe only trust the simple printing process, not the compiler that got us from a mixed embedding to a C-like syntax tree.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Deriving Programs from Specifications}\\label{deriving}\n\nWe have generally focused so far on proving that programs meet specifications.\nWhat if we could generate programs from their specifications, in ways that guarantee correctness?\nLet's explore that direction, in the tradition of \\emph{program derivation}\\index{program derivation} via \\emph{stepwise refinement}\\index{stepwise refinement}.\n\n\\section{Sets as Computations}\n\nThe heart of stepwise refinement is to start with a specification and gradually transform it until it deserves to be called an implementation.\nIt will help to use a common program format for specifications, implementations, and intermediate states on the path from the former to the latter.\nOne convenient choice is \\emph{sets of allowable answers}.\nA specification is naturally considered as a relation $R$ between inputs and outputs, where the set-based version of the specification for inputs $x$ is $\\mt{spec}(x) = \\{y \\mid x \\; R \\; y\\}$.\nAn implementation is naturally considered as a function $f$ from an input to an output, which can be modeled with singleton sets as $\\mt{impl}(x) = \\{f(x)\\}$.\nIntermediate terms in our derivations may still be sets with multiple elements, but we aim to winnow down to single choices eventually.\n\nComputations of this kind form a \\emph{monad}\\index{monad} with respect to two particular operators.\nMonads are an abstraction of sequential computation, popular in functional programming.\nThey require definitions of ``return'' and ``bind'' operators, which we give here, writing $\\mathcal P$ for the ``powerset''\\index{powerset} operator that lifts types into sets.\n\\begin{eqnarray*}\n  \\mt{ret} &:& \\forall \\alpha. \\; \\alpha \\to \\mathcal P(\\alpha) \\\\\n  \\mt{ret} &=& \\lambda x. \\; \\{x\\} \\\\\n  \\mt{bind} &:& \\forall \\alpha, \\beta. \\; \\mathcal P(\\alpha) \\to (\\alpha \\to \\mathcal P(\\beta)) \\to \\mathcal P(\\beta) \\\\\n  \\mt{bind} &=& \\lambda c_1. \\; \\lambda c_2. \\; \\bigcup_{x \\in c_1} c_2(x)\n\\end{eqnarray*}\n\nWe write $x \\leftarrow c_1; c_2(x)$ as shorthand for $\\mt{bind} \\; c_1 \\; c_2$.\n\nA valid monad must also satisfy three algebraic laws.\nWe will state just one of those laws here, with respect to the superset relation $\\supseteq$, which we read as ``refines into.''\\index{refinement}\nThat is, the lefthand operand is a more specification-like computation, which we want to replace with the righthand operand, which should be more concrete.\nIn other words, any legal answer for the new computation is also legal for the old one.\nHowever, we may decide that the new computation rules out some answers that were previously under consideration.\nIf we rule out all the possible answers, then we will be stuck, if we ever want to refine to a singleton set!\n\nWith our notion of refinement in place, we can state three key properties, the first of which is one of the monad laws.\n\n\\begin{theorem}\\label{bindret}\n  $\\mt{bind} \\; (\\mt{ret} \\; v) \\; c \\supseteq c(v)$.\n\\end{theorem}\n\n\\begin{theorem}\\label{refine1}\n  If $c_1 \\supseteq c'_1$, then $\\mt{bind} \\; c_1 \\; c_2 \\supseteq \\mt{bind} \\; c'_1 \\; c_2$.\n\\end{theorem}\n\n\\begin{theorem}\\label{refine2}\n  If $\\forall x. \\; c_2(x) \\supseteq c'_2(x)$, then $\\mt{bind} \\; c_1 \\; c_2 \\supseteq \\mt{bind} \\; c_1 \\; c'_2$.\n\\end{theorem}\n\nTogether with the well-known reflexivity and transitivity of $\\supseteq$, these laws set us up for convenient \\emph{equational reasoning}\\index{equational reasoning}.\nThat is, we start from a specification and repeatedly \\emph{rewrite}\\index{rewriting} in it using $\\supseteq$ facts, until we arrive at an acceptable implementation (singleton set whose element reads as an efficient computation).\nRewriting requires us to descend inside the structure of a term to find a match for the lefthand side of a $\\supseteq$ fact.\nWhen we descend into the first argument or second argument of a $\\mt{bind}$, we appeal to Theorem \\ref{refine1} or \\ref{refine2}, respectively.\nWe also use transitivity of $\\supseteq$ to chain together multiple rewritings.\nFinally, we use Theorem \\ref{bindret} whenever we have reduced a prefix of a computation into deterministic code.\n\nThe associated Coq code contains an example of this kind of refinement in action.\nThere are enough details that mechanized assistance is especially worthwhile.\n\n\\section{Refinement for Abstract Data Types}\n\nAbstract data types (ADTs)\\index{abstract data type} are an important program-encapsulation feature that we studied in Chapter \\ref{adt}.\nRecall that they package private state together with public methods that can manipulate it, somewhat in the style of object-oriented programming\\index{object-oriented programming}.\nLet us now study how to start from an ADT specification and refine it gradually into an efficient implementation, in a way that leaves a ``proof trail'' justifying correctness.\n\nFor simplicity, we will force all methods to take $\\mathbb N$ as input and return $\\mathbb N$ as output, in addition to the implicit threading-through of an object's private state.\nThe whole theory generalizes to methods of varying type.\n\n\\begin{definition}\n  An \\emph{abstract data type (ADT)}\\index{abstract data type} over a set $M$ of methods is a triple $\\angled{\\mathcal S, \\mathcal C, \\mathcal M_{m \\in M}}$, where $\\mathcal S$ is the set of private states, $\\mathcal C : \\mathcal P(\\mathcal S)$ is a \\emph{constructor}\\index{constructor} that initializes the state, and each $\\mathcal M_m : \\mathcal S \\times \\mathbb N \\to \\mathcal P(\\mathcal S \\times \\mathbb N)$ is a method.\n\\end{definition}\n\nNote that constructor and method bodies live in the computation monad, allowing them to be nondeterminstic and to mix program-style and specification-style code.\n\n\\begin{definition}\n  Consider two ADTs $\\mathcal T^1 = \\angled{\\mathcal S^1, \\mathcal C^1, \\mathcal M^1_{m \\in M}}$ and $\\mathcal T^2 = \\angled{\\mathcal S^2, \\mathcal C^2, \\mathcal M^2_{m \\in M}}$ over the same methods $M$.\n  We say that $\\mathcal T^2$ refines $\\mathcal T^1$ (written, with overloaded notation, as $\\mathcal T^1 \\supseteq \\mathcal T^2$) when there exists binary relation $R$ on $\\mathcal S^1$ and $\\mathcal S^2$ such that:\n  \\begin{enumerate}\n  \\item $\\forall s_2 \\in \\mathcal C^2. \\; \\exists s_1 \\in \\mathcal C^1. \\; s_1 \\; R \\; s_2$\n  \\item \\begin{tabular}{l}\n    $\\forall m, s_1, s_2. \\; s_1 \\; R \\; s_2 \\Rightarrow \\forall x, y, s'_2. \\; (s'_2, y) \\in \\mathcal M^2_m(s_2, x)$ \\\\\n    $\\hspace{.1in} \\Rightarrow \\exists s'_1. \\; (s'_1, y) \\in \\mathcal M^1_m(s_1, x) \\land s'_1 \\; R \\; s'_2$\n  \\end{tabular}\n  \\end{enumerate}\n\\end{definition}\n\nIn fact, the relation $R$ here is a \\emph{simulation}\\index{simulation}, in the sense of Chapter \\ref{compiler_correctness}!\nIntuitively, any sequence of method calls on $\\mathcal T^2$ can be \\emph{simulated} with the same sequence of method calls on $\\mathcal T^1$ yielding the same answers.\nThe private states in the two worlds needn't be precisely equal, but at each step they must remain related by $R$.\n\nA number of very handy refinement principles apply.\n\n\\begin{theorem}[Reflexivity]\\label{adtrefl}\n  $\\mathcal T \\supseteq \\mathcal T$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation to be equality.\n\\end{proof}\n\n\\begin{theorem}[Transitivity]\n  If $\\mathcal T_1 \\supseteq \\mathcal T_2$ and $\\mathcal T_2 \\supseteq \\mathcal T_3$, then $\\mathcal T_1 \\supseteq \\mathcal T_3$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation for the conclusion to be the composition of the relations for the premises.\n\\end{proof}\n\n\\begin{theorem}[Focusing on a constructor]\n  If $\\mathcal C^1 \\supseteq \\mathcal C^2$, then $\\angled{\\mathcal S, \\mathcal C^1, \\mathcal M_{m \\in M}} \\supseteq \\angled{\\mathcal S, \\mathcal C^2, \\mathcal M_{m \\in M}}$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation to be equality.\n\\end{proof}\n\n\\begin{theorem}[Focusing on a method]\\label{refinemethod}\n  Let $m$ be one of the methods for $\\mathcal T$, and let the body of that method be $c$.\n  Let $\\mathcal T'$ be the result of replacing $m$'s body in $\\mathcal T$ with a new function $c'$.\n  If $\\forall s, x. \\; c(s, x) \\supseteq c'(s, x)$, then $\\mathcal T \\supseteq \\mathcal T'$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation to be equality.\n\\end{proof}\n\nThe next simulation principle is one of the most powerful.\n\n\\begin{theorem}[Change of representation]\\label{repchange}\n  Let $\\mathcal T = \\angled{\\mathcal S, \\mathcal C, \\mathcal M_{m \\in M}}$ be an ADT, and pick $A : \\mathcal S' \\to \\mathcal S$ (for some new state set $\\mathcal S'$) as an \\emph{abstraction function}\\index{abstraction function}.\n  Now define $\\mathcal T' = \\angled{\\mathcal S', \\mathcal C', \\mathcal M'_{m \\in M}}$, where:\n  \\begin{enumerate}\n  \\item $\\mathcal C' = s \\leftarrow \\mathcal C; \\{s' \\mid A(s') = s\\}$\n  \\item $\\mathcal M'_m = \\lambda s'_0, x. \\; \\mathcal (s, y) \\leftarrow M_m(A(s'_0), x); s' \\leftarrow \\{s' \\mid A(s') = s\\}; \\mt{ret} \\; (s', y)$\n  \\end{enumerate}\n  Then $\\mathcal T \\supseteq \\mathcal T'$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation $\\{(A(s), s) \\mid s \\in \\mathcal S'\\}$.\n\\end{proof}\n\nThe intuition of representation change is that we choose $\\mathcal S'$ as some clever new data structure.\nWe are responsible for a formal characterization of how it relates to the original, more obvious data structure.\nAbstraction function $A$ shows how to ``undo our cleverness,'' computing the old version of a state.\nIt would generally be inefficient to run this conversion on every method call.\nLuckily, the new method bodies generated by this rule can be subjected to further optimization!\nFor instance, we can use Theorem \\ref{refinemethod} to rewrite method bodies further.\nWe will especially want to do so to replace subcomputations of the form $\\{s' \\mid A(s') = s\\}$, which stand for calling $A^{-1}$ on particular values.\nOf course not every function has an inverse as a total relation, let alone a total function, so there is no purely mechanical way to rewrite inverse function calls into executable code.\n\nSee the associated Coq code for some examples of these rules in action for concrete program derivations.\nIt turns out that Theorems \\ref{adtrefl} through \\ref{repchange} are \\emph{complete}: any correct refinement fact on ADTs can be proved using them alone.\n\n\\section{Another Example Refinement Principle: Adding a Cache}\n\nStill, it can be helpful to formulate additional ADT-refinement principles, capturing common optimization strategies.\nAs an example, we formalize the idea of \\emph{adding a cache to a data structure}\\index{caching}, which is also known as \\emph{finite differencing}\\index{finite differencing} in the literature.\n\n\\begin{theorem}[Adding a cache]\n  Let $\\mathcal T = \\angled{\\mathcal S, \\mathcal C, \\mathcal M_{m \\in M}}$ be an ADT, and pick a method $m$ such that $\\mathcal M_m = \\lambda s, x. \\; \\mt{ret} \\; (s, f(s))$ for some pure function $f : \\mathcal S \\to \\mathbb N$.\n  Now define $\\mathcal T' = \\angled{\\mathcal S \\times \\mathbb N, \\mathcal C', \\mathcal M'_{m \\in M}}$, where:\n  \\begin{enumerate}\n  \\item $\\mathcal C' = s \\leftarrow \\mathcal C; \\mt{ret} \\; (s, f(s))$\n  \\item $\\mathcal M'_m = \\lambda (s, c), x. \\; \\mt{ret} \\; ((s, c), c)$\n  \\item For $m' \\neq m$, $\\mathcal M'_{m'} = \\lambda (s, c), x. \\; \\mathcal (s', y) \\leftarrow M_m(s, x); c' \\leftarrow \\{c' \\mid f(s) = c \\Rightarrow f(s') = c'\\}; \\mt{ret} \\; ((s', c'), y)$\n  \\end{enumerate}\n  Then $\\mathcal T \\supseteq \\mathcal T'$.\n\\end{theorem}\n\\begin{proof}\n  Justified by choosing the simulation relation $\\{(s, (s, f(s))) \\mid s \\in \\mathcal S\\}$.\n\\end{proof}\n\nIntuitively, method $m$ is a pure \\emph{observer}, not changing the state, only returning some pure function $f$ of it.\nWe change the state set from $\\mathcal S$ to $\\mathcal S \\times \\mathbb N$, so that the second component of a state \\emph{caches} the output of $f$ on the first component.\nLike in a change of representation, method bodies are all rewritten automatically, but pick-from-set operations are inserted, and we must refine them away to arrive at a final implementation.\n\nHere the crucial such pattern is $\\{c' \\mid f(s) = c \\Rightarrow f(s') = c'\\}$.\nIntuitively, we are asked to choose a cache value $c'$ that is correct for the new state $s'$, while we are allowed to \\emph{assume} that the prior cache value $c$ was accurate for the old state $s$.\nTherefore, it is natural to give an efficient formula for computing $c'$ in terms of $c$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Introduction to Reasoning About Shared-Memory Concurrency}\\label{sharedmem}\n\nSeparation logic~\\index{separation logic} tames sharing of a mutable memory across libraries and data structures.\nWe will need some additional techniques when we add concurrency to the mix, resulting in the \\emph{shared-memory}\\index{shared-memory concurrency} style of concurrency.\nThis chapter introduces a basic style of operational semantics for shared memory, also studying its use in model checking, including with an important optimization called partial-order reduction.\nThe next chapter shows how to prove deeper properties of fancier programs, by extending the Hoare-logic approach to shared-memory concurrency.\nThen the chapter after that shows how to formalize and reason about a different style of concurrency, message passing.\n\n\\section{An Object Language with Shared-Memory Concurrency}\n\nFor the next two chapters, we work with this object language.\n$$\\begin{array}{rrcl}\n  \\textrm{Commands} & c &::=& \\mt{Fail} \\mid \\mt{Return} \\; v \\mid x \\leftarrow c; c \\mid \\mt{Read} \\; a \\mid \\mt{Write} \\; a \\; v \\mid \\mt{Lock} \\; a \\mid \\mt{Unlock} \\; a \\mid c || c\n\\end{array}$$\n\nIn addition to the basic structure of the languages from the last two chapters, we have three features specific to concurrency.\nWe follow the common ``threads and locks''\\index{locks} style of synchronization, with commands $\\mt{Lock} \\; a$ and $\\mt{Unlock} \\; a$ for acquiring and releasing locks, respectively.\nWe also have $c_1 || c_2$ for running commands $c_1$ and $c_2$ in parallel, giving a scheduler free reign to interleave their atomic steps.\n\nThe operational semantics is small-step\\index{small-step operational semantics}, especially because big-step semantics\\index{big-step operational semantics} is notoriously awkward for concurrency.\nEach state of the system is a triple $(h, l, c)$, with $h$ and $c$ the heap and current command from our usual semantics.\nNew component $l$ is a \\emph{lockset}\\index{lockset}, recording which locks are currently held, without distinguishing between different threads that might have taken them.\n\n$$\\infer{\\smallstep{(h, l, x \\leftarrow c_1; c_2(x))}{(h', l', x \\leftarrow c'_1; c_2(x))}}{\n  \\smallstep{(h, l, c_1)}{(h', l', c'_1)}\n}\n\\quad \\infer{\\smallstep{(h, l, x \\leftarrow \\mt{Return} \\; v; c_2(x))}{(h, k, c_2(v))}}{}$$\n\n$$\\infer{\\smallstep{(h, l, \\mt{Read} \\; a)}{(h, l, \\mt{Return} \\; \\msel{h}{a})}}{}\n\\quad \\infer{\\smallstep{(h, l, \\mt{Write} \\; a \\; v)}{(\\mupd{h}{a}{v}, l, \\mt{Return} \\; 0)}}{}$$\n\n$$\\infer{\\smallstep{(h, l, \\mt{Lock} \\; a)}{(h, l \\cup \\{a\\}, \\mt{Return} \\; 0)}}{\n  a \\notin l\n}\n\\quad \\infer{\\smallstep{(h, l, \\mt{Unlock} \\; a)}{(h, l \\setminus \\{a\\}, \\mt{Return} \\; 0)}}{\n  a \\in l\n}$$\n\n$$\\infer{\\smallstep{(h, l, c_1 || c_2)}{(h', l', c'_1 || c_2)}}{\n  \\smallstep{(h, l, c_1)}{(h', l', c'_1)}\n}\n\\quad \\infer{\\smallstep{(h, l, c_1 || c_2)}{(h', l', c_1 || c'_2)}}{\n  \\smallstep{(h, l, c_2)}{(h', l', c'_2)}\n}$$\n\nNote that the last two rules are the only source of \\emph{nondeterminism}\\index{nondeterminism} in this semantics, where a single state can step to multiple different next states.\nThis nondeterminism corresponds to the freedom we give to a scheduler\\index{scheduler} that may pick which thread runs next.\nThough this kind of concurrent programming is very expressive and often achieves very high performance, it comes at a cost in reasoning, as there may be \\emph{exponentially many different schedules} for a single program, measured with respect to the textual length of the program.\nA popular name for this pitfall is \\emph{the state-explosion problem}\\index{state-explosion problem}.\n\nNote also that we have omitted any looping constructs from this object language, so all programs terminate.\nThe Coq formalization uses the mixed-embedding\\index{mixed embedding} style, making it not entirely obvious that all programs really do terminate.\nIn any case, if we must tame the state-explosion problem, we already have our work cut out for us, even when the state space rooted at any concrete state is finite!\n\n\n\\section{Shrinking the State Space via Local Actions}\n\n\\newcommand{\\natf}[1]{\\mt{natf}(#1)}\n\nRecall our study of \\emph{model checking}\\index{model checking} in Chapter \\ref{model_checking}.\nWith a little cleverness, many problems in program verification can be reduced to exploration of finite state spaces of transition systems.\nIn particular, we looked at \\emph{safety properties}, which can be expressed as invariants of transition systems.\nOne simply follows all the edges in the graph determined by a transition system, accepting the program if that process terminates without finding a state that violates the invariant.\nFor our object language in this chapter, a good safety property is that commands are \\emph{not about to fail}, formalized as:\n\\begin{eqnarray*}\n  \\natf{\\mt{Fail}} &=& \\bot \\\\\n  \\natf{x \\leftarrow c_1; c_x(x)} &=& \\natf{c_1} \\\\\n  \\natf{c_1 || c_2} &=& \\natf{c_1} \\land \\natf{c_2} \\\\\n  \\natf{\\_} &=& \\top\n\\end{eqnarray*}\n\nHere is an example of a program execution that avoids failures.\n\\begin{eqnarray*}\n  (\\mupd{\\mempty}{0}{1}, \\emptyset, n \\leftarrow \\mt{Read} \\; 0; \\mt{Write} \\; 0 \\; (n+1))\n  &\\rightarrow& (\\mupd{\\mempty}{0}{1}, \\emptyset, n \\leftarrow \\mt{Return} \\; 1; \\mt{Write} \\; 0 \\; (n+1)) \\\\\n  &\\rightarrow& (\\mupd{\\mempty}{0}{1}, \\emptyset, \\mt{Write} \\; 0 \\; (1+1)) \\\\\n  &\\rightarrow& (\\mupd{\\mempty}{0}{2}, \\emptyset, \\mt{Return} \\; 0)\n\\end{eqnarray*}\n\n\\newcommand{\\rl}[1]{{\\left \\lfloor #1 \\right \\rfloor}}\n\nWhen exploring the state space of this program, a n\\\"aive model checker will generate each of these states explicitly, even the ``silly'' second one that reduces to the third without reading or writing the shared state.\nWe can short-circuit those extra states by writing a simple function that makes all appropriate purely local reductions, everywhere within a command.\n\\begin{eqnarray*}\n  \\rl{x \\leftarrow c_1; c_2(x)} &=& \\rl{c_2(v)}\\textrm{, when $\\rl{c_1} = \\mt{Return} \\; v$} \\\\\n  \\rl{x \\leftarrow c_1; c_2(x)} &=& x \\leftarrow \\rl{c_1}; \\rl{c_2(x)}\\textrm{, when $\\rl{c_1}$ is not $\\mt{Return}$} \\\\\n  \\rl{c_1 || c_2} &=& \\rl{c_1} || \\rl{c_2} \\\\\n  \\rl{c} &=& c\n\\end{eqnarray*}\n\n\\newcommand{\\smallstepL}[2]{#1 \\to_L #2}\n\nUsing this relation, we can define an alternative step relation that short-circuits local steps.\n$$\\infer{\\smallstepL{(h, l, c)}{(h', l', \\rl{c'})}}{\n  \\smallstep{(h, l, c)}{(h', l', c')}\n}$$\n\nThe base semantics can be used to define transition systems in the usual way, with $\\mathbb T(h, l, c) = \\angled{\\{(h, l, c)\\}, \\to}$.\nWe can also define short-circuiting transition systems with $\\mathbb T_L(h, l, c) = \\angled{\\{(h, l, \\rl{c})\\}, \\to_L}$.\nA theorem shows that the latter overapproximates the former.\n\n\\abstraction\n\\begin{theorem}\\label{local}\n  If $\\mt{natf}$ is an invariant of $\\mathbb T_L(h, l, c)$, then it is also an invariant of $\\mathbb T(h, l, c)$.\n\\end{theorem}\n\\begin{proof}\n  By induction on a trace $\\smallsteps{(h, l, c)}{(h', l', c')}$, matching each original step with zero or one alternative steps.\n  We appeal to a number of lemmas, some of which are summarized below.\n\\end{proof}\n\n\\begin{lemma}\\label{rl_idem}\n  For all $c$, $\\rl{\\rl{c}} = \\rl{c}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the structure of $c$.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\smallstep{(h, l, c)}{(h', l', c')}$, then either $(h', l') = (h, l)$ and $\\rl{c'} = \\rl{c}$ (the step was local), or there exists $c''$ where $\\smallstep{(h, l, \\rl{c})}{(h', l', c'')}$ and $\\rl{c''} = \\rl{c'}$ (the step was not local).\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(h, l, c)}{(h', l', c')}$, appealing in places to to Lemma \\ref{rl_idem}.\n\\end{proof}\n\n\\begin{lemma}\n  If $\\natf{\\rl{c}}$, then $\\natf{c}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the structure of $c$.\n\\end{proof}\n\n\n\\section{Basic Partial-Order Reduction}\n\nWhat made the reduction in Theorem \\ref{local} sound?\nIt was that local actions \\emph{commute}\\index{commute}\\index{commutativity} with all actions in other threads.\nA particular run of a system in the base semantics might indeed choose to run a nonlocal action before a local action that is enabled.\nHowever, we can \\emph{reorder} any such action to instead come after every enabled local action, without affecting the final state.\nThis reordering is an example of commutativity in action.\n\nBy recognizing and exploiting other varieties of commutativity, we can shrink state spaces even further, even reducing the spaces of certain interesting program families from exponential size to linear size.\nA popular technique of this kind is \\emph{partial-order reduction}\\index{partial-order reduction}.\nWe formalize a simple variant of it in this section (and in the accompanying Coq code), then sketch a less formal generalization in the chapter's final section.\n\n\\newcommand{\\summ}[2]{\\mt{summarize}(#1, #2)}\n\nTo check commutativity more flexibly, we must use more than just the fact that a local action commutes with any action in another thread.\nFor instance, we should take advantage of the fact that any two $\\mt{Read}$ actions commute.\nWe will do some \\emph{static analysis}\\index{static analysis} of programs to overapproximate which kinds of atomic actions they might perform.\nSuch an analysis is designed to be trivially computable.\nHere's an example of one analysis, formulated as a relation $\\summ{c}{(r, w, \\ell)}$, which asserts that the only globally visible actions that could be performed by thread $c$ are reads to addresses in $r$, writes to addresses in $w$, and acquires or releases of locks in $\\ell$.\n\n$$\\infer{\\summ{\\mt{Return} \\; r}{s}}{}\n\\quad \\infer{\\summ{\\mt{Fail}}{s}}{}\n\\quad \\infer{\\summ{x \\leftarrow c_1; c_2(x)}{s}}{\n    \\summ{c_1}{s}\n    & \\forall r. \\; \\summ{c_2(r)}{s}\n}$$\n\n$$\\infer{\\summ{\\mt{Read} \\; a}{(r, w, \\ell)}}{\n  a \\in r\n}\n\\quad \\infer{\\summ{\\mt{Write} \\; a \\; v}{(r, w, \\ell)}}{\n  a \\in w\n}$$\n\n$$\\infer{\\summ{\\mt{Lock} \\; a}{(r, w, \\ell)}}{\n  a \\in \\ell\n}\n\\quad \\infer{\\summ{\\mt{Unlock} \\; a}{(r, w, \\ell)}}{\n  a \\in \\ell\n}$$\n\n$$\\infer{\\summ{c_1 || c_2}{(r, w, \\ell)}}{\n  \\summ{c_1}{(r, w, \\ell)}\n  & \\summ{c_1}{(r, w, \\ell)}\n}$$\n\n\\newcommand{\\na}[1]{\\mt{nextAction}(#1)}\n\nThose relations do all we need to do to record which actions a thread might not commute with.\nThe other key ingredient is an extractor for the next atomic action in a thread, written as a partial function.\n\\begin{eqnarray*}\n  \\na{\\mt{Return} \\; r} &=& \\mt{Return} \\; r \\\\\n  \\na{\\mt{Fail}} &=& \\mt{Fail} \\\\\n  \\na{\\mt{Read} \\; a} &=& \\mt{Read} \\; a \\\\\n  \\na{\\mt{Write} \\; a \\; v} &=& \\mt{Write} \\; a \\; v \\\\\n  \\na{\\mt{Lock} \\; a} &=& \\mt{Lock} \\; a \\\\\n  \\na{\\mt{Unlock} \\; a} &=& \\mt{Unlock} \\; a \\\\\n  \\na{x \\leftarrow c_1; c_2(x)} &=& \\na{c_1}\n\\end{eqnarray*}\n\nGiven a next atomic action and a summary of another thread, it is now easy to define commutativity of the two.\n\\newcommand{\\commu}[2]{\\mt{commutes}(#1, #2)}\n\\begin{eqnarray*}\n  \\commu{\\mt{Return} \\; \\_}{\\_} &=& \\top \\\\\n  \\commu{\\mt{Fail}}{\\_} &=& \\top \\\\\n  \\commu{\\mt{Read} \\; a}{(\\_, w, \\_)} &=& a \\notin w \\\\\n  \\commu{\\mt{Write} \\; a \\; \\_}{(r, w, \\_)} &=& a \\notin r \\cup w \\\\\n  \\commu{\\mt{Lock} \\; a}{(\\_, \\_, \\ell)} &=& a \\notin \\ell \\\\\n  \\commu{\\mt{Unlock} \\; a}{(\\_, \\_, \\ell)} &=& a \\notin \\ell \\\\\n  \\commu{\\_}{\\_} &=& \\bot\n\\end{eqnarray*}\n\n\\newcommand{\\pors}[1]{\\mt{porSafe}(#1)}\n\nWith these ingredients, we can define a predicate $\\mt{porSafe}$ that figures out when a state is eligible for the partial-order reduction optimization, which is to force the first thread to run next, ignoring the other threads for now.\nIn working out the formal details, we will confine ourselves to commands $c_1 || c_2$ with distinguished ``first threads'' $c_1$, though everything can be generalized to other settings (and doing that generalization could be a worthwhile exercise for the reader, though it requires a lot of logical bookkeeping).\nThis optimization is only safe when the first thread can take a step and when that step commutes with any action that other threads (combined into $c_2$) might perform.\nFormally, we define $\\pors{h, l, c_1, c_2, s}$ as follows, where $s$ should be a valid summary of $c_2$.\n\\begin{itemize}\n\\item There is some $c_0$ where $\\na{c_1} = c_0$.  That is, thread $c_1$ has some uniquely determined atomic action lined up to run next.\n\\item There exist $h'$, $l'$, and $c'_1$ such that $\\smallstep{(h, l, c_1)}{(h', l', c'_1)}$.  That is, thread $c_1$ is actually able to take a step, which might not be possible if e.g. trying to take a lock that is already held.\n\\item And the crucial compatibility condition: $\\commu{c_0}{s}$.  That is, all actions that other threads might perform commute with $c_0$, the first action of $c_1$.\n\\end{itemize}\n\n\\newcommand{\\smallstepC}[3]{#1 \\to_C^{#2} #3}\n\nWith the applicability condition defined, it is now straightforward to define an optimized step relation, parameterized on an accurate summary $s$ for $c_2$.\n\n$$\\infer{\\smallstepC{(h, l, c_1 || c_2)}{s}{(h', l', c'_1 || c_2)}}{\n  \\smallstep{(h, l, c_1)}{(h', l', c'_1)}\n}$$\n\n$$\\infer{\\smallstepC{(h, l, c_1 || c_2)}{s}{(h', l', c_1 || c'_2)}}{\n  \\neg \\pors{h, l, c_1, c_2, s}\n  & \\smallstep{(h, l, c_2)}{(h', l', c'_2)}\n}$$\n\nThe whole thing is wrapped up into transition systems as $\\mathbb T_C(h, l, c_1, c_2, s) = \\angled{\\{(h, l, c_1 || c_2)\\}, \\to_C^s}$.\n\n\\newcommand{\\tof}[2]{\\mt{timeOf}(#1, #2)}\n\nOur proof of soundness for this reduction will depend on having some constant upper bound on program execution time.\nThis relation computes a conservative overapproximation.\n\n$$\\infer{\\tof{\\mt{Return} \\; r}{n}}{}\n\\quad \\infer{\\tof{\\mt{Fail}}{n}}{}\n\\quad \\infer{\\tof{\\mt{Read} \\; a}{n+1}}{}\n\\quad \\infer{\\tof{\\mt{Write} \\; a \\; v}{n+1}}{}$$\n\n$$\\infer{\\tof{\\mt{Lock} \\; a}{n+1}}{}\n\\quad \\infer{\\tof{\\mt{Unlock} \\; a}{n+1}}{}$$\n\n$$\\infer{\\tof{x \\leftarrow c_1; c_2(x)}{n_1 + n_2 + 1}}{\n  \\tof{c_1}{n_1}\n  & \\forall r. \\; \\tof{c_2(r)}{n_2}\n}\n\\quad \\infer{\\tof{c_1 || c_2}{n_1 + n_2 + 1}}{\n  \\tof{c_1}{n_1}\n  & \\tof{c_2}{n_2}\n}$$\n\nIt may be surprising that, in our formal mixed embedding, there exist commands with no provable upper bounds, according to this relation.\nWe leave it as an exercise to the reader to find a concrete example.\n(Actually, the Coq code includes an example and its proof of unboundedness.)\n\nOne last ingredient is to work with a relation $\\to^i$, which is the $i$-way self-composition of $\\to$.\nIt is easy to show that whenever $x \\to^* y$, there exists $i$ such that $x \\to^i y$.\n\n\\newcommand{\\smallstepsC}[3]{#1 \\to_C^{#2*} #3}\n\nWith these ingredients, we can state the reduction theorem.\n\\abstraction\n\\begin{theorem}\n  If $\\summ{c_2}{s}$ and $\\tof{c_1 || c_2}{n}$, then to prove $\\mt{natf}$ as an invariant of $\\mathbb T(h, l, c_1 || c_2)$, it suffices to prove $\\mt{natf}$ as an invariant of $\\mathbb T_C(h, l, c_1, c_2, s)$.\n\\end{theorem}\n\\begin{proof}\n  Setting $c = c_1 || c_2$, we assume for the sake of contradiction that there exists some derivation $\\smallsteps{(h, l, c)}{(h', l', c')}$, where $\\neg \\natf{h', l', c'}$.\n  First, since $c$ runs in bounded time, by Lemma \\ref{completion}, we can \\emph{complete} that execution to continue running to some $(h'', l'', c'')$, which is a stuck state.\n  By Lemma \\ref{stillFailing}, $\\neg \\natf{h'', l'', c''}$.\n  Next, we conclude that there exists $i$ such that $(h, l, c) \\to^i (h'', l'', c'')$.\n  By Lemma \\ref{translate_trace}, there exist $h'''$, $l'''$, and $c'''$ where $\\smallstepsC{(h, l, c_1 || c_2)}{s}{(h''', l''', c''')}$ and $\\neg \\natf{c'''}$.\n  These facts contradict our assumption that $\\mt{natf}$ is an invariant of $\\mathbb T_C(h, l, c_1, c_2, s)$.\n\\end{proof}\n\n\\begin{lemma}\\label{completion}\n  If $\\tof{c}{n}$, then there exist $h'$, $l'$, and $c'$ where $\\smallsteps{(h, l, c)}{(h', l', c')}$, such that $(h', l', c')$ is a stuck state.\n\\end{lemma}\n\\begin{proof}\n  By strong induction\\index{strong induction} on $n$.\n\\end{proof}\n\n\\begin{lemma}\\label{stillFailing}\n  If $\\smallsteps{(h, l, c)}{(h', l', c')}$ and $\\neg \\natf{c}$, then $\\neg \\natf{c'}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\smallsteps{(h, l, c)}{(h', l', c')}$, with a nested induction on the derivations of individual steps.\n\\end{proof}\n\n\\begin{lemma}\\label{translate_trace}\n  If $(h, l, c_1 || c_2) \\to^i (h', l', c')$, and $(h', l', c')$ is stuck and about to fail, and $\\summ{c_2}{s}$, then there exist $h''$, $l''$, and $c'''$ such that $\\smallstepsC{(h, l, c_1 || c_2)}{s}{(h'', l'', c''')}$ and $\\neg \\natf{c'''}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on $i$.\n  Note that induction on the structure of a derivation $\\smallsteps{(h, l, c_1 || c_2)}{(h', l', c')}$ would \\emph{not} be sufficient here, as we will see in the proof sketch below that we sometimes invoke the induction hypothesis on an execution trace that is not just the tail of the one we started with.\n\n  If $i = 0$, then $(h, l, c_1 || c_2)$ is already about to fail, and the conclusion follows trivially.\n\n  Otherwise, $i = i' + 1$ for some $i'$.\n  We proceed by cases on the truth of $\\pors{h, l, c_1, c_2, s}$.\n\n  If $\\neg \\pors{h, l, c_1, c_2, s}$, then we invert the derivation $(h, l, c_1 || c_2) \\to^i (h', l', c')$ to conclude $\\smallstep{(h, l, c_1 || c_2)}{(h'', l'', c'')}$ and $(h'', l'', c'') \\to^{i'} (h', l', c')$ for some intermediate state.\n  $\\to_C$ is easily able to match that first step, as the optimization is disabled, and the rest follows directly by appeal to the induction hypothesis.\n\n  Otherwise, $\\pors{h, l, c_1, c_2, s}$, and the key optimization is enabled, so that $\\to_C$ only allows the first thread to run.\n  The next deduction is not immediate, because the first original step $\\smallstep{(h, l, c_1 || c_2)}{(h'', l'', c'')}$ may have chosen a thread beside $c_1$.\n  However, the trace $(h, l, c_1 || c_2) \\to^{i'+1} (h', l', c')$ \\emph{must} eventually pick the first thread to run, and we apply Lemma \\ref{translate_trace_commute} to \\emph{commute} that eventual step to the front of the derivation, showing its equivalence to one that runs the first thread and then takes $i'$ additional steps to $(h', l', c')$.\n  At this point the induction hypothesis applies to those $i'$ steps, to finish the proof.\n\\end{proof}\n\n\\begin{lemma}\\label{translate_trace_commute}\n  If $(h, l, c_1 || c_2) \\to^{i+1} (h', l', c')$, where that last state is stuck, and if $\\summ{c_2}{s}$, $\\na{c_1} = x$, $\\commu{x}{s}$, and $\\smallstep{(h, l, c_1)}{(h_0, l_0, c'_1)}$, then $(h_0, l_0, c'_1 || c_2) \\to^i (h', l', c')$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $(h, l, c_1 || c_2) \\to^{i+1} (h', l', c')$, appealing to a few crucial lemmas, such as single-step determinism of any state in $\\mt{nextAction}$'s domain, plus the soundness of $\\mt{commutes}$ with respect to single steps of pairs of commands, plus the fact that single steps preserve the accuracy of summaries.\n\\end{proof}\n\n\\section{Partial-Order Reduction More Generally}\n\nThe key insights of the prior section can be adapted to prove soundness of a whole family of optimizations by partial-order reduction.\nIn general, we apply the optimization to remove edges from a state-space graph, whose nodes are states and whose edges are labeled with \\emph{actions} $\\alpha$.\nIn our setting, $\\alpha$ is the identifier of the thread scheduled to run next.\nTo do model checking, the graph need not be materialized in memory in one go.\nInstead, as an optimization, the graph tends to be constructed on the fly, during state-space exploration.\n\nThe proofs from the last two sections only apply to check the invariant that no thread is about to fail.\nHowever, the results easily generalize to arbitrary \\emph{safety properties}\\index{safety properties}, which can be expressed as decidable invariants on states.\nAnother important class of specifications is \\emph{liveness properties}\\index{liveness properties}, the most canonical example of which is \\emph{termination}, phrased in terms of reachability of some subsets of states designated as \\emph{finished}.\nThere are many other useful liveness properties.\nAnother example applies to a producer-consumer system\\index{producer-consumer systems}, where one thread continually enqueues new work into a queue, and another thread continually dequeues work items and does something with them.\nA good liveness property for that system could be that, whenever the producer enqueues an item, the consumer eventually dequeues it, and from there the consumer eventually takes some visible action based on the value of the item.\nOur general treatment of partial-order reduction is parameterized on some property $\\phi$ over states, and it may be safety, liveness, or a combination of the two.\n\nEvery state $s$ of the transition system has an associated set $\\mathcal E(s)$ of identifiers for threads that are enabled to run in $s$.\nThe partial-order reduction optimization conceptually is based on picking a function $\\mathcal A$, mapping each state $s$ to an \\emph{ample set}\\index{ample sets} $\\mathcal A(s)$ of threads to consider in state-space exploration.\nA few eligibility criteria apply, for every state $s$.\n\n\\begin{description}\n  \\item[Readiness] \\index{readiness}$\\mathcal A(s) \\subseteq \\mathcal E(s)$.  That is, we do not select any threads that are not actually ready to run.\n  \\item[Progress] \\index{progress (partial-order reduction)}If $\\mathcal A(s) = \\emptyset$, then $\\mathcal E(s) = \\emptyset$.  That is, so long as any thread at all can step, we select at least one thread.\n  \\item[Commutativity] \\index{commutativity (partial-order reduction)}Consider all executions starting at $s$ and taking steps only with the threads \\emph{not} in $\\mathcal A(s)$.  These executions only include actions that commute with the next actions of the threads in $\\mathcal A(s)$.  As a consequence, any actions that run before elements of the ample set can be reordered to follow the execution of any ample-set element.\n  \\item[Invisibility] \\index{invisibility}If $\\mathcal A(s) \\neq \\mathcal E(s)$, then no action in $\\mathcal A(s)$ modifies the truth of $\\phi$.\n\\end{description}\n\nAny ample-set algorithm leads to a different variant of $\\to_C$ from the prior section, and it is possible to prove that any such transition system is a sound abstraction of the original.\n\nAs an example of a different heuristic, consider a weakness of the one from the prior section: when we pick a thread $c$ as the only one to consider running next, $c$'s first action must commute with \\emph{any action that any other thread might ever run, for the entire rest of the execution}.\nHowever, imagine that thread $c$ holds some lock $a$.\nWe might formalize that notion by saying that (1) $a$ is in the lockset, and (2) the other threads, running independently, will never manage to run an $\\mt{Unlock} \\; a$ command.\nA computable static analysis can verify this statement for many nontrivial programs.\nNow consider which summaries of the other threads we can get away with comparing against $c$ for commutativity.\nWe only need to collect the actions that other threads can run \\emph{before each one reaches its first occurrence of $\\mt{Lock} \\; a$}.\nThe reason is that, if $c$ holds lock $a$ and hasn't run yet, no other thread can progress past its first $\\mt{Lock} \\; a$.\nNow threads may share addresses for read and write access, yet still take advantage of the optimization, when accesses are properly protected by locks.\n\nThe conditions above are only sufficient because we left unbounded loops out of our object language.\nWhat happens if we add them back in?\nConsider this program:\n$$(\\mt{while} \\; (\\mt{true}) \\; \\{ \\; \\mt{Write} \\; 0 \\; 0 \\; \\}) \\; || \\; (n \\leftarrow \\mt{Read} \\; 1; \\mt{Fail})$$\nAn optimization in the spirit of our original from the prior section would happily decree that it is safe always to pick the first thread to run.\nThis reduced state transition system never gets around to running the second thread, so exploring the state space never finds the failure!\nTo plug this soundness hole, we add a final condition on the ample sets.\n\n\\begin{description}\n  \\item[Fairness] \\index{fairness}If there is a cycle in the finite state space where $\\alpha$ is enabled at some point, then $\\alpha \\in \\mathcal A(s)$ for some $s$ in the cycle.\n\\end{description}\n\nThis condition effectively forces the ample set for the example program above to include the second thread.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Concurrent Separation Logic}\n\nChapters \\ref{seplog} and \\ref{sharedmem} respectively introduced techniques for reasoning about two tricky aspects of programs: heap-allocated linked data structures\\index{linked data structures} and shared-memory concurrency\\index{shared-memory concurrency}.\nWhen we add concurrency to the mix for a program-reasoning problem, we are often surprised at how much more complex it becomes.\nThis chapter introduces a pleasant exception to the rule, \\emph{concurrent separation logic}\\index{concurrent separation logic}, a rather small addition to separation logic\\index{separation logic} that supports invariant-based reasoning about threads-and-locks shared-memory programs.\n\n\\section{Object Language: Loops and Locks}\n\nHere's the object language we adopt, which should be old hat by now, just mixing together features of the object languages from Chapters \\ref{seplog} and \\ref{sharedmem}.\n\n$$\\begin{array}{rrcl}\n  \\textrm{Commands} & c &::=& \\mt{Fail} \\mid \\mt{Return} \\; v \\mid x \\leftarrow c; c \\mid \\mt{Loop} \\; i \\; f \\\\\n  &&& \\mid \\mt{Read} \\; a \\mid \\mt{Write} \\; a \\; v \\mid \\mt{Lock} \\; a \\mid \\mt{Unlock} \\; a \\mid c || c\n\\end{array}$$\n\n$$\\infer{\\smallstep{(h, l, x \\leftarrow c_1; c_2(x))}{(h', l', x \\leftarrow c'_1; c_2(x))}}{\n  \\smallstep{(h, l, c_1)}{(h', l', c'_1)}\n}\n\\quad \\infer{\\smallstep{(h, l, x \\leftarrow \\mt{Return} \\; v; c_2(x))}{(h, k, c_2(v))}}{}$$\n\n$$\\infer{\\smallstep{(h, l, \\mt{Loop} \\; i \\; f)}{(h, l, x \\leftarrow f(\\mt{Again}(i)); \\mt{match} \\; x \\; \\mt{with} \\; \\mt{Done}(a) \\Rightarrow \\mt{Return} \\; a \\mid \\mt{Again}(a) \\Rightarrow \\mt{Loop} \\; a \\; f)}}{}$$\n\n$$\\infer{\\smallstep{(h, l, \\mt{Read} \\; a)}{(h, l, \\mt{Return} \\; v)}}{\n  \\msel{h}{a} = v\n}\n\\quad \\infer{\\smallstep{(h, l, \\mt{Write} \\; a \\; v')}{(\\mupd{h}{a}{v'}, l, \\mt{Return} \\; ())}}{\n  \\msel{h}{a} = v\n}$$\n\n$$\\infer{\\smallstep{(h, l, \\mt{Lock} \\; a)}{(h, l \\cup \\{a\\}, \\mt{Return} \\; ())}}{\n  a \\notin l\n}\n\\quad \\infer{\\smallstep{(h, l, \\mt{Unlock} \\; a)}{(h, l \\setminus \\{a\\}, \\mt{Return} \\; ())}}{\n  a \\in l\n}$$\n\n$$\\infer{\\smallstep{(h, l, c_1 || c_2)}{(h', l', c'_1 || c_2)}}{\n  \\smallstep{(h, l, c_1)}{(h', l', c'_1)}\n}\n\\quad \\infer{\\smallstep{(h, l, c_1 || c_2)}{(h', l', c_1 || c'_2)}}{\n  \\smallstep{(h, l, c_2)}{(h', l', c'_2)}\n}$$\n\n\n\\section{The Program Logic}\n\nWe will build on basic separation logic, using the same kind of assertions and even adopting all of the original rules unchanged.\nHere they are again, for easy reference.\n\n$$\\infer{\\hoare{\\emp}{\\mt{Return} \\; v}{\\lambda r. \\; \\lift{r = v}}}{}\n\\quad \\infer{\\hoare{P}{x \\leftarrow c_1; c_2(x)}{R}}{\n  \\hoare{P}{c_1}{Q}\n  & (\\forall r. \\; \\hoare{Q(r)}{c_2(r)}{R})\n}$$\n\n$$\\infer{\\hoare{I(\\mt{Again}(i))}{\\mt{Loop} \\; i \\; f}{\\lambda r. \\; I(\\mt{Done}(r))}}{\n  \\forall a. \\; \\hoare{I(\\mt{Again}(a))}{f(a)}{I}\n}\n\\quad \\infer{\\hoare{\\lift{\\bot}}{\\mt{Fail}}{\\lambda \\_. \\; \\lift{\\bot}}}{}$$\n\n$$\\infer{\\hoare{\\exists v. \\; \\ptsto{a}{v} * R(v)}{\\mt{Read} \\; a}{\\lambda r. \\; \\ptsto{a}{r} * R(r)}}{}\n\\quad \\infer{\\hoare{\\exists v. \\; \\ptsto{a}{v}}{\\mt{Write} \\; a \\; v'}{\\lambda \\_. \\; \\ptsto{a}{v'}}}{}$$\n\n$$\\infer{\\hoare{\\emp}{\\mt{Alloc} \\; n}{\\lambda r. \\; \\ptsto{r}{0^n}}}{}\n\\quad \\infer{\\hoare{\\ptsto{a}{\\; ?^n}}{\\mt{Free} \\; a \\; n}{\\lambda \\_. \\; \\emp}}{}$$\n\n$$\\infer{\\hoare{P'}{c}{Q'}}{\n  \\hoare{P}{c}{Q}\n  & P' \\Rightarrow P\n  & \\forall r. \\; Q(r) \\Rightarrow Q'(r)\n}\n\\quad \\infer{\\hoare{P * R}{c}{\\lambda r. \\; Q(r) * R}}{\n  \\hoare{P}{c}{Q}\n}$$\n\n\\modularity\nWhen two threads use disjoint regions of memory, it is trivial to apply this rule of Concurrent Separation Logic to verify the threads independently.\n$$\\infer{\\hoare{P_1 * P_2}{c_1 || c_2}{\\lambda r. \\; Q_1(r) * Q_2(r)}}{\n  \\hoare{P_1}{c_1}{Q_1}\n  & \\hoare{P_2}{c_2}{Q_2}\n}$$\nThe separating conjunction $*$ turned out to be just the right way to express the idea of ``splitting the heap into a part for the first thread and a part for the second thread.''\nBecause $c_1$ and $c_2$ touch disjoint memory regions, all of their memory operations commute\\index{commutativity}, so that we need not worry about the state-explosion problem, in all the ways that the scheduler might interleave their steps.\n\nHowever, with realistic shared-memory programs, we don't get off that easy.\nThreads \\emph{do} share memory regions, using \\emph{synchronization}\\index{synchronization} to tame the state-explosion problem.\nOur object language includes locks as its example of synchronization, and Concurrent Separation Logic is specialized to locks.\nWe may keep the simplistic-seeming rule for parallel composition and implicitly enrich its power by adding a twist, in the form of some other rules.\n\nThe big twist is that we parameterize everything over some finite set $L$ of locks that may be used.\n\\invariants\nFurthermore, another parameter is a function $\\mathcal I$ that maps locks to invariants, which have the same type as preconditions.\nThe idea is this: when no one holds a lock, \\emph{the lock owns a chunk of memory that satisfies its invariant}.\nWhen a thread holds the lock, the lock doesn't own any memory; it is waiting for the thread to unlock it and \\emph{donate back} a chunk of memory satisfying the invariant.\nWe now think of the precondition of a Hoare triple as only describing the \\emph{local memory} of a thread, which no other thread may access; while locks and their invariants coordinate the \\emph{shared memory} regions of an application.\nThe proof rules will coordinate dynamic motion of memory regions between the shared regions and local regions.\nThis motion is only part of a proof technique; it has no runtime content reflected in the operational semantics!\n\nWith all of that set-up, the final two rules may seem surprisingly simple.\n$$\\infer{\\hoare{\\emp}{\\mt{Lock} \\; a}{\\lambda \\_. \\; \\mathcal I(a)}}{\n  a \\in L\n}\n\\quad \\infer{\\hoare{\\mathcal I(a)}{\\mt{Unlock} \\; a}{\\lambda \\_. \\; \\emp}}{\n  a \\in L\n}$$\n\nWhen a thread takes a lock, it appears as if \\emph{a memory chunk satisfying that lock's invariant materializes in the local memory space}.\nConversely, when a thread releases a lock, it appears as if \\emph{the lock grabs a memory chunk satisfying the invariant out of the local memory space}.\nThe rules are coordinating conceptual ownership transfers between local memory and the global lock memory.\n\nThe accompanying Coq code shows a few example verifications of interesting programs.\n\n\\section{Soundness Proof}\n\n\\newcommand{\\guarded}[2]{#1 \\longrightarrow #2}\n\nWe can adapt the separation-logic soundness proof to concurrency, with just a few new ideas.\nFirst, we will appreciate some new connectives for writing assertions.\nOne simple one is a guarded predicate, defined like so, for pure proposition $\\phi$ (the guard) and separation-logic assertion $P$.\n\\begin{eqnarray*}\n  \\guarded{\\phi}{P} &=& \\mt{if} \\; \\phi \\; \\mt{then} \\; P \\; \\mt{else} \\; \\emp\n\\end{eqnarray*}\n\n\\renewcommand{\\bigstar}[3]{\\Asterisk_{#1 \\in #2} #3}\n\\newcommand{\\bigstarp}[3]{\\Asterisk_{#1 \\in #2} {\\left ( #3 \\right )}}\n\nThe other key addition will be the ``big star,'' \\emph{iterated separating conjunction}, with quantification over finite sets, written like $\\bigstar{x}{S}{P(x)}$.\nThe definition is:\n\\begin{eqnarray*}\n  \\bigstar{x}{\\{v_1, \\ldots, v_n\\}}{P(x)} &=& P(v_1) * \\ldots * P(v_n)\n\\end{eqnarray*}\n\nThe reader may be worried about the inherently unordered nature of sets.\nFor each ordering of a set, we get a syntactically distinct formula on the righthand side of the defining equation.\nLuckily, separating conjunction $*$ is associative and commutative, so all orders lead to logically equivalent formulas.\n\nWith those preliminaries out of the way, we can state the soundness theorem, referring again to the \\emph{not-about-to-fail} predicate $\\mathsf{natf}$ from last chapter, extended appropriately to say that loops are not about to fail.\n\n\\invariants\n\\begin{theorem}[Soundness]\n  If $\\hoare{P}{c}{Q}$, and if a heap $h$ satisfies the predicate $(P * \\bigstar{\\ell}{L}{\\mathcal I(\\ell)})$, then $\\mathsf{natf}$ is an invariant of the system starting at state $(h, \\emptyset, c)$.\n\\end{theorem}\n\nThe theorem lays out restrictions on the starting heap.\nIt must have a segment to serve as the root thread's local heap, matching precondition $P$.\nThen, for each lock $\\ell \\in L$, there must be an associated memory region satisfying $\\mathcal I(\\ell)$.\nOur use of separating conjunction forces each of these regions to occupy disjoint memory from all the others.\n\nSome key lemmas support the proof.\nHere are the highlights.\nThe first is representative of a family of lemmas that we prove, one for each syntactic construct of the object language.\n\n\\begin{lemma}\n  If $\\hoare{P}{\\mt{Read} \\; a}{Q}$, then there exists $R$ such that $P \\Rightarrow \\exists v. \\; \\ptsto{a}{v} * R(v)$ and, for all $r$, $\\ptsto{a}{r} * R(r) \\Rightarrow Q(r)$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{\\mt{Read} \\; a}{Q}$.\n\\end{proof}\n\nAs another example incorporating more of the complexities of concurrency, we have this lemma.\n\n\\begin{lemma}\n  If $\\hoare{P}{c_1 || c_2}{Q}$, then there exist $P_1$, $P_2$, $Q_1$, and $Q_2$ such that $\\hoare{P_1}{c_1}{Q_1}$, $\\hoare{P_2}{c_2}{Q_2}$, $P \\Rightarrow P_1 * P_2$, and $Q_1(()) * Q_2(()) \\Rightarrow Q(())$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c_1 || c_2}{Q}$.\n  One somewhat surprising case is when the frame rule begins the derivation.\n  We have some predicate $R$ that is added to both the precondition and postcondition.\n  In picking $P_1$, $P_2$, $Q_1$, and $Q_2$, we have a choice as to where we incorporate $R$.\n  The two threads together leave $R$ alone, so clearly either thread individually does, too.\n  Therefore, we arbitrarily incorporate $R$ in $P_1$ and $Q_1$.\n\\end{proof}\n\nTwo lemmas express crucial techniques to isolate elements within iterated conjunction.\n\n\\begin{lemma}\\label{chunkslock}\n  If $v \\in S$, then $\\bigstar{x}{S}{P(x)} \\Rightarrow P(v) * \\bigstar{x}{S \\setminus \\{v\\}}{P(x)}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the cardinality of $S$.\n\\end{proof}\n\n\\begin{lemma}\\label{chunksunlock}\n  If $v \\notin S$, then $P(v) * \\bigstar{x}{S}{P(x)} \\Rightarrow \\bigstar{x}{S \\cup \\{v\\}}{P(x)}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the cardinality of $S$.\n\\end{proof}\n\n\\begin{lemma}[Preservation]\\label{cslpreservation}\n  If $\\smallstep{(h, l, c)}{(h', l', c')}$, $\\hoare{P}{c}{Q}$, and $h$ satisfies $(P * R * \\bigstarp{\\ell}{L}{\\guarded{\\ell \\notin l}{\\mathcal I(\\ell)}})$, then there exists $P'$ such that $\\hoare{P'}{c'}{Q}$, where $h'$ satisfies $(P' * R * \\bigstarp{\\ell}{L}{\\guarded{\\ell \\notin l'}{\\mathcal I(\\ell)}})$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\smallstep{(h, l, c)}{(h', l', c')}$.\n  The cases for lock and unlock respectively use Lemmas \\ref{chunkslock} and \\ref{chunksunlock}.\n  Note that we include the parameter $R$ solely to get a strong enough induction hypothesis for steps of commands $c_1 || c_2$.\n  We need to know that a step by one thread does not change the private heap of the other thread.\n  To draw that conclusion, in appealing to the induction hypothesis, we extend $R$ with precisely that private state.\n\\end{proof}\n\n\\begin{lemma}\\label{nonelocked}\n  $\\bigstar{\\ell}{L}{\\mathcal I(\\ell)} \\Rightarrow \\bigstarp{\\ell}{L}{\\guarded{\\ell \\notin \\emptyset}{\\mathcal I(\\ell)}}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on the cardinality of $L$.\n\\end{proof}\n\n\\begin{lemma}\\label{cslinvariant}\n  If $\\hoare{P}{c}{Q}$, and if a heap $h$ satisfies the predicate $(P * \\bigstar{\\ell}{L}{\\mathcal I(\\ell)})$, then an invariant of the system starting at state $(h, \\emptyset, c)$ is: for reachable state $(h', l', c')$, there exists $P'$ where $\\hoare{P'}{c'}{Q}$, such that $h'$ satisfies $(P' * \\bigstarp{\\ell}{L}{\\guarded{\\ell \\notin l'}{\\mathcal I(\\ell)}})$.\n\\end{lemma}\n\\begin{proof}\n  By invariant induction\\index{invariant induction}, using Lemma \\ref{nonelocked} for the base case and Lemma \\ref{cslpreservation} for the induction step, the latter with $R = \\emp$.\n\\end{proof}\n\n\\begin{lemma}[Progress]\\label{cslprogress}\n  If $\\hoare{P}{c}{Q}$ and $c$ is about to fail, then $P$ is unsatisfiable.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\hoare{P}{c}{Q}$.\n\\end{proof}\n\nThe overall soundness proof proceeds by invariant weakening\\index{invariant weakening} with the invariant established by Lemma \\ref{cslinvariant}.\nWe prove the inclusion of new invariant in old by Lemma \\ref{cslprogress}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{process_algebra}Process Algebra and Refinement}\n\nThe last two chapters dealt with the most popular sort of concurrent programming, the threads-and-locks\\index{threads and locks} shared-memory\\index{shared-memory concurrency} style.\nIt's a fundamentally imperative style, with side effects coordinating synchronization across threads.\nAnother well-established (and increasingly popular) style is \\emph{message passing}\\index{message-passing concurrency}, which is closer in spirit to functional programming.\nIn that world, there is, in fact, no memory at all, let alone shared memory.\nInstead, state is incorporated into the text of thread code, and information passes from thread to thread by sending \\emph{messages} over \\emph{channels}\\index{channel}.\nThere are two main kinds of message passing.\nIn the \\emph{asynchronous}\\index{asynchronous message passing} or \\emph{mailbox}\\index{mailbox} style, a thread can deposit a message in a channel, even when no one is ready to receive the message immediately.\nLater, a thread can come along and effectively dequeue the message from the channel.\nIn the \\emph{synchronous}\\index{synchronous message passing} or \\emph{rendezvous}\\index{rendezvous} style, a message send only executes when a matching receive, on the same channel, is available immediately.\nThe threads of the two complementary operations \\emph{rendezvous} and pass the message in one atomic step.\n\nPackages of semantics and proof techniques for such languages are often called \\emph{process algebras}\\index{process algebra}, as they support an algebraic style of reasoning about the source code of message-passing programs.\nThat is, we prove laws very similar to the familiar equations of algebra, and use those laws to ``rewrite'' inside larger processes, by replacing their subprocesses with others we have shown suitably equivalent.\nIt's a powerful technique for highly modular proofs, which we develop in the rest of this chapter for one concrete synchronous language.\nWell-known process algebras include the $\\pi$-calculus\\index{$\\pi$-calculus} and the Calculus of Communicating Systems\\index{Calculus of Communicating Systems}; the one we focus on is idiosyncratic and designed partly to make the Coq proofs manageable.\n\n\n\\section{An Object Language with Synchronous Message Passing}\n\n\\newcommand{\\newp}[3]{\\nu[#1](#2); #3}\n\\newcommand{\\block}[2]{\\mt{block}(#1); #2}\n\\newcommand{\\send}[3]{!#1(#2); #3}\n\\newcommand{\\recv}[3]{?#1(#2); #3}\n\\newcommand{\\parl}[2]{#1 || #2}\n\\newcommand{\\dup}[1]{\\mt{dup}(#1)}\n\\newcommand{\\done}[0]{\\mt{done}}\n\n$$\\begin{array}{rrcl}\n  \\textrm{Channels} & c \\\\\n  \\textrm{Processes} & p &::=& \\newp{\\vec{c}}{x}{p(x)} \\mid \\block{c}{p} \\mid \\; \\send{c}{v}{p} \\mid \\; \\recv{c}{x}{p(x)} \\mid \\parl{p}{p} \\mid \\dup{p} \\mid \\done\n\\end{array}$$\n\nHere's the intuitive explanation of each syntax construction.\n\\begin{itemize}\n  \\item \\textbf{Fresh channel generation}\\index{fresh channel generation} $\\newp{\\vec{c}}{x}{p(x)}$ creates a new \\emph{private} channel to be used by the body process $p(x)$, where we replace $x$ with the channel that is chosen.  Following tradition, we use the Greek letter $\\nu$\\index{$\\nu$}\\index{nu} (nu) for this purpose.  Each generation operation takes a parameter $\\vec{c}$, which we call the \\emph{support}\\index{support} of the operation.  It gives a list of channels already in use for other purposes, so that the fresh channel must not equal any of them.  (We assume an infinite domain of channels, so that, for any specific list, it is always possible to find a channel not in that list.)\n\n  \\item \\textbf{Abstraction boundaries} $\\block{c}{p}$ prevent ``the outside world'' from sending $p$ any messages on channel $c$ or receiving any messages from $p$ via $c$.  That is, $c$ is treated as a local channel for $p$.\n\\abstraction\n\n  \\item \\textbf{Sends} $\\send{c}{v}{p}$ and \\textbf{receives} $\\recv{c}{x}{p(x)}$, where we use an exclamation mark to suggest ``telling something'' and a question mark to suggest ``asking something.''  Processes of these kinds can rendezvous when they agree on the channel.  When $\\send{c}{v}{p_1}$ and $\\recv{c}{x}{p_2(x)}$ rendezvous, they respectively evolve to $p_1$ and $p_2(v)$.\n\n  \\item \\textbf{Parallel compositions}\\index{duplication} $\\parl{p_1}{p_2}$ work as we're used to by now.\n\n  \\item \\textbf{Duplications}\\index{duplication} $\\dup{p}$ act just like infinitely many copies of $p$ composed in parallel.  We use them to implement nonterminating ``server'' processes that are prepared to respond to many requests over particular channels.  In traditional process algebra, duplication fills the role that loops and recursion fill in conventional programming.\n\n  \\item \\textbf{The inert process}\\index{inert process} $\\done$ is incapable of doing anything at all.  It stands for a finished program.\n\\end{itemize}\n\n\\newcommand{\\readl}[2]{?#1(#2)}\n\\newcommand{\\writel}[2]{!#1(#2)}\n\\newcommand{\\lts}[3]{#1 \\stackrel{#2}{\\longrightarrow} #3}\n\\newcommand{\\ltsS}[3]{#1 \\stackrel{#2}{\\longrightarrow}^* #3}\n\n\\medskip\n\nWe give an operational semantics in the form of a \\emph{labeled transition system}\\index{labeled transition system}, as we did to formalize output instructions for compiler correctness in Chapter \\ref{compiler_correctness}.\nThat is, we not only express how a step takes us from one state to another, but we also associate each step with a \\emph{label}\\index{label} that summarizes what happened.\nOur labels will include the \\emph{silent} label $\\silent$, read labels $\\readl{c}{v}$, and write labels $\\writel{c}{v}$.\nThe latter two indicate that a thread has read a value from or written a value to channel $c$, respectively, and the parameter $v$ indicates which value was read or written.\nWe write $\\lts{p_1}{l}{p_2}$ to say that process $p_1$ steps to $p_2$ by performing label $l$.\nWe use $\\lts{p_1}{}{p_2}$ as an abbreviation for $\\lts{p_1}{\\silent}{p_2}$.\n\nWe start with the rules for sends and receives.\n$$\\infer{\\lts{\\send{c}{v}{p}}{\\writel{c}{v}}{p}}{}\n\\quad \\infer{\\lts{\\recv{c}{x}{p(x)}}{\\readl{c}{v}}{p(v)}}{}$$\nThey record the action in the obvious way, but there is already an interesting wrinkle: the rule for receives \\emph{picks a value $v$ nondeterministically}.\nThis nondeterminism is resolved by the next two rules, the rendezvous rules, which force a read label to match a write label precisely.\n\n$$\\infer{\\lts{\\parl{p_1}{p_2}}{}{\\parl{p'_1}{p'_2}}}{\n  \\lts{p_1}{\\writel{c}{v}}{p'_1}\n  & \\lts{p_2}{\\readl{c}{v}}{p'_2}\n}\n\\quad \\infer{\\lts{\\parl{p_1}{p_2}}{}{\\parl{p'_1}{p'_2}}}{\n  \\lts{p_1}{\\readl{c}{v}}{p'_1}\n  & \\lts{p_2}{\\writel{c}{v}}{p'_2}\n}$$\n\nA fresh channel generation can step according to any valid choice of channel.\n$$\\infer{\\lts{\\newp{\\vec c}{x}{p(x)}}{}{\\block{c}{p(c)}}}{\n  c \\notin \\vec c\n}$$\n\nAn abstraction boundary prevents steps with labels that mention the protected channel.\n(We overload notation $c \\in l$ to indicate that channel $c$ appears in the send/receive position of label $l$.)\n$$\\infer{\\lts{\\block{c}{p}}{l}{\\block{c}{p'}}}{\n  \\lts{p}{l}{p'}\n  & c \\notin l\n}$$\n\nAny step can be lifted up out of a parallel composition.\n$$\\infer{\\lts{\\parl{p_1}{p_2}}{l}{\\parl{p'_1}{p_2}}}{\n  \\lts{p_1}{l}{p'_1}\n}\n\\quad \\infer{\\lts{\\parl{p_1}{p_2}}{l}{\\parl{p_1}{p'_2}}}{\n  \\lts{p_2}{l}{p'_2}\n}$$\n\nFinally, a duplication can spawn a new copy (``thread'') at any time.\n$$\\infer{\\lts{\\dup{p}}{}{\\parl{\\dup{p}}{p}}}{}$$\n\nThe labeled-transition-system approach may seem a bit unwieldy for just explaining the behavior of programs.\nWhere it really pays off is in supporting a modular, algebraic reasoning style about processes, which we turn to next.\n\n\n\\section{Refinement Between Processes}\n\nWhat sorts of correctness theorems should we prove about processes?\nThe classic choice is to show that a more complex \\emph{implementation} process is a \\emph{safe substitute} for a simpler \\emph{specification} process.\nWe will say that the implementation $p$ \\emph{refines}\\index{refinement} the specification $p'$.\nIntuitively, such a claim means that any trace of labels that $p$ could generate may also be generated by $p'$, so that $p$ has \\emph{no more behaviors} than $p'$ has, though it may have fewer behaviors.\n(There is a formal connection lurking here to the notion of refinement from Chapter \\ref{deriving}, where method calls there are analogous to channel operations here.)\nCrucially, in building traces of process executions, we ignore silent labels, only collecting the send and receive labels.\n\nThis condition is called \\emph{trace inclusion}\\index{trace inclusion}, and, though it is intuitive, it is not strong enough to support all of the composition properties that we will want.\nInstead, we formalize refinement via \\emph{simulation}, very similarly to how we formalized compiler correctness in Chapter \\ref{compiler_correctness} and data abstraction in Chapter \\ref{deriving}.\n\n\\abstraction\n\\begin{definition}\n  Binary relation $R$ between processes is a \\emph{simulation} when these two conditions hold.\n  \\begin{itemize}\n  \\item \\textbf{Silent steps match up}: when $p_1 \\; R \\; p_2$ and $\\lts{p_1}{}{p'_1}$, there always exists $p'_2$ such that $\\ltsS{p_2}{}{p'_2}$ and $p'_1 \\; R \\; p'_2$.\n  \\item \\textbf{Communication steps match up}: when $p_1 \\; R \\; p_2$ and $\\lts{p_1}{l}{p'_1}$ for $l \\neq \\silent$, there always exist $p''_2$ and $p'_2$ such that $\\ltsS{p_2}{}{p''_2}$, $\\lts{p''_2}{l}{p'_2}$, and $p'_1 \\; R \\; p'_2$.\n  \\end{itemize}\n\\end{definition}\n\nIntuitively, $R$ is a simulation when, starting in a pair of related processes, any step on the left can be matched by a step on the right, taking us back into $R$.\nThe conditions are naturally illustrated with commuting diagrams\\index{commuting diagram}.\n\n\\[\n\\begin{tikzcd}\np_1 \\arrow{r}{R} \\arrow{d}{\\forall \\longrightarrow} & p_2 \\arrow{d}{\\exists \\longrightarrow^*} \\\\\np'_1 & p'_2 \\arrow{l}{R^{-1}}\n\\end{tikzcd}\n\\quad \\begin{tikzcd}\np_1 \\arrow{r}{R} \\arrow{d}{\\forall \\stackrel{l}{\\longrightarrow}} & p_2 \\arrow{d}{\\exists \\longrightarrow^* \\stackrel{l}{\\longrightarrow}} \\\\\np'_1 & p'_2 \\arrow{l}{R^{-1}}\n\\end{tikzcd}\n\\]\n\n\\newcommand{\\refines}[2]{#1 \\leq #2}\n\n\\invariants\nSimulations have quite a lot in common with our well-worn concept of invariants of transition systems.\nSimulation can be seen as a kind of natural generalization of invariants, which are predicates over single states, into relations that apply to states of two different transition systems that need to evolve in (approximate) lock-step.\n\nWe define \\emph{refinement} $\\refines{p_1}{p_2}$ to indicate that there exists a simulation $R$ such that $p_1 \\; R \\; p_2$.\nLuckily, this somewhat involved definition is easily related back to our intuitions.\n\n\\begin{theorem}\n  If $\\refines{p_1}{p_2}$, then every trace generated by $p_1$ is also generated by $p_2$.\n\\end{theorem}\n\\begin{proof}\n  By induction on executions of $p_1$.\n\\end{proof}\n\nRefinement is also a preorder\\index{preorder}.\n\n\\begin{theorem}[Reflexivity]\n  For all $p$, $\\refines{p}{p}$.\n\\end{theorem}\n\\begin{proof}\n  Choose equality as the simulation relation.\n\\end{proof}\n\n\\begin{theorem}[Transitivity]\n  If $\\refines{p_1}{p_2}$ and $\\refines{p_2}{p_3}$, then $\\refines{p_1}{p_3}$.\n\\end{theorem}\n\\begin{proof}\n  The two premises respectively imply the existence of simulations $R_1$ and $R_2$.\n  Set the new simulation relation as $R_1 \\circ R_2$, defined to contain a pair $(p, q)$ iff there exists $r$ with $p \\; R_1 \\; r$ and $r \\; R_2 \\; q$.\n\\end{proof}\n\nThe accompanying Coq code includes several examples of verifying moderately complex processes, by manual tailoring of simulation relations.\nWe leave those details to the code, turning now instead to further algebraic properties that allow us to \\emph{compose} laborious manual proofs about components, in a black-box way.\n\n\n\\section{The Algebra of Refinement}\n\nWe finish the chapter with a tour through some algebraic properties of refinement that are proved in the Coq source.\nWe usually omit proof details here, though we work out one interesting example in more detail.\n\nPerhaps the greatest pay-off from the refinement approach is that \\emph{refinement is a congruence for parallel composition}\\index{congruence}.\n\\begin{theorem}\n  If $\\refines{p_1}{p'_1}$ and $\\refines{p_2}{p'_2}$, then $\\refines{\\parl{p_1}{p_2}}{\\parl{p'_1}{p'_2}}$.\n\\end{theorem}\n\n\\modularity\nThis deceptively simple theorem statement packs a strong modularity punch!\nWe can verify a component in isolation and then connect to an arbitrary additional component, immediately concluding that the composition behaves properly.\nThe secret sauce, implicit in our formulation of the object language and refinement, is the labeled-transition-system style, where processes may generate receive labels nondeterministically.\nIn this way, we can reason about a process implicitly in terms of \\emph{every value that some other process might send to it when they are composed}, without needing to quantify explicitly over all other eligible processes.\n\nA similar congruence property holds for duplication, and we'll take this opportunity to explain a bit of the proof, in the form of choosing a good simulation relation.\n\\begin{theorem}\n  If $\\refines{p}{p'}$, then $\\refines{\\dup{p}}{\\dup{p'}}$.\n\\end{theorem}\n\\begin{proof}\n  The premise implies the existence of a simulation $R$.\n  We define a derived relation $R^D$ with these inference rules.\n  $$\\infer{p \\; R^D \\; p'}{\n    p \\; R \\; p'\n  }\n  \\quad \\infer{\\dup{p} \\; R^D \\; \\dup{p'}}{\n    p \\; R \\; p'\n  }\n  \\quad \\infer{\\parl{p_1}{p_2} \\; R^D \\; \\parl{p'_1}{p'_2}}{\n    p_1 \\; R^D \\; p'_1\n    & p_2 \\; R^D \\; p'_2\n  }$$\n  $R^D$ is precisely the relation we need to finish the current proof.\n  Intuitively, the challenge is that $\\dup{p}$ includes infinitely many copies of $p$, each of which may evolve in a different way.\n  It is even possible for different copies to interact with each other through shared channels.\n  However, comparing intermediate states of $\\dup{p}$ and $\\dup{p'}$, we expect to see a shared backbone, where corresponding threads are related by the original simulation $R$.\n  The definition of $R^D$ formalizes that intuition of a shared backbone with $R$ connecting corresponding leaves.\n\\end{proof}\n\n\\newcommand{\\neverUses}[2]{\\mt{neverUses}(#1, #2)}\n\nWe wrap up the chapter with a few more algebraic properties, which the Coq code puts to good use in larger examples.\nWe sometimes rely on a predicate $\\neverUses{c}{p}$, to express that, no matter how other threads interact with it, process $p$ will never perform a send or receive operation on channel $c$.\n\n\\begin{theorem}\n  If $\\refines{p}{p'}$, then $\\refines{\\block{c}{p}}{\\block{c}{p'}}$.\n\\end{theorem}\n\n\\begin{theorem}\n  $\\refines{\\block{c_1}{\\block{c_2}{p}}}{\\block{c_2}{\\block{c_1}{p}}}$\n\\end{theorem}\n\n\\begin{theorem}\n  If $\\neverUses{c}{p_2}$, then $\\refines{(\\block{c}{\\parl{p_1}{p_2}})}{\\parl{(\\block{c}{p_1})}{p_2}}$.\n\\end{theorem}\n\n\\begin{theorem}[Handoff]\n  If $\\neverUses{c}{p(v)}$, then $\\refines{(\\block{c}{\\parl{(\\send{c}{v}{\\done})}{\\dup{\\recv{c}{x}{p(x)}}}})}{p(v)}$.\n\\end{theorem}\n\nThat last theorem is notable for how it prunes down the space of possibilities given an infinitely duplicated server, where each thread is trying to receive from a channel.\nIf server threads never touch that channel after their initial receives, then most server threads will remain inert.\nThe one send $\\send{c}{v}{\\done}$ is the only possible source of interaction with server threads, thanks to the abstraction barrier on $c$, and that one send can only awaken one server thread.\nThus, the whole composition behaves just like a single server thread, instantiated with the right input value.\n\nA concrete example of the Handoff theorem in action is a refinement like this one, applying to a kind of forwarding chain between channels:\n$$\\begin{array}{l}\n  p = \\block{c_1}{\\block{c_2}{\\parl{\\send{c_1}{v}{\\done}}{\\parl{\\dup{\\recv{c_1}{x}{\\send{c_2}{x}{\\done}}}}{\\dup{\\recv{c_2}{y}{\\send{c_3}{y}{\\done}}}}}}} \\\\\n  \\refines{p}{\\; \\send{c_3}{v}{\\done}}\n\\end{array}$$\n\nNote that, without the abstraction boundaries at the start, this fact would not be derivable.\nWe would need to worry about meddlesome threads in our environment interacting directly with $c_1$ or $c_2$, spoiling the protocol and forcing us to add extra cases to the righthand side of the refinement.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\newcommand{\\compl}[1]{\\overline{#1}}\n\\newcommand{\\channels}[0]{\\mathcal C}\n\\newcommand{\\mpty}[4]{#1 :_{#2,#3} #4}\n\\newcommand{\\mptys}[3]{#1 :_{#2} #3}\n\n\\chapter{Session Types}\n\nProcess algebra, as we met it last chapter, can be helpful for modeling network protocols\\index{network protocols}.\nHere, multiple \\emph{parties} step through a script of exchanging messages and making decisions based on message contents.\nA buggy party might introduce a \\emph{deadlock}\\index{deadlock}, where, say, party A is blocked waiting for a message from party B, while B is also waiting for A.\n\\emph{Session types} are a style of static type system\\index{type system} that rule out deadlock while allowing convenient separate checking of each party, given a shared protocol type.\n\nThere is an almost unlimited variation of different versions of session types.\nWe still step through a progression of three variants here, and even by the end there will be obvious protocols that don't fit the framework.\nStill, we aim to convey the core ideas of the approach.\n\n\\section{Basic Two-Party Session Types}\n\nEach of our type systems will apply to the object language from the prior chapter.\nAssume for now that a protocol involves exactly two parties.\nHere is a simple type system, explaining a protocol's ``script'' from the perspective of one party.\n$$\\begin{array}{rrcl}\n  \\textrm{Base types} & \\sigma \\\\\n  \\textrm{Session types} & \\tau &::=& \\send{c}{\\sigma}{\\tau} \\mid \\; \\recv{c}{\\sigma}{\\tau} \\mid \\done\n\\end{array}$$\n\n\\abstraction\nWe model simple parties with no internal duplication or parallelism.\nA session type looks like an abstracted version of a process, remembering only the \\emph{types} of messages exchanged on channels, rather than their \\emph{values}.\nA simple set of typing rules makes the connection.\n$$\\infer{\\send{c}{v}{p} : \\; \\send{c}{\\sigma}{\\tau}}{\n  v : \\sigma\n  & p : \\tau\n}\n\\quad \\infer{\\recv{c}{x}{p(x)} : \\; \\recv{c}{\\sigma}{\\tau}}{\n  \\forall v : \\sigma. \\; p(v) : \\tau\n}\n\\quad \\infer{\\done : \\done}{}$$\n\nThe only wrinkle in these rules is the use of universal quantification for the receive rule, to force the body to type-check under any well-typed value read from the channel.\nActually, such proof obligations may be nontrivial when we encode this object language in the mixed-embedding\\index{mixed embeddings} style of Section \\ref{mixed}, where the body $p$ in the rule could include arbitrary metalanguage computation, to choose a body based on the value $v$ read from the channel.\n\nThe associated Coq code demonstrates tactics to deal with that complication, for automatic type-checking of concrete programs.\nThat code is also where we keep all of our concrete examples of object-language programs.\n\nFor the rest of this chapter, we will interpret last chapter's object language as a transition system with one small change: we only allow silent steps\\index{silent steps}.\nThat is, we only model whole programs, with no communication with ``the environment.''\nAs a result, we consider self-contained protocols.\n\nA satisfying soundness theorem applies to our type system.  To state it, we first need the crucial operation of \\emph{complementing}\\index{complement (of a session type)} a session type.\n\\begin{eqnarray*}\n  \\compl{\\send{c}{\\sigma}{\\tau}} &=& \\recv{c}{\\sigma}{\\compl{\\tau}} \\\\\n  \\compl{\\recv{c}{\\sigma}{\\tau}} &=& \\send{c}{\\sigma}{\\compl{\\tau}} \\\\\n  \\compl{\\done} &=& \\done\n\\end{eqnarray*}\n\n\\modularity\nIt is apparent that complementation just swaps the sends and receives.\nWhen the original session type tells one party what to do, the complement type tells the other party what to do.\nThe power of this approach is that we can write one global protocol description (the session type) and then check two parties' code against it separately.\nA new version of one party can be dropped in without rechecking the other party's code.\n\nUsing complementation, we can give succinct conditions for deadlock freedom of a pair of parties.\n\n\\begin{theorem}\\label{stsound1}\n  If $p_1 : \\tau$ and $p_2 : \\compl{\\tau}$, then it is an invariant of $\\parl{p_1}{p_2}$ that an intermediate process is either $\\parl{\\done}{\\done}$ or can take a step.\n\\end{theorem}\n\\begin{proof}\n  By invariant induction, after strengthening the invariant to say that any intermediate process takes the form $\\parl{p'_1}{p'_2}$, where, for some type $\\tau'$, we have $p'_1 : \\tau'$ and $p'_2 : \\compl{\\tau'}$.\n  The inductive case of the proof proceeds by simple inversion on the derivation of $p'_1 : \\tau'$, where by the definition of complement it is apparent that any communication $p'_1$ performs has a matching action at the start of $p'_2$.\n  The choice of $\\tau'$ changes during such a step, to the ``tail'' of the old $\\tau'$.\n\\end{proof}\n\n\\section{Dependent Two-Party Session Types}\n\nIt is a boring protocol that follows such a regular communication pattern as our first type system accepts.\nRather, it tends to be crucial to change up the expected protocol steps, based on \\emph{values} sent over channels.\nIt is natural to switch to a \\emph{dependent}\\index{dependent types} type system to strengthen our expressiveness.\nThat is, a communication type will allow its body type to depend on the value sent or received.\n$$\\begin{array}{rrcl}\n  \\textrm{Session types} & \\tau &::=& \\send{c}{x : \\sigma}{\\tau(x)} \\mid \\; \\recv{c}{x : \\sigma}{\\tau(x)} \\mid \\done\n\\end{array}$$\n\nEach nontrivial construct does more than give the base type that should be sent or received on or from a channel.\nWe also bind a variable $x$, to stand for the value sent or received.\nIt may be unintuitive that we must introduce a binder even for sends, when the sender is in control of which value will be sent.\nThe reason is that we must allow the sender to then continue with different subprotocols for different values that might be sent.\nWe should not force the sender's hand by fixing a value in advance, when that value might depend on arbitrary program logic.\n\nVery little change is needed in the typing rules.\n$$\\infer{\\send{c}{v}{p} : \\; \\send{c}{x : \\sigma}{\\tau(x)}}{\n  v : \\sigma\n  & p : \\tau(v)\n}\n\\quad \\infer{\\recv{c}{x}{p(x)} : \\; \\recv{c}{x : \\sigma}{\\tau(x)}}{\n  \\forall v : \\sigma. \\; p(v) : \\tau(v)\n}\n\\quad \\infer{\\done : \\done}{}$$\n\nOur deadlock-freedom property is easy to reestablish.\n\n\\begin{theorem}\n  If $p_1 : \\tau$ and $p_2 : \\compl{\\tau}$, then it is an invariant of $\\parl{p_1}{p_2}$ that an intermediate process is either $\\parl{\\done}{\\done}$ or can take a step.\n\\end{theorem}\n\\begin{proof}\n  Literally the same Coq proof script as for Theorem \\ref{stsound1}!\n\\end{proof}\n\n\\section{Multiparty Session Types}\\index{multiparty session types}\n\nNew complications arise when more than two parties are communicating in a protocol.\nThe Coq code demonstrates a case of an online merchant, a customer sending it orders, and a warehouse being queried by the merchant to be sure a product is in stock.\nMany other such examples appear in the real world.\n\nNow it is no longer possible to start from one party's view of a protocol and compute any other party's view.\nThe reason is that each message only involves two parties.\nAny other party will not see that message in its own session type, making it impossible to preserve that message in a complement-like operation.\n\nInstead, we define one global session type that includes only ``send'' operations.\nHowever, we name the parties and parameterize on a mapping $\\channels$ from channels to unique parties that own their send and receive ends.\nThat is, for any given channel and operation on it (send and receive), precisely one party is given permission to perform the operation -- and indeed, when the time comes, that party is \\emph{obligated} to perform the operation, to avoid deadlock.\n\nWith that view in mind, our type language gets even simpler.\n$$\\begin{array}{rrcl}\n  \\textrm{Session types} & \\tau &::=& \\send{c}{x : \\sigma}{\\tau(x)} \\mid \\done\n\\end{array}$$\n\nWe redefine the typing judgment as $\\mpty{p}{\\alpha}{b}{\\tau}$.\nHere $\\alpha$ is the identifier of the party running $p$, and $b$ is a Boolean that, when set, enforces that $p$'s next action (if any) is a receive.\n$$\\infer{\\mpty{\\send{c}{v}{p}}{\\alpha}{\\bot}{\\send{c}{x : \\sigma}{\\tau(x)}}}{\n  v : \\sigma\n  & \\channels(c) = (\\alpha, \\beta)\n  & \\beta \\neq \\alpha\n  & \\mpty{p}{\\alpha}{\\bot}{\\tau(v)}\n}$$\n\n$$\\infer{\\mpty{\\recv{c}{x}{p(x)}}{\\alpha}{b}{\\send{c}{x : \\sigma}{\\tau(x)}}}{\n  \\channels(c) = (\\beta, \\alpha)\n  & \\beta \\neq \\alpha\n  & \\forall v : \\sigma. \\; \\mpty{p(v)}{\\alpha}{\\bot}{\\tau(v)}\n}$$\n\n$$\\infer{\\mpty{p}{\\alpha}{b}{\\send{c}{x : \\sigma}{\\tau(x)}}}{\n  \\channels(c) = (\\beta, \\gamma)\n  & \\beta \\neq \\alpha\n  & \\gamma \\neq \\alpha\n  & \\forall v : \\sigma. \\; \\mpty{p}{\\alpha}{\\top}{\\tau(v)}\n}$$\n\n$$\\infer{\\mpty{\\done}{\\alpha}{b}{\\done}}{}$$\n\nThe first two rules encode the simple cases where the current party $\\alpha$ is one of the two designated to step next in the protocol, as we verify by looking up the channel in $\\channels$.\nIt is important that the send and receive ends of the channel are owned by different parties, or we would clearly have a deadlock, as that party would either wait forever for a message from itself or try futilely to send itself a message!\nThe $\\neq$ premises enforce that condition.\nAlso, the Boolean subscript enforces that we cannot be running a send operation if we have been instructed to run a receive next.\nThat flag is reset to false in the recursive premises, since we only use the flag to express an obligation for the very next command.\n\nThe third rule is crucial: it applies to a process that is not participating in the next step of the protocol.\nThat is, we look up the owners of the channel that comes next, and we verify that neither owner is $\\alpha$.\nIn this case, we merely proceed to the next protocol step, leaving the process unchanged.\nCrucially, we must be prepared for any value that might be exchanged in this skipped step, even though we do not see it ourselves.\n\nWhy does the last premise of the third rule set the Boolean flag, forcing the next action to be a receive?\nOtherwise, at some point in the protocol, we could have multiple parties trying to send messages.\nIn such a scenario, there might not be a unique step that the composed parties can take.\nThe proofs are easier if we can assume deterministic execution within a protocol, which is why we introduced this static restriction.\n\nTo amend our theorem statement, we need to characterize when a process implements a set of parties correctly.\nWe use the judgment $\\mptys{p}{\\vec{\\alpha}}{\\tau}$ to that end, where $p$ is the process, $\\vec{\\alpha}$ is a list of all the involved parties, and $\\tau$ is the type they must follow collectively.\n$$\\infer{\\mptys{\\done}{[]}{\\tau}}{}\n\\quad \\infer{\\mptys{\\parl{p_1}{p_2}}{\\concat{\\alpha}{\\vec{\\beta}}}{\\tau}}{\n  \\mpty{p_1}{\\alpha}{\\bot}{\\tau}\n  & \\mptys{p_2}{\\vec{\\beta}}{\\tau}\n}$$\n\nThe heart of the proof is demonstrating the existence of a unique sequence of steps to a point where all parties are done.\nHere is a sketch of the key lemmas.\n\n\\begin{lemma}\\label{forever_done}\n  If $\\mptys{p}{\\vec{\\alpha}}{\\done}$, then $p$ can't take any silent step.\n\\end{lemma}\n\\begin{proof}\n  By induction on any derivation of a silent step, followed by inversion on $\\mptys{p}{\\vec{\\alpha}}{\\done}$.\n\\end{proof}\n\n\\begin{lemma}\\label{comm_stuck}\n  If $\\mptys{p}{\\vec{\\alpha}}{\\; \\send{c}{x : \\sigma}{\\tau(x)}}$ and at least one of sender or receiver of channel $c$ is missing from $\\vec{\\alpha}$, then $p$ can't take any silent step.\n\\end{lemma}\n\\begin{proof}\n  By induction on any derivation of a silent step, followed by inversion on $\\mptys{p}{\\vec{\\alpha}}{\\; \\send{c}{x : \\sigma}{\\tau(x)}}$.\n\\end{proof}\n\n\\begin{lemma}\\label{preserve_unused}\n  Assume that $\\vec{\\alpha}$ is a duplicate-free list of parties excluding both sender and receiver of channel $c$.\n  If $\\mptys{p}{\\vec{\\alpha}}{\\; \\send{c}{x : \\sigma}{\\tau(x)}}$, then for any $v : \\sigma$, we have $\\mptys{p'}{\\vec{\\alpha}}{\\tau(v)}$.\n  In other words, when we have well-typed code for a set of parties that do not participate in the first step of a protocol, that code remains well-typed when we advance to the next protocol step.\n\\end{lemma}\n\\begin{proof}\n  By induction on the derivation of $\\mptys{p}{\\vec{\\alpha}}{\\; \\send{c}{x : \\sigma}{\\tau(x)}}$.\n\\end{proof}\n\n\\begin{lemma}\\label{find_sender}\n  Assume that $\\vec{\\alpha}$ is a duplicate-free list of parties, at least comprehensive enough to include the sender of channel $c$.\n  However, $\\vec{\\alpha}$ should \\emph{exclude} the receiver of $c$.\n  If $\\mptys{p}{\\vec{\\alpha}}{\\; \\send{c}{x : \\sigma}{\\tau(x)}}$ and $\\lts{p}{\\writel{c}{v}}{p'}$, then $\\mptys{p'}{\\vec{\\alpha}}{\\tau(v)}$.\n\\end{lemma}\n\\begin{proof}\n  By induction on steps followed by inversion on multiparty typing.\n  As we step through elements of $\\vec{\\alpha}$, we expect to ``pass'' parties that do not participate in the current protocol step.\n  Lemma \\ref{preserve_unused} lets us justify those passings.\n\\end{proof}\n\n\\begin{theorem}\n  Assume that $\\vec{\\alpha}$ is a duplicate-free list of \\emph{all} parties for a protocol.\n  If $\\mptys{p}{\\vec{\\alpha}}{\\tau}$, then it is an invariant of $p$ that an intermediate process is either inert (made up only of $\\done$s and parallel compositions) or can take a step.\n\\end{theorem}\n\\begin{proof}\n  By invariant induction, after strengthening the invariant to say that any intermediate process $p'$ satisfies $\\mptys{p'}{\\vec{\\alpha}}{\\tau'}$ for some $\\tau'$.\n  The inductive case uses Lemma \\ref{forever_done} to rule out steps by finished protocols, and it uses Lemma \\ref{comm_stuck} to rule out cases that are impossible because parties that are scheduled to go next are not present in $\\vec{\\alpha}$.\n  Interesting cases are where we find that one of the active parties is at the head of $\\vec{\\alpha}$.\n  That party either sends or receives.\n  In the first case, we appeal to Lemma \\ref{find_sender} to find a receiver among the remaining parties.\n  In the second case, we appeal to an analogous lemma (not stated here) to find a sender.\n\n  The other crucial case of the proof is showing that existence of a multiparty typing implies that, if a process is not inert, it can take a step.\n  The reasoning is quite similar to in the inductive case, but where instead of showing that any possible step preserves typing, we demonstrate that a particular step exists.\n  The head of the session type telegraphs what step it is: for the communication at the head of the type, the assigned sending party sends to the assigned receiving party.\n\\end{proof}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\appendix\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{\\label{coqref}The Coq Proof Assistant}\n\nCoq\\index{Coq} is a proof-assistant software package developed as open source, primarily by Inria\\index{Inria}, the French national computer-science lab.\n\n\\section{Installation and Basic Use}\n\nThe project home page is:\n\\begin{center}\n  \\url{https://coq.inria.fr/}\n\\end{center}\nThe code associated with this book is designed to work with Coq versions 8.9 and higher.\nThe project Web site makes a number of versions available, and versions are also available in popular OS package distributions, along with binaries for platforms where open-source package systems are less common.\nWe assume that readers have installed Coq by one of those means or another.\nIt will also be almost essential to use some graphical interface for Coq editing.\nThe author prefers Proof General\\index{Proof General}, an Emacs\\index{Emacs} mode:\n\\begin{center}\n  \\url{http://proofgeneral.inf.ed.ac.uk/}\n\\end{center}\nIt should be possible to follow along using CoqIDE\\index{CoqIDE}, a standalone tool distributed with Coq itself, but we will not give any CoqIDE-specific instructions.\n\nThe Proof General instructions are simple: after installing, within a regular Emacs session, open a file with the Coq extension \\texttt{.v}.\nMove the point (cursor) to a position where you would like to examine the current state of a proof, etc.\nThen press C-C C-RET (``control-C, control-enter'') to run Coq up to that point.\nSeveral display panes will open, showing different aspects of Coq's state, any error messages it wants to report, etc.\nThis feature is the main workhorse of Proof General.\nIt can be used both to move \\emph{forward}, checking that Coq accepts a command; and to move \\emph{backward}, to undo commands processed previously.\n\nProof General has plenty of other bells and whistles, but we won't go into them here.\n\n\\section{Tactic Reference}\n\n\\emph{Tactics} are the commands run in Coq to advance the state of a proof, corresponding to deduction steps at different granularities.\nHere we collect all of the short explanations of tactics that appear in Coq source files associated with the chapters included in this document.\nNote that many of these are specific to the \\texttt{Frap} library distributed with this book, where built-in tactics often do quite similar things, but in a way that the author judges to be more of a hassle for beginners.\n\n\\begin{description}\n  \\item[\\texttt{apply} $H$] For $H$ a hypothesis or previously proved theorem, establishing some fact that matches the structure of the current conclusion, switch to proving $H$'s own hypotheses.  This is \\emph{backwards reasoning} via a known fact.\n  \\item[\\texttt{apply} $H$ \\texttt{with} \\texttt{(}$x_1$\\texttt{ := }$e_1$\\texttt{) ... (}$x_n$\\texttt{ := }$e_n$\\texttt{)}] Like the last one, supplying values for quantified variables in $H$'s statement, especially for those variables whose values aren't immediately implied by the current goal.\n  \\item[\\texttt{apply} $H_1$ \\texttt{in} $H_2$] Like \\texttt{apply} $H_1$, but used in a \\emph{forward} direction rather than \\emph{backward}.  For instance, if $H_1$ proves $P \\Rightarrow Q$ and $H_2$ proves $P$, then the effect is to change $H_2$ to $Q$.\n  \\item[\\texttt{assert} $P$] First prove proposition $P$, then continue with it as a new hypothesis.\n  \\item[\\texttt{assumption}] Prove a conclusion that matches a hypothesis exactly.\n  \\item[\\texttt{cases} $e$] Break the proof into one case for each constructor that might have been used to build the value of expression $e$.  In the special case where $e$ essentially has a Boolean type, we consider whether $e$ is true or false.\n  \\item[\\texttt{constructor}] When proving an instance of an inductive predicate, \\texttt{apply} the first matching rule of that predicate.\n  \\item[\\texttt{eapply} $H$] Like \\texttt{apply} but will work even when some quantified variables from $H$ do not have their values determined immediately by the form of the goal.  Instead, \\emph{existential variables} (with names starting with question marks) are introduced for those values.\n  \\item[\\texttt{eassumption}] Like \\texttt{assumption} but will figure out values of existential variables.\n  \\item[\\texttt{econstructor}] When proving an instance of an inductive predicate, \\texttt{eapply} the first matching rule of that predicate.\n  \\item[\\texttt{eexists}] To prove $\\exists x. \\; P(x)$, switch to proving $P(?y)$, for a new existential variable $?y$.\n  \\item[\\texttt{equality}] A complete decision procedure for the theory of equality and uninterpreted functions.  That is, the goal must follow from only reflexivity, symmetry, transitivity, and congruence of equality, including that functions really do behave as functions.  See Section \\ref{decidable}.\n  \\item[\\texttt{exfalso}] From any proof state, switch to proving \\texttt{False}.  In other words, indicate a switch to a proof by contradiction.\n  \\item[\\texttt{exists} $e$] Prove $\\exists x. \\; P(x)$ by proving $P(e)$.\n  \\item[\\texttt{first\\_order}] Simplify a goal into zero or more new goals, based on the rules of first-order logic alone.  \\emph{Warning:} this tactic is especially likely to run forever, on complex enough goals!  (While entailment for propositional logic is decidable, entailment for first-order logic isn't.)\n  \\item[\\texttt{f\\_equal}] When the goal is an equality between two applications of the same function, switch to proving that the function arguments are pairwise equal.\n  \\item[\\texttt{induct} $x$] Where $x$ is a variable in the theorem statement, structure the proof by induction on the structure of $x$.  You will get one generated subgoal per constructor in the inductive definition of $x$.  (Indeed, it is required that $x$'s type was introduced with \\texttt{Inductive}.)\n  \\item[\\texttt{invert} $H$] Replace hypothesis $H$ with other facts that can be deduced from the structure of $H$'s statement.  More detail to be added here soon!\n  \\item[\\texttt{linear\\_arithmetic}] A complete decision procedure for linear arithmetic.  Relevant formulas are essentially those built up from variables and constant natural numbers and integers using only addition and subtraction, with equality and inequality comparisons on top.  (Multiplication by constants is supported, as a shorthand for repeated addition.) See Section \\ref{decidable}.  Also note that this tactic goes a bit beyond that theory, by (1) converting multivariable terms into a standard polynomial form and then (2) treating each different product of powers of variables as one variable in a linear-arithmetic problem.  So, for instance, \\texttt{linear\\_arithmetic} can prove $x \\times y = y \\times x$ simply by deciding that a new variable $z = x \\times y$, rewriting the goal to $z = z$ after putting polynomials in canonical form (in this case, commuting argument order in products to make it consistent).\n  \\item[\\texttt{left}] Prove a disjunction by proving its left side.\n  \\item[\\texttt{maps\\_equal}] Prove that two finite maps are equal by considering all the relevant cases for mappings of different keys.\n  \\item[\\texttt{propositional}] Simplify a goal into zero or more new goals, based on the rules of propositional logic alone.\n  \\item[\\texttt{replace} $e_1$ \\texttt{with} $e_2$ \\texttt{by} \\texttt{tac}] Replace occurrences of $e_1$ with $e_2$, proving $e_2 = e_1$ with tactic \\texttt{tac}.\n  \\item[\\texttt{rewrite} $H$] Where $H$ is a hypothesis or previously proved theorem, establishing \\texttt{forall x1 .. xN, e1 = e2}, find a subterm of the goal that equals \\texttt{e1}, given the right choices of \\texttt{xi} values, and replace that subterm with \\texttt{e2}.\n  \\item[\\texttt{rewrite} $H_1$ \\texttt{in} $H_2$] Like \\texttt{rewrite} $H_1$ but performs the rewrite in hypothesis $H_2$ instead of in the conclusion.\n  \\item[\\texttt{right}] Prove a disjunction by proving its right side.\n  \\item[\\texttt{ring}] Prove goals that are equalities over some registered ring or semiring, in the sense of algebra, where the goal follows solely from the axioms of that algebraic structure.  See Section \\ref{decidable}.\n  \\item[\\texttt{simplify}] Simplify throughout the goal, applying the definitions of recursive functions directly.  That is, when a subterm matches one of the \\texttt{match} cases in a defining \\texttt{Fixpoint}, replace with the body of that case, then repeat.\n  \\item[\\texttt{subst}] Remove all hypotheses like $x = e$ for variables $x$, simply replacing all uses of $x$ by $e$.\n  \\item[\\texttt{symmetry}] When proving $X = Y$, switch to proving $Y = X$.\n  \\item[\\texttt{transitivity} $X$] When proving $Y = Z$, switch to proving $Y = X$ and $X = Z$.\n  \\item[\\texttt{trivial}] Coq maintains a database of simple proof steps, such as proving a fact by direct appeal to a matching hypothesis.  \\texttt{trivial} asks to try all such simple steps.\n  \\item[\\texttt{unfold} $X$] Replace $X$ by its definition.\n  \\item[\\texttt{unfold} $X$ \\texttt{in} \\texttt{*}] Like the last one, but unfolds in hypotheses as well as conclusion.\n\\end{description}\n\n\\section{Further Reading}\n\nFor more Coq information, we recommend a few books (beyond the Coq reference manual).  Some focus purely on introducing Coq:\n\n\\begin{itemize}\n  \\item Adam Chlipala, \\emph{Certified Programming with Dependent Types}, MIT Press, \\url{http://adam.chlipala.net/cpdt/}\n  \\item Yves Bertot and Pierre Cast\\'eran, \\emph{Interactive Theorem Proving and Program Development: Coq'Art: The Calculus of Inductive Constructions}, Springer, \\url{https://www.labri.fr/perso/casteran/CoqArt/}\n\\end{itemize}\n\nThe first of these two, especially, goes in-depth on the automated proof-scripting principles showcased from time to time in the Coq example code associated with the present book.\n\nThere are also other sources that introduce program-reasoning principles at the same time, including:\n\n\\begin{itemize}\n  \\item Benjamin C. Pierce et al., \\emph{Software Foundations}, \\url{http://www.cis.upenn.edu/~bcpierce/sf/}\n\\end{itemize}\n\n\\emph{Software Foundations} generally proceeds at a slower pace than this book does.\n\n\\backmatter\n%    Bibliography styles amsplain or harvard are also acceptable.\n%% \\bibliographystyle{amsalpha}\n%% \\bibliography{}\n%    See note above about multiple indexes.\n\\printindex\n\n\\end{document}\n", "meta": {"hexsha": "ef3719d7b4df20ded94d9c19d9b7631cf7b3c16d", "size": 351066, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "frap_book.tex", "max_stars_repo_name": "bkushigian/frap", "max_stars_repo_head_hexsha": "22f3238a8a12acd8e35bf3a238adbd4e18c714cc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "frap_book.tex", "max_issues_repo_name": "bkushigian/frap", "max_issues_repo_head_hexsha": "22f3238a8a12acd8e35bf3a238adbd4e18c714cc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "frap_book.tex", "max_forks_repo_name": "bkushigian/frap", "max_forks_repo_head_hexsha": "22f3238a8a12acd8e35bf3a238adbd4e18c714cc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.209578682, "max_line_length": 929, "alphanum_fraction": 0.7168851441, "num_tokens": 100788, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4426749614284246}}
{"text": "\\documentclass{beamer}\n\n\\mode<presentation>\n{\n  \\usetheme{Hawke}\n  % or ...\n\n  \\setbeamercovered{transparent}\n  % or whatever (possibly just delete it)\n}\n\n\n\\usepackage[english]{babel}\n\\usepackage[latin1]{inputenc}\n\\usepackage{times}\n\\usepackage[T1]{fontenc}\n\\usepackage{multimedia}\n\n\n%%%%%%\n% My Commands\n%%%%%%\n\n\\newcommand{\\bb}{{\\boldsymbol{b}}}\n\\newcommand{\\bx}{{\\boldsymbol{x}}}\n\\newcommand{\\by}{{\\boldsymbol{y}}}\n\\newcommand{\\bfm}[1]{{\\boldsymbol{#1}}}\n\\newcommand{\\pda}[2]{\\frac{\\partial{#1}}{\\partial{#2}}}\n\n\n%%%%\n\n\\title[Lecture 22] % (optional, use only with long paper titles)\n{Lecture 22 - Finite difference methods for Boundary Value Problems}\n\n\\author[I. Hawke] % (optional, use only with lots of authors)\n{I.~Hawke}\n\n\\institute[University of Southampton] % (optional, but mostly needed)\n{\n%  \\inst{1}%\n  School of Mathematics, \\\\\n  University of Southampton, UK\n}\n\n\\date[Semester 1] % (optional, should be abbreviation of conference name)\n{MATH3018/6141, Semester 1}\n\n\\subject{Numerical methods}\n\n\\pgfdeclareimage[height=0.5cm]{university-logo}{mathematics_7469}\n\\logo{\\pgfuseimage{university-logo}}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>\n    \\frametitle{Outline}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\section{Finite difference methods}\n\n\\subsection{Background}\n\n\\begin{frame}\n  \\frametitle{Boundary Value Problems}\n\n  Considering simple boundary value problem\n  \\begin{equation*}\n    y'' = f(x, y, y'), \\quad y(a) = A, \\,\\, y(b) = B, \\quad x \\in [a,b].\n  \\end{equation*} \\pause\n  Boundary conditions are only examples here. \\pause\n\n  \\vspace{1ex}\n\n  Standard approach: first try \\emph{shooting} method.  Convert BVP to\n  IVP with some initial data free. Free data then modified, using root\n  finding, to satisfy boundary conditions. \\pause\n\n  \\vspace{1ex}\n\n  Shooting is straightforward and efficient -- when it\n  works. Otherwise use \\emph{relaxation} methods based on \\emph{finite\n    differences}.\n\n\\end{frame}\n\n\n\\subsection{Finite differences for linear problems}\n\n\\begin{frame}\n  \\frametitle{The linear problem}\n\n  Consider the linear problem\n  \\begin{equation*}\n    y'' + p(x) y' + q(x) y =  f(x), \\quad y(a) = A, \\,\\, y(b) = B,\n    \\quad x \\in [a,b].\n  \\end{equation*} \\pause\n  %\n  Introduce a \\emph{grid}, evenly spaced over the interval,\n  %\n  \\begin{equation*}\n    x_i = a + i h, \\quad i = 0, 1, \\dots, n + 1, \\quad h = \\frac{b -\n      a}{n + 1}.\n  \\end{equation*}\n  %\n  Contains $n$ \\emph{interior} points and 2 boundary points.\n  \\pause The value of $y$ at the boundary points given by\n  boundary conditions,\n  %\n  \\begin{align*}\n    y_0 & = y(a) = A, \\\\\n    y_{n+1} & = y(b) = B.\n  \\end{align*} \\pause\n  %\n  Value of $y$ at interior points unknown; these\n  give approximate solution. Require approximation to converge to\n  true solution as $h \\rightarrow 0$.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Finite differences}\n\n  Given grid $\\{x_j\\}$, approximate derivatives using standard finite\n  difference formulas. \\pause Typically use centred differencing\n  formulas\n  \\begin{align*}\n    y' (x_i) & = \\frac{y_{i+1} - y_{i-1}}{2 h} + {\\cal O} (h^2), \\\\\n    y'' (x_i) & = \\frac{y_{i+1} + y_{i-1} - 2 y_i}{h^2} + {\\cal O} (h^2),\n  \\end{align*}\n  which are second order accurate. \\pause\n\n  \\vspace{1ex}\n\n  Substituting into BVP equation\n  \\begin{equation*}\n    y'' + p(x) y' + q(x) y =  f(x), \\quad y(a) = A, \\,\\, y(b) = B,\n    \\quad x \\in [a,b]\n  \\end{equation*}\n  for \\emph{interior} points gives finite difference formula ($q_i =\n  q(x_i)$ etc.)\n  \\begin{equation*}\n    y_{i-1} \\left( 1 - \\tfrac{h}{2} p_i \\right) +  y_{i} \\left( h^2\n      q_i - 2 \\right) + y_{i+1} \\left( 1 + \\tfrac{h}{2} p_i \\right) =\n    h^2 f_i.\n  \\end{equation*}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Constructing the linear system}\n\n  Have a system of ($n+2$) linear algebraic equations\n  \\begin{align*}\n    y_0 & = A, \\\\\n    y_{i-1} \\left( 1 - \\tfrac{h}{2} p_i \\right) +  y_{i} \\left( h^2\n      q_i - 2 \\right) + y_{i+1} \\left( 1 + \\tfrac{h}{2} p_i \\right) & =\n    h^2 f_i, \\quad 1 \\le i \\le n \\\\\n    y_{n+1} & = B.\n  \\end{align*} \\pause\n  This is a linear system. Can simplify using the boundary conditions\n  to eliminate $y_0, y_{n+1}$ everywhere.\n\n  \\vspace{1ex}\n\n  \\begin{overlayarea}{\\textwidth}{0.4\\textheight}\n    \\only<3|handout:1>\n    {\n      Take $n=3$ for example. In the interior\n      {\\small\n        \\begin{equation*}\n          \\begin{pmatrix}\n            \\dots & \\dots & \\dots \\\\\n            1 - \\tfrac{h}{2} p_2 & -2 + h^2 q_2 & 1 + \\tfrac{h}{2} p_2 \\\\\n            \\dots & \\dots & \\dots\n          \\end{pmatrix}\n          \\begin{pmatrix}\n            y_1 \\\\ y_2 \\\\ y_3\n          \\end{pmatrix} =\n          \\begin{pmatrix}\n            \\dots \\\\ h^2 f_2 \\\\ \\dots\n          \\end{pmatrix}.\n        \\end{equation*}\n      }\n    }\n    \\only<4|handout:2>\n    {\n      Using boundary conditions replace $y_0, y_{n+1}$.  Full system\n      is\n      {\\small\n        \\begin{equation*}\n          \\begin{pmatrix}\n            -2 + h^2 q_1 & 1 + \\tfrac{h}{2} p_1 & 0 \\\\\n            1 - \\tfrac{h}{2} p_2 & -2 + h^2 q_2 & 1 + \\tfrac{h}{2} p_2 \\\\\n            0 & 1 - \\tfrac{h}{2} p_3 & -2 + h^2 q_3\n          \\end{pmatrix}\n          \\begin{pmatrix}\n            y_1 \\\\ y_2 \\\\ y_3\n          \\end{pmatrix} =\n          \\begin{pmatrix}\n            h^2 f_1 - A ( 1 - \\tfrac{h}{2} p_1 ) \\\\ h^2 f_2\n            \\\\ h^2 f_3 - B ( 1 + \\tfrac{h}{2} p_3 )\n          \\end{pmatrix}.\n        \\end{equation*}\n      }\n    }\n  \\end{overlayarea}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Points about the linear system}\n\n  Important point: provided central differencing is used, the matrix\n  is \\emph{tridiagonal}.  Very efficient algorithms for solving the\n  linear system. \\pause\n\n  \\vspace{1ex}\n\n  Also note that here the matrix $T$ is not modified by the boundary\n  conditions.  Always true for Dirichlet type conditions which fix\n  $y(a)$.  Not true for Neumann type conditions which fix $y'(a)$,\n  for example.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example}\n\n  For the problem\n  \\begin{equation*}\n    y'' + y' + 1 = 0, \\quad y(0) = 0, \\,\\, y(1) = 1, \\quad x \\in [0, 1]\n  \\end{equation*}\n  we have $p(x) = 1$, $q(x) = 0$, $f(x) = -1$. \\pause  Look at grid\n  with 3 points ($n = 1, h = 1/2$). \\pause Gives the equations\n  \\begin{align*}\n    y_0 & = 0, \\\\\n    y_0 \\left( 1 - \\tfrac{h}{2} \\cdot 1 \\right) + y_1 \\left( h^2 \\cdot\n      0 - 2 \\right) + y_2 \\left( 1 + \\tfrac{h}{2} \\cdot 1 \\right) & =\n    h^2 \\cdot (-1), \\\\\n    y_2 & = 1.\n  \\end{align*} \\pause\n  %\n  Boundary points $y_0, y_2$ given by boundary conditions and are\n  exact. \\pause Central point $y_1$ has value\n  \\begin{equation*}\n    y_1 = \\tfrac{3}{4}; \\quad y_e(x = 1/2) = 0.74492.\n  \\end{equation*}\n  Good accuracy for such a coarse grid, as $y_e(x)$ close to linear.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example: 2}\n\n  \\begin{columns}\n    \\begin{column}{0.4\\textwidth}\n      The problem\n      \\begin{align*}\n        y'' + y' + 1 &= 0, \\\\ y(0) &= 0, \\\\ y(1) &= 1, \\\\ x &\\in [0, 1]\n      \\end{align*}\n      solved with finite differences is impressively accurate. \\pause\n\n      \\vspace{1ex}\n\n      Increase $n$ the result converges \\pause well. \\pause\n\n      \\vspace{1ex}\n\n      The convergence is second order in $h$.\n    \\end{column}\n    \\begin{column}{0.6\\textwidth}\n      \\begin{center}\n        \\includegraphics<1|handout:1>[width=\\textwidth]{figures/FDBVP1}\n        \\includegraphics<2|handout:0>[width=\\textwidth]{figures/FDBVP2}\n        \\includegraphics<3|handout:0>[width=\\textwidth]{figures/FDBVP3}\n        \\includegraphics<4|handout:2>[width=\\textwidth]{figures/FDBVPDirichletConvergence1}\n      \\end{center}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\subsection{Boundary conditions}\n\n\\begin{frame}\n  \\frametitle{Boundary conditions}\n\n  When constructing the linear system\n  \\begin{equation*}\n    T \\by = \\bfm{F}\n  \\end{equation*}\n  using Dirichlet type boundary conditions, could give value of $y_0,\n  y_{n+1}$ everywhere; this only modified $\\bfm{F}$.\n\n  \\vspace{1ex}\n\n  \\begin{overlayarea}{\\textwidth}{0.6\\textheight}\n    \\only<2-5|handout:1>\n    {\n      If instead have Neumann type boundary conditions, e.g.\\\n      $y'(b) = \\alpha$, the situation changes.\n    }\n    \\only<3-5|handout:1>\n    {\n      First need finite difference approximation of\n      \\emph{boundary condition itself}.\n    }\n    \\only<4-5|handout:1>\n    {\n      For example could use first order differencing:\n      \\begin{equation*}\n        \\frac{y_{n+1} - y_n}{h} = \\alpha.\n      \\end{equation*}\n    }\n    \\only<5|handout:1>\n    {\n      Then rearrange to find condition on boundary point $y_{n+1}$:\n      \\begin{equation*}\n        y_{n+1} = y_n + h \\alpha.\n      \\end{equation*}\n    }\n    \\only<6|handout:0>\n    {\n      \\begin{equation*}\n        y'(b) = \\alpha \\rightarrow y_{n+1} = y_n + h \\alpha.\n      \\end{equation*}\n      \\vspace{1ex}\n      Note that\n      \\begin{enumerate}\n      \\item The value of $y_{n+1}$ is now \\emph{not exact} as we\n        specify it by finite differences.\n      \\end{enumerate}\n    }\n    \\only<7|handout:2>\n    {\n      \\begin{equation*}\n        y'(b) = \\alpha \\rightarrow y_{n+1} = y_n + h \\alpha.\n      \\end{equation*}\n      \\vspace{1ex}\n      Note that\n      \\begin{enumerate}\n      \\item The value of $y_{n+1}$ is now \\emph{not exact} as we\n        specify it by finite differences.\n      \\item Use condition on $y_{n+1}$ to construct the linear system,\n        giving new terms including $y_n$; hence matrix $T$ is modified\n        as well as $\\bfm{F}$.\n      \\end{enumerate}\n    }\n  \\end{overlayarea}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Example}\n\n  For the problem\n  \\begin{equation*}\n    y'' + y' + 1 = 0, \\quad y(0) = 0, \\,\\, y'(1) = \\tfrac{3 - e}{e -\n      1}, \\quad x \\in [0, 1]\n  \\end{equation*}\n  have same solution as before. \\pause Look at grid with 3 points ($n\n  = 1, h = 1/2$). \\pause Gives equations (two match Dirichlet case)\n  \\begin{align*}\n    y_0 & = 0, \\\\\n    y_0 \\left( 1 - \\tfrac{h}{2} \\cdot 1 \\right) + y_1 \\left( h^2 \\cdot\n      0 - 2 \\right) + y_2 \\left( 1 + \\tfrac{h}{2} \\cdot 1 \\right) & =\n    h^2 \\cdot (-1), \\\\\n    y_2 & = y_1 + h \\tfrac{3 - e}{e - 1}.\n  \\end{align*}  \\pause\n  %\n  Substituting in expressions for $y_0, y_2$, find central\n  point $y_1$ has value\n  \\begin{align*}\n&&    y_1 & = \\tfrac{1}{3} + \\tfrac{5 \\alpha}{6} = 0.470; &  y_e(x =\n    1/2) &= 0.74492. \\\\\n\\Rightarrow && y_2 &= 0.470 + h \\alpha = 0.552; & y_e(x =\n    1) &= 1.\n  \\end{align*}\n  This result is much worse than the Dirichlet case.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Example: 2}\n\n  \\begin{columns}\n    \\begin{column}{0.4\\textwidth}\n      The approximate solution to\n      \\begin{align*}\n        y'' + y' + 1 &= 0, \\\\ y(0) &= 0, \\\\ y'(1) &= \\tfrac{3 - e}{e -\n      1}, \\\\ x &\\in [0, 1]\n      \\end{align*}\n      is not as good as Dirichlet case. \\pause \\vspace{1ex}\n\n      Increasing $n$ the result converges \\pause eventually. \\pause\n      \\vspace{1ex}\n\n       Convergence only first order in $h$.\n    \\end{column}\n    \\begin{column}{0.6\\textwidth}\n      \\begin{center}\n        \\includegraphics<1|handout:1>[width=\\textwidth]{figures/FDBVPNeumann1}\n        \\includegraphics<2|handout:0>[width=\\textwidth]{figures/FDBVPNeumann2}\n        \\includegraphics<3|handout:0>[width=\\textwidth]{figures/FDBVPNeumann3}\n        \\includegraphics<4|handout:2>[width=\\textwidth]{figures/FDBVPNeumannConvergence1}\n      \\end{center}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Example: 3}\n\n  \\begin{columns}\n    \\begin{column}{0.4\\textwidth}\n      Take same problem\n      \\begin{align*}\n        y'' + y' + 1 &= 0, \\\\ y(0) &= 0, \\\\ y'(1) &= \\tfrac{3 - e}{e -\n      1}, \\\\ x &\\in [0, 1]\n      \\end{align*}\n      using second order approximation to derivative in\n      boundary condition gives better results.\\pause\n\n      \\vspace{1ex}\n\n      Increasing $n$ the result converges \\pause faster. \\pause\n\n      \\vspace{1ex}\n\n      Convergence is second order in $h$.\n    \\end{column}\n    \\begin{column}{0.6\\textwidth}\n      \\begin{center}\n        \\includegraphics<1|handout:1>[width=\\textwidth]{figures/FDBVPNeumann2_1}\n        \\includegraphics<2|handout:0>[width=\\textwidth]{figures/FDBVPNeumann2_2}\n        \\includegraphics<3|handout:0>[width=\\textwidth]{figures/FDBVPNeumann2_3}\n        \\includegraphics<4|handout:2>[width=\\textwidth]{figures/FDBVPNeumann2Convergence1}\n      \\end{center}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\subsection{Error analysis}\n\n\\begin{frame}\n  \\frametitle{Error analysis}\n\n  Central differencing methods normally converge at second order.\n  Examples above suggest second order convergence for the BVP. \\pause\n\n  \\vspace{1ex}\n\n  Define error vector $\\bfm{e}$ and look at linear system $T\n  \\bfm{e}$:\n  \\begin{align*}\n    \\left( y(x_{i-1}) - y_{i-1} \\right)& \\left( 1 - \\tfrac{h}{2} p_i\n    \\right) - \\\\\n    \\left( y(x_{i}) - y_{i} \\right) & \\left( 2 - h^2 q_i \\right) + \\\\\n    \\left( y(x_{i+1}) - y_{i+1} \\right) & \\left( 1 + \\tfrac{h}{2} p_i\n    \\right)\n  \\end{align*}\n  for the interior entries. \\pause\n\n  \\vspace{1ex}\n\n  Numerical terms ($y_i$ etc.) give $-h^2 f_i$. \\pause Taylor\n  expanding exact solution $y(x_i)$ gives original ODE (times $h^2$)\n  plus terms $\\propto h^4$ and higher order in $h$, as all other terms\n  cancel.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Error analysis: 2}\n\n  Hence error also satisfies a linear system\n  \\begin{equation*}\n    T \\bfm{e} = h^4 \\bfm{G}\n  \\end{equation*}\n  where $T$ is the same tridiagonal matrix that defines the method and\n  $\\bfm{G}$ is independent of $h$. \\pause\n\n  \\vspace{1ex}\n\n  Hence bound the error using\n  \\begin{align*}\n    \\| \\bfm{e} \\| & = h^4 \\| T^{-1} \\| \\cdot \\| \\bfm{G} \\| \\\\\n    & \\le h^4 G \\| T^{-1} \\|\n  \\end{align*}\n  as $\\bfm{G}$ is a constant vector. \\pause As $T$ is a matrix of size\n  $n \\propto h^{-1}$ the best bound is\n  \\begin{equation*}\n     \\| T^{-1} \\| \\le K n^2 \\quad \\implies \\quad\n    \\| \\bfm{e} \\| \\le \\alpha h^2, \\quad \\alpha \\text{ const.}\n  \\end{equation*}\n\n\\end{frame}\n\n\\section{Summary}\n\n\\subsection{Summary}\n\n\\begin{frame}\n  \\frametitle{Summary}\n\n  \\begin{itemize}\n  \\item First shoot, then relax.\n  \\item Finite difference methods are typically less accurate and\n    efficient, and for nonlinear problems are more complex to\n    implement. However, they are much more likely to work in complex\n    cases.\n  \\item For linear problems finite difference methods convert the ODE\n    to a linear system $T \\by = \\bfm{F}$.\n    \\begin{itemize}\n    \\item The matrix will be tri-diagonal (when using centred\n      differencing).\n    \\item The boundary conditions are normally directly encoded in the\n      known vector $\\bb$ (but more complex boundary conditions may\n      require modification of $A$ as well).\n    \\end{itemize}\n  \\end{itemize}\n\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "0e8cff2f5fd8bc1f908522973296d04cc0c4fd72", "size": 14791, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lectures/tex/Lecture22_BVP2.tex", "max_stars_repo_name": "josh-gree/NumericalMethods", "max_stars_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 76, "max_stars_repo_stars_event_min_datetime": "2015-02-12T19:51:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T15:34:11.000Z", "max_issues_repo_path": "Lectures/tex/Lecture22_BVP2.tex", "max_issues_repo_name": "josh-gree/NumericalMethods", "max_issues_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2017-05-24T19:49:52.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-23T21:40:42.000Z", "max_forks_repo_path": "Lectures/tex/Lecture22_BVP2.tex", "max_forks_repo_name": "josh-gree/NumericalMethods", "max_forks_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2015-01-05T13:30:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-15T09:59:39.000Z", "avg_line_length": 27.2394106814, "max_line_length": 91, "alphanum_fraction": 0.6057061727, "num_tokens": 5209, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.4426749614284246}}
{"text": "\\documentclass[12pt]{article}\n\n\\newcommand{\\m}[1]{{\\bf{#1}}}       % for matrices and vectors\n\\newcommand{\\tr}{^{\\sf T}}          % transpose\n\n\\topmargin 0in\n\\textheight 9in\n\\oddsidemargin 0pt\n\\evensidemargin 0pt\n\\textwidth 6.5in\n\n%-------------------------------------------------------------------------------\n\\begin{document}\n%-------------------------------------------------------------------------------\n\n\\title{User Guide for LDL, a concise sparse Cholesky package}\n\\author{Timothy A. Davis\\thanks{\nemail: DrTimothyAldenDavis@gmail.com,\nhttp://www.suitesparse.com.\nThis work was supported by the National\nScience Foundation, under grant CCR-0203270.\nPortions of the work were done while on sabbatical at Stanford University\nand Lawrence Berkeley National Laboratory (with funding from Stanford\nUniversity and the SciDAC program).\n}}\n\n\\date{VERSION 2.2.1, Oct 10, 2014}\n\n\\maketitle\n\n%-------------------------------------------------------------------------------\n\\begin{abstract}\nThe {\\tt LDL} software package is a set of short, concise routines for\nfactorizing symmetric positive-definite sparse matrices, with some\napplicability to symmetric indefinite matrices.  Its primary purpose is\nto illustrate much of the basic theory of sparse matrix algorithms in as\nconcise a code as possible, including an elegant method\nof sparse symmetric factorization that computes the factorization row-by-row\nbut stores it column-by-column.  The entire symbolic and numeric factorization\nconsists of less than 50 lines of code.  The package is written in C,\nand includes a MATLAB interface.\n\\end{abstract}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\section{Overview}\n%-------------------------------------------------------------------------------\n\n{\\tt LDL} is a set of short, concise routines that compute the $\\m{LDL}\\tr$\nfactorization of a sparse symmetric matrix $\\m{A}$.  Its primary purpose is\nto illustrate much of the basic theory of sparse matrix algorithms in as\ncompact a code as possible, including an elegant method of\nsparse symmetric factorization (related to \\cite{Liu86c,Liu91}).\nThe lower triangular factor $\\m{L}$ is computed row-by-row, in contrast to the\nconventional column-by-column method.\nAlthough it does not achieve the same level of performance\nas methods based on dense matrix kernels\n(such as \\cite{NgPeyton93,RothbergGupta91}),\nits performance is competitive with column-by-column methods that do not\nuse dense kernels \\cite{GeorgeLiu79, GeorgeLiu, GilbertMolerSchreiber}.\n\nSection~\\ref{Algorithm} gives a brief description of the algorithm\nused in the symbolic and numeric factorization.  A more detailed tutorial-level\ndiscussion may be found in \\cite{Stewart03}.  Details\nof the concise implementation of this method are given in\nSection~\\ref{Implementation}.  Sections~\\ref{MATLAB}~and~\\ref{C} give an\noverview of how to use the package in MATLAB and in a stand-alone C program.\n\n%-------------------------------------------------------------------------------\n\\section{Algorithm}\n\\label{Algorithm}\n%-------------------------------------------------------------------------------\n\nThe underlying numerical algorithm is described below.  The $k$th\nstep solves a lower triangular system of dimension $k-1$ to compute the\n$k$th row of $\\m{L}$ and the $d_{kk}$ entry of the diagonal matrix $\\m{D}$.\nColon notation is used for submatrices.  For example,\n$\\m{L}_{k,1:k-1}$ refers to the first $k-1$ columns of\nthe $k$th row of $\\m{L}$.  Similarly, $\\m{L}_{1:k-1,1:k-1}$ refers to\nthe leading $(k-1)$-by-$(k-1)$ submatrix of $\\m{L}$.\n%---------------\n\\vspace{-0.2in}\n\\begin{tabbing}\n\\hspace{2em} \\= \\hspace{2em} \\= \\hspace{2em} \\= \\\\\n{\\bf Algorithm~1\n($\\m{LDL}\\tr$ factorization of a $n$-by-$n$ symmetric matrix $\\m{A}$)} \\\\\n\\> {\\bf for} $k = 1$ {\\bf to} $n$ \\\\\n\\>\\> (step 1) Solve $\\m{L}_{1:k-1,1:k-1}\\m{y} = \\m{A}_{1:k-1,k}$ for $\\m{y}$ \\\\\n\\>\\> (step 2) $\\m{L}_{k,1:k-1} = (\\m{D}_{1:k-1,1:k-1}^{-1} \\m{y})\\tr$ \\\\\n\\>\\> (step 3) $l_{kk} = 1$ \\\\\n\\>\\> (step 4) $d_{kk} = a_{kk} - \\m{L}_{k,1:k-1}\\m{y}$ \\\\\n\\> {\\bf end for}\n\\end{tabbing}\n%---------------\n\nThe algorithm computes an $\\m{LDL}\\tr$ factorization without numerical pivoting.\nIt can thus factorize any symmetric positive definite matrix, and any\nsymmetric indefinite matrix whose leading minors are all well-conditioned.\n\nWhen $\\m{A}$ and $\\m{L}$ are sparse, step 1 of Algorithm~1 requires a\ntriangular solve of the form $\\m{Lx}=\\m{b}$, where all three terms in\nthe equation are sparse.  This is the most costly step of the Algorithm.\nSteps 2 through 4 are fairly straightforward.\n\nLet ${\\cal X}$ and ${\\cal B}$ refer to the set of indices of nonzero entries\nin $\\m{x}$ and $\\m{b}$, respectively, in the lower triangular system\n$\\m{Lx}=\\m{b}$.  To compute $\\m{x}$ efficiently\nthe nonzero pattern ${\\cal X}$ must be found first.\nIn the general case when $\\m{L}$ is arbitrary \\cite{GilbertPeierls88},\nthe nonzero\npattern ${\\cal X}$ is the set of nodes reachable via paths in the graph $G_L$\nfrom all nodes in the set ${\\cal B}$, and where the graph $G_L$ has\n$n$ nodes and a directed edge $(j,i)$ if and only if $l_{ij}$ is nonzero.\nTo compute the numerical solution to $\\m{Lx}=\\m{b}$ by accessing the columns of\n$\\m{L}$ one at a time, ${\\cal X}$ can be traversed\nin any topological order of the subgraph of $G_L$ consisting of nodes in\n${\\cal X}$.  That is, $x_j$ must be computed before $x_i$ if there is a path\nfrom $j$ to $i$ in $G_L$.  The natural order ($1, 2, \\ldots, n$) is one such\nordering, but that requires a costly sort of ${\\cal X}$.\nWith a graph traversal and topological sort, the solution of $\\m{Lx}=\\m{b}$\ncan be computed using Algorithm~2 below.\nThe computation of ${\\cal X}$ and $\\m{x}$ both take\ntime proportional to the floating-point operation count.\n%---------------\n\\vspace{-0.2in}\n\\begin{tabbing}\n\\hspace{2em} \\= \\hspace{2em} \\= \\hspace{2em} \\= \\\\\n{\\bf Algorithm~2\n(Solve $\\m{Lx}=\\m{b}$, where $\\m{L}$ is lower triangular with unit diagonal)} \\\\\n\\> ${\\cal X} = \\mbox{Reach}_{G_L} ({\\cal B})$ \\\\\n\\> $\\m{x} = \\m{b}$ \\\\\n\\> {\\bf for} $i \\in {\\cal X}$ in any topological order \\\\\n\\>\\> $\\m{x}_{i+1:n} = \\m{x}_{i+1:n} - \\m{L}_{i+1:n,i} x_i$ \\\\\n\\> {\\bf end for}\n\\end{tabbing}\n%---------------\n\nThe general result also governs the pattern of $\\m{y}$ in Algorithm~1.\nHowever, in this case $\\m{L}$ arises from a sparse Cholesky factorization,\nand is governed by the elimination tree \\cite{Liu90a}.\nA general graph traversal is not required.\nIn the elimination tree, the parent of node $i$ is the smallest $j > i$\nsuch that $l_{ji}$ is nonzero.  Node $i$ has no parent if column $i$ of\n$\\m{L}$ is completely zero below the diagonal; $i$ is a root of the\nelimination tree in this case.  The nonzero pattern of $\\m{x}$ is the\nunion of all the nodes on the paths from any node $i$ (where $b_i$ is nonzero) to the\nroot of the elimination tree \\cite[Thm 2.4]{Liu86c}.  It is referred to here as a tree,\nbut in general it can be a forest.\n\nRather than a general topological sort of the subgraph of $G_L$ consisting\nnodes reachable from nodes in ${\\cal B}$, a simpler\ntree traversal can be used.  First, select any nonzero entry $b_i$\nand follow the path from $i$ to the root of tree.\nNodes along this path are marked and placed in a stack,\nwith $i$ at the top of the\nstack and the root at the bottom.\nRepeat for every other nonzero entry in $b_i$, in arbitrary order, but stop\njust before reaching a marked node (the result can be empty if $i$ is already\nin the stack).  The stack now contains ${\\cal X}$, a topological ordering of\nthe nonzero pattern of $\\m{x}$, which can be used in Algorithm~2 to solve\n$\\m{Lx}=\\m{b}$.  The time to compute ${\\cal X}$\nusing an elimination tree traversal is much faster than the general graph\ntraversal, taking time proportional to the size of ${\\cal X}$ rather than the\nnumber of floating-point operations required to compute $\\m{x}$.\n\nIn the $k$th step of the factorization, the set ${\\cal X}$ becomes the\nnonzero pattern of row $k$ of $\\m{L}$.  This step requires the elimination\ntree of $\\m{L}_{1:k-1,1:k-1}$, and must construct the elimination tree of\n$\\m{L}_{1:k,1:k}$ for step $k+1$.  Recall that the parent of $i$ in the\ntree is the smallest $j$ such that $i < j$ and $l_{ji} \\ne 0$.\nThus, if any node $i$ already has a parent $j$, then $j$ will remain the\nparent of $i$ in the elimination trees of all other larger leading submatrices\nof $\\m{L}$, and in the elimination tree of $\\m{L}$ itself.\nIf $l_{ki} \\ne 0$ and $i$ does not have a parent in the elimination tree of\n$\\m{L}_{1:k-1,1:k-1}$, then the parent of $i$ is $k$\nin the elimination tree of $\\m{L}_{1:k,1:k}$.\nNode $k$ becomes the parent of any node $i \\in {\\cal X}$ that does not yet\nhave a parent.\n\nSince Algorithm~2 traverses $\\m{L}$ in column order, $\\m{L}$ is stored in a\nconventional sparse column representation.  Each column $j$ is stored as a list\nof nonzero values and their corresponding row indices.  When row $k$ is\ncomputed, the new entries can be placed at the end of each list.  As\na by-product of computing $\\m{L}$ one row at a time,\nthe columns of $\\m{L}$ are computed in a sorted manner.  This is a convenient\nform of the output.\nMATLAB requires the columns of its sparse matrices to be sorted, for example.\nSorted columns improve the speed of Algorithm~2, since the memory access\npattern is more regular.  The conventional column-by-column algorithm\n\\cite{GeorgeLiu79,GeorgeLiu} does not produce columns of $\\m{L}$ with\nsorted row indices.\n\nA simple symbolic pre-analysis can be obtained by repeating the subtree traversals.\nAll that is required to compute the nonzero pattern of\nthe $k$th row of $\\m{L}$ is the partially constructed elimination tree\nand the nonzero pattern of the $k$th column of $\\m{A}$.  This is computed\nin time proportional to the size of this set, using the elimination tree\ntraversal.  Once constructed, the number of nonzeros in each column of\n$\\m{L}$ is incremented, for each entry in ${\\cal X}$, and then ${\\cal X}$\nis discarded.  The set ${\\cal X}$ need not be constructed in topological\norder, so no stack is required.  The run time of the symbolic analysis\nalgorithm is thus proportional to the number of nonzeros in $\\m{L}$.\nThis is more costly than the optimal algorithm \\cite{GilbertNgPeyton94},\nwhich takes time essentially proportional to the number of nonzeros in $\\m{A}$.\nThe memory requirements are just the matrix $\\m{A}$ and a few size-$n$ integer\narrays.  The result of the algorithm is the elimination tree, a count\nof the number of nonzeros in each column of $\\m{L}$, and\nthe cumulative sum of the column counts.\n\n%-------------------------------------------------------------------------------\n\\section{Implementation}\n\\label{Implementation}\n%-------------------------------------------------------------------------------\n\nBecause of its simplicity, the implementation of this algorithm leads to\na very short, concise code.  The symbolic analysis routine {\\tt ldl\\_symbolic}\nshown in Figure~\\ref{ldlsymbolic}\nconsists of only 18 lines of executable C code.\nThis includes 5 lines of code to allow for a\nsparsity-preserving ordering $\\m{P}$ so that either $\\m{A}$ or $\\m{PAP}\\tr$\ncan be analyzed, 3 lines of code to compute the cumulative sum of\nthe column counts, and one line of code to speed up a {\\tt for} loop.\nAn additional line of code allows for a more general form of the input\nsparse matrix $\\m{A}$.\n\nThe {\\tt n}-by-{\\tt n} sparse matrix $\\m{A}$ is provided in compressed column\nform as an {\\tt int} array {\\tt Ap} of length {\\tt n+1},\nan {\\tt int} array {\\tt Ai} of length {\\tt nz},\nand a {\\tt double} array {\\tt Ax} also of length {\\tt nz},\nwhere {\\tt nz} is the number of entries in the matrix.\nThe numerical values of entries in column $j$ are stored in\n{\\tt Ax[Ap[j]} $\\ldots$ {\\tt Ap[j+1]-1]}\nand the corresponding row indices are in\n{\\tt Ai[Ap[j]} $\\ldots$ {\\tt Ap[j+1]-1]}.\nWith {\\tt Ap[0] = 0}, the number of entries in the matrix is {\\tt nz = Ap[n]}.\nIf no fill-reducing ordering {\\tt P} is provided,\nonly entries in the upper triangular part of $\\m{A}$ are considered.\nIf {\\tt P} is provided and row/column {\\tt i} of the\nmatrix $\\m{A}$ is the {\\tt k}-th row/column of $\\m{PAP}\\tr$, then {\\tt P[k]=i}.\nOnly entries in the upper\ntriangular part of $\\m{PAP}\\tr$ are considered.  These entries may be\nin the lower triangular part of $\\m{A}$, so to ensure that the correct matrix\nis factorized, all entries of $\\m{A}$ should be provided when using the\npermutation input {\\tt P}.\n\nThe outputs of {\\tt ldl\\_symbolic} are three size-{\\tt n} arrays:\n{\\tt Parent} holds the elimination tree,\n{\\tt Lnz} holds the counts of the number of entries in each column of\n$\\m{L}$, and\n{\\tt Lp} holds the cumulative sum of {\\tt Lnz}.\nThe size-{\\tt n} array {\\tt Flag} is used as workspace.\nNone of the output or workspace arrays need to be initialized.\n\n\\begin{figure}\n\\caption{{\\tt ldl\\_symbolic:} finding the elimination tree and column counts}\n\\label{ldlsymbolic}\n{\\scriptsize\n\\begin{verbatim}\nvoid ldl_symbolic\n(\n    int n,              /* A and L are n-by-n, where n >= 0 */\n    int Ap [ ],         /* input of size n+1, not modified */\n    int Ai [ ],         /* input of size nz=Ap[n], not modified */\n    int Lp [ ],         /* output of size n+1, not defined on input */\n    int Parent [ ],     /* output of size n, not defined on input */\n    int Lnz [ ],        /* output of size n, not defined on input */\n    int Flag [ ],       /* workspace of size n, not defn. on input or output */\n    int P [ ],          /* optional input of size n */\n    int Pinv [ ]        /* optional output of size n (used if P is not NULL) */\n)\n{\n    int i, k, p, kk, p2 ;\n    if (P)\n    {\n        /* If P is present then compute Pinv, the inverse of P */\n        for (k = 0 ; k < n ; k++)\n        {\n            Pinv [P [k]] = k ;\n        }\n    }\n    for (k = 0 ; k < n ; k++)\n    {\n        /* L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) */\n        Parent [k] = -1 ;           /* parent of k is not yet known */\n        Flag [k] = k ;              /* mark node k as visited */\n        Lnz [k] = 0 ;               /* count of nonzeros in column k of L */\n        kk = (P) ? (P [k]) : (k) ;  /* kth original, or permuted, column */\n        p2 = Ap [kk+1] ;\n        for (p = Ap [kk] ; p < p2 ; p++)\n        {\n            /* A (i,k) is nonzero (original or permuted A) */\n            i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ;\n            if (i < k)\n            {\n                /* follow path from i to root of etree, stop at flagged node */\n                for ( ; Flag [i] != k ; i = Parent [i])\n                {\n                    /* find parent of i if not yet determined */\n                    if (Parent [i] == -1) Parent [i] = k ;\n                    Lnz [i]++ ;                         /* L (k,i) is nonzero */\n                    Flag [i] = k ;                      /* mark i as visited */\n                }\n            }\n        }\n    }\n    /* construct Lp index array from Lnz column counts */\n    Lp [0] = 0 ;\n    for (k = 0 ; k < n ; k++)\n    {\n        Lp [k+1] = Lp [k] + Lnz [k] ;\n    }\n}\n\\end{verbatim}\n}\n\\end{figure}\n\nThe {\\tt ldl\\_numeric} numeric factorization routine shown\nin Figure~\\ref{ldlnumeric} consists of only 31 lines of\nexecutable code.  It includes this same subtree traversal algorithm\nas {\\tt ldl\\_symbolic},\nexcept that each path is placed on a stack that holds\nnonzero pattern of the $k$th row of $\\m{L}$.\nThis traversal is followed by a sparse forward solve\nusing this pattern, and all of the nonzero entries in\nthe resulting $k$th row of $\\m{L}$ are appended to their respective columns\nin the data structure of $\\m{L}$.\n\n\\begin{figure}\n\\caption{{\\tt ldl\\_numeric:} numeric factorization}\n\\label{ldlnumeric}\n{\\scriptsize\n\\begin{verbatim}\nint ldl_numeric         /* returns n if successful, k if D (k,k) is zero */\n(\n    int n,              /* A and L are n-by-n, where n >= 0 */\n    int Ap [ ],         /* input of size n+1, not modified */\n    int Ai [ ],         /* input of size nz=Ap[n], not modified */\n    double Ax [ ],      /* input of size nz=Ap[n], not modified */\n    int Lp [ ],         /* input of size n+1, not modified */\n    int Parent [ ],     /* input of size n, not modified */\n    int Lnz [ ],        /* output of size n, not defn. on input */\n    int Li [ ],         /* output of size lnz=Lp[n], not defined on input */\n    double Lx [ ],      /* output of size lnz=Lp[n], not defined on input */\n    double D [ ],       /* output of size n, not defined on input */\n    double Y [ ],       /* workspace of size n, not defn. on input or output */\n    int Pattern [ ],    /* workspace of size n, not defn. on input or output */\n    int Flag [ ],       /* workspace of size n, not defn. on input or output */\n    int P [ ],          /* optional input of size n */\n    int Pinv [ ]        /* optional input of size n */\n)\n{\n    double yi, l_ki ;\n    int i, k, p, kk, p2, len, top ;\n    for (k = 0 ; k < n ; k++)\n    {\n        /* compute nonzero Pattern of kth row of L, in topological order */\n        Y [k] = 0.0 ;               /* Y(0:k) is now all zero */\n        top = n ;                   /* stack for pattern is empty */\n        Flag [k] = k ;              /* mark node k as visited */\n        Lnz [k] = 0 ;               /* count of nonzeros in column k of L */\n        kk = (P) ? (P [k]) : (k) ;  /* kth original, or permuted, column */\n        p2 = Ap [kk+1] ;\n        for (p = Ap [kk] ; p < p2 ; p++)\n        {\n            i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ;   /* get A(i,k) */\n            if (i <= k)\n            {\n                Y [i] += Ax [p] ;  /* scatter A(i,k) into Y (sum duplicates) */\n                for (len = 0 ; Flag [i] != k ; i = Parent [i])\n                {\n                    Pattern [len++] = i ;   /* L(k,i) is nonzero */\n                    Flag [i] = k ;          /* mark i as visited */\n                }\n                while (len > 0) Pattern [--top] = Pattern [--len] ;\n            }\n        }\n        /* compute numerical values kth row of L (a sparse triangular solve) */\n        D [k] = Y [k] ;             /* get D(k,k) and clear Y(k) */\n        Y [k] = 0.0 ;\n        for ( ; top < n ; top++)\n        {\n            i = Pattern [top] ;     /* Pattern [top:n-1] is pattern of L(:,k) */\n            yi = Y [i] ;            /* get and clear Y(i) */\n            Y [i] = 0.0 ;\n            p2 = Lp [i] + Lnz [i] ;\n            for (p = Lp [i] ; p < p2 ; p++)\n            {\n                Y [Li [p]] -= Lx [p] * yi ;\n            }\n            l_ki = yi / D [i] ;     /* the nonzero entry L(k,i) */\n            D [k] -= l_ki * yi ;\n            Li [p] = k ;            /* store L(k,i) in column form of L */\n            Lx [p] = l_ki ;\n            Lnz [i]++ ;             /* increment count of nonzeros in col i */\n        }\n        if (D [k] == 0.0) return (k) ;      /* failure, D(k,k) is zero */\n    }\n    return (n) ;        /* success, diagonal of D is all nonzero */\n}\n\\end{verbatim}\n}\n\\end{figure}\n\nAfter the matrix is factorized, the {\\tt ldl\\_lsolve}, {\\tt ldl\\_dsolve},\nand {\\tt ldl\\_ltsolve} routines shown in Figure~\\ref{ldlsolve}\nare provided to solve\n$\\m{Lx}=\\m{b}$, $\\m{Dx}=\\m{b}$, and $\\m{L}\\tr\\m{x}=\\m{b}$, respectively.\nTogether, they solve $\\m{Ax}=\\m{b}$, and consist of only 10 lines of executable\ncode.  If a fill-reducing permutation is used,\n{\\tt ldl\\_perm} and {\\tt ldl\\_permt} must be used to permute $\\m{b}$ and\n$\\m{x}$ accordingly.\n\n\\begin{figure}\n\\caption{Solve routines}\n\\label{ldlsolve}\n{\\scriptsize\n\\begin{verbatim}\nvoid ldl_lsolve\n(\n    int n,              /* L is n-by-n, where n >= 0 */\n    double X [ ],       /* size n.  right-hand-side on input, soln. on output */\n    int Lp [ ],         /* input of size n+1, not modified */\n    int Li [ ],         /* input of size lnz=Lp[n], not modified */\n    double Lx [ ]       /* input of size lnz=Lp[n], not modified */\n)\n{\n    int j, p, p2 ;\n    for (j = 0 ; j < n ; j++)\n    {\n        p2 = Lp [j+1] ;\n        for (p = Lp [j] ; p < p2 ; p++)\n        {\n            X [Li [p]] -= Lx [p] * X [j] ;\n        }\n    }\n}\n\nvoid ldl_dsolve\n(\n    int n,              /* D is n-by-n, where n >= 0 */\n    double X [ ],       /* size n.  right-hand-side on input, soln. on output */\n    double D [ ]        /* input of size n, not modified */\n)\n{\n    int j ;\n    for (j = 0 ; j < n ; j++)\n    {\n        X [j] /= D [j] ;\n    }\n}\n\nvoid ldl_ltsolve\n(\n    int n,              /* L is n-by-n, where n >= 0 */\n    double X [ ],       /* size n.  right-hand-side on input, soln. on output */\n    int Lp [ ],         /* input of size n+1, not modified */\n    int Li [ ],         /* input of size lnz=Lp[n], not modified */\n    double Lx [ ]       /* input of size lnz=Lp[n], not modified */\n)\n{\n    int j, p, p2 ;\n    for (j = n-1 ; j >= 0 ; j--)\n    {\n        p2 = Lp [j+1] ;\n        for (p = Lp [j] ; p < p2 ; p++)\n        {\n            X [j] -= Lx [p] * X [Li [p]] ;\n        }\n    }\n}\n\\end{verbatim}\n}\n\\end{figure}\n\nIn addition to appearing as a Collected Algorithm of the ACM \\cite{Davis05},\n{\\tt LDL} is available at http://www.suitesparse.com.\n\n%-------------------------------------------------------------------------------\n\\section{Using LDL in MATLAB}\n\\label{MATLAB}\n%-------------------------------------------------------------------------------\n\nThe simplest way to use {\\tt LDL} is within MATLAB.  Once the {\\tt ldlsparse}\nmexFunction is compiled and installed, the MATLAB statement\n{\\tt [L, D, Parent, fl] = ldlsparse (A)} returns the sparse factorization\n{\\tt A = (L+I)*D*(L+I)'}, where {\\tt L} is lower triangular, {\\tt D} is a\ndiagonal matrix, and {\\tt I} is the {\\tt n}-by-{\\tt n}\nidentity matrix ({\\tt ldlsparse} does not return the unit diagonal of {\\tt L}).\nThe elimination tree is returned in {\\tt Parent}.\nIf no zero on the diagonal of {\\tt D} is encountered, {\\tt fl} is the\nfloating-point operation count.  Otherwise, {\\tt D(-fl,-fl)} is the first\nzero entry encountered.  Let {\\tt d=-fl}.  The function returns the\nfactorization of {\\tt A (1:d,1:d)}, where rows {\\tt d+1} to {\\tt n} of {\\tt L}\nand {\\tt D} are all zero.  If a sparsity preserving permutation {\\tt P} is\npassed, {\\tt [L, D, Parent, fl] = ldlsparse (A,P)}\noperates on {\\tt A(P,P)} without\nforming it explicitly.\n\nThe statement {\\tt x = ldlsparse (A, [ ], b)} is roughly equivalent to\n{\\tt x = A}$\\backslash${\\tt b}, when {\\tt A} is sparse, real, and symmetric.\nThe $\\m{LDL}\\tr$ factorization of {\\tt A} is performed.  If {\\tt P} is\nprovided, {\\tt x = ldlsparse (A, P, b)} still performs\n{\\tt x = A}$\\backslash${\\tt b}, except that {\\tt A(P,P)} is factorized\ninstead.\n\n%-------------------------------------------------------------------------------\n\\section{Using LDL in a C program}\n\\label{C}\n%-------------------------------------------------------------------------------\n\nThe C-callable {\\tt LDL} library consists of nine user-callable routines\nand one include file.\n\n\\begin{itemize}\n\\item {\\tt ldl\\_symbolic}:  given the nonzero pattern of a sparse symmetric\n    matrix $\\m{A}$ and an optional permutation $\\m{P}$, analyzes either\n    $\\m{A}$ or $\\m{PAP}\\tr$, and returns the elimination tree, the\n    number of nonzeros in each column of $\\m{L}$, and the {\\tt Lp} array\n    for the sparse matrix data structure for $\\m{L}$.\n    Duplicate entries are allowed in the columns of $\\m{A}$, and the\n    row indices in each column need not be sorted.\n    Providing a sparsity-preserving ordering is critical for obtaining\n    good performance.  A minimum degree ordering\n    (such as AMD \\cite{AmestoyDavisDuff96,AmestoyDavisDuff03})\n    or a graph-partitioning based ordering are appropriate.\n\\item {\\tt ldl\\_numeric}:  given {\\tt Lp} and the elimination tree computed\n    by {\\tt ldl\\_symbolic}, and an optional permutation $\\m{P}$,\n    returns the numerical factorization of $\\m{A}$ or $\\m{PAP}\\tr$.\n    Duplicate entries are allowed in the columns of $\\m{A}$\n    (any duplicate entries are summed), and the\n    row indices in each column need not be sorted.\n    The data structure for $\\m{L}$ is the same as $\\m{A}$, except that\n    no duplicates appear, and each column has sorted row indices.\n\\item {\\tt ldl\\_lsolve}:  given the factor $\\m{L}$ computed by\n    {\\tt ldl\\_numeric}, solves the linear system $\\m{Lx}=\\m{b}$, where\n    $\\m{x}$ and $\\m{b}$ are full $n$-by-1 vectors.\n\\item {\\tt ldl\\_dsolve}:  given the factor $\\m{D}$ computed by\n    {\\tt ldl\\_numeric}, solves the linear system $\\m{Dx}=\\m{b}$.\n\\item {\\tt ldl\\_ltsolve}:  given the factor $\\m{L}$ computed by\n    {\\tt ldl\\_numeric}, solves the linear system $\\m{L}\\tr\\m{x}=\\m{b}$.\n\\item {\\tt ldl\\_perm}: given a vector $\\m{b}$ and a permutation $\\m{P}$,\n    returns $\\m{x}=\\m{Pb}$.\n\\item {\\tt ldl\\_permt}: given a vector $\\m{b}$ and a permutation $\\m{P}$,\n    returns $\\m{x}=\\m{P}\\tr\\m{b}$.\n\\item {\\tt ldl\\_valid\\_perm}:  Except for checking if the diagonal of\n    $\\m{D}$ is zero, none of the above routines check their inputs for errors.\n    This routine checks the validity of a permutation $\\m{P}$.\n\\item {\\tt ldl\\_valid\\_matrix}:  checks if a matrix $\\m{A}$ is valid as input\n    to {\\tt ldl\\_symbolic} and {\\tt ldl\\_numeric}.\n\\end{itemize}\n\nNote that the primary input to the {\\tt ldl\\_symbolic} and\n{\\tt ldl\\_numeric} is the sparse matrix $\\m{A}$.  It is provided in\ncolumn-oriented form, and only the upper triangular part is accessed.\nThis is slightly different than the primary output: the matrix $\\m{L}$, \nwhich is lower triangular in column-oriented form.\nIf you wish to factorize a symmetric matrix $\\m{A}$ for which only the lower\ntriangular part is supplied, you would need to transpose $\\m{A}$ before\npassing it {\\tt ldl\\_symbolic} and {\\tt ldl\\_numeric}.\n\nAn additional set of routines is available for use in a 64-bit environment.\nEach routine name changes uniformly; {\\tt ldl\\_symbolic} becomes\n{\\tt ldl\\_l\\_symbolic}, and each {\\tt int} parameter becomes type\n{\\tt SuiteSparse\\_long}.  The {\\tt SuiteSparse\\_long} type is {\\tt long}, except for\nMicrosoft Windows 64, where it becomes {\\tt \\_\\_int64}.\n\n\\begin{figure}\n\\caption{Example of use}\n\\label{ldlsimple}\n{\\scriptsize\n\\begin{verbatim}\n#include <stdio.h>\n#include \"ldl.h\"\n#define N 10    /* A is 10-by-10 */\n#define ANZ 19  /* # of nonzeros on diagonal and upper triangular part of A */\n#define LNZ 13  /* # of nonzeros below the diagonal of L */\n\nint main (void)\n{\n    /* only the upper triangular part of A is required */\n    int    Ap [N+1] = {0, 1, 2, 3, 4,   6, 7,   9,   11,      15,     ANZ},\n           Ai [ANZ] = {0, 1, 2, 3, 1,4, 5, 4,6, 4,7, 0,4,7,8, 1,4,6,9 } ;\n    double Ax [ANZ] = {1.7, 1., 1.5, 1.1, .02,2.6, 1.2, .16,1.3, .09,1.6,\n                     .13,.52,.11,1.4, .01,.53,.56,3.1},\n           b [N] = {.287, .22, .45, .44, 2.486, .72, 1.55, 1.424, 1.621, 3.759};\n    double Lx [LNZ], D [N], Y [N] ;\n    int Li [LNZ], Lp [N+1], Parent [N], Lnz [N], Flag [N], Pattern [N], d, i ;\n\n    /* factorize A into LDL' (P and Pinv not used) */\n    ldl_symbolic (N, Ap, Ai, Lp, Parent, Lnz, Flag, NULL, NULL) ;\n    printf (\"Nonzeros in L, excluding diagonal: %d\\n\", Lp [N]) ;\n    d = ldl_numeric (N, Ap, Ai, Ax, Lp, Parent, Lnz, Li, Lx, D, Y, Pattern,\n        Flag, NULL, NULL) ;\n\n    if (d == N)\n    {\n        /* solve Ax=b, overwriting b with the solution x */\n        ldl_lsolve (N, b, Lp, Li, Lx) ;\n        ldl_dsolve (N, b, D) ;\n        ldl_ltsolve (N, b, Lp, Li, Lx) ;\n        for (i = 0 ; i < N ; i++) printf (\"x [%d] = %g\\n\", i, b [i]) ;\n    }\n    else\n    {\n        printf (\"ldl_numeric failed, D (%d,%d) is zero\\n\", d, d) ;\n    }\n    return (0) ;\n}\n\\end{verbatim}\n}\n\\end{figure}\n\nThe program in Figure~\\ref{ldlsimple}\nillustrates the basic usage of the {\\tt LDL} routines.\nIt analyzes and factorizes the sparse symmetric positive-definite matrix\n{\\small\n\\[\n\\m{A} = \\left[\n\\begin{array}{cccccccccc}\n      1.7 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & .13 &   0 \\\\\n        0 &  1. &   0 &   0 & .02 &   0 &   0 &   0 &   0 & .01 \\\\\n        0 &   0 & 1.5 &   0 &   0 &   0 &   0 &   0 &   0 &   0 \\\\\n        0 &   0 &   0 & 1.1 &   0 &   0 &   0 &   0 &   0 &   0 \\\\\n        0 & .02 &   0 &   0 & 2.6 &   0 & .16 & .09 & .52 & .53 \\\\\n        0 &   0 &   0 &   0 &   0 & 1.2 &   0 &   0 &   0 &   0 \\\\\n        0 &   0 &   0 &   0 & .16 &   0 & 1.3 &   0 &   0 & .56 \\\\\n        0 &   0 &   0 &   0 & .09 &   0 &   0 & 1.6 & .11 &   0 \\\\\n      .13 &   0 &   0 &   0 & .52 &   0 &   0 & .11 & 1.4 &   0 \\\\\n        0 & .01 &   0 &   0 & .53 &   0 & .56 &   0 &   0 & 3.1 \\\\\n\\end{array}\n\\right]\n\\]\n}\nand then solves a system $\\m{Ax}=\\m{b}$ whose true solution is\n$x_i = i/10$.  Note that {\\tt Li} and {\\tt Lx} are statically allocated.\nNormally they would be allocated after their size, {\\tt Lp[n]},\nis determined by {\\tt ldl\\_symbolic}.\nMore example programs are included with the {\\tt LDL} package.\n\n\\section{Acknowledgments}\n\nI would like to thank Pete Stewart for his comments on an earlier draft\nof this software and its accompanying paper.\n\n\\newpage\n\\bibliographystyle{plain}\n\\bibliography{ldl}\n\n\\end{document}\n", "meta": {"hexsha": "07766d5943fb43a2b869a515eb032fd4ad611de9", "size": 29100, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SuiteSparse/LDL/Doc/ldl_userguide.tex", "max_stars_repo_name": "GeospatialDaryl/VS2013__19_SuiteSparse_Metis_CUDA", "max_stars_repo_head_hexsha": "a3a9d9c39197f40cb07a5f3aaf8718309048b88f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SuiteSparse/LDL/Doc/ldl_userguide.tex", "max_issues_repo_name": "GeospatialDaryl/VS2013__19_SuiteSparse_Metis_CUDA", "max_issues_repo_head_hexsha": "a3a9d9c39197f40cb07a5f3aaf8718309048b88f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SuiteSparse/LDL/Doc/ldl_userguide.tex", "max_forks_repo_name": "GeospatialDaryl/VS2013__19_SuiteSparse_Metis_CUDA", "max_forks_repo_head_hexsha": "a3a9d9c39197f40cb07a5f3aaf8718309048b88f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.7692307692, "max_line_length": 87, "alphanum_fraction": 0.5892439863, "num_tokens": 8745, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.44267495259917145}}
{"text": "\\section{Updates: 04/13/2020}%\n\\label{sec:updates_2020_04_13}\n%\n\\subsection{Changes to Network}%\n\\label{subsec:changes_to_network}\n%\n\\begin{itemize}\n  \\item Use Cartesian representation \\(\\left[{\\cos\\phi_\\mu(x),\n    \\sin\\phi_\\mu(x)}\\right]\\) instead of angular representation \\(\\phi_{\\mu}(x)\n    \\in [{0, 2\\pi})\\).\n    \\begin{itemize}\n      \\item While this doubles the size of our inputs, it avoids complications\n        that arise from angles near \\(0\\) and \\(2\\pi\\).\n    \\end{itemize}\n  % \\item \\color{blue}{Under this new representation, the bias in the average\n  %   plaquette no longer seems to be an issue.}\\color{black}\n  % \\item However, there is no noticeable improvement in the tunneling rate when\n  %   compared to generic HMC.\\@\n  % \\color{red}{\\item \\textbf{TODO:}}\\color{black}\n  % \\begin{todolist}\n  %   \\item Continue testing with additional hidden layers.\n  %   \\item Add convolutional/pooling layers at beginning of network to ensure\n  %     translational invariance.\n  % \\end{todolist}\n\\end{itemize}\n\n\\subsection{Changes to the loss function}%\n\\label{subsec:changes_to_loss_fn}\n%\nSince our main goal is to obtain a sampler that is able to efficiently sample\nfrom different topological sectors, we can design a loss function around this\nidea.\n%\nRecall that the topological charge \\(\\Q \\in \\mathbb{Z}\\) is computed as\n%\n\\begin{equation}\n  \\mathcal{Q} \\equiv \\frac{1}{2\\pi}\\sum_{\\substack{{x; \\mu, \\nu}\\\\{\\nu > \\mu}}}\n    \\sin\\left(\\phi_{\\mu\\nu}(x)\\right)\n\\end{equation}\n%\nfor\n%\n\\begin{equation}\n  \\phi_{\\mu\\nu}(x) = \\phi_{\\mu}(x) + \\phi_{\\nu}(x+\\hat{\\mu}) -\n  \\phi_{\\mu}(x+\\hat{\\nu}) - \\phi_{\\nu}(x)\n\\end{equation}\n%\nInstead of maximizing the expected squared jump distance (ESJD) between\nconfigurations, it makes more sense to maximize quantities related to the\nplaquette sums, e.g.\\ the \\emph{plaquette distance}, \\(\\delta_{P}(\\xip, \\xi)\\)\n%\n\\begin{equation}\n  \\delta_{P}\\left(\\xip, \\xi\\right)\n  = \\sum 1 - \\cos\\left(\\phi^{\\prime}_{\\mu\\nu}(x) - \\phi_{\\mu\\nu}(x)\\right) \\\\\n  % \\hspace{6em}\\text{\n  %   (\\emph{plaquette distance})\n  % }\\\\\n  \\label{eq:plaq_diff}\n\\end{equation}\n  % \\vspace{1em}\n  % -----------------------------------------------\nor the topological charge difference squared, \\(\\delta_{\\Q}(\\xip, \\xi)\\)\n%\n\\begin{align}\n  \\delta_{\\Q}(\\xip, \\xi)\n  &= \\bigg[\\overbrace{\\frac{1}{2\\pi}\\sum\n    \\sin\\left(\\phi^{\\prime}_{\\mu\\nu}(x)\\right)}^{\\Q^{\\prime}}\n  - \\overbrace{\\frac{1}{2\\pi}\\sum\n    \\sin\\left(\\phi_{\\mu\\nu}(x)\\right)}^{\\Q}\\bigg]^{2} \\\\\n  &= {(\\Q^{\\prime} - \\Q)}^2\n  % \\hspace{10.6em}\\text{\n  %   (\\emph{topological charge difference})\n  % }%\n  \\label{eq:charge_diff}\n\\end{align}\n%\nwhere \\(\\phi_{\\mu\\nu}^{\\prime}(x)\\) denotes the proposed configuration (before\napplying Metropolis-Hastings accept/reject).\n%\nFrom these we can then define\n%\n\\begin{align}\n  \\ell_{\\lambda_{P}}\\left(\\xip, \\xi, A(\\xip|\\xi)\\right) \n  &= \\frac{\\lambda_{P}^{2}}{\\delta_{P}\\cdot A(\\xi^{\\prime}|\\xi)}\n    -  \\frac{\\delta_{P}\\cdot A(\\xi^{\\prime}|\\xi)}{\\lambda_{P}^{2}} \\\\\n  \\ell_{\\lambda_{\\Q}}\\left(\\xip, \\xi, A(\\xip|\\xi)\\right) \n  &= \\frac{\\lambda_{\\Q}^{2}}{\\delta_{\\Q}\\cdot A(\\xi^{\\prime}|\\xi)}\n    -  \\frac{\\delta_{\\Q}\\cdot A(\\xi^{\\prime}|\\xi)}{\\lambda_{\\Q}^{2}}\n\\label{eq:ell_lambda}\n\\end{align}\n%\nwhere \\(\\lambda_{P}, \\lambda_{\\Q}\\) are scaling factors used to control the\ncontribution from each of the \\(\\delta_{P}, \\delta_{\\Q}\\) terms.\n%\nFinally, our loss function becomes\n%\n\\begin{equation}\n  \\mathcal{L}{(\\theta)} = \\mathbb{E}_{p(\\xi)}\\left[\n    \\alpha_{P} \\cdot \\ell_{\\lambda_{P}} + \\alpha_{\\Q} \\cdot \\ell_{\\lambda_{\\Q}}\n  \\right]\n  + \\mathbb{E}_{q(\\xi)}\\left[\n    \\alpha_{P} \\cdot \\ell_{\\lambda_{P}} + \\alpha_{\\Q} \\cdot \\ell_{\\lambda_{\\Q}}\n  \\right]\n\\end{equation}\n%\nwhere \\(\\alpha_{P}, \\alpha_{\\Q}\\) are weights to control the respective terms\ncontribution to the overall loss function.\n\n\n%\n% \\begin{table}[ht!]\n%   \\centering\n%   \\begin{tabular}{@{}rccc@{}}\n%   % \\cmidrule(l){1-4}\n%   \\multicolumn{1}{l}{} & \\multicolumn{1}{l}{\\textbf{tunneling events}} & \\multicolumn{1}{l}{\\textbf{tunneling rate}} & \\multicolumn{1}{l}{\\textbf{accept prob}} \\\\\n%   \\cmidrule(l){1-4}\n%    \\multicolumn{1}{r}{\\textit{chain 1}} & 1 & 0.000125 & 0.684 \\(\\pm\\) 0.003 \\\\\n%    \\multicolumn{1}{r}{\\textit{chain 2}} & 4 & 0.000500 & 0.695 \\(\\pm\\) 0.003 \\\\\n%    \\multicolumn{1}{r}{\\textit{chain 3}} & 4 & 0.000500 & 0.696 \\(\\pm\\) 0.003 \\\\\n%    \\multicolumn{1}{r}{\\textit{chain 4}} & 3 & 0.000375 & 0.698 \\(\\pm\\) 0.003 \\\\\n%   \\cmidrule(l){1-4}\n%    \\multicolumn{1}{r}{\\textbf{average}} & \\textbf{2.4} & \\textbf{0.0003} &\n%    \\textbf{0.696 \\(\\pm\\) 0.003}\n%   \\end{tabular}\n%   \\caption{Inference results for trained \\textbf{L2HMC} sampler ran for \\(N = 1\\times\n%   10^{4}\\) accept/reject steps at \\(\\beta = 5\\).}%\n%   \\label{tab:l2hmc_inference}\n% \\end{table}\n% %\n% \\begin{table}[ht!]\n%   \\centering\n%   \\begin{tabular}{@{}rccc@{}}\n%   % \\cmidrule(l){2-4}\n%   \\multicolumn{1}{l}{} & \\multicolumn{1}{l}{\\textbf{tunneling events}} & \\multicolumn{1}{l}{\\textbf{tunneling rate}} & \\multicolumn{1}{l}{\\textbf{accept prob}} \\\\\n%   \\cmidrule(l){1-4}\n%   \\multicolumn{1}{r}{\\textit{chain 1}} & 2 & 0.000250 & 0.279 \\(\\pm\\) 0.004 \\\\\n%   \\multicolumn{1}{r}{\\textit{chain 2}} & 1 & 0.000125 & 0.271 \\(\\pm\\) 0.004 \\\\\n%   \\multicolumn{1}{r}{\\textit{chain 3}} & 3 & 0.000375 & 0.281 \\(\\pm\\) 0.004 \\\\\n%   \\multicolumn{1}{r}{\\textit{chain 4}} & 4 & 0.000500 & 0.286 \\(\\pm\\) 0.004 \\\\\n%   \\cmidrule(l){1-4}\n%   \\multicolumn{1}{r}{\\textbf{average}} & \\textbf{2} & \\textbf{0.00025} &\n%   \\textbf{0.282 \\(\\pm\\) 0.004}\n%   \\end{tabular}\n%   \\caption{Inference results for generic \\textbf{HMC} sampler ran for \\(N = 1\\times\n%   10^{4}\\) accept/reject steps at \\(\\beta = 5\\).}%\n%   \\label{tab:hmc_inference}\n% \\end{table}\n% %\n% \\clearpage\n% %\n% \\begin{figure}[ht!]\n%   \\centering\n%   \\includegraphics[width=0.7\\linewidth]{figures/updates_2020_04_13/l2hmc.png}\n%   \\caption{Inference results from trained \\textbf{L2HMC} sampler.}%\n%   \\label{fig:l2hmc_inference}\n% \\end{figure}\n% %\n% \\begin{figure}[ht!]\n%   \\centering\n%   \\includegraphics[width=0.7\\linewidth]{figures/updates_2020_04_13/hmc.png}\n%   \\caption{Inference results from generic \\textbf{HMC} sampler.}%\n%   \\label{fig:hmc_inference}\n% \\end{figure}\n% %\n% %\n% \\begin{figure}[htpb]\n%  \\centering\n%  \\begin{subfigure}[t]{0.48\\textwidth}\n%    \\caption{Using gradient clipping.}\n%    \\includegraphics[width=\\textwidth]{grid_plots/lf1/tunn_rate_vs_bias_lf1_clip10.png}\n%  \\end{subfigure}\n%  \\begin{subfigure}[t]{0.48\\textwidth}\n%    \\caption{Without gradient clipping.}\n%    \\includegraphics[width=\\textwidth]{grid_plots/lf1/tunn_rate_vs_bias_lf1.png}\n%  \\end{subfigure}\n%  \\caption{Plot of the tunneling rate $\\gamma$ vs $\\delta \\phi_{P}$.}\n% \\end{figure}\n% (\n% [\n\n% \\begin{figure}[htpb!]\n%   \\centering\n%   \\begin{subfigure}[t]{0.57\\textwidth}\n%     \\includegraphics[width=\\textwidth]{updates_2020_04_28/losses_beta40}%\n%     % \\caption{\\(\\beta = 4\\).}%\n%   \\label{fig:losses_beta4}\n%   \\end{subfigure}\n%   \\begin{subfigure}[t]{0.57\\textwidth}\n%     \\includegraphics[width=\\textwidth]{updates_2020_04_28/losses_beta5}%\n%     % \\caption{\\(\\beta = 5\\).}%\n%     \\label{fig:losses_beta5}\n%   \\end{subfigure}\n%   \\begin{subfigure}[t]{0.57\\textwidth}\n%     \\includegraphics[width=\\textwidth]{updates_2020_04_28/losses_beta55}%\n%     % \\caption{\\(\\beta = 5.5\\).}%\n%     \\label{fig:losses_beta55}\n%   \\end{subfigure}\n%   \\caption{Loss comparisons between L2HMC and HMC at different values of\n%   \\(\\beta\\).}\n% \\end{figure}\n", "meta": {"hexsha": "3f1a1b1de5916426b48bb2ce0b09c4d06633202b", "size": 7444, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/updates/updates_2020_04_13.tex", "max_stars_repo_name": "saforem2/l2hmc-qcd", "max_stars_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 32, "max_stars_repo_stars_event_min_datetime": "2019-04-18T18:50:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T18:30:48.000Z", "max_issues_repo_path": "doc/updates/updates_2020_04_13.tex", "max_issues_repo_name": "saforem2/l2hmc-qcd", "max_issues_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2019-09-09T21:10:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:43:51.000Z", "max_forks_repo_path": "doc/updates/updates_2020_04_13.tex", "max_forks_repo_name": "saforem2/l2hmc-qcd", "max_forks_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-10-31T02:25:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-25T00:49:14.000Z", "avg_line_length": 37.0348258706, "max_line_length": 164, "alphanum_fraction": 0.6309779688, "num_tokens": 2859, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4426749479091953}}
{"text": "\\documentclass[jou]{apa6}\n\n\\usepackage[american]{babel}\n\n\\usepackage{csquotes}\n\\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}\n\\DeclareLanguageMapping{american}{american-apa}\n\\addbibresource{bibliography.bib}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Discrete Structures\n%% The start of RBS stuff\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Working internal and external links in PDF\n\\usepackage{hyperref}\n% Extra math symbols in LaTeX\n\\usepackage{amsmath}\n\\usepackage{gensymb}\n\\usepackage{amssymb}\n% Enumerations with (a), (b), etc.\n\\usepackage{enumerate}\n\n\\let\\OLDitemize\\itemize\n\\renewcommand\\itemize{\\OLDitemize\\addtolength{\\itemsep}{-6pt}}\n\n\\usepackage{etoolbox}\n\\makeatletter\n\\preto{\\@verbatim}{\\topsep=3pt \\partopsep=3pt }\n\\makeatother\n\n% These sizes redefine APA for A4 paper size\n\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.27in\n\\headheight 1.0in\n\\topmargin -24pt\n\\headheight 12pt\n\\headsep 12pt\n\\textheight 9.19in\n\n\n\n\\setlength\\parindent{0pt}\n\n\\title{Midterm, 2020-02-17}\n\\author{Discrete Structures, Fall 2020}\n\\affiliation{RBS}\n\n\\leftheader{Midterm, 2020-02-17}\n\n\\abstract{%\n}\n\n%\\keywords{}\n\n\\begin{document}\n\n%\\thispagestyle{empty}\n\n\\twocolumn\n\\section{Midterm, 2020-02-17}\n\n\\vspace{6pt}\n{\\bf Question 1 (Boolean Expressions).}\\\\\nConsider Boolean expression:\n$$E_0 = (p \\rightarrow q \\rightarrow r) \\wedge (q \\rightarrow r \\rightarrow p) \\wedge (r \\rightarrow p \\rightarrow q)$$\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{midterm/venn-circles.png}}\n\\caption{\\label{fig:venn-circles} Venn diagram for 3 sets.}\n\\end{figure}\n\n\\begin{enumerate}[(A)]\n\\item Copy the Venn diagram's circles in your solution and shade those regions in the diagram that make $E_0$ true\n(being inside each circle $P,Q,R$ means that the respective variable $p,q,r$ is true; being outside the circle means\nthat the variable is false). \n\\item In the truth table of $E_0$ how many entries are $\\mathtt{True}$?\\\\\n({\\em Note.} Building the truth table is optional. Regardless whether you build one or not, you should justify your answer.)\n\\item Rewrite the Boolean expression $E_0$ into an equivalent one, using \nonly conjunctions ($\\wedge$) and negations ($\\neg$). \n\\end{enumerate}\n\nAssume that implication ($\\rightarrow$) is right-associative \nand conjunction ($\\wedge$) has higher precedence than implication. \n\n\n\n\\vspace{10pt}\n{\\bf Question 2 (Nested Quantifiers).}\\\\\nVerify, if the following predicate/quantifier expressions are true for the given predicate. \nThe predicate $P$ is defined on $A \\times A$, where\n$A = \\{ \\mathtt{a},\\mathtt{b},\\mathtt{c},\\mathtt{d},\\mathtt{e},\\mathtt{f} \\}$. \nPredicate $P(\\mathtt{a},\\mathtt{b})$ is true iff the square on row $\\mathtt{a}$\nand column $\\mathtt{b}$ is shaded in Figure~\\ref{fig:relation-set6}. Predicate $P(\\mathtt{a},\\mathtt{b})$ \nis false, if that square is white.\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.2in]{midterm/relation-set6.png}}\n\\caption{\\label{fig:relation-set6} 2 argument predicate.}\n\\end{figure}\n\n\n\\begin{enumerate}[(A)]\n\\item Does the predicate $P$ satisfy the logic formula:\n$$\\forall i \\in A,\\;P(i,i).$$\n\\item Does the predicate $P$ satisfy the logic formula:\n$$\\forall i \\in A,\\,\\forall j \\in A,\\;P(i,j) \\rightarrow P(j,i).$$\n\\item Does the predicate $P$ satisfy the logic formula:\n$$\\forall i,j,k \\in A,\\;P(i,j) \\wedge P(j,k) \\rightarrow P(i,k).$$\n\\item Does the predicate $P$ satisfy the logic formula:\n$$\\forall i,j \\in A,\\;P(i,j) \\vee P(j,i).$$\n\\item Does the predicate $P$ satisfy the logic formula:\n$$\\forall i \\in A,\\, \\exists j \\in A,\\;P(i,j).$$\n\\end{enumerate}\n\n\\vspace{10pt}\n{\\bf Question 3 (Estimate with Big-O Notation).}\\\\\nDefine the sequence $S(n)$ as a sum of squares from $1^2$ to $n^2$:\n$$S(n) = \\sum\\limits_{i=1}^n i^2.$$\nWe have $S(1) = 1^2 = 1$, $S(2) = 1^2 + 2^2 = 5$, \n$S(3) = 1^2 + 2^2 + 3^2 = 14$,\nand so on. \n\n\\begin{enumerate}[(A)]\n\\item Is the function $S(n)$ in $O(n^1)$? \nIs it in $O(n^2)$? Is it in $O(n^3)$? Is it in $O(n^4)$? \nExplain your reasoning. \n\\item Pick any one of the notations from the previous items \n($g(n)$ is either $O(n^1)$, or $O(n^2)$, or $O(n^3)$, or $O(n^4)$). \nCheck the definition of Big-O notation: Find the {\\em witness}: the value $k$ and the constant $C$\nsuch that the absolute value of $S(n)$ does not exceed $C\\cdot{}|g(n)|$ for all $n > k$.\n\\end{enumerate}\n\n\n\\vspace{10pt}\n{\\bf Question 4 (Chinese Remainder Theorem).}\n\nConsider the following system of three congruences:\n$$\\left\\{ \\begin{array}{l}\nx \\equiv 1\\;(\\text{mod}\\,5),\\\\\nx \\equiv 2\\;(\\text{mod}\\,7),\\\\\nx \\equiv 3\\;(\\text{mod}\\,9).\n\\end{array} \\right.$$\n\n\\begin{enumerate}[(A)]\n\\item Does it have a solution? Will it have solution, even if we replace $1,2,3$ with other numbers\non the right sides of the equation.\n\\item Find an arithmetic progression (what is its first member $A$, difference $B$) where all members satisfy\nthe first two congruences from the system.\n\\item Find an arithmetic progression (what is its first member $C$, difference $D$) where all members satisfy\nall three congruences in the system.\n\\end{enumerate}\n\n{\\em Note.} Arithmetic progression is an infinite sequence where every next member can be obtained\nby adding the same number (the difference) to the previous one. For example, \n$$A,\\;A+B,\\;A+2B,\\;A+3B,\\ldots$$\nis an arithmetic progression with the first member $A$ and the difference $B$.\n\n\n\\vspace{10pt}\n{\\bf Question 5 (Binary notation).}\n\nSomebody has written two binary fractions on the board: $\\alpha$ is infinite, $\\beta$ is finite (just $6$ digits\nafter the point): \n$$\\left\\{ \\begin{array}{l}\n\\alpha = 0.(011110)_2 = 0.011110011110011110\\ldots_2\\\\\n\\beta = 0.011110_2.\n\\end{array} \\right.$$\n\n\\begin{enumerate}[(A)]\n\\item Express the number $\\beta$ as a sum of some negative powers of $2$; \nnamely, show how to add up some of the numbers\n$$\\{ 2^{-1}, 2^{-2}, 2^{-3}, \\ldots \\}$$ \nto get $\\beta$. \n\\item Express $\\beta$ as an irreducible fraction {\\tt P/Q}; write this in the regular decimal notation. \n\\item Write the product $64_{10} \\cdot \\alpha = 1000000_2 \\cdot \\alpha$ in the binary notation. \n\\item Express $\\alpha$ as an irreducible fraction {\\tt P/Q} in decimal notation.\n\\end{enumerate}\n\n\n\n\\vspace{10pt}\n{\\bf Question 6 (Truth-tellers and Liars).}\nAmong the people $A,B,C$ one is a truth-teller, \nthe other two are liars. \nEvery person ($A$, $B$, and $C$) has a closed box\nin front of himself/herself. Exactly one of the \nboxes has a candy inside. $A,B,C$ know everything \nabout each other and the location of candy.\n\nSomeone else (person $D$) approaches all of them. $D$ knows, who are \npeople $A$,$B$, and $C$ (it is written on their name-cards), but $D$ does\nnot know anything about their lying behavior or the location of the candy.\n$D$ is allowed to ask YES/NO questions to one or more people.\n\n\\begin{enumerate}[(A)]\n\\item Can $D$ find out who has the candy by asking three questions?\n\\item Can $D$ find out who has the candy by asking two questions?\n\\item Can $D$ find out who has the candy by asking one question?\n\\end{enumerate}\n\nJustify your answers (by construction or by showing that it is impossible).\n\n\n\\vspace{10pt}\n{\\bf Question 7 (Time Complexity of Truth Tables).}\n\nAssume that there is a Boolean expression $E$ with $n$ variables: \n$$E = E(a_1,a_2,\\ldots,a_n).$$\nThe expression $E$ contains $2n$ Boolean operators (such as $\\neg$, $\\wedge$, $\\vee$).\nVariables $a_1,a_2,\\ldots,a_n$ can independently take values \n$\\mathtt{True}$ or $\\mathtt{False}$.\n\nConsider the following algorithm to find, if $E$ is a tautology by \nbuilding the truth table. We will either find a false value, or \nestablish that all values were true (in this case $E$ is a tautology).\n\n{\\bf (1)} \\hspace{0.0in} For each assignment of $n$ truth values to $a_1,\\ldots,a_n$:\\\\\n{\\bf (2)} \\hspace{0.2in} For each of the $2n$ Boolean operators in $E$:\\\\\n{\\bf (3)} \\hspace{0.4in} Compute the value of that Boolean operator\\\\\n{\\bf (4)} \\hspace{0.2in} If $E$ has value $\\mathtt{False}$:\\\\\n{\\bf (5)} \\hspace{0.4in} Return ``$E$ is not a tautology.''\\\\\n{\\bf (6)} \\hspace{0.2in} If $E$ has value $\\mathtt{True}$:\\\\\n{\\bf (7)} \\hspace{0.4in} Continue loop on Line {\\bf (1)}.\\\\\n{\\bf (8)} \\hspace{0.0in} Return ``$E$ is a tautology.''\n\n\\begin{enumerate}[(A)]\n\\item Find the worst-case runtime $T(n)$ for this algorithm as an expression of $n$.\n(Assume that evaluating one Boolean operator $\\neg$, $\\wedge$, $\\vee$ takes $1$ unit of time.)\n\\item Find a function $g(n)$ such that $T(n)$ is in $O(g(n))$. \n\\end{enumerate}\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 8 (About Rational and Irrational).}\n\nWe denote two real numbers by $p$ and $q$. \nProve or disprove statements about the rational and irrational numbers. \n\n\\begin{enumerate}[(A)]\n\\item If $p + q$ is rational, then either both $p,q$ are rational, or both are irrational. \n\\item If $pq$ is rational, then either both $p,q$ are rational, or both are irrational. \n\\item If $p^2$ and $q^2$ are both rational, then the product $(p+q)(p-q)$ is rational. \n\\item If $p^3$ and $p^5$ are both rational, then $p$ is rational.\n\\item If $pq$ and $p+q$ are both rational, then $p$ and $q$ are both rational.\n\\end{enumerate}\n\n\\newpage\n\n\\subsection{Answers}\n\n{\\em Note. Grading criteria (see the tables below) should not be considered as a dogma, \nsince every work is different. They provide some guidelines how the points typically split. \nThere are 10 points (maximum) for any given problem. If the problem has multiple parts\n({\\bf (A)}, {\\bf (B)}, etc.) each part is allocated certain portion of these points. \nThere are 1-2 points that can be added or subtracted depending on how clearly the \npartial solution is written.}\n\n{\\em\nThe theoretical maximum for the whole midterm is 80 points (all 8 problems solved for 10 points each).\nSince the midterm accounts for 150~\\textperthousand{} (150 promilles or 15 percent) of your\ntotal grade; we get the total grade (in promilles) by multiplying your points by 2\n(and cutting it to the maximum value 150~\\textperthousand{}, if necessary). \n}\n\n\\vspace{6pt}\n{\\bf Question 1}\\\\\n{\\bf (A)} The only way to have $p \\rightarrow q \\rightarrow r = p \\rightarrow (q \\rightarrow r)$ evaluate to \n$\\mathtt{False}$ is $p = \\mathtt{True}$ and $(q \\rightarrow r) = \\mathtt{False}$ (i.e.\\ \n$q = \\mathtt{True}$ and $r = \\mathtt{False}$).\\\\\nIf we consider also $q \\rightarrow r \\rightarrow p$ and $r \\rightarrow p \\rightarrow q$, there are two \nmore ways to get the whole expression $E_0$ false. Each of these ways means that exactly two variables\nare $\\mathtt{True}$ and the third one is $\\mathtt{False}$. \nAll the other areas make the expression true. Shaded areas are shown in Figure~\\ref{fig:circles-shaded2}. There are just $3$ \nregions where the expression $E_0$ evaluates to false (white, not shaded). \n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{midterm/circles-shaded2.png}}\n\\caption{\\label{fig:circles-shaded2} Venn diagram with shading.}\n\\end{figure}\n\n\n\n{\\bf (B)} There are exactly $8-3 = 5$ entries in the truth table which make the expression true\n(there are only $3$ ways to make the expression false, as shown in {\\bf (A)}). \n\n{\\bf (C)} Let us just transform one subexpression: \n\\begin{align}\n & p \\rightarrow (q \\rightarrow r) = \\nonumber \\\\\n= & \\neg p \\vee (q \\rightarrow r) = \\nonumber \\\\\n= & \\neg p \\vee (\\neg q \\vee r) = \\nonumber \\\\\n= & \\neg p \\vee \\neg q \\vee r  = \\nonumber \\\\\n= & \\neg (p \\wedge q \\wedge \\neg r). \\nonumber\n\\end{align}\n\nIf we combine all $3$ subexpressions (where $p,q,r$ switch their order), we get \na longer conjuction for $E_0$:\n\n$$\\neg (p \\wedge q \\wedge \\neg r) \\wedge \\neg (q \\wedge r \\wedge \\neg p) \\wedge \\neg (r \\wedge p \\wedge \\neg q).$$\n\n{\\footnotesize\n\\begin{tabular}{|l|l|} \\hline\n{\\bf (A)} Shading is correct & 3 points \\\\ \\hline\n{\\bf (A)} Shading incorrect, but matches truth table & 2 points \\\\ \\hline\n{\\bf (B)} Truth table or explanation for the number of ``true'' & 3 points \\\\ \\hline\n{\\bf (B)} Partial truth table or incomplete justification & 2 points \\\\ \\hline\n{\\bf (C)} Correct formula with conjunctions, negations & 4 points \\\\ \\hline\n\\end{tabular}\n}\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 2}\n\\begin{enumerate}[(A)]\n\\item Yes, $\\forall i \\in A,\\;P(i,i)$ is true (we say that the 2-argument predicate \nis {\\em reflexive}): all the squares $P(i,i)$ on the diagonal of the values are shaded. \n\\item Yes, $\\forall i \\in A,\\,\\forall j \\in A,\\;P(i,j) \\rightarrow P(j,i)$ is true (we say that the 2-argument predicate \nis {\\em symmetric}): the squares in the table of $P(i,j)$ are symmetric against\nthe diagonal of the values: $P(i,j)$ is shaded iff $P(j,i)$ is shaded.\n\\item Yes, $\\forall i,j,k \\in A,\\;P(i,j) \\wedge P(j,k) \\rightarrow P(i,k)$ is true \n(we say that the 2-argument predicate \nis {\\em transitive}). Notice that $P(i,j)$ can be true iff $i=j$ or $(i,j)$ is \none of the pairs of neighbors: $(\\mathtt{a},\\mathtt{b})$, or $(\\mathtt{c},\\mathtt{d})$, or $(\\mathtt{e},\\mathtt{f})$.\n$P(j,k)$ is also true; so $j,k$ also belong to the same pair. Therefore $i$ and $k$ also belong to the same pair. \n\\item No, $\\forall i,j \\in A,\\;P(i,j) \\vee P(j,i)$ is false. For example, neither $P(\\mathtt{a},\\mathtt{c})$\nnor $P(\\mathtt{c},\\mathtt{a})$ are true.\n\\item Yes, $\\forall i \\in A,\\, \\exists j \\in A,\\;P(i,j)$ is true: On each row $i$ there is at least\none shaded square.\n\\end{enumerate}\n\n{\\footnotesize\n\\begin{tabular}{|l|l|} \\hline\n{\\bf (A)-(E)} Correct answer plus valid explanation & 2 points (for each) \\\\ \\hline\n{\\bf (A)-(E)} Correct truth value & 1 point (for each) \\\\ \\hline\n\\end{tabular}\n}\n\n\\vspace{10pt}\n{\\bf Question 3}\n{\\bf (A)} $S(n)$ is in $O(n^3)$ (and therefore it is also in $O(n^4)$). \nOn the other hand, $S(n)$ is not in $O(n^2)$ or $O(n^1)$.\\\\\nLet us show that $S(n)$ is not in $O(n^2)$. Assume from the contrary\nthat there are numbers $k$ and $C$ such that for each $n > k$:\n$$|S(n)| = |1^2 + 2^2 + \\ldots + n^2| \\leq C \\cdot |n^2|.$$\nSince all numbers there are positive, we drop the absolute values. \nWe pick any even number $n > k$ which also satisfies $n > 8C$. In this case:\n\\begin{align}\n & S(n) = 1^2 + 2^2 + \\ldots + n^2 > \\nonumber \\\\\n> & \\left( \\frac{n}{2} + 1 \\right)^2 + \\left( \\frac{n}{2} + 2 \\right)^2 + \\ldots + n^2 > \\nonumber \\\\\n> & \\frac{n}{2} \\cdot \\left( \\frac{n}{2} \\right)^2 \\geq \\frac{n}{8} \\cdot n^2 \\geq C n^2. \\nonumber \n\\end{align}\n{\\em (In these inequalities, we first drop the first half of the sum; \nthen replace each term with $(n/2)^2$ and we still can prove that the sum is more than $Cn^2$ \nfor the given constant $C$.)}\\\\\nSuch $n$ can always be found (no matter what $k$ and $C$ are used). \nTherefore $S(n)$ can never satisfy $|S(n)| \\leq C \\cdot n^2$.\\\\\nSince $n$ is even smaller than $n^2$, $S(n)$ is not in $O(n)$ either. \n\n{\\bf (B)} Let us prove that $S(n)$ is in $O(n^3)$. \nLet us pick the {\\em witness} to check the definition of the Big-O Notation: \n$k = 1$, $C = 1$. \n\\begin{align}\n     & 1^2 + 2^2 + \\ldots + n^2 \\leq \\nonumber \\\\\n\\leq\\;\\; & n^2 + n^2 + \\ldots + n^2=  n \\cdot n^2 = 1 \\cdot n^3. \\nonumber\n\\end{align}\n\n{\\footnotesize\n\\begin{tabular}{|l|l|} \\hline\n{\\bf (A)} Answer $O(n^3)$ with explanation & 6 points \\\\ \\hline\n{\\bf (A)} Answer $O(n^3)$ without explanation & 3 points \\\\ \\hline\n{\\bf (A)} Suboptimal, but correct answer $O(n^4)$ & 2 points \\\\ \\hline\n{\\bf (B)} Correct witness to show inequality & 4 points \\\\ \\hline\n\\end{tabular}\n}\n\n\\vspace{10pt}\n{\\bf Question 4}\n{\\bf (A)} Yes, the system will always have solution (even if you replace the numbers $1,2,3$ by \nany other integers). Chinese Remainder theorem only needs that the modules \n($5,7,9$ in our case) are mutually prime.\n\n{\\bf (B)} The numbers satisfying $x \\equiv 1\\;(\\text{mod}\\,5)$ make this arithmetic progression: \n$$1,\\,6,\\,11,\\,16,\\,21,\\,26,\\,31,\\,\\ldots$$\nNumber $16$ in this progression is also congruent to $2$ (modulo $7$). The next number would be \n$16 + 35 = 51$ (because adding $5 \\cdot 7 = 35$ does not change the remainders, when \nwe divide by $5$ or by $7$.\\\\\nWe conclude that the following arithmetic progression satisfies the top two congruences\n(remainder $1$ modulo $5$ and remainder $2$ modulo $7$):\n$$16,\\,51,\\,86,\\,121,\\,156,\\,191,\\,\\ldots$$\nAnswer: $A = 16$, $B = 35$. \n\n{\\bf (C)} Observe that the first member of this arithmetic sequence ($A = 16$) gives the\nremainder $7$ when divided by $9$. The difference ($B = 35$) is congruent to $8$ and also to $-1$ \nmodulo $9$.\\\\\nWe conclude that by adding four differences, the result is\n$$16 + 4 \\cdot 35 \\equiv 16 + 4 \\cdot (-1) \\equiv 12 \\equiv 3\\;(\\text{mod}\\,9).$$\nThe first number from the progression (item (B)) that is also congruent to $3$ modulo $9$ is $156$. \nWe can add $5 \\cdot 7 \\cdot 9 = 315$ to this number, and all the remainders will stay the same:\n$$156,\\,471,\\,786,\\,1101,\\,1416,\\,1731,\\,2046,\\,\\ldots$$\nAnswer: $C = 156$, $D = 315$.\n\n{\\footnotesize\n\\begin{tabular}{|l|l|} \\hline\n{\\bf (A)} Reasoning that $5,7,9$ are pairwise mutual primes & 2 points \\\\ \\hline\n{\\bf (B)} $16+35k$ & 4 points \\\\ \\hline\n{\\bf (B)} $16$, but wrong difference & 2 points \\\\ \\hline\n{\\bf (C)} $156+315k$ & 4 points \\\\ \\hline\n{\\bf (C)} $156$, but wrong difference & 2 points \\\\ \\hline\n\\end{tabular}\n}\n\n\\vspace{10pt}\n{\\bf Question 5}\n{\\bf (A)} $\\beta = 0.011110_2 = 2^{-2} + 2^{-3} + 2^{-4} + 2^{-5}$.\\\\\n{\\bf (B)} $\\beta = \\frac{8 + 4 + 2 + 1}{2^{5}} = \\frac{15}{32}$.\\\\\n{\\bf (C)} $64\\alpha = 1000000_2 \\cdot \\alpha =$\\\\\n$= 011110.011110011110011110\\ldots_2$ (to multiply \nby $2^6 = 64$ we shift the point six positions to the right).\n{\\bf (D)} Subtract $\\alpha$ from $64\\alpha$: We get $011110_2$ (because all the \ndigits after the point are the same \\textendash{} they cancel out). We get the equation:\n$$64\\alpha - \\alpha = 63\\alpha = 011110_2 = 30_{10}$$\nTherefore $\\alpha = \\frac{30}{63} = \\frac{10}{21}$. We could also get the\nsame answer by finding the sum of an infinite geometric progression: \n$$30 \\cdot \\left( \\frac{1}{64} + \\frac{1}{64^2} + \\frac{1}{64^3} + \\ldots{} \\right).$$\n\n\n\\vspace{10pt}\n{\\bf Question 7} \n{\\bf (A)} In order to get the estimate of time complexity of the algorithm, \nconsider just the first three lines, where all the computations take place:\n\n\\vspace{3pt}\n{\\bf (1)} \\hspace{0.0in} For each assignment of $n$ truth values to $a_1,\\ldots,a_n$:\\\\\n{\\bf (2)} \\hspace{0.2in} For each of the $2n$ Boolean operators in $E$:\\\\\n{\\bf (3)} \\hspace{0.4in} Compute the value of that Boolean operator\n\n\\vspace{3pt}\nThe outer loop on Line 1 repeats $2^n$ times as there are exactly $2^n$ ways to assign true/false to \n$n$ variables. The inner loop on Line 2 repeats $2n$ times (once for every operation you have to evaluate\nin the expression). Line 3 takes just $1$ unit of time (this was given in the exercise). \nThe time complexity $T(n)$ is the product $(2n) \\cdot 2^n$; this (worst case) happens\nwhenever the expression is a tautology. If it is not a tautology, this algorithm will terminate earlier \n(and it will take less time). \n\n{\\bf (B)}\nThis $T(n) = 2n\\cdot{}2^n$ is in $O(2n\\cdot{}2^n)$, since any function\nis in the Big-O of itself (we can take $k = 1$ and $C = 1$). If we want, we can drop the multiplier $2$\nto simplify it slightly: $T(n)$ is in $O(n\\cdot{}2^n)$ (in this case $k = 1$ and $C = 2$).\\\\\nAnswer: $T(n)$ is in $O(g(n))$ where $g(n) = n\\cdot{}2^n$.\n\n\\vspace{10pt}\n{\\bf Question 8} \n{\\bf (A)} True: ``If $p + q$ is rational, then either both $p,q$ are rational, or both are irrational.''\\\\\nFrom the contrary, if $p$ is rational and $q$ is irrational, then $(p + q) - p = q$ should be rational, \nwhich is a contradiction. Same thing happens, if $p$ is irrational and $q$ is rational. \n\n{\\bf (B)} False: ``If $pq$ is rational, then either both $p,q$ are rational, or both are irrational.''\\\\\nWe can take $p = 0$ and $q = \\sqrt{2}$; then $pq = 0$ is rational, also $p$ is rational, but $q$ is irrational. \n \n{\\bf (C)} True: ``If $p^2$ and $q^2$ are both rational, then the product $(p+q)(p-q)$ is rational.''\\\\\nDenote the two rational numbers by $\\alpha = p^2$ and $\\beta = q^2$. Then their difference is \nalso a rational number: $\\alpha - \\beta = p^2 - q^2 = (p+q)(p-q)$. \n\n{\\bf (D)} True: ``If $p^3$ and $p^5$ are both rational, then $p$ is rational.''\\\\\nIf $p = 0$ then all $p$, $p^3$ and $p^5$ are rational.\\\\\nIf $p \\neq 0$, then denote the non-zero rational numbers $\\alpha = p^3$ and $\\beta = p^5$. \nThen their ratio $\\frac{\\beta}{\\alpha} = \\frac{p^5}{p^3} = p^2$ is also rational. \nFinally, if we divide $\\alpha = p^3$ by the rational $p^2$, we get that also $p$ is rational \n(as a fraction of two rational numbers). Shortly: $p = p^1 = p^{2 \\cdot 3 - 5} = \\frac{ \\alpha \\cdot \\alpha}{\\beta}$. \n\n{\\bf (E)} False: ``If $pq$ and $p+q$ are both rational, then $p$ and $q$ are both rational.''\\\\\nConsider two irrational numbers $p = 1 + \\sqrt{2}$ and $q = 1 - \\sqrt{2}$. Then $p + q = 2$ and\n$pq = (1 + \\sqrt{2})(1 - \\sqrt{2}) = 1 -2 = -1$, i.e.\\ the sum and the product are both rational numbers.\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "0716450df5e95475bd9ccfa2bc83858b4ff73288", "size": 20849, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/site/discrete-spring2020/questionbase/midterm.tex", "max_stars_repo_name": "kapsitis/math", "max_stars_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/site/discrete-spring2020/questionbase/midterm.tex", "max_issues_repo_name": "kapsitis/math", "max_issues_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-20T03:40:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T21:50:18.000Z", "max_forks_repo_path": "src/site/discrete-spring2020/questionbase/midterm.tex", "max_forks_repo_name": "kapsitis/math", "max_forks_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.16563147, "max_line_length": 125, "alphanum_fraction": 0.6690009113, "num_tokens": 7017, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.8519528057272543, "lm_q1q2_score": 0.4426076478722178}}
{"text": "\n\\chapter{System architecture of HyCube - a distributed hash table based on a variable metric}\n\\label{sec:hycubeArchitecture}\n\nThis chapter presents the routing architecture of \\emph{HyCube} - a distributed hash table system based on a hierarchical hypercube geometry. Sections \\ref{sec:hycubeHierarchicalHypercube} and \\ref{sec:hycubeRoutingTables} introduce the hierarchical hypercube concept and describe the structure of routing tables maintained by nodes. Section \\ref{sec:routing} presents the basic routing algorithm, and the subsequent sections present various optimizations of the routing algorithm. The optimizations of the basic routing algorithm include the use of a variable routing metric (defining distances between nodes) adopting Steinhaus transform (Section \\ref{sec:metric}) - the routing metric is modified by nodes on routes in a way resulting in a very high degree of flexibility in next hop selection (and this a very high level of resilience to node failures), preserving the routing efficiency of the basic algorithm. The concepts presented in this document have been published in \\cite{hycubePpam2009} and \\cite{hycubeICSReportFeb2013}.\n\n\n\n\n\n\\section{Hierarchical hypercube geometry}\n\\label{sec:hycubeHierarchicalHypercube}\n\nThe routing geometry of \\emph{HyCube} is a combination of the tree geometry and the hypercube geometry. It is similar to \\emph{Plaxton mesh} \\cite{plaxton1}, \\cite{plaxton2}, but nodes are also logically located in vertices of a $d$-dimensional hierarchical hypercube. A hierarchical hypercube is a hypercube whose vertices are also (lower level) hypercubes. Vertices of the hypercubes at the lowest level are positions which may be assigned to nodes. \n\n\\begin{figure}\n\\centering\n\\includegraphics[scale=.6]{img/hh.pdf}\n\\caption{A hierarchical hypercube (3 dimensions and 2 levels of hierarchy)}\n\\label{fig:hierarchicalHypercube}\n\\end{figure}\n\nFigure \\ref{fig:hierarchicalHypercube} presents the structure of an exemplary hierarchical hypercube with 3 dimensions and 2 hierarchy levels. Node IDs are determined by their positions - the identifier of a node is a string of $d$-bit groups determining positions of the node in hypercubes at individual levels (starting with the hypercube at the highest level). The position in a hypercube at a particular level is a number built of bits corresponding to the positions of the node in the hypercube in individual dimensions. The length of the identifier equals $d \\cdot l$, where $d$ is the number of dimensions, and $l$ is the number of levels.\n\nThe hierarchical hypercube and the tree geometries are isomorphic. However, visualizing the structure as a hierarchical hypercube gives an idea of the spatial arrangement of nodes in a $d$-dimensional space - the numbers formed from bits corresponding to individual dimensions relate to the coordinates of the node in these dimensions in the system of coordinates with the center in point $0$. Thus, considering the ID space as a segment of $\\mathbb{Z}^d$ space ($\\mathbb{Z}$ denotes the set of integer numbers), the distance between nodes may be defined by any metric applicable to $\\mathbb{Z}^d$, or $\\mathbb{R}^d$ ($\\mathbb{R}$ - the set of real numbers) as $\\mathbb{Z}$ is a subset of $\\mathbb{R}$. However, the geometry of \\emph{HyCube} should be seen as a $d$-dimensional torus with the perimeter equal to $2^l$ in each dimension (the set of coordinates in each dimension is treated as on a ring). That means that after the point $2^l-1$, point $0$ is located, and all arithmetic is done modulo $2^l$. This fact is important in determining distances between nodes - in every dimension the distance is determined like on a ring - it is the shorter of the distances in either direction.\n\nIn \\emph{HyCube}, the default number of dimensions is 4 and the number of levels is 32, resulting in a 128-bit address space (which allows avoiding conflicts of identifiers in majority of applications).\n\n\n\n\\section{Routing tables}\n\\label{sec:hycubeRoutingTables}\n\n\\subsubsection{Primary routing table.}\n\nThe primary routing table has the same structure as in \\emph{Plaxton mesh}. It has $l$ levels (the number of hierarchy levels), and, at each level, there are $2^d$ slots ($d$ - the number of dimensions). In the primary routing table of a node $X$, the slot $j$ at level $i$ ($i \\geq 0$) contains a reference to a node that is located in the same hypercube at level $i+1$ and in the hypercube corresponding to the number $j$ at level $i$ (lower level). At each level $i>0$, one slot corresponds to the hypercube in which the node $X$ is located - this slot is left empty, as the routing table contains a whole level corresponding to this hypercube.\n\nAn exemplary primary routing table for a 2-dimensional hierarchical hypercube with 6 hierarchy levels for node $X$ = 112013 is presented in Table \\ref{tab:rt1Example}. For clarity, groups of bits are represented by quaternary digits (base-4 numeral system). The digits in bold represent the sub-hypercube addresses corresponding to routing table slots at individual levels. The underlined digits represent the hypercubes corresponding to the routing table slots matching the hypercubes of node $X$ at individual levels.\n\n\\begin{table}\n\\scriptsize\n\\begin{center}\n%\\begin{tabular}{p{2cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|}\n\\begin{tabular}{c|c|c|c|c|}\n\t\\hhline{*{1}{~}*{4}{|-}|~|}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{0}}\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{1}}\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{2}}\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{3}}\t\t\t\t\t\t\t\t\t\t\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 5}}}\t\t\t\t\t\t\t\t& \\texttt{\\underline{\\textbf{0}}11033}\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\underline{\\textbf{2}}31011}\t\t\t\t\t\t\t& \\texttt{\\underline{\\textbf{3}}00232}\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 4}}}\t\t\t\t\t\t\t\t& \\texttt{\\underline{1\\textbf{0}}2223}\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\underline{1\\textbf{2}}1301}\t\t\t\t\t\t\t& \\texttt{\\underline{1\\textbf{3}}0001}\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 3}}}\t\t\t\t\t\t\t\t& \\texttt{\\underline{11\\textbf{0}}113}\t\t\t\t\t& \\texttt{\\underline{11\\textbf{1}}201}\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\underline{11\\textbf{3}}302}\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 2}}}\t\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\underline{112\\textbf{1}}01}\t\t\t\t\t\t\t& \\texttt{\\underline{112\\textbf{2}}03}\t\t\t\t\t\t\t& \\texttt{\\underline{112\\textbf{3}}12}\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 1}}}\t\t\t\t\t\t\t\t& \\texttt{\\underline{1120\\textbf{0}}3}\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\underline{1120\\textbf{2}}1}\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 0}}}\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n    \\hline\n\\end{tabular}\n\\end{center}\n\\caption{Exemplary primary routing table for node 112013 (for a 2-dimensional hierarchical hypercube with 6 hierarchy levels).}\n\\label{tab:rt1Example}\n\\end{table}\n\n\n\n\n\\subsubsection{Secondary routing table.}\n\nThe secondary routing table of a node $X$ contains nodes from adjacent hypercubes to the hypercube of node $X$ in each dimension, in both directions, at each level. An adjacent hypercube (at any level) is the one whose coordinate in one dimension is greater or smaller by 1 than the coordinate of the same level hypercube of $X$ (modulo $2^l$), and coordinates in all other dimensions are equal to those of $X$. The secondary routing table does not contain nodes in slots at the highest level, as hypercubes corresponding to them are covered by the primary routing table. Also, one of the adjacent hypercubes at each level in each dimension is covered by a primary routing table slot.\n\nThe secondary routing table increases the level of flexibility in the next hop selection. If the distance between nodes is defined by a metric in $\\mathbb{R}^d$ space, it is very likely that the secondary routing table contains nodes that are closer to any arbitrarily chosen node. Furthermore, it provides additional shortcut references when a message is routed to a node that is close in the $\\mathbb{R}^d$ space, but is not close in terms of the \\emph{Plaxton mesh} distance. With the use of the primary routing table, routing a message between nodes sharing a short ID prefix would require many steps of traversing the tree structure.\n\nTable \\ref{tab:rt2Example} presents an exemplary secondary routing table for node $X$ = 113012 (binary 01'01'11'00'01'10) - for a 2-dimensional hierarchical hypercube with 6 hierarchy levels. For clarity, in this example, the IDs are represented as binary numbers. Addresses of adjacent hypercubes corresponding to the routing table slots are marked in bold, and bits of addresses of adjacent hypercubes corresponding to the particular dimension are underlined - the numbers built of these bits are larger by 1 or smaller by 1 than the numbers formed of the corresponding bits of $X$. All other hypercube address bits (the remaining dimensions) are equal to the corresponding ones of $X$.\n\n\\begin{table}\n\\scriptsize\n\\begin{center}\n%\\begin{tabular}{p{1.7cm} p{2.7cm} p{2.7cm} p{2.7cm} p{2.7cm}}\n\\begin{tabular}{c|c|c|c|c|}\n    \\hhline{*{1}{~}*{4}{|-}|~|}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\multicolumn{2}{c|}{\\texttt{\\textbf{Dimension 0}}}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\multicolumn{2}{c|}{\\texttt{\\textbf{Dimension 1}}} \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n    \\hhline{*{1}{~}*{4}{|-}|~|}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t& $\\leftarrow$\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& $\\rightarrow$\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& $\\leftarrow$\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& $\\rightarrow$\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n\t\\hline\n    \\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 5}}}\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{-}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 4}}}\t\t& \\texttt{\\textbf{0\\underline{1}'0\\underline{0}}'01'01'00'11}\t\t\t\t\t\t\t& \\texttt{\\textbf{0\\underline{0}'0\\underline{0}}'10'01'10'10}\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{\\underline{1}1'\\underline{1}1}'10'01'00'11}\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{\\underline{0}1'\\underline{1}1}'00'10'10'01}\t\t\t\t\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 3}}}\t\t& \\texttt{\\textbf{0\\underline{1}'0\\underline{1}'1\\underline{0}}'10'01'00}\t\t\t\t& \\texttt{\\textbf{0\\underline{0}'0\\underline{0}'1\\underline{0}}'11'01'01}\t\t\t\t\t\t\t& \\texttt{\\textbf{\\underline{0}1'\\underline{0}1'\\underline{0}1}'11'01'01}\t\t\t\t\t\t\t& \\texttt{\\textbf{\\underline{0}1'\\underline{1}1'\\underline{0}1}'01'00'01}\t\t\t\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 2}}}\t\t& \\texttt{\\textbf{0\\underline{1}'0\\underline{1}'1\\underline{0}'0\\underline{1}}'11'10}\t& \\texttt{\\textbf{0\\underline{1}'0\\underline{1}'1\\underline{1}'0\\underline{1}}'01'01}\t\t\t\t& \\texttt{\\textbf{\\underline{0}1'\\underline{0}1'\\underline{0}1'\\underline{1}0}'01'10}\t\t\t\t& \\texttt{\\textbf{\\underline{0}1'\\underline{0}1'\\underline{1}1'\\underline{1}0}'10'00}\t\t\t\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 1}}}\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \\texttt{\\textbf{0\\underline{1}'0\\underline{1}'1\\underline{1}'0\\underline{1}'0\\underline{0}}'10}\t& \\texttt{\\textbf{\\underline{0}1'\\underline{0}1'\\underline{0}1'\\underline{1}0'\\underline{1}1}'00}\t& \\texttt{\\textbf{\\underline{0}1'\\underline{0}1'\\underline{1}1'\\underline{0}0'\\underline{1}1}'10}\t\\\\\n\t\\multicolumn{1}{|c|}{\\texttt{\\textbf{Level 0}}}\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t& \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\\\n     \\hline\n\\end{tabular}\n\\end{center}\n\\caption{Exemplary secondary routing table for node 113012 (01'01'11'00'01'10) - for a 2-dimensional hierarchical hypercube with 6 hierarchy levels.}\n\\label{tab:rt2Example}\n\\end{table}\n\n\n\n\\subsubsection{Neighborhood set (closest neighbors set).}\n\n\nIn addition to the routing tables described above, nodes maintain sets of closest to them (according to the chosen metric) nodes existing in the system - called \\emph{neighborhood sets}. These sets may allow finding a next hop (routing/lookup), decreasing the distance left to the destination, even if there are no appropriate nodes in both routing tables. The closest neighbors sets are expected to increase the probability of delivering messages in the presence of node failures. The neighborhood sets have also very good properties for supporting joining and leaving procedures, as well as maintenance and recovery algorithms, and they help to keep the DHT consistent. Moreover, their existence is crucial for searching closest nodes for a given key, as well as for replicating resources, which will be discussed in detail in Chapters \\ref{sec:lookupSearch} and \\ref{sec:resourcesManagement}. In \\emph{HyCube}, the default size of the neighborhood set is 16.\n\n\n\n\n\n\n\n\n\\section{Basic routing algorithm}\n\\label{sec:routing}\n\nLet us consider routing a message from node $X$ to node $Y$. Every node $R$ along the route first checks if there is a reference to the destination node in its neighborhood set, in which case, the message is sent directly to that node. Otherwise, the routing tables are searched for an appropriate next hop - the node that shares at least one $d$-bit group longer prefix of ID with $Y$ (than with $R$) or shares the same number of $d$-bit groups of the ID but is closer to $Y$ than $R$ in terms of the chosen routing metric. The routing metric of \\emph{HyCube} is discussed in Section \\ref{sec:metric}. For the time being, let us assume that routing converges according to the Euclidean metric. The detailed algorithm is presented below:\n\n\\begin{enumerate}\n\n\\item Initially, the routing algorithm finds the slot in the primary routing table that corresponds to nodes sharing at least one group of $d$ bits longer prefix of ID with $Y$ than with the current node ($R$). In a hierarchical hypercube, this slot corresponds to a hypercube in which the destination node is located, at a lower level than the lowest-level hypercube containing both, the current and the destination node. If for the current node and $Y$, the common prefix length equals $i$, and the next $d$-bit group of the ID of $Y$ equals $j$, $j$-th routing table slot at level $l - 1 - i$ is used. If this slot is not empty, the message is routed to the node found in the slot - increasing the common prefix length with the destination node $Y$ by at least one $d$-bit group.\n\n\\item If no node is found in the appropriate primary routing table slot, nodes sharing the same prefix length with $Y$ as with $R$ (in terms of the number of bit groups), but closer to $Y$ in terms of the chosen metric, are also considered - both routing tables and the neighborhood set are checked. From the set of nodes found, the node sharing the longest prefix of the ID with $Y$ (number of $d$-bit groups) is chosen, and, if there are more than one such nodes, the node closest to $Y$ (according to the routing metric) is chosen for the next hop.\n\n\\end{enumerate}\n\nThe primary routing table supports routing based on extending the ID prefix (in terms of $d$-bit groups) - tree-based routing (\\emph{Plaxton mesh}), and the secondary routing table supports finding a closer node in any dimension - such nodes are likely to be closer to the destination node also in terms of the Euclidean metric. Both routing tables and the neighborhood set are used for determining the best possible next hop, to which the message is routed.\n\nIt can be shown that the expected route length equals $\\lceil\\log_{2^d} N\\rceil$ hops and, on average, $\\lceil\\log_{2^d} N\\rceil \\cdot (2^d-1)$ slots are populated in the primary routing table and $(\\lceil\\log_{2^d} N\\rceil - 1) \\cdot d$ in the secondary routing table ($N$ is the number of nodes in the network)\\footnote{Based on the assumption that nodes are uniformly distributed in the hierarchical hypercube}.\n\n\n\n\n\\subsubsection{Message TTL}\n\nTo limit the maximum number of hops for messages, every message contains the TTL information (determining the maximum number of hops) and the number of hops that the message already passed. The TTL value should be decremented, and the number of hops is incremented by every node along the route (including the initiating node) before passing it to the next hop. When the TTL falls below 0, after decrementing, the message should not be routed any further and be dropped.\n\n\n\n\\subsubsection{Acknowledging message delivery and detecting duplicates}\n\nOptionally, after receiving messages (DATA messages - sent at the application level), depending on configuration, nodes may send acknowledgments (DATA\\_ACK messages) confirming receiving of the messages (either directly to the sending node, or routed via the system to the message sender). When the sending node receives the DATA\\_ACK message, it knows that the original message was successfully received and processed, and, when no acknowledgment is received (timeout), the node might resend the message (automatic resending may also be configured - up to the defined maximum number of retries). In cases when the acknowledgment mechanism is implemented at the application level (beyond the scope of \\emph{HyCube}), the native \\emph{HyCube} mechanism may be switched off.\n\n\\emph{HyCube} also implements message duplicate detection. In case of receiving a message duplicate, the duplicate is dropped. Message duplicates may be received as a result of incorrect routing or network problems, or an ACK message not being delivered. Duplicates are detected based on the header of the message (the details are specified in Chapter \\ref{sec:protocol}).\n\n\n\n\n\n\n\\section{Number of dimensions versus number of levels}\n\nThe address (node identifiers) space should be large enough to prevent potential conflicts of identifiers (existence of two nodes with the same ID). The size of the address space in \\emph{HyCube} equals:\n\n\\begin{equation}\nN_{max} = 2^{d \\cdot l}\n\\end{equation}\n\n\\noindent\nwhich means that increasing the number of dimensions or the number of hierarchy levels would increase the number of possible identifiers that nodes may be assigned. However, the number or dimensions and levels of the hierarchical hypercube influences the system characteristics.\n\nAdding additional levels of hierarchy causes the address space to increase, but it also proportionally increases the number of routing table slots that nodes maintain. Moreover, the pessimistic route length would also increase, as in the pessimistic scenario, routing steps correspond to individual routing table levels. Nevertheless, the expected route length remains at the same level, because, on average, similar number of routing table slots would be populated (with high probability the lower-level slots are empty).\n\nIncreasing the number of dimensions, on the other hand, has a very strong impact on routing characteristics. Although the routing tables grow sharply with the increase of the number of dimensions, the routing algorithm is more specific in selecting next hops - in each routing step, the common prefix with the destination node ID is increased by a larger number of bits, maintaining the same pessimistic path length and decreasing the average path length. As the base of the logarithm (Equation \\ref{equ:expPathLenRT1}) grows exponentially, the expected path length is inversely proportional to the number of dimensions:\n\n\\begin{equation}\n\\label{equ:expPathLenRT1}\n\\log_{2^d} N = \\frac{1}{d} \\log_2 N\n\\end{equation}\n\n\\noindent\nHowever, the maintenance cost is significant, as the primary routing table size grows exponentially with the number of dimensions:\n\n\\begin{equation}\n\\log_{2^d} N \\cdot (2^d-1) = \\frac{\\log_{2} N \\cdot (2^d-1)}{d}\n\\end{equation}\n\nAt one extreme, when the number of dimensions is equal to the number of identifier bits (1 level of hierarchy), every node would maintain references to all other nodes in the system, and the routing table slots would correspond to all possible values of node identifiers. Increasing the number of dimensions may influence any algorithm used in the distributed hash table and may require adjusting the parameter values for the specified number of dimensions. That is why it is crucial to determine a reasonable value for the number of dimensions that would ensure good routing properties and reasonable sizes of the routing tables, while controlling the identifier length should be done by increasing/decreasing the number of hierarchy levels. Whenever the number of dimensions is changed, it should be verified again that the DHT algorithms parameters still have their optimal values.\n\n\n\n\n\n\n\n\n\n\n\\section{Routing table nodes selection}\n\\label{sec:HyCubeNodeSelection}\n\nThe routing table node selection technique used in \\emph{HyCube} is a variant of the LNS approach, which, at the same time, provides means to remove failed nodes from routing tables.\n\n\n\\subsubsection{LNS (liveness node selection) in HyCube}\n\\label{sec:HyCubeNodeSelectionLNS}\n\n\\emph{HyCube} uses a variant of LNS which bases the neighbor choice on node liveness information discovered locally, working together with a background process checking node's responsiveness. However, the \\emph{HyCube} LNS implementation does not calculate the liveness information based on the node's join and leave times. Every node periodically sends keepalive (PING) messages to all the nodes in its routing tables and updates the stored nodes' liveness values. The value is increased when the node responds to the PING message (sending a PONG message), and is decreased if the keepalive response is not received (timeout). The initial liveness value (new nodes) is defined by the system parameter $L_{init}$, and the values are updated as follows:\n\n\\begin{equation}\nL = L_{prev} \\cdot p + (1-p) \\cdot L_{max}\n\\end{equation}\n\n\\noindent\nif the keepalive confirmation (PONG message) was received, or:\n\n\\begin{equation}\nL = L_{prev} \\cdot p\n\\end{equation}\n\n\\noindent\nwhen the keepalive fails (no PONG message is returned). $L_{prev}$ is the previous value of liveness, $L$ is the new, updated liveness value, $L_{max}$ and $p$ are system parameters. When $L$ falls below the threshold value $L_{deactivate}$ (system parameter), the node is marked as deactivated and is not used in the routing procedure until $L$ falls below the threshold value $L_{remove}$ (parameter), in which case the node is permanently removed from routing tables, or until $L$ reaches above $L_{deactivate}$ again. Whenever the value of $L$ is below the value of the parameter $L_{replace}$, when possible, the current node in the routing table slot is replaced by a new node, whose value $L$ is then given the initial value $L_{init}$. The value of $L$ for any node removed from the routing table should however be stored by nodes for some time to prevent replacing new nodes that temporarily fall below $L_{replace}$ with nodes that were permanently unresponsive. The values $0 < p < 1$ (update coefficient), $L_{deactivate}$, $L_{replace}$ and $L_{remove}$ determine the sensitivity of the algorithm, and $L_{max}$ defines the maximum value of $L$. This technique provides a good way to keep long-living responsive nodes in routing tables and eliminate failed or overloaded nodes that are not able to handle requests. Reasonable values of $p$, $L_{deactivate}$, $L_{replace}$ and $L_{remove}$ should be chosen to prevent the algorithm from removing nodes from routing tables in case of temporary delays in sending responses by nodes, but still, to be able to efficiently remove failed nodes. If $L_{max} = 2$, the values of $L_{init} = 1.5$, $p = 0.5$, $L_{deactivate} = 1$, $L_{replace} = 0.5$ and $L_{remove} = 0.05$ are good defaults as they allow avoiding failed paths due to temporary nodes' unresponsiveness, at the same time allowing unresponsive nodes to be replaced by new nodes. Using these default values would cause deactivating nodes after a single failed keep-alive, however, not replacing/removing them immediately. The parameter values (as well as the keep alive interval) may be fine-tuned depending on the system characteristics. The flexibility in next hop selection guaranteed by \\emph{HyCube} ensures that no significant increase in failed paths rate, nor the average path length, is observed even if large portions of nodes temporarily do not respond to keep-alive messages and are deactivated.\n\n\n\n\n\\subsubsection{\\emph{HyCube} mixed mode node selection}\n\nThe LNS technique described above allows replacing a routing table node only when its value of $L$ drops below $L_{replace}$ (or when $L$ reaches $L_{remove}$, in which case the node is removed). In some cases, however, it would be desirable to take another criterion (or criteria) into account, like for example proximity or any application specific measure. To achieve that, the condition $L < L_{replace}$ may be relaxed, and the neighbor selection could be based on a function measuring both factors - the liveness and the second factor (algorithm-specific). The liveness fulfillment factor may be defined as follows:\n\n\\begin{equation}\n\tFact_{L} = \\left|\\frac{L - L_{replace}}{L_{replace}}\\right|^{e_L} \\cdot \\mathop{\\mathrm{sgn}}(L - L_{replace})\n\\end{equation}\n\n\\noindent\nwhere the exponent $e_L$ determines the exponential growth of $Fact_{L}$ depending on the difference $L - L_{replace}$. Depending on the algorithm, this factor may be used to calculate overall criteria fulfillment at a node level, improvement of the criteria fulfillment for a new node, relative to current node(s), or may be used in calculating the quality function value for a set of nodes (for example for the neighborhood set). An exemplary neighbor selection criterion at a node level might be a weighted sum of two factors:\n\n\\begin{equation}\n\tQ = \\alpha \\cdot Fact_{L} + \\beta \\cdot Fact_{X}\n\\end{equation}\n\n\\noindent\nwhere $Fact_{X}$ may be any neighbor selection algorithm specific function.\n\n\n\n\n\n\n\n\\section{Prefix mismatch heuristic}\n\\label{sec:pmh}\n\nIn the final part of a route, when the message is already relatively close to the destination node, the routing algorithm may omit some nodes that are close to the destination, but do not share the same long or longer prefix of ID with the destination node than with the current node. This phenomenon becomes more significant when a multidimensional metric is used. That is why, like in \\cite{pastry}, \\emph{HyCube} uses a heuristic switching to routing based only on the distance left, when a message is already in vicinity of the destination. Nodes should therefore be able to determine how close the message is to the destination in relation to the density of nodes in the space. In \\emph{HyCube}, before choosing the next hop, each node checks if the distance to the destination is shorter than the average distance to the nodes in the neighborhood set multiplied by the factor $\\lambda$: \n\n\\begin{equation}\nd_{dest} < \\mathop{\\mathrm{avg}}(d_{neigh}) \\cdot \\lambda\n\\end{equation}\n\n\\noindent\nIf this condition is satisfied, all further nodes on the route are chosen based only on their distance to the destination node - they might not share the same long or longer prefix of the identifier. All nodes from both routing tables and the neighborhood set are checked and the closest node is chosen for the next hop.\n\nThe prefix mismatch heuristic may be also enabled, when no next hop is found with routing based on extending the common prefix length with the destination node. This behavior may be configured by changing a system parameter value. In many cases, the number of neighborhood set nodes matching the destination is much larger if the selection is based only on the distance. Obeying the prefix condition is a much stronger constraint on the next hops, and may cause more failed paths, especially in the presence of many node failures. Thus, although the path length might increase, by default, \\emph{HyCube} switches to routing based only on the distance left whenever no next hop is found. To maintain routing convergence, the prefix mismatch heuristic is followed by all subsequent nodes along the path.\n\nThe greater is the value of $\\lambda$, the longer parts of routes will be determined based only on the distance left. The value should be large enough to ensure high probability of message delivery. However, too large values of $\\lambda$ could cause an increase in path lengths. The performed simulations indicated that the value $\\lambda = 1.5$ ensures good static resilience, maintaining the path lengths at a low level.\n\n\n\n\n\n\\section{Routing metric}\n\\label{sec:metric}\n\nIn DHT systems, distances between pairs of nodes are defined by a certain metric, and the routing converges according to this metric. The choice of the metric has a great impact on the average route length and the probability of message delivery. \\emph{HyCube} uses a variable multi-dimensional metric adopting the Steinhaus transform, described in this section. It was confirmed during simulations that such an approach allows reaching a very high level of resilience to node failures and short pessimistic and average routing/lookup paths.\n\n\n\n\n\\subsection{Steinhaus transform}\n\\label{sec:steinhaus}\n\nIn \\cite{nearNeighSearchMetrSpDim} and \\cite{geomCutsMetrics}, the authors present the Steinhaus transform. The terminology comes from the fact that this distance was used in biological problems for the study of biotopes \\cite{certDistSetsCorrDistOfFunc}. The theorem presented says that if $D$ is a metric on a set $X$, $D'$ is also a metric on $X$ for any $a \\in X$, where:\n\n\\begin{equation}\n\\label{equ:steinhaus}\nD'(x,y) = \\frac{2D(x,y)}{D(x,a) + D(y,a) + D(x,y)}\n\\end{equation}\n\nThe default base metric used in \\emph{HyCube} ($D$ in the equation above) is the Euclidean metric. Applying a metric with the Steinhaus transform to every route, setting the value of $a$ to the ID of the source node, causes the next hops to be chosen in such a way that they are closer to the destination node and more distant from the source node. Such an approach increases the expected number of neighborhood set nodes to which messages may be routed in each routing step - although some closer nodes (according to metric $D$) might be considered more distant when the Steinhaus transform is applied, it allows sending messages using more roundabout routes, while still being convergent to the destination node.\n\nOne important remark should be made regarding the Steinhaus transform. In the case when $x = y = a$, Equation \\ref{equ:steinhaus} does not have a value (division by zero). Therefore, the value of the distance should be considered 0 if $x = y$, regardless of the value of $a$.\n\n\n\n\\subsection{Variable metric adopting Steinhaus transform}\n\\label{sec:varSteinhaus}\n\nThe use of the Steinhaus transform yields very good routing parameters and very high resilience to node failures for networks containing relatively few nodes. However, for networks containing much more nodes (denser), in final parts of routes, the addend $D(x,a)$ of the denominator in Equation \\ref{equ:steinhaus} (where $x$ is the current node), has less influence on the value of the distance as its changes in individual steps are very small compared to the value of the entire denominator. Thus, the more nodes in the network, the lesser is the influence of the Steinhaus transform on routing. However, a certain modification can be introduced - a variable metric adopting the Steinhaus transform, where point $a$ would be changed by intermediate nodes along routes. The value of $a$ would initially be set to the source node $ID$, and subsequent nodes, before choosing the next hops, would check whether they are closer (in terms of the Euclidean metric) to the destination than the current point $a$. In such a case, point $a$ would be updated - would be given the value of the current node. Such a way of changing point $a$ ensures that the routing is convergent to the destination (there will be no cycles on routes) and yields a very high level of flexibility in the next hop selection along the whole route, regardless of the network size. It is easy to notice that whenever the Steinhaus point has the value of the current node ID, messages may be passed to any other node, decreasing the Steinhaus distance left to the destination. With great probability the node closest to the destination in terms of the Euclidean metric is chosen. It may however not be a node that is closer (Euclidean) to the destination. Nevertheless, in such a case, the subsequent next hop selections would be more restrictive and converge to the destination faster. The expected route length is still proportional to $\\sqrt[d]{N}$, and, owing to the increase in the flexibility in the next hop selection, the resilience to node failures reached is very high.\n\nIt should be noted that whenever the Steinhaus point is equal to any of the node IDs between which the distance is measured, the distance value equals 1, regardless of the second argument value:\n\n\\begin{equation}\nD'(x,y)\\bigg|_{a=x} = \\frac{2D(x,y)}{D(x,x) + D(y,x) + D(x,y)} = 1\n\\end{equation}\n\n\\begin{equation}\nD'(x,y)\\bigg|_{a=y} = \\frac{2D(x,y)}{D(x,y) + D(y,y) + D(x,y)} = 1\n\\end{equation}\n\n\\noindent\nWhen calculating distances from multiple nodes to the destination node, if the Steinhaus point is given the value of the destination node ID, it is impossible to differentiate the nodes, as all the distances are then equal to 1. The routing algorithm is not exposed to such a situation - the Steinhaus point value would be equal to the destination point only when the destination is already reached. However, any other algorithm using Steinhaus distances, modifying the Steinhaus point, should take that fact into account (e.g. search algorithm, described in Sec. \\ref{sec:lookupSearch}).\n\n\n\nTo limit the average route length increase caused by employing the variable Steinhaus metric, one more modification was introduced - the Steinhaus transform should be used only when the prefix mismatch heuristic is already applied. The use of the Steinhaus transform is the most important when the message is already in the proximity of the destination node, and the probability of finding the next hop in the neighborhood set drops sharply with the use of the Euclidean metric. If the Steinhaus transform is used only when the prefix mismatch heuristic is applied, it is enabled when the message gets close to the destination, or when no next hop is found (which would also enable the prefix mismatch heuristic, allowing the Steinhaus transform to be used). Such a modification decreases the average path length, preventing messages from being routed to more distant areas (according to the Euclidean metric) in initial steps, when the average hop distances are much larger. Despite a significant decrease of the average path length, the modification did not cause any static resilience decrease.\n\n\n\n\n\n\n\\section{Euclidean distance versus Steinhaus distance - re-routing using regular metric}\n\\label{sec:euclideanAfterSteinhaus}\n\nThe final steps of routing with the use of a metric with the Steinhaus transform applied may cause a message to be sent to a node that is more distant from the destination than it would be if the Steinhaus transform was not applied. Therefore, when, at some point, a node on a route cannot find the next hop in its routing tables and neighborhood set, it is possible that the route is ended in a point (node) that is not the closest one to the destination in terms of the Euclidean metric. For some applications, if the destination node itself cannot be reached, it is crucial to reach the closest possible node. Thus, \\emph{HyCube} introduces one more modification - when a message cannot be routed by a node, the node tries to route it again, based only on the Euclidean distance left to the destination. All consecutive next hops after that should be chosen in the same way. Such an approach will cause that, in the case the message is dropped, a relatively close node to the destination is reached. From the experiments (for a network containing 10'000 nodes, with 50\\% failed nodes, routing using only neighborhood sets), it appears that applying this phase in routing allows messages to be sent to a closer node in about 80\\% cases. Furthermore, this additional phase of routing also increases the resilience of the system to node failures.\n\nThere is, however, one drawback of such an approach - the failed path lengths (undelivered messages) may possibly increase due to re-routing with another metric after the next hop is not found. Nevertheless, messages usually get relatively close to the destination node, and, in most cases, only a small number of additional hops (if any) are performed.\n\n\n\n\n\n\n\\section {Uniform distribution of neighborhood set nodes}\n\\label{sec:uniformNSDistribution}\n\nThe neighborhood set should provide possibility to route messages regardless of the direction in which the destination node is located. Therefore, it is important that nodes in neighborhood sets be uniformly distributed in terms of directions. There might be a scenario where some nodes would have more closest neighbors in one direction and no or very few neighbors in other directions. In such a case, the nodes would not be able to route messages in all directions (using neighborhood sets). The issue becomes more important in the presence of node failures, when the number of matching next hops should be as large as possible. In a multi-dimensional space, it is not trivial to ensure uniform distribution of the closest neighbors set, ensuring that certain subset of these nodes would match any potential direction (message destination). Uniform distribution of nodes in terms of directions may be defined in a variety of ways, and many different algorithms may be employed to maximize this uniformity. Both, proximity and even distribution, should be considered, because ensuring uniform distribution of nodes in respect of directions may cause some more distant nodes to be included in neighborhood sets and pass over some closer nodes. The key is to maintain the good properties of neighborhood sets (as being the closest existing nodes), and to make these good properties valid regardless of the direction.\n\n\\emph{HyCube} adopts a simple technique for ensuring uniform distribution of neighborhood set nodes in respect of directions. The technique splits the space into fragments (orthants\\footnote{An \\emph{orthant} is the generalization (in $d$-dimensional Euclidean space) of a quadrant (2-dimensional space)} of the system of coordinates with the center at the address of the node whose neighborhood set is considered) and attempts to ensure that in each orthant, the number of nodes is the same. Within individual orthants, nodes are chosen based on their distances. Such a solution is very simple, efficient and does not require much computational overhead. \n\n\n\n\n\n\\section{Hypercube-aware next hop selection}\n\nWhen the routing algorithm cannot find a node sharing a longer ID prefix with the destination node than with the current node, a node sharing the same long prefix, but closer to the destination according to the chosen metric is selected as the next hop. When the message is routed within a hypercube corresponding to the common prefix length according to the distance only, it is completely independent of the hypercube hierarchy at lower levels. It is however possible to introduce one more criterion in next hop selection. If the message was routed to a node sharing the largest possible number of common bits in the first different digit (group of $d$ bits), this would be the node in the closest possible hypercube at a lower level. If there were more than one such nodes, the next hop would be then chosen by the remaining distance (among the nodes with the same number of common bits in the first different digit). Such an approach increases the probability of finding the next hop sharing longer prefix (in terms of entire bit groups) by the next node(s) on the path - with the support of secondary routing tables.\n\n\n\n\n\n\n\\section{Routing table slots overlapping}\n\\label{sec:rtOverlapping}\n\nHypercubes corresponding to slots of primary and secondary routing tables may contain nodes that are covered by a slot at a lower level in the secondary routing table. If multiple different routing table slots contain the same node, when the node fails, all these slots become unusable. That is why, ideally, the routing tables should contain references to different nodes for all such overlapping hypercubes.\n\nTo overcome the overlapping problem, for the secondary routing table, it is enough to consider a node as a candidate for a matching routing table slot only if the corresponding adjacent hypercube is the lowest-level hypercube containing that node (for individual dimensions and directions). That would ensure that no secondary routing table slot would contain nodes that are located in overlapping lower-level adjacent hypercubes.\n\nAs far as the primary routing table slots are concerned, it may also be easily verified whether a certain node is covered by a lower-level secondary routing table slot (let us denote by $Y$ its identifier, and by $X$ the ID of the node whose routing table is being considered). $X$ and $Y$ are in adjacent hypercubes at levels $l - 1 - j$ to $l - 1 - i$ if and only if all $k<i$ first digits ($d$-bit groups) of $X$ and $Y$ are equal, and $i$-th to $j$-th digits differ on one (the same for all these digits) bit - this bit corresponds to the dimension in which the two hypercubes are adjacent. $l$ is the number of levels, and $d$ is the number of dimensions of the hierarchical hypercube. If $l - 1 - j$ is smaller than the corresponding primary routing table level of $Y$, $l_{RT1}$, that means that $Y$ is located in an adjacent hypercube at a lower level than $l_{RT1}$ and is thus covered by a lower-level secondary routing table slot. There might also be a case that $Y$ is not in an adjacent hypercube in any dimension at any level - if the first different digit ($d$-bit group) of $X$ and $Y$ differs on more than one bit.\n\nThis modification, however, should not be applied to the neighborhood set, because the neighborhood set is crucial for maintaining high resilience and should always contain the closest nodes (as discussed in the previous sections). Thus, the neighborhood set might contain some nodes that are also included in routing tables. Furthermore, when considering a candidate for routing tables, no check whether the node is in the neighborhood set should be performed. The neighborhood set is continuously updated, and such a check might very soon be ``out-of-date'', while still having left the routing table slot empty. Therefore, due to its properties, the neighborhood set should be built independently from the routing tables.\n\n\n\n\n\n\n\n\n\n\n% ex: set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab fileformat=unix filetype=tex encoding=utf-8 fileencodings= fenc= spelllang=pl,en spell:\n\n", "meta": {"hexsha": "4f1014f5de6c8fc8072ca4a45c50e4dda275d338", "size": 42745, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/documentation/protocol_doc_tex/tex/hycube-architecture.tex", "max_stars_repo_name": "arturolszak/hycube", "max_stars_repo_head_hexsha": "e7dc0bc7ff5d7c1d406bfee952398515f3f6b6c8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-07-18T14:05:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-18T02:15:36.000Z", "max_issues_repo_path": "src/documentation/protocol_doc_tex/tex/hycube-architecture.tex", "max_issues_repo_name": "suhasagg/hycube", "max_issues_repo_head_hexsha": "e7dc0bc7ff5d7c1d406bfee952398515f3f6b6c8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2016-10-02T14:25:30.000Z", "max_issues_repo_issues_event_max_datetime": "2016-11-27T18:10:58.000Z", "max_forks_repo_path": "src/documentation/protocol_doc_tex/tex/hycube-architecture.tex", "max_forks_repo_name": "suhasagg/hycube", "max_forks_repo_head_hexsha": "e7dc0bc7ff5d7c1d406bfee952398515f3f6b6c8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-10T16:08:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-10T16:08:30.000Z", "avg_line_length": 118.4072022161, "max_line_length": 2426, "alphanum_fraction": 0.7648145982, "num_tokens": 10161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.442570993778553}}
{"text": "\\subsection{Performance metrics}\n\n    Most of our algorithms are supervised and multiclass. The most suitable performance metric is the test accuracy, basically the ratio between hits and tries. We also present some test intraclass metrics, such as class precision (the fraction of BP $k$ predicted documents that are correct, for some BP $k$) and class recall (the fraction of correct BP $k$ documents that were predicted, for some BP $k$). In general, we also present a test confusion matrix, which shows how many test documents were predicted in each class.\n", "meta": {"hexsha": "eedc5c2ce3a92d80c0a261975bfcebfdd7779f3c", "size": 561, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "a2_assignment/metrics.tex", "max_stars_repo_name": "lucasresck/machine-learning", "max_stars_repo_head_hexsha": "fd038632bf5c5d58a3e7ccf939b27b3d71ae648a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "a2_assignment/metrics.tex", "max_issues_repo_name": "lucasresck/machine-learning", "max_issues_repo_head_hexsha": "fd038632bf5c5d58a3e7ccf939b27b3d71ae648a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "a2_assignment/metrics.tex", "max_forks_repo_name": "lucasresck/machine-learning", "max_forks_repo_head_hexsha": "fd038632bf5c5d58a3e7ccf939b27b3d71ae648a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 140.25, "max_line_length": 526, "alphanum_fraction": 0.7896613191, "num_tokens": 116, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4425546843839258}}
{"text": "\\subsection{Measurement functions in \\tuner}\n\\label{sec:oracles}\nThis section describes our implementation of the measurement oracles used by \\tuner: \\textproc{CurvatureRange}, \\textproc{Variance}, and \\textproc{Distance}.\nWe design the measurement functions with the assumption of a negative log-probability objective; this is in line with typical losses in machine learning, e.g. cross-entropy for neural nets and maximum likelihood estimation in general.\nUnder this assumption, the Fisher information matrix---i.e.\\ the expected outer product of noisy gradients---approximates the Hessian of the objective~\\citep{johnfisherinfo2016,pascanu2013revisiting}. This allows for measurements purely being approximated from minibatch gradients with overhead linear to model dimensionality.\nThese implementations are not guaranteed to give accurate measurements.\nNonetheless, their use in our experiments in Section~\\ref{sec:experiments} shows that they are sufficient for \\tuner to outperform the state of the art on a variety of objectives. We also refer to Appendix~\\ref{sec:practical_impl} for details on zero-debias~\\citep{kingma2014adam}, slow start~\\citep{schaul2013no} and smoothing for curvature range estimation.\n\n%\\begin{minipage}{0.37\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\caption{\\small Curvature range}\n%\t\\begin{algorithmic}\n%\t\t\\State \\textbf{state: } $h_{\\max}$, $h_{\\min}$, $h_i, \\forall i \\in\\{1,2,3,...\\}$\n%\t\t\\Function{CurvatureRange}{gradient $g_t$, $\\beta$}\n%\t\t\t\\State $h_t \\gets \\| g_t \\|^2$\n%\t\t\t\\State $h_{\\max,t}\\!\\!\\gets\\!\\!\\!\\!\\!\\!\\!\\max\\limits_{t - w \\leq i \\leq t}\\!h_i$, $h_{\\min,t}\\!\\!\\gets\\!\\!\\!\\!\\!\\!\\!\\min\\limits_{t - w \\leq i \\leq t}\\!h_i$\n%\t\t\t\\State $h_{\\max} \\gets \\beta \\cdot h_{\\max} + (1 - \\beta) \\cdot h_{\\max,t}$ %\\hfill Smoothed largest curvature.\n%\t\t\t\\State $h_{\\min} \\gets \\beta \\cdot h_{\\min} + (1 - \\beta) \\cdot h_{\\min,t}$ %\\hfill Smoothed smallest curvature.\n%\t\t\t\\Return $h_{\\max}$, $h_{\\min}$\n%\t\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:curv_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n%\\begin{minipage}{0.315\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\setstretch{1.5}\n%\t\\caption{\\small Gradient variance}\n%\t\\begin{algorithmic}\n%\t\\State \\textbf{state: } $\\overline{g^2}\\gets0$, $\\overline{g}\\gets0$\n%\t\\Function{Variance}{gradient $g_t$, $\\beta$}\n%\t\t\\State $\\overline{g^2}\\gets\\beta \\cdot \\overline{g^2} + (1 - \\beta) \\cdot g_t \\odot g_t$\n%\t\t\\State $\\overline{g}\\gets\\beta \\cdot \\overline{g} + (1 - \\beta) \\cdot g_t$\n%\t\t\\Return $\\| \\overline{g^2} - \\overline{g}^2 \\|_1$ %\\hfill Sum of elements in the vect\n%\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:var_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n%\\begin{minipage}{0.3\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\setstretch{1.25}\n%\t\\caption{\\small Distance to opt.}\n%\t\\begin{algorithmic}\n%\t\\State \\textbf{state: } $\\overline{\\|g\\|}\\gets0$, $\\overline{h}\\gets0$\n%\t\t\\Function{Distance}{gradient $g_t$, $\\beta$}\n%\t\t\\State $\\overline{\\|g\\|}\\gets \\beta \\cdot \\overline{\\|g\\|} + (1 - \\beta) \\cdot \\|g_t\\|$\n%\t\t\\State $\\overline{h} \\gets \\beta \\cdot \\overline{h} + (1 - \\beta) \\cdot \\| g_t \\|^2$\n%\t\t\\State $D \\gets \\beta \\cdot D + (1 - \\beta) \\cdot \\overline{\\|g\\|} /\\overline{h}$\n%\t\t\\Return $D$\n%\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:dist_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n\n\\paragraph{Curvature range}\nLet $g_t$ be a noisy gradient, we estimate the curvatures range in Algorithm~\\ref{alg:curv_func}. We notice that the outer product $g_tg_t^T$ has an eigenvalue $h_t=\\| g_t \\|^2$ with eigenvector $g_t$. Thus under our negative log-likelihood assumption, we use $h_t$ to approximate the curvature of Hessian along gradient direction $g_t$. Note here we use empirical Fisher $g_tg_t^T$ instead of Fisher information matrix. Empirical Fisher is typically used in practical natural gradient methods~\\citep{martens2014new, roux2008topmoumoute, duchi2011adaptive}. For practically efficient measurement, we use the empirical Fisher as a coarse proxy of Fisher information matrix which approximates the Hessian of the objective. \nSpecifically in Algorithm~\\ref{alg:curv_func}, we maintain $h_{\\min}$ and $h_{\\max}$ as running averages of extreme curvature $h_{\\min, t}$ and $h_{\\max, t}$, from a sliding window of width 20\\footnote{We use window width 20 across all the models and experiments in our paper. We refer to Section~\\ref{sec:experiments} for details on selecting the window width}.\nAs gradient directions evolve, we estimate curvatures along different directions. Thus $h_{\\min}$ and $h_{\\max}$ capture the curvature variations.\n\n%\\vspace{-0.5em}\n\\paragraph{Gradient variance}\nTo estimate the gradient variance in Algorithm~\\ref{alg:var_func}, \nwe use running averages $\\overline{g}$ and $\\overline{g^2}$ to keep track of $g_t$ and $g_t \\odot g_t$, the first and second order moment of the gradient. \nAs $\\Var(g_t) = \\E{g_t^2} - \\E{g_t} \\odot \\E{g_t}$, we estimate the gradient variance $C$ in \\eqref{equ:noisy_min} using $C=\\bm{1}^T\\!\\!\\cdot(\\overline{g^2} - \\overline{g}^2)$. %To get stable estimates, we use $C$, the running average of $C_t$ as the quantity representing gradient variance.\n\n%\\vspace{-0.25em}\n\\paragraph{Distance to optimum}\nIn Algorithm~\\ref{alg:dist_func}, we estimate the distance to the optimum of the local quadratic approximation.\nInspired by the fact that $\\| \\nabla f(\\mat{x}) \\| \\leq \\| \\mat{H} \\| \\| \\mat{x} - \\mat{x}^{\\star}\\|$ for a quadratic $f(x)$ with Hessian $\\mat{H}$ and minimizer $\\mat{x}^{*}$,  \nwe first maintain $\\overline{h}$ and $\\overline{\\|g\\|}$ as running averages of curvature $h_t$ and gradient norm $\\| g_t \\|$. Then the distance is approximated using $\\overline{\\|g\\|} / \\overline{h}$. %according to inequality $\\| \\nabla f(\\mat{x}) \\| \\leq \\| \\mat{H} \\| \\| \\mat{x} - \\mat{x}^{\\star}\\|$.\n\n%\\begin{minipage}{0.37\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\caption{\\small Curvature range}\n%\t\\begin{algorithmic}\n%\t\t\\State \\textbf{state: } $h_{\\max}$, $h_{\\min}$, $h_i, \\forall i \\in\\{1,2,3,...\\}$\n%\t\t\\Function{CurvatureRange}{gradient $g_t$, $\\beta$}\n%\t\t\t\\State $h_t \\gets \\| g_t \\|^2$\n%\t\t\t\\State $h_{\\max,t}\\!\\!\\gets\\!\\!\\!\\!\\!\\!\\!\\max\\limits_{t - w \\leq i \\leq t}\\!h_i$, $h_{\\min,t}\\!\\!\\gets\\!\\!\\!\\!\\!\\!\\!\\min\\limits_{t - w \\leq i \\leq t}\\!h_i$\n%\t\t\t\\State $h_{\\max} \\gets \\beta \\cdot h_{\\max} + (1 - \\beta) \\cdot h_{\\max,t}$ %\\hfill Smoothed largest curvature.\n%\t\t\t\\State $h_{\\min} \\gets \\beta \\cdot h_{\\min} + (1 - \\beta) \\cdot h_{\\min,t}$ %\\hfill Smoothed smallest curvature.\n%\t\t\t\\Return $h_{\\max}$, $h_{\\min}$\n%\t\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:curv_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n%\\begin{minipage}{0.315\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\setstretch{1.5}\n%\t\\caption{\\small Gradient variance}\n%\t\\begin{algorithmic}\n%\t\\State \\textbf{state: } $\\overline{g^2}\\gets0$, $\\overline{g}\\gets0$\n%\t\\Function{Variance}{gradient $g_t$, $\\beta$}\n%\t\t\\State $\\overline{g^2}\\gets\\beta \\cdot \\overline{g^2} + (1 - \\beta) \\cdot g_t \\odot g_t$\n%\t\t\\State $\\overline{g}\\gets\\beta \\cdot \\overline{g} + (1 - \\beta) \\cdot g_t$\n%\t\t\\Return $\\| \\overline{g^2} - \\overline{g}^2 \\|_1$ %\\hfill Sum of elements in the vect\n%\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:var_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n%\\begin{minipage}{0.3\\textwidth}\n%\\algrenewcommand\\alglinenumber[1]{\\scriptsize #1:}\n%\t\\begin{algorithm}[H]\n%\t\\scriptsize\n%\t\\setstretch{1.25}\n%\t\\caption{\\small Distance to opt.}\n%\t\\begin{algorithmic}\n%\t\\State \\textbf{state: } $\\overline{\\|g\\|}\\gets0$, $\\overline{h}\\gets0$\n%\t\t\\Function{Distance}{gradient $g_t$, $\\beta$}\n%\t\t\\State $\\overline{\\|g\\|}\\gets \\beta \\cdot \\overline{\\|g\\|} + (1 - \\beta) \\cdot \\|g_t\\|$\n%\t\t\\State $\\overline{h} \\gets \\beta \\cdot \\overline{h} + (1 - \\beta) \\cdot \\| g_t \\|^2$\n%\t\t\\State $D \\gets \\beta \\cdot D + (1 - \\beta) \\cdot \\overline{\\|g\\|} /\\overline{h}$\n%\t\t\\Return $D$\n%\t\\EndFunction\n%\t\\end{algorithmic}\n%\t\\label{alg:dist_func}\n%\t\\end{algorithm}\n%\\end{minipage}\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "8c387d51c88267e15fb06c3e3454772291b0c342", "size": 8178, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "oracles.tex", "max_stars_repo_name": "mitliagkas/dshs", "max_stars_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "oracles.tex", "max_issues_repo_name": "mitliagkas/dshs", "max_issues_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "oracles.tex", "max_forks_repo_name": "mitliagkas/dshs", "max_forks_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.5915492958, "max_line_length": 721, "alphanum_fraction": 0.6848862803, "num_tokens": 2906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.44255468383341373}}
{"text": "%% LyX 2.3.5.2 created this file.  For more info, see http://www.lyx.org/.\r\n%% Do not edit unless you really know what you are doing.\r\n\\documentclass[conference]{IEEEtran}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{fontspec}\r\n\\usepackage{float}\r\n\\usepackage{graphicx}\r\n\r\n\\makeatletter\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\r\n%% Because html converters don't know tabularnewline\r\n\\providecommand{\\tabularnewline}{\\\\}\r\n%% A simple dot to overcome graphicx limitations\r\n\\newcommand{\\lyxdot}{.}\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\r\n\\IEEEoverridecommandlockouts\r\n% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.\r\n\\usepackage{cite}\r\n\\usepackage{amsfonts}\\usepackage{algorithmic}\r\n\\usepackage{textcomp}\r\n\\usepackage{xcolor}\r\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\r\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\r\n\r\n\\makeatother\r\n\r\n\\begin{document}\r\n\\title{ELL409 Assignment 1}\r\n\\author{\\IEEEauthorblockN{Harman Singh} \\and \\IEEEauthorblockN{Aayush Srivastava} }\r\n\\maketitle\r\n\\begin{abstract}\r\nSolutions for Assignment 3 of ELL409. \r\n\\end{abstract}\r\n\r\n\r\n\\section{Q1 SVM on health data}\r\n\r\nWe first ran PCA on the health data which has 3 features and ran SVM\r\nto classify into the 2 classes.Then to make the decision boundaries,\r\nwe changed the problem as suggested on piazza and took the first 2\r\nprincipal components of the data to. We fit SVM's with multiple kernels\r\nand plot the decision boundaries. We also implement the SMO algorithm\r\nand compare its performance, training time with libSVM.\r\n\r\n\\subsection{Running SVM with different Kernels}\r\n\r\n\\subsection{Decision Boundaries}\r\n\r\nDecision boundaries for all kernels (Linear, RBF, polynomia with different\r\ndegrees) is shown in Figure \\ref{fig:Question1_fig1}. These figures\r\ncorrespond to the optimal values of 'C' and gamma (in case of RBF)\r\nkernel. The yellow dots signify that they are support vectors. \r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.9\\columnwidth]{images/Q1\\lyxdot 3supportvecs_decision}\r\n\\par\\end{centering}\r\n\\caption{Decision boundary for various kernels \\label{fig:Question1_fig1}}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Decision Boundaries with removed support vectors}\r\n\r\nWe removed the old support vectors and then ran the SVM again to fit\r\nit to the remaining dataset. Our decision boundaries are as shown\r\nin Figure \\ref{fig:Question1_fig2}. The yellow marked points are\r\nthe new support vectors. As we can see these are much smaller in number.\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.9\\columnwidth]{images/Q1\\lyxdot 3without_supportvecs_decision}\r\n\\par\\end{centering}\r\n\\caption{Decision boundary for various kernels when old support vectors are\r\nremoved \\label{fig:Question1_fig2}}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Implementing SMO algorithm (bonus part)}\r\n\r\nWe referred to Platt's original paper, P.S.Sastri's tutorial and CS231\r\nnotes and implemented the SMO algorithm in python itself. The performance\r\nof our code was comparable to the sklearn's LIBSVM implementation\r\nin terms of accuracy but time taken by our code was larger.\r\n\\begin{itemize}\r\n\\item The time taken by our code was more than that of the LIBSVM as shown\r\nin Figure \\ref{fig:Question1_fig3} a) and it continues to increase\r\nas the data scales.\r\n\\item The accuracy of LIBSVM and our implementation of SMO isplotted and\r\nwe can see that for a large enough dataset they are nearly equal to\r\neach other (Figure \\ref{fig:Question1_fig3} b))\r\n\\end{itemize}\r\nWe feel that ours is not the most optimal implementation of the algorithm\r\nand many more techniques can be used for eg in choosing the 2 vectors\r\nat each step and in other parts of the code. We also feel that LIBSVM\r\nmay have been implemented in C/C++ which makes it much faster than\r\nsome parts of our code in Python (like loops etc) which cannot be\r\nvectorized using numpy arrays and hence have to suffer the slow-ness\r\nof python.\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.45\\columnwidth]{images/Q1\\lyxdot 4timecomparison}\\includegraphics[width=0.45\\columnwidth]{images/Q1\\lyxdot 4accuracycomparison}\r\n\\par\\end{centering}\r\n\\caption{a)Time taken SMO implementation (smotime) vs Sklearn's LIBSVM (svmtime)\r\nand b) accuracy of SMO implemenation (smoacc) and Sklearn's LIBSVM\r\n(svmacc) \\label{fig:Question1_fig3}}\r\n\\end{figure}\r\n\r\n\r\n\\section{Neural Networks}\r\n\r\n\\subsection{Ordinary Least Squares}\r\n\r\n\\section{Learning++}\r\n\r\nPart A to E correspond to the 5 subquestions of Q3 \r\n\r\n\\subsection{Class Imbalance in MNIST}\r\n\r\nMNIST class 0, 1, 2 were considered in the ratio 70:25:5. We first\r\nused a comparitively larger self made (non standard) neural network\r\nwhich gave close to 100\\%(>99.8 on both train and test datasets) accuracy.\r\nThis neural network was large for the MNIST dataset and was able to\r\ngeneralize well despite the class imbalance.\r\n\r\nWe then used a smaller feedforward neural network with 2 hidden layers\r\nto first visualize the problems that arose due to class imbalance\r\nand then try to solve them. We first tried out the following methods\r\nand modifications to our losses.\r\n\\begin{itemize}\r\n\\item Cross entropy loss: We did not modify the loss in this case and the\r\nresults we obtained are shown in the folloing table having precision\r\nrecall and F1 score for all three classes. (Table \\ref{tab3.1})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.955 & 0.998 & 0.976\\tabularnewline\r\n\\hline \r\n1 & 0.955 & 0.995 & 0.975\\tabularnewline\r\n\\hline \r\n2 & \\textbf{0.995} & \\textbf{0.908} & \\textbf{0.949}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.967}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Simple Cross entropy loss \\label{tab3.1}}\r\n\\end{table}\r\n\r\nMissclassified samples are as follows, these are randomly picked misclassified\r\nsamples and as we can see most of them are from the class 2 which\r\nhas the least samples (Figure \\ref{fig3.1})\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.9\\columnwidth]{images/Fig3\\lyxdot 1Missclassifiedsamples}\r\n\\par\\end{centering}\r\n\\caption{Missclassified samples, random. T=True, P =Predicted\\label{fig3.1}}\r\n\\end{figure}\r\n\r\n\\begin{itemize}\r\n\\item Weighted Cross entropy loss: We gave more wight to the class with\r\nfewer sample. The weights are inversely proportional to the ratio\r\nof classes. We get an increase in the performance metrics, particularly\r\nthe F1 score of the class 1 and 2 which have less samples. results\r\nare as follows.(Table \\ref{tab3.2})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.976 & 0.996 & 0.985\\tabularnewline\r\n\\hline \r\n1 & 0.977 & 0.997 & 0.986\\tabularnewline\r\n\\hline \r\n2 & \\textbf{0.992} & \\textbf{0.951} & \\textbf{0.972}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.981}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Weighted cross entropy loss stats \\label{tab3.2}}\r\n\\end{table}\r\n\r\n\\begin{itemize}\r\n\\item Focal loss: We experiemnted with the focal loss and obtained an increase\r\nin performance metrics, when compared with the vanilla cross entropy\r\nloss.(Table \\ref{tab3.3})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.977 & 0.995 & 0.987\\tabularnewline\r\n\\hline \r\n1 & 0.981 & 0.997 & 0.988\\tabularnewline\r\n\\hline \r\n2 & \\textbf{0.993} & \\textbf{0.965} & \\textbf{0.980}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.985}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Focal loss stats \\label{tab3.3}}\r\n\\end{table}\r\n\r\n\\begin{itemize}\r\n\\item MSE loss: Simple MSE loss was tried out, performance is much worse\r\nthan cross entropy loss.(Table \\ref{tab3.4})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.863 & 0.997 & 0.925\\tabularnewline\r\n\\hline \r\n1 & 0.853 & 0985 & 0.914\\tabularnewline\r\n\\hline \r\n2 & \\textbf{0.996} & \\textbf{0.685} & \\textbf{0.811}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.8894}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Simple MSE loss stats \\label{tab3.4}}\r\n\\end{table}\r\n\r\n\\begin{itemize}\r\n\\item Weighted MSE: Similar to Weghted Crossentropy but with this time using\r\nMSE.(Table \\ref{tab3.5})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.881 & 0.998 & 0.936\\tabularnewline\r\n\\hline \r\n1 & 0.862 & 0.988 & 0.926\\tabularnewline\r\n\\hline \r\n2 & \\textbf{0.994} & \\textbf{0.718} & \\textbf{0.833}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.896}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Weighted MSE loss stats \\label{tab3.5}}\r\n\\end{table}\r\n\r\n\\begin{itemize}\r\n\\item Focal loss type weighted MSE: We took the ideas of focal loss and\r\nused it in MSE to increase the performance of the classification.(Table\r\n\\ref{tab3.6})\r\n\\end{itemize}\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{c|c|c|c}\r\n\\textbf{Class} & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.872 & 0.998 & 0.930\\tabularnewline\r\n\\hline \r\n1 & 0.859 & 0.986 & 0.918\\tabularnewline\r\n\\hline \r\n2 & \\textbf{9.993} & \\textbf{0.703} & \\textbf{0.823}\\tabularnewline\r\n\\hline \r\nMacro F1 &  &  & \\textbf{0.890}\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\centering{}\\caption{Focal loss MSE stats\\label{tab3.6}}\r\n\\end{table}\r\n\r\n\r\n\\subsection{KMeans on SVHN + classification}\r\n\r\n\\subsection{Class Imbalance in MNIST}\r\n\r\n\\subsection{Class Imbalance in MNIST}\r\n\r\n\\subsection{2D PCA, tSNE on SVHN dataset}\r\n\\begin{itemize}\r\n\\item The result of performing PCA on SVHN is as shown in Figure \\ref{figQ3.5.1}.\r\n\\end{itemize}\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.9\\columnwidth]{images/SVHN_PCA.jpeg}\r\n\\par\\end{centering}\r\n\\caption{SVHN 2D PCA \\label{figQ3.5.1}}\r\n\\end{figure}\r\n\r\n\\begin{itemize}\r\n\\item The result of performing tSNE on SVHN is as shown in Figure \\ref{figQ3.5.2}.\r\ntSNE was performed on a subset (10k images) of data which took considerable\r\nhours on HPC.\r\n\\end{itemize}\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.9\\columnwidth]{images/SVHN_tSNE.jpeg}\r\n\\par\\end{centering}\r\n\\caption{SVHN 2D tSNE \\label{figQ3.5.2}}\r\n\\end{figure}\r\n\r\n\\begin{itemize}\r\n\\item To have a comparison, we went ahead and performed PCA, tSNE on MNIST\r\ndata as well (Figure \\ref{fig:Q3.5.3}) and based on all this we present\r\nour observations and colnclusions below.\r\n\\end{itemize}\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=0.45\\columnwidth]{images/mnist_PCA.jpeg}\\includegraphics[width=0.45\\columnwidth]{images/mnist_tSNE.jpeg}\r\n\\par\\end{centering}\r\n\\caption{a)2D PCA and b)2D tSNE MNIST \\label{fig:Q3.5.3}}\r\n\\end{figure}\r\n\r\n\r\n\\subsubsection{Observations and Conclusions}\r\n\\begin{itemize}\r\n\\item The PCA result on SVHN is very homogeneous, and the classes are not\r\nseparated at all. We can see that all the class labels are placed\r\nat the same point in the figure, ie teh centroid of all the classes\r\nis the same and hence wPCA hasn't been able to separate the classes\r\nvery well in 2 dimesnions.\r\n\\item tSNE on the other hand isn't alot better but we can ee more clustering\r\nthan PCA and the centroids of the classes are also displaced from\r\neach other if we look closely in the tSNE plot. tSNE being a non linear\r\ntechnique, it is expected that it would perform better than PCA, however\r\nin a lot more amount of time due to (O(N\\textasciicircum 2) complexity)\r\n\\item Comparing the results with MNIST we get class separationg using PCA\r\non MNIST. Classes 7, 9, 4 and classes 6 ,5, 8, 2 are close to each\r\nother which is expected due to the struture of the digits. tSNE is\r\nable to completely separate all classes from each other as shown in\r\nthe tSNE plots. An interesting thing to note is that the digit 4 is\r\nseparated into 2 groups and one is closer to 9, this is expected because\r\nsome digits, 4 look very cose to 9.\r\n\\item We can conclude that due to the noisse, background, overlapping digits\r\nand classes, and being in more natural setting, SVHN is difficult\r\nto separate using PCA,tSNE but MNIST is highly separable due to the\r\nnature of the dataset, having contrast between digits and background,\r\nuniform background, no overlapping of labels, classes etc\r\n\\end{itemize}\r\n\r\n\\subsection{smdlsk}\r\n\r\nn param classifier, KNN, is shown here and the other one's in the\r\nAppendix.\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.996 & 0.996 & 0.996\\tabularnewline\r\n\\hline \r\n1 & 0.995 & 0.985 & 0.99\\tabularnewline\r\n\\hline \r\n2 & 0.994 & 0.999 & 0.996\\tabularnewline\r\n\\hline \r\n3 & 0.97 & 0.978 & 0.974\\tabularnewline\r\n\\hline \r\n4 & 0.967 & 0.932 & 0.949\\tabularnewline\r\n\\hline \r\n5 & 0.953 & 0.984 & 0.969\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.996 & 0.0 & 0.004 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 0.985 & 0.0 & 0.0 & 0.001 & 0.015\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.001 & 0.0 & 0.999 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.001 & 0.0 & 0.002 & 0.978 & 0.019 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.002 & 0.0 & 0.0 & 0.03 & 0.932 & 0.035\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.004 & 0.0 & 0.0 & 0.012 & 0.984\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{KNN on Multi-Class Dataset}\r\n\\end{table}\r\n\r\n\r\n\\appendix\r\n\r\n\\section{A}\r\n\r\n\\subsection{Binary Classification - Question 1 : Health Dataset Visualization}\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=7cm,height=7cm,keepaspectratio,bb = 0 0 200 100, draft, type=eps]{C:/Users/shubhammittal/Desktop/assignment/Q1_Binary_Classifier/health dataset.png}\\caption{Health Data\\label{fig:Health-Data}}\r\n\\par\\end{centering}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Binary Classification - Question 1: Logistic Regression - Stochastic\r\nGradient Descent}\r\n\r\n\\begin{table}[H]\r\n\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{MAE} & \\textbf{MSE} & \\textbf{CrossEntropy}\\tabularnewline\r\n\\hline \r\nVal Acc & 0.8286 & 0.8469 & 0.8469\\tabularnewline\r\n\\hline \r\nVal F1 & 0.8278 & 0.8179 & 0.8165\\tabularnewline\r\n\\hline \r\nTrain Acc & 0.851 & 0.851 & 0.851\\tabularnewline\r\n\\hline \r\nTest Acc & 0.8714 & 0.8714 & 0.8714\\tabularnewline\r\n\\hline \r\nPrecision & 0.8571 & 0.8571 & 0.8571\\tabularnewline\r\n\\hline \r\nRecall & 0.8478 & 0.8478 & 0.8478\\tabularnewline\r\n\\hline \r\nF1 & 0.8525 & 0.8525 & 0.8525\\tabularnewline\r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{Logistic Regression Classifiers with different loss functions (SGD)\r\n\\label{tab:Logistic-Regression-Classifiers-1}}\r\n\r\n\\end{table}\r\n\r\n\r\n\\subsection{Regression problem - Question 2: Elastic Net Regularization}\r\n\r\nHere, it is seen that $\\alpha$, coefficient of L2 penalty penalizes\r\nthe training loss more than $\\beta$, coefficient of L1 penalty.\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=6cm,height=6cm,keepaspectratio,bb = 0 0 200 100, draft, type=eps]{C:/Users/shubhammittal/Desktop/assignment/Q2_Regression/ElasticNet.png}\\caption{Elastic Net Regularization\\label{fig:Elastic-Net-Regularization}}\r\n\\par\\end{centering}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Regression problem - Question 2: Linear regression using MAE Loss\r\nfunction}\r\n\r\n\\begin{figure}[H]\r\n\\begin{centering}\r\n\\includegraphics[width=5cm,height=5cm,keepaspectratio,bb = 0 0 200 100, draft, type=eps]{C:/Users/shubhammittal/Desktop/assignment/Q2_Regression/MAE_regressor.png}\\includegraphics[width=5cm,height=5cm,keepaspectratio,bb = 0 0 200 100, draft, type=eps]{C:/Users/shubhammittal/Desktop/assignment/Q2_Regression/MSE_regressor.png}\\caption{Linear regression comparison between MAE and MSE\\label{fig:Linear-regression-comparison}}\r\n\\par\\end{centering}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Question 3: MLE - Bayes Gaussian}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.997 & 0.986 & 0.992\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.947 & 0.985 & 0.966\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.986 & 0.998 & 0.992\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.962 & 0.984 & 0.973\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.974 & 0.922 & 0.947\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.95 & 0.942 & 0.946\\tabularnewline\r\n\\hline \r\n\\end{tabular}\\\\\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.986 & 0.0 & 0.014 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 0.985 & 0.0 & 0.0 & 0.0 & 0.015\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 0.998 & 0.0 & 0.002 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.001 & 0.0 & 0.0 & 0.984 & 0.014 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.002 & 0.0 & 0.0 & 0.039 & 0.922 & 0.037\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.05 & 0.0 & 0.0 & 0.008 & 0.942\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{}\r\n\r\n\\end{table}\r\n\r\n\r\n\\subsection{Question 3: MLE - Naive Bayes Gaussian}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.997 & 0.986 & 0.992\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.937 & 0.996 & 0.966\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.986 & 0.998 & 0.992\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.941 & 0.981 & 0.96\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.958 & 0.906 & 0.931\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.964 & 0.918 & 0.941\\tabularnewline\r\n\\hline \r\n\\end{tabular}\\\\\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.986 & 0.0 & 0.014 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 0.996 & 0.0 & 0.0 & 0.0 & 0.004\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 0.998 & 0.002 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.001 & 0.0 & 0.0 & 0.981 & 0.018 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.002 & 0.0 & 0.0 & 0.06 & 0.906 & 0.031\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.06 & 0.0 & 0.0 & 0.022 & 0.918\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{}\r\n\\end{table}\r\n\r\n\r\n\\subsection{Question 3: MLE - Bayes GMM}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.987 & 0.983 & 0.992\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.946 & 0.979 & 0.923\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.956 & 0.998 & 0.912\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.912 & 0.980 & 0.983\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.984 & 0.921 & 0.951\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.951 & 0.932 & 0.956\\tabularnewline\r\n\\hline \r\n\\end{tabular}\\\\\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.936 & 0.0 & 0.064 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.01 & 0.945 & 0.0 & 0.0 & 0.0 & 0.045\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 0.993 & 0.0 & 0.007 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.011 & 0.0 & 0.0 & 0.985 & 0.004 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.002 & 0.0 & 0.0 & 0.041 & 0.920 & 0.037\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.03 & 0.0 & 0.0 & 0.008 & 0.962\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{}\r\n\\end{table}\r\n\r\n\r\n\\subsection{Question 3: Logistic Regression over MAE Loss}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.57 & 1.0 & 0.726\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.495 & 1.0 & 0.663\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.936 & 0.984 & 0.96\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.724 & 0.908 & 0.806\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\end{tabular}\\\\\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.0 & 0.0 & 0.006 & 0.984 & 0.009 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.0 & 0.013 & 0.012 & 0.067 & 0.908 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.664 & 0.0 & 0.0 & 0.336 & 0.0\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{}\r\n\\end{table}\r\n\r\n\r\n\\subsection{Question 3: Logistic Regression over MSE Loss}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.779 & 0.026 & 0.051\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.782 & 1.0 & 0.878\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.503 & 1.0 & 0.67\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.94 & 0.983 & 0.961\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.843 & 0.896 & 0.869\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.965 & 0.6 & 0.74\\tabularnewline\r\n\\hline \r\n\\end{tabular}\\\\\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.026 & 0.0 & 0.974 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.0 & 0.0 & 0.007 & 0.983 & 0.008 & 0.002\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.008 & 0.007 & 0.006 & 0.062 & 0.896 & 0.02\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.242 & 0.0 & 0.0 & 0.158 & 0.6\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{}\r\n\\end{table}\r\n\r\n\r\n\\subsection{Question 3 : Parzen Windows}\r\n\r\n\\begin{table}[H]\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l}\r\n & \\textbf{Precision} & \\textbf{Recall} & \\textbf{F1}\\tabularnewline\r\n\\hline \r\n0 & 0.982 & 0.99 & 0.986\\tabularnewline\r\n\\hline \r\n1 & 0.999 & 0.974 & 0.987\\tabularnewline\r\n\\hline \r\n2 & 0.99 & 1.0 & 0.995\\tabularnewline\r\n\\hline \r\n3 & 0.967 & 0.981 & 0.974\\tabularnewline\r\n\\hline \r\n4 & 0.978 & 0.92 & 0.948\\tabularnewline\r\n\\hline \r\n5 & 0.946 & 0.991 & 0.968\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\begin{centering}\r\n\\begin{tabular}{l|l|l|l|l|l|l}\r\n\\hline \r\n & \\textbf{0} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}\\tabularnewline\r\n\\hline \r\n\\textbf{0} & 0.99 & 0.0 & 0.01 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{1} & 0.0 & 0.974 & 0.0 & 0.0 & 0.001 & 0.025\\tabularnewline\r\n\\hline \r\n\\textbf{2} & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{3} & 0.006 & 0.0 & 0.0 & 0.981 & 0.012 & 0.0\\tabularnewline\r\n\\hline \r\n\\textbf{4} & 0.012 & 0.0 & 0.0 & 0.034 & 0.92 & 0.034\\tabularnewline\r\n\\hline \r\n\\textbf{5} & 0.0 & 0.0 & 0.0 & 0.0 & 0.008 & 0.991\\tabularnewline\r\n\\hline \r\n\\end{tabular}\r\n\\par\\end{centering}\r\n\\caption{Parzen Windows on Multi-Class Dataset}\r\n\\end{table}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "e8d9037e23442f5f8da68f32b506f2e2042bb306", "size": 24189, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lyx_Files/report.tex", "max_stars_repo_name": "aditi184/ML-Assignment2", "max_stars_repo_head_hexsha": "44a8472f6ab4d1aaedd06c8aaaaf3b2f1c1ca569", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2022-01-07T06:32:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T10:11:23.000Z", "max_issues_repo_path": "Lyx_Files/report.tex", "max_issues_repo_name": "aditi184/ML-Assignment2", "max_issues_repo_head_hexsha": "44a8472f6ab4d1aaedd06c8aaaaf3b2f1c1ca569", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lyx_Files/report.tex", "max_forks_repo_name": "aditi184/ML-Assignment2", "max_forks_repo_head_hexsha": "44a8472f6ab4d1aaedd06c8aaaaf3b2f1c1ca569", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-20T05:32:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-20T05:32:43.000Z", "avg_line_length": 33.1810699588, "max_line_length": 425, "alphanum_fraction": 0.6918020588, "num_tokens": 9161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4425546801075341}}
{"text": "\\section{Algorithmic Typing: \\declang}\n\nSoundness of \\declang trivially reduces to soundness of implication checking.\nHere we give the detailed proof of the Approximation Theorem:\n\\begin{theorem}{[Approximation]}\\label{thm:approximation} \n  If \\decissubref{\\Env}{p_1}{p_2} then \\isimplied{\\Env}{p_1}{p_2}.\n\\end{theorem}\n\\begin{proof}\nTo prove the above, let ${\\VC \\defeq \\VCOND{\\Env}{p_1}{p_2}}$. First, note that\nif $\\VC$ is u-valid then it is valid as the addition of axioms preserves\nvalidity. Next, we prove that if the \\VC is valid then \\isimplied{\\Env}{p_1}{p_2}.\n%\nWe fix a $\\theta$ for which \n$ \\theta \\in \\interp{\\Gamma}$ and \n$\\evals{\\thetasub{\\theta}{q_1}}{\\etrue}$\n%\nIt suffices to prove that \n$\\evals{\\thetasub{\\theta}{q_2}}{\\etrue}$.\n\nFor all $(x_i, \\tlref{x_i}{B}{\\trivial}{p_i}) \\in \\Gamma$\nthere exists $(x_i, e_i) \\in \\theta$ and\n\\begin{align*}\n\te_i \\in \\interp{\\tref{x_i}{B}{\\trivial}{p_i}}\n&\\Leftrightarrow\n\te_i \\in \\interp{\\tref{v}{B}{}{p_i}}\n\t\\land\n\t\\exists v. \\evals{e_i}{v_i}  \\\\\n&\\Leftrightarrow\n\t\\exists v. \\evals{e_i}{v} \\Rightarrow \n\t\\evals{\\thetasub{\\theta}{p_i\\sub{x_i}{v_i}}}{\\etrue}\n\t\\land\n\t\\exists v. \\evals{e_i}{v_i}  \\\\\n&\\Leftrightarrow\n\t\\evals{\\thetasub{\\theta}{p_i}}{\\etrue}\\\\\n\\end{align*}\n\nThus we have that \n$\\evals{\\theta\\ (\\bigwedge p_i \\land q_1)}{\\etrue}$.\n%\nBy Lemma~\\ref{lemma:teval}\n$\\tevals{\\theta}{(\\bigwedge p_i \\land q_1)}{\\theta'}{\\etrue}$.\n%\nLet $\\rho = \\mkbot{\\theta'}$;\nthus, $\\trackevals{\\theta}{\\rho}$.\nBy Lemma~\\ref{lemma:proofs:lifting}\n$\\evals{\\thetasub{\\rho}{\\bigwedge p_i \\land q_1}}{\\etrue}$.\n%\nMoreover, by the construction of $\\rho$, \n\\hastype{\\emptyset}{\\thetasub{\\rho}{\\bigwedge p_i \\land q_1}}{\\tbool}.\nThus, by Equivalence Theorem~\\ref{thm:equiv}\n$\\forall \\sigma \\in \\embed{\\rho}. \n\\lmodels{\\sigma}{\\bigwedge p_i \\land q_1}$.\n%\nBy which and validity of $VC$\n$\\forall \\sigma \\in \\embed{\\rho}. \n\\lmodels{\\sigma}{q_2}$.\n%\nUsing the other direction of Equivalence Theorem~\\ref{thm:equiv}\n$\\evals{\\rho\\ q_2}{\\etrue}$.\n%\nFinally, using the other direction of Lemma~\\ref{lemma:proofs:lifting}\n$\\eval{\\thetasub{\\theta}{q_2}}{\\etrue}$.\n\\end{proof}\n\n\\renewcommand\\botsto{\\ensuremath{\\theta^\\ebot}}\nTo conclude the proof we prove Equivalence Theorem.\nLet \\botsto be a substitution from variables to \\textit{lifted values}.\nWe define the embedding of the substitution \\embed{\\botsto}\nthat maps \\ebot to arbitrary elements of the logical domain:\n\n\n\\begin{definition}\n$$\n\\instance{\\rho}=\n\t\\{(x_1, \\botv_1), \\dots, (x_n, \\botv_n) \\mid \\botv_i \\in \\instance{\\rho(x_i)}  \\}\n$$\n\\begin{align*}\n\\instance{\\ebot}& = \\dom &\n\\instance{D\\ \\overline{v}} &= \n\t\\{ D\\ \\overline{v} \\mid v_i \\in \\instance{v} \\} \\\\ \n\\instance{n} &= \\{n\\} &\n\\instance{v} &= \\{c_v\\}, \\text{otherwise}\n\\end{align*}\n\\end{definition}\n\nThen we prove that\ngiven a lifted substitution a predicate goes to \\etrue\nif and only if for any embedding the\npredicate holds.\n\n\\begin{theorem}{[Equivalence]}\\label{thm:equiv}\nIf \\hastype{\\emptyset}{\\botsto(p)}{\\tbool}, then\n\\begin{itemize}\n\\item $\\evals{\\botsto(p)}{\\etrue}\\ \\mbox{iff}\\ \n\t\\forall \\sigma \\in \\embed{\\botsto}. \\lmodels{\\sigma}{p}$.\n\\item $\\evals{\\botsto(p)}{\\efalse}\\ \n\t\\mbox{iff}\\ \n\t\\forall \\sigma \\in \\embed{\\botsto}. \\lmodels{\\sigma\\not}{p}$.\n\\end{itemize}\n\\end{theorem}\n\\begin{proof}\n\\newcommand\\sigmamodel{\\ensuremath{\\sigma}}\n\\newcommand\\interpI{\\ensuremath{\\mathcal{I}}}\n\\newcommand\\interpIEq[3]{\\ensuremath{\\interpI_{\\sigmamodel}(#2) = #3}}\n\\newcommand\\interpIGEq[3]{\\ensuremath{\\interpI_{\\sigmamodel}(#2) \\sqsupseteq #3}}\n\\newcommand\\interpINGEq[3]{\\ensuremath{\\interpI_{\\sigmamodel}(#2) \\not\\sqsupseteq #3}}\n\\newcommand\\interpINEq[3]{\\ensuremath{\\interpI_{\\sigmamodel}(#2) \\not = #3}}\n\\newcommand\\interpIENGEq[4]{\\ensuremath{\\interpI_{\\sigmamodel}(#2) = {#3}\\not \\sqsupseteq #4}}\n\nTo begin with we define a comparison between lifted values and \nelements of the logical domain:\n\\begin{definition}\n\\begin{align*}\n\\ebot &\\sqsubset d & d &\\sqsubseteq d & v &\\sqsubseteq c_v\n\\end{align*}\n\\end{definition}\n\nand a function $\\interpI_\\sigmamodel (t)$\nthat given a model $\\sigmamodel$ and an (open) logical term $t$ returns an element in the logic:\n\n\\begin{definition}{[Interpretation]}\n$$\\interpI_{\\sigmamodel} :: t \\rightarrow d $$\n%\n\\begin{align*}\n\\interpIEq{\\sigmamodel}{n&}{n} & \n\\interpIEq{\\sigmamodel}{f\\ \\overline{t}&}{f_D\\ (\\overline{\\interpI_{\\sigmamodel}{t}})}\\\\\n& & \\interpIEq{\\sigmamodel}{D\\ \\overline{t}&}{D\\ \\overline{\\interpI_{\\sigmamodel}{t}}}\\\\\n\\interpIEq{\\sigmamodel}{x&}{\\sigmamodel(x)}& \\interpIEq{\\sigmamodel}{t_1 \\oplus t_2 &}{\\interpI_{\\sigmamodel}{t_2}\\oplus_D \\interpI_{\\sigmamodel}{t_2}}\\\\\n\\end{align*}\n\\end{definition}\n\nWe relate the evaluation of logical terms with their interpretation\ninto the logic:\n%\n\\begin{lemma}\nIf \\hastype{\\Gamma}{\\thetasub{\\botsto}{t}}{\\tau}, then\n$\t\\evals{\\thetasub{\\botsto}{t}}{\\botv} \n\t\\Leftrightarrow \n\t\\forall\\sigma\\in \\instance{\\rho}.\\interpIGEq{\\sigma}{t}{\\botv}$  \n\\end{lemma}\n\\begin{proof}\nBy induction on the structure of $t$.\n\\begin{itemize}\n\\item $t \\equiv n$: \\evals{\\rho\\ n}{n} and \n\t  $\\forall\\sigmamodel \\in \\instance{\\rho}\\interpIEq{\\sigmamodel}{n}{n}$\n\\item $t \\equiv x$:\n\t\t\\evals{\\thetasub{\\rho}{x}}{\\rho(x)} and \n\t\t$\\forall\\sigmamodel \\in \\instance{\\rho}. \n\t\t\\interpIEq{\\sigmamodel}{x}{\\sigmamodel(x)} \\sqsupseteq \\rho(x)$\n\\item $t \\equiv f\\ \\overline{t}$:\n\n\t$$\n\t\t\\evals{\\rho\\ (f\\ \\overline{t})}{\\botv} \\Leftrightarrow\n\t\t\\evals{f\\ \\overline{\\rho\\ t}}{\\botv} \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\exists \\botv_i. \\evals{\\thetasub{\\rho}{t_i}}{\\botv_i} \\text{ and } \\evals{f ({\\overline{\\botv}})}{\\botv} \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\exists\\botv_i\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIGEq{\\instance{\\rho}}{t_i}{\\botv_i} \\text{ and } \t\t\n\t\t\\forall d_i\\sqsupseteq\\botv_i. f_D(\\overline{d}) \\sqsupseteq \\botv \\xLeftrightarrow{(*)}\t\n\t$$\n\t$$\t\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\exists d_i\\interpIEq{\\sigmamodel}{t_i}{d_i} \\text{ and } \t\t\n\t\tf_D(\\overline{d}) \\sqsupseteq \\botv \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\n\t\tf_D(\\overline{\\interpI_{\\sigmamodel}(t_i)}) \\sqsupseteq \\botv \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIGEq{\\sigmamodel}{f\\ \\overline{t}}{\\botv} \n\t$$\n\n$(*)$ We can show that for each $f_D$ and $\\botv$ \n\t$$\t\n\t\t\\exists\\botv_i\\forall d_i. d_i\\sqsupseteq\\botv_i \\Leftrightarrow f_D(\\overline{d}) \\sqsupseteq \\botv \n\t$$\nie, $\\botv_i$ contains the least information required by $f_D$\nto produce a result less than \\botv.\nNow, say $$ \\exists\\sigmamodel \\in \\instance{\\rho}\\forall d_i.\\interpIENGEq{\\sigmamodel}{t_i}{d_i}{\\botv_i} $$\nThen, by definition of $\\botv_i$,\n$f_D(\\overline{d}) \\not\\sqsupseteq \\botv $, which is a contradiction.\n\\item $t \\equiv D\\ \\overline{t}$: \n\t$$\n\t\t\\evals{\\rho\\ (D\\ \\overline{t})}{D\\ \\overline{\\botv}} \\Leftrightarrow\n\t\t\\evals{\\rho\\ t_i}{\\botv_i} \\Leftrightarrow\n\t$$\n\t$$\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIGEq{\\sigmamodel}{t_i}{\\botv_i} \\Leftrightarrow\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIGEq{\\sigmamodel}{D\\ \\overline{t}}{D\\ \\overline{\\botv}} \n\t$$\n\\item $t \\equiv t_1 \\oplus t_2 $\n\t$$\n\t\t\\evals{\\rho\\ (t_1 \\oplus t_2)}{d} \\Leftrightarrow\n\t\t\\evals{(\\rho\\ t_1) \\oplus (\\rho\\ t_2)}{d} \\Leftrightarrow\t\n\t$$\n\t$$\n\t\t\\exists d_1.\\evals{\\rho\\ t_1}{d_1} \\text{ and }  \\evals{\\oplus_{d_1} (\\rho\\ t_2)}{d} \\Leftrightarrow\n\t$$\n\t$$\t\n\t\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} \\text{ and }  \\evals{\\rho\\ t_2}{d_2} \\text{ and } d_1 \\oplus_D d_2 = d \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\exists d_1, d_2.\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1}{d_1} \\text{ and }  \n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_2}{d_2} \\text{ and } d_1 \\oplus_D d_2 = d \\xLeftrightarrow{(*)}\t\n\t$$\n\t$$\t\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\n\t\t\\exists d_1, d_2.\\interpIEq{\\sigmamodel}{t_1}{d_1} \\text{ and }  \n\t\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\text{ and } d_1 \\oplus_D d_2 = d \\Leftrightarrow\t\n\t$$\n\t$$\t\n\t\t\\forall\\sigmamodel \\in \\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1 \\oplus t_2}{d} \n\t$$\n$(*)$ For $i = 1 , 2$, fix two instantiations\n$\\sigmamodel_1, \\sigmamodel_2 \\in \\instance{\\rho}$. \nAssume that $d_{i_{\\sigmamodel_1}} \\not = d_{i_{\\sigmamodel_2}}$.\nThen $\\lnot \\forall \\sigmamodel \\in \\instance{\\rho} \\interpIEq{\\sigmamodel}{t_i}{d} \\Rightarrow \\evals{\\rho\\ t_i \\not}{d} \\Rightarrow \\lnot \\hastype{\\Gamma}{t_i}{b^\\finite} \\Rightarrow \\lnot \\hastype{\\Gamma}{p}{\\tbool}$.\n\\end{itemize}\n\\end{proof}\n\nWe use the above Lemma to prove the Theorem by induction on the structure of $p$.\n\\begin{itemize}\n\\item $ p \\equiv \\etrue$:\n\\begin{itemize}\n\\item \\eval{\\rho\\ \\etrue}{\\etrue} and $\\forall\\forall\\sigmamodel \\in  \\instance{\\rho}. \\sigmamodel \\models \\etrue$\n\\item \\eval{\\rho\\ \\etrue\\not}{\\efalse} and $\\exists \\forall\\sigmamodel \\in  \\instance{\\rho}. \\sigmamodel \\models \\etrue$\n\\end{itemize}\n\n\\item $ p \\equiv \\efalse$:\n\\begin{itemize}\n\\item $\\eval{\\rho\\ \\efalse \\not}{\\etrue}$ and $\\exists \\sigmamodel \\in \\instance{\\rho}. \\sigmamodel \\not \\models \\efalse$\n\\item $\\eval{\\rho\\ \\efalse}{\\efalse}$ and $\\forall \\sigmamodel \\in \\instance{\\rho}.\\sigmamodel \\not \\models \\efalse$\n\\end{itemize}\n\\item $ p \\equiv \\lnot q$:\n\\begin{itemize}\n\\item\n$\n\t\\evals{\\rho\\ (\\lnot q)}{\\etrue} \\Leftrightarrow\n\t\\evals{\\lnot (\\rho\\ q)}{\\etrue} \\Leftrightarrow\n\t\\evals{\\rho\\ q}{\\efalse} \t\t\\Leftrightarrow\n\t\\forall \\sigmamodel \\in \\instance{\\rho}. \\sigmamodel \\not \\models q\t \\Leftrightarrow\n\t\\forall \\sigmamodel \\in \\instance{\\rho}. \\sigmamodel \\models \\lnot q \\Leftrightarrow\n\t\\forall \\sigmamodel \\in \\instance{\\rho}. \\sigmamodel \\models p\n$\n\\item\n$\n\t\\evals{\\rho\\ (\\lnot q)}{\\efalse} \\Leftrightarrow\n\t\\evals{\\lnot (\\rho\\ q)}{\\efalse} \\Leftrightarrow\n\t\\evals{\\rho\\ q}{\\etrue} \t\t\\Leftrightarrow\n\t\\forall \\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\models q\t \\Leftrightarrow\n\t\\forall \\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\not \\models \\lnot q \\Leftrightarrow\n\t\\forall \\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\not \\models p\n$\n\\end{itemize}\n\n\\item $ p \\equiv p_1 \\land p_2$:\n\\begin{itemize}\n\\item\n$\n\t\\evals{\\rho\\ (p_1 \\land p_2)}{\\etrue} \\Leftrightarrow\n$\n$\t\n\t\\evals{(\\rho\\ p_1) \\land (\\rho\\ p_2) }{\\etrue} \\Leftrightarrow\n$\n$\t\\evals{\\rho\\ p_1}{\\etrue} \\text{ and } \\evals{\\rho\\ p_2}{\\etrue} \\Leftrightarrow\n$\\\\\n$\n\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel\\models p_1} \\text{ and } \n\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel\\models p_2} \\Leftrightarrow\n$\\\\\n$\t\n\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\instance{\\rho}\\models p_1 \\land p_2}  \\Leftrightarrow\n\t\\forall\\sigmamodel\\in\\instance{\\rho}. \\instance{\\rho}  \\models p\t\t \t\t\n$\n\\item\n$\n\t\\evals{\\rho\\ (p_1 \\land p_2)}{\\efalse} \\Leftrightarrow\n\t\\evals{(\\rho\\ p_1) \\land (\\rho\\ p_2) }{\\efalse} \\Leftrightarrow\n\t\\left\\{\n\t\\begin{array}{c}\n\t\t\\evals{\\rho\\ p_1}{\\efalse} \\\\\n\t\t \\text{OR}\\\\\n\t\t\\evals{\\rho\\ p_2}{\\efalse} \\\\\n\t\\end{array}\n\t\\right.\n\t\\Leftrightarrow\n\t\\left.\n\t\\begin{array}{c}\n\t\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel\\not\\models p_1} \\\\\n\t\t \\text{OR}\\\\\n\t\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel\\not\\models p_2} \\\\\n\t\\end{array}\n\t\\right\\}\n$\\\\\n$\t\n\t  \\Leftrightarrow\n\t{\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel\\not\\models p_1 \\land p_2}  \\Leftrightarrow\n\t\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\not\\models p\t\t \t\t\n$\n\\end{itemize}\n\n\\item $p \\equiv t_1 = t_2$:\n\\begin{itemize}\n\\item\n$\n\\begin{array}{lclclcl}\n\t&&\\evals{\\rho\\ (t_1 = t_2)}{\\etrue} \n\t\\\\&\\Leftrightarrow&\n\t\\evals{(\\rho\\ t_1) = (\\rho\\ t_2)}{\\etrue} &&\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{=_{d_1} (\\rho\\ t_2)}{\\etrue} &\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{\\rho\\ t_2}{d_2} \\\\\n\t&&&\\text{and}& d_1 =_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 =_D d_2\\\\\n\t&\\xLeftrightarrow{(*)}&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}\\exists d_1, d_2.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 =_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in \\instance{\\rho}. \\sigmamodel \\models t_1 = t_2  &&\\\\\n\\end{array}\n$\n\n\\item\n$\n\\begin{array}{lclclcl}\n\t&&\\evals{\\rho\\ (t_1 = t_2)}{\\efalse} \\\\&\\Leftrightarrow&\n\t\\evals{(\\rho\\ t_1) = (\\rho\\ t_2)}{\\efalse} &&\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{=_{d_1} (\\rho\\ t_2)}{\\efalse} &\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{\\rho\\ t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not=_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not =_D d_2\\\\\n\t&\\xLeftrightarrow{(*)}&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}\\exists d_1, d_2.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not =_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in \\instance{\\rho}. \\sigmamodel \\not \\models t_1 = t_2  &&\\\\\n\\end{array}\n$\n\\end{itemize}\n$(*)$ For $i = 1 , 2$, fix two instantiations\n$\\sigmamodel_1, \\sigmamodel_2\\in\\instance{\\rho}$. \nAssume that $d_{i_{\\sigmamodel_1}} \\not = d_{i_{\\sigmamodel_2}}$.\nThen $\\lnot \\forall \\sigmamodel\\in\\instance{\\rho} \\interpIEq{\\sigmamodel}{t_i}{d} \\Rightarrow \\evals{\\rho\\ t_i \\not}{d} \\Rightarrow \\lnot \\hastype{\\Gamma}{t_i}{b^\\finite} \\Rightarrow \\lnot \\hastype{\\Gamma}{p}{\\tbool}$\n\n\\item $p \\equiv t_1 < t_2$:\n\\begin{itemize}\n\\item\n$\n\\begin{array}{lclclcl}\n\t&&\\evals{\\rho\\ (t_1 < t_2)}{\\etrue} \\\\&\\Leftrightarrow&\n\t\\evals{(\\rho\\ t_1) < (\\rho\\ t_2)}{\\etrue} &&\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{<_{d_1} (\\rho\\ t_2)}{\\etrue} &\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{\\rho\\ t_2}{d_2} \\\\&&&\\text{and}& d_1 <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\forall\\instance{\\rho}.\\interpIEq{\\instance{\\rho}}{t_1}{d_1} &\\text{and}& \n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_2}{d_2} \n\t\\\\&&&\\text{and}& d_1 <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\forall\\sigmamodel\\in\\instance{\\rho}.\n\t\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 <_D d_2\\\\\n\t&\\xLeftrightarrow{(*)}&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}\\exists d_1, d_2.\n\t\\interpIEq{\\sigmamodel}{t_1}{d_1}&\\text{and}&\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\forall \\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\models t_1 < t_2  &&\\\\\n\\end{array}\n$\n\\item\n$\n\\begin{array}{lclclcl}\n\t&&\\evals{\\rho\\ (t_1 < t_2)}{\\efalse} \\\\&\\Leftrightarrow&\n\t\\evals{(\\rho\\ t_1) < (\\rho\\ t_2)}{\\efalse} &&\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{<_{d_1} (\\rho\\ t_2)}{\\efalse} &\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2.\\evals{\\rho\\ t_1}{d_1} &\\text{and}& \\evals{\\rho\\ t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\exists d_1, d_2\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not <_D d_2\\\\\n\t&\\xLeftrightarrow{(*)}&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}\\exists d_1, d_2.\n\t\\interpIEq{\\sigmamodel}{t_1}{d_1} &\\text{and}& \n\t\\interpIEq{\\sigmamodel}{t_2}{d_2} \\\\&&&\\text{and}& d_1 \\not <_D d_2\\\\\n\t&\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in \\instance{\\rho}. \\sigmamodel\\not\\models t_1 < t_2  &&\\\\\n\\end{array}\n$\n\\end{itemize}\n$(*)$ For $i = 1 , 2$, fix two instantiations\n$\\sigmamodel_1, \\sigmamodel_2 \\in \\instance{\\rho}$. \nAssume that $d_{i_{\\sigmamodel_1}} \\not = d_{i_{\\sigmamodel_2}}$.\nThen $\\lnot \\forall\\sigmamodel\\in \\instance{\\rho} \\interpIEq{\\sigmamodel}{t_i}{d} \\Rightarrow \\evals{\\rho\\ t_i \\not}{d} \\Rightarrow \\lnot \\hastype{\\Gamma}{t_i}{b^\\finite} \\Rightarrow \\lnot \\hastype{\\Gamma}{p}{\\tbool}$\n\n\n\\item $p \\equiv t$:\n\\begin{itemize}\n\\item\n$\n\\begin{array}{lclclcl}\n\t\\evals{\\rho\\ t}{\\etrue} &\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t}{\\etrue}\n\t\\\\&\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in \\instance{\\rho}. \\sigmamodel \\models t\\\\\n\\end{array}\n$\n\\item\n$\n\\begin{array}{lclclcl}\n\t\\evals{\\rho\\ t}{\\efalse} &\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}.\\interpIEq{\\sigmamodel}{t}{\\efalse}\n\t\\\\&\\Leftrightarrow&\n\t\\forall\\sigmamodel\\in\\instance{\\rho}. \\sigmamodel \\not \\models t\\\\\n\\end{array}\n$\n\\end{itemize}\n\\end{itemize}\n\\end{proof}\n", "meta": {"hexsha": "1039ac6707ceb9e27ad0685fc0fe0aa911bcf2ac", "size": 16677, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinedhaskell/proofs/algorithmic.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinedhaskell/proofs/algorithmic.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinedhaskell/proofs/algorithmic.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 38.6041666667, "max_line_length": 220, "alphanum_fraction": 0.6670864064, "num_tokens": 7029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4425546752806306}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\\begin{document}\n\\subsection{Multiscale Network Testing for Two-Graph} \n\nWe invented multiscale network test via diffusion maps and \\texttt{MGC}, and extends its utility into testing two graphs of the same node set with different edge sets. Assume two graphs $\\mathbf{G}_{1}$ and $\\mathbf{G}_{2}$ are generated via a latent variable $\\mathbf{u}_{i} = ( u_{1i}~ u_{2i}~ \\cdots ~u_{5i} ) \\in \\mathbb{R}^{5}$ as follows:\n\\begin{equation}\n\\begin{split}\nu_{ki} & \\overset{i.i.d.}{\\sim} Unif(0, 1), \\quad i = 1,2, \\ldots, n;~k = 1,2,\\ldots, 5 \\\\\nw_{i} & := (1- u_{i1} )^{2}, \\quad i = 1,2, \\ldots, n \\\\\nA^{(1)}_{ij} \\big| \\mathbf{u}_{i}, \\mathbf{u}_{j} & \\sim Bernoulli \\big( <\\mathbf{u}_{i}/5, \\mathbf{u}_{j}/5  > \\big), \\quad \\forall i < j;~i,j=1,2,\\ldots,n;~\\mathbf{u}_{i}, \\mathbf{u}_{j} \\in \\mathbb{R}^{5} \\\\\nA^{(2)}_{ij} \\big| w_{i}, w_{j} & \\sim Bernoulli \\big( <w_{i}, w_{j}  > \\big), \\quad \\forall i < j;~i,j=1,2,\\ldots,n.\n\\end{split}\n\\label{eq:twoGraphs}\n\\end{equation}\nThat is, Each graph is generated by a random dot product graph (RDPG), and the underlying dependency is reflected via the quadratic function of one-dimensional latent variable; this implies both multi-dimensional and nonlinear relationship where \\texttt{MGC} is preferred to other benchmarks in testing network dependency in nodal attributes.  \n\n\\begin{figure}[h!]\n\\begin{cframed}\n\\centering\n\t\\includegraphics[width=0.7\\textwidth]{../../figs/Graphs}\n\t\\caption{The power curve with respect to increasing number of nodes for the two-graph dependency testing simulation (Equation~\\ref{eq:twoGraphs}). The proposed approach achieves higher power than other methods.}\n    \\label{fig:graphtest}\n\t\t\\end{cframed}\n\\end{figure}\n\nFigure~\\ref{fig:graphtest} shows the testing power of \\texttt{MGC}, \\texttt{mCorr}, and \\texttt{HHG} against the number of nodes $n$, all based on the diffusion maps, and it demonstrates that the proposed approach is able to achieve higher testing power under relatively small number of nodes. Note that if noise is included in the set-up, or the nonlinear relationship is more complex than quadratic, the proposed approach still enjoys the same advantage, i.e., the testing power converges to $1$ faster than all other methods, though the actual number of nodes to achieve perfect power will likely increase under noisy and complex dependency.\n\nThe draft is submitted this month and available on arXiv.\n\n\n\\clearpage\n\\end{document}\n", "meta": {"hexsha": "df3f83e768bdc7a11822e0722ce52472b08f7ef5", "size": 2555, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2017-05/multiscaleNetworkTest.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2017-05/multiscaleNetworkTest.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2017-05/multiscaleNetworkTest.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.0, "max_line_length": 644, "alphanum_fraction": 0.7260273973, "num_tokens": 790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4425546752806306}}
{"text": "\\title{CFD laboratory 4\\\\Flow around a circular cylinder in the sub-critical regime}\n\\author{\n        Sergio M. Vanegas A.\\\\\n        Francesco de Pas\\\\\n                Department of Mathematics\\\\\n        Polimi---Politecnico di Milano\\\\\n        Milano, Italia\n}\n\\date{\\today}\n\n\\documentclass[12pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{siunitx}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract} \n        The fourth test case is the flow around a circular cylinder in the sub-critical regime. The cylinder is considered with infinite height to avoid side effects. The flow develops from the free-stream profile $U_\\infty$ in the form of a laminar boundary layer that, after separation at about 82° from the leading edge, generates a turbulent wake with some periodic behavior. The phenomenon is inherently unsteady even at the macro-scale and therefore it requires solving the U-RANS, which might be computationally demanding even for a 2D problem. As a consequence it is here performed the grid independence study for a steady state (RANS) model, and then use the same grid settings for the subsequent U-RANS simulation.\\cite{FL:06}\n \n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Flow_Sketch.png}\n                \\centering\n                \\caption{}\n                \\label{fig:flow_sketch}\n        \\end{figure}\n \n \n\\end{abstract}\n\n\\section{Introduction}\n\n        In the sub-critical regime, the laminar boundary layer developing over the walls of the cylinder separates at about 82° from the front stagnation point, and a large, turbulent wake generates downstream. The pressure distribution over the walls of the cylinder, shown in Figure~\\ref{fig:p_d}, agrees with the potential flow solution only in the front part of the body. The separation point is just at the beginning of the region of adverse pressure gradient, and it can be easily recognized in the figure since the wall pressure in the wake region is broadly uniform. Additionally, the wall shear stress is zero at the point of separation.\n\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Pressure_Distribution.png}\n                \\centering\n                \\caption{}\n                \\label{fig:p_d}\n        \\end{figure}\n\n        The drag coefficient of a circular cylinder with infinite length is defined as: $$C_D = \\frac{\\frac{F_D}{H}}{\\frac{1}{2} \\rho \\left(\\frac{A_D}{H}\\right) U_\\infty^2} = \\frac{\\frac{F_D}{H}}{\\frac{1}{2} \\rho \\left(\\frac{D_C H}{H}\\right) U_\\infty^2} = \\frac{\\frac{F_D}{H}}{\\frac{1}{2} \\rho D_C U_\\infty^2}$$ and it is a function of $\\text{Re}_D$ and the relative roughness $\\frac{s}{D_C}$. In the sub-critical regime, $C_D$ is nearly constant with $\\text{Re}_D$, and it is not much affected by the roughness. Such constant value is around 1.2, as is it evident from Figure~\\ref{fig:dragtrend}.\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{DragCoefficient_Trend.png}\n                \\centering\n                \\caption{}\n                \\label{fig:dragtrend}\n        \\end{figure}\n\n        Finally, the dimensionless Strouhal number quantifies the characteristic frequency of the turbulent wake, \\textit{f},and it is defined as $St = \\frac{f*D_C}{U_\\infty}$. The paper by Fey et al. (1998) provides a correlation to estimate \\textit{St} as a function of $\\text{Re}_D$, according to which, in the sub-critical regime, \\textit{St} varies between 0.185 and 0.21 Figure~\\ref{fig:strouhal}.\n\n\n \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Strouhal.png}\n                \\centering\n                \\caption{}\n                \\label{fig:strouhal}\n        \\end{figure}\n\n\n        The configuration of the problem is as follows:\n        \\begin{itemize}\n                \\item Diameter \\( D_c = 0.06 \\: m \\),\n                \\item Free-stream velocity \\( U_\\infty = 0.4 \\: m/s \\),\n                \\item Bulk velocity \\( U_b = 5 \\: mm/s \\),\n                \\item Fluid: Water at \\( 20^{\\circ}C \\; \\rho = 998.23 \\: kg/m^3\\;( \\mu=1.006*10^{-6} \\:m^2/s\\)).\n        \\end{itemize}\n\n\n        \\paragraph{Outline}\n        The remainder of the report is organized as follows: Section~\\ref{sec:Steady-state precursor} provides some suitable results concerning the Grid Independence Study performed on RANS solutions; Section~\\ref{sec:URAN} instead makes use of URANS in order to focus on the temporal evolution  of the process.\n      \n\\section{Steady-state precursor} \\label{sec:Steady-state precursor}\n\n        The following Grid-Independence study is applied on RANS solution.   Despite in principle RANS solutions do not provide a trustful representation of the physical phenomenon under investigation, this choice can been consider a practical compromise to face the heavy URANS  computational cost. The variables under investigation are:  the distributions of wall pressure and wall shear stress, the drag coefficient and the position of the separation point, inferred from the wall pressure and the wall shear stresses.In particular the separation point was inferred by the wall pressure approximating the wall pressure second derivative (through finite differences of order 8) and looking for its inflection point. The separation point was instead inferred by the shear stress imposing it as the shear stress zero.\n        \n        The study was performed by setting \\textit{3} different meshes along the $\\Theta$ coordinate: 120, 180 and 360 equally spaced cells, while mantaining the $\\rho$ grid fixed to 100 cells distributed through a Geometric law with a coefficient of...\n\n        Figure~\\ref{fig:drag_independence}, Figure~\\ref{fig:pression_ind}, and Figure~\\ref{fig:wall_ind} show our results.\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{DragCoefficient_Independence.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag_independence}\n        \\end{figure}\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Pressure_Independence.png}\n                \\centering\n                \\caption{}\n                \\label{fig:pression_ind}\n        \\end{figure}\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{WallShearStress_Independence.png}\n                \\centering\n                \\caption{X-velocity Y-profile per delta-step}\n                \\label{fig:wall_ind}\n        \\end{figure}\n\n\n        According to experimental results separation point s should lie at $$ 82 ^\\circ $$, and our plot quite respects this result.\n\n\\section{Unsteady-state modelling} \\label{sec:URAN}\n        In this section we'll make use of our results from URANS simulations. To launch these simulations we re-started from the converged steady-state solutions exploiting the finer grid setting.\n\n        We defined as suitable total simulation time to observe periodicity in the macroscopic flow: 60 s. Then, we performed a sensibility analysis with respect to the time-step of time discretization; we considered three different timesteps, ensuring their value to be much smaller with respect to the total time-scal and bigger than microscopic turbolent time-scales. These were:\n\n        \\begin{itemize}\n                \\item $0.06 s$ ($0.1\\%$ of the total simulation time).\n                \\item $0.10 s$ ($0.17\\%$ of the total simulation time).\n                \\item $0.20 s$ ($0.33\\%$ of the total simulation time).\n        \\end{itemize}\n        \n        At each time-step we considered as target parameter: forces on the \\textit{X} and \\textit{Y} axis.\n\n        The behaviour of the Drag and Lift force with the 3 different values imposed can be seen respectively in Figure~\\ref{fig:drag} and Figure~\\ref{fig:lift}. This figures does not appear to describe correctlythe phenomenon under investigation since the forces under investigation never stabilize even after 100 seconds.\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{DragForce.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag}\n        \\end{figure}\n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{LiftForce.png}\n                \\centering\n                \\caption{}\n                \\label{fig:lift}\n        \\end{figure}\n\n        Regarding the Drag and Lift coefficients evolution over time the $0.06 s$ timestep fails; the numerical results are shown in Figure~\\ref{fig:drag_coeff} and  Figure~\\ref{fig:lift_coeff}. At first glance despite the lift coefficient oscillations are 0-averaged and drag coefficients oscillations are positively averaged the order of amplitude of the oscillations seems too small. \n\n        \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Drag_Coefficient.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag_coeff}\n        \\end{figure}\n                \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{Lift_Coefficient.png}\n                \\centering\n                \\caption{}\n                \\label{fig:lift_coeff}\n        \\end{figure}\n\n\n        Finally both averaged Drag Coefficient and Strouhal number, respectively  $\\num{0.6468}$ and $0.1365$ do not match well with expectations of Figure~\\ref{fig:dragtrend}, that suggesting more than $1.0$ and Figure~\\ref{fig:strouhal}.\n        \n        To overcome this issues we had to manipulate on timesteps and total time, leading to a final decision of 9000 timesteps and 45 seconds. Probabily previous numbers of timesteps were too big and made some charcteristic patterns disappear. In Figure~\\ref{fig:drag_f}, Figure~\\ref{fig:drag_vsl1} and Figure~\\ref{fig:drag_vsl2} our results can be seen. \n        \n               \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{drag_Federica.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag_f}\n        \\end{figure}\n     \n            \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{drag_vs_lift_Federica.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag_vsl1}\n        \\end{figure}\n     \n            \\begin{figure}[!ht]\n                \\includegraphics[width=\\textwidth]{drag_vs_lift_2_Federica.png}\n                \\centering\n                \\caption{}\n                \\label{fig:drag_vsl2}\n        \\end{figure}\n        \n        With these images we can appreciate how drag and lift frequency is comparable, while their amplitude is of different order. Moreover it is well clear that they're in phase, since subject to the same physical phenomenon. Finally the averaged Cd coefficient is 1.067 while Strouhal number 0.17, which respects better the expectations of Figure~\\ref{fig:dragtrend} and of Figure~\\ref{fig:strouhal}.\n     \n\n\\bibliographystyle{abbrv}\n\\bibliography{main}\n\n\\end{document}\n", "meta": {"hexsha": "e0785178e6ca29530516b8fd53da939acec9aabe", "size": 10924, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Fluids_Labs/Lab_6/main.tex", "max_stars_repo_name": "sergiovaneg/LaTex_Documents", "max_stars_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Fluids_Labs/Lab_6/main.tex", "max_issues_repo_name": "sergiovaneg/LaTex_Documents", "max_issues_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fluids_Labs/Lab_6/main.tex", "max_forks_repo_name": "sergiovaneg/LaTex_Documents", "max_forks_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-21T14:26:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-21T14:26:02.000Z", "avg_line_length": 58.7311827957, "max_line_length": 817, "alphanum_fraction": 0.6656902234, "num_tokens": 2609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4425546712794948}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage[margin = 1 in]{geometry}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{booktabs}\n\\usepackage{verbatim}\n%\\usepackage{indentfirst}\n\n\\title{CS5220 Project 2: Shallow Water Equations}\n\\author{Nick Cebry, Jiahao Li, Max Ruth}\n\\date{October 5, 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\nIn this project, we worked with the a finite volume solver for the shallow water equations. These PDEs model the movement of waves in scenarios where the waves are long compared to the depth of the water. We were provided with a moderately performant single threaded version of the code, and made an effort to improve performance by parallelizing the algorithm. For our implementation, we chose to use MPI as our parallelization paradigm. Our algorithm divides the grid up into a series of subdomains, and assigns one subdomain to each processor. Processors are responsible for calculating the behavior of the water in their portion of the domain. They communicate information about the cells on the edge of their domain with the processors of neighboring domains so that information propagates properly across domain boundaries.\n\nThe aims for this project are: 1) using MPI as parallelization implementation for the single-core code; 2) conducting weak and strong scaling studies on the shallow water problem; 3) profiling and tuning the codes for higher-level optimization.\n\n\\section{The Algorithm}\n\\textbf{For the purposes of this algorithm, we are considering two consecutive calls to \\texttt{central2d\\_step} to be ``one time step,'' in order to alleviate any confusion with the shifting grids in Jiang and Tadmor.}\n\nTo address the problem of parallelizing the method of Jiang and Tadmor, we use a domain decomposition method like the one introduced for Conway's Game of Life. For the problem, we assume that the domain $\\Omega = (0,L)^2$ is divided into square cells, with a resolution of $M$ cells in each direction. Because the problem is periodic, this amounts to $M$ ``points'' at which the height $h$, $x$-velocity $u$, and $y$-velocity $v$ are known. To parallelize the code, we divide the domain into an $N_x\\times N_y$ grid of subdomains, where each subdomain is owned by a process. By this construction, we are using a total of $N_x N_y$ processors. \n\nAs a part of this construction, each subdomain is responsible for knowing the value of $m_x \\times m_y$ points \\textit{at all times} where $m_x = M/N_x$ and $m_y = M/N_y$. However, due to the way information flows through a hyperbolic system of equations, we also require each processor to store a ``halo'' of ghost cells with width $m_g.$ Each processor is not tasked with knowing the value of the ghost cells, but rather retrieves the values of the ghost cells from its neighbors. The width of the halo is related to how many time steps each processor can perform independently before information must be exchanged -- called $m_t$ -- by the relation $m_g = 4 m_t$. Independent of the number of processors (assuming $M$ is fixed), the we will call the total number of time step blocks $N_t$, so that the total number of time steps is $m_t N_t$. \n\nWe must also keep track of the maximum speed of information across all of the processors, so that each processor takes the same time step. In the code, we are currently sharing this information \\textit{at every time step}, but this turns out not to be a large burden for the sizes of problems we are considering. \n\nIn total, the algorithm can be summarized by Alg.~\\ref{alg:PJT}. Inside of the main loop, we first share the ghost cells. This goes in the order of pass-left and receive-right; pass-right and receive-left; pass-up and receive-down; pass-down and receive-up. In the left/right passing of ghost cells, we pass a block of size $m_g m_y$, whereas for up/down we pass a block of size $m_g (m_x + 2m_g)$, as we need to communicate the corners of the halo along with the sides in this step. \n\\begin{algorithm}\n\\caption{Parallel Jiang-Tadmor Main Loop}\\label{alg:PJT}\n\\begin{algorithmic}\n\\For {$i \\gets 1$ to $N_t$}\n    \\State Share ghost cells via 4 calls of \\texttt{MPI\\_Sendrecv}\n    \\For{$j \\gets 1$ to $m_t$}\n        \\State Get local time step using \\texttt{speed}\n        \\State Get global time step via \\texttt{MPI\\_Allreduce}\n        \\State Perform time step\n    \\EndFor\n\\EndFor\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Model Speed Up}\n\\textbf{For a more detailed description of the model and the calculations, one can see the Mathematica notebook in the \\texttt{tex} folder of the GitHub repository. Also, for simplicity, we will assume that $N=N_x=N_y$ in this section.}\n\nTo analyze the model, we will first write the cost of each of the routines in Alg.~\\ref{alg:PJT}. In this model, when we say ``cost'', we refer to some amount of time it is assumed to take to do a given operation. We will make some general assumptions about this costs of the operations, including:\n\\begin{itemize}\n    \\item The cost of an \\texttt{MPI\\_Sendrecv} between nodes follows the $\\alpha$-$\\beta$ model $c_{\\textrm{comm}} = \\alpha + \\beta s$ where $s$ is the number of floats communicated (the number of floats received and sent is the same every time, so assume the cost includes both).\n    \\item The cost of a time step at a single point is given by $\\gamma$.\n    \\item The cost of a single speed evaluation for communicating the time step is $\\delta$. \n\\end{itemize}\nIn the following four paragraphs, we calculate the average cost of each operation in Alg.~\\ref{alg:PJT} per time step.\n\n\n\\paragraph{Sharing ghost cells} This is only called once per $m_t$ time steps, so unlike the other three operations, this is divided by $m_t$. We only share each of the cells in the ghost cells once, and call \\texttt{MPI\\_Sendrecv} four times, so the total cost becomes\n\\begin{align}\n\\nonumber\n    c_{g} &\\approx \\frac{1}{m_t}\\left(4 \\alpha + 2 \\beta m_g (m_x + m_y + 2m_g)\\right),\\\\\n\\label{eq:cg}\n          &= 4\\frac{\\alpha}{m_t} + 16 \\beta \\left(\\frac{M}{N}  +  m_t\\right).\n\\end{align}\n\n\\paragraph{Get local time step} In general, this step does not seem to cost a lot. However, because it includes a loop over every point, we include it. Because it is being called every time step, we have\n\\begin{equation*}\n    c_{lts} \\approx \\delta \\frac{M^2}{N^2}.\n\\end{equation*}\n\n\\paragraph{Share the global time step} For the call to \\texttt{MPI\\_Allreduce}, we assume that (1) the algorithm is implemented via some divide-and-conquer scheme and (2) the cost is dominated by latency. So, under these assumptions, we have\n\\begin{equation*}\n    c_{gts} \\approx \\alpha \\log(N^2).\n\\end{equation*}\n\n\\paragraph{Perform $m_t$ time steps} For this part the math gets a little complicated, as the amount of points that one must compute the time step for decreases for every iteration. However, the sums are fairly simple to compute explicitly (they can be even be done by Mathematica!). Intuitively, one would expect the cost to be approximately quadratic in $m_t$, as the number of ghost cells is $O(m_t^2)$. The result for the cost is:\n\\begin{equation}\n\\label{eq:cts}\n    c_{ts} = \\gamma \\left[ 2 \\frac{M^2}{N^2}-8 \\frac{M}{N} + \\frac{16}{3} +16  m_t\\left(\\frac{M}{N} - 2\\right) + \\frac{128  m_t^2}{3}\\right]\n\\end{equation}\n\n\\subsubsection{Behavior for different $m_t$}\nOne question that we might ask is \\textit{what is the best number of time steps to block?} We find the total cost per time step \n\\begin{equation*}\n    c = c_g + c_{lts} + c_{gts} + c_{ts},\n\\end{equation*}\nhas two terms which dominate in this question. One is the $\\alpha/m_t$ term in \\eqref{eq:cg}, associated with the benefits from amortizing the latency. Note that if we shared the time step less often, the benefit of amortization would also be seen in $c_{lts}$ and $c_{gts}$ as well.\n\nThe second term that appears to dominate in big-O is the $m_t^2$ term in \\eqref{eq:cts}. However, the linear term in $m_t$ in \\eqref{eq:cts} is also a large contribution to poor behavior for large $m_t$, as we expect $M/N>m_t$ in general. These terms represent extra work that has to be done for computing intermediate ghost cells.\n\nBecause of these two cost scalings, we expect there to be a finite optimal $m_t$. However, because we have not plugged in specific values for $\\alpha,$  $\\beta,$  $\\gamma,$ and $\\delta$ we do not know exactly the best $m_t$ for a given problem.\n\n\\subsubsection{Weak Scaling}\nIn the weak scaling analysis, we will use the metric of Single Point Time Step Rate to determine how effective our code is. This is similar to FLOPS, but rather than counting floating points, we consider our atomic operation to be a time step of a single point \\textit{excluding ghost cells}. So, the total number of single points time stepped in each global time step is $M^2$. The rate is then simply $r_{WS} = \\frac{M^2}{c}$.\n\nIn the weak scaling paradigm, we will assume that the total number of single point time steps ($M^2$) scales linearly with the number of nodes ($N^2$), giving $M = M_0 N$. Plugging this assumption into our model, we find that there is only one nontrivial dependence that remains in $N$: in the \\texttt{MPI\\_Allreduce} command. So, the rate can be written simply as\n\\begin{equation*}\n    r_{WS} \\approx \\frac{M_0^2 N^2}{c_0 + c_1 \\log(N^2)}.\n\\end{equation*}\nThus, our model does not predict perfect weak scaling, but close enough to it. We will see that there is no noticeable slowdown from the logarithmic scaling in our simulations, however the largest value of $N$ we reach is $9$, which likely is a small perturbation to the constant term in $c$.  \n\n\\subsubsection{Strong Scaling} \nIn the strong scaling analysis, we instead fix $M$ and increase $N$ separately. There are a variety of terms that strong-scale well, such as the whole of $c_{gts}$ and the time steps non-ghost cells of the nodes. However, steps such as sharing ghost cells and the time step can even get worse as $N$ increases, showing that continuously adding more nodes will eventually fail for strong scaling. We never reached the this strong scaling limit though (as our code fails when $m_g > m_x$ or $m_g>m_y$ anyway).\n\n\n\n\\section{Scaling and Profiling Results}\n\\subsection{Scaling Studies}\nWe performed both strong and weak scaling studies to analyze the\nperformance of our algorithm. For the strong scaling study, we used the\ndam break scenario, and fixed the resolution of the grid cells at 1000\ncells in both the X and Y dimensions. We then varied the number of\nprocessors used to compute the simulation up until a fixed simulation\ntime. The size of the sub-domains varied with the number of processors in\norder to keep the problem size constant. We compare the wall clock time\nrequired to solve a fixed problem as the amount of compute resources\navailable varies. For the weak scaling study, we again used the dam break\nscenario, but varied the resolution of the grid cells with the number of\nprocessors used. The resolution of the grid was varied such that each sub-\ndomain was always 300 cells on each side. The simulation was run until a\nfixed amount of time had been simulated. In order to account for the\ndifferent CFL conditions with different grid resolutions, we recorded the\ntotal number of time steps processed, and divided the wall clock time by\nthis number to determine the average amount of time required to compute a\nsingle tick of the simulation. We compare the wall clock time required to\ncompute a single simulation tick as both the size of the problem and the\ncomputational resources available scale. Additionally, for both types of\nscaling tests we analyzed the impact of varying the frequency of\ncommunication between sub-domains. These tests explored the tradeoff\nbetween frequency of suffering the penalty of communication and amount\nof data communicated and duplicated computation performed.\n\n\\begin{table}\n\\resizebox{\\textwidth}{!}{\n\\begin{tabular}{cccccccccc}\n  \\toprule\n  sub-domain grid & nproc & \\multicolumn{8}{c}{simulation ticks per communication} \\\\\\cmidrule(r){3-10}\n                  &                 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\\\\\midrule\n  1x1 &  1 & 138.95 & 140.02 & 136.78 & 130.53 & 119.90 & 130.60 & 160.26 & 171.99 \\\\\\midrule\n  2x2 &  4 &  48.23 &  48.17 &  48.62 &  29.87 &  47.93 &  51.60 &  30.35 &  51.15 \\\\\\midrule\n  3x3 &  9 &  30.36 &  30.65 &  32.47 &  34.00 &  30.08 &  35.37 &  32.00 &  39.20 \\\\\\midrule\n  4x4 & 16 &   9.50 &  10.78 &  12.11 &  13.88 &  14.88 &  17.04 &  16.48 &  20.62 \\\\\\midrule\n  5x5 & 25 &   3.76 &   3.72 &   3.89 &   4.41 &   4.63 &   6.23 &   6.52 &   8.85 \\\\\\midrule\n  6x6 & 36 &   2.69 &   2.62 &   2.65 &   2.76 &   2.81 &   3.08 &   2.99 &   3.67 \\\\\\midrule\n  7x7 & 49 &   2.22 &   2.07 &   2.13 &   2.17 &   2.20 &   2.39 &   2.30 &   2.70 \\\\\\midrule\n  8x8 & 64 &   1.92 &   1.72 &   1.73 &   1.83 &   1.83 &   2.05 &   1.88 &   2.32 \\\\\\midrule\n  9x9 & 81 &   1.62 &   1.46 &   1.41 &   1.51 &   1.53 &   1.78 &   1.56 &   1.89 \\\\\\bottomrule\n\\end{tabular}\n}\n\\caption{Strong scaling study data}\n\\label{table:strong}\n\\end{table}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.75\\textwidth]{strong.png}\n\\caption{Strong scaling study performance}\n\\label{fig:strong}\n\\end{figure}\n\nThe data collected from the strong scaling test is shown in\nTable \\ref{table:strong}. The data in this table is the wall clock time\nrequired for the computation. We see the processing time decrease as the\nnumber of processors increases. We have also presented this data in\ngraphical form in Figure \\ref{fig:strong}.\n\n\\begin{table}\n\\resizebox{\\textwidth}{!}{\n\\begin{tabular}{cccccccccc}\n  \\toprule\n  sub-domain grid & nproc & \\multicolumn{8}{c}{simulation ticks per communication} \\\\\\cmidrule(r){3-10}\n                  &                 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\\\\\midrule\n  1x1 &  1 & 5.33e4 & 3.47e4 & 3.57e4 & 4.87e4 & 3.88e4 & 4.19e4 & 2.99e4 & 2.59e4 \\\\\\midrule\n  2x2 &  4 & 6.22e4 & 4.04e4 & 3.93e4 & 4.20e4 & 3.59e4 & 3.53e4 & 2.92e4 & 6.26e4 \\\\\\midrule\n  3x3 &  9 & 3.96e4 & 4.12e4 & 3.72e4 & 3.64e4 & 3.67e4 & 3.55e4 & 3.27e4 & 3.88e4 \\\\\\midrule\n  4x4 & 16 & 5.45e4 & 5.21e4 & 5.04e4 & 4.62e4 & 4.92e4 & 4.84e4 & 4.04e4 & 4.37e4 \\\\\\midrule\n  5x5 & 25 & 6.79e4 & 6.44e4 & 6.10e4 & 5.89e4 & 5.48e4 & 5.51e4 & 5.00e4 & 5.15e4 \\\\\\midrule\n  6x6 & 36 & 8.03e4 & 7.62e4 & 7.32e4 & 7.13e4 & 6.82e4 & 6.23e4 & 5.98e4 & 5.85e4 \\\\\\midrule\n  7x7 & 49 & 9.38e4 & 8.82e4 & 8.49e4 & 8.17e4 & 7.67e4 & 7.35e4 & 6.97e4 & 6.67e4 \\\\\\midrule\n  8x8 & 64 & 1.02e5 & 9.59e4 & 9.38e4 & 8.99e4 & 8.63e4 & 8.32e4 & 7.82e4 & 7.45e4 \\\\\\midrule\n  9x9 & 81 & 1.16e5 & 1.11e5 & 1.05e5 & 9.98e4 & 9.69e4 & 9.43e4 & 8.77e4 & 8.39e4 \\\\\\bottomrule\n\\end{tabular}\n}\n\\caption{Weak scaling study data}\n\\label{table:weak}\n\\end{table}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.75\\textwidth]{weak.png}\n\\caption{Weak scaling study performance}\n\\label{fig:weak}\n\\end{figure}\n\nFor the weak scaling study, we collected data on the amount of work\naccomplished per time. To get this number, we multiplied the number of\ncells in the simulation by the number of time steps computed, and divided\nby the wall clock time. This data is presented in Table \\ref{table:weak}.\nAs expected, the size of the problem we can compute in a given amount of\ntime increases as the number of processors increase. We present a graph of\nthis data in Figre \\ref{fig:weak}.\n\n\\subsection{Profiling}\n\nWe used Tau package on Comet as the profiler tool to study the performance of our parallelization and higher-level optimization of the original codes. We used compiler-based instrumentation method, which records timing for both the MPI routines and user-defined functions in the codes. By changing the compiler from \\texttt{mpicc} to \\texttt{tau\\_cc.sh} and adding \\texttt{-tau\\_options=-optCompInst} to the argument for compiling, running the program returns profiling results for each processor and we can look them up by \\texttt{pprof} command. The profiling result shows the proportion of time spent, exclusive time, the total inclusive time, number of calls, number of subroutines as well as the average inclusive time per call for each of the functions in the program. As the parallel computing on each individual processor, except for the rank $0$ core where we expect to see different behavior due to all the subdomain data gathering to output solution after certain time steps for a rationale check, mostly the mean times spent on all the cores are compared straightforward. \n\nWe first did a direct profiling comparison between a $200\\times200$ grid and a $1000\\times1000$ grid, where in both cases 9 processors (blocking into $3\\times3$) were called based on Comet terminal environment. Since the two are computed using the same number of cores, the main difference is the size of subdomains divided into each core, which also indicates blocking size affects the performance of codes. For a small grid problem, the \\texttt{MPI\\_Init()} used $35.5\\%$ of the total profiling time; the major of the code \\texttt{central2d\\_xrun} consists of three parts, \\texttt{central2d\\_step}, \\texttt{central2d\\_periodic} and a MPI routine \\texttt{MPI\\_Allreduce()}, taking up $53.0\\%$, $7.0\\%$ and $0.0\\%$, respectively. \\texttt{central2d\\_periodic} is the modified code for inter-core communication of ghost cell; \\texttt{MPI\\_Allreduce()} is used for synchronizing each subdomain at the same physical time. Numerical PDE computing as well as core communication does not take up fully.  When using same amount of computational resources, the situation of the large scale becomes different, where  \\texttt{central2d\\_step}, \\texttt{central2d\\_periodic} and  \\texttt{MPI\\_Allreduce()} take up $95.1\\%$, $3.3\\%$ and $0.0\\%$ of the total time; \\texttt{MPI\\_Init()}  is only $0.1\\%$. This indicates the bottleneck in a large scale problem running on 9 processors is positioned on how to make the PDE computing itself faster. The most time is spent on the actual PDE numerical computing, whereas the cost of core communication is pretty low. The profiling tables are attached at the end of the report.\n\n\\subsection{Tuning with Blocking}\n\nSo a direct way to speed up the computation in the large-scale problem is to introduce more resources, i.e. to decompose into more blocks and assign to more processors. We used \\texttt{sbatch} command on both Graphite and Comet to submit the task in order to take advantage of the huge computational resources on these two large-scale server. A code profiling was also run by Tau on Comet utilizing 81 cores (blocking into $9\\times9$), for comparison with the one using only 9 cores. Under this circumstance, the total time spent on running the whole program with profile instrumentation is greatly reduced, from 15min to 2min. When looking into the computing as well as communication, \\texttt{central2d\\_step}, \\texttt{central2d\\_periodic} and  \\texttt{MPI\\_Allreduce()} use up $69.3\\%$, $6.0\\%$ and $15.0\\%$, respectively. It demonstrates that when deploying more cores to compute, the proportion of computing itself goes down, while communication and synchronization among each cores goes up. Compared with the small-scale, where the blocking size in each core is more comparable, the PDE computing is in the same scale but $9\\times9$ consumes more average inclusive time per call since it still uses nearly twice as large the block size; same as the communication where $9\\times9$ is around twice average per call since there are more data to exchange in the same amount of neighboring. The same trends can be found when compared with $3\\times3$ on the same large-scale. However, more decomposition gives more distributed tasks to be done, meaning when the communication and synchronization is needed, it will pay more. Luckily, our parallelization optimizes the way of communication so that only the ghost cells have to be updated from the left, right, top and bottom neighboring blocks. Nevertheless, the cost of synchronization, as of \\texttt{MPI\\_Allreduce()}, grows tremendously from 22usec/call in $3\\times3$ to 18823usec/call in $9\\times9$. The blocking strategy is constraint to how many computational resources are available. There is also trade-off between the individual computing and synchronization. Block size also plays a key role in utilizing the cache. In our test, blocking works prominently well in large-scale study.\n\n\\subsection{Tuning with Time-step Batching}\n\nAfter making the parallelized code speedup by having more individual processors, another way we tried on is to advance the time-step. In the original code, the iteration is based on a two-time-step staggered grids. During each iteration, the time is forwards two step to an updated status. In our primary parallelization, this means after two time-step, the periodic condition or individual core communication is needed in the area of the ghost cells. As a way to possible speedup, we can move forwards from the two time-step to more, so that the numbers of communication among each cores can be reduced, herein called time-step batching. We did a profile on the large-scale problem with $9\\times9$ cores and a four time-step batching. The numbers of call of \\texttt{central2d\\_periodic} is reduced half, as expected half less of communication in four time-step batching; the inclusive total time is also decreased from 9164msec to 7437msec. However, since more time-step is forwards, which is proportional to the increase of numbers of ghost cells, as indicated that the average inclusive time per call is increased from 7562usec/call to 12437usec/call. At the same time, due to the demand of time-step synchronization, $dt$ has to be communicated in every time-step. So this time-step batching does not help much with the timing of \\texttt{MPI\\_Allreduce()} under this $9\\times9$ 4 time-step batching setting. The time-step batching plays the trade-off between the numbers and the amount of required communication. However, we did not see much improvement in the implementation of large-scale study.\n\n\n\n\\section{Conclusion}\nWhile we did profiling and scaling studies on our code, there are still a variety of improvements that could be made. For instance, despite these studies, we have done no in-depth analysis of the cache performance of the code, which is an important detail for performance that was totally neglected. Another factor that is not considered in the profiling is any measure of the time that MPI communication steps spend waiting for other processors. From the tau profiling of a 9-processor run on Comet, we found that one processor spent a significantly smaller amount of time on \\texttt{MPI\\_Sendrecv} than any of the other processors, indicating that the other processors were probably waiting for a single subdomain of the code to run. A more adaptive method of load balancing would certainly help alleviate these sorts of problems. \n\nAnother problem that we might face as we scale up this code is communicating the time step. Currently, the code communicates the time step at every step, whereas it might be improved communicating less frequently and taking slightly smaller step sizes. This is seen most acutely through the profiling of the $9\\times 9$ processor profiling, where the \\texttt{MPI\\_Allreduce} step takes a much larger percentage of the total time than in the $3\\times3$ profiling case. As the number of processors increases, this result would only get worse. \n\nFinally, we would probably have to think a bit more about the architectures of the computers we are specifically running on. For instance, when one looks at the graph for the strong scaling, there are clear, strange effects when the number of processors jumps from $9$ to $16$ processors, which corresponds to switching from one to two node architectures. It is likely that the different models for MPI sends and receives are responsible for significant effects in the speed of the code, and we could certainly make improvements in this direction.\n\n\\appendix\n\\section{Profiling table: small scale on 9 cores}\n\\noindent\n{\\footnotesize\n\\begin{verbatim}\nFUNCTION SUMMARY (mean):\n---------------------------------------------------------------------------------------\n%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name\n              msec   total msec                          usec/call \n---------------------------------------------------------------------------------------\n100.0            6       16,162           1           1   16162524 .TAU application\n100.0        0.954       16,156           1           3   16156274 main \n 63.8        0.596       10,313           1     119.444   10313260 run_sim \n 60.0       0.0372        9,703          50          50     194062 central2d_run \n 60.0        0.538        9,703          50        1250     194061 central2d_xrun \n 53.0            7        8,559         500     37833.3      17118 central2d_step \n 35.5        5,737        5,737           1           0    5737190 MPI_Init() \n 26.7           49        4,322         500      218000       8644 central2d_predict \n 26.0        4,175        4,205      213500     50014.3         20 limited_deriv1 \n 26.0           68        4,200         500      309001       8401 central2d_correct \n 25.9        4,150        4,179      213500     49986.7         20 limited_derivk \n  7.0            1        1,135         250        7000       4542 central2d_periodic \n  7.0        1,131        1,131        1000           0       1131 MPI_Sendrecv() \n  3.0       0.0558          482          51     96.3333       9452 gather_sol \n  2.5        0.037          398     45.3333     45.3333       8787 send_full_u \n  2.5          398          398     45.3333           0       8787 MPI_Send() \n  0.6          104          104           1           0     104869 MPI_Finalize() \n  0.5           80           81          51     9614.89       1597 copy_u \n  0.5       0.0621           73     45.3333     90.6667       1631 recv_full_u \n  0.4           60           60     5.66667           0      10762 solution_check \n  0.4           43           58      100001      100001          1 limdiff [THROTTLED]\n  0.2           12           28     36833.3     36833.3          1 shallow2d_flux \n  0.2           25           25     5.66667           0       4555 viz_frame \n  0.2           25           25           1           0      25248 MPI_Barrier() \n  0.1           20           20      100001           0          0 central2d_correct_sd [THROTTLED]\n  0.1           16           16     36833.3           0          0 shallow2dv_flux \n  0.1           15           15      100001           0          0 xmin2s [THROTTLED]\n  0.0            7            7    0.111111           0      66771 viz_close \n  0.0            5            5         250           0         22 MPI_Allreduce() \n  0.0            3            5           1     13333.3       5336 lua_init_sim \n  0.0            2            2        6000           0          0 copy_subgrid \n  0.0            2            2           1           0       2708 viz_open \n  0.0        0.133            2         250         250         10 shallow2d_speed \n  0.0            2            2         250           0          9 shallow2dv_speed \n  0.0            2            2     45.3333           0         47 MPI_Recv() \n  0.0            1            1       11837           0          0 central2d_offset \n  0.0            1            1     11111.2           0          0 central2d_offset [THROTTLED]\n  0.0       0.0189       0.0201           1           2         20 central2d_init \n  0.0      0.00733      0.00733           1           0          7 copy_basic_info \n  0.0      0.00122      0.00122           2           0          1 central2d_free \n  0.0     0.000778     0.000778           1           0          1 MPI_Comm_size() \n  0.0     0.000444     0.000444           1           0          0 MPI_Comm_rank() \n\\end{verbatim}\n}\n\n\\section{Profiling table: large scale on 9 cores}\n\\noindent\n{\\footnotesize\n\\begin{verbatim}\nFUNCTION SUMMARY (mean):\n---------------------------------------------------------------------------------------\n%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name\n              msec   total msec                          usec/call \n---------------------------------------------------------------------------------------\n100.0            5    15:34.549           1           1  934549844 .TAU application\n100.0        0.461    15:34.543           1           3  934543980 main \n 99.8        0.763    15:32.687           1     119.444  932687449 run_sim \n 98.4       0.0854    15:19.270          50          50   18385400 central2d_run \n 98.4            4    15:19.269          50        6060   18385398 central2d_xrun \n 95.1        2,382    14:48.441        2424      104849     366519 central2d_step \n 47.7        1,531     7:25.437        2424 4.93526E+06     183761 central2d_predict \n 47.3     7:21.737     7:21.766 4.91345E+06       49979         90 limited_derivk \n 47.1        2,236     7:20.259        2424 4.99163E+06     181625 central2d_correct \n 47.1     7:20.090     7:20.119 4.91345E+06       50022         90 limited_deriv1 \n  3.3            9       30,591        1212       33936      25240 central2d_periodic \n  3.3       30,494       30,494        4848           0       6290 MPI_Sendrecv() \n  1.1        0.131       10,712          51     96.3333     210043 gather_sol \n  0.9        0.102        8,610     45.3333     45.3333     189947 send_full_u \n  0.9        8,610        8,610     45.3333           0     189945 MPI_Send() \n  0.2        1,977        1,977          51           0      38767 copy_u \n  0.2           14        1,877     45.3333     90.6667      41415 recv_full_u \n  0.2        1,508        1,508     5.66667           0     266283 solution_check \n  0.1        1,302        1,302           1           0    1302127 MPI_Init() \n  0.1          616          616     5.66667           0     108842 viz_frame \n  0.1          553          553           1           0     553943 MPI_Finalize() \n  0.1          503          503           1           0     503194 MPI_Barrier() \n  0.0           34          361      100001      100001          4 shallow2d_flux [THROTTLED]\n  0.0          327          327      100001           0          3 shallow2dv_flux [THROTTLED]\n  0.0            1          205        1212        1212        169 shallow2d_speed \n  0.0          204          204        1212           0        168 shallow2dv_speed \n  0.0          109          109     45.3333           0       2419 MPI_Recv() \n  0.0           87           87       29088           0          3 copy_subgrid \n  0.0           55           70           1      100001      70665 lua_init_sim \n  0.0           43           58      100001      100001          1 limdiff [THROTTLED]\n  0.0           42           42      100001           0          0 central2d_correct_sd [THROTTLED]\n  0.0           27           27        1212           0         22 MPI_Allreduce() \n  0.0           15           15      100001           0          0 xmin2s [THROTTLED]\n  0.0           14           14      100001           0          0 central2d_offset [THROTTLED]\n  0.0            4            4    0.111111           0      36135 viz_close \n  0.0        0.639        0.639           2           0        320 central2d_free \n  0.0        0.227        0.227           1           0        227 viz_open \n  0.0       0.0163       0.0171           1           2         17 central2d_init \n  0.0      0.00878      0.00878           1           0          9 copy_basic_info \n  0.0     0.000556     0.000556           1           0          1 MPI_Comm_size() \n  0.0     0.000222     0.000222           1           0          0 MPI_Comm_rank() \n\\end{verbatim}\n}\n\n\\section{Profiling table: large scale on 81 cores}\n\\noindent\n{\\footnotesize\n\\begin{verbatim}\nFUNCTION SUMMARY (mean):\n---------------------------------------------------------------------------------------\n%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name\n              msec   total msec                          usec/call \n---------------------------------------------------------------------------------------\n100.0            6     2:32.563           1           1  152563081 .TAU application\n100.0          255     2:32.556           1           3  152556601 main \n 97.2        0.538     2:28.236           1     109.272  148236114 run_sim \n 90.3       0.0432     2:17.766          50          50    2755333 central2d_run \n 90.3            2     2:17.766          50        6060    2755332 central2d_xrun \n 69.3          140     1:45.760        2424      104849      43631 central2d_step \n 35.0          392       53,411        2424 1.70326E+06      22034 central2d_predict \n 34.3       52,316       52,345 1.68145E+06       49967         31 limited_derivk \n 34.2       52,222       52,251 1.68145E+06       50034         31 limited_deriv1 \n 34.2          511       52,112        2424 1.75963E+06      21498 central2d_correct \n 15.0       22,813       22,813        1212           0      18823 MPI_Allreduce() \n  6.3       0.0596        9,664          51      101.37     189498 gather_sol \n  6.2       0.0427        9,431     50.3704     50.3704     187252 send_full_u \n  6.2        9,431        9,431     50.3704           0     187251 MPI_Send() \n  6.0            7        9,164        1212       33936       7562 central2d_periodic \n  6.0        9,139        9,139        4848           0       1885 MPI_Sendrecv() \n  1.7        2,568        2,568           1           0    2568150 MPI_Init() \n  1.0        1,496        1,496           1           0    1496864 MPI_Finalize() \n  0.4          549          549           1           0     549138 MPI_Barrier() \n  0.2       0.0568          229     50.3704     100.741       4554 recv_full_u \n  0.1          225          226          51     769.988       4433 copy_u \n  0.1          167          167     0.62963           0     266338 solution_check \n  0.1           34           96      100001      100001          1 shallow2d_flux [THROTTLED]\n  0.0           69           69     0.62963           0     109638 viz_frame \n  0.0           62           62      100001           0          1 shallow2dv_flux [THROTTLED]\n  0.0           43           58      100001      100001          1 limdiff [THROTTLED]\n  0.0        0.486           25        1212        1212         21 shallow2d_speed \n  0.0           25           25        1212           0         21 shallow2dv_speed \n  0.0           22           22      100001           0          0 central2d_correct_sd [THROTTLED]\n  0.0           17           17       29088           0          1 copy_subgrid \n  0.0           15           15      100001           0          0 xmin2s [THROTTLED]\n  0.0            9           14           1       37037      14530 lua_init_sim \n  0.0            6            6     50.3704           0        125 MPI_Recv() \n  0.0            5            5     36572.4           0          0 central2d_offset \n  0.0            3            3   0.0123457           0     321839 viz_close \n  0.0        0.182        0.182     1234.58           0          0 central2d_offset [THROTTLED]\n  0.0        0.118        0.118           2           0         59 central2d_free \n  0.0       0.0138       0.0145           1           2         15 central2d_init \n  0.0       0.0119       0.0119           1           0         12 viz_open \n  0.0      0.00809      0.00809           1           0          8 copy_basic_info \n  0.0     0.000481     0.000481           1           0          0 MPI_Comm_size() \n  0.0     0.000272     0.000272           1           0          0 MPI_Comm_rank()\n\\end{verbatim}\n}\n\n\n\\section{Profiling table: large scale on 81 cores with 4 time-step}\n\\noindent\n{\\footnotesize\n\\begin{verbatim}\nFUNCTION SUMMARY (mean):\n---------------------------------------------------------------------------------------\n%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name\n              msec   total msec                          usec/call \n---------------------------------------------------------------------------------------\n100.0            6     2:41.619           1           1  161619151 .TAU application\n100.0        0.911     2:41.612           1           3  161612979 main \n 97.6        0.537     2:37.808           1     109.272  157808979 run_sim \n 91.2       0.0493     2:27.456          50          50    2949131 central2d_run \n 91.2            1     2:27.456          50        5382    2949130 central2d_xrun \n 71.2          184     1:55.142        2392      104785      48137 central2d_step \n 37.1          415     1:00.023        2392 1.79559E+06      25093 central2d_predict \n 35.2       56,930       56,959 1.71666E+06     50023.1         33 limited_deriv1 \n 35.2       56,909       56,938 1.71666E+06     49977.9         33 limited_derivk \n 33.9          508       54,821        2392 1.73772E+06      22919 central2d_correct \n 15.4       24,854       24,854        1196           0      20781 MPI_Allreduce() \n  5.9       0.0624        9,552          51      101.37     187302 gather_sol \n  5.8       0.0445        9,324     50.3704     50.3704     185126 send_full_u \n  5.8        9,324        9,324     50.3704           0     185126 MPI_Send() \n  4.6            3        7,437         598       16744      12437 central2d_periodic \n  4.6        7,421        7,421        2392           0       3103 MPI_Sendrecv() \n  1.6        2,592        2,592           1           0    2592271 MPI_Init() \n  0.7        1,210        1,210           1           0    1210819 MPI_Finalize() \n  0.3          548          548           1           0     548701 MPI_Barrier() \n  0.1       0.0559          224     50.3704     100.741       4457 recv_full_u \n  0.1          220          220          51     769.988       4319 copy_u \n  0.1          167          167     0.62963           0     266331 solution_check \n  0.1           34          113      100001      100001          1 shallow2d_flux [THROTTLED]\n  0.0           79           79      100001           0          1 shallow2dv_flux [THROTTLED]\n  0.0           67           67     0.62963           0     107823 viz_frame \n  0.0           43           58      100001      100001          1 limdiff [THROTTLED]\n  0.0           22           22      100001           0          0 central2d_correct_sd [THROTTLED]\n  0.0        0.488           19        1196        1196         16 shallow2d_speed \n  0.0           19           19        1196           0         16 shallow2dv_speed \n  0.0           15           15      100001           0          0 xmin2s [THROTTLED]\n  0.0            9           14           1       37037      14556 lua_init_sim \n  0.0           11           11       14352           0          1 copy_subgrid \n  0.0            7            7     50.3704           0        142 MPI_Recv() \n  0.0            5            5     36572.4           0          0 central2d_offset \n  0.0        0.494        0.494   0.0123457           0      40006 viz_close \n  0.0        0.186        0.186     1234.58           0          0 central2d_offset [THROTTLED]\n  0.0        0.119        0.119           2           0         60 central2d_free \n  0.0       0.0135       0.0144           1           2         14 central2d_init \n  0.0      0.00979      0.00979           1           0         10 viz_open \n  0.0      0.00801      0.00801           1           0          8 copy_basic_info \n  0.0     0.000679     0.000679           1           0          1 MPI_Comm_size() \n  0.0     0.000247     0.000247           1           0          0 MPI_Comm_rank() \n\\end{verbatim}\n}\n\n\\end{document}\n", "meta": {"hexsha": "1ce284a847f65210f317c333e164597e132ce838", "size": 39733, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/writeup.tex", "max_stars_repo_name": "maxeruth/shallow-water", "max_stars_repo_head_hexsha": "23f52157e25828fc50b37d7e0033d5570bdf757d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/writeup.tex", "max_issues_repo_name": "maxeruth/shallow-water", "max_issues_repo_head_hexsha": "23f52157e25828fc50b37d7e0033d5570bdf757d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/writeup.tex", "max_forks_repo_name": "maxeruth/shallow-water", "max_forks_repo_head_hexsha": "23f52157e25828fc50b37d7e0033d5570bdf757d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 88.4922048998, "max_line_length": 2240, "alphanum_fraction": 0.6123121838, "num_tokens": 11906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.44253103341794253}}
{"text": "\\documentclass[12pt]{article}\r\n\\usepackage{amsmath,amsthm,amssymb,amsfonts}\r\n\\usepackage{booktabs}\r\n\r\n\\usepackage{fancyhdr}\r\n\\usepackage[a4paper, margin=1in]{geometry}\r\n\\usepackage{multicol}\r\n\\usepackage{enumerate}\r\n\r\n\\newcommand{\\N}{\\mathbb{N}}\r\n\\newcommand{\\Z}{\\mathbb{Z}}\r\n\\newcommand{\\R}{\\mathbb{R}}\r\n\r\n\\pagestyle{fancy}\r\n\\fancyhf{}\r\n\\rhead{TSE, Ho Nam}\r\n\\chead{Project \\#1}\r\n\\lhead{MATH4828B}\r\n\\cfoot{\\thepage}\r\n\\begin{document}\r\n\r\n\\subsubsection*{Question 1.}\r\n\\begin{enumerate}[{(i)}]\r\n\t\\item \\(P(B_1 = 1) = 1/3\\)\r\n\t\\item \\(P(B_2 = 0 | B_1 = 1) = 1\\)\r\n\t\\item \\(\\begin{aligned}[t]\r\n\t\t      P(B_1 = 1 | B_2 = 0) = \\frac{P(B_1 = 1) }{ P(B_2=0)} \\cdot P(B_2 = 0 | B_1 = 1) = \\frac{1/3}{1}\\cdot 1 = 1/3\r\n\t      \\end{aligned}\\)\r\n\r\n\t      Note \\(P(B_2 = 0) = 1\\) because the host always chooses the one that does not contain the prize.\r\n\t\\item We should change to \\(B_3\\) because it has a higher probability of being the prize:\\[\r\n\t\t      P(B_1 = 0 | B_2 = 0) = 1-P(B_1 = 1 | B_2 = 0) = 1 - \\frac{1}{3} = \\frac{2}{3}.\r\n\t      \\]\r\n\r\n\\end{enumerate}\r\n\r\n\\subsubsection*{Question 2.}\r\n\\begin{enumerate}[{(i)}]\r\n\t\\item The maximum likelihood estimate of \\(P(y=k)\\) is \\(N_k / N_{\\text{doc}}\\).\r\n\t\\item The maximum likelihood estimate of \\(P(w_i | y=k)\\) is \\[\\frac{\\text{count}(w_i, k)}{\\sum_{j=1}^K\\text{count}(w_j, k)}.\\]\r\n\t\\item We can perform Laplace smoothing, that estimates \\(P(w_i | y=k)\\) with\r\n\t      \\[\r\n\t\t      \\frac{\\text{count}(w_i, k) + 1}{\\sum_{j=1}^K\\text{count}(w_j, k) + K}.\r\n\t      \\]\r\n\t\\item Infrequent words are likely not useful for classification since they are not as important and may likely act as noise instead, therefore those words can be neglected. Frequent words also do not contribute much to the meaning of text, therefore they also can be neglected.\r\n\\end{enumerate}\r\n\\newpage\r\n\\subsubsection*{Question 3.}\r\n\\begin{enumerate}[{(i)}]\r\n\t\\begin{multicols}{2}\r\n\t\t\\item \\(P(y=+) = 5/8;\\quad P(y=-) = 3/8\\).\r\n\t\t\\item\r\n\t\t\\(\r\n\t\t\\begin{array}[t]{ccc}\\toprule\r\n\t\t\t\\text{Vocabulary} & +       & -     \\\\\\midrule\r\n\t\t\t\\text{annoying}   & 0.0     & 0.125 \\\\\\midrule\r\n\t\t\t\\text{awesome}    & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{best}       & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{easy}       & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{good}       & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{great}      & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{is}         & 0.08333 & 0.125 \\\\\\midrule\r\n\t\t\t\\text{one}        & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{rubbish}    & 0.0     & 0.125 \\\\\\midrule\r\n\t\t\t\\text{so}         & 0.0     & 0.125 \\\\\\midrule\r\n\t\t\t\\text{terrible}   & 0.0     & 0.125 \\\\\\midrule\r\n\t\t\t\\text{the}        & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{this}       & 0.08333 & 0.125 \\\\\\midrule\r\n\t\t\t\\text{to}         & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{use}        & 0.08333 & 0.0   \\\\\\midrule\r\n\t\t\t\\text{version}    & 0.08333 & 0.125 \\\\\\midrule\r\n\t\t\t\\text{very}       & 0.0     & 0.125 \\\\\\bottomrule\r\n\t\t\\end{array}\r\n\t\t\\)\r\n\t\t\\item \\(P(y=+) = 0.6;\\quad P(y=-) = 0.4\\).\r\n\r\n\t\t\\(\r\n\t\t\\begin{array}[t]{ccc}\\toprule\r\n\t\t\t\\text{Vocabulary} & +        & -    \\\\\\midrule\r\n\t\t\t\\text{annoying}   & 0.034483 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{awesome}    & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{best}       & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{easy}       & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{good}       & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{great}      & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{is}         & 0.068966 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{one}        & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{rubbish}    & 0.034483 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{so}         & 0.034483 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{terrible}   & 0.034483 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{the}        & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{this}       & 0.068966 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{to}         & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{use}        & 0.068966 & 0.04 \\\\\\midrule\r\n\t\t\t\\text{version}    & 0.068966 & 0.08 \\\\\\midrule\r\n\t\t\t\\text{very}       & 0.034483 & 0.08 \\\\\\bottomrule\r\n\t\t\\end{array}\r\n\t\t\\)\r\n\t\\end{multicols}\r\n\t\\item \\(P(y=+|d) = 0.65776549;\\quad P(y=-|d) = 0.34223451\\).\r\n\r\n\t      Hence, we conclude the text \\(d\\) is positive.\r\n\\end{enumerate}\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "8223676ae283ffb48746caae8340bcc1b69dce33", "size": 4125, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Proj1/proj1.tex", "max_stars_repo_name": "mcreng/COMP4901K-ML4NLP", "max_stars_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-08-03T15:09:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-20T07:04:28.000Z", "max_issues_repo_path": "Proj1/proj1.tex", "max_issues_repo_name": "mcreng/COMP4901K-ML4NLP", "max_issues_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Proj1/proj1.tex", "max_forks_repo_name": "mcreng/COMP4901K-ML4NLP", "max_forks_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-20T04:58:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-20T04:58:51.000Z", "avg_line_length": 38.9150943396, "max_line_length": 279, "alphanum_fraction": 0.5478787879, "num_tokens": 1749, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.44253103033571756}}
{"text": "\\documentclass{elsart}  \n\\usepackage{epsfig,amssymb,amsmath}  \n\\usepackage{rotating}\n\\usepackage{listings}\n\\usepackage{booktabs}\n\\usepackage{fancyhdr}\n\n\\usepackage{float}\n\n\\begin{document}\n\n\n\n\\section{ Alice space point distortion - Nonlinearities}\n\n\nThe electric field in the TPC in the ideal case has just z component ($E=(0,0,E_z)$).\nThe deviation from the ideal behavior causes a distortion which is on the level  $\\approx1$ mm\nclose to the Outer field cage.\nThe drift vector follows the E field vector. The effect of distortion is integrated over the \nelectron drift length. The track position resolution $\\sigma$ is on the level of 100 microns.\nTherefore the nonlinearities due to the E field imperfection can not be neglected.\n\nDistortions can be estimated by histograming the difference between the tracks and the corresponding\n space points. ($\\Delta_z= Z_p-Z_f$,$\\Delta_y= Y_p-Y_f$).The tracks are fitted in the region where the distortion is assumed to be minimal.\nIn our studies, the first and the last 15 pad-rows close to the Inner and Outer field cage were removed from the fit.\n\nTo estimate radial distortion we assume following model:\n\\begin{equation}\n\\Delta_y=\\Delta_{y0}(R,Z)+\\Delta_R(R,Z)\\tan(\\Phi) \n\\end{equation}\n\\begin{equation}\n\\Delta_z=\\Delta_{z0}(R,Z)+\\Delta_R(R,Z)\\tan(\\Theta)\n\\end{equation}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortion/hisdz_XZ0.eps,width=0.8\\linewidth}\t\n  \\centering\\epsfig{figure=picDistortion/hisdz_XAside.eps,width=0.8\\linewidth}\n  \\centering\\epsfig{figure=picDistortion/hisdz_XCside.eps,width=0.8\\linewidth}\n  \\caption{Mean residuals between the track and the space point in z direction as a function of radial position. }\n  \\label{figLocalZDistortion}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortion/hisdy_XZ.eps,width=0.8\\linewidth}\t\n  \\centering\\epsfig{figure=picDistortion/hisdy_XAside.eps,width=0.8\\linewidth}\n  \\centering\\epsfig{figure=picDistortion/hisdy_XCside.eps,width=0.8\\linewidth}\n  \\caption{Mean residuals between the track and the space point in y direction as a function of radial position. Only tracks with positive tan($\\phi$) used. }\n  \\label{figLocalYDistortion}\n\\end{figure}\n\n\nThe influence of radial distortion effect to the cluster residuals in y direction is visualized on picture \\ref{figLocalYDistortion}.\nClose to the Outer field cage the points are systematically shifted. This shift can be\nfitted with exponential fit function with decay length $\\approx$ 7 cm.\n \nThe radial distortion is smaller on C side than on A side, and is proportional to the drift length (see \\ref{figRadialDistortionMapDZ}).\nTo describe the effect in two dimensions 2 exponential decay model was fitted.\n\\begin{equation}\n\\Delta_R=(k5_0+k5_1z+k5_2z^2)e^{-d_{out}/5}+(k10_0+k10_1z+k10_2z^2)e^{-d_{out}/10}\n\\end{equation}\nChosen model is linear in parameters and therefore has a analytical solution.\n(I do not have better idea for the moment). \n\nThe fitted radial distortion is also sector  dependent (see pic. \\ref{figRadialDistortionMapXY})\nThe statistical error of the fit using 400000 tracks is about 0.2 mm.\n\n\n\n\nThe effect of missing correction for the radial distortion on track angular matching is visualized in picture \\ref{figAngularAlignRdist}. The radial distortion has to be calibrated before, or together with the alignment. \n\n\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortion/hisdrfitAC_DZ.eps,width=0.6\\linewidth}\n  \\caption{Fitted radial distortion map.}\n  \\label{figRadialDistortionMapDZ}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortion/hisdrfitA_XY2.eps,width=0.6\\linewidth}\n  \\centering\\epsfig{figure=picDistortion/hisdrfitC_XY2.eps,width=0.6\\linewidth}\n  \\caption{Fitted radial distortion map (XY).}\n  \\label{figRadialDistortionMapXY}\n\\end{figure}\n\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortion/dphi_zphi,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picDistortion/dtheta_ztheta,width=0.5\\linewidth}\n  \\caption{Angular matching between OROC and IROC as function of z. Indication of the radial \n           distortions }\n  \\label{figAngularAlignRdist}\n\\end{figure}\n\n\\section{R-$\\Phi$ distortion}\n\nA R-$\\Phi$ distortion is obsered at the edge of the chambers. This distortion depends on the distance to the edge pad - $d_{pad0}$ and on the distance to the wire mounting ($d_{w}$).\n\nThere are following components contributing:\n\\begin{itemize}\n\\item Main component. Cluster edge effect depends on the distance to edge pad (see pic. \\ref{figAngularAlignRPHIdist})\n\\item Decrease of amplification close to the edge ($d_{w}$ dependence).\n\\item Field distortion ($d_{w}$ dependence)\n\\end{itemize}  \n\nThe effect can be described using weighted Center of gravity function (see eq.\\ref{eq:WeightCOG})\nAt the edge of the chamber the signal is atenuated by factor $w_i$, and cut at the pad\nless then 0. The atenuation factor and Pad Responsense Function (PRF) width were measured independently and they were used on correction formula. The PRF is approximated by gaussian \ndistribution. \n\\begin{eqnarray}\n    \\Delta_{R\\Phi}(y)=y_{\\rm{COG}}-y=\\frac{\\sum_{i=0}^{N}{iw_if_{ri}}}{\\sum_{i=1}^N{w_if_{ri}}}-y \\\\\n    w_i = 1-k_ae^{-d_il_a} \\\\\n    f_{ri}=e^{-(y_p-y)^2/(2\\sigma^2)} \t\n\\label{eq:WeightCOG}\n\\end{eqnarray}\n\nThe correction formula describe the data down to 2 cm distance with precission bellow 0.5 mm\n(see pic. \\ref{figAngularAlignRPHIdistCorr} upper plot). For practical usage in tracking we reject the clusters with in the TPC region with $R-\\Phi$ correction bigger than cluster position resolution  ($\\approx 1 mm$).\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picDistortionRPHI/ycl_ytcm.eps,width=0.5\\linewidth}\n  \\epsfig{figure=picDistortionRPHI/ycl_ytpad.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picDistortionRPHI/dycl_ytcm.eps,width=0.5\\linewidth}\n  \\epsfig{figure=picDistortionRPHI/dycl_ytpad.eps,width=0.5\\linewidth}\n  \\caption{Clusters residual  at the edge of TPC sectors. $Y_0$ is the position of the edge pad.\n\t   For y bellow 0.5 pad width, the COG of cluster is almost independent of the track position. Non linear effect is observed up to distance 2 pad width. Small difference between the different pads can be explained by different Pad response function width.\n\t  }\n  \\label{figAngularAlignRPHIdist}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\\n  \\epsfig{figure=picDistortionRPHI/rphi_dist_max100.000000.eps,width=0.5\\linewidth}\n  \\epsfig{figure=picDistortionRPHI/rphi_dist_max0.100000.eps,width=0.5\\linewidth}\n\\caption{ Cluster residual at the edge of the TPC sectors. In upper part all clusters used, in lower part only the clusters with the estimated distortion bellow 1 mm used.}\n\\label{figAngularAlignRPHIdistCorr}\n\\end{figure}\n\n\n\\section{ Alice TPC alignment}\n\nProblems with y and phi alignment in the OROC -left right alignment. \nSystematic shift in y and phi.\nShift observed mainly for the short track. \nThe effect was reduced making stronger cut on pt matching and pt resolution.\n\n\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignMag5/SigmaY_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/DeltaY_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/PullY_z.eps,width=0.5\\linewidth}\n  \\caption{Field 0.5 T data. Extracted sigma, mean and pull in y matching between IROC and OROC}\n  \\label{figDeltaP0}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignNoMag/SigmaY_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/DeltaY_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/PullY_z.eps,width=0.5\\linewidth}\n  \\caption{No field data. Extracted sigma, mean and pull in y matching between IROC and OROC}\n  \\label{figDeltaP0}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignMag5/SigmaZ_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/DeltaZ_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/PullZ_z.eps,width=0.5\\linewidth}\n  \\caption{Field 0.5 T data. Extracted sigma, mean and pull in z matching between IROC and OROC}\n  \\label{figDeltaP1}\n\\end{figure}\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignNoMag/SigmaZ_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/DeltaZ_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/PullZ_z.eps,width=0.5\\linewidth}\n  \\caption{No field data.Extracted sigma, mean and pull in z matching between IROC and OROC}\n  \\label{figDeltaP1}\n\\end{figure}\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignMag5/SigmaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/DeltaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignMag5/PullP4_z.eps,width=0.5\\linewidth}\n  \\caption{Field 0.5 T data. Extracted sigma, mean and pull in curvature matching between IROC and OROC}\n  \\label{figDeltaP1}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignNoMag/SigmaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/DeltaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/PullP4_z.eps,width=0.5\\linewidth}\n  \\caption{No field data. Extracted sigma, mean and pull in curvature matching between IROC and OROC}\n  \\label{figDeltaP1}\n\\end{figure}\n\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignNoMag/SigmaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/DeltaP4_z.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignNoMag/PullP4_z.eps,width=0.5\\linewidth}\n  \\caption{No field data. Extracted sigma, mean and pull in curvature matching between IROC and OROC}\n  \\label{figDeltaP1}\n\\end{figure}\n\n\n\n\\section{ Alice TPC alignment comparison of data with and without field.}\n\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignComp/mag5dPhi.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/nomagdPhi.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/diffnomagmag5dPhi.eps,width=0.5\\linewidth}\n  \\caption{$\\phi$ Angular alignment. Data with and without magnetic field}\n  \\label{figDeltaPhi}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignComp/mag5dTheta.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/nomagdTheta.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/diffnomagmag5dTheta.eps,width=0.5\\linewidth}\n  \\caption{$\\theta$ Angular alignment. Data with and without magnetic field}\n  \\label{figDeltaTheta}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignComp/mag5dZ.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/nomagdZ.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/diffnomagmag5dZ.eps,width=0.5\\linewidth}\n  \\caption{Z alignment. Data with and without magnetic field}\n  \\label{figDeltaZ}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\\epsfig{figure=picAlignComp/mag5dY.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/nomagdY.eps,width=0.5\\linewidth}\n  \\centering\\epsfig{figure=picAlignComp/diffnomagmag5dY.eps,width=0.5\\linewidth}\n  \\caption{Y alignment. Data with and without magnetic field}\n  \\label{figDeltaY}\n\\end{figure}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n\n\n\n\n", "meta": {"hexsha": "033bf13faeb1e74c6ca394f9e896e255b654957b", "size": 11086, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TPC/doc/calib/alignment/alignment.tex", "max_stars_repo_name": "AllaMaevskaya/AliRoot", "max_stars_repo_head_hexsha": "c53712645bf1c7d5f565b0d3228e3a6b9b09011a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 52, "max_stars_repo_stars_event_min_datetime": "2016-12-11T13:04:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T11:49:35.000Z", "max_issues_repo_path": "TPC/doc/calib/alignment/alignment.tex", "max_issues_repo_name": "AllaMaevskaya/AliRoot", "max_issues_repo_head_hexsha": "c53712645bf1c7d5f565b0d3228e3a6b9b09011a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1388, "max_issues_repo_issues_event_min_datetime": "2016-11-01T10:27:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T15:26:09.000Z", "max_forks_repo_path": "TPC/doc/calib/alignment/alignment.tex", "max_forks_repo_name": "AllaMaevskaya/AliRoot", "max_forks_repo_head_hexsha": "c53712645bf1c7d5f565b0d3228e3a6b9b09011a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 275, "max_forks_repo_forks_event_min_datetime": "2016-06-21T20:24:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T13:06:19.000Z", "avg_line_length": 40.9077490775, "max_line_length": 256, "alphanum_fraction": 0.7787299296, "num_tokens": 3369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4425310272534924}}
{"text": "\\section{Fredholm analysis of the integral representations}\n\\label{sec:analysis}\nIn this section, we establish how layer potential\nrepresentations of oscillatory Stokes velocity fields\ncan be used to compute Stokes eigenvalues.\n%\nThe main results show that for certain representations\nthe resulting integral equation is not invertible precisely\nwhen $k^2$ is an eigenvalue.\n%\nFor the interior Dirichlet eigenvalue problem, this is\nproved separately for a double layer representation on\nsimply connected domains in \\cref{thm:dlmain} and\nfor a combined-field representation on multiply connected\ndomains in \\cref{thm:cfmain}.\n%\n\nBefore proving the main theorems, we require a number\nof uniqueness results for oscillatory Stokes boundary\nvalue problems.\n%\nTo prove the uniqueness results, we follow the \nstructure presented in Colton and Kress~\\cite[Ch. 3]{colton1983integral}\nfor the scalar Helmholtz equation.\n%\nWhile uniqueness results for interior Dirichlet,\nNeumann, and impedance problems follow from energy\nconsiderations and compactness arguments, the proofs\nfor the uniqueness of exterior problems are more\ninvolved.\n%\nIn particular, the exterior problems are only \nwell-posed after imposing an appropriate radiation\ncondition.\n%\nWe formulate well-posed boundary value problems \nfor both interior and exterior domains with\nDirichlet, Neumann and impedance boundary\nconditions and present uniqueness results for\neach.\n\n\nAlong with the Fredholm alternative, these uniqueness\nresults are sufficient to prove\n\\cref{thm:dlmain,thm:cfmain}.\n%\nOnce the main theorems are established,\nthe details of how to use the Fredholm determinant\nas a numerical tool for computing the Stokes eigenvalues\nfollow in a straightforward manner from the results\nin~\\cite{zhao2015robust}.\n%\nWe reproduce these results in the present\ncontext for completeness.\n\n\\subsection{Boundary value problems --- interior}\n\nLet $\\Omega$ be a bounded domain with a $C^2$ boundary\ndenoted by $\\Gamma$.\nWe summarize the interior Dirichlet, Neumann and impedance\nboundary value problems in~\\cref{def:int_dir,def:int_neu,def:int_imp} below.\n\n\\begin{definition}[Interior Dirichlet problem]\n  \\label{def:int_dir}\n  Let $\\ff \\in C(\\Omega)$ be given. Find $(\\bu,p) \\in A(\\Omega)$\n  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:dir_interior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in \\Omega \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in \\Omega \\, ,  \\\\\n    \\bu &= \\ff \\quad \\bx \\in \\Gamma \\, .\n  \\end{aligned}\n  \\end{equation}\n\\end{definition}\nNote that the divergence-free constraint for the oscillatory\nStokes equations implies a compatibility condition on the\nDirichlet data $\\ff$, namely that\n\\begin{equation} \\label{eq:dir_compat}\n  \\int_\\Gamma \\ff \\cdot \\bnu \\, dS = 0 \\; .\n\\end{equation}\n\n\n\\begin{definition}[Interior Neumann problem]\n  \\label{def:int_neu}\n  Let $\\bg \\in C(\\Omega)$ be given. Find $(\\bu,p) \\in A(\\Omega)$\n  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:neu_interior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in \\Omega \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in \\Omega \\, ,  \\\\\n    \\bt &= \\bg \\quad \\bx \\in \\Gamma \\, .\n  \\end{aligned}\n  \\end{equation}\n\\end{definition}\n\n\\begin{definition}[Interior impedance problem]\n\\label{def:int_imp}\n  Let $\\bh \\in C(\\Omega)$ be given and suppose \n  $\\eta \\in \\mathbb{C}$ with $\\Re{(\\eta)} >0$ and $\\Im{(\\eta)}\\ge 0$. \n  Find $(\\bu,p) \\in A(\\Omega)$  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:imp_interior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in \\Omega \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in \\Omega \\, ,  \\\\\n    \\bt - i \\eta \\bu &= \\bh \\quad \\bx \\in \\Gamma \\, .\n  \\end{aligned}\n  \\end{equation}\n\\end{definition}\n\n\\subsection{A radiation condition for the oscillatory Stokes\n  equation}\n\n\\begin{figure}\n  \\begin{center}\n  \\includegraphics[width=0.4\\textwidth]{fig/ext_dom}\n  \\caption{Example of an exterior domain with four obstacles.}\n  \\label{fig:ext_dom}\n  \\end{center}\n\\end{figure}\n\nLet $\\Omega$ be the union of a finite collection of\nsimply connected domains, i.e. $\\Omega = \\bigcup_{i=1}^m \\Omega_i$\nfor some $m \\in \\N$,\nand let $E = \\R^{2} \\setminus \\bar{\\Omega}$ denote its\nexterior; see \\cref{fig:ext_dom} for an example with $m=4$.\n%\nLet $\\Gamma = \\partial E$ denote the boundary of $E$ and\n$\\bnu(\\yy)$ denote the exterior normal to the point $\\yy$ on\n$\\Gamma$, i.e. the normal vector pointing out of $E$ into $\\Omega$.\n%\nFor a given function $\\ff$ defined on $\\Gamma$,\nthe exterior Dirichlet boundary value problem is to\nfind a pair $(\\bu,p)$ which satisfies:\n\\begin{equation}\n\\begin{aligned}\n\\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in E \\, ,\\\\\n\\nabla \\cdot \\bu &= 0 \\quad \\bx \\in E \\, ,  \\\\\n\\bu &= \\ff \\quad \\bx \\in \\Gamma \\, . \\nonumber\n\\end{aligned}\n\\end{equation}\nIn addition to the boundary condition on\n$\\Gamma$, we must impose radiation conditions\nat $\\infty$, analogous to the Helmholtz equation.\n%\n\nLet $B_r(0)$ denote the disc of radius $r$ centered\nat the origin and $\\partial B_r(0)$ its boundary.\n%\nWe propose the following radiation condition.\n\n\\begin{definition} \\label{def:radcond}\nLet $(\\bu,p)$ satisfy the oscillatory Stokes equations in\nthe exterior of a bounded domain. We say that\nthe pair $(\\bu,p)$ is {\\em radiating} if\n\\begin{equation}\n\\lim_{r\\to \\infty} \\sqrt{r} \\left| \\bt - i k \\bu \\right| \\to 0 \\, ,\n\\label{eq:radcond}\n\\end{equation}\nuniformly in direction where $\\bt = \\bsigma \\cdot \\bnu$\nwith $\\bnu = \\xx/|\\xx|$, i.e. $\\bt$ is the surface\ntraction on $\\partial B_r(0)$.     \n\\end{definition}\n\nIn the following lemma, we show that the oscillatory\nStokeslet satisfies the radiation condition. \n\\begin{lem}\nThe oscillatory Stokeslet, as defined in \\eqref{eq:ostokeslet}, \nsatisfies the radiation condition in Definition \\ref{def:radcond}.\n\\end{lem}\n\\begin{proof}\nConsider the Stokeslet induced by an arbitrary charge\n$k^2 \\bpsi$ at the origin where $\\bpsi \\in \\mathbb{C}^2$ \nis a constant. Let $r = |\\xx|$,\n$\\bnu(\\xx) = \\xx/|\\xx|$, and $\\btau(\\xx) = \\bnu(\\xx)^\\perp$. We have\n\n\\begin{align*}\n\\bu (\\xx) &= k^2 \\GG(\\xx,0) \\bpsi \\\\\n&= k^2 \\left (-\\II \\Delta \\Gbh(\\xx,0)\n+ \\nabla \\otimes \\nabla \\Gbh(\\xx,0)\\right ) \\bpsi \\\\\n&= -k^2 \\left (\\nabla^\\perp \\otimes \\nabla^\\perp \\Gbh(\\xx,0) \\right) \\bpsi \\\\\n&= \\left(\\nabla^\\perp \\otimes \\nabla^\\perp \\left ( \\frac{1}{2\\pi}\n\\log r + \\frac{i}{4} H_0^{(1)} (kr) \\right ) \\right)\\bpsi \\; .\n\\end{align*}\nNote that derivatives of $\\log r$ are $\\littleo (1/\\sqrt{r})$\nand that the pressure associated with the Stokeslet is\n$p = \\nabla \\Glap(\\xx) \\cdot \\bpsi$. We then have\n\n\\begin{align*}\n\\left | \\sigma \\cdot \\bnu(\\xx) - i k \\bu \\right | &=\n\\left | p \\bnu(\\xx) + \\partial_{{\\nu_x}} \\bu + \\nabla (\\bu \\cdot \\bnu(\\xx))\n- ik \\bu \\right | \\\\\n&\\leq \\left | \\partial_{{\\nu_x}} \\bu - ik\\bu \\right | + \\left | \\nabla(\\bu \\cdot \\bnu(\\xx)) \\right |\n+ \\littleo (1/\\sqrt{r}) \\\\\n&\\leq \\frac{1}{4} \\left | \\partial_{{\\nu_x}} \\left(\\nabla^\\perp \\otimes\n\\nabla^\\perp \\left (H_0^{(1)} (kr) \\right ) \\right)\\bpsi\n- i k \\left(\\nabla^\\perp \\otimes \\nabla^\\perp\n\\left (H_0^{(1)} (kr) \\right ) \\right)\\bpsi \\right | \\\\\n& \\quad + \\left | \\nabla \\left( \\partial_{\\tau_x} \\left ( \n\\nabla^\\perp \\left (H_0^{(1)} (kr) \\right ) \\cdot \\bpsi  \\right )\n\\right) \\right | + \\littleo (1/\\sqrt{r}) \\; .\n\\end{align*}\nBecause $H_0^{(1)}(kr)$ has the asymptotic expansion \n\n\\begin{equation}\nH_0^{(1)}(kr) = \\sqrt{\\frac{2}{\\pi k r}} e^{i(rk-\\pi/4)} \\left ( 1 + O\\left (\n\\frac{1}{r} \\right ) \\right ) \\; \\nonumber\n\\end{equation}\nas $r\\to \\infty$, we have\n\n\\begin{equation}\n\\left | \\partial_{{\\nu_x}} \\left(\\nabla^\\perp \\otimes\n\\nabla^\\perp \\left (H_0^{(1)} (kr) \\right ) \\right)\\bpsi\n- ik \\left(\\nabla^\\perp \\otimes \\nabla^\\perp\n\\left (H_0^{(1)} (kr) \\right ) \\right)\\bpsi \\right | =\no ( 1/\\sqrt{r} ) \\; . \\nonumber\n\\end{equation}\nFinally, since $H_0^{(1)}(kr)$ is radially symmetric,\nwe have\n\n\\begin{equation}\n\\left | \\nabla \\left( \\partial_{\\tau_x} \\left ( \n\\nabla^\\perp \\left (H_0^{(1)} (kr) \\right ) \\cdot \\bpsi  \\right )\n\\right) \\right | = 0 \\; , \\nonumber\n\\end{equation}\nso that the Stokeslet satisfies the radiation condition.\n\\end{proof}\nA consequence of the above lemma is that the oscillatory Stokes\nsingle layer potential satisfies the radiation condition.\n\\begin{cor}\nSuppose that $\\Gamma$ is the boundary of a region $\\Omega$\nand is $C^{2}$. \nSuppose that $\\bmu \\in C(\\Gamma)\\times C(\\Gamma)$, then\nthe oscillatory Stokes single layer potential $\\bS[\\bmu]$,\nas defined in~\\cref{eq:singlelayer}, satisfies the radiation condition.\n\\end{cor}\nUnfortunately, the stresslet, as defined in~\\cref{eq:ostress}, \ndoes not necessarily satisfy the radiation condition.\nThe reason for failure is the logarithmic growth of \nthe pressure at $\\infty$.\nHowever, this turns out to be a rank-one issue and \nthe oscillatory Stokes double layer potential\ndoes satisfy the radiation condition \nif the density satisfies an integral constraint.\nThe following lemma proves this result.\n\n\\begin{lem}\nSuppose that $\\Gamma$ is the boundary of a region $\\Omega$\nand is $C^{2}$. \nSuppose that $\\bmu \\in C(\\Gamma) \\times C(\\Gamma)$ and satisfies\n$\\int_{\\Gamma} \\bmu \\cdot \\bnu dS = 0$, where\n$\\bnu$ denotes the outward normal to the curve $\\Gamma$.\nThen, the oscillatory Stokes \ndouble layer potential $\\bD[\\bmu]$, as defined in \\eqref{eq:doublelayer},\nalso satisfies the radiation condition.\n\\end{lem}\n\n\\begin{proof}\nWe only establish the\ndecay of the pressure, which we will denote by $p^\\bD$;\nthe rest of the terms in \\eqref{eq:radcond} can be bounded\nusing an argument like that for the Stokeslet above.\nBecause $p^\\bD$ is harmonic in the exterior of any disc\ncontaining $\\Gamma$, it is sufficient to show that\n$|\\nabla p^\\bD| = \\bigo (1/r^2)$. Let $\\btau$ denote the\npositively oriented tangent to the curve $\\Gamma$ and\n$\\mu_\\nu(\\yy)$ and $\\mu_\\tau(\\yy)$ denote $\\bmu(\\yy) \\cdot \\bnu(\\yy)$ and\n$\\bmu(\\yy) \\cdot \\btau(\\yy)$, respectively. Substituting\n$\\bD \\bmu$ into \\eqref{eq:ostokes}, we obtain\n\n\\begin{align*}\n\\nabla p^\\bD(\\xx) &= (\\Delta + k^2) \\bD \\bmu(\\xx) \\\\\n&= \\int_\\Gamma \\left (-k^2 \\nabla \\Glap (\\xx,\\yy) +\n2 \\nabla^\\perp \\partial_{\\nu\\tau} \\Glap (\\xx,\\yy) \\right ) \\mu_\\nu(\\yy)\n\\, dS(\\yy) \\\\\n& \\qquad + \\int_\\Gamma \\nabla^\\perp (\\partial_{\\tau\\tau}-\\partial_{\\nu\\nu})\\Glap \\mu_\\tau(\\yy)\n\\, dS(\\yy) \\; .\n\\end{align*}\nThe other terms are higher-order derivatives\nof $\\Glap$, so it is sufficient to show that the term\n\n\\begin{align*}\n|\\nabla p_1(\\xx)| &:= \\left |-k^2 \\nabla \\int_\\Gamma \\Glap(\\xx,\\yy)\n\\mu_\\nu(\\yy) \\, dS(\\yy) \\right |\n\\end{align*}\nis $\\bigo (1/r^2)$. In the following, let $z = x_1 + i x_2$ be the\npoint corresponding to $\\xx$ in the complex plane and let $R$\nbe the radius of some disc containing $\\Gamma$. If $|\\xx| > 2R$,\nwe can use the standard multipole expansion of $\\log(z-(y_1+iy_2))$\nand the assumption that $\\int_\\Gamma \\bmu \\cdot \\bnu = 0$\nto obtain\n\\begin{align*}\n|\\nabla p_1(\\xx)| &= \\frac{k^2}{2\\pi} \\left |  \\partial_z \\int_\\Gamma \\log(z-(y_1+iy_2))\n\\mu_\\nu(\\yy) dS(\\yy) \\right | \\\\\n&= \\frac{k^2}{2\\pi} \\left |  \\partial_z  \\left ( \\log(z) \\int_\\Gamma \\mu_\\nu(\\yy) \\, dS(\\yy)\n+ \\sum_{l=1}^\\infty \\frac{1}{z^l} \\int_\\Gamma \\left( y_1+iy_2 \\right)^l \\mu_\\nu(\\yy) \\, dS(\\yy)\n\\right ) \\right | \\\\\n&= \\frac{k^2}{2\\pi} \\left | \\sum_{l=1}^\\infty \\frac{-l}{z^{l+1}}\n\\int_\\Gamma \\left( y_1+iy_2 \\right)^l \\mu_\\nu(\\yy) \\, dS(\\yy) \\right | \\\\\n&= \\bigo (1/r^2) \\; .\n\\end{align*}\n\\end{proof}\n\n\\subsection{Boundary value problems --- exterior}\n\nLet $E$ and $\\Gamma$ be as in the previous subsection.\nThe radiation condition allows for a well-posed formulation\nof the exterior boundary value problems, which we\nsummarize in\n\\cref{def:dir_exterior,def:neu_exterior,def:imp_exterior} below.\n\n\\begin{definition}[Exterior Dirichlet problem]\n  \\label{def:dir_exterior}\n  Let $\\ff \\in C(\\Gamma)$ be given. Find $(\\bu,p) \\in A(E)$\n  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:dir_exterior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in E \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in E \\, ,  \\\\\n    \\bu &= \\ff \\quad \\bx \\in \\Gamma \\, , \n  \\end{aligned}\n  \\end{equation}\n  and $(\\bu,p)$ satisfies the radiation condition in\n  \\cref{def:radcond}.\n\\end{definition}\n\\begin{definition}[Exterior Neumann problem]\n  \\label{def:neu_exterior}  \n  Let $\\bg \\in C(\\Gamma)$ be given. Find $(\\bu,p) \\in A(E)$\n  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:neu_exterior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in E \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in E \\, ,  \\\\\n    \\bt &= \\bg \\quad \\bx \\in \\Gamma \\, ,\n  \\end{aligned}\n  \\end{equation}\n  and $(\\bu,p)$ satisfies the radiation condition in\n  \\cref{def:radcond}.\n\\end{definition}\n\n\\begin{definition}[Exterior impedance problem]\n  \\label{def:imp_exterior}  \n  Let $\\bh \\in C(\\Gamma)$ be given and suppose that\n  $\\eta \\in \\mathbb{C}$ with $\\Re{(\\eta)} > 0$ and $\\Im{(\\eta)} \\ge 0$. \n  Find $(\\bu,p) \\in A(E)$\n  such that\n  \\begin{equation}\n  \\begin{aligned} \\label{eq:imp_exterior}\n    \\Delta \\bu + k^{2} \\bu &= \\nabla p \\quad \\bx \\in E \\, ,\\\\\n    \\nabla \\cdot \\bu &= 0 \\quad \\bx \\in E \\, ,  \\\\\n    \\bt + i\\eta \\bu &= \\bh \\quad \\bx \\in \\Gamma \\, ,\n  \\end{aligned}\n  \\end{equation}\n  and $(\\bu,p)$ satisfies the radiation condition in\n  \\cref{def:radcond}.\n\\end{definition}\n\n\n\\subsection{Uniqueness results}\n\nBefore moving on to the exterior uniqueness theorems,\nwe establish the well-known result that\nthe $k$ corresponding to interior eigenvalues, $k^2$,\nare real-valued.\n\n\\begin{thrm}\n  Let $\\Omega$ be a bounded domain and suppose that\n  $\\Im (k) \\neq 0$. Then both the interior\n  Dirichlet and Neumann boundary value problems have\n  unique solutions.\n\\end{thrm}\n\\begin{proof}\n  A couple applications of the divergence theorem establish\n  that\n  \\begin{equation} \\label{eq:greenlike}\n    \\int_\\Omega |2\\be(\\bu)|^2 - \\overline{k}^2 |\\bu|^2 \\, dV\n    = \\int_\\Gamma \\bu \\cdot \\overline{\\bt} \\, dS \\; . \n  \\end{equation}\n  Suppose that either $\\bu = 0$ or $\\bt = 0$ on $\\Gamma$.\n  Then, the right hand side of \\cref{eq:greenlike} is\n  zero. \n  Taking the real and imaginary parts of \\cref{eq:greenlike},\n  it is clear that $\\bu \\equiv 0$, if $\\text{Im}(k) \\neq 0$.\n\\end{proof}\n\nIn the following lemma, we prove uniqueness for the\ninterior impedance problem.\n\n\\begin{thrm}\n  Let $\\Omega$ be a bounded domain and suppose that\n  $\\Re(k),\\Im (k) > 0$. Then the interior\n  impedance problem has a unique solution.\n\\end{thrm}\n\\begin{proof}\n  Plugging $\\bt = i\\eta \\bu$ in~\\cref{eq:greenlike}\n  and taking the imaginary part, we get\n  \\begin{equation}\n   2 \\Re{(k)} \\Im{(k)} \\int_{\\Omega} |\\bu|^2\\, dV + 2\\Re{(\\eta)} \\int_{\\Gamma}\n   |\\bu|^2 \\, dS = 0 \\, ,\n  \\end{equation}\n  from which it is is clear that $\\bu \\equiv 0$, since\n  $\\Re{(\\eta)}, \\Re{(k)}, \\Im{(k)} > 0$.\n\\end{proof}\n\nWe now turn our attention to the proofs of the exterior boundary value problems\nfor the oscillatory Stokes equation. The following lemmas are useful for\nproving these results.\n\n\\begin{lem}\n  \\label{lem:rep}\n  Let the unbounded region $E$ be given as the exterior\n  of a finite collection of bounded domains.\n  Suppose that $(\\bu,p)$ satisfies the oscillatory Stokes equation in \n  $E$ as well as the radiation condition~\\cref{eq:radcond}. \n  Then \n  \\begin{multline}\n    \\label{eq:repinfest}  \n    \\lim_{r\\to\\infty}\n    \\int_{|\\by|=r} \\left( |\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS +\n    2 \\Im(k) \\int_{E \\cap B_{r}(0)} \\left(|k|^2 |\\bu|^2 + |2\\be(\\bu)|^2 \\right)\n    dV \\\\\n    + 2 \\Im \\left( k \\int_{\\Gamma} \\bu \\cdot \n\\overline{\\bt} dS  \\right) = 0\n  \\end{multline}\n  \n\\end{lem}\n\n\\begin{proof}\nSince $(\\bu,p)$ satisfies the radiation condition, we have that\n\\begin{equation}\n\\lim_{r\\to\\infty} \\int_{|\\by|=r} | \\bt - i k \\bu|^2 dS = \n\\lim_{r\\to\\infty} \\int_{|\\by| =r} \\left( |\\bt|^2 + |k|^2|\\bu|^2 + 2 \\Im \n\\left( k \\bu\\cdot \\overline{\\bt} \\right) dS \\label{eq:raddecayproof1}\n\\right) = 0 \\, . \n\\end{equation}\nSince $\\bu$ satisfies the oscillatory Stokes equation $E \\cap B_{r}(0)$,\nusing a couple of applications of the divergence theorem, we have that\n\\begin{equation}\n\\int_{E\\cap B_{r}(0)} |2 \\be(\\bu)|^2 dV =\n-\\int_{\\Gamma} \\bu \\cdot \\overline{\\bt} dS\n+ \\int_{|\\by|=r} \\bu \\cdot \\overline{\\bt} dS + \\overline{k}^2 \n\\int_{E \\cap B_{r}(0)} |\\bu|^2 dV \\,. \\label{eq:raddecayproof2}\n\\end{equation}\nCombining~\\cref{eq:raddecayproof1,eq:raddecayproof2}, we get\n\\begin{multline*}\n\\lim_{r\\to\\infty} \\int_{|\\by|=r}\\left(|\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS \n+ 2 \\Im(k)\\int_{E \\cap B_{r}(0)} \\left(|2\\be(\\bu)|^2 + |k|^2 |\\bu|^2 \n\\right) dV \\\\\n+ 2\\Im \\left ( k \\int_{\\Gamma} \\bu \\cdot \\overline{\\bt} dS \\right) = 0 \\, .\n\\end{multline*}\n\\end{proof}\n\nIn the next lemma, we prove the analogue of Rellich's lemma for the\noscillatory Stokes equation. \n\\begin{lem}\n  \\label{lem:rellich}\n  Let the unbounded region $E$ be given as the exterior\n  of a finite collection of bounded domains.\n  Suppose $k$ is real, $\\bu$ satisfies the oscillatory\n  Stokes equation in $E$, and that \n\\begin{equation}\n\\lim_{r \\to \\infty} \\int_{|\\by|=r} |\\bu|^2 dS = 0 \n\\, . \\label{eq:decayatinf}\n\\end{equation}\nThen each component of $\\bu$ is harmonic in $E$.\n\\end{lem}\n\\begin{proof}\nWe first note that each component of $\\bu= (u_{1},u_{2})$ satisfies the \noscillatory biharmonic equation in $E$, i.e.\n\\begin{equation}\n\\Delta (\\Delta + k^2) u_{j} = 0 \\quad j=1,2 \\,. \\nonumber\n\\end{equation}\nFor $r$ sufficiently large, we can express $u_{j}$ in the Fourier basis as\n\\begin{equation}\nu_{j}(r,\\theta) = \\sum_{n=-\\infty}^{\\infty} a_{j,n}(r) e^{i n \\theta}  \\quad \nj=1,2 \\, . \\nonumber\n\\end{equation}\nUsing Parseval's identity then\n\\begin{equation}\n\\int_{|\\by|=r} |\\bu|^2 dS = r\\sum_{n=-\\infty}^{\\infty} |a_{1,n}(r)|^2  +\n|a_{2,n}(r)|^2 \\, . \\nonumber\n\\end{equation}\nSince $\\bu$ satisfies~\\cref{eq:decayatinf}, we conclude that\n\\begin{equation}\n\\lim_{r\\to\\infty} r|a_{j,n}(r)|^2 = 0 \\quad j=1,2 \\, , \\label{eq:adecay}\n\\end{equation}\nSince $u_{j}$, $j=1,2$ satisfies the oscillatory biharmonic equation,\nthe functions $a_{j,n}$ are linear combinations of \n\\begin{equation}\nr^{|n|}, r^{-|n|}, H^{(1)}_{n}(k r), H^{(2)}_{n}(k r) \\, , \\quad\nn\\neq 0 \\, , \\nonumber\n\\end{equation}\nand\n\\begin{equation}\n1, \\log{(r)}, H^{(1)}_{0}(k r), H^{(2)}_{0}(k r) \\quad n=0 \\, ,  \\nonumber\n\\end{equation} \nwhere $H_{n}^{(1),(2)}(\\cdot)$ are the Hankel functions of the first and\nsecond kind of order $n$.\nSince $a_{j,n}(r)$ satisfy~\\cref{eq:adecay}, and using the asymptotic \nexpansion of $H_{n}^{(1),(2)}(kr)$ when $k$ and $r$ are real-valued, we note\nthat the projection of $a_{j,n}$ on $r^{|n|}$, and $H_{n}^{1,2}(k r)$\nmust be zero. Thus, for sufficiently large $r$,\n\\begin{equation}\nu_{j}(r,\\theta) = \\sum_{n=-\\infty}^{\\infty} \\frac{a_{j,n} e^{i n \\theta}}{r^{|n|}} \n\\, , \\nonumber\n\\end{equation}\ni.e. $u_{j}$ is harmonic \nin $B_{r}(0)^{c}$.\nFinally, by \\cref{cor:analytic}, $\\bu$ is\nanalytic in $E$. Therefore, each $u_j$ is harmonic\nthroughout $E$.\n\\end{proof}\n\n\\begin{remark} \\label{rmk:harmu}\n  Note that if $\\bu$ satisfies the assumptions\n  of~\\cref{lem:rellich}, then each component is harmonic\n  and thus $\\bu$ satisfies\n\\begin{align}\nk^2 \\bu &= \\nabla p \\label{eq:massconsred} \\; .\n\\end{align}\n\\end{remark}\n\n\\begin{remark}\n  It should be noted that in~\\cref{lem:rellich}, $\\bu$ need\n  not be a radiating solution. All that is assumed of $\\bu$\n  is that it satisfies the oscillatory Stokes equations in $E$.\n\\end{remark}\n\nWe now have the results needed to establish the\nuniqueness of exterior boundary value problems.\n\n\\begin{thrm}[Uniqueness of the Exterior Dirichlet Problem]\n  \\label{thrm:unique_dir_ext}\n  Let the unbounded region $E$ be given as the exterior\n  of a finite collection of bounded domains.\n  Suppose that $\\Im(k)\\geq 0$ and \n  that $(\\bu,p)$ is a radiating solution to the oscillatory Stokes\n  equation in $E$ with $\\bu =0$ on the boundary $\\Gamma$, then\n  $\\bu \\equiv 0$ in $E$.\n\\end{thrm}\n\n\\begin{proof}\nSince $\\bu = 0$ on $\\Gamma$, it follows from~\\cref{lem:rep} that\n\\begin{equation}\n\\lim_{r\\to\\infty}\n\\int_{|\\by|=r} \\left( |\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS +\n2 \\Im(k) \\int_{E \\cap B_{r}(0)} \\left(|k|^2 |\\bu|^2 + |\\be(\\bu)|^2 \\right)\ndV = 0 \\nonumber\n\\end{equation}\n\nSuppose that $\\Im(k) > 0$. Then, it is immediate that\n$\\bu \\equiv 0$ in $E$.\n\nSuppose that $k$ is real valued. It is clear that\n\\begin{equation}\n\\lim_{r\\to\\infty} \\int_{|\\by|=r} |\\bu|^2 dS = 0 \\, . \\nonumber\n\\end{equation}\nThus, the conditions on $\\bu$ and $k$ in~\\cref{lem:rellich}\nare satisfied, and each component of $\\bu$ is a harmonic function\nwith $\\bu \\to 0$ as $r \\to \\infty$. Furthermore, since $\\bu=0$ on\n$\\Gamma$, by the uniqueness of solutions to the\nDirichlet problem for Laplace's equation\non exterior domains, we conclude that $\\bu \\equiv 0$\nin $E$.\n\\end{proof}\n\n\\begin{thrm}[Uniqueness of the Exterior Neumann Problem]\n  Suppose that $\\Omega$ is the union of a finite collection \n  of simply connected domains, i.e. $\\Omega = \\bigcup_{i=1}^m \\Omega_{i}$\n  for some $m \\in \\N$, with $C^{2}$ boundaries, \n  and let $E = \\R^{2} \\setminus \\bar{\\Omega}$ denote its exterior;\n  see~\\cref{fig:ext_dom} for an example with $m=4$.\n  Let $\\Gamma_{i}$ denote the boundary of $\\Omega_{i}$, \n  and $\\Gamma = \\bigcup_{i=1}^{m} \\Gamma_{i}$ denote the boundary\n  of $\\Omega$.\n  Suppose that $\\Im(k)\\geq 0$ and \n  that $(\\bu,p)$ is a radiating solution to the oscillatory Stokes\n  equation in $E$ with $\\bt = 0$ on the boundary $\\Gamma$, then\n  $\\bu \\equiv 0$ in $E$.\n\\end{thrm}\n\n\\begin{proof}\nSince $\\bt = 0$ on $\\Gamma$, it follows\nfrom~\\cref{eq:repinfest} that\n\\begin{equation}\n\\lim_{r\\to\\infty}\n\\int_{|\\by|=r} \\left( |\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS +\n2 \\Im(k) \\int_{E \\cap B_{r}(0)} \\left(|k|^2 |\\bu|^2 + |\\be(\\bu)|^2 \\right)\ndV = 0 \\; . \\nonumber\n\\end{equation}\n\nSuppose that $\\Im(k) > 0$. It is then immediate\nthat $\\bu \\equiv 0$ in $E$.\n\nSuppose that $k$ is real. It is clear that\n\\begin{equation}\n\\lim_{r\\to\\infty} \\int_{|\\by|=r} |\\bu|^2 dS = 0 \\, . \\nonumber\n\\end{equation}\nThus, the conditions on $\\bu$ and $k$ in \\cref{lem:rellich}\nare satisfied, and each component of $\\bu$ is a harmonic function\nwith $\\bu \\to 0$ as $r \\to \\infty$. Furthermore, as observed\nin \\cref{rmk:harmu}, $k^2 \\bu = \\nabla p$. Then, the boundary\ncondition becomes $0 = \\bt = -p \\bnu + 2 \\nabla \\partial_\\nu p/k^2$.\nBecause $0 = \\btau \\cdot \\bt = 2\\partial_{\\tau\\nu} p/k^2$,\n$\\partial_\\nu p  = c_{i}$ on $\\Gamma_{i}$ for each $\\Gamma_{i}$,\nwhere $c_{i}$ is a constant. \nObserve that $|\\bu|$ and $|\\be(\\bu)|$ must be $O(1/r)$ as\n$r\\to\\infty$. Thus,\nfor a radiating pair $(\\bu,p)$ with $p$ harmonic,\nwe have that $|p| = O(1/r)$ and $|\\nabla p| = O(1/r^2)$\nas $r\\to\\infty$.\nSince the boundary is $C^{2}$ and the boundary data for $p$\nis analytic, we conclude that $p$ is $C^{2}$ in\n$\\overline{E}$.\nFurthermore, $\\bt=0$ implies $p \\bnu = 2\\nabla \\partial_{\\nu} p/k^2$, \nand taking the dot\nproduct with $\\bnu$, we get\n$p = 2\\partial_{\\nu \\nu}p/k^2$. \nIt then follows that\n$p = -2\\partial_{\\tau \\tau}p/k^2$ on $\\Gamma$ since \n$p$ is harmonic in $E$ and $C^{2}$ in $\\overline{E}$. \nSince $p$ satisfies the radiation condition at $\\infty$,\nwe have\n\\begin{equation}\n\\begin{aligned}\n\\int_{E} |\\nabla p|^2 dV &= \n\\sum_{i=1}^{m} \\int_{\\Gamma_{i}} p \\partial_{\\nu}p \\,dS \\\\\n&= \\sum_{i=1}^{m} c_{i} \\int_{\\Gamma_{i}} p \\,dS \\quad \\text{(Since $\\partial_{\\nu} p = c_{i}$ on\n$\\Gamma_{i}$)} \\\\ \n&= -\\sum_{i=1}^{m} \\frac{2c_{i}}{k^2} \\int_{\\Gamma_{i}} \\partial_{\\tau \\tau} p \\,dS \n\\quad \\text{(Since $p = -\\partial_{\\tau \\tau}p/k^2$ on $\\Gamma$)} \\\\\n&= 0\n\\end{aligned}\n\\end{equation}\nThus, $p$ is a constant in $E$. Furthermore, since $p\\to 0$ at $\\infty$, \nwe conclude that $p\\equiv 0$ in $E$. \nFinally, since $k^2 \\bu = \\nabla p$, we conclude that $\\bu\\equiv 0$ in \n$E$.\n\\end{proof}\n\n\\begin{thrm}[Uniqueness of the Exterior Impedance Problem]\n  Let the unbounded region $E$ be given as the exterior\n  of a finite collection of bounded domains.\n  Suppose that the complex numbers $\\eta$ and $k$ satisfy that\n  $\\Re(\\eta), \\Re(k) > 0$ and $\\Im(\\eta),\\Im(k) \\geq 0$.\n  Suppose further that\n  $(\\bu,p)$ is a radiating solution of the\n  oscillatory Stokes equation in $E$ which satisfies\n  the homogeneous impedance boundary condition\n  \\begin{equation}\n\\bt + i \\eta \\bu = 0 \\quad \\xx \\in \\Gamma \\, . \\nonumber\n\\end{equation}\nThen $\\bu \\equiv 0$ for $\\xx \\in E$.\n\\end{thrm}\n\n\\begin{proof}\nSince $\\bu$ satisfies the radiation condition at $\\infty$ and $\\bt = -i\\eta \\bu$\non $\\Gamma$, it follows from~\\cref{eq:repinfest} that\n\\begin{align*}\n0 &=\n\\int_{|\\by|=r} \\left( |\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS +\n2 \\text{Im}(k) \\int_{E \\cap B_{r}(0)} \\left(|k|^2 |\\bu|^2 + |2\\be(\\bu)|^2 \\right)\ndV \\nonumber \\\\\n& \\qquad + 2 \\text{Im} \\left( k \\int_{\\Gamma} \\bu \\cdot \\overline{\\bt} dS  \\right) \\\\\n&= \n\\int_{|\\by|=r} \\left( |\\bt|^2 + |k|^2 |\\bu|^2 \\right) dS +\n2 \\text{Im}(k) \\int_{E \\cap B_{r}(0)} \\left(|k|^2 |\\bu|^2 + |2\\be(\\bu)|^2 \\right)\ndV \\nonumber \\\\\n& \\qquad + 2 \\left( \\left (\\Re(k)\\Re(\\eta) + \\Im(k)\\Im(\\eta)\n\\right ) \\int_{\\Gamma} |\\bu|^{2} dS  \\right)\n\\, .\n\\end{align*}\nBecause all of the quantities in the last expression above are\nnonnegative, we have that\n\\begin{equation}\n  \\int_{\\Gamma} |\\bu|^{2} = 0 \\implies \\bu = 0  \\quad \\xx \\in \\Gamma \\, .\n  \\nonumber\n\\end{equation}\nThe result then follows from the uniqueness of solutions to the exterior\nDirichlet problem.\n\\end{proof}\n\n\\subsection{The integral equations and their null-spaces}\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.4\\textwidth]{fig/mc_dom}\n\\end{center}\n\\caption{Example of a multiply connected domain with four obstacles.}\n\\label{fig:mc_dom}\n\\end{figure}\n\nIn this section, we establish the correspondence between\nStokes eigenvalues and the invertibility of certain integral\nequations arising from layer potential representations\nof solutions to the oscillatory Stokes equation.\n\nLet $\\Omega$ be a bounded domain given as\nthe intersection of a simply connected domain $\\Omega_0$ and\nthe exteriors of a finite collection of bounded,\nsimply connected domains $\\{ \\Omega_i \\}_{i=1}^m$\nwhose closures are contained in $\\Omega_0$;\nsee \\cref{fig:mc_dom} for an example with four inclusions.\nNote that the\nexterior of $\\Omega$, which we denote by $E$, is the\ndisjoint union of the exterior of $\\Omega_0$, which we\ndenote $E_0$, with the sets $\\{ \\Omega_i \\}_{i=1}^m$.\nLet $\\Gamma$ denote the boundary of $\\Omega$ with the normal\n$\\bnu$ pointing out of $\\Omega$.\nWe will use superscript $+$ and $-$ signs\nto indicate the limit values of a function on $\\Gamma$\nas approached from the exterior and interior, respectively.\n\nFor the sake of brevity, we consider only the\nDirichlet eigenvalue problem but a similar analysis\ncould be applied to the Neumann eigenvalue problem.\nWe analyze two different representations for the\nDirichlet problem: a double layer potential,\ni.e. setting $\\bu=\\bD_{k} \\bmu$, and a combined-field\nlayer potential, i.e. setting\n$\\bu=(i\\eta \\bS_{k} + \\bD_{k})\\bmu$. \nWhile both representations result in a second kind\nintegral equation for the oscillatory Stokes Dirichlet\nproblem, the double layer potential has spurious non-trivial\nnullspaces on domains with positive genus, as\nexplained below.\n\n\\begin{remark}\n  The application of the Fredholm alternative here\n  again follows the structure used for the Laplace\n  eigenvalue problem in~\\cite[Ch. 3]{colton1983integral}.\n\\end{remark}\n\n\n\\subsubsection{Dirichlet eigenvalues --- double layer\n  representation}\n\\label{subsec:dlanalysis}\nSuppose that the solution to the oscillatory\nStokes Dirichlet problem, \\cref{eq:dir_interior},\nis represented using a double layer potential defined\non $\\Gamma$, i.e. setting $\\bu = \\bD_{k} \\bmu$ where\n$\\bmu$ is an unknown density. \nSubstituting this expression\ninto the boundary condition and applying\n\\cref{lem:jump-conds}, we obtain\n\n\\begin{equation}\n  (\\cI - 2\\cD_{k}) \\bmu = -2\\ff \\; . \\label{eq:inteq_dir_int}\n\\end{equation}\n\nThe rank deficiency of $\\cI-2\\cDk$ is\nwell-known~\\cite{biros2002embedded} and we summarize it\nin the lemma below.\n\n\\begin{lem}\n  \\label{lem:nunull} In the notation above,\n  $\\bnu \\in \\cN(\\cI - 2\\cDkt)$.\n\\end{lem}\n\\begin{proof}\nFrom~\\cref{lem:propnullspacecorr}, we note that\n$W[(\\cI - 2\\cD_{k})\\bmu] =0$ implies that\n$\\left<(\\cI -2\\cD_{k})\\bmu ,\\bnu \\right> = 0$ for\nall $\\bmu$, i.e. $\\bnu \\in R(\\cI - 2\\cD_{k})^{\\perp}$, where\n$R(A)$ denotes the range of the operator $A$. \nBy the Fredholm alternative, the result then follows.\n\\end{proof}\nThus, we instead analyze the equation\n\\begin{equation}\n(\\cI - 2\\cD_{k}  -2\\cW) \\bmu = -2\\ff \\; \\, . \\label{eq:inteq_dir_int_mod}\n\\end{equation}\nNote that if $\\ff$ satisfies the compatibility\ncondition $\\int_\\Gamma \\ff \\cdot \\bnu \\, dS =0$, then\n\\cref{eq:inteq_dir_int_mod} implies \\cref{eq:inteq_dir_int}.\n\nOn simply connected domains, there is a one-to-one correspondence between\nthe eigenvalues of the Dirichlet problem for\nthe Stokes equation\nand the values of $k$ for which the operator $(\\cI - 2\\cD_{k} - 2\\cW)$\nis not invertible. To prove this, we also need the \nfollowing lemma:\n\\begin{lem}\n  \\label{lem:nutracli}\n  If $\\bt^{-}$ is the surface traction associated\n  with an interior Dirichlet Stokes eigenfunction $\\bu$,\n  then $\\bt^{-}$ and $\\bnu$ are linearly independent.\n\\end{lem}\n\\begin{proof}\nWe first note that $\\bS_{k}[\\bnu](\\bx) = 0$ for all $\\bx \\in \\Omega$.\nThis follows from an application of the divergence\ntheorem and the fact that\noscillatory Stokeslet is divergence free in $\\Omega$. \nIf $\\bt^{-}$ is a surface traction associated with\na Stokes eigenvalue, then\nusing Green's theorem, it follows that\n$\\bS_{k}[\\bt^{-}](\\bx) = \\bu(\\bx) \\neq 0$ for $\\bx \\in \\Omega$ and\nthus $\\bt^{-}$ and $\\bnu$ are linearly independent.\n\\end{proof}\n\n\\begin{thrm}\n\\label{thm:dlmain}\nSuppose that $\\Omega$ is a bounded, simply connected domain. Then, the operator\n$(\\cI - 2\\cD_{k} - 2 \\cW)$ is not invertible if and only if $k^2$ is a\nDirichlet eigenvalue for the Stokes equation on $\\Omega$.\n\\end{thrm}\n\\begin{proof}\n  Suppose that $k^2$ is not a Dirichlet eigenvalue for\n  the Stokes equation on\n$\\Omega$. \nSuppose further that $\\bmu$ satisfies\n\\begin{equation}\n(\\cI - 2\\cD_{k} - 2\\cW) \\bmu = 0 \\, , \\label{eq:dlproofrep}\n\\end{equation}\ni.e. $\\bmu$ is in the null-space\nof $(\\cI - 2 \\cD_{k} - 2 \\cW)$. \nApplying the operator $\\cW$ to~\\cref{eq:dlproofrep} and \nusing~\\cref{lem:propnullspacecorr}, we get\n\\begin{equation}\n0 = \\cW [(\\cI - 2\\cD_{k} - 2\\cW)\\bmu] = -2\\cW [\\bmu] \\, .\n\\end{equation}\nThus~\\cref{eq:dlproofrep} reduces to\n\\begin{equation}\n(\\cI - 2 \\cD_{k})\\bmu = 0\\, .\n\\end{equation}\nSuppose now $\\bu = -2\\bD_{k}[\\bmu]$ in $\\Omega$.\nThen $\\bu$ is a solution to the oscillatory Stokes equation in $\\Omega$,\nand applying~\\cref{lem:jump-conds}, we get that the interior\nlimit of the velocity $\\bu^{-}=(\\cI - 2\\cD_{k}) \\bmu = 0$\non $\\Gamma$. Since $k^2$ is not a Dirichlet eigenvalue for the Stokes\nequation on $\\Omega$, we conclude that $\\bu \\equiv 0$ in $\\Omega$. \nIn particular, this implies that the interior limit of the surface traction\ndenoted by $\\bt^{-} = 0$ on $\\Gamma$. \nUsing~\\cref{lem:jump-conds} again, we conclude that the exterior limit\nof the surface traction, $\\bt^{+}$, is $0$ on $\\Gamma$. \nNote that $\\bu$ is a radiating solution of the oscillatory\nStokes equation in the exterior $E$, as $\\cW[\\bmu] = 0$ implies\n$\\int_{\\Gamma} \\bmu \\cdot \\bnu = 0$.\nFrom the uniqueness of solutions to the exterior Neumann problem, \nwe conclude that $\\bu \\equiv 0$ in $E$ as well,\nwhich in particular implies that\nthe exterior limit of the velocity, $\\bu^{+}$, is $0$ on $\\Gamma$.   \nUsing the jump conditions in~\\cref{lem:jump-conds} again, we\nget that $2\\bmu = \\bu^{-} - \\bu^{+} = 0$.\nThus $(\\cI - 2\\cD_{k} - 2\\cW)$ is invertible if $k^2$\nis not a Dirichlet eigenvalue for the Stokes equation on $\\Omega$.\n\nTo prove the converse, note that from \\cref{thrm:rep-theorem} we have \n  \\begin{equation} \n    \\bS_{k} [\\bt](\\xx) - \\bD_{k}[\\bu](\\xx) = \\begin{cases} \n    \\bu(\\xx) &\\quad \\xx \\in \\Omega \\, , \\\\\n    0 &\\quad \\xx \\in E \\; .\n    \\end{cases}\n  \\end{equation}\n  Suppose that $k^2$ is a Dirichlet eigenvalue for the Stokes equation\n  on $\\Omega$ and let $\\bu$ denote the corresponding eigenfunction\n  with $\\bt^{-}$ the corresponding surface traction on the\n  boundary $\\Gamma$.\n  Since $\\bu$ is a Dirichlet eigenfunction, the velocity restricted\n  to the boundary, $\\bu^{-}$, is $0$. \n  Using the Green's theorem representation for the pair\n  $(\\bu,\\bt^{-})$ and evaluating the surface traction\n  using~\\cref{lem:jump-conds}, we get\n  \\begin{equation}\n    \\bt^{-} = \\left(\\cDt_{k} + \\frac{1}{2} \\cI\\right) \\bt^{-} \\,\n    \\implies \\left(\\cI - 2\\cDt_{k} \\right) \n    \\bt^{-} = 0 \\, .\n  \\end{equation}\n  From the above and \\cref{lem:nunull,lem:nutracli},\n  we know that $\\bt^{-}, \\bnu \\in \\cN(\\cI - 2\\cDt_{k})$\n  are two linearly independent vectors in the null space.\n  Let $c = \\left< \\bt^{-},\\bnu \\right>$. Then, it\n  follows that $\\left<\\bt^{-} -c \\bnu, \\bnu \\right> = 0$\n  and thus $\\cW[\\bt^{-} - c\\bnu] = 0$. \n  Since $\\bt^{-}$ and $\\bnu$ are linearly independent, we note that\n  $\\bt^{-} -c\\bnu \\neq 0$. Combining these results, we get that\n  $(\\cI - 2\\cDt_{k} - 2\\cW) (\\bt^{-} - c\\bnu) = 0$. \n  Since $\\bt^{-}-c\\bnu$ is non-trivial, and $\\cW$ is\n  self-adjoint, it follows from the Fredholm alternative\n  that the operator $\\cI - 2\\cD_{k} - 2\\cW$ is also not\n  invertible.\n\\end{proof}\n\nThe correspondence result above does not hold on multiply\nconnected domains.\nIn particular, while the operator $\\cI -2\\cD_{k} -2\\cW$ \nis indeed not invertible when $k^2$ is a Dirichlet eigenvalue,\nit turns out that the operator is also not\ninvertible when $k^2$ is a Neumann eigenvalue\ncorresponding to the interior of one of the obstacle regions,\ni.e. one of the $\\Omega_{i}$ with $i > 0$. The following theorem\nproves this result for a region with one obstacle;\nthe extension to the general case is straightforward.\n\n\\begin{thrm}\n  Suppose that $\\Omega$ is a multiply connected domain\n  given by the intersection of a domain $\\Omega_{0}$\n  and the exterior of a single domain $\\Omega_{1}$ with\n  $ \\bar\\Omega_1 \\subset \\Omega_0$.\n  Then, the operator $\\cI - 2\\cD_{k} - 2\\cW$ is not invertible\n  if $k^2$ is a Neumann eigenvalue of $\\Omega_{1}$.\n\\end{thrm}\n\n%\\begin{figure}\n%\\begin{center}\n%\\includegraphics[width=0.3\\linewidth]{fig/multiply_final}\n%\\end{center}\n%\\caption{Example of a multiply connected domain with one obstacle.}\n%\\label{fig:1ply}\n%\\end{figure}\n\n\\begin{proof}\n  Suppose that $k^2$ is a Neumann eigenvalue of $\\Omega_{1}$, and\n  let $\\tilde{\\bu}$ denote the corresponding eigenfunction. \n  Note that $\\tilde{\\bu}$ is not identically $0$ on the boundary\n  of $\\Omega_{1}$, which we denote by $\\Gamma_1$.\n  Since $\\tilde{\\bu}$ is an interior Neumann eigenfunction, we note that\n  the surface traction corresponding to the solution, $\\bt^{-}$, is $0$\n  on the boundary.\n  Applying \\cref{thrm:rep-theorem} to the\n  solution $\\tilde{\\bu}$ in the interior\n  and taking the interior limit we get\n\\begin{equation}\n\\tilde{\\bu} = \\frac{1}{2}\\tilde{\\bu} + \\cD^{\\Gamma_{1}}_{k}[\\tilde{\\bu}] +\n\\cS^{\\Gamma_{1}} [\\bt^{-}] \\implies \\frac{1}{2} \\tilde{\\bu} - \\cD^{\\Gamma_{1}}_{k}[\\tilde{\\bu}]\n= 0\\, .\n\\end{equation}\nNote that the sign of the $\\bD$ operator in the\nrepresentation theorem is switched since the normal\nis pointing inwards for the boundary $\\Omega_{1}$.\nThus, $\\tilde{\\bu}$ is a non-trivial null vector of the operator \n$\\frac{1}{2}\\cI - \\cD^{\\Gamma_{1}}_{k}$. \nFurthermore since $\\tilde{\\bu}$ is the boundary data of \nthe solution of the oscillatory Stokes equation\nin $\\Omega_{1}$, we get that $\\cW^{\\Gamma_{1}}[\\tilde{\\bu}] = 0$.\nSetting $\\bmu = \\tilde{\\bu}$ on $\\Gamma_{1}$, and\n$\\bmu = 0$ on $\\Gamma_{0}$, we obtain a non-trivial null\nvector for the operator $\\cI - 2\\cD^{\\Gamma}_{k} -2\\cW^{\\Gamma}$\non the boundary $\\Gamma = \\Gamma_{0} \\cup \\Gamma_{1}$.\n\\end{proof}\n\nThe spurious eigenvalues of the operator $\\cI-2\\cDk-2\\cW$\nare demonstrated in \\cref{subsec:spurannulus} on an annulus,\nwhere both the true and spurious eigenvalues can be\ndetermined analytically. \nAnalogous with the observation in~\\cite{zhao2015robust},\nthis lack of one-to-one correspondence between\nthe invertibility of the integral operator $\\cI - 2\\cD_{k} - 2\\cW$\nand the Dirichlet eigenvalues of the Stokes operator on multiply\nconnected domains also causes non-robustness and introduces\nnear-resonances for simply-connected domains which are almost\nmultiply-connected.\n%We demonstrate this issue numerically\n%in~\\cref{subsec:crescent}.\n\n\\subsubsection{Dirichlet eigenvalues --- combined-field representation}\n\\label{subsec:mixedanalysis}\n\nThe non-robustness in using the double layer\npotential representation can be\nremedied by using a combined-field, or mixed layer potential,\nrepresentation, i.e. setting $\\bu = (\\bD_{k} + i\\eta \\bS_{k})\n\\bmu$, with $\\eta$ real and positive.\nImposing the Dirichlet boundary condition\nand using~\\cref{lem:jump-conds}, we obtain \n\\begin{equation}\n  (\\cI - 2\\cD_{k} - 2i\\eta \\cS_{k}) \\bmu = -2 \\ff \\,\n  \\textrm{ on } \\Gamma. \n\\end{equation}\nAs with the double layer representation, this\nintegral equation is rank deficient for any $k$.\nInstead, we consider\n\\begin{equation}\n(\\cI - 2\\cD_{k} -2i\\eta \\cS_{k}  -2\\cW)\\bmu = -2 \\ff \\, .\n\\end{equation}\n\nWe now prove that for any bounded region $\\Omega$\n(simply or multiply connected) with $C^{2}$ boundaries,\nthere exists a one-to-one correspondence between the\ninvertibility of the operator $\\cI - 2\\cD_{k}\n- 2i\\eta \\cS_{k} - 2\\cW$ and the Dirichlet eigenvalues.\n\n\\begin{thrm}\n  \\label{thm:cfmain}\n  Suppose $\\Omega$ is a bounded region defined\n  by the intersection of a simply connected domain $\\Omega_{0}$\n  and the exteriors of a finite collection bounded simply\n  connected domains $\\{ \\Omega_{i} \\}_{i=1}^{m}$. As above,\n  let $\\Gamma_{i}$ denote the boundary of $\\Omega_{i}$ and let\n  $\\Gamma = \\cup_{i=0}^{m} \\Gamma_{i}$ denote the boundary of\n  $\\Omega$. Then, the operator $\\cI - 2\\cD_{k} - 2i\\eta \\cS_{k}\n  - 2\\cW$ is invertible if and only if $k^2$ is not a Dirichlet\n  eigenvalue for the Stokes operator on $\\Omega$.\n\\end{thrm}\n\n\\begin{proof}\n  Suppose that $k^2$ is not a Dirichlet eigenvalue for the\n  Stokes equation on $\\Omega$. Suppose further that $\\bmu$ satisfies\n  \\begin{equation}\n    (\\cI - 2\\cD_{k} -2i\\eta\\cS_{k} - 2\\cW) \\bmu = 0 \\, ,\n    \\label{eq:mlproofrep}\n  \\end{equation}\ni.e. $\\bmu$ is in the null-space\nof $(\\cI - 2 \\cD_{k} - 2i\\eta \\cS_{k} - 2 \\cW)$. \nApplying the operator $\\cW$ to~\\cref{eq:mlproofrep} and \nusing~\\cref{lem:propnullspacecorr}, we get\n\\begin{equation}\n0 = \\cW [(\\cI - 2\\cD_{k} - 2i\\eta\\cS_{k} - 2\\cW)\\bmu] = -2\\cW [\\bmu] \\, .\n\\end{equation}\nThus~\\cref{eq:mlproofrep} reduces to\n\\begin{equation}\n(\\cI - 2 \\cD_{k} - 2i\\eta \\cS_{k})\\bmu = 0\\, .\n\\end{equation}\nSuppose now $\\bu = -2\\bD_{k}[\\bmu] -2i\\eta\\bS_{k}[\\bmu]$\nin $\\Omega$. Then $\\bu$ is a solution to the oscillatory\nStokes equation in $\\Omega$, and applying~\\cref{lem:jump-conds},\nwe get that the interior limit of the velocity\n$\\bu^{-} = (\\cI - 2\\cD_{k} -2i\\eta\\cS_{k}) \\bmu = 0$ on $\\Gamma$.\nSince $k^2$ is not a Dirichlet eigenvalue for the Stokes equation\non $\\Omega$, we conclude that $\\bu \\equiv 0$ in $\\Omega$. \nThis in particular implies that the interior limit of the\nsurface traction, denoted by $\\bt^{-}$, is $0$ on $\\Gamma$.\n\n\nUsing~\\cref{lem:jump-conds} we observe that $\\bt^{+}\n= 2i\\eta \\bmu(\\xx)$ and $\\bu^{+} = -2\\bmu(\\xx)$ on $\\Gamma$, i.e.\n$\\bt^{+}+i\\eta \\bu^{+}=0$ and $\\bu^{+}$ satisfies the homogeneous\nexterior impedance problem.\nWe first show that $\\bmu=0$ on $\\Gamma_{0}$. \nTo this end, note that $\\bu$ is a radiating solution\nof the oscillatory Stokes equation in the exterior $E$,\nsince $\\cW[\\bmu] = 0$ implies that $\\int_{\\Gamma} \\bmu\n\\cdot \\bnu = 0$. From the uniqueness of the impedance problem\nin the exterior $E_0$ of $\\Omega_0$, we conclude that\n$\\bu \\equiv 0$ in $E_0$ as well, which in particular\nimplies that $\\bu^{+}=0$ on $\\Gamma_{0}$.   \nUsing the jump conditions in~\\cref{lem:jump-conds}\nagain, we get that\n$2\\bmu = \\bu^{-} - \\bu^{+} = 0$ on\n$\\Gamma_{0}$. \n\n\\begin{remark}\n  Note that there is potential for confusion here\n  in that the exterior limit with respect to $\\Omega$ \n  for the boundary $\\Gamma_{j}$ is the traditional interior \n  limit with respect to the obstacle region $\\Omega_{j}$.\n\\end{remark}\n\nTo show that $\\bmu=0$ on\n$\\Gamma_{j}$, we observe that $\\bu$ is also a\nsolution to the oscillatory Stokes equation in each\nof the obstacles $\\Omega_{j}$.\nUsing the jump conditions in~\\cref{lem:jump-conds},\nwe get that $\\bt^{+} = 2i\\eta \\bmu$ and $\\bu^{+} = -2\\bmu$.\nHowever, the normal is inward pointing inside $\\Omega_{j}$\non the boundary $\\Gamma_{j}$. \nIf we revert back to the normal being defined as \nan outward normal to $\\Omega_{j}$, then\nthe boundary conditions on $\\Gamma_{j}$ \nis $\\bt - i \\eta \\bu = 0$. \nFrom the uniqueness of solutions to the interior \nimpedance problem, we conclude that $\\bu \\equiv 0$\nin $\\Omega_{j}$, which in particular implies\nthat $2\\bmu = \\bu^{-}-\\bu^{+} = 0$ for $\\xx \\in \\Gamma_{j}$,\n$j=1,2,\\ldots m$.\nThus, $\\cI - 2\\cD_{k} -2i\\eta\\cS_{k} -2\\cW$ is\ninvertible when $k^2$ is not a Dirichlet eigenvalue\nfor the Stokes equation on $\\Omega$.\n\nFrom \\cref{thrm:rep-theorem}, we have \n\\begin{equation} \n  \\bS [\\bt](\\xx) - \\bD[\\bu](\\xx) = \\begin{cases} \n    \\bu(\\xx) &\\quad \\xx \\in \\Omega \\, , \\\\\n    0 &\\quad \\xx \\in \\R^2 \\setminus \\bar{\\Omega} \\; .\n    \\end{cases}\n  \\end{equation}\nSuppose that $k^2$ is Dirichlet eigenvalue for\nthe Stokes equation on $\\Omega$ and let $\\bu$\ndenote the corresponding eigenfunction and $\\bt$ denote\nits surface traction. Note that \\cref{thrm:rep-theorem}\nimplies that $\\cS_{k}[\\bt^{-}] = 0$, since\n$\\bu^{-}=0$ on $\\Gamma$. Applying \\cref{thrm:rep-theorem}\nto the pair $\\bt^{-}, \\bu^{-}$ and evaluating the\ntraction on $\\Gamma$ using~\\cref{lem:jump-conds},\nwe get\n\\begin{equation}\n\\bt^{-} = (\\cDt_{k} + \\frac{1}{2} \\cI) \\bt^{-} \\, . \n\\end{equation}\nCombining these two identities, we get\nthat\n\\begin{equation}\n(\\cI - 2\\cDkt -2i\\eta \\cS_{k}) \\bt^{-} = 0 \\, .\n\\end{equation}\nAs in the proof of~\\cref{thm:dlmain}, letting\n$c = \\left< \\bt^{-} ,\\bnu \\right>$, it follows that\n\\begin{equation}\n  (\\cI - 2\\cDkt - 2i \\eta \\cS_{k} - 2\\cW)\n  (\\bt^{-} - c\\bnu) = 0 \\, ,\n\\end{equation}\nwhere $\\bt^{-} - c\\bnu \\neq 0$.\nSince $\\bt^{-} - c\\bnu$ is non-trivial and both\n$i\\eta \\cS_{k}$ and $\\cW$ are self-adjoint with respect\nto the bilinear form \\cref{eq:bi_form},\nit follows from the Fredholm alternative\nthat the operator $\\cI - 2\\cDk -2i\\eta \\cSk - 2\\cW$\nis also not invertible.\n\\end{proof}\n\n\\subsection{Fredholm determinants}\n\\label{sec:dets}\nIn this section, we show\nhow the Fredholm determinant can be used\nas a computational tool for detecting the\nnon-invertibility of $\\cI - 2\\cD_{k} - 2\\cW$.\nThe arguments here follow the structure of the\nanalogous arguments in~\\cite{zhao2015robust}\nfor Laplace eigenvalues.\n\nLet $\\cJ_{1}(X)$ denote the space of trace class operators \non $X$, where $X$ is a Hilbert space, which is a\nsubspace of the space of compact operators on $X$.\nA compact operator $\\cA$ with eigenvalues\n$\\lambda_{i}, i\\in \\mathbb{N}$ is in $\\cJ_{1}(X)$ if\n$\\sum_{i} |\\lambda_{i}| < \\infty$.\nIf $\\cA$, is a trace class operator, then  \nthe Fredholm determinant of the operator $\\cI + \\cA$\nis defined by\n\\begin{equation}\n\\text{det}(\\cI +\\cA) = \\prod_{i=1}^{\\infty} (1+\\lambda_{i}) \\, .\n\\end{equation}\n\nSo far, we have discussed the Fredholm theory in the space\n$C(\\Gamma)\\times C(\\Gamma)$ equipped with the bilinear form~\\cref{eq:bi_form}.\nHowever, it is more convenient to discuss the theory of Fredholm\ndeterminants on Hilbert spaces. \nWe note that both the operators $\\cD_{k}$ and $\\cS_{k}$ \nare also compact operators mapping $Y \\to Y$\nwhere $Y = \\mathbb{L}^{2}(\\Gamma) \\times \\mathbb{L}^{2}(\\Gamma)$.\nFurthermore, it is well-known that the spectrum of compact\noperators with weakly singular kernels coincide on \n$C(\\Gamma)\\times C(\\Gamma)$ and $Y$ (see~\\cite{kress1989linear},\nfor example).\nSo for the rest of the section, we present the discussion of \nthe relevant operators on $Y$ instead of $C(\\Gamma)\\times C(\\Gamma)$.\n\n%It follows from standard results in complex\n%analysis, that the Fredholm determinant is finite and well-defined if \n%$\\text{det}(\\cI+A) < \\infty$ if $\\sum_{i} |\\lambda_{i}| < \\infty$,\n%i.e. if $A$ is in trace class.\n\nThe operator $-2\\cD_{k} - 2\\cW$ is trace class:\n\\begin{lem}\n  Suppose that $\\Gamma$ is a $C^2$ curve.\n  Then $-2\\cD_{k} - 2\\cW \\in \\cJ_1(Y)$\n  for all $k \\in \\mathbb{C} \\setminus \\{0\\}$ \n\\end{lem}\n\\begin{proof}\nUsing Bessel function asymptotics, we note that the\nkernel of $\\cD_{k}$ given by $\\TT_{\\cdot,\\cdot,\\ell}\\nu_{\\ell}(\\bx,\\by)$\nhas a leading order singularity of\n$|\\bx-\\by|^2 \\log{|\\bx-\\by|^2}$ as $\\bx\\to \\by$ \nfor all $k \\in \\mathbb{C} \\setminus \\{ 0\\}$.\nIt follows from the criteria listed\nin~\\cite[Sec. 2]{bornemann2010numerical} that $\\cD_{k}$\nis a trace-class operator.\nSince $\\cW$ is a rank-one perturbation independent of $k$,\nand trace-class operators are a vector space, we conclude\nthat $-2\\cD_{k} - 2\\cW$ is also a trace-class operator.\n\\end{proof}\n\nLet $f(k) = \\text{det}(\\cI - 2\\cD_{k} - 2\\cW)$.\nFirst, note that $f(k)$ is an analytic function of $k$\nfor $k \\in \\mathbb{C} \\setminus \\{0 \\}$, since the kernel\nof $\\cD_{k}$ is an analytic function of $k$ on that domain, \nand the Fredholm determinant of an analytic operator \nis analytic on the domain of analyticity\nof the operator (see~\\cite{zhao2015robust}, for example).\n\nThe zeros of the Fredholm determinant indicate when the\noperator is not invertible.\nThe following lemma summarizes this result.\n\\begin{lem} \\label{lem:detzeros}\n  With $f(k)$ defined as above, $f(k) = 0$ if and only if\n  $\\cI - 2\\cD_{k} -2\\cW$ is not invertible.\n\\end{lem}\n\\begin{proof}\n  The proof is standard; see, for example,\n  \\cite[p. 34]{simon2005trace}.\n\\end{proof}\n\nWhen $\\Omega$ is simply connected, \\cref{lem:detzeros} and \n\\cref{thm:dlmain} together imply that $f(k) = 0$\nif and only if $k^2$ \nis a Dirichlet eigenvalue of the Stokes equation.\nThis reduces the problem of finding eigenvalues to\nfinding the roots of an analytic function.\n\nWe now show how this fact can be used to numerically\nestimate the Dirichlet eigenvalues.\nSuppose that $D_{k}^{N}$ is a Nystr\\\"{o}m discretization \nof the operator $-2\\cD_{k} - 2\\cW$ when the boundary \n$\\Gamma$ is discretized with $N$ points. \nLet $f^{N}(k) = \\text{det}(I + D_{k}^{N})$\nwhere here $\\text{det}$ is the standard matrix determinant.\nNote that the discretized matrix also depends on the choice\nof quadrature rule used in the Nystr\\\"{o}m discretization\nof the operator.\n\nIn~\\cite{zhao2015robust}, the authors prove that\nfor computing the Laplace eigenvalues on regions with \nanalytic boundaries, when the integral operators are\ndiscretized using Kress quadrature --- a spectrally accurate\nquadrature rule for such kernels, see~\\cite{kress1991boundary} ---\nthe determinant of the Nystr\\\"{o}m discretized operators\nat the true eigenvalues converge to $0$ exponentially\nin $N$.\nThus, if the eigenvalues have multiplicity $1$,\ni.e. the derivative of the determinant is non-zero\nat the true-eigenvalues, then the analyticity of the\ndiscretized determinant implies that the zeros\nof the determinant of the Nystr\\\"{o}m discretization\nof the linear operator converge exponentially to\nthe true Dirichlet eigenvalues for Laplace's equation.\n\nThe proof presented in~\\cite{zhao2015robust} applies\nto the BIE approach for computing the Dirichlet eigenvalues\nof the Stokes operator as well.\nThe result is summarized below.\n\\begin{thrm}\n\\label{thm:mainconvfreddet}\nSuppose that $\\Omega$ is a simply connected\ndomain with an analytic boundary. Let $k_{j}^2$, $j=1,2,\\ldots M$\ndenote all the Dirichlet eigenvalues of Stokes equation\non $\\Omega$ contained in the interval $[a,b]$. \nSuppose further that all the eigenvalues have multiplicity $1$.\nLet $f^{N}(k) = \\text{det}(I+D^{N}_{k})$, where $D^{N}_{k}$ \nis the Nystr\\\"{o}m discretization of $-2\\cD_{k} - 2\\cW$ with Kress\nquadrature.\nThen there exists $N_{0} \\in \\mathbb{N}$ such\nthat for all $N>N_{0}$, \n$f^{N}(k)$ has exactly $M$ zeros on the interval $[a,b]$.\nLet $\\omega_{j}$, $j=1,2\\ldots M$ denote the zeros of $f^{N}$.\nFurthermore, there exist constants $a>0$ and $C$, \nsuch that $\\sup_{j=1}^{M} |\\omega_{j} - k_{j}| < C e^{-aN}$.\n\\end{thrm}\n\n\\begin{proof}\n  The proof follows from small modifications of the\n  proofs contained in~\\cite{zhao2015robust}. \n\\end{proof}\n\n\\begin{remark}\nIn practice, using Kress quadrature for large\nproblems is problematic owing to the global\nnature of the quadrature rule.\n%\nFirst, the use of a global rule does not allow\nfor adaptive refinement at a complicated, local\nfeature of the boundary.\n%\nSecond, the integration weight in each entry\nof the matrix depends on both the column and the row\nin a non-separable way.\n%\nAs a result, the fast multipole method is not\ndirectly applicable to the resulting matrix\nand many fast-direct methods for computing\nthe determinant lose efficiency (for\ninstance, the reasoning behind the use of a\n{\\em proxy surface} \\cite{cheng2005compression}\nno longer holds).\nOver the last two decades, many high-order quadrature\nmethods which are compatible with\nthe fast multipole method and fast-direct methods\nhave been developed.\n%\nOur numerical experiments, see \\cref{subsec:convannulus},\nsuggest that the zeros of the \ndeterminants of linear systems discretized using \nthese quadrature methods are also high order approximations\nof Dirichlet eigenvalues for the Stokes operator ---\nthe error is observed to be proportional to the quadrature error\nfor the eigenfunction $\\bt^{-}$ associated with the eigenvalue.\nWe leave a proof of this to future work.\n\\end{remark}\n\n\\begin{remark}\nThe same analysis does not carry through for the operator\n$\\cI - 2 \\cD_{k} - 2i\\eta \\cS_{k} - 2\\cW$, \nsince $\\cS_{k}$ is not a trace class operator.\nFor brevity, let $\\cC_{k} = -2\\cD_{k} - 2i\\eta \\cS_{k} - 2\\cW$.\nThe operator $\\cC_{k}$ is \nin $\\cJ_{2}(Y)$ where\n$\\cJ_{2}(Y)$ is the space of Hilbert-Schmidt operators\non $Y$ (the singular values of the operator are square\nsummable, as opposed to being summable).\nThus the Fredholm determinant of $\\cI + \\cC_{k}$\nis not necessarily finite. \nHowever, as noted in~\\cite{zhao2015robust}, the convergence\nresult~\\cref{thm:mainconvfreddet}\nshould be true up to a logarithmic factor in the rate\nof convergence, since the singular values of the operator\n$\\cC_{k}$ decay like $\\frac{1}{n}$, and the\nFredholm determinant diverges logarithmically. \nIn~\\cref{subsec:convannulus}, we demonstrate this fact\nnumerically on the annulus, where the eigenvalues are\nanalytically known. \n\\end{remark}\n", "meta": {"hexsha": "a79e95a50e679062bb0f47af962c2c47996d1777", "size": 50446, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/draft-01-stokes/03analysis.tex", "max_stars_repo_name": "askhamwhat/biharm-evals", "max_stars_repo_head_hexsha": "d836302f544670b3d899bd91ea4cb49e9afb6a75", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/draft-01-stokes/03analysis.tex", "max_issues_repo_name": "askhamwhat/biharm-evals", "max_issues_repo_head_hexsha": "d836302f544670b3d899bd91ea4cb49e9afb6a75", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/draft-01-stokes/03analysis.tex", "max_forks_repo_name": "askhamwhat/biharm-evals", "max_forks_repo_head_hexsha": "d836302f544670b3d899bd91ea4cb49e9afb6a75", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6263399694, "max_line_length": 100, "alphanum_fraction": 0.6802521508, "num_tokens": 17480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.629774621301746, "lm_q1q2_score": 0.44243560869380355}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{geometry}\n\\usepackage{enumerate}\n\\usepackage{natbib}\n\\usepackage{float}%稳定图片位置\n\\usepackage{graphicx,subfig}%画图\n\\usepackage{caption}\n\\usepackage[english]{babel}\n\\usepackage{indentfirst}%缩进\n\\usepackage{enumerate}%加序号\n\\usepackage{multirow}%合并行\n\\usepackage{hyperref}\n\\newcommand{\\reals}{{\\mathbb{R}}}\n\\hypersetup{hypertex=true, colorlinks=true, linkcolor=black, anchorcolor=black, citecolor=black}\n\\title{\\Large \\textbf{VG441 Problem Set 1}\\\\\n\\author{\\textbf{Pan, Chongdan ID:516370910121}\\\\\n}\n}\n\\begin{document}\n\\maketitle\n\\section{Problem 1}\n\\quad\n\\\\$\\theta^TX^TX\\theta=(X\\theta)^T(X\\theta)=(X\\theta)^2$\n\\\\Assume $X\\in\\reals^{m\\times n},\\theta\\in\\reals^{n\\times1}$ then $=(X\\theta)^2=\\sum_{i=1}^m(\\sum_{j=1}^nx_{ij}\\theta_j)^2$\n\\\\$\\frac{\\mathrm{d}\\theta^TX^TX\\theta^2}{\\mathrm{d}\\theta}=\\frac{\\mathrm{d}(X\\theta)^2}{\\mathrm{d}\\theta}=\\left[\\begin{array}{c}   \n    \\frac{\\partial (X\\theta)^2}{\\partial \\theta_j}\\\\ \n    \\vdots\\\\  \n    \\frac{\\partial (X\\theta)^2}{\\partial \\theta_n}\\\\  \n  \\end{array}\\right]\n  =\\left[\\begin{array}{c}   \n    2\\sum_{i=1}^m(\\sum_{j=1}^nx_{ij}x_{i1}\\theta_j)\\\\ \n    \\vdots\\\\  \n    2\\sum_{i=1}^m(\\sum_{j=1}^nx_{ij}x_{in}\\theta_j)\\\\  \n  \\end{array}\\right]$\n\\\\$2X^TX\\theta=2\\left[\\begin{array}{ccc}   \n    \\sum_{i=1}^mx_{i1}x_{i1} &\\cdots & \\sum_{i=1}^mx_{i1}x_{in}\\\\ \n    \\vdots&\\vdots &\\vdots\\\\  \n    \\sum_{i=1}^mx_{in}x_{i1} &\\cdots & \\sum_{i=1}^mx_{in}x_{in}\\\\  \n  \\end{array}\\right]\\left[\\begin{array}{c}\n    \\theta_1\\\\\n    \\vdots\\\\\n    \\theta_n\\\\    \n  \\end{array}\\right]=\\left[\\begin{array}{c}   \n    2\\sum_{i=1}^m(\\sum_{j=1}^nx_{ij}x_{i1}\\theta_j)\\\\ \n    \\vdots\\\\  \n    2\\sum_{i=1}^m(\\sum_{j=1}^nx_{ij}x_{in}\\theta_j)\\\\  \n  \\end{array}\\right]$\n\\\\\\\\\\\\Therefore, the derivative of $\\theta^TX^TX\\theta$ with respect to $\\theta$ is $2X^TX\\theta$\n\\section{Problem 2}\n\\begin{itemize}\n    \\item The average value for salary is 5875.So before the first iteration:\n    \\begin{table}[htbp]\n        \\begin{tabular}{|c|c|c|c|c|c|c|}\n        \\hline\n        Age & Home Owner & Car Owner & Having kids & Salary & F0 & PR0 \\\\ \\hline\n        40 & YES & YES & YES & 10000 & 5875 & 4125 \\\\ \\hline\n        20 & NO & NO & NO & 500 & 5875 & -5375 \\\\ \\hline\n        50 & YES & NO & YES & 8000 & 5875 & 2125 \\\\ \\hline\n        30 & YES & NO & NO & 5000 & 5875 & -875 \\\\ \\hline\n        \\end{tabular}\n        \\end{table}\n    \\\\The deviance is 5118750.\n    \\\\For \\textbf{Home Owner} node: deviance is 12666666.67\n    \\\\For \\textbf{CAR Owner} node: deviance is 28500000\n    \\\\For \\textbf{Having Kids} node:deviance is 12125000\n    \\\\For \\textbf{Age $\\leq$ 25} node: deviance is 12666666.67\n    \\\\For \\textbf{Age $\\leq$ 35} node: deviance is 12125000\n    \\\\For \\textbf{Age $\\leq$ 45} node: deviance is 45166666\n    \\\\\\\\So we set \\textbf{Having Kids} as the highest node, \\textbf{Home Owner} as the left lower node,\\textbf{CAR Owner} as the right lower node\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.25]{P1.png}\n        \\caption{First decision tree for GBM}\n        \\label{P1}\n    \\end{figure}\n    \\begin{table}[htbp]\n    \\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}\n        \\hline\n        Age & Home Owner & Car Owner & Having kids & Salary & F0 & PR0 & F1 & PR1 & F2 & PR2\\\\ \\hline\n        40 & YES & YES & YES & 10000 & 5875 & 4125 & 6287.5 & 3712.5 & 6658.75 & 3341.25\\\\ \\hline\n        20 & NO & NO & NO & 500 & 5875 & -5375 & 5337.5 & -4837.5 & 4853.75 & -4353.75\\\\ \\hline\n        50 & YES & NO & YES & 8000 & 5875 & 2125 & 6087.5 & 1912.5 & 6278.5 & 1721.25\\\\ \\hline\n        30 & YES & NO & NO & 5000 & 5875 & -875 & 5787.5 & -787.5 & 5708.75 & -708.75\\\\ \\hline\n        \\end{tabular}\n    \\end{table}\n    \\item The average value for salary is 5875.So before the first iteration:\n    \\begin{table}[htbp]\n        \\begin{tabular}{|c|c|c|c|c|c|c|}\n        \\hline\n        Age & Home Owner & Car Owner & Having kids & Salary & F0 & PR0 \\\\ \\hline\n        40 & YES & YES & YES & 10000 & 5875 & 4125 \\\\ \\hline\n        20 & NO & NO & NO & 500 & 5875 & -5375 \\\\ \\hline\n        50 & YES & NO & YES & 8000 & 5875 & 2125 \\\\ \\hline\n        30 & YES & NO & NO & 5000 & 5875 & -875 \\\\ \\hline\n        \\end{tabular}\n        \\end{table}\n        \\\\SS with $\\lambda=1$ is 994050000\n        \\\\For \\textbf{Home Owner} node: Gain is 21667968.75\n        \\\\For \\textbf{CAR Owner} node: Gain is 12761718.75\n        \\\\For \\textbf{Having Kids} node:Gain is 26041666.67\n        \\\\For \\textbf{Age $\\leq$ 25} node: Gain is 21667968.75\n        \\\\For \\textbf{Age $\\leq$ 35} node: Gain is 26041666.67\n        \\\\For \\textbf{Age $\\leq$ 45} node: Gain is 3386718.75\n        \\\\\\\\So we set \\textbf{Having Kids} as the highest node, \\textbf{Home Owner} as the left lower node,\\textbf{CAR Owner} as the right lower node\n        \\\\The \\textbf{Home Owner} node has Gain with $1807292>\\gamma$, so it'll remain.\n        \\\\The \\textbf{CAR Owner} node has Gain with $-2255208<\\gamma$, so it'll be deleted.\n        \\\\After pruning, the XGBoost tree becomes:\n        \\begin{figure}[H]\n            \\centering\n            \\includegraphics[scale=0.25]{P2.png}\n            \\caption{First XGBoost Tree}\n            \\label{P2}\n        \\end{figure}\n        \\begin{table}[htbp]\n            \\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}\n                \\hline\n                Age & Home Owner & Car Owner & Having kids & Salary & F0 & PR0 & F1 & PR1 & F2 & PR2\\\\ \\hline\n                40 & YES & YES & YES & 10000 & 5875 & 4125 & 6083.3 & 3916.7 & 6277.75 & 3722.25\\\\ \\hline\n                20 & NO & NO & NO & 500 & 5875 & -5375 & 5606.3 & -5106.3 & 5351 & -4851\\\\ \\hline\n                50 & YES & NO & YES & 8000 & 5875 & 2125 & 6083.3 & 1916.7 & 6277.75 & 1722.25\\\\ \\hline\n                30 & YES & NO & NO & 5000 & 5875 & -875 & 5831.3 & -831.3 & 5790 & -790\\\\ \\hline\n                \\end{tabular}\n            \\end{table}\n\\end{itemize}\n\\section{Problem 3}\n\\begin{itemize}\n    \\item The Linear Regression model leads to $MSE=3.74\\times10^9, R^2=0.66$\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.5]{LR.png}\n        \\caption{Actual Value vs Linear Regression Predicted Value}\n        \\label{LR}\n    \\end{figure}\n    \\item The GBM model leads to $MSE=2.01\\times10^9, R^2=0.81$\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.5]{GBM.png}\n        \\caption{Actual Value vs Gradient Boosting Predicted Value}\n        \\label{GBM}\n    \\end{figure}\n    \\item The XGBoost model leads to $MSE=1.85\\times10^9, R^2=0.83$\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.5]{XGBoost.png}\n        \\caption{Actual Value vs XGBoost Predicted Value}\n        \\label{XGBoost}\n    \\end{figure}\n\\end{itemize}\nFrom the figure, $MSE,R^2$ we get that the XGBoost Model can achieve the best prediction result, and Linear Regression Model's result is worst.\n\\section*{Python Code}\n\\begin{verbatim}\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn import linear_model\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import mean_squared_error, r2_score\nfrom sklearn.model_selection import cross_val_predict\n\ndf=pd.DataFrame(pd.read_csv(r\"D:\\PANDA\\Study\\VG441\\Homework\\Problem Set 1\\Cal_Housing.csv\"))\n\nclass_mapping={'NEAR BAY':0, 'INLAND':1}\ndf['ocean_proximity']=df['ocean_proximity'].map(class_mapping) # 字符串转数字\ndf=df.dropna(axis=0,how='any',inplace=False) # 删除数据中所有含有nan的行\n\nX=df[['longitude','latitude','housing_median_age','total_rooms','total_bedrooms','population','households','median_income','ocean_proximity']]\nY=df[['median_house_value']]\nX_train,X_test,Y_train,Y_test=train_test_split(X, Y, test_size=0.8)\n\\end{verbatim}\n\\subsection*{Linear Regression Model}\n\\begin{verbatim}\nmodel=linear_model.LinearRegression()\n\\end{verbatim}\n\\subsection*{GBM Model}\n\\begin{verbatim}\nparams = {'n_estimators': 500, 'max_depth': 4, 'min_samples_split': 2, 'learning_rate': 0.05, 'loss': 'ls'}\nmodel = ensemble.GradientBoostingRegressor(**params)\n\\end{verbatim}\n\\subsection*{XGBoost Model}\n\\begin{verbatim}\nparams = {'n_estimators': 500, \"objective\":\"reg:linear\",'colsample_bytree': 0.5,'learning_rate': 0.05,\n                'max_depth': 5, 'alpha': 1}\nmodel = xgb.XGBRegressor(**params)\n\\end{verbatim}\n\\subsection*{Model Fit}\n\\begin{verbatim}\nmodel.fit(X_train, Y_train)\nmodel_score = model.score(X_train,Y_train)\nY_predicted = model.predict(X_test)\n\\end{verbatim}\n\\subsection*{Result and Visualization}\n\\begin{verbatim}\nprint(\"Mean squared error: %.2f\"% mean_squared_error(Y_test, Y_predicted))\nprint('R2 sq: ',r2_score(Y_test, Y_predicted))\nfig, ax = plt.subplots()\nax.scatter(Y_test, Y_predicted, edgecolors=(0, 0, 0))\nax.plot([Y_test.min(), Y_test.max()], [Y_test.min(), Y_test.max()], 'k--', lw=4)\nax.set_xlabel('Actual')\nax.set_ylabel('Predicted')\nax.set_title(\"Ground Truth vs Predicted\")\nplt.show()\n\\end{verbatim}\n\\end{document}", "meta": {"hexsha": "9b4d6ddc84765f4a6718fea6d7618c743dd5c60e", "size": 8905, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "VG441SupplyChain/HW/Problem Set 1/HW1.tex", "max_stars_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_stars_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "VG441SupplyChain/HW/Problem Set 1/HW1.tex", "max_issues_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_issues_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "VG441SupplyChain/HW/Problem Set 1/HW1.tex", "max_forks_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_forks_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.4390243902, "max_line_length": 149, "alphanum_fraction": 0.6284110051, "num_tokens": 3218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4424355910858654}}
{"text": "\\documentclass[xcolor=dvipsnames, professionalfont]{beamer}\n\n\\usepackage{xcolor}\n%\\usepackage{tikz}\n\n\\usefonttheme{serif}\n\n\\usetheme{Berlin}\n\\usecolortheme[named=purple]{structure}\n\n\\author{Ali Abolhassanzadeh Mahani}\n\\title{Growing Critical: Self-Organized Criticality in a Developing Neural System}\n\\date{}\n\\institute{Sharif University of Technology}\n\n\n\\begin{document}\n\t\\frame{\\maketitle}\n\t\\section*{Introduction}\n\t\\begin{frame}\n\t\t{\\centering\n\t\tAn article by:\\\\\n\t\tFelipe Yaroslav Kalle Kossio, Sven Goedeke, Benjamin van\n\t\tden Akker, Borja Ibarz, and Raoul-Martin Memmesheimer\n\t}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\item Intro to criticality \n\t\t\t\\pause\n\t\t\t\\item Genetic development of neural networks:\\\\\n\t\t\tactive neurons shrink while inactive ones grow\n\t\t\\end{itemize}\n\t\\end{frame}\n\n\t\\subsection*{A bit of history}\n\t\\begin{frame}\n\t\t\n\t\\end{frame}\n\n\t\\section*{Stationary State Dynamics}\n\t\\begin{frame}\n\t\tThe dynamics is an inhomogeneous Poisson point process (?)\\\\\n\t\tNotation: \n\t\t\\begin{itemize}\n\t\t\t\\item $f_i(t)$: instantaneous firing rate of neuron $i$\n\t\t\t\\item $gA_{ij}$: time-dependent connection strength\n\t\t\t\\item $g$: proportionality constant\n\t\t\t\\item $A_{ij}$: overlap areas of the neurons\n\t\t\t\\item $\\tau$: the decay time constant due to leak currents\n\t\t\t\\item $\\hat{t}_j$: spike times of neuron $j$\n\t\t\\end{itemize}\n\t\\pause\n\tThe Stationary State Dynamics is a follows:\n\t\\begin{equation}\n\t\t\\tau \\dot{f}_i(t) = f_0 - f_i(t) + \\tau g \\sum_j A_{ij}(t^-) \\sum_{\\hat{t}_j} \\delta(t - \\hat{t}_j)\n\t\\end{equation}\n\t\\end{frame}\n\n\t\\section*{Network Growth}\n\t\\begin{frame}\n\t\tNotation:\n\t\t\\begin{itemize}\n\t\t\t\\item $R_i(t)$: radius of disk representing a single neuron\n\t\t\t\\item $K$: linear growth rate of neurons\n\t\t\t\\item $\\frac{K}{f_{sat}}$: neuron radii shrinkage at spike sending\n\t\t\t\\item Growth takes much longer than decay of\nactivity $\\frac{1}{K} \\gg \\tau$,\n\t\t\t\\item experiments $\\Rightarrow f_{sat} \\gg f_0$\n\t\t\\end{itemize}\n\t\\pause\n\tThe network growth dynamics is as follows:\n\t\\begin{equation}\n\t\t\\dot{R}_i(t) = K \\left( 1 - \\frac{1}{f_{sat}} \\sum_{\\hat{t}_i} \\delta(t - \\hat{t}_i) \\right)\n\t\\end{equation}\n\t\\end{frame}\n\t\n\t\\begin{frame}\n\t\t\\includegraphics[width=\\linewidth]{img/example.png}\n\t\tExample of the network dynamics.\n\t\\end{frame}\n\t\n\t\\section{Results}\n\t\\begin{frame}\n\t\tAveraged over the randomness of spike generation, each spike generates in total \n\t\t\\begin{equation}\n\t\t\t\\sigma = \\tau g \\sum_j \\bar{A_{ij}} = 1 - \\frac{f_{0}}{f_{sat}}\n\t\t\\end{equation}\n\tspikes.\n\t\n\tThus we have a age-dependent branching process with branching parameter $\\sigma$.  (Individuals --spikes-- generate offspring at an age-dependent rate) \n\t\n\t\\textbf{Ref:} Crump-Mode-Jagers branching process\n\t\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\\centering\n\t\\includegraphics[width=.8\\linewidth]{img/simulation.png}\n\t\n\\end{frame}\n\n\t\\begin{frame}\n\t\t\tThe avalanche sizes $s$ follow the Borel distribution \n\t\t\\begin{equation}\n\t\t\tP(s) = \\frac{(s\\sigma)^{s-1} e^{-s\\sigma}}{s!}\n\t\t\\end{equation}\n\twhere using the Stirling's approximation we get\n\t\\begin{equation}\n\t\tP_{appr}(s) = \\frac{1}{\\sqrt{2\\pi}\\sigma} s^{-\\frac{3}{2}} e^{-(\\sigma - \\ln \\sigma - 1)s}\n\t\\end{equation}\n\t\\pause\n\t\n\t\\textbf{Notice} the power-law tail with exponent $\\frac{3}{2}$ of a critical branching process for $\\sigma = 1$\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{img/avalanches.png}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\centering\n\t\t\\Large\n\t\tThank you for your time :)\n\t\\end{frame}\n\t\n\t\n\\end{document}", "meta": {"hexsha": "a8f2c6cf3dfaec33542a2b924d841c55f46554a4", "size": 3451, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/growing critical.tex", "max_stars_repo_name": "ali-mahani/growing-critical", "max_stars_repo_head_hexsha": "bd1dcce5bdfbbe2b1e1cec73e50373af45bd6701", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentation/growing critical.tex", "max_issues_repo_name": "ali-mahani/growing-critical", "max_issues_repo_head_hexsha": "bd1dcce5bdfbbe2b1e1cec73e50373af45bd6701", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/growing critical.tex", "max_forks_repo_name": "ali-mahani/growing-critical", "max_forks_repo_head_hexsha": "bd1dcce5bdfbbe2b1e1cec73e50373af45bd6701", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9609375, "max_line_length": 153, "alphanum_fraction": 0.695450594, "num_tokens": 1173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.44243558524489346}}
{"text": "\\subsection{Syntactic Sugar}\n\\begin{frame}[fragile]{Parallel Operators}\n\\begin{lstlisting}[frame=htrbl]\n(|***|) :: arr a b -> arr c d -> arr (a, c) (b, d)\n(|***|) = parEval2 ()\n\\end{lstlisting}\n\\begin{center}\n\\includegraphics[scale=0.5]{images/starstarstar}\n\\hspace{2em}\n\\includegraphics[scale=0.5]{images/parEval2}\n\\end{center}\n\\begin{lstlisting}[frame=htrbl]\n(|&&&|) :: arr a b -> arr a c -> arr a (b, c)\n(|&&&|) f g = (arr $ \\a -> (a, a)) >>> f |***| g\n\\end{lstlisting}\n\\begin{center}\n\t\\includegraphics[scale=0.5]{images/dollardollardollar}\n\t\\hspace{2em}\n\t\\includegraphics[scale=0.5]{images/pardollardollardollar}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[fragile]{Parallelism made easy}\nParallel Evaluation made easy:\n\\begin{lstlisting}[frame=htrbl]\nadd :: Arrow arr => arr a Int -> arr a Int -> arr a Int\nadd f g = (f |&&&| g) >>> arr (\\(u, v) -> u + v)\n\\end{lstlisting}\n\\begin{center}\n\t\\includegraphics[scale=0.6]{images/addA-comb}\n\t\\hspace{2em}\n\t\\includegraphics[scale=0.5]{images/parAddA}\n\\end{center}\n\\end{frame}", "meta": {"hexsha": "159205bbcf2b127d7b30a2937fe05775cc9abcb8", "size": 1019, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/syntacticSugar.tex", "max_stars_repo_name": "Parrows/Parrows", "max_stars_repo_head_hexsha": "163964988c07a37f19a805816ea71efab9970616", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-25T17:08:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-29T15:07:57.000Z", "max_issues_repo_path": "presentation/syntacticSugar.tex", "max_issues_repo_name": "Parrows/Parrows", "max_issues_repo_head_hexsha": "163964988c07a37f19a805816ea71efab9970616", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/syntacticSugar.tex", "max_forks_repo_name": "Parrows/Parrows", "max_forks_repo_head_hexsha": "163964988c07a37f19a805816ea71efab9970616", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9705882353, "max_line_length": 58, "alphanum_fraction": 0.6633954858, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4424355832412211}}
{"text": "\\chapter{Stability}\r\n\\section {Quadratic Action}\r\n{\\bf Definition 1:} \r\n$G$ is \\emph{$\\pi$-separable} iff every composition factor of $G$ is\r\neither a $\\pi$-group or a $\\pi'$ group.\r\n$G$ is \\emph{$\\pi$-solvable} iff every composition factor of $G$ is\r\neither a solvable $\\pi$-group or a $\\pi'$ group.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 1:}\r\n(1) If $G$ is $\\pi$ separable iff the upper and lower $\\pi$ series of $G$ terminate at\r\n$G$.\\\\\r\n(2) If $G$ is $\\pi$-separable ($\\pi$-solvable) so are subgroups and homomorphic images.\r\n$G$.\\\\\r\n(3) If $G$ is $\\pi$-separable a minimal normal subgroup of $G$ is either a \r\n$\\pi$-group or a\r\n$\\pi'$-group.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nFor 3,\r\nlet $K$ be a minimal normal subgroup of the $\\pi$ separable group $G$.\r\n$K$ is characteristically simple an is thus a direct product of simple groups.\r\nThere is a composition series in which one of the isomophic subgroups in the\r\ndirect product is the last term and this must be a $\\pi$ or $\\pi'$ group.\r\nFor 2, homomorphic and normal subgroups are sutomatically $\\pi$-separable (or $\\pi$-solvable).\r\nLet $H \\le G$ and $K$ be a minimal normal subgroup of $G$, ${\\overline G}= G/K$.\r\nBy induction, ${\\overline H}$ is $\\pi$-separable so we only need to show $H \\cap K$ is;\r\nthis follows from 3 since $K$ is either a $\\pi'$ group or a solvable $\\pi$ group.\r\nFor 1, if the upper or lower series terminate, they can be refined to a composition series and\r\neach of the factors is either a $\\pi$ group or a $\\pi'$ group. \r\nIn either case, $G$ is $\\pi$ separable.\r\nConversely, if $G$ is $\\pi$-separable and the upper $\\pi$ series of $G$ terminates in\r\nthe proper subgroup $H$ of $G$, putting ${\\overline G}= G/H$, we have \r\n$O_{\\pi}(G) = O_{\\pi'}(G)= 1 $. But ${\\overline G}$ is $\\pi$ separable by 2 and so a minimal\r\nnormal subgroup ${\\overline K}$ is either a $\\pi$ or $\\pi'$ group by 3 and thus either\r\n${\\overline K} \\subseteq O_{\\pi}({\\overline G})$ or\r\n${\\overline K} \\subseteq O_{\\pi'}({\\overline G})$ and either is a contradiction establishing 1.\r\n\\end{quote}\r\n{\\bf Theorem 2:}\r\nIf $G$ is $\\pi$ separable and ${\\overline G}= G/O_{\\pi'}(G)$ then\r\n$C_{\\overline G}(O_{\\pi}({\\overline G})) \\subseteq O_{\\pi}({\\overline G})$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nSTS this when\r\n$O_{\\pi'}( G ) = 1$.  Set $H= O_{\\pi}(G)$ and $C= C_G(H)$ so $C \\cap Z = {\\mathbb Z}(H)$ and\r\nwe must show $C= {\\mathbb Z}(H)$.  $O_{\\pi}(C) \\thinspace char \\thinspace \\lhd G$ so\r\n$O_{\\pi}(C) \\lhd G$ and hence\r\n$O_{\\pi}(C) \\subseteq H$.  Thus $O_{\\pi}(C)= C \\cap H = {\\mathbb Z}(H)$.  On the other hand,\r\n${\\mathbb Z}(H) \\lhd G$ and\r\n${\\mathbb Z}(H) \\subseteq C$ so\r\n${\\mathbb Z}(H) \\subseteq O_{\\pi}(C)$ and thus\r\n${\\mathbb Z}(H) = O_{\\pi}(C)$.\r\nAssume, by way of contradiction, that $C \\supset {\\mathbb Z}(H)$ then\r\n$C \\supset O_{\\pi}(C)$.  $C$ is $\\pi$-separable so\r\n$L= O_{\\pi, \\pi'}(C) \\subset O_{\\pi}(C)$.  $L/O_{\\pi}(C)$ is a $\\pi'$ group, \r\n${\\mathbb Z}(H)= O_{\\pi}(C)$ is a normal $S_p$ subgroup of $L$ and by Schur-Zassenhaus,\r\n${\\mathbb Z}(H)$ has a normal complement, $K \\ne 1$ in $L$ which is a normal $S_{\\pi'}$\r\nsubgroup of $L$.  But $K \\subseteq C$ and $[C, {\\mathbb Z}(H)]=1$ so\r\n$L= {\\mathbb Z}(H) \\times K$ and since $K$ is a $\\pi'$ group, $K \\lhd G$ and\r\n$K \\subseteq O_{\\pi'}(G)= 1$, a contradiction.\r\n\\end{quote}\r\n{\\bf Theorem 3:}\r\nIf $G$ is $\\pi$-solvable \r\n$C_G(P \\cap O_{p', p}(G)) \\subseteq O_{p', p}(G)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet ${\\overline G} = G/O_{p'}(G)$.  $C_{\\overline G}({\\overline P}) \\subseteq  O_{p}({\\overline G})$.\r\nBy coprime action, $C_{\\overline G}({\\overline P}) = C_G(P) O_{p'}(G)/O_{p'}(G)$.  By Theorem 2,\r\n$C_G(O_{p',p}(G)) \\subseteq O_{p',p}(G)$ and the result follows.\r\n\\end{quote}\r\n{\\bf Theorem 4:}\r\nLet $G$ be a $p$-solvable group in which $O_{p'}(G)= 1$ and $H= O_p(G)$, then\r\n$G/H$ is faithfully represented on $H/\\Phi(H)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $g$ act by conjugation on $H$. \r\nIf $[g, H]=1$, $g \\in p(G)$ because $O_{p'}(G)=1$.  So $gH$ acts on $H$ and is a $p'$-element.\r\nBy the result in the critical subgroups section, if $gH$ acts non-trivially on $H$ then\r\n$gH$ acts non-trivially on $H/\\Phi(H)$.\r\n\\end{quote}\r\n{\\bf Definitions 2:} If $V$ is an elementary abelian $p$-group then $a$ \r\nacts quadratically on $V$ if $[V,a,a]=1$, in which  case, $v^{(a-1)^2}=0$.\r\n$G$ is said to be \r\n\\emph{$p$-separable} if two non conjugate elements of $G$ remain non-conjugate in \r\nsome finite $p$-group endomorphic image of $G$.\r\nThe \\emph{upper $\\pi$ series}  is\r\n$\\{ 1 \\} \\subseteq O_{\\pi}(G) \\subseteq O_{\\pi, \\pi'}(G) \\subseteq O_{\\pi, \\pi', \\pi}(G) \\ldots$\r\nThe \\emph{lower $\\pi$ series} is\r\n$\\{ 1 \\} \\subseteq O_{\\pi'}(G) \\subseteq O_{\\pi', \\pi}(G) \\subseteq O_{\\pi', \\pi, \\pi'}(G) \\ldots$.\r\n\\\\\r\n\\\\\r\n{\\bf Examples of quadratic action:} \\\\\r\n(a) $G$ a $p$-group acting on the elementary abelian $p$-group $V$: $|V/C_V(G)|= p$;\\\\\r\n(b) $G \\in S_p(SL(V))$ acting on $V$ the vector space over $F_{p^m}$; in this case, note $x \\in S_p(SL_2(p)) \\rightarrow (x-1)^2 = 0$.\\\\\r\n(c) $V, G \\lhd H$, $G$-abelian, since $[V,G] \\subseteq V \\cap G$ and $[V \\cap G, G] = 1$.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 5:}\r\nIf $G$ acts quadratically on $V$ then (a) $[v^n,a]=[v,a^n]=[v,a]^n$,\r\n(b) $|V| \\le |C_V(a)|^2$, (c) $G/C_G(V)$ is an elementary abelian $p-$group.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\n$[v,a^2]= [v,a] [v,a]^a$ but quadratic action gives $[v,a]^a= [v,a]$ so\r\n$[v,a^2]= [v,a]^2$.  $[V,G']= 1$ so $G' \\subseteq C_G(V)$ and so $G/C_G(V))$ is abelian.\r\nSince $[v, a^p] = 1$, it is elementary abelian.  For (b), note that\r\n$V/C_V(G) \\cong [V, a] \\le C_V(a)$.\r\n\\end{quote}\r\n{\\bf Theorem 6:}\r\nLet $G$ act on an $F_q$ vector space $W \\ne 0$, $q=p^m$.  Suppose $G= \\langle a,b \\rangle $ and\r\n$a, b$ act quadratically on $W$, $G/C_G(W)$ is not a $p-$group, $|ab|=p^ek, k \\mid (p-1)$\r\nthen $\\exists \\varphi: G \\rightarrow SL_2(q)$.  \r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nBy induction on $|G|+ dim(W)$.  If action is not faithful, we're done by induction.\r\nLet $W_1$ be a maximal $G$-invariant subspace of $W$.  If $G/C_G(W_1)$ is not a\r\n$p$-group,then $C_G(W/W_1)$ is not a $p$-group; if $W_1 \\ne 0$, again we're done by induction.\r\nSo $G$ acts faithfully and irreducibly on $W$ and if $a, b$ \r\nare $p$-elements, they act quadratically and $G$ is not abelian.\r\nBy Schur, $< \\langle ab \\rangle $ acts as a scalar on a minimal \r\n$ \\langle ab \\rangle $-invariant subspace\r\nof $W$.  $\\exists 0 \\ne W \\in W, \\lambda \\in F_q^*: w^{ab}= \\lambda w$.\r\nIf $w^a \\in F_q w$, it is $G$-invariant and $W= F_qw$ by irreducibility and $G$ is\r\nabelian.  Contradiction.  Thus $W_1 = F_q w + F_q w^a$ is $2$-dimensional and we\r\nhave:\r\n$[w,a] \\in C_{W_1}(a)$ and\r\n$w^{b^{-1}} -w \\in C_{W_1}(b)$.  So $(w^a)^a \\in W_1$, $w^b \\in W_1$ and $w^{ab} \\in W_1$.\r\nso $W_1$  is $G$-invariant and $W= W_1$.  $G \\le SL(W)$ since $SL_2(q)$ is generated by\r\n$p$-elements $a, b$.\r\n\\end{quote}\r\n{\\bf Definition 3:} $G$ is \\emph {$p$-stable} if $\\forall a \\in G, [V,a,a]=1$ implies \r\n$a C_G(V) \\in O_p ( G/C_G(V))$.\r\n\\\\\r\n\\\\\r\n{\\bf Question:}  If $V/F_q$, $q= p^n$, is a faithful $G$-module, when does a $p$ element of\r\n$G$ have a quadratic minimal polynomial?  This is trivial for $p=1$ and is true for\r\nall elements of $SL_2(q)$.  Let $G$ be a group and $O_p(G)=1, p \\ne 2$\r\nA faithful representation of $G$ on $V$, $\\varphi$ is \\emph{$p$-stable} if\r\nno $p$-element of $\\varphi(G)$ has a quadratic minimal polynomial.  $G$ is $p$-stable\r\nif all such faithful representations of $G$ are $p$-stable.\r\n\\\\\r\n\\\\\r\n{\\bf Lemma:} If $G$ is $p$-stable and $a$ acts trivially on $[V,a]$ then $ \\langle A \\rangle \r\nC_G(V)/C_G(V)$ \r\nis a $p$-group.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\n$[V,a,a]=1$ so $a C_G(v) \r\n\\in O_p(G/C_G(V))$ and $\\langle a C_G(V) \\rangle = \\langle A \\rangle\r\n\\subseteq  O_p(G/C_G(V))$.\r\n\\end{quote}\r\n{\\bf Theorem 7:} Let $p \\ne 2$ and $G$ be faithful on $V$.\r\nSuppose (1) $G= \\langle a,b \\rangle $ where $a$ and $b$ act quadratically on $V$ and\r\n(2) $G$ is not a $p-$group then (1) the Sylow $2$ subgroups of $G$ are not abelian and\r\n(2) If $Q$ is a normal $p'$-subgroup of $G$ and $[Q,a] \\ne 1$ then $p=3$ and there\r\nis a section of $G$ isomorphic to $SL_2(3)$.  If $p \\ne 2$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $|ab|= p^e k$ and $q$ be a power of $p$ with $k \\mid (q-1)$.  Write $V$ additively\r\nas a vector space over $F_p$ and choose a basis $ \\langle v_1 , v_2 , \\ldots , v_n \\rangle $; \r\nthe action\r\ncan be extended to an action of $G$ over $W$.  By the previous result,\r\n$\\exists \\varphi: G \\rightarrow SL_2(q)$ with \r\n$G^{\\varphi}= \\langle a^{\\varphi}, b^{\\varphi} \\rangle $ and\r\n$G$ is not a $p$-group so it is not $p$-closed.  This gives (a).  (b) follows since\r\nif $Q^{\\varphi}$ is an $a^{\\varphi}$-invariant $p'$-subgroup\r\nsuch that $[Q^{\\varphi}, a^{\\varphi}] \\ne 1$.\r\n\\end{quote}\r\n{\\bf Theorem 8:}\r\nSuppose $p \\ne 2$ and the action of\r\n$G$ on $V$ is faithful and not $p-$stable then (1) the Sylow $2$-subgroups of\r\n$G$ are non-Abelian and (2) if $G$ is $p-$separable \r\nthen $p=3$ and there is a section of\r\n$G$ isomorphic to $SL_2(3)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\n$\\exists a \\in G \\setminus O_p(G)$ such that $[V,a,a] = 1$.  Let ${\\cal K}$ be the\r\n$G$-composition factors of $V$.  $O_p(G)= \\bigcap_{W \\in {\\cal K}} C_G(W)$.  Hence,\r\n$\\exists W \\in {\\cal K}, a \\notin C_G(W)$ so a $C_G(W) \\notin O_p(G/C_G(W)) = 1$.\r\nThus $G/C_G(W)$ and $W$ satisfy the hypothesis and we can assume $W=V, O_p(G)=1$ by\r\ninduction.  By Baer, $\\exists b \\in a^G: G_1 = \\langle a,b \\rangle $ is not a $p$-group.  Now\r\n(a) follows from the previous result.  If $G$ is $p$-seperable, put $Q= O_{p'}(G)$ then\r\n$[Q, a] \\ne 1$ and $b$ can be chosen in $a^Q$ so we get (b).\r\n\\end{quote}\r\n{\\bf Theorem 9:} Suppose $G$ acts faithfully on $V$ and $E_1 , E_2$ are\r\ntwo subnormal subgroups of $G$ \r\nsuch that $[V,E_1 , E_2 ]=1$ then $[E_1 , E_2 ] \\le O_p (G)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nBy hypothesis, $V_1= [V, E_1]$ is invariant under $E= \\langle E_1 , E_2 \\rangle $ so\r\n$E_0 = C_E(V_1)$ and $E^0= C_E(V/V_1)$ are normal in $E$.\r\n$E_0 \\cap E^0$ acts quadratically on $V$ and is a $p$-group by the earlier result.\r\nThus $E_0 \\cap E^0 \\le O_p(E)$.\r\n$E_1 \\le E^0$ and\r\n$E_2 \\le E_0$ so $[E_1 , E_2 ] \\le [E^0 , E_0] \\le E^0 \\cap E_0 \\le O_p(E)$ so\r\n$E$ and $O_p(E)$ are subnormal in $G$ and hence, $O_p(E) \\le O_p(G)$.\r\n\\end{quote}\r\n$Q_8= \\langle\r\n\\left(\r\n\\begin{array}{cc}\r\ni & 0 \\\\\r\n0 & -i \\\\\r\n\\end{array}\r\n\\right),\r\n\\left( \r\n\\begin{array}{cc}\r\n0 & -1 \\\\\r\n-1 & 0 \\\\\r\n\\end{array}\r\n\\right) \\rangle $.\r\n\\section {Replacement Results}\r\n{\\bf Observation:} $A^* = C_A([V,A])$ acts quadratically on $V$.\r\n\\\\\r\n\\\\\r\n{\\bf Condition ${\\cal Q}_1$:}\r\n$|A| |C_V(A)| \\ge |A^*| C_V(A^*)|, \\forall A, A^*$.\r\n\\\\\r\n\\\\\r\n{\\bf Condition ${\\cal Q}_2$:}\r\n$A/C_A(V)$ is an elementary abelian $p$-group.\r\n\\\\\r\n\\\\\r\n{\\bf Definition 4:}  ${\\cal A}_V(G) = \\{ A \\le G: A$ satisfies ${\\cal Q}_1$ and ${\\cal Q}_2 \\}$.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 10:}  \r\nSuppose $A$ acts on an elementary abelian $p$-group, $V$, with $A/C_A(V)$ abelian.\r\nLet $U \\le V$.  Then $\\exists A^* \\le A$ such that one of the following holds:\r\n(a) $|A| |C_V(A)| \\l |A^*| |C_V(A^*)|$, or \r\n(b)  $A^* = C_A([U,A]), C_V(A^*)= [U,A] C_V(A), |A| |C_V(A)| = |A^*| |C_V(A^*)|$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nAssume ${\\cal Q}_1$ does not hold.   $\\forall B \\le A$, so $|A| |C_V(A)| \\ge |B| |C_V(B)|$.\r\nPut $A^* = C_A([U,A])$.  $[U, A, A^*]=1$ and $A/C_A(V)$ is abelian so\r\n$[A, A^*, U] =1  \\rightarrow [U,A^* A] = 1$ so $[U, A^*] \\le C_V(A)$.\r\n\\\\\r\n\\\\\r\n\\emph{Claim:} $|A| |C_V(A)| \\le |A^*| |[U,A] C_V(A)|$.\r\n\\\\\r\n\\\\\r\nAssuming claim, $|A^*| |C_V(A^*)| \\le |A| |C_V(A)| \\le |A^*| |[U,A] C_V(A)| \\le |A^*| |C_V(A^*)|$\r\nand we're done.\r\n\\\\\r\n\\\\\r\n\\emph{Proof of claim:}\r\nLet $Y= C_V(A), X= [U,A]$.\r\nWe can assume $|U|= p, U= \\langle u \\rangle $ and $[U, A]= [u,a]$.\r\nLet $\\varphi: A/A^* \\rightarrow (XY)/Y$ by $a A^* \\mapsto [u,a]Y$ is well defined.\r\n$\\forall a^* \\in A^*$.\r\n$[u, a^*, a]= [u,a] [u, a^*]^a \\in [u,a]Y$.\r\nIf $\\varphi$ is injective, $|A/A^*| \\le (XY)/Y|$ and the result follows.\r\nLet $a_1, a_2 \\in A$ such that $[u, a_1]Y= [u, a_2 ]Y$.\r\n$[u, a_1] [u, a_2 ]^{-1} \\in Y$ then $[u, a_1 a_2^{-1}] \\in Y$ so\r\n$[u, A, A_1 s_2^{-1}]= 1 $\r\nand $a_1 a_2^{-1} \\in C_A([U,A])=A^*$.  Thus $\\varphi$ is injective.\r\nNow assume $|U| > p$, $|U:U_1|= p, U= U_1 \\langle u \\rangle $.\r\nPut $X_1= [U_1, A]$, $A_1 = C_A(X_1)$ and\r\n$X_2= [U_2, A]$, $A_2 = C_A(X_2)$.\r\nNote $X_1 X_2 C_V(A)= X C_V(A), A^* = A_1 \\cap A_2$ and\r\n$X_1 C_V(A) \\cap X_2 C_V(A) \\le C_V(A_1 A_2 )$.\r\nBy induction on $|U|$,\r\n$|A| |C_V(A)| = |A_i | |X_i:C_V(A)|$.  Hence,\r\n$|A| |C_V(A)| \\ge\r\n|A_1 A_2| |C_V(A_1 A_2 ) | \\ge\r\n{\\frac {|A_1| |A_2| |X_1 C_V(A)| |X_2 C_V(A)|}\r\n{|A_1 \\cap A_2| |X_1 C_V(A)| |X_2 C_V(A)|} }\r\n= {\\frac {|A|^2 |C_V(A)|^2} {|A^*| |X C_V(A)|}}$ and this proves the claim.\r\n\\end{quote}\r\n{\\bf Theorem 11:} \r\n$A \\in {\\cal A}_V(G)$ and $A^* = C_A([V,A])$ then \r\n$|A/A^*| = |C_V(A^*)/C_V(A)|$ and $C_V(A^*)= [V,A] C_V(A)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nBy the previous result, every quadratically acting subgroup, $A$, satisifes\r\n${\\cal Q}_2$ and the result follows from the second conclusion of that theorem, with $U=V$.\r\n\\end{quote}\r\n{\\bf Timmesfeld Replacement Theorem:}  \r\nLet $A \\in {\\cal A}_V(G)$ and $U \\le V$ then $C_A([U,A]) \\in {\\cal A}_V(G)$ and\r\n$C_V(C_A([U,A]))= [U,A] C_V(A)$.  Moreover,\r\n$[V,C_A(([U,A])] \\ne 1$ if $[V,A] \\ne 1$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet  $A^* C_A([U,A])$.  Since $A \\in {\\cal A}_V(G)$, we can apply the previous\r\nresult so\r\n$|A^*| |C_V(A^*)| = |A| |C_V(A)|$ and $C_V(A^*)= [U,A] C_V(A)$.\r\n$\\forall A_0 \\le A, {\\cal Q}_1$ gives\r\n$|A_0| |C_V(A_0)| \\le |A^*| |C_V(A^*)|$.\r\nHence \r\n$A^* \\in {\\cal A}_V(G)$, we may assume $[V, A^*] =1$ then $V= [U,A] C_V(A)= [V,A] C_V(A)$.\r\nIn particular, $[V,A,A]=[V,A]$ but then $[V,A] = 1$ since $A/C_A(V)$ is a $p$-group.\r\n\\end{quote}\r\n{\\bf Definition 5:} ${\\cal A}_V(G)_{min}= \\{ A \\in {\\cal A}(G), [V,A] \\ne 1 \\}$.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 12:}  Every element of ${\\cal A}_V(G)_{min}$ acts quadratically and non-trivially on\r\n$V$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $A \\in \r\n{\\cal A}_V(G)_{min}$.  By previous result, $A^*= C_A([V,A])$ is also in\r\n${\\cal A}_V(G)$ and $[V, A^*] \\ne 1$.  Minimality forces $A=A^*$ and thus\r\n$[V,A,A]=1$.\r\n\\end{quote}\r\n{\\bf Theorem 13:}  Suppose $G$ is $p$-stable on $V$ and $O_p(G/C_G(V))=1$ then every element of\r\n${\\cal A}_V(G)_{min}$ acts trivially on $V$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nFollows from previous result.\r\n\\end{quote}\r\n{\\bf Theorem 14:}\r\nLet $V= \\langle C_V(S), S \\in S_p(G) \\rangle $ then $O_p(G/C_G(V))=1$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $S \\in S_p(G)$, $Z= C_V(S), C= C_G(V)$.  $V= \\langle Z^G \\rangle $.  Let $C \\le D \\le G$:\r\n$D/C \\cong O_p(G/C)$ then $D \\cap S \\in S_p(D)$ and $D= C(D \\cap S)$ and by\r\nFrattini: $G=C N_G(D \\cap S)$.  So $V= \\langle Z^{N_G(D \\cap S)} \\rangle $, so $[V, D \\cap S]= 1$\r\nand $D=C$.\r\n\\end{quote}\r\n{\\bf Theorem 15:}\r\nLet $C_G(O_p(G)) \\le O_p(G)$ then $V= \\langle \\Omega({\\mathbb Z}(S)), S \\in S_p(G) \\rangle $ \r\nis an elementary\r\nabelian normal subgroup of $G$ and $O_p(G/C_G(V))=1$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $S \\in S_p(G)$ then $\\Omega ({\\mathbb Z}(S)) \\le C_G(O_p(G)) \\le O_p(G) \\le S$ so\r\n$V$ is contained in $\\Omega({\\mathbb Z}(O_p(G)))$ and $\\Omega({\\mathbb Z}(S))= C_V(S)$.  \r\nNow the result follows from the previous result.\r\n\\end{quote}\r\n{\\bf Definition 6:} Let ${\\cal E}(G)$ be the set of elementary elementary subgroups of $G$ and\r\n$m$ the the size of the element of ${\\cal E}(G)$ of maximal order.\r\n$J(G)= \\langle A \\in {\\cal A}(G): |A|=m \\rangle $.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 16:}\r\nLet $A \\in {\\cal A}(G)$ act quadratically\r\non $V$ and $A_0 = [V,A] C_A([V,A])$ then $A_0$ is in ${\\cal A}(G)$ and acts quadratically\r\non $V$ and if $[V,A] \\ne 1$ then $[V, A_0 ] \\ne 1$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $X= [V,A]$ and $A^*= C_A(X)$ with $A_0= A^*X$.  $A_0$ is elementary abelian\r\nand $[V,A_0, A_0] \\le [V, A, A_0 ] =1$.  It suffices to show $|A|= |A_0|$ to establish\r\n$A_0 \\in {\\cal A}(G)$.  The maximality of $A$ gives $C_V(A)= V \\cap A= V \\cap A^*$ and since \r\n$X \\cap A = X \\cap A^*$, $|A| |A \\cap V| = |A| |C_V(A)| = |A^*| |XC_V(A)|$.\r\nand so\r\n$|A| = {\\frac {|A^*| |XC_V(A)|} {|C_V(A)|}} =\r\n{\\frac {|A^*|} {|X \\cap C_V(A)|}} = {\\frac {|A^*| |X|} {|X \\cap A^*|}} = |A_0|$.\r\n\\end{quote}\r\n{\\bf Theorem 17:} \r\n(a) ${\\cal A}(G) \\subseteq {\\cal A}_V(G)$ and (b) $V \\nleq {\\mathbb Z}(J(G))$ then\r\n$\\exists A \\in {\\cal A}(G): [V,A] \\ne 1$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $ A^* \\in {\\cal A}(G)$ then $A^* C_V(A^*) \\in {\\cal E}(G)$ so\r\n$|A| \\ge |A^* C_V(A^*)|=\r\n{\\frac {|A^*| |C_V(A^*)|} {|A^* \\cap V|}} \\ge\r\n{\\frac {|A^*| |C_V(A^*)|} {|C_V(A)|}} $ and (a) follows.  (b) is clear.\r\n\\end{quote}\r\n{\\bf Condition ${\\cal Q}_1'$:} $|A/C_A(V)| \\ge |V/C_V(A)|$.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 18:} \r\nLet ${\\cal B}$ be the set of subgroups $A \\le G$ satisfying \r\n${\\cal Q}_1'$ and\r\n${\\cal Q}_2$.  Let $A \\in {\\cal B}$ and suppose that $\\forall A^* \\le A, A^* \\in {\\cal B}$,\r\n$|A^*/C_{A^*}(V)| |C_V(A^*)| \\le |A/C_A(V)| |C_V(A)|$ then $A \\in {\\cal A}_V(G)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nWe need to verify ${\\cal Q}_1$ for $A$.  Let $A^* \\le A$.  If $A^*$ does not satisfy\r\n${\\cal Q}_1'$ then $A^* \\notin {\\cal B}$ and\r\n$|A^*/C_{A^*}(V)| |C_V(A^*)| <\r\n|V| \\le |A/C_A(V)| |C_V(A)| $.  So \r\n$|A/C_A(V)| |C_V(A)| \\ge |A^*/C_{A^*}(V)| |C_V(A^*)|=\r\n|(A^*/C_{A^*}(V))/C_A(V)| |C_V(A^*)|$.  The inequality also holds for $A^* \\in {\\cal B}$ since\r\nthe inequality holds.\r\nThus $\\forall A^* \\le A$: \r\n$|A^*| |C_V(A^*)| \\le |A^* C_{A}(V)| |C_V(A^*)| \\le |A| |C_V(A)|$ and\r\n$A$ satisfies ${\\cal Q}_1$.\r\nAssume $\\exists A \\in {\\cal B}$ that act non-trivially on $V$.\r\nAmong all such choose it with the property that $|A/C_A(V)| |C_V(A)|$ is\r\nmaximal. Then the inequality in the theorem holds for $A$.  Thus\r\n$A \\in {\\cal A}_V(G)$ and ${\\cal A}(G)_{min} \\ne \\emptyset$.  A previous result insures\r\nthe existence that act quadratically and non-trivially on $V$.\r\n\\end{quote}\r\n{\\bf Theorem 19:} If ${\\cal K} \\in  \\{N, S, \\Pi\\}$ then \r\n$\\forall G: O_{\\cal K}(G)= \\langle A: A \\in {\\cal K}, A \\lhd \\lhd G \\rangle $.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nTor $A \\lhd G$, this is clear.  May assume $A$ is not normal in $G$ so $\\exists N \\lhd G$ with\r\n$A \\lhd \\lhd N<G$.  By induction, \r\n$A \\leq O_{\\cal K}(N)$.  \r\n$O_{\\cal K}(N) \\lhd G$ and  ${\\cal K} \\in \\{N , S , \\Pi \\}$.  Hence $A \\leq O_{\\cal K}(N) \\leq O_{\\cal K}(G)$ which\r\nproves the result.\r\n\\end{quote}\r\n\\section{Stability and $SL_2(p)$}\r\n{\\bf Hall's remark on Thompson:}  If $P \\in S_p(K)$ and $K \\ne XP$ for any $X \\in O_{p'}(K)$, then\r\nthere is a characteristic subgroup $D$ of $P$ of nilpotence class at most $2$ such that\r\n$N_K(D)/C_K(D)$ is not a $p$-group.\r\n\\\\\r\n\\\\\r\n{\\bf Definition 7:}  Let $G$ be a $p$-constrained group with $O_{p'}(G)=1$.\r\n$G$ is $p$\\emph{-stable} if $\\forall H \\lhd G, H \\in p(G)$,\r\n$[H,x,x]=1 \\rightarrow {\\overline x} \\in O_p(G/C_G(H))$.\r\n\\\\\r\n\\\\\r\n{\\bf Theorem 20:}\r\nA group is $p$-separable iff\r\n$H<G$ has a non-trivial $\\pi$-closed factor group or, equivalently\r\n$G$ has a normal series $1= A_0 < A_1 < \\ldots <A_n=G$ of characteristic\r\nsubgroups and $A_i/A_{i-1}$ is a $\\pi$ or $\\pi'$ group.\r\n\\begin{quote}\r\n\\emph{Proof:}  Sort of a definition.\r\n\\end{quote}\r\n{\\bf Theorem 21:}\r\nIf $p \\ne 2$, $O_{p'}(G)=1$ and $G$ is $p$-constrained or $p$-solvable and $SL_2(p)$ is\r\nnot involved in $G$, then $G$ is $p$-stable.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nSuppose $H \\lhd G$ is a $p$-group.  $G/C_G(H)$ acts on $H/\\Phi(H)$.  Let $K=ker(\\varphi)$\r\nwhere $\\varphi: G/C_G(H) \\rightarrow Aut(H/\\Phi(H))$.\r\n\\\\\r\n\\\\\r\n\\emph{Claim:} $K$ is a $p$-group.\r\n\\\\\r\n\\emph{Proof of claim:} It suffices to show that if\r\n${\\mathbb Z}_q < G/C_G(H)$ acts non-trivially on $H$, it acts nontrivially on\r\n$H/\\Phi(H)$.  If ${\\mathbb Z}_q$ acts trivially on $H/\\Phi(H)$.  For each coset,\r\n$\\Phi(H)x$, by counting, at least one element of the coset is fixed, say $x_i$.\r\nBy the Burnside Basis Theorem, $ \\langle x_i \\rangle_i = H$.  \r\nThus there is no $q$-element in $K$ and\r\n$|K|=p^m$.\r\n\\\\\r\n\\\\\r\nPut $L= G/C_G(H)/K$.  $L$ act faithfully on $H/\\Phi(H)$.  Since $SL_2(p)$ is not involved,\r\n$K$ is $p$ stable.  Now let $x \\in G$ with $[H,x,x]=1$ and let the canonical map\r\n$G/C_G(H) \\rightarrow L$ be denoted by $\\tilde {}$.  \r\n$[H,x,x]=1 \\rightarrow [H,x,x] \\in \\Phi(H) \\rightarrow\r\n(\\tilde {\\overline x}-1)^2=0$, so\r\n$\\tilde {\\overline x} \\in O_p(\\tilde{G/C_G(H)})$ we have\r\n$\\tilde {\\overline x} \\in O_p(G/C_G(H))$.\r\n\\end{quote}\r\n{\\bf Theorem 21:}\r\nLet $G$ be a group with no non-trivial normal $p$-subgroup, $p \\ne 2$ which satisfies one of\r\nthe following:\r\n(1) $G$ has odd order;\r\n(2) $G$ has an abelian Sylow $2$-subgroup;\r\n(3) $G$ has a dihedral Sylow $2$-subgroup;\r\n(4) $G \\cong PSL_2(q) = L_2(q)$;\r\n(5) $G$ is solvable and $p \\ge 5$ or $p=3$ and $SL_2(3)$ is not involved in $G$\r\nthen $G$ is $p$-stable.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nGeneralization of earlier result.\r\n\\end{quote}\r\n\\section{The Thompson Subgroup}\r\n{\\bf Definition} Let ${\\cal E}(G)$ be the elementary abelian subgroups of $G$ of maximal order.\r\n$J(G)= \\langle {\\cal E}(G) \\rangle)$.\r\n\\\\\r\n\\\\\r\n{\\bf $GL$ Lemma:} Let $G= GL_2(p)$, $p \\neq 2$, $P \\in S_p(G)$.  Suppose $L \\in p'(G)$ and $P \\subseteq N_G(L)$ and\r\nif $S \\in S_2(G)$, $S'=1$.  Then $P \\subseteq C_G(L)$.\r\n\\begin{quote}\r\n\\emph{Proof:}   Sublemma: If $q$ is odd, $-I$ is the unique involution in $SL_2(q)$.  Let $P$ be\r\na $p$-group with at most one group of order $p$.  Either $P$ is cyclic or $p=2$ and\r\n$P$ is generalized quaternion.\r\n\\\\\r\nBy induction on $|L|$, we can assume $P$ centralizes every proper subgroup that it stabilizes.\r\nChoose $q \\mid |L:C_L(P)|$.  We can find a $P$ invariant Sylow $q$ subgroup $Q \\subseteq L$.\r\nSince $Q \\neq C_L(P)$, $Q=L$.  So $L$ is a $q$-group.  $[L, P] \\subseteq P$.\r\nIf $[L,P] < L$, $[L,P,P]=1$ and we're done.  So $[L,P]=P$, $L \\subseteq G' \\subseteq SL_2(p)$ since\r\n$GL_2(p)/SL_2(p)$ is abelian.  If $q = 2$, $L$ is abelian and has a unique involution.\r\n$L$ is a cyclic $2$-group and so is $Aut(L)$  $P$ cannot act non-trivially on $L$ so $q \\neq 2$.\r\n$|L| \\mid (p-1)p(p+1)$ so $q \\mid p-1$ or $q \\mid p+1$. This $|L| \\leq p+1$.  If $P$ acts non-trivially on $L$\r\nthen there must be a $p$-orbit of $L$ of size at least $p$. $|L|=p+1$ and $|L|$ is even but\r\n$|L|$ is a power of $q$.  Contradiction.\r\n\\end{quote}\r\n{\\bf Normal P-Theorem:} Let $P \\in S_p(G)$ and suppose (1) $G$ is $p$-solvable, (2) $p \\ne 2$, (3) if\r\n$R \\in S_2(G)$, $R' = 1$, (4) $O_{p'}(G) = 1$, and (5) $P = C_G({\\mathbb Z}(P))$ then $P \\lhd G$.\r\n\\begin{quote}\r\n\\emph{Proof:} \r\nSuppose $G$ is a minimal counter-example. $\\exists Q \\in S_p(G), P \\neq Q: \\langle P, Q \\rangle G$.\r\n$Q= P^g$ and $C_V(Q) = C_V(P)^g$.  Put $U= C_V(Q) \\cap C_V(P)$. $|V:U| \\leq |V:C_V(P)| |V:C_V(Q)| = p^2$ and\r\n$U \\lhd V$.  $G$ acts trivially on $U$: $[U, G] = 1$.  $G$ acts on $V/U$; let $K$ be the kernel of this map.\r\n$[V,U] \\subseteq U$ and $[V, K, K] =1$ so $K$ is a $p$-group.  Note $K \\subseteq O_p(G)$ so \r\n$K \\subseteq P$ and $K \\subseteq Q$. ${\\overline G} = G/K$ has Sylow subgroups ${\\overline P}, {\\overline Q}$\r\nand ${\\overline G}$ acts faithfully on $V/U$ so $[{\\overline P}, C_V(P)/U] = 1$.  ${\\overline G}$ satisfies\r\nall the hypothesis of the theorem so $K=1$ and $G$ acts faithfully on $V/U$.\r\nReplace $V$ by $V/U$. $|V| \\leq p^2$. $G \\rightarrow Aut(V)$.  If $V$ is cyclic, $Aut(V)$ is abelian and\r\nso is $G$ therefore $P \\lhd G$.  So $V$ is elementary abelian and $Aut(V) = GL_2(p)$ and $O_p(G) = 1$ since\r\n$|P| \\leq p$ and $P$ is not normal.  Let $L = O_{p'}(G)$ and apply the previous lemma.  $[P, L]=1$ so by\r\nHall-Higman, $P \\subseteq C_G(L) \\subseteq L$ and $P=1$.\r\n\\end{quote}\r\n{\\bf Normal J-Theorem:} Let $P \\in S_p(G)$ and suppose (1) $G$ is $p$-solvable, (2) $p \\ne 2$, (3) if\r\n$R \\in S_2(G)$, $R' = 1$, (4) $G$ acts faithfully on some $p$-group, $V$ and (5) $|V:C_P(V)| \\leq p$,\r\nthen $J(P) \\lhd G$.\r\n\\begin{quote}\r\n\\emph{Proof:} \r\nLet $G$ be a minimal counterexample.  $U=O_{p}(G) > 1$, ${\\overline G} = G/U$,\r\n${\\overline L} = O_{p'}({\\overline G})$, where $U \\subseteq L$. \\\\\r\n\\\\\r\n\\emph{Step 1:} (a) ${\\mathbb Z}(P) \\subseteq U$, (b) $U \\subseteq H \\subseteq G$ implies $O_{p'}(H)=1$ and\r\n(c) $C_{{\\overline G}}({\\overline L}) \\subseteq {\\overline L}$.\\\\\r\n\\emph{Proof:} \r\nSince $G$ is $p$-solvable and $O_{p'}(G)=1$,\r\nby 1.2.3, $C_G(U) \\subseteq O_p(G) = U$ but $U \\subseteq P$ so\r\n${\\mathbb Z}(P) \\subseteq C_G(U)$, proving (a).\r\nSince $U = O_p(G)$ and $O_p({\\overline G}) = 1$, so \r\n$C_{{\\overline G}}({\\overline L}) \\subseteq {\\overline L}$ by 1.2.3,\r\nproving (c).  For (b), let\r\n$U \\subseteq H \\subseteq G$, and put $M= O_{p'}(H)$.  $M, U \\lhd H$. $M \\cap U =1$, since\r\n$U$ is a $p$-group and $M$ is a $p'$-group, so $M \\subseteq C_G(U) \\subseteq U$ and thus $O_{p'}(H)=1$\r\nand $M= M \\cap U =1$ proving (b).\r\n\\\\\r\n\\\\\r\n\\emph{Step 2:} $\\exists A \\in {\\cal E}(P): A \\not\\subseteq U$.\\\\\r\n\\emph{Proof:} If not, all members of ${\\cal E}(P)$ are contained in $U$ and so $J(P) \\subseteq U$.\r\nBy the $GL$ Lemma, $J(U) = J(P)$ is characteristic in $U$ and since $U \\lhd G$, $J(P) \\lhd G$,\r\nwhich contradicts the fact that $G$ is a counterexample.\r\n\\\\\r\n\\\\\r\n\\emph{Step 3:} Let $UA \\subseteq H \\subset G$ and $H \\cap P \\in S_p(H)$ then ${\\overline A}$ centralizes\r\n${\\overline {H \\cap L}}$.\\\\\r\n\\emph{Proof:}  $H$ satisfies the first four hypothesis of the theorem.  A Sylow $2$-group of $H$ is abelian so\r\nit meets condition (3).  $O_{p'}(H) = 1$ by 1(b).\r\nPut $S = H \\cap P \\in S_p(H)$.  Since ${\\mathbb Z}(P) \\subseteq U \\subseteq S \\subseteq P$ by 1(a).\r\n${\\mathbb Z}(P) \\subseteq {\\mathbb Z}(S)$ and thus $C_H({\\mathbb Z}(S)) \\subseteq C_G({\\mathbb Z}(P)) = P$.\r\nSo $C_H({\\mathbb Z}(S)) = S$ is a $p$-group of $H$ containing the Sylow $p$ group $S$.\r\nSo $C_H({\\mathbb Z}(S)) = S$ and $H$ satisfies the fifth hypothesis.  Since $H < G$, the theorem holds\r\nfor $H$ and so $J(S) \\lhd H$.  Since $A \\in {\\cal E}(P)$ and $A \\subseteq S \\subseteq P$ and $A \\in {\\cal E}(S)$ so\r\n$A \\subseteq J(S)$.  Thus $[H \\cap L, A] \\subseteq [H \\cap L, J(S)] \\subseteq (H \\cap L) \\cap J(S) = L \\cap J(S) \\subseteq U$\r\n(Reason: $H \\cap L$ and $J(S)$ are normal in $H$ and $U$ is the unique Sylow $p$-subgroup of $L$).\r\n$1 = [{\\overline {H \\cap L}}, {\\overline {A}}]$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 4:} $G = LA$, $P=UA$.\\\\\r\n\\emph{Proof:}  $H=LA$ and $UA \\in p(H)$.  Further,  $|H:UA|= |L(UA):UA| = |L:L \\cap UA|$ which divides the $p'$-number\r\n$|L:Y|$.  So, $UA \\in S_p(H)$, $UA = H \\cap P$.  \r\nIf $H < G$\r\nthen since $L \\subseteq H$, step 3 gives \r\n${\\overline A} \\subseteq C_{\\overline G}({\\overline L}) \\subseteq {\\overline L}$ (by step 1(c)).  Since ${\\overline A}$ is\r\na $p$-group and ${\\overline L}$ is a $p'$-group, ${\\overline A} = 1$ and $A \\subseteq U$.  This contradicts the choice of $A$\r\nso $H = G$.  Finally, $UA = H \\cap P = G \\cap P = P$.\r\n\\\\\r\n\\\\\r\n\\emph{Proof:} Put $H=LA$, $UA \\in p(H)$.  $|H:UA| = |LUA:UA|= |L:L \\cap UA|$ so $UA \\in S_p(H)$ and\r\n$UA = H \\cap P$.\r\nso $UA \\in S_p(H)$.  If $H \\subseteq G$, since $L \\subseteq H$, step 3 gives\r\n${\\overline A} \\subseteq C_{{\\overline G}}({\\overline L}) \\subseteq {\\overline L}$.  Since\r\n$A$ is a $p$-group and ${\\overline L}$ is a $p'$-group, ${\\overline A} =1$ and $A \\subseteq U$.\r\nThis contradicts the choice of $A$ so $H=G$.  Finally, $UA = H \\cap P = G \\cap P = P$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 5:} $|{\\overline A}| = p$.\\\\\r\n\\emph{Proof:}  \r\n${\\overline A} \\ne 1$ since $A \\not\\subseteq U$.  ${\\overline A}$ is elementary abelian, it STS ${\\overline A}$ is cyclic.\r\n${\\overline A}$ acts coprimely on ${\\overline L}$ and the action is faithful since $C_{\\overline L}({\\overline L}) \\subseteq {\\overline L}$\r\nand ${\\overline L} \\cap {\\overline A} = 1$.  A previous result shows ${\\overline A}$ is cyclic so STS ${\\overline A}$ acts trivially\r\non every ${\\overline A}$-invariant proper subgroup of ${\\overline L}$.\r\nSuppose\r\n${\\overline M}$ is ${\\overline A}$-invariant, ${\\overline M} < {\\overline L}$, we can assume\r\n$U \\subseteq M$. $A \\subseteq N_G(M)$ so $MA$ is a group $P = UA \\subseteq MA$.  Since $A$ is a $p$-group,\r\nthe $p'$ part of $|MA|$ is equal to the\r\n$p'$ part of $|M|$ which is less than the $p'$-part of $|L|$ since\r\nthe $p'$ part of$|L:M| >1$.\r\nIt follows $MA < G$.  Apply step 3 to show ${\\overline A}$ centralizes\r\n${\\overline {MA \\cap L}} \\supseteq M$, proving 5.\r\n\\\\\r\n\\\\\r\n\\emph{Step 6:}  Let $V= \\{ z: z \\in {\\mathbb Z}(U) | z^p = 1\\}$.  $V$ is an elementary abelian normal subgroup of $G$ so $G$ acts by\r\nconjugation on $V$.  Since $V \\subseteq {\\mathbb Z} (U)$, the action by $U$ is trivial, so ${\\overline G} = G/U$ on $V$.\r\nNow we prove:\r\nThe action of ${\\overline G}$ on $V$ is faithful. \\\\\r\n\\emph{Proof:}  \r\nLet $K = C_G(V)$ so ${\\overline K}$ is the kernel of the action of ${\\overline G}$ on $V$.\r\nWe argue $K$ is a $p$-group.\r\nLet $Q \\in S_q(K)$, $q \\ne p$.  $Q$ acts coprimely on ${\\mathbb Z}(U)$, so\r\nand $Q$ fixes all elements of order $p$ in ${\\mathbb Z}(U)$, these make up $V$. \r\n$Q \\subseteq K =C_G(V)$.   By Fitting, $Q$ acts trivially on ${\\mathbb Z}(U)$ but\r\n${\\mathbb Z}(P) \\subseteq U$ so ${\\mathbb Z}(P) \\subseteq {\\mathbb Z}(U)$ and so $Q \\subseteq C_G({\\mathbb Z}(P)) = P$.\r\nThus $Q = 1$ and $K$ is a $p$-group, as claimed.   But $K \\lhd G$.  So $K \\subseteq O_p(G)=U$ and ${\\overline K} = 1$ as needed.\r\n\\\\\r\n\\\\\r\n\\emph{Step 7:} $|V: V \\cap A| \\leq p$.\\\\\r\n\\emph{Proof:}  Put $D = U \\cap A$ and $E = V \\cap A$.  $|V:E| = |V:V \\cap D| = |VD:D|$.  $D$ is an elementary abelian\r\nsubgroup of $U$ and $V$ is a central elementary abelian subgroup of $U$ and so $VD$ is elementary abelian.\r\nSince ${\\cal E}(P)$, $|VD| \\leq |A|$ and so $|VD:D| \\leq |A:D| = |{\\overline A}| = p$.  We get $|V:E|= |VD:D| \\leq p$\r\nas required.\r\n\\\\\r\n\\\\\r\n\\emph{Step 8:} Contradiction. \\\\\r\n\\emph{Proof:}\r\nWe apply the Normal-P theorem to the action of ${\\overline G}$ on $V$.\r\n$|V: V \\cap A| \\leq p$. Now, $P=UA$ so ${\\overline P} = {\\overline A}$.\r\n$[{\\overline A}, V \\cap A] = 1$ since $A' = 1$.  \r\nSo $|V:C_V({\\overline P})| \\leq | V: V \\cap A| \\leq p$.  Now we can apply the Normal P theorem,\r\n${\\overline P} \\lhd {\\overline G}$ so $P \\lhd G$ and $A \\subseteq P \\subseteq O_p(G)=U$, which is not\r\nthe case.\r\n\\end{quote}\r\n{\\bf Theorem 22:} \r\n(1) $J(G) \\; char \\; G$ and $J(G) > 1$ if $p \\in \\pi(G)$;\r\n(2) If $J(G) \\le U \\le G$ then $J(G) = J(U)$; \r\n(3) $J(G)= \\langle J(S): S \\in S_p(G) \\rangle $;\r\n(4) If $x \\in C_G(J(G))$ and $|x|=p$, then $x \\in {\\mathbb Z}(J(G))$.\r\n(5) If ${\\cal B} \\subseteq {\\cal A}(G)$ then \r\n$J( \\langle {\\cal B} \\rangle) =  \\langle {\\cal B} \\rangle $.\\\\\r\n\\begin{quote}\r\n\\emph{Proof:}   This is straightforward.\r\n\\end{quote}\r\n{\\bf Definition 8:}\r\n$G$ is Thompson factorizable\r\nwith respect\r\nto $p$ if $G=O_{p'}(G) C_G( \\Omega(Z(S))) N_G(J(S))$.  \r\nNote that $G$ is Thompson factorizable iff $G/O_{p'}(G)$ is.\r\n\\\\\r\n\\\\\r\n{\\bf Thompson Factorization:} \r\nLet $O_{p'}(G)=1$ and $V= \\langle \\Omega({\\mathbb Z}(S)): S \\in S_p(G) \\rangle $.\r\nThen $G$ is Thompson factorizable iff $J(G) \\le C_G(V)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $S \\in S_p(G)$ and $C= C_G(V)$.  Assume that $G$ is Thompson factorizable.\r\n$\\Omega({\\mathbb Z}(S)) \\le {\\mathbb Z}(J(S))$ and so $V \\le {\\mathbb Z}(J(S))$ and\r\n$C \\le J(G)$.\r\nAssume $C \\le J(G)$.  The $J(G) \\le C \\cap S$.  Since $J(S) \\; char \\; C \\cap S \\in S_p(C)$\r\nand\r\n$\\Omega({\\mathbb Z}(S)) \\le {\\mathbb Z}(J(S))$, Frattini yields\r\n$G= C N_G(C \\cap S) =\r\nC_G( \\Omega(Z(S))) N_G(J(S))$.\r\n\\end{quote}\r\n{\\bf Alternate Thompson subgroup:} \r\n$P$ a $p$-group and set $d(P)= sup\\{ |A| : A \\le P, A'=1 \\}$.  Let\r\n${\\cal A}(P)= \\{ A: |A|=d(P), A'=1 \\}$ then $J(P)= \\langle A : A \\in {\\cal A}(P) \\rangle $.\r\n\\\\\r\n\\\\\r\n{\\bf Lemma:}\r\n(1) $A \\in {\\cal A}(P) \\rightarrow A=C_P(A)$;\r\n(2) $C_P(J(P))= {\\mathbb Z}(J(P)) = \\bigcap_{A \\in {\\cal A}(P)} A$;\r\n(3) $H \\le P$ and $d(H)=d(P) \\rightarrow J(H) \\le J(P)$ and\r\n${\\mathbb Z}(J(H)) \\le {\\mathbb Z}(J(P))$;\r\n(4) Suppose $J(P) \\subseteq H \\subseteq P$ then $J(H)=J(P)$.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nIf $x$ centralizes $A$, $ \\langle x, A \\rangle $ is abelian but then \r\n$| \\langle x,A \\rangle | > |A|$ so $x \\in A$; this proves\r\n(1).  $C_P(J(P))= \\bigcap_{A \\in {\\cal A}(P)} C_P(A)$ since $ \\langle A \\rangle =J(P)$.  Thus\r\n$C_P(J(P)) = \\bigcap_{A \\in {\\cal A}(P)} A \\subseteq J(P)$ so\r\n$C_P(J(P))= {\\mathbb Z}(J(P))$; this proves (2).  (3) and (4) are clear.\r\n\\end{quote}\r\n{\\bf Theorem 23:}\r\nSuppose $O_{p'}(G)=1$, $G$ is $p$-stable and $P \\in S_p(G)$.  If $H \\in {\\cal SCN}(P)$ then\r\n$H \\subseteq O_p(G)$.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nPut $L=O_p(G)$.  Since $L \\le P$, $[L, H] \\subseteq H$ and so $[L, H, H]=1$ so\r\n$x \\in H \\rightarrow [L,x,x]=1$ and thus $H/C_G(L) \\subseteq O_p(G/C_G(L)$.  Since\r\n$L$ is $p$-constrained, $C_G(L) \\subseteq L$ and thus $H \\subseteq L$.\r\n\\end{quote}\r\n\\section{Glauberman's $Z(J)$ Theorem:}\r\n{\\bf Glauberman Replacement Lemma:}  If $p \\ne 2$, $P$, a $p$-group, $B \\lhd P$,\r\n$A \\subseteq P$, $A'=1$, $B \\nsubseteq N_P(A)$ and $A \\cap B \\supseteq B'$ then\r\n$\\exists A^* \\subseteq P, (A^*)'=1$ with\r\n(1) $A^* \\cap B > A \\cap B$;\r\n(2) $|A^*|= |A|$;\r\n(3) $A^* \\subseteq N_P(A) \\rightarrow [A^*, A, A]=1$.\r\n\\begin{quote}\r\n{\\bf Outline of proof:} \r\n(1) Reduce to $P=AB$, $N_P(A) \\lhd P$; \r\n(2) $x \\in B-N \\ne \\emptyset, A \\cap B \\subseteq A \\cap A^x$;\r\n(3) $u=A A*$, $V=A \\cap A^*, W=U \\cap B$;\r\n(4) $[x, A]$ is abelian;\r\n(5) $VW$ is abelian;\r\n(6) $VW$ works.\r\n\\\\\r\n\\\\\r\n\\emph{Proof:}\r\nProof is by induction $|P|$.  If $|P|>|AB|$, we are done by induction,\r\nso $P=AB$.  Suppose $N=N_P(A)$, $\\exists M$ such that $N \\le M \\lhd P$ since\r\nthe maximal subgroups of $P$ are normal.  Let $B_1= B \\cap M$ then by\r\nDedekind, $A B_1= M$ and $B_i \\nsubseteq N_M(A)$.  Applying induction,\r\nwe find an $A^*$ such that $A^*$ satisfies (1), (2) and (3) in $A B_1$.  This\r\n$A^*$ works in $P=AB$.  So we may assume, $N \\lhd P$.\\\\\r\n\\emph{Claim:} $x \\in B-N \\rightarrow A \\cap B \\subseteq A \\cap A^x$ and\r\n$A^x \\le N$.  Proof of claim:\r\n$A \\cap B \\supseteq B'$ $\\rightarrow A \\cap B \\lhd B$ $ \\rightarrow A \\cap B= (A \\cap B)^x$\r\n$\\rightarrow A \\cap B \\subseteq A^x \\cap B \\rightarrow A \\cap B \\subseteq A \\cap A^x$.\r\nNow, $A<N$ so $A^x < N^x=N$ by the above and this proves the claim.\r\n\\\\\r\n\\\\\r\nLet $U=A A^x<N$, $V=A \\cap A^x$, $W= U \\cap B$.  $A^x \\subseteq  N_P(A)$ so $U$ is a\r\ngroup and $Z \\lhd U$.\\\\\r\nClaim:  $U' \\subseteq V \\subseteq {\\mathbb Z}(U)$ and $W= [x,A](A \\cap B)$.  Proof of claim:\r\n$A^x \\subseteq N, A \\subseteq N$ so $A^xA \\subseteq N$ and $A^xA, A^xA] \\subseteq A \\cap A^x$,\r\nwhich proves the claim.\\\\\r\nContinuing, $A \\cap B \\subseteq U \\cap B$ and $[x,a]= (a^{-1})^xa \\in U$ and \r\n$[x,a]= x^{-1} x^a \\in B$ so $[x,A](a \\cap B) \\subseteq W$.    If $y=a_1 a_2^x \\in W$,\r\n$a_1 , a_2 \\in A \\rightarrow a_1 a_2 [a_2,x]= a_1 a_2^x \\in B$ so\r\n$a_1 a_2 \\in B$ and $y \\in [x,A](A \\cap B)$.\r\n\\\\\r\n\\\\\r\n\\emph{Major claim:} $[x, A]$ is abelian.\r\n\\\\\r\nSubclaim: $U$ has nilpotence class $\\le 2$ ($U' \\subseteq {\\mathbb Z}(U)$) implies\r\n$[ac,b] [a,b][c,b]$.  This is a calculation.\\\\\r\nLet $a, a_1 \\in A$.  $[x,a,a_1]= [[x, [x,a]^{-1} [x,a], a_1^x]$ but since $[x,a] \\in B$,\r\n$[x, [x,a]^{-1}] \\in B \\subseteq A \\cap B \\subseteq {\\mathbb Z}(U)$,\r\n$[x,a,a_1]^x = [[x,a],a_1^x]$ by the subclaim.\r\nNow, $[[x,a],a_1^x]= [a,a_1^x]= [x,a_1,a]$.\r\nSo $\\forall a, a_1 \\in A: [x,a,a_1]^x=[x,a_1,a] \\rightarrow [x,a,a_1]^{x^2}=[x,a,a_1]$ \r\n(Equation **).  Since $x$ has odd order, this becomes $[[x,a],a_1^x]= [x,a,a_1][[x,a],[a_1,x]]$.\r\nSo $[[x,a],[a_1,x]]=1$; these two generators of $[x,A]$ commute so $[x,A]$ is abelian.\r\n\\\\\r\n\\\\\r\nClaim: $VW$ is abelian: $[x,A] \\subseteq U$ is abelian and $A \\cap B \\subseteq {\\mathbb Z}(U)$,\r\nso $W= [x,A] (A \\cap B)$ is abelian.  Finally, $V \\subseteq {\\mathbb Z}(U)$, so $VW$ is\r\nabelian.\r\n\\\\\r\n$A^*=VW$ satisfies the theorem:\\\\\r\n(1) $[x,A] \\nsubseteq A$ since $x \\notin N_P(A)$.\r\n$A \\cap B < W <B$ so $A^* \\cap B > A \\cap B$.\\\\\r\n(2) $|A^*|= \r\n{\\frac {|V| |W|} {|V \\cap W|}} =\r\n{\\frac {|A \\cap A^x| |U \\cap B|} {|U \\cap B \\cap A \\cap A^x|}} =\r\n{\\frac {|A \\cap A^x| |U \\cap B|} {|A \\cap B|}}$.\r\n$|P|=|AB|=\r\n{\\frac {|A| |B|} {|A \\cap B|}} =\r\n{\\frac {|U| |B|} {|U \\cap B|}}$.  So\r\n$\r\n{\\frac {|U|} {|A|}}=\r\n{\\frac {|U \\cap B|} {|A \\cap B|}}$ and $|A^*|= {\\frac {|A \\cap A^x| |U|} {|A|}}$.\r\n$|A^*| = {\\frac {|A \\cap A^x||A A^x|} {|A|}}= {\\frac {|A| |A^x|} {|A|}}= |A|$.\\\\\r\n(3)\r\n$A^* \\subseteq U$ since $V, W \\subseteq U$ and $U \\subseteq N$ since $A, A^x \\subseteq N$.\r\n\\end{quote}\r\n{\\bf Glauberman's $Z(J)$ Theorem:}  Assume $p \\ne 2$ is prime and that $G$ is a\r\n$p$-stable, $p$-constrained group with $O_{p'}(G)=1$ and $P \\in S_p(G)$ then\r\n${\\mathbb Z}(J(P)) \\lhd G$.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nLet $Z= {\\mathbb Z}(J(P))$ and $H= O_p(G)$.  $J(P) \\; char ;\\ P$ and $Z \\; char \\; P$ so\r\n$Z \\subseteq H$.  Let $H_0$ be a minimal normal $p$-subgroup of $G$ such that $Z \\cap H_0$ is not\r\nnormal in $G$.  Put $Z_0= H_0 \\cap Z$ and let $K/C_G(H_0)= O_p(G/C_G(H_0))$ so $K \\lhd G$.\r\nAlso put $P_0=P \\cap K \\in S_p(K)$.\r\n\\\\\r\n\\\\\r\n(1) $K= P_0 C_G(H_0)$. Reason: Since $K/C_G(H_0)$ is a $p$-group and $P_0C_G(H_0) \\subseteq K$,\r\n$K \\ne P_0 C_G(H_0)$ implies that $|K/C_G(H_0)| \\ge p |(P_0C_G(H_0))/C_G(H_0)= p {\\frac {|P_0 |}\r\n{|P_0 \\cap C_G(H_0)|}}$. Thus $|P_0| \\mid p \\cdot |K|$ which contradicts the fact that\r\n$P_0 \\in S_p(K)$.\r\n\\\\\r\n(2)  By Frattini, $G= KN_G(P_0)$.\r\n\\\\\r\n(3) $J(P) \\nsubseteq P_0$.  Reason: If not, $J(P) < J(P_0) \\lhd N_G(P_0)$ so\r\n$Z_0 \\lhd G$, a contradicton.\r\n\\\\\r\n(4) $H_0' \\subseteq Z_0$. Proof: Since $H_0$ is a $p$-group $H_0' < H_0$ so by\r\nmaximality, $Z \\cap H_0' \\lhd G$ and $H_0 = \\langle Z_0^g \\rangle $.  \r\n$[Z_0, H_0] \\subseteq Z_0 \\cap H_0' \\lhd G$,\r\nso $[Z_0, H_0]^g = [H_0, H_0] \\subseteq Z_0 H_0'$ and $H_0' \\subseteq Z_0 \\cap H_0'$.\r\n\\\\\r\n(5) $H_0 \\nsubseteq N_G(A)$ otherwise, $[H_0,A] \\subseteq A$ and\r\n$[H,A,A]=1$ which implies $A \\subseteq K$ by $p$-stability.\r\n\\\\\r\n(6)  $H_0 \\subseteq {\\mathbb Z}(J(P_0))$.\r\n\\\\\r\n\\\\\r\nConclusion:\r\nBy (1) and (2), $G= N_G(P_0) C_G(H_0)$ so $Z_0^g=Z_0^n, n \\in N_G(P_0)$ and\r\n$H_0= \\langle Z_0^g \\rangle \\subseteq {\\mathbb Z}(J(P_0)), \\forall g \\in G$.  Therefore\r\n$H_0 \\subseteq A^*$ and $A^* \\subseteq N_G(A)$ so $H_0 \\subseteq N_G(A)$ which is\r\na contradiction.\r\n\\end{quote}\r\n\\section{Alperin-Lyons Proof of Baer}\r\n{\\bf Theorem 24:}  Suppose $x$ is a $p$-element of $G$.  \r\n$x \\in O_p(G)$ iff $ \\langle x, x^g \\rangle $ is a $\\forall g \\in G$.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nLet $K= \\langle x^G \\rangle $ and suppose $z, y \\in K \\rightarrow \\langle z, y \\rangle $ \r\nis a $p$-group.  Suppose $K \\nsubseteq O_p(G)$.\r\n\\\\\r\n\\\\\r\n(1) $\\exists P, Q \\in S_p(G): P \\cap K \\ne Q \\cap K$.  \r\nReason: If $K \\subset R, \\forall R \\in S_p(G)$ then $K \\subseteq  \\bigcap R^g \\lhd G$ so\r\n$K \\subseteq O_p(G)$.\r\n\\\\\r\n\\\\\r\n(2) $|P \\cap K| = |Q \\cap K|$.  Reason: $Q= P^g$ so $Q \\cap K= P^g \\cap K^g= (P \\cap K)^g$\r\nso $|Q \\cap K|= |P \\cap K|$.\r\n\\\\\r\n\\\\\r\n(3) $K \\cap P \\nsubseteq Q$ and $K \\cap Q \\nsubseteq P$ for $P, Q$ chosen such that\r\n$P \\cap K \\ne Q \\cap K$.  If $K \\cap P \\subseteq Q$, $K \\cap P \\subseteq K \\cap Q$ if\r\nsince the cardinalities are the same, $K \\cap P = K \\cap Q$.\r\n\\\\\r\n\\\\\r\n(4) We can choose $P$ and $Q$ such that $|K \\cap P \\cap Q|$ is maximal with respect to\r\n$K \\cap P \\ne K \\cap Q$.  Put $W=P_0< P_1< \\ldots < P_n=p$ with $|P_i:P_{i-1}|=p$.\r\nNow $P \\cap K \\nsubseteq W$ (otherwise $ \\langle P \\cap K \\rangle \\subset P \\cap Q$ so \r\n$P \\cap K \\subset Q$\r\nwhich is a contradiction).\r\nLet $j$ be the smallest $j$ such that $P_j \\cap K \\nsubseteq W \\cap K$ ($ j \\ge 1$).  Pick\r\n$x \\in K\\cap P_j-W$.\r\n\\\\\r\n\\\\\r\n(5) Claim: $x \\in N(W)$.  Proof of claim: $x$ normalizes $P_{j-1}$ so $P_{j-1} \\cap K$\r\nis normalized by $x$.  By the choice of $j$, $P_{j-1} \\cap K \\subseteq W \\cap K$ so\r\n$P_{j-1} \\cap K = W \\cap K$.  \r\nThus $W= \\langle P_{j-1} \\cap K \\rangle = P_{j-1} \\cap K \\rangle^x= W^x$ which\r\nproves the claim.\\\\\r\nFor the same reason, $\\exists y \\notin W: y \\in K, y \\in N(W)$ and \r\n$ \\langle x, y \\rangle $ is a $p$-group.\r\nThus if $R \\in S_p(G)$ with $ \\langle x, y \\rangle W  \\subset R$,\r\n$K \\cap P \\cap R \\supseteq K \\cap W \\cap \\langle x \\rangle $ and \r\n$|K \\cap P \\cap R| > |K \\cap P \\cap Q|$\r\nand symmetrically,\r\n$|K \\cap Q \\cap R| > |K \\cap P \\cap Q|$ thus $P \\cap K = R \\cap K= K \\cap Q$ concluding the proof.\r\n\\end{quote}\r\n\\section{Goldschmidt's Proof of Burnside's Theorem for $p \\ne 2$}\r\n{\\bf Burnside's Theorem:}  If $|G|= p^a q^b$ for $p \\ne 2 \\ne q$ then $G$ is solvable.\r\n\\begin{quote}\r\n\\emph{Proof:}\r\nLet $G$ be a minimal counterexample, $r \\in \\{ p , q \\}$.\r\n\\\\\r\n\\\\\r\n\\emph {Lemma 1:}  If $R \\in S_r(G)$ then if $1 \\ne S \\in r'(G)$, $R \\nsubseteq N_G(S)$.\\\\\r\nProof: Let $Q \\in S_{r'}(G)$ with $S \\subseteq Q$.  Since $G=RQ$, $\\forall g, Q^g=Q^r$ for some\r\n$r \\in R$.  Now suppose $R \\subseteq N_G(S)$ then $S \\subseteq Q^r$ and thus\r\n$1 \\ne \\bigcap_{r \\in R} Q^r = \\bigcap_{g \\in G} Q^g \\lhd G$ which is impossible since $G$\r\nis simple.\r\n\\\\\r\n\\\\\r\n\\emph {Lemma 2:}  If $M$ is a maximal subgroup of $G$ then $F(M)$ is an $r$-group.\\\\\r\nProof:\r\nFrom now on, let $F=F(M)= F_p \\times F_q$, and $Z={\\mathbb Z}(F) = Z_p \\times Z_q$.\r\nObserve that if $M$ is maximal, $M$ is solvable and so\r\n$O_{p'}(N_M(P)) \\subseteq O_{p'}(M)$.\r\n\\\\\r\n\\\\\r\n\\emph{Claim 1:}  $F$ is not cyclic.\\\\\r\nAssume, by way of contradiction, that $F$ is cyclic.\r\nSuppose $q > p$ and $Q \\in S_q(M)$.  Since $Q$ acts on $F_p$ and $q \\nmid Aut(F_p)$, $[Q, F_p]=1$.\r\n$Q$ also acts on $F_q$ and\r\n$Q/C_Q(F) \\rightarrow Aut(F_q)$.\r\n$C_M(F) \\subseteq F$, since $M$ is solvable so $C_M(F) \\subseteq F$ and $C_Q(F) \\subseteq F_q$.  Clearly,\r\n$F_q \\subseteq C_Q(F)$ since $F_q$ is cyclic. So $Q/F_q \\subseteq Aut(F_q)$.  Further, $F_q \\thinspace char \\thinspace Q$ and\r\n$N_G(Q) \\subseteq N_G(F_q)$.  $N_G(Q) \\subseteq N_G(F_q) = M $.  Examining $N_M(F_q)/C_M(F_q) \\subseteq Aut(F_q)$, we see $|N_M(F_q)|_q = |Q|$ so\r\n$|N_M(F_q)|_q = |N_G(F_q)|_q$.\r\nThus, $Q \\in S_q(G)$, contradicting Lemma 1.\r\n\\\\\r\n\\\\\r\n\\emph{Claim 2:}  $M$ is the unique maximal subgroup containing $Z$.\r\n\\\\\r\nSuppose $Z \\subseteq M_1 \\ne M$. $M_1$ a maximal subgroup of $G$.\r\n$M= N_G(Z_p)= N_G(Z_q)$, $Z_p \\subseteq O_{q'}(N_{M_1}(Z_q))$ and\r\n$Z_q \\subseteq O_{p'}(N_{M_1}(Z_p))$.\r\nBecause $M$, is solvable, $O_{p'}(N_M(F)) \\subseteq O_{p'}(M)$,\r\n$Z_p \\subseteq F(M_1)_p \\subseteq C(Z_q) \\subseteq M$ and\r\n$Z_q \\subseteq F(M_1)_q \\subseteq C(Z_p) \\subseteq M$ so\r\n$F(M_1) \\subseteq F(M)$.  Since\r\nthe argument also applies to $M_1$, $F(M) \\subseteq F(M_1)$. So\r\n$F(M)= F(M_1)$.  This $M= N_G(F(M)) = M_1$, proving the claim.\r\n\\\\\r\n\\\\\r\nNow, since $F$ is not cyclic, there is an Abelian subgroup\r\n$V \\subseteq F$ of type $(r,r)$.  $\\forall x \\in V^{\\#}$, $Z \\subseteq C(x)$\r\nand by the uniqueness of $M$, $C(x) \\subseteq M$.  Let $V \\subseteq R \\in S_r(M)$.\r\nIf $Q_0 \\in r'(G)$  with $R \\subseteq N(Q_0)$.  $Q_0 = \\prod_{x \\in V^{\\#}} C_{Q_0}(x) \\subseteq M$.\r\nIt follows that $F_{r'}$ is the unique maximal $r'$-subgroup of $G$ normalized by $R$, so\r\n$N(R) \\subseteq N(F_{r'}) = M$ so $R \\in S_r(G)$, contradicting Lemma 1.  This proves Lemma 2.\r\n\\\\\r\n\\\\\r\n\\emph {Lemma 3:}  If $R \\in S_r(G)$ then $R$ is contained in a unique maximal subgroup of\r\n$G$.  Every maximal subgroup, $M \\subseteq G$, contains a Sylow subgroup of $G$.\r\n\\\\\r\n\\emph{Proof:} $R \\subseteq M$ so $O_{p'}(M)=1$ by lemma 1.  Since $M$ is\r\n$r$-constrained, $O_{r'}(M)=1$ and $M$ is solvable, $M$ is $r$-constrained.  Once\r\nwe know $M$ is $r$-stable, by Glauberman's $Z(J)$ theorem, we have: $M=N_G({\\mathbb Z}(J(R)))$.\r\n$p^aq^b$ is odd and $|SL_2(r)|= (r^2-1)r$ which is even, so $G$ is $p$-stable and $M=N_G({\\mathbb Z}(J(R)))$.\r\nSo $M$ is unique.\r\nLet $M_1$ be any maximal subgroup of $G$, we can choose $r$, such that $O_{r'}(M_1)=1$.\r\nIf $R_1 \\in S_r(M)$, we have\r\n$M_1 =N_G({\\mathbb Z}(J(R_1)))$.\r\nSince ${\\mathbb Z}(J(R_1)) \\; char \\; R_1$,\r\n$N_G(R_1) \\subseteq M_1$, so $R_1 \\in S_r(G)$ ,proving the second statement.\r\n\\\\\r\n\\\\\r\n\\emph {Lemma 4:}  If $R \\in S_r(G)$ then ${\\mathbb Z}(R)$ is contained in a \r\nunique maximal subgroup of $G$.\r\n\\\\\r\n\\emph{Proof:}  Suppose ${\\mathbb Z}(R) \\subseteq M \\cap M_1, M \\ne M_1$ with $M, M_1$ maximal in $G$.\r\nWe may assume $M_1$ is chosen such that $|M \\cap M_1|_r$ is maximal.  Now, let\r\n$R_1 \\in S_r(M \\cap M_1)$ such that ${\\mathbb Z}(R) \\subseteq R_1$.  By the maximality of $|M \\cap M_1|_r$,\r\n$N_G(R_1) \\subseteq M$ and $R_1 \\in S_r(M_1)$\r\nConjugating $R$ by something in $M$, we may assume, by lemma 1,\r\n$R_1 \\subset R$ and $M_1$ contains a $r'$ sylow subgroup of $G$.\r\nThus $G=RM_1$ and\r\n$1 \\ne {\\mathbb Z}(R) \\subseteq \\bigcap_{r \\in R} M_1^r= \\bigcap_{g \\in G} M_1^g \\lhd G$,\r\na contradiction.\r\n\\\\\r\n\\\\\r\n\\emph {Lemma 5:}  $\\exists R_1, R_2 \\in S_r(G)$ such that $R_1 \\cap R_2 = 1$.\r\n\\\\\r\n\\emph{Proof:}  Let $R_1 \\in S_r(G)$ and let $M$ be a unique maximal subgroup containing\r\n$R_1$.  Pick $R_2 \\nsubseteq M$.  We can do this since $G$ is simple.\\\\\r\n\\\\\r\nClaim: $R_2 \\cap M=1$.\r\n\\\\\r\nIf not, choose $R_2$ such that $|R_2 \\cap M|$ is as large as possible.  Put\r\n$R_0 = (R_2 \\cap M)$.\r\nWe can assume, possibly after conjugation in $M$, $R_0 \\subseteq R_1$.  ${\\mathbb Z}(R_1) \\subseteq N(R_0)$.\r\nBy lemma 4, $N(R_0) \\subseteq M$.  $R_0 < R_2$ so $N_{R_2}(R_0) > R_0$ and $|R_2 \\cap M| > |R_0|$,\r\nwhich is a contradiction.  So $R_2 \\cap M=1$.\r\n\\\\\r\n\\\\\r\nConclusion: WLOG, assume $q^b > p^a$ and let $Q_1, Q_2 \\in S_q(G)$ with $Q_1 \\cap Q_2=1$.\r\nThen $|G| \\ge |Q_1| \\cdot |Q_2| > |G|$ which is just plain wrong.\r\n\\end{quote}\r\n\\section{Thompson Complements}\r\n{\\bf Thompson Normal $p-$Complement:}\r\nLet $p \\ne 2$ and $P \\in S_p(G)$.  Assume $N_G(J(P))$\r\nand $C_G(\\Omega_1({\\mathbb Z}(P)))$ have a normal $p-$complement then so does $G$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nLet $G$ be a counterexample of minimum order.\r\n\\\\\r\n\\\\\r\n\\emph{Step 1:}  Let ${\\cal H}= \\{ H \\in p(G): N(H)$ does not have a normal $p$-complement $\\}$.\r\nIf $H, K \\in {\\cal H}$.  We say $H \\le K$ if one of the following holds:\r\n(1) $|N(H)|_p < |N(K)|_p$;\r\n(2) $|N(H)|_p = |N(K)|_p$ and $|H| < |K|$; or,\r\n(3) $|H| = |K|$.  Choose $H$ minimal with respect to the ordering and set\r\n$N=N(H)$.  Let $Q \\in S_p(N)$ and $H \\subseteq Q \\subseteq P$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 2:} $H \\ne P$\r\n\\\\\r\nIf $H=P$, $N \\subseteq N(J(P))$ which is a contradiction.\r\n\\\\\r\n\\\\\r\n\\emph{Step 3:} ${\\overline N}= N/H$ has a normal $p$-complement.\r\n\\\\\r\nLet ${\\overline Q}= P/H$ and ${\\overline Q} \\in S_p({\\overline N})$.  Suppose\r\n${\\overline N}$ does not have a\r\nnormal $p$-complement.\r\nSince $|{\\overline N}| < |{\\overline G}|$, either \r\n$C_{\\overline N}({\\mathbb Z}({\\overline P}))$ or\r\n$N_{\\overline N}(J({\\overline Q}))$ does not have a \r\nnormal $p$-complement.  Let $K$ be the inverse image of the one that fails to have a\r\nnormal $p$-complement.  $K \\in p(G)$ and $N(K)$ has no\r\nnormal $p$-complement.  Since $Q \\subseteq N(K)$, either\r\n$|N(K)|_p > |N(H)|_p$ or\r\n$|N(K)|_p = |N(H)|_p$ and $|H| < |K|$.  Hence, $K \\ge \\ge K$.  But $K \\ne H$ and this\r\ncontradicts maximality of $H$ in ${\\cal H}$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 4:} $N=G$.\r\n\\\\\r\n$N$ satisfies the hypothesis of the theorem $H \\subseteq Q \\subseteq P$ so\r\n${\\mathbb Z}(P) \\subseteq  N(H) =N$.\r\n$Q {\\mathbb Z}(P) \\subseteq N \\cap P$ so $Q {\\mathbb Z}(Q) = Q$ and\r\n${\\mathbb Z}(P) \\subseteq Q$ thus $\r\n{\\mathbb Z}(P) \\subseteq\r\n{\\mathbb Z}(Q)$ and $C_N({\\mathbb Z}(Q)) \\subseteq \r\nC_G({\\mathbb Z}(Q)) \\subseteq C_G({\\mathbb Z}(P))$.\r\nIf $P= Q$, $N(J(Q)) \\subseteq N(J(P))$ has a\r\nnormal $p$-complement.\r\nSuppose $Q < P$  so $N_P(Q) > Q$ and $|N_G(J(Q))|_p > |N|_p = |N_G(H)|_p$.\r\nBy the maximality of $H$ in ${\\cal H}$, $J(Q) \\notin {\\cal H}$ and so\r\n$N(J(Q))$ has a\r\nnormal $p$-complement and\r\nso does $N_N(J(Q))$.  If $ N \\ne G$, then by the minimality of $|G|$, $N$ has a\r\nnormal $p$-complement and so $N=G$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 5:}  $O_{p'}(G)=1$.\r\n\\\\\r\nLet $J= O_{p'}(G)$ and ${\\overline X} = X/L$.  If $K \\subset P$,\r\n$ {\\overline {N(K)}} = N({\\overline K})$,\r\n${\\overline {J(P)}} = J({\\overline P})$,\r\n${\\overline {C(P)}} = C({\\overline P})$, and\r\n${\\overline {{\\mathbb Z}(P)}} = {\\mathbb Z}({\\overline P})$.  So \r\n$N({\\mathbb Z}(P))$ has a \r\nnormal $p$-complement.  If $|{\\overline G}| < |G|$, ${\\overline G}$ and the inverse image is\r\na normal $p$-complement of $G$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 6:}  $H= O_p(G)$ and $G$ is $p$-solvable of $p$-length at most $2$.\r\n\\\\\r\nSet $K= O_p(G), K \\subseteq H$.  Since $G$ has no\r\na normal $p$-complement,  $N(K)=G$ and $K \\in {\\cal H}$, by steps 3, 4,\r\n$G/H$ has a\r\nnormal $p$-complement so $G$ has $p$-length $\\le 2$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 7:}  If ${\\overline G}= G/H= {\\overline P}{\\overline M}$ where ${\\overline M}$\r\nis a normal $p$-complement\r\nand ${\\overline M}$ contains no $P$-invariant subgroup.\r\n\\\\\r\nSuppose ${\\overline M} > {\\overline M}_0 >1$ and\r\n${\\overline M}_0$ is $P$-invariant.  Let $M_0$ be the inverse image and set\r\n$G_0= P M_0$.  $G_0 < G$ so $G_0$ has a\r\nnormal $p$-complement \r\nand $K_0 \\lhd G_0, K_0 \\cap P = 1$.  $[H, K_0] \\subseteq K_0 \\cap H =1$ so\r\n$K_0 \\subseteq C(H)$.  But then $K_0 \\subseteq {\\mathbb Z}(O_p(G))$ by Hall-Higman which is\r\na contradiction.\r\n\\\\\r\n\\\\\r\n\\emph{Step 8:} ${\\overline M} = {\\overline R}$ is an elementary abelian $r$-group for some\r\n$r \\ne p$ and $P$ acts irreducibly on ${\\overline R}$. Hence, $P$ is maximal in $G$.\r\n\\\\\r\nLet $r \\mid |{\\overline M}|$.  $P$ permutes Sylow $r$-subgroups and by Sylow, the conjugacy\r\nclass has size $1$.   So ${\\overline R} \\in S_r({\\overline M})$ is $P$-invariant and since\r\n${\\overline R}$ has no non-trivial characteristic subgroups, it is elementary abelian.\r\nSince ${\\overline M}$ has no proper ${\\overline P}$ invariant subgroups, ${\\overline P}$\r\nacts irreducibly.\r\nIf $G > L >P$, $1 \\le {\\overline L} \\cap {\\overline R} < {\\overline R}$\r\nand ${\\overline L} < {\\overline R}$ is a proper ${\\overline P}$-invariant subgroup of\r\n${\\overline R}$ which is a contradiction.\r\n\\\\\r\n\\\\\r\n\\emph{Step 9:} $\\exists 1 \\ne A \\in P$ with $A$ abelian such that $m_p(A)= d(P)$ and\r\n$A \\nsubseteq H$.\r\n\\\\\r\nLet $A$ be a fixed one of minimal order.  If $A_0= A \\cap H$,\r\n$A/A_0$ is elementary abelian.  If $J(P) \\subseteq H$ then $J(P) \\; char \\; H$ and\r\n$J(P) \\lhd G$ which is a contradiction.  So $J(P) \\nsubseteq H$ and such an $A$ exists.\r\nChoose $A$ as mentioned and set $A_0= A \\cap H$,  $A_1= \\Omega_1(A/A_0)$, $A_1 \\nsubseteq H$\r\nand $m(A)= m(A_1)$ so $A= A_1$ and $A/A_0$ is elementary abelian.\r\n\\\\\r\n\\\\\r\n\\emph{Step 10:}  Let ${\\overline A}= (AH)/H$ then $\r\n{\\overline G} = {\\overline A} {\\overline Q} $ and\r\n$|{\\overline A} |=p$.\r\n\\\\\r\n${\\overline G}= {\\overline P} {\\overline R}$ and\r\n${\\overline P}$ normalizes\r\n${\\overline R}$.  The action is faithful since $H=O_p(G)$ and the kernel would be a normal\r\n$p$-subgroup of $G$.  Note ${\\overline A}= (AH)/H \\cong A/A_0 \\ne 1$.\r\n${\\overline A}$ acts nontrivially on\r\n${\\overline R}$ by the previous result an we can find\r\n$ {\\overline R}_1 \\subseteq {\\overline R}$ on which ${\\overline A}$ acts non-trivially and\r\nirreducibly.  Let $G_1$ be the inverse image of\r\n$ {\\overline A} {\\overline R} $ and $P_1 \\in S_p(G_1)$.   $A \\subseteq P_1 \\subseteq P$.\r\nSince $H \\subseteq P_1$ and\r\n$C_G(H) \\subseteq H$, \r\n${\\mathbb Z}(P) \\subseteq C_G(H) \\subseteq H \\subseteq P$, and\r\n${\\mathbb Z}(P) \\subseteq {\\mathbb Z}(P_1)$ and the latter has a \r\nnormal $p$-complement.  Since\r\n$A \\subseteq P_1$ and $m(A)= d(P)$, $d(P_1)=  d(P)$ and\r\n$A \\subseteq J(P_1 )$.  Let $R_1 \\in S_r(N_G(J(P_1 )))$, then\r\n$[A, R_1 ]= [J(P_1 ), Q_2] \\subseteq J(P_1 )$ so\r\n$[A, R_1]$ is a $p$ group.  Since\r\n$ {\\overline R}_2 \\subseteq {\\overline R}_1 $,\r\n$ [A, {\\overline R}_2] \\subseteq {\\overline R}_1 $ is an $r$-group\r\nand so\r\n$ [A, {\\overline R}_2] =1$.   Thus, $R_2$ is an ${\\overline A}$-invariant\r\nsubgroup of ${\\overline R}_1$ centralized by\r\n${\\overline A}$ and ${\\overline R}_2 =1$ and $R_2=1$.  So $N_{G_1}(J(P_1 ))$ is a \r\n$p$-group and has a\r\nnormal $p$-complement. If $G_1 < G$ then $G_1$ has a \r\nnormal $p$-complement and would centralize $H$.   Contradiction.  Hence,\r\n$G = G_1$ and\r\n$ {\\overline G} = {\\overline A} {\\overline R} $\r\nand\r\n$ {\\overline A} $ acts faithfully and irreducibly on\r\n${\\overline R}$.\r\n$ {\\overline A} $ is elementary abelian and hence cyclic so $|A|= p$.\r\n\\\\\r\n\\\\\r\n\\emph{Step 11:}  Set $W= {\\mathbb Z}(H), Z= \\Omega_1(W)$.  If $R \\in S_r(G)$ then\r\n$[R, Z] \\subseteq Z$ but $[R, Z] \\ne 1$.\r\n\\\\\r\n${\\mathbb Z}(P) \\subseteq C_G(H) \\subseteq H$ so ${\\mathbb Z}(P) \\subseteq W$.\r\nIf $[R, W] = 1$, $[R, {\\mathbb Z}(P)] = 1$, hence\r\n${\\mathbb Z}(P)$ would be central in $G$ which is impossible.\r\n\\\\\r\n\\\\\r\n\\emph{Step 12:} Contradiction\r\n\\\\\r\n$Z \\lhd G$ and $G$ acts by conjugation so the kernel of the action is $C(Z) \\supset H$\r\nand so ${\\overline G}$ acts on $Z$.\r\nSince ${\\overline R}$ is the unique minimal normal subgroup of ${\\overline G}$ and\r\n${\\overline G}$ acts nontrivially,\r\n${\\overline G}$ acts irreducibly on $Z$ by step 11.\r\nBy a previous result, $Z= C_Z({\\overline R}) + V$ where $V$ is\r\n${\\overline R}$-invariant.\r\nMoreover,\r\n$ {\\overline R} \\lhd {\\overline G} $ and so $V$ is\r\n$ {\\overline G} $ invariant and \r\n$ {\\overline G} $ acts faithfully on $V$.\r\nSince $|A|=p$, $m(A_0) \\ge d(P) -1$.  Set $V_0= V \\cap A_0$ and let $t= m(V_0 )$ and\r\n$r= m(A/A_0)$.  $V \\subseteq {\\mathbb Z}(H)$ so $ \\langle V, A_0 \\rangle $ is abelian.\r\nSince $V$ is elementary, $d(P) \\ge m( \\langle V, A_0 \\rangle) = m(V)+m(A_0)- m(V \\cap A_0)= t+r +\r\nm(A_0)-t= d(P)-1+r$.  Hence, $r=0$ or $r=1$ and $V_0=V$ or $V_0$ is maximal.\r\nChoose $a \\in A \\setminus A_0$, ${\\overline b} \\in {\\overline R}^H$\r\nsuch that\r\n$[a, {\\overline b}] \\ne 1$,\r\n$[{\\overline a}, V_0] = 1$ and\r\n$[{\\overline a}^{\\overline b}, V_0^{\\overline b}] = 1$ then\r\n$[\\langle {\\overline a}, {\\overline a}^{\\overline b} \\rangle , V_0 \\cap V_0^{\\overline b}] = 1$ \r\nand $V_0 \\cap V_0^{\\overline b} \\le p^2$.  Since $A= \\langle a \\rangle $ is maximal in $Z$ and\r\n${\\overline a}^{\\overline b} \\notin {\\overline A}$, \r\n${\\overline G}_1, V_0 \\cap V_0^{\\overline b} = 1$ hence $|V| \\le p^2$.\r\nSo ${\\overline G} \\subseteq GL_2(p)$ and since\r\n${\\overline G}$ is generated by $2$ elements of order $p$, ${\\overline G} \\subseteq SL_2(p)$.\r\nSo we have an abelian $p'$ group, ${\\overline R}$, which is normalized but not centralized by\r\n${\\overline A} \\subseteq SL_2(p)$ of order $p$ and this is impossible. \r\n\\end{quote}\r\n{\\bf Theorem (Frobenius):}  If $G$ is solvable and $|G| > 1$, \r\n$\\exists p, P \\in p(G): 1 \\ne P \\lhd G$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nThe proof is by induction.  It is clearly true for all $p$-groups.   Since $G$ is solvable,\r\n$exists N \\lhd G$ and we can assume $|G:N|= p \\mid |G|$.  By induction, $exists q:  Q \\in q(N), Q \\lhd N$.\r\nSo $1 \\ne O_q(N) \\thinspace char \\thinspace N \\lhd G$.\r\n\\end{quote}\r\n{\\bf Theorem 25:}\r\nIf $P \\in S_p(G)$, $G$ contains a normal $p$-complement iff\r\nwhenever two elements in $P$ are $G$-conjugate, they are $P$ conjugate.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nSee the section on transfer.\r\n\\end{quote}\r\n{\\bf Theorem 26:}\r\nIf $G$ has a maximal subgroup, $M$, which is nilpotent of odd order, then $G$ is solvable.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nSee Passman.\r\n\\end{quote}\r\n{\\bf Theorem 27:}\r\nLet $p \\ne 2$, $P \\in S_p(G)$ and suppose for any $H<G: H \\; char ;\\ P$, $N_G(H)/C_G(H)$ is\r\na $p$-group, then $G$ has a normal $p$ complement.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nBy induction on $|G|$.  $N_G(H)$ has a normal $p$-complement by induction.\r\nIf $a \\in p'(H)$ then $[a,H]=1$.  So $H$ has  normal $p$-complement.  \r\nThe result follows from Thompson's\r\nnormal $p$-complement theorem.\r\n\\end{quote}\r\n{\\bf Theorem 28:}\r\nLet $p \\ne 2$, $G= SL_2(p)$.  The only abelian $p'$-subgroups of $G$ which are normalized\r\nby an $S_p$ subgroup of $G$ lie in ${\\mathbb Z}(G)$.\r\n\\begin{quote}\r\n\\emph{Proof:}  \r\nSee earlier.\r\n\\end{quote}\r\n", "meta": {"hexsha": "3383654f468b55394f8602ce55df1b8300142207", "size": 55455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "groups/gtStability.tex", "max_stars_repo_name": "jlmucb/class_notes", "max_stars_repo_head_hexsha": "b8571df2dca933f6594a16eb02b581d38ca4ccfd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "groups/gtStability.tex", "max_issues_repo_name": "jlmucb/class_notes", "max_issues_repo_head_hexsha": "b8571df2dca933f6594a16eb02b581d38ca4ccfd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "groups/gtStability.tex", "max_forks_repo_name": "jlmucb/class_notes", "max_forks_repo_head_hexsha": "b8571df2dca933f6594a16eb02b581d38ca4ccfd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.4746503497, "max_line_length": 146, "alphanum_fraction": 0.5757821657, "num_tokens": 23429, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4424355832412211}}
{"text": "%%!TEX TS-program = latex\n\\documentclass[11pt]{article} %DIF > \n\\usepackage{etex}\n\\usepackage[utf8]{inputenc}\n\\input ../AuxFiles/PreambleNotes.tex\n\n\n\\begin{document}\n\\onehalfspace\n\n\\vspace*{\\fill}\n\\begingroup\n\\centering\n\n\\Large {\\scshape Introduction to Statistics}\\\\\n\n(Lectures 9-10: Testing)\n\n\\endgroup\n\\vspace*{\\fill}\n\n\\newpage\n\n\n\\section{Testing}\n\n{\\scshape Overview:} \\noindent Lectures 9-10 will focus on \\emph{testing}. The parameter space in the testing game is partitioned into two subsets: the ``null’’ hypothesis $\\Theta_0$ and the ``alternative’’ hypothesis $\\Theta_1$. There are two actions $\\{0,1\\}$, where action $a=1$ is interpreted as ``reject the null in favor of the alternative’’  and action $a=0$ is its negation. The loss function used for this problem is the ``0-1 loss’’: $\\mathcal{L}(0,\\theta) = 0 =  L(1,\\theta’)$ for any $\\theta \\in \\Theta_0$, $\\theta’ \\in \\Theta_1$ and $\\mathcal{L}(a,\\theta)=1$ otherwise. This loss gives rise to the popular \\emph{Type I/Type II} error performance criterion. \n\nWe first study an idealized environment in which the parameter space has only two components: the null $(\\theta_0)$ and the alternative ($\\theta_1$). We show that in this set-up any reasonable test must maximize “power” subject to a “size” constraint. Moreover, we show that power maximizer tests reject whenever the “likelihood ratio” between the alternative and the null is large enough. \n\n\nWe then analyze some commonly used testing strategies for parametric models with “composite” null or alternative hypothesis: the Likelihood Ratio test, the Wald test, and the Score test. We specialize these trinity of tests to the linear regression model with unknown variance.  \n\n\n\n\\subsection{The Testing Problem} \n\nLet $X$ be a random variable and let $\\{f(x | \\theta)\\}_{\\theta \\in \\Theta}$ be a statistical model.\\footnote{Throughout this section, we will work with statistical models in which $f(x | \\theta)$ is a p.d.f.} Partition the parameter space into two subsets $\\Theta_0$ and $\\Theta_1$.\\footnote{By partition, we mean $\\Theta_0 \\cap \\Theta_1 = \\emptyset$ and $\\Theta_0 \\cup \\Theta_1 = \\Theta$.}The testing problem starts as follows. In the first stage nature selects a parameter $\\theta \\in \\Theta$. Since the null and the alternative hypothesis partition the parameter space, then either $\\theta \\in \\Theta_0$ or $\\theta \\in \\Theta_1$, but not both. \n\nAs usual, the econometrician cannot observe the parameter selected by nature but observes data. Based on the data, the statistician would like to decide whether the parameter selected by nature belongs to $\\Theta_0$ (the null) or to $\\Theta_1$ (the alternative). \n\nIn the simplest set-up, the statistician can take only two actions: $a \\in \\{0,1\\}$. If the econometrician picks $a=1$, he/she will be rejecting the null in favor of the alternative (and thus, saying that $\\theta \\in \\Theta_1$). If, however, $a=0$ we the econometrician does not reject the null (which we interpret as saying that $\\theta \\in \\Theta_0$).  \n\nA \\emph{decision rule/algorithm/strategy} for the statistician in the hypothesis testing problem is a mapping\n\\begin{equation*}\n\\phi:X \\rightarrow \\{0,1\\}\n\\end{equation*}\nThese decision rules are called ``tests’’. The collection of all data sets for which the econometrician rejects the null hypothesis \n$$\\{x \\: | \\: \\phi(x)=1\\} $$\n\\noindent is called the critical region of the test $\\phi$. \\\\\n\n\n\\subsection{0-1 Loss and Type I/Type II error}\n\nThe payoff/loss for the econometrician depends on the action taken (1 or 0) and the true state of the world ($\\theta$). The following $\\{0,1\\}$-loss structure is typical in testing problems:\n\\begin{equation*}\n\\left.\\begin{array}{ccc} a/s& \\theta \\in \\Theta_0 & \\theta \\in \\Theta_1 \\\\ 1 & 1 & 0 \\\\0 & 0 & 1\\end{array}\\right.\n\\end{equation*}\n\nThis is intended to model a payoff structure in which the econometrician is only punished when taking the ``wrong’’ decision. The punishments are symmetric, but it is easy to extend this framework. \n\nThe expected loss (risk) is computed as follows. When $\\theta \\in \\Theta_0$ the econometrician only experiences a loss if he/she (incorrectly) rejects the null hypothesis. Thus, the expected loss equals the probability of (incorrectly!) rejecting the null hypothesis ($\\phi(x)=1$) when the null hypothesis is true. For any $\\theta \\in \\Theta_0:$ \n\n\\begin{equation} \\label{equation:TypeI}\n\\mathbb{E}_{f(x|\\theta)} [  \\mathcal{L}(\\phi(x),\\theta)   ] = \\mathbb{E}_{f(x|\\theta)} [ \\mathbf{1}\\{\\phi(x)=1\\}   ] = P_{\\theta}(\\phi(x)=1) .\n\\end{equation}\n\n\n\\noindent This is referred to as the \\emph{rate of Type I error} of the test $\\phi(x)$ at $\\theta \\in \\Theta_0$. The \\emph{largest} rate of Type I error of a test; i.e., \n\n\\[ \\sup_{\\theta \\in \\Theta_0} P_{\\theta}(\\phi(x)=1)  \\]  \n\n\\noindent is called the \\emph{size} of the test.\n\n\n\nWhen $\\theta \\in \\Theta_1$ the econometrician only experiences a loss if he/she (incorrectly) fails to reject the null hypothesis. Thus, the expected loss equals the probability of (incorrectly!) failing to reject the null hypothesis ($\\phi(x)=0$) when the null hypothesis is not true. For any $\\theta \\in \\Theta_1$: \n\\begin{equation} \\label{equation:TypeII}\n\\mathbb{E}_{f(x|\\theta)} [  \\mathcal{L}(\\phi(x),\\theta)   ] = \\mathbb{E}_{f(x|\\theta)} [ \\mathbf{1}\\{\\phi(x)=0\\}   ] = P_{\\theta}(\\phi(x)=0) .\n\\end{equation}\n\n\\noindent This is the \\emph{rate of Type II error} of the test $\\phi(x)$ at $\\theta$. It is also common to make reference to the \\emph{power} of a test at $\\theta \\in \\Theta_1$. The power is defined as the probability of rejecting the null when it is not true; thus, it equals one minus the rate of Type II error; i.e., \n\n\\[ 1- P_{\\theta} (\\phi(x)=0) = P_{\\theta}(\\phi(x)=1). \\]\n\n\\subsection{Testing a ``simple’’ null against a ``simple’’ alternative}\n\nSuppose that both $\\Theta_0$ and $\\Theta_1$ are singletons, so that the testing problem becomes \n\\[ \\textbf{H}_0: \\theta=\\theta_0 \\textrm{ vs. }  \\textbf{H}_1: \\theta=\\theta_1. \\]\nIn this problem it is relatively straightforward to characterize the ``optimal’’ test. Define a randomized test as a map \n$$\\phi:X \\rightarrow [0,1]$$\n\\noindent where $\\phi(x)$ is interpreted as the probability of ``rejecting the null hypothesis’’ after observing $x$. See \\cite{Ferguson67}, p. 198, 199 (also, think about what we did in the last problem of problem set 3!). The rates of Type I/Type II error of a randomized test $\\phi$ are given by:\n\\[ R(\\phi,\\theta_0) = \\mathbb{E}_{f(x|\\theta_0)}[\\phi(x)], \\quad R(\\phi,\\theta_1) = 1-\\mathbb{E}_{f(x|\\theta_1)}[\\phi(x)]. \\]\n\nThe following proposition shows that under a mild assumption, any admissible test for this problem maximizes power subject to a ``size control’’ constraint. \n\n\\begin{proposition} Suppose that for any set $A \\subseteq \\mathbf{X}$\n$$\\int_{A} f(x,\\theta_0)dx > 0 \\implies \\int_{A} f(x,\\theta_1)dx > 0 .$$ \nA randomized test $\\phi$ is admissible if and only if there exists $\\alpha \\in [0,1]$ such that $\\phi$ maximizes power subject to having size at most $\\alpha$; that is\n\\begin{equation}\n\\phi \\in \\arg \\max_{\\phi} \\left( 1-R(\\phi, \\theta_1) \\right) \\label{equation:optimization}\n\\end{equation}\n\\noindent s.t.\n\\begin{equation}\nR(\\phi, \\theta_0) \\leq \\alpha \\label{equation:sizecontrol}\n\\end{equation}\n\\end{proposition}\n\\begin{proof}\n\\noindent ``$\\Rightarrow$'' First we show that if $\\phi$ is admissible, then $\\phi$ solves $(\\ref{equation:optimization})$ subject to  (\\ref{equation:sizecontrol}) for some $\\alpha$. We show that contrapositive. Let $\\alpha$ be the rate of Type I error of $\\phi$. Suppose $\\phi$ does not solve the constrained optimization problem for any such value of $\\alpha$. Then, there is another test $\\phi'$ (namely, the solution to the constrained optimization problem for $\\alpha = R(\\phi,\\theta_0)$) such that  $R(\\phi,\\theta_1) > R(\\phi',\\theta_1) $ and $R(\\phi,\\theta_0) \\geq R(\\phi',\\theta_0)$. Hence, $\\phi$ is not admissible. \\\\\n\n\\noindent ``$\\Leftarrow$'' We do the proof by contradiction. Suppose that $\\phi$ solves $(\\ref{equation:optimization})$ subject to  (\\ref{equation:sizecontrol}) for some $\\alpha$, but is not admissible. Then, there exists $\\phi'$ such that $R(\\phi,\\theta_1) \\geq R(\\phi',\\theta_1) $ and $R(\\phi,\\theta_0) \\geq R(\\phi',\\theta_0)$ with strict inequality somewhere. We have three cases to consider: \n\\begin{enumerate}\n\\item If $R(\\phi,\\theta_0)=R(\\phi', \\theta_0)$ and $R(\\phi,\\theta_1) > R(\\phi',\\theta_1)$. This contradicts the fact that $\\phi$ solved (\\ref{equation:optimization}) subject to  (\\ref{equation:sizecontrol}).\\\\\n\n\\item Suppose $1>\\alpha=R(\\phi,\\theta_0) > R(\\phi', \\theta_0)$ and $R(\\phi,\\theta_1) \\geq R(\\phi',\\theta_1)$. Consider the test $\\phi''$ that rejects for every value of $x$. Such test has Type I and II error given by $(1,0)$. Consider the test \n$$\\phi'''(x)= \\lambda \\phi''(x) + (1-\\lambda) \\phi'(x), \\quad \\lambda \\in [0,1] $$\n\\noindent This randomized test has Type I error $\\lambda + (1-\\lambda)R(\\phi', \\theta_0)$. Since $\\alpha \\in (R(\\phi',\\theta_0),1)$, there exists $\\lambda(\\alpha)>0$ such that:\n$$(R(\\phi''',\\theta_0), R(\\phi''',\\theta_1))= (\\alpha, (1-\\lambda(\\alpha))R(\\phi'(x),\\theta_1)).$$\n\\noindent This contradicts the fact that $\\phi$ solved (\\ref{equation:optimization}) subject to  (\\ref{equation:sizecontrol}).\n\n\\item Finally, suppose that $1=R(\\phi,\\theta_0)>R(\\phi',\\theta_0)$ and $R(\\phi,\\theta_1) \\geq R(\\phi',\\theta_1)$. We have already seen that the test\n$\\phi''$ which rejects for every value of $x$ has $R(\\phi'',\\theta_0)=1$ and $R(\\phi'',\\theta_1)=0$. Since $\\phi$ solves the minimisation problem for $\\alpha=1$, it must be the case that $R(\\phi,\\theta_1) \\leq R(\\phi'',\\theta_1) = 0$. Then, by assumption $0 \\leq R(\\phi',\\theta_1) \\leq R(\\phi,\\theta_1) \\leq 0$. Therefore, $R(\\phi',\\theta_1) = R(\\phi,\\theta_1) = 0$. Since $R(\\phi',\\theta_0)<1$, this implies\n\n\\begin{align*}\n\\int_{\\{x \\in \\textbf{X} | \\phi'(x)=0 \\}} f(x,\\theta_0) dx > 0\n\\end{align*}\nwhich implies\n\n\\begin{align*}\n\\int_{\\{x \\in \\textbf{X} | \\phi'(x)=0 \\}} f(x,\\theta_1) dx > 0\n\\end{align*}\nwhich implies $R(\\phi',\\theta_1)>0$. Contradiction.\n\n\\end{enumerate}\n\n\\end{proof}\n\n\nThe implication of this proposition is important: if you want to use an admissible test for the simple null against simple alternative then you have no choice but to maximize power subject to a size control constraint. The following proposition tells us how to solve this optimization problem: reject the null hypothesis if the likelihood of the data under the alternative is sufficiently higher than the likelihood under the null. \n\n\n\n\\begin{proposition} (The Neyman-Pearson Lemma) Consider the  hypothesis testing problem of a simple null $\\theta_0$ against a simple alternative $\\theta_1$. Define the \\emph{likelihood ratio statistic} as\n\\begin{equation*}\nL(x) \\equiv \\frac{f(x, \\theta_1)}{f(x, \\theta_0)}\n\\end{equation*}\nand suppose that for each $\\alpha \\in (0,1)$ there exists $c_{LR}(\\alpha)$ such that\n\\begin{equation*}\nP_{\\theta_0} (L(X)>c_{LR}(\\alpha))=\\alpha\n\\end{equation*}\nThen the test:\n\\begin{equation} \\label{equation:NPtest}\n\\phi(x)= 1_{L(x)>c_{LR}(\\alpha)}\n\\end{equation}\nsolves:\n\n\\begin{equation*}\n\\phi \\in \\arg \\max_{\\phi} (1-R(\\phi, \\theta_1) )\n\\end{equation*}\n\\noindent subject to \n$$R(\\phi,\\theta_0) \\leq \\alpha $$\n\n\\end{proposition}\n\n\\begin{proof}\nLet $\\phi(x)$ be defined as in (\\ref{equation:NPtest}). We would like to show the following: if $t(x)$ is another test of level $\\alpha$, then $P_{\\theta_1} (\\phi(x)=1) \\geq P_{\\theta_1} (t(x)=1) \\geq 0$. The prove proceed goes follows. By definition of $\\phi$\n\\begin{equation*}\n\\phi(x)=1 \\quad\\quad \\text{if}  \\quad f(x, \\theta_1) > c_{LR}(\\alpha) f(x, \\theta_0)\n \\end{equation*} \nSince $t(x) \\in [0,1]$ it follows that \n\\begin{equation*}\n\\phi(x) - t(x) \\geq 0 \\quad\\quad \\text{if}  \\quad f(x, \\theta_1) > c_{LR}(\\alpha) f(x, \\theta_0)\n \\end{equation*} \n and\n \\begin{equation*}\n\\phi(x) - t(x) \\leq 0 \\quad\\quad \\text{if}  \\quad f(x, \\theta_1) \\leq c_{LR}(\\alpha) f(x, \\theta_0)\n \\end{equation*} \n Therefore, the function:\n \\begin{equation*}\n\\left[ \\phi(x)-t(x) \\right] \\left[ f(x, \\theta_1) - c_{LR}(\\alpha) f(x, \\theta_0) \\right] \\geq 0\n \\end{equation*}\n Note then that, for all $x$\n \\begin{equation*}\n \\left[ \\phi(x)-t(x) \\right] f(x, \\theta_1) \\quad \\geq  \\quad \\left[ \\phi(x)-t(x) \\right] c_{LR}(\\alpha) f(x, \\theta_0) \n \\end{equation*}\n Therefore, integrating with respect to x:\n  \\begin{equation*}\n\\int_{\\mathbf{X}} \\left[ \\phi(x)-t(x) \\right] f(x, \\theta_1)dx \\quad \\geq  \\quad \\int_{\\mathbf{X}}\\left[ \\phi(x)-t(x) \\right] \\lambda f(x, \\theta_0) dx\n \\end{equation*}\n Note, that the right hand side of the previous equation is exactly the same as the difference in levels (scaled by $\\lambda$) of the tests $\\phi$ and $t$. Since the Neyman-Pearson test has level $\\alpha$ and any other competing test has level at most $\\alpha$, then the right-hand side is larger than or equal to zero.  Re-arranging the expression we get:\n \\begin{equation*}\n \\int_{\\mathbf{X}} \\phi(x) f(x, \\theta_1) \\geq  \\int_{\\mathbf{X}} t(x) f(x, \\theta_1)\n \\end{equation*}\n And this completes the proof (make sure you understand why these integrals equal the power of the tests)\n\\end{proof}\n\n\\subsection{Testing hypotheses in Parametric Models}\n\n\\subsubsection{Generalized Likelihood Ratio Test}\n\nWe have just shown that the test that rejects the null hypothesis whenever the likelihood under the alternative is (sufficiently) larger than the likelihood under the null cannot be dominated. To establish this result we assumed that both the null and the alternative were ``simple’’. Unfortunately, most problems we will encounter in econometric practice involve ``composite’’ hypotheses.  \\\\\n\n\\noindent {\\scshape Example:} Consider the linear regression model with non-stochastic regressors:\n\\begin{equation}\nY \\sim \\mathcal{N}_n(X \\beta, \\sigma^2 \\mathbb{I}_n ).\n\\end{equation}\nAssume (as we did in the last problem set) that both $\\beta \\in \\mathbb{R}^{k}$ and $\\sigma^2 \\in \\mathbb{R}_{+}$ are unknown. Suppose that we are interested in the problem\n\n\\begin{equation}\\label{equation:Hypothesis}\n\\textbf{H}_0: \\beta=\\beta_0 \\textrm{ vs. }  \\textbf{H}_1: \\beta \\neq \\beta_0. \n\\end{equation}\n\n\\noindent Both the null and the alternative  are composite. To see this, write\n\\[ \\Theta_0 \\equiv \\{ (\\beta, \\sigma^2) \\: | \\: \\beta = \\beta_0 \\}, \\quad \\Theta_1 \\equiv \\{ (\\beta, \\sigma^2) \\: | \\: \\beta \\neq \\beta_0 \\}.\\]\n\n\\noindent The value of $\\sigma^2$ is not specified under the null hypothesis, hence any tuple $(\\beta_0, \\sigma^2)$ is plausible under the null. Parameters that are not specified under the null hypothesis are usually called \\emph{nuisance} parameters.\n\nThe \\emph{generalized likelihood ratio} statistic provides a general approach for testing hypothesis in parametric models with composite null and alternative hypotheses. The test rejects $\\Theta_0$ in favor of the alternative whenever the \\emph{likelihood ratio statistic}\n\n\\begin{equation}\n2\\Big [  \\max_{\\theta \\in \\Theta_1} \\ln f(x | \\theta) - \\max_{\\theta \\in \\Theta_0} \\ln f(x | \\theta) \\Big ]\n\\end{equation}\nis large enough. The first term denotes the largest value that the ``log-likelihood’’ can achieve under the alternative, and the second term denotes the largest value that the log-likelihood can achieve under the null. Let $\\widehat{\\theta}_1$ and $\\widehat{\\theta}_0$ denote the values of the parameter that maximize the likelihood under the alternative and the null, respectively. The generalized likelihood ratio test thus rejects whenever\n\\[ 2 \\ln \\left(  f(x | \\widehat{\\theta}_1) / f(x, \\widehat{\\theta_0}) \\right) \\]\nis large enough. \\\\\n\n\\noindent {\\scshape Likelihood Ratio Test for the Linear Regression Model:} We now compute the generalized likelihood ratio statistic for the testing problem (\\ref{equation:Hypothesis}) in the linear regression model. First, we maximize the likelihood under the alternative hypothesis $\\beta \\neq \\beta_0$. This is the same as just maximizing the likelihood over the whole parameter space\n\n\\[  \\max_{\\beta, \\sigma^2} f(Y | \\beta , \\sigma^2). \\] \n\n\\noindent We solved in the previous problem set and we showed that:\n\n\\[ \\widehat{\\beta}_{\\textrm{ML}} = (X’X)^{-1}X’Y, \\quad \\widehat{\\sigma}^2_{\\textrm{ML}} = (Y-X\\widehat{\\beta}_{\\textrm{ML}})’(Y-X\\widehat{\\beta}_{\\textrm{ML}})/n. \\] \n\n\\noindent Thus, we can verify that the largest value of the log-likelihood under the alternative is\n\\[ \\log f(Y | \\widehat{\\beta}_{\\textrm{ML}}, \\widehat{\\sigma}^2_{\\textrm{ML}}) = - \\frac{n}{2} \\log(2 \\pi ) - \\frac{n}{2} \\log( \\widehat{\\sigma}^2_{\\textrm{ML}}) - \\frac{n}{2}. \\]\n\n\\noindent We now turn to the problem of maximizing the log-likelihood under the null hypothesis:\n\\[ \\max_{\\sigma^2} f(Y | \\beta_0 , \\sigma^2). \\]\nAlgebra shows that the maximizer is\n\n\\[\\widehat{\\sigma}^2_{0} = (Y-X\\beta_0)’(Y-X \\beta_0)/n,\\]\n\n\\noindent and the maximized value of the log-likelihood under the alternative corresponds to\n\n\\[ \\log f(Y | \\widehat{\\beta}_{0}, \\widehat{\\sigma}^2_{0}) = - \\frac{n}{2} \\log(2 \\pi ) - \\frac{n}{2} \\log( \\widehat{\\sigma}^2_{0}) - \\frac{n}{2}. \\]\n\\noindent This means that the likelihood ratio test statistic equals\n\n\\begin{equation} \\label{equation:GLR}\nn  \\left( \\ln ( \\widehat{\\sigma}^2_{0} ) -\\ln( \\widehat{\\sigma}^2_{\\textrm{ML}} ) \\right). \n\\end{equation}\n\nThe \\emph{critical value}---the threshold against which the likelihood ratio statistic is compared against---is usually taken as the $1-\\alpha$ quantile of $\\chi^2$ distribution with degrees of freedom given by the dimension of $\\beta_0$. We now explain this approximation for the linear regression model and then present an heuristic derivation of the more general approximation result. \n\nAlgebra shows that we can write the likelihood ratio test statistic above as\n\n\\[n  \\left( \\ln \\left(  (\\widehat{\\sigma}^2_{0} - \\widehat{\\sigma}^2_{\\textrm{ML}})/\\widehat{\\sigma}^2_{\\textrm{ML}} +1  \\right) \\right). \\]\n\n\\noindent Under the null hypothesis we expect $\\widehat{\\sigma}^2_0$ and $\\widehat{\\sigma}^2_{\\textrm{ML}}$ not to be very different. Since a standard first-order Taylor appproximation suggests that $\\ln(1+x) \\approx x$ when $x$ is small, the likelihood ratio test statistic is expected to be approximately equal to \n\n\\[ n(\\widehat{\\sigma}^2_{0} - \\widehat{\\sigma}^2_{\\textrm{ML}})/\\widehat{\\sigma}^2_{\\textrm{ML}}.\\]\n\n\\noindent Interestingly, in the linear regression model \n\n\\[n(\\widehat{\\sigma}^2_{0} - \\widehat{\\sigma}^2_{\\textrm{ML}}) = (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 ) (X’X)  (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 )  = \\sigma^2 \\frac{1}{\\sigma^2} (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 ) (X’X)  (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 ).  \\]\n\n\\noindent Moreover, if the null hypothesis is true\n\n\\[(\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 ) = (X’X)^{-1} X’(Y - X \\beta_0) \\sim \\mathcal{N}_k(0, \\sigma^2 (X’X)^{-1}),\\]\n\n\\noindent implying \n\n\\[\\frac{1}{\\sigma^2} (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 )’ (X’X)  (\\widehat{\\beta}_{\\textrm{ML}} - \\beta_0 ) \\]\n\n\\noindent has the distribution of a $\\chi^2$ random variable with $k$ degrees of freedom. If we further assume that when the sample size is large $\\sigma^2 / \\widehat{\\sigma}^2_{\\textrm{ML}}=1$, with probability close to one then:\n\n\\[ n(\\widehat{\\sigma}^2_{0} - \\widehat{\\sigma}^2_{\\textrm{ML}})/\\widehat{\\sigma}^2_{\\textrm{ML}} \\approx \\chi^2_{k}.\\]\n\n\\subsubsection{The Wald Test}\n\nThe approximation result above is more general. Consider the problem\n\\[\\textbf{H}_0: \\theta=\\theta_0 \\textrm{ vs. }  \\textbf{H}_1: \\theta \\neq \\theta_0. \\]\n\n\\noindent The maximized log-likelihood ratio under the alternative is\n\n\\[ \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}}).\\]\n\n\\noindent Under the null, $\\widehat{\\theta}_{\\textrm{ML}}$ should be close to $\\theta_0$. Thus, an heuristic first-order Taylor approximation of $\\ln f(x|\\theta_0)$ around $\\widehat{\\theta}_{\\textrm{ML}}$ suggests that\n\n\\begin{eqnarray*}\n \\ln f(x| \\theta_0) &\\approx& \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}}) + \\left( \\frac{\\partial}{\\partial \\theta} \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}})\\right )’ (\\theta_0-\\widehat{\\theta}_{\\textrm{ML}}) \\\\\n&+& \\frac{1}{2} (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0)’  \\left( \\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}})\\right ) (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0). \n\\end{eqnarray*}\n\n\\noindent The term\n\n\\[ \\left( \\frac{\\partial}{\\partial \\theta} \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}})\\right ) \\] \n\n\\noindent is the score (the derivative of the log-likelihood) evaluated at $\\widehat{\\theta}_{\\textrm{ML}}$. The F.O.C. defining $\\widehat{\\theta}_{\\textrm{ML}}$ imply this term equals zero. Therefore, the likelihood ratio statistic is approximately equal to\n\\[2(\\ln f( x | \\widehat{\\theta}_{\\textrm{ML}}) - \\ln f(x| \\theta_0)) \\approx (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0)’  \\underbrace{\\left( -\\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f( x | \\widehat{\\theta}_{\\textrm{ML}})\\right )}_{\\widehat{\\mathcal{I}}: \\textrm{ Observed Information Matrix}}  (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0).    \\]\n\n\\noindent The last term in the equation above is called the Wald test statistic for the null hypothesis $\\theta = \\theta_0$. Asymptotic theory (which you will cover in the next block of the course) will show that under very general conditions \n\n\\[ \\widehat{\\mathcal{I}}^{1/2}(\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0) \\sim \\mathcal{N}_{\\textrm{dim}(\\theta)} (0, \\mathbb{I}_{\\textrm{dim}(\\theta)}).\\]\n\n\\noindent Therefore, the Wald test statistic has approximately the same distribution as a $\\chi^2$ random variable with $\\textrm{dim}(\\theta)$ degrees of freedom. This means that if we let $\\chi^2_{\\textrm{dim}(\\theta),1-\\alpha}$ denote the $1-\\alpha$ quantile of a $\\chi^2_{\\textrm{dim}(\\theta)}$ random variable then the test that rejects whenever\n\n\\[  (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0)’  \\widehat{\\mathcal{I}} (\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0) > \\chi^2_{\\textrm{dim}(\\theta),1-\\alpha} \\]\nwill have size of approximately $1-\\alpha$. Moreover, the outcome of this Wald test will be approximately the same as that of the Likelihood Ratio Test. \\\\\n\n\\noindent {\\scshape Wald Test for the Linear Regression Model:} We derive the Wald test for the problem\n\\[ \\textbf{H}_0: \\beta=\\beta_0 \\textrm{ vs. }  \\textbf{H}_1: \\beta \\neq \\beta_0,\\]\nusing the Linear Regression Model with unknown variance. Note that $\\sigma^2$ is a nuisance parameter, as it is not specified under the null hypothesis. To construct the Wald test statistic we will need to replace $\\sigma^2$ by its ML estimator.  \n\nWe showed in the previous problem set that the score is given by\n\\[\\begin{pmatrix}\n\\frac{1}{\\sigma^2}X’(Y-X\\beta) \\\\\n-\\frac{n}{2} \\frac{1}{\\sigma^2} + \\frac{1}{\\sigma^4} (Y-X\\beta)’(Y-X\\beta)\n \\end{pmatrix}.\\]\n The upper $k \\times k$ block of the sample information matrix is then given by the matrix\n \n \\[  \\frac{1}{\\sigma^2} X’X, \\]\n \n\\noindent which does not depend on $\\beta$, but depends $\\sigma^2$. The Wald statistic is thus\n\\[  \\frac{1}{\\widehat{\\sigma}^2_{\\textrm{ML}}} (\\widehat{\\beta} - \\beta_0)’(X’X)(\\widehat{\\beta} - \\beta_0).   \\]\n \n\n\n\\subsubsection{The Score Test} \nFinally, we introduce the score test. Once again, consider the problem\n\\[\\textbf{H}_0: \\theta=\\theta_0 \\textrm{ vs. }  \\textbf{H}_1: \\theta \\neq \\theta_0. \\]\nIn any parametric model, the ML estimator satisfies the first order condition\n\\[ \\frac{\\partial}{\\partial \\theta} \\ln f(x | \\widehat{\\theta}_{\\textrm{ML}})  = 0. \\]\nAn heuristic first-order Taylor approximation thus suggests\n\\[  \\underbrace{\\frac{\\partial}{\\partial \\theta} \\ln f(x | \\theta_0)}_{S(x; \\theta_0): \\textrm{ Score at $\\theta_0$} } \\approx \\underbrace{\\frac{\\partial}{\\partial \\theta} \\ln f(x | \\widehat{\\theta}_{\\textrm{ML}})}_{S(x; \\theta_0): \\textrm{ F.O.C.} } \\quad + \\underbrace{-\\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f(x | \\theta_0)}_{\\widehat{I}: \\textrm{ observed information} } \\left( \\widehat{\\theta}_{\\textrm{ML}} - \\theta_0 \\right), \\]\nimplying\n\n\\[ \\left( -\\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f(x | \\theta_0) \\right)^{1/2} \\left( \\widehat{\\theta}_{\\textrm{ML}} - \\theta_0 \\right)  \\approx  \\left( -\\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f(x | \\theta_0) \\right)^{-1/2} S(x; \\theta_0).  \\]\n\n\\noindent If it is true that $\\widehat{\\mathcal{I}}^{1/2}(\\widehat{\\theta}_{\\textrm{ML}}-\\theta_0) \\sim \\mathcal{N}_{\\textrm{dim}(\\theta)} (0, \\mathbb{I}_{\\textrm{dim}(\\theta)})$ (an approximation we have used to motivate the Wald Test and to derive the critical value for the Likelihood Ratio Test) then we must have\n\n\\[  S(x; \\theta_0)’ \\left( -\\frac{\\partial^2}{\\partial \\theta \\partial \\theta} \\ln f(x | \\theta_0) \\right)^{-1} S(x; \\theta_0) \\approx \\chi^2_{\\textrm{dim}(\\theta)} \\]\n\n\\noindent The score test (with nominal size $\\alpha$) rejects if the \\emph{score test statistic above} is larger than the $1-\\alpha$ quantile of a $\\chi^2_{\\textrm{dim}(\\theta)}$. Note that the score does not require computing the ML estimator, only the F.O.C. \n\n\\newpage\n\n\n\\bibliographystyle{../AuxFiles/ecta}\n\\bibliography{../AuxFiles/BibMaster}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "c2c938d9d73c8e31a69fa23ada06fc155bd4b8be", "size": 25087, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Lectures/Lectures09-10.tex", "max_stars_repo_name": "snowdj/Courses-IntroEconometrics-Ph.D", "max_stars_repo_head_hexsha": "4529b2ff1f38567c9aef15a52cde9de946413686", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/Lectures/Lectures09-10.tex", "max_issues_repo_name": "snowdj/Courses-IntroEconometrics-Ph.D", "max_issues_repo_head_hexsha": "4529b2ff1f38567c9aef15a52cde9de946413686", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/Lectures/Lectures09-10.tex", "max_forks_repo_name": "snowdj/Courses-IntroEconometrics-Ph.D", "max_forks_repo_head_hexsha": "4529b2ff1f38567c9aef15a52cde9de946413686", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.6676056338, "max_line_length": 670, "alphanum_fraction": 0.6984892574, "num_tokens": 8123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.44243374814337677}}
{"text": "\\subsection{Cost model: compression estimators}\n\\label{sub:estimators}\n\n% ----------------------- paths to graphics ------------------------\n\n\n\n% ----------------------- contents from here ------------------------\n% \n\nThe compression learning process is an optimization problem (\\ref{subsec:learningprocess:optimizationproblem}) for finding the best compression tree in terms of disk size of the resulting physical columns. Solving the optimization problem requires a way to compare its solutions, i.e. estimating the final size of the compressed data. For this purpose we created a cost model which relies on leaf compression schemes size estimators (DICT, RLE, FOR, no compression) to predict the size of a column if compressed with these methods.\n\n\\textbf{Methodology}. The score of a solution (compression tree) is computed through the following methodology: 1) represent the sample data according to the compression nodes; 2) for each column of the new representation, estimate its size if it were compressed with: DICT, RLE, FOR or not compressed at all; 3) choose the smallest size among those. The result of this process is the smallest size of the new data representation if it were compressed with leaf compression schemes.\n\n\\textbf{System assumptions}. The size on disk of a compressed column depends on: 1) implementation of the compression method; 2) characteristics of the underlying database system. The former is described in the next sections as part of the estimator implementations. For the latter we defined some assumptions of the underlying system as follows:\\\\\na) \\textit{data types}: strings are stored with null terminator, therefore their size is given by the number of characters + 1. For all other data types we consider the sizes used by Ingres Vectorwise \\cite{zukowski2012vectorwise,actianingres}. \\\\\nb) \\textit{null handling}: we consider the same approach  used by Vectorwise \\cite{zukowski2012vectorwise}: do not store null values, instead, keep track of their positions using a bitmap. This results in 1 additional bit for every attribute (for nullable columns).\\\\\nc) \\textit{exception handling}: we consider a whitebox approach: for each logical column store exceptions on a separate physical nullable column. The exception column has the same datatype as the logical column.\n\nAn additional assumption that we make about the underlying system is that it supports block-level compression, i.e. every block of data is compressed independently. This allows different compression schemes to be used on the same column, enabling the possibility to exploit local data characteristics.\n\n\\subsubsection{Generic compression estimator}\n\\label{subsub:estimator:generic}\nA compression estimator takes as input a column and two samples of data (\\textit{train} and \\textit{test} sample) and outputs the estimated size of the compressed column. The result can be either the size of the compressed sample or the size extrapolated to the total size of the block or column. The latter requires an additional parameter specifying the total number of rows in the full data.\n\nThe estimated size has 4 components (exemplified for Dictionary encoding):\\\\\n1) \\(size_{metadata}\\): size of the metadata (the dictionary itself)\\\\\n2) \\(size_{data}\\): size of the compressed data (the dictionary ids)\\\\\n3) \\(size_{ex}\\): size of the exceptions  (the values that are not in the dictionary)\\\\\n4) \\(size_{null}\\): size required to keep track of the null values. Since exceptions are stored on a separate nullable column, the \\textit{nulls} size is implicitly increased.\n\nThe final estimated size of the test sample is the sum of the 4 components:\n\\begin{equation}\n\\label{eq:estimators:sizesample}\nsize_{sample} = size_{metadata} + size_{data} + size_{ex} + size_{null}\n\\end{equation}\n\nThis result gives the size of the \\textit{test} sample only. It can be extrapolated to the full size of the block or entire column as follows:\n\\begin{equation}\n\\label{eq:estimators:sizefinal}\nsize_{full} = size_{sample} \\times \\frac{count_{full}}{count_{sample}}\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(count_{sample}\\) = total number of values in the test sample\n    \\item[] \\(count_{full}\\) = total number of values in the full block or column\n\\end{itemize}\n\nThe size estimation process works in two phases:\\\\\n1) \\textit{training}: the estimator analyzes the \\textit{train} sample and generates the metadata needed for compression (e.g. \\nameref{subsub:estimator:dict} generates the dictionary, \\nameref{subsub:estimator:for} determines the reference value and the number of bits needed to store the differences).\\\\\n2) \\textit{testing}: the estimator simulates the compression of the \\textit{test} sample using the metadata resulted from the \\emph{training} phase and outputs an estimated size.\n\nThe two-phase estimation process is used to avoid overly-optimistic results: metadata generated based on the \\emph{train} sample is perfectly optimized for that sample (e.g. in FOR all differences will fit in the number of bits chosen to represent them). Depending on the implementation of each compression estimator, this would lead to a reduced number of exceptions or even no exceptions at all. Therefore, the \\textit{test} sample is used to provide new data for size estimation. It produces exceptions and more realistic results. This approach simulates the compression process of real database systems, where the compression metadata is created based on a sample and then applied on a full block of data or even on the entire column.\n\nThe next sections describes 4 compression estimators used in the learning process. All computed sizes will be in bytes.\n\n\n% ------- no compression ------- % \n\n\\subsubsection{No compression estimator}\n\\label{subsub:estimator:nocompression}\n\nThe \\nameref{subsub:estimator:nocompression} predicts the size of the input column stored without compression. The \\textit{training} phase is not relevant since it does not generate any compression metadata. The estimation is performed in the \\textit{testing} phase, based on the size on disk of the column data type. The size components are computed as follows:\n\n\\(size_{metadata}\\) is 0, since there is no compression metadata\n\n\\(size_{ex}\\) is 0, since there are no exceptions\n\n\\(size_{null}\\) is 1 bit for every value in the sample: \n\\begin{equation}\n\\label{eq:estimators:nocompression:sizenull}\nsize_{null} = \\frac{count_{sample}}{8}\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(count_{sample}\\) = total number of values in the test sample\n\\end{itemize}\n\n\\(size_{data}\\) is given by the total size of the non-null values in the sample. It depends on the data type of the column as follows:\n\\begin{equation}\n\\label{eq:estimators:nocompression:sizedata}\nsize_{data} = \n\\left\\{\n\\begin{array}{ll}\n    \\sum_{v \\neq \\mathit{null}} \\mathit{len}(v) + 1 & \\mbox{if } \\mathit{datatype} = \\verb|VARCHAR|\\\\\n    count_{notnull} \\times size_{datatype} & \\mbox{else}\n\\end{array}\n\\right.\n% \\frac{count_{sample}}{8}\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(count_{notnull}\\) = total number of non-null values in the test sample\n    \\item[] \\(size_{datatype}\\) = size on disk of the column data type\n\\end{itemize}\n\n\n% ------- dictionary ------- % \n\n\\subsubsection{Dictionary estimator}\n\\label{subsub:estimator:dict}\n\nThe \\nameref{subsub:estimator:dict} predicts the size of the input column as compressed with Dictionary encoding. Besides the two samples, it receives an additional parameter: \\(size_{max}\\)---maximum size of the dictionary (in bytes). It only applies to \\verb|VARCHAR| columns and therefore the exception column will also be \\verb|VARCHAR|.\n\nThe \\nameref{subsub:estimator:dict} is similar to the \\nameref{subsec:pd:dict} pattern detector defined in \\ref{subsec:pd:dict}. It builds the dictionary and handles exceptions in the same way. Optimizing the dictionary based on a maximum size (in bytes) also works for the estimator, since we use it to compare different ways of compressing a column and the dominant factor here is the nature of the data, not the optimization of the compression scheme. \n\n% Dictionary encoding only produces good results on columns that have a small number of unique values. However, it is hard to reliably quantify this property when analyzing only a sample of the data. Moreover, the distribution of unique values may be skewed, with only a few values with high frequency and a long tail of low frequency values. For the purpose of our estimator, we addressed this issue by enforcing a maximum dictionary size and only keeping the most common values in the dictionary. This approach is also suitable if blocks of data are compressed independently: dictionaries need to be small as they are assigned per block. There are other (possibly better) ways of optimizing the dictionary values and size. However, they are out of the scope of our estimator, since we use it to compare different ways of compressing a column and the dominant factor here is the nature of the data, not the optimization of the compression scheme.\n\n\\textbf{Training phase.} The dictionary (metadata) is built during the \\textit{training} in same way it is done for the \\nameref{subsec:pd:dict} pattern detector (\\ref{subsec:pd:dict}): Step-1: create the histogram of all the values in the \\textit{train} sample. Step-2: select as many values from the histogram in decreasing order of their number of occurrences such that their total size is lower or equal to the maximum size of the dictionary (\\(size_{max}\\)). The dictionary is stored as an array containing the selected values. The indices in the array represent the dictionary ids used to encode the values.\n\n\\(size_{metadata}\\) is given by the total size of the values in the dictionary. Additionally, the number of bits required to store a dictionary id is computed as follows:\n\\begin{equation}\n\\label{eq:estimators:dict:bitsid}\nbits_{id} = \\lceil \\log_2 (count_{entries}) \\rceil\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(count_{entries}\\) = number of values in the dictionary\n\\end{itemize}\n\n\\textbf{Testing phase}. The \\textit{testing} phase estimates the size of the compressed column by going through each value in the \\textit{test} sample and checking if it is present in the dictionary. The following variables are updated in this process: 1) \\(count_{valid}\\): number of values that are found in the dictionary; 2) \\(size_{ex}\\): size of the exceptions (values that are not found in the dictionary).\n\n\\(size_{data}\\) is computed as follows:\n\\begin{equation}\n\\label{eq:estimators:dict:sizedata}\nsize_{data} = \\frac{count_{valid} \\times bits_{id}}{8}\n\\end{equation}\n\n\\(size_{ex}\\) is computed by summing the size of all exceptions.\n\n\\(size_{null}\\) is determined by the number of resulting physical columns: one for compressed data (dictionary ids) and one for exceptions:\n\\begin{equation}\n\\label{eq:estimators:dict:sizenull}\nsize_{null} = \\frac{2 \\times count_{sample}}{8}\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(count_{sample}\\) = total number of values in the test sample\n\\end{itemize}\n\n\n% ------- run length encoding ------- % \n\n\\subsubsection{Run Length Encoding estimator}\n\\label{subsub:estimator:rle}\n\nThe \\nameref{subsub:estimator:rle} predicts the size of the input column as compressed with RLE. The samples are constructed with consecutive ranges of values such that RLE is triggered (see \\ref{subsec:eval:methodology:sampling}~\\nameref{subsec:eval:methodology:sampling} for more details). Even though RLE can be applied to any data type, we limited the scope of our estimator to numeric columns. The other data types are either compressed with Dictionary encoding (\\verb|VARCHAR|) or are very rare in the Public BI benchmark and do not present compression opportunities. We use the following terminology:\\\\\n1) \\textit{run} value = a data value that is repeated on consecutive rows.\\\\\n2) \\textit{length} value = the number of consecutive occurrences of a \\textit{run} value\n\n\\textbf{Training phase.} RLE metadata is composed of: 1) the number of bits needed to represent the \\textit{run} values (\\(bits_{run}\\)) and 2) the number of bits needed to represent the \\textit{length} values (\\(bits_{length}\\)). These values are determined by scanning the \\textit{train} sample and computing all the \\textit{runs} and \\textit{lengths}. \\(bits_{run}\\) is given by the \\textit{run} value of maximum size and \\(bits_{length}\\) is given by the maximum \\textit{length}. \\(bits_{run}\\) also depends on the column data type representation.\n\n\\(size_{metadata}\\) is between 8 and 24 bytes---the size of 2 numbers: \\(bits_{run}\\) and \\(bits_{length}\\)---depending on the data types used to store them.\n\n\\textbf{Testing phase.} The \\textit{testing} phase scans all the values in the \\textit{test} sample and creates (\\textit{run}, \\textit{length}) pairs as follows: 1) if a \\textit{run} value cannot be represented on \\(bits_{run}\\) bits: mark it as exception and skip it; 2) if a \\textit{length} exceeds the maximum value that can be represented on \\(bits_{length}\\) bits: end the current run at this length and start a new run. The following variables are updated in this process: 1) \\(count_{valid}\\): the number of (\\textit{run}, \\textit{length}) pairs resulted from the scanning process; 2) \\(count_{ex}\\): the number of exceptions as defined above.\n\n\\(size_{data}\\) and \\(size_{ex}\\) are computed as follows:\n\\begin{equation}\n\\label{eq:estimators:rle:sizedata}\nsize_{data} = \\frac{count_{valid} \\times (bits_{run} + bits_{length})}{8}\n\\end{equation}\n\\begin{equation}\n\\label{eq:estimators:rle:sizeex}\nsize_{ex} = count_{ex} \\times size_{datatype}\n\\end{equation}\nwhere:\n\\begin{itemize}\n    \\item[] \\(size_{datatype}\\) = size on disk of the column data type\n\\end{itemize}\n\n\\(size_{null}\\) depends on the number of physical columns---one compressed data column (\\textit{run} and \\textit{length} are stored together) and one exception column---the same as in the case of \\nameref{subsub:estimator:dict} (Equation \\ref{eq:estimators:dict:sizenull}).\n\n\n% ------- frame of reference ------- % \n\n\\subsubsection{Frame of Reference estimator}\n\\label{subsub:estimator:for}\n\nThe \\nameref{subsub:estimator:for} predicts the size of the input column as compressed with FOR. It only applies to numeric columns.\n\n\\textbf{Training phase.} FOR metadata is composed of: 1) the \\textit{reference} value and 2) the number of bits needed to store the differences (\\(bits_{\\mathit{diff}}\\)). In our implementation we chose the \\textit{reference} to be the smallest value in the \\textit{train} sample. \\(bits_{\\mathit{diff}}\\) is given by the maximum difference size, which depends on the data type representation.\n\n\\(size_{metadata}\\) is between 8 and 24 bytes---the size of the reference and the size of \\(bits_{\\mathit{diff}}\\)---depending on the data types used to store them.\n\n\\textbf{Testing phase.} The testing phase computes all the differences between the values in the \\textit{test} sample and the \\textit{reference} and filters the ones that can be represented on \\(bits_{\\mathit{diff}}\\) bits. The following variables are updated in this process: 1) \\(count_{valid}\\): the number of differences that fit in \\(bits_{\\mathit{diff}}\\); 2) \\(count_{ex}\\): the number of exceptions (values that give differences larger than \\(bits_{\\mathit{diff}}\\)).\n\n\\(size_{data}\\) is computed as follows:\n\\begin{equation}\n\\label{eq:estimators:for:sizedata}\nsize_{data} = \\frac{count_{valid} \\times bits_{\\mathit{diff}}}{8}\n\\end{equation}\n\n\\(size_{ex}\\) is the same as in the case of \\nameref{subsub:estimator:rle} (Equation \\ref{eq:estimators:rle:sizeex}).\n\n\\(size_{null}\\) depends on the number of physical columns---one compressed data column (differences) and one exception column---the same as in the case of \\nameref{subsub:estimator:rle} and \\nameref{subsub:estimator:dict} (Equation \\ref{eq:estimators:dict:sizenull}).\n\n% ---------------------------------------------------------------------------\n% ----------------------- end of thesis sub-document ------------------------\n% ---------------------------------------------------------------------------", "meta": {"hexsha": "1885b0cf035fd6393fafefe7e06e92bd509723d7", "size": 16113, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/5_automatic_learning/learning_process/compression_estimators.tex", "max_stars_repo_name": "bogdanghita/master-thesis", "max_stars_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-16T08:58:07.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-16T08:58:07.000Z", "max_issues_repo_path": "src/5_automatic_learning/learning_process/compression_estimators.tex", "max_issues_repo_name": "bogdanghita/master-thesis", "max_issues_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/5_automatic_learning/learning_process/compression_estimators.tex", "max_forks_repo_name": "bogdanghita/master-thesis", "max_forks_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 80.9698492462, "max_line_length": 947, "alphanum_fraction": 0.7526221064, "num_tokens": 3946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4424337412119467}}
{"text": "\\documentclass{article}\n\t\\title{Cardano's Formula for Cubic Equations}\n\\author{Matthew Osamor}\n\\date{November 20, 2021}\n\\usepackage{amsmath}\n\\begin{document}\n\t\\maketitle\n\t\\begin{center}\n\n\\begin{center}\t\n\t\tAbstract\n\t\t\\end{center}\n\t\\begin{center}  \n\t\t\n\t  Gerolamo Cardano was born in Pavia in 1501 as the illegitimate child of a jurist. He attended the University of Padua and became a physician in the town of Sacco, after being rejected by his home town of Milan. He became one of the most famous doctors in all of Europe, having treated the Pope. He was also an astrologer and an avid gambler, to which he wrote the Book of Chance, which was the first serious treatise on the mathematics of probability [1].\n\t\\end{center}\n\t\\end{center}\n\\section{Introduction to Cardano's Formula}\nCardano's formula for solution of cubic equations for an equation like;\\\\\n$x^3$ + $a_{1}x^2$ + $a_{2}x$ + $a_{3}$ = 0\\\\\nthe parameters Q, R, S and T can be computed thus,\\\\\n\\\\\nQ=$\\dfrac{3a_{2}-a_{1}^2}{a}$\\\\\n \\\\\nR=$\\dfrac{{9a_1a_2-27a_3-2a^3_1}}{54}$\\\\\n\\\\\nS=$3\\sqrt{R+\\sqrt{-Q^3+R^2}}$\\\\\n\\\\\nT=$\\sqrt{R-\\sqrt{Q^3+R^2}}$\\\\\n\\\\\nto give the roots;\\\\\n$x_{1}=S+T-\\dfrac{1}{3}a_{1}$\\\\\n\\\\\n$x_{2}=\\dfrac{-(S+T)}{2}-\\dfrac{a_1}{3}+i\\dfrac{\\sqrt{3}(s-T)}{2}$\\\\\n\\\\\n$x_{2}=\\dfrac{-(S+T)}{2}-\\dfrac{a_1}{3}-i\\dfrac{\\sqrt{3}(s-T)}{2}$\\\\\n\\\\\nNote:$x^3$ must not have a coefficient.\\\\\n\\subsection{Some Examples}\n\\begin{itemize}\n \\item $x^3-3x^2+4=0$\n \\item $2x^3+6x^2+1=0$\n \\end{itemize}\\\\\n\\section{References}\n[1] P. Scarani, \"Out of control: vita di gerolamo cardano (1501-1576),\"\\\\\nPathologica, vol. 93, pp. 565-574, 2001.\n\\end{document}", "meta": {"hexsha": "7a68b49e56b8e48b64757989d9f17255d4466242", "size": 1602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CLASS PARTICIPATION/WEEK6 PRACTICE/CLASS PROJECT 2.tex", "max_stars_repo_name": "MATTHEW-OSAMOR/MATTHEW-OSAMOR-csc101-", "max_stars_repo_head_hexsha": "dcc90e301839401e5d76c4718b441d9a429a023f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CLASS PARTICIPATION/WEEK6 PRACTICE/CLASS PROJECT 2.tex", "max_issues_repo_name": "MATTHEW-OSAMOR/MATTHEW-OSAMOR-csc101-", "max_issues_repo_head_hexsha": "dcc90e301839401e5d76c4718b441d9a429a023f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CLASS PARTICIPATION/WEEK6 PRACTICE/CLASS PROJECT 2.tex", "max_forks_repo_name": "MATTHEW-OSAMOR/MATTHEW-OSAMOR-csc101-", "max_forks_repo_head_hexsha": "dcc90e301839401e5d76c4718b441d9a429a023f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.085106383, "max_line_length": 458, "alphanum_fraction": 0.6729088639, "num_tokens": 631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.4423863504191212}}
{"text": "\\chapter{How to benefit from this book}\n\n\\epigraph{Young man, in mathematics you don't understand things. You just get used to them.}{John von Neumann (1903--1957) \\cite{zukav1979dancing} (p. 208)}\n\nThis book is optimized for slow thoughtful focused sequential reading.\nThe author tries to make the book as short as possible.\n\n\\section{Notation}\n\nA \\emph{mathematical notation}, like the Latin alphabet,\nis a way of writing \\emph{English} or any other natural language.\nWhen you read ``math'',\nyou are really reading the same language\nthat you speak everyday.\n\nWhen you encounter symbols in a sentence,\nthink about how they should read in English\nto make the whole sentence grammatically correct.\n\nBeware that mathematical notations also have slangs and inconsistencies.\n\nA large part of mathematics is about defining and naming things.\n``\\(A\\) is \\(B\\) with some additional properties. \\(B\\) is \\(C\\) with some other properties.''\n\nThe reader is assumed to know the Greek alphabet.\n\n\\section{Some motivation}\n\nMath seems hard because learning a new language is hard.\n\n\\emph{Math is fun.}\nIndeed you can brainwash yourself into thinking anything is fun,\nincluding physical exercise and healthy eating,\njust by repeatedly shouting in your mind that it is fun.\n\n\\emph{Every time} you think you suck at math,\nshout in your head, ``I love math!''\nEven if you feel you can't,\nno matter however phony you feel,\njust shout it.\nRepeat it until it becomes a reflex.\nRemember that you \\emph{just} want to love math;\nyou don't want to be a math expert.\nYou can love math without being a math expert.\nIt's perfectly logical.\n\nIn mathematics, right is right, and wrong is wrong,\nregardless of age, skin color, gender, weight, wealth,\nnationality, religion, or political affiliation.\nIn mathematics, we don't have to worry about offending anyone.\n\nJohn von Neumann:\n``If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.''\n", "meta": {"hexsha": "048dd59f1fe62545f28b95ac72290a5e5ef0c696", "size": 1973, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "research/intro.tex", "max_stars_repo_name": "edom/work", "max_stars_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "research/intro.tex", "max_issues_repo_name": "edom/work", "max_issues_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-12-02T18:37:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T00:55:32.000Z", "max_forks_repo_path": "research/intro.tex", "max_forks_repo_name": "edom/work", "max_forks_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-10-02T15:20:22.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-02T15:20:22.000Z", "avg_line_length": 36.537037037, "max_line_length": 156, "alphanum_fraction": 0.7729346173, "num_tokens": 456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6791786991753929, "lm_q1q2_score": 0.4423863496854548}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\setcounter{section}{-1}\n\n\\begin{document}\n\n\\title{Numerical Analysis II}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{The Poisson equation}\n\n\\begin{prob} \nSolve\n\\begin{equation*}\n\\begin{aligned}\n\\nabla^2 u = f & x \\in \\Omega\\\\\nu = \\phi & x \\in \\partial\\Omega\n\\end{aligned}\n\\end{equation*}\nhere\n\\begin{equation*}\n\\begin{aligned}\n\\nabla^2 u = \\left(\\frac{\\partial^2}{\\partial x^2} + \\frac{\\partial^2}{\\partial y^2} \\right)u\n\\end{aligned}\n\\end{equation*}\nis the Laplace operator. The method is to impose on $\\Omega$ a rectangular grid $\\Omega_h$ with the spacing $h$, and replace $\\grad^2 u$ by a difference scheme. We'll look for approximate $u|_{\\Omega_h}$.\n\\end{prob}\n\n\\end{document}", "meta": {"hexsha": "2057783dd0068fcc5b74349f1cb53e2df37fc230", "size": 747, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Numerical Analysis II.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Numerical Analysis II.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Numerical Analysis II.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.6578947368, "max_line_length": 204, "alphanum_fraction": 0.7041499331, "num_tokens": 256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.44238634122594844}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{amsthm}\n\\usepackage{geometry}\n\\geometry{a4paper} \n\\usepackage{fancyhdr}\n\\usepackage{xcolor}\n\\usepackage{amssymb}\n\\usepackage{multicol}\n\\theoremstyle{definition}\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{problem}{Problem}\n\n\\begin{document}\n\\author{ \\textbf{Fractals}}\n\\title{\\textbf{Basic Equation Solving}}\n\\maketitle\n\\tableofcontents\n\\noindent\n\\section{Basic Equation Solving}\n\\subsection{Algebraic Manipulation}\nTo introduce the topic of \\textbf{algebraic manipulation},\nlet us start with a little known example: \\textbf{egyptian fractions}\n\n\\begin{theorem}[\\textbf{Egyptian Fractions}]\n    For all \\(a, b \\) where \\(ab \\ne 1 \\)\n    \\[\n        \\dfrac{a}{ab - 1 } = \\dfrac{1}{b( ab - 1)} + \\dfrac{1}{b}.\n    \\]\n    From here, we can see that putting things together (factoring) is just as important as taking them\n    apart (distributing). Now, let us turn the power of products:\n\\end{theorem}\n\\begin{exmp}\n    For positive real numbers \\(a, b \\),\n    \\[\n        a + \\dfrac{1}{b} = 4,\n    \\]\n    \\[\n        b + \\dfrac{1}{a} = 5,\n    \\]\n    Find \\(ab + \\dfrac{1}{ab} \\). \\\\\n\n    \\noindent\n    \\(Solution\\). It is very easy to get lost in the problem if we directly try to solve for a and b. Instead,\n    let us multiply the equations:\n    \\[\n        (a+\\dfrac{1}{b})(b+\\dfrac{1}{a}) = 4(5) = 20.\n    \\]\n    \\[\n        ab + \\dfrac{a}{a} + \\dfrac{b}{b} + \\dfrac{1}{ab} = ab + \\dfrac{1}{ab} + 2 = 20,\n    \\]\n    \\begin{center}\n        \\framebox[1\\width]{ \\( ab + \\dfrac{1}{ab} = 18\\). }\n    \\end{center}\n\\end{exmp}\n\\begin{theorem}\n    Let \\(x, y \\) be nonzero real numbers such that \\(x + y = a\\) and \\(xy = b\\) Then,\n    \\[\n        x^2 + y^2 = a^2 -2b,\n    \\]\n    \\[\n        (x+1)(y+1) = a + b + 1,\n    \\]\n    \\[\n        x^2 + xy^2 = ab,\n    \\]\n    \\[\n        | x - y | = \\sqrt{a^2 - 4b},\n    \\]\n    \\[\n        x^3 + y^3 = a^3 - 3ab,\n    \\]\n    \\[\n        \\dfrac{1}{x} + \\dfrac{1}{y} = \\dfrac{a}{b},\n    \\]\n\\end{theorem}\n\\subsection{Quadratic Equations}\nA polynomial is an equation of the following form:\n\\[\n    a_n x^n + a_{n-1} x^{n-1} + \\cdots + a_1 x + a_0 ,\n\\]\nwhere\n\\[\n    a_0, a_1, \\dots, a_n\n\\]\nare constants. A quadratic equation is a polynoimal with \\(n = 2\\):\n\\[\n    ax^2 + bx + c = 0,\n\\]\nA common way to solve a quadratic equation is to use the quadratic formula:\n\\begin{theorem}[\\textbf{Quadratic Formula}]\n    For the equation \\(ax^2 + bx + c = 0\\), the roots \\(x_1, x_2 \\) must be equal to\n    \\[\n        x_1 = \\dfrac{-b + \\sqrt{b^2 - 4ac}}{2a},\n    \\]\n    \\[\n        x_2 = \\dfrac{-b - \\sqrt{b^2 - 4ac}}{2a},\n    \\]\n\\end{theorem}\n\\begin{theorem}\n    For the equation \\(ax^2 + bx + c = 0\\), we have the following cases:\n    \\begin{itemize}\n        \\item If \\(b^2 - 4ac > 0\\), we have \\textbf{two real roots.}\n        \\item If \\(b^2 - 4ac = 0\\), we have \\textbf{one real root.}\n        \\item If \\(b^2 - 4ac < 0\\), we have \\textbf{no real roots.}\n    \\end{itemize}\n    Using the Quadratic Formula, we can calculate the sum of roots and product of roots:\n\\end{theorem}\n\\begin{theorem}\n    For the equation \\(ax^2 + bx + c = 0\\), the sum of roots is:\n    \\begin{displaymath}\n        x_1 + x_2 = \\dfrac{-b + \\sqrt{b^2 - 4ac}}{2a} + \\dfrac{-b + \\sqrt{b^2 - 4ac}}{2a}\n        = \\dfrac{-2b}{2a} = - \\dfrac{b}{a}\n    \\end{displaymath}\n    \\begin{displaymath}\n        x_1x_2 = \\dfrac{-b^2 + 4ac}{2a} \\times \\dfrac{-b^2 + 4ac}{2a} =\n        \\dfrac{-(-b)^2 - (b^2 - 4ac)}{4a^2} = \\dfrac{c}{a}\n    \\end{displaymath}\n\\end{theorem}\n\\begin{theorem}\n    For any polynoimal\n    \\[\n        a_n x^n + a_{n-1} x^{n-1} + \\cdots + a_1 x + a_0 ,\n    \\]\n\n    \\textbf{The sum of roots is}: \\( - \\dfrac{\\text{seconed coeffeicent}}{\\text{first coeffeicent}}\n    = - \\dfrac{a_{n-1}}{a_n}\\)\n    and \\textbf{the product of roots is:} \\(\\dfrac{\\text{last coeffeicent}}{\\text{first coeffeicent}}\n    = \\dfrac{a_0}{a_n} \\) \\\\\n\n    \\noindent\n    For those who are looking for a more advanced and more powerful theorem, we can generalize\n    this formula:\n\\end{theorem}\n\n\\begin{theorem}[\\textbf{Vieta’s Formulas}]\n    for any polynoimal\n    \\[\n        a_n x^n + a_{n-1} x^{n-1} + \\cdots + a_1 x + a_0 ,\n    \\]\n    let \\(r_1, r_2, \\dots r_n\\) (an \\(n\\)-degree equation has n different roots).\n    Vieta’s formulas state that\n    \\[\n        a_n = a_n\n    \\]\n    \\[\n        a_{n-1} = -a_n(r_1 + r_2 + \\cdots + r_n)\n    \\]\n    \\[\n        a_{n-2} = a_n(r_1r_2+r_1r_3+\\cdots + r_{n-1}r_n)\n    \\]\n    \\[\n        \\vdots\n    \\]\n    \\[\n        a_0 = (-1)^n a_n(r_1r_2\\cdots r_n)\n    \\]\n\\end{theorem}\n\n\\section{Problems}\n\n\\begin{problem}\nLet \\(x\\) be a real number such that \\(x+\\dfrac{1}{x} = \\sqrt{2020}\\).\nWhat is \\(x^2 + \\dfrac{1}{x^2}\\)?\n\\end{problem}\n\n\\begin{problem}\nTwo non-zero real numbers, a and b, satisfy \\(ab = a - b\\).\nWhich of the following is a possible value of \\(\\dfrac{a}{b}\n+ \\dfrac{b}{a} -ab \\)?\n\\end{problem}\n\n\\begin{problem}\nLet \\(x, y\\) be nonnegative real numbers such that \\(x + y = 5\\) and \\(xy = 7\\). Find\n\\(\\dfrac{x}{y-1} +\\dfrac{y}{p-1}\\)\n\\end{problem}\n\n\\begin{problem}\nLet \\(a, b\\) are real numbers such that\n\\[\n    \\dfrac{1}{a(b+1)} + \\dfrac{1}{b(a+1)} = \\dfrac{1}{(a+1)(b+1)}.\n\\]\n\\end{problem}\n\n\\begin{problem}\nFind the sum of roots to the equation \\(x^{2020} = 2020x^{2019} + 1\\)\n\\end{problem}\n\n\\begin{problem}\nFind the product of the roots of the equation \\(x^3 = 9\\pi x + x^2 + 1. \\)\n\\end{problem}\n\n\\begin{problem}\nWhat is the average value of the three roots of the equation \\(x^3 -12x^2 - 4x + 48 = 0\\)?\n\\end{problem}\n\n\\end{document}", "meta": {"hexsha": "5eb3b2d4af761e150bc1ede334f1523293d827e8", "size": 5633, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "basic/basic-equation-sloving/basic-equation-solving.tex", "max_stars_repo_name": "GUC-Fractals/math-curriculum", "max_stars_repo_head_hexsha": "a11336def018106bd31e56e5eb9ac9225d4a072a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-06T09:36:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-06T09:36:30.000Z", "max_issues_repo_path": "basic/basic-equation-sloving/basic-equation-solving.tex", "max_issues_repo_name": "GUC-Fractals/math-curriculum", "max_issues_repo_head_hexsha": "a11336def018106bd31e56e5eb9ac9225d4a072a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "basic/basic-equation-sloving/basic-equation-solving.tex", "max_forks_repo_name": "GUC-Fractals/math-curriculum", "max_forks_repo_head_hexsha": "a11336def018106bd31e56e5eb9ac9225d4a072a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8861386139, "max_line_length": 110, "alphanum_fraction": 0.5744718622, "num_tokens": 2169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7461389986757758, "lm_q1q2_score": 0.44221166343830626}}
{"text": "\\section{Introduction}\n\\label{sec:introduction}\n\n  The multigroup neutron diffusion equation has proven to be a useful tool for\n  modeling the neutron distribution in a typical nuclear reactor. With the\n  development of the \\gls{nem}, the model was made more accurate and\n  computational time was significantly decreased. The typical quantity of\n  interest in these reactor simulations is the fundamental mode of the\n  eigenvalue problem; that is, the largest eigenvalue and associated eigenvector\n  which represent the effective neutron multiplication factor and scalar neutron\n  flux distribution respectively.\n\n  Traditionally, the multigroup neutron diffusion equation and \\gls{nem}\n  equations have been solved using the \\gls{pi} method. The \\gls{pi} method is a\n  fixed-point method useful for solving eigenvalue problems. It is a linear\n  iteration method and converges to the fundamental eigenmode at a linear rate.\n  Recently, the use of \\gls{jfnk} methods has been investigated in an attempt to\n  reduce the computing time required to solve the \\gls{nem} equations.\n  \\gls{jfnk} methods are attractive because when the iteration terminates, the\n  method converges $q$-quadratically. However, \\gls{jfnk} methods require the\n  computation of quantities not required by the \\gls{pi} method including the\n  finite difference Jacobian-vector product. Due to the challenges of computing\n  these quantities, the implementation of \\gls{jfnk} methods for computing the\n  fundamental mode to the multigroup neutron diffusion equation and \\gls{nem}\n  equations remains an active area of research.\n\n  In \\citetitle{qe2paper}, \\citeauthor{qe2paper} explore an implementation of\n  the \\gls{jfnk} method that seeks to efficiently solve the \\gls{nem} equations\n  for the fundamental eigenmode. \\sref{sec:summary} briefly summarizes this work\n  and a few considerations for solving the \\gls{nem} equations using the\n  \\gls{jfnk} method are provided. Then, \\sref{sec:critique} critiques the\n  authors' implementation with a focus on the applicability of the proposed\n  method to realistic nuclear reactor simulations. Finally,\n  \\sref{sec:conclusion} provides a few conclusions based on the work by\n  \\citeauthor{qe2paper} and some considerations for future implementations of\n  the \\gls{jfnk} method to solve the \\gls{nem} equations in nuclear reactor\n  simulations.\n", "meta": {"hexsha": "4c2ae3785ebc3559317bbbc7ff4f4cc0c37ba4b8", "size": 2360, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sec_introduction.tex", "max_stars_repo_name": "wcdawn/WilliamDawn-QE2", "max_stars_repo_head_hexsha": "da790b3bca756652ae97e8f9b0d3d83e13a163ec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-30T15:17:59.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-30T15:17:59.000Z", "max_issues_repo_path": "sec_introduction.tex", "max_issues_repo_name": "wcdawn/WilliamDawn-QE2", "max_issues_repo_head_hexsha": "da790b3bca756652ae97e8f9b0d3d83e13a163ec", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sec_introduction.tex", "max_forks_repo_name": "wcdawn/WilliamDawn-QE2", "max_forks_repo_head_hexsha": "da790b3bca756652ae97e8f9b0d3d83e13a163ec", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.1052631579, "max_line_length": 80, "alphanum_fraction": 0.7949152542, "num_tokens": 557, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4422116600926886}}
{"text": "%===================================Used packages======================%\n%----------------------------------------------------------------------%\n\\documentclass[12pt]{report}\n\\usepackage{sagetex}\n\\pagenumbering{gobble}\n\\oddsidemargin=0pt\n\n%----------------------------------------------------------------------%\n%=======================Title page=====================================%\n%----------------------------------------------------------------------%\n\\title{Dynamic of Structure: Mode and Time Period}\n\\author{Amarjeet Singh }\n\\begin{document}\n\\setcounter{chapter}{1}\n\\thispagestyle{plain}\n\t\\begin{titlepage}\n\\maketitle\n\t\\end{titlepage}\n\n\\begin{sagesilent}\n\tload('main.sage.py')\n\n\\end{sagesilent}\n\nNumber Of Storeys\n\\begin{equation}\n\tN = \\sage{Number_of_storeys}\n\\end{equation}\n\n\n\\begin{sagesilent}\nlatex.matrix_delimiters(\"\\{\",\"\\}\")\n\\end{sagesilent}\n\n\nMass\n\\begin{equation}\n\t [M]=\\sage{mass}\n\\end{equation}\n\n\n\nTime Period\n\\begin{equation}\n\t[T]=\\sage{Time_period}\n\\end{equation}\n\nOmega Square\n\\begin{equation}\n\t[\\omega^2] =\\sage{Omega_square.transpose()}\n\\end{equation}\n\nFrequency\n\\begin{equation}\n\t[\\omega]=\\sage{Omega}\n\\end{equation}\n\n\\newpage\n\\begin{figure}\n\t\\sageplot[scale=0.75]{Graph}\n\t\\caption{Mass Model}\n\\end{figure}\n\n\\begin{equation}Number of modes considered=\\sage{Modes_considered}\n\\end{equation}\n\\newpage\n\nLevel Floor\n\\begin{equation}\n\t[L]=\\sage{Level_floor}\n\\end{equation}\n\nModal Participation Factor\n\\begin{equation}\n\t [p]=\\sage{Modal_participation_factor}\n\\end{equation}\n\nModal Mass\n\\begin{equation}\n\t [M_{{m}}]=\\sage{Modal_mass}\n\\end{equation}\n\nModal Contribution\n\\begin{equation}\n\t[M_{{c}}]=\\sage{Modal_contribution}\n\\end{equation}\n\n\nSa By G\n\\begin{equation}\n\t [S_{{a}}]=\\sage{Sa_by_g}\n\\end{equation}\n\nA H\n\\begin{equation}\n\t[A_{{H}}]=\\sage{A_h[:,1]}\n\\end{equation}\n\n\\begin{sagesilent}\nlatex.matrix_delimiters(\"[\",\"]\")\n\n\\end{sagesilent}\nDesign Lateral Force\n\\begin{equation}\n\t[F]=\\sage{Design_lateral_force}\n\\end{equation}\n\nPeak Shear Force\n\\begin{equation}\n\t[V]=\\sage{Peak_shear_force}\n\\end{equation}\n\n\n\\begin{sagesilent}\nlatex.matrix_delimiters(\"\\{\",\"\\}\")\n\\end{sagesilent}\n\n\\section{Storey Shear Force}\nABS-:\n\\begin{equation}\n\t\\sage{storey_shear_force3}\n\\end{equation}\nSRSS -:\n\\begin{equation}\n\t\\sage{Storey_shear_force2}\n\\end{equation}\nComplete Quadratic combination -:\n\\begin{equation}\n\t\\sage{Lateral_force}\n\\end{equation}\nMaximum Absolute Response -:\n\\begin{equation}\n\t\\sage{Force}\n\\end{equation}\n\\end{document}\n", "meta": {"hexsha": "6c65425a9124080e5cd92d4b34d8c5154905a0b7", "size": 2441, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sage/sagemath/civil.tex", "max_stars_repo_name": "GreatDevelopers/CivilOctave", "max_stars_repo_head_hexsha": "486766dbd2ce85377b26440054f120c02b7535c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-12-17T10:03:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T09:58:50.000Z", "max_issues_repo_path": "sage/sagemath/civil.tex", "max_issues_repo_name": "GreatDevelopers/CivilOctave", "max_issues_repo_head_hexsha": "486766dbd2ce85377b26440054f120c02b7535c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-11-12T08:58:24.000Z", "max_issues_repo_issues_event_max_datetime": "2015-11-15T13:42:21.000Z", "max_forks_repo_path": "sage/sagemath/civil.tex", "max_forks_repo_name": "GreatDevelopers/CivilOctave", "max_forks_repo_head_hexsha": "486766dbd2ce85377b26440054f120c02b7535c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2015-08-11T15:59:12.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-27T03:07:15.000Z", "avg_line_length": 17.9485294118, "max_line_length": 72, "alphanum_fraction": 0.6312986481, "num_tokens": 744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.4422116567470709}}
{"text": "%! Author = tstreule\n\n\\section{Action Potential \\& Hodgkin-Huxley Model}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{minipage}[t]{.5\\columnwidth-.5\\columnsep}\n    \\subsection{Current Clamp}\n    %\n    \\textbf{Fix current} $I_m$ and\\\\\n    measure membrane potential\n    \\begin{itemize}\n        \\item[$\\to\\!\\!$] Good for observing AP\\\\\n        (since voltage can change)\n    \\end{itemize}\n\\end{minipage}%\n\\hspace{\\columnsep}%\n\\begin{minipage}[t]{.5\\columnwidth-.5\\columnsep}\n    \\subsection{Voltage Clamp}\n    %\n    \\textbf{Fix voltage} $V_m$ and\\\\\n    measure the current\n    \\begin{itemize}\n        \\item[$\\to\\!\\!$] Good for studying membrane channel proteins (ion transp.)\n    \\end{itemize}\n\\end{minipage}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{2-state ion channel model}\n%\n\\formula{two states}{\\ce{close <=>[\\alpha][\\beta] open}}\n\\quad with gate charge $Q$\n\\formula{\\#open states}{\\deriv{n(t)}{t} = \\alpha (\\mathcal{N} - n(t)) - \\beta n(t)}\n\\formbox{Prob. being open}{x(t) \\simeq \\frac{n(t)}{\\mathcal{N}} = x_\\infty\\! + (x_0-x_\\infty\\!) \\;\\eu^{-t/\\tau_x}}\n\\formbox{~}{x_\\infty\\! = \\frac{\\alpha}{\\alpha+\\beta}, \\quad \\tau_x = \\frac{1}{\\alpha+\\beta}}\n\n\\begin{minipage}{\\linewidth}\n    \\begin{minipage}{\\linewidth}\n        \\formula{Boltzmann law}{\\alpha = A\\;\\eu^{(E_c-E_B)/kT}}\n        \\formula{~}{\\beta = A\\;\\eu^{(E_o-E_B)/kT}}\n        \\formula{~}{x_\\infty\\! = \\frac{1}{1+\\beta/\\alpha} = \\frac{1}{1+\\eu^{-QV_m/kT}}}\n        \\formula{~}{\\tau_x = \\frac{1}{A\\;\\eu^{-\\frac{1}{2}QV_B/kT}} \\cdots}\n        \\formula{~}{\\phantom{\\tau_x =} \\cdots \\frac{1}{\\eu^{\\frac{1}{2}QV_m/kT} + \\eu^{-\\frac{1}{2}QV_m/kT}}}\n    \\end{minipage}\n    \\begin{minipage}{\\linewidth}\n        \\vspace{-30mm}\\hfill\n        \\includegraphics[width=.35\\columnwidth]{AP_Boltzmann}\n    \\end{minipage}\n\\end{minipage}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Circuit Model \\textnormal{(Conductance) \\hfill\\small$V\\ped{K} \\simeq \\unit[-75]{mV}, \\quad V\\ped{Na} \\simeq \\unit[+55]{mV}$}}\n%\n\\formtex{~}{\\scalebox{.9}{%\n    \\highlight{$J\\ped{C} = C_m \\deriv{V_m(t)}{t}$} \\enskip \\fbox{$J_m = C_m \\deriv{V_m}{t} + G_m(V_m-V_m\\ap{rest})$}}}\n\\formtex{~}{\\scalebox{.9}{%\n    \\highlight{$J\\ped{K} = G\\ped{K}\\;(V_m-V\\ped{K})$} \\scriptsize always $>0$, we don't fall below ($V_m>V\\ped{K}$)}}\n\\formtex{~}{\\scalebox{.9}{%\n    \\highlight{$J\\ped{Na} = G\\ped{Na}\\;(V_m-V\\ped{Na})$} \\scriptsize $\\begin{cases}>0 & \\text{if } V_m-V\\ped{Na}>0 \\\\ <0 & \\text{otw.} \\end{cases}$}}\n\n\\vspace{-18mm}%\n\\begin{minipage}{\\linewidth}\n    \\includegraphics[width=.3\\columnwidth]{AP_Conductance_Model}\n\\end{minipage}\n\n\\begin{minipage}{.25\\columnwidth}\n    \\includegraphics[width=.8\\columnwidth]{AP_Conductance}\n\\end{minipage}\n\\begin{minipage}{.75\\columnwidth}\n    \\begin{itemize}\n        \\item slow onset; decays slow\n        \\item \\ce{K+} inactivates \\ce{Na+} channels\n    \\end{itemize}\n    $\\to$ \\textbf{Refractoriness} {\\scriptsize(kurzzeitige AP Resistenz)}\\\\\n    \\phantom{$\\to$} (\\ce{Na+} channels are still inactivate, $h\\sim0$)\n\\end{minipage}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Multiple states gate}\n%\n\\formtex{open $n_Q(V_m,t)$}{big/small $Q$ $\\to$ fast/slow dynamics}\n\n\\formtex{Let's write}{%\n    \\fbox{$h$} $= n_{-Q}$ ``slow''\\!, \\;\\;\n    \\fbox{$m$} $= n_{2Q}$ ``fast''\\!, \\;\\;\n    \\fbox{$n$} $= n_Q$ %``normal''\n}\n\\formtex{~}{The \\textit{lower} $T$, the \\textit{bigger} the diff. between them.}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Hodkin-Huxley \\textnormal{(HH)} model}\n%\nExperimentally you may fit the \\ce{K+} and \\ce{Na+} current into\n\\formula{Conductance}{G\\ped{K}(V_m,t) = \\overline{G}\\ped{K} \\; n^4}\n\\formula{~}{{G\\ped{Na}(V_m,t) = \\overline{G}\\ped{Na} \\; m^3 h}}\n\n\\begin{minipage}{.35\\columnwidth}\n    \\includegraphics[width=.9\\columnwidth]{AP_Actionpotential}\n\\end{minipage}%\n\\hspace{\\boxmargin}%\n\\begin{minipage}{.65\\columnwidth}\n    \\textbf{Four regimes during AP}:\n    \\begin{enumerate}\n        \\item[II] \\textit{De}polarization:\n        \\ce{Na+} gate opens $\\to$ \\ce{Na+} in\n        \\item[III] \\textit{Re}polarization:\n        \\ce{K+} gate opens $\\to$ \\ce{K+} out\n        \\item[IV] \\textit{Hyper}polarization:\\\\\n        Active \\ce{Na+-K+-ion} pump (\\ce{Na+}$\\leftrightarrow$ \\ce{K+})\n    \\end{enumerate}\n\\end{minipage}%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Decrement-free conduction}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Core -- Conductor Model}\n%\n\\begin{minipage}{.3\\columnwidth}\n    \\vspace{6mm}$V_m \\big\\downarrow$\n    \\begin{minipage}{.5\\columnwidth}\n        \\vspace{-6mm}\\includegraphics[width=\\columnwidth]{AP_Core_Conductor_Model}\n    \\end{minipage}\n\\end{minipage}%\n\\hspace{1.5\\boxmargin}%\n\\begin{minipage}{.6\\columnwidth}\n    $R_i = r_i \\diff z$\\quad $\\leftarrow$ $\\diff z$: per unit length\\\\\n    $R_o = r_o \\diff z$\\\\\n    $I_m = k_m \\diff z$\\quad $\\leftarrow$ may use HH-model\n\\end{minipage}%\n\n\\vspace{-3mm}\n\\formula{Core--Conductor eq.}{\\pderiv[2]{V_m(z,t)}{z} = (r_o+r_i)K_m(z,t) - \\overbrace{r_oK_e(z,t)}^{\\overset{\\textrm{if}}{=}\\; 0 \\;\\to\\; I_o = -I_i}}\n\\formula{\\hfill wave eq.}{\\phantom{\\pderiv[2]{V_m(z,t)}{z}} = \\frac{1}{v^2} \\pderiv[2]{V_m(z,t)}{t} }\n\\enskip with $v = \\frac{W}{\\Delta t}$\n\\formbox{\\hfill$\\overset{K_e=0}{\\implies}$}{v \\simeq \\frac{K_ma}{2\\rho_i}}\n\\enskip for $r_i \\gg r_o$\n\\enskip i.e. $v\\propto\\sqrt{a}$\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Cable model \\textnormal{-- Core--Conductor with HH-model inside}}\n%\n\\formtex{Linearize \\small(1st order)}{\\small timescale for membrane voltage changes {$\\tau_m {=} \\frac{C_m}{G_m}$}}\n\\formtex{Cable equation}{Let $v_m = V_m + V_m\\ap{rest}$}\n~\\qquad $v_m {+} \\hspace{-1mm}\\underbrace{\\tau_m\\pderiv{v_m}{t}\\vspace{-1mm}}_{\\vspace{-2mm} = 0 \\text{ time indep.}}\\hspace{-1mm} - \\lambda_C^2 \\pderiv[2]{v_m}{z} {=} r_o\\lambda_C^2K_e$\n\\enskip \\highlight{$\\lambda_C {=} \\frac{1}{\\sqrt{g_m(r_o+r_i)}}$}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Saltatory Conduction Hypothesis}\n%\n$\\to$ explain discrete manner in steps\n\n\\formula{velocity $\\sim$ axon}{\\textrm{total delay} \\sim N (\\#\\textrm{nodes}) \\sim (\\textrm{axon length})/L}\n\\formula{diameter $D$}{\\ce{->[$L\\sim D$]} \\textrm{velocity} \\sim \\frac{\\textrm{total delay}}{\\textrm{axon length}} \\sim D}\n\n\\begin{minipage}{\\columnwidth/3}\n    \\includegraphics[width=.85\\columnwidth]{AP_Saltatory}\n\\end{minipage}%\n\\begin{minipage}{\\columnwidth/3}\n    \\centering\n    \\includegraphics[width=.8\\columnwidth]{AP_Saltatory_2}\n\\end{minipage}%\n\\begin{minipage}{\\columnwidth/3}\n    \\hfill\n    \\includegraphics[width=.75\\columnwidth]{AP_Ranvier_Node}\n\\end{minipage}\n", "meta": {"hexsha": "b7eb75a84b05f160db80086ea3a56a9b06a6fad2", "size": 6736, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/BE18/sections/12_action_potential.tex", "max_stars_repo_name": "tstreule/eth-cheat-sheets", "max_stars_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-26T23:11:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T23:11:57.000Z", "max_issues_repo_path": "src/BE18/sections/12_action_potential.tex", "max_issues_repo_name": "tstreule/eth-cheat-sheets", "max_issues_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/BE18/sections/12_action_potential.tex", "max_forks_repo_name": "tstreule/eth-cheat-sheets", "max_forks_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6329113924, "max_line_length": 186, "alphanum_fraction": 0.5853622328, "num_tokens": 2473, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4421700622385818}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\n\nThis section covers selection and replacement techniques in the context of a crossover-based evolutionary algorithms. Their purpose is to introduce selection after reproduction in a way that checks whether or not crossover and mutation were able to produce a new solution candidate that outperforms its parents.\n\n\\begin{itemize}\n    \\item \\textbf{OS:} A certain ratio of the next generation has to consist of children that can outperform their parents.\n    \\item \\textbf{RAPGA:} new child solutions are added to the population as long as it is possible to generate unique and successful offspring from the gene pool of the last generation.\n\\end{itemize}\n\nAn upper limit for the selection pressure provides a good termination criterion.\n\n\\section{Offspring Selection (OS)}\n\\sectionmark{OS}\n\nThe progression of genetic search is the assured by means of successful offspring. The goal of OS is to create a sufficient number of children that surpass their parents' fitness.\n\n\\subsection{Success Ratio}\nThe success ration is defined as the relation between the next population members that need to be generated by successful mating, in relation to the total population.\n\n\\begin{equation}\n    \\text{SuccRation} \\in [0,1]\n\\end{equation}\n\nHaving filled up the the claimed ratio, the rest of the generation is filled with randomly generated individuals that were also created by crossover but did not reach the criteria.\n\n\\subsection{Comparison Factor}\nIn oder to classify a child as \\emph{better} than it's parent, the comparison factor is introduced. A comparison factor of 0 means that the child is considered better when it outperforms its weakest parent while it has to outperform its best parent for a comparison factor of 1.\n\n\\begin{equation}\n    \\text{CompFactor} \\in [0,1]\n\\end{equation}\n\nThe comparison factor is scaled from 0 to 1 during the run of the algorithm. This causes a broader search at the beginning and a more directed search in the end.\n\n\\subsection{Actual Selection Pressure}\nThe actual selection pressure is the quotient of individuals that had to be considered until the success ration was reached, and the number of individuals in the population in the following way:\n\n\\begin{equation}\n    \\text{ActSelPress} = \\frac{ | \\text{POP}_{i+1} | + | \\text{POOL} | }{ | \\text{POP}_i | }\n\\end{equation}\n\nAn upper limit defines the maximum numbers of offspring considered. When this limit is sufficiently high, the model can be used for detecting premature convergence.\n\n\\textit{If it is no longer possible to find a sufficient number $(\\text{SuccRatio} \\dot | \\text{POP} |)$ of offspring, outperforming their own parents even if $(\\text{MaxSelPress} \\dot | \\text{POP} |)$ candidates have been generated, premature convergence has occurred.}\n\nHigher success ratios cause higher selection pressure. This does not necessary cause premature convergence because the new selection step does not accepts clones. The latter are a major reason for premature convergence in regular GAs.\n\n\\section{Relevant Alleles Preserving GA (RAPGA)}\n\\sectionmark{RAPGA}\n\nThe goal of this enhanced algorithm variant is trying to bring out as much progress from the actual generation as possible and losing as little genetic diversity as possible at the same time. This is achieved by adjusting the population size. Potential offspring are accepted as members of the next generation $\\Leftrightarrow $ they are able to outperform the fitness of their parents and they are new in the sense that their chromosome consists of a concrete allele alignment that is not represented yet in the  an individual of the current generation.\n\n\\subsection{Considerations}\n\nThe following practical aspects of the RAPGA need to be considered:\n\n\\begin{itemize}\n    \\item The algorithm should offer different parent selection mechanisms, even for different parents (male and female) or allow for it to be disabled completely (random).\n    \\item It is reasonable to have more than one crossover and mutation operator. This works even for operators only generating a good result sporadically, because only successful chromosomes are considered in the evolutionary progress.\n    \\item The population size requires a lower and upper bound. The upper limit is required to prevent snowballing in the first rounds. The lower limit is needed to have a sufficient amount of chromosomes present to outperform parents. Additionally, it can act as a detector for convergence.\n    \\item Checking genotipical identity prevents structurally identical individuals to be included in the next generation.\n    \\item The maximum effort per generation is the maximum number of newly generated chromosomes per generation, no matter whether they are accepted or not. This can be used to terminate generation rounds.\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "51ec64e36e33469b328ab049a18bf97142a316c2", "size": 4845, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "subfiles/preservation.tex", "max_stars_repo_name": "JDevlieghere/Genetic-Algorithms", "max_stars_repo_head_hexsha": "cfdf4e890801b82be1301361b075c011b8c7768b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2015-01-16T21:26:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-10T16:25:22.000Z", "max_issues_repo_path": "subfiles/preservation.tex", "max_issues_repo_name": "JDevlieghere/Genetic-Algorithms", "max_issues_repo_head_hexsha": "cfdf4e890801b82be1301361b075c011b8c7768b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-01-20T12:10:33.000Z", "max_issues_repo_issues_event_max_datetime": "2015-01-20T13:03:09.000Z", "max_forks_repo_path": "subfiles/preservation.tex", "max_forks_repo_name": "JDevlieghere/Genetic-Algorithms", "max_forks_repo_head_hexsha": "cfdf4e890801b82be1301361b075c011b8c7768b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2016-08-11T13:19:05.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-20T00:41:31.000Z", "avg_line_length": 71.25, "max_line_length": 554, "alphanum_fraction": 0.7954592363, "num_tokens": 1016, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.44217005387268904}}
{"text": "\\documentclass[./Thesis.tex]{subfiles}\n\\begin{document}\n\n\\chapter*{Conclusion}\n\\addcontentsline{toc}{chapter}{Conclusion}\n\\chaptermark{Conclusion}\n\\markboth{Conclusion}{Conclusion}\n\nThis thesis described a selection of number theoretic concepts required for the\nformalization and implementation of the AKS primality decision algorithm in the\n\\Agda{} proof assistant. We began with a high level overview of the AKS\nalgorithm. This overview outlined the necessary mathematical concepts that would\nbe required to implement AKS in a proof assistant. Since the \\Agda{} proof\nassistant does not have the mathematical lexicon of the average human number\ntheorist this list of theorems was quite large. As this is an undergraduate time\nlimited thesis, we choose to explicate a select few from this list. \\\\\n\nIn Chapter \\ref{chap:exponentiation} we iteratively developed an exponentiation\nalgorithm that runs in logarithmic time relative to the exponent. This algorithm\ncan exponentiate any base as long as the base forms a commutative monoid under\nits multiplication operation. Following this we proved that our exponentiation\nalgorithm was equal to the standard grade school method of computing\nexponentials. This algorithm appears in the AKS algorithm multiple times and\nimportantly the type of the base changes in each location necessitating the\nability to exponentiate arbitrary commutative monoids. \\\\\n\nNext in Chapter \\ref{chap:termination} we investigated how \\Agda{} is able to\nensure non-looping behavior, or in other words reject circular definitions. We\nremarked on the strength of Agda's termination checker, the code that rejects\npotentially looping programs. We discovered that \\Agda{} can tell if a program\nis soundly defined if it can infer a well-founded relation for its inputs. As\n\\Agda{} does not always succeed in this inference we then built machinery to\nprovide \\Agda{} with our own well-founded relation. This allows us to express\ncomplex recursive algorithms without the fear of non-termination. \\\\\n\nLastly, in Chapter \\ref{chap:primality} we codified the correct representation of a\ndecision procedure in a proof relevant setting. As AKS is a decision procedure\ngetting this correct is paramount. We then developed a decision procedure for\nthe divisibility relation common in number theory. The ability to test if one\nnumber divides another was immediately useful. As we ended the chapter with a\nbrute force primality decision procedure. This is a critical sub-component of the\nAKS algorithm as AKS requires a list of ``small'' primes to test the input\nagainst. \\\\\n\nWe were not able to develop every required component to prove the\ncorrectness of AKS but we estimate at least 75\\% of the required components are\ncompleted. Some of the developed, but not described components are as follows; a\nGCD function that works over an arbitrary Euclidean Domain, a polynomial\ndatatype that forms a Euclidean Domain, a modular ring datatype, and many more.\nAll of these formulations are available publicly in the github repo\n\\url{https://github.com/mckeankylej/thesis}. With more work we believe the\ncorrectness of AKS can be fully formalized.\n\n\\end{document}\n", "meta": {"hexsha": "ca8ecbf1a84c1e4e3b65025b729c28a4997f93d7", "size": 3167, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Conclusion.lagda.tex", "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_issues_repo_path": "tex/Conclusion.lagda.tex", "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Conclusion.lagda.tex", "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.5818181818, "max_line_length": 83, "alphanum_fraction": 0.8124407957, "num_tokens": 693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.442170040407328}}
{"text": "\n\\chapter{Normal forms}\\setcounter{ProbPart}{0}\n\n\\problempart\n\\label{pr.DNF}\nConsider the following sentences:\n\t\\begin{earg}\n\t\t\\item $(A \\eif \\enot B)$\n\t\t\\item $\\enot (A \\eiff B)$\n\t\t\\item $(\\enot A \\eor \\enot (A \\eand B))$\n\t\t\\item $(\\enot (A \\eif B ) \\eand (A \\eif C))$\n\t\t\\item $(\\enot (A \\eor B) \\eiff ((\\enot C \\eand \\enot A) \\eif \\enot B))$\n\t\t\\item $((\\enot (A \\eand \\enot B) \\eif C) \\eand \\enot (A \\eand D))$\n\t\\end{earg}\n        For each sentence, find a tautologically equivalent sentence in DNF and one in CNF.\n\n\\stepcounter{chapter} % Functional completeness\n\\stepcounter{chapter} % Soundness", "meta": {"hexsha": "570e1b613fba925d16610cd2348c5ff1e86c1668", "size": 599, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "solutions/forallx-sol-metatheory.tex", "max_stars_repo_name": "Pi-Cla/forallx-yyc", "max_stars_repo_head_hexsha": "097d57718efa0ad6a7cb0033ff727e9a1a561221", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "solutions/forallx-sol-metatheory.tex", "max_issues_repo_name": "Pi-Cla/forallx-yyc", "max_issues_repo_head_hexsha": "097d57718efa0ad6a7cb0033ff727e9a1a561221", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "solutions/forallx-sol-metatheory.tex", "max_forks_repo_name": "Pi-Cla/forallx-yyc", "max_forks_repo_head_hexsha": "097d57718efa0ad6a7cb0033ff727e9a1a561221", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.2777777778, "max_line_length": 91, "alphanum_fraction": 0.6410684474, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.44216857214785976}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[utf8, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}\n\\usepackage[english]{babel}\n\\setlength{\\parindent}{2em}\n\\setlength{\\parskip}{1em}\n\\renewcommand{\\baselinestretch}{1}\n\\usepackage{graphicx}\n\\usepackage{gensymb}\n\\usepackage{natbib}\n\\usepackage{amssymb}\n\\usepackage{xcolor}\n\\usepackage{wasysym}\n\n\\title{Tidal Evolution of the Earth-Moon System}\n\\author{Patricia Golaszewska}\n\\date{May $14^{th}$ 2021}\n\\begin{document}\n\n\\maketitle\n\n\\newpage\n\n\\begin{center}\n    \\section*{Introduction}\n\\end{center}\n\nThis project sets out to model the tidal evolution of the Earth-Moon system. The evolution of this system can be modelled using a set of ordinary differential equations:\n\n\\begin{equation}\n   \\frac{dL_{\\oplus}}{dt} = T_{\\odot}\n\\end{equation}\n\n\\begin{equation}\n   \\frac{dS_{\\oplus}}{dt} = -T_{\\odot} - T_{\\leftmoon}\n\\end{equation}\n\n\\begin{equation}\n   \\frac{dL_{\\leftmoon}}{dt} = T_{\\leftmoon}\n\\end{equation}\n\nThe ultimate goal is to integrate these ODEs numerically using python. This allows us to model the tidal evolution of the Earth-Moon system; from initial impact to the present day. As discussed in the project outline, tidal forces have an effect on the tides. Our understanding of this phenomenon is a combination of the effects of the spin angular momentum of Earth, and the orbital angular momentum of the Sun and the moon. This then motivates the choice of the set of ODEs used in this project.\n\n\n\\begin{center}\n    \\section*{Methods}\n\\end{center}\n\nWe are first tasked with establishing various quantities which are used throughout the project. Due to the majority of quantities being provided in cgs units, this was the chosen unit system. Other values were converted in order to conform to this unit system.\n\nCalculations could then be made by using the mathematical abilities of python. This allowed us to then calculate the values we'll need to feed into our integrator later on. Thus, we could calculate the numerical values of timescales associated with our three ODEs, their initial conditions, and their RHS. \n\nUsing the scipy.integrate package and the dopri5 integrator, we could then combine our initial conditions with our ODEs following the format discussed in CTA200H lectures. Because we need to integrate into the past, a negative set of time values was chosen, ranging from the present day (0) to billions of years in the past. According to the model, the moon formed roughly 1.5 billion years ago, however, there is scientific evidence that the moon is much older than that.\n\nUsing the result of this integration, we could then analyze the evolution of the moons formation. The giant impact hypothesis is generally regarded as the leading theory in the formation of our moon. Our model allows for us to integrate into the past when the Earth and the object that would become our moon collided. At this point, their separation distance was 0 and grew over time to its present value. Thus, indexing our arrays allows us to find the time which the model predicts that the moon formed. As time moved forward, the semimajor axis expanded, and that expansion is depicted visually in Figure 1.\n\n\\begin{figure}[htp]\n    \\centering\n    \\includegraphics[width=12cm]{Q6.pdf}\n    \\caption{Change in the semimajor axis of the moon over time.}\n    \\label{fig:Q6}\n\\end{figure}\n\nIf the moon formed at the Roche radius (at approximatley 9496 km), then the length of day would be approximately 4 hours long. As the system stabilized over time, the length of day became longer. This is depicted visually in Figure 2. \n\n\\begin{figure}[htp]\n    \\centering\n    \\includegraphics[width=12cm]{Q7.pdf}\n    \\caption{Change in the length of day on Earth over time.}\n    \\label{fig:Q7}\n\\end{figure}\n\nIssues surrounding this model arise from the incorrect age we get for our system. I suspect that there may be issues with how our model predicts the evolution of this system, and possibly doesn't account for the conditions at impact.\n\nFirstly, I do not believe that this model allows for the moon to go through the process of mass accretion. This process would change the dynamics of the system over time as the gravitational effects change.\n\nSecond, I believe that this model assumes that the Earth-Moon system has been tidally locked from impact. This is an extension of the point made above; the dynamics of this system age the Earth-Moon system based on the tidal evolution. However, if the moon spent a period of time in asynchronous rotation, this model doesn't capture this.\n\nI believe that this model interprets the collision as formation, which isn't necessarily true. The moon would have began it's formation at some distance away (i.e possibly the Roche radius) versus at impact.\n\nAdditional inconsistencies may be caused by changes in the eccentricity and alignment of the moons orbit, as well as external gravitational influences. Stabilization and tidal-locking may also result in changes in the energy in this system, which could have influenced the evolution of our system. \n\nThese reasons are listed in the order of what I assume to be the most reasonable assumption. My primary concern is that the initial dynamics of the system differ than those observed today, and they are not accounted for in the scope of this project.\n\n\\end{document}\n", "meta": {"hexsha": "21061c8574881e78187d2c49a77ec4496946c9f1", "size": 5332, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Final Project/main.tex", "max_stars_repo_name": "PatThePhysicist/CTA-2021", "max_stars_repo_head_hexsha": "539589f0ecc465fc5efb21679b36b22f88972f97", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Final Project/main.tex", "max_issues_repo_name": "PatThePhysicist/CTA-2021", "max_issues_repo_head_hexsha": "539589f0ecc465fc5efb21679b36b22f88972f97", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Final Project/main.tex", "max_forks_repo_name": "PatThePhysicist/CTA-2021", "max_forks_repo_head_hexsha": "539589f0ecc465fc5efb21679b36b22f88972f97", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.0, "max_line_length": 610, "alphanum_fraction": 0.7833833458, "num_tokens": 1277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.44216857214785976}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[english]{babel}\n\\usepackage{graphicx, amsmath, mathtools, listings, color, caption, rotating, subfigure, fullpage, textcomp, enumerate, float, alltt, hyperref}\n\n\\lstset{\n\tlanguage=R,\n\tkeywordstyle=\\bfseries\\ttfamily\\color[rgb]{0,0,1},\n\tidentifierstyle=\\ttfamily,\n\tcommentstyle=\\color[rgb]{0.133,0.545,0.133},\n\tstringstyle=\\ttfamily\\color[rgb]{0.627,0.126,0.941},\n\tshowstringspaces=false,\n\tnumberstyle=\\tiny,\n\tnumbers=left,\n\tstepnumber=1,\n\tnumbersep=10pt,\n\ttabsize=2,\n\tbreaklines=true,\n\tbreakatwhitespace=false,\n\taboveskip={1.5\\baselineskip},\n  columns=fixed,\n  upquote=true,\n  extendedchars=true,\n}\n\n\\begin{document}\n\\begin{center}\n\\bf{A Primer on Calculating the Mann-Whitney Statistic}\n\\end{center}\nHello everyone,\nThe Mann-Whitney test is pretty useful. I told my discussion section it's one of the “bread-and-butter techniques” in nonparametric statistics, because if the data is actually normal, it's almost as efficient (i.e.: almost the same power) as the t-test (which relies on normality), and if the data isn't normal, it's often far more efficient. I wrote this walkthrough a few years ago to explain to a biostatistics class how to calculate the MW U-Statistic the way you discussed in lecture. I hope this helps some of you understand how to compute the statistic.\n\nI will use the dataset from page 284 (example 7.10.2) of “Statistics for the Life Sciences”, Fourth Edition, by Samuels, Witmer, and Schaffner, and test the hypothesis that the distribution of population 1 is equal to population 2, \n%%%%\nagainst the alternative that between the two at $\\alpha = 0.05$:\n%%%%\n\\begin{table}[H] \\center\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \\hline \n$X$ & 64 & 315 & 17 & 170 & 20 & 22 & 190 & \\\\ \\hline \n$Y$ & 13 & 14 & 15 & 6 & 29 & 16 & 18 & 22 \\\\ \\hline \n\\end{tabular}\n\\end{table}\n\n\\section{Order the Data}\nOrder the data so that the smallest values are first and the largest values are last. This makes it easier to do the later steps. Reproduced below are the two, ordered, samples.\n\\begin{table}[H] \\center\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \\hline \n$X$ & 17 & 20 & 22 & 64 & 170 & 190 & 315 & \\\\ \\hline \n$Y$ & 6 & 13 & 14 & 15 & 16 & 18 & 22 & 29 \\\\ \\hline \n\\end{tabular}\n\\end{table}\n\n\\section{Count Number of X Smaller Than Y}\nStarting with the first sample, $X$, count how many values in $Y$ are smaller than each value of $X$. For example, the first value of $X$ is 17. The $Y$ values 6, 13, 14, 15, and 16 are all smaller than 17, so the first number of observations in $Y$ smaller than the first observation of $X$ is 5. The second value of $X$ is 20, and in $Y$, values 6, 13, 14, 15, 16, and 18 are smaller. This means the number of observations smaller than the second observation is 6.\n\nFor the third number, 22, you'll notice there are ties with $Y$. Instead of giving the usual point value of 1 to a greater number, if you encounter a tie, add .5. Thus, the third observation of $X$ (22) is bigger than 6, 13, 14, 15, 16, 18, and ties with 22, for a score of 6.5. Repeat this process for all remaining values of $X$. You will get the following numbers of $X$'s greater than $Y$'s: 5, 6, 6.5, 8, 8, 8, 8. Note that the last four observations of $X$ (64, 170, 190, 315) are all greater than the largest number in $Y$, so the number of observations of $Y$ that are smaller than $X$ will be the same for the last four observations. The $K_1$ statistic is the sum of all those numbers. $5 + 6 + 6.5 + 8 + 8 + 8 + 8 = 49.5$.\n\nNow, there's a nifty property that shows that if you repeated the procedure but with $X$ and $Y$ flipped, their sum would be the product of the two sample sizes. We will leverage this fact to avoid having to do this procedure again. If $U_{lower} + U_{upper} = nm$, then $U_{lower} = nm - U_{upper}$. So the lower statistic will be $(7 \\cdot 8) - 49.5 = 6.5$.\n\n\\section{Look Up the Statistic in the Book}\nThe book is going to give you a range of probable lower and upper statistics for a few levels of significance. $X$ has 7 observations and $Y$ has 8, so $n=7$ and $m=8$ (if you confuse $n$ and $m$, it's okay, because it's symmetric--the table gives the same values as $n=8$ and $m=7$). The region to we need to hit is $(13,43)$. If our lower statistic is less than $13$ or our upper statistic is bigger than $43$, we would have evidence to reject our null hypothesis.\n\nAs a note, you only need to check either the upper \\emph{or} the lower value, because once you know the sample sizes and just one of the statistics (lower or upper), you can calculate the other one. \n\nOur statistic is 49.5. Since we said we would reject if the upper statistic was bigger than 46, we reject $H_0$, and conclude that there are differences in the distributions of $X$ and $Y$. \n\\section{How to do This in R}\nGet the data into R. Then use the function \\verb+wilcox.test+.\n\\begin{center}\n\\begin{lstlisting}\nX = c(64, 315, 17, 170, 20, 22, 190)\nY = c(13, 14, 15, 6, 29, 16, 18, 22)\nwilcox.test(X, Y)\n\\end{lstlisting}\n\n\\begin{alltt}\nWilcoxon rank sum test with continuity correction\ndata:  X and Y\nW = 49.5, p-value = 0.015\nalternative hypothesis: true location shift is not equal to 0\n\nWarning message:\nIn wilcox.test.default(X, Y) : cannot compute exact p-value with ties\n\\end{alltt}\n\\end{center}\nFor more information about the Wilcoxon-Mann-Whitney function in R, check out the help page: \\\\\\ \\url{http://stat.ethz.ch/R-manual/R-patched/library/stats/html/wilcox.test.html}. \\\\\nThe page also gives you information about how to specify alternative hypotheses, and whether to use a normal approximation. \n\\end{document}", "meta": {"hexsha": "52daca856f9027bd273b4fac0ab1647bdd67be91", "size": 5593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Primers and Walkthroughs/A Primer on Mann-Whitney.tex", "max_stars_repo_name": "christopheraden/Nonparametric-Statistics", "max_stars_repo_head_hexsha": "15fb5ec1cbae0e00649237a944602932f6ebaedf", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Primers and Walkthroughs/A Primer on Mann-Whitney.tex", "max_issues_repo_name": "christopheraden/Nonparametric-Statistics", "max_issues_repo_head_hexsha": "15fb5ec1cbae0e00649237a944602932f6ebaedf", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Primers and Walkthroughs/A Primer on Mann-Whitney.tex", "max_forks_repo_name": "christopheraden/Nonparametric-Statistics", "max_forks_repo_head_hexsha": "15fb5ec1cbae0e00649237a944602932f6ebaedf", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.0348837209, "max_line_length": 733, "alphanum_fraction": 0.7225102807, "num_tokens": 1734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7606506635289836, "lm_q1q2_score": 0.4421685705751626}}
{"text": "\t%to force start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Quantum Chemistry}\n\t\\lettrine[lines=4]{\\color{BrickRed}B}efore the reader to go further in reading this chapter of the book, we want to remind that the site deals mainly with Applied Mathematics and theoretical physics. Thus, we will address in this section only of theoretical chemistry (theoretical quantum  chemistry, theoretical thermochemistry, theoretical kinetic chemistry, etc).\n\t\n\tThis choice follows the changes of chemistry since the years 1980: form a largely descriptive science descriptive, it tends to become deductive. That is to say that in addition to experience, calculation methods are constantly growing and particularly since the development of modern computing that greatly helps chemists to numerical modeling.\t\n\t\n\tTheoretical chemistry, also named \"\\NewTerm{physical chemistry}\\index{physical chemistry}\" - application of methods from physics to chemistry - is too often seen as a discipline in itself. In fact, under this term any modern chemistry field is included. Thus, the investigation of any problem in advanced chemistry requires the assistance of theoretical chemistry (and this is lucky...) and the chemist must have a thorough knowledge of it. At the level of chemistry teaching as secondary branch, the role of physical chemistry is already evident: the result is an increase in the level of students, increase in the abstraction and therefore a risk in alienating the average student. Finally, the purpose is not to burden the knowledge by incorporating more new elements, but to convert the mode of approach of this discipline by substituting the most often encyclopedic knowledge statements by rational developments based on only a few assumptions and hypothesis that permits to deduce thanks to mathematics many properties thanks to colorraries.\n\t\n\tA good understanding of physical chemistry requires in our point of view necessarily to be familiar with quantum physics (\\SeeChapter{see chapter Atomistic}) to have at least one approach to what an atom is and its different electron orbits before talking about connections, different filling methods of electron orbits, redox, filling layers, and others...\n\t\n\tIn this sense, we will begin by studying the particular case of the hydrogen atom, which is crucial for the whole that will follow (study of polyelectronic atoms). It is therefore necessary for the reader to browse the next lines with all possible attention and to understand as best as possible the subtleties!\n\t\n\t\\subsection{Infinite three-dimensional rectangular potential}\n\tWe studied in details in the section of Corpuscular Quantum Physics the Bohr-Sommerfeld hydrogen atom using the results proved in the section of Special Relativity. This model emerged in a simplistic quantification (but not too much wrong as will discussed later below) of certain properties of matter.\n\t\n\tIn the section of Wave Quantum Physics, we studied alos in details the rectilinear infinite potential wall and the harmonic oscillator without giving many more examples. Now we will move towards to resolve problems closer to those useful in chemistry with the objective of studying the hydrogen-like atom.\n\t\n\tWe will now consider a particle moving freely in the three dimensional box below:\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/box_quantum_chemistry.jpg}\n\t\t\\end{center}\t\n\t\t\\caption[]{Three dimensional imaginary box in which the particle moves}\n\t\\end{figure}\n\n\tThe potential energy of the system is given by:\t\n\n\t\n\tAs in the one-dimensional case (\\SeeChapter{see section Wave Quantumn Physics}), the walls of infinite potential prevent the particle from leaving the box, and the wave function is nonzero only for position vector $\\vec{r}$ being inside the box. It  necessarily vanish when one of the walls is touched. The Schrödinger equation we have to solve is (\\SeeChapter{see section Wave Quantumn Physics}):\n\t\n\tand boundary conditions are:\n\t\n\tNote that the Hamiltonian can be written as the sum of the Hamiltonian in each axis (we speak of the hamiltonian operators of course!). So we have:\n\t\n\twhere\n\t\n\trelations that we have proved the origin in details in the section of Wave Quantum Physics of this book.\n\t\n\tSuch a form is named a \"\\NewTerm{separable form}\\index{chemical separable form}\": the Hamiltonian is the sum of individual operators $H_i$ each depending only on one variable or degree of freedom $q_i$. This form reflects the independent nature of the movements described by the variables $q_i$.\n\t\n\tRemember that the joint probability of two independent events is the product of the individual probabilities of the two events separately (\\SeeChapter{see section Probabilities}). We therefore expect that the presence probability density in space (\\SeeChapter{see section Wave Quantum Physics}) with multidimensional configuration is, if the Hamiltonian of separable form, a simple individual probability density product. In fact, the separable form of the Hamiltonian permits the separation of variables on the wave function itself.\n\n\tLet us write the solutions of the Schrödinger equation under the form:\n\t\n\tof a product of three factors each depending only of one coordinated.\n\n\tSubstituting this notation in the Schrödinger equation, we get without technical developments (elementary algebra):\n\t\n\tor, by dividing both sides of this equation by $\\xi(x)\\vartheta(y)\\zeta(z)$:\n\t\n\twhich is a much more aesthetic and easier to remember.\n\t\n\tThis equation requires that the sum of the three terms in the left-hand side is equal to a constant in the context of a conservative system (that is what often interested chemists)! Each of these three terms depending only on one and only one variable, so that their sum is equal to a constant, it is necessary that each term is itself constant! In fact, by taking the derivative of both sides of the above equation with respect to $x$, for example, we have:\n\t\n\tmeaning that equation although  must be a constant which we will denote equation (as this term expresses an energy). We then have (surprise...):\n\t\n\tSimilarly, we get:\n\t\n\tNote that each of the separate equations that we have just obtained, for the movement of the particle in the three spatial directions, is a Schrödinger equation in a one-dimensional box. Thus, the three relations previously obtained independently describe each movement in the respective $x, y, z$ directions, limited to the respective ranges:\n\t\n\tand must be respectively  solved with boundary conditions:\n\t\n\tThe results obtained in the section of Wave Quantum Physics when solving the Schrödinger equation in the case of straight wells give us directly:\n\t\n\tIn summary the stationary states of the particle in the three-dimensional box are specified by three positive integers quantum numbers $\\lambda, \\mu, \\nu$. The wave function is finally:\n\t\n\tand its respective energies (eigenvalues):\n\t\n\tThe variable separation technique detailed above, is applicable only because the Hamiltonian is in separable form. It comes automatically therefore the three-dimensional probability density $\\vert \\Psi(x,y,z) \\vert^2$ is the product of probability density $\\vert \\xi_\\lambda(x)\\vert^2,\\vert \\vartheta_\\mu(y)\\vert^2,\\vert \\zeta_\\nu(z)\\vert^2$, as we had anticipated it. We also note that the energy of movement in three dimensional space is the sum of energy movements in all three spatial directions: the independence of these three directions or degrees of freedom, implies the additivity of their energy.\n\t\n\t\\subsection{Molecular Vibrations}\n\tWe studied in the Wave Quantum Physics section the harmonic oscillator. Now it in is chemistry that we will use all the power of the results obtained during the study of this system.\n\t\n\tThe harmonic oscillator is a model of molecular vibrations, and is represented by a type of parabolic potential as:\n\t\n\tfor a diatomic molecule. But we have proved in the section of Nuclear Physics that $c^{te}=m\\omega_0^2$ so that we finally have for a diatomic molecule:\n\t\n\tFor a polyatomic molecule, we have verbatim (by the additivity of energy):\n\t\n\tQuantities $\\omega_0$ and $\\omega_i$ are the vibration frequencies (or rather more correctly: the pulsation) of a molecule, diatomic in the first case and polyatomic in the second case. In the first equation, the variable $x$ represents the elongation of the bond between the two atoms $A$ and $B$ (as with a spring) in a diatomic molecule, that is to say $x=R-R_{eq}$, where $R$ is the instantaneous length of this bond, and $R_{eq}$ is its equilibrium value.\n\t\n\tIn the case of a polyatomic molecule, the potential describing molecular vibrations takes a separable form in terms of summation above only if one considers special variables $q_i$ denoting collective motions of nuclei, and which are named \"\\NewTerm{normal vibration modes}\\index{normal vibration modes}\".\n\t\n\tWe also saw in the section of Wave Quantum Physics that the Hamiltonian of a diatomic molecule (problem of the harmonic oscillator) can be written as\n\t\n\tFor a polyatomic molecule that relationship becomes logically:\n\t\n\tThe Hamiltonian above is clearly a type of separable form: it is a sum of one-dimensional Hamiltonians, each depending only on a single mode $q_i$ as variable, describing this mode as a unique spring or harmonic unit mass ($m=1$) oscillator and of pulse oscillation $\\omega_i$. Therefore, a separation of variables $q_i$ is possible, reducing the Schrödinger time independant into a number of equations of the same type as that of a one-dimensional harmonic oscillator. So we need just o know the expression of the wave function for a one-dimensional harmonic oscillator, what we already have done in the section of Wave Quantum Physics where we got:\n\t\n\tand:\n\t\n\tThe figure below shows the graph of the first wave functions of the above relation as well as that of their respective presence probability densities. We can see the same modal structures as those specific to functions of a particle in a one-dimensional box:\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/one_dimensionnal_oscillator.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Wave functions and probability density of a one-dimensional harmonic oscillator}\n\t\\end{figure}\n\tAbove the first energy levels of a one-dimensional oscillator with \\texttt{\\textbf{(a)}} their associated eigenfunction, \\texttt{\\textbf{(b)}} the  associated probability distribution of presence.\n\t\n\tIn the limit of very large values of $n$, the probability distribution approximates more and more of that predicted by classical mechanics, the oscillator lies for the most of the time in the vicinity of the turning points defined by the intersection of potential $E_{\\text{pot}}$ with the level of $n$. This trend is illustrated below:\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/one_dimensionnal_oscillator_limit.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Probability density function of a one-dimensional harmonic oscillator for large $n$}\n\t\\end{figure}\n\tFor a polyatomic molecule the expression of quantified energy therefore becomes:\n\t\n\tand eigenfunctions/eigenstates become:\n\t\n\twith:\n\t\n\tThe last two relations are very important because they allow among others to:\n\t\\begin{itemize}\n\t\t\\item Predict the spectrum of the molecule (spectroscopy)\n\t\t\\item To study the energy bands (where does the bands of valence and conduction comes from)\n\t\t\\item To locate the bonds between atoms and thus the chemical properties\n\t\\end{itemize}\n\t\n\t\\subsection{Hydrogenoid Atom}\n\tWe consider here the quantification of a generic system made of two bodies (particles) interacting with each other and moving in a three-dimensional space. We will be prove at first that, even if the separation of dynamic variables describing individually each of the two bodies is impossible, for cons, the overall movement system (the center of mass) and internal movement, also said \"relative motion\", are separable. In addition, if the potential is centrosymmetric, the internal movement may also be decomposed into a rotational movement and radial movement. The quantification of the rotational movement is intimately connected to that of angular momentum.\n\t\n\tHere we focus on the mechanics of an atomic system having only one electron. This is a two-particle system: a nucleus of mass $M$ and charge $+Zq_e$, and an electron of mass $m_e$ and of charge $-q_e$.\n\t\n\tThe atomic system is described by the following Hamiltonian\n\t\n\tRemember that in the section of Wave Quantum Physics we had proved during our study of functional operators:\n\t\n\tand remember also that $\\vec{r}_e$ and $\\vec{R}_n$ are respectively the position vectors of the electron and nucleus in the prior-previous relation.\n\t\n\tThe potential energy being given by (\\SeeChapter{see section Electrostatic}):\n\t\n\tThe movements of the two particles are correlated because the two charges interact through their mutual electrical field. We can not make a separation between variables $\\vec{r}_e$ and $\\vec{R}_N$. By cons, a separation of variables is possible with the coordinate of the center of mass (see the definition of the center of mass in the section of Classical Mechanics):\n\t\n\tand the relative coordinate of the electron relative to the nucleus:\n\t\n\tWe obtain therefore:\n\t\n\tand:\n\t\n\tThe Hamiltonian in the center of mass repository will therefore be written:\n\t\n\twhere $M_{tot}=m_e+M$ is the total mass of the system and:\n\t\n\tis its reduced mass.\n\t\n\tWe clearly see that the Hamiltonian $H$ is this time set in a separable form and we can write it as follows:\n\t\n\twith:\n\t\n\tIn terms of the coordinates $\\vec{R}_{\\text{CM}}$ and $\\vec{r}_{\\text{rel}}$, the function describing a stationary state of the two-body system is a product of individual wave functions (recall that the joint probability of two events is the product of probabilities), one for the movement of the center of mass and the other for the relative movement:\n\t\n\tand the energy of this state is the sum of the respective energies of movements:\n\t\n\twith:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis approach of separating the wave function into the composition of a wave function of the center of mass and the relative movement is also used in the context of the study of poly-electronic atoms, but with one difference: as the nucleus is much more massive than the processing electrons (in approximation ...), the center of mass is assimilated to the nucleus of the atom and the relative motion to the entire electron cloud. This approximate approach is well known under the designation \"\\NewTerm{Born-Oppenheimer approximation}\\index{Born-Oppenheimer approximation}\".\n\t\\end{tcolorbox}\n\tWhere the Hamiltonian appearing in the first of these relations has been defined above as being:\n\t\n\tThis movement is that of a particle of mass $M_{tot}$ in a three-dimensional box of infinite volume. Eigenvalues and eigenfunctions for this movement has already been obtained in our previous study, we will restrict ourselves to the study of separate equation for the relative movement, or internal movement. As no confusion will be possible between different Hamiltonians, we let down, to simplify the notations, the \"rel\" word in subscript.\n\tWith $H_{\\text{rel}}$ given by the relation that we have proved previously:\n\t\n\tand the relation (as proved above):\n\t\n\tthen we obtain the Schrödinger equation for the relative motion:\n\t\n\tor written differently:\n\t\n\tNote that in the case where the potential energy $E_{\\text{pot}}$ is a centrosymmetric source, that is to say it depends only on the length of the position vector $\\vec{r}$, and not its orientation, the previous equation, written in Cartesian coordinates, is inseparable. Indeed, in Cartesian coordinates, the length $\\vec{r}$ is given by:\n\t\n\tand the potential energy can not be separated into three components, each depending only one of the three variables $x, y, z$. The Hamiltonian is therefore still not a separable form and so we did not meet our target. However, the above equation is separable at the moment we make a change of coordinates to spherical coordinates. Indeed, in this coordinate system, the potential depends on only on one of the three spherical variables: the radius $r$. It is independent of the two angles $\\theta$ and $\\phi$.\n\t\n\tReferring to the result obtained in the study of the Laplace expressions in different coordinate systems, in the section of Vector Calculus, we got for the Laplacian of a scalar field in spherical coordinates the following expression:\n\t\n\tThe hamiltonien:\n\t\n\tthen becomes (simple distribution and new way to note):\n\t\n\twhere:\n\t\n\tis the kinetic energy operator for the radial movement of the electron relative to the nucleus, and $L^2$ is the squared \"associated\" operator of the angular momentum vector:\n\t\n\tThe term:\n\t\n\tis therefore an energy associated with the angular momentum $J$ (\\SeeChapter{see section Classical Mechanics}).\n\t\n\tTo understand the nature of this operator $L^2$ a detour by the notion of rigid rotor will help.\n\t\n\t\\subsection{Rigid Rotator}\n\tIf we now consider the case of a system named \"\\NewTerm{rigid rotor}\\index{rigid rotor}\" where we neglect (\"restrict\" would be a more appropriate term ...) the degrees of freedom of oscillation (this is the system that are the study case for linear diatomic or polyatomic molecules), the only coordinates being into play are the angles $\\theta$ and $\\phi$ which fix the orientation of the rotator.\n\t\n\tThus, in this case $r$ is fixed and we have:\n\t\n\tand in view of the constraints on the potential, it is normally quite easy to understand why the rotator is said to be \"rigid\". In the above case, the Hamiltonian is reduced to:\n\t\n\t\n\tFor the rest, we associate the operator $L^2$ to an angular momentum, for the simple reason that he has the units... Indeed, let us recall that we have prove in the section of Wave Quantum Physics that when the spin is zero (so as part of our study of the hydrogenoid  atom here, the spin will not be taken into account in the first instance) and that we are dealing with a single particle then the angular momentum (which we will denote by $L$ instead of $b$) is given by:\n\t\n\twhere the components of the vector $\\vec{l}$ are also natural numbers. By doing this similarity, we can then write the Schrödinger equation in the form:\n\t\n\tLet us recall we got in the section of Wave Quantum Physics that:\n\t\n\tby the vector product.\n\t\n\tWe go now to rectangular coordinates $x, y, z$ coordinates to spherical coordinates $r,\\theta,\\phi$. Remember for this (\\SeeChapter{see section Vector Calculus}) that:\n\t\n\tand that:\n\t\n\tNow let us express the total differentials:\n\t\n\tThese relations can be written as an orthogonal transformation of the total differential $\\mathrm{d}r,r\\mathrm{d}\\theta,r\\sin(\\theta)\\mathrm{d}\\phi$ by:\n\t\n\tor by the inverse transformation (if required ... it is enough to check that the two transformation matrices multiplied together give the identity matrix):\n\t\n\tIt results of this for example:\n\t\n\tand finally (the method for the second and third lines is the sam as for the first!):\n\t\n\tThus, taking into account these relationships, we obtain for example, in the case of the operator:\n\t\n\tthe following developments:\n\t\n\twhich gives the following result:\n\t\n\tBy doing the same with:\n\t\n\tby doing the same developments:\n\t\n\twe have the following result:\n\t\n\tAnd for finish with:\n\t\n\tby doing the same developments:\n\t\n\twe get the following result:\n\t\n\tFinally, we have only little freedom for the movement of our rigid rotor (as it is very rigid ...) and we can write for the Schrödinger equation:\n\t\n\twhere $H_\\text{rot}$ is for recall, seen as the functional linear operator, and the total energy $E$ as its corresponding eigenvector.\n\n\tTherefore, we can write that angular momentum operator is given by (we change the notation so to not confuse subsequently operator and eigenvalue according to the comments we made during the satement of the postulates of Wave Quantum Physics in the corresponding section):\n\t\n\tThus, the eigenfunctions $\\Phi(\\phi)$ of $\\hat{L}_z$ are solutions of the equation to the eigenvalues and eigenfunctions:\n\t\n\tthat is to say the differential equation:\n\t\n\twhere $L_z$ is obviously the eigenvalue of $\\hat{L}_z$. A simple solution to this differential would be:\n\t\n\twith for uniformity condition, depending on the properties of complex number (\\SeeChapter{see section Numbers}):\n\t\n\tThis mathematical condition imposes the obvious and remarkable following quantification:\n\t\n\twhere (recall) $m_l$ is the magnetic quantum number.\n\n\tKnowing that (\\SeeChapter{see section Corpuscular Quantum Physics}):\n\t\n\tWe can write:\n\t\n\tTherefore, we falls back on the result(s) that we get in the section of Corpuscular Quantum Physics and Wave Quantum Physics:\n\t\n\tWhich is quite satisfactory, even remarkable and enjoyable (to not say it ...).\n\t\n\tThus, the measurement of a component of the angular of $\\hbar$ which appears as a natural unit of angular momentum.\n\tThe common eigenfunctions (!!!) to the operators $\\hat{L}^2$ and $\\hat{L}_z$ are in a more general framework necessarily of the form (method of separation of variables ):\n\t\n\tAs the rotator is rigid, we have $R(r)=c^{e}$. This factor will eliminate itself in the equation of eigenvalues and eigenfunctions that we will determine further below. So we can not take it into account if we ant. Finally, we can write thanks to previous developments:\n\t\n\tWhich brings us to the equation to the eigenvalues and eigenfunctions:\n\t\n\tThat is to say\n\t\n\tTherefore:\n\t\n\tBy putting:\n\t\n\tand therefore:\n\t\n\twe get a \"Fuchs\" like differential equation given by:\n\t\n\tTherefore finally:\n\t\n\tWhose coefficients have poles (singularities) in $\\xi=\\pm 1$. But, let us recall that we have:\n\t\n\tSo that we often find the previous differential equation in the following form in the books after elementary algebra factorization of some terms:\n\t\n\tA nontrivial solution being, knowing the Fuchs of differential equations, that it is customary to name the \"\\NewTerm{associated Legendre polynomials}\\index{associated Legendre polynomials}\" (although this is not strictly speaking a polynomial ....) because containing partly Legendre polynomials (\\SeeChapter{see section Calculus}):\n\t\n\tthat you can check by injecting this solution in prior-previous differential equation.\n\t\n\t...Following the request of a reader is an example of verification before continuing:\n\t\n\tThe $m_l=l=0$ is immediate. Then let us consider the case where $m_l=l=1$:\n\t\n\tThus:\n\t\n\tAnd we inject in it the associated Lagrange polynomial:\n\t\n\tTherefore:\n\t\n\tWhich give after a small simplification:\n\t\n\tBy derivating:\n\t\n\tLet's focus on the left part to see what it is equal to by putting everything to a common denominator:\n\t\n\tBy simplifying the numerator, it should be zero. Let us see this by simplifying a first time:\n\t\n\tby distributing:\n\t\n\tWhich is indeed equal to zero!!!\n\n\tSo finally, we have common eigen functions (because remember that the Legendre polynomials are orthogonal to each other) that will be:\n\t \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is not necessary to make complicated calculations to calculate the normalizaton factor of the exponential, as in the context of an integration over all space, the three factors of $Y_{m_l,l}(\\theta,\\phi)$ are independent of each other. Thus the integral is the product of the integrals (\\SeeChapter{see section of Differential and Integral Calculus}).\n\t\\end{tcolorbox}\n\tFinally, we must find $N_{m_l,l}$ such that:\n\t\n\tand we will see (what we will prove just below) that:\n\t\n\tIn summary, we write (we should rather write \"we will write\"...)\n\t\n\twhere we have omitted the factor $(-1)^l$ since in any case this term in the module of this function this term multiplies himself and then gives $(-1)^{2l}=1$.\n\nLet us check now the framed previous boxed relation (warning this is a bit long and it is advisable to read it several times):\n\n\tWe consider the functions defined by:\n\t\n\twhere:\n\t\n\twith:\n\t\n\tThe aim will therefore be to prove that these functions are orthogonal first and then find the constants $N_{m_l,l}$ such that $||Y_{m_l,l}||$. In short we will have to roll up the sleeves... of our brain...\n\n\tFirst, let us prove for future needs that:\n\t\n\t\\begin{dem}\n\tIf and only if $l=m_l=0$ the equality is obvious. Let us suppose that $l\\geq 1$ (thus the general case outside the obvious previous case) and given $P$ a real polynomial of degree $\\leq l-1$.\n\n\tLet us put:\n\t\n\tLet us prove (functional dot product):\n\t\n\tin  $\\mathcal{C}(x\\in[-1,1],\\mathbb{R})$.\n\t\n\tIndeed, let us recall that we made the change of variable:\n\t\n\tIntegrating by parts, we get:\n\t\n\tlet us notice that for any $0\\leq j\\leq m_l-1$, $\\dfrac{\\mathrm{d}^j}{\\mathrm{d}x^j}Z(x)$ is equal to zero in $x=\\pm 1$ that is to say:\n\t\n\tTherefore (by extension), the above relation simplifies to:\n\t\n\tAfter $m_l$ integration by parts equation, we get:\n\t\n\tIf $\\deg(P)<m_l$ then the above expression shows that trivially:\n\t\n\tIf $\\deg(P)\\geq m_l$ then by putting:\n\t\n\tWe get:\n\t\n\tlet us notice once again that $\\dfrac{\\mathrm{d}^j}{\\mathrm{d}x^j}h(x)$ vanishes in $x=\\pm 1$ for any $j\\leq m_l-1$, that is say:\n\t\n\tBy integrating by parts $m_l$the previous expression, we find:\n\t\n\tbut $h$ is an polynomial of degree $m_l+\\text{deg}(P)$.\n\t\n\tIndeed, the first factor is of degree $2m$ and the $m_l$th derivative of $P(x)$\" is of degree $P-m_l$, therefore:\n\t\n\tSo $\\dfrac{\\mathrm{d}^{m_l}}{\\mathrm{d}x^{m_l}}h(x)$ is a polynomial of degree $\\deg(P)\\leq l-1$ and knowing that $\\dfrac{\\mathrm{d}^l}{\\mathrm{d}x^l}(1-x^2)^l$ is to a given constant equal to the $l$-th Legendre polynomial (\\SeeChapter{see section Calculus}) we then have:\n\t\n\tSo we have just proved that $\\dfrac{\\mathrm{d}m_l}{\\mathrm{d}x^{m}_l}$ is orthogonal to any polynomial of degree $\\leq l-1$.\n\t\\begin{flushright}\n\t\t$\\square$  Q.E.D.\n\t\\end{flushright}\n\t\\end{dem}\n\t$\\dfrac{\\mathrm{d}^{m_l}}{\\mathrm{d}x^{m_l}}Z$ is a polynomial of degree $l$ (its just enough to check for some values) so therefore let us search if there is a constant $c^{te}\\in\\mathbb{R}$ such that:\n\t\n\twith for recall:\n\t\n\tWe can determine the constant $c^{te}$ by comparing the dominant coefficients of the polynomials:\n\t\n\tThe dominant coefficient of $\\dfrac{\\mathrm{d}^{m_l}}{\\mathrm{d}x^{m_l}}Z$ is:\n\t\n\tand the dominant coefficient of $\\dfrac{\\mathrm{d}^l}{\\mathrm{d}x^l}(1-x^2)^l$ is:\n\t\n\tTherefore:\n\t\n\tThat is to say:\n\t\n\tSo we would have for $l\\geq m_l\\geq 0$ (we integrate parts we integrate as many times as necessary to the left and right - necessarily - to achieve this result):\n\t\n\tNow let us establish a remarkable relation that should perhaps exist between $P_{-m_l,l}$ and $P_{m_l,l}$ (and which will be useful to us later). Let us assume for this $0\\leq m_l\\leq l$ and remember that at the base:\n\t\n\tSo that brings us to write (nothing special):\n\t\n\tBy the previous results ($(-1)^{m_l}=(-1)^{-m_l}$):\n\t\n\tthis leads us to write:\n\t\n\tTherefore we get:\n\t\n\t\n\tFirst, let us prove that:\n\t\n\twhere $P_l$ is the $n$-th Legendre polynomial (hence the origin of the name of \"associated  Legendre polynomial\" ...).\n\t\\begin{dem}\n\tFirst, we have proved that the Legendre polynomials satisfy the following recurrence relation (\\SeeChapter{see section Calculus}):\n\t\n\tfor $n\\geq 1$.\n\tMultiplying the above equation by $x^{n-1}$ and integrating, we get:\n\t\n\tBut:\n\t\n\tLet us recall that the $P_{n+1}$ polynomials form an orthogonal basis of which the polynomials that generate it are of increasing degree from $0$ to $n$, so a lower order polynomial - expressed in a sub vector space - will always be perpendicular to the vectors (polynomials) generating the higher dimensions. So if we take the example of $\\mathbb{R}^3$ generated by the basis $(\\vec{e}_1,\\vec{e}_2,\\vec{e}_3)$, then a vector $\\vec{v}$ expressed by the linear combination of $(\\vec{e}_1,\\vec{e}_2)$ will always be perpendicular to $\\vec{e}_3$ and therefore a zero scalar product with it.\n\n\tAnd  therefore it follows:\n\t\n\tLet us put:\n\t\n\tThe previous expression becomes (remember $P_0(x)=1$):\n\t\n\tThus by induction:\n\t\n\t\n\tFurthermore as:\n\t\n\tWe then for for the prior-previous relation the denominator which can obviously be rewritten:\n\t\n\tThen we have:\n\t\n\tSo in the end we can simplify the denominator as follows:\n\t\n\tand:\n\t\n\tSo we have well proved that (just in case ... you would not follow anymore the initial target ...) that:\n\t\n\t\\begin{flushright}\n\t\t$\\square$  Q.E.D.\n\t\\end{flushright}\n\t\\end{dem}\n\tLet us attack us finally to what interests us. That is to say, prove that:\n\t\n\t\\begin{dem}\n\tIf $m_l\\neq j$ then:\n\t\n\twhere:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tLet us recall that the Jacobian in spherical coordinates is $r^2\\sin(\\theta)$ (\\SeeChapter{see section of Differential and Integral Calculus}) and as the integrated function above is not dependent on $r$, we have take out the term $r^2\\mathrm{d}r$ of this integral (by cons we will meet again the same term in the function $R(r)$ present in the Schrödinger equation).\n\t\\end{tcolorbox}\n\tAnd with:\n\t\n\tIf $l>k$ and $m_l=j$ then the dot product of:\n\t\n\tis simplified to:\n\t\n\tBy doing the change of variable $x=\\cos(\\theta)$ we get:\n\t\n\tLet us suppose that $m_l\\geq 0$:\n\t\n\twhere $P_l(x)$ is the $n$-th Legendre polynomial. Thus the expression of the dot product becomes:\n\t\n\tIf we put:\n\t\n\tthen the relation becomes:\n\t\n\tIntegrating by parts $m$ times the expression above we get:\n\t\n\tBut $\\dfrac{\\mathrm{d}^{m_l}}{\\mathrm{d}x^{m_l}}h(x)$ is a polynomial of degree $k$. Knowing that $l>k$, the latter integral is zero for the same reasons as those mentioned above. Therefore:\n\t\n\tIf $m_l<$ then we have proved that:\n\t\n\tand therefore:\n\t\n\tas $-m_l\\geq 0$.\n\t\n\tIt only remains to us to treat the case $m_l=j,l=k$. Let us suppose again that $m_l\\geq 0$. So as before we have:\n\t\n\tand:\n\t\n\tLet us put:\n\t\n\tThe relation then becomes:\n\t\n\tBy integrating $m$ times by parts, we find:\n\t\n\t$\\dfrac{\\mathrm{d} ^{m_l}}{\\mathrm{d} x^{m_l}}h(x)$ is a polynomial of degree $l$ which dominant coefficient is equal to:\n\t\n\t$P_l$ being orthogonal to any polynomial of degree strictly less that $l$, the expression can be written:\n\t\n\tBut, we have proved that:\n\t\n\ttherefore:\n\t\n\tIf $m_l\\leq 0$ we know that we get the result.\n\t\\begin{flushright}\n\t\t$\\square$  Q.E.D.\n\t\\end{flushright}\n\t\\end{dem}\n\tFinally this result gives us also the normalization condition:\n\t\n\tAnd so finally:\n\t\n\tis indeed an orthonormal family. Either explicitly (we reintroduce the factor $(-1)^l$):\n\t\n\tFinally, after this highly mathematical interlude (but instructive for the methodology of approach), we see (which is logical) that ot each value of $l$ correspond therefore $2l + 1$ eigenfunctions $Y_{m_l,l}(\\theta,\\phi)$. We also say that the value $\\hbar l(l+1)$ is $2l + 1$ times degenerated since:\n\t\n\tHere are some values of the function  $Y_{m_l,l}(\\theta,\\phi)$ that generates what we commonly name \"\\NewTerm{spherical harmonics}\\index{spherical harmonics}\":\n\t\n\tLet's see some plots of these beautiful spherical harmonics that can be obtained with Maple 4.00b by using the following command (this is the $6$th spherical harmonic function above):\\\\\n\n\t\\texttt{>plot3d(Re(sqrt(15/(8*Pi))*(sin(theta)*cos(theta)*exp(I*phi)))\\string^2,phi=0..2*Pi,\\\\theta=0..Pi, coords=spherical,scaling=constrained,numpoints=5000,axes=frame);}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/chemistry/orbit_rigid_rotator_hydrogen_y12_maple.jpg}\t\n\t\t\\caption{Plot of the spherical harmpnics $Y_{1,2}$}\n\t\\end{figure}\n\t\n\t\\begin{itemize}\n\t\t\\item $Y_{0,0}$ (corresponding to $n=1$!) gives a sphere (constant value regardless $\\theta,\\phi$) which the probability density can be represented by the \"\\NewTerm{photographic card}\\index{photographic card (chemistry)}\" or \"\\NewTerm{density map}\\index{density map (chemistry)}\" (the density in a given state is represented by the density of light spots on a dark background):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/density_map1s.jpg}\t\n\t\t\t\\caption{$1s$ density map}\n\t\t\\end{figure}\n\t\tRepresenting the possible $1s$ orbits.\n\n\t\t\\item $Y_{0,1},Y_{1,1},Y_{-1,1}$ give (for $n=2$  at least!):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/harmonic_functions_2p.jpg}\t\n\t\t\t\\caption{$2p$ orbitals (spherical harmonics)}\n\t\t\\end{figure}\n\t\tWhich represents the possible $2p$ orbits, the probability density function can be represented by its density and isodensity maps:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/density_map2p.jpg}\t\n\t\t\t\\caption{$2p$ density map}\n\t\t\\end{figure}\n\n\t\t\\item $Y_{-2,2},Y_{-1,2},Y_{1,2},Y_{2,2},Y_{0,2}$ give (for $n=3$  at least!):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/harmonic_functions_3d.jpg}\t\n\t\t\t\\caption{$3d$ orbitals (spherical harmonics)}\n\t\t\\end{figure}\n\t\tRepresenting $5$ possible $3d$ centrosymmetric  orbits, which the probability density can be represented by (the last two maps represent $Y_{0,2}$) the following density maps:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/density_map3d.jpg}\t\n\t\t\t\\caption{$3d$ density map}\n\t\t\\end{figure}\n\n\t\t\\item $Y_{-3,3},Y_{-2,3},Y_{-1,3},Y_{1,3},Y_{2,3},Y_{3,3},Y_{0,3}$ give (for $n=4$  at least!):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/harmonic_functions_4f.jpg}\t\n\t\t\t\\caption{$3d$ orbitals (spherical harmonics)}\n\t\t\\end{figure}\n\t\tRepresenting $7$ possible $3f$ anti-centrosymmetric  orbits, which the probability density can be represented by (in the order: $Y_{0,3},Y_{\\pm 1,3},Y_{\\pm 2,3},Y_{\\pm 3,3}$) the following density maps:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/density_map4f.jpg}\t\n\t\t\t\\caption{$4f$ density map}\n\t\t\\end{figure}\n\t\\end{itemize}\n\tThe above results thus lead us to write:\n\t\n\tSubstituting this in the Schrödinger equation:\n\t\n\tWe get ($T_r=0$ in the rigid rotor but $\\neq 0$ in the case of the hydrogen atom):\n\t\n\tAs there is in this relation no operator which acts on $Y_{m_l,l}(\\theta,\\phi)$, we can simplify to obtain:\n\t\n\twhich we see in the general case of the isolated atom that energy levels are no longer dependent of $m_l$ (due to the spherical symmetry of the potential). Then we say that the levels corresponding to the same values of $n$ and of $l$ are all merged whatever the values of $m_l$.\n\t\n\tIn the case where $E_\\text{pot}$ derived from the $1 / r$ Coulomb potential , this radial equation leads us to a normalizing solution of $R (r)$ (different from zero then...) only for values of the energy corresponding to the following quantization law (well ... what a coincidence, we fall back on the expression proved in the old models of Corpuscular Quantum Physics!):\n\t\n\twhere $R_H$ is the Rydberg constant as we determined in the section of Corpuscular Quantum Physics. Thus, in this case the energy levels corresponding to the same values of $n$ are all merged regardless of the value of $l$.\n\n\tFor a given value of the principal quantum number $n$ (recall that we saw in the section of Corpuscular Quantum Physics that $l\\leq n-1$), it is possible to verify that there are several solutions to the function $R(r)$ according to the value of the azimuthal quantum number $l$. Hence the identification of the solutions by the pair $(n, l)$. We note them $R_{n,l}(r)$. These are real functions of the variable $r$ (it just enough to check ... because if they work then they satisfy the Schrödinger equation, we will make an example a little further below):\n\t\n\twhere (beware some books give this value in natural units!):\n\t\n\tis the equivalent of the Bohr radius (for the reduced mass) that we have determined in the section of Corpuscular Quantum Physics  with the difference that here we have a reduced mass instead of a single mass.\n\t\n\tHowever let us see if our Schrödinger equation is satisfied (taking $n=1,l=0$ for example):\n\t\n\tWhich corresponds well to the expected result.\n\n\tWhich graphically gives us the radial part $R_{n,l}(r)$:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/chemistry/radial_functions.jpg}\t\n\t\t\\caption{Plot of few radial functions $R_{n,l}(r)$}\n\t\\end{figure}\n\tLet us study a little more in detail the radial function in the case of the hydrogen atom!:\n\n\tIn the case of the atomic orbital $1s$ (!special case but we could do the same calculations as the following with all other orbital!) so we have for the hydrogen atom:\n\t\n\tSo it is well a decreasing exponential function as shown in the graphic above. Before continuing let us recall that (\\SeeChapter{see section Wave Quantum Physics}) :\n\t\n\tBut, in spherical coordinates (see the beginning of this section):\n\t\n\tIt then comes as we have seen earlier above:\n\t\n\tThen if follows that:\n\t\n\tWith this result we can calculate the radial probability of finding the electron on each atomic orbital! So, it comes immediately with the previous result:\n\t\n\tSo in the case of our $1s$ atomic orbital:\n\t\n\tIt is now super interesting to calculate the point $r$ point where the probability of finding the electron is maximum on the $1s$ orbital!\n\n\tFor this, we notice that $\\dfrac{P_r}{\\mathrm{d}r}$ reaches a maximum when we have trivially:\n\t\n\tTherefore:\n\t\n\tTherefore:\n\t\n\tWhich is remarkable, because we find the result of the Bohr model (\\SeeChapter{see section Corpuscular Physics})!!!\n\n\tTo summarize a little all this, the stationary states of the hydrogen atom are specified by three quantum numbers $n\\in\\mathbb{N}^{*},l\\leq n-1,|m_l|\\leq l$ and the Schrödinger wave function given finally by:\n\t\n\tWe then the following traditional nomenclature in the case of the hydrogen atom:\n\t\n\tWe can include the spin of the electron in the description of the electronic structure of the atom. If we treat the spin as an additional degree of freedom then the lack of interaction term between conventional degrees of freedom (positions in real space) and the spin interaction named \"\\NewTerm{spin-orbit coupling}\\index{spin-orbit coupling}\" in the previous Hamiltonian implies that we can write the total wave function, spin included, in the form of a product:\n\t\n\t\n\tSo taking into account everything seen so far we have the following density plots:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/chemistry/hydrogen_full_wave_function.jpg}\t\n\t\\end{figure}\n\t\n\twhere we added the spin quantum number $m_s=\\pm 1/2$ (\\SeeChapter{see section Corpuscular Quantum Physics}).\n\n\tThe same remark we made in the section of Corpuscular Quantum Physics then applies: the levels remain $2n^2$ times degenerated.\n\n\tLet us do example. So we have:\n\t\n\tThus for $1$ proton:\n\t\n\tNow let us apply the 5th postulate of wave quantum physics (see section of the same name) for unlike earlier, not calculate the modal radius (most likely one), but the average radius! Then, as the operator position is the position itself (\\SeeChapter{see section of Wave Quantum Physics}), the average value of the radius will be given by (do not forget that we are in spherical coordinates!):\n\t\n\tUsing the Fubini theorem proved in the section of Differential and Integral Calculus we can write (well in this case it's even trivial that we have the right to write this... we should not even have to mention Fubini theorem normally...):\n\t\n\tFor the last integral, we will use integration by parts:\n\t\n\tThus finally:\n\t\n\tOr more explicitly:\n\t\n\tTherefore the average distance of the electron to the core is equal to $3/2$ times that of the Bohr radius so further that the most likely radius we have calculated earlier above (and which corresponds to Bohr radius)!\n\t\n\t\\subsubsection{Potential Profile}\n\tLet us come back on an important point that is often used in physics book but never proved (as far as we know): the quantum potential profile of the hydrogen-like atom. Many books sometimes speak of \"\\NewTerm{harmonic model of the atomic bonding}\\index{harmonic model of the atomic bonding}\" but it seems that this is a priori rather a misnomer.\n\n\tSo we saw much earlier in this section that:\n\t\n\tIn view of the interpretation of the three terms of the Hamiltonian, it is customary to say that the two terms:\n\t\n\tconstitute the \"\\NewTerm{effective potential energy}\\index{effective potential energy}\", thus explicitly:\n\t\n\tSo the first term is (logically) repulsive while the second is attractive. A plot in Maple 4.00b of the effective potential energy gives with real experimental values for the radius with the real values of the constants:\\\\\n\t\n\t\\texttt{>plot([-2.31E-28/r+6.11E-39*0*(0+1)/r\\string^2,-2.31E-28/r+6.11E-39*1*(1+1)/r\\string^2,\\\\-2.31E-28/r+6.11E-39*2*(2+1)/r\\string^2,-2.31E-28/r+6.11E-39*3*(3+1)/r\\string^2,\\\\-2.31E-28/r+6.11E-39*10*(10+1)/r\\string^2],r=5E-11..10E-10,\\\\y=-0.5E-17..0.5E-17,thickness=2);}\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/effective_potential_energy.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Plot of the effective potential energy with Maple 4.00b for various $l$ and $Z$}\n\t\\end{figure}\n\twhere the legends were added afterwards with a text processor software. The reader will notice especially the case where $l=1$ that matches to the case of the figure indicated by the majority of graduate books of physics. Either with a zoom:\\\\\n\n\t\\texttt{>plot(-2.31E-28/r+6.11E-39*1*(1+1)/r\\string^2,r=5E-11..10E-10,thickness=2, color=green);}\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/effective_potential_energy_l_equal_1.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Plot of the famous effective potential energy with Maple 4.00b for  $l=1$ and $Z=1$}\n\t\\end{figure}\n\n\tThe first graph also tells us quite clearly that for $l= 0$ the electron has a negative potential energy that firmly holds it in the orbit of the proton. By cons already at $l= 1$ we guess that the point of stability of the electron is where the derivative is zero. Beyond the $l= 1$, in the case of a nucleus with a single proton, the electron is not naturally linked anymore since its potential energy tends to be positive. The reader can also have fun with Maple by making vary $Z$ and $l$. He will see that the effective potential energy is very sensitive to these parameters. For example, the plot below shows the effective potential energy with $l= 4$ and $Z = 1$ (thus unstable atom) and then with $l = 4$ and $Z = 6$ (which corresponds rather to an excited state):\\\\\n\n\t\\texttt{>plot([-2.31E-28*1/r+6.11E-39*4*(4+1)/r\\string^2,-2.31E-28*6/r+6.11E-39*4*(4+1)/r\\string^2],\\\\r=5E-11..10E-10,thickness=2);}\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/effective_potential_energy_l_equal_1_varous_z.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Plot of the effective potential energy for $l=1$ and various $Z$}\n\t\\end{figure}\n\t\n\tIt is customary in practice to consider that:\n\t\n\tis to a given factor (electric charge factor) an \"\\NewTerm{effective electrical potential}\\index{effective electrical potential}\" or \"\\NewTerm{electric screened potential}\\index{electric screened potential}\". Indeed by defining the electric potential (\\SeeChapter{see section Electrostatics}), there are only an electri charge factor ratio between the electric potential energy and the electric potential. So we have:\n\t\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{90} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 49 votes,  66.12\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Molecular Chemistry}\n\t\\lettrine[lines=4]{\\color{BrickRed}B}olecular chemistry is the central area that interconnects thanks to the study of molecules many promising advanced technologies of the early 21st century which are to name only the best known: molecular biology, molecular materials, molecular electronics, polymers, etc.\nOrbital approximation\n\n\tKnowing it was found experimentally that a single molecule can have several very different functions, its theoretical study allows to use them better (sometimes better performance in terms of R\\&D) in its areas of application. The reader will therefore understand that, as usual in this book, that we will focus here only on the theoretical aspect (mathematical) of molecular chemistry even if we limit ourselves only to theoretical developments made between the years 1910 and about 1935 (beyond the complexity of theories require too many pages to a general book as ours).\n\t\n\tWe are in the beginning of the 21st century at the infancy of the discovery of what nature has done with plenty of time and chance (probabilities): that is to say complex molecules working as nanomachines capable locally (active site) to filter, oxidize, to make catalysis ... and many other manipulations (there is just to observe your own body!).\n\t\n\tA molecule is often treated in school classes with the Schrödinger equation (so no relativistic case and no consideration of the spins) in the usual form (\\SeeChapter{see section Wave Quantum Physics}):\n\t\n\tor also in a stationary from (time-independent) where as a reminder $\\Psi$ is a eigenfunctions and $E$ an eigenvalue of the application $H$.\n\t\n\tIn reality, the wave functions are impossible to calculate normally with contemporary mathematical tools and the only thing we can do are numerical calculations (perturbation method). This is why some chemistry centers are transformed over time into data centers where the predictive character (and inexpensive) of quantum chemistry is becoming more and more important.\n\t\n\tIt remains of course essential, as always, to understand how the theoretical models are built and their underlying assumptions.\n\t\n\tBut we can still thanks to calculations predict the form of reasonable size of molecules, the energy of their internal connections, their energy capacity under stress deformation, the shape of the molecular orbitals (M.O.), energy state transitions (when parts of the molecule move therein), their reactivity vis-a-vis of a reaction medium...\n\t\n\tWe commonly distinguish two cases of study of the molecular chemistry:\n\t\\begin{enumerate}\n\t\t\\item Quantum mechanics: all interactions between particles are taken into account under the assumption of some acceptable simplifications.\n\t\t\\item Molecular mechanics: For large molecules, we are note concerned anymore over the electronic problem, but the interaction of certain parameters on which we want to focus.\n\t\\end{enumerate}\n\tFor example, hemoglobin (protein carrying oxygen carrying in the muscles) is a huge molecular structure which we will study only active site with the tools of quantum mechanics. The overall behavior of the molecule itself is treated with the molecular mechanics tools.\n\t\n\tIt follows that excepts for hydrogen-like atoms, we can not analytically describe a molecule from a purely quantum point of view! All current quantum methods rely on one or more approximations. The wave functions are therefore approximated and the level of calculation is adjusted according to what we want to show and the precision that we seek (seeking to minimize the computation time for cost problems...). The good understanding of approximations permits to express simple models requiring only a minimum of calculations (often trivial).\n\t\n\tWe propose here to show two common models (and the most simplest):\n\t\n\t\\subsubsection{Orbital Approximations}\n\tA molecule is obviously an extremely complex problem: $N$ nuclei, $n$ electrons and everything is moving!\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/vibrating_molecule.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Example of molecule where a almost everything is moving}\n\t\\end{figure}\n\tThe Hamiltonian (\\SeeChapter{see section Wave Quantum Physics}):\n\t\n\tis then a nightmare but in the intuitive form (the subscript $G$ of the Hamiltonian means \"General\") below:\n\t\n\twhere:\n\t\n\t\\begin{enumerate}\n\t\t\\item $\\displaystyle-\\sum_{k=1}^{N}\\frac{\\hbar^2}{2M_k}\\vec{\\nabla}_k^2$ is the kinetic energy of the $k$ nuclei of mass $M_k$ in the molecule.\n\n\t\t\\item $\\displaystyle-\\sum_{i=1}^{n}\\frac{\\hbar^2}{2m_e}\\vec{\\nabla}_i^2$  is the kinetic energy of the $n$ electrons n mass $m_e$.\n\n\t\t\\item $\\displaystyle-\\sum_{k=1}^{N}\\sum_{i=1}^{n}\\frac{Ze^2}{4\\pi\\varepsilon_0 r_{ik}}$ is the potential energy due to the attraction electron(-)/nucleus(+).\n\n\t\t\\item $\\displaystyle\\mathop{\\sum_{i=1}}_{j>1}^{n-1}\\frac{e^2}{4\\pi\\varepsilon_0 r_{ik}}$ is the potential energy of the repulsion electron(-)/electron(-).\n\n\t\t\\item $\\displaystyle\\mathop{\\sum_{k=1}}_{i>k}^{N-1}\\frac{Z_kZ_ie^2}{4\\pi\\varepsilon_0 r_{ik}}$ is the potential energy of repulsion nucleus(+)/nucleus(+).\n\t\\end{enumerate}\n\n\tOften we find these terms in the following form of the Schrödinger equation in the literature:\n\t\n\tA first approximation we might try is to decouple the movement of the nuclei of the electrons. Indeed, as the nucleus is much more massive (about 2,000 times) than the cloud of electrons, the center of mass is assimilated to the nucleus of the atom and all the motion to the entire electron cloud. This approximate approach is well known under the name \"\\NewTerm{Born-Oppenheimer approximation}\\index{Born-Oppenheimer approximation}\":\n\t\n\twhich then allows us to study the molecular orbitals. But unfortunately this approximation is not sufficient because of the repulsion interelectronic term (the double sum) that prevents using the separation of variables technique as we did in the section of Quantum Chemistry with the hydrogenoid-atom.\n\t\n\tMoreover, this latter equation is also written as the first line of the couple of equation below (Schrödinger equation of electrons and nuclei):\n\t\\begin{subequations}\n\t\t\\begin{align}\n\t\t&\\underbrace{(T_e+V_{ee}+V_{en})}_{H_{\\text{el.}}}\\Psi_{el}=E\\Psi_{el}\\\\\n\t\t&\\underbrace{(T_n+V_{nn})}_{H_{\\text{nuclei}}}\\Psi_n\\Psi_{el}=E\\Psi_n\\Psi_{el}\n\t\t\\end{align}\n\t\\end{subequations}\n\tThis system of equations is what some name the \"\\NewTerm{adiabatic approximation}\\index{adiabatic approximation}\" (???).\n\t\n\tThe idea that then comes to mind will be using the following property:\n\t\n\tGiven two operators $A$ and $B$, $f (u)$ and $g(v)$ their respective eigenfunctions associated with eigenvalues $a$ and $b$. Then $f (u) g (v)$ is an eigenfunction of the operator $A + B$ with associated eigenvalue $a + b$.\n\n\tWhich is written:\n\t\n\t\t\t\n\t\\begin{dem}\n\t\tWe have:\n\t\t\n\t\t\\begin{flushright}\n\t\t\t$\\square$  Q.E.D.\n\t\t\\end{flushright}\n\t\\end{dem}\n\tAnd that's what we will use to break the $n$-electronic Hamiltonian $H_{el}$ into a sum of independent-electron Hamiltonian knowing of the above that if we find the eigenfunction for each (which is relatively easier) if will bu sufficient to simply multiply them to get the overall eigenfunction.\n\n\tThus, we write:\n\t\n\t\tand therefore we have to find for each $i$:\n\t\n\tTo then have:\n\t\n\twith therefore:\n\t\n\tThis approach by one-electron Hamiltonian approach will lead us to replace:\n\t\n\tby the sum of Hamiltonian for an electron named \"\\NewTerm{effective Hamiltonian}\\index{effective Hamiltonian}\":\n\t\n\tThis approximation method is sometimes named in theoretical chemistry \"\\NewTerm{independent electron approximation}\\index{independent electron approximation}\" or \"\\NewTerm{orbital approximation}\\index{orbital approximation}\". It consists therefore to include the electron-electron interactions and to write that each electron move in an average potential resulting from the presence of all other electrons.\n\t\n\tThe \"\\NewTerm{Slater method}\\index{Slater method}\" consists by definition to write the latter relation in the form:\n\t\n\twhere $\\sigma$ is named the \"\\NewTerm{screen constant}\\index{screen constant}\".\n\t\n\tThe Slater method basically means replacing the purely electronic terms by a constant. It can be regarded as a parametric method since the constants were determined purely experimentally.\n\t\n\tThe principle of empirical calculation of the screening constant is relatively simple: In a poly-electronic atom, the core electrons are on much contracted orbits  while the valence electrons that will be responsible for the chemical properties of the atom in question are on orbits much more \"relaxed\".\n\t\n\tThe attraction of the nucleus on the latter electrons is much lower than that exerted on the core electrons and these electrons only receive a portion of the atomic charge.\n\t\n\tSlater then proposed that the effective charge, which is usually denoted by $Z^*$ could be calculated by taking into account the screening constant. This constant represents then the average effect of the other electrons on the considered electron  of the effective Hamiltonian $i$:\n\t\n\tFor a peripheral electron, we will need to consider its screen constant is due to all electrons placed on orbits equal or below its own. The tradition (or rather the \"trick\") is that the calculation is done by combining atomic orbitals in several groups $1s/2s, 2p/3s, 3p/3d/4s, 4p/4d/4f/5s, 5p/$ etc.\n\t\n\tThen the calculation is simple because it is based on an array of predefined values and we simply have to add the screening contributions of all the electrons following the table below:\n\t\n\tThis table deserves some explanation of course !:\n\t\n\tThe index indicates the number of the group that contributes to the screening constant while $n$ is the number of the group of electron that we consider.\n\t\n\t\\pagebreak\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tIn the case of the Carbon of configuration $1s^2 2s^2 2p^2$, the nuclear charge is $Z=6$. One electron $1s$ is shielded by onlye the another $1s$ electron, the effective charge it sees is therefore:\n\t\n\tA $2s$ or $2p$ electron is shielded by the two $1s$ electrons and by the other $3$ electrons $2s$ and $2p$. The effective charge by which it is attracted is then:\n\t\n\tSo we see that the effective charge experienced decreases rather quickly!\n\t\\end{tcolorbox}\n\t\n\t\\subsection{LCAO Method}\n\tA linear combination of atomic orbitals or LCAO is a quantum superposition of atomic orbitals and a technique for calculating molecular orbitals in quantum chemistry. In quantum mechanics, electron configurations of atoms are described as wave functions. In mathematical sense, these wave functions are the basis set of functions, the basis functions, which describe the electrons of a given atom. In chemical reactions, orbital wave functions are modified, i.e. the electron cloud shape is changed, according to the type of atoms participating in the chemical bond.\n\t\n\tSo as already mention, this method, rather qualitative, considers that the molecular wave function is a \"\\NewTerm{Linear Combination of Atomic Orbitals LCAO}\\index{Linear Combination of Atomic Orbitals}\" unlike the previous method where we multiply the effective Hamiltonian.\n\t\n\tThis method is important because it is the basis of much of the current vocabulary of chemists when the chemistry done is cutting edge one!\n\t\n\tLet us take the example of the dihydrogen molecule $H_2$. The idea is then following:\n\t\n\tIf we have the function of the atomic orbital $1s_A$ of $H_A$ and respectively the function $1s_B$ of $H_B$, then we assume that the dicentric molecular orbital (linked to two atoms) thereof is given by:\n\t\n\twhich defines a quantum system with two eigenstates.\n\n\tBut as we well know, in reality, only the square of the wave function has a physical sense (probability of presence). Thus, if we assume that the wave function has no value in $\\mathbb{C}$, we have for the single electron of interest ($1s$):\n\t\n\twhere we assume that:\n\t\\begin{itemize}\n\t\t\\item $a^2\\Psi_A^2$ represents the probability of presence to be near $A$.\n\t\t\\item $b^2\\Psi_B^2$ represents the probability of presence to be near $B$.\n\t\t\\item $2ab\\Psi_A\\Psi_B$ represents the probability of presence of the electron that do the link $A-B$.\n\t\\end{itemize}\n\tIn the particular case of the symmetric diatomic molecule we have chosen as an example, the atoms $A$ and $B$ perform the same function and there is no reason that the electron is closer to $A$ than to $B$ or vice versa.\n\n\tThus, the probability of finding the electron near $A$ is equal to the probability of finding it near $B$.\n\t\n\tMoreover, in this case the orbitals $\\Psi_A$ and $\\Psi_B$ are completely identical ($1s$ orbitals, both of the same atom) and there is therefore no need to distinguish them. So we have:\n\t\n\tWe have two solutions for $\\Psi_{AB}$ that are (these two solutions can be found in very different notations in the literature):\n\t\n\tand:\n\t \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tCaution! We can not put for the last two relations that $\\Psi_A=\\Psi_B$. The latter equality occurs at any point only if the distance between the two nucleus is zero (which is unlikely) or, if they are spaced a distant of a certain value $D$ in the middle thereof.\n\t\\end{tcolorbox}\n\tThese two expressions are simultaneously solutions of the Schrödinger equation. So we get two molecular orbitals from the two atomic orbitals in the case of symmetrical diatomic molecule.\n\t\n\tThe function:\n\t\n\tis named \"\\NewTerm{bonding function}\\index{bonding function}\" because it corresponds to a reinforcement of the probability of presence of the electron between atoms $A$ and $B$ which corresponds to the creation of the bond!\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/bonding_link.jpg}\n\t\t\\end{center}\t\n\t\\end{figure}\n\t\t\n\tConversely, the function:\n\t\n\tis named \"\\NewTerm{anti-bonding function}\\index{anti-bonding function}\" because it corresponds to a reduction of the probability of presence of the electron between atoms $A$ and $B$ which corresponds to the destruction of the bond!\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/bonding_unlink.jpg}\n\t\t\\end{center}\t\n\t\\end{figure}\n\t\n\tUltimately, by overlapping, the two atomic orbitals with the same energy give birth to two molecular orbitals of different energy, a stabilized binding and the other antibonding destabilized.\n\n\tWe have obviously from what we see just above that, in more complex cases, the energy level of the bonding molecular orbital is smaller than the antibonding (we will prove this rigorously in details below).\n\n\tThus, it takes more energy to ionize respectively the electron of the binding orbital $\\sigma$ than to ionize the electron of the antibonding orbital $\\sigma^{*}$. It is commonly accepted that the energy of the bond function is stronger than the antibonding one (but we will make the proof further below).\n\n\tLet us also indicate that in chemistry, a chemical bond wherein each of the bonded atoms is sharing an electron from one of its outer layers to form a pair of electrons linking two atoms is commonly known as \"\\NewTerm{covalent bond}\\index{covalent bond}\".\n\t\n\tThe chemists then say the covalent bond involves the equitable sharing of only one pair of electrons, named \"\\NewTerm{bonding pair}\\index{bonding pair}\" (but in fact where only one electron is really shared). Each atom provides an electron, the electron pair is then delocalized between two atoms as we have shown.\n\n\tThese are the reasons why we commonly say that the bond $\\sigma$ is a covalent chemical bond between two atoms created by orbital axial overlap.\n\n\tNow let us in-deep this approach! The molecular orbitals are to be normalized as we know. Which means that:\n\t\n\t\tWhat gives, since the atomic orbitals are normalized for $\\Psi_1$ and are real functions:\n\t\n\tSince $a$ (real number in our case) is imposed as a constant, it comes immediately:\n\t\n\tTherefore for $\\Psi_{AB}^1$:\n\t\n\tIdentically, we have for $\\Psi_{AB}^2$:\n\t\n\tIf we have $S_{12} 1$, it comes the following format that we find in many books:\n\t\n\tLet us make a small example using as orbital, the lowest atomic orbital (1$s$) of the hydrogen atom in the case of a dihydrogeneous bond $H_2$ for which we have proved at the end of that section of Quantum Chemistry of quantum chemistry that:\n\t\n\tTherefore it comes:\n\t\n\twith for recall:\n\t\n\tIt comes then for the molecular binding orbital of level $s$:\n\t\n\tand for the antibonding of also the $s$ level:\n\t\n\tWe then see immediately that $\\sigma^*_s$ vanishes in the middle of the two protons because in this place $r_1=r_2$. The molecular antibonding orbital therefore has a nodal plane and the electrons are mainly located on the protons.\n\t\n\tBy cons, for the molecular orbital $\\sigma_s$ the density does not vanish. Then we understand easily that an electron of $\\sigma_s$ ensures the stability of the molecule and is therefore responsible for the chemical bond.\n\t\n\tWe therefore conclude that the electronic stabilization due to the two identical orbital interaction is proportional to their recovery. More the recovery is big, the more the stabilization is important.\n\t\n\tThere is a more technical approach using Dirac notation (\\SeeChapter{see section Wave Quantum Physics}) and that has the advantage of allowing the determination of the eigenvalues of energy.\n\n\tFirst we write the general expression of the time independant Schrödinger equation with the Bra-Ket notation for one molecular orbital, superposition of two atomic orbitals:\n\t\n\tEither in explicit form:\n\t\n\tIf we multiply by the bra $\\langle \\Psi_A|$  on the left and taking into account that $a$, $b$ and the specific eigenvalues of the energy are constants, we get the following equation:\n\t\n\tSimilarly, we get the bra $\\langle \\Psi_B|$:\n\t\n\tLet us simplify the notations even more:\n\t\n\tBy symmetry of the problem in the case of dihydrogen, we put:\n\t\n\twhich are named \"\\NewTerm{resonance integrals}\\index{resonance integrals}\" because it is a term relating to the combination (resonance) of the both atomic orbital relative to the two atoms that made the molecular structure.\n\n\tWe also have:\n\t\n\twhich are named \"\\NewTerm{Coulomb integrals}\\index{Coulomb integrals}\" because they correspond according to the fifth postulate of Wave Quantum Physics (see section of the same name) to the average value of the total energy of the electron.\n\n\tWe have obviously:\n\t\n\twhich are named \"\\NewTerm{recovery integrals}\\index{recovery integrals}\" because the two atomic orbitals of the same type of each atom overlap.\n\t\n\tAnd finally, we have always have by symmetry of our particular case:\n\t\n\tWe can then write, since the recovery integrals are unitary:\n\t\n\tThese two equations are named \"\\NewTerm{secular equations}\\index{secular equations}\". The trivial solution is a priori not physical because it would mean that the electron has a zero probability density at any point in the space corresponding at $a=b=0$.\n\n\tThere is a nontrivial solution and unique solution if and only if the following determinant (\\SeeChapter{see section Linear Algebra}), known in molecular chemistry under the name \"\\NewTerm{secular determinant}\\index{secular determinant}\", is equal to zero:\n\t\n\tAs we have by symmetry in our particular case:\n\t\n\tTherefore it comes:\n\t\n\tHence:\n\t\n\tThis gives us two solutions ($+$):\n\t\n\tand minus ($-$):\n\t\n\tTherefore we have:\t\n\t\n\tBut to be able to calculate the energy levels in detail, we must still have the shape of the Hamiltonian... and that using the both electrons of the dihydrogen molecule is quite difficult... To simplify the study, we reduce ourselves to the case of the cation (positive ion) $H_2^{+}$ consisting of two protons and one electron:\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/dihydrogen_cation.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Simplified study of the dihydrogen cation $H_2^+$}\n\t\\end{figure}\n\tWe then have base on the relation we ahve obtained at the beginning of this section:\n\t\n\tThe following relation:\n\t\n\twhere the first two terms in the brackets are for recall associated with the potential energy of the electron and the last to the potential repulsion energy of proton (the first term on the right of the equality is the kinetic energy of the electron).\n\n\tNow let us try to sort the energy of these two molecular orbitals. For this, we write:\n\t\n\tLet us recall that for a system to be stable, the energies  $E_n$ must be negatives, this corresponding to the stable states (we need a supply of energy to take them out) and request from us because of the shape of $E_2$:\n\t\n\tKnowing this it comes:\n\t\n\tTherefore, we see that the notations are not consistent with the use in quantum physics because normally the index $1$ is reserved to the lowest energy. So we will write in the future:\n\t\n\twith the associated eigenfunctions  $\\Psi_1$ and $\\Psi_2$ and therefore:\n\t\n\tWe can also noticed an important thing! This is that if we consider the atoms in isolated, the interaction terms cancel and we have:\n\t\n\tTherefore we have the qualitative difference between a single atom and a simple diatomic (ionized) system:\n\t\n\tThis means that the energy of the lowest level of a diatomic ionized molecule is less than the energy of a single atom which is near $\\alpha$. This observation confirms that the system is stabilized in energy compared to two isolated atoms, which seems consistent with the experimental determination of the existence of such molecules.\n\t\n\tThe traditional is that chemists represent the energy differences in the following form for our particular case:\n\t\\begin{figure}[H]\n\t\t\\begin{center}\n\t\t\\includegraphics{img/chemistry/dihydrogen_cation_energy_levels.jpg}\n\t\t\\end{center}\t\n\t\t\\caption{Energy levels of the dihydrogen cation $H_2^+$}\n\t\\end{figure}\n\tWe therefore conclude - by generalizing a little bit... - that when two atoms (each contributing with an electron) combine, their atomic orbitals will combine to generate two molecular orbitals, one of energy level $\\Psi_1$ and the second of higher energy level $\\Psi_2$ than that of the isolated atoms. Thus, the split up that will make leave one of the electron with one of atoms will be exothermic in comparison to the single atoms.\n\t\n\tUp to now we have discussed the electronic states of rigid molecules, where the nuclei are clamped to a fixed position. In this section we will improve our model of molecules and include the rotation and vibration of diatomic molecules.\n\n\t\\pagebreak\n\t\\subsection{Molecular Rotational Energy Levels}\n\tAs we have seen in the section of Quantum chemistry, for analytical reasons we consider molecules als rigid rotators.\n\n\tThe rigid rotators are commonly classified into four types:\n\t\\begin{itemize}\n\t\t\\item Spherical rotors: have equal moments of inertia (e.g., $\\mathrm{CH}_4$).\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/molecule_ch4.jpg}\n\t\t\\end{figure}\n\t\t\n\t\t\\item Symmetric rotors: have two equal moments of inertial (e.g., $\\mathrm{NH}_3$).\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/molecule_nh3.jpg}\n\t\t\\end{figure}\n\t\t\n\t\t\\item Linear rotors: have one moment of inertia equal to zero (e.g., $\\mathrm{CO_2}$, $\\mathrm{HCl}$).\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/molecule_co2.jpg}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/molecule_hcl.jpg}\n\t\t\\end{figure}\n\n\t\t\\item Asymmetric rotors: have three different moments of inertia (e.g., $\\mathrm{H}_2\\mathrm{O}$).\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/chemistry/molecule_h2o.jpg}\n\t\t\\end{figure}\n\t\\end{itemize}\n\tLet us now recall that have proved in the section of Quantum Chemistry that for the rigid rotator the part of the Hamiltonian dedicated to the rotation of energy is:\n\t\n\tWhere $L^2$ was is an operator but from which we know from our study ow Wave Quantum Physics that the eigenvalues are:\n\t\n\tand where $r$ is the distance between the two corpuscules (nucleus and electron in the context of our study of the hydrogenous atom in the section of Quantum Chemistry) and\n\t\n\tIn the context of diatomic molecules $A$ and $B$ it is more common to write $r_{AB}$ and:\n\t\n\n\tIn the section of Wave Quantum Physics we have seen that we must consider the spin we have have to write the more general form:\n\t\n\tTherefore:\n\t\n\tIn the old style spectroscopic literature, the rotational term values $F(J) = E(J)/hc$ are used instead of the energies....The previous relation is then written:\n\t\n\twith the \"\\NewTerm{rotational constant}\\index{rotational constant}\":\n\t\n\t\n\tWe also know from the section of Classical Mechanics that:\n\t\n\tTherefore:\n\t\n\tThat simplifies to:\n\t\n\tTherefore:\n\t\n\t\n\tThe energy separation between the rotational levels $J$ and $J+1$ is given obviously by:\n\t\n\tand increase linearly with $J$.\n\t\n\tLet us now calculate the moment of inertia, that we will denoted $I$ to avoid the confusion with the orbital kinetic momentum $J$ used above, of a diatomic molecule. Let us imagine the diatomic molecule as a system of two tiny spheres at either end of a thin weightless rod.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/chemistry/diatomic_molecule_moment_inertia.jpg}\t\n\t\t\\caption{Construction for the study of inertia momentum of a diatomic molecule}\n\t\\end{figure}\n\tLet $C$ be the center of mass of the molecule. Let $r_1$ and $r_2$ be the distances of the two atoms of respective masses $m_1$, $m_2$ from the center of mass $C$ of the molecule:\n\tWe see that:\n\t\n\tand we have (\\SeeChapter{see section Classical Mechancics}):\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tAfter rearranging we get:\n\t\n\tor:\n\t\n\tSimilarly:\n\t\n\tLet $I$ be the moment of inertia of the diatomic molecule about an axis passing through the center of mass of the molecule and perpendicular to bond length.\n\n\tThen we have seen in the section of Classical Mechanics that:\n\t\n\tor:\n\t\n\tthus:\n\t\n\tafter simplification:\n\t\n\tHence:\n\t\n\tSo finally for a diatomic molecule (or any pair of object turning around a common center) we get the following moment of inertia\\index{moment of inertia of a diatomic molecule}:\n\t\n\tHence the fact that we often found in the literature the previous main relations under the form:\n\t\n\tand:\n\t\n\tTherefore, as: \n\t\n\tthe frequencies at which transitions can occur are given by :\n\t\n\tNotice that for $J_z=0$ we have a non-null zero point energy and frequency:\n\t\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tThe molecule $\\mathrm{NaH}$ is found to undergo a rotational transition from  $J=0$ to $J=1$ when it absorbs a photon of frequency $2.94 \\times 10^{11}$ [Hz]. We want to know the equilibrium bond length of the molecule.\\\\\n\n\tFor this purpose we use $J_z=0$ in the formula for the transition frequency \n\t\n\tSolving for $r_0$ gives:\n\t\n\tThe reduced mass is given by:\n\t\n\twhich is in atomic mass units or relative units. In order to convert to kilograms, we need the conversion factor $1\\;[\\text{au}]= 1.66\\cdot 10^{-27}$ [kg]. Multiplying this by $0.9655$ gives a reduced mass of $1.603\\cdot 10^{-27}$ [kg]. Substituting in for $r_0$ gives:\n\t\n\t\\end{tcolorbox}\n\n\t\\pagebreak\n\t\\subsection{Molecular Vibrational Energy Levels}\n\tLet us consider the simple case of a vibrating diatomic molecule, where restoring force is proportional to displacement such that (\\SeeChapter{see section Mechanical Engineering}):\n\t\n\tThe potential energy is a we proved it in the previously mentioned section, but with the notation of Quantum Physics:\n\t\n\tNow remember that we have proved in the section of Wave Quantique Physique the Schrödinger equation was:\n\t\n\tAfter rearrangement:\n\t\n\tAnd using the conventional notations in chemistry and quantum physics:\n\t\n\tAs we consider a linear vibration mode, the know that we can use the reduced mass to analyze the system (\\SeeChapter{see section Classical Mechanics}). Therefore we:\n\t\n\tHence:\n\t\n\tAnd as we have prove it in the section of Wave Quantum Physique we have:\n\t\n\twith for recall $n\\in \\mathbb{N}$.\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{90} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 23 votes,  64.35\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Analytical Chemistry}\n\t\\lettrine[lines=4]{\\color{BrickRed}C}hemistry is a very complex $n$-body science that mathematics can not explained without the input of numerical computer simulations or approximations regarding the use of quantum theory (\\SeeChapter{see Atomistic section}). Until these tools are powerful enough and accessible to everyone, chemistry remains a primarily experimental science based on the observation of different properties of matter and we would like here give some very important definitions (which we find also elsewhere in other fields as chemistry).\n\t\n\tAnalytical chemistry is concerned with the chemical characterization of matter and the answer to two important questions: what is it (qualitative analysis) and how much is it (quantitative analysis). Chemicals make up everything we use or consume, and knowledge of the chemical composition of many substances is important in our daily lives. Analytical chemistry plays an important role in nearly all aspects of chemistry, for example, agricultural, clinical, environmental, forensic, manufacturing, metallurgical, and pharmaceutical chemistry. The nitrogen content of a fertilizer determines its value. Foods must be analyzed for contaminants (e.g., pesticide residues) and for essential nutrients (e.g., vitamin content). The air we breathe must be analyzed for toxic gases (e.g., carbon monoxide). Blood glucose must be monitored in diabetics (and, in fact,\nmost diseases are diagnosed by chemical analysis). The presence of trace elements from gun powder on a perpetrator’s hand will prove a gun was fired by that hand. The quality of manufactured products often depends on proper chemical proportions, and measurement of the constituents is a necessary part of quality assurance. The carbon content of steel will influence its quality. The purity of drugs will influence their efficacy.\n\n\tIn this section, we will focus only on the mathematical tools and techniques for performing these different types of analyses.\n\n\t\\textbf{Definitions (\\#\\mydef):}\t\n\t\\begin{enumerate}\n\t\t\\item[D1.] A \"\\NewTerm{subjective property}\\index{subjective property}\" is a property based on personal / individual printing, for example: beauty, sympathy, color, utility, etc.\n\t\t\n\t\t\\item[D2.] An \"\\NewTerm{objective property}\\index{objective property}\" is an experienced property (which can not be contradicted), for example: mass, volume, shape, etc.\n\t\t\n\t\t\\item[D3.] A \"\\NewTerm{qualitative property}\\index{qualitative property}\" is a descriptive property given using words. For example: oval, magnetic, conductive, etc.\n\t\t\n\t\t\\item[D4.] A \"\\NewTerm{quantitative property}\\index{quantitative property}\" is a property that can be measured. For example: mass, volume, density, etc.\n\t\t\n\t\t\\item[D5.] A \"\\NewTerm{characteristic property}\\index{characteristic property}\" is an exclusive property that identifies a pure substance. It does not change even if it is physically transformed material, for example: its density, its boiling point, its melting point, etc.\n\t\t\n\t\t\\item[D6.] A \"\\NewTerm{characteristic property}\\index{characteristic property}\" is an exclusive property that identifies a pure substance. It does not change even if it is physically transformed material, for example: its density, its boiling point, its melting point, etc.\n\t\t\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe know about $2,000,000$ different pure substances in the early 21st century (that is to say ... there is work behind it).\n\t\t\\end{tcolorbox}\n\t\t\n\t\t\\item[D7.] We name \"\\NewTerm{compound bodies}\\index{compound bodies}\", the bodies, that subjected to chemical processes, restore their components in the form of pure substances.\n\t\t\n\t\t\\item[D8.] If we make the separation of mixtures and the decomposition of compositions, we finally get the bodies that are non-decomposable by conventional chemical methods; we name them \"\\NewTerm{elements}\\index{elements}\" or \"\\NewTerm{simple bodies}\\index{simple bodies}\".\n\t\t\n\t\t\\item[D9.] The smallest part of a chemical combination yet having all of the properties thereof is the \"\\NewTerm{molecule}\\index{molecule}\" of this combination. The smallest part of an element or simple body is the \"\\NewTerm{atom}\\index{atom}\" of that element.\n\t\\end{enumerate}\n\tSome general reminders first:\n\t\\begin{enumerate}\n\t\t\\item A mixture is named \"\\NewTerm{heterogeneous}\\index{heterogeneous}\" in chemistry if the components are immediately discernible to the naked eye or through the microscope.\n\t\t\n\t\t\\item A mixture is said to be \"\\NewTerm{homogeneous}\\index{homogeneous}\" in chemistry if the components are not discernible to the naked eye or through the microscope.\n\t\t\n\t\t\\item A system or body is said to be \"\\NewTerm{isotropic}\\index{isotropic}\" if it has identical values of a property in all directions otherwise it is said \"\\NewTerm{anisotropic}\\index{anisotropic}\".\n\t\\end{enumerate}\n\t\n\t\\subsection{Simple Mixtures}\n\tBefore going into more or less complicated equations, the simplest case of application of mathematics to chemistry by which we can start is the management of mixtures for analysis and control operations of simple chemical reactions with two mixtures.\n\t\n\tLet us consider two typical and particular examples as theoretical introduction:\n\t\\begin{enumerate}\n\t\t\\item Given a solution (yellow) of $10$ milliliters of a solution containing an acid concentration at $30\\%$. How many milliliters of pure acid (blue) should we add to increase the concentration (green) to $50\\%$?\n\t\t\\begin{figure}[H]\n\t\t\t\\begin{center}\n\t\t\t\\includegraphics{img/chemistry/chemistry_simple_mixture.jpg}\n\t\t\t\\end{center}\t\n\t\t\t\\caption{The joy of mixtures...}\n\t\t\\end{figure}\n\t\tSince the unknown is the amount of pure acid to be added, we will denote it by $x$. Then we have:\n\t\t\n\t\tThat gives:\n\t\t\n\t\tIt comes the obviously:\n\t\t\n\t\tTherefore $4$ milliliters of acid should be added to the original solution.\n\t\t\n\t\t\\item  A canister contains $8$ liters of gasoline and oil to run an aggregate. If $40\\%$ of the initial mixture is of the essence, how much should we remove of the mixture (pink) to replace it with pure gasoline (green) so that the final mixture (light green) contains $60\\%$ gasoline?\n\t\t\\begin{figure}[H]\n\t\t\t\\begin{center}\n\t\t\t\\includegraphics{img/chemistry/chemistry_simple_mixture_gazoline.jpg}\n\t\t\t\\end{center}\t\n\t\t\t\\caption{The joy of mixtures by for diyers and military ...}\n\t\t\\end{figure}\n\t\tWe denote the unknown $x$ that is the number of liters of the initial mixture to remove and replaced by the pure essence being of equal amount also $x$. Then we have:\n\t\t\n\t\tThat gives:\n\t\t\n\t\tWe have then obviously:\n\t\t\n\t\tSo approximately $2.6$ liters should be removed from the original mixture and be replaced by approximately $2.6$ liters of pure essence.\n\t\\end{enumerate}\n\tIn short this is for all mixtures in this book until now. We can go much further and do much more complicated with more unknowns but we'll stop there for now.\n\t\n\t\\subsection{Reactions}\n\tSince the main study in chemistry is to observe the results of pure substances mixtures and/or of compounds mixtures, it is first necessary to deal with  the basic rules governing these mixtures under normal conditions of pressure and temperature (N.C.P.T).\n\t\n\tWe should first clarify that we are not going to study in this section what creates the connections between the elements, as this is the role of quantum and molecular chemistry (see previous sections). Furthermore, we insist on the fact that every theoretical element will be illustrated with a practical example which can be useful sometimes to better understand.\n\t\n\tLet us now consider a closed chemical system (without mass transfer therefore!). We translate the change in the composition (if applicable and if have there is one) of the chemical system with a reaction equation of the form (the system does not always go both ways!):\n\t\n\tnamed \"\\NewTerm{balance equation}\\index{balance equation}\" where the coefficients $v_i \\in \\mathbb{N}^*$ are named  \"\\NewTerm{stoichiometric coefficients}\\index{stoichiometric coefficients}\" in the sense that they indicate the \"golden proportions\", strictly named \"\\NewTerm{stoichiometric ratio}\\index{stoichiometric ratio}\" necessary such that under normal conditions the reaction can take place and where the $A_i$ are the reactants (pure or compounds) and the ${A'}_i$ the formed products.\n\t\n\tCaution! In the writing of the above equation, we require that all the $A_i$ without exception react to the chemical reaction and that therefore all the $v_i$ are dependents.\n\t\n\tIf the \"golden proportions\" are respected (such that the coefficients are well stoichiometric) and exist when writing of the reaction equation, then for any $\\alpha \\in \\mathbb{N}$ we have:\n\t\n\tthis proposal can be proven only if the stoichiometric coefficients on one side or the other of the reaction vary proportionally. Experience shows that in normal conditions of temperature and pressure (N.C.T.P.) this is the case!\n\t\n\tTherefore, the stoichiometry of the reaction requires that if it disappears $x_1$ moles of $A_1$, $x_2$ moles of $A_2$  respectively with a variation of material of the products $\\mathrm{d}n_1,\\mathrm{d}n_2,\\ldots $, it will appear accordingly ${x'}_1$ moles of ${A'}_1$, ${x'}_2$ moles of ${A'}_2$, ... with respectively a variation of material of the products $\\mathrm{d}{n'}_1,\\mathrm{d}{n'}_2,\\ldots $... by respecting the proportionalities of the stoichiometric coefficients such that we can write the \"\\NewTerm{material balance equation}\\index{material balance equation}\":\n\t\n\twhere $\\mathrm{d}\\xi$ is named the \"\\NewTerm{elementary reaction progress}\\index{elementary reaction progress}\" (frequently we will take the absolute values of the ratios to not have to think about the sign of the variations).\n\t\n\tThe division of the variations $\\mathrm{d}n_1,\\mathrm{d}n_2$ and $\\mathrm{d}{n'}_1,\\mathrm{d}{n'}_2$  by their stoichiometric coefficients is justified only for normlization reasons having for purpose to bring $\\mathrm{d}\\xi$ to a value between $0$ and $1$ (between $0\\%$ and $100\\%$...).\n\t\n\tThese last equalities simply indicate that if one of the reactive products disappear in a given quantity, the other reactants have their quantity that decreased in relation to their stoichiometric coefficient so as to maintain the golden proportions of the reaction.\n\t\n\t\tThe writing of the energy balance can be simplified by the introduction of algebraic stoichiometric coefficients $v_i$ such that: $v_i>0$ for a formed product, $v_i<0$ for a reactive product.\n\n\tFinally we can write:\n\t\n\twe also often find in the literature with the absolute value at the numerator!\n\n\tTherefore, with this algebraic convention, the reaction equation as it exists, can be written:\n\t\n\twhich means that the algebraic sum of the total number of pure compounds of the reactants and products formed is always zero.\n\n\tIt is clear that at the initial time of the reaction we choose for the progress the value $\\xi=0$ (its maximum value being equal to unity), time at which the quantities of material are equal to $n_{i,0}$.\n\n\tThe integration of the differential expression of material balance obviously gives:\n\t\n\tTherefore:\n\t\n\trelation that we found in chemical progress tables (see further below), without forgetting that $v_i>0$ for a formed product and, $v_i<0$ for a reactive product.\n\n\tThis bring us to the question: What is the maximum value $\\xi_{\\max}$ of the progress of a reaction? \n\n\tWell the answer to that is in fact quite simple: The maximum progress value of a reaction having the stoichiometric proportions and such that it occurs when the reactants will have all disappear and therefore it is necessarily given by:\n\t\n\tfor what we name the \"\\NewTerm{limiting reactant}\\index{limiting reactant}\", that is to say, the reactant that disappears (has always the smallest value of molarity) first and stops the expected reaction! If there is no limiting reactant, that is that at the end of the reaction all reactants have been transformed: then we say that all reactants were in stoichiometric proportion.\n\t\n\tIt may be helpful to define the \"\\NewTerm{percentage of completion}\\index{percentage of completion (chemistry)}\" $A_i$ given by the intensive quantity:\n\t\n\t\n\twhich gives with a more formal notation:\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tLet us consider to illustrate these concepts the reaction (dinitrogen and hydrogen giving ammonia):\n\t\n\twhere the Latin letters represent the pure substances (atoms) whose name does not matter to us in this book (notation proposed by Jöns Jacob Berzelius in 1813). The indices simply represent the number of combination of atoms to obtain a molecule. \\\\\n\n\tWe then have in this reaction:\n\t\n\tThe reader will have notice that we have well following our convention for the mass balance:\n\t\n\tIf we consider that there is one mole of each compound body, it gives us for the stoichiometric proportions (to a given factor $x\\in\\mathbb{R}^{*}$ for all values):\n\t\n\tIf at any a given time $t\\neq t_0$, we get by measurement:\n\t\n\tWhat is the progress of that reaction?\n\n\tThe answer is:\n\t\n\tor in other words, we are at $10\\%$ of progress (logical!).\\\\\n\t\\end{tcolorbox}\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\tThe conversion rate of $\\mathrm{NH}_3$ is thereto:\n\t\n\tAnd what is the maximum progress value $\\xi_{\\max}$ of the limiting reactant?\\\\\n\n\tSo in the context of the above example where we have $n_{1,0}=1\\;[\\text{mol}]$ for the $\\mathrm{N}_2$ then:\n\t\n\t\\end{tcolorbox}\n\t\n\tChemists also often use what they name a \"\\NewTerm{reaction progress table}\\index{reaction progress table}\".\n\t\n\tLet us take our previous example to introduce this table. We have:\n\t\n\tLet us seek $\\xi_{\\max}$ from this table. The limiting reactant is either $\\mathrm{N}_2$ or $3\\mathrm{H}_2$.\n\n\tSo for $\\mathrm{N}_2$:\n\t\n\tand for $3H_2$:\n\t\n\tEach reactant having the same $\\xi_{\\max}$ progress, it is thus also the minimum $\\xi_{\\max}$. Consequently, according to the definition of limiting reactant, as the proportions are stoichiometric in the given example no reactant is limiting.\n\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{10} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 25 votes,  55.20\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\n\t%to force start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Thermochemistry}\n\t\\lettrine[lines=4]{\\color{BrickRed}T}hermochemistry is the branch that historically focuses on thermic phenomena and to equilibrium accompanying chemical reactions. It mainly has its foundations in the thermodynamics. More technically, thermochemistry is the study of the energy and heat associated with chemical reactions and/or physical transformations. A reaction may release or absorb energy, and a phase change may do the same, such as in melting and boiling. Thermochemistry focuses on these energy changes, particularly on the system's energy exchange with its surroundings. Thermochemistry is useful in predicting reactant and product quantities throughout the course of a given reaction. In combination with entropy determinations, it is also used to predict whether a reaction is spontaneous or non-spontaneous, favorable or unfavorable.\n\t\n\tWe can only strongly recommend the readers to have read or to read the section on Thermodynamics in the Mechanics chapter because many concepts that have been seen there will be assumed to be known in this section.\n\t\n\tMoreover, it is strongly recommended to read this chapter in parallel to that of Analytical Chemistry (this can be a boring but you must do with...).\n\t\n\t\\subsubsection{Chemical transformations}\n\tGiven the closed system closed of the chemical reaction (\\SeeChapter{see section Analytical Chemistry}):\n\t\n\tWe will consider for simplicity that the chemical reaction is complete and that the reactants are used in stoichiometric amounts (state 1: $\\Sigma_1$) to give the products formed, also in stoichiometric quantities (state 2: $\\Sigma_2$).\n\t\n\tIf the transformation is done in (quasi-)steady volume steady, work on the surrounding atmosphere is zero because (\\SeeChapter{see section Thermodynamics}):\n\t\n\tThe application of the first law of thermodynamics is reduced and allows then us to write:\n\t\n\twhere $Q_v$ is within the thermal chemistry framework named \"\\NewTerm{heat of reaction at constant volume}\\index{heat of reaction at constant volume}\", of course exchanged between the system and the external environment (we do not write the delta $\\Delta$ in front of $Q_V$ to indicate that it is a variation... by tradition...).\n\t\n\tLet us recall that:\n\t\n\t\\begin{enumerate}\n\t\t\\item If $Q_V>0$ the reaction is said to be \"\\NewTerm{endothermic}\\index{endothermic}\" (the system receives heat from the external environment).\n\t\t\n\t\t\\item If $Q_V<0$ the reaction is said to be \"\\NewTerm{exothermic}\\index{exothermic}\" (the system gives heat to the external environment).\n\t\t\n\t\t\\item If $Q_V=0$ the reaction is said to be \"\\NewTerm{athermic}\\index{athermic}\" (the system do not exchange any heat with the environment).\n\t\\end{enumerate}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tLet us also recall that a closed system is not an isolated system! For a review of different definitions, the reader is referred once again to the section of Thermodynamics.\n\t\\end{tcolorbox}\n\t\n\tIf the reaction is carried out at constant pressure (the most usual case in practice), that is to say isobaric, then we have:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe choice of integration indices are different to previously to differentiate the fact that a reaction a pressure or constant volume are not necessarily identical.\n\t\\end{tcolorbox}\n\t\n\tThe application of the first law of thermodynamics, between the two states, gives:\n\t\n\twhere $Q_p$ is the amount of heat, named \"\\NewTerm{constant-pressure reaction heat}\\index{constant-pressure reaction heat}\", exchanged between the system and the external environment ($Q_P$ is a variation... even if the traditional unfortunate notation of thermodynamician does not put that in evidence...).\n\t\n\tUsing the definition of enthalpy, we can write the last relation in the form:\n\t\n\tIf we work with the molar volumes, those of condensed phases (therefore solid and liquid) is negligible compared to the gas molar volume, only the gas components have a very different enthalpy of their internal energy (see the example in the section of Thermodynamics) . We would therefore have under the ideal gas approximation (\\SeeChapter{see section Thermodynamics}):\n\t\n\tIn the context of the ideal gas, the prior-previous relation can be written:\n\t\n\tBut, as (\\SeeChapter{see section Continuum Mechanics}) $U_2$ and $U_3$ are both the same final states of a single complete reaction and that for a monatomic gas:\n\t\n\ttherefore the internal energy $U_2$ and $U_3$ only depends on the number of components but ... they are equal since they are the same final state of the same reaction!\n\t\n\tTherefore we have:\n\t\n\tBy putting $\\Delta n=n_2-n_1$ (the difference between the number of moles of gas of formed products and those of reacting products), we can write for a chemical reaction:\n\t\n\tthat gives the possibility to differentiates the energy involved between isobaric and isochoric reaction and look for the best choice in terms of industrial objectives. It is interesting to note that if the $\\Delta$ of moles is zero. Isobaric or isochoric heat variations are equal and there is no a priori reason to prefer one or the other transformations.\n\t\n\tObviously in practice the problem is to know the values of the different variables of the latter relation. These values can be found on huge databases that chemists have access to... This relationship is only very rarely used in practice and in any case it is based on too simplifying and restrictive assumptions to be of real practical interest.\n\t\n\t\\subsection{Molar Quantities}\n\t\\textbf{Definitions (\\#\\mydef):}\n\t\\begin{enumerate}\n\t\t\\item[D1.] By convention, the \"\\NewTerm{mole}\\index{mole}\" is the quantity of substance of a system which contains as many chemical species as there are Carbon atoms in $12$ [g] of carbon $12$ (\\SeeChapter{see section Nuclear Physics}).\n\t\t\n\t\tThe number of carbon atoms contained in $12$ [g] is equal to the Avogadro's \\underline{number} given approximately by:\n\t\t\n\t\tThis means verbatim and by construction that a mole of water, of iron, of electron, respectively always contains a number of atoms equal to the Avogadro's number.\n\t\t\n\t\tMost of time the mole is simply denoted $n$ and has its value in $\\mathbb{R}^{+}$.\n\t\t\n\t\tNote that with a mixed system it is a mathematical nonsense to do the sum of the molar masses of the constituents for the total molar mass. The molar mass is an intensive quantity!\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\t\\textbf{R1.} Hydrogen-1 was once used as a standard but given the inaccuracy that can occur because of its low mass, it was later disregarded. Once mass spectrometry was made available, physicists were using Carbon-12 for it's stability and abundance, and basically to stop everybody from fighting. Carbon-12 also more accurately defines a mass for hydrogen, and it is unbound in it's ground state and also is the most common and readily available isotope to have exactly the same number of protons and neutrons, 6 of each, and thus provides a perfect average when divided by the total number of protons and neutrons (electron is so small as to be considered negligible). \\\\\n\t\t\n\t\t\\textbf{R2.} The \"Avogadro project\" aims to redefine Avogadro's constant (currently defined by the kilogram: the number of atoms in 12 g of Carbon-12) and reverse the relationship so that the kilogram is precisely specified by Avogadro's constant. This method required creating the most perfect sphere on Earth. It is made out of a single crystal of silicon 28 atoms. By carefully measuring the diameter, the volume can be precisely specified. Since the atom spacing of silicon is well known, the number of atoms in a sphere can be accurately calculated. This allows for a very precise determination of Avogadro's constant.\n\t\t\\end{tcolorbox}\t\n\t\t\n\t\t\\item[D2.] The \"\\NewTerm{molar mass (MM)}\\index{molar mass}\" is the mass of one mole of atoms of the chemical elements involved. Therefore by definition the molar mass of $\\mathrm{C}_{12}$ is equal to $12$ grams (yes historically we use the gram to express molar mass because for application purposes is is obviously more convenient...\n\t\t\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\tWe find these atomic molar masses in the periodic classification. But above all it must be known that those that are indicated take into account the natural isotopes (which is normal since they are chemically indistinguishable excepted for the nuclear chemist or nuclear physicist). So the value indicated in the tables is calculated as the sum of the respective proportions of the molar masses of the different corresponding isotopes (the validity of this method of calculation is obviously relative...).\n\t\t\\end{tcolorbox}\t\n\t\t\n\t\t\\item[D3.] The \"\\NewTerm{atomic molar mass}\\index{atomic molar mass}\" is the molar mass of a given element divided by the Avogadro number. Thus:\n\t\t\n\t\tTherefore the atomic (molar) mass is the mass of $1$ atom of a particular element and the molar mass is the mass of $1$ mole of an atom or molecule.\n\t\t\n\t\tWe therefore have the following graph:\n\t\t\\begin{figure}[H]\n\t\t\t\\begin{center}\n\t\t\t\t\\includegraphics{img/chemistry/mole_mass_avogadro.jpg}\n\t\t\t\\end{center}\t\n\t\t\\end{figure}\n\t\t\n\t\t\\item[D4.] The \"\\NewTerm{Molecular molar mass (MMM)}\\index{molecular molar mass}\" is equal to the sum of the atomic molars  masses of the chemical elements that constitutes it.\n\t\t\n\t\tIt comes therefore immediately the following observation: the mass $m$ of a sample consisting of an amount of $n$ moles of identical chemical species of molar mass $M_m$ is given by the relation:\n\t\t\n\t\tSomewhat in a little bit more formal way and in a thermodynamic aspect, here is also is how we can define the molar mass:\n\t\t\n\t\tLet $X$ be an extensive quantity on a single-phase system (see the section of Thermodynamics for precisions about the vocabulary used) and given a volume element $\\mathrm{d}V$ of this system around a common point $M$ and containing the amount of material $\\mathrm{d}n$. We associate it the extensive quantity $\\mathrm{d}X$ proportional to $\\mathrm{d}n$ such that:\n\t\t\n\t\tso that $X_m$ is an intensive quantity (ratio of two extensive quantities according to what was seen in the section of Thermodynamics) which we will name by definition the \"\\NewTerm{associated molar size}\\index{associated molar size}\" to $X$.\n\t\t\n\t\tWe conclude that:\n\t\t\n\t\tthe integral applying on the whole monophasic system.\n\t\t\n\t\tIn the case of a uniform phase, $X_m$ being constant at any point, we can simply write the latter as:\n\t\t\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\tBasically the idea is to say that the mass of a single-phase chemical system is proportional to the molar mass of it to closely to a given integer factor representing the number of its constituents (or the number of moles to be more exact).\n\t\t\\end{tcolorbox}\t\n\t\t\n\t\t\\item[D5.] When the system is heterogeneous, we use the concept of \"\\NewTerm{mole fraction}\\index{mole fraction}\", defined by:\n\t\t\n\t\t$x_i$ being the mole fraction of a species $A_i$ whose the quantit of material (the number of moles for example) is $n_i$ with $n=\\sum_i n_i$ being the total quantity of matter of the studied phase.\n\t\t\n\t\tAs a result, for all chemical species of the studied phase, $\\sum_i x_i=1$ which means that if there are $n$ chemical species, it is enough to  know $n-1$ molar titles to know them all.\n\t\n\t\tIf the studied phase is a gas and assuming a perfect gas according to Boyle's law (approximation of the Van der Waals equation proved in the section of Statistical Mechanics) we have:\n\t\t\n\t\twe therefore have the possibility in the case of gaseous phases to express the mole fraction as:\n\t\t\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\tWe can do obviously the same for the volume $V$.\n\t\t\\end{tcolorbox}\t\n\t\t\n\t\t\\item[D6.] We define the \"\\NewTerm{mass content associated with the species $A_i$}\\index{mass content associated a species}\" by the ration:\n\t\t\n\t\twith $m=\\sum_i m_i$ being the total mass of the studied phase. We also have of course $\\sum_i w_i=1$.\n\t\t\n\t\t\\item[D7.] We define the \"\\NewTerm{volumic molar concentration}\\index{volumic molar concentration}\" or \"\\NewTerm{molarit}\\index{molarit}\" the ratio (do not confuse the notation with the specific heat):\n\t\t\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\tThere are other composition variables used much less used than $x_i$ or $c_i$. We can cite the \"\\NewTerm{mass concentration density}\\index{mass concentration density}\" $m_i/V$, the \"\\NewTerm{molality}\\index{molality}\" (ratio of the amount of material of the species $A_i$ by the total mass of solvent), etc.\n\t\t\\end{tcolorbox}\n\t\t\n\t\t\\item[D8.] We say that a (perfect) gas is in the \"\\NewTerm{standard state}\\index{standard state}\" if its pressure is equal to the standard pressure:\n\t\t\n\t\t\n\t\t\\item[D9.] We call \"\\NewTerm{standard molar quantity}\\index{standard molar quantity}\" of a constituent $X_m^\\circ$ the value of the molar quantity of this same component taken in the standard state, that is to say under the pressure $P^\\circ$.\n\t\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\t\\textbf{R1.} Any standard molar quantity is obviously intensive: the pressure being set by the standard state , it depends only on the temperature.\\\\\n\t\t\n\t\t\\textbf{R2.} Any standard quantity is denoted with the superscript \"${}^\\circ$\". $V_m^\\circ$ is then standard molar volume. For cons, the standard molar quantity is not always specified with the small index $m$, we must sometimes be careful with what is handled in the equations (as always anyway!).\n\t\t\\end{tcolorbox}\t\n\t\tIn the case of the ideal gas, the molar volume is calculated using the ideal gas equation of state. Then we get:\n\t\t\n\t\tWe see of course that the standard molar volume of an ideal gas depends on the temperature.\n\t\t\n\t\tIf we do that calculation at the \"\\NewTerm{standard conditions of temperature and pressure}\\index{standard conditions of temperature and pressure}\" (abbreviated STP), that is to say at a temperature of $273.15$ [K] (i.e. $0$ [$^\\circ$C]) and a pressure of $1$ [atm] (i.e. $101,325$ [kPa]), then we find a volume of $22.4$ [L$\\cdot$mol$^{-1}$] which is a well known value by chemists.\n\t\\end{enumerate}\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} In a wide range of temperatures and pressures, the molar volume of real gases is generally not very different from that of an ideal gas.\\\\\n\t\n\t\\textbf{R2.} In the case of a condensed state, we do not have in general a state equation but we can measure the molar volume..\n\t\\end{tcolorbox}\n\tWe can define then by extension other standard quantities resulting from those we had defined in the section Thermodynamics:\n\t\\begin{enumerate}\n\t\t\\item The \"\\NewTerm{standard molar internal energy}\\index{standard molar internal energy}\" (intensive quantity as expressed by molar unit) and denoted by $U_m^\\circ$.\n\n\t\t\\item The \"\\NewTerm{standard molar enthalpy}\\index{standard molar enthalpy}\" (intensive quantity as expressed by molar unit) with:\n\t\t\n\t\tIt is important that the reader notice that the enthalpy depends only on the temperature (and the internal energy).\n\t\\end{enumerate}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tFor condensed states the standard volume is very low in S.I. units so that $H_m^\\circ\\cong U_m^\\circ$. However, it is very difficult to speak of pressure for so condensed states so this approximation has to be used with caution.\n\t\\end{tcolorbox}\t\n\tIf we now consider an extensive function $X$ (as for example the volume!) defined on a chemical gaseous evolving system. We can a priori express $X$ based on two intensive variables $T$, $P$ (because an extensive function is always a product or ratio of two intensive quantities, or a sum of extensive quantities) and of the different quantity of materials $n_i,{n'}_i$ of $A_i,{A'}_i$ such that:\n\t\n\tIf all products (reagents and resulting one) are in their standard state, the extensive function, therefore denoted $X^\\circ$, gets the form:\n\t\n\twhere the pressure is no longer involved as attached to its standard value. The gas is then described by its temperature and the quantity of its constituents!\n\t\n\tHowever, if we consider an infinitesimal evolution of the system at constant temperature and pressure (because assume a very slow transformation) the different quantities of materials vary therefore following the exact total differential (\\SeeChapter{see section of Differential Calculus and Integral}):\n\t\n\twhere obviously are taken into account, as $T$ and $P$ are are supposed constant, only the quantity of materials that could vary (yes don't forget we are doing chemistry!!!).\n\n\tWe can then define artificially (nothing avoid us to do so, it's not false!) the intensive standard molar quantity that depends only on the temperature:\n\t\n\tTherefore:\n\t\n\tbut we have also defined in the section Analytical Chemistry the relation:\n\t\n\texpressing, for recall, the variation in the quantity of matter of one of the compounds of a chemical reaction relatively toits stoichiometric ratio (constant) and the progress of the reaction. We therefore have:\n\t\n\tand also that:\n\t\n\tBy definition, we name this algebraic sum \"standard quantity reaction associated with the extensive function $X$\" and denote it by (notation badly chosen by chemists in our point of view...):\n\t\n\twhich is an intensive quantity that depends only on the temperature and represents a relative change (hence the subscript $r$!). This relation can also be written:\n\t\n\tIn general, chemists name \"\\NewTerm{Lewis operator}\\index{Lewis operator}\", denoted $\\Delta_r$, the derivative of a quantity $X$ (standardized or not), with respect to the progress of the reaction $\\xi$ with constant temperature and pressure.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe symbol $\\Delta_r$ appears with the letter $r$ in subscript to show that this is a relative reaction quantity. In other words, it is the standard variation of the molecular quantity during the concerned reaction for a given reaction progress of one mole at a pressure of $1$ bar for a perfect gas.\n\t\\end{tcolorbox}\n\tWe must also not forget that the stoichiometric coefficients of the reactants are positive and those of the resulting products are negative (\\SeeChapter{see section of Analytical Chemistry}).\n\n\tThere are two reaction quantities that play important roles in chemistry:\n\t\\begin{enumerate}\n\t\t\\item The internal molar energy of reaction, named often \"\\NewTerm{internal energy of standard reaction}\\index{internal energy of standard reaction}\" of a chemical system:\n\t\t\n\n\t\t\\item The molar enthalpy of reaction, often named more \"\\NewTerm{standard enthalpy of reaction}\\index{standard enthalpy of reaction}\" of a chemical system:\n\t\t\n\t\\end{enumerate}\n\t\n\t\\subsubsection{Standard enthalpy of reaction}\n\tTherefore we can consider the following two cases after knowing the relation (\\SeeChapter{see section Thermodynamics}):\n\t\n\t\\begin{enumerate}\n\t\t\\item If the $A_i$ are in a condensed state, since the internal pressure does not apply we have:\n\t\t\n\t\twhich still remains to be taken with precaution following the scenarios!\n\n\t\t\\item If the $A_i$ are in the gaseous state (assumed perfect gas):\n\t\t\n\t\\end{enumerate}\n\tWe conclude that only gaz will intervene in this relation:\n\t\n\tThat we write conventionally:\n\t\n\tIt follows that in the special case where:\n\t\n\t(Which is in fact an unfortunate notation... for the algebraic sum of the stoichiometric ratio that would equal to zero) for a given temperature then we have:\n\t\n\twhere it must be remembered that the stochiometric coefficients of the products are counted as positive, while those of the reactants are counted as negative (\\SeeChapter{see section Analytical Chemistry}).\n\t\n\tThus, the variation of the enthalpy function corresponds to the variation of the quantity of heat absorbed or emitted in an isobaric transformation at a given temperature $T$. This is why it is sometimes denoted $\\Delta_r H_{T,P^\\circ}$.\n\n\tA chemical reaction that has an enthalpy reaction (which is for recall the instantaneous change in enthalpy during a reaction) that is negative is said to be \"\\NewTerm{exothermic}\\index{exothermic}\", since it releases heat into the environment (constant pressure obligedby the definition of enthalpy reaction!), then a chemical reaction whose reaction enthalpy is positive is say to be \"\\NewTerm{endothermic}\\index{endothermic}\" since it then requires a supply of heat to occur (so the vocabulary is the same as in the section of Thermodynamics).\n\n\tThus, according to the preceding developments, if we denote with an index $p$ the products and with an index $i$ the reactants, we often find the standard enthalpy of reaction as follows if the stochiometric coefficients are counted as positive:\n\t\n\tInto this form, then we see well that the standard reaction enthalpy corresponds to the difference partial molar enthalpies between the products and reactants of the transformation. This is nothing more than the \"\\NewTerm{Hess's law}\\index{Hess's law}\" set in the 19th century by the Swiss chemist Henri Hess. The law the states that the total enthalpy change during the complete course of a chemical reaction is the same whether the reaction is made in one step or in several steps and can be understood as an expression of the principle of conservation of energy, also expressed in the first law of thermodynamics, and the fact that the enthalpy of a chemical process is independent of the path taken from the initial to the final state (i.e. enthalpy is a state function).\n\n\tBecause in a system at equilibrium, the initial energy is always greater than or equal to the final energy (all systems tend to move towards to a more stable state with minimum energy as we have study it in the section of Thermdynamics), then the standard enthalpy of reaction $\\Delta_r H^\\circ$ may be only negative or zero.\n\n\tIf a chemical reaction at constant pressure and at a specific temperature gives only a single chemical compound (product) then the standard enthalpy of reaction is named  \"\\NewTerm{standard enthalpy of formation}\\index{standard enthalpy of formation}\" and is denoted by $\\Delta_f H^\\circ$.\n\n\tIn fact, the interest of prior-previous relation is that the chemist can simply, without having to know the quantities of material involved, determine just by knowing the stochiometric coefficients of an isobaric  gas or condensed chemical reaction (if he agrees that it will then be an approximation for the latter case) that the instantaneous variation of the molar internal energy during the progress of the reaction at a given temperature is equal to the instantaneous variation of the molar enthalpy .\n\n\tTwo different situations arise then:\n\t\\begin{enumerate}\n\t\t\\item The difference between the instantaneous variation of the molar internal energy and the molar enthalpy is zero: therefore, the chemical reaction (at a given temperature) does not instantaneously occupies a larger volume and thus don't loss energy to push (\"unnecessarily\") the pressure of the gas surrounding the studied reaction (this can be seen as a money saving in terms of energy in the chemical industry). In this case, the standard enthalpy of reaction is simply equal to the heat of reaction at constant pressure $Q_p$.\n\n\t\t\\item The difference between the instantaneous variation of the molar internal energy and the molar enthalpy is positive: Therefore, the chemical reaction (at the given temperature) instantly occupies a greater volume and thus loses some energy to push (\"unnecessarily\") the pressure of the gas surrounding the studied reaction  (this can be seen as a waste of money in terms of energy efficiency in the chemical industry).\n\t\\end{enumerate}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tObviously, it is possible to imagine a company that takes advantage of the change in volume of a reaction (case 2 above) that pushes the surrounding gas with a piston system to then produce mechanical energy... so it would be possible in certain situations to lose much less money (verbatim energy ...).\n\t\\end{tcolorbox}\n\tHowever a small difficulty arise, ... the standard enthalpy of a simple pure body (body formed of a single type of atom) can not be calculated in absolute terms because it depends on the internal energy which is very difficult to calculate (you must use the tools of quantum physics which raise insurmountable problems even in the beginning of the 21st century). This means we must define an arbitrary scale of molar enthalpies by setting an arbitrary zero enthalpy and adopted internationally (which is unfortunately not the case as far as we know!).\n\n\tThus, in order to set up tables of standard molars enthalpy, he was chosen to define the scale of enthalpy as follows: the standard molar enthalpy of a simple steady pure body in the standard state is equal to $0$ at $298$ [K]. It follows that the enthalpy of formation of a simple standard pure body is always equal to zero.\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tGiven the reaction:\n\t\n\tThat is to say, the dissociation of chlorine and phosphorus pentachloride in phosphorus trichloride. The tables give us at the temperature of $T=1000$ [K] the following value of the standard molar enthalpy of this reaction:\n\t\n\tThe variation of the value of the molar enthalpy of reaction being positive, it follows that the reaction is endothermic (requires a heat input hence the dissociation temperature of $1000$ [K]) and therefore the product is more volatile than the initial reactant.\n\n\tWe have the following algebraic sum of the stochiometric coefficients of the reaction:\n\t\n\tThat is (which is dimensionless since enthalpy is in molar value!):\n\t\n\ttherefore the reaction increase the pressure by creating an additional mole per mole of reactant.\n\n\tSince:\n\t\n\t\\end{tcolorbox}\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\tthen it comes:\n\t\n\tThis is then the part of internal energy absorbed by the system on the $156 \\;[\\text{kJ}\\cdot \\text{mol}^{-1}]$. The remainder (difference) is has just been used to push the surrounding atmosphere of the chemical reactor.\n\t\\end{tcolorbox}\n\t\n\t\\paragraph{Kirchhoff's Enthalpy Law}\\mbox{}\\\\\\\\\\\n\tKirchhoff's Enthalpy Law describes the enthalpy of a reaction's variation with temperature changes. In general, enthalpy of any substance increases with temperature, which means both the products and the reactants' enthalpies increase. The overall enthalpy of the reaction will change if the increase in the enthalpy of products and reactants is different.\n\t\n\tIn other words, in a more practical way, the latent heat - energy required to evaporate a liquid - is not the same at every temperature! . The difference between the Gas and Liquid energy levels increases at higher temperatures. Thus, the Kirchhoff's Enthalpy law enables the calculation of a new latent heat from an existing one with a known temperature change.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/chemistry/eirchooff_enthalpy_law.jpg}\t\n\t\t\\caption{Kirchoff's enthalpy law illustration}\n\t\\end{figure}\n\tSo the Kirchhoff enthalpy law idea is to express the variations of the enthalpy of reaction (molar or not) in function of the temperature from the knowledge of the heat capacity at constant pressure of the gaseous reactants.\n\n\tHe have built in previous developments the following relation:\n\t\n\twhich is the standard enthalpy of reaction at a given temperature in a system with a standard pressure.\n\n\tWe had also mentioned earlier above that $\\Delta_r$, for recall, is somewhat an unfortunate notation for the differential (Lewis) operator of progress of the reaction $\\mathrm{d}/\\mathrm{d}\\xi$.\n\t\n\tIf we focus on the influence of the temperature $T$ on $\\Delta_r H^\\circ$ we have just to write the exact differential:\n\t\n\tsince the algebraic variation of the standard enthalpy by definition depends only on the temperature.\n\n\tThe stochiometric coefficients $v_i$ are not dependent of the temperature at least until this latter does not changes the essence itself of the studied transformation.\n\t\n\tWe then have under this approximation (assumption):\n\t\n\tNow we have defined in the section of Thermodynamics the heat capacity at constant pressure which is written:\n\t\n\tSo if the conditions are standard (the enthalpy therefore depends only on the temperature), we get is the exact differential:\n\t\n\tThen we have:\n\t\n\tWe can of course integrate the latter relations to get the common form use in practice and available in many books:\n\t\n\tThen we have:\n\t\n\twhere $T_0$ is a particular temperature for which $\\Delta H^\\circ (T_0)$ is known.\n\n\tIn a temperature range very close to $T_0$ chemists sometimes approximate the variation as being linear. That is equivalent to put:\n\t\n\tIt then immediately comes from the prior-previous relation:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tQuite often, the variation of the enthalpy of reaction with temperature is negligible!\n\t\\end{tcolorbox}\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tFor the reaction (graphite + oxygen yielding to carbon dioxide) we would like to know $\\Delta_r H^\\circ$ at $1000$ [K]:\n\t\n\tFor this, it is given in the tables for this reaction at $298$ [K]:\n\t\n\tand:\n\t\n\tWe write in lowercase the heat capacities above as the are enough subscripts to not add a third one ($m$) that mean these are molar heat capacities.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWhen the enthalpy of reaction is given at the reference temperature (nowadays...) at $298$ [K] chemists then speak as we have already mention earlier above the \"standard enthalpy of formation\".\n\t\\end{tcolorbox}\n\tThe value of the molar enthalpy of reaction being negative, it follows that the reaction is exothermic (it is tendency of nature to favor exothermic reactions to stabilize systems in their minimal energy states).\n\t\\end{tcolorbox}\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\tWe then have immediately:\n\t\n\tThus the variation is of $-560\\;[\\text{kJ}\\cdot \\text{mol}^{-1}]$, that is a variation of about $+0.1\\%$. It follows that the higher the temperature increase, more is the reaction exothermic. In fact, the choice of this particular temperature of $1000$ [K] is not innocent because it is from this temperature that experiments shows that the reaction also produces carbon monoxide.\n\t\\end{tcolorbox}\n\tWe can also conclude that some exothermic reactions and having a enthalpy of reaction that decreases rapidly with temperature can blow up!\n\t\n\tFinally, let us indicate that in practice we often use the term \"\\NewTerm{calorific power}\\index{calorific power}\" or \"\\NewTerm{Heat of combustion}\\index{Heat of combustion}\" ,which is simply the fact ... the enthalpy  of reaction per unit mass of fuel or the energy obtained by combusting a kilogram of fuel.\n\n\tThus,  for Gasoline, we have following what give tables (under the assumption that this number is correct):\n\t\n\tAnd we can have fun by calculating the amount of Gasoline needed to accelerate a car of $1000$ [kg] from $0$ to $100\\;[\\text{km}\\cdot \\text{h}^{-1}]$ with a yield of $\\eta=35\\%$ at a temperature of $293$ [K]. Thus we have:\n\t\n\tand to get the amount of fuel in liters the tables give us the for Gasoline density about $700\\;[\\text{kg}\\cdot \\text{m}^{-3}]$ which gives finally a volume in liters of:\n\t\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{20} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 23 votes,  58.26\\%}} \n\t\\end{tabular} \n\t\\end{flushright}", "meta": {"hexsha": "57fcacf05fc6eec4f2443546dbf3002bffdf7592", "size": 117319, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter_Chemistry.tex", "max_stars_repo_name": "lefevred/Opera_Magistris_Francais_v3", "max_stars_repo_head_hexsha": "71a881b8dfdf0ac566c59442244e6ed5f9a2c413", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter_Chemistry.tex", "max_issues_repo_name": "lefevred/Opera_Magistris_Francais_v3", "max_issues_repo_head_hexsha": "71a881b8dfdf0ac566c59442244e6ed5f9a2c413", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter_Chemistry.tex", "max_forks_repo_name": "lefevred/Opera_Magistris_Francais_v3", "max_forks_repo_head_hexsha": "71a881b8dfdf0ac566c59442244e6ed5f9a2c413", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.2087209302, "max_line_length": 1048, "alphanum_fraction": 0.767565356, "num_tokens": 28798, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.44199868391227837}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array, tikz,tkz-berge, calrsfs}\n\\usepackage{tkz-graph}\n\n\\title{Matroids And their Graphs}\n\\author{o.mcdonnell4@nuigalway.ie }\n\\date{19 January 2018}\n\n\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem*{cor}{Corollary}\n\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\\newtheorem{conj}{Conjecture}[section]\n\\newtheorem{exmp}{Example}[section]\n\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\\newtheorem*{note}{Note}\n\n\\newenvironment{rcases}\n  {\\left.\\begin{aligned}}\n  {\\end{aligned}\\right\\rbrace}\n\n\\newcounter{excercise}\n\\newcounter{solution}\n\\newcounter{Question}\n\n\\newcommand\\Excercise{%\n  \\textbf{Excercise:}~%\n  \\setcounter{solution}{0}%\n}\n\n\\newcommand\\TheSolution{%\n  \\textbf{Solution:}\\\\%\n}\n\n\\newcommand\\Question{%\n    \\textbf{Question:}~%\n    \\setcounter{Question}{0}%\n}\n\\newcommand\\Notation{%\n  \\textbf{Notation:}~%\n}\n\n\\newcommand\\Proof{%\n    \\textbf{Proof:}~%\n}\n\n\\setlength{\\droptitle}{-10em}\n\n\\begin{document}\n\\maketitle\n \n \\section{Cardinality of maximal independent sets}\n \n \\begin{thm}\n Show that if $\\mathcal{I}$ is a non-empty hereditary set of subsets of a finite set E, then $(E,\\mathcal{I})$ is a matroid if and only if, for all $X \\subset E$, all maximal members of $\\{I : I \\in \\mathcal{I} $ and $ I \\subset X\\}$ have the same number of elements.\n \\end{thm}\n \n\\noindent \\Proof $(\\implies)$ Let $B_1 , B_2$ be maximal elements of $\\{I : I \\in \\mathcal{I} $and $ I \\subset X\\}$ \\\\\n\\noindent And assume $|B_1| < |B_2|$\nThen since $B_1, B_2 \\in \\mathcal{I}$\n\\\\\nThere exists $e \\in (B_2 \\setminus B_1)$ such that $B_1 \\cup \\{e\\} \\in \\mathcal{I}$\n\\\\\nThis contradicts our maximality of $B_1$.\\\\\n\n \\noindent $\\implies$ All maximal elements of the set $\\{I : I \\in \\mathcal{I} $ and $ I \\subset X\\}$ in our matroid M have the same cardinality.\n \\\\ \\qed\n \\end{document}", "meta": {"hexsha": "8cd38383e977f72cc9b17c19296c60fa03bf5a59", "size": 2005, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeXPdfs/Protos/maximal_cardinality.tex", "max_stars_repo_name": "emcd123/Matroids", "max_stars_repo_head_hexsha": "f1ab7a5164a60b753ba429ef7ba9ce36517d4439", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeXPdfs/Protos/maximal_cardinality.tex", "max_issues_repo_name": "emcd123/Matroids", "max_issues_repo_head_hexsha": "f1ab7a5164a60b753ba429ef7ba9ce36517d4439", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeXPdfs/Protos/maximal_cardinality.tex", "max_forks_repo_name": "emcd123/Matroids", "max_forks_repo_head_hexsha": "f1ab7a5164a60b753ba429ef7ba9ce36517d4439", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-21T18:03:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-21T18:03:07.000Z", "avg_line_length": 26.038961039, "max_line_length": 267, "alphanum_fraction": 0.702244389, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160664, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4419986802054383}}
{"text": "\\section{Introduction}\n  Online marketplaces can be categorized as centralized and decentralized.\n  Two examples of each category are \\href{http://www.ebay.com}{ebay} and \\href{https://openbazaar.org/}{OpenBazaar}.\n  The common denominator of established online marketplaces is that the reputation of each vendor and client is typically\n  expressed in the form of stars and user-generated reviews that are viewable by the whole network.\n\n  The goal of ``Trust Is Risk'' is to offer a reputation system for decentralized marketplaces where the trust each user gives\n  to the other users is quantifiable in monetary terms. The central assumption used throughout this paper is that trust is\n  equivalent to risk, or the proposition that $Alice$'s \\textit{trust} in another user $Charlie$ is defined as the\n  \\textit{maximum sum of money} $Alice$ can lose when $Charlie$ is free to choose any strategy. To flesh out this concept, we\n  will use \\textit{lines of credit} as proposed by Sanchez \\cite{loc}. $Alice$ joins the network by explicitly entrusting some\n  money to another user, say her friend, $Bob$ (see Fig.~\\ref{fig:bottleneckA} and~\\ref{fig:bottleneckB}). If $Bob$ has\n  already entrusted some money to a third user, $Charlie$, then $Alice$ indirectly trusts $Charlie$ since if the latter wished\n  to play unfairly, he could have already stolen the money entrusted to him by $Bob$. We will later see that $Alice$ can now\n  engage in economic interaction with $Charlie$.\n\n  To implement lines-of-credit, we use Bitcoin \\cite{bitcoin}, a decentralized cryptocurrency that differs from conventional\n  currencies in that it does not depend on trusted third parties. All transactions are public as they are recorded on a\n  decentralized ledger, the blockchain. Each transaction takes some coins as input and produces some coins as output. If the\n  output of a transaction is not connected to the input of another one, then this output belongs to the UTXO, the set of\n  unspent transaction outputs. Intuitively, the UTXO contains all coins not yet spent.\n  \\medskip \\ \\\\\n  \\subimport{common/figures/}{simpleexample.tikz}\n  \\noindent We propose a new kind of wallet where coins are not exclusively owned, but are placed in shared accounts materialized\n  through 1-of-2 multisigs, a bitcoin construct that permits any one of two pre-designated users to spend the coins contained\n  within a shared account \\cite{masteringbitcoin}. We use the notation 1/$\\{Alice, Bob\\}$ to represent a 1-of-2 multisig that\n  can be spent by either $Alice$ or $Bob$. In this notation, the order of names is irrelevant, as either user can spend.\n  However, the user who deposits the money initially into the shared account is relevant -- she is the one risking her money.\n\n  Our approach changes the user experience in a subtle but drastic way. A user no more has to base her trust towards a\n  store on stars or ratings which are not expressed in financial units. She can simply consult her wallet to decide whether\n  the store is trustworthy and, if so, up to what value, denominated in bitcoin. This system works as follows: Initially\n  $Alice$ migrates her funds from her private bitcoin wallet to 1-of-2 multisig addresses shared with friends she\n  comfortably trusts. We call this direct trust. Our system is agnostic to the means players use to determine who is\n  trustworthy for these direct 1-of-2 deposits. Nevertheless, these deposits contain an objective value visible to the network\n  that can be used to deterministically evaluate subjective indirect trust towards other users.\n\n  Suppose $Alice$ is viewing the listings of vendor $Charlie$. Instead of his stars, $Alice$ sees a positive value calculated\n  by her wallet representing the maximum value she can safely pay to purchase from $Charlie$. This value, known as indirect\n  trust, is calculated in Theorem~\\ref{trustflow} -- Trust Flow. Indirect trust towards a user is not global but subjective;\n  each user views a personalized indirect trust based on the network topology.  The indirect trust reported by our system\n  maintains the following desired security property: If $Alice$ makes a purchase from $Charlie$, then she is exposed to no\n  more risk than she was already taking willingly. The existing voluntary risk is exactly that which $Alice$ was taking by\n  sharing her coins with her trusted friends. We prove this in Theorem~\\ref{riskinv} -- Risk Invariance. Obviously it is not\n  safe for $Alice$ to buy anything from any vendor if she has not directly entrusted any value to other users.\n\n  In Trust Is Risk the money is not invested at the time of purchase and directly to the vendor, but at an earlier point in\n  time and only to parties that are trustworthy for out of band reasons. The fact that this system can function in a\n  completely decentralized fashion will become clear in the following sections. We prove this in Theorem~\\ref{sybil} -- Sybil\n  Resilience.\n\n  We make the design choice that an entity can express her trust maximally in terms of her available capital. Thus, an\n  impoverished player cannot allocate much direct trust to her friends, no matter how trustworthy they are. On the other hand,\n  a rich player may entrust a small fraction of her funds to a player that she does not extensively trust and still exhibit\n  more direct trust than the impoverished player. There is no upper limit to trust; each player is only limited by her funds.\n  We thus take advantage of the following remarkable property of money: To normalise subjective human preferences into\n  objective value.\n\n  A user has several incentives to join. First, she has access to otherwise inaccessible stores. Moreover, two friends can\n  formalize their mutual trust by directly entrusting the same amount to each other. A company that casually subcontracts\n  others can express its trust towards them. Governments can choose to directly entrust citizens with money and confront them\n  using a corresponding legal arsenal if they make irresponsible use of this trust. Banks can provide loans as outgoing and\n  manage savings as incoming direct trust. Last, the network is an investment and speculation field since it constitutes a new\n  area for financial activity.\n\n  Observe that the same physical person can maintain multiple pseudonymous identities in the same trust network and that\n  multiple independent trust networks for different purposes can coexist. \\ifdefined\\proceedings \\else On the other hand, the\n  same pseudonymous identity can be used to establish trust in different contexts.\\fi\n\n  Trust Is Risk is not just a theoretical conception, but can be deployed and applied in existing decentralized markets such\n  as OpenBazaar. All the necessary bitcoin constructs such as multisigs are readily available. Our only concern pertains to\n  the scalability of such an implementation, but we are confident that such difficulties can be overcome.\n", "meta": {"hexsha": "1b2bc19b884e21041dcb11e86129d5658bc2e207", "size": 6911, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fc17/introduction.tex", "max_stars_repo_name": "dionyziz/DecentralizedTrust", "max_stars_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2017-03-15T14:33:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T14:07:45.000Z", "max_issues_repo_path": "fc17/introduction.tex", "max_issues_repo_name": "dionyziz/DecentralizedTrust", "max_issues_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-03-07T12:25:26.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-31T14:42:20.000Z", "max_forks_repo_path": "fc17/introduction.tex", "max_forks_repo_name": "dionyziz/DecentralizedTrust", "max_forks_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-07T10:49:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-28T06:32:33.000Z", "avg_line_length": 94.6712328767, "max_line_length": 129, "alphanum_fraction": 0.7897554623, "num_tokens": 1506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4419986764985984}}
{"text": "\n\n    \\filetitle{!substitutions}{Define text substitutions}{modellang/substitutions}\n\n\t\\paragraph{Syntax}\\label{syntax}\n\n\\begin{verbatim}\n!substitutions\n    SubsName := TextString;\n    SubsName := TextString;\n    ...\n\\end{verbatim}\n\n\\paragraph{Description}\\label{description}\n\nThe \\texttt{!substitutions} starts a block with substitution\ndefinitions. The definition of each substitution must begin with the\nname of the substitution, followed by a colon-equal sign, \\texttt{:=},\nand a text string ended with a semi-colon. The semi-colon is not part of\nthe substitution.\n\nThe substitutions can be used in any of the model equations, i.e.~in\n\\href{modellang/transitionequations}{transition equations},\n\\href{modellang/measurementequations}{measurement equations},\n\\href{modellang/dtrends}{deterministic trend equations}, and\n\\href{modellang/links}{dynamic links}. Each occurence of the name of a\nsubstitution enclosed in dollar signs, i.e.\n\\texttt{\\$substitution\\_name\\$}, in model equations will be replaced\nwith the text string from the substitution's definition.\n\nSubstitutions can also refer to other substitutions; make sure, though,\nthat they are not recursive. Also, remember to parenthesise the\ndefinitions of the substitutions (or the references to them) in the\nequations properly so that the resulting mathematical expressions are\nevaluated properly.\n\n\\paragraph{Example}\\label{example}\n\n\\begin{verbatim}\n!substitution\n    a := ((omega1+omega2)/(omega1+omega2+omega3));\n\n!transition_equations\n    X = $a$^2*Y + (1-$a$^2)*Z;\n\\end{verbatim}\n\nIn this example, we assume that \\texttt{omega1}, \\texttt{omega2}, and\n\\texttt{omega3} are declared as parameters. The equation will expand to\n\n\\begin{verbatim}\n    X = ((omega1+omega2)/(omega1+omega2+omega3))^2*Y + ...\n      (1-((omega1+omega2)/(omega1+omega2+omega3))^2)*Z;\n\\end{verbatim}\n\nNote that if had not used the outermost parentheses in the definition of\nthe substitution, the resulting expression would not have given us what\nwe meant: The square operator would have only applied to the\ndenominator.\n\n\n", "meta": {"hexsha": "8530449be0011a207383144bfa783665a1cd46d0", "size": 2059, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/modellang/substitutions.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/modellang/substitutions.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/modellang/substitutions.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 33.7540983607, "max_line_length": 82, "alphanum_fraction": 0.7659057795, "num_tokens": 533, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4419986700648608}}
{"text": "%===============================================================================\n% $Id: ifacconf.tex 19 2011-10-27 09:32:13Z jpuente $  \n% Template for IFAC meeting papers\n% Copyright (c) 2007-2008 International Federation of Automatic Control\n%===============================================================================\n\\documentclass{ifacconf}\n\n%\\input{./macros.tex}\n\\usepackage{graphicx}      % include this line if your document contains figures\n\\usepackage{natbib}        % required for bibliography\n\\usepackage{amsmath, amsxtra, amsfonts,amscd,amssymb}\n\\setcounter{tocdepth}{3}\n\\usepackage{graphicx,wrapfig}\n\\usepackage{epstopdf}\n\\usepackage{url}\n\\usepackage[algo2e,linesnumbered, vlined,ruled]{algorithm2e}\n\\usepackage{float}\n\\usepackage{multirow}\n\\usepackage{mathrsfs}\n%===============================================================================\n\n\\begin{document}\n\\begin{frontmatter}\n\n\n\\title{\n\tLinear Mixed-Effect Models}% \\thanksref{footnoteinfo}}    % Title, preferably not more than 10 words.\n\n%\\thanks[footnoteinfo]{}\n\n\\author[First]{Saket Choudhary} \n\n\n\n\n\\address[First]{University of Southern California, \n   LA, CA 90089 USA (e-mail: skchoudh@ usc.edu).}\n\n\n\\begin{abstract}                % Abstract of not more than 250 words.\n\\emph{Linear Mixed-Effect Models} are an extension of \\emph{Linear Regression} that describe the relationship between response variable $\\mathcal{Y}$ and independent variables ${X}$ such that the coefficients can vary with respect to one or more grouping variables and hence at least one independent covariate should be categorical.\n\nMixed-Effects models find use in \\emph{longitudinal} or repeated measures study, where repeated measurements are made on \\emph{experimental} or \\emph{observational} units.\n\nMixed-Effects models make use of constrained optimisation to arrive at the Maximum Likelihood or Restricted Maximum Likelihood estimate of the parameters.\n\n\\end{abstract}\n\n\n\\end{frontmatter}\n\n\\section{Problem description}\nConsider a Linear Regression Problem:\n$$\n\\mathcal{Y} = X\\beta + \\epsilon\n$$\n\nWhere $\\epsilon \\sim \\mathcal{N}(0,\\sigma^2I)$\nand $\\beta$ is a p-dimensional coefficient vector;\n$X$ is $n \\times p$ model matrix. There are two parameters\nin this model: $\\beta$ and $\\sigma^2$\n\nand hence for a linear model:\n$$\ny \\sim \\mathcal{N}({X\\beta,\\sigma^2I})\n$$\n\n\nMixed-effects models the response with an additional \"random-effect\" $\\mathcal{B}$ such that:\n\n$$\n(\\mathcal{Y}|\\mathcal{B}=b) = \\mathcal{N}(XB+Zb, \\sigma^2I)\n$$\nwhere $Z$ is a $n \\times q$ model matrix just like $X$ but for the random-effect covariates $\\mathcal{B}$ which we fix at $b$ and then model $b$ as another normal random variable:\n\n$$\n\\mathcal{B} \\sim \\mathcal{N}(0,\\Sigma)\n$$\n\nwhere $\\Sigma$ is a parameterized $q\\times q$ covariance matrix.\nThe parameter estimation now can be down by separating(profiling) the log-likelihood.(Details Skipped, since I do not understand them yet)\n\n\n\n\n\\section{Goals}\n\n\\begin{itemize}\n\t\\item Understand the derivation/math behind parameter estimation\n\t\\item Use available modeling libraries to demonstrate at least one use case  of mixed-effects models\n\\end{itemize}\n\n\n\\section{References}\n\\begin{itemize}\n\\item Pinherio, J. C., and D. M. Bates. Mixed-Effects Models in S and S-PLUS. Statistics and Computing Series, Springer, 2004.\n\n\\item Bates, Douglas, et al. \"Fitting linear mixed-effects models using lme4.\" arXiv preprint arXiv:1406.5823 (2014).\n\t\n\\end{itemize}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "fb9428c9c800cac905c48054c0be5a0d7b152afc", "size": 3461, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2015_Fall/MATH-547/saket_mixed_effects_proposal.tex", "max_stars_repo_name": "NeveIsa/hatex", "max_stars_repo_head_hexsha": "c5cfa2410d47c7e43a476a8c8a9795182fe8f836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2015-09-10T02:45:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T03:20:47.000Z", "max_issues_repo_path": "2015_Fall/MATH-547/saket_mixed_effects_proposal.tex", "max_issues_repo_name": "NeveIsa/hatex", "max_issues_repo_head_hexsha": "c5cfa2410d47c7e43a476a8c8a9795182fe8f836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-09-16T23:11:00.000Z", "max_issues_repo_issues_event_max_datetime": "2015-09-23T21:21:52.000Z", "max_forks_repo_path": "2015_Fall/MATH-547/saket_mixed_effects_proposal.tex", "max_forks_repo_name": "saketkc/hatex", "max_forks_repo_head_hexsha": "c5cfa2410d47c7e43a476a8c8a9795182fe8f836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2015-09-25T19:06:45.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-10T03:21:09.000Z", "avg_line_length": 32.9619047619, "max_line_length": 332, "alphanum_fraction": 0.6963305403, "num_tokens": 916, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043814, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.4419986663580208}}
{"text": "\\documentclass[11pt, a4]{article}\n\\usepackage{qtree}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{mathtools}\n\\usepackage{tikz}\n\n\\usetikzlibrary{positioning}\n\\newcommand\\tab[1][0.5cm]{\\hspace*{#1}}\n\n%% define left/right/full outer join symbols\n\\def\\ojoin{\\setbox0=\\hbox{$\\bowtie$}%\n  \\rule[-.02ex]{.25em}{.4pt}\\llap{\\rule[\\ht0]{.25em}{.4pt}}}\n\\def\\leftouterjoin{\\mathbin{\\ojoin\\mkern-5.8mu\\bowtie}}\n\\def\\rightouterjoin{\\mathbin{\\bowtie\\mkern-5.8mu\\ojoin}}\n\\def\\fullouterjoin{\\mathbin{\\ojoin\\mkern-5.8mu\\bowtie\\mkern-5.8mu\\ojoin}}\n\\newcommand*{\\QEDB}{\\null\\nobreak\\hfill\\ensuremath{\\square}}%\n\n\\setcounter{section}{1}\n\\begin{document}\n\\title{Exercise Sheet 3}\n\n\\section*{Exercise Sheet 3}\n\\subsection*{Exercise 1}\nGive the query graphs for the two queries from the first exercise sheet.\n\\begin{verbatim}\nSELECT s1.name\nFROM studenten s1\nJOIN hoeren h1 ON s1.matrnr = h1.matrnr\nJOIN hoeren h2 ON h1.vorlnr = h2.vorlnr\nJOIN studenten s2 ON h2.matrnr = s2.matrnr\nWHERE s2.name = 'Schopenhauer'\nAND s1.name != 'Schopenhauer';\n\\end{verbatim}\n\\begin{tikzpicture}[node distance=5cm]\n  \\tikzset{every loop/.style={}}%removes arrow head from all loops.\n  \\node (s1) at (0,0) {studenten s1};\n  \\node (h1) [right of=s1] {hoeren h1};\n  \\node (h2) [right of=h1] {hoeren h2};\n  \\node (s2) [below=1cm of h2] {studenten s2};\n  \\draw (s1) -- (h1) node[pos=0.5,above] {\\tiny s1.matrnr = h1.matrnr};\n  \\draw (h1) -- (h2) node[pos=0.5,above] {\\tiny h1.vorlnr = h2.vorlnr};\n  \\draw (h2) -- (s2) node[pos=0.5,left] {\\tiny h2.matrnr = s2.matrnr};\n  \\draw (s1) edge [loop above] node {\\tiny s1.name != 'Schopenhauer'} (s1);\n  \\draw (s2) edge [loop below] node {\\tiny s2.name == 'Schopenhauer'} (s2);\n\\end{tikzpicture}\n\n\n\\begin{verbatim}\nSELECT p.persnr, p.name\nFROM professoren p\nJOIN vorlesungen v ON v.gelesenvon = p.persnr\nJOIN hoeren h1 ON h1.vorlnr = v.vorlnr\nJOIN hoeren h2 ON h2.vorlnr = h1.vorlnr\nWHERE h1.matrnr != h2.matrnr;\n\\end{verbatim}\n\\begin{tikzpicture}[node distance=5cm]\n  \\node (p) at (0,0) {professoren p};\n  \\node (v) [right of=p] {vorlesungen v};\n  \\node (h1) [right of=v] {hoeren h1};\n  \\node (h2) [below=1cm of h1] {hoeren h2};\n  \\draw (p) -- (v) node[pos=0.5,above] {\\tiny p.persnr = v.gelesenvon};\n  \\draw (v) -- (h1) node[pos=0.5,above] {\\tiny v.vorlnr = h1.vorlnr};\n  \\draw (h1) -- (h2) node[pos=0.5,left] {\\tiny h1.vorlnr = h2.vorlnr $\\land$ h1.matrnr != h2.matrnr};\n\\end{tikzpicture}\n\n\\newpage\n\\subsection*{Exercise 2}\n$|R_1| = 1, |R_2| = 40, |R_3| = 40, |R_4| = 1, f_{1,2} = 0.75, f_{2,3} = 0.01, f_{3,4} = 0.75$\\\\\n\\vspace{.2cm}\\\\\n\\begin{tikzpicture}[node distance=2cm]\n  \\node (R1) at (0,0) {$R_1$};\n  \\node (R2) [right of=R1] {$R_2$};\n  \\node (R3) [right of=R2] {$R_3$};\n  \\node (R4) [right of=R3] {$R_4$};\n  \\draw (R1) -- (R2) node[pos=0.5,below] {\\tiny $f_{1,2} = 0.75$};\n  \\draw (R2) -- (R3) node[pos=0.5,below] {\\tiny $f_{2,3} = 0.01$};\n  \\draw (R3) -- (R4) node[pos=0.5,below] {\\tiny $f_{3,4} = 0.75$};\n  \\node (CR1) [below=0.01cm of R1] {\\tiny{1}};\n  \\node (CR2) [below=0.01cm of R2] {\\tiny{40}};\n  \\node (CR3) [below=0.01cm of R3] {\\tiny{40}};\n  \\node (CR4) [below=0.01cm of R4] {\\tiny{1}};\n\\end{tikzpicture}\\\\\n\\vspace{.2cm}\\\\\n\\begin{tabular}{l|r|r}\n    $X$ & $C_{\\text{out}}$ & $|X|$\\\\\n    \\hline\n    $R_1 \\bowtie R_2$ & 30 & 30\\\\\n    $R_2 \\bowtie R_3$ & 16 & 16\\\\\n    $R_3 \\bowtie R_4$ & 30 & 30\\\\\n    &&\\\\\n    $R_1 X R_3$ & 40 & 40\\\\\n    $R_1 X R_4$ & 1 & 1\\\\\n    \\hline\n    $(R_1 \\bowtie R_2)\\bowtie R_3$ & 42 & 12\\\\\n    $(R_2\\bowtie R_3) \\bowtie R_1$ & 28 & 12\\\\\n    &&\\\\\n    $(R_1 X R_3)\\bowtie R_2$ & 52 & 12\\\\\n    $(R_1 X R_3)\\bowtie R_4$ & 70 & 30\\\\\n    $(R_1 X R_4)\\bowtie R_2$ & 31 & 30\\\\\n    \\hline\n    $(R_1 \\bowtie R_2)\\bowtie (R_3 \\bowtie R_4)$ & 69 & 9\\\\\n    $(R_1 X R_3)\\bowtie (R_2 X R_4)$ & 90 & 9\\\\\n    \\textcolor{red}{$(R_1 X R_4)\\bowtie (R_2 \\bowtie R_3)$} & \\textcolor{red}{26} & \\textcolor{red}{9}\\\\\n    &&\\\\\n    $((R_1 \\bowtie R_2)\\bowtie R_3) \\bowtie R_4$ & 51 & 9\\\\\n    $((R_2 \\bowtie R_3)\\bowtie R_1) \\bowtie R_4$ & 37 & 9\\\\\n    $((R_1 X R_3)\\bowtie R_2) \\bowtie R_4$ & 61 & 9\\\\\n    $((R_1 X R_3)\\bowtie R_4) \\bowtie R_2$ & 79 & 9\\\\\n    $((R_1 X R_4)\\bowtie R_2) \\bowtie R_3$ & 40 & 9\\\\\n\\end{tabular}\n\n\\end{document}\n", "meta": {"hexsha": "d53a2b82022f6c90ae0234824c4b70be1824f735", "size": 4168, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Query Optimization/assignments/Assignment 3.tex", "max_stars_repo_name": "mrahtapot/TUM", "max_stars_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 225, "max_stars_repo_stars_event_min_datetime": "2019-10-02T10:49:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:25:38.000Z", "max_issues_repo_path": "Query Optimization/assignments/Assignment 3.tex", "max_issues_repo_name": "mrahtapot/TUM", "max_issues_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-02-16T12:22:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-31T19:35:57.000Z", "max_forks_repo_path": "Query Optimization/assignments/Assignment 3.tex", "max_forks_repo_name": "mrahtapot/TUM", "max_forks_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 69, "max_forks_repo_forks_event_min_datetime": "2019-10-02T21:46:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T19:27:50.000Z", "avg_line_length": 36.5614035088, "max_line_length": 104, "alphanum_fraction": 0.6125239923, "num_tokens": 1960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4419090835771173}}
{"text": "\n\n\n\\begin{tabular}{lll}\n  \\centering\n  Author &  O. Bonnefon &2010\\\\\n  Revision& section \\ref{Sec:NE_motion} to \\ref{Sec:NE_TD} V. Acary&  05/09/2011\\\\\n  Revision& section \\ref{Sec:NE_motion}  V. Acary&  01/06/2016\\\\\n  Revision& complete edition V. Acary&  06/01/2017\\\\\n\n\\end{tabular}\n\n\\def\\glaw{\\cdot}\n\\def\\cg{\\sf \\small g}\n\n\\section{The equations of motion}\n\n\nIn the maximal coordinates framework, the most natural choice for the kinematic  variables and for the formulation of the equations of motion is the Newton/Euler formalism, where the equation of motion describes the translational and rotational dynamics of each body using a specific choice of parameters. For the translational motion, the position of the center of mass $x_{\\cg}\\in \\RR^3$ and its velocity  $v_{\\cg} = \\dot x_{\\cg} \\in \\RR^3$ is usually chosen. For the orientation of the body is usually defined by the rotation matrix $R$ of the body-fixed frame with respect to a given inertial frame.\n\nFor the rotational motion, a common choice is to choose the rotational velocity  $\\Omega \\in \\RR^3$ of the body expressed in the body--fixed frame. This choice comes from the formulation of a rigid body motion of a point $X$ in the inertial frame as\n\\begin{equation}\n  \\label{eq:1}\n  x(t) = \\Phi(t,X) = x_{\\cg}(t) + R(t) X.\n\\end{equation}\nThe velocity of this point can be written as\n\\begin{equation}\n  \\label{eq:2}\n  \\dot x(t) = v_{\\cg}(t) + \\dot R(t) X\n\\end{equation}\nSince $R^\\top R=I$, we get $R^\\top \\dot R + \\dot R^\\top R =0$. We can conclude that it exists a matrix $\\tilde \\Omega := R^\\top \\dot R $ such that $\\tilde \\Omega + \\tilde \\Omega^\\top=0$, i.e. a skew symmetric matrix. The notation $\\tilde \\Omega$ comes from the fact that there is a bijection between the skew symmetric matrix in $\\RR^{3\\times3}$ and $\\RR^3$ such that\n\\begin{equation}\n  \\label{eq:3}\n  \\tilde \\Omega x  = \\Omega \\times x, \\quad \\forall x\\in \\RR^3.\n\\end{equation}\nThe rotational velocity is then related to the $R$ by :\n\\begin{equation}\n  \\label{eq:angularvelocity}\n  \\widetilde \\Omega = R^\\top \\dot R, \\text { or equivalently, } \\dot R  = R \\widetilde \\Omega\n\\end{equation}\n\nUsing these coordinates, the equations of motion are given by \n\\begin{equation}\n  \\label{eq:motion-NewtonEuler}\n  \\left\\{\\begin{array}{rcl}\n      m \\;\\dot v_{\\cg}  & = &f(t,x_{\\cg}, v_{\\cg},  R,  \\Omega) \\\\\n      I \\dot \\Omega + \\Omega \\times I \\Omega &= & M(t,x_{\\cg}, v_{\\cg}, R, \\Omega) \\\\\n      \\dot x_{\\cg}&=& v_{\\cg}\\\\\n      \\dot R  &=& R \\widetilde \\Omega\n    \\end{array}\n  \\right.\n\\end{equation}\nwhere $m> 0$ is the mass, $I\\in \\RR^{3\\times 3}$ is the matrix of moments of inertia around the center of mass and the axis of the body--fixed frame.\n\nThe vectors $f(\\cdot)\\in \\RR^3$ and $M(\\cdot)\\in \\RR^3$ are the total forces and torques applied to the body. It is important to outline that the total applied forces $f(\\cdot)$ has to be expressed in a consistent frame w.r.t. to $v_{\\cg}$. In our case, it hae to be expressed in the inertial frame. The same applies for the moment $M$ that has to be expressed in the body-fixed frame. If we consider a moment $m(\\cdot)$ expressed in the inertial frame, then is has to be convected to  the body--fixed frame thanks to\n\\begin{equation}\n  \\label{eq:convected_moment}\n  M (\\cdot) =R^\\top  m (\\cdot)\n\\end{equation}\n\n\n\\begin{remark}\nIf we perform the time derivation of $RR^\\top =I$ rather than $R^\\top R=I$, we get $R \\dot R^\\top + \\dot R R^\\top =0$.  We can conclude that it exists a matrix $\\tilde \\omega := \\dot R R^\\top $ such that $\\tilde \\omega + \\tilde \\omega^\\top=0$, i.e. a skew symmetric matrix. Clearly, we have\n \\begin{equation}\n   \\label{eq:4}\n   \\tilde \\omega = R \\tilde \\Omega R^\\top\n \\end{equation}\n and it can be proved that is equivalent to $ \\omega =R \\Omega$. The vector $\\omega$ is the rotational velocity expressed in the inertial frame. The equation of motion can also be expressed in the inertial frame as follows\n  \\begin{equation}\n  \\label{eq:motion-NewtonEuler-inertial}\n  \\left\\{\\begin{array}{rcl}\n      m \\;\\dot v_{\\cg}  & = &f(t,x_{\\cg}, v_{\\cg},  R,  R^T \\omega) \\\\\n      J(R) \\dot \\omega + \\omega \\times J(R) \\omega &= & m(t,x_{\\cg}, v_{\\cg}, R, \\omega) \\\\\n      \\dot x_{\\cg}&=& v_{\\cg}\\\\\n      \\dot R  &=& \\widetilde \\omega R\n    \\end{array}\n  \\right.\n\\end{equation}\nwhere the matrix $J(R) = R I R^T$ is the inertia matrix in the inertial frame.\nDefining the angular momentum with respect to the inertial frame as\n\\begin{equation}\n  \\label{eq:1}\n  \\pi(t) = J(R(t)) \\omega(t)\n\\end{equation}\nthe equation of the angular motion is derived from the balance equation of the angular momentum\n\\begin{equation}\n  \\label{eq:5}\n  \\dot \\pi(t) = m(t,x_{\\cg}, v_{\\cg}, R, \\omega)).\n\\end{equation}\n\n\\end{remark}\n\nFor a given constant (time invariant) $\\tilde \\Omega$, let us consider the differential equation\n\\begin{equation}\n  \\label{eq:5}\n  \\begin{cases}\n    \\dot R(t) = R \\tilde \\Omega\\\\\n    R(0) = I\n  \\end{cases}\n\\end{equation}\nLet us recall the definition of the matrix exponential,\n\\begin{equation}\n  \\label{eq:6}\n  \\exp(A) = \\sum_{k=0}^{\\infty} \\frac {1}{k!} A^k\n\\end{equation}\nA trivial solution of \\eqref{eq:5} is $R(t) = \\exp(t\\tilde\\Omega) $ since\n\\begin{equation}\n  \\label{eq:7}\n  \\frac {d}{dt}(\\exp(At)) = \\exp(At) A.\n\\end{equation}\nMore generally, with the initial condition $R(t_0)= R_0$, we get the solution\n\\begin{equation}\nR(t) = R_0 \\exp((t-t_0)\\tilde\\Omega)\\label{eq:8}\n\\end{equation}\n\nAnother interpretation is as follows. From a (incremental) rotation vector, $\\Omega$ and its associated matrix $\\tilde \\Omega$, we obtain a rotation matrix by the exponentation of $\\tilde \\Omega$:\n\\begin{equation}\n  \\label{eq:9}\n  R = \\exp(\\tilde\\Omega).\n\\end{equation}\nSince we note that $\\tilde \\Omega^ 3 = - \\theta^2 \\tilde \\Omega$ with $\\theta = \\|\\Omega\\|$, it is possible to get a closed form of the matrix exponential of $\\tilde \\Omega$\n\\begin{equation}\n  \\label{eq:10}\n  \\begin{array}[lcl]{lcl}\n    \\exp(\\tilde \\Omega) &=& \\sum_{k=0}^{\\infty} \\frac {1}{k!} (\\tilde \\Omega)^k \\\\\n                        &=&  I_{3\\times 3} + \\sum_{k=1}^{\\infty} \\frac {(-1)^{k-1}}{(2k-1)!}  \\theta ^{2k-1} \\tilde \\Omega + (\\sum_{k=0}^{\\infty} \\frac {(-1)^{k-1}}{(2k)!} \\theta)^{2k-2} \\tilde \\Omega^2\\\\[2mm]\n                        &=&  I_{3\\times 3} + \\frac{\\sin{\\theta}} {\\theta} \\tilde \\Omega +  \\frac{(\\cos{\\theta}-1)}{\\theta^2}\\tilde \\Omega^2   \n  \\end{array} \n\\end{equation}\nthat is\n\\begin{equation}\n  \\label{eq:11}\n  R =  I_{3\\times 3} + \\frac{\\sin{\\theta}} {\\theta} \\tilde \\Omega +  \\frac{(\\cos{\\theta}-1)}{\\theta^2}\\tilde \\Omega^2  \n\\end{equation}\nThe formula \\eqref{eq:11} is the Euler--Rodrigues formula that allows to compute the rotation matrix on closed form.\n\n\n\\begin{ndrva}\n  todo :\n  \\begin{itemize}\n  \\item add the formulation in the inertial frame of the Euler\n    equation with $\\omega =R \\Omega$.\n  \\item Check that \\eqref{eq:10} is the Euler-Rodrigues formula and not the Olinde Rodrigues formula. (division by $\\theta$)\n\\end{itemize}\n\n\\end{ndrva}\n\nIn the numerical practice, the choice of the rotation matrix is not convenient since it introduces redundant parameters. Since $R$ must belong to $SO^+(3)$, we have also to satisfy $\\det(R)=1$ and $R^{-1}=R^\\top$. In general, we use a reduced vector of parameters $p\\in\\RR^{n_p}$ such $R = \\Phi(p)$ and $\\dot p = \\psi(p)\\Omega $. We denote  by $q$ the vector of coordinates of the position and the orientation of the body, and by $v$ {the body twist}:\n\\begin{equation}\n  q \\coloneqq \\begin{bmatrix}\n    x_{\\cg}\\\\\n    p\n  \\end{bmatrix},\\quad \n  v \\coloneqq \\begin{bmatrix}\n     v_{\\cg}\\\\\n     \\Omega\n   \\end{bmatrix}.\n \\end{equation}\n The relation between $v$ and the time derivative of $q$ is\n\\begin{equation}\n  \\label{eq:TT}\n  \\dot q = \n  \\begin{bmatrix}\n     \\dot x_{\\cg}\\\\\n     \\psi(p) \\dot p\n   \\end{bmatrix}\n   = \n   \\begin{bmatrix}\n     I & 0 \\\\\n     0 & \\psi(p)\n   \\end{bmatrix}\n   v\n   \\coloneqq\n   T(q) v\n\\end{equation}\nwith $T(q) \\in \\RR^{{3+n_p}\\times 6}$.\n{Note that the twist $v$ is not directly the time derivative of the coordinate vector as a major difference with Lagrangian systems. }\n\n%\nThe Newton-Euler equation in compact form may be written as:\n\\begin{equation}\n\\label{eq:Newton-Euler-compact}\n\\boxed{ \\left \\{ \n \\begin{aligned}\n  &\\dot q=T(q)v, \\\\\n  & M \\dot v = F(t, q, v)\n \\end{aligned}\n \\right.}\n\\end{equation}\nwhere $M\\in\\RR^{6\\times6}$ is the total inertia matrix\n\\begin{equation}\n  M:= \\begin{pmatrix}\n    m I_{3\\times 3} & 0 \\\\\n    0 & I \n  \\end{pmatrix},\n\\end{equation}\nand $F(t, q, v)\\in \\RR^6$ collects all the forces and torques applied to the body\n\\begin{equation}\n  F(t,q,v):= \\begin{pmatrix}\n    f(t,x_{\\cg},  v_{\\cg}, R, \\Omega ) \\\\\n    I \\Omega \\times \\Omega + M(t,x_{\\cg}, v_{\\cg}, R, \\Omega )\n  \\end{pmatrix}.\n\\end{equation}\nWhen a collection of bodies is considered, we will use the same notation as in~(\\ref{eq:Newton-Euler-compact}) extending the definition of the variables $q,v$ and the operators $M,F$ in a straightforward way.\n\n\n\n\n\\input{LieGroupTheory.tex}\n\\section{ Lie group $SO(3)$ of finite rotations and Lie algebra $\\mathfrak{so}(3)$ of infinitesimal rotations}\nThe presentation is this section follows the notation and the developments taken from~\\cite{Iserles.ea_AN2000,Munthe-Kaas.BIT1998}. For more details on Lie groups and Lie algebra, we refer to \\cite{Varadarajan_book1984} and \\cite{Helgason_Book1978}.\n\n\nThe Lie group $SO(3)$ is the group of linear proper orthogonal transformations in $\\RR^3$ that may be represented by a set of matrices in $\\RR^{3\\times 3}$ as\n\\begin{equation}\n  \\label{eq:47}\n  SO(3) = \\{R \\in \\RR^{3\\times3}\\mid R^TR=I , det(R) = +1  \\}\n\\end{equation}\nwith the group law given by $R_1\\glaw R_2 = R_1R_2$ for $R_1,R_2\\in SO(3)$. The identity element is $e = I_{3\\times 3}$. At any point of $R\\in SO(3)$, the tangent space $T_RSO(3)$ is the set of tangent vectors at a point $R$.\n\n\\paragraph{Left representation of  the tangent space at $R$, $T_RSO(3)$ } Let $S(t)$ be a smooth curve $S(\\cdot) : \\RR  \\rightarrow SO(3)$ in $SO(3)$. An element $a$ of the tangent space at $R$ is given by \n\\begin{equation}\n  \\label{eq:174}\n  a  = \\left.\\frac{d}{dt} S(t)\\right|_{t=0}\n\\end{equation}\nsuch that $S(0)= R$.\nSince $S(t)\\in SO(3)$, we have  $\\frac{d}{dt} (S(t)) = \\dot S(t)S^T(t) +  S(t) \\dot S^T(t) =0$. At $t=0$, we get $a R^T +  R a^T =0$.\nWe conclude that it exists a skew--symmetric matrix $\\tilde \\Omega = R^T a$ such that $\\tilde \\Omega^T + \\tilde \\Omega =0$. Hence, a possible representation of  $T_RSO(3)$ is\n\\begin{equation}\n  \\label{eq:49}\n  T_RSO(3) = \\{ a = R \\tilde \\Omega \\in \\RR^{3\\times 3} \\mid \\tilde \\Omega^T + \\tilde \\Omega =0 \\}.\n\\end{equation}\nFor $R=I$, the tangent space is directly given by the set of  skew--symmetric matrices:\n\\begin{equation}\n  \\label{eq:50}\n  T_ISO(3) = \\{ \\tilde \\Omega\\in \\RR^{3\\times 3} \\mid \\tilde \\Omega^T + \\tilde \\Omega =0 \\}.\n\\end{equation}\nThe tangent space $T_ISO(3)$ with the Lie Bracket $[\\cdot,\\cdot]$ defined by the matrix commutator\n\\begin{equation}\n  \\label{eq:51}\n  [A,B] = AB-BA\n\\end{equation}\nis a Lie algebra that is denoted by\n\\begin{equation}\n  \\label{eq:53}\n  \\mathfrak{so}(3) =\\{\\Omega\\in \\RR^{3\\times 3} \\mid \\Omega + \\tilde \\Omega^T =0\\}.\n\\end{equation}\n For skew symmetric matrices, the commutator can be expressed with the cross product in $\\RR^3$\n\\begin{equation}\n  \\label{eq:52}\n  [\\tilde \\Omega, \\tilde \\Gamma] = \\tilde \\Omega \\tilde \\Gamma - \\tilde \\Gamma \\tilde \\Omega= \\widetilde{\\Omega \\times \\Gamma }\n\\end{equation}\nWe use   $T_ISO(3) \\cong  \\mathfrak{so}(3)$ whenever there is no ambiguity.\n\nThe notation $\\tilde \\Omega$ is implied by the fact that the Lie algebra is isomorphic to $\\RR^3$ thanks to the operator $\\widetilde{(\\cdot)} :\\RR^3 \\rightarrow \\mathfrak{so}(3)$ and defined by\n\\begin{equation}\n  \\label{eq:54}\n \\widetilde{(\\cdot)}: \\Omega \\mapsto \\tilde \\Omega =\n  \\begin{bmatrix}\n    0 & -\\Omega_3 & \\Omega_2 \\\\\n    \\Omega_3 & 0 & -\\Omega_1 \\\\\n    -\\Omega_2  & \\Omega_1 & 0\n  \\end{bmatrix}\n\\end{equation}\nNote that $\\tilde \\Omega x = \\Omega \\times x$.\n\n\\paragraph{ A special  (right)  action of Lie Group $\\mathcal G$ on a manifold $\\mathcal M$. } \n\nLet us come back to the representation of  $T_RSO(3)$ given in~\\eqref{eq:49}. It is clear it can expressed with a representation that relies on $\\mathfrak{so}(3)$\n\\begin{equation}\n  \\label{eq:58}\n   T_RSO(3) = \\{ a = R \\tilde \\Omega \\in \\RR^{3\\times 3} \\mid \\tilde \\Omega \\in \\mathfrak{so}(3) \\}.\n\\end{equation}\nWith \\eqref{eq:58}, we see that there is a linear map that relates $T_RSO(3)$ to  $\\mathfrak{so}(3)$. This can be formalize by noting that the left translation map for a point $R \\in SO(3)$ \n\\begin{equation}\n  \\label{eq:59}\n  \\begin{array}[lcl]{rcl}\n    L_R& :&   SO(3)  \\rightarrow  SO(3)\\\\\n       & &  S  \\mapsto L_R(S) = R \\glaw S = RS\\\\\n  \\end{array}\n\\end{equation}\nwhich is diffeomorphism on $SO(3)$ is a group action. In our case, we identify the manifold and the group. Hence, the mapping $L_R$ can be viewed as a left or a right group action. We choose a right action such that $\\Lambda^r(R,S) = L_{R}(S) =  R \\glaw S $. By differentiation, we get a mapping $L'_R: T_I\\mathfrak{so(3)} \\cong \\mathfrak{so(3)} \\rightarrow T_R SO(3)$. For a given $\\tilde\\Omega \\in \\mathfrak{so(3)}$ and a point $R$, the differential $L'_R$ by computing the tangent vector field $\\lambda^r_{*}(a)(R)$ of the group action  $\\Lambda^r(R,S)$ for a smooth curve $S(t) : \\RR \\rightarrow S0(3)$ such that $\\dot S(0) = \\tilde\\Omega$:\n\\begin{equation}\n  \\label{eq:60}\n   \\lambda^r_{*}(a)(R) \\coloneqq  \\left. \\frac{d}{dt} \\Lambda^r(R,S(t)) \\right|_{t=0} = \\left. \\frac{d}{dt} L_{R}(S(t)) \\right|_{t=0} =  \\left. \\frac{d}{dt} R \\glaw S(t) \\right|_{t=0} =  R \\glaw \\dot S(0) = R \\tilde\\Omega \\in X(\\mathcal M)\n \\end{equation}\n%\nTherefore, the vector field in \\eqref{eq:60} is a tangent vector field that defines a Lie-Type ordinary differential equation\n\\begin{equation}\n  \\label{eq:61}\n  \\dot R(t) = \\lambda^r_{*}(a)(R(t)) = R(t)  \\tilde \\Omega\n\\end{equation}\n\n\nIn~\\cite{Bruls.Cardona2010}, the linear operator $\\lambda^r_{*}(a)$  is defined as  the directional derivative with respect to $S$ an denoted $DL_R(S)$. It defines a diffeomorphism between $T_SSO(3)$ and $T_{RS}SO(3)$. In particular, for $S=I_{3\\times3}$, we get\n\\begin{equation}\n  \\label{eq:62}\n  \\begin{array}{rcl}\n    DL_R(I_{3\\times3}) : \\mathfrak{so}(3) & \\rightarrow & T_R SO(3) \\\\\n    \\tilde \\Omega &\\mapsto &DL_R(I_{3\\times3}). \\tilde \\Omega = R \\tilde \\Omega\n  \\end{array}\n\\end{equation}\nWe end up with a possible representation of $T_{R} SO(3)$ as\n\\begin{equation}\n  \\label{eq:63}\n  T_{R} SO(3) =\\{\\tilde \\Omega_R \\mid \\tilde \\Omega_R = DL_R(I_{3\\times3}). \\tilde \\Omega = R \\tilde \\Omega, \\tilde \\Omega \\in\\mathfrak{so}(3)  \\}.\n\\end{equation}\nIn other words, a tangent vector $\\tilde \\Omega \\in \\mathfrak{so}(3)$ defines a left invariant vector field on $SO(3)$ at the point $R$ given by $R \\tilde \\Omega$.\n\n\n\n\n\\begin{ndrva}\n  what happens at $S(0)=R$, with $ a =R \\tilde \\Omega =\\dot S(0)$ and then $\\dot y(t) = F(y(t)) = R \\tilde \\Omega y(t) =  R\\Omega \\times y(t)= \\dot S(0) y(t) $. What else ? \n\\end{ndrva}\n\n\n\\paragraph{Exponential map $\\expm \\mathfrak{so(3)} \\rightarrow SO(3)$}\nThe relations \\eqref{eq:24} and \\eqref{eq:25} shows that is possible to define tangent vector field from a group action. We can directly apply Theorem~\\ref{Theorem:solutionofLieODE} and we get that the solution of\n\\begin{equation}\n  \\label{eq:130}\n  \\begin{cases}\n  \\dot R(t) = \\lambda^r_{*}(a)(R(t)) = R(t)  \\tilde \\Omega \\\\\n  R(0) = R_0\n\\end{cases}\n\\end{equation}\n is\n\\begin{equation}\n  \\label{eq:138}\n  R(t) = R_0 \\expm(t \\tilde \\Omega)\n\\end{equation}\n\nLet us do the  computation in this case. Let us assume that the solution can be sought as $R(t) = \\Lambda^r(y_o,S(t))$. The initial condition imposes that  $R(0) = R_0 = \\Lambda(R_0,I) = \\Lambda(R_0,S(0))$ that implies $S(0)=I$. Since $\\Lambda(R_0,S(t))$ is the flow that is produces by $S(t)$ and let us try to find the relation satisfied by $S(\\cdot)$. For a smooth curve $T(s) \\in SO(3)$ such that $\\dot T(0)= \\tilde \\Omega$, we have\n\\begin{equation}\n  \\label{eq:64}\n  \\begin{array}[lcl]{lcl}\n    \\dot R(t) = \\lambda^r_*(\\tilde \\Omega)(R(t)) &=& \\left. \\frac{d}{ds}\\Lambda^r(R(t),T(s)) \\right|_{s=0} \\\\\n                                &=& \\left. \\frac{d}{ds} \\Lambda^r(\\Lambda(R_0, S(t)),T(s)) \\right|_{s=0} \\\\\n                                &=& \\left. \\frac{d}{ds} (\\Lambda^r(R_0, S(t)\\glaw T(s)) \\right|_{s=0} \\\\\n                                &=& D_2 \\Lambda^r(R_0, \\glaw S(t) \\glaw \\dot T(0) ) \\\\\n                                &=& D_2 \\Lambda^r(R_0,  S(t)\\glaw \\tilde \\Omega )\n  \\end{array}\n\\end{equation}\nOn the other side, the relation $y(t) = \\Lambda^r(y_0,S(t))$ gives $\\dot y(t) = D_2 \\Lambda^r(y_0,S'(t))$ and we conclude that\n\\begin{equation}\n  \\label{eq:65}\n  \\begin{cases}\n    \\dot S(t) =  S(t)\\glaw\\tilde\\Omega    = S(t) \\tilde \\Omega\\\\\n    S(0) = I.\n  \\end{cases}\n\\end{equation}\nThe ordinary differential equation~\\eqref{eq:65} is a matrix ODE that admits the following solution\n\\begin{equation}\n  \\label{eq:66}\n  S(t) = \\expm(t\\tilde\\Omega)\n\\end{equation}\nwhere $\\exp : \\RR^{3\\times 3} \\rightarrow \\RR^{3\\times 3}$ is the matrix exponential defined by\n\\begin{equation}\n  \\label{eq:67}\n  \\begin{array}[lcl]{lcl}\n    \\expm(A) &=& \\sum_{k=0}^{\\infty} \\frac {1}{k!} (A)^k.\n  \\end{array}\n\\end{equation}\nWe conclude that $R(t) =\\Lambda(R_0,S(t)) = R_0\\expm(t\\tilde\\Omega)$ is the solution of \\eqref{eq:35}.\n\nWe can use the closed form solution for the matrix exponential of $t \\tilde\\Omega  \\in \\mathfrak{so}(3)$ as\n\\begin{equation}\n  \\label{eq:68}\n  \\expm(t\\tilde\\Omega) = I_{3\\times 3} + \\frac{\\sin{t\\theta}} {\\theta}  \\tilde\\Omega  +  \\frac{(\\cos{t \\theta}-1)}{\\theta^2} \\tilde\\Omega^2   \n\\end{equation}\nwith $\\theta = \\|\\Omega\\|$.\nFor given  $\\tilde \\Omega \\in\\mathfrak{so}(3)$, we have\n\\begin{equation}\n  \\label{eq:69}\n  \\det(\\tilde \\Omega) = \\det(\\tilde \\Omega^T) = \\det (-\\tilde \\Omega^T) = (-1)^3 \\det(\\tilde \\Omega ) = - \\det (\\tilde \\Omega )\n\\end{equation}\nthat implies that $\\det(\\tilde \\Omega ) =0 $. From \\eqref{eq:68}, we conclude that\n\\begin{equation}\n  \\label{eq:70}\n  \\det( \\expm(t\\tilde \\Omega)) = 1.\n\\end{equation}\nFurthermore, we have $\\expm(t\\tilde \\Omega)\\expm( -t\\tilde \\Omega) = \\expm(t(\\tilde \\Omega-\\tilde \\Omega)) = I$. We can verify  that  $\\expm(t\\tilde \\Omega) \\in SO(3)$.\n\n\\paragraph{Adjoint representation}\nIn the case of $SO(3)$, the definition of the operator $\\Ad$ gives\n\\begin{equation}\n  \\label{eq:121}\n  \\Ad_R(\\tilde\\Omega)  = R \\tilde\\Omega R^T\n\\end{equation}\n and then mapping $\\ad_{\\tilde\\Omega}(\\tilde \\Gamma)$ is defined by\n\\begin{equation}\n  \\label{eq:56}\n  \\ad_{\\tilde\\Omega}(\\tilde\\Gamma) = \\tilde \\Omega \\tilde\\Gamma - \\tilde \\Gamma \\tilde\\Omega  =  [\\tilde \\Omega,\\tilde \\Gamma] = \\widetilde{\\Omega \\times \\Gamma}.\n\\end{equation}\nUsing the isomorphism between $\\mathfrak so(3)$ and $\\RR^3$, it possible the define the mapping $\\ad_{\\Omega}(\\Gamma) : \\RR^3\\times\\RR^3 \\rightarrow \\RR^3$ with the realization of the Lie algebra in $\\RR^3$ as\n\\begin{equation}\n  \\label{eq:55}\n  \\ad_\\Omega(\\Gamma) = \\tilde\\Omega \\Gamma = \\Omega\\times\\Gamma\n\\end{equation}\n\n\\paragraph{Differential of the exponential map $\\dexpm$}\nThe differential of the exponential mapping, denoted by $\\dexpm$ is defined as the 'right trivialized' tangent of the exponential map \n\\begin{equation}\n  \\label{eq:71}\n  \\frac{d}{dt} (\\exp(\\tilde \\Omega(t))) = \\dexp_{\\tilde\\Omega(t)}(\\frac{d \\tilde{\\Omega}(t)}{dt}) \\exp(\\tilde\\Omega(t))\n\\end{equation}\n\n\n\n% \\begin{ndrva}\n%   explain briefly the notion of left-invariant vector field \n% \\end{ndrva}\n%\\href{https://en.wikipedia.org/wiki/Lie_group}{https://en.wikipedia.org/wiki/Lie_group}\n%Finally, the straight line $\\alpha \\tilde \\Omega$ for $\\Omega$ \n\nThe differential of the exponential mapping, denoted by $\\dexpm$ is defined as the 'left trivialized' tangent of the exponential map\n\\begin{equation}\n  \\label{eq:72}\n   \\frac{d}{dt} (\\exp(\\tilde \\Omega(t))) = \\dexp_{\\tilde\\Omega(t)}(\\frac{d \\tilde{\\Omega}(t)}{dt}) \\exp(\\tilde\\Omega(t))\n\\end{equation}\n\nUsing the formula~\\eqref{eq:43} and the fact that $\\ad_\\Omega(\\Gamma) = \\Tilde\\Omega \\Gamma$, we can write the differential as\n\\begin{equation}\n  \\label{eq:122}\n  \\begin{array}{lcl}\n    \\dexp_{\\tilde\\Omega}(\\tilde\\Gamma) &=& \\sum_{k=0}^\\infty \\frac{1}{(k+1)!} \\ad_{\\tilde \\Omega}^k (\\tilde\\Gamma) \\\\\n                                       &=& \\sum_{k=0}^\\infty \\frac{1}{(k+1)!} \\tilde\\Omega^k \\tilde \\Gamma \\\\\n  \\end{array}\n\\end{equation}\nUsing again the fact that $\\tilde\\Omega^3 = -\\theta^2 \\tilde\\Omega$, we get\n\\begin{equation}\n  \\label{eq:123}\n   \\begin{array}{lcl}\n     \\dexp_{\\tilde\\Omega} &=& \\sum_{k=0}^\\infty  \\frac{1}{(k+1)!} \\tilde\\Omega^k \\\\\n                          &=& I  + \\sum_{k=0}^\\infty  \\frac{(-1)^k}{((2(k+1))!} \\theta^{2k} \\tilde\\Omega + \\sum_{k=0}^\\infty  \\frac{(-1)^k}{((2(k+1)+1)!} \\theta^{2k} \\tilde\\Omega^2\\\\\n  \\end{array}\n\\end{equation}\nHence, we get\n\\begin{equation}\n  \\label{eq:124}\n   \\begin{array}{lcl}\n     \\dexp_{\\tilde\\Omega}  &=& I  + \\frac{(1-\\cos(\\theta))}{\\theta^2}\\tilde\\Omega + \\frac{(\\theta-\\sin(\\theta))}{\\theta^3}\\tilde\\Omega^2 \n  \\end{array}\n\\end{equation}\nSince $\\dexp_{\\tilde\\Omega}$ is a linear mapping from $\\mathfrak{so(3)}$ to $\\mathfrak{so(3)}$, we will use the following notation\n\\begin{equation}\n  \\label{eq:172}\n  \\dexp_{\\tilde\\Omega}\\tilde\\Gamma  \\coloneqq T(\\Omega)\\tilde\\Gamma \n\\end{equation}\nwith\n\\begin{equation}\n  \\label{eq:173}\n   T(\\Omega) \\coloneqq I  + \\frac{(1-\\cos(\\theta))}{\\theta^2}\\tilde\\Omega + \\frac{(\\theta-\\sin(\\theta))}{\\theta^3}\\tilde\\Omega^2  \\in \\RR^{3\\times 3}\n\\end{equation}\n\n\n\n\n\\subsection{Newton method and differential of a map $f : \\mathcal G \\rightarrow \\mathfrak g$}\nFinally, let us define the differential of the map $f : SO(3) \\rightarrow \\mathfrak {so}(3)$ as\n\\begin{equation}\n  \\label{eq:183}\n  \\begin{array}[rcl]{rcl}\n    f'_R : T_RSO(3) &\\rightarrow&T_{f(R)}\\mathfrak {so}(3) \\cong  \\mathfrak {so}(3)\\\\\n           a &\\mapsto& \\left.\\frac{d}{dt} f(R\\glaw \\expm(t L'_{R^{-1}}(a))) \\right|_{t=0}\n  \\end{array}\n\\end{equation}\nThe image of $b$ by $f'_z$   is obtained by first identifying $a$ with an element of $\\tilde\\Omega \\in \\mathfrak {so}(3)$ thanks to the left representation of $T_{f(R)}\\mathfrak {so}(3)$ view the left translation map $\\tilde\\Omega= t L'_R(b)$. The exponential mapping transforms $\\tilde\\Omega$ an element $S$ of the Lie Group $SO(3)$. Then $f'_z$ is obtained by\n\\begin{equation}\n  \\label{eq:184}\n  f'_R(b) = \\lim_{t\\rightarrow 0} \\frac{f(R\\glaw S) - f(R)}{t}\n\\end{equation}\nAs we have done for the exponential mapping, it is possible to get a left trivialization of  \n\\begin{equation}\n  \\label{eq:185}\n  \\dd f_R = (f\\circ L_R)' = f'_R \\circ L'_R\n\\end{equation}\nthus\n\\begin{equation}\n  \\label{eq:186}\n  \\dd f_R (\\tilde\\Omega) =  f'_R \\circ L'_R(\\tilde\\Omega) = f'_R(L'_R(\\tilde\\Omega)) =  \\left.\\frac{d}{dt} f(R\\glaw \\expm(t \\tilde\\Omega )) \\right|_{t=0}\n\\end{equation}\n\n\\begin{ndrva}\n  The computation of this differential is non linear with respect to $\\tilde\\Omega$.\n\n\n  not clear if we write $\\dd f_R (\\tilde\\Omega)$. Better understand the link with $\\dexp_{\\tilde \\Omega}{\\tilde\\Gamma}$\n\\end{ndrva}\nSometimes, it can be formally written as\n\\begin{equation}\n  \\label{eq:180}\n  \\dd f_R (\\tilde\\Omega) = C(\\tilde\\Omega)\\tilde\\Omega \n\\end{equation}\nNevertheless, an explicit expression of $C(\\cdot)$ is not necessarily trivial. \n\nLet us consider a first simple example of a mapping $f(R) = \\widetilde{R  x}$ for a given $x\\in\\RR^3$. The computation yields\n\\begin{equation}\n  \\label{eq:181}\n  \\begin{array}{rcl}\n    \\dd f_R (\\tilde\\Omega) &=& \\widetilde{ \\left.\\frac{d}{dt} R \\exp(t \\tilde\\Omega) x  \\right|_{t=0}} \\\\\n                           &=& \\widetilde{R \\left.\\frac{d}{dt}\\exp(t \\tilde\\Omega)\\right|_{t=0}  x} \\\\\n                           &=& \\widetilde{R \\left. \\dexp_{\\tilde\\Omega}(\\tilde\\Omega)\\exp(t \\tilde\\Omega) \\right|_{t=0}  x} \\\\\n                           &=& \\widetilde{R \\dexp_{\\tilde\\Omega}(\\tilde\\Omega) x} \\\\\n                           &=& \\widetilde{R T(\\Omega) \\tilde\\Omega  x} \\\\\n                           &=& \\widetilde{-R T(\\Omega) \\tilde x \\Omega } \n  \\end{array}\n\\end{equation}\nIn that case, it is difficult to find a expression as in \\eqref{eq:180}, but considering the function $g(R)$ such that $f(R) = \\widetilde g(x)$ we get\n\\begin{equation}\n  \\label{eq:181}\n  \\begin{array}{rcl}\n    \\dd g_R (\\tilde\\Omega)  =- R T(\\Omega) \\tilde x \\Omega  = C(\\Omega) \\Omega\n  \\end{array}\n\\end{equation}\nwith\n\\begin{equation}\n  \\label{eq:182}\n   C(\\Omega) = -R T(\\Omega) \\tilde x\n\\end{equation}\n\n\n\\section{Lie group of unit quaternions $\\HH_1$ and pure imaginary quaternions $\\HH_p$.}\n\n\nIn Siconos we choose to parametrize the rotation with a unit quaternion $p \\in \\HH$ such that $R = \\Phi(p)$. This parameterization has no singularity and has only one redundant variable that is determined by imposing $\\|p\\|=1$.\n\n\n\\paragraph{Quaternion definition.} There is many ways to define quaternions. The most convenient one is to define a quaternion as \na $2\\times 2$ complex matrix, that is an element of $\\CC^{2\\times 2}$. For this end, we write for $z \\in \\CC$, $z=a+ib$ with $a,b \\in \\RR^2$ and $i^2=-1$ and its conjugate $\\bar z= a-ib$. Let ${e, \\bf, i, j, k}$ the following matrices in $\\CC^{2\\times 2}$\n\\begin{equation}\n  \\label{eq:127}\n  e =\n  \\begin{bmatrix}\n    1 & 0 \\\\\n    0 & 1  \\\\\n  \\end{bmatrix},\n  \\quad   \\bf{i} =\n  \\begin{bmatrix}\n    i & 0 \\\\\n    0 & -i  \\\\\n  \\end{bmatrix}\n  \\quad   \\bf{j} =\n  \\begin{bmatrix}\n    0 & 1 \\\\\n    -1 & 0  \\\\\n  \\end{bmatrix}\n   \\quad   \\bf{k} =\n  \\begin{bmatrix}\n    0 & i \\\\\n    i & 0  \\\\\n  \\end{bmatrix}\n\\end{equation}\n\n\\begin{definition}\n  Let $\\HH$ be the set of all matrices of the form\n  \\begin{equation}\n    \\label{eq:128}\n    p_0 e + p_1 {\\bf i} + p_2 {\\bf j} + p_3 {\\bf k}\n  \\end{equation}\n  where $(p_0,p_1,p_2,p_3) \\in \\RR^4$. Every Matrix in $\\HH$ is of the form\n  \\begin{equation}\n    \\label{eq:129}\n    \\begin{bmatrix}\n      x &y  \\\\\n      - \\bar y  & \\bar x\n    \\end{bmatrix}\n  \\end{equation}\nwhere $x = p_0 + i p_1$ and $y = p_2 + i p_3$. The matrices in $\\HH$ are called quaternions. \n\\end{definition}\n\n\n\\begin{definition}\n  The null quaternion generated by $[0,0,0,0] \\in \\RR^4$ is denoted by $0$ . Quaternions of the form $p_1 \\bf {i} + p_2 \\bf{j} + p_3 \\bf{k}$ are called pure quaternions. The set of pure quaternions is denoted by $\\HH_p$.\n\\end{definition}\n\nWith the definition of $\\HH$ as a set of complex matrices, It can be show that $\\HH$ is a real vector space of dimension $4$ with basis ${e, \\bf, i, j, k}$. Furthermore, with the matrix product, $\\HH$ is a real algebra.\n\n\\paragraph{Representation of quaternions} Thanks to the equations~\\eqref{eq:128}, ~\\eqref{eq:128} and ~\\eqref{eq:129}, we see that there are several manner to represent a quaternion $p\\in \\HH$. It can be represented as a complex matrix as in~\\eqref{eq:129}. It can also be represented as a vector in $\\RR^4$ , $p= [p_0,p_1,p_2,p_3]$ with the isomorphism~\\eqref{eq:128}. In other words,  $\\HH$ is isomorphic to $\\RR^4$.  The first element $p_0$ can also be viewed as  a scalar and three last ones as a vector in $\\RR^3$ denoted by $\\vv{p} = [p_1,p_2,p_3]$, and in that case, $\\HH$ is viewed as $\\RR\\times \\RR^3$. The quaternion can be written as $p=(p_0,\\vv{p})$.\n\n\\paragraph{Quaternion product} The quaternion product denoted by $p \\glaw q $ for $p,q\\in \\HH_1$ is naturally defined as the product of complex matrices. With its representation in $\\RR\\times \\RR^3$, the quaternion product is defined by\n\\begin{equation}\n  \\label{eq:73}\n  p \\glaw q =\n  \\begin{bmatrix}\n    p_oq_o - \\vv{p}\\vv{q} \\\\\n    p_0\\vv{q}+q_o\\vv{p} + \\vv{p}\\times\\vv{q}\n  \\end{bmatrix}.\n\\end{equation}\nSince the product is a matrix product, it is not communicative, but it is associative.  The identity element for the quaternion product is \n\\begin{equation}\ne=  \\begin{bmatrix}\n    1 & 0 \\\\\n    0 & 1  \\\\\n  \\end{bmatrix} =(1,\\vv{0})\\label{eq:57}.\n\\end{equation}Let us note that \n\\begin{equation}\n  \\label{eq:74}\n  (0,\\vv{p})\\glaw (0,\\vv(q)) = - (0,\\vv{q})\\glaw (0,\\vv{p}).\n\\end{equation}\nThe quaternion multiplication can also be represented as a matrix operation in $\\RR^{4\\times4}$. Indeed, we have\n\\begin{equation}\n  \\label{eq:75}\n  p \\glaw q  =\n  \\begin{bmatrix}\n    q_0 p_0 -q_1p_1-q_2p_2-q_3p_3\\\\\n    q_0 p_1 +q_1p_0-q_2p_3+q_3p_2\\\\\n    q_0 p_2 +q_1p_3+q_2p_0-q_3p_1\\\\\n    q_0 p_3 -q_1p_2+q_2p_1+q_3p_0\\\\\n  \\end{bmatrix}\n\\end{equation}\nthat can be represented as\n\\begin{equation}\n  \\label{eq:76}\n  p \\glaw q  =\n  \\begin{bmatrix}\n    p_0 & -p_1 & -p_2 & -p_3 \\\\\n    p_1 & p_0 & -p_3 & p_2 \\\\\n    p_2 & p_3 & p_0 & -p_1 \\\\\n    p_3 & -p_2 & p_1 & p_0 \\\\\n  \\end{bmatrix}\n  \\begin{bmatrix}\n    q_0\\\\\n    q_1\\\\\n    q_2\\\\\n    q_3\n  \\end{bmatrix} := [p_\\glaw]q\n\\end{equation}\nor\n\\begin{equation}\n  \\label{eq:77}\n  p \\glaw q  = \n  \\begin{bmatrix}\n    q_0 & -q_1 & -q_2 & -q_3 \\\\\n    q_1 & q_0 & q_3 & -q_2 \\\\\n    q_2 & -q_3 & q_0 & q_1 \\\\\n    q_3 & q_2 & -q_1 & q_0 \\\\\n  \\end{bmatrix}\n  \\begin{bmatrix}\n    p_0\\\\\n    p_1\\\\\n    p_2\\\\\n    p_3\n  \\end{bmatrix} := [{}_\\glaw q] p\n\\end{equation}\n\n\\paragraph{Adjoint quaternion, inverse and norm}\nThe adjoint quaternion of $p$ is denoted by\n\\begin{equation}\n  p^\\star = \\overline{  \\begin{bmatrix}\n      x &y  \\\\\n      - \\bar y  & \\bar x\n    \\end{bmatrix}}^T\n  =\\begin{bmatrix}\n    \\bar x & - y  \\\\\n    \\bar y  &  x\n  \\end{bmatrix} =\n  \\begin{bmatrix}\n    p_0, -p_1, -p_2, -p_3\n  \\end{bmatrix} = (p_0, - \\vv{p})\n\\end{equation}\nWe note that\n\\begin{equation}\n  \\label{eq:131}\n  p \\glaw p^\\star = \n  \\begin{bmatrix}\n      x &y  \\\\\n      - \\bar y  & \\bar x\n    \\end{bmatrix}\n    \\begin{bmatrix}\n    \\bar x & - y  \\\\\n    \\bar y  &  x\n  \\end{bmatrix} = \\det(\\begin{bmatrix}\n      x &y  \\\\\n      - \\bar y  & \\bar x\n    \\end{bmatrix}) e = (x\\bar x + y \\bar y) e  = (p^2_0 + p^2_1+ p_2^2 + p_3^2)e\n\\end{equation}\n\n\nThe norm of a quaternion is given by $|p|^2=p^\\top p = p_o^2+p_1^2+p_2^2+p_3^2$. In particular, we have $p \\glaw p^\\star = p^\\star \\glaw p = |p|^2 e$. This allows to define the reciprocal of a non zero quaternion by\n\\begin{equation}\n  \\label{eq:78}\n  p ^{-1} = \\frac 1 {|p|^2} p^\\star\n\\end{equation}\nA quaternion $p$ is said to be unit if $|p| =1$. \n\n\\paragraph{Unit quaternion and rotation}\nFor two vectors $x\\in \\RR^3$ and $x'\\in \\RR^3$, we define the quaternion $p_x = (0,x)\\in \\HH_p$ and  $p_{x'} = (0,x')\\in \\HH_p$.\nFor a given unit quaternion $p$, the transformation\n\\begin{equation}\n  \\label{eq:79}\n  p_{x'} = p \\glaw p_x \\glaw  p^\\star \n\\end{equation}\ndefines a rotation $R$ such that $x'  = R x$ given by\n\\begin{equation}\n  \\label{eq:80}\n  x' = (p_0^2- p^\\top \\vv{p}) x +2 p_0(\\vv{p}\\times x) +  2 (\\vv{p}^\\top x) p = R x\n\\end{equation}\nThe rotation matrix may be computed as \n\\begin{equation}\n  \\label{eq:81}\n  R = \\Phi(p) =\n  \\begin{bmatrix}\n    1-2 p_2^2- 2 p_3^2 & 2(p_1p_2-p_3p_0) & 2(p_1p_3+p_2p_0)\\\\\n    2(p_1p_2+p_3p_0) & 1-2 p_1^2- 2 p_3^2 & 2(p_2p_3-p_1p_0)\\\\\n    2(p_1p_3-p_2p_0) & 2(p_2p_3+p_1p_0)  & 1-2 p_1^2- 2 p_2^2\\\\\n  \\end{bmatrix}\n\\end{equation} \n\n\n\\paragraph{Computation of the time derivative of a unit  quaternion associated with a rotation.}\nThe derivation with respect to time can obtained as follows. The rotation transformation for a unit quaternion is given by\n\\begin{equation}\n  \\label{eq:82}\n  p_{x'}(t) = p(t) \\glaw p_x \\glaw p^\\star(t) =  p(t) \\glaw p_x \\glaw p^{-1}(t)\n\\end{equation}\nand can be derived as\n\\begin{equation}\n  \\label{eq:83}\n  \\begin{array}{lcl}\n    \\dot p_{x'}(t) &=& \\dot p(t) \\glaw p_x \\glaw p^{-1}(t) + p(t) \\glaw p_x \\glaw \\dot p^{-1}(t) \\\\\n                  &=& \\dot p(t) \\glaw p^{-1}(t)  \\glaw   p_{x'}(t)  +      p_{x'}(t) \\glaw p(t)  \\glaw \\dot p^{-1}(t)    \n  \\end{array}\n\\end{equation}\nFrom $p(t) \\glaw p^{-1}(t) =e$, we get\n\\begin{equation}\n  \\label{eq:84}\n  \\dot p(t) \\glaw p^{-1}(t) + p \\glaw \\dot p^{-1}(t) = 0\n\\end{equation}\nso (\\ref{eq:82}) can be rewritten\n\\begin{equation}\n  \\label{eq:85}\n  \\begin{array}{lcl}\n    \\dot p_{x'}(t) = \\dot p(t) \\glaw p^{-1}(t)   \\glaw   p_{x'}(t)  -    p_{x'}(t) \\glaw  \\dot p(t) \\glaw p^{-1}(t)\n  \\end{array}\n\\end{equation}\nThe scalar part of $\\dot p(t) \\glaw p^{-1}(t)$ is $(\\dot p(t) \\glaw p^{-1}(t))_0 = p_o \\dot p_0 + \\vv{p}^T\\vv{\\dot p}$. Since $p$ is a unit quaternion, we have\n\\begin{equation}\n  \\label{eq:86}\n  |p|=1 \\implies \\frac{d}{dt} (p^\\top p) = 0 =  \\dot p^\\top p + p^\\top \\dot p =   2( p_o \\dot p_0 + \\vv{p}^T\\vv{\\dot p}).\n\\end{equation}\nTherefore, the scalar part $(\\dot p(t) \\glaw p^{-1}(t))_0 =0$.\nThe quaternion product $\\dot p(t) \\glaw p^{-1}(t)$ and  $p_{x'}(t)$ is a product of quaternions with zero scalar part (see~\\eqref{eq:74}), so we have \n\\begin{equation}\n  \\label{eq:87}\n  \\begin{array}{lcl}\n    \\dot p_{x'}(t) = 2 \\dot p(t) \\glaw p^{-1}(t)   \\glaw p_{x'}(t).\n  \\end{array}\n\\end{equation}\nIn terms of vector of $\\RR^3$, this corresponds to\n\\begin{equation}\n  \\label{eq:88}\n  \\dot x'(t) = 2 \\vv{ \\dot p(t) \\glaw p^{-1}(t) } \\times x'(t).\n\\end{equation}\nSince $x'(t) = R(t) x$, we have $\\dot x' = \\dot R(t) x = \\tilde \\omega(t) R(t) x  = \\tilde \\omega(t) x'(t) $. Comparing \\eqref{eq:87} and \\eqref{eq:88}, we get\n\\begin{equation}\n  \\label{eq:89}\n  \\tilde \\omega(t)  = 2 \\vv{ \\dot p(t) \\glaw p^{-1}(t) } \n\\end{equation}\nor equivalently\n\\begin{equation}\n  \\dot p(t) \\glaw p^{-1}(t) = (0, \\frac{\\omega(t)}{2} )\n  \\label{eq:90}\n\\end{equation}\nFinally, we can conclude that\n\\begin{equation}\n  \\label{eq:91}\n  \\dot p(t) = (0, \\frac{\\omega(t)}2 ) \\glaw p(t).\n\\end{equation}\nSince $\\omega(t)=R(t)\\Omega(t)$, we have\n\\begin{equation}\n  \\label{eq:92}\n  (0, \\omega(t) ) = (0, R(t) \\Omega(t) ) = p(t) \\glaw (0, \\Omega(t) ) \\glaw \\bar p(t) = p(t) \\glaw (0, \\Omega(t) ) \\glaw  p^{-1}(t)\n\\end{equation}\nand then\n\\begin{equation}\n  \\label{eq:93}\n  \\dot p(t) =\\frac 1 2 p(t) \\glaw(0, \\Omega(t) ) .\n\\end{equation}\n\nThe time derivation is compactly written\n\\begin{equation}\n  \\label{eq:94}\n  \\dot p = \\frac  1 2 p  \\glaw(0, \\frac\\Omega 2 ) =  [p_\\glaw] p_{\\frac \\Omega 2} = \\Psi(p)\\frac \\Omega 2,\n\\end{equation}\nand using the matrix representation of product of  quaternion\nwe get\n\\begin{equation}\n  \\label{eq:95}\n  \\Psi(p) =  \\begin{bmatrix}\n    -p_1 & -p_2 & -p_3 \\\\\n    p_0 & -p_3 & p_2 \\\\\n    p_3 & p_0 & -p_1 \\\\\n    -p_2 & p_1 & p_0 \\\\\n  \\end{bmatrix}\n\\end{equation}\nThe relation \\eqref{eq:93} can be also inverted by writing\n\\begin{equation}\n  \\label{eq:96}\n   (0, \\Omega(t) ) = 2 p^{-1}(t) \\glaw \\dot p(t)\n\\end{equation}\nUsing again  matrix representation of product of  quaternion, we get \n\\begin{equation}\n  \\label{eq:97}\n  \\Omega(t)  = 2 \\vv{p^{-1}(t) \\glaw \\dot p(t)}  = 2  \\begin{bmatrix}\n    -p_1 & p_0 & p_3 & -p_2 \\\\\n    -p_2 & -p_3 & p_0 & p_1 \\\\\n    -p_3 & p_2 & -p_1  & p_0\\\\\n  \\end{bmatrix}\\dot p(t) = 2 \\Psi(p)^\\top \\dot p(t)\n\\end{equation}\nNote that we have $\\Psi^\\top(p)\\Psi(p)= I_{4\\times 4 }$ and  $\\Psi(p)\\Psi^\\top(p)= I_{3\\times 3 }$\n\n\\paragraph{Lie group structure of unit quaternions.} In terms of complex matrices, an unit quaternion $p$ satisfies\n\\begin{equation}\n  \\label{eq:125}\n  \\det\\left(    \\begin{bmatrix}\n      x &y  \\\\\n      - \\bar y  & \\bar x\n    \\end{bmatrix} \\right) =1\n\\end{equation}\nThe set of all unit quaternions that we denote $\\HH_1$ is the set of unitary matrices of determinant equal to $1$. From~\\eqref{eq:131}, we get that\n\\begin{equation}\n  \\label{eq:126}\n  p \\glaw p^\\star = e  \n\\end{equation}\nIt implies that the set $\\HH_1$ is the set of special unitary complex matrices. The set is a Lie group usually denoted as $SU(2)$. Since we used multiple representation of a quaternion, we continue to use $\\HH_1 \\cong SU(2)$ as a notation but with the Lie group structure implied by $SU(2)$.\n\nLet us compute the tangent vector at a point $p \\in \\HH_1$. Let $q(t)$ be  a smooth curve $q(\\cdot) : t\\in \\RR \\mapsto q(t)\\in H_1$ in $H_1$ such that $q(O)= p$.\nSince $q(t)\\in H_1$, we have $|q(t)|=1$ and then $\\frac{d}{dt} |q(t)| = 2(q_0(0) \\dot q_0(0) + \\vec{q}^T(0) \\vec{\\dot q}(0) ) =0$. At $t=0$, we get\n\\begin{equation}\n  \\label{eq:48}\n  2(p_0 a_0 + \\vec{p}^T \\vec{a})= 0.\n\\end{equation}\nThis relation imposes that the quaternions $2 p^\\star \\glaw a \\in H_1$ and $2 a \\glaw p^\\star \\in H_1$, that is, have to be pure quaternions. Therefore, it exists $\\omega \\in \\RR^3$  and $\\Omega \\in \\RR^3$ such that\n\\begin{equation}\n  \\label{eq:132}\n  (0, \\Omega) = 2 p ^\\star \\glaw a \n\\end{equation}\nand\n\\begin{equation}\n  \\label{eq:132}\n  (0, \\omega) = 2 a\\glaw p^\\star\n\\end{equation}\nIn other terms, the tangent vector spaces at $p \\in \\HH_1$ can be represented as a left representation\n\\begin{equation}\n  \\label{eq:133}\n  T_p\\HH_1 = \\{ a \\mid a = p \\glaw (0, \\frac \\Omega 2 ), \\Omega \\in \\RR^3\\}\n\\end{equation}\nor a right representation\n\\begin{equation}\n  \\label{eq:1330}\n  T_p{\\HH_1} = \\{ a \\mid a =  (0, \\frac \\omega 2 ) \\glaw p, \\omega \\in \\RR^3\\}\n\\end{equation}\n\nAt $p=e$, we get the Lie algebra defined by\n\\begin{equation}\n  \\label{eq:134}\n  \\mathfrak h_1 =  T_e{\\HH_1} =  \\{ a = (0, \\frac \\Omega 2 ), \\Omega \\in \\RR^3 \\}\n\\end{equation}\nequipped with the Lie bracket given by the commutator\n\\begin{equation}\n  \\label{eq:135}\n  [p,q] = p \\glaw q- q\\glaw p.\n\\end{equation}\nWe can easily verify that for $a = (0, \\frac \\Omega 2 ), \\, b = (0, \\frac \\Gamma 2 ) \\in \\mathfrak h_1 $, we have\n\\begin{equation}\n  \\label{eq:136}\n  [a,b] = (0, \\frac \\Omega 2 ) \\glaw (0, \\frac \\Gamma 2 ) - (0, \\frac \\Gamma 2 ) \\glaw  (0, \\frac \\Omega 2 )  = (0, \\frac{\\Omega\\times \\Gamma}{2}) \\in \\mathfrak h_1\n\\end{equation}\nAs for $\\mathfrak so(3)$,  the Lie algebra $\\mathfrak h_1$ is isomorphic to $\\RR^3$ thanks to the operator $\\widehat{(\\cdot)} :\\RR^3 \\rightarrow \\mathfrak h_1$ and defined by\n\\begin{equation}\n  \\label{eq:54}\n \\widehat{(\\cdot)}: \\Omega \\mapsto \\widehat \\Omega = (0, \\frac \\Omega 2 ) \n\\end{equation}\nWith this operator, the Lie Bracket can be written\n\\begin{equation}\n  \\label{eq:137}\n  [\\widehat{\\Omega},\\widehat{\\Gamma}] = \\widehat{\\Omega \\times \\Gamma} \n\\end{equation}\n\n\n\\paragraph{ A special  (right)  action of Lie Group $\\mathcal G$ on a manifold $\\mathcal M$. } \nLet us come back to the representation of  $T_p\\HH_1$ given in~\\eqref{eq:133}. It is clear it can expressed with a representation that relies on $\\mathfrak h_1$\n\\begin{equation}\n  \\label{eq:158}\n   T_RSO(3) = \\{ a = p \\glaw  \\widehat \\Omega \\mid \\widehat \\Omega \\in \\mathfrak h_1 \\}.\n\\end{equation}\nWith \\eqref{eq:58}, we see that there is a linear map that relates $T_p\\HH_1$ to  $\\mathfrak h_1$. This linear map defines a vector field. \nA special group action is defined by the left translation map for a point $p \\in \\HH_1$ \n\\begin{equation}\n  \\label{eq:159}\n  \\begin{array}[lcl]{rcl}\n    L_p& :&   \\HH_1 \\rightarrow  \\HH_1\\\\\n       & &  q  \\mapsto L_p(q) = p \\glaw q\\\\\n  \\end{array}\n\\end{equation}\nwhich is diffeomorphism on $\\HH_1$. In that case, we identify the manifold and the group. So, $L_p$ can be viewed as a left or a right group action. We choose a right action. For our application where $\\mathcal G = \\mathcal M = \\HH_1$ and $\\Lambda^r(p,q) = L_{p}(q) =  p \\glaw q $, we get\n\\begin{equation}\n  \\label{eq:160}\n   \\lambda^r_{*}(a)(p) = \\left. \\frac{d}{dt} L_{p}(q(t)) \\right|_{t=0}  = \\left. \\frac{d}{dt} p \\glaw q(t) \\right|_{t=0} =  p \\glaw \\dot q(0) = p  \\glaw \\dot q(0)  \\in X(\\mathcal M)\n \\end{equation}\n for a smooth curve $q(t)$ in $\\HH_1$.\nSince $q(\\cdot)$ is a smooth curve in $\\HH_1$, $\\dot q(0)$ is a tangent vector at the point $q(0)=I$, that is an element $a = \\widehat  \\Omega  \\in \\mathfrak h_1 $ defined by the relation~\\eqref{eq:33}. Therefore, the vector field in \\eqref{eq:160} is a tangent vector field and we get\n\\begin{equation}\n  \\label{eq:161}\n  \\dot p(t) = \\lambda^r_{*}(a)(p(t)) = p(t)  \\glaw \\widehat \\Omega\n\\end{equation}\n\n\\paragraph{Exponential map $\\expq : \\mathfrak h_1 \\rightarrow \\HH_1$}\nWe can directly apply Theorem~\\ref{Theorem:solutionofLieODE} and we get that the solution of\n\\begin{equation}\n  \\label{eq:130}\n  \\begin{cases}\n  \\dot p(t) = \\lambda^r_{*}(a)(p(t)) = p(t) \\glaw \\widehat \\Omega \\\\\n  p(0) = Rp_0\n\\end{cases}\n\\end{equation}\n is\n\\begin{equation}\n  \\label{eq:138}\n  p(t) = p_0 \\expq(t \\widehat \\Omega)\n\\end{equation}\nThe exponential mapping $\\expq : \\mathfrak h_1 \\rightarrow \\HH_1$ can also be defined as $\\expq(\\widehat \\Omega) = q(1)$ where $q (t)$ satisfies the  differential equation\n\\begin{equation}\n  \\label{eq:235}\n  \\dot q(t) = q(t) \\cdot \\widehat \\Omega , \\quad q (0) = e.\n\\end{equation}\nUsing the quaternion product, the exponential map can be expressed as\n\\begin{equation}\n  \\label{eq:232}\n  \\expq(t \\widehat \\Omega ) = \\sum_{k=0}^\\infty \\frac{(t\\widehat \\Omega)^k}{k!}\n\\end{equation}\nsince it is  a solution of \\eqref{eq:130}. A simple computation allows to check this claim:\n\\begin{equation}\n  \\label{eq:233}\n   \\frac{d}{dt}\\expq(t \\widehat \\Omega ) = \\sum_{k=1}^\\infty  k t^{k-1} \\frac{ \\widehat \\Omega ^k}{k!} =  \\sum_{k=0}^\\infty  t^{k} \\frac{t \\widehat \\Omega ^k}{k!}\\glaw  \\widehat \\Omega  =   \\expq(t \\widehat \\Omega ) \\glaw \\widehat \\Omega.\n\\end{equation}\n\nA closed form relation for the form the quaternion exponential can also be found by noting that\n\\begin{equation}\n  \\label{eq:140}\n  \\widehat \\Omega ^2  = - \\left(\\frac \\theta 2 \\right)^2 e, \\text{ and } \\widehat \\Omega ^3  = - \\left(\\frac \\theta 2 \\right)^2 \\widehat \\Omega.\n\\end{equation}\nA simple expansion of \\eqref{eq:232} at $t=1$ equals\n\\begin{equation}\n  \\label{eq:141}\n  \\begin{array}{lcl}\n    \\expq(\\widehat \\Omega ) &=& \\sum_{k=0}^\\infty \\frac{(\\widehat \\Omega)^k}{k!}\\\\\n                            &=& \\sum_{k=0}^\\infty \\frac{(-1)^k}{(2k)!}\\left(\\frac \\theta 2 \\right)^{2k} e + \\sum_{k=0}^\\infty \\frac{(-1)^k}{(2k+1)!} \\left(\\frac \\theta 2 \\right)^{2k+1} \\widehat \\Omega \\\\\n                            &=& \\cos(\\frac \\theta 2) e + \\frac{\\sin(\\frac \\theta 2)}{\\frac \\theta 2} \\widehat \\Omega \\\\\n  \\end{array}\n\\end{equation}\nthat is\n\\begin{equation}\n  \\label{eq:144}\n  \\expq(\\widehat \\Omega )  = (\\cos(\\frac \\theta 2), \\sin(\\frac \\theta 2) \\frac{\\Omega}{\\theta}   ).\n\\end{equation}\n\n\\paragraph{Adjoint representation}\nIn the case of $\\HH_1$, the definition of the operator $\\Ad$ gives\n\\begin{equation}\n  \\label{eq:121}\n  \\Ad_p(\\widehat\\Omega)  = p\\glaw \\widehat\\Omega p^\\star\n\\end{equation}\n and then mapping $\\ad_{\\widehat\\Omega}(\\widehat \\Gamma)$ is defined by\n\\begin{equation}\n  \\label{eq:56}\n  \\ad_{\\widehat\\Omega}(\\widehat\\Gamma) = \\widehat \\Omega \\widehat\\Gamma - \\widehat \\Gamma \\widehat\\Omega  =  [\\widehat \\Omega,\\widehat \\Gamma] = \\widehat{\\Omega \\times \\Gamma}.\n\\end{equation}\nUsing the isomorphism between $\\mathfrak h_1$ and $\\RR^3$, we can use the  the mapping $\\ad_{\\Omega}(\\Gamma) : \\RR^3\\times\\RR^3 \\rightarrow \\RR^3$ given by \\eqref{eq:55} to get \n\\begin{equation}\n  \\label{eq:145}\n   \\ad_{\\widehat\\Omega}(\\widehat\\Gamma) = \\widehat{\\Omega \\times \\Gamma} = \\widehat{\\ad_{\\Omega}(\\Gamma)} =  \\widehat{\\tilde \\Omega \\Gamma}\n\\end{equation}\n\n\\paragraph{Differential of the exponential map $\\dexpq$}\nThe differential of the exponential mapping, denoted by $\\dexpq$ is defined as the 'right trivialized' tangent of the exponential map \n\\begin{equation}\n  \\label{eq:71}\n  \\frac{d}{dt} (\\expq(\\widehat \\Omega(t))) = \\dexpq_{\\widehat\\Omega(t)}(\\frac{d \\widehat{\\Omega}(t)}{dt}) \\expq(\\widehat\\Omega(t))\n\\end{equation}\n\nAn explicit expression of $\\dexp_{\\widehat\\Omega}(\\widehat\\Gamma)$ can also be developed either by developing the expansion and~\\eqref{eq:137}.\n\\begin{equation}\n  \\label{eq:168}\n   \\dexpq_{\\widehat\\Omega}(\\Gamma) = \\sum_{k=0}^\\infty \\frac{1}{(k+1)!} \\ad_{\\widehat\\Omega}^k (\\widehat\\Gamma) = \\widehat{T(\\Omega)\\Gamma}\n\\end{equation}\n\n\\begin{remark}\nNote that the time derivative in $\\RR^4$ is not differential mapping.\nThe standard time derivative of $\\expq$ in the expression \\eqref{eq:144} gives\n\\begin{equation}\n  \\label{eq:171}\n    \\frac{d}{dt}\\expq(\\widehat \\Gamma(t)) = (- \\frac{\\sin(\\theta)}{\\theta} \\Omega^T\\Gamma, \\frac{\\sin(\\theta)}{\\theta}\\Gamma  +\\frac{\\theta \\cos(\\theta)-\\sin(\\theta)}{\\theta^3}\\Omega^T\\Omega \\Gamma  )\n\\end{equation}\nthat can be expressed in $\\RR^4$ by\n\\begin{equation}\n  \\label{eq:175}\n  \\frac{d}{dt}\\expq(\\widehat \\Gamma(t))  = \\nabla \\expq(\\widehat\\Omega) \\widehat{\\dot\\Omega} \n\\end{equation}\nwith\n\\begin{equation}\n  \\label{eq:176}\n  \\nabla \\expq(\\widehat\\Omega) =\n  \\begin{bmatrix}\n    - \\frac{\\sin(\\theta)}{\\theta} \\Omega^T \\\\\n    \\frac{\\sin(\\theta)}{\\theta}I  +\\frac{\\theta \\cos(\\theta)-\\sin(\\theta)}{\\theta^3}\\Omega^T\\Omega\n  \\end{bmatrix}\n\\end{equation}\n\nClearly, we have \n\\begin{equation}\n  \\label{eq:177}\n  \\nabla \\expq(\\widehat\\Omega) \\neq  \\dexpq_{\\widehat\\Omega}\n\\end{equation}\n\\end{remark}\n\n\n\\paragraph{Directional derivative and Jacobians of functions of a quaternion}\n\\begin{ndrva}\n  experimental\n\\end{ndrva}\n\nLet $f : \\HH_1 \\rightarrow \\RR $ be a mapping from the group to $\\RR^3$. The directional derivative of $f$ in the direction $\\widehat \\Omega \\in \\mathfrak h_1$ at $p\\in \\HH_1$ is \ndefined by\n\\begin{equation}\n  \\label{eq:139}\n df_p(\\widehat \\Omega) =\\left. \\frac{d}{dt} f(p\\glaw \\expq(t\\widehat \\Omega)) \\right|_{t=0}\n\\end{equation}\n\nAs a first simple example let us choose $f(p) = \\vv{p \\glaw p_x \\glaw p^\\star}$ for a given $x \\in \\RR^3 $, we get\n\\begin{equation}\n  \\label{eq:142}\n  \\begin{array}{lcl}\n    D Id \\cdot \\widehat \\Omega (p) = (\\widehat \\Omega^r f )(p) &=& \\left. \\frac{d}{dt}\\vv{p\\glaw \\expq(t\\widehat \\Omega) \\glaw p_x \\glaw (p \\glaw \\expq(t\\widehat \\Omega))^\\star}  \\right|_{t=0}\\\\\n                                                               & = & \\vv{p\\glaw \\frac{d}{dt}\\left. \\expq(t\\widehat \\Omega) \\right|_{t=0} \\glaw p_x \\glaw p^\\star +  p \\glaw p_x \\glaw (p \\glaw\\frac{d}{dt}\\left. \\expq(t\\widehat \\Omega) \\right|_{t=0})^\\star}\\\\                                              \n  \\end{array}\n\\end{equation}\nWe have form the definition of the time derivative of the exponential\n\\begin{equation}\n  \\label{eq:143}\n  \\begin{array}{lcl}\n    \\frac{d}{dt}\\left. \\expq(t\\widehat \\Omega) \\right|_{t=0} &=&  \\left. \\dexpq_{\\widehat\\Omega}(\\widehat \\Omega)\\expq(t\\widehat \\Omega) \\right|_{t=0} \\\\\n                                                            &=&  \\dexpq_{\\widehat\\Omega}(\\widehat \\Omega)\n  \\end{array}\n\\end{equation}\n\nThen, the directional derivative can be written\n\\begin{equation}\n  \\label{eq:146}\n  \\begin{array}{lcl}\n    D Id \\cdot \\widehat \\Omega (p) &=& \\vv{p\\glaw \\dexpq_{\\widehat\\Omega}(\\widehat \\Omega)\\glaw p_x \\glaw p^\\star  + p \\glaw p_x \\glaw (\\dexpq_{\\widehat\\Omega}(\\widehat \\Omega))^* \\glaw  p^\\star } \\\\\n  &=& \\vv{p\\glaw ( \\dexpq_{\\widehat\\Omega}(\\widehat \\Omega)\\glaw p_x +   p_x \\glaw (\\dexpq_{\\widehat\\Omega}(\\widehat \\Omega))^*) \\glaw  p^\\star } \n  \\end{array}\n\\end{equation}\n\n\n\n\n\\section{Newton-Euler equation in quaternion  form}\n\n\\paragraph{Computation of $T$ for unit quaternion} The operator $T(q)$ is directly obtained as\n\\begin{equation}\n  T(q)=\\frac 1 2 \\label{eq:98}\n  \\begin{bmatrix}\n    2 I_{3\\times 3} & & 0_{3\\times 3} & \\\\\n    &   -p_1 & -p_2 & -p_3 \\\\\n    0_{4\\times 3}  &  p_0 & -p_3 & p_2 \\\\\n    & p_3 & p_0 & -p_1 \\\\\n    & -p_2 & p_1 & p_0 \n  \\end{bmatrix}\n\\end{equation}\n\n\\paragraph{}\n\n\n\n\n\\begin{ndrva}\n  todo :\n  \\begin{itemize}\n  \\item computation of the directional derivative of $R(\\Omega)= exp(\\tilde \\Omega)$ in the direction $\\tilde\\Omega$, to get $T(\\Omega)$  \n  \\end{itemize}\n\\end{ndrva}\n\n\\paragraph{Quaternion representation}If the Lie group is described by unit quaternion, we get\n\\begin{equation}\n  \\label{eq:99}\n  SO(3) = \\{p = (p_0,\\vv{p}) \\in \\RR^{4}\\mid |p|=1  \\}\n\\end{equation}\nwith the composition law  $p_1\\glaw p_2$ given by the quaternion product.\n\n\n\nNote that the concept of exponential map for Lie group that are not parameterized by matrices is also possible.\n\n\n\\subsection{Mechanical systems  with bilateral and unilateral constraints}\n\\label{section22}\n\n\nLet us consider that the system~(\\ref{eq:Newton-Euler-compact}) is  subjected to $m$ constraints, with $m_{e}$ holonomic bilateral \nconstraints\n\\begin{equation}\n  \\label{eq:bilateral-constraints}\n  h^\\alpha(q)=0, \\alpha \\in \\mathcal{E}\\subset\\NN,  |\\mathcal E| = m_e,\n\\end{equation}\nand  $m_{i}$ unilateral constraints\n\\begin{equation}\n  \\label{eq:unilateral-constraints}\n  g_{\\n}^\\alpha(q)\\geq 0, \\alpha \\in \\mathcal{I}\\subset\\NN,  |\\mathcal I| = m_i.\n\\end{equation} \n%\nLet us denote as $J^\\alpha_h(q) = \\nabla^\\top_q h^\\alpha(q)  $ the Jacobian matrix of the bilateral constraint $h^\\alpha(q)$ with respect to $q$ and as $J^\\alpha_{g_\\n}(q)$ respectively for $g_{\\n}^\\alpha(q)$  .\n%\nThe bilateral constraints at the velocity level can be obtained as:\n\\begin{equation}\n  \\label{eq:bilateral-constraints-velocity}\n 0 = \\dot h^\\alpha(q)= J^\\alpha_h(q)\\dot q = J^\\alpha_h(q) T(q) v \\coloneqq H^\\alpha(q)  v,\\quad  \\alpha \\in \\mathcal{E}.\n\\end{equation}\nBy duality and introducing a Lagrange multiplier $\\lambda^\\alpha, \\alpha \\in \\mathcal E$, the constraint generates a force applied to the body equal to $H^{\\alpha,\\top}(q)\\lambda^\\alpha$. For the unilateral constraints, a Lagrange multiplier $\\lambda_{\\n}^\\alpha, \\alpha \\in \\mathcal I$ is also associated and the constraints at the velocity level can also be derived as\n\\begin{equation}\n  \\label{eq:unilateral-constraints-velocity}\n 0 \\leq  \\dot g_\\n^\\alpha(q)= J^\\alpha_{g_\\n}(q) \\dot q = J^\\alpha_{g_\\n}(q)  T(q) v , \\text{ if } g_{\\n}^\\alpha(q) = 0,\\quad  \\alpha \\in \\mathcal{I}. \n\\end{equation}\nAgain, the force applied to the body is given by $(J^\\alpha_{g_\\n}(q) T(q))^\\top\\lambda^\\alpha_\\n$. {Nevertheless, there is no reason that $\\lambda^\\alpha_\\n =r^\\alpha_\\n$ and $u_\\n = J^\\alpha_{g_\\n}(q) T(q) v$ if the $g_n$ is not chosen as the signed distance (the gap function)}. This is the reason why  we prefer  directly define the normal and the tangential local relative velocity with respect to the {twist vector} as\n\\begin{equation}\n  \\label{eq:unilateral-constraints-velocity-kinematic1}\n   u^\\alpha_\\n  \\coloneqq G_\\n^\\alpha(q) v, \\quad u^\\alpha_\\t  \\coloneqq G_\\t^\\alpha(q) v, \\quad \\alpha \\in \\mathcal{I},\n\\end{equation}\nand the associated force as $G_\\n^{\\alpha,\\top}(q) r^{\\alpha}_\\n $ and $G_\\t^{\\alpha,\\top}(q) r^{\\alpha}_\\t$. For the sake of simplicity, we use the notation $u^\\alpha  \\coloneqq G^\\alpha(q) v$ and its associated total force generated by the contact $\\alpha$ as $G^{\\alpha,\\top}(q) r^{\\alpha} \\coloneqq G_\\n^{\\alpha,\\top}(q) r^{\\alpha}_\\n + G_\\t^{\\alpha,\\top}(q) r^{\\alpha}_\\t $.\n\nThe complete system of equation of motion can finally be written as\n\\begin{numcases}{ }\n  ~~\\dot q = T(q)v ,\\nonumber \\\\[0.5ex]\n  ~~ M \\dot v  = F(t,q,v) + H^\\top(q) \\lambda +  G^\\top(q) r, \\nonumber \\\\ [0.5ex]\n  ~~\\begin{array}{ll}\n    H^\\alpha(q) v  =  0 ,& \\alpha \\in \\mathcal E \\\\[1ex]\n    \\left. \\begin{array}{ll}\n      r^\\alpha= 0 , &\\text{ if } g_{\\n}^\\alpha(q) > 0,\\\\[1ex]\n      {K}^{\\alpha,*} \\ni \\widehat u^\\alpha  \\bot~ r^\\alpha \\in {K}^\\alpha, &\\text{ if } g_{\\n}^\\alpha(q) = 0, \\\\[1ex]\n      u_{\\n}^{\\alpha,+} = -e_r^\\alpha u_{\\n}^{\\alpha,-}, &\\text{ if } g_{\\n}^\\alpha(q) = 0 \\text{ and } u_{\\n}^{\\alpha,-} \\leq 0, \n    \\end{array}\\right\\} & \\alpha \\in \\mathcal I  \\label{eq:NewtonEuler-uni}\n\\end{array}\n\\end{numcases}\nwhere the definition of the variables $\\lambda\\in \\RR^{m_e}, r\\in \\RR^{3m_i}$ and the operators $H,G$ are extended to collect all the variables for each constraints.\n\nNote that all the constraints are written at the velocity integrators. {Another strong advantage is the straightforward introduction of  the contact dissipation processes that are naturally written at the velocity level such as the Newton impact law and the Coulomb friction. Indeed, in Mechanics, dissipation processes are always given in terms of rates of changes, or if we prefer, in terms of velocities.}\n\n\\paragraph{Siconos Notation} In the siconos notation, we have for the applied torques on the system the following decomposition\n\\begin{equation}\n  F(t,q,v):= \\begin{pmatrix}\n    f(t,x_{\\cg},  v_{\\cg}, R, \\Omega ) \\\\\n    I \\Omega \\times \\Omega + M(t,x_{\\cg}, v_{\\cg}, R, \\Omega )\n  \\end{pmatrix}\n  := \\begin{pmatrix}\n    f_{ext}(t)  - f_{int}(x_{\\cg},  v_{\\cg}, R, \\Omega ) \\\\\n    - M_{gyr}(\\Omega) + M_{ext}(t) -  M_{int}(x_{\\cg}, v_{\\cg}, R, \\Omega )\n  \\end{pmatrix}.\n\\end{equation}\nwith\n\\begin{equation}\n  M_{gyr} := \\begin{pmatrix}\n     \\Omega \\times I\\Omega\n  \\end{pmatrix}\n\\end{equation}\n\n\n\nIn the siconos notation, we have for the relation\n\\begin{equation}\n  \\label{eq:100}\n   C =   J^\\alpha(q) \\quad CT = J^\\alpha(q)T(q)\n\\end{equation}\n\n\n\n\n\n\n\n\\section{Time integration scheme in scheme}\n\n\n\\subsection{Moreau--Jean scheme based on a  $\\theta$-method}\nThe complete Moreau--Jean scheme based on a  $\\theta$-method is written as follows\n \\begin{equation}\n    \\label{eq:Moreau--Jean-theta}\n    \\begin{cases}\n      ~~\\begin{array}{l}\n        q_{k+1} = q_{k} + h T(q_{k+\\theta}) v_{k+\\theta} \\quad \\\\[1ex]\n        M(v_{k+1}-v_k) - h  F(t_{k+\\theta}, q_{k+\\theta},v_{k+\\theta}) =  H^\\top(q_{k+1}) Q_{k+1} + G^\\top(q_{k+1}) P_{k+1},\\quad\\,\\\\[1ex]\n      \\end{array}\\\\\n      ~~\\begin{array}{lcl}\n        \\begin{array}{l}\n          H^\\alpha(q_{k+1}) v_{k+1}  =  0\\\\\n        \\end{array} & \\left. \\begin{array}{l}\n          \\vphantom{H^\\alpha(q_{k+1}) v_{k+1}  =  0}\\\\[1ex]\n        \\end{array}\\right\\}    &\\alpha \\in \\mathcal E  \\\\[1ex]\n      ~~~P_{k+1}^\\alpha= 0, &\n      \\left. \\begin{array}{l}\n          \\vphantom{P_{k+1}^\\alpha= 0,  \\delta^\\alpha_{k+1}=0}\\\\[1ex]\n        \\end{array}\\right\\}   & \\alpha \\not\\in \\mathcal I^\\nu \\\\[1ex]\n      % \n      % \n      \\begin{array}{l}\n          {K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha \\\\\n      \\end{array} &\n      \\left.\\begin{array}{l}\n          \\vphantom{{K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha} \\\\\n        \\end{array}\\right\\}\n      &\\alpha \\in \\mathcal I^\\nu\\\\\n  \\end{array}\n\\end{cases}\n\\end{equation}\nwhere $\\mathcal I^\\nu$ is the set of forecast constraints, that may be evaluated as\n\\begin{equation}\n  \\label{eq:101}\n  \\mathcal I^\\nu = \\{\\alpha \\mid \\bar g_\\n^\\alpha \\coloneqq g_\\n + \\frac h 2 u^\\alpha_\\n \\leq 0\\}.\n\\end{equation}\n\n\n\\subsection{Semi-explicit version Moreau--Jean scheme based on a  $\\theta$-method}\n\n\\begin{equation}\n    \\label{eq:Moreau--Jean-explicit}\n    \\begin{cases}\n      ~~\\begin{array}{l}\n        q_{k+1} = q_{k} + h T(q_{k}) v_{k+\\theta} \\quad \\\\[1ex]\n        M(v_{k+1}-v_k) - h  F(t_{k}, q_{k},v_{k}) =  H^\\top(q_{k}) Q_{k+1}+  G^\\top(q_{k}) P_{k+1},\\quad\\,\\\\[1ex]\n      \\end{array}\\\\\n      ~~\\begin{array}{lcl}\n        \\begin{array}{l}\n          H^\\alpha(q_{k+1}) v_{k+1}  =  0\\\\\n        \\end{array} & \\left. \\begin{array}{l}\n          \\vphantom{H^\\alpha(q_{k+1}) v_{k+1}  =  0}\\\\[1ex]\n        \\end{array}\\right\\}    &\\alpha \\in \\mathcal E  \\\\[1ex]\n      ~~P_{k+1}^\\alpha= 0, &\n      \\left. \\begin{array}{l}\n          \\vphantom{P_{k+1}^\\alpha= 0,  \\delta^\\alpha_{k+1}=0}\\\\[1ex]\n        \\end{array}\\right\\}   & \\alpha \\not\\in \\mathcal I^\\nu \\\\[1ex]\n      % \n      % \n      \\begin{array}{l}\n          {K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha \\\\\n      \\end{array} &\n      \\left.\\begin{array}{l}\n          \\vphantom{{K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha} \\\\\n        \\end{array}\\right\\}\n      &\\alpha \\in \\mathcal I^\\nu\\\\\n  \\end{array}\n\\end{cases}\n\\end{equation}\n\nIn this version, the new velocity $v_{k+1}$ can be computed explicitly, assuming that the inverse of $M$ is easily written, as\n\n\\begin{equation}\n  \\label{eq:Moreau--Jean-theta--explicit-v}\n  v_{k+1}   =  v_k + M^{-1} h  F(t_{k}, q_{k},v_{k}) +  M^{-1} (H^\\top(q_{k}) Q_{k+1}+  G^\\top(q_{k}) P_{k+1})\n\\end{equation}\n\n\n\\subsection{Nearly implicit version Moreau--Jean scheme based on a  $\\theta$-method implemented in siconos}\n\nA first simplification is made considering a given value of $q_{k+1}$ in $T()$, $H()$ and $G()$ denoted by $\\bar q_k$. This limits the computation of the Jacobians of this operators with respect to $q$. \n\\begin{equation}\n    \\label{eq:Moreau--Jean-theta-nearly}\n    \\begin{cases}\n      ~~\\begin{array}{l}\n        q_{k+1} = q_{k} + h T(\\bar q_k) v_{k+\\theta} \\quad \\\\[1ex]\n        M(v_{k+1}-v_k) - h  \\theta F(t_{k+1}, q_{k+1},v_{k+1}) - h (1- \\theta) F(t_{k}, q_{k},v_{k})  =  H^\\top(\\bar q_k) Q_{k+1} + G^\\top(\\bar q_k) P_{k+1},\\quad\\,\\\\[1ex]\n      \\end{array}\\\\\n      ~~\\begin{array}{lcl}\n        \\begin{array}{l}\n          H^\\alpha(\\bar q_k) v_{k+1}  =  0\\\\\n        \\end{array} & \\left. \\begin{array}{l}\n          \\vphantom{H^\\alpha(q_{k+1}) v_{k+1}  =  0}\\\\[1ex]\n        \\end{array}\\right\\}    &\\alpha \\in \\mathcal E  \\\\[1ex]\n      ~~P_{k+1}^\\alpha= 0, &\n      \\left. \\begin{array}{l}\n          \\vphantom{P_{k+1}^\\alpha= 0,  \\delta^\\alpha_{k+1}=0}\\\\[1ex]\n        \\end{array}\\right\\}   & \\alpha \\not\\in \\mathcal I^\\nu \\\\[1ex]\n      % \n      % \n      \\begin{array}{l}\n          {K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha \\\\\n      \\end{array} &\n      \\left.\\begin{array}{l}\n          \\vphantom{{K}^{\\alpha,*} \\ni \\widehat u_{k+1}^\\alpha~ \\bot~ P_{k+1}^\\alpha \\in {K}^\\alpha} \\\\\n        \\end{array}\\right\\}\n      &\\alpha \\in \\mathcal I^\\nu\\\\\n  \\end{array}\n\\end{cases}\n\\end{equation}\nThe nonlinear residu is defined as\n\\begin{equation}\n  \\label{eq:Moreau--Jean-theta--nearly-residu}\n  \\mathcal R(v) =  M(v-v_k) - h  \\theta F(t_{k+1}, q(v),v) - h (1- \\theta) F(t_{k}, q_{k},v_{k}) - H^\\top(\\bar q_k) Q_{k+1} - G^\\top(\\bar q_k) P_{k+1}\n\\end{equation}\nwith\n\\begin{equation}\n  \\label{eq:Moreau--Jean-theta--nearly-residu1}\n  q(v) = q_{k} + h T(\\bar q_k)) ((1-\\theta) v_k + \\theta v).\n\\end{equation}\nAt each time step, we have to solve\n\\begin{equation}\n  \\label{eq:Moreau--Jean-theta--nearly-residu2}\n  \\mathcal R(v_{k+1}) =  0\n\\end{equation}\ntogether with the constraints.\n\nLet us write a linearization of the problem to design a Newton procedure:\n\\begin{equation}\n  \\label{eq:Moreau--Jean-theta--nearly-residu3}\n  \\nabla^\\top_v \\mathcal R(v^{\\tau}_{k+1})(v^{\\tau+1}_{k+1}-v^{\\tau}_{k+1}) = -  \\mathcal R(v^{\\tau}_{k+1}).\n\\end{equation}\nThe computation of $ \\nabla^\\top_v \\mathcal R(v^{\\tau}_{k+1})$ is as follows\n\\begin{equation}\n  \\label{eq:102}\n  \\nabla^\\top_v \\mathcal R(v) = M - h \\theta \\nabla_v F(t_{k+1}, q(v),v)\n\\end{equation}\nwith\n\\begin{equation}\n  \\label{eq:103}\n  \\begin{array}{lcl}\n    \\nabla_v F(t_{k+1}, q(v),v) &=& D_2 F(t_{k+1}, q(v),v) \\nabla_v q(v) + D_3 F(t_{k+1}, q(v),v) \\\\\n                                &=& h \\theta D_2 F(t_{k+1}, q(v),v) T(\\bar q_k) + D_3 F(t_{k+1}, q(v),v) \\\\\n  \\end{array}\n\\end{equation}\nwhere $D_i$ denotes the derivation with respect the $i^{th}$ variable. The complete Jacobian is then given by\n\\begin{equation}\n  \\label{eq:104}\n  \\nabla^\\top_v \\mathcal R(v) = M - h \\theta D_3 F(t_{k+1}, q(v),v) - h^2 \\theta^2 D_2 F(t_{k+1}, q(v),v) T(\\bar q_k)\n\\end{equation}\nIn siconos, we ask the user to provide the functions $D_3 F(t_{k+1}, q ,v )$ and $D_2 F(t_{k+1}, q,v)$.\n\nLet us denote by $W^{\\tau}$ the inverse of  Jacobian of the residu,\n\\begin{equation}\n  \\label{eq:105}\n  W^{\\tau} = (M - h \\theta D_3 F(t_{k+1}, q(v),v) - h^2 \\theta^2 D_2 F(t_{k+1}, q(v),v) T(\\bar q_k))^{-1}.\n\\end{equation}\nand by $\\mathcal R_{free}(v)$ the free residu,\n\\begin{equation}\n  \\label{eq:106}\n  \\mathcal R_{free}(v) =  M(v-v_k) - h  \\theta F(t_{k+1}, q(v),v) - h (1- \\theta) F(t_{k}, q_{k},v_{k}).\n\\end{equation}\n\nThe linear equation \\ref{eq:Moreau--Jean-theta--nearly-residu3} that we have to solve is equivalent to\n\\begin{equation}\n  \\label{eq:107}\n  \\boxed{v^{\\tau+1}_{k+1} = v^{\\tau}_{k+1} - W  \\mathcal R_{free}(v^\\tau_{k+1}) + W   H^\\top(\\bar q_k) Q^{\\tau+1}_{k+1} + W G^\\top(\\bar q_k) P^{\\tau+1}_{k+1}}\n\\end{equation}\nWe define  $v_{free}$ as\n\\begin{equation}\n  \\label{eq:108}\n  v_{free}  = v^{\\tau}_{k+1} - W  \\mathcal R_{free}(v^\\tau_{k+1})\n\\end{equation}\n\nThe local velocity at contact can be written\n\\begin{equation}\n  \\label{eq:109}\n  u^{\\tau+1}_{\\n,k+1} = G(\\bar q_k) [  v_{free}^{\\tau} + W   H^\\top(\\bar q_k) Q^{\\tau+1}_{k+1} + W G^\\top(\\bar q_k) P^{\\tau+1}_{k+1}]\n\\end{equation}\nand for the equality constraints\n\\begin{equation}\n  \\label{eq:110}\n  u^{\\tau+1}_{k+1} = H(\\bar q_k) [  v_{free}^{\\tau} + W   H^\\top(\\bar q_k) Q^{\\tau+1}_{k+1} + W G^\\top(\\bar q_k) P^{\\tau+1}_{k+1}]\n\\end{equation}\nFinally, we get a linear relation between $u^{\\tau+1}_{\\n,k+1}$ and the multiplier \n\\begin{equation}\n  \\label{eq:111}\n \\boxed{ u^{\\tau+1}_{k+1} =\n  \\begin{bmatrix}\n    H(\\bar q_k) \\\\\n    G(\\bar q_k)\n  \\end{bmatrix} v_{free}^{\\tau}\n  +\n  \\begin{bmatrix}\n    H(\\bar q_k)W   H^\\top(\\bar q_k) & H(\\bar q_k)W   G^\\top(\\bar q_k) \\\\\n    G(\\bar q_k)W   H^\\top(\\bar q_k) & G(\\bar q_k)W   G^\\top(\\bar q_k) \\\\\n  \\end{bmatrix}\n  \\begin{bmatrix}\n    Q^{\\tau+1}_{k+1} \\\\\n    P^{\\tau+1}_{k+1}\n  \\end{bmatrix}}\n\\end{equation}\n\n\n\n\n\n\n\\paragraph{choices for $\\bar q_k$} Two choices are possible for $\\bar q_k$\n\\begin{enumerate}\n\\item $\\bar q_k = q_k$\n\\item $\\bar q_k = q^{\\tau}_{k+1}$\n\\end{enumerate}\n\n\\begin{ndrva}\n\n  todo list:\n  \n  \\begin{itemize}\n\n\n  \\item add the projection step for the unit quaternion\n\n  \\item describe the computation of H and G that can be hybrid\n\n    \n\\end{itemize}\n\n\\end{ndrva}\n\n\n\\subsection{Computation of the Jacobian in special case}\n\n\\paragraph{Moment of gyroscopic forces}\nLet us denote by the basis vector $e_i$ given the $i^{th}$ column of the identity matrix $I_{3\\times3}$. The Jacobian of $M_{gyr}$ is given by\n\\begin{equation}\n  \\label{eq:112}\n  \\nabla^\\top_\\Omega M_{gyr}(\\Omega) = \\nabla^\\top_\\Omega (\\Omega \\times I \\Omega) =\n  \\begin{bmatrix}\n    e_i \\times I \\Omega + \\Omega \\times I e_i, i =1,2,3\n  \\end{bmatrix}\n\\end{equation}\n\n\\paragraph{Linear internal wrench}\nIf the internal wrench  is given by\n\\begin{equation}\n  \\label{eq:113}\n  F_{int}(t,q,v) =\n  \\begin{bmatrix}\n    f_{int}(t,q,v)\\\\\n    M_{int}(t,q,v)\n  \\end{bmatrix}\n  = C v + K q, \\quad C \\in \\RR^{6\\times 6}, \\quad K \\in \\RR^{6\\times 7 }\n\\end{equation}\nwe get\n\\begin{equation}\n  \\label{eq:114}\n  \\begin{array}{lcl}\n    \\nabla_v F(t_{k+1}, q(v),v)  &=& h \\theta K T(\\bar q_k) + C \\\\\n    \\nabla^\\top_v \\mathcal R(v) &=& M - h \\theta C - h^2 \\theta^2 K T(\\bar q_k)\n  \\end{array}\n\\end{equation}\n\n\\paragraph{External moment given in the inertial frame}\n\nIf the external moment denoted by $m_{ext} (t)$ is expressed in inertial frame, we have\n\\begin{equation}\n  \\label{eq:115}\n  M_{ext}(q,t) = R^T m_{ext}(t)= \\Phi(p) m_{ext}(t)\n\\end{equation}\nIn that case, $  M_{ext}(q,t)$ appears as a function $q$ and we need to compute its Jacobian w.r.t $q$. This computation needs the computation of\n\\begin{equation}\n  \\label{eq:116}\n  \\nabla_{p} M_{ext}(q,t) = \\nabla_{p} \\Phi(p) m_{ext}(t) \n\\end{equation}\nLet us compute first\n\\begin{equation}\n  \\label{eq:117}\n  \\Phi(p) m_{ext}(t)  =\n  \\begin{bmatrix}\n    (1-2 p_2^2- 2 p_3^2)m_{ext,1} + 2(p_1p_2-p_3p_0)m_{ext,2} + 2(p_1p_3+p_2p_0)m_{ext,3}\\\\\n    2(p_1p_2+p_3p_0)m_{ext,1}  +(1-2 p_1^2- 2 p_3^2)m_{ext,2} + 2(p_2p_3-p_1p_0)m_{ext,3}\\\\\n    2(p_1p_3-p_2p_0)m_{ext,1}  + 2(p_2p_3+p_1p_0)m_{ext,2}  + (1-2 p_1^2- 2 p_2^2)m_{ext,3}\\\\\n  \\end{bmatrix}\n\\end{equation}\nThen we get\n\\begin{equation}\n  \\label{eq:118}\n  \\begin{array}{l}\n  \\nabla_{p} \\Phi(p) m_{ext}(t)  =\\\\\n  \\begin{bmatrix}\n    -2 p_3 m_{ext,2} + 2 p_2 m_{ext,3} & 2p_2 m_{ext,2}+2 p_3 m_{ext,3}  & -4 p_2 m_{ext,1} +2p_1 m_{ext,2}+2 p_0 m_{ext,3} & -3 p_3 m_{ext,1} -2p_0 m_{ext,2} +2 p_1m_{ext,3}  \\\\\n    2p_3 m_{ext,1} -2p_1m_{ext,3}  & 2p_2m_{ext,1} -4p_1 m_{ext,2} -2p_1 m_{ext,3} & & &  \\\\\n  \\end{bmatrix}\n  \\end{array}\n\\end{equation}\n\n\n\n\n\n\\subsection{Siconos implementation}\n\nThe expression:~$\\mathcal R_{free}(v^\\tau_{k+1}) = M(v-v_k) - h  \\theta F(t_{k+1}, q(v^\\tau_{k+1}),v^\\tau_{k+1}) - h (1- \\theta) F(t_{k}, q_{k},v_{k})$ is computed in {\\tt MoreauJeanOSI::computeResidu()} and saved in {\\tt ds->workspace(DynamicalSystem::freeresidu)}\n\n\nThe expression:~$\\mathcal R(v^\\tau_{k+1}) =\\mathcal R_{free}(v^\\tau_{k+1}) - h (1- \\theta) F(t_{k}, q_{k},v_{k}) - H^\\top(\\bar q_k) Q_{k+1} - G^\\top(\\bar q_k) P_{k+1}  $ is computed in {\\tt MoreauJeanOSI::computeResidu()} and saved in {\\tt ds->workspace(DynamicalSystem::free)}.\n\\begin{ndrva}\n  really a bad name for the buffer {\\tt ds->workspace(DynamicalSystem::free)}. Why we are chosing this name ? to save some memory ?\n\\end{ndrva}\n\n\nThe expression:~$v_{free}  = v^{\\tau}_{k+1} - W  \\mathcal R_{free}(v^\\tau_{k+1})$ is compute in {\\tt MoreauJeanOSI::computeFreeState()} and saved in {\\tt d->workspace(DynamicalSystem::free)}. \n\n\n\nThe computation:~ $v^{\\tau+1}_{k+1} = v_{free} + W   H^\\top(\\bar q_k) Q^{\\tau+1}_{k+1} + W G^\\top(\\bar q_k) P^{\\tau+1}_{k+1}$ is done in {\\tt MoreauJeanOSI::updateState} and stored in {\\tt d->twist()}.\\\\\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"DevNotes\"\n%%% End: \n", "meta": {"hexsha": "0be9ac4753d7e050db7a58cafaa72c9141c7a112", "size": 64433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/sphinx/devel_guide/notes/NewtonEuler.tex", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "docs/sphinx/devel_guide/notes/NewtonEuler.tex", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "docs/sphinx/devel_guide/notes/NewtonEuler.tex", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 42.7274535809, "max_line_length": 662, "alphanum_fraction": 0.6299722192, "num_tokens": 24743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7057850340255387, "lm_q1q2_score": 0.44190907372929056}}
{"text": "% When using TeXShop on the Mac, let it know the root document. The following must be one of the first 20 lines.\n% !TEX root = ../design.tex\n\n\\chapter[ARIMA]{ARIMA}\n\\begin{moduleinfo}\n\\item[Authors] {Mark Wellons}\n\\item[History]\n\t\\begin{modulehistory}\n    \t\t\\item[v0.1] Initial version\n\t\\end{modulehistory}\n\\end{moduleinfo}\n\n% Abstract. What is the problem we want to solve?\n\\section{Introduction}\n\nAn ARIMA model is an \\textit{a}uto-\\textit{r}egressive \\textit{i}ntegrated\n\\textit{m}oving \\textit{a}verage model.  An ARIMA model is typically expressed\nin the form\n\\begin{equation}\n(1 - \\phi(B)) Y_t  = (1 + \\theta(B)) Z_t,\n\\end{equation}\nwhere $B$ is the backshift operator. The time $t$ is from $1$ to $N$.\n\nARIMA models involve the following variables:\n\\begin{enumerate}\n   \\item The lag difference $Y_{t}$, where  $Y_{t} = (1-B)^{d}(X_{t} - \\mu)$.\n    \\item The values of the time series $X_t$.\n    \\item $p$, $q$, and $d$ are the parameters of the ARIMA model.\n      $d$ is the differencing order, $p$ is the order of the AR\n      operator, and $q$ is the order of the MA operator.\n    \\item The AR operator $\\phi(B)$.\n    \\item The MA operator $\\theta(B)$.\n    \\item The mean value $\\mu$, which is always set to be zero for\n      $d>0$ or need to be estimated.\n    \\item The error terms $Z_t$.\n\\end{enumerate}\n\n\\subsection{AR \\& MA Operators}\nThe  auto regression operator models the prediction for the next\nobservation  as some linear combination of the previous observations.\nMore formally, an AR operator of order $p$ is defined as\n\\begin{align}\n\\phi(B) Y_t= \\phi_1 Y_{t-1}   + \\dots +  \\phi_{p} Y_{t-p}\n\\end{align}\n\nThe moving average operator is similar, and it models the prediction\nfor the next observation as a linear combination of the errors in the\nprevious prediction errors.  More formally, the MA operator of order\n$q$ is defined as\n\\begin{align}\n\\theta(B) Z_t =   \\theta_{1} Z_{t-1} + \\dots + \\theta_{q} Z_{t-q}.\n\\end{align}\n\n\\section{Solving for the model parameters}\\label{sec:para_est}\n\n\\subsection{Least Squares}\\label{sec:CLS}\nWe assume that\n\\begin{equation}\n\\Pr(Z_t) = \\frac{1}{\\sqrt{2 \\pi \\sigma^2}} e^{-Z^2_t/2 \\sigma^2}, \\quad t > 0\n\\end{equation}\nand that  $Z_{-q+1} = Z_{-q+2} = \\dots = Z_0 = Z_1 = \\dots = Z_p =\n0$. The initial values of $Y_t=X_t-\\mu$ for $t=-p+1, -p+2, \\dots,\n0$ can be solved from the following linear equations\n\\begin{eqnarray}\n\\phi_1 Y_0 + \\phi_2 Y_{-1} + \\cdots + \\phi_p Y_{-p+1} &=& Y_1 \\nonumber\\\\\n\\phi_2 Y_0 + \\cdots + \\phi_p Y_{-p+2} &=& Y_2 - \\phi_1 Y_1  \\nonumber\\\\\n&\\vdots& \\nonumber\\\\\n\\phi_{p-1} Y_0 + \\phi_p Y_{-1} &=& Y_{p-1} - \\phi_1 Y_{p-2} - \\cdots -\n\\phi_{p-2} Y_1 \\nonumber \\\\\n\\phi_p Y_0  &=& Y_p - \\phi_1 Y_{p-1} - \\cdots - \\phi_{p-1} Y_{1} \\label{eq:init_Y}\n\\end{eqnarray}\n\nThe likelihood function $L$ for $N$ values of $Z_t$  is then\n\\begin{equation}\nL(\\phi, \\theta) = \\prod_{t = 1}^N  \\frac{1}{\\sqrt{2 \\pi \\sigma^2}} e^{-Z^2_t/2 \\sigma^2}\n\\end{equation}\nso the log likelihood function $l$ is\n\\begin{align}\nl(\\phi, \\theta) &= \\sum_{t = 1}^N \\ln \\left(\\frac{1}{\\sqrt{2 \\pi \\sigma^2}} e^{-Z^2_t/2 \\sigma^2}\n \\right) \\nonumber\\\\\n &=  \\sum_{t = 1}^N  - \\ln \\left( \\sqrt{2 \\pi \\sigma^2}\\right)  -\\frac{Z^2_t}{2 \\sigma^2}\\nonumber\\\\\n&=  -\\frac{N}{2} \\ln \\left( 2 \\pi \\sigma^2\\right)  - \\frac{1}{2\n  \\sigma^2} \\sum_{t = 1}^N   Z^2_t\\ . \\label{eq:loglikelihood}\n\\end{align}\nThus, finding the maximum likelihood is equivalent to solving the\noptimization problem (known as the conditional least squares\nformation)\n\\begin{align}\n\\min_{\\theta, \\phi} \\sum_{t = 1}^N  Z^2_t.\n\\end{align}\nThe error term $Z_t$ can be computed iteratively as follows:\n\\begin{align}\\label{equ:error terms}\nZ_t = X_t - F_t(\\phi, \\theta, \\mu)\n\\end{align}\nwhere\n\\begin{align}\nF_t(\\phi, \\theta, \\mu) = \\mu + \\sum_{i=1}^p \\phi_i (X_{t-i}-\\mu) + \\sum_{i=1}^q \\theta_i Z_{t-i}\n\\end{align}\n\n\\subsubsection{Levenberg-Marquardt Algorithm}\nIn mathematics and computing, the Levenberg-Marquardt algorithm (LMA),\nalso known as the damped least-squares (DLS) method, provides a\nnumerical solution to the problem of minimizing a function, generally\nnonlinear, over a space of parameters of the function. These\nminimization problems arise especially in least squares curve fitting\nand nonlinear programming.\n\n%Author's (Mark W) Note: This is taken from http://people.duke.edu/~hpgavin/ce281/lm.pdf\nTo understand the Levenberg-Marquardt algorithm, it helps to know the\ngradient descent method and the Gauss-Newton method.  On many\n``reasonable'' functions, the gradient descent method takes large\nsteps when the current iterate is distant from the true solution, but\nis slow to converge an the current iterate nears the true solution.\nThe Gauss-Newton method is much faster for converging when the current\niterate is in the neighborhood of the true solution.  The\nLevenberg-Marquardt algorithm tries to get the best of best worlds,\nand combine the gradient descent step with Gauss-Newton step in a\nweighted average.  For iterates far from the true solution, the step\nfavors the gradient descent step, but as the iterate approaches the\ntrue solution, the Gauss-Newton step dominates.\n\n%Author's (Mark W) Note: Sudo code taken from http://users.ics.forth.gr/~lourakis/levmar/levmar.pdf\nLike other numeric minimization algorithms, LMA is an iterative\nprocedure.  To start a minimization, the user has to provide an\ninitial guess for the parameter vector, $p$, as well as some tuning\nparameters $\\tau, \\epsilon_1, \\epsilon_2, \\epsilon_3,$ and $k_{max}$.\nLet $Z(p)$ be the vector of calculated errors ($Z_t$'s) for the\nparameter vector $p$, and let $J = (J_{1}, J_{2}, \\dots, J_N)^T$\nbe a Jacobian matrix.\n\nA proposed implementation is as follows:\n\\begin{algorithm}\n\\alginput{An initial guess for parameters $\\vec{\\phi}_0, \\vec{\\theta}_0, \\mu_0$}\n\\algoutput{The parameters that maximize the likelihood $\\vec{\\phi}^*,\n  \\vec{\\theta}^*, \\mu^*$}\n\\begin{algorithmic}[1]\n\t\\State $k \\leftarrow 0$  \\Comment{Iteration counter}\n\t\\State $v \\leftarrow 2$ \\Comment{The change in the weighting factor.}\n\t\\State $(\\vec{\\phi},\\vec{\\theta},\\mu) \\leftarrow (\\vec{\\phi}_0,\\vec{\\theta}_0,\\mu_0)$ \\Comment{Initialize parameter vector}\n\t\\State Calculate $Z(\\vec{\\phi},\\vec{\\theta},\\mu)$ with equation \\ref{equ:error terms}.  \\Comment{Vector of errors}\n\t\\State $A \\leftarrow J^T J$   \\Comment{The  Gauss-Newton Hessian approximation}\n\t\\State $u \\leftarrow \\tau * \\max_i(A_{ii})$ \\Comment{Weight of the gradient-descent step}\n\t\\State $g \\leftarrow J^T Z(\\vec{\\phi},\\vec{\\theta},\\mu)$ \\Comment{The gradient descent step.}\n\t\\State $ \\text{stop} \\leftarrow (\\|g\\|_{\\infty} \\le \\epsilon_1)$ \\Comment{Termination Variable}\n\t\\While{(not stop) and ($k < k_{max}$)}\n\t\t\\State $k \\leftarrow k + 1$\n\t\t\\Repeat\n\t\t\t\\State $\\delta \\leftarrow (A + u \\times \\text{diag}(A))^{-1} g$ \\Comment{Calculate step direction}\n\t\t\t\\If{$\\| \\delta \\| \\le \\epsilon_2 \\|\n              (\\vec{\\phi},\\vec{\\theta},\\mu) \\|$} \\Comment{Change in the parameters is too small to continue.}\n\t\t\t\t\\State  $\\text{stop} \\leftarrow \\text{true}$\n\t\t\t\\Else\n\t\t\t\t\\State $(\\vec{\\phi}_{new},\\vec{\\theta}_{new},\\mu_{new}) \\leftarrow (\\vec{\\phi},\\vec{\\theta},\\mu) + \\delta$ \\Comment{Take a trial step in the new direction}\n\t\t\t\t\\State $\\rho \\leftarrow (\\| Z(\\vec{\\phi},\\vec{\\theta},\\mu)\\|^2 - \\| Z(\\vec{\\phi}_{new},\\vec{\\theta}_{new},\\mu_{new})\\|^2 )/(\\delta^T(u \\delta + g))$ \\Comment{Calculate improvement of trial step}\n\t\t\t\t\\If{$\\rho > 0$} \\Comment{Trial step was good, proceed to next iteration}\n\t\t\t\t\t\\State $(\\vec{\\phi},\\vec{\\theta},\\mu) \\leftarrow (\\vec{\\phi}_{new},\\vec{\\theta}_{new},\\mu_{new})$ \\Comment{Update variables}\n\t\t\t\t\t\\State Calculate $Z(\\vec{\\phi},\\vec{\\theta},\\mu)$ with equation \\ref{equ:error terms}.\n\t\t\t\t\t\\State $A \\leftarrow J^T J$\n\t\t\t\t\t\\State $g \\leftarrow J^T Z(\\vec{\\phi},\\vec{\\theta},\\mu)$\n\t\t\t\t\t\\State $ \\text{stop} \\leftarrow (\\|g\\|_{\\infty} \\le \\epsilon_1)$ or $(\\| Z(\\vec{\\phi},\\vec{\\theta},\\mu)^2 \\| \\le \\epsilon_3)$  \\Comment{Terminate if we are close to the solution.}\n\t\t\t\t\t\\State $v \\leftarrow 2$\n\t\t\t\t\t\\State $u \\rightarrow u * \\max(1/3, 1 - (2\\rho - 1)^3 )$\n\t\t\t\t\\Else  \\Comment{Trial step was bad, change weighting on the gradient decent step}\n\t\t\t\t\t\\State $v \\leftarrow 2 v$\n\t\t\t\t\t\\State $u \\leftarrow u v$\n\t\t\t\t\\EndIf\n\t\t\t\\EndIf\n\t\t\\Until{(stop) or ($\\rho > 0$) }\n\t\\EndWhile\n\t\\State $(\\vec{\\phi}^*,\\vec{\\theta}^*,\\mu^*) \\leftarrow (\\vec{\\phi},\\vec{\\theta},\\mu)$\n\\end{algorithmic}\n\\label{alg: Levenberg-Marquardt}\n\\end{algorithm}\n\nSuggested values for the tuning parameters are $\\epsilon_1 = \\epsilon_2 = \\epsilon_3 = 10^{-15}, \\tau = 10^{-3}$ and $k_{max} = 100$.\n\\subsubsection{Partial Derivatives}\\label{sec:partial der}\nThe Jacobian matrix $J = (J_{1}, J_{2}, \\dots, J_N)^T$ requires the partial derivatives, which are\n\\begin{align}\nJ_t = (J_{t, \\phi_1}, \\dots, J_{t,\\phi_p}, J_{t,\\theta_1}, \\dots,\nJ_{t,\\theta_q}, J_{t,\\mu})^T\\ .\n\\end{align}\nHere the last term is present only when \\texttt{include\\_mean} is\n\\texttt{True}.\nThe iteration relations for $J$ are\n\\begin{align}\nJ_{t, \\phi_i} &= \\frac{\\partial F_t(\\phi,\\theta)}{\\partial \\phi_i} =\n-\\frac{\\partial Z_t}{\\partial \\phi_i} = X_{t-i}-\\mu + \\sum_{j=1}^q\n\\theta_j \\frac{\\partial Z_{t - j}}{\\partial \\phi_i} = X_{t-i}-\\mu - \\sum_{j=1}^q\n\\theta_j J_{t-j,\\phi_i}, \\\\\nJ_{t, \\theta_i}&=\\frac{\\partial F_t(\\phi,\\theta)}{\\partial \\theta_i} =\n-\\frac{\\partial Z_t}{\\partial \\theta_i} = Z_{t-i} + \\sum_{j =1}^q\n\\theta_j \\frac{\\partial Z_{t - j}}{\\partial \\theta_i} = Z_{t-i} -\n\\sum_{j=1}^q \\theta_j J_{t-j,\\theta_i}, \\\\\nJ_{t, \\mu} &=\\frac{\\partial F_t(\\phi,\\theta)}{\\partial \\mu} =\n-\\frac{\\partial Z_t}{\\partial \\mu} = 1 -\n\\sum_{j=1}^p \\phi_j - \\sum_{j=1}^q \\theta_j \\frac{\\partial\n  Z_{t-j}}{\\partial \\mu} = 1 - \\sum_{j=1}^p \\phi_j - \\sum_{j=1}^q\n\\theta_j J_{t-j,\\mu}.\n\\end{align}\nNote that the mean value $\\mu$ is considered separately in the above\nformulations. When \\texttt{include\\_mean} is set to \\texttt{False}, $\\mu$ will be simply\nset to 0. Otherwise, $\\mu$ will also be estimated together with\n$\\vec{\\phi}$ and $\\vec{\\theta}$. The initial conditions for the above\nequations are\n\\begin{equation}\nJ_{t,\\phi_i} = J_{t,\\theta_j} = J_{t,\\mu} = 0 \\quad \\mbox{for }\nt \\leq p, \\mbox{ and } i=1,\\dots,p; j = 1, \\dots, q\\ ,\n\\end{equation}\nbecause we have fixed $Z_t$ for $t\\leq p$ to be a constant $0$ in the initial\ncondition. Note that $J$ is zero not only for $t\\leq\n0$ but also for $t\\leq p$.\n\n\\subsection{Estimates of  Other Quantities}\nFinally the variance of the residuals is\n\\begin{equation}\n\\sigma^2 = \\frac{1}{N-p}\\sum_{t=1}^N Z_t^2\\ . \\label{eq:s2}\n\\end{equation}\nThe estimate for the maximized log-likelihood is\n\\begin{equation}\nl = -\\frac{N}{2}\\left[1 + \\log(2\\pi\\sigma^2)\\right]\\ , \\label{eq:loglik-R}\n\\end{equation}\nwhere $\\sigma^2$ uses the value in Eq. (\\ref{eq:s2}).\nActually if you put Eq. (\\ref{eq:s2}) into\nEq. (\\ref{eq:loglikelihood}), you will get a result slightly different\nfrom Eq. (\\ref{eq:loglik-R}). However, Eq. (\\ref{eq:loglik-R}) is what\nR uses for the method \\texttt{``CSS''}.\n\nThe standard error for coefficient $a$, where $a=\\phi_1,\\dots,\\phi_p,\\theta_1,\\dots,\\theta_q,\\mu$, is\n\\begin{equation}\n\\mbox{error}_a = \\sqrt{(H^{-1})_{aa}}\\ .\n\\end{equation}\nThe Hessian matrix is\n\\begin{equation}\nH_{ab} = \\frac{\\partial^2}{\\partial a \\partial b}\n\\left(\\frac{1}{2\\sigma^2}\\sum_{t=1}^N Z_t^2 \\right) =\n\\frac{1}{\\sigma^2}\\sum_{t=1}^N\n\\left(J_{t,a}J_{t,b} -\n  Z_t K_{t,ab} \\right) = \\frac{1}{\\sigma^2}\\left(\n  A - \\sum_{t=1}^N Z_t K_{t,ab}\\right)\\ ,\n\\end{equation}\nwhere $a,b=\\phi_1,\\dots,\\phi_p,\\theta_1,\\dots,\\theta_q,\\mu$,\n$\\sigma^2$ is given by Eq. (\\ref{eq:s2}), $A=J^TJ$ and\n\\begin{equation}\nK_{t,ab}=\\frac{\\partial J_{t,a}}{\\partial b} = - \\frac{\\partial^2\n  Z_t}{\\partial a \\partial b} \\ .\n\\end{equation}\nAnd\n\\begin{eqnarray}\nK_{t,\\phi_i\\phi_j} &=& -\\sum_{k=1}^q \\theta_k K_{t-k,\\phi_i\\phi_j} = 0\n\\nonumber\\\\\nK_{t,\\phi_i\\theta_j} &=& -J_{t-j,\\phi_i} - \\sum_{k=1}^q\\theta_k\nK_{t-k,\\phi_i\\theta_j} \\nonumber\\\\\nK_{t,\\phi_i\\mu} &=& -1 -\\sum_{k=1}^q\\theta_k\nK_{t-k,\\phi_i\\mu}\\nonumber \\\\\nK_{t,\\theta_i\\phi_j} &=& -J_{t-i,\\phi_j}-\\sum_{k=1}^q\\theta_k\nK_{t-k,\\theta_i\\phi_j} \\nonumber\\\\\nK_{t,\\theta_i\\theta_j} &=& -J_{t-i,\\theta_j} - J_{t-j,\\theta_i} -\n\\sum_{k=1}^q \\theta_k K_{t-k,\\theta_i\\theta_j} \\nonumber \\\\\nK_{t,\\theta_i\\mu} &=& -J_{t-i,\\mu} - \\sum_{k=1}^q\\theta_k\nK_{t-k,\\theta_i\\mu} \\nonumber\\\\\nK_{t,\\mu\\phi_j} &=& -1-\\sum_{k=1}^q \\theta_k K_{t-k,\\mu\\phi_j}\n\\nonumber \\\\\nK_{t,\\mu\\theta_j} &=& -J_{t-j,\\mu} -\\sum_{k=1}^q \\theta_k\nK_{t-k,\\mu\\theta_j} \\nonumber \\\\\nK_{t,\\mu\\mu} &=& - \\sum_{k=1}^q \\theta_k K_{t-k,\\mu\\mu} = 0\\ , \\label{eq:K}\n\\end{eqnarray}\nwhere the initial conditions are\n\\begin{equation}\nK_{t,ab} = 0\\quad \\mbox{for } t\\leq p, \\mbox{ and }\na,b=\\phi_1,\\dots,\\phi_p,\\theta_1,\\dots,\\theta_q,\\mu\\ . \\label{eq:K_init}\n\\end{equation}\nAccording to Eqs. (\\ref{eq:K},\\ref{eq:K_init}), $K_{t,\\phi_i\\phi_j}$ and\n$K_{t,\\mu\\mu}$ are always $0$.\n\nThe iteration equations Eq. (\\ref{eq:K}) are quite complicated. Maybe\nan easier way to compute $K$ is to numerically differentiate the\nfunction\n\\begin{equation}\nf(\\vec{\\phi},\\vec{\\theta},\\mu) = \\frac{1}{2\\sigma^2}\\sum_{t=1}^NZ_t^2\\ ,\n\\end{equation}\nwhere $Z_t$ values are computed using given coefficients of\n$\\vec{\\phi}$, $\\vec{\\theta}$ and $\\mu$.\nFor example,\n\\begin{eqnarray}\nH_{ab} &=&\n\\frac{1}{\\Delta}\\left[\\frac{f(a+\\Delta/2,b+\\Delta/2)-f(a-\\Delta/2,b+\\Delta/2)}{\\Delta}\n- \\right. \\nonumber\\\\\n& & \\left. \\frac{f(a+\\Delta/2,b-\\Delta/2) - f(a-\\Delta/2,b-\\Delta/2)}{\\Delta}\\right] \\mbox{ for } a\\neq b \\\n, \\\\\nH_{aa} &=& \\frac{f(a+\\Delta) - 2f(a) + f(a-\\Delta)}{\\Delta^2}\n\\end{eqnarray}\nwhere $\\Delta$ is a small number and the coefficients other than $a$\nand $b$ are ignored from the arguments of $f(\\cdot)$ for simplicity.\n\n\n\\subsubsection{Implementation}\nThe key of LMA is to compute Jacobian matrix $J$ in each iteration. In order to compute $J$, we need to compute $Z_t$ for $t=1,\\dots,N$ in a recursive manner. The difficulty here is how to leverage the parallel capability of MPP databases. By carefully distributing the dataset to the segment nodes - distribute time servies data by the time range,  the recursive computation can be done in parallel via approximation. It's also necessary here to utilize the window function for the recursive computation.\n\n\\subsection{Exact Maximum Likelihood Calculation}\n\n\n%\\subsection{Unconditional Least Squares}\n\n\\section{Solving for the optimal model}\\label{sec:model_opt}\n\n\\subsection{Auto-Correlation Function}\nNote that there several common definitions of the auto-correlation function.  This implementation uses the normalized form.\n\nThe auto-correlation function  is a cross-correlation of a function (or time-series) with itself, and is typically used to find periodic behavior in a time-series.  For a real, discrete time series, the auto-correlation  $R(k)$ for lag $k$ of a time series $X$ with $N$ data points  is\n\\begin{align}\\label{equ:auto corr}\nR_X(k) =\\sum_{t=k+1}^N  \\frac{(x_t -\\mu) (x_{t-k} - \\mu)}{N \\sigma^2} .\n\\end{align}\nwhere $\\sigma^2$ and $\\mu$ are the variance and mean of the time series respectively.\nFor this implementation, the range of desired $k$ values will be small ($\\approx 10\\log(N)$ ), and the auto-correlation function for the range can be computed naively with equation \\ref{equ:auto corr}.\n\n\\subsection{Partial Auto-Correlation Function}\n%Author's note: this material is taken from http://sfb649.wiwi.hu-berlin.de/fedc_homepage/xplore/tutorials/sfehtmlnode59.html\n%Some definitions are also from http://sfb649.wiwi.hu-berlin.de/fedc_homepage/xplore/tutorials/sfehtmlnode48.html\nThe partial auto-correlation function is a conceptually simple extension to the auto-correlation function, but greatly increases the complexity of the calculations.  The partial auto-correlation is the correlation for lag $k$ after all correlations from lags $<k$ have been accounted for.\n\nLet\n\\begin{align}\nR_{(k)} \\equiv  \\left[ R_X(1), R_X(2), \\dots, R_X(k)\\right]^T\n\\end{align}\nand let\n\\begin{align}\nP_k = \\left[ \\begin{matrix}\n1 &  R_X(1) & \\dots & R_X(k-1) \\\\\nR_X(1) & 1 & \\dots & R_X(k-2) \\\\\n\\vdots & \\vdots & \\ddots & \\vdots \\\\\nR_X(k-1) &R_X(k-2) & \\dots & 1 \\end{matrix} \\right]\n\\end{align}\n\nThen the partial auto-correlation function $\\Phi(k)$ for lag $k$ is\n\\begin{align}\n\\Phi(k) = \\frac{ \\det P^*_k}{\\det P_k}\n\\end{align}\nwhere $P^*_k$ is equal to the matrix $P_k$, except the $k$th column is replaced with $R_{(k)}$.\n\n\\subsection{Automatic Model Selection}\n\n\\section{Seasonal Models}", "meta": {"hexsha": "b70c478cecc118fe0fd22d3dcdecf39dc1f63b6f", "size": 16363, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/design/modules/ARIMA.tex", "max_stars_repo_name": "fmcquillan99/apache-madlib", "max_stars_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-01T17:58:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-01T17:58:05.000Z", "max_issues_repo_path": "doc/design/modules/ARIMA.tex", "max_issues_repo_name": "fmcquillan99/apache-madlib", "max_issues_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-09-06T05:50:17.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-06T05:50:17.000Z", "max_forks_repo_path": "doc/design/modules/ARIMA.tex", "max_forks_repo_name": "fmcquillan99/apache-madlib", "max_forks_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-03T20:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-03T20:50:13.000Z", "avg_line_length": 47.8450292398, "max_line_length": 505, "alphanum_fraction": 0.6803153456, "num_tokens": 5798, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.44190906985450384}}
{"text": "%s How the representative set is computed; pruning strategies and verification\n%step goes here.\n\n\\section{Computing Representative Sets} \n\\label{sec:representative}\nRepresentative vertex $v$ of a pattern\nvertex $u$ implies that there exists an isomorphism $\\phi$ for which $\\phi(u) =\nv$.  One way to interpret it is that the neighborhood of $u$ matches with that\nof $v$.  By comparing the neighborhoods we can find vertices that are not valid\nrepresentatives of $u$ without trying to find an isomorphism exhaustively.\nTherefore, to compute the representative sets we will start with a candidate\nrepresentative set denoted by \\CR  and iteratively prune some of the vertices if\nthe neighborhoods cannot be matched.  The candidate set is a super set of the\nrepresentative set, $\\CR \\supseteq \\RS$.  An example of candidate set, $ \\CR =\n\\{v| v \\in \\vg, \\labcost{C}{L(u)}{L(v)} \\leq \\alpha \\}$ i.e., the isomorphisms of\nthe single vertex pattern with label $L(u)$.  In this section, we will describe\ndifferent notions of neighborhood and show how they help us in computing the\nrepresentative sets of vertices in a pattern.\n\nThe problem of checking whether a vertex $v \\in R(u)$ involves solving\nisomorphism is atleast as hard finding unlabeled subgraph isomorphism.\nTherefore, checking if a vertex is a valid representative is an\nNP Hard problem. The pruning methods typically do not\nprune all the invalid vertices.  So, we use an exhaustive enumeration method to\nprune these invalid vertices and reduce \\CR to \\RS.\n\n \\subsection{\\khop Label}\n \\label{sec:khop}\n %Neighbors of a vertex in a graph denotes the set of vertices that are\n %reachable via a single edge. \n \\khop label is defined as the set of vertices that are reachable via a simple\n path of length $k$.  In other words, k-hop label contains all vertices that are\n reachable in k-hops starting from $u$ and by visiting each vertex at most once.\n Note that, we use the word label even though we refer to a set of vertices.\n Formally, the \\khop label of a vertex $u$ in graph $G$, $\\khopl{k}{u,G} = \\{v |\n v \\in G, \\kpath{u}{v}{k}\\}$.  We simply write it as $\\khopl{k}{u}$ when the\n graph is evident from the context.  For example, for pattern $P$ in\n Fig.~\\ref{subfig:pattern}, the $0$-hop label of vertex $5$ is $h_0(5) = \\{5\\}$,\n its $1$-hop label is the multiset $h_1(5) = 2, 4, 6$ (we omit the set notation\n for convenience) and its $2$-hop label $h_2(5) = 1, 3$. The minimum cost of\n matching \\khop labels $\\khopl{k}{u}$ and $\\khopl{k}{v}$ is \n\n \\begin{equation} \\label{eq:khop} \\khopcost{k}{u}{v} =\n     \\text{min}\\displaystyle\\sum_{u' \\in \\khopl{k}{u}}\n     \\labcost{C}{L(u')}{L(f(u'))} \\end{equation}\n\n where the minimization is over all injective functions $f\\!\\!:\\khopl{k}{u}\n \\rightarrow \\khopl{k}{v}$ and $\\labcost{C}{L(u')}{L(f(u'))}$ is the cost of\n matching the vertex labels.  In other words, it is the minimum total cost of\n matching the vertices present in the k-hop labels.  The following theorem\n places an upper bound on the minimum cost of matching the k-hop labels of\n a pattern vertex and any of its representative vertices.\n\n\n\\begin{thm} \n\\label{thm:khop}\nGiven any pattern vertex $u$, a representative vertex $v \\in R(u)$\n    and cost threshold $\\alpha$, the minimum cost of matching the \\khop labels,\n    $\\khopcost{k}{u}{v} \\leq \\alpha$ for all $k \\geq 0$.\n\n\\begin{myproof} Consider any isomorphism $\\phi$ such that $\\phi(u) = v$. It is\n    enough if we can show an injective function $f\\!\\!:\\khopl{k}{u} \\rightarrow\n    \\khopl{k}{v}$ with a cost ( as defined in equation \\ref{eq:khop}) $\\leq\n    \\alpha$. We will argue that the function $\\phi$ on the restricted domain\n    $\\khopl{k}{u}$ is one such function $f$.  First, we know that\n    $\\sum\\labcost{C}{L(u)}{\\phi(L(u)} \\leq \\alpha$, $u \\in \\vp$, since $\\phi$ is\n    an isomorphism. Second, let $\\kpath{u}{u'}{k}$ then $\\phi(u') \\in\n    \\khopl{k}{v}$ because for every edge $(u_1, u_2)$ on a path between $u$ and\n    $u'$ in $\\pat$, $(\\phi(u_1),\\phi(u_2)) \\in \\eg$.  Therefore the cost\n    of matching the \\khop labels using $\\phi$ is  upper bounded by $\\alpha$.  Hence,\n    the minimum cost of matching $\\khopcost{u}{v} \\leq \\alpha$.\n    \\end{myproof}\n    \\label{thm:khop} \\end{thm}\n\nBased on the above theorem, a vertex $v$ is not a representative vertex of $u$\nif $\\khopcost{k}{u}{v} > \\alpha$ for any $k \\geq 0$. However, in practice, it\nenough to check the condition only for $k \\leq |V_P|-1$ because $\\khopl{k}{u}$\nis the null set $\\forall k \\geq |V_P|$ and the condition is trivially satisfied.\n\nFigure~\\ref{fig:ncexample} shows an example for the \\khop label based pruning of\nthe candidate representative set where the threshold $\\alpha = 0.5$. Consider\nvertex $2 \\in \\vp$ and vertex $20 \\in \\vg$, we have, $\\khopcost{0}{2}{20} = 0$,\nsince the cost of matching vertex labels $\\labcost{C}{L(2)}{L(20)} = 0$ , as per\nthe label matching matrix $C$ in Fig.~\\ref{subfig:match}. The \\khop labels for\n$k=1,2,3$ and the minimum of cost matching them are as shown in the table\n\\ref{tab:khop220}, and it can be verified that the minimum cost is within the\nthreshold $\\alpha$.\n\nThus far, we cannot prune node $20$ from $R(2)$.  However, $\\khopl{4}{2} = 4, 6\n$ and $\\khopl{4}{20} = 30, 60$ and the minimum cost of matching them is $0.6 >\n\\alpha$.  Thus, from theorem \\ref{thm:khop} we conclude that $20 \\notin R(2)$. This example illustrates\nthat \\khop labels can help prune the candidate representative sets.\n\n\n% Example for showing the incremental updates of the labels\n\\begin{figure}[!ht]\n\\captionsetup[subfloat]{captionskip=15pt}\n  \\centering\n  \\subfloat[Pattern $P$]{\n    \\label{subfig:pattern}\n\t\\scalebox{0.9}{\n    % # 3 vertices and 2 edge pattern\n    \\begin{pspicture}(0,0)(4,3)\n    \\cnodeput[linecolor=black](0,2) {n1} {A}\n    \\cnodeput[linecolor=black](0,1) {n2} {C}\n    \\cnodeput[linecolor=black](1,0) {n3} {B}\n    \\cnodeput[linecolor=black](2,2) {n4} {C}\n    \\cnodeput[linecolor=black](2,1) {n5} {A}\n    \\cnodeput[linecolor=black](2,0) {n6} {D}\n    %% Draw the edges of the pattern\n  \\ncline{-}{n1}{n2}\n  \\ncline{-}{n2}{n3}\n  \\ncline{-}{n3}{n4}\n  \\ncline{-}{n2}{n5}\n  \\ncline{-}{n4}{n5}\n  \\ncline{-}{n5}{n6}\n  \\ncline{-}{n3}{n6}\n    \\uput{.3cm}[90](n1){ {1} }\n    \\uput{.3cm}[180](n2){ {2} }\n    \\uput{.3cm}[270](n3){ {3} }\n    \\uput{.3cm}[90](n4){ {4} }\n    \\uput{.3cm}[0](n5){ {5} }\n    \\uput{.3cm}[270](n6){ {6} }\n    \\end{pspicture}\n\t} }\n  \\subfloat[Database Graph $G$]{\n    \\label{subfig:database}\n\t\\scalebox{0.9}{\n    \\begin{pspicture}(0,0)(2.5,2.5)\n    \\cnodeput[linecolor=black](0,2) {N1} {A}\n    \\cnodeput[linecolor=black](0,1) {N2} {C}\n    \\cnodeput[linecolor=black](0,0) {N3} {D}\n    \\cnodeput[linecolor=black](1,2) {N4} {B}\n    \\cnodeput[linecolor=black](2.25,1) {N5} {B}\n    \\cnodeput[linecolor=black](2,0) {N6} {A}\n    % vertex ids\n    \\uput{.3cm}[90](N1){ {10} }\n    \\uput{.3cm}[180](N2){ {20} }\n    \\uput{.3cm}[270](N3){ {30} }\n    \\uput{.3cm}[90](N4){ {40} }\n    \\uput{.3cm}[0](N5){ {50} }\n    \\uput{.3cm}[270](N6){ {60} }\n    % edges in the database\n  \\ncline{-}{N1}{N2}\n  \\ncline{-}{N2}{N3}\n  \\ncline{-}{N4}{N5}\n  \\ncline{-}{N5}{N6}\n  \\ncline{-}{N3}{N4}\n  \\ncline{-}{N2}{N5}\n  \\ncline{-}{N2}{N6}\n    \\end{pspicture}\n\t} }\n  \\newline\n\\captionsetup[subfloat]{captionskip=5pt}\n\\subfloat[Cost Matrix]{\n  \\label{subfig:match}\n  % Table for the search space pruning\n  \\begin{tabular}{|c|c|c|c|c|}\n    \\hline\n    \\costmat{C} & A &  B & C & D \\\\\n    \\hline\n    A & 0 & 0.7 & 0.6 & 0.1\\\\\n    \\hline\n    B & 0.7 & 0 & 0.3 & 1\\\\\n    \\hline\n    C & 0.6 & 0.3 & 0 & 0.8\\\\\n    \\hline\n    D & 0.1 & 1 & 0.8 & 0\\\\\n    \\hline\n  \\end{tabular}\n  } \n  \\caption{Pattern \\protect\\subref{subfig:pattern}, \n  database graph \\protect\\subref{subfig:database}, and cost\n  matrix \\protect\\subref{subfig:match}.\n  } \n  \\label{fig:ncexample}\n\\end{figure}\n\n\\begin{table}[h]\n    \\centering\n    \\begin{tabular}{|c|c|c|c|}\n        \\hline\n        k & $\\khopl{k}{2}$ & $\\khopl{k}{20}$ & $\\khopcost{k}{2}{20}$\\\\\n        \\hline\n        1 & 1, 3, 5 & 10, 30, 50, 60 & 0 \\\\\n        2 & 4, 6 & 40, 50, 60 & 0.4 \\\\\n        3 & 3, 5 & 40, 30, 50 & 0.1\\\\\n        \\hline\n    \\end{tabular}\n    \\caption{\\khop label of vertices $2$ and $20$}\n    \\label{tab:khop220}\n\\end{table}\n\n\\begin{table}[h]\n    \\centering\n    \\begin{tabular}{|c|c|c|c|}\n        \\hline\n        k & $h_k(3)$ & $h_k(50)$ & $\\khopcost{k}{3}{50}$ \\\\\n        \\hline\n        0 & 3 & 50 & $0$\\\\\n        1 & 2, 4, 6 & 20, 40, 60 & $0.4$ \\\\\n        2 & 1, 5 & 10, 20 , 30, 60 & 0\\\\\n        3 & 2, 4, 6 & 10, 20, 30, 40 & $0.3$ \\\\\n        4 & $1$ & $10, 40, 60$ & $0$ \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{\\khop labels of vertices $3$ and $50$.}\n    \\label{tab:khop350}\n\\end{table}\n\n\n\n\\subsection{Neighbor Concatenated Label} In Neighbor concatenated label (\\ncl) ,\nthe information regarding the candidates of a neighbor that were pruned in the\nprevious iteration is used along with the current \\khop label to prune\ncandidates in the current iteration. In contrast, the \\khop label pruning\nstrategy for a vertex $u$ works independently of the result of \\khop label\npruning of other vertices in the pattern. This leads us to the following\nrecursive formulation for \\ncl.\n\nThe \\ncl of a vertex in the ${k+1}^{th}$ iteration, $\\nclab{k+1}{u}$, is defined\nas the tuple $(\\{\\nclab{k}{u'} | u' \\in N(u)\\},\\xspace \\khopl{k+1}{u})$.  The\nfirst element(A) of the tuple is the set of \\ncl of the neighbors of the vertex $u$ in\nthe previous iteration($k$) and the second element(B) is exactly same as the (k+1)-hop\nlabel defined in the section \\ref{sec:khop}. We say that $\\nclab{k+1}{u}$ dominated by\n$\\nclab{k+1}{v}$, denoted by $\\nclab{k+1}{u} = (A, B) \\preceq \\nclab{k+1}{v} =\n(A', B') $, i) iff $\\khopcost{k+1}{B}{B'} \\leq \\alpha$ i.e., the minimum cost of\nmatching the (k+1)-hop labels is within $\\alpha$ ii) there exits an injective\nfunction $g\\!\\!:A\\rightarrow A'$ such that $a \\preceq g(a)$ for all $a \\in A$\ni.e., there is a one to one mapping between the \\ncl labels (of the previous\niteration, $k$) of neighbors of $u$ and $v$.  The base case $\\nclab{0}{u}\n\\preceq \\nclab{0}{v}$ iff $\\labcost{C}{L(u)}{L(v)} \\leq \\alpha$. For example, in\nFig~\\ref{fig:ncexample} $\\nclab{1}{2} \\preceq \\nclab{1}{20}$ because\n$\\khopcost{1}{2}{20} \\leq \\alpha$ and the \\ncl labels of vertices $1, 3, 5$ are\ndominated by the \\ncl labels of vertices $10, 50, 30$ respectively.  The\nfollowing theorem states that the \\ncl of a pattern vertex $u$ is dominated by\nthe \\ncl of any of its representative vertex $v \\in  R(u)$.\n\n\\begin{thm} Given any pattern vertex $u$, a representative vertex $v \\in R(u)$\n    and cost threshold $\\alpha$, $\\nclab{k}{u} \\preceq \\nclab{k}{v}$ for all $k\n    \\geq 0$.  \\begin{myproof} Let $\\phi$ be any isomorphism such that $\\phi(u) =\n        v$.  We prove the theorem by using induction on $k$.\\\\ \\textbf{Base\n        case:} $\\nclab{0}{u} \\preceq \\nclab{0}{v} \\iff \\labcost{C}{L(u)}{L(v)}\n        \\leq \\alpha$ is true because $v \\in R(u)$. \\\\ \\textbf{Inductive\n        Hypothesis:} Assume that $\\nclab{k}{u} \\preceq \\nclab{k}{v}$ holds true\n        for all $u \\in \\pat$ and $v \\in R(u)$. \\\\ Now consider $\\nclab{k+1}{u} =\n        (A, B)$  and $ \\nclab{k+1}{v} = (A', B') $, from theorem \\ref{thm:khop}\n        we know that $\\mathcal{C}[B][B'] \\leq \\alpha$, for all $k \\geq 0$.\n        Let $u' \\in N(u)$ and $v' = \\phi(u')$. From inductive hypothesis, \n\t$\\nclab{k}{u'} \\preceq \\nclab{k}{v'}$. Also, $v' \\in N(v)$ because\n\t$(u, u') \\in \\ep \\implies (\\phi(u)=v, \\phi(u')=v') \\in \\eg$.\n        Therefore,\n        the injective function $\\phi$ maps the elements $a \\in A$ to $\\phi(a)\n        \\in A'$.  The theorem follows from the definition of the NL label.\n    \\end{myproof} \\label{thm:ncl} \\end{thm}\n\nBased on the above theorem, a vertex $v$ can be pruned from \\CR if $\\nclab{k}{u}\n\\not\\preceq \\nclab{k}{v}$ for some $k \\geq 0$. In Fig~\\ref{fig:ncexample} ,\nconsider the vertices $3 \\in \\pat$ , $50 \\in \\db$ and let $\\alpha = 0.5$. The\n\\ncl labels, $\\nclab{0}{3} \\preceq \\nclab{0}{50}$ as $\\labcost{C}{B}{B} = 0 \\leq\n\\alpha$.  Similarly it is also true for the pairs $(2, 20)$, $(4, 40)$ etc. It\nfollows that $\\nclab{1}{3} \\preceq \\nclab{1}{50}$ as the neighbors $2, 4, 6$ can\nbe mapped to $20, 40, 60$ respectively and  the minimum cost of the matching the\n$1$-hop label is $0.4$ which is less than the $\\alpha$ threshold. But\n$\\nclab{2}{3} \\not\\preceq \\nclab{2}{50}$ because the \\ncl label $\\nclab{1}{6}$\nis not dominated by the \\ncl label of $20, 40$ or  $60$ in the first\niteration . So, there is no mapping between the neighbors of vertices $3$ and\n$50$ in the second iteration. Hence, $50 \\notin R(3)$.\nNote that using the \\khop label in\nthe same example will not prune the vertex $50$ because the minimum cost of\nmatching the \\khop labels is within $\\alpha$ as shown in table\n\\ref{tab:khop350}. Therefore, \\ncl label is more efficient compared to \\khop\nlabel as it subsumes the latter label.\n\n\\subsection{Candidate set verification} \\label{sec:verification} The pruning\nmethods based on the \\khop and the \\ncl labels start with a \\CR and prune some\nof the candidate vertices based on the conditions described in theorems\n\\ref{thm:khop} and \\ref{thm:ncl}.  The verification step reduces \\CR to \\RS by\nretaining only those vertices $v$ for which there exists an isomorphism $\\phi$ in\nwhich $\\phi(u) = v$.  Informally, it does this by checking if the pattern $P$ can be\nembedded at $v$ such that total cost of label mismatch is at most $\\alpha$.\n\nA vertex $v \\in R(u)$ iff for any walk $w_p = (u_0=u), u_1,\\ldots,u_m$ that covers all\nthe edges in pattern $P$ there exists atleast one walk $w_d = (v_0=v), v_1,\\ldots,\nv_m$ in the database $G$ and satisfying the following three conditions: i) \n$u_i = u_j \\implies v_i = v_j$ ii) $(v_i, v_{i+1}) \\in \\eg$\niii) $\\sum\\labcost{C}{L(u_i)}{L(v_i)} \\leq \\alpha$.\nUnlike the \\ncl label condition, the above conditions are necessary and\nsufficient and can be verified by following the definition of isomorphism.\n\nNow, to check whether $v \\in R(u)$, we first map $u$ to $v$ and subtract the cost of\n$\\labcost{C}{L(u)}{L(v)}$ from the threshold $\\alpha$. We then try to map the\nremaining vertices in $P$ by following $w_p$ one edge at a time. In any step\n$(u_i, u_{i+1})$, if $u_i$ and $u_{i+1}$ are mapped to $x$ and $y$ respectively\nthen we ensure that $(x, y) \\in \\eg$\n(condition ii). If on the other hand, $u_{i+1}$ is not mapped then we map it\nto some vertex in $y \\in R'(u_{i+1})$ and subtract the cost\n$\\labcost{C}{L(u_{i+1})}{L(y)}$ from the remaining $\\alpha$ threshold. We back\ntrack if the remaining threshold is less than $0$. The vertex $v \\in R(u)$, if we\ncan complete the walk $w_p$ satisfying the above three conditions.\n\nConsider checking whether the vertex $30 \\in R(1)$ \nin the pattern in the figure~\\ref{subfig:ex_sub} and let $\\alpha = 0.5$. The\nsequence $w_p = 1, 2, 4, 3, 1$ is a walk in the pattern that covers all the edges.\nIn general, finding a walk that covers all the edges in a graph is a special\ncase of Chinese postman problem \\cite{chinesepostman}. We first map $1$ to $30$\nan subtract the cost $\\labcost{C}{L(1)}{L(30)} = 0.2$ from $0.5$. In the first\nstep $(1,2)$, since $2$ is not mapped we map it some vertex, say $20$. The cost\nof the mapping is $0.2$ and the remaining threshold is $0.3 -0.2 = 0.1$. It can\nbe verified that these mappings cannot complete the walk $w_p$. So we backtrack \nand map $2$ to another vertex say $10$. The walk can be completed with the\nmappings as in $\\phi_1$ in Table~\\ref{subfig:ex_occur} and the remaining cost is \n$0.1$. The mappings of the pattern vertices not only implies that $30 \\in R(1)$,\nit also tells us that $10, 60, 40$ represent vertices $2, 3, 4$ respectively.\nThe above procedure can be easily extended to enumerate all the isomorphims of the\npattern.\n\n\n\n\\subsection{Label costs and dominance checking} \\label{sec:labelcheck} \nCandidate representative vertices are pruned by checking for dominance \nrelation between the \\ncl labels of pattern vertex and that of candidate\nvertex in the database. Comparing the \\ncl labels requires i) computing the\ncost of matching the \\khop labels ii) matching the neighbors of pattern vertex \nwith neighbors of the candidate vertex. First problem can be formulated\nas a minimum cost maximum flow in a network and the second as maximum matching\nin a bipartite graph.\n\n\\medskip{\\textit{Computing \\khop label cost}:} The minimum cost of matching the\n\\khop labels $\\khopl{k}{u}$ and $\\khopl{k}{v}$ is equal to\nminimum cost for maximum cost in a flow network $F$ defined as follows.  Each\nedge in $F$ is associated with a maximum capacity and a cost for sending one\nunit of flow across it.  The network contains a vertex for each label $l_u =\nL(u')$ where $u' \\in h_k(u)$ and a vertex for each label $l_v = L(v')$ where $v'\n\\in h_k(v)$. There is a directed between between source vertex ($s$) and each\n$l_u$ with zero cost and a capacity equal to the multiplicity of the $l_u$\ni.e., the number of vertices in $h_k(u)$ that have the label $l_u$. Similarly\nthere is a directed edge between $l_v$ and the sink node ($t$). In addition,\nthere is a directed edge from $l_u$ to $l_v$ with a cost\nequal to $\\labcost{C}{l_u}{l_v}$ and a capacity equal to the\nmultiplicity of $l_u$. The cost between the \\khop labels is equal to\nthe minimum cost for maximum flow if the maximum flow is equal to\n$|\\khopl{k}{u}|$ and $\\infty$ otherwise.\n\\\\ Figure~\\ref{fig:Hflow} shows the\nflow network required to compute the minimum cost of matching the \\khop labels\n$\\khopl{2}{2} = 4,6 $ and $\\khopl{2}{20} = 40, 50, 60$ as shown in Table\n\\ref{tab:khop220}. The labels of vertices in the \\khop labels are $C,D$ and $B,\nB, A$ respectively. \nThere is an edge from $s$ to each of $C, D$ with zero cost\nand maximum capacity of one.  Similarly, there is an edge from each of $A, B$ to\nthe sink vertex $t$ with zero cost and maximum capacity of one and two\nrespectively. The capacity of the edge betweenn $B$ and $t$ is two because \nboth the vertices $40$ and $50$ have the same label $B$.\nThere is an edge from $C, D$ to each of $A, B$ with cost equal to\nthe corresponding entry in the cost matrix $C$. The maximum flow in the network\nis two and the minimum cost of sending two units of flow $0.4$ is achieved by\npushing a unit flow along the paths $s, C, B, t$ and $a, D, A, t$.  Therefore,\nthe cost of matching the labels $\\khopl{2}{2}$ and $\\khopl{2}{20}$ is $0.4$. It\nimplies that the vertex $4$ with label $C$ can be matched to either $40$ or $50$\nand the vertex $6$ to $60$.\n\n\\medskip{\\textit{Dominance check}: } Consider the \n\\ncl labels $\\nclab{k+1}{u} = (A, B)$ and  $\\nclab{k+1}{v} = (A', B')$, the cost of \nmatching the \\khop labels\n$B$ and $B'$ can be computed using the above the network formulation.\nFinding an injective function $f\\!\\!:A \\rightarrow A'$ such that $a \\preceq\nf(a)$ , is equivalent to find a matching of size $|N(u)|$ in the bipartite graph\nwith edges $(a, a')$, for all $a \\in A$ and $a \\preceq a'$.\nThe \\ncl label $\\nclab{k}{u}$ is therefore dominated by $\\nclab{k}{v}$ if the\ncost between the \\khop labels is within $\\alpha$ and the size of maximum\nbipartite matching is $|N(u)|$.\n\n\\medskip{\\textit{Optimization}: } The candidate pattern may contain groups of\nsymmetric vertices that are indistinguishable with respect to the \\khop label.\nIn such a scenario, the candidate representative sets of all these vertices are\nexactly the same. Utilizing the symmetry, we can apply the pruning label strategy only on\none vertex per symmetry group and replicate the results for all other vertices\nin the group. For example, the vertices $1$ and $4$ in\nfigure~\\ref{subfig:ex_sub} are symmetric and the representative sets $R(1)$\nand $R(4)$ are exactly the same.  In abstract algebra terms such  groups are\ncalled orbits of the graph and can be computed using nauty algorithm\n\\cite{nauty}. \nEven\nthough computing the orbits is expensive, we can avoid $ (|g|-1) \\times |\\CR|$\n\\ncl label cost computations where $g$ is the size of an orbit. Note that\nwe find the orbits only for the pattern which is usually very small compared\nto the database graph.\n%Note that the payoff is zero if all the vertex orbits are of size $1$.\n\n\\subsection{Precomputing database \\khop labels} The \\khop label of a database\nvertex is independent of the candidate pattern.\nAlso, the flow network to compute the cost of matching the \\khop labels requires\nonly the aggregate information about the multiplicity of the vertex label in the\n\\khop label.\nHence, we can precompute the \\khop label of the database vertices and store them\nin the memory. The following theorem proves that computing \\khop label is\nexpensive.\n\n\\begin{thm} k-reachable (KR) : Given a graph $G$, $k$ and $u \\in \\vg$. Compute\n    $\\khopl{k}{u}$.  KR cannot be solved in polynomial time unless $P =\n    NP$.\n\n\\begin{myproof} We prove this by reducing Hamiltonian path (HP) to KR.\n    Hamiltonian Path : Given a graph $G$, is there a simple path of length\n    $|\\vg|-1$ i.e. is there a path that visits each and every vertex exactly\n    once. The problem of finding a Hamiltonian path is \n    NP-Complete \\cite{npcomplete}.\\\\ Assume that algorithm $X(k)$ can\n    compute KR in polynomial time. Let $|\\vg| = n$ and $u$ be the starting\n    vertex in HP if it exists.  Given an instance of HP, we first get a vertex\n    $v$, $\\kpath{u}{v}{n-1}$ using $X(n-1)$. The vertex $v$ is removed from the\n    graph and we find a vertex $v'$ such that $\\kpath{u}{v'}{n-2}$ and $(v', v)\n    \\in \\eg$. We repeat this process $n-1$ times. If at any stage $X(j) = \\{\\}$\n    then we restart from a different starting vertex. The vertices selected in\n    each iteration lie on a path of length $n-1$ if it exists. If there is\n    polynomial time algorithm for KR then HP could be solved in polynomial time\n    by reducing it to KR. Therefore, $KR$ is atleast as hard as $HP$.\n    So, KR cannot be solved in polynomial time unless\n    P = NP.\n\\end{myproof}\n\\end{thm}\n\nTo compute \\khop label of a vertex $u$, we check for each vertex $v$ whether $v\n\\in \\kpath{u}{v}{k}$ by enumerating all possible $k$ length paths until a path\nis found.  This procedure is exponential, we therefore fix a maximum value\n$k_{max}$ and use the \\ncl label based pruning only for values of $k \\leq\nk_{max}$.  It only takes a couple of minutes to compute the \\khop label for $k\n\\leq 6$ for all the vertices in the database graph. This is significantly less\nthan the overall run time of the algorithm. Once $\\khopl{k}{u}$ is computed we\nstore in memory only the tuples $(l, m)$ where $m$ is the multiplicity of the label \n$l = L(u')$.\nThe total amount of main memory required to store\nthe precomputed \\khop labels is O($|\\vg| \\times |\\Sigma| \\times k_{max}$).\n\n\n\n\n\\begin{figure}[!h]\n    \\centering\n\\scalebox{0.6}[0.6]{\n  \\psset{unit=0.85in}\n  \\newcommand\\arc[4]{\\ncline{#1}{#2}{#3}\\ncput{\\colorbox{gray!40}{#4}}}\n      \\begin{pspicture}(0,1)(5,3)\n        \\cnodeput[doubleline=true](1,2){src}{s}\n        \\cnodeput(2,1){n1}{C}\n        \\cnodeput(2,3){n2}{D}\n        \\cnodeput[doubleline=true](5,2){sink}{t}\n        \\cnodeput(4,1){n4}{B}\n        \\cnodeput(4,3){n5}{A}\n        \\arc{->}{src}{n1}{$1,0$}\n        \\arc{->}{src}{n2}{$1,0$}\n        %\\arc{->}{n1}{n4}{$1$}\n        \\ncline{->}{n1}{n4}\\ncput[npos=0.5]{\\colorbox{gray!40}{$1,0.1$}}\n        \\ncline{->}{n1}{n5}\\ncput[npos=0.3]{\\colorbox{gray!40}{$1,1$}}\n        \\ncline{->}{n2}{n4}\\ncput[npos=0.3]{\\colorbox{gray!40}{$1,0.6$}}\n        \\ncline{->}{n2}{n5}\\ncput[npos=0.5]{\\colorbox{gray!40}{$1,0.3$}}\n        \\arc{->}{n4}{sink}{$2,0$}\n        \\arc{->}{n5}{sink}{$1,0$}\n        %\\arc{->}{n6}{sink}{$1$}\n      \\end{pspicture}\n    }\n    \\caption{Flow network for \\khopl{2}{2} and \\khopl{2}{20}}\n\t\\label{fig:Hflow}\n\\end{figure}\n", "meta": {"hexsha": "6dc102833f38c47c85ea9a2bf351307dcf2fbd00", "size": 23711, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "finalversion/sigkdd13/representative.tex", "max_stars_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_stars_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "finalversion/sigkdd13/representative.tex", "max_issues_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_issues_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "finalversion/sigkdd13/representative.tex", "max_forks_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_forks_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-08T11:17:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-08T11:17:33.000Z", "avg_line_length": 51.1012931034, "max_line_length": 103, "alphanum_fraction": 0.6682974147, "num_tokens": 8039, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.44190906210493053}}
{"text": "\\section{Conventional Feature Extraction Methods}\nResearchers in this field of study often use a combination of features in the detection of informal settlements. Our research uses features that performed well in previous research;  the Histogram of Oriented Gradients (HoG) and Line Support Region (LSR) features. Both HoG and LSR are implemented in a Python library, called \\textit{Spfeas}, which is based on the research of Graesser \\textit{et al.} \\cite{graesser2012image}. Alongside these features, we design a new feature that is based on the difference in the distribution of road intersections between formal and informal areas.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{images/block_scale}\n    \\caption{An example of block size and scale}\n    \\label{fig:block_scale}\n\\end{figure}\n\n\n\\subsection{Terminology}\nThe paper of Graesser \\textit{et al.} divides the image into small blocks instead of pixels when extracting features from the satellite images. The features are calculated for each block of pixels instead of each pixel individually, which significantly lowers the computational load as the extraction methods can be computationally quite expensive. The dimensions of the blocks are referred to as the \\textit{block size},  which is 20 by 20 pixels in the paper of Graesser \\textit{et al}. In our research, various block sizes will be evaluated for their effect on the classification performance. Besides \\textit{block size}, another important parameter in the paper is the \\textit{scale} of a feature. The \\textit{scale} specifies an n by n block around the pixel block of which the features are calculated.\n\nFigure \\ref{fig:block_scale} is an example of how the size of the block and the scale are used in the calculation of the features from an image. In this example, the size of the image is 120 by 120 pixels and is divided into blocks of the 20 by 20 pixels each, which is the block size. In this example, the scale is the area around each of 80 by 80 pixels. For every block in the image, starting from the top left to the bottom right, the features are calculated over the area covered by the scale. To clarify, if we extract $n$ features from the image in the example, the dimensions of the feature vector would be (6 x 6 x $n$). The block size essentially controls the resolution of the calculated feature vector with an increased block size causing a decreased resolution and the same in reverse. In practice, the block size is almost never a multiple of the image size. In the border regions of the image using a scale larger than the block size, the outer blocks where the scale falls off the edge of the image are discarded. This results in a smaller feature vector than merely dividing the size of the image by the block size.\n\n\\begin{figure}[h]\n    \\centering\n    $\\mathlarger{\\mathlarger{\\mathlarger{   p_x = \\ceil*{\\frac{i_x}{b_x}} - \\ceil*{\\frac{i_x - s_x - b_x}{b_x}} }}}$\n    \\caption{Definition of the padding calculation in the $x$-direction}\n    \\label{padding}\n\\end{figure}\n\nFigure \\ref{padding} shows displays the equation to calculate how many blocks will be removed as padding $p$ for a particular image $i$ with the combination of scale $s$ and block size $b$. We displayed the function for the calculation of the padding in the $x$-direction, although this will be different for the $y$-direction if the image, scale or block size is not of equal width and length. In our case, only the images will have a different width and length; the scales and block sizes will always be $n$x$n$; thus we will be referring two these parameters with a single value $n$ instead of $n$x$n$\n\nWe used this equation to predict the dimensions of the features that the Python library would produce after we supplied the input image and the accompanying parameters. We need this prediction to reshape the ground truth into the same shape as the produced features. If the shape of the ground truth does not match the size of the feature, we cannot correctly label the values from the feature vector as either belonging to the formal or informal class and produce the dataset for training and testing for the classification algorithms.\n\n\\subsection{Histogram of Oriented Gradients}\n\nAlthough the patent application describing the Histogram of Oriented Gradients was submitted in 1986, the approach only became widespread in 2005, after a paper used this method to detect humans on images \\cite{dalal2005histograms}. The Histogram of Oriented gradients creates a histogram for every block in the image where the histogram contains the gradient orientation of the pixels in the block and surrounding area, as determined by the scale and block size parameter. In the case of the detection of humans, for example, the visual differences between humans and the background manifests itself in the gradient orientations of the image, which the Histogram of Oriented Gradients can capture. The difference in gradient orientation, therefore, enables objects with distinct visual characteristics, such as humans, to be detected from images.\n\nBeyond the detection of humans, a paper from 2003 showed that this approach can also be used to detect man-made structures in photographs \\cite{kumar2003man}, which used images of buildings surrounded by vegetation. The Histogram of Oriented Gradients method described in the paper of Graesser \\textit{et al.} is based on this paper, although they used satellite images instead of regular photographs from nature. As in the method for the detection of humans with the Histogram of Oriented Gradients, the paper from Graesser \\textit{et al.} captures characteristics of a particular class, which are, in this case, the characteristics of informal neighborhoods. In case of slums, these characteristics are the diverse orientations of gradients in a slum area due to diverse building orientations compared to formal structures. In contrast to slums, formal buildings are often placed in a regular pattern with consistent orientation.\n\n\nThe Python library we used extracts different features from the Histogram of Oriented Gradients than the ones described in the paper. The paper uses the first two central moments together with three orientation features, but they are ill-described; the library instead uses four central moments together with a maximum. Because we use the implementation from the library, we will only discuss the features that are used in the library instead of the paper. \n\nThe four central moments that are used form a set of values that characterize a probability distribution relative to the mean of the distribution. These characteristics of a distribution, better known as the mean, variance, skew and kurtosis, are defined using the formula displayed in \\ref{central_moments} \\cite{grimmett2001probability}. In this formula, $n$ is the order of the central moment, $\\mu_{n}$ is the $n$th central moment and $\\mu$ without a subscript is the mean of the distribution on which the central moments are based. The zeroth and first central moment are trivial because $n=0$ and $n=1$ will always result in 1 and 0 respectively. Instead of using the trivial first central moment, the library uses the regular mean instead. The other three central moments, variance, skew and kurtosis are calculated using the formula in \\ref{central_moments} for $n=2$, $n=3$, and $n=4$, respectively. Besides the central moments, the fifth feature is a maximum although, due to lack of documentation, it is unclear what this maximum refers to exactly.\n\n\\begin{figure}[h]\n    \\centering\n    $\\mathlarger{\\mathlarger{\\mu_{n} = \\int_{-\\infty}^{+\\infty} (x-\\mu)^nf(x)dx }} $\n    \\caption{The definition of the central moments}\n    \\label{central_moments}\n\\end{figure}\n\nInstead of using a single scale for feature calculation, the paper of Graesser \\textit{et al.} uses octaves of three scales, meaning that the size of the scale doubles for every scale. To illustrate, the scale octaves used for both the Histogram of Gradients and the Line Support Regions, is 50, 100, and 200. To summarize: in the paper, a single HoG feature vector contains five values, since the feature is performed for three different scales, the total values in the feature vector results in 15. Although it is not mentioned in the paper, the library calculates the features for the different color bands as well, resulting in 45 values instead of 15, which implies that in the paper only a single color band was used.\n\nAccording to the results presented in the paper, these 15 features could produce an accuracy of 65 to 75 percent. However, this feature was applied to specific image regions where the visual difference between formal and informal was substantial. It is therefore debatable whether this performance is to be attributed to the Histogram of Oriented Gradients or the specific contents of the image. Besides, the morphology of the slums in their area of study is different from the slums in Bangalore, making a comparison difficult.\n\n\n\\subsection{Line Support Region Features}\n\nThe Line Support Regions method was initially used for the detection of straight lines in photographs \\cite{burns1986extracting}. As with the Histogram of Oriented Gradients, this method is a spatial feature and uses gradient orientation to characterize parts in the image, in this case, straight lines. This approach groups pixels together with similar gradient orientation based on the fact that straight lines are in essence regions of pixels with similar gradients. \n\nThis approach was shown to be suited for land use classification \\cite{unsalan2004classifying} \\cite{unsalan2006gradient}, and has been used in slum and informal region detection since \\cite{graesser2012image} \\cite{accra} \\cite{colombo}. LSR characterizes neighborhoods using the lines that inhabit the area, which often corresponds to the contours of buildings. In formal neighborhoods, these lines are often relatively long since the formal structures tend to be bigger than informal structures. Furthermore, according to the paper \\cite{unsalan2004classifying}, line contrast can be used as well to differentiate between land use, as developed areas tend to have high contrast as opposed to low contrast in underdeveloped areas. This difference in contrast can, for instance, be caused by the presence of asphalt, shining roof material and vegetation, which tends to lack in underdeveloped regions. In the paper, this approach was used to differentiate between urban areas and rural areas, although this is now used as well to differentiate between region types within an urban area.\n\nLSR is implemented in Spfeas in accordance with the paper of Graesser \\textit{et al.} \\cite{graesser2012image}. The paper uses the line length entropy, mean, and entropy of line contrasts as statistical features from the Line Support Regions, although the paper does not describe this process detail. The paper to which Graesser \\textit{et al.} refers to, describes the process of calculating these statistical features using three coefficients produced by a Fourier Transformation \\cite{unsalan2004classifying}. These coefficients are $(\\alpha_{-1}, \\beta_{-1})$, $(\\alpha_{0}, \\beta_{0})$, and $(\\alpha_{1}, \\beta_{1})$ of which the derivation can be found in the paper.\n\n\\begin{figure}[h]\n    \\centering\n    $$\\mathlarger{\\mathlarger{ \\mu_{xy} = (\\alpha_{0}, \\beta_{0}) }}$$\n    $$\\mathlarger{\\mathlarger{ l = 2\\left[\\sqrt{\\alpha_{1}^2 + \\beta_{1}^2} + \\sqrt{\\alpha_{-1}^2 + \\beta_{-1}^2}\\right] }}$$\n    $$\\mathlarger{\\mathlarger{ \\theta = \\frac{\\arctan(\\frac{\\beta_{1}}{\\alpha_{1}}) + \\arctan(\\frac{\\beta_{-1}}{\\alpha_{-1}})}{2} }}$$\n    \\caption{Definition of the center of mass $\\mu_{xy}$, the line length $l$ and orientation $\\theta$}\n    \\label{line_def}\n\\end{figure}\n\nUsing these coefficients, we can characterize the lines detected within the scale of a block by using the center of mass $\\mu_{xy}$, the line length $l$ and orientation $\\theta$ with the formula displayed in Figure \\ref{line_def}. The most straightforward statistical feature is the mean, which is calculated by taking the mean of all $l$ values of the detected line support regions. The other two features, the entropy of the line length and the line contrast,  are calculated using the entropy formula in Figure \\ref{line_entropy_def}. \n\n\\begin{figure}[h]\n    \n    $$ \\mathlarger{\\mathlarger{ E = -\\sum_{i=1}^{N} \\left[ h(i) \\log_2(h(i))\\right] }}$$\n    \\caption{Definition of the entropy function}\n    \\label{line_entropy_def}\n\\end{figure}\n\nIn the creation of the line length entropy, the length of the lines in the area is collected in a histogram with bins representing the different length of the lines. The paper\\cite{unsalan2004classifying} describes a total of 37 bins ranging from 5 to 150 pixels. Regarding the formula in Figure \\ref{line_entropy_def}, using the histogram $h$ with $N$ bins, we can calculate the entropy of the line length $E_l$.\n\nThe line contrasts are calculated by finding the maximum gradient for every line support region. These maximum gradients are, as the line contrasts calculation, collected in a histogram of 31 bins, ranging from 5 to 3000. A more detailed description including the formula for the maximum feature selection can be found in the paper \\cite{unsalan2004classifying}. The histogram is used by the entropy function defined in Figure \\ref{line_entropy_def} and results in the line contrast entropy $E_c$.\n\nThe paper by Graesser \\textit{et al.} uses the same octave scale and block size used for HoG, resulting in a total of 9 features. Again, since we use three color bands, the number of features used in our implementation is multiplied by three relative to the paper. Using the LSR features, the paper achieved an accuracy of 60 to 75 percent.\n\n\n\n", "meta": {"hexsha": "ef6213bbbdbefa1a5d8383deb03f81232c147c44", "size": 13792, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/features.tex", "max_stars_repo_name": "DerkBarten/SlumDetection", "max_stars_repo_head_hexsha": "8ae38623454dc3467333f07571401073d9c40616", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/features.tex", "max_issues_repo_name": "DerkBarten/SlumDetection", "max_issues_repo_head_hexsha": "8ae38623454dc3467333f07571401073d9c40616", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/features.tex", "max_forks_repo_name": "DerkBarten/SlumDetection", "max_forks_repo_head_hexsha": "8ae38623454dc3467333f07571401073d9c40616", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 162.2588235294, "max_line_length": 1132, "alphanum_fraction": 0.7876305104, "num_tokens": 3099, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949467848392, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.44190587833988226}}
{"text": "{\\bf \\Large\n\\begin{tabular}{ccc}\n\\hline\n  Corresponding author & : & Seiya Nishizawa\\\\\n\\hline\n\\end{tabular}\n}\n\n\\section{Temporal integration scheme}\n\n\\subsection{Runge-Kutta schemes}\n\nFor the time integration of Eqs.(\\ref{eq:rhotot_d2})-(\\ref{eq:etot_d2}),\nwe adopt the full explicit scheme with\nthe $p$ step Runge-Kutta scheme.\n\\begin{eqnarray}\n&& \\phi^{*}_{0} = \\phi^{t}\\\\\n&& k_1 = f(\\phi^t) \\\\\n&& k_2 = f(\\phi^t + k_1 \\Delta t \\alpha_1) \\\\\n&&  \\cdot \\cdot \\cdot\\nonumber\\\\\n&& k_p = f(\\phi^t + k_{p-1} \\Delta t \\alpha_{p-1}) \\\\\n&& \\phi^{t+\\Delta t} = \\phi^t + \\Delta t\\sum_p \\beta_p k_p.\n\\end{eqnarray}\nThe 3 and 4 step Runge-Kutta scheme are implemented.\n\n\n\\subsubsection{The Heun's three step scheme}\n\n\\begin{align}\n  k_1 &= f(\\phi^n), \\\\\n  k_2 &= f\\left(\\phi^n + \\frac{1}{3}\\Delta t k_1\\right), \\\\\n  k_3 &= f\\left(\\phi^n + \\frac{2}{3}\\Delta t k_2\\right), \\\\\n  \\phi^{n+1} &= \\phi^n + \\frac{1}{4}\\Delta t (k_1 + 3k_3).\n\\end{align}\n\n\n\\subsubsection{The Kutta's three step scheme}\n\n\\begin{align}\n  k_1 &= f(\\phi^n), \\\\\n  k_2 &= f\\left(\\phi^n + \\frac{1}{2}\\Delta t k_1\\right), \\\\\n  k_3 &= f\\left(\\phi^n - \\Delta t k_1  + 2 \\Delta t k_2\\right), \\\\\n  \\phi^{n+1} &= \\phi^n + \\frac{1}{6}\\Delta t (k_1 + 4k_2 + k_3).\n\\end{align}\n\n\n\\subsubsection{The \\citet{Wicker_2002}'s three step scheme}\n\n\\begin{align}\n  k_1 &= f(\\phi^n), \\\\\n  k_2 &= f\\left(\\phi^n + \\frac{1}{3}\\Delta t k_1\\right), \\\\\n  k_3 &= f\\left(\\phi^n + \\frac{1}{2}\\Delta t k_2\\right), \\\\\n  \\phi^{n+1} &= \\phi^n + \\Delta t k_3.\n\\end{align}\n\n\n\\subsubsection{The four step scheme}\n\n\\begin{align}\n  k_1 &= f(\\phi^n), \\\\\n  k_2 &= f\\left(\\phi^n + \\frac{1}{2}\\Delta t k_1\\right), \\\\\n  k_3 &= f\\left(\\phi^n + \\frac{1}{2}\\Delta t k_2\\right), \\\\\n  k_4 &= f\\left(\\phi^n + \\Delta t k_3\\right), \\\\\n  \\phi^{n+1} &= \\phi^n + \\frac{1}{6}\\Delta t (k_1 + 2k_2 + 2k_3 + k_4).\n\\end{align}\n\n\n\\subsubsection{The forward-backward scheme}\nIn the short time step, the momentums are updated first and then density is updated with the updated momentums.\n\\begin{align}\n  \\rho u^{n+1}_i &= \\rho u^n_i + \\Delta t f_{\\rho u_i}(\\rho^n), \\\\\n  \\rho^{n+1}     &= \\rho^n + \\Delta t f_{\\rho}(\\rho u^{n+1}_i).\n\\end{align}\n\n\\subsection{Numerical stability}\n\nA fully compressive equations of a acoustic mode is considered.\nThe continuous and momentum equations is the followings:\n\\begin{align}\n  \\frac{\\partial \\rho}{\\partial t} &=\n  - \\frac{\\partial \\rho u_i}{\\partial x_i} \\\\\n  \\frac{\\partial \\rho u_i}{\\partial t} &=\n  - \\frac{\\partial p}{\\partial x_i} \\\\\n  p &= p_0 \\left( \\frac{R \\rho \\theta}{p_0} \\right)^{c_p/c_v},\n\\end{align}\nhere the potential temperature $\\theta$ is assumed to be constant.\n\nIn order to analize the numerical stability of equation, the equation of the state is linearized.\n\\begin{equation}\n  p \\approx \\bar{p} + c^2 \\rho',\n\\end{equation}\nwhere $c$ is the sound speed: $c^2=\\frac{c_p\\bar{p}}{c_v\\bar{\\rho}}$.\n\n\nWe descritize the governing equation with the 2th order central difference.\n\\begin{align}\n  \\left. \\frac{\\partial \\rho}{\\partial t}\\right|_{i,j,k} &=\n  -\\frac{U_{i+1/2}-U_{i-1/2}}{\\Delta x}\n  -\\frac{V_{j+1/2}-V_{j-1/2}}{\\Delta y}\n  -\\frac{W_{k+1/2}-W_{k-1/2}}{\\Delta z} \\\\\n  \\left. \\frac{\\partial U}{\\partial t}\\right|_{i+1/2} &=\n  -c^2\\frac{\\rho_{i+1}-\\rho_i}{\\Delta x} \\\\\n  \\left. \\frac{\\partial V}{\\partial t}\\right|_{j+1/2} &=\n  -c^2\\frac{\\rho_{j+1}-\\rho_j}{\\Delta y} \\\\\n  \\left. \\frac{\\partial W}{\\partial t}\\right|_{i+1/2} &=\n  -c^2\\frac{\\rho_{k+1}-\\rho_k}{\\Delta z},\n\\end{align}\nwhere $U, V$, and $W$ is the momentum at the stagared grid point in $x, y$, and $z$ direction, respectively.\n\nThe error of the spatial differenece of a wavenumber $k$ component $\\hat{\\phi}_k$ is $\\left\\{\\exp(ik\\Delta x)-1\\right\\}\\hat{\\phi}$, and the error of 2-grid mode is the largest: $\\exp(i\\pi)-1 = -2$.\n\nThe temporal differential of the 2-grid mode is\n\\begin{align}\n  \\frac{\\partial \\rho}{\\partial t} &=\n  -\\frac{1-\\exp(-i\\pi)}{\\Delta x}U\n  -\\frac{1-\\exp(-i\\pi)}{\\Delta y}V\n  -\\frac{1-\\exp(-i\\pi)}{\\Delta z}W \\\\\n  \\frac{\\partial U}{\\partial t} &=\n  -c^2\\frac{\\exp(i\\pi)-1}{\\Delta x}\\rho \\\\\n  \\frac{\\partial V}{\\partial t} &=\n  -c^2\\frac{\\exp(i\\pi)-1}{\\Delta y}\\rho \\\\\n  \\frac{\\partial W}{\\partial t} &=\n  -c^2\\frac{\\exp(i\\pi)-1}{\\Delta z}\\rho.\n\\end{align}\nThe mode of which the $U, V$ and $W$ has the same phase is the most unstable:\n\\begin{align}\n  \\frac{\\partial \\rho}{\\partial t} &=\n  -3\\frac{1-\\exp(-i\\pi)}{\\Delta x}U \\\\\n  \\frac{\\partial U}{\\partial t} &=\n  -c^2\\frac{\\exp(i\\pi)-1}{\\Delta x}\\rho\n\\end{align}\n\nWriting matrix form,\n\\begin{equation}\n  \\begin{pmatrix}\n    \\frac{\\partial \\rho}{\\partial t} \\\\\n    \\frac{\\partial U}{\\partial t}\n  \\end{pmatrix}\n  = D\n  \\begin{pmatrix}\n    \\rho \\\\\n    U\n  \\end{pmatrix},\n\\end{equation}\nwhere\n\\begin{equation}\n  D =\n  \\begin{pmatrix}\n    0 & -\\frac{6}{\\Delta x} \\\\\n    \\frac{2c^2}{\\Delta x} & 0\n  \\end{pmatrix}.\n\\end{equation}\n\n\\subsubsection{The Euler scheme}\nWith the Euler scheme,\n\\begin{equation}\n  \\phi^{n+1} = \\phi^n + \\Delta t f(\\phi^n)\n\\end{equation}\nThe $A$ is the matrix representing the time step, then\n\\begin{align}\n  A &= I + dt D, \\\\\n    &= \\begin{pmatrix}\n    1 & -6\\frac{\\Delta t}{\\Delta x} \\\\\n    \\frac{2c^2\\Delta t}{\\Delta x} & 1\n    \\end{pmatrix}.\n\\end{align}\nThe eigen value of $A$ is larger than 1, and the Euler scheme is instable for any $\\Delta t$.\n\n\n\\subsubsection{The second step Runge-Kutta scheme}\nThe Heun's second step Runge-Kutta scheme is\n\\begin{align}\n  k_1 &= f(\\phi^n), \\\\\n  k_2 &= f(\\phi^n + \\Delta t k_1), \\\\\n  \\phi^{n+1} &= \\phi^n + \\frac{\\Delta t}{2}(k_1 + k_2).\n\\end{align}\n\n\\begin{align}\n  A &= I + \\frac{\\Delta t}{2}(K_1 + K_2), \\\\\n  K_1 &= D, \\\\\n  K_2 &= D (I + \\Delta t K_1).\n\\end{align}\nAfter all,\n\\begin{equation}\n  A = \\begin{pmatrix}\n    1-6\\nu^2 & -\\frac{6\\Delta t}{\\Delta x} \\\\\n    \\frac{2c^2\\Delta t}{\\Delta x} & 1-6\\nu^2\n    \\end{pmatrix},\n\\end{equation}\nwhere $\\nu$ is the Courant number for the sound speed: $\\frac{c\\Delta t}{\\Delta x}$.\nThe eigen value of $A$ is larger than 1, and the Euler scheme is instable for any $\\Delta t$.\n\n\n\n\\subsubsection{The third step Runge-Kutta scheme}\nWith the Heun's third step Runge-Kutta scheme, the matrix $A$ is written by\n\\begin{align}\n  A &= I + \\frac{\\Delta t}{4}(K_1 + 4K_3), \\\\\n  &= \\begin{pmatrix}\n    1-6\\nu^2 & -\\frac{6\\Delta t}{\\Delta x}(1-2\\nu^2) \\\\\n    \\frac{2c^2\\Delta t}{\\Delta x}(1-2\\nu^2) & 1-6\\nu^2\n  \\end{pmatrix}, \\label{eq: A two}\n\\end{align}\nwhere\n\\begin{align}\n  K_1 &= D, \\\\\n  K_2 &= D (I + \\frac{\\Delta t}{3}K_1), \\\\\n  K_3 &= D (I + \\frac{2\\Delta t}{3}K_2).\n\\end{align}\n\nThe condition that all the eigen values are less than or equal to 1 is\n\\begin{equation}\n  \\nu \\leq \\frac{1}{2}. \\label{eq: cond nu two}\n\\end{equation}\n\nIn the Kutta's three step Runge-Kutta scheme, the matrix $A$ is\n\\begin{equation}\n  A = I + \\frac{\\Delta t}{6}(K_1 + 4K_2 + K_3),\n\\end{equation}\nwhere\n\\begin{align}\n  K_1 &= D, \\\\\n  K_2 &= D \\left(I + \\frac{\\Delta t}{2}K_1\\right), \\\\\n  K_3 &= D \\left(I - \\Delta t K_1 + 2\\Delta t K_2\\right).\n\\end{align}\nIt is the idential as that in the Heun's scheme (eq. \\ref{eq: A two}).\nThus, the stable condition is the same (eq. \\ref{eq: cond nu two}).\n\nThe \\citet{Wicker_2002}'s Runge-Kutta scheme is described as\n\\begin{align}\n  A &= I + \\Delta t K_3, \\\\\n  K_1 &= D, \\\\\n  K_2 &= D \\left(I + \\frac{\\Delta t}{3}K_1\\right), \\\\\n  K_3 &= D \\left(I + \\frac{\\Delta t}{2}K_2\\right).\n\\end{align}\nThe $A$ and the consequent stable condition are the identical as the above two schemes.\n\n\n\\subsubsection{The four step Runge-Kutta scheme}\nThe matrix $A$ is\n\\begin{align}\n  A &= I + \\frac{\\Delta t}{6}(K_1 + 2K_2 + 2K_3 + K_4), \\\\\n  &= \\begin{pmatrix}\n    1-6\\nu^2+6\\nu^4 & -\\frac{6\\Delta t}{\\Delta x}(1-2\\nu^2) \\\\\n    \\frac{2c^2\\Delta t}{\\Delta x}(1-2\\nu^2) & 1-6\\nu^2+6^4\n  \\end{pmatrix},\n\\end{align}\nwhere\n\\begin{align}\n  K_1 &= D, \\\\\n  K_2 &= D \\left(I + \\frac{\\Delta t}{2}K_1\\right), \\\\\n  K_3 &= D \\left(I + \\frac{\\Delta t}{2}K_2\\right), \\\\\n  K_4 &= D (I + \\Delta t K_3).\n\\end{align}\n\nThe condition for stability is\n\\begin{equation}\n  \\nu \\le \\frac{\\sqrt{6}}{3}.\n\\end{equation}\n\nThe number of floating opint operations with the four step Runge-Kutta scheme is about $4/3$ times larger than that with the three step scheme.\nHowere, the time step can be $2\\sqrt{6}/3$ larger than that in the three step scheme.\nSince $2\\sqrt{6}/3 > 4/3$, the four step Runge-Kutta scheme is more cost effective than the three step scheme in terms of numerical stability.\n\n\n\\subsubsection{The forward-backward scheme}\nThe stabitlity condition is\n\\begin{equation}\n  \\nu \\le \\frac{1}{\\sqrt{3}}.\n\\end{equation}\n\nThe forward-backward scheme can be used in each step in the Runge-Kutta schemes.\nThe stability conditions are the followings:\n\\begin{description}\n \\item[The second step RK scheme]\n \\begin{equation}\n   \\nu \\le \\frac{1}{\\sqrt{3}}.\n \\end{equation}\n\n \\item[The Heun's three step RK scheme]\n \\begin{equation}\n   \\nu \\le \\frac{1}{2}.\n \\end{equation}\n\n \\item[The Kutta's three step RK scheme]\n \\begin{equation}\n   \\nu \\le \\frac{1}{2}.\n \\end{equation}\n\n \\item[The\\citet{Wicker_2002}'s three step RK scheme]\n \\begin{equation}\n   \\nu \\le \\frac{\\sqrt{6}}{4}.\n \\end{equation}\n\n \\item[The four step RK scheme]\n \\begin{equation}\n   \\nu \\le 0.66\n \\end{equation}\n\n\n\\end{description}\n", "meta": {"hexsha": "c9a901f012fca5494252a0fb23201784ad16db90", "size": 9166, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/descriptions/temporal_integration.tex", "max_stars_repo_name": "slayoo/scale", "max_stars_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-06-14T11:12:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T05:29:55.000Z", "max_issues_repo_path": "doc/descriptions/temporal_integration.tex", "max_issues_repo_name": "slayoo/scale", "max_issues_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-07-29T03:38:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-30T05:08:47.000Z", "max_forks_repo_path": "doc/descriptions/temporal_integration.tex", "max_forks_repo_name": "slayoo/scale", "max_forks_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-07-10T10:39:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-28T22:20:41.000Z", "avg_line_length": 30.3509933775, "max_line_length": 197, "alphanum_fraction": 0.6263364608, "num_tokens": 3570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.44190586896889883}}
{"text": "\\section{Conclusions}\n\nThe actual \\emph{convergence rates} of the \\emph{primal} $\\protect \\mathcal{L}_1$-SVM formulations, i.e., the figures~\\ref{fig:l1_svc_loss_history} and~\\ref{fig:l1_svr_loss_history}, shows as they do not meet the theoretical expectations at the first line of the table~\\ref{primal_svm_objectives_rates}. Both the \\emph{Polyak} and the \\emph{Nesterov} momentums provide a significant accelleration wrt the \\emph{vanilla SGD} and they are quite comparable.\n\nConversely, the actual \\emph{convergence rates} of the \\emph{primal} $\\protect \\mathcal{L}_2$-SVC formulations, i.e., the figure~\\ref{fig:l2_svc_loss_history} and~\\ref{fig:l2_svr_loss_history}, shows as they do in part meet the theoretical expectations at the second line of the table~\\ref{primal_svm_objectives_rates}. Despite the \\emph{Nesterov} momentum provide a significant accelleration wrt the \\emph{vanilla SGD} as expected, also the \\emph{Polyak} momentm provide a quite comparable accelleration only reserved for the quadratic case according to the theoretical analysis.\n\nMeanwhile, the actual \\emph{convergence rates} of the \\emph{primal} $\\protect \\mathcal{L}_2$-SVR formulations, i.e., the figure~\\ref{fig:l2_svr_loss_history}, shows as they do not meet the theoretical expectations at the second line of the table~\\ref{primal_svm_objectives_rates} since in this specific case, both the \\emph{Polyak} and \\emph{Nesterov} momentums does not provide an accelleration wrt the \\emph{vanilla SGD} as expected.\n\n\\bigskip\n\nThe actual \\emph{convergence rates} of the \\emph{Lagrangian dual} formulations shows as they do not meet the theoretical expectations in the table~\\ref{dual_svm_objectives_props}. The different \\emph{convergence rate} is more highlighted in the linear case for lower regularization parameters $C$ but the situation is reversed as the latter grows. In the nonlinear settings, it depends on the kernel function, e.g., in the \\emph{polynomial} case the convergence can become pathologically slower, meanwhile in the \\emph{gaussian} or \\emph{laplacian} case often it is better.\n\nMoreover, from all the actual \\emph{convergence rates} of the \\emph{Lagrangian dual} formulations, it is evident that fitting the bias in an explicit way, i.e., by adding Lagrange multipliers to control the equality constraint, always causes slower converge of the \\emph{AdaGrad} algorithm wrt the \\emph{Lagrangian dual} of the problem where the bias term embedded into the Hessian matrix.\n\n\\bigskip\n\nAll the \\emph{custom} implementations underperforms the others, i.e., \\emph{liblinear}~\\cite{fan2008liblinear}, \\emph{libsvm}~\\cite{chang2011libsvm} and \\emph{cvxopt}~\\cite{vandenberghe2010cvxopt} implementations, in terms of \\emph{time} obviously in part due to the different core implementation languages, i.e., Python vs C, in part due to the different algorithm uses to solve the  optimization problem, e.g., the \\emph{liblinear}~\\cite{fan2008liblinear} implementation uses the \\emph{Coordinate Gradient Descent} to sove the \\emph{primal formulation} which minimizes one coordinate at a time.\n\nMeanwhile, for what about the \\emph{Wolfe dual} formulations, despite \\emph{cvxopt}~\\cite{vandenberghe2010cvxopt} underperforms the \\emph{libsvm}~\\cite{chang2011libsvm} implementation in terms of \\emph{time}, since it is a general-purpose QP solver and it does not exploit the structure of the problem, the number of \\emph{iterations} of the \\emph{custom} SMO algorithm is always lower wrt that in \\emph{libsvm}~\\cite{chang2011libsvm}, probably due to the improvements described in~\\cite{keerthi2001improvements, shevade1999improvements} for classification and regression respectively.\n\n\\bigskip\n\nFinally, all the \\emph{primal formulations} are suitable for potentially large linear training since the complexity of the model grows with the number of features or, more in general, when the number of examples $n$ is much larger than the number of features $m$, i.e., $n \\gg m$.\n\nMeanwhile, the \\emph{dual formulations} are suitable in case the number of examples $n$ is less than the number of features $m$, i.e., $n < m$, since the complexity of the model is dominated by the number of examples. The \\emph{Lagrangian} formulation never overperforms the \\emph{Wolfe} one in our experiments, neither in terms of \\emph{time} nor in terms of \\emph{iterations}, but it is useful to highlight the complexity introduced by the dual formulation. Its training time complexity is more than quadratic with the number of samples which makes it hard to scale to large datasets. In this case, it could be useful to use the \\emph{primal formulation} possibly after a nonlinear transformation of the instance vectors (if this should not be in the given space) using a low-rank kernel matrix approximation, i.e., Nyström, before training.", "meta": {"hexsha": "c7d75a44b945995f35cc1d51b925d3dc88e82563", "size": 4804, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_stars_repo_name": "DonatoMeoli/NumericalOptimization", "max_stars_repo_head_hexsha": "e60144458026a6ddbe1612f92b838c342db572eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-05-22T09:17:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T18:23:56.000Z", "max_issues_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_issues_repo_name": "DonatoMeoli/NumericalOptimization", "max_issues_repo_head_hexsha": "e60144458026a6ddbe1612f92b838c342db572eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-02-25T08:29:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T09:03:13.000Z", "max_forks_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_forks_repo_name": "DonatoMeoli/NumericalOptimization", "max_forks_repo_head_hexsha": "e60144458026a6ddbe1612f92b838c342db572eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2020-10-10T13:38:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-13T20:23:37.000Z", "avg_line_length": 192.16, "max_line_length": 843, "alphanum_fraction": 0.7960033306, "num_tokens": 1281, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4419058617959241}}
{"text": "\\documentclass[main_montangero.tex]{subfiles}\n\\begin{document}\n\n\\section{Shor's algorithm}\n\nIt is a method to factor a product of large numbers.\n\n\\paragraph{Motivation}\n\nAlice wants to communicate a message \\(P\\) to Bob.\nBob generates a public key \\( K _{\\text{Pu}} \\) and a private key \\( K _{\\text{Pr}}  \\), he sends the public key \\( K _{\\text{Pu}} \\) to Alice, who encodes the message with an algorithm \\(E\\) which depends on the public key:\n\n\\begin{equation}\n  C = E _{K _{\\text{Pu}} } (P) = P ^e \\mod N\n\\end{equation}\n\nwhere \\( N \\) is chosen such that \\( N = pq \\), with \\( p, q \\in \\Z_{\\text{prime}} \\), \\(\\Phi = (p-1) (q-1)\\), \\( 1<e<\\Phi \\),  and \\( \\text{GCD}(\\Phi, e) = 1 \\).\n\nShe then sends \\( C \\) to Bob, who uses \\( K _{\\text{Pr}} \\) to decode it with an algorithm \\(D\\):\n\n\\begin{equation}\n  P = D _{K _{\\text{Pr}}} C^d \\mod N % P (d, N)??\n\\end{equation}\n\nwhere \\( d \\) is chosen such that \\( de = 1 \\mod \\Phi \\).\n\nFactoring \\( N \\) is equivalent to finding the period of a function: the \\emph{order} \\( r \\) is the number such that \\( x ^{r} = 1 \\mod N  \\) , \\( f(r) = x^r \\mod N \\).\n\nIf \\( r \\) is even, then \\( y = x ^{r/2}  \\), so \\( y^2 = 1 \\mod N \\) therefore \\( (y+1)(y-1) = 0 \\mod N \\).\n\nTherefore \\( (y+1)(y-1) = kN \\) for some \\( k \\in \\N \\), so we have found the factors.\n\n\\paragraph{The algorithm}\n\nGiven \\( N = pq \\), we have the following steps:\n\n\\begin{enumerate}\n  \\item Choose \\( x<N \\). If it divides \\( N \\), we are done;\n  \\item Find the order \\( r \\) such that \\( f(r) = x^r \\mod N \\); \\label{item:qft}\n  \\item If \\( r \\) is even, we have the factors. If it is not, start over.\n\\end{enumerate}\n\nThe quantum step is in step \\ref{item:qft}.\n\n\n\\paragraph{Step 1}\n\n\\subparagraph{Hypotheses} These are not actually needed but they make treating the problem much simpler, and there is not much to learn in generalizing: we assume \\( N = 2^n \\) and \\( N/r = m \\in \\N \\).\n\nAs always we cannot directly encode our function as a unitary transformation since it will be periodic, therefore not injective, therefore not unitary. So we encode it taking the input along, as\n\n\\begin{equation}\n   U: \\ket{x}\\ket{0} \\longmapsto \\ket{x} \\ket{f(x)}\n\\end{equation}\n\nWe start from \\( \\ket{0}^{\\otimes n} \\), apply \\(N\\) Hadamards and get \\( \\ket{\\psi_0} \\) = superposition of all possible states, and with this\nwe prepare\n\n\\begin{equation}\n  \\ket{\\psi_1} = \\frac{1}{\\sqrt{2^n}} \\sum _{x=0} ^{N}   \\ket{x} \\ket{f(x)}\n\\end{equation}\n\n\\paragraph{Step 2}\n\nWe measure the second registry, and obtain \\( \\ket{\\overline{f}} \\). Then the first registry must contain all the combinations which generate that state: so:\n\n\\begin{subequations}\n\\begin{align}\n  \\ket{\\psi_2}\n  &= \\frac{1}{\\sqrt{m}}\\sum _{j=0} ^{m-1} \\ket{x_0 + jr} \\ket{\\overline{f(x_0)}}  \\\\\n  &= \\qty[\\frac{1}{\\sqrt{m}}\\sum _{j=0} ^{m-1} \\ket{x_0 + jr} ] \\otimes \\ket{\\overline{f(x_0)}}\n\\end{align}\n\\end{subequations}\n\n\\paragraph{Step 3}\n\nWe want to find \\( r \\), so we can do a quantum Fourier transform. It can be slow  to actually measure the full transform for generic functions but in our case the transform is applied to a function which is already periodic\n\n\\begin{equation}\n  \\ket{\\psi _3} = \\text{QFT}\\qty{\\ket{\\psi_2}} = \\frac{1}{\\sqrt{mN}} \\sum _{y=0} ^{N-1} \\sum _{j=0} ^{m-1} \\exp(2 \\pi i (x_0 + jr) y/N) \\ket{y}\n\\end{equation}\n\n\\paragraph{Step 4}\n\nWe compute the probability of obtaining a specific value \\(\\overline{y} \\) from a measure of the registry:\n\n\\begin{subequations}\n\\begin{align}\n  \\P\\qty(\\overline{y})\n  &= \\frac{1}{Nm} \\abs{\\sum _{j=0} ^{m-1} \\exp(2 \\pi i (x_0 + jr) \\overline{y}/N) }  \\\\\n  &= \\frac{1}{r} \\abs{\\frac{1}{m} \\sum_j \\exp(2 \\pi i j \\overline{y} /m)}\n\\end{align}\n\\end{subequations}\n\nClaim: the states with nonzero probability to be found are those with \\( \\overline{y} = km \\), where \\( k \\in 0, \\dots,  r \\).\n\n\\subparagraph{Example}\n\n\\( P(\\overline{y} = 0) = 1/r \\abs{1/m \\sum_j 1} = 1/r \\). Our function is periodic with period \\(r\\), and there are \\(r-1\\) other analogous states. So, the probability is saturated and there is no other possible outcome.\n\nSo all the states we get are in the form \\( \\overline{y}=km = kN/r \\). We know $N$, we measured \\( \\overline{y} \\), so:\n\n\\begin{itemize}\n  \\item if \\( k=0 \\), we failed;\n  \\item if \\( k\\neq 0 \\), we set \\( \\overline{y}/N = \\overline{k}/r \\) and find the solution in polynomial time.\n\\end{itemize}\n\n\\( P(\\text{success}) \\sim 1 \\) dopo \\( O(\\log(\\log(r))) \\).\n\nRecall \\( n = \\log N \\): the complexity of Shor's algorithm scales as \\( O(n^2 \\log n \\log \\log n) \\), whereas the classical algorithm scales as \\( \\exp(O(\\sqrt[3]{n\\log n})) \\).\n\nIt is important to emphasize that no classical algorithm has been found which runs in polynomial time, but it has \\emph{not} been proven that it is impossible for one to be found.\n\n\\paragraph{Example of period search}\n\n\\begin{equation}\n  f(x) = \\frac{1}{2} \\qty(\\cos \\pi x + 1)\n\\end{equation}\n\n\\[\n f:\n\\left|\n  \\begin{array}{rcl}\n    \\qty{0,1}^3 & \\longrightarrow & \\qty{0,1} \\\\\n    0,2,4,6 & \\longmapsto & 1 \\\\\n    1,3,5,7 & \\longmapsto & 0 \\\\\n  \\end{array}\n\\right.\n\\]\n\nAs always, we mix the notation for \\(n\\)-qubit states, \\(n\\)-bit numbers expressed in binary and in decimal.\n\nSo \\( N = 2^3 = 8 \\). \\( r=2 \\), \\( m = N/r = 4 \\).\n\n\\subparagraph{Step 1}\n\n\\begin{equation}\n  \\ket{\\psi _1 }  =  \\frac{1}{\\sqrt{8}} \\sum_{m=0} ^{7} \\ket{x}_1 \\ket{f(x)}_2\n\\end{equation}\n\n\\subparagraph{Step 2}\n\n\\begin{equation}\n  \\ket{\\psi_2} = \\frac{1}{2} \\qty(\\ket{1}+\\ket{3}+\\ket{5}+\\ket{7})_1 \\otimes \\ket{0}_2\n\\end{equation}\n\n\\subparagraph{Step 3}\n\nWe map \\( j \\rightarrow \\frac{1}{\\sqrt{8}} \\sum_k \\exp(2 \\pi i j k / 8) \\ket{k} \\)\n\n\n\\begin{subequations}\n\\begin{align}\n  \\ket{\\psi_3}\n  &= \\frac{1}{2 \\sqrt{8}} (\\ket{0} + e^{i \\pi/4} \\ket{1} \\\\\n  &+ \\dots + \\ket{0} + e^{3 i \\pi /4}\\ket{1})_1 \\otimes \\ket{0}_2 \\\\\n  &= \\frac{1}{\\sqrt{2}} \\qty(\\ket{0}+\\ket{4} )\n\\end{align}\n\\end{subequations}\n\nWe either measure 0 or 4. So, if it is 0 we have failed, if it is 4 we have \\( \\overline{y} = 4 \\), therefore \\( k=1 \\)  works and \\( r=2 \\).\n\n\\end{document}\n", "meta": {"hexsha": "d9d80398e1ae70068d826c06ecaaaf696e18da1c", "size": 6041, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "info_Q/montangero/montangero1.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "info_Q/montangero/montangero1.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "info_Q/montangero/montangero1.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 36.8353658537, "max_line_length": 224, "alphanum_fraction": 0.6207581526, "num_tokens": 2216, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4419058606969201}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\n\\onlyinsubfile{\n\\title{NeuroData SIMPLEX Report: Reduced Dimension Clustering}\n}\n\n\\begin{document}\n\\onlyinsubfile{\n\\maketitle\n\\thispagestyle{empty}\n\nThe following report documents the progress made by the labs of Randal~Burns and Joshua~T.~Vogelstein at Johns Hopkins University towards goals set by the DARPA SIMPLEX grant.\n\n%%%% Table of Contents\n\\tableofcontents\n\n%%%% Publications\n\\bibliographystyle{IEEEtran}\n\\begin{spacing}{0.5}\n\\section*{Publications, Presentations, and Talks}\n%\\vspace{-20pt}\n\\nocite{*}\n{\\footnotesize\t\\bibliography{simplex}}\n\\end{spacing}\n%%%% End Publications\n}\n\n\\subsection{Batch effect removal in dimension reduction of multiway array data}\n\nBatch effects are unwanted random variations caused by different data sources and experimental conditions. Generalized linear random effects model is effective to mitigate these confounders in traditional low dimensional data; however, there is a lack of such tool for high dimensional and multiway array data. While tensor factorization is routinely used for dimension reduction, due to the sharing of factors among all batches, the batch effects quickly populate the low dimensional core and confound the signal. In this research, we propose a different strategy by letting factor matrices vary over batches, while leaving the remaining variation in the core. This allows capturing sophisticated batch effects, while retaining the low rank structure for describing signal. To allow estimation with flexible factors, we utilize a hierarchical random effects model to borrow information among the batches. An efficient closed-form expectation conditional maxmization strategy is developed for rapid estimation. We focus the application on the joint diagonalization of brain connectivity data obtained from different sources.\n\nThe model we propose is:\n\n\\begin{equation}\n\\begin{aligned}\nA_{ji, kl} & =  A_{ji, lk}\\\\\nA_{ji, kl} & \\stackrel{indep}{\\sim} \\text{Bern}(\\text{logit}(\\psi_{ji,kl}))\\\\\n\\psi_{ji,kl} & = \\sum_{r=1}^{d} c_{ji, r} f_{j,kr} f_{j,lr}   \\\\\nf_{j,kr} & \\stackrel{indep}{\\sim}  \\text{N}(f_{0,kr}, \\sigma^2)\\\\\nf_{0,kr} & \\stackrel{iid}{\\sim} \\text{N}(0, 1)\n\\end{aligned}\n\\end{equation}\nwith $k=1\\ldots l$ and $l=2\\ldots n$.\n\nThe batch effect adjusted connectome is then $A_{ji, kl} = \\psi_{ji,kl} = \\sum_{r=1}^{d} c_{ji, r} f_{0,kr} f_{0,lr} $\n\\begin{figure}[h!]\n\\begin{cframed}\n\\centering\n\\includegraphics[width=0.455\\textwidth, clip = true,  trim = 0mm 15mm 0mm 10mm]{../../figs/avgA1}\n\\includegraphics[width=0.4635\\textwidth, clip = true, trim = 0mm 15mm 0mm 10mm ]{../../figs/avgA3}\n\\includegraphics[width=0.455\\textwidth, clip = true,  trim = 0mm 15mm 0mm 10mm]{../../figs/avgA1adjusted}\n\\includegraphics[width=0.4635\\textwidth, clip = true, trim = 0mm 15mm 0mm 10mm]{../../figs/avgA3adjusted}\n\\caption{The first row shows the average connectome of two groups, that some difference can be obsevered. The second row shows the batch effect adjusted average connectome of the two groups, that they become similar.}\n\\end{cframed}\n\\end{figure}\n\n\n\\end{document}\n", "meta": {"hexsha": "601b7e3ad81c56eeb77606aa42ac7a92da5993af", "size": 3176, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2017-01/batchEffectsRemoval.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2017-01/batchEffectsRemoval.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2017-01/batchEffectsRemoval.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0655737705, "max_line_length": 1124, "alphanum_fraction": 0.7610201511, "num_tokens": 907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.44190584718994735}}
{"text": "\\documentclass{article}\n \\usepackage[utf8]{inputenc}\n \\usepackage{graphicx}\n \\graphicspath{ {images/} }\n \\begin{document}\n\n \\title{ARTIFICIAL INTELLIGENCE EXAM}\n \\author{Course Code: 1DL340}\n \\date{Ref.  This is a student generated exam. }\n \\maketitle\n\n This exam has  18  questions for a total of  49  marks. Grade boundaries are:\n\n \\begin{center}\n 3 -  24.5 \n\n 4 -  32.5 \n\n 5 -  40.5 \n\n \\end{center}\n\n In exceptional circumstances these boundaries may be adjusted at the discretion of the examiner. This would be done on an exam-wide basis, NOT for individual students.\n\n You are permitted to make use of a calculator and language dictionary in this exam.\n\\clearpage\n\\section{A-Star}\n\nTable~\\ref{AStar_Edges} gives the edge values for a shortest path problem. Using these and the A* algorithm, find the shortest path from the start node to the goal node. Provide a valid heuristic and show all working. (4 marks)\n\n\\begin{table}[h!]\n\\caption{Edges}\n\\label{AStar_Edges}\n\\begin{center}\n\\begin{tabular}{ |c||c|c|c|c|c|c|c| } \n\\hline\n & Start & A & B & C & D & E & Goal\\\\\n\\hline\nStart & 0 & 5 & 4 & 0 & 0 & 0 & 0\\\\\nA & 0 & 0 & 6 & 0 & 6 & 0 & 0\\\\\nB & 0 & 0 & 0 & 7 & 0 & 0 & 0\\\\\nC & 0 & 0 & 0 & 0 & 2 & 0 & 0\\\\\nD & 0 & 0 & 0 & 0 & 0 & 7 & 0\\\\\nE & 0 & 0 & 0 & 0 & 0 & 0 & 3\\\\\nGoal & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{MCMC and Directed Graphical Models}\n\nTables~\\ref{MCMC1} to~\\ref{MCMC5} provide the conditional probability distributions for a directed graphical model.\n\nA. Use this information to draw the graph of the associated directed graphical model. (1 mark)\n\nB. Table~\\ref{MCMC6} provides observed values for some of the nodes. Given these, the initial values provided in Table~\\ref{MCMC7} and the random numbers provided below, use the Metropolis within Gibbs MCMC sampling algorithm to generate two complete samples of the variables. Assume that the candidate function gives the opposite of the current value. At each step, explain what value you are considering, what the current and candidate values are, and why you updated it or did not update it. (4 marks)\n\nRandom numbers: 0.839,0.753,0.534,0.923,0.72,0.739 \n\\begin{table}[h!]\n\\caption{P(A)}\n\\label{MCMC1}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n - & A=F & A=T\\\\\n\\hline\n & 0.75 & 0.25\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{P(B$|$A)}\n\\label{MCMC2}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n A & B=F & B=T\\\\\n\\hline\n A=F & 0.15 & 0.85\\\\\n A=T & 0.05 & 0.95\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{P(C$|$A)}\n\\label{MCMC3}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n A & C=F & C=T\\\\\n\\hline\n A=F & 0.2 & 0.8\\\\\n A=T & 0.35 & 0.65\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{P(D$|$B,C)}\n\\label{MCMC4}\n\\begin{center}\n\\begin{tabular}{ |c|c||c|c| } \n\\hline\n B & C & D=F & D=T\\\\\n\\hline\n B=F & C=F & 0.8 & 0.2\\\\\n B=F & C=T & 0.55 & 0.45\\\\\n B=T & C=F & 0.3 & 0.7\\\\\n B=T & C=T & 0.1 & 0.9\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{P(E$|$C)}\n\\label{MCMC5}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n C & E=F & E=T\\\\\n\\hline\n C=F & 0.25 & 0.75\\\\\n C=T & 0.2 & 0.8\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Observed Values}\n\\label{MCMC6}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n Node & Value \\\\\n\\hline\nD & FALSE\\\\\nE & FALSE\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Initial Values}\n\\label{MCMC7}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n Node  & Value \\\\\n\\hline\nA & TRUE\\\\\nB & TRUE\\\\\nC & TRUE\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{Hidden Markov Models: Forward-Backward Algorithm}\n\nTables~\\ref{hmmfb1} to~\\ref{hmmfb4} provide the transition matrix, emission matrix, initial state and a sequence of observations for a hidden Markov model. Use the forward-backward algorithm to calculate the probability distributions for the state of the system at times 0, 1 and 2 given the observations. Show all working. (4 marks)\n\n\\begin{table}[h!]\n\\caption{Transition Matrix}\n\\label{hmmfb1}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n $S_{t-1}$ & $S_t$=0 & $S_t$=1\\\\\n\\hline\n 0 & 0.3 & 0.7\\\\\n 1 & 0.9 & 0.1\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Emission Matrix}\n\\label{hmmfb2}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n $S$ & $E=0$ & $E=1$\\\\\n\\hline\n 0 & 0.1 & 0.9\\\\\n 1 & 0.2 & 0.8\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Initial State}\n\\label{hmmfb3}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n $S=0$ & $S=1$\\\\\n\\hline\n0.5 & 0.5\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Observations}\n\\label{hmmfb4}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n Time=1 & Time=2\\\\\n\\hline\nFALSE & TRUE\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{Hidden Markov Models: Viterbi Algorithm}\n\nTables~\\ref{hmmvit1} to~\\ref{hmmvit4} provide the transition matrix, emission matrix, initial state and a sequence of observations for a hidden Markov model. Use the Viterbi algorithm to calculate the most probable path and its probability. Show all working. (3 marks)\n\n\\begin{table}[h!]\n\\caption{Transition Matrix}\n\\label{hmmvit1}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n $S_{t-1}$ & $S_t$=0 & $S_t$=1\\\\\n\\hline\n 0 & 0.4 & 0.6\\\\\n 1 & 0.1 & 0.9\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Emission Matrix}\n\\label{hmmvit2}\n\\begin{center}\n\\begin{tabular}{ |c||c|c| } \n\\hline\n $S$ & $E=0$ & $E=1$\\\\\n\\hline\n 0 & 0.7 & 0.3\\\\\n 1 & 0.7 & 0.3\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Initial State}\n\\label{hmmvit3}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n $S=0$ & $S=1$\\\\\n\\hline\n0.5 & 0.5\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Observations}\n\\label{hmmvit4}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n Time=1 & Time=2\\\\\n\\hline\nTRUE & TRUE\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{Alpha-Beta Pruning}\n\nExamine the game tree included in this exam. Note that the values in the nodes are node indices, not mini-max values. Perform alpha-beta pruning on this game tree.  You should show all working, where this means all alpha-beta values.  You can write these values on the diagram, or alternatively on a separate sheet of paper.  In both cases, provide a way of identifying the sequence of updates to alpha-beta values associated with nodes (we suggest you just cross out old values and write new values sequentially downwards).  If you write on a separate sheet of paper, use the node indices in the diagram as a way of identifying which node particular alpha-beta values are associated with.  Show where pruning occurs, by indicating which branches will not be evaluated.  Finally, provide the result (value at end state) of the game assuming optimal play. (3 marks)\n\n\\begin{figure}[h!]\n\\includegraphics[width=\\textwidth]{ab.jpg}\n\\end{figure}\n\\clearpage\n\\section{Scheduling}\n\nProvide a complete resource constrained schedule for the actions found in Table~\\ref{schActions}. (4 marks)\n\\begin{table}[h!]\n\\caption{Actions}\n\\label{schActions}\n\\begin{center}\n\\begin{tabular}{ |c|c|c|c|c|c| } \n\\hline\n Index & Action & Duration & Uses & Consumes & After \\\\\n\\hline\n1 & Start & 0 &   & 0 nails & NA\\\\\n2 & Action 1 & 35 &  Saw & -1 nail & 1\\\\\n3 & Action 2 & 45 &  Saw & 0 nails & 1\\\\\n4 & Action 3 & 10 &   & -1 nail & 1\\\\\n5 & Action 4 & 15 &   & 0 nails & 4\\\\\n6 & Action 5 & 25 &   & 1 nail & 4,2,5\\\\\n7 & Action 6 & 50 &  Saw & 0 nails & 3,5\\\\\n8 & Action 7 & 40 &   & 1 nail & 3,2,4\\\\\n9 & Finish & 0 &   & 0 nails & 6,7,8\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{Multi-Armed Bandit Optimization}\n\nImage we are testing click through rates on three different web layouts. At the current point, the Dirichlet (beta) distributions associated with each layout have the parameters in Table~\\ref{MABO1}.\\begin{table}[h!]\n\\caption{Dirichlet (Beta) Parameters for Layout}\n\\label{MABO1}\n\\begin{center}\n\\begin{tabular}{ |c|c|c| } \n\\hline\n Layout & Parameter 1 & Parameter 2 \\\\\n\\hline\nA &  11  &  4 \\\\\nB &  8  &  3 \\\\\nC &  10  &  6 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\nThe first value is associated with not clicking through, the second clicking through.\n\nA new person views the site. We generate samples from the distributions to determine which layout is used. These samples are given in Table~\\ref{MABO2}.\n\\begin{table}[h!]\n\\caption{Samples from Layout Dirichlet (Beta) Distributions}\n\\label{MABO2}\n\\begin{center}\n\\begin{tabular}{ |c|c|c|c|c|c| } \n\\hline\n Layout & Sample 1 & Sample 2 & Sample 3 & Sample 4 & Sample 5 \\\\\n\\hline\nA &  0.25  &  0.15  &  0.31  &  0.29  &  0.39 \\\\\nA &  0.25  &  0.14  &  0.22  &  0.26  &  0.26 \\\\\nA &  0.2  &  0.19  &  0.32  &  0.48  &  0.18 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\n\nWhen shown the website with the chosen layout, the person makes a purchase ('clicks through'). Give the new parameters of the three distributions after this event. (2 Marks)\n\\clearpage\n\\section{Basic Feed-Forward ANNs}\n\nExamine the neural network given in the diagram labelled 'Basic Regression Feed-Forward Neural Network'. In this diagram, square nodes represent biases, blue nodes the input layer, green nodes a hidden layer, and red nodes the output layer. The first round blue input node is associated with feature X1, and the second with feature X2 (counting downwards). Assuming that all activation functions are rectifiers (i.e. the hidden nodes are ReLU units), and the output is a basic linear regression function, calculate the output of this network if it was given an input of X1 = 5 and X2 = -5. Show all working. (2 Marks)\n\n\\begin{figure}[h!]\n\\includegraphics[width=\\textwidth]{ffnn.jpg}\n\\end{figure}\n\\clearpage\n\\section{Convolution layers in CNNs}\n\nTables~\\ref{CNN1} to~\\ref{CNN3} provide an input matrix and two filter matrices for a convolutional layer in a CNN. Assuming no padding, that stride is [1,1], and that all activation functions are rectifiers, calculate the output of this layer. (2 marks)\n\\begin{table}[h!]\n\\caption{Input Matrix}\n\\label{CNN1}\n\\begin{center}\n\\begin{tabular}{ |c|c|c| } \n\\hline\n-3  &  -2  &  1 \\\\\n-3  &  4  &  -3 \\\\\n-2  &  -4  &  0 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Filter 1}\n\\label{CNN2}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n4  &  -4 \\\\\n1  &  2 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\begin{table}[h!]\n\\caption{Filter 1}\n\\label{CNN3}\n\\begin{center}\n\\begin{tabular}{ |c|c| } \n\\hline\n-2  &  -2 \\\\\n3  &  -4 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\\clearpage\n\\section{ Bias-Variance }\n\nGive a basic explanation (as per what was discussed in the course) of the bias and variance components of expected error and their relationship to model complexity. (3 marks)\n\\clearpage\n\\section{ Reinforcement Learning }\n\nWhat is the purpose of including randomness in the action-deciding process of a reinforcement learning system? (1 mark)\\clearpage\n\\section{ LSTMs }\n\nExplain the steps involving the memory vector in a pass through a LSTM layer at time t. Mention what is done to the memory vector (non-mathematically) and/or what the memory vector is used for in each of these steps. Make reference to the input at time t, and the outputs of time t-1 and t. (2 marks)\\clearpage\n\\section{ Local Search }\n\nGreedy Hill Climb suffers from the problem of local optima. Name and provide a brief explanation of three alternative local search strategies covered in this course that attempt to overcome or minimize this problem. (3 marks)\n\\clearpage\n\\section{ Planning Graphs }\n\nExplain the two ways a planning graph can be used to provide a heuristic for A*. (2 marks)\n\\clearpage\n\\section{ Depth-First Search }\n\nUnder what conditions could a depth-first search FAIL to find a solution (in a finite search space with at most a single edge between any two nodes)? (1 mark)\\clearpage\n\\section{ PDDL }\n\nWhat is PDDL? Explain all components of a PDDL problem. Be as precise and concise as possible.  (4 marks)\n\\clearpage\n\\section{ Iterated Deepening }\n\nExplain iterated deepening. (2 marks)\n\\clearpage\n\\section{ GANs }\n\nAssume you have a GAN where the discriminator network is a simple binary (Genuine/Fake) classifier. Briefly explain how the generator network is trained. (2 marks)\n\n\\end{document}\n", "meta": {"hexsha": "f07108cc69587fc0d5f9da9bd0d2dee94e577095", "size": 12471, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Test.tex", "max_stars_repo_name": "mickash/Automated-AI-Exam", "max_stars_repo_head_hexsha": "7da6d776b1f1414a06ad61a7f0948ac685f38a3d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Test.tex", "max_issues_repo_name": "mickash/Automated-AI-Exam", "max_issues_repo_head_hexsha": "7da6d776b1f1414a06ad61a7f0948ac685f38a3d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Test.tex", "max_forks_repo_name": "mickash/Automated-AI-Exam", "max_forks_repo_head_hexsha": "7da6d776b1f1414a06ad61a7f0948ac685f38a3d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-10T14:44:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-10T14:44:45.000Z", "avg_line_length": 28.6689655172, "max_line_length": 864, "alphanum_fraction": 0.6901611739, "num_tokens": 4385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8080672181749422, "lm_q1q2_score": 0.44180117754431564}}
{"text": "\\chapter{Algebraic integers}\nHere's a first taste of algebraic number theory.\n\nThis is really close to the border between olympiads and higher math.\nYou've always known that $a+\\sqrt2 b$ had a ``norm'' $a^2-2b^2$,\nand that somehow this norm was multiplicative.\nYou've also always known that roots come in conjugate pairs.\nYou might have heard of minimal polynomials but not know much about them.\n\nThis chapter and the next one will make all these vague notions precise.\nIt's drawn largely from the first chapter of \\cite{ref:oggier_NT}.\n\n\\section{Motivation from high school algebra}\nThis is adapted from my blog, \\emph{Power Overwhelming}\\footnote{URL: \\url{https://usamo.wordpress.com/2014/10/19/why-do-roots-come-in-conjugate-pairs/}}.\n\nIn high school precalculus, you'll often be asked to find the roots of some polynomial with integer coefficients.\nFor instance,\n\\[ x^3 - x^2 - x - 15 = (x-3)(x^2+2x+5) \\]\nhas roots $3$, $-1+2i$, $-1-2i$.\nOr as another example, \n\\[ x^3 - 3x^2 - 2x + 2 = (x+1)(x^2-4x+2) \\]\nhas roots $-1$, $2 + \\sqrt 2$, $2 - \\sqrt 2$.\nYou'll notice that the irrational roots, like $-1 \\pm 2i$ and $2 \\pm \\sqrt 2$, are coming up in pairs. In fact, I think precalculus explicitly tells you that the imaginary roots come in conjugate pairs. More generally, it seems like all the roots of the form $a + b \\sqrt c$ come in ``conjugate pairs''. And you can see why.\n\nBut a polynomial like\n\\[ x^3 - 8x + 4 \\]\nhas no rational roots.\n(The roots of this are approximately $-3.0514$, $0.51730$, $2.5341$.)\nOr even simpler,\n\\[ x^3 - 2 \\]\nhas only one real root, $\\sqrt[3]{2}$.\nThese roots, even though they are irrational, have no ``conjugate'' pairs.\nOr do they?\n\nLet's try and figure out exactly what's happening.\nLet $\\alpha$ be any complex number.\nWe define the \\vocab{minimal polynomial} of $\\alpha$ over $\\QQ$ to be the polynomial such that\n\\begin{itemize}\n\t\\item $P(x)$ has rational coefficients, and leading coefficient $1$,\n\t\\item $P(\\alpha) = 0$.\n\t\\item The degree of $P$ is as small as possible.\n\t\tWe call $\\deg P$ the \\vocab{degree} of $\\alpha$.\n\\end{itemize}\n\\begin{example}[Examples of minimal polynomials]\n\t\\listhack\n\t\\begin{enumerate}[(a)]\n\t\\ii $\\sqrt 2$ has minimal polynomial $x^2-2$.\n\t\\ii The imaginary unit $i = \\sqrt{-1}$ has minimal polynomial $x^2+1$.\n\t\\ii A primitive $p$th root of unity, $\\zeta_p = e^{\\frac{2\\pi i}{p}}$, has minimal polynomial $x^{p-1} + x^{p-2} + \\dots + 1$, where $p$ is a prime.\n\t\\end{enumerate}\n\\end{example}\nNote that $100x^2 - 200$ is also a polynomial of the same degree which has $\\sqrt 2$ as a root; that's why we want to require the polynomial to be monic. That's also why we choose to work in the rational numbers; that way, we can divide by leading coefficients without worrying if we get non-integers.\n\nWhy do we care? The point is as follows: suppose we have another polynomial $A(x)$ such that $A(\\alpha) = 0$.\nThen we claim that $P(x)$ actually divides $A(x)$!\nThat means that all the other roots of $P$ will also be roots of $A$.\n\nThe proof is by contradiction: if not, by polynomial long division we can find a quotient and remainder $Q(x)$, $R(x)$ such that\n\\[ A(x) = Q(x) P(x) + R(x) \\]\nand $R(x) \\not\\equiv 0$.\nNotice that by plugging in $x = \\alpha$, we find that $R(\\alpha) = 0$.\nBut $\\deg R < \\deg P$, and $P(x)$ was supposed to be the minimal polynomial.\nThat's impossible!\n\nLet's look at a more concrete example.\nConsider $A(x) = x^3-3x^2-2x+2$ from the beginning. \nThe minimal polynomial of $2 + \\sqrt 2$ is $P(x) = x^2 - 4x + 2$ (why?).\nNow we know that if $2 + \\sqrt 2$ is a root, then $A(x)$ is divisible by $P(x)$.\nAnd that's how we know that if $2 + \\sqrt 2$ is a root of $A$, then $2 - \\sqrt 2$ must be a root too.\n\nAs another example, the minimal polynomial of $\\sqrt[3]{2}$ is $x^3-2$. So $\\sqrt[3]{2}$ actually has \\textbf{two} conjugates, namely, $\\alpha = \\sqrt[3]{2} \\left( \\cos 120^\\circ + i \\sin 120^\\circ \\right)$ and $\\beta = \\sqrt[3]{2} \\left( \\cos 240^\\circ + i \\sin 240^\\circ \\right)$. Thus any polynomial which vanishes at $\\sqrt[3]{2}$ also has $\\alpha$ and $\\beta$ as roots!\n\n\\begin{ques}\n\t[Important but tautological:\n\tirreducible $\\iff$ minimal]\n\tLet $\\alpha$ be a root of the polynomial $P(x)$.\n\tShow that $P(x)$ is the minimal polynomial\n\tif and only if it is irreducible.\n\t% (This is tautological: the point is just to realize that ``minimal polynomials'' and ``irreducible polynomials'' are the same beasts.)\n\\end{ques}\n\n\\section{Algebraic numbers and algebraic integers}\n\\prototype{$\\sqrt2$ is an algebraic integer (root of $x^2-2$),\n$\\half$ is an algebraic number but not an algebraic integer (root of $x-\\half$).}\n\nLet's now work in much vaster generality.\nFirst, let's give names to the new numbers we've discussed above.\n\\begin{definition}\n\tAn \\vocab{algebraic number} is any $\\alpha \\in \\CC$\n\twhich is the root of \\emph{some} polynomial with coefficients in $\\QQ$.\n\tThe set of algebraic numbers is denoted $\\ol\\QQ$.\n\\end{definition}\n\\begin{remark}\n\tOne can equally well say algebraic numbers are those of which \n\tare roots of some polynomial with coefficients in $\\ZZ$ (rather than $\\QQ$),\n\tsince any polynomial in $\\QQ[x]$ can be scaled to one in $\\ZZ[x]$.\n\\end{remark}\n\\begin{definition}\n\tConsider an algebraic number $\\alpha$ and\n\tits minimal polynomial $P$\n\t(which is monic and has rational coefficients).\n\tIf it turns out the coefficients of $P$ are integers,\n\tthen we say $\\alpha$ is an \\vocab{algebraic integer}.\n\n\tThe set of algebraic integers is denoted $\\ol\\ZZ$.\n\\end{definition}\n\\begin{remark}\n\tOne can show, using \\emph{Gauss's Lemma}, that if $\\alpha$ is the root\n\tof \\emph{any} monic polynomial with integer coefficients,\n\tthen $\\alpha$ is an algebraic integer.\n\tSo in practice, if I want to prove that $\\sqrt 2 + \\sqrt 3$ is an algebraic integer,\n\tthen I only have to say ``the polynomial $(x^2-5)^2-24$ works''\n\twithout checking that it's minimal.\n\\end{remark}\nSometimes for clarity, we refer to elements of $\\ZZ$\nas \\vocab{rational integers}.\n\\begin{example}[Examples of algebraic integers]\n\tThe numbers\n\t\\[ 4, \\; i = \\sqrt{-1}, \\; \\sqrt[3]{2}, \\; \\sqrt2+\\sqrt3 \\]\n\tare all algebraic integers, since they are the roots of the monic polynomials\n\t$x-4$, $x^2+1$, $x^3-2$ and $(x^2-5)^2-24$.\n\n\tThe number $\\half$ has minimal polynomial $x - \\half$,\n\tso it's an algebraic number but not an algebraic integer.\n\t(In fact, the rational root theorem also directly implies\n\tthat any monic integer polynomial does not have $\\half$ as a root!)\n\\end{example}\n\nThere are two properties I want to give\nfor these off the bat,\nbecause they'll be used extensively in the tricky\n(but nice) problems at the end of the section.\nThe first we prove now, since it's very easy:\n\\begin{proposition}[Rational algebraic integers are rational integers]\n\tAn algebraic integer is rational\n\tif and only if it is a rational integer.\n\tIn symbols, \\[ \\ol\\ZZ \\cap \\QQ = \\ZZ. \\]\n\\end{proposition}\n\\begin{proof}\n\tLet $\\alpha$ be a rational number.\n\tIf $\\alpha$ is an integer, it is the root of $x-\\alpha$,\n\thence an algebraic integer too.\n\n\tConversely, if $P$ is a monic polynomial with integer\n\tcoefficients such that $P(\\alpha) = 0$ then\n\t(by the rational root theorem, say)\n\tit follows $\\alpha$ must be an integer.\n\\end{proof}\nThe other is that:\n\\begin{proposition}\n\t[$\\ol{\\ZZ}$ is a ring and $\\ol{\\QQ}$ is a field]\n\tThe algebraic integers $\\ol{\\ZZ}$ form a ring.\n\tThe algebraic numbers $\\ol{\\QQ}$ form a field.\n\\end{proposition}\nWe could prove this now if we wanted to,\nbut the results in the next chapter will more or less\ndo it for us, and so we take this on faith temporarily.\n\n\\section{Number fields}\n\\prototype{$\\QQ(\\sqrt2)$ is a typical number field.}\n\nGiven any algebraic number $\\alpha$,\nwe're able to consider fields of the form $\\QQ(\\alpha)$.\nLet us write down the more full version.\n\n\\begin{definition}\n\tA \\vocab{number field} $K$ is a field containing $\\QQ$ as a subfield\n\twhich is a \\emph{finite-dimensional} $\\QQ$-vector space.\n\tThe \\vocab{degree} of $K$ is its dimension.\n\\end{definition}\n\\begin{example}[Prototypical example]\n\tConsider the field\n\t\\[ K = \\QQ(\\sqrt2) = \\left\\{ a+b\\sqrt2 \\mid a,b \\in \\QQ \\right\\}. \\]\n\tThis is a field extension of $\\QQ$,\n\tand has degree $2$ (the basis being $1$ and $\\sqrt2$).\n\\end{example}\n\nYou might be confused that I wrote $\\QQ(\\sqrt2)$\n(which should permit denominators) instead of $\\QQ[\\sqrt2]$, say.\nBut if you read through \\Cref{ex:gaussian_rationals},\nyou should see that the denominators don't really matter:\n$\\frac{1}{3-\\sqrt2} = \\frac17(3+\\sqrt2)$ anyways, for example.\nYou can either check this now in general,\nor just ignore the distinction and pretend I wrote square brackets everywhere.\n\\begin{exercise}\n\t[Unimportant]\n\tShow that if $\\alpha$ is an algebraic number,\n\tthen $\\QQ(\\alpha) \\cong \\QQ[\\alpha]$.\n\\end{exercise}\n\n\\begin{example}[Adjoining an algebraic number]\n\tLet $\\alpha$ be the root of some irreducible polynomial $P(x)$ in $\\QQ$.\n\tThe field $\\QQ(\\alpha)$ is a field extension as well, and the basis\n\tis $1, \\alpha, \\alpha^2, \\dots, \\alpha^{m-1}$,\n\twhere $m$ is the degree of $\\alpha$.\n\tIn particular, the degree of $\\QQ(\\alpha)$ is just the degree of $\\alpha$.\n\\end{example}\n\\begin{example}[Non-examples of number fields]\n\t$\\RR$ and $\\CC$ are not number fields since there is no \\emph{finite}\n\t$\\QQ$-basis of them.\n\\end{example}\n\n\\section{Primitive element theorem, and monogenic extensions}\n\\prototype{$\\QQ(\\sqrt3,\\sqrt5) \\cong \\QQ(\\sqrt3+\\sqrt5)$. Can you see why?}\n\nI'm only putting this theorem here because I was upset that no one\ntold me it was true (it's a very natural conjecture),\nand I hope to not do the same to the reader.\nHowever, I'm not going to use it in anything that follows.\n\n\\begin{theorem}\n\t[Artin's primitive element theorem]\n\tEvery number field $K$ is isomorphic to $\\QQ(\\alpha)$\n\tfor some algebraic number $\\alpha$.\n\t\\label{thm:artin_primitive_elm}\n\\end{theorem}\nThe proof is left as \\Cref{prob:artin_primitive_elm}, since to prove it I need to talk\nabout field extensions first.\n\nThe prototypical example \\[ \\QQ(\\sqrt3,\\sqrt5) \\cong \\QQ(\\sqrt3+\\sqrt5) \\]\nmakes it clear why this theorem should not be too surprising.\n%To see why this is true, note that $K$ contains the element\n%\\[ \\left( \\sqrt3+\\sqrt5 \\right)^2-8 = 2\\sqrt15 \\]\n%and hence also the element $2(\\sqrt15)(\\sqrt3+\\sqrt5) = 6\\sqrt5+10\\sqrt3$.\n%Thus from the fact that $6\\sqrt5+10\\sqrt3$ and $\\sqrt3+\\sqrt5$ are in $K$,\n%we can extract both $\\sqrt 3$ and $\\sqrt 5$.\n%Thus $\\sqrt3, \\sqrt5 \\in K$, which is what we wanted.\n\n\\section{\\problemhead}\n\n\\begin{problem}\n\tFind a polynomial with integer coefficients\n\twhich has $\\sqrt2+\\sqrt[3]{3}$ as a root.\n\\end{problem}\n\n\\begin{problem}\n\t[Brazil 2006]\n\t\\gim\n\tLet $p$ be an irreducible polynomial in $\\QQ[x]$\n\tand degree larger than $1$.\n\tProve that if $p$ has two roots $r$ and $s$ whose product is $1$\n\tthen the degree of $p$ is even.\n\t\\begin{hint}\n\t\tNote that $p(x)$ is a minimal polynomial for $r$,\n\t\tbut so is $q(x) = x^{\\deg p} p(1/x)$.\n\t\tSo $q$ and $p$ must be multiples of each other.\n\t\\end{hint}\n\\end{problem}\n\n\\begin{sproblem}\n\t\\label{prob:rep_lemma}\n\tConsider $n$ roots of unity $\\eps_1$, \\dots, $\\eps_n$.\n\tAssume the average $\\frac1n(\\eps_1 + \\dots + \\eps_n)$ is an algebraic integer.\n\tProve that either the average is zero or $\\eps_1 = \\dots = \\eps_n$.\n\t(Used in \\Cref{lem:burnside_ant_lemma}.)\n\t\\begin{hint}\n\t\t$\\left\\lvert \\frac 1n(\\eps_1 + \\dots + \\eps_n) \\right\\rvert \\le 1$.\n\t\\end{hint}\n\\end{sproblem}\n\n\\begin{dproblem}\n\t\\gim\n\tWhich rational numbers $q$ satisfy $\\cos(q\\pi) \\in \\QQ$?\n\t\\begin{hint}\n\t\tOnly the obvious ones.\n\t\tAssume $\\cos(q\\pi) \\in \\QQ$.\n\t\tLet $\\zeta$ be a root of unity (algebraic integer\n\t\tas $\\zeta^N-1 = 0$ for some $N$)\n\t\tand note that $2\\cos(q\\pi) = \\zeta + \\zeta^{N-1}$\n\t\tis both an algebraic integer and a rational number.\n\t\\end{hint}\n\\end{dproblem}\n\n\\begin{problem}\n\t[MOP 2010]\n\tThere are $n > 2$ lamps arranged in a circle;\n\tinitially one is on and the others are off.\n\tWe may select any regular polygon whose vertices are among the lamps\n\tand toggle the states of all the lamps simultaneously.\n\tShow it is impossible to turn all lamps off.\n\t\\begin{hint}\n\t\tView as roots of unity. Note $\\half$ isn't an algebraic integer.\n\t\\end{hint}\n\\end{problem}\n\n\\begin{problem}[Kronecker's theorem]\n\t\\yod\n\tLet $\\alpha$ be an algebraic integer.\n\tSuppose all its Galois conjugates have absolute value one.\n\tProve that $\\alpha^N=1$ for some positive integer $N$.\n\t\\begin{hint}\n\t\tLet $\\alpha = \\alpha_1$, $\\alpha_2$, \\dots, $\\alpha_n$ be its conjugates.\n\t\tLook at the polynomial $(x-\\alpha_1^e) \\dots (x-\\alpha_n^e)$ across $e \\in \\NN$.\n\t\tPigeonhole principle on all possible polynomials.\n\t\\end{hint}\n\\end{problem}\n\n\\begin{problem}\n\t\\yod\n\tIs there an algebraic integer with absolute value one\n\twhich is not a root of unity?\n\\end{problem}\n\n\\begin{problem}\n\tIs the ring of algebraic integers Noetherian?\n\\end{problem}\n", "meta": {"hexsha": "29c4acabe26842fd6b2151184b5f036b0fcee088", "size": 12846, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "corpus/napkin/tex/alg-NT/numfield.tex", "max_stars_repo_name": "aDotInTheVoid/ltxmk", "max_stars_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "corpus/napkin/tex/alg-NT/numfield.tex", "max_issues_repo_name": "aDotInTheVoid/ltxmk", "max_issues_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "corpus/napkin/tex/alg-NT/numfield.tex", "max_forks_repo_name": "aDotInTheVoid/ltxmk", "max_forks_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.8436482085, "max_line_length": 374, "alphanum_fraction": 0.7032539312, "num_tokens": 3984, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8080672158638528, "lm_q1q2_score": 0.4418011762807549}}
{"text": "\n\\subsection{Recap}\n\nIn the multinomial logit model we had:\n\n\\(P_{ij}=\\dfrac{e^{\\Theta z_j}}{1+\\sum_{k=1} e^{\\Theta z_k }}\\)\n\n\\subsection{Adding customer characteristics}\n\nIf \\(z_j\\) just includes product characteristics then we have homogeneous preferences.\n\nWe can include customer level data in \\(z_j\\), for example individual income, location, age etc.\n\n\\subsection{Estimation}\n\nAs before, we want product characteristics and prices.\n\nHowever rather than market share we instead use customer level  information.\n\n", "meta": {"hexsha": "15a1b1402a1d87cec58949c7d3ad12a52e879478", "size": 517, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/consumerDiscrete/05-01-discreteCharacteristics.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/consumerDiscrete/05-01-discreteCharacteristics.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/consumerDiscrete/05-01-discreteCharacteristics.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.85, "max_line_length": 96, "alphanum_fraction": 0.7601547389, "num_tokens": 124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.546738151984614, "lm_q1q2_score": 0.4418011699629508}}
{"text": "\\chapter{Lecture 13 May 30th 2018}%\n\\label{chp:lecture_13_may_30th_2018}\n% chapter lecture_13_may_30th_2018\n\n\\section{Isomorphism Theorems (Continued)}%\n\\label{sec:isomorphism_theorems_continued}\n% section isomorphism_theorems_continued\n\n\\subsection{Quotient Groups (Continued)}%\n\\label{sub:quotient_groups_continued}\n% subsection quotient_groups_continued\n\n\\begin{propo}\n\\label{propo:propo_related_to_quotient_groups}\n  Let $K \\triangleleft G$ and write $\\faktor{G}{K} = \\{Ka \\, : \\, a \\in G\\}$ for the set of cosets of $K$.\n  \\begin{enumerate}\n    \\item $\\faktor{G}{K}$ is a group under the operation $Ka Kb = Kab$.\n    \\item The mapping $\\phi : G \\to \\faktor{G}{K}$ given by $\\phi(a) = Ka$ is a surjective homomorphism.\\sidenote{\n    \\begin{ex}\n      Is $\\phi$ injective?\n    \\end{ex}\n\n    \\begin{solution}\n      We know that we cannot uniquely express a coset, since for $a, b \\in Ka$ such that $a \\neq b$, we have that $Ka = Kb$.\n    \\end{solution}\n    }\n    \\item If $[G : K]$ is finite, then $\\abs{\\faktor{G}{K}} = [G : K]$. In particular, if $\\abs{G}$ is finite, then $\\abs{\\faktor{G}{K}} = \\frac{\\abs{G}}{\\abs{K}}$.\n  \\end{enumerate}\n\\end{propo}\n\n\\begin{proof}\n  \\begin{enumerate}\n    \\item By \\cref{lemma:multiplication_of_cosets_of_normal_subgroups}, the operation is well-defined, and $\\faktor{G}{K}$ is closed under the operation. The identity of $\\faktor{G}{K}$ is $K = K(1)$ since $\\forall Ka \\in \\faktor{G}{K}$,\n      \\begin{equation*}\n        Ka K(1) = Ka = K(1) Ka.\n      \\end{equation*}\n      Also, since\n      \\begin{equation*}\n        Ka Ka^{-1} = K(1) = Ka^{-1} Ka,\n      \\end{equation*}\n      the inverse of $Ka$ is $Ka^{-1}$. Finally, by associativity of $G$, we have that\n      \\begin{equation*}\n        Ka(KbKc) = Kabc = (KaKb)Kc.\n      \\end{equation*}\n      It follows that $\\faktor{G}{K}$ is a group.\n\n    \\item Clearly, $\\phi$ is surjective. For $a, b \\in G$,\n      \\begin{equation*}\n        \\phi(ab) = Kab = Ka Kb = \\phi(a) \\phi(b).\n      \\end{equation*}\n      Thus $\\phi$ is a surjective homomorphism.\n\n    \\item If $[G : K]$ is finite, then by definition of the index $[G : K]$, we have that $[G : K] = \\abs{\\faktor{G}{K}}$. Also, if $\\abs{G}$ is finite, then by \\cref{thm:lagrange_s_theorem},\n      \\begin{equation*}\n        \\abs{\\faktor{G}{K}} = [G : K] = \\frac{\\abs{G}}{\\abs{K}}.\n      \\end{equation*}\n  \\end{enumerate}\\qed\n\\end{proof}\n\n\\begin{defn}[Quotient Group]\\index{Quotient Group}\\index{Coset Map}\\index{Quotient Map}\n\\label{defn:quotient_group}\n  Let $K \\triangleleft G$. The group $\\faktor{G}{K}$ of all cosets of $K$ in $G$ is called the \\hlnoteb{quotient group} of $G$ by $K$. Also, the mapping\n  \\begin{equation*}\n    \\phi: G \\to \\faktor{G}{K} \\text{ defined by } a \\mapsto Ka\n  \\end{equation*}\n  is called the \\hlnoteb{coset} (or \\hlnoteb{quotient}) \\hlnoteb{map}.\n\\end{defn}\n\n% subsection quotient_groups_continued (end)\n\n\\subsection{Isomorphism Theorems}%\n\\label{sub:isomorphism_theorems}\n% subsection isomorphism_theorems\n\n\\begin{defn}[Kernel and Image]\\index{Kernel}\\index{Image of a Homomorphism}\n\\label{defn:kernel_and_image}\n  Let $\\alpha: G \\to H$ be a group homomorphism. The \\hlnoteb{kernel} of $\\alpha$ is defined by\n  \\begin{equation*}\n    \\ker \\alpha := \\{g \\in G \\, : \\, \\alpha(g) = 1_H \\} \\subseteq G\n  \\end{equation*}\n  and the image of $\\alpha$ is defined by\n  \\begin{equation*}\n    \\img \\alpha := \\alpha(G) = \\{\\alpha(g) \\, : \\, g \\in G \\} \\subseteq H.\n  \\end{equation*}\n\\end{defn}\n\n\\begin{propo}\n\\label{propo:image_of_hm_is_a_subgroup_n_kernel_of_hm_is_a_normal_subgroup}\n  Let $\\alpha : G \\to H$ be a group homomorphism.\n  \\begin{enumerate}\n    \\item $\\img \\alpha$ is a subgroup of $H$\n    \\item $\\ker \\alpha \\triangleleft G$\n  \\end{enumerate}\n\\end{propo}\n\n\\begin{proof}\n  \\begin{enumerate}\n    \\item Note that $1_H = \\alpha(1_G) \\in \\alpha(G)$ (i.e. the identity is in $\\img \\alpha$). Also, for $h_1 = \\alpha(g_1)$ and $h_2 = \\alpha(g_2)$ in $\\alpha(G)$ and $h_1, h_2 \\in H$, we have\n      \\begin{equation*}\n        h_1 h_2 = \\alpha(g_1) \\alpha(g_2) = \\alpha(g_1 g_2) \\in \\alpha(G).\n      \\end{equation*}\n      (i.e. $\\img \\alpha$ i closed under its operation). By \\cref{propo:properties_of_homomorphism}, $\\alpha(g)^{-1} = \\alpha(g^{-1}) \\in \\alpha(G)$ (i.e. the inverse of an element is also in $\\img \\alpha$). Thus by the \\hlnotea{Subgroup Test}, we have that $\\img \\alpha$ is a subgroup of $H$.\n\n    \\item For $\\ker \\alpha$, $\\alpha(1_G) = 1_H$. For $k_1, k_2 \\in \\ker \\alpha$, we have\n      \\begin{equation*}\n        \\alpha(k_1 k_2) = \\alpha(k_1) \\alpha(k_2) = 1 \\cdot 1 = 1.\n      \\end{equation*}\n      Also,\n      \\begin{equation*}\n        \\alpha(k_1^{-1}) = \\alpha(k_1)^{-1} = 1^{-1} = 1.\n      \\end{equation*}\n      By the \\hlnotea{Subgroup Test}, $\\ker \\alpha$ is a subgroup of $G$.\n\n      If $g \\in G$ and $k \\in \\ker \\alpha$, then\n      \\begin{equation*}\n        \\alpha(gkg^{-1}) = \\alpha(g) \\alpha(k) \\alpha(g^{-1}) = \\alpha(g) \\alpha(g^{-1}) = 1.\n      \\end{equation*}\n      Thus by \\cref{propo:normality_test}, $\\ker \\alpha \\triangleleft G$.\n  \\end{enumerate}\\qed\n\\end{proof}\n\n\\begin{eg}\n  Consider the determinant map\n  \\begin{equation*}\n    \\det : GL_n(\\mathbb{R}) \\to \\mathbb{R}^* \\text{ defined by } A \\mapsto \\det A.\n  \\end{equation*}\n  Then $\\ker \\det = SL_n(\\mathbb{R})$. Then $SL_n(\\mathbb{R}) \\triangleleft GL_n(\\mathbb{R})$, as proven before.\n\\end{eg}\n\n\\begin{eg}\n  Define the \\hldefn{sign of a permutation} $\\sigma \\in S_n$ by\n  \\begin{equation*}\n    \\sign(\\sigma) = \\begin{cases}\n      1 & \\text{if } \\sigma \\text{ is even;} \\\\\n      -1 & \\text{if } \\sigma \\text{ is odd.}\n    \\end{cases}\n  \\end{equation*}\n  Then the sign mapping, $\\sign : S_n \\to \\{\\pm 1\\}$ defined by $\\sigma \\mapsto \\sign(\\sigma)$ is a homomorphism.\\sidenote{Think about why. It's quite straightforward using the defintion.} Also, $\\ker \\sign = A_n$. Thus, we have $A_n \\triangleleft S_n$, as proven before.\n\\end{eg}\n\n\\begin{propo}[Normal Subgroup as the Kernel]\n\\label{propo:normal_subgroup_as_the_kernel}\n  If $K \\triangleleft G$, then $K = \\ker \\phi$ where $\\phi : G \\to \\faktor{G}{K}$ is the coset map.\n\\end{propo}\n\n\\begin{proof}\n  Recall that $\\phi : G \\to \\faktor{G}{K}$ is defined by $g \\mapsto Kg$, $\\forall g \\in G$, and is a group homomorphism. By \\cref{propo:properties_of_cosets}, we have\n  \\begin{equation*}\n    Kg = K = K1 \\iff g \\in K.\n  \\end{equation*}\n  Thus $K = \\ker \\phi$.\\qed\n\\end{proof}\n\n\\begin{thm}[First Isomorphism Theorem]\n\\index{First Isomorphism Theorem}\n\\label{thm:first_isomorphism_theorem}\n  Let $\\alpha: G \\to H$ be a group homomorphism. We have\n  \\begin{equation*}\n    \\faktor{G}{\\ker \\alpha} \\cong \\img \\alpha\n  \\end{equation*}\n\\end{thm}\n\n\\begin{proof}\n  Let $K = \\ker \\alpha$. Since $K \\triangleleft G$ (by \\cref{propo:image_of_hm_is_a_subgroup_n_kernel_of_hm_is_a_normal_subgroup}), $\\faktor{G}{K}$ is a group. Let\\sidenote{We must check that the function is well-defined, since cosets are not uniquely represented and so it is likely that a constructed mapping is not well-defined.}\n  \\begin{equation*}\n    \\bar{\\alpha} : \\faktor{G}{K} \\to \\img \\alpha \\text{ be defined by } Kg \\mapsto \\alpha(g)\n  \\end{equation*}\n  Note that\n  \\begin{equation*}\n    Kg = Kg_1 \\iff gg_1^{-1} \\in K \\iff \\alpha(gg_1^{-1}) = 1 \\iff \\alpha(g) = \\alpha(g_1).\n  \\end{equation*}\n  Thus $\\bar{ \\alpha }$ is well-defined and injective. Clearly, $\\bar{ \\alpha }$ is surjective. It remains to show that $\\bar{\\alpha}$ is a group homomorphism. $\\forall g, h \\in G$, we have\n  \\begin{equation*}\n    \\bar{\\alpha}(Kg Kh) = \\bar{\\alpha}(Kgh) = \\alpha(gh) = \\alpha(g) \\alpha(h) = \\bar{\\alpha}(Kg) \\bar{\\alpha}(Kh).\n  \\end{equation*}\n  Therefore, we have that $\\bar{\\alpha}$ is an isomorphism and hence $\\faktor{G}{\\ker \\alpha} \\cong \\img \\alpha$ as desired. \\qed\n\\end{proof}\n\n% subsection isomorphism_theorems (end)\n\n% section isomorphism_theorems_continued (end)\n\n% chapter lecture_13_may_30th_2018 (end)\n", "meta": {"hexsha": "ce1b6bdb7f6fefc74a922d83875aa56061d9e6a0", "size": 7877, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PMATH347S18/lectures/lec13.tex", "max_stars_repo_name": "japorized/TeX_notes", "max_stars_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-09-28T21:23:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-21T01:41:27.000Z", "max_issues_repo_path": "PMATH347S18/lectures/lec13.tex", "max_issues_repo_name": "japorized/TeX_notes", "max_issues_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-29T17:58:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-29T17:58:51.000Z", "max_forks_repo_path": "PMATH347S18/lectures/lec13.tex", "max_forks_repo_name": "japorized/TeX_notes", "max_forks_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-09-27T20:55:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-27T20:55:58.000Z", "avg_line_length": 42.8097826087, "max_line_length": 332, "alphanum_fraction": 0.6403453091, "num_tokens": 2871, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.44171187007223917}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 03/19/21\n\n\\chapter{Local structure of fractals}\n\\label{cha:local_structure_of_fractals}\n\nIn order to analyze the local properties of fractals, we restrict to \\(s\\)-sets, which are Borel sets of Hausdorff dimension \\(s\\) with positive finite \\(s-\\) dimensional Hausdorff measure. This is a first introduction to problems in geometric measure theory.\n\n\\section{Densities}\n\\label{sec:densities}\n\n\\begin{defn}[Density]\n\tLet \\(F\\) be a subset of the plane. The \\textbf{density} of \\(F\\) at \\(x\\) is\n\t\\begin{align*}\n\t\t\\lim_{r \\to 0} \\frac{\\textrm{area}(F\\cap \\overline{B}(x,r))}{\\pi r^2}\n\t\\end{align*}\n\twhere the denominator is simply the area of \\(\\overline{B}(x,r)\\).\n\\end{defn}\nThe Lebesgue density theorem tells us that for \\(F\\) Borel, the value is either \\(0\\) or \\(1\\) depending on whether \\(x\\) is in \\(F\\).\\\\\n\nNow we consider \\(s\\)-dimensional Hausdorff measure on these sets for \\(F\\) with dimension \\(s\\).\n\\begin{defn}[Upper and lower densities]\n\tLet \\(x \\in \\R^{n}\\) and \\(F\\) be an \\(s\\)-set. The \\textbf{lower} and \\textbf{upper density} is given by\n\t\\begin{align*}\n\t\t\\underline{D}^{s}(F,x) = \\underline{\\textrm{lim}}_{r\\to 0} \\frac{\\mathcal{H}^{s}(F\\cap B(x,r))}{(2r)^{s}}\\\\\n\t\t\\overline{D}^{s}(F,x) = \\overline{\\textrm{lim}}_{r\\to 0} \\frac{\\mathcal{H}^{s}(F\\cap B(x,r))}{(2r)^{s}}.\n\t\\end{align*}\n\tIf they both agree, then the density of \\(F\\) at \\(x\\) exists and is that value.\n\\end{defn}\n\n\\begin{defn}[Regular points]\n\tIf \\(\\underline{D}^{s}(F,x) = \\overline{D}^{s}(F,x) = 1\\), then \\(x\\) is a \\textbf{regular} point of \\(F\\), otherwise it is an \\textbf{irregular} point.\\\\\n\n\tAn \\(s\\)-set is called \\textbf{regular} if, except on a set of \\(\\mathcal{H}^{s}\\)-measure, all of its points are regular. If instead all of its points (except on a set of \\(\\mathcal{H}^{s}\\) ) are irregular, then the \\(s\\)-set is \\textbf{irregular}.\n\\end{defn}\nNote that unlike points, an \\(s\\)-set can be not regular, but not irregular.\\\\\n\nDespite expectations, the densities of irregular sets do have some conditions.\n\\begin{prop}\n\tLet \\(F\\) be an \\(s\\)-set in \\(\\R^{n}\\). Then\n\t\\begin{enumerate}[(a).]\n\t\t\\item \\(\\underline{D}^{s}(F,x) = \\overline{D}^{s}(F,x) = 0\\) for \\(\\mathcal{H}^{s}\\)-almost all \\(x \\not\\in F\\) \n\t\t\\item \\(2^{-s}\\leq \\overline{D}^{s}(F,x)\\leq 1\\) for \\(\\mathcal{H}^{s}\\)-almost all \\(x \\in F\\).\n\t\\end{enumerate}\n\\end{prop}\nOf course, it follows from (b) that the lower density of irregular sets is strictly less than 1 almost everywhere.\\\\\n\nIt can be shown that if \\(E\\subset F\\) is a Borel subset, then \\(E\\) is regular if \\(F\\) is regular and \\(E\\) is irregular if \\(F\\) is irregular. This also gives us that the intersection of a regular and irregular set must have \\(\\mathcal{H}^{s}\\)-measure zero.\n\n\\begin{thm}\n\tLet \\(F\\) be an \\(s\\)-set in \\(\\R^2\\). Then \\(F\\) is irregular unless \\(s\\) is an integer.\n\\end{thm}\n\\begin{proof}\n\tWe will only show the case for when \\(0<s<1\\), as the other cases are much harder. We will do this by showing that the density \\(D^{s}(F,x)\\) fails to exist almost everywhere in \\(F\\). Suppose for the sake of contradiction that there exists \\(F_1\\subset F\\) of positive measure where the density exists and so\n\t\\begin{align*}\n\t\t\\frac{1}{2}< 2^{-s} \\leq D^{s}(F,x).\n\t\\end{align*}\n\tBy Egoroff's theorem, we may find \\(r_0>0\\) and a Borel set \\(E\\subset F_1\\subset F\\) with \\(\\mathcal{H}^{s}(E) > 0\\) such that\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s}(F\\cap B(x,r)) > \\frac{1}{2}(2r)^{s}\n\t\\end{align*}\n\tfor all \\(x \\in E\\) and \\(r<r_0\\). Let \\(y \\in E\\) be a cluster point of \\(E\\), and \\(\\eta\\) be a number with \\(0<\\eta <1\\), and let \\(A_{r,\\eta }\\) be the annulus given by \\(B(y,r(1+\\eta )) \\setminus B(y,r(1-\\eta ))\\) as can be seen in Figure \\ref{fig:annulus}. Then\n\t\\begin{align*}\n\t\t(2r)^{-s}\\mathcal{H}^{s}(F\\cap A_{r,\\eta }) = (2r)^{-s}\\mathcal{H}^{s}(F\\cap B(y,r(1+ \\eta ))) - (2r)^{-s}\\mathcal{H}^{s}(F\\cap B(y,r(1-\\eta )))\\\\\n\t\t\\to D^{s}(F,y)((1+\\eta )^{s}-(1-\\eta )^{s})\n\t\\end{align*} as \\(r\\to 0\\). For each term in a sequence of values of \\(r\\) tending to 0, we can find some \\(x \\in E\\) with \\(\\left| x-y \\right| =r\\). This tells us that \\(B(x,r\\eta  / 2) \\subset A_{r,\\eta }\\) and hence\n\t\\begin{align*}\n\t\t\\frac{1}{2}r^{s}\\eta^{s} < \\mathcal{H}^{s}(F\\cap B(x,r \\eta  / 2)) \\leq \\mathcal{H}^{s}(F\\cap A_{r,\\eta }) \\implies\\\\\n\t\t2^{-s-1}\\eta^{s} \\leq D^{s}(F,y)((1+\\eta )^{s}-(1-\\eta )^{s}) = D^{s}(F,y)(2s\\eta +\\text{higher order terms})\n\t\\end{align*}\n\tAs \\(\\eta \\to 0\\), this cannot hold for \\(0<s<1\\), and so we have a contradiction.\n\\end{proof}\n\n\\begin{figure}[ht]\n\\scalebox{1}{\n    \\centering\n     \\def\\svgwidth{1\\linewidth}\n     \\input{./figures/annulus.pdf_tex}\n}\n    \\caption{Annulus}\n    \\label{fig:annulus}\n\\end{figure}\n\\section{Structure of 1-sets}\n\\label{sec:structure_of_1_sets}\n\nWe cannot generalize integral dimension \\(s\\)-sets as easily, but fortunately we can sometimes obtain decomposition theorems that can allow us to analyze \\(s\\)-sets.\n\n\\begin{thm}[Decomposition Theorem]\n\tLet \\(F\\) be a \\(1\\)-set. The set of regular points of \\(F\\) form a regular set, and the set of irregular points forms an irregular set.\n\\end{thm}\n\nRecall the definition of curves:\n\\begin{defn}[Jordan curve]\n\tA \\textbf{Jordan curve} \\(C\\) is the image of a continuous injection \\(\\psi:[a,b]\\to \\R^2\\), where \\([a,b] \\subset \\R\\) is a proper closed interval.\n\\end{defn}\nBy this definition, curves are not self-intersecting, have two ends, and are compact connected subsets of the plane. The length \\(\\mathcal{L}(C)\\) of the curve \\(C\\) is given by the approximation\n\\begin{align*}\n\t\\mathcal{L}(C) = \\sup \\sum_{i=1}^{m} \\left| x_i - x_{i-1} \\right| \n\\end{align*}\nwhere the supremum is taken over all partitions. If \\(\\mathcal{L}(C)\\) is positive and finite, we call \\(C\\) a \\textbf{rectifiable curve}. Of course, the length of a curve equals its \\(1\\)-dimensional Hausdorff measure.\n\n\\begin{lemma}\n\tIf \\(C\\) is a rectifiable curve, then \\(\\mathcal{H}^{1}(C) = \\mathcal{L}(C)\\).\n\\end{lemma}\nRectifiable curves act nicely in the plane.\n\\begin{lemma}\n\tA rectifiable curve is a regular \\(1\\)-set.\n\\end{lemma}\nOf course, this also tells us that curve-like structures are also regular. That is,\n\\begin{prop}\n\tA \\(1\\)-set contained in a countable union of rectifiable curves is a regular \\(1\\)-set.\n\\end{prop}\nWe can also say that a \\(1 \\)-set is curve-free if its intersection with every rectifiable curve has \\(\\mathcal{H}^{1}\\)-measure zero,\n\\begin{prop}\n\tAn irregular \\(1\\)-set is curve-free.\n\\end{prop}\n\\begin{prop}\n\tLet \\(F\\) be a curve-free \\(1\\)-set in \\(\\R^2\\). Then \\(\\underline{D}^{1}(F,x) \\leq \\frac{3}{4}\\) at almost all \\(x \\in F\\).\n\\end{prop}\n\n\\begin{thm}\n\t\\begin{enumerate}[(a).]\n\t\t\\item A \\(1\\)-set in \\(\\R^2\\) is irregular if and only if it is curve-free.\n\t\t\\item A \\(1\\)-set in \\(\\R^2\\) is regular if and only if it is the union of a curve-like set and a set of \\(\\mathcal{H}^{1}\\)-measure zero.\n\t\\end{enumerate}\n\\end{thm}\n\nThese are remarkable as they classify densities of sets by curves. In fact, this even told us that in any \\(1\\)-set \\(F\\), the set of points for which \\(\\frac{3}{4} < \\underline{D}^{1}(F,x) < 1\\) has \\(\\mathcal{H}^{1}\\)-measure zero.\\\\\n\nSome other nice properties we have are total disconnectedness of irregular \\(1\\)-sets.\n\n% Section on tangents\n\n\\section{Tangents to s-sets}\n\\label{sec:tangents_to_s_sets}\n\nAt first, the concepts of tangents may seem unrelated to our discussion on dimension and local volume. However, the topic is more related than one might expect-- if a smooth curve \\(C\\) has a tangent at \\(x\\), then when one is close to \\(x\\), the set \\(C\\) is concentrated in two directions that are diametrically opposite. This is a notable property, and one we hope to extend to more generalized \\(s\\)-sets.\\\\\n\nOf course, we have to focus locally on sets of positive measure (i.e. almost all points).\n\n\\begin{defn}[Tangent]\n\tAn \\(s\\)-set \\(F\\) in \\(\\R^{n}\\) has a \\textbf{tangent at \\(x\\) in direction \\(\\theta \\)}, where \\(\\theta \\) is a unit vector, if\n\t\\begin{align*}\n\t\t\\overline{D}^{s}(F,x) > 0\n\t\\end{align*}\n\tand for every angle \\(\\varphi >0\\),\n\t\\begin{align*}\n\t\t\\lim_{r \\to 0} r^{-s} \\mathcal{H}^{s}(F \\cap \\; (B(x,r)\\setminus S(x,\\theta ,\\varphi ))) = 0\n\t\\end{align*}\n\twhere \\(S(x,\\theta ,\\varphi )\\) is the double sector with vector \\(x\\), consisting of those \\(y\\) such that the line segment \\([x,y]\\) makes an angle at most \\(\\varphi \\) with \\(\\theta \\) or \\(-\\theta \\).\n\\end{defn}\nIn other words, a tangent in direction \\(\\theta \\) requires that (a). a significant part of \\(F\\) lies near \\(x\\), and (b) a negligible amount close to \\(x\\) lies outside of any double sector near \\(\\theta \\).\\\\\n\nFirst we discuss \\(1\\)-sets for posterity.\n\\begin{prop}\n\tA rectifiable curve \\(C\\) has a tangent at almost all of its points.\n\\end{prop}\nWe already know by a previous lemma that the upper density is \\(1\\) for almost all \\(x \\in C\\). The rest of the proof follows by the fact that the change in length of the curve is a well-defined function that exists as a vector almost everywhere. Of course, by arc length reparametrization, its magnitude is always one. This derivative then is precisely the unit vector \\(\\theta \\), and we can constrain via epsilon-delta techniques so that the length derivative is contained in \\(S\\) provided that the parametrization is within \\(\\varepsilon\\) of the tangent point \\(x\\). Thus we can force the set outside of the double sector to be empty, and hence it has a tangent at almost all \\(x\\). % Full proof can be found in Federer 5.10\n\n\\begin{prop}\n\tA regular \\(1\\)-set \\(F\\) in \\(\\R^2\\) has a tangent at almost all of its points.\n\\end{prop}\nThis follows because regular \\(1\\)-sets can be covered a.e. by a countable collection of rectifiable curves.\n\n \\begin{prop}\n\tAt almost all points of an irregular \\(1\\)-set, no tangent exists.\n\\end{prop}\nThis proof depends on the characterisation of irreuglar sets as curve-free sets, which is very involved.\n\n\\begin{prop}\n\tIf \\(F\\) is an \\(s\\)-set in \\(\\R^2\\) with \\(1<s<2\\), then at almost all points of \\(F\\) no tangent exists.\n\\end{prop}\n\nThese results start to illuminate a much larger picture. For example, it can be shjown that if \\(s>1\\), almost every line through \\(\\mathcal{H}^{s}\\)-a.e. point of an \\(s\\)-set \\(F\\) intersects \\(F\\) in a set of dimension \\(s-1\\).\n\\end{document}\n", "meta": {"hexsha": "4f99cb4d4525f2230255937d3524d6bd99e04c10", "size": 10711, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Geometric Measure Theory/Notes/source/Chapter5.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Geometric Measure Theory/Notes/source/Chapter5.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Geometric Measure Theory/Notes/source/Chapter5.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.4974093264, "max_line_length": 730, "alphanum_fraction": 0.667538045, "num_tokens": 3572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.44170163659403433}}
{"text": "\n\\section{Usage of CellML Models}\\label{sec:usage_cellml}\n\nThe CellML description language can be used to describe mathematical models of a wide range of physiological processes. Arbitrary systems of differential-algebraic equations (DAE) can be represented.\nWe use it for incorporating and exchanging subcellular models, which describe the electrophysiology on a muscle fiber, and for models of motor neurons or sensory organs.\nThe CellML infrastructure is popular in the bioengineering community. The CellML website of the Physiome project hosts over 600 curated CellML models from different areas. Each model can be downloaded in CellML format or as source code containing the expressions of the equations in various programming languages such as MATLAB, Python and C.\n\n\\subsection{Integration of CellML in OpenDiHu and Comparison with Other Framework}\n\nMathematically, a CellML model describes the functions $G$ and $H$ of the following DAE:\n\\begin{align}\\label{eq:cellml_generic_dae}\n  \\p{\\bfy(t)}{t} &= G\\big(t,\\bfy(t),\\bfh(t),\\hat{\\bfc},\\hat{\\bfp}(t)\\big), & \\bfh(t) &= H\\big(\\bfy(t),\\hat{\\bfc},\\hat{\\bfp}(t)\\big).\n\\end{align}\nHere, $\\bfy$ is the state vector and $\\bfh$ is a vector with additional values that are derived from the state vector. The vectors of constants $\\hat{\\bfc}$ and parameters $\\hat{\\bfp}$ are prescribed and fixed over time for $\\hat{\\bfc}$ or varying over time for $\\hat{\\bfp}$.\n\nVarious open source tools exist to create or manipulate CellML models and to solve them and visualize the results \\cite{pmid18579471}. A comprehensive list is given on the CellML website \\cite{cellmlWebsite} and some of them, which are relevant to our work, are outlined in the following.\n\nThere exist two application programming interfaces (APIs), the \\emph{CellML API} and the newer \\emph{libCellML}, which allow direct access to the structures of the CellML model from, e.g., C++ code \\cite{pmid20377909}. \n\n\\begin{figure}%\n  \\centering%\n  \\begin{subfigure}[t]{0.45\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/opencor1.png}\n    \\caption{CellML editor with the ODE for the membrane voltage \\say{V} in the Hodgkin-Huxley cellular model, which corresponds to \\cref{eq:subcellular_model_helper4} inserted into \\cref{eq:subcellular_model_helper3}.}%\n    \\label{fig:opencor1}%\n  \\end{subfigure}\n  \\quad\n  \\begin{subfigure}[t]{0.45\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/opencor2.png}\n    \\caption{Visualization of a simulated action potential $V_m$ over time.}%\n    \\label{fig:opencor2}%\n  \\end{subfigure}\n  \\caption{The CellML modeling environment OpenCOR.}%\n  \\label{fig:opencor}%\n\\end{figure}%\n\n\\emph{OpenCOR} \\cite{OpenCOR2015} provides a modeling environment in a graphical user interface, where models can be edited. \n\\Cref{fig:opencor1} shows the interface with the editor on the right. Mathematical equations are described in a declarative language and can be rendered to mathematical notation, as seen in the upper part in \\cref{fig:opencor1}. OpenCOR automatically transfers the equations to the XML-based MathML syntax and integrates them in the XML-based CellML description.\nOpenCOR can also be used to solve the system of DAEs using implicit solvers such as backward differentiation formulas. The solver parameters can be adjusted and the solver can be started from the graphical user interface. \\Cref{fig:opencor2} shows the interface that lists all variables with their current values on the left and a visualization of the result, in this case an action potential, on the right.\n\nOpenCOR also provides command line functionality to convert CellML files into C code. This generated C code can evaluate all model equations but not solve the DAE system. Because OpenCOR is robust and well established in the bioengineering modeling community, we decide to use it in OpenDiHu. The installation procedure of OpenDiHu downloads and installs OpenCOR automatically.\n\nDuring execution of a simulation, our framework parses the C code of CellML models, compiles a shared library and executes the functions, all at runtime. Thus, the CellML model can be directly given as a C file. Otherwise, if the model file is in XML format, it is assumed to be a CellML description and automatically converted to the required C code using the OpenCOR command line interface.\n\nIf a CellML model is manually simulated in the OpenCOR graphical user interface with time-varying input signals, these signals have to be hard-coded in the model, e.g., as a piecewise defined function. This is acceptable for getting insight into the models, but counteracts the idea of modular models that can be shared and recombined. \nAs a remedy, we design our framework in a way that simulations of CellML models with configurable time-varying input signals are possible without the need to change the CellML description.\n\nCellML models are limited to single-cell systems of DAEs and are not designed for PDEs that, e.g., involve multiple instances of a DAE system on a given geometry. Thus, the monodomain equation cannot be solved with OpenCOR and a multi-scale software framework is needed for this task. Two such frameworks with CellML support, which were described in the introduction in \\cref{sec:intro_related_software}, are Chaste and OpenCMISS Iron. In the following, we relate and compare the approaches of CellML integration in OpenDiHu and these existing frameworks.\n\n\\begin{table}\n  \\centering%\n  \\begin{tabular}{|c|l|l|l|l|l|}\n    \\hline\n    Symbol        & \\multicolumn{3}{l|}{Name}            & Computed          & Initial values\\\\\n    \\cline{2-4}\n                  & OpenCOR    & OpenCMISS & OpenDiHu   & by model?          & can be set?\\\\\n    \\hline\n    $\\bfy$        & \\code{state}     & \\code{STATES}    & \\code{state}     & by timestepping   & yes \\\\[2mm]\n    $\\partial\\bfy/\\partial t$ & \\code{rate}      & \\code{RATES}     & \\code{rate}      & yes               & no  \\\\[2mm]\n    $\\hat{\\bfc}$  & \\code{constant}  & \\code{CONSTANTS} & \\code{constant}  & no                &in CellML  \\\\[2mm]\n    $\\bfh$        & \\code{algebraic}  & \\code{WANTED}    & \\code{algebraic} & yes               & no  \\\\[2mm]\n    $\\hat{\\bfp}$  & -  & \\code{KNOWN}     & \\code{parameter} & no                & yes \\\\\n    \\hline\n  \\end{tabular}\n  \\caption{The different CellML quantities and their properties and names in various tools.}%\n  \\label{tab:cellml_names}%\n\\end{table}\n\nThe variables in the generic DAE in \\cref{eq:cellml_generic_dae} have different names in the different software packages. \\Cref{tab:cellml_names} compares the symbols and their names in OpenCOR, OpenCMISS in OpenDiHu and summarized how their values are determined. \n\nAll three software packages have the concept of \\code{state} and \\code{rate} vectors, where the states $\\bfy$ are the input and the rates $\\partial\\bfy/\\partial t$ are the output of the CellML formulas. Similarly, the constants $\\hat{\\bfc}$ are always a set of predefined values that are fixed during the computations.\n\nThe algebraic formulas lead to the values in $\\bfh$, independently of the timestepping scheme. These algebraic values can be considered as the resulting quantities of interest of the model and are typically written to output files or transferred to coupled solvers.\n\nMoreover, OpenCMISS and OpenDiHu define parameters $\\hat{\\bfp}$, which influence the behavior of the model. Their values can be changed by a coupled solver or prescribed from the settings. \nIn OpenDiHu, any constant or algebraic variable in a CellML model can be converted into a parameter. All occurrences of the constant or algebraic variable in the CellML description get replaced by the parameter variable. For former algebraic variables, this replacement step overrides the equations that would have defined the algebraic value. Exemplary use cases are to set the external stimulation current $I_\\text{ext}$ in \\cref{eq:subcellular_model_helper3} or to set the fiber stretch in a strain-dependent subcellular model.\n\nOpenCMISS uses a similar concept, where some algebraics in the CellML description can be declared as \\code{WANTED} to be read by the framework. Some of the constants can be declared as \\code{KNOWN} such that OpenCMISS sets their values from other computations within OpenCMISS. (Assigning new values to algebraics as in OpenDiHu is not possible.) Because the terms \\code{WANTED} and \\code{KNOWN} can be ambiguous if either seen from within the CellML model or from the framework, we decide to use the terms \\code{algebraics} and \\code{parameters} instead.\n\nThe last two columns of \\cref{tab:cellml_names} summarize the purpose of the different quantities. The CellML description defines formulas for the states, rates and algebraics. Rates and algebraics are directly calculated by the code that is generated from the CellML model, the vector of states is then computed from the vector of rates by the timestepping scheme. The initial values of the states are either explicitly specified in the OpenDiHu settings, e.g., to allow different values for different instances of a model. Or, if this specification is omitted,  the initial values are set according to the specification in the CellML file. The parameter values always have to be specified in the Python settings. By definition, the constants cannot be set from OpenDiHu, but are given in the CellML model. If the value of a constant should be specified from the settings, the variable should instead be configured to be a parameter.\n\n\nFrom a computational point of view, a CellML model computes the following function in terms of the introduced variable names:\n\\begin{equation}\n  \\left(\n    \\begin{array}{cc}\n      \\texttt{rates} \\\\ \\texttt{algebraics} \n    \\end{array}\n  \\right) = \\texttt{cellml}\\left(\\texttt{states}, \\texttt{constants}\\right).\n  \\label{eq:cellml_generic}\n\\end{equation}\n\nIn the fiber based electrophysiology model, CellML is needed to formulate the reaction term in the monodomain equation \\cref{eq:monodomain}, which is repeated here:\n\\begin{align}\\label{eq:monodomain_2}\n  \\p{V_m}{t}  = \\dfrac{\\sigma_\\text{eff}}{A_m\\,C_m} \\p{V_m}{x}{2} - \\dfrac{1}{C_m} I_\\text{ion}(V_m,\\bfy).\n\\end{align}\nThe \\code{states} vector in \\cref{eq:cellml_generic} includes both $V_m$ and $\\bfy$ in \\cref{eq:monodomain_2}. In consequence, the computed \\code{rates} contain $\\partial V_m/\\partial t$ and $\\partial\\bfy/\\partial t$. The right-hand side of \\cref{eq:cellml_generic}, i.e., the \\code{cellml} function calculates the term $(-1/C_m \\cdot I_\\text{ion})$, which is the reaction part of the monodomain equation in \\cref{eq:monodomain_2}. Thus, the CellML computation can be directly used in the operator splitting approach in \\cref{sec:discretization_monodomain}.\n\nFor the solution of CellML models, OpenCMISS implements the explicit forward Euler scheme or allows to use the backward differentiation formula (BDF) schemes with adaptive order of convergence of SUNDIALS. Recently, an implementation of the second order explicit Heun scheme was added by Aaron Krämer. Accuracy and runtimes were investigated for Euler, Heun and BDF solvers for the subcellular model within the monodomain equation. Because of the operator splitting scheme, only very small timespans have to be solved by those solvers, which does not redeem the overhead of advanced schemes such as the BDF solver, ultimately yielding the best performance for the Heun solver. Based on these investigations, we choose to implement the forward Euler and Heun schemes for the solution of CellML models in OpenDiHu.\n\n% comparison to Chaste\nThe following differences exist between the approaches to support CellML models in Chaste, OpenCMISS Iron and OpenDiHu:\nChaste tries to automatically determine the CellML variable names of standard quantities such as the membrane voltage and the stimulation current. This requires potentially less user intervention when CellML models are exchanged.\nIn OpenDiHu, the step of identifying the CellML variables to be connected to the coupled solvers is done manually to give the user complete control over the setup. It can be achieved in a clear way with the Python settings script. Another difference in OpenDiHu is that all computational code is guaranteed to invoke vector instructions, i.e., following the single-instruction multiple data (SIMD) paradigm. Chaste only relies on the optimization behavior of the Intel compiler, which is not guaranteed to be optimal, e.g., for non-Intel hardware.\n\n% comparison to Iron\nThe computational core Iron from the OpenCMISS package employs the CellML API and also requires manual connections of CellML variables to the solver code. These variable mappings have to be hard-coded in the main Fortran program (if the Python wrappers are not used) and are compiled into the program. Thus, a CellML model is a fixed part of a compiled simulation program. In contrast, OpenDiHu allows to configure the CellML model at runtime.\nAnother difference in the implementation is that Iron uses a non-optimal memory layout for the state vector, which prohibits vectorization and slows down the solution compared to OpenDiHu.\n\n\\subsection{Mapping of CellML Variables to Slots and Parameters}\n\nPreparing the OpenDiHu solver for use with a CellML model consists of the two steps of adjusting the C++ template parameters and setting up the variable mappings in the Python settings. The two C++ template parameters have to be set to the sizes of the state vector $\\bfy$ and the algebraics vector $\\bfh$. The code snipped in \\cref{fig:example_shorten_cellml} belongs to the example program in \\code{examples/electrophysiology/cellml/shorten}, which solves a single-cell CellML model:\n\\begin{figure}[H]\n\\centering\n\\begin{framed}\n\\begin{lstlisting}[basicstyle=\\small\\ttfamily,commentstyle=\\color{gray},numbers=left]\n  TimeSteppingScheme::ExplicitEuler<\n    CellmlAdapter<56,71>\n  >\n\\end{lstlisting}\n\\end{framed}\n\\caption{C++ code snipped that solves a CellML model with an explicit Euler scheme. The two template parameters 56 and 71 correspond to the number of states and algebraics, respectively.}%\n\\label{fig:example_shorten_cellml}%\n\\end{figure}\nIn this case, the model contains 56 states and 71 algebraics. The reason that these numbers have to be fixed at compile-time is that this allows the data structures in the implementation to have a fixed layout and be allocated on the stack instead of the heap, which improves the performance.\n\nIf the given numbers are not matching the variables in the CellML file, appropriate warnings or errors are generated, containing the correct C++ code to be copied to the C++ file. If the numbers are too high, the solver still works correctly, however, some memory and computation time is wasted for the excess variables.\n\nThe other step is configuring the connections between the CellML computation and input data or coupled solvers. This involves defining a \\code{mappings} parameter. \\Cref{fig:example_mapping} shows such a definition for the multidomain example with fat layer and a contraction model, which was presented in \\cref{sec:exemplary_usage_2}.\n\n\\begin{figure}\n\\centering\n\\begin{framed}\n%\\begin{Verbatim}[fontsize=\\small]\n\\begin{lstlisting}[basicstyle=\\small\\ttfamily,commentstyle=\\color{gray},numbers=left,language=python]\n  mappings = {\n    # function in OpenDiHu      name in CellML model    # comment\n    \n    (\"parameter\", 0):           \"wal_environment/I_HH\", # I_stim (constant)   $\\label{alg:5.3}$\n    (\"parameter\", 1):           \"razumova/L_S\",         # $\\textcolor{gray}{\\lambda}$ (constant)      $\\label{alg:5.4}$\n    \n    (\"connectorSlot\", \"vm\"):    \"wal_environment/vS\",   # $\\textcolor{gray}{V_m}$ (state)            $\\label{alg:5.7}$\n    (\"connectorSlot\", \"stress\"):\"razumova/stress\",      # $\\textcolor{gray}{\\gamma}$ (algebraic) $\\label{alg:5.8}$\n    (\"connectorSlot\", \"lambda\"):\"razumova/L_S\",         # $\\textcolor{gray}{\\lambda}$ (constant)        $\\label{alg:5.9}$\n  }\n  \n  parameters_initial_values = [0.0, 1.0]                # I_stim=0, $\\textcolor{gray}{\\lambda}$=1                    $\\label{alg:5.12}$\n\\end{lstlisting}\n%\\end{Verbatim}\n\\end{framed}\n\\caption{Specification of parameters and connector slots in a CellML model. The listed settings define two CellML variables to be parameters and specify three connector slots to transfer values between coupled solvers.}%\n\\label{fig:example_mapping}%\n\\end{figure}\n\nThe \\code{mappings} define which CellML constants or algebraics are treated as parameters. Lines \\ref{alg:5.3} and \\ref{alg:5.4} make the stimulation current and fiber stretch constants accessible from outside the CellML model by making them parameters. The variables are identified by their names and the model components they are defined in in the CellML model. In this example, the first parameter is the stimulation current \\code{I_HH} within the \\code{wal_environment} model component and the second parameter is the fiber stretch or half-sarcomere length \\code{L_S} in the \\code{razumova} component.\nThe initial values for these parameters are given in line \\ref{alg:5.12}, which sets the stimulation current to zero and the fiber stretch to one.\n\nThe second information in the \\code{mappings} parameter is which variables from the CellML model are exposed to coupled solvers in OpenDiHu. This happens by defining connector slots that can be connected between the solvers as shown in \\cref{fig:example_multidomain_solver_structure}.\nThree slots are defined in lines \\ref{alg:5.7} to \\ref{alg:5.9} with slot names \\code{`vm`}, \\code{`stress`} and \\code{`lambda`}. The corresponding CellML variables are again specified by their model component name and their own name. \n\nCellML variables of all three different types are connected in the example. The membrane voltage $V_m$ in slot \\code{`vm`} is part of the state vector $\\bfy$. In this example, it is used in a bidirectional coupling with the diffusion solver. The second slot, \\code{`stress`}, connects to the activation parameter $\\gamma$, which is part of the algebraic vector $\\bfh$. It is an output of the model. The slot \\code{`lambda`} refers to a constant in the CellML description, which has been transformed to a parameter in line \\ref{alg:5.4}. It is used as an  input and the received values at these slots are moved to the corresponding locations in the CellML formulation.\n\n\n\\subsection{Consistent Physical Units in CellML Models and the Multi-Scale Framework}\n\nThe variables in a CellML model describe physical quantities. CellML handles their physical units and computes the appropriate conversions when combining model components within a CellML description.\nFor the integration of a CellML model in external solvers such as OpenDiHu, we have to take care that the units are consistent.\n\n\\sisetup{retain-unity-mantissa = false}\nThe subcellular models that we use are formulated with the following units for length, time, electric current and capacitance:%\n\\begin{align*}\n   \\SI{1}{\\centi\\meter} &= \\SI{1e-2}{\\meter}, &\n   \\SI{1}{\\milli\\second} &= \\SI{1e-3}{\\second}, &\n   \\SI{1}{\\micro\\ampere} &= \\SI{1e-6}{\\ampere}, &\n   \\SI{1}{\\micro\\farad} = \\SI{1e-6}{\\farad}.\n\\end{align*}\nThese basic units also fix derived units such as \\SI{1}{\\kilo\\hertz} for frequencies and \\SI{1}{\\milli\\volt} for voltages. For example, the membrane capacitance $C_m$ has to be specified in units \\SI{1}{\\micro\\farad\\per\\square\\centi\\meter} and the stimulation current $I_\\text{stim}$ in the units \\SI{1}{\\micro\\ampere\\per\\square\\centi\\meter}.\n\nWith this system of units, values are in a similar scale when computing subcellular models. However, these units are less suitable for organ-scale computations, as the derived mass and density units are \\SI{1e-14}{\\kilogram} and \\SI{1e-8}{\\kilogram\\per\\meter\\cubed} and the derived force and stress units are \\SI{1e-10}{\\newton} and \\SI{1e-6}{\\pascal}. For the dynamic solid mechanics model, where these quantities play a role, we use the following different system of units:\n\\begin{align*}\n   \\SI{1}{\\centi\\meter} &= \\SI{1e-2}{\\meter}, &\n   \\SI{1}{\\milli\\second} &= \\SI{1e-3}{\\second}, &\n   \\SI{1}{\\newton}.\n\\end{align*}\nThe length and time scales are identical to the subcellular model and allow for consistent coupling. The coupling of active stresses from the subcellular model to the solid mechanics model uses the unit-less activation parameter $\\gamma \\in [0,1]$, which is transferred to stress units by multiplication with a maximum active stress value in the solid mechanics model.\n\nDerived units in the solid mechanics system of units are \\SI{1e2}{\\kilogram\\per\\meter\\cubed} for the density, \\SI{1e4}{\\meter\\per\\square\\second} for the acceleration and $\\SI{1}{\\newton\\per\\square\\centi\\meter} = \\SI{10}{\\kilo\\pascal}$ for the stress. The values of material parameters and boundary conditions have to be given with respect to these units.\nThe units allow for smaller values in the solid mechanics computation than in the unit system of the subcellular model. Moreover, it is  convenient to specify forces directly in terms of \\SI{1}{\\newton}.\n\n% # Fixed units in cellMl models:\n% # These define the unit system.\n% # 1 cm = 1e-2 m\n% # 1 ms = 1e-3 s\n% # 1 uA = 1e-6 A\n% # 1 uF = 1e-6 F\n% # \n% # derived units:\n% #   (F=s^4*A^2*m^-2*kg^-1) => 1 ms^4*uA^2*cm^-2*x*kg^-1 = (1e-3)^4 s^4 * (1e-6)^2 A^2 * (1e-2)^-2 m^-2 * (x)^-1 kg^-1 = 1e-12 * 1e-12 * 1e4 F = 1e-20 * x^-1 F := 1e-6 F => x = 1e-14\n% # 1e-14 kg = 10e-15 kg = 10e-12 g = 10 pg\n% \n% # (N=kg*m*s^-2) => 1 10pg*cm*ms^2 = 1e-14 kg * 1e-2 m * (1e-3)^-2 s^-2 = 1e-14 * 1e-2 * 1e6 N = 1e-10 N = 10 nN\n% # (S=kg^-1*m^-2*s^3*A^2, Siemens not Sievert!) => (1e-14*kg)^-1*cm^-2*ms^3*uA^2 = (1e-14)^-1 kg^-1 * (1e-2)^-2 m^-2 * (1e-3)^3 s^3 * (1e-6)^2 A^2 = 1e14 * 1e4 * 1e-9 * 1e-12 S = 1e-3 S = 1 mS\n% # (V=kg*m^2*s^-3*A^-1) => 1 10pg*cm^2*ms^-3*uA^-1 = (1e-14) kg * (1e-2)^2 m^2 * (1e-3)^-3 s^-3 * (1e-6)^-1 A^-1 = 1e-14 * 1e-4 * 1e6 * 1e6 V = 1e-6 V = 1mV\n% # (Hz=s^-1) => 1 ms^-1 = (1e-3)^-1 s^-1 = 1e3 Hz\n% # (kg/m^3) => 1 10 pg/cm^3 = 1e-14 kg / (1e-2 m)^3 = 1e-14 * 1e6 kg/m^3 = 1e-8 kg/m^3\n% # (Pa=kg/(m*s^2)) => 1e-14 kg / (1e-2 m * 1e-3^2 s^2) = 1e-14 / (1e-8) Pa = 1e-6 Pa\n% \n% # Hodgkin-Huxley\n% # t: ms\n% # STATES[0], Vm: mV\n% # CONSTANTS[1], Cm: uF*cm^-2\n% # CONSTANTS[2], I_Stim: uA*cm^-2\n% # -> all units are consistent\n% \n% # Shorten\n% # t: ms\n% # CONSTANTS[0], Cm: uF*cm^-2\n% # STATES[0], Vm: mV\n% # ALGEBRAIC[32], I_Stim: uA*cm^-2\n% # -> all units are consistent\n% \n% # Fixed units in mechanics system\n% # 1 cm = 1e-2 m\n% # 1 ms = 1e-3 s\n% # 1 N\n% # 1 N/cm^2 = (kg*m*s^-2) / (1e-2 m)^2 = 1e4 kg*m^-1*s^-2 = 10 kPa\n% # (kg = N*s^2*m^-1) => N*ms^2*cm^-1 = N*(1e-3 s)^2 * (1e-2 m)^-1 = 1e-4 N*s^2*m^-1 = 1e-4 kg\n% # (kg/m^3) => 1 * 1e-4 kg * (1e-2 m)^-3 = 1e2 kg/m^3\n% # (m/s^2) => 1 cm/ms^2 = 1e-2 m * (1e-3 s)^-2 = 1e4 m*s^-2\n\n\\subsection{Specification of Stimulation Times Using Callback Functions}\\label{sec:stimulation_times_callbacks}\n\nA muscle fiber is activated by impulse trains that are generated from a motor neuron and stimulate the fiber at its neuromuscular junction. At the synaptic terminal, neurotransmitters are released and open certain ion channels, which results in depolarization of the muscle fiber membrane.\nThis process can either be modeled by adding an external stimulation current $I_\\text{stim}$ through the dedicated ion channels or by directly prescribing the transmembrane voltage $V_m$ to reflect the resulting depolarized state. The first approach is more accurate as it also describes the depolarization process at the stimulated parts of the fiber. The electric \\say{far field} away from the stimulation point, however, is the same for both approaches.\n\nIn OpenDiHu, it is possible to configure either approach. Setting the stimulation current is more involved as the actual value of  $I_\\text{stim}$ has to be chosen depending on the mesh width. Furthermore, multiple adjacent nodes have to be stimulated such that the electric current that is added to the system balances with the amount that is carried away by the diffusion term. The nonlinear subcellular model fails to compute a valid solution, if too much current is present. With too little current, the membrane potential stays below the activation threshold and no action potential is triggered. \n\nPrescribing the transmembrane voltage to a value above the depolarization threshold at multiple adjacent nodes leads to equivalent action potentials independent of the mesh width. However, a suitable value for the prescribed voltage also has to be chosen in accordance with the employed subcellular model.\n\nThe stimulation current $I_\\text{stim}$ is a CellML parameter and the transmembrane voltage $V_m$ corresponds to a state in the CellML model. The values of both parameters and states can be adjusted during the simulation. This feature is implemented by means of callback functions in the Python settings. A callback is a user defined function that gets called in regular intervals during the simulation, receives various information about the current state of the simulation and can alter some values such as the states vector $\\bfy(t)$ or the parameters vector $\\hat{\\bfp}(t)$.\n\n\\begin{figure}\n\\centering\n\\begin{framed}\n%\\begin{Verbatim}[fontsize=\\small]\n\\begin{lstlisting}[basicstyle=\\footnotesize\\ttfamily,commentstyle=\\color{gray},numbers=left,language=python]\n\n  # callback function that can set parameters, i.e. stimulation current\n  def $\\textcolor{Maroon}{\\text{\\ttfamily set\\_specific\\_parameters}}$(n_nodes_global, time_step_no, current_time, $\\label{alg:6.3}$\n                              parameters, fiber_no):    \n    \n    # determine if fiber gets stimulated at the current time\n    if fiber_gets_stimulated(fiber_no, current_time):    $\\label{alg:6.6}$\n      stimulation_current = 40.\n    else:\n      stimulation_current = 0.\n\n    innervation_node_global = int(n_nodes_global / 2)    $\\label{alg:6.11}$\n    parameters[(innervation_node_global),0,0] = stimulation_current    $\\label{alg:6.12}$\n\n  # callback function that can set states, e.g., prescribe $\\textcolor{gray}{V_m}$ for stimulation\n  def $\\textcolor{Maroon}{\\text{\\ttfamily set\\_specific\\_states}}$(n_nodes_global, time_step_no, current_time,       $\\label{alg:6.15}$\n                          states, fiber_no):            \n\n    # determine if fiber gets stimulated at the current time\n    if fiber_gets_stimulated(fiber_no, current_time):    $\\label{alg:6.18}$\n      innervation_node_global = int(n_nodes_global / 2)    $\\label{alg:6.19}$\n      states[(innervation_node_global),0,0] = 40.0      $\\label{alg:6.20}$\n\n  config = {        $\\label{alg:6.22}$\n    (...)          \n    \n    # callback to adjust parameters\n    \"setSpecificParametersFunction\":         $\\textcolor{Maroon}{\\text{\\ttfamily set\\_specific\\_parameters}}$,    $\\label{alg:6.28}$\n    \"setSpecificParametersCallInterval\":     1e3,\n    \"setSpecificStatesFrequencyJitter\":      0,                          \n                    \n    # callback to alter values of states\n    \"setSpecificStatesFunction\":             $\\textcolor{Maroon}{\\text{\\ttfamily set\\_specific\\_states}}$,      $\\label{alg:6.33}$\n    \"setSpecificStatesCallInterval\":         2*int(1/stimulation_frequency/dt_0D),     $\\label{alg:6.34}$\n    \n    \"setSpecificStatesCallFrequency\":        stimulation_frequency,    $\\label{alg:6.36}$\n    \"setSpecificStatesCallEnableBegin\":      0,                        $\\label{alg:6.37}$\n    \"setSpecificStatesRepeatAfterFirstCall\": 0.01,                     $\\label{alg:6.38}$\n    \"setSpecificStatesFrequencyJitter\":      [0.1,-0.2,0.0],           $\\label{alg:6.39}$\n                         \n    # callback to postprocess the result\n    \"handleResultFunction\":                  $\\textcolor{Maroon}{\\text{\\ttfamily handle\\_result}}$,    $\\label{alg:6.41}$\n    \"handleResultCallInterval\":              1e4,         \n     \n    \"additionalArgument\":                    fiber_no,        $\\label{alg:6.43}$\n  }\n\n\\end{lstlisting}\n%\\end{Verbatim}\n\\end{framed}\n\\caption{Settings that define neural spike trains activating muscle fibers. The definition of the two callback functions \\code{set_specific_parameters} and \\code{set_specific_states} is demonstrated.}%\n\\label{fig:example_callback_functions}%\n\\end{figure}\n\n\\Cref{fig:example_callback_functions} defines two such callback functions used in the fiber based electrophysiology model to add electric stimulation to the monodomain model. Either suffices to implement the stimulation. The function \\code{set_specific_parameters} in line \\ref{alg:6.3} and the function \\code{set_specific_states} in line \\ref{alg:6.15} both receive similar information from the simulation as their function arguments: the total number \\code{n_nodes_global} of nodes in the current fiber, the current integer timestep number \\code{time_step_no}, the corresponding floating-point number \\code{current_time} of the current simulation time, and the number \\code{fiber_no} that identifies the current fiber.\n\nThe variables \\code{parameters} and \\code{states} are the output of the callback functions that alter the parameter and state values, respectively. Both callbacks determine, whether the current fiber should be stimulated at the current time, in lines \\ref{alg:6.6} and \\ref{alg:6.18}.\nIf yes, the parameter or state at the center point of the fiber, computed in lines \\ref{alg:6.11} and \\ref{alg:6.19}, gets changed accordingly. In the real scenario, three adjacent points get stimulated instead of a single point.\n\nBecause the conversion of transferred data between the Python code and the C++ code costs some runtime, the number of transferred values is reduced to a minimum. Only the parameters and states that should be changed are indicated in the \\code{parameters} and \\code{states} variables in lines \\ref{alg:6.12} and \\ref{alg:6.20}. These variables are Python dictionaries, i.e., key-value pairs. The key is a tuple of three items: First, the global coordinates $(x,y,z)$ of the node where the parameter or state change is applied. In case of a 1D fiber mesh, this is only a single coordinate. Second, the dof index on this node. This is different from zero only for Hermite ansatz functions, which have multiple dofs per node. And third, the index of the parameter or state that should be set. Parameter 0 corresponds to the stimulation current as defined in line \\ref{alg:5.3} of \\cref{fig:example_mapping}, and state 0 corresponds to the transmembrane voltage $V_m$. The new value to set is the value of the key-value pair.\n\nThe comparison of the two callbacks functions shows one difference: In the callback for the parameters, the stimulation current is set to zero when there is no stimulation. In the callback for the states, nothing is done during this time. The reason for this is that the state values will be continuously updated from the rates by the timestepping scheme, whereas the parameters keep their values until they are changed from the callback. This has consequences on the times at which the callback functions have to be called from the simulation, which are described in the following.\n\nInvoking the Python interpreter on a callback requires some time. Calling the callback after every small timestep of the simulation is, thus, not performant. We model the stimulation of a fiber by a piecewise constant function with two possible values for on and off.\nIn the approach that sets the stimulation current, the callback \\code{set_specific_parameters} has to be called at the onset and at the end of every stimulation spike. If the approach with the prescribed membrane voltage is used, the callback \\code{set_specific_states} has to be called after every stimulation onset in every subsequent timestep until the stimulation is over.\n\nThe requirements for both approaches can be satisfied by defining a small constant interval of timesteps after which the callback functions are invoked. This call interval can be specified in the \\code{config} dictionary of the Python file in \\cref{fig:example_callback_functions} , which is shown in excerpts from line \\ref{alg:6.22} onwards. The \\code{config} variable references the callback functions in lines \\ref{alg:6.28} and \\ref{alg:6.33} and the parameters for the call interval in the next lines. Note that this configuration is only shown for demonstration, a real configuration should either specify the states callback or the parameters callback function, not both.\n\nLine \\ref{alg:6.34} in \\cref{fig:example_callback_functions} shows how the call interval can be computed to correspond to a given stimulation frequency \\code{stimulation_frequency}, given the timestep width \\code{dt_0D}. The prefactor of two occurs because the callback would be called twice per timestep in the Strang splitting scheme.\n\nReal impulse trains from the motor neuron pool typically follow a base frequency with some added jitter that offsets the exact firing times from the base frequency by a small random time. Furthermore, studies are often designed to start with a completely inactive muscle and switch on certain MUs after specified times. To efficiently account for these two demands, we add another way to specify the times when the \\code{set_specific_states} callback gets invoked. In this second way of specification, the \\code{setSpecificStatesCallInterval} parameter is disabled by setting it to zero. Then, the three options \\code{CallFrequency}, \\code{CallEnableBegin}, \\code{RepeatAfterFirstCall} and \\code{Frequency}\\code{Jitter} (prefixed by \\code{set}\\code{Specific}\\code{States}) given in lines \\ref{alg:6.36} to \\ref{alg:6.39} are significant. \n\n\\begin{figure}%\n  \\centering%\n  \\includegraphics[width=0.8\\textwidth]{images/implementation/stimulation_times.pdf}%\n  \\caption{Parametrization of stimulation times in electrophysiology simulations. The neuronal impulse train is given by the black spikes. The parameters \\code{CallEnableBegin}, \\code{RepeatAfterFirstCall}, \\code{CallFrequency} and \\code{FrequencyJitter} (in the settings all prefixed by \\code{setSpecificStates}) specify the shape of the spike train.}%\n  \\label{fig:stimulation_times}%\n\\end{figure}%\n\nTheir meaning is illustrated in \\cref{fig:stimulation_times}. \\code{CallEnableBegin} specifies the time when the callback should be called for the first time. Then, it is called with a frequency that is additively composed of the base frequency given by \\code{CallFrequency} and one entry of the parameter \\code{FrequencyJitter}. This parameter is a ring buffer of relative factors by which the regular time span between subsequent firing events is prolonged. For example, if \\code{FrequencyJitter} contains the list \\code{[0.1,-0.2,0.0]}, the time span $T_{01}$ between the first two firing events is \\SI{10}{\\percent} longer than according to the base frequency $f$, the next timespan $T_{12}$ is \\SI{20}{\\percent} shorter and the next time span $T_{23}$ exactly equals the inverse base frequency, $T_{23} = 1/f$. Subsequently, the scheme repeats. Typically, this parameter is set to a randomly generated list with a large number of entries.\nAfter each onset of a stimulation, the \\code{setSpecificStatesCallInterval} function is called repeatedly in every subsequent timestep for a time span given by \\code{RepeatAfterFirstCall}. \n\nIn the fiber based electrophysiology example, every fiber has its own instance of the Python settings, and it is possible to specify different parameter values for different fibers or motor units, e.g., to set a different beginning time of the stimulations. The fibers can be distinguished by the last parameter of the callbacks, which receives the custom value that is defined by the \\code{`additionalArgument`} parameter in line \\ref{alg:6.43}. In the given example, the current fiber number is used here, but any other Python variable is possible.\n\n\\Cref{fig:firing_times_ramp} shows a scenario, where different parameters are set for different MUs. The figure shows the firing times of fibers grouped to 20 MUs, which are activated in a ramp in the first $t=\\SI{19}{\\second}$. The base frequency decreases from \\SI{23.92}{\\hertz} to \\SI{7.66}{\\hertz} for MUs 1 to 20, which reproduces a scenario in literature \\cite{Klotz2020}. The frequency jitter parameter is a list of 100 randomly chosen values between \\SI{-10}{\\percent} and \\SI[retain-explicit-plus]{+10}{\\percent}. The \\code{CallEnableBegin} parameter enables the stimulation of the next MU every second.\n\n\\begin{figure}%\n  \\centering%\n  \\includegraphics[width=\\textwidth]{images/implementation/firing_times_ramp1.pdf}%\n  \\caption{Firing times for a scenario with 20 motor units with ramp-like activation and different stimulation frequencies.}%\n  \\label{fig:firing_times_ramp}%\n\\end{figure}%\n\nSimilar to the two presented callbacks, which set parameters and states, a third callback \\code{handle_result} can be defined as given in line \\ref{alg:6.41} of \\cref{fig:example_callback_functions}. This callback function gets called in a fixed interval specified by \\code{`handleResultCallInterval`}. It receives the complete vectors of states $\\bfy$ and intermediates $\\bfh$ and can be used to perform custom post-processing or to output custom data files from the Python script.\n\nIn summary, variables of CellML models can be coupled to other solvers. Their parameters and values can be adjusted from the settings file. Callback functions are used to alter values during the simulation. This flexibility comes at the runtime cost of invoking the Python interpreter, therefore the times when to call the callback functions have to be specified appropriately. Special methods exist to model steady stimulation with frequency jitter, which occurs in typical neural stimulation of muscle fibers.\n\n% --------------------------------------------\n\\section{Output File Formats}\\label{sec:output_file_formats}\n\nAfter the simulation program completes, the computed results can be visualized using external tools.\nAs mentioned in the previous sections, output writers are used to generate output files in various formats. The formats of the output writers and additional options are configured in the Python settings under the parameter \\code{OutputWriter}. The following formats are supported:\\code{`ParaView`}, \\code{`ExFile`}, \\code{`PythonFile`}, \\code{`PythonCallback`} and\\break\\code{`MegaMol`}.\nThe corresponding output can be visualized and post-processed using different tools, which will be presented in the following. We use simulation results of a fiber-based electrophysiology scenario with 49 1D fibers and a 3D muscle mesh to showcase the different output data formats.\n\n\\subsection{Output of VTK Files for the Use with ParaView}\nThe canonical way to visualize simulation results computed by OpenDiHu is to use the software ParaView \\cite{paraview}. \nThe required output file formats are defined by the Visualization Toolkit (VTK) specification \\cite{vtk}. Depending on the mesh type in OpenDiHu, different file types are generated:\n\\emph{RectilinearGrid} files (with file ending \\code{.vtr}) for the output of \\say{regular fixed} meshes that represent a cartesian grid,\n\\emph{StructuredGrid} files (\\code{.vts}) for the output of \\say{structured deformable} meshes, i.e., structured meshes that can deform over time, \n\\emph{UnstructuredGrid} files (\\code{.vtu}) for the output of unstructured meshes, and\n\\emph{PolyData} files (\\code{.vtp}) containing connected points are used to represent multiple muscle fibers in a single file.\nParaView can be used to load and visualize all of these file types.\n\nAll of these files are XML based and their payload data can be configured to be either written in ASCII representation or in Base64 encoding. Base64 encoding also translates the raw data into ASCII characters. The data stream is split into pieces of 6 bits, which are each represented by an 8-bit-ASCII character. Thus, the required memory is $4/3$ of the raw data. Compared to a full ASCII representation containing the digits of all numerical values, this leads to a significant reduction of file sizes.\n\nThe VTK file format specifies parallel file output, where each process writes its local data to a separate file and one additional master file references the pieces in all files. This parallel file output scheme is implemented in OpenDiHu. However, it can lead to an impractically large number of small output files for high degrees of parallelism. \n\nTherefore, we additionally implement a second approach, where non-parallel VTK files, which contain the whole dataset, are written. The same type of output files is generated during serial and parallel execution of the program. \nWriting the data to such a file is done using the parallel output capabilities of MPI. The respective MPI functions allow to collectively write data to the same file from different processes at different locations in the file. For parallel execution, every process only writes its own local data and no communication of the payload data to a master process is necessary. \n\nBecause the byte boundaries in a Base64 encoded data stream coincide with multiples of 8 bits only every three bytes, the processes that write neighboring parts in the output file have to coordinate the bit offsets of their data streams. For this, a small amount of data has to be communicated between these processes. However, the cost of this communication is negligible.\n\nWith this improved output scheme, one file is generated per mesh and output timestep of the simulation. The frequency of output timesteps can be configured in the Python settings.\nIt is also possible and useful to combine all 1D fiber meshes into a single output file per timestep to reduce the number of output files.\n\nDifferent meshes can be written with different frequency. For example, for a simulation of fiber based electrophysiology with EMG signals, it is reasonable to output the comprehensive dataset of all fibers less frequently than the smaller dataset of EMG signals on the 2D skin surface. To associate the output files with the correct times, a timestamp of the current simulation time is added to every file. Furthermore, partitioning information is added, i.e., which part of the mesh is computed by which process.\n\nTo synchronize output files of different meshes with different output frequencies in the visualization tool, additional \\emph{series files} (with file ending \\code{.series}) are automatically created for every mesh. Such a file references all available output files of a mesh with their simulation times in JSON format. These files can be opened in ParaView to get a time-series of the simulation result.\n\nUsing the series files is also convenient, if the simulation is run in a directory, where old simulation results from previous runs exist. Because the series files are updated every timestep and only reference the newly created files, opening these files in ParaView only visualizes newly created simulation output, in contrast to opening a whole directory, which would potentially also load old results.\n\n\\subsection{Visualization With ParaView}\nParaView allows various manipulations and types of visualization of the loaded data. \\Cref{fig:paraview_output} shows the ParaView window with simulation data of a fiber-based electrophysiology scenario. The loaded data are organized in a tree of datasets with applied filters, which can be seen in the \\say{Pipeline Browser} in the top left. The center view shows a visualization of the muscle fibers and the 3D mesh at simulation time $t=\\SI{89.6}{\\milli\\second}$. An animation of the transient data can be shown by using the playback controls in the top bar.\n\n\\begin{figure}%\n  \\centering%\n  \\includegraphics[width=\\textwidth]{images/implementation/paraview.png}%\n  \\caption{Visualization of simulation results with ParaView: ParaView window with a visualization of muscle fibers and a 3D muscle mesh.}%\n  \\label{fig:paraview_output}%\n\\end{figure}%\n\nThe visualization in the center top view displays the membrane voltage $V_m$ at the fibers and in the 3D mesh, colored by the scheme shown at the left in the view. The 3D mesh is sliced on the right-hand side of the muscle to make the fiber dataset better visible.\n\nThe view on the bottom left depicts the extra-cellular potential $\\phi_e$ on the 3D mesh. The view on the bottom right shows a plot of the value of $\\phi_e$ along a horizontal line on the surface of the muscle.\n\nIt can be seen that three fibers near the surface are activated, and that the action potentials effect the EMG value given by $\\phi_e$ on the surface.\n\nFor larger datasets, a head-less render server of ParaView also can be run in parallel on a remote server and the graphical user interface shown in \\cref{fig:paraview_output} can be used as the client to interactively control the visualization.\n\nParaView also supports ray tracing using the OSPRay ray tracing engine. With ray tracing, more advanced lighting and the computation of shadows are possible.\n\n\\subsection{ExFiles and Visualization with CMGUI}\n\nAnother option in OpenDiHu is to output files in the \\say{ExFile} format. This format originates from the software environment of OpenCMISS. Output of results in simulations with OpenCMISS Iron relies on this type of files. The visualization toolbox of OpenCMISS Zinc is able to create various visualizations of the data given in this format. The program \\emph{CMGUI} provides a graphical user interface to visualize the data.\n\nThe output consists of corresponding \\code{.exelem} and \\code{.exnode} files containing information at element and node level, respectively. The mesh is assumed to be unstructured and, thus, the information which nodes correspond to a particular element has to be explicitly stored. It is stored in the \\code{.exelem} file. The payload data are contained in the \\code{.exnode} file. The file format supports parallel output to separate files. However, only serial output is supported in OpenDiHu.\nExFiles are ASCII-based and, thus, only usable up to a certain problem size.\n\nAn advantage of the \\say{ExFile} format is that also higher order elements can be represented. The visualization tools are capable of representing the geometric data accordingly, e.g., it is possible to visualize the correct shape of cubic Hermite 3D hexahedral elements. In contrast, ParaView only visualizes linear elements and linearly interpolates the data between the nodes of an element.\n\nThe program CMGUI can be used to visualize the output files of OpenDiHu in ExFile format.\nIn the graphical user interface, the \\code{.exelem} and \\code{.exnode} files can be loaded. Representations of loaded points, lines and elements can be added to the visualization in the scene editor. Various options such as coordinate frames and parameters for shading and tessellation can be set. The visualizations can be colored using predefined appearances or according to the loaded solution values.\n\nFor larger datasets, these manual adjustments are tedious. For example, for a dataset with 49 fibers, the user would have to load 49 \\code{.exelem} and 49 \\code{.exnode} files one by one. Instead, the Perl scripting interface of CMGUI can be used. Every command in the GUI corresponds to a Perl command and CMGUI can load and execute those commands from a given Perl script.\n\nOpenDiHu automatically creates such Perl scripts. The generated script for a mesh loads all generated output files into CMGUI, adds a  corresponding visualization depending on the mesh dimensionality and opens the required CMGUI windows such that the data are immediately visible. This is an improvement to OpenCMISS Iron, where all steps have to be done manually. By using the generated Perl script, less expert knowledge on the usage of CMGUI is required, and it is also possible to visualize datasets with a large number of fibers.\n\n\\Cref{fig:cmgui_output1} shows two windows of CMGUI. In \\cref{fig:current_configuration_1}, the main graphics window can be seen with a visualization of 49 muscle fibers. The membrane potential is visualized by varying colors, and action potentials can be seen on three of the shown fibers. Similar to ParaView, the transient data can be animated by using the controls at the bottom.\n\\Cref{fig:cmgui_spectrum} shows the spectrum editor, where the color scheme can be adjusted to the range of the loaded data.\n\nThe other Perl script besides the one used in \\cref{fig:cmgui_output1} to visualize the muscle fibers addresses the 3D mesh of the muscle.\n\\Cref{fig:cmgui_output2} shows the graphics windows with the resulting visualizations of this dataset. In \\cref{fig:cmgui_emg}, the extracellular potential $\\phi_e$ is visualized on the muscle surface. The visualization contains the colored 3D representation for the mesh and a 1D representation of the mesh consisting of white tubes.\n\n\\Cref{fig:cmgui_phie} demonstrates the feature of visualizing nodal data using glyphs. The $V_m$ values at every node are represented by colored circles with a radius that corresponds to the value. With this representation, it is possible to also show the data inside the muscle volume.\n\n\\begin{figure}%\n  \\centering%\n  \\begin{subfigure}[t]{0.62\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/cmgui_graphics1.png}\n    \\caption{The main graphics window that displays the visualization and allows to control the current view and the current timestep.}%\n    \\label{fig:current_configuration_1}%\n  \\end{subfigure}\n  \\begin{subfigure}[t]{0.363\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/cmgui_spectrum.png}\n    \\caption{The spectrum editor that can be used to adjust the coloring according to the loaded solution values.}%\n    \\label{fig:cmgui_spectrum}%\n  \\end{subfigure}\n  \\caption{Visualization of the results of an electrophysiology simulation with CMGUI involving 49 muscle fibers.}%\n  \\label{fig:cmgui_output1}%\n\\end{figure}%\n\n\\begin{figure}%\n  \\centering%\n  \\begin{subfigure}[t]{0.48\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/cmgui_emg.png}%\n    \\caption{Graphics window with the visualization of a 3D mesh.}%\n    \\label{fig:cmgui_emg}%\n  \\end{subfigure}\n  \\begin{subfigure}[t]{0.48\\textwidth}%\n    \\centering%\n    \\includegraphics[width=\\textwidth]{images/implementation/cmgui_phie.png}\n    \\caption{Visualization of the same data as in (a), but using sphere glyphs at every node.}%\n    \\label{fig:cmgui_phie}%\n  \\end{subfigure}\n  \\caption{Visualization of data on a 3D mesh with CMGUI.}%\n  \\label{fig:cmgui_output2}%\n\\end{figure}%\n\n\\subsection{Python Output Files}\nAnother option in OpenDiHu is to output data in a Python-friendly format, which can easily be parsed from within a python script.\nThe data can then be used, e.g., for error analysis or to convert them to other custom formats.\n\nIf the format \\code{PythonFile} is specified in the output writer, the data get written to output files. If the format \\code{PythonCallback} is specified, the same data are passed to a callback function and can directly be used in the Python settings script during the running simulation. \n\nFor output, the data are organized in a Python dictionary. The output files either contain the plain Python code of this dictionary or a binary representation obtained by the \\emph{pickle} package of Python. In parallel execution, every process writes its own file containing the data of the corresponding subdomain. OpenDiHu provides a Python module to parse these output files. The data representation, whether the data are stored in binary or in human-readable format and whether it is composed of multiple files resulting from parallel execution is abstracted and transparent in the call to this module.\n\nThe utility program \\code{plot} can be used to quickly visualize the simulation results in such Python output files. It creates plots and animations of 1D and 2D structured meshes and chooses different layouts for the type of data, e.g, a plot over time for single-cell CellML models or an animation with multiple plots for subcellular models with multiple ion channels. This script is useful mainly for 1D and 2D toy problems, such as the Laplace, Poisson and Diffusion problems.\n\n\\Cref{fig:python_output} shows the output of the \\code{plot} script for one muscle fiber. The top plot visualizes the geometry in 3D space, colored by the membrane potential $V_m$. The plot below shows the spatial progression of the $V_m$ value along the $x$-axis. However, for the visualization of 3D data, other options such as ParaView or CMGUI are better suited and should be used instead.\n\n\\begin{figure}%\n  \\centering%\n  \\includegraphics[width=\\textwidth]{images/implementation/python_output.png}%\n  \\caption{Visualization of Python based simulation results using the \\code{plot} utility.}%\n  \\label{fig:python_output}%\n\\end{figure}%\n\n\\subsection{ADIOS output files and MegaMol}\nAnother output format is the binary-pack file format defined by the Adaptable Input Output System library (ADIOS2). This type of output is selected by the OpenDiHu output writers for the \\code{`MegaMol`} format. ADIOS2 provides a framework for high-performance computing data management \\cite{adios2}. ADIOS2 manages self-describing data that allows rapid metadata extraction also from large data sets.\n\nOutput files in this format can be loaded into the visualization software MegaMol by experts. MegaMol has been successfully used together with OpenDiHu to implement in-situ visualization, where OpenDiHu shares the computed simulation data with MegaMol using the ADIOS2 format and triggers updates of the visualization by sending asynchronous messages to MegaMol during the runtime of the simulation. As both OpenDiHu and MegaMol can run in parallel, the partitioned data needs to be merged from all processes only at the stage of rendering the visualization image. For highly parallel runs on supercomputers, the local data that are generated by the OpenDiHu processes on the same compute node can be shared in memory with one instance of MegaMol per compute node. Then, all MegaMol instances collectively render the resulting visualization. This approach bypasses the costly file output operation on the highly distributed file system of a supercomputer.\n\n\\begin{figure}\n\\centering\n\\begin{framed}\n%\\begin{Verbatim}[fontsize=\\small]\n\\begin{lstlisting}[basicstyle=\\footnotesize\\ttfamily,commentstyle=\\color{gray},numbers=left,language=python]\n    string   config                         (...)\n    string   meta                           $\\text{\"}$current time: 2021/3/30 19:48:05,$\\textcolor{gray}{\\hookleftarrow}$\n                                             hostname: lapsgs05, n ranks: 4$\\text{\"}$\n    string   version                        $\\text{\"}$opendihu 1.2, built $\\textcolor{gray}{\\hookleftarrow}$\n                                             Mar 27 2021, C++ 201402, GCC 7.5.0$\\text{\"}$\n    double   localBoundingBox               10*{4, 6} = -56.3 / 19.7732   $\\label{alg:7.6}$\n    double   globalBoundingBox              10*{6} = -56.3 / 19.7732     $\\label{alg:7.7}$\n    double   global_radius                  10*scalar = 0.1 / 0.1\n    int32_t  nPointsPerCoordinateDirection  10*{3} = 4 / 31\n    int32_t  nodeOffsetOnOwnComputeNode     10*{4} = 0 / 368\n    int32_t  node_count                     10*scalar = 496 / 496\n    int32_t  rankNo                         10*{496} = 0 / 3                 $\\label{alg:7.12}$\n    double   emg                            10*{496} = -12.0536 / 4.89757    $\\label{alg:7.13}$\n    double   transmembraneFlow              10*{496} = -125.014 / 226.428    $\\label{alg:7.14}$\n    double   vm                             10*{496} = -81.3198 / -27.4762   $\\label{alg:7.15}$\n    double   xyz                            10*{1488} = -56.3 / 19.7732      $\\label{alg:7.16}$\n\\end{lstlisting}\n%\\end{Verbatim}\n\\end{framed}\n\\caption{Contents of the output file created by ADIOS2.}%\n\\label{fig:adios_output}%\n\\end{figure}             \n\nThe generated output files can be inspected using the \\code{bpls} utility. \\Cref{fig:adios_output} shows a description of the 3D dataset extracted from the binary-pack format that was written by a simulation with four processes.\nEach line corresponds to one variable in the file. The first column specifies the variable type and the second column is the name of the variable. The third column contains structural information with minimum and maximum values for numeric types. \n\nThe first three shown variables are of type \\code{string} and contain metadata for the simulation run. The \\code{config} variable contains the Python settings code of the scenario and, thus, accurately describes the settings of the simulation run. \nThe values of the \\code{meta} and \\code{version} variables are fully listed in \\cref{fig:adios_output} and contain meta information about the simulation program and the particular run. \n\nFor the numeric values, the third column specifies the dimension of the stored data. The file contains the simulation output for 10 different timesteps, which can be seen in the third column. For example, the \\code{localBoundingBox} variable in line \\ref{alg:7.6} stores 10 instances of a matrix with dimension $4\\times 6$. The four rows of this matrix correspond to the four processes and the columns store the six values of the geometric bounding box of the subdomain on the respective process. This information is required by MegaMol to constrain the volume that has to be rendered on each process. Further structural information is contained in the variables in lines \\ref{alg:7.7} to \\ref{alg:7.12}. \nThe remaining variables contain the payload data.  The variables \\code{emg}, \\code{transmembraneFlow} and \\code{vm} correspond to $\\phi_e$, the right-hand side of the first bidomain equation in \\cref{eq:static_bidomain_rhs}, and $V_m$, respectively. The variable  \\code{xyz} holds the geometry information for all nodes.\n\n\n\\begin{reproduce_no_break}\n  The visualizations in this section are based on outputs of the following simulation:\n  \\begin{lstlisting}[columns=fullflexible,breaklines=true,postbreak=\\mbox{\\textcolor{gray}{$\\hookrightarrow$}\\space}]\n    cd $\\$$OPENDIHU_HOME/examples/electrophysiology/fibers/fibers_emg/build_release\n    ./fast_fibers_emg ../settings_fibers_emg.py output_demo.py\n  \\end{lstlisting}\n  \n  Output files for ADIOS2, CMGUI, ParaView and Python will be generated in corresponding subdirectories under \\code{out/}.\n  The following commands invoke the respective visualization tool in the corresponding output directory:\n  \\begin{lstlisting}[columns=fullflexible,breaklines=true,postbreak=\\mbox{\\textcolor{gray}{$\\hookrightarrow$}\\space}]\n    paraview fibers.vtp.series              # ParaView\n    cmgui fibers.com                        # CMGUI\n    cmgui hd_emg.com                        # CMGUI\n    plot fibers_0000001_MeshFiber_*.py      # Python\n    bpls hd_emg.bp -la                      # ADIOS2\n  \\end{lstlisting}\n  In the graphical user interfaces of CMGUI and ParaView, more settings have to be adjusted to obtain the results shown in \\cref{fig:paraview_output,fig:cmgui_output1,fig:cmgui_output2}.\n  \n  The listing shown in \\cref{fig:adios_output} was obtained by a simulation with 4 processes. \n  Because the ExFile output writer does not work for parallel execution, the corresponding option has to be disabled in the \\code{output_demo.py} variables file prior to execution:\n  \\begin{lstlisting}[columns=fullflexible,breaklines=true,postbreak=\\mbox{\\textcolor{gray}{$\\hookrightarrow$}\\space}]\n    mpirun -n 4 ./fast_fibers_emg ../settings_fibers_emg.py output_demo.py\n  \\end{lstlisting}\n  Afterwards, the shown listing can be obtained by \\code{bpls -la hd_emg.bp}.\n\\end{reproduce_no_break}\n\n", "meta": {"hexsha": "546e67687ebee3a987a1193192417994899ef82c", "size": 59684, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "document/06_usage_1.tex", "max_stars_repo_name": "maierbn/phd_thesis_source", "max_stars_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-05T19:00:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-05T19:00:04.000Z", "max_issues_repo_path": "document/06_usage_1.tex", "max_issues_repo_name": "maierbn/phd_thesis_source", "max_issues_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "document/06_usage_1.tex", "max_forks_repo_name": "maierbn/phd_thesis_source", "max_forks_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 108.9124087591, "max_line_length": 1020, "alphanum_fraction": 0.7604215535, "num_tokens": 14879, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4417016301415664}}
{"text": "\\documentclass{article}\n\\pagestyle{empty}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\setlength{\\oddsidemargin}{0in} \\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{0in} \\setlength{\\textheight}{8.5in}\n\\setlength{\\textwidth}{6.5in}\n\n\\makeatletter\n\\renewcommand*\\env@matrix[1][*\\c@MaxMatrixCols c]{%\n\t\\hskip -\\arraycolsep\n\t\\let\\@ifnextchar\\new@ifnextchar\n\t\\array{#1}}\n\\makeatother\n\n\\begin{document}\n\\begin{flushleft}\n\t\\bfseries{MATH 260, Linear Systems and Matrices, Fall `14}\\\\\n\t\\bfseries{Activity 6:  Determinants}\\\\\n%\t\\bfseries{Honor Code:} \\hspace{3.5in}\\bfseries{Names:}\\\\\n\\end{flushleft}\n\\begin{flushleft}\n\n\\section*{Warmup: Specific Determinant Formulas}\n\n$|\\textbf{A}| = \\begin{vmatrix}[rr] a_{11} & a_{12} \\\\ a_{21} & a_{22} \\end{vmatrix} = a_{11} a_{22} - a_{12} a_{21}$ \n\n\\vspace{0.2in}\n\n$|\\textbf{A}| = \\begin{vmatrix}[rrr] a_{11} & a_{12} & a_{13} \\\\ a_{21} & a_{22} & a_{23} \\\\ a_{31} & a_{32} & a_{33} \\end{vmatrix} = a_{11} a_{22} a_{33} +  a_{12} a_{23} a_{31} + a_{13} a_{21} a_{32} - a_{13} a_{22} a_{31} - a_{11} a_{23} a_{32} - a_{12} a_{21} a_{33} $\n\n\\vspace{0.2in}\n\n\\textit{Note:} You will need to have at least the first formula memorized!  The second formula is called the ``basketweaving\" technique for solving $3 \\times 3$ determinants.  Note that basketweaving ONLY works for $3 \\times 3$s, it doesn't generalize to larger matrices.  We'll learn another technique, too, one that works on any size square matrix.\n\n\\vspace{0.2in}\n\n\nFind the determinant of the following matrices:\n\n\\begin{center}\n$\\begin{bmatrix}[rr]\n-3 & 1   \\\\\n4 & 2   \n\\end{bmatrix}\n$\n\\hspace{1in}\n$\\begin{bmatrix}[rrr]\n3 & 0 & -1\\\\\n0 & 0 &  3 \\\\\n0 & 1 & 0\n\\end{bmatrix}\n$\n\\end{center}\n\n\\newpage\n\n\n\\section{Some Properties and Practice}\n\nFor \\textbf{Activity 5} you found several inverses and transposes of matrices. Let's use them...\n\n\\begin{center}\n$\\textbf{H}=\\begin{bmatrix}[rr]\n1 & 1\\\\\n4  & 1\n\\end{bmatrix}$\n\\hspace{0.5in}\n$\\textbf{H}^{-1}=\\left[\n\\begin{array}{cc}\n- \\frac{1}{3} & \\frac{1}{3} \\vspace{0.1in}\\\\\n\n\\frac{4}{3} & - \\frac{1}{3}\n\\end{array} \\right]$\n\\hspace{0.5in}\n$\n\\textbf{H}^{T}=\\begin{bmatrix}[rr]\n1 & 4\\\\\n1  & 1\n\\end{bmatrix}$\n\\hspace{0.5in}\n$\\textbf{G}=\n\\begin{bmatrix}[rrr]\n3 & 0 & 3\\\\\n-1 & 2 & 1\\\\\n1 & 1 & 2\n\\end{bmatrix}$\\\\\n\\end{center}\n\n\\vspace{0.1in}\n\na) Find $|\\textbf{H}|$.\n\n\\vspace{1in}\n\nb) Find $|\\textbf{H}^{-1}|$.\n\n\\vspace{1in}\n\nc) Find $|\\textbf{H}^{T}|$.\n\n\\vspace{1in}\n\nd) Find $|\\textbf{G}|$.\n\n\\vspace{1in}\n\ne) Are any of the numbers above the same? Closely related? Try to write each as a generalized property.\n\n\\newpage\n\n\n\\section{Finding Minors}\n\n\n\\textbf{Definition:} For the $n \\times n$ matrix \\textbf{A}, the \\textit{minor $M_{ij}$} of $a_{ij}$ is an $(n-1) \\times (n-1)$ matrix obtained by deleting the $i$th row and the $j$th column of \\textbf{A}.\n\n\\begin{center}\n$\\textbf{A}=\n\\begin{bmatrix}\n\\bullet &\\bullet &\\bullet & \\bullet \\\\\n\\bullet &\\bullet &\\bullet & \\bullet \\\\\n\\bullet &\\bullet &\\bullet & \\bullet \\\\\n\\bullet &\\bullet &\\bullet & \\bullet \\\\\n\\end{bmatrix}\n=\n\\begin{bmatrix}[rrrr]\n1&2&3&1\\\\\n5&0&1&-2\\\\\n4&0&1&0\\\\\n2&0&3&1\n\\end{bmatrix}\n$\n\\hspace{0.4in}\n$\\textbf{M}_{12}=\n\\begin{bmatrix}\n\\circ & \\circ & \\circ & \\circ \\\\\n\\bullet & \\circ & \\bullet & \\bullet \\\\\n\\bullet & \\circ & \\bullet & \\bullet \\\\\n\\bullet & \\circ & \\bullet & \\bullet \\\\\n\\end{bmatrix}\n\\rightarrow\n\\begin{bmatrix}\n\\bullet & \\bullet & \\bullet \\\\\n\\bullet & \\bullet & \\bullet \\\\\n\\bullet & \\bullet & \\bullet \\\\\n\\end{bmatrix}\n=\n\\begin{bmatrix}[rrr]\n5 & 1&-2\\\\\n4 & 1& 0\\\\\n2&3&1\n\\end{bmatrix}$\n\\end{center}\n\na) Find the minor $\\textbf{M}_{43}$ of $\\textbf{A}$.\n\n\\vspace{1.25in}\n\nb) Let's find some minors of $\\textbf{B} =\n\\begin{bmatrix}[rrr]\n5 & 1&-2\\\\\n4 & 1& 0\\\\\n2&3&1\n\\end{bmatrix}$.  Notice that $\\textbf{B}$ is just $\\textbf{M}_{12}$ from above, so you'll be finding the minor of a minor.\n\n\\vspace{0.2in}\n\n(i) Find $\\textbf{M}_{21}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\n(ii) Find $\\textbf{M}_{22}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\n(iii) Find $\\textbf{M}_{23}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\nc) Find the determinant of the minors you found in part (b).\n\n\\vspace{0.2in}\n\n(i)\n\n\\vspace{0.5in}\n\n(ii)\n\n\\vspace{0.5in}\n\n(iii)\n\n\\newpage\n\n\\section{Co-Factors}\n\n\\textbf{Definition:} The \\textit{co-factor} of an element $a_{ij}$ is the scalar: $C_{ij}=(-1)^{i+j}|\\textbf{M}_{ij}|$\n\n\\vspace{0.2in}\n\nNotice that the co-factor is just the determinant of a minor, times $\\pm 1$. We'll use this in the next part of the activity.\n\n\\vspace{0.2in}\n\na) Find $C_{21}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\nb) Find $C_{22}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\nc) Find $C_{23}$ of $\\textbf{B}$\n\n\\vspace{0.75in}\n\nd) Can you find $C_{12}$ of \\textbf{A} (based on what you've already computed)? Why or why not?\\\\\n\n\\vspace{1in}\n\n\\section{Determinants of $n \\times n$ matrices}\n\nLet's start by finding the determinant of the $3 \\times 3$ matrix $\\textbf{B}$.\n\n\\vspace{0.2in}\n\na) First find the determinant of $\\textbf{B}$ using the basketweaving technique from the warm-up.\n\n\\pagebreak\n\nb) Find the following sum: \\hspace{0.2in} $b_{21}*C_{21} + b_{22}*C_{22} + b_{23}*C_{23}$ \\\\\n\n\\vspace{0.2in}\n\n\\textit{Hint: You should get a single, scalar number, which should look familiar.}\\\\\n\n\\vspace{1in}\n\nc) Try writing the sum for (b) in summation notation (i.e. using: $\\Sigma$).\\\\\n\n\\vspace{2in}\n\nThis method of finding the determinant is called ``cofactor expansion by a row or column.\"  Here, we found the determinant of $\\textbf{B}$ by expanding by row 2.  You can obtain the determinant by using the formula you found in part (c) but you can pick any row or column the general formula is given on page 157 of your textbook, and below.  Since you can pick any row or column, it is often wise to pick the row or column with the most 0s, to make computation easier.\n\n\\vspace{0.2in}\n\n\\textbf{Definition:} Choose a row $i$ or column $j$, then $|A|=\\sum\\limits^{n}_{(j \\text{ or } i)} a_{ij} C_{ij} = \\sum\\limits^{n}_{j \\text{ or } i} a_{ij} (-1)^{i+j} |\\textbf{M}_{ij}| $\n\n\\vspace{0.2in}\n\nFor matrices larger than $3 \\times 3$, finding the determinant of an $n \\times n$ matrix is a recursive process.  Notice that $\\textbf{M}_{ij}$ may not be a $2 \\times 2$!  You might have to use this process several times, reducing the size of the minors by 1 each time.\n\n\\vspace{0.2in}\n\nc) Using this definition find the determinant of our original $\\textbf{A}$ matrix.  (Use cofactor expansion to reduce the determinant from a $4 \\times 4$ to a sum of $3 \\times 3$ determinants, then either use basketweaving on those, or do a cofactor expansion on each $3 \\times 3$ to make a sum of $2 \\times 2$ determinants.\n\n\\vspace{0.2in}\n\n\\textit{Hint: You should only need to do a few new multiplications and additions, you calculated most of it already.}\n\n\\end{flushleft}\n\\end{document}", "meta": {"hexsha": "5e09a29c0041c2e8b8b4e03e4b0c7d1a37e4ec68", "size": 6778, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Fall 2014 - Capaldi A/Activities/Activity06_Determinants.tex", "max_stars_repo_name": "Pelonza/PB-LinAlg", "max_stars_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Fall 2014 - Capaldi A/Activities/Activity06_Determinants.tex", "max_issues_repo_name": "Pelonza/PB-LinAlg", "max_issues_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fall 2014 - Capaldi A/Activities/Activity06_Determinants.tex", "max_forks_repo_name": "Pelonza/PB-LinAlg", "max_forks_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.5773584906, "max_line_length": 469, "alphanum_fraction": 0.6624372971, "num_tokens": 2519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795672, "lm_q2_score": 0.8376199673867852, "lm_q1q2_score": 0.4416908491157061}}
{"text": "\\documentclass{article}\n\n\\include{stddefs}\n\\include{genericdefs}\n\n\\newcommand{\\red}[1]{\\textcolor{red}{\\textbf{#1}}}\n\\newcommand{\\green}[1]{\\textcolor{green}{\\textbf{#1}}}\n\n\\begin{document}\n\n\\chapterno{1}\n\n\\chapter{The language of mathematics}\n\nWe need to introduce some formal notation to be able to talk clearly about mathematics and also in a reasonable way \nformulate mathematical models of the real world. In modern mathematics the \nconcept of a set is crucial. It is \\url{a bit tricky}{https://en.wikipedia.org/wiki/Set_theory\\#Axiomatic_set_theory} to define this precisely.\nWe will go on and define the basic concepts of what is called \n\\url{naive set theory}{https://en.wikipedia.org/wiki/Naive_set_theory}.\n\nMathematics is hard and there are a lot of relevant and good questions\nto ask. For example, I do not agree that\n% \\url{\\includegraphics[width=\"50\\%\"]{tweetmath.png}}{https://twitter.com/aIeturner/status/1298372968838508546}\n\\includegraphics[width=\"50\\%\"]{tweetmath.png}\nis \\emph{the dumbest video ive ever seen}. In learning mathematics,\nthere should be no place for arrogance and putting other people down.\n\n\\begin{hideinbutton}{Emergency access}\n  For some reason the Twitter account of Mohammed El Mocro %(in the link above)\n  has been suspended. Here is a salvaged copy of the original TikTok video that went viral.\n\n\n\\youtube{SqTtWIiS42o}\n\\end{hideinbutton}\n\n\\section{Computer algebra}\n\nWe will use the computer algebra system\n\\url{Sage}{http://www.sagemath.org/} in exploring and experimenting\nwith mathematics. This means that you will have to write small\ncommands and code snippets. Sage is built on top of the very wide\nspread language\n\\url{Python}{https://en.wikipedia.org/wiki/Python_(programming_language)}\nand you can in fact enter \\footnote{Python code}{One may also enter code in several other languages, but I have so far only set the interface up for Sage and Python} in\nthe Sage input windows in this text. Below is an example of a basic\ngraphics command in Sage.  Push the Compute button to evaluate.\n\n\n\\begin{sage}\nplot(sin(x) + cos(2*x), (x, 0, 2*pi))\n\\end{sage}\n\n\n\\beginshex\nDid you notice that you can edit and enter new commands in the Sage window?\nDo the following problems using Sage based on the \\url{Sage guided tour}{http://doc.sagemath.org/html/en/tutorial/tour.html}. \n\n\\begin{enumerate}[(i)]\n\\item Consider $f(x) = x \\sin(1/x)$. Plot the graph of $f$ from $0$ to $0.1$. Computing $f(0)$ does not make sense. Do you\n  see a way of assigning a natural value to $f(0)$ using the graph?\n\\item Find an approximate solution with four decimals to the equation $\\cos(x) = x$.\n  \n  \\begin{hint}[showhide]\n    This is an example of an equation, that can only be solved numerically.\n    Try first plotting the graph of $f(x) = x - \\cos(x)$ from $0$ to $1$. Then use a\n    suitable function from the Sage guide.\n    \\end{hint}\n\\item Compute $\\pi$ with $100$ decimals.\n\\end{enumerate}\n  \n\\endshex\n\n\n\\section{Objects or elements and the symbols $=$ and $\\neq$}\n\nMathematics can be broadly viewed as handling objects precisely\naccording to a specific system of rules. The first element\nof precision is in distinguishing the objects and deciding when\nthey are the same. This calls for notation. If two objects\n$x$ and $y$ are the same, we write $x = y$. If they are different\nwe write $x\\neq y$.\n\nYou may laugh here, but identifying objects is really one of the fundamental tasks of mathematics.\nIt is not always that easy. Even though objects appear different they are the same as\nin, for example\n$$\n\\frac{105}{189} = \\frac{35}{63}\\qquad\\text{and}\\qquad \\sin\\left(\\frac{\\pi}{2}\\right) = 1.\n$$\nThe first example above is an identity of fractions (rational numbers). The second is\nan identity, which calls for knowledge of the sine function and real numbers. Each of these\nidentities calls for some rather advanced mathematics.\n\n\n\\beginshex\\label{sagecompex1}\n\n\\begin{sage}\nvar('a b')\ne = (a+b)^2\ne.expand()\n\\end{sage}\n\nUse the Sage window above to reason \nabout equality in the quiz below. In each case describe the objects i.e.,\nare they numbers, symbols, etc.? Also, please check your computations\nby hand with the old fashioned paper and pencil, especially $(a+b)(a-b)$.\n\n\\begin{quiz}\n\\question\nClick on the right equalities below.\n\\answer{T}\n$$a + b - 2 b = a - b$$\n\\answer{F}\n$$(a+b)^2 = a^2 + b^2$$\n\\answer{T}\n$$(a + b)(a - b) = a^2 - b^2$$\n\\answer{T}\n$$(a + b)^2 = a^2 + 2 a b +  b^2$$\n\\answer{F}\n$$(a+b)^3 = a^3 + 2 a^2 b + 2 a b^2 + b^3$$\n\\answer{F}\n$$\\frac{3}{8} = \\frac{5}{13}$$ \n\\answer{F}\n$$\n\\pi = \\frac{22}{7}\n$$\n\\answer{T}\n$$\n\\cos^2(\\pi) + \\sin^2(\\pi) = 1\n$$\n\\end{quiz}\n\\endshex\n\n\\beginshex\nYou know that $(a+ b)^2 = a^2 + 2 a b + b^2$. Use Sage to find a similar identity\nfor $(a + b)^4$.\n\n\\begin{hint}[showhide]\n  Go back and look at (the beginning of) Exercise \\ref{sagecompex1}.\n\\end{hint}\n\\endshex\n\n\n\n\\section{Sets}\n\nA set is (informally) a collection of distinct objects or \\emph{elements}. \n\n\\begin{equation*}[emph]\n  \\text{Two sets are equal if they contain the same elements.}\n\\end{equation*}\n\nAn example of a set could be \nthe set $\\{1,2,3\\}$ of natural numbers between $0$ and $4$. Notice that we use the symbol\n\"$\\{$\" to start the listing of elements in a set and the symbol \"$\\}$\" to denote the end of the listing.\nNotice also that (by our definition of equality between sets), the order of the elements in the listing does not matter i.e.,\n$$\n\\{1, 2, 3\\} = \\{2, 3, 1\\}.\n$$\nWe are also not allowing duplicates like for\nexample in the listing $\\{1, 2, 2, 3, 3, 3\\}$ (such a thing is called a \\url{multiset}{https://en.m.wikipedia.org/wiki/Multiset}).\n\nAn example of a set not involving numbers could be the set of letters \n$$\nS=\\{A, n, e, x, a, m, p, l, c, o, u, d, b, t, h, s, r, i\\}\n$$ \nused in this sentence. The number of elements in a set $S$ is called the \\emph{cardinality} of the set.\nWe will denote it by $|S|$.\n\n\\beginshex\nGive a precise reason as to why the two sets $\\{1, 2, 3\\}$ and $\\{1, 2, 4\\}$ are not equal.\nIs it possible for a set with $5$ elements to be equal to a set with $7$ elements?\n\\endshex\n\n\n\nSets may be explored using Sage. This is illustrated in the Sage snippet below.\n\n\\begin{code}\nX = Set([1, 2, 3])\nY = Set([2, 3, 1])\nprint(\"X=Y is \", X==Y)\n\nS = Set(['A','n','e','x','a','m','p','l','c','o','u','d','b','t','h','s','r','i'])\nprint(\"S = \", S) \nprint(\"The number of elements in S is |S|=\", S.cardinality())\n\\end{code}\n\n\n\\subsection{The empty set}\n\nThere is a unique set containing no or zero elements. This set is called the empty set and\nis denoted $\\emptyset$ i.e.,\n$$\n\\emptyset = \\{\\}\\qquad\\text{and}\\qquad |\\emptyset| = 0.\n$$\nThe empty set and its cardinality may be explored using the Sage code below.\n\n\\begin{code}\nemptyset = Set([])\nprint(emptyset.cardinality())\n\\end{code}\n\n\n\n\n\\subsection{Sets of numbers}\n\nA set could also be the natural numbers (yes, I want $0$ as a natural number:\n$0$ is very natural, although it came late \\url{historically}{https://en.wikipedia.org/wiki/0})\n$$\n\\NN = \\{0, 1, 2, 3, \\dots\\},\n$$\nor the set of integers\n$$\n\\ZZ = \\{\\dots, -3, -2, -1, 0, 1, 2, 3, \\dots\\}.\n$$\nThese sets are called infinite, since they contain infinitely many elements. Even though\nthe natural numbers seem as easy as one, two three, they contain wonderful and deep\nmathematical mysteries, such as the nature and distribution of the prime numbers\n$2, 3, 5, 7, 11, 13, 17, \\dots$. Also please respect, that the \\url{negative numbers}{https://en.m.wikipedia.org/wiki/Negative_number} like\n$-3, -1\\in \\ZZ$ have caused confusion for centuries.\n \nWe also have\nthe set $\\QQ$ of rational numbers (fractions) and the set\n$\\RR$ of real numbers. The real numbers\ncontains all the possible numbers that we encounter in \nthis course.\n\nWe will not define the\narithmetic operations (like addition and multiplication) on $\\ZZ, \\QQ$\nand $\\RR$ \nformally. I will assume that you know how to add and multiply fractions,\nand that you \\textbf{do not make mistakes like}\n$$\n\\color{red}\n\\frac{1}{2} + \\frac{2}{3} = \\frac{1+2}{2+3}=\\frac{3}{5}.\n$$\nSimilarly, I will assume that you know that a rational number stays the\nsame, when the numerator and denominator is multiplied by the same non-zero \ninteger. For example,\n$$\n\\frac{1}{2} = \\frac{3}{6}\\qquad\\text{and}\\qquad \\frac{2}{3} = \\frac{4}{6}.\n$$\nIn fact, \n$$\n\\frac{1}{2} + \\frac{2}{3} = \\frac{3}{6} + \\frac{4}{6} = \\frac{3 + 4}{6} = \\frac{7}{6}.\n$$\nThe computation above says that it is straightforward to add pizza slices of the\nsame size (one sixth), but that you need to think a bit when adding one half pizza slice and\ntwo pizza slices of size one third.\n\n\n\n\n\\begin{quizexercise}[showhide]\n  \\begin{quiz}\n\\question\nClick on the right equalities below. Do not use Sage (or any computer)!\n\\answer{F}\n$$\n\\frac{1}{5} + \\frac{1}{7} = \\frac{1}{35}\n$$\n\\answer{T}\n$$\n\\frac{3}{7} + \\frac{4}{7} = 1\n$$\n\\answer{T}\n$$\n\\frac{2}{3} + \\frac{3}{2} - 2 = \\frac{1}{6}\n$$\n\\answer{F}\n$$\n\\frac{1}{3} + 2 = \\frac{8}{3}.\n$$\n\\end{quiz}\n\\end{quizexercise}\n\n\\subsection{The symbols $\\in$ and $\\notin$}\n\nThe symbol $\\in$ is ubiquitous in set theory (and mathematics). \nIt means \\emph{belongs to} or \\emph{is an element of} as in \n$x\\in A$, where $x$ is an element and $A$ is a set. The symbol\n$\\notin$ means is \\textbf{not} an element of as in\n$x\\notin A$ meaning $x$ is not an element of $A$.\n\n\n\\begin{quizexercise}[showhide]\n\\begin{paraquiz}\n  \\question\n  \\box$\\in$\\box, but \\box$\\not\\in$\\box. This exercise actually has \\box possible correct solutions\nif $\\{1, 2, 3\\}$ is in the second empty box and $\\{4, 5, 6\\}$ in the fourth empty box.\n  \\answer\n  $\\{1, 2, 3\\}$\n  \\answer\n  $\\{4, 5, 6\\}$\n  \\answer\n  $0$\n  \\answer\n  $1$\n  \\answer\n  $3$\n  \\answer\n  $6$\n  \\answer\n  $7$\n\n  \\case{(is 41326)}{T} \n  \\green{Correct!}\n  \\case{(is 41526)}{T} \n  \\green{Correct!}\n  \\case{(is 41726)}{T} \n  \\green{Correct!}\n  \\case{(is 51326)}{T} \n  \\green{Correct!}\n  \\case{(is 51426)}{T} \n  \\green{Correct!}\n  \\case{(is 51726)}{T} \n  \\green{Correct!}\n\n  \\default\n  \\red{Nope. Try again!}\n\\end{paraquiz}\n\\end{quizexercise}\n\n\nBelongs to ($\\in$) is straightforward in Sage:\n\n\\begin{code}\nS = Set([1,2,3])\nprint(\"S = \", S)\nprint(\"The element 1 is in S: \", 1 in S)\nprint(\"The element 4 is in S: \", 4 in S)\n\\end{code}\n\n\n\n\\subsection{Subsets and the symbols $\\subseteq$ and $\\not\\subseteq$}\n\nIf $A$ and $B$ are sets, then $A\\subseteq B$ means that\nevery element of $A$ is also an element of $B$. In this case we say\nthat \\emph{$A$ is a subset of $B$}.\n\nWe have\nfor example that \n$$\n\\NN \\subseteq \\ZZ.\n$$\nWhat does $A\\not\\subseteq B$ mean? Here we have to be a little\ncareful. We want this notation to mean that $A$ is \\textbf{not} a\nsubset of $B$. In order for $A\\subseteq B$ to be\nfalse, there must exist $x\\in A$, such that $x\\notin B$. This\nis the meaning of $A\\not\\subseteq B$. For example, \n$$\n\\ZZ\\not\\subseteq \\NN,\n$$\nsince $-1\\in \\ZZ$ and $-1\\notin \\NN$.\n\n\\begin{quizexercise}[showhide]\n\\begin{paraquiz}\n  \\question\n  The set \\box is not a subset of $A=$\\box, simply because \\box does not belong to $A$.\n  This exercise actually has \\box possible correct solutions.\n  \\answer\n  $\\{1, 2, 3\\}$\n  \\answer\n  $\\{-1, 1, 2, 3, 4\\}$\n  \\answer\n  $\\{-1, 0, 1, 2, 4\\}$\n  \\answer\n  $3$\n  \\answer\n  $-1$\n  \\answer\n  $5$\n  \\answer\n  $6$\n  \\answer\n  $0$\n  \\case{(is 1347)}{T} %13(3)\n  \\green{Correct!}\n  \\case{(is 2157)}{T} %21(-1)\n  \\green{Correct!}\n  \\case{(is 2347)}{T} %23(3)\n  \\green{Correct!}\n  \\case{(is 3287)}{T} %32(0)\n  \\green{Correct!}\n  \\case{(is 3157)}{T} %31 (-1)\n  \\green{Correct!}\n  \\case{(is 3187)}{T} %31 (0)\n  \\green{Correct!}\n  \\default\n  \\red{Nope. Try again!}\n\\end{paraquiz}\n\\end{quizexercise}\n\n\n\nBelow Sage will list all subsets of the set $\\{1, 2, 3\\}$. Before pressing\nthe Compute button, try to write them down on your own.\n\n\\begin{sage}\nX = Set([1,2,3])\nlist(X.subsets())\n\\end{sage}\n\n\n\\begin{quizexercise}[showhide]\n\\begin{paraquiz}\n  \\question\n  The empty set has \\box elements. A set with \\box elements has \\box subsets. In general a set with\n  $n$ elements has \\box subsets.\n  \\answer\n  $1$\n  \\answer\n  $0$\n  \\answer\n  $5$\n  \\answer\n  $25$\n  \\answer\n  $32$\n  \\answer\n  $n^2$\n  \\answer\n  $2^n$\n  \\case{(is 2357)}{T}\n  \\green{Correct!}\n  \\default\n  \\red{Nope. Try again!}\n\\end{paraquiz}\n\\end{quizexercise}\n\n\nIt turns out that the empty set $\\emptyset$ is a subset of any set. Does this\nmake sense?\n\n\\subsection{Intersections, unions and the symbols $\\cap,\\,\\, \\cup$ and $\\setminus$}\n\nSuppose that we have two sets $A$ and $B$. Then the \\emph{intersection} $A\\cap B$ is the\nset consisting of the elements in both $A$ and $B$. This is illustrated in the\nsocalled \\url{Venn diagram}{https://en.wikipedia.org/wiki/Venn_diagram} below.\n\n\\includegraphics{vennintersection.svg}\n\nThe \\emph{union} $A\\cup B$ is the\nset consisting of the elements in $A$ or $B$. To be more precise, an element is in\n$A\\cup B$ if it is in $A$ or in $B$ (or in both of them):\n\n\\includegraphics{vennunion.svg}\n\nLastly, the\ndifference $A\\setminus B$ (between $A$ and $B$) consists of the elements\nin $A$, the are not contained in $B$:\n\n\\includegraphics{venndifference.svg}\n\nYou should experiment using the Sage window below to get a feeling for these three operations.\n\n\\begin{sage}\nA = Set([1, 2, 3, 4, 5, 6, 7, 8, 9])\nB = Set([7, 8, 9, 10, 11, 12])\nprint(\"A =\", A)\nprint(\"B =\", B)\nprint(\"The intersection of A and B is \", A.intersection(B))\nprint(\"The union of A and B is \", A.union(B))\nprint(\"The difference between A and B is \", A.difference(B))\n\\end{sage}\n\n\\beginshex\nGiven two sets $A$ and $B$, is it true that\n$A \\cap B = B \\cap A$ and $A\\cup B = B\\cup A$?\n\nWhat about $A\\setminus B = B\\setminus A$?\n\nSuppose that $A$ and $B$ are two finite sets. Is it true that\n$$\n|A\\setminus B| = |A| - |B|?\n$$\nWhat about\n$$\n|A\\cup B| = |A| + |B|?\n$$\nSeriously, both formulas are wrong. Can you come up with the correct\nversion of the formula for $|A \\cup B|$?\n\nUse your correct formula to find a formula for\n$$\n|A\\cup B \\cup C|\n$$\nviewing $A\\cup B$ as the first set and $C$ as the second set. Here you need\nthe formula\n$$\n(A\\cup B)\\cap C = (A\\cap C) \\cup (B\\cap C).\n$$\nWhy is this formula true?\n\\endshex\n\n\\beginshex\nThere is one more operation called the symmetric difference between two sets $A$ and $B$. It is\ndenoted $A\\, \\Delta\\, B$. Experiment in the Sage window below to find out exactly what it does.\nIs it true that $A\\, \\Delta\\, B = B\\, \\Delta\\, A$?\n\n\\begin{sage}\nA = Set([1,2,3,4])\nB = Set([4,5,6,7])\nprint(\"A =\", A)\nprint(\"B =\", B)\nprint(\"The symmetric difference between A and B is \", A.symmetric_difference(B))\n\\end{sage}\n\\endshex\n\n\\begin{hideinbutton}{CS test on sets}\n\nThe following is an excerpt from the infamous \\emph{Beredskabsprøve Datalogi}.\n\n\\begin{quiz}\n\\question\nLet $X$ and $Y$ denote sets. Which of the following are true?\n\\answer{T}\n$X \\cup X = X$\n\\answer{T}\n$X\\cap X = X$\n\\answer{F}\n$X\\setminus X = X$\n\\answer{T}\n$X\\subseteq X\\cap X$\n\\answer{T}\n$\\emptyset \\subseteq X$\n\\answer{T}\nFor some sets $X$ and $Y$ we can have\n$$\nX\\cap Y = X\\cup Y.\n$$\n\\end{quiz}\n\\end{hideinbutton}\n\n\\subsection{Pairs, triples and tuples}\n\nGiven two sets $A$ and $B$ we can form the new set $A\\times B$,\nwhich is the set of pairs $(a, b)$, where $a\\in A$ and\n$b\\in B$. For example,\n$$\n\\{1, 2\\}\\times \\{1, 2, 3\\} = \n\\{(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)\\}.\n$$\nThe set $A\\times B$ is also called the \\url{Cartesian\n  product}{https://en.wikipedia.org/wiki/Cartesian_product} of $A$ and\n$B$.\n\n\\beginshex\nConsider two pairs $(a, b)$ and $(c, d)$. What is a natural way of defining\nequality between these pairs i.e., $(a, b) = (c, d)$?\n\\endshex\n\n\n\\begin{sage}\nA = Set([1, 2])\nB = Set([1, 2, 3])\nC = cartesian_product([A, B])\nprint(\"A =\", A)\nprint(\"B =\", B)\nprint(\"The cartesian product of A and B is \", list(C))\n\\end{sage}\n\nThere is no need to restrict ourselves to tuples. We might as well\nconsider triples $A\\times B\\times C$ i.e., \nthe set of all $(a, b, c)$, where $A$, $B$ and $C$ are sets, or\nfor that matter tuples\n$$\n(a_1, a_2, \\dots, a_n)\\in A_1\\times A_2\\times \\cdots \\times A_n\n$$\nof any length $n\\in \\NN$, where $a_1\\in A_1, a_2\\in A_2, \n\\dots, a_n\\in A_n$. Based on the above example with tuples we have,\n\\begin{align*}\n&\\{0\\}\\times\\{1, 2\\}\\times \\{1, 2, 3\\} = \\\\\n&\\{(0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 2, 1), (0, 2, 2), (0, 2, 3)\\}.\n\\end{align*}\n\nYou may check this using the Sage snippet below.\n\n\\begin{code}\nA = Set([0])\nB = Set([1, 2])\nC = Set([1, 2, 3])\nprint(\"A =\", A)\nprint(\"B =\", B)\nprint(\"C =\", C)\nD = cartesian_product([A, B, C])\nprint(\"The cartesian product of A, B and C is \", list(D))\n\\end{code}\n\n\nFor a given set $A$ and $n\\in \\NN$ we define $n$-fold cartesian product of $A$ as\n$$\nA^n = \\underbrace{A\\times A\\times \\cdots \\times A}_{n\\text{ times}}.\n$$\n\\begin{code}\nA = Set([1,2])\nn = 3\nB = cartesian_product([A]*n)\nprint(\"A =\", A)\nprint(\"n =\", n)\nprint(\"The n-fold cartesian product of A is \", list(B))\n\\end{code}\n\n\\beginshex\nLet $A$ and $B$ be two sets. Is $A\\times B = B \\times A$?\n\nLet $X$ be any set. What is $\\emptyset \\times X$?\n\nLet $A, B, C$ and $D$ be four sets. Is\n$$\n(A\\times B)\\setminus (C\\times D) = (A\\setminus C)\\times (B\\setminus D)?\n$$\n\\endshex\n\n\n\n\\section{Ordering numbers}\n\nLet us be a little rigorous and introduce the (usual) ordering\non our numbers with addition and multiplication using almost full blown\nmathematical formalities. First the formal definition for two\nintegers $x, y\\in \\ZZ$:\n\n\\begin{equation}[emph]\\label{ordZ}\nx \\leq y\\qquad \\text{ means that }\\qquad y - x\\in \\NN\n\\end{equation}\n\n\nNotice that $x = y$ implies that $x\\leq y$ (and $y\\leq x$).\nAlong this line we also define $x < y$ if $x \\leq y$ and $x\\neq y$.\n\n\\begin{quizexercise}[showhide]\n\\begin{orderquiz}\n  \\question\n  Assume that $x, y, z\\in \\ZZ$ and that $x \\leq y$. Then drag and drop the\n  elements from the left to the right below to explain that\n  $x + z \\leq y + z$.\n  \\answer %1\n  By assumption $x\\leq y$.\n  \\answer %2\n  This means that $z - x + y\\in \\NN$\n  \\answer %3\n  This means that $y - x\\in \\NN$\n  \\answer %4\n  To show that $x + z \\leq y + z$, we need to show that\n  $(y + z) - (x + z) \\in \\NN$.\n  \\answer %5\n  But $(y + z) - (x + z) = y + z - x + z$. Therefore,\n  \\answer %6\n  But $(y + z) - (x + z) = y + z - x - z = y - x$. Therefore,\n  \\answer %7\n  $(y + z) - (x + z)\\in \\NN$, since\n  \\answer %8\n  $y - x \\in \\NN$\n  \\expected{6}\n\n  \\case{(is 134678)}{T}\n  \\green{Spot on, my friend.}\n\n  \\case{(is 467813)}{T}\n  \\green{This is right!}\n  \n  \\case{(is 413678)}{T}\n  \\green{This is right!}\n\n  \\default\n  \\red{Wrong order. Check the definition of $\\leq$ in \\eqref{ordZ} once more!}\n\\end{orderquiz}\n\\end{quizexercise}\n\n\nYou can\nsee that this definition agrees with our preconception that\n\\begin{equation}\\label{ordwrong}\n\\cdots < -3 < -2 < -1 < 0 < 1 < 2 < \\cdots\n\\end{equation}\n\n\\begin{exercise}[showhide]\n  To be precise, writing $\\cdots < -3 < -2 < -1 < 0 < 1 < 2 < \\cdots$ is nonsense, since $\\leq$ is only defined for two integers in \\eqref{ordZ}. How is one supposed to interpret $0 < 1 < 2$ for example? Go ahead and write \\eqref{ordwrong} the\n  right way. Also, suppose \\footnote{that}{As an example, this could be assuming $1 \\leq 2$ and $2 \\leq 5$ and then\n    arguing that $1\\leq 5$.}\n  $$x \\leq y\\qquad\\text{and}\\qquad y\\leq z\n  $$\n  for three integers $x, y, z\\in \\ZZ$. Argue\n  from the definition in \\eqref{ordZ} that $x\\leq z$.\n\n  How does Python/Sage interpret $-3 < -2 < -1< 0 < 1 < 2$? Find out using the Sage snippet below.\n  \n  \\begin{code}\nprint(-3 < -2 < -1 < 0 < 1 < 2)\n  \\end{code}\n  \n  What about $1 < 5 > 3 < 4$? \n\\end{exercise}\n\nNotice that the integers has huge holes. Given two integers $a, b\\in \\ZZ$, such\nthat $a < b$, we cannot always find an integer $c\\in \\ZZ$ in between $a$ and $b$:\n$$\na < c < b.\n$$\n\nThe rational numbers has the property that they do not have holes. We can\nalways find an in between number such as $c$ above. But we need a precise way\nof comparing rational numbers. A way to explain precisely why for example\n$$\n\\frac{2}{3}\\,\\, \\leq \\,\\, \\frac{5}{7}.\n$$\nOf course, you can enter the two numbers a on computer and see that\n$\\frac{2}{3}$ is approximately $0.67$ and $\\frac{5}{7}$\nis approximately $0.71$, but we aim for the mathematical\nprecise definition.\n\nA\nrational number $\\frac{p}{q}$ consists of a numerator $p\\in \\ZZ$ and a denominator\n$q\\in \\ZZ$ with $q > 0$. We already know the criterion for two rational numbers\n$\\frac{p}{q}$ and $\\frac{p'}{q'}$\nto be \\footnote{equal}{Technically speaking we are defining a socalled \\emph{equivalence relation} identifying the infinitely many ways of writing a rational number into one.}:\n\n\\begin{equation*}[emph]\n\\frac{p}{q}\\, =\\, \\frac{p'}{q'}\\qquad \\text{ means that }\\qquad p q' = p' q\\qquad (\\text{in }\\ZZ).\n\\end{equation*}\n\n\nWe wish to compare the two rational numbers $\\frac{p}{q}$ and $\\frac{p'}{q'}$ deciding\nprecisely how they are ordered:\n\n\\begin{equation}[emph]\n\\frac{p}{q}\\, \\leq\\, \\frac{p'}{q'}\\qquad \\text{ means that }\\qquad p q' \\leq p' q\\qquad (\\text{in }\\ZZ).\n\\end{equation}\n\n\nAs for the integers, we also define $x < y$ if $x \\leq y$ and $x\\neq y$ for\ntwo rational numbers $x$ and $y$.\n\nUsing this definition, you can check that $\\frac{2}{3} \\leq \\frac{5}{7}$, since\n$$\n2\\cdot 7 < 3 \\cdot 5.\n$$\n \nAn easy, but surprising, \nway of finding a rational number strictly between these two is\nadding their numerators and denominators:\n$$\n\\frac{2}{3} < \\frac{2 + 5}{3 + 7} < \\frac{5}{7}.\n$$\n\nWe wil try to explain the first inequality in mathematical general terms going through a\nrather formal proof consisting of five steps. These steps are\ngiven in the quiz below. Your task is drag from the left and drop them to the right in an order, \nso that the proof makes sense. \n\nAfter that you are supposed, on your own, to write down a precise proof of\nthe second inequality.\n\n\\begin{quizexercise}[showhide]\n\\begin{orderquiz}\n  \\question\n  Order the arguments below so that they constitute a coherent explanation of the\n  statement that if\n  $$\n  \\frac{a}{b} < \\frac{c}{d},\n  $$\n  then\n  $$\n  \\frac{a}{b} < \\frac{a + c}{b + d}\n  $$\n\n  \n  \\answer %2\n  By definition this means that $a d < b c$.\n\n  \n  \n \\answer %1\n  We are assuming that $\\frac{a}{b} < \\frac{c}{d}$. \n\n  \\answer %4\n  For integers $x, y, z$ we know that the rule\n  $\n  x ( y + z) = x y + x z\n  $\n  holds. Therefore\n  \\answer %5\n  we need to show that $a b + c d < b a + b c$.\n\n  \n  \\answer %6\n  Since $a b = b a$ and $a b + a d < a b + b c$ is a consequence of $a d < b c$, we are\n  done if we know this is true.\n  \\answer %7\n  However, this is a consequence of our assumption $\\frac{a}{b} < \\frac{c}{d}$.\n\n\\answer %3\n  To show that\n  $\n  \\frac{a}{b} < \\frac{a+c}{b + d},\n  $\n  we need to argue that $a (b + d) < b (a + c)$.\n\n  \n  \\answer\n\n  we need to show that $a b + a d < b a + b c$.\n  \n  \\expected{5}\n\n  \\case{(is 73856)}{T}\n  \\green{Spot on, my friend!}\n\n  \\case{(contains 4)}{F}\n  \\red{You have not applied the formula for expanding $x(y + z)$ correctly.}\n\n  \\default\n  \\red{Wrong order.}\n\n\\end{orderquiz}\n\\end{quizexercise}\n\n\n\n\n\\beginshex\nSimilarly to the quiz above, assume that  \n$$\n  \\frac{a}{b} < \\frac{c}{d}.\n  $$\n  Write down a precise argument showing that\n  $$\n  \\frac{a + c}{b + d} < \\frac{c}{d}.\n  $$\n  You may seek inspiration in Video \\ref{Video:proofexample} for\n  how to mix math and words (even though\n  it is further ahead).\n  \\endshex\n\n  \n  \n\n\\beginshex\nOn \\url{Twitter}{https://twitter.com/Ramangupta4/status/1162999733142482945}, Raman Gupta posted the note below\n\n\\includegraphics[width=\"50\\%\"]{tweet.jpg}\n\nFor a natural number $m\\in \\NN$,\n$$\nm! = m (m-1) (m-2)\\cdot \\dots \\cdot 2\\cdot 1. \n$$\nFor example, $3! = 6$ and $5! = 120$. What is the answer for the\nquestion in the note?\n\\endshex\n\nThe exercise below shows that our trick for finding rational numbers\nin between two given rational numbers can be made into a machine for\ngenerating all positive rational numbers!\n\n\\beginshex\nCan you spot the system in the fractions in the diagram below?\n\\includegraphics{SternBrocotTree.svg}\nOnce you see the system, extend the diagram with the next level downwards. Is every\npositive fraction present in this diagram if one keeps adding levels?\n\n\\begin{hint}[showhide]\nSuppose that\n$$\n\\frac{p}{q} < \\frac{r}{s}\n$$\nand $q r - s p = 1$. Then for\n$$\n\\frac{p}{q} <  \\frac{p+r}{q+s} < \\frac{r}{s},\n$$\nwe have $q (p+r) - (q+s) p = 1$ and $(q+s) r - (p + r) s = 1$. If $\\frac{a}{b}$ is \na positive fraction, such that\n$$\n\\frac{p}{q} <  \\frac{a}{b} < \\frac{r}{s},\n$$\nshow that \n$$\na + b = (r+s)(qa−bp)+(p+q)(br−as)\\geq p+q+r+s.\n$$\n\\end{hint}\n\\endshex\n\n\n\\subsection{Subsets of numbers and first elements}\\label{subsecfirst}\n\nIn a set equipped with an order, it is intuitively clear what a first element should be. For example,\nthe natural numbers $\\NN$ has $0$ as its first element. On the other hand the set $\\ZZ$ of\nintegers does not have a first element (it is ``infinite to the left'').\n\nIn fact every non-empty subset $S\\subseteq \\NN$ has\na first element. This follows from a rather special property of $\\NN$: there\ncan be only finitely many natural numbers smaller than a given one. This is\nnot true for $\\ZZ$. Here there are infinitely many integers smaller than\nany integer.\n\n\\beginshex\nConsider the subset $S$ of $\\QQ$ consisting of positive fractions i.e., rational numbers  $>0$.\nDoes this subset have a first element?\n\\endshex\n\n\n\n\n\\section{Propositional logic}\n\nWe have seen quite a few mathematical statements that ended up \nbeing true or false. Such statements are called \\emph{propositions}.\nHere are two examples of propositions usings sets (in Sage):\n\n\\begin{sage}\nprint(1 in Set([1,2,3]))\nA = Set([1, 2, 3])\nB = Set([2, 3, 4])\nprint(A.intersection(B) == Set([2, 3])) \n\\end{sage}\n\n\\beginshex\nWhat exactly are the two propositions in the above Sage window written\nup in mathematical terminology? Notice that the symbol == is\na programming construct. It is not used in mathematics notation.\n\\endshex\n\nPropositions can be combined into\nnew (compound) propositions. Take for example the propositions\n\n\\begin{align*}\n&p: \\text{it rains}\\\\\n&q: \\text{it is cloudy}.\n\\end{align*}\n  \n  Then ($p$ and $q$) is a perfectly good\n  new proposition reading \\emph{it rains and it is cloudy}. The same goes for (if $p$ then $q$), which reads\n  \\emph{if it rains then it is cloudy}. The proposition (if $q$ then $p$) reads \\emph{if it is cloudy then\n    it rains}. This proposition is (clearly) false.\n\n\nWe need some notation to describe these compound propositions:\n\n\\begin{equation*}\n\\begin{array}{ll}\np \\land q\\qquad\\qquad & \\qquad\\qquad p \\text{ and } q\\\\\n\\\\\np \\lor q\\qquad\\qquad & \\qquad\\qquad p \\text{ or } q\\\\\n\\\\\np\\implies q\\qquad\\qquad & \\qquad\\qquad \\text{if } p \\text{ then } q\\\\\n\\\\\n\\neg p\\qquad\\qquad & \\qquad\\qquad \\text{not } p\n\\end{array}\n\\end{equation*}\n\nThe compound propositions are either true($t$) or false ($f$) depending on\n$p$ and $q$. The dependencies are displayed in the \\emph{truth tables} below.\n\n\\begin{equation*}[emph]\n\\def\\arraystretch{1.2}\n      \\begin{array}{c|c|c}\n        p & q  & p\\land q  \\\\\n        \\hline \n        t & t  & t    \\\\\n        t & f & f\\\\\n        f & t & f\\\\\n        f & f & f\n      \\end{array}\\qquad\n      \\begin{array}{c|c|c}\n        p & q  & p\\lor q  \\\\\n        \\hline\n        t & t  & t    \\\\\n        t & f & t\\\\\n        f & t & t\\\\\n        f & f & f\n      \\end{array}\n      \\qquad\n      \\begin{array}{c|c|c}\n        p & q  & p\\implies q  \\\\\n        \\hline\n        t & t  & t    \\\\\n        t & f & f\\\\\n        f & t & t\\\\\n        f & f & t\n      \\end{array}\\qquad\n      \\begin{array}{c|c}\n        p & \\neg p \\\\\n        \\hline\n        t & f\\\\\n        f & t\n      \\end{array}\n  \\end{equation*}\n\n\nThe tables for the compound propositions $p\\land q, p\\lor q$ and also\n$\\neg p$ are not too hard to grasp. The table for $p\\implies q$ \nraises a few more questions. Why is $f\\implies t$ true?\nI will not go into this, but just point out that there are\nmany explanations available online and, \nperhaps more importantly, refer you to the exercise below.\n\n\n\n\\beginshex\nSuppose that we are presented with four cards\n\\begin{equation}\\label{cards}\n\\boxed{3}\\qquad \\fcolorbox{black}{red}{\\phantom{3}}\n\\qquad\\boxed{4}\\qquad \\fcolorbox{black}{blue}{\\phantom{4}}\n\\end{equation}\nwith a (natural) number on the front and the color\n\\textcolor{blue}{blue} or \\textcolor{red}{red} on the back.\nIn \\eqref{cards}, the first and third cards are shown with their fronts facing up and\nthe second and fourth cards are shown with their backs facing up.\n\nA claim (proposition) is made that if a card has an even number on the front, then it\nmust have the color \\textcolor{blue}{blue} on the back.\n\nYour task is to verify this for the cards above. Of course you can\ndo this by turning all four cards, but is there a way of checking this\nby turning less than four cards?\n\nWhat if we add the claim, that if a card has the color \n\\textcolor{blue}{blue} on the back, then\nit must have an even number on the front?\n\n\\begin{hint}[showhide]\n  Find two propositions $p$ and $q$ so that the claim reads\n  $p\\implies q$.\n\\end{hint}\n  \n\\endshex\n\n\n\\beginshex\nExplain why Python/Sage thinks that \\footnote{the value}{Thanks to Gerth Brodal for pointing this out to me} of\n  $$\n  1 < 0 < 1/0\n  $$\n  is False! Notice that you are dividing one by zero in the last \"integer\" above.\n\\endshex\n\n\nIn the exercise below you will see for example that\n$p\\implies q$ is the same as $\\neg q \\implies \\neg p$.\n\n\\beginshex\\label{trutheq}\nTwo propositions are considered the same ($=$) if they have the same truth table. Verify, by\nfilling out and comparing truth tables, that\n\\begin{enumerate}[(i)]\n\\item\n$\\neg (p \\land q) = (\\neg p) \\lor (\\neg q)$\n\\item\n$\\neg (p \\lor q) = (\\neg p) \\land (\\neg q)$\n\\item\n$p \\implies q = (\\neg q) \\implies (\\neg p)$\n\\item\n$p \\implies q = (\\neg p)\\lor q$\n\\end{enumerate}\n\\endshex\n\n\\beginshex\nCan you use the setup up in Exercise \\ref{trutheq} to verify that\n$$\np\\land (q \\lor r) = (p\\land q) \\lor (p \\land r)\n$$\nfor three propositions $p, q$ and $r$? What about\n$\np\\lor (q \\land r)?\n$\n\\endshex\n\nThe notation $p \\iff q$ is used frequently. It means that both\n$p\\implies q$ and $q\\implies p$ are true i.e.,\n$$\n(p\\implies q) \\land (q\\implies p).\n$$\n\n% \\subsection{Predicates with variables}\n\n% In mathematics it is natural to work with propositions with variables, such as $x > 0$. By itself\n% the expression $x>0$ is hopelessly imprecise. We need to specify which numbers we wish to compare:\n% natural numbers, rational numbers, $\\dots$ i.e., what does $>$ really mean? Once this is done,\n% we can substitute a number for $x$ and only then do we get a predicate!\n\n% A precise way of writing, could be: for $x\\in \\ZZ$ we consider $p(x) = x > 0$.\n\n% \\subsection{Subsets defined using predicates}\n\n\\subsection{The symbols $\\exists, \\forall$ and propositions with variables}\n\nIn mathematics one usually reasons with propositions with variables.\n\nIn order to have a variable $x$, one must first specify to which set\n$S$ the variable belongs. For example, the proposition $p(x)$ given by\n$$\nx^2 > 0,\n$$\ndoes not make sense if $x$ is taken from the set of letters in the\nEnglish alphabet (not unless you give an interpretation of $x^2$,\n$>$ and $0$ in this set). However, if $x\\in \\ZZ$, then $p(x)$\ncertainly makes sense. Whether $p(x)$ is true depends on $x$.\n\n\nFor example, $p(0)$ is false, whereas $p(-1)$ is true. This leads us to\nthe existential and universal quantifiers $\\exists$ and $\\forall$.\nThe former reads \\emph{there exists} and the latter \\emph{for every}.\n\nFor example, the proposition\n$$\n\\exists x\\in \\ZZ: \\neg p(x)\n$$\nis true and so is\n$$\n\\forall x\\in \\ZZ\\setminus\\{0\\}: p(x).\n$$\nNotice that the  symbol \":\" above means \\footnote{\"such that\"}{Therefore  \n$\\exists x\\in \\ZZ: \\neg p(x)$ reads \"there exists $x$ in $\\ZZ$, such that\n$\\neg p(x)$ is true\".}.\n\nAlso, $\\forall x\\in \\ZZ: p(x)$ is false, because\n$\\exists x\\in \\ZZ: \\neg p(x)$ is true. In general,\n$$\n\\neg\\left(\\forall x\\in S: p(x)\\right) = \\exists x\\in S: \\neg p(x).\n$$\nSo we do not really need the quantifier $\\forall$, when we have\n$\\neg$ and $\\exists$, but $\\forall$ is convenient and used all\nthe time.\n\nThe quantifiers are important to learn and apply when expressing\nmathematical ideas. So is the use of propositions with variables\nin writing up subsets: if $S$ is a set, $x$ a variable taking values\nin $S$ and $p(x)$ a proposition (making sense in $S$), then\n$$\n\\{x\\in S \\mid p(x)\\}\n$$\nis the subset of the elements $x\\in S$, such that $p(x)$ is true.\n\nFor example, if $p(x) = x^2 > 0$, then\n$$\n\\{x\\in \\ZZ \\mid p(x)\\} = \\ZZ\\setminus \\{0\\}.\n$$\n\n\\begin{hideinbutton}{More from CS}\n\nThe following is yet another excerpt from the infamous \\emph{Beredskabsprøve Datalogi}.\n\n\\begin{quiz}\n\\question\nWhich of the following are true?\n\\answer{F}\n$\\forall x\\in \\NN: x > 2$\n\\answer{T}\n$\\exists x\\in \\NN: x > 2$\n\\answer{T}\n$\\forall x\\in \\emptyset: x = 7$\n\\answer{F}\n$\\exists x\\in \\emptyset: x = 7$\n\\end{quiz}\n\\end{hideinbutton}\n\n\n\\subsection{The use of implication ($\\implies$) and bi-implication ($\\iff$)}\n\nUsually $\\implies$ and $\\iff$ are applied to link propositions in a logical argument. An example\nis\n$$\nx \\leq y \\iff x + z \\leq y + z\n$$\nfor integers $x, y, z$. To be completely precise, I should here write\n$$\n\\forall x, y, z\\in \\ZZ: x \\leq y \\iff x + z \\leq y + z,\n$$\nbut one often writes $\\forall$ with words as for example \\emph{for integers $x, y, z$}.\n\n\nHere $x \\leq y\\implies x + z \\leq y + z$ is true and similarly\n$x + z \\leq y + z \\implies x \\leq y$ (by using the definition (see \\eqref{ordZ}) of $\\leq$ in $\\ZZ$). So the\nuse of $\\iff$ is valid.\n\nHowever, for $x \\geq 0 \\implies x^2 \\geq 0$ we cannot link the two propositions by $\\iff$,\nsimply because $x^2 \\geq 0 \\implies x \\geq 0$ is false.\n\n\n\\section{What is a mathematical proof?}\n\n\nMost professional mathematicians rarely think about the precise\ndefinition of a proof. During many years of training they have\nassimilated knowledge by experience. Therefore many proofs\nseem born out of witchcraft containing several magical\ndevices.\n\nHowever, many proofs appearing in\nrespected mathematical journals, submitted by respected mathematicians, have turned out to contain\nerrors. Recent developments in automated proof systems\nlike \\url{Coq}{https://en.wikipedia.org/wiki/Coq} show\npromise in checking proofs like for example the famous\n\\url{four color theorem}{https://en.wikipedia.org/wiki/Four_color_theorem}.\n\nInformally a proof of a proposition $q$, consists in arguing that an implication $p\\implies q$ is true by first assuming $p$. Usually this is done\nnot only through one implication $p\\implies q$, but through a series\nof intermediate implications\n$$\np\\implies q_1 \\implies q_2 \\implies q_3 \\implies \\cdots \\implies q_N,\n$$\nwhere the last proposition $q_N$ is $q$. If $p$ is true, this\nwill constitute a proof that $q_N = q$ is true. Just like in \\eqref{ordwrong},\nthere is an imprecision here. Can you tell what it is?\n\nIn this section we will illustrate a simple mathematical proof of the\nproposition:\n$$\n\\forall n\\in \\NN: p(n)\\implies p(n^2),\n$$\nwhere $p(n) = (n\\text{ is odd})$ i.e., the square of an odd\nnatural number has to be odd. This seems true for a first selection\nof examples: $3^2=9, 5^2=25, \\dots$.\n\nFirst we need to know what $p(n)$ means. What does it mean\nexactly for a number to be odd? This means that it is\nnot divisible by $2$ or that there exists another\nnatural number $a$, such that $n = 2 a + 1$. So\n$$\np(n) = \\exists a\\in \\NN: n = 2 a + 1.\n$$\nTherefore we need to show that\n$$\n\\left(\\exists a\\in \\NN: n = 2 a + 1\\right) \\implies\n\\left(\\exists b\\in \\NN: n^2 = 2 b + 1\\right).\n$$\nNotice that I had to change $a$ into $b$ in the second proposition above.\nThe two variables are not the same: $a$ is associated with $n$ and\n$b$ is associated with $n^2$.\n\nLet us assume that $n = 2 a + 1$. Now we need to argue that $\nn^2 = 2 b + 1$ for some $b\\in \\NN$. You stare at this for a while\nand notice that we should use the assumption $n=2 a + 1$ in\ncomputing $n^2$:\n$$\nn^2 = (2 a + 1)^2 = (2 a)^2 + 2 (2 a) + 1^2 = 4 a^2 + 4 a + 1 =\n2(2 a^2 + 2 a) + 1.\n$$\nThus, using our assumption we may conclude that if $n = 2 a + 1$, then\n$$\nn^2 = 2 b + 1,\n$$\nwhere $b=2a^2+ 2 a$. This completes the proof.\n\nThe beauty here is that we have verified for all odd natural numbers\nthat their square is odd. Not just a finite selection like\n$3, 7, 11, 13$.\n\nBelow I have given a very detailed walk through of the proof above. It\nexamplifies how to write up the proof mixing words and mathematics. In\nmany ways a proof is like a detailed argument in a court case, except\nthat the rules of mathematics are universal. You need the absolute truth.\n\n\\begin{video}\\label{Video:proofexample}\n\\youtube{1tewESCAP2k}  \n\\end{video}\n\n\n\n\n\\subsection{Proof by contradiction}\n\nA proposition $p$ is either true or false. This seemingly obvious statement\ngoes by the name of \\footnote{the law of excluded middle}{\nAn application could be in proving the existence of irrational numbers $\\alpha$ and $\\beta$, such that\n$\\alpha^\\beta$ is rational. The law of excluded middle is here applied to the proposition\n\\emph{$\\sqrt{2}^{\\sqrt{2}}$ is rational}.}.\n\n\nThe law of excluded middle can be turned\ninto a powerful proof technique called \\emph{proof by contradiction}.\n\nSuppose we wish to establish that $p$ is true. Then we turn things upside down by\nassuming that $p$ is false i.e., that $\\neg p$ is true. If we then\nby logical deduction can show that\n$$\n\\neg p \\implies q,\n$$\nfor some proposition $q$, which is demonstrably false, then $\\neg p$ cannot be true (since\ntrue $\\implies$ false is false). Therefore $\\neg p$\nmust be false and $p$ must be true. This technique is used all the time!\n\n\\beginshex\nWe will give an example of a proof by contradiction using a previous exercise: show that\nthe set\n$$\nS = \\{x\\in \\QQ \\mid x > 0\\}\n$$\ndoes not have a first element. Recall the definition of a first element in\nthe context of $S$: $x_0\\in S$ is a first element if \n$$\n\\forall x\\in S: x_0 \\leq x.\n$$\nSo if $x_0$ is a first element in $S$, there cannot exist $x_1\\in S$, such that\n$x_1 < x_0$.\n\nThe proof by contradiction  in this case, runs as follows. Assume that $S$\nhas a first element $x_0 = \\frac{p}{q}$. Then using $x_0$ we can form\n$$\nx_1 = \\frac{p}{q+1},\n$$\nand you \\footnote{can check}{Check that $p q < p(q+1)$.} that $x_1\\in S$ and $x_1 < x_0$ i.e., $x_0$ is not a first\nelement. So our assumption that $S$ has a first element immediately leads\nto the conclusion that $S$ does not have a first element. Therefore this\nassumption has to be false, and $S$ cannot have a first element.\n\\endshex\n\n\\beginshex\nSuppose that $q(n) = (n \\text{ is even})$. Prove that\n$$\n\\forall n\\in \\NN: q(n^2) \\implies q(n).\n$$\nSuppose that\n$$\n\\sqrt{2} = \\frac{m}{n}.\n$$\nShow that this implies $2 n^2 = m^2$ and that $m$ and $n$ are even numbers.\n\nGiven the above, write up a precise proof that $\\sqrt{2}\\not\\in \\QQ$\nusing proof by contradiction.\n\nYou may wonder what is so special about rational numbers. Which property does\n$\\sqrt{2}$ break? You can explore this by looking at the decimal expansion of\nsome fractions below.\n\n\\begin{sage}\nprint(\"1/8 =\", (1/8).n(digits=50))\nprint(\"3/17 = \", (3/17).n(digits=50))\nprint(\"5/7 = \", (5/7).n(digits=50))\nprint(\"\")\nprint(\"sqrt(2) = \", sqrt(2).n(digits=100))\n\\end{sage}\n\nHowever, $\\sqrt{2}$ is an algebraic number being a root in the\npolynomial $x^2 - 2$. In general an algebraic number is a number,\nwhich is a root in a polynomial with coefficients in $\\ZZ$.\n\n\\endshex\n\n\n\\subsection{Proof by induction}\n\nA precocious Gauss proved the formula\n\\begin{equation}\\label{gaussind}\n1 + 2 + \\cdots + n = \\frac{n(n+1)}{2}\n\\end{equation}\nat the age of seven diplaying remarkable ingenuity for his age. Lesser\nmortals usually use induction to prove this formula. Gauss was asked\nalong with his classmates to compute the sum of all natural numbers\n$1, 2, \\dots, 100$. Using his formula he quickly came up with the correct\nanswer $5050$. His classmates had to work for the entire lesson.\n\nSuppose that the formula in \\eqref{gaussind} is viewed as a\nproposition $p(n)$. To prove the formula we need to prove it for all\nnatural numbers (you can easily see that $p(1)$ and $p(2)$ are true) i.e.,\nwe need to prove\n$$\n\\forall n\\in \\NN: p(n).\n$$\nAn induction proof is a way of proving this statement by showing two things:\n\\begin{enumerate}[(i)]\n\\item\n  $p(1)$\n\\item\n  $\\forall n\\in \\NN: p(n)\\implies p(n+1)$\n\\end{enumerate}\nThese two statements ensure that $p(1) \\implies p(2)$. Therefore\n$p(2)$ must be true, since we assumed $p(1)$ true from the\nbeginning. Similarly $p(2)\\implies p(3)$ ensures that $p(3)$\nis true. In fact we have proved $p(n)$ for every $n\\in \\NN$\nusing this technique. One can prove this using proof by\ncontradiction and that every non-empty subset\nof $\\NN$ has a first element (see subsection \\ref{subsecfirst} and below).\n\n\\begin{proof}[showhide]\nSuppose by contradiction that there exists $n\\in \\NN$, such that\n$p(n)$ is false. Then the subset\n$$\nS = \\{n\\in \\NN \\mid \\neg p(n)\\}\\subseteq \\NN\n$$\nis non-empty. Therefore it has a first element $n_0\\in S$. \nHere $n_0 > 1$, since $p(1)$ is assumed to be true. So we\nknow that $p(n_0-1)$ is true and that\n$p(n_0-1)\\implies p(n_0)$ is true. But the latter\nimplication is a contradiction, since true implies\nfalse is false.\n\\end{proof}\n\nLet us see how an induction proof plays out in the above example\nwith the statement $p(n)$ that\n\\begin{equation}\\label{indant}\n1 + 2 + \\cdots + n = \\frac{n(n+1)}{2}.\n\\end{equation}\nClearly $p(1)$ is true. We need to prove $p(n)\\implies p(n+1)$, so\nwe assume that $p(n)$ holds i.e., that \\eqref{indant} is true.\nThen we may add $n+1$ to both sides of \\eqref{indant} to get\n$$\n1 + 2 + \\cdots + n + (n+1) = \\frac{n(n+1)}{2} + (n+1).\n$$\nHere the right hand side can be rewritten as\n$$\n\\frac{n(n+1) + 2(n+1)}{2} = \\frac{(n+1)(n+2)}{2},\n$$\nwhich is exactly what we want. This is the conjectured formula for\nthe sum of the numbers $1, 2, \\dots, n, n+1$. Therefore\nwe have proved that $p(n)\\implies p(n+1)$ and the induction\nproof is complete.\n\n\n\\begin{example}\n  For a real number $r\\neq 1$, the extremely useful formula\n  \\begin{equation}\\label{geoind}\n  1 + r + \\cdots + r^n = \\frac{1 - r^{n+1}}{1-r}\n  \\end{equation}\n  holds. Let us prove this formula by induction. For $n=1$ this amounts to the identity\n  $$\n  1 + r = \\frac{1-r^2}{1-r},\n  $$\n  which is true since $1-r^2 = (1+r)(1-r)$. We let $p(n)$ denote\n  the identity in \\eqref{geoind}. We have seen that $p(1)$ is true. The induction step\n  consists in proving $p(n)\\implies p(n+1)$. We can prove this\n  by adding $r^{n+1}$ to the right hand side in \\eqref{geoind}:\n  $$\n  \\frac{1 - r^{n+1}}{1-r} + r^{n+1} = \\frac{1 - r^{n+1} + (1-r) r^{n+1}}{1-r} = \\frac{1 - r^{n+2}}{1-r}.\n  $$\n\\begin{hideinbutton}{Real life application}\n    In order to pay for a house you borrow $P$ DKK at an interest of\n    $r$ per year. You want to pay off your debt over $N$ years by\n    paying a fixed amount each year. How much is the fixed yearly\n    amount you need to pay?\n\n    Let us analyze the setup: suppose that the fixed yearly amount\n    is $Y$. We will find an equation giving us $Y$ in terms of\n    $P, N$ and $r$. Put $q = 1+ r$.\n\n    After one year you owe\n    $$\n    q P - Y.\n    $$\n    After two years you owe\n    $$\n    q(q P - Y) - Y.\n    $$\n    After three years you owe\n    $$\n    q ( q ( q P - Y) - Y) - Y.\n    $$\n    In general after $n$ years you owe\n    $$\n    q^n P - Y (1 + q + \\cdots + q^{n-1}).\n    $$\n    Since we want to be debt free after $N$ years, the yearly payment will have to satisfy\n    $$\n    q^N P = Y ( 1 + q + \\cdots + q^{N-1}).\n    $$\n    By the formula \\eqref{geoind}, we get\n    $$\n    q^N P = Y \\frac{1-q^N}{1-q}.\n    $$\n    Here $Y$ can be isolated giving the formula\n    $$\n    Y = \\frac{r P}{1 - \\left(\\frac{1}{1+r}\\right)^N}.\n    $$\n    With the current (August 2020) interest rate around one percent, you pay a fixed monthly\n    amount of around 3200 DKK for borrowing one million DKK over $30$ years.\n  \\end{hideinbutton}\n\\end{example}\n\n\n\\beginshex\nProve by induction that the sum of the first $n$ odd numbers is\ngiven by the formula\n$$\n1 + 3 + \\cdots + (2 n - 1) = n^2,\n$$\ni.e., for $n=5$ we have\n$$\n1 + 3 + 5 + 7 + 9 = 25.\n$$\n\\endshex\n\n\\beginshex\nProve by induction that\n$$\n1^2 + 2^2 + 3^2 + \\cdots + n^2 = \\frac{n(n+1)(2n + 1)}{6}.\n$$, \n\\endshex\n\n\\beginshex\nProve using the idea of induction that\n$$\n2^n < n!\n$$\nfor $n\\geq 4$.\n\\endshex\n\nThe last exercise related to induction concerns the famous \\url{pigeonhole principle}{https://en.wikipedia.org/wiki/Pigeonhole_principle}. The statement itself looks innocent, well almost ridiculous, but it is very \\url{powerful}{https://mindyourdecisions.com/blog/2008/11/25/16-fun-applications-of-the-pigeonhole-principle/}. Even the go-to website \n\\url{mathoverflow}{https://mathoverflow.net/} for research mathematicians has \na quite nice \\url{thread}{https://mathoverflow.net/questions/4279/interesting-applications-of-the-pigeonhole-principle} \nabout this.\n\n\\beginshex\nProve the following by induction on $m$: if $n$ items are put into $m$ containers and \n$n > m$, then at least one container must contain more than one item.\n\\endshex\n\n\\section{The concept of a function}\n\nA function is a crucial concept in mathematics. In Sage (actually python here) a simple function can be\nprogrammed like\n\n\\begin{code}\ndef f(n): return(n+1) \n\\end{code}\n\nThe code above seems to take a number and returns the number plus one. This (f) is in fact a function \ntaking as \\emph{input} a number and returning as \\emph{output} the number plus one. Notice that\nwe do not even know which numbers we are talking about here. In mathematics we need to have\na more precise notion of a function. \n\n\nMathematically a function $f$ takes values from a set $S$ and returns values in a set $T$. In details,\nit is denoted $f: S\\rightarrow T$ and the value associated with $s\\in S$ is denoted $f(s)\\in T$.\n\nThe above python function could more formally be denoted as $f: \\ZZ\\rightarrow \\ZZ$ with\n$f(n) = n+1$ if we are dealing with the integers, but we cannot tell from the code.\n\n\\begin{hideinbutton}{Well, to be fair ...}\nTo be completely fair, it is possible from Python version 3.5 to add type annotations to functions, so that we could write\n%\\begin{sage}\n%def f(n: int) -> int: return(n+1)\n%\\end{sage}\n\\begin{code}\ndef f(n: int) -> int: return(n+1)\n\\end{code}\nin the Python code to state that the function should take values in the integers and return integers.\n\\end{hideinbutton}\n\n\nIf you want the  super precise mathematical definition of a function, I\nwill give it here.  A function $f: S\\rightarrow T$ is a subset\n$f\\subseteq S\\times T$, such that\n$(s, t_1)\\in f \\land (s, t_2)\\in f \\implies t_1 = t_2$. In words it states that a\nfunction $f: S\\rightarrow T$ is a subset $f$ of $S\\times T$, containing pairs\nhaving only one second coordinate for every first coordinate.\n\nThe everyday working definition of a\nfunction is more intuitive: a machine taking input from some set\n$S$ and giving output in some set $T$. The uniqueness of the output\nis encoded in the mathematical definition of a function.\n\n\n\\beginshex\nWrite down precisely how the truth table for $p\\implies q$ may\nbe expressed in terms of a function $f: S\\rightarrow T$. What are the sets $S$ and $T$ in this case?\n\\endshex\n\n\n\\subsection{Composition of functions}\n\nGiven two functions $f: S\\rightarrow T$ and $g: U\\rightarrow V$, where\n$V\\subseteq S$, we define a new function $f\\circ g: U \\rightarrow T$ by\n$$\n(f\\circ g)(u) = f(g(u)).\n$$\nThis notion calls for some reflection. We have a total of four sets\nin this definition: $U, V, S$ and $T$ and, not to forget, the condition that\n$V\\subseteq S$. If this last condition was not satisfied it would be\nmeaningless to apply the function $f$ to $g(u)$.\nI hope the diagram below helps the\nunderstanding.\n\n\\includegraphics{compositefunction.svg}\n\n\\begin{remark}\n  The concept of a function is powerful and underlies functional programming in computer science: every computation can be realized as applying a composition of functions to an argument. This is examplified in the computer language\n  \\url{Haskell}{https://www.haskell.org/}.\n  \\end{remark}\n\n\n  \n\\beginshex\nConsider $f: \\RR\\rightarrow \\RR^2$ and $g: \\RR^2\\rightarrow \\RR$ given by\n\\begin{align*}\n  f(t) &= (t^2, t^3)\\\\\n  g((x, y)) &= \\cos(x y) + x \\sin(x + y).\n\\end{align*}\nWhat is $(g\\circ f)(t)$ as a function from $\\RR$ to $\\RR$ in terms of $t$?\n\\endshex\n\n\\subsection{Neural networks}\n\nHaving defined functions and composition of functions, we can deflate\nthe term (deep) neural network, which is often clouded in\nmagic and mystery.\n\nA \\emph{neural network} is a special case of a function\n\\begin{equation}\\label{neural}\nf: A\\rightarrow B,\n\\end{equation}\nwhere $A\\subseteq \\RR^m$ and $B\\subseteq \\RR^n$. Neural networks are\noften compositions of many intermediate functions called\n(hidden) layers.\n\nA function such as \\eqref{neural} can\nbe written\n$$\nf(x_1, \\dots, x_m) = \\left(\nf_1(x_1, \\dots, x_m), \\dots, f_n(x_1, \\dots, x_m)\\right),\n$$\nwhere $f_1, \\dots, f_n$ are functions $A\\rightarrow \\RR$.\n\nIn a neural\nnetwork the functions $f_1, f_2, \\dots, f_n$ are viewed as neurons. Depending on their\ninput they either fire or do not fire a signal. Classically this is\nmodelled by the \\url{perceptron}{https://en.wikipedia.org/wiki/Perceptron},\nwhich is a function $p:\\RR^n\\rightarrow \\RR$ of the form\n$$\np(x_1, \\dots, x_n) =\n\\begin{cases}\n  1 &\\text{if } w_1 x_1 + \\cdots + w_n x_n > b\\\\\n  0 &\\text{if } w_1 x_1 + \\cdots + w_n x_n \\leq b\n\\end{cases}\n$$  \n  for fixed numbers $w_1, \\dots, w_n$ (called weights) and a number $b$ (called the threshold).\n  If the weighted sum $w_1 x_1 + \\cdots + w_n x_n$ is above the threshold, the neuron\n  fires (returns the value $1$). If not it does not fire (returns the value $0$).\n\n\\includegraphics{perceptron.svg}\n\n\n  \\beginshex\n  Consider the three perceptrons $p_1, p_2, p_3: \\RR^2\\rightarrow \\RR$, where\n  $$\np_1(x, y) =\n\\begin{cases}\n  1 &\\text{if } -x-y > -\\frac{3}{2}\\\\\n  0 &\\text{if } -x-y \\leq -\\frac{3}{2}\n\\end{cases},\n\\qquad\np_2(x, y) =\n\\begin{cases}\n  1 &\\text{if } x + y > \\frac{1}{2}\\\\\n  0 &\\text{if } x + y \\leq \\frac{1}{2}\n\\end{cases},\n$$\nand\n$$\np_3(x, y) =\n\\begin{cases}\n  1 &\\text{if } x + y > \\frac{3}{2}\\\\\n  0 &\\text{if } x + y \\leq \\frac{3}{2}\n\\end{cases}.\n$$\nLet $f(x, y) = p_3 (p_1(x, y), p_2(x, y))$. Then $f$ is\na composite function $f = g\\circ h$ of two functions $h: \\RR^2\\rightarrow \\RR^2$\nand $g: \\RR^2\\rightarrow \\RR$. Write down these functions.\n\nCompute\n$f(0, 0), f(1, 0), f(0, 1)$ and $f(1, 1)$.\n\n\n\nRelate the perceptrons $ p_1 $ and $ p_2 $ to the illustration\nbelow. What do you think the red and blue line illustrate?  What does\nit mean that a dot is solid compared to hollow? What is special\nabout points between the red and blue lines?  Try to relate $f(0,0),\nf(1,0), f(0,1)$ and $f(1,1)$ to the illustration.\n\n\\includegraphics{whkperceptron.svg}\n\n(Illustration courtesy of William Heyman Krill).\n\n\\endshex\n\n  \\beginshex\n  Give weights $w_1, w_2$ and a threshold $b$ for a perceptron $p:\\RR^2\\rightarrow \\RR$ that computes\n  the logical and function $\\land$ i.e, $p$ must satisfy\n  \\begin{align*}\n    p(0,0) &= 0\\\\\n    p(1, 0) &= 0\\\\\n    p(0,1) &= 0\\\\\n     p(1, 1) &= 1.\n  \\end{align*}\n  Do the same for the logical or function $\\lor$.\n  \\endshex\n  \n  The output of one neuron can be used as input for other neurons in a potentially extremely complicated network:\n\n  \\includegraphics{deepneural.png}\n\n  The diagram above represents a neural network, which is a function $\\RR^8\\rightarrow \\RR^4$. This function\n  is actually a composition (represented by the hidden layers $1$, $2$, $3$ and the output layer):\n  $$\n  \\RR^8\\rightarrow \\RR^9 \\rightarrow \\RR^9 \\rightarrow \\RR^9 \\rightarrow \\RR^4.\n  $$\n  All of the nodes above, except the ones in the input layer, represent perceptrons.\n\n  \\beginshex \n  Is it possible to find a perceptron $p:\\RR^2\\rightarrow \\RR$, such that\n    \\begin{align*}\n    p(0,0) &= 0\\\\\n    p(1, 0) &= 1\\\\\n    p(0,1) &= 1\\\\\n     p(1, 1) &= 0?\n  \\end{align*}\n  What if you are allowed to use a neural network composed as $\\RR^2\\rightarrow \\RR^2\\rightarrow \\RR$ (one hidden layer)\n  \\includegraphics{xor.svg}?\n  \\endshex\n  \n  Mathematically there is no reason to use special functions such as perceptrons in each node. One also uses\n  a (smooth) version of the perceptron employing the \\url{sigmoid function}{https://en.wikipedia.org/wiki/Sigmoid_function}.\n  With the notation above, this function is given as\n  $$\n  \\sigma(x_1, \\dots, x_n) = \\frac{1}{1 + e^{-(w_1 x_1 + \\cdots + w_n x_n) - b}},\n  $$\n\n\\end{document}\n", "meta": {"hexsha": "bb856ef5e27254de1a1308eaec4fd3baa4f8dca6", "size": 52440, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Generic/intro.tex", "max_stars_repo_name": "Znunu/QaDiL", "max_stars_repo_head_hexsha": "d079ff9cbd376b96649fbab39e87d67725d25516", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2021-05-31T08:27:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T22:05:28.000Z", "max_issues_repo_path": "Notes/Generic/intro.tex", "max_issues_repo_name": "Znunu/QaDiL", "max_issues_repo_head_hexsha": "d079ff9cbd376b96649fbab39e87d67725d25516", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-06-05T20:37:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T16:38:52.000Z", "max_forks_repo_path": "Notes/Generic/intro.tex", "max_forks_repo_name": "Znunu/QaDiL", "max_forks_repo_head_hexsha": "d079ff9cbd376b96649fbab39e87d67725d25516", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-06-10T08:26:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-25T02:04:32.000Z", "avg_line_length": 30.488372093, "max_line_length": 350, "alphanum_fraction": 0.671948894, "num_tokens": 17426, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6893056295505782, "lm_q2_score": 0.640635861701035, "lm_q1q2_score": 0.4415939059625091}}
{"text": "\\section{Deterministic Variational Approach}\nThere are two main parts for computing the reconstruction term: propagation of distributions through activations to compute $\\tilde{q}(\\mathbf{a}^L)$, and evaluation of unparameterized log-likelihood $\\mathcal{L}$. In Fig~\\ref{fig:feed_arch} we can see the general architecture used to accomplish these tasks.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale=.5]{fig/dvi-architect-p1.png}\n\\caption{Feed-forward architecture for reconstruction term computation.}\n\\label{fig:feed_arch}\n\\end{figure}\n\n\\noindent\\textbf{Moment Propagation.} \\\\\nWe can consider the model, $\\mathcal{M}$, as a set of layers each containing an non-linear and affine transformation,\n$$\n\\mathcal{M} := \\{(\\bm{h}^l,\\bm{a}^l): \\bm{h}^l = f(\\bm{a}^{l-1}), \\bm{a}^l = \\bm{h}^l\\bm{W}^l + \\bm{b}^l\\}_{l=1}^{\\mathbb{N}}\n$$\n\nwhere $\\{\\bm{W},\\bm{b}\\}\\subset\\bm{\\omega}$ are random variables representing the weights and are assumed independent per layer. $\\bm{a}^l$ is argued to be Gaussian under the Central Limit Theorem given a sufficiently large latent space and finite $1^{st}$ and $2^{nd}$ moment since it is formulated as the linear combination of the elements of $\\bm{h}^l$. Given that $\\bm{a}^l$ is Gaussian we can appoximate the $1^{st}$ and $2^{nd}$ moment,\n\n\\begin{equation}\n\\langle a_i\\rangle = \\langle h_j\\rangle\\langle W_{ji}\\rangle + \\langle b_i\\rangle\n\\end{equation}\n$$\n\\text{Cov}(a_i,a_k) = \n$$\n\\begin{equation}\n\\langle h_jh_l\\rangle\\text{Cov}(W_{ji},W_{lk})+ \\langle W_{ji}\\rangle\\text{Cov}(h_j,h_l)\\langle W_{lk}\\rangle + \\text{Cov}(b_i,b_k)\n\\end{equation}\n\nwhere $\\langle a_i\\rangle := \\mathbb{E}_{q}[a_i]$ and $h_jW_{ji} = \\sum_{j=1}^nh_jW_{ji}$ is called Einstein notation. To reduce approximation, gaussian distributions are considered for the mean and covariance of the weights so that all that is left determine are the moments $\\langle h_j\\rangle$ and $\\langle h_jh_l\\rangle$\n\n\\begin{equation}\n\\langle h_j\\rangle \\propto \\int f(\\alpha_j)\\exp\\bigg[-\\frac{(\\alpha_j-\\langle a_j^{l-1}\\rangle)^2}{2\\Sigma_{jj}^{l-1}}\\bigg]d\\alpha_j\n\\end{equation}\n\n\\begin{equation}\n\\langle h_jh_l\\rangle \\propto \\int f(\\alpha_j)f(\\alpha_l)\\exp\\bigg[-\\frac{1}{2}\\zeta^T\\Lambda^{-1}\\zeta\\bigg]d\\alpha_jd\\alpha_l\n\\end{equation}\n\n$$\n\\zeta = \\begin{pmatrix} \\alpha_j - \\langle a_j^{l-1}\\rangle\\\\ \\alpha_l - \\langle a_l^{l-1}\\rangle\\\\\\end{pmatrix}\n$$\n\n$$\n\\Lambda = \\begin{pmatrix} \\Sigma_{jj}^{l-1} & \\Sigma_{jl}^{l-1}\\\\ \\Sigma_{lj}^{l-1} & \\Sigma_{ll}^{l-1}\\\\\\end{pmatrix}\n$$\n\n Closed form solutions exist for (4) when considering Heaviside or ReLU non-linearity for $f$. For (5), we can approximate the moment through,\n\n\\begin{equation}\n\\langle h_jh_l\\rangle = S_{jl}^{l-1}\\bigg\\{A(\\mu_j^{l-1},\\mu_{l}^{l-1},\\rho_{jl}^{l-1})+\\exp[-Q(\\mu_j^{l-1},\\mu_l^{l-1},\\rho_{jl}^{l-1})]\\bigg\\}\n\\end{equation}\n\nwhere the key idea is that the asymptotes $A$ of the non-linearities as well as the residuals $Q$ in the form of a polynomial provide a good first order approximation of the moment. Fig~\\ref{fig:approx} provides a visual representation of this process. Due to CLT these approximations provide sufficient information for us to explicitly determine $\\tilde{q}(\\bm{a}^L)$ through sequential distribution propagation.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale=.5]{fig/activations.png}\n\\caption{Model activation function approximation.}\n\\label{fig:approx}\n\\end{figure}\n\n\\noindent\\textbf{Log-Likelihood Evaluation.} \\\\\nWe can evaluate the expected log-likelihood $\\mathbb{E}_{\\bm{\\omega}\\sim q}\\big[\\log p(y \\mid \\bm{x},\\bm{\\omega})\\big]$ through directly evaluating $\\mathbb{E}_{\\bm{a}^L\\sim q(\\bm{a}^L)}\\big[\\log p(y \\mid \\bm{a}^L)\\big]$ since $q(y \\mid \\bm{a}^L)$ is a parameter free transformation.\n\n\\section{Empirical Bayes for Variational BNNs}\n\nConsidering a $d$-dimensional Gaussian prior, $p(\\bm{\\omega}) = \\mathcal{N}(\\mu_p,\\Sigma_p)$, and variational distribution, $q = \\mathcal{N}(\\mu_q,\\Sigma_q)$, the KL divergence has the form,\n\n\\begin{equation}\n\\frac{1}{2}\\bigg[\\log\\frac{\\det(\\Sigma_p)}{\\det(\\Sigma_q)} - d + \\text{tr}(\\Sigma_p^{-1}\\Sigma_q) + (\\mu_p - \\mu_q)^T\\Sigma_p^{-1}(\\mu_p - \\mu_q)\\bigg]\n\\end{equation}\n\nRather than using this directly the authors propose conditioning the prior on a hyper-parameter $\\bm{s}$ such that $\\bm{\\omega}\\sim p(\\bm{\\omega}\\mid\\bm{s}); \\bm{s} \\sim p(\\bm{s})$, where $\\bm{s}$ is distributed according to a inverse gamma distribution and acts as a conjugate prior for the diagonal gaussian variance. Further through partioning the weights $\\bm{\\omega}$ into sets $\\{\\lambda\\}$ such that an element $s_\\lambda$ of $\\bm{s}$ can be assigned to each set,\n$$\ns_\\lambda \\sim \\text{Inv-Gamma}(\\alpha,\\beta), \\quad w_i^\\lambda \\sim \\mathcal{N}(0,s_\\lambda) \n$$\nwe can consider solving the MAP optimization problem for the KL divergence,\n\n$$\ns^*_\\lambda = \\argmin_{s_\\lambda} KL\\bigg[q(\\bm{\\omega};\\bm{\\theta})||p(\\bm{\\omega}^\\lambda\\mid s_\\lambda) - \\log p(s_\\lambda)\\bigg]\n$$\n\nThis leads to the closed-form solution,\n$$\ns^*_\\lambda = \\frac{\\text{tr}(\\Sigma_q^\\lambda+\\mu_q^\\lambda(\\mu_q^\\lambda)^T)+2\\beta}{\\Omega_\\lambda + 2\\alpha + 2}\n$$\n\nwhere $\\Omega_\\lambda := |\\lambda|$. We can then use $s^*_\\lambda$ to determine the diagonal entries of $\\Sigma_p$ and solve (1).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[scale=.5]{fig/empirical-bayes.png}\n\\caption{Test Log-likelihood with tuned prior (orange) and EB (blue).}\n\\label{fig:emp_bayes}\n\\end{figure}\n", "meta": {"hexsha": "fa0eb59f5cd5c49fe71e0da4f6b971f0b6607c5a", "size": 5419, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_notes/paper-summary/DVI-2019-05-23/tex/Approach.tex", "max_stars_repo_name": "ibrahimkakbar/ibrahimkakbar.github.io", "max_stars_repo_head_hexsha": "5e6b0ea67f5e5f8f3a7bb4394095ea7f7992673a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_notes/paper-summary/DVI-2019-05-23/tex/Approach.tex", "max_issues_repo_name": "ibrahimkakbar/ibrahimkakbar.github.io", "max_issues_repo_head_hexsha": "5e6b0ea67f5e5f8f3a7bb4394095ea7f7992673a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_notes/paper-summary/DVI-2019-05-23/tex/Approach.tex", "max_forks_repo_name": "ibrahimkakbar/ibrahimkakbar.github.io", "max_forks_repo_head_hexsha": "5e6b0ea67f5e5f8f3a7bb4394095ea7f7992673a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.4479166667, "max_line_length": 470, "alphanum_fraction": 0.7080642185, "num_tokens": 1793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.441593902514128}}
{"text": "% ------------------------------------------------------------------\n\\documentclass[12 pt]{article}\n\\newcommand\\ignore[1]{}\n\\usepackage[left]{lineno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{cancel}\n \\usepackage{graphicx}\n\\usepackage{braket}\n\\usepackage{authblk}\n\\usepackage{caption,subcaption}\n\\usepackage{comment}\n\\usepackage{enumitem}\n\\pagestyle{plain}\n\\pagenumbering{arabic}\n\\usepackage{color}\n\\newcommand{\\rcb}[1]{\\textcolor{blue}{  #1 }}\n\\newcommand{\\rcbfoot}[1]{\\textcolor{red}{**\\footnote{\\textcolor{blue}{ \\sc COMMENT REMOVE LATER *** #1 ***}}}}\n\\pdfpagewidth 8.5 in\n\\pdfpageheight 11 in\n\\setlength{\\parindent}{0 mm}\n\\setlength{\\parskip}{10pt}\n\\setlength{\\abovedisplayskip}{0 pt}\n\\setlength{\\belowdisplayskip}{0 pt}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage[margin = .75 in]{geometry}\n\\usepackage[pdftex, pdfstartview={FitH}, pdfnewwindow=true, colorlinks=false, pdfpagemode=UseNone]{hyperref}\n\n% Laziness shortcuts\n\n\\newcommand\\dd{\\partial}\n\\newcommand{\\nn}{\\nonumber \\\\}\n\\newcommand\\be{\\begin{equation}}\n\\newcommand\\ee{\\end{equation}}\n\\newcommand\\bea{\\begin{eqnarray}}\n\\newcommand\\eea{\\end{eqnarray}}\n\\newcommand{\\<}{\\langle}\n\\renewcommand{\\>}{\\rangle}\n\\newcommand\\half{ \\textstyle {\\frac{1}{2}}}\n% ------------------------------------------------------------------\n\\bibliographystyle{unsrt}\n\n% ------------------------------------------------------------------\n\\begin{document}\n\n\\begin{center}\n \\Large \\bf 2D U(1) Gauge Slab Action\n\\end{center}\n\n\\section{Massless $\\phi^4$ Theory}\nConsider the 1D central line of a 1D $\\phi^4$ theory. One may ask the question \"what is the effective action on the central line if we integrate out the action from the non-central lines?\"\n\nWe shall refer to coordinates on the $x$- plane simply as $x$ and coordinates in the extra dimension as $s$. Hence, a lattice point will in general be given by $(x,s)$. The full action given in terms of the discrete Laplace operator is\n\\be\nS =  \\frac{1}{2} \\sum_{x,s} (\\phi(x+a,s) - \\phi(x,s))^2 + \\frac{1}{2}\\sum_{x}\\sum_{s=-L_{s}/2}^{L_s/2-1}(\\phi(x,s+a) - \\phi(x,s))^2\n\\ee\nso we are asking the question \n\n\n\n\\section{Non-compact Gaussian Action}\n\nHere is the 2d $L^2$ action  with $L_s + 1$  slices: $s = 0, \\pm 1, \\cdots L_s/2$.\n%\n\\be\nS =  \\frac{1}{4} \\sum_{x,s}   \\sum_{\\mu,\\nu} F_{\\mu \\nu}(x,s) F_{\\mu\n  \\nu}(x,s)  + \\frac{1}{2} \\sum_{\\mu,\\nu} E_\\mu(x,s) E_\\mu(x,s)  \n\\ee\nwhere \n\\be\nF_{\\mu \\nu}(x,s)  = \\Delta_\\mu \\theta_\\nu(x,s) - \\Delta_\\nu \\theta_\\mu(x,s) \\nn\n = ( \\theta_\\nu(x +\\mu,s) - \\theta_\\nu(x,s) ) - ( \\theta_\\mu(x +\\nu,s) - \\theta_\\mu(x,s) )\n\\ee\nand \n\\be\nE_\\mu(x,s) = \\Delta_s \\theta_\\mu(x,s) = \\theta_\\mu(x,s+1)  -\\theta_\\mu(x,s) \n\\ee\nTherefore,\n\\be\nS =  \\frac{1}{2} \\sum_{x,s}  \\sum_{\\mu <\\nu} ( ( \\theta_\\nu(x +\\mu,s)\n- \\theta_\\nu(x,s) ) - ( \\theta_\\mu(x +\\nu,s) - \\theta_\\mu(x,s) ))^2\n+ \\frac{1}{2} \\sum_{x,s} \\sum^{L_s/2 -1}_{s= -L_s/2} (\\theta_\\mu(x,s+1)  -\\theta_\\mu(x,s) )^2\n\\ee\nWe can go to momentum space by a unitary transformation :\n\\be\n\\theta_\\mu(x,s) =  \\frac{1}{(2 \\pi)^2}\\int^\\pi_{-\\pi} d^2k   e^{i x k}\\widetilde\\theta_\\mu(k,s) \\quad \n\\mbox{and} \\quad  \\widetilde \\theta_\\mu(k,s) = \\frac{1}{L}\\sum_{x \\in Z}  e^{-i x k} \\theta_\\mu(x,s) \n\\ee\nand \n\\be\n\\Delta_\\mu \\theta_\\nu(x,s)\n= \\frac{1}{L}\\sum_k(e^{ik_\\mu} - 1)  e^{i x k} \\widetilde\n\\theta_\\nu(k,s) \n\\ee\n\nor defining $ (e^{ik_\\mu} - 1) =  i \\hat k_\\mu $ this  gives,\n\\bea\nS &=&  \\frac{1}{2} \\sum_{k,s}\\sum_{\\mu <\\nu} [ \\hat k^*_\\mu  \\widetilde \\theta^*_\\nu(k,s) -\n\\hat k^*_\\nu   \\widetilde \\theta^*_\\mu(k,s) ]  [ \\hat k_\\mu  \\widetilde \\theta_\\nu(k,s) -\n\\hat k_\\nu   \\widetilde \\theta_\\mu(k,s) ]  \\nn\n&+& \\frac{1}{2} \\sum^{L_s/2 -1}_{s= -L_s/2}  \\sum_{k,\\mu} (\\widetilde\\theta^*_\\mu(k,s+1) -\\widetilde\\theta^*_\\mu(k,s))(\\widetilde\\theta_\\mu(k,s+1)  -\\widetilde\\theta_\\mu(k,s) )\n\\eea\n(Note in 2D  $\\mu = x$, and $\\nu = y$ so there is no sum at all!) \nThe quadratic form is \n\\be\nS = \\frac{1}{2} \\widetilde \\theta^*_\\mu(k,s)\nM_{\\mu\\nu}(k)\\theta_\\nu(k,s)  - \\frac{1}{2} [\\widetilde\n\\theta^*_\\mu(k,s) \\theta_\\mu(k,s+1) + \\widetilde\n\\theta^*_\\mu(k,s+1) \\theta_\\mu(k,s)]\n\\ee\nSince it is of course diagonal in k, the sum over $k$ implicit. \n\nWe now integrate all {\\bf but} the zero-th central slice. Formally separating\ncalling the thetas on the midels slide $\\widetilde \\theta(k,0) \\equiv\n\\widetilde \\theta_\\mu(0) $ we don the \n integral for over the others  $\\Theta_{\\mu s}(k) = \\widetilde \\theta_\\mu(k,s \\ne 0)$'s; to get the effective action in\n$k-space$:\n%\n\\bea\n&& e^{\\textstyle - S_{eff}} \\nn\n &=& e^{\\textstyle -\\frac{1}{2} \\widetilde \\theta^*_\\mu(k,0)\nM_{\\mu\\nu}(k) \\widetilde \\theta_\\nu(k,0) }  \\nn &\\times &\\int \nd^2\\Theta_{\\mu s}(k) \ne^{  \\textstyle -\\frac{1}{2}  \\Theta^\\dag_{\\mu s}(k) G^{ss'}_{\\mu\\nu} (k) \n  \\Theta_{s'\\nu}(k)  + \\frac{1}{2}[\\widetilde \\theta^*_\\mu(k,0) (\n  \\Theta_{1,\\mu}(k) + \\Theta_{-1,\\mu}(k))  +(\\Theta^\\dag_{1,\\mu} + \\Theta^\\dag_{-1,\\mu} )\\widetilde \\theta_\\mu(k,0)]}\\nn\n&=& e^{\\textstyle -\\frac{1}{2} \\widetilde \\theta^*_\\mu(k,0)\nM_{\\mu\\nu}(k) \\widetilde \\theta_\\nu(k,0)  +  \\frac{1}{2} \\widetilde\n\\theta^*_\\mu(k,0) ([1/G(k)]^{11}_{\\mu\\nu} (k)  +[1/G(k)]^{-1-1}_{\\mu\\nu} (k)]\\widetilde \\theta_\\nu(k,0) } \n\\eea\n%\n\\end{document}", "meta": {"hexsha": "ced8fa620d7f7a07cc6a4d1da58e7e3b9b24fe64", "size": 5172, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/U1_slab_notes.tex", "max_stars_repo_name": "ekowen86/2p1D-Schwinger", "max_stars_repo_head_hexsha": "09418f75b116eb98b9b934ee25f2046852becb44", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/U1_slab_notes.tex", "max_issues_repo_name": "ekowen86/2p1D-Schwinger", "max_issues_repo_head_hexsha": "09418f75b116eb98b9b934ee25f2046852becb44", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/U1_slab_notes.tex", "max_forks_repo_name": "ekowen86/2p1D-Schwinger", "max_forks_repo_head_hexsha": "09418f75b116eb98b9b934ee25f2046852becb44", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3111111111, "max_line_length": 235, "alphanum_fraction": 0.6104021655, "num_tokens": 2086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4415938848774858}}
{"text": "\\chapter{Rotor-dynamic analysis}\n\n\n\\noindent\nFrom this point onwards, the tail-rotor behaviour has been investigated implementing a simplified FEM model and taking advantage of the Rotordynamics capabilities of Ansys. \\\\\nFrom the definition of ANSYS help, \\textit{Rotor-dynamics is the study of vibrational behaviour in axially symmetric rotating structures}. At high rotational speeds, such as in a helicopter's tail rotor, the inertia effects of the rotating parts must be consistently represented in order to accurately predict the rotor behaviour. An important part of the inertia effects is the \\underline{gyroscopic moment} introduced by the precession motion of the rotor which is function of the spin velocity. Hence, the velocity term in the equation of motion as well as the support flexibility and damping behaviour cannot be neglected and they are important factors in enhancing the stability of the vibrating rotor.\n\n\n\n\\section*{Modal analysis of rotating structures}\n\\addcontentsline{toc}{section}{Modal analysis of rotating structures}\n\\noindent\nThe modal analysis allows for the calculation of natural frequencies and critical speeds (Campbell diagram) of the rotor. \\\\\nFrom dynamical point of view, the equations of motion of a generic rotating structure is:\n\\medskip\n\n\\begin{equation*}\n\\left[ M \\right] \\left\\lbrace \\ddot{u} \\right\\rbrace + \\left( \\left[ C \\right] + \\left[ G \\right] \\right) \\left\\lbrace \\dot{u} \\right\\rbrace + \\left( \\left[ K \\right] - \\left[ K_c \\right] \\right) \\left\\lbrace u \\right\\rbrace = \\left\\lbrace 0 \\right\\rbrace\n\\end{equation*}\n\n\n\\medskip\n\\noindent\nwhere [G] is the gyroscopic matrix that depends on the rotational velocity and is the major contributor to tailboom's rotor, while [$K_c$], the spin softnening matrix, also depends upon the rotational velocity and it modifies the apparent stiffness of the structure. \\\\\nThis equation holds when motion is described in a stationary reference frame.\n\n\\clearpage\n\\noindent\n\\underline{STEPS FOR MODAL ANALYSIS IN ANSYS}: \\\\\n\\begin{itemize}\n\t\\item 1) Model implementation; \n\t\n\t\\item 2) Boundary conditions; \n\t\n\t\\item 3) Solution including rotational effects (centrifugal and Coriolis); \n\t\n\t\\item 4) Postprocessing. \\\\\n\\end{itemize}\n\n\n\n\\subsection*{Tail rotor simplified model}\n\\addcontentsline{toc}{subsection}{Tail rotor simplified model}\n\\noindent\nA simplified model of the tail rotor has been defined, and built up in apart macro. It consists in the following parts:\n\\begin{itemize}\n\t\\item \\textbf{SHAFT}: elastically supported shaft modelled with BEAM 188 elements;\n\t\\item \\textbf{ROTOR'S HUB}: modelled with a lumped mass and inertia concentrated in the center of the rotor attached to a master node;\n\t\\item \\textbf{ROTOR}: modelled with a circular ring of SHELL 181 elements with radius passing through to the center of mass of the blades. CERIG elements have been introduced in order to connect the master node (hub) to the slave nodes of the ring.\n\\end{itemize}\n\n\\medskip\n\\begin{figure}[h]\t\n\t\\centering\n\t\\subfloat[][\\emph{real tail rotor assembly}.]\n\t{\\includegraphics[width=.45\\textwidth]{PICTURES/2_Lama_truss/PNG/model2/hqdefault2}} \\quad\n\t\\subfloat[][\\emph{analysis model}.]\n\t{\\includegraphics[width=.45\\textwidth]{PICTURES/5_Rotordynamics/scheme.png}}\\\\\n\t\\caption{Schemes of tail rotor assembly's model}\n\\end{figure}\n%\\vspace{0.5cm}\n\n\\subsection*{Model assumptions}\n\\addcontentsline{toc}{subsection}{Model assumptions}\n\\begin{itemize}\n\t\\item Axial-symmetric structure (rotor-dynamics requirement in Ansys);\n\t\\item Linear elastic material properties;\n\t\\item Rotor elastically supported (2 bearings);\n\t\\item Aerodynamic loads not considered;\n\t\\item Rigid rotor and connections (no hinges or flexible joints).\n\\end{itemize}\n\n\n\n\\subsection*{Applied boundary conditions}\n\\addcontentsline{toc}{subsection}{Applied boundary conditions}\n\\noindent\n\\begin{itemize}\n\t\\item Only fixed constraints are allowed for rotor-dynamic analysis;\n\t\\item Support elasticity modelled using COMBIN14 elements to represent bearings;\n\\end{itemize}\n\n\\noindent\n\\textbf{COMBIN14} \\\\\nBearings have been modelled with COMBIN14 element whose properties simulate the effect of a longitudinal spring-damper as a axial tension-compression element.\nThe element is created between two nodes which, in our case, are overlapped. One of the nodes is rigidly attached to the shaft while the other one is constrained on the ground. These elements allows the elastic movement of the shaft in the Y and Z directions. The bearing is composed by 7 balls that ensure an overall stiffness equal to $378e+7$ N/m.\\\\\n\n\\medskip\n\\begin{figure}[h]\n\t\\begin{center}\n\t\t\\centering  \t\t \t\t\n\t\t\\includegraphics[width=0.55\\linewidth]{PICTURES/5_Rotordynamics/2.png}\n\t\\end{center}\n\t\\caption {Tail rotor simplified model}\n\\end{figure}\n%\\vspace{0.5cm}\n\n\\clearpage\n\\subsection*{Solution including rotational effects (centrifugal and Coriolis)}\n\\addcontentsline{toc}{subsection}{Solution including rotational effects (centrifugal and Coriolis)}\n\\noindent\nThe modal analysis must be solved using an algorithm for damped modal analysis (complex Eigenvalues and Eigenvectors). We have chosen the \\textbf{QRDAMP} solver including the rotational effects (\\textbf{CORIOLIS, ON, , , ON}), as reported in listing (\\ref{list:SolutionChunk}). The rotation speed (2000 RPM) has been divided in several load-steps. 10 modes have been extracted from each step. \n\n\\lstinputlisting[firstline=133, lastline=146, language=apdl-modified,label={list:SolutionChunk}, caption=solution including rotational effects]{./COMMAND_LISTS/SOLO_ROTOR.txt}\n\n\\subsection*{Postprocessing}\n\\addcontentsline{toc}{subsection}{Postprocessing}\n\\noindent\nRotor's natural frequencies have been calculated for each value of the rotation speed (hence for each load step) and assigned to a substep. Resulting natural frequencies vary with the rotor speed as it is displayed in the campbell diagram below. \\\\\nA \\textbf{critical speed} appears when the natural frequency is equal to the excitation frequency, and excitation may come from unbalance that is synchronous with the rotational velocity. \\\\\nCritical speeds are directly determined by solving a new eigenvalue problem or by performing a Campbell diagram analysis, where the intersection points between the frequency curves and the excitation line are calculated.\n\n\\noindent\nThe rotational velocity of the rotor is specified via the \\textbf{CMOMEGA} command which requires to specify which is the rotating component, previously defined and selected as input for the velocity vector (magnitude and direction). \\\\\nThen, we can set the \\textbf{CAMPBELL, ON} Ansys' command. \\\\\n\n\\noindent\n\\textbf{NOTE:} \\\\\nBearing stiffness has an important effect on the critical speeds. When analysing a rotor, it is important to understand the effect of the bearing stiffness on the critical speeds and this can be done drawing the \"Critical Speed Map\" (here neglected).\n\n\\vspace{5mm}\n\\noindent\nThe rotor has been achieved with some parameters determined after performed a static analysis on ANSYS. The resulting given matrix provide us the information needed for establish some following conclusions:\n\n\\begin{equation*}\n\\left[ I \\right] = \\begin{bmatrix} 8.6440 & 0.1476 \\times 10^{-3} & -0.3815 \\times 10^{-4} \\\\ 0.1476 \\times 10^{-3} & 14.487 & -0.1114 \\times 10^{-3} \\\\ -0.3815 \\times 10^{-4} & -0.1114 \\times 10^{-3} & 13.895\n\\end{bmatrix} \\quad\n\\end{equation*}\n\n\\vspace{3mm}\n\\noindent\nAs can be seen from the preceding matrix [\\textit{I}], the diagonal guys refers to polar ($I_{p1}$ = 8.6440 $kg*m^2$) and diametrical inertia ($I_{d2}$ = 14.487 $kg*m^2$, $I_{d3}$ = 13.895 $kg*m^2$), respectively. From the literature, we expected 4 critical speeds, thanks to the fact that $I_{d}$ > $I_{p}$ for thick disc.\nThe results match with our expectation as we can notice from the Campbell plot below: \n\n\\medskip\n\\begin{figure}[h]\n\t\\begin{center}\n\t\t\\centering  \t\t \t\t\n\t\t\\includegraphics[width=1\\linewidth]{PICTURES/5_Rotordynamics/campbell1.png}\n\t\\end{center}\n\t\\caption{Campbell diagram}\n\t\\label{fig:critical speed} \n\\end{figure}\n%\\vspace{0.5cm}\n\n\\begin{table}[h!]\n\t\\centering\n\t\\pgfplotstableset{\n\t\t% global config, for example in the preamble\n\t\t% these columns/<colname>/.style={<options>} things define a style\n\t\t% which applies to <colname> only.\n\t\tevery head row/.style={before row=\\hline,after row=\\hline},\n\t\tevery last row/.style={after row=\\hline},\n\t\tdisplay columns/0/.style={column name =Num, int detect,column type=r},\n\t\tdisplay columns/1/.style={column name =Critical Speed [rpm], column type=r,\n\t\t\tfixed,fixed zerofill,precision=5,set thousands separator={\\,}},\n\t\t%other style option   \n\t}\n\t\\pgfplotstabletypeset[col sep=space]{VelocCritic-ModalAnalisys.txt}\n\t\\caption{Natural frequencies for the simple model}\n\t\\label{tab:ModalFreq-Shellmodel}\n\\end{table}\n%\n\\noindent The fourth critical speed isn't shown in the figure~\\ref{fig:critical speed} because is much higher than the full scale (2000 rpm), which value representing the nominal rotational speed of the rotor. We can even say that, with these results, it would be not advisable to design a rotor which is expected to operate at a velocity that stands in the middle of 2 of its critical speeds, since this range is typically UNSTABLE and inside it the onset of self-excited vibration phenomenon cannot be prevented.\\\\\nHowever, this model does not represent the real tail rotor but it is just a very simplified model with the idea of explore the Ansys rotordynamics capabilities.\\\\\nHence, we can conclude that this value of speed appears unsafe from a dynamical point of view. In these cases, in order to be a rigid rotor, the literature suggests to change the geometrical parameters of the rotors, e.g. by adding or subtracting suitable masses or essentially \\underline{by made torsionally stiffer the rotor shaft}. The idea of increase the stiffness of the shaft, from our point of view, could be a smart solution to solve this issue. Anyway, we are completely aware of the roughly results and so we can go on with the remaining analysis. One brief and further consideration is given relative to the resulting orbit motion of the rotor (whirling), that turns out by the gravitational static imbalance affecting the rotor structure and produces rotating bending of the shaft.\n\n\\medskip\n\\begin{figure}[h]\n\t\\begin{center}\n\t\t\\centering  \t\t \t\t\n\t\t\\includegraphics[width=0.45\\linewidth]{PICTURES/5_Rotordynamics/ModalAnalisys004.png} \n\t\\end{center}\n\t\\caption{Orbital motion of the rotor shaft}\n\\end{figure}\n\n\\subsection*{Coupling analysis}\n\\addcontentsline{toc}{subsection}{Coupling analysis}\n\\noindent Once realized the rotor, one attempt was given on mounting that system upon the main structure, in order to verify the rotor-tailboom coupling, starting with the hints written on the chapter~\\ref{ch:Rotor-fuselage dynamic coupling}. Here, one goal is to check the vibrations exerted by the gravitational static imbalance of the rotor on the tailboom main structure and spend some words regarding modal shape and natural frequencies of the overall assembly. \n\n\\medskip\n\\begin{figure}[h]\t\n\t\\centering\n\t\\subfloat[][Truss model]  \t\t \t\t\n\t{\\includegraphics[width=0.45\\linewidth]{PICTURES/5_Rotordynamics/TrussTailLumpedRotorRun003.png}} \\quad\n\t\\subfloat[][Shell model]\n\t{\\includegraphics[width=0.45\\linewidth]{PICTURES/5_Rotordynamics/ShellmodelShaftLumped005.png}} \n\t\\caption{Rotor - fuselage coupling}\n\t\\label{Rotor - fuselage coupling}\n\\end{figure}\n\n\\noindent\nUnfortunately, rotordynamics in ANSYS has no advanced tools to study asymmetric structures and, as we mentioned before, it performs and solve frameworks that are only axisymmetric respect to one principal axis. Indeed, we tried to follow this way, but ANSYS provide only information relative to the sole rotor (as we can observe from the figure~\\ref{Rotor - fuselage coupling}), without take into account the coupling effect. This software lack pushed ourselves to don't proceed the analysis forward, even though could be a future matter of investigation.\n", "meta": {"hexsha": "f719370a4a6c7883cbea6e46c4796a302481dec8", "size": 12010, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/CHAPTER_5.tex", "max_stars_repo_name": "frank1789/FEM-Analysis---Helicopter-s-Tail", "max_stars_repo_head_hexsha": "48c3bbc21f16c18537925db985f91c30aa87a8aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-02T12:50:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-02T12:50:01.000Z", "max_issues_repo_path": "Report/CHAPTER_5.tex", "max_issues_repo_name": "frank1789/FEM-Analysis---Helicopter-s-Tail", "max_issues_repo_head_hexsha": "48c3bbc21f16c18537925db985f91c30aa87a8aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-07-06T08:06:09.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-06T08:06:09.000Z", "max_forks_repo_path": "Report/CHAPTER_5.tex", "max_forks_repo_name": "frank1789/FEM-Analysis---Helicopter-s-Tail", "max_forks_repo_head_hexsha": "48c3bbc21f16c18537925db985f91c30aa87a8aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.9072164948, "max_line_length": 794, "alphanum_fraction": 0.7803497086, "num_tokens": 3042, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4415938754186453}}
{"text": "\\documentclass[11pt]{amsart}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage{fp}  % Prevents issues with arithmetic overflow.\n\\usepackage{pgfplots}\n\\usepackage{xcolor}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage[section]{placeins}  % Prevents figure placement outside of section.\n\\usetikzlibrary{arrows, fixedpointarithmetic}\n\n\\newcommand{\\shaft}{\\mathrm{shaft}}\n\\newcommand{\\kiteshaft}{\\mathrm{kite-shaft}}\n\\newcommand{\\ground}{\\mathrm{ground}}\n\\newcommand{\\tether}{\\mathrm{tether}}\n\\newcommand{\\bus}{\\mathrm{bus}}\n\n\\definecolor{matlab1}{rgb}{0, 0.4470, 0.7410}\n\\definecolor{matlab2}{rgb}{0.8500, 0.3250, 0.0980}\n\\definecolor{matlab3}{rgb}{0.9290, 0.6940, 0.1250}\n\\definecolor{matlab4}{rgb}{0.4940, 0.1840, 0.5560}\n\\definecolor{matlab5}{rgb}{0.4660, 0.6740, 0.1880}\n\\definecolor{matlab6}{rgb}{0.3010, 0.7450, 0.9330}\n\\definecolor{matlab7}{rgb}{0.6350, 0.0780, 0.1840}\n\n\\title{Motor basics}\n\\author{Makani Technologies LLC}\n\n\\begin{document}\n\\maketitle\n\n\\section{Basic three-phase motor equations}\n\nThe basic equations that describe a three-phase motor circuit are\n%\n\\begin{eqnarray}\n  \\label{eqn:motor_abc}\n  v_a &=& R_s i_a + \\frac{d\\lambda_a}{dt} \\\\\n  v_b &=& R_s i_b + \\frac{d\\lambda_b}{dt} \\\\\n  v_c &=& R_s i_c + \\frac{d\\lambda_c}{dt}\n\\end{eqnarray}\n%\nwhere $v_i$ and $i_i$ are the individual phase voltages and currents\nand $R_s$ is the single phase stator resistance.  The flux linkages,\n$\\lambda_i$, are defined such that their derivative is the induced\nvoltage, and they include both the effects from the self-inductance of\nthe motor coils as well as the back EMF induced by the permanent\nmagnets.\n\n\n\\section{Park transformation}\n\nThe Park transformation is an \\textit{amplitude invariant} coordinate\ntransformation\\footnote{There is a power invariant form of this\n  coordinate transformation, which is an orthogonal rotation in a\n  vector space spanned by orthogonal $a$, $b$, and $c$ axes about the\n  $[1,1,1]^T$ vector.}  to a frame that rotates with the rotor (see\nFig. \\ref{fig:dq0}).  Because it is amplitude invariant, the maximum\nphase voltage and current remain the same; however, the naive torques\nand powers calculations must be scaled by a factor of 3/2.\n\n\\begin{figure}[!htb]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\begin{scope}[scale=4]\n        % Draw a, b, c axes.\n        \\draw [dashed, arrows={-latex}] (0, 0) -- (1, 0) node[below] {$a$};\n        \\draw [dashed, arrows={-latex}] (0, 0) -- ({-1/2}, {sqrt(3)/2}) node[above] {$b$};\n        \\draw [dashed, arrows={-latex}] (0, 0) -- ({-1/2}, {-sqrt(3)/2}) node[below] {$c$};\n\n        \\begin{scope}[rotate=45]\n          % Draw d, q axes.\n          \\draw [arrows={-latex}] (0, 0) -- (1, 0) node[below] {$d$};\n          \\draw [arrows={-latex}] (0, 0) -- (0, 1) node[above] {$q$};\n\n          % Draw magnet.\n          \\draw (0, -0.1) rectangle (0.25, 0.1) node[pos=0.5, rotate=-45] {N};\n          \\draw (-0.25, -0.1) rectangle (0, 0.1) node[pos=0.5, rotate=-45] {S};\n        \\end{scope}\n\n        % Draw omega * t.\n        \\draw [arrows={-latex}] (0.4, 0) arc (0:45:0.4);\n        \\path (0.4, 0) arc (0:25.5:0.4) node[right] {$\\omega_e t$};\n      \\end{scope}\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{\\label{fig:dq0}Representation of the Park transformation.}\n\\end{figure}\n\nThe transformation is defined by\n%\n\\begin{equation}\n  \\label{eqn:park}\n  \\begin{bmatrix}\n    f_d \\\\\n    f_q \\\\\n    f_0 \\\\\n  \\end{bmatrix}\n  = \\frac{2}{3}\n  \\begin{bmatrix}\n    \\cos (\\theta_e)  & \\cos (\\theta_e - \\frac{2 \\pi}{3})  & \\cos (\\theta_e + \\frac{2 \\pi}{3}) \\\\\n    -\\sin (\\theta_e) & -\\sin (\\theta_e - \\frac{2 \\pi}{3}) & -\\sin (\\theta_e + \\frac{2 \\pi}{3}) \\\\\n    \\frac{1}{2}    & \\frac{1}{2}                        & \\frac{1}{2} \\\\\n  \\end{bmatrix}\n  \\cdot\n  \\begin{bmatrix}\n    f_a \\\\\n    f_b \\\\\n    f_c \\\\\n  \\end{bmatrix}\n\\end{equation}\n%\nwhere $\\theta_e = \\omega_e t = p \\theta_m$ is the electrical angle of\nrotation, and $f_i$ may either be the phase voltages or currents or\nthe flux linkages.\n\nAlso, note that the Park transformation matrix,\n$\\mathbf{K}(\\theta_e) = \\mathbf{K}(\\omega_e t)$, is a function of\ntime, so derivatives of parameters transform as\n%\n\\begin{equation}\n  \\label{eqn:park_deriv}\n  \\dot{\\vec{f}}_{dq0} = \\mathbf{K}(\\theta_e) \\dot{\\vec{f}}_{abc} +\n                        \\omega_e \\frac{d \\mathbf{K}(\\theta_e)}{d\\theta_e} \\vec{f}_{abc}\n\\end{equation}\n\n\\section{Circuit equations in dq0 coordinates}\n\nUsing the Park transformation (Eq. \\ref{eqn:park}) and its derivative\n(Eq. \\ref{eqn:park_deriv}), it is possible to transform the basic\nthree-phase motor equations (Eq. \\ref{eqn:motor_abc}) into a frame\nthat rotates with the rotor.  Notably, because of the derivative, the\nflux linkages transform as\n%\n\\begin{equation}\n  \\frac{d}{dt}\n  \\begin{bmatrix}\n    \\lambda_d \\\\\n    \\lambda_q \\\\\n    \\lambda_0 \\\\\n  \\end{bmatrix}\n  +\n  \\omega_e\n  \\begin{bmatrix}\n    -\\lambda_q \\\\\n    \\lambda_d \\\\\n    0 \\\\\n  \\end{bmatrix}\n  = \\mathbf{K}(\\theta_e) \\cdot \\frac{d}{dt}\n  \\begin{bmatrix}\n    \\lambda_a \\\\\n    \\lambda_b \\\\\n    \\lambda_c \\\\\n  \\end{bmatrix}\n\\end{equation}\n%\nThus, the basic three-phase motor equations may be rewritten in the\nrotating frame as\n%\n\\begin{eqnarray}\n  v_d &=& R_s i_d + \\frac{d\\lambda_d}{dt} - \\omega_e \\lambda_q \\\\\n  v_q &=& R_s i_q + \\frac{d\\lambda_q}{dt} + \\omega_e \\lambda_d\n\\end{eqnarray}\n%\nIn the rotating frame, the flux linkages may be written in terms of\nconstant inductances along the $d$- and $q$-axes, $L_d$ and $L_q$, as\nwell as a component due to the permanent magnets, $\\lambda_m$, along\nthe $d$-axis.\n%\n\\begin{eqnarray}\n  \\lambda_d &=& L_d i_d + \\lambda_m \\\\\n  \\lambda_q &=& L_q i_q\n\\end{eqnarray}\n%\nFinally, the motor dynamics may be written in matrix form as\n%\n\\begin{equation}\n  \\frac{d}{dt}\n  \\begin{bmatrix}\n    i_d \\\\\n    i_q \\\\\n  \\end{bmatrix}\n  =\n  \\begin{bmatrix}\n    -R_s / L_d          & \\omega_e L_q / L_d \\\\\n    -\\omega_e L_d / L_q & -R_s / L_q \\\\\n  \\end{bmatrix}\n  \\cdot\n  \\begin{bmatrix}\n    i_d \\\\\n    i_q \\\\\n  \\end{bmatrix}\n  +\n  \\begin{bmatrix}\n    1/L_d & 0 \\\\\n    0     & 1/L_q \\\\\n  \\end{bmatrix}\n  \\cdot\n  \\begin{bmatrix}\n    v_d \\\\\n    v_q - \\omega_e \\lambda_m \\\\\n  \\end{bmatrix}\n\\end{equation}\n\nThe steady-state form of these equations,\n%\n\\begin{equation}\n  \\label{eqn:voltage_limit}\n  \\begin{bmatrix}\n    v_d \\\\\n    v_q \\\\\n  \\end{bmatrix}\n  =\n  \\begin{bmatrix}\n    R_s          & -\\omega_e L_q \\\\\n    \\omega_e L_d & R_s \\\\\n  \\end{bmatrix}\n  \\cdot\n  \\begin{bmatrix}\n    i_d \\\\\n    i_q \\\\\n  \\end{bmatrix}\n  +\n  \\begin{bmatrix}\n    0 \\\\\n    \\omega_e \\lambda_m \\\\\n  \\end{bmatrix}\n\\end{equation}\n%\ndefine a family of ellipses in the phase current plane.  The ellipse\ndefined by the maximum single phase voltage,\n$|v_{dq}| < m \\cdot v_{\\bus} / \\sqrt{3}$, where $m$ is the maximum\nmodulation index, defines the accesible region of the phase current\nplane for a given $\\omega_e$.  The center of this voltage-limit\nellipse is given by the short-circuit current:\n%\n\\begin{equation}\n  \\vec{i}_{sc} =\n  \\frac{-\\omega_e \\lambda_m}{R_s^2 + \\omega_e^2 L_d L_q}\n  \\begin{bmatrix}\n    \\omega_e L_q \\\\\n    R_s\n  \\end{bmatrix}\n\\end{equation}\n%\nEquation \\ref{eqn:voltage_limit} may be grossly simplied by assuming,\n$L_d = L_q$ (i.e. non-salient motor), and $\\omega_e L \\gg R_s$.\n%\n\\begin{equation}\n  \\frac{1}{\\omega_e L}\n  \\begin{bmatrix}\n    v_d \\\\\n    v_q \\\\\n  \\end{bmatrix}\n  =\n  \\begin{bmatrix}\n    0 & -1 \\\\\n    1 & 0 \\\\\n  \\end{bmatrix}\n  \\cdot\n  \\begin{bmatrix}\n    i_d \\\\\n    i_q \\\\\n  \\end{bmatrix}\n  +\n  \\begin{bmatrix}\n    0 \\\\\n    \\lambda_m / L \\\\\n  \\end{bmatrix}\n\\end{equation}\n%\nIn this limit, the relationship between the phase voltage and current\nis clear.  The voltage limit circle is centered at\n$\\vec{i}_{dq} = [-\\lambda_m / L, 0]^T$ and has radius\n$v_{\\max} / \\omega_e L$.  The phase voltage axes are rotated\n$-\\frac{\\pi}{2}$ rad from the phase current axes (see\nFig. \\ref{fig:voltage_limit}).\n\n\\begin{figure}[!htb]\n  \\begin{center}\n    \\begin{tikzpicture}[fixed point arithmetic]\n      \\begin{scope}[scale=0.012]\n        \\def\\Rs{0.103};\n        \\def\\L{0.868e-3};\n        \\def\\lambdam{0.1666};\n        \\def\\Npp{15};\n        \\def\\imax{225};  % [A]\n        \\def\\axislen{300};\n\n        \\def\\omegam{100};\n        \\def\\omegae{(\\omegam * \\Npp)};\n        \\def\\znorm{(\\Rs * \\Rs + \\L * \\omegae * \\L * \\omegae)};\n        \\def\\idcenter{(-\\omegae * \\omegae * \\L * \\lambdam / \\znorm)};\n        \\def\\iqcenter{(-\\Rs * \\omegae * \\lambdam / \\znorm)};\n        \\def\\vdqmax{(850.0 / sqrt(3) * 0.95 * 0.94)};\n        \\def\\iradius{(\\vdqmax / sqrt(\\znorm))};\n        \\def\\iqfw{sqrt(\\iradius * \\iradius - \\idcenter * \\idcenter)};\n        \\def\\idsc{(-\\lambdam / \\L)};\n\n        % Draw axes.\n        \\draw [arrows={latex-latex}] (-\\axislen, 0) -- (\\axislen, 0)\n              node[below] {$i_d$};\n        \\draw [arrows={latex-latex}] (0, -\\axislen) -- (0, \\axislen)\n              node[right] {$i_q$};\n\n        % Draw phase current magnitude limit.\n        \\draw [dashed] (0, 0) circle (\\imax);\n        \\draw [arrows={-latex}] ({1.2 * \\imax * cos(45) + 50},\n                                 {1.2 * \\imax * sin(45)})\n                                node[right] {$i_{\\max}$} --\n                                ({1.2 * \\imax * cos(45)},\n                                 {1.2 * \\imax * sin(45)}) --\n                                ({\\imax * cos(45)},\n                                 {\\imax * sin(45)});\n\n        % Draw phase voltage axes.\n        \\draw [arrows={-latex}] ({\\idsc}, 0) -- ({\\idsc + 50}, 0) node[below] {$v_q$};\n        \\draw [arrows={-latex}] ({\\idsc}, 0) -- ({\\idsc}, -50) node[right] {$v_d$};\n        \\draw [fill] ({\\idsc}, 0) circle (5) node[above right] {$\\vec{i}_{sc}$};\n        % $(-\\frac{\\lambda_m}{L}, 0)$};\n\n        % Draw voltage limit circles.\n        \\def\\omegam{120};\n        \\draw ({\\idcenter}, {\\iqcenter}) circle ({\\iradius});\n        \\draw [arrows={-latex}] ({1.2 * \\iradius * cos(150) - 50 + \\idcenter},\n                                 {1.2 * \\iradius * sin(150) + \\iqcenter})\n                                node[left] {$\\frac{v_{\\max}}{\\omega_e L}$} --\n                                ({1.2 * \\iradius * cos(150) + \\idcenter},\n                                 {1.2 * \\iradius * sin(150) + \\iqcenter}) --\n                                ({\\iradius * cos(150) + \\idcenter},\n                                 {\\iradius * sin(150) + \\iqcenter});\n\n        % Draw increasing speed path.\n        \\def\\nudge{5};\n        \\draw [blue!75, densely dotted, arrows={-latex}]\n              (-\\nudge, 0) -- (-\\nudge, {\\iqfw - 3*\\nudge})\n              node [midway, left] {a};\n        \\draw [blue!75, densely dotted, arrows={-latex}]\n              (-\\nudge, {\\iqfw - 3*\\nudge})\n              arc\n              ({atan2(\\iqfw, -\\idcenter) + 5}:{atan2(\\iqfw, -\\idcenter) + 13}:{\\iradius})\n              node [below] {b}\n              coordinate (end);\n        \\draw [blue!75, densely dotted, arrows={-latex}] (end) arc (100:125:\\imax)\n              node [below right] {c} arc (125:150:\\imax);\n        \\draw [blue!75, densely dotted, arrows={latex-}] ({\\idsc}, \\nudge) -- ({\\idsc}, 100)\n              node [right] {d};\n\n        % Draw higher speed voltage limit circles.\n        \\def\\omegam{150};\n        \\draw [lightgray] ({\\idcenter}, {\\iqcenter}) circle ({\\iradius});\n\n        \\def\\omegam{187.5};\n        \\draw [lightgray] ({\\idcenter}, {\\iqcenter}) circle ({\\iradius});\n\n        %\n        \\draw [gray, arrows={-latex}]\n              ({\\idcenter + (\\iradius + 90) * cos(110)}, {\\iqcenter + (\\iradius + 90) * sin(110)})\n              node [gray, above left] {increasing $\\omega_e$} --\n              ({\\idcenter + (\\iradius - 50) * cos(110)}, {\\iqcenter + (\\iradius - 50) * sin(110)});\n\n        \\draw [gray, arrows={-latex}] (100, 220) -- (100, 300) node [right] {increasing torque};\n      \\end{scope}\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{\\label{fig:voltage_limit}Phase voltage limits in the phase\n    current plane for a non-salient motor in the limit of low stator\n    resistance.  The solid circle is the phase voltage limit, whose\n    radius decreases as the rotor speed increases.  The dashed circle\n    describes the phase current limit, which is determined by gate\n    heating.  The blue line shows a typical path for increasing rotor\n    speed and power: a) the torque increases, b) flux weakening is\n    used to further increase the torque, c) the phase current limit is\n    hit but the motor speed is still increasing, and d) the motor is\n    in the constant power regime.}\n\\end{figure}\n\nThe equation for torque in $dq0$-coordinates is\n%\n\\begin{eqnarray}\n  \\tau_e &=& \\frac{3}{2} p (\\lambda_d i_q - \\lambda_q i_d) \\\\\n         &=& \\frac{3}{2} p \\lambda_m i_q + \\frac{3}{2} p (L_d - L_q) i_q i_d \\\\\n         &\\approx& \\frac{3}{2} p \\lambda_m i_q\n\\end{eqnarray}\n%\nwhere $p$ is the number of pole pairs.  The equation for power is\n%\n\\begin{equation}\n  P_e = \\frac{3}{2} (v_d i_d + v_q i_q)\n\\end{equation}\n%\nwhich under steady-state conditions is\n%\n\\begin{equation}\n  P_e = \\frac{3}{2}\n  \\left(\n    R_s (i_d^2 + i_q^2) + \\omega_e (L_d - L_q) i_q i_d + \\omega_e \\lambda_m i_q\n  \\right)\n\\end{equation}\n\n\n\\begin{table}\n  \\begin{tabular}{lllll}\n    \\hline\n    \\hline\n    Parameter                    & Symbol      & Value   &         & Units \\\\\n                                 &             & Protean & Yasa    & \\\\\n    \\hline\n    Number of pole pairs         & $p$         & 32      & 15      & \\# \\\\\n    d-axis inductance            & $L_d$       & 165     & 1000    & $\\mu$H \\\\\n    q-axis inductance            & $L_q$       & 165     & 1000    & $\\mu$H \\\\\n    Stator resistance            & $R_s$       & 0.041   & 0.103   & $\\Omega$ \\\\\n    Permanet magnet flux linkage & $\\lambda_m$ & 0.06203 & 0.16667 & N$\\cdot$m/A \\\\\n                                 &             &         &         & or V$\\cdot$s/rad \\\\\n    \\hline\n    \\hline\n  \\end{tabular}\n  \\caption{Motor parameters\\protect\\footnotemark.}\n\\end{table}\n%\n\\footnotetext{See\n       {\\texttt{config/m600/power\\_sys\\_sim.py}} and \\\\\n       {\\texttt{avionics/motor/firmware/params.c}}\n}\n\n\\section{Space vector pulse width modulation}\n\nThe phase voltage vector is controlled using a space vector pulse\nwidth modulation scheme \\cite{broek} (see Fig. \\ref{fig:svpwm}).\n\n\\begin{figure}[ht]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\begin{scope}[scale=5]\n        % Draw d, q axes.\n        \\draw [dashed, arrows={-latex}] (0, 0) -- (1, 0) node[below] {$v_d$};\n        \\draw [dashed, arrows={-latex}] (0, 0) -- (0, 1) node[above] {$v_q$};\n\n        % Draw circle.\n        \\draw [lightgray] (0, 0) circle ({1/sqrt(3)});\n        \\draw [arrows={latex-}]\n              ({1/sqrt(3) * cos(30)}, {1/sqrt(3) * sin(30)}) --\n              ({1.2/sqrt(3) * cos(30)}, {1.2/sqrt(3) * sin(30)})\n              node [right] {$v_{\\bus} / \\sqrt{3}$};\n\n        % Draw hexagon.\n        \\draw (2/3, 0) -- (1/3, {1/sqrt(3)}) -- (-1/3, {1/sqrt(3)}) --\n              (-2/3, 0) -- (-1/3, {-1/sqrt(3)}) -- (1/3, {-1/sqrt(3)}) --\n              (2/3, 0);\n        \\draw [fill] (0, 0) -- (2/3, 0) circle (0.01)\n              node [above right] {(100)};\n        \\draw [arrows={latex-}] (2/3, -0.03) -- (2/3, -0.15)\n              node [right] {$\\frac{2}{3} v_{\\bus}$};\n        \\draw [fill] (0, 0) -- (1/3, {1/sqrt(3)}) circle (0.01)\n              node [above right] {(110)};\n        \\draw [fill] (0, 0) -- (-1/3, {1/sqrt(3)}) circle (0.01)\n              node [above left] {(010)};\n        \\draw [fill] (0, 0) -- (-2/3, 0) circle (0.01)\n              node [above left] {(011)};\n        \\draw [fill] (0, 0) -- (-1/3, {-1/sqrt(3)}) circle (0.01)\n              node [below left] {(001)};\n        \\draw [fill] (0, 0) -- (1/3, {-1/sqrt(3)}) circle (0.01)\n              node [below right] {(101)};\n\n        \\draw [fill] (0, 0) circle (0.01)\n              node [below left] {(000)} node [below right] {(111)};\n\n        \\path (0, 0) -- ({0.25 * cos(30)}, {0.25 * sin(30)}) node {I};\n        \\path (0, 0) -- ({0.25 * cos(90)}, {0.25 * sin(90)}) node {II};\n        \\path (0, 0) -- ({0.25 * cos(150)}, {0.25 * sin(150)}) node {III};\n        \\path (0, 0) -- ({0.25 * cos(210)}, {0.25 * sin(210)}) node {IV};\n        \\path (0, 0) -- ({0.25 * cos(270)}, {0.25 * sin(270)}) node {V};\n        \\path (0, 0) -- ({0.25 * cos(330)}, {0.25 * sin(330)}) node {VI};\n\n        % Draw PWM vector.\n        \\draw [arrows={-latex}] (0, 0) -- ({0.5 * cos(20)}, {0.5 * sin(20)});\n        \\draw [dashed] ({0.5 * sin(20) * tan(30)}, {0.5 * sin(20)}) --\n                       ({0.5 * cos(20)}, {0.5 * sin(20)}) node [midway, above] {$t_1$};\n        \\draw [dashed] ({0.5 * (cos(20) - sin(20) * tan(30))}, 0) --\n                       ({0.5 * cos(20)}, {0.5 * sin(20)}) node [midway, right] {$t_2$};\n\n      \\end{scope}\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{\\label{fig:svpwm}Space vector pulse width modulation.  The\n    six corners of the hexagon represent six of the on-off states of\n    the three switches on one side of the H-bridge.}\n\\end{figure}\n\n\n\\section{Motor limits}\n\n\\subsection{Source power limit}\n\nThe total shaft power of the motors is limited by the maximum ground\npower as well as the efficiency losses from the tether, inverters, and\nmotors.  This constraint is expressed as:\n%\n\\begin{equation}\n  \\sum_i P_{\\shaft, i} < \\eta_{\\kiteshaft}\n  \\left( 1 - \\frac{P_{\\ground} R_{\\tether}}{V_{\\ground}^2} \\right) P_{\\ground}\n\\end{equation}\n\n\\begin{table}\n  \\begin{tabular}{llll}\n    \\hline\n    \\hline\n    Parameter & Symbol & Value & Units \\\\\n    \\hline\n    Kite-bus-to-shaft efficiency    & $\\eta_{\\kiteshaft}$ & 0.88 & \\# \\\\\n    Ground power (SatCon I)         & $P_{\\ground}$       & 660  & kW \\\\\n    Ground power (SatCon II)        & $P_{\\ground}$       & 1000 & kW \\\\\n    Tether resistance               & $R_{\\tether}$       & 0.8  & $\\Omega$ \\\\\n    Ground voltage                  & $V_{\\ground}$       & 3400 & V \\\\\n    Phase current limit             & $i_{dq,\\max}$       & 225  & A \\\\\n    Flux weakening modulation limit & $m_{\\mathrm{fw}}$   & 0.95 & \\# \\\\\n    Gate hold time modulation limit & $m_{\\mathrm{gate}}$ & 0.94 & \\# \\\\\n    \\hline\n    \\hline\n  \\end{tabular}\n  \\caption{Power source and motor limitation parameters\\protect\\footnotemark.}\n\\end{table}\n\n\\footnotetext{See {\\texttt{config/m600/power\\_sys.py}}}\n\n\\subsection{Phase current limit}\n\nThe motor controllers enforce a phase current magnitude limit to\ncontrol the maximum temperature that the SiC modules can reach\\footnote{See\n       {\\texttt{go/makanimotorthermallimits}}}.\n%\n\\begin{equation}\n  i_d^2 + i_q^2 < i_{dq,\\max}^2\n\\end{equation}\n%\nThis is the dashed line shown in Fig. \\ref{fig:voltage_limit}.  Before\nflux weakening was implemented, this constraint was called a ``torque\nlimit'' as $\\tau \\propto i_q$.  However, with flux weakening and\nconsequently non-zero $i_d$ values, it is more accurately refered to\nas a phase current limit.  Currently, $i_{dq,\\max} = 225$\nA\\footnote{See\n  {\\texttt{config/m600/power\\_sys\\_sim.py}} and \\\\\n  {\\texttt{avionics/motor/firmware/foc.c}}}; though it\ncould potentially be raised in the future.\n\n\\subsection{Motor power limit}\n\nThe maximum power the motor can deliver occurs when the current\ncommand is at the top of the voltage limit circle.  Here, even as the\nmotor speed increases and the voltage-limit circle shrinks, the power\nremains constant because the radius of the circle is inversely\nproportional to the motor speed.  An approximate equation for the\nmaximum power is\n%\n\\begin{equation}\n  P_{\\max} \\approx \\frac{3}{2} \\frac{\\lambda_m}{L_q} m \\frac{v_{\\bus}}{\\sqrt{3}}\n\\end{equation}\n%\nwhere $m$ is the maximum modulation index, including the gate hold\ntimes.  Currently, $m = 0.95 \\times 0.94$ where the first term is the\nmaximum modulation allowed by flux weakening and the second term is\nthe maximum duty cycle allowed by the gate hold times.\n\nBecause parameters such as $\\lambda_m$ change significantly at high\ntorques, it is better to measure the maximum power empirically.  The\nmaximum motor shaft power was measured to be\n$P_{\\shaft,\\max} \\approx 108$ kW.\n\nA more exact equation for the maximum power is\n%\n\\begin{equation}\n  P_{\\max} =\n  \\frac{3}{2} \\lambda_m \\omega_e\n  \\left(\n    \\frac{m \\cdot v_{\\bus} / \\sqrt{3}}{\\sqrt{R_s^2 + \\omega_e^2 L_q^2}} -\n    \\frac{R_s \\omega_e \\lambda_m}{R_s^2 + \\omega_e^2 L_d L_q}\n  \\right)\n\\end{equation}\n\n\\section{Base speed}\n\nThe constant torque section of the speed-power curve ends when the\nvoltage limit circle intersects the $i_q$ axis at the maximum phase\ncurrent.\n%\n\\begin{equation}\n  \\omega_{m, r_1} = \\frac{v_{\\max}}{p L \\sqrt{i_{\\max}^2 + i_{d,sc}^2}}\n\\end{equation}\n%\nThe constant power section of the speed-power curve begins when the\ntop of the voltage limit circle intersects the maximum phase current\nlimit circle.\n%\n\\begin{equation}\n  \\omega_{m, r_2} = \\frac{v_{\\max}}{p L \\sqrt{i_{\\max}^2 - i_{d,sc}^2}}\n\\end{equation}\n\n\\begin{thebibliography}{1}\n\\bibitem{broek} H. Broeck et. al. ``Analysis and realization of a\n  pulsewidth modulator based on space vectors.'' IEEE\n  Trans. Industry. App., \\textbf{24}, 1 (1988).\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "e403b9cfe012ad7f659c0788c0f50d52f9cd2fdc", "size": 21005, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/control/system/motors.tex", "max_stars_repo_name": "leozz37/makani", "max_stars_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1178, "max_stars_repo_stars_event_min_datetime": "2020-09-10T17:15:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:59:35.000Z", "max_issues_repo_path": "documentation/control/system/motors.tex", "max_issues_repo_name": "leozz37/makani", "max_issues_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-22T05:22:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-22T05:22:35.000Z", "max_forks_repo_path": "documentation/control/system/motors.tex", "max_forks_repo_name": "leozz37/makani", "max_forks_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 107, "max_forks_repo_forks_event_min_datetime": "2020-09-10T17:29:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T09:00:14.000Z", "avg_line_length": 34.6617161716, "max_line_length": 99, "alphanum_fraction": 0.5813377767, "num_tokens": 7087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4415095479531115}}
{"text": "\\longsection{%\n  \\texorpdfstring{%\n    Hierarchization on Spatially Adaptive Sparse Grids\\\\\n    with the Unidirectional Principle%\n  }{%\n    Hierarchization on Spatially Adaptive Sparse Grids\n    with the Unidirectional Principle%\n  }%\n}{%\n  Hierarchization on Spatially Adaptive Sparse Grids\n  with the Unidirectional Principle%\n}{%\n  Hierarchization with the Unidirectional Principle%\n}\n\\label{sec:45spatAdaptiveUP}\n\n\\minitoc{90mm}{9}\n\n\\noindent\nIn this final section of the chapter,\nwe further decrease the computational complexity\nfor the application of the linear operator $\\linop$\non spatially adaptive sparse grids\nfrom quadratic to linear time with two algorithms based on the \\up.\n\n\n\n\\subsection{%\n  Iteratively Applying the Unidirectional Principle with Iterative Refinement%\n}\n\\label{sec:451iterativeRefinement}\n\nThe first algorithm can be applied if two requirements are met:\n\\begin{itemize}\n  \\item\n  The inverse $\\linop^{-1}$ is known and can be efficiently applied.\n  \n  \\item\n  There is an operator $\\linop'$\n  that is ``sufficiently close'' to $\\linop$ and can be efficiently applied.\n\\end{itemize}\nFor hierarchization with B-splines on sparse grids,\nwe choose $\\linop$ to be the hierarchization\noperator given in \\cref{eq:hierarchizationSLE} and\n$\\linop'$ to be the \\up directly applied on the\nsparse grid.\nBoth of the assumptions are then satisfied,\nas $\\linop^{-1}$ is known\n(interpolation matrix $\\intpmat$ of basis function evaluations)\nand $\\linop^{-1}$ and $\\linop'$ can be applied fast.\nThe \\up $\\linop'$ generally produces wrong\nresults for hierarchical B-splines due to missing coupling points.\nHowever, especially for low B-spline degrees,\n$\\linop'$ does not deviate too much from the true operator $\\linop$.\nBelow, we will specify a sufficient criterion for the ``closeness.''\n\n\\paragraph{Iterative refinement}\n\nUnder the two assumptions above, we can apply the procedure given in\n\\cref{alg:iterativeRefinement}.\nThe algorithm is equivalent to the well-known method of\n\\term{iterative refinement,} which has been developed to\nstabilize the numerical solution of a linear system\ninfluenced by rounding errors \\cite{Higham02Accuracy}.\nThe operator $\\linop'$ acts like a preconditioner,\nwhich is why it is required to be close to $\\linop$.\nNote that the algorithm is similar to the repeated application\nof the method of residual interpolation\n(see \\cref{sec:433residualInterpolation}) on the whole sparse grid.\n\n\\begin{algorithm}\n  \\begin{algorithmic}[1]\n    \\Function{$\\vlinout = \\texttt{iterativeRefinement}$}{%\n      $\\vlinin$, $\\vlinout[(0)]$%\n    }\n      \\State{$\\*r^{(0)} \\gets \\vlinin - \\linop^{-1}\\vlinout[(0)]$}\n      \\Comment{initial residual}%\n      \\For{$m = 0, 1, 2, \\dotsc$}\n        \\State{$\\vlinout[(m+1)] \\gets \\vlinout[(m)] + \\linop' \\*r^{(m)}$}\n        \\Comment{update solution}%\n        \\State{$\\*r^{(m+1)} \\gets \\*r^{(m)} - \\linop^{-1} \\linop' \\*r^{(m)}$}\n        \\Comment{update residual}%\n      \\EndFor{}\n      \\vspace{-1mm}\n      \\State{$\\vlinout \\gets \\text{last computed } \\vlinout[(m)]$}\n    \\EndFunction{}\n  \\end{algorithmic}\n  \\caption[%\n    Iterative refinement%\n  ]{%\n    Application of a tensor product operator $\\linop$\n    on spatially adaptive sparse grids with iterative refinement,\n    where $\\linop'$ is an approximation of $\\linop$.\n    Inputs are the vector $\\vlinin = (\\linin{\\*l,\\*i})_{(\\*l,\\*i) \\in \\liset}$\n    of input data (function values $\\fcnval{\\*l,\\*i}$ at the grid points) and\n    an initial solution $\\vlinout[(0)]$.\n    The output is the vector\n    $\\vlinout = (\\linout{\\*l,\\*i})_{(\\*l,\\*i) \\in \\liset}$\n    of output data (hierarchical surpluses $\\surplus{\\*l,\\*i}$).%\n  }%\n  \\label{alg:iterativeRefinement}%\n\\end{algorithm}\n\nThe loop in \\cref{alg:iterativeRefinement} has to be terminated\nafter some iterations.\nThe following simple lemma allows to use a stopping criterion based on the\nsize of the residual $\\*r^{(m)}$ to the true solution,\nwhich we denote with $\\vlinout[\\ast] \\ceq \\linop \\vlinin$.\n\n\\begin{shortlemma}[equivalent convergence for iterative refinement]\n  \\label{lemma:iterativeRefinementEquivalent}\n  In \\cref{alg:iterativeRefinement}, we have\n  $\\vlinout[(m)] \\to \\vlinout[\\ast] \\iff \\*r^{(m)} \\to \\*0$ for\n  $m \\to \\infty$.\n\\end{shortlemma}\n\n\\vspace{-0.5em}\n\n\\begin{proof}\n  It suffices to prove $\\linop \\*r^{(m)} = \\vlinout[\\ast] - \\vlinout[(m)]$\n  for $m \\in \\nat$ by induction.\n  For $m = 0$, we have\n  $\\linop \\*r^{(0)}\n  = \\linop \\vlinin - \\linop \\linop^{-1} \\vlinout[(0)]\n  = \\vlinout[\\ast] - \\vlinout[(0)]$.\n  For $m \\to m+1$, it holds\n  $\\linop \\*r^{(m+1)}\n  = \\linop \\*r^{(m)} - \\linop \\linop^{-1} \\linop' \\*r^{(m)}\n  = (\\vlinout[\\ast] - \\vlinout[(m)]) - \\linop' \\*r^{(m)}\n  = \\vlinout[\\ast] - \\vlinout[(m+1)]$.\n\\end{proof}\n\n\\vspace{0.5em}\n\n\\noindent\nNext, we give a sufficient condition for the\nconvergence of \\cref{alg:iterativeRefinement} to the true solution.\n\n\\vspace{0.5em}\n\n\\begin{proposition}[%\n  sufficient condition for the convergence of\n  {\\hyperref[alg:iterativeRefinement]{Alg.\\ \\ref*{alg:iterativeRefinement}}}%\n]\n  \\label{prop:iterativeRefinementSufficient}\n  If we have $\\limsup_{m \\to \\infty}\n  \\sqrt[m]{\\norm{(\\idop - \\linop^{-1} \\linop')^m}} < 1$\n  with an arbitrary operator matrix norm $\\norm{\\cdot}$ and the\n  identity operator $\\idop$,\n  then $\\vlinout[(m)] \\to \\vlinout[\\ast]$ for $m \\to \\infty$\n  in \\cref{alg:iterativeRefinement}\n  for every initial solution $\\vlinout[(0)]$.\n\\end{proposition}\n\n\\vspace{-0.5em}\n\n\\begin{proof}\n  A short proof by induction shows that\n  \\begin{equation}\n    \\label{eq:proofPropIterativeRefinementSufficient}\n    \\vlinout[(m)]\n    = \\vlinout[(0)] + \\linop'\n    \\sum_{m'=0}^{m-1} (\\idop - \\linop^{-1} \\linop')^{m'} \\*r^{(0)},\n  \\end{equation}\n  where $(\\idop - \\linop^{-1} \\linop')^{m'} \\*r^{(0)} = \\*r^{(m')}$.\n  For $m \\to \\infty$ and with the assumption on\n  $\\norm{(\\idop - \\linop^{-1} \\linop')^m}$,\n  the sum converges to the Neumann series\n  $\\sum_{m'=0}^\\infty (\\idop - \\linop^{-1} \\linop')^{m'}\n  = (\\idop - (\\idop - \\linop^{-1} \\linop'))^{-1} = (\\linop')^{-1} \\linop$\n  (see, e.g., \\cite{Werner11Funktionalanalysis}).\n  In this case, we infer that the limit of $\\vlinout[(m)]$ is given by\n  \\begin{equation}\n    \\vlinout[(0)] + \\linop' (\\linop')^{-1} \\linop \\*r^{(0)}\n    = \\vlinout[(0)] + \\linop \\vlinin - \\linop \\linop^{-1} \\vlinout[(0)]\n    = \\linop \\vlinin\n    = \\vlinout[\\ast],\n  \\end{equation}\n  as claimed.\n\\end{proof}\n\nThe sufficient condition given in \\cref{prop:iterativeRefinementSufficient}\nis quite strong, as it can be shown that $\\limsup_{m \\to \\infty}\n\\sqrt[m]{\\norm{(\\idop - \\linop^{-1} \\linop')^m}} \\le 1$ is necessary for\nconvergence.\nUnfortunately, in the case of hierarchization with B-splines,\nnumerical experiments show that\nthis condition is only met for low dimensionalities $d$ and low\nB-spline degrees $p$.\n\\Cref{alg:iterativeRefinement} generally diverges\nfor higher dimensionalities or higher degrees.\n\n\n\n\\subsection{Duality of the Unidirectional Principle}\n\\label{sec:452duality}\n\nTo motivate the second algorithm that we present in this section,\nwe study why we cannot directly apply the \\up\n(as introduced in \\cref{alg:unidirectionalPrinciple})\non spatially adaptive sparse grids.\nAs before, we denote with $\\liset$ the level-index set of\nthe spatially adaptive sparse grid (see \\cref{sec:41problem}).\n\nThe \\up\\punctfix{,} as stated in\n\\cref{alg:unidirectionalPrinciple} for full grids,\nsubsequently applies one-dimensional operators\n$\\upopuv{t_j}{\\lisetpole}\\colon \\real^{\\setsize{\\lisetpole}} \\to\n\\real^{\\setsize{\\lisetpole}}$\non the poles $\\lisetpole$ of the sparse grid at hand,\niterating over a permutation $t_1, \\dotsc, t_d$\nof the dimensions $1, \\dotsc, d$.\nWe recall the pole equivalence relation $\\samepole{t_j}$\nfrom \\cref{eq:poleEquivalenceRelation}:\nTwo points $\\*k', \\*k'' \\in \\liset$ are $\\samepole{t_j}$-equivalent,\nif $\\*k'$ is contained in the pole through $\\*k''$\nwith respect to the $t_j$-th dimension, i.e.,\n\\begin{equation}\n  \\*k' \\samepole{t_j} \\*k'' \\iff \\*k'_{-t_j} = \\*k''_{-t_j},\\quad\n  \\*k', \\*k'' \\in \\liset.\n\\end{equation}\n\n\\paragraph{Operators for the unidirectional principle}\n\nThe combined application of all one-di\\-men\\-sional operators\n$\\upopuv{t_j}{\\lisetpole}$\n($\\lisetpole \\in \\eqclasses{\\liset}{\\samepole{t_j}}$)\nof the $j$-th iteration of \\cref{alg:unidirectionalPrinciple}\nis equivalent to a single application of the following operator\n$\\upop{t_j}\\colon \\real^{\\setsize{\\liset}} \\to \\real^{\\setsize{\\liset}}$:\n\\begin{equation}\n  \\label{eq:upopEntries}\n  (\\upop{t_j})_{\\*k'',\\*k'}\n  \\ceq\n  \\begin{cases}\n    (\\upopuv{t_j}{\\lisetpole})_{k''_{t_j},k'_{t_j}},&\n    \\ex{\\lisetpole \\in \\eqclasses{\\liset}{\\samepole{t_j}}}{\n      \\*k', \\*k'' \\in \\lisetpole\n    },\\\\\n    0,&\\*k' \\not\\samepole{t_j} \\*k'',\n  \\end{cases}\n\\end{equation}\nwhere $(\\upop{t_j})_{\\*k'',\\*k'}$ denotes the entry of row $\\*k''$\nand column $\\*k'$ of the matrix corresponding to $\\upop{t_j}$\n(similar for $(\\upopuv{t_j}{\\lisetpole})_{k''_{t_j},k'_{t_j}}$).\nThe reason for this equivalence is that\nthe poles $\\lisetpole$ are pairwise disjoint equivalence classes.\nConsequently, every point $\\*k$ is only acted upon by a single\none-dimensional operator $\\upopuv{t_j}{\\lisetpole}$,\nnamely the one with $\\lisetpole = \\eqclass{\\*k}{\\samepole{t_j}}$.\nThis leads to the block-diagonal structure\nof $\\upop{t_j}$ given in \\eqref{eq:upopEntries},\nif the rows of the matrix of $\\upop{t_j}$\nare grouped by poles $\\lisetpole$ and the columns are arranged accordingly.\n\n\\paragraph{Correctness and duality of the unidirectional principle}\n\nFor the remaining considerations, we assume that\nthe operators $\\linop$ and $\\upopuv{t_j}{\\lisetpole}$ are invertible.\nIn this case, $\\upop{t_j}$ is also invertible and\n$\\upopinv{t_j}$ is given by the block-diagonal matrix composed of\nthe inverses of the blocks $\\upopuv{t_j}{\\lisetpole}$ of $\\upop{t_j}$.\nThis is satisfied by dehierarchization operators $\\intpmat$ due to the\nlinear independence of the hierarchical basis functions.\n\nWe are now able to describe the whole \\up of\n\\cref{alg:unidirectionalPrinciple} as the operator\n$\\upop{t_1,\\dotsc,t_d}\\colon \\real^{\\setsize{\\liset}} \\to\n\\real^{\\setsize{\\liset}}$ given by\n\\begin{equation}\n  \\label{eq:upopProduct}\n  \\upop{t_1,\\dotsc,t_d}\n  \\ceq \\upop{t_d} \\dotsm \\upop{t_1}.\n\\end{equation}\nThe right-most operator is $\\upop{t_1}$, since it is applied first.\nWe say that the \\up is \\term{correct} for $\\linop$ and\n$(t_1, \\dotsc, t_d)$, if\n\\begin{equation}\n  \\upop{t_1,\\dotsc,t_d}\n  \\overset{?}{=} \\linop.\n\\end{equation}\nThis relation is not satisfied in general,\nespecially for B-spline hierarchization with the operator\n$\\linop = \\intpmatinv$.\nHowever, for operators like these, whose inverse\n$\\linopinv = \\intpmat$ can be described and applied much easier,\nwe can make use of the so-called \\term{duality of the \\up:}\n\n\\begin{lemma}[duality of the unidirectional principle]\n  \\label{lemma:dualityUnidirectionalPrinciple}\n  Let the operators $\\linop$ and $\\upopuv{t_j}{\\lisetpole}$ be invertible\n  for all poles $\\lisetpole$ in $\\liset$.\n  Then the \\up is correct for $\\linop$ and $(t_1, \\dotsc, t_d)$\n  if and only if the \\up is correct for $\\linopinv$ and $(t_d, \\dotsc, t_1)$.\n\\end{lemma}\n\n\\begin{proof}\n  The correctness of the \\up for $\\linop$ and $(t_1, \\dotsc, t_d)$\n  is by definition equivalent to\n  \\begin{equation}\n    \\upop{t_d} \\dotsm \\upop{t_1} = \\linop.\n  \\end{equation}\n  By inverting both sides, we obtain the definition of the\n  correctness of the \\up for $\\linopinv$ and $(t_d, \\dotsc, t_1)$.\n\\end{proof}\n\nThis duality means that in order to establish the correctness of $\\linop$\nfor some arbitrary permutation $(t_1, \\dotsc, t_d)$ of $1, \\dotsc, d$,\nit suffices to establish the \\up's correctness for the\ninverse operator $\\linopinv$ and the reverse permutation $(t_d, \\dotsc, t_1)$.\nThis is especially of interest for our main application,\nthe hierarchization operator $\\linop = \\intpmatinv$ for B-splines.\n\n\n\n\\subsection{Chains and Equivalent Correctness Conditions}\n\\label{sec:453chains}\n\nWe first define the notion of a chain between two grid points\n$\\*k'$ and $\\*k''$.\n\n\\begin{definition}[chain]\n  \\label{def:chain}\n  Let $\\*k', \\*k'' \\in \\liset$ and\n  $(t_1, \\dotsc, t_j)$ be a permutation of $j$ of the\n  dimensions $1, \\dotsc, d$.\n  We define the \\term{chain} from $\\*k'$ to $\\*k''$ with respect to\n  $(t_1, \\dotsc, t_j)$ as the sequence\n  $(\\chain{0}, \\dotsc, \\chain{j})$, where\n  \\begin{equation}\n    \\chain{j'}_{T_{j'}}\n    \\ceq \\*k''_{T_{j'}},\\quad\n    \\chain{j'}_{-T_{j'}}\n    \\ceq \\*k'_{-T_{j'}},\\quad\n    T_{j'}\n    \\ceq (t_1, \\dotsc, t_{j'}),\\quad\n    j' = 0, \\dotsc, j,\n    \\hspace*{-10mm}\n  \\end{equation}\n  if $\\chain{j} = \\*k''$ and\n  $\\chain{j'} \\in \\liset$ for all $j' = 0, \\dotsc, j$.\n\\end{definition}\n\nThis definition is equivalent to\n$\\chain{j'-1} \\samepole{t_{j'}} \\chain{j'}$ for $j' = 1, \\dotsc, j$.\n\\Cref{fig:chainDefinition} shows examples of chains in\ntwo and three dimensions.\nAs it is shown in \\cref{fig:chainDefinition2},\nthe order $(t_1, \\dotsc, t_j)$ of the dimensions is important\nfor whether the grid contains the chain from $\\*k'$ to $\\*k''$.\nThe grid must contain all intermediate points, otherwise\nit is not a chain.\n\n\\begin{figure}\n  \\subcaptionbox{%\n    $d = 2$, $(t_1, t_2) = (2, 1)$%\n  }[47mm]{%\n    \\includegraphics{chainDefinition_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $d = 2$, $(t_1, t_2) = (1, 2)$%\n    \\label{fig:chainDefinition2}%\n  }[47mm]{%\n    \\includegraphics{chainDefinition_2}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $d = 3$, $(t_1, t_2, t_3) = (2, 3, 1)$%\n  }[50mm]{%\n    \\includegraphics{chainDefinition_3}%\n  }%\n  \\caption[%\n    Examples for the definition of chains%\n  ]{%\n    Examples for chains in two and three dimensions.\n    \\emph{Left:} A chain from $\\chain{0}$ to $\\chain{2}$\n    with respect to $(t_1, t_2) = (2, 1)$ in a two-dimensional sparse grid.\n    \\emph{Center:}\n    With respect to the reverse permutation\n    $(t_1, t_2) = (1, 2)$ of the dimensions,\n    there is no chain from $\\chain{0}$ to $\\chain{2}$,\n    because the corresponding chain point $\\chain{1}$ is missing in the grid.\n    \\emph{Right:} A chain in three dimensions.%\n  }%\n  \\label{fig:chainDefinition}%\n\\end{figure}\n\nWe now show two lemmas.\nFirst, we prove that $(\\upop{t_1,\\dotsc,t_j})_{\\*k'',\\*k'} \\not= 0$\nis sufficient for the existence of a chain from $\\*k'$ to $\\*k''$:\n\n\\begin{restatable}[sufficient condition for chain existence]{%\n  lemma%\n}{%\n  lemmaChainExistenceSufficient%\n}\n  \\label{lemma:chainExistenceSufficient}\n  If $(\\upop{t_1,\\dotsc,t_j})_{\\*k'',\\*k'} \\not= 0$\n  for some $j = 0, \\dotsc, d$,\n  then the grid $\\liset$ contains the chain from $\\*k'$ to $\\*k''$\n  with respect to $(t_1, \\dotsc, t_j)$.\n\\end{restatable}\n\n\\vspace{-0.5em}\n\n\\begin{proof}\n  See \\cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.\n\\end{proof}\n\n\\vspace{0.5em}\n\nSecond, we show that the equality of\n$(\\upop{t_1,\\dotsc,t_j})_{\\chain{j},\\*k'}$ and the product of\nthe one-dimensional operators is necessary for the\nexistence of a chain from $\\*k'$ to $\\*k''$:\n\n\\begin{restatable}[necessary condition for chain existence]{%\n  lemma%\n}{%\n  lemmaChainExistenceNecessary%\n}\n  \\label{lemma:chainExistenceNecessary}\n  If the grid $\\liset$ contains the chain $(\\chain{0}, \\dotsc, \\chain{j})$\n  from $\\*k'$ to $\\*k''$ with respect to $(t_1, \\dotsc, t_j)$\n  for some $j = 0, \\dotsc, d$, then\n  \\begin{equation}\n    \\label{eq:lemmaChainExistenceNecessary}\n    (\\upop{t_1,\\dotsc,t_j})_{\\chain{j},\\*k'}\n    = (\\upopuv{t_1}{\\eqclass{\\chain{1}}{\\samepole{t_1}}})_{k''_{t_1},k'_{t_1}}\n    \\dotsm\n    (\\upopuv{t_j}{\\eqclass{\\chain{j}}{\\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}.\n  \\end{equation}\n\\end{restatable}\n\n\\vspace{-0.5em}\n\n\\begin{proof}\n  See \\cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.\n\\end{proof}\n\n\\vspace{0.5em}\n\nThese two lemmas can be used to prove the following characterization\nof the correctness of the \\up\\punctfix{.}\nHere, we need an additional assumption on the structure of the\noperator $\\linop$, which we call \\term{tensor product structure:}\n\n\\begin{restatable}[characterization of the correctness of the UP]{%\n  proposition%\n}{%\n  propCorrectnessUPCharacterization%\n}\n  \\label{prop:correctnessUPCharacterization}\n  Let $\\linop$ have tensor product structure:\n  For all $\\*k', \\*k'' \\in \\liset$ with the chain\n  $(\\chain{0}, \\dotsc, \\chain{d})$ from $\\*k'$ to $\\*k''$\n  with respect to $(t_1, \\dotsc, t_d)$,\n  we assume that\n  \\begin{equation}\n    \\label{eq:tensorProductOperator}\n    (\\linop)_{\\*k'',\\*k'}\n    = \\prod_{j=1}^d\n    (\\upopuv{t_j}{\\eqclass{\\chain{j}}{\\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}.\n  \\end{equation}\n  Then the \\up is correct for $\\linop$ and $(t_1, \\dotsc, t_d)$\n  if and only if the grid $\\liset$ contains the chain from $\\*k'$ to $\\*k''$\n  with respect to $(t_1, \\dotsc, t_d)$ for all $\\*k', \\*k'' \\in \\liset$\n  for which $(\\linop)_{\\*k'',\\*k'} \\not= 0$.\n\\end{restatable}\n\n\\vspace{-0.5em}\n\n\\begin{proof}\n  See \\cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.\n\\end{proof}\n\n\\vspace{0.5em}\n\nWhen applied to the hierarchization operator,\nthe combination of \\cref{prop:correctnessUPCharacterization} with\n\\thmref{lemma:dualityUnidirectionalPrinciple} can be summarized in\nthe following corollary:\n\n\\begin{corollary}[%\n  equivalent statements for correctness of UP for hierarchization%\n]\n  \\label{cor:equivalentCorrectnessUPHierarchization}\n  The following statements are equivalent:\n  \\begin{itemize}\n    \\item\n    The \\up is correct for $\\intpmatinv$ and $(t_1, \\dotsc, t_d)$.\n    \n    \\item\n    The \\up is correct for $\\intpmat$ and $(t_d, \\dotsc, t_1)$.\n    \n    \\item\n    The grid $\\liset$ contains the chain from $\\*k'$ to $\\*k''$\n    with respect to $(t_d, \\dotsc, t_1)$ for all $\\*k', \\*k'' \\in \\liset$\n    for which $\\basis{\\*k'}(\\gp{\\*k''}) \\not= 0$.\n  \\end{itemize}\n\\end{corollary}\n\n\\begin{proof}\n  The corollary is a direct consequence of\n  \\cref{lemma:dualityUnidirectionalPrinciple} and\n  \\cref{prop:correctnessUPCharacterization},\n  applied to the dehierarchization operator $\\linop = \\intpmat$.\n  \n  The assumption of \\cref{lemma:dualityUnidirectionalPrinciple}\n  is satisfied:\n  The operators $\\upopuv{t_j}{\\lisetpole}$ are invertible\n  for all poles $\\lisetpole$ in $\\liset$\n  due to the uniqueness of univariate interpolants\n  (linear independence of the basis functions).\n  Similarly, $\\linop$ is invertible\n  due to the uniqueness of multivariate interpolants.\n  In addition, the assumption of \\cref{prop:correctnessUPCharacterization}\n  is satisfied, since\n  \\begin{equation}\n    (\\linop)_{\\*k'',\\*k'}\n    = (\\intpmat)_{\\*k'',\\*k'}\n    = \\prod_{j=1}^d \\basis{k'_{t_j}}(\\gp{k''_{t_j}})\n    = \\prod_{j=1}^d\n    (\\upopuv{t_j}{\\eqclass{\\chain{j}}{\\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}\n  \\end{equation}\n  due to the tensor product basis functions.\n\\end{proof}\n\n\\paragraph{Inserting chain points}\n\nThis means that we can establish the correctness of the \\up\nfor the hierarchization operator $\\linop = \\intpmatinv$,\nif we insert all missing chain points that are specified by\n\\cref{prop:correctnessUPCharacterization} into the grid.\n\nWe take the case $p = 1$ of piecewise linear\nstandard B-splines $\\bspl{\\*l,\\*i}{1}$ as an example.\nWe assume that we iteratively generated a spatially adaptive sparse grid\nsuch that all grid points are reachable from the corners of $\\clint{\\*0, \\*1}$\nin the sense of \\cref{eq:bfsAssumption2}.\nIf we want to ensure the correctness of the \\up for all possible permutations\n$(t_1, \\dotsc, t_d)$ of the dimensions $(1, \\dotsc, d)$,\nthen the existence of the necessary chains in\n\\cref{cor:equivalentCorrectnessUPHierarchization} is equivalent to the\nrequirement that the grid should contain\nthe hierarchical ancestors of every grid point in every direction:\n\\begin{subequations}\n  \\begin{alignat}{4}\n    \\fafa{(\\*l',\\*i') \\in \\liset}{\\{t = 1, \\dotsc, d \\mid l'_t > 1\\}}{\n      (\\*l,\\*i) \\in \\liset\n    },\\quad\n    &&&\\*l \\ceq \\*l' - \\stdbasis{t},\\quad\n    &&i_t \\ceq 2 \\floor{\\tfrac{i'_t}{4}} + 1,\\quad\n    &&\\*i_{-t} = \\*i'_{-t},\\\\\n    \\fafa{(\\*l',\\*i') \\in \\liset}{\\{t = 1, \\dotsc, d \\mid l'_t = 1\\}}{\n      (\\*l,\\*i) \\in \\liset\n    },\\quad\n    &&&\\*l \\ceq \\*l' - \\stdbasis{t},\\quad\n    &&i_t \\ceq 0,\\quad\n    &&\\*i_{-t} = \\*i'_{-t},\n  \\end{alignat}\n\\end{subequations}\nwhere $\\stdbasis{t}$ is the $t$-th standard basis vector.\nThis is a standard assumption on spatially adaptive sparse grids with\npiecewise linear basis functions \\cite{Pflueger10Spatially}.\nHowever, we only have to satisfy the conditions of\n\\cref{cor:equivalentCorrectnessUPHierarchization} for a single permutation\n$(t_1, \\dotsc, t_d)$ of the dimensions\nin order to hierarchize with the \\up\\punctfix{.}\n\\Cref{fig:chainInsertionBSpline} shows the necessary ancestor chain points\n(colored points in \\cref{fig:chainInsertionBSpline2})\nfor an example of a two-dimensional spatially adaptive sparse grid\n(\\cref{fig:chainInsertionBSpline1}).\n\n\\begin{figure}\n  \\subcaptionbox{%\n    Original grid ($N = 85$)%\n    \\label{fig:chainInsertionBSpline1}%\n  }[48mm]{%\n    \\includegraphics{chainInsertion_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    Chain points for $p = 1$\\\\\n    \\rlap{\\hspace*{10.5mm}($N = 121$)}%\n    \\label{fig:chainInsertionBSpline2}%\n  }[48mm]{%\n    \\includegraphics{chainInsertion_2}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    Chain points for $p = 3$\\\\\n    \\rlap{\\hspace*{10.5mm}($N = 289 = 17 \\times 17$)}%\n    \\label{fig:chainInsertionBSpline3}%\n  }[48mm]{%\n    \\includegraphics{chainInsertion_3}%\n  }%\n  \\caption[%\n    Chain points for hierarchical B-splines on a sparse grid%\n  ]{%\n    Necessary chain points for the correctness of the unidirectional principle\n    with respect to $(t_1, t_2) = (1, 2)$\n    for hierarchical B-splines $\\bspl{l,i}{p}$ on a\n    two-dimensional spatially adaptive sparse grid.\n    The colors indicate the recursion depth in which the\n    chain points have been inserted.\n    Black points are contained in the original grid\n    (``zero-order points'').\n    \\textcolor{C0}{Blue points} are part of chains\n    between original grid points (``first-order chain points'').\n    \\textcolor{C1}{Red points} are second-order chain points,\n    i.e., they are part of chains\n    from $\\*k'$ to $\\*k''$ where $\\*k'$ and $\\*k''$ are\n    original grid points or first-order chain points\n    and at least one of them is a first-order chain point.\n    Analogously,\n    \\textcolor{C2}{brown points} are third-order chain points.\n    $N$ is the number of points in the final grid.%\n  }%\n  \\label{fig:chainInsertionBSpline}%\n\\end{figure}\n\nUnfortunately, we have to insert these points recursively,\ne.g., the inserted points may generate new chains,\nfor which other missing points have to be inserted and so on\n(``higher-order chain points'' in \\cref{fig:chainInsertionBSpline}).\nTherefore, the number of points to be inserted may be large.\nThe worst case is that the final grid is a full grid, i.e.,\nthe Cartesian product of the union of the poles in the different dimensions:\n\\begin{equation}\n  \\paren*{\\bigcup_{\\*k \\in \\liset} \\eqclass{\\*k}{\\samepole{1}}}\n  \\times \\dotsb \\times\n  \\paren*{\\bigcup_{\\*k \\in \\liset} \\eqclass{\\*k}{\\samepole{d}}},\n\\end{equation}\ni.e., we fully lose the advantage of sparse grids,\nwhose purpose is to ease the curse of dimensionality.\nFor the standard hierarchical B-spline basis $\\bspl{l,i}{p}$,\nthis worst case often occurs as there are many non-zero entries\nin the corresponding interpolation matrices $\\intpmat$\n(see \\cref{sec:41problem} and \\cref{fig:chainInsertionBSpline3}).\n\n\n\n\\subsection{Hierarchical Weakly Fundamental Splines}\n\\label{sec:454wfs}\n\n\\paragraph{Motivation}\n\nIn order to reduce the number of chain points to be inserted,\nwe have to use other spline bases such that\nthe resulting interpolation matrices $\\intpmat$ have more zero entries.\nThe hierarchical fundamental splines\nas introduced in \\cref{sec:443fundamentalSplines} are one possibility.\nHowever, they are globally supported, which implies a number\nof disadvantages concerning the algorithms and the implementations.\nThe most significant disadvantage is that although\nwe can use \\bfs for the univariate hierarchization operators,\nthe time complexity for the univariate hierarchization is still quadratic.\nWe search for a locally supported spline basis for which\nthe univariate hierarchization can be done in linear time.\n\nTo meet these goals, we have to relax the fundamental property\nto a weaker version, which results in the so-called\n\\term{weakly fundamental property.}\nA univariate hierarchical basis\n$\\wfundbasis{l',i'}\\colon \\clint{0, 1} \\to \\real$\nis called \\term{weakly fundamental,} if\n\\begin{equation}\n  \\label{eq:weaklyFundamentalProperty}\n  \\wfundbasis{l',i'}(\\gp{l,i}) = 0,\\quad\n  l < l',\\;\\;\n  i \\in \\hiset{l}.\n\\end{equation}\nThis is exactly the first condition \\eqref{eq:fundamentalProperty1}\nof the fundamental property \\eqref{eq:fundamentalProperty}.\nWe drop the requirement that the basis functions\nshould vanish at the other grid points of the same level.\nThe relation \\eqref{eq:fundamentalPropertyImplicationMV} from the\nfundamental case becomes\n\\begin{equation}\n  \\label{eq:weaklyFundamentalPropertyImplicationMV}\n  \\wfundbasis{\\*l',\\*i'}(\\gp{\\*l,\\*i})\n  \\not= 0\n  \\implies\n  \\*l' \\le \\*l,\n\\end{equation}\ni.e., every basis function $\\wfundbasis{\\*l',\\*i'}$\ncan only be non-zero at grid points $\\gp{\\*l,\\*i}$ with\nhigher or equal level $\\*l$.\n\n\\paragraph{Definition of hierarchical weakly fundamental splines}\n\nWe construct the \\term{weakly fundamental spline parent function}\n$\\parentwfundspl{p}\\colon \\real \\to \\real$\nby forming a linear combination of as few neighboring\nuniform B-splines as possible such that $\\parentwfundspl{p}$\nsatisfies the weakly fundamental property\n\\eqref{eq:weaklyFundamentalProperty}:\n\\begin{subequations}\n  \\begin{gather}\n    \\label{eq:weaklyFundamentalSplineParent}\n    \\parentwfundspl{p}(x)\n    \\ceq \\largesum[(p-1)/2]{k=-(p-1)/2}\n    \\wfundsplcoeff{k}{p} \\parentbspl{p}(x - k)\n    \\quad\\text{such that}\\\\\n    \\wfundsplcoeff{0}{p} = 1,\\quad\n    \\parentwfundspl{p}(k') = 0,\\;\\;\n    k' = -p + 2,\\; -p + 4,\\; \\dotsc,\\; p - 2.\n  \\end{gather}\n\\end{subequations}\n\\usenotation{zzzzwfs}\n\\term{Hierarchical weakly fundamental splines}\n$\\bspl[\\wfs]{l,i}{p}\\colon \\clint{0, 1} \\to \\real$\nare now defined canonically via an affine parameter transformation:\n\\begin{equation}\n  \\bspl[\\wfs]{l,i}{p}(x)\n  \\ceq \\parentwfundspl{p}(\\tfrac{x}{\\ms{l}} - i),\\quad\n  l \\ge 1.\n\\end{equation}\nFor $l = 0$, we define $\\bspl[\\wfs]{l,i}{p}$ to be the\nlinear Lagrange polynomial of level zero:%\n\\footnote{%\n  This will simplify the description of the\n  Hermite hierarchization algorithm in \\cref{sec:455hermiteHierarchization}.%\n}\n\\begin{equation}\n  \\bspl[\\wfs]{0,i}{p}\n  \\ceq \\lagrangepoly{0,i},\\quad\n  i = 0, 1.\n\\end{equation}\nThe hierarchical weakly fundamental spline basis is shown in\n\\cref{fig:hierarchicalWeaklyFundamentalSpline}.\nNote that these basis functions are translation-invariant by construction\n(starting with level $l \\ge 1$).\nAs the weakly fundamental parent spline $\\parentwfundspl{p}$\nvanishes at all odd integers and as the\nsupport of $\\bspl[\\wfs]{l,i}{p}$ is local\n($\\supp \\bspl[\\wfs]{l,i}{p}\n= \\clint{\\gp{l,i-p}, \\gp{l,i+p}} \\cap \\clint{0, 1}$),\nthis implies that the weakly fundamental property\n\\eqref{eq:weaklyFundamentalProperty} is fulfilled.\n\n\\begin{SCfigure}\n  \\includegraphics{hierarchicalBasis_17}%\n  \\caption[%\n    Hierarchical weakly fundamental splines%\n  ]{%\n    Hierarchical cubic weakly\n    \\vspace{-0.1em}%\n    fundamental splines\n    $\\bspl[\\wfs]{l',i'}{p}$\n    ($l' \\le l$, $i' \\in \\hiset{l'}$, $p = 3$) and\n    grid points $\\gp{l',i'}$ \\emph{(dots)} up to level $l = 3$.%\n  }%\n  \\label{fig:hierarchicalWeaklyFundamentalSpline}%\n\\end{SCfigure}\n\n\\paragraph{Chain points for weakly fundamental splines}\n\nThe first advantage of the\nweakly fundamental spline basis $\\bspl[\\wfs]{l,i}{p}$\nover standard uniform B-splines $\\bspl{l,i}{p}$ is that\nthe condition $\\basis{\\*k'}(\\gp{\\*k''}) \\not= 0$ in\n\\cref{cor:equivalentCorrectnessUPHierarchization} is\nsatisfied for much fewer $\\*k', \\*k''$.\nConsequently, fewer chain grid points have to be inserted to\nensure the correctness of the \\up for hierarchization.\n\\Cref{fig:chainInsertionWeaklyFundamentalSpline} shows the inserted points\nfor the same grid as in \\cref{fig:chainInsertionBSpline}.\n\n\\begin{SCfigure}\n  \\includegraphics{chainInsertion_4}%\n  \\caption[%\n    Chain points for hierarchical weakly fundamental splines on a\n    sparse grid%\n  ]{%\n    Necessary chain points for the correctness of the unidirectional principle\n    with respect to $(t_1, t_2) = (1, 2)$\n    for hierarchical cubic weakly fundamental splines\n    $\\bspl[\\wfs]{l,i}{p}$ ($p = 3$)\n    on the same two-dimensional spatially adaptive sparse grid\n    as in \\cref{fig:chainInsertionBSpline1}.\n    The colors indicate the recursion depth in which the\n    chain points have been inserted\n    (see caption of \\cref{fig:chainInsertionBSpline}).\n    The number of points in the final grid is $N = 157$.%\n  }%\n  \\label{fig:chainInsertionWeaklyFundamentalSpline}%\n\\end{SCfigure}\n\nIn the special case of regular sparse grids $\\regsgset{n}{d}$,\nwe do not have to insert any grid points for the correctness of the\n\\up\\punctfix{.}\nWe can verify this statement with\n\\thmref{cor:equivalentCorrectnessUPHierarchization}:\nLet $(\\*l',\\*i')$ and $(\\*l'',\\*i'')$ with\n$\\normone{\\*l'}, \\normone{\\*l''} \\le n$ and\n$\\*i' \\in \\hiset{\\*l'}$, $\\*i'' \\in \\hiset{\\*l''}$,\nsuch that $\\bspl[\\wfs]{\\*l',\\*i'}{p}(\\gp{\\*l'',\\*i''}) \\not= 0$.\nFurthermore, let $(\\chain[\\*l]{0}, \\chain[\\*i]{0}), \\dotsc,\n(\\chain[\\*l]{d}, \\chain[\\*i]{d})$ be the chain\nfrom $\\*k'$ to $\\*k''$ with respect to $t_1, \\dotsc, t_d$.\nNote that $\\chain[\\*l]{j} \\le \\vecmax\\{\\*l', \\*l''\\}$ due to the\ndefinition of chain points (\\cref{def:chain}).\nTherefore, we have for $j = 0, \\dotsc, d$\nby \\eqref{eq:weaklyFundamentalPropertyImplicationMV}:\n\\begin{equation}\n\\*l' \\le \\*l''\n\\implies\n\\chain[\\*l]{j} \\le \\vecmax\\{\\*l', \\*l''\\} \\le \\*l''\n\\implies\n\\normone{\\chain[\\*l]{j}} \\le \\normone{\\*l''} \\le n.\n\\end{equation}\nHence, $\\regsgset{n}{d}$ contains the grid points corresponding to\n$(\\chain[\\*l]{j}, \\chain[\\*i]{j})$ for all $j = 0, \\dotsc, d$.\nConsequently, the conditions of\n\\cref{cor:equivalentCorrectnessUPHierarchization} are satisfied without\ninserting any additional chain points.\nThis statement is even valid for arbitrary\ndimensionally adaptive sparse grids.\n\n\n\n\\subsection{Hermite Hierarchization}\n\\label{sec:455hermiteHierarchization}\n\n\\paragraph{Hermite interpolation}\n\nThe second advantage of the weakly fundamental spline basis\nis that due to the reduced coupling,\nthe univariate hierarchization operators can be applied easier\nthan for standard uniform B-splines.\nThis results in the formulation of the so-called\n\\term{Hermite hierarchization} algorithm.\nWe first recall higher-order Hermite interpolation:\n\n\\begin{lemma}[higher-order Hermite interpolation]\n  \\label{lemma:hermiteInterpolation}\n  Let $p \\in \\nat$ be odd and $a, b \\in \\real$ with $a < b$.\n  Furthermore, let\n  $\\deriv[q]{x}{\\objfun}(a) \\in \\real$ and\n  $\\deriv[q]{x}{\\objfun}(b) \\in \\real$ be given data\n  for $q = 0, \\dotsc, \\frac{p-1}{2}$.\n  Then there is a unique polynomial $\\spl \\in \\polyspace{p}$ such that\n  \\begin{equation}\n    \\deriv[q]{x}{\\objfun}(a)\n    = \\deriv[q]{x}{\\spl}(a),\\quad\n    \\deriv[q]{x}{\\objfun}(b)\n    = \\deriv[q]{x}{\\spl}(b),\\quad\n    q = 0, \\dotsc, \\frac{p-1}{2}.\n    \\hspace*{-10mm}\n  \\end{equation}\n\\end{lemma}\n\n\\begin{proof}\n  See \\cite{Freund07Stoer}.\n\\end{proof}\n\n\\paragraph{Hermite hierarchization algorithm}\n\nThe interpolating polynomial $\\spl$ and its derivatives can be\nefficiently evaluated using Hermite basis functions\n(generalized Lagrange polynomials \\cite{Freund07Stoer}).\nWith Hermite interpolation, we formulate\n\\cref{alg:hermiteHierarchization}\nfor the hierarchization with hierarchical weakly fundamental splines.\nWhile we formulate \\cref{alg:hermiteHierarchization}\nonly for regular univariate grids and weakly fundamental splines,\na slightly reformulated version of the algorithm\nalso correctly operates on spatially adaptive univariate grids\n(with the assumption that the grids contain the parents of their grid points)\nand other weakly fundamental bases that are\npiecewise polynomials of degree $\\le p$.\n\n\\begin{algorithm}\n  \\begin{algorithmic}[1]\n    \\Function{$\\vlinout = \\texttt{hermiteHierarchization1D}$}{%\n      $\\vlinin$, $n$%\n    }\n      \\For{$i = 0, 1$}\n      \\Comment{set values for level $0$}%\n        \\State{%\n          $\\linout{0,i} \\gets \\fcnval{0,i}$%\n        }\n        \\label{line:algHermiteHierarchization1}\n        \\State{%\n          $\\deriv[q]{x}{\\fgintp{0}}(\\gp{0,i})\n          \\gets \\kronecker{q}{0} \\cdot \\fcnval{0,i} +\n          \\kronecker{q}{1} \\cdot (\\fcnval{0,1} - \\fcnval{0,0})$\n          for all $q = 0, \\dotsc, \\frac{p-1}{2}$%\n        }\n        \\label{line:algHermiteHierarchization3}\n      \\EndFor{}\n      \\For{$l = 1, \\dotsc, n$}\n        \\For{$i \\in \\hiset{l}$}\n          \\State{%\n            $\\fgintp{l-1}(\\gp{l,i}) \\gets \\text{Hermite interpolation of}$\n            $\\deriv[q]{x}{\\fgintp{l-1}}(\\gp{l,i\\pm1})$\n            ($q = 0, \\dotsc, \\frac{p-1}{2}$)%\n          }\n          \\label{line:algHermiteHierarchization4}\n          \\State{%\n            $r^{(l)}(\\gp{l,i})\n            \\gets \\fcnval{l,i} - \\fgintp{l-1}(\\gp{l,i})$%\n          }\n          \\label{line:algHermiteHierarchization5}\n          \\Comment{residual to be interpolated}%\n        \\EndFor{}\n        \\State{%\n          Let $r^{(l)}_l$ be of the form\n          $\\sum_{i' \\in \\hiset{l}} \\linout{l,i'} \\bspl[\\wfs]{l,i'}{p}$%\n        }\n        \\Comment{contribution of level $l$}%\n        \\label{line:algHermiteHierarchization6}\n        \\State{%\n          Choose $(\\linout{l,i'})_{i' \\in \\hiset{l}}$ such that\n          $r^{(l)}_l(\\gp{l,i}) = r^{(l)}(\\gp{l,i})$ for all $i \\in \\hiset{l}$%\n        }\n        \\label{line:algHermiteHierarchization7}\n        \\For{$i = 0, \\dotsc, 2^l$}\n        \\Comment{for all points (current level and ancestors)}%\n          \\For{$q = 0, \\dotsc, \\frac{p-1}{2}$}\n            \\State{%\n              $\\deriv[q]{x}{\\fgintp{l}}(\\gp{l,i})\n              \\gets \\deriv[q]{x}{\\fgintp{l-1}}(\\gp{l,i}) +\n              \\deriv[q]{x}{r^{(l)}_l}(\\gp{l,i})$%\n            }\n            \\Comment{update values}%\n            \\label{line:algHermiteHierarchization8}\n          \\EndFor{}\n        \\EndFor{}\n      \\EndFor{}\n    \\EndFunction{}\n  \\end{algorithmic}\n  \\caption[%\n    Hermite hierarchization%\n  ]{%\n    Hermite hierarchization on one-dimensional regular grids.\n    Inputs are\n    the vector $\\vlinin = (\\linin{l,i})_{(l,i) \\in \\liset}$\n    of input data (function values $\\fcnval{l,i}$ at the grid points) and\n    the level $n$ of the regular grid,\n    where $\\liset = \\{(l, i) \\mid l = 0, \\dotsc, n,\\; i \\in \\hiset{l}\\}$.\n    The output is the vector\n    $\\vlinout = (\\linout{l,i})_{(l,i) \\in \\liset}$\n    of output data (hierarchical surpluses $\\surplus{l,i}$).%\n  }%\n  \\label{alg:hermiteHierarchization}%\n\\end{algorithm}\n\n\\vspace*{\\fill}\n\nThe idea of \\cref{alg:hermiteHierarchization},\nwhich is also illustrated in \\cref{fig:hermiteHierarchization},\nis to hierarchize the function value data level by level,\nwhich is only possible because of the weakly fundamental property\n\\eqref{eq:weaklyFundamentalProperty}.\nFor each level $l$, we calculate surpluses\n$\\surplus{l,i} = \\linout{l,i}$, while keeping track of\nthe values and derivatives\n$\\deriv[q]{x}{\\fgintp{l}}(\\gp{l,i})$ of the\n``current'' interpolant $\\fgintp{l}$ (up to level $l$).\nHermite interpolation is used to determine the ``delta''\nto the interpolant of the next level.\nNote that in \\cref{line:algHermiteHierarchization8},\nwe have to evaluate the derivatives of\n$\\deriv[q]{x}{\\fgintp{l-1}}(\\gp{l,i})$ of the Hermite interpolant\ndetermined in \\cref{line:algHermiteHierarchization4}.\nThis is not an issue since in an implementation\none would typically simultaneously evaluate the\nHermite interpolant and its derivatives.\n\n\\vspace*{\\fill}\n\n\\begin{SCfigure}\n  \\includegraphics{hermiteHierarchization_1}%\n  \\caption[%\n    Hermite hierarchization%\n  ]{%\n    Hermite hierarchization on a regular grid in one dimension\n    with cubic weakly fundamental splines $\\bspl[\\wfs]{l,i}{p}$ ($p = 3$).\n    The interpolants $\\fgintp{l}$ \\emph{\\textcolor{C1}{(red)}}\n    of the objective function \\emph{\\textcolor{C0}{(blue)}}\n    are computed level by level.\n    For each level $l$,\n    \\vspace{-0.1em}%\n    the values $\\fgintp{l}(\\gp{l,i})$ and the derivatives\n    $\\deriv{x}{\\fgintp{l}}(\\gp{l,i})$ of the\n    current interpolant $\\fgintp{l}$ at the\n    grid points $\\gp{l,i}$ ($i = 0, \\dotsc, 2^l$) are saved\n    \\emph{(black dots and bars).}\n    The values and derivatives are used for the Hermite interpolation\n    of the residual $\\objfun - \\fgintp{l}$.\n    The interpolated residual is then added to the current interpolant\n    such that the sum vanishes in the grid points of the next level $l + 1$\n    \\emph{%\n      (black dashed lines between \\textcolor{C1}{red} and\n      \\textcolor{C0}{blue} dots).%\n    }\n    Due to the weakly fundamental property, the previously\n    interpolated values of $\\objfun$ remain unchanged.%\n  }%\n  \\label{fig:hermiteHierarchization}%\n\\end{SCfigure}\n\nFor hierarchical weakly fundamental splines,\nthe complexity of the $l$-th iteration of \\cref{alg:hermiteHierarchization}\nis linear in the number of grid points of level $l$, i.e., $\\landauO{2^l}$.\nThe reason for this is the bandedness (with bandwidth $\\landauO{p}$) of the\nsystem of linear equations corresponding to the interpolation problem of\n\\cref{line:algHermiteHierarchization6,line:algHermiteHierarchization7},\nwhich means that the interpolation problem can be solved in\nlinear time and memory.\nIn total, the complexity of \\cref{alg:hermiteHierarchization} is\ngiven by $\\landauO{\\sum_{l=0}^n 2^l} = \\landauO{2^n}$, i.e.,\nthe time and memory required by \\cref{alg:hermiteHierarchization}\nis only linear in the number of grid points.\n\n\\pagebreak\n\n\\paragraph{Correctness}\n\nWe prove the correctness of Hermite hierarchization\nwith the following invariant.\n\n\\begin{restatable}[invariant of Hermite hierarchization]{%\n  proposition%\n}{%\n  propInvariantHermiteHierarchization%\n}\n  \\label{prop:invariantHermiteHierarchization}\n  In \\cref{alg:hermiteHierarchization}, it holds\n  for $l = 0, \\dotsc, n$ and $i = 0, \\dotsc, 2^l$\n  \\begin{equation}\n    \\label{eq:propInvariantHermiteHierarchization}\n    \\deriv[q]{x}{\\fgintp{l}}(\\gp{l,i})\n    = \\sum_{l'=0}^l \\sum_{i' \\in \\hiset{l'}}\n    \\linout{l',i'} \\deriv[q]{x}{\\bspl[\\wfs]{l',i'}{p}}(\\gp{l,i}),\\quad\n    q = 0, \\dotsc, \\frac{p-1}{2}.\n    \\hspace*{-6mm}\n  \\end{equation}\n\\end{restatable}\n\n\\begin{proof}\n  See \\cref{sec:a135proofHermiteHierarchization}.\n\\end{proof}\n\n\\begin{restatable}[correctness of Hermite hierarchization]{%\n  shortcorollary%\n}{%\n  corAlgHermiteHierarchizationCorrectness%\n}\n  \\label{cor:algHermiteHierarchizationCorrectness}\n  \\Cref{alg:hermiteHierarchization} is correct.\n\\end{restatable}\n\n\\begin{proof}\n  See \\cref{sec:a135proofHermiteHierarchization}.\n\\end{proof}\n\n\n\n\\subsection{Hierarchical Weakly Fundamental Not-A-Knot Splines}\n\\label{sec:456wfsNotAKnot}\n\nFinally, as for fundamental splines,\nit is possible to combine the weakly fundamental basis\nwith the not-a-knot idea from \\cref{sec:32notAKnot} to construct\nhierarchical weakly fundamental not-a-knot spline functions\n$\\bspl[\\wfs,\\nak]{l',i'}{p}$.\nThe approach is similar to the fundamental not-a-knot splines\nin \\cref{sec:445fundamentalNotAKnotSplines}\n(see \\cref{eq:fundamentalNotAKnotSplines}):\nInstead of combining uniform B-splines as in\n\\eqref{eq:weaklyFundamentalSplineParent},\nwe combine not-a-knot B-splines such that the\nweakly fundamental property is satisfied.\n\nHowever, the exact construction is somewhat complicated,\nas one has to carefully consider which conditions to enforce\nwith which basis functions.\nThere are some special cases, if the index of the basis function\n$\\bspl[\\wfs,\\nak]{l',i'}{p}$ is near the boundary\n(near $i' = 0$ or near $i' = 2^{l'}$).\nNevertheless, there are only finitely many special cases;\nfor higher levels $l'$, one can just scale the basis functions\nof coarser levels.\nIn the scope of this thesis,\nit suffices to show the resulting basis functions for\nthe cubic case ($p = 3$) in\n\\cref{fig:hierarchicalWeaklyFundamentalNotAKnotSpline},\ninstead of rigorously stating the technical formulas.\n\n\\begin{SCfigure}\n  \\includegraphics{hierarchicalBasis_18}%\n  \\caption[%\n    Hierarchical weakly fundamental not-a-knot splines%\n  ]{%\n    Hierarchical cubic weakly fundamental not-a-knot splines\n    $\\bspl[\\wfs,\\nak]{l',i'}{p}$\n    ($l' \\le l$, $i' \\in \\hiset{l'}$, $p = 3$),\n    grid points $\\gp{l',i'}$ \\emph{(dots),} and\n    removed knots \\emph{(crosses)} up to level $l = 3$.%\n  }%\n  \\label{fig:hierarchicalWeaklyFundamentalNotAKnotSpline}%\n\\end{SCfigure}\n", "meta": {"hexsha": "4c3f088ad9b23d651e5a4047bf18a31e44aedd9a", "size": 40770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/document/45spatAdaptiveUP.tex", "max_stars_repo_name": "valentjn/thesis-arxiv", "max_stars_repo_head_hexsha": "ae30179e67cd6a7813385e140b609546fd65b897", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-10-12T09:28:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T21:07:17.000Z", "max_issues_repo_path": "tex/document/45spatAdaptiveUP.tex", "max_issues_repo_name": "valentjn/thesis-arxiv", "max_issues_repo_head_hexsha": "ae30179e67cd6a7813385e140b609546fd65b897", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/document/45spatAdaptiveUP.tex", "max_forks_repo_name": "valentjn/thesis-arxiv", "max_forks_repo_head_hexsha": "ae30179e67cd6a7813385e140b609546fd65b897", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7960288809, "max_line_length": 78, "alphanum_fraction": 0.6872209958, "num_tokens": 13326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.44150954106890755}}
{"text": "%\\documentclass[12pt]{article}\n\\documentclass[12pt,landscape]{article}\n\n\\usepackage[normalem]{ulem}\n\\include{preamble}\n\n\\newcommand{\\instr}{\\small Your answer will consist of a lowercase string (e.g. \\texttt{aebgd}) where the order of the letters does not matter. \\normalsize}\n\n\\title{Math 369 / 690 Fall \\the\\year{} \\\\ Final Examination}\n\\author{Professor Adam Kapelner}\n\n\\date{Thursday, December 16, \\the\\year{}}\n\n\\begin{document}\n\\maketitle\n\n%\\noindent Full Name \\line(1,0){410}\n\n\\thispagestyle{empty}\n\n\\section*{Code of Academic Integrity}\n\n\\footnotesize\nSince the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.\n\nActivities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:\n\n\\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using an unauthorized cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.\n\\\\\n\n\\noindent By taking this exam, you acknowledge and agree to uphold this Code of Academic Integrity. \\\\\n\n%\\begin{center}\n%\\line(1,0){250} ~~~ \\line(1,0){100}\\\\\n%~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date\n%\\end{center}\n\n\\normalsize\n\\vspace{-0.3cm}\n\\section*{Instructions}\nThis exam is 110 minutes (variable time per question) and closed-book. You are allowed \\textbf{three} page (front and back) of a \\qu{cheat sheet}, blank scrap paper and a graphing calculator. Please read the questions carefully. I recommend answering all questions that are easy first and then circling back to work on the harder ones. \\ingray{Gray text} means the text is repeated verbatim from a previous problem. No food is allowed, only drinks. %If the question reads \\qu{compute,} this means the solution will be a number otherwise you can leave the answer in \\textit{any} widely accepted mathematical notation which could be resolved to an exact or approximate number with the use of a computer. I advise you to skip problems marked \\qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \\fbox{Box} in your final answers. Good luck!\n\n\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{13} \\href{https://en.wikipedia.org/wiki/Benford\\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \\qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the Benford Law distribution's PMF and CDF. It's mean is 3.441.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{l|lllllllll}\n$x$\t\t&\t1\t\t& \t2\t\t&\t3\t\t&\t4\t\t&\t5\t\t&\t6\t\t&\t7\t\t&\t\t8\t&\t9 \\\\ \\hline\n$p(x)$\t&\t.301\t&\t.176\t&\t.125\t&\t.097\t&\t.079\t&\t.067\t&\t.058\t& \t\t.051\t&\t.046 \\\\\n$F(x)$  &   .301\t\t&\t.477\t&\t.602\t&\t.699\t&\t.778\t&\t.845\t&\t.903\t& \t\t.954\t&\t1.000 \\\\\n\\end{tabular}\n\\end{table}\n\\FloatBarrier\n\\vspace{-0.2cm}\n\\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\\x = <1,1,1,1,1,2,2,2,2,2, \\ldots, 9,9,9,9,9>$.  This smells of fraud; we will investigate. To test cheating we can use ...\n\n\\vspace{-0.1cm}\\benum\\truefalsesubquestionwithpoints{13} \n\\begin{enumerate}[(a)]\n\\item ... the one sample asymptotic $z$ test for the mean\n\\item ... the one sample asymptotic $t$ test for the mean\n\\item ... the one sample Wald test for the mean\n\\item ... the score test for the mean\n\\item ... the likelihood ratio test for the mean\n\\item ... a generalized likelihood ratio test\n\\item ... Pearson's $\\chi^2$ goodness of fit test\n\\item ... Kolmogorov-Smirnov's one-sample test\n\\item ... a bootstrap test where $\\xbar$ is calculated for each bootstrap sample\n\\item ... the Welch-Satterthwaite $t$ test\n\\item ... Kolmogorov-Smirnov's two-sample test\n\\item ... Fisher's two-sample permutation test\n\\item ... the multivariate delta method\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{14} \\ingray{\\small{\\href{https://en.wikipedia.org/wiki/Benford\\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \\qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.} \\normalsize\n\n\n\\vspace{-0.2cm}\n\\begin{table}[h]\n\\centering\\ingray{\n\\begin{tabular}{l|lllllllll}\n\n$x$\t\t&\t1\t\t& \t2\t\t&\t3\t\t&\t4\t\t&\t5\t\t&\t6\t\t&\t7\t\t&\t\t8\t&\t9 \\\\ \\hline\n$p(x)$\t&\t.301\t&\t.176\t&\t.125\t&\t.097\t&\t.079\t&\t.067\t&\t.058\t& \t\t.051\t&\t.046 \\\\\n$F(x)$  &   .301\t\t&\t.477\t&\t.602\t&\t.699\t&\t.778\t&\t.845\t&\t.903\t& \t\t.954\t&\t1.000 \\\\\n\\end{tabular}}\n\\end{table}\n\\FloatBarrier\n\n\\vspace{-0.3cm}\n\\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\\x = <1,1,1,1,1,2,2,2,2,2, \\ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} To do so, we will employ Pearson's $\\chi^2$ goodness of fit test at $\\alpha = 5\\%$. Critical values you may need to reference are: $F_{\\chisq{7}}(14.1) = F_{\\chisq{8}}(15.5) = F_{\\chisq{9}}(16.9) = F_{\\chisq{10}}(18.3) = .95$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{12} \n\\begin{enumerate}[(a)]\n\\item $H_0: \\theta = 3.441$ where $\\theta$ denotes the mean of the DGP that generated $x_1, \\ldots, x_{45}$\n\\item $H_0:$ the DGP that generated $x_1, \\ldots, x_{45}$ is Benford's law\n\\item $H_0:$ the PMF of the DGP that generated $x_1, \\ldots, x_{45}$ is the $p(x)$ given as $p(x)$ in the table above\n%\\item $H_0:$ the CDF of the DGP that generated $x_1, \\ldots, x_{45}$ is the $p(x)$ given as $F(x)$ in the table above\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is a realization from an approximate $\\chisq{7}$ distribution\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is a realization from an approximate $\\chisq{9}$ distribution\n\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is 0\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is 18.05 rounded to the nearest two digits\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is 18.39 rounded to the nearest two digits\n\\item Pearson's $\\chi^2$ goodness of fit test statistic is 213.01 rounded to the nearest two digits\n%\\item Pearson's $\\chi^2$ goodness of fit test statistic is 4888.37 rounded to the nearest two digits\n\\item Pearson's $\\chi^2$ goodness of fit test statistic cannot be computed given the information available\n\n\\item $H_0$ is rejected\n\\item There is sufficient evidence to conclude this person is cheating on their tax return\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{13} \\ingray{\\footnotesize{\\href{https://en.wikipedia.org/wiki/Benford\\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \\qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.} \\normalsize\n\n\\vspace{-0.2cm}\n\\begin{table}[h]\n\\centering\\ingray{\n\\begin{tabular}{l|lllllllll}\n\n$x$\t\t&\t1\t\t& \t2\t\t&\t3\t\t&\t4\t\t&\t5\t\t&\t6\t\t&\t7\t\t&\t\t8\t&\t9 \\\\ \\hline\n$p(x)$\t&\t.301\t&\t.176\t&\t.125\t&\t.097\t&\t.079\t&\t.067\t&\t.058\t& \t\t.051\t&\t.046 \\\\\n$F(x)$  &   .301\t\t&\t.477\t&\t.602\t&\t.699\t&\t.778\t&\t.845\t&\t.903\t& \t\t.954\t&\t1.000 \\\\\n\\end{tabular}}\n\\end{table}\n\\FloatBarrier\n\n\\vspace{-0.2cm}\n\\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\\x = <1,1,1,1,1,2,2,2,2,2, \\ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} To do so, we will employ the Kolmogorov-Smirnov (KS) test at $\\alpha = 5\\%$ (and assume it works for discrete rv's). The critical value you need for reference is: $F_{K}(1.36) = .95$ where $K$ denotes the Kolmogorov distribution.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{12} \n\\begin{enumerate}[(a)]\n\\item $H_0: \\theta = 3.441$ where $\\theta$ denotes the mean of the DGP that generated $x_1, \\ldots, x_{45}$\n\\item $H_0:$ the DGP that generated $x_1, \\ldots, x_{45}$ is Benford's law\n%\\item $H_0:$ the PMF of the DGP that generated $x_1, \\ldots, x_{45}$ is the $p(x)$ given as $p(x)$ in the table above\n%\\item $H_0:$ the CDF of the DGP that generated $x_1, \\ldots, x_{45}$ is the $p(x)$ given as $F(x)$ in the table above\n\\item The KS test is an approximate test\n\n\\item The $\\doublehat{D}_n$ test statistic is 0 \n\\item The $\\doublehat{D}_n$ test statistic is 0.19 rounded to the nearest two digits \n\\item The $\\doublehat{D}_n$ test statistic is 0.25 rounded to the nearest two digits\n\\item The $\\doublehat{D}_n$ test statistic is 0.27 rounded to the nearest two digits\n\\item The $\\doublehat{D}_n$ test statistic cannot be computed given the information available\n\n\\item If $\\doublehat{D}_n < 1.36$, this means the null hypothesis is retained\n\\item There is sufficient evidence to conclude this person is cheating on their tax return\n\\item the KS test statistic should be approximately equal to Pearson's $\\chi^2$ goodness of fit test statistic\n\\item Fisher's p-value in the KS test should be approximately equal to Fisher's p-value in Pearson's $\\chi^2$ goodness of fit test\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{14} \\ingray{\\footnotesize{\\href{https://en.wikipedia.org/wiki/Benford\\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \\qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.\n\n\\vspace{-0.2cm}\n\\begin{table}[h]\n\\centering\\ingray{\n\\begin{tabular}{l|lllllllll}\n\n$x$\t\t&\t1\t\t& \t2\t\t&\t3\t\t&\t4\t\t&\t5\t\t&\t6\t\t&\t7\t\t&\t\t8\t&\t9 \\\\ \\hline\n$p(x)$\t&\t.301\t&\t.176\t&\t.125\t&\t.097\t&\t.079\t&\t.067\t&\t.058\t& \t\t.051\t&\t.046 \\\\\n$F(x)$  &   .301\t\t&\t.477\t&\t.602\t&\t.699\t&\t.778\t&\t.845\t&\t.903\t& \t\t.954\t&\t1.000 \\\\\n\\end{tabular}}\n\\end{table}\n\\FloatBarrier\n\n\\vspace{-0.2cm}\n\\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\\x = <1,1,1,1,1,2,2,2,2,2, \\ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.}} \\normalsize To do so, we will employ the generalized likelihood ratio test at $\\alpha = 5\\%$. Critical values you may need to reference are: $F_{\\chisq{7}}(14.1) = F_{\\chisq{8}}(15.5) = F_{\\chisq{9}}(16.9) = F_{\\chisq{10}}(18.3) = .95$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{13} \n\\begin{enumerate}[(a)]\n\\item $H_0: \\theta = 3.441$ where $\\theta$ denotes the mean of the DGP that generated $x_1, \\ldots, x_{45}$\n\\item $H_0:$ the DGP that generated $x_1, \\ldots, x_{45}$ is Benford's law\n\n%\\item The $\\doublehat{\\Lambda}$ test statistic is a realization from an approximate $\\chisq{7}$ distribution\n\\item The $\\doublehat{\\Lambda}$  test statistic is a realization from an approximate $\\chisq{9}$ distribution\n\n\\item The generalized likelihood ratio test is an approximate test\n\\item The numerator in the likelihood ratio is $1/9^{45}$\n\\item The denominator in the likelihood ratio is $1/9^{45}$\n\\item The likelihood that this data came from Benford's law is less than 1 in 1,000,000,000\n\\item The $\\doublehat{\\Lambda}$ test statistic is 0 \n\\item The $\\doublehat{\\Lambda}$ test statistic is 2.12 $\\times 10^{-47}$ rounded to the nearest two digits\n\\item The $\\doublehat{\\Lambda}$ test statistic is 8.59 rounded to the nearest two digits\n\\item The $\\doublehat{\\Lambda}$ test statistic cannot be computed given the information available\n\n\\item If the likelihood ratio is calculated to be a value strictly greater than 1, the null hypothesis is rejected\n\\item There is sufficient evidence to conclude this person is cheating on their tax return\n\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\problem\\timedsection{13} Below is the PMF and log PMF of Benford's law distribution:\n\n\\vspace{-0.2cm}\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{l|lllllllll}\n\n$x$\t\t&\t1\t\t& \t2\t\t&\t3\t\t&\t4\t\t&\t5\t\t&\t6\t\t&\t7\t\t&\t\t8\t&\t9 \\\\ \\hline\n$p(x)$\t&\t.301\t&\t.176\t&\t.125\t&\t.097\t&\t.079\t&\t.067\t&\t.058\t& \t\t.051\t&\t.046 \\\\\n$\\natlog{p(x)}$  &   -1.201 & -1.737 & -2.079 & -2.333 & -2.538 & -2.703 & -2.847 & -2.976 & -3.079 \\\\\n\\end{tabular}\n\\end{table}\n\\FloatBarrier\n\n\\vspace{-0.2cm}\n\\noindent \\ingray{Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\\x = <1,1,1,1,1,2,2,2,2,2, \\ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} \\normalsize This time, we will use model selection even though this is not, strictly speaking, a form of hypothesis testing. Consider two models:\n\n\\begin{itemize}\n\\item[I] Uniform i.e. with likelihood $\\tothepow{\\oneover{9}}{5} \\tothepow{\\oneover{9}}{5} \\cdot \\ldots \\cdot \\tothepow{\\oneover{9}}{5}$\n\\item[II] Benford i.e. with likelihood $\\tothepow{0.301}{5} \\tothepow{0.176}{5} \\cdot \\ldots \\cdot \\tothepow{0.046}{5}$\n\\end{itemize}\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{16} \n\\begin{enumerate}[(a)]\n\\item The log-likelihood in the first model is -98.88 rounded to the nearest two digits\n\\item The log-likelihood in the second model is -107.47 rounded to the nearest two digits\n\\item Since the log-likelihood in the second model is absolutely larger than the first model, the second model is more likely to be true if you assume one of the two models is true\n\n\\item The AIC for Model I is 197.75 rounded to the nearest two digits\n\\item The AIC for Model I is 199.75 rounded to the nearest two digits\n\n\\item Since Model I has the lower AIC, model I is the selected model according to the AIC model selection procedure\n\n\\item Assuming one of these two models is the true model, the probability that model I is true is 50\\%\n\\item Assuming one of these two models is the true model, the probability that model I is true is 99.98\\% rounded to the nearest two digits\n\n\\item For Model II, the AIC and the AICC metrics will be equivalent\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\problem\\timedsection{11} Consider running $m > 1$ hypothesis tests. Following the notation from the lectures, below is a table that tabulates the random variables that model the possible events (denoted by uppercase letters) and the fixed constants (denoted by lowercase letters) in the course of these tests:\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{c|cc|c}\n& Decision: Retain $H_0$ & Decision: Reject $H_0$ & total \\\\\\hline\n$H_0$ true & $U$ & $V$ & $m_0$ \\\\\n$H_a$ true & $T$ & $S$ & $m - m_0$ \\\\ \\hline\ntotal & $F$ & $R$ & $m$\n\\end{tabular}\n\\end{table}\n\\FloatBarrier\n\nAssume each of the $m$ tests are \\textbf{independent from each other} and that the levels for each test are $\\alpha$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{13} \n\n\\begin{enumerate}[(a)]\n\\item $U \\sim \\binomial{m}{\\alpha}$ \n\\item $U \\sim \\binomial{m}{1 - \\alpha}$ \n\\item For any $m -m_0$ alternative distributions, $S$ can be modeled as a binomial\n\\item $T$ is the rv model which models the number of type II errors\n\\item If the FWER is properly controlled, $T$ goes to zero as $m \\rightarrow \\infty$\n\\item If the FWER is properly controlled, the rejected tests's results are of higher practical significance then the rejected tests's results without FWER control (but still may not be practically significant)\n\\item The familywise error rate (FWER) is equal to the probability that $R > 1$\n\\item Using the Dunn-Sidak correction, the threshold for significance of each test would be less than $\\alpha$\n\\item The Simes procedure has a higher $\\expe{R}$ than the Bonferroni procedure\n\n\\item If you set $\\alpha = 5\\% / m$ then FWER $=5\\%$\n\\item If you set $\\alpha = 5\\% / m$ then FWER $> 5\\%$\n\n\\item In order to compute the threshold of significance for Sime's FWER-controlling procedure, you need to first run all $m$ tests and compute their $m$ p-values\n\\item For $m_0$ of the $m$ tests, the p-values could be drawn as realizations from $\\stduniform$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\problem\\timedsection{9} A not-so well-known test is a test for a DGP's \\qu{kurtosis}. Kurtosis is generally speaking a measure of how fast the tails of the distribution approach zero. Pearson defined it to be $\\kappa := \\expe{(X - \\mu)^4 / \\sigma^4}$, the fourth standardized moment. A very interesting fact is that the normal distribution has $\\kappa = 3$ regardless of its mean and variance. Thus, we define the \\qu{excess kurtosis} as the amount in excess over 3, i.e. $\\kappa_0 := \\kappa - 3$. An excess kurtosis of different than 0 means the tails of the distribution are thinner/fatter than the normal's tails. This is really important to test sometimes.\n\n\n\\vspace{-0.1cm}\n\\benum\\truefalsesubquestionwithpoints{8} \n\\begin{enumerate}[(a)]\n\\item To test this we can use a one sample Wald test if we were given the DGP and can derive the MLE for $\\kappa_0$\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use Pearson's $\\chi^2$ goodness of fit test\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use Kolmogorov-Smirnov's one-sample test\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use Fisher's two-sample permutation test\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use the multivariate delta method\n\\item We can always estimate $\\kappa_0$ using MM for any DGP whose $\\kappa_0$ is finite\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use a one sample Wald test if we can derive the standard error for the MM $\\kappa_0$ estimator\n\\item To test $H_a: \\kappa_0 \\neq 0$ we can use a bootstrap test where the MM excess kurtosis estimate is calculated for each bootstrap sample\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\problem\\timedsection{8} \\ingray{A not-so well-known test is a test for a DGP's \\qu{kurtosis}. Kurtosis is generally speaking a measure of how fast the tails of the distribution approach zero. Pearson defined it to be $\\kappa := \\expe{(X - \\mu)^4 / \\sigma^4}$, the fourth standardized moment. A very interesting fact is that the normal distribution has $\\kappa = 3$ regardless of its mean and variance. Thus, we define the \\qu{excess kurtosis} as the amount in excess over 3, i.e. $\\kappa_0 := \\kappa - 3$. An excess kurtosis of greater than 0 means the tails of the distribution are fatter than the normal's tails. This is really important to test sometimes.} Consider the following stock market data: centered daily percentage returns from the S\\&P 500 in the past year. We wish to test if the tails of this distribution are fatter than the normal distribution's tails, i.e. $H_a: \\kappa_0 \\neq 0$ at $\\alpha = 5\\%$ and to do so we'll use a bootstrap test. Here is a histogram of $B=1,000,000$ MM estimates of $\\kappa_0$. And $\\doublehat{\\kappa}^{MM}_0 = 0.748$\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=7in]{boot}\n\\end{figure}\n\n\n\\vspace{-0.9cm}\n\\benum\\truefalsesubquestionwithpoints{9} \n\\begin{enumerate}[(a)]\n\\item We do not really need to use the bootstrap test as the sampling distribution of $\\hat{\\kappa}^{MM}_0$ can be derived analytically\n\\item A 95\\% bootstrap confidence interval will be approximately between -1 and 3\n\\item A 95\\% bootstrap confidence interval will be approximately between 0.2 and 1.4\n\\item The null hypothesis is rejected\n\\item The data seems to suggest the normal model is not a good model for daily percentage returns from the S\\&P 500 in the past year\n\\item $B=1,000,000$ seems to be sufficient to construct CI's and run hypothesis tests\n\\item $\\hat{\\kappa}^{MM}_0$ may be biased\n\\item If $\\hat{\\kappa}^{MM}_0$ were to be biased, the test is still valid regardless of the bias\n\\item If $\\hat{\\kappa}^{MM}_0$ were to be biased, the bias could be fixed by increasing $n$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\problem\\timedsection{15} Assume a DGP of $\\Xoneton \\iid \\normnot{0}{\\theta}$. We wish to test $H_a: \\theta \\neq 1$ for the dataset 1.41, 1.44, 4.19, 5.12, 0.09, 8.62, 0.6, -8.88, 0.63, -8.57 at $\\alpha = 5\\%$ using the score test.\n\n\\vspace{-0.1cm}\n\\benum\\truefalsesubquestionwithpoints{14} \n\\begin{enumerate}[(a)]\n\\item The score test requires you to compute $\\doublehat{\\theta}^{MLE}$\n\\item $\\mathcal{L}\\parens{\\theta; \\Xoneton} = \\displaystyle\\prod_{i=1}^n \\oneoversqrt{2\\pi\\theta} \\exp{-\\oneover{2\\theta} X_i^2}$\n\\item $\\ell\\parens{\\theta; \\Xoneton} = \\tothepow{2\\pi\\theta}{-n/2} \\natlog{-\\oneover{2\\theta} X_i^2}$\n\\item $\\ell'\\parens{\\theta; \\Xoneton} = -\\displaystyle\\frac{n}{2\\pi} -\\displaystyle\\frac{n}{2\\theta} - \\oneover{2\\theta} \\sum_{i=1}^nX_i^2$\n\\item $\\ell'\\parens{\\theta; \\Xoneton} =-\\displaystyle\\frac{n}{2\\theta} + \\oneover{2\\theta^2} \\sum_{i=1}^n X_i^2$\n\\item $\\ell''\\parens{\\theta; \\Xoneton} = \\displaystyle\\frac{n}{2\\theta^2} - \\oneover{\\theta^3} \\sum_{i=1}^n X_i^2$\n\\item $I(\\theta) = \\displaystyle\\frac{n}{2\\theta^2}$\n\\item $I(\\theta) = -\\displaystyle\\frac{n}{2\\theta^2}$\n\\item The score statistic is $\\parens{-\\displaystyle\\frac{n}{2} + \\half \\sum_{i=1}^n X_i^2} \\displaystyle\\overn{\\sqrt{2}}$\n\\item The score statistic is 0\n\\item The score statistic is 16.40 rounded to the two nearest digits \n\\item The score statistic is 89.98 rounded to the two nearest digits\n\\item The null hypothesis is rejected\n\\item The p-value of the score test will be similar to the p-values of the likelihood ratio test and the wald test but may not be exactly equal\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n\n\\end{document}\n\n\n\n\n", "meta": {"hexsha": "fb631470ad9068243b9872344383d27ee96b4e4d", "size": 24787, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/final/final.tex", "max_stars_repo_name": "kapelner/QC_MATH_369_Fall_2021", "max_stars_repo_head_hexsha": "71ec8d551a4bbd435d5d21756c1a8cc6c0f42fda", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exams/final/final.tex", "max_issues_repo_name": "kapelner/QC_MATH_369_Fall_2021", "max_issues_repo_head_hexsha": "71ec8d551a4bbd435d5d21756c1a8cc6c0f42fda", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exams/final/final.tex", "max_forks_repo_name": "kapelner/QC_MATH_369_Fall_2021", "max_forks_repo_head_hexsha": "71ec8d551a4bbd435d5d21756c1a8cc6c0f42fda", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.0197740113, "max_line_length": 1063, "alphanum_fraction": 0.7222334288, "num_tokens": 7604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.4414820388153894}}
{"text": "\\chapter{Data Application} \\label{chapter4:Data-Application}\n\nTo evaluate the performance of our method on real data, we use an atomic force microscopy (AFM) image of a solar cell. The image (see Figure~\\ref{fig:film}) comes from a paper by Singh et al.~\\cite{Singh2014}, who wanted to improve efficiency of converting light into electricity by optimizing the concentration of carbon nanotubes in solar cells coated with a particular compound called poly(3-hexylthiophene): phenyl-C61-butyric acid methyl ester (P3HT:PCBM). This compound is spread in a microscopically thin film over the cell.\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.65\\textwidth]{film.png}\n\t\\caption{Atomic force microscopy image of a thin film of the P3HT:PCBM compound on a solar cell. Dark clusters represent areas where the film is thinner, and lighter clusters are thicker areas.}\n\t\\label{fig:film}\n\\end{figure}\n\nFigure~\\ref{fig:film} shows a P3HT:PCBM film doped with a 0.1\\% concentration of carbon nanotubes. By treating the film thickness as observations from an unknown isotropic stationary Gaussian process, our goal was to train a covariance model on some of these observations and predict the others.\n\nTo prepare the data, we selected ten 25-by-25 pixel squares to use to estimate the covariance function. We treated the squares as 10 independent observations of a Gaussian process on the 25-by-25 grid. Once we obtained our estimate, we selected an out of sample 25-by-25 square, removed a 4-by-4 section of that square made predictions conditionally on the remainder as observations in the square. One of the training squares is shown in Figure~\\ref{fig:training25}, and Figure~\\ref{fig:pred25} shows the observation square, with the withheld prediction points highlighted in red.\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.95\\textwidth]{col_image_5.pdf}\n\t\\caption{One of the 10 25-by-25 sections of the film image used to fit the spline model.}\n\t\\label{fig:training25}\n\\end{figure}\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.95\\textwidth]{col_pred.pdf}\n\t\\caption{This 25-by-25 section of the film image was held out from the training step. The 16 outlined pixels are used for prediction, and the others are treated as observations.}\n\t\\label{fig:pred25}\n\\end{figure}\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.95\\textwidth]{covariance_realdata.pdf}\n\t\\caption{The estimated covariance function based on the 10 25-by-25 sections of the film image used to fit the spline model.}\n\t\\label{fig:covariance-realdata}\n\\end{figure}\n\nWe fit the semiparametric model and a Mat\\'ern model, and compare the prediction performance of each. The mean squared prediction error for the Mat\\'ern model was $0.0008707$, while the mean squared prediction error for the semiparametric model was $0.0006414$. The semiparametric model performed $26.3\\%$ better on the 16 prediction points, indicating that it is capturing the local behavior of the Gaussian process more effectively than the best-fit Mat\\'ern model can. Figure~\\ref{fig:covariance-realdata} shows the estimated covariance function from the semiparametric model. There is a significant hole effect that a Mat\\'ern model is not capable of capturing.\n", "meta": {"hexsha": "2d44b40ed6a9c2d210cd09ba813026c87bdd70ca", "size": 3243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Chapter-4/Chapter-4.tex", "max_stars_repo_name": "ensley/thesis", "max_stars_repo_head_hexsha": "fc8af97cdb1ed43e6a996a9eed5f1f195199669c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/Chapter-4/Chapter-4.tex", "max_issues_repo_name": "ensley/thesis", "max_issues_repo_head_hexsha": "fc8af97cdb1ed43e6a996a9eed5f1f195199669c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Chapter-4/Chapter-4.tex", "max_forks_repo_name": "ensley/thesis", "max_forks_repo_head_hexsha": "fc8af97cdb1ed43e6a996a9eed5f1f195199669c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 85.3421052632, "max_line_length": 665, "alphanum_fraction": 0.7927844588, "num_tokens": 828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.4414820272943358}}
{"text": "% Created 2018-03-13 mar 13:26\n\\documentclass[a4paper]{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{fixltx2e}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{float}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{marvosym}\n\\usepackage{wasysym}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\tolerance=1000\n\\usepackage{khpreamble}\n\\newcommand*{\\shift}{\\operatorname{q}}\n\\author{Kjartan Halvorsen}\n\\date{Due 2018-03-07}\n\\title{Computerized control - homework 3}\n\\hypersetup{\n  pdfkeywords={},\n  pdfsubject={},\n  pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}\n\\begin{document}\n\n\\maketitle\n\n\\section*{The system}\n\\label{sec-1}\nConsider the linearized model of the tank that we looked at in class\n\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{../../MR2012/figures/tank-with-hole}\n\\end{center}\nUsing the parameter values \n\\[ A = 1, \\qquad a = 0.1, \\qquad g = 9.8,\\]\nand the operating point given by\n\\[ h_0 = 1, \\qquad z_0 = a\\sqrt{2gh_0} \\approx 0.44,\\]\nthe linearized model of the tank is described by the first-order system\n\\[ G_1(s) = \\frac{1}{s + 0.44}\\]\nfrom the deviation in flow $w(t)$ to the deviation in level $y(t)$.\n\nA valve is used to control the flow. The valve is a so-called control valve, which means it includes an inner controller that works as a position servo. That is, it will make sure the opening of the valve follows the input signal to the valve. This signal is named $u(t)$. The response of the opening of the valve $\\theta(t)$ to the input signal $u(t)$ is well-described by a second-order, critically damped system\n\\[ G_2(s) = \\frac{1}{(0.5s + 1)(0.5s+1)} = \\frac{4}{(s+2)(s+2)}. \\]\n\nThe flow through the valve depends also on the square root of the pressure difference across the valve. In a linearized model, a change in pressure enters as an additive disturbance to the system. The complete model of the process is given in the block-diagram below.\n\n  \\begin{center}\n  \\begin{tikzpicture}[scale = 0.8, node distance=18mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n  \n  \\node[coordinate] (input) {};\n  \\node[block, right of=input] (valve) {$G_2(s)$};\n  \\node[above of=valve, node distance=6mm] {valve};\n  \\node[sumnode, right of=valve, node distance=16mm] (sum) {\\tiny $\\sum$};\n  \\node[block, right of=sum, node distance=20mm] (tank) {$G_1(s)$};\n  \\node[above of=tank, node distance=6mm] {tank};\n  \\node[coordinate, right of=tank] (output) {};\n  \\node[coordinate, above of=sum, node distance=12mm] (disturbance) {};\n\n  \\draw[->] (input) -- node[above] {$u(t)$} (valve);\n  \\draw[->] (valve) -- node[above] {} (sum);\n  \\draw[->] (sum) -- node[above] {$w(t)$} (tank);\n  \\draw[->] (tank) -- node[above] {$y(t)$} (output);\n  \\draw[->] (disturbance) -- node[right, pos=0.2] {$v(t)$} (sum);\n\n  \\end{tikzpicture}\n\\end{center}\n\nThe level of the tank is measured, and is available for feedback control. \n    \\begin{center}\n  \\begin{tikzpicture}[scale = 0.8, node distance=20mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n  \n  \\node[coordinate] (refinput) {};\n  \\node[sumnode, right of=refinput, node distance=20mm] (sumerr) {\\tiny $\\sum$};\n  \\node[block, right of=sumerr] (controller) {$F(s)$};\n  \\node[above of=controller, node distance=6mm] {controller};\n  \\node[block, right of=controller, node distance=24mm] (valve) {$G_2(s)$};\n  \\node[above of=valve, node distance=6mm] {valve};\n  \\node[sumnode, right of=valve, node distance=16mm] (sum) {\\tiny $\\sum$};\n  \\node[block, right of=sum, node distance=20mm] (tank) {$G_1(s)$};\n  \\node[above of=tank, node distance=6mm] {tank};\n  \\node[coordinate, right of=tank, node distance=20mm] (output) {};\n  \\node[coordinate, above of=sum, node distance=12mm] (disturbance) {};\n\n  \\draw[->] (refinput) -- node[above, pos=0.3] {$y_{ref}(t)=0$} (sumerr);\n  \\draw[->] (sumerr) -- node[above] {$e(t)$} (controller);\n  \\draw[->] (controller) -- node[above] {$u(t)$} (valve);\n  \\draw[->] (valve) -- node[above] {} (sum);\n  \\draw[->] (sum) -- node[above] {$w(t)$} (tank);\n  \\draw[->] (tank) -- node[coordinate] (measure) {} node[above, pos=0.8] {$y(t)$} (output);\n  \\draw[->] (disturbance) -- node[right, pos=0.2] {$v(t)$} (sum);\n  \\draw[->] (measure) -- ++(0,-14mm) -| node[right, pos=0.95] {$-$} (sumerr);\n \\end{tikzpicture}\n\\end{center}\n\n\nA simulation model (\\texttt{simulink}) of the system is available on Blackboard under \\texttt{Course Documents/Matlab and Simulink} \n\n\\section*{Exercises}\n\\label{sec-2}\n\\subsection*{Problem 1 - Tuning a PID}\n\\label{sec-2-1}\n\nPerform a bumptest on the plant (valve+tank). This means to connect a step block (see \\texttt{Sources} in the \\texttt{Simulink Library Browser}) to the input of the valve. Determine the slope $R$, the apparent deadtime $L$, and the parameter $a=RL$ from the step response. See figure 8.13 in the text-book\n\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{../figures/fig8-13.png}\n\\end{center}\n\nInclude your simulated step-response in your report.\n\nDetermine a PID controller using table 8.2 in the book.\n\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{../figures/table8-2.png}\n\\end{center}\n\n\\subsection*{Problem 2 - Implement the PID in simulink}\n\\label{sec-2-2}\n\nThe controller is written\n\\[U(s) = K \\left( U_c(s) - Y(s) + \\frac{1}{sT_i}\\big(U_c(s) - Y(s)\\big) - \\frac{sT_d}{1 + sT_d/N} Y(s)\\right).\\]\n\nSet $N=10$ and implement the controller in simulink using the values for $K$, $T_i$ and $T_d$ that you determined in Problem 1.\n\nSimulate the closed-loop system's response to step changes in both the set point, $u_c(t)$ and the disturbance, $v(t)$. Include the step-responses in your report and comment on the results.\n\n\\subsection*{Problem 3 - Discrete PID}\n\\label{sec-2-3}\n\nThe discretized controller is written\n\\[ R(\\shift) u(kh) = T(\\shift) u_c(kh) - S(\\shift) y(kh), \\]\nwhere\n\\begin{align*}\n R(\\shift) &= (\\shift -1)(\\shift - a_d)\\\\\n S(\\shift) &= s_0\\shift^2 + s_1\\shift + s_2\\\\\nT(\\shift) &= t_0\\shift^2 + t_1\\shift + t_2\n\\end{align*}\n\nDetermine the discrete PID controller parameters $a_d$, $s_0$, $s_1$, $s_2$, $t_0$, $t_1$ and $t_2$ using table 8.1 in the textbook (given below). You can use whichever of the three discretization methods provided.\n\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{../figures/table8-1.png}\n\\end{center}\n\n\\section*{Solutions}\n\\label{sec-3}\n\\subsection*{Problem 1 - Tuning a PID}\n\\label{sec-3-1}\n\nBelow is the result from a bumptest on the plant (valve+tank).\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{./figures/hw3-bumptest.png}\n\\end{center}\nThe measurement points (\\(t_1, y_1\\)) and (\\(t_2, y_2\\)) were moved around in order to find two close points which gave the largest slope \\(R = \\frac{y_2-y_1}{t_2-t_1}\\). The apparent deadtime $L$ is the intersection of the steepest tangent with the time axis. This can be found by noting that if we take the midpoint of $y_1$ and $y_2$ as the tangent point, then $R = \\frac{y_2+y_1}{2L}$. We get\n\\begin{align*}\nR &= \\frac{y_2-y_1}{t_2-t_1} = 0.73\\\\\nL &= \\frac{y_1+y_2}{2R} = 2.85\\\\\na &= RL = 2.09\n\\end{align*}\n\nFrom table 8.2 we obtain the parameters\n\\begin{align*}\nK &= 1.2/a = 0.575\\\\\nT_i &= 2L = 5.69\\\\\nT_d &= 0.5L = 1.42\n\\end{align*}\n\n\\subsection*{Problem 2 - Implement the PID in simulink}\n\\label{sec-3-2}\n\nThe controller is written\n\\[U(s) = K \\left( U_c(s) - Y(s) + \\frac{1}{sT_i}\\big(U_c(s) - Y(s)\\big) - \\frac{sT_d}{1 + sT_d/N} Y(s)\\right).\\]\n\nIn \\texttt{simulink} the model should look like the following\n\\begin{center}\n\\includegraphics[width=0.9\\linewidth]{./figures/hw3-pid-block.png}\n\\end{center}\nNote that the derivative part acts only on the feedback signal $-y(t)$. The blocks are\n\\begin{description}\n\\item[{Derivative part}] num: [Td, 0], den: [Td/N, 1]\n\\item[{Integrating part}] num: [ 1 ], den: [Ti, 0]\n\\end{description}\n\nA step response of the closed-loop system is given below. A step change in the set point occurs at time $t=10$ and then a step in the disturbance occurs at time $t=50$. \n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{./figures/hw3-pid-step.png}\n\\end{center}\n\nWe can see that thanks to the integrating part of the controller, there is no steady-state error. It takes the system about 20 seconds to settle. There is some overshoot in the set-point response, but not too much. This should be acceptable. \n\n\\subsection*{Problem 3 - Discrete PID}\n\\label{sec-3-3}\n\nThe discretized controller is written\n\\[ R(\\shift) u(kh) = T(\\shift) u_c(kh) - S(\\shift) y(kh), \\]\nwhere\n\\begin{align*}\n R(\\shift) &= (\\shift -1)(\\shift - a_d)\\\\\n S(\\shift) &= s_0\\shift^2 + s_1\\shift + s_2\\\\\nT(\\shift) &= t_0\\shift^2 + t_1\\shift + t_2\n\\end{align*}\n\nDetermine the discrete PID controller parameters $a_d$, $s_0$, $s_1$, $s_2$, $t_0$, $t_1$ and $t_2$ using table 8.1 in the textbook (given below). \n\nUsing the special discretization (and $b=1$) we get\n\n\\begin{align*}\n  a_d &= \\frac{T_d}{Nh + T_d} = \\frac{1.42}{10h + 1.42}\\\\\n  s_0 &= K(1 + b_d) = K(1 + Na_d) = 0.575(1 + \\frac{14.2}{10h + 1.42})\\\\\n  s_1 &= -K(1 + a_d + 2b_d - b_i) = -0.575( 1 + \\frac{1.42 + 28.4}{10h + 1.42} - \\frac{h}{5.69})\\\\\n  s_2 &= K(a_d + b_d - b_ia_d) = 0.575\\frac{1.42 + 14.2 - h/5.69}{10h + 1.42}\\\\\n  t_0 &= Kb = 0.575\\\\\n  t_1 &= -K(b(1+a_d) - b_i) = -0.575( \\frac{10h + 1.42 + 1.42}{10h + 1.42} - \\frac{h}{5.69})\\\\\n  t_2 &= Ka_d(b-b_i) = 0.575 \\frac{1.42(1-\\frac{h}{5.69})}{10h + 1.42}\n\\end{align*}\n% Emacs 24.5.1 (Org mode 8.2.10)\n\\end{document}", "meta": {"hexsha": "6d32485a5585547472a2e5bd373b6fe041ca5b8f", "size": 9502, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homework/historical/hw3-discrete-pid-spring18.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "homework/historical/hw3-discrete-pid-spring18.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "homework/historical/hw3-discrete-pid-spring18.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 42.8018018018, "max_line_length": 414, "alphanum_fraction": 0.6752262682, "num_tokens": 3401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.44146453415453263}}
{"text": "\\chapter{Angular-momentum coupling for the IMSRG}\\label{ch:ang_mom_coupling}\n\nIn theoretical physics,\nthe exploitation of symmetries is essential to making\nthe solution of certain problems computationally tractable.\nIn many-body theories,\ngeneral theories can be simplified\n(in terms of computational cost)\nby exploiting the symmetries\npresent in the system and the chosen single-particle basis.\nFor rotationally invariant systems,\nthis symmetry exploitation is called angular-momentum reduction (AMR),\nwhich casts the many-body problem\ninto the language of spherical tensors\nand angular-momentum eigenstates\nand analytically simplifies\nthe angular-momentum-projection dependence\nrelated to the geometry of spherical systems.\nThe angular-momentum reduction of a many-body approach\ncan reduce the storage and computational cost by orders of magnitude,\nmaking it a very powerful tool to extend\nthe range of the approach to larger model spaces\nor in some cases make calculations possible at all.\nThe IMSRG is an excellent target for angular-momentum reduction,\nas one typically needs to push the model space\nto quite large single-particle basis truncations\nto achieve converged results.\nIn this chapter,\nwe give a brief overview of how angular-momentum reduction works\nand discuss its application\nto the IMSRG(3).\n\n\\section{Wigner-Eckart theorem}\\label{sec:amr}\n\nCore to the angular-momentum reduction formalism\nare rotational symmetry,\nformally described by the SU(2) Lie group,\nand the generator of rotations,\nthe angular momentum $\\vec{J}$.\nThe prerequisites for AMR are~\\cite{Tich20jcoupling}:\na rotationally invariant Hamiltonian, which commutes with $\\vec{J}$;\na spherical single-particle basis, which consists of eigenstates of $J^2$ and $J_{z}$;\nand a spherical reference state,\nwhich has good angular momentum $J=0$.\nIn this case, the Hamiltonian, the single-particle basis,\nand the reference state share the symmetry group SU(2),\nand one can cast the working equations of the theory\ninto a spherically symmetric form\nand perform the analytical simplifications\nto allow one to profit from AMR.\n\nAn operator $O$ can be expanded in spherical tensors $\\mathbf{O}^{J}$ of rank $J$,\neach with $2 J + 1$ components $O^{J}_{M}$~\\cite{Suho07angmom}.\nThese spherical tensors have definite transformation behavior\nunder rotations.\nSpecifically, for a given unitary transformation $U(R)$\nthat corresponds to a rotation $R$,\nthe spherical tensor components transform like~\\cite{Suho07angmom}\n\\begin{equation}\n  U(R)O^{J}_{M}U^{\\dagger}(R) = \\sum_{M'=-J}^{J} D^{J}_{M'M}(R) O_{M'}^{J}\\,,\n\\end{equation}\nwhere $D^{J}_{M'M}(R)$ are the Wigner $D$ functions,\nwhich also give the transformation of the spherical harmonics under the same rotation~\\cite{Suho07angmom}:\n\\begin{equation}\n  U(R)\\ket{j m} = \\sum_{m' = -j}^{j} D_{m' m}^{j}(R) \\ket{j m'}.\n\\end{equation}\nSpherical tensors can be further simplified by the Wigner-Eckart theorem.\nThe Wigner-Eckart theorem states\nthat the matrix elements of a spherical tensor\ncan be factorized into\na reduced matrix element that is operator-specific\nand independent of any angular-momentum projection\n(in the bra state, ket state, and the tensor component)\nand a projection-dependent part\nthat contains only geometric information\nand is independent of the specific operator~\\cite{Wign27wet,Ecka30wet}:\n\\begin{equation}\\label{eq:wet_theorem}\n  \\braket{\\xi_1 j_1 m_1 | O^{J}_{M} | \\xi_2 j_2 m_2 }\n  = (-1 )^{2J} \\frac{1}{\\hat{\\jmath}_1}\n  \\cgsymbol{j_2}{J}{j_1}{m_2}{M}{m_1}\n  \\braket{\\xi_1 j_1 || \\textbf{O}^{J} || \\xi_2 j_2}\\,,\n\\end{equation}\nwhere $\\hat{\\jmath} \\equiv \\sqrt{2 j + 1}$.\nThe states $\\ket{\\xi j m}$\nare eigenstates of\nangular momentum squared $J^2$\nand angular-momentum projection $J_{z}$,\nwith all other relevant quantum numbers\ncontained in $\\xi$.\nWe generally use the shorthand $\\ket{p} = \\ket{\\tilde{p} m_p}$,\nwhere $\\tilde{p} \\equiv \\xi_p j_p$, for simplicity.\nOccasionally, we need time-reversed states\nwith flipped angular-momentum projections,\nwhich we denote by $\\ket{\\bar{p}} \\equiv \\ket{\\tilde{p} (-m_p)}$.\nNote that the reduced single-particle index $\\tilde{p}$ is the same\nfor normal states and time-reversed states.\nNote that in Eq.~\\eqref{eq:wet_theorem}\nwe have chosen the ``Wigner'' convention for reduced matrix elements,\nwhich is also used by Suhonen, Edmonds, Racah, and Varshalovich\nand which differs from the convention used by, for example, Sakurai.\n\nEquipped with the factorization\nprovided by the Wigner-Eckart theorem\nand the choice of spherical reference state\nand single-particle basis,\none can in principle analytically perform the summations\nover all the angular-momentum-projection quantum numbers\nin a given expression.\nIntuitively,\nfor every reduced index $\\tilde{p}$ in a many-body expression,\none knows that both the reduced matrix elements\nand the reference state do not depend on $m_p$,\nso one is able to treat the entire ``shell''\nof $2 j_p + 1$ states collectively.\nThis is where the ``reduction'' part of angular-momentum reduction\ntakes place,\nsince the resulting expressions\nare completely independent of projection quantum numbers,\nand one can use a reduced representation\nfor the remaining operator-specific information\nthat does not depend on the projection quantum numbers.\n\nOne particularly convenient approach to\ndoing angular-momentum reduction\nis the diagrammatic expansion\nof an expression in a so-called Jucys graph\nand the simplification of the graph using various identities~\\cite{Vars88angmom,Worm06angmom,Lind86angmom}.\nThis approach was automated in the \\texttt{amc} code\npublished in Ref.~\\cite{Tich20jcoupling}.\nThe \\texttt{amc} program\nautomatically converts an uncoupled expression\nprovided to it via an input file written in the AMC language\ninto an equivalent $m$-independent reduced expression.\nAccomplishing this reduction by hand\nis tedious and error-prone,\nso we used this program as the primary workhorse\nfor the angular-momentum reduction in Section~\\ref{sec:amr_scalar}.\n\n\\section{Angular-momentum reduction for scalar operators}\\label{sec:amr_scalar}\n\nWe will now apply angular-momentum reduction\nto the in-medium similarity renormalization group.\nThe result of this symmetry reduction is the so-called $J$-scheme IMSRG,\nwhere the flow equations are formulated\nin terms of coupled or reduced matrix elements\nand the expressions have been reduced\nsuch that all dependence on angular-momentum projections\nhas been analytically simplified.\nIn the nuclear case,\nscalar operators play a special role in the IMSRG\nas the Hamiltonian and the generator are both scalar operators.\nThis means that the many-body formalisms\ndiscussed in Chapters~\\ref{ch:many_body} and~\\ref{ch:imsrg}\ncan be symmetry reduced for closed-shell systems\nby considering only the case of scalar spherical tensors.\nAs a result,\nthe $J$-scheme IMSRG can access energies and charge radii\nwithout needing to consider the more complicated case\nof general spherical tensor operators\n(which we give an outlook on in Section~\\ref{sec:tensor_jscheme}).\n\n\\subsection{Operator representation}\n\nSince spherical scalars are invariant under rotations\nand do not depend on any angular-momentum projection numbers,\none can work with coupled matrix elements\nrather than reduced matrix elements\n  [as in Eq.~\\eqref{eq:wet_theorem}],\nwhich differ by a simple factor\n(shown here for a one-body operator):\n\\begin{equation}\n  \\braket{\\tilde{p} | T^{0}_{0} | \\tilde{q}} =\n  \\frac{1}{\\hat{j_p}}\\braket{\\tilde{p} || \\mathbf{T}^{0} || \\tilde{q}}.\n\\end{equation}\n\nFor the IMSRG(3), we need coupled matrix elements\nfor up to three-body operators.\nThus, we need to couple our $A$-body basis\nto be made up of eigenstates of\nthe $A$-body total angular momentum squared $J^2$\nand the $z$-component of the total angular momentum $J_{z}$.\nSince our chosen single-particle basis $\\ket{p} = \\ket{\\tilde{p}m_p}$\nconsists of eigenstates of $J_{\\text{1B}}^2$ and $J_{\\text{1B},z}$\nfor the one-body angular momentum $\\vec{J}_{\\text{1B}}$,\nthe coupled matrix elements of a scalar one-body operator\nare simply the uncoupled matrix elements\n\\footnote{\n  In Eq.~\\eqref{eq:onebody_coupled_to_uncoupled},\n  $p$ and $q$ have their angular-momentum projections\n  implicitly fixed to $m_p=m_q=1/2$.\n},\n\\begin{equation}\n  O_{\\tilde{p} \\tilde{q}} = \\braket{\\tilde{p} m_p=1/2 | O | \\tilde{q} m_q=1/2} \\delta_{j_p j_q}\n  = O_{pq}\\,, \\label{eq:onebody_coupled_to_uncoupled}\n\\end{equation}\nwhere we have explicitly denoted that $O$ is diagonal in $j_p$\n\\footnote{We previously denoted $A$-body operators by $\\abodyop{O}$.\n  From this point on, we will leave off the (redundant) superscript\n  to reduce notational clutter,\n  as the many-body rank of an operator\n  can be inferred from the number of indices on its matrix elements.}.\nNote that $m_p = m_q$ could be any other value\nwithin the range given by $j_p$;\nthe matrix elements of a scalar operator will not change due to a different choice.\nWe used $m_p=1/2$ here simply because it will always be a valid choice\nfor all $j_p$ in our single-particle basis.\n\nThe representation of one-body operators can be made a bit more clear\nby adding an angular-momentum ``channel'' to the notation:\n\\begin{equation}\n  O^{j}_{pq}\\,.\n\\end{equation}\nThe channel $j$ indicates that the matrix elements of $O_{pq}$\nare diagonal in $j_p=j_q$,\nand in this channel only the indices $p$ and $q$ with\n$j_p = j_q = j$ have non-zero matrix elements.\nWe will stick with this notation\nfor coupled one-body matrix elements going forward.\n\nOur antisymmetrized two-body states\n\\begin{equation}\n  \\ket{pq} = \\crea{p} \\crea{q} \\ket{0}\n\\end{equation}\nare not eigenstates of $J_{\\text{2B}}^2$,\nonly of $J_{\\text{2B},z}$.\nCoupling the states to two-body angular momentum $J_{pq}$\ngives the coupled two-body basis,\n\\begin{equation}\\label{eq:unnormalized_twobody_basis}\n  \\ket{(\\tilde{p} \\tilde{q}) J_{pq} M_{pq}} \\equiv\n  \\sum_{m_p, m_q}\n  \\cgsymbol{j_p}{j_q}{J_{pq}}{m_p}{m_q}{M_{pq}}\n  \\ket{pq}\n  \\,,\n\\end{equation}\nwhere the coupling brackets in $\\ket{(\\tilde{p} \\tilde{q}) J_{pq} M_{pq}}$\nindicate that $j_p$ and $j_q$ are coupled to $J_{pq}$\n(and the rest of the quantum numbers in $\\tilde{p}$ and $\\tilde{q}$ are not involved).\nNote that the Clebsch-Gordan coefficients\n\\begin{equation}\n  \\cgsymbol{j_p}{j_q}{J_{pq}}{m_p}{m_q}{M_{pq}}\n\\end{equation}\nare defined such that they are 0\nif $M_{pq} \\neq m_p + m_q$,\ncollapsing one of the sums over angular-momentum projections.\nThe two-body states in Eq.~\\eqref{eq:unnormalized_twobody_basis}\nare not normalized,\nwhich can be remedied by multiplying them with the following factor~\\cite{Suho07angmom}:\n\\begin{equation}\n  N_{pq(J_{pq})} \\equiv \\frac{\\sqrt{1 + (-1)^{J_{pq}}\n      \\delta_{\\tilde{p} \\tilde{q}}}}{1 + \\delta_{\\tilde{p} \\tilde{q}}}.\n\\end{equation}\nHowever, the coupled many-body expressions\n(and their numerical implementations)\nare simpler when using unnormalized coupled two- and three-body matrix elements.\n\nThe unnormalized coupled two-body matrix elements of\na scalar two-body operator $O$ are given by\n\\begin{samepage}\n  \\begin{align}\n    O^{J_{pq}}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}}\n     & \\equiv \\braket{\n      (\\tilde{p} \\tilde{q})J_{pq} M_{pq}=0|\n      O\n      |(\\tilde{r} \\tilde{s})J_{pq} M_{pq}=0\n    }                           \\\\\n     & =\\sum_{\\substack{m_p,m_q \\\\ m_r,m_s}}\n    \\cgsymbol{j_p}{j_q}{J_{pq}}{m_p}{m_q}{M_{pq} = 0}\n    \\cgsymbol{j_r}{j_s}{J_{pq}}{m_r}{m_s}{M_{pq} = 0}\n    O_{pqrs}\\,.\\label{eq:unnormalized_twobody_mels}\n  \\end{align}\n\\end{samepage}\nOur representation builds the diagonality of the matrix elements\nin $J_{pq} = J_{rs}$ into the notation,\nas indicated by the $J_{pq}$ channel in the superscript.\nAgain, $M_{pq} = 0$ is a choice we have made that works\nfor all sets of $\\tilde{p}$ and $\\tilde{q}$.\nIt is worth noting that not all $\\tilde{p} \\tilde{q}$\n(or $\\tilde{r} \\tilde{s}$) combinations\ncan couple to a given $J_{pq}$.\nThis is not a problem, because in Eq.~\\eqref{eq:unnormalized_twobody_mels}\nthe Clebsch-Gordan coefficients cause those matrix elements to be 0.\nThis means they do not unphysically contribute in any many-body expressions.\nIn numerical implementations,\nthe exploitation of this reduction in the number of valid two-body states\nin a given angular-momentum channel\nis essential to improving performance to the point\nwhere calculations in large model spaces are possible.\n\nThe definition of the coupled three-body basis follows analogously,\n\\begin{equation}\\label{eq:unnormalized_threebody_basis}\n  \\ket{[(\\tilde{p} \\tilde{q}) J_{pq} \\tilde{r}] J_{pqr} M_{pqr}} \\equiv\n  \\sum_{m_r, M_{pq}}\n  \\cgsymbol{J_{pq}}{j_r}{J_{pqr}}{M_{pq}}{m_r}{M_{pqr}}\n  \\sum_{m_p, m_q}\n  \\cgsymbol{j_p}{j_q}{J_{pq}}{m_p}{m_q}{M_{pq}}\n  \\ket{pqr}\n  \\,,\n\\end{equation}\nwhere we have selected the ``standard'' coupling order\nwith $j_p$ and $j_q$ coupled first to $J_{pq}$\nand then $J_{pq}$ and $j_r$ coupled to $J_{pqr}$.\nOnce again, these states are not normalized,\nbut working with unnormalized states is more convenient.\n\nThe unnormalized coupled matrix elements of a three-body operator $O$\nare given by\n\\begin{align}\n  \\phantom{O^{(J_{pqr}, J_{pq}, J_{st})}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}}\n   & \\begin{aligned}\n    \\mathllap{O^{(J_{pqr}, J_{pq}, J_{st})}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}}\n    \\equiv \\braket{\n    [(\\tilde{p} \\tilde{q})J_{pq} \\tilde{r}] J_{pqr} M_{pqr} = 1/2 |\n    O\n    | [(\\tilde{s} \\tilde{t})J_{st} \\tilde{u}] J_{pqr} M_{pqr} = 1/2\n    }\n  \\end{aligned} \\\\\n   & \\begin{aligned}\n    \\mathllap{}\n    = \\sum_{\\substack{m_p,m_q,m_r,M_{pq}                     \\\\ m_s,m_t,m_u,M_{st}}} &\n    \\cgsymbol{j_p}{j_q}{J_{pq}}{m_p}{m_q}{M_{pq}}\n    \\cgsymbol{j_s}{j_t}{J_{st}}{m_s}{m_t}{M_{st}}            \\\\\n     & \\cgsymbol{J_{pq}}{j_r}{J_{pqr}}{M_{pq}}{m_r}{M_{pqr}=1/2}\n    \\cgsymbol{J_{st}}{j_u}{J_{pqr}}{M_{st}}{m_u}{M_{pqr}=1/2}    \\\\\n     & O_{pqrstu}\n    \\,.\n  \\end{aligned}\n\\end{align}\nThe channel structure of the three-body matrix elements\nhas grown more complicated,\nwith the channel including the diagonal total three-body angular momentum\n$J_{pqr} = J_{stu}$\nand the intermediate couplings $J_{pq}$ and $J_{st}$.\nThese intermediate couplings can take on different values,\nsubstantially increasing the number of three-body channels\nfor which we need to handle matrix elements.\nAgain, $M_{pqr} = 1/2$ is a choice we have made that works\nfor all sets of $\\tilde{p}$, $\\tilde{q}$, and $\\tilde{r}$.\n\nAt this point, it is useful to discuss the symmetry properties\nof these matrix elements.\nFor a Hermitian operator\nthe coupled matrix elements have the following properties:\n\\begin{samepage}\n  \\begin{subequations}\n    \\begin{align}\n      O_{\\tilde{p}\\tilde{q}}                                                                 & = O_{\\tilde{q}\\tilde{p}}\\,, \\\\\n      O^{J_{pq}}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}}                                      & =\n      O^{J_{pq}}_{\\tilde{r}\\tilde{s}\\tilde{p}\\tilde{q}}\\,,                                                                 \\\\\n      O^{(J_{pqr}, J_{pq}, J_{st})}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}} & =\n      O^{(J_{pqr}, J_{st}, J_{pq})}_{\\tilde{s}\\tilde{t}\\tilde{u}\\tilde{p}\\tilde{q}\\tilde{r}}\\,.\\label{eq:coupled_herm_threebody}\n    \\end{align}\n  \\end{subequations}\n\\end{samepage}\nNote the transposition of the intermediate couplings\nin the three-body channel in Eq.~\\eqref{eq:coupled_herm_threebody}.\nFor an anti-Hermitian operator\nthe coupled matrix elements have the following properties:\n\\begin{subequations}\n  \\begin{align}\n    O_{\\tilde{p}\\tilde{q}}                                                                 & = - O_{\\tilde{q}\\tilde{p}}\\,, \\\\\n    O^{J_{pq}}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}}                                      & =\n    - O^{J_{pq}}_{\\tilde{r}\\tilde{s}\\tilde{p}\\tilde{q}}\\,,                                                                 \\\\\n    O^{(J_{pqr}, J_{pq}, J_{st})}_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}} & =\n    - O^{(J_{pqr}, J_{st}, J_{pq})}_{\\tilde{s}\\tilde{t}\\tilde{u}\\tilde{p}\\tilde{q}\\tilde{r}}\\,.\\label{eq:coupled_antiherm_threebody}\n  \\end{align}\n\\end{subequations}\n\nOur two- and three-body matrix elements are also antisymmetric,\nalthough this symmetry is not realized as simply\nfor coupled matrix elements as it is for uncoupled matrix elements.\nTwo-body matrix elements have the following properties:\n\\begin{subequations}\n  \\begin{align}\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}}^{J_{pq}} & =\n    - (-1)^{j_p + j_q - J_{pq}}\n    O_{\\tilde{q}\\tilde{p}\\tilde{r}\\tilde{s}}^{J_{pq}}\\,,  \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}}^{J_{pq}} & =\n    - (-1)^{j_r + j_s - J_{pq}}\n    O_{\\tilde{p}\\tilde{q}\\tilde{s}\\tilde{r}}^{J_{pq}}\\,.\n  \\end{align}\n\\end{subequations}\nThree-body matrix elements have the following properties:\n\\begin{subequations}\n  \\begin{align}\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    - (-1)^{j_p + j_q - J_{pq}}\n    O_{\\tilde{q}\\tilde{p}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})}\\,,  \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    \\hat{J}_{pq}\n    \\sum_{J_{2}} \\hat{J}_{2}\n    \\sixj{j_p}{j_q}{J_{pq}}{j_r}{J_{pqr}}{J_{2}}\n    O_{\\tilde{r}\\tilde{q}\\tilde{p}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{2}, J_{st})}\\,,   \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    - (-1)^{j_q + j_r - J_{pq}}\n    \\hat{J}_{pq}\n    \\sum_{J_{2}} \\hat{J}_{2} (-1)^{J_{2}}\n    \\sixj{j_q}{j_p}{J_{pq}}{j_r}{J_{pqr}}{J_{2}}\n    O_{\\tilde{p}\\tilde{r}\\tilde{q}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{2}, J_{st})}\\,,   \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    - (-1)^{j_s + j_t - J_{st}}\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{t}\\tilde{s}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})}\\,,  \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    \\hat{J}_{st}\n    \\sum_{J_{2}} \\hat{J}_{2}\n    \\sixj{j_s}{j_t}{J_{st}}{j_u}{J_{pqr}}{J_{2}}\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{u}\\tilde{t}\\tilde{s}}^{(J_{pqr}, J_{pq}, J_{2})}\\,,   \\\\\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{t}\\tilde{u}}^{(J_{pqr}, J_{pq}, J_{st})} & =\n    - (-1)^{j_t + j_u - J_{st}}\n    \\hat{J}_{st}\n    \\sum_{J_{2}} \\hat{J}_{2} (-1)^{J_{2}}\n    \\sixj{j_t}{j_s}{J_{st}}{j_u}{J_{pqr}}{J_{2}}\n    O_{\\tilde{p}\\tilde{q}\\tilde{r}\\tilde{s}\\tilde{u}\\tilde{t}}^{(J_{pqr}, J_{pq}, J_{2})}\\,.\n  \\end{align}\n\\end{subequations}\nWe provide only the pairwise antisymmetry properties,\nas the relations for the remaining permutations\ncan be obtained by applying pairwise permutations.\n\nAt this point, we drop the cumbersome ``tilde'' notation\nfor reduced state indices.\nThe channels on matrix elements should make it clear\nwhether the matrix elements are coupled or not.\nAdditionally, in the surrounding text,\nwe make it clear whether an expression\nis coupled or uncoupled.\n\n\\subsection{Coupled many-body expressions}\\label{sec:jscheme_many_body_expressions}\n\nIn addition to the fundamental commutators,\nIMSRG calculations typically employ a couple standard operations,\nwhich we discuss here.\nThe first is bringing the initial Hamiltonian into normal order\nwith respect to the employed $A$-body reference state.\nGiven a Hamiltonian $H$ with one- through three-body parts,\nthe coupled expressions for\nthe matrix elements of the normal-ordered Hamiltonian are\n\\begin{subequations}\n  \\begin{align}\n    \\phantom{W_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})}}\n     & \\begin{aligned}\n      \\mathllap{E} = \\bar{H} & = \\sum_{j_{a}} \\hat{\\jmath}^{2}_a \\sum_{a} H_{aa}^{j_{a}}\n      + \\frac{1}{2} \\sum_{J_{ab}} \\hat{J}_{ab}^2 \\sum_{ab} H_{abab}^{J_{ab}}             \\\\\n                             & \\quad\n      + \\frac{1}{6} \\sum_{J_{ab} J_{abc}} \\hat{J}_{abc}^2 \\sum_{abc}  H_{abcabc}^{(J_{abc}, J_{ab}, J_{ab})}\\,,\n    \\end{aligned} \\\\\n     & \\begin{aligned}\n      \\mathllap{f_{pq}^{j_p}} = \\bar{H}_{pq}^{j_p} &\n      = H_{pq}^{j_p}\n      + \\frac{1}{\\hat{\\jmath}_{p}^2} \\sum_{J_{pa}} \\hat{J}_{pa}^2 \\sum_{a} H_{paqa}^{J_{pa}} \\\\\n                                                   & \\quad\n      + \\frac{1}{2 \\hat{\\jmath}_{p}^2} \\sum_{J_{pa} J_{pab}} \\hat{J}_{pab}^2 \\sum_{ab}  H_{pabqab}^{(J_{pab}, J_{pa}, J_{pa})}\\,,\n    \\end{aligned} \\\\\n     & \\begin{aligned}\n      \\mathllap{\\Gamma_{pqrs}^{J_{pq}}} = \\bar{H}_{pqrs}^{J_{pq}}\n       & = H_{pqrs}^{J_{pq}}\n      + \\frac{1}{\\hat{J}_{pq}^2} \\sum_{J_{pqa}} \\hat{J}_{pqa}^2 \\sum_{a} H_{pqarsa}^{(J_{pqa}, J_{pq}, J_{pq})} \\,,\n    \\end{aligned} \\\\\n     & \\begin{aligned}\n      \\mathllap{W_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})}} = \\bar{H}_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} & = H_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} \\,.\n    \\end{aligned}\n  \\end{align}\n\\end{subequations}\nRecall our previous convention that\nthe indices $p$, $q$, $r$, \\ldots\\ run over all single-particle states,\nthe indices $i$, $j$, $k$, \\ldots\\ run over hole states,\nand the indices $a$, $b$, $c$, \\ldots\\ run over particle states.\n\nNext, we need an antisymmetrizer for our two- and three-body matrix elements.\nThis is because the fundamental commutators in Section~\\ref{sec:jscheme_fundamental_comm}\nare not antisymmetrized to simplify the expressions and the numerical implementations.\nThus, we need to explicitly restore the antisymmetry of some index combinations\nafter evaluating the non-antisymmetrized fundamental commutators.\nIn the two-body case,\nthe antisymmetrizer is\n\\begin{equation}\\label{eq:twobody_antisymmetrizer}\n  \\mathcal{A}_{\\text{2B}} \\equiv\\mathcal{A}_{pq} \\mathcal{A}_{rs}\\,,\n\\end{equation}\nwith\n\\begin{equation}\n  \\mathcal{A}_{pq} \\equiv \\frac{1}{2}(1 - P_{pq})\\,.\n\\end{equation}\nRecall that in the uncoupled expressions in Chapter~\\ref{ch:imsrg}\nthe permutation operator $P_{pq}$ simply exchanged the indices $p$ and $q$ in the following expression.\nNow that indices are coupled,\nthe action of permutation operators is complicated\nby the fact that they also change the coupling order.\nTo implement $\\mathcal{A}_{\\text{2B}}$,\nall we need are the expressions for the action of $P_{pq}$\nand $P_{rs}$ on two-body matrix elements:\n\\begin{subequations}\n  \\begin{align}\n    O_{pqrs}^{J_{pq}} & \\xleftarrow{P_{pq}} (-1)^{j_p + j_q - J_{pq}} O_{qprs}^{J_{pq}}\\,, \\\\\n    O_{pqrs}^{J_{pq}} & \\xleftarrow{P_{rs}} (-1)^{j_r + j_s - J_{pq}} O_{pqsr}^{J_{pq}}\\,.\n  \\end{align}\n\\end{subequations}\nUsing these operations along with scalar multiplication of and addition of matrix elements,\nthe implementation of a two-body antisymmetrizer is simple.\n\nIn the three-body case,\nthe antisymmetrizer is\n\\begin{equation}\\label{eq:threebody_antisymmetrizer}\n  \\mathcal{A}_{\\text{3B}} \\equiv \\mathcal{A}_{pqr} \\mathcal{A}_{stu}\\,,\n\\end{equation}\nwith\n\\begin{equation}\n  \\mathcal{A}_{pqr} \\equiv \\frac{1}{6}(1 + P_{prq} + P_{prq}^2)(1 - P_{pq})\\,.\n\\end{equation}\nHere $P_{prq}$ cyclically permutes the indices $p$, $q$, and $r$ such that\n\\begin{equation}\n  (p, q, r) \\xrightarrow{P_{prq}} (q, r, p) \\xrightarrow{P_{prq}} (r, p, q) \\xrightarrow{P_{prq}} (p, q, r)\\,.\n\\end{equation}\nThere are other ways to define $\\mathcal{A}_{pqr}$,\nfor example in terms of $P_{pq}$ and $P_{qr}$.\nThey are all equivalent,\nand which one one chooses is a matter of preference.\nThe action of $P_{prq}$, $P_{pq}$, $P_{sut}$, and $P_{st}$\non three-body matrix elements is given by\n\\begin{subequations}\n  \\begin{align}\n    O_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} &\n    \\xleftarrow{P_{prq}}\n    -1 (-1)^{j_p + j_q - J_{pq}} \\hat{J}_{pq}\n    \\sum_{J_{2}} \\hat{J}_{2}\n    \\sixj{j_q}{j_p}{J_{pq}}{j_r}{J_{pqr}}{J_{2}}\n    O_{rpqstu}^{(J_{pqr}, J_{2}, J_{st})}\\,,  \\\\\n    O_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} &\n    \\xleftarrow{P_{pq}}\n    (-1)^{j_p + j_q - J_{pq}}\n    O_{qprstu}^{(J_{pqr}, J_{pq}, J_{st})}\\,, \\\\\n    O_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} &\n    \\xleftarrow{P_{sut}}\n    -1 (-1)^{j_s + j_t - J_{st}} \\hat{J}_{st}\n    \\sum_{J_{2}} \\hat{J}_{2}\n    \\sixj{j_t}{j_s}{J_{st}}{j_u}{J_{pqr}}{J_{2}}\n    O_{pqrust}^{(J_{pqr}, J_{pq}, J_{2})}\\,,  \\\\\n    O_{pqrstu}^{(J_{pqr}, J_{pq}, J_{st})} &\n    \\xleftarrow{P_{st}}\n    (-1)^{j_s + j_t - J_{st}}\n    O_{pqrtsu}^{(J_{pqr}, J_{pq}, J_{st})}\\,.\n  \\end{align}\n\\end{subequations}\nWith these basic operations in hand,\none can implement a general three-body antisymmetrizer.\n\nFinally, the second-order M{\\o}ller-Plesset MBPT (MP2) energy correction\nis a critical diagnostic for the IMSRG\nas it is directly proportional to the matrix elements\nthat the IMSRG evolution should suppress.\nThe coupled expression for the MP2 energy correction is\n\\begin{equation}\n  E_{\\text{MP2}} =\n  - \\sum_{j_{a}} \\hat{\\jmath}_{a}^2 \\sum_{ai} \\frac{|f_{ai}^{j_a}|^2}{\\epsilon_{i}^{a}}\n  - \\frac{1}{4} \\sum_{J_{ab}} \\hat{J}_{ab}^2 \\sum_{abij}\n  \\frac{|\\Gamma_{abij}^{J_{ab}}|^2}{\\epsilon_{ij}^{ab}}\n  - \\frac{1}{36} \\sum_{J_{abc} J_{ab} J_{ij}} \\hat{J}_{abc}^2 \\sum_{abcijk}\n  \\frac{|W_{abcijk}^{(J_{abc}, J_{ab}, J_{ij})}|^2}{\\epsilon_{ijk}^{abc}}\\,,\n\\end{equation}\nwith\n\\begin{align}\n  \\epsilon_{ij\\cdots}^{ab\\cdots} & = e_a + e_b + \\cdots - (e_i + e_j + \\cdots)\\,, \\\\\n  e_p                            & = f_{pp}\\,,\n\\end{align}\nas in Eq.~\\eqref{eq:mp_energy_denom}.\n\n\\subsection{Coupled fundamental commutators}\\label{sec:jscheme_fundamental_comm}\n\nIn this section,\nwe present the coupled expressions for\nthe fundamental commutators of two scalar operators.\nThese expressions were obtained using\nthe \\texttt{amc} code from Ref.~\\cite{Tich20jcoupling}\non the uncoupled commutator expressions\ngiven in Appendix~\\ref{app:mscheme_fundamental_commutators}.\nWhile this approach immediately produced desirable results\nfor some commutators,\nfor many it was possible to simplify the resulting expressions\nby exploiting symmetries of the uncoupled expressions.\nWe discuss examples of these simplifications in Appendix~\\ref{app:jscheme_commutator_tricks}.\nHere, we will only show the simplest expressions\nwe were able to produce.\n\nThe commutator expressions are ``fundamental'' in the sense\nthat they are the basic operations required for any IMSRG(3) implementation.\nUsing these expressions,\none can quickly combine and expand them to produce\nthe full IMSRG(3) flow equations (see Section~\\ref{sec:imsrgthree}),\nand one can also easily implement\nthe series of nested commutators required by\nthe Magnus and BCH expansions (see Section~\\ref{sec:imsrg_magnus}).\nThus, correctly and efficiently implementing these expressions\nconstitutes the main challenge of any IMSRG implementation.\n\nThe commutator of a $K$-body and an $L$-body operator\ngives an operator with \\mbox{$|K-L|$-} to $(K+L-1)$-body parts:\n\\begin{equation}\n  \\left[A^{(K)}, B^{(L)}\\right] = \\sum_{M=|K - L|}^{K + L - 1} C^{(M)}\\,.\n\\end{equation}\nThe expressions we give below are\nfor the coupled matrix elements of the different $M$-body terms.\nIn the IMSRG(3), we discard any four- and five-body parts induced,\nwhich appear in principle\nin the commutator of a two-body and a three-body operator\nand in the commutator of two three-body operators.\nWe focus on the case where $A$ and $B$ and thus the resulting $C$ are scalar operators.\n\nNote that expressions for two- and three-body matrix elements\nare not antisymmetrized,\nso the appropriate antisymmetrizer must be applied\n  [see Eqs.~\\eqref{eq:twobody_antisymmetrizer} and~\\eqref{eq:threebody_antisymmetrizer}]\nto the matrix elements after evaluating the commutator.\nWe break our typical index label convention\nto use the convention that the index labels $i$,~$j$,~$k$,~\\ldots\\\nare reserved for external indices,\nthat is, indices appearing on the matrix elements of the resulting operator,\nand the index labels $a$,~$b$,~$c$,~\\ldots\\\nare reserved for contracted indices,\nthat is, indices that are summed over in the matrix elements of the input operators.\nAs in Chapter~\\ref{ch:imsrg}, $\\bar{n}_a = 1 - n_a$.\n\n\\subsubsection{\n  \\texorpdfstring{$[\\onebodyop{A}, \\onebodyop{B}]$}{[1, 1]}\n}\n\nThe commutator of two one-body operators has\nzero- and one-body parts.\n\nThe resulting zero-body contribution is given by the coupled expression\n\\begin{equation}\n  C = \\sum_{j_a} \\hat{\\jmath}^{2}_{a} \\sum_{ab} (n_a - n_b) A_{ab}^{j_a} B_{ba}^{j_a}\\,.\n\\end{equation}\n\nThe resulting coupled one-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ij}^{j_i} = \\sum_{a}(A_{ia}^{j_i} B_{aj}^{j_i} - B_{ia}^{j_i} A_{aj}^{j_i})\\,.\n\\end{equation}\n\n\\subsubsection{\n  \\texorpdfstring{$[\\onebodyop{A}, \\twobodyop{B}]$}{[1, 2]}\n}\n\nThe commutator of a one-body operator and a two-body operator has\none- and two-body parts.\n\nThe resulting coupled one-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ij}^{j_i} = \\frac{1}{\\hat{\\jmath}_{i}^2} \\sum_{j_a} \\sum_{J_2} \\hat{J}_{2}^2\n  \\sum_{ab} (n_a \\bar{n}_b - \\bar{n}_a n_b) A_{ab}^{j_a} B_{iajb}^{J_2}\\,.\n\\end{equation}\n\nThe resulting coupled two-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijkl}^{J_C} = 2 \\sum_{j_a} \\sum_{a} \\left(\n  A_{ia}^{j_a} B_{ajkl}^{J_C} - A_{ak}^{j_a} B_{ijal}^{J_C}\n  \\right)\n  \\,.\n\\end{equation}\n\n\\subsubsection{\n  \\texorpdfstring{$[\\twobodyop{A}, \\twobodyop{B}]$}{[2, 2]}\n}\n\nThe commutator of two two-body operators has\nzero- through three-body parts.\n\nThe resulting zero-body contribution is given by the coupled expression\n\\begin{equation}\n  C = \\frac{1}{4}\\sum_{J_{ab}} \\hat{J}_{ab}^{2}\\sum_{abcd}\n  (n_a n_b \\bar{n}_c \\bar{n}_d - \\bar{n}_a \\bar{n}_b n_c n_d)\n  A_{abcd}^{J_{ab}} B_{cdab}^{J_{ab}}\\,.\n\\end{equation}\n\nThe resulting coupled one-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ij}^{j_i} = \\frac{1}{2} \\frac{1}{\\hat{\\jmath}_{i}^2}\n  \\sum_{J_{ab}} \\hat{J}_{ab}^2\n  \\sum_{abc}\n  (\\bar{n}_a \\bar{n}_b n_c + n_a n_b \\bar{n}_c)\n  (A_{ciab}^{J_{ab}} B_{abcj}^{J_{ab}} - B_{ciab}^{J_{ab}} A_{abcj}^{J_{ab}})\\,.\n\\end{equation}\n\nThe resulting coupled two-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C^{J_C}_{ijkl}\n  =\n  D^{J_C}_{ijkl}\n  + E^{J_C}_{ijkl}\\,,\n\\end{equation}\nwith\n\\begin{align}\n  D^{J_C}_{ijkl}                        & \\equiv \\frac{1}{2} \\sum_{ab}\n  (\\bar{n}_a \\bar{n}_b - n_a n_b)\n  \\left(\n  A_{ijab}^{J_C} B_{abkl}^{J_C} - B_{ijab}^{J_C} A_{abkl}^{J_C}\n  \\right)\\,,                                                           \\\\\n  \\overline{E}_{i\\bar{l}k\\bar{j}}^{J_C} & \\equiv 4 \\sum_{ab}\n  (n_a \\bar{n}_b - \\bar{n}_a n_b)\n  \\overline{A}_{a\\bar{b}k\\bar{j}}^{J_C}\n  \\overline{B}_{i\\bar{l}a\\bar{b}}^{J_C}\\,. \\label{eq:comm222_term2}\n\\end{align}\nThe expression in Eq.~\\eqref{eq:comm222_term2} is written\nin terms of Pandya-transformed matrix elements,\nwhere the two-body Pandya transformation is given by~\\cite{Pand56pandya}\n\\begin{equation}\n  \\overline{O}_{p\\bar{q}r\\bar{s}}^{J_{2}} \\equiv\n  - \\sum_{J_{2}'}\n  \\hat{J}_{2}^{\\prime 2}\n  \\sixj{j_p}{j_q}{J_{2}}{j_r}{j_s}{J_{2}'}\n  O_{prqs}^{J_{2}'}\\,.\n\\end{equation}\nThe indices $\\bar{q}$ and $\\bar{s}$ are time reversed,\nthat is, their angular-momentum projections are flipped.\nSince we are working with reduced indices\nwithout angular-momentum projections everywhere,\nthis distinction is irrelevant,\nbut we keep the modified indices around to be formally precise.\nThe Pandya-transformed matrix elements\nare useful intermediates that isolate recoupling on $A$, $B$, and $E$\nthat can be done independently.\nThe resulting $\\overline{E}$ must be\nconverted back to normal coupled matrix elements\nby a final Pandya transformation\nbefore being added to $D$ to give $C$.\n\nThe resulting coupled three-body matrix elements are given by the coupled expression\n\\begin{equation}\n  \\begin{split}\n    C_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})} & =\n    -9 (-1)^{J_{C,lm}} \\hat{J}_{C,ij} \\hat{J}_{C,lm}\n    \\sum_{a} (-1)^{j_a + j_k}\n    \\sixj{j_k}{j_a}{J_{C,lm}}{j_{n}}{J_{C,3}}{J_{C,ij}} \\\\\n    & \\quad \\quad \\times \\left(\n    A_{ijna}^{J_{C,ij}} B_{aklm}^{J_{C,lm}}\n    - B_{ijna}^{J_{C,ij}} A_{aklm}^{J_{C,lm}}\n    \\right).\n  \\end{split}\n\\end{equation}\n\n\\subsubsection{\n  \\texorpdfstring{$[\\onebodyop{A}, \\threebodyop{B}]$}{[1, 3]}\n}\n\nThe commutator of a one-body operator and a three-body operator has\ntwo- and three-body parts.\n\nThe resulting coupled two-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijkl}^{J_C} = \\frac{1}{\\hat{J}_{C}^2}\n  \\sum_{j_a}\n  \\sum_{J_{B,3}} \\hat{J}_{B,3}^2\n  \\sum_{ab} (n_a \\bar{n}_b - \\bar{n}_a n_b)\n  A_{ab}^{j_a} B_{ijbkla}^{(J_{B,3}, J_{C}, J_{C})}\\,.\n\\end{equation}\n\nThe resulting coupled three-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})} =\n  3 \\sum_{j_a} \\sum_{a}\n  \\left(\n  A_{ia}^{j_a} B_{ajklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n  - A_{la}^{j_a} B_{ijkamn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n  \\right).\n\\end{equation}\n\n\\subsubsection{\n  \\texorpdfstring{$[\\twobodyop{A}, \\threebodyop{B}]$}{[2, 3]}\n}\n\nThe commutator of a two-body operator and a three-body operator has\none- through three-body parts.\n\nThe resulting coupled one-body matrix elements are given by the coupled expression\n\\begin{equation}\n  \\begin{split}\n    C_{ij}^{j_i} &= - \\frac{1}{4} \\frac{1}{\\hat{\\jmath}_{i}^2}\n    \\sum_{(J_{B,3}, J_{ab})}\n    \\hat{J}_{B,3}^2\n    \\sum_{abcd}\n    (n_a n_b \\bar{n}_c \\bar{n}_d - \\bar{n}_a \\bar{n}_b n_c n_d)\n    A_{cdab}^{J_{ab}} B_{abicdj}^{(J_{B,3}, J_{ab}, J_{ab})}\\,.\n  \\end{split}\n\\end{equation}\n\nThe resulting coupled two-body matrix elements are given by the coupled expression\n\\begin{equation}\n  \\begin{split}\n    C_{ijkl}^{J_C} &= \\frac{(-1)^{J_C}}{\\hat{J}_C}\n    \\sum_{J_A, J_{B,3}} \\hat{J}_A \\hat{J}_{B,3}^2\n    \\sum_{abc}\n    (n_a \\bar{n}_b \\bar{n}_c + \\bar{n}_a n_b n_c) \\\\\n    & \\quad \\left(\n    (-1)^{j_k + j_l}\n    \\sixj{j_l}{j_k}{J_C}{j_a}{J_{B,3}}{J_A}\n    A_{bcak}^{J_A} B_{ijabcl}^{(J_{B,3}, J_C, J_A)}\n    \\right.\\\\\n    &\\quad\\quad \\left. + (-1)^{j_i + j_j}\n    \\sixj{j_j}{j_i}{J_C}{j_a}{J_{B,3}}{J_A}\n    A_{bcai}^{J_A} B_{klabcj}^{(J_{B,3}, J_C, J_A)}\n    \\right)\\,.\n  \\end{split}\n\\end{equation}\n\nThe resulting coupled three-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijklmn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\n  = D_{ijklmn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\n  + E_{ijklmn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\\,,\n\\end{equation}\nwith\n\\begin{align}\n  D_{ijklmn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\n   & \\equiv \\frac{3}{2} \\sum_{ab} (\\bar{n}_a \\bar{n}_b - n_a n_b)\n  A_{ijab}^{J_{C, ij}}\n  B_{abklmn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\\,,                 \\\\\n  E_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n   & \\equiv\n  -\\frac{3}{2} \\sum_{ab} (\\bar{n}_a \\bar{n}_b - n_a n_b)\n  A_{ablm}^{J_{C, lm}}\n  B_{ijkabn}^{(J_{C,3}, J_{C, ij}, J_{C, lm})}\\,.\n\\end{align}\n\n\\subsubsection{\n  \\texorpdfstring{$[\\threebodyop{A}, \\threebodyop{B}]$}{[3, 3]}\n}\n\nThe commutator of two three-body operators has\nzero- through three-body parts.\n\nThe resulting zero-body contribution is given by the coupled expression\n\\begin{equation}\n  C = \\frac{1}{36}\n  \\sum_{(J_3, J_{ab}, J_{de})} \\hat{J}_{3}^2\n  \\sum_{abcdef}\n  (\n  n_a n_b n_c \\bar{n}_d \\bar{n}_e \\bar{n}_f\n  - \\bar{n}_a \\bar{n}_b \\bar{n}_c n_d n_e n_f\n  )\n  A_{abcdef}^{(J_{3}, J_{ab}, J_{de})}\n  B_{defabc}^{(J_{3}, J_{de}, J_{ab})}\\,.\n\\end{equation}\n\nThe resulting coupled one-body matrix elements are given by the coupled expression\n\\begin{equation}\n  \\begin{split}\n    C_{ij}^{j_i} & = \\frac{1}{12} \\frac{1}{\\hat{j}_{i}^2}\n    \\sum_{(J_{3}, J_{ab}, J_{cd})} \\hat{J}_{3}^2\n    \\sum_{abcde} (\n    n_a n_b \\bar{n}_c \\bar{n}_d \\bar{n}_e\n    + \\bar{n}_a \\bar{n}_b n_c n_d n_e\n    ) \\\\\n    & \\quad \\left(\n    A_{abicde}^{(J_3, J_{ab}, J_{cd})}\n    B_{cdeabj}^{(J_3, J_{cd}, J_{ab})}\n    - B_{abicde}^{(J_3, J_{ab}, J_{cd})}\n    A_{cdeabj}^{(J_3, J_{cd}, J_{ab})}\n    \\right).\n  \\end{split}\n\\end{equation}\n\nThe resulting coupled two-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijkl}^{J_C}\n  = D_{ijkl}^{J_C}\n  + E_{ijkl}^{J_C}\\,,\n\\end{equation}\nwith\n\\begin{align}\n  \\phantom{D_{ijkl}^{J_C}}\n   & \\begin{aligned}\n    \\mathllap{D_{ijkl}^{J_C}} & \\equiv\n    \\frac{1}{6} \\frac{1}{\\hat{J}_{C}^2}\n    \\sum_{(J_3, J_{bc})}\n    \\sum_{abcd}\n    (\n    n_a \\bar{n}_b \\bar{n}_c \\bar{n}_d\n    - \\bar{n}_a n_b n_c n_d\n    )                                  \\\\\n                              & \\quad\n    \\left(\n    A_{ijabcd}^{(J_3, J_C, J_{bc})} B_{bcdkla}^{(J_3, J_{bc}, J_C)}\n    - B_{ijabcd}^{(J_3, J_C, J_{bc})} A_{bcdkla}^{(J_3, J_{bc}, J_C)}\n    \\right),\n  \\end{aligned} \\\\\n  \\phantom{D_{ijkl}^{J_C}}\n   & \\begin{aligned}\n    \\mathllap{E_{ijkl}^{J_C}} & \\equiv\n    (-1)^{j_j + j_l}\n    \\sum_{(J_{A,3}, J_{ab}, J_{cd})}\n    (-1)^{J_{ab} + J_{cd}} \\hat{J}_{A,3}^2\n    \\sum_{J_{B,3}}\n    \\hat{J}_{B,3}^2                    \\\\\n                              & \\quad\n    \\ninej{j_i}{J_{A,3}}{J_{ab}}{j_j}{J_{cd}}{J_{B,3}}{J_{C}}{j_l}{j_k}\n    \\sum_{abcd}\n    (\n    \\bar{n}_a \\bar{n}_b n_c n_d\n    - n_a n_b \\bar{n}_c \\bar{n}_d\n    )                                  \\\\\n                              & \\quad\n    A_{abicdk}^{(J_{A,3}, J_{ab}, J_{cd})}\n    B_{cdjabl}^{(J_{B,3}, J_{cd}, J_{ab})}\\,.\n  \\end{aligned}\n\\end{align}\n\nThe resulting coupled three-body matrix elements are given by the coupled expression\n\\begin{equation}\n  C_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n  = D_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n  + E_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\n  + F_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}\\,,\n\\end{equation}\nwith\n\\begin{align}\n  \\phantom{D_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}}\n   & \\begin{aligned}\n    \\mathllap{D_{ijklmn}^{(J_{C,3}, J_{C,ij}, J_{C,lm})}}\n     & \\equiv \\frac{1}{6} \\sum_{J_{ab}}\n    \\sum_{ab}\n    (n_a n_b n_c + \\bar{n}_a \\bar{n}_b \\bar{n}_c)\n    \\\\\n     & \\quad \\left(\n    A_{ijkabc}^{(J_{C,3}, J_{C,ij}, J_{ab})}\n    B_{abclmn}^{(J_{C,3}, J_{ab}, J_{C,lm})}\n    - B_{ijkabc}^{(J_{C,3}, J_{C,ij}, J_{ab})}\n    A_{abclmn}^{(J_{C,3}, J_{ab}, J_{C,lm})}\n    \\right)\\,.\n  \\end{aligned}                         \\\\\n   & \\begin{aligned}\n    \\mathllap{\\overline{E}_{ij\\bar{n}lm\\bar{k}}^{(J_{3},J_{C,ij},J_{C,lm})}} \\equiv\n    \\frac{9}{2} \\sum_{J_{ab}}\n    \\sum_{abc}\n    (n_a n_b \\bar{n}_c +  \\bar{n}_a \\bar{n}_b n_c)\n    \\overline{B}_{ij\\bar{n}ab\\bar{c}}^{(J_{3}, J_{C,ij}, J_{ab})}\n    \\overline{A}_{ab\\bar{c}lm\\bar{k}}^{(J_{3}, J_{ab}, J_{C,lm})}\\,,\n  \\end{aligned}\\label{eq:comm333_term2} \\\\\n   & \\begin{aligned}\n    \\mathllap{\\overline{F}_{ij\\bar{n}lm\\bar{k}}^{(J_{3}, J_{C,ij}, J_{C,lm})}}\n    \\equiv -\\frac{9}{2}\n    \\sum_{J_{ab}}\n    \\sum_{abc}\n    (n_a n_b \\bar{n}_c +  \\bar{n}_a \\bar{n}_b n_c)\n    \\overline{A}_{ij\\bar{n}ab\\bar{c}}^{(J_{3}, J_{C,ij}, J_{ab})}\n    \\overline{B}_{ab\\bar{c}lm\\bar{k}}^{(J_{3}, J_{ab}, J_{C,lm})}\\,.\n  \\end{aligned}\\label{eq:comm333_term3}\n\\end{align}\nThe expressions in Eqs.~\\eqref{eq:comm333_term2} and~\\eqref{eq:comm333_term3}\nare written in terms of Pandya-transformed matrix elements,\nwhere the three-body Pandya transformation is given by\n\\begin{equation}\n  \\overline{O}_{pq\\bar{r}st\\bar{u}}^{(J_{3}, J_{pq}, J_{st})}\n  \\equiv - \\sum_{J_{3}'}\n  \\hat{J}_{3}^{\\prime 2}\n  \\sixj{J_{pq}}{j_r}{J_{3}}{J_{st}}{j_u}{J_{3}'}\n  O_{pqustr}^{(J_{3}', J_{pq}, J_{st})}\\,.\n\\end{equation}\nThe indices $\\bar{r}$ and $\\bar{u}$ are time reversed,\nthat is, their angular-momentum projections are flipped.\nSince we are working with reduced indices\nwithout angular-momentum projections everywhere,\nthis distinction is irrelevant,\nbut we keep the modified indices around to be formally precise.\nThe Pandya-transformed matrix elements\nare useful intermediates that isolate recoupling on $A$, $B$, and $E$/$F$\nthat can be done independently.\nThe resulting $\\overline{E}$ and $\\overline{F}$ must be\nconverted back to normal coupled matrix elements\nby a final Pandya transformation\nbefore being added to $D$ to give $C$.\n\n\\subsection{Validation of numerical implementation}\n\nWith any numerical implementation,\nthere is the question of how we can ensure that\nthe code correctly implements the underlying formalism.\nWith the $J$-scheme IMSRG,\none has the advantage that\nthere is the (more transparent) $m$-scheme formalism\nthat one can compare against.\nThis means one can uncouple the initial Hamiltonian\nfed into the $J$-scheme implementation,\nsolve the IMSRG(3) flow equations via an $m$-scheme implementation,\nand compare the results with those of the $J$-scheme IMSRG(3) solver.\nThis can be done by looking at the ground-state energy\nor the second-order MBPT energy correction\nor by recoupling the resulting Hamiltonian matrix elements\nand checking that they match the $J$-scheme matrix elements\nto within the expected precision.\n\nWe take a more fine-grained approach to validating\nour $J$-scheme IMSRG(3) implementation,\nbut using the same overall strategy.\nWorking with the same initial matrix elements\n(in coupled and uncoupled form),\nwe evaluate the fundamental commutators\n(and some many-body operations like\nthe second-order MBPT energy correction and the two- and three-body antisymmetrizers)\nin our $J$-scheme implementation\nand an independent $m$-scheme implementation\n(used in Section~\\ref{sec:imsrg2_he4_mscheme} and Appendix~\\ref{app:pairing_hamiltonian_imsrg3}).\nThe resulting uncoupled matrix elements\nprovided by the $m$-scheme implementation\nare then recoupled and compared with the coupled matrix elements\nprovided by the $J$-scheme implementation.\nWith this strategy,\nwe can demand stringent numerical agreement between the results,\nbecause accumulated numerical error should be low.\nWe find all tested operations,\nwhich includes all fundamental commutators with antisymmetrization,\nthe second-order MBPT energy corrections,\nand the normal ordering methods,\npass this check.\n\n\\section{Outlook towards tensor operators}\\label{sec:tensor_jscheme}\n\nImplementing tensor operator support in the IMSRG\nprovides access to the full range of observables.\nExamples of observable tensor operators are\nelectric and magnetic multipole operators,\nwhich when implemented give access to\nlow-lying spectroscopy~\\cite{Parz17imsrg_em_obs}.\n\nThe implementation of tensor operators\nis a bit more challenging than that of scalar operators\nfor a couple of reasons.\nFirst, the coupled matrix elements of tensor operators\nare no longer diagonal in total angular momentum $J$\nand angular-momentum projection $M$~\\cite{Tich20jcoupling}.\nThe $M$-dependence is taken care of by\nthe factorization provided by the Wigner-Eckart theorem.\nHowever, when using the reduced matrix elements\nthe non-diagonality in $J$ remains,\nso the representation that worked for scalar operators\nneeds to be generalized to support this\n(along with the inclusion of the tensor rank).\n\nAdditionally, one requires a whole new set\nof fundamental commutators,\nspecifically those of a scalar operator\n(either the generator $\\eta$ or the Magnus operator $\\Omega$)\nand a tensor operator.\nThe \\texttt{amc} code has no trouble generating\nthe coupled/reduced expressions for these fundamental commutators~\\cite{Tich20jcoupling},\nbut the implementation effort for these additional commutators\nwill be similar to (probably greater than) that for the scalar-scalar commutators.\nUltimately,\nin order to explore electroweak observables in nuclei,\nadditional work in this direction must be done\nto implement these more general tensor-scalar commutators.\n", "meta": {"hexsha": "09dc75ec5dac82a291bb07f3c33e2466e5569f30", "size": 43203, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/doc/05_angular_momentum_coupling.tex", "max_stars_repo_name": "cheshyre/masters-thesis", "max_stars_repo_head_hexsha": "464fb498b0f0225d370358164c8efefe014fa820", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/doc/05_angular_momentum_coupling.tex", "max_issues_repo_name": "cheshyre/masters-thesis", "max_issues_repo_head_hexsha": "464fb498b0f0225d370358164c8efefe014fa820", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/doc/05_angular_momentum_coupling.tex", "max_forks_repo_name": "cheshyre/masters-thesis", "max_forks_repo_head_hexsha": "464fb498b0f0225d370358164c8efefe014fa820", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2242366412, "max_line_length": 149, "alphanum_fraction": 0.6750225679, "num_tokens": 14795, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019594, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.44146453037222166}}
{"text": "\\chapter{Random Forests}\\label{ch:forest}\n\n\\begin{remark}{Outline}\nIn this chapter, we present the well-known family of \\textit{random forests}\nmethods. In Section~\\ref{sec:4:bias-variance}, we first describe the bias-variance\ndecomposition of the prediction error and then present, in\nSection~\\ref{sec:4:ensemble}, how aggregating randomized models through\nensembles reduces the prediction error by decreasing the variance term in this\ndecomposition. In Section~\\ref{sec:4:random-forests}, we revisit random forests\nand its variants and study how randomness introduced into the decision trees\nreduces prediction errors by decorrelating the decision\ntrees in the ensemble. Properties and features of random forests are then outlined\nin Section~\\ref{sec:4:features} while their consistency\nis finally explored in Section~\\ref{sec:4:consistency}.\n\\end{remark}\n\n\n\\section{Bias-variance decomposition}\n\\label{sec:4:bias-variance}\n\nIn section~\\ref{sec:2:performance-evaluation}, we defined the generalization\nerror of a model $\\varphi_{\\cal L}$ as its expected prediction error\naccording to some loss function $L$\n\\begin{equation}\\label{eqn:4:generalization-error}\nErr(\\varphi_{\\cal L}) = \\mathbb{E}_{X,Y} \\{ L(Y, \\varphi_{\\cal L}(X)) \\}.\n\\end{equation}\nSimilarly, the expected prediction error of $\\varphi_{\\cal L}$ at $X=\\mathbf{x}$\ncan be expressed as\n\\begin{equation}\nErr(\\varphi_{\\cal L}(\\mathbf{x})) = \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ L(Y, \\varphi_{\\cal L}(\\mathbf{x})) \\}.\\label{eqn:4:generalization-error:x}\n\\end{equation}\n\nIn regression, for the squared error loss, this latter form of the expected\nprediction error additively decomposes into bias and variance terms which\ntogether constitute a very useful framework for diagnosing the prediction error\nof a model. In classification, for the zero-one loss, a similar decomposition\nis more difficult to obtain. Yet, the concepts of bias and variance can be\ntransposed in several ways to classification, thereby providing comparable\nframeworks for studying the prediction error of classifiers.\n\n\n\\subsection{Regression}\n\\label{sec:bias-variance:regression}\n\nIn regression, assuming that $L$ is the squared error loss, the expected\nprediction error of a model $\\varphi_{\\cal L}$ at a given point $X=\\mathbf{x}$\ncan be rewritten with respect to the Bayes model $\\varphi_B$:\n\\begin{align}\n& Err(\\varphi_{\\cal L}(\\mathbf{x})) \\nonumber \\\\\n&= \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (Y - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n&= \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (Y -\\varphi_B(\\mathbf{x}) + \\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n&= \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (Y -\\varphi_B(\\mathbf{x}))^2  \\} + \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (\\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n& \\hookrightarrow + \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ 2 (Y - \\varphi_B(\\mathbf{x}))(\\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x})) \\} \\nonumber \\\\\n&= \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (Y -\\varphi_B(\\mathbf{x}))^2 \\} + \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (\\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n&= Err(\\varphi_B(\\mathbf{x})) +  (\\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\label{eqn:4:decomp1}\n\\end{align}\nsince $\\mathbb{E}_{Y|X=\\mathbf{x}} \\{ Y - \\varphi_B(\\mathbf{x}) \\} =\n\\mathbb{E}_{Y|X=\\mathbf{x}} \\{ Y \\} - \\varphi_B(\\mathbf{x}) = 0$ by definition\nof the Bayes model in regression. In this form, the first term in the last\nexpression of Equation~\\ref{eqn:4:decomp1} corresponds to the (irreducible)\nresidual error  at $X=\\mathbf{x}$ while the second term represents the\ndiscrepancy of $\\varphi_{\\cal L}$ from the Bayes model. The farther from the\nBayes model, the more sub-optimal the model and the larger the error.\n\nIf we further assume that the learning set ${\\cal L}$ is itself a random\nvariable (sampled from the population $\\Omega$) and that the learning algorithm is deterministic, then the expected\ndiscrepancy over ${\\cal L}$ with the Bayes model can further be re-expressed in terms of the\naverage prediction $\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\}$\nover the models learned from all possible learning sets of size $N$:\n\\begin{align}\n& \\mathbb{E}_{\\cal L} \\{ (\\varphi_B(\\mathbf{x}) - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\}\\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} + \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} )^2 \\} + \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\}\\nonumber \\\\\n& \\hookrightarrow+ \\mathbb{E}_{\\cal L} \\{ 2(\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\})(\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))\\} \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} )^2 \\} + \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\} \\}\\nonumber \\\\\n&= (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} )^2 + \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\}\n\\end{align}\nsince $\\mathbb{E}_{\\cal L}\\{ \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal\nL}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}) \\} =  \\mathbb{E}_{\\cal L} \\{\n\\varphi_{\\cal L}(\\mathbf{x}) \\} -  \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal\nL}(\\mathbf{x}) \\} = 0$. In summary, the expected generalization error additively\ndecomposes as formulated in Theorem~\\ref{thm:bias-variance}.\n\n\\begin{theorem}\\label{thm:bias-variance}\nFor the squared error loss, the bias-variance decomposition of the expected\ngeneralization error $\\mathbb{E}_{\\cal L} \\{ Err(\\varphi_{\\cal L}(\\mathbf{x}))\n\\}$ at $X=\\mathbf{x}$ is\n\\begin{equation}\n\\mathbb{E}_{\\cal L} \\{ Err(\\varphi_{\\cal L}(\\mathbf{x})) \\} = \\text{noise}(\\mathbf{x}) + \\text{bias}^2(\\mathbf{x}) + \\text{var}(\\mathbf{x}),\n\\end{equation}\nwhere\n\\begin{align*}\n\\text{noise}(\\mathbf{x}) &= Err(\\varphi_B(\\mathbf{x})), \\\\\n\\text{bias}^2(\\mathbf{x}) &= (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} )^2, \\\\\n\\text{var}(\\mathbf{x}) &= \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\} - \\varphi_{\\cal L}(\\mathbf{x}))^2 \\}.\n\\end{align*}\n\\end{theorem}\n\nThis bias-variance decomposition of the generalization error is due to\n\\citet{geman:1992} and was first proposed in the context of neural networks.\nThe first term, $\\text{noise}(\\mathbf{x})$, is the residual error. It is\nentirely independent of both the learning algorithm and the learning set and\nprovides for any model a theoretical lower bound on its generalization error.\nThe second term, $\\text{bias}^2(\\mathbf{x})$, measures the discrepancy between\nthe average prediction and the prediction of the Bayes model. Finally, the\nthird term, $\\text{var}(\\mathbf{x})$, measures the variability of the\npredictions at $X=\\mathbf{x}$ over the models learned from all possible\nlearning sets. All three terms are illustrated in Figure~\\ref{fig:bias-variance}\nfor a toy and artificial regression problem. Both $\\text{noise}(\\mathbf{x})$ and\n$\\text{var}(\\mathbf{x})$ measures the spread of the two densities while\n$\\text{bias}^2(\\mathbf{x})$ is the distance between their means.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/ch4_bias_variance.pdf}\n    \\caption{Residual error, bias and variance at $X=\\mathbf{x}$. (Figure inspired from \\citep{geurts:2002}.)}\n    \\label{fig:bias-variance}\n\\end{figure}\n\nAs a typical example, the bias-variance decomposition framework can be used as\na tool for diagnosing underfitting and overfitting (as previously introduced in\nSection \\ref{sec:2:model-selection}). The upper plots in\nFigure~\\ref{fig:overfitting} illustrate in light red predictions $\\varphi_{\\cal\nL}(\\mathbf{x})$ for polynomials of degree $1$, $5$ and $15$ learned over random\nlearning sets ${\\cal L}$ sampled from a noisy cosine function. Predictions\n$\\mathbb{E}_{\\cal L} \\{ \\varphi_{\\cal L}(\\mathbf{x}) \\}$ of the average model\nare represented by the thick red lines. Predictions for the model learned over\nthe learning set, represented by the blue dots, are represented in gray.\nPredictions of the Bayes model are shown by blue lines and coincide with the unnoised\ncosine function that defines the regression problem. The lower plots in the\nfigure illustrate the bias-variance decomposition of the expected\ngeneralization error of the polynomials.\n\n\\begin{figure}\n    \\hspace{-0.75cm}\\includegraphics[width=1.1\\textwidth]{figures/ch4_overfitting.pdf}\n    \\caption{Bias-variance decomposition of the expected generalization error for polynomials of degree $1$, $5$ and $15$.}\n    \\label{fig:overfitting}\n\\end{figure}\n\nClearly, polynomials of degree $1$ (left) suffer from underfitting. In terms of\nbias and variance, this translates into low variance but high bias as shown in\nthe lower left plot of Figure~\\ref{fig:overfitting}. Indeed, due to the low\ndegree of the polynomials (i.e., due to the low model complexity), the\nresulting models are almost all identical and  the variability of the\npredictions from one model to another is therefore quite low. Also, because of\nlow complexity, none of them really fits the trend of the training points, even\napproximately, which implies that the average model is far from approximating\nthe Bayes model. This results in high bias. On the other hand, polynomials of\ndegree $15$ (right) suffer from overfitting. In terms of bias and variance, the\nsituation is the opposite. Predictions have low bias but high variance, as\nshown in the lower right plot of Figure~\\ref{fig:overfitting}. The variability\nof the predictions is large because the high degree of the polynomials (i.e.,\nthe high model complexity) captures noise in the learning set. Indeed, compare\nthe gray line with the blue dots -- they almost all intersect. Put otherwise,\nsmall changes in the learning set result in large changes in the obtained model\nand therefore in its predictions. By contrast, the average model is now quite\nclose from the Bayes model, which results in low bias\\footnote{Note however the\nGibbs-like phenomenon resulting in both high variance and high bias at the\nboundaries of ${\\cal X}$.}. Finally, polynomials of degree $5$ (middle) are\nneither too simple nor too complex. In terms of bias and variance, the trade-off\nis well-balanced between the two extreme situations. Bias and variance are\nneither too low nor too large.\n\n\n\\subsection{Classification}\n\\label{sec:bias-variance:classification}\n\nIn direct analogy with the bias-variance decomposition for the squared error\nloss, similar decompositions have been proposed in the literature for the\nexpected generalization error based on the zero-one loss, i.e., for\n$\\mathbb{E}_{\\cal L}\\{ \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ 1(\\varphi_{\\cal L}(x)\n\\neq Y) \\} \\} = P_{{\\cal L},Y|X=\\mathbf{x}}(\\varphi_{\\cal L}(\\mathbf{x}) \\neq\nY)$. Most notably, \\citet{dietterich:1995}, \\citet{breiman:1996},\n\\citet{kohavi:1996}, \\citet{tibshirani:1996} and \\citet{domingos:2000} have all developed additive\ndecompositions similar to Theorem~\\ref{thm:bias-variance} by redefining the\nconcepts of bias and variance in the case of classification. While these\nefforts have all provided useful insight into the nature of classification\nerror, none of them really have provided a seductively as simple and\nsatisfactory framework as in regression (for reviews, see\n\\citep{friedman:1997,james:2003,geurts:2005}).\n\nAn interesting connection with Theorem~\\ref{thm:bias-variance} however is to\nremark that classification algorithms usually work by computing estimates\n\\begin{equation}\\label{eqn:4:proba-estimates}\n\\widehat{p}_{\\cal L}(Y=c|X=\\mathbf{x})\n\\end{equation}\nof the conditional class probability (e.g.,\n$\\widehat{p}_{\\cal L}(Y=c|X=\\mathbf{x}) = p(c|t)$ in decision trees, as defined in Section~\\ref{sec:3:assignment}) and then deriving a classification rule by\npredicting the class that maximizes this estimate, that is:\n\\begin{equation}\\label{eqn:4:classificaton-rule}\n\\varphi_{\\cal L}(\\mathbf{x}) = \\argmax_{c \\in {\\cal Y}} \\widehat{p}_{\\cal L}(Y=c|X=\\mathbf{x})\n\\end{equation}\nAs such, a direction for studying classification models is to relate the\nbias-variance decomposition of these numerical estimates to the expected\nmisclassification error of classification rule~\\ref{eqn:4:classificaton-rule}.\n\nWe now reproduce the results of \\citet{friedman:1997} who made this connection\nexplicit for the case of binary classification. Let us first decompose the\nexpected classification error into an irreducible part associated with the\nrandom nature of the output $Y$ and a reducible part that depends on\n$\\varphi_{\\cal L}(\\mathbf{x})$, in analogy with Equation~\\ref{eqn:4:decomp1}\nfor the squared error loss. (Note that, to simplify notations, we assume that\nall probabilities based on the random variable $Y$ is with respect to the\ndistribution of $Y$ at $X=\\mathbf{x}$.)\n\\begin{align}\n& \\mathbb{E}_{\\cal L}\\{ \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ 1(\\varphi_{\\cal L}(\\mathbf{x}) \\neq Y) \\} \\}  \\\\\n&= P_{{\\cal L}}(\\varphi_{\\cal L}(\\mathbf{x}) \\neq Y) \\nonumber \\\\\n&= 1 - P_{{\\cal L}}(\\varphi_{\\cal L}(\\mathbf{x}) = Y) \\nonumber \\\\\n&= \\begin{aligned}[t]\n    1 &- P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x}) = \\varphi_B(\\mathbf{x})) P(\\varphi_B(\\mathbf{x})=Y) \\nonumber \\\\\n      &- P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x}) \\neq \\varphi_B(\\mathbf{x})) P(\\varphi_B(\\mathbf{x})\\neq Y) \\nonumber\n   \\end{aligned}\\nonumber \\\\\n&= \\begin{aligned}[t]\n    &P(\\varphi_B(\\mathbf{x})\\neq Y) + P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x})\\neq \\varphi_B(\\mathbf{x})) \\nonumber \\\\\n    &- 2 P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x})\\neq \\varphi_B(\\mathbf{x})) P(\\varphi_B(\\mathbf{x})\\neq Y)  \\nonumber \\\\\n   \\end{aligned}\\nonumber \\\\\n&= P(\\varphi_B(\\mathbf{x})\\neq Y) + P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x})\\neq \\varphi_B(\\mathbf{x}))(2 P(\\varphi_B(\\mathbf{x}) = Y) - 1) \\nonumber\n\\end{align}\n\nIn this form, the first term is the irreducible error of the Bayes model. The\nsecond term is the increased error due to the misestimation of the optimal\ndecision boundary. The probability $P_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x})\\neq\n\\varphi_B(\\mathbf{x}))$  is the probability for the model of making a decision\nwhich is different from the decision of the Bayes model. This happens\nwhen the estimate $\\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}))$ is lower\nthan $0.5$, that is:\n\\begin{equation}\\label{eqn:4:prob-diff-from-bayes}\nP_{\\cal L}(\\varphi_{\\cal L}(\\mathbf{x})\\neq \\varphi_B(\\mathbf{x})) = P_{\\cal L}(\\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) < 0.5)\n\\end{equation}\nAs Figure~\\ref{fig:estimate-distribution} illustrates, probability~\\ref{eqn:4:prob-diff-from-bayes}\nin fact corresponds to the tail area on the left side\nof the decision threshold (at 0.5) of the distribution of the estimate.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/ch4_estimate_distribution.pdf}\n    \\caption{Probability distribution of the estimate $\\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}))$.}\n    \\label{fig:estimate-distribution}\n\\end{figure}\n\nIf we now further assume\\footnote{For single decision trees, the normal\nassumption is certainly not satisfied in all cases, but the qualitative\nconclusions are still generally valid. When the computations of the estimates\ninvolve some averaging process, e.g., as further developed in the case of\nensemble of randomized trees, this approximation is however fairly reasonable.}\nthat the estimate $\\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}))$ is normally distributed,\nthen probability~\\ref{eqn:4:prob-diff-from-bayes} can be computed explicitly\nfrom its mean and variance:\n\\begin{equation}\nP_{\\cal L}(\\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) < 0.5) = \\Phi(\\frac{0.5 - \\mathbb{E}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\}}{\\sqrt{\\mathbb{V}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\}}})\n\\end{equation}\nwhere $\\Phi(x)=\\frac{1}{\\sqrt{2\\pi}} \\int_{-\\infty}^x \\exp(-\\frac{t^2}{2}) dt$\nis the cumulative distribution function of the standard normal distribution.\nIn summary, the expected generalization error additively\ndecomposes as formulated in Theorem~\\ref{thm:bias-variance:classification}.\n\n\\begin{theorem}\\label{thm:bias-variance:classification}\nFor the zero-one loss and binary classification, the expected\ngeneralization error $\\mathbb{E}_{\\cal L} \\{ Err(\\varphi_{\\cal L}(\\mathbf{x}))\n\\}$ at $X=\\mathbf{x}$ decomposes as follows:\n\n\\begin{align}\n\\mathbb{E}_{\\cal L} \\{ Err(\\varphi_{\\cal L}(\\mathbf{x})) \\} &= P(\\varphi_B(\\mathbf{x})\\neq Y) \\\\\n                                                            &+ \\Phi(\\frac{0.5 - \\mathbb{E}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\}}{\\sqrt{\\mathbb{V}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\}}}) (2 P(\\varphi_B(\\mathbf{x}) = Y) - 1) \\nonumber\n\\end{align}\n\\end{theorem}\n\nAs a result, Theorem~\\ref{thm:bias-variance:classification} establishes a\ndirect connection between the regression variance of the estimates and the\nclassification error of the resulting model. In practice, this decomposition\nhas important consequences:\n\\begin{itemize}\n\\item When the expected probability estimate $\\mathbb{E}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}) \\}$\n      for the true majority class is greater than $0.5$, a reduction of\n      variance of the estimate results in a decrease of the total misclassification\n      error. If $\\mathbb{V}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\} \\to 0$,\n      then $\\Phi \\to 0$ and the expected generalization error tends to the error of the Bayes model.\n      In particular, the generalization error can be driven to its minimum\n      value whatever the regression bias of the estimate (at least as long as $\\mathbb{E}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}) \\} > 0.5$).\n\\item Conversely, when $\\mathbb{E}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x}) \\} < 0.5$,\n      a decrease of variance might actually increase the total misclassification error.\n      If $\\mathbb{V}_{\\cal L}\\{ \\widehat{p}_{\\cal L}(Y=\\varphi_B(\\mathbf{x})) \\} \\to 0$,\n      then $\\Phi \\to 1$ and the error is maximal.\n\\end{itemize}\n\n\n\\section{Ensemble methods based on randomization}\n\\label{sec:4:ensemble}\n\nBoth theorems~\\ref{thm:bias-variance} and \\ref{thm:bias-variance:classification}\nreveal the role of variance in the expected generalization error of a model. In\nlight of these results, a sensible approach for reducing generalization error\nwould therefore consist in driving down the prediction variance, provided the\nrespective bias can be kept the same or not be increased too much.\n\nAs it happens, \\textit{ensemble methods} constitute a beautifully simple way to\ndo just that. Specifically, the core principle of ensemble methods based on randomization is to\nintroduce random perturbations into the learning procedure in order to produce\nseveral different models from a single learning set ${\\cal L}$ and then to\ncombine the predictions of those models to form the prediction of the ensemble.\nHow predictions are combined and why does it help is formally studied in the\nnext sections.\n\n\n\\subsection{Randomized models}\n\nGiven a learning set ${\\cal L}$, a learning algorithm ${\\cal A}$\ndeterministically produces a model ${\\cal A}(\\theta, {\\cal L})$, denoted\n$\\varphi_{{\\cal L},\\theta}$\\label{ntn:varphi-Ltheta}, where $\\theta$ are\nhyper-parameters controlling the execution of ${\\cal A}$. Let us assume that $\\theta$\nincludes a random seed parameter for mimicking some stochastic behavior in\n${\\cal A}$, hence producing (pseudo-)randomized models that are more or less\ndifferent from one random seed to another. (We defer the discussion on specific\nrandom perturbations in the case of decision trees to Section~\\ref{sec:4:random-forests}.)\n\nIn this context, the bias-variance decomposition can be extended to account for\neverything that is random, hence considering both ${\\cal L}$ and $\\theta$ as\nrandom variables\\footnote{From now on, and without loss of generality, we\nassume that the random variable $\\theta$ only controls the randomness of the\nlearning algorithm.}.\nAccordingly, theorems~\\ref{thm:bias-variance} and \\ref{thm:bias-variance:classification}\nnaturally extend to the expected generalization error\n$\\mathbb{E}_{{\\cal L},\\theta} \\{ Err(\\varphi_{{\\cal L},\\theta}(\\mathbf{x})) \\}$\nof the randomized model $\\varphi_{{\\cal L},\\theta}$ by replacing expectations\n$\\mathbb{E}_{\\cal L} \\{ . \\}$ and variances $\\mathbb{V}_{\\cal L} \\{ . \\}$ with\ntheir respective counterparts $\\mathbb{E}_{{\\cal L},\\theta} \\{ . \\}$ and\n$\\mathbb{V}_{{\\cal L},\\theta} \\{ . \\}$ computed over the joint distribution of\n${\\cal L}$ and $\\theta$. In regression, the bias-variance decomposition\nof the squared error loss thus becomes:\n\\begin{equation}\n\\mathbb{E}_{{\\cal L},\\theta} \\{ Err(\\varphi_{{\\cal L},\\theta}(\\mathbf{x})) \\} = \\text{noise}(\\mathbf{x}) + \\text{bias}^2(\\mathbf{x}) + \\text{var}(\\mathbf{x}),\n\\end{equation}\nwhere\n\\begin{align}\n\\text{noise}(\\mathbf{x}) &= Err(\\varphi_B(\\mathbf{x})), \\\\\n\\text{bias}^2(\\mathbf{x}) &= (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{{\\cal L},\\theta} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} )^2, \\\\\n\\text{var}(\\mathbf{x}) &= \\mathbb{E}_{{\\cal L},\\theta} \\{ (\\mathbb{E}_{{\\cal L},\\theta} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} - \\varphi_{{\\cal L},\\theta}(\\mathbf{x}))^2 \\}.\n\\end{align}\n\nIn this form, variance now accounts for both the prediction variability due to\nthe randomness of the learning set ${\\cal L}$ and the variability due to the\nrandomness of the learning algorithm itself. As such, the variance of a\nrandomized algorithm is typically larger than the variance of its\ndeterministic counterpart. Depending on the strength of randomization, bias\nalso usually increases, but often to a smaller extent than variance.\n\nWhile randomizing an algorithm might seem counter-intuitive, since it\nincreases both variance and bias, we will show in Section~\\ref{sec:4:bias-variance:ensemble}\nthat combining several such randomized models might actually\nachieve better performance than a single non-randomized model.\n\n\n\\subsection{Combining randomized models}\n\nLet us assume a set of $M$\\label{ntn:M} randomized models $\\{\\varphi_{{\\cal L}, \\theta_m} |\nm = 1, \\dots, M \\}$, all learned on the same data ${\\cal L}$ but each built\nfrom an independent random seed $\\theta_m$\\label{ntn:theta-seed}\\label{ntn:theta-seed-m}. Ensemble methods work by combining\nthe predictions of these models into a new \\textit{ensemble} model, denoted\n$\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}$\\label{ntn:psi}, such that the expected\ngeneralization error of the ensemble is (hopefully) smaller than the expected\ngeneralization error of the individual randomized models.\n\nIn regression, for the squared error loss, the most common way to combine the\nrandomized models into an ensemble is to average their predictions to form the\nfinal prediction:\n\\begin{equation}\\label{eqn:4:averaging}\n\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x}) = \\frac{1}{M} \\sum_{m=1}^M \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x})\n\\end{equation}\nThe rationale is that the average prediction is the prediction that minimizes the average\nsquared error with respect to the individual predictions of the models. In that sense, the average prediction is the closest prediction with respect to all individual predictions.\n\n\\begin{remark}{Ambiguity decomposition}\nFor prediction averaging, as defined in Equation~\\ref{eqn:4:averaging},\nthe \\textit{ambiguity decomposition}~\\citep{krogh:1995}\nguarantees the generalization error of the ensemble to be lower\nthan the average generalization error of its constituents. Formally,\nthe ambiguity decomposition states that\n\\begin{equation}\nErr(\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}) = \\overline{E} - \\overline{A}\n\\end{equation}\nwhere\n\\begin{align}\n\\overline{E} &= \\frac{1}{M} \\sum_{m=1}^M Err(\\varphi_{{\\cal L},\\theta_m}), \\\\\n\\overline{A} &= \\mathbb{E}_{X} \\{ \\frac{1}{M} \\sum_{m=1}^M (\\varphi_{{\\cal L},\\theta_m}(X) - \\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(X))^2 \\}.\n\\end{align}\nThe first term is the average generalization error of the individual models. The second term is the ensemble ambiguity and\ncorresponds to the variance of the individual predictions around the prediction of the ensemble. Since $\\overline{A}$ is non-negative,\nthe generalization error of the ensemble is therefore smaller than the average generalization\nerror of its constituents.\n\\end{remark}\n\nIn classification, for the zero-one loss, predictions are usually aggregated by considering the\nmodels in the ensemble as a committee  and then resorting to \\textit{majority voting} to\nform the final prediction:\n\\begin{equation}\\label{eqn:4:majority-vote}\n\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x}) = \\argmax_{c \\in {\\cal Y}}  \\sum_{m=1}^M 1(\\varphi_{{\\cal L},\\theta_m}(\\mathbf{x})=c)\n\\end{equation}\nSimilarly, the rationale is that the majority prediction is the prediction that minimizes\nthe average zero-one error with respect to the individual predictions.\nAlternatively, when individual models provide class probability estimates $\\widehat{p}_{{\\cal L},\\theta m}(Y=c|X=\\mathbf{x})$,\n\\textit{soft voting}~\\citep{zhou:2012}\nconsists in averaging the class probability estimates\nand then predict the class which is the most likely:\n\\begin{equation}\\label{eqn:4:avg-estimate}\n\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x}) = \\argmax_{c \\in {\\cal Y}} \\frac{1}{M} \\sum_{m=1}^M \\widehat{p}_{{\\cal L},\\theta m}(Y=c|X=\\mathbf{x})\n\\end{equation}\nAs empirically investigated by \\citet{breiman:1996b}, both approaches yield\nresults that are nearly identical\\footnote{In the case of ensembles of fully developed decision trees that perfectly classify all samples from ${\\cal L}$, majority voting and soft voting are exactly equivalent.}. From a practical point of view however,\nEquation~\\ref{eqn:4:avg-estimate} has the advantage of providing smoother class\nprobability estimates for the ensemble, which may prove to be useful in\ncritical applications, e.g., when (estimates of) the certainty about\npredictions is as important as the predictions themselves. Additionally,\ncombining predictions in this way makes it easy to study the expected\ngeneralization error of the ensemble -- it suffices to plug the averaged\nestimates into Theorem~\\ref{thm:bias-variance:classification}. For these\nreasons, and for the rest of this work, predictions in classification are now\nassumed to be combined with soft voting (see Equation~\\ref{eqn:4:avg-estimate}) unless\nmentioned otherwise.\n\n\\begin{remark}{Condorcet's jury theorem}\nMajority voting, as defined in Equation~\\ref{eqn:4:majority-vote},\nfinds its origins in the \\textit{Condorcet's jury theorem}\nfrom the field of political science. Let consider a group of $M$ voters that\nwishes to reach a decision by majority vote. The theorem states that if each\nvoter has an independent  probability $p > \\tfrac{1}{2}$ of voting for the\ncorrect decision, then adding more voters increases the probability of\nthe majority decision to be correct. When $M \\to \\infty$, the probability that the decision\ntaken by the group is correct approaches $1$. Conversely, if $p < \\tfrac{1}{2}$, then\neach voter is more likely to vote incorrectly and increasing $M$ makes things\nworse.\n\\end{remark}\n\n\\subsection{Bias-variance decomposition of an ensemble}\n\\label{sec:4:bias-variance:ensemble}\n\nLet us now study the bias-variance decomposition of the expected generalization\nerror of an ensemble $\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}$, first in the\ncase in case of regression and then for classification.\n\nTo simplify notations in the analysis below, let us denote the mean prediction at\n$X=\\mathbf{x}$ of a single randomized model $\\varphi_{{\\cal L},\\theta_m}$ and its\nrespective prediction variance as:\n\\begin{align}\n\\mu_{{\\cal L},\\theta_m}(\\mathbf{x}) &= \\mathbb{E}_{{\\cal L},\\theta_m} \\{ \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}) \\} \\label{eqn:4:mu} \\\\\n\\sigma^2_{{\\cal L},\\theta_m}(\\mathbf{x}) &= \\mathbb{V}_{{\\cal L},\\theta_m} \\{ \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}) \\label{eqn:4:sigma} \\}\n\\end{align}\n\n\\subsubsection{Regression}\n\nFrom Theorem~\\ref{thm:bias-variance}, the expected generalization error of an\nensemble $\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}$ made of $M$ randomized\nmodels decomposes into a sum of $\\text{noise}(\\mathbf{x})$,\n$\\text{bias}^2(\\mathbf{x})$ and $\\text{var}(\\mathbf{x})$ terms.\n\nThe noise term only depends on the intrinsic randomness of $Y$. Its value\nstays therefore the same, no matter the learning algorithm:\n\\begin{equation}\n\\text{noise}(\\mathbf{x}) = \\mathbb{E}_{Y|X=\\mathbf{x}} \\{ (Y - \\varphi_B(\\mathbf{x}))^2 \\}\n\\end{equation}\n\nThe (squared) bias term is the (squared) difference between the prediction of the Bayes model\nand the average prediction of the model. For an ensemble, the average prediction\nis in fact the same as the average prediction of the corresponding randomized individual model. Indeed,\n\\begin{align}\n\\mathbb{E}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ \\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x}) \\} &= \\mathbb{E}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ \\frac{1}{M} \\sum_{m=1}^M \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}) \\} \\nonumber \\\\\n&= \\frac{1}{M} \\sum_{m=1}^M \\mathbb{E}_{{\\cal L},\\theta_m} \\{ \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}) \\} \\nonumber \\\\\n&= \\mu_{{\\cal L},\\theta}(\\mathbf{x})\n\\end{align}\nsince random variables $\\theta_m$ are independent and all follow the\nsame distribution. As a result,\n\\begin{equation}\n\\text{bias}^2(\\mathbf{x}) = (\\varphi_B(\\mathbf{x}) - \\mu_{{\\cal L},\\theta}(\\mathbf{x}))^2,\n\\end{equation}\nwhich indicates that the bias of an ensemble of randomized models is the same\nas the bias of any of the randomized models. Put otherwise, combining\nrandomized models has no effect on the bias.\n\nOn variance on the other hand, ensemble methods show all their raison d'etre,\nvirtually reducing the variability of predictions to almost nothing and thereby\nimproving the accuracy of the ensemble. Before considering the variance of\n$\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x})$ however, let us first\nderive the correlation coefficient $\\rho(\\mathbf{x})$ between the predictions\nof two randomized models built on the same learning set, but grown from two\nindependent random seeds $\\theta^\\prime$ and $\\theta^{\\prime\\prime}$. From the definition of the Pearson's correlation\ncoefficient, it comes:\n\\begin{align}\n\\rho(\\mathbf{x}) &= \\frac{\\mathbb{E}_{{\\cal L},\\theta^\\prime,\\theta^{\\prime\\prime}} \\{ (\\varphi_{{\\cal L}, \\theta^\\prime}(\\mathbf{x}) - \\mu_{{\\cal L},\\theta^\\prime}(\\mathbf{x})) (\\varphi_{{\\cal L}, \\theta^{\\prime\\prime}}(\\mathbf{x}) - \\mu_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x})) \\}}{\\sigma_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\sigma_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x})} \\nonumber \\\\\n&= \\frac{\\mathbb{E}_{{\\cal L},\\theta^\\prime,\\theta^{\\prime\\prime}} \\{ \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) - \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\mu_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) - \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\mu_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) + \\mu_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\mu_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\}}{\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})} \\nonumber \\\\\n&= \\frac{\\mathbb{E}_{{\\cal L},\\theta^\\prime,\\theta^{\\prime\\prime}} \\{ \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\} - \\mu^2_{{\\cal L},\\theta}(\\mathbf{x})}{\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})} \\label{eqn:4:correlation}\n\\end{align}\nby linearity of the expectation and exploiting the fact that random variables\n$\\theta^\\prime$ and $\\theta^{\\prime\\prime}$ follow the same distribution.\nIntuitively, $\\rho(\\mathbf{x})$ represents the strength of the random\nperturbations introduced in the learning algorithm. When it is close to $1$,\npredictions of two randomized models are highly correlated, suggesting that\nrandomization has no sensible effect on the predictions. By contrast, when it\nis close to $0$, predictions of the randomized models are decorrelated, hence\nindicating that randomization has a strong effect on the predictions. At the\nlimit, when $\\rho(\\mathbf{x})=0$, predictions of two models built on the same\nlearning set ${\\cal L}$ are independent, which happens when they are perfectly\nrandom. As proved later with Equation~\\ref{eqn:4:correlation-bis}, let us\nfinally also remark that the correlation term $\\rho(\\mathbf{x})$\nis non-negative, which confirms that randomization has a decorrelation effect\nonly.\n\nFrom Equation~\\ref{eqn:4:correlation}, the variance of $\\psi_{{\\cal\nL},\\theta_1,\\dots,\\theta_M}(\\mathbf{x})$ can now be derived as follows:\n\\begin{align}\n\\text{var}(\\mathbf{x}) &= \\mathbb{V}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ \\frac{1}{M} \\sum_{m=1}^M \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x})  \\} \\nonumber \\\\\n&= \\frac{1}{M^2} \\Bigg[ \\mathbb{E}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ (\\sum_{m=1}^M \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}))^2 \\} - \\mathbb{E}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ \\sum_{m=1}^M \\varphi_{{\\cal L},\\theta_m}(\\mathbf{x}) \\}^2 \\Bigg] \\nonumber\n\\end{align}\nby exploiting the facts that $\\mathbb{V}\\{a X\\} = a^2 \\mathbb{V}\\{ X \\}$,\n$\\mathbb{V}\\{ X \\} = \\mathbb{E}\\{X^2\\} - \\mathbb{E}\\{ X \\}^2$ and the linearity\nof expectation. By rewriting the square of the sum of the $\\varphi_{{\\cal L},\\theta_m}(\\mathbf{x})$ terms as a sum over all pairwise products $\\varphi_{{\\cal L},\\theta_i}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta_j}(\\mathbf{x})$, the variance can further be rewritten as:\n\\begin{align}\n&= \\frac{1}{M^2} \\Bigg[ \\mathbb{E}_{{\\cal L},\\theta_1,\\dots,\\theta_M} \\{ \\sum_{i,j} \\varphi_{{\\cal L},\\theta_i}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta_j}(\\mathbf{x}) \\} - (M \\mu_{{\\cal L},\\theta}(\\mathbf{x}))^2 \\Bigg] \\nonumber \\\\\n&= \\frac{1}{M^2} \\Bigg[ \\sum_{i,j} \\mathbb{E}_{{\\cal L},\\theta_i,\\theta_j} \\{  \\varphi_{{\\cal L},\\theta_i}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta_j}(\\mathbf{x}) \\} - M^2 \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}) \\Bigg] \\nonumber \\\\\n&= \\frac{1}{M^2} \\Bigg[ M \\mathbb{E}_{{\\cal L},\\theta} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x})^2 \\} \\nonumber \\\\\n&\\quad \\hookrightarrow + (M^2-M) \\mathbb{E}_{{\\cal L},\\theta^\\prime,\\theta^{\\prime\\prime}} \\{  \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\}  - M^2 \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}) \\Bigg] \\nonumber \\\\\n&= \\frac{1}{M^2} \\Bigg[ M (\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) + \\mu^2_{{\\cal L},\\theta}(\\mathbf{x})) \\nonumber \\\\\n&\\quad \\hookrightarrow + (M^2-M)(\\rho(\\mathbf{x}) \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) + \\mu^2_{{\\cal L},\\theta}(\\mathbf{x})) - M^2 \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}) \\Bigg] \\nonumber \\\\\n&= \\frac{\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})}{M} + \\rho(\\mathbf{x})\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) - \\rho(\\mathbf{x}) \\frac{\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})}{M} \\nonumber \\\\\n&= \\rho(\\mathbf{x}) \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) + \\frac{1 - \\rho(\\mathbf{x})}{M} \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) \\label{eqn:4:variance-hastie}\n\\end{align}\nAs the size of the ensemble gets arbitrarily large, i.e., as $M \\to \\infty$,\nthe variance of the ensemble reduces to $\\rho(\\mathbf{x})\n\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})$. Under the assumption that randomization has some\neffect on the predictions of randomized models, i.e., assuming\n$\\rho(\\mathbf{x}) < 1$, the variance of an ensemble is therefore strictly\nsmaller than the variance of an individual model. As a result, the expected\ngeneralization error of an ensemble is strictly smaller than the expected error\nof a randomized model. As such, improvements in predictions are\nsolely the result of variance reduction, since both $\\text{noise}(\\mathbf{x})$\nand $\\text{bias}^2(\\mathbf{x})$ remain unchanged. Additionally, when random\neffects are strong, i.e., when $\\rho(\\mathbf{x}) \\to 0$, variance reduces to\n$\\smash{\\tfrac{\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})}{M}}$, which can further be driven to $0$ by\nincreasing the size of the ensemble. On the other hand, when random effects are weak,\ni.e., when $\\rho(\\mathbf{x}) \\to 1$, then variance reduces to $\\sigma^2_{{\\cal\nL},\\theta}(\\mathbf{x})$ and building an ensemble brings no benefit. Put otherwise, the stronger the random effects, the larger\nthe reduction of variance due to ensembling, and vice-versa.\n\nIn summary, the expected generalization error of an ensemble additively\ndecomposes as stated in Theorem~\\ref{thm:bias-variance:ensemble}.\n\\begin{theorem}\\label{thm:bias-variance:ensemble}\nFor the squared error loss, the bias-variance decomposition of the expected\ngeneralization error $\\mathbb{E}_{\\cal L} \\{ Err( \\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x}))\n\\}$ at $X=\\mathbf{x}$ of an ensemble of $M$ randomized models $\\varphi_{{\\cal L},\\theta_m}$ is\n\\begin{equation}\n\\mathbb{E}_{\\cal L} \\{ Err(\\psi_{{\\cal L},\\theta_1,\\dots,\\theta_M}(\\mathbf{x})) \\} = \\text{noise}(\\mathbf{x}) + \\text{bias}^2(\\mathbf{x}) + \\text{var}(\\mathbf{x}),\n\\end{equation}\nwhere\n\\begin{align*}\n\\text{noise}(\\mathbf{x}) &= Err(\\varphi_B(\\mathbf{x})), \\\\\n\\text{bias}^2(\\mathbf{x}) &= (\\varphi_B(\\mathbf{x}) - \\mathbb{E}_{{\\cal L},\\theta} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} )^2, \\\\\n\\text{var}(\\mathbf{x}) &= \\rho(\\mathbf{x}) \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) + \\frac{1 - \\rho(\\mathbf{x})}{M} \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}).\n\\end{align*}\n\\end{theorem}\n\nIn light of Theorem~\\ref{thm:bias-variance:ensemble}, the core principle of\nensemble methods is thus to introduce random perturbations in order to\ndecorrelate as much as possible the predictions of the individual models,\nthereby maximizing variance reduction. However, random perturbations need to be\ncarefully chosen so as to increase bias as little as possible.  The crux of the\nproblem is to find the right trade-off between randomness and bias.\n\n\\begin{remark}{Alternative variance decomposition}\n\\citet{geurts:2002} (Chapter 4, Equation~4.31) alternatively decomposes the ensemble variance as\n\\begin{equation}\\label{eqn:4:variance-geurts}\n\\text{var}(\\mathbf{x}) = \\mathbb{V}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\} + \\frac{1}{M} \\mathbb{E}_{\\cal L} \\{ \\mathbb{V}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\}.\n\\end{equation}\nThe first term of this decomposition is the variance due to the randomness\nof the learning set ${\\cal L}$, averaged over the random perturbations due to $\\theta$. It\nmeasures the dependence of the model on the learning set, independently of\n$\\theta$. The second term is the expectation over all learning sets of\nthe variance with respect to $\\theta$. It measures the strength of the\nrandom effects. As the decomposition shows, only this last part of the variance\ncan be reduced as a result of averaging, which is consistent with our previous\nconclusions.  The stronger the random effects, the larger the variance with\nrespect to $\\theta$, and hence the larger of reduction of variance due\nto ensembling.\n\n\\begin{proposition}Decompositions \\ref{eqn:4:variance-hastie} and \\ref{eqn:4:variance-geurts} of the prediction variance for an ensemble are equivalent.\n\\end{proposition}\n\n\\begin{proof}\nFrom Equations~\\ref{eqn:4:variance-hastie} and \\ref{eqn:4:variance-geurts}, equivalence holds if Equation~\\ref{eqn:4:correlation}\nis equivalent to\n\\begin{equation}\\label{eqn:4:correlation-bis}\n\\rho(\\mathbf{x}) = \\frac{\\mathbb{V}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\}}{\\mathbb{V}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\} + \\mathbb{E}_{\\cal L} \\{ \\mathbb{V}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\}}.\n\\end{equation}\nFrom the law of total variance, the denominator of Equation~\\ref{eqn:4:correlation} expands\nto the denominator of Equation~\\ref{eqn:4:correlation-bis}:\n\\begin{equation}\n\\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) = \\mathbb{V}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\} + \\mathbb{E}_{\\cal L} \\{ \\mathbb{V}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\}\n\\end{equation}\nSimilarly, the numerator of Equation~\\ref{eqn:4:correlation-bis} can be reexpressed\nas the numerator of Equation~\\ref{eqn:4:correlation}, thereby proving the equivalence:\n\\begin{align}\n& \\mathbb{V}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} \\} \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} - \\mathbb{E}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x})\\} \\})^2 \\} \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ (\\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\} - \\mu_{{\\cal L},\\theta}(\\mathbf{x}))^2 \\} \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ \\mathbb{E}_{\\theta|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta}(\\mathbf{x}) \\}^2 \\} - \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}) \\nonumber \\\\\n&= \\mathbb{E}_{\\cal L} \\{ \\mathbb{E}_{\\theta^\\prime|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\} \\mathbb{E}_{\\theta^{\\prime\\prime}|{\\cal L}} \\{ \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\} \\} - \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}) \\nonumber \\\\\n&= \\mathbb{E}_{{\\cal L},\\theta^\\prime,\\theta^{\\prime\\prime}} \\{ \\varphi_{{\\cal L},\\theta^\\prime}(\\mathbf{x}) \\varphi_{{\\cal L},\\theta^{\\prime\\prime}}(\\mathbf{x}) \\} - \\mu^2_{{\\cal L},\\theta}(\\mathbf{x}).\n\\end{align}\n\\end{proof}\n\nIn this form, $\\rho(\\mathbf{x})$ is interpreted as the ratio between the variance\ndue to the learning set  and the total variance, accounting for\nrandom effects due to both the learning set and the random perturbations.\nIt is close to $1$ when variance is mostly due to the learning set, hence\nyielding correlated predictions. Conversely, it is close to $0$ when variance\nis mostly due to the random perturbations induced by $\\theta$, hence decorrelating\nthe predictions.\n\\end{remark}\n\n\\subsubsection{Classification}\n\nThe decomposition of the expected generalization error of an ensemble in\nclassification directly follows from theorems~\\ref{thm:bias-variance:classification} and\n\\ref{thm:bias-variance:ensemble}.\nBuilding an ensemble always reduces the variance of the class probability estimate\n$\\mathbb{E}_{{\\cal L},\\theta}\\{ \\widehat{p}_{{\\cal\nL},\\theta}(Y=\\varphi_B(\\mathbf{x}) \\}$ (as shown in Equation~\\ref{eqn:4:variance-hastie}), which results in a decrease of the misclassification error\nif the expected estimate remains strictly greater than $0.5$ in a\nrandomized model.\n\n\\begin{remark}{Shortcomings addressed by ensembles}\nIn complement with the formal bias-variance analysis carried out in the previous\nsection, \\citet{dietterich:2000b} identifies three fundamental reasons\nintuitively explaining why ensembles often work better than single models.\n\nThe first reason is statistical. When the learning set is too small, a learning\nalgorithm can typically find several models in the hypothesis space ${\\cal H}$\nthat all give the same performance on the training data. Provided their predictions\nare uncorrelated, averaging several models reduces the risk of choosing the wrong hypothesis.\n\nThe second reason is computational. Many learning algorithms rely on some\ngreedy assumption or local search that may get stuck in local optima. As such, an ensemble\nmade of individual models built from many different starting points may provide\na better approximation of the true unknown function that any of the single\nmodels.\n\nFinally, the third reason is representational. In most cases, for a learning set of finite size, the true\nfunction cannot be represented by any of the candidate models in ${\\cal H}$.\nBy combining several models in an ensemble, it may be possible to expand the space\nof representable functions and to better model the true function.\n\\end{remark}\n\n\n\\section{Random Forests}\n\\label{sec:4:random-forests}\n\nRandom forests\\footnote{The term\n\\textit{random forests}, without capitals, is used to denote any ensemble of decision\ntrees. Specific variants are referred to using their original designation,\ndenoted with capitals. In particular, the ensemble method due to\n\\citet{breiman:2001} is denoted as \\textit{Random Forests}, with capitals.}\nform a family of methods that consist in building an ensemble (or\n\\textit{forest}) of decision trees grown from a randomized variant of the tree\ninduction algorithm (as described in Chapter~\\ref{ch:cart}). Decision trees are\nindeed ideal candidates for ensemble methods since they usually have low bias\nand high variance, making them very likely to benefit from the averaging\nprocess. As we will review in this section, random forests methods mostly\ndiffer from each other in the way they introduce random perturbations into the\ninduction procedure. As highlighted in the previous section, the difficulty is\nto inject randomness while minimizing $\\rho(\\mathbf{x})$ and\nsimultaneously maintaining a low bias in the randomized decision trees.\n\n\\subsection{Randomized induction algorithms}\n\n\\begin{description}\n\n\\item \\citet{kwok:1990}: \\hfill \\\\\n    Historically, the earliest mention of ensemble of decision trees is due to\n    \\citet{kwok:1990}. In this work, the authors empirically observe that\n    averaging multiple decision trees with different structure consistently\n    produces better results than any of the constituents of the ensemble. This\n    approach however was not based on randomization nor was fully automatic:\n    decision trees were generated by first manually selecting at the top of the\n    tree splits that were almost as good as the optimal splits, and then\n    expanded using the classical ID3 induction procedure.\n\n\\item \\citet{breiman:1996b}: \\hfill \\\\\n    In a now famous technical report, \\citet{breiman:1996b} was one of the earliest to\n    show, both theoretically and empirically, that aggregating multiple\n    versions of an estimator into an ensemble can give substantial gains in\n    accuracy. He notes and shows that the average model $\\mathbb{E}_{\\cal L}\\{\n    \\varphi_{\\cal L} \\}$ has a lower expected generalization error than\n    $\\varphi_{\\cal L}$. As such, \\textit{Bagging}  consists in\n    approximating $\\mathbb{E}_{\\cal L}\\{ \\varphi_{\\cal L} \\}$  by combining\n    models built from \\textit{bootstrap samples}~\\citep{efron:1979} ${\\cal\n    L}^m$\\label{ntn:L_m} (for $m=1,\\dots,M$) of the learning set ${\\cal L}$. The $\\{ {\\cal\n    L}^m \\}$ form replicates of ${\\cal L}$, each consisting of $N$ cases $(\\mathbf{x},y)$, drawn\n    at random but \\textit{with replacement} from ${\\cal L}$.\n\n    Note that even\n    though $|{\\cal L}|=|{\\cal L}^m|=N$, $37\\%$ of the couples $(\\mathbf{x},y)$ from ${\\cal L}$\n    are on average missing in the bootstrap replicates. Indeed, after $N$ draws\n    with replacement, the probability of never have been selected is\n    \\begin{equation}\n    (1 - \\frac{1}{N})^N \\approx \\frac{1}{e} \\approx 0.368.\n    \\end{equation}\n    When the learning algorithm is unstable (i.e., when small changes in the\n    learning set can cause large changes in the learned models), Bagging\n    generates individual models that are  different from one bootstrap sample\n    to another, hence making them likely to benefit from the averaging process.\n    In some cases however, when the learning set ${\\cal L}$ is small,\n    subsampling $67\\%$ of the objects might lead to an increase of bias\n    (e.g., because of a decrease in model complexity) which\n    is too large to be compensated by a decrease of variance, hence resulting\n    in overall poorer performance. Despite this defect, Bagging has proven to\n    be an effective method in numerous applications, one of its strengths being\n    that it can be used to combine any kind of models -- i.e., not only\n    decision trees.\n\n\\item \\citet{dietterich:1995}: \\hfill \\\\\n    Building upon \\citep{kwok:1990}, \\citet{dietterich:1995} propose\n    to randomize the choice of the best split at a given node by selecting\n    uniformly at random one of the $20$ best splits of node $t$. The authors empirically\n    show in \\citep{dietterich:1995,dietterich:2000} that randomizing in this\n    way gives results that are slightly better than Bagging in low noise settings.\n    Experiments show however that when noise is important, Bagging usually\n    yield better results. From a bias-variance point of view, this method\n    virtually does not change bias but increases variance due to randomization.\n\n\\item \\citet{amit:1997}: \\hfill \\\\\n    In the context of handwritten character recognition, where the number $p$\n    of input variables is typically very large, \\citet{amit:1997} propose a\n    randomized variant of the tree induction algorithm that consists in\n    searching for the best split at each node over a random subsample of the\n    variables.\n\n    Denoting $K \\leq p$\\label{ntn:K-split} (also known as \\texttt{mtry} or\n    \\texttt{max\\_features}) the number of variables effectively considered at\n    each node, this variant replaces Algorithm~\\ref{algo:findsplit}\n    with the following randomized alternative:\n    \\begin{algorithm}\\label{algo:findsplit:random}\n    Find the best split $s^*$ that partitions ${\\cal L}_t$, among a random subset of $K \\leq p$ input variables.\n    \\textnormal{\n    \\begin{algorithmic}[1]\n    \\Function{FindBestSplitRandom}{${\\cal L}_t$, $K$}\n        \\State $\\Delta = -\\infty$\n        \\State Draw $K$ random indices $j_k$ from $1,\\dots,p$\n        \\For{$k=1, \\dots, K$}\n            \\State Find the best binary split $s^*_{j_k}$ defined on $X_{j_k}$\n            \\If{$\\Delta i(s^*_{j_k}, t) > \\Delta$}\n                \\State $\\Delta = \\Delta i(s^*_{j_k}, t)$\n                \\State $s^* = s^*_{j_k}$\n            \\EndIf\n        \\EndFor\n        \\State \\Return $s^*$\n    \\EndFunction\n    \\end{algorithmic}\n    }\n    \\end{algorithm}\n    When the output $Y$ can be explained in several ways, this randomized\n    algorithm generates trees that are each structurally different, yet\n    individually good. As a result, bias usually increases only slightly, while\n    the increased variance due to randomization can be cancelled out through averaging. The\n    optimal trade-off between these quantities can otherwise be adjusted by\n    tuning the value of $K$. As $K \\to 1$, the larger the bias but the larger the\n    variance of the individual models and hence the more effective the\n    averaging process. Conversely, as $K \\to p$, the smaller the bias but also the\n    smaller the variance of the individual models and therefore the less\n    beneficial the ensemble.\n\n\\item \\citet{ho:1998}: \\hfill \\\\\n    Inspired from the principles of Bagging~\\citep{breiman:1996b} and\n    random subsets of variables~\\citep{amit:1997}, \\citet{ho:1998} proposes\n    with the \\textit{Random Subspace} (RS) method to build a \\textit{decision\n    forest} whose trees are grown on random subsets of the input variables\n    -- drawn once, prior to the construction of each tree -- rather than on all $p$\n    variables. As empirically evaluated at several\n    occasions~\\citep{ho:1998,panov:2007,louppe:2012}, the Random Subspace\n    method is a powerful generic ensemble method that can achieve near state-of-the-art\n    performance on many problems. Again, the optimal trade-off between the\n    variance due to randomization  and the increase of bias can be controlled\n    by tuning the size of the random subset.\n\n\\item \\citet{breiman:2001}: \\hfill \\\\\n    In his seminal \\textit{Random Forests} (RF) paper, \\citet{breiman:2001} combines\n    Bagging~\\citep{breiman:1996b} with random variable selection at each\n    node~\\citep{amit:1997}. Injecting randomness simultaneously with both strategies  yields\n    one the most effective off-the-shelf methods in machine learning, working\n    surprisingly well for almost any kind of problems. The author empirically\n    shows that Random Forests give results that are competitive with\n    boosting \\citep{freund:1995} and arcing algorithms \\citep{breiman:1996},\n    which both are designed to reduce bias while forests focus on variance\n    reduction.\n\n    While the original principles are due to several authors (as discussed\n    above), Breiman is often cited as the father of forests of randomized trees. Parts of\n    this recognition are certainly due to the pioneer theoretical analysis that\n    has always complemented his empirical analysis of algorithms. In contrast\n    with other authors, another reason might also be his efficient software\n    implementation~\\citep{breiman:2002} that was made freely available,\n    allowing users outside of the machine learning community to quickly and\n    easily apply Random Forests to their problems.\n\n\\item \\citet{cutler:2001}: \\hfill \\\\\n    With \\textit{Perfect Random Tree Ensembles} (PERT), \\citet{cutler:2001}\n    propose to grow a forest of perfectly fit decision trees in which both the\n    (ordered) variable to split on and the discretization threshold are chosen\n    at random. More specifically, given a node $t$, the split variable $X_j$ is\n    drawn at random using Algorithm~\\ref{algo:findsplit:random} with $K=1$\n    while the cut-point $v$ is set midway between two randomly drawn samples using\n    the following procedure (instead of Algorithm~\\ref{algo:findsplit:x_j}):\n    \\begin{algorithm}\\label{algo:findsplit:pert}\n    Draw a random split on $X_j$ that partitions ${\\cal L}_t$.\n    \\textnormal{\n    \\begin{algorithmic}[1]\n    \\Function{FindRandomSplit-PERT}{${\\cal L}_t$, $X_j$}\n        \\State Draw $(\\mathbf{x}_1,y_1), (\\mathbf{x}_2,y_2) \\in {\\cal L}_t$ such that $y_1 \\neq y_2$\n        \\State Draw $\\alpha$ uniformly at random from $[0,1]$\n        \\State $v = \\alpha x_{1,j} + (1 -\\alpha) x_{2, j}$\n        \\State \\Return $s^v_j$\n    \\EndFunction\n    \\end{algorithmic}\n    }\n    \\end{algorithm}\n    The induction of the tree proceeds using such random splits until\n    all nodes become pure or until it is no longer possible to draw samples\n    of different output values.\n\n    From a practical point of view, PERT is an easily coded and a very\n    efficient ensemble method since there is no impurity criterion to evaluate\n    when splitting the nodes of a tree. Regarding accuracy, experimental\n    comparisons in \\citep{cutler:2001} show that PERT is often nearly as good as\n    Random Forests \\citep{breiman:2001}, while resulting however in random\n    trees that are typically larger than  decision trees grown with\n    less randomization. The simplicity of the method also allows for an amenable\n    theoretical analysis of forests of randomized trees, as carried out in \\citep{zhao:2000}.\n\n\\item \\citet{geurts:2006}: \\hfill \\\\\n    As investigated in \\citep{wehenkel:1997,geurts:2000},  the notoriously high\n    variance of decision trees partly finds its origins from the high\n    dependence of the splits with the random nature of the learning set. The\n    authors empirically show that the variance of the optimal cut-point $v$ (in\n    the case of ordered input variables) may indeed be very high, even for\n    large sample sizes.  In particular, \\citet{geurts:2002} shows that cut-point\n    variance appears to be responsible for a significant part of the\n    generalization error of decision trees. As a way to smoothen the decision\n    boundary, \\citet{geurts:2006} hence propose in \\textit{Extremely Randomized\n    Trees} (ETs) to combine random variable selection~\\citep{amit:1997} with\n    random discretization thresholds. As a drop-in replacement of Algorithm~\\ref{algo:findsplit:x_j},\n    the authors propose the following simplistic but effective\n    procedure for drawing splits at random:\n    \\begin{algorithm}\\label{algo:findsplit:et}\n    Draw a random split on $X_j$ that partitions ${\\cal L}_t$.\n    \\textnormal{\n    \\begin{algorithmic}[1]\n    \\Function{FindRandomSplit-ETs}{${\\cal L}_t$, $X_j$}\n        \\State $\\min_j = \\min(\\{ x_{i,j} | (\\mathbf{x}_i,y_i) \\in {\\cal L}_t \\})$\n        \\State $\\max_j = \\max(\\{ x_{i,j} | (\\mathbf{x}_i,y_i) \\in {\\cal L}_t \\})$\n        \\State Draw $v$ uniformly at random from $[\\min_j, \\max_j[$\n        \\State \\Return $s^v_j$\n    \\EndFunction\n    \\end{algorithmic}\n    }\n    \\end{algorithm}\n    With respect to decomposition~\\ref{eqn:4:variance-geurts} of variance,\n    extremely randomized trees can therefore be seen as a way to transfer\n    cut-point variance from the variance term due to the learning\n    set to the (reducible) variance term that is due to random effects.\n\n    In the special case where $K=1$, Extremely Randomized Trees reduce to\n    \\textit{Totally Randomized Trees}, in which both a single variable $X_j$\n    and a discretization threshold $v$ are drawn at random at each node. As a\n    result, the structure of such trees can be learned in an unsupervised way,\n    independently of the output variable $Y$. In this setting, Totally\n    Randomized Trees are very close to Perfect Random Tree\n    Ensembles~\\citep{cutler:2001} since both draw $X_j$ and $v$ at random.\n    These methods are however not strictly equivalent since they do not draw\n    the random discretization thresholds $v$ with respect to the same\n    probability distribution.\n\n\\item \\citet{rodriguez:2006}: \\hfill \\\\\n    In a different direction, \\citet{rodriguez:2006} propose in\n    \\textit{Rotation Forests} to generate randomized decision trees based on\n    feature extraction. As in Bagging~\\citep{breiman:1996b}, individual\n    decision trees are built on bootstrap replicates ${\\cal L}^m$ of the\n    learning set ${\\cal L}$. To further enhance diversity (i.e., to further\n    decorrelate the predictions of the constituents of the ensemble), for each\n    of the $M$ bootstrap replicates, input variables are randomly partitioned\n    into $q$  subsets of $\\tfrac{p}{q}$ variables, principal component analysis\n    (PCA) is run separately on each subset, and a new set\n    $\\smash{\\widetilde{{\\cal L}^m}}$ of $p$ extracted input variables is\n    constructed by pooling all principal components from the $q$ projections.\n    In this way, bootstrap replicates ${\\cal L}^m$ are each independently\n    transformed linearly into a new input space using $q$  axis rotations. In\n    this framework,  decision trees are particularly suited because they are\n    sensitive to changes in the input space and still can be very accurate. As\n    reported in \\citep{rodriguez:2006,kuncheva:2007}, Rotation Forests\n    favorably compare with other tree-based ensemble methods, yielding results\n    that are often as good, sometimes better, than Random\n    Forests~\\citep{breiman:2001}. In terms of complexity however, the computational\n    overhead due to the $q$ axis rotations should not be overlooked when\n    resources are limited.\n\n\\end{description}\n\n\\subsection{Illustration}\n\\label{sec:4:illustration}\n\nAs a summary and illustrative example, let us consider a simulated toy\nregression problem such that\n\\begin{equation}\nY = \\sum_{j=1}^{5} X_j,\n\\end{equation}\nwhere all input variables $X_1,\\dots,X_{5}$ are independent\nrandom Gaussian variables of zero mean and unit variance. To simulate\nnoise in the data, 5 additional random Gaussian input variables $X_{6},\\dots,X_{10}$,\nall independent from $Y$, are further appended to the learning set.\n\nLet us compare for this problem the bias-variance decomposition of the expected\ngeneralization error of a Random Forest~\\citep{breiman:2001} (RF) and of\nExtremely Randomized Trees~\\citep{geurts:2006} (ETs). For both methods, the\nerror is estimated as derived from Theorem~\\ref{thm:bias-variance:ensemble},\nusing $100$ randomly drawn learning sets ${\\cal L}$ of $50$ samples, on which\nensembles of $10$ trees are built. Their generalization error is estimated on\nan independent test set of $1000$ samples.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/ch4_correlation.pdf}\n    \\caption{(Left) Bias-variance decomposition of the generalization error\n            with respect to the hyper-parameter $K$. The total error is shown by the plain\n            lines. Bias and variance terms are respectively shown by the dashed and dotted\n            lines.  (Right) Average correlation\n            coefficient $\\rho(\\mathbf{x})$ over the predictions of two randomized trees\n            grown from the same learning set but with different random seeds.}\n    \\label{fig:correlation}\n\\end{figure}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/ch4_variance.pdf}\n    \\caption{Decomposition of the variance term $\\text{var}(\\mathbf{x})$ with respect to the number $M$ of trees in the ensemble.}\n    \\label{fig:variance}\n\\end{figure}\n\nAs the left plot in Figure~\\ref{fig:correlation} shows,  the expected\ngeneralization error additively decomposes into (squared) bias and variance\nterms.  For small values of $K$, random effects are strong, leading to high\nbias and low variance. By contrast, for larger values of $K$, random effects\nare less important, reducing bias but increasing variance.   For both methods,\ntoo small a value of $K$ appears however to lead to a too large increase of\nbias, for which averaging is not able to compensate. For RF, the optimal\ntrade-off is at $K=8$, which indicates that bagging and random variable selection are\nhere complementary with regard to the level of randomness injected into the\ntrees. Indeed, using bagging only (at $K=10$) for randomizing the construction\nof the trees yield results that are slightly worse than when both techniques\nare combined. For ETs, the optimal trade-off is at $K=10$, suggesting that\nrandom thresholds $v$ provide by themselves enough randomization on this\nproblem.\n\nThe right plot of Figure~\\ref{fig:correlation} illustrates the (averaged)\ncorrelation coefficient $\\rho(\\mathbf{x})$ between the predictions of two\nrandomized trees grown on the same learning set. As expected, the smaller $K$,\nthe stronger the random effects, therefore the less correlated the predictions\nand the more variance can be reduced from averaging. The plot also confirms\nthat ETs are inherently less correlated than trees built\nin RF, which is not surprising given the fact that the former\nmethod randomizes the choice of the discretization threshold while the latter\ndoes not. In cases where such a randomization does not induce too large an\nincrease of bias, as in this problem, ETs are therefore\nexpected to yield better results than RF.  (The choice of the\noptimal randomization strategy is however highly dependent on the problem and\nno general conclusion should be drawn from this toy regression problem.)\n\nAs confirmed by Figure~\\ref{fig:variance} for RF, variance also additively decomposes  into\n\\begin{equation}\n\\text{var}(\\mathbf{x}) = \\rho(\\mathbf{x}) \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}) + \\tfrac{1 - \\rho(\\mathbf{x})}{M} \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x}).\n\\end{equation}\nThe first term is the variance due to the learning set ${\\cal L}$ and remains\nconstant as the number $M$ of trees increases. The second term is the variance\ndue to random effects and decreases as $M$ increases. Of particular interest is\nvariance at $M=1$, which corresponds to the variance of a single decision tree.\nAs the figure clearly shows, averaging several decision trees into an ensemble\nallows to significantly reduce this quantity. At the limit, when $M\\to \\infty$,\nvariance tends to $\\rho(\\mathbf{x}) \\sigma^2_{{\\cal L},\\theta}(\\mathbf{x})$, as shown by\nthe dotted line and as expected from Theorem~\\ref{thm:bias-variance:ensemble}.\n\n\\section{Properties and features}\n\\label{sec:4:features}\n\n\\subsection{Out-of-bag estimates}\n\nAn interesting  feature of ensemble methods that construct models\non bootstrap samples, like Bagging or Random Forests, is the built-in possibility of\nusing the left-out samples ${\\cal L}\\setminus {\\cal L}^m$ to form\nestimates of important statistics. In the case of generalization error, the\n\\textit{out-of-bag} estimate at $(\\mathbf{x}_i,y_i)$ consists in evaluating the\nprediction of the ensemble using only the individual models $\\varphi_{{\\cal\nL}^m}$ whose bootstrap samples ${\\cal L}^m$ did not include\n$(\\mathbf{x}_i,y_i)$. That is, in regression,\n\\begin{align}\\label{eqn:oob-error}\n\\widehat{Err}^\\text{OOB}(\\psi_{\\cal L}) &= \\frac{1}{N} \\sum_{(\\mathbf{x}_i,y_i) \\in {\\cal L}} L(\\frac{1}{M^{-i}} \\sum_{l=1}^{M^{-i}} \\varphi_{{\\cal L}^{m_{k_l}}}(\\mathbf{x}_i), y_i),\n\\end{align}\nwhere $m_{k_1}, \\dots, m_{k_{M^{-i}}}$ denote the indices of $M^{-i}$ the trees that\nhave been built from bootstrap replicates that do not include $(\\mathbf{x}_i,\ny_i)$. For classification, the out-of-bag estimate of the generalization error is similar to\nEquation~\\ref{eqn:oob-error}, except that the out-of-bag average prediction is\nreplaced with the class which is the most likely, as computed from the out-of-bag\nclass probability estimates.\n\nOut-of-bag estimates provide accurate estimates of the\ngeneralization error of the ensemble, often yielding statistics that are as\ngood or even more precise than $K$-fold cross-validation\nestimates~\\citep{wolpert:1999}. In practice, out-of-bag estimates also\nconstitute a computationally efficient alternative to $K$-fold cross-validation,\nreducing to $M$ the number of invocations of the learning\nalgorithm, instead of otherwise having to build $K\\times M$ base models.\n\nWhile out-of-bag estimates constitute an helpful tool, their benefits should\nhowever be put in balance with the potential decrease of accuracy that the use\nof bootstrap replicates may induce. As shown experimentally in\n\\citep{louppe:2012}, bootstrapping is in fact rarely crucial for random forests\nto obtain good accuracy. On the contrary, not using bootstrap samples usually\nyield better results.\n\n\\subsection{Variable importances}\n\nIn most machine learning tasks, the goal is not only to find the most accurate\nmodel of the response but also to identify which of the input variables are the\nmost important to make the predictions, e.g., in order to lead to a deeper\nunderstanding of the problem under study.\n\nIn this context, random forests offer several mechanisms for assessing the\n\\textit{importance} of an input variable, and therefore enhance the\ninterpretability of the model. These are the object of\nChapter~\\ref{ch:importances}, in which we study variable importance measures\nand develop original contributions to further improve their understanding.\n\n\\subsection{Proximity measures}\n\nAnother helpful built-in feature of tree-based ensemble methods is the\n\\textit{proximity measure}~\\citep{breiman:2002} between two sample points. Formally, the proximity\nbetween $(\\mathbf{x}_1, y_1)$ and $(\\mathbf{x}_2, y_2)$ is defined as the\nnumber of times both samples reach the same leaf $t$ within each decision tree,\nnormalized by the number of trees in the forest. That is,\n\\begin{equation}\n\\text{proximity}(\\mathbf{x}_1, \\mathbf{x}_2) = \\frac{1}{M} \\sum_{m=1}^M \\sum_{t \\in \\widetilde{\\varphi}_{{\\cal L},\\theta_m}} 1(\\mathbf{x}_1 , \\mathbf{x}_2 \\in {\\cal X}_t)\n\\end{equation}\nwhere $\\widetilde{\\varphi}_{{\\cal L},\\theta_m}$ denotes the set of terminal\nnodes in $\\varphi_{{\\cal L},\\theta_m}$. The idea is that the proximity measure\ngives an indication of how close the  samples are in the eyes of the random\nforest~\\citep{hastie:2005}, even if the data is high-dimensional or involves\nmixed input variables. When proximity is close to $1$, samples propagate into\nthe same leaves and are therefore similar according to the forest. On the other\nhand, when it is close to $0$, samples reach different leaves, suggesting that\nthey are structurally different from each other. The proximity measure\ndepends on both the depth and the number of trees in the forest.\nWhen trees are shallow, samples are more likely to end up in the same leaves\nthan when trees are grown more deeply, thereby impacting on the spread of the measure.\nLikewise, the more trees in the forest, the smoother the measure since\nthe larger the number $M+1$ of values the proximity measure can take.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/ch4_proximity_plot.pdf}\n    \\caption{Proximity plot for a 10-class handwritten digit classification task.}\n    \\label{fig:proximity-plot}\n\\end{figure}\n\nFor exploratory purposes, the $N\\times N$ proximity matrix $P$ such that\n\\begin{equation}\nP_{ij} = \\text{proximity}(\\mathbf{x}_i, \\mathbf{x}_j),\n\\end{equation}\ncan be used to visually represent how samples are close together with respect\nto the random forest. Using $1-P$ as a dissimilarity matrix,  the level of\nsimilarity between individual samples can be visualized e.g., by projecting them\non a $d$-dimensional space (e.g., on a plane) such that the distances\nbetween any pair of samples in that space correspond as best as possible to the\ndissimilarities in $1-P$. As an illustrative example, Figure~\\ref{fig:proximity-plot}\nrepresents the proximity matrix learned for a 10-class handwritten digit\nclassification task, as projected on a plane using Multidimensional Scaling~\\citep{kruskal:1964}.\nSamples from a same class form identifiable clusters, which suggests that\nthey share similar structure (since they end up in the same leaves). The figure\nalso highlights classes for which the random forest makes errors. In this case,\ndigits $1$ and $8$ are the more dispersed, suggesting high within-class variance,\nbut also overlap the most with samples of other classes, indicating\nthat the random forest fails to identify the true class for these samples.\n\nAdditionally, proximity measures can be used for identifying outliers within a\nlearning set ${\\cal L}$. A sample $\\mathbf{x}$ can be considered as an outlier\nif its average proximity with respect to all other samples is small, which\nindeed indicates that $\\mathbf{x}$ is structurally different from the other\nsamples (since they do not end up in the same leaves). In the same way, in\nclassification, within-class outliers can be identified by computing the\naverage proximity of a sample with respect to all other samples of the same\nclass. Conversely, proximity measures can be used for identifying class\nprototypes, by considering samples whose proximity with all other samples\nof the same class is the largest.\n\nAn alternative formulation of proximity measures is to consider a random forest\nas a mapping $\\phi: {\\cal X} \\mapsto {\\cal X}^\\prime$ which transforms a sample\n$\\mathbf{x}$ into the (one-hot-encoded) indices of the leaves it ends up in.\nThat is, $\\mathbf{x}^\\prime_t$ is $1$ for all leaves $t$ of the forest in which\n$\\mathbf{x}$ falls in, and $0$ for all the others:\n\\begin{equation}\n\\phi(\\mathbf{x}) = \\Big( 1(\\mathbf{x} \\in {\\cal X}_{t_1}), \\dots, 1(\\mathbf{x} \\in {\\cal X}_{t_L} ) \\Big)\n\\end{equation}\nwhere $t_1, \\dots, t_L \\in \\widetilde{\\psi}$ denote the leafs of all $M$ trees in the forest $\\psi$.\nIn this formalism, the\nproximity between $\\mathbf{x}_1$ and $\\mathbf{x}_2$ corresponds to a\n\\textit{kernel}~\\citep{scholkopf:2001}\\label{ntn:kernel2}, that can be defined as the normalized\ndot product of the samples, as represented in ${\\cal X}^\\prime$:\n\\begin{equation}\n\\text{proximity}(\\mathbf{x}_1, \\mathbf{x}_2) = \\frac{1}{M} \\phi(\\mathbf{x}_1) \\cdot \\phi(\\mathbf{x}_2)\n\\end{equation}\nInterestingly, $\\phi$ provides a non-linear transformation to a sparse very\nhigh-dimensional space, taking somehow into account the structure of the\nproblem. If two samples are structurally similar, then they will end up in the\nsame leafs and their representations in the projected space will be close, even\nif they may in fact appear quite dissimilar in the original space.\n\nIn close connection, \\citep{geurts:2006} show that a regression tree\n$\\varphi$ can be expressed as a kernel-based model by formulating the\nprediction $\\varphi(\\mathbf{x})$ as a scalar product over the input space\ndefined by the normalized characteristic function $\\phi^\\prime$ of the leaf nodes. That is,\n\\begin{equation}\n\\varphi(\\mathbf{x}) = \\sum_{(\\mathbf{x}_i, y_i) \\in {\\cal L}} y_i K_\\varphi(\\mathbf{x}_i, \\mathbf{x})\n\\end{equation}\nwhere\n\\begin{align}\nK_\\varphi(\\mathbf{x}_i, \\mathbf{x}) &= \\phi^\\prime(\\mathbf{x}_i) \\cdot \\phi^\\prime(\\mathbf{x}), \\\\\n\\phi^\\prime(\\mathbf{x}) &= \\Big( \\frac{1(\\mathbf{x} \\in {\\cal X}_1)}{\\sqrt{N_1}}, \\dots, \\frac{1(\\mathbf{x} \\in {\\cal X}_{t_L})}{\\sqrt{N_{t_L}}}  \\Big),\n\\end{align}\nand where $t_1,\\dots,t_L \\in \\widetilde{\\varphi}$ denote the leafs of $\\varphi$.\nLikewise, the formulation can be extended to an ensemble $\\psi$ of $M$ decision\ntrees by defining $K_\\psi$ as the average kernel over $K_{\\varphi_m}$ (for $m=1,\\dots,M$).\n\nFrom a more practical point of view, such forest-based transforms $\\phi$ and\n$\\phi^\\prime$ have proven to be helpful and efficient embeddings, e.g., when\ncombined with linear methods or support vector machines\n\\citep{moosmann:2006,maree:2013}. In particular, they find useful applications\nin computer vision for transforming the raw pixel input space into a new\nfeature space hopefully capturing structures and patterns in images.\n\n\\subsection{Missing data}\n\nBecause of practical limitations, physical constraints or for privacy reasons,\nreal-world data are often imperfect, erroneous or incomplete. In particular,\nmost machine learning algorithms are often not applicable on data containing\nmissing values because they implicitly assume an ideal scenario in which all\nvalues are known for all input variables. Fortunately, random forests offer\nseveral mechanisms for dealing with this issue.\n\n\\begin{description}\n\n\\item \\textit{Ternary decision trees.}\\hfill\\\\\n    The simplest strategy is to explicitly model missing values in the\n    structure of decision trees by considering ternary splits instead of binary\n    splits. That is, partition $t$ into $t_L$, $t_R$ and $t_M$, such that $t_L$\n    and $t_R$ are defined from a binary split $s_j^v : X_j \\leq v$, for all node\n    samples where the value of $X_j$ is known, and such that $t_M$ contain all node\n    samples for which the value of $X_j$ is missing.\n\n\\item \\textit{Propagate in both child nodes}\\hfill\\\\\n    An alternative strategy is to  propagate samples\n    for which the value of the split variable is missing into both the left and\n    right child nodes. Accordingly, samples going into both child nodes should be\n    re-weighted by half their sample weight (see Chapter~\\ref{ch:complexity}), so\n    that they are not unfairly taken into account more than the other samples.\n\n\\item \\textit{Imputation.}\\hfill\\\\\n    Finally, random forests also offer several mechanisms for imputing missing\n    values. A simple approach, due to \\citep{breiman:2002}, consists first in\n    filling missing values with a rough and inaccurate approximation (e.g., the\n    median). Then build a random forest on the completed data and update the\n    missing values of each sample by the weighted mean value over the samples\n    that are the closest (as defined by the proximity measure). The procedure\n    is then repeated  until convergence, typically after $4$ to $6$ iterations.\n\n    Alternatively, missing data imputation can be considered as a supervised\n    learning problem in itself, where the response variable is the input\n    variable for which values are missing. As such, the MissForest\n    algorithm~\\citep{stekhoven:2012} consists in iteratively building a random\n    forest on the observed parts of the data in order to predict the missing\n    values for a given variable.\n\n\\end{description}\n\n\n\\section{Consistency}\n\\label{sec:4:consistency}\n\nDespite their extensive use in practice, excellent performance and relative\nalgorithmic simplicity, the mathematical mechanisms that drive random forests\nare still not well understood. More specifically, the fundamental theoretical\nquestion of the consistency (see definitions \\ref{def:consistency} and\n\\ref{def:consistency-strong}) of random forests, i.e., whether convergence towards an\noptimal model is guaranteed provided an infinitely large learning set, remains\nan open and difficult problem. In this section, we review theoretical works\nthat have investigated simplified versions of the algorithm, for which the construction\nprocedure is often made data-independent, hence making the\ntheoretical analysis typically more tractable. With the hope that results\nobtained for these simplified models will provide insights on the mathematical\nproperties of the actual algorithm, the long-term objective of this line of\nresearch is usually to prove the consistency of the original Random Forest\nalgorithm \\citep{breiman:2001}, hence bridging the gap between theory and\npractice.\n\n\\begin{description}\n\n\\item \\citet{breiman:1984}:\\hfill \\\\\n    Single decision trees are proved to be consistent, both in regression and\n    classification.\n\n    Note that these results do not extend to the Random Forest algorithm for the following reasons:\n    \\begin{itemize}\n    \\item In single decision trees, the number of samples in terminal nodes\n          is let to become large, while trees in random forests are usually fully developed;\n    \\item Single decision trees do not make use of bootstrap sampling;\n    \\item The splitting strategy in single decision trees consists in selecting\n          the split that maximizes the Gini criterion. By contrast, in random forests,\n          the splitting strategy is randomized.\n    \\end{itemize}\n\n\\item \\citet{zhao:2000}:\\hfill\\\\\n    One of the earliest works studying the consistency of ensembles of\n    randomized trees is due to \\citet{zhao:2000}. In classification, the author\n    conjectures that PERT is (weakly) consistent, but establishes its strong\n    consistency (Theorem 4.4.2) provided the construction of the trees stops early. More\n    specifically, strong consistency is guaranteed provided:\n\n    \\begin{enumerate}\n        \\item Trees are grown\n            infinitely deeply while forming leaves with infinitely many node samples,\n            hence making empirical class proportions in terminal nodes\n            converge towards their theoretical counterparts. This is guaranteed,\n            e.g.,  by stopping the construction\n            when $N_t < N_\\text{min}^{(N)}$, such that\n            $N_\\text{min}^{(N)} \\to 0$ and  $N\\times N_\\text{min}^{(N)} \\to \\infty$ as $N \\to\n            \\infty$ (where $N_\\text{min}^{(N)}$ is the value of the $N_\\text{min}$ parameter\n            for a forest grown on a learning set of size $N$);\n\n        \\item The posterior class probabilities induced by the ensemble are all\n              continuous in the input space ${\\cal X}$.\n    \\end{enumerate}\n\n    Given the close formulations of the methods, results from \\citep{zhao:2000}\n    regarding PERT extend to Extremely Randomized Trees provided the posterior\n    class probabilities are continuous. In Appendix F of \\citep{geurts:2006},\n    Extremely Randomizes Trees (for $K=1$ and $M \\to \\infty$) are shown\n    to be a continuous piecewise multilinear function of its arguments,\n    which should therefore suffice to establish the strong consistency of the method when\n    trees are built totally at random.\n\n\\item \\citet{breiman:2004}:\\hfill\\\\\n    In this work, consistency is studied for a simplified variant of the Random\n    Forest algorithm, assuming (i) no bootstrap sampling, (ii) that variables are selected as split variables\n    with probability $p(m)$ (for $m=1,\\dots,p$), (iii) that splits on\n    relevant variables are set at the midpoint of the values of the selected\n    variable, (iv) that splits on irrelevant variables are set at random points\n    along the values of the selected variable and (v) that trees are balanced.\n    Under these assumptions,  it can be shown that this variant reduces\n    to an (adaptive) nearest neighbor algorithm~\\citep{lin:2006}, for which (weak) consistency\n    conditions are met (both in regression and classification).\n    Additionally, this work studies the bias-variance decomposition of this simplified\n    method and shows that the rate of convergence towards the Bayes error\n    only depends on the number $r$ of relevant variables, hence explaining\n    why random forests work well even with many noise variables.\n\n\\item \\citet{biau:2008}:\\hfill\\\\\n    In binary classification, \\citet{biau:2008} proves that if the randomized base\n    models in an ensemble are consistent, then the corresponding majority\n    or soft voting ensembles are also consistent. (This result\n    was later expanded both for multi-class classification~\\citep{denil:2013b} and\n    regression~\\citep{denil:2013}.)\n\n    From this proposition, the consistency of Purely Random Forests\n    \\citep{breiman2000some} is established.  Let us assume that the input space\n    ${\\cal X}$ is supported on $[0,1]^p$ and that terminal nodes represent\n    hyper rectangles of $[0,1]^p$, called cells, and forming together a\n    partition of $[0,1]^p$. At each step, one of the current terminal nodes $t$\n    and one the $p$ input variables are chosen uniformly at random. The\n    selected node $t$ is then split along the chosen variable at a random\n    location, along the length of the chosen side in $t$. This\n    procedure is repeated $k \\geq 1$ times, which amounts to developing  trees\n    in random order.  In this setting, and similarly to PERT, (strong) consistency of\n    Purely Random Forests is guaranteed whenever $\\smash{k^{(N)} \\to \\infty}$ and\n    $\\smash{\\tfrac{k^{(N)}}{N} \\to 0}$ as $N \\to \\infty$ (where $\\smash{k^{(N)}}$  is the value\n    of $k$ for a forest grown on learning set of size $N$) -- which is equivalent\n    to letting the number of points in terminal nodes grow to infinity.\n\n    In Purely Random Forests, let us remark that trees are built in a\n    data-independent manner, without even looking at the samples in ${\\cal L}$. In\n    this same work, and assuming no bootstrap sampling, the authors show that consistency is however\n    also guaranteed when the position of the cut is chosen in a data-dependent\n    manner, by selecting a random gap between consecutive node samples (ordered\n    along the chosen variable) and then sampling uniformly within the gap.\n\n\\item \\citet{biau:2012}:\\hfill \\\\\n    In this work, the authors more closely approaches the consistency of the\n    actual Random Forest algorithm and prove the consistency of the following\n    variant.\n\n    Again, let us assume that the input space ${\\cal X}$ is supported on\n    $[0,1]^p$ and that terminal nodes represent hyper rectangles of $[0,1]^p$,\n    forming together a partition of the input space. At each step, all current\n    terminal nodes are independently split using one of the $p$ input variables\n    $X_j$, drawn with probability $p_{j}^{(N)}$, and using as threshold the\n    mid-point of the chosen side in $t$. This procedure is repeated $\\lceil\n    \\log_2 k \\rceil$ times, which amounts to developing trees in breadth-first\n    order until depth $\\lceil \\log_2 k \\rceil$. (Strong) Consistency is then guaranteed\n    whenever  $\\smash{p_j^{(N)} k^{(N)} \\to \\infty}$ (for $j=1,\\dots,p$) and\n    $\\smash{\\tfrac{k^{(N)}}{N} \\to 0}$ as $N \\to \\infty$.\n\n    In particular, by properly defining the probabilities  $p_j$, this result\n    can be shown to include the situation where, at each node, randomness is\n    introduced by selecting at random a subset of $K$ variables and splitting\n    along the one that maximizes some impurity criterion, like in Random\n    Forest. (Note however that best cut-points coincide with the mid-points\n    only for some probability distributions.) Assuming no bootstrap sampling\n    and provided that two independent datasets are used for evaluating the\n    goodness of the splits and fitting the prediction values at leafs,\n    consistency of the method is then also established.\n\n    Interestingly, and corroborating results of \\citep{breiman:2004}, this work\n    also highlights the fact that performance of random forests only depends on\n    the number $r$ of relevant variables, and not on $p$, making the method\n    robust to overfitting.\n\n\\item \\citet{denil:2013}:\\hfill \\\\\n    Building upon \\citep{biau:2012}, \\citet{denil:2013} narrowed the gap\n    between theory and practice by proving the consistency of the following variant.\n\n    For each tree in the forest, the learning set is partitioned randomly into\n    structure points (used for determining splits) and estimation points (used\n    for fitting values at leafs).  Again, let us assume that the input space\n    ${\\cal X}$ is supported on $[0,1]^p$ and that terminal nodes represent\n    hyper rectangles of $[0,1]^p$, forming together a partition of the input\n    space. At each step, current terminal nodes are expanded by drawing at\n    random $\\min(1+\\text{Poisson}(\\lambda), p)$ variables and then looking for\n    the cut-point that maximizes the impurity criterion, as computed over $m$\n    randomly drawn structure points. The construction halts when no split\n    leading to child nodes with less than $k$ node samples can be found.\n\n    In regression, assuming not bootstrap sampling, (strong)  consistency of this variant\n    is guaranteed whenever $k^{(N)} \\to \\infty$ and $\\tfrac{k^{(N)}}{N} \\to 0$\n    as $N \\to \\infty$ (where $k^{(N)}$  is the value of $k$ for a forest grown\n    on learning set of size $N$).\n\n\\item \\citet{scornet:2014}:\\hfill \\\\\n    This work establishes the first consistency result for the original Random\n    Forest algorithm. In particular, (strong)  consistency is obtained in the context of\n    regression additive models, assuming subsampling without replacement\n    (instead of bootstrap sampling). This work is the first result\n    establishing consistency when (i) splits are chosen in a data-dependent\n    manner and (ii) leafs are not let to grow to an infinite number of node samples.\n\n\\end{description}\n\nIn conclusions, despite the difficulty of the mathematical analysis of the\nmethod, these theoretical works provide together converging arguments all\nconfirming why random forests -- including the Random Forest algorithm but also\nExtremely Randomized Trees -- appear to work so well in practice.\n\nFinally, let us complete this review by mentioning consistency results in the\ncase of domain-specific adaptations of random forests, including quantile\nregression~\\citep{meinshausen:2006}, survival analysis~\\citep{ishwaran:2010}\nand online forest construction~\\citep{denil:2013b}.\n", "meta": {"hexsha": "a10c6cc52b26e793772d786f8fc6974acb548201", "size": 86413, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/chapters/chapter04.tex", "max_stars_repo_name": "mathkann/understanding-random-forests", "max_stars_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 353, "max_stars_repo_stars_event_min_datetime": "2015-01-03T13:34:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T05:16:30.000Z", "max_issues_repo_path": "tex/chapters/chapter04.tex", "max_issues_repo_name": "mathkann/understanding-random-forests", "max_issues_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-06-29T05:43:41.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-29T05:43:41.000Z", "max_forks_repo_path": "tex/chapters/chapter04.tex", "max_forks_repo_name": "mathkann/understanding-random-forests", "max_forks_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 153, "max_forks_repo_forks_event_min_datetime": "2015-01-14T03:46:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-26T10:13:51.000Z", "avg_line_length": 63.3062271062, "max_line_length": 508, "alphanum_fraction": 0.7287792346, "num_tokens": 24730, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.441464527317653}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{amsmath}\n\n\n\\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}\n%\\topmargin=0cm\n\\topmargin=-2cm\n\\addtolength{\\textheight}{6.5cm}\n\\addtolength{\\textwidth}{2.0cm}\n%\\setlength{\\leftmargin}{-5cm}\n\\setlength{\\oddsidemargin}{0.0cm}\n\\setlength{\\evensidemargin}{0.0cm}\n\n\\newcommand{\\HRule}{\\rule{\\linewidth}{1mm}}\n\n%misc libraries goes here\n\\usepackage{tikz}\n\\usetikzlibrary{automata,positioning}\n\n\\begin{document}\n\n\\noindent\n\\HRule \\\\[3mm]\n\\begin{flushright}\n\n                                         \\LARGE \\textbf{CENG 222}  \\\\[4mm]\n                                         \\Large Statistical Methods for Computer Engineering \\\\[4mm]\n                                        \\normalsize      Spring '2018-2019 \\\\\n                                           \\Large   Homework 3 \\\\\n\\end{flushright}\n\\HRule\n\n\\section*{Student Information }\n%Write your full name and id number between the colon and newline\n%Put one empty space character after colon and before newline\nFull Name : Yavuz Selim Yesilyurt \\\\\nId Number : 2259166 \n\n% Write your answers below the section tags\n\\section*{Answer a}\nI have conducted a Monte Carlo study using Matlab, after which I have used this study for estimating the probability that the total weight of all vehicles that pass over the bridge in the village in a day is more than 220 tons, for estimating expected weight and calculating the standard deviation of it. \\\\\n\nTo conduct such a study I have first used Normal approximation with $\\alpha = 0.01$ and $\\epsilon = 0.02$, namely (since no estimator for $p$ has been given I have directly used the following):\n\n\\begin{align*}\nN &\\geq 0.25(\\frac{z_{\\alpha/2}}{\\epsilon})^2 \\\\\n  &= 0.25(\\frac{2.575}{0.02})^2 \\\\\n  &\\approx 4144\n\\end{align*}\n\nI have created some variables for holding the values of distribution parameters and I have also created a vector named $TotalWeight$ for keeping the total weight of vehicles that use the bridge for each Monte Carlo run and initialized it to 0 for all $N$.\\\\\n\nNext, to find number of vehicles for each type, I have generated samples ($NMotors$, $NCars$ and $NTrucks$) for all vehicles with their corresponding Poisson parameters using sampling from Poisson. \\\\\n\nThen, to find weights of each vehicle according to its type, I have used the samples that correspond to numbers for each type of vehicles together with their corresponding Gamma parameters. With this way I was able to generate the sample weights for all vehicles ($WMotors$, $WCars$ and $WTrucks$) and after summing them up at the end I have calculated the total weight for 1 Monte Carlo run and filled the corresponding place in my $TotalWeight$ vector. I have repeated this study $N=4144$ times and filled the $TotalWeight$ vector accordingly. \\\\\n\nFor the answer of \\textit{part a}; after construction of $TotalWeight$ vector with desired Monte Carlo runs, I have calculated the \\textit{mean} of the proportion of runs with the total weight more than 220 tons. With this way I have estimated the probability that the total weight of all the vehicles that pass over the bridge in a day is more than 220 tons; in other words, I have found our estimator for the desired probability. \\\\\n\nI have simulated my solution in Octave Online a number of times and I was able to determine that my estimated probability is always in between 0.35 and 0.38 (But in general 0.36). I share a sample output (which I will refer in other parts of the answer) in below:\n\n\\begin{center}\nEstimated probability = 0.364865 \\\\\nExpected weight = 208441.367130 \\\\\nStandard deviation = 38401.600168 \n\\end{center}\n\n\\section*{Answer b}\nFor estimation of the total weight of all the vehicles that pass over the bridge in a day $X$, I have simply got the \\textit{mean} of $TotalWeight$ and found the Expected weight. Expected weight for a sample simulation can be seen from the sample output shared in part a.\n\n\\section*{Answer c}\nFor estimation of $Std(X)$, I have simply got the \\textit{std} of $TotalWeight$ and found the Standard deviation of $X$. Standard deviation for a sample simulation can be seen from the sample output shared in part a.\\\\\n\nSince initially we have created a Monte Carlo study with size $N$ that attains our desired accuracy ($\\alpha = 0.01$ and $\\epsilon = 0.02$), We have guaranteed a Monte Carlo study of size $N$ with an error not exceeding $\\epsilon$ with high probability $(1-\\alpha)$ and created an estimator $X$ with that accuracy.\n\n\\end{document}\n", "meta": {"hexsha": "b4b8b28584df4f8f436badaba8090c49cec7b5a0", "size": 4510, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "222/hw3/the3.tex", "max_stars_repo_name": "ysyesilyurt/Metu-CENG", "max_stars_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 33, "max_stars_repo_stars_event_min_datetime": "2019-03-19T07:51:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:04:35.000Z", "max_issues_repo_path": "222/hw3/the3.tex", "max_issues_repo_name": "ysyesilyurt/Metu-CENG", "max_issues_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-11-09T18:08:21.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-09T18:08:21.000Z", "max_forks_repo_path": "222/hw3/the3.tex", "max_forks_repo_name": "ysyesilyurt/Metu-CENG", "max_forks_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2019-11-08T06:18:21.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T17:17:38.000Z", "avg_line_length": 57.8205128205, "max_line_length": 548, "alphanum_fraction": 0.7350332594, "num_tokens": 1139, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.4414645235353425}}
{"text": "\n\\typeout{new file: Verification_Tests_Chapter.tex}\n\n\\chapter{Verification Tests}\n\\label{sec:verification}\n\nThis chapter reports the results of the verification tests performed with the new fuel data, \\textit{i.e.} Ethylene ($\\rm C_2H_4$), Ethane ($\\rm C_2H_6$), Propylene ($\\rm C_3H_6$), Propane ($\\rm C_3H_8$), Toluene ($\\rm C_7H_8$),\n  \\textit{n}-Heptane ($\\rm C_7H_{16}$), Methanol ($\\rm CH_3OH$), Methyl Methacrylate ($\\rm C_5H_8O_2$). Synthetic transmissivity spectrum were generated with RadCal and compared with all the experimental data they were extract from. The experimental data resolution was adjusted to match that of RadCal:\n\\begin{equation}\n \\begin{cases}\n   5~{\\rm cm}^{-1},\\, & \\om \\leq 1000 {\\rm cm^{-1}}\\\\\n    25~{\\rm cm}^{-1},\\,& 5000 > \\om > 1000 {\\rm cm^{-1}} \\\\\n    50~{\\rm cm}^{-1},\\,& \\om > 5000 {\\rm cm^{-1}}\n \\end{cases}\n\\end{equation}\n\nThe relative error between the experimental and the RadCal-generated transmissivity, denoted $\\epsilon{(\\tau_{\\omega})}$, was also quantified. The relative error between the experimental and the RadCal calculated transmissivities can also be quantified by a weighted average relative error $\\epsilon$ over the entire experimental spectrum. A useful test function to perform the weighting is given by the spectral emissivity. Assuming Kirchhoff's law applies for each wavenumber over a narrow band, the spectral emissivity of a narrow band, denoted $\\bar{\\varepsilon}_{\\omega}$, is given by:\n\\begin{equation}\n \\bar{\\varepsilon}_{\\omega} = 1 -\\bar{\\tau}_{\\omega}.\n\\end{equation}\nThe weighted average error is then defined by the following relation:\n\\begin{equation}\n\\label{eq:WeightedError}\n \\langle\\epsilon{(\\bar{\\tau}_{\\omega})}\\rangle = \\dfrac{\\displaystyle\\int\\limits_{700}^{4000}\\bar{\\varepsilon}_{\\omega}\\epsilon(\\bar{\\tau}_{\\omega}) {\\rm d} \\omega}{\\displaystyle\\int\\limits_{700}^{4000}\\bar{\\varepsilon}_{\\omega} {\\rm d} \\omega}.\n\\end{equation}\n\nFigure~\\ref{fig:Verify_All} plots the maximum relative error and the maximum integrated weighted error for all the new species. Note that the values given in these plot correspond to the maximum over the set of tested temperatures.\n\n\\begin{figure}\n\\begin{center}\n      \\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Test2_Results.pdf}\n\\end{center}\n \\caption{Left: Maximum relative error, in percent, across the whole spectrum and temperature for the new molecules implemented in RadCal. Right: Maximum integrated weighted error (across tested temperatures) calculated using Eq.~\\ref{eq:WeightedError}. \\label{fig:Verify_All}}\n\\end{figure}\n\nIn the following sections below, for each species, detailed plots comparing the spectral experimental transmissivities with the synthetic ones calculated with RadCal are presented along with plots of the spectral relative error in transmissivity for each pressure-path and temperature tested. Very good agreement is overall found except in some well localized parts of the spectrum for the heaviest molecules and usually at elevated temperature. The reason behind it is that at elevated temperature, the experimental measurements were very close to the optically thin limit, \\textit{i.e.} $\\tau \\rightarrow 1$, and thus some of the measurements were affected by the FTIR sensitivity. Nevertheless, when comparing integrated quantities, \\textit{e.g.} the integrated weighted error, the match between experimental and predicted results is very good.\n\n\n\\clearpage\n\n\\section{Ethylene: $\\rm C_2H_4$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_296.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 296~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_296K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_400.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 400~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_400K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_450.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 450~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_450K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_500.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 500~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_500K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_601.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 601~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_600K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_801.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 801~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_801K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethylene_1000.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethylene of an isothermal homogeneous column of ethylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.305, 0.18, and 0.0784 atm.cm. The gas temperature is set at 1000~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethylene_Verify_1000K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Ethane: $\\rm C_2H_6$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_296.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 296~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_296K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_400.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 400~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_400K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_450.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 450~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_450K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_500.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 500~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_500K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_600.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 600~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_600K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_800.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 801~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_800K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Ethane_1000.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of ethane of an isothermal homogeneous column of ethane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.339, 0.211, and 0.0812 atm.cm. The gas temperature is set at 1000~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:ethane_Verify_1000K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Propylene: $\\rm C_3H_6$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_296.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 296~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_296K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_390.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 390~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_390K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_444.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 444~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_444K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_491.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 491~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_491K}}\n\\end{figure}\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_594.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 594~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_594K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_793.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 793~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_793K}}\n\\end{figure}\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propylene_1003.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propylene of an isothermal homogeneous column of propylene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.476, 0.318, and 0.159 atm.cm. The gas temperature is set at 1003~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propylene_Verify_1003K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Propane: $\\rm C_3H_8$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_295.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.127, 0.0794, and 0.0318 atm.cm. The gas temperature is set at 295~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_295K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_396.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.0794, and 0.127 atm.cm. The gas temperature is set at 396~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_396K}}\n\\end{figure}\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_435.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.0794, and 0.127 atm.cm. The gas temperature is set at 435~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_435K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_513.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.127, and 0.0794 atm.cm. The gas temperature is set at 513~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_513K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_578.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.0794, and 0.127 atm.cm. The gas temperature is set at 578~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_578K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_790.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.0794, and 0.127 atm.cm. The gas temperature is set at 790~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_790K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Propane_1009.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of propane of an isothermal homogeneous column of propane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0318, 0.0794, and 0.127 atm.cm. The gas temperature is set at 1009~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:propane_Verify_1009K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Toluene: $\\rm C_7H_8$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_300.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.101, 0.0809, and 0.136 atm.cm. The gas temperature is set at 300~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_300K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_396.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.081, 0.125, and 0.0959 atm.cm. The gas temperature is set at 396~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_396K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_440.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.109, 0.0846, and 0.0743 atm.cm. The gas temperature is set at 440~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_440K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_477.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0831, 0.126, and 0.0963 atm.cm. The gas temperature is set at 477~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_477K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_587.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.118, 0.0961, and 0.0812 atm.cm. The gas temperature is set at 587~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_587K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_795.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.128, 0.0966, and 0.0834 atm.cm. The gas temperature is set at 795~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_795K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Toluene_999.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of toluene of an isothermal homogeneous column of toluene. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.138, 0.104, and 0.0896 atm.cm. The gas temperature is set at 999~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:toluene_Verify_999K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{\\textit{n}-Heptane: $\\rm C_7H_{16}$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_293.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.015, 0.0313, and 0.0493 atm.cm. The gas temperature is set at 293~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_293K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_400.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0476, 0.0302, and 0.0145 atm.cm. The gas temperature is set at 400~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_400K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_450.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0497, 0.0312, and 0.0152 atm.cm. The gas temperature is set at 450~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_450K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_490.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0496, 0.0306, and 0.015 atm.cm. The gas temperature is set at 490~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_490K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_593.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0504, 0.0315, and 0.0152 atm.cm. The gas temperature is set at 593~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_593K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_794.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0149, 0.0441, and 0.0302 atm.cm. The gas temperature is set at 794~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_794K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Heptane_1000.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of \\textit{n}-heptane of an isothermal homogeneous column of \\textit{n}-heptane. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0308, 0.0174, and 0.0365 atm.cm. The gas temperature is set at 1000~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:nheptane_Verify_1000K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Methanol: $\\rm CH_3OH$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_293.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0498, 0.0716, and 0.0925 atm.cm. The gas temperature is set at 293~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_293K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_396.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0505, 0.0738, and 0.0932 atm.cm. The gas temperature is set at 396~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_396K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_443.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0459, 0.071, and 0.094 atm.cm. The gas temperature is set at 443~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_443K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_483.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0489, 0.0703, and 0.0907 atm.cm. The gas temperature is set at 483~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_483K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_570.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0922, 0.05, and 0.0726 atm.cm. The gas temperature is set at 570~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_570K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_804.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0537, 0.0785, and 0.101 atm.cm. The gas temperature is set at 804~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_804K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/Methanol_1000.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of methanol of an isothermal homogeneous column of methanol. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.097, 0.0731, and 0.049 atm.cm. The gas temperature is set at 1000~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:methanol_Verify_1000K}}\n\\end{figure}\n\n\n\\clearpage\n\n\\section{Methyl Methacrylate: $\\rm C_5H_8O_2$}\n\n\\begin{figure}[h]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_297.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.1, 0.0785, and 0.0545 atm.cm. The gas temperature is set at 297~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_297K}}\n\\end{figure}\n\n\\newpage\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_396.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.102, 0.179, and 0.0782 atm.cm. The gas temperature is set at 396~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_396K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_441.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0946, 0.074, and 0.0508 atm.cm. The gas temperature is set at 441~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_443K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_483.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0956, 0.0742, and 0.0512 atm.cm. The gas temperature is set at 483~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_483K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_597.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.0966, 0.0746, and 0.0516 atm.cm. The gas temperature is set at 597~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_597K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_803.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.106, 0.081, and 0.0554 atm.cm. The gas temperature is set at 803~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_803K}}\n\\end{figure}\n\n\\begin{figure}[p]\n\\includegraphics[width=\\textwidth]{../Verification/Results_Test2/MMA_1014.pdf}\n\\caption{Top: comparison between the experimental (solid lines) and RadCal-generated synthetic (dashed lines) spectral transmissivity profiles, denoted $\\tau_{\\omega}$, of MMA of an isothermal homogeneous column of MMA. Bottom: relative transmissivity error, denoted $\\epsilon{(\\tau_{\\omega})}$, between the experiment and the synthetic profiles presented on the top figure. Three different pressure path lengths are considered: 0.114, 0.0879, and 0.0598 atm.cm. The gas temperature is set at 1014~K and the total pressure is 101 kPa. Note: the experimental data resolution has been changed to match that of the narrow band model. \\label{fig:MMA_Verify_1014K}}\n\\end{figure}\n", "meta": {"hexsha": "499797a8d4c057337968bf70ba5cf0bf5dd128b7", "size": 48009, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Verification_Tests_Chapter.tex", "max_stars_repo_name": "mcgratta/radcal", "max_stars_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_stars_repo_licenses": ["Linux-OpenIB"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documentation/Verification_Tests_Chapter.tex", "max_issues_repo_name": "mcgratta/radcal", "max_issues_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_issues_repo_licenses": ["Linux-OpenIB"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/Verification_Tests_Chapter.tex", "max_forks_repo_name": "mcgratta/radcal", "max_forks_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_forks_repo_licenses": ["Linux-OpenIB"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 127.6835106383, "max_line_length": 847, "alphanum_fraction": 0.7909766919, "num_tokens": 12315, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.441464516698463}}
{"text": "%!TEX root = ../notes.tex\n\\section{March 1, 2022}\n\\subsection{Power Residues}\nFor this section, corresponds to pages 45-46 of Ireland \\& Rosen \\cite{ireland1990classical} are a good reference.\n\\begin{definition}[Power Residue]\n    If $m, n\\in \\ZZ_+$ and $a\\in \\ZZ$ such that $(a, m) = 1$, then we say that \\ul{$a$ is an $n^\\mathrm{th}$ power residue} modulo $m$ if and only if the congruence\n    \\begin{equation}\\label{eqn:pow-residue}x^n\\equiv a\\mod m\\end{equation}\n    has solutions.\n\\end{definition}\nGiven \\cref{eqn:pow-residue}, we're interested in two questions:\n\\begin{enumerate}[1)]\n    \\item Does \\cref{eqn:pow-residue} have a solution?\n    \\item If yes, then how many?\n\\end{enumerate}\n\n\\begin{proposition}\\label{prop:4.2.1}\n    If $m\\in\\ZZ_+$ is such that $U(m)$ is cyclic, and $a\\in\\ZZ$ is such that $(a, m)=1$, then\n    \\[x^n\\equiv a\\mod m\\]\n    has solutions if and only if\n    \\[a^{\\phi(m)/d}\\equiv 1\\mod m\\]\n    where $d = (\\phi(m), n)$.\n\n    If there are solutions, then there are exactly $d$ solutions.\n\\end{proposition}\n\\begin{proof}\n    Let $g$ be a primitive root mod $m$, and let\n    \\[a=g^b.\\]\n    Suppose $x = g^y$. Then\n    \\begin{alignat*}{3}\n         &        &  & x^n    &  & \\equiv a\\mod m       \\\\\n         & \\iff\\  &  & g^{ny} &  & \\equiv g^b\\mod m     \\\\\n         & \\iff   &  & ny     &  & \\equiv b\\mod \\phi(m)\n    \\end{alignat*}\n    This is solvable if and only if $d=(\\phi(m), n)\\mid b$. If there is at least one solution, then there are exactly $d$ solutions.\n\n    Now we show that $d\\mid b\\Leftrightarrow a^{\\phi(m)/d}\\equiv 1\\mod m$.\n\n    Forward direction:\n    \\[a^{\\phi(m)/d} = g^{b\\cdot \\phi(m)/d} = \\left(g^{\\phi(m)}\\right)^{b/d} = 1\\mod m\\]\n\n    Backward direction:\n    \\[a^{\\phi(m)/d}\\equiv 1\\mod m \\Rightarrow g^{b\\cdot \\phi(m)/d}\\equiv 1\\mod m \\Rightarrow \\phi(m)\\mid b\\cdot \\phi(m)/d \\Rightarrow \\frac{b}{d}\\in\\ZZ\\]\n\\end{proof}\n\nWe can prove this using a similar group theory theorem that we can apply directly.\n\\begin{theorem}\\label{thm:ft-cyclic-groups}\n    Let $G$ be a cyclic group of order $n$, suppose $k\\in\\ZZ_+$ and $a\\in G$. Then $a=b^k$ ($a$ is a $k^\\mathrm{th}$ power in $G$) iff $a^{n/(k,n)} = e$ iff $x^k = a$ has $(n, k)$ solutions in $G$.\n\\end{theorem}\n\nThe proof of this theorem uses the following lemma:\n\\begin{lemma}\n    Let $G$ be a cyclic group of order $n$ and let $H$ be a subgroup of $G$ of order $d$. Then $x\\in H$ iff $x^d = e$ iff $\\ord(x)\\mid d$.\n\\end{lemma}\n\n\\begin{proof}[Proof of \\cref{thm:ft-cyclic-groups}]\n    Let $H$ be a subgroup of $k^\\mathrm{th}$ powers in $G$\\footnote{This is indeed a subgroup. We use the fact that $G$ is Abelian.}, and let $g\\in G$ be such that $G = \\langle g\\rangle$.\n\n    Then $H = \\{g^{jk}\\mid j\\in \\ZZ\\} = \\langle g^k\\rangle$. Since $\\ord(g^k) = \\frac{n}{(k, n)}$ (\\emph{exercise}), we that $|H| - \\frac{n}{(k,n)}$.\n\n    Consider $\\phi: G\\to G$ that powers by $k$, $\\phi: x\\mapsto x^k$. Then $\\im(\\phi) = H$, so this implies that $\\phi$ is a $(k, n)$-to-$1$ mapping (so gives us the number of solutions to each power, and how many $k$ powers there are).\n\\end{proof}\n\nKnowing how to solve these modulo a group of units gives us ways using CRT/Sunzi's Theorem to solve mod composite numbers.\n\nWe write $m = 2^ep_1^{e_1}\\cdots p_r^{e_r}$ where $p_i$ are pairwise distinct odd primes. Then\n\\[x^n\\equiv a\\mod m, \\quad (a, m) = 1\\]\nis solvable if and only if the system\n\\begin{align*}\n    x^n & \\equiv a\\mod 2^e       \\\\\n    x^n & \\equiv a\\mod p_i^{e_i} \\\\\n        & \\vdots                 \\\\\n    x^n & \\equiv a\\mod p_r^{e_r}\n\\end{align*}\nis solvable.\n\nWe have that $U(p_i^{e_i}), U(2), U(4)$ are all cyclic. Hence our prior discussion can be applied to those.\n\n\\begin{ques*}\n    How do we solve\n    \\[x^n\\equiv a\\mod m\\]\n    where $e\\geq 3$ (for powers of $2$)?\n\\end{ques*}\n\\begin{proposition}[4.2.2 from Text]\n    Let $a\\in\\ZZ$ be odd, $e\\geq 3$, and consider $x^n\\equiv a\\mod 2^e$.\n\n    If $n$ is odd, then $a$ solution exists and is unique. If $n$ is even, $a$ solution exists if and only if $a\\equiv 1\\mod 4$ and $a^{2^{e-2}/d}\\equiv 1\\mod 2^e$ where $d = (n, 2^{e-2})$. When a solution exists, there are exactly $2d$ solutions.\n\\end{proposition}\n\\begin{proof}\n    \\emph{Exercise to come.}\n\\end{proof}\n\n\\subsection{Quadratic Residues}\nThings are a lot simpler and nicer when we consider only quadratic congruences (as opposed to arbitrary residues).\n\\begin{definition}[Quadratic Residue]\n    Let $a\\in\\ZZ$, $m\\in\\ZZ_+$, $(a, m) = 1$. We say that $a$ is a \\ul{quadratic residue mod $m$} if the congruence\n    \\begin{equation}\\label{eqn:quadratic-residue}x^2\\equiv a\\mod m\\end{equation}\n    has a solution.\n\\end{definition}\n\nConversely, if $a$ is not a quadratic residue (that is, \\cref{eqn:quadratic-residue} does not have a solution), we call it a \\ul{nonresidue} or a \\ul{quadratic nonresidue}.\n\nWe extract the consequences of previous propositions to get special cases of propositions 4.2.3 and 4.2.4 from text.\n\n\\begin{enumerate}[1)]\n    \\item\n          Let $p\\in\\ZZ_+$ be an odd prime, and suppose $a\\in\\ZZ$ with $p\\nmid a$. Then\n          \\begin{align*}\n              x^2 & \\equiv a\\mod p\n              \\intertext{is solvable iff}\n              x^2 & \\equiv a\\mod p^e\n          \\end{align*}\n          is solvable for all $e\\geq 1$.\n    \\item\n          Let $a\\in\\ZZ$ be odd. Then\n          \\begin{align*}\n              x^2 & \\equiv a\\mod 8\n              \\intertext{is solvable iff }\n              x^2 & \\equiv a\\mod 2^e\n          \\end{align*}\n          is solvable for all $e\\geq 3$.\n\\end{enumerate}\n\\begin{proposition}[5.1.1 from Text]\n    Let\n    \\[m = 2^ep_1^{e_1}\\cdots p_r^{e_r}\\]\n    be the prime factorization of $m\\in\\ZZ_+$, and suppose $(a, m) = 1$.\n\n    Then\n    \\begin{equation}\\label{eqn:5.1.1}\n        x^2\\equiv a\\mod m\n    \\end{equation}\n    is solvable if and only if three conditions are satisfied:\n    \\begin{enumerate}[i.]\n        \\item If $e = 2$, then $a\\equiv 1\\mod 4$.\n        \\item If $e\\geq 3$, then $a\\equiv 1\\mod 8$.\n        \\item For each $i$, have\n              \\[a^{(p_i-1)/2}\\equiv 1\\mod p_i\\]\n    \\end{enumerate}\n\\end{proposition}\n\\begin{proof}\n    Sunzi's theorem tells us that \\cref{eqn:5.1.1} is solvable iff\n    \\begin{align*}\n        x^2 & \\equiv x\\mod 2^e       \\\\\n        x^2 & \\equiv a\\mod p_1^{e_1} \\\\\n            & \\vdots                 \\\\\n        x^2 & \\equiv a\\mod p_r^{e_r}\n    \\end{align*}\n    are \\emph{all} solvable.\n\n    First consider the first equation $x^2\\equiv 1\\mod 2^e$. $1$ is the only quadratic residue mod $4$ and the same thing is true mod $8$. On the other hand, black box 2 gives us $x^2\\equiv a\\mod 8$ is solvable iff $x^2\\equiv a\\mod 2^e$ for $e\\geq 3$. This gives us conditions i and ii.\n\n    Now consider $x^2\\equiv a\\mod p_i^{e_i}$. \\Cref{prop:4.2.1} gives that $x^2\\equiv a\\mod p_i$ is solvable iff $a^{(p_i - 1)/2}\\equiv 1\\mod p_i$. Black box 1 then tells us that\n    \\begin{align*}\n        x^2           & \\equiv a\\mod p_i\\quad\\text{is solvable}        \\\\\n        \\iff\\quad x^2 & \\equiv a\\mod p_i^{e_i}\\quad\\text{is solvable.}\n    \\end{align*}\n    which concludes our proof.\n\\end{proof}\n\n\\begin{remark*}\n    Studying these quadratic congruences amounts to studying them modulo primes.\n\\end{remark*}\n\n\\subsection{The Legendre Symbol}\n\\begin{definition}[The Legendre Symbol]\\label{defn:legendre-symbol}\n    Let $p$ be an odd prime, and let $a\\in\\ZZ$.\n    \\[\\lege{a}{p} = \\begin{cases}\n            1  & \\text{if $a$ is a quadratic residue mod $p$} \\\\\n            0  & \\text{if $p\\mid a$}                          \\\\\n            -1 & \\text{otherwise}\n        \\end{cases}\\]\n    This symbol $\\lege{a}{p}$ is called the Legendre symbol.\n\\end{definition}\n\n\\begin{proposition}[5.1.2 of Text]\\label{prop:5.1.2}\n    We have the following properties of the Legendre symbol:\n    \\begin{enumerate}[(a)]\n        \\item\n              \\[\\lege{a}{p} = a^{(p-1)/2}\\mod p\\]\n              This is called \\emph{Euler's Criterion}.\n        \\item\n              \\[\\lege{ab}{p} = \\lege{a}{p}\\cdot\\lege{b}{p}\\]\n              which is to say that the Legendre symbol is totally multiplicative.\n        \\item If $a\\equiv b\\mod p$, then\n              \\[\\lege{a}{p} = \\lege{b}{p}.\\]\n    \\end{enumerate}\n\\end{proposition}", "meta": {"hexsha": "86314f06652ba59144acecd276cee09aa13a336c", "size": 8167, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-03-01.tex", "max_stars_repo_name": "jchen/math1560-notes", "max_stars_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-02T15:41:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T20:28:48.000Z", "max_issues_repo_path": "lectures/2022-03-01.tex", "max_issues_repo_name": "jchen/math1560-notes", "max_issues_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-03-01.tex", "max_forks_repo_name": "jchen/math1560-notes", "max_forks_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9086021505, "max_line_length": 286, "alphanum_fraction": 0.601322395, "num_tokens": 2891, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.44139839817301946}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\n\\author{Fuad Aji Pratomo}\n\\title{LaTeX Intro}\n\n\\begin{document}\n\n\\maketitle\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n\nExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\n\\section{Introductio}\nThis section introduce a paper or journal\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\n\\section{Formatting}\n\n\\subsection{Formatting Subsection}\n\nLet $D$ be a subset of $\\bf R$ and let\n$f \\colon D \\to \\mathbf{R}$ be a real-valued function on\n$D$. The function $f$ is said to be \\emph{continuous} on\n$D$ if, for all $\\epsilon > 0$ and for all $x \\in D$,\nthere exists some $\\delta > 0$ (which may depend on $x$)\nsuch that if $y \\in D$ satisfies\n\\[ |y - x| < \\delta \\]\nthen\n\\[ |f(y) - f(x)| < \\epsilon. \\]\n\nOne may readily verify that if $f$ and $g$ are continuous\nfunctions on $D$ then the functions $f+g$, $f-g$ and\n$f.g$ are continuous. If in addition $g$ is everywhere\nnon-zero then $f/g$ is continuous.\n\n\\end{document}", "meta": {"hexsha": "65b153b050103b9a71ce85d6e6eec99208e156d7", "size": 1385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "example.tex", "max_stars_repo_name": "fuadajip/latex-intro", "max_stars_repo_head_hexsha": "52e7d58ee897af0c7a85bb3450757ef5a31a85c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-21T17:58:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-21T17:58:51.000Z", "max_issues_repo_path": "example.tex", "max_issues_repo_name": "fuadajip/latex-intro", "max_issues_repo_head_hexsha": "52e7d58ee897af0c7a85bb3450757ef5a31a85c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "example.tex", "max_forks_repo_name": "fuadajip/latex-intro", "max_forks_repo_head_hexsha": "52e7d58ee897af0c7a85bb3450757ef5a31a85c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4473684211, "max_line_length": 210, "alphanum_fraction": 0.7422382671, "num_tokens": 385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.569852651414157, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.4413983952077321}}
{"text": "\\documentclass{article}%\n\\usepackage[T1]{fontenc}%\n\\usepackage[utf8]{inputenc}%\n\\usepackage{lmodern}%\n\\usepackage{textcomp}%\n\\usepackage{lastpage}%\n%\n\\input{common_symbols_and_format.tex}%\n\\usepackage{tocloft}%\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}%\n%\n\\begin{document}%\n\\normalsize%\n\\logo%\n\\rulename{Static Combination Regression}%\n\\tblofcontents%\n\n\\ruledescription{Regresses the one-day price changes against the lagged level and one day change of the signal for the specified number of days, using coefficients estimated from the start of the data.}\n\\howtotrade{\nGiven default parameter values, if the asset drift is 0.01 and the error is 0.05 (5\\% daily volatility), this rule will take a $0.01 / (0.05)^2  = 4.0$ or 400\\% position (leveraged).}\n{\n\\begin{figure}[H]\n\\begin{multicols}{2}\n  \\centering\n    \\begin{subfigure}{\\linewidth}\n        \\includegraphics[width=\\linewidth]{\\graphdir{market.png}}\n        \\caption{Market series data}\n        \\label{fig:01}\n    \\end{subfigure}\n  \\par\n  \\vspace{5mm}\n  \\begin{subfigure}{\\linewidth}\n    \\includegraphics[width=\\linewidth]{\\graphdir{research.png}}\n    \\caption{Research series data}\n    \\label{fig:02}\n  \\end{subfigure}\n  \\par\n  \\begin{subfigure}{\\linewidth}\n    \\includegraphics[width=\\linewidth]{\\graphdir{pa(StaticCombinationRegression).png}}\n    \\caption{ Suggested volume to buy or sell}\n    \\label{fig:03}\n  \\end{subfigure}\n  \\par\n  \\vspace{5mm}\n  \\begin{subfigure}{\\linewidth}\n    \\includegraphics[width=\\linewidth]{\\graphdir{pr(StaticCombinationRegression).png}}\n    \\caption{Portfolio return}\n    \\label{fig:04}\n  \\end{subfigure}\n  \\end{multicols}\n  \\caption{Graphical depiction of the Static Combination Regression algorithm. 20 Days of trading data is visualised in the graphs (\\ref{fig:01}) A line chart showing changes in the market price for multiple trading days. (\\ref{fig:02}) A chart displaying the research series data. (\\ref{fig:03}) Positive values indicate that buying the security by x\\%. The negative values mean you are shorting the security by x\\% (\\ref{fig:04}) Chart showing the portfolio return when using the Static Combination Regression as the trading rule.}\n  \\label{fig:cps_graph}\n\\end{figure}\n\n\n}\n\n\\ruleparameters{Kelly fraction}{1.0}{Amplitude weighting. 1.0 is maximum growth if regression is exact. <1.0 scales down positions taken.}{$\\kellyfraction$}{Regression length}{50}{This is the number of days used to estimate the regression coefficients.}{$\\lookbacklength$}%\n\\stoptable%\n\n\\section{Equation}\nThe equations below govern how the static combination regression rule calculates a trading position.\n\n\n\n\\begin{equation}\n\\regressionprice_\\currenttime = \\amplitudecoefficientone\\research_\\currenttime + \\amplitudecoefficienttwo(\\frac{\\research_\\currenttime}{\\research_{\\currenttime - 1}} - 1) +\\amplitudecoefficientthree(\\frac{\\price_\\currenttime}{\\research_\\currenttime}-1)+\\constantc\n\\label{eq1}\n\\end{equation}\\\\\n\n\nIn the equation (\\ref{eq1}), the predictive price  $\\regressionprice_\\currenttime$ is calculated using the static change regression, static difference regression and static level regression combined in one trading rule. Since we are using a static approach the amplitude coefficients $\\amplitudecoefficient$ remain constant. In order to calculate the resultant fractional portfolio allocation $\\position_{\\currenttime}$ we use the Kelly fraction to obtain the maximum results for the long run. \n\n\\begin{equation}\n\\position_\\currenttime = \\kellyfraction \\frac{\\regressionprice_\\currenttime}{ \\rmserror_{\\regressionprice}^{2}}  \\\\\n\\label{eq2}\n\\end{equation}\n\n\\hspace{200mm}\n\\\\\n\n\nwhere \n\n$\\research$:is the value of the research series.\n\n$\\regressionprice_\\currenttime$: is the predicted price at time $\\currenttime$.\n\n$\\rmserror_\\regressionprice$: is the standard error. \n\n$\\kellyfraction$ is the Kelly Fraction.\n\n$\\position$: is the resultant fractional portfolio investment.\n\n\nThe standard error $\\rmserror_{\\regressionprice}$ is calculated and included in equation (\\ref{eq2}) to normalize the predicted price. \n\n\n\\hspace{200mm}\n\\hspace{200mm}\n\n\\keyterms%\n\\furtherlinks%\n\\end{document}\n", "meta": {"hexsha": "b6495d4ae109bded6ec1209a280b709f2fb5517f", "size": 4106, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/StaticCombinationRegression.tex", "max_stars_repo_name": "pawkw/infertrade", "max_stars_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/StaticCombinationRegression.tex", "max_issues_repo_name": "pawkw/infertrade", "max_issues_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/StaticCombinationRegression.tex", "max_forks_repo_name": "pawkw/infertrade", "max_forks_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 39.1047619048, "max_line_length": 533, "alphanum_fraction": 0.7586458841, "num_tokens": 1098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4413355895838606}}
{"text": "\\chapter{{\\tt PatchAndGoInfo}: Pivot Modification Object}\n\\par\nOn occasion, an application will demand specific behavior \nduring a factorization.\nWe have written the {\\tt PatchAndGoInfo} object to communicate\ninformation to the {\\tt Chv} object during a factorization of a front.\nMost users can ignore this object.\nHowever, if a different type of behavior is required, one could\nextend this object by adding a new strategy to it and modifying the\n{\\tt Chv} methods that factor a front.\n\\par\nLet us describe two strategies that we presently support.\n\\begin{itemize}\n\\item\nPrimal-dual linear programming may require repeated factorizations\nof matrices of the form $AD^2A^T$, where $A$ comes from constraint\nequations and $D$ is a diagonal matrix.\nAs the optimization proceeds,\n$AD^2A^T$ becomes increasingly ill-conditioned because the\nentries in $D$ go to zero or infinity.\nNormally, when a small or zero pivot element is detected, we would\neither signal an error (if we expected the matrix to be positive\ndefinite) or pivot for stability.\nHowever, in the primal-dual pivot context, a small or zero element\non the diagonal is not a calamity.\nIt signals that the variable associated with the small entry can be\n``skipped'' in the solution process.\nThere are several ways to implement this behavior.\nWe have chosen a simple way: the diagonal entry is set to 1.0\nand all off-diagonal entries in the corresponding column of $L$\nare set to zero.\n\\item\nIn structural analysis, ``multi-point constraints'' are often\napplied to a linear system. At times, applying these constraints\ngenerates a matrix that is essentially singular. The singularity\nmay be benign, as in the following case.\n$$\n\\left \\lbrack \\begin{array}{cc}\nA_{1,1} & 0 \\\\\n0 & A_{2,2}\n\\end{array} \\right \\rbrack\n\\left \\lbrack \\begin{array}{c}\nX_1 \\\\\nX_2\n\\end{array} \\right \\rbrack\n=\n\\left \\lbrack \\begin{array}{c}\n0 \\\\\nB_2\n\\end{array} \\right \\rbrack\n$$\nIf $A_{1,1}$ is singular, the solution $X_1 = 0$ and\n$X_2 = A_{2,2}^{-1} B_2$ is perfectly acceptable.\nIn other cases, the location of the singularity can be\ncommunicated back to the user to supply useful information\nabout the finite element model.\nOne common practice is to not use pivoting, but to check the \nmagnitude of the diagonal entry as a row and column is to be eliminated.\nIf the magnitude is smaller than a user-supplied parameter,\nthe diagonal entry is set to some multiple of the largest\noffdiagonal entry in that row and column of the front,\nthe location and perturbation is noted, \nand the factorization proceeds.\n\\end{itemize}\n\\par\nOther strategies can be added to the {\\tt PatchAndGoInfo} object.\nFor example, if a matrix is being factored that is believed to be\npositive definite, and a negative value is found in a pivot\nelement, one could abort the factorization, or perturb the element\nso that it is positive.\n", "meta": {"hexsha": "aeba2227b050f285e3b64722110e94d2d779b664", "size": 2841, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/PatchAndGoInfo/doc/intro.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/PatchAndGoInfo/doc/intro.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/PatchAndGoInfo/doc/intro.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 40.014084507, "max_line_length": 72, "alphanum_fraction": 0.7750791975, "num_tokens": 734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.4413355834796281}}
{"text": "Implements the Gr\\\"obner bases based procedure as presented in~\\cite{JLCA_CAI13}. In general, this procedure can detect only the unsatisfiability of a conjunction of equations. This module also supports the usage of these equations to further simplify all constraints in the conjunction of constraints forming its input and passes these simplified constraints to its backends. However, it cannot be guaranteed that backends perform better on the simplified constraints than on the constraints before simplification.\n\n\\paragraph{Efficiency} The worst case complexity of the underlying procedure is exponential in the number of variables of the input constraints. In the case that the conjunction of constraints to check for satisfiability contains equations, this module can be more efficient than other modules for NRA on finding out inconsistency.", "meta": {"hexsha": "ff787665eb7c5f0a93cd6a5a3926e5b781eebc39", "size": 848, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/smtrat-modules/GBModule/GBModule.tex", "max_stars_repo_name": "minemebarsha/smtrat", "max_stars_repo_head_hexsha": "eaada50cdf9bbfe4dd4f6a54776387484c37b0f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/smtrat-modules/GBModule/GBModule.tex", "max_issues_repo_name": "minemebarsha/smtrat", "max_issues_repo_head_hexsha": "eaada50cdf9bbfe4dd4f6a54776387484c37b0f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/smtrat-modules/GBModule/GBModule.tex", "max_forks_repo_name": "minemebarsha/smtrat", "max_forks_repo_head_hexsha": "eaada50cdf9bbfe4dd4f6a54776387484c37b0f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 282.6666666667, "max_line_length": 515, "alphanum_fraction": 0.8360849057, "num_tokens": 155, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.44133558079091373}}
{"text": "% Generated by Sphinx.\n%\\usepackage[utf8]{inputenc}\n%\\usepackage[T1]{fontenc}\n%\\usepackage{babel}\n%\\usepackage{times}\n%\\usepackage[Bjarne]{fncychap}\n\n\nPyMC provides 35 built-in probability distributions. For each distribution, PyMC provides:\n\\begin{itemize}\n    \\item A function that evaluates its log-probability or log-density, for example \\code{normal_like()}.\n    \\item A function that draws random variables, for example \\code{rnormal()}.\n    \\item A function that computes the expectation associated with the distribution, for example \\code{normal_expval()}.\n    \\item A \\code{Stochastic} subclass generated from the distribution, for example \\code{Normal}.\n\\end{itemize}\n\nThis section describes the likelihood functions of these distributions.\n\\index{pymc.distributions (module)}\n\\hypertarget{module-pymc.distributions}{}\n%\\declaremodule[pymc.distributions]{}{pymc.distributions}\n\n\\small\n\n\\section{Discrete distributions}\n\\index{bernoulli\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.bernoulli_like}{}\\begin{funcdesc}{bernoulli\\_like}{x, p}\nThe Bernoulli distribution describes the probability of successes (x=1) and\nfailures (x=0).\n\\begin{gather}\n\\begin{split}f(x \\mid p) = p^{x} (1-p)^{1-x}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Series of successes (1) and failures (0). $x=0,1$\n\n\\item {} \n\\emph{p} : Probability of success. $0 < p < 1$.\n\n\\end{itemize}\n\n\\item[Example] \\leavevmode\n\\begin{Verbatim}[commandchars=@\\[\\]]\n@PYGaQ[@textgreater[]@textgreater[]@textgreater[] ]bernoulli@_like(@PYGZlb[]@PYGaw[0],@PYGaw[1],@PYGaw[0],@PYGaw[1]@PYGZrb[], @PYGbe[.]@PYGaw[4])\n@PYGaa[-2.8542325496673584]\n\\end{Verbatim}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(x)= p$\n\n\\item {} \n$Var(x)= p(1-p)$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{binomial\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.binomial_like}{}\\begin{funcdesc}{binomial\\_like}{x, n, p}\nBinomial log-likelihood.  The discrete probability distribution of the\nnumber of successes in a sequence of n independent yes/no experiments,\neach of which yields success with probability p.\n\\begin{gather}\n\\begin{split}f(x \\mid n, p) = \\frac{n!}{x!(n-x)!} p^x (1-p)^{n-x}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} Number of successes, \\textgreater{} 0.\n\n\\item {} \n\\emph{n} : {[}int{]} Number of Bernoulli trials, \\textgreater{} x.\n\n\\item {} \n\\emph{p} : Probability of success in each trial, $p \\in [0,1]$.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X)=np$\n\n\\item {} \n$Var(X)=np(1-p)$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{categorical\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.categorical_like}{}\\begin{funcdesc}{categorical\\_like}{x, p}\nCategorical log-likelihood. The most general discrete distribution.\n\\begin{gather}\n\\begin{split}f(x=i \\mid p) = p_i\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nfor $i \\in 0 \\ldots k-1$.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} $x \\in 0\\ldots k-1$\n\n\\item {} \n\\emph{p} : {[}float{]} $p > 0$, $\\sum p = 1$\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{discrete\\_uniform\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.discrete_uniform_like}{}\\begin{funcdesc}{discrete\\_uniform\\_like}{x, lower, upper}\nDiscrete uniform log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid lower, upper) = \\frac{1}{upper-lower}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} $lower \\leq x \\leq upper$\n\n\\item {} \n\\emph{lower} : Lower limit.\n\n\\item {} \n\\emph{upper} : Upper limit (upper \\textgreater{} lower).\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{geometric\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.geometric_like}{}\\begin{funcdesc}{geometric\\_like}{x, p}\nGeometric log-likelihood. The probability that the first success in a\nsequence of Bernoulli trials occurs on the x'th trial.\n\\begin{gather}\n\\begin{split}f(x \\mid p) = p(1-p)^{x-1}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} Number of trials before first success (x \\textgreater{} 0).\n\n\\item {} \n\\emph{p} : Probability of success on an individual trial, $p \\in [0,1]$\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X)=1/p$\n\n\\item {} \n$Var(X)=\\frac{1-p}{p^2}$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{hypergeometric\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.hypergeometric_like}{}\\begin{funcdesc}{hypergeometric\\_like}{x, n, m, N}\nHypergeometric log-likelihood. Discrete probability distribution that\ndescribes the number of successes in a sequence of draws from a finite\npopulation without replacement.\n\\begin{gather}\n\\begin{split}f(x \\mid n, m, N) = \\frac{\\binom{m}{x}\\binom{N-m}{n-x}}{\\binom{N}{n}}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} Number of successes in a sample drawn from a population.\n\n\\item {} \n\\emph{n} : {[}int{]} Size of sample drawn from the population.\n\n\\item {} \n\\emph{m} : {[}int{]} Number of successes in the population.\n\n\\item {} \n\\emph{N} : {[}int{]} Total number of units in the population.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\n$E(X) = \\frac{n n}{N}$\n\\end{notice}\n\\end{funcdesc}\n\\index{negative\\_binomial\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.negative_binomial_like}{}\\begin{funcdesc}{negative\\_binomial\\_like}{x, mu, alpha}\nNegative binomial log-likelihood. The negative binomial distribution describes a\nPoisson random variable whose rate parameter is gamma distributed. PyMC's chosen\nparameterization is based on this mixture interpretation.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\alpha) = \\frac{\\Gamma(x+\\alpha)}{x! \\Gamma(\\alpha)} (\\alpha/(\\mu+\\alpha))^\\alpha (\\mu/(\\mu+\\alpha))^x\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data (x \\textgreater{} 0).\n\n\\item {} \n\\emph{mu} : mu \\textgreater{} 0\n\n\\item {} \n\\emph{alpha} : alpha \\textgreater{} 0\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E[x]=\\mu$\n\n\\item {} \nIn Wikipedia's parameterization,\n$r=\\alpha$\n$p=\\alpha/(\\mu+\\alpha)$\n$\\mu=r(1-p)/p$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{poisson\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.poisson_like}{}\\begin{funcdesc}{poisson\\_like}{x, mu}\nPoisson log-likelihood. The Poisson is a discrete probability distribution.\nIt is often used to model the number of events occurring in a fixed period of\ntime when the times at which events occur are independent. The Poisson\ndistribution can be derived as a limiting case of the binomial distribution.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu) = \\frac{e^{-\\mu}\\mu^x}{x!}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} $x \\in {0,1,2,...}$\n\n\\item {} \n\\emph{mu} : Expected number of occurrences during the given interval, $\\mu \\geq 0$.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(x)=\\mu$\n\n\\item {} \n$Var(x)=\\mu$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\n\n\\section{Continuous distributions}\n\\index{beta\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.beta_like}{}\\begin{funcdesc}{beta\\_like}{x, alpha, beta}\nBeta log-likelihood. The conjugate prior for the parameter :math: \\emph{p} of the binomial distribution.\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha, \\beta) = \\frac{\\Gamma(\\alpha + \\beta)}{\\Gamma(\\alpha) \\Gamma(\\beta)} x^{\\alpha - 1} (1 - x)^{\\beta - 1}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : 0 \\textless{} x \\textless{} 1\n\n\\item {} \n\\emph{alpha} : alpha \\textgreater{} 0\n\n\\item {} \n\\emph{beta} : beta \\textgreater{} 0\n\n\\end{itemize}\n\n\\item[Example] \\leavevmode\n\\begin{Verbatim}[commandchars=@\\[\\]]\n@PYGaQ[@textgreater[]@textgreater[]@textgreater[] ]beta@_like(@PYGbe[.]@PYGaw[4],@PYGaw[1],@PYGaw[2])\n@PYGaa[0.18232160806655884]\n\\end{Verbatim}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X)=\\frac{\\alpha}{\\alpha+\\beta}$\n\n\\item {} \n$Var(X)=\\frac{\\alpha \\beta}{(\\alpha+\\beta)^2(\\alpha+\\beta+1)}$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{cauchy\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.cauchy_like}{}\\begin{funcdesc}{cauchy\\_like}{x, alpha, beta}\nCauchy log-likelihood. The Cauchy distribution is also known as the\nLorentz or the Breit-Wigner distribution.\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha, \\beta) = \\frac{1}{\\pi \\beta [1 + (\\frac{x-\\alpha}{\\beta})^2]}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{alpha} : Location parameter.\n\n\\item {} \n\\emph{beta} : Scale parameter \\textgreater{} 0.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \nMode and median are at alpha.\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{chi2\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.chi2_like}{}\\begin{funcdesc}{chi2\\_like}{x, nu}\nChi-squared $\\chi^2$ log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid \\nu) = \\frac{x^{(\\nu-2)/2}e^{-x/2}}{2^{\\nu/2}\\Gamma(\\nu/2)}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : \\textgreater{} 0\n\n\\item {} \n\\emph{nu} : {[}int{]} Degrees of freedom ( nu \\textgreater{} 0 )\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X)=\\nu$\n\n\\item {} \n$Var(X)=2\\nu$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{degenerate\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.degenerate_like}{}\\begin{funcdesc}{degenerate\\_like}{x, k}\nDegenerate log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid k) = \\left\\{ \\begin{matrix} 1 \\text{ if } x = k \\\\ 0 \\text{ if } x \\ne k\\end{matrix} \\right.\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input value.\n\n\\item {} \n\\emph{k} : Degenerate value.\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{exponential\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.exponential_like}{}\\begin{funcdesc}{exponential\\_like}{x, beta}\nExponential log-likelihood.\n\nThe exponential distribution is a special case of the gamma distribution\nwith alpha=1. It often describes the time until an event.\n\\begin{gather}\n\\begin{split}f(x \\mid \\beta) = \\frac{1}{\\beta}e^{-x/\\beta}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : x \\textgreater{} 0\n\n\\item {} \n\\emph{beta} : Survival parameter (beta \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\beta$\n\n\\item {} \n$Var(X) = \\beta^2$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{exponweib\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.exponweib_like}{}\\begin{funcdesc}{exponweib\\_like}{x, alpha, k, loc=0, scale=1}\nExponentiated Weibull log-likelihood.\n\nThe exponentiated Weibull distribution is a generalization of the Weibull\nfamily. Its value lies in being able to model monotone and non-monotone\nfailure rates.\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha,k,loc,scale)  & = \\frac{\\alpha k}{scale} (1-e^{-z^k})^{\\alpha-1} e^{-z^k} z^{k-1} \\\\\nz & = \\frac{x-loc}{scale}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : x \\textgreater{} 0\n\n\\item {} \n\\emph{alpha} : Shape parameter\n\n\\item {} \n\\emph{k} : k \\textgreater{} 0\n\n\\item {} \n\\emph{loc} : Location parameter\n\n\\item {} \n\\emph{scale} : Scale parameter (scale \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{gamma\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.gamma_like}{}\\begin{funcdesc}{gamma\\_like}{x, alpha, beta}\nGamma log-likelihood.\n\nRepresents the sum of alpha exponentially distributed random variables, each\nof which has mean beta.\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha, \\beta) = \\frac{\\beta^{\\alpha}x^{\\alpha-1}e^{-\\beta x}}{\\Gamma(\\alpha)}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : math:\\emph{x ge 0}\n\n\\item {} \n\\emph{alpha} : Shape parameter (alpha \\textgreater{} 0).\n\n\\item {} \n\\emph{beta} : Scale parameter (beta \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\frac{\\alpha}{\\beta}$\n\n\\item {} \n$Var(X) = \\frac{\\alpha}{\\beta^2}$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{half\\_normal\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.half_normal_like}{}\\begin{funcdesc}{half\\_normal\\_like}{x, tau}\nHalf-normal log-likelihood, a normal distribution with mean 0 limited\nto the domain $x \\in [0, \\infty)$.\n\\begin{gather}\n\\begin{split}f(x \\mid \\tau) = \\sqrt{\\frac{2\\tau}{\\pi}}\\exp\\left\\{ {\\frac{-x^2 \\tau}{2}}\\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : $x \\ge 0$\n\n\\item {} \n\\emph{tau} : tau \\textgreater{} 0\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{hypergeometric\\_like() (in module pymc.distributions)}\n\n\\begin{funcdesc}{hypergeometric\\_like}{x, n, m, N}\nHypergeometric log-likelihood. Discrete probability distribution that\ndescribes the number of successes in a sequence of draws from a finite\npopulation without replacement.\n\\begin{gather}\n\\begin{split}f(x \\mid n, m, N) = \\frac{\\binom{m}{x}\\binom{N-m}{n-x}}{\\binom{N}{n}}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int{]} Number of successes in a sample drawn from a population.\n\n\\item {} \n\\emph{n} : {[}int{]} Size of sample drawn from the population.\n\n\\item {} \n\\emph{m} : {[}int{]} Number of successes in the population.\n\n\\item {} \n\\emph{N} : {[}int{]} Total number of units in the population.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\n$E(X) = \\frac{n n}{N}$\n\\end{notice}\n\\end{funcdesc}\n\\index{inverse\\_gamma\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.inverse_gamma_like}{}\\begin{funcdesc}{inverse\\_gamma\\_like}{x, alpha, beta}\nInverse gamma log-likelihood, the reciprocal of the gamma distribution.\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha, \\beta) = \\frac{\\beta^{\\alpha}}{\\Gamma(\\alpha)} x^{-\\alpha - 1} \\exp\\left(\\frac{-\\beta}{x}\\right)\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : x \\textgreater{} 0\n\n\\item {} \n\\emph{alpha} : Shape parameter (alpha \\textgreater{} 0).\n\n\\item {} \n\\emph{beta} : Scale parameter (beta \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\n$E(X)=\\frac{\\beta}{\\alpha-1}$  for $\\alpha > 1$\n$Var(X)=\\frac{\\beta^2}{(\\alpha-1)^2(\\alpha)}$  for $\\alpha > 2$\n\\end{notice}\n\\end{funcdesc}\n\\index{laplace\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.laplace_like}{}\\begin{funcdesc}{laplace\\_like}{x, mu, tau}\nLaplace (double exponential) log-likelihood.\n\nThe Laplace (or double exponential) distribution describes the\ndifference between two independent, identically distributed exponential\nevents. It is often used as a heavier-tailed alternative to the normal.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\tau) = \\frac{\\tau}{2}e^{-\\tau |x-\\mu|}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : $-\\infty < x < \\infty$\n\n\\item {} \n\\emph{mu} : Location parameter :math: \\emph{-infty \\textless{} mu \\textless{} infty}\n\n\\item {} \n\\emph{tau} : Scale parameter $\\tau > 0$\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\mu$\n\n\\item {} \n$Var(X) = \\frac{2}{\\tau^2}$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{logistic\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.logistic_like}{}\\begin{funcdesc}{logistic\\_like}{x, mu, tau}\nLogistic log-likelihood.\n\nThe logistic distribution is often used as a growth model; for example,\npopulations, markets. Resembles a heavy-tailed normal distribution.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, tau) = \\frac{\\tau \\exp(-\\tau[x-\\mu])}{[1 + \\exp(-\\tau[x-\\mu])]^2}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : $-\\infty < x < \\infty$\n\n\\item {} \n\\emph{mu} : Location parameter $-\\infty < mu < \\infty$\n\n\\item {} \n\\emph{tau} : Scale parameter (tau \\textgreater{} 0)\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\mu$\n\n\\item {} \n$Var(X) = \\frac{\\pi^2}{3\\tau^2}$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{lognormal\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.lognormal_like}{}\\begin{funcdesc}{lognormal\\_like}{x, mu, tau}\nLog-normal log-likelihood. Distribution of any random variable whose\nlogarithm is normally distributed. A variable might be modeled as\nlog-normal if it can be thought of as the multiplicative product of many\nsmall independent factors.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\tau) = \\sqrt{\\frac{\\tau}{2\\pi}}\\frac{\n\\exp\\left\\{ -\\frac{\\tau}{2} (\\ln(x)-\\mu)^2 \\right\\}}{x}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : x \\textgreater{} 0\n\n\\item {} \n\\emph{mu} : Location parameter.\n\n\\item {} \n\\emph{tau} : Scale parameter (tau \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\n$E(X)=e^{\\mu+\\frac{1}{2\\tau}}$\n$Var(X)=(e^{1/\\tau}-1)e^{2\\mu+\\frac{1}{\\tau}}$\n\\end{notice}\n\\end{funcdesc}\n\\index{normal\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.normal_like}{}\\begin{funcdesc}{normal\\_like}{x, mu, tau}\nNormal log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\tau) = \\sqrt{\\frac{\\tau}{2\\pi}} \\exp\\left\\{ -\\frac{\\tau}{2} (x-\\mu)^2 \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data.\n\n\\item {} \n\\emph{mu} : Mean of the distribution.\n\n\\item {} \n\\emph{tau} : Precision of the distribution, which corresponds to $1/\\sigma^2$ (tau \\textgreater{} 0).\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\mu$\n\n\\item {} \n$Var(X) = 1/\\tau$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{skew\\_normal\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.skew_normal_like}{}\\begin{funcdesc}{skew\\_normal\\_like}{x, mu, tau, alpha}\nAzzalini's skew-normal log-likelihood\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\tau, \\alpha) = 2 \\Phi((x-\\mu)\\sqrt{\\tau}\\alpha) \\phi(x,\\mu,\\tau)\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere :math: Phi is the normal CDF and :math: phi is the normal PDF.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data.\n\n\\item {} \n\\emph{mu} : Mean of the distribution.\n\n\\item {} \n\\emph{tau} : Precision of the distribution (\\textgreater{} 0).\n\n\\item {} \n\\emph{alpha} : Shape parameter of the distribution.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\nSee \\href{http://azzalini.stat.unipd.it/SN/}{http://azzalini.stat.unipd.it/SN/}\n\\end{notice}\n\\end{funcdesc}\n\\index{t\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.t_like}{}\\begin{funcdesc}{t\\_like}{x, nu}\nStudent's T log-likelihood. Describes a zero-mean normal variable whose precision is\ngamma distributed. Alternatively, describes the mean of several zero-mean normal\nrandom variables divided by their sample standard deviation.\n\\begin{gather}\n\\begin{split}f(x \\mid \\nu) = \\frac{\\Gamma(\\frac{\\nu+1}{2})}{\\Gamma(\\frac{\\nu}{2}) \\sqrt{\\nu\\pi}} \\left( 1 + \\frac{x^2}{\\nu} \\right)^{-\\frac{\\nu+1}{2}}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data.\n\n\\item {} \n\\emph{nu} : Degrees of freedom.\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{truncnorm\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.truncnorm_like}{}\\begin{funcdesc}{truncnorm\\_like}{x, mu, tau, a, b}\nTruncated normal log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, \\tau, a, b) = \\frac{\\phi(\\frac{x-\\mu}{\\sigma})} {\\Phi(\\frac{b-\\mu}{\\sigma}) - \\Phi(\\frac{a-\\mu}{\\sigma})},\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere $\\sigma^2=1/\\tau$, \\emph{phi} is the standard normal PDF and \\emph{Phi} is the standard normal CDF.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data.\n\n\\item {} \n\\emph{mu} : Mean of the distribution.\n\n\\item {} \n\\emph{tau} : Precision of the distribution, which corresponds to 1/sigma**2 (tau \\textgreater{} 0).\n\n\\item {} \n\\emph{a} : Left bound of the distribution.\n\n\\item {} \n\\emph{b} : Right bound of the distribution.\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{uniform\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.uniform_like}{}\\begin{funcdesc}{uniform\\_like}{x, lower, upper}\nUniform log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid lower, upper) = \\frac{1}{upper-lower}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : $lower \\leq x \\leq upper$\n\n\\item {} \n\\emph{lower} : Lower limit.\n\n\\item {} \n\\emph{upper} : Upper limit (upper \\textgreater{} lower).\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{von\\_mises\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.von_mises_like}{}\\begin{funcdesc}{von\\_mises\\_like}{x, mu, kappa}\nvon Mises log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid \\mu, k) = \\frac{e^{k \\cos(x - \\mu)}}{2 \\pi I_0(k)}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere \\emph{I\\_0} is the modified Bessel function of order 0.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : Input data.\n\n\\item {} \n\\emph{mu} : Mean of the distribution.\n\n\\item {} \n\\emph{kappa} : Dispersion of the distribution\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X) = \\mu$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\\index{weibull\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.weibull_like}{}\\begin{funcdesc}{weibull\\_like}{x, alpha, beta}\nWeibull log-likelihood\n\\begin{gather}\n\\begin{split}f(x \\mid \\alpha, \\beta) = \\frac{\\alpha x^{\\alpha - 1}\n\\exp(-(\\frac{x}{\\beta})^{\\alpha})}{\\beta^\\alpha}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : $x \\ge 0$\n\n\\item {} \n\\emph{alpha} : alpha \\textgreater{} 0\n\n\\item {} \n\\emph{beta} : beta \\textgreater{} 0\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(x)=\\beta \\Gamma(1+\\frac{1}{\\alpha})$\n\n\\item {} \n$Var(x)=\\beta^2 \\Gamma(1+\\frac{2}{\\alpha} - \\mu^2)$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\n\n\\section{Multivariate discrete distributions}\n\\index{multivariate\\_hypergeometric\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.multivariate_hypergeometric_like}{}\\begin{funcdesc}{multivariate\\_hypergeometric\\_like}{x, m}\nThe multivariate hypergeometric describes the probability of drawing x{[}i{]}\nelements of the ith category, when the number of items in each category is\ngiven by m.\n\\begin{gather}\n\\begin{split}\\frac{\\prod_i \\binom{m_i}{x_i}}{\\binom{N}{n}}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere $N = \\sum_i m_i$ and $n = \\sum_i x_i$.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : {[}int sequence{]} Number of draws from each category, (x \\textless{} m).\n\n\\item {} \n\\emph{m} : {[}int sequence{]} Number of items in each categoy.\n\n\\end{itemize}\n\n\\end{description}\n\\end{funcdesc}\n\\index{multinomial\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.multinomial_like}{}\\begin{funcdesc}{multinomial\\_like}{x, n, p}\nMultinomial log-likelihood. Generalization of the binomial\ndistribution, but instead of each trial resulting in ``success'' or\n``failure'', each one results in exactly one of some fixed finite number k\nof possible outcomes over n independent trials. `x{[}i{]}' indicates the number\nof times outcome number i was observed over the n trials.\n\\begin{gather}\n\\begin{split}f(x \\mid n, p) = \\frac{n!}{\\prod_{i=1}^k x_i!} \\prod_{i=1}^k p_i^{x_i}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{description}\n\\item[x] \\leavevmode{[}(ns, k) int{]}\nRandom variable indicating the number of time outcome i is \nobserved. $\\sum_{i=1}^k x_i=n$, $x_i \\ge 0$.\n\n\\item[n] \\leavevmode{[}int{]}\nNumber of trials.\n\n\\item[p] \\leavevmode{[}(k,) {]}\nProbability of each one of the different outcomes.\n$\\sum_{i=1}^k p_i = 1)$, $p_i \\ge 0$.\n\n\\end{description}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\\begin{itemize}\n\\item {} \n$E(X_i)=n p_i$\n\n\\item {} \n$Var(X_i)=n p_i(1-p_i)$\n\n\\item {} \n$Cov(X_i,X_j) = -n p_i p_j$\n\n\\end{itemize}\n\\end{notice}\n\\end{funcdesc}\n\n\n\\section{Multivariate continuous distributions}\n\\index{dirichlet\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.dirichlet_like}{}\\begin{funcdesc}{dirichlet\\_like}{x, theta}\nDirichlet log-likelihood.\n\nThis is a multivariate continuous distribution.\n\\begin{gather}\n\\begin{split}f(\\mathbf{x}) = \\frac{\\Gamma(\\sum_{i=1}^k \\theta_i)}{\\prod \\Gamma(\\theta_i)}\\prod_{i=1}^{k-1} x_i^{\\theta_i - 1}\\cdot\\left(1-\\sum_{i=1}^{k-1}x_i\\right)^\\theta_k\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{description}\n\\item[x] \\leavevmode{[}(n, k-1) array {]}\nArray of shape (n, k-1) where \\emph{n} is the number of samples \nand \\emph{k} the dimension. \n$0 < x_i < 1$,  $\\sum_{i=1}^{k-1} x_i < 1$\n\\item[theta] \\leavevmode{[}array{]}\nAn (n,k) or (1,k) array \\textgreater{} 0.\n\n\\end{description}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\nOnly the first \\emph{k-1} elements of \\emph{x} are expected. Can be used as a parent of Multinomial and Categorical\nnevertheless.\n\\end{notice}\n\\end{funcdesc}\n\\index{inverse\\_wishart\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.inverse_wishart_like}{}\\begin{funcdesc}{inverse\\_wishart\\_like}{X, n, Tau}\nInverse Wishart log-likelihood. The inverse Wishart distribution is the conjugate\nprior for the covariance matrix of a multivariate normal distribution.\n\\begin{gather}\n\\begin{split}f(X \\mid n, T) = \\frac{{\\mid T \\mid}^{n/2}{\\mid X \\mid}^{(n-k-1)/2} \\exp\\left\\{ -\\frac{1}{2} Tr(TX^{-1}) \\right\\}}{2^{nk/2} \\Gamma_p(n/2)}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere $k$ is the rank of X.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{X} : Symmetric, positive definite matrix.\n\n\\item {} \n\\emph{n} : {[}int{]} Degrees of freedom (n \\textgreater{} 0).\n\n\\item {} \n\\emph{Tau} : Symmetric and positive definite matrix.\n\n\\end{itemize}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\nStep method MatrixMetropolis will preserve the symmetry of Wishart variables.\n\\end{notice}\n\\end{funcdesc}\n\\index{mv\\_normal\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.mv_normal_like}{}\\begin{funcdesc}{mv\\_normal\\_like}{x, mu, tau}\nMultivariate normal log-likelihood\n\\begin{gather}\n\\begin{split}f(x \\mid \\pi, T) = \\frac{|T|^{1/2}}{(2\\pi)^{1/2}} \\exp\\left\\{ -\\frac{1}{2} (x-\\mu)^{\\prime}T(x-\\mu) \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : (n,k)\n\n\\item {} \n\\emph{mu} : (k) Location parameter sequence.\n\n\\item {} \n\\emph{Tau} : (k,k) Positive definite precision matrix.\n\n\\end{itemize}\n\n\\end{description}\n\n\n\\strong{See Also:}\n\n\n\\hyperlink{pymc.distributions.mv_normal_chol_like}{\\code{mv\\_normal\\_chol\\_like()}}, \\hyperlink{pymc.distributions.mv_normal_cov_like}{\\code{mv\\_normal\\_cov\\_like()}}\n\n\n\\end{funcdesc}\n\\index{mv\\_normal\\_chol\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.mv_normal_chol_like}{}\\begin{funcdesc}{mv\\_normal\\_chol\\_like}{x, mu, sig}\nMultivariate normal log-likelihood.\n\\begin{gather}\n\\begin{split}f(x \\mid \\pi, \\sigma) = \\frac{1}{(2\\pi)^{1/2}|\\sigma|)} \\exp\\left\\{ -\\frac{1}{2} (x-\\mu)^{\\prime}(\\sigma \\sigma^{\\prime})^{-1}(x-\\mu) \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : (n,k)\n\n\\item {} \n\\emph{mu} : (k) Location parameter.\n\n\\item {} \n\\emph{sigma} : (k,k) Lower triangular matrix.\n\n\\end{itemize}\n\n\\end{description}\n\n\n\\strong{See Also:}\n\n\n\\hyperlink{pymc.distributions.mv_normal_like}{\\code{mv\\_normal\\_like()}}, \\hyperlink{pymc.distributions.mv_normal_cov_like}{\\code{mv\\_normal\\_cov\\_like()}}\n\n\n\\end{funcdesc}\n\\index{mv\\_normal\\_cov\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.mv_normal_cov_like}{}\\begin{funcdesc}{mv\\_normal\\_cov\\_like}{x, mu, C}\nMultivariate normal log-likelihood parameterized by a covariance \nmatrix.\n\\begin{gather}\n\\begin{split}f(x \\mid \\pi, C) = \\frac{1}{(2\\pi|C|)^{1/2}} \\exp\\left\\{ -\\frac{1}{2} (x-\\mu)^{\\prime}C^{-1}(x-\\mu) \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{itemize}\n\\item {} \n\\emph{x} : (n,k)\n\n\\item {} \n\\emph{mu} : (k) Location parameter.\n\n\\item {} \n\\emph{C} : (k,k) Positive definite covariance matrix.\n\n\\end{itemize}\n\n\\end{description}\n\n\n\\strong{See Also:}\n\n\n\\hyperlink{pymc.distributions.mv_normal_like}{\\code{mv\\_normal\\_like()}}, \\hyperlink{pymc.distributions.mv_normal_chol_like}{\\code{mv\\_normal\\_chol\\_like()}}\n\n\n\\end{funcdesc}\n\\index{wishart\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.wishart_like}{}\\begin{funcdesc}{wishart\\_like}{X, n, Tau}\nWishart log-likelihood. The Wishart distribution is the probability\ndistribution of the maximum-likelihood estimator (MLE) of the precision\nmatrix of a multivariate normal distribution. If Tau=1, the distribution\nis identical to the chi-square distribution with n degrees of freedom.\n\nFor an alternative parameterization based on $C=T{-1}$, see\n\\emph{wishart\\_cov\\_like}.\n\\begin{gather}\n\\begin{split}f(X \\mid n, T) = {\\mid T \\mid}^{n/2}{\\mid X \\mid}^{(n-k-1)/2} \\exp\\left\\{ -\\frac{1}{2} Tr(TX) \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere $k$ is the rank of X.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{description}\n\\item[X] \\leavevmode{[}matrix{]}\nSymmetric, positive definite.\n\n\\item[n] \\leavevmode{[}int{]}\nDegrees of freedom, \\textgreater{} 0.\n\n\\item[Tau] \\leavevmode{[}matrix{]}\nSymmetric and positive definite\n\n\\end{description}\n\n\\end{description}\n\n\\begin{notice}{note}{Note:}\nStep method MatrixMetropolis will preserve the symmetry of Wishart variables.\n\\end{notice}\n\\end{funcdesc}\n\\index{wishart\\_cov\\_like() (in module pymc.distributions)}\n\n\\hypertarget{pymc.distributions.wishart_cov_like}{}\\begin{funcdesc}{wishart\\_cov\\_like}{X, n, C}\nWishart log-likelihood. The Wishart distribution is the probability\ndistribution of the maximum-likelihood estimator (MLE) of the covariance\nmatrix of a multivariate normal distribution. If C=1, the distribution\nis identical to the chi-square distribution with n degrees of freedom.\n\nFor an alternative parameterization based on $T=C{-1}$, see\n\\emph{wishart\\_like}.\n\\begin{gather}\n\\begin{split}f(X \\mid n, C) = {\\mid C^{-1} \\mid}^{n/2}{\\mid X \\mid}^{(n-k-1)/2} \\exp\\left\\{ -\\frac{1}{2} Tr(C^{-1}X) \\right\\}\\end{split}\\notag\\\\\\begin{split}\\end{split}\\notag\n\\end{gather}\nwhere $k$ is the rank of X.\n\\begin{description}\n\\item[Parameters] \\leavevmode\\begin{description}\n\\item[X] \\leavevmode{[}matrix{]}\nSymmetric, positive definite.\n\n\\item[n] \\leavevmode{[}int{]}\nDegrees of freedom, \\textgreater{} 0.\n\n\\item[C] \\leavevmode{[}matrix{]}\nSymmetric and positive definite\n\n\\end{description}\n\n\\end{description}\n\\end{funcdesc}\n\\normalsize\n", "meta": {"hexsha": "67c8585dd2bb36712f0c167c5bcff5cd64e30491", "size": 33426, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/distributions-module.tex", "max_stars_repo_name": "matthew-brett/pymc", "max_stars_repo_head_hexsha": "3a31613f056e7993a449d89bafef5fdaa40d47e9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-12-03T09:42:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-06T19:23:29.000Z", "max_issues_repo_path": "docs/distributions-module.tex", "max_issues_repo_name": "matthew-brett/pymc", "max_issues_repo_head_hexsha": "3a31613f056e7993a449d89bafef5fdaa40d47e9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-09-27T02:00:41.000Z", "max_issues_repo_issues_event_max_datetime": "2016-09-27T02:15:32.000Z", "max_forks_repo_path": "docs/distributions-module.tex", "max_forks_repo_name": "matthew-brett/pymc", "max_forks_repo_head_hexsha": "3a31613f056e7993a449d89bafef5fdaa40d47e9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-10-27T13:27:32.000Z", "max_forks_repo_forks_event_max_datetime": "2017-10-27T13:27:32.000Z", "avg_line_length": 30.1406672678, "max_line_length": 222, "alphanum_fraction": 0.7047507928, "num_tokens": 11351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018545, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.44133557199796686}}
{"text": "\\section{Adversarial Training}\n\n\\transitionFrame{Adversarially Robust Training}\n\n\\begin{frame}{Solving the Outer Minimization}\n  \\onslide<+->{%\n    \\begin{equation}\\label{eq:MinimaxTrainRepeat}\n      \\green{\\min_{\\params} \\rho(\\params)} \\text{, where } \\rho(\\params) = \\mathbb{E}_{(\\X,\\y) \\sim \\distr} \\sbrack{\\red{\\max_{\\delta \\in \\sPerturb} \\loss (\\X + \\perturb, \\y ; \\params)}}\n    \\end{equation}\n  }\n\n  \\begin{itemize}[<+->]\n    \\item So far, we have only talked about solving the \\red{inner maximization} to create adversarial examples\n\n    \\vspace{10pt}\n    \\item \\textbf{Question}: What do we need to solve to train adversarially robust networks?\n    \\vspace{3pt}\n    \\item \\textbf{Answer}: Solve the \\green{outer minimization}\n\n    \\vspace{10pt}\n    \\item \\textbf{Question}: What algorithm can be used to solve the outer minimization?\n    \\vspace{3pt}\n    \\item \\textbf{Answer}: Stochastic gradient descent (SGD) on the adversarial examples\n      \\begin{itemize}[<+->]\n        \\setlength{\\itemsep}{4pt}\n        \\item \\textit{Intuition}: SGD on adv.\\ examples' loss reduces the \\red{inner maximization}\n        \\item \\textit{Takeaway}: Given an algorithm that transforms training examples into adv.\\ examples (e.g.,~PGD), the rest of the \\textbf{\\blue{training process proceeds normally}}\n      \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Why Should You Believe the Preceding Claims are True?}\n  \\onslide<+->{}\n  \\onslide<+->{\\textbf{Answer}: You shouldn't.  The preceding explanation is definitely \\red{not a proof}.}\n\n  \\vspace{20pt}\n  \\onslide<+->{\\madry\\ rely on \\textbf{\\blue{Danskin's Theorem}} that states gradients at inner maximizers (think adversarial examples) correspond to descent directions for the complete problem}\n\n  \\vspace{20pt}\n  \\onslide<+->{\\textbf{Problem}: Multiple assumptions made by Danskin's Theorem's \\red{do not apply} here, e.g.,~continuously differentiable function, only \\red{\\textit{approximate}} inner maximizers etc.}\n  \\begin{itemize}[<+->]\n    \\setlength{\\itemsep}{6pt}\n    \\item Empirical results show that despite Danskin's not holding, \\madry's approach is robust\n    \\item A more complete discussion of how Danksin's applies to this problem is in Appendix~A (see Arxiv version) and is beyond the scope of this talk\n  \\end{itemize}\n\\end{frame}\n", "meta": {"hexsha": "7b34d1d47d71423836a5d022eefee6c71913aef5", "size": 2306, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/train_to_eliminate_adv_examples.tex", "max_stars_repo_name": "ZaydH/towards_adversarial_robustness", "max_stars_repo_head_hexsha": "c03c7948a7b8a8efefb7f7aa1d420b05c1eaee2f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/train_to_eliminate_adv_examples.tex", "max_issues_repo_name": "ZaydH/towards_adversarial_robustness", "max_issues_repo_head_hexsha": "c03c7948a7b8a8efefb7f7aa1d420b05c1eaee2f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/train_to_eliminate_adv_examples.tex", "max_forks_repo_name": "ZaydH/towards_adversarial_robustness", "max_forks_repo_head_hexsha": "c03c7948a7b8a8efefb7f7aa1d420b05c1eaee2f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.0416666667, "max_line_length": 205, "alphanum_fraction": 0.7068516912, "num_tokens": 680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.441335570859461}}
{"text": "\\chapter{Classification Trees}\n\\label{ch:classification-trees}\n\nIn the previous lesson, we used a classification tree,\n\\marginnote{Classification trees were hugely popular in the early years of machine learning, when they were first independently proposed by the engineer Ross Quinlan (C4.5) and a group of statisticians (CART), including the father of random forests Leo Brieman.}\none of the oldest, but still popular, machine learning methods. We like it since the method is easy to explain and gives rise to random forests, one of the most accurate machine learning techniques (more on this later). So, what kind of model is a classification tree?\n\nLet us load \\textit{iris} data set, build a tree (widget \\widget{Tree}) and visualize it in a \\widget{Tree Viewer}.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.4]{workflow-tree-viewer.png}\n\\end{figure}\n\n\\begin{figure*}[h]\n    \\vspace{-0.4cm}\n    \\includegraphics[scale=0.35]{iris-data.png}\n    \\label{fig:classification-predictions}\n\\end{figure*}\n\n\\begin{wrapfigure}{o}{1.0\\textwidth}\n    \\includegraphics[scale=0.35]{tree-viewer.png}\n    \\label{fig:classification-predictions}\n\\end{wrapfigure}\n\nWe read the tree from top to bottom. Looks like the column \\textit{petal length} best separates the iris variety \\textit{setosa} from the others, and in the next step, \\textit{petal width} then almost perfectly separates the remaining two varieties.\n\nTrees place the most useful feature at the root. What would be the most useful feature? The feature that splits the data into two purest possible subsets. It then splits both subsets further, again by their most useful features, and keeps doing so until it reaches subsets in which all data belongs to the same class (leaf nodes in strong blue or red) or until it runs out of data instances to split or out of useful features (the two leaf nodes in white).\n\nWe still have not been very explicit about what we mean by \"the most useful\" feature. There are many ways to measure the quality of features, based on how well they distinguish between classes. We will illustrate the general idea with information gain. We can compute this measure in Orange using the \\widget{Rank} widget\\marginnote{The \\widget{Rank} widget can be used on its own to show the best predicting features. Say, to figure out which genes are best predictors of the phenotype in some gene expression data set.}, which estimates the quality of data features and ranks them according to how informative they are about the class. We can either estimate the information gain from the whole data set, or compute it on data corresponding to an internal node of the classification tree in the \\widget{Tree Viewer}. In the following example we use the \\textit{Sailing} data set.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.4]{workflow-rank.png}\n    \\caption{The \\widget{Datasets} widget is set to load the \\textit{Sailing} data set. To use the second \\widget{Rank}, select a node in the \\widget{Tree Viewer}.}\n\\end{figure}\n\nBesides the information gain, \\widget{Rank} displays several other measures (including Gain Ratio and Gini), which are often quite in agreement and were invented to better handle discrete features with many different values.\n\n\\begin{figure}[h]\n    \\centering\n    \\vspace{-0.2cm}\n    \\includegraphics[scale=0.4]{rank.png}\n    \\caption{For the whole \\textit{Sailing} data set, \\textit{Company} is the most class-informative feature according to all measures shown.}\n\\end{figure}\n\n\\newpage\n\nHere is an interesting combination of a \\widget{Tree Viewer} and a \\widget{Scatter Plot}. This time, use the \\textit{Iris} data set. In the \\widget{Scatter Plot}, we first find the best visualization of this data set, that is, the one that best separates the instances from different classes. Then we connect the \\widget{Tree Viewer} to the \\widget{Scatter Plot}. Data instances (particular irises) from the selected node in the \\widget{Tree Viewer} are shown in the \\widget{Scatter Plot}.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.4]{workflow-inspection.png}\n    \\caption{Careful, the \\widget{Data} widget needs to be connected to the \\widget{Scatter Plot}'s \\textit{Data} input, and \\widget{Tree Viewer} to the \\widget{Scatter Plot}'s \\textit{Data Subset} input.}\n\\end{figure}\n\nJust for fun, we have included a few other widgets in this workflow. In a way, a \\widget{Tree Viewer} behaves like \\widget{Select Rows}, except that the rules used to filter the data are inferred from the data itself and optimized to obtain purer data subsets.\n\n\\begin{figure*}[h]\n  \\infinitewidthbox{\\includegraphics[scale=0.35]{tree-viewer-selection.png} \\includegraphics[scale=0.35]{scatter-plot-subset.png}}\n  \\caption{In the \\widget{Tree Viewer} we selected the rightmost node. All data instances coming to the selected node are highlighted in \\widget{Scatter Plot}.}\n\\end{figure*}\n\nWherever possible, visualizations in Orange are designed to support selection and passing of the data that applies to it. Finding interesting data subsets and analyzing their commonalities is a central part of explorative data analysis, a data analysis approach favored by the data visualization guru Edward Tufte.", "meta": {"hexsha": "1b02de7a651d4f3dbb459d4ee58e4462b3de38d6", "size": 5213, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/021-classification-trees/classification-trees.tex", "max_stars_repo_name": "PrimozGodec/orange-lecture-notes", "max_stars_repo_head_hexsha": "5072afa3e29cec77e1a7f6c0d1fd044e737fe378", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-10-13T14:31:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T03:47:06.000Z", "max_issues_repo_path": "chapters/021-classification-trees/classification-trees.tex", "max_issues_repo_name": "PrimozGodec/orange-lecture-notes", "max_issues_repo_head_hexsha": "5072afa3e29cec77e1a7f6c0d1fd044e737fe378", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2021-02-26T13:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-25T19:15:34.000Z", "max_forks_repo_path": "chapters/021-classification-trees/classification-trees.tex", "max_forks_repo_name": "PrimozGodec/orange-lecture-notes", "max_forks_repo_head_hexsha": "5072afa3e29cec77e1a7f6c0d1fd044e737fe378", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-01-19T16:55:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-21T20:35:41.000Z", "avg_line_length": 81.453125, "max_line_length": 881, "alphanum_fraction": 0.7753692691, "num_tokens": 1269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.441260785677873}}
{"text": "\n\\section{The \\copyi algorithm}\n\\Label{sec:copyi}\n\nThe \\copyi  algorithm in the \\cxx Standard Library \\cite[\\S 28.6.1]{cxx-17-draft} implements\na duplication algorithm for general sequences.\nFor our purposes we have modified\nthe generic implementation\nto that of a range of type \\valuetype.\nThe signature now reads:\n\n\\begin{lstlisting}[style=acsl-block]\n\n  void copy(const value_type* a, size_type n, value_type* b);\n\\end{lstlisting}\n\nInformally, the function copies every element from the source range \\inl{a[0..n-1]} to the\ndestination range~\\inl{b[0..n-1]}, as shown in Figure~\\ref{fig:copy}.\n\n\\begin{figure}[hbt]\n\\centering\n\\includegraphics[width=0.50\\textwidth]{Figures/copy.pdf}\n\\caption{\\Label{fig:copy} Effects of \\copyi}\n\\end{figure}\n\n\\subsection{Formal specification of \\copyi}\n\nFigure~\\ref{fig:copy} might suggest that the ranges \\inl{a[0..n-1]} and \\inl{b[0..n-1]}\nmust not overlap.\nHowever, since the informal specification requires that elements are copied in the\norder of increasing indices only a weaker condition is necessary.\nTo be more specific, it is required that the pointer~\\inl{b} does not refer\nto elements of \\inl{a[0..n-1]} as shown in the example in Figure~\\ref{fig:copy-overlap}.\n\n\\begin{figure}[hbt]\n\\centering\n\\includegraphics[width=0.60\\textwidth]{Figures/copy-overlap.pdf}\n\\caption{\\Label{fig:copy-overlap} Possible overlap of \\copyi ranges}\n\\end{figure}\n\n\\FloatBarrier\n\nThe specification of \\copyi is shown in the following listing.\nThe \\copyi algorithm expects that the ranges \\inl{a} and \\inl{b} are valid for reading\nand writing, respectively.\nNote the precondition~\\inl{sep} that expresses the previously discussed non-overlapping property.\n\n\\input{Listings/copy.h.tex}\n\nAgain, we can use the \\logicref{Equal} predicate to express that the\narray~\\inl{a} equals~\\inl{b} after \\copyi has been called.\nNothing else must be altered.\nTo state this we use the \\inl{assigns}-clause.\n\n%\\clearpage\n\n\\subsection{Implementation of \\copyi}\n\nThe following listing shows an implementation of the \\copyi function.\n\n\\input{Listings/copy.c.tex}\n\nFor the postcondition \\equal to be true, we must ensure that for every index\n\\inl{i}, the value \\inl{a[i]} must not yet have been changed before it is \ncopied to \\inl{b[i]}.\nWe express this by using the  \\Unchanged predicate.\\footnote{\nAlternatively, this could also be expressed by changing the\n\\inl{loop assigns} clause to \\inl{i, b[0..i-1]}; however,\n\\framac doesn't yet support \\inl{loop assigns} clauses\ncontaining the loop variable.\n}\n\nThe \\inl{assigns} clause ensures that nothing but the range \\inl{b[0..n-1]}\nand the loop variable \\inl{i} is modified.\nKeep in mind, however, that parts of the source range \\inl{a[0..n-1]} might change\ndue to its potential overlap with the destination range.\n\n\\clearpage\n\n", "meta": {"hexsha": "2b6edc5858ec209e20460621ac72041b6854b17d", "size": 2781, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/mutating/copy.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/mutating/copy.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/mutating/copy.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 34.7625, "max_line_length": 97, "alphanum_fraction": 0.7608773822, "num_tokens": 801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4412342863944368}}
{"text": "\\documentclass[10.5pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{setspace}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{listings}\n\\usepackage{wrapfig}\n\\usepackage{hyperref}\n\\usepackage[left=1cm, right=1cm, top=1.5cm, bottom=1.5cm]{geometry}\n\\usepackage[font=small]{caption, subcaption}\n\n%\\setlength{\\parskip}{0em}\n\\setstretch{0.3}\n\n\\algdef{SE}[SUBALG]{Indent}{EndIndent}{}{\\algorithmicend\\ }%\n\\algtext*{Indent}\n\\algtext*{EndIndent}\n\n\\newcommand{\\algorithmautorefname}{Algorithm}\n\n\\begin{document}\n    \\begin{center}\n        \\large \\textbf{Problem, Search and beyond}\n        \n        \\normalsize Chuanyuna Liu 884140, Zhuoqun Huang 908525\n    \\end{center}\n    \\section{Problem}\n    \\subsection{General Problem}\n    We formulate our problem with the following five concepts:\n    \\begin{itemize}\n        \\itemsep0em\n        \\item \\textbf{State($\\mathbb{S}$)} including a \\textbf{initial state ($s_0$)} the agent begins with\n        \\item \\textbf{Actions($\\mathbb{A}$)} available to agent at each State\n        \\item \\textbf{Transition function ($F:\\mathbb{S}\\times \\mathbb{A}\\rightarrow \\mathbb{S}$)} that takes a (state, action) pair and return a new state\n        \\item \\textbf{Goal Test($GT:S\\rightarrow \\{True, False\\}$)} that takes a state $s$ and return true if $s\\in S_{goal}$, the \\textbf{Goal State} of the problem.\n        \\item \\textbf{Path Cost ($C:\\mathbb{S}\\times \\mathbb{S}\\rightarrow \\mathbb{R}$)} That takes two states and return cost moving from one to another\n    \\end{itemize}\n    \\vspace{-15pt}\n    \\subsection{Single-player Chexers}\n    In this section, we formally describe how the above framework fits the Chexers game.\n    \\begin{itemize}\n        \\itemsep0em\n        \\item Denote set of pieces with $\\mathbb{P}=\\{(r, q, t)\\}$. \\\\\n        where\n        \\begin{align*}\n            \\text{$r, q, -(r+q)\\in [-3, 3]$ denotes the location on board.}\\\\\n            \\text{$t\\in \\{red, blue, green, block\\}$ stands for type of piece.}    \n        \\end{align*}\n        \n        \\item $\\mathbb{S} := \\{p_i\\in \\mathbb{P}, t_b|i\\le n\\}$ where $n$ is number of pieces on board, where $t_b$ is the searched type.*\n        \\item $\\mathbb{A} := (Move,p_i), (Jump, p_i), (Exit, p_i), \\forall\\ p_i $ where$\\ t(p_i)=t_b.\\ | \\mathbb{A}_s| \\le 6n_p\\ \\forall s$.\n        \\item $f(s, a) := s'$. where $s'$ differs exactly by one piece $r(p_{i,s}), q(p_{i,s}) \\ne r(p_{i,s'}), q(p_{i,s'})$ or $p_i\\notin s'$\n        \\item $c(s, s') := 1, \\forall s, s'\\ \\text{if}\\ \\exists a\\ \\text{such that} f(s, a) = s'$\n        \\item $gt(s) = True$ if $\\nexists p_i$ such that $t(p_i) = t_b$\n    \\end{itemize}\n    \\vspace{-5pt}\n    *Initial State $s_0$ given by problem specification.\n    \\vspace{-5pt}\n    \\section{Search}\n        \\subsection{preliminary}\n        We use the following \\autoref{a_star}, to search for our goal. Based on our problem specification, we have all required components except for \\textbf{H($node$)}, so we will propose one type of \\textbf{H} we found to be most effective after comparing it against \\textbf{Null $H=0$} and \\textbf{depth first search}\\footnote{In the following analysis, $b$ for \\textbf{branching factor}, $d$ for \\textbf{depth to optimal solution}}.\n        \\begin{algorithm}[ht]\n            \\footnotesize\n            \\caption{General A* algorithm}\\label{a_star}\n            \\begin{algorithmic}[1]\n                \\Statex PRIORITY-QUEUE \\Comment{\\textbf{Min} Priority Queue (min key)}\n                \\Statex  \\hskip2.0em ADD($q$, $key$, $value$), \\Comment{Add (key, value) to q. If value exists, update the key}\n                \\Statex  \\hskip2.0em POP($q$) \\Comment{Pop the value with \\textbf{least} key}\n                \\Statex  \\hskip2.0em GET($q$, $value$) \\Comment{Get the key associated with a value}\n                \\Statex \\Comment{All above Queue operations can operate in $\\Theta(1)$}\n                \\Statex\n                \\Statex NODE \\Comment{stores associated \\textbf{state} and its \\textbf{parent}}\n                \\Require EXPAND($node$)\\Comment{expand a \\textbf{node} to get it's \\textbf{children}}\n                \\Require G($node$)\\Comment{get \\textbf{total cost} arriving this node}\n                \\Require H($node$) \\Comment{Computes an \\textbf{admissible estimation} of cost to goal state}\n                \\Require C($node1$, $node2$) \\Comment{Give Path cost arriving node 2 from node 1}\n                \\Procedure{A*}{$problem$, $initial$}\n                \\State $openSet \\gets$ PRIORITY-QUEUE(H($initial$),  $initial$)\n                \\State $closedSet \\gets$ \\{\\}\n                \\While{$openSet$ \\textbf{is not} empty} \\Comment{$O(b^d)$ repetitions}\n                    \\State $node \\gets POP(openSet)$\n                    \\State $ADD(closedSet, node)$\n                    \\If {GOAL-TEST($node$) \\textbf{is} True}\n                        \\State \\textbf{return} $node$\n                    \\EndIf\n                    \\For {$child$ \\textbf{in} EXPAND($node$)} \\Comment{$O(b)$ repetitions*}\n                        \\State $cost$ = G($node$) + C($node$, $child$) + H($child$)\n                        \\If {$child$ \\textbf{in} $closedSet$}\n                            continue\n                        \\ElsIf {$child$ not in $openSet$ \\textbf{or} cost $<$ GET($openSet$, $child$)}\n                            \\State ADD(openSet, cost, child)\n                        \\EndIf\n                    \\EndFor\n                \\EndWhile\n                \\State \\textbf{return} no solution\n                \\EndProcedure\\\\\n                All operations $O(1)$ unless explicitly stated, we denote the complexity of search for problem also here.\\\\\n                *\\textbf{Note} at $d$ level, we don't run this loop, making overall factor only $O(b^d)$.\n            \\end{algorithmic}\n        \\end{algorithm}\n    \\vspace{-10pt}\n    \\subsection{Heuristic}\n        \\paragraph{As a Problem} We propose the following problem definition for mapping a good heuristic value for each pieces and we define $H(s) = \\sum_{p_i}h(p_i), \\forall p_i$ that $t(p_i) = t_b$ after relaxing the problem to be: a piece can choose freely between \\textbf{move}, \\textbf{jump} disregarding normal constrains and \\textbf{cannot} move on to blocks.\n        \\begin{itemize}\n            \\itemsep0em   \n            \\item $\\mathbb{S} := \\{(cost_i, position_i)|position_i\\in board\\}$*,\n            \\item $\\mathbb{A} :$ for $pos_i$ with $cost_i=min({cost_n})$, $\\forall$ $pos_{j\\ne i} $ reachable from $pos_i$ and $cost_j > cost_i+1$. Update $(pos_j, cost_i + 1)$. If $\\nexists pos_j$, remove $(pos_i, cost_i)$ from $s$ and put $h(pos_i) = cost_i$\n            \\item $c(s, s')=0$ and $f(s,a)$ follows definition in $\\mathbb{A}$\n            \\item $gt(s')=True$ if $s' = \\emptyset$\n        \\end{itemize}\n        \\vspace{-5pt}\n        *$s_0 = \\{(1, pos_i)|can\\_exit(pos_i) = True\\} | \\{(\\infty, pos_i)|can\\_exit(pos_i) = False\\}$\n        \\vspace{-10pt}\n        \\paragraph{Heuristic problem solution} Finding heuristic is straight forward with the given above problem definition. Supporting all the given operations to \\ref{a_star}, and you should end up with a complete heuristic map in constant time (due to small and constant search space $O(\\mathbb{V}\\times \\mathbb{E}) = O(37\\times 12)=O(1)$).\n        \\vspace{-10pt}\n        \\paragraph{Admissible?} The algorithm is guaranteed to provide us with a admissible cost estimation for each game state:\\\\\n    - The relaxed rule let pieces always able to jump.\\\\\n    - This will in all cases reduce the number of action taken, by always increasing the distance a piece can move.\n    \\vspace{-10pt}\n    \\subsection{Property of search}\n        \\paragraph{Efficiency} The efficiency of A* algorithm heavily depends on how accurate the heuristic is. As we can see from the example below. Our heuristic (shown in \\hyperref[fig:heurstics]{this figure}) is very close to the real cost.\n        \\begin{wrapfigure}{r}{0.3\\textwidth}\n            \\vspace{-32pt}\n                \\begin{center}\n                    \\includegraphics[width=0.3\\textwidth]{heuristic.png}\n                    \\label{fig:heurstics}\n                \\end{center}\n            \\vspace{-10pt}\n            \\caption{Map formed by heuristic}\n            \\vspace{-100pt}\n        \\end{wrapfigure}\n        \\vspace{-40pt}\n        \\paragraph{Optimality} A* algorithm can only find the optimal solution if the heuristic is admissible. We relaxed the rule to allow pieces jumping freely without the need to leapfrog another piece. Because jump move allows pieces to move twice the normal move, our heuristic at most underestimates the real cost by a factor of $2$, and cannot be faster the real cost. This satisfied admissibility. Monotonicity is also met because each move adds $1$ unit of cost. Hence our program is optimal.\n        \\vspace{-10pt}\n        \\paragraph{Completeness} A* algorithm is complete if the graph contains finite nodes. For our problem, both the board and number of pieces are finite leading to a bounded size for state space, concludes the completeness of our algorithm.\n    \\section{Beyond}\n    \n        The complexity of problem is \\textbf{exponentially} related to \\textbf{number} of \\textbf{moving pieces}. This is due to the effect of more moving options leading to a higher branching factor.\\\\\n        The \\textbf{further} pieces are from the \\textbf{goal}, deeper the program has to search.\\\\\n        A* algorithm stores each layer of nodes in a priority queue and only expend the $node$ $n$ with the least $g(n)+h(n)$. In the \\textbf{worst case}, it expands all the nodes fully, store and sort them in order of cost, giving $O(b^d)$ complexity for both \\textbf{space and time}. In the best case, our heuristic matches the real cost, and A only expand nodes with the correct path. This gives us $O(bd)$. The \\textbf{high memory complexity} of A* ($O(b^d)$) can be avoided by using \\textbf{iterative deepening A search}. This would reduce A* algorithm's \\textbf{space complexity} to $O(bd)$ (by trading off some time complexity).\\\\\n        The amount of free space on the board also affects the complexity of algorithm. From \\ref{fig:moves} we can see that as the board becomes more empty, we have more actions to consider. Despite the low cost solution of \\ref{fig:more_move}, its free space is drastically larger, leading to a significantly higher number of expanded nodes than that of \\ref{fig:less_move}.\n        \\begin{wrapfigure}[b]{r}{0.7\\textwidth}\n            \\begin{center}\n                \\begin{subfigure}[b]{0.25\\textwidth}\n                    \\includegraphics[width=\\textwidth]{SpaceComplexity1.png}\n                    \\caption{More options}\n                    \\label{fig:more_move}\n                \\end{subfigure}\n                \\begin{subfigure}[b]{0.25\\textwidth}\n                    \\includegraphics[width=\\textwidth]{SpaceComplexity2.png}\n                    \\caption{Less Options}\n                    \\label{fig:less_move}\n                \\end{subfigure}\n            \\end{center}\n            \\vspace{-10pt}\n            \\caption{Search space illustration}\\label{fig:moves}\n        \\end{wrapfigure}\n\\end{document}\n", "meta": {"hexsha": "ecb6f7410424406fbf2978f3aacfdae1eef811d7", "size": 11177, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/partA/report.tex", "max_stars_repo_name": "Dovermore/artificial_intelligence_project", "max_stars_repo_head_hexsha": "2d71afd241490b456dd58e71b8f1fa92e8e2f0b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/partA/report.tex", "max_issues_repo_name": "Dovermore/artificial_intelligence_project", "max_issues_repo_head_hexsha": "2d71afd241490b456dd58e71b8f1fa92e8e2f0b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/partA/report.tex", "max_forks_repo_name": "Dovermore/artificial_intelligence_project", "max_forks_repo_head_hexsha": "2d71afd241490b456dd58e71b8f1fa92e8e2f0b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.5705521472, "max_line_length": 637, "alphanum_fraction": 0.629238615, "num_tokens": 3124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.44123427831103995}}
{"text": "\n\\documentclass[11pt]{article}\n\\setlength{\\textwidth}{7in} \\setlength{\\textheight}{9.8in}\n\\setlength{\\topmargin}{-0.8in} \\setlength{\\oddsidemargin}{-0.25in}\n\\setlength{\\evensidemargin}{-0.25in}\n\n\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}\n\\usepackage{color}\n\\usepackage{hyperref}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n%\\usepackage{algpseudocode}\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Homework2  Page \\thepage}\n\\lhead{Shen Qu}\n\\chead{STAT 671}\n\n\\DeclareMathOperator{\\trace}{trace}\n\n\\begin{document}\n%\\includegraphics{../../../psulogo_horiz_bw.eps}\\hfill\\includegraphics{../../../deptlogo}\n\n\n\n\\section{Kernels}\n\n\\begin{enumerate}\n\\item let $(x,y) \\in \\mathbb{R}^+ \\times \\mathbb{R}^+$, where $\\mathbb{R}^+=\\{x \\in \\mathbb{R};x \\geq 0\\}$, the ``french positive\\rq\\rq{} real numbers. \n\n\\begin{enumerate}\n\\item  Verify that $\\min(x,y) = \\int_0^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt$\nwhere  $\\mathbb{I}_A =  \\left\\{\n\\begin{tabular}{ll}\n1 & \\mbox{ if A is true}\\\\\n0 & \\mbox{otherwise}\n\\end{tabular}\\right.$\n\nWhen $x\\le y$,\n\\begin{align*}\n\\int_0^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt&=\\int_0^x \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt+\\int_x^y \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt+\\int_y^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt\\\\\n&=\\int_0^x 1\\cdot 1 dt+\\int_x^y 0\\cdot 1 dt+\\int_y^\\infty 0\\cdot 0 dt=x\\\\\n\\end{align*}\n\nBy the same way, when $y\\le x$, $\\int_0^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt=y$.\n\nTherefore, $\\min(x,y) = \\int_0^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt$\n\\vspace{2mm}\n\\item Use the previous question to show that $K(x,y)=\\min(x,y)$ is a pd kernel over $\\mathbb{R}^+$\n\n\n\\vspace{2mm}\n$K(x,y)=\\min(x,y)=\\int_0^\\infty \\mathbb{I}_{t\\leq x} \\mathbb{I}_{t\\leq y} dt=\\min(y,x)=K(y,x)$ symmetric\n\n$$\\sum_{i=1}^n\\sum_{j=1}^n\\alpha_i\\alpha_j\\min(x,y)=\\int_0^\\infty \\sum_{i=1}^n\\alpha_i\\mathbb{I}_{t\\leq x} \\sum_{j=1}^n\\alpha_j\\mathbb{I}_{t\\leq y} dt=\\int_0^\\infty (\\sum_{i=1}^n\\alpha_i\\mathbb{I}_{t\\leq x})^2dt\\ge0$$\n\n\n\n\\item Show that $\\max(x,y)$ is not a pd kernel over  $\\mathbb{R}^+$. \n\\end{enumerate}\n\n% When $x\\le y$,  $\\int_0^\\infty \\mathbb{I}_{t\\geq x} \\mathbb{I}_{t\\geq y} dt=\\int_y^\\infty 1\\cdot 1 dt=\\left.t\\right|_y^\\infty\\neq\\max(x,y)$\n% The Gram Matrix\n% $$M(x,y)=\\begin{bmatrix}\\alpha_1\\alpha_1\\max(x, x) & \\alpha_1\\alpha_2\\max(x, y)\\\\\\alpha_2\\alpha_1\\max(x,y) & \\alpha_2\\alpha_2\\max(y,y)\\end{bmatrix} =\n%       \\begin{bmatrix}x &y \\\\y & y\\end{bmatrix}=xy-y^2\\le 0$$\n% When $y\\le x$, it is the same. $M(x,y)=xy-x^2\\le 0$. For example, \n\n\nLet $x_1=1,x_2=2,\\alpha_1=1,\\alpha_2=-1$ \n\n$\\sum_{i=1}^2\\sum_{j=1}^2\\alpha_1\\alpha_2 k(x_1,x_2)=\\alpha_1\\alpha_1 \\max(1,1)+\\alpha_1\\alpha_2 \\max(1,2)+\\alpha_2\\alpha_1 \\max(2,1)+\\alpha_2\\alpha_2 \\max(2,2)=1-2-2+2=-1<0$\n\nTherefore, $\\max(x,y)$ is not a p.d. kernel over  $\\mathbb{R}^+$\n\n\n\\item Consider a probability space $(\\Omega,\\mathcal{A},P)$\n\n\n\n\\begin{enumerate}\n\\item Define for any two events $A$ and $B$, $K_1(A,B)=P(A \\cap B)$\nwhere $A \\cap B$ is the intersection between the events A and B \nVerify that $K_1$ is positive definite. Hint: $P(A)=E[\\mathbb{I}_A]$\n\n\\vspace{2mm}\n$K_1(A,B)=P(A \\cap B)=P(B \\cap A)=K_1(B,A)$ symmetric\n\n$P(A)=E[\\mathbb{I}_A]$; $P(B)=E[\\mathbb{I}_B]$; $P(A\\cap B)=E[\\mathbb{I}_A\\mathbb{I}_B]$\n\n$$\\sum_{i=1}^n\\sum_{j=1}^n\\alpha_i\\alpha_jE[\\mathbb{I}_{A_i}\\mathbb{I}_{A_j}]=E[\\sum_{i=1}^n\\sum_{j=1}^n\\alpha_i\\alpha_j\\mathbb{I}_{A_i}\\mathbb{I}_{A_j}]=E[(\\sum_{i=1}^n\\alpha_i\\mathbb{I}_{A_i})^2]\\ge0$$\n\n\n\\item Define for any two events $A$ and $B$, \n$K_2(A,B)=P(A \\cap B)-P(A)P(B)$\nVerify that $K_2$ is positive definite. \n\\end{enumerate}\n\n\\vspace{2mm}\n$K_2(A,B)=P(A \\cap B)-P(A)P(B)=E[\\mathbb{I}_A\\mathbb{I}_B]-E[\\mathbb{I}_A]E[\\mathbb{I}_B]=Cov[\\mathbb{I}_A,\\mathbb{I}_B]$\n\n$$\\sum_{i=1}^n\\sum_{j=1}^n\\alpha_i\\alpha_jCov[\\mathbb{I}_{A_i},\\mathbb{I}_{A_j}]=Cov[\\sum_{i=1}^n\\alpha_i\\mathbb{I}_{A_i},\\sum_{j=1}^n\\alpha_j\\mathbb{I}_{A_j}]=Var[\\sum_{i=1}^n\\alpha_i\\mathbb{I}_{A_i}]\\ge 0$$\n\n\n\n\\end{enumerate}\n\n\n\\section{Kernels and RKHS}\n\\begin{enumerate}\n\\item Define the RKHS  over $\\mathbb{R}^d$ $K(x,y)=x^Ty+c$ where $c>0$. \n\n\\begin{enumerate}\n\\item What is the RKHS associated with the kernel $K$? no proof is required. \n\n$$\\mathcal{H} = \\{f:\\ \\mathbb{R}^d\\mapsto\\mathbb{R};\\ f_{w,w_0}(x)=w^Tx+w_0;\\quad w\\in\\mathbb{R}^d,w_0\\in\\mathbb{R}\\}$$\n\n\n\\item What is the inner product in this RKHS? no proof required.  \n\n$$\\langle f_{v,v_0},f_{w,w_0}\\rangle_{\\mathcal{H}}=v^Tw+\\frac1cv_0w_0\\Rightarrow\\langle f_{v,v_0},f_{v,v_0}\\rangle=\\|f_{v,v_0}\\|^2_{\\mathcal{H}}=\\|v\\|^2+\\frac{v_0^2}c$$\n\n\n\\item Verify the reproducing property\n\n$\\mathcal{H}$ contains all the functions $k(\\cdot,x): t\\mapsto k(t,x)=t^Tx+c=f_t(x)$\n\n$$\\langle f_{w,w_0},k(\\cdot,x)\\rangle=\\langle f_{w,w_0},f_{x,c}\\rangle=x^Tw+\\frac1ccw_0=w^Tx+w_0=f_w(x)$$\n\n$\\therefore\\langle f,k(\\cdot,x)\\rangle_{\\mathcal{H}}=f(x)$ for each $f\\in\\mathcal{H}$, $x\\in\\mathcal{X}$\n\n\\end{enumerate}\n\n\n\\item Define the RKHS  over $\\mathbb{R}^d$\n$K(x,y)=(x^Ty)^2$\nThe RKHS associated with the kernel $K$ is $\\{f_S;f_S(x)=x^T S x\\}$ where $S$ is a symmetric $(d,d)$ matrix. The inner product is\n$<f_{S_1},f_{S_2}>=<S_1,S_2>_F$\n\n\\begin{enumerate}\n\\item Verify the reproducing property. \n\n$\\mathcal{H}$ contains all the functions \n$k(\\cdot,x): t\\mapsto k(t,x)=(t^Tx)(t^Tx)=x^T\\cdot (tt^T)\\cdot x=f_t(x)$\n\n$$ \\langle f_{S},k(\\cdot,x)\\rangle_{\\mathcal{H}}=\\langle f_{S},f_{xx^T}\\rangle_{\\mathcal{H}}=\\langle S,xx^T\\rangle_{\\mathcal{F}}=\\trace[Sxx^T]=\\trace[x^TSx]=x^TS x= f_{S}(x)$$\n\n$\\therefore\\langle f_{S},k(\\cdot,x)\\rangle_{\\mathcal{H}}=f_{S}(x)$ for each $f\\in\\mathcal{H}$, $x\\in\\mathcal{X}$\n\n\n\\item Why do we require that $S$ is symmetric?\n\n$k(x,y)=(x^Ty)^2$ is a p.d. kernel. $\\langle f_{S},k(\\cdot,x)\\rangle_{\\mathcal{H}}= f_{S}(x)=x^TS x$ is a quadratic form over $\\mathbb{R}^d$, where $x$ is the column vector and $S$ must be a symmetric $n\\times n$ matrix by the definition of quadratic form.\n\n% The matrices $S$ and $x^TSx$ are congruent where $x$ is an invertible matrix over the same field.\n% Matrix congruence is an equivalence relation. Any matrix congruent to a symmetric matrix is again symmetric. Therefore, $S$ must be symmetric.\n\n\n%Only if $\\underset{(d,d)}{S}$ is a symmetric Matrix, $t^Tx=x^Tt$.\n\n%$$[S_1]_{ij}[S_2]_{ij}=\\trace[(x_i^Tx_j)(y_j^Ty_i)]=\\trace[(y_ix_i^T)(x_jy_j^T)]=\\langle x_iy_i^T,x_jy_j^T\\rangle_{\\mathcal{F}}=\\langle z_i,z_j\\rangle_{\\mathbb{R}^{n^2}}$$\n%If not, we can not complete the step of $(t^Tx)(t^Tx)=x^T\\cdot (tt^T)\\cdot x$ in (b).\n\n\n\\end{enumerate}\n\n\\item Define the RKHS  over $\\mathbb{R}^d$ $K(x,y)=(x^Ty+c)^2$ where $c>0$. \n\n\\begin{enumerate}\n\\item What is the RKHS associated with the kernel $K$? no proof is required. \n\n$$\\{f_{S,s,s_0}: f_{S,s,s_{0}}(x)=x^T S x+2s_0 s^Tx+s_0^2;\\quad S\\in\\mathbb{R}^{d\\times d},s\\in\\mathbb{R}^{d},s_0\\in\\mathbb{R}\\}$$\n\n\n\\item What is the inner product in this RKHS? no proof required.  \n\n\n$$\\langle f_{S_1,s_1,s_{10}},f_{S_2,s_2,s_{20}}\\rangle_{\\mathcal{H}}=\\langle S_1,S_2\\rangle_{\\mathcal{F}}+\\frac{2s_{10}s_{20}}cs_1^Ts_2+(\\frac{s_{10}s_{20}}c)^2$$\n\n\\item Verify the reproducing property\n\n$\\mathcal{H}$ contains all the functions \n$k(\\cdot,x_i): t\\mapsto k(t,x)=(t^Tx+c)^2=x^T\\cdot (tt^T)\\cdot x+2ct^Tx+c^2=f_t(x)$\n\n\n$$\\langle f_{S,s,s_{0}},k(\\cdot,x)\\rangle_{\\mathcal{H}}=\\langle f_{S,s,s_{0}},f_{xx^T,x,c}\\rangle_{\\mathcal{H}}=\\langle S,xx^T\\rangle_{\\mathcal{F}}+\\frac{2s_{0}c}cs^Tx+(\\frac{s_{0}c}c)^2$$\n$$=x^T Sx+2s_{0}s^Tx+s_0^2= f_{S,s,s_{0}}(x)$$\n\n$\\therefore\\langle f_{S,s,s_{0}},k(\\cdot,x)\\rangle_{\\mathcal{H}}=f_{S,s,s_{0}}(x)$ for each $f\\in\\mathcal{H}$, $x\\in\\mathcal{X}$\n\n\\end{enumerate}\n\n\\end{enumerate}\n\n\n\n\n\\section{Fisher kernel} \nLet $\\theta \\in \\mathbb{R}$ be a parameter and let $p_\\theta$ be a probabilistic model (i.e a point mass function or a density) over a set $\\mathcal{X}$ indexed by $\\theta$. Let $\\theta_0 \\in \\mathbb{R}$ be a specific value for $\\theta$.\nLet us define the Fisher score at $x \\in \\mathcal{X}$ as\n$\\phi(x,\\theta_0) = \\frac{\\delta}{\\delta \\theta} \\ln p_\\theta(x) \\mbox{ evaluated at } \\theta=\\theta_0$\nassuming that this quantity exists. \nDefine $I(\\theta)$, the Fisher information associated with the parameter $\\theta$, i.e., \n$I(\\theta)=E[\\phi^2(X,\\theta)]$\nwhere $E$ stands for expectation and $X$ is a random variable with distribution $p_\\theta$. \nThe Fisher kernel is then \n$k(x,x')=\\frac{\\phi(x,\\theta_0)\\phi(x',\\theta_0)}{I(\\theta_0)}$\nwhere \n\\begin{enumerate}\n\\item Verify that $k(.,.)$ is a positive definite kernel over $\\mathcal{X}$\n\n$k(x,x')=\\frac{\\phi(x,\\theta_0)\\phi(x',\\theta_0)}{I(\\theta_0)}=\\frac{\\phi(x',\\theta_0)\\phi(x,\\theta_0)}{I(\\theta_0)}=k(x',x)$ symmetric.\n\nFor $I(\\theta)=E[\\phi^2(X,\\theta)]\\ge0$,\n\n$k(x,x')=\\frac{1}{I(\\theta_0)}\\sum_{i=1}^n\\alpha_i\\phi(x_i,\\theta_0)\\sum_{j=1}^n\\alpha_j\\phi(x_j,\\theta_0)=\\frac{1}{I(\\theta_0)}[\\sum_{i=1}^n\\alpha_i\\phi(x_i,\\theta_0)]^2\\ge0$\n\n$\\therefore k(.,.)$ is a positive definite kernel over $\\mathcal{X}$\n\n\\item Consider the following model: $x \\in \\{0,1\\}$, $X \\sim Bernoulli(\\theta)$, $0 < \\theta < 1$, that is\n$p_\\theta(x)=\\theta^x(1-\\theta)^{(1-x)}$\nWe recall that in this case $E[X]=\\theta$ and $Var[X]=E[(X-\\theta)^2]=\\theta(1-\\theta)$\nCompute $k(x,x')$\n\n\\begin{align*}\np_\\theta(x)&=\\theta^x(1-\\theta)^{(1-x)} \\\\\n  \\ln p_\\theta(x)&=x\\ln\\theta+(1-x)\\ln(1-\\theta)\\\\\n  \\frac{d}{d \\theta} \\ln p_\\theta(x)&=\\frac{x}{\\theta}+\\frac{1-x}{1-\\theta}=\\frac{x-\\theta}{\\theta(1-\\theta)}\n\\end{align*}\n\n$$I(\\theta)=E[\\phi^2(X,\\theta)]=E[(\\frac{X-\\theta}{\\theta(1-\\theta)})^2]\n=\\frac{E[(X-\\theta)^2]}{\\theta^2(1-\\theta)^2}=\\frac{V[X]}{\\theta^2(1-\\theta)^2}\n=\\frac{\\theta(1-\\theta)}{\\theta^2(1-\\theta)^2}=\\frac{1}{\\theta(1-\\theta)}$$\n\n\n$$k(x,x')=\\frac{\\phi(x,\\theta_0)\\phi(x',\\theta_0)}{I(\\theta_0)}=\\frac{(x-\\theta_0)(x'-\\theta_0)}{\\theta_0^2(1-\\theta_0)^2}\\theta_0(1-\\theta_0)=\\frac{(x-\\theta_0)(x'-\\theta_0)}{\\theta_0(1-\\theta_0)} \\qquad\\hfill\\square$$\n\n\\item Assume now $x=(x_1,x_2)$ with $x_1 \\in \\{0,1\\}$ and $x_2 \\in \\{0,1\\}$. \nWe consider the following model where $X=(X_1,X_2)$, $X_1$ and $X_2$ are independent with the same $Bernoulli(\\theta)$ distribution. \nCompute $k(x,x')$. \n\n\\begin{align*}\n  p_\\theta(\\vec x)\\underset{x_1\\perp x_2}{=}&p_\\theta(x_1)p_\\theta(x_2)=\\theta^{x_1+x_2}(1-\\theta)^{2-x_1-x_2}\\\\\n  \\ln p_\\theta(x)=&(x_1+x_2)\\ln\\theta+(2-x_1-x_2)\\ln(1-\\theta)\\\\\n  \\phi(\\vec x,\\theta)=& \\frac{d}{d \\theta} \\ln p_\\theta(x)=\\frac{x_1+x_2}{\\theta}+\\frac{2-x_1-x_2}{1-\\theta}=\\frac{x_1+x_2-2\\theta}{\\theta(1-\\theta)}\n\\end{align*}\n\n\\begin{align*}\nI(\\theta)=&E[\\phi^2(\\vec X,\\theta)]=\\frac{E[(X_1+X_2-2\\theta)^2]}{\\theta^2(1-\\theta)^2}\\\\\n\\underset{x_1\\perp x_2}{=}&\\frac{E[(X_1-\\theta)^2]+E[(X_2-\\theta)^2]+2(E[X_1]-\\theta)(E[X_2]-\\theta)}{\\theta^2(1-\\theta)^2}\\\\\n=&\\frac{V[X_1]+V[X_2]-0}{\\theta^2(1-\\theta)^2}=\\frac{2\\theta(1-\\theta)}{\\theta^2(1-\\theta)^2}=\\frac{2}{\\theta(1-\\theta)}\n\\end{align*}\n\n\\begin{align*}\nk(x,x')&=\\frac{\\phi(\\vec x,\\theta_0)\\phi(\\vec x',\\theta_0)}{I(\\theta_0)}=\\frac{(x_1+x_2-2\\theta_0)(x'_1+x'_2-2\\theta_0)}{\\theta_0^2(1-\\theta_0)^2}\\frac{\\theta_0(1-\\theta_0)}2\\\\\n&=\\frac{(x_1+x_2-2\\theta_0)(x'_1+x'_2-2\\theta_0)}{2\\theta_0(1-\\theta_0)}&& \\square\n\\end{align*}\n\n\\end{enumerate}\n \n\n\n \n\n\n\\end{document}\n", "meta": {"hexsha": "9913c4a4739beaf48d1e3bcfd96b9629a94fcfef", "size": 11235, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "static/stat671/hw/hw2_stat671.tex", "max_stars_repo_name": "UrbanStudy/stat2019_website", "max_stars_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-29T12:51:19.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T12:51:19.000Z", "max_issues_repo_path": "static/stat671/hw/hw2_stat671.tex", "max_issues_repo_name": "UrbanStudy/stat2019_website", "max_issues_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "static/stat671/hw/hw2_stat671.tex", "max_forks_repo_name": "UrbanStudy/stat2019_website", "max_forks_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4575645756, "max_line_length": 256, "alphanum_fraction": 0.6436137072, "num_tokens": 4938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.44123427684848743}}
{"text": "%!TEX root = ../chapter2.tex\n%******************************\n%\t Results \n%*****************************\n\n\\section{Extending the  BASiCS model}\n\nUnlike bulk RNA sequencing, scRNA-Seq provides information about cell-to-cell expression heterogeneity within a population of cells. \nPast works have used a variety of measures to quantify this heterogeneity. Among others, this includes the \\gls{CV2} \\citep{Brennecke2013} and entropy measures \\citep{Richard2016}. \nThe BASiCS model \\citep{Vallejos2015BASiCS, Vallejos2016}, which was introduced in \\textbf{Section \\ref{sec0:BASiCS}}, focuses on biological \\textit{over-dispersion} as a proxy for transcriptional heterogeneity. \nThis is defined as the excess of variability that is observed with respect to what would be predicted by Poisson sampling noise, after accounting for technical variation. \n\n\\subsection{The BASiCS model}\n\nLet $X_{ij}$ be a random variable representing the expression count of gene $i \\in \\{1, \\ldots, q\\}$ in cell $j \\in \\{ 1, \\ldots ,n\\}$.  \nTo control for technical noise, we employ reads from synthetic RNA spike-ins (see \\citep{Jiang2011}). \nWe assume the first $q_0$ genes to be biological followed by the $q-q_0$ spike-in genes. \nBASiCS assumes a hierarchical Poisson formulation: \n\n\\begin{equation} \\label{eq::PoissonBASiCS}\n X_{ij}|\\mu_i,\\phi_j,\\nu_j,\\rho_{ij} \\ind\n \\left\\lbrace\n  \\begin{aligned}\n    &\\text{Poisson}(\\phi_j\\nu_j\\mu_i\\rho_{ij}), && i=1,...,q_0,j=1,...n;  \\\\ \n    &\\text{Poisson}(\\nu_j\\mu_i), && i=q_0+1,...,q,j=1,...,n,    \t    \n  \\end{aligned}\n\\right.\n\\end{equation} \n\nwhere, to account for technical ($\\nu_j$) and biological ($\\rho_{ij}$) factors that affect the variance of the transcript counts, we incorporate two random effects: \n\n\\begin{equation} \\label{eq::RandomEffectsBASiCS}\n\\nu_j|s_j,\\theta \\ind \\text{Gamma}\\left(\\frac{1}{\\theta},\\frac{1}{s_j\\theta}\\right), \\hspace{0.5cm} \\rho_{ij}|\\delta_i  \\iid \\text{Gamma}\\left(\\frac{1}{\\delta_i},\\frac{1}{\\delta_i}\\right)\\\\\n\\end{equation} \n\nHere, $\\phi_j$ represents a cell-specific normalisation parameter to correct for differences in mRNA content between cells. \nGene-specific parameters $\\mu_i$ represent average expression of a gene across cells. \nThe strength of the technical noise $\\nu_j$ is quantified by a global parameter $\\theta$ (shared across all genes and cells). \n$s_j$ models cell-specific differences in efficiency to capture RNA spike-in transcripts affecting all biological and technical genes. \nThe strength of heterogeneous gene expression across cells $\\rho_{ij}$ is controlled by gene-specific over-dispersion parameters $\\delta_i$ which we used as a proxy for biological expression variability in the previous chapter. \nAs shown in the previous chapter, over-dispersion as a measure of variability can be used to identify genes whose transcriptional heterogeneity differs between groups of cells (defined by experimental conditions or cell types). \nHowever, the strong relationship that is typically observed between variability and mean estimates (see \\textbf{Section \\ref{sec0:BASiCS}} and \\citep{Brennecke2013}) can hinder the interpretation of these results. \n\n\\newpage\n\n\\subsection{Approaches to correct the mean-variability confounding effect}\n\nA simple solution to avoid the confounding effect of mean expression was used in \\textbf{Chapter 2} by restricting the assessment of differential variability to genes with equal mean expression across populations \\textbf{(Fig.~\\ref{fig2:Schematic_model}A and Section \\ref{sec1:BASiCS})}. \nHowever, this is sub-optimal, particularly in the case of naive and activated CD4\\plus{} T cells where large sets of genes are differentially regulated upon immune activation. \nWith the current model, immune response genes (e.g.~cytokines, nuclear receptors, transcription factors) are excluded from differential variability testing. \nAn alternative approach is to directly adjust variability measures to remove this confounding. \nFor example, Kolodziejczyk \\emph{et al.}, 2015 computed the empirical distance between the \\gls{CV2} to a rolling median along expression levels --- referred to as the DM method \\citep{Newman2006, Kolodziejczyk2015cell}.  \\\\\n\nIn line with this idea, our method extends the statistical model implemented in BASiCS \\citep{Vallejos2015BASiCS, Vallejos2016} to meaningfully assess changes in transcriptional heterogeneity when genes exhibit shifts in mean expression \\textbf{(Fig.~\\ref{fig2:Schematic_model}B)}. \nFor this, we infer a regression trend between over-dispersion ($\\delta_i$) and gene-specific mean parameters ($\\mu_i$), by introducing a joint informative prior to capture the dependence between these parameters. \nA latent gene-specific \\textit{residual over-dispersion} parameter $\\epsilon_i$ describes departures from this trend \\textbf{(Fig~\\ref{fig2:Schematic_model}C)}. \nThe value of $\\epsilon_i$ indicates whether a gene exhibits more (positive) or less (negative) variation than expected relative to genes with similar expression levels. \nImportantly, this measure is not confounded by mean expression \\textbf{(Fig.~\\ref{fig2:Schematic_model}D)}. \\\\\n\nThe hierarchical Bayesian approach infers full posterior distributions for the gene-specific latent residual over-dispersion parameters $\\epsilon_i$. \nAs a result, we can directly use a probabilistic approach to identify genes with large absolute differences in residual over-dispersion between two groups of cells. \nWhen the posterior samples of $\\epsilon_i$ in condition A are very different from posterior samples of $\\epsilon_i$ in condition B, the majority of values for $|\\epsilon_i^A - \\epsilon_i^B|$ are larger than a given threshold $\\psi_0>0$. \nIn this case, the gene is found to be differentially variable between the two conditions  \\textbf{(Fig.~\\ref{fig2:Schematic_model}E and Section \\ref{sec0:decision})}. \nIn contrast, mean-corrected point estimates for residual noise parameters (such as those obtained by the DM method) cannot be directly used to perform gene-specific statistical testing between two conditions as no measure of the uncertainty in the estimate is available.\\\\\n\n\\newpage\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.9\\textwidth]{Fig_1.png}\n\\caption[Addressing the mean confounding effect in scRNA-Seq data]{\\textbf{Addressing the mean confounding effect in scRNA-Seq data (full legend on next page).}\\\\}\n\\label{fig2:Schematic_model}\n\\end{figure}\n\n\\newpage\n\n\\captionsetup[figure]{list=no}\n\\addtocounter{figure}{-1}   \n\\captionof{figure}{\\textbf{Addressing the mean confounding effect in scRNA-Seq data (continued).}\\\\\n\\textbf{(A and B)} Illustration of changes in expression variability for a single gene between two cell populations without (left) and with (right) changes in mean expression, \n\\textbf{(C and D)} The extended BASiCS model infers a regression trend between gene-specific estimates of over-dispersion parameters $\\delta_i$ and mean expression $\\mu_i$. \nResidual over-dispersion parameters $\\epsilon_i$ are defined by departures from the regression trend (red arrow). \nThe colour code within the scatterplots is used to represent areas with high (yellow/red) and low (blue) concentration of genes. \nFor illustration purposes, the data introduced by Antolovi\\'{c} \\emph{et al.}, 2017 \\cite{Antolovic2017} has been used, \\textbf{(C)} Illustration of the typical confounding effect that is observed between gene-specific estimates of over-dispersion parameters $\\delta_i$ and mean expression parameters $\\mu_i$. \nGenes that are not detected in at least 2 cells are indicated by purple points, \n\\textbf{(D)} Gene-specific estimates of residual over-dispersion parameters $\\epsilon_i$ are independent of mean expression parameters $\\mu_i$, \n\\textbf{(E)} Illustration of how posterior uncertainty is used to highlight changes in residual over-dispersion. \nTwo example genes with (upper panels) and without (lower panels) changes in residual over-dispersion are shown. \nLeft panels illustrate the posterior density associated to residual over-dispersion parameters $\\epsilon_i$ for a gene in two groups of cells (group A: light blue, group B: dark blue). \nThe coloured area in the right panels represents the posterior probability of observing an absolute difference $|\\epsilon^A_{i} - \\epsilon^B_{i}|$ that is larger than the minimum tolerance threshold $\\psi_0$.\\\\}\n\\captionsetup[figure]{list=yes}\n\n\\subsection{Modelling the confounding between mean and over-dispersion} \\label{sec2:extended_BASiCS}\n\nHere, we extend BASiCS to account for the confounding effect described above. In a Bayesian framework, the prior information captures the relationship between parameters. \nTherefore, we introduce the following joint prior distribution for $(\\mu_i, \\delta_i)'$: \n\n\\begin{equation} \\label{eq::jointprior} \\mu_i \\sim \\text{log-Normal}\\left(0, s^2_{\\mu}\\right), \\hspace{0.8cm}\n\\delta_i | \\mu_i \\sim \\text{log-}\\text{T}_{\\eta}\\left( \\text{f}(\\mu_i), \\sigma^2 \\right).\n\\end{equation} \n\nThe latter is equivalent to the following non-linear regression model:\n\n\\begin{equation} \\label{eq::regression}\n\\log(\\delta_i) =\\text{f}(\\mu_i)+\\epsilon_i, \\hspace{0.5cm} \\epsilon_i \\sim{}\\text{T}_{\\eta}(0,\\sigma^2), \n\\end{equation} where $\\text{f}(\\mu_i)$ represents the over-dispersion (on the log-scale) that is predicted by the global trend (across all genes) for a given mean expression $\\mu_i$. \nTherefore, $\\epsilon_i$ can be interpreted as a latent gene-specific \\textit{residual over-dispersion} parameter, capturing departures from the overall trend. \\\\\n\nA similar approach was introduced by DESeq2 \\citep{Love2014} in the context of bulk RNA sequencing. \nWhereas DESeq2 assumes normally distributed errors when estimating this trend, here we use Student-T distributed errors (with $\\eta$ degrees of freedom) as it leads to inference that is more robust to the presence of outlier genes \\citep{Fernandez1999}. \n\n\\newpage\n\nMoreover, the parametric trend assumed by DESeq2 is replaced by a more flexible semi-parametric approach. This is defined by\n\n\\begin{equation} \\label{eq::trend}\n\\text{f}(\\mu_i) = \\alpha_0 + \\log(\\mu_i)\\alpha_1 + \\sum_{l=1}^L \\text{g}_l(\\log(\\mu_i))\\beta_l,\n\\end{equation} \n\nwhich is a linear combination of an intercept, a linear term $\\log(\\mu_i)$ and a set of $L$ \\gls{GRBF} kernels $\\text{g}_1(\\cdot), \\ldots, \\text{g}_L(\\cdot)$. As in Kapourani \\emph{et al.}, 2016 \\cite{Kapourani2016}, these are defined as: \n\n\\begin{equation} \\label{eq::GRBF}\n\\text{g}_l(\\log(\\mu_i)) = \\exp\\left\\lbrace-\\frac{1}{2}\\left(\\dfrac{\\log(\\mu_i)-m_l}{h_l}\\right)^2\\right\\rbrace, \\hspace{0.3cm} l = 1, \\ldots, L,\n\\end{equation} \n\nwhere $m_l$ and $h_l$ represent location and scale hyper-parameters for GRBF kernels and $\\alpha_0, \\alpha_1, \\beta_1, \\ldots, \\beta_L$ are regression coefficients. \\\\\n\nIn equation \\eqref{eq::trend}, the linear term captures the (typically negative) global correlation between $\\delta_i$ and $\\mu_i$. \nIts addition also stabilises inference of GRBFs around mean expression values where only a few of genes are observed. \nIn equation \\eqref{eq::GRBF}, the location and scale hyper-parameters $(m_l, h_l)$ are assumed to be fixed \\emph{a priori} (see \\textbf{Section \\ref{sec2:hyper-parameters}}). \n\n\\newpage\n\n\\subsection{Implementation}\n\nNext, we will give a detailed explanation on how the model was built and how posterior sampling was performed.  \n\n\\subsubsection{Prior specification}\n\nFor implementation purposes, the log-Student-T distribution in equation \\eqref{eq::jointprior} is represented via a shape mixture of a log-Normal density with a Gamma density as in Vallejos \\emph{et al.}, 2015 \\cite{Vallejos2015}. \nThis introduces an auxiliary set of parameters $\\lambda_i$ such that the full prior specifications of the extended BASiCS model are:\n\n\\begin{align*}\n\\mu_i &\\ind \\mbox{log-Normal}\\left(0, s^2_{\\mu}\\right) \\\\\n\\delta_i| \\mu_i,\\beta,\\sigma^2, \\lambda_i, \\eta &\\ind \\text{log-N}\\left( \\text{f}(\\mu_i),\\frac{\\sigma^2}{\\lambda_i} \\right)\\\\\n\\lambda_i|\\eta &\\ind \\text{Gamma}\\left(\\frac{\\eta}{2},\\frac{\\eta}{2}\\right)\\\\\n\\beta|\\sigma^2 & \\sim \\textnormal{Normal}(m_\\beta,\\sigma^2V_\\beta),\\\\\n\\sigma^2 & \\sim  \\textnormal{Inv-Gamma}(a_{\\sigma^2},b_{\\sigma^2}),\\\\\ns_j & \\iid  \\textnormal{Gamma}(a_s,b_s) \\\\\n(\\phi_1, \\ldots, \\phi_n)' & \\sim  n \\times \\textnormal{Dirichlet}(a_\\phi),\\\\\n\\theta & \\sim  \\textnormal{Gamma}(a_\\theta,b_\\theta)\n\\end{align*}\n\nHere, $s^2_{\\mu}, m_\\beta, V_\\beta, a_{\\sigma^2}, b_{\\sigma^2}, a_s, b_s, a_\\phi, a_\\theta, b_\\theta$ are hyper-parameters that are fixed \\emph{a priori}. \nTheir initial values can be found in \\textbf{Appendix \\ref{appB.1.hyper}}. \nIn principle, the degrees of freedom parameter $\\eta$ could also be estimated within a Bayesian framework. \nHowever, we observed that fixing this parameter \\emph{a priori} led to more stable results. \nA default choice for this parameter is described in \\textbf{Section \\ref{sec2:hyper-parameters}}.\n\n\\newpage\n\n\\subsubsection{Estimation of regression parameters}\n\nTo simplify inference for the regression coefficients $\\beta = (\\alpha_0, \\alpha_1, \\beta_1, \\ldots, \\beta_L)'$ equation \\eqref{eq::trend} can be rewritten as a linear regression model using \n\n\\begin{equation} \\label{eq::trend2} \n\\text{f}(\\mu_i) = X \\beta\n\\end{equation} \n\nHere, $X$ is a $q_0 \\times (L+2)$ model matrix given by \n\n\\begin{equation} \\label{eq::X} X = \\left( \\begin{array}{ccccc}\n1 & \\log(\\mu_1) & g_1(\\log(\\mu_1)) & \\cdots & g_L(\\log(\\mu_1)) \\\\\n1 & \\log(\\mu_2) & g_1(\\log(\\mu_2)) & \\cdots & g_L(\\log(\\mu_2)) \\\\\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots  \\\\\n1 & \\log(\\mu_{q_0}) & g_1(\\log(\\mu_{q_0})) & \\cdots & g_L(\\log(\\mu_{q_0}))\n\\end{array}\\right)\n\\end{equation}\n\nEach column contains either the intercept, the linear component or values of one of the $L$ GRBF. \nThis matrix is updated every 50 iterations during posterior sampling.\n\n\\subsubsection{Posterior inference}\n\nPosterior inference for the model described above is implemented by extending the Adaptive Metropolis within Gibbs sampler \\citep{Roberts2009} that was adopted by Vallejos \\emph{et al.}, 2016 \\cite{Vallejos2016}. \nTo implement the sampler, the full conditionals for each model parameter need to be derived. \\\\\n\nAs in Vallejos \\emph{et al.}, 2015 \\cite{Vallejos2015BASiCS}, the random effect $\\rho_{ij}$ in \\ref{eq::PoissonBASiCS} is integrated out, leading to the following count distributions:\n\n\\begin{equation} \\label{eq::NegBinBASiCS}\n X_{ij}|\\mu_i,\\delta_i,\\phi_j,\\nu_j \\ind\n \\left\\lbrace\n  \\begin{aligned}\n    &\\text{Neg-Bin}\\left(\\frac{1}{\\delta_i},\\frac{\\phi_j\\nu_j\\mu_i}{\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i}}\\right), && i=1,...,q_0,j=1,...n;  \\\\ \n    &\\text{Poisson}(\\nu_j\\mu_i), && i=q_0+1,...,q,j=1,...,n        \n  \\end{aligned}\n\\right.\n\\end{equation}\n\nBased on equation \\eqref{eq::NegBinBASiCS}, the likelihood function therefore takes the form\n\n\\begin{align} \\label{eq::loglik}\n\\Lagr = & \\left[\\prod_{i=1}^{q_0}\\prod_{j=1}^n\\frac{\\Gamma(x_{ij}+\\frac{1}{\\delta_i})}{\\Gamma(\\frac{1}{\\delta_i})x_{ij}!}\\left(\\frac{\\frac{1}{\\delta_i}}{\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i}}\\right)^\\frac{1}{\\delta_i}\\left(\\frac{\\phi_j\\nu_j\\mu_i}{\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i}}\\right)^{x_{ij}}\\right] \\nonumber\\\\ \n&\\times\\left[\\prod_{i=q_0+1}^{q}\\prod_{j=1}^n\\frac{(\\nu_j\\mu_i)^{x_{ij}}}{x_{ij}!}\\exp\\lbrace-\\nu_j\\mu_i\\rbrace\\right]\\times{}\\left[\\prod_{j=1}^n\\frac{(s_j\\theta)^{-\\frac{1}{\\theta}}}{\\Gamma(\\frac{1}{\\theta})}\\nu_j^{\\frac{1}{\\theta}-1}\\exp\\left\\lbrace-\\frac{\\nu_j}{s_j\\theta}\\right\\rbrace\\right]\n\\end{align} \n\n\\newpage\n\nThe full conditionals can now be derived by calculating the parameter-dependent part of the posterior distribution which is a product of the likelihood times the prior specifications $\\pi^\\ast(\\cdot)\\propto{}\\Lagr\\times\\pi(\\cdot)$. \nFull conditionals for the model are as follows: \\\\\n\n\\begingroup\n\\addtolength{\\jot}{0.8em}\n\\begin{align*} \\label{eq::FullCond}\n&\\pi^*(\\mu_i|\\cdot) && \\propto \\frac{\\mu_i^{\\sum_{j=1}^n{}x_{ij}}}{\\prod_{j=1}^n{}(\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i})^{\\frac{1}{\\delta_i}+x_{ij}}}\\times{}\\exp\\left(-\\frac{(\\log(\\mu_i))^2}{2a_\\mu^2}-\\frac{\\lambda_i(\\log(\\delta_i)-f(\\mu_i))^2}{2\\sigma^2}\\right)\\frac{1}{\\mu_i} \\\\\n&\\pi^*(\\delta_i|\\cdot) && \\propto \\left[\\prod_{j=1}^n\\frac{\\Gamma(x_{ij}+\\frac{1}{\\delta_i})}{\\Gamma(\\frac{1}{\\delta_i})}\\frac{(\\frac{1}{\\delta_i})^{\\frac{1}{\\delta_i}}}{(\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i})^{\\frac{1}{\\delta_i}+x_{ij}}}\\right]\\times{}\\exp\\left\\lbrace-\\frac{\\lambda_i(\\log(\\delta_i)-f(\\mu_i))^2}{2\\sigma^2}\\right\\rbrace\\frac{1}{\\delta_i}\\\\\n&\\pi^*(\\beta|\\cdot)&&\\propto{}\\text{Normal}(m^*_\\beta,\\sigma^2V^*_\\beta)\\\\\n&\\pi^*(\\lambda_i|\\cdot)&&\\propto{}\\text{Gamma}(a^*_\\lambda,b^*_\\lambda)\\\\\n&\\pi^*(\\sigma^2|\\cdot)&&\\propto{}\\text{Inv-Gamma}(a^*_{\\sigma^2},b^*_{\\sigma^2})\\\\\n&\\pi^*(s_j|\\cdot)&&\\propto{}s_j{}^{a_s-\\frac{1}{\\theta}-1}\\exp\\lbrace-\\frac{\\nu_j}{s_j\\theta}-b_ss_j\\rbrace\\\\\n&\\pi^*(\\phi_j|\\cdot)&&\\propto{}\\frac{\\prod_{i=1}^{q_0}\\phi_j{}^{\\sum_{j=1}^nx_{ij}}}{\\prod_{i=1}^{q_0}\\prod_{j=1}^{n}(\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i})^{\\frac{1}{\\delta_i}+x_{ij}}}\\times{}\\pi(\\phi_j)\\\\\n&\\pi^*(\\nu_j|\\cdot)&&\\propto{}\\left[\\prod_{i=1}^{q_0}\\left(\\frac{1}{\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i}}\\right)^\\frac{1}{\\delta_i}\\left(\\frac{\\nu_j}{\\phi_j\\nu_j\\mu_i+\\frac{1}{\\delta_i}}\\right)^{x_{ij}}\\right]\\left[\\prod_{i=q_0+1}^{q}\\nu_j{}^{x_{ij}}\\exp\\lbrace-\\nu_j\\mu_i\\rbrace\\right]\\nu_j^{\\frac{1}{\\theta}-1}\\exp\\lbrace-\\frac{\\nu_j}{s_j\\theta}\\rbrace\\\\\n&\\pi^*(\\theta|\\cdot)&&\\propto{}\\frac{\\left(\\prod_{j=1}^{n}\\frac{s_j}{\\nu_j}\\right)^{-\\frac{1}{\\theta}}}{\\Gamma{}^n(\\frac{1}{\\theta})}\\theta^{a_\\theta-\\frac{n}{\\theta}-1}\\exp\\lbrace-\\frac{1}{\\theta}\\sum_{j=1}^n\\frac{\\nu_j}{s_j}-b_\\theta\\theta\\rbrace\n\\end{align*}\n\\endgroup\n\nHere, posteriors for $\\beta, \\lambda_i, \\sigma^2$ take on closed form distributions. \nThe posterior for $s_j$ represents a Generalised Inverse Gaussian distribution. \nTo sample all other posterior distributions adaptive Metropolis sampling was implemented as described in \\textbf{Section \\ref{sec0:posterior_inference}}. \nThe derivation of the full conditionals can be found in \\textbf{Appendix  \\ref{appB.1.derivation}}. \nIn practice, the MCMC sampler is run for 40,000 iterations with a 20,000 iteration burn in period. \nThe chain was thinned by storing parameter samples every 20 iterations.\n\n\\newpage\n\n\\subsection{Probabilistic rule associated to the differential test} \\label{sec:differentialtest}\n\nThe residual over-dispersion parameter is calculated as $\\epsilon_i=\\log(\\delta_i)-\\text{f}(\\mu_i)$. \nWe can now implement a probabilistic approach to identify changes in residual over-disperison between groups of cells. \nLet $\\delta_i^A$ and $\\delta_i^B$ be the over-dispersion parameters associated to gene $i$ in groups $A$ and $B$. \nFollowing equation \\eqref{eq::regression}, the log$_2$ fold change in over-dispersion between these groups can be decomposed as: \n\n\\begin{equation} \\label{eq::dispersion_lfc}\n\\log_2 \\left( \\frac{\\delta_i^A}{\\delta_i^B}\\right) = \\log_2(e) \\times \\left[\\underbrace{\\text{f}^A(\\mu_i^A) - \\text{f}^B(\\mu_i^B) }_{\\text{Mean contribution}} + \\underbrace{\\epsilon_i^A - \\epsilon_i^B}_{\\text{Residual change}} \\right]\n\\end{equation} \n\nwhere the first term captures the over-dispersion change that can be attributed to differences between $\\mu_i^A$ and $\\mu_i^B$. \nThe second term in equation \\eqref{eq::dispersion_lfc} represents the change in residual over-dispersion that is not confounded by mean expression. \nBased on this observation, statistically significant differences in residual over-dispersion will be identified for those genes where the tail posterior probability of observing a large difference between $\\epsilon_i^A$ and $\\epsilon_i^B$ exceeds a certain threshold $\\psi_0 > 0$:\n\n\\begin{equation} \\label{eq::decision_rule}\n\\pi_i(\\psi_0)=\\text{P}(\\mid\\epsilon_i^{A}-\\epsilon_i^{B}\\mid >\\psi_0 \\mid \\text{Data} ) >\\alpha_R\n\\end{equation}\n \nAs a default choice for testing changes in over-dispersion we chose a 50\\% increase. \nThis translates into $\\psi_0 = \\log_2(1.5) / \\log_2(e) \\approx 0.41$ as default threshold for testing changes in residual over-dispersion. \nIn the limiting case when $\\psi_0 = 0$, the probability in equation \\eqref{eq::decision_rule} is equal to 1 regardless of the information contained in the data. \nTherefore, as in Bochkina \\emph{et al.}, 2007 \\cite{Bochkina2007}, our decision rule is based on the maximum of the posterior probabilities associated to the one-sided hypotheses $\\epsilon^A - \\epsilon^B_i > 0$ and  $\\epsilon^A - \\epsilon^B_i < 0$:\n\n\\begin{equation} \\label{eq::decision_rule2} 2 \\times \\max\\{\\pi_i^+, 1-\\pi_i^+\\} - 1  >\\alpha_R, \\hspace{0.2cm} \\text{with} \\hspace{0.2cm} \\pi_i^+ = \\text{P}(\\epsilon_i^{A}-\\epsilon_i^{B} > 0 \\mid \\text{Data})\n\\end{equation}\n\nIn both cases, the posterior probability threshold $\\alpha_R$ is chosen to control the expected false discovery rate (EFDR) \\citep{Newton2004}. The default value for EFDR is set to 10\\%. The EFDR is defined as:\n\n\\begin{equation}\n\\text{EFDR}_{\\alpha_R}(\\psi_0)=\\frac{\\sum_{i=1}^{q_0}(1-\\pi_i(\\psi_0))\\text{I}(\\pi_i(\\psi_0)>\\alpha_R)}{\\sum_{i=1}^{q_0}\\text{I}(\\pi_i(\\psi_0)>\\alpha_R)}\n\\end{equation}\n\nwhere I(A)=1 if the event A is true. \nAs a default and to support interpretability of the results, we exclude genes that are not expressed in at least 2 cells per condition from differential variability testing.\n\n\\newpage\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_3.png}\n\\caption[EFDR, FPR and TPR estimation using simulated data]{\\textbf{EFDR, FPR and TPR estimation using simulated data (Full legend on next page).}\\\\\nData was simulated using the BASiCS model with model parameters set by empirical estimates based on 98 microglia cells \\citep{Zeisel2015} \\textbf{(Table \\ref{tab2:datasets})}. \nDifferent samples sizes (40 - 200 cells) were simulated in replicates of 5. \nDifferential testing was performed between 2 simulated datasets of equal size to calculate the false positive rate (FPR, number of detections divided by number of genes tested) and the true positive rate (TPR, number of true positive divided by number of all positives). \nMoreover, we report the expected false discovery rate (EFDR, \\citep{Newton2004}). \nFor each test, the EFDR was controlled to 10\\% and the default minimum tolerance thresholds were used ($\\tau_0 = \\log_2(1.5)$, $\\omega_0 = \\log_2(1.5)$ and $\\psi_0 = 0.41$), \n\\textbf{(A)-(C)} Synthetic datasets generated using the null model (without changes in variability). FPR and EFDR for (A) differential mean expression, (B) differential over-dispersion and (C) differential residual over-dispersion testing using datasets with increasing samples sizes, \n\\textbf{(D)-(E)} Synthetic datasets generated using the alternative model where 1000 genes were randomly selected and their associated over-dispersion parameters were increased or decreased by a $\\log_2$ fold change of 5. \nTPR and EFDR for (D) differential over-dispersion testing and (E) differential residual over-dispersion testing using simulated datasets with increasing samples sizes.}\\label{fig2:EFDR}\n\\end{figure}\n\n\\newpage\n\nTo evaluate the performance of our test we generated synthetic data under a null model (without changes in variability) and an alternative model (with changes in variability). \nAll datasets were generated following the BASiCS model, with parameter values set by empirical posterior estimates based on 98 microglia cells \\citep{Zeisel2015} (see \\textbf{Table \\ref{tab2:datasets}} in \\textbf{Section \\ref{sec2:datasets}}). \nTo simulate data under an alternative model, 1000 genes were randomly selected and their associated $\\delta_i$'s were increased or decreased by a $\\log_2$ fold change of 5. \nIncreasing numbers of cells were simulated to estimate the effect of sample size on differential testing. \nDifferential testing was performed either between data simulated on the same set of parameters (null model) or between data simulated from the original parameters and the altered parameters (alternative model). \nWe report the EFDR \\citep{Newton2004} as well as the \\gls{FPR} for simulations under the null model \\textbf{(Fig.~\\ref{fig2:EFDR}A-C)} and the \\gls{TPR} for simulations under the alternative model \\textbf{(Fig.~\\ref{fig2:EFDR}D and E)}. \\\\\n\nAs specified, the EFDR is controlled at 10\\%. \nFurthermore, the FPR for differential mean expression and differential over-dispersion is consistently smaller than 10\\% and is only slightly higher for differential residual over-dispersion testing. \nSince the data was simulated under the non-regression BASiCS model, the simulated expression variability cannot be controlled in terms of residual over-dispersion parameters $\\epsilon_i$ leading to subtle differences between simulated cell populations. \nThe TPR for differential over-dispersion and differential residual over-dispersion testing increases with increasing sample size and plateaus at 100\\% \\textbf{(Fig.~\\ref{fig2:EFDR})}.\n\n\\subsection{Choice of hyper-parameters} \\label{sec2:hyper-parameters}\n\nAs discussed above, the degrees of freedom $\\eta$, the number of GRBFs  $L$ as well as their hyper-parameters ($m_l$, $h_l$) are set \\emph{a priori}. \nHere, we explain the default values implemented in the extended BASiCS model. \nThese were chosen to achieve a compromise between flexibility of the trend fit and the strength of shrinkage towards the estimated trend. \nFurther discussion on the shrinkage can be found in \\textbf{Section \\ref{sec2:stabilization}}. \\\\ \n\nFirstly, we observed that large values of $L$ can lead to over-fitting but that small values of $L$ can limit the flexibility to capture non-linear relations between $\\log(\\delta_i)$ and $\\log(\\mu_i)$ \\textbf{(Fig.~\\ref{fig2:choice_hyper})}. \nThus, as a parsimonious choice, we selected $L = 10$. Moreover, as in Kapourani \\emph{et al.}, 2016 \\cite{Kapourani2016}, values for $m_l$ were chosen to be equally spaced across the range of $\\log(\\mu_i)$:. \n\n\\begin{equation} m_l = a + (l-1)\\frac{b - a }{L-1}, \\hspace{0.2cm}  l=1,\\ldots, L, \\end{equation} \n\nwhere $a=\\min_{i\\in\\{1,\\ldots,q_0\\}}\\{\\log(\\mu_i)\\}$ and $b=\\max_{i\\in\\{1,\\ldots,q_0\\}}\\{\\log(\\mu_i)\\}$. \nAs $\\mu_i$ values are unknown \\emph{a priori} and change throughout the sampling procedure, $a$ and $b$ are updated every 50 MCMC iterations during the burn-in phase. \nAdditionally, the scale hyper-parameters $h_l$ control the width of the GRBFs and, consequently, the locality of the regression. \nAs a default, we set these as $h_l = c \\times \\Delta m$, where $c$ is a fixed proportionality constant and $\\Delta m$ is the distance between consecutive values of $m_l$. \nIn practice, we observed that the choice of a particular value of $c$ is not critical, as long as narrow kernels ($c<0.5$) are avoided \\textbf{(Fig.~\\ref{fig2:choice_hyper})}. \nAs a default, $c = 1.2$ was chosen. \n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{Fig_4.png}\n\\caption[Effect of regression hyper-parameters on trend fitting]{\\textbf{Effect of regression hyper-parameters on trend fitting.}\\\\\nPosterior estimates of over-dispersion parameters $\\delta_i$ are plotted versus posterior estimates of mean expression parameters $\\mu_i$ on the log-log scale. \nThe extended BASiCS model was used to estimate these parameters using naive CD4\\plus{} T cells from the previous chapter. \nDifferent hyper-parameter combinations were used to fit the model. \nL: number of Gaussian Radial Basis Functions, c: constant multiplier of the scale parameter, $\\eta$: degrees of freedom. \nPurple points indicate genes which are expressed in fewer than 2 cells.}\n\\label{fig2:choice_hyper}\n\\end{figure}\n\n\\newpage\n\nThe degrees of freedom $\\eta$ controls the tails of the distribution for the residual term in equation \\eqref{eq::regression}. \nThis influences the shrinkage towards the global trend and the robustness against outlying observations \\textbf{(Fig.~\\ref{fig2:choice_hyper})}.  \nIf $\\eta \\geq 30$, $\\epsilon_i$ approximately follows a normal distribution for which posterior inference for $\\beta$ is known to be sensitive to outliers. \nInstead, small values of $\\eta$ introduce heavy-tails for $\\epsilon_i$, leading to more robust posterior inference. \nIn principle, $\\eta$ could be estimated within a Bayesian framework. \nHowever, this is problematic as the likelihood function associated to equation \\eqref{eq::regression} can be unbounded \\citep{Fernandez1999}. Here, we opt for a pragmatic approach where the value of $\\eta$ is fixed \\emph{a priori}. \nTo select a reasonable default value, we ran the regression BASiCS model for a grid of possible values of $\\eta$, using the datasets described in \\textbf{Table \\ref{tab2:datasets}} in \\textbf{Section \\ref{sec2:datasets}} (with $L$, $m_l$ and $h_l$ fixed as described above). \nIn all cases, we calculated a Monte Carlo estimate for the log-likelihood associated to equation \\eqref{eq::PoissonBASiCS} as a proxy for goodness-of-fit \\textbf{(Fig.~\\ref{fig2:DoF}A)}. \nWe observed that log-likelihood estimates were consistently the smallest for $\\eta=1$ and that no substantial differences are observed across larger values of $\\eta$. \nThe \\textit{Dictyostelium} data show very similar log-likelihood estimates for all tested $\\eta$.  \nWhen visualising posterior estimates for the variance $\\sigma^2$ of the distribution for the residual term depending on the degrees of freedom chosen, we observe a constant increase plateauing when the distribution reaches the normal distribution at $\\eta=30$ \\textbf{(Fig.~\\ref{fig2:DoF}B)}. \nWe chose $\\eta=5$ to be the default parameter as a compromise between shrinkage and sensitivity to outlying data points. \n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_5.png}\n\\caption[Comparison of model fits for varying degrees of freedom]{\\textbf{Comparison of model fits for varying degrees of freedom.}\\\\\nThe regression BASiCS model was fit to datasets listed in \\textbf{Table \\ref{tab2:datasets}}. \nThese include CA1 pyramidal neurons (CA1, \\citep{Zeisel2015}), pool-and-split RNA 2i medium (PS, \\citep{Grun2014}), mouse embryonic stem cells 2i medium (mESC, \\citep{Grun2014}), \\textit{Dictyostelium} cells at day 0 of differentiation (Dict, \\citep{Antolovic2017}) and naive CD4\\plus{} T cells (CD4, previous chapter). \n\\textbf{(A)} The model was fit using varying degrees of freedom and the log-likelihood was calculated as stated in equation \\eqref{eq::loglik}. The log-likelihood was scaled between the highest and lowest value for each dataset. \n\\textbf{(B)} Posterior estimates of the variance parameter $\\sigma^2$ depending on the number of degrees of freedom.}\n\\label{fig2:DoF}\n\\end{figure}\n\n%Based on these observations, default values implemented in the BASiCS software are set to $L=10, c=1.2, \\eta=5$. Despite this, the model's implementation also allows flexible adjustment of $L$, $c$ and $\\eta$ by the user. \n\n\\section{Pre-processing of scRNA-Seq data used in this chapter} \\label{sec2:datasets}\n\nWe employed a range of different datasets to test the proposed methodology. \nThese datasets were selected to cover different experimental techniques (with and without UMIs) and to encompass a variety of cell types. \nMoreover, key features of each dataset can be found in \\textbf{Table \\ref{tab2:datasets}}. \n\n\\begin{table}[ht\t]\n\\centering\n\\caption[Datasets used for model testing and analysis]{\\textbf{Datasets used for model testing and analysis.} \\\\\nFor each of the datasets analysed in this study: number of cells (2$^\\text{nd}$ column), number of genes (biological + technical spike-ins, 3$^{rd}$ column), number of batches (4$^\\text{th}$ column), type of data acquisition system (5$^\\text{th}$ column), information on whether the data was generated using unique molecular identifiers (UMIs, 6$^\\text{th}$ column) and the reference to the original study (7$^\\text{th}$ column) are provided.}\n\\label{tab2:datasets}\n\\begin{tabular}{lllllll}\n\\toprule\n\\textbf{Dataset} & \\textbf{\\# cells} & \\textbf{\\# genes} & \\textbf{\\# batches} & \\textbf{Protocol} & \\textbf{UMIs} & \\textbf{Ref.}                       \\\\\n\\midrule\nYoung naive  & 93       & 10,553    & 2          & Fluidigm C1       & No   & \\citep{Martinez-jimenez2017} \\\\\nCD4\\plus{} T cells   &        &   &          &       & No   &  \\\\\n\\midrule\n\nYoung active    & 53       & 10,553    & 2          & Fluidigm C1       & No   & \\citep{Martinez-jimenez2017} \\\\\nCD4\\plus{} T cells    &        &     &           &        &    &  \\\\\n\\midrule\n\nMicroglia cells                         & 98       & 10,687    & 1          & Fluidigm C1       & Yes  & \\citep{Zeisel2015}           \\\\\n\\midrule\n\nCA1 pyramidal                    & 948      & 10,687    & 1          & Fluidigm C1       & Yes  & \\citep{Zeisel2015}           \\\\\nneurons       &       &     &           &       &   &           \\\\\n\\midrule\n\nMalaria infected     & 89       & 7899     & 2          & Fluidigm C1       & No   & \\citep{Lonnberg2017}         \\\\\nCD4\\plus{} T cells day 2     &        &      &          &  &    &  \\\\\n\\midrule\n\nMalaria infected  & 133      & 7899     & 2          & Fluidigm C1       & No   & \\citep{Lonnberg2017}         \\\\\nCD4\\plus{} T cells day 4     &       &      &    &  &    &\\\\\n\\midrule\n\nMalaria infected  & 64       & 7899     & 1          & Fluidigm C1       & No   & \\citep{Lonnberg2017}         \\\\\nCD4\\plus{}  T cells day 7    &   & &  &  &  &   \\\\\n\\midrule\n\n\\textit{Dictyostelium}             & 131      & 10,738    & 3          & Fluidigm C1       & No   & \\citep{Antolovic2017}        \\\\\ncells day 0  &  &   &   &  & & \\\\\n\\midrule\n\nPool-split RNA                 & 76       & 8924     & 2          & CEL-Seq           & Yes  & \\citep{Grun2014}            \\\\\n2i medium  &  &  & &  &  & \\\\\n\\midrule\n\nmESC 2i medium    & 74       & 8924     & 2          & CEL-Seq           & Yes  & \\citep{Grun2014} \\\\\n\\midrule\n\nPool-split RNA             & 56       & 8924     & 2          & CEL-Seq           & Yes  & \\citep{Grun2014}            \\\\\nserum medium &  &      &         &   &   &  \\\\\n\\midrule\n\nmECS serum medium & 52       & 8924     & 2          & CEL-Seq           & Yes  & \\citep{Grun2014} \\\\\n\\bottomrule       \n\\end{tabular}\n\\end{table}\n\\addcontentsline{lot}{table}{\\ref{tab2:datasets} \\hspace{2.5mm} Datasets used for model testing and analysis.}\n\n\\subsection{\\textit{Dictyostelium} cells} \\label{seq::data_dict}\n\nAntolovi\\'{c} \\emph{et al.}, 2017 studied changes in expression variability between 0 hours (undifferentiated), 3 hours and 6 hours of \\emph{Dictyostelium} differentiation \\cite{Antolovic2017}. \nRaw data is available by direct download (see Data S1 in \\citep{Antolovic2017}). \nAcross all time points, 5 cells were removed due to low quality. Technical spike-in genes that were not detected and biological genes with an average expression (across all cells) smaller than 1 count were removed. \nIn total, 433 cells (131 cells in 3 batches at 0h, 157 cells in 3 batches at 3h, and 145 cells in 3 batches at 6h) and 10,551 genes (88 technical and 10,650 biological genes) passed filtering. \nWe used data from the 0h time point to test the functionality of our model.\n\n\\subsection{Mouse brain cells} \\label{seq::data_micro}\n\nThis dataset was composed of UMI scRNA-Seq data of cells isolated from the mouse somatosensory cortex and hippocampal CA1 region \\citep{Zeisel2015}. \nRaw data is available from Gene Expression Omnibus under accession code GSE60361. Prior to the analysis, we removed technical genes with 0 total counts and biological genes for which the average count across all 3007 cells was below 0.1. \nThe groups comprising microglia cells and CA1 neurons were chosen for analysis to include cell populations comprising a small and large number of cells. \nFor these groups, 98 cells (microglia), 939 cells (CA1 pyramidal neurons) and 10,744 genes (10,687 biological and 57 technical genes) passed filtering.\n\n\\subsection{Pool-and-split RNAseq data} \\label{seq::data_PaS}\n\nThis UMI-based dataset provides a control experiment to assess changes in biological heterogeneity in a situation where mean expression remains unchanged across conditions. \nPool-and-split samples were created by pooling 1 million mESCs grown in 2i or serum medium and splitting 20pg of RNA into aliquots. \nThese libraries are compared against single-cell samples (mESCs) \\citep{Grun2014}. \nRaw data is available from Gene Expression Omnibus under accession code GSE54695. \\\\\n\nAs in Gr\\\"un \\emph{et al.}, 2014 \\cite{Grun2014}, some cells were removed from the analysis due to low expression of the stem cell marker \\textit{Oct4}. \nTechnical genes with 0 total counts were also removed from the analysis. Additionally, lowly expressed biological genes with fewer than 0.5 counts (on average, across all samples) were excluded. \nThis left 258 libraries (74 single mESCs grown in 2i medium, 52 single mESCs grown in serum medium, 76 pool-and-split aliquots from cells grown in 2i medium and 56 pool-and-split aliquots from cells grown in serum medium) as well as 8924 genes (50 technical spike-ins and 8874 biological genes) for the analysis. \nEach condition contained 2 batches.\\\\\n\nMatched smFISH data from mESCs grown in 2i and serum media were obtained from Dominic Gr\\\"un (Max Planck Institute of Immunobiology and Epigenetics, Freiburg, Germany) through personal communications. This smFISH experiment assayed 9 genes (\\textit{Gli1}, \\textit{Klf4}, \\textit{Notch1}, \\textit{Pcna}, \\textit{Pou5f1}, \\textit{Sohlh2}, \\textit{Sox2}, \\textit{Stag3}, \\textit{Tpx2}) in more than 70 cells per condition. %We excluded \\textit{Notch1} from the analysis due to strong disagreement between smFISH and scRNA-Seq data of cells grown in serum medium.\n\n\\subsection{CD4\\plus{} T cell activation} \\label{seq::data_cd4}\n\nNon-UMI scRNA-Seq data of CD4\\plus{} T cells represent data analysed in  the previous chapter. \nRaw data is available from ArrayExpress under accession code E-MTAB-4888. To perform a variety of tests, naive and activated CD4\\plus{} T cells from young \\emph{Mus musculus} (B6) mice were selected. \nBiological genes with an average count $<~1$ and non-detected technical genes were removed from the analysis. \nIn total, 146 cells (93 naive and 53 activated CD4\\plus{} T cells) and 10,553 genes (10,495 biological and 58 technical genes) passed filtering. Each condition contains 2 replicates.\n\n\\subsection{CD4\\plus{} T cell differentiation} \\label{seq::data_cd4diff}\n\nNon-UMI scRNA-Seq data were generated from CD4\\plus{} T cells during differentiation towards Th1 and Tfh cell fates after \\emph{Plasmodium} infection \\citep{Lonnberg2017}. \nRaw reads were downloaded from ArrayExpress [E-MTAB-4388] and mapped against the \\emph{Mus musculus} genome (GRCm38) using \\emph{gsnap} \\citep{Wu2010a} with default settings. \nRead counting was performed using \\emph{HTSeq} \\citep{Anders2014} with default settings. \\\\\n\nQuality control was performed by removing cells with fewer than 300,000 biological reads or fewer than 600,000 technical reads at day 2. \nAt days 4 and 7, cells with fewer than 1,000,000 biological reads were excluded from downstream analysis. \nAdditionally, we removed genes that did not show an average detection of more than 1 read at day 2, day 3, day 4 or day 7 after infection. \nAfter applying these criteria, 376 cells (Day 0: 16 cells, Day 2: 89, Day 3: 21, Day 4: 133, Day 7: 64, Day 7 non-infected: 53) and 7899 genes (7847 biological and 52 technical) remained for analysis. \nNote that, due to low sample sizes, we focused our analysis on data from day 2, day 4 and day 7 post-infection.\n\n\\newpage\n\n\n\\section{The informative prior stabilises parameter estimation}\n\\label{sec2:stabilization}\n\nOur joint prior formulation induces a non-linear regression that captures the overall trend between gene-specific over-dispersion parameters $\\delta_i$ and mean expression parameters $\\mu_i$. \nThus, we also refer to the extended model induced by this prior as the \\textit{regression} BASiCS model. \nAccordingly, the model induced by the original independent prior specification \\citep{Vallejos2016} is referred to as the \\textit{non-regression} BASiCS model. \n\n\\subsection{Dataset specificity of the regression trend}\n\nTo study the performance of the regression BASiCS model, we applied both the regression and non-regression BASiCS model to a variety of scRNA-Seq datasets. \nEach dataset is unique in its composition, covering a range of different cell types and experimental protocols (see \\textbf{Section \\ref{sec2:datasets}} and \\textbf{Table \\ref{tab2:datasets}}). \nQualitatively, we observe that the inferred regression trend varies substantially across different datasets \\textbf{(Fig.~\\ref{fig2:datasets})}, justifying the choice of a flexible semi-parametric approach (see \\textbf{Section \\ref{sec2:extended_BASiCS}} and \\textbf{Section \\ref{sec2:hyper-parameters}}). \nMoreover, as expected, we observe that residual over-dispersion parameters $\\epsilon_i$ are not confounded by mean expression. \nAdditionally, we assessed whether the residual over-dispersion parameter is biased by the percentage of zero counts per gene \\textbf{(Fig.~\\ref{fig2:datasets}, fourth column)}. \nThis feature increases for lowly expressed genes due to technical expression drop-outs. \nNevertheless, posterior estimates of gene-specific residual over-dispersion parameters are not confounded by the percentage of zero counts per gene \\textbf{(Fig.~\\ref{fig2:datasets})}. \\\\\n\nNext, we observed that the regression BASiCS model shrinks the posterior estimates for $\\mu_i$ and $\\delta_i$ towards the regression trend. \nThis is due to the joint prior specification on $(\\mu_i,\\delta_i)'$ and is consistent with the shrinkage observed in Love \\emph{et al.}, 2014 \\citep{Love2014}. \nThe strength of this shrinkage is dataset-specific, being more prominent in sparser datasets with a higher frequency of zero counts and for lowly-expressed genes where measurement error is greatest \\textbf{(Fig.~\\ref{fig2:datasets}A)}. \n\n\\newpage\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.95\\textwidth]{Fig_6.png}\n\\caption[Parameter estimation using a variety of scRNA-Seq datasets]{\\textbf{Parameter estimation using a variety of scRNA-Seq datasets.}\\\\\nModel parameters were estimated using the regression and non-regression BASiCS models on \\textbf{(A)} naive CD4\\plus{} T cells \\citep{Martinez-jimenez2017}, \\textbf{(B)} \\textit{Dictyostelium} cells prior to differentiation (day 0) \\citep{Antolovic2017}, \\textbf{(C)} microglia cells \\citep{Zeisel2015} and \\textbf{(D)} pool-and-split RNA \\citep{Grun2014}. \nThese datasets were selected to highlight situations with different levels of sparsity (i.e.~the proportion of zero counts, see fourth column). \nThe colour code within the scatterplots is used to represent areas with high (yellow/red) and low (blue) density of genes. \n\\textbf{First column:} gene-specific over-dispersion $\\delta_i$ versus mean expression $\\mu_i$ as estimated by the non-regression BASiCS model. \n\\textbf{Second column:} gene-specific over-dispersion $\\delta_i$ versus mean expression $\\mu_i$ as estimated by the regression BASiCS model. \nThe red line indicates the estimated regression trend. \nPurple dots indicate genes detected (i.e.~with at least one count) in less than 2 cells. \n\\textbf{Third column:} gene-specific residual over-dispersion $\\epsilon_i$ versus mean expression $\\mu_i$ as estimated by the regression BASiCS model. \n\\textbf{Forth column:} gene-specific posterior estimates for residual over-dispersion $\\epsilon_i$ parameters versus percentage of zero counts for each gene.\\\\}\n\\label{fig2:datasets}\n\\end{figure}\n\n\\newpage\n\n\\subsection{Stabilisation of posterior inference}\n\\label{sec2:parameter_stabilization}\n\nNext, we asked whether or not the shrinkage introduced by the regression BASiCS model improves posterior inference. \nTo assess this, we compared estimates for gene-specific parameters across (i) different sample sizes and (ii) different gene expression levels. \nBoth the sample size and the level of expression influence posterior estimation of model parameters due to loss of power when few cells are used to estimate parameters for lowly expressed genes. \nMore concretely, we used a large dataset containing 939 CA1 pyramidal neurons \\citep{Zeisel2015} (\\textbf{Section \\ref{seq::data_micro}}) to artificially generate smaller datasets by randomly sub-sampling 50-500 cells. \nFor each sample size, parameter estimates were then obtained using both the regression and non-regression BASiCS models. \nBased on parameter estimates using the non-regression model, we split the genes into three sets: lowly expressed ($\\mu_i<1.89$), medium expressed ($1.89<\\mu_i<5.37$) and highly expressed ($\\mu_i>5.37$). \nThese cut-off values were chosen such that roughly a third of genes were assigned to each category. \nThe distribution of these estimates is summarised in \\textbf{Fig.~\\ref{fig2:parameter_stabilization}}. \\\\\n\nFirstly, we observe that both the regression and non-regression BASiCS models led to consistent and largely stable mean expression estimates $\\mu_i$ across different sample sizes and expression levels \\textbf{(Fig.~\\ref{fig2:parameter_stabilization}A)}. \nSecondly, in line with the results in \\textbf{Fig.~\\ref{fig2:datasets}}, the main differences between the methods arise when estimating the over-dispersion parameters $\\delta_i$ \\textbf{(Fig.~\\ref{fig2:parameter_stabilization}B)}. \nIn particular, we observe that the non-regression BASiCS model appears to underestimate $\\delta_i$ for lowly expressed genes when the sample size is small (with respect to the parameter estimates obtained based on the full dataset of 939 cells). \nThis is due to the original, non-informative prior: $\\delta_i\\sim\\textnormal{log-N}(0,a_\\delta^2)$. \nIn the case of lowly expressed genes, the data is not informative and the over-dispersion parameters are estimated as $\\delta_i\\approx{}0$. In contrast, the shrinkage introduced by our regression BASiCS model aids parameter estimation, leading to robust estimates even for the smallest sample size. \nThis is particularly important for rare cell populations where large sample sizes are difficult to obtain. \nA similar effect is observed for genes with medium and high expression levels, where the non-regression BASiCS model appears to slightly overestimate $\\delta_i$. \nWe also observe that estimates of residual over-dispersion parameters $\\epsilon_i$ are stable across sample sizes and expression levels. \\textbf{Fig.~\\ref{fig2:parameter_stabilization2}A-C} summarises 10 replicates of the down-sampling experiment performed in \\textbf{Fig.~\\ref{fig2:parameter_stabilization}A-C}. \nWe use parameters estimated from the full dataset as \\gls{pgt} values. \nFor each sub-sampling experiment, sample size and gene set, we computed the median $\\log_2$ fold change in $\\mu_i$ and $\\delta_i$ and the median difference for $\\epsilon_i$ between the estimates and the \\gls{pgt}. \nThe median and the range of these values across 10 sub-sampling experiments is used for visualisation purposes \\textbf{(Fig.~\\ref{fig2:parameter_stabilization2}A-C)}. \n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.9\\textwidth]{Fig_7.png}\n\\caption[Estimation of gene-specific model parameters for varying sample sizes]{\\textbf{Estimation of gene-specific model parameters for varying sample sizes.}\\\\\nThe regression (orange) and non-regression (blue) BASiCS models were used to estimate gene-specific model parameters for lowly (lower panels), medium (mid panels) and highly (upper panels) expressed genes across populations with varying numbers of cells. \nThese were generated by randomly sub-sampling cells from a population of 939 CA1 pyramidal neurons \\citep{Zeisel2015}. \nExtended results based on multiple downsampling experiments are displayed in \\textbf{Fig.~\\ref{fig2:parameter_stabilization2}A-C}. \n\\textbf{(A-C)} For a single sub-sampling experiment, boxplots summarise the distribution of gene-specific estimates for (A) mean expression parameters $\\mu_i$ (log-scale), (B) over-dispersion parameters $\\delta_i$ (log-scale) and (C) residual over-dispersion parameters $\\epsilon_i$. \n\\textbf{(D-F)} For 10 sub-sampling experiments, parameter estimates were compared against a \\textit{pseudo} ground truth (pgt). \nThe latter is defined as the parameter estimates obtained for the full population of 939 cells using the regression BASiCS model. \nFor each sub-sampling experiment, gene-specific log$_2$ fold changes ($\\log_2(\\mu_i/\\mu_{i,pgt})$ and $\\log_2(\\delta_i/\\delta_{i,pgt})$) and distances ($\\epsilon_i - \\epsilon_{i,pgt}$) between the estimates and the pgt were computed. \nFor visualisation purposes, the medians across genes for each sub-sampling experiment are presented,}\n\\label{fig2:parameter_stabilization}\n\\end{figure}\n\n\\subsection{Validation of gene-specific posterior estimates by smFISH}\n\nAs an external validation, we compared our posterior estimates of gene-specific model parameters obtained from scRNA-Seq data to empirical estimates from matched smFISH data of mouse embryonic stem cells grown in 2i and serum media \\citep{Grun2014}. \nFirstly, posterior estimates of mean-expression parameters $\\mu_i$ exhibit high correlation to smFISH mean transcript counts \\textbf{(Fig.~\\ref{fig2:parameter_stabilization2}D)}. \nSecondly, we also observe a strong correlation between posterior estimates for over-dispersion parameters $\\delta_i$ and the empirical CV$^2$ values obtained from smFISH data \\textbf{(Fig.\\ref{fig2:parameter_stabilization2}E)}. \nFinally, a similar behaviour is observed when comparing posterior estimates of residual over-dispersion parameters $\\epsilon_i$ to a residual CV$^2$ \\textbf{(Fig.\\ref{fig2:parameter_stabilization2}F)}. \nAs in Brennecke \\emph{et al.}, 2013 \\cite{Brennecke2013}, to obtain residual CV$^2$ values for the smFISH data, we fitted a gamma generalised linear model with identity link (\\textit{glmgam.fit} of the \\textit{statmod} package in R) between the CV$^2$ and the reciprocal log-transformed mean transcript counts.\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.9\\textwidth]{Fig_8.png}\n\\caption[Stability of posterior estimates for gene-specific parameters]{\\textbf{Stability of posterior estimates for gene-specific parameters.}\\\\\n\\textbf{(A-C)} Matched scRNA-Seq and smFISH data measured on mouse embryonic stem cells grown in 2i and serum media \\citep{Grun2014} was used to validate the performance of the regression BASiCS model. \nGene-specific parameter estimates obtained by the regression BASiCS model were compared against empirical estimates calculated based on smFISH data. \nThis comparison includes 8 genes, measured in both conditions. Pearson's correlation is indicated for each comparison, \n\\textbf{(D)} Estimates of mean expression parameters $\\mu_i$ (log-scale) are plotted against mean transcript count (smFISH), \n\\textbf{(E)} Estimates of over-dispersion parameters $\\delta_i$ (log-scale) are plotted against the squared coefficient of variation (CV$^2$) of transcript counts (smFISH), \n\\textbf{(F)} Estimates for residual over-dispersion parameters $\\epsilon_i$ are compared against residual estimates of variability estimated for the smFISH data.}\n\\label{fig2:parameter_stabilization2}\n\\end{figure}\n\n\\newpage\n\n\\section{Expression variability during immune responses}\n\nHere, we illustrate how the regression BASiCS model assesses changes in expression variability using CD4\\plus{} T cell activation and differentiation. \nFor all datasets, pre-processing steps are described in \\textbf{Section \\ref{sec2:datasets}}. \n\n\\subsection{Testing variability changes upon immune activation}\n\\label{sec2:immune_activation}\n\nAs described in the previous chapter, the non-regression BASiCS model only allows the assessment of changes in variability for genes that remain stable in gene expression across conditions. \nHere, we extend the previous analysis and test for changes in variability in parallel to changes in mean expression. \\\\\n\nTo identify gene expression changes during early T cell activation, we compared CD4\\plus{} T cells before (naive) and after (active) 3 hours of stimulation with CD28 and CD3\\textepsilon{} antibodies (see \\textbf{Section \\ref{sec1:activation}} and \\citep{Martinez-jimenez2017}). \nFor both conditions, we ran the regression BASiCS model independently and performed differential mean expression and differential variability testing using the residual over-dispersion parameters. \nTesting changes in variability through residual over-dispersion is performed across all genes, including the large set of genes that are up-regulated upon immune activation \\textbf{(Fig.~\\ref{fig1:immune_activation})}. \nThe latter include immune-response genes and critical drivers for CD4\\plus{} T cell functionality that had to be excluded from analysis in the previous chapter.\n\n\\subsubsection{Comparison between the regression and non-regression BASiCS model}\n\nFirstly, we compared the results obtained by the regression BASiCS model to those presented in \\textbf{Section \\ref{sec1:activation}}.  \nTo allow for a direct comparison of the results, the same inclusion criteria as in the previous chapter is adopted, i.e.~we excluded genes with low mean expression ($\\mu_i<50$) in both conditions from testing. \nMoreover, the minimum tolerance thresholds were also adapted to match the choices in \\textbf{Section \\ref{sec1:activation}}. \nTo detect differentially expressed genes, a minimum tolerance threshold $\\tau_0 = 2$ was used \\textbf{(Fig.~\\ref{fig2:model_comparison}A)}. \nTo compare the detection of differentially over-dispersed genes, we performed differential mean expression testing using a stringent minimum tolerance threshold $\\tau_0 = 0$ for both models (this is to avoid the results being confounded by changes in mean, see upper panel in \\textbf{Fig.~\\ref{fig2:model_comparison}B}). \nFor the 463 genes that are detected as non-differentially expressed by both models for this threshold, a total of 111 genes are detected as differentially over-dispersed by either model (minimum tolerance log$_2$ fold change threshold $\\omega_0 = \\log_2(1.5) = 0.58$). \nOut of this set, 93 genes ($\\sim$83\\%) are detected as differentially over-dispersed by both models (see lower panel in \\textbf{Fig.~\\ref{fig2:model_comparison}B}).\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_9.png}\n\\caption[Differential testing results of the two BASiCS models]{\\textbf{Differential testing comparison between the regression and non-regression BASiCS model.}\\\\\n\\textbf{(A)-(B)} Results of differential testing between naive and activated CD4\\plus{} T cells were compared between the regression and non-regression BASiCS models. \nAs in \\textbf{Section \\ref{sec1:activation}}, genes with low mean expression ($\\mu_i<50$) in both conditions were excluded from testing. \\textbf{(A)} Overlap of differentially expressed genes (mean) using a minimum tolerance threshold $\\tau_0=2$ obtained by the regression and non-regression BASiCS models (EFDR = 10\\%), \n\\textbf{(B)} Upper panel: overlap of genes detected as non-differentially expressed using a stringent minimum tolerance threshold $\\tau_0=0$ obtained by the regression and non-regression BASiCS models (EFDR = 10\\%). \nLower panel: overlap of differentially over-dispersed genes using a minimum tolerance threshold $\\omega_0=\\log_2(1.5)$ obtained using the regression and non-regression  BASiCS models for the 463 genes detected as non-differentially expressed by both models (EFDR = 10\\%).}\n\\label{fig2:model_comparison}\n\\end{figure}\n\n\\subsubsection{Differential testing during immune activation}\n\nFor further analyses in this chapter (and in contrast to the previous chapter), we exclude genes whose estimated mean expression parameter $\\mu_i$ was below 1 from the differential testing. \nFurthermore, a $\\log_2$ fold change threshold $\\tau_0 = 1$ was adopted for mean expression testing. \nUnlike the more stringent threshold used in the previous chapter ($\\tau_0 = 2$), this choice allows us to detect more subtle changes in mean expression. \nMoreover, the default threshold $\\psi_0 = 0.41$ was used for differential variability testing. \nThe EFDR was controlled to 10\\%. By using these thresholds, our model classifies genes into four categories based on their expression dynamics: down-regulated upon activation with (i) lower and (ii) higher variability, and up-regulated with (iii) lower and (iv) higher variability \\textbf{(Fig.~\\ref{fig2:immune_activation}A)}. \\\\\n\nGenes with up-regulated expression upon activation and decreased expression variability encode components of the splicing machinery (e.g.~\\textit{Sf3a3}, \\textit{Plrg1}), RNA polymerase subunits (e.g.~\\textit{Polr2l}, \\textit{Polr1d}) as well as translation machinery components (e.g.~\\textit{Ncl}, \\textit{Naf1}) (see \\textbf{Fig.~\\ref{fig2:immune_activation}B}). \nThese biosynthetic processes help naive T cells to rapidly enter a programme of proliferation and effector molecule synthesis \\citep{Tan2017,Araki2017}. \nTherefore, rapid and uniform up-regulation of these transcripts would assist such processes. \nThis observation also confirms our previous findings that the translational machinery is tightly regulated during early immune activation (see \\textbf{Section \\ref{sec1:activation}}).\\\\\n\nIn contrast, genes with up-regulated expression and increased expression variability (see \\textbf{Fig.~\\ref{fig2:immune_activation}C}) include the death-inducing and inhibitory transmembrane ligands \\gls{Fasl} and \\gls{PDL1} (gene symbol: \\textit{Cd274}), the regulatory transcription factor Smad3 (\\textit{Smad3}), and the TCR-induced transcription factor, Oct2 (\\textit{Pou2f2}). \nAdditionally, we detect a heterogeneous up-regulation in the mRNA expression of the autocrine/paracrine growth factor Il2 (\\textit{Il2}) upon immune activation. \nThis is in line with previous reports of binary Il2 expression within a population of activated T cells, which has been suggested to be necessary for a scalable antigen response \\citep{Fuhrmann2016}. \nHeterogeneity in expression of these genes suggests that, despite their uniform up-regulation of biosynthetic machinery, the T cells in this early activation culture represent a mixed population with varying degrees of activation and/or regulatory potential. \\\\\n\nFor each of these gene sets, functional annotation analysis was performed using all tested genes as background. \nThe functional annotation clustering tool in DAVID \\citep{Dennis2003} was used to cluster annotation categories based on similarity and sort them according to their enrichment score. \nHere, we list the top 3 functional annotation clusters per gene set and their corresponding enrichment score (ES):\n\\begin{itemize}\n\\item \\textbf{Down-regulated with lower variability:} Pleckstrin homology domain (ES = 1.57), G protein signalling (ES = 1.51), glycosidase (ES = 1.49),\n\\item \\textbf{Down-regulated with higher variability:} Ankyrin repeat-containing domain (ES = 2.19), GTPase mediated signalling (ES = 1.51), steroid biosynthesis (ES = 0.89), \n\\item \\textbf{Up-regulated with lower variability:} RNA polymerase (ES = 1.6), RNA binding (ES = 1.53), splicing (ES = 1.41),\n\\item \\textbf{Up-regulated with higher variability:} Cytokine-cytokine receptor interaction (ES = 1.65), WD40 repeat (ES = 1.22), transcription (ES = 1.18).\n\\end{itemize}\n\n\\newpage\n\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{Fig_10.png}\n\\caption[Changes in expression patterns during early immune activation]{\\textbf{Changes in expression patterns during early immune activation.}\\\\\nDifferential testing (mean and residual over-dispersion) was performed between naive and activated murine CD4\\plus{} T cells taken from the previous chapter. \nThis analysis uses a minimum tolerance threshold of $\\tau_0=1$ for changes in mean expression and a minimum tolerance threshold of $\\psi_0=0.41$ for differential residual over-dispersion testing (expected false discovery rate is fixed at 10\\%). \n\\textbf{(A)} For each gene, the difference in residual over-dispersion estimates (Active - Naive) is plotted versus the log$_2$ fold change in mean expression (Active/Naive). \nGenes with statistically significant changes in mean expression and variability are coloured based on their regulation (up/down-regulated, higher/lower variability), \n\\textbf{(B-C)} Normalised expression counts across the naive (purple) and active (green) CD4\\plus{} T cell population are visualised for representative genes that (B) increase in mean expression and decrease in expression variability and (C) increase in mean expression as well as expression variability  upon immune activation. \nEach dot represents a single cell.}\n\\label{fig2:immune_activation}\n\\end{figure}\n\n\\newpage\n\n\\subsubsection{Effect of expression outliers on changes in variability}\n\nWe observe that for some genes (e.g.~\\textit{Plrg1}), changes in variability are driven by a small number of outlier cells with high expression. \nThe interpretation of these results is not trivial as it could reflect very subtle sub-structure or genuine changes in variability. \nTo explore this, we performed the following synthetic experiment: We artificially created a mixed population of cells by combining 5 activated CD4\\plus{} T cells with a population of 93 naive CD4\\plus{} T cells therefore simulating expression outliers. \nSubsequently, we performed a differential testing (mean and residual over-dispersion) between this mixed population and a \\textit{pure} population of 93 naive CD4\\plus{} T cells. \nAs expected, this analysis shows an overall increase in variability in the mixed population. \nFor example, among the genes that exhibit higher mean expression and higher residual over-dispersion in the mixed population, we found \\textit{Il2} which is up-regulated upon CD4\\plus{} T cell activation \\textbf{(Fig.~\\ref{fig2:mixture_population}A)}. \nMoreover, we observe that the genes in this category are enriched for those that are only expressed in the 5 activated CD4\\plus{} T cells \\textbf{(Fig.~\\ref{fig2:mixture_population}B)}. \nThis result suggests that differential variability testing can potentially uncover markers for heterogeneous cell states or cell types that can provide important biological insights. \nHowever, changes in residual over-dispersion that are driven by outliers can also reflect unwanted contamination (e.g.~mixed cell types), hence careful data filtering and clustering analysis should be performed prior to differential variability testing. \n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_11.png}\n\\caption[Dissecting changes in variability driven by expression outliers]{\\textbf{Dissecting changes in variability driven by expression outliers.}\\\\\n5 activated CD4\\plus{} T cells were combined with a population of 93 naive CD4\\plus{} T cells. \n\\textbf{(A)} Distribution of normalised expression counts for \\textit{Il2} in a population of naive CD4\\plus{} T cells (red) and the mixture population representing a mix of 93 naive and 5 activated CD4\\plus{} T cells (blue). \nEach dot represents a single cell, \\textbf{(B)} Genes with increased mean expression and increased variability in the mixed population were detected. \nThe heatmap shows normalised expression counts for these genes across the mixed population (93 naive and 5 activated CD4\\plus{} T cells).}\n\\label{fig2:mixture_population}\n\\end{figure}\n\n\\newpage\n\nIn summary, our approach allows us to extend the findings from the previous chapter, dissecting immune-response genes into two functional sets: (i) homogeneous up-regulation of biosynthetic machinery components and (ii) heterogeneous up-regulation of several immunoregulatory genes.\n\n\\subsection{Expression dynamics during \\textit{in vivo} CD4\\plus{} T cell differentiation}\n\nIn contrast to the quick transcriptional switch that occurs within hours of naive T cell activation, transcriptional changes during cellular differentiation processes are more subtle and were found to be coupled with changes in variability prior to cell fate decisions \\citep{Richard2016, Mojtahedi2016}. \nHere, we apply our method to study changes in expression variability during CD4\\plus{} T cell differentiation after malaria infection using the dataset introduced by L\\\"onnberg \\emph{et al.}, 2017 \\cite{Lonnberg2017}. \nIn particular, we focus on samples collected 2, 4 and 7 days post-malaria infection, for which more than 50 cells are available. \nThe BASiCS model was run for 40,000 iterations independently for each condition.\n\n\\subsubsection{Changes in variability over the differentiation time course}\n\nFirst, we studied global changes in over-dispersion along the differentiation time course by comparing posterior estimates for the gene-specific over-dispersion parameter $\\delta_i$, focusing on 126 genes for which mean expression does not change \\textbf{(Fig.~\\ref{fig2:immune_differentiation}A)}. \nThese genes were detected by testing changes in mean expression using a stringent threshold ($\\tau_0=0$) between day 2 and day 4 as well as between day 4 and day 7. \nGenes that are not detected as differentially expressed in both tests were considered for variability analysis. \nWe found that the expression of these genes is most tightly regulated at day 4, when cells are in a highly proliferative state. \nMoreover, between day 4 and day 7, the cell population becomes more heterogeneous. \nThis is in line with the emergence of differentiated Th1 and Tfh cells that was observed by L\\\"onnberg \\emph{et al.}, 2017. \\\\\n\nNext, we exploited the residual over-dispersion parameters to identify changes in variability (irrespective of changes in mean expression) between consecutive time points. \nFor this, we performed differential variability testing using the default threshold on changes in the residual over-dispersion parameter ($\\psi_0 = 0.41$) between day 2 and day 4 as well as between day 4 and day 7. \nAfter testing, we excluded all genes that are expressed in fewer than 2 cells in at least one time point from down-stream analysis. \nSeparating the remaining genes by whether their variability increases or decreases between time points revealed four different patterns \\textbf{(Fig.~\\ref{fig2:immune_differentiation}B)}. \nThese include genes whose variability systematically increases (or decreases) as well as patterns where variability is highest (or lowest) at day 4. \n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_12.png}\n\\caption[Dynamics of expression variability throughout CD4\\plus{} T cell differentiation]{\\textbf{Dynamics of expression variability throughout CD4\\plus{} T cell differentiation.}\\\\\nAnalysis was performed on CD4\\plus{} T cells assayed 2 days, 4 days and 7 days after \\textit{Plasmodium} infection. \nChanges in residual over-dispersion were tested using a minimum tolerance threshold of $\\psi_0=0.41$ (EFDR is fixed at 10\\%), \n\\textbf{(A)} Distribution of posterior estimates of over-dispersion parameters $\\delta_i$ for genes that exhibit no changes in mean expression across the differentiation time course. \nChanges in mean expression were tested using a minimum tolerance threshold of $\\tau_0=0$ (expected false discovery rate is fixed at 10\\%), \n\\textbf{(B)} Posterior estimates for residual over-dispersion parameters  $\\epsilon_i$, focusing on genes with statistically significant changes in expression variability between time points. \nGene set size is indicated for each plot, \n\\textbf{(C-D)} Normalised expression counts across cell populations at day 2 (yellow) and day 4 (red) post infection are visualised for representative genes that (C) increase or (D) decrease in variability during differentiation. \nEach dot represents a single cell.\\\\}\n\\label{fig2:immune_differentiation}\n\\end{figure}\n\n\\subsubsection{Opposing expression dynamics of lineage-defining marker genes}\n\nThe differential variability analysis between day 2 and day 4, revealed  changes in expression variability for a set of immune-related genes \\textbf{(Fig.~\\ref{fig2:immune_differentiation}C-D)}. \nFor example, expression of \\gls{Cxcr5} which encodes the chemokine receptor that directs Tfh cells to the B cell follicles \\citep{Crotty2014}, strongly increases in variability on day 4. \nThis finding agrees with results from L\\\"onnberg \\emph{et al.}, 2017 \\citep{Lonnberg2017}, where Tfh and Th1 differentiation was observed to be transcriptionally detectable at day 4 within a subset of activated cells. \nA similar behaviour was observed for \\gls{Tyk2} and \\gls{Tigit}. The latter encodes a receptor that is expressed by a subset of Tfh cells and that was found to promote Tfh function \\citep{Godefroy2015}. \nIn contrast, we observe a decrease in variability between day 2 and day 4 for \\gls{Ikzf4} (Treg-associated gene), \\textit{Ly6c1} (expressed by effector T cells) and \\textit{Tbx21} (encoding the Th1 lineage-defining transcription factor Tbet). \\\\\n\nTo achieve a broader view on changes in variability within sets of genes that drive this differentiation process, we selected gene sets listed in L\\\"onnberg \\emph{et al.}, 2017 to visualise their changes in mean expression and residual over-dispersion \\citep{Lonnberg2017}. \nThe first set of genes is taken from Figure 3E of the original publication, which filtered genes based on their association with the bifurcation of Th1 and Tfh differentiation. \nThe second set of genes with sequential peak expression over pseudo-time is taken from Figure 5A of the original publication, which were selected based on immunological relevance from a list of dynamic genes during \\textit{in vivo} differentiation. \nFor the genes that were detected to be lineage-associated, we detected a continuous increase in expression of Th1-associated genes but not Tfh-associated genes \\textbf{(Fig.~\\ref{fig2:immune_differentiation2}A)}, with the majority of changes in variability for these genes occurring between day 2 and day 4. \\\\\n\nFinally, we examined immune-related genes (\\textit{Il2ra, Tbx21, Il2rb, Cxcr5, Selplg, Id2, Ifng, Icos, Ifngr1}) that were previously described as showing differences in their peak expression over the pseudo time course of differentiation \\citep{Lonnberg2017} \\textbf{(Fig.~\\ref{fig2:immune_differentiation2}B)}. \nFrom this list, the lineage-associated genes \\textit{Tbx21} and \\textit{Cxcr5} are up-regulated between days 2 and 4. \nHowever, these genes  exhibit opposite behaviours in terms of variability: \\textit{Cxcr5} increases and \\textit{Tbx21} decreases in variability between day 2 and day 4 \\textbf{(Fig.~\\ref{fig2:immune_differentiation2}C)}. \nThe fact that variability of \\textit{Tbx21} (Tbet) expression was highest on day 2 suggests that Tbet is up-regulated very early in differentiation, as seen in \\cite{Lonnberg2017} and similar to \\textit{in vitro} Th1 induction \\citep{Szabo2000}. \nMoreover, this suggests that Th1 fate decisions (for at least a subset of cells) may be made even earlier than the differentiation bifurcation point identified on day 4 by the original study \\citep{Lonnberg2017}. \n\n\\newpage\n\n\\begin{figure}[!h]\n  \\begin{minipage}[c]{0.57\\textwidth}\n    \\includegraphics[width=\\textwidth]{Fig_13.png}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[c]{0.4\\textwidth}\n\\caption[Differential regulation of lineage-associated genes across differentiation]{\\textbf{Differential regulation of Th1- and Tfh-associated genes across the differentiation process.}\\\\\nDifferential mean expression testing (minimum tolerance threshold $\\tau_0=1$) and differential residual over-dispersion testing (minimum tolerance threshold $\\psi_0=0.41$) was performed on cell populations between day 2 and day 4 as well as day 4 and day 7 controlling the EFDR to 10\\%. \nGenes that increase in expression over time are marked with a red dot while genes that decrease in expression over time are marked with a blue dot. \nSimilarly, genes that increase in variability over time are marked in purple while genes that decrease in variability over time are marked in green. Only genes that pass filtering are visualised. \n\\textbf{(A)} Differential testing results are visualised for Th1- and Tfh-associated genes taken from Figure 3E in L\\\"onnberg \\emph{et al.}, 2017 \\citep{Lonnberg2017}. \nGenes are ordered based on their correlation with the Th1 trend assignment (top to bottom) or their correlation to Tfh trend assignment (bottom to top), \n\\textbf{(B)} Differential testing results are visualised for important genes during CD4\\plus{} T cell differentiation taken from Figure 5A in \\citep{Lonnberg2017}. Genes were ordered based on their peak expression point in pseudo-time as defined by L\\\"onnberg \\emph{et al.}, 2017 \\citep{Lonnberg2017}, \n\\textbf{(C)} \\textit{Tbx21} (blue) and \\textit{Cxcr5} (red) measured at day 2, day 4 and day 7 post-infection. \nPosterior estimates for residual over-dispersion parameters $\\epsilon_i$ are plotted against posterior estimates for mean expression parameters $\\mu_i$. \nStatistically significant changes in mean expression (DE, minimum tolerance threshold of $\\tau_0=1$) and variability (DV, minimum tolerance threshold of $\\psi_0=0.41$) are indicated for each comparison} \\label{fig2:immune_differentiation2}\n  \\end{minipage}\n\\end{figure}\n\n\\newpage\n\n\\section{Application to droplet-based scRNA-Seq data}\n\\label{sec2:droplet}\n\n\\begin{Comment}\n\\hspace{-3mm} \\textbf{Declaration} In the context of expanding the BASiCS framework to test changes in variability independent of mean expression, Catalina A. Vallejos (The Alan Turing Institute/MRC Institute of Human Genetics/University of Edinburgh) developed an approach where technical variation was quantified by borrowing information across multiple replicates. \nThis avoids the use of technical spike-in genes when droplet-based scRNA-Seq data is analysed. \nThis approach is part of the publication:\\\\\n\nNils Eling, Arianne C. Richard, Sylvia Richardson, John C. Marioni, Catalina A. Vallejos. Robust expression variability testing reveals heterogeneous T cell responses. \\emph{Cell Systems}, In press, 2018 \\\\\n\nHere, I will not describe this approach in detail as this has not been my own work. \nHowever in the context of this section, it integrates with my contribution to assess mean-independent changes in variability for droplet-based scRNA-Seq data.\n\\end{Comment}\n\nWith the development of droplet-based scRNA-Seq technologies, the number of cells that can be profiled per experiment strongly increased at the cost of lower sequencing depth per cell \\citep{Macosko2015, Klein2015, Zheng2017}. \nFurthermore, these technologies exclude the use of spike-in RNA to measure technical variation, which is essential for quantifying technical variation using the original BASiCS model \\citep{Vallejos2015BASiCS, Vallejos2016}. \nTo ensure the broad applicability of the BASiCS model, both the regression and non-regression models have been expanded to handle datasets without spike-in genes. \nFor this purpose, principles of measurement error models were exploited, where --- in the absence of gold standard features --- technical variation is quantified through {\\it replication} \\citep{Carroll1998}. \nThis horizontal data integration approach is based on experimental designs where cells from a population are randomly allocated to multiple independent experimental replicates (batches). \nIn such an experimental design, the no-spikes implementation of BASiCS assumes that biological effects are shared across batches and that technical variation will be reflected by spurious differences. \nAs shown in the publication, posterior inference under the no-spikes BASiCS model closely matches the original implementation for datasets where spike-ins and batches are available. \nTechnical details about the no-spikes implementation of BASiCS are discussed in the original publication (see \\textbf{Declaration}).\n\n\\newpage\n\n\\subsection{Differential testing using somitic and pre-somitic mesoderm cells}\n\nTo test the applicability of the regression BASiCS model to droplet-based scRNA-Seq data, I analysed cells isolated from mouse embryos at E8.25 \\citep{Ibarra-Soria2018}. \nIbarra-Soria \\emph{et al.}, 2018 analysed more than 20,000 cells to identify the major cell types following gastrulation. \nKey findings included a spatial sub-structure within the foregut, detection of oscillating gene expression patterns during somitogenesis and the contribution of the leukotriene pathway to blood formation. \nI selected the cells identified as presomotic mesoderm and somitic mesoderm as test populations as they reside in contrasting differentiation stages. \nSomitogenesis is a rhythmic and sequential differentiation process from \\gls{PSM} cells to mature somites, which later will give rise to bone, muscle and skin of the adult body. \nThroughout this process, oscillating gene expression patterns control the differentiation of PSM into \\gls{SM}. \nDriving factors for this are Wnt and \\gls{Fgf} signalling on the side of the PSM and retinoic acid signalling in somites \\cite{Oates2012}. \nThe regression BASiCS model can now further dissect transcriptional regulation between these groups of cells.\n\n\\subsubsection{Data processing}\n\nThe raw counts data and assigned cluster labels can be obtained from ArrayExpress [E-MTAB-6153] \\citep{Ibarra-Soria2018}. \nI selected cells labelled as pre-somitic mesoderm and somitic mesoderm for further down-stream analysis and removed lowly expressed genes ($< 0.1$ reads on average). \nFor visualisation purposes, I normalised the data using \\emph{scran} by pooling cells within each cell type. \nPCA computed on the log-transformed normalised counts shows a clear separation between these two cells types with an additional intermediate cell type labelled as 'presomiticmesoderm.b'. \nI excluded this small set of cells as well as outlying cells for which $\\text{PC2}{}<{}-5$ \\textbf{(Fig.~\\ref{fig2:droplet}A)}. \nAfter filtering, I obtained 791 pre-somitic mesoderm cells and 670 somitic mesoderm cells for further analysis. For each of the two populations, the MCMC was run for 20,000 iterations separately. \nAfter posterior inference was completed, I first confirmed that the model estimated the regression trend between the over-dispersion parameters $\\delta_i$ and mean expression parameters $\\mu_i$ correctly. \nFor both conditions, the regression trend captures the full range of data points and differential testing can be performed \\textbf{(Fig.~\\ref{fig2:droplet}B)}. \nFor differential testing, I used a threshold of $\\tau_0=1$ to assess changes in mean expression and the default threshold $\\psi_0\\approx{}0.41$ to test changes in residual over-dispersion.  \n\n\\newpage\n\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\textwidth]{Fig_14.png}\n\\caption[Quantification of expression dynamics from droplet-based scRNA-Seq data]{\\textbf{Quantification of expression dynamics from droplet-based scRNA-Seq data (Full legend on next page).}}\n\\label{fig2:droplet}\n\\end{figure}\n\n\\newpage\n\n\\captionsetup[figure]{list=no}\n\\addtocounter{figure}{-1}   \n\\captionof{figure}{\\textbf{Quantification of expression dynamics from droplet-based scRNA-Seq data (continued).}\\\\\n\\textbf{(A)} Somitic (SM) and pre-somitic mesoderm (PSM) cells from droplet-based scRNA-Seq data \\citep{Ibarra-Soria2018} were selected and visualised via a PCA. \nColour labelling was done based on the cluster annotation taken from the original publication. \nFor down-stream analysis cells with $\\text{PC2}{}<{}-5$ and marked as 'presomiticmesoderm.b'/Pre-somitic mesoderm 2 were removed, \\textbf{(B)} For each condition, over-dispersion estimates $\\delta_i$ were plotted against mean expression estimates $\\mu_i$. \nThe regression trend is indicated as red line, \n\\textbf{(C)} Posterior estimates for the log$_2$ fold change in mean expression between PSM and SM were plotted against mean expression averaged across the two populations. \nDifferentially expressed genes are coloured based on their regulation: blue: PSM-specific (PSM+), red: SM-specific (SM+), \n\\textbf{(D)} Posterior estimates for differences in residual over-dispersion between PSM and SM were plotted against mean expression averaged across the two populations. \nDifferentially variable genes are coloured based on their regulation: purple: PSM-specific (PSM+), brown: SM-specific (SM+), \n\\textbf{(E)} Heatmap showing the Z score scaled gene expression of pre-somitic mesoderm-specific genes of the GO category GO:0009952: anterior/posterior pattern specification. \nGenes were ordered based on their log$_2$ fold change in expression from highest to lowest, \n\\textbf{(F)} Gene expression of \\textit{Meox2} in PSM and SM. This gene was detected to be heterogeneously up-regulated in SM. \nUpper panel: violin plots showing distribution of log-normalised expression counts. \nLower panel: \\textit{Meox2} expression across the PCA from \\textbf{(A)}.\\\\}\n\\captionsetup[figure]{list=yes}\n\n\\subsubsection{Changes in mean expression during somitogenesis}\n\nI first tested changes in mean expression between SM and PSM and detected 203 SM-specific genes and 236 PSM-specific genes. \nBased on these cell type-specific gene lists, I performed GO analysis using the Bioconductor \\emph{goseq} package while correcting for gene length biases. \nAs expected, top enriched categories for SM-specific genes include 'animal organ morphogenesis' and 'skeletal system development' which contain genes such as \\textit{Bmp7}, \\textit{Fgfr2}, \\textit{Gata6} and \\textit{Meox2}. \nSomites are rhythmically formed from the PSM and are embryonic precursors for vertebrae and skeletal muscles \\citep{Dequeant2008}. \nOn the other hand, top categories for PSM-specific genes include 'pattern specification process', 'somitogenesis' and 'Wnt signaling pathway'. \nIt is known that the posterior end of the PSM is high in Wnt and Fgf signalling that determines the oscillation dynamics of individual cells during somitogenesis \\citep{Oates2012}. \n\\textbf{Fig.~\\ref{fig2:droplet}E} visualises the PSM-specific gene expression of the GO category: GO:0009952 - anterior/posterior pattern specification. \nThis category includes contributors to embryonic patterning: \\textit{Fgf8} \\citep{Dubrulle2004}, Wnt signalling components (e.g.~\\textit{Wnt5a}, \\textit{Dkk1}), Notch signalling components (e.g.~\\textit{Dll1}) \\citep{Dequeant2008} and several members of the Hox gene family which control embryonic patterning \\citep{Pearson2005}.\n\n\\newpage\n\n\\subsubsection{Changes in variability during somitogenesis}\n\nNext, I tested changes in variability between SM and PSM and categorised genes based on their regulation as in \\textbf{Section \\ref{sec2:immune_activation}}. \nThese categories include genes with higher expression and higher variability in SM, higher expression and lower variability in SM, higher expression and higher variability in PSM and higher expression and lower variability in PSM. \nInterestingly, I detected the \\gls{Meox2} gene to be heterogeneously up-regulated in somitic mesoderm when compared to the precursor mesoderm \\textbf{(Fig.~\\ref{fig2:droplet}F)}. \n\\textit{Meox2} has been shown to regulate somite morphogenesis, patterning and differentiation specifically in the sclerotome (forming the vertebrae and rib cartilage) alongside its paralog \\textit{Meox1}. \nWhile knocking out \\textit{Meox1} in mice only shows mild defects in vertebrate and rib bones, the knockout of \\textit{Meox2} induces defective differentiation and morphogenesis of the limb muscles \\cite{Mankoo2003}. \nThe heterogeneous, but unstructured \\textbf{(Fig.~\\ref{fig2:droplet}F)}, expression of \\textit{Meox2} might therefore indicate the identity of early progenitor cells that later on differentiate to form  muscles of the limbs. \nSimilarly, I find \\gls{Dmrt2} heterogeneously up-regulated in SM compared to PSM. \nThis transcription factor has been implicated in somite development with specific expression in the dermomyotome, the part of the mesoderm that forms skin. \nThe homozygous loss of \\textit{Dmrt2} leads to severe somite patterning defects at E10.5 and mice die shortly after birth \\citep{Seo2006}. \nThe differential variability analysis revealed an early and heterogeneous expression of \\textit{Dmrt2} in SM which leads to the possible identification of dermomyotome progenitor cells.\\\\\n\nIn sum, I confirmed that the regression BASiCS model can be applied to droplet-based scRNA-Seq data to assess changes in transcriptional variability between conditions. \nThis is an important validation for the next chapter, where I apply the regression BASiCS model to continuous droplet-based scRNA-Seq data to study changes in variability during spermatogenesis. \n", "meta": {"hexsha": "b7aa8ed0aa3b01153eb297b8fb8b1b479ea9d81b", "size": 84458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/Chapt3_files/results.tex", "max_stars_repo_name": "nilseling/Thesis", "max_stars_repo_head_hexsha": "20bf4e22748cd4649bedcf91a6fb39caf07d1053", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2019-03-15T19:34:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-10T09:18:54.000Z", "max_issues_repo_path": "Chapter3/Chapt3_files/results.tex", "max_issues_repo_name": "nilseling/Thesis", "max_issues_repo_head_hexsha": "20bf4e22748cd4649bedcf91a6fb39caf07d1053", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/Chapt3_files/results.tex", "max_forks_repo_name": "nilseling/Thesis", "max_forks_repo_head_hexsha": "20bf4e22748cd4649bedcf91a6fb39caf07d1053", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-04-22T16:28:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-07T18:32:52.000Z", "avg_line_length": 96.9667049369, "max_line_length": 559, "alphanum_fraction": 0.7695185773, "num_tokens": 22298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4412047256059339}}
{"text": "\\lab{Pandas 3: Grouping}{Pandas 3: Grouping}\n\\objective{\nMany data sets contain categorical values that naturally sort the data into groups.\nAnalyzing and comparing such groups is an important part of data analysis.\nIn this lab we explore pandas tools for grouping data and presenting tabular data more compactly, primarily through grouby and pivot tables.\n}\n\n\\section*{Groupby} % ==========================================================\n\nThe file \\texttt{mammal\\_sleep.csv}\\footnote{Proceedings of the National Academy of Sciences, 104 (3):1051--1056, 2007.\nUpdates from V. M. Savage and G. B. West, with additional variables supplemented by Wikipedia.\nAvailable in \\texttt{pydataset} (with a few more columns) under the key \\texttt{\"msleep\"}.} contains data on the sleep cycles of different mammals, classified by order, genus, species, and diet (carnivore, herbivore, omnivore, or insectivore).\nThe \\li{\"sleep_total\"} column gives the total number of hours that each animal sleeps (on average) every $24$ hours.\nTo get an idea of how many animals sleep for how long, we start off with a histogram of the \\li{\"sleep_total\"} column.\n\n\\begin{lstlisting}\n>>> import pandas as pd\n>>> from matplotlib import pyplot as plt\n\n# Read in the data and print a few random entries.\n>>> msleep = pd.read_csv(\"mammal_sleep.csv\")\n>>> msleep.sample(5)\n<<      name     genus   vore         order  sleep_total  sleep_rem  sleep_cycle\n51  Jaguar  Panthera  carni     Carnivora         10.4        NaN          NaN\n77  Tenrec    Tenrec   omni  Afrosoricida         15.6        2.3          NaN\n10    Goat     Capri  herbi  Artiodactyla          5.3        0.6          NaN\n80   Genet   Genetta  carni     Carnivora          6.3        1.3          NaN\n33   Human      Homo   omni      Primates          8.0        1.9          1.5>>\n\n# Plot the distribution of the sleep_total variable.\n>>> msleep.plot(kind=\"hist\", y=\"sleep_total\", title=\"Mammalian Sleep Data\")\n>>> plt.xlabel(\"Hours\")\n\\end{lstlisting}\n\n\\begin{figure}[H] % Mammal sleep_total hist (all groups)\n    \\centering\n    \\includegraphics[width=.7\\textwidth]{figures/mammal_hist.pdf}\n    \\caption{\\li{\"sleep_total\"} frequencies from the mammalian sleep data set.}\n    \\label{fig:pandas-mammals-sleep-all}\n\\end{figure}\n\nWhile this visualization is a good start, it doesn't provide any information about how different kinds of animals have different sleeping habits.\nHow long do carnivores sleep compared to herbivores?\nDo mammals of the same genus have similar sleep patterns?\n\nA powerful tool for answering these kinds of questions is the \\li{groupby()} method of the pandas \\li{DataFrame} class, which partitions the original \\li{DataFrame} into groups based on the values in one or more columns.\nThe \\li{groupby()} method does \\textbf{not} return a new \\li{DataFrame}; it returns a pandas \\li{GroupBy} object, an interface for analyzing the original \\li{DataFrame} by groups.\n\nFor example, the columns \\li{\"genus\"}, \\li{\"vore\"}, and \\li{\"order\"} in the mammal sleep data all have a discrete number of categorical values that could be used to group the data.\nSince the \\li{\"vore\"} column has only a few unique values, we start by grouping the animals by diet.\n\n\\begin{lstlisting}\n# List all of the unique values in the 'vore' column.\n>>> set(msleep[\"vore\"])\n<<{nan, 'herbi', 'omni', 'carni', 'insecti'}>>\n\n# Group the data by the 'vore' column.\n>>> vores = msleep.groupby(\"vore\")\n>>> list(vores.groups)\n<<['carni', 'herbi', 'insecti', 'omni']>>       # NaN values for vore were dropped.\n\n# Get a single group and sample a few rows. Note vore='carni' in each entry.\n>>> vores.get_group(\"carni\").sample(5)\n<<       name     genus   vore      order  sleep_total  sleep_rem  sleep_cycle\n80    Genet   Genetta  carni  Carnivora          6.3        1.3          NaN\n50    Tiger  Panthera  carni  Carnivora         15.8        NaN          NaN\n8       Dog     Canis  carni  Carnivora         10.1        2.9        0.333\n0   Cheetah  Acinonyx  carni  Carnivora         12.1        NaN          NaN\n82  Red fox    Vulpes  carni  Carnivora          9.8        2.4        0.350>>\n\\end{lstlisting}\n\nFor starters, \\li{groupby()} is useful for filtering a \\li{DataFrame} by column values:\nthe command \\li{df.groupby(col).get_group(value)} returns the rows of \\li{df} where the entry of the \\li{col} column is \\li{value}.\nThe real advantage of \\li{groupby()}, however, is how easy it makes it to compare groups of data.\nStandard \\li{DataFrame} methods like \\li{describe()}, \\li{mean()}, \\li{std()}, \\li{<<min>>()}, and \\li{<<max>>()} all work on \\li{GroupBy} objects to produce a new data frame that describes the statistics of each group.\n\n\\begin{lstlisting}\n# Get averages of the numerical columns for each group.\n>>> vores.mean()\n<<         sleep_total  sleep_rem  sleep_cycle\nvore\ncarni         10.379      2.290        0.373\nherbi          9.509      1.367        0.418\ninsecti       14.940      3.525        0.161\nomni          10.925      1.956        0.592>>\n\n# Get more detailed statistics for 'sleep_total' by group.\n>>> vores[\"sleep_total\"].describe()\n<<         count    mean    std  min   25%   50%     75%   max\nvore\ncarni     19.0  10.379  4.669  2.7  6.25  10.4  13.000  19.4\nherbi     32.0   9.509  4.879  1.9  4.30  10.3  14.225  16.6\ninsecti    5.0  14.940  5.921  8.4  8.60  18.1  19.700  19.9\nomni      20.0  10.925  2.949  8.0  9.10   9.9  10.925  18.0>>\n\\end{lstlisting}\n\nMultiple columns can be used simultaneously for grouping.\nIn this case, the \\li{get_group()} method of the \\li{GroupBy} object requires a tuple specifying the values for each of the grouping columns.\n\n\\begin{lstlisting}\n>>> msleep_small = msleep.drop([\"sleep_rem\", \"sleep_cycle\"], axis=1)\n>>> vores_orders = msleep_small.groupby([\"vore\", \"order\"])\n>>> vores_orders.get_group((\"carni\", \"Cetacea\"))\n<<                    name          genus   vore    order  sleep_total\n30           Pilot whale  Globicephalus  carni  Cetacea          2.7\n59       Common porpoise       Phocoena  carni  Cetacea          5.6\n79  Bottle-nosed dolphin       Tursiops  carni  Cetacea          5.2>>\n\\end{lstlisting}\n\n\\subsection*{Visualizing Groups} % --------------------------------------------\n\nThere are a few ways that \\li{groupby()} or similar techniques can simplify the process of visualizing groups of data.\nFirst of all, \\li{groupby()} makes it easy to visualize one group at a time.\nThe following visualization improve on Figure \\ref{fig:pandas-mammals-sleep-all} by grouping mammals by their diets.\n\n\\begin{lstlisting}\n# Plot histograms of 'sleep_total' for two separate groups.\n>>> vores.get_group(\"carni\").plot(kind=\"hist\", y=\"sleep_total\", legend=\"False\",\n                                                title=\"Carnivore Sleep Data\")\n>>> plt.xlabel(\"Hours\")\n>>> vores.get_group(\"herbi\").plot(kind=\"hist\", y=\"sleep_total\", legend=\"False\",\n                                                title=\"Herbivore Sleep Data\")\n>>> plt.xlabel(\"Hours\")\n\\end{lstlisting}\n\n\\begin{figure}[H] % Grouped mammal sleep_total histograms.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.495\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/mammal_hist_carni.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.495\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/mammal_hist_herbi.pdf}\n\\end{subfigure}\n\\caption{\\li{\"sleep_total\"} histograms for two groups in the mammalian sleep data set.}\n\\end{figure}\n\n\\begin{comment} % hist() isn't a great option from a datavis standpoint.\n\\begin{info}\nThe \\li{hist()} method of the \\li{DataFrame} class has a keyword \\li{by} that groups data before plotting, producing one histogram per group.\nThis can be a very quick way to get an overview of the data in multiple groups.\n\n\\begin{lstlisting}\n>>> msleep.hist(\"sleep_total\", by=\"vore\", sharex=True)\n>>> plt.tight_layout()\n\\end{lstlisting}\n\\end{info}\n\\end{comment}\n\nThe statistical summaries from the \\li{GroupBy} object's \\li{mean()}, \\li{std()}, or \\li{describe()} methods also lend themselves well to certain visualizations for comparing groups.\n\n\\begin{lstlisting}\n>>> vores[[\"sleep_total\", \"sleep_rem\", \"sleep_cycle\"]].mean().plot(kind=\"barh\",\n                xerr=vores.std(), title=r\"Mammallian Sleep, $\\mu\\pm\\sigma$\")\n>>> plt.xlabel(\"Hours\")\n>>> plt.ylabel(\"Mammal Diet Classification (vore)\")\n\\end{lstlisting}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.7\\textwidth]{figures/mammal_bar.pdf}\n\\end{figure}\n\nBox plots are well suited for comparing similar distributions.\nThe \\li{boxplot()} method of the \\li{GroupBy} class creates one subplot \\textbf{per group}, plotting each of the columns as a box plot.\n\n\\begin{lstlisting}\n# Use GroupBy.boxplot() to generate one box plot per group.\n>>> vores.boxplot(grid=False)\n>>> plt.tight_layout()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.7\\textwidth]{figures/mammal_box_groups.pdf}\n\\end{figure}\n\nAlternatively, the \\li{boxplot()} method of the \\li{DataFrame} class creates one subplot \\textbf{per column}, plotting each of the columns as a box plot.\nSpecify the \\li{by} keyword to group the data appropriately.\n\n\\begin{lstlisting}\n# Use DataFrame.boxplot() to generate one box plot per column.\n>>> msleep.boxplot([\"sleep_total\", \"sleep_rem\"], by=\"vore\", grid=False)\n\\end{lstlisting}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.7\\textwidth]{figures/mammal_box_cols.pdf}\n\\end{figure}\n\nLike \\li{groupby()}, the \\li{by} argument can be a single column label or a list of column labels.\nSimilar methods exist for creating histograms (\\li{GroupBy.hist()} and \\li{DataFrame.hist()} with \\li{by} keyword), but generally box plots are better for comparing multiple distributions.\n\n\\begin{problem} % More dataset visualizations.\nExamine the following data sets from \\li{pydataset} and answer the corresponding questions.\nUse visualizations to support your conclusions.\n\n\\begin{itemize}\n    \\item \\li{\"iris\"}, measurements of various species of iris flowers.\n    \\begin{enumerate}\n        \\item Which species is easiest to distinguish from the others? How?\n        \\item Given iris data without a species label, what strategies could you use to identify the flower's species?\n    \\end{enumerate}\n    \\item \\li{\"poisons\"}, experimental results of three different poisons and four different treatments.\n    \\begin{enumerate}\n        \\item In general, which poison is most deadly?\n        Which treatment is most effective?\n        \\item If you were poisoned, how would you choose the treatment if you did not know which poison it was? What if you did know which poison it was?\n        \\\\(Hint: group the data by poison, then group each subset by treatment.)\n    \\end{enumerate}\n    \\item \\li{\"diamonds\"}, prices and characteristics of almost 54,000 round-cut diamonds.\n    \\begin{enumerate}\n        \\item How does the color and cut of a diamond affect its price?\n        \\item Of the diamonds with color \\li{\"H\"}, those with a \\li{\"Fair\"} cut sell, on average, for a \\textbf{higher} price than those with an \\li{\"Ideal\"} (superior) cut.\n        What other factors could explain this unintuitive statistic?\n    \\end{enumerate}\n\\end{itemize}\n\\end{problem}\n\n\\section*{Pivot Tables} % =====================================================\n\nOne of the downfalls of \\li{groupby()} is that a typical \\li{GroupBy} object has too much information to display coherently.\nA \\emph{pivot table} intelligently summarizes the results of a \\li{groupby()} operation by aggregating the data in a specified way.\nThe standard tool for making a pivot table is the \\li{pivot_table()} method of the \\li{DataFrame} class.\nAs an example, consider the \\li{\"HairEyeColor\"} data set from \\li{pydataset}.\n\n\\begin{lstlisting}\n>>> from pydataset import data\n>>> hec = data(\"HairEyeColor\")              # Load and preview the data.\n>>> hec.sample(5)\n<<     Hair    Eye     Sex  Freq\n3     Red  Brown    Male    10\n1   Black  Brown    Male    32\n14  Brown  Green    Male    15\n31    Red  Green  Female     7\n21  Black   Blue  Female     9>>\n\n>>> for col in [\"Hair\", \"Eye\", \"Sex\"]:      # Get unique values per column.\n...     print(\"{}: {}\".format(col, \", \".join(set(str(x) for x in hec[col]))))\n...\nHair: Brown, Black, Blond, Red\nEye: Brown, Blue, Hazel, Green\nSex: Male, Female\n\\end{lstlisting}\n\nThere are several ways to group this data with \\li{groupby()}.\nHowever, since there is only one entry per unique hair-eye-sex combination, the data can be completely presented in a pivot table.\n\n\\begin{lstlisting}\n>>> hec.pivot_table(values=\"Freq\", index=[\"Hair\", \"Eye\"], columns=\"Sex\")\n<<Sex          Female  Male\nHair  Eye\nBlack Blue        9    11\n      Brown      36    32\n      Green       2     3\n      Hazel       5    10\nBlond Blue       64    30\n      Brown       4     3\n      Green       8     8\n      Hazel       5     5\nBrown Blue       34    50\n      Brown      66    53\n      Green      14    15\n      Hazel      29    25\nRed   Blue        7    10\n      Brown      16    10\n      Green       7     7\n      Hazel       7     7>>\n\\end{lstlisting}\n\nListing the data in this way makes it easy to locate data and compare the female and male groups.\nFor example, it is easy to see that brown hair is more common than red hair and that about twice as many females have blond hair and blue eyes than males.\n\nUnlike \\li{\"HairEyeColor\"}, many data sets have more than one entry in the data for each grouping (for example, if there were two or more rows in the original data for females with blond hair and blue eyes).\nTo construct a pivot table, data of similar groups must be \\emph{aggregated} together in some way.\nBy default entries are aggregated by averaging the non-null values.\nOther options include taking the min, max, standard deviation, or just counting the number of occurrences.\n\nAs an example, consider again the Titanic data set found in \\texttt{titanic.csv}\\footnote{There is a \\lif{\"Titanic\"} data set in \\lif{pydataset}, but it does not contain as much information as the data in \\texttt{titanic.csv}.}.\nFor this analysis, take only the \\li{\"Survived\"}, \\li{\"Pclass\"}, \\li{\"Sex\"}, \\li{\"Age\"}, \\li{\"Fare\"}, and \\li{\"Embarked\"} columns, replace null age values with the average age, then drop any rows that are missing data.\nTo begin, we examine the average survival rate grouped by sex and passenger class.\n\n\\begin{lstlisting}\n>>> titanic = pd.read_csv(\"titanic.csv\")\n>>> titanic = titanic[[\"Survived\", \"Pclass\", \"Sex\", \"Age\", \"Fare\", \"Embarked\"]]\n>>> titanic[\"Age\"].fillna(titanic[\"Age\"].mean(), inplace=True)\n>>> titanic.dropna(inplace=True)\n\n>>> titanic.pivot_table(values=\"Survived\", index=\"Sex\", columns=\"Pclass\")\n<<Pclass    1.0    2.0    3.0\nSex\nfemale  0.965  0.887  0.491\nmale    0.341  0.146  0.152>>\n\\end{lstlisting}\n\n\\begin{info} % pivot_table() is a shortcut for a complicated groupby().\nThe \\li{pivot_table()} method is just a convenient way of performing a potentially complicated \\li{groupby()} operation with aggregation and some reshaping.\nFor example, the following code is equivalent to the previous example.\n\n\\begin{lstlisting}\n>>> titanic.groupby([\"Sex\", \"Pclass\"])[\"Survived\"].mean().unstack()\n<<Pclass    1.0    2.0    3.0\nSex\nfemale  0.965  0.887  0.491\nmale    0.341  0.146  0.152>>\n\\end{lstlisting}\n\nThe \\li{stack()}, \\li{unstack()}, and \\li{pivot()} methods provide more advanced shaping options.\n\\end{info}\n\nAmong other things, this pivot table clearly shows how much more likely females were to survive than males.\nTo see how many entries fall into each category, or how many survived in each category, aggregate by counting or summing instead of taking the mean.\n\n\\begin{lstlisting}\n# See how many entries are in each category.\n>>> titanic.pivot_table(values=\"Survived\", index=\"Sex\", columns=\"Pclass\",\n...                     aggfunc=\"count\")\n<<Pclass  1.0  2.0  3.0\nSex\nfemale  144  106  216\nmale    179  171  493>>\n\n# See how many people from each category survived.\n>>> titanic.pivot_table(values=\"Survived\", index=\"Sex\", columns=\"Pclass\",\n...                     aggfunc=\"sum\")\n<<Pclass    1.0   2.0    3.0\nSex\nfemale  137.0  94.0  106.0\nmale     61.0  25.0   75.0>>\n\\end{lstlisting}\n\n\\subsection*{Discretizing Continuous Data} % ----------------------------------\n\nSo far we have examined survival rates based on sex and passenger class.\nAnother factor that could have played into survival is age.\nWere male children as likely to die as females in general?\nWe can investigate this question by \\emph{multi-indexing}, or pivoting on more than just two variables, by adding in another index.\n\nIn the original dataset, the \\li{\"Age\"} column has a floating point value for the age of each passenger.\nIf we just added \\li{\"Age\"} as another pivot, then the table would create a new row for \\textbf{each} age present.\nInstead, we partition the \\li{\"Age\"} column into intervals with \\li{pd.cut()}, thus creating a categorical that can be used for grouping.\n\n\\newpage\n\n\\begin{lstlisting}\n# pd.cut() maps continuous entries to discrete intervals.\n>>> pd.cut([6, 1, 2, 3, 4, 5, 6, 7], [0, 4, 8])\n<<[(0, 4], (0, 4], (0, 4], (0, 4], (4, 8], (4, 8], (4, 8], (0, 4]]\nCategories (2, interval[int64]): [(0, 4] < (4, 8]]>>\n\n# Partition the passengers into 3 categories based on age.\n>>> age = pd.cut(titanic['Age'], [0, 12, 18, 80])\n\n>>> titanic.pivot_table(values=\"Survived\", index=[\"Sex\", age],\n                        columns=\"Pclass\", aggfunc=\"mean\")\n<<Pclass             1.0    2.0    3.0\nSex    Age\nfemale (0, 12]   0.000  1.000  0.467\n       (12, 18]  1.000  0.875  0.607\n       (18, 80]  0.969  0.871  0.475\nmale   (0, 12]   1.000  1.000  0.343\n       (12, 18]  0.500  0.000  0.081\n       (18, 80]  0.322  0.093  0.143>>\n\\end{lstlisting}\n\nFrom this table, it appears that male children (ages 0 to 12) in the 1st and 2nd class were very likely to survive, whereas those in 3rd class were much less likely to.\nThis clarifies the claim that males were less likely to survive than females.\nHowever, there are a few oddities in this table: zero percent of the female children in 1st class survived, and zero percent of teenage males in second class survived.\nTo further investigate, count the number of entries in each group.\n\n%\n% This might seem a little odd, but if we looked at our data set again to see how many passengers fell into this category of female, 1st class, and age 0 to 12, we would find only one passenger.\n% Therefore, the statistic that 0\\% of female children in first class lived is misleading.\n\n\\begin{lstlisting}\n>>> titanic.pivot_table(values=\"Survived\", index=[\"Sex\", age],\n                        columns=\"Pclass\", aggfunc=\"count\")\n<<Pclass           1.0  2.0  3.0\nSex    Age\nfemale (0, 12]     1   13   30\n       (12, 18]   12    8   28\n       (18, 80]  129   85  158\nmale   (0, 12]     4   11   35\n       (12, 18]    4   10   37\n       (18, 80]  171  150  420>>\n\\end{lstlisting}\n\nThis table shows that there was only 1 female child in first class and only 10 male teenagers in second class, which sheds light on the previous table.\n\n\\begin{warn}\nThe previous pivot table brings up an important point about partitioning datasets.\nThe Titanic dataset includes data for about 1300 passengers, which is a somewhat reasonable sample size, but half of the groupings include less than 30 entries, which is \\textbf{not} a healthy sample size for statistical analysis.\nAlways carefully question the numbers from pivot tables before making any conclusions.\n\\end{warn}\n\nPandas also supports multi-indexing on the columns.\nAs an example, consider the price of a passenger tickets.\nThis is another continuous feature that can be discretized with \\li{pd.cut()}.\nInstead, we use \\li{pd.qcut()} to split the prices into 2 equal quantiles.\nSome of the resulting groups are empty; to improve readability, specify \\li{fill_value} as the empty string or a dash.\n\n\\begin{lstlisting}\n# pd.qcut() partitions entries into equally populated intervals.\n>>> pd.qcut([1, 2, 5, 6, 8, 3], 2)\n<<[(0.999, 4.0], (0.999, 4.0], (4.0, 8.0], (4.0, 8.0], (4.0, 8.0], (0.999, 4.0]]\nCategories (2, interval[float64]): [(0.999, 4.0] < (4.0, 8.0]]>>\n\n# Cut the ticket price into two intervals (cheap vs expensive).\n>>> fare = pd.qcut(titanic[\"Fare\"], 2)\n>>> titanic.pivot_table(values=\"Survived\",\n                        index=[\"Sex\", age], columns=[fare, \"Pclass\"],\n                        aggfunc=\"count\", fill_value='-')\n<<Fare            (-0.001, 14.454]          (14.454, 512.329]\nPclass                       1.0 2.0  3.0               1.0 2.0 3.0\nSex    Age\nfemale (0, 12]                 -   -    7                 1  13  23\n       (12, 18]                -   4   23                12   4   5\n       (18, 80]                -  31  101               129  54  57\nmale   (0, 12]                 -   -    8                 4  11  27\n       (12, 18]                -   5   26                 4   5  11\n       (18, 80]                8  94  350               163  56  70>>\n\\end{lstlisting}\n\nNot surprisingly, most of the cheap tickets went to passengers in 3rd class.\n%\n% It should be noted though that with datasets where NaN's occur frequently, some preprocessing needs to be done so as to get the most accurate statistics and insights about your dataset.\n\n\\begin{problem} % More Titanic analysis.\nSuppose that someone claims that the city from which a passenger embarked had a strong influence on the passenger's survival rate.\nInvestigate this claim.\n\\begin{enumerate}\n    \\item Check the survival rates of the passengers based on where they embarked from (given in the \\li{\"Embarked\"} column).\n    \\item Create a pivot table to examine survival rates based on both place of embarkment and gender.\n    \\item What do these tables suggest to you about the significance of where people embarked in influencing their survival rate?\n    Examine the context of the problem, and explain what you think this really means.\n    \\item Investigate the claim further with at least two more pivot tables, exploring other criteria (e.g., class, age, etc.).\n    Carefully explain your conclusions.\n\\end{enumerate}\n\\end{problem}\n\n\\newpage\n\n\\begin{problem} % More grouping visualizations / pivot tables.\nExamine the following data sets from \\li{pydataset} and answer the corresponding questions.\nUse visualizations and/or pivot tables as appropriate to support your conclusions.\n\\begin{itemize}\n    \\item \\li{\"npk\"}, an experiment on the effects of nitrogen (N), phosphate (P), and potassium (K) on the growth of peas.\n    \\begin{enumerate}\n        \\item Which element is most effective in general for simulating growth?\n        Which is the least effective?\n        \\item What combination of N, P, and K is optimal? What combination is the worst?\n    \\end{enumerate}\n    \\item \\li{\"swiss\"}, standardized fertility measures and socio-economic indicators for French-speaking provinces of Switzerland at about 1888.\n    \\begin{enumerate}\n        \\item What is the relationship in the data between fertility rates and infant mortality?\n        \\item How are provinces that are predominantly Catholic different from non-Catholic provinces, if at all?\n        \\item What factors in the data are the most important for predicting fertility?\n    \\end{enumerate}\n    \\item Examine a data set of your choice.\n    Formulate simple questions about the data and hypothesize the answers to those questions.\n    Demonstrate the correctness of incorrectness of each hypothesis.\n    Explain your conclusions.\n\\end{itemize}\n\\end{problem}\n", "meta": {"hexsha": "4b74ed8b92bc1c1145503e3cadfdb63c9f870a00", "size": 23464, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "acme-material/Labs/DataScienceEssentials/Pandas3/Pandas3.tex", "max_stars_repo_name": "DM561/dm561.github.io", "max_stars_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-13T13:22:41.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-13T13:22:41.000Z", "max_issues_repo_path": "acme-material/Labs/DataScienceEssentials/Pandas3/Pandas3.tex", "max_issues_repo_name": "DM561/dm561.github.io", "max_issues_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-10-18T19:57:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-31T19:00:36.000Z", "max_forks_repo_path": "acme-material/Labs/DataScienceEssentials/Pandas3/Pandas3.tex", "max_forks_repo_name": "DM561/dm561.github.io", "max_forks_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.1367521368, "max_line_length": 243, "alphanum_fraction": 0.6750767133, "num_tokens": 6494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.4411293243977688}}
{"text": "\\input{newcommands}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Mesh refinement}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[width=15cm]{ICNSP_2011_Vay_fig1.png}\n  \\caption{Sketches of the implementation of mesh refinement in WarpX with the electrostatic (left) and electromagnetic (right) solvers. In both cases, the charge/current from particles are deposited at the finest levels first, then interpolated recursively to coarser levels. In the electrostatic case, the potential is calculated first at the coarsest level $L_0$, the solution interpolated to the boundaries of the refined patch $r$ at the next level $L_{1}$ and the potential calculated at $L_1$. The procedure is repeated iteratively up to the highest level.  In the electromagnetic case, the fields are computed independently on each grid and patch without interpolation at boundaries. Patches are terminated by absorbing layers (PML) to prevent the reflection of electromagnetic waves. Additional coarse patch $c$ and fine grid $a$ are needed so that the full solution is obtained by substitution on $a$ as $F_{n+1}(a)=F_{n+1}(r)+I[F_n( s )-F_{n+1}( c )]$ where $F$ is the field, and $I$ is a coarse-to-fine interpolation operator. In both cases, the field solution at a given level $L_n$ is unaffected by the solution at higher levels $L_{n+1}$ and up, allowing for mitigation of some spurious effects (see text) by providing a transition zone via extension of the patches by a few cells beyond the desired refined area (red \\& orange rectangles) in which the field is interpolated onto particles from the coarser parent level only.}\n  \\label{fig:ESAMR}\n\\end{figure}\n\nThe mesh refinement methods that have been implemented in WarpX were developed following the following principles: i) avoidance of spurious effects from mesh refinement, or minimization of such effects; ii) user controllability of the spurious effects' relative magnitude; iii) simplicity of implementation. The two main generic issues that were identified are: a) spurious self-force on macroparticles close to the mesh refinement interface \\cite{Vaylpb2002,Colellajcp2010}; b) reflection (and possible amplification) of short wavelength electromagnetic waves at the mesh refinement interface \\cite{Vayjcp01}. The two effects are due to the loss of translation invariance introduced by the asymmetry of the grid on each side of the mesh refinement interface.\n\nIn addition, for some implementations where the field that is computed at a given level is affected by the solution at finer levels, there are cases where the procedure violates the integral of Gauss' Law around the refined patch, leading to long range errors \\cite{Vaylpb2002,Colellajcp2010}. As will be shown below, in the procedure that has been developed in WarpX, the field at a given refinement level is not affected by the solution at finer levels, and is thus not affected by this type of error.\n\n\\subsection{Electrostatic}\nA cornerstone of the Particle-In-Cell method is that assuming a particle lying in a hypothetical infinite grid, then if the grid is regular and symmetrical, and if the order of field gathering matches the order of charge (or current) deposition, then there is no self-force of the particle acting on itself: a) anywhere if using the so-called ``momentum conserving'' gathering scheme; b) on average within one cell if using the ``energy conserving'' gathering scheme \\cite{Birdsalllangdon}. A breaking of the regularity and/or symmetry in the grid, whether it is from the use of irregular meshes or mesh refinement, and whether one uses finite difference, finite volume or finite elements, results in a net spurious self-force (which does not average to zero over one cell)  for a macroparticle close to the point of irregularity (mesh refinement interface for the current purpose) \\cite{Vaylpb2002,Colellajcp2010}.\n\nA sketch of the implementation of mesh refinement in WarpX is given in Figure~\\ref{fig:ESAMR} (left). Given the solution of the electric potential at a refinement level $L_n$, it is interpolated onto the boundaries of the grid patch(es) at the next refined level $L_{n+1}$. The electric potential is then computed at level $L_{n+1}$ by solving the Poisson equation. This procedure necessitates the knowledge of the charge density at every level of refinement. For efficiency, the macroparticle charge is deposited on the highest level patch that contains them, and the charge density of each patch is added recursively to lower levels, down to the lowest.\n\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[width=15cm]{ICNSP_2011_Vay_fig2.png}\n  \\caption{Position history of one charged particle attracted by its image induced by a nearby metallic (dirichlet) boundary. The particle is initialized at rest. Without refinement patch (reference case), the particle is accelerated by its image, is reflected specularly at the wall, then decelerates until it reaches its initial position at rest. If the particle is initialized inside a refinement patch, the particle is initially accelerated toward the wall but is spuriously reflected before it reaches the boundary of the patch whether using the method implemented in WarpX or the MC method. Providing a surrounding transition region 2 or 4 cells wide in which the potential is interpolated from the parent coarse solution reduces significantly the effect of the spurious self-force. }\n  \\label{fig:ESselfforce}\n\\end{figure}\nThe presence of the self-force is illustrated on a simple test case that was introduced in \\cite{Vaylpb2002} and also used in \\cite{Colellajcp2010}: a single macroparticle is initialized at rest within a single refinement patch four cells away from the patch refinement boundary. The patch at level $L_1$ has $32\\times32$ cells and is centered relative to the lowest $64\\times64$ grid at level $L_0$ (``main grid''), while the macroparticle is centered in one direction but not in the other. The boundaries of the main grid are perfectly conducting, so that the macroparticle is attracted to the closest wall by its image. Specular reflection is applied when the particle reaches the boundary so that the motion is cyclic. The test was performed with WarpX using either linear or quadratic interpolation when gathering the main grid solution onto the refined patch boundary. It was also performed using another method from P. McCorquodale et al (labeled ``MC'' in this paper) based on the algorithm given in \\cite{Mccorquodalejcp2004}, which employs a more elaborate procedure involving two-ways interpolations between the main grid and the refined patch. A reference case was also run using a single $128\\times128$ grid with no refined patch, in which it is observed that the particle propagates toward the closest boundary at an accelerated pace, is reflected specularly at the boundary, then slows down until it reaches its initial position at zero velocity. The particle position histories are shown for the various cases in Fig. \\ref{fig:ESselfforce}. In all the cases using the refinement patch, the particle was spuriously reflected near the patch boundary and was effectively trapped in the patch. We notice that linear interpolation performs better than quadratic, and that the simple method implemented in WarpX performs better than the other proposed method for this test (see discussion below).\n\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[width=15cm]{ICNSP_2011_Vay_fig3.png}\n  \\caption{(left) Maps of the magnitude of the spurious self-force $\\epsilon$ in arbitrary units within one quarter of the refined patch, defined as $\\epsilon=\\sqrt{(E_x-E_x^{ref})^2+(E_y-E_y^{ref})^2}$, where $E_x$ and $E_y$ are the electric field components within the patch experienced by one particle at a given location and $E_x^{ref}$ and $E_y^{ref}$ are the electric field from a reference solution. The map is given for the WarpX and the MC mesh refinement algorithms and for linear and quadratic interpolation at the patch refinement boundary. (right) Lineouts of the maximum (taken over neighboring cells) of the spurious self-force. Close to the interface boundary (x=0), the spurious self-force decreases at a rate close to one order of magnitude per cell (red line), then at about one order of magnitude per six cells (green line).}\n  \\label{fig:ESselfforcemap}\n\\end{figure}\nThe magnitude of the spurious self-force as a function of the macroparticle position was mapped and is shown in Fig. \\ref{fig:ESselfforcemap} for the WarpX and MC algorithms using linear or quadratic interpolations between grid levels. It is observed that the magnitude of the spurious self-force decreases rapidly with the distance between the particle and the refined patch boundary, at a rate approaching one order of magnitude per cell for the four cells closest to the boundary and about one order of magnitude per six cells beyond. The method implemented in WarpX offers a weaker spurious force on average and especially at the cells that are the closest to the coarse-fine interface where it is the largest and thus matters most.\nWe notice that the magnitude of the spurious self-force depends strongly on the distance to the edge of the patch and to the nodes of the underlying coarse grid, but weakly on the order of deposition and size of the patch.\n\nA method was devised and implemented in WarpX for reducing the magnitude of spurious self-forces near the coarse-fine boundaries as follows. Noting that the coarse grid solution is unaffected by the presence of the patch and is thus free of self-force, extra ``transition'' cells  are added around the ``effective'' refined area.\nWithin the effective area, the particles gather the potential in the fine grid. In the extra transition cells surrounding the refinement patch, the force is gathered directly from the coarse grid (an option, which has not yet been implemented, would be to interpolate between the coarse and fine grid field solutions within the transition zone so as to provide continuity of the force experienced by the particles at the interface). The number of cells allocated in the transition zones is controllable by the user in WarpX, giving the opportunity to check whether the spurious self-force is affecting the calculation by repeating it using different thicknesses of the transition zones. The control of the spurious force using the transition zone is illustrated in Fig.~\\ref{fig:ESselfforce}, where the calculation with WarpX using linear interpolation at the patch interface was repeated using either two or four cells transition regions (measured in refined patch cell units). Using two extra cells allowed for the particle to be free of spurious trapping within the refined area and follow a trajectory that is close to the reference one, and using four extra cells improved further to the point where the resulting trajectory becomes undistinguishable from the reference one.\nWe note that an alternative method was devised for reducing the magnitude of self-force near the coarse-fine boundaries for the MC method, by using a special deposition procedure near the interface \\cite{Colellajcp2010}.\n\n%\\begin{figure}[htb]\n%  \\centering\n%  \\includegraphics[width=15cm]{ICNSP_2011_Vay_fig4.png}\n%  \\caption{Snapshot from a 3D self-consistent simulation of the injector in the High Current Experiment shows the beam emerging from the source at low energy (blue) and being accelerated (green-yellow-orange) and transported in a four quadrupole front end. The automatic layout of the mesh refinement patches from a 2D axisymmetric simulation of the source area shows 2 levels of refinement, concentrating the finer meshes around the emitter (white curve surface) and the beam edge (dark blue).}\n%  \\label{fig:ESHCX}\n%\\end{figure}\n%Automatic remeshing has been implemented in WarpX following the procedure described in \\cite{Vaynim2005}, refining on criteria based on measures of local charge density magnitude and gradients. AMR WarpX simulations were applied to the modeling of the front end injector of the High Current Experiment (HCX) \\cite{Prostprstab2005}, and provided the first numerically converged estimates of phase space beam distorsions, which directly affects beam quality \\cite{Vaypop04}. Fig.~\\ref{fig:ESHCX} shows snapshots from 2D axisymmetric simulation of the souce area illustrating the automatic placement of refined patches, and 3D simulation of the full injector showing the beam generation, acceleration and transport.\n\n\\subsection{Electromagnetic}\nThe method that is used for electrostatic mesh refinement is not directly applicable to electromagnetic calculations. As was shown in section 3.4 of \\cite{Vayjcp01}, refinement schemes relying solely on interpolation between coarse and fine patches lead to the reflection with amplification of the short wavelength modes that fall below the cutoff of the Nyquist frequency of the coarse grid. Unless these modes are damped heavily or prevented from occurring at their source, they may affect particle motion and their effect can escalate if trapped within a patch, via multiple successive reflections with amplification.\n\nTo circumvent this issue, an additional coarse patch (with the same resolution as the parent grid) is added, as shown in Fig.~\\ref{fig:ESAMR}-right and described in \\cite{Vaycpc04}. Both the fine and the coarse grid patches are terminated by Perfectly Matched Layers, reducing wave reflection by orders of magnitude, controllable by the user \\cite{Berengerjcp96,Vayjcp02}. The source current resulting from the motion of charged macroparticles within the refined region is accumulated on the fine patch and is then interpolated onto the coarse patch and added onto the parent grid. The process is repeated recursively from the finest level down to the coarsest. The Maxwell equations are then solved for one time interval on the entire set of grids, by default for one time step using the time step of the finest grid. The field on the coarse and fine patches only contain the contributions from the particles that have evolved within the refined area but not from the current sources outside the area. The total contribution of the field from sources within and outside the refined area is obtained by adding the field from the refined grid $F(r)$, and adding an interpolation $I$ of the difference between the relevant subset $s$ of the field in the parent grid $F(s)$ and the field of the coarse grid  $F( c )$, on an auxiliary grid $a$, i.e. $F(a)=F(r)+I[F(s)-F( c )]$. The field on the parent grid subset $F(s)$ contains contributions from sources from both within and outside of the refined area. Thus, in effect, there is substitution of the coarse field resulting from sources within the patch area by its fine resolution counterpart. The operation is carried out recursively starting at the coarsest level up to the finest.\nAn option has been implemented in which various grid levels are pushed with different time steps, given as a fixed fraction of the individual grid Courant conditions (assuming same cell aspect ratio for all grids and refinement by integer factors). In this case, the fields from the coarse levels, which are advanced less often, are interpolated in time.\n\nThe substitution method has two potential drawbacks due to the inexact cancellation between the coarse and fine patches of : (i) the remnants of ghost fixed charges created by the particles entering and leaving the patches (this effect is due to the use of the electromagnetic solver and is different from the spurious self-force that was described for the electrostatic case); (ii) if using a Maxwell solver with a low-order stencil, the electromagnetic waves traveling on each patch at slightly different velocity due to numerical dispersion.\nThe first issue results in an effective spurious multipole field whose magnitude decreases very rapidly with the distance to the patch boundary, similarly to the spurious self-force in the electrostatic case. Hence, adding a few extra transition cells surrounding the patches mitigates this effect very effectively.\n%[Add hyperbolic correction?]\nThe tunability of WarpX's electromagnetic finite-difference and pseudo-spectral solvers provides the means to optimize the numerical dispersion so as to minimize the second effect for a given application, which has been demonstrated on the laser-plasma interaction test case presented in \\cite{Vaycpc04}.\nBoth effects and their mitigation are described in more detail in \\cite{Vaycpc04}.\n\nCaustics are supported anywhere on the grid with an accuracy that is set by the local resolution, and will be adequately resolved if the grid resolution supports the necessary  modes from their sources to the points of wavefront crossing. The mesh refinement method that is implemented in WarpX has the potential to provide higher efficiency than the standard use of fixed gridding, by offering a path toward adaptive gridding following wavefronts.\n\n%\\begin{figure}[htb]\n%  \\centering\n%  \\includegraphics[width=13cm]{ICNSP_2011_Vay_fig5.png}\n%  \\caption{Electron density $n_e$ (normalized to the density of the injected plasma) from WarpX simulations  in 2-1/2D for a), b), c) and 3D for d) of a rigid beam (thin light-blue outline) propagating through a neutral plasma, for grid sizes of a) $128\\times320$, b) $512\\times1280$, c) $128\\times320$ (main grid, red box) + $128\\times640$ (patch 1, orange box) + $128\\times1280$ (patch 2, yellow box), such that the resolution of patch 2 matched the resolution of the grid used for b), d) grid size of $64\\times64\\times160$ (main grid, red box) + $64\\times64\\times320$ (patch 1, orange box) + $64\\times64\\times640$ (patch 2, yellow box). For c) and d),  the number and weight of injected plasma macroparticles was adjusted to keep the number of macroparticles per cell constant in each grid at injection in front of the beam.}\n%  \\label{fig:EMplasma}\n%\\end{figure}\n%As a test to the electromagnetic PIC implementation, WarpX simulations of wave excitations by a beam propagating through plasma, as described in \\cite{Kaganovichpop2004}, were conducted. In these simulations, a hard-edged, elliptical, rigid beam propagates at constant velocity $v_z = 0.5c$ where $c$ is the speed of light through an initially cold neutral plasma of initial density $n_0$. The beam has a flat-top density profile of $n_b = n_0/2$, and an elliptical shape of length $l = 15 c/\\omega_p$ and diameter $d = l/10$, where $\\omega_p$ is the electron plasma frequency. It is shown in  \\cite{Kaganovichpop2004} that waves with a wavenumber of approximately $2\\omega_p/v_z$ are generated in the plasma by the beam's electrostatic field, and have larger amplitude inside the beam, due to their interaction with the beam's sharp edges.\n\n%Resolving the beam edge and the small structures developing in the wake inside the beam forces small cell sizes. The resolution that is needed for macroscopic convergence was explored in 2-1/2D in a series of four runs where the number of grid cells was varied from $64\\times160$ to $512\\times1280$ by incremental factors of 2. Third order spline interpolation was used for the beam and plasma macroparticle current deposition and force gathering. The details of the plasma wake were very similar between the two highest resolution cases, indicating that macroscopic convergence was reached. The results from the runs using $128\\times320$ and $512\\times1280$ grids are shown in Fig.~\\ref{fig:EMplasma}. The result from the highest resolution run serves as the reference for subsequent calculations with mesh refinement.\n\n%A run was conducted where the main grid had $128\\times320$ cells and was complemented by two refinement patches (with successive refinement factors of 2 in each direction), such that the resolution in the central patch matched the resolution of the case of reference.\n%The number and weight of the injected plasma macroparticles was varied, such that the number of macroparticles per cell in each grid at injection was constant. Results are plotted in Fig.~\\ref{fig:EMplasma} (bottom-left) showing a good reproduction of the fine scale structures within the central fine patch in good agreement with the reference case.\n%Lastly, a three-dimensional simulation with mesh refinement of the same physical setup was conducted. The grid setup and 3D isosurfaces of the plasma electron density as the beam enters the plasma are shown in Fig.~\\ref{fig:EMplasma} (bottom-right). As expected, structures similar to the ones observed in 2D are present within the beam envelope. The speedup achieved by the use of mesh refinement was estimated to be approximately one order of magnitude in 3D.\n", "meta": {"hexsha": "23e32f6a189d94f94e47c3cf596f41ca5e684d27", "size": 20667, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/source/latex_theory/AMR/AMR.tex", "max_stars_repo_name": "kngott/WarpX", "max_stars_repo_head_hexsha": "a20fa37ecd9042a377116dc1bd0ac3b599784f43", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-14T19:27:03.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-14T19:27:03.000Z", "max_issues_repo_path": "Docs/source/latex_theory/AMR/AMR.tex", "max_issues_repo_name": "kngott/WarpX", "max_issues_repo_head_hexsha": "a20fa37ecd9042a377116dc1bd0ac3b599784f43", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-01-23T21:54:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-23T21:54:51.000Z", "max_forks_repo_path": "Docs/source/latex_theory/AMR/AMR.tex", "max_forks_repo_name": "gtrichardson/WarpX", "max_forks_repo_head_hexsha": "86f690e672578fb51e70493824026f3c372d5540", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 261.6075949367, "max_line_length": 1906, "alphanum_fraction": 0.8005032177, "num_tokens": 4538, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4411293243977688}}
{"text": "\\documentclass[11pt]{article}\n\\newcommand\\tab[1][1cm]{\\hspace*{#1}}\n\\usepackage{graphicx}\n\\graphicspath{ {C:/Users/yedkk/Desktop/CS465/hw4} }\n\\begin{document}\n\\section{Homework 10}\nName: Kangdong Yuan\n\t\n\\subsection{problem1}\na).I did not work in a group.\n\\\\b).I did not consult without anyone my group members\n\\\\c).I did not consult any non-class materials.\n\n\\subsection{problem2}\nCreate an array B of length n and put 0 in each entry. For each element a $\\in$ A , add 1 to B[a.deadline]. For each element in B, if B[a.deadline] $>$ a.deadline, return False (set is not independent). Otherwise, we continue the for loop. If there is no B[a.deadline] $>$ a.deadline in whole for loop return True (set is independent). The time complexity of this algorithm is $O(|A|)$.\n\n\n\\subsection{problem3}\nLet OPT(j) be the maximum number of missiles that can be destroyed for the interval $[x_1,x_2,.....x_j]$ . If the input ends at $x_j$ , , so the choice is just when to last activate it before step j. Thus OPT(j) is the best of these\nchoices over all i.\\\\\n\\\\\n$OPT(j)=max_{o\\leq i \\leq j} \\ [OPT(i)+min\\{x_j, f(j-i)\\}]$ \\\\\n\\\\\nset OPT(0) = 0 \\\\\nfor j = 1 to n \\\\\n\\tab $OPT(j)=max_{o\\leq i \\leq j} \\ [OPT(i)+min\\{x_j, f(j-i)\\}]$\\\\\nendfor\\\\\nreturn OPT(n)\\\\\nThe running time is O(n) per iteration, for a total of $O(n^2)$.\\\\\n\\\\\n\\subsection{problem4}\na).\\\\\nThis greedy approach will not be optimal, it will not give us best solution.\\\\\nFor example sequence (2,20,2,2,1,1). If the first player use  greedy approach and takes the first card with a value of 2 then the second player can take the card witha value of 20 and win. \\\\\nThe better solution the first player is to take the last card with a value of 1. Then the second player will take either the 2 or the remaining 1 and the first player can take 20.\\\\\n\\\\\nb).\\\\\nwe define that OPT(i,j) be the difference between, i is the largest total score first player can obtain, j is corresponding score of the second player, on the sequence interval $s_i \\ to \\ s_j$. And $V[i]$ is the value of each card, n is number of card in original sequence.\\\\\n\\\\\nThe Pre-computation code is \\\\\nPseudo-code\\\\\nset the inital value\\\\\nfor i = 1...n:\\\\\n\\tab OPT[i, i] = v[i]\\\\\n\\\\\nfor j from i to n:\\\\\n\\tab for i from j to 1:\\\\\n\\tab \\tab OPT[i, j] = max (v[i] - OPT(i+1,j), v[j] - OPT(i,j-1))\\\\\nreturn OPT array\\\\\n\\\\\nThe look up process:\\\\\nchoose $s_i$ (first in squence), if $OPT[i,j]=v[i]-OPT(i+1,j)$\\\\\nchoose $s_j$ (last in squence), otherwise\\\\\n\\\\\nThe time complexity for Pre-computation is $O(n^2)$, the time complexity for each lookup is $O(1)$.\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "e1a5c5d0407ba9603331ab54138b4c3ac027d190", "size": 2586, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "10. dynamic programming/hw10.tex", "max_stars_repo_name": "yedkk/algorithm-design", "max_stars_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-06-01T02:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T02:39:45.000Z", "max_issues_repo_path": "10. dynamic programming/hw10.tex", "max_issues_repo_name": "yedkk/algorithm-design", "max_issues_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "10. dynamic programming/hw10.tex", "max_forks_repo_name": "yedkk/algorithm-design", "max_forks_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.393442623, "max_line_length": 386, "alphanum_fraction": 0.6879350348, "num_tokens": 820, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.441129313588284}}
{"text": "\\section{Evaluation}\\label{sec:evaluation}\n\n% The source counts were generated by:\n% $ cd benchmarks/haskell16/pos/\n% $ find . -type f -name '*.hs' -exec sed -i '' s/\\{-@/\\{-#LH/ {} +\n% $ sloccount\n\n\\begin{table}[t!]\n\\captionsetup{justification=centering}\n\\caption{Summary of Refinement Reflection Case Studies.}\n\\label{fig:eval-summary}\n\\begin{center}\n\\begin{tabular}{lllr}\n\\toprule\n  \\multicolumn{3}{l}{\\textbf{CATEGORY}}              & \\textbf{LOC} \\\\\n\\toprule\n  \\textbf{I.} & \\multicolumn{3}{l}{\\textbf{Arithmetic}} \\\\[0.05in]\n   & Fibonacci      & \\S~\\ref{sec:refinementreflection:overview}          &  48 \\\\ % Overview.hs\n   & Ackermann      & \\citep{ackermann}\n                    , Fig.~\\ref{fig:ackermann}       & 280 \\\\ % Ackermann.hs\n\n  \\midrule\n\n  \\textbf{II.} & \\multicolumn{3}{l}{\\textbf{Algebraic Data Types}} \\\\[0.05in]\n\n  & Fold Universal & \\citep{agdaequational}          & 105 \\\\ % FoldrUniversal.hs\n  & Fold Fusion    & \\citep{agdaequational}          &     \\\\\n\n  \\midrule\n\n  \\textbf{III.} & \\textbf{Typeclasses} & Table~\\ref{fig:laws} & \\\\[0.05in]\n  & Monoid         & \\tPeano, \\tMaybe, \\tList        & 189 \\\\ % Monoid*.hs\n  & Functor        & \\tMaybe, \\tList, \\tId, \\tReader & 296 \\\\ % Functor*.hs - FunctorReader.hs\n  & Applicative    & \\tMaybe, \\tList, \\tId, \\tReader & 578 \\\\ % Applicative*.hs\n  & Monad          & \\tMaybe, \\tList, \\tId, \\tReader & 435 \\\\ % Monad*.hs\n\n  \\midrule\n\n  \\textbf{IV.} & \\multicolumn{3}{l}{\\textbf{Functional Correctness}} \\\\[0.05in]\n  & SAT Solver     & \\citep{Zombie}                  & 133 \\\\ % Solver.hs\n  & Unification    & \\citep{Sjoberg2015}             & 200 \\\\ % Unification\n\n  \\midrule\n\n  \\textbf{V.} & \\multicolumn{3}{l}{\\textbf{Deterministic Parallelism}} \\\\[0.05in]\n  & Concurrent Sets     & \\S~\\ref{sec:set}           & 906 \\\\ % VerifiedEq/Ord + PureSet.hs + SLSet.hs\n  & $n$-body simulation & \\S~\\ref{sec:nbody}         & 930 \\\\ % VerifiedEq/Ord + Inj/Iso + allpairs.hs\n  & Parallel Reducers   & \\S~\\ref{sec:reducer}       &  55 \\\\ % VerifiedSemigroup + Iso + IntegerSumReduction2.hs\n\n  \\midrule\n\n  \\multicolumn{3}{l}{\\textbf{TOTAL}}                 & 4155 \\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{table}\n\nWe have implemented refinement reflection\nin \\toolname. \n%\nIn this section, we evaluate our approach\nby using \\toolname to verify a variety of\ndeep specifications of Haskell functions\ndrawn from the literature and categorized\nin Table~\\ref{fig:eval-summary},\ntotalling about 4000 lines of specifications\nand proofs.\n%\nNext, we detail each of the first four classes of\nspecifications, illustrate how they were\nverified using refinement reflection, and\ndiscuss the strengths and weaknesses of\nour approach.\n%\n\\emph{All} of these proofs require refinement\nreflection, \\ie are beyond the scope of shallow\nrefinement typing.\n\n\\mypara{Proof Strategies.}\n%\nOur proofs use three building blocks, that are seamlessly\nconnected via refinement typing:\n%\n\\begin{itemize}\n  \\item \\emphbf{Un/folding}\n     definitions of a function @f@ at\n     arguments @e1...en@, which due\n     to refinement reflection, happens\n     whenever the term @f e1 ... en@\n     appears in a proof.\n     For exposition, we render the function\n     whose un/folding is relevant as @#f#@;\n\n  \\item \\emphbf{Lemma Application}\n     which is carried out by using\n     the ``because'' combinator\n     ($\\because$) to instantiate\n     some fact at some inputs;\n\n  \\item \\emphbf{SMT Reasoning}\n     in particular, \\emph{arithmetic},\n     \\emph{ordering} and \\emph{congruence closure}\n     which kicks in automatically (and predictably!),\n     allowing us to simplify proofs by not\n     having to specify, \\eg which subterms\n     to rewrite.\n\\end{itemize}\n\n\\subsection{Arithmetic Properties} \\label{subsec:arith} \\label{subsec:ackermann}\n\nThe first category of theorems pertains to the textbook\nFibonacci and Ackermann functions.\n%\nThe former were shown in \\S~\\ref{sec:refinementreflection:overview}.\n%\nThe latter are summarized in Figure~\\ref{fig:ackermann},\nwhich shows two alternative definitions for the\nAckermann function.\n%\nWe proved equivalence of the definition (Prop 1)\nand various arithmetic relations between\nthem (Prop 2 --- 13), by mechanizing the\nproofs from~\\cite{ackermann}.\n\n\\begin{figure}[t!]\n\\centering\n\\captionsetup{justification=centering}\n\\textbf{Ackermann's Function}\n\\[\n\\begin{array}{lr}\n\\ack{n}{x} \\defeq\n \\left\\{\n\\begin{array}{l}\n\\setlength\\arraycolsep{0pt}\n\\begin{array}{ll}\n      x+2 &\\quad \\text{, if}\\ n=0 \\\\\n      2   &\\quad \\text{, if}\\ x=0 \\\\\n\\end{array} \\\\\n\\ack{n-1}{\\ack{n}{x-1}}\n\\end{array}\n\\right.\n&\n\\iack{h}{n}{x} \\defeq\n \\left\\{\n\\begin{array}{l}\n      x \\quad \\text{, if}\\ h=0 \\\\\n      \\ack{n}{\\iack{h-1}{n}{x}}\n\\end{array}\n\\right.\n\\end{array}\n \\]\n\n\\textbf{Properties}\n$$\n\\begin{array}{lrcrcl}\n1.&                &&            \\ack{n+1}{x}   &=& \\iack{x}{n}{2}\\\\\n2.&                &&            x + 1          &<& \\ack{n}{x}\\\\\n3.&                &&            \\ack{n}{x}     &<& \\ack{n}{x+1}\\\\\n4.& x < y          &\\Rightarrow& \\ack{n}{x}     &<& \\ack{n}{y}\\\\\n5.& 0 < x          &\\Rightarrow& \\ack{n}{x}     &<& \\ack{n+1}{x}\\\\\n6.& 0 < x, n < m   &\\Rightarrow& \\ack{n}{x}     &<& \\ack{m}{x}\\\\\n7.&                &&            \\iack{h}{n}{x} &<& \\iack{h+1}{n}{x}\\\\\n8.&                &&            \\iack{h}{n}{x} &<& \\iack{h}{n}{x+1}\\\\\n9.& x<y            &\\Rightarrow& \\iack{h}{n}{x} &<& \\iack{h}{n}{y}\\\\\n10.&               &\\Rightarrow& \\iack{h}{n}{x} &<& \\iack{h}{n+1}{x}\\\\\n11.& 0<n, l-2 < x  &\\Rightarrow& x + l          &<& \\ack{n}{x}\\\\\n12.& 0<n, l-2 < x  &\\Rightarrow& \\iack{l}{n}{x} &<& \\ack{n+1}{x}\\\\\n13.&               &&            \\iack{x}{n}{y} &<& \\ack{n+1}{x+y}\\\\\n\\end{array}\n$$\n\\caption[Ackermann Properties verified using \\toolname.]{Ackermann Properties~\\citep{ackermann},\n$\\forall n, m, x, y, h, l \\geq 0$}\n\\label{fig:ackermann}\n\\end{figure}\n\n\\mypara{Monotonicity}\n%\nProp 3. shows that \\ack{n}{x} is increasing on $x$.\n%\nWe derived Prop 4. by applying @fMono@ theorem\nfrom \\S~\\ref{sec:examples} with input function\nthe partially applied Ackermann Function\n$\\ack{n}{\\star}$.\n%\nSimilarly, we derived the monotonicity Prop 9. by\napplying @fMono@ to the locally increasing Prop. 8\nand $\\iack{h}{n}{\\star}$.\n%\nProp 5. proves that \\ack{n}{x} is increasing\non the \\emph{first} argument $n$.\n%\nAs @fMono@ applies to the \\emph{last} argument\nof a function, we cannot directly use it to\nderive Prop 6.\n%\nInstead, we define a variant @fMono2@ that works\non the first argument of a binary function, and\nuse it to derive Prop 6.\n\n%%\\mypara{Existentials}\n%%%\n%%Properties 11. and 12. are described in~\\citep{ackermann}\n%%to hold for almost every $x$.\n%%%\n%%That is, Property 11. is described as\n%%$\\exists x_0. x_0 < x \\Rightarrow x + l < \\ack{n}{x}$.\n%%%\n%%Refinement types cannot express existentials,\n%%thus expressing the above property is (currently)\n%%not feasible, but the minimum $x$ was easy to retrieve.\n%%%\n%%Thus, we expressed the above statement by specifying $x_0 = l - 2$.\n%%%\n%%\\NV{``Almost'' means in English for large x.\n%%In math it translates to there exist some x0 such that...\n%%in LiquidHaskell, and due to lack of existentials\n%%I had to find (``retrieve'') an x0 = l-2 above which\n%%the property holds For almost see big o notation, where\n%%there exists a c such that...to specify these properties\n%%in LH you need to give a concrete c But, this paragraph\n%%summarizes a lot of internal thinking, so feel free to\n%%rephrase. I wanted it in, because when I saw the lemma\n%%stating this property holds almost everywhere I though\n%%we could not express it, but we can!}\n\n%\n\\mypara{Constructive Proofs}\n%\nIn \\citep{ackermann} Prop 12. was proved by constructing\nan auxiliary \\emph{ladder} that counts the number of\n(recursive) invocations of the Ackermann function, and\nuses this count to bound \\iack{h}{n}{x} and \\ack{n}{x}.\n%\nIt turned out to be straightforward and natural\nto formalize the proof just by defining the\n@ladder@ function in Haskell, reflecting it,\nand using it to formalize the algebra from~\\citep{ackermann}.\n\n\\subsection{Algebraic Data Properties}\n\\label{subsec:fold}\n\nThe second category of properties pertain to\nalgebraic data types.\n%, \\eg \\emph{folding} over lists.\n\n\\mypara{Fold Univerality}\n%\nNext, we proved properties of list folding, such as\nthe following, describing the \\emph{universal}\nproperty of right-folds~\\citep{agdaequational}:\n%\n\\begin{code}\nfoldr_univ\n  :: f:(a -> b -> b)\n  -> h:([a] -> b)\n  -> e:b\n  -> ys:[a]\n  -> base:{h [] = e }\n  -> stp:(x:a ->l:[a]->{h(x:l) = f x (h l)})\n  -> {h ys = foldr f e ys}\n\\end{code}\n%\nOur proof @foldr_univ@ differs from the one in Agda,\nin two ways.\n%\nFirst, we encode Agda's universal quantification over\n@x@ and @l@ in the assumption @stp@ using a function type.\n%\nSecond, unlike Agda, \\toolname\ndoes not support implicit arguments,\nso at \\emph{uses} of @foldr_univ@\nthe programmer must explicitly\nprovide arguments for @base@\nand @stp@, as illustrated below.\n\n\\mypara{Fold Fusion}\n%\nLet us define the usual composition operator:\n%\n\\begin{code}\n  reflect . :: (b -> c) -> (a -> b) -> a -> c\n  f . g     = \\x -> f (g x)\n\\end{code}\n%\nWe can prove the following @foldr_fusion@ theorem\n(that shows operations can be pushed inside a @foldr@),\nby applying @foldr_univ@ to explicit @bas@ and @stp@ proofs:\n%\n\\begin{code}\n  foldr_fusion\n   :: h:(b -> c)\n   -> f:(a -> b -> b)\n   -> g:(a -> c -> c)\n   -> e:b -> z:[a] -> x:a -> y:b\n   -> fuse: {h (f x y) = g x (h y)})\n   -> {(h . foldr f e) z = foldr g (h e) z}\n\n  foldr_fusion h f g e ys fuse\n    = foldr_univ g (h . foldr f e) (h e) ys\n        (fuse_base h f e)\n        (fuse_step h f e g fuse)\n\\end{code}\n%\nwhere @fuse_base@ and @fuse_step@ prove the\nbase and inductive cases. For example\nthe type of @fuse_base@ is the following theorem\n%\n\\begin{code}\n  fuse_base :: h:(b->c) -> f:(a->b->b) -> e:b\n            -> {(h . foldr f e) [] = h e}\n\\end{code}\n\n\\subsection{Typeclass Laws}\\label{subsec:list}\n\n\\begin{table}[t!]\n\\captionsetup{justification=centering}\n\\caption{Typeclass Laws verified using \\toolname.}\n\\label{fig:laws}\n\\begin{center}\n\\begin{tabular}{rl}\n\n\\toprule\n\n\\multicolumn{2}{c}{\\textbf{Monoid}} \\\\\n{Left Ident.}  & $\\emempty\\ x\\ \\emappend\\  \\equiv x$  \\\\\n{Right Ident.} & $x\\ \\emappend\\ \\emempty \\equiv x$  \\\\\n{Associativity}  & $(x\\ \\emappend\\ y)\\ \\emappend\\ z \\equiv x\\ \\emappend\\ (y\\ \\emappend\\ z)$ \\\\\n\n\\midrule\n\n\\multicolumn{2}{c}{\\textbf{Functor}} \\\\\n{Ident.}     & $\\efmap\\ \\eid\\ xs \\equiv \\eid\\ xs$ \\\\\n{Distribution} & $\\efmap\\ (g\\ecompose\\ h)\\ xs \\equiv (\\efmap\\ g\\ \\ecompose\\ \\efmap\\ h)\\ xs$\\\\\n\n\\midrule\n\n\\multicolumn{2}{c}{\\textbf{Applicative}} \\\\\n\n{Ident.}      & $\\epure \\eid \\eseq\\ v \\equiv v$ \\\\\n{Compos.}     & $\\epure (\\ecompose) \\eseq u \\eseq v \\eseq w \\equiv u \\eseq (v \\eseq w)$ \\\\\n{Homomorph.}  & $\\epure\\ f\\ \\eseq\\ \\epure\\ x \\equiv \\epure\\ (f\\ x)$\\\\\n{Interchange} & $u\\ \\eseq\\ \\epure\\ y \\equiv \\epure\\ (\\$\\ y) \\ \\eseq \\ u$ \\\\\n\n\\midrule\n\\multicolumn{2}{c}{\\textbf{Monad}} \\\\\n{Left Ident.}   & $\\ereturn\\ a \\ebind f \\equiv f\\ a$ \\\\\n{Right Ident.}  & $m \\ebind \\ereturn \\equiv m$ \\\\\n{Associativity} & $(m\\ebind f) \\ebind g \\equiv m\\ebind (\\lambda x \\rightarrow f\\ x \\ebind g)$\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{table}\nWe used \\toolname to prove the Monoid, Functor,\nApplicative and Monad Laws, summarized in\nTable~\\ref{fig:laws}, for various user-defined\ninstances summarized in Table~\\ref{fig:eval-summary}.\n\n%% The purpose of these proofs is to investigate the\n%% proving abilities of \\libname.\n%% For this purpose, we defined the appropriate class\n%% operators on user defined lists, instead of using\n%% Haskell's predefined class instances.\n%% %\n%% In the near future, we plan to embed these proofs\n%% to check the laws on real Haskell instances,\n%% but this requires some engineering from the\n%% \\liquidHaskell team.\n\n\\mypara{Monoid Laws}\n%\nA Monoid is a datatype equipped with an associative\nbinary operator $\\emappend$ and an \\emph{identity}\nelement $\\emempty$.\n%\nWe use \\toolname to prove that\n%\n@Peano@ (with @add@ and @Z@),\n@Maybe@ (with a suitable @mappend@ and @Nothing@), and\n@List@ (with append @++@ and @[]@) satisfy the monoid laws.\n%\nFor example, we prove that @++@ (\\S~\\ref{subsec:list})\nis associative by reifying the textbook proof~\\cite{HuttonBook}\ninto a Haskell function, where the induction\ncorresponds to case-splitting and recurring\non the first argument:\n%\n\\begin{mcode}\n  assoc :: xs:[a] -> ys:[a] -> zs:[a] -> {(xs ++ ys) ++ zs = xs ++ (ys ++ zs)}\n\n  assoc [] ys zs     = ([] #++# ys) ++ zs\n                     =. [] #++# (ys ++ zs)\n                     ** QED\n  assoc (x:xs) ys zs = ((x:  xs)#++# ys) ++ zs\n                     =. (x: (xs ++ ys))#++# zs\n                     =.  x:((xs ++ ys) ++ zs)\n                     =.  x: (xs ++ (ys ++ zs))\n                         $\\because$ assoc xs ys zs\n                     =. (x:xs)  #++# (ys ++ zs)\n                     ** QED\n\\end{mcode}\n\n\n\\mypara{Functor Laws}\n%\nA type is a functor if it has a function\n@fmap@ that satisfies the \\emph{identity}\nand \\emph{distribution} (or fusion) laws\nin Table~\\ref{fig:laws}.\n%\nFor example, consider the proof of\nthe @fmap@ distribution law for the lists,\nalso known as ``map-fusion'', which is the\nbasis for important optimizations in\nGHC~\\cite{ghc-map-fusion}.\n%\nWe reflect the definition of @fmap@:\n%\n\\begin{code}\n  reflect map :: (a -> b) -> [a] -> [b]\n  map f []     = []\n  map f (x:xs) = f x : fmap f xs\n\\end{code}\n%\nand then specify fusion and verify it by an inductive proof:\n% by induction (recursion) on the list argument:\n%\n\\begin{mcode}\n  map_fusion :: f:(b -> c) -> g:(a -> b) -> xs:[a]\n             -> {map (f . g) xs = (map f . map g) xs}\n\\end{mcode}\n\n%%\\begin{mcode}\n%%  map_fusion f g []\n%%    =  ((map f) #.# (map g)) []\n%%    =. (map f) (#map# g [])\n%%    =. #map# f []\n%%    =. []\n%%    =. #map# (f . g) []\n%%    ** QED\n%%\n%%  map_fusion f g (x:xs)\n%%    =   #map# (f . g) (x:xs)\n%%    =. (f . g) x : map (f . g) xs\n%%    =. (f . g) x : (map f #.# map g) xs\n%%       $\\because$  map_fusion f g xs\n%%    =. (f# . #g) x : map f (map g xs)\n%%    =. f   (g  x): map f (map g xs)\n%%    =. #map# f (g x: map g xs)\n%%    =. map f   (#map# g (x:xs))\n%%    =. (map f #.# map g)(x:xs)\n%%    ** QED\n%%\\end{mcode}\n%%\n% \\NV{Say why we need defunctionalization}\n% \\NV{We use app function like HALO (link to the theory)}\n\n% \\mypara{Applicative}\n\n\\mypara{Monad Laws}\n%\nThe monad laws, which relate the\nproperties of the two operators\n$\\ebind$ and $\\ereturn$ (Table~\\ref{fig:laws}),\nrefer to $\\lambda$-functions,\nthus their proof exercises\nour support for defunctionalization\nand $\\eta$- and $\\beta$-equivalence.\n% and the extensionality axioms to prove.\n%\nFor example, consider the proof of the\nassociativity law for the list monad.\nFirst, we reflect the bind operator:\n%\n\\begin{code}\n  reflect (>>=) :: [a] -> (a -> [b]) -> [b]\n  (x:xs) >>= f = f x ++ (xs >>= f)\n  []     >>= f = []\n\\end{code}\n%\nNext, we define an abbreviation for the associativity property:\n%\n\\begin{code}\n  type AssocLaw m f g = {m >>= f >>= g = m >>= (\\x -> f x >>= g)}\n\\end{code}\n%\nFinally, we can prove that the list-bind is associative:\n%\n\\begin{mcode}\n  assoc :: m:[a] -> f:(a ->[b]) -> g:(b ->[c]) -> AssocLaw m f g\n  assoc [] f g\n    =  [] #>>=# f >>= g\n    =. [] #>>=# g\n    =. []\n    =. [] #>>=# (\\x -> f x >>= g) ** QED\n\n  assoc (x:xs) f g\n    =  (x:xs) #>>=# f  >>= g\n    =. (f x ++ xs >>= f) >>= g\n    =. (f x >>= g) ++ (xs >>= f >>= g)\n       $\\because$ bind_append (f x) (xs >>= f) g\n    =. (f x >>= g) ++ (xs >>= \\y -> f y >>= g)\n       $\\because$ assoc xs f g\n    =. (\\y -> f y >>= g) x ++ (xs >>= \\y -> f y >>= g)\n       $\\because$ $\\beta$eq f g x\n    =. (x:xs) #>>=# (\\y -> f y >>= g) ** QED\n\\end{mcode}\n%\nWhere the bind-append fusion lemma states that:\n%\n\\begin{code}\n  bind_append :: xs:[a] -> ys:[a] -> f:(a -> [b])\n              -> {(xs++ys) >>= f = (xs >>= f)++(ys >>= f)}\n\\end{code}\n%\nNotice that the last step requires\n$\\beta$-equivalence on anonymous\nfunctions, which we get by explicitly\ninserting the redex in the logic,\nvia the following lemma with @trivial@ proof\n%\n\\begin{mcode}\n  $\\beta$eq :: f:_ -> g:_ -> x:_ -> {bind (f x) g = (\\y -> bind (f y) g) x}\n  $\\beta$eq _ _ _ = trivial\n\\end{mcode}\n%\n% \\RJ{TODO:discuss $\\alpha$ and $\\beta$ equality, axiom text commented out}\n\n%%\\NV{This is new, text can be simplified}\n%%\\mypara{The Reader Monad} was the most challenging of our benchmarks,\n%%as the @Reader r a@ data type wraps the value @a@ inside a reader-only state,\n%%represented by a lambda argument @r@\n%%%\n%%\\begin{mcode}\n%%  data Reader r a = R { runR :: r -> a }\n%%\\end{mcode}\n%%%\n%%Because of the functional structure of the Reader data type,\n%%equational proofs proceed via unfolding wrapped inside the abstracted\n%%state, thus proving equalities made heavy use of the extensionality\n%%function equality~\\ref{subsec:extensionality} requiring\n%%usage $\\eta$-reduced proof arguments.\n%%%\n%%As an example, proof of monadic associativity performs an\n%%unfolding if the reflected bind wrapped inside \\textit{two} lambda arguments:\n%%%\n%%\\begin{code}\n%%     R (\\r2 -> runR ((\\r4 ->\n%%      R (\\r3 ->\n%%       runR (g ((runR (f r4)) r3)) r3)\n%%     ) (x r2)) r2)\n%%  =. R (\\r2 -> runR ((\\r4 ->\n%%      f r4 #>>=# g\n%%     ) (x r2)) r2)\n%%\\end{code}\n%%%\n%%Even though the intermediate equation step seemed\n%%straightforward, it required usage of extensionality equality twice,\n%%thus two intermediate $\\eta$-expanded helper proofs\n%%\n%%% To prove this equality, in the logic,\n%%% the anonymous functions are represented\n%%% as functional variables axiomatized with\n%%% extensionality axioms.\n%%% %\n%%% Thus, in the logic, we define @f'@ and\n%%% the axioms @forall x. f' x = f x >>= g@\n%%% and @forall g x. (f' x = g x) => f' = g@.\n%%% %\n%%% These two axioms are sufficient to prove\n%%% 1. $\\eta$-equivalence that is required in\n   %%% the last step of the inductive case; and\n%%% 2. $\\beta$-equivalence that is required\n   %%% to prove that our proof\n   %%% @xs >>= f >>= g =. xs >>= (\\y -> f y >>= g)@\n   %%% implies the specification.\n\n\n%% In all, most of the proofs are straightforward,\n%% using inductive reasoning in the structure of\n%% the data constructors and rewriting the definitions\n%% of axiomatized functions.\n\n\\subsection{Functional Correctness} \\label{subsec:programs}\n\nFinally, we proved correctness of two programs\nfrom the literature: a SAT solver and a Unification\nalgorithm.\n\n\\mypara{SAT Solver}\n%\nWe implemented and verified the simple\nSAT solver used to illustrate and evaluate\nthe features of the dependently typed language\nZombie~\\citep{Zombie}.\n%\nThe solver takes as input a formula @f@\nand returns an assignment that\n\\emph{satisfies} @f@ if one exists.\n%\n\\begin{code}\n  solve :: f:Formula -> Maybe {a:Asgn|sat a f}\n  solve f = find (`sat` f) (assignments f)\n\\end{code}\n%\nFunction @assignments f@ returns all possible\nassignments of the formula @f@ and @sat a f@\nreturns @True@ iff the assignment @a@ satisfies\nthe formula @f@:\n%\n\\begin{code}\n  reflect sat :: Asgn -> Formula -> Bool\n  assignments :: Formula -> [Asgn]\n\\end{code}\n%\nVerification of @solve@ follows simply by\nreflecting @sat@ into the refinement logic,\nand using (bounded) refinements to show\nthat @find@ only returns values on which\nits input predicate yields @True@ from chapter~\\ref{boundedrefinements}.\n%\n\\begin{code}\n  find :: p:(a -> Bool) -> [a] -> Maybe {v:a | p v}\n\\end{code}\n\n\n\\mypara{Unification}\n%\nAs another example, we verified the\nunification of first order terms, as\npresented in~\\citep{Sjoberg2015}.\n%\nFirst, we define a predicate alias for\nwhen two terms @s@ and @t@ are equal\nunder a substitution @su@:\n%\n\\begin{code}\n  eq_sub su s t = apply su s == apply su t\n\\end{code}\n%\nNow, we can define a Haskell function\n@unify s t@ that can diverge, or return\n@Nothing@, or return a substitution @su@\nthat makes the terms equal:\n%\n\\begin{code}\n  unify :: s:Term -> t:Term -> Maybe {su| eq_sub su s t}\n\\end{code}\n%\nFor the specification and verification\nwe only needed to reflect @apply@ and\nnot @unify@; thus we only had to verify\nthat the former terminates, and not the latter.\n%\n% not that @unify@ terminates, which is a\n% complicate proof.\n\n%%% HERE\n%\nAs before, we prove correctness by invoking\nseparate helper lemmas.\n%\nFor example to prove the post-condition\nwhen unifying a variable @TVar i@ with\na term @t@ in which @i@ \\emph{does not}\nappear, we apply a lemma @not_in@:\n%\n\\begin{mcode}\n  unify (TVar i) t2\n    | not (i Set_mem freeVars t2)\n    = Just (const [(i, t2)] $\\because$ not_in i t2)\n\n\\end{mcode}\n%%\n\\ie if @i@ is not free in @t@,\nthe singleton substitution yields @t@:\n%\n\\begin{code}\n  not_in :: i:Int\n         -> t:{Term | not (i Set_mem freeVars t)}\n         -> {eq_sub [(i, t)] (TVar i) t}\n\\end{code}\n%%\n%% \\NV{Emphasize how real world - diverging code co-exists with refinement reflection}\n", "meta": {"hexsha": "ffe3ecfa0cefb5cd6a64cbd2b94953950cd2e006", "size": 20795, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinementreflection/evaluation.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinementreflection/evaluation.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinementreflection/evaluation.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 30.4020467836, "max_line_length": 113, "alphanum_fraction": 0.6237557105, "num_tokens": 6767, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376236, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.4411293003936058}}
{"text": "\\chapter{Model architectures}\n\\label{app:model_training}\n\nThis chapter goes into more detail on the specific architectures for the models presented in \\cref{chap:method}. Specifically, the output shape, number of parameters and the connections for each layer in all models is presented in the form of Tables \\ref{tab:Models_Baseline}, \\ref{tab:Models_GCN}, \\ref{tab:Models_Poptoy} and \\ref{tab:Models_Popencoder}. When numbers are presented for either output shape or number of parameters they refer to age/sex. \n\n\\todo{Lägg in modellnamn i tabellen}\n\\begin{table}[H]\n    \\centering\n    \\caption{Baseline}\n    \\begin{tabular}{c|c c c}\n         Layer & Output shape & Params & Connected to\\\\ \\hline\\hline\n         Input layer A &(210) & & \\\\ \\hline\n         Dense layer & (1/2) & 211/422 & Input layer A \\\\ \\hline\\hline\n         Total params & & 211/422\n    \\end{tabular}\n    \\label{tab:Models_Baseline}\n\\end{table}\n\n\\begin{table}[H]\n    \\centering\n    \\caption{GCN}\n    \\begin{tabular}{c|c c c}\n         Layer & Output shape & Params & Connected to\\\\ \\hline\\hline\n         Input layer popgraph &(42, 42) & & \\\\ \\hline\n         Input layer X &  (42, 42)& & \\\\ \\hline\n         GCN layer 1 & (42,10) & 430 & \\thead{Input layer popgraph \\\\ Input layer X}   \\\\ \\hline\n         GCN layer 2 & (42,10)& 110 & GCN layer 1\\\\ \\hline\n         GCN layer 3 & (42,10)& 110  &GCN layer 2\\\\ \\hline\n         Concatenate &(42, 30)  & 0 & \\thead{GCN layer 1\\\\GCN layer 2\\\\GCN layer 3} \\\\ \\hline\n         Dense layer & (1/2) & 1261/2522 & Concatenate \\\\ \\hline\\hline\n         Total params & & 1911/3172\n    \\end{tabular}\n    \\label{tab:Models_GCN}\n\\end{table}\n\n\\begin{table}[H]\n    \\centering\n    \\caption{Poptoy}\n    \\begin{tabular}{c|c c c}\n         Layer & Output shape & Params & Connected to\\\\ \\hline\\hline\n         Input layer popgraph &(100, 100) & & \\\\ \\hline\n         Input layer X &  (100, 100)& & \\\\ \\hline\n         GCN layer 1 & (100,10) & 20 & \\thead{Input layer popgraph \\\\ Input layer X}   \\\\ \\hline\n         GCN layer 2 & (100,10)& 110 & GCN layer 1\\\\ \\hline\n         GCN layer 3 & (100,10)& 110  &GCN layer 2\\\\ \\hline\n         GCN layer 4 & (100,10)& 110  &GCN layer 3\\\\ \\hline\n         GCN layer 5 & (100,10)& 110  &GCN layer 4\\\\ \\hline\n         Concatenate & (100, 50)  & 0 & \\thead{GCN layer 1\\\\GCN layer 2\\\\GCN layer 3\\\\GCN layer 4\\\\GCN layer 5} \\\\ \\hline\n         Dense layer 1& (100, 32) & 1632 & Concatenate \\\\\n         Dense layer 2& (100, 16) & 528 & Dense layer 1\\\\\n         Dense layer 3& (100, 1/2) & 17/34 & Dense layer 2\\\\\n         \\hline\\hline\n         Total params & & 3627/3644\n    \\end{tabular}\n    \\label{tab:Models_Poptoy}\n\\end{table}\n\n\\begin{table}[H]\n    \\centering\n    \\caption{Popencoder }\n    \\begin{tabular}{c|c c c}\n         Layer & Output shape & Params & Connected to\\\\ \\hline\\hline\n         Input layer A &(100, 42,42) & & \\\\ \\hline\n         Input layer X &  (100, 42,42)& & \\\\ \\hline\n         Input layer popgraph &  (100,100)& & \\\\ \\hline\n         Encoder GCN layer 1 & (100,42,10) & 430 & \\thead{Input layer A \\\\ Input layer X} \\\\ \\hline\n         Encoder GCN layer 2 & (100,42,10) & 110 & \\thead{Encoder GCN layer 1} \\\\ \\hline\n         Concatenate 1& (100, 42, 20)  & 0 & \\thead{Encoder GCN layer 1\\\\Encoder GCN layer 2} \\\\ \\hline\n         Dense encoder& (100,1/2) & 841/1682 & \\thead{Concatenate 1}   \\\\ \\hline\n         GCN layer 1 & (100,10) & 1010 & \\thead{Input layer popgraph \\\\ Dense encoder}   \\\\ \\hline\n         GCN layer 2 & (100,10)& 110 & GCN layer 1\\\\ \\hline\n         GCN layer 3 & (100,10)& 110  &GCN layer 2\\\\ \\hline\n         GCN layer 4 & (100,10)& 110  &GCN layer 3\\\\ \\hline\n         GCN layer 5 & (100,10)& 110  &GCN layer 4\\\\ \\hline\n         Concatenate 2& (100, 51/52)  & 0 & \\thead{GCN layer 1\\\\GCN layer 2\\\\GCN layer 3\\\\GCN layer 4\\\\GCN layer 5} \\\\ \\hline\n         Dense layer 1& (100, 32) & 1664/1696 & Concatenate 2\\\\\n         Dense layer 2& (100, 16) & 528 & Dense layer 1\\\\\n         Dense layer 3& (100, 1/2) & 17/34 & Dense layer 2\\\\\n         \\hline\\hline\n         Total params & & 4050/4950\n    \\end{tabular}\n    \\label{tab:Models_Popencoder}\n\\end{table}\n% -- Model parameters\n% -- Training details\n", "meta": {"hexsha": "d2a18d46a5ce210207bbb465fb69bed7a4d28565", "size": 4155, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "appendices/model_training.tex", "max_stars_repo_name": "elindgren/master_thesis", "max_stars_repo_head_hexsha": "62185cdeafbf1ce65a49bb41828281c09435ac87", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "appendices/model_training.tex", "max_issues_repo_name": "elindgren/master_thesis", "max_issues_repo_head_hexsha": "62185cdeafbf1ce65a49bb41828281c09435ac87", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "appendices/model_training.tex", "max_forks_repo_name": "elindgren/master_thesis", "max_forks_repo_head_hexsha": "62185cdeafbf1ce65a49bb41828281c09435ac87", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.3139534884, "max_line_length": 454, "alphanum_fraction": 0.5898916968, "num_tokens": 1487, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4409083348472241}}
{"text": "%\\documentclass[prd,preprint,superscriptaddress,tightenlines,nofootinbib,\r\n%  eqsecnum,showpacs]{revtex4-1}\r\n\\documentclass[prd,preprint,superscriptaddress,tightenlines,nofootinbib,\r\n  eqsecnum,showpacs]{revtex4}\r\n\r\n\\usepackage{amsmath}\r\n\\usepackage{amsfonts}\r\n\\usepackage{amssymb}\r\n\\usepackage{bm}\r\n\\usepackage{hyperref}\r\n\\usepackage{mathrsfs}\r\n\\usepackage{graphicx}\r\n\r\n\\usepackage{ulem}\r\n\\normalem\r\n\\usepackage[usenames]{color}\r\n\\newcommand{\\blue}{\\textcolor{blue}}\r\n\\newcommand{\\green}{\\textcolor{green}}\r\n\\newcommand{\\red}{\\textcolor{red}}\r\n\\newcommand{\\magenta}{\\textcolor{magenta}}\r\n\r\n%%%%%%%%%%%%\r\n% Uncomment the following line to display all labels\r\n%\\usepackage{showkeys}\r\n%%%%%%%%%%%%\r\n        \r\n\\allowdisplaybreaks\r\n% Better to do this locally for a given very long equation:\r\n% {\\allowdisplaybreaks \\begin{eqnarray} ... \\end{eqnarray}}\r\n% \\noindent\r\n\r\n\\DeclareSymbolFontAlphabet{\\mathrsfs}{rsfs}\r\n\\DeclareMathAlphabet{\\mathcal}{OMS}{cmsy}{m}{n}\r\n\r\n\\newcommand{\\scri}{\\mathrsfs{I}}\r\n\\newcommand{\\ud}{\\mathrm{d}}\r\n\\newcommand{\\ui}{\\mathrm{i}}\r\n\\newcommand{\\beq}{\\begin{equation}}\r\n\\newcommand{\\eeq}{\\end{equation}}\r\n\r\n\\setlength{\\unitlength}{1cm}\r\n\r\n\\begin{document}\r\n\r\n\\title{Non-linear multipole interactions and gravitational-wave\r\n  \\\\octupole modes for inspiralling compact binaries to\r\n  third-and-a-half post-Newtonian order}\r\n\r\n\\author{Guillaume Faye}\\email{faye@iap.fr}\r\n\\affiliation{$\\mathcal{G}\\mathbb{R}\\varepsilon{\\mathbb{C}}\\mathcal{O}$,\r\n  Institut d'Astrophysique de Paris --- UMR 7095 du CNRS,\r\n  \\\\ Universit\\'e Pierre \\& Marie Curie, 98\\textsuperscript{bis}\r\n  boulevard Arago, 75014 Paris, France}\r\n\r\n\\author{Luc Blanchet}\\email{blanchet@iap.fr}\r\n\\affiliation{$\\mathcal{G}\\mathbb{R}\\varepsilon{\\mathbb{C}}\\mathcal{O}$,\r\n  Institut d'Astrophysique de Paris --- UMR 7095 du CNRS,\r\n  \\\\ Universit\\'e Pierre \\& Marie Curie, 98\\textsuperscript{bis}\r\n  boulevard Arago, 75014 Paris, France}\r\n\r\n\\author{Bala R. Iyer} \\email{bri@rri.res.in} \\affiliation{Raman\r\n  Research Institute, Bangalore 560 080, India}\r\n\r\n\\date{\\today}\r\n\r\n\\begin{abstract}\r\n  This paper is motivated by the need to improve the post-Newtonian\r\n  (PN) amplitude accuracy of waveforms for gravitational waves\r\n  generated by inspiralling compact binaries, both for use in data\r\n  analysis and in the comparison between post-Newtonian approximations\r\n  and numerical relativity computations. It presents: (i) the\r\n  non-linear couplings between multipole moments of general\r\n  post-Newtonian matter sources up to order 3.5PN, including all\r\n  contributions from tails, tails-of-tails and the non-linear memory\r\n  effect; and (ii) the source mass-type octupole moment of\r\n  (non-spinning) compact binaries up to order 3PN, which permits to\r\n  complete the expressions of the octupole modes $(3,3)$ and $(3,1)$\r\n  of the gravitational waveform to order 3.5PN. At this occasion we\r\n  reconfirm by means of independent calculations our earlier results\r\n  concerning the source mass-type quadrupole moment to order\r\n  3PN. Related discussions on factorized resummed waveforms and the\r\n  occurence of logarithmic contributions to high order are also\r\n  included.\r\n\\end{abstract}\r\n\r\n\\pacs{04.25.Nx, 04.30.-w, 97.60.Jd, 97.60.Lf}\r\n\r\n\\maketitle\r\n\r\n\\section{Introduction} \\label{sec:intro}\r\n\r\nCoalescing compact binaries --- two neutron stars or black holes in\r\ntheir late stage of evolution prior the final coalescence --- should\r\nbe the \\textit{workhorse} source driving the network of advanced\r\ninterferometric gravitational-wave detectors on ground. The\r\npost-Newtonian (PN) approximation is the appropriate technique to\r\nextract accurate and reliable predictions from general relativity\r\ntheory for the inspiral phase of these systems. This constitutes the\r\nstarting point, in data analysis, to construct templates for double\r\nneutron-star binaries and a crucial input to validate the early\r\ninspiral phase of the numerical relativity waveforms for black-hole\r\nbinaries.\r\n\r\nThe non-linear evolution of the orbital phase due to gravitational\r\nradiation reaction is the crucial ingredient in constructing these\r\ntemplates. It has been completed for non-spinning compact binaries up\r\nto order 3.5PN~\\cite{BDIWW95, B98tail, BIJ02, BFIJ02, BI04mult,\r\n  BDEI04, BDEI05dr}.\\footnote{As usual the $n$PN order refers to the\r\n  terms of order $1/c^{2n}$ in the waveform and energy flux, beyond\r\n  the Einstein quadrupole formula which is referred to as the Newtonian\r\n  appoximation.} The amplitude of the signal, including all signal\r\nharmonics besides the dominant one at twice the orbital frequency, has\r\nbeen computed over the years with increasing precision and is now\r\ncomplete to order 3PN~\\cite{BIWW96, ABIQ04, KBI07, K07,\r\n  BFIS08}. Furthermore the dominant quadrupole mode $(2,2)$ is also\r\nknown to order 3.5PN~\\cite{FMBI12}. Our current program consists in\r\nextending this computation and obtaining the full waveform up to order\r\n3.5PN for all the modes $(\\ell, m)$ in a spin-weighted\r\nspherical-harmonic decomposition. In the present paper we shall, as\r\nkey milestones for this program:\r\n%\r\n\\begin{enumerate}\r\n\r\n\\item Control all the non-linear couplings between multipole moments up to\r\n  order 3.5PN for general matter sources; those couplings involve the\r\n  important contributions of tails, tails-of-tails and the non-linear memory\r\n  effect, as well as some extra contributions due to our specific definitions\r\n  for the source multipole moments;\r\n\r\n\\item Obtain the source mass-type \\textit{octupole} moment of (non-spinning)\r\n  compact binaries up to order 3PN, which allows us to obtain the expressions\r\n  of the octupole modes $(3,3)$ and $(3,1)$ of the waveform to order 3.5PN; we\r\n  shall take this opportunity to recompute, using our new programs, the\r\n  mass-type quadrupole moment to order 3PN and confirm the earlier\r\n  results~\\cite{BI04mult, BDEI04, BDEI05dr}.\r\n\\end{enumerate}\r\n%\r\nThe full completion of our program will have to wait for the more difficult\r\ncomputation of the source current-type quadrupole moment to order 3PN, which\r\nis left for future work.\r\n\r\nThe plan of this paper is the following. Sec.~\\ref{sec:MPM} is a\r\nrecapitulation of the basic definitions we use for source and\r\ncanonical multipole moments within the multipolar-post-Minkowskian\r\n(MPM) formalism. In Sec.~\\ref{sec:rad} we present (without proof) the\r\nexpressions of the radiative moments seen at infinity in terms of\r\ncanonical ones up to order 3.5PN for general matter sources (including\r\nthe various tail and memory effects), and the explicit links between\r\ncanonical and source moments. Next, Sec.~\\ref{sec:octupole} deals with\r\nthe waveform of non-spinning compact binary sources. Notably, in\r\nSubsec.~\\ref{sec:octCM}, we compute the mass-type octupole moment for\r\ngeneral orbits to 3PN order, reduce it to the center-of-mass frame and\r\nthen to circular orbits, and, in Subsec.~\\ref{sec:modes}, we obtain\r\nthe gravitational-wave modes $(3,3)$ and $(3,1)$ up to order 3.5PN for\r\ncircular orbits. Sec.~\\ref{sec:factor} is devoted to the occurence of\r\nlogarithmic contributions in the MPM waveform to arbitrary high\r\nnon-linear orders, with an application to factorized resummed\r\nwaveforms in the effective one body (EOB) approach. The paper ends\r\nwith three more technical Appendices.\r\n\r\n\\section{Multipolar Post-Minkowskian expansion} \r\n\\label{sec:MPM}\r\n\r\nWe look for the solution of the Einstein field equations in the vacuum\r\nregion outside the compact support of a general isolated matter\r\nsource. With\r\n$h^{\\alpha\\beta}\\equiv\\sqrt{-g}g^{\\alpha\\beta}-\\eta^{\\alpha\\beta}$\r\ndenoting the ``gothic'' metric deviation, where $g$ and\r\n$g^{\\alpha\\beta}$ are respectively the determinant and the inverse of\r\nthe ``covariant'' metric $g_{\\alpha\\beta}$ and where\r\n$\\eta^{\\alpha\\beta}\\equiv\\text{diag}(-1,1,1,1)$ stands for the\r\nMinkowski metric in Cartesian coordinates, the vacuum field equations\r\nrelaxed by the harmonic-gauge condition read\r\n%\r\n\\begin{subequations}\\label{EFE}\r\n\\begin{align}\r\n\\Box h^{\\alpha\\beta} &= \\Lambda^{\\alpha\\beta}\\bigl[h, \\partial h,\r\n  \\partial^2h\\bigr]\\,,\\label{EFEa}\\\\ \\partial_\\beta h^{\\alpha\\beta} &=\r\n0\\,.\\label{EFEb}\r\n\\end{align}\\end{subequations}\r\n%\r\nHere $\\Box\\equiv\\eta^{\\alpha\\beta}\\partial_\\alpha\\partial_\\beta$\r\ndenotes the flat d'Alembertian operator, whereas the non-linear\r\ngravitational source term $\\Lambda^{\\alpha\\beta}$ is an expression of\r\nsecond-order (at least) in the space-time components\r\n$h^{\\gamma\\delta}$, which is quadratic in the first space-time\r\nderivatives symbolized by $\\partial h$ and linear in the second\r\nspace-time derivatives $\\partial^2h$.\r\n\r\nThe multipolar-post-Minkowskian (MPM) expansion~\\cite{BD86} is an\r\nalgorithmic procedure for generating iteratively the most general\r\nsolution of the field equations~\\eqref{EFE} in the form of a\r\npost-Minkowskian (or non-linearity) expansion whose coefficients are\r\nthemselves given by a multipole expansion physically valid outside the\r\ncompact support of the source. The multipole expansion is parametrized\r\nby certain multipole moments characterizing the matter source but\r\nleft, in a first stage, as some unspecified functions of\r\ntime. However, among these moments, the mass monopole $M$ as well as\r\nthe mass and current dipoles, $M_i$ and $S_i$ respectively, are\r\nconstrained to be constant or to vary linearly with time; they\r\nrepresent the ADM conserved mass, linear momentum and total angular\r\nmomentum of the source. In this paper we shall work in a mass-centred\r\nframe such that $M_i=0$. Furthermore, an important assumption of the\r\nMPM formalism is the stationarity in the past, namely the fact that\r\nthe matter source has been stationary in the remote past, before some\r\ngiven date $-\\mathcal{T}$. Thus, all multipole moments we shall\r\nconsider are assumed to be constant when $t\\leqslant -\\mathcal{T}$.\r\n\r\nThe starting point of the MPM algorithm is Thorne's~\\cite{Th80}\r\nlinearized vacuum solution parametrized by two types of multipole\r\nmoments, called the \\textit{source} moments: the mass-type moments\r\n$I_L(t)$ and the current-type moments $J_L(t)$; they are such that\r\n$I=M$, $I_i=M_i=0$ and $J_i=S_i$ are constant. Such  general linearized\r\nsolution, referred to as ``canonical'', reads\\footnote{Our notation is\r\n  as follows. The retarded time is denoted as $t_r\\equiv t-r/c$. The\r\n  $n$-th time derivatives of multipole moments are indicated by\r\n  superscripts $(n)$. $L = i_1 \\cdots i_\\ell$ denotes a multi-index\r\n  composed of $\\ell$ spatial indices (ranging from 1 to 3); $aL-1=a\r\n  i_1 \\cdots i_{\\ell-1}$ and so on; $\\partial_L = \\partial_{i_1}\r\n  \\cdots \\partial_{i_\\ell}$ is the ``product'' of $\\ell$ partial\r\n  derivatives $\\partial_i \\equiv \\partial / \\partial x^i$; similarly\r\n  $x_L = x_{i_1} \\cdots x_{i_\\ell}$ with $x_i$ being the spatial\r\n  position, and $n_L = n_{i_1} \\cdots n_{i_\\ell}$ with\r\n  $n_i=x_i/r$. Symmetrization over indices is denoted by\r\n  $T_{(ij)}=\\frac{1}{2}(T_{ij}+T_{ji})$. The symmetric-trace-free\r\n  (STF) projection is indicated with a hat, \\textit{i.e.} $\\hat{n}_L\r\n  \\equiv \\text{STF}[n_L]$, or by angular brackets $\\langle\\rangle$\r\n  surrounding the relevant indices, \\textit{e.g.}\r\n  $\\hat{n}_{ijk}=n_{\\langle\r\n    ijk\\rangle}=n_in_jn_k-\\frac{1}{5}[\\delta_{ij}n_k +\\delta_{jk}n_i\r\n    +\\delta_{ki}n_j]$. Underlined indices mean that they should be\r\n  excluded from the STF projection, \\textit{e.g.} $T_{\\langle\r\n    i\\underline{a}j\\rangle}=\\frac{1}{2}(T_{iaj}+T_{jai}) -\r\n  \\frac{1}{3}\\delta_{ij}T_{kak}$. The multipole moments we use,\r\n  $\\{I_L, J_L, W_L, X_L, Y_L, Z_L\\}$, $\\{M_L, S_L\\}$ and $\\{U_L,\r\n  V_L\\}$, are all STF, hence \\textit{e.g.} $I_L=\\hat{I}_L=I_{\\langle\r\n    L\\rangle}$. In the case of summed-up multi-indices $L$, we do not\r\n  write the $\\ell$ summations from 1 to 3 over the dummy indices. The\r\n  Levi-Civita antisymmetric symbol is denoted $\\varepsilon_{iab}$\r\n  (with $\\varepsilon_{123}=1$).}\r\n%\r\n\\begin{subequations} \\label{hcan1}\r\n\\begin{align}\r\nh^{00}_{\\mathrm{can}\\,(1)} &= -\\frac{4}{c^2}\\sum_{\\ell = 0}^{+\\infty}\r\n\\frac{(-)^\\ell}{\\ell !} \\partial_L \\left[ r^{-1} I_L (t_r)\\right] \\,\r\n,\\\\ h^{0i}_{\\mathrm{can}\\,(1)} &= \\frac{4}{c^3}\\sum_{\\ell =\r\n  1}^{+\\infty} \\frac{(-)^\\ell}{\\ell!}  \\left\\{ \\partial_{L-1} \\left[\r\n  r^{-1} I_{iL-1}^{(1)} (t_r)\\right] + \\frac{\\ell}{\\ell+1}\r\n\\varepsilon_{iab} \\, \\partial_{aL-1} \\left[ r^{-1} J_{bL-1}\r\n  (t_r)\\right]\\right\\} \\, ,\\\\ h^{ij}_{\\mathrm{can}\\,(1)} &=\r\n-\\frac{4}{c^4} \\sum_{\\ell = 2}^{+\\infty} \\frac{(-)^\\ell}{\\ell !}\r\n\\left\\{ \\partial_{L-2} \\left[ r^{-1} I_{ijL-2}^{(2)} (t_r)\\right] +\r\n\\frac{2\\ell}{\\ell+1} \\partial_{aL-2} \\left[ r^{-1} \\varepsilon_{ab(i}\r\n  J_{j)bL-2}^{(1)} (t_r)\\right]\\right\\}\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nIt satisfies the relaxed linearized vacuum field equations $\\Box\r\nh_{\\mathrm{can}\\,(1)}^{\\alpha\\beta}=0$ and the harmonic gauge\r\ncondition $\\partial_\\beta h_{\\mathrm{can}\\,(1)}^{\\alpha\\beta} =0$,\r\nformally at any point but $r=0$. However this solution is not the most\r\ngeneral one, as we can always perform an arbitrary linearized gauge\r\ntransformation maintaining the harmonic-gauge condition. Introducing\r\nan arbitrary gauge vector $\\varphi_{(1)}^\\alpha$ satisfying\r\n$\\Box\\varphi_{(1)}^\\alpha=0$ (except at $r=0$), which will be\r\nparametrized by four supplementary types of (unconstrained) multipole\r\nmoments $W_L(t)$, $X_L(t)$, $Y_L(t)$ and $Z_L(t)$ called the\r\n\\textit{gauge} moments, we can write\r\n%\r\n\\begin{subequations} \\label{phi1}\r\n\\begin{align}\r\n\\varphi^0_{(1)} =& \\frac{4}{c^3} \\sum_{\\ell = 0}^{+\\infty}\r\n\\frac{(-)^\\ell}{\\ell !}  \\partial_L \\left[ r^{-1} W_L (t_r)\\right]\r\n\\,, \\\\ \\varphi^i_{(1)} =& -\\frac{4}{c^4} \\sum_{\\ell = 0}^{+\\infty}\r\n\\frac{(-)^\\ell}{ \\ell !}  \\partial_{iL} \\left[ r^{-1} X_L\r\n  (t_r)\\right] \\\\ & -\\frac{4}{c^4} \\sum_{\\ell = 1}^{+\\infty}\r\n\\frac{(-)^\\ell}{\\ell !}  \\left\\{ \\partial_{L-1} \\left[ r^{-1} Y_{iL-1}\r\n  (t_r)\\right] + \\frac{\\ell}{\\ell+1} \\varepsilon_{iab} \\,\r\n\\partial_{aL-1} \\left[ r^{-1} Z_{bL-1} (t_r)\\right]\\right\\} \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nThe linear gauge terms take the form\r\n$\\partial\\varphi_{(1)}^{\\alpha\\beta} \\equiv\r\n\\partial^\\alpha\\varphi_{(1)}^{\\beta} +\r\n\\partial^\\beta\\varphi_{(1)}^{\\alpha} -\r\n\\eta^{\\alpha\\beta}\\partial_\\gamma\\varphi_{(1)}^{\\gamma}$ so that the\r\nmost general linearized vacuum solution in harmonic coordinates reads\r\n%\r\n\\begin{equation} \\label{hgen1}\r\nh_{\\mathrm{gen}\\,(1)}^{\\alpha\\beta} =\r\nh_{\\mathrm{can}\\,(1)}^{\\alpha\\beta}\\bigl[I_L,J_L\\bigr] +\r\n\\partial\\varphi_{(1)}^{\\alpha\\beta}\\bigl[W_L,X_L,Y_L,Z_L\\bigr]\\,.\r\n\\end{equation}\r\n%\r\nStarting from $h_{\\mathrm{gen}\\,(1)}$ the MPM algorithm will generate a full\r\npost-Minkowskian solution of the field equations~\\eqref{EFE}, \\textit{i.e.} a\r\nsolution given as a formal non-linear expansion series in powers of Newton's\r\nconstant $G$, as shown in Eq.~\\eqref{PMgen} below. Suppose that one has\r\nsucceeded in generating all the post-Minkowskian coefficients up to some order\r\n$n-1$, say $h_{\\mathrm{gen}\\,(2)}$, $\\cdots$, $h_{\\mathrm{gen}\\,(n-1)}$. Then\r\nthe precise procedure by which the next post-Minkowskian coefficient,\r\n\\textit{i.e.} $h_{\\mathrm{gen}\\,(n)}$, is generated is as follows~\\cite{BD86}.\r\nOne decomposes this coefficient into two terms,\r\n%\r\n\\begin{equation} \\label{hgenn}\r\nh^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)} =\r\nu^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)} +\r\nv^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)} \\,.\r\n\\end{equation}\r\n%\r\nThe first one is defined as the standard (flat) retarded integral,\r\ndenoted $\\Box^{-1}_\\mathrm{ret}$, of the iterated source term coming\r\nfrom the relaxed Einstein field equation~\\eqref{EFEa}. Namely, after\r\nobtaining from the previous iterations the $n$-th post-Minkowskian\r\norder source term as some\r\n$\\Lambda_{(n)}=\\Lambda_{(n)}[h_{\\mathrm{gen}\\,(1)}, \\cdots,\r\n  h_{\\mathrm{gen}\\,(n-1)}]$, we pose\r\n%\r\n\\begin{equation} \\label{un}\r\nu^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)} = \\mathop{\\mathrm{FP}}_{B=0} \\,\r\n\\Box^{-1}_\\mathrm{ret} \\left[ \\widetilde{r}^B\r\n  \\Lambda_{(n)}^{\\alpha\\beta} \\right] \\,.\r\n\\end{equation}\r\n%\r\nCrucial to the MPM algorithm is the regularization process based on\r\nanalytic continuation in a complex parameter $B$ which enters a\r\nregulator factor,\r\n%\r\n\\begin{equation} \\label{regulator}\r\n\\widetilde{r}^B \\equiv \\left(\\frac{r}{r_0}\\right)^B \\, ,\r\n\\end{equation}\r\n%\r\nmultiplying the source term. Here $r_0$ is an arbitrary constant\r\nlength scale. The regulator~\\eqref{regulator} permits, thanks to\r\nanalytic continuation, to cure the divergency of the multipole\r\nexpansion when $r\\to 0$ that follows from the fact that the vacuum\r\nsolution is physically valid only outside the matter source and is yet\r\nto be matched to the actual solution inside it.\\footnote{The matching\r\n  to a general isolated post-Newtonian matter source in the external\r\n  near zone of this source has been elucidated within this\r\n    formalism in Refs.~\\cite{B95, B98mult, PB02, BFN05}.} Finally, an\r\noperation of taking the finite part (FP), \\textit{i.e.} picking up the\r\nterm with zeroth power of $B$ in the Laurent expansion of the\r\nexpression when $B\\to 0$, is applied. This fully defines the\r\nexpression~\\eqref{un} as a particular solution of $\\Box\r\nu_{\\mathrm{gen}\\,(n)} = \\Lambda_{\\mathrm{gen}\\,(n)}$ everywhere except\r\nat $r=0$.\r\n\r\nThe second term in Eq.~\\eqref{hgenn} ensures that the harmonic gauge\r\ncondition $\\partial_\\beta h^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)}=0$ is\r\nsatisfied. It is algorithmically computed from the divergence of the\r\nfirst term, namely $w^{\\alpha}_{\\mathrm{gen}\\,(n)} \\equiv\r\n\\partial_{\\beta}u^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)}$, which is necessarily a\r\nretarded solution of the source-free d'Alembertian equation, $\\Box\r\nw^{\\alpha}_{\\mathrm{can}\\,(n)}=0$. That solution can thus always be written as\r\n%\r\n\\begin{subequations} \\label{wn}\r\n\\begin{align}\r\nw^0_{\\mathrm{gen}\\,(n)} &= \\sum_{\\ell = 0}^{+\\infty} \\partial_L\r\n\\left[r^{-1} N_L(t_r)\\right] \\,, \\\\ w^i_{\\mathrm{gen}\\,(n)} & =\r\n\\sum_{\\ell =0}^{+\\infty}\\partial_{iL} \\left[ r^{-1} P_L (t_r)\r\n  \\right] \\nonumber \\\\ & + \\sum_{\\ell = 1}^{+\\infty} \\Bigl\\{\r\n\\partial_{L-1} \\left[ r^{-1} Q_{iL-1} (t_r) \\right] +\r\n\\varepsilon_{iab} \\, \\partial_{aL-1} \\left[r^{-1} R_{bL-1} (t_r)\r\n  \\right] \\Bigr\\} \\,,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nwhere the STF multipole moments $\\{N_L, P_L, Q_L, R_L\\}$ are given by\r\nsome (very complicated at high post-Minkowskian orders $n$)\r\nfunctionals of the initial source and gauge moments $\\{I_L, J_L, W_L,\r\nX_L, Y_L, Z_L\\}$. We then pose~\\cite{BD86,B98mult} \r\n%\r\n\\begin{subequations} \\label{vn}\r\n\\begin{align}\r\nv^{00}_{\\mathrm{gen}\\,(n)} &= - c\\, r^{-1} N^{(-1)} + \\partial_a \\left[\r\n  r^{-1} \\left(- c\\, N^{(-1)}_a+ c^2 Q^{(-2)}_a -3P_a\\right) \\right] \\, ,\r\n\\\\ v^{0i}_{\\mathrm{gen}\\,(n)} &= r^{-1} \\left( - c\\, Q^{(-1)}_i +3 c^{-1}\r\nP^{(1)}_i\\right) - \\varepsilon_{iab} \\, \\partial_a \\left[ r^{-1} c\\, \r\n  R^{(-1)}_b \\right] - \\sum_{\\ell = 2}^{+\\infty}\\partial_{L-1} \\left[\r\n  r^{-1} N_{iL-1} \\right] \\, , \\\\ v^{ij}_{\\mathrm{gen}\\,(n)} &= -\r\n\\delta_{ij} r^{-1} P + \\sum_{\\ell = 2}^{+\\infty} \\biggl\\{ 2\r\n\\delta_{ij}\\partial_{L-1} \\left[ r^{-1} P_{L-1}\\right] - 6\r\n\\partial_{L-2(i} \\left[ r^{-1} P_{j)L-2}\\right] \\nonumber \\\\ & \\quad +\r\n\\partial_{L-2} \\left[ r^{-1} (c^{-1}N^{(1)}_{ijL-2} + 3 c^{-2} P^{(2)}_{ijL-2} -\r\n  Q_{ijL-2}) \\right] - 2 \\partial_{aL-2}\\left[ r^{-1}\r\n  \\varepsilon_{ab(i} R_{j)bL-2} \\right] \\biggr\\} \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nIt can readily be checked that $\\partial_\\beta\r\nv^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)}=-w^{\\alpha}_{\\mathrm{gen}\\,(n)}$,\r\nhence $\\partial_\\beta h^{\\alpha\\beta}_{\\mathrm{gen}\\,(n)}=0$. Since we\r\nalso have $\\Box v^{\\alpha\\beta}_{\\mathrm{can}\\,(n)}=0$, we see that\r\nthe $n$-th post-Minkowskian order piece of the gravitational\r\nfield~\\eqref{hgenn} satisfies the relaxed field equations in harmonic\r\ncoordinates at order $n$.  Note the presence in Eqs.~\\eqref{vn} of\r\nanti-derivatives, denoted \\textit{e.g.} $N^{(-1)}$, which are\r\nassociated with the secular losses of energy, linear momentum and\r\nangular momentum of the source through gravitational radiation.\r\n\r\nFinally, we get a full solution of the vacuum Einstein field\r\nequations~\\eqref{EFE}, parametrized by two sets of source moments\r\n$I_L$, $J_L$ and four sets of gauge moments $W_L$, $X_L$, $Y_L$,\r\n$Z_L$, in the form of the post-Minkowskian expansion series\r\n%\r\n\\begin{equation} \\label{PMgen}\r\nh_\\text{gen}^{\\alpha\\beta} = \\sum_{n=1}^{+\\infty} G^n\r\nh_{\\mathrm{gen}\\,(n)}^{\\alpha\\beta}\\bigl[I_L,J_L,W_L,X_L,Y_L,Z_L\\bigr]\\,.\r\n\\end{equation}\r\n%\r\nIt was proved~\\cite{BD86} that this represents physically the most\r\ngeneral solution of the vacuum field equations outside an isolated\r\nmatter system.  Thanks to the matching, all the multipole moments\r\ntherein have been given explicit closed-form expressions as integrals\r\nover the matter and gravitational fields of a general post-Newtonian\r\nsource~\\cite{B98mult, PB02}.\r\n\r\nThe explicit MPM construction leading to Eq.~\\eqref{PMgen} is quite\r\ncomplicated in practice but now entirely performed  on a\r\ncomputer.\\footnote{The MPM algorithm is implemented by using the\r\n  algebraic computing software Mathematica together with the tensor\r\n  package \\textit{xAct}~\\cite{xtensor}.}  It is often convenient to\r\nsimplify it by considering, instead of the six sets of source and\r\ngauge moments, only two, called the \\textit{canonical} mass-type and\r\ncurrent-type multipole moments, $M_L(t)$ and $S_L(t)$\r\nrespectively. Indeed it has been proved~\\cite{Th80, BD86} that the\r\nmost general solution is actually parametrized by two and only two\r\nsets of moments --- by definition these canonical $M_L$ and $S_L$\r\nmoments. The simplest MPM construction, here referred to as\r\n``canonical'', is obtained by annulling all the gauge moments in\r\nEq.~\\eqref{PMgen} and starting with $M_L$, $S_L$ in place of $I_L$,\r\n$J_L$, \\textit{i.e.}\r\n%\r\n\\begin{equation} \\label{PMcan}\r\nh_\\text{can}^{\\alpha\\beta} = \\sum_{n=1}^{+\\infty} G^n\r\nh_{\\mathrm{gen}\\,(n)}^{\\alpha\\beta}\\bigl[M_L,S_L,0,0,0,0\\bigr]\\,.\r\n\\end{equation}\r\n%\r\nThis means that the iteration now begins at linearized order with the\r\nsolution $h_{\\mathrm{can}\\,(1)}[M_L,S_L]$. However, even if we proceed\r\nwith the simpler construction~\\eqref{PMcan}, we still have to relate\r\nthe canonical moments $\\{M_L, S_L\\}$ to the source and gauge moments\r\n$\\{I_L, J_L, W_L, X_L, Y_L, Z_L\\}$, because only the latter are known\r\nas explicit integrals over the matter and gravitational fields of the\r\nsource. To relate these two sets, we impose that the two\r\nconstructions~\\eqref{PMgen} and~\\eqref{PMcan} are to be\r\n\\textit{isometric}, \\textit{i.e.} to differ by a coordinate\r\ntransformation. It can be shown --- see notably Ref.~\\cite{BFIS08} for\r\nan explicit derivation at quadratic order --- that this yields unique\r\nrelations of the type\r\n%\r\n\\begin{subequations}\\label{cangen}\r\n\\begin{align}\r\nM_L &= I_L + \\mathcal{M}_L\\left[I, J, W, X, Y, Z\\right]\\,,\\\\ S_L &=\r\nJ_L + \\mathcal{S}_L\\left[I, J, W, X, Y, Z\\right]\\,,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nwhere $\\mathcal{M}_L$ and $\\mathcal{S}_L$ denote some non-linear\r\nfunctionals of the source and gauge moments that are at least\r\nquadratic and start only at the high order 2.5PN. When the\r\nrelations~\\eqref{cangen} are satisfied, the two sets of moments\r\n$\\{M_L, S_L\\}$ and $\\{I_L, J_L, W_L, X_L, Y_L, Z_L\\}$ describe the\r\nsame physical matter source. We shall give in Sec.~\\ref{sec:cansource}\r\nbelow their most up-to-date explicit forms.\r\n\r\n\\section{The radiative multipole moments}\r\n\\label{sec:rad}\r\n\r\nIn the previous section we reviewed the MPM\r\nsolutions~\\eqref{PMgen}--\\eqref{PMcan}, which are valid all-over the\r\nexterior of the source, in particular at future null\r\ninfinity. However, these solutions exhibit a logarithmic far-zone\r\nstructure $\\sim (\\ln r)^p/r^k$ when expanded as $r\\to +\\infty$ with\r\n$t_r\\equiv t-r/c=\\mathrm{const}$, where $t$ and $r$ refer to the\r\nharmonic coordinates (see also Sec.~\\ref{sec:resum}). This is due to\r\nthe well-known logarithmic deviation of the null cones with respect to\r\nthe retarded cones $t-r/c$ in this coordinate grid. It is thus\r\nconvenient to introduce so-called \\textit{radiative} coordinates $(T,\r\nR)$ such that $T_R\\equiv T-R/c$ is a null coordinate, or becomes\r\nasymptotically null in the limit $R\\to +\\infty$. We then have (with\r\nthe angular coordinates being untouched)\r\n%\r\n\\begin{equation}\\label{TRtr}\r\nT_R = t_r -\\frac{2 G\r\n  M}{c^3}\\ln\\left(\\frac{r}{c b}\\right) +\r\n\\mathcal{O}\\left(\\frac{1}{r}\\right)\\,,\r\n\\end{equation}\r\n%\r\nwhere $M$ is the total mass of the source and $b$ is an arbitrary\r\nconstant time scale, \\textit{a priori} unrelated to the constant $r_0$\r\nintroduced in the MPM regulator~\\eqref{regulator}. In radiative\r\ncoordinates the structure of the expansion when $R\\to +\\infty$ with\r\n$T_R=\\mathrm{const}$ is merely $\\sim 1/R^k$~\\cite{B87}.\r\n\r\nThe STF radiative moments $\\{U_L, V_L\\}$ are then defined from the\r\nleading $1/R$ term of the asymptotic waveform by~\\cite{Th80}\r\n%\r\n\\begin{align} \\label{gijTT}\r\ng_{ij}^\\text{TT} = \\delta_{ij} &+ \\frac{4G}{c^2R}\r\n\\left[\\sum^{+\\infty}_{\\ell=2}\\frac{1}{c^\\ell \\ell !} \\biggl\\{ N_{L-2}\r\n  \\, U_{ijL-2}(T_R) - \\frac{2\\ell}{c(\\ell+1)} \\, N_{aL-2}\r\n  \\,\\varepsilon_{ab(i} \\, V_{j)bL-2}(T_R)\\biggr\\}\\right]^\\text{TT}\r\n\\nonumber\\\\ & + \\mathcal{O}\\left(\\frac{1}{R^2}\\right)\\,,\r\n\\end{align}\r\n%\r\nwhere the superscript TT refers to the usual algebraic\r\ntransverse-traceless projection. Below we shall present (without the\r\nfull derivations) the expressions of the radiative multipole moments\r\nneeded to control the waveform up to order 3.5PN. These results are\r\nobtained by implementing the MPM algorithm reviewed in the previous\r\nsection.\r\n\r\nOur goal being to obtain the radiative moments $\\{U_L, V_L\\}$ as\r\nfunctionals of the source and gauge moments $\\{I_L, J_L, W_L, X_L,\r\nY_L, Z_L\\}$, it is useful to know beforehand which types of\r\ninteractions between any moments $A_J$ and $B_K$ (with $j$ and $k$\r\nindices respectively), among the set of source and gauge moments, are\r\nallowed in a given radiative mass moment $U_L$ or current moment $V_L$\r\nup the 3.5PN order. To answer that question in the case of quadratic\r\ninteractions, say $A_J\\times B_K$ where $A_J, B_K \\in \\{I_L, J_L, W_L,\r\nX_L, Y_L, Z_L\\}$, we have developed some ``selection rules'' following\r\nRefs.~\\cite{BFIS08, FMBI12}. The interactions allowed by those rules\r\nat order 3.5PN are given in Table~\\ref{tab:rules}.\r\n\r\nThe two panels of Table~\\ref{tab:rules} show the maximal number of\r\nindices $\\ell_\\text{max}[A_J, B_K]$ on the mass moment $U_L$ and the\r\ncurrent moment $V_{L}$ (respectively), beyond which $U_L$ or $V_L$\r\ncannot contain products of the two multipole moments $A_J$ and $B_K$\r\nor their time derivatives (or possibly time anti-derivatives) at the\r\n3.5PN order in the waveform. Thus, when $\\ell>\\ell_\\text{max}[A_J,\r\n  B_K]$ we can safely ignore the multipole interaction $A_J\\times B_K$\r\nin $U_L$ or $V_L$ since it will be of higher PN order. When\r\n$\\ell\\leqslant\\ell_\\text{max}[A_J, B_K]$ we can deduce all the\r\npossible relevant interactions $A_J\\times B_K$ by noticing that\r\n$j+k=\\ell_\\text{max}[A_J, B_K]$ if the product $A_J B_K$ has the same\r\nparity as the radiative moment containing the interaction\r\n(\\textit{i.e.} both $A_J$ and $B_K$ are mass moments or both are\r\ncurrent moments in $U_L$; one is a mass moment and the other is a\r\ncurrent moment in $V_L$), and $j+k=\\ell_\\text{max}[A_J, B_K]+1$ in all\r\nother cases.\\footnote{From Eq.~\\eqref{phi1} we see that the gauge\r\n  moments $W_L$, $X_L$ and $Y_L$ have the same parity as the mass\r\n  moment $I_L$, while the gauge moment $Z_L$ has the same parity as\r\n  the current moment $J_L$.} Finally, the case $\\ell_\\text{max}[A_J,\r\n  B_K]<2$ is obviously impossible since radiative moments have at\r\nleast $\\ell=2$. This case is indicated by dashes in the two panels of\r\nTable~\\ref{tab:rules}. We emphasize that the latter rules apply to\r\nquadratic interactions, which are the most tricky to control\r\nthoroughly. In the present paper we shall also need to include some\r\ncubic interactions. These are simpler to look for and will be dealt\r\nwith separately.\r\n%\r\n\\begin{figure}[t]\r\n\\begin{center}\r\n\\begin{tabular}{|l||c|c|c|c|c|c|} \r\n\\hline\r\n$A_J$ & \\multicolumn{6}{c|}{$B_K$} \\\\ \\cline{2-7} %\\hline \\hline \r\n      &$I_K$&$J_K$&$W_K$&$X_K$&$Y_K$&$Z_K$ \\\\ \\hline \r\n$I_J$ &  6  &  4  &  4  &  2 &  4  &  2  \\\\ \\hline\r\n$J_J$ &  4  &  4  &  2  & -- &  2  &  2  \\\\ \\hline\r\n$W_J$ &  4  &  2  &  2  & -- &  2  & --  \\\\ \\hline\r\n$X_J$ &  2  & --  &  -- & -- & --  & --  \\\\ \\hline\r\n$Y_J$ &  4  &  2  &  2  & -- &  2  & --  \\\\ \\hline\r\n$Z_J$ &  2  &  2  &  -- & -- & --  & --  \\\\ \\hline\r\n\\end{tabular}\r\n\\hspace{2cm}\r\n\\begin{tabular}{|l||c|c|c|c|c|c|} \r\n\\hline\r\n$A_J$ & \\multicolumn{6}{c|}{$B_K$} \\\\ \\cline{2-7} %\\hline \\hline \r\n      &$I_K$&$J_K$&$W_K$&$X_K$&$Y_K$&$Z_K$ \\\\ \\hline \r\n$I_J$ &  5  &  5  &  3  &  -- &  3  &  3  \\\\ \\hline\r\n$J_J$ &  5  &  3  &  3  & -- &  3  &  --  \\\\ \\hline\r\n$W_J$ &  3  &  3  &  --  & -- &  --  & --  \\\\ \\hline\r\n$X_J$ &  --  &  --  &  -- & -- & --  & --  \\\\ \\hline\r\n$Y_J$ &  3  &  3  &  --  & -- &  --  & --  \\\\ \\hline\r\n$Z_J$ &  3  &  --  &  -- & -- & --  & --  \\\\ \\hline\r\n\\end{tabular}\t\t\r\n\\caption{Left panel: Values of $\\ell_\\text{max}[A_J,B_K]$ for the mass\r\n  multipole moment $U_L$ at the 3.5PN order for the various possible\r\n  choices of multipole interactions between $A_J$ and $B_K \\in \\{I, J,\r\n  W, X, Y, Z\\}$. Right panel: likewise but for the current multipole\r\n  moment $V_L$. We must have $j+k=\\ell_\\text{max}[A_J, B_K]$ if the\r\n  product $A_J B_K$ has the same parity as the radiative moment\r\n  containing the interaction $A_J\\times B_K$, \\textit{i.e.} both $A_J$\r\n  and $B_K$ belong to $\\{I, W, X, Y\\}$ or both belong to $\\{J, Z\\}$ in\r\n  $U_L$, $A_J$ belongs to $\\{I, W, X, Y\\}$ and $B_K$ belongs to $\\{J,\r\n  Z\\}$ or \\textit{vice-versa} in $V_L$; in all other cases\r\n  $j+k=\\ell_\\text{max}[A_J, B_K]+1$. Impossible (because too low)\r\n  values of $\\ell_\\text{max}[A_J,B_K]$ are indicated by\r\n  dashes.}\\label{tab:rules}\r\n\\end{center}\r\n\\end{figure}\r\n%\r\n\r\n\\subsection{Radiative moments in terms of canonical moments}\r\n\\label{sec:radcan}\r\n\r\nLike in our previous papers~\\cite{BFIS08, FMBI12}, in order to\r\nsimplify the presentation, we shall first present the radiative\r\nmoments $\\{U_L, V_L\\}$ in terms of the canonical moments $\\{M_L,\r\nS_L\\}$, and only in a second stage shall we give the canonical moments\r\nin terms of the set of source and gauge moments $\\{I_L, J_L, W_L, X_L,\r\nY_L, Z_L\\}$. Clearly, the selection rules provided in\r\nTable~\\ref{tab:rules} apply to the full set of quadratic interactions\r\nwith $A_J, B_K \\in \\{I_L, J_L, W_L, X_L, Y_L, Z_L\\}$ as well as to the\r\nrestricted set with $A_J, B_K \\in \\{M_L, S_L\\}$.\r\n\r\nTo display the results, it is also convenient to group the terms in\r\nthe radiative moments $U_L$ and $V_L$ into different types, namely on\r\nthe one hand all the instantaneous terms, and on the other hand the\r\nhereditary terms~\\cite{BD92} which comprise the tails, the\r\ntails-of-tails, and the non-linear memory integrals:\r\n%\r\n\\begin{subequations}\\label{UVL}\r\n\\begin{align}\r\nU_L &= U_L^\\text{inst} + U_L^\\text{tail} + U_L^\\text{tail-tail} +\r\nU_L^\\text{mem} + \\delta U_L\\,,\\\\ V_L &= V_L^\\text{inst} +\r\nV_L^\\text{tail} + V_L^\\text{tail-tail} + V_L^\\text{mem} + \\delta\r\n  V_L\\,.\r\n\\end{align}\\end{subequations}\r\n%\r\nThe terms $\\delta U_L$ and $\\delta V_L$ in the above decomposition represent\r\nthe contributions occuring at 4PN or higher orders in the waveform (generally\r\nwith a more complex non-linear structure), which will be neglected here. Below\r\nwe shall show the formulas needed to complete the waveform including all its\r\nrelevant harmonics up to order 3.5PN. Some of those formulas have already been\r\npartially published in Refs.~\\cite{BFIS08, FMBI12}, but we reproduce them all\r\nin order to be  self-contained for the convenience of the user.\r\n\r\n\\subsubsection{Instantaneous terms}\r\n\\label{sec:inst}\r\n\r\nThese terms, in which by definition all the canonical moments are\r\nevaluated at the current (retarded) time $T_R=T-R/c$, are the most\r\nintricate terms to obtain. For the mass-type moments they are given\r\nby:\r\n%\r\n\\begin{subequations}\r\n\\begin{align}\r\nU_{ij}^\\text{inst} &= M^{(2)}_{ij} \\nonumber \\\\ &+\\frac{G}{\r\n  c^5}\\biggl[ \\frac{1}{ 7}M^{(5)}_{a\\langle i}M_{j\\rangle a} -\r\n  \\frac{5}{7} M^{(4)}_{a\\langle i}M^{(1)}_{j\\rangle a} -\\frac{2}{7}\r\n  M^{(3)}_{a\\langle i}M^{(2)}_{j\\rangle a}\r\n  +\\frac{1}{3}\\varepsilon_{ab\\langle i}M^{(4)}_{j\\rangle\r\n    a}S_{b}\\biggr]\\nonumber \\\\ & + \\frac{G}{c^7} \\bigg[- \\frac{1}{432}\r\n  M_{ab} M_{ijab}^{(7)} + \\frac{1}{432} M_{ab}^{(1)} M_{ijab}^{(6)} -\r\n  \\frac{5}{756} M_{ab}^{(2)} M_{ijab}^{(5)} + \\frac{19}{648}\r\n  M_{ab}^{(3)} M_{ijab}^{(4)} \\nonumber \\\\ & \\quad\\qquad +\r\n  \\frac{1957}{3024} M_{ab}^{(4)} M_{ijab}^{(3)} + \\frac{1685}{1008}\r\n  M_{ab}^{(5)} M_{ijab}^{(2)} + \\frac{41}{28} M_{ab}^{(6)}\r\n  M_{ijab}^{(1)} + \\frac{91}{216} M_{ab}^{(7)} M_{ijab} \\nonumber \\\\ &\r\n  \\quad\\qquad - \\frac{5}{252} M_{ab \\langle i} M_{j \\rangle ab}^{(7)}\r\n  + \\frac{5}{189} M_{ab \\langle i}^{(1)} M_{j \\rangle ab}^{(6)} +\r\n  \\frac{5}{126} M_{ab \\langle i}^{(2)} M_{j \\rangle ab}^{(5)} +\r\n  \\frac{5}{2268} M_{ab \\langle i}^{(3)} M_{j \\rangle ab}^{(4)}\r\n  \\nonumber \\\\ & \\quad\\qquad + \\frac{5}{42} S_a S_{ija}^{(5)} +\r\n  \\frac{80}{63} S_{a \\langle i} S_{j \\rangle a}^{(5)} + \\frac{16}{63}\r\n  S_{a \\langle i}^{(1)} S_{j \\rangle a}^{(4)} - \\frac{64}{63} S_{a\r\n    \\langle i}^{(2)} S_{j \\rangle a}^{(3)} \\nonumber \\\\ & \\quad\\qquad\r\n  + \\varepsilon_{ac \\langle i} \\Big( \\frac{1}{168} S_{j \\rangle\r\n    bc}^{(6)} M_{ab} + \\frac{1}{24} S_{j\\rangle bc}^{(5)} M_{ab}^{(1)}\r\n  + \\frac{1}{28} S_{j \\rangle bc}^{(4)} M_{ab}^{(2)} + \\frac{3}{56}\r\n  S_{j \\rangle bc}^{(2)} M_{ab}^{(4)} \\nonumber \\\\ & \\quad\\qquad\\qquad\r\n  + \\frac{187}{168} S_{j \\rangle bc}^{(1)} M_{ab}^{(5)} +\r\n  \\frac{65}{84} S_{j \\rangle bc} M_{ab}^{(6)} + \\frac{1}{189} M_{j\r\n    \\rangle bc}^{(6)} S_{ab} - \\frac{1}{189} M_{j \\rangle bc}^{(5)}\r\n  S_{ab}^{(1)} \\nonumber \\\\ & \\quad\\qquad\\qquad + \\frac{10}{189} M_{j\r\n    \\rangle bc}^{(4)} S_{ab}^{(2)} + \\frac{32}{189} M_{j \\rangle\r\n    bc}^{(3)} S_{ab}^{(3)} + \\frac{65}{189} M_{j \\rangle bc}^{(2)}\r\n  S_{ab}^{(4)} - \\frac{5}{189} M_{j \\rangle bc}^{(1)} S_{ab}^{(5)}\r\n  \\nonumber\\\\ & \\quad\\qquad\\qquad - \\frac{10}{63} M_{j \\rangle bc}\r\n  S_{ab}^{(6)} - \\frac{1}{6} S_{j \\rangle bc}^{(3)} M_{ab}^{(3)} \\Big)\r\n  \\bigg] \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijk}^\\text{inst} &= M^{(3)}_{ijk} \\nonumber \\\\ & +{G\\over\r\n  c^5}\\bigg[-{4\\over3}M^{(3)}_{a\\langle i}M^{(3)}_{jk\\rangle\r\n    a}-{9\\over4}M^{(4)}_{a\\langle i}M^{(2)}_{jk\\rangle a} +\r\n  {1\\over4}M^{(2)}_{a\\langle i}M^{(4)}_{jk\\rangle a} -\r\n  {3\\over4}M^{(5)}_{a\\langle i}M^{(1)}_{jk\\rangle a} \\nonumber\\\\ &\r\n  \\quad\\qquad +{1\\over4}M^{(1)}_{a\\langle i}M^{(5)}_{jk\\rangle a} +\r\n              {1\\over12}M^{(6)}_{a\\langle i}M_{jk\\rangle a}\r\n              +{1\\over4}M_{a\\langle i}M^{(6)}_{jk\\rangle a}\r\n              \\nonumber\\\\ & \\quad\\qquad +\r\n                          {1\\over5}\\varepsilon_{ab\\langle i}\\bigg(\r\n                          -12S^{(2)}_{ja}M^{(3)}_{k\\rangle\r\n                            b}-8M^{(2)}_{ja}S^{(3)}_{k\\rangle b}\r\n                          -3S^{(1)}_{ja}M^{(4)}_{k\\rangle\r\n                            b}\\nonumber\\\\ & \\quad\\qquad\\qquad\r\n                          -27M^{(1)}_{ja}S^{(4)}_{k\\rangle\r\n                            b}-S_{ja}M^{(5)}_{k\\rangle\r\n                            b}-9M_{ja}S^{(5)}_{k\\rangle b}\r\n                          -{9\\over4}S_{a}M^{(5)}_{jk\\rangle b}\\bigg)\r\n                          +{12\\over5}S_{\\langle\r\n                            i}S^{(4)}_{jk\\rangle}\\bigg]\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijkl}^\\text{inst} &= M^{(4)}_{ijkl} \\nonumber \\\\ &+ {G\\over c^3}\r\n\\bigg[ -{21\\over5}M^{(5)}_{\\langle ij}M_{kl\\rangle }- {63\r\n    \\over5}M^{(4)}_{\\langle ij}M^{(1)}_{kl\\rangle }-\r\n  {102\\over5}M^{(3)}_{\\langle ij}M^{(2)}_{kl\\rangle }\\bigg] \\nonumber\r\n\\\\ &+\\frac{G}{c^5} \\bigg[ \\frac{7}{55} M_{a \\langle i} M_{jkl \\rangle\r\n    a}^{(7)} + \\frac{7}{55} M_{a \\langle i}^{(1)} M_{jkl \\rangle\r\n    a}^{(6)} + \\frac{1}{25} M_{a \\langle i}^{(2)} M_{jkl \\rangle\r\n    a}^{(5)} - \\frac{28}{11} M_{a \\langle i}^{(3)} M_{jkl \\rangle\r\n    a}^{(4)} \\nonumber \\\\ & \\quad\\qquad - \\frac{273}{55} M_{a \\langle\r\n    i}^{(4)} M_{jkl \\rangle a}^{(3)} - \\frac{203}{55} M_{a \\langle\r\n    i}^{(5)} M_{jkl \\rangle a}^{(2)} - \\frac{49}{55} M_{a \\langle\r\n    i}^{(6)} M_{jkl \\rangle a}^{(1)} + \\frac{14}{275} M_{a \\langle\r\n    i}^{(7)} M_{jkl \\rangle a} \\nonumber \\\\ & \\quad\\qquad +\r\n  \\frac{14}{33} M_{a \\langle ij} M_{kl \\rangle a}^{(7)} +\r\n  \\frac{37}{33} M_{a \\langle ij}^{(1)} M_{kl \\rangle a}^{(6)} +\r\n  \\frac{9}{11} M_{a \\langle ij}^{(2)} M_{kl \\rangle a}^{(5)} +\r\n  \\frac{8}{33} M_{a \\langle ij}^{(3)} M_{kl \\rangle a}^{(4)} +\r\n  \\frac{9}{5} S_{\\langle i} S_{jkl \\rangle}^{(5)} \\nonumber \\\\ &\r\n  \\quad\\qquad + \\frac{16}{5} S_{\\langle ij} S_{kl \\rangle}^{(5)} +\r\n  \\frac{48}{5} S_{\\langle ij}^{(1)} S_{kl \\rangle}^{(4)} +\r\n  \\frac{32}{5} S_{\\langle ij}^{(2)} S_{kl \\rangle}^{(3)} \\nonumber\r\n  \\\\ & \\quad\\qquad + \\varepsilon_{ab \\langle i} \\Big(- \\frac{3}{5}\r\n  M_{j\\underline{a}} S_{kl \\rangle b}^{(6)} - \\frac{63}{25}\r\n  M_{j\\underline{a}}^{(1)} S_{kl \\rangle b}^{(5)} + \\frac{3}{5}\r\n  M_{j\\underline{a}}^{(2)} S_{kl \\rangle b}^{(4)} + \\frac{18}{5}\r\n  M_{j\\underline{a}}^{(3)} S_{kl \\rangle b}^{(3)} \\nonumber \\\\ &\r\n  \\quad\\qquad\\qquad + \\frac{9}{5} M_{j\\underline{a}}^{(4)} S_{kl\r\n    \\rangle b}^{(2)} + \\frac{3}{5} M_{j\\underline{a}}^{(5)} S_{kl\r\n    \\rangle b}^{(1)} + \\frac{3}{25} M_{j\\underline{a}}^{(6)} S_{kl\r\n    \\rangle b} - \\frac{8}{15} S_{j\\underline{a}} M_{kl \\rangle\r\n    b}^{(6)} - \\frac{24}{25} S_{j\\underline{a}}^{(1)} M_{kl \\rangle\r\n    b}^{(5)} \\nonumber \\\\ & \\quad\\qquad\\qquad - \\frac{8}{5}\r\n  S_{j\\underline{a}}^{(2)} M_{kl \\rangle b}^{(4)} + \\frac{16}{3}\r\n  S_{j\\underline{a}}^{(3)} M_{kl \\rangle b}^{(3)} + \\frac{72}{5}\r\n  S_{j\\underline{a}}^{(4)} M_{kl \\rangle b}^{(2)} + \\frac{56}{5}\r\n  S_{j\\underline{a}}^{(5)} M_{kl \\rangle b}^{(1)} \\nonumber \\\\ &\r\n  \\quad\\qquad\\qquad + \\frac{232}{75} S_{j\\underline{a}}^{(6)} M_{kl\r\n    \\rangle b} + \\frac{29}{75} M_{jkl \\rangle a}^{(6)} S_b \\Big)\r\n  \\bigg] \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijklm}^\\text{inst} &= M^{(5)}_{ijklm} \\nonumber \\\\ &+ {G\\over\r\n  c^3}\\bigg[ -{710\\over21}M^{(3)}_{\\langle\r\n    ij}M^{(3)}_{klm\\rangle}-{265\\over7}M^{(2)}_{\\langle\r\n    ijk}M^{(4)}_{lm\\rangle} -{120\\over7}M^{(2)}_{\\langle\r\n    ij}M^{(4)}_{klm\\rangle}\\nonumber\\\\ & \\quad\\qquad\r\n  -{155\\over7}M^{(1)}_{\\langle\r\n    ijk}M^{(5)}_{lm\\rangle}-{41\\over7}M^{(1)}_{\\langle\r\n    ij}M^{(5)}_{klm\\rangle} -{34\\over7}M_{\\langle\r\n    ijk}M^{(6)}_{lm\\rangle}-{15\\over7}M_{\\langle\r\n    ij}M^{(6)}_{klm\\rangle}\\bigg]\\,,\\label{U5}\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijklmn}^\\text{inst} &= M^{(6)}_{ijklmn} \\nonumber \\\\ &+\r\n\\frac{G}{c^3} \\bigg[ - \\frac{45}{28} M_{\\langle ij} M_{klmn\r\n    \\rangle}^{(7)} - \\frac{111}{28} M_{\\langle ij}^{(1)} M_{klmn\r\n    \\rangle}^{(6)} - \\frac{561}{28} M_{\\langle ij}^{(2)} M_{klmn\r\n    \\rangle}^{(5)} \\nonumber \\\\ & \\quad\\qquad - \\frac{1595}{28}\r\n  M_{\\langle ij}^{(3)} M_{klmn \\rangle}^{(4)} - \\frac{2505}{28}\r\n  M_{\\langle ij}^{(4)} M_{klmn \\rangle}^{(3)} - \\frac{2115}{28}\r\n  M_{\\langle ij}^{(5)} M_{klmn \\rangle}^{(2)} \\nonumber \\\\ &\r\n  \\quad\\qquad - \\frac{909}{28} M_{\\langle ij}^{(6)} M_{klmn\r\n    \\rangle}^{(1)} - \\frac{159}{28} M_{\\langle ij}^{(7)} M_{klmn\r\n    \\rangle} - \\frac{15}{7} M_{\\langle ijk} M_{lmn \\rangle}^{(7)} -\r\n  \\frac{75}{7} M_{\\langle ijk}^{(1)} M_{lmn \\rangle}^{(6)} \\nonumber\r\n  \\\\ & \\quad\\qquad - \\frac{135}{7} M_{\\langle ijk}^{(2)} M_{lmn\r\n    \\rangle}^{(5)} - \\frac{505}{21} M_{\\langle ijk}^{(3)} M_{lmn\r\n    \\rangle}^{(4)} \\bigg] \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nIn the above expressions, the $1/c^5$ terms in $U_{ijkl}^\\text{inst}$\r\nand $1/c^3$ terms in $U_{ijklmn}^\\text{inst}$ are new with the present\r\npaper; the other terms were obtained in\r\nRefs.~\\cite{BFIS08,FMBI12}. For the current-type moments we have:\r\n%\r\n\\begin{subequations}\r\n\\begin{align}\r\n  V_{ij}^\\text{inst} &= S^{(2)}_{ij} \\nonumber \\\\ & +\r\n  {G\\over7\\,c^{5}}\\bigg[4S^{(2)}_{a\\langle i}M^{(3)}_{j\\rangle\r\n      a}+8M^{(2)}_{a\\langle i}S^{(3)}_{j\\rangle a}\r\n    +17S^{(1)}_{a\\langle i}M^{(4)}_{j\\rangle a}-3M^{(1)}_{a\\langle\r\n      i}S^{(4)}_{j\\rangle a}+9S_{a\\langle i}M^{(5)}_{j\\rangle\r\n      a}\\nonumber\\\\ & \\quad\\qquad -3M_{a\\langle i}S^{(5)}_{j\\rangle\r\n      a}-{1\\over4}S_{a}M^{(5)}_{ija}-7\\varepsilon_{ab\\langle\r\n      i}S_{a}S^{(4)}_{j\\rangle b} +{1\\over2}\\varepsilon_{ac\\langle\r\n      i}\\bigg(3M^{(3)}_{ab}M^{(3)}_{j\\rangle bc}\r\n    +{353\\over24}M^{(2)}_{j\\rangle bc}M^{(4)}_{ab}\\nonumber\\\\ &\r\n    \\quad\\qquad -{5\\over12}M^{(2)}_{ab}M^{(4)}_{j\\rangle\r\n      bc}+{113\\over8}M^{(1)}_{j\\rangle bc}M^{(5)}_{ab}\r\n    -{3\\over8}M^{(1)}_{ab}M^{(5)}_{j\\rangle bc}+{15\\over4}M_{j\\rangle\r\n      bc}M^{(6)}_{ab} +{3\\over8}M_{ab}M^{(6)}_{j\\rangle\r\n      bc}\\bigg)\\bigg]\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nV_{ijk}^\\text{inst} &= S^{(3)}_{ijk} \\nonumber \\\\ &+ {G\\over c^3}\r\n\\bigg[ {1\\over10}\\varepsilon_{ab\\langle i}M^{(5)}_{ja}M_{k\\rangle b}-\r\n  {1\\over2}\\varepsilon_{ab\\langle i}M^{(4)}_{ja}M^{(1)}_{k\\rangle b} -\r\n  2 S_{\\langle i}M^{(4)}_{jk\\rangle } \\bigg] \\nonumber \\\\ &+\r\n\\frac{G}{c^5} \\bigg[ \\frac{1}{12} M_{a \\langle i} S_{jk \\rangle\r\n    a}^{(6)} + \\frac{1}{12} M_{a \\langle i}^{(1)} S_{jk \\rangle\r\n    a}^{(5)} + \\frac{5}{12} M_{a \\langle i}^{(2)} S_{jk \\rangle\r\n    a}^{(4)} + \\frac{35}{12} M_{a \\langle i}^{(4)} S_{jk \\rangle\r\n    a}^{(2)} + \\frac{49}{12} M_{a \\langle i}^{(5)} S_{jk \\rangle\r\n    a}^{(1)} \\nonumber \\\\ & \\quad\\qquad + \\frac{19}{12} M_{a \\langle\r\n    i}^{(6)} S_{jk \\rangle a} + \\frac{2}{27} S_{a \\langle i} M_{jk\r\n    \\rangle a}^{(6)} + \\frac{10}{27} S_{a \\langle i}^{(1)} M_{jk\r\n    \\rangle a}^{(5)} + \\frac{2}{27} S_{a \\langle i}^{(2)} M_{jk\r\n    \\rangle a}^{(4)} + \\frac{8}{9} S_{a \\langle i}^{(3)} M_{jk \\rangle\r\n    a}^{(3)} \\nonumber \\\\ & \\quad\\qquad - \\frac{10}{27} S_{a \\langle\r\n    i}^{(4)} M_{jk \\rangle a}^{(2)} - \\frac{38}{27} S_{a \\langle\r\n    i}^{(5)} M_{jk \\rangle a}^{(1)} - \\frac{2}{3} S_{a \\langle\r\n    i}^{(6)} M_{jk \\rangle a} - \\frac{1}{60} S_a M_{ijka}^{(6)}\r\n  \\nonumber \\\\ & \\quad\\qquad + \\varepsilon_{ab \\langle i} \\bigg(-\r\n  \\frac{1}{180} M_{jk \\rangle ac}^{(7)} M_{bc} + \\frac{11}{900} M_{jk\r\n    \\rangle ac}^{(6)} M_{bc}^{(1)} + \\frac{7}{300} M_{jk \\rangle\r\n    ac}^{(5)} M_{bc}^{(2)} \\nonumber \\\\ & \\quad\\qquad\\qquad -\r\n  \\frac{37}{270} M_{jk \\rangle ac}^{(4)} M_{bc}^{(3)} -\r\n  \\frac{191}{180} M_{jk \\rangle ac}^{(3)} M_{bc}^{(4)} - \\frac{65}{36}\r\n  M_{jk \\rangle ac}^{(2)} M_{bc}^{(5)} - \\frac{367}{300} M_{jk \\rangle\r\n    ac}^{(1)} M_{bc}^{(6)} \\nonumber \\\\ & \\quad\\qquad\\qquad -\r\n  \\frac{133}{450} M_{jk \\rangle ac} M_{bc}^{(7)} + \\frac{1}{27} M_{j\r\n    \\underline{ac}} M_{k \\rangle bc}^{(7)} + \\frac{5}{162}\r\n  M_{j\\underline{ac}}^{(1)} M_{k \\rangle bc}^{(6)} - \\frac{5}{162}\r\n  M_{j\\underline{ac}}^{(2)} M_{k \\rangle bc}^{(5)} \\nonumber \\\\ &\r\n  \\nonumber \\quad\\qquad\\qquad - \\frac{1}{81} M_{j\\underline{ac}}^{(3)}\r\n  M_{k \\rangle bc}^{(4)} - \\frac{11}{20} S_{jk \\rangle b}^{(5)} S_a -\r\n  \\frac{88}{45} S_{j \\underline{a}} S_{k \\rangle b}^{(5)} -\r\n  \\frac{40}{9} S_{j\\underline{a}}^{(1)} S_{k \\rangle b}^{(4)}\r\n  \\nonumber \\\\ & \\nonumber \\quad\\qquad\\qquad - \\frac{32}{9}\r\n  S_{j\\underline{a}}^{(2)} S_{k \\rangle b}^{(3)} \\bigg)\\bigg] \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nV_{ijkl}^\\text{inst} &= S^{(4)}_{ijkl} \\nonumber \\\\ &+ {G\\over\r\n  c^3}\\bigg[- {35\\over3}S^{(2)}_{\\langle\r\n    ij}M^{(3)}_{kl\\rangle}-{25\\over3}M^{(2)}_{\\langle\r\n    ij}S^{(3)}_{kl\\rangle} -{65\\over6}S^{(1)}_{\\langle\r\n    ij}M^{(4)}_{kl\\rangle}-{25\\over6}M^{(1)}_{\\langle\r\n    ij}S^{(4)}_{kl\\rangle} -{19\\over6}S_{\\langle\r\n    ij}M^{(5)}_{kl\\rangle}\\nonumber\\\\ & \\quad\\qquad\r\n  -{11\\over6}M_{\\langle ij}S^{(5)}_{kl\\rangle}-{11\\over12}S_{\\langle\r\n    i}M^{(5)}_{jkl\\rangle} +{1\\over6}\\varepsilon_{ab\\langle\r\n    i}\\bigg(-5M^{(3)}_{ja}M^{(3)}_{kl\\rangle b}\r\n  -{11\\over2}M^{(4)}_{ja}M^{(2)}_{kl\\rangle b}\r\n  -{5\\over2}M^{(2)}_{ja}M^{(4)}_{kl\\rangle b}\\nonumber\\\\ & \\quad\\qquad\r\n  -{1\\over2}M^{(5)}_{ja}M^{(1)}_{kl\\rangle b}\r\n  +{37\\over10}M^{(1)}_{ja}M^{(5)}_{kl\\rangle b}\r\n  +{3\\over10}M^{(6)}_{ja}M_{kl\\rangle\r\n    b}+{1\\over2}M_{ja}M^{(6)}_{kl\\rangle b}\\bigg)\\bigg] \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nV_{ijklm}^\\text{inst} &= S^{(5)}_{ijklm} \\nonumber \\\\ &+ \\frac{G}{c^3}\r\n\\bigg[- \\frac{3}{2} M_{\\langle ij} S_{klm \\rangle}^{(6)} -\r\n  \\frac{33}{10} M_{\\langle ij}^{(1)} S_{klm \\rangle}^{(5)} - 12\r\n  M_{\\langle ij}^{(2)} S_{klm \\rangle}^{(4)} - 27 M_{\\langle ij}^{(3)}\r\n  S_{klm \\rangle}^{(3)} \\nonumber \\\\ & \\quad\\qquad - \\frac{69}{2}\r\n  M_{\\langle ij}^{(4)} S_{klm \\rangle}^{(2)} - \\frac{39}{2} M_{\\langle\r\n    ij}^{(5)} S_{klm \\rangle}^{(1)} - \\frac{21}{5} M_{\\langle\r\n    ij}^{(6)} S_{klm \\rangle} - \\frac{4}{3} S_{\\langle ij} M_{klm\r\n    \\rangle}^{(6)} \\nonumber \\\\ & \\quad\\qquad - \\frac{76}{15}\r\n  S_{\\langle ij}^{(1)} M_{klm \\rangle}^{(5)} - \\frac{16}{3} S_{\\langle\r\n    ij}^{(2)} M_{klm \\rangle}^{(4)} - 8 S_{\\langle ij}^{(3)} M_{klm\r\n    \\rangle}^{(3)} - \\frac{28}{3} S_{\\langle ij}^{(4)} M_{klm\r\n    \\rangle}^{(2)} \\nonumber \\\\ & \\quad\\qquad - \\frac{20}{3}\r\n  S_{\\langle ij}^{(5)} M_{klm \\rangle}^{(1)} - \\frac{8}{5} S_{\\langle\r\n    ij}^{(6)} M_{klm \\rangle} - \\frac{3}{5} S_{\\langle i} M_{jklm\r\n    \\rangle}^{(6)} \\nonumber \\\\ & \\quad\\qquad + \\varepsilon_{ab\r\n    \\langle i} \\Big( \\frac{1}{14} M_{j\\underline{a}} M_{klm \\rangle\r\n    b}^{(7)} + \\frac{1}{2} M_{j\\underline{a}}^{(1)} M_{klm \\rangle\r\n    b}^{(6)} - \\frac{3}{5} M_{j\\underline{a}}^{(2)} M_{klm \\rangle\r\n    b}^{(5)} - \\frac{4}{3} M_{j\\underline{a}}^{(3)} M_{klm \\rangle\r\n    b}^{(4)} \\nonumber \\\\ & \\quad\\qquad\\qquad - \\frac{3}{2}\r\n  M_{j\\underline{a}}^{(4)} M_{klm \\rangle b}^{(3)} - \\frac{1}{2}\r\n  M_{j\\underline{a}}^{(5)} M_{klm \\rangle b}^{(2)} + \\frac{1}{35}\r\n  M_{j\\underline{a}}^{(7)} M_{klm \\rangle b} + \\frac{1}{7}\r\n  M_{jk\\underline{a}} M_{lm \\rangle b}^{(7)} \\nonumber \\\\ &\r\n  \\quad\\qquad\\qquad + \\frac{2}{3} M_{jk\\underline{a}}^{(1)} M_{lm\r\n    \\rangle b}^{(6)} + \\frac{4}{3} M_{jk\\underline{a}}^{(2)} M_{lm\r\n    \\rangle b}^{(5)} + \\frac{1}{3} M_{jk \\underline{a}}^{(3)} M_{lm\r\n    \\rangle b}^{(4)} \\Big) \\bigg] \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nIn the  expressions for the current moments above, the $1/c^5$ terms in\r\n$V_{ijk}^\\text{inst}$ and the $1/c^3$ terms in $V_{ijklm}^\\text{inst}$\r\nare new with this paper. For all higher multipole moments it\r\n  suffices, at this approximation level, to replace $U_L^\\text{inst}$ and\r\n  $V_L^\\text{inst}$ by the corresponding $M^{(\\ell)}_L$ and\r\n  $S^{(\\ell)}_L$.\r\n\r\n\\subsubsection{Tail terms}\r\n\\label{sec:tail}\r\n\r\nNext we give the contributions due to tails which correspond to\r\nquadratic interactions and arise at (relative) order 1.5PN. They come\r\nfrom the interaction between the mass monopole $M$ and a non-static\r\nmultipole $M_L$ or $S_L$ (with $\\ell\\geqslant 2$). For these we\r\ndispose of a general formula valid for any $\\ell$~\\cite{BD92,\r\n  B95}. The following contributions have to be added to any mass and\r\ncurrent multipole moments:\r\n%\r\n\\begin{subequations}\r\n\\begin{align}\r\nU_L^\\text{tail}(T_R) &= \\frac{2 G M}{c^3} \\int_{-\\infty}^{T_R}\r\nM_L^{(\\ell+2)} (\\tau) \\bigg[ \\ln\\bigg(\\frac{T_R-\\tau}{2b}\\bigg) +\r\n  \\kappa_\\ell \\bigg] \\ud \\tau \\,,\\\\ V_L^\\text{tail}(T_R) &=\r\n\\frac{2 G M}{c^3} \\int_{-\\infty}^{T_R} S_L^{(\\ell+2)} (\\tau) \\bigg[\r\n  \\ln \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) + \\pi_\\ell \\bigg] \\ud \\tau\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nHere the constant $b$ entering the logarithmic kernel is the constant\r\ntime scale that has been introduced into the relation~\\eqref{TRtr}\r\nbetween the retarded time $T_R$ in radiative coordinates and the\r\nretarded time $t_r$ in harmonic coordinates. The numerical constants\r\n$\\kappa_\\ell$ and $\\pi_\\ell$ are given for general $\\ell$, in\r\n\\textit{harmonic coordinates}, by\r\n%\r\n\\begin{equation}\\label{pikappa}\r\n    \\kappa_\\ell = \\frac{2\\ell^2+5\\ell+4}{\\ell(\\ell+1)(\\ell+2)} +\r\n    H_{\\ell-2}\\,,\\qquad \\pi_\\ell = \\frac{\\ell-1}{\\ell(\\ell+1)} +\r\n    H_{\\ell-1}\\,,\r\n\\end{equation}\r\n%\r\nwhere $H_k \\equiv \\sum_{j=1}^k \\frac{1}{j}$ denotes the $k$-th\r\nharmonic number.\r\n\r\n\\subsubsection{Tail-of-tail terms}\r\n\\label{sec:tail2}\r\n\r\nThe tails-of-tails arise at relative order 3PN and are due to the\r\ncubic interaction between two monopoles $M$ and one non-static\r\nmultipole, \\textit{i.e.} $M\\times M\\times M_L$ or $M\\times M\\times\r\nS_L$. The tail-of-tail entering the mass quadrupole moment has been\r\nalready computed in Ref.~\\cite{B98tail}. Those in the mass octupole\r\nand current quadrupole moments, new with this paper, have been\r\nobtained by the same method. The relevant formulas to integrate the\r\nelementary cubic source terms are presented in\r\nAppendix~\\ref{app:cubic_integrals}. We find\r\n%\r\n\\begin{subequations}\\label{tailtail}\r\n\\begin{align}\r\nU_{ij}^\\text{tail-tail}(T_R) &= \\frac{G^2 M^2}{c^6}\r\n\\int_{-\\infty}^{T_R} M_{ij}^{(5)}(\\tau) \\bigg[2 \\ln^2\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) + \\frac{11}{3} \\ln\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) \\nonumber \\\\ & \\qquad\\qquad\\quad -\r\n  \\frac{214}{105}\\ln \\bigg(\\frac{T_R-\\tau}{2\\tau_0}\\bigg) +\r\n  \\frac{124627}{22050}\\bigg] \\ud \\tau \\,,\\label{tailtailU2}\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijk}^\\text{tail-tail}(T_R) &= \\frac{G^2 M^2}{c^6} \r\n\\int_{-\\infty}^{T_R} M_{ijk}^{(6)}(\\tau) \\bigg[2 \\ln^2\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) + \\frac{97}{15} \\ln\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) \\nonumber \\\\ & \\qquad\\qquad\\quad -\r\n  \\frac{26}{21} \\ln \\bigg(\\frac{T_R-\\tau}{2\\tau_0}\\bigg) +\r\n  \\frac{13283}{4410}\\bigg] \\ud \\tau \\,,\\label{tailtailU3}\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nV_{ij}^\\text{tail-tail}(T_R) &= \\frac{G^2 M^2}{c^6} \r\n\\int_{-\\infty}^{T_R} J_{ij}^{(5)}(\\tau) \\bigg[2 \\ln^2\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) + \\frac{14}{3} \\ln\r\n  \\bigg(\\frac{T_R-\\tau}{2b} \\bigg) \\nonumber \\\\ & \\qquad\\qquad\\quad -\r\n  \\frac{214}{105} \\ln \\bigg(\\frac{T_R-\\tau}{2\\tau_0}\\bigg) -\r\n  \\frac{26254}{11025}\\bigg] \\ud \\tau \\,.\\label{tailtailV2}\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\n\r\nNote the appearance of two constant time scales there: (i) The time\r\nscale $b$, which is a pure gauge constant entering the definition of\r\nthe particular radiative coordinates used in\r\nEq.~\\eqref{TRtr}. Changing $b$ simply means shifting the origin of\r\ntime of the radiative coordinate system $(T,X^i=R N^i)$ with respect\r\nto the harmonic coordinate grid $(t,x^i = r n^i)$, which has clearly\r\nno physical implication. (ii) The time scale $\\tau_0=r_0/c$, where\r\n$r_0$ is the regularization constant introduced in the\r\nregulator~\\eqref{regulator} of the MPM algorithm;\\footnote{When\r\n  studying the case of the mass quadrupole tail-of-tail in\r\n  Ref.~\\cite{B98tail}, the choice $b=\\tau_0$ was adopted.} the\r\nconstant $\\tau_0$ cannot be removed by a coordinate transformation,\r\nbut it must disappear from the radiative moments (and hence from the\r\nphysical waveform) once the \\textit{source} moments are explicitly\r\nrelated to the parameters of the matter source, \\textit{e.g.} the\r\nmasses, trajectories and velocities of the particles in a binary\r\nsystem. This has been verified explicitly in the case of the 3PN mass\r\nquadrupole moment in Refs.~\\cite{BIJ02, BI04mult}. In\r\nSec.~\\eqref{sec:octupole} below we shall check the cancellation of\r\n$\\tau_0$ in the case of the 3PN mass octupole moment as well.\r\n\r\nAccordingly, there are two types of logarithms in the kernels of\r\nEqs.~\\eqref{tailtail}: those containing $b$ and those containing\r\n$\\tau_0$. The coefficient of the leading logarithm square (which\r\ncontains $b$) is always 2.  We also know the coefficient of the\r\nlogarithm containing $\\tau_0$ in the case of mass-type moments for\r\ngeneral $\\ell$. Indeed, the coefficient of $\\ln\\tau_0$ in the\r\ntails-of-tails associated with mass multipole moments, resulting from\r\nthe long computation of the multipole interactions $M\\times M\\times\r\nM_L$, is given by Eq.~(A6) in Ref.~\\cite{BD88} as\r\n%\r\n\\begin{equation}\\label{alphaell}\r\n\\alpha_\\ell = 2\\frac{15\\ell^4+30\\ell^3 +\r\n  28\\ell^2+13\\ell+24}{\\ell(\\ell+1)(2\\ell+3)(2\\ell+1)(2\\ell-1)}\\,.\r\n\\end{equation}\r\n%\r\nThus, we have $\\alpha_2=214/105$ and $\\alpha_3=26/21$ in agreement\r\nwith the coefficients displayed in Eqs.~\\eqref{tailtailU2}\r\nand~\\eqref{tailtailU3}. We shall come back on the significance of this\r\nresult in Sec.~\\eqref{sec:octupole} when we check that the value\r\n$\\alpha_3=26/21$ is fully consistent with our 3PN computation of the\r\nsource mass octupole moment $I_{ijk}$ for compact binaries [see\r\n  Eqs.~\\eqref{lnr0}--\\eqref{tailtaillnr0}]. In Sec.~\\ref{sec:resum} we\r\nshall investigate the occurence of the dominant powers of logarithms\r\nfor more general tail interactions of the type $M\\times \\cdots \\times\r\nM \\times (M_L$ or $S_L)$.\r\n\r\n\\subsubsection{Memory terms}\r\n\\label{sec:mem}\r\n\r\nThe contributions coming from the non-linear memory effect arise from\r\nquadratic interactions between two radiative moments. They have been\r\ncomputed in Refs.~\\cite{B90, Chr91, WW91, Th92, BD92, B98quad} in the\r\nmass quadrupole moment at the lowest order, which is 2.5PN. More\r\nrecently, the 3.5PN corrections beyond leading order have been\r\nobtained for both circular~\\cite{F09} and eccentric\r\norbits~\\cite{F11}. Note that the non-linear memory effect does not\r\nenter the current-type multipole moments $V_L$, but only the mass-type\r\nmultipole moments $U_L$, hence $V_L^{\\text{mem}}=0$. Its contribution\r\nto the mass radiative moments needed for the 3.5PN waveform read\r\n%\r\n\\begin{subequations}\r\n\\begin{align}\r\nU_{ij}^{\\text{mem}}(T_R) &= \\frac{G}{c^5}\\int_{-\\infty}^{T_R}\r\n\\biggl[-\\frac{2}{7}M^{(3)}_{a\\langle i}(\\tau)\\,M^{(3)}_{j\\rangle\r\n    a}(\\tau) \\biggr]\\ud \\tau\\nonumber \\\\ &+ \\frac{G}{c^7}\r\n\\int_{-\\infty }^{T_R} \\bigg[- \\frac{5}{756} M_{ab}^{(4)} (\\tau)\r\n  M_{ijab}^{(4)}(\\tau)-\\frac{32}{63} S_{a \\langle i}^{(3)} (\\tau) S_{j\r\n    \\rangle a}^{(3)} (\\tau) \\nonumber \\\\ &\\qquad + \\varepsilon_{ab\r\n    \\langle i} \\bigg( \\frac{5}{42} S_{j \\rangle bc}^{(4)} (\\tau)\r\n  M_{ac}^{(3)} (\\tau) - \\frac{20}{189} M_{j \\rangle bc}^{(4)} (\\tau)\r\n  S_{ac}^{(3)} (\\tau) \\bigg) \\bigg] \\ud \\tau \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijk}^\\text{mem}(T_R) &= {G\\over c^5} \\int_{-\\infty}^{T_R}\r\n\\bigg[-{1\\over3}M^{(3)}_{a\\langle i} (\\tau)M^{(4)}_{jk\\rangle a}\r\n(\\tau)-{4\\over5}\\varepsilon_{ab\\langle i} M^{(3)}_{ja} (\\tau)S^{(3)}_{k\\rangle\r\nb} (\\tau)\\bigg]\\ud \\tau \\,,\\\\ \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijkl}^\\text{mem}(T_R) &= \\frac{G}{c^3}\\int_{-\\infty}^{T_R}\r\n\\bigg[{2\\over5} M^{(3)}_{\\langle ij}(\\tau)M^{(3)}_{kl\\rangle\r\n  }(\\tau)\\bigg]\\ud\\tau \\nonumber \\\\ &+ \\frac{G}{c^5}\r\n  \\int_{-\\infty}^{T_R} \\bigg[ \\frac{12}{55} M_{a \\langle i}^{(4)}\r\n    (\\tau) M_{jkl \\rangle a}^{(4)}(\\tau) - \\frac{14}{99} M_{a \\langle\r\n      ij}^{(4)}(\\tau) M_{kl \\rangle a}^{(4)} (\\tau) + \\frac{32}{45}\r\n    S_{\\langle ij}^{(3)}(\\tau) S_{kl \\rangle}^{(3)} (\\tau) \\nonumber\r\n    \\\\ &\\qquad + \\varepsilon_{ab \\langle i} \\bigg(- \\frac{4}{5} M_{j\r\n      \\underline{a}}^{(3)}(\\tau) S_{kl \\rangle b}^{(4)} (\\tau) +\r\n    \\frac{32}{45} S_{j \\underline{a}}^{(3)}(\\tau) M_{kl \\rangle\r\n      b}^{(4)}(\\tau) \\bigg) \\bigg] \\ud \\tau \\,,\\\\ \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijklm}^\\text{mem}(T_R) &= \\frac{G}{c^3}\\int_{-\\infty}^{T_R}\r\n\\bigg[{20\\over21} M^{(3)}_{\\langle\r\n    ij}(\\tau)M^{(4)}_{klm\\rangle}(\\tau)\\bigg]\\ud\\tau \\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nU_{ijklmn}^\\text{mem}(T_R) &= \\frac{G}{c^3} \\int_{-\\infty}^{T_R}\\bigg[\r\n  \\frac{5}{7} M_{\\langle ijk}^{(4)} (\\tau) M_{lmn \\rangle}^{(4)}\r\n  (\\tau) - \\frac{15}{14} M_{\\langle ij}^{(4)} (\\tau) M_{klmn\r\n    \\rangle}^{(4)} (\\tau) \\bigg] \\ud \\tau \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nIn fact, the non-linear memory terms are known for any multipolar\r\norder $\\ell$~\\cite{F09}; the above expressions are a particular case\r\nof the general formula given for completeness in\r\nAppendix~\\ref{app:memory_modes}, in which we also present the\r\ncorresponding modal decomposition of the non-linear memory.\r\n\r\n\\subsection{Canonical moments in terms of source moments}\r\n\\label{sec:cansource}\r\n\r\nAdding up all the previous contributions in Eqs.\\eqref{UVL} we obtain\r\nthe radiative mass and current moments $\\{U_L, V_L\\}$ as full\r\nfunctionals of the canonical moments $\\{M_L, S_L\\}$ consistently with\r\nour 3.5PN goal. However there still remains to relate with that same\r\nprecision the canonical moments to the actual sets of source moments\r\n$\\{I_L, J_L\\}$ and gauge moments $\\{W_L, X_L, Y_L, Z_L\\}$ as shown\r\nschematically in Eqs.~\\eqref{cangen}. Here we present the most\r\ncomplete up-to-date results, with some repetition (for the sake of\r\nexhaustiveness) with respect to Refs.~\\cite{BFIS08, FMBI12}:\r\n%\r\n\\begin{subequations}\\label{cansourceMS}\r\n\\begin{align}  \r\nM_{ij} &= I_{ij} +\\frac{4G}{c^5}\r\n\\left[W^{(2)}I_{ij}-W^{(1)}I_{ij}^{(1)}\\right] \\nonumber\\\\ &+\r\n\\frac{4G}{c^7} \\biggl[ - 2 X I_{ij}^{(3)} + \\frac{4}{7} I_{a \\langle\r\n    i}^{(3)} W_{j \\rangle a}^{(1)} + \\frac{6}{7} I_{a \\langle i}^{(4)}\r\n  W_{j \\rangle a} - \\frac{1}{7} I_{a \\langle i} Y_{j \\rangle a}^{(3)}\r\n  - I_{a \\langle i}^{(3)} Y_{j \\rangle a} + \\frac{1}{63} W_a^{(3)}\r\n  I_{ija}^{(1)} \\nonumber \\\\ & - \\frac{5}{21} W_a^{(4)} I_{ija} +\r\n  \\frac{5}{63} Y_a^{(1)} I_{ija}^{(2)} - \\frac{22}{63} Y_a^{(2)}\r\n  I_{ija}^{(1)} - \\frac{25}{21} Y_a^{(3)} I_{ija} + 2 W^{(2)}\r\n  W_{ij}^{(1)} \\nonumber \\\\ & + 2 W^{(3)} W_{ij} + 2 W^{(2)} Y_{ij} -\r\n  \\frac{4}{3} W_{\\langle i} W_{j \\rangle}^{(3)} - 4 W_{\\langle i} Y_{j\r\n    \\rangle}^{(2)} \\nonumber \\\\ & + \\varepsilon_{ab \\langle i} \\bigg(-\r\n  I_{j \\rangle a}^{(3)} Z_b + \\frac{1}{3} I_{j \\rangle a} Z_b^{(3)} +\r\n  \\frac{4}{9} J_{j \\rangle a} W_b^{(3)} + \\frac{8}{9} J_{j \\rangle\r\n    a}^{(1)} Y_b^{(1)} - \\frac{4}{9} J_{j \\rangle a} Y_b^{(2)} \\bigg)\r\n  \\biggr] + \\mathcal{O}\\left(\\frac{1}{c^8}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nM_{ijk} &= I_{ijk} + {4G\\over\r\n  c^5}\\left[W^{(2)}I_{ijk}-W^{(1)}I_{ijk}^{(1)}+3\\,I_{\\langle\r\n    ij}Y_{k\\rangle }^{(1)}\\right] +\r\n\\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\label{M3} \\,,\\\\ \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \r\nM_{ijkl} &= I_{ijkl} + \\frac{4 G}{c^5} \\bigg[- W^{(1)} I_{ijkl}^{(1)} +\r\n  W^{(2)} I_{ijkl} + 4 Y_{\\langle i}^{(1)} I_{jkl \\rangle} \\bigg] +\r\n\\mathcal{O}\\left(\\frac{1}{c^6}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nS_{ij} &= J_{ij} +{2G\\over c^5}\\left[\\varepsilon_{ab\\langle\r\n    i}\\left(-I_{j\\rangle b}^{(3)}W_{a}-2I_{j\\rangle b}Y_{a}^{(2)}\r\n  +I_{j\\rangle b}^{(1)}Y_{a}^{(1)}\\right)+3J_{\\langle i}Y_{j\\rangle\r\n  }^{(1)}-2J_{ij}^{(1)}W^{(1)}\\right] \\nonumber\\\\& +\r\n\\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nS_{ijk} &= J_{ijk} + \\frac{4G}{c^5} \\bigg[ - W^{(1)} J_{ijk}^{(1)} +\r\n  \\frac{8}{3} Y_{\\langle i}^{(1)} J_{jk \\rangle} + \\varepsilon_{ab\r\n    \\langle i} \\bigg(- \\frac{1}{3} I_{jk \\rangle a}^{(1)} Y_b^{(1)} +\r\n  I_{jk \\rangle a} Y_b^{(2)} + I_{j\\underline{a}}^{(3)} W_{k \\rangle\r\n    b} \\bigg) \\bigg] \\nonumber\\\\& +\r\n\\mathcal{O}\\left(\\frac{1}{c^6}\\right)\\,,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nThe term $1/c^7$ in $M_{ij}$ was already computed in\r\nRef.~\\cite{FMBI12}, but the terms $1/c^5$ in $M_{ijkl}$ and $S_{ijk}$\r\nare new with the present paper.  Finally, combining the previous\r\nformulas~\\eqref{cansourceMS} together with all the results of\r\nSec.~\\ref{sec:radcan} we control the full waveform in terms of the\r\nbasic source and gauge moments up to order 3.5PN.\r\n\r\n\\section{Gravitational-wave octupole modes of compact binaries}\r\n\\label{sec:octupole}\r\n\r\nIn this section we shall present the mass octupole source moment\r\n$I_{ijk}$ of non-spinning compact (point-particle) binaries at 3PN\r\norder for general orbits in the center-of-mass frame, as well as the\r\nassociated octupole gravitational-wave modes. These results are part\r\nof our current program to obtain the waveform of compact binaries\r\ncomplete up to order 3.5PN. The mass octupole moment $I_{ijk}$ is not\r\nconceptually more difficult than the mass quadrupole moment $I_{ij}$,\r\nwhich has been obtained to order 3PN in Refs.~\\cite{BI04mult, BDEI04,\r\n  BDEI05dr} and extended to 3.5PN in Ref.~\\cite{FMBI12}. Therefore, we\r\nshall simply present the result of the long calculation, after a short\r\nrecapitulation of the method, which is based exactly as in\r\nRefs.~\\cite{BI04mult, BDEI04, BDEI05dr} on a preliminary Hadamard type\r\nself-field regularization, followed by dimensional regularization and\r\nrenormalization. The more difficult computation of the current\r\nquadrupole moment $J_{ij}$ at the 3PN order will be left for future\r\nwork.\r\n\r\n\\subsection{Dimensional regularization of the mass octupole moment}\r\n\\label{sec:DR}\r\n\r\nIn the first stage of the calculation we obtain the mass octupole\r\nmoment by means of the so-called pure-Hadamard-Schwartz (pHS)\r\nregularization to deal with the infinite self-field of the point\r\nparticles. The pHS regularization is a specific, minimal Hadamard-type\r\nregularization of integrals, used together with a minimal treatment of\r\ncontact ambiguities and Schwartz distributional\r\nderivatives~\\cite{BDE04}. It is free of ambiguities but depends on the\r\nusual arbitrary UV regularization length scales $s_A$ ($A=1,2$)\r\nassociated with the Hadamard \\textit{partie finie} regularization of\r\nintegrals that diverge at the locations of the two point\r\nparticles~\\cite{BFreg}. In addition the constant $r_0$ introduced into\r\nthe regulator~\\eqref{regulator} is also involved and plays the role of\r\nan IR regularization scale when computing the multipole moments. The\r\nresult of this initial calculation thus reads\r\n%\r\n\\begin{equation}\\label{pHS}\r\nI_{ijk}^\\text{pHS} = I_{ijk}^\\text{pHS} \\bigl[\\overline{\\bm{y}}_A,\r\n  s_A, r_0\\bigr]\\,,\r\n\\end{equation}\r\n%\r\nwhere we emphasize the dependence on both the UV and IR scales, $s_A$\r\nand $r_0$ respectively, and the functional dependence on the two\r\ntrajectories, denoted $\\overline{\\bm{y}}_A$, with implicit dependence\r\non the associated coordinate velocities $\\overline{\\bm{v}}_A =\r\n\\ud\\overline{\\bm{y}}_A/\\ud t$.  The trajectories $\\overline{\\bm{y}}_A$\r\nwill later be understood as being ``bare'' trajectories to be\r\n``dressed'' by renormalization [see Eq.~\\eqref{shifts}]. Notice that\r\nthe initial result~\\eqref{pHS} does not constitute by itself a\r\n\\textit{physical} solution to the problem. In order to make it\r\nphysical within Hadamard's regularization, it must be supplemented by\r\ncertain ``\\textit{ambiguity terms}''~\\cite{BIJ02, BI04mult}. In\r\ndimensional regularization~\\cite{Bollini, tHooft}, which is free of\r\nambiguities and will thus be adopted here, the physical solution is\r\nobtained by augmenting the pHS result with some specific\r\n``\\textit{pole part}'' $\\propto 1/(d-3)$ in the spatial dimension $d$\r\nconsidered as a complex number~\\cite{BDE04, BDEI04, BDEI05dr}.\r\n\r\nTherefore, in the second stage of the calculation, we add to the pHS\r\nresult~\\eqref{pHS} the so-called ``difference'', which is by\r\ndefinition what we precisely have to add in order to obtain the\r\nphysical result produced by dimensional regularization (DR). The\r\nimportant point is that the latter difference can be computed purely\r\n\\textit{locally}, \\textit{i.e.} at the location of the two particles,\r\nin the limit where the dimension tends to three, or equivalently\r\n$\\varepsilon\\to 0$ with $\\varepsilon \\equiv d-3$, because it is\r\ndetermined only by the singular behaviour of integrals in the\r\nneighbourhood of the two singular source points. Moreover, this\r\ndifference depends on the Hadamard UV regularization scales $s_A$ as\r\nwell as on the DR characteristic parameters, namely $\\varepsilon$ and\r\nan arbitrary length scale $\\ell_0$ entering Newton's constant in $d$\r\ndimension, $G^{(d)}=G\\ell_0^\\varepsilon$. To summarize, the mass\r\noctupole source moment $I_{ijk}^\\text{DR}$ in $d=3+\\varepsilon$\r\ndimensions is given, in the limit $\\varepsilon\\to 0$, by\r\n%\r\n\\begin{equation}\\label{I3DR}\r\nI_{ijk}^\\text{DR}[\\overline{\\bm{y}}_A, r_0, \\varepsilon, \\ell_0] =\r\nI_{ijk}^\\text{pHS}[\\overline{\\bm{y}}_A, s_A,r_0] +\r\n\\mathcal{D}I_{ijk}[\\overline{\\bm{y}}_A, s_A, \\varepsilon, \\ell_0]\\,,\r\n\\end{equation}\r\n%\r\nwhere the second term is made of a polar part $\\propto 1/\\varepsilon$\r\nplus a finite part contribution $\\propto \\varepsilon^0$, \\textit{i.e.}\r\nis of the type $\\mathcal{D}I_{ijk} = \\frac{1}{\\varepsilon} A_{ijk} +\r\nB_{ijk} + \\mathcal{O}\\left(\\varepsilon\\right)$, all terms\r\n$\\mathcal{O}(\\varepsilon)$ being systematically\r\nneglected.\\footnote{One can show that there is only a simple pole at\r\n  order 3PN.} At this stage we check that the two parameters $s_A$\r\ncancel out between the two terms in the right-hand side\r\nof~\\eqref{I3DR}, so that $I_{ijk}^\\text{DR}$ is free of such arbitrary\r\nUV regularization scales.\r\n\r\nFinally, in the third stage of the computation, we\r\n\\textit{renormalize} the pole part $\\propto 1/\\varepsilon$ of the DR\r\nresult~\\eqref{I3DR} by shifting the particle positions that can be\r\nthought as the bare trajectories\r\n$\\overline{\\bm{y}}_A\\equiv\\bm{y}^\\text{bare}_A$ into some physical\r\npositions, corresponding to renormalized trajectories\r\n$\\bm{y}_A\\equiv\\bm{y}^\\text{renorm}_A$ that will entirely absorb the\r\npole. The precise \\textit{shifts} $\\bm{\\eta}_A$ of the trajectories,\r\nsuch that\r\n%\r\n\\begin{equation}\\label{shifts}\r\n\\overline{\\bm{y}}_A = \\bm{y}_A + \\bm{\\eta}_A[\\bm{y}_A,\r\n  r'_A,\\varepsilon,\\ell_0]\\,,\r\n\\end{equation}\r\n%\r\nwill consist of a pole part followed by a finite part, neglecting a\r\nremainder $\\mathcal{O}(\\varepsilon)$. These shifts arise at 3PN order\r\nand have been uniquely determined at the same approximation level in\r\nEqs.~(1.13) and~(6.41)--(6.43) of Ref.~\\cite{BDE04}, or Eq.~(6.8) of\r\nRef.~\\cite{BDEI05dr}.  They are precisely those that ensure the\r\ncomplete equivalence between the Hadamard regularized equations of\r\nmotion --- end result of Ref.~\\cite{BFeom} --- and the DR equations of\r\nmotion obtained in Ref.~\\cite{BDE04}. Note that the two UV\r\nregularization scales $r'_A$ entering Eqs.~\\eqref{shifts} are\r\n\\textit{a priori} different from the parameters $s_A$; they have been\r\nchosen instead to match exactly their counterparts entering the\r\nHadamard regularized 3PN equations of motion~\\cite{BFeom}, in which\r\nthey play the role of UV regularization scales in the context of\r\nHadamard's regularization. Finally our physical, renormalized\r\n(``dressed'') result, which is numerically equal to the original, bare\r\nresult, modulo $\\mathcal{O}(\\varepsilon)$ corrections, \\textit{i.e.}\r\n%\r\n\\begin{equation}\\label{physDR}\r\nI_{ijk}[\\bm{y}_A, r'_A, r_0] \\equiv\r\nI^\\text{DR}_{ijk}[\\overline{\\bm{y}}_A, r_0, \\varepsilon, \\ell_0] +\r\n\\mathcal{O}(\\varepsilon)\\,,\r\n\\end{equation}\r\n%\r\nis finite in the limit where $\\varepsilon \\to 0$ while keeping the\r\ndressed trajectories $\\bm{y}_A$ constant. Using the\r\nlink~\\eqref{shifts} we can rewrite:\r\n%\r\n\\begin{equation}\\label{I3phys}\r\nI_{ijk}[\\bm{y}_A, r'_A, r_0] = \\lim_{\\varepsilon\\to\r\n  0}\\Bigl\\{I_{ijk}^\\text{DR}[\\bm{y}_A, r_0, \\varepsilon, \\ell_0] +\r\n\\delta_{\\bm{\\eta}[\\bm{y}_A, r'_A,\\varepsilon,\\ell_0]}I_{ijk}\\Bigr\\}\\,,\r\n\\end{equation}\r\n%\r\nwhere the modification $\\delta_{\\bm{\\eta}}I_{ijk} = 3 \\sum_{A=1,2} m_A\r\ny_A^{\\langle i}y_A^j\\eta_A^{k\\rangle}$ due to the latter shifts\r\nfollows from the variation of the Newtonian mass octupole moment\r\n$I^\\text{N}_{ijk} = \\sum_{A=1,2} m_A y_A^{\\langle\r\n  i}y_A^jy_A^{k\\rangle}$ (valid in any dimension $d$) induced by\r\n$\\bm{\\eta}_A$. By construction, the poles $\\sim 1/\\varepsilon$ cancel\r\nout between the two terms in the right-hand side of Eq.~\\eqref{I3phys}\r\nso that the result is indeed finite (and does not depend on $\\ell_0$)\r\nin the limit $\\varepsilon\\to 0$. The final scales it depends upon are\r\nthe two UV scales $r'_A$ and the IR scale $r_0$.\r\n\r\nNow, the scales $r'_A$ have been shown to be gauge constants,\r\n\\textit{i.e.}  removable by a suitable gauge transformation, both in\r\nthe equations of motion~\\cite{BFeom} and in the radiation\r\nfield~\\cite{BIJ02, BI04mult}. We shall indeed check that these\r\nconstants disappear when we compute the time derivatives of the\r\noctupole moment~\\eqref{I3phys} by means of the 3PN equations of motion\r\nfor insertion into the waveform. Our final invariant results, namely\r\nthe gravitational modes $(3,3)$ and $(3,1)$ obtained in\r\nSec.~\\ref{sec:modes}, are thus independent of $r'_A$.\r\n\r\nOn the other hand, the dependence on the IR constant $r_0$ offers the\r\npossibility of an interesting consistency check with the expression of\r\nthe tails-of-tails for the mass octupole derived previously in\r\nEq.~\\eqref{tailtailU3}. Indeed, as we already mentioned, the\r\ntail-of-tail integrals depend on the constant $\\tau_0=r_0/c$, where\r\n$r_0$ is defined by Eq.~\\eqref{regulator}, in such a way that it will\r\nexactly cancel the constant $r_0$ coming from the expressions of the\r\nsource multipole moments written in terms of the source parameters\r\n(\\textit{i.e.} the positions and velocities of the particles). That\r\nsuch a cancellation between tails-of-tails and source moments actually\r\noccurs has been proved very generally for any isolated matter\r\nsystem~\\cite{B98tail, B98mult}. This has also been explicitly checked\r\nin the case of point particle binaries for the mass quadrupole moment\r\nat 3PN order in Refs.~\\cite{BIJ02, BI04mult}. In Sec.~\\ref{sec:octCM}\r\nwe shall extend this check to the case of the mass octupole moment at\r\n3PN order for general orbits in the center-of-mass frame.\r\n\r\n\\subsection{The 3PN mass octupole in the center-of-mass frame}\r\n\\label{sec:octCM}\r\n \r\nWe have computed the 3PN mass octupole moment~\\eqref{I3phys} of two\r\npoint masses $\\bm{y}_A$ for general orbits in an arbitrary frame. We\r\nthen reduced that result to the frame of the center of mass defined by\r\nthe nullity of the center-of-mass integral associated with the 3PN\r\nequations of motion, given by Eq.~(2.13) in Ref.~\\cite{BI03CM}. An\r\ninteresting point about this calculation is that it requires the full\r\n3PN relations between the variables in the center-of-mass frame and\r\nthe relative variables, in contrast to what happens for the 3PN mass\r\nquadrupole moment where only the 2PN center-of-mass relations are\r\nneeded~\\cite{BI04mult}.\r\n\r\nThe center-of-mass relations for point particle binaries take the\r\nform\\footnote{Our notation for point particle binaries is as follows:\r\n  $m_A$ stands for the two masses ($A=1,2$); $m = m_1+m_2$ for the\r\n  total mass; $X_A=m_A/m$ for the two mass fractions; $\\nu = X_1X_2$\r\n  for the symmetric mass ratio; $\\mu = m\\nu$ for the reduced mass;\r\n  $\\Delta = X_1-X_2$ for the relative mass difference; $\\bm{x}=(x^i) =\r\n  \\bm{y}_1 - \\bm{y}_2$ and $\\bm{v} = (v^i) = \\ud \\bm{x}/\\ud t =\r\n  \\bm{v}_1-\\bm{v}_2$ for the relative separation and velocity;\r\n  $v^2=\\bm{v}^2$ and $\\dot{r}=\\bm{n}\\cdot\\bm{v}$, where\r\n  $\\bm{n}=\\bm{x}/r$ and $r=\\vert\\bm{x}\\vert$.}\r\n%\r\n\\begin{subequations}\\label{y12i}\r\n\\begin{align}\r\n\\bm{y}_1 &= \\Big[X_2+\\nu\\,\\Delta\\,P\\Big] \\bm{x} +\r\n\\nu\\,\\Delta\\,Q\\,\\bm{v} \\,,\\\\ \\bm{y}_2 &= \\Big[-X_1+\\nu\\,\\Delta P\\Big]\r\n\\bm{x} +\\nu\\,\\Delta\\,Q\\,\\bm{v} \\,,\r\n\\end{align}\\end{subequations}\r\n%\r\nwhere all the PN corrections are proportional to the symmetric mass\r\nratio $\\nu$ and the mass difference $\\Delta=X_1-X_2$. The two\r\ndimensionless coefficients $P$ and $Q$ are given with the full 3PN\r\nprecision in Eqs.~(3.13)--(3.14) of Ref.~\\cite{BI03CM}.\r\n\r\nAs an interesting feature the gauge-constants $r'_A$ appear at the 3PN\r\norder, in the coefficient $P$ only, in the form of the particular\r\ncombination $r''_0$ defined by\r\n%\r\n\\begin{equation}\\label{r0pp}\r\n\\Delta\\,\\ln r''_0 = X_1^2 \\ln r'_1 - X_2^2 \\ln r'_2\\,,\r\n\\end{equation}\r\n%\r\nsee Eq.~(3.15) in Ref.~\\cite{BI03CM}, due to the use of the full 3PN\r\ncenter-of-mass relations for this calculation. However, our final 3PN\r\nmass octupole source moment in the center-of-mass frame\r\n[Eqs.~\\eqref{Iijk}--\\eqref{ABCDcirc} below] will depend on $r'_A$\r\nthrough a combination that differs from that of Eq.~\\eqref{r0pp},\r\nnamely\r\n%\r\n\\begin{equation}\\label{r0p}\r\n\\ln r'_0 = X_1 \\ln r'_1 + X_2 \\ln r'_2\\,.\r\n\\end{equation}\r\n%\r\n\r\nIndeed we have found that the $r'_A$ in the 3PN center-of-mass\r\nrelations combine nicely with another combination of these constants\r\nin the 3PN mass octupole moment~\\eqref{I3phys} for general orbits,\r\n\\textit{i.e.} after applying the required shift of the world\r\nlines~\\eqref{shifts} but before the center-of-mass reduction, so that\r\nthe final center-of-mass expression of the mass octupole moment\r\ncontains the classic combination of these constants as given by\r\nEq.~\\eqref{r0p}. This is perfectly consistent with the fact that the\r\nconstants $r'_A$ should \\textit{in fine} disappear from\r\ngauge-invariant results such as our final polarization $(3,3)$ and\r\n$(3,1)$ modes~\\eqref{hlm}.\r\n\r\nThe mass octupole moment defined by Eq.~\\eqref{I3phys} at the 3PN\r\norder, \\textit{i.e.} after the processes of dimensional regularization\r\nand renormalization by shifts of the world lines as reviewed in\r\nSec.~\\ref{sec:DR}, and reduced to the center-of-mass frame using\r\nEqs.~\\eqref{y12i} with full 3PN precision, is finally of the form\r\n%\r\n\\begin{equation}\\label{Iijk}\r\nI_{ijk} = - \\nu\\,m\\,\\Delta\\biggl\\{A\\,x_{\\langle i}x_{j}x_{k\\rangle} +\r\nB\\,\\frac{r}{c}\\,v_{\\langle i}x_{j}x_{k\\rangle} +\r\nC\\,\\frac{r^2}{c^2}\\,v_{\\langle i}v_{j}x_{k\\rangle} +\r\nD\\,\\frac{r^3}{c^3}\\,v_{\\langle i}v_{j}v_{k\\rangle} \\biggr\\}\\,.\r\n\\end{equation}\r\n%\r\nThe coefficients for general orbits in the center-of-mass frame are\r\nfound to be\r\n%\r\n\\begin{subequations}\\label{ABCD}\r\n\\begin{align}\r\nA &= 1 + \\frac{1}{c^{2}} \\biggl\\{v^2 \\Bigl(\\frac{5}{6} - \\frac{19}{6}\r\n\\nu\\Bigr) + \\frac{G m}{r} \\biggl[- \\frac{5}{6} + \\frac{13}{6}\r\n  \\nu\\biggr] \\biggr\\}\\nonumber\\\\ & + \\frac{1}{c^{4}} \\biggl\\{v^4\r\n\\Bigl(\\frac{257}{440} - \\frac{7319}{1320} \\nu + \\frac{5501}{440}\r\n\\nu^2\\Bigr) + \\frac{G m}{r} \\biggl[v^2 \\Big( \\frac{3853}{1320} -\r\n  \\frac{14257}{1320} \\nu - \\frac{17371}{1320} \\nu^2 \\Big)\\nonumber\\\\ &\r\n  \\qquad + \\dot{r}^2 \\Big(- \\frac{247}{1320} + \\frac{531}{440} \\nu -\r\n  \\frac{1347}{440} \\nu^2\\Big) \\biggr] + \\frac{G^2 m^2}{r^2} \\biggl[-\r\n  \\frac{47}{33} - \\frac{1591}{132} \\nu + \\frac{235}{66}\r\n  \\nu^2\\biggr]\\biggr\\} \\nonumber\\\\ & + \\frac{1}{c^{5}} \\biggl\\{ -\r\n\\frac{56}{9} \\frac{G^2 m^2 \\nu \\dot{r}}{r^2}\\biggr\\} \\nonumber\\\\ & +\r\n\\frac{1}{c^{6}} \\biggl\\{v^6 \\Bigl(\\frac{3235}{6864} -\r\n\\frac{7667}{1040} \\nu + \\frac{10319}{286} \\nu^2 - \\frac{129707}{2288}\r\n\\nu^3\\Bigr) \\nonumber\\\\ & \\qquad + \\frac{G m}{r} \\biggl[v^4\r\n  \\Big(\\frac{11633}{2640} - \\frac{93167}{2640} \\nu+ \\frac{5289}{110}\r\n  \\nu^2 + \\frac{203299}{2640} \\nu^3\\Big)\\nonumber\\\\ & \\qquad + v^2\r\n  \\dot{r}^2 \\Big(- \\frac{841}{11440} + \\frac{2039}{3432} \\nu -\r\n  \\frac{121393}{11440} \\nu^2 + \\frac{589981}{17160} \\nu^3\\Big)\r\n  \\nonumber\\\\ & \\qquad + \\dot{r}^4 \\Big(\\frac{1}{208} -\r\n  \\frac{1379}{2288} \\nu + \\frac{44841}{11440} \\nu^2 -\r\n  \\frac{63699}{11440} \\nu^3\\Big)\\biggr]\\nonumber\\\\ & \\qquad +\r\n\\frac{G^2 m^2}{r^2} \\biggl[v^2 \\Big(\\frac{40497}{20020} -\r\n  \\frac{397027}{8580} \\nu + \\frac{120069}{2860} \\nu^2 -\r\n  \\frac{29429}{858} \\nu^3\\Big)\\nonumber\\\\ & \\qquad + \\dot{r}^2 \\Big(-\r\n  \\frac{60413}{120120} + \\frac{20801}{1560} \\nu - \\frac{623351}{17160}\r\n  \\nu^2 - \\frac{70735}{3432} \\nu^3\\Big) \\biggr]\\nonumber\\\\ & \\qquad +\r\n\\frac{G^3 m^3}{r^3} \\biggl[\\frac{4553429}{229320} +\r\n  \\frac{902873}{15015} \\nu - \\frac{31673}{1716} \\nu^2 +\r\n  \\frac{27085}{5148} \\nu^3 - \\frac{26}{7} \\ln\r\n  \\Bigl(\\frac{r}{r_0}\\Bigr) - 22 \\nu \\ln\r\n  \\Bigl(\\frac{r}{r'_{0}}\\Bigr)\\biggr] \\biggr\\}\\nonumber\\\\ & +\r\n\\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nB &= \\frac{\\dot{r}}{c} \\biggl\\{-1 + 2 \\nu\\biggr\\} \\nonumber\\\\ & +\r\n\\frac{\\dot{r}}{c^3} \\biggl\\{v^2 \\Bigl(- \\frac{13}{22} + \\frac{107}{22}\r\n\\nu - \\frac{102}{11} \\nu^2\\Bigr) + \\frac{G m}{r} \\biggl[-\r\n  \\frac{2461}{660} + \\frac{8689}{660} \\nu + \\frac{1389}{220}\r\n  \\nu^2\\biggr]\\biggr\\}\\nonumber\\\\ & + \\frac{1}{c^{4}} \\biggl\\{ -\r\n\\frac{12 G m \\nu v^2}{5 r}+\\frac{232 G^2 m^2 \\nu}{15 r^2}\\biggr\\}\r\n\\nonumber\\\\ & + \\frac{\\dot{r}}{c^{5}} \\biggl\\{ v^4 \\Big(-\r\n\\frac{2461}{5720} + \\frac{37321}{5720} \\nu - \\frac{34627}{1144} \\nu^2\r\n+ \\frac{127447}{2860} \\nu^3\\Big)\\nonumber\\\\ & \\qquad + \\frac{G m}{r}\r\n\\bigg[ v^2 \\Big(- \\frac{80629}{17160} + \\frac{47979}{1144} \\nu -\r\n  \\frac{167122}{2145} \\nu^2 - \\frac{267081}{5720}\r\n  \\nu^3\\Big)\\nonumber\\\\ & \\qquad + \\dot{r}^2 \\Bigl(\\frac{5}{572} +\r\n  \\frac{1851}{1144} \\nu + \\frac{3059}{1560} \\nu^2 -\r\n  \\frac{299171}{17160} \\nu^3\\Bigr) \\bigg]\\nonumber\\\\ & \\qquad +\r\n\\frac{G^2 m^2}{r^2} \\bigg[\\frac{229}{9240} + \\frac{33459}{440} \\nu -\r\n  \\frac{1283}{330} \\nu^2 + \\frac{2287}{264} \\nu^3 \\bigg]\r\n\\biggr\\}\\nonumber\\\\ & + \\mathcal{O}\\left(\\frac{1}{c^6}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nC &= 1 - 2 \\nu \\nonumber\\\\ & + \\frac{1}{c^{2}} \\biggl\\{v^2\r\n\\Bigl(\\frac{61}{110} - \\frac{519}{110} \\nu + \\frac{504}{55}\r\n\\nu^2\\Bigr) + \\dot{r}^2 \\Bigl(- \\frac{1}{11} + \\frac{4}{11} \\nu -\r\n\\frac{3}{11} \\nu^2\\Bigr) \\nonumber\\\\ & \\qquad + \\frac{G m}{r}\r\n\\biggl[\\frac{1949}{330}+ \\frac{62}{165} \\nu - \\frac{483}{55}\r\n  \\nu^2\\biggr] \\bigg\\} \\nonumber\\\\ & + \\frac{1}{c^{4}} \\biggl\\{v^4\r\n\\Bigl(\\frac{465}{1144} - \\frac{35777}{5720} \\nu + \\frac{3057}{104}\r\n\\nu^2 - \\frac{25071}{572} \\nu^3\\Bigr) \\nonumber\\\\ & \\qquad + v^2\r\n\\dot{r}^2 \\Bigl(- \\frac{197}{1430} + \\frac{1637}{1430} \\nu -\r\n\\frac{849}{286} \\nu^2 + \\frac{3063}{1430} \\nu^3\\Bigr)\\nonumber\\\\ &\r\n\\qquad + \\frac{G m}{r} \\biggl[v^2 \\Big(\\frac{91379}{17160} -\r\n  \\frac{169537}{5720} \\nu + \\frac{83211}{5720} \\nu^2+\r\n  \\frac{504721}{8580} \\nu^3\\Big)\\nonumber\\\\ & \\qquad + \\dot{r}^2\\Big(-\r\n  \\frac{3037}{3432} - \\frac{125}{104} \\nu + \\frac{62143}{17160} \\nu^2\r\n  + \\frac{113089}{8580} \\nu^3\\Big)\\biggr] \\nonumber\\\\ & \\qquad +\r\n\\frac{G^2 m^2}{r^2} \\biggl[- \\frac{34515967}{1261260} -\r\n  \\frac{75373}{8580} \\nu+ \\frac{428669}{8580} \\nu^2 -\r\n  \\frac{62665}{2574} \\nu^3 +\r\n  \\frac{52}{7}\\ln\\Bigl(\\frac{r}{r_0}\\Bigr)\\biggr]\\biggr\\}\\nonumber\\\\ &\r\n+ \\mathcal{O}\\left(\\frac{1}{c^5}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nD &=\\frac{\\dot{r}}{c} \\biggl\\{ \\frac{13}{55} - \\frac{52}{55} \\nu +\r\n\\frac{39}{55} \\nu^2\\biggr\\}\\nonumber\\\\ & + \\frac{\\dot{r}}{c^{3}}\r\n\\biggl\\{v^2 \\Big(\\frac{333}{1430} - \\frac{3181}{1430} \\nu +\r\n\\frac{1849}{286} \\nu^2 - \\frac{7247}{1430} \\nu^3\\Big) \\nonumber\\\\ &\r\n\\qquad + \\dot{r}^2 \\Big(\\frac{112}{2145}- \\frac{224}{715} \\nu +\r\n\\frac{224}{429} \\nu^2 - \\frac{448}{2145} \\nu^3\\Big)\\nonumber\\\\ &\r\n\\qquad + \\frac{G m}{r} \\bigg[\\frac{26641}{8580} - \\frac{8341}{2860}\r\n  \\nu - \\frac{1655}{156} \\nu^2 + \\frac{24367}{4290} \\nu^3\\bigg]\r\n\\biggr\\} \\nonumber\\\\ & + \\mathcal{O}\\left(\\frac{1}{c^4}\\right)\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nLet us also give the result of the reduction to quasi-circular orbits.\r\nIntroducing the post-Newtonian parameter $\\gamma=G m/(r c^2)$, we have\r\n%\r\n\\begin{subequations}\\label{ABCDcirc}\r\n\\begin{align}\r\nA^\\text{circ} &= 1 -\\gamma \\nu + \\gamma^2 \\left( - \\frac{139}{330} -\r\n\\frac{11923}{660}\\nu - \\frac{29}{110}\\nu^2\\right) \\nonumber \\\\ & +\r\n\\gamma^3 \\left( \\frac{1229440}{63063} + \\frac{610499}{20020} \\nu +\r\n\\frac{319823}{17160} \\nu^2 - \\frac{101}{2340} \\nu^3 - \\frac{26}{7} \\ln\r\n\\Bigl(\\frac{r}{r_0}\\Bigr) - 22 \\nu \\ln \\Bigl(\\frac{r}{r'_{0}}\\Bigr)\r\n\\right) \\nonumber \\\\ & + \\mathcal{O}\\left(\\frac{1}{c^8}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nB^\\text{circ} &= \\frac{196}{15}\\gamma^2 \\nu +\r\n\\mathcal{O}\\left(\\frac{1}{c^6}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nC^\\text{circ} &= 1 - 2\\nu +\r\n\\gamma \\left(\\frac{1066}{165} - \\frac{1433}{330}\\nu + \\frac{21}{55}\r\n\\nu^2\\right) \\nonumber \\\\ & + \\gamma^2 \\left( - \\frac{1130201}{48510}\r\n- \\frac{989}{33} \\nu + \\frac{20359}{330} \\nu^2 - \\frac{37}{198} \\nu^3\r\n+ \\frac{52}{7} \\ln \\Bigl(\\frac{r}{r_0}\\Bigr)\\right) +\r\n\\mathcal{O}\\left(\\frac{1}{c^6}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nD^\\text{circ} &= \\mathcal{O}\\left(\\frac{1}{c^4}\\right)\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nWe observe that the coefficients $A^\\text{circ}$ and $C^\\text{circ}$\r\nfor quasi-circular orbits are purely conservative, while the other\r\nones, $B^\\text{circ}$ and $D^\\text{circ}$, are purely dissipative,\r\n\\textit{i.e.} due to radiation reaction. The results~\\eqref{ABCDcirc}\r\nextend Eq.~(5.15a) in Ref.~\\cite{BFIS08} to 3PN order.\r\n\r\nAs already mentioned, the IR constant $r_0$ coming from the MPM\r\nregulator~\\eqref{regulator} in the 3PN octupole moment is exactly\r\ncompensated by the same constant $r_0=c\\tau_0$ coming from the kernel\r\nof the mass octupole tail-of-tail integral displayed in\r\nEq.~\\eqref{tailtailU3}. Indeed we can check from\r\nEqs.~\\eqref{Iijk}--\\eqref{ABCD} that the octupole moment for general\r\norbits depends on this constant through the combination\r\n%\r\n\\begin{equation}\\label{lnr0}\r\nI_{ijk} = \\dots - \\frac{26}{21}\\frac{G^2 m^2}{c^6}I^{(2)}_{ijk} \\ln\r\nr_0 + \\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\,,\r\n\\end{equation}\r\n%\r\nwhere we have re-expressed the 3PN coefficient by means of the\r\nNewtonian octupole $I^\\text{N}_{ijk} = \\sum_A m_A y_A^{\\langle\r\n  ijk\\rangle}$. The ellipsis denote all the other terms in\r\nEqs.~\\eqref{Iijk}--\\eqref{ABCD} which are independent of $r_0$. On the\r\nother hand, Eq.~\\eqref{tailtailU3} immediately gives\r\n%\r\n\\begin{equation}\\label{tailtaillnr0}\r\nU_{ijk}^\\text{tail-tail} = \\dots + \\frac{26}{21}\\frac{G^2\r\n  M^2}{c^6}M^{(5)}_{ijk} \\ln r_0 \\,,\r\n\\end{equation}\r\n%\r\nwhich is nicely consistent with the source moment~\\eqref{lnr0} and\r\nshows that the octupole tail-of-tail indeed compensates the $r_0$\r\npresent in the source octupole, at leading order. Recall that the\r\ncoefficient $\\alpha_3=26/21$ is a particular case of the general\r\nformula~\\eqref{alphaell}.\r\n\r\n\\subsection{The gravitational-wave octupole modes  $(3,3)$ and $(3,1)$}\r\n\\label{sec:modes}\r\n\r\nWith the 3PN mass octupole source moment in hand, and using all the\r\nnon-linear multipole interactions computed in Sec.~\\ref{sec:rad}, we\r\nobtain the complete 3PN mass octupole radiative moment $U_{ijk}$. Now,\r\nrecall that for non-spinning compact binaries, there is a clean\r\nseparation of the modes $(\\ell,m)$ into those with $\\ell+m$ even,\r\nwhich depend only on the mass-type moments $U_L$, and those with\r\n$\\ell+m$ odd, which depend only on the current-type ones\r\n$V_L$.\\footnote{This fact is more generally true for ``planar''\r\n  binaries, whose motion takes place in a fixed orbital plane, which\r\n  is the case of spinning binaries with spins aligned or anti-aligned\r\n  with the orbital angular momentum; see Ref.~\\cite{FMBI12} for a\r\n  proof.} From the radiative octupole $U_{ijk}$ we can thus compute\r\nthe associated modes $(3,3)$ and $(3,1)$ in the usual spin-weighted\r\nspherical-harmonic decomposition of the waveform~\\eqref{gijTT} for\r\nquasi-circular orbits. For $\\ell+m$ even we have, adopting the\r\nconventions of Refs.~\\cite{BFIS08, FMBI12},\r\n%\r\n\\begin{equation}\\label{modes}\r\nh_{\\ell m} = - \\frac{2G}{R c^{\\ell +2}\\ell!}\r\n\\,\\sqrt{\\frac{(\\ell+1)(\\ell+2)}{\\ell(\\ell-1)}} \\,\\alpha^L_{\\ell\r\n  m}\\,U_L\\,,\r\n\\end{equation}\r\n%\r\nwhere the STF tensorial factor $\\alpha^L_{\\ell m}$ connects the usual\r\nbasis of spherical harmonics $Y_{\\ell m}$ to the set of STF products\r\nof unit direction vectors $\\hat{N}_L$ [see\r\n  Eq.~\\eqref{defalphaL}]. Like in Refs.~\\cite{BFIS08, FMBI12}, we pose\r\n%\r\n\\begin{equation}\\label{modedef}\r\n  h_{\\ell m} = \\frac{2 G \\,m \\,\\nu \\,x}{R \\,c^2}\r\n  \\,\\sqrt{\\frac{16\\pi}{5}}\\, H_{\\ell m}\\,\\mathrm{e}^{-\\ui m \\, \\psi} \\,,\r\n\\end{equation}\r\n%\r\nwhere the post-Newtonian parameter $x=(\\frac{G m\\omega}{c^3})^{2/3}$\r\nis defined from the orbital frequency of circular motion $\\omega$, and\r\nwhere $\\psi$ denotes a particular phase variable related to the actual\r\norbital phase of the binary, namely $\\varphi=\\int\\omega\\ud t$, by\r\n%\r\n\\begin{equation}\\label{changephaseomega}\r\n\\psi = \\varphi - \\frac{2 G M \\omega}{c^3}\r\n\\ln\\left(\\frac{\\omega}{\\omega_0}\\right) \\,,\r\n\\end{equation}\r\n%\r\nthe constant frequency $\\omega_0$ being directly linked to the time\r\nscale $b$ entering the relation~\\eqref{TRtr} between harmonic and\r\nradiative coordinates:\r\n%\r\n\\begin{equation}\\label{omega0}\r\n\\omega_0=\\frac{\\mathrm{e}^{\\frac{11}{12}-\\gamma_\\text{E}}}{4b}\\,,\r\n\\end{equation}\r\n%\r\nwith $\\gamma_\\text{E}$ denoting the Euler constant. The 1.5PN\r\nlogarithmic phase modulation in Eq.~\\eqref{changephaseomega}\r\noriginates physically from tails that propagate in the far\r\nzone~\\cite{BIWW96, ABIQ04}. The mass $M$ therein is the ADM mass; it\r\n\\textit{must} include the relevant post-Newtonian corrections, up to\r\n1PN order in the present case (see Eq.~(5.23) in Ref.~\\cite{BFIS08}).\r\n\r\nOur final results for the gravitational-wave modes $(3,3)$ and $(3,1)$\r\nat order 3.5PN in the waveform for quasi-circular orbits read\r\n%\r\n\\begin{subequations} \\label{hlm}\\begin{align}\r\nH_{33} &=-\\frac{3}{4} \\ui \\sqrt{\\frac{15}{14}} \\,\\Delta\r\n\\bigg[x^{1/2}+x^{3/2} \\biggl(-4+2 \\nu \\biggr)+x^2 \\left(3 \\pi +\\ui\r\n  \\Bigl[-\\frac{21}{5}+6 \\ln (3/2)\\Bigr]\\right) \\nonumber \\\\ &+x^{5/2}\r\n  \\left(\\frac{123}{110}-\\frac{1838 \\nu }{165}+\\frac{887 \\nu\r\n    ^2}{330}\\right)+x^3 \\bigg(-12 \\pi +\\frac{9 \\pi \\nu }{2} \\nonumber\r\n  \\\\ & \\qquad +\\ui \\Bigl[\\frac{84}{5}-24 \\ln \\left(3/2\\right)+\\nu\r\n    \\Bigl(-\\frac{48103}{1215}+9 \\ln \\left(3/2\\right)\\Bigr)\\Bigr]\\bigg)\r\n  \\nonumber \\\\ & + x^{7/2}\\biggl(\\frac{19388147}{280280} +\r\n  \\frac{492}{35} \\ln \\left(3/2\\right) -18\\ln^2 (3/2) -\r\n  \\frac{78}{7}\\gamma_\\text{E} + \\frac{3}{2} \\pi^2 + 6 \\ui \\pi\r\n  \\Big[-\\frac{41}{35} + 3 \\ln (3/2) \\Big] \\nonumber \\\\ & \\qquad +\r\n  \\frac{\\nu}{8} \\Big[- \\frac{7055}{429} + \\frac{41}{8} \\pi^2 \\Big] -\r\n  \\frac{318841}{17160} \\nu^2 + \\frac{8237}{2860} \\nu^3 - \\frac{39}{7}\r\n  \\ln (16x) \\biggr)\\bigg] \\nonumber \\\\ &+\r\n\\mathcal{O}\\left(\\frac{1}{c^8}\\right)\\,,\\\\\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nH_{31} &=\\frac{\\ui \\,\\Delta}{12 \\sqrt{14}} \\bigg[x^{1/2}+x^{3/2}\r\n  \\left(-\\frac{8}{3}-\\frac{2 \\nu }{3}\\right)+x^2 \\left(\\pi +\\ui\r\n  \\Big[-\\frac{7}{5}-2 \\ln 2\\Big]\\right) \\nonumber \\\\ &+x^{5/2}\r\n  \\left(\\frac{607}{198}-\\frac{136 \\nu }{99}-\\frac{247\r\n    \\nu^2}{198}\\right)+x^3 \\bigg(-\\frac{8 \\pi }{3}-\\frac{7 \\pi \\nu\r\n  }{6} \\nonumber \\\\ & \\qquad +\\ui \\Big[\\frac{56}{15}+\\frac{16 \\ln\r\n      2}{3}+\\nu \\Big(-\\frac{1}{15}+\\frac{7 \\ln 2}{3}\\Big)\\Big]\\bigg)\r\n  \\nonumber \\\\ &+ x^{7/2}\\biggl( \\frac{10753397}{1513512} - 2 \\ln 2\r\n  \\Big[ \\frac{212}{105} + \\ln 2\\Big] - \\frac{26}{21} \\gamma_\\text{E} +\r\n  \\frac{\\pi^2}{6} -2 \\ui \\pi \\Big[ \\frac{41}{105} + \\ln 2 \\Big]\r\n  \\nonumber \\\\ & \\qquad + \\frac{\\nu}{8} \\bigg(- \\frac{1738843}{19305}\r\n  + \\frac{41}{8} \\pi^2 \\bigg) + \\frac{327059}{30888} \\nu^2 -\r\n  \\frac{17525}{15444} \\nu^3 - \\frac{13}{21} \\ln x \\biggr)\\bigg]\r\n\\nonumber \\\\ & + \\mathcal{O}\\left(\\frac{1}{c^8}\\right)\\,.\r\n\\end{align}\\end{subequations}\r\n%\r\nThis extends Eqs.~(9.4d) and (9.4f) in Ref.~\\cite{BFIS08} by one-half\r\nPN order. We have verified the complete agreement in the test-mass\r\nlimit $\\nu\\to 0$ with the corresponding modes computed by black-hole\r\nperturbation techniques and reported in Eqs.~(4.9) of\r\nRefs.~\\cite{FI10}. Notice that the latter work uses a phase variable\r\nwhich differs from our definition $\\psi$ given by\r\nEq.~\\eqref{changephaseomega}; in particular it happens to be different\r\nfor each mode $(\\ell, m)$.\\footnote{It is related to ours in the\r\n    test-mass limit ($m_1\\to 0$) by\r\n%\r\n$$\\psi^\\text{FI}_{\\ell m} = \\psi + 2 x^{3/2} \\left(\\gamma_\\text{E} +\r\n  \\frac{3}{2}\\ln \\left(4 x\\right) - \\frac{17}{12} \\right) + \\psi_{\\ell\r\n    m}^{(3\\text{PN})}\\,,$$\r\n%\r\nwith $\\psi_{\\ell m}^{(3\\text{PN})}$ being defined by Eq.~(4.5) of\r\nRef.~\\cite{FI10}.}\r\n\r\nThe other modes $(3,2)$ and $(3,0)$ are known at order 3PN but cannot\r\nbe computed at order 3.5PN for now; this computation will have to wait\r\nfor the completion of the current quadrupole moment $J_{ij}$\r\n(currently known at order 2.5PN~\\cite{BFIS08}) up to order 3PN. The\r\nderivation of the 3PN current quadrupole presents new difficulties\r\nwith respect to the 3PN mass quadrupole or octupole moments, and will\r\nbe left for future work.\r\n\r\n\\section{Tail-induced resummed waveform}\r\n\\label{sec:factor}\r\n\r\n\\subsection{Resummation of IR logarithms}\r\n\\label{sec:resum}\r\n\r\nBy implementing the MPM algorithm, it has been shown by induction that\r\nthe $n$-th post-Minkowskian coefficient in harmonic coordinates in an\r\nexpansion when $r\\to +\\infty$ with $t_r=\\text{const}$ involves powers\r\nof $1/r$ and powers of the logarithm $\\ln r$ up to $n-1$, so that its\r\ngeneral structure at future null infinity\r\nreads~\\cite{BD86}\\footnote{Recall that $t_r\\equiv t-r$.  In this\r\n  section we pose $G=c=1$.}\r\n%\r\n\\begin{equation}\\label{hMPMstruct}\r\nh^{\\alpha\\beta}_{(n)}(\\mathbf{x}, t) = \\sum_{\\ell=0}^{+\\infty}\r\n\\hat{n}_L \\biggl\\{\\sum_{1 \\leqslant k \\leqslant N\\atop 0\\leqslant p\r\n  \\leqslant n-1} \\frac{\\bigl(\\ln r/b\\bigr)^p}{r^k}\r\nF^{\\alpha\\beta}_{L(n)kp}(t_r) + R_{L(n)N}^{\\alpha\\beta}(r,t_r)\r\n\\biggr\\} \\,.\r\n\\end{equation}\r\n%\r\nHere $h_{(n)}$ stands for the $n$-th order post-Minkowskian\r\npiece of the gravitational field either in the canonical or the\r\ngeneral MPM algorithms reviewed in Sec.~\\ref{sec:MPM}. The functions\r\n$F_{L(n)kp}$ are complicated functionals of the canonical moments\r\n$\\{M_L, S_L\\}$, or the source and gauge moments, $\\{I_L, J_L\\}$ and\r\n$\\{W_L, X_L, Y_L, Z_L\\}$ respectively, depending on the chosen\r\nalgorithm. The angular part is expressed with the STF products\r\n$\\hat{n}_L$ of unit vectors $n^i=x^i/r$. The remainder\r\n$R_{L(n)N}(r,t_r)$ is $\\mathcal{O}(1/r^{N-\\epsilon})$, with\r\n$0<\\epsilon\\ll 1$ taking into account the fact that the expansion\r\ninvolves powers of $\\ln r$. Finally the logarithms in\r\nEq.~\\eqref{hMPMstruct} are conveniently rescaled by means of an\r\narbitrary constant $b$, being understood that the functions\r\n$F_{L(n)kp}$ are themselves dependent on this constant\r\n$b$. Restricting our attention to the leading coefficient of $1/r$ at\r\ninfinity we write\r\n%\r\n\\begin{subequations}\\label{hnasymp}\r\n\\begin{align}\r\nh^{\\alpha\\beta}_{(n)} &= \\frac{1}{r}\r\n\\,z^{\\alpha\\beta}_{(n)}(\\mathbf{n}, \\ln r, t_r) + \\mathcal{O}\\Bigl(\r\n\\frac{1}{r^{2-\\epsilon}}\\Bigr) \\,,\\\\\\text{with}\\quad\r\nz^{\\alpha\\beta}_{(n)} &= \\sum_{\\ell} \\hat{n}_L \\sum_{p=0}^{n-1}\r\n\\left(\\ln\\frac{r}{b}\\right)^p F_{L(n)p}^{\\alpha\\beta}(t_r)\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\n\r\nWe shall refer to the logarithms generated in the far zone expansion\r\nof the metric at infinity as the \\textit{IR logarithms}. They have\r\ntheir root in the famous logarithmic deviation of the retarded cones\r\n$t_r=\\text{const}$ in harmonic coordinates with respect to the true\r\nnull cones $u=\\text{const}$, where $u$ is a null coordinate\r\n  satisfying $g^{\\mu\\nu}\\partial_\\mu u \\,\\partial_\\nu u=0$. The IR\r\nlogarithms can be removed by a coordinate transformation order by\r\norder in the MPM expansion. We have already seen in\r\nEqs.~\\eqref{TRtr}--\\eqref{gijTT} that one can construct radiative\r\ncoordinates that are free of any such IR logarithms. Radiative\r\ncoordinates are such that $T_R=u+\\mathcal{O}(1/R)$.\r\n\r\nIn this subsection we consider a particular class of IR\r\nlogarithms generated by tails. Recall that in the MPM algorithm the IR\r\nlogarithms are produced by source terms behaving like $1/r^2$ when\r\n$r\\to +\\infty$ with $t_r=\\text{const}$ (where we include in the\r\ncoefficient the usual dependence on powers of $\\ln r$). Although\r\nsource terms behaving like $1/r^k$ with $k\\geqslant 3$ do generate\r\n$1/r$ contributions after application of the retarded integral\r\n[\\textit{i.e.}  $\\mathop{\\mathrm{FP}}_{B=0} \\, \\Box^{-1}_\\mathrm{ret}\r\n  \\widetilde{r}^B$ in the notation of Eq.~\\eqref{un}], those are in\r\nthe form of source-free retarded waves which do not contain IR\r\nlogarithms; this is proved by Lemma~7.2 in Ref.~\\cite{BD86}.\r\n\r\nUsing the leading order behaviour $1/r$ of $h_{(n)}$,\r\nEqs.~\\eqref{hnasymp}, we see that IR logarithms can only come from\r\nthat part of the gravitational source term $\\Lambda$ in\r\nEq.~\\eqref{EFEa} which is quadratic in $h$, say $\\Lambda = N(h,h) +\r\n\\mathcal{O}(h^3)$ where $N(h,h)$ is bilinear in $h$ as well as its\r\nspace-time derivatives $\\partial h$ and $\\partial^2 h$. Thus IR\r\nlogarithms come only from solving the equation\r\n%\r\n\\begin{align} \\label{BoxhN}\r\n\\Box h^{\\alpha\\beta}_{(n)} = \\sum_{m=1}^{n-1}\r\nN^{\\alpha\\beta}\\bigl(h_{(m)},h_{(n-m)}\\bigr) +\r\n\\mathcal{O}\\left(\\frac{1}{r^{3 - \\epsilon}}\\right)\\,.\r\n\\end{align}\r\n%\r\nWriting the Einstein equations in harmonic coordinates in terms of the\r\ngothic metric and using the asymptotic formula $\\partial_\\mu\r\nh^{\\alpha\\beta}_{(n)} = - k_\\mu \\,\\partial_t h^{\\alpha\\beta}_{(n)} +\r\n\\mathcal{O}(1/r^{2-\\epsilon})$, where $t_r=\\text{const}$ and $k_\\mu=\r\n(-1, n^i)$ denotes a null Minkowskian vector, yields \\cite{B87, BD92}\r\n%\r\n\\begin{equation} \\label{eqnIR}\r\n\\Box h^{\\alpha\\beta}_{(n)} = \\frac{1}{r^2}\\left[ 4M \\,\\partial_t^2\r\n  z^{\\alpha\\beta}_{(n-1)} + k^\\alpha k^\\beta \\sigma_{(n)} \\right] +\r\n\\mathcal{O}\\left(\\frac{1}{r^{3 - \\epsilon}}\\right)\\,.\r\n\\end{equation}\r\n%\r\n\r\nThe second term in that expression is due to the re-radiation of\r\ngravitational waves by the stress-energy tensor of gravitational waves\r\nthemselves. This term is responsible for the non-linear memory\r\neffect~\\cite{B90, Chr91, WW91, Th92, BD92, B98quad, F09, F11} (see\r\nSec.~\\ref{sec:radcan}). The energy density $\\sigma_{(n)}$ is\r\nproportional to the total gravitational-wave flux emitted to order $n$\r\nand reads explicitly\r\n%\r\n\\begin{equation} \\label{sigman}\r\n\\sigma_{(n)} = \\frac{1}{2} \\sum_{m=1}^{n-1}\r\n\\Bigl(\\eta_{\\mu\\rho}\\eta_{\\nu\\sigma} -\r\n\\frac{1}{2}\\eta_{\\mu\\nu}\\eta_{\\rho\\sigma}\\Bigr)\\partial_t\r\nz^{\\mu\\nu}_{(m)}\\partial_t z^{\\rho\\sigma}_{(n-m)} \\,.\r\n\\end{equation}\r\n%\r\nAs proved in Ref.~\\cite{B87} (see Lemma~2.1 there) the IR logarithms\r\ncoming from the second term in Eq.~\\eqref{eqnIR} can be removed, order\r\nby order in the MPM iteration, by means of the gauge transformation\r\nwith gauge vector\r\n%\r\n\\begin{equation} \\label{gaugelambdan}\r\n\\lambda^\\alpha_{(n)} = \\Box^{-1}_\\mathrm{ret}\r\n\\left[\\frac{k^\\alpha}{2r^2}\\!\\int_{-\\infty}^{t_r}\\!\\ud\r\n  \\tau\\,\\sigma_{(n)}(\\mathbf{n}, \\ln r, \\tau)\\right] \\,.\r\n\\end{equation}\r\n%\r\nAs the retarded integral is convergent there is no need to include the\r\n$\\mathop{\\mathrm{FP}}_{B=0}$ operation.\r\n\r\nIn this Appendix we shall be interested in the IR logarithms generated\r\nby the tail term associated with backscatter onto the static\r\nspace-time curvature generated by the total ADM mass $M$ of the system\r\n--- the first term in the right-hand side of Eq.~\\eqref{eqnIR}. The\r\nmass is introduced in the formalism as the constant monopole moment\r\n$I\\equiv M$ in the ``canonical'' linearized metric~\\eqref{hcan1}. To\r\nprove that $M$ enters the source term at any MPM order $n$ in the way\r\nshown in~\\eqref{eqnIR}, we invoke our assumption that the matter\r\nsystem is stationary before some instant $-\\mathcal{T}$ in the past.\r\nUnder this assumption the relaxed Einstein equation~\\eqref{EFEa} for\r\nthe quadratic metric in the stationary epoch $t\\leqslant -\\mathcal{T}$\r\ntells us that $\\Delta h_{(2)}^{\\alpha\\beta} = \\mathcal{O}(1/r^4)$\r\nhence $h_{(2)}^{\\alpha\\beta} = \\mathcal{O}(1/r^2)$. By immediate\r\nrecurrence, we conclude that $h_{(n)}^{\\alpha\\beta} =\r\n\\mathcal{O}(1/r^n)$ when $t\\leqslant -\\mathcal{T}$. From this we infer\r\nthat $k_\\mu k_\\nu z_{(n)}^{\\mu\\nu} = 0$ at any time for $n\\geqslant\r\n2$, since it is constant, due to the asymptotic form of the\r\nharmonic-gauge condition, and vanishes at early time $t\\leqslant\r\n-\\mathcal{T}$, while we have $k_\\mu k_\\nu z_{(1)}^{\\mu\\nu} = - 4\r\nM$. Thus, for any $n\\geqslant 2$, the first term of Eq.~\\eqref{eqnIR}\r\ncomes only from the coupling between the static part of $h_{(1)}$ and\r\n$h_{(n-1)}$.\r\n\r\nWe shall solve recursively and look for IR logarithms in the equation\r\n%\r\n\\begin{align} \\label{eqBoxhIR}\r\n\\Box \\bar{h}^{\\alpha\\beta}_{(n)} = \\frac{4 M}{r^2} \\partial_t^2\r\n\\bar{z}^{\\alpha\\beta}_{(n-1)} + \\mathcal{O}\\left(\\frac{1}{r^{3 -\r\n    \\epsilon}}\\right)\\,.\r\n\\end{align}\r\n%\r\nWe add an overbar to emphasize that we are considering an\r\napproximation of the harmonic-coordinate MPM algorithm in which we\r\nneglect all the IR logarithms generated by the second term of\r\nEq.~\\eqref{eqnIR}. The iteration of Eq.~\\eqref{eqBoxhIR} is achieved\r\nmost easily in the frequency space. The time Fourier transform of a\r\nfunction $F(t)$ will be denoted by $\\tilde{F}(\\Omega) \\equiv\r\n\\mathcal{F}(F)(\\Omega)$ with the convention\r\n%\r\n\\begin{equation}\\label{Fourier}\r\n\\tilde{F}(\\Omega) = \\int_{-\\infty}^{+\\infty} \\!\\! \\ud t \\,\r\nF(t)\\,\\mathrm{e}^{\\ui \\Omega t} \\,,\\qquad F(t) =\r\n\\int_{-\\infty}^{+\\infty} \\!  \\frac{\\ud \\Omega}{2\\pi}\r\n\\,\\tilde{F}(\\Omega)\\,\\mathrm{e}^{-\\ui \\Omega t} \\,.\r\n\\end{equation}\r\n%\r\nThe integration of the relevant $1/r^2$ source terms will be achieved\r\nin the Fourier domain with the help of the following formula:\r\n%\r\n\\begin{align} \\label{elementaryIR}\r\n \\Box^{-1}_\\mathrm{ret} \\Bigl[ \\frac{\\hat{n}_L}{r^2}\r\n   \\left(\\ln\\frac{r}{b}\\right)^p \\!F(t_r)\\Bigr] &=\r\n \\frac{\\hat{n}_L}{2(p+1)r}\r\n \\int_{-\\infty}^{+\\infty}\\frac{\\ud\\Omega}{2\\pi}\r\n \\frac{\\tilde{F}(\\Omega)\\,\\mathrm{e}^{-\\ui \\Omega\r\n     t_r}}{(-\\ui\\Omega)}\\biggl[ \\gamma_\\ell^{(p+1)}(0,\\Omega b) -\r\n   \\left(\\ln\\frac{r}{b}\\right)^{p+1} \\biggr]\\nonumber\\\\ &+\r\n \\mathcal{O}\\Big( \\frac{1}{r^{2-\\epsilon}}\\Big) \\,,\r\n\\end{align}\r\n%\r\nin which the function of two variables $\\gamma_\\ell(B,x)$ is defined\r\nby (with $\\Gamma$ the Eulerian function) \r\n%\r\n\\begin{equation}\\label{gammaell}\r\n\\gamma_\\ell(B,x) = \\frac{\\Gamma(\\ell+1+B)\\Gamma(1-B)}{(-2\\ui\r\n  x)^{B}\\Gamma(\\ell+1-B)}\\,.\r\n\\end{equation}\r\n%\r\nIn Eq.~\\eqref{elementaryIR} this function is differentiated $(p+1)$\r\ntimes with respect to the first variable $B$, and then evaluated at\r\n$B=0$ and for $x=\\Omega b$, defining thus\r\n%\r\n\\begin{equation}\\label{gammaellexpl}\r\n\\gamma_\\ell^{(p+1)}(0,\\Omega b) \\equiv\r\n\\left(\\frac{\\partial^{p+1}\\gamma_\\ell}{\\partial B^{p+1}}\\right)(0,\r\n\\Omega b)\\,.\r\n\\end{equation}\r\n%\r\nAgain notice that the retarded integral~\\eqref{elementaryIR} is\r\nconvergent so there is no need to invoke a finite part operation like\r\nin Eq.~\\eqref{un}. For the reader's convenience we provide the proof\r\nof the elementary formula~\\eqref{elementaryIR} in\r\nAppendix~\\ref{app:proof_formula}.\r\n\r\nWe can now obtain thanks to the elementary\r\nformula~\\eqref{elementaryIR}\\footnote{Here we consider only the\r\n  retarded integral of the source term, corresponding to the part\r\n  $\\bar{u}^{\\alpha\\beta}_{(n)}$ of the MPM algorithm [see\r\n    Eqs.~\\eqref{hgenn}--\\eqref{un}], since the part\r\n  $\\bar{v}^{\\alpha\\beta}_{(n)}$ does not contain IR logarithms.} the\r\nleading order waveform $\\bar{z}_{(n)}$ starting from the preceding one\r\n$\\bar{z}_{(n-1)}$, both having general structures similar to\r\nEq.~\\eqref{hnasymp}. This gives some recursion relations for the\r\nfunctions $F_{L(n)p}$ parametrizing their general structures. These\r\nare given in the Fourier domain for any $n\\geqslant 2$ by\r\n%\r\n\\begin{subequations}\\label{recursion0}\\begin{align}\r\n\\tilde{F}_{L(n)p}(\\Omega) &= \\frac{2\\ui M \\Omega\r\n}{p}\\tilde{F}_{L(n-1)p-1}(\\Omega) &\\text{for $1\\leqslant\r\n  p\\leqslant n-1$}\\,,\\\\ \\tilde{F}_{L(n)0}(\\Omega) &= - \\sum_{q=0}^{n-2}\r\n\\,\\frac{2\\ui M \\Omega }{q+1} \\,\\gamma_\\ell^{(q+1)}(0,\\Omega\r\nb)\\,\\tilde{F}_{L(n-1)q}(\\Omega) &\\text{for $p=0$}\\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nSuch recursion formulas are easily iterated with the result that\r\n%\r\n\\begin{subequations}\\label{recursion}\\begin{align} \r\n\\tilde{F}_{L(n)p} &= \\frac{(2\\ui M \\Omega)^p}{p!}\\tilde{F}_{L(n-p)0}\r\n&\\text{for $1\\leqslant p\\leqslant\r\n  n-1$}\\,,\\label{recursiona}\\\\\\tilde{F}_{L(n)0} &= - \\sum_{q=0}^{n-2}\r\n\\,\\frac{(2\\ui M \\Omega)^{q+1}}{(q+1)!}  \\,\\gamma_\\ell^{(q+1)}(0,\\Omega\r\nb)\\,\\tilde{F}_{L(n-q-1)0} &\\text{for $p=0$}\\,.\\label{recursionb}\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\n\r\nThese results yield immediately the complete resummed waveform in the\r\nFourier domain as follows. For convenience we denote by $\\tilde{z}_L$\r\nthe STF piece with multipolarity $\\ell$ in the full waveform. From the\r\nfirst result~\\eqref{recursiona} we then determine\r\n%\r\n\\begin{equation}\\label{zLfull}\r\n\\tilde{z}^{\\alpha\\beta}_L(\\ln r, \\Omega) =\r\n\\sum_{n=1}^{+\\infty}\\tilde{z}^{\\alpha\\beta}_{L(n)}(\\ln r,\r\n\\Omega)=\\mathrm{e}^{2\\ui M \\Omega \\ln\\left(\\frac{r}{b}\\right)}\r\n\\tilde{F}^{\\alpha\\beta}_{L0}(\\Omega)\\,,\r\n\\end{equation}\r\n%\r\nin which $\\tilde{F}_{L0}(\\Omega)$ refers to the logarithmic-free part\r\nof the full waveform and is defined by\r\n$\\tilde{F}_{L0}=\\sum_{n=1}^{+\\infty}\\tilde{F}_{L(n)0}$. Next, the\r\nsecond result~\\eqref{recursionb} gives the logarithmic-free part of\r\nthe waveform in terms of the linearized approximation which is nicely\r\nfactorized out as\r\n%\r\n\\begin{equation}\\label{FL0full}\r\n\\tilde{F}_{L0}(\\Omega) =\r\n\\frac{\\tilde{F}_{L(1)0}(\\Omega)}{\\gamma_\\ell(2\\ui M \\Omega,\\Omega\r\n  b)}\\,,\r\n\\end{equation}\r\n%\r\nwhere the denominator is made of the function $\\gamma_\\ell(B,x)$\r\nnow evaluated at $B=2\\ui M \\Omega$ and $x=\\Omega b$, and where\r\nwe have used the fact that $\\gamma_\\ell(0,x)=1$. Note that\r\n$\\tilde{z}_{L(1)}(\\Omega)=\\tilde{F}_{L(1)0}(\\Omega)$ is the waveform\r\nat the linear order $n=1$. Finally, combining these two findings with\r\nthe expression of the function~\\eqref{gammaell} we obtain the final\r\nexpression for our resummed tail-modified waveform: \r\n%\r\n\\begin{equation}\\label{resumzL}\r\n\\bar{z}_L(\\ln r, t_r) = \\int_{-\\infty}^{+\\infty} \\!\\frac{\\ud\r\n  \\Omega}{2\\pi} \\,\\frac{\\Gamma(\\ell+1-2\\ui M\r\n  \\Omega)}{\\Gamma(\\ell+1+2\\ui M \\Omega)\\Gamma(1-2\\ui M\r\n  \\Omega)}\\,\\tilde{z}_{L(1)}(\\Omega)\\,\\mathrm{e}^{- \\ui \\Omega t_r +\r\n  2\\ui M \\Omega \\ln\\left(2 |\\Omega| r\\right)+M |\\Omega|\\pi} \\,.\r\n\\end{equation}\r\n%\r\nWe gladly notice that the scale $b$ has cancelled out from the final\r\nresult~\\eqref{resumzL}, in agreement with the fact that the iteration\r\nof the equation~\\eqref{eqBoxhIR} does not make any reference to an\r\narbitrary scale such as $b$. However, the dependence on $b$ is\r\nrestored in radiative coordinates through the\r\nredefinition~\\eqref{TRtr} of the retarded time $T_R$ at future null\r\ninfinity, and the phase factor in Eq.~\\eqref{resumzL} becomes\r\n$\\mathrm{exp}[-\\ui \\Omega T_R + 2 \\ui M \\Omega \\ln(2 |\\Omega| b)+M\r\n  |\\Omega| \\pi]$. We observe that all powers of $\\ln r$ have been\r\nabsorbed into $T_R$, but there are still powers of $\\ln (2|\\Omega| b)$\r\nleft. This motivates the change of phase variable introduced in\r\nEq.~\\eqref{changephaseomega}, the constant frequency $\\omega_0$\r\ndefined in Eq.~\\eqref{omega0} being chosen for convenience to minimize\r\nthe number of terms in the waveform. Recall also that, as indicated by\r\nan overbar, the resummed waveform~\\eqref{resumzL} does not constitute\r\nthe complete resummed waveform in harmonic coordinates because we have\r\nsystematically neglected the second terms in\r\nEqs.~\\eqref{eqnIR}. However, it motivates the introduction of\r\n\\textit{factorized} resummed waveforms~\\cite{DIN09} which we shall\r\nshortly review and complete in the next subsection for the case of the\r\nmass octupole waveform.\r\n\r\nIn fact, the solution~\\eqref{resumzL} can be obtained without MPM\r\niteration and resummation by computing directly the solution of a\r\n``scattering'' problem,\r\n%\r\n\\begin{align}\\label{scattering}\r\n\\Box \\bar{h} - \\frac{4 M}{r} \\partial_t^2 \\bar{h} = \\bar{S} \\,,\r\n\\end{align}\r\n%\r\nwhere the scattering barrier is the usual potential $M/r$, and where $\\bar{S}$\r\nis some effective source. To recover the solution~\\eqref{resumzL}, it suffices\r\nto impose that $\\bar{S}$ decreases like $\\mathcal{O}(1/r^{3-\\varepsilon})$ at\r\ninfinity. The most general solution of~\\eqref{scattering} can be constructed\r\nformally by convoluting the source $\\bar{S}$ with the retarded Green function\r\n$G_\\text{ret}(x-x')$ of the differential operator $\\Box - (4\r\nM/r) \\partial^2_t$. In Ref.~\\cite{AF97}, $G_\\text{ret}(x-x')$ is computed\r\nexplicitly using standard techniques of scattering theory~\\cite{Messiah}. In\r\nthe limit $r \\to +\\infty$ at $t_r=\\text{const}$, it is essentially\r\nproportional to the retarded solution of the modified Whittaker equation and\r\nto the normalization coefficient of the solution regular at the origin, for\r\n$\\Omega r \\to 0$.\r\n\r\n\\subsection{Application to the octupole resummed waveform}\r\n\\label{sec:appli}\r\n\r\nWe conclude the paper with an application of our above computation of\r\nthe 3.5PN accurate modes $h_{33}$ and $h_{31}$ to the\r\neffective-one-body (EOB) approach~\\cite{BuonD99, DNorleans} to\r\nanalytically blend PN approximants and numerical-relativity (NR)\r\nresults. Factorized resummed waveforms were introduced in\r\nRef.~\\cite{DIN09} and consist of a physically motivated product of the\r\nNewtonian waveform, a relativistic correction coming from an effective\r\nsource built from the EOB Hamiltonian, the resummed tail effects\r\nlinked to propagation on a Schwarzschild background (see\r\nSec.~\\ref{sec:resum}), a residual tail dephasing $\\ui \\delta_{\\ell m}$\r\n(complex), and finally the $\\ell$-th power of a residual relativistic\r\namplitude correction (thus purely real) denoted $\\rho_{\\ell m}$. The\r\nfactorized resummed waveforms achieve better agreement with NR results\r\nthan the conventional Taylor expanded PN waveforms~\\cite{DIN09, DN09,\r\n  Buon09, FI10}. For $\\ell + m$ even (corresponding to even-parity\r\n$\\epsilon=0$) we have\r\n%\r\n\\begin{equation}\\label{factor}\r\nH_{\\ell m} = H_{\\ell m}^\\text{N}\\,S_\\text{eff}\\,T_{\\ell m}\\,\\mathrm{e}^{\\ui\r\n  \\delta_{\\ell m}}\\,\\left(\\rho_{\\ell m}\\right)^\\ell\\,.\r\n\\end{equation}\r\n%\r\nThe Newtonian approximation to any even-parity mode reads\r\n%\r\n\\begin{align}\\label{HlmN}\r\nH_{\\ell m}^\\text{N} =& \\frac{(-)^{(\\ell-m+2)/2}}{2^{\\ell+1}\r\n  (\\frac{\\ell+m}{2})!  (\\frac{\\ell-m}{2})!(2\\ell-1)!!}\r\n\\left(\\frac{5(\\ell+1)(\\ell+2)(\\ell+m)!(\\ell-m)!}{\\ell\r\n  (\\ell-1)(2\\ell+1)}\\right)^{1/2} \\!\\!s_\\ell(\\nu) \\,(i m)^\\ell\r\n\\,x^{\\ell/2-1}\\,,\r\n\\end{align}\r\n% \r\nwhere we denote $s_\\ell(\\nu)\\equiv X_2^{\\ell-1}+(-)^\\ell\r\nX_1^{\\ell-1}$, see \\textit{e.g.} Eq.~(9.5) in Ref.~\\cite{BFIS08}. The\r\neffective source $S_\\text{eff} = \\frac{H_\\text{eff}}{\\mu c^2}$ is\r\ngiven at order 3PN by\r\n%\r\n\\begin{align}\\label{Seff}\r\nS_\\text{eff} &= 1 -\\frac{x}{2} \\biggl\\{ 1 +\\left(-\\frac{3}{4} -\r\n\\frac{1}{3}\\nu\\right) x + \\left(-\\frac{27}{8} + \\frac{11}{4}\\nu\\right)\r\nx^2 \\nonumber \\\\ & \\quad \\quad + \\left( -\\frac{675}{64} +\r\n\\left[\\frac{4417}{72} - \\frac{205}{96}\\pi^2 \\right]\\nu -\r\n\\frac{17}{6}\\nu^2 + \\frac{\\nu^3}{81} \\right) x^3 +\r\n\\mathcal{O}\\left(\\frac{1}{c^8}\\right)\\biggr\\}\\,.\r\n\\end{align}\r\n%\r\nFor $m\\geqslant 0$, the leading Schwarzschild tail factor reads\r\n%\r\n\\begin{equation}\\label{Tellm}\r\nT_{\\ell m} = \\frac{\\Gamma\\left(\\ell+1-2\\ui\r\n  k_m\\right)}{\\Gamma(\\ell+1)}\\,\\mathrm{e}^{k_m\\left[\\pi +\r\n    2\\ui\\ln\\left(2m\\omega_0 b\\right)\\right]}\\,,\r\n\\end{equation}\r\n%\r\nin which we denote $k_m \\equiv G M m \\omega/c^3$, with $M$ being the ADM mass\r\nto be inserted here at 1PN order like in Eq.~\\eqref{changephaseomega} (see\r\nEq.~(5.23) in Ref.~\\cite{BFIS08}), and where $\\omega_0 b$ is a pure real\r\nnumber to be found from Eq.~\\eqref{omega0}.\\footnote{Our definition takes into\r\n  account the modification of the phase given by Eq.~\\eqref{changephaseomega}.\r\n  The factor used in Ref.~\\cite{DIN09} is thus related to ours by\r\n  $T^\\text{DIN}_{\\ell m}=T_{\\ell m}\\mathrm{e}^{2\\ui\r\n    k_m\\ln(\\omega/\\omega_0)}$.} Note that the EOB tail factor~\\eqref{Tellm} is\r\nmotivated by the factorized resummed waveform~\\eqref{resumzL}. Indeed, the\r\ndominant Fourier component of the mode $h_{\\ell m}$ defined by\r\nEq.~\\eqref{modedef} is obtained by setting $\\Omega = m \\omega$ in the\r\nstationary phase approximation.\r\n\r\nAs for the residual dephasings $\\delta_{33}$ and $\\delta_{31}$, we\r\nfind that they do not receive any finite mass corrections\r\n$\\mathcal{O}(\\nu)$ at order 3PN, and are therefore given by the sum of\r\nthe expressions~(22) and (24) of Ref.~\\cite{DIN09} truncated at order\r\n2.5PN, and the 3PN contributions in the test mass limit computed in\r\nEqs.~(5.8c) and~(5.8e) of Ref.~\\cite{FI10}, \\textit{i.e.} up to order\r\n3PN:\r\n%\r\n\\begin{subequations}\\label{deltalm}\r\n\\begin{align}\r\n\\delta_{33} &= \\frac{13}{10} y^{3/2} - \\frac{80897}{2430} \\nu y^{5/2}\r\n+ \\frac{39}{7}\\pi y^3 +\r\n\\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\,,\\\\ \\delta_{31} &=\r\n\\frac{13}{30} y^{3/2} - \\frac{17}{10}\\nu y^{5/2} + \\frac{13}{21}\\pi\r\ny^3 + \\mathcal{O}\\left(\\frac{1}{c^7}\\right)\\,,\r\n\\end{align}\\end{subequations}\r\n%\r\nwith $y = (G M \\omega/c^3)^{2/3}$, and $M$ is the ADM mass.\r\n\r\nFinally the most important inputs we provide in this application are\r\nthe finite mass corrections to order 3PN of the amplitude factors\r\n$\\rho_{33}$ and $\\rho_{31}$ that will form the main blocks in the\r\nfactorized resummation of waveforms~\\cite{DIN09, FI10, Fuj22PN}. These\r\nare straightforwardly computed from Eqs.~\\eqref{hlm}; for completeness\r\nwe report here the full 3PN expressions, extending at 3PN order\r\nEqs.~(52) and~(54) in Ref.~\\cite{DIN09}:\r\n%\r\n\\begin{subequations} \\label{rholm}\\begin{align}\r\n\\rho_{33} &= 1+ \\left(-\\frac{7}{6}+\\frac{2}{3}\\nu\\right)x +\r\n\\left(-\\frac{6719}{3960}-\\frac{1861}{990}\\nu\r\n+\\frac{149}{330}\\nu^2\\right)x^2 \\nonumber\\\\ &\\qquad + \\left(\r\n\\frac{3203101567}{227026800} - \\frac{26}{7}\\gamma_\\text{E} -\r\n\\frac{13}{7}\\ln\\left(36 x\\right) + \\biggl[-\\frac{129509}{25740} +\r\n  \\frac{41}{192} \\pi^2 \\biggr] \\nu\r\n\\right.\\nonumber\\\\&\\qquad\\qquad\\qquad \\left. - \\frac{274621}{154440}\r\n\\nu^2 + \\frac{12011}{46332} \\nu^3\\right)x^3 +\r\n\\mathcal{O}\\left(\\frac{1}{c^8}\\right) \\,, \\\\ \\rho_{31} &= 1+\r\n\\left(-\\frac{13}{18}-\\frac{2}{9}\\nu\\right)x +\r\n\\left(\\frac{101}{7128}-\\frac{1685}{1782}\\nu -\r\n\\frac{829}{1782}\\nu^2\\right)x^2\\nonumber\\\\ &\\qquad +\r\n\\left(\\frac{11706720301}{6129723600} - \\frac{26}{63}\\gamma_\\text{E} -\r\n\\frac{13}{63}\\ln\\left(4 x\\right) + \\biggl[-\\frac{9688441}{2084940} +\r\n  \\frac{41}{192} \\pi^2 \\biggr] \\nu\r\n\\right.\\nonumber\\\\&\\qquad\\qquad\\qquad \\left. + \\frac{174535}{75816}\r\n\\nu^2 - \\frac{727247}{1250964} \\nu^3\\right)x^3 +\r\n\\mathcal{O}\\left(\\frac{1}{c^8}\\right) \\,.\r\n\\end{align}\\end{subequations}\r\n%\r\nThis completes our application to EOB resummed waveforms.\r\n\r\n\\acknowledgments We thank the Indo-French collaboration (IFCPAR) under\r\nwhich a major part of this work has been carried out. B.R.I. is\r\ngrateful to IHES, France, and G.F. and L.B. to RRI, India for their\r\nsupport during the final stages of the project. We also thank Cyril\r\nDenoux for checking the typesetting of the longest equations.\r\n\r\n\\appendix\r\n\r\n\\section{Integration of elementary cubic source terms}\r\n\\label{app:cubic_integrals}\r\n\r\nIn order to compute the tail-of-tail contributions to the waveform in\r\nthe far zone, we need to control the dominant asymptotic behaviour at\r\nfuture null infinity of the (finite part of the) retarded integrals of\r\nrelevant cubic-source piece, \\textit{i.e.}\r\n$\\Lambda^{\\alpha\\beta}_{(3)}$ in the notation of Eq.~\\eqref{un}. This\r\nproblem is essentially solved in Appendix A of Ref.~\\cite{B98tail},\r\nbut we shall provide here some more details and additional material.\r\n\r\nFor generic elementary source terms with multipolarity $\\ell$ and\r\nradial dependence $1/r^{k}$ ($k\\geqslant 1$) that involve a non-local\r\nintegral whose kernel is a Legendre function $Q_m(x)$, we\r\nconsider:\\footnote{The Legendre function of the second kind $Q_m(x)$\r\n  considered here has a branch cut from $-\\infty$ to $1$, and is\r\n  defined by (the first equality being known as Neumann's formula)\r\n%\r\n\\begin{equation}\\label{legendre}\r\nQ_m(x) = \\frac{1}{2} \\int_{-1}^1 \\ud z\\,\\frac{P_m(z)}{x-z} =\r\n\\frac{1}{2} P_m (x) \\, \\mathrm{ln} \\left(\\frac{x+1}{x-1} \\right)-\r\n\\sum^{m}_{ j=1} \\frac{1}{j} P_{m-j}(x) P_{j-1}(x)\\,,\r\n\\end{equation}\r\n%\r\nwhere $P_m(z)$ is the usual Legendre polynomial whose Rodrigues'\r\nrepresentation reads\r\n%\r\n\\begin{equation}\\label{rodrigues}\r\nP_m(z) = \\frac{1}{2^m m!} \\frac{\\ud^m}{\\ud z^m}\r\n\\Bigl[(z^2-1)^m\\Bigr]\\,.\r\n\\end{equation}\r\n%\r\n}\r\n%\r\n\\begin{equation}\r\n\\Psi^L_{m,\\ell,k}= \\mathop{\\mathrm{FP}}_{B=0} \\, \\Box^{-1}_\\mathrm{ret}\r\n\\Big[\\widetilde{r}^B \\hat{n}_L r^{-k}\\int^{+\\infty}_1\\!\\!\\!\\!  \\ud x\r\n  \\, Q_m(x) F (t - rx) \\Big] \\,.\r\n\\end{equation}\r\n%\r\nDepending on the values of $m$, $\\ell$ and $k$, the far-zone expansion\r\nof $\\Psi^L_{m,\\ell,k}$ when $r\\to\\infty$ (with $t_r=\\text{const}$)\r\ntakes one of the following forms. For $k=1$ and $m=\\ell$ we have\r\n%\r\n\\begin{equation}\\label{eq:1lPsiL}\r\n\\Psi^L_{\\ell,\\ell,1} = -{\\hat{n}_L\\over 8r} \\int^{+\\infty}_0 \\! \\!\r\n\\!\\!\\ud\\tau F^{(-1)} (t_r - \\tau) \\biggl[ \\ln^2 \\Big( \\frac{\\tau}{2r}\r\n  \\Big) + 4 H_\\ell \\ln \\Big( \\frac{\\tau}{2r} \\Big) + 4 H^2_\\ell\r\n  ~\\biggr] + \\mathcal{O}\\Big( \\frac{1}{r^{2-\\epsilon}}\\Big) \\,,\r\n\\end{equation}\r\n%\r\nwhere $H_\\ell=\\sum_{j=1}^\\ell \\frac{1}{j}$ is the $\\ell$-th harmonic\r\nnumber, and $F^{(-1)}$ denotes the anti-derivative of $F$ that\r\nvanishes at $-\\infty$. For $2 \\leqslant k \\leqslant \\ell+2$ and\r\n$k\\geqslant \\ell +3$ respectively, we have\r\n%\r\n\\begin{subequations}\r\n\\begin{align} \\label{eq:klPsiL}\r\n& \\Psi^L_{m,\\ell,k} = - \\alpha_{m,\\ell,k} ~\\frac{\\hat{n}_L}{r} F^{(k-3)}\r\n  (t_r) + \\mathcal{O}\\Big( \\frac{1}{r^{2-\\epsilon}}\\Big) \\,, \\\\ &\r\n  \\Psi^L_{m,\\ell,k} = -\\frac{\\hat{n}_L}{r} \\int^{+\\infty}_0 \\!\\!\\!\\!\r\n  d\\tau F^{(k-2)} (t_r - \\tau)\\Big[ \\beta_{m,\\ell,k} \\ln \\Big(\r\n    \\frac{\\tau}{2r_0} \\Big) + \\gamma_{m,\\ell,k} \\Big] +\r\n  \\mathcal{O}\\Big( \\frac{1}{r^{2-\\epsilon}}\\Big) \\,.\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nThe formula~\\eqref{eq:1lPsiL} and the explicit expression of\r\n$\\alpha_{m,\\ell,k}$ for arbitrary $m$, $\\ell$, $k$, are obtained in\r\nRef.~\\cite{B98tail}, as well as the explicit expressions of\r\n$\\beta_{m,\\ell,k}$ and $\\gamma_{m,\\ell,k}$ for specific values of $k$\r\nand $\\ell$.\r\n\r\nLet us first recall the derivation of the coefficient\r\n$\\alpha_{m,\\ell,k}$ which is given for general values of $k$ and\r\n$\\ell$ such that $2 \\leqslant k \\leqslant \\ell+2$ by\r\n%\r\n\\begin{equation} \\label{eqkmalphal}\r\n\\alpha_{m,\\ell,k} = \\int_1^{+\\infty} \\!\\!\\!\\! \\ud x \\, Q_m(x)\r\n\\int_{x}^{+\\infty} \\ud z \\, Q_\\ell(z)\\,\\frac{(z-x)^{k-3}}{(k-3)!}\\,.\r\n\\end{equation}\r\n%\r\nIt is convenient to introduce as intermediate notation the\r\n$(k-2)$-th anti-derivative of $Q_\\ell(x)$ that vanishes at\r\n$x=+\\infty$, and given for $k\\geqslant 3$ by\r\n%\r\n\\begin{equation}\\label{antiderQ}\r\nQ^{(-k+2)}_\\ell(x) = - \\int_{x}^{+\\infty}\\ud\r\nz\\,Q_\\ell(z)\\,\\frac{(x-z)^{k-3}}{(k-3)!} \\,.\r\n\\end{equation}\r\n%\r\nFor $k=2$ we naturally pose $Q^{(0)}_\\ell(x)=Q_\\ell(x)$. Recalling\r\nthat $Q_\\ell(z)$ behaves like $z^{-\\ell-1}$ when $z\\to+\\infty$ we see\r\nthat the integral in the right-side is convergent when $k \\leqslant\r\n\\ell+2$. Anti-derivatives of Legendre functions can straightforwardly\r\nbe expanded on the basis of Legendre functions themselves by means of\r\nthe recurrence relation $(\\ud/\\ud z)[Q_{\\ell+1}(x)- Q_{\\ell-1}(x)] =\r\n(2\\ell +1) Q_\\ell (x)$. This leads to\r\n%\r\n\\begin{align}\\label{expandQ}\r\nQ^{(-k+2)}_\\ell(x) &= (-)^k \\sum_{j=0}^{k-2}\r\nC_{\\ell,j}^{k-2}\\,Q_{\\ell+2j-k+2}(x)\\,,\\\\ \\text{with}\\quad\r\nC_{\\ell,j}^{k-2} &= (-)^j{\\genfrac{(}{)}{0pt}{}{k-2}{j}}\r\n\\frac{(2\\ell+2j-2k+3)!!}{(2\\ell+2j+1)!!}(2\\ell-2k+4j+5)\\,,\r\n\\end{align}\r\n%\r\nwhere ${\\genfrac{(}{)}{0pt}{}{k-2}{j}}$ is the usual binomial\r\ncoefficient. Hence the coefficient $\\alpha_{m,\\ell,k}$ reads\r\n%\r\n\\begin{equation} \\label{alphaalt}\r\n\\alpha_{m,\\ell,k} = (-)^k \\int_1^{+\\infty} \\!\\!\\!\\! \\ud x \\,\r\nQ_m(x)\\,Q^{(-k+2)}_\\ell(x) =\r\n\\sum_{j=0}^{k-2}C_{\\ell,j}^{k-2}\\,j_{m,\\ell+2j-k+2}\\,,\r\n\\end{equation}\r\n%\r\nwhere the remaining integral are explicitly given by (see\r\n\\textit{e.g.}~\\cite{GR})\\footnote{Notice that\r\n  $\\psi(m+1)-\\psi(p+1)=H_m-H_p$ and\r\n  $\\psi'(m+1)=\\frac{\\pi^2}{6}-H_{m,2}$, where $\\psi(x)$ is the usual\r\n  logarithmic derivative of the Euler gamma function $\\Gamma(x)$ and\r\n  $H_{m,2}= \\sum_{j=1}^m \\frac{1}{j^2}$ is the $m$-th generalized\r\n  harmonic number of order 2.}\r\n%\r\n\\begin{equation}\r\n\\label{jmp}\r\nj_{m,p} = \\int_1^{+\\infty} \\ud x\\, Q_m(x) Q_p(x) =\r\n\\left\\{\\begin{array}{l}\\displaystyle\r\n\\frac{H_m-H_p}{(m-p)(m+p+1)}\\quad\\text{for $m\\not=\r\n  p$}\\,,\\\\[0.6cm]\\displaystyle\r\n\\frac{1}{2m+1}\\left(\\frac{\\pi^2}{6}-H_{m,2} \\right)\\quad\\text{for\r\n  $m=p$}\\,.\\end{array}\\right.\r\n\\end{equation}\r\n%\r\n\r\nWe next tackle the case of the two other coefficients\r\n$\\beta_{m,\\ell,k}$ and $\\gamma_{m,\\ell,k}$, defined for generic values\r\nof $k$ and $\\ell$ such that $k\\geqslant \\ell +3$ as double integrals,\r\n%\r\n\\begin{subequations} \\label{eq:coeffs}\r\n\\begin{align} \\label{eq:kmbetal}\r\n& \\beta_{m,\\ell,k} = \\int_1^{+\\infty} \\!\\!\\!\\! \\ud x \\, Q_m(x)\r\n  \\,J_{\\ell,k}(x) \\, , \\\\ \\label{eq:kmgammal} & \\gamma_{m,\\ell,k} =\r\n  \\int_1^{+\\infty} \\!\\!\\!\\! \\ud x\\, Q_m(x) \\Big[ \\bigl(\\ln 2\r\n    +H_{k-3}\\bigr) \\,J_{\\ell,k}(x) - K_{\\ell,k}(x) \\Big] \\, ,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nwith the following definitions:\r\n%\r\n\\begin{subequations}\\label{eq:kJl}\r\n\\begin{align} \r\n& J_{\\ell,k}(x) = \\frac{1}{2} \\int_{-1}^1 \\ud z \\, P_\\ell(z)\r\n  \\frac{(z-x)^{k-3}}{(k-3)!} \\, , \\\\ & K_{\\ell,k}(x) = \\frac{1}{2}\r\n  \\int_{-1}^1 \\ud z \\, P_\\ell(z) \\frac{(z-x)^{k-3}}{(k-3)!} \\ln\r\n  (x-z)\\, .\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nSimilarly to Eq.~\\eqref{antiderQ} we introduce the $(k-2)^\\text{th}$\r\nanti-derivative of the Legendre polynomial $P_\\ell(x)$ that vanishes\r\nat $x=-1$ and is defined by\r\n%\r\n\\begin{equation}\\label{antiderP}\r\nP^{(-k+2)}_\\ell(x) = \\int_{-1}^{x}\\ud z\\, P_\\ell(z)\\frac{(x-z)^{k-3}}{(k-3)!}\r\n\\,,\r\n\\end{equation}\r\n% \r\ntogether with $P^{(0)}_\\ell(x)=P_\\ell(x)$. For the Legendre polynomial\r\nwe have exactly the same expansion as in Eqs.~\\eqref{expandQ}, namely\r\n%\r\n\\begin{equation}\\label{expandP}\r\nP^{(-k+2)}_\\ell(x) = (-)^k \\sum_{j=0}^{k-2}\r\nC_{\\ell,j}^{k-2}\\,P_{\\ell+2j-k+2}(x)\\,.\r\n\\end{equation}\r\n%\r\nWe start by writing $J_{\\ell,k}(x)$ and $K_{\\ell,k}(x)$ in a way\r\nappropriate for future integration over $x$ with some kernel\r\n$Q_m(x)$. Since the following integral is already known \\cite{GR},\r\n%\r\n\\begin{equation}\\label{intGR}\r\n\\int_1^{+\\infty} \\ud x\\, Q_m(x) (x-1)^{\\nu} = 2^{\\nu}\r\n\\frac{[\\Gamma(\\nu+1)]^2\\,\\Gamma(m-\\nu)}{\\Gamma(m+\\nu+2)}\\,,\r\n\\end{equation}\r\n%\r\nour strategy will consist in expressing the integrals~\\eqref{eq:kJl}\r\nas a sum of monomials $(x-1)^\\nu$, with $\\nu\\in \\mathbb{N}$ or\r\n$\\mathbb{C}$. This is achieved by performing $k-3$ integrations by\r\nparts on the expressions~\\eqref{eq:kJl}. Concerning $J_{\\ell,k}(x)$\r\nthis results in\r\n%\r\n\\begin{equation}\\label{Jellk}\r\nJ_{\\ell,k}(x) = \\frac{(-)^{k+1}}{2}\\sum_{p=\\ell+1}^{k-2}\r\n\\frac{P^{(-p)}_\\ell(1)}{(k-p-2)!}\\,(x-1)^{k-p-2} \\,,\r\n\\end{equation}\r\n% \r\nwhere the coefficients of each of the monomials are built from the\r\nvalues at 1 of the anti-derivatives of the Legendre\r\npolynomial. Adapting some formulas for the anti-derivatives of the\r\nLegendre polynomial in Ref.~\\cite{GR}, we get the values at $z=1$ as\r\n%\r\n\\begin{equation}\r\n\\label{Plk1}\r\nP^{(-p)}_\\ell(1) = \\left\\{\\begin{array}{lr} 0 &\\text{for $1\\leqslant\r\n  p\\leqslant\\ell$}\\,,\\\\[0.4cm]\\displaystyle \\frac{(-)^\\ell 2^{p}\r\n  (p-1)!}{(p+\\ell)!(p-\\ell-1)!} &\\text{for $\\ell+1\\leqslant\r\n  p$}\\,.\\end{array}\\right.\r\n\\end{equation}\r\n%\r\nNote that the case for $1\\leqslant p\\leqslant\\ell$ is a simple\r\nconsequence of Rodrigues' formula~\\eqref{rodrigues}; accordingly, we\r\nhave written the sum in Eq.~\\eqref{Jellk} as starting with\r\n$p=\\ell+1$. Finally, the integral~\\eqref{eq:kmbetal} over $z$ can be\r\ncomputed with the help of formula~\\eqref{intGR} with $\\nu=k-p-2$.\r\n\r\nThe treatment of $K_{\\ell,k}(x)$ is more involved. It is based on the\r\nfact that $\\ln(x-z)=\\frac{\\ud}{\\ud B}[(x-z)^B]_{B=0}$ where $B$ is a\r\nconvenient complex parameter. The calculation of $K_{\\ell,k}(x)$ is\r\nthus similar to that of $J_{\\ell,k}(x)$ with one major difference:\r\nAfter the $k-3$ integrations by part, there remains a $x$-dependent\r\nfactor $(z-x)^B$ in the source of the integral, which becomes $B\r\n(z-x)^{B-1}$ after a last integration by part. The presence of the\r\nprefactor $B$ prevents the appearance of logarithms $\\ln (x-z)$ when\r\napplying the derivative $\\ud/\\ud B$ and taking the limit $B \\to 0$. We\r\nobtain at the end:\r\n%\r\n\\begin{align} \\label{eqkJlogl}\r\n K_{\\ell,k}(x) &= \\frac{\\ud}{\\ud\r\n   B}\\biggl[\\frac{(-)^{k+1}}{2}\\sum_{p=\\ell+1}^{k-2}\r\n   \\frac{P^{(-p)}_\\ell(1)}{(k-3)!}\r\n   \\frac{\\Gamma(B+k-2)}{\\Gamma(B+k-p-1)}\\,(x-1)^{B+k-p-2}\\biggr]_{B=0}\r\n \\nonumber \\\\ & + \\frac{(-)^k}{2} \\int_{-1}^1 \\ud z\\,\r\n \\frac{P^{(-k+2)}_\\ell(z)}{z-x} \\,.\r\n\\end{align}\r\n%\r\nThe last term in Eq.~\\eqref{eqkJlogl} is expanded by means of\r\nrelation~\\eqref{expandP}, whose validity extends to the case $k\r\n\\geqslant \\ell+3$, provided that we pose $P_{-m-1}(z) \\equiv\r\n-P_{m}(z)$ and $(-2m-1)!! \\equiv (-)^m/(2m-1)!!$ for any non-negative\r\ninteger $m$. Using also Neumann's formula~\\eqref{legendre}, we obtain\r\n%\r\n\\begin{equation}\\label{lasteq}\r\n\\frac{1}{2} \\int_{-1}^1 \\ud z\\, \\frac{P^{(-k+2)}_\\ell(z)}{z-x} =\r\n(-)^{k+1} \\sum_{j=0}^{k-2} C_{\\ell,j}^{k-2}\\,Q_{\\ell+2j-k+2}(z)\\,,\r\n\\end{equation}\r\n%\r\nwhere we have defined $Q_{-m-1}(z) \\equiv -Q_{m}(z)$ for\r\n$m\\in\\mathbb{N}$. Like for $J_{\\ell,k}(x)$, the next step consists in\r\nintegrating over $z$ each of the monomials $(x-1)^{B+k-p-2}$ by means\r\nof formula~\\eqref{intGR}, but this time with a complex parameter\r\n$\\nu=B+k-p-2$. After integration we apply the derivative with respect\r\nto $B$ and take the limit $B\\to 0$ which is straightforwardly\r\nperformed and yields in particular many terms involving the\r\nlogarithmic derivative $\\psi$ of the Euler gamma function $\\Gamma$\r\n[which relates, for integer arguments, to harmonic numbers through the\r\n  equality $\\psi(k+1) -\\psi(1)= H_k$]. Note that the integration over\r\n$z$ of the last term in~\\eqref{eqkJlogl} produces the coefficient\r\n$\\alpha_{m,\\ell,k}$; compare Eq.~\\eqref{lasteq} with\r\nEqs.~\\eqref{expandQ} and \\eqref{alphaalt}. However, the coefficient\r\n$j_{m,p}$ defined in Eqs.~\\eqref{jmp} must now be extended to the case\r\nwhere $p$ is negative by posing $j_{m, -|p| -1} = -j_{m, |p|}$.\r\n\r\nFinally we are in a position to write down the expressions for\r\n$\\beta_{m,\\ell,k}$ and $\\gamma_{m,\\ell,k}$ [besides that given\r\n  by~\\eqref{alphaalt} for $\\alpha_{m,\\ell,k}$] that are effectively\r\nused in the present work:\r\n%\r\n\\begin{subequations}\\label{betagammaused}\r\n\\begin{align}\r\n\\beta_{m,\\ell,k} &= (-)^{k + \\ell +1} 2^{k-3} \\sum_{j=0}^{k-\\ell-3}\r\n\\frac{(j+\\ell)!}{j!(j+2\\ell +1)!}  \\frac{(m-k+\\ell+2 + j)!}{(k-\\ell -3\r\n  -j)!}  \\frac{[(k-\\ell-3-j)!]^2}{(m+k-\\ell-2-j)!} \\,\r\n,\\\\ \\gamma_{m,\\ell,k} &= (-)^{k + \\ell} 2^{k-3} \\sum_{j=0}^{k-\\ell-3}\r\n\\frac{(j+\\ell)!}{j!(j+2\\ell +1)!}  \\frac{(m-k+\\ell+2 + j)!}{(k-\\ell -3\r\n  -j)!}  \\frac{[(k-\\ell-3-j)!]^2}{(m+k-\\ell-2-j)!} \\times \\nonumber\r\n\\\\ & \\qquad \\qquad \\qquad \\qquad \\qquad \\times \\Bigl(H_{k-\\ell-3-j} -\r\nH_{m+\\ell + 2 -k + j} - H_{m+k-\\ell -2 -j}\\Bigr) + \\alpha_{m,\\ell,k}\r\n\\,.\\label{gammaused}\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Proof of an elementary integration formula}\r\n\\label{app:proof_formula}\r\n\r\nWe derive the integration formula~\\eqref{elementaryIR} used in\r\nSec.~\\ref{sec:resum}. We start with the following formula, valid\r\nthrough analytic continuation for any $B\\in\\mathbb{C}$,\r\n%\r\n\\begin{equation}\\label{elementaryIRB}\r\n \\Box^{-1}_\\mathrm{ret} \\biggl[\\left(\\frac{r}{b}\\right)^B\r\n   \\frac{\\hat{n}_L}{r^{2}} F(t_r)\\biggr] = \\frac{\\hat{n}_L}{2r}\r\n \\int_0^{+\\infty}\\!\\!  \\ud\\tau F(t_r-\\tau) \\,\\frac{g_\\ell(B)\r\n   (\\tau/2b)^B- (r/b)^B}{B} + \\mathcal{O}\\Big(\r\n \\frac{1}{r^{2-\\epsilon}}\\Big) \\,,\r\n\\end{equation}\r\n%\r\nwhere the function $g_\\ell(B)$ is\r\n%\r\n\\begin{equation} \\label{gell}\r\ng_\\ell(B) =\r\n\\frac{\\Gamma(\\ell+1+B)\\Gamma(1-B)}{\\Gamma(1+B)\\Gamma(\\ell+1-B)} \\,.\r\n\\end{equation}\r\n%\r\nThis formula~\\eqref{elementaryIRB} is deduced from Eq.~(A.2) of\r\nRef.~\\cite{B98quad} by performing the change of variable $s=\\tau + r$,\r\nexpanding the STF derivative operator $\\hat{\\partial}_L$ (see~(A.15)\r\nin~\\cite{B98quad}), and keeping the leading term of order $1/r$. Here\r\nwe are working in a neigthbourhood of the value of interest $B=0$; in\r\nparticular, we suppose $\\Re(B) < \\epsilon$. We point out that the\r\nelementary integral~\\eqref{elementaryIRB} is convergent for $B$ close\r\nto zero. As usual we assume stationarity in the remote past, which\r\nimplies in this case that $F(t) = 0$ when $t< -\\mathcal{T}$. Thus,\r\ndespite the apparent presence of a pole $1/B$, the explicit\r\nexpression~\\eqref{elementaryIRB} is finite and regular as $B\\to\r\n0$. After differentiating $p$ times with respect to $B$, the left-hand\r\nside of~\\eqref{elementaryIRB} acquires $p$ powers of the logarithm of\r\n$r/b$, while the right-hand side is straightforwardly evaluated at\r\n$B=0$ with the help of the Leibniz rule. We find\r\n%\r\n\\begin{align} \\label{elementaryIRB2}\r\n \\Box^{-1}_\\mathrm{ret} \\Bigl[ \\frac{\\hat{n}_L}{r^2}\r\n   \\left(\\ln\\frac{r}{b}\\right)^p \\!F(t_r)\\Bigr] &=\r\n \\frac{\\hat{n}_L}{2(p+1)r} \\int_{0}^{+\\infty} \\!\\! \\ud\\tau F(t_r-\\tau)\r\n \\left(\\frac{\\partial^{p+1} }{\\partial B^{p+1}}\\left[g_\\ell(B)\r\n   \\left(\\frac{\\tau}{2b}\\right)^B - \\left(\\frac{r}{b}\\right)^B\r\n   \\right]\\right)_{B=0} \\nonumber\\\\ &+ \\mathcal{O}\\Big(\r\n \\frac{1}{r^{2-\\epsilon}}\\Big) \\,,\r\n\\end{align}\r\n%\r\nWe see that each application of the retarded integral operator\r\n$\\Box^{-1}_\\mathrm{ret}$ on a source term increases the maximal power\r\nof the logarithms by one unit. Since there is no logarithm in the\r\nlinearized part $h_{(1)}$, we infer by recurrence that the $n$-th MPM\r\ncoefficient $h_{(n)}$ contains logarithms with maximal power $n-1$\r\n(the reasoning is in fact valid for any piece $\\sim 1/r^k$ in the\r\nwaveform~\\cite{BD86}). Finally the formula~\\cite{GR}\r\n%\r\n\\begin{equation}\r\n\\int_0^{+\\infty}\\ud \\tau\\,\\tau^B\\,\\mathrm{e}^{\\ui \\Omega \\tau} =\r\n\\frac{\\Gamma(B+1)}{(-\\ui \\Omega)^{B+1}}\\,,\r\n\\end{equation}\r\n%\r\nachieves the integration of Eq.~\\eqref{elementaryIRB2} in the\r\nfrequency space. This yields\r\n%\r\n\\begin{align} \\label{intfourier}\r\n &\\Box^{-1}_\\mathrm{ret} \\Bigl[ \\frac{\\hat{n}_L}{r^2}\r\n   \\left(\\ln\\frac{r}{b}\\right)^p \\!F(t_r)\\Bigr] = \\nonumber\\\\ \r\n &\\qquad\\quad \\frac{\\hat{n}_L}{2(p+1)r}\r\n \\int_{-\\infty}^{+\\infty}\\frac{\\ud\\Omega}{2\\pi}\r\n \\frac{\\tilde{F}(\\Omega)\\,\\mathrm{e}^{-\\ui \\Omega\r\n     t_r}}{(-\\ui\\Omega)}\\left(\\frac{\\partial^{p+1} }{\\partial\r\n   B^{p+1}}\\left[\\frac{g_\\ell(B)\\Gamma(B+1)}{(-2\\ui \\Omega b)^B} -\r\n   \\left(\\frac{r}{b}\\right)^B \\right]\\right)_{B=0} \\!\\!+\r\n \\mathcal{O}\\Big( \\frac{1}{r^{2-\\epsilon}}\\Big) \\,,\r\n\\end{align}\r\n%\r\nwhich coincides with Eq.~\\eqref{elementaryIR}.\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Modal decomposition of the non-linear memory}\r\n\\label{app:memory_modes}\r\n\r\nThe expressions for the non-linear memory terms given in the text can\r\nbe recovered, after appropriate integrations by part, from the general\r\nformula known for any $\\ell$~\\cite{F09, F11}:\r\n%\r\n\\begin{subequations}\\label{eq:memgen}\\begin{align} \r\nU_{L}^\\text{mem} &= \\mathcal{U}_{L}^\\text{mem} + \\text{(instantaneous\r\n  contributions)} \\,, \\\\ \\text{with}\\qquad \\mathcal{U}_{L}^\\text{mem}\r\n&= \\frac{2 c^{\\ell-2} (2\\ell +1)!!}{(\\ell+1)(\\ell+2)}\r\n\\int_{-\\infty}^{T_R} \\ud t \\int \\ud \\Omega \\,\\frac{\\ud E}{\\ud t\\ud\r\n  \\Omega} \\,\\hat{N}_{L} \\,,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nwhere the instantaneous contributions come from the latter\r\nintegrations by part. For convenience these instantaneous terms have\r\nbeen transferred to the instantaneous part of the radiative moments,\r\nsee Eqs.~\\eqref{UVL}. They have been included into our explicit\r\nexpressions at 3.5PN order in Sec.~\\ref{sec:inst}. Recall in addition\r\nthat we have $V_{L}^\\text{mem} = 0$ for any current moments (at any PN\r\norder).\r\n\r\nHere, $\\frac{\\ud E}{\\ud t\\ud \\Omega} = \\frac{R^2c^3}{32\\pi G}\r\n\\,(\\partial_t g^\\text{TT}_{ij})^2$ is the gravitational-wave energy\r\nflux per solid angle unit; the other notations are the same as in\r\nSec.~\\ref{sec:rad}. The right-hand side may be put in a more explicit\r\nform by substituting to $g^\\text{TT}_{ij}$ its asymptotic\r\nexpansion~\\eqref{gijTT} and integrating over the solid angle. The last\r\noperation is achieved by means of the useful identity:\r\n%\r\n\\begin{align}\r\n\\int\\frac{ \\ud \\Omega}{4\\pi} \\hat{n}_{L_1} \\hat{n}_{L_2} n_L =\r\n\\frac{\\ell_1!  \\ell_2!  \\ell!}{(\\frac{\\ell_1+\\ell_2-\\ell}{2})!\r\n  (\\frac{\\ell_1+\\ell-\\ell_2}{2})!(\\frac{\\ell_2+\\ell-\\ell_1}{2})!}\r\n\\frac{\\delta^{\\langle k_1}_{i_1} \\!\\!\\dots \\delta^{k_s}_{i_s}\\delta^{\r\n    k_{s+1}}_{j_1} \\!\\!\\dots \\delta^{k_\\ell \\rangle}_{j_{\\ell-s}}\r\n  \\delta^{\\langle i_{s+1}}_{j_{\\ell-s+1}} \\!\\!\\dots\r\n  \\delta^{i_{\\ell_1}\\rangle}_{j_{\\ell_2}}}{(\\ell+\\ell_1+\\ell_2)!!} \\,,\r\n\\end{align}\r\n%\r\nwith $s=(\\ell_1+\\ell-\\ell_2)/2$ and $|\\ell_1-\\ell_2|\\leqslant \\ell\r\n\\leqslant \\ell_1+\\ell_2$ (hence $s \\leqslant \\ell$ and $s \\leqslant\r\n\\ell_1$).\r\n\r\nAfter some combinatorics we find\r\n%\r\n\\begin{align}\r\nU_{L}^\\text{mem} & = \\frac{2G}{c^3 (\\ell+1) (\\ell+2)} \\sum_{p, k}\r\n\\frac{1}{c^{2p}p! k} \\frac{(2\\ell +1)!!}{(2p+2\\ell+1)!!}  \\biggl(\r\n\\genfrac{}{}{0pt}{}{\\ell}{k-p} \\biggr) \\nonumber \\\\ & \\quad\\times\r\n\\int_{-\\infty}^{T_R} \\ud\\tau \\biggl[ d^\\ell_{pk} \\, U^{(1)}_{P\\langle\r\n    K-P} U^{(1)}_{L-[K-P]\\rangle P} + \\frac{e^\\ell_{pk}}{c^2} \\,\r\n  V^{(1)}_{P\\langle K-P} V^{(1)}_{L-[K-P]\\rangle P} \\nonumber \\\\ &\r\n  \\qquad\\qquad\\qquad + \\frac{f^\\ell_{pk}}{c^2} \\varepsilon_{ab\\langle\r\n    i_1} \\, U^{(1)}_{\\underline{aP} K-P-1} V^{(1)}_{L-[K-P]\\rangle b\r\n    P} \\biggr] \\,.\r\n\\end{align}\r\n%\r\nNote that this expression is implicit because the radiative moment\r\n$U_L$ in the right-hand side contains itself a memory\r\ncontribution. The coefficient $d^\\ell_{pk}$ reads\r\n%\r\n\\begin{equation}\r\nd^\\ell_{pk} = k - 4 p \\frac{2p+2\\ell+1}{2p+\\ell-k} +\r\n\\frac{2p(p-1)(2p+2\\ell+1)(2p+2\\ell-1)}{(k-1)(2p+\\ell-k)\r\n  (2p+\\ell-k-1)}\\,,\r\n\\end{equation}\r\n% \r\nif $\\text{max}(0, [(5-\\ell)/2]) \\leqslant p$ and $\\text{max}(p+1,2)\r\n\\leqslant k \\leqslant \\text{min} (p+\\ell, 2p + \\ell -2)$ (with\r\n$[\\cdots]$ denoting the integer part), and $d^\\ell_{pk} = 0$\r\notherwise. The other coefficients are given by\r\n%\r\n\\begin{equation}\r\ne^\\ell_{pk} = \\frac{4 k (2p+\\ell-k)}{(k+1)(2p+\\ell-k+1)}\r\nd^\\ell_{pk}\\,,\r\n\\end{equation}\r\n% \r\nand\r\n%\r\n\\begin{equation}\r\nf^\\ell_{pk} = \\frac{8 (k-p)}{(2p+\\ell-k+2)} \\biggl[\r\n  \\frac{p(2p+2\\ell+1)}{(k-1)(2p+\\ell-k)} -1 \\biggr]\\,,\r\n\\end{equation}\r\n% \r\nif $\\text{max}(0, [(4-\\ell)/2]) \\leqslant p$ and $\\text{max}(p,2)\r\n\\leqslant k \\leqslant \\text{min} (p+\\ell, 2p + \\ell -1)$, and\r\n$f^\\ell_{pk} = 0$ otherwise.\r\n\r\nFor completeness, we shall now provide the corresponding formula for\r\nthe modal decomposition of the non-linear memory term. The complex\r\nwaveform $h \\equiv h_+ - \\ui h_\\times$ can be decomposed onto an\r\northonormal basis of functions with spin-weight -2 defined over the\r\nunit sphere. Here we shall choose the set of spin-weighted spherical\r\nharmonics $Y^{\\ell m}_{-2}(\\Theta,\\Phi)$ and use the same conventions\r\nas in Refs.~\\cite{BFIS08, FMBI12}:\r\n%\r\n\\begin{equation}\\label{eq:hdecomp}\r\nh = \\sum^{+\\infty}_{\\ell=2}\\sum^{\\ell}_{m=-\\ell} h_{\\ell\r\nm} \\,Y^{\\ell m}_{-2}(\\Theta,\\Phi)\\,.\r\n\\end{equation}\r\n%\r\nThe coefficients $h_{\\ell m}$ may be written in terms of mass and\r\ncurrent type radiative components $U_{\\ell m}$ and $V_{\\ell m}$\r\n(corresponding to a decomposition in even and odd parity modes in the\r\ncase on non-spinning compact binaries):\r\n%\r\n\\begin{equation}\\label{eq:inv}\r\nh_{\\ell m} = -\\frac{G}{\\sqrt{2}\\,R\\,c^{\\ell+2}}\\left[U_{\\ell\r\nm}-\\frac{\\ui}{c}V_{\\ell m}\\right]\\,,\r\n\\end{equation}\r\n%\r\nThose are related to the STF radiative moments by~\\cite{Th80}:\r\n%\r\n\\begin{subequations} \\label{eq:UV}\r\n\\begin{align}\r\nU_{\\ell m} &=\r\n\\frac{4}{\\ell!}\\,\\sqrt{\\frac{(\\ell+1)(\\ell+2)}{2\\ell(\\ell-1)}}\r\n\\,\\alpha^L_{\\ell m}\\,U_L\\,,\\label{eq:U}\\\\ V_{\\ell m} &\r\n=-\\frac{8}{\\ell!}\\,\\sqrt{\\frac{\\ell(\\ell+2)}{2(\\ell+1)(\\ell-1)}}\r\n\\,\\alpha^L_{\\ell m}\\,V_L\\,,\r\n\\end{align}\r\n\\end{subequations}\r\n%\r\nwhere $\\alpha_L^{\\ell m}$ is the unique (constant) STF tensor such\r\nthat\r\n%\r\n\\begin{equation} \\label{defalphaL}\r\n\\hat{N}_L = \\sum_{m=-\\ell}^{\\ell} \\alpha^L_{\\ell m}\\,Y^{\\ell\r\n  m}(\\Theta,\\Phi)\\,.\r\n\\end{equation}\r\n%\r\n\r\nTo compute the memory mode $U_{\\ell m}^\\text{mem}\\propto\r\n\\alpha^L_{\\ell m} U_L^\\text{mem}$, we insert the angular integral of\r\nEq.~\\eqref{eq:memgen} into the form~\\eqref{eq:U} and contract\r\n$\\alpha^L_{\\ell m}$ with $\\hat{N}_L$ using the\r\nproperty~\\eqref{defalphaL}~\\cite{F09}. It remains to integrate a\r\nproduct of three harmonic functions. After writing them as Wigner\r\nmatrices, we obtain an explicit expression for the required integral\r\nby means of standard integration formulas:\r\n%\r\n\\begin{multline}\r\n\\int \\frac{\\ud \\Omega}{4\\pi} \\overline{Y}^{\\ell m}(\\Theta,\\Phi)\r\nY^{\\ell' m'}_{-2}(\\Theta,\\Phi) \\overline{Y}^{\\ell''\r\n  m''}_{-2}(\\Theta,\\Phi) \\\\= (-)^{m+m'}\r\n\\Big(\\frac{(2\\ell+1)(2\\ell'+1)(2\\ell''+1)}{(4\\pi)^3}\\Big)^{1/2} \\left(\r\n\\begin{array}{ccc}\r\n\\ell & \\ell' & \\ell'' \\\\\r\n0 & 2 & -2 \r\n\\end{array}\r\n\\right) \\left(\r\n\\begin{array}{ccc}\r\n\\ell & \\ell' & \\ell'' \\\\\r\n-m & m' & -m'' \r\n\\end{array}\r\n\\right) \\, .\r\n\\end{multline}\r\n%\r\nThis yields for the memory mode $(\\ell,m)$\r\n%\r\n\\begin{align}\r\n\\mathcal{U}_{\\ell m}^\\text{mem} &= \\frac{G}{c^3}\r\n\\Big[\\frac{(2\\ell+1)(\\ell-2)!}{8\\pi (\\ell +2)!} \\Big]^{1/2} \\! \\! \\!\r\n\\!  \\sum_{k \\geqslant \\text{max}(0,4-\\ell)}\r\n\\sum_{\\ell'=\\text{max}([\\frac{k+1}{2}],2)}^{\\text{min}([\\frac{k}{2}]+\\ell,k+\\ell-2)}\r\n\\sum_{m'=\r\n  \\text{max}(-\\ell',m+\\ell'-\\ell-k)}^{\\text{min}(\\ell',m+\\ell-\\ell'+k)}\r\n\\frac{(-)^{m'}}{c^k} \\times \\nonumber \\\\ & \\qquad \\times\r\n\\bigl[(2\\ell'+1)(2k+2\\ell-2\\ell'+1)\\bigr]^{1/2}\r\n\\bigg(\\begin{array}{ccc} \\ell & \\ell' & k + \\ell - \\ell' \\\\ 0 & 2 &\r\n  -2 \\end{array} \\bigg) \\bigg(\\begin{array}{ccc} \\ell & \\ell' & k +\r\n  \\ell - \\ell' \\\\ -m & m' & m-m' \\end{array} \\bigg) \\times \\nonumber\r\n\\\\ & \\qquad \\times \\Big[ \\int_{-\\infty}^{T_R} \\ud\\tau \\,\r\n  U^{(1)}_{\\ell' m'} \\overline{U}^{(1)}_{k+\\ell-\\ell'\\, m'-m} +\r\n  \\frac{1}{c^2} \\int_{-\\infty}^{T_R} \\ud\\tau \\, V^{(1)}_{\\ell' m'}\r\n  \\overline{V}^{(1)}_{k+\\ell-\\ell'\\, m'-m} \\nonumber \\\\ & \\qquad \\quad\r\n  + \\frac{\\ui}{c} \\int_{-\\infty}^{T_R} \\ud\\tau \\bigl(U^{(1)}_{\\ell'\r\n    m'} \\overline{V}^{(1)}_{k+\\ell-\\ell'\\, m'-m}- V^{(1)}_{\\ell' m'}\r\n  \\overline{U}^{(1)}_{k+\\ell-\\ell'\\, m'-m}\\bigr) \\Big]\r\n\\end{align}\r\n%\r\nwhere the even-$k$ (odd-$k$) coefficients cancel each other for memory\r\nintegrals over products of multipole moments with different\r\n(identical) parities, as one can check explicitly.\r\n\r\n\\bibliography{ListeRef.bib}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "70d8fbd184661be78d505aa319eb5452a4634c66", "size": 133987, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Waveforms/source/FBI_Sep2014/FBI_Sept14_grqc.tex", "max_stars_repo_name": "keefemitman/PostNewtonian", "max_stars_repo_head_hexsha": "853d6577cb0002da5eebe1cb55f0c28fbc114324", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2015-03-26T01:04:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T19:26:21.000Z", "max_issues_repo_path": "Waveforms/source/FBI_Sep2014/FBI_Sept14_grqc.tex", "max_issues_repo_name": "keefemitman/PostNewtonian", "max_issues_repo_head_hexsha": "853d6577cb0002da5eebe1cb55f0c28fbc114324", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-01-08T23:46:29.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-20T19:13:51.000Z", "max_forks_repo_path": "Waveforms/source/FBI_Sep2014/FBI_Sept14_grqc.tex", "max_forks_repo_name": "keefemitman/PostNewtonian", "max_forks_repo_head_hexsha": "853d6577cb0002da5eebe1cb55f0c28fbc114324", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-13T02:36:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-23T21:36:32.000Z", "avg_line_length": 50.0885981308, "max_line_length": 85, "alphanum_fraction": 0.6437714107, "num_tokens": 49371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.440908334847224}}
{"text": "\\documentclass{article} % For LaTeX2e\n\\usepackage[a4paper,margin=1.5in]{geometry}\n\\usepackage[mathlines]{lineno}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{bm}\n\\usepackage{hyperref}\n\\usepackage{natbib}\n\\usepackage{latexsym,amsbsy,amssymb,color,xspace, booktabs}\n\n\\include{macros}\n\\include{local_macros}\n\\def\\linenumberfont{\\normalfont\\small\\sffamily}\n\n\\title{Multiple Output Gaussian Processes Regression}\n\n\\newcommand{\\fix}{\\marginpar{FIX}}\n\\newcommand{\\new}{\\marginpar{NEW}}\n\n%\\nipsfinalcopy % Uncomment for camera-ready version\n\n\\begin{document}\n\\maketitle\n\\linenumbers\n\n\\section{Model Description}\nWe describe a multiple-output regression model.\nSuppose that we have inputs $\\X = \\{\\x_n\\}_{n=1}^N$ and outputs $\\y = \\{\\y_n\\}_{n=1}^N$, with $\\x_n \\in \\calR^D$ and $\\y_n \\in \\calR^P$, i.e. the output is $P$-dimensional.\nFor ease of exposition, we assume that there are no missing values in any output dimension.\nThe most dominant approach in GP-based multiple output regression is to compose the different outputs as some \\textit{linear} mixing (combination) of some basic processes (random functions).\nOur model is also underpinned by this composition approach.\n\n\\noindent Consider the semiparametric latent factor models (SLFM) \\cite{teh-et-al-aistats-05}.\nIt assumes $Q$ basic independent processes, $g_j(\\x) \\sim \\GP(0, k(\\x,\\x';\\vectheta_j))$, where $\\vectheta_j$ is the hyperparameters of the covariance function of $g_j(\\x)$.\nEach (latent) output is a weighted combination of these basic processes, i.e.\n\\begin{align}\nf_i(\\x) = \\sum_{j=1}^Q w_{ij} g_j(\\x), \\quad i = 1 \\hdots P,\n\\end{align}\nIn \\cite{seeger2005semiparametric}, an extra degree of freedom is given by allowing each output $i$ to have its own process $h_i(\\x) \\sim \\GP(0, k(\\x,\\x'; \\vectheta^h_i)$ leading to\n\\begin{align}\nf_i(\\x) = \\sum_{j=1}^Q w_{ij} g_j(\\x) + h_i(\\x), \n\\end{align}\nWe emphasize that, although $k$ denotes covariance functions in general, each independent process can have its own covariance function.\n\n\\noindent \n\\textbf{Augmented sparse GPs}\nToward scalable modeling, we replace standard GPs with sparse GPs augmented with \\textit{different} set of inducing inputs.\nThis adds much flexibility to the model as each of the shared process $g_j(\\x)$ can model a different pattern in the data with its own covariance function and inducing inputs. The roles of $g_j(\\x)$ and $h_i(\\x)$ can be quite different, so it is necessary that each has its own inducing inputs.\nFurthermore, $g_j(\\x)$ can be seen as a \\textit{global} function operating on the entire input space (of all output dimensions), while each $h_i(\\x)$ operates only on the inputs of the $i$-th output, which can be a subspace of the input.\n\n%However, to really address the issue of scalability, this model is built upon sparse GPs from the ground up.\n\n\\subsection{Prior and Likelihood}\nIn this section we specify the prior and likelihood of this model. \n\\newcommand{\\Zj}{\\Z_j}\n\\newcommand{\\Zhi}{\\Z^h_i}\nLet the set of inducing inputs for $g_j(\\x)$ and $h_i(\\x)$ be $\\Z_j$ and $\\Z^h_i$, and the corresponding inducing points $\\u_j$ and $\\v_i$, respectively.\nWe denote the collective variables: $\\g = \\{\\g_j\\}$, $\\h = \\{\\h_i \\}$, $\\u = \\{\\u_j\\}$, $\\v = \\{\\v_i\\}$, $\\Z = \\{\\Zj\\}$, and $\\Z^h = \\{\\Zhi \\}$ where $\\g_j = \\{g_j(\\x_n)\\}$, $\\h_i = \\{h_i(\\x_n)\\}$. \nThe subscripts are $i = 1 \\hdots P$, $j = 1 \\hdots Q$, and $n = 1 \\hdots N$.\n\n\\noindent\n\\textbf{Prior}\nThe prior of the augmented model is given by:\n\\begin{align}\np(\\g | \\u) &= \\prod_{j=1}^Q p(\\g_j | \\u_j) = \\prod_{j=1}^Q \\Normal(\\g_j; \\BigMu_j, \\tilde{\\K}_j )\\\\\np(\\u) &= \\prod_{j=1}^Q p(\\u_j) = \\prod_{j=1}^Q \\Normal(\\u_j; \\vec{0}, k(\\Zj, \\Zj)) \\\\\np(\\h | \\v) &= \\prod_{i=1}^P p(\\h_i | \\v_i) = \\prod_{i=1}^P \\Normal(\\h_i; \\BigMu^h_i, \\tilde{\\K}^h_i)\\\\\np(\\v) &= \\prod_{i=1}^P p(\\v_i) = \\prod_{i=1}^P \\Normal(\\v_i; \\vec{0}, k(\\Zhi, \\Zhi)),\n\\end{align}\nwhere $\\BigMu_j = k(\\X,\\Zj)k(\\Zj,\\Zj)^{-1}\\u$ and $\\tilde{\\K}_j = k_j(\\X,\\X) - k(\\X,\\Zj)k(\\Zj,\\Zj)^{-1}k(\\Zj,\\X)$ and $\\BigMu^h_i, \\tilde{\\K}^h_i$ are similarly defined.\nTo avoid notational clutter, we omit the subscripts $j,h,i$ from the kernels $k_j(\\cdot,\\cdot)$ and $k^h_i(\\cdot,\\cdot)$ when it is clear from the parameters inside the parentheses which covariance function is in action. \n\n\\noindent\n\\textbf{Likelihood}\nThe likelihood as usual follows the standard iid Gaussian likelihood,\n\\begin{align}\np(\\y | \\g, \\h ) = \\prod_{i=1}^P p( \\y_i ; \\g, \\h_i) = \\prod_{i=1}^P \\Normal( \\y_i ; \\sum_{j=1}^Q w_{ij} \\g_j + \\h_i, \\beta_i^{-1} \\I).\n\\end{align}\n\n\\subsection{Variational Inference in Sparse GPs Revisited}\nIn this section we review inference in sparse GPs (as presented in Titsias).\nThe posterior in an augmented model is $p(\\f, \\u | \\y) = p(\\f | \\u, \\y) p(\\u | \\y)$.\nThe key property of such augmented GPs  is the notation of \\textit{sufficient statistics}: given the inducing points $\\u$, the latent values $\\f$ are independent with any other set of latent values (e.g. the test set).\nIn the optimal setting when $\\u$ is the sufficient statistics of $\\f$, it should hold that $p(\\f | \\u, \\y) = p(\\f | \\u)$ as $\\y$ is only the noisy version of $\\f$.\nThis leads to choosing a variational approximation of the posterior which factorizes as $q(\\f, \\u | \\y) = p(\\f | \\u) q(\\u | \\y)$.\nSince the conditional $p(\\f | \\u)$ is known, variational inference becomes learning an optimal posterior $q(\\u | \\y)$ only. \\\\\n\n\\noindent Also as a consequence of sufficient statistics, the approximate prediction for test targets $\\vfstar$ at test inputs $\\X_*$ is\n\\begin{align}\n\\nonumber\np(\\vfstar | \\y, \\X_*) &= \\int p(\\vfstar | \\f, \\u, \\X_*) q(\\f, \\u | \\y) \\der \\f \\der \\u \\\\\n\\nonumber\n&= \\int p(\\vfstar | \\u) q(\\u| \\y) p(\\f | \\u) \\der \\f \\der \\u \\\\ \\nonumber\n&= \\int p(\\vfstar | \\u) q(\\u| \\y) \\der \\u \\\\\n\\label{eq:sorprediction}\n&= \\Normal(\\vfstar; \\bs{\\mu_*},\\vec{s_*})\n\\end{align}\nwhere,\n\\begin{align}\n\\nonumber\n\\bs{\\mu_*} &= \\K_{*z} \\K_{zz}^{-1}\\m \\\\ \n\\nonumber\n\\S_* &= \\K_{**} - \\K_{*z} \\left(\\K_{zz}^{-1} - \\K_{zz}^{-1} \\S \\K_{zz}^{-1} \\right) \\K_{*z}^T.\n\\end{align}\n Here $\\K_{*z}$ is the covariance matrix between test and inducing inputs, $\\K_{zz}$ is the covariance matrix of the inducing inputs.\n\n\\subsection{Variational Inference}\n\\newcommand{\\ug}{\\u_g}\n\\newcommand{\\uh}{\\u^h}\n\\newcommand{\\mgj}{\\m_j}\n\\newcommand{\\mhi}{\\m^h_i}\n\\newcommand{\\Sgj}{\\S_j}\n\\newcommand{\\Shi}{\\S^h_i}\nOur goal of inference is to find the posterior $p(\\g, \\h, \\u, \\v | \\y)$. \nFollowing the previous discussion, we assume a variational distribution which factorizes as:\n\\begin{align}\n\\nonumber\nq(\\g, \\h, \\u, \\v | \\y)\n\\nonumber\n &= p(\\g|\\u) p(\\h|\\v) q(\\u,\\v)  \\\\\n &= p(\\g|\\u) p(\\h|\\v) \\prod_{j=1}^Q q(\\u_j) \\prod_{i=1}^P  q(\\v_i)\n\\end{align}\nSince the conditionals $p(\\g | \\u)$ and $p(\\h | \\v)$ are given, we need only to find the optimum $q(\\u_j)$ and $q(\\v_i)$.\nLet $q(\\u_j) = \\Normal(\\u_j; \\mgj, \\Sgj)$ and $q(\\v_i) = \\Normal(\\v_i; \\mhi, \\Shi)$. \\\\\n\n\\noindent\nTo find the optimum $q(\\u, \\v)$ we optimize the evidence lower bound (ELBO) of the log marginal,\n\\begin{align}\n\\nonumber\n\\log p(\\y) \\ge& \\int q(\\u, \\v) \\log \\frac{p(\\y | \\u, \\v) p(\\u, \\v)}{q(\\u, \\v)} \\der \\u \\der \\v \\\\\n\\nonumber\n=& \\int q(\\u, \\v) \\log p(\\y | \\u, \\v)  \\der \\u \\der \\v \n+ \\int q(\\u, \\v) \\log \\frac{p(\\u, \\v)}{q(\\u, \\v)} \\der \\u \\der \\v \\\\\n\\label{eq:elbo}\n=& \\int q(\\u, \\v) \\log p(\\y | \\u, \\v)  \\der \\u \\der \\v \n- \\left(\\sum_{j=1}^Q \\KL[q(\\u_j) || p(\\u_j)] + \\sum_{i=1}^P \\KL[q(\\u_i) || p(\\u_i)] \\right),\n\\end{align}\nwhere the last equality occurs because both of $q(\\u, \\v)$ and $p(\\u, \\v)$ fully factorize.\nSince $q(\\u_j), q(\\v_i), p(\\u_j), p(\\v_i)$ are all multivariate Gaussian distributions, the KL divergences are analytically tractable and require $\\calO(M^3)$ computation, where $M$ is the largest number of inducing inputs (recall that $g_j(\\x)$ and $h_i(\\x)$ use separate set of inducing inputs). \\\\\n\n\\noindent To compute the ELBO we first focus on the term:\n\\newcommand{\\llangle}{\\left\\langle}\n\\newcommand{\\rrangle}{\\right\\rangle}\n\\begin{align}\n\\nonumber\n\\log p(\\y | \\u, \\v)\n &= \\log \\Eb{p(\\y | \\g, \\h)}_{p(\\g,\\h | \\u, \\v)} \\\\\n \\nonumber\n&\\ge \\Eb{\\log p(\\y | \\g, \\h)}_{p(\\g,\\h | \\u, \\v)} \\quad &\\text{(Jensen's inequality)} \\\\\n&= \\sum_{i=1}^P \\sum_{n=1}^N \\Eb{\\log p(y_{in} | \\g_n, h_{in}) }_{p(\\g_n | \\u) p(\\h_{in} | \\v_i)}, \\quad \n &\\text{(factorized likelihood)}\n\\end{align}\nwhere $\\g_n = \\{g_{jn} = (\\g_j)_n\\}_{j=1}^Q$.\nEach individual term $l_{in} \\define \\Eb{\\log p(y_{in} | \\g_n, h_{in}) }_{p(\\g_n | \\u) p(\\h_in | \\v_i)}$ can be computed using the identity in eq. \\ref{eq:identity} given in the appendix to give:\n\\begin{align}\n\\nonumber\nl_{in} &= \\int \\log p(y_{in} | \\g_n, h_{in}) \\prod_{j=1}^Q p(g_{jn} | \\u_j) p(h_{in} | \\u_i) \\der \\g_n \\der h_{in} \\\\\n&= \\log \\Normal(y_{in}; \\sum_{j=1}^Q w_{ij} \\mu_{jn}+ \\mu^h_{in}, \\beta_i^{-1})\n- \\frac{1}{2} \\beta_i \\sum_{j=1}^Q w_{ij}^2 \\tilde{k}_{nn} \n- \\frac{1}{2} \\beta_i \\tilde{k}^h_{inn},\n\\end{align}\nwhere $\\tilde{k}_{nn} = (\\tilde{\\K})_{nn}, \\tilde{k}^h_{inn} = (\\tilde{\\K}^h_i)_{nn}, \\mu_{jn} = (\\Mu_j)_n, \\text{ and } \\mu^h_{in} = (\\Mu^h_i)_n$.\n\n% previous detailed derivation\n%\\begin{align}\n%\\nonumber\n%l_{in} &= \\int \\log p(y_{in} | g_n, h_{in}) p(\\g | \\ug) p(\\h_i | \\u_i) \\der \\g \\der \\h_i \\\\\n%\\nonumber\n%&= \\int \\log \\Normal(y_{in} ; w_i g_n + h_{in}, \\beta_i^{-1}) \n%\\Normal(g_n ; \\mu_{gn}, \\tilde{k}_{gnn})\n%\\Normal(h_{in} ; \\mu_{in}, (\\tilde{k}_{inn}) \\der g_n \\der h_{in} \\\\\n%\\nonumber\n%&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} \\int (y_{in} - w_i g_n - h_{in}) \\beta_i (y_{in} - w_i g_n - h_{in})\n%\\Normal(g_n ; \\mu_{gn}, \\tilde{k}_{gnn})\n%\\Normal(h_{in} ; \\mu_{in}, \\tilde{k}_{inn}) \\der g_n \\der h_{in} \\\\\n%\\nonumber\n%&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} \\int \\left[(y_{in} - h_{in} - w_i \\mu_{gn}) \\beta_i (y_{in} - h_{in} - w_i \\mu_{gn}) + w_i^2 \\beta_i \\tilde{k}_{gnn} \\right] \n%\\Normal(h_{in} ; \\mu_{in}, \\tilde{k}_{inn}) \\der h_{in} \\\\\n%\\nonumber\n%&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} w_i^2 \\beta_i \\tilde{k}_{gnn}\n%- \\frac{1}{2} \\beta_i \\tilde{k}_{inn} - \\frac{1}{2} (y_{in} - w_i \\mu_{gn} - \\mu_{in}) \\beta_i (y_{in} - w_i \\mu_{gn} - \\mu_{in}) \\\\\n%&= \\log \\Normal(y_{in}; w_i \\mu_{gn} + \\mu_{in}, \\beta_i^{-1})  - \\frac{1}{2} \\beta_i (w_i^2 \\tilde{k}_{gnn} + \\tilde{k}_{inn}),\n%\\end{align}\n\n\\noindent Substituting $l_{in}$ into equation \\ref{eq:elbo} and carrying out the integral using the identity in eq. \\ref{eq:identity} we get:\n\\begin{align}\n\\nonumber\n\\log p(\\y)\n\\ge& \\sum_{i=1}^P \\sum_{n=1}^N\n\\bigg( \\log \\Normal(y_{in}; \\tilde{\\mu}_{in}, \\beta_i^{-1})\n          - \\frac{1}{2} \\beta_i \\sum_{j=1}^Q w_{ij}^2        \\tilde{k}_{nn} - \\frac{1}{2} \\beta_i \\tilde{k}^h_{inn}\n \\\\ \\nonumber\n         &\\quad \\quad \\quad \\quad - \\frac{1}{2} \\beta_i \\trace  \\sum_{j=1}^Q w_{ij}^2 \\S_j \\mat{\\Lambda}_{jn} - \\beta_i \\frac{1}{2} \\trace \\S^h_i \\mat{\\Lambda}_{in} \n\\bigg) \\\\\n&- \\left(\\sum_{j=1}^Q \\KL[q(\\u_j) || p(\\u_j)] + \\sum_{i=1}^P \\KL[q(\\v_i) || p(\\v_i)] \\right) \\define \\calL,\n\\end{align}\nwhere \n%TODO \\Lambda_gn depends on the output i so need a better notation\n\\newcommand{\\Zg}{\\Z_g}\n\\newcommand{\\Zi}{\\Z_i}\n\\begin{align}\n\\tilde{\\mu}_{in}\n&= \\sum_{j=1}^Q w_{ij} k(\\x_n, \\Zj)k(\\Zj,\\Zj)^{-1}\\m_j + k(\\x_n, \\Zhi)k(\\Zhi,\\Zhi)^{-1}\\mhi \\\\\n\\mat{\\Lambda}_{jn}\n&= k(\\Zj,\\Zj)^{-1} k(\\Zj, \\x_n) k(\\x_n, \\Zj) k(\\Zj,\\Zj)^{-1} \\\\\n\\mat{\\Lambda}_{in}\n&= k(\\Zhi,\\Zhi)^{-1} k(\\Zhi, \\x_n) k(\\x_n, \\Zhi) k(\\Zhi,\\Zhi)^{-1}.\n\\end{align}\n\n\\noindent Notice that this ELBO clearly generalizes the standard GP regression. In particular, setting $P = Q = 1$, $w_i = 1$ and $h_i(\\x) = 0$ we recover the bound in Hensman et al \\cite{hensmangaussian}.\nDue to the decomposition of this bound, we can use stochastic gradient descent to learn the variational parameters.\n\n\\subsubsection{Variational Parameters Derivatives}\n\\newcommand{\\oi}{\\vec{o}_i}\n% some notation\nBefore diving into the details, we first define the indexing operator of a matrix: $\\B(\\vec{r},\\vec{c})$ extracts the submatrix in rows $\\vec{r}$ and columns $\\vec{c}$ of $\\B$.\nTo index all columns we use $\\B(\\vec{r},:)$ and similarly for all rows $\\B(:,\\vec{c})$.\nReaders familiar with this operator will recognize that this is the MATLAB indexing operator.\n\nThe optimal posteriors are found by setting the gradients of the lowerbound $\\calL$ wrt to the parameters of $q(\\u_j)$ and $q(\\v_i)$.\nRecall that in the model, different outputs can be observed at different inputs (i.e. the case of missing values).\nLet $\\oi$ be the indice of the observed inputs of the output dimension $i$.\nWe denote its set of observed inputs and targets as: $\\X_i = \\X(\\oi,:)$ and $\\y_i = y_{i}(\\oi)$.\n\n\\noindent As a function of the parameters of $q(\\u_j)$, the lowerbound $\\calL$ is:\n\\newcommand{\\Ahi}{\\A^h_i}\n\\begin{align}\n\\nonumber\n\\calL^g_j \\define&\n \\sum_{i=1}^P \\log \\Normal(\\y_i; \\sum_{j=1}^Q w_{ij} \\A_j(\\oi,:) \\m_j + \\Ahi \\mhi, \\beta_i^{-1} \\I)  \\\\\n \\nonumber\n &- \\frac{1}{2} \\sum_{i=1}^P \\bigg(\\beta_i \\trace w_{ij}^2 \\tilde{\\K}_j(\\oi,\\oi) \n + \\beta_i \\trace w_{ij}^2 \\S_j \\A_j(\\oi,:)^T \\A_j(\\oi,:) \\bigg)\n \\\\\n &- \\frac{1}{2} \\log |k(\\Zj,\\Zj) \\S_j^{-1}| -\\frac{1}{2} \\trace k(\\Zj,\\Zj)^{-1} (\\m_j \\m_j^T + \\S_j) ,\n\\end{align}\nwhere $\\A_j = k(\\X,\\Zj)k(\\Zj,\\Zj)^{-1}$, which gives $\\A_j(\\oi,:) = k(\\X_i,\\Zj) k(\\Zj,\\Zj)^{-1}$, and  \n$\\Ahi = k(\\X_i,\\Zhi)k(\\Zhi,\\Zhi)^{-1}$. \\\\\n\n%------------------------------------------\n% derivatives of q(u_j)\n\\newcommand{\\Lgj}{\\calL^g_j}\n\\newcommand{\\ynoj}{\\y_i^{\\backslash j}}\n\\noindent The derivatives of $\\Lgj$ wrt $\\m_j$ and $\\S_j$ are given by:\n\\begin{align}\n\\deriv{\\Lgj}{\\m_j}\n& = \\sum_{i=1}^P \\beta_i w_{ij} \\A_j(\\oi,:)^T \\ynoj - \\bigg[k_g(\\Zg,\\Zg)^{-1} + \\sum_{i=1}^P \\beta_i w_{ij}^2 \\A_j(\\oi,:)^T \\A_j(\\oi,:) \\bigg] \\m_j \\\\\n\\deriv{\\Lgj}{\\S_j} \n&= \\frac{1}{2} \\S_j^{-1} - \\frac{1}{2} \\bigg[ k(\\Zj,\\Zj)^{-1} + \\sum_{i=1}^P \\beta_i w_{ij}^2 \\A_j(\\oi,:)^T \\A_j(\\oi,:) \\bigg],\n\\end{align}\nwhere $\\y_i^{\\backslash j} = \\y_i - \\Ahi \\mhi - \\sum_{j' \\neq j} w_{ij'} \\A_{j'}(\\oi,:) \\m_{j'}$.\n\n%-------------------------------------------\n%  derivatives of q(v_i)\n\\newcommand{\\Lhi}{\\calL^h_i}\n\\noindent As a function of the parameters of $q(\\v_i)$, the lower bound $\\calL$ is:\n\\begin{align}\n\\nonumber\n\\Lhi \\define&\n \\log \\Normal(\\y_i; \\sum_{j=1}^Q w_{ij} \\A_j(\\oi,:) \\m_j + \\Ahi \\mhi, \\beta_i^{-1} \\I)\n - \\frac{1}{2} \\beta_i \\trace \\tilde{\\K}^h_i(\\oi,\\oi)\n - \\frac{1}{2} \\beta_i \\trace \\Shi (\\Ahi)^T \\Ahi\n \\\\\n  &- \\frac{1}{2} \\log |k(\\Zhi,\\Zhi) (\\Shi)^{-1}| -\\frac{1}{2} \\trace k(\\Zhi,\\Zhi)^{-1} (\\mhi (\\mhi)^T + \\Shi) ,\n\\end{align}\n\n\\noindent The derivatives of $\\Lhi$ wrt $\\mhi$ and $\\Shi$ are given by:\n\\newcommand{\\ynoh}{\\y_i^{\\backslash h}}\n\\begin{align}\n\\deriv{\\Lhi}{\\mhi}\n& = \\beta_i \\A_i^T \\ynoh - \\left[k(\\Zhi,\\Zhi)^{-1} +  \\beta_i \\A_i^T \\A_i \\right] \\m_i \\\\\n\\deriv{\\Lhi}{\\Shi} \n&= \\frac{1}{2} \\S_i^{-1} - \\frac{1}{2} \\left[ k(\\Zhi,\\Zhi)^{-1} + \\beta_i \\A_i^T \\A_i \\right] ,\n\\end{align}\nwhere $\\ynoh = \\y_i - \\sum_{j=1}^Q w_{ij} \\A_j(\\oi,:) \\m_j$.\n\n% comment on computation\n\\noindent It can be seen that the derivatives of the parameters of $q(\\v_i)$ only involve the observations of the output dimension $i$.\nThe derivatives of the parameters of $q(\\u_j)$ involve the observations across all output dimensions but decompose as a sum of contributions from individual outputs.\nTherefore, computation of the derivatives (and hence the update equations) can be distributed or parallelized easily.\nThis attractive property allows the model to scale to a very large number of inputs and outputs.\n\n% Comment on other hyperparameters\n\n%\\subsubsection{Update Equations}\n% and comment on the intuition of the update equations: e.g. y(x) - g(x) for h(x) \n\\subsection{Prediction}\nThe predictive distribution of the $i$-th output for a test input $\\x_*$ is \n\\begin{align}\np(\\fstar | \\y, \\x_*) = \\int \\Normal(\\fstar; \\sum_{j=1}^Q w_j g_{j*} + h_{i*}, 0) p(\\g_* | \\y, \\x_*) p(h_{i*} | \\y, \\x_*) \\der \\g_* \\der h_{i*},\n\\end{align}\nwhere $p(\\g_* | \\y, \\x_*) = \\prod_{j=1}^Q \\Normal(g_{j*}; \\mu_{j*}, s_{j*})$ and $p(h_{i*} | \\y, \\x_*) = p(h_{i*}; \\mu^h_{i*}, s^h_{i*})$ are the predictive distributions of the sparse GPs as given in eq. \\ref{eq:sorprediction}.\nTherefore we have:\n\\begin{align}\np(\\fstar | \\y, \\x_*) = \\Normal(\\fstar; \\sum_{j=1}^Q w_{ij} \\mu_{j*} + \\mu_{i*}, w_{ij}^2 s_{j*} + s_{i*}). \n\\end{align}\n\n%\\begin{linenomath}\n%\\begin{align}\n%\\sum_{i,h} \\lambda_i \\lambda_h cov [f(\\x, \\x')]\n%&= \\sum_{i,h}   \\sum_{j,j'} \\lambda_i g(\\x_i - \\vs_j) k(\\vs_j, \\vs_{j'}) \\lambda_h g(\\x_h - \\vs_j') \\\\\n%\\end{align}\n%\\end{linenomath}\n\n\\section{Toy Experiments}\nThe first toy experiment uses two identical outputs which are noisy version of the same version plus some noise: $y_1(x) = sin(x) + \\epsilon$ and $y_2(x) = sin(x) + \\epsilon$, $\\epsilon \\sim \\Normal(0,0.01)$.\nIn this case the shared function $g(x)$ is $sin(x)$ and the independent processes $h_1(x)$ and $h_2(x)$ are just white noises.\nEach output has missing values in one region of the input space.\nThe predictive distributions of the multiple-gp model compared to that of independent gps are shown in \\ref{fig4}.\n\n\\noindent The second toy experiment uses similar setting as the first one, except that now $y_1(x) = sin(x) + \\epsilon$ and $y_2(x) = -sin(x) + \\epsilon$. \nIn this case the shared function is still $g(x) = sin(x)$, but the weights should be opposite i.e. $w_1 = 1$ and $w_2 = 1$.\nThe learning procedure was indeed able to recovered this relation and learned that $w_1 = 1.2$ and $w_2 = -1.3$.\nThe predictive distributions are shown in \\ref{fig5}.\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{cc}\n\\includegraphics[scale=0.5]{figures/ssvi-y1.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi-svi1.eps} \\\\\n\\includegraphics[scale=0.5]{figures/ssvi-y2.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi-svi2.eps} \\\\\n\\multicolumn{2}{c}{\\includegraphics[scale=0.5]{figures/ssvi-y1byg.eps} }\n\\end{tabular}\n\\label{fig4}\n\\caption{Predictive distributions of the multipe-output gps (left column) and independent gps (right column) for the first toy example. The predictive distribution by $g(x)$ for $y_1(x)$ is shown in the bottom figure.}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{cc}\n\\includegraphics[scale=0.5]{figures/ssvi2-y1.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi2-svi1.eps} \\\\\n\\includegraphics[scale=0.5]{figures/ssvi2-y2.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi2-svi2.eps} \\\\\n\\multicolumn{2}{c}{\\includegraphics[scale=0.5]{figures/ssvi-y1byg.eps} }\n\\end{tabular}\n\\label{fig5}\n\\caption{Predictive distributions of the multipe-output gps (left column) and independent gps (right column) for the second toy experiment. The predictive distribution by $g(x)$ for $y_1(x)$ is shown in the bottom figure.}\n\\end{figure*}\n\n\\section{Appendix 1: Derivatives}\nHere we derive the gradients of the lower bound wrt the  hyperparameters.\nAs a template, consider the lower bound in Hensman et al (as a function of the hyperparameters):\n\\begin{align}\n\\nonumber\n\\calL\n=& \\log \\Normal(\\y; \\K_{NM} \\K_{MM}^{-1} \\m, \\beta^{-1}\\I)\n - \\frac{1}{2} \\beta \\trace \\tilde{\\K}\n - \\frac{1}{2} \\beta \\trace (\\S\\K_{MM}^{-1} \\K_{MN} \\K_{NM} \\K_{MM}^{-1}) \\\\  \\nonumber\n&- \\frac{1}{2} \\left( \\log |\\K_{MM}| + \\trace(\\K_{MM}^{-1}(\\m \\m^T + \\S)) \\right) \\\\ \\nonumber\n=& \\underbrace{\\log \\Normal(\\y; \\A \\m, \\beta^{-1}\\I)}_{\\calL_1}\n - \\underbrace{\\frac{1}{2} \\beta \\trace (\\K_{NN} - \\A\\K_{MN})}_{\\calL_2}\n - \\underbrace{\\frac{1}{2} \\beta \\trace (\\S\\A^T\\A)}_{\\calL_3} \\\\  \n&- \\underbrace{\\frac{1}{2} \\left( \\log |\\K_{MM}| + \\trace(\\K_{MM}^{-1}(\\m \\m^T + \\S)) \\right)}_{\\calL_4},\n\\end{align}\nwhere $\\A = \\K_{NM} \\K_{MM}^{-1}$.\nNotice that we have re-written the sum of individual terms in matrix form which will make the derivation and also computation easier.\n\n\\subsection{Derivative of the Noise Hyperparameter}\nThe derivative of the noise hyperparameter $\\beta$ is easily computed as:\n\\begin{align}\n\\deriv{\\calL}{\\beta} = \\frac{N}{2\\beta} - \\frac{1}{2} (\\y - \\A\\m)^T (\\y - \\A\\m) - \\frac{\\calL_2}{\\beta} - \\frac{\\calL_3}{\\beta}.\n\\end{align}\n\\subsection{Derivatives of the Covariance Hyperparameters}  \nTo simplify the math, we utilize the matrix $\\A$ defined above.\nFirstly, the derivative of $\\A$ wrt a covariance hyperparameter $t$ is given by:\n\\begin{align}\n\\deriv{\\A}{t} = \\left(\\deriv{\\K_{NM}}{t} - \\A \\deriv{\\K_{MM}}{t}\\right)\\K_{MM}^{-1}.\n\\end{align}\nThe derivatives of $\\calL_1, \\calL_2, \\calL_3 \\text{ and } \\calL_4$ are thus given by:\n\\begin{align}\n\\deriv{\\calL_1}{t} &= \\beta (\\y - \\A\\m)^T \\deriv{\\A}{t} \\m \\\\\n\\deriv{\\calL_2}{t} &= \\frac{1}{2}\\beta \\trace \\left(\\deriv{\\K_{NN}}{t} - \\A \\deriv{\\K_{MN}}{t} - \\deriv{\\A}{t} \\K_{MN}\\right) \\\\\n\\deriv{\\calL_3}{t} &= \\beta \\trace \\left(\\A \\S \\deriv{\\A^T}{t} \\right) \\\\\n\\deriv{\\calL_4}{t} &= \\frac{1}{2}  \\trace \\left(\\K_{MM}^{-1} \\deriv{ \\K_{MM}}{t}\\right) - \\frac{1}{2} \\trace \\left(\\K_{MM}^{-1} \\deriv{\\K_{MM}}{t} \\K_{MM}^{-1} (\\m \\m^T + \\S) \\right) \n\\end{align}\nThe derivatives are then computed by taking the derivatives of the covariance matrices $\\K_{NN} (\\text{the diagonal only}), \\K_{NM} \\text{ and }  \\K_{MM}$, hence the covariance function, wrt the hyperparameters. \n\n\\subsection{Derivatives of the Inducing Inputs}\nTo compute the derivatives of $\\calL$ wrt the inducing inputs, first notice that $\\Z = \\{\\z_m\\}_{m=1}^M$ are also parameters of the covariance matrices $\\K_{NM}$ and $\\K_{MM}$.\nHence the derivative wrt a single dimension of an inducing input, i.e. $z_{mj}$, is the same as that of $\\deriv{ \\calL}{t}$.\n\n%Since $MD$ parameters are needed for the inducing inputs, it appears that the derivatives of all inducing inputs would require $\\calO(MD \\times M^3)$ in computation.\n%However, this complexity can actually be reduced to $\\calO(DM^3)$ using the following lemma. \\\\\n%\n%\\noindent \\textbf{Lemma} Let $A, B$ be two matrices of size $N \\times M$ and $M \\times N$, respectively. Furthermore, $B$ has the property that only one of its rows or columns is non-zero. The complexity of $\\trace(AB)$ is only $\\calO(N)$. \\\\\n%\n%\\noindent \\textbf{Proof} Let $m <= M$ be the non-zero row of $B$. We have\n%\\begin{align}\n%\\trace (AB) = \\sum_{i=1}^N \\sum_{j=1}^M A_{ij} B_{ji} = \\sum_{i=1}^N A_{im} B_{mi},\n%\\end{align}\n%which clearly takes $\\calO(N)$. It is easy to see that the lemma also holds when $B$ is symmetric and only one of its row and the corresponding column is non-zero. \\\\\n%\n%\\noindent To exploit the property in the Lemma, we re-write $\\frac{d \\calL_1}{dt}, \\frac{d \\calL_2}{dt}, \\frac{d \\calL_3}{dt}, \\frac{d \\calL_4}{dt}$ by expanding $\\frac{d\\A}{dt}$ (here $t = z_{mj}$):\n\n\\noindent We re-write $\\deriv{\\calL_1}{t}, \\deriv{\\calL_2}{t}, \\deriv{ \\calL_3}{t}, \\deriv{\\calL_4}{t}$ by expanding $\\deriv{\\A}{t}$ (here $t = z_{mj}$):\n\\begin{align}\n\\nonumber\n% dL1\n\\deriv{\\calL_1}{t}\n &= \\beta \\trace (\\y - \\A\\m)^T \\left(\\deriv{\\K_{NM}}{t} -  \\A \\deriv{ \\K_{MM}}{t}\\right)\\K_{MM}^{-1} \\m \\\\\n&= \\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\deriv{\\K_{NM}}{t} \n-\\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\A \\deriv{\\K_{MM}}{t} \\\\\n%dL2\n\\deriv{\\calL_2}{t}\n&= - \\beta \\trace \\A^T \\deriv{\\K_{NM}}{t}\n + \\frac{1}{2} \\beta \\trace \\A^T \\A \\deriv{\\K_{MM}}{t}  \\\\\n% dL3\n\\deriv{\\calL_3}{t}\n&= \\beta \\trace \\K_{MM}^{-1} \\S \\A^T \\deriv{\\K_{NM}}{t}\n - \\beta \\trace \\K_{MM}^{-1} \\S \\A^T \\A \\deriv{\\K_{MM}}{t}\\\\\n% dL4\n\\deriv{\\calL_4}{t}\n &= \\frac{1}{2}  \\trace \\K_{MM}^{-1} \\deriv{\\K_{MM}}{t}\n  - \\frac{1}{2} \\trace \\K_{MM}^{-1} (\\m \\m^T + \\S) \\K_{MM}^{-1} \\deriv{\\K_{MM}}{t} \n\\end{align}\nFrom the above equations we get,\n\\begin{align}\n\\deriv{\\calL}{t} = \\trace \\D_1 \\deriv{\\K_{NM}}{t} + \\trace \\D_2 \\deriv{ \\K_{MM}}{t},\n\\end{align}\nwhere \n\\begin{align}\n\\D_1 =& \\beta \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T\n + \\beta \\A^T\n - \\beta \\K_{MM}^{-1} \\S \\A^T \\\\ \\nonumber\n\\D_2 =& -\\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\A\n - \\frac{1}{2} \\beta \\A^T \\A\n  + \\beta \\K_{MM}^{-1} \\S \\A^T \\A\t \\\\ \n  &-\\frac{1}{2} \\K_{MM}^{-1} + \\frac{1}{2} \\K_{MM}^{-1} (\\m \\m^T + \\S) \\K_{MM}^{-1}\n\\end{align}\nNotice that $\\D_1$ and $\\D_2$ can be pre-computed with a cost of $\\calO(M^3)$ (or $\\calO(N_bM^2)$ if the minibatch size $N_b > M$).\nThe computational cost of taking derivatives of $MD$ inducing parameters is thus $\\calO(M^3 + MDM) = \\calO(M^3)$ as the cost of the two $\\trace$ operators is $\\calO(M)$ due to the fact that only $\\calO(M)$ elements of $\\deriv{\\K_{MM}}{t}$ or $\\deriv{\\K_{NM}}{t}$ are non-zero.\nThis fact can be further exploited to perform vectorized operation, for e.g. in Matlab, such that the iteration over all inducing inputs can be avoided.\n\n\\section{Appendix 2: Gaussian Identity}\nLet $\\y$, $\\g = \\{\\g_j\\}_{j=1}^q$, and $\\h$ be random variables with multivariate Gaussian distributions: \n$p(\\y | \\g, \\h) = \\Normal(\\y; \\sum_{j=1}^Q \\W_j \\g_j + \\W \\h, \\beta^{-1} \\I)$, $p(\\g_j) = \\Normal(\\g_j; \\m_j, \\S_j)$, and $p(\\h) = \\Normal(\\h; \\m, \\S)$.\nThe following identity is important in deriving the evidence lower bound:\n\\begin{align}\n\\nonumber\n\\int \\log p(\\y | \\g, \\h) \\prod_{j=1}^q p(\\g_j) p(\\h) \\der \\g \\der \\h\n=& \\log \\Normal(\\y; \\sum_{j=1}^q \\W_j \\m_j + \\W \\m, \\beta^{-1} \\I) - \\frac{1}{2} \\beta \\trace \\W^T \\W \\S \\\\\n\\label{eq:identity}\n&- \\frac{1}{2} \\beta \\trace \\sum_{j=1}^q \\W_j^T \\W_j \\S_j.\n\\end{align}\nThe identity can be proved by using this fact: \n\\begin{align}\n\\nonumber\n\\int (\\W\\x - \\Mu)^T \\BigSigma^{-1} &(\\W \\x - \\Mu) \\Normal(\\x; \\m, \\S) \\der \\x \\\\\n\\nonumber\n&= (\\Mu - \\W\\m)^T \\BigSigma^{-1} (\\Mu - \\W\\m) + \\trace \\W^T \\BigSigma^{-1} \\W \\S.\n\\end{align}\n\n\\section{Appendix: Analysis on Learning of the Inducing Inputs}\nIn this section we present some analysis on learning of the inducing inputs under the stochastic variational inference procedure on some toy problems.\nWe use three real-valued truth functions of scalar inputs: the first one was used in Snelson et al, the second one is a function $f(x) = \\sin(x) + \\cos(x)$, and the third one is a sample function generated from a GP with squared exponential with ARD covariance function with a lengthscale of 2 and signal variance of 1.\n\n\\noindent \\paragraph{Experimental Settings} We use gpsvi to optimize for \\textit{all} of the parameters in the model, i.e. the variational parameters of the posterior, the covariance hyperparameters, the noise hyperparameter, and the inducing inputs.\nFor the hyperparameters, we use a momentum of $0.9$ and a fixed learn rate of $1e-5$. \nFor the variational parameters, we use a learn rate of $0.01$ (no momentum was used).\nWe vary the learn rate of the inducing inputs from $1e{-2}$ to $1e{-6}$.\nUsing momentum for the inducing inputs does not seem to have much effects.\nThe maximum number of iterations is 500, the batch size 5, and the number of inducing values 10.\n\n% effect of learn rate on inducing inputs\n\\noindent \\paragraph{Effects of the Learn Rates }\nIn Figure \\ref{fig1}, \\ref{fig2}, and \\ref{fig3}, we show the lower bounds, predictive distributions, and the learned inducing inputs using stochastic variational inference with varying learn rates for the inducing inputs.\nWe also show the results with FITC for comparison.\nIt can be seen from the figures that, as typical in stochastic optimization, the behavior of GPSVI is very sensitive to the learn rate.\nIn particular, when the rate is slow e.g. $1e{-5}$, almost no progress was made in learning the inducing inputs.\nHowever, when the rate increases to e.g. $1e{-3}$, the inducing inputs are spread out more evenly in the input space compared to the initial locations.\nAlthough not shown the in figures, when the learn rate is too large, e.g. $1e{-02}$, the inducing inputs may spread to regions far outside of the training intervals.\nAn example of this phenomenon can be observed in the top left figure in Figure \\ref{fig1}.\nThe learn rates also affect the evidence lower bound which seems to wiggle more compared to not learning the inducing inputs.\nThe predictive distributions are sensible particularly because the toy functions exhibit sparsity and are easy to learn.  \\\\\n\n\\noindent The results of this qualitative analysis do not seem to suggest that learning of the inducing inputs does not work in GPSVI.\nIts effectiveness perhaps rests upon empirical performance on real datasets.\n\n\\noindent \\paragraph{The Noise Parameter} It seems harder to set the initial value and the learning rate of the noise parameter compared to standard GP. \nWhile a large range of values of noise can be used in standard gp or fitc (e.g. 0.5), a very small value of noise $1e{-02}$, which is the true noise, is required for gpsvi to work well.\nIt appears that an adaptive learning rate may be required for the noise parameter.\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func1-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the first function. Top row: GPSVI with different learning rates (the rates decreases from left to right). Bottom row: FITC. Magenta dots : training points. Solid blue line: predictive mean. Grey-shaded area and solid black lines: two standard deviations of the predictive distributions. Black (+) crosses: initial locations of inducing inputs. Magenta (+) crosses: learned locations of inducing inputs.  Middle row: the evidence lower bound of gpsvi vs. iteration.}\n\\label{fig1}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func2-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the second function. The legends are same as in Figure 1.}\n\\label{fig2}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func3-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the third function. The legends are same as in Figure 1.}\n\\label{fig3}\n\\end{figure*}\n\n\\bibliographystyle{abbrv}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "cdf89a199f70057c6afb5bcd652460cc0841cf3c", "size": 31307, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "note/paper.tex", "max_stars_repo_name": "fkopsaf/cogp", "max_stars_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2015-05-28T13:46:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T11:02:08.000Z", "max_issues_repo_path": "note/paper.tex", "max_issues_repo_name": "fkopsaf/cogp", "max_issues_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-07-30T08:52:36.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-04T01:44:21.000Z", "max_forks_repo_path": "paper/note.tex", "max_forks_repo_name": "trungngv/cogp", "max_forks_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2016-04-03T03:18:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-23T13:28:55.000Z", "avg_line_length": 58.0834879406, "max_line_length": 550, "alphanum_fraction": 0.6585108762, "num_tokens": 11460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.44082715415702717}}
{"text": "% !TeX spellcheck = en_GB\n\\section{Integrated Vapour Transport}\n\\label{sec:weather:atm_riv}\n% An atmospheric river (AR) is a filament structure of intense moisture transport from the tropics to higher latitudes. Heavy precipitation can be associated with it, because the air is warm and moist. This can often be observed at mountain ranges at west coasts such as in Norway \\citep{azad_extreme_2017}. Due to orographic lifting the moisture will be released and follow high amounts of precipitation. \n% \\\\\n% An atmospheric river is characterised if the integrated vapour transport shows values higher than \\SI{250}{\\IVT} and a continuous region larger than \\SI{2000}{\\km} \\citep{rutz_climatological_2014}.\n% \\\\\n\\Cref{fig:AR24_pres} shows coloured contours of the integrated vapour transport (IVT) in \\SI{}{\\IVT}, where warmer colours indicate higher IVT. \nStream vectors in \\Cref{fig:AR24_pres} indicate the direction and intensity of the IVT flow. \n% The integrated vapour transport (IVT) was calculated from the ECMWF data as followed:\n% \\begin{align}\n% IVT = \\frac{1}{g} \\int\\limits_{p_{sfc}}^{\\SI{100}{\\hPa}} q \\mathbf{V} dp \\qquad [\\SI{}{\\IVT}]\n% \\label{eq:IVT}\n% \\end{align} \n% where $g$ is the standard gravity, $q$ the specific humidity, and $\\mathbf{V}$ the total wind vector at each pressure level $p$. The numerical, trapezoidal integration is performed by using data from the surface pressure $p_{sfc}$ to \\SI{850}{\\hPa} in \\SI{50}{\\hPa} intervals and from \\SIrange{700}{100}{\\hPa} in \\SI{100}{\\hPa} intervals.\n\\\\\nAnalysing integrated vapour transport maps is important, since extreme precipitation events in Norway are often influenced by moist, warm air advection from the tropics \\citep{azad_extreme_2017}. \\Cref{fig:AtmRiv_00} and \\ref{fig:AtmRiv_01} shows integrated vapour transport from the tropics to the midlatitudes, but it also presents that the occurrence of the atmospheric river was not the main factor which led to intense precipitation during the 2016 Christmas storm. \nSince it showed not to be intense it will not be further discussed.\n%%% Atmospheric river maps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[!b]\n\t\\centering\n\t%%%%%% 29/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161219_12}\n\t\t\\caption{}\\label{fig:AR19}\n\t\\end{subfigure}\n\t%%%%%% 20/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161220_12}\n\t\t\\caption{}\\label{fig:AR20}\n\t\\end{subfigure}\n\t%%%%%% 21/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161221_12}\n\t\t\\caption{}\\label{fig:AR21}\n\t\\end{subfigure}\n\t%%%%%% 22/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161222_12}\n\t\t\\caption{}\\label{fig:AR22}\n\t\t%\\label{fig:sfc2100}\n\t\\end{subfigure}\n\t%%%%%% label\n\t\\begin{subfigure}[b]{\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 0cm 4.3cm 36.8cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161225_12}\n\t\\end{subfigure}\n\t\\caption{Atmospheric river analysis map, data from ECMWF. During \\num{19} to \\SI{22}{\\dec} at \\SI{12}{\\UTC}, chronologically (\\protect\\subref{fig:AR19} to \\protect\\subref{fig:AR22}). IVT, shaded according to the colour bar [\\SI{}{\\IVT}]. Vectors, indicating the direction and magnitude of the IVT. }\\label{fig:AtmRiv_00}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\noindent\n%% Atmospheric river maps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[t!]%\\ContinuedFloat\n\t%%%%%% 23/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161223_12}\n\t\t\\caption{}\\label{fig:AR23}\n\t\\end{subfigure}\n\t%%%%%% 24/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161224_12}\n\t\t\\caption{}\\label{fig:AR24}\n\t\\end{subfigure}\n\t%%%%%% 25/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161225_12}\n\t\t\\caption{}\\label{fig:AR25}\n\t\\end{subfigure}\n\t%\t\\centering\n\t%%%%%% 26/12\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 3.9cm 4.3cm 5.1cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161226_12}\n\t\t\\caption{}\\label{fig:AR26}\n\t\\end{subfigure}\n\t%%%%%% label\n\t\\begin{subfigure}[b]{\\textwidth}\n\t\t\\includegraphics[trim={4.2cm 0cm 4.3cm 36.8cm},clip,\n\t\twidth=\\textwidth]{./fig_Atm_Riv/20161225_12}\n\t\\end{subfigure}\n\t\\caption{\\textit{(As \\Cref{fig:AtmRiv_00}.)} During \\num{23} to \\SI{26}{\\dec} at \\SI{12}{\\UTC}, chronologically (\\protect\\subref{fig:AR23} to \\protect\\subref{fig:AR26})} \\label{fig:AtmRiv_01}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n", "meta": {"hexsha": "6c4bd60b09151aeb45ea6b09868292e68ec98db9", "size": 4937, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_full/Weather_Situation/atmospheric_river_map.tex", "max_stars_repo_name": "franzihe/Latex_thesis", "max_stars_repo_head_hexsha": "128284a01155bdc28b3e9374e538a07a1e5722c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis_full/Weather_Situation/atmospheric_river_map.tex", "max_issues_repo_name": "franzihe/Latex_thesis", "max_issues_repo_head_hexsha": "128284a01155bdc28b3e9374e538a07a1e5722c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis_full/Weather_Situation/atmospheric_river_map.tex", "max_forks_repo_name": "franzihe/Latex_thesis", "max_forks_repo_head_hexsha": "128284a01155bdc28b3e9374e538a07a1e5722c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.6630434783, "max_line_length": 471, "alphanum_fraction": 0.6939436905, "num_tokens": 1715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.44082714616822716}}
{"text": "\\section{Deep Learning approach}\r\n\\label{sec32}\r\n\r\nDeep Learning (DL) is a subfield of Machine Learning.\r\nDL emerged as a solution to the feature engineering extraction issue which requires high expertise and skills to extract damage-sensitive features for specific SHM applications.\r\nDL is a representation learning that automatically distinguishes  the proper data representations required for models like classification and detection.\r\n\r\nIt can be said that DL techniques developed rapidly in recent years due to the huge development that occurred in the computational powers (e.g. central processing units (CPU), graphical processing units (GPU), etc.), in addition to the availability of big data, and the development of new learning algorithms~\\cite{Yuan2020}.\r\nConsequently, DL-based SHM methods have been utilized to overcome issues related to ML-based SHM.\r\n  \r\nOriginally, DL was inspired by the human brain method of learning. \r\nIn which it has a huge number of neurons that are densely connected to form a hierarchical structure that is capable of receiving data at the visual cortex which can identify distinct shapes of edges of an object.\r\nThen, these learned patterns  are shifted down to the brain area which is capable to detect more complex patterns. \r\n\r\nDL is a hierarchical learning~\\cite{Ongsulee2018}, in which\r\ndata representations is acquired from the raw input data using non-linear function~\\cite{Lecun2015}. \r\nAt shallow levels, the acquired representation data has simple learnable extracted features, those extracted features keep shifting into more complex learnable features as moving into deeper levels.\r\n\r\n\\subsection{Multilayer Perceptrons}\r\n\r\nThe simplest DL networks are called multilayer perceptron (MLP) that are constructed from a group of multiple layers of perceptrons (artificial neurons), hence, the term \"deep\" came from the multiple layers.\r\nA perceptron has several inputs and outputs that are weighted connections with a nonlinear activation function.\r\nBy performing this operation a non-linearity is injected to the network, which is important for the learning process.\r\nTherefore, if the non-linearity was not considered, no matter how many layers there are  in the network, it would act like a single-layer neuron. \r\nSimply, because by just linearly adding these layers it will produce another linear output, consequently, the neuron can not update its weights therefore, no learning happens. Artificial neuron structure is presented in Fig.~\\ref{fig:artificial Neuron}.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure} [!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_1/artificial_neuron.png}\r\n\t\\end{center}\r\n\t\\caption{Structure of Perceptron} \r\n\t\\label{fig:artificial Neuron}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nThere are several non-linear functions used in artificial neural networks such as the Rectified Linear unit (Relu) which is used commonly, shown in Equation~\\ref{Eq:relu}. Other non-linear functions are the Sigmoid logistic function as shown in Equation~\\ref{sigmoid} and hyperbolic tangent function tanh as shown in Equation~\\ref{tanh} ~\\cite{Lecun2015}, where \\(z\\) is the summation of adjustable weights \\(\\{w_0,w_1,...,w_n \\}\\) multiplied by input variables (from previous layer) \\(\\{x_0,x_1,_...,x_n\\}\\) and a bias \\(b\\) as shown in Equation~\\ref{z}.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\tRelu(z) = \r\n\t\\begin{cases}\r\n\t\t0,  \\text{  if}\\ z<0\\\\\r\n\t\tz,  \\text{  otherwise}\r\n\t\\end{cases}\r\n\t\\label{Eq:relu}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\t\\sigma(z) = \\frac{1}{1+e^{-z}}\r\n\t\\label{sigmoid}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\t\\tanh(z)=  \\frac{e^z-e^{-z}}{e^z+e^{-z}}\r\n\t\\label{tanh}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\tz= \\sum_{i=0}^{n}  w_i\\times x_i +b\r\n\t\\label{z}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nSupervised learning is the traditional approach for learning in which a neural network builds its knowledge from the given labelled dataset, where the ground truth output is known previously~\\cite{Lecun2015}.\r\n\r\n\\subsubsection{Optimization and Deep Learning}\r\nMLP models learn to find the desired output by updating the network parameters such as weights and biases.\r\nAccordingly, a model does a comparison between the calculated output (predicted) and the ground truth output (target).\r\nFor this purpose, an objective function (cost function) is applied to estimate the loss (error) between the predicted output and the target.\r\nAccordingly, this process needs to be optimized to minimize the estimated value of the loss.\r\nA well-know optimization algorithm utilised in DL is the gradient descent (GD)~\\cite{Lecun2015}.\r\nFig.~\\ref{fig:GD} illustrates the concept of GD in one dimension, in which weights \\(\\{w_0,w_1,...,w_n\\}\\) are initially assigned randomly.\r\nGD aims to reduce the cost function \\(J(w)\\) at each step to reach the \\(J_{min}(w)\\) (global minimum) by calculating the gradient which represent the slope of the cost function.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/Gradient_decent.png}\r\n\t\\end{center}\r\n\t\\caption{The process of Gradient Descent} \r\n\t\\label{fig:GD}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nAccordingly, the weights are modified as shown in Eqn.~\\ref{weight_updates} where the partial derivative \\(\\frac{\\partial J(w)}{\\partial w_i}\\) is the gradient, and \\(\\alpha \\) is the learning rate which is the amount that the weights are updated during the learning process~\\cite{Russell2010}.\r\nTherefore, learning rate monitors the rate at which the neural network learns.\r\nHence, small learning rates require more training time because of the small changes made to the weights when updated, whereas large learning rates result in accelerated changes, consequently, require less training time.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\tw_{i+1}= w_{i} -\\alpha \\frac{\\partial J(w)}{\\partial w_i} \r\n\t\\label{weight_updates}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nThe backpropagation algorithm is the most widely used learning algorithm for neural networks, in which it back propagates the calculated gradients across all the perceptrons.\r\nAccordingly, all weights and biases are updated, which leads to minimizing the loss value.\r\n\\subsubsection{Optimization Challenges in Deep Learning}\r\nThe optimization algorithm in DL aims to reach the global minimum value of the cost function \\(J(w)\\).\r\nHowever, some challenges during the training process may occur.\r\nThe most tricky challenges are the local minima, saddle points, vanishing gradients, and exploding gradients.\r\n\r\nThe local minima occurs during training when the optimization algorithm ends up with a value of the cost function \\(J(w)\\) that is the smaller than values of \\(J(w)\\) at any other points in the local neighbourhood of \\(w\\).\r\nFigure~\\ref{fig:local_minima} shows that during the optimization process it is possible to end up in a local minima.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/local_minima.png}\r\n\t\\end{center}\r\n\t\\caption{Local minima} \r\n\t\\label{fig:local_minima}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nMoreover, a saddle point is any location where all gradients of a cost function vanish but which is neither a global nor a local minima as shown if Fig.\\ref{fig:saddle_point}.\r\n\r\nThe vanishing gradients is the most encountered problem during optimization process as the gradients become too small causing the learning process stuck for a long time  before it makes any progress or to stop at all~\\cite{Brownlee2017a}.\r\nWhereas, the exploding gradients problem occurs when the gradients become so large that leads to numerical overflow and results in \\say{NaN} values~\\cite{Brownlee2017a}.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/saddle_point.png}\r\n\t\\end{center}\r\n\t\\caption{Saddle point} \r\n\t\\label{fig:saddle_point}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{Convolutional Neural Network} \r\nConvolutional Neural Networks (CNNs) are a special type of artificial neural network (ANN) that were initially developed in 1980s by ~\\textcite{Fukushima1980} who was inspired by the discoveries of Hubel and Wiesel regarding the cat's visual cortex. \r\nCNNs are one of the most utilised architectures in DL for image processing as they can recognise complex patterns of images by performing convolution operations.\r\n\r\nIn mathematics, a convolution is an operation performed between any two functions, as for example \\(f, g:\\mathbb{R}^{d} \\to \\mathbb{R}\\) to produce at third function \\((f\\ast g)\\) depicted in Eqn.~\\ref{eqn:convolution}.\r\nIn which, we measure the overlap between \\(f\\) and \\(g\\), as one function is flipped and shifted by \\(x\\).\r\n\\begin{equation}\r\n\t(f\\ast g)(x) = \\int_{}^{} f(z).g(x-z)dz\r\n\t\\label{eqn:convolution}\r\n\\end{equation}\r\nIn the case of discrete objects defined on the set \\(\\mathbb{Z}\\) of integers, the integral operation turns into a summation,  as depicted in Eqn.~\\ref{eqn:discrete_conv}\r\n\\begin{equation}\t\t\r\n\t(f\\ast g)(x) = \\sum_{a}^{} f(a)g(i-a)\r\n\t\\label{eqn:discrete_conv}\r\n\\end{equation}\r\nFor inputs with two dimensions, we have a corresponding sum with indices \\((a,b)\\) for \\(f\\) and \\((i-a, j-b)\\) for \\(y\\) respectively as depicted in Eqn.~\\ref{eqn:2d_conv} and that describes a cross correlation operation.\r\n\\begin{equation}\r\n\t(f\\ast g)(i,j) = \\sum_{a}^{}\\sum_{b}^{}f(a,b)g(i-a,j-b)\r\n\t\\label{eqn:2d_conv}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%% from here\r\nConvolution operation for image processing is essentially a cross-correlation operation also known as a sliding dot product or sliding inner-product. \r\n%%%%%%%%%%%%%%%%%%%% \r\nCNNs was designed to process data as tensors with different dimensions. \r\nFor a 1D data tensor, it can represent various data forms, such as signals and sequences, in addition to languages.\r\nFor a 2D data tensor, it can represent an image in grey scale (one channel),\r\nmoreover, by combining three 2D tensors a coloured 3D image is produced due to different intensities of the pixels in the (RGB) channels.\r\nA 4D tensors represents volumetric data, such as a sequence of 3D images  or a video.\r\n\r\n%Commonly, a CNN consists of three main parts: convolutional layers, downsampling layers, and dense layers.\r\nA convolutional layer, has a number \\( n\\) of convolution kernels (filters), in  which,  each kernel has a set of weights, of a size \\((w_k,h_k,d_k)\\).\r\nThe kernel slides over an input image of a size \\((w,h,d)\\) performing a convolution operation (dot product), where \\(w\\) and \\(h\\) represent the image width and height, respectively, while \\(d\\) represents the depth (number of channels).\r\nThe output of the convolution operation are feature maps, moreover, each feature map is locally connected to the previous layer. \r\nFigure~\\ref{fig:convolution_3d} illustrates the convolution operation for a 3D input and the calculated output (feature map) with a new shape of \\((h_{n}\\times w_{n} \\times d_{n})\\).\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure} [!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=0.75\\textwidth]{Figures/Chapter_3/convolution_operation_3D.png}\r\n\t\\end{center}\r\n\t\\caption{Convolution operation with a sliding kernel.} \r\n\t\\label{fig:convolution_3d}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nTypically, the feature map size is diminished due to the convolution operation, however, the feature map can keep the same size of the input by applying some padding over the input. \r\nEquations~\\ref{new_hight} and~\\ref{new_width} illustrates the calculations of new height and width of the output, where \\(h_{n}\\) and \\(w_{n}\\) are the new height and width dimensions of the feature map respectively after applying the convolution. \r\nThe padding \\(p\\) which is added to the input image of a feature map to guarantee that both the input and the output have the same dimensions, \\(h_{k}\\) and \\(w_{k}\\) are the height and the width of the convolutional kernel, respectively.\r\nThe stride \\(s\\) defines how much the convolutional kernel slides each step during convolution.\r\nThe number channels at the output feature map \\((d_{n})\\) equals to the applied number of convolutional kernels \\((n)\\). \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\th_{n} = \\frac{h+2\\times p-h_{k}}{s}+1  \r\n\t\\label{new_hight}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\tw_{n} = \\frac{w+2\\times p-w_{k}}{s}+1\r\n\t\\label{new_width}\r\n\\end{equation}\r\nTypically,  while training a CNN model, the kernel weights are initialised randomly.\r\nAccordingly, during the backpropagation process, all learnable parameters (kernels weights and biases) are updated.\r\nConsequently, kernels learn to detect different of types of edges (vertical, horizontal, and diagonal edges), color intensities, etc.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nCommonly, a convolutional operation is followed by a non-linear activation function such as (relu, sigmoid, tanh), followed by a downsampling operation (pooling). \r\nThe idea behind pooling operation is to aggregate related features into one by reducing the spatial dimensions of the feature maps(e.g., width, height, and depth)~\\cite{Lecun2015}, which reduces the computation complexity.\r\nFigure~\\ref{fig:downsampling} presents common downsampling operations, which are Max and average pooling, further, the pool size is \\(2 \\times 2\\) with strides of \\(2\\).\r\nThe Maxpool picks the maximum value in the local pool filter in a feature map, whereas the average pool picks the average value in the local pool filter in a feature map.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure} [!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/downsampling.png}\r\n\t\\end{center}\r\n\t\\caption{Types of downsampling operations} \r\n\t\\label{fig:downsampling}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nA convolution operation, followed by a non-linear activation function, and pooling is referred to as a convolutional block.\r\nMoreover, a convolutional block can be stacked and repeated several times. \r\nFinally, to pass the output from the convolutional block to the dense layer, a flattened layer is utilised to produce a 1D tensor.\r\nFigure~\\ref{fig:CNN} presents the default architecture of a CNN.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure} [!ht]\r\n\t\\begin{center}\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=1\\textwidth]{Figures/Chapter_3/cnn.png}\r\n\t\\end{center}\r\n\t\\caption{Convolutional Neural Network architecture} \r\n\t\\label{fig:CNN}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nCNNs became popular after the competition of the Large Scale Visual Recognition Challenge 2012 (ILSVRC2012). \r\nWhen \\textcite{Krizhevsky2012} introduced AlexNet~\\cite{Krizhevsky2012}, which is a deep CNN applied on a large dataset of \\(1,000,000\\) images and \\(1,000\\) different classes.\r\nAlexNet results were magnificent. \r\nThe success has stimulated the progress of the development in GPUs technology and the use of the non-linear activation function Relu~\\cite{Lecun2015}.\r\nIn next years, several spectacular CNNs architectures were presented (e.g VGG-16, ResNet, Inception-v4 and others).\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{Recurrent neural networks}\r\n\\label{sec222}\r\nRecurrent neural network (RNN) is a class of ANN that was introduced to work with time-series data (sequential data).\r\nRNN technique can remember its data input, because of its internal memory which makes it a powerful and promising technique in the field of DL.\r\nSince there are temporal problems such as natural language processing, language translation, image captioning and so on, they require to be handled sequentially.\r\nIn the traditional deep neural networks (feed-forward) the information only moves in one direction from input layer through hidden layers to the output layers.\r\nHowever, this is not the case for the RNN technique, which implies the current output of an RNN depends on prior input sequence.\r\nAccordingly, future events are also utilised for predicting the output of a given sequence.\r\nFigure~\\ref{fig:rnn_vs_FFNN} depicts the difference between RNN and feed-forward deep neural networks.\r\nAs shown in the Fig.~\\ref{fig:rrn}, for the RNN, the output of a certain layer is looped back to its input which helps in making the prediction.\r\nHowever, in feed-forward networks shown in Fig.~\\ref{fig:FFNN} the inputs and outputs are independent, as there is only one direction for the data to move.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[!ht]\r\n\t\\centering\r\n\t\\begin{subfigure}{0.49\\textwidth}\t\t\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/recurrent_NN.png}\r\n\t\t\\caption{} \r\n\t\t\\label{fig:rrn}\r\n\t\\end{subfigure}\r\n\t\\hfill\r\n\t\\begin{subfigure}{0.49\\textwidth}\r\n\t\t\\centering\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/feedforward_NN.png}\r\n\t\t\\caption{} \r\n\t\t\\label{fig:FFNN}\r\n\t\\end{subfigure}\t\r\n\t\\caption{(a) RNN v.s. (b) Feed-forward neural network}\r\n\t\\label{fig:rnn_vs_FFNN}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nFigure~\\ref{unrolled_rnn} presents a visualisation of an unrolled RNN, where \\(x_{t}\\) corresponds to the sequential timestamped input at time \\(t\\), \\(h_{t}\\) corresponds to internal state  and \\(Y_{t}\\) corresponds to the predicted timestamped output at time \\(t\\).\r\nAn unrolled RNN can be seen as a cascaded sequence of feed-forward networks.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\\includegraphics[scale=1]{Figures/Chapter_3/unrolled_rnn.png}\r\n\t\\end{center}\r\n\t\\captionof{figure}{Unrolled RNN.}\r\n\t\\label{unrolled_rnn}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nIn feed-forward neural networks, as mentioned earlier, the learnable parameters (adjustable weights) are available only for the forward path of data propagation that are updated through back-propagation algorithm.\r\nIn RNNs, there are two paths of data propagation (forward and backward), hence, there are learnable weights for both directions.\r\nIn RNN, weights are updated using back-propagation through time (BBTT)~\\cite{Werbos1990}.\r\nBBTT depends on the number of timestamps, so it is computationally expensive when there are a high number of timestamps as BBTT performs a back-propagation algorithm on unrolled RNN.\r\nConsequently, when implementing RNNs, issues may arise during updating the learnable weights using BBTT which are vanishing and exploding gradients.\r\nTo overcome such issues, ~\\textcite{Hochreiter1997} introduced a long short-term memory (LSTM), which is a memory extension for a regular RNN to address the problem of long-term dependencies.\r\nFurther, LSTMs handle inputs or outputs of any length that makes LSTMs powerful for solving very complex sequential problems.\r\nLSTM is composed of four units: an input gate, a cell state, a forget gate, and a output gate as presented in Fig.~\\ref{fig:lstm}.\r\nThese gates help regulating the flow of information that is added to or removed from the cell state. \r\nThe hidden states in LSTM hold the short-term memory, while the cells state holds the long-term memory.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[h!]\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/lstm.png}\r\n\t\\end{center}\r\n\t\\captionof{figure}{LSTM architecture.}\r\n\t\\label{fig:lstm}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nThe forget gate is utilised to determine which information to consider and which to neglect.\r\nThe current input \\(x_t\\) and the previous hidden state \\(h_{t-1}\\) are passed through a sigmoid function which will produce values between \\(0\\) and \\(1\\).\r\nThen the outputs of the sigmoid are multiplied with the previous cell state \\(c_{t-1}\\) to discard outputs equal to zero.\r\nEquation~\\ref{eqn:forget_gate} depicts the calculation at the forget gate.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\t\\centering\r\n\tf_t = \\sigma(W_f.[h_{t-1}, X_{t}]+ b_f)\r\n\t\\label{eqn:forget_gate}\r\n\\end{equation}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nwhere \\(W\\) represents the learnable weights, and \\(b\\) represents the bias term.\r\n\r\nThe input gate \\(i_{t}\\) takes the current input \\(X_t\\) with the previous hidden state \\(h_{t-1}\\) then apply the sigmoid function to get values in a range between 0 (not important) and 1 (important), then the\r\nsame current input \\(X_t\\), and the hidden state \\(h_{t-1}\\) are passed through a \\(\\tanh\\) function at \\(\\tilde{C}_{t}\\) that will regulate the network by transferring the values into a range between \\(-1\\) and \\(1\\).\r\nThen, the outputs from the sigmoid and \\(\\tanh\\) functions are multiplied point-by-point to eliminate \\(0\\) values.  \r\nEquation~(\\ref{eq:eq2}) depicts the calculation at the input gate:\r\n\\begin{equation}\r\n\t\\begin{aligned}\r\n\t\ti_{t} &=\\sigma\\left(W_{i} \\cdot\\left[h_{t-1}, X_{t}\\right]+b_{i}\\right) \r\n\t\t\\\\\r\n\t\t\\tilde{C}_{t} &=\\tanh \\left(W_{s} \\cdot\\left[h_{t-1}, X_{t}\\right]+b_{c}\\right) \r\n\t\\end{aligned} \\label{eq:eq2}\r\n\\end{equation}\r\nAt this point, the network has sufficient information obtained from the input and forget gates. \r\nHence, the current cell state \\(C_t\\) can be calculated by multiplying the previous cell state \\(C_{t-1}\\) with the output of the forget gate, then the result is added to the calculated input values as depicted in Eqn.~(\\ref{eq:eq3}).\r\n\\begin{equation}\r\n\tC_{t}=f_{t} * C_{t-1}+i_{t} * \\tilde{C}_{t}\r\n\t\\label{eq:eq3}\r\n\\end{equation}\r\nThe output gate \\(o_{t}\\) computes the next hidden state \\(h_{t}\\) which\r\nholds information related to the current inputs. \r\nAccordingly, the current input \\(X_{t}\\) and the previous hidden state \\(h_{t-1}\\) are passed through a third sigmoid function to produce values between \\(0\\) and \\(1\\).\r\nThe current cell state \\(C_{t}\\) is passed through a \\(\\tanh\\) function and multiplied point-by-point with \\(o_{t}\\) to produce the new hidden state \\(h_{t}\\) which is transferred to the next timestamp.\r\nEquation~(\\ref{eq:eq4}) illustrates the calculations at the output gate:\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{equation}\r\n\t\\begin{aligned}\r\n\t\to_{t} &=\\sigma\\left(W_{o}\\left[h_{t-1}, X_{t}\\right]+b_{o}\\right) \\\\\r\n\t\th_{t} &=o_{t} * \\tanh \\left(C_{t}\\right)\r\n\t\\end{aligned}\r\n\t\\label{eq:eq4}\r\n\\end{equation} \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nRecently, LSTMs have been widely used for large-scale learning of language translation models, speech recognition systems, chatbots, forecasting stock markets, text data analysis, and many more~\\cite{graves2014towards, cho2014properties}. \r\nHowever, LSTMs are inefficient regarding capturing spatial information by themselves when the time series inputs are consecutive images.\r\nAccordingly, ConvLSTM layer which is a combination of CNN and LSTM unit was introduced by Shi et al.~\\cite{xingjian2015convolutional} to solve such a problem.\r\nFor ConvLSTM, the convolution operations are applied both at the input-to-state transition and at the state-to-state transitions.  \r\nConvLSTM shown in Fig.~\\ref{fig:ConvLSTM} is a variation of the LSTM cell as it performs a convolution operation within the LSTM cell.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure}[h!]\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=1]{Figures/Chapter_3/convlstm_image.png}\r\n\t\\end{center}\r\n\t\\captionof{figure}{ConvLSTM architecture.}\r\n\t\\label{fig:ConvLSTM}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nConvLSTM is a combination of a convolution operation and an LSTM cell.\r\nThus, ConvLSTM can capture the time-correlated and spatial features in a series of consecutive images. \r\nEquation~(\\ref{eq:eq5}) depicts the ConvLSTM operations as the inputs \\(X_1, \\dots, X_t\\), hidden states \\(h_1, \\dots, h_t\\), cell states \\(C_1, \\dots, C_t\\) and input, forget and output gates are represented as \\(i_t, f_t\\), and \\(o_t\\), respectively:\r\n\\begin{equation}\r\n\t\\begin{aligned}\r\n\t\ti_{t} &=\\sigma\\left(W_{x i} * X_{t}+W_{h i} * h_{t-1}+W_{c i} \\odot C_{t-1}+b_{i}\\right) \r\n\t\t\\\\\r\n\t\tf_{t} &=\\sigma\\left(W_{x f} * X_{t}+W_{h f} * h_{t-1}+W_{c f} \\odot C_{t-1}+b_{f}\\right) \\\\\r\n\t\tC_{t} &=f_{t} \\odot C_{t-1}+i_{t} \\odot \\tanh \\left(W_{x c} * X_{t}+W_{h c} * h_{t-1}+b_{c}\\right) \r\n\t\t\\\\\r\n\t\to_{t} &=\\sigma\\left(W_{x o} * X_{t}+W_{h o} * h_{t-1}+W_{c o} \\odot C_{t}+b_{o}\\right) \\\\\r\n\t\th_{t} &=o_{t} \\odot \\tanh \\left(C_{t}\\right)\r\n\t\\end{aligned}\r\n\t\\label{eq:eq5}\r\n\\end{equation}\r\nwhere \\(*\\) indicates the convolution operation, and \\(\\odot\\) represents the \r\nHadamard product. \r\nRecently, ConvLSTM has become very popular and is increasingly being used in \r\nmore and more image processing applications.", "meta": {"hexsha": "8ccb633548f28eb9be78b67b74c9b613510ad797", "size": 26462, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/project_reports/Ijjeh_thesis_template/Chapters/Chapter3/sect32.tex", "max_stars_repo_name": "IFFM-PAS-MISD/aidd", "max_stars_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-03T05:36:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:36:07.000Z", "max_issues_repo_path": "reports/project_reports/Ijjeh_thesis_template/Chapters/Chapter3/sect32.tex", "max_issues_repo_name": "IFFM-PAS-MISD/aidd", "max_issues_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/project_reports/Ijjeh_thesis_template/Chapters/Chapter3/sect32.tex", "max_forks_repo_name": "IFFM-PAS-MISD/aidd", "max_forks_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.1035422343, "max_line_length": 556, "alphanum_fraction": 0.6664273298, "num_tokens": 6298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4407153474489862}}
{"text": "\\section{Accelerated Sampling Methods}\n\\label{section:accel}\n\n\\subsection{Accelerated Molecular Dynamics}\n\\label{section:accelmd}\nAccelerated molecular dynamics (aMD)~\\cite{HAME2004mc} is an enhanced-sampling method that\nimproves the conformational space sampling by \nreducing energy barriers separating different states of a system.\nThe method modifies the potential \nenergy landscape by raising energy wells that are below\na certain threshold level, while leaving those above this level unaffected.\nAs a result, barriers separating adjacent energy basins are reduced, allowing the system to sample\nconformational space that cannot be easily accessed in a classical MD simulation.\n\nPlease include the following two references in your work using the NAMD implementation of aMD:\n\\begin{itemize}\n  \\item {Accelerated Molecular Dynamics: A Promising and Efficient Simulation Method for Biomolecules, D.\\,Hamelberg, J.\\,Mongan, and J.\\,A. McCammon. {\\it J. Chem. Phys.}, 120:11919-11929, 2004.}\n  \\item{Implementation of Accelerated Molecular Dynamics in NAMD, Y.\\,Wang, C.\\,Harrison, K.\\,Schulten, and J.\\,A. McCammon, {\\it Comp.~Sci.~Discov.}, 4:015002, 2011.}\n\\end{itemize}\n\n\\subsubsection{Theoretical background}\nIn the original form of aMD~\\cite{HAME2004mc}, when the system's potential energy falls       \nbelow a threshold energy, $E$, a boost potential is added, \nsuch that the modified potential, $V^*({\\bf r})$, is related to the original\npotential, $V({\\bf r})$, via\n\\begin{equation}\nV^*({\\bf r})= V({\\bf r}) + \\Delta V({\\bf r}),\n\\end{equation}\nwhere $\\Delta V({\\bf r})$ is the boost potential, \n\\begin{equation} \n\\Delta V({\\bf r})= \\left \\{\n\\begin{array}{l l}\n0   & \\quad \\quad V({\\bf r})\\geq E \\\\  \n\\frac{(E-V({\\bf r}))^2}{\\alpha+E-V({\\bf r})}  & \\quad \\quad V({\\bf r})<E. \\\\\n\\end{array} \\right. \n\\end{equation}\nAs shown in the following figure, the threshold energy $E$ controls the portion of \nthe potential surface affected by the boost, while the acceleration factor \n$\\alpha$ determines the shape of the modified potential.\n%as $\\alpha$ increases, the modified potential asymptotically approaches the original potential;\n%as $\\alpha$ decreases, the energy surface below $E$ begins to resemble a constant potential.\nNote that $\\alpha$ cannot be set to zero, otherwise the derivative of the modified potential\nis discontinuous.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=7cm]{figures/amd_schematic.jpg}\n  \\caption{Schematics of the aMD method. When the original potential (thick line) falls below a threshold energy $E$ (dashed line),\n          a boost potential is added. The modified energy profiles (thin lines) have smaller barriers separating adjacent\n\t  energy basins. \n\t  %Two parameters, $E$ and $\\alpha$, controls the portion of the affected potential landscape and the\n\t  %shape of the modified potential, respectively.\n\t  }\n  \\label{fig:amd_schematic}\n\\end{figure}\nFrom an aMD simulation, the ensemble average, $\\langle A \\rangle$, of an observable, $A({\\bf r})$, can be calculated\nusing the following reweighting procedure:\n\\begin{equation}\n\\langle A \\rangle =\\frac{\\langle A({\\bf r})\\,\\text{exp} (\\beta \\Delta V({\\bf r})) \\rangle^* }\n{\\langle \\text{exp}  (\\beta \\Delta V({\\bf r})) \\rangle^*},\n\\end{equation}\nin which $\\beta$=$1/k_BT$, and $\\langle ... \\rangle$ and $\\langle...\\rangle^*$ represent \nthe ensemble average in the original and the aMD ensembles, respectively. \n\nCurrently, aMD can be applied in three modes in NAMD: aMDd, aMDT, and aMDdual~\\cite{WANG2011mc}. The boost energy\nis applied to the dihedral potential in the aMDd mode (the default mode), and to the total potential in the aMDT mode.\nIn the dual boost mode (aMDdual)~\\cite{HAME2007mc}, two independent boost energies are applied, one on the dihedral potential and the other\non the (Total - Dihedral) potential.\n\n\\subsubsection{NAMD parameters}\n\nThe following parameters are used to enable accelerated MD:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{accelMD}{Is accelerated molecular dynamics active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies if accelerated MD is active.}\n\n\\item\n\\NAMDCONFWDEF{accelMDdihe}{Apply boost to dihedrals?}{{\\tt on} or {\\tt off}} {{\\tt on}} \n{Only applies boost to the dihedral potential. \nBy default, {\\tt accelMDdihe} is turned on and the boost energy is applied to the dihedral potential of the simulated system.\nWhen {\\tt accelMDdihe} is turned off, aMD switches to the {\\tt accelMDT} mode, and the boost is applied to the total potential.\n}\n\n\\item\n\\NAMDCONF{accelMDE}{Threshold energy $E$}\n{Real number}\n{Specifies the threshold energy $E$ in the aMD equations. \n}\n\n\\item\n\\NAMDCONF{accelMDalpha}{Acceleration factor $\\alpha$}\n{Positive real number}\n{Specifies the acceleration factor $\\alpha$ in the aMD equations. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDdual}{Use dual boost mode?}{{\\tt on} or {\\tt off}}{{\\tt off}}\n{When {\\tt accelMDdual} is on, aMD switches to the dual boost mode. Two independent boost potentials \nwill be applied: one to the dihedral potential that is controlled by the parameters {\\tt accelMDE} and {\\tt accelMDalpha},\nand a second to the (Total - Dihedral) potential that is controlled by the  {\\tt accelMDTE} and {\\tt accelMDTalpha} parameters described below.\n}\n\n\\item\n\\NAMDCONF{accelMDTE}{Threshold energy $E$ in the dual boost mode}\n{Real number}\n{Specifies the threshold energy $E$ used in the calculation of boost energy for the (Total - Dihedral) potential. \nThis option is only available when {\\tt accelMDdual} is turned on.\n}\n\n\\item\n\\NAMDCONF{accelMDTalpha}{Acceleration factor $\\alpha$ in the dual boost mode}\n{Positive real number}\n{Specifies the acceleration factor $\\alpha$ used in the calculation of boost energy for the (Total - Dihedral) potential. \nThis option is only available when {\\tt accelMDdual} is turned on.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDFirstStep}{First accelerated MD step}\n{Zero or positive integer}{0}\n{Accelerated MD will only be performed when the current step is equal to or higher than {\\tt accelMDFirstStep}, and equal to or lower than {\\tt accelMDLastStep}. Otherwise regular MD will be performed.\n}\n\\item\n\\NAMDCONFWDEF{accelMDLastStep}{Last accelerated MD step}\n{Zero or positive integer}{0}\n{Accelerated MD will only be performed when the current step is equal to or higher than {\\tt accelMDFirstStep}, and equal to or lower than {\\tt accelMDLastStep}. Otherwise regular MD will be performed. Note that the accelMDLastStep parameter only has an effect when it is positive. When accelMDLastStep is set to zero (the default), aMD is `open-ended' and will be performed\ntill the end of the simulation. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDOutFreq}{Frequency in steps of aMD output}\n{Positive integer}{1}\n{An aMD output line will be printed to the log file at the frequency specified by {\\tt accelMDOutFreq}.\nThe aMD output will contain the boost potential ($dV$) at the current timestep, \nthe average boost potential ($dVAVG$) since the last aMD output, and various potential energy values at the current timestep.\nThe boost potential $dV$ can be used to reconstruct the ensemble average described earlier.\n}\n\n\\end{itemize}\n\n\\subsection{Adaptive Tempering}\n\\label{section:adapttemp}\nAdaptive tempering is akin to a single-copy replica exchange method for dynamically updating the simulation temperature. The temperature $T$ is a new random variable in the range $[Tmin,Tmax]$ that is governed by the equation $dE/dT = E-E(T)-1/T+sqrt(2)T\\xi$, where $\\xi$ is Gaussian white noise. The effect is that when the potential energy for a given structure is lower than the (so far calculated) average energy, the temperature is lowered. Conversely when the current energy is higher than the average energy, the temperature is raised. The effect is faster conformational sampling to find minimum energy structures. The method is implemented exactly as described by Zhang and Ma in J. Chem. Phys. 132, 244101 (2010) (using Equation 18 of their paper to calculate the average energy at a given temperature from the histogram of energies). \n\nThe dynamic temperature is realized either by changing the temperature of the Langevin thermostat or by velocity rescaling. \n\n\\subsubsection{NAMD parameters}\n\nThe following parameters are used to adaptive tempering:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{adaptTempMD}{Is adaptive tempering active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies whether or not adaptive tempering is used. If set to on then the following parameters are required to be set: either all of ({\\tt adaptTempTmin}, {\\tt adaptTempTmax}, {\\tt adaptTempBins}, {\\tt adaptTempDt}) or {\\tt adaptTempInFile} (but not both).\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempFreq}{steps between temperature updates}\n{Positive integers}{10}\n{The number of steps between temperature updates. Note that the potential energy at the current is calculated and added to the temperature-energy histogram at every step.\n}\n\n\\item\n\\NAMDCONF{adaptTempTmin}{minimum temperature (K)}\n{Positive real number} \n{Sets the minimum temperature to be used in the simulation.\n}\n\n\\item\n\\NAMDCONF{adaptTempTmax}{maximum temperature (K)}\n{Positive real number}\n{Sets the maximum temperature to be used in the simulation.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempBins}{number of temperature bins}\n{Positive integer}{1000}\n{Sets the number of bins to subdivide the temperature range. Each bin stores the average energy for the given temperature \n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempDt}{stepsize for temperature updates}{Positive real numbers}{$10^{-4}$}\n{Integration timestep for temperature updates. This is unrelated to the simulation timestep and only scales the size of the step taken in temperature space every {\\tt adaptTempFreq} steps.\n}\n\n\\item\n\\NAMDCONF{adaptTempInFile}{adaptive tempering input filename}\n{UNIX filename}\n{The input file containing restart information for adaptive tempering (written out by {\\tt adaptTempRestartFile}).\n}\n\n\\item\n\\NAMDCONF{adaptTempRestartFile}{adaptive tempering restart filename}\n{UNIX filename}\n{The file to write out restart information for adaptive tempering.\n}\n\n\\item\n\\NAMDCONF{adaptTempRestartFreq}{steps between writing restart file}\n{Positive integer}\n{Frequency of writing restart file.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempLangevin}{send temperature updates to langevin thermostat?}\n{{\\tt on} or {\\tt off}}{{\\tt on}}\n{Setting this to on will cause the langevin thermostat to use the updated temperatures from adaptive tempering. Note that either one of adaptTempLangevin or adaptTempRescaling have to be on.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempRescaling}{send temperature to velocity rescaling thermostat?}\n{{\\tt on} or {\\tt off}}{{\\tt on}}\n{Setting this to on will cause the veloctiy rescaling thermostat to use the updated temperatures from adaptive tempering.  Note that either one of adaptTempLangevin or adaptTempRescaling have to be on.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempOutFreq}{steps between printing adaptive tempering output}\n{Positive integers}{10}\n{The number of timesteps between printing adaptive tempering output to the log file.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempFirstStep}{step to start adaptive tempering}\n{Non-negative integers}{0}\n{The first timestep from which adaptive tempering will be run.}\n\n\\item\n\\NAMDCONF{adaptTempLastStep}{step to stop adaptive tempering}\n{Positive integers}\n{The last timestep to apply adaptive tempering.}\n\n\\item\n\\NAMDCONFWDEF{adaptTempCgamma}{dynamic bin averaging constant}\n{Non-negative real number}{0.1}\n{The calculation of the mean energy for a given bin is weighted by a factor of 1 - Cgamma / samples to damp out old statistics. Setting Cgamma to zero restores the use of a standard arithmetic mean to calculate the mean energy for each bin.}\n\n\\item\n\\NAMDCONFWDEF{adaptTempRandom}{assign random temperature if we step out of range?}\n{{\\tt on} or {\\tt off}}{{\\tt off}}\n{If set to on and the temperature steps out of [{\\tt adaptTempTmin}, {\\tt adaptTempTmax}], a random temperature in that range is assigned. Otherwise the previous temperature is kept.\n}\n\n%\\item\n%\\NAMDCONFWDEF{adaptTempDebug}{print debug output?}\n%{{\\tt on} or {\\tt off}}{{\\tt off}}\n%{Print adaptive tempering debug output.\n%}\n\n\\end{itemize}\n\n\n\\subsection{Locally enhanced sampling}\n\\label{section:les}\n\nLocally enhanced sampling (LES)~\\cite{ROIT91,SIMM98,SIMM00} increases\nsampling and transition rates for a portion of a molecule by the use of\nmultiple non-interacting copies of the enhanced atoms.  These enhanced\natoms experience an interaction (electrostatics, van der Waals, and\ncovalent) potential that is divided by the number of copies present.\nIn this way the enhanced atoms can occupy the same space, while the\nmultiple instances and reduces barriers increase transition rates.\n\n\\subsubsection{Structure generation}\n\nTo use LES, the structure and coordinate input files must be modified to\ncontain multiple copies of the enhanced atoms.  \\PSFGEN\\ provides the\n{\\tt multiply} command for this purpose.  \\NAMD\\ supports a maximum of 255\ncopies, which should be sufficient.  \n\nBegin by generating the complete molecular structure and guessing\ncoordinates as described in Sec.~\\ref{section:psfgen}.  As the last\noperation in your script, prior to writing the psf and pdb files, add\nthe {\\tt multiply} command, specifying the number of copies desired and\nlisting segments, residues, or atoms to be multiplied.  For example,\n\\verb#multiply 4 BPTI:56 BPTI:57# will create four copies of the last\ntwo residues of segment BPTI.  You must include all atoms to be\nenhanced in a single {\\tt multiply} command in order for the bonded\nterms in the psf file to be duplicated correctly.  Calling {\\tt multiply}\non connected sets of atoms multiple times will produce unpredictable\nresults, as may running other commands after {\\tt multiply}.\n\nThe enhanced atoms are duplicated exactly in the structure---they have\nthe same segment, residue, and atom names.  They are distinguished only\nby the value of the B (beta) column in the pdb file, which is 0 for\nnormal atoms and varies from 1 to the number of copies created for\nenhanced atoms.  The enhanced atoms may be easily observed in VMD with\nthe atom selection \\verb#beta != 0#.\n\n\\subsubsection{Simulation}\n\nIn practice, LES is a simple method used to increase sampling;\nno special output is generated.\nThe following parameters are used to enable LES:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{les}{is locally enhanced sampling active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies whether or not LES is active.}\n\n\\NAMDCONF{lesFactor}{number of LES images to use}\n{positive integer equal to the number of images present}\n{This should be equal to the factor used in {\\tt multiply}\n when creating the structure.  The interaction potentials for images is\n divided by {\\tt lesFactor}.  \n}\n\n\\item\n\\NAMDCONFWDEF{lesReduceTemp}{reduce enhanced atom temperature?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Enhanced atoms experience interaction potentials divided by {\\tt lesFactor}.\nThis allows them to enter regions that would not normally be thermally\naccessible.  If this is not desired, then the temperature of these atoms\nmay be reduced to correspond with the reduced potential.  This option\naffects velocity initialization, reinititialization, reassignment, and\nthe target temperature for langevin dynamics.  Langevin dynamics is\nrecommended with this option, since in a constant energy simulation energy\nwill flow into the enhanced degrees of freedom until they reach thermal\nequilibrium with the rest of the system.  The reduced temperature atoms\nwill have reduced velocities as well, unless {\\tt lesReduceMass} is also\nenabled.}\n\n\\item\n\\NAMDCONFWDEF{lesReduceMass}{reduce enhanced atom mass?}{{\\tt on} or {\\tt off}}{{\\tt off}}\n{Used with {\\tt lesReduceTemp} to restore velocity distribution to\nenhanced atoms.  If used alone, enhanced atoms would move faster than\nnormal atoms, and hence a smaller timestep would be required.}\n\n\\item\n\\NAMDCONFWDEF{lesFile}{PDB file containing LES flags}{UNIX filename} {{\\tt coordinates}}\n{PDB file to specify the LES image number of each atom.\nIf this parameter is not specified, then \nthe PDB file containing initial coordinates specified by \n{\\tt coordinates} is used.}\n\n\\item\n\\NAMDCONFWDEF{lesCol}{column of PDB file containing LES flags}{{\\tt X}, {\\tt Y}, {\\tt Z}, {\\tt O}, or {\\tt B}}{{\\tt B}}\n{Column of the PDB file to specify the LES image number of each atom.\nThis parameter may specify any of the floating point fields of the PDB file, \neither X, Y, Z, occupancy, or beta-coupling (temperature-coupling).  \nA value of 0 in this column indicates that the atom is not enhanced.\nAny other value should be a positive integer less than {\\tt lesFactor}.}\n\n\\end{itemize}\n\n\n\\subsection{Replica exchange simulations}\n\n\\index{replica exchange}\nThe {\\tt lib/replica/}\ndirectory contains Tcl scripts that implement replica exchange\nboth for parallel tempering (temperature exchange) and\numbrella sampling (exchanging collective variable biases).\nThis replaces the old Tcl server and socket connections driving a\nseparate NAMD process for every replica used in the simulation.\n\n{\\bf A NAMD build based on Charm++ 6.5.0 or later using one of the\n``LRTS'' (low-level runtime system) machine layers is required!}\nCurrent LRTS machine layers include mpi, netlrts, verbs (for InfiniBand),\ngemini\\_gni-crayxe, gni-crayxc, and pamilrts-bluegeneq.\n\nOnly temperature-exchange simulations are described below.\nTo employ replicas for umbrella sampling you will need to understand\nthis material, collective variable-based calculations (Sec.\\ \\ref{section:colvars}),\nand basic Tcl programming to adapt the examples in {\\tt lib/replica/umbrella/}\nand {\\tt lib/replica/umbrella2d/} until further\ndocumentation and a tutorial are available.\n\nThis implementation is designed to be modified to implement\nexchanges of parameters other than temperature or via other temperature\nexchange methods.  The scripts should provide a good starting point for\nany simulation method requiring a number of loosely interacting systems.\n\nReplica exchanges and energies are recorded in the .history files\nwritten in the output directories.  These can be viewed with, e.g.,\n``{\\tt xmgrace output/*/*.history}'' and processed via awk or other tools.\nThere is also a script to load the output into VMD and color each\nframe according to replica index.  An example simulation folds\na 66-atom model of a deca-alanine helix in about 10\\,ns.\n\n{\\tt replica.namd}\nis the master script for replica temperature-exchange simulations.  To run:\n\\begin{verbatim}\n          cd example\n          mkdir output\n          (cd output; mkdir 0 1 2 3 4 5 6 7)\n          mpirun namd2 +replicas 8 job0.conf +stdout output/%d/job0.%d.log\n          mpirun namd2 +replicas 8 job1.conf +stdout output/%d/job1.%d.log\n\\end{verbatim}\n\nThe number of MPI ranks must be a multiple of the number of replicas\n(+replicas).  Be sure to increment jobX for +stdout option on command line.\n\n{\\tt show\\_replicas.vmd} is a script for loading replicas into VMD;\nfirst source the replica exchange conf file and then this script, then\nrepeat for each restart conf file or for example just do\n``{\\tt vmd -e load\\_all.vmd}''.\nThis script will likely destroy anything else you are doing in VMD at the\ntime, so it is best to start with a fresh VMD.\n{\\tt clone\\_reps.vmd} provides the {\\tt clone\\_reps} commmand to copy graphical\nrepresentation from the top molecule to all other molecules.\n\n{\\tt sortreplicas}, found in the namd2 binary directory, is a program to un-shuffle\nreplica trajectories to place same-temperature frames in the same file.\nUsage:\n\\begin{verbatim}\n  sortreplicas <job_output_root> <num_replicas> <runs_per_frame> [final_step]\n\\end{verbatim}\nwhere job\\_output\\_root is the job specific output base path, including\n\\%s or \\%d for separate directories as in output/\\%s/fold\\_alanin.job1\nThis will be extended with .\\%d.dcd .\\%d.history for input files and\n.\\%d.sort.dcd .\\%d.sort.history for output files.  The optional final\\_step\nparameter will truncate all output files after the specified step,\nwhich is useful in dealing with restarts from runs that did not complete.\nColvars trajectory files are similarly processed if they are found.\n\nA replica exchange config file should define the following Tcl variables:\n\\begin{itemize}\n\\item {\\tt num\\_replicas}, the number of replica simulations to use,\n\\item {\\tt min\\_temp}, the lowest replica target temperature,\n\\item {\\tt max\\_temp}, the highest replica target temperature,\n\\item {\\tt steps\\_per\\_run}, the number of steps between exchange attempts,\n\\item {\\tt num\\_runs}, the number of runs before stopping\n(should be divisible by {\\tt runs\\_per\\_frame} $\\times$ {\\tt frames\\_per\\_restart}).\n\\item {\\tt runs\\_per\\_frame}, the number of runs between trajectory outputs,\n\\item {\\tt frames\\_per\\_restart}, the number of frames between restart outputs,\n\n\\item {\\tt namd\\_config\\_file}, the NAMD config file containing all parameters,\nneeded for the simulation except {\\tt seed}, {\\tt langevin}, \n{\\tt langevinTemp}, {\\tt outputEnergies},\n{\\tt outputname}, {\\tt dcdFreq},\n{\\tt temperature}, {\\tt bincoordinates}, {\\tt binvelocities},\nor {\\tt extendedSystem}, which are provided by {\\tt replica.namd},\n\n\\item {\\tt output\\_root}, the directory/fileroot for output files,\noptionally including a ``\\%s'' that is replaced with the replica index\nto use multiple output directories,\n\n\\item {\\tt psf\\_file}, the psf file for {\\tt show\\_replicas.vmd}, \n\\item {\\tt initial\\_pdb\\_file}, the initial coordinate pdb file for {\\tt show\\_replicas.vmd},\n\\item {\\tt fit\\_pdb\\_file}, the coodinates that frames are fit to by {\\tt show\\_replicas.vmd} (e.g., a folded structure),\n\\end{itemize}\n\nThe {\\tt lib/replica/example/} directory contains\nall files needed to fold a 66-atom model of a deca-alanine helix:\n\\begin{itemize}\n\\item {\\tt alanin\\_base.namd}, basic config options for NAMD,\n\\item {\\tt alanin.params}, parameters,\n\\item {\\tt alanin.psf}, structure,\n\\item {\\tt unfolded.pdb}, initial coordinates,\n\\item {\\tt alanin.pdb}, folded structure for fitting in {\\tt show\\_replicas.vmd},\n\\item {\\tt fold\\_alanin.conf}, config file for {\\tt replica\\_exchange.tcl} script,\n\\item {\\tt job0.conf}, config file to start alanin folding for 10\\,ns,\n\\item {\\tt job1.conf}, config file to continue alanin folding another 10\\,ns, and\n\\item {\\tt load\\_all.vmd}, load all output into VMD and color by replica index.\n\\end{itemize}\n\nThe {\\tt fold\\_alanin.conf} config file contains the following settings:\n\\begin{verbatim}\nset num_replicas 8\nset min_temp 300\nset max_temp 600\nset steps_per_run 1000\nset num_runs 10000\n# num_runs should be divisible by runs_per_frame * frames_per_restart\nset runs_per_frame 10\nset frames_per_restart 10\nset namd_config_file \"alanin_base.namd\"\nset output_root \"output/%s/fold_alanin\" ; # directories must exist\n\n# the following used only by show_replicas.vmd\nset psf_file \"alanin.psf\"\nset initial_pdb_file \"unfolded.pdb\"\nset fit_pdb_file \"alanin.pdb\"\n\\end{verbatim}\n\n\\subsection{Random acceleration molecular dynamics simulations}\n\nThe \"lib/ramd\" directory stores the tcl scripts and the example files for the implementation of the Random Acceleration Molecular Dynamics (RAMD) simulation method in NAMD. \nThe RAMD method can be used to carry out molecular dynamics (MD) simulations with an additional randomly oriented acceleration applied to the center of mass of one group of atoms (referred below as \"ligand\") in the system. \nIt can, for example, be used to identify egress routes for a ligand from a buried protein binding site. \nSince its original implementation in the ARGOS (ref 1, 2) program, the method has been also implemented in AMBER 8 (ref 3), and CHARMM (ref 4). \nThe first implementation of RAMD in NAMD using a tcl script (available as supplementary material in ref 6) provided only limited functionality compared to the AMBER 8 implementation. \n\nIn the current implementation, the RAMD method can be performed in 2 flavors: (i) \"pure RAMD simulations\" in which the randomly-oriented acceleration is applied continuously, and (ii) \"combined RAMD-MD simulations\" in which RAMD steps alternate with standard MD steps. \nAdditional information is found in the README file in the \"lib/ramd\" directory. \nThe user is encouraged to carefully read this information before starting production runs.\n\nThe three required scripts are stored in \"lib/ramd/scripts\": (i) ramd--4.0.tcl defines the simulation parameters and passes them from the NAMD configuration file to the main script, (ii) \"ramd--4.0\\_script.tcl\" adds the randomly oriented force and performs all related computations, and  (iii) \"vectors.tcl\" was borrowed from VMD and defines the vector operations used.\n\nTwo examples for running the scripts are included in the directory \"lib/ramd/examples\".  \nThe user is encouraged to read the \"README.examples\" file provided in the same directory.\n\nIn order to turn RAMD on, the line \"source /path/to/your/files/ramd--4.0.tcl\" should be included in the NAMD configuration file. \nUnless the user decides to store the scripts at a different location, the path \n\"/path/to/your/files\" should point to the \"lib/ramd/scripts\" directory. \nOtherwise, the user should make sure that the directory \"/path/to/your/files\" stores all three scripts described above. \n\nThe specific RAMD simulation parameters to be provided in the NAMD configuration file (listed below) should be preceded by the keyword \"ramd\". \nThe default values for these parameters are only given as guidance. \nThey are likely not to be suitable for other systems than those the scripts were tested on. \n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{ramd debugLevel}{ Set debug level of RAMD} {\\tt integer value } {0} { Activates verbose output if set to an integer greater than 0. Should be used only for testing purposes because the very dense output is full of information only relevant for debugging.}\n\n\\NAMDCONFWDEF{ramd mdStart}{ Start RAMD-MD with MD or RAMD?} {{\\tt yes} or {\\tt no}} {{\\tt no}} { Specifies if combined RAMD-MD simulation starts with MD or RAMD steps; ignored if pure RAMD simulation is performed.  Should be set to \"yes\" if initial MD steps are desired.}\n\n\\item\n\\NAMDCONFWDEF{ramd ramdSteps} { Set number steps in RAMD block} {{\\tt positive integer}} {{\\tt 50}} {Specifies the number of steps in 1 RAMD block; the simulations are evaluated every 'ramdSteps' steps.} \n \n\\item\n\\NAMDCONFWDEF{ramd mdSteps} { Set number steps in MD block} {{\\tt positive integer}} {{\\tt 0}} {Specifies the number of steps in 1 standard MD block; in combined RAMD-MD simulations, the RAMD blocks are evaluated every 'ramdSteps', the MD blocks every 'mdSteps' steps. Default of 0 gives pure RAMD simulation.}\n\n\\item\n\\NAMDCONFWDEF{ramd accel} {Set acceleration energy} {{\\tt positive decimal}} {{\\tt 0.25}} {Specifies acceleration in kcal/mol*A*amu to be applied during RAMD step.}\n\n\\item\n\\NAMDCONFWDEF{ramd rMinRamd} {Set threshold for distance traveled RAMD} {{\\tt positive decimal}} {{\\tt 0.01}} {Specifies a threshold value for the distance in Angstroms traveled by the ligand in 1 RAMD block. In pure RAMD simulations the direction of the acceleration is changed if the ligand traveled less than 'rMinRamd' \\AA in the evaluated block. In combined RAMD-MD simulations, a switch from a RAMD block to a standard MD block is applied if the ligand traveled more than 'rMinRamd' \\AA in the evaluated block.}\n\n\\item\n\\NAMDCONF{ramd rMinMd} {Set threshold for distance traveled in MD} {{\\tt positive decimal}} {Specifies a threshold value for the distance, in Angstroms, traveled by accelerated atoms in 1 standard MD block.  In combined RAMD-MD simulations, a switch from a standard MD block to a RAMD block is applied according to the criteria described in the note below.  Required if 'mdStep' is not 0; ignored if 'mdSteps' is 0.}\n \n\\item\n\\NAMDCONFWDEF{ramd forceOutFreq}{Set frequency of RAMD forces output} {{\\tt positive integer}, Must be divisor of both {\\tt ramdSteps} and {\\tt mdSteps}} {{\\tt 0}} { Every 'forceOutFreq' steps, detailed output of forces will be written.} \n\n\\item\n\\NAMDCONFWDEF{ramd maxDist} {Set center of mass separation} {{\\tt positive decimal}} {{\\tt 50}} { Specifies the distance in Angstroms between the the centers of mass of the ligand and the protein when the simulation is stopped.}\n \n\\item\n\\NAMDCONFWDEF{ramd firstProtAtom} {First index of protein atom} {{\\tt positive integer}} {{\\tt 1}} { Specifies the index of the first protein atom.}\n \n\\item\n\\NAMDCONF{ramd lastProtAtom} {Last index of protein atom} {{\\tt positive atom}} { Specifies the index of the last protein atom. } \n\n\\item\n\\NAMDCONF{ramd firstRamdAtom}{ First index of ligand atom } {{\\tt positive integer}} {Specifies the index of the first ligand atom.}\n\n\\item\n\\NAMDCONF{ramd lastRamdAtom}{ Last index of ligand atom } {{\\tt positive integer}} {Specifies the index of the last ligand atom. }\n\n\\item\n\\NAMDCONFWDEF{ramd ramdSeed}{Set RAMD seed} {{\\tt positive integer}} {{\\tt 14253}} {Specifies seed for the random number generator for generation of acceleration directions. Change this parameter if you wish to run different trajectories with identical parameters.}\n\n\\end{itemize}\n\nNote: \nIn combined RAMD-MD simulations, RAMD blocks alternate with standard MD blocks ('ramdSteps' and 'mdSteps' input parameters). The switches between RAMD and MD blocks are decided based on the following parameters: (i) 'd' =  the distance between the protein and ligand centers of mass, (ii) 'dr' = the distance traveled by the ligand in 1 RAMD block, and (iii) 'dm' = the distance traveled by the ligand in 1 MD block. A switch from RAMD to MD is applied if 'dr' $>$ 'rRamdMin'. A switch from MD to RAMD is applied if: (i) 'dm' $<$ 'rMdMin' and 'd' $>$ 0 (acceleration direction is kept from previous RAMD block), (ii) if 'dm' $<$ 'rMdMin' and 'd' $<$ 0 (acceleration direction is changed), (iii) if 'dm' $>$ 'rMdMin' and 'd' $<$ 0 (acceleration direction is changed). In all other case, a switch is not applied.\n \n%References:\n%Luedemann, S.K., Lounnas, V. and R. C. Wade. How do Substrates Enter and Products Exit the Buried Active Site of Cytochrome P450cam ? 1. Random Expulsion Molecular Dynamics Investigation of Ligand Access Channels and Mechanisms. J Mol Biol, 303:797-811 (2000). \n%Winn,P., Luedemann, S.K., Gauges,R., Lounnas, V. and R. C. Wade. Comparison of the dynamics of substrate access channels in three cytochrome P450s reveals different opening mechanisms and a new functional role for a buried arginine PNAS, 99, 5361-5366 (2002). \n%Schleinkofer, K., Sudarko, Winn,P., Luedemann, S.K. and R. C. Wade. Do mammalian cytochrome P450s show multiple ligand access pathways and ligand channelling? EMBO Reports, 6, 584-589 (2005).\n%Carlsson, P., Burendahl, S., Nilsson, L. Unbinding of retinoic acid from the retinoic acid receptor by random expulsion molecular dynamics. Biophys. J. 91, 3151-3161 (2006).\n%Wang, T., Duan, Y. Chromophore channeling in the G-protein coupled receptor rhodopsin. J. Am. Chem. Soc. 129, 6970-6971 (2007).\n%Vashisth, H., Abrams, C.F. Ligand escape pathways and (un)binding free energy calculations for the hexameric insulin-phenol complex. Biophys. J. 95, 4193-4204 (2008).\n%Perakyla, M. Ligand unbinding pathways from the vitamin D receptor studied by molecular dynamics simulations. 38, 185-198 (2009).doi:10.1007/s00249-008-0369-x \n%Klvana, M. et al. Pathways and Mechanisms for Product Release in the Engineered Haloalkane Dehalogenases Explored Using Classical and Random Acceleration Molecular Dynamics Simulations  J. Mol. Biol. 392, 1339-1356 (2009).\n%Pavlova, M. et al. Redesigning dehalogenase access tunnels as a strategy for degrading an anthropogenic substrate Nature Chem. Biol. 5, 727-733 (2009).\n%Wang, T., Duan, Y. Ligand entry and exit pathways in the beta2-adrenergic receptor. J. Mol. Biol. 392, 1102-1115 (2009).\n\n\n\n", "meta": {"hexsha": "20b3d77d8967f749f0f0d6fe6cb56461aac6ef3c", "size": 31754, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "NAMD_2.12_Source/ug/ug_accel.tex", "max_stars_repo_name": "scottkwarren/config-db", "max_stars_repo_head_hexsha": "fb5c3da2465e5cff0ad30950493b11d452bd686b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-01-17T20:07:23.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-17T20:07:23.000Z", "max_issues_repo_path": "NAMD_2.12_Source/ug/ug_accel.tex", "max_issues_repo_name": "scottkwarren/config-db", "max_issues_repo_head_hexsha": "fb5c3da2465e5cff0ad30950493b11d452bd686b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NAMD_2.12_Source/ug/ug_accel.tex", "max_forks_repo_name": "scottkwarren/config-db", "max_forks_repo_head_hexsha": "fb5c3da2465e5cff0ad30950493b11d452bd686b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.6112084063, "max_line_length": 845, "alphanum_fraction": 0.768155193, "num_tokens": 8297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.44071533988970524}}
{"text": "\\chapter{Holographic Wilson loops}\n\nAs discussed in chapter \\ref{ch:WilsonLoops}, Wilson loops are important gauge invariant observables \nthat can play the role of order parameters of the different phases of the gauge theory.\n% Being non-local, there are also natural suggestions for their holographic dual.\nLet us describe the basic idea that lead to find the holographic dual of Wilson loops, \nin the context of AdS/CFT correspondence. We then summarize the results obtained for the Pilch-Warner supergravity.\n\n\n\\section{In the $AdS_5 \\times S^5$ background}\n\n\n\\subsection{Fundamental representation}\nIn the fundamental representation, the (Maldacena-)Wilson loop \\eqref{maldacenaWL}\ndescribes the phase of a trajectory of an external quark. \nA way to introduce the massive quark is to consider $\\mathcal{N}=4$ SYM theory with all the fields in the adjoint representation\nof $U(N+1)$ instead.\nThen, we break spontaneously the gauge group $U(N+1) \\rightarrow U(N) \\times U(1)$.\nIn this way, the off-diagonal states of the scalars that were in the adjoint of $U(N+1)$\nbecome fundamental quarks and anti-quarks in $U(N)$, \nwhich are massive due to the Higgs mechanism. \nThis is a useful picture because, in string theory, \nit is equivalent to separating one D-brane from the original stack of $N+1$ coincident D3-branes.\nThis produces excited open strings that stretch along the stack and the individual brane,\nwith the mass proportional to the separation distance. \nSince we consider probe quarks (non-dynamical), the brane must be infinitely far away from the stack.\nThe stretched strings not only source the gauge fields, but by pulling the $N$ branes, \nthey cause deformation on the branes that are described by the scalar fields in \\eqref{maldacenaWL}. \nThe details of the derivation can be found in the appendix of \\cite{Drukker:1999zq}.\n\nNow, let us consider the dual gravitational picture. \nThe stack gravitates and the near-horizon geometry is $AdS_5 \\times S^5$. \nThen the position of the single D-brane lays on the conformal boundary of $AdS_5$, i.e. $z\\rightarrow 0$, \nand sits at a point on $S^5$. \nThe probe particle moves on the single D-brane.\nThe Wilson loop operator is then dual to the partition function of fundamental strings in $AdS_5 \\times S^5$ \nwhose worldsheets end on the same curve $C$ that defines the Wilson loop at the boundary, \\cite{Maldacena:1998im}:\n\\begin{equation}\n W(C) = \\int_{C=\\partial \\Sigma} DX e^{-S_\\text{string}[X]}.\n\\end{equation}\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=11cm]{Images/WLcircle.pdf}\n\\end{center}\n\\caption{\\label{fig:WLcircle} Circular Wilson loop as the minimal worldsheet area $\\Sigma$ drawn by string ending in the contour $C$ at the boundary of $AdS_5$. }\n\\end{figure}\n\nIn the 't Hooft limit, which corresponds to classical supergravity limit,\nminimizing the bosonic string action is sufficient for the leading order, which is essentially the minimal worldsheet area.\n% \\begin{equation}\n%   W(C) \\sim e^{-\\sqrt{\\lambda} A}.\n% \\end{equation}\nNevertheless, the area is infinite in $AdS$, hence we must regularize it.\nFor example, the minimal surface that is dual to the circular Wilson loop in the fundamental representation\nis parametrized as\n\\begin{equation}\n z(r)=\\sqrt{R^2-r^2}, \\quad r\\in[0, R], \\quad \\phi\\in[0, 2\\pi].\n\\end{equation}\nThis result can be obtained either by minimizing the string Nambu-Goto action \\cite{Drukker:1999zq},\n% \\begin{equation}\n%  S_\\text{NG} = \\dfrac{\\sqrt{\\lambda}}{2\\pi} \\int d^2 \\sigma e^{\\Phi/2} \\sqrt{\\text{det}}\n% \\end{equation}\nor by exploiting the conformal symmetry, i.e. \nmapping the special conformal transformation of the straight line solution \\cite{Berenstein:1998ij}.\nThe induced worldsheet metric, that is the pullback of the background metric $g$ \\eqref{metricAdS} in polar coordinates for some $x^i$,\nis:\n\\begin{equation}\n ds^2 = \\dfrac{L^2}{z^2}\\left((1+z'^2) dr^2 + r^2 d\\phi^2 \\right).\n\\end{equation}\nThen the on-shell (Nambu-Goto) action gives:\n\\begin{eqnarray}\n S &=& T_\\text{F1} \\int \\sqrt{\\text{det} P[g]}\\\\\n   &=& \\dfrac{\\sqrt{\\lambda}}{2\\pi} \\int_0^{2\\pi} d\\phi \\int_{0}^{\\sqrt{R^2-\\epsilon^2}} dr \\dfrac{r}{z^2} \\sqrt{1+z'^2}\\\\\n   &=& \\sqrt{\\lambda} \\left(\\dfrac{R}{\\epsilon}-1 \\right). \\label{minimalAction}\n\\end{eqnarray}\nThe correct prescription to regularize the action is to set the boundary cut-off at $z=\\epsilon$,\nthen, we remove the perimeter divergence \\cite{Drukker:1999zq}. \nThis regularization scheme will be used for other cases of Wilson loop dual computations.\nThe finite remnant in \\eqref{minimalAction} matches with the leading order field theory result \\eqref{W1holographic}, i.e.\n\\begin{equation}\n W_1 = e^{\\sqrt{\\lambda}}, \n \\quad (N\\rightarrow \\infty \\quad \\text{and} \\quad \\lambda \\rightarrow \\infty).\n\\end{equation}\n\nIn order to compute the subleading correction \n% $\\sqrt{2/\\pi}\\:\\lambda^{-3/4}$ \nin \\eqref{W1holographic}, \nthe fermionic contribution must be taken into account. \nThe full string action to use would be the Green-Schwarz action.\nAlthough it is not fully known in curved background,\nits quadratic order is known \\cite{Cvetic:1999zs}, which suffices for 1-loop corrections. \nIts quartic order was also derived in \\cite{Wulff:2013kga}.\nMany efforts have been put into finding the subleading correction  \n\\cite{Kruczenski:2008zk, Kristjansen:2012nz, Bergamin:2015vxa, Forini:2015bgo, Faraggi:2016ekd, Forini:2017whz}\nbut no full matching has been achieved.\nThe ambiguity in the path integral measure hindered this computation.\n% A way to evade it was to use the ratio of Wilson loops, and then the matching was proved for the ratio when expanding for small angles \\cite{Forini:2017whz}.\n\n\\subsection{Higher rank representations}\n\nThe lesson from the fundamental Wilson loop suggests that \nthe string dual of rank-$k$ representations must be an object that carries $k$ units of the string charge.\nIntuitively, if we consider a Wilson loop wrapped $k$ times around the contour (the $k$-fundamental representation), \nwe would expect the worldsheet to puff up, due to repulsive charges from multiple coincident fundamental strings.\nWe see that the individual string action is no longer useful in this case. \nInstead, we can describe the new object in terms of D-branes with fundamental string charges dissolve in it. \n% The charges are the source of a worldvolume electric field in the DBI action (ref).\nThe worldvolume must also pinch off at the boundary of $AdS_5$, \nending along the curve defined by the Wilson loop, see figure \\ref{fig:WLcircle}.\nSupersymmetry will then guide us which D-brane configurations are allowed.\n\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=11cm]{Images/DbraneWL.pdf}\n\\end{center}\n\\caption{\\label{fig:DbraneWL} Circular Wilson loop of rank $k$ as a D-brane with $k$ string charges dissolved in it and the worldvolume ends in the contour $C$ at the boundary of $AdS_5$. }\n\\end{figure}\n\n\nMore generally, \\cite{Gomis:2006sb} related supersymmetric Wilson loops of any representation of the gauge group \nto a stack of bulk D3-branes or a stack of bulk D5-branes, see figure \\ref{fig:YoungTable}.\nThey proved the correspondence by explicitly integrating out the physics on the D-branes, \nwhich results to a half-BPS Wilson loop insertion in the desired representation in the $\\mathcal{N}=4$ SYM path integral.\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=7cm]{Images/YoungTable.png}\n\\end{center}\n\\caption{\\label{fig:YoungTable} A generic Young table, taken from \\cite{Gomis:2006sb}. \nRow $i$ corresponds to a D3-brane with $n_i$ fundamental string charge dissolved in it.\nColumn $j$ corresponds to a D5-brane with $m_j$ fundamental string charge dissolved in it.\nThus, for symmetric (one row) and antisymmetric (one column) representations,\ntheir rank $k$ corresponds to the string charges a D3-brane and a D5-brane contains.}\n\\end{figure}\n\nLet us focus on a single D3-brane and a single D5-brane.\nConsider first the line element for $AdS_5\\times S^5$ is this convenient form:\n\\begin{equation}\n    ds^2 = L^2 \\left( du^2 + \\cosh^2 u \\,d\\check{\\Omega}^2  + \\sinh^2 u \\, d\\Omega_2^2 \n  + d\\theta^2 + \\sin^2 \\theta \\, d\\Omega_4^2 \\right),\n\\end{equation}\nwhere $u\\geq 0$, and $\\pi \\geq \\theta \\geq 0 $. \n$d\\check{\\Omega}_n^2$ and $d\\Omega_n^2$ indicate the line element for $AdS_n$ and $S^n$, respectively.\n% and we use global coordinates to parametrize $AdS_2$ line element:\n% \\begin{equation}\n%  d\\check{\\Omega}^2 =d\\chi^2+\\sinh^2\\chi d\\varphi^2, \\quad \\chi\\geq 0, \\quad 2 \\pi \\geq \\varphi \\geq 0.\n% \\end{equation}\nUsing the supersymmetry condition\\footnote{\nMay be up to a sign depending on the conventions.}\n\\begin{equation}\\label{susyCondition}\n \\Gamma \\epsilon =  \\epsilon,\n\\end{equation}\nwhere $\\Gamma$ is the kappa symmetry\\footnote{\nIt is a fermionic local gauge symmetry that is present also in particles and strings. \nIts full definition can be found in Paper III.}\nprojector for the D-brane and $\\epsilon$ is the Killing spinor of the background geometry,\nwe can find the D-brane embeddings that preserve half of the original supersymmetries. \nNote that the supersymmetry condition, which gives first order differential equations,\nimply the D-brane equations of motions, which are of second order, up to some integration constants. \nThe list below shows the half-BPS D-brane embeddings with their worldvolume geometries\ninduced from the target space, and the worldvolume gauge fields $F$ \\cite{Yamaguchi:2006tq}:\n\\begin{eqnarray}\n \\text{D3-brane:} &\\quad& AdS_2 \\times S^2, \\quad u=\\text{constant}, \\quad \\theta = 0 \\\\\n\t\t  &\\quad& \\dfrac{1}{T_{F1}}F = L^2\\sqrt{1+\\kappa^2} e^0 e^1, \\quad \\kappa \\equiv \\sinh u \\\\\n \\text{D5-brane:} &\\quad& AdS_2 \\times S^4, \\quad u=0, \\quad \\theta = \\text{constant} \\\\\n \t\t  &\\quad& \\dfrac{1}{T_{F1}}F = L^2 \\cos \\theta e^0 e^1 \n\\end{eqnarray}\nwhere $e^0$ and $e^1$ are the vielbeins\\footnote{\nVielbeins are defined by $ds^2=\\eta_{mn} e^m e^n$, which is often referred as the \\emph{local frame}.\nIn terms of components: $e^m=e^m_M dx^M$, thus, we can relate them to the metric as $g_{MN} = \\eta_{mn} e^m_M e^n_M$.} \nof $d\\check{\\Omega}^2$. \nWe see that the D3-brane sits on a fixed point on the $S^5$, \nwhile the D5-brane sits on $S^4$ that is $\\theta$ angle away from the pole of $S^5$, see figure \\ref{fig:S5}.\n\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=4cm]{Images/S5.png}\n\\end{center}\n\\caption{\\label{fig:S5} $S^4$ that is $\\theta$ angle away from the pole of $S^5$. \nThe angle depends on the amount of string charges $k$ that D5-brane contains.}\n\\end{figure}\n\n\nThe dual counterparts of the symmetric/antisymmetric representation in the leading order 't Hooft limit\nare the on-shell action DBI \\eqref{DBI} + WZ \\eqref{WZ} of the D3-brane/D5-brane configuration aforementioned:\n\\begin{equation}\\label{WLDbrane}\n \\log W^{+}_k = - S_{D3}, \\quad \\log W^{-}_k = - S_{D5}.\n\\end{equation}\nMoreover, we must ensure the string charge $k$ constraint, which can be added as a Lagrange multiplier term to the D-brane action:\n\\begin{equation} \\label{stringChargeConstraint}\nS_k = - k  \\int_\\Sigma F \n\\quad \\Rightarrow \\quad  \nk = \\dfrac{1}{T_{F1}} \\dfrac{\\delta S_\\text{DBI}}{\\delta F} .\n\\end{equation}\nThe couplings in terms of $\\lambda$ and $N$ are:\n\\begin{equation}\n T_\\text{F1} = \\dfrac{\\sqrt{\\lambda}}{2\\pi L^2},\n \\quad\n%  T_\\text{D1} = \\dfrac{2N}{\\sqrt{\\lambda}},\n%  \\quad \n T_\\text{D3} = \\dfrac{N}{2\\pi^2 L^4},\n \\quad \n T_\\text{D5} = \\dfrac{N\\sqrt{\\lambda}}{8\\pi^4 L^6},\n\\end{equation}\nwhich are derived from \\eqref{couplingsTension} using \\eqref{couplings}.\n\nFinally, the regularized actions are \\cite{Drukker:2005kx, Yamaguchi:2006tq, Zarembo:2016bbk}: \n\\begin{eqnarray}\n S_\\text{D3} &=& - 2 N  (\\kappa\\sqrt{1+\\kappa^2}+\\mathop{\\mathrm{arcsinh}}\\kappa)\\\\\n S_\\text{D5} &=& - N \\frac{2\\sqrt{\\lambda }}{3\\pi}\\,\\sin^3\\theta,\n\\end{eqnarray}\nwith the $\\theta$ satisfying the string charge constraint \\eqref{stringChargeConstraint} that gives \\eqref{eqThetaAntisym}, i.e. \n\\begin{equation}\n \\theta -\\frac{1}{2}\\,\\sin 2\\theta =\\pi \\frac{k}{N}.\n\\end{equation}\nThus the latitude angle $\\theta$ depends on the amount of string charges $k$ dissolved in the D5-brane.\nIn conclusion, there is an exact agreement with \\eqref{solW+} and \\eqref{solW-}, according to \\eqref{WLDbrane}.\n\n\n\n\\section{In Pilch-Warner background}\n\nIn $\\mathcal{N}=2^*$ SYM on $S^4$, we took the decompactification limit for circular Wilson loops in order to have results on $\\mathbb{R}^4$.\nThis means that in the Pilch-Warner background, the contour is a straight line of length $l\\rightarrow \\infty$. \n\n\\subsection{Fundamental representation}\nThe minimal surface of a straight Wilson line is a wall,\nwith the worldsheet coordinates $(\\tau, \\sigma)$ induced from the Pilch-Warner geometry in the following way:\n\\begin{equation}\n \\tau = x^1, \\quad \\sigma = c.\n\\end{equation}\nThe regularized on-shell action was computed in \\cite{Buchel:2013id}, \nwhich agrees with the leading order result in \\eqref{WLFundN2}, that is:\n\\begin{equation}\\label{W1leading}\n \\log W_1 = \\sqrt{\\lambda} M \\frac{l}{2\\pi }, \\quad (l\\rightarrow \\infty).\n\\end{equation}\n\n\nThe goal of Paper V was to compute the loop corrections to the minimal surface \nby using string perturbation around the above classical solution.\nThere are two contributions, which turned out to be of equal weight in our case. \nThe first one comes from the dilaton coupling to the worldsheet curvature called the Fradkin-Tseytlin term \\cite{Fradkin:1983xs}:\n\\begin{equation}\n S_{FT}=\\dfrac{1}{4\\pi} \\int d^2\\sigma \\sqrt{h}  R^{(2)} \\Phi,\n\\end{equation}\nwhich is actually a bit controversial, \nwith some authors arguing it is not needed \\cite{GRISARU1988625, GRISARU1985116, Cvetic:1999zs}.\nBesides, it is zero for the familiar $AdS_5 \\times S^5$ background due to a vanishing dilaton. \n% explicitly break the conformal invariance of the classical world-sheet action\nThe other one comes from 1-loop stringy corrections, \nwhich are computed by expanding the Green-Schwarz action up to quadratic fluctuations \\cite{Cvetic:1999zs}.\nThese contribute as functional determinants, from generalizing the Gaussian integration formula \\eqref{GaussianIntegral} for the bosons,\nand the Grassmann integration for the fermions \\eqref{GrassmannIntegral}.\nThus the semiclassical partition function is schematically of the form\n\\begin{equation}\n W = e^{-S_\\text{cl}-S_\\text{FT}} \\dfrac{\\text{det} F}{\\sqrt{\\text{det} B}},\n\\end{equation}\nwhere $S_\\text{cl}$ is the classical on-shell action in \\eqref{W1leading}, \n$B$ and $F$ here just represent the bosonic and fermionic operators.\n% of Schroedinger type (second order differential operator), \n% of Dirac type ($2\\times2$ first order differential operator). \n\nSupersymmetry simplifies our problem by cancelling exactly \nthe sector of bosonic and fermionic operators that are asymptotically massless (far away from the boundary $\\sigma=1$).\nThe remaining sector is asymptotically massive, and the operators (after several manipulations) look enticingly similar:\n\\begin{equation}\\label{basicDirac}\n H_B=\\begin{pmatrix}\n  1+\\frac{A}{\\sigma }  & \\mathcal{L} \\\\ \n  \\mathcal{L}^\\dagger  & -1 \\\\ \n \\end{pmatrix},\\qquad \n  H_F=\\begin{pmatrix}\n  -1                   & \\mathcal{L} \\\\ \n  \\mathcal{L}^\\dagger  & 1+\\frac{A}{\\sigma }  \\\\ \n \\end{pmatrix},\n\\end{equation}\nwith\n\\begin{eqnarray}\\label{EuclideanLs}\n \\mathcal{L}&=&A\\sqrt{\\sigma ^2-1}\\,\\partial _\\sigma +\\frac{A\\left(2\\sigma ^2+1\\right)}{2\\sigma \\sqrt{\\sigma ^2-1}} ,\n\\nonumber \\\\\n \\mathcal{L}^\\dagger &=&-A\\sqrt{\\sigma ^2-1}\\,\\partial _\\sigma \n-\\frac{A\\left(4\\sigma ^2-1\\right)}{2\\sigma \\sqrt{\\sigma ^2-1}}\n+\\frac{2}{\\sqrt{\\sigma ^2-1}}\\,.\n\\end{eqnarray}\nThe final semiclassical partition function to compute is then:\n\\begin{equation}\\label{semiclassicalW}\n  W = e^{-S_\\text{cl}-S_\\text{FT}}\\dfrac{\\text{det}^2 (\\partial_\\tau-H_F)}{\\text{det}^2 (\\partial_\\tau-H_B)},\n\\end{equation}\n\n\nInstead of using the heat kernel technique or the Gelfand-Yaglom method, \nboth commonly used in the computation of functional determinants,\nwe used the phase-shift method from quantum mechanical scattering problems, see e.g. \\cite{PhysRevD.10.4130}.\nThe method requires the operators to be asymptotically free, hence it works for (semi-)infinite intervals.\nOur operators \\eqref{basicDirac} share the same asymptotics in large $\\sigma$, and they are defined in a semi-infinite interval $\\sigma>1$,\nso the method applies. Note that for $\\tau$ variable, we do a usual Fourier transformation. \nThe exponential of the ratio of the determinants of the operators in \\eqref{semiclassicalW}\ncan be written in terms of the phase-shift $\\delta(p)$ between the wave function and the asymptotic plane wave, \nsee figure \\ref{fig:potentialWavesPlot},\nwhich is\n\\begin{equation}\\label{deltaphases}    \n -2 \\, \\int_{0}^{\\infty }\\frac{dp}{2\\pi }\\,\\,\n \\frac{4 p }{9\\sqrt{\\frac{4}{9}\\,p^2+1}}\\,\\left(\n \\delta_F ^+(p)\n +\n\\delta_F ^-(p)\n-\\delta_B ^+(p)\n -\n\\delta_B^-(p)\n\\right) = -\\dfrac{1}{4},\n\\end{equation}\nwhere $\\pm$ distinguish the two eigenvectors (particles and holes) of the Dirac Hamiltonians \\eqref{basicDirac}.\nThe last equality is backed by our numerics.\nThus, together with the Fradkin-Tseytlin contribution, the total correction is $-1/2$. \nIn conclusion, we do have a perfect matching with the field theory result \\eqref{WLFundN2}.\n% up to the subleading order in strong coupling expansion.\nMoreover, the existence of Fradkin-Tseytlin term is necessary for this agreement.\n\n\n\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{Images/potentialWavesPlotBlack.pdf}\n\\end{center}\n\\caption{\\label{fig:potentialWavesPlot} Phase-shift $\\delta(p)$ of the wave function \nin the presence of a typical potential wall that many of our operators show, versus the free wave, \nfor certain momentum $p$. \n}\n\\end{figure}\n\n\n\\subsection{Symmetric representation}\nAs for higher rank Wilson loops, Paper III found the D3-brane embedding dual to \nthe straight Wilson line of length $l$ in symmetric representation, with the help of the supersymmetric condition \\eqref{susyCondition}. \nThe worldvolume metric is induced from the deformed $AdS$ part of \\eqref{metricPW} in string frame\\footnote{\nWe changed to mostly minus signature in order to follow Paper III.\nThe string metric $g$ and the Einstein metric $G$ are related by $g=e^{-\\frac{4 \\Phi }{D-2}} G$,\nwhere $\\Phi$ is the dilaton. \n}:\n\\begin{equation}\n ds^2 = \\dfrac{A M^2 L^2}{c^2-1}\\left(dx^2  - \\rho(c)^2 d\\Omega_2^2 \\right)\n\t-L^2\\left(\\dfrac{1}{A \\left(c^2-1\\right)^2} + \\dfrac{A M^2 \\rho'(c)^2}{c^2-1} \\right) dc^2,\n\\end{equation}\nwhere \n\\begin{equation}\n \\rho(c)= \\kappa \\, \\sqrt{c^2-1},\n\\end{equation}\nsince the deformed sphere shrinks to $\\theta=\\pi/2$ and $\\phi=0$.\nThe worldvolume gauge field is given by\n\\begin{equation}\n \\frac{1} {T_\\text{F1}} F (c)  = -\\dfrac{M L^2}{(c^2-1)^{3/2}} dx\\wedge dc.\n\\end{equation}\nAs expected, it also reduces to the analogous case in $AdS_5 \\times S^5$ close to the boundary. \n\nThe regularized on-shell action reduces to\n\\begin{equation}\n S_{D3} = - \\sqrt{\\lambda} k M \\dfrac{l}{2\\pi}.\n%  , \\quad (l \\rightarrow \\infty).\n\\end{equation}\nThis agrees with the matrix model result \\eqref{WsymPW} according to \\eqref{WLDbrane}, only in the low rank limit\n\\begin{equation}\n \\kappa \\ll M l.\n\\end{equation}\nFurthermore, for $k=1$, we recover the fundamental case \\eqref{W1leading}.\nWe can conclude that this D3-brane configuration cannot probe the entire matrix model region, \nand a full dual object is still to be understood.\n\nFor the antisymmetric case, it is technically challenging to find the D5-brane solution. \nSo far, we have not succeeded.\nWe do expect it though to match the leading order field theory result, \nbecause the matrix model result \\eqref{WantisymPW} is proportional to $Ml$, the same as in the D-brane action.\nIt would be definitely interesting to compute the subleading order to determine the phase-transitions observed. \n\n\n", "meta": {"hexsha": "7bd364442bdc354431585fadcd08b900d3934fcf", "size": 19877, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/HoloWL.tex", "max_stars_repo_name": "yixinyi/PhDThesis", "max_stars_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/HoloWL.tex", "max_issues_repo_name": "yixinyi/PhDThesis", "max_issues_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/HoloWL.tex", "max_forks_repo_name": "yixinyi/PhDThesis", "max_forks_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5846560847, "max_line_length": 189, "alphanum_fraction": 0.7420636917, "num_tokens": 6015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.4407153373374917}}
{"text": "\\section{Measure and Integration}\n\\subsection{Measure Spaces}\n  \\paragraph{1.}\n  \\begin{proof}\n    Put $B_1=A_1$ and $B_n=A_n\\setminus A_{n-1}$ for $n\\ge 2$. $(B_n)$ is a \n    sequence of disjoint measurable sets. By the\n    countable additivity of $\\mu$,\n    \\[\n      \\mu\\left(\\bigcup_{k=1}^\\infty B_k\\right)=\n      \\sum_{k=1}^\\infty\\mu(B_k)=\n      \\lim_{n\\to\\infty}\\sum_{k=1}^n\\mu(B_k)=\n      \\lim_{n\\to\\infty}\\mu\\left(\\bigcup_{k=1}^n B_k\\right).\n    \\]\n    Since $\\bigcup_{k=1}^n B_k=\\bigcup_{k=1}^n A_k$ for $k=1,\\dots,n,\\dots,\n    \\infty$, this implies $\\mu(\\bigcup A_k)=\\lim\\mu(\\bigcup_{k=1}^n A_k)$.\n  \\end{proof}\n  \n  \\paragraph{3.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) First,\n    \\[\n      0=\\mu(E_1\\bigtriangleup E_2)=\\mu(E_1\\setminus E_2\\cup E_2\\setminus E_1)=\n      \\mu(E_1\\setminus E_2)+\\mu(E_2\\setminus E_1).\n    \\]\n    Together with the nonnegativity of $\\mu$, we conclude that $\\mu(E_1\n    \\setminus E_2)=\\mu(E_2\\setminus E_1)=0$. Note that\n    \\[\n      \\mu(E_1\\cup E_2)=\\mu(E_1\\setminus E_2\\cup E_2)=\n      \\mu(E_1\\setminus E_2)+\\mu(E_2).\n    \\]\n    Hence, $\\mu(E_1\\cup E_2)=\\mu(E_2)$. Similarly, $\\mu(E_1\\cup E_2)=\\mu(E_1)$.\n    Thus, $\\mu(E_1)=\\mu(E_2)$.\\par\n    (b) Since $\\mu(E_1\\bigtriangleup E_2)=0$ and $E_2\\setminus E_1\\subset E_1\n    \\bigtriangleup E_2$, by the completeness of $\\mu$, $E_2\\setminus E_1\\in\n    \\mathcal{B}$. Similarly, $E_1\\setminus E_2\\in\\mathcal{B}$. In consequence,\n    $E_1\\cap E_2 = E_1\\setminus(E_1\\setminus E_2)\\in\\mcal{B}$ and, therefore,\n    $E_2=(E_1\\cap E_2)\\cup(E_2\\setminus E_1)\\in\\mcal{B}$.\n  \\end{proof}\n  \n  \\paragraph{7.}\n  \\begin{proof}\n    Let $\\mcal{B}_0$ be the collection of all sets $E=A\\cup B$ where $B\\in\n    \\mcal{B}$ and $A\\subset C$, $C\\in\\mcal{B}$, $\\mu C=0$. Clear that $\\mcal{B}\n    \\subset\\mcal{B}_0$. Now we show that it is a $\\sigma$-algebra. Since $X\\in\n    \\mcal{B}$, $X\\in\\mcal{B}_0$. Let $E_n=A_n\\cup B_n$ be a sequence of elements\n    of $\\mcal{B}_0$. Then, $\\bigcup E_n=(\\bigcup A_n)\\cup(\\bigcup B_n)$ also\n    belongs to $\\mcal{B}_0$ since $\\bigcup B_n\\in\\mcal{B}$ and $\\bigcup A_n\n    \\subset\\bigcup C_n$, which is a countable union of sets of measure zero. \n    Hence, $\\mcal{B}_0$ is closed under countable union. Now, let $E=A\\cup B\\in\n    \\mcal{B}_0$. Note that\n    \\[\n      E^c=A^c\\cap B^c=(C\\setminus A)\\cup(B^c\\setminus C),\n    \\]\n    where $C\\setminus A\\subset C$ and $B^c\\setminus C\\in\\mcal{B}$. Hence, \n    $\\mcal{B}_0$ is closed under complement. Thus, it is a $\\sigma$-algebra.\\par\n    We define $\\mu_0:\\mcal{B}_0\\to[0,\\infty]$ by $\\mu_0 E=\\mu_0(A\\cup B)=\\mu B$.\n    First, we show that it is well-defined, that is, if $E=A\\hp\\cup B\\hp$, then\n    $\\mu B=\\mu B\\hp$. Since $C\\in\\mcal{B}$ contains $A$, $(A\\cup B)\\setminus C\n    \\in\\mcal{B}$. Meanwhile, since $\\mu C=0$,\n    \\begin{equation}\n      \\label{eq:11.7-1}\n      \\mu B=\\mu((A\\cup B)\\setminus C)=\\mu(E\\setminus C).\n    \\end{equation}\n    Since $E\\setminus C\\subset E\\cup C\\hp$,\n    \\begin{equation}\n      \\label{eq:11.7-2}\n      \\mu(E\\setminus C)\\le \\mu(E\\cup C\\hp)=\\mu((A\\hp\\cup B\\hp)\\cup C\\hp)=\n      \\mu B\\hp,\n    \\end{equation}\n    where the measurability of $E\\cup C\\hp$ and the last equality both comes \n    from the fact that $A\\hp\\subset C\\hp\\in\\mcal{B}$ and $\\mu C\\hp=0$. Combine\n    \\eqref{eq:11.7-1} and \\eqref{eq:11.7-2} and we get $\\mu B\\le\\mu B\\hp$.\n    Interchanging the role of $A\\cup B$ and $A\\hp\\cup B\\hp$ yields $\\mu B\\ge\n    \\mu B\\hp$. Hence, $\\mu B=\\mu B\\hp$ and, in consequence, $\\mu_0$ is\n    well-defined. Meanwhile, clear that for $E\\in\\mcal{B}$, $\\mu E=\\mu_0 E$.\\par\n    Finally, we show that $\\mu_0$ is a measure. Clear that $\\mu_0$ is \n    nonnegative and $\\mu_0\\varnothing=0$. Let $\\langle E_n\\rangle\\subset\n    \\mcal{B}_0$ be a sequence of disjoint sets. Then\n    \\[\n      \\mu_0\\left(\\bigcup E_n\\right)=\n      \\mu_0\\left(\\bigcup A_n \\cup \\bigcup B_n\\right)=\n      \\mu\\left(\\bigcup B_n\\right)=\n      \\sum\\mu B_n=\n      \\sum\\mu_0 E_n.\n    \\]\n    Namely, $\\mu_0$ is countably additive. Thus, $\\mu_0$ is a measure.\n  \\end{proof}\n  \n  \\paragraph{9.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) First, we argue by contradiction to show that $\\mcal{R}$ and \n    $\\mcal{R}$. Assume that there exists some $E\\in\\mcal{R}\\cap\\mcal{R}\\hp$, \n    that is, $E\\in\\mcal{R}$ and $E^c\\in\\mcal{R}$. Then $X=E\\cup E^c\\in\n    \\mcal{R}$, which contradicts the assumption that $\\mcal{R}$ is not a \n    $\\sigma$-algebra. Thus, $\\mcal{R}\\cap\\mcal{R}\\hp=\\varnothing$.\\par\n    Clear that $\\mcal{R}\\cup\\mcal{R}\\hp$ is a $\\sigma$-algebra containing \n    $\\mcal{R}$. Hence, $\\mcal{R}\\cup\\mcal{R}\\hp\\supset\\mcal{B}$. Meanwhile, \n    since $\\mcal{B}=\\sigma(\\mcal{R})$, $\\mcal{R}\\cup\\mcal{R}\\hp\\subset\n    \\mcal{B}$. Thus, $\\mcal{R}\\cup\\mcal{R}\\hp=\\mcal{B}$.\\par\n    (b) Since $\\varnothing\\in\\mcal{R}$, $\\bar{\\mu}\\varnothing=\\mu\\varnothing\n    =0$. Meanwhile, clear that $\\bar{\\mu}$ is nonnegative. Let $(E_n)\\subset \n    \\mcal{B}$ be a sequence of disjoint sets. By part (a), each $E_n$ is either \n    an element of $\\mcal{R}$ or $\\mcal{R}\\hp$. If all $E_n\\in\\mcal{R}$, then by\n    the countable additivity of $\\mu$, $\\mu(\\bigcup E_n)=\\sum\\mu E_n$. Suppose \n    there exists some $E_n$ in $\\mcal{R}$ and some $E_m$ in $\\mcal{R}\\hp$. Let \n    $F_1$ and $F_2$ be the union of theses sets respectively. Since \n    $\\sigma$-ring is closed under union, $F_1\\in\\mcal{R}$, and since $(\\bigcup \n    E_m)^c=\\bigcap E_m^c$, $F_2\\in\\mcal{R\\hp}$. Hence, $F_1\\cup F_2\\in\\mcal{R}\n    \\hp$, otherwise, $F_2=(F_1\\cup F_2)\\setminus F_1$ would be an element of \n    $\\mcal{R}$. Therefore, $\\mu(\\bigcup E_n)=\\infty=\\sum\\mu E_n$. Thus, $\\bar{\n    \\mu}$ is a measure on $\\mcal{B}$.\\par\n    (c) Clear that $\\ubar{\\mu}$ is nonnegative and $\\ubar{\\mu}\\varnothing=0$.\n    Let $(E_n)\\subset\\mcal{B}$ be disjoint. Note that for $E\\in\\mcal{R}$, $\\mu \n    E=\\sup\\{\\mu A:\\,A\\subset E,A\\in\\mcal{R}\\}$. Hence, it suffices to show that\n    \\[\n      M=\\sup\\left\\{\\mu A:\\, A\\subset\\bigcup_n E_n,A\\in\\mcal{R}\\right\\}=\n      \\sum_n\\sup\\{\\mu A:\\, A\\subset E_n,A\\in\\mcal{R}\\}=\\sum_n M_n.\n    \\]\n    By definition, for all $\\vep>0$, there exists a sequence $(A_n)\\subset\n    \\mcal{R}$ such that $A_n\\subset E_n$ and $M_n<\\mu A_n+\\vep/2^n$. Put $A=\n    \\bigcup A_n$. Since $(A_n)$ are disjoint as $(E_n)$ are, \n    \\[\n      \\sum M_n < \\vep+\\sum\\mu A_n =\\vep+\\mu A.\n    \\]\n    Meanwhile, since $A\\subset\\bigcup E_n$ and $A\\in\\mcal{R}$, $\\mu A\\le M$. \n    Therefore, $\\sum M_n<\\vep+M$. Thus, $\\sum M_n\\le M$.\\par\n    For the converse, similarly, for every $\\vep>0$, there exists an $A\\in\n    \\mcal{R}$ such that $A\\subset\\bigcup E_n$ and $M-\\vep>\\mu A$. Put $A_n=E_n\n    \\cap A$. If $E_n\\in\\mcal{R}$, $A_n\\in\\mcal{R}$ by definition. If $E_n\\in\n    \\mcal{R}\\hp$, $A_n=A\\setminus E_n^c\\in\\mcal{R}$. Hence, $A_n\\in\\mcal{R}$\n    for each $n$. Thus,\n    \\[\n      M-\\vep<\\mu A=\\sum_n\\mu A_n\\le\\sum_n M_n,\n    \\]\n    implying that $M\\le \\sum M_n$. Therefore, $M=\\sum M_n$, i.e., $\\ubar{\\mu}$ \n    is countably additive. Thus, we conclude that $\\ubar{\\mu}$ is a measure on\n    $\\mcal{B}$.\\par\n    (d) Clear that $\\mu_\\beta$ is nonnegative and $\\mu_beta\\varnothing=0$. The\n    preceding discussion, \\textit{mutatis mutandis}, yields the countable \n    additivity.\n  \\end{proof}\n% end\n\\subsection{Measurable Functions}\n  \\paragraph{10.}\n  \\begin{proof}\n    For every integers $n$ and $k$, let\n    \\begin{align*}\n      &E_{n,k}=\\{x:\\, k2^{-n}\\le f(x)<(k+1)2^{-n}\\}, (k\\le 2^{2n})\\\\\n      &E_{n,2^{2n}+1}=\\{x:\\, f(x)\\ge(2^{2n}+1)2^{-n})\\},\\\\\n      &\\varphi_n=2^{-n}\\sum_{k=0}^{2^{2n}+1}k\\chi_{E_{n,k}}\n    \\end{align*}\n    Since $f$ is measurable, all $E_{n,k}$ are measurable. Thus, $\\langle\n    \\varphi_n\\rangle$ is a sequence of nonnegative simple functions. Clear that \n    for fixed $n$, $\\langle E_{n,k}\\rangle_k$ are disjoint. Let $x\\in X$ be \n    fixed. If $x\\in E_{n,k}$ for some $k\\le 2^{2n}$, then $x\\in E_{n+1,2k}\\cup\n    E_{n+1,2k+1}$. Hence, $\\varphi_{n+1}(x)\\ge 2k/2^{-(n+1)}=\\varphi_n(x)$. If\n    $x\\in E_{n,2^{2n}+1}$, then $x\\in E_{n+1,k\\hp}$ for some $k\\hp\\ge\n    2^{2n+2}$. Hence, $\\varphi_{n+1}(x)\\ge 2k/2^{-(n+1)}=\\varphi_n(x)$. Thus,\n    $\\varphi_{n+1}\\ge\\varphi_n$ for all $n$.\\par\n    Now, we show that $\\varphi_n$ converges to $f$ pointwisely. Let $x\\in X$ be\n    fixed. If $f(x)=\\infty$, then $\\varphi_n(x)=2^{-n}(2^{2n}+1)\\to\\infty$ as\n    $n\\to\\infty$. If $f(x)<\\infty$, then $f(x)<2^{N}$ for some integer $N$. \n    For all $n>N$, $x\\in E_{n,k_n}$ where $k_n=\\lfloor 2^nf(x)\\rfloor$. Thus,\n    \\[\n      f(x)-\\varphi_n(x)=f(x)-2^{-n}\\lfloor 2^nf(x)\\rfloor\\to 0\n    \\]\n    as $n\\to\\infty$. Namely, $\\varphi_n(x)\\to f(x)$.\\par\n    If the measure space is $\\sigma$-finite, then let $(X_n)\\subset X$ be a\n    sequence of measurable sets such that $X_n\\subset X_{n+1}$, $\\mu X_n<\n    \\infty$ and $X=\\bigcup X_n$. Replacing $E_{n,k}$ with $E_{n,k}\\cap X_n$ \n    yields a sequence $\\langle\\varphi_n\\rangle$ satisfying all previous \n    requirements and vanishing outside $X_n$ for each $n$.\n  \\end{proof}\n  \n  \\paragraph{11.}\n  \\begin{proof}\n    Put $F_\\alpha=\\{x:\\,f(x)\\le\\alpha\\}$, $G_\\alpha=\\{x:\\,g(x)\\le\\alpha\\}$, \n    $E=\\{x:\\,f(x)\\ne g(x)\\}$ and $E_\\alpha=\\{x\\in E: g(x)\\le\\alpha\\}$. Then\n    $G_\\alpha=(F_\\alpha\\setminus E)\\cup E_\\alpha$. Since $F$ is measurable, all\n    $F_\\alpha$ are measurable. Since $f=g$ a.e., $E$ is of measure zero. \n    Meanwhile, since $\\mu$ is complete, $E_\\alpha\\subset E$ is measurable. \n    Thus, $G_\\alpha$ is measurable. Namely, $g$ is measurable.\n  \\end{proof}\n  \n  \\paragraph{13.}\n  \\begin{proof}\n    Note that $f_n$ converges to $f$ in measure iff for every $\\vep>0$,\n    \\begin{equation*}\n      \\lim_{n\\to\\infty}\\mu\\{x\\in X:\\, |f_n(x)-f(x)|\\ge\\vep\\}=0.\n    \\end{equation*}\\par\n    (a) By definition, for every $\\vep_m=2^{-m}$, there exists some integer \n    $N_m$ such that for all $n\\ge N_m$, $\\mu\\{x:\\,|f_n(x)-f(x)|\\ge\\vep_m\\}<\n    \\vep_m$. Consider the subsequence $\\langle f_{N_m}\\rangle_m$. We show that\n    it converges to $f$ almost everywhere. Put $E_m=\\{x:\\,|f_{N_m}-f(x)|\\ge\n    \\vep_m\\}$ and $E=\\limsup E_m$. Then, for each $k$,\n    \\[\n      \\mu E\\le \\bigcup_{m=k}^\\infty E_m\\le \\sum_{m=k}^\\infty 2^{-m+1}\\to 0,\n      \\quad\\text{as}\\quad k\\to\\infty.\n    \\]\n    For every $x\\notin E$, $x\\notin\\bigcup_{m=k}^\\infty E_m$ for some $k$. Then\n    for all $m>k$, $|f_{N_m}(x)-f(x)|<\\vep_{N_m}$. Hence, $f_{N_m}(x)\\to f(x)$.\n    Namely, $f_{N_m}\\to f$ almost everywhere.\\par\n    (b) First we prove a lemma: Let $\\langle E_n\\rangle$ be a sequence of\n    measurable subset of $A$. Then $\\limsup\\mu E_n\\le \\mu(\\limsup E_n)$. Let\n    $F_N=\\bigcup_{n=N}^\\infty E_n$. Clear that $F_{n+1}\\subset F_n$ and $\\mu \n    F_1<\\infty$. Hence, by Prop. 2, \n    \\[\n      \\limsup\\mu E_n\\le \\lim\\mu F_n=\n      \\mu\\left(\\bigcap_{n=1}^\\infty F_n\\right)=\\mu(\\limsup E_n).\n    \\]\n    Thus, the lemma holds.\\par\n    For fixed $\\vep>0$, let $E_n=\\{x\\in A:\\, |f_n(x)-f(x)|\\ge\\vep\\}$. We\n    show that $\\lim\\mu E_n=0$. First, clear that $0\\le\\limsup\\mu E_n$. \n    Meanwhile, if $x\\in\\limsup E_n$, then $x$ belongs to infinitely many $E_n$.\n    As a consequence, $f_n$ does not converges to $f$ at $x$. Since $f_n$ \n    converges to $f$ a.e., $\\mu(\\limsup E_n)=0$. Note that all $E_n\\subset A$ \n    are of finite measure. Hence, by the preceding lemma, $\\limsup\\mu E_n\\le \n    0$. Thus, $\\lim\\mu E_n=0$. Let $F_n$ denote $\\{x\\in X:\\,|f_n(x)-f(x)|\\ge\n    \\vep\\}$ and $G$ the collection of points at which $f_n$ does not converge\n    to $f$. Since all $f_n$ vanishes outside $A$, for a point outside to belong\n    to $F_n$, it has to belong to $G$, a set of measure zero. Therefore, $E_n\n    \\subset F_n\\subset E_n\\cup G$, implying that $\\mu F_n=\\mu E_n$. Thus, $f_n$\n    converges to $f$ in measure.\\par\n    (c) By definition, for each positive integer $k$, there is an integer $N_k$ \n    such that for all $n,m\\ge N_k$, $\\mu\\{x\\in X:\\,|f_n(x)-f_m(x)|\\ge 2^{-k}\\}<\n    2^{-k}$. We may assume without loss of generality that $N_k$ is increasing.\n    Put $E_k=\\{x:\\, |f_{N_{k+1}}-f_{N_k}|\\ge 2^{-k}\\}$ and $E=\\limsup E_k$. By\n    our construction, $\\mu E=0$. For $x\\notin E$, $|f_{N_{k+1}}(x)-f_{N_k}(x))|\n    <2^{-k}$ for large $k$ and, therefore, the number series $\\sum(f_{N_{k+1}}\n    (x)-f_{N_k}(x))$ converges to some point, say, $g(x)$. Hence, $f_{N_k}$\n    converges to $f=f_{N_1}+g$ almost everywhere. Since all $f_{N_k}$ are\n    measurable, $f$ is measurable.\\par\n    Now we show that $f_n$ converges to $f$ in measure. Let $D$ be the set of\n    points at which $f_{N_k}$ does not converge to $f$. For every $\\vep>0$,\n    let $F_n=\\{x\\in X\\setminus D:\\, |f_n(x)-f(x)|\\ge\\vep\\}$. Note that for \n    all sufficiently large $N_k$,\n    \\begin{align*}\n      F_n\n      &\\subset\\{x\\in X\\setminus D:\\,|f_n(x)-f_{N_k}(x)|+|f_{N_k}(x)-f(x)|\n      \\ge\\vep \\}\\\\\n      &\\subset\\{x\\in X\\setminus D:\\,|f_n(x)-f_{N_k}(x)|\\ge\\vep/2\\},\n    \\end{align*}\n    where the measure of the last set can be less than $\\vep$ for sufficiently\n    large $n$ and $N_k$ as $\\langle f\\rangle$ is Cauchy in measure. Since $D$\n    is of measure zero, we conclude that $\\langle f_n\\rangle$ converges to $f$\n    in measure.\n  \\end{proof}\n  \n  \n  \\paragraph{16.}\n  \\begin{proof}\n    Egoroff: Let $(X,\\mcal{B},\\mu)$ be a measure space and $E\\subset X$ is of\n    finite measure. Let $\\langle f_n\\rangle$ be a sequence of measurable\n    functions which converge to some function $f$ a.e. on $E$. Then\n    for every $\\eta>0$, there is a subset $A\\subset E$ with $\\mu A<\\eta$ such\n    that $f_n$ converges to $f$ uniformly on $E\\setminus A$.\\par\n    We may assume without loss of generality that all $f_n$ vanish outside $E$.\n    Then, by Prob. 13(b), $f_n$ converges to $f$ in measure over $E$. Fix \n    $\\eta>0$. First, we construct $A$. Put $\\delta_m=\\delta/2^m$. For every \n    $m$, there exists some integer $N_m$ and a measurable set $A_m$ with $\\mu\n    A_m<\\delta_m$ such that for all $n>N_m$ and $x\\notin A_m$, $|f_n(x)-f(x)|<\n    \\delta_m$. Put $A=\\bigcup A_m$. Clear that $\\mu A<\\delta$.\\par\n    Now we show that $f_n$ converges to $f$ uniformly on $E\\setminus A$. Fix \n    $x\\in E\\setminus A$. For every $\\vep>0$, suppose there is an $m$ such that\n    $0<\\delta_m<\\vep$. For all $n>N_m$, since $x\\notin A$, $|f_n(x)-f(x)|<\n    \\delta_m<\\vep$. Thus, $f_n\\to f$ uniformly on $E\\setminus A$.\n  \\end{proof}\n% end\n\\subsection{Integration}\n  \\paragraph{19.}\n  \\begin{proof}\n    Since $|\\int_E f|\\le \\int_E|f|$, it suffices to show the result for\n    nonnegative $f$. Fix $\\vep>0$. By definition, there is a nonnegative simple\n    function $\\varphi=\\sum_{i=1}^n c_i\\chi_{E_i}$ such that $\\int f<\\int\n    \\varphi+\\vep/2$. Put $M=\\max_ic_i$ and $\\delta=\\vep/2Mn$. Then, for every\n    measurable $E$ with $\\mu E<\\delta$, we have\n    \\[\n      \\int_E f<\\int_E\\varphi+\\vep/2=\n      \\sum_{i=1}^nc_i\\mu(E_i\\cap E)+\\vep/2\\le\n      Mn\\delta+\\vep/2=\\vep.\n    \\]\n  \\end{proof}\n  \n  \\paragraph{20.}\n  \\begin{proof}\n    We show here Fatou's Lemma: Let $\\langle f_n\\rangle$ be a sequence of \n    nonnegative measurable functions which converges to a function $f$ in\n    measure on a measurable set $E$. Then $\\int_E f\\le\\lowlim\\int_E f_n$.\\par\n    Since the collection of limits point of $\\int_E f_n$ forms a closed set, \n    there exists a subsequence $\\langle f_{n_k}\\rangle_k$ such that $\\lim\\int_E\n    f_{n_k}=\\liminf\\int_E f_n$. Since $f_{n_k}$ also converges to $f$ in \n    measure, by Prob. 13(a), there is a subsequence $\\langle f_{n_{k_j}}\\rangle$\n    which converges to $f$ a.e. on $E$. Hence, by Theorem 10,\n    \\[\n      \\int_E f\\le \\liminf_j \\int_E f_{n_{k_j}}=\n      \\lim_j \\int_E f_{n_{k_j}}=\n      \\liminf_n\\int_E f_n.\n    \\]\n  \\end{proof}\n  \n  \\paragraph{21.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) We may assume without loss of generality that $f$ is nonnegative since \n    replacing $f$ by $|f|$ dose not change the integrability and the set $E=\n    \\{x:\\,f(x)\\ne 0\\}$. For every positive integer $n$, since $\\int f<\\infty$, \n    the set $E_n=\\{x:\\, f(x)\\ge 1/n\\}$ is of finite measure. Thus, $E=\n    \\bigcup_{n=1}^\\infty E_n$ is of $\\sigma$-finite measure.\\par\n    (b) It follows immediately from part (a) and Prop. 7.\\par\n    (c) If $f\\ge 0$, then the existence of such a $\\varphi$ comes directly from\n    the definition. For general cases, let $f=f^+-f^-$ and $\\varphi^+,\\varphi^-$\n    two simple functions such that\n    \\[\n      \\int|f^+-\\varphi^+|<\\vep/2\n      \\quad\\text{and}\\quad\n      \\int|f^--\\varphi^-|<\\vep/2.\n    \\]\n    Note that $\\varphi=\\varphi^+-\\varphi^-$ is also a simple function and\n    \\[\n      \\int|f-\\varphi|\\le\n      \\int|f^+-\\varphi^+|+\\int|f^--\\varphi^-|\n      <\\vep.\n    \\]\n  \\end{proof}\n  \n  \\paragraph{22.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) Clear that $\\nu$ is nonnegative and $\\nu\\varnothing=0$. Let $\\langle \n    E_n\\rangle$ be a sequence of disjoint measurable sets and $E=\\bigcup_n E_n$.\n    By Corollary 14, we have\n    \\[\n      \\nu E=\\int_E g\\rd\\mu=\n      \\int_E\\sum g\\chi_{E_n}\\rd\\mu=\n      \\sum\\int_E g\\chi_{E_n}\\rd\\mu=\n      \\sum\\int_{E_n}g\\rd\\mu=\n      \\sum\\nu E_n.\n    \\]\n    Thus, $\\nu$ is a measure.\\par\n    (b) First, we show the identity for an arbitrary simple function $\\varphi=\n    \\sum_{k=1}^n c_k\\chi_{E_k}$ where $E_k$ are disjoint.\n    \\[\n      \\int\\varphi\\rd\\nu=\n      \\sum_{k=1}^nc_k\\nu E_k=\n      \\sum_{k=1}^nc_k\\int g\\chi_{E_k}\\rd\\mu=\n      \\int \\varphi g\\rd\\mu.\n    \\]\\par\n    Let $f$ be a nonnegative measurable function and $\\langle\\varphi_n\\rangle$ a\n    increasing sequence of simple functions converging to $f$, the existence of\n    which is guaranteed by Prop. 7. Then, By the monotone convergence theorem,\n    \\[\n      \\int f\\rd\\nu=\\lim\\int\\varphi_n\\rd\\nu=\\lim\\int\\varphi_n g\\rd\\mu.\n    \\]\n    Note that $\\langle\\varphi_ng\\rangle$ is a increasing sequence of functions\n    converging to $fg$ and with $\\varphi_ng\\le fg$. Hence, again by the \n    monotone convergence theorem,\n    \\[\n      \\lim\\int\\varphi_n g\\rd\\mu=\\int fg\\rd\\mu.\n    \\]\n    Thus, $\\int f\\rd\\nu=\\int fg\\rd\\mu$.\n  \\end{proof}\n% end\n\\subsection{General Convergence Theorems}\n  \\paragraph{24.}\n  \\begin{proof}\n    Since $\\mu_n E$ is increasing for every $E$, such limits do exists. Clear \n    that $\\mu$ is nonnegative and $\\mu\\varnothing=0$. Let $\\langle E_k\\rangle$ \n    be a sequence of disjoint measurable sets. Then\n    \\[\n      \\mu\\left(\\bigcup_{k=1}^\\infty E_k\\right)=\n      \\lim_{n\\to\\infty}\\mu_n\\left(\\bigcup_{k=1}^n E_k\\right)=\n      \\lim_{n\\to\\infty}\\sum_{k=1}^\\infty\\mu_n(E_k).\n    \\]\n    Since for fixed $k$, $\\mu_n(E_k)\\le\\mu_{n+1}(E_k)$, it is valid to change \n    the order of the limit and the summation, which implies that $\\mu(\\bigcup\n    E_k)=\\sum\\mu E_k$. Thus, $\\mu$ is a measure.\n  \\end{proof}\n  % TODO: 11.26\n% end\n\\subsection{Signed Measures}\n  \\paragraph{27.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) Consider the usual Lebesgue measure on $\\mathbb{R}$. Let $A$ be any\n    countable subset of $\\mathbb{R}$ and $B=\\mathbb{R}\\setminus A$. Clear that\n    $A$ is negative set while $B$ is a positive set. Namely, $A$ and $B$ form a \n    Hahn decomposition of $\\mathbb{R}$ for $\\mu$.\\par\n    (b) Let $\\{A_1,B_1\\}$ and $\\{A_2,B_2\\}$ be two Hahn decomposition of $X$ \n    for $\\nu$ and $A_1$ and $A_2$ are two positive sets. We show that $A_1\n    \\bigtriangleup A_2$ is a null set. Since the roles of $A_1$ and $A_2$ are \n    interchangeable, it suffices to show that $A_1\\setminus A_2$ is a null set.\n    Since $A_1$ is positive, every subset $E\\subset A_1\\setminus A_2\\subset \n    A_1$ is of nonnegative measure. Meanwhile, $A_1\\setminus A_2$ is also \n    contained in $B_2$, a negative set. Hence, $\\nu E\\le 0$. Thus, $\\nu E=0$,\n    implying that $A_1\\bigtriangleup A_2$ is a null set.\n  \\end{proof}\n  \n  \\paragraph{28.}\n  \\begin{proof}\n    Let $\\nu=\\nu^+-\\nu^-$ be the Jordan decomposition of $\\nu$ and $A$ and $B$\n    be such that $X=A\\cup B$ and $\\nu^+(A)=\\nu^-(B)=0$. For every $E\\subset A$,\n    \\[\n      \\nu E=\\nu^+E-\\nu^-E=-\\nu^-E\\le 0.\n    \\]\n    Hence, $A$ is a negative set. Similarly, $B$ is positive set. Thus, $\\{A,\n    B\\}$ is a Hahn decomposition of $X$.\\par\n    Let $\\nu=\\nu_1+\\nu_2$ be another Jordan decomposition of $\\nu$ and $\\{C,\n    D\\}$ be the corresponding Hahn decomposition. By Prob. 27(b), $\\{A,B\\}$ and\n    $\\{C,D\\}$ only differ by two null sets. Thus, $\\nu_1=\\nu^+$ and $\\nu_2=\n    \\nu^-$. Namely, the decomposition is unique.\n  \\end{proof}\n  \n  \\paragraph{31.}\n  \\begin{proof}\n    Clear that\n    \\begin{align*}\n      \\left|\\int_E f\\rd\\nu\\right|\n      \\le \\left|\\int_E f\\rd\\nu^+\\right|+\\left|\\int_E f\\rd\\nu^-\\right|\n      \\le M\\nu^+E+M\\nu^-E=M|\\nu|(E).\n    \\end{align*}\n    Let $\\{A,B\\}$ be the corresponding Hahn decomposition of $X$ and $A$ is the\n    positive set. Then define $f$ by\n    \\[\n      f(x)=\\begin{cases}\n        1, & x\\in A,\\\\\n        -1, & x\\notin A.\n      \\end{cases}\n    \\]\n    Clear that $|f|\\le 1$ and\n    \\[\n      \\int_E f\\rd\\nu=\n      \\int_E f\\rd\\nu^+-\\int_E f\\rd\\nu^-=\n      \\mu^+(A\\cap E)+\\nu^-(A\\cap B)=\n      |\\nu|(E).\n    \\]\n  \\end{proof}\n  \n  \\paragraph{32.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) Put $\\mu\\wedge\\nu=\\frac{1}{2}(\\mu+\\nu-|\\mu-\\nu|)$, which can be \n    verified to be a measure. For every $E\\subset X$, suppose $\\mu E\\le\\nu E$. \n    Then\n    \\[\n      (\\mu\\wedge\\nu)(E)=\n      \\frac{1}{2}(\\mu E+\\nu E-|\\mu-\\nu|(E))=\n      \\frac{1}{2}(\\mu E+\\nu E-\\nu E+\\mu E)=\n      \\mu E.\n    \\]\n    Similarly, $(\\mu\\wedge\\nu)(E)=\\nu E$ if $\\nu E\\le\\mu E$. Hence, $\\mu\n    \\wedge\\nu$ is smaller than both $\\mu$ and $\\nu$. Note that $(\\mu\\wedge\\nu)\n    (E)=\\min\\{\\mu E, \\nu E\\}$. Thus, clear that it is larger than any other\n    signed measure smaller than $\\mu$ and $\\nu$.\\par\n    (b) Put $\\mu\\vee\\nu=\\frac{1}{2}(|\\mu-\\nu|+\\mu+\\nu)$. The previous argument,\n    \\textit{mutatis mutandis}, shows that $(\\mu\\vee\\nu)(E)=\\max\\{\\mu E,\\nu E\n    \\}$. Thus, it is the smallest measure larger than $\\mu$ and $\\nu$. \n    Meanwhile, clear that $\\mu\\wedge\\nu+\\mu\\vee\\nu=\\mu+\\nu$.\\par\n    (c) Suppose that $\\mu$ and $\\nu$ are mutually singular and let $\\{A,B\\}$\n    be such that $A\\cup B=X$ $\\mu A=\\nu B=0$. Then\n    \\[\n      (\\mu\\wedge\\nu)(E)\\le(\\mu\\wedge\\nu)(E\\cap A)+(\\mu\\wedge\\nu)(E\\cap B)\n      \\le\\mu A+\\nu B=0.\n    \\]\n    For the converse, suppose that $\\mu\\wedge\\nu=0$. If $\\mu=0$ or $\\nu=0$, \n    then $\\mu\\perp\\nu$ holds vacuously. Suppose that both $\\mu$ and $\\nu$ are\n    nonzero. Since the roles of $\\mu$ and $\\nu$ are interchangeable, we may\n    assume without loss of generality that $\\mu E=0$ and $\\nu E>0$ for some\n    measurable $E$. Then, $\\mu E^c\\ne 0$, forcing $\\nu E^c$ to be zero. \n    Therefore, $\\mu E=\\nu E^c=0$, implying that $\\mu\\perp\\nu$.\n  \\end{proof}\n% end\n\\subsection{The Radon-Nikodym Theorem}\n  \\paragraph{33.}\n  \\begin{proof}\n    Suppose $X=\\bigcup_{n=1}^\\infty X_i$ and $\\mu X_i<\\infty$ for each $n$\n    and $X_i$ are disjoint. Then both $\\mu|_{X_i}$ and $\\nu|_{X_i}$, the \n    restrictions to $X_i$, are finite. In consequence, by the Radon-Nikodym\n    theorem for finite measure, there is a nonnegative measurable function \n    $f_i:X_i\\to\\mathbb{R}$ such that $\\nu(E\\cap X_i)=\\int_{(E\\cap X_i)}\n    f_i\\rd\\mu$. Without loss of generality, we may consider $f_i$ to be a\n    function on $X$ (instead of $X_i$) that vanishes outside $X_i$.\\par\n    Put $f=\\sum f_i$. Since $X_i$ are disjoint and $f_i$ vanishes outside $X_i$,\n    the summation does make sense. Meanwhile, clear that $f$ is nonnegative and\n    measurable. Note that for each measurable $E$,\n    \\[\n      \\nu E=\\sum_{n=1}^\\infty\\nu(E\\cap X_i)=\n      \\sum_{n=1}^\\infty\\int_E f_i\\rd\\mu=\n      \\int_E f\\rd\\mu,\n    \\]\n    where the last equality comes from Corollary 14. Namely, $\\nu E=\\int_E \n    f\\rd\\mu$.\\par\n    Finally, we show that $f$ is unique up to almost equality. Let $g$ be a\n    nonnegative measurable function with this property. Then, $g|_{X_i}$, the\n    restriction of $g$ to $X_i$, equals to $f_i$ a.e. [$\\mu$]. Thus, $g=f$\n    a.e. [$\\mu$].\n  \\end{proof}\n  \n  \\paragraph{34. Radon-Nikodym derivatives}\n  \\begin{proof}\n    $\\,$\\par\n    (a) It suffices to show the result for simple functions. Let $\\varphi=\n    \\sum_{k=1}^nc_k\\chi_{E_k}$ be a simple function. Then\n    \\begin{equation*}\n      \\int \\varphi\\,\\rd\\nu=\\sum_{k=1}^nc_i\\nu E_k.\n    \\end{equation*}\n    Meanwhile,\n    \\[\n      \\int \\varphi\\left[\\frac{\\rd\\nu}{\\rd\\mu}\\right]\\,\\rd\\mu=\n      \\sum_{k=1}^n c_k\\int_{E_k}\\left[\\frac{\\rd\\nu}{\\rd\\mu}\\right]\\,\\rd\\mu=\n      \\sum_{k=1}^nc_i\\nu E_k.\n    \\]\n    Thus, $\\int\\varphi\\,\\rd\\nu=\\int\\varphi[\\rd\\nu/\\rd\\mu]\\rd\\mu$.\n  \\end{proof}\n  \n  \\paragraph{35.}\n  \\begin{proof}\n    $\\,$\\par\n    (d) Let $\\rho_0,\\rho_1$ be two measures with $\\rho_0\\perp\\mu$, $\\rho_1\\ll\n    \\mu$ and $\\nu=\\rho_0+\\rho_1$. We show that $\\rho_0=\\nu_0$ and $\\rho_1\n    =\\nu_1$. Since $\\nu_0\\perp\\mu$ and $\\rho_0\\perp\\mu$, there exists measurable\n    $A,B$ and $C,D$ such that $A\\cup B=C\\cup D=X$, $A\\cap B=C\\cap D=\\varnothing$\n    and $\\nu_0A=\\mu B=\\rho_0C=\\mu D=0$. Put $U=A\\cap C$ and $V=B\\cup D$. Note\n    that\n    \\begin{align*}\n      U\\cup V=(A\\cap C)\\cup(B\\cup D)=(A\\cup B\\cup D)\\cap(C\\cup B\\cup D)=X,\\\\\n      U\\cap V=(A\\cap C)\\cap(B\\cup D)=(A\\cap C\\cap B)\\cup(C\\cap B\\cap D)=\n      \\varnothing.\n    \\end{align*}\n    For every measurable $E$, if $E\\subset U$, then $\\nu_0E=\\rho_0E=0$ and\n    $(\\nu_0+\\nu_1)(E)=(\\rho_0+\\rho_1)(E)$ implies that $\\nu_1 E=\\rho_1 E$. \n    If $E\\subset V$, then $\\mu E=0$, implying that $\\nu_1E=\\rho_1E=0$ and,\n    therefore, $\\nu_0E=\\rho_0E$. Since $U$ and $V$ partitions $X$, this implies\n    that $\\nu_0=\\rho_0$ and $\\nu_1=\\rho_1$ for all measurable $E$. \n  \\end{proof}\n  \n  \\paragraph{36.}\n  \\begin{proof}\n    We show that: Let $(X,\\mcal{B},\\mu)$ be a $\\sigma$-finite signed measure\n    space, and let $\\nu$ be a signed measure on $\\mcal{B}$ with $\\nu\\ll\\mu$.\n    Then there is a measurable function such that for all measurable $E$ we have\n    $\\nu E=\\int_E f\\,\\rd\\mu$. Furthermore, the function $f$ is unique up to \n    almost equality with respect to $\\mu$.\\par\n    Let $\\mu=\\mu^+-\\mu^-$ and $\\nu=\\nu^+-\\nu^-$ be the Jordan decompositions.\n    Clear that $\\nu^+\\ll\\mu^+$ and $\\nu^-\\ll\\mu^-$. Hence, by the Radon-Nikodym\n    theorem for measures, there exists nonnegative $g$ and $h$ such that\n    \\[\n      \\nu^+E=\\int_E g\\,\\rd\\mu^+\n      \\quad\\text{and}\\quad\n      \\nu^-E=\\int_E h\\,\\rd\\mu^-\n    \\]\n    for all measurable $E$. Put $f=g-h$. Clear that it is measurable. Meanwhile,\n    \\[\n      \\nu E=\\nu^+E-\\nu^-E=\n      \\int_E g\\,\\rd\\mu^+-\\int_E h\\,\\rd\\mu^-=\n      \\int_E (g-h)\\,\\rd\\mu\n    \\]\n    where the last equality comes from the mutual singularity of $\\mu^+$ and\n    $\\mu^-$. And the argument in Prob. 33, \\textit{mutatis mutandis}, gives the\n    uniqueness.\n  \\end{proof}\n  \n  \\paragraph{40.}\n  \\begin{proof}\n    Let $I$ denote the index set of $\\{X_\\alpha\\}$ and, just for convenience,\n    let $\\sum_J$ denote $\\sum_{\\alpha\\in J}\\mu(E\\cap X_\\alpha)$.\\par\n    (a) First, we suppose that $E$ is of finite measure. Let $J$ be any finite\n    index subset of $I$. Then, since $X_\\alpha$ are disjoint, $\\mu E\\ge\\sum_J$. \n    Hence, $\\mu E\\ge\\sum_I$. For the converse, since, by our previous result, \n    all $\\sum_J$ are bounded by $\\mu E$, $\\sum_I$ is finite. For each positive\n    integer $n$, there is a finite subset $J_n$ of $I$ such that $\\sum_I-1/n<\n    \\sum_{J_n}$. Put\n    \\[\n      J=\\bigcup_{n=1}^\\infty J_n\n      \\quad\\text{and}\\quad\n      Y=\\bigcup_{\\beta\\in J}X_\\beta.\n    \\]\n    We show that (1) $\\mu(Y\\cap E)\\le\\sum_I$ and (2) $\\mu E=\\mu(Y\\cap E)$ to\n    complete the proof. Since $\\{X_\\beta\\}_{\\beta\\in J}$ is a countable \n    collection of disjoint sets,\n    \\[\n      \\mu(Y\\cap E)=\\sum_{\\beta\\in J}\\mu(X_\\beta\\cap E)\\le\n      \\sum_{\\alpha\\in I}\\mu(X_\\beta\\cap E).\n    \\]\n    Namely, (1) holds. To show (2), we first show that, for each $\\alpha\\in I$, \n    the set $X_\\alpha\\cap(E\\setminus Y)$ is of measure zero. Assume, to obtain\n    a contradiction, that there is some $\\alpha$ such that $\\mu(X_\\alpha\\cap(\n    E\\setminus Y))=\\delta>0$. Since\n    \\[\n      X_\\alpha\\cap(E\\setminus Y)=\n      X_\\alpha\\cap E\\cap\\left(\\bigcap_{\\beta\\in J}X_\\beta^c\\right),\n    \\]\n    this implies that $\\alpha\\notin J_n$ for all $n$ and $\\mu(X_\\alpha\\cap E)=\n    \\delta$. Since $\\delta>1/n$ for some large $n$, this leads to the \n    contradiction\n    \\[\n      \\sum_{J_n\\cup\\{\\alpha\\}}=\\sum_{J_n}+\\mu(X_\\alpha\\cap E)\n      >\\sum_I-\\frac{1}{n}+\\delta\\ge\\sum_I.\n    \\]\n    Hence, $\\mu(X_\\alpha\\cap(E\\setminus Y))=0$ for all $n$ and, therefore, \n    $\\mu(E\\setminus Y)=0$. Note that $E\\setminus(Y\\cap E)=E\\setminus Y$, this\n    implies that $\\mu(E\\setminus(Y\\cap E))=0$. In consequence, $\\mu E=\\mu(Y\\cap\n    E)$. Thus, $\\mu E\\le\\sum_I$.\\par\n    Now suppose $\\mu E=\\infty$. If all $\\sum_J$ are finite\n  \\end{proof}\n  \n  \\paragraph{40.}\n  \\begin{proof}\n    Let $I$ denote the index set of $\\{X_\\alpha\\}$. Fix a measurable $E$. Put\n    \\[\n      J=\\{\\alpha\\in I:\\,\\mu(E\\cap X_\\alpha)>0\\}\n      \\quad\\text{and}\\quad\n      Y=\\bigcup_{\\beta\\in J}X_\\beta.\n    \\]\n    First we show that $\\mu E=\\mu(E\\cap Y)$. Clear that $\\mu E\\ge\\mu(E\\cap Y)$.\n    For the converse, consider the set $E\\setminus(E\\cap Y)=E\\setminus Y$. For\n    every $X_\\alpha$, if $\\alpha\\notin J$, by the construction of $J$, $\\mu(\n    X_\\alpha\\cap(E\\setminus Y))=0$. If $\\alpha\\in J$, then\n    \\[\n      X_\\alpha\\cap(E\\setminus Y)=\n      X_\\alpha\\cap E\\cap\\left(\\bigcap_{\\beta\\in J}X_\\beta\\right)=\n      \\varnothing.\n    \\]\n    As a result, $\\mu(X_\\alpha\\cap(E\\setminus Y))=0$ for all $\\alpha\\in I$. \n    Since $\\{X_\\alpha\\}$ is a decomposition, this implies that $\\mu(E\\setminus \n    Y)=0$. Therefore, $\\mu E\\le \\mu(E\\cap Y)$. Thus, $\\mu E=\\mu(E\\cap Y)$.\\par\n    (a) For each positive integer $n$, put\n    \\[\n      J_n=\\{\\alpha\\in I:\\,\\mu(E\\cap X_\\alpha)>1/n\\}.\n    \\]\n    Clear that $J=\\bigcup_n J_n$. If $J$ is uncountable, then there must exist\n    some uncountable $J_n$, which implies that $\\mu E=\\sum\\mu(X_\\alpha\\cap E)=\n    \\infty$. If $J$ is countable, then\n    \\[\n      \\mu E=\\mu(E\\cap Y)=\\sum_{\\beta\\in J}\\mu(E\\cap X_\\beta)=\n      \\sum_{\\alpha\\in I}\\mu(E\\cap X_\\alpha).\n    \\]\n    Thus, $\\mu E=\\sum\\mu(E\\cap X_\\alpha)$.\n  \\end{proof}\n% end\n\\subsection{The $L^p$ Spaces}\n  \\paragraph{41.}\n  \\begin{proof}\n    First, we prove the following lemma: For $a,b\\ge 0$, $|a-b|^p\\le 2|a^p-\n    b^p|$. It suffices to show that $(a-b)^p\\le 2(a^p-b^p)$ for all $a\\ge b\\ge \n    0$. If $p=1$, then the inequality holds trivially. Suppose $p>1$ and put\n    $h(x)=(x-b)^p-2(x^p-b^p)$. Clear that $h(b)=0$. Meanwhile, for $x\\ge b$, \n    \\[\n      h\\hp(x)=p(x-b)^{p-1}-2px^{p-1}=px^{p-1}\n      \\left(\\left(1-\\frac{b}{x}\\right)^{p-1}-2\\right)<0.\n    \\]\n    Thus, $h(x)\\le 0$ for all $x\\ge b$, which implies that $|a-b|^p\\le 2|a^p-\n    b^p|$ for all $a,b\\ge 0$.\\par\n    Since $|f|^p$ is integrable, by Prob. 21(a), the set on which $f$ does not\n    vanish is of $\\sigma$-finite measure. Hence, $\\int|f|^p=\\sup\\int\\varphi$\n    as $\\varphi$ ranges over all simple functions that each vanishes outside a \n    set of finite measure. Thus, for every $\\vep>0$, there is a nonnegative \n    simple function $\\tilde{\\varphi}\\le|f|^p$, vanishing outside a set $E$ of \n    finite measure, such that $\\int(|f|^p-\\tilde{\\varphi})<\\vep^p/2$. Put \n    $\\varphi=\\sqrt[p]{\\tilde{\\varphi}}$, which is also a nonnegative simple \n    function that vanishes outside $E$. Meanwhile, by the previous inequality,\n    \\[\n      \\|f-\\varphi\\|_p^p=\n      \\int|f-\\varphi|^p\\le\n      2\\int(|f|^p-\\tilde{\\varphi})<\n      \\vep^p.\n    \\]\n    Namely, Prop. 26 holds.\n  \\end{proof}\n  \n  \\paragraph{42.}\n  \\begin{proof}\n    We may assume without loss of generality that $g$ is nonnegative. Assume, \n    to obtain a contradiction, that $\\esssup|g|>M$, that is, the measure of\n    $E=\\{t:\\,g(t)>M+\\eta\\}$ is nonzero for some positive $\\eta$. Meanwhile,\n    since $\\mu$ is finite, $\\mu E<\\infty$. Let $\\varphi=\\chi_E$, which is \n    clearly a simple function. Then\n    \\[\n      \\left|\\int g\\varphi\\right|\\ge\n      (M+\\eta)\\mu E>\n      M\\|\\varphi\\|_1.\n    \\]\n    Contradiction. Hence, $\\esssup|g|\\le M$, implying that $g\\in L^\\infty$.\n  \\end{proof}\n  \n  \\paragraph{43.}\n    The case $p=1$ is left undone. \n  \\begin{proof}\n    Suppose that $p>1$.\n    Let $\\langle X_n\\rangle$ be such that $\\mu X_n<\\infty$ and $X=\\bigcup X_n$.\n    Furthermore, we may assume without loss of generality that $X_n$ are \n    disjoint. Put $g_n=\\sum g\\chi_{X_n}$. By Lemma 27, for $n$, $g\\chi_{X_n}\\in \n    L^q$ and $\\|g_n\\|_q\\le M$. Since $g_n\\to g$, by Fatou's lemma, $\\|g\\|_q\\le\n    M$. Thus, $g\\in L^q$.\n  \\end{proof}\n  \n  \\paragraph{44.}\n  \\begin{proof}\n    Note that\n    \\[\n      \\int|f|^p=\\sum\\int|f|^p\\chi_{E_n}=\\sum\\int|f_n|^p=\\sum\\|f_n\\|^p.\n    \\]\n    Thus, $f\\in L^p$ iff $\\sum\\|f_n\\|^p<\\infty$.\n  \\end{proof}\n  \n  \\paragraph{45.}\n  \\begin{proof}\n    For every $f\\in L^p$ with $\\|f\\|_p=1$,\n    \\[\n      \\int|fg|\\le \\|f\\|_p\\|g\\|_q = \\|g\\|_q.\n    \\]\n    Hence, $\\|F\\|\\le\\|g\\|_q$. For the reverse inequality, put\n    \\[\n      f=(\\sgn g)|g|^{q-1}=(\\sgn g)|g|^{p/q}.\n    \\]\n    Note that $|f|^p=|g|^q$. Therefore, $g\\in L^q$ implies $f\\in L^q$. \n    Meanwhile, $\\|f\\|_p^p=\\|g\\|_q^q$. Hence, \n    \\[\n      \\|F\\|\\|f\\|_p \\ge |F(f)| = \\int|g|^q = \\|g\\|_q^q\n      \\quad\\Rightarrow\\quad\n      \\|F\\|\\ge\\|g\\|_q.\n    \\]\n    Thus, $\\|F\\|=\\|g\\|_q$.\n  \\end{proof}\n% end\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "cd599925fa9e01887739920c25ebd5979a3c1ccb", "size": 33061, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "real_analysis_3rd/ch11_measure_and_integration.tex", "max_stars_repo_name": "Engineev/solutions", "max_stars_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-07-13T08:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T17:37:17.000Z", "max_issues_repo_path": "real_analysis_3rd/ch11_measure_and_integration.tex", "max_issues_repo_name": "Engineev/solutions", "max_issues_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "real_analysis_3rd/ch11_measure_and_integration.tex", "max_forks_repo_name": "Engineev/solutions", "max_forks_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-28T00:05:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-28T00:05:28.000Z", "avg_line_length": 44.798102981, "max_line_length": 80, "alphanum_fraction": 0.5950515713, "num_tokens": 12990, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.44061000834244285}}
{"text": "\\section{MODULE DESIGN}\n\\subsection{DATA PREPROCESSING}\nJPEG uses a lossy image compression. Each re-encoding process (new saving) performed on the image leads to further loss of quality. The JPEG algorithm is based on a 8x8 pixel grid. Each 8x8 square grid is thereby treated and compressed separately. If the image is untouched, then all these 8x8 squares will show the same error level potential.  \n\\subsubsection{Algorithm:} \n\\begin{enumerate}\n    \\item The image is resaved with 95\\%(or 90\\%)JPEG quality.\n    \\item Compare each(8*8) blocks of corresponding original and new resaved image. \n\\item If image is unmodified, then all 8 x8 squares should have similar error potentials.\n\\item Else modified areas will appear with a higher potential error level.\n\\end{enumerate}\n\nINPUT \\ \\ \\ \\ : Tampered image\n\nOUTPUT : The output of ELA is image with higher error potential.\n\n\\subsection{TRAINING THE CNN}\n\\begin{figure}[htp]\n\\centering\n\\includegraphics[scale=0.5,width=17cm]{Figures/cnn.PNG}\n\\caption{Training the model}\n\\label{fig:universe}\n\\end{figure}\nThe training process of a CNN is done through an iterative algorithm that alternates between feedforward  and back propagation passes of the data. The weights of the convolutional filters and fully-connected layers are updated at each iteration of the backpropagation passes. CNN is capable of learning classification features directly from the data. The ReLU activation function is applied to each value in the feature maps of every convolutional layer. The convolutional layers are followed by the max pooling layers. We use a batch normalization layer after each regular convolutional layer. However, the prediction error convolutional filters outputs are directly convolved with the next convolutional layer without using the batch normalization layer. We consider the RMSProp optimizer  to train our model. This module is proposed to extract features related to the traces left by different editing operations, and which are utilized to check the authenticity of images. \n\nINPUT \\ \\ \\ \\ : The pre-processed images.\n\nOUTPUT : The trained classifier to detect the tampered images.\n\n\\subsubsection{Algorithm:}\n1. Initialize w_k 's\\  using \\ randomly\\  drawn\\  weights.\n    \n2. Assign i=1\n\n3. While  i \\leq  maximum\\_iteration \\ do\n\n4. Feedforward  pass.\n\n5. Update filter weights  and backpropagate errors.\n\n6. Set w_k(0, 0)^(^1^) = 0  for \\ all \\ K \\ filters\n\n7. Normalize w_k^(^1^)  ’s \\ such \\ that \\  \\Sigma_l_,_m_ \\neq _0 w_k^(^1^)   (l, m) = 1\n\n8. Set w_k(0, 0)^(^1^) = - 1  \\ for \\ all \\  K \\ filters\n\n9. i = i + 1\n\n10. If training accuracy converges then\n\n11. exit\n\n12. end\n\\newpage\n\\subsubsection{RMSPROP OPTIMISER }\nThe RMSprop optimizer is similar to the gradient descent algorithm with momentum. The RMSprop optimizer restricts the oscillations in the vertical direction. Therefore, we can increase our learning rate and our algorithm could take larger steps in the horizontal direction converging faster. \n\n              vdw =\\beta. vdw  + (1- \\beta).dw2  \n                 \n                     where  \\beta \\ is \\ a \\ momentum \\ in \\ learning \\ rate \n              \n              vdb  = \\beta. vdw  + (1- \\beta).db2\n              \n              W = W -\\alpha dw/(\\sqrt(v\\_db )+∈)      \n                     \n                     where W are weights to be updated during the back propagation and  \\alpha \\ is \\ a \\ value \\  always \\textless 1.      \n               \n              b = b - \\alpha dw/(\\sqrt(v\\_db )+\\epsilon)     \n              \n                     where b is the calculated gradient of the system while learning and \\epsilon \\  is\\ a \\ small \\ value \\  added \\ to \\ prevent \\ gradient \\ from \\ blowing \\ up.\n\n\\subsubsection{CROSS ENTROPY LOSS FUNCTION}\nCross Entropy is commonly-used in binary classification (labels are assumed to take values 0 or 1) as a loss function (For multi-classification, use Multiclass Cross Entropy), which is computed by  \n\n       L=-1/n \\Sigma_(i_=_1)^n [\\ (\\ y^(^i^)  log(\\ \\^y^i)\\ +(\\ 1-y^i)log(\\ 1-\\^y^i) ]\\\n\nWhere L is a loss calculated which is the difference between the actual and the predicted output. \nCross entropy measures the divergence between two probability distribution, if the cross entropy is large, which means that the difference between two distribution is large, while if the cross entropy is small, which means that two distribution is similar to each other. When the difference between predicted value and actual value is large, the learning speed, i.e., convergence speed, is fast, otherwise, the difference is small, the learning speed is small. Cross entropy cost function has the advantages of fast convergence and is more likely to reach the global optimization. \n\n\\subsection{CLASSIFICATION BLOCK}\n\\begin{figure}[htp]\n\\centering\n\\includegraphics[scale=0.5,width=10cm]{Figures/soft.PNG}\n\\caption{Classification}\n\\label{fig:universe}\n\\end{figure}\nThis first layer of the classification block contains about 256 nodes and accepts input as vectors. This layer uses ReLU activation function where negative values will not be considered significant hence makes it more efficient. To give the accurate result the last layer in the classification block of the neural network uses the softmax activation function which gives the highest activation level. The CNN model extracts the feature and classifies the pre-processed forged image to detect whether the given image is spiced or not.\n\n\\subsection{COPY MOVE TYPE DETECTION}\nA copy move attack is commonly used to conceal parts of an image or to remove unwanted portions in an image. A portion from the picture is copied and pasted over any unwanted portion in the same image.\nThis block is where the image that is not detected to be spliced is checked for copy move forgery using the following steps:\n\\begin{enumerate}\n    \\item Blur image for eliminating image details.\n    \n\\item Convert image to degraded palette.\n\n\\item Decompose the image into small NxN pixel blocks.\n\n\\item Alphabetically order these blocks by their pixel values.\n\n\\item Extract only these adjacent blocks which have small absolute color difference.\n\n\\item Cluster these blocks into clusters by intersection area among blocks.\n\n\\item Extract only these clusters which are bigger than block size.\n\n\\item Extract only these clusters which have similar cluster, by using some sort of similarity function (in this case Hausdorff distance between clusters).\n\n\\item Draw discovered similar clusters on image.\n\n\\end{enumerate}\n\n\n\\section{COMPLEXITY ANALYSIS}\n\\subsection{COMPLEXITY OF THE PROJECT}\n\\begin{itemize}\n    \\item  The complexity of the project lies in determining the passive type of forgery the image has undergone  rather than just determining if the image is only forged or not. The neural network is used to detect the spliced images.\n    \\item The accuracy of the neural network also affects the efﬁciency of the output. Hence efficient loss function and optimiser with the appropriate parameters needs to be chosen. \n    \\item Certain additional hints need to be added to the images in order to efficiently detect the tampered regions in the images. Error Level Analysis is used for this purpose. This analysis is made to all images irrespective of their formats and error potential.  \n    \\item Determining the identical regions in a copy move image is done by the extraction of similar properties between those regions for which efficient similarity functions has to be used. \n    \\item The identification of copy move image is done without any comparison with the original image but rather the input image itself which makes it a tedious task to implement.\n\\end{itemize}", "meta": {"hexsha": "cf1a8fcd355a2fc3eb90b535cd7bb28bbc5077d4", "size": 7648, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "samples/thesis/sample/Chapters/Chapter4.tex", "max_stars_repo_name": "sbenstewart/cantina-plus", "max_stars_repo_head_hexsha": "5cb08a712936694d2106c987912ac8ad1128cfe9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "samples/thesis/sample/Chapters/Chapter4.tex", "max_issues_repo_name": "sbenstewart/cantina-plus", "max_issues_repo_head_hexsha": "5cb08a712936694d2106c987912ac8ad1128cfe9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "samples/thesis/sample/Chapters/Chapter4.tex", "max_forks_repo_name": "sbenstewart/cantina-plus", "max_forks_repo_head_hexsha": "5cb08a712936694d2106c987912ac8ad1128cfe9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.2066115702, "max_line_length": 976, "alphanum_fraction": 0.750915272, "num_tokens": 1745, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4406099943510988}}
{"text": "%!TEX root = ../main.tex\n%-------------------------------------------------------------------------------\n\\section{Example}\\label{Example}\n%-------------------------------------------------------------------------------\nWe now present an exemplifying analysis of a canonical EKW model on human capital investment. The model was initially studied in \\citet{Keane.1997} to explore the career decisions of young men about their schooling, work, and occupational choice. We first outline the basic setup of the model, provide some descriptive statistics of the empirical data used for its calibration, and then explore selected economic insights.\n%-------------------------------------------------------------------------------\n\\subsection{Basic setup}\n%-------------------------------------------------------------------------------\nWe follow individuals over their working life from young adulthood at age 16 to retirement at age 65 where the decision period $t = 16, \\dots, 65$  is a school year. \\autoref{Decision tree} %\n%\\comment[id=HG]{I would use different colors in \\autoref{Decision tree}: white background for ``white-collar jobs'' and brown for ``military''.}\nillustrates the initial decision problem as individuals decide $a\\in\\mathcal{A}$ whether to work in a blue-collar or white-collar occupation ($a = 1, 2$), to serve in the military $(a = 3)$, to attend school $(a = 4)$, or to stay at home $(a = 5)$.\n\n%\n\\begin{figure}[t!]\\centering\n\t\\scalebox{0.75}{%\n\t\t%\\input{../material/fig-decision-tree-bw}%\n\t\t\\input{../material/fig-decision-tree-bw}%\n\t}\n\t\\caption{Decision tree}\n\t\\label{Decision tree}\n\\end{figure}%\\FloatBarrier%\\vspace{1.0cm}\n%\n\nIndividuals are already heterogeneous when entering the model. They differ with respect to their level of completed schooling $h_{16}$ and have one of four different $\\mathcal{J} = \\{1, \\hdots, 4\\}$ alternative-specific skill endowments $\\bm{e} = \\left(e_{j,a}\\right)_{\\mathcal{J} \\times \\mathcal{A}}$.\n\nThe immediate utility $u(\\cdot)$ of each alternative consists of a non-pecuniary utility $\\zeta_a(\\cdot)$ and, at least for the working alternatives, an additional wage component $w_a(\\cdot)$. Both depend on the level of human capital as measured by their occupation-specific work experience $\\bm{k}_t = \\left(k_{a,t}\\right)_{a\\in\\{1, 2, 3\\}}$, years of completed schooling $h_t$, and alternative-specific skill endowment $\\bm{e}$. The immediate utilities are influenced by last-period choices $a_{t -1}$ and alternative-specific productivity shocks $\\bm{\\epsilon_t} = \\left(\\epsilon_{a,t}\\right)_{a\\in\\mathcal{A}}$ as well. Their general form is given by:\n\n%\n\\begin{align*}\nu(\\cdot) =\n\\begin{cases}\n    \\zeta_a(\\bm{k}_t, h_t, t, a_{t -1})  + w_a(\\bm{k}_t, h_t, t, a_{t -1}, e_{j, a}, \\epsilon_{a,t})\n    & \\text{if}\\quad a \\in \\{1, 2, 3\\}  \\\\\n    \\zeta_a(\\bm{k}_t, h_t, t, a_{t-1}, e_{j,a}, \\epsilon_{a,t})\n    & \\text{if}\\quad a \\in \\{4, 5\\}\n\\end{cases}.\n\\end{align*}\n%\n\\noindent Work experience $\\bm{k}_t$  and years of completed schooling $h_t$ evolve deterministically.\n%\n\\begin{align*}\nk_{a,t+1} & = k_{a,t} + \\ind[a_t = a] \\quad \\text{if}\\quad a \\in \\{1, 2, 3\\} \\\\\nh_{t + 1\\phantom{,a}} & = h_{t\\phantom{,a}} +   \\ind[a_t = 4].\n\\end{align*}\n%\nThe productivity shocks $\\bm{\\epsilon}_t$ are uncorrelated across time and follow a multivariate normal distribution with mean $\\bm{0}$ and covariance matrix $\\bm{\\Sigma}$. Given the structure of the utility functions and the distribution of the shocks, the state at time $t$ is $s_t = \\{\\bm{k}_t, h_t, t, a_{t -1}, \\bm{e},\\bm{\\epsilon}_t\\}$.\n\nTheoretical and empirical research from specialized disciplines within economics informs the specification of each $u_a(\\cdot)$ and we discuss the exact functional form of the per-period utility in the blue-collar occupation as an example.\\footnote{All additional details are available in Appendix \\ref{Computational implementation}.}\n\n\nEquation~\\eqref{Non-pecuniary benefits} shows the parameterization of the non-pecuniary utility from working in a blue-collar occupation:\n%\n\\begin{align}\\label{Non-pecuniary benefits}\n\\zeta_{1}(\\bm{k}_t, h_t, a_{t-1})  = \\alpha_1  &+ c_{1,1} \\cdot \\ind[a_{t-1} \\neq 1] + c_{1,2} \\cdot \\ind[k_{1,t} = 0] \\\\ \\nonumber\n                            & + \\vartheta_1 \\cdot \\ind[h_t \\geq 12] + \\vartheta_2 \\cdot \\ind[h_t \\geq 16] + \\vartheta_3 \\cdot \\ind[k_{3,t} = 1].\n\\end{align}\n%\nIt includes job amenities $\\alpha_1$ and mobility and search costs $(c_{1,1}, c_{1,2})$ that capture the extra effort for individuals who only recently started working in a blue-collar occupation. Additional components depend on whether an individual has a high school $\\vartheta_1$ or college $\\vartheta_2$ degree. There is a detrimental impact of leaving the military after a single year $\\vartheta_3$.\n\nThe wage component $w_{1}(\\cdot)$ is given by the product of the market-equilibrium rental price $r_{1}$ and an occupation-specific skill level $x_{1}(\\cdot)$. The latter is determined by the overall level of human capital. This specification leads to a standard logarithmic wage equation in which the constant term is the skill rental price $\\ln(r_{1})$ and wages follow a log-normal distribution.\n\nThe occupation-specific skill level $x_{1}(\\cdot)$ is determined by a skill production function, which includes a deterministic component $\\Gamma_1(\\cdot)$ and a multiplicative stochastic productivity shock $\\epsilon_{1,t}$:\n%\n\\begin{align}\n    x_{1}(\\bm{k}_t, h_t, t, a_{t-1}, e_{j, 1}, \\epsilon_{1,t}) & = \\exp \\big( \\Gamma_{1}(\\bm{k}_t,  h_t, t, a_{t-1}, e_{j,1}) \\cdot \\epsilon_{1,t} \\big). \\nonumber\n\\end{align}\n%\n\\noindent Equation (\\ref{Skill production function}) shows the parameterization of the deterministic component of the skill production function:\n%\n\\begin{align}\\label{Skill production function}\n    \\Gamma_1(\\bm{k}_t, h_t, t, a_{t-1}, e_{j, 1}) = e_{j,1} & + \\beta_{1,1} \\cdot h_t + \\beta_{1, 2} \\cdot \\ind[h_t \\geq 12]   \\\\ \\nonumber\n                                  & + \\gamma_{1, 1} \\cdot  k_{1,t} + \\gamma_{1,2} \\cdot  (k_{1,t})^2  \\\\ \\nonumber\n                                & + \\gamma_{1,3} \\cdot  \\ind[k_{1,t} > 0] + \\gamma_{1,4} \\cdot  t + \\gamma_{1,5} \\cdot \\ind[t < 18]\\\\\n                                  & + \\gamma_{1,6} \\cdot \\ind[a_{t-1} = 1] + \\gamma_{1,7} \\cdot  k_{2,t} + \\gamma_{1,8} \\cdot  k_{3,t}. \\nonumber\n\\end{align}\n\n\\noindent There are several notable features. Skills increase with schooling $\\beta_{1,1}$ and blue-collar work experience ($\\gamma_{1,1}, \\gamma_{1,2}$). There are so-called sheep-skin effects \\citep{Hungerford.1987, Jaeger.1996} associated with completing a high school $\\beta_{1,2}$ and graduate $\\beta_{1,3}$ education that capture the impact of completing a degree beyond just the associated years of schooling. Also, there is a first-year blue-collar experience effect $\\gamma_{1,3}$ while skills depreciate when not employed in a blue-collar occupation in the preceding period $\\gamma_{1,6}$. Other work experience ($\\gamma_{1,7}, \\gamma_{1,8}$) is transferable.\n%-------------------------------------------------------------------------------\n\\subsection{Empirical data}\n%-------------------------------------------------------------------------------\nWe analyze the original dataset used by \\citet{Keane.1997} and thus only provide a brief description here.\\footnote{We provide additional details in Appendix \\ref{Empirical data}.} The authors construct their sample based on the National Longitudinal Survey of Youth 1979 (NLSY79) \\citep{NLSY.2019}. The NLSY79 is a nationally representative sample of young men and women living in the United States in 1979 and born between 1957 and 1964. Individuals were followed from 1979 onwards and repeatedly interviewed about their schooling decisions and labor market experiences. Based on this information, individuals are assigned to either working in one of the three occupations, attending school, or simply staying at home.\n\n\\citet{Keane.1997} restrict attention to white males that turn 16 between 1977 and 1981 and exploit the information collected between 1979 and 1987. Thus individuals in the sample are all between 16 and 26 years old. While the sample initially consists of 1,373 individuals at age 16, this number drops to 256 at the age of 26 due to sample attrition, missing data, and the short observation period. Overall, the final sample consists of 12,359 person-period observations.\n\n\\autoref{Overview} summarizes our information about choices and wages by age. We show the distribution of choices on the left, and report average wages on the right. Initially, roughly 86\\% of individuals enroll in school, but this share steadily declines with age. Nevertheless, about 39\\% obtain more than a high school degree and continue their schooling for more than twelve years. As individuals leave school, most of them initially pursue a blue-collar occupation. But the relative share of the white-collar occupation increases as individuals entering the labor market later have higher levels of schooling. At age 26, about 48\\% work in a blue-collar occupation and 34\\% in a white-collar occupation. The share of individuals in the military peaks around age 20 when it amounts to 8\\%. At its maximum around age 18, approximately 20\\% of individuals stay at home.\n\n%\n\\begin{figure}[t!]\\centering\n\\caption{Data overview}\\label{Overview}\n\\subfloat[Choices]{\\scalebox{0.19}{\\includegraphics{fig-data-choice-all-bw}}}\\hspace{0.3cm}\n\\subfloat[Average wage]{\\scalebox{0.19}{\\includegraphics{fig-data-wage-occupations-bw}}}\n\\begin{center}\n\\begin{minipage}[t]{0.8\\columnwidth}\n\\item \\scriptsize{\\textbf{Notes:} The wage is a full-time equivalent deflated by the gross national product deflator, with 1987 as the base year. We do not report the wage if less than ten observations are available.}\n\\end{minipage}\n\\end{center}\n\\end{figure}%\\FloatBarrier\n%\n\nOverall, average wages start at about \\$10,000 at age 16 but increase considerably up to about \\$25,000 at age 26. While wages in the blue-collar occupation are initially highest with about \\$10,286, wages in the white-collar occupation and military start around \\$9,000. However, wages in the white-collar occupation increase steeper over time and overtake blue-collar wages around age 21. At the end of the observation period, wages in the white-collar occupation are about 50\\% higher than blue-collar wages with \\$32,756 as opposed to only \\$20,739. Military wages remain lowest throughout.\n\nWe fit the model to the empirical data using maximum likelihood calibration. Figure \\ref{Model fit} shows the overall agreement between the empirical data and a dataset simulated using the calibrated parameters within the support of the data. On the left, we show the choice probability of working in a blue-collar occupation, while we plot the average wage across all occupations on the right.\n\n%\n\\begin{figure}[t!]\\centering\n\\caption{Model fit}\\label{Model fit}\n\\subfloat[Blue-collar]{\\scalebox{0.19}{\\includegraphics{fig-model-fit-choice-blue-bw}}}\\hspace{0.3cm}\n\\subfloat[Average wage]{\\scalebox{0.19}{\\includegraphics{fig-model-fit-wage-all-bw}}}\n\\begin{center}\n\\begin{minipage}[t]{0.7\\columnwidth}\n\\item \\scriptsize{\\textbf{Notes:} We simulate a sample of 1,000 individuals using the calibrated model.}\n\\end{minipage}\\end{center}\n\\end{figure}%\\FloatBarrier\n%\n\nOverall, the values of the calibrated parameters of the model are in broad agreement with the relevant literature. For example, individuals discount future utilities by $6\\%$ per year, and wages increase by about $7\\%$ with each additional year of schooling.\n%-------------------------------------------------------------------------------\n\\subsection{Economic insights}\n%-------------------------------------------------------------------------------\n\\autoref{Economic mechanism and policy forecast} illustrates the ability of the model to quantify the impact of economic mechanisms and to forecast the effect of public policies. On the left, we vary the discount factor capturing time preferences between $0.91$ and $0.95$ while we introduce a tuition subsidy of up to $\\$4{,}000$ on the right. In both cases, we are interested in the changes to average final schooling.\n\nIncreases in the discount factor and the tuition subsidy both result in higher average final schooling. However, they do so for very different reasons. While individuals emphasize the future benefits of their schooling investment in the former, they react to a reduction of its immediate cost in the latter.\n\n\\begin{figure}[h!]\\centering\n\t\\caption{Economic mechanism and policy forecast}\\label{Economic mechanism and policy forecast}\n\t\\subfloat[Time preference]{\\scalebox{0.19}{\\includegraphics{fig-economic-mechanism-bw}}}\\hspace{0.3cm}\n\t\\subfloat[Tuition subsidy]{\\scalebox{0.19}{\\includegraphics{fig-policy-forecast-bw}}}\n\t\\begin{center}\n\t\t\\begin{minipage}[t]{0.675\\columnwidth}\n\t\t\t\\item \\scriptsize{\\textbf{Notes:} We simulate a sample of 1,000 individuals using the calibrated model.}\n\t\t\\end{minipage}\n\t\\end{center}\n\\end{figure}%\\FloatBarrier\n", "meta": {"hexsha": "c3b6af799febd47f1d2b04cb99e8a46f7f443051", "size": 13023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/sections/s-example.tex", "max_stars_repo_name": "OpenSourceEconomics/handout-eckstein-keane-wolpin-models", "max_stars_repo_head_hexsha": "68cc55540c8b8772a3b204b7ba063fb324b08fdb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/sections/s-example.tex", "max_issues_repo_name": "OpenSourceEconomics/handout-eckstein-keane-wolpin-models", "max_issues_repo_head_hexsha": "68cc55540c8b8772a3b204b7ba063fb324b08fdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2020-03-05T07:53:32.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-30T11:59:58.000Z", "max_forks_repo_path": "paper/sections/s-example.tex", "max_forks_repo_name": "OpenSourceEconomics/handout-eckstein-keane-wolpin-models", "max_forks_repo_head_hexsha": "68cc55540c8b8772a3b204b7ba063fb324b08fdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-09-17T17:09:27.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-15T19:27:05.000Z", "avg_line_length": 97.1865671642, "max_line_length": 871, "alphanum_fraction": 0.705060278, "num_tokens": 3424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.44060999435109877}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{November 20, 2013}\n\\maketitle\n\\section*{exam 2}\n4.4 has 1 problem for 20 points\n4.7 has one problem for 20 points\n5.1 has 1 problem for 10 points\n8.1-8.3 has one point (technically from 8.3) for 20 points\n8.5 has one problem for 30 points\n\nmost should be similar to class problems, one is exactly the same as in class even\n\n\\section*{section 5.1}\ndetermine the spring constant of the spring with natural length 10 in that is stretched to a distance 13 in by an object weighing 5 lb\n\\begin{align*}\n    m\\frac{\\mathrm{d}^2x}{\\mathrm{d}t^2}+kx&=0\\\\\n    x(0)&=\\alpha\\\\\n    x'(0)&=\\beta\n\\end{align*}\n\\subsection*{solution}\n``English'' units\n\\begin{align*}\n    s&=3\\text{in}\\\\\n    &=\\frac{3}{12}\\text{ft}=\\frac{1}{4}\\text{ft}\\\\\n    F&=ks\\\\\n    5&=k\\frac{1}{4}\\\\\n    k&=20\\text{lb/ft}\\\\\n    F&=mg\\\\\n    5&=m32\\\\\n    m&=\\frac{5}{32}\\text{slug}\n\\end{align*}\n\\section*{random question example}\n\\begin{align*}\n    \\mathcal{L}^{-1}\\left\\{\\frac{4s}{(s^2+16)^2}\\right\\}\\\\\n    \\sin 4t &\\to \\frac{4}{s^2+16}\\\\\n    t\\sin 4t &\\to -\\frac{\\mathrm{d}}{\\mathrm{d}x}(\\frac{4}{s^2+16})\\\\\n    &=\\frac{4(2s)}{(s^2+16)^2}\\\\\n    &=\\frac{8s}{(s^2+16)^2}\\\\\n    \\mathcal{L}\\{t^nf(t)&=(-1)^n\\frac{\\mathrm{d}^nF}{\\mathrm{d}s^n}\\}\\\\\n    \\frac{1}{2}t\\sin 4t&\\to \\frac{4s}{(s^2+16)^2}\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "2a06e5842a729d381b8ab1a5a8828ffd3d0cd253", "size": 1475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "differential equations/diffeq-notes-2013-11-25.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "differential equations/diffeq-notes-2013-11-25.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "differential equations/diffeq-notes-2013-11-25.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3653846154, "max_line_length": 134, "alphanum_fraction": 0.6277966102, "num_tokens": 622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.44060998734241447}}
{"text": "\\section{Specification Model}\n\\label{sec:performance-modeling-specification-model}\nThe typical modeling workflow requires to specify\n(i) the statistical analysis of data collected from the real system in order to determine the input model to drive simulations,\n(ii) the analytical model and equations to determine performance metrics,\n(iii) the adopted simulation approach and\n(iv) the algorithms involved in computations.\n\n\\paragraph{Statistical specifications}\nWe have been provided with the statistical characterization of the target system.\nTasks belonging to the $i$-th class arrive to the system according to an exponential arrival process with rate $ \\lambda_{i}$.\nThe Cloudlet serves tasks belonging to the $i$-th class according to an exponential service process with rate $\\mu_{clt,i}$.\nThe Cloud serves tasks belonging to the $i$-th class according to an exponential service process with rate $\\mu_{cld,i}$.\nWe assume that \n(i) $\\mu_{clt,i}>\\mu_{cld,i}\\ \\forall i=1,2$ and\n(ii) the setup time $T_{setup}$ is exponentially distributed with expected value $E[T_{setup}]$.\n\nIn particular, we consider values shown in Equations~\\ref{eqn:statistical-specifications}.\n\n\\begin{equation} \n\\begin{split}\n\\lambda_{1}  &=6.00\\;tasks/sec \\\\\n\\lambda_{2}  &=6.25\\;tasks/sec \\\\\n\\mu_{clt,1}  &=0.45\\;tasks/sec \\\\\n\\mu_{clt,2}  &=0.27\\;tasks/sec \\\\\n\\mu_{cld,1}  &=0.25\\;tasks/sec \\\\\n\\mu_{cld,2}  &=0.22\\;tasks/sec \\\\\nE[T_{setup}] &=0.8\\;sec \\\\\n\\end{split}\n\\label{eqn:statistical-specifications}\n\\end{equation}\n\n\\paragraph{Analytical Model}\nGiven the importance and complexity of the analytical model, we preferred to reserve the whole Section~\\ref{sec:analytical-model} to present it.\n\n\\paragraph{Simulation Approach}\nWe decided to adopt the \\textit{next-event simulation method}, which is the most effective discrete-event technique in terms of algorithmic modeling, time management and computational requirements.\n\n\\paragraph{Algorithmic specifications}\nFrom the point of view of algorithms involved in the simulation, we need to specify:\n\n\\begin{itemize}\n\t\n\t\\item \\textit{Off-Loading Algorithm}: defines the off-loading policy implemented by the \\textit{Cloudlet Controller (CTRL)}.\n\t%\n\tThe first policy, defined in Algorithm~\\ref{alg:off-loading-policy-1}, makes no distinction between classes of tasks, which are all served by the Cloudlet as long as it has available resources. \n\t%\n\tThe second policy, defined in Algorithm~\\ref{alg:off-loading-policy-2}, gives higher priority to the $1^{st}$ class tasks by \n\t(i) accepting in Cloudlet at most $S$ $2^{nd}$ class tasks and \n\t(ii) freeing up Cloudlet resources occupied by the $2^{nd}$ class tasks in favor of $1^{st}$ class tasks restarting the former on Cloud.\n\tNotice that the threshold $S$ plays a key role here.\n\tOn one hand, a high $S$ increases the opportunity for  $2^{nd}$ class tasks to be served by the Cloudlet, that is faster than the Cloud.\n\tOn the other hand, a high $S$ increases also the risk for $2^{nd}$ class tasks to incur in the overhead caused by the restart in Cloud.\n\t\n\t\\item \\textit{Simulation Algorithm}: defines the main execution flow of the simulator, as specified in Algorithm~\\ref{alg:simulation-workflow}.\n\\end{itemize}\n\nWith reference to the simulation algorithm, it is worth focusing on the following aspects:\n\n\\begin{itemize}\n\t\n\t\\item \\textit{event generation}: a new \\textit{arrival event} is generated every time an arrival is processed and the closed-door condition does not hold. We adopted Algorithm~\\ref{alg:arrivals} to generate classed arrivals, whose statistical correctness relies on the properties of the exponential distribution.\n\t%\n\tA new \\textit{completion event} is generated every time an arrival is processed.\n\t%\n\tA new \\textit{interruption event} is generated when an arrival is processed and the Cloudlet Controller determines that a task must be interrupted in the Cloudlet and restarted in the Cloud~\\footnote{the generation of interruption events is possible only when Off-Loading Policy 2 is adopted.}.\n\t%\n\tNotice that the interruption event is never mentioned in the simulation workflow in Algorithm~\\ref{alg:simulation-workflow}; this is because the interruption event is not an external arrival, but an internal task switching between subsystems.\n\t\n\t\\item \\textit{event submission}: when a new event is submitted to the system, the simulator updates (i) the system state and (ii) the simulation counters, e.g. number of arrivals, number of completions and so on.\n\t\n\t\\item \\textit{closed-door condition}: when this condition holds true, no more arrivals will be generated and system will only handle remaining completion events until it reaches the idle state. \n\tThis condition is crucial because it identifies the point in time when the simulator has collected enough data to achieve our goals. \n\tTo this aim, this condition holds true when the simulator has collected the configured number of batches, i.e. 64 batches with 512 samples each.\n\t\n\t\\item \\textit{stop condition}: when this condition holds true, the simulation is terminated. The logical definition of this condition depends on whether the simulator is used for the performance analysis in the transient state or in the steady state.\n\t\n\tIn transient analysis, the condition holds true when the simulation clock is greater than a given stop time because we want to study whether or not performance metrics to converge to stable values within the given amount of time.\n\t\n\tIn performance analysis, the condition holds true when the closed-door condition does and the system has reached the idle state because we assume that the steady state exists and we want to collect enough data to generated meaningful confidence intervals.\n\t\n\t\\item \\textit{sampling condition}: when this condition holds true, performance metrics should be sampled. \n\tIn particular, it holds true when the processed event is a completion. \n\tWe did like this because \n\t(i) sampling, as any other operation within the simulator, should happen in correspondence of an event, by design, and\n\t(ii) a completion events brings a super set of insights w.r.t. an arrival.\n\t\n\t\n\t\\item \\textit{metrics management}: when an event is submitted to the system, all the simulation counters are updated, e.g. number of arrivals, service time, integral areas and so on. \n\tWhen the sampling condition holds true, those counters are used to compute a sample of performance metrics. Such a sample is then used to update performance statistics leveraging \\textit{One-Pass Wellford algorithm, batch means and confidence intervals} with formulas and algorithms described in \\cite{leemis2006discrete}.\n\t\n\tWe decoupled counters updates and metrics sampling in this way in order to improve the simulator performances both in terms of timing and memory consumption.\n\t%\n\tIn fact\n\t(i) the former is a low-effort operation that must be executed whenever a new event is processed,\n\t(ii) the latter is a higher-effort operation that should be executed in correspondence of the event type carrying the most complete set of information, i.e. completion events.\n\t%\n\tFurthermore, we preferred to compute metrics by executing metrics updates within the simulation loop rather than at the end of the simulation because in this way we can consume subsets of data points at every sampling operation rather than collecting all of them until the end, thus saving up memory.\n\\end{itemize}\n\n\\begin{algorithm}\n\t\\SetAlgoLined\n\t\\If{arrival of class 1 or class 2}{\n\t\t\\eIf{$n_{clt,1}+n_{clt,2}=N$}{\n\t\t\tsend to the Cloud\n\t\t}{\n\t\t\taccept on Cloudlet\n\t\t}\n\t}\n\t\\caption{Off-Loading Policy 1 (OP1).}\n\t\\label{alg:off-loading-policy-1}\n\\end{algorithm}\n\n\\begin{algorithm}\n\t\\SetAlgoLined\n\t\\If{arrival of class 1}{\n\t\t\\If{$n_{clt,1}=N$}{\n\t\t\tsend to the Cloud\n\t\t} \n\t\t\\If{$n_{clt,1}+n_{clt,2}<S$}{\n\t\t\taccept on the Cloudlet\n\t\t} \n\t\t\\eIf{$n_{clt,2} > 0$}{\n\t\t\taccept on the Cloudlet, interrupt a $2^{nd}$ class task in the Cloudlet and restart it in the Cloud\n\t\t}{\n\t\t\taccept on Cloudlet\n\t\t}\n\t}\n\t\\If{arrival of class 2}{\n\t\t\\eIf{$n_{clt,1}+n_{clt,2}>=S$}{\n\t\t\tsend to the Cloud\n\t\t}{\n\t\t\taccept on the Cloudlet\n\t\t}\n\t}\n\t\\caption{Off-Loading Policy 2 (OP2).}\n\t\\label{alg:off-loading-policy-2}\n\\end{algorithm}\n\n\\begin{algorithm}\n\t\\SetAlgoLined\n\t\n\tcalendar.schedule\\_arrival();\n\t\n\t\\While{$\\neg stop\\_condition()$}{\n\t\te = calendar.next\\_event();\n\t\t\n\t\t\\If{$e.type = completion$}{\n\t\t\tsubmit\\_event(e);\n\t\t}\n\t\n\t\t\\If{$e.type = arrival \\land \\neg close\\_door\\_condition()$}{\n\t\t\te\\_next = submit\\_event(e);\n\t\t\t\n\t\t\tcalendar.schedule(e\\_next);\n\t\t\t\n\t\t\tcalendar.schedule\\_arrival();\n\t\t}\n\t\n\t\tupdate\\_simulation\\_counters();\n\n\t\t\\If{$sampling\\_condition()$}{\n\t\t\tsample = sampling();\n\t\t\t\n\t\t\tupdate\\_metrics(sample);\n\t\t}\n\t}\n\n\\caption{Simulation Workflow.}\n\\label{alg:simulation-workflow}\n\\end{algorithm}\n\n\\begin{algorithm}\n\t\\SetAlgoLined\n\t\n\trndgen.select\\_stream(ARRIVAL)\n\t\n\t$p_{1}=\\frac{\\lambda_{1}}{\\lambda_{1}+\\lambda_{2}}$\n\t\n\tu = rndgen.uniform(0.0,1.0)\n\t\n\t\\eIf{$u\\leq p_{1}$}{\n\t\tarrival\\_type = TASK\\_1\n\t\t\n\t\trndgen.select\\_stream(ARRIVAL\\_TASK\\_1)\n\t\t\n\t\t$t_{inter-arrival}$ = rndgen.exponential($\\lambda_{1}$)\n\t}{\n\t\tarrival\\_type = TASK\\_2\n\t\t\n\t\trndgen.select\\_stream(ARRIVAL\\_TASK\\_2)\n\t\t\n\t\t$t_{inter-arrival}$ = rndgen.exponential($\\lambda_{2}$)\n\t}\n\t\n\t$t_{arrival}=t_{last\\_arrival}+t_{inter-arrival}$\n\n\t$t_{last\\_arrival}=t_{arrival}$\n\t\n\tschedule(arrival\\_type,$t_{arrival}$)\n\t\\caption{Generation of arrivals.}\n\t\\label{alg:arrivals}\n\\end{algorithm}\n\n", "meta": {"hexsha": "cd6a5c854e6ba211be80b4baa4cb37b9fe5e5b52", "size": 9401, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pydes/sec/performance-modeling-specification-model.tex", "max_stars_repo_name": "gmarciani/research", "max_stars_repo_head_hexsha": "7cc526fe7cd9916ceaf8285c4e4bc4dce4028537", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-07-27T13:31:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-20T12:54:12.000Z", "max_issues_repo_path": "pydes/sec/performance-modeling-specification-model.tex", "max_issues_repo_name": "gmarciani/research", "max_issues_repo_head_hexsha": "7cc526fe7cd9916ceaf8285c4e4bc4dce4028537", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pydes/sec/performance-modeling-specification-model.tex", "max_forks_repo_name": "gmarciani/research", "max_forks_repo_head_hexsha": "7cc526fe7cd9916ceaf8285c4e4bc4dce4028537", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-02-17T13:30:49.000Z", "max_forks_repo_forks_event_max_datetime": "2018-02-17T13:30:49.000Z", "avg_line_length": 45.8585365854, "max_line_length": 323, "alphanum_fraction": 0.7531113711, "num_tokens": 2422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4405082037353805}}
{"text": "\\documentstyle[12pt]{article}\n\\begin{document}\n\\begin{center} {\\Large Polynomial Ideals} \\end{center}\n\\begin{center} Arithmetic for polynomial ideals supported by \nGr\\\"obner bases \\end{center}\n\\begin{center} Version 1.0 May 1992 \\end{center}\n\n\\begin{center} Herbert Melenk \\\\ Konrad-Zuse-Zentrum f\\\"ur\nInformationstechnik \\\\\nTakustra\\\"se 7 \\\\ D14195 Berlin--Dahlem \\\\ Federal Republic of Germany \\\\ \nmelenk@zib.de \\\\ May 1992 \\end{center}\n\n\\section{Introduction}\n\nThis package implements the basic arithmetic for polynomial ideals\nby exploiting the Gr\\\"obner bases package of REDUCE.\nIn order to save computing time all intermediate Gr\\\"obner bases\nare stored internally such that time consuming repetitions\nare inhibited. A uniform setting facilitates the access.\n\n\\section{Initialization}\n\nPrior to any computation the set of variables has to be declared\nby calling the operator $I\\_setting$ . E.g. in order to initiate\ncomputations in the polynomial ring $Q[x,y,z]$ call\n\\begin{verbatim}\n    I_setting(x,y,z);\n\\end{verbatim}\nA subsequent call to $I\\_setting$ allows one to select another set\nof variables; at the same time the internal data structures\nare cleared in order to free memory resources.\n\n\\section{Bases}\n\nAn ideal is represented by a basis (set of polynomials) tagged\nwith the symbol $I$, e.g.\n\\begin{verbatim}\n   u := I(x*z-y**2, x**3-y*z);\n\\end{verbatim}\nAlternatively a list of polynomials can be used as input basis; however,\nall arithmetic results will be presented in the above form. The\noperator $ideal2list$ allows one to convert an ideal basis into a\nconventional REDUCE list.\n\n\\subsection{Operators}\n\nBecause of syntactical restrictions in REDUCE, special operators\nhave to be used for ideal arithmetic: \n\n\\begin{verbatim}\n         .+            ideal sum (infix)\n         .*            ideal product (infix)\n         .:            ideal quotient (infix)\n         ./            ideal quotient (infix)\n         .=            ideal equality test (infix)\n         subset        ideal inclusion test (infix)\n         intersection  ideal intersection (prefix,binary)\n         member        test for membership in an ideal\n                         (infix: polynomial and ideal)\n         gb            Groebner basis of an ideal (prefix, unary)\n         ideal2list    convert ideal basis to polynomial list \n                         (prefix,unary)\n\\end{verbatim}\n\nExample:\n\n\\begin{verbatim}\n    I(x+y,x^2) .* I(x-z);\n\n      2                      2    2\n   I(X  + X*Y - X*Z - Y*Z,X*Y  - Y *Z)\n\\end{verbatim}\n\nThe test operators return the values 1 (=true) or 0 (=false)\nsuch that they can be used in REDUCE $if-then-else$ statements\ndirectly.\n\nThe results of $sum,product, quotient,intersction$ are ideals\nrepresented by their Gr\\\"obner basis in the current setting and\nterm order. The term order can be modified using the operator\n$torder$ from the Gr\\\"obner package. Note that ideal equality \ncannot be tested with the REDUCE equal sign:\n\n\\begin{verbatim}\n\n   I(x,y)  = I(y,x)       is false\n   I(x,y) .= I(y,x)       is true\n\n\\end{verbatim}\n\n\\section{Algorithms}\n\nThe operators $groebner$, $preduce$ and $idealquotient$ of the \nREDUCE Gr\\\"obner package support the basic algorithms:\n\n$GB(Iu_1,u_2...) \\rightarrow groebner(\\{u_1,u_2...\\},\\{x,...\\})$\n\n$p \\in I_1 \\rightarrow p=0 \\ mod \\ I_1$\n\n$I_1 : I(p) \\rightarrow (I_1 \\bigcap I(p)) / p \\ elementwise$\n\n\\noindent\nOn top of these the Ideals package implements the following \noperations:\n\n\n$I(u_1,u_2...)+I(v_1,v_2...) \\rightarrow GB(I(u_1,u_2...,v_1,v_2...))$\n\n\n$I(u_1,u_2...)*I(v_1,v_2...)\\rightarrow \n GB(I(u_1*v_1,u_1*v2,...,u_2*v_1,u_2*v_2...))$\n\n\n$I_1 \\bigcap I_2 \\rightarrow\n  Q[x,...] \\bigcap GB_{lex}(t*I_1 + (1-t)*I_2,\\{t,x,..\\}) $\n\n\n$I_1 : I(p_1,p_2,...) \\rightarrow I_1 : I(p_1) \\bigcap I_1 : I(p_2)\n\\bigcap ...$\n\n$I_1 = I_2 \\rightarrow GB(I_1)=GB(I_2)$\n\n$I_1 \\subseteq I_2\n   \\rightarrow \\ u_i \\in I_2 \\ \\forall \\ u_i \\in I_1=I(u_1,u_2...)$\n\n\\section{Examples}\n\nPlease consult the file $ideals.tst$.\n\\end{document}\n", "meta": {"hexsha": "6476b78b02c06b82d01be74a0402f82479ea2d4b", "size": 3998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/groebner/ideals.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/groebner/ideals.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/groebner/ideals.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7538461538, "max_line_length": 74, "alphanum_fraction": 0.6740870435, "num_tokens": 1161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.607663184043154, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.4404769872632358}}
{"text": "\\documentclass{beamer}\n\n\\usepackage{amsmath,amssymb,amsthm,graphicx}\n\\usepackage{caption,subcaption}\n\\usetheme{Copenhagen}\n \\newcommand{\\N}{\\mathbb{N}}\n \\newcommand{\\Z}{\\mathbb{Z}}\n \\newcommand{\\Q}{\\mathbb{Q}}\n \\newcommand{\\R}{\\mathbb{R}}\n \\newcommand{\\C}{\\mathbb{C}}\n \\newcommand{\\bM}{\\begin{bmatrix}}\n \\newcommand{\\eM}{\\end{bmatrix}}\n \\newcommand{\\Ni}{\\N\\cup\\{\\infty\\}}\n  \\newcommand{\\rmD}[1]{\\mathrm{d}#1}\n\\newcommand{\\floor}[1]{\\lfloor #1 \\rfloor}\n\\title{Optimal Path Planning for Robotic Arms in Household Assistance}\n\\author{Vikram Sunder and Zachary Greenberg}\n\n\\begin{document}\n\\begin{frame}\n\\maketitle\n\\end{frame}\n\n\\section{Introduction}\n\\begin{frame}{The Robot}\n\\begin{itemize}\n\\item Irobot Create Base\\\\\n\\item 5-degree of freedom arm\n\\end{itemize}\n\\begin{figure}[htb]\n\\centering\n\\includegraphics[scale=.05]{PathPics/Robot_With_Arm.jpg}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{The Problem}\nFind the shortest path the arm should take to a point.\\\\\n~\\\\\nExplore different notions of ``shortest'' to get different paths.\n\\begin{itemize}\n\\item Euclidean Distance\n\\item Energy Required to Hold an Object\n\\item Kinetic Energy\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{The Algorithm}\n\\begin{itemize}\n\\item Divide configuration space into a grid to make a graph.\n\\item We used $A^*$ to compute the shortest path in the graph.\n\\item Use different cost functions to simulate different metrics.\n\\item As long as the cost is at least the euclidean distance, then the euclidean distance to the target is an admissible heuristic.\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Kinematics}\nForward Kinematics is a mapping $FK$ from configuration space to work space.\\\\\nThe Jacobian $J$ is the derivative matrix for $FK$.\\\\\nTo get linear velocities from angular velocities $\\dot{\\theta}$ take $J\\dot{\\theta}$\\\\\nThe $J^T$ maps from workspace forces to torques. $\\tau = J^TF$.\\\\\n~\\\\\nFor our robot only the first 4 angles determine position.\\\\\nIn addition the first angle determines the plane the arm moves in. So we can solve for it first and only have to search 3 dimensional space for the path.\n\\end{frame}\n\n\\section{Results}\n\\begin{frame}{Euclidean Distance}\nCompute distance between nodes in work space.\\\\\nConsidering the angle of the end effector gives a different path.\n\\begin{figure}[htb]\n\\centering\n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.3]{PathPics/Basic_Path.jpg}\n\\caption{Orientation Path}\n\\end{subfigure}%\n~ \n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.3]{PathPics/NoAlpha_Path.jpg}\n\\caption{No Orientation Path}\n\\end{subfigure}\n\n\\caption{Euclidean Distance Paths}\n\\label{fig:basicPaths}\n\\end{figure} \n\n\\end{frame}\n\n\\begin{frame}{Energy To Hold Up an Object (Next State)}\nAdd the energy to hold up an object of weight $m$ in the next state:\\\\ \n$$\td(u,v) =  \\left\\|(FK(u)-FK(v))\\right\\|^2 + \\small\\left\\|J^T_v\\bM 0 \\\\ 0 \\\\ mg \\eM\\right\\|^2$$\\normalsize\n\\begin{figure}[htb]\n\\centering\n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.2]{PathPics/Wrench_Path.jpg}\n\\caption{Orientation Path}\n\\end{subfigure}%\n~ \n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.2]{PathPics/Wrench_NoAlpha_Path.jpg}\n\\caption{No Orientation Path}\n\\end{subfigure}\n\n\\caption{Paths When Considering Energy To Hold Up an Object}\n\\label{fig:EnergyPaths1}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{Energy to Hold Up an Object (Ratios)}\nUsing the ratio of torques between the states gives:\n $$\td(u,v) =  \\left\\|(FK(u)-FK(v))\\right\\|^2 + \\Tiny\\frac{\\left\\|J^T_v\\bM 0 \\\\ 0 \\\\ mg \\eM\\right\\|^2}{\\left\\|J^T_u\\bM 0 \\\\ 0 \\\\ mg \\eM\\right\\|^2}$$\\normalsize\n\\begin{figure}[htb]\n\\centering\n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.19]{PathPics/Wrench_Path.jpg}\n\\caption{Path When Only Considering The Next State}\n\\end{subfigure}%\n~ \n\\begin{subfigure}[b]{0.5\\textwidth}\n\\centering\n\\includegraphics[scale=.19]{PathPics/Wrench_Ratio_Path.jpg}\n\\caption{Path When Considering a Ratio of Torques}\n\\end{subfigure}\n\n\\caption{Paths When Considering Energy To Hold Up an Object}\n\\label{fig:EnergyPaths2}\n\\end{figure}\n\\end{frame}\n\\begin{frame}{Kinetic Energy}\nLet $J$ be the Jacobian. Let $\\dot{\\theta}$ be the angular velocity vector.\n \\small\\[E_{linear} = \\frac{1}{2}m \\|J_u\\dot{\\theta}\\|^2\\]. \\\\\n\\[E_{angular} = \\frac{1}{2}m \\left\\|\\frac{\\Delta\\theta_1+\\Delta\\theta_2+\\Delta\\theta_3)}{h}\\right\\|^2\\]\\normalsize\n\\begin{figure}[htb]\n\\centering\n\\begin{subfigure}[b]{0.33\\textwidth}\n\\centering\n\\includegraphics[scale=.135]{PathPics/Energy_Linear_Path.jpg}\n\\caption{Linear Kinetic Engery Path}\n\\end{subfigure}%\n~ \n\\begin{subfigure}[b]{0.33\\textwidth}\n\\centering\n\\includegraphics[scale=.135]{PathPics/Energy_Angular_Path.jpg}\n\\caption{Angular Kinetic Energy Path}\n\\end{subfigure}%\n~ \n\\begin{subfigure}[b]{0.33\\textwidth}\n\\centering\n\\includegraphics[scale=.135]{PathPics/Energy_Kinetic_Path.jpg}\n\\caption{Total Kinetic Energy Path}\n\\end{subfigure}\n\n\\caption{Paths When Considering Kinetic Energy}\n\\label{fig:EnergyPaths2}\n\\end{figure}\n\\end{frame}\n\n\\section{Future Work}\n\\begin{frame}{Future Work}\n\\begin{itemize}\n\\item Consider other metrics\\\\\n\\begin{itemize}\n\\item Better angular kinetic energy metric\n\\item More accurate physics model of the arm\n\\end{itemize}\n\\item Using the robot base as part of the path finding\n\\item Increasing the grid size for smoother path\n\\item Move beyond simulation to the actual robot\n\\item Collision detection and obstacle avoidance\n\\end{itemize}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "3dc52ac694afc850c05bef778d364eb6c8f472ae", "size": 5474, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Arm Planning/finalPres.tex", "max_stars_repo_name": "Boberito25/ButlerBot", "max_stars_repo_head_hexsha": "959f961bbc8c43be0ccb533dd2e2af5c55b0cc2a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documentation/Arm Planning/finalPres.tex", "max_issues_repo_name": "Boberito25/ButlerBot", "max_issues_repo_head_hexsha": "959f961bbc8c43be0ccb533dd2e2af5c55b0cc2a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-06-08T19:55:40.000Z", "max_issues_repo_issues_event_max_datetime": "2015-06-08T19:55:40.000Z", "max_forks_repo_path": "Documentation/Arm Planning/finalPres.tex", "max_forks_repo_name": "Boberito25/ButlerBot", "max_forks_repo_head_hexsha": "959f961bbc8c43be0ccb533dd2e2af5c55b0cc2a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4597701149, "max_line_length": 158, "alphanum_fraction": 0.7449762514, "num_tokens": 1729, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.4404769769626388}}
{"text": "\\label{qft}\n\\begin{chapterbox}\n\\vspace{-60pt}\n\\chapter{Quantum Field Theory}\n\\vspace{-30pt}\n\\centering\\normalsize\\textit{Michaelmas Term 2017 - Professor B. Allanach}\n\\end{chapterbox}\n\\vspace{20pt}\n%\\begin{multicols*}{2}\n\\minitoc\n\\newpage\n\\section{Classical Field Theory}\n\\begin{definitionbox}\nA field is a physical quantity defined at every point of spacetime $(\\vec x, t)$. In field\\index{field} theory we have a set of fields $\\phi_a (\\vec x, t)$, where both $\\vec x$ and $a$ are labels, so there are an infinite number of degrees of freedom.\n\\end{definitionbox}\nThe dynamics of fields are governed by a Lagrangian\\index{Lagrangian},\n\\begin{equation}\nL = \\int{\\upd{^3 x} \\mathcal{L}(\\phi_a, \\partial_\\mu \\phi_a)}\n\\end{equation}\nwhere $\\mathcal{L}$ is the Lagrangian density. Then the action is;\n\\begin{equation}\n\\mathcal{S} = \\int_{t_0}^{t}{\\upd{t} L} = \\int{\\upd{^4 x} \\mathcal{L}(\\phi_a, \\partial_\\mu \\phi_a)}\n\\end{equation}\n\\subsection{Units}\nWe work in units where $c = \\hbar = 1$ which implies that $\\left[L\\right] = \\left[T\\right] = \\left[M\\right]^{-1}$, so length and time are measured in units of inverse mass, or equivalently, energy. There are two things to note;\n\\begin{enumerate}\n\\item If a quantity $X$ has mass dimension $d$, then we say $X$ has dimension $d$\n\\item The action, $\\mathcal{S}$ is dimensionless $\\Rightarrow \\left[\\ud^4 x\\right] = -4, \\left[\\mathcal{L}\\right] = 4$\n\\end{enumerate}\n\\subsection{Dynamical Principles of Classical Field Theory}\nClassical Field theory is built on the principle of stationary action; the fields evolve such that $\\mathcal{S}$ is stationary with respect to variations in the fields;\n\\begin{dmath}\n\\delta \\mathcal{S} = \\sum_{a}{\\int{\\upd{^4 x} \\left( \\frac{\\partial \\mathcal{L}}{\\partial \\phi_a} \\delta \\phi_a +\\frac{\\partial \\mathcal{L}}{\\partial\\left(\\partial_\\mu \\phi_a \\right)} \\delta \\left( \\partial_\\mu \\phi_a \\right)\\right)}} = \\sum_{a}{\\int{\\upd{^4 x} \\left( \\frac{\\partial \\mathcal{L}}{\\partial \\phi_a} \\delta \\phi_a - \\partial_\\mu \\left(\\frac{\\partial \\mathcal{L}}{\\partial\\left(\\partial_\\mu \\phi_a \\right)}\\right) \\delta  \\phi_a \\right) + \\partial_\\mu \\left(\\frac{\\partial \\mathcal{L}}{\\partial\\left(\\partial_\\mu \\phi_a \\right)} \\delta \\phi_a \\right)}}\n\\end{dmath}\nThe last term vanishes for any Lagrangian that decays at spatial infinite and has $\\delta \\phi_a (\\vec x, t_i) = \\delta \\phi_a (\\vec x, t_f) = 0$. Thus $\\delta \\mathcal{S} = 0$ for all $\\delta \\phi_a$ gives us the Euler-Lagrange equations\\index{equation!Euler-Lagrange} for the field:\\footnote{For more on this, refer to Appendix \\ref{sec:parttofield}.} \\boxed{\\textbf{I.i}}\n\\begin{equation}\n\\label{eq:EL}\n\\partial_\\mu \\left(\\frac{\\partial \\mathcal{L}}{\\del\\left(\\del_\\mu \\phi_a\\right)}\\right) - \\frac{\\partial \\mathcal{L}}{\\partial \\phi_a} = 0\n\\end{equation}\nAs an example of this consider the Klein-Gordon field;\n\\begin{examplebox}[The Klein-Gordon Equation\\index{equation!Klein-Gordon}]\t\nConsider the Lagrangian;\n\\begin{equation*}\n\\mathcal{L} = \\tfrac{1}{2}\\etamn{^}\\del_\\mu \\phi \\del_\\nu \\phi - \\tfrac{1}{2} m^2 \\phi^2 = \\tfrac{1}{2} \\dot{\\phi}^2 - \\tfrac{1}{2}(\\nabla \\phi)^2 - \\tfrac{1}{2} m^2 \\phi^2\n\\end{equation*}\nThen using \\eqref{eq:EL} we find the Klein-Gordon equation;\n\\begin{equation}\n\\del_\\mu \\del^\\mu \\phi + m^2 \\phi = 0\n\\end{equation}\n\\end{examplebox}\nThe realm of Quantum Field Theory are relativistic energies where quantum effects are important. The mass energy equivalence at these high energies mean that the quantum states are multi-particle ones, and the particle number is \\emph{not fixed}. This is fundamentally different to normal quantum mechanics. The Schr{\\\"o}dinger equation is for a single particle, there is no mechanism to create more. Furthermore, interactions arise due to locality and symmetry, they do not arise from arbitrary potentials in the Lagrangian. Indeed, this is made explicit in \\emph{Advanced Quantum Field Theory}, where symmetries of the path integral measure and the classical action remain manifest in the full quantum theory. This ensures that the interactions generated respect this symmetry. A special QFT is the free theory\\index{free theory} where there are particles, but no interactions. This is a relativistic theory with an infinite number of quantised harmonic oscillators\\index{harmonic oscillator}, at least one at each point in space. The interacting theory is then built perturbatively on top of this.\n\\subsubsection{Lorentz Invariance\\index{Lorentz!invariance}}\nThe Lorentz matrices\\footnotemark satisfy the relation; \\boxed{\\textbf{I.ii}}\n\\footnotetext{\nNote that this expression implies the Lorentz invariance of quantities such as $p^\\mu p_\\mu$. Under a Lorentz transformation $p^{\\mu} \\rightarrow \\Lambda\\indices{^{\\mu}_{\\nu}}p^{\\nu}$ so; \n\\begin{equation*}\np^\\mu p_\\mu = \\eta_{\\mu\\nu}p^\\mu p^\\nu \\rightarrow \\eta_{\\mu\\nu} \\Lambda\\indices{^{\\mu}_{\\rho}}\\Lambda\\indices{^{\\nu}_{\\sigma}}\\eta_{\\rho\\sigma}p^\\rho p^\\sigma = \\eta_{\\rho \\sigma}p^{\\rho} p^{\\sigma}\n\\end{equation*}\n}\n\\begin{equation}\n\\label{eq:LT}\n\\Lambda\\indices{^\\mu_\\sigma}\\eta\\indices{^{\\sigma \\tau}}\\Lambda\\indices{_\\tau ^\\nu} = \\etamn{^}\n\\end{equation}\nConsider the Lorentz transformation\\index{Lorentz!transformation} of a field, $\\phi$ under the transformation;\\footnotemark\n\\footnotetext{\nThis is really the statement that Lorentz transformations are isometries of the Minkowski metric, in other words, we can define the group in a co-ordinate free way via;\n\\begin{equation*}\n\\mO(3, 1) \\coloneqq \\set{M \\in \\text{GL}(\\RR^{3, 1}) : \\eta(M \\vec{x}, M \\vec{y}) = \\eta(\\vec{x}, \\vec{y})}\n\\end{equation*}\n}\n\\begin{equation*}\n\\Lambda : \\phi \\rightarrow \\phi^{\\prime}, \\quad \\phi^{\\prime}(x^\\mu) = \\phi(x^{\\prime \\, \\mu}), \\quad x^{\\prime \\, \\mu} = \\left(\\Lambda^{-1}\\right)\\indices{^\\mu_\\nu} x^\\nu\n\\end{equation*}\nThis is an active transformation of the field, pulling the field value at $\\Lambda^{-1} x$ to $x$. We say the Lorentz transformations have a \\emph{representation} on the fields. For a scalar field\\index{field!scalar}, this is just $\\phi(x) \\rightarrow \\phi^{\\prime}(x) = \\phi(\\Lambda^{-1} x)$. But we could equally have used a passive transformation where we relabel spacetime points, $\\phi(x) \\rightarrow \\phi(\\Lambda x)$. Since we work with Lorentz invariant theories it doesn't matter what we choose.\n\n\\paraskip\nA Lorentz invariant theory is one where the action is invariant under a Lorentz transformation, e.g.\n\\begin{equation*}\n\\mathcal{S} = \\int{\\upd{^4 x} \\tfrac{1}{2}\\del_\\mu \\phi \\del^\\mu \\phi - U(\\phi)}\n\\end{equation*}\nUnder a Lorentz transformation;\n\\begin{itemize}\n\\item $U \\rightarrow U\\left(\\phi(x^{\\prime})\\right) = U(x^{\\prime})$\n\\item $\\left(\\del_\\mu \\phi\\right)^{\\prime} = \\left(\\Lambda^{-1}\\right)\\indices{^\\sigma_\\mu} \\del^{\\prime}_\\sigma \\phi(x^{\\prime})$ (This is how a vector field transforms). But plugging this into the kinetic term, and using the relation in \\eqref{eq:LT}, we see that the Lagrangian simply transforms as a scalar field.\n\\end{itemize}\nSo,\n$$\\mathcal{S}^{\\prime} = \\int{\\upd{^4 x} \\mathcal{L}(x^{\\prime})}$$\nThe final step is to note that Lorentz transformations have determinants with modulus $1$. So,\n\\begin{equation}\n\\mathcal{S}^{\\prime} = \\int{\\upd{^4 x^{\\prime}} \\mathcal{L}(x^{\\prime})} = \\mathcal{S}\n\\end{equation}\n\\subsection{Noether's Theorem\\index{Noether's theorem} \\& Symmetries}\n\\begin{thm}{Noether's Theorem}\nEvery continuous symmetry of the Lagrangian gives rise to a conserved current, $j^\\mu (x)$ such that $\\del_\\mu j^\\mu (x) = 0$. Furthermore, each conserved current has an associated conserved charge,\n\\begin{equation}\nQ = \\int_{\\mathbb{R}^3}{\\upd{^3 x} j^0 (x^{\\mu})}\n\\end{equation}\nwhich follows from the divergence theorem and the continuity equation as well as the assumption that $j$ decays sufficiently rapidly. Note that the current is only conserved \\emph{on-shell}\\index{on-shell} where the equations of motion hold. Furthermore, Noether's theorem holds for global symmetries \\emph{as well as gauge symmetries} where $\\alpha = \\alpha(x)$. Indeed, the global symmetry is a special case of this.\n\\end{thm}\nA transformation which induces a variation in the field, $\\phi(x) \\rightarrow \\phi(x) + \\alpha \\Delta \\phi(x)$, is a symmetry if it leaves the action invariant $\\iff$ the Lagrangian is invariant up to a total derivative; \n\\begin{equation}\n\\label{eq:var}\n\\mathcal{L} \\rightarrow \\mathcal{L} + \\alpha \\del_\\mu X^\\mu (x)\n\\end{equation} \nIn detail,\n\\begin{dmath}\n\\mathcal{L}(x) \\rightarrow \\mathcal{L}(x) + \\alpha \\frac{\\del \\mathcal{L}}{\\del \\phi}\\Delta \\phi + \\alpha \\frac{\\del \\mathcal{L}}{\\del \\left(\\del_\\mu \\phi\\right)}\\del_\\mu \\left(\\Delta \\phi\\right) = \\mathcal{L}(x) + \\alpha\\del_\\mu \\left(\\frac{\\del \\mathcal{L}}{\\del\\left(\\del_\\mu \\phi\\right)} \\Delta \\phi \\right)\n\\end{dmath}\nwhere we have used the Euler Lagrange equations in the second line. So comparing to \\eqref{eq:var}, we find the current, \\boxed{\\textbf{I.iii}}\n\\begin{equation}\n\\label{eq:current}\nj^{\\mu} = \\frac{\\del \\mathcal{L}}{\\del \\left(\\del_\\mu \\phi\\right)} \\Delta \\phi - X^\\mu, \\quad \\del_\\mu j^\\mu = 0\n\\end{equation}\nWe consider the example of a complex scalar\\index{field!complex scalar} field to illustrate this,\n\\begin{examplebox}\nWe write the theory using $\\psi$, $\\psi^{\\star}$ with Lagrangian;\n\\begin{equation}\n\\mathcal{L} = \\del_\\mu \\psi^{\\star} \\del^\\mu \\psi - V\\left( \\left| \\psi \\right|^2 \\right), \\quad \\textrm{e.g. } V\\left( \\left| \\psi \\right|^2 \\right) = m^2 \\psi^{\\star} \\psi - \\tfrac{\\lambda}{2}\\left( \\psi^{\\star} \\psi \\right)^2\n\\end{equation}\nThe symmetry is a phase rotation $\\psi \\rightarrow e^{i \\beta} \\psi \\rightarrow \\Delta \\psi = i \\psi, \\Delta \\psi^{\\star} = - i \\psi^{\\star}$. Lagrangian clearly invariant, so $X^{\\mu} = 0$. Then we use \\eqref{eq:current} to find,\n\\begin{equation}\nj_\\mu = i \\left(\\psi \\del_\\mu \\psi^{\\star} - \\psi^{\\star} \\del_\\mu \\psi \\right)\n\\end{equation}\nand the conserved charge is the electric charge\\index{electric charge}/particle number. \n\\end{examplebox}\nPerhaps a more important example is that of translations, which leads to the energy-momentum tensor\\index{tensor!energy-momentum};\n\\begin{examplebox}[The Energy-Momentum Tensor]\nWe consider the translation $x^\\mu \\rightarrow x^\\mu - \\xi^\\mu$, so $\\phi(x) \\rightarrow \\phi(x) + \\xi^\\mu \\del_\\mu \\phi(x)$, where we use the fact that $\\phi$ transforms under the inverse map. If $\\mathcal{L}$ doesn't depend explicitly on time, then it transforms as a scalar field, then;\n\\begin{equation}\n\\mathcal{L}(x) \\rightarrow \\mathcal{L}(x) + \\xi^\\mu \\del_\\mu \\mathcal{L} (x) = \\mathcal{L}(x) + \\xi^\\nu \\del_\\mu \\left( \\delta\\indices{^\\mu_\\nu}\\mathcal{L}\\right)\n\\end{equation}\nWe have one conserved current for each component of $\\xi^\\nu$, so identifying $\\Delta \\phi = \\del_\\mu \\phi$, $X^\\mu = \\delta\\indices{^\\mu_\\nu}\\mathcal{L}$, we find;\n\\begin{equation}\nj\\indices{^\\mu_\\nu} \\coloneqq T\\indices{^\\mu_\\nu} = \\frac{\\del \\mathcal{L}}{\\del \\left( \\del_\\mu \\phi \\right)}\\del_\\nu \\phi - \\delta\\indices{^\\mu_\\nu}\\mathcal{L}, \\quad \\del_\\mu T\\indices{^\\mu_\\nu} = 0\n\\end{equation}\nThis gives us the conserved charges;\n\\begin{itemize}\n\\item Total field energy, $E = \\int{\\upd{^3 x}} T^{00}$\n\\item Total field momentum, $P^{i} = \\int{\\upd{^3 x}} T^{0i}$\n\\end{itemize}\n\\end{examplebox}\n\\newpage\n\\section{Canonical Quantisation}\nWe can also use the Hamiltonian\\index{Hamiltonian} formalism in field theories; the conjugate momentum\\index{conjugate momentum} is defined by;\n\\begin{equation}\n\\pi_a (x) = \\frac{\\del \\mL}{\\del \\dot{\\phi}_a} \\Rightarrow \\hamilt = \\sum_{a}{\\pi_a (x) \\dot{\\phi}_a} - \\mL(x)\n\\end{equation}\nwhere $\\hamilt$ is the Hamiltonian density\\index{Hamiltonian!density}. For example, consider $\\mL = \\tfrac{1}{2} \\dot{\\phi}^2 - \\tfrac{1}{2} \\left(\\nabla \\phi \\right)^2 - V(\\phi) \\Rightarrow \\pi(x) = \\dot{\\phi}(x) \\Rightarrow \\hamilt = \\tfrac{1}{2} \\pi^2 + \\tfrac{1}{2} \\left(\\nabla \\phi \\right)^2 + V(\\phi)$. Hamilton's equations\\index{equation!Hamilton's};\n\\begin{equation}\n\\dot{\\phi} = \\frac{\\del \\hamilt}{\\del \\pi}, \\quad \\dot{\\pi} = - \\frac{\\del \\hamilt}{\\del \\phi}\n\\end{equation}\nIn general it is not obvious that the Hamiltonian is manifestly Lorentz invariant, but the physics is unchanged, so it must be. Now, in quantum mechanics, the process of quantisation\\index{canonical quantisation} takes co-ordinates $q_a$ and momenta $p_a$ and promotes them to operators, replacing the Poisson bracket\\index{Poisson bracket} with commutators. We'll do the same here;\n\\begin{definitionbox}\nA \\emph{quantum field}\\index{field!quantum} is an operator valued function of space obeying the commutation relations;\n\\begin{align}\n\\left[\\phi_a(\\vec x), \\pi^b(\\vec y)\\right] &= i\\delta\\indices{^{a}_{b}}\\delta^{(3)}(\\vec x - \\vec y) \\\\\n\\left[\\phi_a(\\vec x), \\phi_b(\\vec y)\\right] &= 0 = \\left[\\pi^{a}(\\vec x), \\pi^{b}(\\vec y)\\right] \n\\end{align}\nwhere we are in the Schr{\\\"o}dinger picture, so there is no time dependence in the fields.\n\\end{definitionbox}\nIt is usually not possible to know the spectrum of $\\hamilt$ as there are an infinite number of degrees of freedom. In certain theories, the co-ordinates evolve independently, these are \\emph{free theories}\\index{free theory} where $\\mL$ is quadratic in the fields, giving linear equations of motion. For example, the free theory of a scalar field leads to the Klein-Gordon equation\\index{equation!Klein-Gordon} for the field $\\phi(\\vec, t)$;\n\\begin{equation}\n\\del_\\mu \\del^\\mu + m^2 \\phi = 0\n\\end{equation}\nTaking the Fourier transform\\index{Fourier transform};\n\\begin{equation}\n\\phi(\\vec x, t) = \\int{\\frac{\\ud^3 p}{(2\\pi)^3} e^{i \\vec p \\cdot \\vec x} \\phi(\\vec p, t)} \\Rightarrow \\left(\\del^2_t + ( \\vec{p}^2 + m^2 )\\right) \\phi(\\vec p, t) = 0\n\\end{equation}\nBut this is just a harmonic oscillator with frequency $\\omega_{p} = \\sqrt{\\vec{p}^2 + m^2}$. Then $\\phi(\\vec x, t)$ is just a superposition of an infinite number of harmonic oscillators that we need to quantise.\n\\subsection{Review of the Simple Harmonic Oscillator\\index{harmonic oscillator}}\nThe main details of the harmonic oscillator can be found elsewhere, here we focus only on the concept of \\emph{normal ordering}\\index{normal ordering}. Often we are only interested in energy differences between states. So we set the zero point energy $\\tfrac{1}{2} \\omega \\ket{n}$ to zero. This is not so drastic in the case of a single oscillator, it just results from fixing the Hamiltonian to be $\\text{H} = \\omega a\\dagg a$. In the free theory of a full quantum field however, this zero point energy is infinite and thus in this context normal ordering represents a far more subtle process. \n\\subsection{Free Field Theory}\nWe take guidance from the simple harmonic oscillator where we write the position and momentum operators in terms of the ladder operators;\n\\begin{equation}\n\\label{eq:sho}\n\\phi = \\tfrac{1}{\\sqrt{2\\omega}}\\left(a + a\\dagg\\right), \\quad \\pi = -i \\sqrt{\\tfrac{\\omega}{2}} \\left(a - a\\dagg\\right)\n\\end{equation}\nThen we can find the spectrum of the Klein-Gordon Hamiltonian using the same form, but now each Fourier mode of the field is treated as an independent oscillator with it's own $a$, $a\\dagg$. So in analogy with \\eqref{eq:sho}, we write;\\footnote{Note that the second term in the expression for $\\phi(\\vec x)$ ensures that $\\phi$ is a real field.}\n\\begin{definitionbox}[The Klein-Gordon Scalar Field]\n\\vspace{-10pt}\n\\begin{align}\n\\label{eq:kgfield}\n\\phi(\\vec x) &= \\int{\\frac{\\ud^3 p}{(2\\pi)^3}\\frac{1}{\\sqrt{2\\omega_p}} \\left(a_{\\vec p}\\, e^{i\\vec{p} \n\\cdot \\vec{x}} + a_{\\vec p}\\dagg \\,e^{-i\\vec{p}\\cdot\\vec{x}}\\right)} \\\\\n\\pi(\\vec x) &= \\int{\\frac{\\ud^3 p}{(2\\pi)^3}(-i)\\sqrt{\\frac{\\omega_p}{2}} \\left(a_{\\vec p}\\, e^{i\\vec{p} \n\\cdot \\vec{x}} - a_{\\vec p}\\dagg\\, e^{-i\\vec{p}\\cdot\\vec{x}}\\right)}\n\\end{align}\n\\end{definitionbox}\nImportantly we can use this definition along with the identity;\n\\begin{equation}\n\\int{\\frac{\\ud^3 p}{(2\\pi)^3}e^{i \\vec{p} \\cdot \\vec{x}}} = \\delta^{(3)}(\\vec x)\n\\end{equation}\nto show that;\\footnote{It is the commutation relations in \\eqref{eq:comm} that really motivate the definition in \\eqref{eq:kgfield}. It is this algebraic structure that is the hallmark of the quantisation process, not the analogy with the simple harmonic oscillator}\n\\begin{multline}\n\\label{eq:comm}\n\\left[\\phi(\\vec x), \\pi(\\vec y)\\right] = i\\delta^{(3)}(\\vec x - \\vec y), \\left[\\phi(\\vec x), \\phi(\\vec y)\\right] = 0 = \\left[\\pi(\\vec x), \\pi(\\vec y)\\right] \\\\ \\iff \\left[a_{\\vec p}, a_{\\vec q}\\right] = 0 = \\left[a_{\\vec p}\\dagg, a_{\\vec q}\\dagg\\right], \\left[a_{\\vec p}, a_{\\vec q}\\dagg\\right] = (2\\pi)^3 \\delta^{(3)}(\\vec p - \\vec q)\n\\end{multline}\nSo, given these definitions, can we calculate the Hamiltonian in terms of the ladder operators? It is a lengthy, but relatively straightforward calculation to find that;\n\\begin{align}\n\\text{H} &= \\frac{1}{2} \\int{\\upd{^3 x} \\pi^2 + \\left(\\nabla \\phi\\right)^2 + m^2 \\phi^2} \\nonumber \\\\\n&= \\frac{1}{4} \\int{\\frac{\\ud^3 p}{(2\\pi)^3 \\omega_p}\\left(-\\omega_p^2 + \\vec{p}^2 + m^2\\right)\\left(a_{\\vec p} a_{-\\vec p} + a_{\\vec p}\\dagg a_{-\\vec p}\\dagg\\right)} \\nonumber \\\\ \n&\\qquad\\qquad\\qquad+ \\left(\\omega_p^2 + \\vec{p}^2 + m^2\\right)\\left(a_{\\vec p} a_{\\vec p}\\dagg + a_{\\vec p}\\dagg a_{\\vec p}\\right)\n\\end{align}\nBut now we can use the fact that $\\omega_p = \\sqrt{\\vec{p}^2 + m^2}$ to see that the first term vanishes and we are left with;\n\\begin{equation}\n\\text{H} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3} \\omega_p \\left(a_{\\vec p}\\dagg a_{\\vec p} + \\frac{1}{2}\\left[a_{\\vec p}, a_{\\vec p}\\dagg\\right]\\right)}\n\\end{equation}\n\\subsubsection{The Vacuum}\nWe define the \\emph{vacuum}\\index{vacuum} of the theory, $\\ket{0}$ by the condition that $a_{\\vec p} \\ket{0} = 0$ for all momenta $\\vec p$. The energy is then given by $\\text{H}\\ket{0}$;\n\\begin{equation}\n\\text{H}\\ket{0} = \\frac{1}{2}\\int{\\frac{\\ud^3 p}{(2\\pi)^3} \\omega_p (2\\pi)^3 \\delta^{(3)}(0) \\ket{0}}\n\\end{equation}\nbut this is divergent (an \\emph{ultra-violet divergence}\\index{UV divergence}). To rectify this we apply the concept of normal ordering\\index{normal ordering}. We are only interested in energy differences, so we redefine the normal ordered Hamiltonian to be;\\footnotemark\n\\footnotetext{\nThere are actually two infinities here. The first is because space is infinitely large. If instead we put the system in a box of side length $L$, then;\n\\begin{equation*}\n(2\\pi)^3 \\delta^{(3)}(0) = \\lim_{L \\rightarrow \\infty}\\int_{-L/2}^{L/2}{\\upd{^3 x}\\left.e^{i \\vec{p}\\cdot\\vec{x}}\\right|_{\\vec{p} = 0}} = \\lim_{L \\rightarrow \\infty}\\int_{-L/2}^{L/2}{\\upd{^3 x}} = V\n\\end{equation*}\nThis we can resolve then by simply considering the energy density $E/V \\coloneqq \\epsilon_0$. This still leaves;\n\\begin{equation*}8\n\\int{\\frac{\\ud^3 p}{(2\\pi)^2}\\frac{1}{2}\\omega_{\\vec{p}}} \\rightarrow \\infty\n\\end{equation*}\nsince $\\omega_{\\vec{p}}$ diverges. This is the UV divergence mentioned above.\n}\n\\begin{equation}\n\\normord{\\text{H}} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3}\\omega_p a_{\\vec p}\\dagg a_{\\vec p}}\n\\end{equation}\n\\begin{definitionbox}[Normal Ordering]\nIn general, we define a normal ordering\\index{normal ordering} string of operators $\\phi_1(x_1)\\cdots\\phi_n(x_n)$ to be $\\normord{\\phi_1(x_1)\\cdots\\phi_n(x_n)}$ which is simply the normal product with all annihilation operators moved to the right of each term.\n\\end{definitionbox}\n\\subsubsection{Particles}\nWith this definition of normal ordering, we now have $\\normord{\\text{H}}\\ket{0} = 0$. We can also verify that,\n\\begin{equation}\n\\left[\\text{H}, a_{\\vec p}\\dagg\\right] = \\omega_p a_{\\vec p}\\dagg, \\quad \\left[\\text{H}, a_{\\vec p}\\right] = -\\omega_p a_{\\vec p}\n\\end{equation}\nSo $a_{\\vec p}\\dagg$ increases the energy by $\\omega_{\\vec p}$. Let $\\ket{\\vec{p}\\pr} = a_{\\vec{p}\\pr}\\dagg \\ket{0}$ then we may show that; \n\\begin{equation}\n\\text{H}\\ket{\\vec{p}\\pr} = \\omega_{\\vec{p}\\pr} a_{\\vec{p}\\pr}\\dagg \\ket{0} = \\omega_{\\vec{p}\\pr}\\ket{\\vec{p}\\pr}\n\\end{equation}\ni.e. the energy is just $\\omega_{\\vec{p}\\pr} = \\sqrt{\\vec{p}^{\\prime^2} + m^2}$ which is the dispersions relation \\index{dispersion relation} for a relativistic particle of mass $m$ and momentum $\\vec{p}\\pr$. We write $\\omega_{\\vec{p}} = E_{\\vec{p}}$ from now on. We can also show that the total momentum and angular momentum operators;\n\\begin{align}\n\\vec P &= -\\int{\\upd{^3 x} \\pi(\\vec x) \\nabla \\phi(\\vec x)} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3} \\vec p a_{\\vec p}\\dagg a_{\\vec p}} \\\\\nJ_i &= -\\frac{i}{2}\\epsilon_{ijk}\\int{\\frac{\\ud^3 p}{(2\\pi)^3} a_{\\vec p}\\dagg\\left(p_j \\frac{\\del}{\\del p_k} - p_k \\frac{\\del}{\\del p_j}\\right)a_{\\vec p}}\n\\end{align} \nsatisfy $\\vec P \\ket{\\vec p} = \\vec p \\ket{\\vec p}$ and $J_i \\ket{\\vec p = \\vec 0} = 0$. This second equality tells us that the single particle states of the scalar field have spin $0$. \n\n\\paraskip\nNow consider the more general multi-particle states, $\\ket{\\vec{p}_1, \\ldots, \\vec{p}_n} = a_{\\vec{p}_1}\\dagg \\cdots a_{\\vec{p}_n}\\dagg\\ket{0}$. The $a\\dagg$ commute, so this is symmetric under interchange implying that the particles of the scalar field are also \\emph{bosons}\\index{boson}. The full Hilbert space\\index{Hilbert space}, know as the \\emph{Fock space}\\index{Fock space} is spanned by \n\\begin{equation}\n\\set{\\ket{0}, a_{\\vec{p}_1}\\dagg\\ket{0}, a_{\\vec{p}_1}\\dagg a_{\\vec{p}_2}\\dagg\\ket{0}, \\ldots}\n\\end{equation}\nThe number operator\\index{number operator} counts the number of particles;\n\\begin{equation}\nN = \\int{\\frac{\\ud^3 p}{(2\\pi)^3} a_{\\vec{p}}\\dagg a_{\\vec p}}, \\quad N \\ket{\\vec{p}_1, \\ldots, \\vec{p}_n} = n\\ket{\\vec{p}_1, \\ldots, \\vec{p}_n} \n\\end{equation}\nIn the free theory, $\\left[N, \\text{H}\\right] = 0$ so the particle number is actually conserved. This is certainly not true in the interacting theory\\index{interacting theory} however. \n\n\\paraskip\nNote that these momentum states are not localised in space, and even after taking a Fourier transform;\n\\begin{equation*}\n\\ket{\\vec{x}} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3}e^{i\\vec{p}\\cdot\\vec{x}}\\ket{\\vec{p}}}\n\\end{equation*}\nthe localised states are still not normalisable; $\\braket{\\vec{x}}{\\vec{x}} = \\infty$. This is really the statement that $a_{\\vec{p}}$ and $\\phi(\\vec{x})$ are not good operators on the Hilbert space. To construct well defined operators, we should consider a wave packet;\n\\begin{equation}\n\\ket{\\varphi} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3}e^{-i\\vec{p}\\cdot\\vec{x}}\\varphi(\\vec{p})\\ket{\\vec{p}}} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3}e^{-i\\vec{p}\\cdot\\vec{x}}\\varphi(\\vec{p})a_{\\vec{p}}\\dagg \\ket{0}}\n\\end{equation}\nwhich we can show satisfies;\n\\begin{equation*}\n\\braket{\\varphi}{\\varphi} = \\int{\\upd{^3 p}\\abs{\\varphi(\\vec{p})}^2}\n\\end{equation*}\nSo we deduce that states such that $\\varphi(\\vec{p})$ has a finite $L^2$ norm are good operators on the Hilbert space.\n\\subsection{Relativistic Normalisation}\nWe define the vacuum to be normalised; $\\braket{0}{0} = 1$, then $\\braket{\\vec p}{\\vec q} = \\expval{a_{\\vec p} a_{\\vec q}\\dagg}{0} = \\expval{\\left[a_{\\vec p}, a_{\\vec q}\\dagg\\right]}{0} = (2\\pi)^3 \\delta^{(3)}(\\vec p - \\vec q)$. We want to know if this is Lorentz invariant. Clearly the vacuum normalisation is since it is just a scalar but, a priori, the general one-particle state is not, and indeed it will need some modification. Consider a boost in the $3$-direction; then $p_3\\pr = \\gamma(p_3 + \\beta E), E\\pr = \\gamma(E + \\beta p_3)$. We can use a delta function identity;\n\\begin{equation}\n\\label{eq:deltaident}\n\\delta\\left(f(x) - f(x_0)\\right) = \\frac{1}{\\abs{f\\pr(x_0)}} \\delta(x - x_0)\n\\end{equation}\nto deduce that;\\footnote{Note that $E = \\sqrt{p_i p^i + m^2} \\Rightarrow \\del_{p_3}E = \\tfrac{p_3}{E}$ as claimed.}\n\\begin{align}\n\\delta^{(3)}(\\vec p - \\vec q) &= \\delta(p_1 - q_1)\\delta(p_2 - q_2)\\delta(p_3 - q_3) \\nonumber \\\\\n&= \\delta^{(3)}(\\vec{p}\\pr - \\vec{q}\\pr) \\cdot \\frac{\\ud p_3\\pr}{\\ud p_3} = \\delta^{(3)}(\\vec{p}\\pr - \\vec{q}\\pr) \\gamma\\left(1 + \\beta \\frac{\\ud E}{\\ud p_3}\\right) \\nonumber \\\\\n&= \\delta^{(3)}(\\vec{p}\\pr - \\vec{q}\\pr) \\frac{\\gamma}{E}(E + \\beta p_3) = \\delta^{(3)}(\\vec{p}\\pr - \\vec{q}\\pr)\\frac{E\\pr}{E}\n\\end{align}\nWe see then that whilst $\\delta^{(3)}(\\vec{p}- \\vec{q})$ is not Lorentz invariant, $E_{\\vec p}\\delta^{(3)}(\\vec{p} - \\vec{q})$ is. Hence we define the normalised one particle states;\n\\begin{equation}\n\\ket{p} = \\sqrt{2E_{\\vec p}}a\\dagg_{\\vec p}\\ket{0} \\Rightarrow \\braket{p}{q} = (2\\pi)^3 \\cdot 2\\sqrt{E_{\\vec p}E_{\\vec q}} \\delta^{(3)}(\\vec p - \\vec q)\n\\end{equation}\nBecause of this redefinition, we need to include factors of $\\sqrt{2E_{\\vec p}}$ elsewhere, for example. the identity on one particle states is now;\n\\begin{equation}\n\\left(\\II\\right)_{\\text{one particle states}} = \\int{\\frac{\\ud^3 p}{2 E_{\\vec p}}\\frac{1}{(2\\pi)^3}\\ket{p}\\bra{p}}\n\\end{equation}\nAs a final point in this regard, note that, using \\eqref{eq:deltaident};\n\\begin{equation}\n\\int{\\upd{^4 p} \\left.\\delta(p_0^2 - \\vec{p}^2 - m^2)\\right|_{p_0 > 0}} = \\int{\\left.\\frac{\\ud^3 p}{2p_0}\\right|_{p_0 = E_{\\vec p}}}\n\\end{equation}\nwhich justifies the fact that the integration measure $\\left(\\ud^3 p / 2E_{\\vec p}\\right)$ is Lorentz Invariant since the LHS is.\\footnote{$\\ud^4 p$ certainly is because $\\det \\text{M} = 1$ for $\\text{M} \\in \\Orth{3,1}$, and the delta function is only dependent on Lorentz invariant quantities.}\n\\subsection{Complex Scalar Field\\index{field!complex scalar}}\nConsider now the Lagrangian;\\footnote{If we write the complex field $\\psi = \\tfrac{1}{\\sqrt{2}}(\\phi_1 + i \\phi_2)$, then expanding the Lagrangian gives the sum of the usual Lagrangian for two real scalar fields $\\mL_i = \\tfrac{1}{2}(\\del \\phi_i)^2 - \\tfrac{1}{2}m^2 \\phi_i^2$. Furthermore, this explains the presence of \\emph{two} types of creation/annihilation operators, one for the real component of $\\psi$ and one for the imaginary part.}\n\\begin{equation}\n\\mL = \\del_\\mu \\psi^{\\star} \\del^\\mu \\psi - \\mu^2 \\psi^{\\star} \\psi\n\\end{equation}\nwhich leads to the Euler-Lagrange equations\\index{equation!Euler-Lagrange};\n\\begin{equation}\n\\del_\\mu \\del^\\mu \\psi + \\mu^2 \\psi = 0, \\quad \\del_\\mu \\del^\\mu \\psi^{\\star} + \\mu^2 \\psi^{\\star} = 0\n\\end{equation}\nThis allows us to expand;\n\\begin{align}\n\\psi &= \\int{\\frac{\\ud^3 p}{(2\\pi)^3}\\frac{1}{\\sqrt{2E_p}}\\left(b_{\\vec p}e^{i\\vec{p}\\cdot \\vec{x}} + c\\dagg_{\\vec p}e^{-i \\vec{p}\\cdot \\vec{x}}\\right)} \\\\\n\\pi &=i \\int{\\frac{\\ud^3 p}{(2\\pi)^3}\\sqrt{\\frac{E_p}{2}}\\left(b_{\\vec p}\\dagg e^{-i\\vec{p}\\cdot \\vec{x}} + c_{\\vec p}e^{i \\vec{p}\\cdot \\vec{x}}\\right)}\n\\end{align}\nThen the commutation relations are $\\left[\\psi(\\vec x), \\pi(\\vec y)\\right] = i\\delta^{(3)}(\\vec x - \\vec y)$ and $[\\psi(\\vec x), \\pi\\dagg(\\vec y)] = 0$ etc. In terms of the creation and annihilation operators, $\\left[b_{\\vec p}, b\\dagg_{\\vec q}\\right] = (2\\pi)^3\\delta^{(3)}(\\vec p - \\vec q) = \\left[c_{\\vec p}, c\\dagg_{\\vec q}\\right]$ with all other commutators vanishing. The two Klein-Gordon equations\\index{equation!Klein-Gordon} ensure that we have two types of creation operator, $b_{\\vec p}\\dagg, c_{\\vec q}\\dagg$, which we interpret as creating two types of particle with mass $\\mu$; a particle and its anti-particle\\index{anti-particle}. The conserved charge, after normal ordering is;\n\\begin{align}\nQ &= i\\int{\\upd{^3 x} \\dot{\\psi}^{\\star}\\psi - \\psi^{\\star} \\dot{\\psi}} = i\\int{\\upd{^3 x}\\pi\\psi - \\psi^{\\star}\\pi^{\\star}} \\nonumber \\\\\n&= \\int{\\frac{\\ud^3 p}{(2\\pi)^3}\\left(c_{\\vec p}\\dagg c_{\\vec p} - b_{\\vec p}\\dagg b_{\\vec p}\\right)} \\coloneqq N_c - N_b\n\\end{align}\nWe can also calculate the Hamiltonian;\n\\begin{equation}\n\\text{H} = \\int{\\frac{\\ud^3 p}{(2\\pi)^3} E_p \\left(b\\dagg_{\\vec p} b_{\\vec p} + c_{\\vec p}\\dagg c_{\\vec p}\\right)}\n\\end{equation}\nfrom which we may deduce\\footnotemark that $\\left[\\hamilt, Q\\right] = 0$. In the free theory, it is true that $N_{c}$ and $N_{b}$ are conserved separately, however in the interacting theory (with the requisite symmetry), the total charge $Q$ still is.\n\\footnotetext{Define $B_{\\vec p} \\coloneqq b_{\\vec p}\\dagg b_{\\vec p}$ and $C_{\\vec p} \\coloneqq c_{\\vec p}\\dagg c_{\\vec p}$, then;\n\\begin{align*}\n\\left[\\hamilt, Q\\right] &= \\int{\\frac{\\ud^3 p \\ud^3 q}{(2\\pi)^6}E_{p}\\left[B_{\\vec p} + C_{\\vec p}, C_{\\vec q} - B_{\\vec q}\\right]} \\\\\n&= \\int{\\frac{\\ud^3 p \\ud^3 q}{(2\\pi)^6}E_{p}\\left(\\left[C_{\\vec p}, C_{\\vec q}\\right] - \\left[B_{\\vec p}, B_{\\vec q}\\right]\\right)}\n\\end{align*}\nNow, $\\left[B_{\\vec p}, B_{\\vec q}\\right] = b_{\\vec p}\\dagg b_{\\vec p}b_{\\vec q}\\dagg b_{\\vec q} - b_{\\vec q}\\dagg b_{\\vec q}b_{\\vec p}\\dagg b_{\\vec p} = b_{\\vec p}\\dagg \\left[b_{\\vec p}, b_{\\vec q}\\dagg\\right] b_{\\vec q} - b_{\\vec q}\\dagg \\left[b_{\\vec q}, b_{\\vec p}\\dagg\\right] b_{\\vec p}$, so;\n\\begin{equation*}\n\\left[\\hamilt, Q\\right] = \\int{\\frac{\\ud^3 p \\ud^3 q}{(2\\pi)^3}E_p \\delta^{(3)}(\\vec p - \\vec q)\\left(c_{\\vec p}\\dagg c_{\\vec q} - c_{\\vec q}\\dagg c_{\\vec p} - b_{\\vec p}\\dagg b_{\\vec q} + b_{\\vec q}\\dagg b_{\\vec p}\\right)}\n\\end{equation*}\nwhich vanishes on integrating $\\ud^3 p \\ud^3 q$.\n}\n\\subsection{The Heisenberg Picture\\index{picture!Heisenberg}}\nSo far in the Schr{\\\"o}dinger picture\\index{picture!Schr{\\\"o}dinger}, $\\phi(\\vec x)$ does not depend on time. In the Heisenberg picture all the time dependence is assigned to the operators;\n\\begin{equation}\n\\mO_{\\hamilt}(t) = e^{iHt} \\mO_{\\mathcal{S}} e^{-iHt} \\Rightarrow \\frac{\\ud \\mO_{\\hamilt}(t)}{\\ud t} = i\\left[\\hamilt, \\mO_{\\hamilt}\\right]\n\\end{equation}\nThen the Heisenberg fields now satisfy equal time commutation relations;\n\\begin{equation}\n\\left[\\phi(\\vec x, t), \\phi(\\vec y, t)\\right] = \\left[\\pi(\\vec x, t), \\pi(\\vec y, t)\\right] = 0\n\\end{equation}\n\\begin{equation}\n\\left[\\phi(\\vec x, t), \\pi(\\vec y, t)\\right] = i\\delta^{(3)}(\\vec x - \\vec y)\n\\end{equation}\n\n\n\n\n\n\n\n\n\n\n%\\end{multicols*}", "meta": {"hexsha": "26c2426bbee2c7bc7b6ee8056cece294a9620a20", "size": 29481, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Part III/Revision Notes/qft.tex", "max_stars_repo_name": "james-alvey-42/LectureNotes", "max_stars_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Part III/Revision Notes/qft.tex", "max_issues_repo_name": "james-alvey-42/LectureNotes", "max_issues_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Part III/Revision Notes/qft.tex", "max_forks_repo_name": "james-alvey-42/LectureNotes", "max_forks_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-10-26T17:48:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-26T17:48:29.000Z", "avg_line_length": 83.2796610169, "max_line_length": 1100, "alphanum_fraction": 0.6883077236, "num_tokens": 10360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.440476969739253}}
{"text": "\\documentclass[10pt]{report}\n\n\\usepackage{subcaption} % for subfigures\n\\usepackage{amsthm} % for QED\n%\\usepackage{algpseudocode} % for pseudo-code\n\\usepackage{mathtools} % for delimiter\n\n\\usepackage{listings} % for code\n\\lstset\n{\n\tlanguage=Matlab,\n\tframe=single,\n\tbasicstyle=\\footnotesize,\n\tcaptionpos=b,\n\tnumbers=left,\n\tstepnumber=1,\n\tshowstringspaces=false,\n\ttabsize=4,\n\tbreaklines=true,\n\tbreakatwhitespace=false,\n}\n\n\\usepackage{siunitx} % for scientific notation\n% for `e' in scientific notation\n\\sisetup{output-exponent-marker=\\ensuremath{\\mathrm{e}}}\n\n\\usepackage{float} % for figure [H]\n\\usepackage{booktabs} % for tabular\n\\usepackage{caption} % for \\caption*\n\\usepackage[export]{adjustbox} % for valign=t\n\\usepackage{array} % for column type m\n\\usepackage{verbatim}\n\\usepackage{graphicx}\n\\graphicspath{ {imgs/} }\n\\usepackage{fancyhdr}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n%%%%%% Pagination\n\\setlength{\\topmargin}{-.3 in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\evensidemargin}{0in}\n\\setlength{\\textheight}{9.in}\n\\setlength{\\textwidth}{6.5in}\n\n%Title page\n\\newcommand{\\hwTitle}{Homework \\#1}\n\\newcommand{\\hwCourse}{Numerical Differential Equations/Computational Mathematics II}\n\\newcommand{\\hmwkClassInstructor}{Professor Shuwang Li}\n\n\\title{\n\t\\vspace{2in}\n\t\\textmd{\\textbf{\\hwCourse\\\\\\hwTitle}}\\\\\n\t\\vspace{0.3in}\\large{\\textit{\\hmwkClassInstructor}}\n\t\\vspace{3in}\n}\n\n%\\title{Homework 1}\n\\author{\\textbf{Zhihao Ai}}\n\\date{}\n\n%Header setting. \n\\pagestyle{fancy}\n\\fancyhead[L]{Zhihao Ai}\n\\fancyhead[C]{Math 478}\n\\fancyhead[R]{Homework 1}\n%%%%%%\n\n%Global setting.\n\\everymath{\\displaystyle}\n\\setlength\\parindent{0pt}\n\n%Custom general commands.\n\\newcommand{\\ds}{\\displaystyle}\n\\newcommand{\\f}[1] {f\\left(#1\\right)}\n\\newcommand{\\eva}[2] {\\left. #1 \\right|_{#2}}\n\\newcommand{\\dintt}[4] {\\int_{#1}^{#2} #3 d#4}\n\n\\newcolumntype{M}[1]{>{\\centering\\arraybackslash}m{#1}}\n\\newcolumntype{C}{M{3em}}\n\\newcolumntype{D}{M{5em}}\n\n\\DeclarePairedDelimiter{\\paren}{(}{)}\n\\newcommand{\\abs}[1] {\\left| #1 \\right|}\n\n%Custom local commands\n\\newcommand{\\varQa} {\\sqrt{\\frac{3}{5}}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Question 1.}\n\\begin{enumerate}\n\t\\item \n\t(Section 6.1 Problem 23)\\\\\n\tConsider the data\n\t\\\\\n\t\\[\n\t\t\\begin{tabular}{l M{5em} M{2em} M{5em}} \n\t\t\t\\toprule\n\t\t\t$x$ & $-\\sqrt{\\frac{3}{5}}$ & $0$ & $\\sqrt{\\frac{3}{5}}$ \\\\ \\addlinespace[0.4em]\n\t\t\t\\hline \\addlinespace[0.4em]\n\t\t\t$f(x)$ & $\\f{-\\sqrt{\\frac{3}{5}}}$ & $f(0)$ & $\\f{\\sqrt{\\frac{3}{5}}}$ \\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}\n\t\\]\n\t\\\\\n\tWhat are the Newton interpolation polynomial and the Lagrange interpolation polynomial for these data?\n\t\n\tNewton:\n\t\\[\n\tc_k = \\frac{y_k - p_{k-1}(x_k)}{(x_k-x_0)(x_k-x_1)\\cdots(x_k-x_{k-1})}\n\t\\]\n\t\\begin{align*}\n\t\tc_0 &= \\f{-\\sqrt{\\frac{3}{5}}} \n\t\t\t& p_0(x)\n\t\t\t&= c_0\n\t\t\t\\\\\n\t\tc_1 \n\t\t\t&= \\frac{\\f{0} - p_0(0)}{0 - \\paren*{-\\sqrt{\\frac{3}{5}}}} \n\t\t\t& p_1(x)\n\t\t\t&= c_0 + c_1 \\paren*{x - \\paren*{-\\sqrt{\\frac{3}{5}}}}\n\t\t\t\\\\\n\t\tc_2 \n\t\t\t&= \\frac{\\f{\\sqrt{\\frac{3}{5}}} - p_1\\paren*{\\sqrt{\\frac{3}{5}}}}{\\paren*{\\sqrt{\\frac{3}{5}} - \\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{\\sqrt{\\frac{3}{5}} - 0}} \n\t\t\t& p_2(x)\n\t\t\t&= c_0 + c_1\\paren*{x-\\paren*{-\\sqrt{\\frac{3}{5}}}} + c_2\\paren*{x-\\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{x-0}\n\t\\end{align*}\n\t\n\tLagrange:\n\t\\[\n\tl_i(x) = \\prod_{\\substack{j=0 \\\\ j\\ne i}}^{n} \\frac{x - x_j}{x_i - x_j}\n\t\\]\n\t\\begin{multline*}\n\tp_2(x) = \\sum_{i=0}^{n} y_i l_i(x)\n\t\t= \\f{-\\sqrt{\\frac{3}{5}}} \\cdot \\frac{\\paren*{x-0} \\paren*{x - \\sqrt{\\frac{3}{5}}}}{\\paren*{-\\sqrt{\\frac{3}{5}} - 0} \\paren*{-\\sqrt{\\frac{3}{5}} - \\sqrt{\\frac{3}{5}}}}\n\t\t+ \\f{0} \\cdot \\frac{\\paren*{x - \\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{x - \\sqrt{\\frac{3}{5}}}}\n\t\t {\\paren*{0 - \\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{0 - \\sqrt{\\frac{3}{5}}}}\n\t\t \\\\\n\t\t+ \\f{\\sqrt{\\frac{3}{5}}} \\cdot \\frac{\\paren*{x - \\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{x-0}} {\\paren*{\\sqrt{\\frac{3}{5}} - \\paren*{-\\sqrt{\\frac{3}{5}}}} \\paren*{\\sqrt{\\frac{3}{5}} - 0}}\n\t\\end{multline*}\n\t\n\t\\item \n\t(Section 6.1 Problem 15)\\\\\n\tWhat is the final value of $v$ in the algorithm shown?\n\t\n\t$v \\leftarrow c_{i-1}$\\\\\n\t\\textbf{for} $j = i$ \\textbf{to} $n$ \\textbf{do}\\\\\n\t\\hspace*{4ex} $v \\leftarrow vx + c_j$\\\\\n\t\\textbf{end do}\n\t\n\tWhat is the number of additions and substractions involved in this algorithm?\n\t\\begin{align*}\n\t\tv &= ((((c_{i-1}x + c_i)x + c_{i+1})x + c_{i+2})x + \\cdots c_{n-1})x + c_n\\\\\n\t\t\t&= c_{i-1}x^{n-i+1} + c_ix^{n-i} + \\cdots + c_{n-1}x + c_n\n\t\\end{align*}\n\tThe number of additions is $n-i+1$; no substractions are involved.\n\t\n\t\\item \n\t(Section 6.1 Problem 16)\\\\\n\tWrite an efficient algorithm for evaluating\n\t\\[\n\tu = \\sum_{i=1}^{n} \\prod_{j=1}^{i} d_j\n\t\\]\n\t$u \\leftarrow d_{n}$\\\\\n\t\\textbf{for} $i = n-1$ \\textbf{to} $1$ \\textbf{step} $-1$ \\textbf{do}\\\\\n\t\\hspace*{4ex} $u \\leftarrow d_i*(1+u)$\\\\\n\t\\textbf{end do}\n\\end{enumerate}\n\n\\section*{Question 2.}\n(Section 6.1 Problem 13)\\\\\nProve that if we take \\textit{any} set of 23 nodes in the interval $[-1, 1]$ and interpolate the function $f(x) = \\cosh{x}$ with a polynomial $p$ of degree 22, then the relative error $\\abs{p(x)-f(x)}/\\abs{f(x)}$ is no greater than $5 \\times 10^{-16}$ on $[-1, 1]$.\n\nDenote the nodes as $x_i, i=0,1,\\cdots,22$. According to Theorem 2,\n\\[\nf(x) - p(x) = \\frac{1}{(n+1)!} \\cdot f^{(n+1)}(\\xi_x) \\cdot \\prod_{i=0}^{n} (x-x_i)\n\t= \\frac{1}{23!} \\cdot f^{(23)}(\\xi_x) \\cdot \\prod_{i=0}^{22} (x-x_i)\n\\]\nSince $f^{(23)}(\\xi_x) = \\sinh{\\xi_x}$, which increases monotonically,\n\\[\nf^{(23)}(\\xi_x) < \\sinh{1},\\ \\xi_x\\in [-1, 1]\n\\]\nSince $x\\in [-1, 1]$,\n\\[\n\\prod_{i=0}^{22} (x-x_i) \\le \\prod_{i=0}^{22} 2 = 2^{23}\n\\]\nSince $\\cosh{x} \\ge 1, f(x)\\ge 1$. Therefore,\n\\[\n\\frac{\\abs{p(x)-f(x)}}{\\abs{f(x)}} < \\frac{\\frac{1}{23!} \\cdot \\sinh{1} \\cdot 2^{23}}{1}\n\t\\approx 3.81336\\times 10^{-16}\n\t< 5 \\times 10^{-16}\n\\]\n\\qed\n\n\\section*{Question 3.}\n(Section 6.2 Problem 24)\\\\\nWrite the Newton interpolating polynomial for these data:\n%\\\\\n\\[\n\t\\begin{tabular}{lcccc} \n\t\t\\toprule\n\t\tx & 4 & 2 & 0 & 3 \\\\ \\midrule\n\t\tf(x) & 63 & 11 & 7 & 28 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\]\n\\\\\nBy Theorem 1,\n\\[\t\nf[x_0, x_1, \\cdots, x_n] = \\frac{f[x_1, x_2, \\cdots, x_n] - f[x_0, x_1, \\cdots, x_{n-1}]}{x_n - x_0}\n\\]\nwe get the divided differences table:\n\\[\n\\begin{array}{cc|ccc}\n4 & 63 & 26 & 6 & 1 \\\\\n2 & 11  & 2   & 5 \\\\\n0 & 7   & 7 \\\\\n3 & 28\n\\end{array}\n\\]\nTherefore the Newton polynomial is\n\\[\np(x) = 63 + 26(x-4) + 6(x-4)(x-2) + (x-4)(x-2)x\n\\]\n\n\\section*{Question 4.}\n\\begin{enumerate}\n\t\\item \n\t(Section 6.4 Problem 14)\\\\\n\tDetermine whether this function is a natural cubic spline:\n\t\\[\n\tf(x) = \n\t\\begin{cases}\n\t\t1+x-x^3, &x\\in [0,1]\\\\\n\t\t1-2(x-1)-3(x-1)^2+4(x-1)^3, &x\\in [1,2]\\\\\n\t\t4(x-2)+9(x-2)^2-3(x-2)^3, &x\\in [2,3]\\\\\n\t\\end{cases}\n\t\\]\n\tBy inspection, the order of $f(x)$ is no greater than 3.\\\\\n\tThe first derivative of $f(x)$ is continuous:\n\t\\[\n\tf'(x) = \n\t\\begin{cases}\n\t1-3x^2, &x\\in [0,1]\\\\\n\t-2-6(x-1)+12(x-1)^2, &x\\in [1,2]\\\\\n\t4+18(x-2)-9(x-2)^2, &x\\in [2,3]\\\\\n\t\\end{cases}\n\t\\]\n\tThe second derivative of $f(x)$ is also continuous:\n\t\\[\n\tf''(x) = \n\t\\begin{cases}\n\t-6x, &x\\in [0,1]\\\\\n\t-6+24x, &x\\in [1,2]\\\\\n\t18-18(x-2), &x\\in [2,3]\\\\\n\t\\end{cases}\n\t\\]\n\tDefine $S_i(x),\\ i=0,1,2$ as the sub-functions of $f(x)$ on $[0,1], [1,2], [2,3]$, respectively.\n\t\\begin{align*}\n\t\tS_0(1) &= 1 = S_1(1) & S_1(2) &= 0 =S_2(2)\\\\\n\t\tS_0'(1) &= -1 = S_1'(1) & S_1'(2) &= 4 =S_2'(2)\\\\\n\t\tS_0''(1) &= -6 = S_1''(1) & S_1''(2) &= 18 =S_2''(2)\n\t\\end{align*}\n\tAlso we have\n\t\\[\n\tf''(0) = f''(3) = 0\n\t\\]\n\tTherefore, this function is a natural cubic spline.\n\t\n\t\\item \n\t(Section 6.4 Problem 20)\\\\\n\tDetermine whether the coefficients $a, b, c,$ and $d$ exist so that the function\n\t\\[\n\tS(x) = \n\t\\begin{cases}\n\t1-2x, &x\\in (-\\infty,-3]\\\\\n\ta+bx+cx^2+dx^3, &x\\in [-3,4]\\\\\n\t157-32x, &x\\in [4,+\\infty)\\\\\n\t\\end{cases}\n\t\\]\n\tis a natural cubic spline for the interval $[-3, 4]$.\n\t\n\tTake the first and second derivatives of $S(x)$ and we have\n\t\\[\n\tS'(x) = \n\t\\begin{cases}\n\t-2, &x\\in (-\\infty,-3]\\\\\n\tb+2cx+3dx^2, &x\\in [-3,4]\\\\\n\t-32, &x\\in [4,+\\infty)\\\\\n\t\\end{cases}\n\t,\\ \n\tS''(x) = \n\t\\begin{cases}\n\t0, &x\\in (-\\infty,-3]\\\\\n\t2c+6dx, &x\\in [-3,4]\\\\\n\t0, &x\\in [4,+\\infty)\\\\\n\t\\end{cases}\n\t\\]\n\tFor $S(x)$ to be a natural cubic spline, we need to satisfy\n\t\\[\n\t\\begin{cases}\n\tS_0(-3) = S_1(-3)\\\\\n\tS_0'(-3) = S_1'(-3)\\\\\n\tS_0''(-3) = S_1''(-3)\\\\\n\tS_1(4) = S_2(4)\\\\\n\tS_1'(4) = S_2'(4)\\\\\n\tS_1''(4) = S_2''(4)\n\t\\end{cases}\n\t\\Rightarrow\n\t\\begin{cases}\n\t7 = a - 3 b + 9 c - 27 d\\\\\n\t-2 = b - 6 c + 27 d\\\\\n\t0 = 2 c - 18 d\\\\\n\ta + 4 b + 16 c + 64 d = 29\\\\\n\tb + 8 c + 48 d = -32\\\\\n\t2 c + 24 d = 0\n\t\\end{cases}\n\t\\]\n\tThis system has no solution, as shown below:\n\t\\[\n\t\\left(\n\t\\begin{array}{@{}cccc|c@{}}\n\t\t1& -3& 9& -27& 7\\\\\n\t\t0& 1& -6& 27& -2\\\\\n\t\t0& 0& 2& -18& 0\\\\\n\t\t1& 4& 16& 64& 29\\\\\n\t\t0& 1& 8& 48& -32\\\\\n\t\t0& 0& 2& 24& 0\n\t\\end{array}\n\t\\right)\n\t\\xRightarrow{\\text{R.R.}}\n\t\\left(\n\t\\begin{array}{@{}cccc|c@{}}\n\t1& 0& 0& 0& 0\\\\\n\t0& 1& 0& 0& 0\\\\\n\t0& 0& 1& 0& 0\\\\\n\t0& 0& 0& 1& 0\\\\\n\t0& 0& 0& 0& 1\\\\\n\t0& 0& 0& 0& 0\n\t\\end{array}\n\t\\right)\n\t\\]\n\tTherefore, such $a,b,c,$ and $d$ do not exist.\n\\end{enumerate}\n\n\\section*{Question 5.}\n(Section 6.1 Problem 37)\\\\\nThe first U.S. postage stamp was issued in 1885, with the cost to mail a letter set at 2 cents. In 1917, the cost was raised to 3 cents but then was returned to 2 cents in 1919. In 1932, it was upped to 3 cents again, where it remained for 26 years. Then a series of increases took place as follows: 1958 = 4 cents, 1963 = 5 cents, 1968 = 6 cents, 1971 = 8 cents, 1974 = 10 cents, 1978 = 15 cents, 1981 = 18 cents in March and 20 cents in October, 1985 = 22 cents, 1988 = 25 cents, 1991 = 29 cents, 1995 = 32 cents, 1999 = 33 cents, and 2001 = 34 cents. Determine the Newton interpolation polynomial for these data. Based on this, when will it cost \\$1 to mail a letter? When will it cost \\$10?\n\nThe following code is for calculating the coefficients and each $p(x)$:\n\\lstinputlisting[caption={Coefficients}]{coefficients.m}\n\\lstinputlisting[caption={Newton interpolation polynomial}]{newtonPoly.m}\nThe code below is for displaying coefficients and years when it will cost \\$1 and \\$10.\n\\lstinputlisting[caption={Find the year}]{q5p37stamp.m}\n\nIt produces the coefficent vector \n\\begin{multline*}\nd=[2,\n0.03125,\n-0.015625,\n1.15077741e-03,\n-2.89440714e-05,\n6.78486768e-07,\n-1.52159492e-08,\\\\\n8.18727496e-10,\n-9.10167759e-11,\n9.40668614e-12,\n-9.18167360e-13,\n1.69879421e-13,\\\\\n-2.96877259e-14,\n3.92879060e-15,\n-3.91394609e-16,\n2.83733707e-17,\n-1.60579668e-18,\\\\\n8.19150612e-20]\n\\end{multline*}\nTherefore, the Newton interpolation polynomial is\n\\begin{multline*}\n\tp(x) = 2 + 0.03125(x-1885) - 0.015625(x-1885)(x-1917) + \\cdots +\n\t\\\\ 8.19150612e-20(x-1885)(x-1917)\\cdots(x-1999)(x-2001)\n\\end{multline*}\nBy this interpolation polynomial, it costs \\$1 to mail a letter in 2001.030137, which is in January, 2001; it cost \\$10 in 2001.309589, which is in April, 2001.\n\n\\section*{Computer Assignment}\n(Section 6.1 Problem 36)\\\\\nThe function $1/(1+x^2)$ and $e^{-x^2}$ have a similar appearance. Do they behave similarly in the interpolation process for equally spaced nodes?\\\\\nUse the Newton interpolating polynomial $p_n(x)$ with $n=5,10,15$ on $[-5, 5]$. In each case, compute the error $f(x) - p_n(x)$ for $N = 30$ equally spaced points on $[-5, 5]$. Comment on what you get.\n\\lstinputlisting[caption={Interpolation on {$[-5,5]$}}]{interp.m}\n\\lstinputlisting[caption={Plotting functions and calculating errors}]{runge.m}\nDenote $1/(1+x^2)$ as $f_a(x)$ and $e^{-x^2}$ as $f_b(x)$. The code above produces the following plots:\n\\begin{figure}[H]\n\t\\centering\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{functiona.jpg}\n\t\t\\caption*{$f_a(x)$ and its polynomial interpolations}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{functionb.jpg}\n\t\t\\caption*{$f_b(x)$ and its polynomial interpolations}\n\t\\end{subfigure}%\n\\end{figure}\nThe errors for $N = 30$ equally spaced points on $[-5, 5]$ are:\n\\begin{align*}\n\tf_a(x) - p_{5}(x) &= 1.257120 & f_b(x) - p_{5}(x) &= 1.416331\\\\\n\tf_a(x) - p_{10}(x) &= -4.711533 & f_b(x) - p_{10}(x) &= -5.689687\\\\\n\tf_a(x) - p_{15}(x) &= -2.607657 & f_b(x) - p_{15}(x) &= -2.487981\n\\end{align*}\nThe interpolation process for equally spaced nodes for function $1/(1+x^2)$ and $e^{-x^2}$ behave similarly. For each function, the interpolating polynomial of degree 5 does not fit the curve well at the center, but on the other hand it is relatively close to the curve at the edges. In contrast, even though the polynomials of higher degree like $p_{10}(x)$ and $p_{15}(x)$ fit the curve nicely around the center, they oscillate dramatically at the edges of the interval, leading to errors even greater than the polynomial of degree 5. The comparison clearly demostrates Runge's phenomenon, which means using polynomials of high degree for interpolation can introduce much error.\n\n\\end{document}\n\n\n", "meta": {"hexsha": "fedfcec013cebad01d6c6a3a19a11588432df9eb", "size": 12784, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW1/Math-478-HW1.tex", "max_stars_repo_name": "ZhihaoAi/MATH-478-Assignments", "max_stars_repo_head_hexsha": "d0d758fbf52057c97dea4150630beeffa87fa49a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW1/Math-478-HW1.tex", "max_issues_repo_name": "ZhihaoAi/MATH-478-Assignments", "max_issues_repo_head_hexsha": "d0d758fbf52057c97dea4150630beeffa87fa49a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW1/Math-478-HW1.tex", "max_forks_repo_name": "ZhihaoAi/MATH-478-Assignments", "max_forks_repo_head_hexsha": "d0d758fbf52057c97dea4150630beeffa87fa49a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6570743405, "max_line_length": 694, "alphanum_fraction": 0.6196026283, "num_tokens": 5437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.4404698541829307}}
{"text": "\\documentclass{article}\n\\usepackage{ws_template}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{a4wide}\n\\usepackage{graphicx}\n\\usepackage{booktabs}\n\n\\title{homework sheet 04}\n\n\\author{\n\t\\name{Denys Sobchyshak}\\\\\n\t\\imat{03636581}\\\\\n\t\\email{denys.sobchyshak@gmail.com}\n\t\\And\n\t\\name{Sergey Zakharov}\\\\\n\t\\imat{03636642}\\\\\n\t\\email{ga39pad@mytum.de}\n}\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Still refreshing}\n\\textbf{Problem 1:} \\\\\\\\\n\t Let X represent the number of flips which were made. Then the possible values of X\n\tare $1, 2, ... ,$ and the distribution function of X is deﬁned by.\n\t\\[ m(i) =\\frac{1}{2^i} \\]\n\tThus,\n\t\\begin{eqnarray*}\n  \tE(X) & = & \\sum_{i=1}^{\\infty}{i \\frac{1}{2^i}} \\\\\n \t  & = & 1+ \\frac{1}{2} +\\frac{1}{2^2} + \\dots \\\\\n  \t & = & 2\n\t\\end{eqnarray*}\n\n\tSo, the expected number of flips until one head is thrown is 2. \\\\\n\tNow, Let T represent the expexted number of tails. The possible values of T are 0, 1 and 2. The corresponding probabilities are 1/4, 1/2 and 1/4. Thus,\n\t\\[ E(T) = 0(\\frac{1}{4}) + 1(\\frac{1}{2}) + 2 (\\frac{1}{4}) = 1\\]\n\tThe expected number of heads equals to the expected number of tails $E(T) = E(H) = 1$\n\n\\section{Parameter Estimation}\n\\subsection{Coins}\n\\textbf{Problem 2:}\\\\\\\\\n\tThe likelihood function $L(\\theta)$ is, by definition:\n\t\\begin{eqnarray*}\n  \tL(\\theta) & = &\\prod_{i=i}^{n}{P(X_i = x_i|\\theta)} \\\\\n \t  & = & \\theta^{x_1}(1-\\theta)^{1-x_1} \\times \\theta^{x_2}(1-\\theta)^{1-x_2} \\times \\dots \\times \\theta^{x_n}(1-\\theta)^{1-x_n} \\\\\n  \t & = & \\theta^{\\sum{x_i}}(1-\\theta)^{n-\\sum{x_i}}\n\t\\end{eqnarray*}\nNow, in order to implement the method of maximum likelihood, we need to find the $\\theta$ that maximizes the likelihood $L(\\theta)$.\n\\[ ln L(\\theta) = (\\sum{x_i})ln(\\theta) + (n-\\sum{x_i})ln(1-\\theta) \\]\nDifferentiating with respect to $\\theta$ results in:\n\\[ \\frac{d ln L(\\theta)}{d\\theta} = \\frac{\\sum{x_i}}{\\theta} - \\frac{n-\\sum{x_i}}{1-\\theta} \\]\nSetting the derivative to zero we get:\n\\begin{eqnarray*}\n(\\sum{x_i})(1- \\theta) - (n-\\sum{x_i})\\theta = 0 \\\\\n\\sum{x_i} - n\\theta = 0\n\\end{eqnarray*}\nTherefore the MLE for $\\theta$ is:\n\\[ \\hat{\\theta} = \\frac{\\sum{x_i}}{n} \\]\n\n\\textbf{Problem 3:}\\\\\\\\\nGiven the observations and $\\alpha$,$\\beta$ as beta distribution parameters we can write the expected posterior mean for $\\mu$ as follows:\n\\[ E_{\\mu}[\\mu|\\mathcal{D}]=\\frac{m+\\alpha}{m+\\ell+\\alpha+\\beta}=\\frac{m}{m+\\ell+\\alpha+\\beta}+\n\\frac{\\alpha}{m+\\ell+\\alpha+\\beta}\\]\nHowever:\n\\[\\frac{m}{m+\\ell+\\alpha+\\beta}=\\frac{\\frac{m}{m+\\ell}}{\\frac{m+\\ell+\\alpha+\\beta}{m+\\ell}}\\]\n\\[\\frac{\\alpha}{m+\\ell+\\alpha+\\beta}=\\frac{\\frac{\\alpha}{\\alpha+\\beta}}{\\frac{m+\\ell+\\alpha+\\beta}{\\alpha+\\beta}}\\]\nSince $\\frac{\\alpha}{\\alpha+\\beta}$ is the prior mean value of $\\mu$ and $\\frac{m}{m+\\ell}$ is the maximum likelyhood estimate we have shown what was being asked.\n\n\\subsection{Poisson distribution}\n\\textbf{Problem 4:}\\\\\\\\\nThe likelihood function is:\n\\[ L(\\lambda) =\\prod_{i=1}^{n}{\\frac{\\lambda^{x_i}e^{-\\lambda}}{x_i !}} = \\frac{\\lambda^{\\sum {x_i}}e^{-\\lambda}}{\\prod{x_i !}} \\]\nThen, taking the natural logarithm, we have:\n\\[ ln L(\\lambda) = \\sum_{i=1}^{n}{x_i ln \\lambda} - n\\lambda - \\sum_{i=1}^{n}{ln(x_i !)} \\]\nDifferentiating with respect to $\\lambda$ results in:\n\\[ \\frac{d ln L(\\lambda)}{d\\lambda} = \\frac{\\sum{x_i}}{\\lambda} - n \\]\nSetting the derivative to zero we get:\n\\[ \\frac{\\sum{x_i}}{\\lambda} - n = 0 \\]\nTherefore the MLE for $\\lambda$ is:\n\\[  \\hat{\\lambda} = \\frac{\\sum{x_i}}{n}\\]\nTo show that the maximum likelihood estimator is an unbiased estimator of $\\lambda$ we have to show that $E(\\hat{\\lambda}) = p$.\n\\[ E(\\hat{\\lambda}) = E() = \\frac{1}{n}\\sum_{i=1}^{n}{E(X_i)} =\\frac{1}{n}\\sum_{i=1}^{n}{p} = \\frac{1}{n}(np) = p \\]\nThus, the estimator is unbiased.\t\n\t\n\\end{document}\n\n", "meta": {"hexsha": "d888be33fda09ff9ab659840ed702f3205fe053e", "size": 3754, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tum/machine-learning/ws04-mle.tex", "max_stars_repo_name": "nyxcalamity/classwork", "max_stars_repo_head_hexsha": "dfe47a40fe57ec5e0ccfd672a8dcaf246386de99", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2017-02-10T19:12:21.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-03T00:08:40.000Z", "max_issues_repo_path": "tum/machine-learning/ws04-mle.tex", "max_issues_repo_name": "nyxcalamity/classwork", "max_issues_repo_head_hexsha": "dfe47a40fe57ec5e0ccfd672a8dcaf246386de99", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tum/machine-learning/ws04-mle.tex", "max_forks_repo_name": "nyxcalamity/classwork", "max_forks_repo_head_hexsha": "dfe47a40fe57ec5e0ccfd672a8dcaf246386de99", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2016-05-02T11:00:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T03:55:35.000Z", "avg_line_length": 41.7111111111, "max_line_length": 162, "alphanum_fraction": 0.6353223229, "num_tokens": 1387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381372136563, "lm_q2_score": 0.8056321959813274, "lm_q1q2_score": 0.4404698461101782}}
{"text": "\\section{Solving and Estimating the Extended Model}\n\n\\subsection{Solution}\n\nFor this extended model I only use the Double Deep Q-Network agent, since it was shown with the simpler environment, to have comparable performance to the VFI implementation and Deep Q-network. The model is solved by running 3000 episodes. As was true for the simple model, the neural network has the best performance if states are scaled mean 0 and a standard deviation of 1. In practice this is done by implementing a transformer in my agent that scales the states.  The transformer is also capable of doing an inverse transformation. The rewards are also scaled. This slightly improves performance, but the primary reason is, that it helps track the learning. I scale the rewards to have a variance of about 1, and let them have the same mean conditional of the $\\beta_L$  value! I train the algorithm for 3000 episodes, have the hyper parameters of the algorithm being: $\\gamma=0.99$ representing the impatience of the agent. The agent is initialized with $\\epsilon=1.0$ which decays by $0.9999$ for each step the agent performs. The learning rate is $\\alpha=0.0005$. The size of the memory buffer is one million rows, and I train with a batch size=64. I let the minimum exploration rate in training be $0.01$.  The architecture of the network is identical to the one used previously: An input layer of same size as the state space, 2 fully connected layers of size 256 with rectified linear units as activation functions, and a linear output layer of the same size as the action space. At the beginning of each episode a random $\\beta_L \\sim Uniform(0, 60)$ is drawn, allowing the agent to step through an episode until termination with given $\\beta_L$. Finally the target network inherits the policy weights every $100$'th step. A score for every 50'th episode is calculated, taking the average of the previous 50 episodes. If the current iteration of the model beats the high score, the weights of the neural network is saved. The estimation and simulation is performed with the weights that yields the highest score for 50 consecutive episodes. \n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[scale=0.4]{figures/ddqn_extended_model_training_performance.png}\n    \\caption{Training Performance of Double DQN Agent - Extended Model}\n    \\label{fig:training_extended}\n\\end{figure}\n\nLooking to figure \\ref{fig:training_extended} the agent clearly learns to navigate in the environment. After about 1000 episodes the agent seems to have learned to navigate the environment! The maximum score appears at around episode 1400, which is the weights used for estimation and simulations. The asymptotic training performance is about 177 comparing to an initial score of approximately zero.\n\n\\subsection{Estimation}\n\nAs was the case with the simpler model, only a single parameter $\\beta_L$ needs to be estimated. Again, just as was the case before with the simpler model, I extend the state space to contain $\\beta_L$. I use a grid search in the range $\\beta_L \\in [0, 60]$, simulating $N=800$ observations, calculating the objective function. I use the same seed in each iteration of the optimization process. To address the short comings of the simple model, I expand the objective function of the optimization problem. In the initial model too many women choose not to be part of the labour force yielding unrealistic results. In response to this problem the new objective function extends to two broad goals: Let the right number of women be out of the labour force (around 15 \\%) and fit the curve of number of working hours for women. The first objective, \\textit{objective 1}, is formulated as: \n\n\\begin{equation}\n    \\text{objective 1} = \\lsp\\frac{\\sum_{i=1}^{N} \\sum_{q=Q_{\\min}}^{Q_{\\max}} \\mathbf{1}\\{H_{i,q} = 0\\}}{ N \\cdot (Q_{\\max} - Q_{\\min} )} - 15\\% \\rsp^2\n\\end{equation}\n\nThe second objective is formulated the same way as it was when first estimating the simple model, which correspond the conditional expectation of supplied number of working hours conditional on the age and of being in the labour force $ \\E[H \\mid Q=q, H>0]$. The desired outcome is for this to be true for all ages from 18 to 60. $\\mu_q$ is the empirical moment found using the data \\textbf{LIGEF15}:\n\n\\begin{equation}\n    \\text{Objective 2} = \\sum_{q=Q_{\\min}}^{Q_{\\min}} \\lsp \\mu_q  - \\frac{1}{\\sum_{i=1}^{N} \\mathbf{1}\\{H_{i,q} > 0\\}}\\sum_{i=1}^N (H_{i,q})\\rsp^2\n\\end{equation}\nThe description of the objectives can be translated into a more formal formulation. The number of moments are $\\#_{moments} = 1 + (Q_{\\max} - Q_{\\min}) = 1 + 60 - 18 = 43$. The weighing of these moments would usually be done by some weight matrix $W$ in an equation of the form: $[\\hat{m} - \\tilde{m}]^{\\top} W^{-1} [\\hat{m} - \\tilde{m}]$, where $\\tilde{m}$ is a vector of empirical moments and $\\hat{m}$ is a vector of simulated moments allowing for the methods of moments estimation. The choosing of the weight matrix is application specific. \\textcite{eisenhauer_estimation_2015} suggests the choice in that setting should be the inverse variance of the empirical moments $\\tilde{m}_j$, on the diagonal of the weight matrix (zeros else), letting the $j$'th moment correspond to the $j$'th weight. This is however not possible in this application, due to the fact, that I only have access to aggregated data from statistics Denmark. Instead, I manually choose scales such that \\textit{objective 1} is equally weighted to \\textit{objective 2}. This first and foremost requires a scaling of the moments. And secondly, all this requires a re-weighing since there are 42 moments composing \\textit{objective 2} and only a single moment composing \\textit{objective 1}. Since the distance between the empirical and the simulated moment is squared, the scaling must be performed before the squaring. Finally, since the weight matrix is chosen as it is, a transformation can be performed such that instead of a matrix product it can be considered a sum: $\\sum_{j = 1}\n^{43} ( \\hat{m}_j - \\tilde{m}_j )^2$, becoming a mean squared error optimization problem. It is implied that $N$ agents is simulated conditional on a value of $\\beta_L$. The objective function is:\n\n\\begin{multline}\n   \\text{Objective}(\\beta_L) =  \\lsp 37 \\cdot \\lp\\frac{\\sum_{i=1}^{N} \\sum_{q=Q_{\\min}}^{Q_{\\max}} \\mathbf{1}\\{H_{i,q} = 0\\}}{ N \\cdot (Q_{\\max} - Q_{\\min} )} - 15\\% \\rp \\rsp^2 \\\\ + \\frac{1}{Q_{\\max} - Q_{\\min}}\\sum_{q=Q_{\\min}}^{Q_{\\max}} \\lsp \\mu_q - \\frac{1}{\\sum_{i=1}^{N} \\mathbf{1}\\{H_{i,q} > 0\\}}\\sum_{i=1}^N (H_{i,q})\\rsp^2\n\\end{multline}\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[scale=0.4]{figures/ddqn_extended_model_estimation_beta_L.png}\n    \\caption{Estimation of $\\beta_L$ for the Extended Model}\n    \\label{fig:estimation_extended}\n\\end{figure}\n\nThe estimated value of $\\beta_L = 24.49$. Figure \\ref{fig:estimation_extended} shows the grid search, and finds that optimization problem, contains a minimum at $\\beta_L = 24.49$, suggesting that the range of the grid is adequate for the estimation problem. I take the $\\log (\\cdot)$ of the mean squared error to better represent it in figure \\ref{fig:estimation_extended}.", "meta": {"hexsha": "862a079ddf219ea69b38318df1495210220df65c", "size": 7177, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/model2_solution_estimation.tex", "max_stars_repo_name": "JakartaLaw/speciale", "max_stars_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/model2_solution_estimation.tex", "max_issues_repo_name": "JakartaLaw/speciale", "max_issues_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/model2_solution_estimation.tex", "max_forks_repo_name": "JakartaLaw/speciale", "max_forks_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 166.9069767442, "max_line_length": 2053, "alphanum_fraction": 0.7553295249, "num_tokens": 1891, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4404504795421454}}
{"text": "\\documentclass{parcfd2015}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\n\\title{PetIBM - A PETSc-based Immersed Boundary Method code}\n\n\\author{OLIVIER P. MESNARD$^{*}$, ANUSH KRISHNAN$^{*}$ \\\\ AND LORENA A. BARBA$^{*}$}\n\n\\heading{Olivier P. Mesnard, Anush Krishnan and Lorena A. Barba}\n\n\\address{$^{*}$ Mechanical and Aerospace Engineering, The George Washington University\\\\\nWashington, DC, 20052, United-States\\\\\ne-mail: mesnardo@gwu.edu, web page: lorenabarba.com}\n\n\\keywords{Immersed Boundary Method, PETSc, flying snake}\n\n\\abstract{A new, open-source \\texttt{PETSc}-based immersed boundary method code is under development that uses a fully discrete projection formulation. Its initial purpose is to study the three-dimensional flow around an accurate cross-sectional shape of the flying snake species \\textit{Chrysopelea paradisi}. We analyze vorticity structures in the wake and explain the enhanced lift generation of the snake at a particular angle of attack.}\n\n\\begin{document}\n\\maketitle\n\n\\section{IMMERSED BOUNDARY METHOD}\n\nImmersed boundary methods (IBM) form a class of techniques in computational fluid dynamics where an immersed boundary is represented by a collection of Lagrangian points that do not coincide with the Eulerian grid nodes. They are particularly useful to simulate flows over complex and moving geometries. Simple, structured Cartesian meshes covering the entire physical domain (including the solid region) can be used, requiring low memory storage. The governing equations are solved over the whole domain and the key is finding a way to incorporate the boundary conditions on the immersed surface.\n\nWe use the method proposed by Taira and Colonius \\cite{Taira_Colonius_2007} in which the momentum equations are augmented by a forcing term that acts as a Lagrange multiplier to bring the fluid to rest in the vicinity of the body surface. The fully-discrete modified Navier-Stokes equations produce an algebraic system that is solved via a projection method by performing a block LU decomposition \\cite{Perot_1993}.\n\n\\section{PETIBM}\n\nWe use the open-source library \\texttt{PETSc} \\cite{PETSc_webpage_2014} to build the IBM code, taking advantage of its efficient data structures and routines to solve partial differential equations on multi-CPUs. The \\texttt{PETSc} data structure \\textit{distributed array} allows us to perform a logically Cartesian decomposition, such that nodal values spatially close in the physical domain are stored on the same process, thus, minimizing communications when using finite-difference stencils. Explicit terms of the Navier-Stokes system are stored using \\textit{local vectors} that include ghost-cell values while \\textit{global vectors} are used in sparse linear algebra routines.\n\nThe full code, named \\texttt{PetIBM}, is open-source, released under an MIT License and hosted on the version-controlled platform GitHub \\cite{PetIBM}.\n\n\\section{APPLICATION TO FLYING SNAKES}\n\nWe study the aerodynamics of the \\textit{Chrysopelea paradisi}, a species of flying snake. Previous experimental work \\cite{Holden_et_al_2014} reported enhanced lift force on a snake gliding at angle of attack of $35^o$ for flows with Reynolds number beyond $9000$. Two-dimensional numerical investigations confirmed a spike in the lift curve at this particular angle of attack ($Re=2000$) \\cite{Krishnan_et_al_2014}. Using \\texttt{PetIBM}, we aim to understand the three-dimensional wake structures responsible for high gliding performances of the paradise tree snake.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=8cm]{images/flying_snake_petibm.png}\n\\caption{Contours of the spanwise (red and blue) and streamwise (grey) components of the vorticity shed in the wake of an infinitely long cylinder with cross-section of the \\textit{Chrysopelea paradisi}.}\n\\label{flying_snake_petibm}\n\\end{figure}\n\n\\begin{thebibliography}{99}\n\\bibitem{PETSc_webpage_2014} Balay S., Abhyankar S., Adams M.F., Brown J., Brune P., Buschelman K., Eijkhout V., Gropp W.D., Kaushik D., Knepley M.G., Curfman McInnes L., Rupp K., Smith B.F. and Zhang H. PETSc Web page. \\texttt{http://www.mcs.anl.gov/petsc} (2014).\n\\bibitem{Holden_et_al_2014} Holden D., Socha J.J., Cardwell N.D. and Vlachos P.P. Aerodynamics of the flying snake Chrysopelea paradisi: how a bluff body cross-sectional shape contributes to gliding performance. \\textit{J. Exp. Biol.} (2014) \\textbf{217}:382--394.\n\\bibitem{PetIBM} Krishnan A. and Barba L.A. PetIBM - A 3D and parallel PETSc-based immersed boundary method code. \\texttt{https://www.github.com/barbagroup/PetIBM}.\n\\bibitem{Krishnan_et_al_2014} Krishnan A., Socha J.J., Vlachos P.P. and Barba L.A. Lift and wakes of flying snakes. \\textit{Phys. Fluids} (2014) \\textbf{26(3)}:031901.\n\\bibitem{Perot_1993} Perot J.B. An analysis of the fractional step method. \\textit{J. Comp. Phys.} (1993) \\textbf{108(1)}:51--58.\n\\bibitem{Taira_Colonius_2007} Taira K. and Colonius T. The immersed boundary method: A projection approach. \\textit{J. Comp. Phys.} (2007) \\textbf{225(2)}:2118--2137.\n\\end{thebibliography}\n\n\\end{document}\n\n\n", "meta": {"hexsha": "4a5740f3a917c07b30d0894f369dbbd356c3fdd0", "size": 5128, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "parcfd2015/abstract_mesnard_krishnan_barba.tex", "max_stars_repo_name": "barbagroup/conferences", "max_stars_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-01T03:23:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T03:23:03.000Z", "max_issues_repo_path": "parcfd2015/abstract_mesnard_krishnan_barba.tex", "max_issues_repo_name": "barbagroup/conferences", "max_issues_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-05-20T09:32:36.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-20T09:32:36.000Z", "max_forks_repo_path": "parcfd2015/abstract_mesnard_krishnan_barba.tex", "max_forks_repo_name": "barbagroup/conferences", "max_forks_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-12-13T07:09:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-01T03:23:13.000Z", "avg_line_length": 85.4666666667, "max_line_length": 684, "alphanum_fraction": 0.7890015601, "num_tokens": 1370, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.4404504707582041}}
{"text": "\\section{Instance models and instance graphs}\n\\label{sec:transformation_framework:instance_models_and_instance_graphs}\n\nIn the previous section, the structure of the framework was applied to type models and type graphs. In this section, the structure will be applied to instance models and instance graphs. Since instance models and instance graphs directly depend on type models and type graphs, some definitions will be borrowed from the previous section.\n\nFirst, the general structure of the framework applied to instance models and instance graphs is discussed. Then the required definitions and theorems are given.\n\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture} \n    \\path\n    (-3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](ME) {$O$}\n    (-4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MA) {$Im_A$}\n    (-1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MB) {$Im_B$}\n    (-3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](MAB) {$Im_{AB}$}\n    \n    (3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](GN) {$N$}\n    (1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GA) {$IG_A$}\n    (4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GB) {$IG_B$}\n    (3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](GAB) {$IG_{AB}$};\n    \n    \\path[]\t\t\n    (ME) [-, black, out=240, in=90] edge node[above] {} (MA)\n    (ME) [-, black, out=300, in=90] edge node[above] {} (MB)\n    \n    (MA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)\n    (MB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)\n    \n    (GN) [-, black, out=240, in=90] edge node[above] {} (GA)\n    (GN) [-, black, out=300, in=90] edge node[above] {} (GB)\n    \n    (GA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)\n    (GB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)\n    \n    (ME) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f$} (GN)\n    (GN) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (ME)\n    \n    (MA) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_A$} (GA)\n    (GA) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MA)\n    \n    (MB) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_B$} (GB)\n    (GB) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MB)\n    \n    (MAB) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f_{A} \\sqcup f_{B}$} (GAB)\n    (GAB) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (MAB)\n    ;\n    \\end{tikzpicture}\n    \\caption{Structure for transforming between instance models and instance graphs}\n    \\label{fig:transformation_framework:instance_models_and_instance_graphs:structure_instance_models_graphs}\n\\end{figure}\n\n\\cref{fig:transformation_framework:instance_models_and_instance_graphs:structure_instance_models_graphs} shows one more alternation of the structure proposed in \\cref{sec:transformation_framework:structure}. This version of the structure is applied to instance models and instance graphs. As before, instance model $Im_A$ represents the partially build model which corresponds to instance graph $IG_A$ under the transformation function $f_A$. Instance model $Im_B$ represents the next building block to add to this model. It corresponds to instance graph $IG_B$ under the bijective transformation function $f_B$.\n\nInstance models $Im_A$ and $Im_B$ are entirely distinct except for a set objects $O$, which means $O \\subseteq Object_{Im_A} \\land O \\subseteq Object_{Im_B}$. In a similar way, instance graphs $IG_A$ and $IG_B$ are entirely distinct except for a set of nodes $N$, so $N \\subseteq N_{IG_A} \\land N \\subseteq N_{IG_B}$.\n\nInstance models $Im_A$ and $Im_B$ are combined into instance model $Im_{AB}$ using \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine}. In a similar way instance graphs $IG_A$ and $IG_B$ are combined into instance graph $IG_{AB}$ using \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:combine}. \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_merge_correct} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_merge_correct} respectively show that $Im_{AB}$ and $IG_{AB}$ are valid. Then \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_model_instance_graph} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_graph_instance_model} can be used to merge the transformation functions $f_A$ and $f_B$ into $f_{A} \\sqcup f_{B}$, where \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ig_combine_mapping_correct} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ig_combine_mapping_function_correct} show that $f_{A} \\sqcup f_{B}$ is again a valid transformation function transforming $Im_{AB}$ to $IG_{AB}$. Similarly, \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:imod_combine_mapping_correct} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:imod_combine_mapping_function_correct} show that the inverse function of $f_{A} \\sqcup f_{B}$ is again a valid transformation function transforming $IG_{AB}$ to $Im_{AB}$.\n\n\\input{tex/04_transformation_framework/04_instance_models_and_instance_graphs/01_combining_instance_models.tex}\n\\input{tex/04_transformation_framework/04_instance_models_and_instance_graphs/02_combining_instance_graphs.tex}\n\\input{tex/04_transformation_framework/04_instance_models_and_instance_graphs/03_combining_transformation_functions.tex}", "meta": {"hexsha": "cdc584447de8b2c1d6911c1c1568e6f080dfbe37", "size": 6068, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.1333333333, "max_line_length": 1999, "alphanum_fraction": 0.7633487146, "num_tokens": 1744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4404504706666426}}
{"text": "\\section{The camera calibration problem}\n\\label{sec:teo-calibration}\nThe \\textit{geometric camera calibration} is a process that allows to determine all the parameters introduced with the Equation \\ref{eq:perspective_projection}. When we calibrate a single camera, we are determining only its intrinsic parameters, instead if we calibrate a couple of cameras (or, as in this case, a laser-camera pair) we are able to locate the points in the 3D space, and we can determine the extrinsic parameters of the equation. Accordingly with what we said in Subsection \\ref{subsec:lenses}, lens distortions are critic when we need to reconstruct the 3D world from an image, so they have to be considered by calibration algorithms that, generally, implement non-linear optimization methods (note that the general model for lens distortions is non-linear). Furthermore, some algorithms (such as \\cite{SchCameraCalib} and \\cite{hamrouni2012new}) try to consider the distortion due to the lens tilt caused by, in turn, the use of the Scheimpflug principle. \\\\\n\nIn literature there is a multitude of calibration algorithms, most developed for stereocamera systems. In this subsection we briefly introduced two algorithms that can be used to calibrate laser triangulation systems, proposed by Tsai \\cite{TsaiTvLenses} (the pioneer of camera calibration algorithms) and Zhang \\cite{Zhang-calib}. Both the algorithms are based on the pinhole projective model, described in Equation \\ref{eq:perspective_projection}, and take in input a grid of points, both in image and world reference systems, and give in output the camera parameters. As we can understand, the origin of the world reference system could be arbitrary, but the system must be consistent with the world.\n\nThe choice of to use these algorithms was done by their interest in our filed of study and by the availability of data to compare. However, the use of non-linear optimizations made it difficult to estimate some parameters of interest for the next analysis.\n\n\\subsubsection{Tsai}\nRoger Tsai proposed its algorithm in 1987 in order to improve the already existing algorithms, that lacked of many informations, such as lens distortions. Thus, he introduced a two-step process: in the first step he evaluated the intrinsic parameters starting from the grid took in input; in the second step he applied a non-linear optimization to correctly evaluate intrinsic parameters, with particular attention with focal length and lens distortions. As shown in his article, he developed a very accurate, fast and versatile algorithm to calibrate cameras. Furthermore, one of the advantages of this technique is the ability to calibrate using a single planar view of the reference target. \\\\\n\nAs we can read in the Reg Wilson's FAQ\\footnote{\\url{http://www.ius.cs.cmu.edu/IUS/usrp2/rgw/www/faq.txt}, no longer available now.} we have to be cautious when we set Tsai parameters. First of all, it assumes that some nominal values, such as pixel sizes, sensor size and frame grabber are correct. In this way he simplifies some passages of the algorithm. Second we have to pay attention on the choice of the world reference system: if we consider the coplanar procedure, the origin of our coordinate reference system must to be far from the center of the sensor, otherwise the algorithm could be not work. \\\\\nBoth in coplanar and non-coplanar procedure, the input grid must have at least $11$ point to calibrate correctly. Furthermore, the points have to be taken broadly across the \\acs{FOV} to let the non-linear optimization work properly. \\\\\n\nNote that, in order to separate the effects of $f$ and $T_z$ on the image, there needs to be perspective distortion effects in the calibration data. For useable perspective distortion, the distance between the calibration points nearest and farthest from the camera should be on the same scale as the distance between the calibration points and the camera. This applies both to coplanar and non-coplanar calibration:\n\nFor co-planar calibration the worst situation is to have the 3D points lied in a plane parallel to the camera's image plane (all points at   equal distance away). Simple geometry tells us we can't separate the effects of $f$ and $T_z$. A relative angle of $30$ degrees or more is recommended to give some effective depth to the data points.\n\nFor non-coplanar calibration the worst case is to have the 3D points lied in a volume of space that is relatively small compared to the volume's distance to the camera. From a distance the image formation process is closer to orthographic (not perspective) projection and the calibration problem becomes poorly conditioned.\n\n\n\\subsubsection{Zhang}\nZhang developed an hybrid process that combines self-calibration (a grid similar to that of Tsai) and traditional calibration techniques (match between the same point in different images), which enables the linear estimation of all intrinsic parameters. To do that at least three images of a well known planar pattern (or reasonably considered such) are needed, taken in different positions. The motion of the pattern should not necessarily be known. The steps needed to calibrate the system are the following, to:\n  \\begin{enumerate}\n    \\item Print a pattern and attach it to a planar surface.\n    \\item Take a few images of the model plane under different orientations by moving either the plane or the camera. In the scenarios we are interested in, we will move the pattern keeping fixed the camera.\n    \\item Detect the feature points in the images.\n    \\item Estimate the five intrinsic parameters and all the extrinsic parameters using the closed-form solution.\n    \\item Refine all parameters, including lens distortion parameters.\n  \\end{enumerate}\nUnlike Tsai, Zhang tries to estimate the lens distortions until the fourth degree. As the author admitted in the original paper, his algorithm could degenerate if the pattern took in the different frames, lies in parallel planes.\n\n\\bigskip\nNow we can understand the importance of planar calibration algorithm in laser-based triangulation systems: the laser forms a flat plane in the 3D world reference system. All points we will acquire lie on this plane. From this point of view, Tsai is preferable with respect to Zhang, because it used a single view of scene, taken on the laser plane. Note that if we use a known pattern (i.e. a checkboard), we must be sure that the pattern lies on the laser plane, otherwise the map that obtained will be incorrect.\n", "meta": {"hexsha": "fb571a37abf226da4af63f2bf37e0497a5e55f72", "size": 6500, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/src/chapters/ch2-Technology/3_calibration.tex", "max_stars_repo_name": "extoxesses/LaserMat", "max_stars_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-12T08:53:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T06:36:55.000Z", "max_issues_repo_path": "report/thesis/src/chapters/ch2-Technology/3_calibration.tex", "max_issues_repo_name": "extoxesses/LaserMat", "max_issues_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/src/chapters/ch2-Technology/3_calibration.tex", "max_forks_repo_name": "extoxesses/LaserMat", "max_forks_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 185.7142857143, "max_line_length": 976, "alphanum_fraction": 0.8026153846, "num_tokens": 1369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4404504706666426}}
{"text": "\\input{../header_function}\r\n\r\n%---------- start document ---------- %\r\n \\section{squarefree -- Squarefreeness tests}\\linkedzero{squarefree}\r\n\r\nThere are two method groups.\r\nA function in one group raises \\linkingone{squarefree}{Undetermined} when it cannot determine squarefreeness.\r\nA function in another group returns {\\tt None} in such cases.\r\nThe latter group of functions have ``\\_ternary'' suffix on their names.\r\nWe refer a set \\(\\{{\\tt True}, {\\tt False}, {\\tt None}\\}\\) as {\\it ternary}\\linkedone{squarefree}{ternary}.\r\n\r\nThe parameter type {\\it integer}\\linkedone{squarefree}{integer} means either {\\it int}, {\\it long} or \\linkingone{rational}{Integer}.\r\n\r\nThis module provides an exception class.\r\n\\begin{description}\r\n  \\item[Undetermined]:\\ Report undetermined state of calculation.\r\n    The exception will be raised by\r\n    \\linkingone{squarefree}{lenstra} or\r\n    \\linkingone{squarefree}{trivial\\_test}.\r\n\\end{description}\r\n\r\n\\subsection{Definition}\r\n\r\n  We define squarefreeness as:\\\\\r\n  \\(n\\) is squarefree \\(\\iff\\) there is no prime \\(p\\) whose square divides \\(n\\).\r\n\r\n\\vspace{1em}\r\n\\noindent Examples:\r\n  \\begin{itemize}\r\n  \\item \\(0\\) is non-squarefree because any square of prime can divide \\(0\\).\r\n  \\item \\(1\\) is squarefree because there is no prime dividing \\(1\\).\r\n  \\item \\(2\\), \\(3\\), \\(5\\), and any other primes are squarefree.\r\n  \\item \\(4\\), \\(8\\), \\(9\\), \\(12\\), \\(16\\) are non-squarefree composites.\r\n  \\item \\(6\\), \\(10\\), \\(14\\), \\(15\\), \\(21\\) are squarefree composites.\r\n\\end{itemize}\r\n\r\n \\subsection{lenstra -- Lenstra's condition}\\linkedone{squarefree}{lenstra}\r\n \\func{lenstra}{\\hiki{n}{integer}}{\\out{bool}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad If return value is True, \\param{n} is squarefree.  Otherwise, the\r\n squarefreeness is still unknown and \\linkingone{squarefree}{Undetermined} is raised.\r\n The algorithm is based on~\\cite{Lenstra1979}. \\\\\r\n \\spacing\r\n % added document\r\n \\negok The condition is so strong that it seems \\param{n} has to be a\r\n prime or a Carmichael number to satisfy it.\\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an odd \\linkingone{squarefree}{integer}.\r\n % \r\n \\subsection{trial\\_division -- trial division}\\linkedone{squarefree}{trial\\_division}\r\n \\func{trial\\_division}{\\hiki{n}{integer}}{\\out{bool}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Check whether \\param{n} is squarefree or not. \\\\\r\n \\spacing\r\n % added document\r\n The method is a kind of trial division and inefficient for large numbers. \\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{trivial\\_test -- trivial tests}\\linkedone{squarefree}{trivial\\_test}\r\n \\func{trivial\\_test}{\\hiki{n}{integer}}{\\out{bool}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Check whether \\param{n} is squarefree or not.  If the squarefreeness is still unknown, then \\linkingone{squarefree}{Undetermined} is raised. \\\\\r\n \\spacing\r\n % added document\r\n This method do anything but factorization including Lenstra's method. \\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an odd \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{viafactor -- via factorization}\\linkedone{squarefree}{viafactor}\r\n \\func{viafactor}{\\hiki{n}{integer}}{\\out{bool}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Check whether \\param{n} is squarefree or not. \\\\\r\n \\spacing\r\n % added document\r\n It is obvious that if one knows the prime factorization of the number, he/she can tell whether the number is squarefree or not. \\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{viadecomposition -- via partial factorization}\\linkedone{squarefree}{viadecomposition}\r\n \\func{viadecomposition}{\\hiki{n}{integer}}{\\out{bool}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Test the squarefreeness of \\param{n}.\r\n The return value is either one of {\\tt True} or {\\tt False};\r\n {\\tt None} never be returned. \\\\\r\n \\spacing\r\n % added document\r\n The method uses partial factorization into squarefree parts,\r\n if such partial factorization is possible.  In other cases,\r\n It completely factor \\param{n} by trial division.\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{lenstra\\_ternary -- Lenstra's condition, ternary version}\\linkedone{squarefree}{lenstra\\_ternary}\r\n \\func{lenstra\\_ternary}{\\hiki{n}{integer}}{\\out{ternary}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Test the squarefreeness of \\param{n}. The return value is one of the ternary logical constants.  If return value is {\\tt True}, \\param{n} is squarefree.  Otherwise, the squarefreeness is still unknown and {\\tt None} is returned. \\\\\r\n \\spacing\r\n % added document\r\n \\negok The condition is so strong that it seems \\param{n} has to be a\r\n prime or a Carmichael number to satisfy it.\\\\\r\n This is a ternary version of \\linkingone{squarefree}{lenstra}. \\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an odd \\linkingone{squarefree}{integer}.\r\n % \r\n \\subsection{trivial\\_test\\_ternary -- trivial tests, ternary version}\\linkedone{squarefree}{trivial\\_test\\_ternary}\r\n \\func{trivial\\_test\\_ternary}{\\hiki{n}{integer}}{\\out{ternary}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Test the squarefreeness of \\param{n}.\r\n The return value is one of the ternary logical constants. \\\\\r\n \\spacing\r\n % added document\r\n The method uses a series of trivial tests including \\linkingone{squarefree}{lenstra\\_ternary}. \\\\\r\n This is a ternary version of \\linkingone{squarefree}{trivial\\_test}. \\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{trial\\_division\\_ternary  -- trial division, ternary version}\\linkedone{squarefree}{trial\\_division\\_ternary}\r\n \\func{trial\\_division\\_ternary}{\\hiki{n}{integer}}{\\out{ternary}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Test the squarefreeness of \\param{n}.\r\n The return value is either one of {\\tt True} or {\\tt False};\r\n {\\tt None} never be returned. \\\\\r\n \\spacing\r\n % added document\r\n The method is a kind of trial division. \\\\\r\n This is a ternary version of \\linkingone{squarefree}{trial\\_division}.\\\\\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n \\subsection{viafactor\\_ternary -- via factorization, ternary version}\\linkedone{squarefree}{viafactor\\_ternary}\r\n \\func{viafactor\\_ternary}{\\hiki{n}{integer}}{\\out{ternary}}\\\\\r\n \\spacing\r\n % document of basic document\r\n \\quad Just for symmetry, this function is defined as an alias of \\linkingone{squarefree}{viafactor}. \\\\\r\n \\spacing\r\n % added document\r\n \\spacing\r\n % input, output document\r\n \\quad Input parameter \\param{n} ought to be an \\linkingone{squarefree}{integer}.\r\n% \r\n\\C\r\n\r\n%---------- end document ---------- %\r\n\r\n\\input{../footer}\r\n", "meta": {"hexsha": "a6117f33cc6d8327a977652a8b5a881181128085", "size": 7102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/en/squarefree.tex", "max_stars_repo_name": "turkeydonkey/nzmath3", "max_stars_repo_head_hexsha": "a48ae9efcf0d9ad1485c2e9863c948a7f1b20311", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-26T19:22:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-26T19:22:17.000Z", "max_issues_repo_path": "manual/ja/squarefree.tex", "max_issues_repo_name": "turkeydonkey/nzmath3", "max_issues_repo_head_hexsha": "a48ae9efcf0d9ad1485c2e9863c948a7f1b20311", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/ja/squarefree.tex", "max_forks_repo_name": "turkeydonkey/nzmath3", "max_forks_repo_head_hexsha": "a48ae9efcf0d9ad1485c2e9863c948a7f1b20311", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.5705521472, "max_line_length": 239, "alphanum_fraction": 0.7126161645, "num_tokens": 1911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4404504662288912}}
{"text": "\\chapter{Assignment solutions-Hamilltonian Equation of Motion}\n\\begin{abox}\nAssignment solution-1\n\\end{abox}\n\\begin{enumerate}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{(A) }T&=\\frac{1}{2} m\\left(\\dot{r}^{2}+r^{2} \\dot{\\theta}^{2}+\\dot{z}^{2}\\right)=\\frac{m}{2}\\left(\\dot{r}^{2}+r^{2} \\dot{\\theta}^{2}+a^{2} r^{2} \\dot{r}^{2}\\right) \\quad \\because z=\\frac{1}{2} a r^{2} \\Rightarrow \\quad \\dot{z}=a r \\dot{r}\\\\\n\t\tV&=m g z=\\frac{1}{2} m g a r^{2} \\\\\n\t\tL&=\\frac{m}{2}\\left[\\dot{r}^{2}\\left(1+a^{2} r^{2}\\right)+r^{2} \\dot{\\theta}^{2}-a g r^{2}\\right]\n\t\\intertext{\t(a) $\\theta$ is cyclic coordinate}\n\t\\because \\frac{\\partial L}{\\partial \\theta}&=0, \\Rightarrow \\dot{p}_{\\theta}=0 \\Rightarrow P_{\\theta}=\\text{ constant}\n\t\\intertext{(b) Hamiltonian}\n\tH&=\\frac{p_{r}^{2}}{2 m\\left(1+a^{2} r^{2}\\right)}+\\frac{p_{\\theta}^{2}}{2 m r^{2}}+\\frac{1}{2} m a g r^{2} \\quad \\\\&\\because \\frac{\\partial L}{\\partial \\dot{r}}=p_{r}=m\\left(1+a^{2} r^{2}\\right) \\dot{r}\\text{ and }\\frac{\\partial L}{\\partial \\dot{\\theta}}=p_{\\theta}=m r^{2} \\dot{\\theta}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2cm,width=3.5cm]{diagram-20220314-9-crop}\n\t\\end{figure}\n    \\begin{answer}\n    \t\\begin{align*}\n    \t\\because z&=a\\left(x^{2}+y^{2}\\right)\n    \t\\intertext{Using equation of constrain, we must solve the given system in cylindrical co-ordinate.}\n    \tz&=a r^{2}, \\dot{z}=2 a r \\dot{r}\\\\\n    \tL&=\\frac{1}{2} m\\left(\\dot{r}^{2}+r^{2} \\dot{\\theta}^{2}+\\dot{z}^{2}\\right)-m g z\\\\\n    \t\\Rightarrow L=\\frac{1}{2} m\\left(\\dot{r}^{2}+r^{2} \\dot{\\theta}^{2}+4 a^{2} r^{2} \\dot{r}^{2}\\right)-m g a r^{2}&=\\frac{1}{2} m\\left(\\dot{r}^{2}\\left(1+4 a^{2} r^{2}\\right)+r^{2} \\dot{\\theta}^{2}\\right)-m g a r^{2}\\\\\n    \t\\text{Equation of motion }&\\frac{d}{d t}\\left(\\frac{\\partial L}{\\partial \\dot{r}}\\right)-\\frac{\\partial L}{\\partial r}=0\\\\\n    \tm \\ddot{r}\\left(1+4 a^{2} r^{2}\\right)&+4 m \\dot{r}^{2} a^{2} r-m r \\dot{\\theta}^{2}+2 m g a r=0\\\\\n    \t\\text{At }z=z_{0}, \\quad \\dot{r}&=0, \\quad r=r_{0} \\Rightarrow+m r_{0} \\dot{\\theta}^{2}=2 m g a r_{0} \\Rightarrow \\dot{\\theta}=\\sqrt{2 g a}\\\\\n    \t\\Rightarrow \\frac{v}{r_{0}}=\\sqrt{2 g a} \\Rightarrow v&=\\sqrt{2 g a} \\cdot r_{0}=\\sqrt{2 g a} \\cdot\\left(\\frac{z_{0}}{a}\\right)^{1 / 2} \\Rightarrow v=\\sqrt{2 g z_{0}}\\\\\n    \t\\because z_{0}&=a r_{0}^{2}\n    \t\\end{align*}\n    \\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t(a) x_{1}=0, x_{2}=l \\sin \\theta \\Rightarrow \\dot{x}_{2}&=l \\cos \\theta \\dot{\\theta}\\\\\n\t\ty_{2}=y_{1}+l \\cos \\theta, \\quad \\dot{y}_{2}&=\\dot{y}_{1}-l \\sin \\theta \\dot{\\theta}\\\\\n\t\tL=\\frac{M}{2}\\left(\\dot{y}_{1}^{2}\\right)+\\frac{m}{2}\\left(l^{2} \\dot{\\theta}^{2}+\\dot{y}_{1}^{2}-2 l \\dot{y}_{1} \\dot{\\theta} \\sin \\theta\\right)&-\\frac{k}{2} y_{1}^{2}+M g y_{1}+m g l \\cos \\theta+m g y_{1}\\\\\n\t\t\\text{(b) Equation of motion: }\\frac{d}{d t}\\left(\\frac{\\partial L}{\\partial \\dot{y}_{1}}\\right)&-\\frac{\\partial L}{\\partial y_{1}}=0\\\\\n\t\t\\frac{d}{d t}\\left(M \\dot{y}_{1}+m \\dot{y}_{1}-m l \\dot{\\theta} \\sin \\theta\\right)&-\\left(-k y_{1}+M g+m g\\right)=0 \\\\\n\t\tM \\ddot{y}_{1}+m \\ddot{y}_{1}-m l\\left(\\ddot{\\theta} \\sin \\theta+\\dot{\\theta}^{2} \\cos \\theta\\right)&-\\left(-k y_{1}+M g+m g\\right)=0\\\\\n\t\tM y_{1}+m y_{1}-m l\\left(\\theta \\sin \\theta+\\theta^{2} \\cos \\theta\\right)&-\\left(-k y_{1}+M g+m g\\right)=0\\\\\n\t\t\\because \\frac{d}{d t}\\left(\\frac{\\partial L}{\\partial \\dot{\\theta}}\\right)-\\left(\\frac{\\partial L}{\\partial \\theta}\\right)&=0 \\\\\n\t\t\\frac{d}{d t}\\left(m l^{2} \\dot{\\theta}-m l \\dot{y}_{1} \\sin \\theta\\right)-\\left(-m l \\dot{y}_{1} \\dot{\\theta} \\cos \\theta\\right)&-(m g l(-\\sin \\theta))=0\n\t\t\\intertext{$\\left(m l^{2} \\ddot{\\theta}-m l \\ddot{y}_{1} \\sin \\theta-m l \\dot{y}_{1} \\cos \\theta \\dot{\\theta}\\right)+m l \\dot{y}_{1} \\dot{\\theta} \\cos \\theta+m g l \\sin \\theta=0$\n\t\t$m l^{2} \\ddot{\\theta}-m l \\ddot{y}_{1} \\sin \\theta+m g l \\sin \\theta=0$}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL&=\\frac{1}{2} m\\left(\\dot{x}^{2}+\\dot{y}^{2}+\\dot{z}^{2}\\right)-[m g(-z)]\\\\\n\t\tL&=\\frac{1}{2} m\\left(a^{2} \\dot{\\theta}^{2}+a^{2} \\sin ^{2} \\theta \\dot{\\phi}^{2}\\right)+m g a \\cos (\\pi-\\theta)\\\\\n\t\tL&=\\frac{1}{2} m\\left(a^{2} \\dot{\\theta}^{2}+a^{2} \\sin ^{2} \\theta \\dot{\\phi}^{2}\\right)-m g a \\cos (\\theta)\\\\\n\t\tH&=\\sum \\dot{q}_{1} p_{1}-L\\\\\n\t\tH&=\\frac{p_{\\theta}^{2}}{2 m a^{2}}+\\frac{p_{\\phi}^{2}}{2 m a^{2} \\sin ^{2} \\theta}+m a g \\cos \\theta \\because \\frac{\\partial L}{\\partial \\dot{\\theta}}=p_{\\theta}=m a^{2} \\dot{\\theta}\\text{ and } \\frac{\\partial L}{\\partial \\dot{\\phi}}=p_{\\phi}=m a^{2} \\sin ^{2} \\theta \\dot{\\phi}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\ty&=a x^{2}\\\\\n\t\t\\text{(a) }\\dot{y}&=2 a x \\dot{x}\\\\\n\t\tL&=\\frac{m}{2}\\left(\\dot{x}^{2}+\\dot{y}^{2}\\right)-m g y=\\frac{m}{2}\\left(\\dot{x}^{2}+4 a^{2} x^{2} \\dot{x}^{2}\\right)-m g a x^{2}\\\\\n\t\tL&=\\frac{m}{2}\\left(1+4 a^{2} x^{2}\\right) \\dot{x}^{2}-m g a x^{2}\\\\\n\t\\text{\t(b) }&\\frac{d}{d t}\\left(\\frac{\\partial L}{\\partial \\dot{x}}\\right)-\\frac{\\partial L}{\\partial x}=0\\\\\n\t\\frac{d}{d t}&\\left[m\\left(1+4 a^{2} x^{2}\\right) \\dot{x}\\right]-\\left[4 m a^{2} \\dot{x}^{2} x-2 \\mathrm{~m} g\\right.\\text{ a }\\left.x\\right]=0\\\\\n\tm \\ddot{x}&+4 m a^{2} \\ddot{x} x^{2}+8 m a^{2} \\dot{x} x \\dot{x}-4 m a^{2} \\dot{x}^{2} x+2 m g a x=0\\\\\n\tm \\ddot{x}&+4 m a^{2} x^{2} \\ddot{x}+4 m a^{2} x \\dot{x}^{2}+2 m g a x=0\\\\\n\t\\text{(c) }H&=\\sum \\dot{x} p_{x}-L\\\\\n\tH&=\\frac{p_{x}^{2}}{2 m\\left(1+4 a^{2} x^{2}\\right)}+m g a x^{2} \\quad \\because \\frac{\\partial L}{\\partial \\dot{x}}=p_{x}=m\\left(1+4 a^{2} x^{2}\\right) \\dot{x}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL&=e^{\\alpha t}\\left(\\frac{m \\dot{x}^{2}}{2}-\\frac{k x^{2}}{2}\\right)\\\\\n\t\t\\text{(a) }\\frac{d}{d t}\\left(e^{\\alpha t} m \\dot{x}\\right)-e^{\\alpha t} k x&=0 \\Rightarrow e^{\\alpha t} m \\ddot{x}+m \\dot{x} e^{\\alpha t} \\cdot \\alpha-e^{\\alpha t} k x=0 \\Rightarrow e^{\\alpha t}[m \\ddot{x}+\\alpha m \\dot{x}-k x]=0\\\\\n\t\t\\text{(b) }H&=e^{-\\alpha t} \\frac{p_{x}^{2}}{2 m}+e^{\\alpha t} \\frac{k x^{2}}{2}\n\t\t\\because \\frac{\\partial L}{\\partial \\dot{x}}=p_{x}=e^{\\alpha t} m \\dot{x}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL&=\\frac{m_{1} \\dot{x}_{1}^{2}}{2}+\\frac{m_{2}\\left(\\dot{x}_{2}^{2}+\\dot{y}_{2}^{2}\\right)}{2}-\\left(-m_{2} g y_{2}\\right)\\\\\n\t\tx_{2}&=x_{1}+l \\sin \\phi, y_{2}=l \\cos \\phi\\\\\n\t\t\\Rightarrow \\dot{x}_{2}&=\\dot{x}_{1}+l \\cos \\phi \\dot{\\phi}, \\quad \\dot{y}_{2}=-l \\sin \\phi \\dot{\\phi}\\\\\n\t\t\\text{(a) }L&=\\frac{1}{2}\\left(m_{1}+m_{2}\\right) \\dot{x}_{1}^{2}+\\frac{1}{2} m_{2}\\left(l^{2} \\dot{\\phi}^{2}+2 l \\dot{x}_{1} \\dot{\\phi} \\cos \\phi\\right)+m_{2} g l \\cos \\phi\\\\\n\t\t\\text{(b) }x_{1}&\\text{ is cyclic coordinate}\\\\\n\t\t\\because \\frac{\\partial L}{\\partial x_{1}}&=0 \\Rightarrow p_{x}=\\left(m_{1}+m_{2}\\right) \\dot{x}_{1}+m_{2} l \\dot{\\phi} \\cos \\phi\\\\\n\t\t\\text{(c) }\\frac{\\partial L}{\\partial \\dot{\\phi}}&=p_{\\phi}=m_{2} l^{2} \\dot{\\phi}+l \\dot{x}_{1} \\cos \\phi, \\quad p_{x}=\\left(m_{1}+m_{2}\\right) \\dot{x}_{1}+m_{2} l \\dot{\\phi} \\cos \\phi\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t \\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=5.5cm,width=5.5cm]{Assignment-HE-05}\n\t\\end{figure}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{(a) We choose the origin of our coordinate system to be at the center of the rotating rim. The Cartesian components of mass $m$ become}\n\t\t&\\left.\\begin{array}{l}x=a \\cos \\omega t+b \\sin \\theta \\\\ y=b \\cos \\theta-a \\sin \\omega t\\end{array}\\right\\}\n\t\t\\intertext{The velocities are}\n\t\t&\\left.\\begin{array}{l}\\dot{x}=-a w \\sin \\omega t+b \\dot{\\theta} \\cos \\theta \\\\ \\dot{y}=-a \\omega \\cos \\omega t-b \\dot{\\theta} \\sin \\theta\\end{array}\\right\\}\n\t\t\\intertext{Taking the time derivative once again gives the acceleration:}\n\t\t\\ddot{x}&=-a \\omega^{2} \\cos \\omega t+b\\left(\\ddot{\\theta} \\cos \\theta-\\dot{\\theta}^{2} \\sin \\theta\\right)\\\\\n\t\t\\ddot{y}&=+a \\omega^{2} \\sin \\omega t-b\\left(\\ddot{\\theta} \\sin \\theta+\\dot{\\theta}^{2} \\cos \\theta\\right)\n\t\t\\intertext{(b) It should now be clear that the single generalized coordinate is $\\theta$. The kinetic and potential energies are}\n\tT &=\\frac{1}{2} m\\left(\\dot{x}^{2}+\\dot{y}^{2}\\right) \\\\\n\t U &=-m g y \\\\\n\t \\text{where }U&=0\\text{ at }y=0.\n\t \\intertext{The Lagrangian of a system is given by}\n\t L&=T-U=\\frac{m}{2}\\left[a^{2} \\omega^{2}+b^{2} \\dot{\\theta}^{2}+2 b \\dot{\\theta} a \\omega \\sin (\\theta-\\omega t)\\right]+m g(b \\cos \\theta-a \\sin \\omega t)\n\t \\intertext{(c) The derivatives for the Lagrange equation of motion for $\\theta$ are}\n\t \\frac{d}{d t} \\frac{\\partial L}{\\partial \\dot{\\theta}}&=m b^{2} \\ddot{\\theta}+m b a \\omega(\\dot{\\theta}-\\omega) \\cos (\\theta-\\omega t)\\\\\n\t \\frac{\\partial L}{\\partial \\theta}&=m b \\dot{\\theta} a \\omega \\cos (\\theta-\\omega t)-m g b \\sin \\theta\n\t \\intertext{which results in the equation of motion (after solving for $\\ddot{\\theta}$ )}\n\t \\ddot{\\theta}&=\\frac{\\omega^{2} a}{b} \\cos (\\theta-\\omega t)-\\frac{g}{b} \\sin \\theta\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t  \\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=6cm,width=3.6cm]{Assignment-HE-06}\n\t\\end{figure}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{(a) }&r_{1}=a, r_{2}=a, \\theta_{1}=\\theta_{2}=\\theta, \\quad \\phi_{3}=0, \\quad \\theta_{3}=0, \\quad r_{3}=2 a \\cos \\theta, \\quad \\phi_{1}=\\phi_{2}+c\\\\\n\t\t&\\text{Degree of freedom }=3 \\times 3-7=2\\\\\n\t\\text{\t(b) }&L=m_{1} a^{2}\\left(\\dot{\\theta}^{2}+\\omega^{2} \\sin ^{2} \\theta\\right)+2 m_{2} a^{2} \\dot{\\theta}^{2} \\sin ^{2} \\theta+2\\left(m_{1}+m_{2}\\right) g a \\cos \\theta\\\\\n\t\t\\text{(c) }&\\frac{d}{d t}\\left(\\frac{\\partial L}{\\partial \\dot{\\theta}}\\right)-\\frac{\\partial L}{\\partial \\theta}=0\\\\\n\t\t&\\frac{d}{d t}\\left(2 m_{1} a^{2} \\dot{\\theta}+4 m_{2} a^{2} \\dot{\\theta} \\sin ^{2} \\theta\\right)-m_{1} a^{2} \\omega^{2} 2 \\sin \\theta \\cos \\theta-2 m_{2} a^{2} \\dot{\\theta}^{2} 2 \\sin \\theta \\cos \\theta+2\\left(m_{1}+m_{2}\\right) g a \\sin \\theta=0\\\\\n\t\t&\\Rightarrow\\left(2 m_{1} a^{2}+4 m_{2} a^{2} \\sin ^{2} \\theta\\right) \\ddot{\\theta}+2 m_{2} a^{2} \\sin 2 \\theta \\dot{\\theta}^{2}-m_{1} a^{2} \\omega^{2} \\sin 2 \\theta+2\\left(m_{1}+m_{2}\\right) g a \\sin \\theta=0\\\\\n\t\\text{\t(d) }&H=\\sum \\dot{\\theta} p_{\\theta}-L\\\\\n\t&\\frac{\\partial L}{\\partial \\dot{\\theta}}=p_{\\theta}=2 m_{1} a^{2} \\dot{\\theta}+4 m_{2} a^{2} \\dot{\\theta} \\sin ^{2} \\theta \\Rightarrow \\dot{\\theta}=\\frac{p_{\\theta}}{2 m_{1} a^{2}+4 m_{2} a^{2} \\sin ^{2} \\theta}\\\\\n\tH&=\\frac{p_{\\theta}^{2}}{4 m a^{2}+\\theta m_{2} a^{2} \\sin ^{2} \\theta}-m_{1} a^{2} \\omega^{2} \\sin ^{2} \\theta-2\\left(m_{1}+m_{2}\\right) g a \\cos \\theta\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t \\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4.5cm,width=6.5cm]{Assignment-HE-07}\n\t\\end{figure}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL&=\\frac{1}{2} m\\left(\\dot{r}^{2}+r^{2} \\dot{\\theta}^{2}+r^{2} \\sin ^{2} \\theta \\dot{\\phi}^{2}\\right)-m g r \\cos \\theta\\\\\n\t\t\\text{equation of constrain is }\\theta&=\\frac{\\pi}{4}\\text{ and it is given }\\dot{\\phi}=\\omega\\\\\n\t\tL&=\\frac{1}{2} m\\left(\\dot{r}^{2}+\\frac{1}{2} r^{2} \\omega^{2}\\right)-\\frac{1}{\\sqrt{2}} m g r\\\\\n\t\\text{\tthe momentum conjugate to $r$ is }p_{r}&=\\frac{\\partial L}{\\partial \\dot{r}} \\quad \\Rightarrow p_{r}=m \\dot{r}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\t\\item $\\left. \\right. $\n\t\t  \\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=6cm,width=5.2cm]{Assignment-HE-08}\n\t\t\\end{figure}\n\t\\begin{answer}\n\t\t\\begin{align}\n\t\t\\intertext{Because the problem has cylindrical symmetry, we choose $r, \\theta$ and $z$ as the generalized coordinates. The kinetic energy of the bead is}\n\t\tT&=\\frac{m}{2}\\left[\\dot{r}^{2}+\\dot{z}^{2}+(r \\dot{\\theta})^{2}\\right]\\notag\\\\\n\t\\text{\tIf we choose }U=0\\text{ at }z&=0\\text{, the potential energy term is}\\notag\\\\\n\tU&=m g z\\notag\n\t\\intertext{But $r, z$ and $\\theta$ are not independent. The equation of constraint for the parabola is}\n\tz&=c r^{2} \\Rightarrow \\dot{z}=2 c \\dot{r} r\\notag\n\t\\intertext{We also have an explicit time dependence of the angular rotation}\\notag\n\t\\theta&=\\omega t \\Rightarrow \\dot{\\theta}=\\omega\\notag\n\t\\intertext{We can now construct the Lagrangian as being dependent only on $r$, because there is no direct $\\theta$ dependence.}\n\tL&=T-U=\\frac{m}{2}\\left(\\dot{r}^{2}+4 c^{2} r^{2} \\dot{r}^{2}+r^{2} \\omega^{2}\\right)-m g c r^{2}\\notag\n\t\\intertext{The problem stated that the bead moved in a circle of radius $R$. The reader might be tempted at this point to let $r=R=$ constant and $\\dot{r}=0$. It would be a mistake to do this now in the Lagrangian. First, we should find the equation of motion for the variable $r$ and then let $r=R$ as a condition of the particular motion. This determines the particular value of $c$ needed for $r=R$.}\\notag\n\t\\frac{\\partial L}{\\partial \\dot{r}}&=\\frac{m}{2}\\left(2 \\dot{r}+8 c^{2} r^{2} \\dot{r}\\right), \\frac{d}{d t} \\frac{\\partial L}{\\partial \\dot{r}}=\\frac{m}{2}\\left(2 \\ddot{r}+16 c^{2} r \\dot{r}^{2}+8 c^{2} r^{2} \\ddot{r}\\right)\\notag\\\\\n\t\\frac{\\partial L}{\\partial \\dot{r}}&=m\\left(4 c^{2} r \\dot{r}^{2}+r \\omega^{2}-2 g c r\\right)\\notag\n\t\\intertext{Lagrange's equation of motion becomes}\\notag\\\\\n\t\\ddot{r}\\left(1+4 c^{2} r^{2}\\right)&+\\dot{r}^{2}\\left(4 c^{2} r\\right)+r\\left(2 g c-\\omega^{2}\\right)=0\\label{HE-01}\n\t\\intertext{which is a complicated result. If, however, the bead rotates with $r=R=$ constant, then $\\dot{r}=\\ddot{r}=0$ and equation (\\ref{HE-01}) becomes}\n\tR\\left(2 g c-\\omega^{2}\\right)&=0 \\Rightarrow \\omega=\\sqrt{2 g c}\\notag\n\t\t\\end{align}\n\t\\end{answer}\n\\end{enumerate}\n\\begin{abox}\n\tAssignment solution-2\n\\end{abox}\n\\begin{enumerate}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\t\\text{Poisson bracket }\\left[p_{x}-3 y, H\\right]&=0 and \\left[p_{y}+2 y, H\\right]=0\\\\\n\tp_{y}(b-3)+x\\left(3 b-b^{2}\\right)&=0\\text{ and }p_{x}(a+2)-y\\left(2 a+a^{2}\\right)=0\\\\\n\t\\Rightarrow a&=-2, b=3\n\t\\end{align*}\n\\end{answer} \n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tH&=\\sum \\dot{q} p-L\\text{ where }L=\\frac{1}{2} m \\dot{q}^{2}-\\frac{1}{2} \\lambda q \\dot{q}^{2}\\\\\n\t\t\\frac{\\partial L}{\\partial \\dot{q}}&=p=m \\dot{q}-\\lambda q \\dot{q} \\Rightarrow p=\\dot{q}(m-\\lambda q) \\Rightarrow \\dot{q}=\\frac{p}{m-\\lambda q}\\\\\n\t\t\\Rightarrow H&=\\dot{q} p-L=\\frac{p^{2}}{(m-\\lambda q)}-\\frac{1}{2} m \\frac{\\left(p^{2}\\right)}{(m-\\lambda q)^{2}}+\\frac{\\lambda}{2} q \\cdot \\frac{p^{2}}{(m-\\lambda q)^{2}}\\\\\n\t\t\\Rightarrow H&=\\frac{p^{2}}{(m-\\lambda q)}-\\frac{p^{2}}{2(m-\\lambda q)^{2}}(m-\\lambda q)=\\frac{p^{2}}{(m-\\lambda q)}-\\frac{p^{2}}{2(m-\\lambda q)}\\\\\n\t\t\\Rightarrow H&=\\frac{p^{2}}{2(m-\\lambda q)}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\\text{\t(a) }\\left\\{C_{1}, C_{2}\\right\\}&=\\left\\{x_{2} p_{3}+x_{3} p_{2}, x_{1} p_{2}-x_{2} p_{1}\\right\\}\\\\\n\t\t\\left\\{C_{1}, C_{2}\\right\\} &=\\left\\{x_{2} p_{3}, x_{1} p_{2}\\right\\}-\\left\\{x_{2} p_{3}, x_{2} p_{1}\\right\\}+\\left\\{x_{3} p_{2}, x_{1} p_{2}\\right\\}-\\left\\{x_{3} p_{2}, x_{2} p_{1}\\right\\} \\\\\n\t\t&=x_{1}\\left\\{x_{2}, p_{2}\\right\\} p_{3}+0+0-x_{3}\\left\\{p_{2}, x_{2}\\right\\} p_{1}\\\\\n\t\t\\Rightarrow\\left\\{C_{1}, C_{2}\\right\\}&=x_{1} p_{3}+x_{3} p_{1}\\\\\n\t\t\\text{(b) }\\left\\{C_{1}, C_{2}\\right\\}&=C_{3}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\t\\text{If $u$ is conserve then }\\frac{d u}{d t}&=[u, H]+\\frac{\\partial u}{\\partial t}=0 \\Rightarrow \\frac{d u}{d t}=\\frac{\\partial u}{\\partial x} \\cdot \\frac{\\partial H}{\\partial p}-\\frac{\\partial u}{\\partial p} \\cdot \\frac{\\partial H}{\\partial x}+\\frac{\\partial u}{\\partial t}\\\\\n\t\\Rightarrow \\frac{d u}{d t}&=\\frac{i m \\omega}{p+i m \\omega x} \\cdot \\frac{p}{m}-\\frac{1}{p+i m \\omega x} \\cdot m \\omega^{2} x-i \\omega\\\\\n\t&=\\frac{i \\omega p}{p+i m \\omega x}-\\frac{m \\omega^{2} x}{p+i m \\omega x}-i \\omega=\\frac{i \\omega(p+i m \\omega x)}{p+i m \\omega x}-i \\omega=0\n\t\\intertext{So $u$ is conserve during the motion}\n\t\\end{align*}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\t\\intertext{(a) Solving Hamiltonian equation of motion}\n\t\\frac{\\partial H}{\\partial x}&=-\\dot{p}_{x} \\Rightarrow p_{x}-x=-\\dot{p}_{x}\\text{ and }\\frac{\\partial H}{\\partial y}=-\\dot{p}_{y} \\Rightarrow-p_{y}+y=-\\dot{p}_{y}\\\\\n\t\\frac{\\partial H}{\\partial p_{x}}&=\\dot{x} \\Rightarrow x=\\dot{x}\\text{ and } \\frac{\\partial H}{\\partial p_{y}}=\\dot{y} \\Rightarrow-y=\\dot{y}\n\t\\intertext{(b) After solving these four differential equation and eliminating time $t$ and using boundary condition one will get $\\Rightarrow x \\propto \\frac{1}{y}$ and $p_{x} \\propto \\frac{1}{p_{y}}$}\n\t\\end{align*}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align}\n\tH&=\\frac{p^{2}}{2 m}+\\frac{1}{2} m \\omega^{2} q^{2}, \\quad F=F_{1}(q, Q)=-\\frac{Q}{q}\\notag\\\\\n\t\\Rightarrow \\frac{\\partial F_{1}}{\\partial q}&=p \\Rightarrow \\frac{Q}{q^{2}}=p\\label{HE02}\\\\\n\t\\Rightarrow \\frac{\\partial F_{1}}{\\partial Q}&=-P \\Rightarrow-\\frac{1}{q}=-P \\Rightarrow q=\\frac{1}{P}\\label{HE-03}\n\t\\intertext{From equation (\\ref{HE02}) and (\\ref{HE-03}) $\\Rightarrow p=Q P^{2}$\t$\n\t\t\\quad \\because q=\\frac{1}{P}\t$}\\notag\n\tH&=\\frac{p^{2}}{2 m}-\\frac{1}{2} m \\omega^{2} q^{2}=\\frac{Q^{2} P^{4}}{2 m}-\\frac{1}{2} m \\omega^{2}\\left(\\frac{1}{P^{2}}\\right)=\\frac{1}{2 m} Q^{2} P^{4}-\\frac{1}{2} m \\omega^{2} P^{-2}\\notag\n\t\\end{align}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\t\tH&=\\frac{p_{x}^{2}}{2 m}+\\frac{p_{y}^{2}}{2 m}+\\frac{1}{2} m \\omega^{2}\\left(x^{2}+y^{2}\\right) \\quad S_{1}=\\frac{1}{2}\\left(x p_{y}-y p_{x}\\right)\\\\\n\t\t\\text{(a) }&\\left[S_{1}, H\\right]=0\\\\\n\t\t&\\Rightarrow \\frac{\\partial S_{1}}{\\partial x} \\frac{\\partial H}{\\partial p_{x}}-\\frac{\\partial S_{1}}{\\partial p_{x}} \\frac{\\partial H}{\\partial x}+\\frac{\\partial S_{1}}{\\partial y} \\frac{\\partial H}{\\partial p_{y}}-\\frac{\\partial S_{1}}{\\partial p_{y}} \\cdot \\frac{\\partial H}{\\partial y} \\\\\n\t\t&\\Rightarrow \\frac{p_{y}}{2} \\cdot \\frac{p_{x}}{m}-\\left(-\\frac{y}{2}\\right) \\cdot m \\omega^{2} x+\\frac{1}{2}\\left(-p_{x}\\right) \\cdot \\frac{p_{y}}{m}-\\frac{1}{2}(x) \\cdot m \\omega^{2} y=0\\\\\n\t\t\\text{(b) }&\\left[S_{2}, H\\right]=0\\hspace{2cm}\n\t\tS_{2}=\\frac{1}{2 m \\omega}\\left(p_{x} p_{y}+m^{2} \\omega^{2} x y\\right)\\\\\n\t\t&\\Rightarrow \\quad \\frac{\\partial S_{2}}{\\partial x} \\frac{\\partial H}{\\partial p_{x}}-\\frac{\\partial S_{2}}{\\partial p_{x}} \\frac{\\partial H}{\\partial x}+\\frac{\\partial S_{2}}{\\partial y} \\frac{\\partial H}{\\partial p_{y}}-\\frac{\\partial S_{2}}{\\partial p_{y}} \\frac{\\partial H}{\\partial y}\\\\\n\t\t&\\Rightarrow \\quad \\frac{1}{2 m \\omega}\\left(m^{2} \\omega^{2} y\\right)\\left(\\frac{p_{x}}{m}\\right)-\\frac{p_{y}}{2 m \\omega} \\cdot\\left(m \\omega^{2} x\\right)+\\frac{1}{2 m \\omega} m^{2} \\omega^{2} x \\cdot \\frac{p_{y}}{m}-\\frac{p_{x}}{2 m \\omega} \\cdot m \\omega^{2} y=0\\\\\n\t\t\\text{(c) }&\\left[S_{3}, H\\right]=0\\\\\n\t\t&\\frac{\\partial S_{3}}{\\partial x} \\frac{\\partial H}{\\partial p_{x}}-\\frac{\\partial S_{3}}{\\partial p_{x}} \\frac{\\partial H}{\\partial x}+\\frac{\\partial S_{3}}{\\partial y} \\frac{\\partial H}{\\partial p_{y}}-\\frac{\\partial S_{3}}{\\partial p_{y}} \\cdot \\frac{\\partial H}{\\partial y} \\\\\n\t\t&\\Rightarrow \\frac{1}{4 m \\omega} \\times m^{2} \\omega^{2}(-2 x) \\cdot \\frac{p_{x}}{m}-\\frac{1}{4 m \\omega} \\times 2 p_{x} \\cdot m \\omega^{2} x+\\frac{m^{2} \\omega^{2}}{4 m \\omega} \\times 2 y \\cdot \\frac{p_{y}}{m}-\\frac{1}{4 m \\omega}\\left(-2 p_{y} \\cdot m \\omega^{2} y\\right) \\\\\n\t\t&\\Rightarrow \\frac{-p_{x} x \\omega}{2}-\\frac{p_{x} \\omega x}{2}+\\frac{p_{y} \\cdot y \\omega}{2}+\\frac{p_{y} y \\omega}{2} \\neq 0\n\t\\end{align*}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\tQ&=\\log \\left(1+q^{\\frac{1}{2}} \\cos p\\right)\\\\\n\tP&=2\\left(1+q^{\\frac{1}{2}} \\cos p\\right) q^{\\frac{1}{2}} \\sin p \\Rightarrow 2 q^{\\frac{1}{2}} \\sin p+q \\sin 2 p\\\\\n\\text{\t(a) }&\\text{For canonical transformation: }\\frac{\\partial Q}{\\partial q} \\cdot \\frac{\\partial P}{\\partial p}-\\frac{\\partial Q}{\\partial p} \\cdot \\frac{\\partial P}{\\partial q}=1\\\\\n\t&\\Rightarrow \\frac{\\partial Q}{\\partial q}=\\frac{1}{\\left(1+q^{\\frac{1}{2}} \\cos p\\right)} \\times \\frac{1}{2} q^{-\\frac{1}{2}} \\cos p, \\frac{\\partial Q}{\\partial p}=\\frac{q^{\\frac{1}{2}}(-\\sin p)}{\\left(1+q^{\\frac{1}{2}} \\cos p\\right)}\\\\\n\t\\frac{\\partial P}{\\partial p}&=2 q^{\\frac{1}{2}} \\cos p+2 q \\cos 2 p, \\frac{\\partial P}{\\partial q}=2 \\times \\frac{1}{2} q^{-\\frac{1}{2}} \\sin p+\\sin 2 p\\\\\n\t&\\Rightarrow \\frac{\\cos p}{2\\left(1+q^{\\frac{1}{2}} \\cos p\\right) q^{\\frac{1}{2}}} \\cdot 2\\left(q^{\\frac{1}{2}} \\cos p+q \\cos 2 p\\right)-\\frac{\\left(-q^{\\frac{1}{2}} \\sin p\\right)}{\\left(1+q^{\\frac{1}{2}} \\cos p\\right)} \\times\\left(q^{-\\frac{1}{2}} \\sin p+\\sin 2 p\\right)=1\\\\\n\t\\text{(b) }F_{3}&=F_{3}(p, Q, t)\\\\\n\t\\frac{\\partial F_{3}}{\\partial p}&=-q, \\quad \\frac{\\partial F_{3}}{\\partial Q}=-P \\\\\n\tQ&=\\log \\left(1+q^{1 / 2} \\cos p\\right) \\Rightarrow e^{Q}=1+q^{1 / 2} \\cos p\\\\\n\t\\frac{e^{Q}-1}{\\cos p}&=q^{1 / 2} \\Rightarrow q=\\left(\\frac{e^{Q}-1}{\\cos p}\\right)^{2}\\\\\n\tP&=2\\left(1+q^{1 / 2} \\cos p\\right) q^{1 / 2} \\sin p \\Rightarrow P=2 e^{Q} q^{1 / 2} \\sin p \\Rightarrow 2 e^{Q}\\left(e^{Q}-1\\right) \\tan p\\\\\n\t\\frac{\\partial F_{3}}{\\partial p}&=-q=-\\frac{\\left(e^{Q}-1\\right)^{2}}{\\cos ^{2} p} \\Rightarrow F_{3}=-\\int\\left(e^{Q}-1\\right)^{2} \\sec ^{2} p d p\n\t\\end{align*}\n\t\\begin{align}\n\tF_{3}&=-\\left(e^{Q}-1\\right)^{2} \\tan p+f_{1}(Q)\\label{HE-04}\\\\\n\t\\frac{\\partial F_{3}}{\\partial Q}&=-P=-2\\left(e^{2 Q}-e^{Q}\\right) \\tan p\\notag\\\\\n\tF_{3}&=-2\\left(\\frac{1}{2} e^{2 Q}-e^{Q}\\right) \\tan p+f_{2}(p)=-\\left(e^{Q}-1\\right)^{2} \\tan p+\\tan p+f_{2}(p) \\label{HE-05}\n\\intertext{\tEquating $\\ref{HE-04}$ and $\\ref{HE-05}$}\n\tf_{1}(Q)&=0, \\quad f_{2}(p)=-\\tan p\\notag\\\\\n\t\\text{So }F_{3}&=-\\left(e^{Q}-1\\right)^{2} \\tan p \\notag\n\t\\end{align}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}\n\t\\begin{align*}\n\t\\frac{\\partial Q_{1}}{\\partial q_{1}} \\frac{\\partial P_{1}}{\\partial p_{1}}&-\\frac{\\partial Q_{1}}{\\partial p_{1}} \\frac{\\partial P_{1}}{\\partial q_{1}}+\\frac{\\partial Q_{1}}{\\partial q_{2}} \\frac{\\partial P_{1}}{\\partial p_{2}}-\\frac{\\partial Q_{1}}{\\partial p_{2}} \\frac{\\partial P_{1}}{\\partial q_{2}}=1 \\times 1-0=1\\\\\n\t\\text{and }&\\frac{\\partial Q_{1}}{\\partial q_{1}} \\frac{\\partial P_{1}}{\\partial p_{1}}-\\frac{\\partial Q_{1}}{\\partial p_{1}} \\frac{\\partial P_{1}}{\\partial q_{1}}+\\frac{\\partial Q_{2}}{\\partial q_{2}} \\frac{\\partial P_{2}}{\\partial p_{2}}-\\frac{\\partial Q}{\\partial p_{2}} \\frac{\\partial P_{2}}{\\partial q_{2}}=0-(-1)=1\n\t\\end{align*}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\\begin{answer}$\\left. \\right. $\n\t\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2.5cm,width=5cm]{Assignment-HE-13.pdf}\n\t\\end{figure}\n\t\\begin{align*}\n\t\\text{(A)\\quad (a)\\quad }H&=\\frac{1}{2 m}\\left[p^{2}+m^{2} \\omega^{2} q^{2}\\right]\\\\\n\t\\frac{\\partial H}{\\partial p}&=\\dot{q} \\Rightarrow \\frac{p}{m}=\\dot{q} \\Rightarrow p=m \\dot{q}\\\\\n\t\\frac{\\partial H}{d q}&=-\\dot{p} \\Rightarrow m \\omega^{2} q=-\\dot{p}\\\\\n\t-m \\omega^{2} q&=m \\ddot{q}\\\\\\\n\t\\ddot{q}+\\omega^{2} q&=0\\\\\n\tq&=A \\cos \\omega t+B \\sin \\omega t\n\t\\end{align*}\n\t\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=4cm]{Assignment-HE-14.pdf}\n\t\\end{figure}\n\t\\begin{align*}\n\t\\text{(b) \\quad}&\\frac{p^{2}}{(\\sqrt{2 m E})^{2}}+\\frac{q^{2}}{\\left(\\sqrt{\\frac{2 E}{m \\omega^{2}}}\\right)^{2}}=1\\\\\n\t\\text{(c) \\quad}&\\text{ With initial condition, when }t=0, q=q_{0}\\text{ and } \\dot{q}=0\\text{ at }t=0\\\\\n\t\\text{Then, }q_{0}&=A\\text{ and }q=q_{0} \\cos \\omega t\\\\\n\t\\text{(d) }\\quad p&=m \\dot{q}\\\\\n\tp&=-q_{0} \\omega m \\sin \\omega t\n\t\\end{align*}\n\t\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2.8cm,width=4.5cm]{Assignment-HE-12.pdf}\n\t\\end{figure}\n\t\\begin{align*}\n\\text{\t(B)\\quad  (a)\\quad }F_{1}&=\\frac{m \\omega q^{2}}{2} \\cot Q, \\frac{\\partial F_{1}}{\\partial q}=p, \\frac{\\partial F_{1}}{\\partial Q}=-P\\\\\nm \\omega q \\cdot \\cot Q&=p,-\\frac{m \\omega q^{2}}{2} \\operatorname{cosec} Q=-P\\\\\nq^{2}&=\\frac{2 P}{m \\omega} \\frac{1}{\\operatorname{cosec}{ }^{2} Q}\\\\\nq&=\\sqrt{\\frac{2 P}{m \\omega}} \\sin Q, p=m \\omega \\sqrt{\\frac{2 P}{m \\omega}} \\cot Q \\sin Q\\\\\np&=\\sqrt{2 m P \\omega} \\cos Q\\\\\n\\text{(b) }\\quad H&=\\frac{p^{2}}{2 m}+\\frac{1}{2} m \\omega^{2} q^{2}\\\\\nK&=H+\\frac{\\partial F_{1}}{\\partial t} \\Rightarrow \\frac{\\partial F_{1}}{\\partial t}=0, K=H=\\frac{1}{2 m}(\\sqrt{2 P m \\omega} \\cos Q)^{2}+\\frac{1}{2} m \\omega^{2}\\left(\\sqrt{\\frac{2 P}{m \\omega}}\\right)^{2} \\sin ^{2} Q\\\\\nK&=\\omega P\\\\\n\\text{(c)\\quad}&\n\\frac{\\partial K}{\\partial Q}=-\\dot{P} \\Rightarrow \\dot{P}=0, \\frac{d P}{d t}=0, P=c\\\\\n\\frac{\\partial K}{\\partial P}&=\\dot{Q}=\\omega, Q=\\omega t+\\alpha\\text{ where } \\alpha\\text{ is constant, can be find with initial condition}\n\t\\end{align*}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2.8cm,width=4.5cm]{Assignment-HE-09.pdf}\n\t\\end{figure}\n \\begin{tasks}(1)\n\t\\task[\\text{(d)}] \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2.8cm,width=4.5cm]{Assignment-HE-10.pdf}\n\t\\end{figure}where $P=\\frac{E}{\\omega}$\n\t\\task[\\text{(e)}] \n\t\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=2.8cm,width=4.5cm]{Assignment-HE-11.pdf}\n\t\\end{figure}\n\\end{tasks}\n\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tF_{2}&=q^{2} P\\\\\n\t\t\\frac{\\partial F_{2}}{\\partial q}&=2 q P=p, \\frac{\\partial F_{2}}{\\partial P}=q^{2}=Q, q=\\sqrt{Q}, p=2 \\sqrt{Q} P\\\\\n\t\tK&=\\frac{p^{2}}{2 \\alpha q^{2}}+\\frac{\\beta \\cdot q^{4}}{4}=\\frac{4 Q P^{2}}{2 \\alpha Q}+\\frac{\\beta Q^{2}}{4} \\Rightarrow K=\\frac{2 P^{2}}{\\alpha}+\\frac{\\beta Q^{2}}{4}\\\\\n\t\t\\frac{\\partial K}{\\partial P}&=\\dot{Q} \\Rightarrow \\frac{4 P}{\\alpha}=\\dot{Q}\\\\\n\t\t\\frac{\\partial K}{\\partial Q}&=-\\dot{P} \\Rightarrow \\frac{\\beta Q}{2}=-\\dot{P}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{(a) }L&=\\frac{1}{2} m \\dot{x}^{2}+m\\left(\\dot{y}^{2}+\\dot{z}^{2}\\right)-\\frac{1}{2} k x^{2}-\\frac{1}{2} k(y+z)^{2}\\\\\n\t\tH&=\\frac{p_{x}^{2}}{2 m}+\\frac{p_{y}^{2}}{4 m}+\\frac{p_{z}^{2}}{4 m}+\\frac{1}{2} k x^{2}+\\frac{1}{2} k(y+z)^{2}\\\\\n\t\t\\text{(b) }\\quad L_{z}^=x p_{y}-y p_{x}\\\\\n\t\t\\frac{d L_{z}}{d t}&=\\left[L_{z} H\\right]+\\frac{\\partial L_{z}}{\\partial t}, \\frac{\\partial L_{z}}{\\partial t}=0\\\\\n\t\t\\left[L_{z}, H\\right]&=\\left[x p_{y}-y p_{x}, H\\right]=x\\left[p_{y}, H\\right]+[x, H] p_{y}-y\\left[p_{x}, H\\right]-[y, H] p_{x} \\\\\n\t\t&=x\\left[p_{y}, \\frac{1}{2} k(y+z)^{2}\\right]+\\left[x, \\frac{p_{x}^{2}}{2 m}\\right] p_{y}-y\\left[p_{x}, \\frac{1}{2} k x^{2}\\right]-\\left[y, \\frac{p_{y}^{2}}{4 m}\\right] p_{x}\\\\\n\t\t&=x(-k(y+z))+\\frac{p_{x} p_{y}}{m}+k y x-\\frac{p_{x} p_{y}}{2 m}\\\\\n\t\t\\left[L_{z}, H\\right]&=\\frac{p_{y} p_{x}}{2 m}-k x z, \\frac{d L_{z}}{d t}=\\frac{p_{x} p_{y}}{2 m}-k x z \\\\\n\t\t\\text{(c) }\\quad\\left[L_{x}, H\\right]&=\\left[y p_{z}-z p_{y}, H\\right]=\\left[y p_{z}, H\\right]-\\left[z p_{y}, H\\right]\\\\\n\t\t&=[y, H] p_{z}+y\\left[p_{z}, H\\right]-[z, H] p_{y}-z\\left[p_{y}, H\\right]\\\\\n\t\t&=\\left[y, \\frac{p_{y}^{2}}{4 m}\\right] p_{z}+y\\left[p_{z}, \\frac{1}{2} k(y+z)^{2}\\right]-\\left[z, \\frac{p_{z}^{2}}{4 m}\\right] p_{y}-z\\left[p_{y}, \\frac{1}{2} k(y+z)^{2}\\right]\\\\\n\t\t&=\\frac{p_{y}}{2 m} p_{z}+y[-k(y+z)]-\\frac{p_{z}}{2 m} p_{y}+k z(y+z)=-k y^{2}-k z y+k z y+k z^{2}\\\\\n\t\t\\left[L_{x}, H\\right]&=k\\left[z^{2}-y^{2}\\right], \\frac{d L_{x}}{d t}=k\\left[z^{2}-y^{2}\\right] \\\\\n\t\t\\text{(d) }\\quad \\frac{d L_{y}}{d t}&=-\\frac{p_{x} p_{z}}{2 m}+k x y\\\\\n\t\\text{\t(e)\\quad }\n\t\t\\frac{\\partial H}{\\partial x}&=-\\dot{p}_{x}, k x=-\\dot{p}_{x}=\\frac{-d p_{x}}{d t} \\Rightarrow \\frac{d p_{x}}{d t}=-k x\\\\\n\t\t\\frac{\\partial H}{\\partial y}&=-\\dot{p}_{y}, \\frac{2 k}{2}(y+z)=-\\dot{p}_{y}, \\frac{d p_{y}}{d t}=-k(y+z)\n\t\t\\end{align*}\n\t\\end{answer}\n\\end{enumerate}", "meta": {"hexsha": "c81b336f1dfdb6d5f99322400074046126c2f328", "size": 27287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Classical Mechanics  -CSIR/chapter/Assignments/Assignment solutions-Hamilltonian Equation of Motion.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Classical Mechanics  -CSIR/chapter/Assignments/Assignment solutions-Hamilltonian Equation of Motion.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Classical Mechanics  -CSIR/chapter/Assignments/Assignment solutions-Hamilltonian Equation of Motion.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.8753246753, "max_line_length": 410, "alphanum_fraction": 0.5811558618, "num_tokens": 12324, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.661922862511608, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4404504617911396}}
{"text": "\\chapter{Categories related with funcoids}\n\nI consider some categories related with pointfree funcoids.\n\n\\section{Draft status}\n\nThis is a rough partial draft.\n\n\\section{Topic of this article}\n\nIn this article are considered some categories related to \\emph{pointfree\nfuncoids}.\n\n\\section{Category of continuous morphisms}\n\nI will denote $\\Ob f$ the object (source and destination) of an\nendomorphism $f$.\n\n\\begin{defn}\n  Let $C$ is a partially ordered category. The category\n  $\\cont (C)$ (which I call \\emph{the category of\n  continuous morphism} over $C$) is:\n  \\begin{itemize}\n    \\item Objects are endomorphisms of category $C$.\n    \n    \\item Morphisms are triples $(f , a , b)$ where $a$ and $b$ are objects\n    and $f : \\Ob a \\rightarrow \\Ob b$ is a morphism of the\n    category $C$ such that $f \\circ a \\sqsubseteq b \\circ f$.\n    \n    \\item Composition of morphisms is defined by the formula $(g , b , c)\n    \\circ (f , a , b) = (g \\circ f , a , c)$.\n    \n    \\item Identity morphisms are $(a , a , 1^C_a)$.\n  \\end{itemize}\n\\end{defn}\n\nIt is really a category:\n\n\\begin{proof}\n  We need to prove that: composition of morphisms is a morphism, composition\n  is associative, and identity morphisms can be canceled on the left and on\n  the right.\n  \n  That composition of morphisms is a morphism follows from these implications:\n  \\[ f \\circ a \\sqsubseteq b \\circ f \\wedge g \\circ b \\sqsubseteq c \\circ g\n     \\Rightarrow g \\circ f \\circ a \\sqsubseteq g \\circ b \\circ f \\sqsubseteq c\n     \\circ g \\circ f. \\]\n  That composition is associative is obvious.\n  \n  That identity morphisms can be canceled on the left and on the right is\n  obvious.\n\\end{proof}\n\n\\begin{rem}\n  The ``physical'' meaning of this category is:\n  \\begin{itemize}\n    \\item Objects (endomorphisms of $C$) are spaces.\n    \n    \\item Morphisms are continuous functions between spaces.\n    \n    \\item $f \\circ a \\sqsubseteq b \\circ f$ intuitively means that $f$\n    combined with an infinitely small is less than infinitely small combined\n    with $f$ (that is $f$ is continuous).\n  \\end{itemize}\n\\end{rem}\n\n\\begin{rem}\n  Every $\\Hom (\\mathfrak{A}, \\mathfrak{B})$ of $\\mathbf{Pos}$\n  is partially ordered by the formula $a \\leqslant b \\Leftrightarrow \\forall x\n  \\in \\mathfrak{A}: a (x) \\leqslant b (x)$. So $\\cont\n  (\\mathbf{Pos})$ is defined.\n\\end{rem}\n\n\\begin{defn}\n  I call a $\\mathbf{Pos}$-morphism \\emph{monovalued} when it maps\n  atoms to atoms or least element.\n\\end{defn}\n\n\\begin{defn}\n  I call a $\\mathbf{Pos}$-morphism \\emph{entirely defined} when\n  its value is non-least on every non-least element.\n\\end{defn}\n\n\\begin{obvious}\nA morphism is both monovalued and entirely defined iff it maps atoms into\natoms.\n\\end{obvious}\n\n\\fxnote{Show how it relates with dagger categories.}\n\n\\begin{defn}\n  $\\mathbf{mePos}$ is the subcategory of $\\mathbf{Pos}$ with\n  only monovalued and entirely defined morphisms.\n\\end{defn}\n\n\\begin{obvious}\nThis is a well defined category.{\\hspace*{\\fill}}{\\medskip}\n\\end{obvious}\n\n\\begin{defn}\n  $\\mathbf{mefp} \\mathsf{FCD}$ is the subcategory of\n  $\\mathbf{fp} \\mathsf{FCD}$ with only monovalued and entirely\n  defined morphisms.\n\\end{defn}\n\n\\begin{rem}\n  In the two above definitions different definitions of monovaluedness and\n  entire definedness from different articles.\n\\end{rem}\n\n\\section{Definition of the categories}\n\n\\begin{defn}\n  A \\emph{(pointfree) endo-funcoid} is a (pointfree) funcoid with the same\n  source and destination (an endomorphism of the category of (pointfree)\n  funcoids). I will denote $\\Ob f$ the object of an endomorphism $f$.\n\\end{defn}\n\n\\begin{obvious}\nThe \\emph{category of continuous pointfree funcoids} $\\cont\n(\\mathbf{fp} \\mathsf{FCD})$ is:\n\\begin{itemize}\n  \\item Objects are small pointfree endo-funcoids.\n  \n  \\item Morphisms from an object $a$ to an object $b$ are triples $(f , a ,\n  b)$ where $f$ is a pointfree funcoid from $\\Ob a$ to $\\Ob b$\n  such that $f$ is a continuous morphism from $a$ to $b$ (that is $f \\circ a\n  \\sqsubseteq b \\circ f$, or equivalently $a \\sqsubseteq f^{- 1} \\circ b \\circ\n  f$, or equivalently $f \\circ a \\circ f^{- 1} \\sqsubseteq f$).\n  \n  \\item Composition is the composition of pointfree funcoids.\n  \n  \\item Identity for an object $a$ is $(I^{\\mathsf{FCD}}_{\\Ob a}\n  , a , a)$.\n\\end{itemize}\n\\end{obvious}\n\n\\section{Isomorphisms}\n\n\\begin{thm}\n  If $f$ is an isomorphism $a \\rightarrow b$ of the category\n  $\\cont (\\mathbf{fp}\n  \\mathsf{FCD})$, then:\n  \\begin{enumerate}\n    \\item $f \\circ a = b \\circ f$;\n    \n    \\item $a = f^{- 1} \\circ b \\circ f$;\n    \n    \\item $f \\circ a \\circ f^{- 1} = b$.\n  \\end{enumerate}\n\\end{thm}\n\n\\begin{proof}\n  Note that $f$ is monovalued and entirely defined.\n  \n  1. We have $f \\circ a \\sqsubseteq b \\circ f$ and $f^{- 1} \\circ b\n  \\sqsubseteq a \\circ f^{- 1}$. Consequently $f^{- 1} \\circ f \\circ a\n  \\sqsubseteq f^{- 1} \\circ b \\circ f$; $a \\sqsubseteq f^{- 1} \\circ b \\circ\n  f$; $a \\circ f^{- 1} \\sqsubseteq f^{- 1} \\circ b \\circ f \\circ f^{- 1}$; $a\n  \\circ f^{- 1} \\sqsubseteq f^{- 1} \\circ b$. Similarly $b \\circ f \\sqsubseteq\n  f \\circ a$. So $f \\circ a = b \\circ f$.\n  \n  2 and 3. Follow from the definition of isomorphism.\n\\end{proof}\n\nIsomorphisms are meant to preserve structure of objects. I will show that\n(under certain conditions) isomorphisms of $\\cont\n(\\mathbf{fp} \\mathsf{FCD})$ really preserve\nstructure of objects.\n\nFirst we will consider an isomorphism between objects $a$ and $b$ which are\nfuncoids (not the general case of pointfree funcoids). In this case a map\nwhich preserves structure of objects is a \\emph{bijection}. It is really a\nbijection as the following theorem says:\n\n\\begin{thm}\nIf $f$ is an isomorphism of the category of funcoids then $f$ is a discrete\nfuncoid (so, it is essentially a bijection).\n\\fxnote{Split it into two propositions: about completeness and co-completeness.}\n\\end{thm}\n\n\\begin{proof}\n  $\\supfun{f}^{\\ast} A \\sqcap \\supfun{f}^{\\ast} ((\\Src f)\n  \\setminus A) = 0^{\\Dst f}$ because $f$ is monovalued.\n  \n  $\\supfun{f}^{\\ast} A \\sqcup \\supfun{f}^{\\ast} ((\\Src f)\n  \\setminus A) = 1^{\\Dst f}$.\n  \n  Therefore $\\supfun{f}^{\\ast} A$ is a principal filter (theorem 49 in\n  {\\cite{filters}}). So $f$ is co-complete.\n  \n  That $f$ is complete follows from symmetry.\n\\end{proof}\n\nFor wider class of pointfree funcoids the concept of bijection does not make\nsense. Instead we would want a structure preserving map to be \\emph{order\nisomorphism}.\n\nActually, for mapping between $\\subsets A$ and $\\subsets B$ where $A$\nand $B$ are some sets (including the above considered case of funcoids from\n$A$ to $B$) bijection and order isomorphism are essentially the same:\n\n\\begin{prop}\n  Bijections $F$ between sets $A$ and $B$ bijectively correspond to order\n  isomorphisms $f$ between $\\subsets A$ and $\\subsets B$ by the formula\n  $f = \\supfun{F}$.\n\\end{prop}\n\n\\begin{proof}\n  Let $F$ is a bijection. Then $X \\subseteq Y \\Rightarrow \\supfun{F} X\n  \\subseteq \\supfun{F} Y$ and $\\langle F^{- 1} \\rangle \\langle F\n  \\rangle X = X$ for every sets $X, Y \\in \\subsets A$. Thus $f = \\langle F\n  \\rangle$ is an order isomorphism.\n  \n  Let now $f$ is an order isomorphism between $\\subsets A$ and $\\subsets\n  B$. Then $f (\\{ x \\})$ is a singleton for every $x \\in A$. Take $F (x)$ to\n  the unique $y$ such that $f (\\{ x \\}) = \\{ y \\}$. Obviously $f$ is a\n  bijection and $f = \\supfun{F}$.\n\\end{proof}\n\nFor arbitrary pointfree funcoids isomorphisms do not necessarily preserve\nstructure. It holds only for \\emph{increasing pointfree funcoids}:\n\n\\begin{defn}\n  I call a pointfree funcoid $f$ \\emph{increasing} iff $\\supfun{f}$\n  and $\\langle f^{- 1} \\rangle$ are monotone functions.\n\\end{defn}\n\n\\begin{prop}\n  If $f$ is an increasing isomorphism of the category of pointfree funcoids\n  then $\\supfun{f}$ is an order isomorphism.\n\\end{prop}\n\n\\begin{proof}\n  We have: $\\supfun{f} \\circ \\langle f^{- 1} \\rangle = \\langle f \\circ\n  f^{- 1} \\rangle = \\langle \\id^{\\mathsf{FCD}}_{\\mathfrak{B}}\n  \\rangle = \\id_{\\mathfrak{B}}$ and $\\langle f^{- 1} \\rangle \\circ\n  \\supfun{f} = \\langle f^{- 1} \\circ f \\rangle = \\langle\n  \\id^{\\mathsf{FCD}}_{\\mathfrak{A}} \\rangle =\n  \\id_{\\mathfrak{A}}$. Thus $\\supfun{f}$ is a bijection.\n  \n  $\\supfun{f}$ is increasing and bijective.\n\\end{proof}\n\n\\begin{rem}\n  Non-increasing isomorphisms of the category of pointfree funcoids are\n  against sound mind, they don't preserve the structure of the source, that is\n  for them $\\supfun{f}$ or $\\langle f^{- 1} \\rangle$ are not order\n  isomorphisms.\n\\end{rem}\n\n\\begin{obvious}\nIsomorphisms of $\\cont (\\mathbf{Pos})$ and\n$\\cont (\\mathbf{mePos})$ are order\nisomorphisms.\n\\end{obvious}\n\n\\section{Direct products}\n\n\\fxerror{Now this section is a complete mess. Clean it up.}\n\nConsider the category $\\mathbf{contFcd}$ which is the full\nsubcategory $\\cont (\\mathbf{mePos})$ restricted to\nobjects which are essentially increasing pointfree funcoids.\n\nLet $f_1 : Y \\rightarrow X_1$ and $f_2 : Y \\rightarrow X_2$ are morphisms of\n$\\mathbf{contFcd}$.\n\nThe product object is $X_1 \\times^{(C)} X_2$ (cross composition product of\nfuncoids used). It is easy to see that $X_1 \\times^{(C)} X_2$ is an object of\n$\\mathbf{contFcd}$ that is an endo-funcoid.\n\nThe morphism $f_1 \\times^{(D)} f_2 : Y \\rightarrow X_1 \\times^{(C)} X_2$ is\ndefined by the formula $(f_1 \\times^{(D)} f_2) y = f_1 y\n\\times^{\\mathsf{FCD}} f_2 y$.\n\n$f_1 \\times^{(D)} f_2$ is monovalued and entirely defined because so are $f_1$\nand $f_2$.\n\\[ (f_1 \\times^{(D 2)} f_2) y = \\bigcup \\left\\{ f_1 Y\n   \\times^{\\mathsf{FCD}} f_2 Y \\hspace{1em} | \\hspace{1em} Y \\in\n   \\atoms^{\\mathfrak{A}} y \\right\\} . \\]\n\n\\fxnote{Is $(f_1 \\times^{(D 2)} f_2)$ a pointfree funcoid?}\n\nTo prove that it is really a morphism we need to show\n\\[ (f_1 \\times^{(D)} f_2) \\circ Y \\sqsubseteq (X_1 \\times^{(C)} X_2) \\circ\n   (f_1 \\times^{(D)} f_2) \\]\nthat is (for every $y$)\n\\[ (f_1 \\times^{(D)} f_2) Y y \\sqsubseteq (X_1 \\times^{(C)} X_2) (f_1\n   \\times^{(D)} f_2) y. \\]\nReally, $(f_1 \\times^{(D)} f_2) Y y = f_1 Y y \\times^{\\mathsf{FCD}} f_2\nY y$;\n\n$(X_1 \\times^{(C)} X_2) (f_1 \\times^{(D)} f_2) y = (X_1 \\times^{(C)} X_2) (f_1\ny \\times^{\\mathsf{FCD}} f_2 y) = X_1 f_1 y \\times^{\\mathsf{FCD}}\nX_2 f_2 y$;\n\nbut it is easy to show $f_1 Y y \\times^{\\mathsf{FCD}} f_2 Y y\n\\sqsubseteq X_1 f_1 y \\times^{\\mathsf{FCD}} X_2 f_2 y$.\n\n??\n\nI define ??\n\n\\fxnote{Prove that it is a direct product in $\\mathbf{contFcd}$.}", "meta": {"hexsha": "3ebccd0cd830590a8e1d536604fc3e3147e926ff", "size": 10349, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-pf-cat.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-pf-cat.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-pf-cat.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.931147541, "max_line_length": 80, "alphanum_fraction": 0.6763938545, "num_tokens": 3563, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.44040248238370705}}
{"text": "\\section{Prob 2. b)}\n\nFig. \\ref{fig:fig3} shows log-log plot of single points for $n(10^{-4})$, $n(10^{-2})$, $n(10^{-1})$, $n(1)$ and $n(5)$ withan axis range from $x=10^{-4}$ to $x_{max}=5$  and corresponding interpolation.\n\\lstinputlisting{interpolation.py}\n\n\\begin{figure}[ht!]\n  \\centering\n  \\includegraphics[width=0.9\\linewidth]{./plots/interpolation.png}\n  \\caption{Log-log Plot of $n(x)$ and its interpolation.}\n  \\label{fig:fig3}\n\\end{figure}\n\nOutput of $x$ and $n(x)$.\n\n\\lstinputlisting{density_profile.txt}", "meta": {"hexsha": "b94e9052ff0558d131bbb82587e66f71fd41430b", "size": 517, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Hand_in_exercise_1/interpolation.tex", "max_stars_repo_name": "rywjhzd/Numerical-Recipes-In-Astrophysics", "max_stars_repo_head_hexsha": "1f4bf40c504cd5f0117a9986c2756dcfd5bfc5c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Hand_in_exercise_1/interpolation.tex", "max_issues_repo_name": "rywjhzd/Numerical-Recipes-In-Astrophysics", "max_issues_repo_head_hexsha": "1f4bf40c504cd5f0117a9986c2756dcfd5bfc5c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Hand_in_exercise_1/interpolation.tex", "max_forks_repo_name": "rywjhzd/Numerical-Recipes-In-Astrophysics", "max_forks_repo_head_hexsha": "1f4bf40c504cd5f0117a9986c2756dcfd5bfc5c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4666666667, "max_line_length": 203, "alphanum_fraction": 0.6750483559, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4404024781750789}}
{"text": "% Copyright 2018 by Till Tantau\n%\n% This file may be distributed and/or modified\n%\n% 1. under the LaTeX Project Public License and/or\n% 2. under the GNU Free Documentation License.\n%\n% See the file doc/generic/pgf/licenses/LICENSE for more details.\n\n\n\\section{Constructing Paths}\n\n\\subsection{Overview}\n\nThe ``basic entity of drawing'' in \\pgfname\\ is the \\emph{path}. A path\nconsists of several parts, each of which is either a closed or open curve. An\nopen curve has a starting point and an end point and, in between, consists of\nseveral \\emph{segments}, each of which is either a straight line or a Bézier\ncurve. Here is an example of a path (in red) consisting of two parts, one open,\none closed:\n%\n\\begin{codeexample}[]\n\\begin{tikzpicture}[scale=2]\n  \\draw[thick,red]\n       (0,0) coordinate (a)\n    -- coordinate (ab) (1,.5) coordinate (b)\n    .. coordinate (bc) controls +(up:1cm) and +(left:1cm) .. (3,1)  coordinate (c)\n       (0,1) -- (2,1) -- coordinate (x) (1,2) -- cycle;\n\n  \\draw (a)  node[below] {start part 1}\n        (ab) node[below right] {straight segment}\n        (b)  node[right] {end first segment}\n        (c)  node[right] {end part 1}\n        (x)  node[above right]  {part 2 (closed)};\n\\end{tikzpicture}\n\\end{codeexample}\n\nA path, by itself, has no ``effect'', that is, it does not leave any marks on\nthe page. It is just a set of points on the plane. However, you can \\emph{use}\na path in different ways. The most natural actions are \\emph{stroking} (also\nknown as \\emph{drawing}) and \\emph{filling}. Stroking can be imagined as\npicking up a pen of a certain diameter and ``moving it along the path''.\nFilling means that everything ``inside'' the path is filled with a uniform\ncolor. Naturally, the open parts of a path must first be closed before a path\ncan be filled.\n\nIn \\pgfname, there are numerous commands for constructing paths, all of which\nstart with |\\pgfpath|. There are also commands for \\emph{using} paths, though\nmost operations can be performed by calling |\\pgfusepath| with an appropriate\nparameter.\n\nAs a side-effect, the path construction commands keep track of two bounding\nboxes. One is the bounding box for the current path, the other is a bounding\nbox for all paths in the current picture. See Section~\\ref{section-bb} for more\ndetails.\n\nEach path construction command extends the current path in some way. The\n``current path'' is a global entity that persists across \\TeX\\ groups. Thus,\nbetween calls to the path construction commands you can perform arbitrary\ncomputations and even open and close \\TeX\\ groups. The current path only gets\n``flushed'' when the |\\pgfusepath| command is called (or when the soft-path\nsubsystem is used directly, see Section~\\ref{section-soft-paths}).\n\n\n\\subsection{The Move-To Path Operation}\n\nThe most basic operation is the move-to operation. It must be given at the\nbeginning of paths, though some path construction command (like\n|\\pgfpathrectangle|) generate move-tos implicitly. A move-to operation can also\nbe used to start a new part of a path.\n\n\\begin{command}{\\pgfpathmoveto\\marg{coordinate}}\n    This command expects a \\pgfname-coordinate like |\\pgfpointorigin| as its\n    parameter. When the current path is empty, this operation will start the\n    path at the given \\meta{coordinate}. If a path has already been partly\n    constructed, this command will end the current part of the path and start a\n    new one.\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathlineto{\\pgfpoint{1cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{2cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{3cm}{0.5cm}}\n  \\pgfpathlineto{\\pgfpoint{3cm}{0cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathlineto{\\pgfpoint{1cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{2cm}{1cm}}\n  \\pgfpathmoveto{\\pgfpoint{2cm}{1cm}} % New part\n  \\pgfpathlineto{\\pgfpoint{3cm}{0.5cm}}\n  \\pgfpathlineto{\\pgfpoint{3cm}{0cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply the current coordinate transformation matrix to\n    \\meta{coordinate} before using it.\n\n    It will update the bounding box of the current path and picture, if\n    necessary.\n\\end{command}\n\n\n\\subsection{The Line-To Path Operation}\n\n\\begin{command}{\\pgfpathlineto\\marg{coordinate}}\n    This command extends the current path in a straight line to the given\n    \\meta{coordinate}. If this command is given at the beginning of path\n    without any other path construction command given before (in particular\n    without a move-to operation), the \\TeX\\ file may compile without an error\n    message, but a viewer application may display an error message when trying\n    to render the picture.\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathlineto{\\pgfpoint{1cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{2cm}{1cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply the current coordinate transformation matrix to\n    \\meta{coordinate} before using it.\n\n    It will update the bounding box of the current path and picture, if\n    necessary.\n\\end{command}\n\n\n\\subsection{The Curve-To Path Operations}\n\n\\begin{command}{\\pgfpathcurveto\\marg{support 1}\\marg{support 2}\\marg{coordinate}}\n    This command extends the current path with a Bézier curve from the last\n    point of the path to  \\meta{coordinate}. The \\meta{support 1} and\n    \\meta{support 2} are the first and second support point of the Bézier\n    curve. For more information on Bézier curves, please consult a standard\n    textbook on computer graphics.\n\n    Like the line-to command, this command may not be the first path\n    construction command in a path.\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathcurveto\n    {\\pgfpoint{1cm}{1cm}}{\\pgfpoint{2cm}{1cm}}{\\pgfpoint{3cm}{0cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply the current coordinate transformation matrix to\n    \\meta{coordinate} before using it.\n\n    It will update the bounding box of the current path and picture, if\n    necessary. However, the bounding box is simply made large enough such that\n    it encompasses all of the support points and the \\meta{coordinate}. This\n    will guarantee that the curve is completely inside the bounding box, but\n    the bounding box will typically be quite a bit too large. It is not clear\n    (to me) how this can be avoided without resorting to ``some serious math''\n    in order to calculate a precise bounding box.\n\\end{command}\n\n\\begin{command}{\\pgfpathquadraticcurveto\\marg{support}\\marg{coordinate}}\n    This command works like |\\pgfpathcurveto|, only it uses a quadratic Bézier\n    curve rather than a cubic one. This means that only one support point is\n    needed.\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathquadraticcurveto\n    {\\pgfpoint{1cm}{1cm}}{\\pgfpoint{2cm}{0cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    Internally, the quadratic curve is converted into a cubic curve. The only\n    noticeable effect of this is that the points used for computing the\n    bounding box are the control points of the converted curve rather than\n    \\meta{support}. The main effect of this is that the bounding box will be a\n    bit tighter than might be expected. In particular, \\meta{support} will not\n    always be part of the bounding box.\n\\end{command}\n\nThere exist two commands to draw only part of a cubic Bézier curve:\n\n\\begin{command}{\\pgfpathcurvebetweentime\\marg{time $t_1$}\\marg{time $t_2$}\\marg{point p}\\marg{point $s_1$}\\marg{point $s_2$}\\marg{point q}}\n    This command draws the part of the curve described by $p$, $s_1$, $s_2$ and\n    $q$ between the times $t_1$ and $t_2$. A time value of 0 indicates the\n    point $p$ and a time value of 1 indicates point $q$. This command includes\n    a moveto operation to the first point.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw [thin] (0,0) .. controls (0,2) and (3,0) .. (3,2);\n  \\pgfpathcurvebetweentime{0.25}{0.9}{\\pgfpointxy{0}{0}}{\\pgfpointxy{0}{2}}\n    {\\pgfpointxy{3}{0}}{\\pgfpointxy{3}{2}}\n  \\pgfsetstrokecolor{red}\n  \\pgfsetstrokeopacity{0.5}\n  \\pgfsetlinewidth{2pt}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n\\end{command}\n\n\\begin{command}{\\pgfpathcurvebetweentimecontinue\\marg{time $t_1$}\\marg{time $t_2$}\\marg{point p}\\marg{point $s_1$}\\marg{point $s_2$}\\marg{point q}}\n    This command works like |\\pgfpathcurvebetweentime|, except that a moveto\n    operation is \\emph{not} made to the first point.\n\\end{command}\n\n\n\\subsection{The Close Path Operation}\n\n\\begin{command}{\\pgfpathclose}\n    This command closes the current part of the path by appending a straight\n    line to the start point of the current part. Note that there \\emph{is} a\n    difference between closing a path and using the line-to operation to add a\n    straight line to the start of the current path. The difference is\n    demonstrated by the upper corners of the triangles in the following\n    example:\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfsetlinewidth{5pt}\n  \\pgfpathmoveto{\\pgfpoint{1cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{0cm}{-1cm}}\n  \\pgfpathlineto{\\pgfpoint{1cm}{-1cm}}\n  \\pgfpathclose\n  \\pgfpathmoveto{\\pgfpoint{2.5cm}{1cm}}\n  \\pgfpathlineto{\\pgfpoint{1.5cm}{-1cm}}\n  \\pgfpathlineto{\\pgfpoint{2.5cm}{-1cm}}\n  \\pgfpathlineto{\\pgfpoint{2.5cm}{1cm}}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n\\end{command}\n\n\n\\subsection{Arc, Ellipse and Circle Path Operations}\n\nThe path construction commands that we have discussed up to now are sufficient\nto create all paths that can be created ``at all''. However, it is useful to\nhave special commands to create certain shapes, like circles, that arise often\nin practice.\n\nIn the following, the commands for adding (parts of) (transformed) circles to a\npath are described.\n\n\\begin{command}{\\pgfpatharc\\marg{start angle}\\marg{end angle}{\\ttfamily\\char`\\{}\\meta{radius}\\opt{| and |\\meta{y-radius}}{\\ttfamily\\char`\\}}}\n    This command appends a part of a circle (or an ellipse) to the current\n    path. Imagine the curve between \\meta{start angle} and \\meta{end angle} on\n    a circle of radius \\meta{radius} (if $\\meta{start angle} < \\meta{end\n    angle}$, the curve goes around the circle counterclockwise, otherwise\n    clockwise). This curve is now moved such that the point where the curve\n    starts is the previous last point of the path. Note that this command will\n    \\emph{not} start a new part of the path, which is important for example for\n    filling purposes.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathlineto{\\pgfpoint{0cm}{1cm}}\n  \\pgfpatharc{180}{90}{.5cm}\n  \\pgfpathlineto{\\pgfpoint{3cm}{1.5cm}}\n  \\pgfpatharc{90}{-45}{.5cm}\n  \\pgfusepath{fill}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    Saying |\\pgfpatharc{0}{360}{1cm}| ``nearly'' gives you a full circle. The\n    ``nearly'' refers to the fact that the circle will not be closed. You can\n    close it using |\\pgfpathclose|.\n\n    If the optional \\meta{y-radius} is given, the \\meta{radius} is the\n    $x$-radius and the \\meta{y-radius} the $y$-radius of the ellipse from which\n    the curve is taken:\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharc{180}{45}{2cm and 1cm}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    The axes of the circle or ellipse from which the arc is ``taken'' always\n    point up and right. However, the current coordinate transformation matrix\n    will have an effect on the arc. This can be used to, say, rotate an arc:\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgftransformrotate{30}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharc{180}{45}{2cm and 1cm}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    The command will update the bounding box of the current path and picture,\n    if necessary. Unless rotation or shearing transformations are applied, the\n    bounding box will be tight.\n\\end{command}\n\n\\begin{command}{\\pgfpatharcaxes\\marg{start angle}\\marg{end angle}\\marg{first axis}\\marg{second axis}}\n    This command is similar to |\\pgfpatharc|. The main difference is how the\n    ellipse or circle is specified from which the arc is taken. The two\n    parameters \\meta{first axis} and \\meta{second axis} are the $0^\\circ$-axis\n    and the $90^\\circ$-axis of the ellipse from which the path is taken. Thus,\n    |\\pgfpatharc{0}{90}{1cm and 2cm}| has the same effect as\n    %\n\\begin{verbatim}\n\\pgfpatharcaxes{0}{90}{\\pgfpoint{1cm}{0cm}}{\\pgfpoint{0cm}{2cm}}\n\\end{verbatim}\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\draw (0,0) -- (2cm,5mm) (0,0) -- (0cm,1cm);\n\n  \\pgfpathmoveto{\\pgfpoint{2cm}{5mm}}\n  \\pgfpatharcaxes{0}{90}{\\pgfpoint{2cm}{5mm}}{\\pgfpoint{0cm}{1cm}}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n\\end{command}\n\n\\begin{command}{\\pgfpatharcto\\marg{x-radius}\\marg{y-radius}\\marg{rotation} \\marg{large arc flag}\\marg{counterclockwise flag}\\\\\\marg{target point}}\n    This command (which directly corresponds to the arc-path command of\n    \\textsc{svg}) is used to add an arc to the path that starts at the current\n    point and ends at \\meta{target point}. This arc is part of an ellipse that\n    is determined in the following way: Imagine an ellipse with radii\n    \\meta{x-radius} and \\meta{y-radius} that is rotated around its center by\n    \\meta{rotation} degrees. When you move this ellipse around in the plane,\n    there will be exactly two positions such that the two current point and the\n    target point lie on the border of the ellipse (excluding pathological\n    cases). The flags \\meta{large arc flag} and \\meta{clockwise flag} are then\n    used to decide which of these ellipses should be picked and which arc on\n    the picked ellipsis should be used.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n\n  \\pgfpathmoveto{\\pgfpoint{0mm}{20mm}}\n  \\pgfpatharcto{3cm}{1cm}{0}{0}{0}{\\pgfpoint{3cm}{1cm}}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n    Both flags are considered to be false exactly if they evaluate to |0|,\n    otherwise they are true. If the \\meta{large arc flag} is true, then the\n    angle spanned by the arc will be greater than $180^\\circ$, otherwise it\n    will be less than $180^\\circ$. The \\meta{clockwise flag} is used to\n    determine which of the two ellipses should be used: if the flag is true,\n    then the arc goes from the current point to the target point in a\n    counterclockwise direction, otherwise in a clockwise fashion.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\pgfsetlinewidth{2pt}\n  % Flags 0 0: red\n  \\pgfsetstrokecolor{red}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharcto{20pt}{10pt}{0}{0}{0}{\\pgfpoint{20pt}{10pt}}\n  \\pgfusepath{stroke}\n  % Flags 0 1: blue\n  \\pgfsetstrokecolor{blue}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharcto{20pt}{10pt}{0}{0}{1}{\\pgfpoint{20pt}{10pt}}\n  \\pgfusepath{stroke}\n  % Flags 1 0: orange\n  \\pgfsetstrokecolor{orange}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharcto{20pt}{10pt}{0}{1}{0}{\\pgfpoint{20pt}{10pt}}\n  \\pgfusepath{stroke}\n  % Flags 1 1: black\n  \\pgfsetstrokecolor{black}\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpatharcto{20pt}{10pt}{0}{1}{1}{\\pgfpoint{20pt}{10pt}}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n    \\emph{Warning:} The internal computations necessary for this command are\n    numerically very unstable. In particular, the arc will not always really\n    end at the \\meta{target coordinate}, but may be off by up to several\n    points. A more precise positioning is currently infeasible due to \\TeX's\n    numerical weaknesses. The only case it works quite nicely is when the\n    resulting angle is a multiple of~$90^\\circ$.\n\\end{command}\n\n\\begin{command}{\\pgfpatharctoprecomputed\\marg{center point}\\marg{start angle}\\marg{end angle}\\marg{end point}\\\\\\marg{x-radius}\\marg{y-radius}\\marg{ratio x-radius/y-radius}\\marg{ratio y-radius/x-radius}}\n    A specialized arc operation which is fast and numerically stable, provided\n    a lot of information is given in advance.\n\n    In contrast to |\\pgfpatharc|, it explicitly interpolates start and end\n    points.\n\n    In contrast to |\\pgfpatharcto|, this routine is numerically stable and\n    quite fast since it relies on a lot of available information.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n\n  \\def\\cx{1.5cm}% center x\n  \\def\\cy{1cm}% center y\n  \\def\\startangle{0}%\n  \\def\\endangle{270}%\n  \\def\\a{1.5cm}% xradius\n  \\def\\b{0.5cm}% yradius\n  \\pgfmathparse{\\a/\\b}\\let\\abratio=\\pgfmathresult\n  \\pgfmathparse{\\b/\\a}\\let\\baratio=\\pgfmathresult\n  %\n  % start point:\n  \\pgfpathmoveto{\\pgfpoint{\\cx+\\a*cos(\\startangle)}{\\cy+\\b*sin(\\startangle)}}%\n  \\pgfpatharctoprecomputed\n    {\\pgfpoint{\\cx}{\\cy}}\n    {\\startangle}\n    {\\endangle}\n    {\\pgfpoint{\\cx+\\a*cos(\\endangle)}{\\cy+\\b*sin(\\endangle)}}% end point\n    {\\a}\n    {\\b}\n    {\\abratio}\n    {\\baratio}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    \\begin{command}{\\pgfpatharctomaxstepsize}\n        The quality of arc approximation taken by |\\pgfpatharctoprecomputed| by\n        means of Bézier splines is controlled by a mesh width, which is\n        initially\n\n        |\\def\\pgfpatharctoprecomputed{45}|.\n\n        The mesh width is provided in (full!) degrees. The smaller the mesh\n        width, the more precise the arc approximation.\n\n        Use an empty value to disable spline approximation (uses a single cubic\n        polynomial for the complete arc).\n\n        The value must be an integer!\n    \\end{command}\n\\end{command}\n\n\\begin{command}{\\pgfpathellipse\\marg{center}\\marg{first axis}\\marg{second axis}}\n    The effect of this command is to append an ellipse to the current path (if\n    the path is not empty, a new part is started). The ellipse's center will be\n    \\meta{center} and \\meta{first axis} and \\meta{second axis} are the axis\n    \\emph{vectors}. The same effect as this command can also be achieved using\n    an appropriate sequence of move-to, arc, and close operations, but this\n    command is easier and faster.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfpathellipse{\\pgfpoint{1cm}{0cm}}\n                 {\\pgfpoint{1.5cm}{0cm}}\n                 {\\pgfpoint{0cm}{1cm}}\n  \\pgfusepath{draw}\n  \\color{red}\n  \\pgfpathellipse{\\pgfpoint{1cm}{0cm}}\n                 {\\pgfpoint{1cm}{1cm}}\n                 {\\pgfpoint{-0.5cm}{0.5cm}}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    The command will apply coordinate transformations to all coordinates of the\n    ellipse. However, the coordinate transformations are applied only after the\n    ellipse is ``finished conceptually''. Thus, a transformation of 1cm to the\n    right will simply shift the ellipse one centimeter to the right; it will\n    not add 1cm to the $x$-coordinates of the two axis vectors.\n\n    The command will update the bounding box of the current path and picture,\n    if necessary.\n\\end{command}\n\n\\begin{command}{\\pgfpathcircle\\marg{center}\\marg{radius}}\n    A shorthand for |\\pgfpathellipse| applied to \\meta{center} and the two axis\n    vectors $(\\meta{radius},0)$ and $(0,\\meta{radius})$.\n\\end{command}\n\n\n\\subsection{Rectangle Path Operations}\n\nAnother shape that arises frequently is the rectangle. Two commands can be used\nto add a rectangle to the current path. Both commands will start a new part of\nthe path.\n\n\\begin{command}{\\pgfpathrectangle\\marg{corner}\\marg{diagonal vector}}\n    Adds a rectangle to the path whose one corner is \\meta{corner} and whose\n    opposite corner is given by $\\meta{corner} + \\meta{diagonal vector}$.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfpathrectangle{\\pgfpoint{1cm}{0cm}}{\\pgfpoint{1.5cm}{1cm}}\n  \\pgfpathrectangle{\\pgfpoint{1.5cm}{0.25cm}}{\\pgfpoint{1.5cm}{1cm}}\n  \\pgfpathrectangle{\\pgfpoint{2cm}{0.5cm}}{\\pgfpoint{1.5cm}{1cm}}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes tightly.\n\\end{command}\n\n\\begin{command}{\\pgfpathrectanglecorners\\marg{corner}\\marg{opposite corner}}\n    Adds a rectangle to the path whose two opposing corners are \\meta{corner}\n    and \\meta{opposite corner}.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n  \\pgfpathrectanglecorners{\\pgfpoint{1cm}{0cm}}{\\pgfpoint{1.5cm}{1cm}}\n  \\pgfusepath{draw}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes tightly.\n\\end{command}\n\n\n\\subsection{The Grid Path Operation}\n\n\\begin{command}{\\pgfpathgrid\\oarg{options}\\marg{first corner}\\marg{second corner}}\n    Appends a grid to the current path. That is, a (possibly large) number of\n    parts are added to the path, each part consisting of a single horizontal or\n    vertical straight line segment.\n\n    Conceptually, the origin is part of the grid and the grid is clipped to the\n    rectangle specified by the \\meta{first corner} and the \\meta{second\n    corner}. However, no clipping occurs (this command just adds parts to the\n    current path) and the points where the lines enter and leave the ``clipping\n    area'' are computed and used to add simple lines to the current path.\n\n    The following keys influence the grid:\n    %\n    \\begin{key}{/pgf/stepx=\\meta{dimension} (initially 1cm)}\n        The horizontal stepping.\n    \\end{key}\n    %\n    \\begin{key}{/pgf/stepy=\\meta{dimension} (initially 1cm)}\n        The vertical stepping.\n    \\end{key}\n    %\n    \\begin{key}{/pgf/step=\\meta{vector}}\n        Sets the horizontal stepping to the $x$-coordinate of \\meta{vector} and\n        the vertical stepping to its $y$-coordinate.\n    \\end{key}\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfsetlinewidth{0.8pt}\n  \\pgfpathgrid[step={\\pgfpoint{1cm}{1cm}}]\n    {\\pgfpoint{-3mm}{-3mm}}{\\pgfpoint{33mm}{23mm}}\n  \\pgfusepath{stroke}\n  \\pgfsetlinewidth{0.4pt}\n  \\pgfpathgrid[stepx=1mm,stepy=1mm]\n    {\\pgfpoint{-1.5mm}{-1.5mm}}{\\pgfpoint{31.5mm}{21.5mm}}\n  \\pgfusepath{stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes. As for ellipses, the transformations are applied to the\n    ``conceptually finished'' grid.\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgftransformrotate{10}\n  \\pgfpathgrid[stepx=1mm,stepy=2mm]{\\pgfpoint{0mm}{0mm}}{\\pgfpoint{30mm}{30mm}}\n  \\pgfusepath{stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n\\end{command}\n\n\n\\subsection{The Parabola Path Operation}\n\n\\begin{command}{\\pgfpathparabola\\marg{bend vector}\\marg{end vector}}\n    This command appends two half-parabolas to the  current path. The first\n    starts at the current point and ends at the current point plus \\meta{bend\n    vector}. At this point, it has its bend. The second half parabola starts at\n    that bend point and ends at point that is given by the bend plus \\meta{end\n    vector}.\n\n    If you set \\meta{end vector} to the null vector, you append only a half\n    parabola that goes from the current point to the bend; by setting\n    \\meta{bend vector} to the null vector, you append only a half parabola that\n    goes through the current point and \\meta{end vector} and has its bend at\n    the current point.\n\n    It is not possible to use this command to draw a part of a parabola that\n    does not contain the bend.\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  % Half-parabola going ``up and right''\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathparabola{\\pgfpointorigin}{\\pgfpoint{2cm}{4cm}}\n  \\color{red}\n  \\pgfusepath{stroke}\n\n  % Half-parabola going ``down and right''\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathparabola{\\pgfpoint{-2cm}{4cm}}{\\pgfpointorigin}\n  \\color{blue}\n  \\pgfusepath{stroke}\n\n  % Full parabola\n  \\pgfpathmoveto{\\pgfpoint{-2cm}{2cm}}\n  \\pgfpathparabola{\\pgfpoint{1cm}{-1cm}}{\\pgfpoint{2cm}{4cm}}\n  \\color{orange}\n  \\pgfusepath{stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes.\n\\end{command}\n\n\n\\subsection{Sine and Cosine Path Operations}\n\nSine and cosine curves often need to be drawn and the following commands may\nhelp with this. However, they only allow you to append sine and cosine curves\nin intervals that are multiples of $\\pi/2$.\n\n\\begin{command}{\\pgfpathsine\\marg{vector}}\n    This command appends a sine curve in the interval $[0,\\pi/2]$ to the\n    current path. The sine curve is squeezed or stretched such that the curve\n    starts at the current point and ends at the current point plus\n    \\meta{vector}.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,1);\n  \\pgfpathmoveto{\\pgfpoint{1cm}{0cm}}\n  \\pgfpathsine{\\pgfpoint{1cm}{1cm}}\n  \\pgfusepath{stroke}\n\n  \\color{red}\n  \\pgfpathmoveto{\\pgfpoint{1cm}{0cm}}\n  \\pgfpathsine{\\pgfpoint{-2cm}{-2cm}}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes.\n\\end{command}\n\n\\begin{command}{\\pgfpathcosine\\marg{vector}}\n    This command appends a cosine curve in the interval $[0,\\pi/2]$ to the\n    current path. The curve is squeezed or stretched such that the curve starts\n    at the current point and ends at the current point plus \\meta{vector}.\n    Using several sine and cosine operations in sequence allows you to produce\n    a complete sine or cosine curve\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfpathmoveto{\\pgfpoint{0cm}{0cm}}\n  \\pgfpathsine{\\pgfpoint{1cm}{1cm}}\n  \\pgfpathcosine{\\pgfpoint{1cm}{-1cm}}\n  \\pgfpathsine{\\pgfpoint{1cm}{-1cm}}\n  \\pgfpathcosine{\\pgfpoint{1cm}{1cm}}\n  \\pgfsetfillcolor{yellow!80!black}\n  \\pgfusepath{fill,stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n    %\n    The command will apply coordinate transformations and update the bounding\n    boxes.\n\\end{command}\n\n\n\\subsection{Plot Path Operations}\n\nThere exist several commands for appending plots to a path. These commands are\navailable through the module |plot|. They are documented in\nSection~\\ref{section-plots}.\n\n\n\\subsection{Rounded Corners}\n\nNormally, when you connect two straight line segments or when you connect two\ncurves that end and start ``at different angles'', you get ``sharp corners''\nbetween the lines or curves. In some cases it is desirable to produce ``rounded\ncorners'' instead. Thus, the lines or curves should be shortened a bit and then\nconnected by arcs.\n\n\\pgfname\\ offers an easy way to achieve this effect, by calling the following\ntwo commands.\n\n\\begin{command}{\\pgfsetcornersarced\\marg{point}}\n    This command causes all subsequent corners to be replaced by little\n    arcs. The effect of this command lasts till the end of the current\n    \\TeX\\ scope.\n\n    The \\meta{point} dictates how large the corner arc will be. Consider a\n    corner made by two lines $l$ and~$r$ and assume that the line $l$ comes\n    first on the path. The $x$-dimension of the \\meta{point} decides by how\n    much the line~$l$ will be shortened, the $y$-dimension of \\meta{point}\n    decides by how much the line $r$ will be shortened. Then, the shortened\n    lines are connected by an arc.\n    %\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n\n  \\pgfsetcornersarced{\\pgfpoint{5mm}{5mm}}\n  \\pgfpathrectanglecorners{\\pgfpointorigin}{\\pgfpoint{3cm}{2cm}}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n\n\\begin{codeexample}[]\n\\begin{tikzpicture}\n  \\draw[help lines] (0,0) grid (3,2);\n\n  \\pgfsetcornersarced{\\pgfpoint{10mm}{5mm}}\n  % 10mm entering,\n  % 5mm leaving.\n  \\pgfpathmoveto{\\pgfpointorigin}\n  \\pgfpathlineto{\\pgfpoint{0cm}{2cm}}\n  \\pgfpathlineto{\\pgfpoint{3cm}{2cm}}\n  \\pgfpathcurveto\n    {\\pgfpoint{3cm}{0cm}}\n    {\\pgfpoint{2cm}{0cm}}\n    {\\pgfpoint{1cm}{0cm}}\n  \\pgfusepath{stroke}\n\\end{tikzpicture}\n\\end{codeexample}\n\n    If the $x$- and $y$-coordinates of \\meta{point} are the same and the corner\n    is a right angle, you will get a perfect quarter circle (well, not quite\n    perfect, but perfect up to six decimals). When the angle is not $90^\\circ$,\n    you only get a fair approximation.\n\n    More or less ``all'' corners will be rounded, even the corner generated by\n    a |\\pgfpathclose| command. (The author is a bit proud of this feature.)\n    %\n\\begin{codeexample}[]\n\\begin{pgfpicture}\n  \\pgfsetcornersarced{\\pgfpoint{4pt}{4pt}}\n  \\pgfpathmoveto{\\pgfpointpolar{0}{1cm}}\n  \\pgfpathlineto{\\pgfpointpolar{72}{1cm}}\n  \\pgfpathlineto{\\pgfpointpolar{144}{1cm}}\n  \\pgfpathlineto{\\pgfpointpolar{216}{1cm}}\n  \\pgfpathlineto{\\pgfpointpolar{288}{1cm}}\n  \\pgfpathclose\n  \\pgfusepath{stroke}\n\\end{pgfpicture}\n\\end{codeexample}\n\n    To return to normal (unrounded) corners, use\n    |\\pgfsetcornersarced{\\pgfpointorigin}|.\n\n    Note that the rounding will produce strange and undesirable effects if the\n    lines at the corners are too short. In this case the shortening may cause\n    the lines to ``suddenly extend over the other end'' which is rarely\n    desirable.\n\\end{command}\n\n\n\\subsection{Internal Tracking of Bounding Boxes for Paths and Pictures}\n\\label{section-bb}\n\n\\makeatletter\n\nThe path construction commands keep track of two bounding boxes: One for the\ncurrent path, which is reset whenever the path is used and thereby flushed, and\na bounding box for the current |{pgfpicture}|.\n\n\\begin{command}{\\pgfresetboundingbox}\n    Resets the picture's bounding box. The picture will simply forget any\n    previous bounding box updates and start collecting from scratch.\n\n    You can use this together with |\\pgfusepath{use as bounding box}| to\n    replace the bounding box by the one of a particular path (ignoring\n    subsequent paths).\n\\end{command}\n\nThe bounding boxes are not accessible by ``normal'' macros. Rather, two sets of\nfour dimension variables are used for this, all of which contain the\nletter~|@|.\n\n\\begin{textoken}{\\pgf@pathminx}\n    The minimum $x$-coordinate ``mentioned'' in the current path. Initially,\n    this is set to $16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@pathmaxx}\n    The maximum $x$-coordinate ``mentioned'' in the current path. Initially,\n    this is set to $-16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@pathminy}\n    The minimum $y$-coordinate ``mentioned'' in the current path. Initially,\n    this is set to $16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@pathmaxy}\n    The maximum $y$-coordinate ``mentioned'' in the current path. Initially,\n    this is set to $-16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@picminx}\n    The minimum $x$-coordinate ``mentioned'' in the current picture. Initially,\n    this is set to $16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@picmaxx}\n    The maximum $x$-coordinate ``mentioned'' in the current picture. Initially,\n    this is set to $-16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@picminy}\n    The minimum $y$-coordinate ``mentioned'' in the current picture. Initially,\n    this is set to $16000$pt.\n\\end{textoken}\n\n\\begin{textoken}{\\pgf@picmaxy}\n    The maximum $y$-coordinate ``mentioned'' in the current picture. Initially,\n    this is set to $-16000$pt.\n\\end{textoken}\n\n\nEach time a path construction command is called, the above variables are\n(globally) updated. To facilitate this, you can use the following command:\n\n\\begin{command}{\\pgf@protocolsizes\\marg{x-dimension}\\marg{y-dimension}}\n    Updates all of the above dimensions in such a way that the point specified\n    by the two arguments is inside both bounding boxes. For the picture's\n    bounding box this updating occurs only if |\\ifpgf@relevantforpicturesize|\n    is true, see below.\n\\end{command}\n\nFor the bounding box of the picture it is not always desirable that every path\nconstruction command affects this bounding box. For example, if you have just\nused a clip command, you do not want anything outside the clipping area to\naffect the bounding box. For this reason, there exists a special ``\\TeX\\ if''\nthat (locally) decides whether updating should be applied to the picture's\nbounding box. Clipping will set this if to false, as will certain other\ncommands.\n\n\\begin{command}{\\pgf@relevantforpicturesizefalse}\n    Suppresses updating of the picture's bounding box.\n\\end{command}\n\n\\begin{command}{\\pgf@relevantforpicturesizetrue}\n    Causes updating of the picture's bounding box.\n\\end{command}\n", "meta": {"hexsha": "690de303d477f54c2332b37464b233da4f56635f", "size": 32919, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-paths.tex", "max_stars_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_stars_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-paths.tex", "max_issues_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_issues_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-paths.tex", "max_forks_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_forks_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5359179019, "max_line_length": 202, "alphanum_fraction": 0.7219842644, "num_tokens": 9938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.44040247369180296}}
{"text": "\n\\section{The \\reverse algorithm}\n\\Label{sec:reverse}\n\nThe \\reverse algorithm of the \\cxx Standard Library\n\\cite[\\S 28.6.10]{cxx-17-draft} inverts the order of elements \\emph{within} a sequence.\nThe signature of our version of \\reverse reads.\n\n\\begin{lstlisting}[style=acsl-block]\n\n  void reverse(value_type* a, size_type n);\n\\end{lstlisting}\n\n\n\\subsection{Formal specification of \\reverse}\n\nThe specification for the \\specref{reverse} function is shown in the following listing.\n\n\\input{Listings/reverse.h.tex}\n\n\\subsection{Implementation of \\reverse}\n\nSince the implementation of \\implref{reverse} operates \\emph{in place}\nwe use \\specref{swap} in order to exchange the elements of the first half\nof the array with the corresponding elements of the second half.\nWe reuse the predicates \\logicref{Reverse} and \\logicref{Unchanged}\nin order to write concise loop invariants.\n\n\\input{Listings/reverse.c.tex}\n\n", "meta": {"hexsha": "692ff94920367ea9f34a40b9ef1b30411342565d", "size": 908, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/mutating/reverse.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/mutating/reverse.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/mutating/reverse.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 29.2903225806, "max_line_length": 87, "alphanum_fraction": 0.7797356828, "num_tokens": 233, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.44040246499989893}}
{"text": "\n\\subsection{The Hausman specification test}\n\n\\subsubsection{Introduction}\n\nThe Hausman specification test allows you to choose between a fixed effects model and a random effects model.\n\n\\subsubsection{Efficiency}\n\nRandom effects models are more efficient.\n\n", "meta": {"hexsha": "df3a317304687e5bb7ef3af08dc089659a703d6e", "size": 258, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/statistics/generalLinearModels/05-01-hausman.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/statistics/generalLinearModels/05-01-hausman.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/statistics/generalLinearModels/05-01-hausman.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.5, "max_line_length": 109, "alphanum_fraction": 0.8178294574, "num_tokens": 50, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.44040246472525124}}
{"text": "%\n% Licensed to the OpenAirInterface (OAI) Software Alliance under one or more\n% contributor license agreements.  See the NOTICE file distributed with\n% this work for additional information regarding copyright ownership.\n% The OpenAirInterface Software Alliance licenses this file to You under\n% the OAI Public License, Version 1.1  (the \"License\"); you may not use this file\n% except in compliance with the License.\n% You may obtain a copy of the License at\n%\n%      http://www.openairinterface.org/?page_id=698\n%\n% Unless required by applicable law or agreed to in writing, software\n% distributed under the License is distributed on an \"AS IS\" BASIS,\n% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n% See the License for the specific language governing permissions and\n% limitations under the License.\n%-------------------------------------------------------------------------------\n% For more information about the OpenAirInterface (OAI) Software Alliance:\n%      contact@openairinterface.org\n%\n\n\\documentclass{article}\n\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{booktabs}\n\\usepackage{url}\n\\usepackage{tcolorbox}\n\n\\usepackage{tikz}\n\\usetikzlibrary{arrows,decorations,shapes,backgrounds,patterns}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=newest}\n\\definecolor{green}{RGB}{32,127,43}\n\\usetikzlibrary{calc}\n\n\\usepackage{listings}\n\\lstdefinestyle{customc}{\n  belowcaptionskip=1\\baselineskip,\n  breaklines=true,\n  frame=L,\n  xleftmargin=\\parindent,\n  language=C,\n  showstringspaces=false,\n  basicstyle=\\footnotesize\\ttfamily,\n  keywordstyle=\\bfseries\\color{green!40!black},\n  commentstyle=\\itshape\\color{purple!40!black},\n  identifierstyle=\\color{blue},\n  stringstyle=\\color{orange},\n}\n\\lstset{escapechar=@,style=customc}\n\n\\title{NR LDPC Decoder}\n\\author{Sebastian Wagner (TCL)}\n\\date{\\today}\n\n\\def\\0{\\mathbf{0}}\n\\def\\b{\\mathbf{b}}\n\\def\\Bbb{\\mathbb{B}}\n\\def\\Bcal{\\mathcal{B}}\n\\def\\c{\\mathbf{c}}\n\\def\\C{\\mathbf{C}}\n\\def\\Cbb{\\mathbb{C}}\n\\def\\Ccal{\\mathcal{C}}\n\\def\\eqdef{\\triangleq}\n\\def\\g{\\mathbf{g}}\n\\def\\G{\\mathbf{G}}\n\\def\\Gcal{\\mathcal{G}}\n\\def\\h{\\mathbf{h}}\n\\def\\H{\\mathbf{H}}\n\\def\\Hbg{\\mathbf{H}_\\mathrm{BG}}\n\\def\\Hbgo{\\mathbf{H}_\\mathrm{BG1}}\n\\def\\Hbgt{\\mathbf{H}_\\mathrm{BG2}}\n\\def\\I{\\mathbf{I}}\n\\def\\Kb{{K_b}}\n\\def\\m{\\mathbf{m}}\n\\def\\Mb{{M_b}}\n\\def\\Nb{{N_b}}\n\\def\\Nbb{\\mathbb{N}}\n\\def\\n{\\mathbf{n}}\n\\def\\nr{{n_{\\rm r}}}\n\\def\\nt{{n_{\\rm t}}}\n\\def\\s{\\mathbf{s}}\n\\def\\SNR{\\mathsf{SNR}}\n\\def\\y{\\mathbf{y}}\n\\def\\z{\\mathbf{z}}\n\\def\\Z{\\mathbf{Z}}\n\\def\\Zc{{Z_c}}\n\n\n\\def\\herm{\\mathsf{H}}\n\\def\\trans{\\mathsf{T}}\n\\def\\EE{\\mathsf{E}}\n\\newcommand{\\sgn}{\\operatorname{sgn}}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{tikzpicture}[remember picture,overlay]\n   \\node[anchor=north west,inner sep=0pt] at (current page.north west)\n              {\\includegraphics[scale=0.5]{logo.png}};\n\\end{tikzpicture}\n\n\n\\begin{center}Currently Supported:\\end{center}\n\\tcbox[center]{\n    \\begin{tabular}{lll}\n      \\toprule\n      \\textbf{BG} & \\textbf{Lifting Size Z} & \\textbf{Code Rate R} \\\\\n      \\midrule\n        1 & all & 1/3, 2/3, 8/9 \\\\\n        2 & all & 1/5, 1/3, 2/3 \\\\\n      \\bottomrule\n    \\end{tabular}\n}\n\n\\paragraph{Version 1.0:}\n\\begin{itemize}\n\\item Initial version\n\\end{itemize}\n\n\\paragraph{Version 2.0:}\n\\begin{itemize}\n\\item Enhancements in message passing:\n  \\begin{itemize}\n  \\item LUTs replaced by smaller BG-specific parameters\n  \\item Inefficient load/store replaced by circular memcpy\n  \\end{itemize}\n\\item Bug fixes:\n  \\begin{itemize}\n  \\item Fixed bug in function \\texttt{llr2CnProcBuf}\n  \\item Corrected input LLR dynamic range in BLER simulations\n  \\end{itemize}\n\\item Results:\n  \\begin{itemize}\n  \\item Size of LUTs reduced significantly (60MB to 200KB)\n  \\item Siginifcantly enhances execution time (factor 3.5)\n  \\item Improved BLER performance (all simulation results have been updated)\n  \\end{itemize}\n\\end{itemize}\n\n\n\\newpage\n\\tableofcontents\n\n\\newpage\n\\section{Introduction}\n\\label{sec:introduction}\n\nLow Density Parity Check (LDPC) codes have been developed by Gallager in 1963 \\cite{gallager1962low}. They are linear error correcting codes that are capacity-achieving for large block length and are completely described by their Parity Check Matrix (PCM) $\\H^{M\\times N}$. The PCM $\\H$ defines $M$ constraints on the codeword $\\c$ of length $N$ such that\n\\begin{equation}\n  \\label{eq:29}\n  \\H\\c = \\0.\n\\end{equation}\nThe number of information bits $B$ that can be encoded with $\\H$ is given by $B=N-M$. Hence the code rate $R$ of $\\H$ reads\n\\begin{equation}\n  \\label{eq:37}\n  R = \\frac{B}{N} = 1-\\frac{M}{N}.\n\\end{equation}\n\n\n\\subsection{LDPC in NR}\n\\label{sec:ldpc-nr}\n\nNR uses quasi-cyclic (QC) Protograph LDPC codes, i.e. a smaller graph, called Base Graph (BG), is defined and utilized to construct the larger PCM. This has the advantage that the large PCM does not have to be stored in memory and allows for a more efficient implementation while maintaining good decoding properties.\nTwo BGs $\\Hbg\\in\\Nbb^{\\Mb\\times \\Nb}$ are defined in NR:\n\\begin{enumerate}\n\\item $\\Hbgo\\in\\Nbb^{46\\times 68}$\n\\item $\\Hbgt\\in\\Nbb^{42\\times 52}$\n\\end{enumerate}\nwhere $\\Nbb$ is the set of integers. For instance the first 3 rows and 13 columns of BG2 are given by\n\n\\setcounter{MaxMatrixCols}{30}\n\\begin{equation*}\n  \\label{eq:33}\n  \\Hbgt =\n  \\begin{bmatrix}\n    9   & 117       & 204       & 26  & \\emptyset & \\emptyset & 189       & \\emptyset & \\emptyset & 205       & 0         & 0         & \\emptyset & \\emptyset \\\\\n    127 & \\emptyset & \\emptyset & 166 & 253       & 125       & 226       & 156       & 224       & 252       & \\emptyset & 0         & 0         & \\emptyset \\\\\n    81  & 114       & \\emptyset & 44  & 52        & \\emptyset & \\emptyset & \\emptyset & 240       & \\emptyset & 1         & \\emptyset & 0         & 0\n  \\end{bmatrix}.\n\\end{equation*}\n\nTo obtain the PCM $\\H$ from the BG $\\Hbg$, each element $\\Hbg(i,j)$ in the BG is replaced by a lifting matrix of size $\\Zc\\times \\Zc$ according to\n\\begin{equation}\n  \\label{eq:35}\n  \\Hbg(i,j) =\n  \\begin{cases}\n    \\0 & \\textrm{if}~ \\Hbg(i,j)=\\emptyset \\\\\n    \\I_{P_{ij}} & \\textrm{otherwise}\n  \\end{cases}\n\\end{equation}\nwhere $\\I_{P_{ij}}$ is the identity matrix circularly shifted to the right by $P_{ij} = \\Hbg(i,j)\\mod \\Zc$. Hence, the resulting PCM $\\H$ will be of size $\\Mb\\Zc\\times\\Nb\\Zc$.\n\nThe lifting size $\\Zc$ depends on the number of bits to encode. To limit the complexity, a discrete set $\\mathcal{Z}$ of possible values of $\\Zc$ has been defined in \\cite{3gpp2017_38212} and the optimal value $\\Zc$ is calculated according to\n\\begin{equation}\n  \\label{eq:36}\n  \\Zc = \\min_{\\Z\\in\\mathcal{Z}}\\left[Z\\geq\\frac{B}{\\Nb}\\right].\n\\end{equation}\n\nThe base rate of the two BGs is $1/3$ and $1/5$ for BG1 and BG2, respectively. That is, BG1 encodes $K=22\\Zc$ bits and BG2 encodes $K=10\\Zc$ bits. Note that the first 2 columns of BG 1 and 2 are always punctured, that is after encoding, the first $2\\Zc$ bits are discarded and not transmitted.\nFor instance, consider $B=500$ information bits to encode using BG2, \\eqref{eq:36} yields $\\Zc=64$ hence $K=640$. Since $K>B$, $K-B=140$ filler bits are appended to the information bits. The PCM $\\Hbgt$ is of size $2688\\times 3328$ and the $640$ bits $\\b$ are encoded according to \\eqref{eq:29} at a rate $R \\approx 0.192$. To achieve the higher base rate of $0.2$, the first $128$ are punctured, i.e. instead of transmitting all $3328$ bits, only $3200$ are transmitted resulting in the desired rate $R=640/3200=0.2$.\n\n\\subsection{LDPC Decoding}\n\\label{sec:ldpc-decoding}\n\nThe decoding of codeword $\\c$ can be achieved via the classical message passing algorithm. This algorithm can be illustrated best using the Tanner graph of the PCM. The rows of the PCM are called check nodes (CN) since they represent the parity check equations. The parity check equation of each of these check nodes involves various bits in the codeword. Similarly, every column of the PCM corresponds to a bit and each bit is involved in several parity check equations. In the Tanner graph representation, the bits are called bit nodes (BN). Let's go back to the previous example of BG2 and assume $\\Zc=2$, hence the first 3 rows and 13 columns of BG2 $\\Hbgt$ read\n\\begin{equation*}\n  \\label{eq:36}\n  \\Hbgt =\n  \\begin{bmatrix}\n    1 & 1         & 0         & 0 & \\emptyset & \\emptyset & 1         & \\emptyset & \\emptyset & 1         & 0         & 0         & \\emptyset & \\emptyset \\\\\n    1 & \\emptyset & \\emptyset & 0 & 1         & 1         & 0         & 0         & 0         & 0         & \\emptyset & 0         & 0         & \\emptyset \\\\\n    1 & 0         & \\emptyset & 0 & 0         & \\emptyset & \\emptyset & \\emptyset & 0         & \\emptyset & 1         & \\emptyset & 0         & 0\n  \\end{bmatrix}.\n\\end{equation*}\nReplacing the elements according to \\eqref{eq:35}, we obtain the first 6 rows and 26 columns of the PCM as\n\\begin{equation*}\n  \\label{eq:39}\n  \\H =\n  \\begin{bmatrix}\n    0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\\\\n    1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n    0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0\\\\\n    1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0\\\\\n    0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0\\\\\n    1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 1\n  \\end{bmatrix}.\n\\end{equation*}\n\nThe Tanner graph of the first 8 BNs is shown in Figure \\ref{fig:tannergraph}.\n\n\\begin{figure}[ht]\n  \\label{fig:tannergraph}\n  \\centering\n  \\def\\ww{0.3cm}\n  \\def\\hh{0.3cm}\n  \\tikzstyle{cnode}=[fill=white,rectangle,draw=black,thick,inner sep=2pt, minimum height=\\hh,minimum width=\\ww, rounded corners=1pt,text width=\\ww]\n  \\tikzstyle{vnode}=[fill=white,circle,draw=black,thick,inner sep=2pt, minimum height=\\hh,minimum width=\\ww, rounded corners=1pt,text width=\\ww]\n  \\tikzstyle{connector}=[<->,>=latex',semithick]\n\n  \\begin{tikzpicture}\n    \\tikzstyle{every node}=[node distance=1.5cm,text centered]\n    % Check nodes\n    \\node[cnode, label=above:$v_0$] (v0) {};\n    \\node[cnode, label=above:$v_1$, right of=v0] (v1) {};\n    \\node[cnode, label=above:$v_2$, right of=v1] (v2) {};\n    % Variable nodes\n    \\node[vnode, label=below:$c_3$, below of=v1, node distance=1.5cm] (c3) {};\n    \\node[vnode, label=below:$c_2$, left of=c3, node distance=1.5cm] (c2) {};\n    \\node[vnode, label=below:$c_1$, left of=c2, node distance=1.5cm] (c1) {};\n    \\node[vnode, label=below:$c_0$, left of=c1, node distance=1.5cm] (c0) {};\n    \\node[vnode, label=below:$c_4$, right of=c3, node distance=1.5cm] (c4) {};\n    \\node[vnode, label=below:$c_5$, right of=c4, node distance=1.5cm] (c5) {};\n    \\node[vnode, label=below:$c_6$, right of=c5, node distance=1.5cm] (c6) {};\n\n    % Draw edges\n    \\draw (c0) edge[connector] (v1);\n    \\draw (c1) edge[connector] (v0);\n    \\draw (c1) edge[connector] (v2);\n    \\draw (c2) edge[connector] (v1);\n    \\draw (c3) edge[connector] (v0);\n    \\draw (c4) edge[connector] (v0);\n    \\draw (c4) edge[connector] (v2);\n    \\draw (c5) edge[connector] (v1);\n    \\draw (c6) edge[connector] (v0);\n    \\draw (c6) edge[connector] (v2);\n\n  \\end{tikzpicture}\n\n  \\caption{Tanner graph for first 7 bits nodes and 3 check nodes from \\eqref{eq:39}.}\n\\end{figure}\n\nThe message passing algorithm is an iterative algorithm where probabilities of the bits (being either 0 or 1) are exchanged between the BNs and CNs. After sufficient iterations, the probabilities will have either converged to either 0 or 1 and the parity check equations will be satisfied, at this point, the codeword has been decoded correctly.\n\n\\newpage\n\\section{LDPC Decoder Implementation}\n\\label{sec:ldpc-implementation}\n\nThe implementation on a general purpose processor (GPP) has to take advantage of potential instruction extension of the processor architecture. We focus on the Intel x86 instruction set architecture (ISA) and its advanced vector extension (AVX). In particular, we utilize AVX2 with its 256-bit single instruction multiple data (SIMD) format. In order to utilize AVX2 to speed up the processing at the CNs and BNs, the corresponding data has to be ordered/aligned in a specific way. The processing flow of the LDPC decoder is depicted in \\ref{fig:ldpc_decoder_flow}.\n\n\\begin{figure}[ht]\n  \\label{fig:ldpc_decoder_flow}\n  \\centering\n  \\def\\ww{0.3cm}\n  \\def\\hh{0.3cm}\n  \\tikzstyle{func}=[,draw=none]\n  \\tikzstyle{connector}=[->,>=latex',semithick]\n\n  \\begin{tikzpicture}\n    \\tikzstyle{every node}=[node distance=2.5cm,text centered]\n    % Check nodes\n    % First iteration\n    \\node[func]                               (llr2llrProcBuf) {\\texttt{llr2llrProcBuf}};\n    \\node[func, above of=llr2llrProcBuf]      (llr2CnProcBuf)  {\\texttt{llr2CnProcBuf}};\n    \\node[func, above right of=llr2CnProcBuf] (cnProc1)        {\\texttt{cnProc}};\n    \\node[func, below right of=cnProc1]       (cn2bnProcBuf1)  {\\texttt{cn2bnProcBuf}};\n    \\node[func, below  of=cn2bnProcBuf1]      (bnProcPc1)      {\\texttt{bnProcPc}};\n\n    % Iterations\n    \\node[func, right of=cnProc1, node distance=7cm] (cnProc)       {\\texttt{cnProc}};\n    \\node[func, below right of=cnProc]               (cn2bnProcBuf) {\\texttt{cn2bnProcBuf}};\n    \\node[func, below of=cn2bnProcBuf]               (bnProcPc)     {\\texttt{bnProcPc}};\n    \\node[func, below left of=cnProc]                (bn2cnProcBuf) {\\texttt{bn2cnProcBuf}};\n    \\node[func, below  of=bn2cnProcBuf]              (bnProc)       {\\texttt{bnProc}};\n\n    % Post processing\n    \\node[func, below of=bnProcPc]      (llrRes2llrOut) {\\texttt{llrRes2llrOut}};\n    \\node[func, below of=llrRes2llrOut, node distance=1cm] (llr2bit) {\\texttt{llr2bit}};\n\n    % Draw edges\n    \\draw (llr2llrProcBuf)  edge[connector] (llr2CnProcBuf);\n    \\draw (llr2CnProcBuf)   edge[connector] (cnProc1);\n    \\draw (cnProc1)         edge[connector] (cn2bnProcBuf1);\n    \\draw (cn2bnProcBuf1)   edge[connector] (bnProcPc1);\n\n    \\draw (bnProcPc)       edge[connector] (bnProc);\n    \\draw (bnProc)         edge[connector] (bn2cnProcBuf);\n    \\draw (bn2cnProcBuf)   edge[connector] node[above left] {\\texttt{cnProcPc}} (cnProc);\n    \\draw (cnProc)         edge[connector] (cn2bnProcBuf);\n    \\draw (cn2bnProcBuf)   edge[connector] (bnProcPc);\n\n    \\draw (bnProcPc1)      edge[connector] (bnProc);\n\n    \\draw (bnProcPc) edge[connector] node[left] {iterations done} (llrRes2llrOut);\n    \\draw (llrRes2llrOut) edge[connector] (llr2bit);\n\n    % Boxes\n    \\node[inner sep=0pt,above right of=cn2bnProcBuf1, node distance = 2.5cm] (ref) {};\n\n    \\draw[fill=black,opacity=.2, rounded corners] (llr2llrProcBuf.south west) rectangle ($(ref) + (-.5cm,.5cm)$);\n    \\draw[fill=black,opacity=.2, rounded corners] ($(ref) + (.5cm,.5cm)$) rectangle ($(bnProcPc.south east) + (.4cm,0)$);\n\n    \\node[func, above of=cnProc1, node distance=.8cm] (iter1) {\\textbf{First Iteration}};\n    \\node[func, above of=cnProc , node distance=.8cm] (iterX) {\\textbf{Subsequent Iterations}};\n\n  \\end{tikzpicture}\n\n  \\caption{LDPC Decoder processing flow.}\n\\end{figure}\n\nThe functions involved are described in more detail in Table \\ref{tab:sum_func}.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{ll}\n    \\toprule\n    \\textbf{Function} & \\textbf{Description} \\\\\n    \\midrule\n    \\texttt{llr2llrProcBuf} & Copies input LLRs to LLR processing buffer \\\\\n    \\texttt{llr2CnProcBuf}  & Copies input LLRs to CN  processing buffer \\\\\n    \\texttt{cnProc}         & Performs CN signal processing \\\\\n    \\texttt{cnProcPc}       & Performs parity check \\\\\n    \\texttt{cn2bnProcBuf}   & Copies the CN results to the BN processing buffer \\\\\n    \\texttt{bnProcPc}       & Performs BN processing for parity check and/or hard-decision \\\\\n    \\texttt{bnProc}         & Utilizes the results of \\texttt{bnProcPc} to compute LLRs for CN processing \\\\\n    \\texttt{bn2cnProcBuf}   & Copies the BN results to the CN processing buffer \\\\\n    \\texttt{llrRes2llrOut}  & Copies the results of \\texttt{bnProcPc} to output LLRs \\\\\n    \\texttt{llr2bit}        & Performs hard-decision on the output LLRs \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Summary of the LDPC decoder functions.}\n  \\label{tab:sum_func}\n\\end{table}\n\nThe input LLRs are assumed to be 8-bit and aligned on 32 bytes. CN processing is carried out in 8-bit whereas BN processing is done in 16 bit. Subsequently, the processing tasks at the CNs and BNs are explained in more detail.\n\n\\newpage\n\\subsection{Check Node Processing}\n\\label{sec:check-node-proc}\n\nDenote $q_{ij}$ the value from BN $j$ to CN $i$ and let $\\Bcal_i$ be the set of connected BNs to the $i$th CN. Then, using the min-sum approximation, CN $i$ has to carry out the following operation for each connected BN.\n\\begin{equation}\n  \\label{eq:40}\n  r_{ji} = \\prod_{j'\\in\\Bcal_i\\setminus j}\\sgn q_{ij'}\\min_{j'\\in\\Bcal_i\\setminus j} |q_{ij'}|\n\\end{equation}\nwhere $r_{ji}$ is the value returned to BN $j$ from CN $i$. There are $\\Mb = \\{46,42\\}$ CNs in BG 1 and BG 2, respectively. Each of these CNs is connected to only a small number of BNs. The number of connected BNs to CN $i$ is $|\\Bcal_i|$. In BG1 and BG2, $|\\Bcal_i|=\\{3,4,5,6,7,8,9,10,19\\}$ and $|\\Bcal_i|=\\{3,4,5,6,8,10\\}$, respectively. The following tables show the number of CNs $M_{|\\Bcal_i|}$ that are connected to the same number of BNs.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{llllllllll}\n    \\toprule\n    $|\\Bcal_i|$   & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 19 \\\\\n    \\midrule\n    $M_{|\\Bcal_i|}^\\mathrm{BG1}$ & 1 & 5  &18 & 8 & 5 & 2 & 2 & 1 & 4 \\\\\n    $M_{|\\Bcal_i|}^\\mathrm{BG2}$ & 6 & 20 & 9 & 3 & 0 & 2 & 0 & 2 & 0 \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Ceck node groups for BG1 and BG2.}\n  \\label{tab:checkNodeGroups}\n\\end{table}\n\nIt can be observed that each CN is at least connected to 3 BNs and there are 9 groups and 5 groups in BG1 and BG2, respectively. Denote the set of CN groups as $\\Gcal$ and $M_k$ the number of CNs in group $k\\in\\Gcal$, e.g. for BG2 $M_4=20\\Zc$. Each CN group will be processed separately. The CN processing buffer $p_C^k$ of group $k$ is defined as\n\\begin{equation}\n  \\label{eq:44}\n  p_C^k = \\{\\underbrace{q_{11}q_{21}\\dots q_{M_k 1}}_{\\text 1. BN},\\underbrace{q_{12}q_{22}\\dots q_{M_k 2}}_{\\text 2. BN},\\dots,\\underbrace{q_{12}q_{22}\\dots q_{M_k k}}_{\\text last BN}\\}\n\\end{equation}\nHence, $|p_C^k| = kM_k$, e.g, $\\Zc=128$, $|p_C^4| = 4\\cdot 20\\cdot 128 = 10240$.\n\n\\begin{lstlisting}[frame=single,caption={Example of CN processing for group 3 from \\texttt{cnProc}.},label=code_cnproc]  % Start your code-block\n\n  const uint8_t lut_idxCnProcG3[3][2] = {{72,144}, {0,144}, {0,72}};\n\n  // =====================================================================\n  // Process group with 3 BNs\n\n  // Number of groups of 32 CNs for parallel processing\n  M = (lut_numCnInCnGroups[0]*Z)>>5;\n  // Set the offset to each bit within a group in terms of 32 Byte\n  bitOffsetInGroup = (lut_numCnInCnGroups_BG2_R15[0]*NR_LDPC_ZMAX)>>5;\n\n  // Set pointers to start of group 3\n  p_cnProcBuf    = (__m256i*) &cnProcBuf   [lut_startAddrCnGroups[0]];\n  p_cnProcBufRes = (__m256i*) &cnProcBufRes[lut_startAddrCnGroups[0]];\n\n  // Loop over every BN\n  for (j=0; j<3; j++)\n  {\n    // Set of results pointer to correct BN address\n    p_cnProcBufResBit = p_cnProcBufRes + (j*bitOffsetInGroup);\n\n    // Loop over CNs\n    for (i=0; i<M; i++)\n    {\n      // Abs and sign of 32 CNs (first BN)\n      ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][0] + i];\n      sgn  = _mm256_sign_epi8(*p_ones, ymm0);\n      min  = _mm256_abs_epi8(ymm0);\n\n      // 32 CNs of second BN\n      ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][1] + i];\n      min  = _mm256_min_epu8(min, _mm256_abs_epi8(ymm0));\n      sgn  = _mm256_sign_epi8(sgn, ymm0);\n\n      // Store result\n      min = _mm256_min_epu8(min, *p_maxLLR); // 128 in epi8 is -127\n      *p_cnProcBufResBit = _mm256_sign_epi8(min, sgn);\n      p_cnProcBufResBit++;\n    }\n  }\n\n}\n\\end{lstlisting}\n\nOnce all results of the check node processing $r_{ji}$ have been calculated, they are copied to the bit node processing buffer.\n\n\\subsection{Bit Node Processing}\n\\label{sec:bit-node-processing}\n\nDenote $r_{ji}$ the value from CN $i$ to BN $j$ and let $\\Ccal_j$ be the set of connected CNs to the $j$th BN. Each BN $j$ has to carry out the following operation for every connected CN $i\\in\\Ccal_j$.\n\\begin{equation}\n  \\label{eq:46}\n  q_{ij} = \\Lambda_j + \\sum_{i'\\in\\Ccal_j\\setminus i}r_{ji'}\n\\end{equation}\n\nThere are $\\Nb = \\{68,52\\}$ BNs in BG 1 and BG 2, respectively. Each of these BNs is connected to only a small number of CNs. The number of connected CNs to BN $j$ is $|\\Ccal_j|$. In BG1 and BG2, $|\\Ccal_j|=\\{1,4,7,8,9,10,11,12,28,30\\}$ and $|\\Ccal_j|=\\{1,5,6,7,8,9,10,12,13,14,16,22,23\\}$, respectively. The following tables show the number of BNs $K_{|\\Ccal_j|}$ that are connected to the same number of CNs.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lllllllllllllllllll}\n    \\toprule\n    $|\\Ccal_j|$ & 1&4&5&6&7&8&9&10&11&12&13 & 14 & 15 & 16 & 22 & 23 &28&30 \\\\\n    \\midrule\n    $K_{|\\Ccal_j|}^\\mathrm{BG1}$ & 42 & 1 & 1 & 2 & 4 & 3 & 1 & 4 & 3 & 4 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\\\\n    $K_{|\\Ccal_j|}^\\mathrm{BG2}$ & 38 & 0 & 2 & 1 & 1 & 1 & 2 & 1 & 0 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0\\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Bit node groups for BG1 and BG2 for base rates 1/3 and 1/5, respectively.}\n  \\label{tab:bitNodeGroups}\n\\end{table}\n\nThe BNs that are connected to a single CN do not need to be considered in the BN processing since \\eqref{eq:46} yields $q_{ij} = \\Lambda_j$. It can be observed that the grouping is less compact, i.e. there are many groups with only a small number of elements.\n\nDenote the set of BN groups as $\\Bcal$ and $K_k$ the number of BNs in group $k\\in\\Bcal$, e.g. for BG2 $K_5=2\\Zc$. Each BN group will be processed separately. The BN processing buffer $p_B^k$ of group $k$ is defined as\n\\begin{equation}\n  \\label{eq:47}\n  p_B^k = \\{\\underbrace{r_{11}r_{21}\\dots r_{K_k 1}}_{\\text 1. CN},\\underbrace{r_{12}r_{22}\\dots r_{K_k 2}}_{\\text 2. CN},\\dots,\\underbrace{r_{12}r_{22}\\dots r_{K_k k}}_{\\text last CN}\\}\n\\end{equation}\nHence, $|p_B^k| = kK_k$, e.g, $\\Zc=128$, $|p_B^5| = 5\\cdot 2\\cdot 128 = 1024$.\n\nDepending on the code rate, some parity bits are not being transmitted. For instance, for BG2 with code rate $R = 1/3$ the last $20\\Zc$ bits are discarded. Therefore, the last 20 columns or the last $20\\Zc$ parity check equation are not required for decoding. This means that the BN groups shown in table \\ref{tab:bitNodeGroups} are depending on the rate.\n\n\\begin{lstlisting}[frame=single,caption={Example of BN processing for group 3 from \\texttt{bnProcPc}.},label=code_bnproc]  % Start your code-block\n\n  // If elements in group move to next address\n  idxBnGroup++;\n\n  // Number of groups of 32 BNs for parallel processing\n  M = (lut_numBnInBnGroups[2]*Z)>>5;\n\n  // Set the offset to each CN within a group in terms of 16 Byte\n  cnOffsetInGroup = (lut_numBnInBnGroups[2]*NR_LDPC_ZMAX)>>4;\n\n  // Set pointers to start of group 3\n  p_bnProcBuf  = (__m128i*) &bnProcBuf  [lut_startAddrBnGroups   [idxBnGroup]];\n  p_llrProcBuf = (__m128i*) &llrProcBuf [lut_startAddrBnGroupsLlr[idxBnGroup]];\n  p_llrRes     = (__m256i*) &llrRes     [lut_startAddrBnGroupsLlr[idxBnGroup]];\n\n  // Loop over BNs\n  for (i=0,j=0; i<M; i++,j+=2)\n  {\n    // First 16 LLRs of first CN\n    ymmRes0 = _mm256_cvtepi8_epi16(p_bnProcBuf[j]);\n    ymmRes1 = _mm256_cvtepi8_epi16(p_bnProcBuf[j+1]);\n\n    // Loop over CNs\n    for (k=1; k<3; k++)\n    {\n      ymm0 = _mm256_cvtepi8_epi16(p_bnProcBuf[k*cnOffsetInGroup + j]);\n      ymmRes0 = _mm256_adds_epi16(ymmRes0, ymm0);\n\n      ymm1 = _mm256_cvtepi8_epi16(p_bnProcBuf[k*cnOffsetInGroup + j+1]);\n      ymmRes1 = _mm256_adds_epi16(ymmRes1, ymm1);\n    }\n\n    // Add LLR from receiver input\n    ymm0    = _mm256_cvtepi8_epi16(p_llrProcBuf[j]);\n    ymmRes0 = _mm256_adds_epi16(ymmRes0, ymm0);\n\n    ymm1    = _mm256_cvtepi8_epi16(p_llrProcBuf[j+1]);\n    ymmRes1 = _mm256_adds_epi16(ymmRes1, ymm1);\n\n    // Pack results back to epi8\n    ymm0 = _mm256_packs_epi16(ymmRes0, ymmRes1);\n    // ymm0     = [ymmRes1[255:128] ymmRes0[255:128] ymmRes1[127:0] ymmRes0[127:0]]\n    // p_llrRes = [ymmRes1[255:128] ymmRes1[127:0] ymmRes0[255:128] ymmRes0[127:0]]\n    *p_llrRes = _mm256_permute4x64_epi64(ymm0, 0xD8);\n\n    // Next result\n    p_llrRes++;\n  }\n}\n\n\\end{lstlisting}\n\nThe sum of the LLRs is carried out in 16 bit for accuracy and is then saturated to 8 bit for CN processing. Saturation after each addition results in significant loss of sensitivity for low code rates.\n\n\\subsection{Mapping to the Processing Buffers}\n\\label{sec:mapp-cn-proc}\n\nFor efficient processing with the AVX instructions, the data is required to be aligned in a certain manner. That is the reason why processing buffers have been introduced. The drawback is that the results of the processing need to copied every time to the processing buffer of the next task. However, the speed up in computation with AVX more than makes up for the time wasted in copying data. The copying is implemented as a circular memcpy because every edge in the BG is a circular shift of a $Z\\times Z$ identity matrix. Hence, a circular mempcy consists of two regular memcpys each copying a part of the $Z$ values depending on the circular shift in the BG definition. The circular shifts are stored in \\texttt{nrLDPC\\_lut.h} in arrays \\texttt{circShift\\_BGX\\_ZX\\_CNGX}. In the specification there are only 8 sets of cirular shifts defined. However, the applied circular shift depends on $Z$, i.e. modulo $Z$. To avoid inefficient modulo operations in loops, we store the the circular shift values for every $Z$. Moreover, for convinience the arrays are already arranged depending on the CN group (CNG).\n\n\\newpage\n\\section{Performance Results}\n\\label{sec:performance-results}\n\nIn this section, the performance in terms of BLER and decoding latency of the current LDPC decoder implementation is verified.\n\n\\subsection{BLER Performance}\n\\label{sec:bler-performance}\n\nIn all simulations, we assume AWGN, QPSK modulation and 8-bit input LLRs, i.e. $-127$ until $+127$. The DLSCH coding procedure in 38.212 is used to encode/decode the TB and an error is declared if the TB CRC check failed. Results are averaged over at least $10\\,000$ channel realizations. \n\nThe first set of simulations in Figure \\ref{fig:bler-bg2-15} compares the current LDPC decoder implementation to the reference implementation developed by Kien. This reference implementation is called \\textit{LDPC Ref} and uses the min-sum algorithm with 2 layers and 16 bit for processing. Our current optimized decoder implementation is referred to as \\textit{LDPC OAI}. Moreover, reference results provided by Huawei are also shown.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=-4, xmax=2, xtick={-4,-3.5,...,2}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % HUAWEI merged BG2 2017-06-15\n      \\addplot[black, solid] plot coordinates { (-3.91839,0.01) (-3.5567,0.0001) };\n\n      % 5 iterations\n      % LDPC Ref\n      \\addplot[red, solid, mark=o] plot coordinates {(-1.250000,0.781300) (-1.000000,0.421000) (-0.750000,0.140400) (-0.500000,0.028900) (-0.250000,0.003300) (0.000000,0.000300) (0.250000,0.000000) (0.500000,0.000000)};\n      % LDPC OAI\n      \\addplot[blue, solid, mark=square] plot coordinates {(-1.000000,0.693730) (-0.750000,0.370190) (-0.500000,0.137260) (-0.250000,0.038850) (0.000000,0.009740) (0.250000,0.002510) (0.500000,0.000730) (0.750000,0.000180) };\n      % Matlab layered min-sum with scaling factor 1\n      \\addplot[green, solid, mark=triangle] plot coordinates {(-1.750000,0.709000) (-1.500000,0.360600) (-1.250000,0.105500) (-1.000000,0.015700) (-0.750000,0.001300) (-0.500000,0.000100) (-0.250000,0.000000) (0.000000,0.000000) };\n      % Matlab layered min-sum with scaling factor 0.8\n      %\\addplot[green, solid, mark=triangle] plot coordinates {(-2.750000,0.982300) (-2.500000,0.882200) (-2.250000,0.573100) (-2.000000,0.214100) (-1.750000,0.041300) (-1.500000,0.003800) (-1.250000,0.000000) (-1.000000,0.000000) };\n\n      % 10 iterations\n      % Kien's 2-layer 16bit code\n      \\addplot[red, solid, mark=o] plot coordinates { (-2.750000,0.915500) (-2.500000,0.576000) (-2.250000,0.165000) (-2.000000,0.017100) (-1.750000,0.000600) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n      % LDPC OAI\n      \\addplot[blue, solid, mark=square] plot coordinates { (-2.750000,0.997200) (-2.500000,0.955000) (-2.250000,0.710900) (-2.000000,0.270400) (-1.750000,0.042400) (-1.500000,0.002200) (-1.250000,0.000000) (-1.000000,0.000000)};\n      % Matlab layered min-sum with scaling factor 1\n      \\addplot[green, solid, mark=triangle] plot coordinates {(-2.750000,0.942900) (-2.500000,0.723200) (-2.250000,0.362300) (-2.000000,0.098400) (-1.750000,0.014500) (-1.500000,0.001100) (-1.250000,0.000000) (-1.000000,0.000000) };\n      % Matlab layered min-sum with scaling factor 0.8\n      %\\addplot[green, solid, mark=triangle] plot coordinates {(-3.750000,0.994300) (-3.500000,0.927200) (-3.250000,0.651100) (-3.000000,0.252000) (-2.750000,0.042500) (-2.500000,0.002700) (-2.250000,0.000000) (-2.000000,0.000000) (-1.750000,0.000000) (-1.500000,0.000000) };\n\n\n      % 20 iterations\n      % Kien's 2-layer 16bit code\n      \\addplot[red, solid, mark=o] plot coordinates { (-2.750000,0.330300) (-2.500000,0.067800) (-2.250000,0.006000) (-2.000000,0.000100) (-1.750000,0.000000) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n      % LDPC OAI\n      \\addplot[blue, solid, mark=square] plot coordinates  {(-2.750000,0.337900) (-2.500000,0.058300) (-2.250000,0.004000) (-2.000000,0.000200) (-1.750000,0.000000) (-1.500000,0.000000) };\n      % Matlab layered min-sum with scaling factor 1\n      %\\addplot[green, solid, mark=triangle] plot coordinates {(-2.750000,0.843200) (-2.500000,0.524600) (-2.250000,0.198100) (-2.000000,0.037300) (-1.750000,0.003200) (-1.500000,0.000000) };\n      % Matlab layered min-sum with scaling factor 0.8\n      %\\addplot[green, solid, mark=triangle] plot coordinates {(-3.750000,0.872300) (-3.500000,0.544600) (-3.250000,0.186400) (-3.000000,0.027500) (-2.750000,0.001900) (-2.500000,0.000000) };\n\n\n      \n      % Parity check 50 iterations\n      %\\addplot[blue, solid, mark=square] plot coordinates {(-2.750000,0.214600) (-2.500000,0.029200) (-2.250000,0.001500) (-2.000000,0.000100) (-1.750000,0.000000) (-1.500000,0.000000) };\n\n\n      \\draw (axis cs:-3.3,0.1)  node[fill=white,draw=black] (pint0) {20 iter};\n      \\draw (axis cs:-2.3,0.01) node[draw,black,thick,ellipse,minimum height=0.3cm] (ell0) {}; \\draw[black,thick] (pint0) -- (ell0);\n      \n      \\draw (axis cs:-1.2,0.0001)   node[fill=white,draw=black] (pint1) {10 iter};\n      \\draw (axis cs:-1.6,0.002) node[draw,black,thick,ellipse,minimum width=0.8cm] (ell1) {}; \\draw[black,thick] (pint1) -- (ell1);\n      \n      \\draw (axis cs:1.3,0.2)  node[fill=white,draw=black] (pint2) {5 iter};\n      \\draw (axis cs:-0.4,0.01) node[draw,black,thick,ellipse,minimum width=2cm] (ell2) {}; \\draw[black,thick] (pint2) -- (ell2);\n      \n\n      \\legend{ {Huawei 2017-06-15}\\\\\n               {LDPC Ref}\\\\\n               {LDPC OAI}\\\\\n               {MATLAB NMS SF=1}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG2, Rate=1/5, \\{5,10,20\\} Iterations, B=1280.}\n  \\label{fig:bler-bg2-15}\n\\end{figure}\n\nFrom Figure \\ref{fig:bler-bg2-15} it can be observed that the reference decoder outperforms the current implementation significantly for low to medium number of iterations. The reason is the implementation of 2 layers in the reference decoder, which results in faster convergence for punctured codes and hence requires less iterations to achieve a given BLER target. Note that there is a large performance loss of about 4 dB at BLER $10^{-2}$ between the Huawei reference and the current optimized decoder implementation with 5 iterations.\n\nMoreover, there is a gap of about 1.5 dB between the results provided by Huawei and the current decoder with 20 iterations. The reason is the min-sum approximation algorithm used in both the reference decoder and the current implementation. The gap can be closed by using a tighter approximation like the min-sum with normalization or the lambda-min approach. Moreover, the gap closes for higher code rates which can be observed from Figure \\ref{fig:bler-bg2-r23}. The gap is only about 0.6 dB for 50 iterations.\n\nThe Matlab results denoted \\texttt{MATLAB NMS} are obtained with the function \\texttt{nrLDPCDecode} provided by the MATLAB 5G Toolbox R2019b. The following options are provided to the function: \\texttt{'Termination','max','Algorithm','Normalized min-sum','ScalingFactor',1}. Furthermore, the 8-bit input LLRs are adapted to fit the dynamic range of \\texttt{nrLDPCDecode} which is shown in Listing \\ref{ldpc_matlab}. \n\n\\begin{lstlisting}[frame=single,caption={Input adaptation for MATLAB LDPC Decoder},label=ldpc_matlab]\nmaxLLR = max(abs(softbits));\nrxLLRs = round((softbits/maxLLR)*127);\n// adjust range to fit tanh use in decoder code \nsoftbits = rxLLRs/3.4;\n\\end{lstlisting}\n\nA scaling factor (SF) of 1 has been chosen to compare the results more easily with the \\textit{LDPC OAI} since the resulting check node processing is the same. However, the Matlab normelized min-sum algorithm uses layered processing and floating point operations. Thus, for the same number of iterations, the performance is significantly better than \\textit{LDPC OAI}, especially for small a number of iterations.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=3, xmax=6.5, xtick={3,3.5,...,6.5}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % Kien's 2-layer 16bit code\n      %\\addplot[red, solid] plot coordinates { (-2.750000,0.915500) (-2.500000,0.576000) (-2.250000,0.165000) (-2.000000,0.017100) (-1.750000,0.000600) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n\n      % Huawei\n      \\addplot[black, solid] plot coordinates { (3.28392,0.01) (3.73319,0.0001) };\n\n      % LDPC opt with 16bit BN processing\n      %\\addplot[blue, solid, mark=square] plot coordinates {(4.000000,0.487500) (4.250000,0.163400) (4.500000,0.029800) (4.750000,0.002700) (5.000000,0.000100)};\n      \\addplot[blue, solid, mark=square] plot coordinates {(5.000000,0.439600) (5.250000,0.185800) (5.500000,0.062100) (5.750000,0.015000) (6.000000,0.003900)};\n\n\n      %\\addplot[blue, dashed, mark=triangle] plot coordinates {(4.000000,0.487500) (4.250000,0.163700) (4.500000,0.030000) (4.750000,0.002900) (5.000000,0.000100)};\n\n      %\\addplot[blue, dashed, mark=square] plot coordinates {(3.000000,0.911600) (3.250000,0.614100) (3.500000,0.230100) (3.750000,0.036900) (4.000000,0.001100) (4.250000,0.000000) (4.500000,0.000000)};\n      \\addplot[blue, dashed, mark=square] plot coordinates {(3.000000,0.900400) (3.250000,0.600000) (3.500000,0.216400) (3.750000,0.036000) (4.000000,0.002600) (4.250000,0.000000) };      \n\n\n      \\legend{ {Huawei 2017-06-15}\\\\\n               {LDPC OAI 5 iter}\\\\\n               {LDPC OAI 50 iter}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG2, Rate=2/3, \\{5,50\\} Iterations, B=1280.}\n  \\label{fig:bler-bg2-r23}\n\\end{figure}\n\nIn Figure \\ref{fig:bler-bg2-15-2} we compare the performance of different algorithms using at most 50 iterations with early stopping if the parity check passes. The Matlab layered believe propagation (LBP) is used with unquantized input LLRs and performs the best since no approximation is done in the processing. Both NMS and offset min-sum (OMS) use a scaling factor and offset, respectively, that has been empirically found to perform best in this simulation setting. Theirs performance is very close to the BLP and OMS is slightly better than NMS. The performance of \\textit{LDPC OAI} is more than 1 dB worse mainly because of the looser approximation. Moreover, the NMS algorithm with SF=1 performs worst probably because the SF is not optimized for the input LLRs. From the results in Figure \\ref{fig:bler-bg2-15-2} we can conclude that the performance of the \\textit{LDPC OAI} can be significantly improved by adopting an offset min-sum approximation improving the performance to within 0.3dB of the Huawei reference curve.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=-4, xmax=-1, xtick={-4,-3.5,...,-1}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % HUAWEI merged BG2 2017-06-15\n      \\addplot[black, solid] plot coordinates { (-3.91839,0.01) (-3.5567,0.0001) };\n\n      % Parity check 50 iterations\n      \\addplot[blue, solid, mark=square] plot coordinates {(-2.750000,0.214600) (-2.500000,0.029200) (-2.250000,0.001500) (-2.000000,0.000100) (-1.750000,0.000000) (-1.500000,0.000000) };\n\n      % Matlab layered believe propagation\n      \\addplot[red, solid, mark=diamond] plot coordinates {(-4.500000,0.854200) (-4.250000,0.495800) (-4.000000,0.147700) (-3.750000,0.016100) (-3.500000,0.000800) (-3.250000,0.000200) (-3.000000,0.000000) };\n      \n      % Matlab layered min-sum with scaling factor 1\n      \\addplot[green, dashed, mark=triangle] plot coordinates {(-2.750000,0.830100) (-2.500000,0.497700) (-2.250000,0.165800) (-2.000000,0.024000) (-1.750000,0.001900) (-1.500000,0.000000) };\n      % Matlab layered min-sum with scaling factor 0.8\n      %\\addplot[green, solid, mark=triangle] plot coordinates {(-3.750000,0.734800) (-3.500000,0.353800) (-3.250000,0.084300) (-3.000000,0.008000) (-2.750000,0.000400) };\n      \\addplot[green, solid, mark=triangle] plot coordinates {(-4.500000,0.964400) (-4.250000,0.748200) (-4.000000,0.333600) (-3.750000,0.057700) (-3.500000,0.004400) (-3.250000,0.000400) };\n\n      % Matlab layered offset min-sum with offset 0.025\n      \\addplot[brown, solid, mark=asterisk] plot coordinates {(-4.250000,0.688800) (-4.000000,0.253800) (-3.750000,0.035600) (-3.500000,0.002000) (-3.250000,0.000000) (-3.000000,0.000000) };\n\n      \n\n      \\legend{ {Huawei 2017-06-15}\\\\\n               {LDPC OAI}\\\\\n               {MATLAB LBP}\\\\\n               {MATLAB NMS SF=1}\\\\\n               {MATLAB NMS SF=0.65}\\\\\n               {MATLAB OMS OS=0.025}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG2, Rate=1/5, max iterations = 50, B=1280.}\n  \\label{fig:bler-bg2-15-2}\n\\end{figure}\n\n\nFigure \\ref{fig:bler-bg1-r89} shows the performance of BG1 with largest block size of $B=8448$ and highest code rate $R=8/9$. From Figure \\ref{fig:bler-bg1-r89} it can be observed that the performance gap is only about 0.3 dB if 50 iterations are used. However, for 5 iterations there is still a significant performance loss of about 2.3 dB at BLER $10^{-2}$.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=6, xmax=9, xtick={6,6.5,...,9}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % Huawei\n      \\addplot[black, solid] plot coordinates { (6.118717,0.01) (6.291449,0.0001) };\n\n      % LDPC opt 5 iter\n      %\\addplot[blue, solid, mark=square] plot coordinates {(8.500000,0.350000) (8.750000,0.155100) (9.000000,0.062400) (9.250000,0.023000) (9.500000,0.008700) (9.750000,0.003500) (10.000000,0.000900) (10.250000,0.000300) };\n      \\addplot[blue, solid, mark=square] plot coordinates {(7.500000,0.858900) (7.750000,0.449500) (8.000000,0.129700) (8.250000,0.025500) (8.500000,0.002300) (8.750000,0.000300) (9.000000,0.000000) };\n\n      % LDPC opt 50 iter\n      %\\addplot[blue, dashed, mark=square] plot coordinates {(6.000000,0.705333) (6.100000,0.353367) (6.200000,0.102100) (6.300000,0.015133) (6.400000,0.000967) (6.500000,0.000000)};\n      \\addplot[blue, dashed, mark=square] plot coordinates {(6.000000,0.970000) (6.100000,0.830800) (6.200000,0.527300) (6.300000,0.216900) (6.400000,0.045500) (6.500000,0.005600) (6.600000,0.000300) (6.700000,0.000000) (6.800000,0.000000) };\n\n      \\legend{ {Huawei}\\\\\n               {LDPC OAI 5 iter}\\\\\n               {LDPC OAI 50 iter}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG1, Rate=8/9 \\{5,50\\} Iterations, B=8448.}\n  \\label{fig:bler-bg1-r89}\n\\end{figure}\n\n\\newpage\n\\subsection{Decoding Latency}\n\\label{sec:decoding-time}\n\nThis section provides results in terms of decoding latency. That is, the time it takes the decoder to to finish decoding for a given number of iterations. To measure the run time of the decoder we use the OAI tool \\texttt{time\\_meas.h}. The clock frequency is about 2.9 GHZ, decoder is run on a single core and the results are averaged over $10\\,000$ blocks.\n\nThe results in Table \\ref{tab:lat-bg2-r15} show the impact of the number of iterations on the decoding latency. It can be observed that the latency roughly doubles if the number of iterations are doubled.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} & \\textbf{Time [$\\mu s$] (5 it)} & \\textbf{Time [$\\mu s$] (10 it)} & \\textbf{Time [$\\mu s$] (20 it)}\\\\\n    \\midrule\n    % \\texttt{llr2llrProcBuf} & 1.1   & 1.1   & 1.1   \\\\\n    % \\texttt{llr2CnProcBuf}  & 12.4  & 12.0  & 12.0  \\\\\n    % \\texttt{cnProc}         & 11.7  & 22.1  & 43.5  \\\\\n    % \\texttt{bnProcPc}       & 6.6   & 12.1  & 23.8  \\\\\n    % \\texttt{bnProc}         & 4.2   & 8.1   & 16.2  \\\\\n    % \\texttt{cn2bnProcBuf}   & 61.3  & 118.3 & 234.9 \\\\\n    % \\texttt{bn2cnProcBuf}   & 38.1  & 82.5  & 172.3 \\\\\n    % \\texttt{llrRes2llrOut}  & 3.5   & 3.4   & 3.4   \\\\\n    % \\texttt{llr2bit}        & 0.2   & 0.1   & 0.1   \\\\\n    \\texttt{llr2llrProcBuf} & 0.5  & 0.5  & 0.5  \\\\\n    \\texttt{llr2CnProcBuf}  & 5.0  & 4.8  & 4.9  \\\\\n    \\texttt{cnProc}         & 12.4 & 23.0 & 42.7 \\\\\n    \\texttt{bnProcPc}       & 8.4  & 14.8 & 27.0 \\\\\n    \\texttt{bnProc}         & 5.5  & 10.1 & 19.0 \\\\\n    \\texttt{cn2bnProcBuf}   & 14.9 & 24.4 & 44.0 \\\\\n    \\texttt{bn2cnProcBuf}   & 10.5 & 17.8 & 31.8 \\\\\n    \\texttt{llrRes2llrOut}  & 0.3  & 0.3  & 0.3  \\\\\n    \\texttt{llr2bit}        & 0.2  & 0.2  & 0.2  \\\\\n    \\midrule\n    % \\textbf{Total}          & \\textbf{139.4} & \\textbf{260.3} & \\textbf{508.4} \\\\\n    \\textbf{Total}          & \\textbf{58.5} & \\textbf{97.1} & \\textbf{172.6} \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG2, Z=128, R=1/5, B=1280, LDPC OAI}\n  \\label{tab:lat-bg2-r15}\n\\end{table}\n\nTable \\ref{tab:lat-bg2-i5} shows the impact of the code rate on the latency for a given block size and 5 iterations. It can be observed that the performance gain from code rate 1/3 to 2/3 is about a factor 2.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} & \\textbf{Time [$\\mu s$] (R=1/5)} & \\textbf{Time [$\\mu s$] (R=1/3)} & \\textbf{Time [$\\mu s$] (R=2/3)}\\\\\n    \\midrule\n    % \\texttt{llr2llrProcBuf} & 3.2   & 2.9   & 2.6   \\\\\n    % \\texttt{llr2CnProcBuf}  & 36.5  & 25.4  & 14.8  \\\\\n    % \\texttt{cnProc}         & 33.6  & 25.2  & 13.3  \\\\\n    % \\texttt{bnProcPc}       & 17.6  & 10.2  & 4.5   \\\\\n    % \\texttt{bnProc}         & 8.5   & 5.4   & 2.5   \\\\\n    % \\texttt{cn2bnProcBuf}   & 175.3 & 110.6 & 50.7  \\\\\n    % \\texttt{bn2cnProcBuf}   & 106.6 & 71.2  & 36.1  \\\\\n    % \\texttt{llrRes2llrOut}  & 10.2  & 6.3   & 3.3   \\\\\n    % \\texttt{llr2bit}        & 0.4   & 0.2   & 0.1   \\\\\n    \\texttt{llr2llrProcBuf} & 1.5  & 0.9  & 0.5  \\\\\n    \\texttt{llr2CnProcBuf}  & 6.0  & 4.1  & 2.2  \\\\\n    \\texttt{cnProc}         & 32.2 & 23.7 & 14.4 \\\\\n    \\texttt{bnProcPc}       & 21.2 & 12.1 & 5.5  \\\\\n    \\texttt{bnProc}         & 9.8  & 5.9  & 2.9  \\\\\n    \\texttt{cn2bnProcBuf}   & 23.3 & 13.9 & 6.8  \\\\\n    \\texttt{bn2cnProcBuf}   & 14.8 & 9.7  & 5.0  \\\\\n    \\texttt{llrRes2llrOut}  & 0.6  & 0.4  & 0.3  \\\\\n    \\texttt{llr2bit}        & 0.7  & 0.4  & 0.2  \\\\\n    \\midrule\n    % \\textbf{Total}          & \\textbf{392.4} & \\textbf{258.0} & \\textbf{128.2} \\\\\n    \\textbf{Total}          & \\textbf{111.0} & \\textbf{71.8} & \\textbf{38.5} \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG2, Z=384, B=3840, LDPC OAI, 5 iterations}\n  \\label{tab:lat-bg2-i5}\n\\end{table}\n\nTable \\ref{tab:lat-bg1-i5} shows the results for BG1, larges block size and different code rates. The latency difference betwee code rate 1/3 and code rate 2/3 is less than half because upper left corner of the PCM is more dense than the rest of the PCM.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} &  \\textbf{Time [$\\mu s$] (R=1/3)} & \\textbf{Time [$\\mu s$] (R=2/3)} & \\textbf{Time [$\\mu s$] (R=8/9)}\\\\\n    \\midrule\n    % \\texttt{llr2llrProcBuf}  & 5.5   & 4.9   & 4.6  \\\\\n    % \\texttt{llr2CnProcBuf}   & 60.6  & 34.1  & 24.4 \\\\\n    % \\texttt{cnProc}          & 102.0 & 74.1  & 56.0 \\\\\n    % \\texttt{bnProcPc}        & 26.0  & 11.0  & 6.4  \\\\\n    % \\texttt{bnProc}          & 15.7  & 7.4   & 4.5  \\\\\n    % \\texttt{cn2bnProcBuf}    & 291.0 & 140.8 & 83.1 \\\\\n    % \\texttt{bn2cnProcBuf}    & 193.6 & 100.5 & 63.0 \\\\\n    % \\texttt{llrRes2llrOut}   & 13.3  & 6.9   & 5.2  \\\\\n    % \\texttt{llr2bit}         & 0.4   & 0.2   & 0.2  \\\\\n    \\texttt{llr2llrProcBuf}  & 2.1  & 1.2  & 0.9  \\\\\n    \\texttt{llr2CnProcBuf}   & 10.6 & 5.4  & 2.9  \\\\\n    \\texttt{cnProc}          & 89.8 & 66.3 & 50.0 \\\\\n    \\texttt{bnProcPc}        & 28.1 & 12.4 & 7.1 \\\\\n    \\texttt{bnProc}          & 17.1 & 8.1  & 4.8 \\\\\n    \\texttt{cn2bnProcBuf}    & 38.7 & 17.1 & 9.3 \\\\\n    \\texttt{bn2cnProcBuf}    & 25.6 & 12.7 & 7.2 \\\\\n    \\texttt{llrRes2llrOut}   & 0.8  & 0.4  & 0.3 \\\\\n    \\texttt{llr2bit}         & 0.9  & 0.4  & 0.3 \\\\\n    \\midrule\n    % \\textbf{Total}           & \\textbf{708.9} & \\textbf{380.6} & \\textbf{248.1}\\\\\n    \\textbf{Total}           & \\textbf{214.6} & \\textbf{124.6} & \\textbf{83.6}\\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG1, Z=384, B=8448, LDPC OAI, 5 iterations}\n  \\label{tab:lat-bg1-i5}\n\\end{table}\n\nFrom the above results it can be observed that the data transfer between CNs and BNs takes up a significant amount of the run time. However, the performance gain due to AVX instructions in both CN and BN processing is significantly larger than the penalty incurred by the data transfers.\n\n\\section{Parity Check and Early Stopping Criteria}\nIt is often unnecessary to carry out the maximum number of iterations. After each iteration a parity check (PC) \\eqref{eq:29} can be computed and if a valid code word is found the decoder can stop. This functionality has been implemented and the additional overhead is reasonable. The PC is carried out in the CN processing buffer and the calculation complexity itself is negligible. However, for the processing it is necessary to move the BN results to the CN buffer which takes time, the overall overhead is at most $10\\%$ compared to an algorithm without early stopping criteria with the same number of iterations. The PC has to be activated via the define \\texttt{NR\\_LDPC\\_ENABLE\\_PARITY\\_CHECK}.\n\n\n\\section{Conclusion}\n\\label{sec:conclusion}\n\nThe results in the previous sections show that the current optimized LDPC implementation full-fills the requirements in terms of decoding latency for low to medium number of iterations at the expense of a loss in BLER performance. To improve BLER performance, it is recommended to implement a layered algorithm and a min-sum algorithm with normalization. Further improvements upon the current implementation are detailed in the next section.\n\n\\newpage\n\\section{Future Work}\n\\label{sec:future-work}\n\nThe improvements upon the current LDPC decoder implementation can be divided into two categories:\n\\begin{enumerate}\n\\item Improved BLER performance\n\\item Reduced decoding latency\n\\end{enumerate}\n\n\\subsection{Improved BLER Performance}\n\\label{sec:impr-bler-perf}\n\nThe BLER performance can be improved by using a tighter approximation than the min-sum approximation. For instance, the min-sum algorithm can be improved by adding a correction factor in the CN processing . The min-sum approximation in \\eqref{eq:40} is modified as\n\\begin{equation}\n  \\label{eq:50}\n  r_{ji} = \\prod_{j'\\in\\Bcal_i\\setminus j}\\sgn q_{ij'}\\min_{j'\\in\\Bcal_i\\setminus j} |q_{ij'}| + w(q_{ij'})\n\\end{equation}\nThe correction term $w(q_{ij'})$ is defined as\n\\begin{equation}\n  \\label{eq:51}\n  w(q_{ij'}) =\n  \\begin{cases}\n     c & \\textrm{if}~  \\\\\n    -c & \\textrm{if}~ \\\\\n     0 & \\textrm{otherwise}\n  \\end{cases}\n\\end{equation}\nwhere the constant $c$ is of order $0.5$ typically.\n\n\\subsection{Reduced Decoding Latency}\n\\label{sec:reduc-decod-latency}\n\nThe following improvements will reduce the decoding latency:\n\n\\begin{itemize}\n\\item Adapt to AVX512\n\\item Optimization of CN processing\n\\item Implement 2/3-layers for faster convergence\n\\end{itemize}\n\n\\paragraph{AVX512:}\nThe computations in the CN and BN processing can be further accelerated by using AVX512 instructions. This improvement will speed-up the CN and BN processing by a approximately a factor of 2.\n\n\\paragraph{Optimization of CN Processing:}\nIt can be investigated if CN processing can be improved by computing two minima regardless of the number of BNs. Susequently, the (absolute) value fed back to the BN is one of those minima.\n\n\\paragraph{Layered processing:}\nThe LDPC code in NR always punctures the first 2 columns of the base graph. Hence, the decoder inserts LLRs with value 0 at their place and needs to retrieve those bits during the decoding process. Instead of computing all the parity equations and then passing the results to the BN processing, it is beneficial to first compute parity equations where at most one punctured BN is connected to that CN. If two punctured BNs are connected than according to \\eqref{eq:40}, the result will be again 0. Thus in a first sub-iteration those parity equation are computed and the results are send to BN processing which calculates the results using only those rows in the PCM. In the second sub-iteration the remaining check equation are used.\nThe convergence of this layered approach is much fast since the bit can be retrieved more quickly while the decoding complexity remains the same. Therefore, for a fixed number of iterations the layered algorithm will have a significantly better performance.\n\n\\newpage\n\\bibliographystyle{IEEEtran}\n\\bibliography{./references}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "019b51aa96feae79983d471b3f6c2e3f84ff9f40", "size": 52173, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_stars_repo_name": "shadansari/onos-cu-cp", "max_stars_repo_head_hexsha": "16cbf4828bd11e4c7319e7a009a26b6f39fde628", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-27T00:55:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T11:36:20.000Z", "max_issues_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_issues_repo_name": "shadansari/onos-cu-cp", "max_issues_repo_head_hexsha": "16cbf4828bd11e4c7319e7a009a26b6f39fde628", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-06-17T05:01:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T14:23:54.000Z", "max_forks_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_forks_repo_name": "shadansari/onos-cu-cp", "max_forks_repo_head_hexsha": "16cbf4828bd11e4c7319e7a009a26b6f39fde628", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2019-12-27T00:55:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T02:13:45.000Z", "avg_line_length": 54.2903225806, "max_line_length": 1108, "alphanum_fraction": 0.6673566787, "num_tokens": 18583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.44037269610989854}}
{"text": "\\documentclass{beamer}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{bm}\n\n\\usepackage{tabularx}\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\usepackage{multirow}\n\n\\graphicspath{{../../images/}}\n\n\\usetheme{Madrid}\n\\usebeamercolor{sidebartab}\n\\usefonttheme{professionalfonts}\n\n\n\\title[M.Sc. Thesis 2015]{Spatial Summarization of Image Collections}\n\\author{Diego A. Ballesteros Villamizar}\n\\institute[ETHZ]{ETH Zürich}\n\\date{February 8th, 2016}\n\n\\DeclareMathOperator*{\\argmin}{argmin}\n\\DeclareMathOperator*{\\argmax}{argmax}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>\n    \\frametitle{Outline}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\section{Augmented features}\n\n\\begin{frame}{Leftover question}\n  \\begin{itemize}\n    \\item Does using a feature matrix $\\mathbf{X}' = \\mathbf{X} \\mid \\mathbb{I}$ improve the results?\n    \\begin{table}\n      \\begin{tabular}{l|lllll}\n        \\hline\n        & \\multicolumn{5}{c}{K} \\\\\n        \\hline\n        \\multirow{5}{*}{L} & & 0 & 2 & 5 & 10 \\\\\n        & 0 & $17.38 \\pm 1.81$ & $18.75 \\pm 2.95$ & $18.82 \\pm 2.58$ & $18.91 \\pm 2.40$ \\\\\n        & 2 & $22.66 \\pm 4.58$ & $28.53 \\pm 4.36$ &&\\\\\n        & 5 & $25.40 \\pm 4.77$ && $31.59 \\pm 2.38$ &\\\\\n        & 10 & $31.13 \\pm 2.92$ &&& $30.49 \\pm 3.51$ \\\\\n      \\end{tabular}\n    \\end{table}\n    \\item Not really, the best score so far is $34.35 \\pm 2.15$ with $\\mathbf{X} = \\mathbb{I}$.\n    \\item Running time is significantly slower, because of the increased number of features $M = N + 4$.\n  \\end{itemize}\n\\end{frame}\n\n\\section{Sampling the distribution}\n\n\\begin{frame}{Sampling from the model}\n  \\begin{itemize}\n    \\item Using the best model, i.e. without features and with $L = 5, K=5$.\n    \\item How does the resulting distribution look?\n    \\item How to use the distribution to recommend sets?\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Exact sampling}\n  \\begin{itemize}\n    \\item With $N = 10$, it is possible to calculate the probabilities from the model for all $2^{10} = 1024$ possible sets.\n    \\item Evaluating the model on all sets $S \\subseteq V$and then normalizing the probability distribution.\n    \\item Takes only seconds to evaluate.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Distribution of set size ($100k$ samples)}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{length_histogram_exact}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Distribution of sets with $|S| = 2$ ($100k$ samples)}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{pairs_histogram_exact}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Gibbs sampling}\n  \\begin{itemize}\n    \\item What about a method that scales? For example if $N = 30$, then there are $2^{30} = 1073741824$ sets.\n    \\item Gibbs sampling as presented in \\cite{gotovos15sampling}.\n    \\item Run for $1M$ iterations, remove the first half of iterations are burn-in.\n    \\item Running time is a couple of minutes.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Distribution of set size ($100k$ samples)}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{length_histogram_gibbs}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Distribution of sets with $|S| = 2$ ($100k$ samples)}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{pairs_histogram_gibbs}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Gibbs Sampling Performance}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{gibbs_performance}\n  \\end{figure}\n\\end{frame}\n\n\\section{Extending the location set}\n\n\\begin{frame}{More mean-shift clusters}\n  \\begin{itemize}\n    \\item Original dataset has over 160k photos.\n    \\item When clustered using mean-shift with a bandwidth of approximately 100m, there are over 2k clusters.\n    \\item Previous tests were done using the 10 top clusters according number of photos per cluster. This covered only over 30k photos.\n    \\item Does the approach scale if the number of clusters is increased?\n    \\item 50 clusters cover over 100k photos.\n    \\item 12k paths are present, in comparison there were 8k paths with 10 clusters.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Baselines}\n  \\begin{table}\n    \\centering\n    \\begin{tabular}{@{}lll@{}}\n      \\hline\n      \\textbf{Model} & \\textbf{Accuracy} & \\textbf{MRR} \\\\\n      \\hline\n      Modular & $9.21 \\pm 1.02$ & $27.00 \\pm 1.01$ \\\\\n      Markov & $19.72 \\pm 1.23$ & $34.50 \\pm 1.00$ \\\\\n      \\textbf{Markov with rejection} & $\\mathbf{22.36 \\pm 1.41}$ & $\\mathbf{38.65 \\pm 1.09}$ \\\\\n      Proximity & $12.76 \\pm 0.70$ & $27.71 \\pm 0.88$ \\\\\n      Proximity with rejection & $14.74 \\pm 0.64$ & $31.34 \\pm 1.14$ \\\\\n      \\hline\n    \\end{tabular}\n  \\end{table}\n  \\begin{itemize}\n    \\item Similar trend as with $N = 10$, Markov with rejection is the best model and it's significantly better than the modular model.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{FLDC - Facility Location Diversity and Coherence}\n  \\begin{itemize}\n    \\item Use the best model from the case for $N = 10$.\n    \\item The model with a diversity term, i.e. submodular, and a coherence term, i.e. supermodular. Without features, i.e. $\\mathbf{X} = \\mathbb{I}$.\n    \\item Running on $k = 10$ folds, with a noise factor of 50.\n    \\item Latent dimensions are: $0 \\leq L \\leq 20, 0 \\leq M \\leq 20$.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Evaluation}\n  \\begin{table}\n    \\begin{tabular}{l|lllll}\n      \\hline\n      & \\multicolumn{5}{c}{K} \\\\\n      \\hline\n      \\multirow{5}{*}{L} & & 0 & 2 & 10 & 20 \\\\\n      & 0 & $9.21 \\pm 1.02$ & $16.24 \\pm 1.43$ & $16.12 \\pm 1.29$ & $16.44 \\pm 1.77$\\\\\n      & 2 & $12.09 \\pm 1.36$ & $17.05 \\pm 0.91$ &&\\\\\n      & 10 & $12.94 \\pm 1.39$ && $19.28 \\pm 0.73$ &\\\\\n      & 20 & $9.17 \\pm 2.27$ &&& $\\mathbf{21.53 \\pm 1.24}$\\\\\n    \\end{tabular}\n  \\end{table}\n  \\begin{itemize}\n    \\item Model with diversity and coherence term has performance close to the markov model with rejection.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Distribution of set size ($100k$ samples)}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[height=0.8\\textheight]{length_histogram_gibbs_50}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Frequency of data}\n  \\begin{columns}\n    \\begin{column}{0.5\\columnwidth}\n      \\begin{table}\n        \\centering\n        \\caption{Frequency of Item Sets}\n        \\begin{tabular}{ll}\n          \\hline\n          Set & Frequency \\\\\n          \\hline\n          $[0, 7]$ & 61\\\\\n          $[27, 28]$ & 39\\\\\n          $[13, 7]$ & 36\\\\\n          $[11, 14]$ & 27\\\\\n          $[0, 13]$ & 25\\\\\n          $[2, 7]$ & 23\\\\\n          $[10, 2]$ & 22\\\\\n          $[25, 34]$ & 22\\\\\n          $[2, 15]$ & 21\\\\\n          $[10, 15]$ & 21\\\\\n          \\hline\n        \\end{tabular}\n      \\end{table}\n    \\end{column}\n    \n    \\begin{column}{0.5\\columnwidth}\n      \\begin{table}\n        \\centering\n        \\caption{Locations}\n        \\begin{tabular}{ll}\n          \\hline\n          Index & Location \\\\\n          \\hline\n          0 & Grossmünster \\\\\n          2 & Bürkliterrasse \\\\\n          7 & Fraumünster \\\\\n          10 & Quaibrücke \\\\\n          11 & Hauptbahnhof \\\\\n          13 & Rathaus \\\\\n          14 & Urania-Sternwarte \\\\\n          15 & Bellevue \\\\\n          25 & Frau Gerolds Garten \\\\\n          27 & Zoo \\\\\n          28 & Restaurant Masoala (Zoo) \\\\\n          34 & Stadion Letzigrund \\\\\n          \\hline\n        \\end{tabular}\n      \\end{table}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\n\\begin{frame}{References}\n  \\bibliographystyle{acm}\n  \\bibliography{../references}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "00eebafa6a96e0114f5b53cac7df7b9128604c6a", "size": 7605, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/presentation-more-items/main.tex", "max_stars_repo_name": "dballesteros7/master-thesis-2015", "max_stars_repo_head_hexsha": "8c0bf9a6eef172fc8167a30780ae0666f8ea2d88", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/presentation-more-items/main.tex", "max_issues_repo_name": "dballesteros7/master-thesis-2015", "max_issues_repo_head_hexsha": "8c0bf9a6eef172fc8167a30780ae0666f8ea2d88", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/presentation-more-items/main.tex", "max_forks_repo_name": "dballesteros7/master-thesis-2015", "max_forks_repo_head_hexsha": "8c0bf9a6eef172fc8167a30780ae0666f8ea2d88", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1785714286, "max_line_length": 150, "alphanum_fraction": 0.6197238659, "num_tokens": 2592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.44037267272733216}}
{"text": "\\documentclass[11pt,twocolumn]{article}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{bibentry}\r\n\\usepackage{cite}\r\n\\usepackage{float}\r\n\\usepackage[margin=1in]{geometry}\r\n\\usepackage{tikz}\r\n\\usepackage[section]{placeins}\r\n\r\n\\floatstyle{boxed}\r\n\\restylefloat{figure}\r\n\r\n\\usetikzlibrary{arrows,backgrounds,decorations.pathmorphing,positioning}\r\n\r\n\\newcommand{\\comment}[1]{}\r\n\r\n\\title{Canary}\r\n\\author{Andrew Carter}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\\section{Problem Statement}\r\nDetermine whether a graph $G$ has a minor isomorphic to $H$.\r\nIn particular we consider $G$ to have a minor $H$ if we can find a function $f : H \\to 2^G$\r\n such that for all $h \\in H$, $f(h)$ is non-empty and connected,\r\n  and if there is an edge between $h_i$ and $h_j$\r\n then there exists a $g_k \\in f(h_k)$  and $g_j \\in f(h_j)$ that are connected.\r\n\r\n\\section{General Algorithm}\r\nLet $G_k$ be the set of vertices in $G$ that are assigned to $h_k$ (i.e. $G_k = f(h_k)$).\r\n\r\nVertices $g \\in G$ may be in one of three states, a vertex may have no constraints, and is therefore considered unassigned.\r\nA vertex maybe be constrained to a specific $G_k$, and are therefore considered assigned to $h_k$.\r\nOr vertices may be constrainted to a binary union of $G_k \\cup G_j$,\r\n and will be referenced as ``may'' be in $G_k$ or ``may'' be in $G_j$.\r\n\r\nStart by considering all vertices in $G$ as unassigned.\r\nGo through each vertex $h_k \\in H$ and assign it to a vertex in $G$.\r\n\r\nThen for each previously assigned vertex $h_j \\in H$ that has an edge between $h_j$ and $h_k$ find a path in $G$ that:\r\n\\begin{enumerate}\r\n\\item Starts at a vertex in $G_j$\r\n\\item Through vertices that may be in $G_j$\r\n\\item Through vertices that are unassigned\r\n\\item Through vertices that may be in $G_k$\r\n\\item Ends at a vertex in $G_k$\r\n\\end{enumerate}\r\nAll vertices on the path that may be in $G_j$ are then put into $G_j$,\r\n  likewise all vertices on the path that may in $G_i$ are then put into $G_i$.\r\nAll unassigned vertices on the path are in $G_j \\cup G_k$.\r\n\r\nRepeat until either the vertices and edges in $H$ are exhausted, or until no path is possible.\r\nIf no path is possible backtrack, trying a diffrent path or vertex assignment until all paths and assignments have been tried.\r\n\r\n\r\nThe middle steps may contain $0$ vertices.\r\nAdditionally the starting vertex and ending vertex are irrelevant when consider unique paths as they don't affect the change in\r\n constraints.\r\n\\section{Optimizations}\r\nWe can apply diffreent optimizations to prevent duplicate or strictly suboptimal paths from being consider.\r\nThis prunes the search space, hopefully speeding up termination.\r\n\r\n\\subsection{Minimal Initial Assignment}\r\nIf $h_k$ was assigned to vertex $g \\in G$, and then reassigned, then no future assignment need assign $g$ to $h_k$.\r\n\\subsection{Minimal Path Length}\r\nIf a path has connected vertices $g_j, g_k$ then the path should also contain the edge $g_j, g_k$.\r\n\r\n\\begin{figure}[H]\r\n\\begin{tikzpicture}\r\n  [\r\n   node distance=5mm and 12mm,\r\n   rn/.style={circle,thick,draw=red,inner sep=0pt,minimum size=6mm},\r\n   gn/.style={circle,thick,draw=green,inner sep=0pt,minimum size=6mm},\r\n   bn/.style={circle,thick,draw=blue,inner sep=0pt,minimum size=6mm},\r\n   yn/.style={circle,thick,draw=yellow,inner sep=0pt,minimum size=6mm},\r\n   cn/.style={circle,thick,draw=cyan,inner sep=0pt,minimum size=6mm},\r\n   mn/.style={circle,thick,draw=magenta,inner sep=0pt,minimum size=6mm}\r\n  ]\r\n   \\node[bn] (n1)               {1};\r\n   \\node[mn] (n3) [above right=of n1] {3};\r\n   \\node[mn] (n4) [right=of n1] {4};\r\n   \\node[rn] (n2) [right=of n4] {2};\r\n\r\n   \\draw[-,color=magenta] (n1) -- (n3);\r\n   \\draw[-,color=magenta] (n3) -- (n4);\r\n   \\draw[-,color=magenta] (n4) -- (n2);\r\n   \\draw[-] (n1) -- (n4);\r\n\r\n\\end{tikzpicture}\r\n\\caption{\\label{fig:min path 1.1}Non-Minimal Path}\r\n\\end{figure}\r\n\r\nIn Figure \\ref{fig:min path 1.1} we see that the path from 1 to 2 through both 3 and 4 is needlessly long.\r\nWe could take the edge directly between 1 and 3, resulting in strictly less constraints.\r\n\r\n\r\n\\subsection{Minimal Path Length on Path Starts and Ends}\r\nThis can be extended to starting vertices, if vertex $g_j \\in G_j$,\r\n  and connected to $g_k$ which is on a path from $G_j$ to $G_k$.\r\nThen the path should contain an edge from a $g \\in G_j$ to $g_k$.\r\n\r\nSimilarly for ending vertices.\r\n\r\n\\begin{figure}[H]\r\n\\begin{tikzpicture}\r\n  [\r\n   node distance=5mm and 12mm,\r\n   rn/.style={circle,thick,draw=red,inner sep=0pt,minimum size=6mm},\r\n   gn/.style={circle,thick,draw=green,inner sep=0pt,minimum size=6mm},\r\n   bn/.style={circle,thick,draw=blue,inner sep=0pt,minimum size=6mm},\r\n   yn/.style={circle,thick,draw=yellow,inner sep=0pt,minimum size=6mm},\r\n   cn/.style={circle,thick,draw=cyan,inner sep=0pt,minimum size=6mm},\r\n   mn/.style={circle,thick,draw=magenta,inner sep=0pt,minimum size=6mm}\r\n  ]\r\n   \\node[bn] (n1)               {1};\r\n   \\node[mn] (n3) [below right=of n1] {3};\r\n   \\node[bn] (n4) [above right=of n1] {4};\r\n   \\node[mn] (n5) [right=of n3] {5};\r\n   \\node[mn] (n6) [right=of n3] {6};\r\n   \\node[rn] (n2) [below right=of n6] {2};\r\n\r\n   \\draw[-,color=magenta] (n1) -- (n3);\r\n   \\draw[-,color=blue] (n1) -- (n4);\r\n   \\draw[-,color=magenta] (n3) -- (n5);\r\n   \\draw[-,color=magenta] (n5) -- (n6);\r\n   \\draw[-,color=magenta] (n6) -- (n2);\r\n   \\draw[-] (n4) -- (n6);\r\n\r\n\\end{tikzpicture}\r\n\\caption{\\label{fig:min path 2.1}Non-Minimal Path}\r\n\\end{figure}\r\n\r\nIn Figure \\ref{fig:min path 2.1}, if vertex 4 is already assigned to vertex 1,\r\n then the path from 1 to 2 through vertices 3, 5, and 6 is needlessly long.\r\nInstead the path could go through 4 (which is already assigned), then directly to 6 and onto 2.\r\nAgain this would result in strictly less constraints.\r\n\r\n\r\n\\subsection{Retroactive Minimal Path Length}\r\nFurthermore if $g_j$ is not assigned to $h_j$, but known to be contained in $G_j \\cup G_k$,\r\n  then it follows that if $g_k$ is not connected to a vertex in $G_j$ then $g_j \\in G_k$.\r\nOtherwise the previous optimization would be violated.\r\n\r\n\\begin{figure}[H]\r\n\\begin{tikzpicture}\r\n  [\r\n   node distance=5mm and 12mm,\r\n   rn/.style={circle,thick,draw=red,inner sep=0pt,minimum size=6mm},\r\n   gn/.style={circle,thick,draw=green,inner sep=0pt,minimum size=6mm},\r\n   bn/.style={circle,thick,draw=blue,inner sep=0pt,minimum size=6mm},\r\n   yn/.style={circle,thick,draw=yellow,inner sep=0pt,minimum size=6mm},\r\n   cn/.style={circle,thick,draw=cyan,inner sep=0pt,minimum size=6mm},\r\n   mn/.style={circle,thick,draw=magenta,inner sep=0pt,minimum size=6mm}\r\n  ]\r\n   \\node[bn] (n1)               {1};\r\n   \\node[mn] (n6) [above right=of n1] {6};\r\n   \\node[cn] (n7) [below right=of n1] {7};\r\n   \\node[mn] (n4) [right=of n6] {4};\r\n   \\node[cn] (n5) [right=of n7] {5};\r\n   \\node[rn] (n2) [right=of n4] {2};\r\n   \\node[gn] (n3) [right=of n5] {3};\r\n\r\n   \\draw[-,color=magenta] (n1) -- (n6);\r\n   \\draw[-,color=magenta] (n6) -- (n4);\r\n   \\draw[-,color=magenta] (n4) -- (n2);\r\n   \\draw[-,color=cyan] (n1) -- (n7);\r\n   \\draw[-,color=cyan] (n7) -- (n5);\r\n   \\draw[-,color=cyan] (n5) -- (n3);\r\n   \\draw[-] (n4) -- (n5);\r\n\r\n\\end{tikzpicture}\r\n\\caption{\\label{fig:min path 3.1}Retroactive Minimal Path Length}\r\n\\end{figure}\r\nIn Figure \\ref{fig:min path 3.1} nodes 1, 2, and 3 are all inital assignments for 3 different vertices in the minor.\r\n There is a path created between 1 and 2 as shown in magenta through vertices 6 and 4.\r\n Both vertices may be assigned to either 4 or 6.\r\n Similarly there is a path between 1 and 3 as shown in cyan through vertices 7 and 5.\r\n\\begin{figure}[H]\r\n\\begin{tikzpicture}\r\n  [\r\n   node distance=5mm and 12mm,\r\n   n/.style={circle,thick,draw=black,inner sep=0pt,minimum size=6mm},\r\n   rn/.style={circle,thick,draw=red,inner sep=0pt,minimum size=6mm},\r\n   gn/.style={circle,thick,draw=green,inner sep=0pt,minimum size=6mm},\r\n   bn/.style={circle,thick,draw=blue,inner sep=0pt,minimum size=6mm},\r\n   yn/.style={circle,thick,draw=yellow,inner sep=0pt,minimum size=6mm},\r\n   cn/.style={circle,thick,draw=cyan,inner sep=0pt,minimum size=6mm},\r\n   mn/.style={circle,thick,draw=magenta,inner sep=0pt,minimum size=6mm}\r\n  ]\r\n   \\node[bn] (n1)               {1};\r\n   \\node[bn] (n6) [above right=of n1] {6};\r\n   \\node[n] (n7) [below right=of n1] {7};\r\n   \\node[bn] (n4) [right=of n6] {4};\r\n   \\node[cn] (n5) [right=of n7] {5};\r\n   \\node[rn] (n2) [right=of n4] {2};\r\n   \\node[gn] (n3) [right=of n5] {3};\r\n\r\n   \\draw[-,color=blue] (n1) -- (n6);\r\n   \\draw[-,color=blue] (n6) -- (n4);\r\n   \\draw[-,color=magenta] (n4) -- (n2);\r\n   \\draw[-] (n1) -- (n7);\r\n   \\draw[-] (n7) -- (n5);\r\n   \\draw[-,color=cyan] (n5) -- (n3);\r\n   \\draw[-,color=cyan] (n4) -- (n5);\r\n\r\n\\end{tikzpicture}\r\n\\caption{\\label{fig:min path 3.2}Assigning 4 to vertex 1}\r\n\\end{figure}\r\n\r\nIn Figure \\ref{fig:min path 3.2} we see that if we were to assign 4 to vertex 1,\r\n  that there would be a more minimal path from 1 to 3 which does not need to use vertex 7.\r\n\r\n\\begin{figure}[H]\r\n\\begin{tikzpicture}\r\n  [\r\n   node distance=5mm and 12mm,\r\n   rn/.style={circle,thick,draw=red,inner sep=0pt,minimum size=6mm},\r\n   gn/.style={circle,thick,draw=green,inner sep=0pt,minimum size=6mm},\r\n   bn/.style={circle,thick,draw=blue,inner sep=0pt,minimum size=6mm},\r\n   yn/.style={circle,thick,draw=yellow,inner sep=0pt,minimum size=6mm},\r\n   cn/.style={circle,thick,draw=cyan,inner sep=0pt,minimum size=6mm},\r\n   mn/.style={circle,thick,draw=magenta,inner sep=0pt,minimum size=6mm}\r\n  ]\r\n   \\node[bn] (n1)               {1};\r\n   \\node[mn] (n6) [above right=of n1] {6};\r\n   \\node[cn] (n7) [below right=of n1] {7};\r\n   \\node[rn] (n4) [right=of n6] {4};\r\n   \\node[gn] (n5) [right=of n7] {5};\r\n   \\node[rn] (n2) [right=of n4] {2};\r\n   \\node[gn] (n3) [right=of n5] {3};\r\n\r\n   \\draw[-,color=magenta] (n1) -- (n6);\r\n   \\draw[-,color=magenta] (n6) -- (n4);\r\n   \\draw[-,color=red] (n4) -- (n2);\r\n   \\draw[-,color=cyan] (n1) -- (n7);\r\n   \\draw[-,color=cyan] (n7) -- (n5);\r\n   \\draw[-,color=green] (n5) -- (n3);\r\n   \\draw[-] (n4) -- (n5);\r\n\r\n\\end{tikzpicture}\r\n\\caption{\\label{fig:min path 3.3}Implied Assignments}\r\n\\end{figure}\r\nTherefore in the original position we must assign 4 to vertex 2, and likewise 5 is assigned vertex 3 as shown in Figure \\ref{fig:min path 3.3}.\r\n\r\n\r\n% No bibliography, change if/when citations are added\r\n\\bibliographystyle{alpha}\r\n\\nocite*{}\r\n\\nobibliography{bib/main}\r\n\\end{document}\r\n\r\n", "meta": {"hexsha": "c0075de959cdb178e030f449534fd127e576572c", "size": 10349, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/canary/paper.tex", "max_stars_repo_name": "calcu16/canary", "max_stars_repo_head_hexsha": "e2bb4444b07226ad3b092f87c73a037921b220d6", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/canary/paper.tex", "max_issues_repo_name": "calcu16/canary", "max_issues_repo_head_hexsha": "e2bb4444b07226ad3b092f87c73a037921b220d6", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/canary/paper.tex", "max_forks_repo_name": "calcu16/canary", "max_forks_repo_head_hexsha": "e2bb4444b07226ad3b092f87c73a037921b220d6", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.7440944882, "max_line_length": 144, "alphanum_fraction": 0.6604502851, "num_tokens": 3576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044135, "lm_q2_score": 0.69925440852404, "lm_q1q2_score": 0.4403726706040326}}
{"text": "%!TEX root = ../../template.tex\n\\section{Tomographic algorithms and reconstruction techniques}%\n\\label{sec:tomographic_algorithms_and_reconstruction_techniques}\n\nTomography is the cross-sectional imaging of an object through the use\nof transmitted or reflected waves, captured by the object exposure to\nthe waves from a set of known angles. It has many different applications\nin science, industry, and most prominently, medicine. Since the\ninvention of the Computed Tomography (\\gls{CT}) machine in 1972, by\nHounsfield~\\cite{Gunderman2006}, tomographic imaging techniques have had\na revolutionary impact, allowing doctors to see inside their patients,\nwithout having to subject them to more invasive\nprocedures~\\cite{Kak2001}.\n\nThe central thought around tomographic image reconstruction is to\nrecreate the information contained inside a target physical body,\nwithout having to cut it or open it in any way. The theory is based on\nRadon's idea that it is possible to \"\\emph{represent a function written\nin $\\mathbb{R}$ in the space of straight lines ($\\mathbb{L}$) through\nits line integrals}\"~\\cite{Radon1986}.\n\nSay we have a body that we want to fully characterise without cutting\nopen or destroying in any way. Now imagine we can traverse it with some\nkind of radiation, ray by ray, and that we are able to measure the rays\nafter they traverse the target. What we would capture would be relative\nto the emitted radiation, of course, but it would also contain\ninformation on how that ray had interacted with the target body's\nmatter. In the case of the ubiquitously used X-Ray radiation, the\nmeasurement would be one of the total attenuation \"imprinted\" onto the\nray by the target body's molecules, in the ray's particular direction.\nIf said body is heterogeneous, the total attenuation can be derived by\nthe infinitesimal sum of all different attenuation phenomena caused by\nthe object's several different constituents (the same can be said of a\nhomogeneous object, but in that case there is only one type of\nattenuation present). This means that each one of the rays contains\ninformation regarding the constitution of said body.\n\nThe question that arises is thus \"\\emph{how we can use this information\nto create a spatially accurate representation of this target's interior\ncomposition?}\". The answer to this question lies on many factors, but\nthe most prominent of which are surely choosing the quantity that we are\ntrying to find (that characterises the object) and assembling the\nprojections (that is what we call the line integrals in tomographic\nimaging) in a way that allows solving an equation system for the\naforementioned quantity. This assembly, a matrix of projections\norganised by their angles and position within the detector, is called\nsinogram. All tomography methods revolve around finding the relationship\nbetween it and the system's geometrical description~\\cite{Bruyant2002,\nKak2001, Herman1973, Herman1995, Herman2009, Defrise2003}.\n\nLet's consider the case in which we deal with a single ray of solar\nlight entering the atmosphere at a given point. Since the atmosphere\ncontains numerous absorbers and comparable atmospheric effects, the ray\nchanges from the point where it enters the atmosphere to the point at\nwhich it is measured by a detector. Total absorption will depend on the\npollutant species, their cross-section and their concentration, since it\nobeys Lambert-Beer's law. Looking from another angle, this absorption\nis also the line integral that we will use to reconstruct our image.\nWith \\gls{DOAS}, it is possible to measure several pollutants at the\nsame time, but for simplicity (and since it is one of the most studied\ncompounds in the field), let's consider that the single pollutant in our\natmospheric mixture is NO$_2$.\n\nThe problem of tomographic reconstruction can be approached in a number\nof ways, depending mostly on the authors. In my literary search, I have\nfound that Kak and Slaney~\\cite{Kak2001} have certainly explained this\nproblem in one of the clearer ways available. Therefore, I shall base\nthe rest of my presentation in their writings, and complement with other\nauthors' notes wherever necessary.\n\nConsidering the coordinate system displayed in\nFigure~\\ref{fig:coordinates}. In this schematic, the object is\nrepresented by the function $f(x, y)$. The  $(\\theta, t)$ parameters can\nbe used to define any line in this schematic. Line AB in particular can\nbe written:\n\n\\begin{equation}\n    \\label{eq:lineAB}\n    x \\cdot \\cos(\\theta) + y \\cdot \\sin(\\theta) = t\n\\end{equation}\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{img/png/coordinates.png}\n    \\caption{Schematic representation for coordinate setting. The image\n    depicts a parallel projection setting~\\cite{Kak2001a}.}\n    \\label{fig:coordinates}\n\\end{figure}\n\nAnd if we were to write a line integral along this line, it would look\nlike Equation~\\ref{eq:lineABIntegral}, the Radon transform of function\n$f(x, y)$:\n\n\\begin{equation}\n    \\label{eq:lineABIntegral}\n    P_{\\theta}(t) = \\int_{-\\infty}^{\\infty} f(x, y) \\cdot \\delta(x \\cdot\n    \\cos(\\theta) + y \\cdot \\sin(\\theta) - t) dxdy\n\\end{equation}\n\nWhere $\\delta$, the delta function, is defined in\nEquation~\\ref{eq:delta}.\n\n\\begin{equation}\n    \\label{eq:delta}\n    \\delta (\\phi) =  \n    \\begin{cases}\n            1, & \\phi = 0\\\\\n            0, & otherwise\n    \\end{cases}\n\\end{equation}\n\nAs I have mentioned previously, a projection is a set of line integrals\nsuch as $P_{\\theta}(t)$. Geometry plays a very important role in how the\nintegrals are written and solved for reconstruction. The simplest case\nis the one where the set is acquired in a row, describing what is called\na parallel geometry. Another more complex case is when a single point\nsource is used as origin for all rays, forming a fan. This is called a\nfan-beam array. There are other possible geometries, but they fall out of\nthe scope of this work and will therefore not be addressed any further.\n\nThe Fourier Slice Theorem (\\gls{FST}) is the most important component of\nthe most important algorithm in tomographic inversion, the Filtered\nBackProjection algorithm (\\gls{FBP}). \\gls{FST} is based on the equality\nrelation between the \ntwo-dimensional Fourier Transform (\\gls{FT}) of the object function and\nthe one-dimensional \\gls{FT} of the object's projection at an angle\n$\\theta$. Let's start by writing the 2D \\gls{FT} for the object\nfunction, Equation~\\ref{eq:objectFT}, and the 1D \\gls{FT} of projection\nP$_\\theta$, in Equation~\\ref{eq:1dFTproj}.\n\n\\begin{equation}\n    \\label{eq:objectFT}\n    F(u, v) = \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} f(x, y)\n    \\cdot \\exp \\left [ -j2\\pi (ux + vy) \\right ] dx dy \n\\end{equation}\n\n\\begin{equation}\n    \\label{eq:1dFTproj}\n    S_{\\theta}(\\omega) = \\int_{-\\infty}^{\\infty} P_{\\theta} \\cdot \\exp\\left[\n    -j2 \\pi \\omega t \\right]\n\\end{equation}\n\nFor simplicity, let's consider the 2D \\gls{FT} at the line defined by\n$v=0$ in the frequency domain. We rewrite the 2D \\gls{FT} integral as:\n\n\\begin{equation}\n    \\label{eq:v0}\n    F(u, 0) = \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} f(x, y)\n    \\cdot \\exp \\left[  -j 2\\pi  \\omega ux \\right] dx dy\n\\end{equation}\n\nNotice that $y$ is not present in the phase factor of the \\gls{FT}\nexpression anymore, and this means we can rearrange the integral as:\n\n\\begin{equation}\n    \\label{eq:v02}\n    F(u, 0) = \\int_{-\\infty}^{\\infty} \\left[ \\mathbf{\\int_{-\\infty}^{\\infty}\n    f(x, y) dy }\\right] \\cdot \\exp \\left[  -j 2\\pi  \\omega ux \\right] dx \n\\end{equation}\n\nNow, the \\textbf{bold} part of Equation~\\ref{eq:v02} is similar to\nEquation~\\ref{eq:lineABIntegral}. It is precisely that equation,\nconsidering $\\theta=0$ and a constant value of $x$, as in\nEquation~\\ref{eq:p0}.\n\n\\begin{equation}\n    \\label{eq:p0}\n    P_{\\theta=0} (x) = \\int_{-\\infty}^{\\infty} f(x, y) dy\n\\end{equation}\n\nThis in turn can be substituted in Equation~\\ref{eq:v02}, finally\narriving at:\n\n\\begin{equation}\n    \\label{eq:FTP}\n    F(u, 0) = \\int_{-\\infty}^{\\infty} P_{\\theta=0} (x) \\cdot \\exp \\left[\n    -j 2\\pi ux \\right] dx\n\\end{equation}\n\nAnd this is the one-dimensional \\gls{FT} for the projection at angle\n$\\theta=0$. Finally, the enunciation of the Fourier Slice Theorem:\n\\begin{center}\n    \\begin{minipage}{0.8\\textwidth}\n\n        \\noindent\\textbf{\\emph{The Fourier Transform of a parallel\n                projection  of an image $f(x, y)$ taken at angle\n                $\\theta$ gives a slice of the two-dimensional Fourier\n                Transform, $F(u, v)$, subtending an angle $\\theta$ with\n                the $u$-axis (see Figure~\\ref{fig:fst})}}\n\n    \\end{minipage}\n\\end{center}\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{img/png/fst.png}\n    \\caption{The \\gls{FST}, a schematic\n    representation~\\cite{Asl2013a}.}\n    \\label{fig:fst}\n\\end{figure}\n\nIf one takes the \\gls{FST} into account, the idea behind the \\gls{FBP}\nseems to appear almost naturally. Say one has a single projection and\nits Fourier transform. From the \\gls{FST}, this projection is the same\nas the object's two-dimensional \\gls{FT} in a single line. A crude\nreconstruction of the original object would result if someone were to\nplace this projection in its right place in the Fourier domain and then\nperform a two-dimensional \\gls{IFT}, while assuming every other\nprojection to be 0. The result, in the image space, would be as if\nsomeone had smeared the object in the projections direction.\n\nWhat is really needed for a correct reconstruction is to do this many\ntimes, with many projections. This brings a problem with the method:\nsmearing the object in all directions will clearly produce a wrong\n\\emph{accumulation} in the center of the image, since every projection\npasses through the middle (remember we are still talking about parallel\ngeometry projections) and are summed on top of each other, but on the\nouter edges, this does not occur. If one does not address this, the\nimage intensity levels in the reconstructed image will be severely\noverestimated in the center and underestimated in the edges (due to\nnormalization). The solution is conceptually easy: we multiply the\nFourier transform by a weighting filter proportional to its frequency\n($\\omega$) and that encompasses its relevance in the global scheme of\nprojections. If there are $K$ projections, then it is adequate for this\nvalue to be $\\frac{2\\pi\\lvert\\omega\\rvert}{K}$. As an algorithm,\n\\gls{FBP} can be written as in Algorithm~\\ref{alg:fbp}.\n\n\\begin{algorithm}\n    \\caption{The Filtered BackProjection Algorithm}\n    \\label{alg:fbp}\n    \\SetAlgoLined\n    \\KwResult{A reconstructed image of the projected object.}\n    \\For{$\\theta \\gets 0$ \\KwTo $180$ \\KwBy $\\frac{180}{K}$}{\n        measure projection $P_{theta}(t)$\\;\n        FT($P_{\\theta}(t)$), rendering $S_{\\theta}(\\omega)$\\;\n        Multiply by $\\frac{2\\pi\\lvert{\\omega}\\rvert}{K}$\\;\n        Sum the \\gls{IFT} of the result in the image space\\;\n    }\n    \n\\end{algorithm}\n\nParallel projections, in which the object is scanned linearly from\nmultiple directions, have the advantage of having a relatively simple\nreconstruction scheme. However, they usually result in acquisition times\nwhich are in the order of minutes. A faster way of collecting the data\nis one where all radiation emanates from a single point-source, which\nrotates around the target object (as well as the detectors). There are\ntwo types of fan-beam projections: equiangular and equally spaced. In\nthis project, I have only worked with equiangular processes, so I will\nnot include an explanation for equally spaced fan-beam projections. The\nreader may find this well described (much better than I would be able\nto) in ~\\cite{Kak2001} and ~\\cite{Herman1973}.\n\nConsider Figure~\\ref{fig:equiangular}. If our projection data were\nacquired through a parallel ray geometry, we would be able to say that\nray SA belonged to a projection $P_{\\theta}(t)$, in which $\\theta$ and\n$t$ would be written:\n\n\\begin{equation}\n    \\label{eq:theta_and_t}\n    \\theta = \\beta + \\gamma \\quad \\text{ and } \\quad t = D \\cdot \\sin \\gamma\n\\end{equation}\n\nIn Equation~\\ref{eq:theta_and_t}, $D$ is the distance between the source\n$S$ and the origin $O$; $\\gamma$ is the angle of a ray within a fan and\n$\\beta$ is the angle that the source $S$ makes with a reference axis.\nThrough these relationships one can \\emph{translate} the parallel\nprojection's FBP algorithm to the fan-beam case, which involves several\ncomplex geometric transformations, although the overall rationale is\nexactly the same.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{img/png/fig319.png}\n    \\caption{Schematic representation of an equiangular fan-beam\n    projection, taken from~\\cite{Kak2001}.}\n    \\label{fig:equiangular}\n\\end{figure}\n\nAnother particularity of fan-beam projection data is the fact that they\ncan be sorted into a parallel projection. For that, one starts with the\npremise that if one were to substitute the fan geometry for parallel\nbeams, most of the fan-beam rays would also appear in some projection of\nthe parallel setup. This re-sorting algorithm starts with\nEquation~\\ref{eq:theta_and_t}. Now, if we call a fan-beam projection\ntaken at angle $\\beta$ $R_{\\beta}(\\gamma)$, and a parallel projection\ntaken at angle $\\theta$ $P_{\\theta}(t)$, one could thus write\nEquation~\\ref{eq:parallel_vs_fanbeam}, which can already be used to\nre-sort any fan-beam projection into parallel beam geometry.\n\n\\begin{equation}\n    \\label{eq:parallel_vs_fanbeam}\n    R_{\\beta}(\\gamma) = P_{\\beta + \\gamma}(D \\cdot \\sin \\gamma)\n\\end{equation}\n\nLet's call the angular interval between fan-beam projections can be\nwritten $\\delta\\beta$, and the angular interval of rays within each fan\nis written $\\delta\\gamma$. In the case that they are the same\n($\\beta=\\gamma=\\alpha$), then it it is the case that they can both be\nreplaced by multiples of that interval in\nEquation~\\ref{eq:parallel_vs_fanbeam}, which becomes\nEquation~\\ref{eq:parallel_vs_fanbeam2}.\n\n\\begin{equation}\n    \\label{eq:parallel_vs_fanbeam2}\n    R_{m \\cdot \\alpha}(n \\cdot\\alpha) = P_{m \\cdot\\alpha + n\n    \\cdot\\alpha}(D \\cdot \\sin n \\cdot\\alpha)\n\\end{equation}\n\nOr, in non-mathematical notation, the n\\textsuperscript{th} ray of the\nm\\textsuperscript{th} radial projection (R) is the same as the\nn\\textsuperscript{th} ray in the (m+n)\\textsuperscript{th} parallel\nprojection. Although being much simpler than directly applying the\n\\gls{FBP} algorithm to the fan-beam projection data, this method has a\nlimitation, which is the non-uniformity of the generated parallel\nprojections. This can usually be corrected through\ninterpolation~\\cite{Kak2001a}. \n", "meta": {"hexsha": "a1cb507e34eb248d8a5f349a49310e1bf810175c", "size": 14656, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/lit_review/tomography.tex", "max_stars_repo_name": "ruivalmeida/novathesis", "max_stars_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/lit_review/tomography.tex", "max_issues_repo_name": "ruivalmeida/novathesis", "max_issues_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/lit_review/tomography.tex", "max_forks_repo_name": "ruivalmeida/novathesis", "max_forks_repo_head_hexsha": "ba50f95c3e6e10f5ec3ff4c98cc8bb786246a6ef", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0880503145, "max_line_length": 76, "alphanum_fraction": 0.7487718341, "num_tokens": 4004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4403726706040326}}
{"text": "\\include{preamble}\n\n\\begin{document}\n\t\\title{Standard \\LaTeX Preamble and Usage Examples}\n\t\\section{Algorithm Example}\n\t\t\\begin{algorithmic}\t[1]\n\t\t\t\\LState $counter\\gets Sketch.total$\n\t\t\t\\For{$h = 1$ \\textbf{to} $H$}\n\t\t\t\\LState $i\\gets Sketch[h].hash(k_1)$\n\t\t\t\\If{$Sketch[h][i].total \\leq counter$}\n\t\t\t\\LState{$index\\gets h$}\n\t\t\t\\LState{$hash\\gets i$}\n\t\t\t\\LState{$counter\\gets Sketch[h][i].total$}\n\t\t\t\\EndIf\n\t\t\t\\EndFor\n\t\t\t\\LState $result\\gets Sketch[index][hash][k_2]$\n\t\t\\end{algorithmic}\n\t\\section{Theory Example}\n\t\t\\begin{lemma}\n\t\t\t\\label{thr:collision}\n\t\t\tLet $h_1...h_n : \\{1...k\\} \\to \\{1...v\\}$, $H$ be a set of sets $H_i$ where $h_i(x) \\in H_i$, $S = \\{h_i^{-1}(x) | x \\in \\bigcup H\\}$.\\\\\n\t\t\t\\begin{displaymath}\n\t\t\t\\forall H_i \\in H, |H_i| = \\sum_{j}^{j \\in S} \\begin{cases}0 \\textnormal{ if } h_i(j) \\notin H_i\\\\\n\t\t\t1 \\textnormal{ otherwise}\\end{cases}.\n\t\t\t\\end{displaymath}\n\t\t\t\\\\\n\t\t\\end{lemma}\n\t\t\n\t\t\\begin{corollary}\n\t\t\t\\label{cor:collision}\n\t\t\tAs a consequence of Lemma~\\ref{thr:collision},\n\t\t\t\\begin{displaymath}\n\t\t\t\\forall H_i \\in H, \\sum_{j}^{j \\in H_i}j = \\sum_{j}^{j \\in S}{\\begin{cases}0 \\textnormal{ if } h(j) \\notin H_i\\\\\n\t\t\t\th(j) \\textnormal{ otherwise}\\end{cases}}.\n\t\t\t\\end{displaymath}\n\t\t\tTherefore, if we were to remove an arbitrary element $x$ from $S$, then the sum would become:\n\t\t\t\\begin{displaymath}\n\t\t\t\\forall H_i \\in H, \\sum_{j}^{j \\in H_i}j = \\sum_{j}^{j \\in S-\\{x\\}}{\\begin{cases}0 \\textnormal{ if } h(j) \\notin H_i\\\\\n\t\t\t\th(j) \\textnormal{ otherwise}\\end{cases}} + h_i(x).\n\t\t\t\\end{displaymath}\n\t\t\tFinally, this allows us to conclude that in the case of the sum of all elements in $S-\\{x\\}$ which have images in $H_i$ is equal to $\\sum_{j}^{j \\in H_i}{j - h_i(x)}$.\n\t\t\\end{corollary}\n\t\\section{Tikz Example}\n\t\n\t\t\\begin{tikzpicture}\n\t\t\n\t\t\\node[server](server 1){};\n\t\t\\node[server, right of= server 1](server 2){};\n\t\t\\node[server, right of= server 2](server 3){};\n\t\t\\node[server, right of= server 3](server 4){};\n\t\t\\node[server, right of= server 4](server 5){};\n\t\t\\node[server, right of= server 5](server 6){};\n\t\t\\node[server, right of= server 6](server 7){};\n\t\t\\node[server, right of= server 7](server 8){};\n\t\t\n\t\t\\node[l3 switch, above of =server 5, xshift=0.1cm,yshift=0.3cm]\n\t\t(l3 switch){};\n\t\t\n\t\t\n\t\t\\draw[thick,darkgray!10!gray] (server 1.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 2.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 3.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 4.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 5.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 6.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 7.north)--(l3 switch);\n\t\t\\draw[thick,darkgray!10!gray] (server 8.north)--(l3 switch);\t\n\t\t\n\t\t\\node[xshift=-1.05cm,yshift=0.2cm,left of = server 8,align=left](lev1){Computing Servers};\n\t\t\\node[xshift=-0.2cm,yshift=0.3cm,above of = lev1,align=left](lev2){L4 Open vSwitch};\n\t\t\n\t\t\n\t\t%\\begin{scope}\n\t\t%\t\\node[my cloud, above of=l3 switch,font=\\large] (it) {Internet}\n\t\t%\t\\draw[thick,darkgray!10!gray] (l3 switch)--(it);\n\t\t%\\end{scope}\n\t\t\n\t\t\\begin{scope}\n\t\t\\node[xshift=0.1cm, yshift=1cm,scale=0.2, above of=l3 switch] (brouter) {\\router{}} edge[very thick,darkgray!10!gray] ([xshift=0.1cm,yshift=0.5cm]l3 switch);\n\t\t\n\t\t\\node[yshift=0.65cm,my cloud, minimum width=1.25cm, minimum height=1.55cm, above of=brouter, font=\\large] (it) {Internet}\tedge[very thick,darkgray!30!gray] (brouter);\n\t\t\n\t\t%\t\\draw[very thick,darkgray!30!gray](brouter)--([xshift=0.1cm,yshift=0.125cm]border 1-a.north);\n\t\t\\end{scope}\n\t\t\n\t\t\\end{tikzpicture}\n\t\t\n\\end{document}", "meta": {"hexsha": "9054e930a66c6100db0a215edcbd8717f60bf7a9", "size": 3582, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples.tex", "max_stars_repo_name": "mirceaIordache/LaTeXTemplates", "max_stars_repo_head_hexsha": "00bf1458af33727ebd364b5b8fcac9cb523b200e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-11T11:08:49.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-11T11:08:49.000Z", "max_issues_repo_path": "examples.tex", "max_issues_repo_name": "mirceaIordache/LaTeXTemplates", "max_issues_repo_head_hexsha": "00bf1458af33727ebd364b5b8fcac9cb523b200e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples.tex", "max_forks_repo_name": "mirceaIordache/LaTeXTemplates", "max_forks_repo_head_hexsha": "00bf1458af33727ebd364b5b8fcac9cb523b200e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.7045454545, "max_line_length": 170, "alphanum_fraction": 0.6448911223, "num_tokens": 1452, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4403726608862615}}
{"text": "%!TEX root = da2020-03.tex\n\n\\Chapter{3}{\\tPN{}~Model: Port~Numbering}\n\n\\noindent\nNow that we have introduced the essential graph-theoretic concepts, we are ready to define what a ``distributed algorithm'' is. In this chapter, we will study one variant of the theme: deterministic distributed algorithms in the ``port-numbering model''. We will use the abbreviation $\\PN$ for the port-numbering model, and we will also use the term ``$\\PN$-algorithm'' to refer to deterministic distributed algorithms in the port-numbering model. For now, everything will be deterministic\\mydash randomized algorithms will be discussed in later chapters.\n\n\\section{Introduction}\n\nThe basic idea of the $\\PN$ model is best explained through an example. Suppose that I claim the following:\n\\begin{itemize}\n    \\item $A$ is a deterministic distributed algorithm that finds a \\Apx{2} of a minimum vertex cover in the port-numbering model.\n\\end{itemize}\nOr, in brief:\n\\begin{itemize}\n    \\item $A$ is a $\\PN$-algorithm for finding a \\Apx{2} of a minimum vertex cover.\n\\end{itemize}\nInformally, this entails the following:\n\\begin{enumerate}\n    \\item We can take any simple undirected graph $G = (V,E)$.\n    \\item We can then put together a computer network $N$ with the same structure as $G$. A node $v \\in V$ corresponds to a computer in $N$, and an edge $\\{u,v\\} \\in E$ corresponds to a communication link between the computers $u$ and $v$.\n    \\item Communication takes place through communication ports. A node of degree $d$ corresponds to a computer with $d$ ports that are labeled with numbers $1, 2, \\dotsc, d$ in an arbitrary order.\n    \\item Each computer runs a copy of the same deterministic algorithm $A$. All nodes are identical; initially they know only their own degree (i.e., the number of communication ports).\n    \\item All computers are started simultaneously, and they follow algorithm $A$ synchronously in parallel. In each synchronous communication round, all computers in parallel\n    \\begin{enumerate}[label=(\\arabic*)]\n        \\item send a message to each of their ports,\n        \\item wait while the messages are propagated along the communication channels,\n        \\item receive a message from each of their ports, and\n        \\item update their own state.\n    \\end{enumerate}\n    \\item After each round, a computer can stop and announce its \\emph{local output}: in this case the local output is either $0$ or $1$.\n    \\item We require that all nodes eventually stop\\mydash the \\emph{running time} of the algorithm is the number of communication rounds it takes until all nodes have stopped.\n    \\item We require that\n        \\[ C = \\Set{ v \\in V : \\text{computer $v$ produced output $1$} } \\]\n        is a feasible vertex cover for graph $G$, and its size is at most $2$ times the size of a minimum vertex cover. \n\\end{enumerate}\nSections \\ref{sec:pnn} and \\ref{sec:distr-alg} will formalize this idea.\n\n\\section{Port-Numbered Network}\\label{sec:pnn}\n\nA \\emph{port-numbered network} is a triple $N = (V,P,p)$, where $V$ is the set of \\emph{nodes}, $P$ is the set of \\emph{ports}, and $p\\colon P \\to P$ is a function that specifies the \\emph{connections} between the ports. We make the following assumptions:\n\\begin{enumerate}\n    \\item Each port is a pair $(v,i)$ where $v \\in V$ and $i \\in \\{1,2,\\dotsc\\}$.\n    \\item The connection function $p$ is an involution, that is, for any port $x \\in P$ we have $p(p(x)) = x$.\n\\end{enumerate}\nSee Figures \\ref{fig:pnna} and \\ref{fig:pnnb} for illustrations.\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PPnnA]{figs.pdf}\n    \\caption{A port-numbered network $N = (V,P,p)$. There are four nodes, $V = \\{a,b,c,d\\}$; the degree of node $a$ is $3$, the degrees of nodes $b$ and $c$ are $2$, and the degree of node $d$ is $1$. The connection function $p$ is illustrated with arrows\\mydash for example, $p(a,3) = (d,1)$ and conversely $p(d,1) = (a,3)$. This network is simple.}\\label{fig:pnna}\n\\end{figure}\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PPnnB]{figs.pdf}\n    \\caption{A port-numbered network $N = (V,P,p)$. There is a loop at node $a$, as $p(a,1) = (a,1)$, and another loop at node $d$, as $p(d,3) = (d,4)$. There are also multiple connections between $c$ and $d$. Hence the network is not simple.}\\label{fig:pnnb}\n\\end{figure}\n\n\\subsection{Terminology}\n\nIf $(v,i) \\in P$, we say that $(v,i)$ is the port number $i$ in node $v$. The \\emph{degree} $\\deg_N(v)$ of a node $v \\in V$ is the number of ports in $v$, that is, $\\deg_N(v) = |\\Set{ i \\in \\NN : (v,i) \\in P }|$.\n\nUnless otherwise mentioned, we assume that the port numbers are \\emph{consecutive}: for each $v \\in V$ there are ports $(v,1),\\allowbreak (v,2),\\allowbreak \\dotsc,\\allowbreak (v,\\deg_N(v))$ in~$P$.\n\nWe use the shorthand notation $p(v,i)$ for $p((v,i))$. If $p(u,i) = (v,j)$, we say that port $(u,i)$ is \\emph{connected} to port $(v,j)$; we also say that port $(u,i)$ is connected to node $v$, and that node $u$ is connected to node~$v$.\n\nIf $p(v,i) = (v,j)$ for some $j$, we say that there is a \\emph{loop} at $v$\\mydash note that we may have $i = j$ or $i \\ne j$. If $p(u,i_1) = (v,j_1)$ and $p(u,i_2) = (v,j_2)$ for some $u \\ne v$, $i_1 \\ne i_2$, and $j_1 \\ne j_2$, we say that there are \\emph{multiple connections} between $u$ and~$v$. A port-numbered network $N = (V,P,p)$ is \\emph{simple} if there are no loops or multiple connections. \n\n\\subsection{Underlying Graph}\n\nFor a simple port-numbered network $N = (V,P,p)$ we define the \\emph{underlying graph} $G = (V,E)$ as follows: $\\{u,v\\} \\in E$ if and only if $u$ is connected to $v$ in network~$N$. Observe that $\\deg_G(v) = \\deg_N(v)$ for all $v \\in V$. See Figure~\\ref{fig:pnnc} for an illustration.\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PPnnC]{figs.pdf}\n    \\caption{(a)~An alternative drawing of the simple port-numbered network $N$ from Figure~\\ref{fig:pnna}. (b)~The underlying graph $G$ of $N$.}\\label{fig:pnnc}\n\\end{figure}\n\n\\subsection{Encoding Input and Output}\\label{ssec:encoding-io}\n\nIn a distributed system, nodes are the active elements: they can read input and produce output. Hence we will heavily rely on \\emph{node labelings}: we can directly associate information with each node $v \\in V$.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PPnnD]{figs.pdf}\n    \\caption{(a)~A graph $G = (V,E)$ and a matching $M \\subseteq E$. (b)~A port-numbered network $N$; graph $G$ is the underlying graph of $N$. The node labeling $f\\colon V \\to \\{0,1\\}^*$ is an encoding of matching $M$.}\\label{fig:pnnd}\n\\end{figure}\n\nAssume that $N = (V,P,p)$ is a simple port-numbered network, and $G = (V,E)$ is the underlying graph of~$N$. We show that a node labeling $f\\colon V \\to Y$ can be used to represent the following graph-theoretic structures; see Figure~\\ref{fig:pnnd} for an illustration.\n\\begin{description}\n    \\item[Node labeling $g\\colon V \\to X$.]\n        Trivial: we can choose $Y = X$ and $f = g$.\n    \\item[Subset of nodes $X \\subseteq V$.]\n        We can interpret a subset of nodes as a node labeling $g\\colon V \\to \\{0,1\\}$, where $g$ is the indicator function of set~$X$. That is, $g(v) = 1$ iff $v \\in X$.\n    \\item[Edge labeling $g\\colon E \\to X$.]\n        For each node $v$, its label $f(v)$ encodes the values $g(e)$ for all edges $e$ incident to $v$, in the order of increasing port numbers. More precisely, if $v$ is a node of degree $d$, its label is a vector $f(v) \\in X^d$. If $(v,j) \\in P$ and $p(v,j) = (u,i)$, then element $j$ of vector $f(v)$ is $g(\\{u,v\\})$.\n    \\item[Subset of edges $X \\subseteq E$.]\n        We can interpret a subset of edges as an edge labeling $g\\colon E \\to \\{0,1\\}$.\n    \\item[Orientation $H = (V,E')$.]\n        For each node $v$, its label $f(v)$ indicates which of the edges incident to $v$ are outgoing edges, in the order of increasing port numbers.\n\\end{description}\n\nIt is trivial to compose the labelings. For example, we can easily construct a node labeling that encodes both a subset of nodes and a subset of edges.\n\n\n\\subsection{Distributed Graph Problems}\\label{ssec:distr-graph-problem}\n\nA \\emph{distributed graph problem} $\\Pi$ associates a set of solutions $\\Pi(N)$ with each simple port-numbered network $N = (V,P,p)$. A \\emph{solution} $f \\in \\Pi(N)$ is a node labeling $f\\colon V \\to Y$ for some set $Y$ of \\emph{local outputs}.\n\nUsing the encodings of Section~\\ref{ssec:encoding-io}, we can interpret all of the following as distributed graph problems: independent sets, vertex covers, dominating sets, matchings, edge covers, edge dominating sets, colorings, edge colorings, domatic partitions, edge domatic partitions, factors, factorizations, orientations, and any combinations of these.\n\nTo make the idea more clear, we will give some more detailed examples.\n\\begin{enumerate}\n    \\item \\emph{Vertex cover}: $f \\in \\Pi(N)$ if $f$ encodes a vertex cover of the underlying graph of $N$.\n    \\item \\emph{Minimal vertex cover}: $f \\in \\Pi(N)$ if $f$ encodes a minimal vertex cover of the underlying graph of $N$.\n    \\item \\emph{Minimum vertex cover}: $f \\in \\Pi(N)$ if $f$ encodes a minimum vertex cover of the underlying graph of $N$.\n    \\item \\emph{\\Apx{2} of minimum vertex cover}: $f \\in \\Pi(N)$ if $f$ encodes a vertex cover $C$ of the underlying graph of $N$; moreover, the size of $C$ is at most two times the size of a minimum vertex cover.\n    \\item \\emph{Orientation}: $f \\in \\Pi(N)$ if $f$ encodes an orientation of the underlying graph of $N$.\n    \\item \\emph{$2$-coloring}: $f \\in \\Pi(N)$ if $f$ encodes a $2$-coloring of the underlying graph of $N$. Note that we will have $\\Pi(N) = \\emptyset$ if the underlying graph of $N$ is not bipartite.\n\\end{enumerate}\n\n\n\\section[Distributed Algorithms in the \\tPN{} model]{Distributed Algorithms in the Port-Numbering Model}\\label{sec:distr-alg}\n\nWe will now give a formal definition of a distributed algorithm in the port-numbering model. In essence, a distributed algorithm is a state machine (not necessarily a finite-state machine). To run the algorithm on a certain port-numbered network, we put a copy of the same state machine at each node of the network.\n\nThe formal definition of a distributed algorithm plays a similar role as the definition of a Turing machine in the study of non-distributed algorithms. A formally rigorous foundation is necessary to study questions such as computability and computational complexity. However, we do not usually present algorithms as Turing machines, and the same is the case here. Once we become more familiar with distributed algorithms, we will use higher-level pseudocode to define algorithms and omit the tedious details of translating the high-level description into a state machine.\n\n\\subsection{State Machine}\n\nA distributed algorithm $A$ is a state machine that consists of the following components:\n\\begin{enumerate}[label=(\\roman*)]\n    \\item $\\Input_A$ is the set of \\emph{local inputs},\n    \\item $\\States_A$ is the set of states,\n    \\item $\\Output_A \\subseteq \\States_A$ is the set of stopping states (\\emph{local outputs}),\n    \\item $\\Msg_A$ is the set of possible messages.\n\\end{enumerate}\nMoreover, for each possible degree $d \\in \\NN$ we have the following functions:\n\\begin{enumerate}[resume*]\n    \\item $\\Init_{A,d} \\colon \\Input_A \\to \\States_A$ initializes the state machine,\n    \\item $\\Send_{A,d} \\colon \\States_A \\to \\Msg_A^d$ constructs outgoing messages,\n    \\item $\\Receive_{A,d} \\colon \\States_A \\times \\Msg_A^d \\to \\States_A$ processes incoming messages.\n\\end{enumerate}\nWe require that $\\Receive_{A,d}(x,y) = x$ whenever $x \\in \\Output_A$. The idea is that a node that has already stopped and printed its local output no longer changes its state.\n\n\\subsection{Execution}\\label{ssec:execution}\n\nLet $A$ be a distributed algorithm, let $N = (V,P,p)$ be a port-numbered network, and let $f\\colon V \\to \\Input_A$ be a labeling of the nodes. A \\emph{state vector} is a function $x\\colon V \\to \\States_A$. The \\emph{execution} of $A$ on $(N,f)$ is a sequence of state vectors $x_0, x_1, \\dotsc$ defined recursively as follows.\n\nThe initial state vector $x_0$ is defined by\n\\[\n    x_0(u) = \\Init_{A,d}(f(u)),\n\\]\nwhere $u \\in V$ and $d = \\deg_N(u)$.\n\nNow assume that we have defined state vector $x_{t-1}$. Define $m_t \\colon P \\to \\Msg_A$ as follows. Assume that $(u,i) \\in P$, $(v,j) = p(u,i)$, and $\\deg_N(v) = \\ell$. Let $m_t(u,i)$ be component $j$ of the vector $\\Send_{A,\\ell}(x_{t-1}(v))$.\n\nIntuitively, $m_t(u,i)$ is the message received by node $u$ from port number $i$ on round $t$. Equivalently, it is the message sent by node $v$ to port number $j$ on round $t$\\mydash recall that ports $(u,i)$ and $(v,j)$ are connected.\n\nFor each node $u \\in V$ with $d = \\deg_N(u)$, we define the message vector\n\\[\n    m_t(u) = \\bigl(m_t(u,1), m_t(u,2), \\dotsc, m_t(u,d) \\bigr).\n\\]\nFinally, we define the new state vector $x_t$ by\n\\[\n    x_t(u) = \\Receive_{A,d}\\bigl(x_{t-1}(u), m_t(u) \\bigr).\n\\]\n\nWe say that algorithm $A$ \\emph{stops in time $T$} if $x_T(u) \\in \\Output_A$ for each $u \\in V$. We say that $A$ \\emph{stops} if $A$ stops in time $T$ for some finite $T$. If $A$ stops in time $T$, we say that $g = x_T$ is the \\emph{output} of $A$, and $x_T(u)$ is the \\emph{local output} of node $u$.\n\n\\subsection{Solving Graph Problems}\\label{ssec:def-solving-graph-problem}\n\nNow we will define precisely what it means if we say that a distributed algorithm $A$ solves a certain graph problem.\n\nLet $\\calF$ be a family of simple undirected graphs. Let $\\Pi$ and $\\Pi'$ be distributed graph problems (see Section~\\ref{ssec:distr-graph-problem}). We say that \\emph{distributed algorithm $A$ solves problem $\\Pi$ on graph family $\\calF$ given $\\Pi'$} if the following holds: assuming that\n\\begin{enumerate}[noitemsep]\n    \\item $N = (V,P,p)$ is a simple port-numbered network,\n    \\item the underlying graph of $N$ is in $\\calF$, and\n    \\item the input $f$ is in $\\Pi'(N)$,\n\\end{enumerate}\nthe execution of algorithm $A$ on $(N,f)$ stops and produces an output $g \\in \\Pi(N)$. If $A$ stops in time $T(|V|)$ for some function $T\\colon \\NN \\to \\NN$, we say that $A$ solves the problem \\emph{in time $T$}.\n\nObviously, $A$ has to be compatible with the encodings of $\\Pi$ and $\\Pi'$. That is, each $f \\in \\Pi'(N)$ has to be a function of the form $f\\colon V \\to \\Input_A$, and each $g \\in \\Pi(N)$ has to be a function of the form $g\\colon V \\to \\Output_A$.\n\nProblem $\\Pi'$ is often omitted. If $A$ does not need the input $f$, we simply say that \\emph{$A$ solves problem $\\Pi$ on graph family $\\calF$}. More precisely, in this case we provide a trivial input $f(v) = 0$ for each $v \\in V$.\n\nIn practice, we will often specify $\\calF$, $\\Pi$, $\\Pi'$, and $T$ implicitly. Here are some examples of common parlance:\n\\begin{enumerate}\n    \\item \\emph{Algorithm $A$ finds a maximum matching in any path graph}: here $\\calF$ consists of all path graphs; $\\Pi'$ is omitted; and $\\Pi$ is the problem of finding a maximum matching.\n    \\item \\emph{Algorithm $A$ finds a maximal independent set in $k$-colored graphs in time $k$}: here $\\calF$ consists of all graphs that admit a $k$-coloring; $\\Pi'$ is the problem of finding a $k$-coloring; $\\Pi$ is the problem of finding a maximal independent set; and $T$ is the constant function $T\\colon n \\mapsto k$.\n\\end{enumerate}\n\n\n\\section{Example: Coloring Paths}\\label{sec:algo-p3c-formal}\n\nRecall the fast $3$-coloring algorithm for paths from Section~\\longref{1.3}{sec:algo-p3c}. We will now present the algorithm in a formally precise manner as a state machine. Let us start with the problem definition:\n\\begin{itemize}[noitemsep]\n    \\item $\\calF$ is the family of path graphs.\n    \\item $\\Pi$ is the problem of coloring graphs with $3$ colors.\n    \\item $\\Pi'$ is the problem of coloring graphs with any number of colors.\n\\end{itemize}\nWe will present algorithm $A$ that solves problem $\\Pi$ on graph family $\\calF$ given $\\Pi'$. Note that in Section~\\longref{1.3}{sec:algo-p3c} we assumed that we have unique identifiers, but it is sufficient to assume that we have some graph coloring, i.e., a solution to problem $\\Pi'$.\n\nThe set of local inputs is determined by what we assume as input:\n\\[\n    \\Input_A = \\NNpos.\n\\]\nThe set of stopping states is determined by the problem that we are trying to solve:\n\\[\n    \\Output_A = \\{1,2,3\\}.\n\\]\nIn our algorithm, each node only needs to store one positive integer (the current color):\n\\[\n    \\States_A = \\NNpos.\n\\]\nMessages are also integers:\n\\[\n    \\Msg_A = \\NNpos.\n\\]\nInitialization is trivial: the initial state of a node is its color. Hence for all $d$ we have\n\\[\n    \\Init_{A,d}(x) = x.\n\\]\nIn each step, each node sends its current color to each of its neighbors. As we assume that all nodes have degree at most $2$, we only need to define $\\Send_{A,d}$ for $d \\le 2$:\n\\begin{align*}\n    \\Send_{A,0}(x) &= (). \\\\\n    \\Send_{A,1}(x) &= (x). \\\\\n    \\Send_{A,2}(x) &= (x,x).\n\\end{align*}\nThe nontrivial part of the algorithm is hidden in the $\\Receive$ function. To define it, we will use the following auxiliary function that returns the smallest positive number not in $X$:\n\\[\n    g(X) = \\min(\\NNpos \\setminus X).\n\\]\nAgain, we only need to define $\\Receive_{A,d}$ for degrees $d \\le 2$:\n\\begin{align*}\n    \\Receive_{A,0}(x, ()) &= \\begin{cases}\n        g(\\emptyset) & \\text{if } x \\notin \\{1,2,3\\}, \\\\\n        x & \\text{otherwise}.\n    \\end{cases}\\\\\n    \\Receive_{A,1}(x, (y)) &= \\begin{cases}\n        g(\\{y\\}) & \\text{if } x \\notin \\{1,2,3\\}\\\\[-2pt]&\\text{and } x > y, \\\\\n        x & \\text{otherwise}.\n    \\end{cases}\\\\\n    \\Receive_{A,2}(x, (y, z)) &= \\begin{cases}\n        g(\\{y,z\\}) & \\text{if } x \\notin \\{1,2,3\\}\\\\[-2pt]&\\text{and } x > y\\text{, }x > z, \\\\\n        x & \\text{otherwise}.\n    \\end{cases}\n\\end{align*}\n\nThis algorithm does precisely the same thing as the algorithm that was described in pseudocode in Table~\\longref{1.1}{tab:algo-p3c}. It can be verified that this algorithm indeed solves problem $\\Pi$ on graph family $\\calF$ given $\\Pi'$, in the sense that we defined in Section~\\ref{ssec:def-solving-graph-problem}.\n\nWe will not usually present distributed algorithms in the low-level state-machine formalism. Typically we are happy with a higher-level presentation (e.g., in pseudocode), but it is important to understand that any distributed algorithm can be always translated into the state machine formalism.\n\nIn the next two sections we will give some non-trivial examples of $\\PN$-algorithms. We will give informal descriptions of the algorithms; in the exercises we will see how to translate these algorithms into the state machine formalism.\n\n\n\\section[Example: Bipartite Maximal Matching]{Example: Maximal Matching in Two-Colored Graphs}\\label{sec:bmm}\n\nIn this section we present a distributed \\emph{bipartite maximal matching} algorithm: it finds a maximal matching in $2$-colored graphs. That is, $\\calF$ is the family of bipartite graphs, we are given a $2$-coloring $f\\colon V \\to \\{1,2\\}$, and the algorithm will output an encoding of a maximal matching $M \\subseteq E$.\n\n\\subsection{Algorithm}\n\nIn what follows, we say that a node $v \\in V$ is \\emph{white} if $f(v) = 1$, and it is \\emph{black} if $f(v) = 2$. During the execution of the algorithm, each node is in one of the states\n\\[\n    \\Set{\n        \\state{UR},\\,\n        \\state{MR}(i),\\,\n        \\state{US},\\,\n        \\state{MS}(i)\n    },\n\\]\nwhich stand for ``unmatched and running'', ``matched and running'', ``unmatched and stopped'', and ``matched and stopped'', respectively. As the names suggest, $\\state{US}$ and $\\state{MS}(i)$ are stopping states. If the state of a node $v$ is $\\state{MS}(i)$ then $v$ is matched with the neighbor that is connected to port $i$.\n\nInitially, all nodes are in state $\\state{UR}$. Each black node $v$ maintains variables $M(v)$ and $X(v)$, which are initialized\n\\[\n    M(v) \\gets \\emptyset, \\quad X(v) \\gets \\{ 1,2, \\dotsc, \\deg(v) \\}.\n\\]\nThe algorithm is presented in Table~\\ref{tab:bmm}; see Figure~\\ref{fig:bmm} for an illustration.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PMaximalMatching]{figs.pdf}\n    \\caption{The bipartite maximal matching algorithm; the illustration shows the algorithm both from the perspective of the port-numbered network $N$ and from the perspective of the underlying graph $G$. Arrows pointing right are proposals, and arrows pointing left are acceptances. Wide gray edges have been added to matching~$M$.}\\label{fig:bmm}\n\\end{figure}\n\n\\begin{table}\n    \\raggedright\n    \\algtoprule\n    \\begin{descriptionb}\n        \\item[Round $2k-1$, white nodes:] \\mbox{}\n        \\begin{itemize}\n            \\item State $\\state{UR}$, $k \\le \\deg_N(v)$: Send \\msg{proposal} to port $(v,k)$.\n            \\item State $\\state{UR}$, $k > \\deg_N(v)$: Switch to state $\\state{US}$.\n            \\item State $\\state{MR}(i)$: Send \\msg{matched} to all ports. \\\\\n                Switch to state $\\state{MS}(i)$.\n        \\end{itemize}\n        \\item[Round $2k-1$, black nodes:] \\mbox{}\n        \\begin{itemize}\n            \\item State $\\state{UR}$: Read incoming messages. \\\\\n                If we receive \\msg{matched} from port $i$, remove $i$ from $X(v)$. \\\\\n                If we receive \\msg{proposal} from port $i$, add $i$ to $M(v)$.\n        \\end{itemize}\n        \\item[Round $2k$, black nodes:] \\mbox{}\n        \\begin{itemize}\n            \\item State $\\state{UR}$, $M(v) \\ne \\emptyset$: Let $i = \\min M(v)$. \\\\\n                Send \\msg{accept} to port $(v,i)$. Switch to state $\\state{MS}(i)$.\n            \\item State $\\state{UR}$, $X(v) = \\emptyset$: Switch to state $\\state{US}$.\n        \\end{itemize}\n        \\item[Round $2k$, white nodes:] \\mbox{}\n        \\begin{itemize}\n            \\item State $\\state{UR}$: Process incoming messages. \\\\\n                If we receive \\msg{accept} from port $i$, switch to state $\\state{MR}(i)$.\n        \\end{itemize}\n    \\end{descriptionb}\n    \\algbottomrule\n    \\caption{The bipartite maximal matching algorithm; here $k = 1, 2, \\dotsc$.}\\label{tab:bmm}\n\\end{table}\n\n\n\\subsection{Analysis}\n\nThe following invariant is useful in order to analyze the algorithm.\n\\begin{lemma}\\label{lem:bmminv}\n    Assume that $u$ is a white node, $v$ is a black node, and $(u,i) = p(v,j)$. Then at least one of the following holds:\n    \\begin{enumerate}[noitemsep]\n        \\item element $j$ is removed from $X(v)$ before round $2i$,\n        \\item at least one element is added to $M(v)$ before round $2i$.\n    \\end{enumerate}\n\\end{lemma}\n\\begin{proof}\n    Assume that we still have $M(v) = \\emptyset$ and $j \\in X(v)$ after round $2i-2$. This implies that $v$ is still in state $\\state{UR}$, and $u$ has not sent \\msg{matched} to $v$. In particular, $u$ is in state $\\state{UR}$ or $\\state{MR}(i)$ after round $2i-2$. In the former case, $u$ sends \\msg{proposal} to $v$ on round $2i-1$, and $j$ is added to $M(v)$ on round $2i-1$. In the latter case, $u$ sends \\msg{matched} to $v$ on round $2i-1$, and $j$ is removed from $X(v)$ on round $2i-1$.\n\\end{proof}\n\nNow it is easy to verify that the algorithm actually makes some progress and eventually halts.\n\\begin{lemma}\\label{lem:bmm-time}\n    The bipartite maximal matching algorithm stops in time $2\\Delta+1$, where $\\Delta$ is the maximum degree of $N$.\n\\end{lemma}\n\\begin{proof}\n    A white node of degree $d$ stops before or during round $2d+1 \\le 2\\Delta+1$.\n    \n    Now let us consider a black node $v$. Assume that we still have $j \\in X(v)$ on round $2\\Delta$. Let $(u,i) = p(v,j)$; note that $i \\le \\Delta$. By Lemma~\\ref{lem:bmminv}, at least one element has been added to $M(v)$ before round $2\\Delta$. In particular, $v$ stops before or during round $2\\Delta$.\n\\end{proof}\n\nMoreover, the output is correct.\n\\begin{lemma}\\label{lem:bmm-correct}\n    The bipartite maximal matching algorithm finds a maximal matching in any two-colored graph.\n\\end{lemma}\n\\begin{proof}\n    Let us first verify that the output correctly encodes a matching. In particular, assume that $u$ is a white node, $v$ is a black node, and $p(u,i) = (v,j)$. We have to prove that $u$ stops in state $\\state{MS}(i)$ if and only if $v$ stops in state $\\state{MS}(j)$. If $u$ stops in state $\\state{MS}(i)$, it has received an \\msg{accept} from $v$, and $v$ stops in state $\\state{MS}(j)$. Conversely, if $v$ stops in state $\\state{MS}(j)$, it has received a \\msg{proposal} from $u$ and it sends an \\msg{accept} to $u$, after which $u$ stops in state $\\state{MS}(i)$.\n    \n    Let us then verify that $M$ is indeed maximal. If this was not the case, there would be an unmatched white node $u$ that is connected to an unmatched black node $v$. However, Lemma~\\ref{lem:bmminv} implies that at least one of them becomes matched before or during round $2\\Delta$.\n\\end{proof}\n\n\n\\section{Example: Vertex Covers}\\label{sec:vc3}\n\nWe will now give a distributed \\emph{minimum vertex cover \\Apx{3}} algorithm; we will use the bipartite maximal matching algorithm from the previous section as a building block.\n\nSo far we have seen algorithms that assume something about the input (e.g., we are given a proper coloring of the network). The algorithm that we will see in this section makes no such assumptions. We can run the minimum vertex cover \\Apx{3} algorithm in any port-numbered network, without any additional input. In particular, we do not need any kind of coloring, unique identifiers, or randomness.\n\n\n\\subsection{Virtual 2-Colored Network}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PVCThreeApx]{figs.pdf}\n    \\caption{Construction of the virtual network $N'$ in the minimum vertex cover \\Apx{3} algorithm.}\\label{fig:vc3}\n\\end{figure}\n\nLet $N = (V,P,p)$ be a port-numbered network. We will construct another port-numbered network $N' = (V'\\!,P'\\!,p')$ as follows; see Figure~\\ref{fig:vc3} for an illustration. First, we double the number of nodes\\mydash for each node $v \\in V$ we have two nodes $v_1$ and $v_2$ in $V'$:\n\\begin{align*}\n    V' &= \\Set{ v_1, v_2 : v \\in V }, \\\\\n    P' &= \\Set{ (v_1,i),\\ (v_2,i) : (v,i) \\in P }.\n\\end{align*}\nThen we define the connections. If $p(u,i) = (v,j)$, we set\n\\begin{align*}\n    p'(u_1,i) &= (v_2,j), \\\\\n    p'(u_2,i) &= (v_1,j).\n\\end{align*}\nWith these definitions we have constructed a network $N'$ such that the underlying graph $G' = (V'\\!,E')$ is bipartite. We can define a $2$-coloring $f'\\colon V' \\to \\{1,2\\}$ as follows:\n\\[\n    f'(v_1) = 1 \\text{ and } f'(v_2) = 2 \\text{ for each } v \\in V.\n\\]\nNodes of color $1$ are called \\emph{white} and nodes of color $2$ are called \\emph{black}.\n\n\n\\subsection{Simulation of the Virtual Network}\n\nNow $N$ is our physical communication network, and $N'$ is merely a mathematical construction. However, the key observation is that we can use the physical network $N$ to efficiently \\emph{simulate} the execution of any distributed algorithm $A$ on $(N'\\!, f')$. Each physical node $v \\in V$ simulates nodes $v_1$ and $v_2$ in $N'$:\n\\begin{enumerate}\n    \\item If $v_1$ sends a message $m_1$ to port $(v_1,i)$ and $v_2$ sends a message $m_2$ to port $(v_2,i)$ in the simulation, then $v$ sends the pair $(m_1,m_2)$ to port $(v,i)$ in the physical network.\n    \\item If $v$ receives a pair $(m_1,m_2)$ from port $(v,i)$ in the physical network, then $v_1$ receives message $m_2$ from port $(v_1,i)$ in the simulation, and $v_2$ receives message $m_1$ from port $(v_2,i)$ in the simulation.\n    \n    Note that we have here reversed the messages: what came from a white node is received by a black node and vice versa.\n\\end{enumerate}\n\nIn particular, we can take the bipartite maximal matching algorithm of Section~\\ref{sec:bmm} and use the network $N$ to simulate it on $(N'\\!,f')$. Note that network $N$ is not necessarily bipartite and we do not have any coloring of $N$; hence we would not be able to apply the bipartite maximal matching algorithm on~$N$.\n\n\n\\subsection{Algorithm}\n\nNow we are ready to present the minimum vertex cover \\Apx{3} algorithm:\n\\begin{enumerate}\n    \\item Simulate the bipartite maximal matching algorithm in the virtual network $N'$. Each node $v$ waits until both of its copies, $v_1$ and $v_2$, have stopped.\n    \\item Node $v$ outputs $1$ if at least one of its copies $v_1$ or $v_2$ becomes matched.\n\\end{enumerate}\n\n\n\\subsection{Analysis}\n\nClearly the minimum vertex cover \\Apx{3} algorithm stops, as the bipartite maximal matching algorithm stops. Moreover, the running time is $2\\Delta+1$ rounds, where $\\Delta$ is the maximum degree of~$N$.\n\nLet us now prove that the output is correct. To this end, let $G = (V,E)$ be the underlying graph of $N$, and let $G' = (V'\\!,E')$ be the underlying graph of $N'$. The bipartite maximal matching algorithm outputs a maximal matching $M' \\subseteq E'$ for $G'$. Define the edge set $M \\subseteq E$ as follows:\n\\begin{equation}\\label{eq:vc3-M}\n    M = \\bigSet{ \\{u,v\\} \\in E : \\{u_1,v_2\\} \\in M' \\text{ or } \\{u_2,v_1\\} \\in M' }.\n\\end{equation}\nSee Figure~\\ref{fig:vc3b} for an illustration. Furthermore, let $C' \\subseteq V'$ be the set of nodes that are incident to an edge of $M'$ in $G'$, and let $C \\subseteq V$ be the set of nodes that are incident to an edge of $M$ in $G$; equivalently, $C$ is the set of nodes that output $1$. We make the following observations.\n\\begin{enumerate}[noitemsep]\n    \\item Each node of $C'$ is incident to precisely one edge of $M'$.\n    \\item\\label{item:vc3deg} Each node of $C$ is incident to one or two edges of $M$.\n    \\item Each edge of $E'$ is incident to at least one node of $C'$.\n    \\item\\label{item:vc3isvc} Each edge of $E$ is incident to at least one node of $C$.\n\\end{enumerate}\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PVCThreeApxB]{figs.pdf}\n    \\caption{Set $M \\subseteq E$ (left) and matching $M' \\subseteq E'$ (right).}\\label{fig:vc3b}\n\\end{figure}\n\nWe are now ready to prove the main result of this section.\n\\begin{lemma}\n    Set $C$ is a \\Apx{3} of a minimum vertex cover of $G$.\n\\end{lemma}\n\\begin{proof}\n    First, observation~\\ref{item:vc3isvc} above already shows that $C$ is a vertex cover of $G$.\n    \n    To analyze the approximation ratio, let $C^* \\subseteq V$ be a vertex cover of $G$. By definition each edge of $E$ is incident to at least one node of $C^*$; in particular, each edge of $M$ is incident to a node of $C^*$. Therefore $C^* \\cap C$ is a vertex cover of the subgraph $H = (C,M)$.\n    \n    By observation~\\ref{item:vc3deg} above, graph $H$ has a maximum degree of at most~$2$. Set $C$ consists of all nodes in $H$. We will then argue that any vertex cover $C^*$ contains at least a fraction $1/3$ of the nodes in $H$; see Figure~\\ref{fig:vc3c} for an example. Then it follows that $C$ is at most $3$ times as large as a minimum vertex cover.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[page=\\PVCThreeApxC]{figs.pdf}\n    \\caption{(a)~In a cycle with $n$ nodes, any vertex cover contains at least $n/2$ nodes. (b)~In a path with $n$ nodes, any vertex cover contains at least $n/3$ nodes.}\\label{fig:vc3c}\n\\end{figure}\n    \n    To this end, let $H_i = (C_i,M_i)$, $i = 1, 2, \\dotsc, k$, be the connected components of $H$; each component is either a path or a cycle. Now $C_i^* = C^* \\cap C_i$ is a vertex cover of $H_i$.\n\n    A node of $C_i^*$ is incident to at most two edges of $M_i$. Therefore\n    \\[\n        |C_i^*| \\ge |M_i|/2.\n    \\]\n    If $H_i$ is a cycle, we have $|C_i| = |M_i|$ and\n    \\[\n        |C_i^*| \\ge |C_i|/2.\n    \\]\n    If $H_i$ is a path, we have $|M_i| = |C_i| - 1$. If $|C_i| \\ge 3$, it follows that\n    \\[\n        |C_i^*| \\ge |C_i|/3.\n    \\]\n    The only remaining case is a path with two nodes, in which case trivially $|C_i^*| \\ge |C_i|/2$.\n\n    In conclusion, we have $|C_i^*| \\ge |C_i|/3$ for each component $H_i$. It follows that\n    \\[\n        |C^*| \\ge |C^* \\cap C| = \\sum_{i=1}^k |C_i^*| \\ge \\sum_{i=1}^k |C_i|/3 = |C|/3. \\qedhere\n    \\]\n\\end{proof}\n\nIn summary, the minimum vertex cover algorithm finds a \\Apx{3} of a minimum vertex cover in any graph $G$. Moreover, if the maximum degree of $G$ is small, the algorithm is fast: we only need $O(\\Delta)$ rounds in a network of maximum degree $\\Delta$.\n\n\\section{Quiz}\n\nConstruct a simple port-numbered network $N = (V,P,p)$ and its underlying graph $G = (V,E)$ that has \\emph{as few nodes as possible} and that satisfies the following properties:\n\\begin{itemize}[noitemsep]\n    \\item Set $E$ is nonempty.\n    \\item If $M \\subseteq E$ consists of the edges $\\{u,v\\} \\in E$ with $p(u,1) = (v,2)$, then $M$ is a perfect matching of graph $G$.\n\\end{itemize}\nPlease answer by listing all elements of sets $V$, $E$, and $P$, and by listing all values of $p$. For example, you might specify a network with two nodes as follows: $V = \\{1,2\\}$, $E = \\{ \\{1,2\\} \\}$, $P = \\{ (1,1), (2,1) \\}$, $p(1,1) = (2,1)$, and $p(2,1) = (1,1)$.\n\n\\section{Exercises}\n\n\\begin{ex}[formalizing bipartite maximal matching]\n    Present the bipartite maximal matching algorithm from Section~\\ref{sec:bmm} in a formally precise manner, using the definitions of Section~\\ref{sec:distr-alg}. Try to make $\\Msg_A$ as small as possible.\n\\end{ex}\n\n\\begin{ex}[formalizing vertex cover approximation]\n    Present the minimum vertex cover \\Apx{3} algorithm from Section~\\ref{sec:vc3} in a formally precise manner, using the definitions of Section~\\ref{sec:distr-alg}. Try to make both $\\Msg_A$ and $\\States_A$ as small as possible.\n    \n    \\hint{For the purposes of the minimum vertex cover algorithm, it is sufficient to know which nodes are matched in the bipartite maximal matching algorithm\\mydash we do not need to know with whom they are matched.}\n\\end{ex}\n\n\\begin{ex}[stopped nodes]\\label{ex:stopped}\n    In the formalism of this chapter, a node that stops will repeatedly send messages to its neighbors. Show that this detail is irrelevant, and we can always re-write algorithms so that such messages are ignored. Put otherwise, a node that stops can also stop sending messages.\n    \n    More precisely, assume that $A$ is a distributed algorithm that solves problem $\\Pi$ on family $\\calF$ given $\\Pi'$ in time $T$. Show that there is another algorithm $A'$ such that (i)~$A'$ solves problem $\\Pi$ on family $\\calF$ given $\\Pi'$ in time $T + O(1)$, and (ii)~in $A'$ the state transitions never depend on the messages that are sent by nodes that have stopped.\n\\end{ex}\n\n\\begin{ex}[more than two colors]\n    Design a distributed algorithm that finds a maximal matching in $k$-colored graphs. You can assume that $k$ is a known constant.\n\\end{ex}\n\n\\begin{ex}[analysis of vertex cover approximation]\\label{ex:vc3tight}\n    Is the analysis of the minimum vertex cover \\Apx{3} algorithm tight? That is, is it possible to construct a network $N$ such that the algorithm outputs a vertex cover that is exactly $3$ times as large as the minimum vertex cover of the underlying graph of $N$?\n\\end{ex}\n\n\\begin{exs}[implementation]\\label{ex:simulator}\n    Using your favorite programming language, implement a simulator that lets you play with distributed algorithms in the port-numbering model. Implement the algorithms for bipartite maximal matching and minimum vertex cover \\Apx{3} and try them out in the simulator.\n\\end{exs}\n\n\\begin{exs}[composition]\\label{ex:composition}\n    Assume that algorithm $A_1$ solves problem $\\Pi_1$ on family $\\calF$ given $\\Pi_0$ in time $T_1$, and algorithm $A_2$ solves problem $\\Pi_2$ on family $\\calF$ given $\\Pi_1$ in time $T_2$.\n    \n    Is it always possible to design an algorithm $A$ that solves problem $\\Pi_2$ on family $\\calF$ given $\\Pi_0$ in time $O(T_1 + T_2)$?\n    \n    \\hint{This exercise is not trivial. If $T_1$ was a constant function $T_1(n) = c$, we could simply run $A_1$, and then start $A_2$ at time $c$, using the output of $A_1$ as the input of $A_2$. However, if $T_1$ is an arbitrary function of $|V|$, this strategy is not possible\\mydash we do not know in advance when $A_1$ will stop.}\n\\end{exs}\n\n\n\\section{Bibliographic Notes}\n\nThe concept of a port numbering is from Angluin's~\\cite{angluin80local} work. The bipartite maximal matching algorithm is due to Ha\\'{n}\\'{c}kowiak et al.~\\cite{hanckowiak98distributed}, and the minimum vertex cover \\Apx{3} algorithm is from a paper with Polishchuk~\\cite{polishchuk09simple}.\n\n", "meta": {"hexsha": "037d81d823f5462d02389be5a9a7b571de959f2e", "size": 36147, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "book/ch03.tex", "max_stars_repo_name": "suomela/da2020", "max_stars_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2020-12-11T00:47:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T15:46:43.000Z", "max_issues_repo_path": "book/ch03.tex", "max_issues_repo_name": "suomela/da2020", "max_issues_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-17T18:31:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-17T18:42:16.000Z", "max_forks_repo_path": "book/ch03.tex", "max_forks_repo_name": "suomela/da2020", "max_forks_repo_head_hexsha": "874238b4e1d395769fc89d0d3a9453366056ad1d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-22T03:53:31.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:33:40.000Z", "avg_line_length": 69.3800383877, "max_line_length": 571, "alphanum_fraction": 0.6863916784, "num_tokens": 10882, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.44030648596045174}}
{"text": "\\qquad This chapter is based on three different texts. We have used \\cite{Artemov11} and \\cite{Fitting14} to lay down the basic syntax and semantics of first-order JT45. To prove completeness we have used an unpublished paper by Melvin Fitting. The first time Sergei Artemov constructed the quantified version of LP, it could support a constant domain semantics. In the unpublished paper Fitting proved completeness for that early version of first-order LP. Since Artemov changed the construction of the quantified version of LP, Fitting left that paper unpublished. The Completeness Theorem presented in this chapter is just an adaptation of the proof strategy presented in that paper (the use of \\textit{templates}) for first-order JT45. \r\n\r\n\r\n\r\n\\section{Language and axiom system}\r\n\r\n\r\n\\qquad For this whole chapter we set $\\Li = \\{P, Q, P\\p, Q\\p, \\dots \\}$ to be a countable relational language with no propositional letters.\r\n\r\n\r\n\\begin{defn} (Basic vocabulary)\r\n\t\r\n\t\\begin{itemize} \r\n\t\t\\item $x_{0}, x_{1}, x_{2}, \\dots$ (\\textit{individual variables});\r\n\t\t\\item $\\impli, \\bot$ (\\textit{boolean connectives});\r\n\t\t\\item $\\todo$ (\\textit{universal quantifier});\r\n\t\t\\item $p_{0}, p_{1}, p_{2}, \\dots$(\\textit{justification variables});\r\n\t\t\\item $c_{0}, c_{1}, c_{2A}, \\dots$ (\\textit{justification constants});\r\n\t\t\\item $+$, $\\cdot$, $!$, $?$, $gen_{x}$ (\\textit{justification operators -- for every individual variable $x$, there is an operator $gen_{x}$})\\footnote{To be precise, there is a operator $gen_{i}$ for each $i \\in \\omega$. We identify each operator $gen_{i}$ with the individual variables $x_{i}$. There is no occurrence of a variable in a justification operator, it is just a label.};\r\n\t\t\\item $(\\cdot):_{X} (\\cdot)$,(for every finite set of individual variables $X$);\r\n\t\t\\item $),($ (\\textit{parentheses}).\r\n\t\\end{itemize}\r\n\\end{defn}\r\n\r\n\\begin{defn} (First-order justification terms)\r\n\t\\begin{center}\r\n\t\t$ t :: = p_{i}$   $|$ $c$ $|$  $(t \\cdot t)$ $|$ $(t + t)$ $|$  $!t$ $|$ $?t$ $|$ $gen_{x}(t)$\r\n\t\\end{center}\r\n\\end{defn}\r\n\r\n\\begin{defn} (First-order justification formulas)\r\n\t\\begin{center}\r\n\t\t$ \\varphi :: = Px_1 \\dots x_n$   $|$ $\\bot$ $|$  $(\\varphi \\impli \\varphi)$ $|$ $\\todo x \\varphi$ $|$  $t$$:_{X}$$\\varphi$\r\n\t\\end{center}\r\n\\end{defn}\r\n\r\n\r\n\\qquad The set of all formulas is denoted by $\\Fj$. We are assuming that the set of individual variables, justification variables and justification constants are all countable sets. Thus, it is easy to check that $\\Fj$ itself is a countable set. \r\n\r\n\\begin{defn}\r\n\tWe define the notion of free variables of $\\varphi$, $fv(\\varphi)$, recursively as follows:\r\n\t\r\n\t\\begin{itemize} \r\n\t\t\\item If $\\varphi$ is atomic, then $fv(\\varphi)$ is the set of all variables occurring in $\\varphi$.\r\n\t\t\\item If $\\varphi$ is $(\\psi \\impli \\theta)$, then $fv(\\varphi)$ is $fv(\\psi) \\cup fv(\\theta)$.\r\n\t\t\\item If $\\varphi$ is $\\todo x \\psi$, then $fv(\\varphi)$ is $fv(\\psi) \\backslash \\{x\\}$.\r\n\t\t\\item If $\\varphi$ is $t$$:_{X}$$\\psi$, then  $fv(\\varphi)$ is $X$.\r\n\t\\end{itemize}\r\n\t\r\n\t\r\n\t\\qquad Similarly as in the classical case, we must define the notion of an individual variable $y$ being free for $x$ in the formula $\\varphi$. The definition is the same as in the classical case, we only add the following clause: $y$ is free for $x$ in $t$$:_{X}$$\\varphi$ if two conditions are met, i) $y$ is free for $x$ in $\\varphi$ (in the classical sense), ii) if $y \\in fv(\\varphi)$, then $y \\in X$.\r\n\\end{defn}\r\n\r\n\\qquad We write $Xy$ instead of $X \\cup \\{y\\}$; in this case it is assumed that $y \\notin X$. And we use $t$$:$$\\varphi$ as an abbreviation for $t$$:_{\\vazio}$$\\varphi$\r\n\r\n\\qquad  The first-order JT45, FOJT45, is axiomatized by the following axiom schemes and inference rules:\\\\\r\n\r\n\\textbf{A1} classical axioms of first-order logic\\\\\r\n\r\n\\textbf{A2} $t$$:_{Xy}$$\\varphi \\impli$ $t$$:_{X}$$\\varphi$, provided $y$ does not occur free in $\\varphi$\\\\\r\n\r\n\\textbf{A3} $t$$:_{X}$$\\varphi \\impli$ $t$$:_{Xy}$$\\varphi$ \\\\\r\n\r\n\\textbf{B1} $t$$:_{X}$$\\varphi \\impli \\varphi$\\\\\r\n\r\n\\textbf{B2} $t$$:_{X}$$(\\varphi \\impli \\psi) \\impli$ $(s$$:_{X}$$\\varphi \\impli$ $[t\\cdot s]$$:_{X}$$\\psi)$\\\\\r\n\r\n\\textbf{B3} $t$$:_{X}$$\\varphi \\impli$ $[t+s]$$:_{X}$$\\varphi$, $s$$:_{X}$$\\varphi \\impli$ $[t+s]$$:_{X}$$\\varphi$\\\\ \r\n\r\n\\textbf{B4} $t$$:_{X}$$\\varphi \\impli$ $!t$$:_{X}$$t$$:_{X}$$\\varphi$\\\\\r\n\r\n\r\n\\textbf{B5} $\\nao t$$:_{X}$$\\varphi \\impli$ $?t$$:_{X}$$\\nao t$$:_{X}$$\\varphi$\\\\\r\n\r\n\r\n\\textbf{B6} $t$$:_{X}$$\\varphi \\impli$ $gen_{x}(t)$$:_{X}$$ \\todo x \\varphi$, provided $x \\notin X$\\\\\r\n\r\n\r\n\\textbf{R1} (\\textit{Modus Ponens}) $\\teo \\varphi$, $\\teo \\varphi\\impli\\psi$ $\\Rightarrow$ $\\teo \\psi$ \\\\\r\n\r\n\\textbf{R2} (\\textit{generalization})  $\\teo \\varphi$ $\\Rightarrow$ $\\teo \\todo x \\varphi$ \\\\\r\n\r\n\\textbf{R3} (\\textit{axiom necessitation})  $\\teo c$$:$$\\varphi$, where $\\varphi$ is an axiom and $c$ is a justification constant.\\\\\r\n\r\n\\qquad We use $\\Gamma, \\Delta, \\Theta, \\dots$ as variables for sets of formulas. The notion of $\\Gamma \\teo \\varphi$ is defined as usual. The only thing that should be noted is that, if $\\Gamma$ deduces $\\varphi$ using the generalization rule, then this rule was not applied to a variable which occurs free in the formulas of $\\Gamma$. \r\n\r\n\\qquad Since derivations depend on the constant specification being considered, we sometimes write $\\teo_{\\C} \\varphi$ to point out that the proof of $\\varphi$ meets the constant specification $\\C$.\r\n\r\n\\begin{lema}\r\n\t(\\textit{Deduction})  $\\Gamma,\\varphi \\teo \\psi$ iff  $\\Gamma \\teo \\varphi \\impli \\psi$.\r\n\\end{lema}\r\n\r\n\\begin{proof}\r\n\tA similar proof as the one from the classical case.\r\n\\end{proof}\r\n\r\n\r\n\\begin{teor}\r\n\t(\\textit{Internalization}) Let $\\C$ be an axiomatically appropriate constant specification; $p_{0}, \\dots, p_{k}$ be justification variables; $X_{0}, \\dots, X_{k}$ be finite sets of individual variables, and $X =X_{0} \\cup \\dots \\cup X_{k}$. In these conditions, if  $p_{0}$$:_{X_{0}}$$\\varphi_{0}, \\dots, p_{k}$$:_{X_{k}}$$\\varphi_{k} \\teo_{\\C} \\psi$, then there is a justification term $t(p_{0}, \\dots, p_{k})$ such that \r\n\t\r\n\t\\begin{center}\r\n\t\t$p_{0}$$:_{X_{0}}$$\\varphi_{0}, \\dots, \r\n\t\tp_{k}$$:_{X_{k}}$$\\varphi_{k} \\teo_{\\C} t$$:_{X}$$\\psi$.\r\n\t\\end{center}\r\n\t\r\n\\end{teor}\r\n\r\n\\begin{proof}\r\n\tThe same proof as presented in \\cite[p. 7]{Artemov11}.\r\n\\end{proof}\r\n\r\n\r\n\r\n\\begin{pro}\r\n\t(\\textit{Explicit counterpart of the Barcan Formula and its converse}) Let $y$ be an individual variable. For  every finite set of individual variables $X$ such that $y \\notin X$, for every formula $\\varphi(y)$ and every justification term $t$, there are justification terms $CB(t)$ and $B(t)$ such that: \r\n\t\\begin{center}\r\n\t\t$\\teo t$$:_{X}$$\\todo y \\varphi(y) \\impli \\todo y CB(t)$$:_{Xy}$$\\varphi(y)$\\\\\r\n\t\t\r\n\t\t$\\teo \\todo y t$$:_{Xy}$$\\varphi(y) \\impli B(t)$$:_{X}$$\\todo y \\varphi(y)$\r\n\t\\end{center}\r\n\\end{pro}\r\n\r\n\r\n\r\n\\begin{proof}\r\n\t\\qquad In Appendix.\r\n\\end{proof}\r\n\r\n\r\n\r\n\\begin{pro}\r\n\tLet $y$ be an individual variable. For  every finite set of individual variables $X$ such that $y \\notin X$, for every formula $\\varphi(y)$ and every justification term $t$, there is a justification term $s(t)$ such that: \r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y t$$:_{Xy}$$\\varphi(y) \\impli s(t)$$:_{X}$$\\ex y \\varphi(y)$\r\n\t\\end{center}\r\n\\end{pro}\r\n\r\n\r\n\r\n\\begin{proof}\r\n\t\\qquad In Appendix.\r\n\\end{proof}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\section{Semantics: basic definitions}\r\n\r\n\\qquad In Chapters 2 and 3 we have used valuation functions to define the relation $\\models$. In the present case it is more convenient to define the semantic notions adding constants to the basic language. That is the path that we take here. So, for any non-empty set $\\D$ we are going to use the elements of $\\D$ as constants. And  we are going to use $\\vec{a}, \\vec{b},  \\dots$ to denote sequences of constants.\r\n\r\n\\begin{defn}\r\n\tLet $\\D$ be a non-empty set. The set of all $\\D$-formulas, $\\D$-$\\Fj$, is defined as follows:\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\D$-$\\Fj = \\{\\varphi (\\vec{a})$ $|$  $\\varphi(\\vec{x}) \\in \\Fj$ and $\\vec{a} \\in \\D\\}$.\r\n\t\\end{center}\r\n\t\r\n\\end{defn}\r\n\r\n\\qquad As usual, for a $\\D$-formula $\\varphi$, we say that $\\varphi$ is closed if  $\\varphi$ has no free variables.\r\n\r\n\\begin{defn}\r\n\tA \\textit{Fitting model} is a structure $\\M = \\model$ where $\\bl \\W, \\R, \\D \\br$ is a skeleton, $\\R$ is an equivalence relation\\footnote{Of course, we can define a Fitting model more generally for any kind of relation $\\R$, but for our purposes we are going to use this restricted definition.},  $\\I$ is an \\textit{interpretation function} and:\r\n\t\r\n\t\\begin{itemize} \r\n\t\t\\item $\\E$ is an \\textit{evidence function}, i.e., for any justification term $t$ and $\\D$-formula $\\varphi$, $\\E(t,\\varphi) \\subseteq \\W$.\r\n\t\\end{itemize}\r\n\t\r\n\\end{defn}\r\n\r\n\r\n\r\n\\begin{defn}\r\n\t\\textit{Evidence Function Conditions}. Let $\\M = \\model$ be a Fitting model. We require the evidence function to meet the following conditions:\r\n\t\r\n\t\r\n\t\\begin{itemize} \r\n\t\t\\item[] \\textbf{$\\cdot$ Condition} $\\E (t, \\varphi \\impli \\psi) \\cap \\E(s, \\varphi) \\subseteq \\E([t\\cdot s], \\psi).$\r\n\t\t\\item[] \\textbf{$+$ Condition} $\\E (s, \\varphi) \\cup \\E(t, \\varphi) \\subseteq \\E([s+t], \\varphi).$\r\n\t\t\\item[] \\textbf{$!$ Condition} $\\E (t, \\varphi) \\subseteq \\E(!t, t$$:_{X}\\varphi)$, where $X$ is the set of constant occurring in $\\varphi$.\r\n\t\t\\item[] \\textbf{$?$ Condition} $\\W  \\backslash \\E (t, \\varphi) \\subseteq \\E(?t,\\nao t$$:_{X}\\varphi)$, where $X$ is the set of constants occurring in $\\varphi$.\r\n\t\t\\item[] \\textbf{$\\R$ Closure Condition} If $w \\in \\E (t, \\varphi)$ and $w \\R w\\p$, then $w\\p \\in \\E (t, \\varphi)$.\r\n\t\t\\item[] \\textbf{Instantiation Condition} If $w \\in \\E (t, \\varphi(x))$ and $a \\in \\D$, then $w \\in \\E (t, \\varphi(a))$.\r\n\t\t\\item[] \\textbf{$gen_{x}$ Condition} $\\E (t, \\varphi) \\subseteq \\E(gen_{x}(t),\\todo x\\varphi)$.\r\n\t\\end{itemize}\r\n\\end{defn}\r\n\r\n\\qquad We say that a model $\\M = \\model$ \\textit{meets constant specification $\\C$} iff whenever $c$$:$$\\varphi \\in \\C$, then $\\E (c, \\varphi) = \\W$.\r\n\r\n\r\n\\begin{defn}\r\n\tLet $\\M = \\model$ be a Fitting model, $\\varphi$ a closed $\\D$-formula and $w \\in \\W$. The notion that \\textit{$\\varphi$ is true at world $w$ of $\\M$}, in symbols $\\M,w \\models \\varphi$, is defined recursively as follows: \r\n\t\\begin{itemize} \r\n\t\t\\item $\\M,w \\models P(\\vec{a})$ iff $\\bl \\vec{a}\\br \\in \\I(P,w)$. \r\n\t\t\\item $\\M,w \\nmodels \\bot$. \r\n\t\t\\item $\\M,w \\models \\psi \\impli \\theta$ iff $\\M,w \\nmodels \\psi$ or $\\M,w \\models \\theta$.\r\n\t\t\\item $\\M,w \\models \\todo x \\psi(x)$ iff for every $a \\in \\D$, $\\M,w \\models \\psi(a)$.        \r\n\t\t\\item Assume $t$$:_{X}$$\\psi(\\vec{x})$ is closed and $\\vec{x}$ are all the free variables of $\\psi$. Then, $\\M,w \\models t$$:_{X}$$\\psi(\\vec{x})$ iff\r\n\t\t\\begin{enumerate}[(a)]\r\n\t\t\t\\item $w \\in \\E (t, \\psi(\\vec{x}))$ and\r\n\t\t\t\\item for every $w\\p \\in \\W$ such that $w\\R w\\p$, $\\M,w\\p \\models \\psi(\\vec{a})$ for every $\\vec{a} \\in \\D$.\r\n\t\t\\end{enumerate}\r\n\t\t\r\n\t\\end{itemize}\r\n\t\r\n\\end{defn}\r\n\r\n\r\n\r\n\\begin{defn}\r\n\tLet $\\varphi \\in \\Fj$ be a closed formula. We say that $\\varphi$ is \\textit{valid in the Fitting model} $\\M = \\model$ provided for every $w \\in W$, $\\M,w \\models \\varphi$. A formula with free individual variables is valid if its universal closure is valid.\r\n\\end{defn}\r\n\r\n\r\n\\begin{defn}\r\n\tA \\textit{Fitting model for FOJT45} is a Fitting model $\\M = \\model$ where $\\E$ is a \\textit{strong evidence function}, i.e., for every term $t$ and $\\D$-formula $\\varphi$, $\\E(t,\\varphi) \\subseteq \\{w \\in \\W$ $|$ $ \\M,w \\models t$$:_{X}$$\\varphi\\}$ where $X$ is the set of constant occurring in $\\varphi$.\r\n\t\r\n\t\r\n\t\\qquad For a formula $\\varphi$ and constant specification $\\C$, we write $\\models_{\\C}\\varphi$ if for every Fitting model for FOJT45 $\\M$ meeting $\\C$, $\\varphi$ is valid in $\\M$.\r\n\\end{defn}\r\n\r\n\r\n\r\n\\section{Semantics: non-validity}\r\n\r\n\\qquad Before we deal with soundness and completeness, it is useful to know some examples of non-validity in order to see that the provisions of some axioms make sense. There is only a minor problem, we require that Fitting models for FOJT45 have a strong evidence function, and it is not so easy to construct models with that property. The following proposition helps us to circumnavigate this issue.\r\n\r\n\r\n\\begin{pro}\r\n\tIf $\\M = \\model$ is a Fitting model such that for every justification term $t$ and $\\D$-formula $\\varphi$, $\\E(t,\\varphi) = \\W$, then there is a Fitting model for FOJT45 $\\M^{*} = \\bl\\W,\\R,\\D,\\I,\\E^{*} \\br$ such that for every $w \\in \\W$ and every formula $\\varphi$, $\\M,w \\models \\varphi$ iff $\\M^{*},w \\models \\varphi$.   \r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\t\\qquad Let $\\M^{*} =\\bl\\W,\\R,\\D,\\I,\\E^{*} \\br$ where for every justification term and $\\D$-formula $\\varphi$,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\E^{*}(t,\\varphi) = \\{w \\in \\W$ $|$ $ \\M,w \\models t$$:_{X}$$\\varphi\\}$\r\n\t\\end{center}\r\nwhere $X$ is the set of constants occurring in $\\varphi$. \r\n\t\r\n\t\\qquad It is straightforward to check that $\\M^{*}$ is indeed a Fitting model. Now consider the following:\\\\\r\n\t\r\n\t(+) For every $w \\in \\W$ and every closed $\\D$-formula $\\varphi$, $\\M,w \\models \\varphi$ iff $\\M^{*},w \\models \\varphi$.\\\\\r\n\t\r\n\t(Proof of (+)) Induction on $\\varphi$. Crucial case, $\\varphi$ is $t$$:_{X}$$\\psi$. For simplicity, let us assume that $\\varphi$ is $t$$:_{\\{a\\}}$$\\psi(a,y)$.\r\n\t\r\n\t\\qquad ($\\Rightarrow$) If $\\M,w \\models t$$:_{\\{a\\}}$$\\psi(a,y)$, then by definition $w \\in \\E^{*}(t, \\psi(a,y))$ and for every $w\\p \\in \\W$, if $w\\R w\\p$, then $\\M,w\\p \\models \\psi(a,b)$ for every $b \\in \\D$. By the induction hypothesis, for every $w\\p \\in \\W$, if $w\\R w\\p$, then $\\M^{*},w\\p \\models \\psi(a,b)$ for every $b \\in \\D$. Thus, $\\M^{*},w \\models t$$:_{\\{a\\}}$$\\psi(a,y)$.\r\n\t\r\n\t\\qquad ($\\Leftarrow$) If $\\M^{*},w \\models t$$:_{\\{a\\}}$$\\psi(a,y)$, then $w \\in \\E^{*}(t, \\psi(a,y))$. By definition, $\\M,w \\models t$$:_{\\{a\\}}$$\\psi(a,y)$. $\\Box$\\\\\r\n\t\r\n\t\r\n\t\\qquad By (+) we have that,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\E^{*}(t,\\varphi) = \\{w \\in \\W$ $|$ $ \\M,w \\models t$$:_{X}$$\\varphi\\} = \\{w \\in \\W$ $|$ $ \\M^{*},w \\models t$$:_{X}$$\\varphi\\}$\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Hence, $\\E^{*}$ is a strong evidence function and $\\M$ and $\\M^{*}$ agree on all $\\D$-formulas. Therefore, $\\M^{*}$ is a Fitting model for FOJT45 and $\\M$ and $\\M^{*}$ agree on all formulas.\r\n\\end{proof}\r\n\r\n\r\n\\qquad With this proposition we can construct non-validity examples similar to those presented in \\cite{Fitting14}.\r\n\r\n\\qquad \\textbf{Example 1:} the restriction on axiom \\textbf{A2} is needed. Take, for example, the formula $t$$:_{\\{x,y\\}}$$Qxy \\impli t$$:_{\\{x\\}}$$Qxy$; let $\\M =\\model$ be a Fitting model where:\r\n\\begin{itemize}\r\n\t\\item $\\W = \\{w_0, w_1\\}$;\r\n\t\\item $\\R = \\W \\times \\W$;\r\n\t\\item $\\D = \\{a, b\\}$;\r\n\t\\item $\\I(w_{0},Q) = \\I(w_{1},Q) = \\{\\bl a,b \\br\\}$;\r\n\t\\item $\\E(t,\\varphi) = \\W$, for every term $t$ and formula $\\varphi$.\r\n\\end{itemize}\r\n\r\n\r\n\\qquad Clearly, $\\M,w_0 \\models t$$:_{\\{a,b\\}}$$Qab$ and $\\M,w_0 \\nmodels t$$:_{\\{a\\}}$$Qay$. Hence, $\\M,w_0 \\nmodels t$$:_{\\{x,y\\}}$$Qxy \\impli t$$:_{\\{x\\}}$$Qxy$. By Proposition 19, $t$$:_{\\{x,y\\}}$$Qxy \\impli t$$:_{\\{x\\}}$$Qxy$ is not valid in every Fitting model for FOJT45.\r\n\r\n\r\n\\qquad \\textbf{Example 2:} The proviso of axiom \\textbf{B6} is necessary. Take, for example, the formula $t$$:_{\\{x\\}}$$Qx \\impli gen_{x}(t)$$:_{\\{x\\}}$$\\todo x Qx$; let $\\M =\\model$ be a Fitting model where:\r\n\\begin{itemize}\r\n\t\\item $\\W = \\{w_0\\}$;\r\n\t\\item $\\R = \\W \\times \\W$;\r\n\t\\item $\\D = \\{a,b\\}$;\r\n\t\\item $\\I(w_{0},Q) =  \\{a\\}$;\r\n\t\\item $\\E(t,\\varphi) = \\W$, for every term $t$ and formula $\\W$.\r\n\\end{itemize}\r\n\r\n\r\n\\qquad Clearly, $\\M,w_0 \\models t$$:_{\\{a\\}}$$Qa$ and since $\\M,w_0 \\nmodels Qb$, then $\\M,w_0 \\nmodels \\todo x Qx$, and so $\\M,w_0 \\nmodels gen_{x}(t)$$:_{\\{a\\}}$$\\todo x Qx$. Hence, $\\M,w \\nmodels t$$:_{\\{x\\}}$$Qx \\impli gen_{x}(t)$$:_{\\{x\\}}$$\\todo x Qx$. Again by Proposition 19, $t$$:_{\\{x\\}}$$Qx \\impli gen_{x}(t)$$:_{\\{x\\}}$$\\todo x Qx$ is not valid in every Fitting model for FOJT45.\r\n\r\n\\section{Soundness and Completeness}\r\n\r\n\\subsection{Soundness}\r\n\r\n\\begin{teor}\r\n\t(\\textit{Soundness}) Let $\\C$ be a constant specification. For every formula $\\varphi \\in \\Fj$, if $\\teo_{\\C} \\varphi$, then $\\models_{\\C}\\varphi$.\r\n\\end{teor}    \r\n\r\n\\begin{proof}\r\n\tThe proof is by induction on the theorems of the axiom system using the constant specification $\\C$. The argument is exactly the same as presented in \\cite[pp. 9-10]{Fitting14}. We are going to show validity for the specific axiom of FOJT45.\r\n\t\r\n\t\\qquad Suppose $\\varphi$ is an instance of \\textbf{B5}, i.e., $\\varphi$ is $\\nao t$$:_{X}$$\\psi \\impli$ $?t$$:_{X}$$\\nao t$$:_{X}$$\\psi$. For simplicity, assume $X= \\{x\\}$ and $\\psi = \\psi(x,y)$. So, we have that $\\teo_{\\C}\\nao t$$:_{\\{x\\}}$$\\psi(x,y) \\impli$ $?t$$:_{\\{x\\}}$$\\nao t$$:_{\\{x\\}}$$\\psi(x,y)$.\r\n\t\r\n\t\\qquad Let $\\M = \\model$ be a Fitting model for FOJT45 meeting $\\C$, $w \\in \\W$ and $a \\in \\D$. Suppose $\\M, w \\models \\nao t$$:_{\\{a\\}}$$\\psi(a,y)$. Then, $\\M, w \\nmodels t$$:_{\\{a\\}}$$\\psi(a,y)$. By the definition of the strong evidence function, $w \\notin \\E (t, \\psi(a,y))$. By the ? condition, $w \\in \\E(?t,\\nao t_{\\{a\\}}$$:\\psi(a,y))$. Again, by the strong evidence function $\\M, w \\models ?t$$:_{\\{a\\}}$$\\nao t$$:_{\\{a\\}}$$\\psi(a,y)$.\r\n\t\r\n\\end{proof}\r\n\r\n\r\n\\subsection{An obstacle in the proof of the Completeness Theorem}\r\n\r\n\\qquad There are two ways that we can prove the Completeness Theorem, one simple and the other more complex. Here we shall present the complex version. Although we are going to have much more work (if compared to the simple version) it is worthwhile because, we believe that \\textit{the methods that we are going to use in the next subsections can be used to prove the semantical version of the Realization Theorems for FOJT45} (in Chapter 6 we give a more detailed exposition of that theorem).   \r\n\r\n\\qquad The general strategy is the same as presented in \\cite[pp. 256-265]{Hughes96}. Let us just briefly comment on what is the obstacle that we find when trying to adapt the proof from the modal case to the justification case. In one step of the proof \\cite[pp. 259-260]{Hughes96} we need to establish the following: \\\\\r\n\r\n(+) There is an individual variable $y^{*}$ such that $\\Gamma^{\\#} \\cup \\{ \\gamma_{n} \\e (\\delta(y^{*}/ x) \\impli \\todo x \\delta) \\}$ is consistent,\\\\ \r\nwhere $\\Gamma^{\\#} = \\{\\varphi$ $|$ $\\Box \\varphi \\in \\Gamma\\}$ and $\\Gamma$ is a maximal consistent set. We begin proving (+) with the following argument. Suppose (+) is false.\r\n\r\n\\qquad (1) Then for every individual variable $y$,  $\\Gamma^{\\#} \\cup \\{ \\gamma_{n} \\e (\\delta(y/ x) \\impli \\todo x \\delta) \\}$ is inconsistent. Hence, for some $\\beta_{1}, \\dots, \\beta_{k} \\in \\Gamma^{\\#}$ we have that\r\n\r\n\\begin{center}\r\n\t$\\teo (\\beta_{1} \\e \\dots \\e \\beta_{k}) \\impli( \\gamma_{n} \\impli \\nao (\\delta(y/ x) \\impli \\todo x \\delta))$;\r\n\\end{center}\r\nby the usual reasoning in modal logic,\r\n\r\n\r\n\\begin{center}\r\n\t$\\teo (\\Box\\beta_{1} \\e \\dots \\e \\Box\\beta_{k}) \\impli\\Box( \\gamma_{n} \\impli \\nao (\\delta(y/ x) \\impli \\todo x \\delta))$\r\n\\end{center}\r\n\r\n\\qquad Since $\\Box\\beta_{1}, \\dots, \\Box\\beta_{k} \\in \\Gamma$, then $\\Box( \\gamma_{n} \\impli \\nao (\\delta(y/ x) \\impli \\todo x \\delta)) \\in \\Gamma$.\r\n\r\n\\qquad (2) It is assumed that $\\Gamma$ has the `$\\todo$-property', i.e., for every formula $\\varphi (x)$ there is an individual variable $y^{*}$ such that   $\\varphi(y^{*}/ x) \\impli \\todo x \\varphi \\in \\Gamma$.\r\n\r\n\\qquad Now, using these two facts we can conclude the following: let $z$ be a variable that does not occur in $\\gamma_{n}$ and $\\delta$. By (2), there is a variable $y^{*}$ such that\r\n\r\n\\begin{center}\r\n\t$\\Box(\\gamma_{n} \\impli \\nao (\\delta(y^{*}/ x) \\impli \\todo x \\delta)) \\impli \\todo z \\Box(\\gamma_{n} \\impli \\nao (\\delta(z/ x) \\impli \\todo x \\delta)) \\in \\Gamma$\r\n\\end{center}\r\n\r\n\\qquad And by (1) for the particular case when $y = y^{*}$,\r\n\r\n\r\n\\begin{center}\r\n\t$\\Box( \\gamma_{n} \\impli \\nao (\\delta(y^{*}/ x) \\impli \\todo x \\delta)) \\in \\Gamma$.\r\n\\end{center}\r\n\r\n\\qquad So, by the maximal consistency of $\\Gamma$ we can conclude that $\\todo z \\Box(\\gamma_{n} \\impli \\nao (\\delta(z/ x) \\impli \\todo x \\delta)) \\in \\Gamma$. The rest of the proof of (+) is not important for our point here.\r\n\r\n\\qquad The adaptation of this step for the first-order justification logic is problematic because \\textit{justification terms internalize Hilbert-style derivations}.\r\n\r\n\\qquad It should be noted that for two different individual variables $y$ and $y\\p$ if $\\Gamma^{\\#} \\cup \\{ \\gamma_{n} \\e (\\delta(y/ x) \\impli \\todo x \\delta) \\}$ and $\\Gamma^{\\#} \\cup \\{ \\gamma_{n} \\e (\\delta(y\\p/ x) \\impli \\todo x \\delta) \\}$ are inconsistent sets, then there are two finite subsets of $\\Gamma^{\\#}$, $\\{ \\beta_{1}, \\dots, \\beta_{k} \\}$ and $\\{ \\beta\\p_{1}, \\dots, \\beta\\p_{k\\p} \\}$ such that\r\n\r\n\r\n\\begin{center}\r\n\t$\\teo (\\beta_{1} \\e \\dots \\e \\beta_{k}) \\impli( \\gamma_{n} \\impli \\nao (\\delta(y/ x) \\impli \\todo x \\delta))$\\\\\r\n\t$\\teo (\\beta\\p_{1} \\e \\dots \\e \\beta\\p_{k\\p}) \\impli( \\gamma_{n} \\impli \\nao (\\delta(y\\p/ x) \\impli \\todo x \\delta))$\r\n\\end{center}\r\nand we cannot assume that $\\{ \\beta_{1}, \\dots, \\beta_{k} \\}=\\{ \\beta\\p_{1}, \\dots, \\beta\\p_{k\\p} \\}$. So, for each variable $y$ we may have a different derivation.\r\n\r\n\\qquad If we adopt the argument (1) for first-order justification logic we would have that for each individual variable $y$ \r\n\r\n\\begin{center}\r\n\t$t^{y}$$:_{X}$$( \\gamma_{n} \\impli \\nao (\\delta(y/ x) \\impli \\todo x \\delta)) \\in \\Gamma$,\r\n\\end{center}\r\nwhere $t^{y}$ is a term constructed by the Internalization Theorem, the axiom \\textbf{B2} and the fact that $\\Gamma^{\\#} \\cup \\{ \\gamma_{n} \\e (\\delta(y/ x) \\impli \\todo x \\delta) \\}$ is inconsistent. Hence, $t^{y}$ \\textit{depends on the individual variable} $y$. \r\n\r\n\\qquad Now, let us try to continue the argument. Let $z$ be a variable that does not occur in $\\gamma_{n}$ and $\\delta$. If we adapt (2) for justification logic, we would have that for every individual variable $y$ there is an individual variable $y^{*}$ such that\r\n\r\n\\begin{center}\r\n\t$t^{y}$$:_{X}$$(\\gamma_{n} \\impli \\nao (\\delta(y^{*}/ x) \\impli \\todo x \\delta)) \\impli \\todo z t^{y}$$:_{X}$$(\\gamma_{n} \\impli \\nao (\\delta(z/ x) \\impli \\todo x \\delta)) \\in \\Gamma$\r\n\\end{center}\r\n\r\n\r\n\\qquad But from this adapted version of (2) we cannot conclude that there is a variable $y^{*}$ such that\r\n\r\n\r\n\\begin{center}\r\n\t$t^{y^{*}}$$:_{X}$$(\\gamma_{n} \\impli \\nao (\\delta(y^{*}/ x) \\impli \\todo x \\delta)) \\impli \\todo z t^{y^{*}}$$:_{X}$$(\\gamma_{n} \\impli \\nao (\\delta(z/ x) \\impli \\todo x \\delta)) \\in \\Gamma$\r\n\\end{center}\r\n\r\n\\qquad  So  we cannot use (1) to conclude that $\\todo z t^{y^{*}}$$:_{X}$$(\\gamma_{n} \\impli \\nao (\\delta(z/ x) \\impli \\todo x \\delta)) \\in \\Gamma$.\r\n\r\n\r\n\\qquad  A way to remedy this problem is to make the `$\\todo$-property' stronger. If  $\\varphi(y^{*}/ x) \\impli \\todo x \\varphi \\in \\Gamma$ we say that $y^{*}$ instantiates the formula $\\todo x \\varphi$. We want that the same individual variable is used to simultaneously instantiate an infinite list of formulas of the same form. In order to guarantee this feature we are going to use the notion of \\textit{templates}. But in doing so we need to stablish some facts about templates. That makes the proof bigger than it should be, and that is why we divided the proof of the Completeness Theorem into different subsections.  \r\n\r\n\r\n\r\n\r\n\\subsection{Language extension}\r\n\r\n\\qquad The basic idea is to extend the language in order to prove a Henkin-style Completeness Theorem. Instead of using constants to construct our canonical model we shall add a new kind of variable called `witness variable'. We do that because when working with maximal consistent sets we need to be able to do formal derivations and so bind some witness variables.\r\n\r\n\r\n\r\n\\begin{defn}\r\n\tTwo formulas are \\textit{variable variants} provided each can be turned into the other by a uniform renaming of free individual variables, bound individual variables and labels of justification terms. We are always assuming that the renaming is safe, i.e., the new variables that are being introduced do not occur in the original formula.\r\n\\end{defn}\r\n\r\n\\begin{defn}\r\n\tA constant specification $\\C$ is \\textit{variant closed} iff whenever $\\varphi$ and $\\psi$ are variable variants, then $c$$:$$\\varphi \\in \\C$ iff $c$$:$$\\psi \\in \\C$.\r\n\\end{defn}\r\n\r\n\r\n\\begin{defn}\r\n\tFix a countable set \\textbf{V} $=\\{a_{0}, a_{1}, a_{2}, \\dots \\}$ of additional individual variables that are not in the original language. We define a new set of formulas $\\Fjv$ in the same fashion as $\\Fj$. It should be noted that variables of \\textbf{V} can be bound. We add every finite subset of $\\textbf{V}\\cup \\{x_{0}, x_{1}, \\dots \\}$ to the language; and for every $a \\in \\textbf{V}$ we add the justification operator $gen_{a}$.\\footnote{To be precise, we add $gen_{\\omega +i}$ for each $i \\in \\omega$. And we identify each operator $gen_{\\omega +i}$ with $a_{i}$.} It can be easily checked that $\\Fjv$ is a countable set.\r\n\t\r\n\\end{defn}\r\n\r\n\\qquad Until the end of this chapter we write `individual variables' to denote the members of $\\textbf{V}\\cup \\{x_{0}, x_{1}, \\dots \\}$, `basic variables' to denote the members of $\\{x_{0}, x_{1}, \\dots \\}$ and `witness variables' to denote the members of \\textbf{V}.\r\n\r\n\r\n\\qquad We are interested in using $\\textbf{V}$ as the domain $\\D$ of the canonical model, so from now on we shall call a $\\D$-formula a formula of $\\Fjv$ where the members of $\\textbf{V}$ \\textit{occur only free} (not bound, nor as labels of justification terms). And we say that a $\\D$-formula is closed if no basic variable occurrences are free.\r\n\r\n\r\n\r\n\\qquad Together with this new language we construct a new axiomatic system for FOJT45 based on the formulas from $\\Fjv$.\r\n\r\n\r\n\\begin{defn}\r\n\tLet $\\C$ be a variant closed constant specification for the basic system. $\\Cv$ is the smallest set satisfying the following:\r\n\t\r\n\t\\begin{itemize}\r\n\t\t\\item[] If $\\varphi \\in \\C$, $\\psi \\in \\Fjv$ and $\\varphi$ and $\\psi$ are variable variants, then $\\psi \\in \\Cv$.\r\n\t\\end{itemize}    \r\n\\end{defn}\r\n\r\n\r\n\r\n\\qquad From this definition we can make some observations:\r\n\\begin{itemize}\r\n\t\\item $\\C \\subseteq \\Cv$.\r\n\t\\item $\\Cv$ is variant closed.\r\n\t\\item If $\\C$ is axiomatically appropriate, then $\\Cv$ is axiomatically appropriate. \r\n\t\\item We can prove the Deduction Lemma, the Internalization Theorem, Propositions 17 and 18 for the new axiom system.\r\n\\end{itemize}\r\n\r\n\\begin{pro}\r\n\tLet $\\C$ be a variant closed constant specification for the basic system and $\\Cv$ its extension for $\\Fjv$. In these conditions, for every $\\varphi \\in \\Fj$, if $\\teocv \\varphi$, then $\\teoc \\varphi$. \r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\tLet $\\psi_{1}, \\psi_{2}, \\dots , \\psi_{n} = \\varphi$ be a FOJT45 proof in the language of $\\Fjv$ using $\\Cv$. Let $a_{1}, \\dots, a_{k}$ be all the witness variables that occur free, bound or as a label in the proof. Let $y_{1}, \\dots, y_{k}$ be basic variables that do not appear free, bound or as a label in the proof. And let $(\\psi_{i})^{-}$ be the result of replacing each $a_{j}$ with $y_{j}$ throughout.\r\n\t\r\n\t\\qquad We shall show that  $(\\psi_{1})^{-}, (\\psi_{2})^{-}, \\dots , (\\psi_{n})^{-}$ is a FOJT45 proof in the language of $\\Fj$ using $\\C$. And so $\\teoc (\\psi_{n})^{-}$, i.e., $\\teoc \\varphi$.  \r\n\t\r\n\t\\qquad If $\\psi_{i}$ is an axiom, since we are using axiom schemes and the introduced variables are new (to prevent that any proviso be violated), then $(\\psi_{i})^{-}$ is also an axiom.    \r\n\t\r\n\t\\qquad If $\\psi_{i}$ is a member of $\\Cv$, then there is a $\\phi \\in \\C$ such that $\\psi_{i}$ and $\\phi$ are variable variants. Now, $(\\psi_{i})^{-}$ and $\\phi$ may not be variable variants, because they may have some basic variable in common. But we can construct a formula $\\theta \\in \\Fj$ such that $\\theta$ has no variable in common with $(\\psi_{i})^{-}$ and $\\phi$, $\\theta$ and $(\\psi_{i})^{-}$ are variable variants, and $\\theta$ and $\\phi$ are variable variants. Since $\\phi \\in \\C$ and $\\C$ is variant close, $(\\psi_{i})^{-}\\in \\C$.    \r\n\t\r\n\t\\qquad If $\\psi_{i}$ is deduced from $\\psi_{i_1}$ and $\\psi_{i_2} = \\psi_{i_1}\\impli \\psi_{i}$ by modus ponens, then $(\\psi_{i_2})^{-}$ is $(\\psi_{i_1})^{-} \\impli (\\psi_{i})^{-}$. So $(\\psi_{i})^{-}$ also follows from $(\\psi_{i_2})^{-}$ and $(\\psi_{i_1})^{-}$ by modus ponens. \r\n\t\r\n\t\r\n\t\\qquad If $\\psi_{i}$ is deduced from $\\psi_{l}$ by generalization, then $\\psi_{i}$ is $\\todo x \\psi_{l}$. If $x$ is a basic variable, then $\\todo x (\\psi_{l})^{-}$ is deduced from $(\\psi_{l})^{-}$ by generalization. If $x = a_{j}$, then $\\todo y_{j} (\\psi_{l})^{-}$ is deduced from $(\\psi_{l})^{-}$ by generalization.    \r\n\t\r\n\\end{proof}\r\n\r\n\r\n\\begin{pro}\r\n\t(\\textit{Controlled Internalization}) Let $\\C$ be a constant specification variant closed and axiomatically appropriate, $\\Cv$ its expansion to $\\Fjv$ and $\\varphi \\in \\Fjv$. If $\\varphi$ is a $\\D$-formula and $\\teocv \\varphi$, then there is a justification term $t$ of $\\Fj$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teocv t$$:$$\\varphi$\r\n\t\\end{center}\r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\tLet $a_{1}, \\dots, a_{n}$ be the witness variables occurring free in $\\varphi$. So we can write $\\varphi$ as $\\varphi(a_{1}, \\dots, a_{n})$. Let $x_{1}, \\dots, x_{n}$ be basic variables that do not occur in the proof of $\\varphi(a_{1}, \\dots, a_{n})$. By an argument similar to the one presented in the proof of Proposition 20, we have that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teoc \\varphi(x_{1}, \\dots, x_{n})$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $\\C$ is axiomatically appropriated, by the Internalization Theorem there is a justification term $s$ of $\\Fj$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teoc s$$:$$\\varphi(x_{1}, \\dots, x_{n})$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Let `$gen_{\\vec{x}}(s)$' be the abreviation of `$gen_{x_{1}}(gen_{x_{2}} \\dots (gen_{x_{n}}(s)))$'. By repeated use of the axiom \\textbf{B6},\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teoc gen_{\\vec{x}}(s)$$:$$\\todo x_{1} \\dots \\todo x_{n} \\varphi(x_{1}, \\dots, x_{n})$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Now, since the axiom system in the language of $\\Fjv$ using $\\Cv$ is an extension of the basic axiom system using $\\C$, we have that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teocv gen_{\\vec{x}}(s)$$:$$\\todo x_{1} \\dots \\todo x_{n} \\varphi(x_{1}, \\dots, x_{n})$\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad By the fact that $\\Cv$ is axiomatically appropriate, we have that the following formulas are elements of $\\Cv$: \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$c_{1}$$:$$[\\todo x_{1} \\todo x_{2} \\dots \\todo x_{n} \\varphi(x_{1},x_{2}, \\dots, x_{n}) \\impli  \\todo x_{2} \\dots \\todo x_{n} \\varphi(a_{1},x_{2}, \\dots, x_{n}) ]$\\\\\r\n\t\t$c_{2}$$:$$[\\todo x_{2} \\todo x_{3} \\dots \\todo x_{n} \\varphi(a_{1},x_{2},x_{3}, \\dots, x_{n}) \\impli  \\todo x_{3} \\dots \\todo x_{n} \\varphi(a_{1},a_{2},x_{3}, \\dots, x_{n}) ]$\\\\\r\n\t\t$\\vdots$\\\\\r\n\t\t$c_{n}$$:$$[\\todo x_{n} \\varphi(a_{1}, \\dots, a_{n-1}, x_{n}) \\impli  \\varphi(a_{1}, \\dots, a_{n-1}, a_{n}) ]$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Hence, by repeated use of axiom \\textbf{B2} and modus ponens,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teocv [c_{n}\\cdot$ $\\dots$ $\\cdot [c_{1} \\cdot gen_{\\vec{x}}(s)]]$$:$$\\varphi(a_{1}, \\dots, a_{n})$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Take $t$ as $[c_{n}\\cdot$ $\\dots$ $\\cdot [c_{1} \\cdot gen_{\\vec{x}}(s)]]$. \r\n\\end{proof}\r\n\r\n\r\n\\qquad It should be noted that in the proofs of Proposition 17 and 18 we can use Proposition 21 in the place of the Internalization Theorem. So if $\\varphi(y)$ is a $\\D$-formula and $t$ is a term of $\\Fj$, then the terms constructed by Propositions 17 and 18 -- $CB(t)$, $B(t)$ and $s(t)$ -- are also justification terms of $\\Fj$.\r\n\r\n\r\n\r\n\r\n\r\n\\begin{defn}\r\n\tLet $\\C$ be a variant closed constant specification for the basic language and $\\Gamma \\subseteq \\Fj$. We say that $\\Gamma$ is $\\C$-\\textit{inconsistent} iff $\\Gamma \\teo_{\\C} \\bot$. By the Deduction Lemma, \r\n\t$\\Gamma$ is $\\C$-inconsistent iff there is a finite subset $\\{\\psi_{1}, \\dots, \\psi_{n}\\}$ of $\\Gamma$ such that $\\teo_{\\C} (\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\bot$. A set $\\Gamma$ is $\\C$-\\textit{consistent} if it is not $\\C$-inconsistent. And we say that $\\Gamma$ is $\\C$-\\textit{maximal consistent} whenever $\\Gamma$ is $\\C$-consistent and $\\Gamma$ has no proper extension that is $\\C$-consistent. We have similar notions for $\\C(\\textbf{V})$.\r\n\\end{defn}\r\n\r\n\\qquad It follows from Proposition 20 that for every set of basic formulas $\\Gamma$, if $\\Gamma$ is $\\C$-consistent, then $\\Gamma$ is $\\C(\\textbf{V})$-consistent.\r\n\r\n\r\n\r\n\\begin{pro}\r\n\t(\\textit{Lindenbaum})  Let $\\C$ be a constant specification variant closed and $\\Cv$ its extension. If $\\Gamma \\subseteq \\Fjv$ is $\\Cv$-consistent then there is a $\\Gamma\\p \\subseteq \\Fjv$ such\r\n\tthat $\\Gamma \\subseteq \\Gamma\\p$ and $\\Gamma\\p$ is a $\\Cv$-maximal consistent set.\r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\tA similar proof as the one from the classical case.\r\n\\end{proof}\r\n\r\n\r\n\\subsection{Templates}\r\n\r\n\r\n\\begin{defn} (Template vocabulary)    \r\n\t\\begin{itemize} \r\n\t\t\\item $\\tp_{0}$, $\\tp_{1}$, $\\tp_{2}$, $\\dots$ (\\textit{propositional variables});\r\n\t\t\\item $\\nao, \\ou, \\e $ (\\textit{boolean connectives});\r\n\t\t\\item $\\Box$ (\\textit{necessity});\r\n\t\t\\item $),($ (\\textit{parentheses}).\r\n\t\\end{itemize}\r\n\\end{defn}\r\n\r\n\r\n\r\n\\qquad We are going to use $\\tp$, $\\tq$ and $\\tr$ as meta-variables for propositional variables. Similarly, we write $\\tvp$ to denote a sequence of propositional variables.\r\n\r\n\\begin{defn} \r\n\tWe define the notions of \\textit{template} $F$ and the occurrence set of $F$, $occ(F)$, recursively as follows:\r\n\t\r\n\t\\begin{enumerate}[a)]\r\n\t\t\\item \r\n\t\t\\begin{itemize}\r\n\t\t\t\\item $\\tp$ is a template.\r\n\t\t\t\\item $occ(\\tp) = \\{ \\tp \\}$.\r\n\t\t\\end{itemize}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\\item \r\n\t\t\\begin{itemize}\r\n\t\t\t\\item If $F$ is a template, then $\\nao F$ is a template. \r\n\t\t\t\\item $occ(\\nao F) = occ(F)$.\r\n\t\t\\end{itemize}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\\item \r\n\t\t\\begin{itemize}\r\n\t\t\t\\item If $F$ and $G$ are templates and if  $occ(F)\\cap occ(G) =\\vazio$, then $F \\ou G$ is a template. \r\n\t\t\t\\item $occ(F\\ou G) = occ(F)\\cup occ(G)$.\r\n\t\t\\end{itemize}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\\item \r\n\t\t\\begin{itemize}\r\n\t\t\t\\item If $F$ and $G$ are templates and if  $occ(F)\\cap occ(G) =\\vazio$, then $F \\e G$ is a template. \r\n\t\t\t\\item $occ(F\\e G) = occ(F)\\cup occ(G)$.\r\n\t\t\\end{itemize}\r\n\t\t\r\n\t\t\r\n\t\t\\item \r\n\t\t\\begin{itemize}\r\n\t\t\t\\item If $F$ is a template, then $\\Box F$ is a template. \r\n\t\t\t\\item $occ(\\Box F) = occ(F)$.\r\n\t\t\\end{itemize}\r\n\t\t\r\n\t\\end{enumerate}\r\n\\end{defn}\r\n\r\n\r\n\\qquad Similarly as in the case when we work with formulas, we can define the notion of \\textit{complexity} of a template (the number of occurrences of boolean and modal connectives). So we shall define some notions recursively based on the complexity of templates  and prove some facts by induction on the complexity of templates.\r\n\r\n\r\n\\begin{defn} \r\n\tLet $\\tvp$ be an $n$-ary sequence of propositional variables, $\\vvarphi$ be an $n$-ary sequence of $\\D$-formulas and    $F(\\tvp)$ a template. We define the \\textit{instantiation set} $\\Arrowvert F(\\vvarphi) \\Arrowvert$ recursively as follows:\r\n\t\r\n\t\\begin{enumerate}[a)]\r\n\t\t\r\n\t\t\\item If $F(\\tvp)$ is $\\tp_{i}$, then $\\Arrowvert F(\\vvarphi) \\Arrowvert = \\{ \\varphi_{i}\\}$.\r\n\t\t\r\n\t\t\\item If $F(\\tvp)$ is $\\nao G(\\tvp)$, then  $\\Arrowvert F(\\vvarphi) \\Arrowvert = \\{ \\nao \\psi$ $|$ $\\psi \\in  \\Arrowvert G(\\vvarphi) \\Arrowvert   \\}$.\r\n\t\t\r\n\t\t\\item If $F(\\tvp)$ is $G(\\tvp) \\ou H(\\tvp)$, then  $\\Arrowvert F(\\vvarphi) \\Arrowvert = \\{ \\psi\\ou \\theta $ $|$ $\\psi \\in  \\Arrowvert G(\\vvarphi) \\Arrowvert$ and $\\theta \\in  \\Arrowvert H(\\vvarphi) \\Arrowvert  \\}$.\r\n\t\t\r\n\t\t\\item If $F(\\tvp)$ is $G(\\tvp) \\e H(\\tvp)$, then   $\\Arrowvert F(\\vvarphi) \\Arrowvert = \\{ \\psi\\e \\theta $ $|$ $\\psi \\in  \\Arrowvert G(\\vvarphi) \\Arrowvert$ and $\\theta \\in  \\Arrowvert H(\\vvarphi) \\Arrowvert  \\}$.\r\n\t\t\r\n\t\t\r\n\t\t\\item If $F(\\tvp)$ is  $\\Box G(\\tvp)$, then   $\\Arrowvert F(\\vvarphi) \\Arrowvert = \\{ t$$:_{X}$$\\psi$ $|$ $\\psi \\in  \\Arrowvert G(\\vvarphi) \\Arrowvert   \\}$; where $t$ is a justification term of $\\Fj$ and $X$ is the set of all witness variables occurring in $\\psi$.\r\n\t\\end{enumerate}\r\n\\end{defn}\r\n\r\n\\qquad Clearly, for every template $F(\\tvp)$ and every sequence $\\vvarphi$ of $\\D$-formulas, $\\Arrowvert F(\\vvarphi) \\Arrowvert$ is a set of $\\D$-formulas.  \r\n\r\n\r\n\\begin{defn}\r\n\tWe say that the template $F$ is \\textit{positive} if all the  boolean connectives that occur in $F$ are $\\e$ and $\\ou$. Similarly, we say that $F$ is \\textit{disjunctive} if all the boolean connectives that occur in $F$ are $\\ou$.           \r\n\\end{defn}\r\n\r\n\r\n\\qquad From now to the end of this subsection we shall prove some facts about templates. We are always assuming that there is a fixed constant specification variant closed and axiomatically appropriate $\\C$ for the basic language, and that $\\Cv$ is its extension. To make things simple, we will not refer to this assumption in every proposition and, in this subsection only, we shall write `$\\teo$' to denote `$\\teocv$', `consistent' to denote `$\\Cv$-consistent', `inconsistent' to denote `$\\Cv$-inconsistent' and `maximal-consistent' to denote `$\\Cv$-maximal consistent'.\r\n\r\n\r\n\r\n\\begin{pro}(\\textit{Semi-Replacement})\r\n\tLet $F(\\tvp,\\tq)$ be a positive template,  $\\varphi$ and $\\psi$ $\\D$-formulas, and $\\vvarphi$ a sequence of $\\D$-formulas. In these conditions, if $\\teo \\varphi \\impli \\psi$, then for every $\\phi \\in \\Arrowvert F(\\vvarphi,\\varphi) \\Arrowvert$ there is a $\\theta \\in \\Arrowvert F(\\vvarphi,\\psi) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\phi \\impli \\theta$\r\n\t\\end{center}    \r\n\\end{pro}\r\n\r\n\\begin{proof} (Induction on the complexity of $F(\\tvp,\\tq)$).\\\\\r\n\t\r\n\t\r\n\t($F(\\tvp,\\tq)$ is atomic)\\\\\r\n\t\r\n\t\\qquad i) $F(\\tvp,\\tq) = \\tp_{i}$. Then for any $\\phi \\in \\Arrowvert F(\\vvarphi,\\varphi) \\Arrowvert = \\{ \\varphi_{i}\\}$, $\\phi = \\varphi_{i}$. Since $\\varphi_{i} \\in  \\Arrowvert F(\\vvarphi,\\psi) \\Arrowvert = \\{ \\varphi_{i}\\}$, take $\\theta$ as $\\varphi_{i}$. \r\n\t\r\n\t\\qquad ii) $F(\\tvp,\\tq) = \\tq$. Then for any $\\phi \\in \\Arrowvert F(\\vvarphi,\\varphi) \\Arrowvert = \\{ \\varphi\\}$, $\\phi = \\varphi$. Since $\\psi \\in  \\Arrowvert F(\\vvarphi,\\psi) \\Arrowvert = \\{ \\psi\\}$, take $\\theta$ as $\\psi$. \\\\\r\n\t\r\n\t\r\n\t\r\n\t($F(\\tvp,\\tq)$ is $G(\\tvp, \\tq)\\ou H(\\tvp, \\tq)$)\\\\\r\n\t\r\n\t\\qquad Let $\\phi \\in \\Arrowvert F(\\vvarphi,\\varphi) \\Arrowvert$. So $\\phi$ is $\\phi\\p \\ou \\phi\\pp$ where  $\\phi\\p \\in \\Arrowvert G(\\vvarphi,\\varphi) \\Arrowvert$ and  $\\phi\\pp \\in \\Arrowvert H(\\vvarphi,\\varphi) \\Arrowvert$. By the induction hypothesis, there are $\\theta\\p \\in \\Arrowvert G(\\vvarphi,\\psi) \\Arrowvert$ and  $\\theta\\pp \\in \\Arrowvert H(\\vvarphi,\\psi) \\Arrowvert$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\phi\\p \\impli \\theta\\p$ and $\\teo \\phi\\pp \\impli \\theta\\pp$\r\n\t\\end{center}\r\nHence,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\phi\\p \\ou \\phi\\pp  \\impli \\theta\\p \\ou \\theta\\pp$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $\\theta\\p \\ou \\theta\\pp \\in \\Arrowvert F(\\vvarphi,\\psi) \\Arrowvert$, take $\\theta$ as $\\theta\\p \\ou \\theta\\pp$. \\\\\r\n\t\r\n\t\\qquad If $F(\\tvp,\\tq)$ is $G(\\tvp, \\tq)\\e H(\\tvp, \\tq)$, then the argument is similar to the previous one.\\\\\r\n\t\r\n\t($F(\\tvp,\\tq)$ is $\\Box G(\\tvp, \\tq)$)\\\\\r\n\t\r\n\t\r\n\t\\qquad Let $\\phi \\in \\Arrowvert F(\\vvarphi,\\varphi) \\Arrowvert$. So $\\phi$ is $t$$:_{X}$$\\phi\\p$ where $\\phi\\p \\in \\Arrowvert G(\\vvarphi,\\varphi) \\Arrowvert$. By the induction hypothesis, there is a $\\theta\\p \\in \\Arrowvert G(\\vvarphi,\\psi) \\Arrowvert$ such that $\\teo \\phi\\p \\impli \\theta\\p$. By Proposition 21, there is a justification term $s$ of $\\Fj$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s$$:$$(\\phi\\p \\impli \\theta\\p)$\r\n\t\\end{center}\r\nBy repeated use of axiom \\textbf{A3} and classical reasoning  \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s$$:_{X}$$(\\phi\\p \\impli \\theta\\p)$\r\n\t\\end{center}\r\nBy axiom \\textbf{B2} and modus ponens \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t$$:_{X}$$\\phi\\p \\impli [s\\cdot t]$$:_{X}$$ \\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Let $Y$ be the set of all witness variables that occur in $\\theta\\p$. By repeated use of axioms \\textbf{A2} and \\textbf{A3}, we have that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [s\\cdot t]$$:_{X}$$ \\theta\\p \\impli [s\\cdot t]$$:_{Y}$$ \\theta\\p$\r\n\t\\end{center} \r\nHence, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t$$:_{X}$$\\phi\\p \\impli [s\\cdot t]$$:_{Y}$$ \\theta\\p$.\r\n\t\\end{center} \r\n\t\r\n\t\\qquad Since $[s\\cdot t]$$:_{Y}$$ \\theta\\p \\in \\Arrowvert F(\\vvarphi,\\psi) \\Arrowvert$, take $\\theta$ as $[s\\cdot t]$$:_{Y}$$ \\theta\\p$.\r\n\t\r\n\\end{proof}\r\n\r\n\r\n\r\n\r\n\\begin{coro}(\\textit{Variable Change})\r\n\tLet $\\Gamma \\subseteq \\Fjv$, $F(\\tvp,\\tq)$ a positive template, $\\vvarphi$ a sequence of $\\D$-formulas, $\\todo x \\varphi(x)$ a $\\D$-formula, and $y$ a basic variable that does not occur free in $\\todo x \\varphi(x)$. In these conditions, if $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent, then $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo y\\varphi(y)) \\Arrowvert$ is consistent.     \r\n\\end{coro}\r\n\r\n\r\n\r\n\\begin{proof} Suppose that $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent and  $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo y\\varphi(y)) \\Arrowvert$ is inconsistent. Then, there are $\\psi_{1}, \\dots, \\psi_{n} \\in \\Arrowvert F(\\vvarphi,\\todo y\\varphi(y)) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma \\teo \\psi_{1} \\ou \\dots \\ou \\psi_{n}$\r\n\t\\end{center} \r\nBy classical logic,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y\\varphi(y) \\impli \\todo x\\varphi(x) $.\r\n\t\\end{center} \r\n\t\r\n\t\r\n\t\\qquad Hence by Proposition 23, for each $\\psi_{i}$ there is a $\\theta_{i} \\in  \\Arrowvert F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$\r\n\tsuch that     \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\psi_{i} \\impli \\theta_{i}$\r\n\t\\end{center} \r\nThus,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma \\teo \\theta_{1} \\ou \\dots \\ou \\theta_{n}$.\r\n\t\\end{center} \r\n\t\r\n\t\\qquad And since each $\\nao \\theta_{i} \\in  \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$, $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is inconsistent; a contradiction.\r\n\\end{proof}\r\n\r\n\\begin{pro}(\\textit{Vacuous Quantification})\r\n\tLet $F(\\tvp)$ be a disjunctive template, and $\\vvarphi$ a sequence of $\\D$-formulas none of which contain free occurrences of the basic variable $y$. In these conditions, for each $\\psi \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$ there is some $\\theta \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y\\psi \\impli \\theta$\r\n\t\\end{center}    \r\n\\end{pro}\r\n\r\n\\begin{proof} (Induction on the complexity of $F(\\tvp)$)\\\\\r\n\t\r\n\t\r\n\t($F(\\tvp)$ is $\\tp_{i}$)\\\\\r\n\t\r\n\t\\qquad  For each $\\psi \\in \\Arrowvert F(\\vvarphi) \\Arrowvert =\\{ \\varphi_{i}  \\}$,  $\\psi = \\varphi_{i}$. Since $y$ does not occur free in $\\varphi_{i}$, $\\teo \\ex y\\varphi_{i} \\impli \\varphi_{i}$. We can take $\\theta$ as $\\varphi_{i}$.\\\\\r\n\t\r\n\t($F(\\tvp)$ is $G(\\tvp)\\ou H(\\tvp)$)\\\\\r\n\t\r\n\t\\qquad Let $\\psi \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$. So $\\psi$ is $\\psi\\p \\ou \\psi\\pp$ where  $\\psi\\p \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ and  $\\psi\\pp \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$. By the induction hypothesis, there are $\\theta\\p \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ and  $\\theta\\pp \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y \\psi\\p \\impli \\theta\\p$ and $\\teo \\ex y\\psi\\pp \\impli \\theta\\pp$\r\n\t\\end{center}    \r\nBy classical logic,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y (\\psi\\p \\ou \\psi\\pp) \\see  (\\ex y\\psi\\p \\ou \\ex y\\psi\\pp)$\r\n\t\\end{center}     \r\nHence,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y (\\psi\\p \\ou \\psi\\pp) \\impli \\theta\\p \\ou \\theta\\pp$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Since $\\theta\\p \\ou \\theta\\pp \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$, take $\\theta$ as $\\theta\\p \\ou \\theta\\pp$.\\\\\r\n\t\r\n\t\r\n\t\r\n\t($F(\\tvp)$ is $\\Box G(\\tvp)$)\\\\\r\n\t\r\n\t\r\n\t\\qquad Let $\\psi \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$. So $\\psi$ is $t$$:_{X}$$\\phi$ where $\\phi \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$. By the axiom \\textbf{A3}, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t$$:_{X}$$\\phi \\impli t$$:_{Xy}$$\\phi$\r\n\t\\end{center}\r\nBy classical logic,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y t$$:_{X}$$\\phi \\impli \\ex y t$$:_{Xy}$$\\phi$.\r\n\t\\end{center}     \r\n\t\r\n\t\\qquad By definition, $X$ is a set of witness variables and since $y$ is a basic variable we have that $y \\notin X$; so by Proposition 18,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y t$$:_{Xy}$$\\phi \\impli s(t)$$:_{X}$$\\ex y \\phi$\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\r\n\t\\qquad By induction hypothesis, there is a $\\theta\\p \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ such that $\\teo \\ex y \\phi \\impli \\theta\\p$. By Proposition 21 and by the axiom \\textbf{A3}, there is a justification term $s\\p$ of $\\Fj$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s\\p$$:_{X}$$(\\ex y \\phi \\impli \\theta\\p)$\r\n\t\\end{center}    \r\nBy axiom \\textbf{B2},    \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s(t)$$:_{X}$$\\ex y \\phi \\impli [s\\p \\cdot s(t)]$$:_{X}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Let $Y$ be the set of all witness variables that occur in $\\theta\\p$. By repeated use of axioms \\textbf{A2} and \\textbf{A3}, we have that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [s\\p \\cdot s(t)]$$:_{X}$$\\theta\\p \\impli  [s\\p \\cdot s(t)]$$:_{Y}$$\\theta\\p$\r\n\t\\end{center} \r\nHence, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\ex y t$$:_{X}$$\\phi \\impli [s\\p \\cdot s(t)]$$:_{Y}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Since $[s\\p \\cdot s(t)]$$:_{Y}$$\\theta\\p \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$, take $\\theta$ as $[s\\p \\cdot s(t)]$$:_{Y}$$\\theta\\p$.\\\\    \r\n\t\r\n\\end{proof}\r\n\r\n\r\n\\begin{pro}(\\textit{Generalized Barcan})\r\n\tLet $F(\\tvp,\\tq)$ be a disjunctive template, $y$ a basic variable, $\\varphi(y)$ a $\\D$-formula, and  $\\vvarphi$ a sequence of $\\D$-formulas none of which contain free occurrences of $y$. In these conditions, for each $\\psi \\in \\Arrowvert F(\\vvarphi,\\varphi(y)) \\Arrowvert$ there is some $\\theta \\in \\Arrowvert F(\\vvarphi,\\todo y \\varphi(y)) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y\\psi \\impli \\theta$\r\n\t\\end{center}    \r\n\\end{pro}\r\n\r\n\\begin{proof} (Induction on the complexity of $F(\\tvp,\\tq)$)\\\\\r\n\t\r\n\t\\qquad If $F(\\tvp,\\tq)$ is atomic, then the result is trivial.\\\\\r\n\t\r\n\t($F(\\tvp,\\tq)$ is $G(\\tvp,\\tq)\\ou H(\\tvp,\\tq)$)\\\\\r\n\t\r\n\t\r\n\t\\qquad By the definition of template, the propositional variable $\\tq$ can occur at most once in $F(\\tvp,\\tq)$. So either it does not occur in $G(\\tvp,\\tq)$ or it does not occur in  $H(\\tvp,\\tq)$. Assume that it does not occur in $H(\\tvp,\\tq)$ (the other case is symmetric); then we can assume that $H(\\tvp,\\tq)$ is $H(\\tvp)$.    \r\n\t\r\n\t\\qquad Let $\\psi \\in \\Arrowvert F(\\vvarphi,\\varphi(y)) \\Arrowvert$. So $\\psi$ is $\\phi\\p \\ou \\phi\\pp$ where  $\\phi\\p \\in \\Arrowvert G(\\vvarphi,\\varphi(y)) \\Arrowvert$ and  $\\phi\\pp \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$. By classical logic, we have that \r\n\t\r\n\t\\begin{center}    \r\n\t\t$\\teo \\todo y (\\phi\\p \\ou \\phi\\pp) \\impli (\\todo y \\phi\\p \\ou \\ex y \\phi\\pp)$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $y$ does not occur free in any formula of $\\vvarphi$, then by Proposition 24 there is some $\\theta\\pp \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$ such that \r\n\t\r\n\t\r\n\t\\begin{center}    \r\n\t\t$\\teo \\ex y \\phi\\pp \\impli \\theta\\pp$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad By the induction hypothesis, there is $\\theta\\p \\in \\Arrowvert G(\\vvarphi,\\todo y \\varphi (y)) \\Arrowvert$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y \\psi\\p \\impli \\theta\\p$ \r\n\t\\end{center}    \r\nHence,    \r\n\t\r\n\t\\begin{center}    \r\n\t\t$\\teo \\todo y (\\phi\\p \\ou \\phi\\pp) \\impli \\theta\\p \\ou \\theta\\pp$.\r\n\t\\end{center}    \r\n\t\r\n\t\r\n\t\\qquad And so we can take $\\theta$ as $\\theta\\p \\ou \\theta\\pp$.    \\\\\r\n\t\r\n\t\r\n\t($F(\\tvp,\\tq)$ is $\\Box G(\\tvp,\\tq)$)\\\\\r\n\t\r\n\t\\qquad Let $\\psi \\in \\Arrowvert F(\\vvarphi, \\varphi(y)) \\Arrowvert$. So $\\psi$ is $t$$:_{X}$$\\phi$ where $\\phi \\in \\Arrowvert G(\\vvarphi,\\varphi(y)) \\Arrowvert$. By definition, $X$ is a set of witness variables, then $y \\notin X$. So, by Proposition 17 \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y t$$:_{Xy}$$\\phi \\impli B(t)$$:_{X}$$\\todo y \\phi$\r\n\t\\end{center}\r\nBy axiom \\textbf{A3},\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t$$:_{X}$$\\phi \\impli t$$:_{Xy}$$\\phi$\r\n\t\\end{center}\r\nBy classical logic,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y t$$:_{X}$$\\phi \\impli \\todo y t$$:_{Xy}$$\\phi$\r\n\t\\end{center}\r\nSo,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y t$$:_{X}$$\\phi \\impli B(t)$$:_{X}$$\\todo y \\phi$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad By the induction hypothesis, there is a $\\theta\\p \\in \\Arrowvert G(\\vvarphi, \\todo y \\varphi(y)) \\Arrowvert$ such that $\\teo \\todo y \\phi \\impli \\theta\\p$. By Proposition 21 and by the axiom \\textbf{A3}, there is a justification term $s$ of $\\Fj$ such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s$$:_{X}$$(\\todo y \\phi \\impli \\theta\\p)$\r\n\t\\end{center}    \r\nBy axiom \\textbf{B2},    \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo B(t)$$:_{X}$$\\todo y \\phi \\impli [s \\cdot B(t)]$$:_{X}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Let $Y$ be the set of all witness variables that occur in $\\theta\\p$. By repeated use of axioms \\textbf{A2} and \\textbf{A3}, we have that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [s \\cdot B(t)]$$:_{X}$$\\theta\\p \\impli  [s \\cdot B(t)]$$:_{Y}$$\\theta\\p$\r\n\t\\end{center} \r\nHence, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y t$$:_{X}$$\\phi \\impli [s \\cdot B(t)]$$:_{Y}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Take $\\theta$ as $[s \\cdot B(t)]$$:_{Y}$$\\theta\\p$.\\\\    \r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\\end{proof}\r\n\r\n\r\n\\begin{pro}(\\textit{Formula Combining}) Let $F(\\tvp)$ be a disjunctive template, and $\\vvarphi$ a sequence of $\\D$-formulas. In these conditions, for any $\\psi_{1}, \\dots, \\psi_{k}  \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$ there is some formula $\\theta \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\psi_{1} \\ou \\dots \\ou \\psi_{k}) \\impli \\theta$\r\n\t\\end{center}    \r\n\\end{pro}\r\n\r\n\\begin{proof} (Induction on the complexity of $F(\\tvp)$.)\\\\\r\n\t\r\n\t\\qquad If $F(\\tvp)$ is atomic, then the result is trivial.\\\\\r\n\t\r\n\r\n\t\r\n\t($F(\\tvp)$ is $G(\\tvp)\\ou H(\\tvp)$)\\\\\r\n\t\r\n\t\\qquad Let $\\psi_{1}, \\dots, \\psi_{k} \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$. So there are $\\phi_{1}^{\\p}, \\dots, \\phi_{k}^{\\p} \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ and  $\\phi_{1}^{\\pp}, \\dots, \\phi_{k}^{\\pp} \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$, such that $\\psi_{i} = \\phi_{i}^{\\p} \\ou \\phi_{i}^{\\pp}$. By the induction hypothesis, there are $\\theta^{\\p} \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ and $\\theta^{\\pp} \\in \\Arrowvert H(\\vvarphi) \\Arrowvert$ such that  \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\phi_{1}^{\\p} \\ou \\dots \\ou \\phi_{k}^{\\p}) \\impli \\theta\\p$\\\\\r\n\t\t$\\teo (\\phi_{1}^{\\pp} \\ou \\dots \\ou \\phi_{k}^{\\pp}) \\impli \\theta\\pp$\r\n\t\\end{center}\r\nHence, \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo ((\\phi_{1}^{\\p} \\ou \\dots \\ou \\phi_{k}^{\\p}) \\ou (\\phi_{1}^{\\pp} \\ou \\dots \\ou \\phi_{k}^{\\pp})) \\impli \\theta\\p \\ou \\theta\\pp$\r\n\t\\end{center}\r\nAnd so, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo ((\\phi_{1}^{\\p} \\ou \\phi_{1}^{\\pp})  \\ou \\dots \\ou (\\phi_{k}^{\\p} \\ou \\phi_{k}^{\\pp}))  \\impli \\theta\\p \\ou \\theta\\pp$\r\n\t\\end{center}\r\ni.e.,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\psi_{1} \\ou \\dots \\ou \\psi_{k}) \\impli \\theta\\p \\ou \\theta\\pp$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Take $\\theta$ as $\\theta\\p \\ou \\theta\\pp$.\\\\    \r\n\t\r\n\\pagebreak\r\n\t\r\n\t($F(\\tvp)$ is $\\Box G(\\tvp)$)\\\\    \r\n\t\r\n\t\\qquad Let $\\psi_{1}, \\dots, \\psi_{k} \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$. So there are justification terms $t_{1}, \\dots, t_{k}$ and $\\phi_{1}, \\dots, \\phi_{k} \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ such that $\\psi_{i} =     t_{i}$$:_{X_{i}}$$\\phi_{i}$.\r\n\tBy the induction hypothesis, there is $\\theta^{\\p} \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ such that  \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\phi_{1} \\ou \\dots \\ou \\phi_{k}) \\impli \\theta\\p$\\\r\n\t\\end{center}\r\nHence, by classical reasoning, for each $i$,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\phi_{i} \\impli \\theta\\p$\\\r\n\t\\end{center}\r\n\t\r\n\\qquad So, by Proposition 21 and by the axiom \\textbf{A3} there are  justification terms $s_{1}, \\dots, s_{k}$ of $\\Fj$ such that for each $i$,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s_{i}$$:_{X_{i}}$$(\\phi_{i} \\impli \\theta\\p)$\\\r\n\t\\end{center}\r\nBy axiom \\textbf{B2},\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t_{i}$$:_{X_{i}}$$\\phi_{i}  \\impli [s_{i} \\cdot t_{i}]$$:_{X_{i}}$$\\theta\\p$\\\r\n\t\\end{center}\r\nBy an appropriate use of axiom \\textbf{B3}, we have that for each $i$, \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [s_{i} \\cdot t_{i}]$$:_{X_{i}}$$\\theta\\p  \\impli [[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{X_{i}}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Let $Y$ be the set of all witness variables that occur in $\\theta\\p$. By repeated use of axioms \\textbf{A2} and \\textbf{A3}, we have that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{X_{i}}$$\\theta\\p  \\impli [[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{Y}$$\\theta\\p$\r\n\t\\end{center}\r\nHence, for each $i$, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t_{i}$$:_{X_{i}}$$\\phi_{i}  \\impli  [[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{Y}$$\\theta\\p$\r\n\t\\end{center}\r\nSo,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (t_{1}$$:_{X_{1}}$$\\phi_{1} \\ou \\dots \\ou t_{k}$$:_{X_{k}}$$\\phi_{k} )   \\impli  [[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{Y}$$\\theta\\p$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $[[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{Y}$$\\theta\\p \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$, we can take $\\theta$ as $[[s_{1} \\cdot t_{1}] +$ $\\dots$ $+ [s_{k} \\cdot t_{k}]]$$:_{Y}$$\\theta\\p$.\r\n\\end{proof}\r\n\r\n\\begin{pro}(\\textit{Existential Instantiation})\r\n\tLet $F(\\tvp,\\tq)$ be a disjunctive template, $\\Gamma \\subseteq \\Fj$, $\\vvarphi$ a sequence of $\\D$-formulas,  $\\todo x \\varphi(x)$ a $\\D$-formula, and $a$ a witness variable that does not occur free in $\\todo x \\varphi(x)$ and in any member of $\\vvarphi$. In these conditions, if $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent, then $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\varphi(a)) \\Arrowvert$ is consistent.    \r\n\\end{pro}\r\n\r\n\\begin{proof} \r\n\tSuppose that  $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent and $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\varphi(a)) \\Arrowvert$ is inconsistent.  Then, there are $\\psi_{1}, \\dots, \\psi_{n} \\in \\Gamma$ and $\\nao \\phi_{1}(a), \\dots, \\nao \\phi_{k}(a) \\in \\Arrowvert \\nao F(\\vvarphi,\\varphi(a)) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\e (\\nao \\phi_{1}(a) \\e \\dots \\e \\nao \\phi_{k}(a)) \\impli \\bot$\r\n\t\\end{center} \r\nHence,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli (\\phi_{1}(a) \\ou \\dots \\ou \\phi_{k}(a))$.\r\n\t\\end{center} \r\n\t\r\n\t\r\n\\qquad By Proposition 26 there is a $\\psi(a) \\in \\Arrowvert F(\\vvarphi,\\varphi(a)) \\Arrowvert$, such that\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\phi_{1}(a) \\ou \\dots \\ou \\phi_{k}(a)) \\impli \\psi(a)$\r\n\t\\end{center} \r\nHence,\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(a)$\r\n\t\\end{center}\r\nBy generalization (remember, $a$ is a variable in the new language),\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo a [(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(a)]$.\r\n\t\\end{center}\r\n\t\r\n\\qquad Let $y$ be a basic variable that does not occur in $\\psi_{1}, \\dots,\\psi_{n}$, $\\todo x \\varphi (x)$, $\\vvarphi$, $\\varphi (a)$ and $\\psi(a)$. By classical logic,  \r\n\t\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo a [(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(a)] \\impli [(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(a)](y/a)$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $\\Gamma$ is a set of basic formulas, $a$ does not occur in any formula of $\\Gamma$; in particular, $a$ does not occur in any $\\psi_{i}$. Hence $[(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(a)](y/a)$ is $(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(y)$. So, by modus ponens and generalization, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y [(\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\psi(y)]$.\r\n\t\\end{center}\r\n\t\r\n\r\n\t\\qquad Since $y$ does not occur in any $\\psi_{i}$, by classical reasoning,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\psi_{1} \\e \\dots \\e \\psi_{n}) \\impli \\todo y \\psi(y)$\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Since $a$ does not occur free in any formula of $\\vvarphi$, it can be easily checked that for every formula $\\psi(a)$,\r\n\t\r\n\t\\begin{center}\r\n\t\tIf $\\psi(a) \\in \\Arrowvert F(\\vvarphi,\\varphi(a)) \\Arrowvert$, then $\\psi(y) \\in \\Arrowvert F(\\vvarphi,\\varphi(y)) \\Arrowvert$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad By this fact, we have that $\\psi(y) \\in \\Arrowvert F(\\vvarphi,\\varphi(y)) \\Arrowvert$. Now since $y$ does not occur in $\\vvarphi$, then by Proposition 25 there is a $\\theta \\in \\Arrowvert F(\\vvarphi,\\todo y \\varphi(y)) \\Arrowvert$ such that\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo y\\psi \\impli \\theta$\r\n\t\\end{center}\r\nThus,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo  (\\psi_{1} \\e \\dots \\e \\psi_{n})  \\impli \\theta$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Since $\\nao\\theta \\in \\Arrowvert \\nao F(\\vvarphi,\\todo y \\varphi(y)) \\Arrowvert$, it follows that $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo y\\varphi(y)) \\Arrowvert$ is inconsistent. By Corollary 1, $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is inconsistent, a contradiction.\r\n\\end{proof}\r\n\r\n\r\n\\begin{defn}\r\n\tIf $\\Gamma \\subseteq \\Fjv$, then let $\\Gamma^{\\#}$ be the set of all formulas $\\todo \\vec{y} \\varphi$ such that $t$$:_{X}$$\\varphi \\in \\Gamma$, where $t$$:_{X}$$\\varphi$ is a closed $\\D$-formula with $X$ being the set of witness variables in $\\varphi$, and $\\vec{y}$ are the free  basic variables of $\\varphi$. \r\n\\end{defn}\r\n\r\n\\begin{pro}\\textit{(Up and Down Consistency})\r\n\tLet $F(\\tvp) = \\Box G(\\tvp)$ be a template, $\\Gamma \\subseteq \\Fjv$,  and $\\vvarphi$ a sequence of $\\D$-formulas.\r\n\t\r\n\t\\begin{enumerate}[1)]\r\n\t\t\\item Suppose $\\Gamma$ is maximal consistent. In these conditions, if $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\vvarphi) \\Arrowvert$ is consistent, then  $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ is consistent.\r\n\t\t\\item Suppose $G(\\tvp)$ is a disjunctive template. In these conditions,  if $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ is consistent, then  $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\vvarphi) \\Arrowvert$ is consistent.\r\n\t\\end{enumerate}    \r\n\\end{pro}\r\n\r\n\\begin{proof} \r\n\t\r\n\t1) Suppose $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\vvarphi) \\Arrowvert$ is consistent and  $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ is inconsistent. Then, for some $\\nao t_{1}$$:_{X_{1}}$$\\theta_{1}, \\dots,  \\nao t_{k}$$:_{X_{k}}$$\\theta_{k} \\in  \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ (where $\\theta_{1}, \\dots, \\theta_{k} \\in  \\Arrowvert  G(\\vvarphi) \\Arrowvert$)\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma \\teo (\\nao t_{1}$$:_{X_{1}}$$\\theta_{1} \\e \\dots \\e  \\nao t_{k}$$:_{X_{k}}$$\\theta_{k}) \\impli \\bot $\r\n\t\\end{center}    \r\nHence,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma \\teo t_{1}$$:_{X_{1}}$$\\theta_{1} \\ou \\dots \\ou   t_{k}$$:_{X_{k}}$$\\theta_{k}$.\r\n\t\\end{center}        \r\n\t\r\n\t\r\n\\qquad Now, since $\\Gamma$ is maximal consistent set, for some $i$, $t_{i}$$:_{X_{i}}$$\\theta_{i} \\in \\Gamma$. And since $t_{i}$$:_{X_{i}}$$\\theta_{i}$ is a closed $\\D$-formula, $\\todo \\vec{x} \\theta_{i} \\in \\Gamma^{\\#}$. By classical logic, \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\nao \\theta_{i} \\impli \\nao \\todo \\vec{x} \\theta_{i}$\r\n\t\\end{center}        \r\n\t\r\n\\qquad Since $\\nao \\theta_{i} \\in \\Arrowvert  \\nao G(\\vvarphi) \\Arrowvert$, we have that  $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\vvarphi) \\Arrowvert$ is inconsistent, a contradiction.\\\\\r\n\t\r\n\t\r\n\\qquad 2) Suppose $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ is consistent and $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\vvarphi) \\Arrowvert$ is inconsistent. Then, there are $\\todo \\vec{x}_{1} \\psi_{1}, \\dots, \\todo \\vec{x}_{n} \\psi_{n} \\in \\Gamma^{\\#}$ (where $t_{1}$$:_{X_{1}}$$\\psi_{1}, \\dots,  t_{n}$$:_{X_{n}}$$\\psi_{n} \\in  \\Gamma$) and $\\nao \\theta_{1}, \\dots, \\nao \\theta_{k} \\in \\Arrowvert  \\nao G(\\vvarphi) \\Arrowvert$ such that\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\todo \\vec{x}_{1} \\psi_{1} \\e \\dots \\e \\todo \\vec{x}_{n} \\psi_{n}) \\e  (\\nao \\theta_{1}\\e \\dots \\e \\nao \\theta_{k}) \\impli \\bot $\r\n\t\\end{center}\r\nSo,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\todo \\vec{x}_{1} \\psi_{1} \\e \\dots \\e \\todo \\vec{x}_{n} \\psi_{n}) \\impli  (\\theta_{1} \\ou \\dots \\ou  \\theta_{k})$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Since $\\theta_{1}, \\dots, \\theta_{k} \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ and $G(\\tvp)$ is a disjunctive template, then by Proposition 26 there is a $\\theta \\in \\Arrowvert G(\\vvarphi) \\Arrowvert$ such that \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (\\theta_{1} \\ou \\dots \\ou  \\theta_{k}) \\impli \\theta$\r\n\t\\end{center}\r\nBy classical logic,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo \\todo \\vec{x}_{1} \\psi_{1} \\impli \\dots \\impli \\todo \\vec{x}_{n} \\psi_{n} \\impli  \\theta$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Now, for each $i$ any member of the sequence $\\vec{x}_{i}$ does not occur in the set $X_{i}$ (the set $X_{i}$ is a set of witness variables). So, by repeated use of axiom \\textbf{B6} we have that for each $i$\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t_{i}$$:_{X_{i}}$$\\psi_{i}\\impli gen_{\\vec{x}_{i}}(t)$$:_{X_{i}}$$\\todo \\vec{x}\\psi_{i}$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad It should be noted that `$gen_{\\vec{x}_{i}}(t)$' is not a justification term, it is just an abbreviation that we use to help readability. Let $X = X_{1}\\cup$ $\\dots$ $\\cup X_{n}$, by axiom \\textbf{A3},\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo t_{i}$$:_{X_{i}}$$\\psi_{i}\\impli gen_{\\vec{x}_{i}}(t)$$:_{X}$$\\todo \\vec{x}\\psi_{i}$\r\n\t\\end{center}\r\n\t\r\n\t\\qquad By Proposition 21 and axiom \\textbf{A3} there is a justification term $s$ of $\\Fj$ such that \r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo s$$:_{X}$$(\\todo \\vec{x}_{1} \\psi_{1} \\impli \\dots \\impli \\todo \\vec{x}_{n} \\psi_{n} \\impli  \\theta)$\r\n\t\\end{center}\r\nAnd by repeated use of axiom \\textbf{B2}\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo gen_{\\vec{x}_{1}}(t)$$:_{X}$$\\todo \\vec{x}\\psi_{1}\\impli \\dots \\impli gen_{\\vec{x}_{n}}(t)$$:_{X}$$\\todo \\vec{x}\\psi_{n}\\impli  [s\\cdot gen_{\\vec{x}_{1}}(t) \\cdot$ $\\dots$ $\\cdot gen_{\\vec{x}_{n}}(t) ]$$:_{X}$$\\theta$.\r\n\t\\end{center}\r\n\t\r\n\t\\qquad Let $Y$ be the set of all witness variables of $\\theta$; by axioms \\textbf{A2} and \\textbf{A3}\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo [s\\cdot gen_{\\vec{x}_{1}}(t) \\cdot$ $\\dots$ $\\cdot gen_{\\vec{x}_{n}}(t) ]$$:_{X}$$\\theta \\impli  [s\\cdot gen_{\\vec{x}_{1}}(t) \\cdot$ $\\dots$ $\\cdot gen_{\\vec{x}_{n}}(t) ]$$:_{Y}$$\\theta$\r\n\t\\end{center}\r\nBy classical reasoning,\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\teo (t_{1}$$:_{X_{1}}$$\\psi_{1} \\e \\dots \\e t_{n}$$:_{X_{n}}$$\\psi_{n}) \\impli  [s\\cdot gen_{\\vec{x}_{1}}(t) \\cdot$ $\\dots$ $\\cdot gen_{\\vec{x}_{n}}(t) ]$$:_{Y}$$\\theta$.\r\n\t\\end{center}\r\n\t\r\n\t\r\n\t\\qquad Since each $t_{i}$$:_{X_{i}}$$\\psi_{i} \\in \\Gamma$ and $[s\\cdot gen_{\\vec{x}_{1}}(t) \\cdot$ $\\dots$ $\\cdot gen_{\\vec{x}_{n}}(t) ]$$:_{Y}$$\\theta \\in \\Arrowvert F(\\vvarphi) \\Arrowvert$ we have that $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ is inconsistent; a contradiction.\r\n\\end{proof}\r\n\r\n\r\n\r\n\\begin{defn}  \r\n\tA set of formulas $\\Gamma$ \\textit{admits instantiation} provided for each disjunctive template $F(\\tvp,\\tq)$, for each sequence $\\vvarphi$ of $\\D$-formulas, and each universally quantified $\\D$-formula $\\todo x \\varphi (x)$, if $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent, then for some witness variable $a$, $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi,\\varphi(a)) \\Arrowvert$ is consistent.\\footnote{This is the stronger version of the `$\\todo$-property' that we mentioned in subsection 5.4.2.}   \r\n\\end{defn}\r\n\r\n\r\n\r\n\\begin{pro}\r\n\tSuppose $\\Gamma$ is maximal consistent and $\\Gamma$ admits instantiation. For every $\\D$-formula $\\todo x \\varphi(x)$, if $\\nao \\todo x \\varphi(x) \\in \\Gamma$, then there is a witness variable $a$ such that $\\nao \\varphi(a) \\in \\Gamma$.          \r\n\\end{pro}\r\n\r\n\r\n\\begin{proof} \r\n\t\r\n\tIf $\\nao \\todo x \\varphi (x) \\in \\Gamma $, then $S\\cup \\{ \\nao \\todo x \\varphi (x) \\}$ is consistent. Let $\\tq$ be a propositional letter; $F(\\tq) =\\tq$ is a disjunctive template. Since $\\Arrowvert \\nao F(\\todo x\\varphi(x)) \\Arrowvert=  \\{ \\nao \\todo x \\varphi (x) \\}$, then  $\\Gamma \\cup \\Arrowvert \\nao F(\\todo x\\varphi(x)) \\Arrowvert$ is consistent. Since $\\Gamma$ admits instantiation, there is a witness variable $a$ such that $\\Gamma \\cup \\Arrowvert \\nao F(\\varphi(a)) \\Arrowvert$ is consistent, i.e., $\\Gamma \\cup  \\{ \\nao \\varphi (a) \\}$ is consistent. By the maximality of $\\Gamma$, $ \\nao \\varphi(a) \\in \\Gamma$. \r\n\t\r\n\\end{proof}\r\n\r\n\r\n\\begin{pro}Let $\\Gamma \\subseteq \\Fjv$. If $\\Gamma$ is maximal consistent and admits instantiation, then $\\Gamma^{\\#}$ also admits instantiation.\r\n\\end{pro}\r\n\r\n\\begin{proof} \r\n\tSuppose $\\Gamma$ is maximal consistent, $\\Gamma$ admits instantiation, $F(\\tvp, \\tq)$ is a disjunctive template, $\\vvarphi$ is a sequence of $\\D$-formulas, $\\todo x \\varphi(x)$ is a $\\D$-formula, and $\\Gamma^{\\#}\\cup \\Arrowvert \\nao F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent. By item 1) of Proposition 28, $\\Gamma\\cup \\Arrowvert \\nao\\Box F(\\vvarphi,\\todo x\\varphi(x)) \\Arrowvert$ is consistent.  $\\Box F(\\tvp, \\tq)$ is also a disjunctive template. Then, since $\\Gamma$ admits instantiation, for some witness variables $a$,  $\\Gamma\\cup \\Arrowvert \\nao\\Box F(\\vvarphi,\\varphi(a)) \\Arrowvert$ is consistent. By item 2) of Proposition 28, $\\Gamma^{\\#}\\cup \\Arrowvert \\nao F(\\vvarphi,\\varphi(a)) \\Arrowvert$ is consistent.       \r\n\\end{proof}\r\n\r\n\r\n\\subsection{Using templates for Henkin-like theorems}\r\n\r\n\\qquad Since the set of all templates is a countable set, the set of all disjunctives templates is also a countable set. By the same set-theoretical considerations, since $\\Fjv$ is countable, the set of all sequences $\\vvarphi$ of $\\D$-formulas is also countable. Hence, the set of all pairs $\\bl F(\\tvp), \\vvarphi \\br$ is countable, where $F$ is a disjunctive template, $\\tvp$ is $n$-ary sequence of propositional variables and $\\vvarphi$ is a $n$-ary sequence of $\\D$-formulas.\r\n\r\n\\qquad For this whole subsection we shall assume that the members of the set of pairs $\\bl F(\\tvp), \\vvarphi \\br$ are arranged in a sequence\r\n\r\n\\begin{center}\r\n\t$\\bl F_{1}(\\tvp_{1}), \\vvarphi_{1} \\br, \\bl F_{2}(\\tvp_{2}), \\vvarphi_{2} \\br, \\bl F_{3}(\\tvp_{3}), \\vvarphi_{3} \\br, \\dots $\r\n\\end{center}  \r\n\r\n\\qquad From now on we shall refer to this sequence as the `initial sequence'. This sequence of pairs determines a corresponding sequence of instantiation sets:\r\n\r\n\\begin{center}\r\n\t$\\Arrowvert F_{1}( \\vvarphi_{1}) \\Arrowvert, \\Arrowvert F_{2}( \\vvarphi_{2}) \\Arrowvert, \\Arrowvert F_{3}( \\vvarphi_{3}) \\Arrowvert, \\dots $\r\n\\end{center}  \r\n\r\n\r\n\\qquad It should be noted that for two different pairs $\\bl F_{i}(\\tvp_{i}), \\vvarphi_{i} \\br$, $\\bl F_{j}(\\tvp_{j}), \\vvarphi_{j} \\br$ the corresponding instantiation sets may be the same. For example, the pairs $\\bl \\tp_{0}, \\bl \\todo x \\varphi (x)\\br\\br$, $\\bl \\tp_{1}, \\bl \\todo x \\varphi (x)\\br \\br$ determine the same set $\\{\\todo x \\varphi(x)\\}$. Hence there are some repetitions in the sequence of instantiation sets, but this will not cause any trouble. \r\n\r\n\r\n\r\n\r\n\\begin{pro}(\\textit{Basic expansion})\r\n\tLet $\\C$ be a variant closed and axiomatically appropriate constant specification for the basic language, $\\Cv$ its extension and let $\\Gamma \\subseteq \\Fj$ be a $\\C$-consistent set. In these conditions, there is a $\\Gamma\\p \\subseteq \\Fjv$ such that $\\Gamma \\subseteq \\Gamma\\p$, $\\Gamma\\p$ is $\\Cv$-maximal consistent set and $\\Gamma\\p$ admits instantiation.  \r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\tWe define a sequence of sets of $\\Fjv$ formulas $\\Gamma_{1}, \\Gamma_{2}, \\Gamma_{3}, \\dots $ so that:\r\n\t\r\n\t\\begin{itemize}\r\n\t\t\\item $\\Gamma_{n}$ is $\\Cv$-consistent.\r\n\t\t\\item $\\Gamma_{n}$ is either $\\Gamma$ or $\\Gamma \\cup \\Arrowvert \\nao F_{i_{1}}( \\vvarphi_{i_{1}}) \\Arrowvert \\cup$ $\\dots$ $\\cup\\Arrowvert \\nao F_{i_{k}}( \\vvarphi_{i_{k}}) \\Arrowvert $.    \r\n\t\\end{itemize}    \r\n\t\r\n\t\\qquad First of all, $\\Gamma_{1} =\\Gamma$. By the remark at the end of subsection 5.4.3, $\\Gamma_{1}$ is $\\Cv$-consistent.  \r\n\t\r\n\t\\qquad Now, suppose $\\Gamma_{n}$ is constructed and it is of the form\r\n\t$\\Gamma \\cup \\Arrowvert \\nao F_{i_{1}}( \\vvarphi_{i_{1}}) \\Arrowvert \\cup$ $\\dots$ $\\cup\\Arrowvert \\nao F_{i_{k}}( \\vvarphi_{i_{k}}) \\Arrowvert $ (the other case has a similar proof). Let $\\bl F_{n}(\\tvp_{n}), \\vvarphi_{n} \\br$ be the $n$\\textsuperscript{th} pair of the initial sequence. If the last term of the sequence $\\vvarphi_{n}$ is not a universal formula, let $\\Gamma_{n+1} = \\Gamma_{n}$. Otherwise, consider the following. $\\vvarphi_{n}$ is of the form $\\vec{\\psi}, \\todo x \\varphi (x)$. And $F_{n}(\\tvp_{n})$ is the disjunctive template $G(\\vec{\\tq},\\tr)$ and so  $\\Arrowvert\\nao  F_{n}( \\vvarphi_{n}) \\Arrowvert = \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$.\r\n\t\r\n\t\\qquad If $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ is not $\\Cv$-consistent, then take $\\Gamma_{n+1}$ as $\\Gamma_{n}$.\r\n\t\r\n\t\\qquad If $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ is $\\Cv$-consistent, we shall show that for some witness variable $a$, $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$ is $\\Cv$-consistent.\r\n\t\r\n\t\\qquad First, we can assume that there is no overlap between the propositional variables $\\tvp_{i_{1}}, \\dots,\\tvp_{i_{k}},\\vec{\\tq},\\tr$ because from the point of view of the instantiation sets it does not matter if there is an overlap or not, and we are going to work only with the instantiation sets. Hence, by the definition of template\r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$F_{i_{1}}(\\tvp_{i_{1}})\\ou \\dots \\ou F_{i_{k}}(\\tvp_{i_{k}}) \\ou G(\\vec{\\tq},\\tr)$\r\n\t\\end{center}\r\nis a disjunctive template.\r\n\t\r\n\t\\qquad Second, from the definition of instantiation set and from classical reasoning, it can be easily checked that the sets  \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma \\cup \\Arrowvert \\nao F_{i_{1}}( \\vvarphi_{i_{1}}) \\Arrowvert \\cup \\dots \\cup\\Arrowvert \\nao F_{i_{k}}( \\vvarphi_{i_{k}}) \\Arrowvert \\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x\\varphi (x)) \\Arrowvert$ \\\\    \r\n\t\t\r\n\t\t$\\Gamma \\cup \\Arrowvert \\nao F_{i_{1}}( \\vvarphi_{i_{1}}) \\e \\dots \\e \\nao F_{i_{k}}( \\vvarphi_{i_{k}}) \\e \\nao G(\\vec{\\psi}, \\todo x\\varphi (x)) \\Arrowvert$ \\\\        \r\n\t\t\r\n\t\t$\\Gamma \\cup \\Arrowvert \\nao (F_{i_{1}}( \\vvarphi_{i_{1}}) \\ou \\dots \\ou  F_{i_{k}}( \\vvarphi_{i_{k}}) \\ou  G(\\vec{\\psi}, \\todo x\\varphi (x))) \\Arrowvert$     \r\n\t\\end{center}\r\nhave the same consequences. Thus, $\\Gamma \\cup \\Arrowvert \\nao (F_{i_{1}}( \\vvarphi_{i_{1}}) \\ou \\dots \\ou  F_{i_{k}}( \\vvarphi_{i_{k}}) \\ou  G(\\vec{\\psi}, \\todo x\\varphi (x))) \\Arrowvert$  is $\\Cv$-consistent.\r\n\t\r\n\t\r\n\t\\qquad Third, let $a$ be the first witness variable that does not occur in $\\Gamma, \\vvarphi_{i_{1}},\\dots, \\vvarphi_{i_{k}}, \\vec{\\psi}$ and $\\todo x \\varphi (x)$ (remember $\\Gamma$ is a set of formulas from the basic language). Then, by Proposition 27, $\\Gamma \\cup \\Arrowvert \\nao (F_{i_{1}}( \\vvarphi_{i_{1}}) \\ou \\dots \\ou  F_{i_{k}}( \\vvarphi_{i_{k}}) \\ou  G(\\vec{\\psi},\\varphi (a))) \\Arrowvert$  is $\\Cv$-consistent. As before, it can be seen that  \r\n\t\\begin{center}\r\n\t\t$\\Gamma \\cup \\Arrowvert \\nao F_{i_{1}}( \\vvarphi_{i_{1}}) \\Arrowvert \\cup \\dots \\cup\\Arrowvert \\nao F_{i_{k}}( \\vvarphi_{i_{k}}) \\Arrowvert \\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$ \\\\    \r\n\t\t\r\n\t\\end{center}\r\nis $\\Cv$-consistent. That is:    \r\n\t\r\n\t\r\n\t\\begin{center}\r\n\t\t$\\Gamma_{n} \\cup  \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$ \\\\        \r\n\t\\end{center}\r\nis $\\Cv$-consistent. So, take $\\Gamma_{n+1}$ as $\\Gamma_{n} \\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$.\r\n\t\r\n\t\\qquad It can be easily checked that $\\bigcup_{n\\in \\omega} \\Gamma_{n}$ is $\\Cv$-consistent. So, by Proposition 22 there is a set $\\Gamma\\p$ such that  $\\bigcup_{n\\in \\omega} \\Gamma_{n} \\subseteq\\Gamma\\p$ and $\\Gamma\\p$ is $\\Cv$-maximal consistent. \r\n\t\r\n\t\\qquad Clearly, $\\Gamma\\subseteq\\bigcup_{n\\in \\omega} \\Gamma_{n} \\subseteq\\Gamma\\p$. Now we show that $\\Gamma\\p$ admits instantiation.\r\n\t\r\n\t\r\n\t\\qquad Let $\\vvarphi$ be a sequence of $\\D$-formulas, $\\todo x \\varphi (x)$ a $\\D$-formula and $F(\\tvp,\\tq)$ a disjunctive template. Suppose that $\\Gamma\\p \\cup  \\Arrowvert \\nao F(\\vvarphi, \\todo x\\varphi (x)) \\Arrowvert$ is $\\Cv$-consistent. So, for some $k \\in \\omega$, $\\bl F(\\tvp,\\tq) , \\bl\\vvarphi,\\todo x \\varphi (x)  \\br\\br$ is the $k$\\textsuperscript{th} term of the initial sequence. Since $\\Gamma_{k}\\subseteq\\bigcup_{n\\in \\omega} \\Gamma_{n} \\subseteq\\Gamma\\p$, $\\Gamma_{k} \\cup  \\Arrowvert \\nao F(\\vvarphi, \\todo x\\varphi (x)) \\Arrowvert$ is $\\Cv$-consistent. By construction, for some witness variable $a$, $\\Gamma_{k+1}=\\Gamma_{k} \\cup  \\Arrowvert \\nao F(\\vvarphi, \\varphi (a)) \\Arrowvert$ is $\\Cv$-consistent. Thus $\\Arrowvert \\nao F(\\vvarphi, \\varphi (a)) \\Arrowvert\\subseteq \\Gamma\\p$. Hence, $\\Gamma\\p \\cup \\Arrowvert \\nao F(\\vvarphi, \\varphi (a)) \\Arrowvert$ is $\\Cv$-consistent. \r\n\\end{proof}\r\n\r\n\r\n\r\n\\begin{lema}\r\n\tSuppose $\\Gamma$ is a set of formulas that admits instantiation, $F(\\tvp)$ is a disjunctive template, and $\\vvarphi$ is a sequence of $\\D$-formulas. Then, $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert$ also admits instantiation.\r\n\\end{lema}\r\n\r\n\\begin{proof}\r\n\tLet $\\vec{\\psi}$ be a sequence of $\\D$-formulas, $\\todo x \\varphi (x)$ a $\\D$-formula and $G(\\vec{\\tq}, \\tr)$ a disjunctive template. Suppose $(\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert) \\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ is $\\Cv$-consistent.\r\n\t\r\n\t\\qquad As before, we can assume that $occ(F(\\tvp)) \\cap occ(G(\\vec{\\tq}, \\tr)) = \\vazio$. So $F(\\tvp) \\ou G(\\vec{\\tq}, \\tr)$ is a disjunctive template. And as before, the sets\r\n\t\r\n\t\\begin{center}\r\n\t\t$(\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert) \\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ \\\\\r\n\t\t$\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\e \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$\\\\ \r\n\t\t$\\Gamma \\cup \\Arrowvert  \\nao (F(\\vvarphi) \\ou  G(\\vec{\\psi}, \\todo x \\varphi (x))) \\Arrowvert$\r\n\t\\end{center}\r\nhave the same consequences. Thus, $\\Gamma \\cup \\Arrowvert  \\nao (F(\\vvarphi) \\ou  G(\\vec{\\psi}, \\todo x \\varphi (x))) \\Arrowvert$ is $\\Cv$-consistent. Since $\\Gamma$ admits instantiation, there is a witness variable $a$ such that $\\Gamma \\cup \\Arrowvert  \\nao (F(\\vvarphi) \\ou  G(\\vec{\\psi}, \\varphi (a))) \\Arrowvert$ is $\\Cv$-consistent. Hence, $(\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi) \\Arrowvert) \\cup \\Arrowvert \\nao G(\\vec{\\psi},\\varphi (a)) \\Arrowvert$ is $\\Cv$-consistent.\r\n\\end{proof}\r\n\r\n\r\n\r\n\r\n\\begin{pro}(\\textit{Secondary expansion}) Let $\\C$ be a variant closed and axiomatically appropriate constant specification for the basic language, $\\Cv$ its extension and $\\Gamma \\subseteq \\Fjv$ a $\\Cv$-consistent set that admits instantiation. In these conditions, there is a $\\Gamma\\p \\subseteq \\Fjv$ such that $\\Gamma \\subseteq \\Gamma\\p$, $\\Gamma\\p$ is $\\Cv$-maximal consistent set and $\\Gamma\\p$ admits instantiation.  \r\n\\end{pro}\r\n\r\n\\begin{proof}\r\n\tThe proof is very similar to the proof of Proposition 31.\r\n\t\r\n\t\\qquad We define a sequence $\\Gamma_{1},\\Gamma_{2}, \\dots$ of $\\Cv$-consistent sets that admit instantiation. First,     $\\Gamma_{1} = \\Gamma$.\r\n\t\r\n\t\\qquad Now, suppose $\\Gamma_{n}$ is already constructed. Let $\\bl F_{n}(\\tvp_{n}), \\vvarphi_{n} \\br$ be the $n$\\textsuperscript{th} pair of the initial sequence. If the last term of the sequence $\\vvarphi_{n}$ is not a universal formula, let $\\Gamma_{n+1} = \\Gamma_{n}$. Otherwise, consider the following. $\\vvarphi_{n}$ is of the form $\\vec{\\psi}, \\todo x \\varphi (x)$. And $F_{n}(\\tvp_{n})$ is the disjunctive template $G(\\vec{\\tq},\\tr)$ and so  $\\Arrowvert \\nao F_{n}( \\vvarphi_{n}) \\Arrowvert = \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$. If $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ is not $\\Cv$-consistent, then take $\\Gamma_{n+1}$ as $\\Gamma_{n}$.\r\n\t\r\n\t\\qquad If $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\todo x \\varphi (x)) \\Arrowvert$ is $\\Cv$-consistent, then, since $\\Gamma_{n}$ admits instantiation, there is a witness variable $a$ such that $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$ is $\\Cv$-consistent. By Lemma 4,  $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$ admits instantiation. So, take $\\Gamma_{n+1}$ as $\\Gamma_{n}\\cup \\Arrowvert \\nao G(\\vec{\\psi}, \\varphi (a)) \\Arrowvert$.\r\n\t\r\n\t\\qquad As before, it can be checked that $\\bigcup_{n\\in \\omega}\\Gamma _{n}$ is a  $\\Cv$-consistent set that admits instantiation. By Proposition 22 there is a set $\\Gamma\\p$ such that  $\\bigcup_{n\\in \\omega} \\Gamma_{n} \\subseteq\\Gamma\\p$ and $\\Gamma\\p$ is $\\Cv$-maximal consistent. It is easy to see that  $\\Gamma\\p$  admits instantiation. \r\n\\end{proof}\r\n\r\n\r\n\\subsection{Completeness}\r\n\r\n\\begin{defn}\r\n\tA \\textit{canonical model} $\\M = \\model$, using constant specification $\\C$, is specified as follows.\r\n\t\r\n\t\\begin{itemize}\r\n\t\t\\item $\\W$ is the set of all $\\C(\\textbf{V})$-maximally consistent sets that admit instantiation.\r\n\t\t\\item Let $\\Gamma, \\Delta \\in \\W$. $\\Gamma\\R\\Delta$ iff $\\Gamma^{\\#} \\subseteq  \\Delta$.\r\n\t\t\\item $\\D = \\textbf{V}$.\r\n\t\t\\item For an $n$-place relation symbol $P$ and for $\\Gamma \\in \\W$, let $\\I(P,\\Gamma)$ be the set of all $\\vec{a}$ where $\\vec{a} \\in \\textbf{V}$ and $P(\\vec{a}) \\in \\Gamma$.\r\n\t\t\\item For $\\Gamma \\in \\W$, set $\\Gamma \\in \\E(t,\\varphi)$ iff $t$$:_{X}$$\\varphi \\in \\Gamma$, where $t$$:_{X}$$\\varphi$ is a closed $\\D$-formula and $X$ is the set of witness variables in $\\varphi$.\r\n\t\\end{itemize}\r\n\\end{defn}\r\n\r\n\r\n\\qquad First we need to check that $\\M$ is indeed a Fitting model meeting $\\C$. Since the argument is similar to the one presented in \\cite[pp. 13-14]{Fitting14} we are only going to show that $\\R$ is an equivalence relation and that the $?$ Condition holds.  \\\\\r\n\r\n\\qquad \\textit{$\\R$ is reflexive}. Let $\\Gamma \\in \\W$, and let $t$$:_{X}$$\\varphi = t$$:_{X}$$\\varphi(\\vec{y})$ be a closed $\\D$-formula in $\\Gamma$ such that $\\vec{y}$ is an $n$-ary sequence of basic variables, say $y_{1}, \\dots, y_{n}$ and, of course, $\\vec{y} \\notin X$. By repeated use of axiom \\textbf{B6} and classical reasoning:\r\n\r\n\\begin{center}\r\n\t$\\teo_{C(\\textbf{V})}t$$:_{X}$$\\varphi(\\vec{y}) \\impli gen_{y_{1}}(gen_{y_{2}} \\dots (gen_{y_{n}}(t)))$$:_{X}\\todo \\vec{y} \\varphi(\\vec{y})$\r\n\\end{center}\r\nBy axiom \\textbf{B1},\r\n\r\n\\begin{center}\r\n\t$\\teo_{C(\\textbf{V})} gen_{y_{1}}(gen_{y_{2}} \\dots (gen_{y_{n}}(t)))$$:_{X}\\todo \\vec{y} \\varphi(\\vec{y}) \\impli \\todo \\vec{y} \\varphi(\\vec{y})$\r\n\\end{center}\r\nhence, by the maximal consistency of $\\Gamma$, $\\todo \\vec{y} \\varphi(\\vec{y}) \\in \\Gamma$. Thus $\\Gamma^{\\#} \\subseteq \\Gamma$, i.e., $\\Gamma\\R\\Gamma$.\\\\\r\n\r\n\\qquad \\textit{$\\R$ is transitive}. Let $\\Gamma, \\Delta, \\Theta \\in \\W$ such that $\\Gamma\\R\\Delta$ and $\\Delta\\R\\Theta$; and let $\\varphi \\in \\Gamma^{\\#}$, i.e., $\\varphi = \\todo \\vec{y} \\psi(\\vec{a},\\vec{y})$ ($\\vec{a}$ is a sequence of witness variables and $\\vec{y}$ is a sequence of basic variables) and $t$$:_{\\{\\vec{a}\\}}$$\\psi(\\vec{a},\\vec{y}) \\in \\Gamma$.\r\n\r\n\\qquad By the axiom \\textbf{B4} and by the maximal consistency of $\\Gamma$,  $!t$$:_{\\{\\vec{a}\\}}$$ t$$:_{\\{\\vec{a}\\}}$$\\psi(\\vec{a},\\vec{y}) \\in \\Gamma$. Since $t$$:_{\\{\\vec{a}\\}}$$\\psi(\\vec{a},\\vec{y})$ has no free basic variables and $\\Gamma \\R \\Delta$, then $t$$:_{\\{\\vec{a}\\}}$$\\psi(\\vec{a},\\vec{y}) \\in \\Delta$. And since $\\Delta\\R\\Theta$, then $\\todo \\vec{y} \\psi(\\vec{a},\\vec{y}) \\in \\Theta$, i.e., $\\varphi  \\in \\Theta$. Thus, $\\Gamma^{\\#} \\subseteq \\Theta$, i.e., $\\Gamma\\R\\Theta$.\\\\\r\n\r\n\r\n\r\n\r\n\r\n\\qquad \\textit{$\\R$ is symmetric}. Let $\\Gamma, \\Delta \\in \\W$. Suppose that $\\Gamma \\R \\Delta$ and suppose it is not the case that $\\Delta \\R \\Gamma$. Then $\\Delta^{\\#} \\nsubseteq \\Gamma$. So for some term $t$, some set of witness variables $X$ and some $\\D$-formula $\\varphi(\\vec{y})$,  $t$$:_{X}$$\\varphi(\\vec{y}) \\in \\Delta$ and $\\todo \\vec{y} \\varphi(\\vec{y}) \\notin \\Gamma$. By the maximal consistency of $\\Gamma$,  $\\nao \\todo \\vec{y} \\varphi(\\vec{y}) \\in \\Gamma$. Now, assume that $t$$:_{X}$$\\varphi(\\vec{y}) \\in \\Gamma$. Then by repeated use of axiom \\textbf{B6}, $gen_{y_{1}}(gen_{y_{2}} \\dots (gen_{y_{n}}(t)))$$:_{X}\\todo \\vec{y} \\varphi(\\vec{y})\\in \\Gamma$. By axiom \\textbf{B1}, $\\todo \\vec{y} \\varphi(\\vec{y})\\in \\Gamma$, a contradiction. Hence, $t$$:_{X}$$\\varphi(\\vec{y}) \\notin \\Gamma$, by the maximal consistency of $\\Gamma$, $\\nao t$$:_{X}$$\\varphi(\\vec{y}) \\in \\Gamma$. By axiom \\textbf{B5}, $?t$$:_{X}$$\\nao t$$:_{X}$$\\varphi(\\vec{y}) \\in \\Gamma$. Since $\\Gamma^{\\#} \\subseteq \\Delta$, then $\\nao t$$:_{X}$$\\varphi(\\vec{y}) \\in \\Delta$, a contradiction. Therefore, if $\\Gamma \\R \\Delta$, then $\\Delta \\R \\Gamma$.\\\\\r\n\r\n\\qquad \\textit{$?$ Condition}. Suppose $\\Gamma \\in \\W \\backslash \\E(t,\\varphi)$; and let $X$ be the set of all witness variables occurring in $\\varphi$. Thus, by the definition of $\\E$, $t$$:_{X}$$\\varphi \\notin \\Gamma$. By the maximal consistency of $\\Gamma$,  $\\nao t$$:_{X}$$\\varphi \\in \\Gamma$. By the axiom \\textbf{B5}, $?t$$:_{X}$$\\nao t$$:_{X}$$\\varphi \\in \\Gamma$. Hence, $\\Gamma \\in \\E(?t,\\nao t$$:_{X}$$\\varphi)$.\\\\\r\n\r\n\r\n\\qquad We have shown that the canonical model is a Fitting model meeting $\\C$. Now, to show that the canonical model is a Fitting model for FOJT45, we need to show that $\\E$ is a strong evidence function. This is going to be a consequence of the following Lemma:\r\n\r\n\r\n\\begin{lema}\r\n\t(\\textit{Truth Lemma}). Let $\\M=\\model$ be a canonical model. For each $\\Gamma \\in \\W$ and for each closed $\\D$-formula $\\varphi$,\r\n\t\\begin{center}\r\n\t\t$\\M,\\Gamma \\models \\varphi$ iff $\\varphi \\in \\Gamma$\r\n\t\\end{center}\r\n\\end{lema}\r\n\r\n\\begin{proof}\r\n\tInduction on the complexity of $\\varphi$. The crucial cases are when $\\varphi$ is $t$$:_{X}$$\\psi$ and when $\\varphi$ is $\\todo x \\psi(x)$. \\\\\r\n\t\r\n\t($\\varphi$ is $t$$:_{X}$$\\psi$)\\\\\r\n\t\r\n\t\\qquad ($\\Rightarrow$) Suppose $t$$:_{X}$$\\psi \\notin \\Gamma$. Let $X\\p \\subseteq X$ be a set where $X\\p$ contain exactly the witness variables that occur in $\\psi$. It is not the case that $t$$:_{X\\p}$$\\psi \\in \\Gamma$. Otherwise, by axiom \\textbf{A3} and by the maximal consistency of $\\Gamma$,  $t$$:_{X}$$\\psi \\in \\Gamma$. So by the definition of $\\E$, $\\Gamma \\notin \\E(t,\\psi)$, thus $\\M,\\Gamma \\nmodels t$$:_{X}$$\\psi$.\r\n\t\r\n\t\\qquad ($\\Leftarrow$) First, suppose $t$$:_{X}$$\\psi \\in \\Gamma$. Again, let $X\\p \\subseteq X$ be as above. So, by the axiom \\textbf{A2} and by the maximal consistency of $\\Gamma$, $t$$:_{X\\p}$$\\psi \\in \\Gamma$. Hence, $\\Gamma \\in \\E(t,\\psi)$. Second, let $\\Delta \\in \\W$ such that $\\Gamma \\R \\Delta$. So $\\todo \\vec{y}\\psi \\in \\Delta$ where $\\vec{y}$ are the free basic variables of $\\psi$. Thus, by the classical axioms and by the maximal consistency of $\\Delta$, for every $\\vec{a} \\in \\textbf{V}$,  $\\psi(\\vec{a}) \\in \\Delta$. By the induction hypothesis, for every $\\vec{a} \\in \\textbf{V}$, $\\M, \\Delta \\models \\psi(\\vec{a})$. Therefore, $\\M,\\Gamma \\models t$$:_{X\\p}$$\\psi$, and so $M,\\Gamma \\models t$$:_{X}$$\\psi$.\\\\\r\n\t\r\n\t\r\n\t($\\varphi$ is $\\todo x \\psi(x)$)\\\\\r\n\t\r\n\t\\qquad ($\\Rightarrow$) Suppose $\\todo x \\psi(x) \\notin \\Gamma$. By the maximal consistency of $\\Gamma$, $\\nao \\todo x \\psi(x) \\in \\Gamma$. Since $\\Gamma$ admits instantiation, then by Proposition 29 there is an $a \\in \\textbf{V}$ such that $\\nao \\psi(a) \\in \\Gamma$. By the consistency of $\\Gamma$, $\\psi(a) \\notin \\Gamma$. By the induction hypothesis, $\\M, \\Gamma \\nmodels \\psi(a)$, thus $\\M, \\Gamma \\nmodels \\todo x \\psi(x)$.    \r\n\t\r\n\t\r\n\t\\qquad ($\\Leftarrow$) Suppose  $\\todo x \\psi(x) \\in \\Gamma$. By the classical axioms and by the maximal consistency of $\\Gamma$, for every $a \\in \\textbf{V}$,  $\\psi(a) \\in \\Gamma$. By the induction hypothesis, $\\M, \\Gamma \\models \\psi(a)$, for every $a \\in \\textbf{V}$. Therefore,  $\\M, \\Gamma \\models \\todo x \\psi(x)$.  \r\n\\end{proof}\r\n\r\n\\qquad By the Truth Lemma, we have the following:\r\n\r\n\r\n\\begin{center}\r\n\t$\\Gamma \\in \\E(t,\\varphi) \\Rightarrow t$$:_{X}$$\\varphi \\in \\Gamma \\Rightarrow \\M,\\Gamma \\models t$$:_{X}$$\\varphi \\Rightarrow \\Gamma \\in \\{w \\in \\W$ $|$ $ \\M,w \\models t$$:_{X}$$\\varphi\\}$\r\n\\end{center}\r\n\r\nHence $\\E$ is a strong evidence function, and so $\\M$ is a Fitting model for FOJT45 meeting $\\C$.\r\n\r\n\\begin{teor}\r\n\t(\\textit{Completeness}) Let $\\C$ be a constant specification. For every closed formula $\\varphi \\in \\Fj$, if $\\models_{\\C} \\varphi$, then $\\teo_{\\C}\\varphi$.\r\n\\end{teor}\r\n\r\n\\begin{proof}\r\n\tSuppose $\\not\\teo_{\\C}\\varphi$. Then $\\{\\nao \\varphi\\}$ is $\\C$-consistent. By Proposition 31, there is a $\\C(\\textbf{V})$-maximal consistent $\\Gamma$ such that $\\Gamma$ admits instantiation and  $\\{\\nao \\varphi\\} \\subseteq \\Gamma$. By the Truth Lemma, $\\M,\\Gamma \\models \\nao \\varphi$, so  $\\M,\\Gamma \\nmodels \\varphi$. Hence, $\\nmodels_{\\C} \\varphi$.     \r\n\\end{proof}\r\n\r\n\r\n\r\n\r\n\\begin{defn}\r\n\tA model $\\M = \\model$ is \\textit{fully explanatory} if the following condition is fulfilled. Let $\\varphi$ be a formula with no free individual variables, but with constants from the domain of the model. Let $w \\in \\W$. If for every $v \\in \\W$ such that $w\\R v$, $\\M, v \\models \\varphi$, then there is a justification term $t$ such that $\\M, w \\models t$$:_{X}$$\\varphi$, where $X$ is the set of\r\n\tdomain constants appearing in $\\varphi$. \r\n\\end{defn}\r\n\r\n\r\n\\begin{teor}\r\n\tThe canonical model is fully explanatory.\r\n\\end{teor}\r\n\r\n\\begin{proof}\r\n\tLet $\\M = \\model$ be a canonical model, $\\Gamma \\in \\W$, $\\varphi$ a closed $\\D$-formula and $X$ the set of the witness variables occurring $\\varphi$. We shall show that if $\\M, \\Gamma \\nmodels t$$:_{X}$$\\varphi$ for every justification term $t$ of $\\Fj$, then there is a $\\Delta \\in \\W$ such that $\\Gamma \\R\\Delta$ and $\\M, \\Delta \\nmodels \\varphi$.\r\n\t\r\n\t\\qquad If $\\M, \\Gamma \\nmodels t$$:_{X}$$\\varphi$ for every justification term $t$ of $\\Fj$, then by the Truth Lemma, $\\nao t$$:_{X}$$\\varphi \\in \\Gamma$ for every justification term $t$ of $\\Fj$. The template $G(\\tp) =\\tp$ is a disjunctive template. Let $F(\\tp) = \\Box G(\\tp)$. Hence, $\\Arrowvert \\nao F(\\varphi)\\Arrowvert \\subseteq \\Gamma$. And so, $\\Gamma \\cup \\Arrowvert \\nao F(\\vvarphi)\\Arrowvert$ is $\\Cv$-consistent. By item 2) of Proposition 28, $\\Gamma^{\\#} \\cup \\Arrowvert \\nao G(\\varphi)\\Arrowvert$ is $\\Cv$-consistent, i.e.,  $\\Gamma^{\\#} \\cup \\{  \\nao \\varphi \\} $ is $\\Cv$-consistent. By Proposition 30, $\\Gamma^{\\#}$ admits instantiation. By Lemma 4,  $\\Gamma^{\\#} \\cup \\{  \\nao \\varphi \\} $ admits instantiation. By Proposition 32, there is a $\\Cv$-maximal consistent set $\\Delta$ such that $\\Delta$ admits instantiation and $\\Gamma^{\\#} \\cup \\{  \\nao \\varphi \\}\\subseteq\\Delta$. Since $\\Gamma^{\\#} \\subseteq \\Delta$, $\\Gamma \\R \\Delta$. And since $\\nao \\varphi \\in \\Delta$, by the Truth Lemma,  $\\M, \\Delta \\nmodels \\varphi$.\r\n\t\r\n\\end{proof}", "meta": {"hexsha": "59e8069ab1893cf8999688269f9def2f2d09780a", "size": 86232, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/chapters/first-order_JT45.tex", "max_stars_repo_name": "felipessalvatore/dissertacao_mestrado", "max_stars_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/chapters/first-order_JT45.tex", "max_issues_repo_name": "felipessalvatore/dissertacao_mestrado", "max_issues_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/chapters/first-order_JT45.tex", "max_forks_repo_name": "felipessalvatore/dissertacao_mestrado", "max_forks_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.3042596349, "max_line_length": 1137, "alphanum_fraction": 0.6282122646, "num_tokens": 31234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710234, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4403064769034014}}
{"text": "% This is part of the TFTB Reference Manual.\n% Copyright (C) 1996 CNRS (France) and Rice University (US).\n% See the file refguide.tex for copying conditions.\n\n\n\n\\markright{atoms}\n\\section*{\\hspace*{-1.6cm} atoms}\n\n\\vspace*{-.4cm}\n\\hspace*{-1.6cm}\\rule[0in]{16.5cm}{.02cm}\n\\vspace*{.2cm}\n\n\n\n{\\bf \\large \\sf Purpose}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\nLinear combination of elementary Gaussian atoms.\n\\end{minipage}\n\\vspace*{.5cm}\n\n{\\bf \\large \\sf Synopsis}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n\\begin{verbatim}\n[sig,locatoms] = atoms(N)\n[sig,locatoms] = atoms(N,coord)\n\\end{verbatim}\n\\end{minipage}\n\\vspace*{.5cm}\n\n\n{\\bf \\large \\sf Description}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n        {\\ty atoms} generates a signal consisting in a linear combination\n        of elementary gaussian atoms. The locations of the time-frequency\n        centers of the different atoms are either fixed by the input\n        parameter {\\ty coord} or successively defined by clicking with the\n        mouse (if {\\ty nargin==1}), with the help of a menu.\\\\\n\n\\hspace*{-.5cm}\\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}\nName & Description & Default value\\\\\n\\hline\n        {\\ty N}        & number of points of the signal\\\\\n        {\\ty coord}    & matrix of time-frequency centers, of the form\n                   {\\ty [t1,f1,T1,A1;...;tM,fM,TM,AM]}. {\\ty (ti,fi)} are the \n                   time-frequency coordinates of atom {\\ty i}, {\\ty Ti} is its time \n                   duration and {\\ty Ai} its amplitude. Frequencies {\\ty f1..fM} should \n                   be between 0 and 0.5.\n                   If {\\ty nargin==1}, the location of the atoms will be defined\n                   by clicking with the mouse& {\\ty Ti=N/4, Ai=1}.\\\\\n \\hline {\\ty sig}      & output signal\\\\\n        {\\ty locatoms} & matrix of time-frequency coordinates and durations of the\n                   atoms  \\\\\n\n\\hline\n\\end{tabular*}\n\\vspace*{.1cm}\n\nWhen the selection of the atoms is finished (after clicking on the 'Stop'\nbuttom, or after having specified the coordinates at the command line with\nthe input parameter {\\ty coord}), the signal in time together with a\nschematic representation of the atoms in the time-frequency plane are\ndisplayed on the current figure.\n\\end{minipage}\n\\vspace*{.5cm}\n\n{\\bf \\large \\sf Examples}\n\\begin{verbatim}\n         sig=atoms(128);\n         sig=atoms(128,[32,0.3,32,1;56,0.15,48,1.22;102,0.41,20,0.7]); \n\\end{verbatim}\n\\vspace*{.5cm}\n\n{\\bf \\large \\sf See Also}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n\\begin{verbatim}\namgauss, fmconst.\n\\end{verbatim}\n\\end{minipage}", "meta": {"hexsha": "44394d59a3fbe699750b9f6089bddaddfcffe859", "size": 2593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tftb/refguide/atoms.tex", "max_stars_repo_name": "sangyoonHan/extern", "max_stars_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2018-03-28T01:50:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T07:24:14.000Z", "max_issues_repo_path": "tftb/refguide/atoms.tex", "max_issues_repo_name": "sangyoonHan/extern", "max_issues_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tftb/refguide/atoms.tex", "max_forks_repo_name": "sangyoonHan/extern", "max_forks_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2018-03-28T01:50:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T09:09:40.000Z", "avg_line_length": 31.2409638554, "max_line_length": 88, "alphanum_fraction": 0.6428846895, "num_tokens": 813, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017746, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4401625736431093}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 16, Section 2.7: 2, 3, 9, 10, 15}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{2.}\n$\\begin{bmatrix} -1 & 0\\\\  0 & 1   \\end{bmatrix} \\begin{bmatrix} 4 & 2 & 5\\\\  0 & 2 & 3  \\end{bmatrix} = \\begin{bmatrix} -4 & -2 & -5\\\\  0 & 2 & 3   \\end{bmatrix}$\n\\subsection*{3.}\nFirst, we have to start with the translating the matrix, and then we need to multiply it by the matrix that will rotate it 90 degrees. After these multiplications, the resulting matrix is computed. \n$\\begin{bmatrix}0 & -1 & -1\\\\ 1 & 0 & 2 \\\\ 0 & 0 & 1   \\end{bmatrix}$\n\\subsection*{9.}\nThe two possibilities result in drastically different results. Multiplying the 2 x 2 matrices first, (8 multiplications) and then multiplying it by D (total of 408 multiplications) is drastically different than multiplying A(DB) (DB is 200, and then by A is 800). Obviously, the first way is the better way to multiply. If we were doing this on a 1080 x 1920 resolution screen, at 60 frames per second, it would save millions of computations over the course of just a minute. \n\\subsection*{10.}\nD commutes with R but not with T; R does not commute with T. \n\\subsection*{15.}\n(12, -6, -3)\n\n\n\n\\end{document}", "meta": {"hexsha": "2f6588f1072a228be9ad9d3e024fcf540eed5f4b", "size": 1563, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LinearAlgebra/Homework16.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LinearAlgebra/Homework16.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LinearAlgebra/Homework16.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.4166666667, "max_line_length": 476, "alphanum_fraction": 0.7031349968, "num_tokens": 553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4401625602428719}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\hyphenation{UPARAM}\n\\begin{document}\n\\begmath 6.4  One Householder Transformation\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese subroutines compute the parameters defining a Householder orthogonal\ntransformation which zeroes specified components in a given vector, or in\na column or row of a matrix. Also they optionally apply either a newly\ndefined transformation or a previously defined Householder transformation to\na vector or a set of vectors, which typically would be columns or rows of a\nmatrix.\n\nTwo versions are provided. For the usual case in which both the pivot vector\nand the vectors to which the transformation is to be applied are column\nvectors, we recommend the use of DHTCC or SHTCC. If either the pivot vector\nor the vectors to which the transformations are to be applied, or both, are\nrow vectors, one must use DHTGEN or SHTGEN.\n\nThese subroutines are used by other library subroutines, and can be used as\nmodules in implementing other linear algebra algorithms.\n\n\\subsection{Usage}\n\n\\subsubsection{Usage of SHTGEN and DHTGEN}\n\nWe use the term {\\em pivot vector} to mean the vector that plays a special role in\ndetermining or defining the Householder transformation. When MODE = 1 a\ntransformation will be determined that is appropriate to zero components L1\nthrough M of the pivot vector. These components are then replaced by\nvalues that partially define the appropriate Householder transformation.\nComponent LPIVOT of the pivot vector, and UPARAM are also assigned values to\ncomplete the definition of the transformation. After defining the\ntransformation it will optionally be applied to specified vectors.\n\nWhen MODE = 2 the transformation defined in a previous call with MODE\n= 1 will be applied to specified vectors.\n\n\\paragraph{Program Prototype, Single Precision}\n\n\\begin{description}\n\n\\item[INTEGER] \\ {\\bf MODE, LPIVOT, L1, M, LDU, LDC, NCV}\n\n\\item[LOGICAL] \\ {\\bf COLU, COLC}\n\n\\item[REAL] \\ {\\bf U}(LDU,$*$){\\bf , UPARAM, C}(LDC,$*$)\n\n\\end{description}\n\nAssign values to all integer and logical arguments and to the relevant real\narguments.\n\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nCALL SHTGEN(MODE, LPIVOT, L1,\\\\\nM, U, LDU, COLU, UPARAM,\\\\\nC, LDC, NCV, COLC)\\\\\n\\end{tabular}}\n\\end{center}\n\nComputed results will be returned in U(,), UPARAM, and/or C(,),\ndepending on the initial settings of the integer arguments.\n\n\\paragraph{Argument Definitions}\n\n\\begin{description}\n\n\\item[MODE] \\ [in] Set by the user to the value 1 or~2. If MODE = 1, the subroutine\ncomputes parameters defining a Householder transformation as described in\nSection D. If MODE = 2, it is assumed that Householder transformation\nparameters have already been defined by a previous call with MODE = 1. In\neither case, if NCV $> 0$, the subroutine will apply the current\ntransformation to the set of NCV M-vectors stored in the array C(,).\n\n\\item[LPIVOT, L1, M] \\ [in] These integers specify that the vectors to be referenced\nor operated upon are M-dimensional, and the components to be referenced or\noperated upon in each vector are the one indexed by LPIVOT and the set\nindexed from L1 through M. To define a nontrivial transformation these\nintegers must satisfy\n\\begin{equation*}\n1 \\leq \\text{LPIVOT} <\\text{L1} \\leq \\text{M}\n\\end{equation*}\nIf these inequalities are not all satisfied, the subroutine returns without\ndoing any computation. This is not regarded as an error. It has the implicit\neffect of applying an identity transformation.\n\n\\item[U(,)] \\ [inout] The array U(,) contains the pivot vector as either a column\nor a row. Examples:\n\nIf the pivot vector is column J of an array declared as A(IDIM,JDIM), the\narguments corresponding to ``U, LDU, COLU\" should be written as ``A(1, J),\nIDIM, .true.\".\n\nIf the pivot vector is row I of an array declared as A(IDIM,JDIM), the\narguments corresponding to ``U, LDU, COLU\" should be written as ``A(I,1),\nIDIM, .false.\".\n\n\\item[LDU] \\ [in] Leading dimensioning parameter for U(,).\n\n\\item[COLU] \\ [in] Must be set to .true.\\ if the pivot vector is a column of U(,)\nand to .false.\\ if the pivot vector is a row of U(,).\n\n\\item[UPARAM] \\ [inout] Holds a value completing the definition of a Householder\ntransformation. See description in Section D. This value will be computed by\nthe subroutine when MODE = 1 and must be present on entry when MODE\\ = 2.\n\n\\item[C(,)] \\ [inout] If NCV $\\leq$ 0, no reference will be made to C(,).\nIf NCV $> 0$, the array C(,) is regarded as containing a set of NCV M%\n-vectors. These are regarded as column vectors if COLC = .true.\\ and row\nvectors if COLC\\ = .false. On entry C(,) contains vectors to be\ntransformed, and on return C(,) contains the vectors resulting from\napplication of the current Householder transformation. Examples:\n\nTo apply a transformation to columns J + 1 through N of an array declared\nas A(IDIM,JDIM), the arguments ``C, LDC, NCV, COLC\" should be written as\n``A(1, J+1), IDIM, N$-$J, .true.\".\n\nTo apply a transformation to rows K + 1 through M1 of an array declared as\nA(IDIM,JDIM), the arguments ``C, LDC, NCV, COLC\" should be written as\n``A(K+1,~1), IDIM, M1$-$K, .false.\".\n\n\\item[LDC] \\ [in] Leading dimensioning parameter of C(,).\n\n\\item[NCV] \\ [in] Number of vectors in C(,) to be transformed. If\nNCV $\\leq $ 0, the array C(,) will not be referenced.\n\n\\item[COLC] \\ [in] Must be set to .true.\\ if the vectors to be transformed are column\nvectors of C(,), and to .false.\\ if the vectors to be transformed are row\nvectors of C(,).\n\\end{description}\n\n\\subsubsection{Usage of SHTCC and DHTCC}\n\nSubroutine DHTCC is a modification of DHTGEN specialized for the case of\nCOLU\\ = .true.\\ and COLC\\ = .true.\n\n\\paragraph{Program Prototype, Single Precision}\n\n\\begin{description}\n\n\\item[INTEGER] \\ {\\bf MODE, LPIVOT, L1, M, LDC, NCV}\n\n\\item[REAL] \\ {\\bf U}$(*)${\\bf , UPARAM, C}(LDC,$*)$\n\n\\end{description}\n\nAssign values to all integer and logical arguments and to the relevant real\narguments.\n\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nCALL SHTCC(MODE, LPIVOT, L1, M,\\\\\nU, UPARAM, C, LDC, NCV)\\\\\n\\end{tabular}}\n\\end{center}\n\nComputed results will be returned in U(,), UPARAM, and/or C(,),\ndepending on the initial settings of the integer arguments.\n\n\\paragraph{Argument Definitions}\n\nThe arguments have the same meanings as the arguments of the same names in\nthe call to SHTGEN. Note that arguments LDU, COLU, and COLC are not used,\nand U is a one-dimensional array. This subroutine functions as though COLU\n= .true.\\ and COLC = .true.\n\n\\subsubsection{Modifications for Double Precision}\n\nFor double precision usage change the REAL statement to DOUBLE PRECISION and\nchange the subroutine names SHTGEN and SHTCC to DHTGEN and DHTCC\nrespectively.\n\n\\subsection{Examples and Remarks}\n\nThe program DRSHTCC illustrates the use of SHTCC. The array D(,) is\ninitialized with a $3\\times 2$ matrix, $A$, in its first 2 columns, and a $%\n3\\times 3$ identity matrix in columns 3 through 5. Subroutine SHTCC is used\nto compute the QR factorization of $A$, $i.e.$, the program determines an\northogonal matrix, $Q$, and a triangular matrix, $R$, such that $A = Q R$.\nResults are shown in ODSHTCC.\n\nFor additional examples of the use of SHTCC and SHTGEN see the source code\nfor the library subroutines SHFTI or SSVDRS.\n\n\\subsection{Functional Description}\n\nLet ${\\bf u}$ be a nonzero $n$-vector and define $\\beta  = -\\|{\\bf u}\\|^2/2$. The matrix\n\\begin{equation*}\nQ = I + \\beta ^{-1}{\\bf uu}^t\n\\end{equation*}\nis symmetric and orthogonal, and is called a Householder transformation\nmatrix.\n\nA product of the form ${\\bf w} = Q{\\bf v}$ can be computed by the steps:\n\\begin{align*}\n\\gamma &= ({\\bf u}^t{\\bf v})/\\beta\\\\\n{\\bf w} &= {\\bf v} + \\gamma {\\bf u}\n\\end{align*}\nTypically one desires a ${\\bf u}$ such that for some particular nonzero vector, ${\\bf v}$%\n, the vector ${\\bf w} = Q{\\bf v}$ will consist of zeros except for the first component.\nGiven ${\\bf v}$, the appropriate ${\\bf u}$ and $\\beta $ to accomplish this can be\ndefined mathematically as follows:\n\\begin{align*}\n\\sigma &= 1 \\hspace{.7in} \\text{if } v_1 > 0 \\text{ and } {-}{1} \\text{ otherwise}\\\\\nu_1 &= v_1 + \\sigma \\|{\\bf v}\\|\\\\\nu_i &= v_i, \\hspace{.6in} i = 2{\\text, ..., }n\\\\\n\\beta  &= -\\sigma u_1\\|{\\bf v}\\| \\hspace{.2in} \\text{(Note that }\\beta  \\leq 0.)\n\\end{align*}\nWith this definition of $\\sigma $, ${\\bf u}$, and $\\beta $, and thus of $Q$,\nthe vector ${\\bf w} = Q{\\bf v}$ will have components:\n\\begin{align*}\nw_1 &= -\\sigma \\|{\\bf v}\\|\\\\\nw_i &= 0, \\hspace{.4in} i = 2\\text{, ..., }n.\n\\end{align*}\nIn applications it is frequently convenient to regard the vectors ${\\bf v}$, ${\\bf u}$,\nand ${\\bf w}$ of the above formulas as embedded in higher dimensional vectors with\nother components which play no role in the current transformation.\nSpecifically we regard the host vector for ${\\bf v}$ (and similarly for ${\\bf u}$ and ${\\bf w})\n$ as being of dimension M, with $v_1$ at position LPIVOT and $v_2$, ..., $%\nv_n$ in positions L1 through M. Thus we are identifying $n$ with the value\nM $-$ L1 + 2. We assume $1 \\leq \\text{LPIVOT} < \\text{L1} \\leq \\text{M}.$\n\nOn input with MODE = 1 the array U(,) contains ${\\bf v}$ embedded as specified\nby the integers LPIVOT, L1, and M, and with the Fortran~77 storage mapping\nas specified by the arguments LDU and COLU. The subroutine computes $w_1$\nand ${\\bf u}$. It stores the $u_1$ in UPARAM, $w_1$ in place of $v_1$, and $u_2$, $%\n...,u_M$ in place of $v_2$, $...,v_M.$\n\nWhen applying transformations the quantity $\\beta $ is computed as $\\beta  =\nu_1w_1$, using the value of $u_1$ stored in UPARAM and $w_1$ stored in U(,).\n\nThis is essentially Algorithm H12 of \\cite{Lawson:1974:SLS} with a change\nin the way the user specifies the column/row options.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nTo define and/or apply a nontrivial transformation one must have\n\\begin{equation*}\n1 \\leq \\text{LPIVOT} < \\text{L1} \\leq \\text{M}\n\\end{equation*}\nIf these conditions are not all satisfied the subroutine returns\nimmediately, doing no computation. This is not regarded as an error\ncondition as it may occur intentionally as an end condition in a loop. It\nwill have the effect of computing and/or applying an identity\ntransformation.\n\nIf, on entry with MODE = 1, the components of the pivot vector indexed by\nLPIVOT, and L1 through M, are all zero, the subroutine will effectively\ndefine an identity transformation. It will set UPARAM = 0. This is not\nregarded as an error condition.\n\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDHTCC & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nDHTCC, DNRM2\\rule[-5pt]{0pt}{8pt}}\\\\\nDHTGEN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nDAXPY, DDOT, DHTGEN, DNRM2\\rule[-5pt]{0pt}{8pt}}\\\\\nSHTCC & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nSHTCC, SNRM2\\rule[-5pt]{0pt}{8pt}}\\\\\nSHTGEN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nSAXPY, SDOT, SHTGEN, SNRM2}\\\\\n\\end{tabular}\n\nOriginal version designed and programmed by C.  L.  Lawson and R.  J.\nHanson, JPL, 1968, and published in \\cite{Lawson:1974:SLS} as subroutine\nH12.  Adapted to Fortran~77 for the MATH77 library by Lawson and S.  Y.\nChiu, June~1987.\n\n\n\\begcodenp\n\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSHTCC}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{shtcc}}\n\n\\vspace{30pt}\\centerline{\\bf \\large ODSHTCC}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{shtcc}}\n\\end{document}\n", "meta": {"hexsha": "f733c6c4898d9d4c07a5b4e7c85bc10c5ab0d8f3", "size": 11758, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch06-04.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch06-04.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch06-04.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 39.8576271186, "max_line_length": 98, "alphanum_fraction": 0.7298009866, "num_tokens": 3550, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4401625602428719}}
{"text": "\\documentclass[a4paper,11pt]{article}\n%\\usepackage{showlabels}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{pstricks}\n\\usepackage{fullpage}\n\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newcommand{\\GL}[1]{\\ensuremath{\\mathrm{GL}\\left(#1\\right)}}\n\\newcommand{\\Sym}[1]{\\ensuremath{\\mathrm{Sym}\\left(#1\\right)}}\n\\newcommand{\\Aut}[1]{\\ensuremath{\\mathrm{Aut}\\left(#1\\right)}}\n\\newcommand{\\Vertex}[1]{\\ensuremath{V\\left(#1\\right)}}\n\\newcommand{\\Edge}[1]{\\ensuremath{E\\left(#1\\right)}}\n\\newcommand{\\pcyc}{\\mathbb{Z}/p\\mathbb{Z}}\n\\usepackage{verbatim}\n\\begin{document}\n\\title{Representing groups on graphs}\n\\author{Sagarmoy Dutta and Piyush P Kurur\\\\\n  Department of Computer Science and Engineering,\\\\\n  Indian Institute of Technology Kanpur,\\\\\n  Kanpur, Uttar Pradesh, India 208016\\\\\n  {\\tt \\{sagarmoy,ppk\\}@cse.iitk.ac.in}\n}\n\\date{}\n\\maketitle\n\n\\begin{abstract}\n  In this paper we formulate and study the problem of representing\n  groups on graphs. We show that with respect to polynomial time\n  turing reducibility, both abelian and solvable group\n  representability are all equivalent to graph isomorphism, even when\n  the group is presented as a permutation group via generators. On the\n  other hand, the representability problem for general groups on trees\n  is equivalent to checking, given a group $G$ and $n$, whether a\n  nontrivial homomorphism from $G$ to $S_n$ exists.  There does not\n  seem to be a polynomial time algorithm for this problem, in spite of\n  the fact that tree isomorphism has polynomial time algorithm.\n\\end{abstract}\n\n\\section{Introduction}\n\nRepresentation theory of groups is a vast and successful branch of\nmathematics with applications ranging from fundamental physics to\ncomputer graphics and coding theory \\cite{repRealworld}. Recently\nrepresentation theory has seen quite a few applications in computer\nscience as well.  In this article, we study some of the questions\nrelated to representation of finite groups on graphs.\n\nA representation of a group $G$ usually means a linear representation,\ni.e. a homomorphism from the group $G$ to the group $\\GL{V}$ of\ninvertible linear transformations on a vector space $V$.  Notice that\n$\\GL{V}$ is the set of \\emph{symmetries} or \\emph{automorphisms} of\nthe vector space $V$. In general, by a representation of $G$ on an\nobject $X$, we mean a homomorphism from $G$ to the automorphism group\nof $X$.  In this article, we study some computational problems that\narise in the representation of \\emph{finite groups} on graphs. Our\ninterest is the following group representability problem: Given a\ngroup $G$ and a graph $X$, decide whether $G$ has a nontrivial\nrepresentation on $X$. As expected this problem is closely connected\nto graph isomorphism: We show, for example, that the graph isomorphism\nproblem reduces to representability of abelian groups. In the other\ndirection we show that even for solvable groups the representability\non graphs is decidable using a graph isomorphism oracle. The\nreductions hold true even when the groups are presented as permutation\ngroups. One might be tempted to conjecture that the problem is\nequivalent to Graph Isomorphism. However we conjecture that this might\nnot be the case. The non-solvable version of this problem seems to be\nharder than graph isomorphism. For example, we were able to show that\nrepresentability of groups on trees, a class of graphs for which\nisomorphism is decidable in polynomial time, is as hard as checking\nwhether, given an integer $n$ and a group $G$, the symmetric group\n$S_n$ has a nontrivial subgroup homomorphic to $G$, a problem for\nwhich no polynomial time algorithm is known.\n\n\\section{Background}\n\nIn this section we review the group theory required for the rest of\nthe article. Any standard text book on group theory, for example the\none by Hall~\\cite{hall}, will contain the required results.\n\nWe use the following standard notation: The identity of a group $G$ is\ndenoted by $1$. In addition $1$ also stands for the singleton group\nconsisting of only the identity. For groups $G$ and $H$, $H \\leq G$\n(or $G\\geq H$) means that $H$ is a subgroup of $G$. Similarly by $H\n\\unlhd G$ (or $G\\unrhd H$) we mean $H$ is a \\emph{normal subgroup} of\n$G$.\n\nLet $G$ be any group and let $x$ and $y$ be any two elements. By the\n\\emph{commutator} of $x$ and $y$, denoted by $[x,y]$, we mean\n$xyx^{-1}y^{-1}$. The \\emph{commutator subgroup} of $G$ is the group\ngenerated by the set $\\{[x,y]|x,y \\in G\\}$. We denote the commutator\nsubgroup of $G$ by $G'$. The following is a well known result in group\ntheory~\\cite[Theorem 9.2.1]{hall}\n\n\\begin{theorem}\nThe commutator subgroup $G'$ is a normal subgroup of $G$ and $G/G'$ is\nabelian. Further for any normal subgroup $N$ of $G$ such that $G/N$ is\nabelian, $N$ contains $G'$ as a subgroup.\n\\end{theorem}\n\nA group is \\emph{abelian} if it is commutative, i.e. $g h = hg$ for\nall group elements $g$ and $h$. A group $G$ is said to be\n\\emph{solvable}~\\cite[Page 138]{hall} if there exists a decreasing\nchain of groups $G = G_0 \\rhd G_1 \\ldots \\rhd G_t = 1$ such that\n$G_{i+1}$ is the commutator subgroup of $G_i$ for all $0 \\leq i < t$.\n\nAn important class of groups that play a crucial role in graph\nisomorphism and related problems are permutation groups. We follow the\nnotation of Wielandt~\\cite{wielandt64finite} for permutation groups.\nLet $\\Omega$ be a finite set. The \\emph{symmetric group} on $\\Omega$,\ndenoted by $\\Sym{\\Omega}$, is the group of all permutations on the set\n$\\Omega$.  By a \\emph{permutation group} on $\\Omega$ we mean a\nsubgroup of the symmetric group $\\Sym{\\Omega}$. For any positive\ninteger $n$, we will use $S_n$ to denote the symmetric group on\n$\\{1,\\ldots, n\\}$. Let $g$ be a permutation on $\\Omega$ and let\n$\\alpha$ be an element of $\\Omega$. The image of $\\alpha$ under $g$\nwill be denoted by $\\alpha^g$. For a permutation group $G$ on\n$\\Omega$, the orbit of $\\alpha$ is denoted by $\\alpha^G$. Similarly if\n$\\Delta$ be a subset of $\\Omega$ then $\\Delta^g$ denotes the set $\\{\n\\alpha^g | \\alpha \\in \\Delta \\}$.\n\nAny permutation group $G$ on $n$ symbols has a generating set of size\nat most $n$. Thus for computational tasks involving permutation groups\nit is assumed that the group is presented to the algorithm via a small\ngenerating set. As a result, by efficient algorithms for permutation\ngroups on $n$ symbols we mean algorithms that take time polynomial in\nthe size of the generating set and $n$.\n\nLet $G$ be a subgroup of $S_n$ and let $G^{(i)}$ denote the subgroup\nof $G$ that fixes pointwise $j \\leq i$, i.e. $G^{(i)} = \\{ g | j^g =\nj, 1 \\leq j \\leq i \\}$. Let $C_i$ denote a right \\emph{transversal},\ni.e.  the set of right coset representative, for $G^{(i)}$ in\n$G^{(i-1)}$. The $\\cup_i C_i$ is a generating set for $G$ and is\ncalled the \\emph{strong generating set} for $G$. The corner stone for\nmost polynomial time algorithms for permutation group is the\nSchreier-Sims~\\cite{sims70computational,sims78some,furst80polynomialtime}\nalgorithm for computing the \\emph{strong generating set} of a\npermutation group $G$ given an arbitrary generating set. Once the\nstrong generating set is computed, many natural problems for\npermutation groups can be solved efficiently. We give a list of them\nin the next theorem.\n\n\\begin{theorem}\\label{thm-perm-polytime}\n  Given a generating set for $G$ there are polynomial time algorithms\n  for the following task.\n  \\begin{enumerate}\n  \\item Computing the strong generating set.\n  \\item Computing the order of $G$.\n  \\end{enumerate}\n\\end{theorem}\n\nBy a graph we mean a \\emph{finite undirected graph}. For a graph $X$,\n$\\Vertex{X}$ and $\\Edge{X}$ denotes the set of vertices and edges\nrespectively and $\\Aut{X}$ denotes the group of all\nautomorphisms of $X$, i.e. permutations on $\\Vertex{X}$ that maps\nedges to edges and non-edges to non-edges. \n\n\\begin{definition}[Representation]\n  A representation $\\rho$ from a group $G$ to a graph $X$ is a\n  homomorphism from $G$ to the automorphism group $\\Aut{X}$ of $X$.\n\\end{definition}\n\nAlternatively we say that $G$ acts on (the right) of $X$ via the\nrepresentation $\\rho$. When $\\rho$ is understood, we use $u^g$ to\ndenoted $u^{\\rho(g)}$. \n\nA representation $\\rho$ is \\emph{trivial} if all the elements of $G$\nare mapped to the identity permutation. A representation $\\rho$ is\nsaid to be \\emph{faithful} if it is an injection as well. Under a\nfaithful action $G$ can be thought of as a subgroup of the\nautomorphism group. We say that $G$ is \\emph{representable} on $X$\n if there is a nontrivial representation from $G$ to\n$X$. We now define the following natural computational problem.\n\n\\begin{definition}[Group representability problem]\n  Given a group $G$ and a graph $X$ decide whether $G$ is\n  representable on $X$ nontrivially.\n\\end{definition}\n\nWe will look at various restrictions of the above problem. For example,\nwe study the abelian (solvable) group representability problem where\nour input groups are abelian (solvable). We also study the group\nrepresentability problem on trees, by which we mean group\nrepresentability where the input graph is a tree.\n\nDepending on how the group is presented to the algorithm, the\ncomplexity of the problem changes. One possible way to present $G$ is\nto present it as a permutation group on $m$ symbols via a generating\nset. In this case the input size is $m + \\# V(X)$. On the other hand,\nwe can make the task of the algorithm easier by presenting the group\nvia a multiplication table. In this paper we mostly assume that the\ngroup is in fact presented via its multiplication table. Thus\npolynomial time means polynomial in $\\# G$ and $\\# V(X)$. However for\nsolvable representability problem, our results extend to the case when\n$G$ is a permutation group presented via a set of generators.\n\nWe now look at the following closely related problem that occurs\nwhen we study the representability of groups on trees.\n\n\\begin{definition}[Permutation representability problem] \n  \\label{def-perm-representability}\n  Given a group $G$ and an integer $n$ in unary, check whether there is\n  a homomorphism from $G$ to $S_n$.\n\\end{definition}\n\n\\subsection*{Overview of the results}\n\nOur first result is to show that graph isomorphism reduces to abelian\nrepresentability problem. In fact we show that graph isomorphism\nreduces to the representability of prime order cyclic groups on\ngraphs. Next we show that solvable group representability problem\nreduces to graph isomorphism problem. Thus as far as polynomial time\nTuring reducibility is concerned abelian group representability and\nsolvable group representability are all equivalent to graph\nisomorphism. As a corollary we have, solvable group representability on\nsay bounded degree graphs or bounded genus graphs are all in\npolynomial time.\n\nWe then show that group representability on trees is equivalent to\npermutation representability\n(Definition~\\ref{def-perm-representability}). This is in contrast to\nthe corresponding isomorphism problem because for trees, isomorphism\ntesting is in polynomial time whereas permutation representability\nproblem does not appear to have a polynomial time algorithm.\n\n\\section{Abelian representability}\n\nIn this section we prove that the graph isomorphism problem reduces to\nabelian group representability on graph. Given input graphs $X$ and\n$Y$ of $n$ vertices each and any prime $p > n$, we construct a graph\n$Z$ of exactly $p \\cdot n$ vertices such that $X$ and $Y$ are\nisomorphic if and only if the cyclic group of order $p$ is\nrepresentable on $Z$. Since for any integer $n$ there is a\nprime $p$ between $n$ and $2n$ (Bertrand's conjecture), the above\nconstructions gives us a reduction from the graph isomorphism problem\nto abelian group representability problem.\n\nFor the rest of the section, fix the input graphs $X$ and $Y$. Our\ntask is to decide whether $X$ and $Y$ are isomorphic.  Firstly we\nassume, without loss of generality, that the graphs $X$ and $Y$ are\nconnected, for otherwise we can take their complement graphs $X'$ and\n$Y'$, which are connected and are isomorphic if and only if $X$ and\n$Y$ are isomorphic. Let $n$ be the number of vertices in $X$ and $Y$\nand let $p$ be any prime greater than $n$. Consider the graph $Z$\nwhich is the disjoint union of $p$ connected components\n$Z_1,\\ldots,Z_p$ where, for each $1 \\leq i < p$, each $Z_i$ is an\nisomorphic copy of $X$ and $Z_p$ is an isomorphic copy of $Y$. First\nwe prove the following lemma.\n\n\\begin{lemma}\\label{lem-gigrepf}\n  If $X$ and $Y$ are isomorphic then $\\pcyc$ is representable\n  on $Z$.\n\\end{lemma}\n\\begin{proof}\n  Clearly it is sufficient to show that there is an order $p$\n  automorphism for $Z$. Let $h$ be an isomorphism from $X$ to $Y$. For\n  every vertex $v$ in $X$, let $v_i$ denote its copy in\n  $Z_i$. Consider the bijection $g$ from $V(Z)$ to itself defined as\n  follows: For all vertices $v$ in $V(X)$ and each $1 \\leq i < p - 2$,\n  let $v_i^g = v_{i+1}$. Further let $g$ map $v_{p-1}$ to $v^h$ and\n  $v^h$ to $v_1$. It is easy to verify that $g$ is an automorphism of\n  $Z$ and has order $p$.\n\\end{proof}\n\nWe now prove the converse\n\\begin{lemma}\\label{lem-gigrepb}\n  If $\\pcyc$ can be represented on $Z$ then $X$ and $Y$ are\n  isomorphic.\n\\end{lemma}\n\\begin{proof}\n  If $\\pcyc$ can be represented on $Z$ then there exists a nonidentity\n  automorphism $g$ of $Z$ such that order of $g$ is $p$. We consider\n  the action of the cyclic group $H$, generated by $g$, on $V(X)$. Since\n  $g$ is nontrivial, there exists at least one $H$-orbit $\\Delta$ of\n  $V(X)$ which is of cardinality greater than $1$. However by orbit\n  stabiliser formula \\cite[Theorem 3.2]{wielandt64finite}, $\\# \\Delta$\n  divides $\\# H = p$. Since $p$ is prime, $\\Delta$ should be of\n  cardinality $p$.\n\n  We prove that no two vertices of $\\Delta$ belong to the same\n  connected component. Assume the contrary and let $\\alpha$ and\n  $\\beta$ be two elements of $\\Delta$ which also belong to the same\n  connected component of $Z$. There is some $0 < t < p$ such that\n  $\\alpha^{g^t} = \\beta$. We assume further, without loss of\n  generality, that $t=1$, for otherwise we replace $g$ by the\n  automorphism $g^t$, which is also of order $p$, and carry out the\n  argument. Therefore $\\alpha^g = \\beta$ lie in the same component of\n  $Z$. It follows then that, for each $0 \\leq i \\leq p -1 $, the element\n  $\\alpha_i = \\alpha^{g^i}$ is in the same component of $Z$, as\n  automorphisms preserve edges and hence paths. However this means\n  that there is a component of $Z$ that is of cardinality at least\n  $p$. This is a contradiction as each component of $Z$ has at most $n\n  < p$ vertices as they are copies of either $X$ or $Y$.\n\n  It follows that there is some $1 \\leq i < p$, for which $g$ must map\n  at least one vertex of the component $Z_i$ to some vertex of\n  $Z_p$. As a result the automorphism $g$ maps the entire component\n  $Z_i$ to $Z_p$.  Therefore the components $Z_i$ and $Z_p$ are\n  isomorphic and so are their isomorphic copies $X$ and $Y$.\n\\end{proof}\n\nGiven two graphs $X$ and $Y$ of $n$ vertices we find a prime $p$ such\nthat $n < p < 2n$, construct the graph $Z$ and construct the\nmultiplication table for $\\pcyc$. This requires only logarithmic space\nin $n$. Using Lemmas~\\ref{lem-gigrepf} and \\ref{lem-gigrepb} we have\nthe desired reduction.\n\n\\begin{theorem}\n  The graph isomorphism problem logspace many-one reduces to abelian\n  group representability problem.\n\\end{theorem}\n\n\\section{Solvable representability problem}\n\nIn the previous section we proved that abelian group representability\nis at least as hard as graph isomorphism. In this section we show that\nsolvable group representability is polynomial time Turing reducible to\nthe graph isomorphism problem. We claim that a solvable group $G$ is\nrepresentable on $X$ if and only if $\\# \\Aut{X}$ and $\\# G/G'$ have a\ncommon prime factor, where $G'$ is commutator subgroup of $G$. We do\nthis in two stages.\n\n\\begin{lemma}\\label{lem-solf}\n  A solvable group $G$ can be represented on a graph $X$ if $\\#G/G'$\n  and $\\#\\Aut{X}$ have a common prime factor.\n\\end{lemma}\n\\begin{proof}\n\nFirstly notice that it suffices to prove that there is a nontrivial\nhomomorphism, say $\\rho$, from $G/G'$ to $\\Aut{X}$. A nontrivial\nrepresentation for $G$ can be obtained by composing the natural\nquotient homomorphism from $G$ \\emph{onto} $G/G'$ with $\\rho$.\n\nRecall that the quotient group $G/G'$ is an abelian group and hence\ncan be represented on $X$ if for some prime $p$ that divides $\\#\nG/G'$, there is an order $p$ automorphism for $X$. However by the\nassumption of the theorem, there is a common prime factor, say $p$, of\n$\\# G/G'$ and $\\# \\Aut{X}$. Therefore, by Cayley's theorem there is an\norder $p$ element in $\\Aut{X}$. As a result, $G/G'$ and hence $G$ is\nrepresentable on $X$.\n\\end{proof}\n\nTo prove the converse, for the rest of the section fix the input, the\nsolvable group $G$ and the graph $X$. Consider any nontrivial\nhomomorphism $\\rho$ from the group $G$ to $\\Aut{X}$. Let $H \\leq\n\\Aut{X}$ denote the image of the group $G$ under $\\rho$. We will from\nnow on consider $\\rho$ as an automorphism from $G$ \\emph{onto}\n$H$. Since the subgroup $H$ is the homomorphic image of $G$, $H$\nitself is a solvable group.\n\n\\begin{lemma}\\label{comm}\nThe homomorphism $\\rho$ maps the commutator subgroup $G'$ of $G$\n\\emph{onto} the commutator subgroup $H'$.\n\\end{lemma}\n\\begin{proof}\n  First we prove that $\\rho(G') \\leq H'$. For this notice that for all\n  $x$ and $y$ in $G$, since $\\rho$ is a homomorphism, $\\rho([x,y]) =\n  [\\rho(x),\\rho(y)]$ is an element of $H'$. As $G'$ is generated by\n  the set $\\{ [x,y] | x,y \\in G\\}$ of all commutators, $\\rho(G') \\leq\n  H'$.  To prove the converse notice that $\\rho$ is a surjection on\n  $H$.  Therefore for any element $h$ of $H$, we have element $x_h$ of\n  $G$ such that $\\rho(x_h) = h$. Consider the commutator $[g,h]$ for\n  any two elements $g$ and $h$ of $H$. We have $\\rho([x_g,x_h]) =\n  [g,h]$.  This proves that all the commutators of $H$ are in the\n  image of $G'$ and hence $\\rho(G') \\geq H'$.\n\\end{proof}\n\nWe have the following result about solvable groups that directly\nfollows from the definition of solvable groups \\cite[Page 138]{hall}.\n\n\\begin{lemma}\\label{lem-nontrivial-govergprime}\n  Let $G$ be any nontrivial solvable group then its commutator\n  subgroup $G'$ is a strict subgroup of $G$.\n\\end{lemma}\n\\begin{proof}\n  By the definition of solvable groups, there exist a chain $G = G_0\n  \\rhd G_1 \\ldots \\rhd G_t = 1$ such that $G_{i+1}$ is the commutator\n  subgroup of $G_i$ for all $0 \\leq i < t$. If $G=G'=G_1$ then $G=G_i$\n  for all $0 \\leq i \\leq t$ implying $G=1$\n\\end{proof}\n\nWe are now ready to prove the converse of Lemma~\\ref{lem-solf}.\n\n\\begin{lemma}\\label{lem-solb}\n  Let $G$ be any solvable group and let $X$ be any graph. The orders\n  $\\#G/G'$ and $\\#\\Aut{X}$ have a common prime factor if $G$ is\n  representable on graph $X$.\n\\end{lemma}\n\\begin{proof}\n  Let $\\rho$ be any nontrivial homomorphism from $G$ to $\\Aut{X}$, and\n  let $H$ be the image of group $G$ under this homomorphism. Since the\n  commutator subgroup $G'$ is strictly contained in the group $G$\n  (Lemma~\\ref{lem-nontrivial-govergprime}), order of the quotient\n  group $\\#G/G' >1$. Furthermore, the image group $H$ itself is\n  solvable and nontrivial, as it is the image of a solvable group $G$\n  under a nontrivial homomorphism. Therefore, the commutator subgroup\n  $H'$ is strictly contained in $H$ implying $\\#H/\\#H'>1$.\n\n  Consider the homomorphism $\\tilde{\\rho}$ from $G$ \\emph{onto} $H/H'$\n  defined as $\\tilde{\\rho}(g) = \\rho(g) H'$. Since $\\rho$ maps $G'$\n  onto $H'$, we have that $G'$ is in the kernel of\n  $\\tilde{\\rho}$. Therefore, $\\tilde{\\rho}$ can be \\emph{refined} to a\n  map from $G/G'$ \\emph{onto} $H/H'$. Clearly the prime factors of $\\#\n  H/H'$ are all prime factors of $\\# G/G'$. However, any prime factor\n  of $\\# H/H'$ is a prime factor of $\\Aut{X}$, as both $H$ and $H'$\n  are subgroups of $\\Aut{X}$. Therefore, the orders of $G/G'$ and\n  $\\Aut{X}$ have a common prime factor.\n\\end{proof}\n\nThe order of the automorphism group of the input graph $X$ can be\ncomputed in polynomial time using an oracle to the graph isomorphism\nproblem~\\cite{mathon79note}. Further since the automorphism group is a\nsubgroup of $S_n$, where $n$ is the cardinality of $V(X)$, all its\nprime factors are less than $n$ and hence can be determined. Also\nsince $G$ is given as a table, its commutator subgroup $G'$ can be\ncomputed in polynomial time and the prime factors of $\\# G/G'$ can\nalso be similarly determined.  Therefore we can easily check, given\nthe group $G$ via its multiplication table and the graph $X$, whether\nthe order of the quotient group $G/G'$ has common factors with the\norder of $\\Aut{X}$. We thus have the following theorem.\n\n\\begin{theorem}\\label{thm-solvable-to-gi}\n  The problem of deciding whether a solvable group can be represented\n  on a given graph reduces to graph isomorphism problem.\n\\end{theorem}\n\nFor the reduction in the above theorem to work, it is sufficient to\ncompute the order of $G$ and its commutator subgroup $G'$. This can be\ndone even when the group $G$ is presented as a permutation group on\n$m$ symbols via a generating set. To compute $\\# G$ we can compute the\nstrong generating set of $G$ and use\nTheorem~\\ref{thm-perm-polytime}. Further given a generating set for\n$G$, a generating set for its commutator subgroup $G'$ can be compute\nin polynomial time~\\cite[Theorem 4]{furst80polynomialtime}. Therefore,\nthe order of $G/G'$ can be computed in polynomial time given the\ngenerating set for $G$. Furthermore, $G$ and $G'$ are subgroups of\n$S_m$ and hence all their prime factors are less than $m$ and can\nbe determined. We can then check whether $\\# G/G'$ has any common\nprime factors with $\\# \\Aut{X}$ just as before using the graph isomorphism\noracle. Thus we have the following theorem.\n\n\\begin{theorem}\n  The solvable group representability problem, where the group is\n  presented as a permutation group via a generating set, reduces to\n  the graph isomorphism problem via polynomial time Turing reduction.\n\\end{theorem}\n\n\\section{Representation on tree}\\label{sect-tree-representability}\n\nIn this section we study the representation of groups on trees. It is\nknown that isomorphism of trees can be tested in polynomial\ntime~\\cite{babai83canonical}. However we show that the group\nrepresentability problem over trees is equivalent to permutation\nrepresentability problem (Definition~\\ref{def-perm-representability}),\na problem for which, we believe, there is no polynomial time\nalgorithm.\n\nFirstly, to show that permutation representability problem is\nreducible to group representability problem on trees, it is sufficient\nto construct, given and integer $n$, a tree whose automorphism group\nis $S_n$. Clearly a tree with $n$ leaves, all of which is connected to\nthe root, gives such a tree (see\nFigure~\\ref{fig-tree-with-sn}). Therefore we have the following lemma.\n\\begin{lemma}\\label{lemsn2tree}\nPermutation representability reduces to representability on tree.\n\\end{lemma}\n\n\\begin{figure}[h!]\n\\begin{center}\n\\begin{pspicture}(3,1.3)\n%\\psgrid\n\\psline{*-*}(1.5,1.2)(0.1,0.1)\n\\psline{-*}(1.5,1.2)(0.7,0.1)\n\\psline{-*}(1.5,1.2)(1.3,0.1)\n\\psline{-*}(1.5,1.2)(2.9,0.1)\n\\rput(1.8,0.1){$\\ldots$}\n\\end{pspicture}\n\\end{center}\n\\caption{Tree with automorphism group $S_n$}\\label{fig-tree-with-sn}\n\\end{figure}\n\nTo prove the converse, we first reduce the group representability\nproblem on an arbitrary tree to the problem of representability on a\nrooted tree. We then do a divide and conquer on the structure of the\nrooted tree using the permutation representability oracle. The main\nidea behind this reduction is Lemma~\\ref{lem-edge} where we show that for any\ntree $T$, either there is a vertex which is fixed by all automorphism,\nin which case we can choose this vertex as the root, or there are two\nvertices $\\alpha$ and $\\beta$ connected by an edge which together\nforms an orbit under the action of $\\Aut{T}$, in which case we can add\na dummy root (see Figure~\\ref{fig-maximal-orbit}) to make it a rooted\ntree without changing the automorphism group.\n\n\\begin{figure}[h!]\n\\begin{center}\n\\begin{pspicture}(9,2.2)\n%\\psgrid\n\\psline{*-*}(1,1.4)(3,1.4)\n\\pspolygon(1,1.4)(0.3,0.1)(1.7,0.1)\n\\pspolygon(3,1.4)(2.3,0.1)(3.7,0.1)\n\\rput[b](1,1.5){$\\alpha$} \\rput[b](3,1.5){$\\beta$}\n\\psline{*-*}(6,1.4)(7,1.8)\n\\psline{-*}(7,1.8)(8,1.4)\n\\pspolygon(6,1.4)(5.3,0.1)(6.7,0.1)\n\\pspolygon(8,1.4)(7.3,0.1)(8.7,0.1)\n\\rput[b](6,1.5){$\\alpha$} \\rput[b](8,1.5){$\\beta$} \\rput[b](7,1.9){$\\gamma$}\n\\end{pspicture}\n\\end{center}\n\\caption{Minimal orbit has two elements}\\label{fig-maximal-orbit}\n\\end{figure}\n\nFor the rest of the section fix a tree $T$.  Let $\\Delta$ be an orbit\nin the action of $\\Aut{T}$ on $V(T)$.  We define the graph $T_\\Delta$\nas follows: A vertex $\\gamma$ (or edge $e$) of $T$ belongs to\n$T_\\Delta$ if there are two vertices $\\alpha$ and $\\beta$ in $\\Delta$\nsuch that $\\gamma$ (or $e$) is contained in the path from $\\alpha$ to\n$\\beta$. It is easy to see that $T_\\Delta$ contains paths between any\ntwo vertices of $\\Delta$. Any vertex in $T_{\\Delta}$ is connected to\nsome vertex in $\\Delta$ and all vertices in $\\Delta$ are connected in\n$T_{\\Delta}$ which implies $T_{\\Delta}$ is connected. Furthermore\n$T_\\Delta$ has no cycle, as its edge set is a subset of the edge set\nof $T$. Therefore $T_\\Delta$ is a tree.\n\n\\begin{lemma}\n  Let $g$ be any automorphism of $T$ and consider any vertex $\\gamma$\n  (or edge $e$) of $T_\\Delta$. Then the vertex $\\gamma^g$ (or edge\n  $e^g$) is also in $T_\\Delta$.\n\\end{lemma}\n\\begin{proof}\n  Since $\\gamma$ (or $e$) is present in $T_\\Delta$, there exists\n  $\\alpha$ and $\\beta$ in $\\Delta$ such that $\\gamma$ (or $e$) is in\n  the path between $\\alpha$ and $\\beta$. Also since automorphisms\n  preserve paths, $\\gamma^g$ (or $e^g$) is in the path from\n  $\\alpha^g$ to $\\beta^g$.\n\\end{proof}\n\n\\begin{lemma}\\label{lemleaf}\n  The orbit $\\Delta$ is precisely the set of leaves of $T_{\\Delta}$.\n\\end{lemma}\n\\begin{proof}\n  First we show that all leaf nodes of $T_{\\Delta}$ are in orbit\n  $\\Delta$. Any node $\\alpha$ of $T_{\\Delta}$ must lie on a path such\n  that the endpoints are in orbit $\\Delta$. If $\\alpha$ is a leaf of\n  $T_{\\Delta}$, this can only happen when $\\alpha$ itself is in\n  $\\Delta$.\n\n  We will prove the converse by contradiction. If possible let\n  $\\alpha$ be a vertex in the orbit $\\Delta$ which is not a leaf of\n  $T_{\\Delta}$. Vertex $\\alpha$ must lie on the path between two\n  leaves $\\beta$ and $\\gamma$. Also since $\\beta$ and $\\gamma$ are\n  leaves of $T_\\Delta$, they are in the orbit $\\Delta$.\n\n  Let $g$ be an automorphism of $T$ which maps $\\alpha$ to $\\beta$.\n  Such an automorphism exists because $\\alpha$ and $\\beta$ are in the\n  same orbit $\\Delta$. The image $\\alpha^g=\\beta$ must lie on the path\n  between $\\beta^g$ and $\\gamma^g$ and neither $\\beta^g$ or $\\gamma^g$\n  is $\\beta$. This is impossible because $\\beta$ is a leaf of\n  $T_\\Delta$. \n\\end{proof}\n\n\\begin{lemma}\\label{lem-subtree}\n  Let $\\gamma$ be a vertex in orbit $\\Sigma$. If $\\gamma$ is a vertex\n  of the subtree $T_{\\Delta}$ then subtree $T_{\\Sigma}$ is a subtree\n  of $T_{\\Delta}$.\n\\end{lemma}\n\\begin{proof}\n  Assume that $\\Delta$ is different from $\\Sigma$, for otherwise the\n  proof is trivial. First we show that all the vertices of $\\Sigma$\n  are vertices of $T_\\Delta$. The vertex $\\gamma$ lies on a path\n  between two vertices of $\\Delta$, say $\\alpha$ and $\\beta$. Take any\n  vertex $\\gamma'$ from the orbit $\\Sigma$. There is an automorphism\n  $g$ of $T$ which maps $\\gamma$ to $\\gamma'$. Now $\\gamma'=\\gamma^g$\n  lies on the path between $\\alpha^g$ and $\\beta^g$ and hence is in\n  the tree $T_\\Delta$.\n\n  Consider any edge $e$ of $T_\\Sigma$. There exists $\\gamma_1$ and\n  $\\gamma_2$ of $\\Sigma$ such that $e$ is on the path from $\\gamma_1$\n  to $\\gamma_2$. By previous argument, $T$ contains $\\gamma_1$ and\n  $\\gamma_2$. Since $T$ is a tree, this path is unique and any\n  subgraph of $T$, in which $\\gamma_1$ and $\\gamma_2$ are connected,\n  must contain this path. Hence $T_{\\Delta}$ contains $e$.\n\\end{proof}\n\n\\begin{lemma}\\label{lem-edge}\n  Let $T$ be any tree then either there exists a vertex $\\alpha$ that\n  is fixed by all the automorphisms of $T$ or there exists two\n  vertices $\\alpha$ and $\\beta$ connected via an edge $e$ such that\n  $\\{ \\alpha,\\beta\\}$ is an orbit of $\\Aut{T}$. In the latter case\n  every automorphism maps $e$ to itself.\n\\end{lemma}\n\n%% \\begin{proof}[Proof of lemma \\ref{lemedge}]\n%% First we prove the existence of such an orbit. Take any vertex\n%% $\\alpha$ belonging to orbit $\\Delta$. If $T_{\\Delta}$ has more than 2\n%% vertices then there must be a nonleaf $\\beta$ in $T_{\\Delta}$. Let\n%% $\\Sigma$ be the orbit of $\\beta$. Lemma \\ref{lemleaf} ensures that\n%% $\\Delta\\not=\\Sigma$ and by lemma \\ref{lemsubtree} $T_{\\Sigma}$ is\n%% proper subtree of $T_{\\Delta}$. Thus we can continue constructing\n%% smaller and smaller subtrees until it has less than vertices. Since\n%% each orbit contains more than one vertices, there is an orbit such\n%% that the corresponding subtree has 2 leaves and an edge between them.\n\n%% Now we show that there is only one such orbit. If possible let there\n%% be two such orbit $\\{\\alpha,\\alpha'\\}$ and $\\{\\beta,\\beta'\\}$. Without\n%% loss of generality let us assume that the path between $\\alpha$ and\n%% $\\beta$ does not contain $\\alpha'$ or $\\beta'$, otherwise could choose\n%% $\\alpha'$ or $\\beta'$ instead of $\\alpha$ or $\\beta$\n%% respectively. There is an automorphism $g$ of $T$ which maps $\\alpha$\n%% to $\\alpha'$. The same automorphism also maps $\\beta$ to either\n%% $\\beta'$ or $\\beta$ itself. Now since the paths from $\\alpha'$ to\n%% $\\beta$ or $\\beta'$ must pass through $\\alpha$, the path length of\n%% between $\\alpha^g$ and $\\beta^g$ is more than the path length between\n%% $\\alpha$ and $\\beta$. But, since $g$ is an automorphism, the\n%% pathlengths must be same. Hence we have a contradiction.\n%% \\end{proof}\n\n\\begin{proof}\n  Consider the following partial order between orbits of $\\Aut{T}$:\n  $\\Sigma \\leq \\Delta$ if $T_\\Sigma$ is a subtree of $T_\\Delta$. The\n  relation $\\leq$ is clearly a partial order because the ``subtree''\n  relation is.  Since there are finitely many orbits there is always a\n  minimal orbit under the above ordering.  From Lemmas~\\ref{lemleaf}\n  and \\ref{lem-subtree} it follows that for an orbit $\\Delta$, if\n  $\\Sigma$ is the orbit containing an internal node $\\gamma$ of\n  $T_\\Delta$ then $\\Sigma$ is strictly less than $\\Delta$. Therefore\n  for any minimal orbit $\\Delta$, all the nodes are leaves. This is\n  possible if either $T_\\Delta$ is a singleton vertex $\\alpha$, or\n  consists of exactly two nodes connected via an edge. In the former\n  case all automorphisms of $T$ have to fix $\\alpha$, whereas in the\n  latter case the two nodes may be flipped but the edge connecting\n  them has to be mapped to itself.\n\\end{proof}\n\nIt follows from Lemma~\\ref{lem-edge} that any tree $T$ can be rooted,\neither at a vertex or at an edge with out changing the automorphism.\nGiven a tree $T$, since computing the generating set for $\\Aut{T}$ can\nbe done in polynomial time, we can determine all the orbits of\n$\\Aut{T}$ by a simple transitive closure algorithm. Having computed\nthese orbits, we determine whether $T$ has singleton orbit or an orbit\nof cardinality $2$. For trees with an orbit containing a single vertex\n$\\alpha$, rooting the tree at $\\alpha$ does not change the\nautomorphism group. On the other hand if the tree has an orbit with\ntwo elements we can add a dummy root as in\nFigure~\\ref{fig-maximal-orbit} without changing the automorphism\ngroup. Since by Lemma~\\ref{lem-edge} these are the only two\npossibilities we have the following theorem.\n\n\\begin{theorem}\n  There is a polynomial time algorithm that, given as input a tree $T$,\n  outputs a rooted tree $T'$ such that for any group $G$, $G$ is\n  representable on $T$ if and only if $G$ is representable on the rooted tree\n  $T'$.\n\\end{theorem}\n\nFor the rest of the section by a tree we mean a rooted tree. We will\nprove the reduction from representability on rooted trees to\npermutation representability. First we characterise the automorphism\ngroup of a tree in terms of wreath product [Theorem \\ref{thmtreeauto}]\nand then show that we can find a nontrivial homomorphism, if there\nexists one, from the given group $G$ to this automorphism group by\nquerying a permutation representability oracle.\n\n\\begin{definition}[Semidirect product and wreath product]\n  Let $G$ and $A$ be any two group and let $\\varphi$ be any\n  homomorphism from $G$ to $\\Aut{A}$, then the semi-direct product\n  $G\\ltimes_\\varphi A$ is the group whose underlying set is $G\\times\n  A$ and the multiplication is defined as $(g,a) (h,b) = (gh,\n  a^{\\varphi(h)}b)$.\n  \n  We use $W_n(A)$ to denote the wreath product $S_n \\wr A$ which is\n  the semidirect product $S_n\\ltimes_\\varphi A^n$, where $A^n$ is the\n  $n$-fold direct product of $A$ and ${\\varphi(h)}$, for each $h$ in\n  $S_n$, permutes $\\mathbf{a} \\in A^n$ according to the permutation\n  $h$, i.e. maps $(\\ldots,a_i,\\ldots) \\in A^n$ to\n  $(\\ldots,a_{j},\\ldots)$ where $j^h = i$.\n\\end{definition}\n\nAs the wreath product is a semidirect product, we have the following\nlemma.\n\n\\begin{lemma}\\label{lem-wreath-property}\n  The wreath product $W_n(A)$ contains (isomorphic copies of) $S_n$\n  and $A^n$ as subgroups such that $A^n$ is normal and the quotient\n  group $W_n(A)/A^n=S_n$.\n\\end{lemma}\n\nFor the rest of the section fix the following: Let $T$ be a tree with\nroot $\\omega$ with $k$ children. Consider the subtrees of $T$ rooted\nat each of these $k$ children and partition them such that two\nsubtrees are in the same partition if and only if they are\nisomorphic. Let $t$ be the number of partitions and let $k_i$, for $(1\n\\leq i \\leq t)$, be the number of subtrees in the $i$-th\npartition. For each $i$, pick a representative subtree $T_i$ from the\n$i$-th partition and let $A_i$ denote the automorphism group of\n$T_i$. The following result is well known but a proof is given for\ncompleteness.\n\n\\begin{theorem}\\label{thmtreeauto}\n  The automorphism group of the tree $T$ is (isomorphic to) the direct\n  product $\\prod_{i=1}^t W_{k_i}(A_i)$.\n\\end{theorem}\n\\begin{proof}\n  Let $\\omega_1,\\ldots,\\omega_k$ be the children of the root $\\omega$\n  and let $X_i$ denote the subtree rooted at $\\omega_i$. We first\n  consider the case when $t=1$, i.e. all the subtrees $X_i$ are\n  isomorphic. Any automorphism $g$ of $T$ must permute the children\n  $\\omega_i$'s among themselves and whenever $\\omega_i^g = \\omega_j$,\n  the entire subtree $X_i$ maps to $X_j$.  As all the subtrees $X_i$\n  are isomorphic to $T_1$, the forest $\\{X_1,\\ldots, X_k\\}$ can be\n  thought of as the disjoint union of $k$ copies of the tree $T_1$ by\n  fixing, for each $i$, an isomorphism $\\sigma_i$ from $T_1$ to $X_i$.\n  \n  For an automorphism $g$ of $T$, define the permutation $\\tilde{g}\\in\n  S_k$ and the automorphisms $a_i(g)$ of $T_1$ as follows: if\n  $\\omega_i^g = \\omega_j$ then $i^{\\tilde{g}} = j$ and $a_i(g) =\n  \\sigma_i g \\sigma_j^{-1}$.  Consider the map $\\phi$ from $\\Aut{T}$\n  to $W_k(A)$ which maps an automorphism $g$ to the group element\n  $(\\tilde{g},a_1(g),\\ldots,a_k(g))$ in $W_k (A)$.  It is easy to\n  verify that $\\phi$ is the desired isomorphism.\n\n  When the number of partitions $t$ is greater than $1$, any\n  automorphism of $T$ fixes the root $\\omega$ and permutes the\n  subtrees in the $i$-th partition among themselves. Therefore the\n  automorphism group of $T$ is same as the automorphism group of the\n  collection of forests $F_i$ one for each partition $i$. Each forest\n  is a disjoint union of $k_i$ copies of $T_i$ and we can argue as\n  before that its automorphism group is (isomorphic to)\n  $W_{k_i}(A)$. Therefore $\\Aut{T}$ should be the direct product\n  $\\prod_{i=1}^t W_{k_i}(A_i)$.\n\\end{proof}\n\n\n\n\\begin{lemma}\\label{lem-break1}\n  If the group $G$ can be represented on the tree $T$, then there\n  exists $1\\leq i \\leq t$ such that there is a nontrivial homomorphism\n  from $G$ to $W_{k_i}(A_i)$.\n\\end{lemma}\n\n\\begin{proof}\n  If there is a nontrivial homomorphism from a group $G$ to the direct\n  product of groups $H_1,\\ldots,H_t$ then for some $i$, $1 \\leq i \\leq\n  t$, there is a nontrivial homomorphism from $G$ to $H_i$. The lemma\n  then follows from Theorem \\ref{thmtreeauto}.\n\\end{proof}\n\n\\begin{lemma}\\label{lem-break2}\n  If there is a nontrivial homomorphism $\\rho$ from a group $G$ to\n  $W_n(A)$ then there is also a nontrivial homomorphism from $G$\n  either to $S_n$ or to $A$.\n\\end{lemma}\n\\begin{proof}\n  Let $\\rho$ be a nontrivial homomorphism $G$ to $W_n(A)$. Since $A^n$\n  is a normal subgroup of $W_n(A)$ and the quotient group $W_n(A)/A^n$\n  is $S_n$, there is a homomorphism $\\rho'$ from $W_n(A)$ to $S_n$\n  with kernel $A^n$.  The composition of $\\rho$ and $\\rho'$ is a\n  homomorphism from $G$ to $S_n$.\n\n  If $\\rho'\\cdot\\rho$ is trivial then $\\rho'$ maps all elements of\n  $\\rho(G)$ to identity of $S_n$. Which imply that $\\rho(G)$ is a\n  subgroup of the kernel of $\\rho'$, that is $A^n$. So, $\\rho$ is a\n  nontrivial homomorphism from $G$ to $A^n$. Hence there must be a\n  nontrivial homomorphism from $G$ to $A$.\n\\end{proof}\n\n\\begin{theorem}\n  Given a group $G$ and a rooted tree $T$ with $n$ nodes and an oracle\n  for deciding whether $G$ has a nontrivial homomorphism to $S_m$ for\n  $1 \\leq m \\leq n$, it can be decided in polynomial time whether $G$\n  can be represented on $T$.\n\\end{theorem}\n\n\\begin{proof}\n  If the tree has only one vertex then reject. Otherwise let $t$,\n  $k_1,\\ldots, k_t$ and $A_1,\\ldots A_t$ be the quantities as defined\n  in Theorem~\\ref{thmtreeauto}. Since there is efficient algorithm to\n  compute tree isomorphism, $t$ and $k_1,\\ldots, k_t$ can be computed\n  in polynomial time. If $G$ is representable on $T$ then, by\n  Lemma~\\ref{lem-break1} and Lemma~\\ref{lem-break2}, there is a\n  nontrivial homomorphism from $G$ to either $S_{k_i}$ or $A_i$ for\n  some $i$. Using the oracle, check whether there is a nontrivial\n  homomorphism to any of the symmetric groups. If found then accept,\n  otherwise for all $i$, decide whether there is a nontrivial\n  homomorphism to $A_i$ by choosing a subtree $T_i$ from the $i^{th}$\n  partition and recursively asking whether $G$ is representable on\n  $T_i$. Total number of recursive calls is bounded by the number of\n  vertices of $T$. Hence the reduction is polynomial time.\n\\end{proof}\n\n\\section{Conclusion}\n\nIn this paper we studied the group representability problem, a\ncomputational problem that is closely related to graph\nisomorphism. The representability problem could be equivalent to graph\nisomorphism, but the results of\nSection~\\ref{sect-tree-representability} give some, albeit weak,\nevidence that this might not be the case. It would be interesting to\nknow what is the exact complexity of this problem vis a vis the graph\nisomorphism problem. We know from the work of\nMathon~\\cite{mathon79note} that the graph isomorphism problem is\nequivalent to its functional version where, given two graphs $X$ and\n$Y$, we have to compute an isomorphism if there exists one. The\nfunctional version of group representability, namely give a group $G$\nand a graph $X$ compute a nontrivial representation if it exists, does\nnot appear to be equivalent to the decision version. Also it would be\ninteresting to know if the representability problem shares some of\nlowness of graph\nisomorphism~\\cite{schoning87graph,kobler92graph,arvind2002graph}.  Our\nhope is that, like the study of group representation in geometry and\nmathematics, the study of group representability on graphs help us\nbetter understand the graph isomorphism problem.\n\n\\bibliographystyle{plain}\n\\bibliography{./bibdata}\n\n\\end{document}\n\nhttp://www.usna.edu/Users/math/wdj/repn_thry_appl.htm \n\n\n", "meta": {"hexsha": "8adecf7a84c5ba66a458aff618b78a136dda0ff0", "size": 40012, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "contents/research/publication/Conference/2009-07-09-Representation-Graph/grep.tex", "max_stars_repo_name": "piyush-kurur-pages/website", "max_stars_repo_head_hexsha": "246dfa730328b45b65840ebed3293e96c497aa86", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-04-16T09:55:17.000Z", "max_stars_repo_stars_event_max_datetime": "2017-04-16T09:55:17.000Z", "max_issues_repo_path": "contents/research/publication/Conference/2009-07-09-Representation-Graph/grep.tex", "max_issues_repo_name": "piyush-kurur-pages/website", "max_issues_repo_head_hexsha": "246dfa730328b45b65840ebed3293e96c497aa86", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "contents/research/publication/Conference/2009-07-09-Representation-Graph/grep.tex", "max_forks_repo_name": "piyush-kurur-pages/website", "max_forks_repo_head_hexsha": "246dfa730328b45b65840ebed3293e96c497aa86", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-11-10T22:18:56.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-10T22:18:56.000Z", "avg_line_length": 48.3821039903, "max_line_length": 77, "alphanum_fraction": 0.7229331201, "num_tokens": 11901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4401625596024642}}
{"text": "% Section: Related Work\n\\section{Related Work} \\label{sec:related}\n\\para{Gaussian Process Regression}\nRasmussen\\cite{rasmussen2006gaussian} and Williams\\cite{williams1998prediction} have a wonderful fundamental work on the introduction of Gaussian Process Regression.\n\n\n\n\\para{Kernel Choice}\nDuvenaud et.al introduce a GP model of functions which are additive\\cite{duvenaud2011additive}.\nAlong with Lloyd et.al, they introduce a way to automatic construct some desired kernels to better fit the dataset\\cite{duvenaud2013structure,duvenaud2014automatic}.\nThey also figure out an auto way to produce the Natural-Language description of a data structure\\cite{lloyd2014automatic}.\nIn this paper, we will give a precise introduction on the above work.\n\n\\para{Inference Methods}\nSome popular works on inference methods include\nMCMC\\cite{gamerman1997sampling},\nExpectation Propagation\\cite{minka2001expectation},\nVariational Bayes\\cite{palmer2006variational,nickisch2009convex},\nLeave-One-Out\\cite{fukunaga1989leave},\nand Laplace Approximation\\cite{tierney1986accurate},\netc.\nDue to the limited time and space, we won't go very deep into these inference methods.\\\\ \\\\", "meta": {"hexsha": "f2eab6ee7e3d1015dcf6f44fc1e7e29e8b9640ca", "size": 1160, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/related.tex", "max_stars_repo_name": "lzhbrian/gpr", "max_stars_repo_head_hexsha": "912c530fec02e4fe1a4d49b96e6fc3a25b2bdf3c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-02-08T13:38:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-07T02:26:12.000Z", "max_issues_repo_path": "tex/related.tex", "max_issues_repo_name": "lzhbrian/gpr", "max_issues_repo_head_hexsha": "912c530fec02e4fe1a4d49b96e6fc3a25b2bdf3c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/related.tex", "max_forks_repo_name": "lzhbrian/gpr", "max_forks_repo_head_hexsha": "912c530fec02e4fe1a4d49b96e6fc3a25b2bdf3c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.7272727273, "max_line_length": 165, "alphanum_fraction": 0.8275862069, "num_tokens": 288, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4401625556693915}}
{"text": "\\subsection{L-shaped bracket}\n\\label{subsection:l_shaped_bracket}\n\\paragraph{}\nIn this example, an L-shaped bracket with isotropic material properties is considered.\nFig.~\\ref{iso_fig:l_with_fillet_geo_bc} shows the geometry and the boundary conditions of the problem.\nThe L-shaped bracket is fixed at one end and subjected to downward vertical displacement at the other end.\nPlain strain conditions are assumed.\n    \\begin{figure}[h!]\n        \\centering\n        \\scalebox{0.6}{\n            \\includegraphics{isogeometric_sbfem/images/l_with_fillet_geo_bc.eps}\n        }\n        \\caption{Geometry and boundary conditions} \n        \\label{iso_fig:l_with_fillet_geo_bc}         \n    \\end{figure}\n%\nThe dimension of the example is: $L=\\SI{14}{\\meter}$, $W=\\SI{4}{\\meter}$ and $R=\\SI{1}{\\meter}$.\nWhile the material properties are: Young's modulus $E=\\SI{1e3}{\\mega\\pascal}$ and poisson's ratio $\\nu=0.3$.\nThis problem was studied in \\citep{LIPTON2010357} by employing the conventional IGA.\nIn their study, the fillet was modeled as a separate path using biquadratic NURBS with nine control points.\n\n\\paragraph{}\nIn the present study, the control mesh is directly employed for the stress analysis.\nHowever, as the domain does not meet the star convexity, we divide the domain into three subdomains (see Fig.~\\ref{iso_fig:l_with_fillet_mesh}).\nWe employ NURBS to represent the fillet, whilst for the straight lines, we employ Lagrange basis functions.\nThe results from the present approach are compared with conventional finite element analysis using the commercial\n    software ANSYS$^\\circledR$.\n    \\begin{figure}[h!]\n        \\centering\n        \\scalebox{0.6}{\n            \\includegraphics{isogeometric_sbfem/images/l_with_fillet_mesh.png}\n        }\n        \\caption{Control net where `filled' circles represents control points}\n        \\label{iso_fig:l_with_fillet_mesh}\n    \\end{figure}\n%\n\\paragraph{}\nA total of $2000$ $8$-node quadrilateral elements were used for the finite element analysis.\nFig.~\\ref{iso_fig:l_stress_contour} shows the von Mises equivalent stress for the L-shaped bracket with and without the fillet.\nAs expected, the no fillet case shows higher stress when compared to the L-shaped bracket with the fillet.\nFrom Fig.~\\ref{iso_fig:l_stress_contour}, it can be observed that the results from the present approach qualitatively match with the FE solution.\nIt should be noted that, the proposed method is computationally less intensive than the conventional IGA as it requires\n    only the boundary information.\n    \\begin{figure}[h!]\n        \\begin{subfigure}[b]{0.5\\linewidth}\n            \\centering\n            \\scalebox{0.5}{\n                \\includegraphics{isogeometric_sbfem/images/l_stress_contour_fem.png}\n            }\n            \\caption{FEM}\n        \\end{subfigure}\n        \\begin{subfigure}[b]{0.5\\linewidth}\n            \\centering\n            \\scalebox{0.5}{\n                \\includegraphics{isogeometric_sbfem/images/l_stress_contour_sbfem.png}\n            }\n            \\caption{Isogeometric SBFEM}\n        \\end{subfigure}\n\n        \\begin{subfigure}[b]{0.5\\linewidth}\n            \\centering\n            \\scalebox{0.5}{\n                \\includegraphics{isogeometric_sbfem/images/l_with_fillet_stress_contour_fem.png}\n            }\n            \\caption{FEM}\n        \\end{subfigure}\n        \\begin{subfigure}[b]{0.5\\linewidth}\n            \\centering\n            \\scalebox{0.5}{\n                \\includegraphics{isogeometric_sbfem/images/l_with_fillet_stress_contour_sbfem.png}\n            }\n            \\caption{Isogeometric SBFEM}\n        \\end{subfigure}\n        \\caption[Von Mises equivalent stress contours for L-shaped bracket without and with fillet]{Von Mises equivalent stress contours for L-shaped bracket without and with fillet. The stress values are in Mpa}\n        \\label{iso_fig:l_stress_contour}\n    \\end{figure}\n%\n\n%=================================================================================================================================%\n\\paragraph{}\nNext, we extend the present formulation to study the transient response of an L-shaped bracket.\nThe dimensions and the boundary conditions are shown in Fig.~\\ref{iso_fig:l_dynamic_geo_bc}.\n    \\begin{figure}\n        \\begin{subfigure}[b]{1\\linewidth}\n            \\centering\n            \\scalebox{0.8}{\n                \\includegraphics{isogeometric_sbfem/images/l_dynamic_geo_bc.eps}\n            }\n            \\caption{without fillet}\n        \\end{subfigure}\n        \\begin{subfigure}[b]{1\\linewidth}\n            \\centering\n            \\scalebox{0.8}{\n                \\includegraphics{isogeometric_sbfem/images/l_with_fillet_dynamic_geo_bc.eps}\n            }\n            \\caption{without fillet}\n        \\end{subfigure}\n        \\caption{L-shaped bracket: geometry and boundary conditions for transient analysis}\n        \\label{iso_fig:l_dynamic_geo_bc}\n    \\end{figure}\n%\n\\paragraph{}\nIn the example, $b=\\SI{1}{\\meter}$ and $r=\\SI{0.2}{\\meter}$.\nA state of plane stress is considered and the material properties are:\n    Young’s modulus $E = \\SI{1}{\\newton \\per \\square \\meter}$ , poisson’s ratio, $\\nu = 1/3$ and mass density, $\\rho = \\SI{1}{\\kilo \\gram \\per \\cubic \\meter}$.\n    The shear wave velocity is $c_s=\\SI[parse-numbers = false]{\\sqrt{3/8}}{\\meter \\per \\second}$\n    and the dilatational wave velocity $c_p=\\SI[parse-numbers = false]{\\sqrt{9/8}}{\\meter \\per \\second}$\nThe order of the continued fraction used in Eq.~\\ref{lr_eq:sbfem_dynamic_s_full} is chosen as $M_{cf} = 6$.\nA uniform pressure $p(t)$ is applied at the side BC of the bracket.\nThe pressure varies as a triangular impulse in the time domain.\nIt reaches a peak value $p$ at time $t= 0.5b/c_p$ , reduces to $0$ at $t = b/c_p$ and stays at $0$ afterwards.\nThe time integration is carried out by using Newmark's method with $\\gamma = 1/2$ and $\\beta = 1/4$.\nThe time step is chosen as $\\delta t = 0.025b/c_p$.\n\n\\paragraph{}\nThe calculation is performed for 3000 time steps.\nFor the Isogeometric-SBFEM, the arc is represented with quadratic NURBS functions and the straight lines are discretized with\n    Lagrange basis functions.\nAs the problem domain does not satisfy the star convexity, the domain is sub-divided into three subdomains as done in the static example.\nThe scaling center for each of the subdomain is placed at the center of the subdomain.\nTo demonstrate the efficacy of the present formulation, the results are compared with those obtained using the conventional\n    finite element method.\nA FE mesh leading to a similar accuracy is identified from a convergence study.\nThe FE analysis is performed with the commercial software ANSYS$^\\circledR$ (a total of 2000 8-node quadrilateral elements\n    were employed for this study).\n\n\\paragraph{}\nThe vertical displacement responses at point A are plotted in Fig.~\\ref{iso_fig:l_uy_dynamic_at_A} as a function of the dimensionless\n    time $T = c_pt/b$.\nIt can be seen that the results from the present formulation agree well with the finite element solution.\n    \\begin{figure}\n        \\centering\n        \\scalebox{0.5}{\n            \\includegraphics{isogeometric_sbfem/images/l_uy_at_A.png}\n        }\n    \\caption{Vertical displacement of L-shaped bracket at Point A: comparison with conventional FE solution}\n    \\label{iso_fig:l_uy_dynamic_at_A}\n    \\end{figure}\n%\n", "meta": {"hexsha": "f3fea04b2851daf9a6f2718f60018439c3eb5c4e", "size": 7307, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "isogeometric_sbfem/ex_l_shaped_bracket.tex", "max_stars_repo_name": "fa93hws/thesis", "max_stars_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-30T12:14:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-30T12:14:47.000Z", "max_issues_repo_path": "isogeometric_sbfem/ex_l_shaped_bracket.tex", "max_issues_repo_name": "fa93hws/thesis", "max_issues_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "isogeometric_sbfem/ex_l_shaped_bracket.tex", "max_forks_repo_name": "fa93hws/thesis", "max_forks_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.1928571429, "max_line_length": 212, "alphanum_fraction": 0.6904338306, "num_tokens": 1842, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4401625556693915}}
{"text": "\\subsubsection*{Ternary Operations\\hspace*{\\fill}\\hyperlink{ElementwiseOperations}{(up)}\\hypertarget{ternaryOperations}{}}\\addcontentsline{toc}{subsubsection}{Ternary Operations}\nTernary operations are those involving three inputs such as $ y = a \\cdot x + b$ or $y = (a + b) \\cdot x$. They are defined in the element-wise chapter of the C VSIPL specification.\\\\\nWe note that the VSIPL specification only defines ternary operations for \\ttbf{view}s of shape vector and precision float. Both complex and real are covered although no mixed depths are defined. Some ternary operations involve scalar constants.\n\\begin{table}[H]\n\\caption{Ternary Operations}\n\\label{tab:ternaryOperations}\n\\begin{center}\n\\begin{tabular}{|l|l|}\\hline\n\\hlnkFunc{am} & Add and multiply \\\\\n\\hlnkFunc{ma} & Multiply and add \\\\\n\\hlnkFunc{msb} & Multiply and subtract\\\\\n\\hlnkFunc{sbm} & Substract and multiply\\\\\n\\hline\\end{tabular}\n\\end{center}\n%\\label{default}\n\\end{table}%\n", "meta": {"hexsha": "d8ef63a9c8cb73f719eded5ec9297dbc7c1e9275", "size": 946, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/jvsip_book/TernaryOperations.tex", "max_stars_repo_name": "rrjudd/jvsip", "max_stars_repo_head_hexsha": "56a965fff595b027139ff151d27d434f2480b9e8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2016-01-16T04:10:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T02:17:44.000Z", "max_issues_repo_path": "doc/jvsip_book/TernaryOperations.tex", "max_issues_repo_name": "rrjudd/jvsip", "max_issues_repo_head_hexsha": "56a965fff595b027139ff151d27d434f2480b9e8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-09-11T04:48:03.000Z", "max_issues_repo_issues_event_max_datetime": "2015-09-11T13:44:29.000Z", "max_forks_repo_path": "doc/jvsip_book/TernaryOperations.tex", "max_forks_repo_name": "rrjudd/jvsip", "max_forks_repo_head_hexsha": "56a965fff595b027139ff151d27d434f2480b9e8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-06-13T21:48:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:07:44.000Z", "avg_line_length": 55.6470588235, "max_line_length": 244, "alphanum_fraction": 0.7653276956, "num_tokens": 276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.44004861881531915}}
{"text": "\\chapter{Ambiguity Resolution}\n\\label{ch:Ambiguity Resolution}\nAn advantage of the ambiguity fixed solutions is the significantly reduced number of parameters which have to be solved for. \nA reduction of the normal equation to be inverted is important because usually a duplication of its size leads to over four times longer computing time for the inversion. \nIf many parameters are estimated (orbits, Earth orientation parameters etc.) ambiguity resolution improves also the results of much longer sessions than the traditional daily solution.  \nDue to the FDMA technology the ambiguity resolution for GLONASS is not a straight forward task, and we have not attempted to implement this into the pea yet.\n%\nThere are many methods that can be used to resolve ambiguities, but they mainly consist of two steps:\n%\n\\begin{enumerate}\n    \\item The ambiguities are estimates as real numbers (with the other parameters).\n    \\item Integer values of the ambiguities are resolved using the results of step 1 (the real-value ambiguities and the VCV matrix) employing a number of statistical tests to ensure a reliable estimate.\n\\end{enumerate}\n%\n\\textit{Determining a reference or a pivot} is normally done by selecting a station with the most number of observations, however this is not possible to no apriori for a systems that is designed to run in real-time.\n%\nIn the pea we have implemented a number of different ambiguity resolution strategies:\n\\begin{itemize}\n    \\item rounding and weighted rounding\n    \\item bootstrapping\n    \\item lambda decorelation\n    \\item BIE\n\\end{itemize}\n%\n\\section{rounding algorithm}\nThe simplest strategy to apply is to round the real-values estimates to the nearest integers, without using any variance co-variance information.\n%\n\\section{bootstrapping}\n%\nThe bootstrapping algorithm takes the first ambiguity and rounds its value to the nearest integer. Having obtained the integer value of this first ambiguity, the real-valued estimates of all remaining ambiguities are then corrected by virtue of their correlation with the first ambiguity. \nThen the second, but now corrected, real-valued ambiguity estimate is rounded to its nearest integer, and the process is then repeated again with both ambiguities held fixed, and the process is continued until all ambiguities are accommodated. \nThus the bootstrapped estimator reduces to ’integer rounding’ in case correlations are absent.\n%\n\\section{lambda}\n\\section{BIE}\nThe previously mentioned algorithms are known as @hard decision algorithms.\n\n\\subsection{Melbourne-Wubbena linear combination}\nThe Melbourne-Wubbena linear combination (Melbourne 1985),(Wubbena 1985) is a linear combination of the L1 and L2 carrier phase plus the P1 and P2 pseudorange. The geometry, troposphere and ionosphere are eliminated by it. The Melbourne-Wubbena linear combination can be represented as:\n%\n\\begin{equation}\nE(L_{r,IF}^S) - \\frac{cf_2z_{r,w}^s}{f_1^2 - f_2^2} = \\rho_r^s + c(dt_{r,IF} - dt_{IF}^s) + \\tau_r^s + \\lambda_n z_{r,1}^s + (\\lambda_{IF}\\delta_{r,IF}\n\\end{equation}\n%\nSince ,,\\% comprises of both code and phase measurements, it is reasonable to exclude the lower\nelevation measurements to avoid the multipath impacts from the code observation. Normally, with\n30 degree elevation cut-off, an averaging of 5 minutes of (4) is good enough to fixing the wide-lane\nambiguities [RD 04]. The rests are the wide-lane phase bias, which can be broadcasted to the user for\nuser side wide-lane ambiguity resolution. Either choosing a pivot receiver bias or a single-differencing\nbetween two satellites can avoid the linear dependency. \n%\n%\ndoesn't need lambda not as correlated\n%\n\\section{Narrowlane and phase clock estimation}\n%\nhighly correlated need lambda\n% \\[E(L^S) - \\]\n%\n%\nWith the fixing of the wide-lane ambiguity, equation (1) and (2) can be further deducted as:\n%\nThe code bias and phase bias in equations \\eqref{obsEq} and (6) can be lumped into the corresponding receiver\nand satellite clock errors. Then equations (5) and (6) become:\n%\nwith:\n%\nBy such an reformulation, there are two types of satellite clock: 1) IGS type clock, but estimated only\nfrom code measurements; 2) phase clock, estimated using phase measurements and can be used to\nsupport PPP ambiguity resolution on the user side. The drawback of this approach is that there is no\nprecise IGS compatible clock after the processing and it has to be derived from the existing PEA\nprocessing\n%\n\\section{Narrowlane and phase bias estimation}\n%\nIn this approach, equation (7) holds the same for the code measurements. However, in equation (8),\nthe phase biases are not lumped into the clocks, but the ambiguities. More specifically, equation (8)\ncan be written as:\n%\nIn equation (9), the clocks are the same as the clocks provided in equation (7), which means the\nprecise IGS satellite clock can be estimated.\nThe narrow-lane integer ambiguities, as shown in equation (9), are linearly dependent on the phase\nbiases, which means they cannot be estimated simultaneously. However, similar as the wide-lane\nambiguity resolution, the narrow-lane integer ambiguities can be fixed by rounding the float solution\nto the nearest integer, and the remaining will be the phase bias, which can be broadcasted to the\nuser for user side PPP ambiguity resolution.\n%\n\\textit{Bootstrapping} is designed to do some stuff.\n%\n\\textit{Rounding}\n%\n\\textit{Lambda}\n%\nDecorrelation algorithm\n%\n%2 nearest\n%\n\\section{References on Ambiguity Resolution}\n%\n\\begin{itemize}\n    \\item A modified phase clock/bias model to improve PPP ambiguity resolution at Wuhan University Journal of Geodesy - Geng et al. (2019)\n    \\item On the interoperability of IGS products for precise point positioning with ambiguity resolution Journal of Geodesy - Simon et al. (2020)\n    \\item Resolution of GPS carrier-phase ambiguities in precise point positioning (PPP) with daily observations Journal of Geodesy - Ge et al. (2008)\n    \\item Real time zero-difference ambiguities fixing and absolute RTK ION NTM - Laurichesse et al. (2008)\n    \\item Undifferenced GPS ambiguity resolution using the decoupled clock model and ambiguity datum fixing Navigation – Collins et al. (2010)\n    \\item Improving the estimation of fractional-cycle biases for ambiguity resolution in precise point positioning Journal of Geodesy – Geng (2012).\n    \\item Modeling and quality control for reliable precise point positioning integer ambiguity resolution with GNSS modernization\nGPS Solutions – Li et al. (2014).\n\\end{itemize}", "meta": {"hexsha": "c02023b56219b9ca0450c76fe341c687e74acfe1", "size": 6506, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/manual/ambiguity_resolution.tex", "max_stars_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_stars_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 73, "max_stars_repo_stars_event_min_datetime": "2021-07-08T23:35:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T15:17:58.000Z", "max_issues_repo_path": "docs/manual/ambiguity_resolution.tex", "max_issues_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_issues_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-09-27T14:27:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T23:50:02.000Z", "max_forks_repo_path": "docs/manual/ambiguity_resolution.tex", "max_forks_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_forks_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2021-07-12T05:42:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T15:15:34.000Z", "avg_line_length": 59.6880733945, "max_line_length": 289, "alphanum_fraction": 0.7888103289, "num_tokens": 1506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.44004861881531915}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% LaTeX Example: Project Report\n%\n% Source: http://www.howtotex.com\n%\n% Feel free to distribute this example, but please keep the referral\n% to howtotex.com\n% Date: March 2011\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% How to use writeLaTeX:\n%\n% You edit the source code here on the left, and the preview on the\n% right shows you the result within a few seconds.\n%\n% Bookmark this page and share the URL with your co-authors. They can\n% edit at the same time!\n%\n% You can upload figures, bibliographies, custom classes and\n% styles using the files menu.\n%\n% If you're new to LaTeX, the wikibook is a great place to start:\n% http://en.wikibooks.org/wiki/LaTeX\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Edit the title below to update the display in My Documents\n%\\title{Project Report}\n%\n%%% Preamble\n\\documentclass[paper=a4, fontsize=11pt]{scrartcl}\n\\usepackage[T1]{fontenc}\n\\usepackage{fourier}\n\n\\usepackage[english]{babel}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t% English language/hyphenation\n\\usepackage[protrusion=true,expansion=true]{microtype}\n\\usepackage{amsmath,amsfonts,amsthm} % Math packages\n\\usepackage[pdftex]{graphicx}\n\\usepackage{url}\n\\usepackage{caption}\n\\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}\n\\usepackage{subcaption}  % For placing two subfigures side by side\n\n%%% Custom sectioning\n\\usepackage{sectsty}\n\\usepackage{multirow}\n\\allsectionsfont{\\centering \\normalfont\\scshape}\n\n%%% Inserting landscape pages\n\\usepackage{pdflscape}\n\n%%% Custom headers/footers (fancyhdr package)\n\\usepackage{fancyhdr}\n\\pagestyle{fancyplain}\n\\fancyhead{}\t\t\t\t\t\t\t\t\t\t\t% No page header\n\\fancyfoot[L]{}\t\t\t\t\t\t\t\t\t\t\t% Empty\n\\fancyfoot[C]{}\t\t\t\t\t\t\t\t\t\t\t% Empty\n\\fancyfoot[R]{\\thepage}\t\t\t\t\t\t\t\t\t% Pagenumbering\n\\renewcommand{\\headrulewidth}{0pt}\t\t\t% Remove header underlines\n\\renewcommand{\\footrulewidth}{0pt}\t\t\t\t% Remove footer underlines\n\\setlength{\\headheight}{13.6pt}\n\\setlength{\\fboxrule}{1mm}\n\\setlength{\\fboxsep}{5mm}\n\n%%% Equation and float numbering\n\\numberwithin{equation}{section}\t\t% Equationnumbering: section.eq#\n\\numberwithin{figure}{section}\t\t\t% Figurenumbering: section.fig#\n\\numberwithin{table}{section}\t\t\t\t% Tablenumbering: section.tab#\n\n\n%%% Maketitle metadata\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} \t% Horizontal rule\n\n\\title{\n\t\t%\\vspace{-1in}\n\t\t\\usefont{OT1}{bch}{b}{n}\n\t\t\\horrule{0.5pt} \\\\[0.2cm]\n\t\t\\LARGE General expressions of bsplines of degree 0,1,2 and 3 in 1D\\\\\n        -\\\\\n        \\normalsize Another tool for ToFu\n\t\t\\horrule{2pt} \\\\[0.3cm]\n}\n\\author{D. VEZINET}\n\\date{\\today}\n\n% Graphics path\n\\graphicspath{ {./} }\n\n%%% Begin document\n\\begin{document}\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\\section{General expression of the bsplines}\n\n\n\\begin{figure}[hbtp]\n    \\centering\n    \\includegraphics[scale=0.50]{BSplines_GeneralExpression_Deriv0.pdf}\n    \\caption{\\small Bsplines of degrees 0, 1, 2 and 3}\n    \\label{Fig:Grid}\n\\end{figure}\n\nA b-spline $b_{d,0}$ of degree $d$ living from $x_0$ is:$ b_{d,0} = \\frac{x-x_0}{x_{0+d}-x_0}b_{d-1,0} + \\frac{x_{0+d+1}-x}{x_{0+d+1}-x_{0+1}}b_{d-1,1} $\\\\\nHence:\n\n$$\nb_{0,0} =\n\\left\\{\n\\begin{array}{lll}\n1 & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n0 & \\text{ ,  else}\n\\end{array}\n\\right.\n$$\n\n$$\nb_{1,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{x-x_0}{x_1-x_0} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{x_2-x}{x_2-x_1} & \\text{ ,  if  } & x \\in [x_1,x_2[\n\\end{array}\n\\right.\n$$\n\n$$\nb_{2,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{(x-x_0)^2}{(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{(x-x_0)(x_2-x)}{(x_2-x_0)(x_2-x_1)} + \\frac{(x-x_1)(x_3-x)}{(x_2-x_1)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{(x_3-x)^2}{(x_3-x_2)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_2,x_3[\n\\end{array}\n\\right.\n$$\n\n$$\nb_{3,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{(x-x_0)^3}{(x_3-x_0)(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{x-x_0}{x_3-x_0}\\left(\\frac{(x-x_0)(x_2-x)}{(x_2-x_0)(x_2-x_1)} + \\frac{(x-x_1)(x_3-x)}{(x_2-x_1)(x_3-x_1)}\\right) + \\frac{x_4-x}{x_4-x_1}\\left(\\frac{(x-x_1)^2}{(x_3-x_1)(x_2-x_1)}\\right) & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{x-x_0}{x_3-x_0}\\left(\\frac{(x_3-x)^2}{(x_3-x_2)(x_3-x_1)}\\right) + \\frac{x_4-x}{x_4-x_1}\\left(\\frac{(x-x_1)(x_3-x)}{(x_3-x_1)(x_3-x_2)} + \\frac{(x-x_2)(x_4-x)}{(x_3-x_2)(x_4-x_2)}\\right)& \\text{ ,  if  } & x \\in [x_2,x_3[\\\\\n\\frac{(x_4-x)^3}{(x_4-x_3)(x_4-x_2)(x_4-x_1)} & \\text{ ,  if  } & x \\in [x_3,x_4[\n\\end{array}\n\\right.\n$$\n\nOr (see \\ref{Ap:DistribueDeg3} for details):\n\n$$\nb_{2,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{x^2-2xx_0+x_0^2}{(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{-x^2(x_3+x_2-x_1-x_0) + 2x(x_3x_2-x_1x_0) - (x_3x_2x_0 - x_2x_1x_0 + x_3x_2x_1 - x_3x_1x_0)}{ (x_2-x_1)(x_2-x_0)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{x^2-2xx_3+x_3^2}{(x_3-x_2)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_2,x_3[\n\\end{array}\n\\right.\n$$\n\n\n$$\nb_{3,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{x^3 - 3x^2x_0 + 3xx_0^2 - x_0^3}{(x_3-x_0)(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{x^3A + x^2B + xC + D}{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{x^3A^/ + x^2B^/ + xC^/ + D^/}{(x_4-x_2)(x_4-x_1)(x_3-x_2)(x_3-x_1)(x_3-x_0)} & \\text{ ,  if  } & x \\in [x_2,x_3[\\\\\n\\frac{-x^3 + 3x^2x_4 - 3xx_4^2 + x_4^3}{(x_4-x_3)(x_4-x_2)(x_4-x_1)} & \\text{ ,  if  } & x \\in [x_3,x_4[\n\\end{array}\n\\right.\n$$\n\n\n\n\\newpage\n\\section{Derivatives}\n\nBy noting $\\partial_n b_{d,0}$ the $n$-th derivative of b-spline $b_{d,0}$, where $n\\leq d$:\n\n$$\n\\partial_1 b_{1,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{1}{x_1-x_0} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{-1}{x_2-x_1} & \\text{ ,  if  } & x \\in [x_1,x_2[\n\\end{array}\n\\right.\n$$\n\n$$\n\\partial_1 b_{2,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{2(x-x_0)}{(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{-2x(x_3+x_2-x_1-x_0) + 2(x_3x_2-x_1x_0)}{ (x_2-x_1)(x_2-x_0)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{-2(x_3-x)}{(x_3-x_2)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_2,x_3[\n\\end{array}\n\\right.\n$$\n\n$$\n\\partial_2 b_{2,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{2}{(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{-2(x_3+x_2-x_1-x_0)}{ (x_2-x_1)(x_2-x_0)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{2}{(x_3-x_2)(x_3-x_1)} & \\text{ ,  if  } & x \\in [x_2,x_3[\n\\end{array}\n\\right.\n$$\n\n\n$$\n\\partial_1 b_{3,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{3(x-x_0)^2}{(x_3-x_0)(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{3x^2A + 2xB + C}{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{3x^2A^/ + 2xB^/ + C^/}{(x_4-x_2)(x_4-x_1)(x_3-x_2)(x_3-x_1)(x_3-x_0)} & \\text{ ,  if  } & x \\in [x_2,x_3[\\\\\n\\frac{-3(x_4-x)^2}{(x_4-x_3)(x_4-x_2)(x_4-x_1)} & \\text{ ,  if  } & x \\in [x_3,x_4[\n\\end{array}\n\\right.\n$$\n\n$$\n\\partial_2 b_{3,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{6(x-x_0)}{(x_3-x_0)(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{6xA + 2B}{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{6xA^/ + 2B^/}{(x_4-x_2)(x_4-x_1)(x_3-x_2)(x_3-x_1)(x_3-x_0)} & \\text{ ,  if  } & x \\in [x_2,x_3[\\\\\n\\frac{6(x_4-x)}{(x_4-x_3)(x_4-x_2)(x_4-x_1)} & \\text{ ,  if  } & x \\in [x_3,x_4[\n\\end{array}\n\\right.\n$$\n\n$$\n\\partial_3 b_{3,0} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{6}{(x_3-x_0)(x_2-x_0)(x_1-x_0)} & \\text{ ,  if  } & x \\in [x_0,x_1[\\\\\n\\frac{6A}{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)} & \\text{ ,  if  } & x \\in [x_1,x_2[\\\\\n\\frac{6A^/}{(x_4-x_2)(x_4-x_1)(x_3-x_2)(x_3-x_1)(x_3-x_0)} & \\text{ ,  if  } & x \\in [x_2,x_3[\\\\\n\\frac{-6}{(x_4-x_3)(x_4-x_2)(x_4-x_1)} & \\text{ ,  if  } & x \\in [x_3,x_4[\n\\end{array}\n\\right.\n$$\n\n\n\n\n\n\n\n\\newpage\n\\begin{landscape}\n\n\\begin{figure}[hbtp]\n    \\centering\n    \\includegraphics[scale=0.75]{tests01_bsplines_test02_BSpline_LFunc.pdf}\n    \\caption{\\small Bsplines of degrees 0, 1, 2 and 3 and their derivatives D0, D1, D2 and D3}\n    \\label{Fig:Deriv}\n\\end{figure}\n\n\n\\newpage\n\\appendix\n\n\\section{Distributing the degree 3 polynoms}\n\\label{Ap:DistribueDeg3}\n\n$$\n\\begin{array}{ll}\n& \\frac{x-x_0}{x_3-x_0}\\left(\\frac{(x-x_0)(x_2-x)}{(x_2-x_0)(x_2-x_1)} + \\frac{(x-x_1)(x_3-x)}{(x_2-x_1)(x_3-x_1)}\\right) + \\frac{x_4-x}{x_4-x_1}\\left(\\frac{(x-x_1)^2}{(x_3-x_1)(x_2-x_1)}\\right)\\\\\n= & \\frac{ (x-x_0)^2(x_2-x)(x_3-x_1)(x_4-x_1) + (x-x_0)(x-x_1)(x_3-x)(x_2-x_0)(x_4-x_1) + (x_4-x)(x-x_1)^2(x_3-x_0)(x_2-x_0) }{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)}\\\\\n= & \\frac{ (x^2-2xx_0+x_0^2)(x_2-x)(x_3-x_1)(x_4-x_1) + (x^2-x(x_0+x_1)+x_0x_1)(x_3-x)(x_2-x_0)(x_4-x_1) + (x^2-2xx_1+x_1^2)(x_4-x)(x_3-x_0)(x_2-x_0) }{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)}\\\\\n\n= & \\frac{ (x^2x_2-2xx_2x_0+x_2x_0^2 - x^3+2x^2x_0-xx_0^2)(x_3-x_1)(x_4-x_1) + (x^2x_3-xx_3(x_0+x_1)+x_0x_1x_3 - x^3+x^2(x_0+x_1)-xx_0x_1)(x_2-x_0)(x_4-x_1)\n+ (x^2x_4-2xx_4x_1+x_4x_1^2 - x^3+2x^2x_1-xx_1^2)(x_3-x_0)(x_2-x_0) }{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)}\\\\\n\n= & \\frac{1}{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)} \\left[ \\begin{array}{ll}\n-x^3((x_3-x_1)(x_4-x_1) + (x_2-x_0)(x_4-x_1) + (x_3-x_0)(x_2-x_0))\\\\\n+ x^2( (x_2+2x_0)(x_3-x_1)(x_4-x_1) + (x_3+x_0+x_1)(x_2-x_0)(x_4-x_1) + (x_4+2x_1)(x_3-x_0)(x_2-x_0) )\\\\\n+ x( -x_0(2x_2+x_0)(x_3-x_1)(x_4-x_1) - (x_3(x_0+x_1)+x_0x_1)(x_2-x_0)(x_4-x_1) - x_1(2x_4+x_1)(x_3-x_0)(x_2-x_0) )\\\\\n+ x_2x_0^2(x_3-x_1)(x_4-x_1) + x_0x_1x_3(x_2-x_0)(x_4-x_1) + x_4x_1^2(x_3-x_0)(x_2-x_0)\n\\end{array}\\right]\\\\\n\n= & \\frac{ Ax^3 + Bx^2 + Cx + D }{(x_4-x_1)(x_3-x_1)(x_3-x_0)(x_2-x_1)(x_2-x_0)}\n\n\\end{array}\n$$\n\nwhere $\\left\\{\\begin{array}{ll}\nA & = -((x_3-x_1)(x_4-x_1) + (x_2-x_0)(x_4-x_1) + (x_3-x_0)(x_2-x_0))\\\\\nB & = (x_2+2x_0)(x_3-x_1)(x_4-x_1) + (x_3+x_0+x_1)(x_2-x_0)(x_4-x_1) + (x_4+2x_1)(x_3-x_0)(x_2-x_0)\\\\\nC & = -(x_0(2x_2+x_0)(x_3-x_1)(x_4-x_1) + (x_3(x_0+x_1)+x_0x_1)(x_2-x_0)(x_4-x_1) + x_1(2x_4+x_1)(x_3-x_0)(x_2-x_0))\\\\\nD & = x_2x_0^2(x_3-x_1)(x_4-x_1) + x_0x_1x_3(x_2-x_0)(x_4-x_1) + x_4x_1^2(x_3-x_0)(x_2-x_0)\n\\end{array}\\right.$\\\\\n\n\n\n\nSimilarly\n$$\n\\frac{x-x_0}{x_3-x_0}\\left(\\frac{(x_3-x)^2}{(x_3-x_2)(x_3-x_1)}\\right) + \\frac{x_4-x}{x_4-x_1}\\left(\\frac{(x-x_1)(x_3-x)}{(x_3-x_1)(x_3-x_2)} + \\frac{(x-x_2)(x_4-x)}{(x_3-x_2)(x_4-x_2)}\\right)\n= \\frac{x^3A^/ + x^2B^/ + xC^/ + D^/}{(x_4-x_2)(x_4-x_1)(x_3-x_2)(x_3-x_1)(x_3-x_0)}\n$$\n\nwhere we simply substitute $(x_0,x_1,x_2,x_3,x_4)$ in $A,B,C,D$ by $(x_4,x_3,x_2,x_1,x_0)$ and notice that the denominator is the opposite of the substituted version:\n$$\n\\left\\{\\begin{array}{ll}\nA^/ & = (x_1-x_3)(x_0-x_3) + (x_2-x_4)(x_0-x_3) + (x_1-x_4)(x_2-x_4)\\\\\nB^/ & = -((x_2+2x_4)(x_1-x_3)(x_0-x_3) + (x_1+x_4+x_3)(x_2-x_4)(x_0-x_3) + (x_0+2x_3)(x_1-x_4)(x_2-x_4))\\\\\nC^/ & = x_4(2x_2+x_4)(x_1-x_3)(x_0-x_3) + (x_1(x_4+x_3)+x_4x_3)(x_2-x_4)(x_0-x_3) + x_3(2x_0+x_3)(x_1-x_4)(x_2-x_4)\\\\\nD^/ & = -(x_2x_4^2(x_1-x_3)(x_0-x_3) + x_4x_3x_1(x_2-x_4)(x_0-x_3) + x_0x_3^2(x_1-x_4)(x_2-x_4))\n\\end{array}\\right.\n$$\n\n\n\\end{landscape}\n\n\n\n\n\n\n\n\n\n%%% End document\n\\end{document}\n", "meta": {"hexsha": "e5a549a4454352e9a764a3b771af8c03dddfac25", "size": 10954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/BSplines_GeneralExpressions.tex", "max_stars_repo_name": "WinstonLHS/tofu", "max_stars_repo_head_hexsha": "c95b2eb6aedcf4bac5676752b9635b78f31af6ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2017-07-09T10:29:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T02:44:50.000Z", "max_issues_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/BSplines_GeneralExpressions.tex", "max_issues_repo_name": "WinstonLHS/tofu", "max_issues_repo_head_hexsha": "c95b2eb6aedcf4bac5676752b9635b78f31af6ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 522, "max_issues_repo_issues_event_min_datetime": "2017-07-02T21:06:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T08:07:57.000Z", "max_forks_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/BSplines_GeneralExpressions.tex", "max_forks_repo_name": "Didou09/tofu", "max_forks_repo_head_hexsha": "4a4e1f058bab8e7556ed9d518f90807cec605476", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2017-07-02T20:38:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-04T00:12:30.000Z", "avg_line_length": 32.6011904762, "max_line_length": 230, "alphanum_fraction": 0.593573124, "num_tokens": 5858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7154240079185318, "lm_q1q2_score": 0.4400486188153191}}
{"text": "\n\\section{Algorithmic version}\n\nAndromeda should be thought of as a programming language for deriving judgments. At the moment the language is untyped. We can hope to have it \\emph{simply typed} one day.\n\n\\subsection{Syntax} % (fold)\n\\label{sub:prog-syntax}\n\nExpressions:\n%\n\\begin{equation*}\n  \\expr\n  \\begin{aligned}[t]\n    \\bnf   {}& \\cmdType & & \\text{universe}\\\\\n    \\bnfor {}& \\x   &&\\text{variable} \\\\\n  \\end{aligned}\n\\end{equation*}\n%\nComputations:\n%\n\\begin{equation*}\n  \\cmd\n  \\begin{aligned}[t]\n    \\bnf   {}& \\cmdReturn \\expr              &&\\text{pure expressions} \\\\\n    \\bnfor {}& \\cmdLet{\\x}{\\cmd_1} \\cmd_2    &&\\text{let binding} \\\\\n    \\bnfor {}& \\cmdAscribe{\\cmd}{\\expr}      &&\\text{ascription} \\\\\n    \\bnfor {}& \\cmdProd{x}{\\expr} \\cmd       &&\\text{product}\\\\\n    \\bnfor {}& \\cmdEq{\\cmd}{\\cmd}            &&\\text{equality type} \\\\\n    \\bnfor {}& \\cmdLam{\\x}{\\expr} \\cmd       &&\\text{$\\lambda$-abstraction} \\\\\n    \\bnfor {}& \\cmdApp{\\expr}{\\cmd}          &&\\text{application} \\\\\n    \\bnfor {}& \\cmdRefl \\cmd                 &&\\text{reflexivity}\n  \\end{aligned}\n\\end{equation*}\n\nThe result of a computation is a value, which is a pair $(e,T)$ where $e$ and $T$ are terms of type theory, as described in Section~\\ref{sec:syntax}. The correctness guarantee which we want is that a computation only ever evaluates to derivable judgments.\n\n% subsection prog-syntax (end)\n\n\\subsubsection{Operational semantics} % (fold)\n\\label{ssub:operational_semantics}\n\nOperational semantics is given by \\emph{two} versions of evaluation of computations, called \\emph{inference} and \\emph{checking}, of the forms:\n%\n\\begin{align*}\n  \\text{Inference:}&\\quad \\evali{\\ctxenv}{\\cmd}{\\e}{\\T} \\\\\n  \\text{Checking:}&\\quad  \\evalc{\\ctxenv}{\\cmd}{\\T}{\\e}\n\\end{align*}\n%\nThese are read as ``in the given context $\\G$ and environment $\\env$ command $\\cmd$ infers that $\\e$ has type $\\T$'' and ``in the given context $\\G$ and environment $\\env$ command $\\cmd$ checks that $\\e$ has the given type $\\T$.''\n\n[EXPLAIN THAT AN ENVIRONMENT MAPS VARIABLES TO VALUES.]\n\n\\begin{mathpar}\n\n  \\infer[\\rulename{check-infer}]\n  {\\evali{\\ctxenv}{\\cmd}{\\e}{\\U} \\\\\n    \\eqtypealg{\\ctxenv}{\\T}{\\U}}\n  {\\evalc{\\ctxenv}{\\cmd}{\\T}{\\e}}\n\n  \\infer[\\rulename{infer-type}]\n  {}\n  {\\evali{\\ctxenv}{\\cmdReturn \\Type}{\\Type}{\\Type}}\n\n  \\infer[\\rulename{infer-product}]\n  {\\evalc \\ctxenv {\\cmd_1} \\Type {\\T_1} \\\\\n    \\evalc {\\ctxextend \\G \\x {\\T_1};\\, \\env} {\\cmd_2} \\Type {\\T_2}}\n  {\\evali \\ctxenv {\\cmdProd \\x {\\cmd_1} {\\cmd_2}} {\\Prod \\x {\\T_1} {\\T_2}} \\Type}\n\n  \\infer[\\rulename{infer-eq}]\n  {\\evali \\ctxenv {\\cmd_1} {\\e_1} \\T \\\\\n    \\evalc \\ctxenv {\\cmd_2} \\T {\\e_2}}\n  {\\evali \\ctxenv {\\cmdEq {\\cmd_1} {\\cmd_2}} {\\JuEqual {\\T} {\\e_1} {\\e_2}} \\Type}\n\n  \\infer[\\rulename{infer-ascription}]\n  {\\evalc \\ctxenv \\expr \\Type \\T \\\\\n    \\evalc \\ctxenv \\cmd \\T \\e}\n  {\\evali \\ctxenv {\\cmdAscribe \\cmd \\expr} \\e \\T}\n\n\\end{mathpar}\n\nInference of $\\cmdEq{\\cmd_1} {\\cmd_2}$ keeps the type of the first argument.\n\nAscription only has an infer rule, and will always switch to a checking phase. It breaks the inward information flow and has to use the check-infer when encountered during checking.\n\n\\begin{mathpar}\n\n  \\infer[\\rulename{infer-var}]\n  {\\env(\\x) = (\\e, \\T)}\n  {\\evali{\\ctxenv}{\\cmdReturn \\x}{\\e}{\\T}}\n\n  % supposedly the user annotated the lambda, so we should use the type \\T_1\n  % which we get out of \\expr in the recursive call, instead of \\U_1\n  \\infer[\\rulename{check-$\\lambda$-tagged}]\n  {\\tywhnfs \\ctxenv \\U {\\Prod \\x {\\U_1} {\\U_2}} \\\\\n    \\evalc \\ctxenv \\expr \\Type {\\T_1} \\\\\n    \\eqtypealg \\ctxenv {\\T_1} {\\U_1} \\\\\n    \\evalc {\\ctxextend \\G \\x {\\T_1};\\, \\env} \\cmd {\\U_2} \\e}\n  {\\evalc \\ctxenv {\\cmdLam \\x \\expr \\cmd} \\U {\\lam \\x {\\U_1} {\\U_2} \\e}}\n  % XXX should the result be (x:U1)->U2 or (x:T1)->U2?\n\n  \\infer[\\rulename{check-$\\lambda$-untagged}]\n  {\\tywhnfs \\ctxenv \\U {\\Prod \\x {\\U_1} {\\U_2}} \\\\\n    \\evalc {\\ctxextend \\G \\x {\\U_1};\\, \\env} \\cmd {\\U_2} \\e}\n  {\\evalc \\ctxenv {\\cmdLamCurry \\x \\cmd} \\U {\\lam \\x {\\U_1} {\\U_2} \\e}}\n\n  \\infer[\\rulename{infer-$\\lambda$}]\n  {\\evalc \\ctxenv \\expr \\Type {\\U_1} \\\\\n    \\evali {\\ctxextend \\G \\x {\\U_1};\\, \\envextend \\env \\x \\x {\\U_1}} \\cmd \\e {\\U_2}}\n  {\\evali \\ctxenv {\\cmdLam \\x \\expr \\cmd} {\\lam \\x {\\U_1} {\\U_2} \\e} {\\Prod \\x {\\U_1} {\\U_2}}}\n\n  \\infer[\\rulename{infer-app}]\n  {\\evali{\\ctxenv}{\\expr}{\\e_1}{\\T} \\\\\n   \\tywhnfs{\\ctxenv}{\\T}{\\Prod{\\x}{\\U_1} \\U_2} \\\\\n   \\evalc{\\ctxenv}{\\cmd}{\\U_1}{\\e_2}\n  }\n  {\\evali\n    {\\ctxenv}\n    {\\cmdApp{\\expr}{\\cmd}}\n    {\\app{\\e_1}{\\x}{\\U_1}{\\U_2}{\\e_2}}\n    {\\subst{\\U_2}{\\x}{\\e_2}}\n  }\n\n  \\infer[\\rulename{check-app-non-dep}]\n  {\\evali \\ctxenv \\cmd {\\e_2} \\U \\\\\n    \\evalc \\ctxenv \\expr {\\Prod \\_ \\U \\T} {\\e_1}}\n  {\\evalc \\ctxenv {\\cmdApp \\expr \\cmd} \\T\n    {\\app{\\e_1} \\_ \\U \\T {\\e_2}}}\n\n  \\infer[\\rulename{infer-refl}]\n  {\\evali{\\ctxenv}{\\cmd}{\\e}{\\T}}\n  {\\evali{\\ctxenv}{\\cmdRefl \\cmd}{\\juRefl{\\T}{\\e}}{\\JuEqual{\\T}{\\e}{\\e}}}\n\n  \\infer[\\rulename{check-refl}]\n  {\\tywhnfs{\\ctxenv}{\\T}{\\JuEqual{\\U}{\\e_1}{\\e_2}} \\\\\n   \\evalc{\\ctxenv}{\\cmd}{\\U}{\\e} \\\\\n   \\eqtermalg{\\ctxenv}{\\e}{\\e_1}{\\U} \\\\\n   \\eqtermalg{\\ctxenv}{\\e}{\\e_2}{\\U}\n }\n  {\\evalc{\\ctxenv}{\\cmdRefl \\cmd}{\\T}{\\juRefl \\T \\e}}\n\n  \\infer[\\rulename{check-let}]\n  {\\evali \\ctxenv {\\cmd_1} {\\e_1} \\U \\\\\n  \\evalc {\\G;\\, \\envextend \\env \\x \\e \\U} {\\cmd_2} \\T {\\e_2}}\n  {\\evalc \\ctxenv {\\cmdLet \\x {\\cmd_1} \\cmd_2} \\T {\\e_2}}\n\n  \\infer[\\rulename{infer-let}]\n  {\\evali \\ctxenv {\\cmd_1} {\\e_1} \\U \\\\\n  \\evali {\\G;\\, \\envextend \\env \\x \\e \\U} {\\cmd_2} {\\e_2} \\T}\n  {\\evali \\ctxenv {\\cmdLet \\x {\\cmd_1} \\cmd_2} {\\e_2} \\T}\n\n\\end{mathpar}\n\nTODO: check the freshness (and other side-conditions?).\n\n% subsubsection operational_semantics (end)\n", "meta": {"hexsha": "e399b8a882bba7a7fe132ea549f85e476f8433bc", "size": 5648, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "archive/doc/2015-05 - ETT theory/eval.tex", "max_stars_repo_name": "Andromedans/andromeda", "max_stars_repo_head_hexsha": "761b0fd07cab5cbcf68a06e79b7f27301826ca82", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 210, "max_stars_repo_stars_event_min_datetime": "2015-11-10T17:16:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T16:08:42.000Z", "max_issues_repo_path": "archive/doc/2015-05 - ETT theory/eval.tex", "max_issues_repo_name": "anjapetkovic/andromeda", "max_issues_repo_head_hexsha": "a5c678450e6c6d4a7cd5eee1196bde558541b994", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 244, "max_issues_repo_issues_event_min_datetime": "2015-11-10T16:20:24.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-06T03:55:46.000Z", "max_forks_repo_path": "archive/doc/2015-05 - ETT theory/eval.tex", "max_forks_repo_name": "anjapetkovic/andromeda", "max_forks_repo_head_hexsha": "a5c678450e6c6d4a7cd5eee1196bde558541b994", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 20, "max_forks_repo_forks_event_min_datetime": "2015-11-10T16:15:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-16T08:08:23.000Z", "avg_line_length": 36.2051282051, "max_line_length": 255, "alphanum_fraction": 0.5970254958, "num_tokens": 2211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4400034248821999}}
{"text": "\n\\section{3D model fitting}\nThe model optimization stage refines model parameters to match the silhouette sequence $\\mathcal S$. The procedure defined here is inspired by the human reconstruction method of SMALify~\\cite{bogo16keep} (defined in detail in \\Cref{chap:relwork}) and the non-automatic quadruped fitting method presented in 3D Menagerie (3DM) ~\\cite{zuffi2017menagerie}. The technique presented in this section can be viewed as an extension of these approaches to input video sequences. \n\n% SMALR exploited this fact (simultaneous fitting) in tangential work to ours.\nA naive 3D model fitting implementation would be to simple apply 3DM independently to each of the $N$ video frame to yield a set of pose parameters $\\seq{\\pose}{t}{1}{N}$, shape parameters $\\seq{\\shape}{t}{1}{N}$ and position parameters $\\seq{\\posn}{t}{1}{N}$. However, fitting to a video sequence rather than single frames offers additional opportunities to constrain the challenging monocular 3D reconstruction task. For example, video sequences typically offer multiple views of the animal subject, although the animal's limb positions often change between frames. However, the animal's \\emph{shape} characteristics (such as height, body proportions etc.) can be relied upon to remain largely consistent between frames. This fact is exploited through an extension that learns a single set of \\emph{global} shape parameters $\\shape$ and is assigned to across all frames $\\shape_{t} := \\shape$. Another benefit offered by video is the opportunity to constrain inter-frame subject motion. Assuming a reasonable framerate, it is expected that the animal's pose and position parameters should vary only slightly between successive frames. This intuition is characterized in \\Cref{eq:temporal-energy}.\n\nThe following section defines the 4 energy terms used in the optimization: \n\n\\ss{Silhouette energy.}\nThe silhouette energy $\\E{sil}$ compares the 3D animal model to the silhouette image according to the L2 distance between the OpenDR rendered binary image and the input silhouette $S_{t}$:\n\n\\begin{equation}\n\\E{sil}(\\posn_{t}, \\pose_{t}, \\shape; S_{t}) = \\lVert S_{t} - R\\bigl(\\posn_{t} * \\verts(\\pose_{t}, \\shape)\\bigr) \\rVert\n\\end{equation}\n\n\\ss{Unimodal Prior energy.}\nThe prior term $\\E{prior}$ encourages the regressed shape and pose parameters to remain close to a those in the combined artist traininthose in our set of artist 3D dog meshes.\n\n% \\begin{equation}\n%     \\L{pose}(\\pose) = (\\pose - \\meanpose)^T \\pose_cov^{-1} (\\pose - \\meanpose)\n% \\end{equation}\n\n% \\begin{equation}\n%     \\L{uni-shape}(\\beta) = (\\beta - \\meanbeta)^T \\beta_cov^{-1} (\\beta - \\meanbeta)\n% \\end{equation}\n\nThe Mahalanobis distance is used to encourage the model to remain close to: (1) a distribution over shape coefficients given by the mean and covariance of SMAL training samples of the relevant animal family, (2) a distribution of pose parameters built over a walking sequence. The final term ensures the pose parameters remain within set limits.\n\\begin{equation}\n\\E{lim}(\\pose_{t}) = \\max\\{\\pose_{t} - \\pose_{\\text{max}}, 0\\} + \\max\\{\\pose_{\\text{min}} - \\pose_{t}, 0\\}.\n\\end{equation}\n\n\\ss{Joints energy.}\nThe joints energy $\\E{joints}$ compares the rendered model joints to the OJA predictions, and therefore must account for missing and incorrect joints.  It is used primarily to stabilize the nonlinear optimization in the initial iterations, and its importance is scaled down as the silhouette term begins to enter its convergence basin.\n\n\\begin{equation}\n\\E{joints}(\\posn_{t}, \\pose_{t}, \\shape; X^{*}) = \n\\lVert X^{*} - \\posn_{t} * \\verts(\\pose_{t},\\shape)\\jointselect_{t}(:,j) \\rVert\n\\end{equation}\n\n\\ss{Temporal energy.}\nThe optimizer for each frame is initialized to the result of that previous. In addition, a simple temporal smoothness term is introduced to penalize large inter-frame variation:\n\\begin{equation}\n\\E{temp}(\\posn_{t}, \\pose_{t}) = (\\posn_{t} - \\posn_{t+1})^2 + (\\pose_{t} - \\pose_{t+1})^2\n\\end{equation}\\label{eq:temporal-energy}\n\n% TODO: Maybe some more here?\nThe optimization is via a second order dogleg method~\\cite{lourakis2005levenberg}.\n", "meta": {"hexsha": "5804daa90eb13b30f40221e44231752a7e654a1a", "size": 4141, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4/5_model-fitting.tex", "max_stars_repo_name": "benjiebob/phd-thesis-template", "max_stars_repo_head_hexsha": "2fd86bb807b830c06944d9c59962939d9a95ca7a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter4/5_model-fitting.tex", "max_issues_repo_name": "benjiebob/phd-thesis-template", "max_issues_repo_head_hexsha": "2fd86bb807b830c06944d9c59962939d9a95ca7a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4/5_model-fitting.tex", "max_forks_repo_name": "benjiebob/phd-thesis-template", "max_forks_repo_head_hexsha": "2fd86bb807b830c06944d9c59962939d9a95ca7a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.5102040816, "max_line_length": 1198, "alphanum_fraction": 0.7558560734, "num_tokens": 1087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597971, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4400034248821998}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{January 23, 2015}\n\\maketitle\nskipping 1.4\n\na graph is connected if for all $u,v$ in $E(G)$ there is a $u-v$ path\n\nhow can you tell if a graph is connected with the adjacency matrix? raise it to powers until it hits a nonzero entry. but you have to raise to infinity to prove non connectedness. this is inefficient at best.\n\nthere is a very easy way to do this\n\nwhat happens when graph is disconnected?\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { 1 -- {2 -- 3} -- 1; 4--5 }\n  [shift=(0:1)];\n\n\n\\[A(G)=\\left[\\begin{array}{ccccc}\n0&1&1&0&0\\\\\n1&0&1&0&0\\\\\n1&1&0&0&0\\\\\n0&0&0&0&1\\\\\n0&0&0&1&0\\\\\n\\end{array}\\right]\\]\n\nnotice blocks of zeros on upper right and lower left\n\nthis depends on vertex labelling, note homework problem on isomorphic graphs and adjacency matrices\n\nreduced row echelon form? determine negates when you switch columns or rows? same eigenvalues (?unsure). spectrum of graph\n\n\\section*{definition}\n$k(G)$ is the number of components of a graph\n\n\\subsection*{example}\nfrom above, $k(G)$ is 2\n\nif $G$ is connected $k(G)=1$\n\n\\begin{description}\n\\item[cut vertex]\nvertex $v$ such that $k(G)<k(G-v)$\n\\subsubsection*{example}\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { {1 -- 9}--8--7--6--5;1--{8--2}--1;8--3--6;{7--3};6--{4--5} }\n  [shift=(0:1)];\n\n8 and 6 are cut vertices\n\\item[nonseparable]\na connected graph with no cut vertices\n\\end{description}\n\\section*{theorem}\nif $G$ is nonseparable and is simple and $|G|\\ge 3$ then every pair of vertices lies on a cycle.\n\nanother way of thinking of this is that there are two paths between any two vertices.\n\n\\subsubsection*{proof}\npicture:\n\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] {  }\n  [shift=(0:1)];\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n\n  \\node[main_node] (1) at (-1,-1) {u};\n  \\node[main_node] (2) at (1,-1) {v};\n  \\draw (1) to[out=45,in=135] (2);\n  \\draw (1) to[out=90,in=215] (2);\n  \\draw (1) to[out=-45,in=90] (2);\n\\end{tikzpicture}\n\n$G$ has no cut vertices and $|G|\\ge 3$ since $G$ is connected, there is a $u-v$ path $P$. Let $\\mathcal{P}=\\{p_1,\\dots,p_r\\}$ be all the $u-v$ paths different from $P$. why is $\\mathcal{P}\\ne \\emptyset$? nonseperability\n\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n\n  \\node[main_node] (1) at (-1,-1) {u};\n  \\node[main_node] (2) at (1,-1) {w};\n  \\node[main_node] (3) at (3,-1) {v};\n  \\draw (1) to[out=45,in=135] (2);\n  \\draw (1) to[out=90,in=90] (2);\n  \\draw (1) to[out=0,in=180] (2);\n  \\draw (1) to[out=-90,in=-90] (2);\n  \\draw (1) to[out=-45,in=-135] (2);\n  \\draw (2) to[out=45,in=135] (3);\n  \\draw (2) to[out=90,in=90] (3);\n  \\draw (2) to[out=0,in=180] (3);\n  \\draw (2) to[out=-90,in=-90] (3);\n  \\draw (2) to[out=-45,in=-135] (3);\n\\end{tikzpicture}\n\nif $P_i\\cap P=\\{u,v\\}$ for some $i$, then we are done. if $P_i\\cap P\\ni w\\forall i,$ then $w$ is a cut vertex. so\n$\\not\\exists w\\in P_i\\cap P\\forall i$.\nlet $v_i\\in P_i\\cap P\\not\\ni v_j\\in P_j\\cap P\\not\\ni v_i$ \n\n$\\qquad\n\\quad\nP_1\n\\qquad\n\\qquad\n\\qquad\n\\qquad\n\\qquad\nP_2$\n\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n  \\node[main_node] (1) at (-1,-1) {u};\n  \\node[main_node] (2) at (1,-1) {$v_i$};\n  \\node[main_node] (3) at (3,-1) {$v_j$};\n  \\node[main_node] (4) at (5,-1) {v};\n  \\draw (1) to[out=45,in=135] (2);\n  \\draw (2) to[out=-45,in=215] (4);\n  \\draw (1) to[out=-45,in=215] (3);\n  \\draw (3) to[out=45,in=135] (4);\n\\end{tikzpicture}\n\n{\\bfseries claim:} we can choose $v_i,v_j$ such that $\\{v_i,v_j\\}\\le N_G(u)$\n{\\bfseries proof:} by nonsep $\\deg(u)\\ge 2$. if every $u-v$ path used edge $uw$ then w is a cut verte, therefore there are at least two $u-v$ paths starting from $u$ going through  distinct neighbors.\n\nfromthe claim, let $v_i,v_j$ be as before. then we have\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { 1 -- {2 -- 3} -- 4 -- 1; 5 }\n  [shift=(0:1)];\n\n$vi=1, v_j=3, u=2, v=3$\n\nrepeat for $v_i, v_j$ to find two disjoint $u-v$paths making a cycle\n\n\\section*{corollary 1}\na connected graph $G$ of order 3 or more is nonsep  iff every pair of vertices has two internally disjoint paths between them\n\n\\section*{corollary 2}\nlet $u,v$be two distinct vertices in a nonseparable graph $G$. if $H$ is obtained by  adding a vertex to $G$ and connecting it to $u$ and $v$ $G$ then $H$ is nonsep\n\n\\section*{corollary 3}\nif $G$ is nonsep and order 4 or more and $u,v\\subseteq V(G)$ with $|U|=|V|=2$ and $U\\cap V=\\emptyset$ then $G$ contains two internally disjoint paths from vertices in $U$ to vertices in $V$.\n\n\\subsection*{internally disjoint:}\ntwo$u-v$ paths $P_1$ and $P_2$ are internally disjoint if $P_1\\cap P_2=\\{u,v\\}$\n\\end{document}\n\n\n", "meta": {"hexsha": "8909f1c2ee6e9d067ab3c84fe066577e863b4a95", "size": 5271, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-01-23.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-01-23.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-01-23.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1509433962, "max_line_length": 219, "alphanum_fraction": 0.6640106242, "num_tokens": 1985, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7826624789529376, "lm_q1q2_score": 0.4399944652746005}}
{"text": "\\chapter{Chargino production}\n\n\\section{Lagrangian representation}\n\nIn this chapter I consider the production cross section\nfor the lightest charginos by the process \n\\bel{charginoProdProc}\ne^+e^- \\rightarrow \\chi^+\\chi^- ,\n\\ee\n\nwhere I denote by $\\chi$ the lightest chargino $\\chi_1$. Also I will refer\nto $\\chi^+$ as the chargino particle and to $\\chi^-$ as \nthe corresponding antiparticle.\n\n\\P\nAt the tree level, the process is represented by the following \ninteraction terms from the MSSM Lagrangian,\n\n\\bel{eToChi}\nL_{int}\n  = L[e, \\gamma] + L[e, Z]\n  + L[\\chi, \\gamma] + L[\\chi, Z] \n  + L[e, \\tilde{\\nu_{e1}}, \\chi]\n.\n\\ee         \n\nHere $L[e, \\gamma]$ and $L[e, Z]$  represent the usual coupling \nof electrons with photons and $Z^0$ bosons and the remaining terms are given \nby~\\rf{charginoCoupling} and~\\rf{ChiLSNu}. \n\n\\P\nTo simplify the cross-section calculations I found it useful to introduce \nthe following notations,\n\n\\bem\nL[e, \\gamma] & = & -\\overline{\\psi}_e e\\gu{\\rho} \\psi_e A_\\rho\n\\nel\n&\\equiv&\n\\overline{\\psi}_e \\gu{\\rho}(a_\\gamma - b_\\gamma \\gd5 ) \\psi_e D^\\gamma_\\rho,\n\\nel\nL[e, Z] &=& - \\frac{g}{4\\cos\\theta_W} \n  \\overline{\\psi}_e \\gu{\\rho} [(1 - 4\\sin^2\\theta_W) - \\gd5] \\psi_e Z_\\rho\n\\nel\n& \\equiv &\n\\overline{\\psi}_e \\gu{\\rho}(a_Z - b_Z \\gd5 ) \\psi_e D^Z_\\rho,\n\n\\ee\n\nwith\n\\bel{chargeGabIs}\na_\\gamma = -e \\equiv - \\abs{e}, \\quad b_\\gamma = 0, \n\\ee\n\n\\beml{chargeZabIs}\na_Z  =  -\\frac{g}{4\\cos\\theta_W}(1 - 4\\sin^2\\theta_W),\n\\quad \nb_Z  =  -\\frac{g}{4\\cos\\theta_W},\n\\ee\n\nand\n\\be\nD^\\gamma_\\rho =  A_\\rho, \\quad D^Z_\\rho =  Z_\\rho\n.\n\\ee\n\nAccording to~\\rf{charginoCoupling} I can write \nin the case of the  coupling of the lightest chargino $\\chi_1$\nwith the gauge bosons\n\\beml{charge-L-with-chi-and-gamma}\nL[\\chi, \\gamma] &=& \n\\overline{\\psi}_{\\chi_1} e\\gu{\\rho} \\psi_{\\chi_1} A_\\rho\n\\nel\n& \\equiv &\n\\overline{\\psi}_{\\chi}\\gu{\\rho}(A_\\gamma - B_\\gamma \\gu5)\\psi_{\\chi}\n   D^\\gamma_\\rho,\n\\nel\nL[\\chi,Z] &=&\n    \\frac{g}{4 \\cos \\theta_W} \n    \\overline{\\psi}_{\\chi_1} \\gu{\\rho} \n\\nel && \\times\n    \\Bigl\\lbrace \n          [2\\cos (2\\theta_W) \n            + \\abs{Y_{11}}^2 + \\abs{X_{11}}^2]\n        \n          + \\gu5 [\\abs{Y_{11}}^2 - \\abs{X_{11}}^2]\\Bigr\\rbrace\n\n    \\psi_{\\chi_1} Z_\\rho\n\\nel\n& \\equiv &\n  \\overline{\\psi}_{\\chi}\\gu{\\rho}(A_Z - B_Z \\gu5)\\psi_{\\chi} \n      D^Z_\\rho,\n\\ee\n\nwhere \n\n\\bel{chargeGABIs}\nA_\\gamma  = e, \\quad B_\\gamma =   0, \n\\ee\n\nand\n\\beml{chargeZABIs}\nA_Z &=& \\frac{g}{4 \\cos \\theta_W}\n             [2\\cos (2\\theta_W) + \\abs{Y_{11}}^2 + \\abs{X_{11}}^2],\n\\nel\nB_Z &=& - \\frac{g}{4 \\cos \\theta_W} [\\abs{Y_{11}}^2 - \\abs{X_{11}}^2].\n\\ee\n\nThe interaction term between electrons and positrons, charginos and\nscalar electron neutrinos is given by~\\rf{lagranChiLSNu}\n(I write in the following $\\tilde\\nu^L_e$ simply as $\\tilde\\nu$)\n\n\\bem\nL[e, \\tilde{\\nu}_{e1}, \\chi] & = &\n  \\frac{g}{2} \n    [-\\psi^T_{\\chi_1}C (\\Vc^\\chi_{e1L} + \\Ac^\\chi_{e1L}\\gd{5}) \\psi_{e}\n                    \\tilde{\\nu}^\\hc\n       + \\overline{\\psi}_e (\\Vc^{\\chi\\hc}_{e1L} - \\Ac^{\\chi\\hc}_{e1L} \\gd{5})\n                 C^{-1}\\overline{\\psi}_{\\chi_1}^T \\tilde{\\nu}]\n\\nel\n& \\equiv &\n        -\\psi^T_{\\chi}C (F + G\\gd{5}) \\psi_e\n                    \\cc{\\tilde{\\nu}}\n       + \\overline{\\psi}_e (F^\\hc - G^\\hc \\gd{5})\n                 C^{-1}\\overline{\\psi}_{\\chi}^T \\tilde{\\nu}.\n\\ee\n\nHere\n\\be\nF = \\frac{g}{2}\\Vc^\\chi_{e1L},\n\\quad \nG  =  \\frac{g}{2}\\Ac^\\chi_{e1L}\n.\n\\ee\n\nUnder the approximation \n\\be\n\\abs{Y_{i2}\\frac{m_e}{\\sqrt{2} m_W \\cos\\beta}}\n\\le \\frac{m_e}{\\sqrt{2} m_W \\cos\\beta} \\approx 0\n\\ee\n\n($\\abs{Y_{i2}} \\le 1$ as an element of the unitary matrix $Y$), \nthe coefficients $F$ and $G$ become\n\\bel{chargeFandG1}\nF \\approx -{g \\over 2} X_{11}^\\hc,\n\\quad\nG  \\approx {g \\over 2} X_{11}^\\hc\n\\ee\n\n\\P\nThe expressions for\n$X_{11}^\\hc$, $\\abs{X_{11}}^2$ and $\\abs{Y_{11}}^2$ are given by~\\rf{lagXandY}, \n\\bel{chargeFandG2}\nX_{11}^\\hc = \\cos\\theta_X, \n\\quad \n\\abs{X_{11}}^2 = \\cos^2\\theta_X,\n\\quad \n\\abs{Y_{11}}^2 = \\cos^2\\theta_Y\n,\n\\ee\n\n\\P\nWith this notations $L_{int}$ becomes\n\n\\bel{charge-useful-form-for-L}\nL_{int} = \\sum_{k = \\gamma, Z} (L_e^k + L_\\chi^k) \n            + L_{\\tilde\\nu} + L_{\\tilde\\nu}^\\hc,\n\\ee\n\nwhere I set\n\\beml{charge-useful-form-for-L-2}\nL_e^k & = & \n\\overline{\\psi}_{e}\\gu{\\rho}(a_k - b_k \\gu5)\\psi_{e}D^k_\\rho\n,\n\\nel\nL_\\chi^k & = & \n\\overline{\\psi}_{\\chi}\\gu{\\rho}(A_k - B_k \\gu5)\\psi_{\\chi}D^k_\\rho\n,\n\\nel \nL_{\\tilde\\nu} & = &  \\overline{\\psi}_e (F^\\hc - G^\\hc \\gd{5})\n                 C^{-1}\\overline{\\psi}_{\\chi}^T \\tilde{\\nu}\n,                 \n\\nel\nL_{\\tilde\\nu}^\\hc & = & -\\psi^T_{\\chi}C (F + G\\gd{5}) \\psi_e \\tilde{\\nu}^\\hc\n.\n\\ee\n\n\n\\section{Production Amplitude}\n\nAccording to~\\cite{SMTextBook} the tree-level transition amplitude \nfor the process \\rf{charginoProdProc}\nis given by the second-order $S$-matrix element, \n\n\\bem\n\\lefteqn{\nS_2(e^+e^- \\rightarrow \\chi^+\\chi^-) = \n\\frac{(-i)^2}{2!} \\int d^4\\!x\\, d^4\\!x' \n}\n\\nel &&{} \\times \n\\bra{\\chi^+(\\ppa, \\rpa), \\chi^-(\\ppb, \\rpb)}\n  \\Torder\\lbrace \n    \\Norder[L_{int}(x)] \\Norder[L_{int}(x')]\\rbrace\n\\ket{e^+(\\pa, \\ra), e^-(\\pb, \\rb)}\n.\n\\ee\n\nHere $\\pa$, $\\ra$, $\\pb$, $\\rb$ denote the initial momentum and polarization\nstate for the positron and electron fields, \n$\\ppa$, $\\rpa$, $\\ppb$, $\\rpb$ are used\nfor the final states of antichargino and chargino.\nThe functional $\\Torder$ gives \nthe time ordered product of its arguments\nand $\\Norder[L_{int}]$ stands for the normal-ordered form \nof the interaction Lagrangian. \n \n\\P\n\nI must note here that there is an ambiguity in the definition of\na multi-fermion state. \nFor example, for any two fermions $f_1$, $f_2$\none can take either \n\\bel{charge-multi-fermion-state-is}\n\\ket{f_1, f_2} \n    = (2\\pi)^{3\\over 2} c^\\hc(f_1) (2\\pi)^{3\\over 2} c^\\hc(f_2)\\ket{0} \n    = (2\\pi)^3 c^\\hc(f_1) c^\\hc(f_2)\\ket{0} \n    \n\\ee\n\nor\n\\be\n\\ket{f_1, f_2} \n    = (2\\pi)^{3\\over 2} c^\\hc(f_2) (2\\pi)^{3\\over 2} c^\\hc(f_1)\\ket{0} \n    = -(2\\pi)^3 c^\\hc(f_1)c^\\hc(f_2)\\ket{0}.\n\\ee\nwhere the factor $(2\\pi)^{3\\over 2}$ reflects the unit volume normalization of \nthe states.\n\n\\P\nThis causes an uncertainty in the sign of the S matrix for processes \nwith more than one fermion in the initial or final state\nalthough measurable quantities do not have this ambiguity.\nNevertheless, from the computational point of view the sign should be fixed\nsomehow. Thus I choose the first possibility~\\rf{charge-multi-fermion-state-is} and\n\n\\bem\n\\bra{f_1, f_2} & \\equiv & \\left(\\ket{f_1, f_2}\\right)^\\hc \n    = \\left((2\\pi)^3 c^\\hc(f_1)c^\\hc(f_2)\\ket{0}\\right)^\\hc \n\\nel & = &\n    (2\\pi)^3 \\bra{0}c(f_2)c(f_1)\n\\ee\n\n\\P\nI may write now for the initial and final states of \nthe process~\\rf{charginoProdProc},\n\\bem\n\\bra{\\chi^+(\\ppa, \\rpa), \\chi^-(\\ppb, \\rpb)}\n&=& \n(2\\pi)^3 \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa),\n\\nel\n\\ket{e^+(\\pa, \\ra), e^-(\\pb, \\rb)} \n&= &\n(2\\pi)^3 d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0},\n\\ee\n\nwhere $c$ and $d$ are fermion and antifermion annihilation operators \nand $c^\\hc$ and $d^\\hc$ are creation operators. \n\n\\P\nThe explicit form~\\rf{charge-useful-form-for-L} of $L_{int}$ \nand the commutational and anticommutational properties of different fields\nit depends on give\n\n\\bem\n\\lefteqn{\nS_2 = \\frac{(-i)^2}{2!} \\int d^4\\!x\\, d^4\\!x' \n    \\bra{\\chi^+(\\ppa, \\rpa), \\chi^-(\\ppb, \\rpb)}\n}\n\\nel\n&& {} \\times\n\\Torder\\Bigl\\lbrace \n  \\sum_{k = \\gamma, Z} \\bigl( \n    \\Norder[L_e^k(x)]\\Norder[L_\\chi^k(x)(x')] \n    +  \\Norder[L_\\chi^k(x)(x)]\\Norder[L_e^k(x')] \\bigr)\n\\nel && \\qquad \\qquad {}\n+ \\Norder[L_{\\tilde\\nu}(x)]\\Norder[L_{\\tilde\\nu}^\\hc(x')] \n+ \\Norder[L_{\\tilde\\nu}^\\hc(x)]\\Norder[L_{\\tilde\\nu}(x')] \n \\Bigr\\rbrace\n\\nel && \\times\n\\ket{e^+(\\pa, \\ra), e^-(\\pb, \\rb)}\n\n\n\\nel\n& = & -\\int d^4\\!x\\, d^4\\!x' \n\\bra{\\chi^+(\\ppa, \\rpa), \\chi^-(\\ppb, \\rpb)}\n\\nel && {} \\times\n  \\Torder\\Bigl\\{ \n  \\sum_{k = \\gamma, Z} \\Norder[L_e^k(x)]\\Norder[L_\\chi^k(x)(x')]\n    + \\Norder[L_{\\tilde\\nu}^\\hc(x)]\\Norder[L_{\\tilde\\nu}(x')]\n \\Bigr\\}\n\\nel && \\times\n\\ket{e^+(\\pa, \\ra), e^-(\\pb, \\rb)}\n,\n\\ee\n\nwhere I have taken into account that \nthe terms like $\\Norder[L(x)]$ here contains an even number (two)\nof fermion fields so I can freely move them to any position \nin the $\\Torder$-product. Thus if I simply rename $x \\leftrightarrow x'$\nand change the integration order, I find, for example, \n\\bem\n\\int\\! d^4\\!x\\, d^4\\!x' \n  \\Torder\\Bigl\\lbrace \n     \\Norder[L_\\chi^k(x)(x)]\\Norder[L_e^k(x')]\n\\Bigr\\rbrace\n& = &\n\\int\\! d^4\\!x\\, d^4\\!x' \n  \\Torder\\Bigl\\lbrace \n     \\Norder[L_e^k(x')]\\Norder[L_\\chi^k(x)(x)]\n\\Bigr\\rbrace\n\\nel\n& = &\n\\int\\! d^4\\!x'\\, d^4\\!x\n  \\Torder\\Bigl\\lbrace \n     \\Norder[L_e^k(x)]\\Norder[L_\\chi^k(x')(x)]\n \\Bigr\\rbrace\n\\nel\n& = &\n\\int\\! d^4\\!x\\, d^4\\!x'\n  \\Torder\\Bigl\\lbrace \n     \\Norder[L_e^k(x)]\\Norder[L_\\chi^k(x')(x)]\n \\Bigr\\rbrace\n, \n\\ee\n\nand in the same way\n\\bem\n\\int d^4\\!x\\, d^4\\!x' \n    \\Norder[L_{\\tilde\\nu}(x)]\\Norder[L_{\\tilde\\nu}^\\hc(x')] \n& = &\n\\int d^4\\!x\\, d^4\\!x' \n    \\Norder[L_{\\tilde\\nu}^\\hc(x)]\\Norder[L_{\\tilde\\nu}(x')] \n.\n\\ee\n\nAt this stage \nI can represent $S_2$ according to~\\rf{charge-useful-form-for-L-2} \nand~\\rf{charge-multi-fermion-state-is} as, \n\n\\bel{charge-S2-as-two-term}\nS_2 = \\sum_{k = \\gamma, Z} S_k + S_{\\tilde\\nu},\n\\ee\n\nwith\n\\beml{charge-S-D-k-is}\nS_k & = & -(2\\pi)^6 \\int d^4\\!x\\, d^4\\!x' \n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel && \\times\n    \\Torder\\Bigl\\lbrace \n        \\Norder[\\overline\\psi_{\\chi} \n                \\gu{\\rho}(A_k - B_k\\gd{5})\n                \\psi_{\\chi}\n                D_\\rho]_{x}\n        \\Norder[\\overline\\psi_e \n                \\gu{\\sigma}(a_k - b_k\\gd{5})\n                \\psi_e\n                D_\\sigma]_{x'}\n    \\Bigr\\rbrace \n\\nel && \\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n,\n\\ee\n\nand\n\\beml{charge-S-nu-is}\nS_{\\tilde\\nu} & = & (2\\pi)^6 \\int d^4\\!x\\, d^4\\!x' \n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel && \\times\n    \\Torder\\Bigl\\lbrace \n        \\Norder[\\psi^T_{\\chi}C(F + G\\gd{5})\n                \\psi_{e}\\cc{\\tilde\\nu}]_x\n        \\Norder[\\overline{\\psi}_e (F^\\hc - G^\\hc\\gd{5})\n                C^{-1}\\overline{\\psi}_{\\chi}^T{\\tilde\\nu}]_{x'} \n    \\Bigr\\rbrace \n\\nel && \\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n.\n\\ee\n\n\n\\P\nI follow the usual approach and calculate $S_2$ by the means of\nWick's theorem. According to~\\rf{gammaFermionField} I have,\n\\bem\n\\lefteqn{\n\\psi(x) \\; = \\; \\posPart\\psi(x) + \\negPart\\psi(x)\n}\n\\nel & = &\n\\sum_{r = +, -}\\int d^3p \\left(\\frac{m}{(2\\pi)^3 E_p}\\right)^{\\frac{1}{2}}\n    [ u_r(p)c_r(p) e^{-ipx} + v_r(p)d_r^\\hc(p) e^{ipx} ] ,\n\\nel\n\\lefteqn{\n\\overline{\\psi}(x) \\; = \\;  \n\\overline{\\posPart\\psi}(x) + \\overline{\\negPart\\psi}(x)\n}\n\\nel & = &\n\\sum_{r = +, -}\\int d^3p \\left(\\frac{m}{(2\\pi)^3 E_p}\\right)^{\\frac{1}{2}}\n    [ \\ub_r(p)c_r^\\hc(p) e^{ipx} + \\vb_r(p)d_r(p) e^{-ipx} ]\n    ,\n\\ee\n\nwhere $u_r(p) = u_r(p/m)$ and $v_r(p) = v_r(p/m)$.\n\n\\P\nThus I obtain for first term $S_k$ in \\rf{charge-S2-as-two-term} \n(I suppress here the index $k$) :\n\\beml{charge-ref11}\nS_k & = & -(2\\pi)^6\\int d^4\\!x\\, d^4\\!x'\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel &&{} \\qquad\\times \n\\Torder\\Bigl\\lbrace \n            \\Norder[\\overline\\psi_{\\chi} \n                    \\gu{\\rho}(A - B\\gd{5})\n                    \\psi_{\\chi}\n                    D_\\rho]_{x}\n            \\Norder[\\overline\\psi_e \n                    \\gu{\\sigma}(a - b\\gd{5})\n                    \\psi_e\n                    D_\\sigma]_{x'}\n        \\Bigr\\rbrace\n\\nel &&{} \\qquad\\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n\\nel & = & \n-(2\\pi)^6 \\int d^4\\!x\\, d^4\\!x'\n    \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel &&{} \\qquad\\times \n        \\Torder\\Bigl\\lbrace \n            [\\overline{\\posPart\\psi}_{\\chi} \n                    \\gu{\\rho}(A - B\\gd{5})\n                    \\negPart\\psi_{\\chi}\n                    D_\\rho]_{x}\n            [\\overline{\\negPart\\psi}_e \n                    \\gu{\\sigma}(a - b\\gd{5})\n                    \\posPart\\psi_e\n                    D_\\sigma]_{x'}\n        \\Bigr\\rbrace\n\\nel &&{} \\qquad\\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n\\nel\n& = & \n-(2\\pi)^6 \\int d^4\\!x\\, d^4\\!x'\n    \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel &&{} \\qquad\\times \n        \\Norder\\Bigl\\lbrace \n            [\\overline{\\posPart\\psi}_{\\chi} \n                    \\gu{\\rho}(A - B\\gd{5})\n                    \\negPart\\psi_{\\chi}]_{x}\n            [\\overline{\\negPart\\psi}_e \n                    \\gu{\\sigma}(a - b\\gd{5})\n                    \\posPart\\psi_e]_{x'}\n        \\Bigr\\rbrace    \n            iD_{\\rho\\sigma}(x' - x)\n\\nel &&{} \\qquad\\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0},\n\\ee\n\nwhere $D_{\\rho\\sigma}(x' - x)$ stands for $\\gamma$ or $Z^0$\npropagator. Normal ordering of the fermion operators in~\\rf{charge-ref11} \ngives \n\n\\beml{charge-ref11-a}\nS_k\n& = & \n-(2\\pi)^6 \\int d^4\\!x\\, d^4\\!x'\n    \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel &&{} \\qquad\\times \n        [\\overline{\\negPart\\psi}_e \n                \\gu{\\sigma}(a - b\\gd{5})\n                \\posPart\\psi_e]_{x'}\n        [\\overline{\\posPart\\psi}_{\\chi} \n                \\gu{\\rho}(A - B\\gd{5})\n                \\negPart\\psi_{\\chi}]_{x}\n        iD_{\\rho\\sigma}(x' - x)\n\\nel &&{} \\qquad\\times \n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0} .\n\\ee\n\nFrom the anticommutational relations between fermion operators \nand~\\rf{gammaFermionField} I obtain for the scalar product in~\\rf{charge-ref13}:\n\\beml{charge-ref12}\n\\lefteqn{\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n[\\overline{\\negPart\\psi}_e\\dots \\posPart\\psi_e]_{x'} \\}\n[\\overline{\\posPart\\psi}_{\\chi} ... \\negPart\\psi_{\\chi}]_{x}\nd^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n} \\;\n\\nel & = &\n-\n\\left(\\frac{m_e^2}{\\Ea\\Eb}\\right)^{\\frac{1}{2}} \n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa) \n[\\overline{\\posPart\\psi}_{\\chi} ... \\negPart\\psi_{\\chi}]_{x} \\ket{0}\n\\nel && \\qquad \\times\n[\\vb_{\\ra}(\\pa)e^{-i\\pa x'} \\dots u_{\\rb}(\\pb)e^{-i\\pb x'}] \n\n\\nel & = & \n-\n\\left(\\frac{m_e^2 m_\\chi^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\dirProd{0}{0}\n\\nel && \\quad \\times\n[\\ub_{\\rpb}(\\ppb)e^{i\\ppb x} \\dots v_{\\rpa}(\\ppa)e^{i\\ppa x}]\n[\\vb_{\\ra}(\\pa)e^{-i\\pa x'} \\dots u_{\\rb}(\\pb)e^{-i\\pb x'}] \n,\n\\ee\n\nwhere $\\Ea$ and $\\Eb$ are the energies of the incoming particles and \n$\\Epa$ and $\\Epb$ are the energies of the outgoing ones. In the \ncenter-of-mass frame one will have $\\Ea = \\Eb$ and $\\Epa = \\Epb$.\n\n\\P\nThus from the equations~\\rf{charge-ref12} I find\n\n\\beml{charge-S2-boson-tmp1}\nS_k \n& = & \n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\int d^4\\!x\\, d^4\\!x'\n    \\dirProd{0}{0}\n\\nel & & \\qquad \\times \\,\n    [\\ub_{\\rpb}(\\ppb)e^{i\\ppb x}\n        \\gu{\\rho}(A - B\\gd{5})\n         v_{\\rpa}(\\ppa)e^{i\\ppa x}]\n\\nel & & \\qquad \\times  \\,\n    [\\vb_{\\ra}(\\pa)e^{-i\\pa x'}\n        \\gu{\\sigma}(a - b\\gd{5})\n        u_{\\rb}(\\pb)e^{-i\\pb x'}]\n    iD_{\\rho\\sigma}(x' - x) \n.\n\\ee\n\nTo calculate the integral in~\\rf{charge-S2-boson-tmp1} \nI use the Fourier transformation to write\n\\be\niD_{\\rho\\sigma}(x' - x) = (2\\pi)^{-4}\n\\int  d^4\\!k\\, e^{-ik(x' - x)} iD_{\\rho\\sigma}(k) \n.\n\\ee\n\nIt gives for~\\rf{charge-S2-boson-tmp1}\n\\beml{charge-boson-S-is}\nS_k & = & \n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n(2\\pi)^{-4}\n\\int d^4\\!x\\, d^4\\!x' d^4\\!k\\,\n    e^{ix(\\ppa + \\ppb)}e^{-ix'(\\pa + \\pb)}e^{-ik(x' - x)}\n    iD_{\\rho\\sigma}(k) \n\\nel & & \\times\\,\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a - b\\gd{5})u_{\\rb}(\\pb)]\n\\nel\n& = & \n(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\int d^4\\!k\\,\n    \\delta^4(k + \\ppa + \\ppb)\\delta^4(k + \\pa + \\pb)\n    iD_{\\rho\\sigma}(k) \n\\nel & & \\times\\,\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a - b\\gd{5})u_{\\rb}(\\pb)]\n\\nel\n& = & \n(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\delta^4(\\ppa + \\ppb - \\pa - \\pb) \n\\left. iD_{\\rho\\sigma}(k) \\right|_{k = - \\pa - \\pb =  - \\ppa - \\ppb} \n\\nel & & \\times\\,\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a - b\\gd{5})u_{\\rb}(\\pb)]\n    .\n\\ee\n\n\\P\nHandling of the $S_{\\tilde\\nu}$ term \nin~\\rf{charge-S2-as-two-term} is slightly\ndifferent due to the presence of the charge conjugation operation.\n \n\\beml{charge-ref13}\nS_{\\tilde\\nu} & = & (2\\pi)^6 \\int d^4\\!x\\, d^4\\!x'\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel&&\\qquad {} \\times\n       \\Torder\\Bigl\\lbrace \n            \\Norder[\\psi^T_{\\chi}C(F + G\\gd{5})\n                    \\psi_{e}{\\tilde\\nu}^\\hc]_x\n            \\Norder[\\overline{\\psi}_e (\\cc{F} - \\cc{G}\\gd{5})\n                    C^{-1}\\overline{\\psi}_{\\chi}^T\\tilde{\\nu}]_{x'} \n        \\Bigr\\rbrace\n\\nel&&\\qquad {} \\times\n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n\\nel\n& = & \n(2\\pi)^6\\int d^4\\!x\\, d^4\\!x'\n    \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel&&\\qquad {} \\times\n        \\Torder\\Bigl\\lbrace \n            [(\\negPart{\\psi})^T_{\\chi}C(F + G\\gd{5})\n                    \\posPart{\\psi}_{e}\\cc{\\tilde{\\nu}}]_x\n            [\\overline{\\negPart{\\psi}}_e (\\cc{F} - \\cc{G}\\gd{5})\n                    C^{-1}(\\overline{\\posPart{\\psi}}_{\\chi})^T\\tilde{\\nu}]_{x'} \n        \\Bigr\\rbrace\n\\nel & & \\qquad \\times \\,\n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n\\nel\n& = & \n(2\\pi)^6 \\int d^4\\!x\\, d^4\\!x'\n    \\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel&&\\qquad {} \\times\n        \\Norder\\Bigl\\lbrace \n            [(\\negPart{\\psi})^T_{\\chi}C(F + G\\gd{5})\n                    \\posPart{\\psi}_{e}]_x\n            [\\overline{\\negPart{\\psi}}_e (\\cc{F} - \\cc{G}\\gd{5})\n                    C^{-1}(\\overline{\\posPart{\\psi}}_{\\chi})^T]_{x'} \n        \\Bigr\\rbrace\n\\nel&&\\qquad {} \\times\n        i\\Delta_{\\tilde{\\nu}}(x' - x)\n    d^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0},\n\\ee\n\nwhere $\\Delta_{\\tilde\\nu}$ is the sneutrino propagator that has the usual\nform of the propagator for a scalar particle. If I take into account \nthat $\\psi_\\chi$ anticommutes with $\\psi_e$ \nI will find from~\\rf{gammaFermionField} in a way similar to~\\rf{charge-ref12} \nthat\n\\bem\n\\lefteqn{\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\Norder\\Bigl\\lbrace \n  [(\\negPart{\\psi})^T_{\\chi} \\dots \\posPart{\\psi}_{e}]_x\n  [\\overline{\\negPart{\\psi}}_e \\dots (\\overline{\\posPart{\\psi}}_{\\chi})^T]_{x'}\n\\Bigr\\rbrace\nd^\\hc_e(\\pa,\\ra)c^\\hc_e(\\pb,\\rb)\\ket{0}\n}\n\\nel\n& = &\n-\n\\left(\\frac{m_e}{\\Ea}\\right)^{\\frac{1}{2}}\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel && \\qquad{}\\times\n\\Norder\\Bigl\\lbrace \n  [(\\negPart{\\psi})^T_{\\chi} \\dots \\posPart{\\psi}_{e}]_x\n  e^{-i\\pa x'}[\\vb_{\\ra}(\\pa) \\dots (\\overline{\\posPart{\\psi}}_{\\chi})^T]_{x'}\n\\Bigr\\rbrace\nc^\\hc_e(\\pb,\\rb)\\ket{0}\n\\nel\n& = &\n\\left(\\frac{m_e^2}{\\Ea\\Eb}\\right)^{\\frac{1}{2}}\n\\bra{0}c_{\\chi}(\\ppb,\\rpb)d_{\\chi}(\\ppa, \\rpa)\n\\nel && \\qquad{}\\times\n\\Norder\\Bigl\\lbrace \n  [(\\negPart{\\psi})^T_{\\chi} \\dots u_{\\rb}(\\pb)]_xe^{-i\\pb x}\n  e^{-i\\pa x'}[\\vb_{\\ra}(\\pa) \\dots (\\overline{\\posPart{\\psi}}_{\\chi})^T]_{x'}\n\\Bigr\\rbrace\n\\ket{0}\n\\nel\n& = &\n\\left(\\frac{m_e^2 m_\\chi^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}}\n\\dirProd{0}{0}\n\\nel && \\qquad{}\\times\ne^{i\\ppa x}[v^T(\\ppa, \\rpa) \\dots u_{\\rb}(\\pb)]e^{-i\\pb x}\n  e^{-i\\pa x'}[\\vb_{\\ra}(\\pa) \\dots \\ub^T(\\ppb, \\rpb)]e^{i\\ppb x'}\n.\n\\ee\n\nThus~\\rf{charge-ref13} gives\n\n\\bem\nS_{\\tilde\\nu} & = & \n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\int d^4\\!x\\, d^4\\!x'\n    \\dirProd{0}{0}  i\\Delta_{\\tilde{\\nu}}(x' - x)\n\\nel & & {}\\times \n    e^{i\\ppa x}e^{-i\\pb x}\n    [{v^T(\\ppa, \\rpa)}C(F + G\\gd{5})u_{\\rb}(\\pb)]\n\\nel & & {}\\times \n    e^{-i\\pa x'}e^{i\\ppb x'}\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})\n                    C^{-1}\\ub^T(\\ppb, \\rpb)] \n.                    \n\\ee\n\nThe Fourier transformation of $i\\Delta_{\\tilde{\\nu}}(x' - x)$ leads to\n\\bem\nS_{\\tilde\\nu}\n& = &\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n(2\\pi)^{-4}\n\\int d^4\\!x\\, d^4\\!x' d^4\\!k\\,\n    e^{ix(\\ppa - \\pb)}e^{ix'(\\ppb - \\pa)}e^{-ik(x' - x)}\n    i\\Delta_{\\tilde{\\nu}}(k)\n\\nel & & \\qquad \\times\\,\n    [{v^T(\\ppa, \\rpa)}C(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})\n        C^{-1}\\ub^T(\\ppb, \\rpb)]\n\\nel\n& = & \n(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\int d^4\\!k\\,\n    \\delta^4(\\ppa - \\pb + k)\\delta^4(\\ppb - \\pa - k)\n    i\\Delta_{\\tilde{\\nu}}(k)\n\\nel & & \\qquad \\times\\,\n    [{v^T(\\ppa, \\rpa)}C(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})\n        C^{-1}\\ub^T(\\ppb, \\rpb)]\n\\nel\n& = & \n(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\delta^4(\\ppa + \\ppb - \\pa - \\pb) \n\\left. i\\Delta_{\\tilde{\\nu}}(k) \\right|_{k = \\pb - \\ppa =  \\ppb - \\pa} \n\\nel & & \\qquad \\times\\,\n    [{v^T(\\ppa, \\rpa)}C(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})\n        C^{-1}\\ub^T(\\ppb, \\rpb)]\n.\n\\ee\n\nNow, if I use~\\rf{gammaSpinorRelation}, I will obtain\n$v^T(p, s) C = - \\ub$, $C^{-1}\\ub^T = v$,\n\\bem\nS_{\\tilde\\nu} & = & \n-(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\delta(\\ppa + \\ppb - \\pa - \\pb) \n\\left. i\\Delta_{\\tilde{\\nu}}(k) \\right|_{k = \\pb - \\ppa =  \\ppb - \\pa} \n\\nel & & \\quad \\times\\,\n    [{\\ub_{\\rpa}(\\ppa)}(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})v_{\\rpb}(\\ppb)]\n.\n\\ee\n\nSo the whole amplitude can be represented in the standard form,\n\\beml{charginoProductionAmpl}\n\\lefteqn{\nS_2(e^+e^- \\rightarrow \\chi^+\\chi^-) \\; = \\;\n\\sum_{k = \\gamma, Z} S_k + S_{\\tilde\\nu}\n}\n\\nel\n& = &\ni(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\delta(\\ppa + \\ppb - \\pa - \\pb) \n\\nel & & {}\\times\n\\Bigl\\lbrace \n\n\\sum_{k = \\gamma, Z}  \nD^k_{\\rho\\sigma}(\\pa + \\pb)  \n\\nel & & {}\\qquad\\qquad \\times\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n\n\\nel & & \\quad {}\n\n-\n\\Delta_{\\tilde{\\nu}}(\\pb - \\ppa)\n    [\\ub_{\\rpa}(\\ppa)(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})v_{\\rpb}(\\ppb)]\n\\Bigr\\rbrace\n\n\\nel \n& \\equiv & -i(2\\pi)^{4}\n\\left(\\frac{m_e^2m_{\\chi}^2}{\\Ea\\Eb\\Epa\\Epb}\\right)^{\\frac{1}{2}} \n\\delta(\\ppa + \\ppb - \\pa - \\pb)M_{e\\chi},\n\\ee\n\nwhere I set\n\\beml{charge-M-is}\nM_{e\\chi} & = & \\sum_{k = \\gamma, Z} M_k + M_{\\tilde\\nu},\n\\ee\n\nand\n\\beml{charge-M-channels-is}\nM_k & = &\n-D^k_{\\rho\\sigma}(\\pa + \\pb)  \n\\nel&&{} \\quad\\times\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n    ,\n\\nel\nM_{\\tilde\\nu}\n&= &\\Delta_{\\tilde{\\nu}}(\\pb - \\ppa)\n    [\\ub_{\\rpa}(\\ppa)(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})v_{\\rpb}(\\ppb)]\n    .\n\\nel    \n\\ee\n\n\nIn the unitary gauge the photon and $Z$ propagators have the \nform~\\cite{SMTextBook}\n\\bel{photonPropogator}\nD^\\gamma_{\\rho\\sigma}(k) \n= - {g_{\\rho\\sigma}\\over k^2} \n= (-g_{\\rho\\sigma} + \\omega_\\gamma k_\\rho k_\\sigma ) \\Delta_\\gamma(k^2),\n\\ee\n\\be\n\\omega_\\gamma = 0, \n\\qquad \\Delta_\\gamma(k^2) = {1 \\over k^2},\n\\ee\n\n\\be\nD^Z_{\\rho\\sigma}(k) = \n{(-g_{\\rho\\sigma} + k_\\rho k_\\sigma/\\mB^2)\\over\nk^2 - \\mB^2 + i\\mB\\Gamma_Z}\n= (-g_{\\rho\\sigma} + \\omega_Z k_\\rho k_\\sigma ) \\Delta_Z(k^2),\n\\ee\n\n\\bel{ZPropogator}\n\\omega_Z = {1 \\over \\mB^2}, \n\\qquad \\Delta_Z(k^2) = {1 \\over k^2 - \\mB^2 + i\\mB\\Gamma_Z},\n\\ee\n\nwhere $\\mB$ is the mass of $Z$ and $\\Gamma_\\B$ is its decay rate, \nit reflects the instability of $Z$.\n\nI also include the decay term to the sneutrino propagator,\n\\bel{chargeSneutrinoDelta}\n\\Delta_{\\tilde{\\nu}}(k) = \n\\Delta_{\\tilde{\\nu}}(k^2) = \n{1 \\over k^2 - m_{\\tilde{\\nu}}^2 + im_{\\tilde{\\nu}}\\Gamma_{\\tilde{\\nu}}}\n.\n\\ee\n\nThe delta function in \\rf{charginoProductionAmpl} implies\nthe usual conservation law $\\pa + \\pb = \\ppa + \\ppb$.\n\n\\P\nNow with the help of \\rf{gammaPOnSpinors}, $\\pc u = m u$ and $\\pc v = -m v$,\nI find from $k = \\pa + \\pb$ applied to the electron current\n\\bem\n\\lefteqn{\nk_\\sigma [\\vb_{\\ra}(\\pa)\\gu{\\sigma}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n\\; = \\; [\\vb_{\\ra}(\\pa)\\slsh{k}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n}\n\\nel & = &\n[\\vb_{\\ra}(\\pa)\\pca(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n+\n[\\vb_{\\ra}(\\pa)\\pcb(a_k - b_k\\gd{5})u_{\\rb}(\\pb)] \n\\nel & = &\n[\\vb_{\\ra}(\\pa)\\pca(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n+\n[\\vb_{\\ra}(\\pa)(a_k + b_k\\gd{5})\\pcb u_{\\rb}(\\pb)] \n\\nel & = &\n-[\\vb_{\\ra}(\\pa)\\ma(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n+\n[\\vb_{\\ra}(\\pa)(a_k + b_k\\gd{5}) \\mb u_{\\rb}(\\pb)] \n\\nel & = &\n2m_eb_k[\\vb_{\\ra}(\\pa)\\gd{5}u_{\\rb}(\\pb)]\n.\n\\ee\n\nIn the same way from $k = \\ppa + \\ppb$ I have \n\\bem\n\\lefteqn{\nk_\\rho [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n}\n\\nel & = &\n[\\ub_{\\rpb}(\\ppb)\\mpb(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n-\n[\\ub_{\\rpb}(\\ppb)(A_k + B_k\\gd{5})\\mpa v_{\\rpa}(\\ppa)]\n\\nel & = &\n-2m_\\chi B_k[\\ub_{\\rpb}(\\ppb)\\gd{5}v_{\\rpa}(\\ppa)] \n.\n\\ee\n\nThus\n\n\\beml{chargeMBoson}\nM_k & = &\n\\Delta_k(s)\\bigl\\{  \n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n\\nel &&\n{} + 4m_e m_\\chi \\omega_k b_k B_k \n  [\\ub_{\\rpb}(\\ppb)\\gd{5}v_{\\rpa}(\\ppa)][\\vb_{\\ra}(\\pa)\\gd{5}u_{\\rb}(\\pb)] \n  \\bigr\\}\n  ,  \n\\ee\n\nand \n\\beml{chargeMTriple}\nM_{\\tilde\\nu}  &=& \\Delta_{\\tilde{\\nu}}(t)\n    [\\ub_{\\rpa}(\\ppa)(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\vb_{\\ra}(\\pa)(\\cc{F} - \\cc{G}\\gd{5})v_{\\rpb}(\\ppb)]\n    ,\n\\ee\n\nwith\n\\be\ns = (\\pa + \\pb)^2 = (\\ppa + \\ppb)^2, \n\\qquad\nt = (\\ppb - \\pa)^2 = (\\pb - \\ppa)^2\n.\n\\ee\n\nIt is expected that the lightest chargino mass would not exceed\nthe order of some TeV. So I may use the approximation \n\\be\nm_e m_\\chi \\omega_Z = {m_e m_\\chi \\over \\mB^2} \\ll 1\n.\n\\ee\n\nAt the same time I have from \\rf{gammaProj} that the spinors $u$, $v$\ndo not depend on masses. Thus under the approximation\n\\be\n{m_e m_\\chi \\over \\mB^2} \\approx 0\n\\ee\nI may write, \n\n\\bel{chargeMBosonApprox}\nM_k \\approx\n\\Delta_k(s)  \n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A_k - B_k\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a_k - b_k\\gd{5})u_{\\rb}(\\pb)]\n    .\n\\ee\n\n\\section{Cross section}\n\nFrom the usual form of \\rf{charginoProductionAmpl} \naccording to appendix \\rf{CrossSectionApp}\nI may express the center-of-mass differential and \ntotal cross sections for the process \\rf{charginoProdProc}\nthrough $X_{e\\chi}$ that reads\n\\beml{chargeFullX}\nX_{e\\chi}\n&=&  {1 \\over 4}\\sum_\\ra\\sum_\\rb\\sum_\\rpa\\sum_\\rpb\n   M_{e\\chi}^\\hc M_{e\\chi}\n= \\frac{1}{4}\\sum_{\\ra, \\rb, \\rpa, \\rpb}\n\\abs{\\sum_{k = \\gamma, Z} M_k + M_{\\tilde\\nu}}^2\n\\nel\n&=& \n\\sum_{k, k' = \\gamma, Z} X_{kk'} + X_{\\tilde\\nu\\tilde\\nu}\n + 2\\sum_{k = \\gamma, Z} X_{k\\tilde\\nu}\n.\n\\ee\n\nHere the contribution from boson ($\\gamma$ and $Z^0$) reaction \nchannels is given by\n\\beml{charge-boson-X-definition}\nX_{kk'} & = &\n\\frac{1}{4}\\sum_{\\ra, \\rb, \\rpa, \\rpb} \\Re(M_k M_{k'}^\\hc).\n\\ee\n\nand similarly the $\\tilde\\nu$ channel is given by\n\\beml{charge-sneutrino-X-definition}\nX_{\\tilde\\nu\\tilde\\nu} & = &\n\\frac{1}{4}\\sum_{\\ra, \\rb, \\rpa, \\rpb} M_{\\tilde\\nu} M_{\\tilde\\nu}^{\\hc}\n.\n\\ee\n\nThe interference term between boson and sneutrino channels has the form\n\\beml{charge-interference-X-definition}\nX_{k\\tilde\\nu} & = &\n\\frac{1}{4}\\sum_{\\ra, \\rb, \\rpa, \\rpb} \\Re(M_k M_{\\tilde\\nu}^{\\hc}) .\n\\ee\n\n\\P\n\nTo represent the calculations of the terms in \\rf{chargeFullX}\nin a compact form I suppress the index $k$ in \nthe expressions~\\rf{chargeMTriple} and \\rf{chargeMBosonApprox},\n\n\\bel{charge-M-k-form}\nM_k = \\Delta_k(s)  \n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a - b\\gd{5})u_{\\rb}(\\pb)].\n\\ee\n\nSo $M_{k'}^\\hc$ is given by\n\\bem\nM_{k'}^\\hc  &=& \\Delta_{k'}^\\hc (s)  \n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A' - B'\\gd{5})v_{\\rpa}(\\ppa)]^\\hc\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a' - b'\\gd{5})u_{\\rb}(\\pb)]^\\hc\n\\nel & = &     \n\\Delta_{k'}^\\hc (s)  \n    [\\vb_{\\rpa}(\\ppa)(A' + B'\\gd{5})\\gu{\\sigma}u_{\\rpb}(\\ppb)]\n    [\\ub_{\\rb}(\\pb)(a' + b'\\gd{5})\\gd{\\sigma}v_{\\ra}(\\pa)], \n\\ee\n\nIn the same way I find $M_{\\tilde\\nu}^{\\hc}$\n\n\\beml{chargeMShortExp}\nM_{\\tilde\\nu}^{\\hc}\n&=& \\Delta_{\\tilde{\\nu}}^\\hc(t)\n    [\\ub_{\\rpa}(\\ppa)(F + G\\gd{5})u_{\\rb}(\\pb)]^\\hc\n    [\\vb_{\\ra}(\\pa)(F^\\hc - G^\\hc\\gd{5})v_{\\rpb}(\\ppb)]^\\hc   \n\\nel & = &\n \\Delta_{\\tilde{\\nu}}^\\hc(t)\n    [\\ub_{\\rb}(\\pb)(F^\\hc - G^\\hc\\gd{5})u_{\\rpa}(\\ppa)]\n    [\\vb_{\\rpb}(\\ppb)(F + G\\gd{5})v_{\\ra}(\\pa)]\n,\n\\ee\n\nwhere I used \\rf{gammaBProperties} to calculate the hermitian conjugated \nexpression.\n\n\\subsection{Contribution from boson channels}\n\nBy using the spin polarization sum formulae  \\rf{gammaSpinPolarization},\n\\beml{SpinSums}\n\\sum_r {\\v_k}(p, r){\\vb_l}(p, r) & = & \n \\frac{1}{2m}(\\slsh{p} - m)_{kl} \n    = \\frac{1}{2}(\\slsh{q} - 1)_{kl},\n\\nel\n\\sum_r {\\u_k}(p, r){\\ub_l}(p, r) & = & \n\\frac{1}{2m}(\\slsh{p} + m)_{kl} \n   = \\frac{1}{2}(\\slsh{q} + 1)_{kl},\n\\quad q \\equiv p/m,\n\\ee\n\nwhere $k$ and $l$ denote spinor indices , I have\n\n\\bel{charge-X-boson-1}\nX_{kk'} = \n\\frac{1}{4}\\Re\\left[\\sum_{\\ra, \\rb, \\rpa, \\rpb}\nM_k M_{k'}^\\hc \\right]\n\\approx\n\\frac{1}{4}\\Re[\\Delta_k(s)\\Delta_{k'}^\\hc(s)\nL^{\\rho\\sigma} N_{\\rho\\sigma}],\n\\ee\n\nwith ``electron'' ($L^{\\rho\\sigma}$) and ``chargino'' \n($N_{\\rho\\sigma}$) tensors given by   \n\\bem\nL^{\\rho\\sigma} & = & \\sum_{\\rpa, \\rpb}\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\rpa}(\\ppa)(A' + B'\\gd{5})\\gu{\\sigma}u_{\\rpb}(\\ppb)]\n\\nel \n& = &     \n{1 \\over 4} \n    \\Tr\\Bigl[(\\qcpb + 1)\\gu\\rho(A - B\\gd5)\n             (\\qcpa - 1)(A' + B'\\gd5)\\gu\\sigma\\Bigr] ,\n\\ee\n\nand\n\\bem\nN_{\\rho\\sigma} & = & \\sum_{\\ra, \\rb}\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a - b\\gd{5})u_{\\rb}(\\pb)]\n    [\\ub_{\\rb}(\\pb)(a' + b'\\gd{5})\\gd{\\sigma}v_{\\ra}(\\pa)]\n\\nel\n& = &     \n{1 \\over 4} \n\\Tr\\Bigl[(\\qca - 1)\\gu\\rho(a - b\\gd5)(\\qcb + 1)(a' + b'\\gd5)\\gu\\sigma\\Bigr]\n.\n\\ee\n\nThe chargino tensor $N_{\\rho\\sigma}$ \ncan be expressed through $L^{\\rho\\sigma}(A, A', B, B', \\qpa, \\qpb)$ via \n\\bel{NthroughL}\nN_{\\rho\\sigma} \n   = L_{\\rho\\sigma}(A\\rightarrow a, A'\\rightarrow a', \n                   B \\rightarrow b, B' \\rightarrow b', \n                   \\qpa \\rightarrow -\\qb, \\qpb \\rightarrow -\\qa) \n.\n\\ee\nThus it is necessary to calculate only one quantity.\n\n\\P\n\nApplying properties of $\\gamma$-matrices one finds for $L^{\\rho\\sigma}$\n\\bem\nL^{\\rho\\sigma} & = &\n\\frac{1}{4}\n    \\Tr\\Bigl[\n        \\qcpb\\gu\\rho(A - B\\gd5)\\qcpa(A' + B'\\gd5)\\gu\\sigma\n        - \\gu\\rho(A - B\\gd5)(A' + B'\\gd5)\\gu\\sigma\\Bigr]\n\\nel & = &\n\\frac{1}{4}\n    \\Tr\\Bigl[\n        \\qcpb\\gu\\rho(A - B\\gd5)(A' - B'\\gd5)\\qcpa\\gu\\sigma\n        - \\gu\\rho(A - B\\gd5)(A' + B'\\gd5)\\gu\\sigma\\Bigr]\n\\nel & = &\n\\frac{1}{4}\n    \\Tr\\Bigl[\n        \\qcpb\\gu\\rho\\lbrace \n            AA' + BB' - \\gd5(AB' + BA')\n        \\rbrace \\qcpa\\gu\\sigma\n\\nel & & \\qquad{}\n        - \\gu\\rho\\lbrace\n            AA' - BB' + \\gd5(AB' - BA')\n        \\rbrace \\gu\\sigma\\Bigr]\n\\nel & = &\n\\frac{1}{4}\n    \\Tr\\Bigl[\n        \\qcpb\\gu\\rho\\lbrace \n            AA' + BB' - \\gd5(AB' + BA')\n        \\rbrace \\qcpa\\gu\\sigma\n        - \\gu\\rho(AA' - BB')\\gu\\sigma\\Bigr]\n\\nel & = &\n\\frac{1}{4}\\Bigl[\n    (AA' + BB')\\Tr(\\qcpb\\gu\\rho\\qcpa\\gu\\sigma)\n    -(AB' + BA')\\Tr(\\qcpb\\gu\\rho\\qcpa\\gu\\sigma\\gd5)\n\\nel & & \\qquad {}\n    -(AA' - BB')\\Tr(\\gu\\rho\\gu\\sigma)\n    \\Bigr]\n    .\n\\ee\n\nI calculate the traces with the help of \\rf{gammaTraces}, \n\n\\bem\nL^{\\rho\\sigma} & = &\n    (AA' + BB')\n        [\\qpb^\\rho \\qpa^\\sigma + \\qpb^\\sigma \\qpa^\\rho \n        - \n        (\\qpb\\cdot\\qpa)g^{\\rho\\sigma}]\n\\nel & & {} + \n    i(AB' + BA')\n        \\varepsilon^{\\mu\\rho\\nu\\sigma}\\qpb_\\mu \\qpa_\\nu\n    -(AA' - BB')g^{\\rho\\sigma}\n\\nel \n & = & L_S^{\\rho\\sigma} + L_A^{\\rho\\sigma},\n\\ee\n\nwhere\n\\bem\nL_S^{\\rho\\sigma}  & = & \n    (AA' + BB')[2\\qpb^{(\\rho} \\qpa^{\\sigma)}  \n     - (\\qpb\\cdot\\qpa)g^{\\rho\\sigma}]\n    -(AA' - BB')g^{\\rho\\sigma}\n,\n\\nel\n\nL_A^{\\rho\\sigma}  & = & \n    i(AB' + BA')\n        \\varepsilon^{\\mu\\rho\\nu\\sigma}\\qpb_\\mu \\qpa_\\nu\n\\ee\n\nIn the last expression I explicitly write the symmetric part \n$L_S^{\\rho\\sigma}=L_S^{(\\sigma\\rho)}$ and the asymmetric one \n$L_A^{\\rho\\sigma}=L_A^{[\\sigma\\rho]}$.\n\n\\P\nFrom~\\rf{NthroughL} I have for the chargino tensor $N_{\\rho\\sigma}$,\n\\bem\nN_{\\rho\\sigma} & = & {N_S}_{\\rho\\sigma} + {N_A}_{\\rho\\sigma},\n\\nel\n{N_S}_{\\rho\\sigma} & =  & \n    (aa' + bb')[2\\qa_{(\\rho} \\qb_{\\sigma)} \n     - (\\qb\\cdot\\qa)g_{\\rho\\sigma}]\n    -(aa' - bb')g_{\\rho\\sigma}\n,\n\\nel \n{N_A}_{\\rho\\sigma} & =  & \n    i(ab' + ba')\n        \\varepsilon_{\\eta\\rho\\theta\\sigma}\\qa^\\eta \\qb^\\theta\n        .\n\\ee\n\nTwo products will be required. I first consider the symmetric parts:\n\n\\bem\nL_S^{\\rho\\sigma} {N_S}_{\\rho\\sigma}\n& =  &\n\\{\n    (AA' + BB')[2\\qpb^{(\\rho} \\qpa^{\\sigma)}  \n     - (\\qpb\\cdot\\qpa)g^{\\rho\\sigma}]\n    -(AA' - BB')g^{\\rho\\sigma}\n\\}\n\\nel && {} \\times\n\\{\n    (aa' + bb')[2\\qa_{(\\rho} \\qb_{\\sigma)} \n     - (\\qb\\cdot\\qa)g_{\\rho\\sigma}]\n    -(aa' - bb')g_{\\rho\\sigma}\n\\}\n\n\\nel\n& = & \n(aa' + bb')(AA' + BB')\n\\nel && \\qquad {} \\times \n[2\\qpb^{(\\rho} \\qpa^{\\sigma)} - (\\qpb\\cdot\\qpa)g^{\\rho\\sigma}]\n[2\\qa_{\\rho} \\qb_{\\sigma} - (\\qb\\cdot\\qa)g_{\\rho\\sigma}]\n\\nel \n&& {}\n- (aa' - bb')(AA' + BB')[2(\\qpb \\cdot \\qpa) - 4(\\qpb\\cdot\\qpa)]\n\\nel && {}\n- (aa' + bb')(AA' - BB')[2(\\qb \\cdot \\qa) - 4(\\qb\\cdot\\qa)]\n\\nel \n&& {}\n+ 4(aa' - bb')(AA' - BB')\n\\nel\n& = & \n(aa' + bb')(AA' + BB')\n[2(\\qpb \\cdot \\qa) (\\qpa \\cdot \\qb) + 2(\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)\n\\nel\n&& \\qquad {}\n- 2 (\\qb\\cdot\\qa) (\\qpb \\cdot \\qpa) - 2 (\\qb\\cdot\\qa) (\\qpb \\cdot \\qpa)\n + 4 (\\qb\\cdot\\qa) (\\qpb \\cdot \\qpa)]\n\\nel\n&& {}\n+ 2(aa' - bb')(AA' + BB')(\\qpb\\cdot\\qpa)\n\\nel\n&& {}\n+ 2(aa' + bb')(AA' - BB')(\\qb\\cdot\\qa)\n+ 4(aa' - bb')(AA' - BB')\n\\nel\n& = & \n2(aa' + bb')(AA' + BB')\n[(\\qpb \\cdot \\qa) (\\qpa \\cdot \\qb) + (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)]\n\\nel\n&& {}\n+ 2(aa' - bb')(AA' + BB')(\\qpb\\cdot\\qpa)\n\\nel\n&& {}\n+ 2(aa' + bb')(AA' - BB')(\\qb\\cdot\\qa)\n+ 4(aa' - bb')(AA' - BB')\n.\n\\ee\n\nTo calculate $L_A^{\\rho\\sigma} {N_A}_{\\rho\\sigma}$ I use the identity\n\\be\n\\varepsilon^{\\mu\\rho\\nu\\sigma} \\varepsilon_{\\eta\\rho\\theta\\sigma}\n= -2\n(\\delta^\\mu_\\eta \\delta^\\nu_\\theta - \\delta^\\mu_\\theta \\delta^\\nu_\\eta)\n.\n\\ee\n\nThus\n\\bem\nL_A^{\\rho\\sigma} {N_A}_{\\rho\\sigma}\n& = & \n-(ab' + ba')(AB' + BA')\n        \\varepsilon^{\\mu\\rho\\nu\\sigma}\\qpb_\\mu \\qpa_\\nu\n        \\varepsilon_{\\eta\\rho\\theta\\sigma}\\qa^\\eta \\qb^\\theta\n\\nel\n& = & \n2(ab' + ba')(AB' + BA')\n(\\delta^\\mu_\\eta \\delta^\\nu_\\theta - \\delta^\\mu_\\theta \\delta^\\nu_\\eta)\n\\qpb_\\mu \\qpa_\\nu\n\\qa^\\eta \\qb^\\theta\n\n\\nel\n& = & \n2(ab' + ba')(AB' + BA')\n[(\\qpb \\cdot \\qa) (\\qpa \\cdot \\qb) - (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)]\n.\n\\ee\n\nNow I use~\\rf{contractionWithSymAnti} to simplify the product \n$L^{\\rho\\sigma} N_{\\rho\\sigma}$,\n\\beml{chargeLMIs}\n\\lefteqn{\nL^{\\rho\\sigma} N_{\\rho\\sigma}\n= \n(L_S^{\\rho\\sigma} + L_A^{\\rho\\sigma})({N_S}_{\\rho\\sigma} + {N_A}_{\\rho\\sigma})\n= L_S^{\\rho\\sigma} {N_S}_{\\rho\\sigma} + L_A^{\\rho\\sigma} {N_A}_{\\rho\\sigma}\n}\n\\nel\n& = & \n2(aa' + bb')(AA' + BB')\n[(\\qpb \\cdot \\qa) (\\qpa \\cdot \\qb) + (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)]\n\\nel\n&& {} \n+ 2(ab' + ba')(AB' + BA')\n[(\\qpb \\cdot \\qa) (\\qpa \\cdot \\qb) - (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)]\n\\nel\n&& {}\n+ 2(aa' - bb')(AA' + BB')(\\qpb\\cdot\\qpa)\n\\nel\n&& {}\n+ 2(aa' + bb')(AA' - BB')(\\qb\\cdot\\qa)\n\\nel\n&& {}\n+ 4(aa' - bb')(AA' - BB')\n.\n\\ee\n\n\\P\nUnder the approximations $m_\\chi \\gg m_e$, $s \\gg 4m_e$\nI may use the formula~\\rf{cs-q-scalar-products}\nwhere $m = m_e$, $m' = m_\\chi$,\nto calculate the kinematic quantities in \\rf{chargeLMIs}, \n\\bem\n(\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb) + (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)\n&\\approx& {1 \\over 4m_e^2 m_\\chi^2}[2(m_\\chi^2 - t)^2 + s(s + 2t - 2m_\\chi^2)],\n\\nel\n(\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb) - (\\qpb \\cdot \\qb) (\\qpa \\cdot \\qa)\n&\\approx& {s \\over 4 m_e^2 m_\\chi^2}(s + 2t - 2m_\\chi^2),\n\\nel\n(\\qb\\cdot\\qa) &\\approx& {s \\over 2 m_e^2}\n,\n\\ee\n\n\\be\nt = (\\ppa - \\pa)^2 = (\\pb - \\ppb)^2\n.\n\\ee\n\nI also may neglect $2(aa' - bb')(AA' + BB')(\\qpb\\cdot\\qpa)$ and\n$4(aa' - bb')(AA' - BB')$ under \nthe same approximation because they do not contain $m_e^{-2}$. Thus\n\\bem\n\\lefteqn{\nL^{\\rho\\sigma} N_{\\rho\\sigma}\n}\n\\nel\n& \\approx  & \n{1 \\over 2m_e^2 m_\\chi^2} \\bigl\\{\n(aa' + bb')(AA' + BB')[2(m_\\chi^2 - t)^2 + s(s + 2t - 2m_\\chi^2)]\n\\nel && \\qquad {}\n+ (ab' + ba')(AB' + BA')s(s + 2t - 2m_\\chi^2) \\bigr\\}\n\\nel\n&& {}\n+ {s \\over m_e^2}(aa' + bb')(AA' - BB')\n\n\\nel\n& = & \n{(m_\\chi^2 - t)^2 \\over m_e^2 m_\\chi^2} (aa' + bb')(AA' + BB')\n\\nel && {}\n+\n{s(s + 2t - 2m_\\chi^2) \\over 2m_e^2 m_\\chi^2}\n[(ab' + ba')(AB' + BA') + (aa' + bb')(AA' + BB')]\n\\nel\n&& {}\n+ {s \\over m_e^2}(aa' + bb')(AA' - BB')\n,\n\\ee\n\nwhich is a real quantity so $X_{kk'}$ of the equation~\\rf{charge-X-boson-1}\nis given by\n\n\\beml{charge-X1}\n\\lefteqn{\nX_{kk'} \\approx \\Re[\\Delta_k(s)\\Delta_{k'}^\\hc(s)]\n}\n\\nel\n& \\times & \\Bigl\\{\n{(m_\\chi^2 - t)^2 \\over 4m_e^2 m_\\chi^2} \n(a_{k}a_{k'} + b_{k}b_{k'})(A_{k}A_{k'} + B_{k}B_{k'})\n\\nel\n&& {}\n+\n{s(s + 2t - 2m_\\chi^2) \\over 8m_e^2 m_\\chi^2}\n\\nel\n&& \\quad{}\\times\n[(a_{k}b_{k'} + b_{k}a_{k'})(A_{k}B_{k'} + B_{k}A_{k'}) \n    + (a_{k}a_{k'} + b_{k}b_{k'})(A_{k'}A_{k'} + B_{k}B_{k'})]\n\\nel\n&& {}\n+ {s \\over 4m_e^2}(a_{k}a_{k'} + b_{k}b_{k'})(A_{k}A_{k'} - B_{k}B_{k'})\n\\Bigr\\}\n.\n\\ee\n\n\n\\subsection{Contribution from the scalar neutrino channel}\n\n\nThe calculation of $X_{\\tilde\\nu\\tilde\\nu}$ \n(see~\\rf{charge-sneutrino-X-definition}) \nfollows the same pattern as for $X_{kk'}$,\n\n\n\\be\nX_{\\tilde\\nu\\tilde\\nu} = \n\\frac{1}{4}\\Re\\left[\\sum_{\\ra, \\rb, \\rpa, \\rpb}\nM_{\\tilde\\nu} M_{\\tilde\\nu}^{\\hc}\\right]\n=\n\\frac{1}{4}\\abs{\\Delta_{\\tilde\\nu}(t)}^2\\Re[L N],\n\\ee\n\nwhere $L$ and $N$ come from~\\rf{chargeMTriple} and~\\rf{chargeMShortExp}, \n\\bem\nL & = & \\sum_{\\rpa, \\rb}\n    [\\ub_{\\rpa}(\\ppa)(F + G\\gd{5})u_{\\rb}(\\pb)]\n    [\\ub_{\\rb}(\\pb)(F^\\hc - G^\\hc\\gd{5})u_{\\rpa}(\\ppa)]\n\\nel\n& = & \n\\frac{1}{4} \\Tr\n\\Bigl[(\\qcpa + 1)(F + G\\gd{5})\n      (\\qcb + 1)(F^\\hc - G^\\hc\\gd{5})\\Bigr]\n,\n\\ee\n\nand\n\\beml{charge-N-tmp23}\nN & = &  \\sum_{\\ra, \\rpb}  \n    [\\vb_{\\ra}(\\pa)(F^\\hc - G^\\hc\\gd{5})v_{\\rpb}(\\ppb)]\n    [\\vb_{\\rpb}(\\ppb)(F + G\\gd{5})v_{\\ra}(\\pa)]\n\\nel\n& = & \n\\frac{1}{4}\\Tr\n\\Bigl[(\\qca - 1)(F^\\hc - G^\\hc\\gd{5})\n      (\\qcpb - 1)(F + G\\gd{5})\\Bigr]\n\\nel & = &\nL(\\qpa \\rightarrow -\\qpb, \\qb \\rightarrow -\\qa).\n\\ee\n\nNow I simplify $L$:\n\\bem\nL \n& = &\n\\frac{1}{4} \\Tr\n\\Bigl[\\qcpa(F + G\\gd{5})\\qcb(\\cc{F} - \\cc{G}\\gd{5})\n      + (F + G\\gd{5})(\\cc{F} - \\cc{G}\\gd{5})\n\\Bigr]\n\n\\nel & = &\n\\frac{1}{4} \\Tr\n\\Bigl[\\qcpa\\qcb(F - G\\gd{5})(\\cc{F} - \\cc{G}\\gd{5})\n      + \\abs{F}^2 - \\abs{G}^2\n\\Bigr]\n\n\\nel & = &\n\\frac{1}{4} \\Tr\n\\Bigl[\\qcpa\\qcb(\\abs{F}^2 + \\abs{G}^2)\n      + \\abs{F}^2 - \\abs{G}^2\n\\Bigr]\n\n\\nel & = &\n(\\abs{F}^2 + \\abs{G}^2)(\\qpa \\cdot \\qb) + \\abs{F}^2 - \\abs{G}^2.\n\\ee\n\nThe relation~\\rf{charge-N-tmp23} gives for $N$\n\\bem\nN \n& = &\n(\\abs{F}^2 + \\abs{G}^2)(\\qpb \\cdot \\qa) + \\abs{F}^2 - \\abs{G}^2\n\\; = \\; L \n.\n\\ee\n\nThus I have\n\\bem\nX_{\\tilde\\nu\\tilde\\nu} & = & \n\n\\frac{1}{4}\\abs{\\Delta_{\\tilde\\nu}(t)}^2\\Re\\left\\{\n[(\\abs{F}^2 + \\abs{G}^2)(\\qpa \\cdot \\qb) + \\abs{F}^2 - \\abs{G}^2]^2\n\\right\\}\n\n\\nel  \n& = & \n\\frac{1}{4}\\abs{\\Delta_{\\tilde\\nu}(t)}^2\n[(\\abs{F}^2 + \\abs{G}^2)(\\qpa \\cdot \\qb) + \\abs{F}^2 - \\abs{G}^2]^2\n\n\\nel & \\approx & \n\\frac{1}{4}\\abs{\\Delta_{\\tilde\\nu}(t)}^2\n(\\abs{F}^2 + \\abs{G}^2)^2(\\qpa \\cdot \\qb)^2 \n,\n\\ee\n\nor\n\n\\bel{charge-X2}\nX_{\\tilde\\nu\\tilde\\nu} \\approx \n\\abs{\\Delta_{\\tilde\\nu}(t)}^2{(s + t - m_\\chi^2)^2 \\over 16 m_e^2 m_\\chi^2}\n(\\abs{F}^2 + \\abs{G}^2)^2\n,\n\\ee\n\nwhere I used \\rf{csKinApproximation} in the last step.\n\n\\subsection{Interference contribution.}\n\n\nTo find $X_{k\\tilde\\nu}$ I write for it according to~\\rf{chargeMShortExp}, \n\\be\nX_{k\\tilde\\nu} \\approx\n\\frac{1}{4}\\Re\\left[\\sum_{\\ra, \\rb, \\rpa, \\rpb}\nM_k M_{\\tilde\\nu}^{\\hc}\\right]\n=\n\\frac{1}{4}\\Re[\\Delta_k(s)\\Delta_{\\tilde\\nu}^\\hc(t) K]\n,\n\\ee\n\nwith $K$ given by\n\\bem\nK  \n& = & \\sum_{\\ra, \\rb, \\rpa, \\rpb}\n    [\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a - b\\gd{5})u_{\\rb}(\\pb)]\n\\nel && \\qquad\n{} \\times \n    [\\ub_{\\rb}(\\pb)(F^\\hc - G^\\hc\\gd{5})u_{\\rpa}(\\ppa)]\n    [\\vb_{\\rpb}(\\ppb)(F + G\\gd{5})v_{\\ra}(\\pa)]\n.\n\\ee\n\nI transform $K$ to the form necessary to calculate the spin\npolarization sums with the \nhelp of~\\rf{gammaCProperties} and~\\rf{gammaSpinorRelation}, \n\n\\beml{charge-before-spin-sums-1}\n[\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]\n& = &\n[\\ub_{\\rpb}(\\ppb)\\gu{\\rho}(A - B\\gd{5})v_{\\rpa}(\\ppa)]^T\n\\nel & = &\n[v_{\\rpa}^T(\\ppa)(A - B\\gd{5}^T)\\gu{\\rho}^T\\ub_{\\rpb}^T(\\ppb)]\n\\nel & = &\n[v_{\\rpa}^T(\\ppa)CC^{-1}(A - B\\gd{5}^T)\\gu{\\rho}^TCC^{-1}\\ub_{\\rpb}^T(\\ppb)]\n\\nel & = &\n-[\\ub_{\\rpa}(\\ppa)(A - B C^{-1}\\gd{5}^T C)C^{-1}\\gu{\\rho}^TC v_{\\rpb}(\\ppb)]\n\\nel & = &\n[\\ub_{\\rpa}(\\ppa)(A - B \\gd{5})\\gu{\\rho} v_{\\rpb}(\\ppb)]\n.\n\\ee\n    \nNow I can represent $K$ as a trace\n\\bem\nK  \n& = & \\sum_{\\ra, \\rb, \\rpa, \\rpb}\n    [\\ub_{\\rpa}(\\ppa)(A - B \\gd{5})\\gu{\\rho} v_{\\rpb}(\\ppb)]\n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a - b\\gd{5})u_{\\rb}(\\pb)]\n\\nel && \\qquad\n{} \\times \n    [\\ub_{\\rb}(\\pb)(F^\\hc - G^\\hc\\gd{5})u_{\\rpa}(\\ppa)]\n    [\\vb_{\\rpb}(\\ppb)(F + G\\gd{5})v_{\\ra}(\\pa)]\n\\nel\n& = & \\sum_{\\ra, \\rb, \\rpa, \\rpb}\n    [\\ub_{\\rpa}(\\ppa)(A - B \\gd{5})\\gu{\\rho} v_{\\rpb}(\\ppb)]\n    [\\vb_{\\rpb}(\\ppb)(F + G\\gd{5})v_{\\ra}(\\pa)]\n\\nel && \\qquad\n{} \\times \n    [\\vb_{\\ra}(\\pa)\\gd{\\rho}(a - b\\gd{5})u_{\\rb}(\\pb)]\n    [\\ub_{\\rb}(\\pb)(F^\\hc - G^\\hc\\gd{5})u_{\\rpa}(\\ppa)]\n\\nel\n& = & {1 \\over 16} \\Tr \\Bigl[\n    (\\qcpa + 1)(A - B \\gd{5})\\gu{\\rho} (\\qcpb - 1)(F + G\\gd{5})\n\\nel && \\qquad\n{} \\times \n    (\\qca - 1) \\gd{\\rho}(a - b\\gd{5}) (\\qcb + 1)(F^\\hc - G^\\hc\\gd{5})\n    \\Bigr]\n.\n\\ee\n\n\\P\n\nTo simplify $K$ I use $m_\\chi \\gg m_e$, thus I can omit terms without \n$m_e^{-2}$ that come from $\\qca = \\pca/m_e$, $\\qcb = \\pcb/m_e$. I also \nkeep only terms with an even number of Dirac matrices, \n\\bem\nK  \n& \\approx & \n{1 \\over 16} \\Tr [\n    \\qcpa(A - B \\gd{5})\\gu{\\rho}\\qcpb(F + G\\gd{5})\n    \\qca \\gd{\\rho}(a - b\\gd{5}) \\qcb(F^\\hc - G^\\hc\\gd{5})\n    ]\n\\nel && {} \n-\n{1 \\over 16} \\Tr [\n    (A - B \\gd{5})\\gu{\\rho}(F + G\\gd{5})\n    \\qca \\gd{\\rho}(a - b\\gd{5}) \\qcb(F^\\hc - G^\\hc\\gd{5})\n    ]\n\\nel& = &\n{1 \\over 16} (K_1 - K_2),\n\\ee\n\nwhere $K_1$ and $K_2$ are given by\n\\bem\nK_1 & = & \n\\Tr [\\qcpa(A - B \\gd{5})\\gu{\\rho}\\qcpb(F + G\\gd{5})\n    \\qca \\gd{\\rho}(a - b\\gd{5}) \\qcb(F^\\hc - G^\\hc\\gd{5})]\n\\nel & = & \n\\Tr [\\qcpa\\gu{\\rho}\\qcpb(A - B \\gd{5})(F + G\\gd{5})\n    \\qca \\gd{\\rho}\\qcb (a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n\\nel & = & \n\\Tr [\\qcpa\\gu{\\rho}\\qcpb\\qca \\gd{\\rho}\\qcb\n     (A + B \\gd{5})(F - G\\gd{5})\n     (a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n,\n\\ee\n\n\\bem\nK_2 & = &\n\\Tr [(A - B \\gd{5})\\gu{\\rho}(F + G\\gd{5})\n    \\qca \\gd{\\rho}(a - b\\gd{5}) \\qcb(F^\\hc - G^\\hc\\gd{5})]\n\\nel & = &\n\\Tr [\\gu{\\rho}(A + B \\gd{5})(F + G\\gd{5})\n    \\qca \\gd{\\rho}\\qcb(a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n\\nel & = &\n\\Tr [\\gu{\\rho}\\qca \\gd{\\rho}\\qcb(A - B \\gd{5})(F - G\\gd{5})\n    (a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n.\n\\ee\n\nTo find the sandwich-like products $\\gu{\\rho} \\dots \\gd{\\rho}$ I use \nthe basic properties \\rf{gammaAlgebra} of the Dirac algebra,\n\n\\be\n\\gu{\\rho}\\qca \\gd{\\rho} = -\\gu{\\rho}\\gd{\\rho}\\qca + 2\\gu{\\rho} \\qa_\\rho\n= -4\\qca + 2\\qca = - 2\\qca, \n\\ee\n\nand\n\\be\n\\gu{\\rho}\\qcpb\\qca \\gd{\\rho}\n= \n-\\gu{\\rho}\\qcpb\\gd{\\rho}\\qca + 2 \\gu{\\rho}\\qcpb \\qa_\\rho \n= 2\\qcpb \\qca + 2 \\qca \\qcpb = 2\\{\\qcpb, \\qca\\} = 4 (\\qpb \\cdot \\qa)\n.\n\\ee\n\nIt gives for $K_1$ and $K_2$ \n\n\\bem\nK_1 & = & 4 (\\qpb \\cdot \\qa) \\Tr [\\qcpa\\qcb\n     (A + B \\gd{5})(F - G\\gd{5})\n     (a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n\\nel & = &\n4 (\\qpb \\cdot \\qa) \\Tr [\\qcpa\\qcb\n\\nel && \\qquad {} \\times\n     \\{AF - BG +\\gd5(BF - AG)\\}\n     \\{aF^\\hc - bG^\\hc +\\gd5(bF^\\hc - aG^\\hc)\\}]\n\\nel & = &\n4 (\\qpb \\cdot \\qa) \\Tr [\\qcpa\\qcb\n     \\{(AF - BG)(aF^\\hc - bG^\\hc) + (BF - AG)(bF^\\hc - aG^\\hc) \\} ]\n\n\\nel & = &\n16 (\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb)\n[(AF - BG)(aF^\\hc - bG^\\hc) + (BF - AG)(bF^\\hc - aG^\\hc)]\n\\nel & = &\n16 (\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb)\n[(aA + bB)\\abs{F}^2  + (aA + bB)\\abs{G}^2\n\\nel & & \\quad {}\n- GF^\\hc(bA + aB) - FG^\\hc(bA + aB)]\n\\nel & = &\n16 (\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb)\n[(aA + bB)(\\abs{F}^2  + \\abs{G}^2) - 2\\Re(FG^\\hc)(bA + aB)]\n,\n\\ee\n\nand\n\\bem\nK_2 & = &\n-2 \\Tr [\\qca\\qcb(A - B \\gd{5})(F - G\\gd{5})\n    (a + b\\gd{5}) (F^\\hc - G^\\hc\\gd{5})]\n\\nel & = &\n-2 \\Tr [\\qca\\qcb\n     \\{AF + BG - \\gd5(BF + AG)\\}\n     \\{aF^\\hc - bG^\\hc +\\gd5(bF^\\hc - aG^\\hc)\\}]\n\\nel & = &\n-2 \\Tr [\\qca\\qcb\n     \\{(AF + BG)(aF^\\hc - bG^\\hc) + (BF + AG)(aG^\\hc - bF^\\hc)\\}]\n\\nel & = &\n-8(\\qb \\cdot \\qa) \n[(AF + BG)(aF^\\hc - bG^\\hc) + (BF + AG)(aG^\\hc - bF^\\hc)]\n\\nel & = &\n-8(\\qb \\cdot \\qa) \n[(aA -bB)\\abs{F}^2 + (aA - bB)\\abs{G}^2 \n\\nel & & \\quad {}\n+ GF^\\hc(aB - bA) + FG^\\hc(aB - bA)]\n\\nel & = &\n-8(\\qb \\cdot \\qa) \n[(aA - bB)(\\abs{F}^2  + \\abs{G}^2) + 2\\Re(FG^\\hc)(aB - bA)]\n,\n\\ee\n\nwhere I used~\\rf{gammaTraces} and~\\rf{gammaZeroTraces} \ntogether with $\\gd5^2 = 1$. Thus\n\n\\bem\nK & \\approx & \n{1 \\over 16} (K_1 - K_2)\n\\nel\n& = & \n(\\qpb \\cdot \\qa)(\\qpa \\cdot \\qb)\n[(aA + bB)(\\abs{F}^2  + \\abs{G}^2) - 2\\Re(FG^\\hc)(bA + aB)]\n\\nel && {} + \n{1 \\over 2} (\\qb \\cdot \\qa) \n[(aA - bB)(\\abs{F}^2 + \\abs{G}^2) - 2\\Re(FG^\\hc)(bA - aB)]\n\\nel & \\approx & \n{(s + t - m_\\chi^2)^2 \\over 4 m_e^2 m_\\chi^2}\n[(aA + bB)(\\abs{F}^2  + \\abs{G}^2) - 2\\Re(FG^\\hc)(bA + aB)]\n\\nel && {} + \n{s \\over 4m_e^2}\n[(aA - bB)(\\abs{F}^2 + \\abs{G}^2) - 2\\Re(FG^\\hc)(bA - aB)]\n\\ee\n\nfrom~\\rf{csKinApproximation}. \n\n\\P\nNow I have for the interference contribution $X_{k\\tilde\\nu}$ \n\n\\beml{charge-X3}\nX_{k\\tilde\\nu} & \\approx & \n\\frac{1}{4}\\Re[\\Delta_k(s)\\Delta_{\\tilde\\nu}^\\hc(t) K]\n\\nel & \\approx & \n{(s + t - m_\\chi^2)^2 \\over 16 m_e^2 m_\\chi^2}\n\\Re[\\Delta_k(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && \\qquad {} \\times\n[(a_k A_k + b_kB_k)(\\abs{F}^2  + \\abs{G}^2) - 2\\Re(FG^\\hc)(b_k A_k + a_k B_k)]\n\\nel && {} + \n{s \\over 16 m_e^2}\n\\Re[\\Delta_k(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)] \n\\nel && \\qquad {} \\times\n[(a_k A_k - b_k B_k)(\\abs{F}^2 + \\abs{G}^2) - 2\\Re(FG^\\hc)(b_k A_k - a_k B_k)]\n.\n\\ee\n\n\\subsection{Differential cross section}\n\nAccording to~\\rf{chargeFullX} and~\\rf{csDifApproximation} \nthe differential cross section for the chargino production process\nis given by\n\n\\be\n\\left({d\\sigma \\over d\\Omega }\\right)_{\\rm c.m.}\n\\approx {m_e^2 m_\\chi^2  \\over 4\\pi^2 s} \\sqrt{1 - 4\\rho}X_{e\\chi}(s, t),\n\\ee\n\nwhere\n\\be\n\\rho = {m_\\chi^2 \\over s},\n\\ee\n\nand\n\\bel{charge-differential-as-a-sum}\nX_{e\\chi}(s, t)\n= X_{\\gamma\\gamma} + X_{ZZ} + 2X_{\\gamma Z} + X_{\\tilde\\nu\\tilde\\nu} \n+ 2X_{\\gamma\\tilde\\nu} + 2X_{Z\\tilde\\nu}\n.\n\\ee\n\nThe first three terms in~\\rf{charge-differential-as-a-sum} are given \nby~\\rf{charge-X1},\n\n\\beml{charge-d-gamma-gamma}\nX_{\\gamma\\gamma} & \\approx & { \\Delta_\\gamma^2(s) \\over 4m_e^2 m_\\chi^2 }\n\\Bigl\\{\n(m_\\chi^2 - t)^2 a_\\gamma^2 A_\\gamma^2\n+ {1 \\over 2} s(s + 2t - 2m_\\chi^2) a_\\gamma^2 A_\\gamma^2\n+ s m_\\chi^2 a_\\gamma^2 A_\\gamma^2 \\Bigr\\}\n\\nel\n& = &\n{e^4 \\over 4s^2m_e^2 m_\\chi^2 }\n[(m_\\chi^2 - t)^2  + s m_\\chi^2\n+ {1 \\over 2} s(s + 2t - 2m_\\chi^2)\n],\n\\ee\n\nwhere I use~\\rf{chargeGabIs}, \\rf{chargeGABIs} and~\\rf{photonPropogator},\n\\be\n-a_\\gamma = A_\\gamma = e, \\quad b_\\gamma = B_\\gamma = 0,\n\\quad \\Delta_\\gamma(s) = {1 \\over s}.\n\\ee\n\nThe explicit form of $X_{ZZ}$ is\n\\bem\nX_{ZZ} & \\approx & {\\abs{\\Delta_Z(s)}^2 \\over  4m_e^2 m_\\chi^2 }\n\\Bigl\\{\n(m_\\chi^2 - t)^2 (a_Z^2 + b_Z^2)(A_Z^2 + B_Z^2)\n\\nel\n&& {}\n+\n{1 \\over 2} s(s + 2t - 2m_\\chi^2) \n[(2a_Z b_Z)(2A_Z B_Z) + (a_Z^2 + b_Z^2)(A_Z^2 + B_Z^2)]\n\\nel\n&& {}\n+ sm_\\chi^2(a_Z^2 + b_Z^2)(A_Z^2 - B_Z^2)\n\\Bigr\\}.\n\\ee\n\nI find for the coefficients in the last expressions\n\n\\bem\na_Z^2 + b_Z^2 & = &\n{g^2 \\over 16\\cos^2\\theta_W}[(1 - 4\\sin^2\\theta_W)^2 + 1]\n\\nel &=& {g^2 \\over 8\\cos^2\\theta_W}(1 - 4\\sin^2\\theta_W + 8\\sin^4\\theta_W)\n\\quad (\\mbox{from \\rf{chargeZabIs}})\n,\n\\ee\n\nand\n\\be\na_Z b_Z = \n{g^2 \\over 16\\cos^2\\theta_W}(1 - 4\\sin^2\\theta_W)\n.\n\\ee\n\nThe definitions~\\rf{chargeZABIs} lead to\n\\bem\nA_Z^2 \\pm B_Z^2 &= &\n{g^2 \\over 16\\cos^2\\theta_W}\n\\{\n[2\\cos (2\\theta_W) + \\abs{Y_{11}}^2 + \\abs{X_{11}}^2]^2\n\\pm [\\abs{Y_{11}}^2 - \\abs{X_{11}}^2]^2\n\\}\n,\n\\nel\nA_Z B_Z &= &\n-{g^2 \\over 16\\cos^2\\theta_W}\n[2\\cos (2\\theta_W) + \\abs{Y_{11}}^2 + \\abs{X_{11}}^2]\n[\\abs{Y_{11}}^2 - \\abs{X_{11}}^2]\n.\n\\ee\n\nThus\n\\beml{charge-d-Z-Z}\nX_{ZZ} & \\approx & {a_Z^2 + b_Z^2 \\over 4m_e^2 m_\\chi^2}\\abs{\\Delta_Z(s)}^2\n[\n(m_\\chi^2 - t)^2 (A_Z^2 + B_Z^2) + s m_\\chi^2 (A_Z^2 - B_Z^2)\n]\n\\nel &&{} +\n{s(s + 2t - 2m_\\chi^2) \\over 8m_e^2 m_\\chi^2} \\abs{\\Delta_Z(s)}^2\n[4 a_Z b_Z A_Z B_Z + (a_Z^2 + b_Z^2)(A_Z^2 + B_Z^2)] .\n\\nel\n\\ee\n\n\\P\nThe interference between the $\\gamma$ and $Z^0$ channels reads,\naccording to the equation~\\rf{charge-X1}\n\\beml{charge-d-gamma-Z}\n\\lefteqn{\nX_{\\gamma Z}\n}\n\\nel & \\approx & {\\Delta_\\gamma(s)\\Re(\\Delta_Z^\\hc(s)) \\over 4m_e^2 m_\\chi^2}\n\\Bigl\\{\n(m_\\chi^2 - t)^2(a_\\gamma a_Z)(A_\\gamma A_Z)\n\\nel\n&& {}\n+\n{1\\over 2} s(s + 2t - 2m_\\chi^2)\n[(a_\\gamma b_Z)(A_\\gamma B_Z) + (a_\\gamma a_Z)(A_\\gamma A_Z)]\n\\nel\n&& {}\n+ s m_\\chi^2(a_\\gamma a_Z)(A_\\gamma A_Z)\n\\Bigr\\}\n\\nel\n& = &\n-{e^2 a_Z A_Z \\over 4sm_e^2 m_\\chi^2} \\Re(\\Delta_Z(s))\n\\nel&& {} \\quad \\times\n\\Biggl[\n(m_\\chi^2 - t)^2 \n+\n{1 \\over 2}s(s + 2t - 2m_\\chi^2) \n\\left( {b_Z B_Z\\over a_Z A_Z} + 1\\right)\n+ sm_\\chi^2\n\\Biggr]\n.\n%\\nel\n\\ee\n\n\\P\nThe expression for $X_{\\tilde\\nu\\tilde\\nu}$ is given by~\\rf{charge-X2}.\nIf I substitute there the definitions~\\rf{chargeFandG1} and~\\rf{chargeFandG2},\nthen\n\\be\n\\abs{F}^2 + \\abs{G}^2 \\approx {g^2 \\over 2}\\cos^2\\theta_X, \n\\quad\n2\\Re(FG^\\hc) \\approx {g^2 \\over 2}\\cos^2\\theta_X,\n\\ee\n\nwhere according to~\\rf{lagrangian-theta-X-and-Y} \nand~\\rf{lagrangian-eta-X-and-Y}\n\\be\n\\cos^2\\theta_X = {1 \\over 2 + 2 \\eta_X^2 - 2\\sqrt{1 + \\eta_X^2}}, \n\\quad \n\\eta_X = \n   \\frac{m_{\\tilde\\Lambda}^2 - \\abs{\\mu}^2 + 2m_W^2\\cos(2\\beta)}\n        {2\\sqrt{2}m_W\\abs{m_{\\tilde\\Lambda}\\sin\\beta + \\mu^* \\cos\\beta}}\n        .\n\\ee\n\n\nThus\n\\beml{charge-d-nu-nu}\nX_{\\tilde\\nu\\tilde\\nu} &\\approx &\n\\abs{\\Delta_{\\tilde\\nu}(t)}^2{(s + t - m_\\chi^2)^2 \\over 16 m_e^2 m_\\chi^2}\n(\\abs{F}^2 + \\abs{G}^2)^2\n\\nel\n& = &\ng^4 \\cos^4\\theta_X\n\\abs{\\Delta_{\\tilde\\nu}(t)}^2{(s + t - m_\\chi^2)^2 \\over 64 m_e^2 m_\\chi^2}\n.\n\\ee\n\nNow I use~\\rf{charge-X3} to write the photon--$\\tilde\\nu$ \ninterference term $X_{\\gamma\\tilde\\nu}$\n\n\\beml{charge-d-gamma-nu}\nX_{\\gamma\\tilde\\nu} & \\approx & \n{(s + t - m_\\chi^2)^2 \\over 16 m_e^2 m_\\chi^2}\n\\Delta_\\gamma(s) \\Re[\\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && \\qquad {} \\times\n[(a_\\gamma A_\\gamma)(\\abs{F}^2  + \\abs{G}^2)]\n\\nel && {} + \n{s \\over 16 m_e^2}\n\\Delta_\\gamma(s)\\Re[\\Delta_{\\tilde{\\nu}}^\\hc(t)] \n[(a_\\gamma A_\\gamma)(\\abs{F}^2 + \\abs{G}^2)]\n\n\\nel & = &\n-{e^2 (\\abs{F}^2 + \\abs{G}^2) \\over 16s m_e^2 m_\\chi^2}\n\\Re[\\Delta_{\\tilde{\\nu}}(t)]\n\\left[(s + t - m_\\chi^2)^2 + s m_\\chi^2\\right]\n\n\\nel & = &\n-{e^2 g^2 \\cos^2\\theta_X \\over 32 s m_e^2 m_\\chi^2}\n\\Re[\\Delta_{\\tilde{\\nu}}(t)]\n\\left[(s + t - m_\\chi^2)^2 + s^2\\rho \\right]\n.\n\\ee\n\nIn a similar way $X_{Z\\tilde\\nu}$ becomes\n\\beml{charge-d-gamma-nu1}\nX_{Z\\tilde\\nu} & \\approx & \n{(s + t - m_\\chi^2)^2 \\over 16 m_e^2 m_\\chi^2}\n\\Re[\\Delta_Z(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && \\qquad {} \\times\n[(a_Z A_Z + b_Z B_Z)(\\abs{F}^2  + \\abs{G}^2) - 2\\Re(FG^\\hc)(b_Z A_Z + a_Z B_Z)]\n\\nel && {} + \n{s \\over 16 m_e^2}\n\\Re[\\Delta_Z(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)] \n\\nel && \\qquad {} \\times\n[(a_Z A_Z - b_Z B_Z)(\\abs{F}^2 + \\abs{G}^2) - 2\\Re(FG^\\hc)(b_Z A_Z - a_Z B_Z)]\n\\nel\n& = &\n{1 \\over 16 m_e^2 m_\\chi^2 } \\Re[\\Delta_Z(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && {}\\times\n{g^2 \\cos^2\\theta_X \\over 2}\n\\Bigl[\n(s + t - m_\\chi^2)^2(a_Z A_Z + b_Z B_Z - b_Z A_Z - a_Z B_Z)\n\\nel && {}\\qquad\n+\nsm_\\chi^2(a_Z A_Z - b_Z B_Z - b_Z A_Z + a_Z B_Z)\n\\Bigr]\n\\nel\n& = &\n{a_Z - b_Z \\over 16 m_e^2 m_\\chi^2 } \\Re[\\Delta_Z(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && {}\\times\n{g^2 \\cos^2\\theta_X \\over 2}\n\\Bigl[\n(s + t - m_\\chi^2)^2(A_Z - B_Z)\n+\nsm_\\chi^2(A_Z + B_Z)\n\\Bigr]\n.\n\\ee\n\nFrom~\\rf{chargeZabIs} and~\\rf{chargeZABIs} I have\n\\be\na_Z - b_Z  =  {g \\sin^2 \\theta_W \\over \\cos \\theta_W},\n\\ee\n\nand\n\\bem\nA_Z + B_Z &= &\n{g \\over 4\\cos\\theta_W}\n\\{[2\\cos (2\\theta_W) + \\abs{Y_{11}}^2 + \\abs{X_{11}}^2] \n- [\\abs{Y_{11}}^2 - \\abs{X_{11}}^2]\\}\n\\nel\n& = &\n{g \\over 2\\cos\\theta_W}[\\cos(2\\theta_W) + \\abs{X_{11}}^2]\n= \n{g \\over 2\\cos\\theta_W}[\\cos(2\\theta_W) + \\cos^2\\theta_X]\n,\n\\nel\nA_Z - B_Z & = &\n{g \\over 2\\cos\\theta_W}[\\cos(2\\theta_W) + \\abs{Y_{11}}^2]\n= \n{g \\over 2\\cos\\theta_W}[\\cos(2\\theta_W) + \\cos^2\\theta_Y],\n\\ee\n\nThus\n\\beml{charge-d-Z-nu}\nX_{Z\\tilde\\nu} & \\approx & \n{g^4 \\tan^2 \\theta_W \\cos^2\\theta_X \\over 64 m_e^2 m_\\chi^2}\n \\Re[\\Delta_Z(s) \\Delta_{\\tilde{\\nu}}^\\hc(t)]\n\\nel && {} \\times\n\\Bigl[\n(s + t - m_\\chi^2)^2(\\cos(2\\theta_W) + \\cos^2\\theta_Y)\n+\nsm_\\chi^2(\\cos(2\\theta_W) + \\cos^2\\theta_X)\n\\Bigr]\n\\nel\n.\n\\ee\n\n\n\\subsection{Total cross section}\n\nI have for the total cross-section from~\\rf{csTotalApproximation},\n\\bel{chargeCross}\n\\sigma^T_{e\\chi}(s)  \n= {m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} \nX_{e\\chi}(s, t) \\, dt\n= \\sigma^T_{\\gamma\\gamma} \n+ \\sigma^T_{ZZ} \n+ 2\\sigma^T_{\\gamma Z} \n+ \\sigma^T_{\\tilde{\\nu}\\tilde{\\nu}} \n+ 2\\sigma^T_{\\gamma \\tilde{\\nu}} \n+ 2\\sigma^T_{Z \\tilde{\\nu}}\n,\n\\ee\n\nwith the limits of integration\n\\bel{charge-t-plus-minus-is}\nt_{\\pm} \\approx {s \\over 2} (2\\rho - 1 \\pm \\sqrt{1 - 4\\rho})\n.\n\\ee\n\nI use \\rf{csInt1}--\\rf{csInt65} to calculate the integrals  \nin~\\rf{chargeCross} together with the \nexpressions~\\rf{chargeSneutrinoDelta} and~\\rf{ZPropogator} for \n$\\Delta_Z(s)$ and $\\Delta_{\\tilde{\\nu}}(t)$,\n\\be\n\\Delta_Z(s) \n= {1 \\over s - \\mB^2 + i\\mB\\Gamma_Z} \n= {s - \\mB^2 - i\\mB\\Gamma_Z \\over (s - \\mB^2)^2 + \\mB^2\\Gamma_Z^2},\n\\ee\n\n\\bel{charge-x-is}\n\\Delta_{\\tilde{\\nu}}(t) = {1 \\over t - x} ,\n\\quad x =  m_{\\tilde{\\nu}}^2 - im_{\\tilde{\\nu}}\\Gamma_{\\tilde{\\nu}}\n.\n\\ee\n\nI obtain for the photon-channel contribution from~\\rf{charge-d-gamma-gamma}  \n\n\\bem\n\\sigma^T_{\\gamma\\gamma} & = & \n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{\\gamma\\gamma} dt\n\\nel\n&\\approx&\n{e^4 \\over 4\\pi s^4 }\n\\int_{t_-}^{t_+}[(m_\\chi^2 - t)^2  + s m_\\chi^2 \n+ {1 \\over 2} s(s + 2t - 2m_\\chi^2)]dt\n\\nel&=&\n {e^4 \\over 4\\pi s^4 }\n[{s^3 \\over 3} (1 - \\rho)\\sqrt{1 - 4\\rho} + s^2 \\rho(t_+ - t_-) + 0]\n\\nel&=&\n{e^4 \\over 4\\pi s^4 }\n[{s^3 \\over 3} (1 - \\rho)\\sqrt{1 - 4\\rho} + s^3 \\rho\\sqrt{1 - 4\\rho}]\n,\n\\ee\n\nwhere the integration was carried out with the help \nof~\\rf{csInt2} and~\\rf{csInt1}. So I find\n\n\\bel{charge-total-gamma-gamma}\n\\sigma^T_{\\gamma\\gamma}(s) = \n{e^4 \\over 4\\pi s} \\sqrt{1 - 4\\rho}{1 + 2\\rho \\over 3}\n.\n\\ee\n\nSimilarly for the $Z^0$-channel contribution, the equation~\\rf{charge-d-Z-Z}\nyields\n\\bem\n\\sigma^T_{ZZ} & = & \n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{ZZ} dt\n\\nel\n& \\approx & {a_Z^2 + b_Z^2 \\over 4\\pi s^2}\\abs{\\Delta_Z(s)}^2\n\\int_{t_-}^{t_+}[\n(m_\\chi^2 - t)^2 (A_Z^2 + B_Z^2) + s m_\\chi^2 (A_Z^2 - B_Z^2)\n]dt + 0\n,\n\\ee\n\nwhere again the term in $X_{ZZ}$ proportional to $(s + 2t - 2m_\\chi^2)$\ndoes not contribute to the integral. Thus,\n\\bem\n\\sigma^T_{ZZ} & = & \n{a_Z^2 + b_Z^2 \\over 4\\pi s^2}\\abs{\\Delta_Z(s)}^2\n\\biggl[{s^3 \\over 3} (1 - \\rho)\\sqrt{1 - 4\\rho}(A_Z^2 + B_Z^2)\n\\nel&& {} \\qquad\n  + s^3\\rho \\sqrt{1 - 4\\rho}(A_Z^2 - B_Z^2)\n\\biggr]\n\\nel\n& = & \n{a_Z^2 + b_Z^2 \\over 4\\pi} s\\abs{\\Delta_Z(s)}^2\n\\left[{1 \\over 3} (1 - \\rho)(A_Z^2 + B_Z^2)\n  + \\rho (A_Z^2 - B_Z^2)\n\\right]\\sqrt{1 - 4\\rho},\n\\ee\n\nso\n\\bel{charge-total-Z-Z}\n\\sigma^T_{ZZ}(s) = \n{a_Z^2 + b_Z^2 \\over 4\\pi} s\\abs{\\Delta_Z(s)}^2\\sqrt{1 - 4\\rho}\n\\left[A_Z^2{1 + 2\\rho \\over 3} + B_Z^2{1 - 4\\rho \\over 3}\\right].\n\\ee\n\nThe calculation of $\\sigma^T_{\\gamma Z}$ is also straightforward. \nI obtain from~\\rf{charge-d-gamma-Z}\n\\bem\n\\sigma^T_{\\gamma Z}(s) & = &\n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{Z\\gamma} dt\n\\nel\n&\\approx&\n-{e^2 a_Z A_Z \\over 4\\pi s^3} \\Re(\\Delta_Z(s))\n\\int_{t_-}^{t_+}[(m_\\chi^2 - t)^2 + sm_\\chi^2]dt \n\\nel&=&\n-{e^2 a_Z A_Z \\over 4\\pi s^3} \\Re(\\Delta_Z(s))\n\\left[{s^3 \\over 3} (1 - \\rho)\\sqrt{1 - 4\\rho} \n   + s^3 \\rho\\sqrt{1 - 4\\rho}\\right],\n\\ee\n\nor\n\\bel{charge-total-gamma-Z}\n\\sigma^T_{\\gamma Z}(s)\n=\n-{e^2 a_Z A_Z \\over 4\\pi} \\Re(\\Delta_Z(s))\n\\sqrt{1 - 4\\rho}{1 + 2\\rho \\over 3}\n.\n\\ee\n\n\\P\nCalculations of the terms in~\\rf{chargeCross} that involve scalar neutrinos\nis more complicated due to the integrations over $\\Delta_{\\tilde\\nu}(t)$-like\nterms. By the equation~\\rf{charge-d-nu-nu}\n\n\\bem\n\\sigma^T_{\\tilde{\\nu}\\tilde{\\nu}} & = &\n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{\\tilde\\nu\\tilde\\nu} dt\n\\nel\n&\\approx &\n\n{g^4 \\cos^4\\theta_X\\over 64 \\pi s^2}\n\\int_{t_-}^{t_+} \\abs{\\Delta_{\\tilde\\nu}(t)}^2(s + t - m_\\chi^2)^2 dt\n\\nel\n& = &\n{g^4 \\cos^4\\theta_X\\over 64 \\pi s^2}\n\\int_{t_-}^{t_+} \n{1 \\over \\abs{t - x}^2}[t - s(\\rho - 1)]^2\ndt.\n\\ee\n\nAccording to~\\rf{csInt65} and from the definition~\\rf{charge-x-is} of $x$ I get\n\\beml{charge-total-nu-nu}\n\\sigma^T_{\\tilde{\\nu}\\tilde{\\nu}} & \\approx  &\n{g^4 \\cos^4\\theta_X\\over 64 \\pi s^2}\n\\Biggl\\{\n{[\\Re(x) + s(1 - \\rho)]^2 - \\Im(x)^2 \\over \\Im(x)}\n\\phi(x)\n\\nel&&\n\\qquad{}\n+ 2[\\Re(x) + s(1 - \\rho)]\\ln\\abs{t_+ - x \\over t_- - x}\n+ s\\sqrt{1 - 4\\rho}\n\\Biggr\\}\n\\nel & \\equiv  &\n{g^4 \\cos^4\\theta_X\\over 64 \\pi s^2}\n\\Biggl\\{\n-{[m_{\\tilde{\\nu}}^2 + s(1 - \\rho)]^2 \n    - m_{\\tilde{\\nu}}^2\\Gamma_{\\tilde{\\nu}}^2 \n  \\over m_{\\tilde{\\nu}}\\Gamma_{\\tilde{\\nu}}}\n\\phi(x)\n\\nel&&\n\\qquad{}\n+ 2[m_{\\tilde{\\nu}}^2 + s(1 - \\rho)]\\ln\\abs{t_+ - x \\over t_- - x}\n+ s\\sqrt{1 - 4\\rho}\n\\Biggr\\}\n,\n\\ee\n\nwhere $\\phi(x)$ is defined in~\\rf{csImLog}. In this case it becomes\n\\bem\n\\phi(x) & = & \\arctg{s\\sqrt{1 - 4\\rho}\\Im(x)\n         \\over m_\\chi^4 + \\abs{x}^2 - s(2\\rho - 1)\\Re(x)}\n\\nel\n& \\equiv &          \n-\n\\arctg{s\\sqrt{1 - 4\\rho}\\, m_{\\tilde{\\nu}}\\Gamma_{\\tilde{\\nu}}\n         \\over s^2 \\rho^2 \n            + m_{\\tilde{\\nu}}^2[m_{\\tilde{\\nu}}^2 + \\Gamma_{\\tilde{\\nu}}^2\n             + s(1 - 2\\rho)]}\n.\n\\ee\n\n\\P\nFinally I consider the interference between the bosons and sneutrino channels.\nTo find $\\sigma^T_{\\gamma\\tilde{\\nu}}$ from~\\rf{charge-d-gamma-nu} \nI apply~\\rf{csInt3} and~\\rf{csInt4} \nin the case when $z = 1$, so\n\\bem\n\\sigma^T_{\\gamma\\tilde{\\nu}}\n& = &\n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{\\gamma\\tilde\\nu} dt\n\\nel\n& \\approx &\n-{e^2 g^2 \\cos^2\\theta_X \\over 32\\pi s^3 }\n\\int_{t_-}^{t_+} \n\\Re[\\Delta_{\\tilde{\\nu}}(t)]\n\\left[(s + t - m_\\chi^2)^2 + s m_\\chi^2\\right]\ndt\n\\nel\n& = &\n-{e^2 g^2 \\cos^2\\theta_X \\over 32\\pi s^3 }\n\\int_{t_-}^{t_+} \n\\Re\\left({ 1 \\over t - x}\\right)\n\\left\\{[t - s(\\rho - 1)]^2 + s m_\\chi^2\\right\\}\ndt\n\\nel\n& = &\n-\n{e^2 g^2 \\cos^2\\theta_X \\over 32\\pi s^3 }\n\\Biggl\\{\n\\Re[(x - s(\\rho - 1))^2] \\ln\\abs{t_+ - x \\over t_- - x}\n\\nel\n&&\\qquad{}\n+ \\Im[((x - s(\\rho - 1))^2] \\phi(x)\n\\nel\n&&\\qquad{}\n+ s\\sqrt{1 - 4\\rho}[\\Re(x) - 2s(\\rho - 1) - s(1 - 2\\rho)/2]\n+ s^2\\rho\\ln\\abs{t_+ - x \\over t_- - x}\n\\Biggr\\}\n,\n\\ee\n\nThus\nfrom~\\rf{csReImForSub} I have,\n\n\\beml{charge-total-gamma-nu}\n\\sigma^T_{\\gamma\\tilde{\\nu}} & \\approx  &\n-{e^2 g^2 \\cos^2\\theta_X \\over 32\\pi s^3 }\n\\Biggl\\{\n[(\\Re(x) + s(1 - \\rho))^2 - \\Im(x)^2 + s^2\\rho] \n\\ln\\abs{t_+ - x \\over t_- - x}\n\\nel\n&&\\qquad{}\n- 2\\Im(x)[\\Re(x) + s(1 - \\rho)] \\phi(x)\n\n+ s\\sqrt{1 - 4\\rho}[\\Re(x) - s\\rho + {3 \\over 2}s]\n\\Biggr\\}\n\\nel\n& \\equiv &\n-{e^2 g^2 \\cos^2\\theta_X \\over 32\\pi s^3 }\n\\Biggl\\{\n[(m_{\\tilde\\nu}^2 + s(1 - \\rho))^2 \n- m_{\\tilde\\nu}^2\\Gamma_{\\tilde\\nu}^2 + s^2\\rho] \n\\ln\\abs{t_+ - x \\over t_- - x}\n\\nel\n&&\\qquad{}\n+ 2m_{\\tilde\\nu}\\Gamma_{\\tilde\\nu}[m_{\\tilde\\nu}^2 + s(1 - \\rho)] \\phi(x)\n\n+ s\\sqrt{1 - 4\\rho}[m_{\\tilde\\nu}^2 - s\\rho + {3 \\over 2}s]\n\\Biggr\\}\n.\n\\ee\n\nTo calculate $\\sigma^T_{Z\\tilde{\\nu}}$ I rewrite it from~\\rf{charge-d-Z-nu} as\n\\beml{charge-total-Z-nu}\n\\sigma^T_{Z\\tilde{\\nu}} & = & \n{m_e^2 m_\\chi^2 \\over \\pi s^2} \\int_{t_-}^{t_+} X_{Z\\tilde\\nu} dt\n\\nel\n& \\approx &\n{g^4 \\tan^2 \\theta_W \\cos^2\\theta_X \\over 64 \\pi s^2}\n\\int_{t_-}^{t_+} \\Re\\left[\\Delta_Z^\\hc(s) { 1 \\over t - x}\\right]\n\\nel &&{}\\times\n\\Bigl\\{\n[t - s(\\rho - 1)]^2[\\cos(2\\theta_W) + \\cos^2\\theta_Y]\n+\ns^2\\rho[\\cos(2\\theta_W) + \\cos^2\\theta_X]\n\\Bigr\\}\ndt\n\\nel\n& = &\n{g^4 \\tan^2 \\theta_W \\cos^2\\theta_X \\over 64 \\pi}\n\\{f_1[\\cos(2\\theta_W) + \\cos^2\\theta_Y]\n    + f_2[\\cos(2\\theta_W) + \\cos^2\\theta_X]\\}\n.\n\\nel\n\\ee\n\nThe formulas~\\rf{csInt3} and~\\rf{csInt4} give for $f_1$ and $f_2$,\n\n\n\\bem\nf_1 & = & {1 \\over s^2}\\int_{t_-}^{t_+}\n \\Re\\left[\\Delta_Z^\\hc(s){ 1 \\over t - x}\\right][t - s(\\rho - 1)]^2 dt\n\\nel\n& = &\n\\Re\\{z[x/s + 1 - \\rho]^2\\} \\ln\\abs{t_+ - x \\over t_- - x}\n-\\Im\\{z[x/s + 1 - \\rho]\\} \\phi(x)\n\\nel\n&&{}\n+ {1 \\over s}\n  \\sqrt{1 - 4\\rho}\\{\\Re(zx) - \\Re(z)[2s(\\rho - 1) + s(1 - 2\\rho)/2]\\}\n\\nel\n& = &\n\\Re\\{z[x/s + 1 - \\rho]^2\\} \\ln\\abs{t_+ - x \\over t_- - x}\n-\\Im\\{z[x/s + 1 - \\rho]^2\\} \\phi(x)\n\\nel\n&&{}\n+ \\sqrt{1 - 4\\rho}[\\Re(zx/s) + ({3\\over 2} - \\rho)\\Re(z)]\n,\n\\nel\nf_2 & = & \\rho \\int_{t_-}^{t_+} \n \\Re\\left[\\Delta_Z^\\hc(s){ 1 \\over t - x}\\right] dt\n=\n\\rho\\left[\\Re(z)\\ln\\abs{t_+ - x \\over t_- - x}\n- \\Im(z) \\phi(x)\\right],\n\\ee\n\nwhere  \n\\be\nz = \\Delta_Z^\\hc(s) = {1 \\over s - \\mB^2 - i\\mB\\Gamma_Z}\n.\n\\ee\n", "meta": {"hexsha": "c76f40622a8543b8ea7c34fdcbea83675389b119", "size": 59662, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writes/bergen_master_thesis/body/CharginoProduction.tex", "max_stars_repo_name": "ibukanov/ahome", "max_stars_repo_head_hexsha": "dc12d4a98c626414264c0cf38b357035e6e04a45", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "writes/bergen_master_thesis/body/CharginoProduction.tex", "max_issues_repo_name": "ibukanov/ahome", "max_issues_repo_head_hexsha": "dc12d4a98c626414264c0cf38b357035e6e04a45", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "writes/bergen_master_thesis/body/CharginoProduction.tex", "max_forks_repo_name": "ibukanov/ahome", "max_forks_repo_head_hexsha": "dc12d4a98c626414264c0cf38b357035e6e04a45", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9851916376, "max_line_length": 83, "alphanum_fraction": 0.5422714626, "num_tokens": 28307, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.43999445949219834}}
{"text": "%!TEX root = ../notes.tex\n\\section{February 4, 2022}\n\\subsection{Fast Powering \\emph{continued}}\n\\begin{example}\n    \\recall we wanted to compute $3^{37}\\mod 100$\n    \\begin{align*}\n        3^1    & \\equiv 3\\pmod{100} \\\\\n        3^2    & \\equiv 9           \\\\\n        3^4    & \\equiv 81          \\\\\n        3^8    & \\equiv 61          \\\\\n        3^{16} & \\equiv 21          \\\\\n        3^{32} & \\equiv 41\n    \\end{align*}\n    so we have\n    \\[37=1+4+32 \\qquad 3^{37} = 3^1\\cdot 3^4\\cdot 3^{32} \\equiv 3\\cdot 81\\cdot 41\\equiv 63\\]\n\\end{example}\nHow might we do this as an algorithm? We want to keep track of a few things, such as $g$ (the current power), $p$ (the multiple we are building), $a$ (the remaining powers). This is akin to \\emph{deconstructing the power in binary and composing our product}.\n\n\\begin{algorithm}[Fast Powering Algorithm]\n    ~\\lstinputlisting[numbers=none,language=Python]{code/pow_mod.py}\n\\end{algorithm}\n\n\\begin{example}\n    $37=100101_2$, so we peel off last digits and multiply $g$ into $p$.\n\n    Thinking about iterations, we have\n    \\[\\begin{array}{llll}\n            g  & p          & a  & a_2                \\\\ \\hline\n            3  & 1          & 37 & 10010\\underline{1} \\\\\n            9  & 3          & 18 & 10010\\underline{0} \\\\\n            81 & 3          & 9  & 100\\underline{1}   \\\\\n            61 & 43         & 4  & 10\\underline{0}    \\\\\n            21 & 43         & 2  & 1\\underline{0}     \\\\\n            41 & 43         & 1  & \\underline{1}      \\\\\n               & \\boxed{63} & 0  & \\underline{0}\n        \\end{array}\\]\n\\end{example}\n\nThis algorithm takes approximately $\\log_2(a)$ time to run, since it does as many steps for each digit in the binary representation of $a$.\n\n\\subsection{Fun Integers}\n\\recall An integer $p$ is \\ul{prime} if $p\\geq 2$ and\n\\[a\\mid p\\Rightarrow a = \\pm 1, \\pm p\\]\n\n\\begin{proposition}\n    Let $p$ be prime. Then $p\\mid ab\\Rightarrow p\\mid a$ or $p\\mid b$.\n\\end{proposition}\n\\begin{example}\n    $p$ is not prime, this doesn't work. $p = 6$. $p\\mid 4\\cdot 9 = 36$\n    but $6\\nmid 4$ and $6\\nmid 9$.\n\\end{example}\n\n\\begin{proof}\n    Let $g = \\gcd(p, a)$. $g$ is either $1$ or $p$.\n\n    If $g = p$, then we have that $p = g\\mid a$.\n\n    If $p = 1$, we can write this as\n    \\begin{align*}\n        1 = g & = p\\cdot u + a\\cdot v   \\\\\n        b     & = p\\cdot ub + ab\\cdot v\n    \\end{align*}\n    since $p$ is a multiple of $p$ and $ab$ is a multiple of $p$, we have that $p\\mid b$.\n\\end{proof}\n\n\\begin{theorem}[Fundamental Theorem of Arithmetic]\n    Any integer $a\\geq 1$ can be factored into product of primes\n    \\[a = p_1^{e_1}\\cdots p_n^{e_n}\\]\n    and this product of primes is \\emph{unique} up to rearrangement.\\footnote{This is to say, $\\ZZ$ is a UFD! }\n\\end{theorem}\n\\begin{example}\n    Instead of thinking about integers, we think about $\\ZZ[\\sqrt{-5}]$, like\n    \\[\\ZZ[\\sqrt{-5}] = \\{a + b\\sqrt{-5}\\mid a, b\\in \\ZZ\\}\\]\n    Consider\n    \\[6 = (1 + \\sqrt{-5})(1-\\sqrt{-5}) = 2\\cdot 3\\]\n    and each of $(1 + \\sqrt{-5})$, $(1-\\sqrt{-5})$, $2$, $3$ have no divisors besides themselves and $\\pm 1$ (units).\n\\end{example}\n\\begin{proof}\n    We begin by working out an example:\n    \\begin{example}\n        Let's factor $60$, we can write this as \\[60=6\\cdot 10 = (2\\cdot 3)\\cdot (2\\cdot 5) = 2^2\\cdot 3\\cdot 5.\\]\n    \\end{example}\n    What if we had different answers\n    \\[p_1p_2\\cdots p_t = a = q_1q_2\\cdots q_s\\]\n    We have that\n    \\begin{align*}\n        p_1\\mid p_1\\cdots p_t & = q_1\\cdots q_s      \\\\\n                              & = q_1(q_2\\cdots q_s)\n    \\end{align*}\n    So we have that $p_1\\mid q_1$ or $p_1\\mid q_2\\cdots q_s$, and we go on. So $p_1$ has to divide \\emph{one} of $q_i$. But both are primes, so they are equal $p_1 = q_i$. We rearrange so $q_i$ is $q_1$. We strip off $p_1$ and $q_1$ and we have\n    \\[p_2\\cdots p_t = q_2\\cdots q_s\\]\n    we continue until we have no factors left\\footnote{We could also have taken a well-ordering approach to this statement, taking $a$ to be the least such non-uniquely factorizable number and showing that by peeling off $p_1$ and $q_1$, we get a smaller such $a$, which is a contradiction. }\n\\end{proof}\n\n\\begin{definition}[Order]\\label{defn:order-of-prime-factor}\n    We define the \\ul{order}\n    \\[\\ord_p(a) = \\text{the power of $p$ in the factorization of $a$}\\]\n    such that we have\n    \\[a = \\prod_p p^{\\ord_p(a)}\\]\n    \\emph{(This makes sense since $\\ord_p(a)$ is finite for finitely many $p$.)}\n\\end{definition}\n\n\\begin{theorem}[Fermat's Little Theorem]\\label{theorem:flt}\n    Let $p$ be prime, $a\\in \\ZZ/p\\ZZ$,\n    \\[a^{p-1}\\equiv \\begin{cases}\n            0 & \\text{if $a\\equiv 0$} \\\\\n            1 & \\text{otherwise}\n        \\end{cases}\\]\n\\end{theorem}\nIn abstract algebra, this directly follows from Lagrange's Theorem for $\\ZZ/p\\ZZ$, we give another argument.\n\n\\begin{proof}\n    If $a\\equiv 0$, this is sufficiently clear.\n\n    Let $a\\not\\equiv 0$. We look at the numbers\n    \\[a, 2a, 3a, \\dots, (p-1)a\\]\n    We consider 2 questions:\n    \\begin{enumerate}[i.]\n        \\item Are any of these divisible by $p$?\n\n              No! $p\\nmid a$ and $p\\nmid i$ so $p\\nmid ia$ for $1\\leq i < p$.\n        \\item Are any of these equal? i.e. $ia\\equiv ja\\mod p$.\n\n              No again! $a$ has an inverse mod $p$.\n    \\end{enumerate}\n    So we have that this list is a permutation of $\\{1, 2, \\dots, p-1\\}$, that is,\n    \\[\\{1, 2, \\dots, p-1\\} = \\{a, 2a, \\dots, (p-1)a\\}\\mod p\\]\n    we multiply these sets together\\footnote{This is truly a pro-gamer move},\n    \\begin{align*}\n        1\\cdot 2\\cdot 3\\cdots (p-1) & \\equiv a\\cdot 2a\\cdots (p-1)a \\mod p \\\\\n                                    & \\equiv (1\\cdot 2\\cdots p-1)a^{p-1}\n        1\\cdot 2\\cdot 3\\cdot (p-1)(a^{p-1}-1)\\equiv 0\\mod p                \\\\\\implies a^{p-1}&\\equiv 1\\mod p.\n    \\end{align*}\n    Which is as desired.\n\\end{proof}", "meta": {"hexsha": "c48c3669895befa427a849cd97879a699fc32b11", "size": 5827, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-02-04.tex", "max_stars_repo_name": "jchen/math1580-notes", "max_stars_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-14T15:03:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T15:03:38.000Z", "max_issues_repo_path": "lectures/2022-02-04.tex", "max_issues_repo_name": "jchen/math1580-notes", "max_issues_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-02-04.tex", "max_forks_repo_name": "jchen/math1580-notes", "max_forks_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.162962963, "max_line_length": 292, "alphanum_fraction": 0.5740518277, "num_tokens": 2101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7826624789529376, "lm_q1q2_score": 0.43999445379236707}}
{"text": "%----------------------------------------------------------------------\n% COMPUTATIONAL PHYSICS - PROJECT 5\n% GRAVITATIONAL LENSING BY POINT MASSES\n%----------------------------------------------------------------------\n\n\\documentclass[aspectratio=1610,xcolor=dvipsnames,t]{beamer} \n\n%\\usepackage{listings} \n\\usepackage{color} \n\\usepackage{xcolor}  \n\\usepackage{microtype} \n\\usepackage{helvet} \n\\usepackage{inconsolata} \n\\usepackage[framemethod=TikZ]{mdframed} \n\\usepackage{graphicx} \n\n\\usepackage{amssymb}\n\\usepackage{amsmath} \n\\usepackage{cite} \n\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\n\\usepackage{pifont} \n\\usepackage{helvet} \n\n\\usetheme{Madrid} \n\\useinnertheme{rectangles} \n\\setbeamertemplate{blocks}[default] \n\n\\setbeamertemplate{navigation symbols}{}\n%\\setbeamerfont{block title}{size={}}\n%\\setbeamercolor*{title}{bg=}\n\n%\\definecolor{mypurple}{rgb}{.49,0,98}\n%\\setbeamercolor*{palette primary}{use=structure,fg=white,bg=green}\n%\\usecolortheme[rgb={0.9,0.2,0.2}]{structure}\n\\usecolortheme[rgb={0.2,0.3,0.6}]{structure}\n\n\\title[Gravitational Lensing]{Gravitational Lensing by Point Masses} \n\\author{Michael Papasimeon} \n\\date{29 October 1998}\n%\\titlegraphic{\\includegraphics[width=\\textwidth]{hydrogen-spectrum}}\n\n%\\addtobeamertemplate{title\n%page}{\\centering\\includegraphics[width=0.5\\textwidth]{hydrogen-spectrum}}{}\n\n\n\n%----------------------------------------------------------------------\n% CODE LISTING SETTINGS\n%----------------------------------------------------------------------\n\n\\definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0}\n\n%----------------------------------------------------------------------\n% BEGIN DOCUMENT\n%----------------------------------------------------------------------\n\n\\begin{document}\n\\maketitle\n\n\\begin{frame}{Gravitational Lens in Abbell 2218} \n    \\begin{center}\n        \\includegraphics[width=0.7\\textwidth]{images/hubble.eps}\n    \\end{center}\n\\end{frame} \n\n\\begin{frame}{The Lens Equation}\n    The angular deflection $\\alpha$ of a gravitational lense is given by\n    \\begin{equation}    \n        \\alpha = \\frac{4GM}{c^2 \\xi}\n    \\end{equation}\n    where\n    \\begin{itemize}\n        \\item $M = $ mass of the deflecting object\n        \\item $G = $ gravitational constant\n        \\item $c = $ speed of light\n        \\item $\\xi = $ impact radius of the incoming photon\n        \\item $\\alpha = $ deflection angle\n    \\end{itemize}\n\\end{frame} \n\n\\begin{frame}{Angular Deflection of a Photon} \n    \\begin{center}\n        \\includegraphics[width=0.7\\textwidth]{images/gldiag.eps}\n    \\end{center}\n\\end{frame} \n\n\\begin{frame}{Deflecting Mass}  \n    The deflecting mass may be viewed as an optical thin lens, made up\n    of a two dimensional mass distribution.\n    \\begin{equation}\n        M = \\int_{R^2} \\Sigma(\\vec{\\xi '}) \n            \\frac{\\vec{\\xi} - \\vec{\\xi '} }{|\\vec{\\xi} - \\vec{\\xi '}|^2} d^2 \\xi '\n    \\end{equation}\n    where\n    \\begin{itemize}\n        \\item $\\Sigma = $ surface density\n        \\item $R^2 = $ surface area\n    \\end{itemize}\n    If the deflecting mass, is perfectly symmetric, the deflection angle becomes\n    \\begin{equation}\n        \\vec{\\alpha} = \\frac{4GM(<\\xi)\\vec{\\xi}}{c^2|\\vec{\\xi}|^2}\n    \\end{equation}\n\\end{frame} \n\n\\begin{frame}{The Lens Equation} \n    The lens equation is\n    \\begin{equation}\n        \\psi D_{os} + \\alpha D_{ds} = \\beta D_{os}\n    \\end{equation}\n    It is often the case in many gravitational lensing problems that \n    the images form do not depend on the distances between source, observer\n    and deflector directly. Rather a specific ratio of these distances\n    is the quantity which needs to be considered. This is known as the\n    effective distance $D$ and is defined as:\n    \\begin{equation}\n    \\label{eq:effd}\n        D = \\frac{D_{od} D_{ds} }{D_{os}}\n    \\end{equation}\n\\end{frame} \n\n\\begin{frame}{Setup for the Gravitational Lens Equation} \n    \\begin{center}\n        \\includegraphics[angle=-90,width=0.8\\textwidth]{images/setup.eps}\n    \\end{center}\n\\end{frame} \n\n\\begin{frame}{Einstein Ring} \n    If a distant star is in perfect alignment with a point mass gravitational\n    lens and an observer, the light from the distant star is lensed \n    perfectly symmetrically forming a ring image of the star known as an\n    Einstein ring. The radius of the Einstein ring is given by\n    \\begin{equation}\n        \\theta_{E} = \\sqrt{\\frac{4GM}{c^2} \\frac{D_{ds}}{D_{od} D_{os}}}\n    \\end{equation}\n    If however there isn't a perfect alignment, for a point mass two\n    images are produced for each point on the source plane. \n    The angular positions at which these images is given by:\n    \\begin{equation}\n        \\theta_{\\pm} = \\frac{\\xi}{D_{od}}\n                 = \\frac{\\beta}{2} \\pm \\sqrt{\\beta^2 + 4\\theta^{2}_{E}}\n    \\end{equation}\n    where $\\beta$ is the angular position of the source as shown in figure 3.\n    The magnification of each of the images is given by\n    \\begin{equation}\n        \\mu_{\\pm} = \\frac{1}{4} \n                \\left[ \n                    \\frac{y}{\\sqrt{y^2 + 4}} \n                    +\n                    \\frac{\\sqrt{y^2 + 4}}{y} \n                    \\pm 2\n                \\right]\n    \\end{equation}\n    where the source and image angles have been scaled such that \n    $y = \\psi / \\alpha_0$ and $x = \\alpha / \\alpha_0$.\n\\end{frame} \n\n\\begin{frame}{Reformulating the Lens Equation} \nUsing this notation the lens equation can be rewritten as the scaled\nlens equation given by\n\\begin{equation}\n    \\vec{y} = \\vec{x} - \\vec{\\alpha}(\\vec{x}).\n\\end{equation}\nThe vector notation used represents the coordinate in a cartesian plane.\nTherefore\n\\begin{itemize}\n    \\item $\\vec{y} = (y_1, y_2)$ is a coordinate in the source plane and\n    \\item $\\vec{x} = (x_1, x_2)$ is a coordinate in the deflecting plane.\n\\end{itemize}\n\\end{frame} \n\n\\begin{frame}{Complex Notation}  \nThis can also be written using complex number notation. A position in \ndeflecting plane can be denoted as $z = x_1 + ix_2$, and a position in the\nsource plane as $z_s = y_1 + iy_2$.\n\nThe magnification is given by:\n\\begin{equation}\n    \\mu(\\vec{x}) = \\frac{1}{det A(\\vec{x})}\n\\end{equation}\nwhere $det A(\\vec{x})$ is the Jacobian determinant of the Hessian matrix\ngiven by\n\\begin{equation}\n    A(\\vec{x}) = \\frac{\\partial \\vec{y}}{\\partial \\vec{x}}\n\\end{equation}\n\\end{frame} \n\n\\begin{frame}{Critical Curves and Caustics}\n\\begin{itemize} \n    \\item Critical curves are the set of all points in the deflection plane where $A(\\vec{x}) = 0$. \n    \\item The corresponding curves in the source plane (obtained from the lens equation) are known as caustics.    \\item Critical curves are where the gravitational lens infinitely magnifies the light passing through\n          that point. \n    \\item Source plane caustics are the pre-image of the critical curves.\n    \\item Any light emitted near a caustic will be greatly magnified as it passes through the lens. \n\\end{itemize}\n\\end{frame} \n\n\\begin{frame}{The Chang-Refsdal Lens}\nThe Chang-Refsdal lens model describes gravitational lensing using a modification\nof the point mass model. This model says that when a source crosses a fold caustic\nthe lensing is due to a point mass but with an additional external shear applied.\nThe corresponding lens equation for the Chang-Refsdal model is:\n\\begin{equation}\n    \\vec{y} = \\left[\n                \\begin{array}{cc}\n                    1 + \\gamma & 0   \\\\\n                    0          & 1 - \\gamma\n                \\end{array} \n              \\right] \\vec{x} - \\frac{\\vec{x}}{|\\vec{x}|^2}\n\\end{equation}\nThis can also be written in the complex notation as \n$z_s = z + \\gamma \\bar{z} - \\frac{\\epsilon}{\\bar{z}}$, where\n\\begin{itemize}\n    \\item $\\gamma$ is a constant determining the amount shear.\n    \\item $\\epsilon = (\\frac{\\kappa_s}{1 - \\kappa_c})$, where $\\kappa_s$ is\n          the density of compact objects such as stars and $\\kappa_c$ is the\n          surface density of continuously distributed matter.\n\\end{itemize}\n\\end{frame} \n\n%\\end{multicols}\n\n\\begin{frame}{The Effects of Distance on Gravitational Lensing}\nThe Dyer-Roeder equation is given by:\n\\begin{equation}\n    (z+1)(\\Omega z + 1) \\frac{d^2D}{dz^2} + \n    \\left( \\frac{7}{2}\\Omega z + \\frac{1}{2}\\Omega + 3 \\right) \\frac{dD}{dz} + \n    \\frac{3}{2} \\tilde{\\alpha} \\Omega D = 0\n\\end{equation}\nThis relates the angular diameter distance of a lensing system with the\nredshift $z$ of the source object.\n\\begin{itemize}\n    \\item $\\Omega$ is the ratio of the mean mass density to the critical\n          density of the universe and\n    \\item $\\tilde{\\alpha}$ is the clumpiness parameter, which determines\n          the amount of matter between the source and the observer.\n\\end{itemize}\n\\end{frame} \n\n\\begin{frame}{Initial Conditions for Dyer-Roeder Equation} \nThe initial conditions of the Dyer-Roeder equation are:\n\\begin{equation}\n    D_{ii} = 0\n\\end{equation}\n\\begin{equation}\n    \\left[ \\frac{dD_{ij}}{dz} \\right]_{z_j = z_i} =\n         \\frac{\\mathrm{sgn} (z_j - z_i)}{(z_i + 1)^2 \\sqrt{\\Omega z_i + 1} }\n\\end{equation}\n\nThe Dyer-Roeder equation needs to be solved for three different cases.\n\\begin{enumerate}\n    \\item  $\\Omega = 0$ $(D_{I})$\n    \\item  $\\Omega = 1$, $\\tilde{\\alpha} = 1$ $(D_{II})$\n    \\item  $\\Omega = 1$, $\\tilde{\\alpha} = 0$ $(D_{III})$\n\\end{enumerate}\n\\end{frame} \n\n\\begin{frame}{Solving the Dyer-Roeder Equation} \nThis leads to three different equations which need to be solved.\n\\begin{equation}\n    (z+1)\\frac{d^2D}{dz^2} + 3 \\frac{dD}{dz} = 0\n\\end{equation}\n\n\\begin{equation}\n    (z+1)^2 \\frac{d^2D}{dz^2} + \\frac{7}{2}(z+1)\\frac{dD}{dz} + \\frac{3}{2}D = 0\n\\end{equation}\n\n\\begin{equation}\n    (z+1)^2 \\frac{d^2D}{dz^2} + \\frac{7}{2}(z+1)\\frac{dD}{dz} = 0\n\\end{equation}\n\\end{frame} \n\n\\begin{frame}{Computational Solution to the Dyer-Roeder Equation} \n\\begin{itemize} \n\\item A FORTRAN program was written\nto numerically solve these equations. \n\\item The algorithm used to solve these\nequation numerically was the \\emph{Runge-Kutta-Nystr\\\"{o}m}\nmethod.  \n\\item This method is a fourth order algorithm which is a general form \nof the standard \\emph{Runge-Kutta} method, used for solving second order \nordinary differential equations.\n\\item The equations were integrated from $z = 0$ to $z = 10$. \n\\item The dimming factor $(D_{II}/D_{III})^2$ was determined and plotted\nas a function of redshift $z$.\n\\end{itemize} \n\\end{frame} \n\n\\begin{frame}{Solutions to the Dyer-Roeder Equation} \nWe solve the Dyer-Roeder\nequation for the three different cosmologies resulting in three\nsolutions for the angular diameter distance $D$.\n\\begin{itemize}\n    \\item $D_{I}$   \\texttt{d1.dat} (The top curve)\n    \\item $D_{II}$  \\texttt{d2.dat} (The bottom curve)\n    \\item $D_{III}$ \\texttt{d3.dat} (The centre curve)\n\\end{itemize}\n    \\begin{center}\n        \\includegraphics[width=0.5\\textwidth]{results/cosmo_all.eps}\n    \\end{center}\n\\end{frame}\n\n\\begin{frame}{Increasing Redshift} \n\\begin{itemize}\n\\item According to the big bang model of the universe, objects with large\nredshifts are further away. \n\\item Hence the results of solving the Dyer-Roeder\nequation for the cases (1 and 3) when the ``clumpiness'' parameter \n$\\tilde{\\alpha}$ is ignored the angular diameter distance $D$ increases\nas the redshift increases. \n\\item In both cases we get asymptoting values:\n\\end{itemize} \n\\begin{equation}\n    \\lim_{z \\rightarrow \\infty} D_{I}(z) = 0.5\n\\end{equation}\n\\begin{equation}\n    \\lim_{z \\rightarrow \\infty} D_{II}(z) = 0.4\n\\end{equation}\n\\end{frame} \n%In both these cases where $\\tilde{\\alpha}$ is not in the equation, \n%the lens is the only matter along the line of sight to the source and\n%hence we get an increase in the angular diameter distance as the redshift \n%increases. Of particular interest is that in case $I$ ($\\Omega = 0$), \n%the value of $D$ increases more rapidly than in case $III$ ($\\Omega = 1$).\n%Hence we see that the density of the universe plays influences the results\n%of any models chosen for gravitational lensing. Since the mean and \n%critical densities of the universe are unknown (especially since it is\n%believed that most of the matter of the universe is dark matter), \n%there are limits to how accurately we can determined parameters from\n%gravitational lensing observations.\n\n%The second case is perhaps the most interesting of the three cosmologies\n%in that we have a non-zero contribution from the ``clumpiness'' parameter\n%$\\tilde{\\alpha}$. As a result is also produces the most interesting result\n%as we have a maxiumum in $D$ at $z \\simeq 1$. \n%In this case where $\\tilde{\\alpha} = 1$, the gravitational lense\n%make only a minor contribution to the total amount of smoothly distributed\n%matter in the line of sight of the observer and the source. In this situation\n%the matter is smootly distributed and we get gravitational lens being\n%the matter between source and observer. We can then think of this\n%as the light passing through a material of a different refractive index\n%as in electrodynamics.\n\n\\begin{frame}{Dimming factor against source redshift}\n    \\begin{center}\n        \\includegraphics[width=0.7\\textwidth]{results/dim.eps}\n    \\end{center}\n\\end{frame} \n\n%Figure~\\ref{fig:dimming} shows the dimming factor $(D_{II}/D_{III})^2$ plotted\n%against source redshift $z$. In case $II$ has a smoothly distributed\n%matter distribution meaning that we see more and brigter images than\n%in case $III$ where the ``clumpiness'' parameter results in less\n%light reaching the observer. As a result, a case $III$ universe appears\n%to be dimmer than a case $II$ universe. The dimming ratio of factor\n%is $(D_{II}/D_{III})^2$ and is plotted against red shift in the plot above.\n%As we can see in the plot the higher the redshift the more dimness in\n%a case $III$ universe.\n\n%\\section{Lensing an Extended Source by a Point Mass}\n%    \\subsection{Method}\n%    A program was written to simulate the gravitational lensing \n%    of a two dimensional grid. Two make the results of the simulation\n%    more interesting the two dimensional grid chosen was represented\n%    as a two dimensional array of integers ranging from 0 to 255.\n%    The value at each array element represents an intensity value. As a result\n%    the grid represents a two dimensional Portable Grey Map (PGM) image.\n%    The program was written to accept the name of a PGM file on the command\n%    line, load the image into memory,, apply the gravitational lensing calculations\n%    and output a new ``lensed'' PGM image to standard output. The program\n%    also takes the mass $M$ (in $kg$) of the lensing body, the effective\n%    distance D specified in equation~\\ref{eq:effd}, and the $(x,y)$\n%    location of the lensing body.\n%    The details of the lensing algorithm can be found in Algorithm~\\ref{alg:lense}.\n\n\\begin{frame}{Lensing an Extended Source by a Point Mass} \n        \\begin{block}{Lensing Algorithm} \n        \\begin{algorithmic}[1]\n            \\Procedure {Lense}{} \n                \\State $img \\leftarrow \\textbf{load\\_image}()$\n                \\State $x_c, y_c \\leftarrow \\textbf{find\\_centre}(img)$\n                \\State $\\theta_E \\leftarrow \\textbf{calc\\_einstein\\_radius}()$\n                \\For {$c \\in img.coordinates$}\n                    \\State $b_x, b_y \\leftarrow \\textbf{calc\\_location\\_lensing\\_body}()$\n                    \\State $\\beta \\leftarrow \\textbf{impact\\_radius}()$\n                    \\State $\\textbf{calc\\_angle\\_for\\_each\\_quadrant}()$\n                    \\State $\\theta_{\\pm} \\leftarrow \\textbf{calc\\_new\\_angles}()$\n                    \\State $c \\leftarrow \\textbf{calc\\_new\\_deflected\\_coordinate}()$\n                \\EndFor\n                \\State $\\textbf{save\\_image(img)}$ \n            \\EndProcedure\n        \\end{algorithmic} \n        \\end{block} \n\\end{frame} \n\n%    \\begin{verbatim}\n%        load the image\n%        calculate the Einstein radius\n%        for all coordinates in the image\n%           calculate the location of the lensing body \n%           calculate the impact radius beta\n%           determine the correct angle for each quadrant\n%           calculate the new angles for each point thetaPlus and thetaMinus\n%           set the current coordinate to the new deflected coordinates\n%        end for\n%        output the image\n%    \\end{verbatim}\n\n\\begin{frame}{Lensing Images}\n    A number of different images were used in the simulation. Two were used\n    for testing purposes and to observe the effect, and three were images\n    of astronomical interest. The images used include:\n    \\begin{itemize}\n        \\item A human face\n        \\item The starship Enterprise\n        \\item The Andromeda Galaxy\n        \\item The Milky Way\n        \\item The Pleiades Star Cluster\n    \\end{itemize}\n\n    %The program used for the simulation called \\texttt{image.c} can\n    %be found in Appendix C. The programming language used in this case\n    %was C instead of FORTRAN, for the following reasons:\n    %\\begin{itemize}\n    %    \\item Using a C \\texttt{struct} was appropriate in representing\n    %          the data stored in a single PGM image.\n    %    \\item Image files of varying widths and heights were used, and \n    %          therefore the program made used of dynamic memory allocation\n    %          to allocate only the memory that was required to store\n    %          the images.\n    %\\end{itemize}\n\n    In all cases the distance ratio used was $D = 1$ and just the mass\n    was varied. This is because when calculating the Einstein radius,\n    the quantity $DM$ appears as follows:\n    \\begin{equation}\n        \\theta_E = \\sqrt{\\frac{4GMD}{c^2}}\n    \\end{equation}\n\\end{frame} \n\n%\\subsection{Results and Discussion}\n\n%\\subsubsection{A Human Face}\n%An image of a face was used to first test the program. \n%The original image and the simulated lensing of the face is shown\n%in Figure~\\ref{fig:face}.  The image on the\n%left is the original, and the image on the right is one that has been\n%gravitationally lensed by a point mass in the lower right hand corner\n%of mass, $M = 5 \\times 10^{30}$ kg.\n\n\\begin{frame}{Gravitational lensing of image of a human face by a mass $M = 5 \\times 10^{30}$ kg} \n    \\begin{center}\n    \\begin{tabular}{cc}\n        \\includegraphics[width=0.3\\textwidth]{pics/kr.eps} &\n        \\includegraphics[width=0.3\\textwidth]{pics/kr_5e30.eps} \\\\\n    \\end{tabular}\n    \\end{center}\n\\end{frame} \n\n%Apart from the obvious distortion in the lensed image, of particular\n%interest is the formation of two images, one small and one large.\n%The smaller image is inside the Einstein radius of the lense.\n\n%\\subsubsection{The Enterprise}\n%Figure~\\ref{fig:enterprise} shows three images of the starship Enterprise\n%from Star Trek. \n%\\begin{itemize}\n%    \\item The image on the left is the original\n%    \\item The center image has a gravitational lense of mass\n%          $M = 2 \\times 10^{30}$ kg with the lense placed in the \n%          centre.\n%    \\item The image on the right has a gravitational lense of\n%          mass $M = 1 \\times 10^{31}$ in the lower right hand corner.\n%\\end{itemize}\n\n%With the lense in the center of the image it is more difficult to \n%see the two images. The image on the right resulting from a larger\n%mass (and with the lens in the bottom right hand corner)\n%clearly shows both the images and large distortions.\n%In many cases of actual observations, the images inside the Einstein radius\n%are two small to be resolved by even the most powerful telescopes.\n\n\\begin{frame}{Gravitational lensing of an image of the starship Enterprise} \n    \\begin{center}\n        \\begin{tabular}{ccc}\n            \\includegraphics[width=0.3\\textwidth]{pics/1701.eps} &\n            \\includegraphics[width=0.3\\textwidth]{pics/ent_2e30.eps} &\n            \\includegraphics[width=0.3\\textwidth]{pics/ent_1e31.eps} \n        \\end{tabular}\n    \\end{center}\n\\end{frame} \n\n%\\subsubsection{The Andromeda Galaxy}     \n%%Figure~\\ref{fig:andromeda} shows the effect of different masses gravitational lensing\n%an image of the Andromeda galaxy.  A number different lenses\n%of varying masses were used. In all the cases the lensing object\n%is located in the upper left hand corner of the image [position $(0,0)$].\n\n\\begin{frame}{Gravitational Lensing of the Andromeda Galaxy} \n\\begin{center}\n    \\begin{tabular}{cc} \n    \\includegraphics[width=0.3\\textwidth]{pics/andromeda.eps}  &\n    \\includegraphics[width=0.3\\textwidth]{pics/1e30and.eps}  \\\\\n    $M = 0 kg$ & $M = 1 \\times 10^{30}$ kg, $D = 1$ \\\\ \n    \\includegraphics[width=0.3\\textwidth]{pics/1e31and.eps}  &\n    \\includegraphics[width=0.3\\textwidth]{pics/4e31and.eps} \\\\\n    $M = 1 \\times 10^{31}$ kg, $D = 1$ &  $M = 4 \\times 10^{31}$ kg, $D = 1$ \\\\ \n    \\end{tabular} \n\\end{center}\n\\end{frame}\n\n%As the mass of the lense is increased, the amount of distortion in the\n%resulting image is increased. The secondary image is also clearly visible.\n\n%\\subsubsection{The Milky Way}\n%Figure~\\ref{fig:milky-way} shows the effect of simulated gravitational lensing\n%on an image of the centre of the Milky Way galaxy. \n%The image on left is looking towards the centre of the Milky Way in the\n%infrared. The image on the right is gravitationally lensed by a \n%$M = 3 \\times 10^{30}$ kg mass. The lense is located slightly left and above\n%from the center. This image of the Milky Way allows us to see the distortion\n%of the image within the Einstein radius much easier.\n\n\\begin{frame}{Gravitational Lensing of the Milky Way} \n    \\begin{center}\n            \\includegraphics[width=0.45\\textwidth]{Pics/milky.eps} \\hspace{1mm} \n            \\includegraphics[width=0.45\\textwidth]{Pics/milky3e30.eps} \n    \\end{center}\n\\end{frame} \n\n%\\subsubsection{The Pleiades Star Cluster}\n%Figure~\\ref{fig:pleiades} shows the effect of simulated gravitational lensing\n%on a star cluster. \n%The image on the left is that of the Pleiades star cluster. The image\n%on the right is gravitationally lensed by a $M = 2 \\times 10^{30}$ kg\n%mass.\n\n\\begin{frame}{Gravitational Lensing of the Pleiades Star Cluster} \n    \\begin{center}\n            \\includegraphics[width=0.45\\textwidth]{Pics/pl.eps} \\hspace{1mm} \n            \\includegraphics[width=0.45\\textwidth]{Pics/pl2e30.eps} \n    \\end{center}\n\\end{frame} \n\n%\\section{Caustics for the Chang-Refsdal Lens}\n%    \\subsection{Method}\n%    A FORTRAN program was written (see Appendix A -- \\texttt{caustics.f})\n%    which calculated critical curves and caustics for given\n%    values of $\\gamma$ and $\\epsilon$. As stated earlier, critical\n%    curves are obtained when Jacobian determinant is zero ($\\det A = 0$)\n%    This gives:\n\n\\begin{frame}{Caustics for the Chang-Refsdal Lens} \n    \\begin{equation}\n        \\det A = 1 - \\left( \\gamma + \\frac{\\epsilon}{\\bar{z}^2} \\right)\n                     \\left( \\gamma + \\frac{\\epsilon}{\\bar{z}^2} \\right) = 0\n    \\end{equation}.\n    Using complex polar coordinates letting $z = x \\cos \\phi + ix \\sin \\phi$\n    we get\n    \\begin{equation}\n        x^4 (1 - \\gamma^2) - 2 \\gamma \\epsilon x^2 \n            (\\cos^2\\phi - \\sin^2\\phi) - 1 = 0\n    \\end{equation}\n    The equation can be parameterised by letting:\n        \\[ \\lambda = \\cos^2\\phi - \\sin^2\\phi \\]\n        \\[ u = x^2 \\]\n    giving\n    \\begin{equation}\n        u^2(1 - \\gamma^2) - 2\\gamma \\epsilon \\lambda u - 1 = 0.\n    \\end{equation}\n\\end{frame} \n\n\\begin{frame}{Caustics for the Change-Refsdal Lens (continued)} \n    Solving this quadratic we obtain:\n    \\begin{equation}\n        u = \\frac{\\gamma\\epsilon\\lambda \\pm \\sqrt{\\gamma^2(\\lambda^2 - 1) + 1}}\n                 {(1 - \\gamma^2)}\n    \\end{equation}\n    For a given values of $\\gamma$, $\\epsilon$ and for $0 < \\phi < 2\\pi$\n    the program calculates $u$ and then $x$. The $(x,y)$ coordinates\n    for the caustic curve is then given by $(x\\cos\\phi, x\\sin\\phi)$.\n    The corresponding caustics are given by:\n    \\begin{equation}\n        y_1 = \\left[ (1 + \\gamma)x - \\frac{\\epsilon}{x} \\right] \n              \\sqrt{\\frac{1 + \\lambda}{2} } \n    \\end{equation}\n    \\begin{equation}\n       y_2 = \\left[ (1 - \\gamma)x - \\frac{\\epsilon}{x} \\right] \n                     \\sqrt{\\frac{1 - \\lambda}{2} }\n    \\end{equation}\n\\end{frame} \n\n\\begin{frame}{Selecting Values for $\\epsilon$ and $\\gamma$} \n    In the program a value of $\\epsilon = 0.5$ was chosen. Values\n    of gamma were chosen for the four representative regions in which\n    caustics are found. The four regions are:\n    \\begin{itemize}\n        \\item $\\gamma < -1$\n        \\item $-1 < \\gamma < 0$\n        \\item $0 < \\gamma < 1$\n        \\item $\\gamma > 1$\n    \\end{itemize}\n    The four values of $\\gamma$ selected are:\n    \\begin{itemize}\n        \\item $\\gamma = -1.3$ \n        \\item $\\gamma = -0.4$\n        \\item $\\gamma = +0.8$\n        \\item $\\gamma = +1.6$\n    \\end{itemize}\n\\end{frame} \n\n%    \\subsection{Results}\n%    The generated critical curves and caustics for the different values of $\\gamma$ selected \n%    are shown in the following figures:\n%    \\begin{itemize}\n%        \\item $\\gamma = -1.3$ Figure~\\ref{fig:critical-gamma-1-3} \n%        \\item $\\gamma = -0.4$ Figure~\\ref{fig:critical-gamma-0-4}\n%        \\item $\\gamma = +0.8$ Figure~\\ref{fig:critical-gamma08} \n%        \\item $\\gamma = +1.6$ Figure~\\ref{fig:critical-gamma1-6}\n%    \\end{itemize} \n   \n    \\begin{frame}{Critical curves and caustics for $\\gamma = -1.3$}\n        \\begin{center}\n                \\includegraphics[width=0.5\\textwidth]{images/neg1-3-critical.eps}  \n                \\includegraphics[width=0.5\\textwidth]{images/neg1-3-caustic.eps} \n        \\end{center}\n    \\end{frame} \n\n    \\begin{frame}{Critical curves and caustics for $\\gamma = -0.4$}\n        \\begin{center}\n                \\includegraphics[width=0.5\\textwidth]{images/neg0-4-critical.eps} \n                \\includegraphics[width=0.5\\textwidth]{images/neg0-4-caustic.eps} \n        \\end{center}\n    \\end{frame} \n\n    \\begin{frame}{Critical curves and caustics for $\\gamma = 0.8$}\n        \\begin{center}\n                \\includegraphics[width=0.5\\textwidth]{images/pos0-8-critical.eps} \n                \\includegraphics[width=0.5\\textwidth]{images/pos0-8-caustic.eps} \n        \\end{center}\n    \\end{frame} \n\n    \\begin{frame}{Critical curves and caustics for $\\gamma = 1.6$} \n        \\begin{center}\n            \\includegraphics[width=0.5\\textwidth]{images/pos1-6-critical.eps} \n            \\includegraphics[width=0.5\\textwidth]{images/pos1-6-caustic.eps} \n        \\end{center}\n    \\end{frame} \n\n%    \\subsection{Discussion}\n%    As can be seen from the diagrams in the previouse section, \n%    the caustic curves with values of $\\gamma$ ranging between\n%    $-1$ and $1$ are non overlapping curves, whereas the others\n%    overlap in a ``petal'' pattern.\n\n%    The caustics can be used to determine light curves for background\n%    sources since they mark where intensity increases in the resulting\n%    gravitationally lensed image occur.\n\n    \\begin{frame}{Gravitational Lensing by a Binary Star System}\n        \\begin{center}\n            \\includegraphics[width=0.7\\textwidth]{images/lens_model.eps}\n        \\end{center}\n    \\end{frame} \n\n%    The use of critical lines and caustics are even more important\n%    when modelling graviational lenses especially when both the source\n%    and the lens are more complicated objects such as galaxies.\n%    For example Figure~\\ref{fig:binary-star} shows the representation of \n%    gravitational lensing for a distant star by a binary star system.\n%    As can be seen from the diagram, a simple point mass model is\n%    not sufficient to handle a system such as this, and hence\n%    more detailed models such as the Chang-Refsdal lens model\n%    are needed to simulate this situation so that it we can accurate\n%    comparisons with observations.\n\n%----------------------------------------------------------------------\n% END DOCUMENT\n%----------------------------------------------------------------------\n\n\n\n\\end{document}\n    \n", "meta": {"hexsha": "42972da4f9ee2b2ca423ff55063b3d5f08eb4ac3", "size": 27733, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lensing-talk.tex", "max_stars_repo_name": "mikepsn/gravitational-lensing", "max_stars_repo_head_hexsha": "6273de4880fcc1a4a065a90857a94620ab21c186", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lensing-talk.tex", "max_issues_repo_name": "mikepsn/gravitational-lensing", "max_issues_repo_head_hexsha": "6273de4880fcc1a4a065a90857a94620ab21c186", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lensing-talk.tex", "max_forks_repo_name": "mikepsn/gravitational-lensing", "max_forks_repo_head_hexsha": "6273de4880fcc1a4a065a90857a94620ab21c186", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3682678311, "max_line_length": 216, "alphanum_fraction": 0.658637724, "num_tokens": 8046, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7826624789529375, "lm_q1q2_score": 0.43999445379236707}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{Fri Nov 15 2019}\n\nWe want to study the behaviour of light and particles in a Schwarzschild background, for \\(r > 2 GM\\). The metric is: \n%\n\\begin{align}\n  \\dd{s^2} = - \\qty(1 - \\frac{2GM}{r}) \\dd{t^2} \n  + \\qty(1 - \\frac{2GM}{r})^{-1} \\dd{r^2}\n  + r^2 \\dd{\\Omega^2}\n\\,.\n\\end{align}\n\nIn general, the motion of light is nonradial.\nThe metric is independent of time: our Killing vector field is \\(\\xi^{\\alpha } = (1, \\vec{0} )\\), so \\(p \\cdot \\xi = \\const\\).\n\nFrom QM we know that \\(f_A = E_A / h\\), where \\(E_A\\) is the energy measured by \\(A\\).\n\nThe 4-velocity of \\(A\\) has spatial components equal to zero, since \\(A\\) does not move.\nIts norm must be  \\(u^{\\mu } u_{\\mu } = -1\\), therefore \\(u^{\\mu }_A = (1/ \\sqrt{1 - 2GM / r_A}, \\vec{0})\\), or \\(u^{\\alpha}_A = (1, \\vec{0}) / \\sqrt{1 - 2GM / r_A} = \\xi^{\\alpha } / \\sqrt{1 - 2GM/r_A}\\).\n\nFor Bob, we have the exact same thing, except \\(A \\rightarrow B\\).\n\nSo, for \\(i = A, B\\): \n%\n\\begin{align}\n  f_i = u_{\\mu }^{(i)} p^{\\mu }_{ \\text{photon}} = - \\qty(1 - \\frac{2GM}{r_i})^{-1/2} \\frac{p _{\\text{photon}} \\cdot \\xi }{h}\n\\,,\n\\end{align}\n%\nsince both of the 4-velocities are proportional to the Killing (unit) vector field, with \\emph{different proportionality constants}. \nThe last part is exactly the same since the light moves along a geodesic: so their ratio is given by\n%\n\\begin{align}\n  \\frac{f_B}{f_A} = \\sqrt{\\frac{1-2GM /r_A}{1-2GM/r_B}}\n\\,,\n\\end{align}\n%\nor \n%\n\\begin{align}\n  f _{\\text{obs}} = f _{\\text{emit}} \\frac{\\sqrt{1 - \\frac{2GM}{r _{\\text{emit}}}}}{\\sqrt{1 - \\frac{2GM}{r _{\\text{obs}}}}}\n\\,.\n\\end{align}\n\nLet us consider the nonrelativistic approximation: \\(r_A = R + h\\), while \\(r_B = R\\), where \\(R = R _{\\text{earth}}\\).\nIf we Taylor expand (with \\(2GM \\ll R\\)), we get: \n%\n\\begin{align}\n  f _{\\text{obs}} = f _{\\text{emit}} \\qty(1 - \\frac{GM}{r _{\\text{emit}}} + \\frac{GM}{r _{\\text{obs}}})\n\\,,\n\\end{align}\n%\nand then we expand in \\(h/R\\): we get \n%\n\\begin{align}\n    f _{\\text{obs}} = f _{\\text{emit}} \\qty(1 - \\frac{GM}{R} \\qty(1 - \\frac{h}{R}) + \\frac{GM}{R}) \n    = f _{\\text{emit}} \\qty(1 + \\frac{GM}{R^2} h)\n    = f _{\\text{emit}} \\qty(1 + g h)\n  \\,,\n\\end{align}\n%\nif we want more precision then we can keep more orders. \n\n\\subsubsection{Classical orbits}\n\nKepler's laws are \\emph{wrong}! We will show this.\n\nIn classical circular orbits, for a planet with mass \\(m=1\\), we have the gravitational force \\(GM/r^2\\) equalling \\(v^2/r\\), or with respect to the angular momentum \\(l = vr\\): \n%\n\\begin{align}\n  \\frac{GM}{r^2} = \\frac{l^2}{r^3}\n\\,,\n\\end{align}\n%\nso we get \\(r = l^2/GM\\). The energy is given by \n%\n\\begin{align}\n  \\frac{v^2}{2} - \\frac{GM}{r} = E\n\\,,\n\\end{align}\n%\nand if we want to write these with respect to the velocity vector in polar coordinates, \\(v_r = \\dv*{v}{t}\\) and \\(v_\\theta = r \\dv*{\\theta }{t}\\) we have \n%\n\\begin{align}\n  v^2 = \\qty(\\dv{r}{t})^2 + r^2 \\qty(\\dv{\\theta }{t})^2\n\\,,\n\\end{align}\n%\nwhile the angular momentum in general is \\(\\vec{L} = \\vec{r} \\times \\vec{v}\\), whose modulus is \\(l = \\abs{\\vec{L}} = r v_{\\theta } = r^2 \\dv*{\\theta }{t}\\).\nTherefore, \\(v_{\\theta } = l/r\\). So, the velocity is \n%\n\\begin{align}\n  v^2= \\qty(\\dv{r}{t})^2 + \\frac{l^2}{r^2}\n\\,.\n\\end{align}\n\nThen, the equation for the radial motion of the planet is \n%\n\\begin{align}\n  \\frac{1}{2} \\qty(\\dv{r}{t})^2 - \\frac{GM}{r} + \\frac{l^2}{2r^2} = E\n\\,,\n\\end{align}\n%\nwhich for large \\(r\\) tends to 0 from below, while for small \\(r\\) tends to \\(+ \\infty\\).\n\nThe circular orbit is the one which corresponds to the bottom of the potential.\n\n\\subsubsection{Relativistic Schwarzschild orbits}\n\nPlanets \\emph{do not} actually orbit in true ellipses, but this is not actually the case even in Newtonian mechanics, since there are other objects in the universe.\nThe orbit of Mercury was expected to precede by \\(532''\\) every \\SI{100}{yr}, but people observed an additional \\(43''\\) every \\SI{100}{yr}.\nWe will compute this.\n\nFor semplicity, we will say that in our spherical coordinates Mercury will always have \\(\\theta = \\pi /2\\).\nThe 4-velocity of the planet will be \n%\n\\begin{align}\n  u^{\\alpha } = \\qty(\\dv{t}{\\tau }, \\dv{r}{\\tau }, 0, \\dv{\\varphi }{\\tau })\n\\,,\n\\end{align}\n%\nand we have two immediate Killing vectors: \\(\\xi^{\\alpha }_t= (1, \\vec{0} )\\) and \\(\\xi^{\\alpha }_\\varphi = (0,0,0, 1)\\) since the metric is independent of \\(t\\) and \\(\\varphi\\).\n\nWe call \\(e = - \\xi_t \\cdot u = (1 - 2GM/r) \\dv{t}{\\tau }\\).\n\nThe other Killing vector is \\(l = \\xi_\\varphi \\cdot u  =  r^2 \\sin^2 \\theta \\dv*{\\varphi }{\\tau }\\), but \\(\\theta = \\pi /2\\) so \\(l = r^2 \\dv*{\\varphi }{\\tau }\\). \n\nNow we want to impose the condition \\(-1 = u \\cdot u\\): \n%\n\\begin{subequations}\n\\begin{align}\n  -1 &=\n  - \\qty(1 - \\frac{2GM}{r}) \\qty(\\dv[]{t}{\\tau })^2\n  + \\qty(1 - \\frac{2GM}{r})^{-1} \\qty(\\dv[]{r}{\\tau })^2\n  + r^2 \\sin^2 \\theta \\qty(\\dv{\\varphi }{\\tau })^2  \\\\\n  &=\n  - \\qty(1 - \\frac{2GM}{r}) \\qty(\\frac{e}{1 - \\frac{2GM}{r}})^2\n  + \\qty(1 - \\frac{2GM}{r})^{-1} \\qty(\\dv[]{r}{\\tau })^2\n  + r^2 \\sin^2 \\theta \\qty(\\frac{l^2}{r^2})^2  \\\\\n  0&= - e^2 + \\qty(\\dv{r}{\\tau })^2\n  + \\qty(\\frac{l^2}{r^2}+1) \\qty(1 - \\frac{2GM}{r})\n\\,,\n\\end{align}\n\\end{subequations}\n%\nso \n%\n\\begin{subequations}\n\\begin{align}\n  e^2-1 &= \\qty(\\dv{r}{\\tau })^2 + \\qty(\\frac{l^2}{r^2} +1)\n  \\qty(1 - \\frac{2GM}{r}) - 1 \\\\\n  E &=  \\frac{1}{2} \\qty(\\dv{r}{\\tau })^2\n  + V _{\\text{eff}}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere \n%\n\\begin{align}\n  V_{\\text{eff}} = - \\frac{GM}{r} + \\frac{l^2}{2 r^2} - \\frac{GMl^2}{r^3}\n\\,,\n\\end{align}\n%\nand \n%\n\\begin{align}\n  E = \\frac{e^2-1}{2}\n\\,,\n\\end{align}\n%\nso the GR effects are exactly contained in that last term \\(GMl^2r^{-3}\\). This is very small: we consider it as a perturbation.\nThe potential can also be written, suggestively, as \n%\n\\begin{align}\nV _{\\text{eff}} = - \\frac{GM}{r} + \\frac{l^2}{2r^2} \\qty(1 - \\frac{2GM}{r})\n\\,,\n\\end{align}\n%\n\n\nAre there circular orbits in this case? \n\nThis \\(r^{-3}\\) term means that for \\(r \\rightarrow 0\\) the effective potential goes to \\(- \\infty\\).\n\nIn general we'd expect two stationary points: one which is closer and unstable, and one which is further and stable.\n\nIf we differentiate \\(\\dv*{V _{\\text{eff}}}{r}= 0\\) we get: \n%\n\\begin{align}\n  GM r^2 - l^2 r + 3GM l^2 = 0\n\\,,\n\\end{align}\n%\nand we consider the positive solution: \n%\n\\begin{align}\n  r= \\frac{l^2 \\pm \\sqrt{l^4 - 12 G^2M^2l^2}}{2GM}\n\\,,\n\\end{align}\n%\nand we take the plus sign since we want the orbit which is further out. \n%\n\\begin{align}\n  r = \\frac{l^2}{2GM} \\qty(1 + \\sqrt{1 - 12 \\frac{G^2M^2}{l^2}})\n\\,,\n\\end{align}\n%\nwhich is the formula for the stable circular orbit.\nExpanding for small relativistic corrections we get \n%\n\\begin{align}\n  r _{\\text{classical}} = \\frac{l^2}{2GM} \\qty(1+1-6 \\frac{G^2M^2}{l^2}) = \\frac{l^2}{GM} - 3GM\n\\,,\n\\end{align}\n%\nwhich is the Newtonian orbit \\(r = l^2/GM\\) with a correction.\n\nWhere is the boundary at which the solution disappears? it is where the square root vanishes: \n%\n\\begin{align}\n  l^2 = 12 G^2 M^2\n\\,,\n\\end{align}\n%\nor \\(l = GM \\sqrt{12}\\). Solutions exist as long as the angular momentum is greater than \\(GM \\sqrt{12}\\).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/fixed_L_orbits.pdf}\n\\caption{Allowed orbits at fixed \\(L\\). The unstable (lower) branch approaches \\(r = 3GM\\) asymptotically, the stable (upper) branch allows for arbitrarily large radii.}\n\\label{fig:fixed_L_orbits.pdf}\n\\end{figure}\n  \n\nFor \\(l _{\\text{min}}\\) we have \\(r _{\\text{min}} = 6 GM\\).\nThis is called the ISCO: \\emph{innermost stable circular orbit}: it is \\(3\\) times the Schwazschild radius \\(2GM\\).\n\n\\subsubsection{Orbital precession}\n\nNow, we consider elliptical orbits.\n\nThe idea is: the angle between two consecutive perihelions is \\(2\\pi + \\delta \\varphi _{\\text{precession}}\\).\n\nIn order to find the orbits, we want a relation between different coordinates during the orbit: we will use the equations \n%\n\\begin{subequations}\n\\begin{align}\n  l &= r^2 \\dv[]{\\varphi }{\\tau }  \\\\\n  \\frac{1}{2}\\qty(\\dv{r}{\\tau })^2 - \\frac{GM}{r} + \\frac{l^2}{2r^2} - \\frac{GMl^2}{r^3} &= E \n\\,,\n\\end{align}\n\\end{subequations}\n%\nso \\(\\dv{}{\\tau } = \\frac{l}{r^2} \\dv{}{\\varphi }\\). Then: \n%\n\\begin{align}\n  \\frac{l^2}{2 r^2} \\qty(\\dv{r}{\\varphi })^2 - \\frac{GM}{r} + \\frac{l^2}{2r^2} - \\frac{GMl^2}{r^3} = E\n\\,,\n\\end{align}\n%\nand it is convenient to solve for \\(u = r^{-1}\\): we get \n%\n\\begin{align}\n  \\dv[]{r}{\\varphi } = - \\frac{1}{u^2} \\dv{u }{\\varphi }\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{subequations}\n\\begin{align}\n  \\frac{l^2}{2} u^{4} \\frac{1}{ u^{4 }} \\qty(\\dv{u}{\\varphi })^2 - GMu + \\frac{l^2u^2}{2} - GMl^2u^3 &= E \\\\\n  \\frac{1}{2}\\qty(\\dv{u}{\\varphi })^2 - \\frac{GM}{l} u + \\frac{u^2}{2} - GMu^3 &= \\frac{E}{l^2}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand we want to remove \\(E\\) so we differentiate with respect to \\(\\varphi \\): \n%\n\\begin{align}\n  \\dv{u }{\\varphi } \\dv[2]{u}{\\varphi } - \\frac{GM}{l^2} \\dv{u}{\\varphi } + u \\dv[]{u}{\\varphi } - 3GM u^2 \\dv{u}{\\varphi } = 0\n\\,,\n\\end{align}\n%\nand the orbit is monotonic so \\(\\dv{u}{\\varphi } \\neq 0\\): \n%\n\\begin{align}\n  \\dv[2]{u}{\\varphi } + u = \\frac{GM}{l^2} + 3GMu^2\n\\,,\n\\end{align}\n%\nwhere the term from \\(GR\\) is precisely \\(3GMu^2\\), the rest is fully Newtonian.\n\nThis can be solved exactly with respect to complicated elliptic function, but we do it in a simpler way: a nearly circular orbit: \\(u = u_c (1+w(\\varphi ))\\), where \\(w \\ll 1\\).\n\nTo the order \\(w^{0}\\): \\(u_c = \\frac{GM}{l^2} + 3GM u_c^{2}\\), since it is a circular orbit (\\(u_c\\) is a constant!)\n\nTo first order in \\(w\\), instead, we get: \n%\n\\begin{align}\n  u_c \\dv[2]{w}{\\varphi } + u_c(1+w) = \\frac{GM}{l^2} + 3GMu_c^2 (1+2w)\n\\,,\n\\end{align}\n%\nsince \\(w \\ll 1\\). But the terms without \\(w\\) simplify: they satisfy the zeroth order equation. So, we are left with \n%\n\\begin{align}\n  \\dv[2]{w}{\\varphi }  = (6GMu_c-1) w\n\\,,\n\\end{align}\n%\nwhich is in the form \\(\\ddot{w} + \\omega^2 w =0\\), since \\(u_c < 1/(6GM)\\). If we look at unstable orbits with radii smaller than \\(6GM\\), then this is exponentially diverging.\n\n\\end{document}", "meta": {"hexsha": "c8b8428b0a1165c7174997611c366f1147ba71d5", "size": 10075, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/15nov.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/15nov.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/15nov.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 31.7823343849, "max_line_length": 204, "alphanum_fraction": 0.6064516129, "num_tokens": 3915, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.4399707686464115}}
{"text": "% NB: use pdflatex to compile NOT pdftex.  Also make sure youngtab is\n% there...\n\n% converting eps graphics to pdf with ps2pdf generates way too much\n% whitespace in the resulting pdf, so crop with pdfcrop\n% cf. http://www.cora.nwra.com/~stockwel/rgspages/pdftips/pdftips.shtml\n\n\n\n\n\\documentclass[10pt,aspectratio=169,dvipsnames]{beamer}\n\\usetheme[color/block=transparent]{metropolis}\n\n\\usepackage[absolute,overlay]{textpos}\n\\usepackage{booktabs}\n\\usepackage[utf8]{inputenc}\n\n\n\\usepackage[scale=2]{ccicons}\n\n\\usepackage[official]{eurosym}\n\n%use this to add space between rows\n\\newcommand{\\ra}[1]{\\renewcommand{\\arraystretch}{#1}}\n\n\n\\setbeamerfont{alerted text}{series=\\bfseries}\n\\setbeamercolor{alerted text}{fg=Mahogany}\n\\setbeamercolor{background canvas}{bg=white}\n\n\n\\newcommand{\\R}{\\mathbb{R}}\n\n\\def\\l{\\lambda}\n\\def\\m{\\mu}\n\\def\\d{\\partial}\n\\def\\cL{\\mathcal{L}}\n\\def\\co2{CO${}_2$}\n\n\n\n% for sources http://tex.stackexchange.com/questions/48473/best-way-to-give-sources-of-images-used-in-a-beamer-presentation\n\n\\setbeamercolor{framesource}{fg=gray}\n\\setbeamerfont{framesource}{size=\\tiny}\n\n\n\\newcommand{\\source}[1]{\\begin{textblock*}{5cm}(10.5cm,8.35cm)\n    \\begin{beamercolorbox}[ht=0.5cm,right]{framesource}\n        \\usebeamerfont{framesource}\\usebeamercolor[fg]{framesource} Source: {#1}\n    \\end{beamercolorbox}\n\\end{textblock*}}\n\n\\usepackage{hyperref}\n\n\n%\\usepackage[pdftex]{graphicx}\n\n\n\\graphicspath{{graphics/}}\n\n\\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg}\n\n\n\n\\def\\goat#1{{\\scriptsize\\color{green}{[#1]}}}\n\n\n\\newcommand{\\ubar}[1]{\\text{\\b{$#1$}}}\n\n\\let\\olditem\\item\n\\renewcommand{\\item}{%\n\\olditem\\vspace{5pt}}\n\n\\title{Energy System Modelling\\\\ Summer Semester 2020, Lecture 14}\n%\\subtitle{---}\n\\author{\n  {\\bf Dr. Tom Brown}, \\href{mailto:tom.brown@kit.edu}{tom.brown@kit.edu}, \\url{https://nworbmot.org/}\\\\\n  \\emph{Karlsruhe Institute of Technology (KIT), Institute for Automation and Applied Informatics (IAI)}\n}\n\n\\date{}\n\n\n\\titlegraphic{\n  \\vspace{0cm}\n  \\hspace{10cm}\n    \\includegraphics[trim=0 0cm 0 0cm,height=1.8cm,clip=true]{kit.png}\n\n\\vspace{5.1cm}\n\n  {\\footnotesize\n\n  Unless otherwise stated, graphics and text are Copyright \\copyright Tom Brown, 2020.\n  Graphics and text for which no other attribution are given are licensed under a\n  \\href{https://creativecommons.org/licenses/by/4.0/}{Creative Commons\n  Attribution 4.0 International Licence}. \\ccby}\n}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\begin{frame}\n\n  \\frametitle{Table of Contents}\n  \\setbeamertemplate{section in toc}[sections numbered]\n  \\tableofcontents[hideallsubsections]\n\\end{frame}\n\n\n\\section{Idea of Principal Component Analysis (PCA)}\n\n\n\\begin{frame}\n  \\frametitle{The idea of Principal Component Analysis (PCA)}\n\n\n\n    \\begin{columns}[T]\n    \\begin{column}{7.5cm}\n\n      Suppose we have a set of time series $x_i(t)$ for $i=1,\\dots N$ whose means $\\langle \\cdot \\rangle$ are centred at the origin $\\langle x_i(t) \\rangle = 0$ for all $i$.\n\n      \\vspace{.2cm}\n\n      \\alert{Principal Component Analysis (PCA)} is a tool to find the directions in the $N$-dimensional $x_i$ space which cause the biggest variance.\n\n      \\vspace{.2cm}\n\n      We change to a new (orthonormal) basis $\\rho^k_i$ ($k=1,\\dots N$) in $N$-dimensional $x_i$ space where the first basis vector $\\rho^1$ is in the direction of highest variance, the second $\\rho^2$ in the next highest, etc.\n\n      \\vspace{.2cm}\n\n      We can then use this for \\alert{dimensional reduction} and ignore directions with low variance.\n    \\end{column}\n    \\begin{column}{6.5cm}\n\n        \\vspace{.3cm}\n        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html\n        \\includegraphics[trim=0 0cm 0 0cm,width=7cm,clip=true]{price-residual_load-1806.png}\n\n\n    \\end{column}\n    \\end{columns}\n\n    \\source{\\url{https://energy-charts.de/}}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Procedure 1/2}\n\n  \\begin{itemize}\n  \\item Calculate the \\alert{covariance matrix}:\n    \\begin{equation*}\n      \\Sigma_{ij} = \\langle x_i(t) x_j(t) \\rangle -\\langle x_i(t) \\rangle \\langle x_j (t) \\rangle = \\langle x_i(t) x_j(t) \\rangle\n    \\end{equation*}\n    remembering that we've arranged $\\langle x_i(t) \\rangle = 0$. NB: The covariance matrix is \\alert{symmetric} ($\\Rightarrow$ $N$ orthogonal eigenvectors) and \\alert{positive semi-definite} ($\\Rightarrow$ eigenvalues $\\l_k \\geq 0$).\n\n    The diagonal entries $\\Sigma_{ii}$ give the variance of each $x_i(t)$.\n\n  \\item Find the \\alert{eigenvectors} $\\rho^k_i$ and \\alert{eigenvalues} $\\lambda_k$ for $k=1,\\dots N$ of the \\alert{normalised covariance matrix} $\\frac{\\Sigma}{\\textrm{tr}(\\Sigma)}$\n    \\begin{equation*}\n      \\frac{1}{\\textrm{tr}(\\Sigma)}\\sum_j \\Sigma_{ij} \\rho^k_j = \\lambda_k \\rho^k_i\n    \\end{equation*}\n    The normalization is chosen such that $\\sum_{k=1}^N \\lambda_k = \\textrm{tr} \\left(\\frac{\\Sigma}{\\textrm{tr}(\\Sigma)}\\right) = 1$.\n  \\end{itemize}\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Procedure 2/2}\n\n  \\begin{itemize}\n      \\item Order the eigenvectors $\\rho^k_i$ and eigenvalues $\\lambda_k$ from highest $\\lambda_k$ to lowest. The value $\\lambda_k$ represents the share of the variance of $x_i(t)$ associated with the $k$th component $\\rho^k_i$.\n    \\item We can discard components with low variance, e.g. only keep the first $K$ \\alert{principal components} such that $\\sum_{k=1}^K\\lambda_k \\geq  0.95$, i.e. that represent 95\\% of the variance.\n  \\end{itemize}\n\n  Note that the $\\rho^k_i$ is an orthogonal matrix  that defines a new basis for the $N$-dimensional space such that the projections of $x_i(t)$ onto this new basis are uncorrelated with variance $\\propto\\lambda_k$.\n\n  Orthogonal means the matrix multiplied by its transpose gives the identity matrix $\\mathbb{I}$:\n  \\begin{equation*}\n    \\sum_i \\rho^k_i \\rho^l_i = \\mathbb{I}_{kl} = \\left\\{\\begin{array}{lr} 0 \\text{ if } k \\neq l \\\\ 1  \\text{ if } k = l \\end{array} \\right.\n  \\end{equation*}\n  If we now project $x_i(t)$ onto the $\\rho^k_i$, $x_i(t) = \\sum_k a_k(t) \\rho^k_i$, show that $a_k(t) = \\sum_i  \\rho^k_i x_i(t)$ and now\n  \\begin{equation*}\n    \\langle a_k(t) a_l(t) \\rangle = \\sum_{i,j}\\rho^k_i \\rho^l_j \\langle x_i(t) x_j(t) \\rangle  = \\sum_{i,j}\\rho^k_i    \\Sigma_{ij} \\rho^l_j =  \\sum_{i}\\rho^k_i \\textrm{tr}(\\Sigma) \\lambda_l \\rho^l_i = \\textrm{tr}(\\Sigma) \\lambda_k \\mathbb{I}_{kl}\n  \\end{equation*}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{PCA as optimisation problem}\n  We can also represent this procedure as an optimisation problem.\n\n  We define the projection of $x_i(t)$ onto some unit vector $\\rho^1_i$ ($\\rho^1 \\cdot \\rho^1 =1$):\n  \\begin{equation*}\n    a_1(t) = x(t) \\cdot \\rho^1\n  \\end{equation*}\n  We choose the $\\rho^1$ such that the variance of $a_1(t)$:\n  \\begin{equation*}\n    \\langle a_1(t)^2 \\rangle = \\langle (x(t) \\cdot \\rho^1)^2 \\rangle\n  \\end{equation*}\n  is maximised. This is an optimisation problem!\n  \\begin{equation*}\n    \\max_{\\{\\rho_i^1\\}} \\sum_{i,j} \\left\\langle x_i(t)x_j(t) \\rho^1_i  \\rho^1_j \\right\\rangle\n  \\end{equation*}\n  such that\n  \\begin{equation*}\n    \\sum_i \\rho^1_i \\rho^1_i = 1 \\hspace{.5cm} \\leftrightarrow \\lambda_1\n  \\end{equation*}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{PCA as optimisation problem}\n\n  KKT gives us from stationarity\n  \\begin{equation*}\n    0 = \\frac{\\d \\mathcal{L}}{\\d \\rho^1_i} = \\frac{\\d f}{\\d \\rho^1_i} - \\lambda_1 \\frac{\\d g_1}{\\d \\rho^1_i} = 2\\sum_j \\rho^1_j \\left\\langle x_i(t)x_j(t) \\right\\rangle - 2\\lambda_1 \\rho^1_i\n  \\end{equation*}\n  This is nothing other than the eigenvalue equation for the covariance matrix $\\Sigma_{ij} = \\left\\langle x_i(t)x_j(t) \\right\\rangle$!\n\n  Now consider the remainder defined by\n  \\begin{equation*}\n    \\delta_i(t) = x_i(t) - a_1(t) \\rho^1_i\n  \\end{equation*}\n\n  Now let's find a second unit vector $\\rho^2_i$ which is orthogonal to $\\rho^1_i$ and points in the direction of greatest variance of the remainder $\\delta_i(t)$\n  \\begin{equation*}\n    \\max_{\\{\\rho_i^2\\}} \\sum_{i,j} \\left\\langle (\\delta_i (t) \\cdot \\rho^2)^2 \\right\\rangle =     \\max_{\\{\\rho_i^2\\}} \\sum_{i,j} \\left\\langle (x_i (t) \\cdot \\rho^2)^2 \\right\\rangle\n  \\end{equation*}\n  where we've used the fact that $\\rho^1 \\cdot \\rho^2 = 0$. Repeating optimisation, we get another eigenvalue-eigenvector pair. Repeat until we have all eigenvalues and eigenvectors.\n\n\\end{frame}\n\n\n\n\n\\section{Application to Power System}\n\n\n\n\\begin{frame}\n  \\frametitle{Application to power injections for highly renewable European system}\n\n    \\begin{columns}[T]\n      \\begin{column}{7.5cm}\n\n        We're now going to apply PCA to the solved dispatch and network flows for a highly renewable European power system.\n\n        \\vspace{.2cm}\n\n        First we apply PCA to the power injections $p_i(t) = \\sum_s g_{i,s}(t) - d_i(t)$ (generation minus demand). We compute the power injection covariance matrix:\n        \\begin{equation*}\n          \\Sigma^p_{ij} = \\langle p_i(t) p_j(t) \\rangle -\\langle p_i(t) \\rangle \\langle p_j (t) \\rangle\n        \\end{equation*}\n        NB: $i,j$ run over the $N$ different network nodes.\n\n        \\vspace{.2cm}\n\n        Next we find the eigenvectors and eigenvalues $\\lambda_k^p$ that represent the principal components.\n\n    \\end{column}\n    \\begin{column}{7cm}\n\n      Average power injection $\\langle p_i(t) \\rangle$ at each node:\n        \\vspace{.1cm}\n        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html\n        \\includegraphics[trim=0 0cm 0 0cm,width=7.5cm,clip=true]{pca-pi_mean.png}\n\n\n    \\end{column}\n  \\end{columns}\n\n    \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Power injection components}\n\n  The first 3 principal components represent the major axes of weather variations (1st is coastal wind production, 2nd is North-South seasonal pattern, 3rd is East-West load and solar daily pattern - check by Fourier transforming projection onto components):\n\n  \\vspace{.2cm}\n  \\centering\n  \\includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-pi_components.png}\n\n  \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Application to resulting power flows}\n\n    \\begin{columns}[T]\n      \\begin{column}{7.5cm}\n\n        Next we apply PCA to the resulting power flows $f_\\ell$, related via the Power Transfer Distribution Factors\n        \\begin{equation*}\n          f_\\ell = \\sum_i H_{\\ell i} p_i\n        \\end{equation*}\n        (we use the notation $H =  K^t L^{-1}$ for the PTDF to make things easier later).\n\n        \\vspace{.2cm}\n\n        We compute the power flow covariance matrix:\n        \\begin{equation*}\n          \\Sigma^f_{\\ell m} = \\langle f_\\ell(t) f_m(t) \\rangle -\\langle f_\\ell(t) \\rangle \\langle f_m (t) \\rangle\n        \\end{equation*}\n        NB: $\\ell,m$ run over the $L$ different network lines.\n\n        \\vspace{.2cm}\n\n        Next we find the eigenvectors and eigenvalues $\\lambda_n^f$ that represent the principal components.\n\n    \\end{column}\n    \\begin{column}{7cm}\n\n      Average power flow $\\langle f_\\ell(t) \\rangle$ at each line:\n        \\vspace{.3cm}\n        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html\n        \\includegraphics[trim=0 0cm 0 0cm,width=7.5cm,clip=true]{pca-fl_mean.png}\n\n\n    \\end{column}\n  \\end{columns}\n\n    \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Power flow components}\n\n  The first 3 principal components represent the major flow (1st is flow to North-West, 2nd to North-East and 3rd shows multiple directions). Note that the first three make up a \\alert{much larger share of the variance} than for the power injection case.\n\n  \\vspace{.2cm}\n  \\centering\n  \\includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-fl_components.png}\n\n  \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Number of relevant components}\n\n  \\begin{itemize}\n  \\item How many principal components $K$ do we need to represent 95\\% of the total variance?\n    \\begin{equation*}\n      \\sum_{k=1}^K \\lambda_k \\geq  0.95\n    \\end{equation*}\n  \\item How does this number depend on the spatial resolution, i.e. the number of network nodes $N$ used to represent the European grid?\n  \\end{itemize}\n  \\vspace{.2cm}\n  \\centering\n  \\includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-p_v_f.png}\n\n  \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Number of relevant components}\n\n  \\centering\n  \\includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-p_v_f.png}\n\n  \\raggedright\n  This graph is odd for (at least) 3 reasons:\n  \\begin{itemize}\n  \\item Why does the number of components required for the power injection rise then saturate at several hundred nodes? (Answer: correlation length)\n  \\item Why are so few components required to represent the power flow?\n    \\item Why doesn't the number of components change for the power flow?\n  \\end{itemize}\n\n  \\source{\\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Relation of injection to flow covariance matrix}\n\n  We have the following equations:\n  \\begin{align*}\n    f_\\ell & = \\sum_i H_{\\ell i} p_i \\\\\n    \\Sigma^p_{ij} & = \\langle p_i(t) p_j(t) \\rangle -\\langle p_i(t) \\rangle \\langle p_j (t) \\rangle \\\\\n          \\Sigma^f_{\\ell m} & = \\langle f_\\ell(t) f_m(t) \\rangle -\\langle f_\\ell(t) \\rangle \\langle f_m (t) \\rangle\n  \\end{align*}\n  So how are the flow covariance $\\Sigma^f_{\\ell m}$ and injection covariance $\\Sigma^p_{ij}$ matrices related?\n\n  \\pause\n  \\begin{equation*}\n     \\Sigma^f = H\\Sigma^p H^t\n  \\end{equation*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Relation of injection to flow covariance matrix}\n  Now consider another $N\\times N$ matrix $M$ defined by\n  \\begin{equation*}\n    M = \\Sigma^p H^tH\n  \\end{equation*}\n  Note that the first term $\\Sigma^p$ comes from the injection\n  pattern, whereas the second part $H^tH$ is entirely determined by\n  the topology of the network (built from $K$ and $L$).\n\n  If $\\nu^k$ is an eigenvector of $M$ with eigenvalue $\\eta_k$, $M\\nu^k = \\eta_k \\nu^k$, show that $H\\nu^k$ is an eigenvector of $\\Sigma^f$ with eigenvalue $\\eta_k$.\n  \\pause\n  \\begin{equation*}\n    \\Sigma^f H\\nu^k = H \\Sigma^p H^t H \\nu^k = H M \\nu^k = \\eta_k H\\nu^k\n  \\end{equation*}\n\n  So to analyse the principal components of the flow, it suffices to study the eigenvectors of matrix $M$.\n\n  It turns out that if the first few eigenvectors of $H^t H$ and\n  $\\Sigma^p$ with the strongest eigenvalues strongly overlap, then they magnify each other to the\n  exclusion of other eigenvectors.\n\n  This is what happens for $M$ (and by extension $\\Sigma^p$): the eigenvectors of $H^tH$ magnify only the first few principal components of $\\Sigma^p$, which then dominate $\\Sigma^f$.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Network topology reinforces power injection pattern to magnify flow pattern}\n\n  \\centering\n  \\includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca_magnification.png}\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Network Topology reinforces flow pattern}\n\n  To find out more, see our paper:\n\n  Fabian Hofmann, Mirko Schäfer, Tom Brown, Jonas Hörsch, Stefan Schramm, Martin Greiner, ``Principal Flow Patterns across renewable electricity networks,'' EPL, 2018, \\href{https://arxiv.org/abs/1807.07771}{\\bf\\color{blue}\\underline{link}}\n\n\\end{frame}\n\\end{document}\n", "meta": {"hexsha": "9c49ef7e395fae9b688eb154996a49cfc2361d6b", "size": 15403, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "esm-lecture-14.tex", "max_stars_repo_name": "nworbmot/esm-lectures", "max_stars_repo_head_hexsha": "780320fa6755596cd1578f1c035f66208e496215", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2020-05-26T19:02:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T17:54:02.000Z", "max_issues_repo_path": "esm-lecture-14.tex", "max_issues_repo_name": "pitmonticone/esm-lectures", "max_issues_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "esm-lecture-14.tex", "max_forks_repo_name": "pitmonticone/esm-lectures", "max_forks_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-06-25T16:25:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-15T08:25:36.000Z", "avg_line_length": 34.0774336283, "max_line_length": 258, "alphanum_fraction": 0.6914237486, "num_tokens": 5010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.43997076443975436}}
{"text": "\\section{Algorithms}\n\tIn this section we will present our aproach to tackle the speaker recognition problem.\n\n    An utterance of a user is collected during enrollment procedure.\n    Further processing of the utterance follows following steps:\n    \\subsection{VAD}\n        Signals must be first filtered to rule out the silence part, otherwise the\n        training might be seriously biased. Therefore \\textbf{Voice Activity Detection} must\n        be first performed.\n\n        An observation found is that, the corpus provided is nearly noise-free.\n        Therefore we use a simple energy-based approach\n        to remove the silence part, by simply remove the frames that the average\n        energy is below 0.01 times the average energy of the whole utterance.\n\n        This energy-based method is found to work well on database, but not\n        on GUI.\n        We use LTSD(Long-Term Spectral Divergence) \\cite{ltsd1}\n        algorithm on GUI, as well as noise reduction technique from SOX\\cite{sox} to gain better result in real-life application.\n\n        LTSD algorithm splits a utterance into overlapped frames, and give scores for each frame on\n        the probability that there is voice activity in this frame. This probability will be accumulated\n        to extract all the intervals with voice activity. A picture depicting the principle of LTSD is as followed:\n\n        \\begin{figure}[H]\n          \\centering\n          \\includegraphics[width=0.6\\textwidth]{img/ltsd.png}\n        \\end{figure}\n\t\tSince this is not our primary-task, we shall not expand details here. For further\n\t\tinformation on how these works, please consult original paper.\n\n\n        \\input{feature}\n        \\input{model}\n\n", "meta": {"hexsha": "80157f195ddf4e6e4539230f0e3f4c865f2fc20d", "size": 1703, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/Final-Report-Complete/algorithm.tex", "max_stars_repo_name": "juliia5m/knu_voice", "max_stars_repo_head_hexsha": "1f5d150ded23af4c152b8d20f1ab4ecec77b40e1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 717, "max_stars_repo_stars_event_min_datetime": "2015-01-03T15:25:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T12:45:45.000Z", "max_issues_repo_path": "doc/Final-Report-Complete/algorithm.tex", "max_issues_repo_name": "juliia5m/knu_voice", "max_issues_repo_head_hexsha": "1f5d150ded23af4c152b8d20f1ab4ecec77b40e1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2015-03-19T09:25:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-19T08:51:26.000Z", "max_forks_repo_path": "doc/Final-Report-Complete/algorithm.tex", "max_forks_repo_name": "juliia5m/knu_voice", "max_forks_repo_head_hexsha": "1f5d150ded23af4c152b8d20f1ab4ecec77b40e1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 315, "max_forks_repo_forks_event_min_datetime": "2015-01-21T00:06:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T08:13:36.000Z", "avg_line_length": 47.3055555556, "max_line_length": 129, "alphanum_fraction": 0.7193188491, "num_tokens": 366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.43997075941016606}}
{"text": "\\section{Other rules}\n\n\\subsection{Conditional rules}\n\\label{sec-cond}\n\nConditional rules allow us to introduce and eliminate the conditional wffs\n{\\wffif} and conditional terms {\\termif}.\n\n\\begin{bnf}\n\t{\\wffif}  \\sep {\\bf wffif} {\\wff}$_1$ {\\bf then} {\\wff}$_2$ {\\bf else}\n\t\t\t\t   {\\wff}$_3$ \\\\\n\t{\\termif} \\sep {\\bf trmif} {\\wff} {\\bf then} {\\term}$_1$ {\\bf else}\n\t\t\t\t   {\\term}$_2$\n\\end{bnf}\n\nNote that the {\\termif} construct is not first order.\nHowever, it can easily be shown that {\\termif} can be defined as a conservative\nextension of first order logic using an induction on the length of deductions.\n\n\\renewcommand{\\arraystretch}{0.5}\n\\[\n\\begin{array}{|c|c||c|c|} \\hline \n\\multicolumn{2}{|c||}{\\mbox{\\bf Introduction rules}} &\n\\multicolumn{2}{c|}{\\mbox{\\bf Elimination rules}} \\\\ \\hline\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em wif}} \\  I  \n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n{[A]}\\\\\n\\vdots\\\\\nB\n\\end{array}\n\\ \\ \\ \n\\begin{array}{c}\n{[\\neg A]}\\\\\n\\vdots\\\\\nC\n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\n\\mbox{{\\em wffif}} \\ A \\ \\mbox{{\\em then}} \\ B \\ \\mbox{{\\em else}} \\ C \n\\end{array}\n\\end{array}\n&\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em wif}} \\  E\n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\nA\n\\end{array}\n\\ \\ \\ \n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em wffif}} \\ A \\ \\mbox{{\\em then}} \\ B \\ \\mbox{{\\em else}} \\ C \n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\nB\n\\end{array}\n\\end{array}\n%\\fraz{\\Gamma \\vdash A \\ \\ \\Delta \\vdash \\mbox{{\\em wffif}} \\ A \\ \\mbox{{\\em then}} \\ B \\ \n%\\mbox{{\\em else}} \\ C}\n%     {\\Gamma,\\Delta \\vdash B}\n\\\\ %\\hline \n& &\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em wif}} \\  E_{\\neg}\n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\n\\neg A\n\\end{array}\n\\ \\ \\ \n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em wffif}} \\ A \\ \\mbox{{\\em then}} \\ B \\ \\mbox{{\\em else}} \\ C \n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\nC\n\\end{array}\n\\end{array}\n\\\\ %\\hline\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em tif}} \\  I    \n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n{[A]}\\\\\n\\vdots\\\\\nB(t_1)\n\\end{array}\n\\ \\ \\ \n\\begin{array}{c}\n{[\\neg A]}\\\\\n\\vdots\\\\\nB(t_2)\n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\nB(\\mbox{{\\em termif}} \\ A \\ \\mbox{{\\em then}} \\ t_1 \\ \\mbox{{\\em else}} \\ t_2)\n\\end{array}\n\\end{array}\n&\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em tif}} \\  E\n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\nA\n\\end{array}\n\\ \\ \\ \n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\nB(\\mbox{{\\em termif}} \\ A \\ \\mbox{{\\em then}} \\ t_1 \\ \\mbox{{\\em else}} \\ t_2)\n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\nB(t_1)\n\\end{array}\n\\end{array}\n\\\\ %\\hline \n& &\n\\begin{array}{l}\n\\\\ \\\\ \\\\ \\\\ \\\\\n\\mbox{{\\em tif}} \\  E_{\\neg}\n\\end{array}\n&\n\\begin{array}{cc}\n\\\\ \\\\\n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\n\\neg A\n\\end{array}\n\\begin{array}{c}\n\\\\ \\\\ \\\\ \\\\\nB(\\mbox{{\\em termif}} \\ A \\ \\mbox{{\\em then}} \\ t_1 \\ \\mbox{{\\em else}} \\ t_2)\n\\end{array}\n\\\\\n\\hline\\\\\n\\begin{array}{c}\nB(t_2)\n\\end{array}\n\\end{array}\n\\\\ \n& & & \\\\ \\hline \n\\end{array}\n\\]\n\\renewcommand{\\arraystretch}{1}\n\n\n\\subsection{Structural rules}\n\nStructural rules are useful when performing theorem proving.", "meta": {"hexsha": "82a54396feae5ee8b3e66240384778fa2a4cec65", "size": 3102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user/rules/introrul.tex", "max_stars_repo_name": "getfol/GETFOL", "max_stars_repo_head_hexsha": "b861b00f2301b826f058010b42555789e2a9401d", "max_stars_repo_licenses": ["DOC", "Unlicense"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2019-08-25T01:02:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T05:17:17.000Z", "max_issues_repo_path": "doc/user/rules/introrul.tex", "max_issues_repo_name": "getfol/GETFOL", "max_issues_repo_head_hexsha": "b861b00f2301b826f058010b42555789e2a9401d", "max_issues_repo_licenses": ["DOC", "Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/user/rules/introrul.tex", "max_forks_repo_name": "getfol/GETFOL", "max_forks_repo_head_hexsha": "b861b00f2301b826f058010b42555789e2a9401d", "max_forks_repo_licenses": ["DOC", "Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-25T02:05:54.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-25T02:05:54.000Z", "avg_line_length": 17.3296089385, "max_line_length": 90, "alphanum_fraction": 0.5473887814, "num_tokens": 1289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4399707560264401}}
{"text": "\\vspace{-.1em}\n\\subsection{Dependent Types and Co-Constructors}\n\\p{To see why the metaconstructor problem \ndetermines how extensively Dependent Types are \nsupported in a type system, consider a variation \non the range \\ZeroToOneHundred{} type.  \nIn lieu of a fixed range, consider a procedure \ntaking a (variable) \\Tvar{}-range \\rRan{} and a number \\xSym{}\n\\i{which must be in that range}.  Here \\xSym{}\n\\q{depends} on \\rRan{} \\mdash{} its \\i{type} is \\rRan{}\nseen as its own \\TVOneToVTwo{} type \\mdash{} so \n\\xSym{} can vary among many \nrange-types, only being fixed at runtime.  Defining a \n\\i{type} for procedures meeting those \n\\i{specifications} is a classic problem of \nDependent Type theory.\n}\n\\p{Using the \\rRan{}-type as before, the type of \\fFun{}'s second parameter\nwould then be \\Tvar{} restricted to the \\rRan{} interval, but here\n\\rRan{} is not fixed in \\fFun{}'s declaration but rather passed in to\n\\fFun{} as a parameter.  Unless we know \\i{a priori} that only\na specific set of \\rRan{}s in the first parameter will ever be encountered,\nthe compiler has to be prepared for \\xSym{} being assigned any one \nof many different range types, depending on the \\fFun{}'s first argument.  \nIn particular, the compiler cannot know ahead of time which \nconstructor to call for \\xSym{}.  More precisely, it is impossible \nfor the compiler to have \\i{separate} constructors for millions \nof possible range types.  Instead, the compiler must either \n\\q{create} a constructor \\q{on the fly} or else have \nsome generic constructor which services many range-types, \nbut then requires extra information to establish \n\\i{which} range is desired. \n}\n\\p{Assuming we use co-constructors to wrap constructors, \nthese two options for compiler writers correspond to \nthe choice of \\i{either} creating ad-hoc co-constructors \n\\i{or} designing co-constructors as a \ncompound data structure.  We could certainly write a function that takes a range and a value and\nensures that the value fits the range \\mdash{} perhaps by throwing an\nexception if not, or mapping the value to the range's closest point.\nSuch a function would provide common functionality for a family of\nconstructors each associated with a given range.  But a function (\\cfFun{}, say)\nproviding \\q{common functionality} for value constructors is not necessarily\nitself a value constructor.\\footnote{Here I say \\q{value constructor} to clarify that I am not \ncommenting on \\i{type constructors}, which derive specialized \ntypes from generic ones.\n}\nTo treat such a function as a\n\\i{real} value constructor we would have to add contextual modifiers:\n\\cfFun{} is a value constructor for range-type \\rRan{} in the \npresence of a \\Tvar{}-pair to specify \\rRan{} at runtime.\nThe co-constructor for a range type \\TrRan{} is accordingly the\n\\q{common functionality} base function \\i{plus} \\Tvar{}'s \npassed to it \\mdash{} some sort of \\Cfr{} compound data structure,\nagain by analogy to \\inc{} and\n\\addOne{} (see footnote \\ref{fofgplausible}, above).  Here again, though, \nthe co-constructor is a temporary data structure, \ncreated on-the-fly to model the desired value constructor \nfor an \\xSym{} whose type (and therefore whose constructor) \nis not known until runtime.  I contend, on examples like \nthese, that Dependant Typing for a type system \\TyS{} is thus logically \nequivalent to the possibility of \\TyS{} co-constructors \nbeing temporary values.   \n}\n\\p{But value constructors (and by extension co-constructors) \nare not just any function-value: they have a privileged\nstatus \\visavis{} types, and may be invoked whenever an appropriately-typed\nvalue is used.  Many constructors are called behind-the-scenes: \nin \\Cpp{}, the standard function-call mechanism is\n\\q{pass by value}, wherein values are \\i{copied} when passed \nbetween procedures; but any copy can potentially \ninvoke a so-called \\q{copy constructor}.  Indeed, programmers \nuse certain constructors as \\q{hooks} to silently \ninsert logic into normal program flow (usually this is \nto make complex types behave like built-in-types from \nclient code's point of view).  Allowing large type families (like one type\nfor each \\int{} or each two-number range \\rRan{} \\mdash{} similar to \\q{inductive typing} as\ndiscussed by Edwin Brady in the context of the Idris language\n\\cite[p. 12]{EdwinBradyImpl}) \\mdash{} could easily conflict with \nuser-defined constructor overrides: users (meaning, in this context, \nlibrary developers) would need not only to write their own \n(e.g., copy) constructors, but to hook into a complex \nrun-time mechanism for creating constructors ad-hoc as temporary values.\nConversely, forcing co-constructors to be\naddressable prohibits \\q{large} type families \\mdash{} like types indexed\nover other (non-enumerative) types\n(see e.g. \\cite[p. 4]{BernardyEtAl}) \\mdash{} at least as \\i{actual} types.\nThis apparently precludes full-fledged Dependent Types, since\ndependent-typed values invariably require in general some extra\ncontextual data \\mdash{} not just a function-pointer \\mdash{} to designate the\ndesired value constructor at the point where a value,\nattributed to the relevant dependent type,\nis needed.  It may be infeasible to add the requisite contextual\ninformation at every point where a dependent-typed value has to be constructed\n\\mdash{} unless, perhaps, a description of the context can be packaged and\ncarried around with the value, sharing the value's lifetime.\n}\n\\p{As I will now review, this analysis in the realm of \nDependent Types carries over into \\i{typestate}, \nwhich is another mechanism intended to model \ncoding requirements via type-checkable specifications.\n}\n", "meta": {"hexsha": "e974e60e72f3da2051a707bb2ae7ca2ea04d85a1", "size": 5629, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "NCG/section4a.ngml.tex", "max_stars_repo_name": "ScignScape-RZ/ntxh", "max_stars_repo_head_hexsha": "8e3fe51f5e9071fb24b41586b5151576a932dd1b", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "NCG/section4a.ngml.tex", "max_issues_repo_name": "ScignScape-RZ/ntxh", "max_issues_repo_head_hexsha": "8e3fe51f5e9071fb24b41586b5151576a932dd1b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NCG/section4a.ngml.tex", "max_forks_repo_name": "ScignScape-RZ/ntxh", "max_forks_repo_head_hexsha": "8e3fe51f5e9071fb24b41586b5151576a932dd1b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.6504854369, "max_line_length": 96, "alphanum_fraction": 0.7710072837, "num_tokens": 1418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6791786991753931, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.43997074176060674}}
{"text": "\\documentclass{article}\n\\title{Automata}\n\\author{Jeroen F. J. Laros}\n\\date{August 6, 2004}\n\\usepackage{../graphs/graphs}\n\\usepackage{amsfonts, amssymb, amsthm}\n\\frenchspacing\n\\setlength{\\parindent}{0pt}\n\\begin{document}\n\n\\renewcommand{\\qedsymbol}{$\\blacksquare$}\n\\newcommand{\\bs}{\\begin{small}}\n\\newcommand{\\es}{\\end{small}}\n\\newcommand{\\bS}{\\begin{tiny}}\n\\newcommand{\\eS}{\\end{tiny}}\n\\newcommand{\\monoit}[1]{\\texttt{\\textit{#1}}}\n\n\\newtheorem{theorem}{Theorem}[subsection]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\n\\theoremstyle{definition}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{remark}[theorem]{Remark}\n\n\\maketitle\n\n\\section{Introduction}\nAutomatic sequences are connected in a fundamental way with substitutions of\n\\emph{constant length}.\n\n\\begin{definition}[Finite automaton] \\label{def:finite_automaton}\nA finite automaton is a 5-tuple $A = \\{\\mathcal{S}, \\Delta, \\delta, I, F\\}$\nin which:\n\\begin{itemize}\n\\item $\\mathcal{S}$ is the finite set of states.\n\\item $\\Delta$ is the finite alphabet of labels.\n\\item $\\delta \\subseteq \\mathcal{S} \\times \\Delta \\times \\mathcal{S}$ is the \n      collection of transitions.\n\\item $I \\subseteq \\mathcal{S}$ is the collection of initial states.\n\\item $F \\subseteq \\mathcal{S}$ is the collection of final states.\n\\end{itemize}\n\\end{definition}\n\nA finite automaton is represented as a directed graph with a set of vertices\n$\\mathcal{S}$ called \\emph{states}, a set of edges $\\delta$ called \n\\emph{transitions}\nand specially marked subsets of states $I$ and $F$, being the initial and final\nstates.\n\nFor our purposes, we will restrict ourselves to automata that have\n$F = \\mathcal{S}$ as the set of final states, so we will leave notion $F$\nout unless stated otherwise. The states in $I$ are marked with a $\\Uparrow$.\n\n\\begin{definition}[Finiteness] \\label{def:finiteness}\nAn automaton is called \\emph{finite} if $\\mathcal{S}$ is finite.\n\\end{definition}\n\n\\begin{definition}[Determinism] \\label{def:determinism}\nAn automaton is called \\emph{deterministic} if the following two conditions \nhold:\n\\begin{itemize}\n\\item $\\exists (p \\in I) \\forall (q  \\in \\mathcal{S})\n\\{q = p \\lor q \\notin I\\}$\n\\item $\\forall (p \\in \\mathcal{S}) \\forall (a \\in \\Delta)\n\\forall (q \\in \\mathcal{S}) \\forall (r \\in \\mathcal{S})\n\\{(p, a, q) \\in \\delta \\land (p, a, r) \\in \\delta \\Rightarrow q = r\\}$.\n\\end{itemize}\n\\end{definition}\n\nIn other words:\n\\begin{itemize}\n\\item There must be one and only one initial state.\n\\item There can be no two branches with the same label coming from the same \n  state.\n\\end{itemize}\n% Picture of non-deterministic automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0) \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{0}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n  \\freetext(-2.5, -1.2){non-deterministic}\n\\end{graph}\n%}}}1\n% Picture of deterministic automaton. {{{1\n\\begin{graph}(0, 3)(-9, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0) \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n  \\freetext(-2.5, -1.2){deterministic}\n\\end{graph}\n%}}}1\n\n\\begin{definition}[Completeness] \\label{def:completeness}\nAn automaton is \\emph{complete} (or total) if the following condition holds:\n\\begin{itemize}\n\\item $\\forall (p \\in \\mathcal{S}) \\forall (a \\in \\Delta)\n\\exists (q \\in \\mathcal{S}) \\{(p, a, q) \\in \\delta\\}$\n\\end{itemize}\n\\end{definition}\n\nIn other words: Each state must have $|\\Delta|$ outgoing branches.\n\n% Picture of non-complete automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0) \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n  \\freetext(-2.5, -1.2){non-complete}\n\\end{graph}\n%}}}1\n% Picture of complete automaton. {{{1\n\\begin{graph}(0, 3)(-9, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0) \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){0,1}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n  \\freetext(-2.5, -1.2){complete}\n\\end{graph}\n%}}}1\n\n\\section{$k$-automata}\nThe $k$-automaton (not a 2-tape automaton or transducer, as stated in\n\\cite{Fogg} page 12, but rather a Moore automaton) is a finite, \ndeterministic and complete automaton with $|\\Delta| = k$, expanded with an \noutput function or exit map.\n\nSo a $k$-automaton is an automaton with states $\\mathcal{S}$. Each state has\n$k$ outgoing branches, labeled $0, \\ldots, k - 1$. Furthermore, there is only\none initial state. Each state also has an output function. For $k$-automata\nwe use the following notation.\n\n\\begin{definition}[$k$-automaton] \\label{def:k-automaton}\nFor $k \\in \\mathbb{N} \\ge 2$ denote by\n\\begin{itemize}\n\\item $\\mathcal{S}$: A finite set of states. There is a unique \n      $\\iota \\in \\mathcal{S}$ called the initial state.\n\\item $\\Delta$: $k$ labels indicated by integers from 0 to $k - 1$.\n\\item $\\mathcal{L}$: The input language, in this case always $\\Delta^*$.\n\\item $\\sigma: S \\to S^k$: The substitution such that \n      $\\sigma(a) = \\sigma_0(a) \\sigma_1(a) \\ldots \\sigma_{k - 1}(a)$ indicates \n      the endpoints of the transitions starting from $a$ with labels \n      $0, 1, \\ldots, k - 1$, respectively.\n\\item $Y$: The output alphabet. We usually take $Y = \\mathcal{S}$.\n\\item $\\varphi$: A function from $\\mathcal{S}$ to $Y$ called the exit map. We\n      usually take $\\varphi =$ Id.\n\\end{itemize}\n\\end{definition}\n\n\\begin{remark} \\label{rem:output}\nNormally, an automaton accepts a string if it is in\na final state after having read the complete input. In this case, the final \nstate results (via $\\varphi$) in an output.\n\\end{remark}\n\n\\begin{remark} \\label{rem:generate_accept}\nNote that we use automata to generate a sequence, not to recognize one as is\nusual in computer science. Further on we shall prove that most of the generated\nsequences can not be recognized by finite automata.\n\\end{remark}\n\n\\begin{example} \\label{ex:ab_star}\n\\begin{eqnarray*}\n&&k = 2\\\\\n&&\\mathcal{S} = \\{a, b\\}, \\iota \\in \\mathcal{S} = \\{a\\}\\\\\n&&\\Delta = \\{0, 1\\}\\\\\n&&\\sigma:\\{a, b\\} \\to \\{a, b\\}^*, \\sigma(a) \\to ab,\n\\sigma(b) \\to ab\\\\\n&&Y = \\{a, b\\}\\\\\n&&\\varphi: \\varphi(a) \\to a, \\varphi(b) \\to b\n\\end{eqnarray*}\nThe automaton is given by the directed graph\n\n% Picture of mod-2 automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{.2} \\bowtext{s1}{s2}{.2}{1}\n  \\dirbow{s2}{s1}{.2} \\bowtext{s2}{s1}{.2}{0}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\\\\\n%}}}1\nThe substitution $\\sigma$ (of constant length 2) has only one fixed point;\\\\\n\\\\\n\\monoit{u = ababababababababababababababababababababababababab\\ldots}\n$= (ab)^\\mathbb{N}$.\\\\\n\\\\\nIf we take the base 2 expansion of an integer (let us say the decimal\nnumber 22) and feed it to the automaton above, the automaton receives the\ndigits 10110 and will be in state $a$ when it starts.\\\\\nAfter reading the first digit, it will be in state $b$, after reading the\nsecond one the automaton will be in state $a$. The table below shows the path\ntaken:\\\\\n\\\\\n\\begin{tabular}{c|c|c|l}\nstate & transition & next state & tail\\\\\n\\hline\n$i=a$ & 1 & $b$ & 0110\\\\\n$b$   & 0 & $a$ & 110\\\\\n$a$   & 1 & $b$ & 10\\\\\n$b$   & 1 & $b$ & 0\\\\\n$b$   & 0 & $a$ &\\\\\n$a$   &   &   &\n\\end{tabular}\\\\\n\\\\\nIt will be clear that this automaton will always reach state $a$ if the last \ndigit is 0 and state $b$ if it is 1, so it maps any integer $n$ to $a$ if and \nonly if $n \\mathrm{\\ mod\\ } 2 = 0$ and to $b$ if and only if \n$n \\mathrm{\\ mod\\ } 2 = 1$.\n\nThus if we feed the binary sequence 0, 1, 10, 11, 100, \\ldots of non-negative \nintegers to the automaton, we will get the sequence $u$.\n\\end{example}\n\nExample \\ref{ex:ab_star} shows a duality between automata and words invariant \nunder substitutions. We shall study this duality in the sequel.\n\n\\subsection{Direct reading}\n\\begin{definition}[Letter-to-letter projection] \\label{def:letter-to-letter}\nConsider a map from a finite alphabet $\\mathcal{A}$ to an other finite alphabet\n$\\mathcal{B}$. This map extends in a natural way (by concatenation) to a map \nfrom $\\mathcal{A}^* \\cup \\mathcal{A}^\\mathbb{N}$ to\n$\\mathcal{B}^* \\cup \\mathcal{B}^\\mathbb{N}$.\n\\end{definition}\n\n\\begin{definition}[Direct reading] \\label{def:direct_reading}\nA sequence $u = (u_n)_{n \\in \\mathbb{N}}$ with values in $Y$ is $k$-automatic \nin direct reading if it can be generated by a $k$-automaton as follows: For \n$n = 0, 1, \\ldots$\n\\begin{itemize}\n\\item let $\\sum_{i=0}^j n_i k^i (n_j \\neq 0)$ be the base $k$ expansion of an\n      integer $n$.\n\\item initialize the automaton and feed it with the sequence \n      $n_j, \\ldots, n_ 1, n_0$, note that the most significant digit is read \n      first.\n\\item put $u_n = \\varphi(a(n))$, if the automaton is in state $a(n)$ after all\n      letters have been read.\n\\end{itemize}\n\\end{definition}\n\n\\begin{theorem} \\label{thm:direct_reading}\nA sequence $u$ is $k$-automatic in direct reading if and only if $u$ is the \nimage of a letter-to-letter projection of a fixed point of a substitution of \nconstant length $k$.\n\\end{theorem} \n\n\\begin{proof}\n$\\Leftarrow$ Let $u$ be a fixed point of a substitution $\\sigma$ of length\n$k$ over the alphabet $\\mathcal{A}$. We construct a $k$-automaton in direct \nreading. Let $\\mathcal{S = A}$. We make a transition from $a$ to $b$ labeled \n$i$ if $b$ occurs in $\\sigma(a)$ at position $i + 1$. Take \n$\\iota \\in \\mathcal{S} = u_0$ as the initial state. Take $\\varphi =$ Id.\nLet $\\sum_{i = 0}^t n_i k^i$ be the $k$-adic expansion of $n$. We start from \n$u(0)$, then go to the $(n_t + 1)$--th letter of $\\sigma(u(0))$, denoted by \n$a_1$, then go to the $(n_{t - 1} + 1)$--th letter of $\\sigma(a_1)$, which is \nalso the $(kn_t + n_{t - 1} + 1)$--th letter of $\\sigma^2(u(0))$, and so on.\nAfter $t$ steps we arrive at the $(n + 1)$--th letter of \n$\\sigma^{t + 1}(u_0)$, which is $u(n)$. We have constructed an automaton that \ngenerates the sequence $u$ in direct reading. If $v$ is the image of a \nletter-to-letter projection $\\varphi: \\mathcal{A} \\to \\mathcal{B}$ of the \nfixed point $u = (u(n))_{n \\in \\mathbb{N}} \\in \\mathcal{A}^\\mathbb{N}$ of a \nsubstitution $\\sigma$ of constant length $k$ defined on the alphabet \n$\\mathcal{A}$. Then $v$ is generated by the same automaton that generated $u$, \nbut with the projection $\\varphi$ as output function.\n\n$\\Rightarrow$ Let $u$ be a sequence generated by a $k$-automaton in direct\nreading. Let $\\mathcal{S}$ be the set of states of the automaton and let\n$f_0, \\ldots, f_{k - 1}$ be the transition maps (hence \n$f_i: \\mathcal{S \\to S}$ maps state $j$ to the state which is reached by \nfollowing transition $i$ from state $j$ for every $j \\in \\mathcal{S}$). Define \nthe substitution of constant length $\\sigma = f_0 \\dots f_{k - 1}$ over \n$\\mathcal{S}$. Let $v$ be the fixed point of $\\sigma$ beginning with the \ninitial state $\\iota$. It is easily checked that the sequence $u$ is the image \nby the output function $\\varphi$ of the fixed point $v$. \n\\end{proof}\n\n\\begin{remark}\nWhen using direct reading we map the initial state $\\iota$ onto itself with \nlabel 0 by default. This is a direct consequence of the existence of the fixed\npoint of a substitution.\n\\end{remark}\n\n\\begin{example}[The Cantor sequence]\nThe Cantor sequence is defined as the invariant word under the substitution: \n$\\sigma: \\sigma(a) \\to aba, \\sigma(b) \\to bbb$. With $a$ as the\ninitial letter, it gives the following fixed point.\\\\\n\\\\\n\\monoit{u = ababbbababbbbbbbbbababbbababbbbbbbbbbbbbbbbbbbbbbbbbb\\ldots}\\\\\n\\\\\nThe following automaton is associated with this\nsubstitution.\n\n% Picture of cantor automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0,2}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){0,1,2}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nLet us denote the set of integers $n$ such that the $(n + 1)$--th letter of the\nCantor sequence is $a$ by $\\mathbb{C}_a$.The automaton above suggests that \n$\\mathbb{C}_a$ is given by\n\\begin{displaymath}\n  \\mathbb{C}_a = \\Big\\{n \\in \\mathbb{N}; n = \\sum_{i \\ge 0} n_i3^i,\n  \\mathrm{\\ with\\ } \\forall(i \\ge 0): n_i \\in \\{0, 2\\}\\Big\\}.\n\\end{displaymath}\nThe following argument shows that this is true. Let \n$n = \\sum_{i = 0}^t n_i 3^i$ with $n_i \\in \\{0, 1, 2\\}$ for all $i$. Consider \nthe mapping $\\tau: \\{0, 1, \\ldots, t\\} \\to \\{a, b\\}$ with \n$\\tau(j) = u(\\sum_{i = 0}^j n_i 3^i)$. By definition of $\\sigma$ we have \n$\\tau(j + 1) = a$ if and only if $\\tau(j) = a$ and $n_{j + 1} \\in \\{0, 2\\}$.\n\nCompare the Cantor fractal with the Cantor word:\n\n% Picture of the Cantor set. {{{1\n\\ \\\\\n\\verb#   0      0.1       0.2      1  |   0     0.1         0.2     1#\\\\\n\\verb#---------------------------------------------------------------#\\\\\n\\verb#   ===========================  |               #\\monoit{a}\\\\\n\\verb#   =========         =========  |      #\\monoit{a} { } { } { } { } { } { }\\monoit{b} { } { } { } { } { } { }\\monoit{a}\\\\\n\\verb#   ===   ===         ===   ===  |   #\\monoit{a { }b { }a { }b { }b { }b { }a { }b { }a}\\\\\n\\verb#   = =   = =         = =   = =  |  #\\monoit{ababbbababbbbbbbbbababbbaba}\n%}}}1\n\\end{example}\n\n\\subsection{Reverse reading}\n\\begin{definition}[$k$-kernel] \\label{def:k-kernel}\nLet $N_k(u)$ be the set of subsequences of the sequence \n$(u(n))_{n \\in \\mathbb{N}}$ defined by:\n\\begin{displaymath}\nN_k(u) = \\{(u(k^ln + r))_{n \\in \\mathbb{N}}; l \\ge 0; 0 \\le r \\le k^l - 1\\}.\n\\end{displaymath}\n\\end{definition}\n\n\\begin{example} \\label{ex:k-kernel}\nThe kernel of the Cantor sequence is given by\\\\\n\\\\\n\\monoit{ababbbababbbbbbbbbababbbababbbbbbbbbbbbbb\\ldots}\n$(l = 0) \\Rightarrow u(3^0 n + 0)_{n \\in \\mathbb{N}}$,\\\\\n\\monoit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ldots}\n$(l = 1) \\Rightarrow u(3^1 n + 1)_{n \\in \\mathbb{N}}$.\\\\\n\\end{example}\n\n\\begin{definition}[Reverse reading] \\label{def:reverse_reading}\nThis definition is analogue to Definition \\ref{def:direct_reading}, but it\nfeeds the sequence $n_0, n_1, \\ldots, n_j$ to the automaton.\n\\end{definition}\n\n\\begin{theorem} \\label{thm:reverse_reading}\nA sequence $u \\in \\mathcal{A}^\\mathbb{N}$ is $k$-automatic in reverse reading \nif and only if the $k$-kernel $N_k(u)$ of the sequence $u$ is finite.\n\\end{theorem}\n\n\\begin{proof}\n$\\Leftarrow$ Suppose the $k$-kernel of a sequence $u$ is finite. Let\n$\\overline{a}_1, \\ldots, \\overline{a}_d$ be the sequences of $N_k(u)$. Take\n$\\mathcal{S} = \\{a_1, \\ldots, a_d\\}$ as the finite set of $d$ states in \nbijection with $N_k(u)$ with $a_1$ as initial state. For any integer \n$r \\in \\{0, \\ldots, k - 1\\}$, define the map $r : \\mathcal{S} \\to \\mathcal{S}$ \nby associating the state corresponding with  \n$(\\overline{a}_i(kn + r))_{n \\in \\mathbb{N}}$ to $a_i$. Let \n$n = \\sum_{i = 0}^j n_i k^i$ be the base $k$ expansion of an integer $n$, with \n$n_j \\ne 0$. We define the map $n$ from\n$\\mathcal{S}$ to $\\mathcal{S}$ by $n(a_i) = n_j(n_{j - 1}( \\ldots (n_0(a_i))))$\nif $n \\ne 0$, otherwise the map 0 is the identity. It follows by induction that\n$r(a_i)$ is in bijection with $(u(k^{j + 1} n + r))_{n \\in \\mathbb{N}}$. \nHence if $r(a_1) = s(a_1)$ then $u_r = u_s$, the first terms of the\ntwo corresponding subsequences. Now we define the output \nfunction $\\varphi$ by $\\varphi(a_i) = u_r$ if \n$r(a_1) = a_i$. Therefore the sequence $u$ is generated by the automaton \nin reverse reading.\n\n$\\Rightarrow$ Suppose $A$ is a finite $k$-automaton with initial state $\\iota$\nwhich generates $u$. The subsequence $(u(k^ln + r))_{n \\ge 0}$, where\n$l \\ge 0$ and $0 \\le r < k^l$, is generated by $A$ with the initial state\n$\\overline{r}(\\iota)$, where $\\overline{r}$ is the word of $l$ letters\nobtained by concatenating in front of the base $k$ expansion of $r$ as many\nzeros as necessary. Because $A$ has a finite number of states, there is only a\nfinite set of subsequences. \n\\end{proof}\n\nThe proof of Theorem \\ref{thm:reverse_reading} gives a method for constructing \na $k$-automaton in reverse reading corresponding to a given sequence $u$ if $u$ \nis $k$-automatic in reverse reading. Take the $k$-kernel of $u$ and let \n$\\mathcal{S}$ be in bijection with the sequences in the kernel. Now add \ntransitions from state $a$ to state $b$ labeled $r$ \n($r \\in \\{0, 1, \\ldots, k - 1\\}$) if the sequence associated with $b$ is the \nsubsequence $(\\overline{a}(kn + r))_{n \\in \\mathbb{N}}$. Make $a_0$ the initial\nstate and make all states that have incoming transitions (starting from that \ninitial state) final states.\n\n\\begin{example} \\label{ex:reverse_reading}\nThe fixed point of the substitution $a \\to ab$, $b \\to ab$,\nwhich is $abababab\\ldots$ has as 2-kernel\\\\\n\\\\\n\\monoit{ababababababababababababababababababa\\ldots}\n$= (ab)^\\mathbb{N} = (u(2^0 n + 0))_{n \\in \\mathbb{N}}$,\\\\\n\\monoit{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ldots}\n$= a^\\mathbb{N} = (u(2^1 n + 0))_{n \\in \\mathbb{N}}$,\\\\\n\\monoit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ldots}\n$= b^\\mathbb{N} = (u(2^1 n + 1))_{n \\in \\mathbb{N}}$.\\\\\n\\end{example}\n\nBy taking $l = 0$, we find $(2^0 n + 0)_{n \\in \\mathbb{N}}$. For $l = 1$ we\nobtain two sequences: $(2^1 n + 0)_{n \\in \\mathbb{N}}$ and\n$(2^1 n + 1)_{n \\in \\mathbb{N}}$. This is the complete $k$-kernel, because all \nstep sizes are of the form $k^l$. So taking larger step sizes will only yield \nthe second or third sequence.\n\n% Picture of mod-2 automaton in reverse reading. {{{1\n\\begin{graph}(0, 3)(-4, -1)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-1, 0) \\nodetext{s1}(0, 0){$\\iota$}\n  \\roundnode{s2}(-2, 1.5)\n    \\nodetext{s2}(0, -0.22){\\circle{0.8}} \\nodetext{s2}(0, 0){$a$}\n  \\roundnode{s3}(0, 1.5)\n    \\nodetext{s3}(0, -0.22){\\circle{0.8}} \\nodetext{s3}(0, 0){$b$}\n\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{0}\n  \\diredge{s1}{s3} \\edgetext{s1}{s3}{1}\n  \\dirloopedge{s2}{50}(-1, 0) \\freetext(-3.6, 1.5){0,1}\n  \\dirloopedge{s3}{50}(1, 0) \\freetext(1.6, 1.5){0,1}\n\n  \\freetext(-1, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n% Picture of mod-2 automaton in direct reading again. {{{1\n\\begin{graph}(0, 3)(-10, -2)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{.2} \\bowtext{s1}{s2}{.2}{1}\n  \\dirbow{s2}{s1}{.2} \\bowtext{s2}{s1}{.2}{0}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nThe left figure is the automaton that generates $u$ in reverse reading. Note \nthat $\\iota$ is not a final state, hence $\\mathcal{S} \\ne \\mathcal{A}$. The \nfinal states are marked with an internal circle.\n\nThe right figure is the automaton that generates $u$ in direct reading. Hence\nthe generating automata can be essentially different.\n\n\\subsection{Equivalence between direct- and reverse reading}\n\\begin{theorem} \\label{thm:direct_is_reverse}\nA sequence is $k$-automatic in direct reading if and only if it is \n$k$-automatic in reverse reading.\n\\end{theorem}\n\n\\begin{proof}\nTheorem \\ref{thm:direct_reading} states that a $k$-automaton in direct reading \nis in bijection with a substitution of constant length. Theorem \n\\ref{thm:reverse_reading} states that a $k$-automaton in reverse reading is in \nbijection with a finite $k$-kernel.\n\nIt remains to prove that a substitution of constant length results in a finite \n$k$-kernel.\n\n$\\Rightarrow$ Define $\\sigma_i(a) : \\mathcal{A \\to A}$, which associates the\nletter $a$ with the $i + 1$-th letter of its image in $\\sigma$. We have \n$\\sigma_i(u(n)) = u(kn + i)$, for any integer $n$ and for any \n$i \\in \\{0, \\ldots, k - 1\\}$. Let $l \\ge 0$, $0 \\le r \\le k^l - 1$. Write\n$r =  \\sum_{i = 0}^{l - 1} r_i k^i$, where $0 \\le r_i \\le k - 1$. We thus have\n$u(k^l n + r) = \\sigma_{r_0}(\\sigma_{r_1}( \\ldots (\\sigma_{r_{l - 1}}(u(n)))))$.\nThere are at most $|\\mathcal{A}|^{|\\mathcal{A}|}$ of these maps, so the\n$k$-kernel is finite.\n\n$\\Leftarrow$ Suppose the $k$-kernel $N_k(u)$ of the sequence $u$ is finite.\nLet $\\overline{a}_1, \\ldots, \\overline{a}_d$ be the sequences in $N_k(u)$. Let\n$U = (U(n))_{n \\in \\mathbb{N}}$ be the sequence with values in $\\mathcal{A}^d$\ndefined by $U(n) = (\\overline{a}_1(n), \\ldots, \\overline{a}_d(n))$. We \nconstruct a substitution $\\sigma$ of constant length $k$ defined on \n$\\mathcal{A}^d$ with $U$ as a fixed point. As $N_k(u)$ is stable by the maps\n$\\mathcal{A}_r$, where \n$\\mathcal{A}_r(v(n))_{n \\in \\mathbb{N}} = (v(kn + r))_{n \\in \\mathbb{N}}$, then\nfor any $0 \\le r \\le k - 1$, $U(kn + r) = U(km + r)$, if $U(n) = U(m)$. We\ndefine for $0 \\le r \\le k - 1$, $\\sigma_r : \\mathcal{A}^d \\to \\mathcal{A}^d$,\n$U(n) \\to U(nk +r)$ if there exists and $n$ such that \n$(a_1, \\ldots, a_r) = U(n)$ and otherwise \n$(a_1, \\ldots, a_r) \\to (0, \\ldots, 0)$. Hence the sequence $U$ is the fixed\npoint of the substitution of constant length \n$\\sigma: a \\to \\sigma_0(a) \\ldots \\sigma_{k - 1}(a)$ and the sequence $u$ is\nthe image of $U$ by the projection of the first coordinate of $\\mathcal{A}^d$ \nto $\\mathcal{A}$.\n\\end{proof}\n\n\\begin{definition}\nBecause of Theorem \\ref{thm:direct_is_reverse} we can define $k$-automaticity\nas one of the following equivalences\n\\begin{itemize}\n\\item $k$-automaton in direct reading.\n\\item $k$-automaton in reverse reading.\n\\item a finite $k$-kernel. \n\\item the fixed point of a substitution of constant length.\n\\end{itemize}\n\\end{definition}\n\n\\begin{corollary} \\label{cor:homomorphism}\nIf we take a $k$-automatic sequence and apply some homomorphism to it, it will \nremain $k$-automatic.\n\\end{corollary}\n\n\\begin{proof}  \nThis is a direct result of Theorem \\ref{thm:direct_reading} and Theorem\n\\ref{thm:direct_is_reverse}.\n\\end{proof}\n\n\\begin{example}\\label{ex:homomorphism}\\end{example}\n% Picture of mod-2 automaton with exit map. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$/0}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$/1}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{.2} \\bowtext{s1}{s2}{.2}{1}\n  \\dirbow{s2}{s1}{.2} \\bowtext{s2}{s1}{.2}{0}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nThis automaton has an output alphabet $Y$ different from $\\mathcal{S}$. We \nhave $Y = \\{0, 1\\}$ and we do not use Id$_{\\{a, b\\}}$ as the exit map, but\n$\\varphi(a) \\to 0, \\varphi(b) \\to 1$. This is denoted by\n$a/0, b/1$ in the automaton.\n\n\\section{Examples}\n\\subsection{The Prouhet-Thue-Morse sequence}\nLet us look at the following substitution: $\\sigma: \\sigma(a) \\to ab$,\n$\\sigma(b) \\to ba$. With $a$ as the initial letter, it gives the\nfollowing fixed point:\\\\\n\\\\\n\\monoit{u = abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbab\\ldots}\\\\\n\\\\\nThe following 2-automaton is associated with this substitution:\\\\\n% Picture of Prouhet-Thue-Morse automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{.2} \\bowtext{s1}{s2}{.2}{1}\n  \\dirbow{s2}{s1}{.2} \\bowtext{s2}{s1}{.2}{1}\n  \\dirloopedge{s2}{50}(1, 0) \\freetext(1.6, 0){0}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nNote that the final state is $a$ when the number of ones in the input word\nis even, and $b$ otherwise. Hence this automaton generates $u$ both in direct\nand in reverse reading.\n\nThe automaton above induces the following partitions of $\\mathbb{N}$; \n\\begin{eqnarray*}\n\\mathbb{N}_a &=& \\{0, 3, 5, 6, 9, 10, 12, 15, \\ldots\\}\\\\\n\\mathbb{N}_b &=& \\{1, 2, 4, 7, 8, 11, 13, 14, \\ldots\\}.\n\\end{eqnarray*}\nLet us define $S_2(n)$ as the sum of the dyadic digits:\n\\begin{displaymath}\nS_2(n) = \\sum_{i \\ge 0}n_i,\\mathrm{\\ if\\ }\nn = \\sum_{i \\ge 0}n_i2^i, n_i \\in \\{0, 1\\}.\n\\end{displaymath}\nIt is obvious from the automaton that the sets $\\mathbb{N}_a$ and \n$\\mathbb{N}_b$ are defined by\n\\begin{eqnarray*}\nx \\in \\mathbb{N}_a \\Leftrightarrow S_2(n) \\mathrm{\\ is\\ even},\nx \\in \\mathbb{N}_b \\Leftrightarrow S_2(n) \\mathrm{\\ is\\ odd}.\n\\end{eqnarray*}\n\nThe 2-kernel of this sequence is\\\\\n\\\\\n\\monoit{abbabaabbaababbabaababbaabbabaabbaababbaabbab\\ldots} $(l = 0)$,\\\\\n\\monoit{baababbaabbabaababbabaabbaababbaabbabaabbaaba\\ldots} $(l = 1, r = 1)$.\\\\\n\\\\\nSo the 2-kernel consists of both fixed points.\n\n\\subsection{The Rudin-Shapiro sequence}\nDefine $u(n) = (-1)^{r_n}$, where $r_n$ is the number of occurrences of\nconsecutive `11' in the binary representation of $n$. It does not matter if we \napply direct or reverse reading. The corresponding automaton is given by\n\n% Picture of Rudin-Shapiro automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){\\bs$a$/+1\\es}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){\\bs$b$/+1\\es}\n  \\roundnode{s3}(2, 0)  \\nodetext{s3}(0, 0){\\bs$c$/-1\\es}\n  \\roundnode{s4}(4, 0)  \\nodetext{s4}(0, 0){\\bs$d$/-1\\es}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{0.2} \\bowtext{s1}{s2}{0.2}{1}\n  \\dirbow{s2}{s1}{0.2} \\bowtext{s2}{s1}{0.2}{0}\n  \\dirbow{s2}{s3}{0.2} \\bowtext{s2}{s3}{0.2}{1}\n  \\dirbow{s3}{s4}{0.2} \\bowtext{s3}{s4}{0.2}{0}\n  \\dirbow{s3}{s2}{0.2} \\bowtext{s3}{s2}{0.2}{1}\n  \\dirloopedge{s4}{50}(1, 0) \\freetext(5.6, 0){0}\n  \\dirbow{s4}{s3}{0.2} \\bowtext{s4}{s3}{0.2}{1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nThus the Rudin-Shapiro sequence is the invariant word under the substitution\n$a \\to ab, b \\to ac, c \\to db, d \\to dc$\nstarting with $a$ and with the indicated output function.\n\n\\subsection{The Baum-Sweet sequence}\nThe Baum-Sweet sequence $(u_n)_{n \\in \\mathbb{N}}$ with values in the alphabet\n$\\{0, 1\\}$ is defined by:\n\n\\vbox{\\begin{eqnarray*}\nu_n &=& 0 \\mathrm{\\ if\\ the\\ dyadic\\ development\\ of\\ } n\n          \\mathrm{\\ contains\\ at\\ least\\ one\\ odd\\ string\\ of\\ 0's},\\\\\n    &=& 1 \\mathrm{\\ if\\ not.}\n\\end{eqnarray*}}\nObviously the automaton does not depend on the way of reading. It is given by\n\n% Picture of Baum-Sweet automaton. {{{1\n\\begin{graph}(0, 4)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$/1}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$/1}\n  \\roundnode{s3}(2, 0)  \\nodetext{s3}(0, 0){$c$/0}\n  \\roundnode{s4}(4, 0)  \\nodetext{s4}(0, 0){$d$/0}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n  \\dirbow{s2}{s3}{0.2} \\bowtext{s2}{s3}{0.2}{0}\n  \\dirloopedge{s2}{50}(0, 1) \\freetext(0, 1.6){1}\n  \\dirbow{s3}{s2}{0.2} \\bowtext{s3}{s2}{0.2}{0}\n  \\diredge{s3}{s4} \\edgetext{s3}{s4}{1}\n  \\dirloopedge{s4}{50}(1, 0) \\freetext(5.6, 0){0,1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\nIt will be clear that the automaton above generates the sequence when we use\n$\\varphi(a) = \\varphi(b) = 1$ and $\\varphi(c) = \\varphi(d) = 0$.\n\nThe automaton corresponds to the substitution $\\sigma$ given by\n$\\sigma(a) \\to ab, \\sigma(b) \\to cb$,\n$\\sigma(c) \\to bd, \\sigma(d) \\to dd$.\n\n\\subsection{A divisibility automaton}\nGiven two integers $k$ and $d$ greater or equal to two, can an automaton \ndecide only from its $k$-adic development whether any $n \\in \\mathbb{N}$ is\ndivisible by $d$? Let $\\mathcal{S} = \\{0, 1, \\ldots, d - 1\\}$ and let $u$ be the\nperiodic sequence:\n\\begin{displaymath}\n  u = 01\\ldots(d - 1)01\\ldots(d - 1)\\ldots\n\\end{displaymath}\nWe need to construct a $k$-automaton that generates $u$. To do this we need to\nfind a substitution $\\sigma$ of constant length $k$ such that $u$ is the fixed\npoint of $\\sigma$. We can do that by cutting $u$ in words of length $k$ and\nrewriting $u$ as\n$u = \\sigma(0)\\sigma(1)\\ldots\\sigma(d - 1)\\sigma(0)\\sigma(1)\\ldots\\sigma(d - 1)\\ldots$\n\nFor the case $k = 2, d = 5$, the substitution looks as follows:\n\n\\vbox{\\begin{eqnarray*}\n  \\sigma(0) &\\to& 01\\\\\n  \\sigma(1) &\\to& 23\\\\\n  \\sigma(2) &\\to& 40\\\\\n  \\sigma(3) &\\to& 12\\\\\n  \\sigma(4) &\\to& 34\n\\end{eqnarray*}}\nThis gives the following automaton:\\\\\n% Picture of mod-5 automaton. {{{1\n\\begin{graph}(0, 3)(-4, -0.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$0$}\n  \\roundnode{s2}(-1, 1.5) \\nodetext{s2}(0, 0){$1$}\n  \\roundnode{s3}(0, 0) \\nodetext{s3}(0, 0){$2$}\n  \\roundnode{s4}(1, 1.5) \\nodetext{s4}(0, 0){$3$}\n  \\roundnode{s5}(2, 0) \\nodetext{s5}(0, 0){$4$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{1}\n  \\diredge{s2}{s3} \\edgetext{s2}{s3}{0}\n  \\dirbow{s2}{s4}{0.2} \\bowtext{s2}{s4}{0.2}{1}\n  \\diredge{s3}{s5} \\edgetext{s3}{s5}{0}\n  \\diredge{s3}{s1} \\edgetext{s3}{s1}{1}\n  \\dirbow{s4}{s2}{0.2} \\bowtext{s4}{s2}{0.2}{0}\n  \\diredge{s4}{s3} \\edgetext{s4}{s3}{1}\n  \\diredge{s5}{s4} \\edgetext{s5}{s4}{0}\n  \\dirloopedge{s5}{50}(1, 0) \\freetext(3.6, 0){1}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\\\\\n%}}}1\n\\\\\nThus $n = (n_t n_{t - 1} \\ldots n_0)_2$ is divisible by 5 if and only if 0 is\nthe final state after the consecutive transitions $n_t, n_{t - 1}, \\ldots n_0$.\nMoreover, if $j$ is the final state, then $j$ is the rest of $n$ after dividing\nby 5.\n\n\\section{General automata}\n\\subsection{Regular languages}\n\\begin{definition}[Regular language] \\label{def:regular_language}\nA language $\\mathcal{L}$ is called \\emph{regular} if there exists a finite \nautomaton that accepts $\\mathcal{L}$. \n\\end{definition}\n\nNote that we do not talk about $k$-automata, but about automata in general.\n\n\\begin{lemma}[The pumping lemma for regular languages] \\label{lem:pumping}\nLet $\\mathcal{L}$ be an infinite regular language. Then there exists an \n$n \\in \\mathbb{N}, n \\ge 1$, such that for all $z \\in \\mathcal{L}$, if \n$|z| > n$ there are words $r, s, t$ such that\n\\begin{itemize}\n\\item $z = rst$\n\\item $s \\ne \\epsilon$\n\\item $|rs| \\le n$\n\\item $r s^i t \\in \\mathcal{L}$ for all $i \\in \\mathbb{N}$ \n\\end{itemize}\n\\end{lemma}\n\n\\begin{proof}\nLet $A = (\\mathcal{S}, \\Delta, \\delta, I, F)$ be a finite automaton which \naccepts $\\mathcal{L}$. Let $K = \\mathcal{L}(A)$, let $n = |\\mathcal{S}|$, and \nlet trans be a sequence of transitions. $\\mathcal{S} \\ne \\epsilon$ because \n$\\mathcal{L}$ is infinite, and therefore $n \\ge 1$.\n\nConsider $z \\in K$ with $m = |z| > n$. If such a word does not exist, we are\nfinished. We look at the path $\\pi$ in $A$ corresponding with $z$, say\n$\\pi = (q_0, a_1, q_1)(q_1, a_2, q_2)$ $\\ldots(q_{m - 1}, a_m, q_m)$ with\n$q_0 \\in I$ and $q_m \\in F$, so $z = \\mathrm{trans}(\\pi) = a_1a_2\\ldots a_m$.\nBecause $m > n$, there exist $k$ and $j$ with $0 \\le k < j \\le n$ and\n$q_k = q_j$. We now split the path into three parts; $\\pi = \\pi_1 \\pi_2 \\pi_3$,\nwith\n\\begin{eqnarray*}\n  \\pi_1 &=& (q_0, a_1, q_1) \\ldots (q_{k - 1}, a_k, q_k),\\\\\n  \\pi_2 &=& (q_k, a_{k + 1}, q_{k + 1}) \\ldots (q_{j - 1}, a_j, q_j),\\\\\n  \\pi_3 &=& (q_j, a_{j + 1}, q_{j + 1}) \\ldots (q_{m - 1}, a_m, q_m).\n\\end{eqnarray*}\nLet $r = \\mathrm{trans}(\\pi_1), s = \\mathrm{trans}(\\pi_2),\n     t = \\mathrm{trans}(\\pi_3)$\n\nBecause $\\pi_2$ is a cycle in the automaton, from $q_k$ to $q_j = q_k$, there\nexists for all $i \\in \\mathbb{N}$ a path $\\pi_1 \\pi_2^i \\pi_3$ from $q_0$ to\n$q_m$. So $\\mathrm{trans}(\\pi_1 \\pi_2^i \\pi_3) \\in K$. Because trans is a\nhomomorphism, we can say:  $\\mathrm{trans}(\\pi_1 \\pi_2^i \\pi_3) =\n\\mathrm{trans}(\\pi_1) \\mathrm{trans}(\\pi_2)^i \\mathrm{trans}(\\pi_3) = r s^i t$.\nSo $r s^i t \\in K$ for all $i \\in \\mathbb{N}$.\n\nNote that $|s| = |\\mathrm{trans}(\\pi_2)| = j - k > 0$, so $s \\ne \\epsilon$,\nand that $|rs| = |\\mathrm{trans}(\\pi_1 \\pi_2)| = j \\le n$. \n\\end{proof}\n\n% Picture of general automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){\\bs$q_0$\\es}\n  \\roundnode{s2}(0, 0) \\nodetext{s2}(0, 0){\\bS$q_k=q_j$\\eS}\n  \\roundnode{s3}(2, 0)\n    \\nodetext{s3}(0, -0.22){\\circle{0.8}} \\nodetext{s3}(0, 0){\\bs$q_m$\\es}\n\n  \\diredge{s1}{s2} \\edgetext{s1}{s2}{$r$}\n  \\dirloopedge{s2}{50}(0, 1) \\freetext(0, 1.6){$s$}\n  \\diredge{s2}{s3} \\edgetext{s2}{s3}{$t$}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\n%}}}1\n\n\\begin{remark}\nIn a similar way, but by choosing $j$ maximal and $k$ minimal, we may prove \nthe statement with the condition $|rs| \\le n$ replaced with $|rt| \\le n$.\n\\end{remark}\n\nWe can use the pumping lemma to prove that a certain language is not regular.\n\n\\begin{example} \\label{ex:pumping}\n$\\mathcal{L} = \\{0^m1^m | m \\in \\mathbb{N}\\}$ is not regular.\n\\end{example}\n\n\\begin{proof}\nSuppose $\\mathcal{L}$ is regular. We can then find a number $n \\ge 1$ that\nconforms to the pumping lemma. Consider the word $z = 0^n 1^n$. We see that \n$z \\in \\mathcal{L}$ and $|z| = 2n > n$. So we can write $z = r s t$ with \n$|r s| \\le n$ and $s \\ne \\epsilon$. Hence $rs$ consists of only zeros, so \n$s = 0^k$ for a certain $k$. Now take $i = 0$. According to the pumping lemma\n$r s^0 t = r t \\in \\mathcal{L}$, but $r t = 0^{n - k} 1^n$ with $n - k < n$, so\n$rt \\notin \\mathcal{L}$. This is a contradiction, so our assumption was false\nand $\\mathcal{L}$ is not regular. \n\\end{proof}\n\n\\begin{theorem} \\label{thm:not_regular}\nIf $\\mathcal{L}(u)$ is regular and $u$ is minimal, then $u$ is periodic with\nperiod $|s|$.\n\\end{theorem}\n\n\\begin{proof}\nSuppose $\\mathcal{L}(u)$ is regular. Let $z \\in \\mathcal{L}$. By Theorem \n\\ref{lem:pumping}, we can write $z = r s t$ such that $r s^i t \\in \\mathcal{L}$ \nfor every $i$. We have $|r s^i t|_1 = |r|_1 + i|s|_1 + |t|_1$. It follows that\n$|s| |r s^i t|_1 - |s|_1 |r s^i t| = |s| |r|_1 + |s| |t|_1 - |r| |s|_1 - \n|t| |s|_1$ is independent of $i$. Hence $\\lim_{i \\to \\infty} \n\\frac{|r s^i t|_1}{|r s^i t|} - \\frac{|s|_1}{|s|} = 0$. Since $r s^i t$ would\nbe a subword of $u$ for every $i$ and $u$ is minimal, it would follow from\nProposition 5.1.10 \\cite{Fogg} page 105 that the frequency of 1 in $u$ is \n$\\frac{|s|_1}{|s|} \\in \\mathbb{Q}$. \n\\end{proof}\n\n\\begin{corollary} \\label{cor:ptm_not_regular}\nThe language $\\mathcal{L}(u)$ defined by the Prouhet-Thue-Morse sequence $u$ is\nnot regular.\n\\end{corollary}\n\n\\begin{proof} \nBy Proposition 5.1.2 \\cite{Fogg} page 102, $u$ is minimal and not periodic.\nTheorem \\ref{thm:not_regular} states that those sequences are not regular.\n\\end{proof}\n\n\\begin{corollary} \\label{cor:sturmian_not_regular}\nIf $u$ is a Sturmian sequence, then $\\mathcal{L}(u)$ is not regular.\n\\end{corollary}\n\n\\begin{proof} \nBy Theorem 6.1.8 \\cite{Fogg} a Sturmian sequence is minimal and by Theorem \nProposition 6.1.10 \\cite{Fogg} the frequency of 1 is irrational. Theorem \n\\ref{thm:not_regular} states that those sequences are not regular.\n\\end{proof}\n\n\\subsection{The Fibonacci sequence}\nWe consider substitutions of non-constant length. They will result in \nnon-complete automata, and therefore will only accept a subset of $\\Delta^*$.\\\\\n\\\\\nThe Fibonacci sequence is $u$ is the fixed point of the substitution \n$\\sigma: \\sigma(a) \\to ab, \\sigma(b) \\to a$, hence\\\\\n\\\\\n\\monoit{u = abaababaabaababaababaabaababaabaababaababaabaababaaba\\ldots}\\\\\n\\\\\nThe 2-kernel of this sequence contains the words:\\\\\n\\\\\n\\monoit{abaababaabaababaababaabaababaabaababaababaabaababaaba\\ldots}\\\\\n\\\\\n\\monoit{aabbaabbaaabaaabaaabbaabbaaabaaabaaabba\\ldots}\\\\\n\\monoit{baaabaaabbaabbaabbaaabaaabbaabbaabbaaab\\ldots}\\\\\n\\\\\n\\monoit{ababaaaaaabababababa\\ldots}\\\\\n\\monoit{ababababababaaaaaaba\\ldots}\\\\\n\\monoit{bababababaaaabababab\\ldots}\\\\\n\\monoit{aaaabababababababaaa\\ldots}\\\\\n\\monoit{}\\\\\n\\\\\nThis suggests that the 2-kernel of this sequence is infinite. Its cardinality\ncertainly exceeds $|\\mathcal{A}|^{|\\mathcal{A}|}$, \nso the sequence is not 2-automatic and because this is the smallest \nsubstitution that generates the sequence, it is not $k$-automatic at all. The \nassociated automaton is\\\\\n% Picture of Fibonacci automaton. {{{1\n\\begin{graph}(0, 3)(-4, -1.5)\n  \\graphnodecolour{1}\n  \\graphnodesize{1}\n  \\roundnode{s1}(-2, 0) \\nodetext{s1}(0, 0){$a$}\n  \\roundnode{s2}(0, 0)  \\nodetext{s2}(0, 0){$b$}\n\n  \\dirloopedge{s1}{50}(-1, 0) \\freetext(-3.6, 0){0}\n  \\dirbow{s1}{s2}{.2} \\bowtext{s1}{s2}{.2}{1}\n  \\dirbow{s2}{s1}{.2} \\bowtext{s2}{s1}{.2}{0}\n\n  \\freetext(-2, -0.7){$\\Uparrow$}\n\\end{graph}\\\\\n%}}}1\nNote that this is almost the same automaton that generates $(ab)^{\\mathbb{N}}$,\nand that it only lacks one branch. We immediately see that this is not a \n$k$-automaton, for it is not total. Moreover, if we feed this automaton with \nthe base 2 expansion of $n \\in \\mathbb{N}$, it will halt (or crash) when \nwe feed it a string which has two consecutive ones as a substring (another\nreason to conclude that this substitution is not $k$-automatic). However, our \nintuition is right, the automaton generates the Fibonacci sequence, but since \nit is not a $k$-automaton, we can not feed it with the base 2 expansion of all\nthe nonnegative integers. In this particular case we know which expansion to \ntake, viz. the Fibonacci expansion of the nonnegative integers; in general this\nis not known.\n\n\\begin{definition}[Zeckendorf expansion]\nLet $(F_n)_{n \\in \\mathbb{N}}$ be the sequence of integers defined by $F_0 = 1,\nF_1 = 2$ and for any integer $n > 1, F_{n + 1} = F_{n - 1} + F_n$.\n\nIf $n = \\sum_{i = 0}^k n_i F_i$ with $n_k = 1, n_i \\in \\{0, 1\\}$ and \n$\\forall (i < k): n_i n_{i + 1} = 0$, we say that \nFib$(n) = n_k n_{k - 1} \\ldots n_0 \\in \\{0, 1\\}^{k + 1}$ is the\n\\emph{Zeckendorf expansion} or \\emph{Fibonacci representation} of the integer \n$n$.\n\\end{definition}\n\nThis gives the expansions\\\\ \\vbox{\n\\begin{verbatim}\n  0 = 0\n  1 = 1\n  2 = 10\n  3 = 100\n  4 = 101\n  5 = 1000\n   ...\n\\end{verbatim}}\n\n\\begin{theorem} \\label{thm:fibonacci_numbersystem}\nEvery nonnegative integer $n$ can be written in a unique way as \n$n = \\sum_{i \\ge 0} n_i F_i$ with $n_i \\in \\{0, 1\\}$ and\n$\\forall (i \\ge 0): n_i n_{i + 1} = 0$\n\\end{theorem}\n\n\\begin{proof} By induction over $n$.\\\\\nIt is true for $n = 0$. Suppose it holds for $n < F_k$. If \n$F_k \\le n < F_{k + 1}$ then by $F_{k + 1} = F_k + F_{k - 1}$ we have \n$n - F_k < F_{k - 1}$. Because we can write $n - F_k$ by our hypothesis as\n$n - F_k = \\sum_{i = 0}^{k - 2} n_i F_i$ with $n_i n_{i - 1} = 0$ for\n$i = 1, \\ldots, k - 2$, we can write $n = F_k + \\sum_{i = 0}^{k - 2} n_i F_i$ \nsuch that there are no two consecutive ones.\\\\\n\\\\\nIt remains to prove that the Fibonacci representation is unique.\\\\\nLet $n \\in \\mathbb{N}$ be the smallest number for which there is more than one\nrepresentation. Choose $k$ such that $F_k \\le n < F_{k + 1}$ and write\n$n = n_k n_{k - 1} \\ldots n_0$ (the standard representation) and\n$n = n'_l n'_{l - 1} \\ldots n'_0$ (another representation satisfying \n$n'_i n'_{i - 1} = 0$ for $i = 1, \\ldots, k - 2$). Then $n_k = 1$ and $l \\le k$.\nIf $n_k = n'_k$ then $n - F_k$ would have two distinct representations as well.\nHence $n'_k = 0$.\nThe maximum number of length $k - 1$ we can represent is \n$F_{k - 1} + F_{k - 3} + F_{k - 5} + \\ldots$, which is equal to $F_k - 1$ and \ntherefore smaller than $n$. \n\\end{proof}\n\nSince this system can be used to enumerate $n \\in \\mathbb{N}$ and it has the\nproperty that no two ones succeed each other, this is the mapping we are\nlooking for.\\\\\nPut\n\\begin{eqnarray*}\n  \\mathbb{N}_a &=& \\{n \\in \\mathbb{N}, \\mathrm{Fib}(n) \\in \\{0, 1\\}^* 0\\} = \n                   \\{0, 2, 3, 5, 7, 8, 10, 11, 13, 15, \\ldots\\}\\\\\n  \\mathbb{N}_b &=& \\{n \\in \\mathbb{N}, \\mathrm{Fib}(n) \\in \\{0, 1\\}^* 1\\} =\n                   \\{1, 4, 6, 9, 12, 14, 17, 19, 22, 25, \\ldots\\}\n\\end{eqnarray*}\n\\\\\nConsider the first few substitutions of $\\sigma$,\\\\\n\\\\\n$\\sigma^0(a) =$ \\monoit{a}\\\\\n$\\sigma^1(a) =$ \\monoit{ab}\\\\\n$\\sigma^2(a) =$ \\monoit{aba}\\\\\n$\\sigma^3(a) =$ \\monoit{abaab}\\\\\n$\\sigma^4(a) =$ \\monoit{abaababa}\n\n\\begin{theorem} \\label{thm:fibonacci_fixedpoint}\n$\\sigma^n = \\sigma^{n - 1} \\sigma^{n - 2}, n \\in \\mathbb{N}, n \\ge 2$\n\\end{theorem}\n\n\\begin{proof} By induction over $n$. Initial step:\n$\\sigma^2 = aba = \\sigma^1 \\sigma^0$.\\\\\nInduction step: We have \n$\\sigma^{n + 1} = \\sigma(\\sigma^n) = \\sigma(\\sigma^{n - 1} \\sigma^{n - 2}) = \n\\sigma(\\sigma^{n - 1}) \\sigma(\\sigma^{n - 2}) = \\sigma^n \\sigma^{n - 1}$.\n\\end{proof}\n\nWe write in column $j$ the Fibonacci expansion of $j$ from above to below.\\\\\n\\\\\n\\monoit{a b a ab aba abaab \\ldots}\\\\\n\\verb#0 1 1 11 111 11111#\\\\\n\\verb#    0 00 000 00000#\\\\\n\\verb#      01 001 00011#\\\\\n\\verb#         010 00100#\\\\\n\\verb#             01001#\\\\\n\\\\\nWe see that the Fibonacci expansions of the integers $n$ with \n$F_k \\le n < F_{k + 1}$ are all of length $k$. We deduce from the definition of\nthe Fibonacci expansion strings that end with a 0 can be extended in two ways: \n$\\ldots 0 \\to \\ldots 00, \\ldots 01$, and strings that end with a 1 can only be \nextended in one way: $\\ldots 1 \\to \\ldots 10$.\n\n\\begin{thebibliography}{XX}\n\\bibitem{Fogg} Fogg, N. Pytheas. Substitutions is Dynamics, Arithmetics and \n               Combinatorics, Springer Verlag, 2002.\n\\end{thebibliography}\n\\end{document}\n", "meta": {"hexsha": "53cb6d4f99253f27f19e4b49c734f90a70c09cef", "size": 41519, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/k-automata/paper.tex", "max_stars_repo_name": "jfjlaros/numauto", "max_stars_repo_head_hexsha": "0f634cd88b9f784bebee4733cc1c325913a71381", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/k-automata/paper.tex", "max_issues_repo_name": "jfjlaros/numauto", "max_issues_repo_head_hexsha": "0f634cd88b9f784bebee4733cc1c325913a71381", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/k-automata/paper.tex", "max_forks_repo_name": "jfjlaros/numauto", "max_forks_repo_head_hexsha": "0f634cd88b9f784bebee4733cc1c325913a71381", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1537717602, "max_line_length": 126, "alphanum_fraction": 0.6504251066, "num_tokens": 16259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529716, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.43997073755394966}}
{"text": "\\documentclass[12pt]{report} \n%\\usepackage[pdftex]{hyperref}\n\\usepackage{amsmath} % advanced math\n\\usepackage{amssymb}\n\\usepackage{ulem}\n\\usepackage{graphicx,color}\n%\\usepackage{subfigure}\n\\usepackage{verbatim} % multi-line comments\n\\usepackage[backref, colorlinks=false, pdftitle={20110125}, \npdfauthor={Ben Payne, Alexey Yamilov}, pdfsubject={meeting}, \npdfkeywords={localization, gain, transmission, random, media}]{hyperref}\n%\\usepackage{hyperref} % hyper links\n%I'd like to use \"backpageref\" instead of linking back to section numbers\n\\setlength{\\topmargin}{-.5in}\n\\setlength{\\textheight}{9in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\textwidth}{6.5in}\n\\newcounter{fignum}\n\\newcommand{\\fignum}{\\stepcounter{fignum}\\arabic{fignum}}\n\\begin{document}\n\\section{Gaussian and SI}\n\\begin{tabular}{c c | c c}\nGaussian (``CGS'') & & SI & \\\\\ncm, gram, second & & m, kg, second &\\\\\\hline\n&&&\\\\\n$\\vec{\\nabla} \\times \\vec{E} = -\\frac{1}{c} \\frac{\\partial \\vec{B}}{\\partial t}$ & $\\vec{\\nabla} \\times \\vec{H} = \\frac{1}{c} \\frac{\\partial \\vec{D}}{\\partial t} + \\frac{4\\pi}{c}\\vec{J}$ & $\\vec{\\nabla} \\times \\vec{E} = -\\frac{1}{c} \\frac{\\partial \\vec{B}}{\\partial t}$ & $\\vec{\\nabla} \\times \\vec{H} = \\frac{\\partial \\vec{D}}{\\partial t} + \\vec{J}$ \\\\\n&&&\\\\\n$\\vec{\\nabla} \\cdot \\vec{D} = 4 \\pi \\rho $ & $\\vec{\\nabla} \\cdot \\vec{B}=0$ & $\\vec{\\nabla} \\cdot \\vec{D} = \\rho $ & $\\vec{\\nabla} \\cdot \\vec{B}=0$ \\\\\n&&&\\\\\\hline\n&&&\\\\\n$\\vec{F} = q \\left(\\vec{E} + \\frac{1}{c}\\vec{v}\\times \\vec{B}\\right)$ & & $\\vec{F} = q \\left(\\vec{E} + \\vec{v}\\times \\vec{B}\\right)$ & \\\\ \n&&&\\\\\\hline\n&&&\\\\\n$\\vec{D} \\equiv \\vec{E} + 4\\pi \\vec{P}$ & $\\vec{H} \\equiv \\vec{B}-4\\pi \\vec{\\mu}$ & $\\vec{D} \\equiv \\epsilon_0\\ \\vec{E} + \\vec{P}$ & $ \\vec{H} = \\frac{1}{\\mu_0} \\vec{B} - \\vec{\\mu}$ \\\\\n\\end{tabular}\n\n\\ \\\\\n\nConversion factors between Gaussian, SI. Usage: $X_{Gaussian} = k_X X_{SI}$\n\n\\ \\\\\n\\begin{tabular}{c c c}\n$k_{\\vec{D}} = \\sqrt{4\\pi/\\epsilon_0}$ & $k_{\\vec{H}} = \\sqrt{4 \\pi \\mu_0}$ & $k_{\\rho} = k_{\\vec{J}} = k_{\\vec{P}} = 1/\\sqrt{4 \\pi \\epsilon_0}$\\\\\n&& \\\\\n$k_{\\vec{E}} = \\sqrt{4 \\pi \\epsilon_0}$ & $k_{\\vec{B}} = \\sqrt{4 \\pi /\\mu_0}$ & $k_{\\mu} = \\sqrt{\\mu_0/(4 \\pi)}$ \\\\\n\\end{tabular}\n\n\\ \\\\\n\nFor dimensions, $k_{length} = 100$. $k_{mass}=1000$.\n\\ \\\\\n\n\n\\begin{equation}\n \\epsilon_0 \\mu_0 = \\frac{1}{c^2}\n\\end{equation}\n\\begin{equation}\n \\mu_0 = 4 \\pi \\cdot 10^{-7}\n\\end{equation}\n\n\\section{basics}\n\\begin{equation}\n E = h\\ f = \\frac{h\\ c}{\\lambda}  \n\\end{equation}\n\\begin{equation}\n F = -G \\frac{m_1\\ m_2}{r^2}\n\\end{equation}\nExplain the following momentum relation physically\n\\begin{equation}\n p = \\hbar k =mv\n\\end{equation}\nExplain the following relation between flux and velocity physically\n\\begin{equation}\n \\vec{J} = n \\vec{v}\n\\end{equation}\n\\begin{equation}\n KE = \\frac{1}{2} m v^2 \\quad \\quad \\quad PE = mgh\n\\end{equation}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "5409011f9fb8a6fe5aad0466cae945f18f29979b", "size": 2832, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "basic_essentials.tex", "max_stars_repo_name": "bhpayne/physics_equations_reference", "max_stars_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-09-05T00:38:21.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-05T00:38:21.000Z", "max_issues_repo_path": "basic_essentials.tex", "max_issues_repo_name": "bhpayne/physics_equations_reference", "max_issues_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "basic_essentials.tex", "max_forks_repo_name": "bhpayne/physics_equations_reference", "max_forks_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1204819277, "max_line_length": 352, "alphanum_fraction": 0.6193502825, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7772998714925403, "lm_q1q2_score": 0.4399661346703256}}
{"text": "\\subsection{Instance models}\n\\label{subsec:formalisations:ecore_formalisation:instance_models}\nAn instance model represents an instance of a type model. In other words, the metamodel of an instance model is its type model. Because of our definitions of type models, this means that the metametamodel of an instance model is the Ecore metamodel.\n\nAn instance model consists of a set of objects, which have a corresponding class they instantiate and an optional identifier. All objects are an instance of a specific class and are therefore typed by that class and its superclasses. Furthermore, an instance model also specifies the values for each field of an object. Its type determines the fields present for each object. Finally, the instance model specifies a set of default values, which assigns a value to each of the named constants from the type model ($Constant_{Tm}$), allowing to assign default values to fields.\n\nAs with the type model and type definitions, there is a cyclic dependency between instance models and values. In the same manner, the solution is set to be the smallest solution to the set of equations for the instance model and values.\n\nThe suffix $Im$ is used when the definition of something depends on any instance model $Im$, which itself depends on the definition of any type model $Tm$.\n\n\\begin{defin}[Instance model]\n\\label{defin:formalisations:ecore_formalisation:instance_models:instance_model}\nFor a type model $Tm$,\n\\begin{equation*}\n    Tm = \\langle Class, Enum, UserDataType, Field, \\mathrm{FieldSig}, EnumValue, Inh, Prop, Constant, \\mathrm{ConstType} \\rangle\n\\end{equation*}\na single instance model $Im$ is defined as\n\\begin{equation*}\n    Im = \\langle Object, \\mathrm{ObjectClass}, \\mathrm{ObjectId}, \\mathrm{FieldValue}, \\mathrm{DefaultValue} \\rangle\n\\end{equation*}\nwith\n\\begin{itemize}\n    \\item $Object$ is the set of objects (class instances) in $Im$.\n    \\item $\\mathrm{ObjectClass}: Object \\Rightarrow Class_{Tm}$ is the function that maps each object in $Im$ to a class.\n    \\item $\\mathrm{ObjectId}: Object \\Rightarrow Name$ is the injective partial function that maps each object in $Im$ to an identifier.\n    \\item $\\mathrm{FieldValue}: (Object \\times Field_{Tm}) \\Rightarrow Value_{Im}$ is the partial function between each $Field_{Tm}$ of an $Object_{Im}$ and a $Value_{Im}$ (see \\cref{defin:formalisations:ecore_formalisation:instance_models:values}).\n    \\item $\\mathrm{DefaultValue}: Constant_{Tm} \\Rightarrow Value_{Im}$ is the function that assigns a value to each constant in the corresponding type model $Tm$.\n\\end{itemize}\nwhere\n\\begin{itemize}\n    \\item $\\forall ( o, n ), ( o', n' ) \\in ObjectId: n = n' \\Longrightarrow o = o'$.\n    \\item $\\forall o \\in Object, f \\in Field_{Tm}: ( o, f ) \\in \\mathrm{dom}\\ FieldValue \\Longleftrightarrow ObjectClass(o) \\sqsubseteq_{Tm} \\mathrm{class}(f)$.\n\\end{itemize}\n\n\\isabellelref{instance_model}{Ecore.Instance_Model}\n\\end{defin}\n\nPlease note that $\\mathrm{ObjectId}$ is injective because each object must have a unique identifier. It is partial because an object does not necessarily need an identifier: The internal object identifiers (the elements of the set $Object$) are already unique. The $\\mathrm{ObjectId}$ function is for adding an explicit identifier that is not generated internally.\n\nThe $\\mathrm{FieldValue}$ function maps a combination of an object and field to a value. Please note that the function is partial because not every combination of object and field is valid. The domain of this function is therefore made explicit by the constraints of the definition. Please note that this function is not injective: Values can be shared across objects and do not have to be unique.\n\nAn important function is the $\\mathrm{DefaultValue}$ function, which is defined on an instance model rather than a type model. This definition has been chosen to accommodate for default values that reference another object. In order to reference another object, the possible object references need to be known. These object references are only known on the instance level, as the type level does not define any objects.\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/instance_model_example.pdf}\n        \\caption{Instance model based on Ecore notation}\n    \\end{subfigure}\n    \n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\begin{align*}\n            Object_{Im} =\\ & \\{ \n                1, 2, 3, 4, 5, 6\n            \\}\\\\\n            \\mathrm{ObjectClass}_{Im} =\\ & \\{ \n                ( 1, .\\type{House} ),\n                ( 2, .\\type{Room} ),\n                ( 3, .\\type{Room} ), \n                ( 4, .\\type{Room} ),\n                ( 5, .\\type{Renter} ),\n                ( 6, .\\type{Renter} ),\n            \\}\\\\\n            \\mathrm{ObjectId}_{Im} =\\ & \\{ \n                ( 1, .\\type{SmallHouse} ),\n                ( 2, .\\type{1} ),\n                ( 3, .\\type{2} ), \n                ( 4, .\\type{3} ),\n                ( 5, .\\type{John} ),\n                ( 6, .\\type{Jane} )\n            \\}\\\\\n            \\mathrm{FieldValue}_{Im} =\\ & \\Big\\{ \n                \\Big( \\big( 1, ( .\\type{House}, \\type{name} ) \\big), \\big[ \\type{string}, \\text{``Small House''} \\big] \\Big),\\\\&\n                \\Big( \\big( 1, ( .\\type{House}, \\type{rooms} ) \\big), \\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ], [ \\type{obj}, 4 ] \\big\\rangle \\big] \\Big),\\\\&\n                \\Big( \\big( 2, ( .\\type{Room}, \\type{number} ) \\big), \\big[ \\type{int}, 1 \\big] \\Big),\\\n                \\Big( \\big( 2, ( .\\type{Room}, \\type{renter} ) \\big), \\big[ \\type{obj}, 5 \\big] \\Big),\\\\&\n                \\Big( \\big( 3, ( .\\type{Room}, \\type{number} ) \\big), \\big[ \\type{int}, 2 \\big] \\Big),\n                \\Big( \\big( 3, ( .\\type{Room}, \\type{renter} ) \\big), \\big[ \\type{obj}, 5 \\big] \\Big),\\\\&\n                \\Big( \\big( 4, ( .\\type{Room}, \\type{number} ) \\big), \\big[ \\type{int}, 3 \\big] \\Big),\n                \\Big( \\big( 4, ( .\\type{Room}, \\type{renter} ) \\big), \\big[ \\type{obj}, 6 \\big] \\Big),\\\\&\n                \\Big( \\big( 5, ( .\\type{Person}, \\type{name} ) \\big), \\big[ \\type{string}, \\text{``John Doe''} \\big] \\Big),\\\\&\n                \\Big( \\big( 5, ( .\\type{Person}, \\type{age} ) \\big), \\big[ \\type{int}, 24 \\big] \\Big),\\\\&\n                \\Big( \\big( 5, ( .\\type{Renter}, \\type{payment\\_interval} ) \\big), \\big[ \\type{enum}, ( .\\type{PaymentInterval}, \\type{MONTH} ) \\big] \\Big),\\\\&\n                \\Big( \\big( 5, ( .\\type{Renter}, \\type{rents} ) \\big), \\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ] \\big\\rangle \\big] \\Big),\\\\&\n                \\Big( \\big( 6, ( .\\type{Person}, \\type{name} ) \\big), \\big[ \\type{string}, \\text{``Jane Doe''} \\big] \\Big),\\\\&\n                \\Big( \\big( 6, ( .\\type{Person}, \\type{age} ) \\big), \\big[ \\type{int}, 23 \\big] \\Big),\\\\&\n                \\Big( \\big( 6, ( .\\type{Renter}, \\type{payment\\_interval} ) \\big), \\big[ \\type{enum}, ( .\\type{PaymentInterval}, \\type{MONTH} ) \\big] \\Big),\\\\&\n                \\Big( \\big( 6, ( .\\type{Renter}, \\type{rents} ) \\big), \\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 4 ] \\big\\rangle \\big] \\Big)\n            \\Big\\}\\\\\n            \\mathrm{DefaultValue}_{Im} =\\ & \\Big\\{ \n                \\Big( .\\type{Constant}.\\type{PaymentInterval}.\\type{Month}, \\big[ \\type{enum}, ( .\\type{PaymentInterval}, \\type{MONTH} ) \\big] \\Big)\n            \\Big\\}\n        \\end{align*}\n        \\caption{Formal definition of the instance model}\n    \\end{subfigure}\n    \\caption{Example of an instance model corresponding with \\cref{defin:formalisations:ecore_formalisation:instance_models:instance_model}}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:instance_model_example}\n\\end{figure}\n\nAn example model is represented by \\cref{fig:formalisations:ecore_formalisation:instance_models:instance_model_example}. It is based on the type model from the example in \\cref{fig:formalisations:ecore_formalisation:type_models:type_model_example}.\nIt shows 2 instantiations of the $\\type{Renter}$ class: the $\\type{John}$ and $\\type{Jane}$ objects. Furthermore, there are three instantiations of the $\\type{Room}$ class ($\\type{1}$, $\\type{2}$ and $\\type{3}$) and one instantiation of the $\\type{House}$ class ($\\type{SmallHouse}$). The text after the colon in the header of each object represents the $ObjectClass_{Im}$ of each object. Additionally, the text preceding the colon represents the $ObjectId_{Im}$. The $\\type{Renter}$ objects have values assigned for all fields, including the fields of their superclasses. This also holds for the $\\type{Room}$ and $\\type{House}$ objects. For attributes, the assignment to a field name represents the value of a field. For relations, a named arrow between two objects represents the value of the field. The name of the arrow represents the field name, and multiple arrows with the same name represent multiple values for the same field.\n\nNote that the objects from the example are represented by elements from $\\mathbb{N}^+$. The conceptual model does not give a concrete specification for elements in the $Object_{Im}$ set, but by convention objects (or in graph terms, nodes) are represented by numbers.\n\nFor each instance model, a set of possible values is defined by the values for all data types, the possible enumerations of the type model and the objects in the instance model. Each value has a symbol that defines its type, allowing the values in an instance model to be typed by the types in the type model. This symbol also allows values with identical content but a different type to be separated. For example, any value in $\\mathbb{Z} \\cap \\mathbb{R}$ (which can be of type $\\type{integer}$ or $\\type{real}$). Container values aggregate multiple values, which are typed by container types.\n\n\\begin{defin}[Values]\n\\label{defin:formalisations:ecore_formalisation:instance_models:values}\nGiven any instance model $Im$, the set of values is $Value_{Im}$.\n\nThe set of values is then defined as\n\\begin{equation*}\n    Value_{Im} = AtomValue_{Im} \\cup ContainerValue_{Im}\n\\end{equation*}\nwith\n\\begin{itemize}\n    \\item $AtomValue_{Im} = ClassValue_{Im} \\cup LiteralValue \\cup (\\{ \\type{enum} \\} \\times EnumValue_{Tm}) \\cup (\\{ \\type{data} \\times \\mathbb{S}\\})$\n    \\item $LiteralValue = (\\{ \\type{bool} \\} \\times \\mathbb{B}) \\cup (\\{ \\type{int} \\} \\times \\mathbb{Z}) \\cup (\\{ \\type{real} \\} \\times \\mathbb{R}) \\cup (\\{ \\type{string} \\} \\times \\mathbb{S})$\n    \\item $ClassValue_{Im} = \\{ \\type{obj} \\} \\times (Object_{Im} \\cup { \\type{nil} })$\n    \\item $ContainerValue_{Im} = \\{ \\type{setof}, \\type{bagof}, \\type{seqof}, \\type{ordof} \\} \\times Value_{Im}^*$ (where $Value_{Im}^*$ allows containers to recursively contain other containers.)\n\\end{itemize}\n\nThe set of values is recursively defined as the smallest solution of the given set of equations for $Value_{Im}$ and $ContainerValue_{Im}$. Furthermore, elements of the set $Value_{Im}$ are written using square brackets, e.g. $[\\type{string}, \\text{``Example''}]$ or $[\\type{setof}, \\langle [\\type{int}, 4], [\\type{int}, 8] \\rangle]$.\n\n\\isabellelref{Value}{Ecore.Instance_Model}\n\\end{defin}\n\nFor custom data types, the value is an element from the set $\\mathbb{S}$. In Ecore, custom data types can be made serializable, which means a value from $\\mathbb{S}$ can be stored for the custom data type. Thus, the value for a custom data type can be stored in the model, but it cannot be further interpreted.\n\nContainers attributed as $\\type{setof}$ or $\\type{ordof}$ are considered to have unique values, whereas containers attributed as $\\type{bagof}$ or $\\type{seqof}$ are not. This means for example that a tuple with two or more identical values is not a valid value for a container attributed as $\\type{setof}$ or $\\type{ordof}$, see also \\cref{defin:formalisations:ecore_formalisation:instance_models:valid_type_values}.\n\nAdditionally, the values of a container attributed as $\\type{bagof}$ or $\\type{setof}$ are considered unordered, and $\\type{seqof}$ or $\\type{ordof}$ ordered. This affects the equivalency of containers, as defined in \\cref{defin:formalisations:ecore_formalisation:instance_models:value_equivalency}.\n\nIn the example, the set of atomic values that are assigned consists of\n\\begin{align*}\n    \\{&\n        [ \\type{string}, \\text{``Small House''} ], \n        [ \\type{string}, \\text{``John Doe''} ], \n        [ \\type{string}, \\text{``Jane Doe''} ],\\\\&\n        [ \\type{int}, 1 ], \n        [ \\type{int}, 2 ], \n        [ \\type{int}, 3 ], \n        [ \\type{int}, 24 ], \n        [ \\type{int}, 23 ],\\\\&\n        [ \\type{enum}, ( .\\type{PaymentInterval}, \\type{MONTH} ) ]\\\\&\n        [ \\type{obj}, 5 ],\n        [ \\type{obj}, 6 ]\n    \\}\n\\end{align*}\nNote that only the $\\type{Renter}$ objects are in an atomic assigned value for the field $(.\\type{Room}, \\type{renter})$, as it is the only field that references a single object. All other relations in the type model are container types, and as such all the objects are contained in a container value as well. For example, the container value for the $\\type{rooms}$ field of the $\\type{House}$ object is $\\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ], [ \\type{obj}, 4 ] \\big\\rangle \\big]$ (in no particular order, as the relation is of a set container type).\n\nEach instance model also defines an equivalence relation for values. This relation allows the comparison of aggregate values and explicitly defines equivalency for unordered container values.\n\n\\begin{defin}[Value equivalency]\n\\label{defin:formalisations:ecore_formalisation:instance_models:value_equivalency}\nTwo values are equivalent $(\\equiv_{Im}\\: \\subseteq Value_{Im} \\times Value_{Im})$ if both the type is identical and the actual value content is equivalent. It is defined as the smallest reflexive relation between values and the relations defined by the rules given next.\n\nFor atomic values equivalence is defined as\n\\begin{mathpar}\n    \\inferrule{v_1 \\in Value_{Im} \\\\ v_2 \\in Value_{Im} \\\\ v_1 = v_2}{v_1 \\equiv_{Im} v_2}\n\\end{mathpar}\n\nSequences and ordered sets are equivalent if the values in their tuples are pairwise equivalent.\n\\begin{mathpar}\n    \\inferrule[Sequence container equivalency]{c_1 = \\big[ \\type{seqof}, \\langle v_1, \\dotsc, v_n \\rangle \\big] \\\\ c_2 = \\big[ \\type{seqof}, \\langle u_1, \\dotsc, u_n \\rangle \\big] \\\\ v_1 \\equiv_{Im} u_1, \\dotsc, v_n \\equiv_{Im} u_n}{c_1 \\equiv_{Im} c_2}\n\\end{mathpar}\n\\begin{mathpar}\n    \\inferrule[Ordered set container equivalency]{c_1 = \\big[ \\type{ordof}, \\langle v_1, \\dotsc, v_n \\rangle \\big] \\\\ c_2 = \\big[ \\type{ordof}, \\langle u_1, \\dotsc, u_n \\rangle \\big] \\\\ v_1 \\equiv_{Im} u_1, \\dotsc, v_n \\equiv_{Im} u_n}{c_1 \\equiv_{Im} c_2}\n\\end{mathpar}\n\nSets and bags are equivalent if there exists a bijective function which maps elements from one set/bag\nto the other, such that the mapped values are equivalent.\n\\begin{mathpar}\n    \\inferrule[Set container equivalency]{c_1 = \\big[ \\type{setof}, \\langle v_1, \\dotsc, v_n \\rangle \\big] \\\\ c_2 = \\big[ \\type{setof}, \\langle u_1, \\dotsc, u_n \\rangle \\big] \\\\ \\exists f: \\{1, \\dotsc, n\\} \\bij \\{1, \\dotsc, n\\}: v_i \\equiv_{Im} u_{f(i)}}{c_1 \\equiv_{Im} c_2}\n\\end{mathpar}\n\\begin{mathpar}\n    \\inferrule[Bag container equivalency]{c_1 = \\big[ \\type{bagof}, \\langle v_1, \\dotsc, v_n \\rangle \\big] \\\\ c_2 = \\big[ \\type{bagof}, \\langle u_1, \\dotsc, u_n \\rangle \\big] \\\\ \\exists f: \\{1, \\dotsc, n\\} \\bij \\{1, \\dotsc, n\\}: v_i \\equiv_{Im} u_{f(i)}}{c_1 \\equiv_{Im} c_2}\n\\end{mathpar}\n\n\\isabellelref{value_equiv}{Ecore.Instance_Model}\n\\end{defin}\n\nIn the example, the value $\\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 2 ], [ \\type{obj}, 3 ] \\big\\rangle \\big]$ would thus be equivalent to $\\big[ \\type{setof}, \\big\\langle [ \\type{obj}, 3 ], [ \\type{obj}, 2 ] \\big\\rangle \\big]$, as the ordering does not matter for `$\\type{setof}$' container types.\n\nFor each type in $Type_{Tm}$, there exists a set of values from $Value_{Im}$ which is considered \\textit{valid}. This is\ndefined by a relation $Valid_{Im} \\subseteq (Type_{Tm} \\times Value_{Im})$ which defines a tuple for each valid value given a type.\n\n\\begin{defin}[Valid type values]\n\\label{defin:formalisations:ecore_formalisation:instance_models:valid_type_values}\nThe $Valid_{Im}$ set contains tuples which indicate what values are valid for a given type, which is defined by\n\\begin{equation*}\n    Valid_{Im} \\subseteq (Type_{Tm} \\times Value_{Im})\n\\end{equation*}\n\nAn element $[ T, v ] \\in Valid_{Im}$ may be written as\n\\begin{mathpar}\n    \\inferrule{\\ }{v:_{Im} T}\n\\end{mathpar}\n\nThe contents of the $Valid_{Im}$ set is then defined as follows:\n\nData type values:\n\\begin{mathpar}\n    \\inferrule{v \\in \\mathbb{B}}{[ \\type{bool}, v ]:_{Im} \\type{boolean}}\n    \\and\n    \\inferrule{v \\in \\mathbb{Z}}{[ \\type{int}, v ]:_{Im} \\type{integer}}\n    \\and\n    \\inferrule{v \\in \\mathbb{R}}{[ \\type{real}, v ]:_{Im} \\type{real}}\n    \\and\n    \\inferrule{v \\in \\mathbb{S}}{[ \\type{string}, v ]:_{Im} \\type{string}}\n\\end{mathpar}\n\nClass values:\n\\begin{mathpar}\n    \\inferrule{ObjectClass_{Im}(o) = c \\\\ !c \\sqsubseteq_{Tm} t \\\\ t \\in ClassType_{Tm}}{[ \\type{obj}, o ]:_{Im} t}\n    \\and\n    \\inferrule{t \\in \\{ \\type{nullable} \\} \\times Class_{Tm}}{[ \\type{obj}, \\type{nil} ]:_{Im} t}\n\\end{mathpar}\n\nEnumeration values:\n\\begin{mathpar}\n    \\inferrule{( ename, eval ) \\in EnumValue_{Tm} \\\\ ename \\in Enum_{Tm}}{[ \\type{enum}, ( ename, eval ) ]:_{Im} ename}\n\\end{mathpar}\n\nUser-defined data type values:\n\\begin{mathpar}\n    \\inferrule{v \\in \\mathbb{S} \\\\ t \\in UserDataType_{Tm}}{[ \\type{data}, v ]:_{Im} t}\n\\end{mathpar}\n\nContainer values:\n\\begin{mathpar}\n    \\inferrule{v_1:_{Im} T, \\dotsc, v_n:_{Im} T \\\\ \\langle v_1, \\dotsc, v_n \\rangle\\ \\mathrm{distinct} \\\\ [ \\type{setof}, T ] \\in Container_{Tm}}{[ \\type{setof}, \\langle v_1, \\dotsc, v_n \\rangle ]:_{Im} [ \\type{setof}, T ]}\n    \\and\n    \\inferrule{v_1:_{Im} T, \\dotsc, v_n:_{Im} T \\\\ [ \\type{bagof}, T ] \\in Container_{Tm}}{[ \\type{bagof}, \\langle v_1, \\dotsc, v_n \\rangle ]:_{Im} [ \\type{bagof}, T ]}\n    \\and\n    \\inferrule{v_1:_{Im} T, \\dotsc, v_n:_{Im} T \\\\ \\langle v_1, \\dotsc, v_n \\rangle\\ \\mathrm{distinct} \\\\ [ \\type{ordof}, T ] \\in Container_{Tm}}{[ \\type{ordof}, \\langle v_1, \\dotsc, v_n \\rangle ]:_{Im} [ \\type{ordof}, T ]}\n    \\and\n    \\inferrule{v_1:_{Im} T, \\dotsc, v_n:_{Im} T \\\\ [ \\type{seqof}, T ] \\in Container_{Tm}}{[ \\type{seqof}, \\langle v_1, \\dotsc, v_n \\rangle ]:_{Im} [ \\type{seqof}, T ]}\n\\end{mathpar}\n\n\\isabellelref{Valid}{Ecore.Instance_Model}\n\\end{defin}\n\nThe validity of an instance model depends on the multiplicity of field values. The valid multiplicities depend on the types and field signatures in the corresponding type model. As a consequence, a valid multiplicity also requires the type of the value to be valid. The multiplicity is of most influence for container values, as they can contain an arbitrary amount of values.\n\n\\begin{defin}[Multiplicity validity]\n\\label{defin:formalisations:ecore_formalisation:instance_models:multiplicity_validity}\nA field value $( ( object, field ), value ) \\in FieldValue_{Im}$ has a valid multiplicity if the following property holds:\n\\begin{multline*}\n    value:_{Im} \\mathrm{type}_{Tm}(field) \\land value = [ t, \\langle v_1, \\dotsc, v_n \\rangle ] \\in ContainerValue_{Im} \\Longrightarrow\\\\ \\mathrm{lower}_{Im}(field) \\leq n \\leq \\mathrm{upper}_{Im}(field)\n\\end{multline*}\n\nThis may be written as $\\mathrm{validMul}_{Im}\\big((( object, field ), value)\\big)$.\n\n\\isabellelref{validMul}{Ecore.Instance_Model}\n\\end{defin}\n\n\\begin{figure}\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/multiplicities/type_model.pdf}\n        \\caption{Example type model}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:type_model}\n    \\end{subfigure}\n    \n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/multiplicities/invalid_lower.pdf}\n        \\caption{Invalid instance model: cardinality of $\\type{rel}$ too low}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:invalid_lower}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/multiplicities/valid.pdf}\n        \\caption{Valid instance model: cardinality of $\\type{rel}$ within bounds}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:valid}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/multiplicities/invalid_upper.pdf}\n        \\caption{Invalid instance model: cardinality of $\\type{rel}$ too high}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:invalid_upper}\n    \\end{subfigure}\n    \\caption{Examples of valid and invalid multiplicities}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example}\n\\end{figure}\n\nThe examples shown in \\cref{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example} show different multiplicities in instance models. More specifically, \\cref{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:type_model} shows a type model that specifies a multiplicity of $1..2$ for the $\\type{rel}$ relation. \\cref{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:invalid_lower} and \\cref{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:invalid_upper} show two instance models that have an invalid multiplicity (too low and too high respectively), whereas \\cref{fig:formalisations:ecore_formalisation:instance_models:multiplicity_example:valid} shows an instance model with correct multiplicity (an alternative correct instance model could have only a single instance of class $\\type{B}$).\n\nIn order to simplify reasoning over assignments of values, the $\\mathrm{edgeCount}$ and $\\mathrm{edge}$ operators are defined. These operators specify the number of relations (and the existence thereof) between any two objects.\n\n\\begin{defin}[Value edges]\n\\label{defin:formalisations:ecore_formalisation:instance_models:value_edges}\nLet $a, b \\in Object_{Im}$ and $r \\in Field_{Tm}$ where $r \\in fields_{Tm}(\\mathrm{ObjectClass}_{Im}(a))$. Furthermore, we define $\\mathrm{containerCount}_{Im}(a, r, b)$ as\n\\begin{equation*}\n    \\mathrm{containerCount}_{Im}(a, r, b) = \\big|\\big\\{ i \\in \\mathbb{N} \\mid \\big( (a, r), \\big[ t, \\langle v_1, \\dotsc, v_n \\rangle \\big] \\big) \\in \\mathrm{FieldValue}_{Im} \\land v_i = [ \\type{obj}, b ] \\big\\}\\big|\n\\end{equation*}\n\nThen $\\mathrm{edgeCount}_{Im}(a, r, b)$ is defined as\n\\begin{equation*}\n    \\mathrm{edgeCount}_{Im}(a, r, b) = \n    \\begin{cases}\n        0, & \\begin{aligned} \n            \\text{if } &\\mathrm{type}_{Tm}(r) \\not\\in Container_{Tm} \\\\&\\land \\big( (a, r), [ \\type{obj}, b ] \\big) \\not\\in \\mathrm{FieldValue}_{Im}\n        \\end{aligned}\\\\\n        1, & \\begin{aligned} \n            \\text{if } &\\mathrm{type}_{Tm}(r) \\not\\in Container_{Tm} \\\\&\\land \\big( (a, r), [ \\type{obj}, b ] \\big) \\in \\mathrm{FieldValue}_{Im}\n        \\end{aligned}\\\\\n        \\mathrm{containerCount}_{Im}(a, r, b), & \\text{otherwise}\n    \\end{cases}\n\\end{equation*}\n\\isabellelref{edgeCount}{Ecore.Instance_Model}\n\nThe $\\mathrm{edge}_{Im}(a, r, b)$ predicate is defined as\n\\begin{equation*}\n    \\mathrm{edge}_{Im}(a, r, b) = \\mathrm{edgeCount}_{Im}(a, r, b) \\geq 1\n\\end{equation*}\n\\isabellelref{edge}{Ecore.Instance_Model}\n\\end{defin}\n\nAs previously mentioned, the properties specified in a type model must be satisfied by the instance model in order for it to be valid. For each property, there is a satisfaction formula defined, which must hold for a given instance model for that instance model to be valid. The following definition specifies such a formula for each possible property in a type model.\n\n\\begin{defin}[Property satisfaction]\n\\label{defin:formalisations:ecore_formalisation:instance_models:property_satisfaction}\nGiven an instance model $Im$ and a type model $Tm$, a property $p \\in Prop_{Tm}$ can be satisfied, written\nas $Im \\models p$, if the satisfaction formula holds for $p$.\n\n\\begin{itemize}\n    \\item The abstract property $[ \\type{abstract}, c ]$ is satisfied by some instance model $Im$ if none of the objects in $Im$ is typed by class $c$.\n    \n    Formally, the satisfaction formula for $Im \\models [ \\type{abstract}, c ]$ is defined as:\n    \\begin{equation*}\n        \\nexists o \\in Object_{Im}: \\mathrm{ObjectClass}_{Im}(o) = c\n    \\end{equation*}\n\n    \\item The containment property $[ \\type{containment}, r ]$ is satisfied for an instance model $Im$ when any object in $Im$ that is the target for a containment relation is contained by no more than one object, and there are no cycles in the instance model given the containment values.\n    \n    Let $CR_{Tm} = \\{r \\mid r \\in Rel_{Tm} \\land [ \\type{containment}, r ] \\in Prop_{Tm} \\}$ be the set of all containment relations in a type model $Tm$. The satisfaction formula for $Im \\models [ \\type{containment}, r ]$ is then defined as:\n    \\begin{align*}\n        \\forall o \\in\\ &Object_{Im}\\!: \\big|\\big\\{ \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\mid \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\in \\mathrm{FieldValue}_{Im} \\land [ \\type{obj}, o ] = f\\!v \\land f\\!\\!f \\in CR_{Tm} \\big\\}\\big| \\leq 1 \\\\&\n        \\land \\big\\{ (f\\!o, f\\!v) \\mid \\big( ( f\\!o, f\\!\\!f ), f\\!v \\big) \\in \\mathrm{FieldValue}_{Im} \\land f\\!\\!f \\in CR_{Tm} \\big\\} \\text{ is acyclic}\n    \\end{align*}\n    \n    \\item The identity property $[ \\type{identity}, c, A ]$. is satisfied for an instance model $Im$, when for each pair of objects of class $c$, the values for at least one of the attributes in $A$ is different.\n    \n    Formally, the satisfaction formula for $Im \\models [ \\type{identity}, c, A ]$ is defined as:\n    \\begin{align*}\n        \\forall o, o' \\in\\ &Object_{Im}\\!: \\mathrm{ObjectClass}_{Im}(o) = c \\land \\mathrm{ObjectClass}_{Im}(o') = c \\\\&\\land \\forall a \\in A\\!: \\mathrm{FieldValue}_{Im}(( o, a )) \\equiv_{Im} \\mathrm{FieldValue}_{Im}(( o', a )) \\\\&\\Longrightarrow o = o'\n    \\end{align*}\n    \n    \\item The keyset property $[ \\type{keyset}, r, A ]$ is satisfied for an instance model $Im$ when for each object containing relation $r$, each pair of objects referenced by $r$ has a different set of values for the attributes in $A$. In other words, for each such pair, there is at least one value for the attributes in $A$ that is different for both objects.\n    \n    The satisfaction formula for $Im \\models [ \\type{keyset}, r, A ]$ is defined as:\n    \\begin{align*}\n        \\forall o, o', p \\in\\ &Object_{Im}\\!: r \\in \\mathrm{fields}_{Tm}(\\mathrm{ObjectClass}_{Im}(p))\\\\&\n        \\land \\mathrm{edge}_{Im}(p, r, o) \\land \\mathrm{edge}_{Im}(p, r, o')\\\\&\n        \\land \\forall a \\in A\\!: \\mathrm{FieldValue}_{Im}(( o, a )) \\equiv_{Im} \\mathrm{FieldValue}_{Im}(( o', a )) \\\\& \\Longrightarrow o = o'\n    \\end{align*}\n    \n    \\item The opposite property $[ \\type{opposite}, r, r' ]$ is satisfied for an instance model $Im$ when for each object $o$ with a value for $r$, the referenced objects by $r$ have a value for $r'$, which references object $o$. In other words: each object referenced by $r$ must also have a reference $r'$ that references the source object that defined $r$.\n    \n    Formally, the satisfaction formula for $Im \\models [ \\type{opposite}, r, r' ]$ given an instance is defined as:\n    \\begin{align*}\n        \\forall o, o' \\in Object_{Im}\\!: \\mathrm{edgeCount}_{Im}(o, r, o') = \\mathrm{edgeCount}_{Im}(o', r', o)\n    \\end{align*}\n\\end{itemize}\n\n\\isabellelref{property_satisfaction}{Ecore.Instance_Model}\n\\end{defin}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/invalid_abstract.pdf}\n    \\caption{Model not satisfying the $\\type{abstract}$ property.}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:properties:abstract}\n\\end{figure}\n\n\\cref{fig:formalisations:ecore_formalisation:instance_models:instance_model_example} shows an example of an instance model that satisfies the $[ \\type{abstract}, \\type{Person} ]$ property, as no direct instantiations of the $\\type{Person}$ class exist. On the other hand, \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:abstract} shows an instance model that does not satisfy the property, as the $\\type{Person}$ class has been instantiated (by the object $\\type{Jane}$).\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.35\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/containment/type_model.pdf}\n        \\caption{Example type model with two containment relations}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:containment:type_model}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/containment/invalid.pdf}\n        \\caption{Model not satisfying the containment property}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:containment:invalid}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/containment/valid.pdf}\n        \\caption{Model satisfying the containment property}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:containment:valid}\n    \\end{subfigure}\n    \\caption{Examples of the $\\type{containment}$ property.}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:properties:containment}\n\\end{figure}\n\n\\cref{fig:formalisations:ecore_formalisation:instance_models:properties:containment:type_model} shows a type model that defines two containment relations, in opposite direction. The instance model given in \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:containment:invalid} does not satisfy the satisfaction formula for the containment property, as there exists a cycle of containment relations. This is corrected in the instance model in \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:containment:valid}, where such a cycle does not exist (and each object is containment by at most one other object).\n\n\\begin{figure}[p]\n    \\centering\n    \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/invalid_identity.pdf}\n    \\caption{Model not satisfying the $\\type{identity}$ property.}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:properties:identity}\n\\end{figure}\n\nTo illustrate the satisfaction of a $\\textsf{identity}$ property, assume the type model in \\cref{fig:formalisations:ecore_formalisation:type_models:type_model_example} specifies an identity property for the $\\type{name}$ and $\\type{age}$ attributes of the $\\type{Renter}$ object. Formally, we define the following property:\n\\begin{equation*}\n  \\big[ \\textsf{identity}, .\\type{Renter}, \\big\\{ ( .\\type{Person}, \\type{name} ), ( .\\type{Person}, \\type{age} ) \\big\\} \\big]  \n\\end{equation*}\n\nThe example in \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:identity} shows an instance model that does not satisfy the property, as the $\\type{Renter}$ objects share the same values for the $\\type{name}$ and $\\type{age}$ attributes, but are still identified as different objects. In \\cref{fig:formalisations:ecore_formalisation:instance_models:instance_model_example} the values of the $\\type{name}$ and $\\type{age}$ attributes are not the same, and thus the property would be satisfied.\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/keyset/type_model.pdf}\n        \\caption{Example type model with relation $\\type{rel}$ that has the keyset property defined on field $\\type{key}$}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:type_model}\n    \\end{subfigure}\n    \\begin{subfigure}{0.25\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/keyset/invalid.pdf}\n        \\caption{Model not satisfying the keyset property}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:invalid}\n    \\end{subfigure}\n    \\begin{subfigure}{0.25\\textwidth}\n        \\centering\n        \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/keyset/valid.pdf}\n        \\caption{Model satisfying the keyset property}\n        \\label{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:valid}\n    \\end{subfigure}\n    \\caption{Examples of the $\\type{keyset}$ property.}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:properties:keyset}\n\\end{figure}\n\nAn example of the keyset property is shown in \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:keyset}. In \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:type_model}, we see the type model of this example. We assume there exists a class $\\type{A}$ which can reference objects of class $\\type{B}$ through relation $\\type{rel}$. Furthermore, we assume that the $\\type{key}$ field on class $\\type{B}$ is used as key for the relation $\\type{rel}$. In that case, \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:invalid} shows a violation of the $\\type{keyset}$ property, because the 2 objects of type $\\type{B}$ have the same value for $\\type{key}$. In \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:keyset:valid}, the property is satisfied as both objects of type $\\type{B}$ have a different value for $\\type{key}$.\n\n\\begin{figure}[p]\n    \\centering\n    \\includegraphics{images/03_formalisations/02_ecore_formalisation/properties/invalid_opposite.pdf}\n    \\caption{Model not satisfying the $\\type{opposite}$ property.}\n    \\label{fig:formalisations:ecore_formalisation:instance_models:properties:opposite}\n\\end{figure}\n\nIn \\cref{fig:formalisations:ecore_formalisation:instance_models:properties:opposite}, an example model is shown which does not satisfy the opposite property for the $\\type{rents}$ and $\\type{renter}$ relations. Although the number of relations is equal, they do not have the same source and target objects (in opposite direction). The example model in \\cref{fig:formalisations:ecore_formalisation:instance_models:instance_model_example} does in fact satisfy the property.\n\nWith the previous definitions, it is now possible to define when an instance model itself is valid, given its type model.\n\n\\begin{defin}[Model validity]\n\\label{defin:formalisations:ecore_formalisation:instance_models:model_validity}\nAn instance model $Im$ is said to be valid with respect to type model $Tm$ if and only if\n\\begin{itemize}\n    \\item All values are correctly typed: $\\forall ( ( obj, f\\!ield ), val ) \\in \\mathrm{FieldValue}_{Im}\\!: val:_{Im} \\mathrm{type}_{Tm}(f\\!ield)$.\n    \\item All container multiplicities are valid: $\\forall fv \\in \\mathrm{FieldValue}_{Im}\\!: \\mathrm{validMul}_{Im}(f\\!v)$.\n    \\item All properties are satisfied: $\\forall p \\in Prop_{Tm}\\!: Im \\models p$\n    \\item All default values have the correct type: $\\forall c \\in Constant_{Tm}\\!: \\mathrm{DefaultValue}_{Im}(c):_{Im} \\mathrm{ConstType}_{Tm}(c)$.\n    \\item $Tm$ is consistent, as defined in \\cref{defin:formalisations:ecore_formalisation:type_models:type_model_consistency}.\n\\end{itemize}\n\nThe validity of $Im$ with respect to $Tm$ is written as $Tm \\vdash Im$.\n\\isabellelref{instance_model}{Ecore.Instance_Model}\n\\end{defin}", "meta": {"hexsha": "5d3113543f3504dd6ab08179a6c91213ae0abffe", "size": 35950, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/03_formalisations/02_ecore_formalisation/03_instance_models.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/03_formalisations/02_ecore_formalisation/03_instance_models.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/03_formalisations/02_ecore_formalisation/03_instance_models.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.0042283298, "max_line_length": 936, "alphanum_fraction": 0.7021974965, "num_tokens": 10615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891479496523, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4399521211017115}}
{"text": "\\section{Compact and Locally Compact Spaces}\n\\subsection{Compact Spaces}\n\n\\paragraph{2.}\n  I further assume that $X$ is Hausdorff. \n\\begin{proof}\n  Assume, to obtain a contradiction, that $F_n = K_n\\setminus O \\ne\\varnothing$\n  for every $n$. Since $F_n \\supset F_{n+1}$, $\\{F_n\\}$ is collection of closed\n  subsets of compact set $K_1$ with finite intersection property. Hence, \n  $\\bigcap F_n$ is nonempty, contradicting with $\\bigcap K_n \\subset O$. \n\\end{proof}\n\n\\paragraph{3.}\n\\begin{proof}\n  Let $F$ be a closed set and $x \\notin F$. Since $X$ is Hausdorff, for every\n  $y \\in F$, there are two disjoint open sets $U_y$ and $O_y$ s.t. $y \\in U_y$\n  and $x \\in O_y$. Since $X$ is compact, so is $F$. Note that $\\{U_y\\}$ is an\n  open cover for $F$. Hence, it has a finite subcover $\\{U_{y_i}\\}_{i=1}^n$.\n  Let $U = \\bigcup U_{y_i}$ and $O = \\bigcap O_{y_i}$. Clear that they are\n  disjoint open sets s.t. $F \\subset U$ and $x \\in O$.\n\\end{proof}\n\n\\paragraph{6.}\n\\begin{proof}\n  Let $\\vep > 0$ be fixed. Since $\\mcal{F}$ is equicontinuous, for every \n  $x \\in X$, there is a neighborhood $O_x$ s.t. for every $x\\hp \\in X$,\n  $\\sigma(f(x), f(x\\hp)) < \\vep$. Clear that $\\{O_x\\}$ is an open cover and\n  since $X$ is compact, it has a finite subcover $\\{O_{x_i}\\}_{i=1}^m$. \n  \n  For $x_i$, since $f_n(x_i) \\to f(x_i)$, there is an integer $N_i$ s.t. for  \n  every $n > N$, $\\sigma(f_n(x_i), f(x_i)) < \\vep$. Since $\\sigma(f_n(x_i), \n  f_n(x)) < \\vep$ holds for all $n$, $\\sigma(f(x_i), f(x)) \\le \\vep$.\n  Hence, for every $x \\in O_{x_i}$ and $n > N$,\n  \\[\n    \\sigma(f_n(x), f(x))\n    \\le \\sigma(f_n(x), f_n(x_i)) + \\sigma(f_n(x_i), f(x_i)) \n      + \\sigma(f(x_i), f(x))\n    < 3\\vep.\n  \\]\n  Let $N = \\max N_{x_i}$ and we get the desired result.\n\\end{proof}\n\n\\subsection{Countable Compactness and the Bolzano-Weierstrass Property}\n\\paragraph{9.}\n\\begin{proof}\n  $\\,$\\par\n  (a) It follows immediately from the definition and Problem 8.20.\n  \n  (b) For every $\\alpha \\in \\mathbb{R}$,\n  \\[\n    f + g < \\alpha\n    \\quad\\text{iff}\\quad\n    f < \\alpha - g \n    \\quad\\text{iff}\\quad \n    \\exists q\\in \\mathbb{Q} \\text{ s.t. } f < q,\\, q < \\alpha - g.\n  \\]\n  Hence, \n  \\[\n    \\{f + g < \\alpha\\} \n    = \\bigcup_{q \\in \\mathbb{Q}} \\{f < q\\} \\cap \\{g < \\alpha - q\\},\n  \\]\n  which is open. Thus, $f + g$ is also upper semicontinuous. \n  \n  (c) Since $(f_n)$ is a decreasing sequence, we can write $f(x) = \\inf_n\n  f_n(x)$. Hence, for every $\\alpha \\in \\mathbb{R}$, $f < \\alpha$ iff there\n  exists some $n$ s.t. $f_n(x) < \\alpha$. Hence,\n  \\[\n    \\{f < \\alpha\\} = \\bigcup_n \\{f_n < \\alpha\\},\n  \\]\n  which is open. Thus, $f$ is also upper semicontinuous. \n  \n  (d) Note that $(f_n - f)$ is a decreasing sequence of upper semicontinuous\n  functions that converges to $0$. Hence, by Dini's theorem, the convergence is\n  uniform.\n  \n  (e) Suppose that $x \\in \\{f < \\alpha\\}$. Let $\\vep$ be a positive real\n  number. Since $f_n \\to f$ uniformly, there is an integer $n$ s.t. \n  $|f(y) - f_n(y)| < \\vep$ for all $y \\in X$. Meanwhile, since $f_n$ is upper\n  semicontinuous, there is a $\\delta > 0$ s.t. for every $y$ in the\n  $\\delta$-ball $B$ centered at $x$, $f_n(y) < f_n(x) + \\vep$. Hence, for every\n  $y \\in B$,\n  \\begin{align*}\n    f(y) = f(y) - f_n(y) + f_n(y) - f_n(x) + f_n(x) - f(x) + f(x) \n    \\le 3\\vep + f(x). \n  \\end{align*}\n  Thus, for sufficiently small $\\vep > 0$, we have $B \\subset \\{f < \\alpha\\}$.\n  Namely, $\\{f < \\alpha\\}$ is open whence $f$ is upper semicontinuous. \n\\end{proof}\n\n\\paragraph{10.}\n\\begin{proof}\n  $\\,$\\par\n  (i. $\\Rightarrow$ iii.) Let $f$ be a bounded continuous real-valued function\n  and $M := \\sup f < \\infty$. Let $F_n = \\{f \\ge M - 1/n\\}$. Since $f$ is\n  continuous, $F_n$ is closed. Note that $(F_n)$ is a countable family of\n  closed sets with finite intersection property. Hence, $\\bigcap F_n =\n  \\{f \\ge M\\}$ is nonempty as $X$ is countably compact. Namely, the maximum\n  can be attained. \n  \n  (iii. $\\Rightarrow$ ii.) Let $f$ be a continuous function and assume, to\n  obtain a contradiction, that $f$ is unbounded. Then the function \n  $-1/(|f| + 1)$ is a continuous bounded function whose maximum can not be \n  attained. Contradiction.\n  \n  (ii. $\\Rightarrow$ i.) Assume, to obtain a contradiction, that $X$ does not\n  have the Bolzano-Weierstrass property, that is, there is a sequence $(x_n)$\n  in $X$ that has no cluster point. Then $F := \\{x_n\\}_{n=1}^\\infty$ is closed.\n  Define $f: F \\to \\mathbb{R}$ by $f(x_n) = n$. Note that $f$ is continuous on\n  $F$ and by Tietze's extension theorem, it can be continuously extended to \n  $X$. However, $f$ is unbounded, contradicting (ii.). Thus $X$ has the\n  Bolzano-Weierstrass and, therefore, is countably compact. \n\\end{proof}\n\n\\subsection{Products of Compact Spaces}\n\\paragraph{13.}\n\\begin{proof}\n  Let $E$ be a closed and bounded set in $\\mathbb{R}^n$. Then it is contained\n  in some closed cube $K = \\prod_{i=1}^n[a_i, b_i]$. By Tychonoff's theorem,\n  $K$ is compact. Thus, $K$, a closed subset of a compact set, is also compact.\n\\end{proof}\n\n\\paragraph{15.}\n\\begin{proof}\n  Let $X = \\prod_{n=1}^\\infty$ be the product of sequentially compact spaces\n  $(X_n)$. Let $(x_n)$ be a sequence in $X$. Since $X_1$ is sequentially\n  compact, we may choose a subsequence $x_n^1$ of $x_n$ s.t. the first\n  coordinate of $(x_n^1)$ converges to some $x^1$. Similarly, from $(x_n^1)$ we\n  may choose a subsequence $x_n^2$ whose second coordinate converges to some\n  $x^2$. Proceed inductively and we get a sequence of sequence. Finally,\n  consider the sequence $(x_n^n)$. Since each coordinate converges and we are\n  dealing with the product topology, $x_n^n$ converges to $(x_1, x_2, \\dots)$.\n\\end{proof}\n\n\n\\subsection{Locally Compact Spaces}\n\\paragraph{18.}\n\\begin{proof}\n  For every $x \\in K$, since $X$ is locally compact, there is an open set \n  $O_x$ with $\\cl O_x$ compact. Note that $\\{O_x\\}_{x\\in K}$ is an open cover\n  for the compact set $K$. Hence, it has a finite subcover\n  $\\{O_{x_i}\\}_{i=1}^n$. Then, $O = \\bigcup_{i=1}^n O_{x_i}$ is an open set\n  containing $K$ whose closure is compact. \n\\end{proof}\n\n\\paragraph{19.}\n\\begin{proof}\n  $\\,$\\par\n  (a) Since $X$ is a locally compact Hausdorff space and $K$ is compact, there\n  exists an open set $V$ with compact closure s.t. $V\\supset K$. Since \n  $\\cl V$ is compact, it is normal. Therefore, by Urysohn's lemma, there is\n  a continuous function $f: \\cl V \\to [0, 1]$ s.t. $f\\equiv 1$ on $K$ and\n  $f\\equiv 0$ on $\\partial V$. Extend $f$ to $X$ by setting $f \\equiv 0$\n  outsides $\\cl V$. Then $f$ is continuous and $f \\equiv 1$ on $K$. Meanwhile,\n  since $\\supp f\\subset \\cl V$, it is also compact.\n\\end{proof}\n\n\\paragraph{24.}\n  Assume that $X$ is also Hausdorff.\n\\begin{proof}\n  $\\,$\\par\n  (a) Clear that if $F$ is closed, so is $F\\cap K$ for each closed compact\n  $K$. For the reverse, we show that $F^c$ is open.\n  Let $x \\notin F$. Since $X$ is locally compact, there is a neighborhood $U$\n  of $x$ whose closure is compact. If $F\\cap\\cl U = \\varnothing$, then we are\n  done. If $F\\cap \\cl U \\ne \\varnothing$, then by the hypothesis, it is closed.\n  Therefore, $U\\setminus(F\\cap\\cl U)$ is again an open neighborhood of $x$.\n  Since $X$ is a locally compact Hausdorff space, we can find an open\n  neighborhood $V$ with $\\cl V \\subset U\\setminus(F\\cap\\cl U)$. In both cases,\n  $F^c$ is open. \n  \n  (b) Suppose that for each closed compact $K$, $F\\cap K$ is closed. For every\n  $x \\in \\cl F$, since $X$ is first-countable, there exists a sequence $(x_n)\n  \\subset F$ which converges to $x$. Then $E := \\{x\\}\\cup\\{x_n\\}_{n=1}^\\infty$\n  is closed and compact. Thus, by the hypothesis, $F\\cap E$ is also closed,\n  which implies that $x \\in F$. Hence, $F$ is closed. \n\\end{proof}\n\n\\paragraph{26.}\n  Assume that $X$ is Hausdorff.\n\\begin{proof}\n  Let $x$ be an arbitrary point in $X$ and $V$ any neighborhood of $x$. Since \n  $X$ is a locally compact Hausdorff space, we may choose a open neighborhood\n  $U_1$ of $x$ whose closure is compact and contained by $V$. Since $O_1$ is\n  dense, $U_1\\cap O_1$ is a nonempty neighborhood of $x$. Then, choose a \n  neighborhood $U_2$ of $x$ s.t. $\\cl U$ is compact and $\\cl U \\subset \n  U_1\\cap O_1$. Proceed inductively and we get a sequence $(U_n)$ s.t.\n  $\\cl U_n$ is compact and $\\cl U_{n+1} \\subset O_n\\cap U_n$.\n  \n  Since $(\\cl U_n)$ is a nested sequence of compact sets, $\\bigcap \\cl U_n$\n  is nonempty. Choose $x_* \\in \\bigcap\\cl U_n$. For every $O_n$, $x_*\n  \\in \\cl U_{n+1} \\subset O_n$. Thus, $x_* \\in V\\cap\\bigcap_{n=1}^\\infty O_n$.\n  Namely, $\\bigcap_{n=1}^\\infty O_n$ is dense.\n\\end{proof}\n\n\\paragraph{29.}\n\\begin{proof}\n  $\\,$\\par\n  (a) Let $F$ be a closed subset of a locally compact space $X$. For every \n  $x\\in F\\subset X$, there is a neighborhood $U$ of $x$ whose closure is \n  compact in $X$. Then, $U\\cap F$ is also compact. Thus, $F$ is locally\n  compact.\n  \n  (b) Let $O$ be an open subset of a locally compact Hausdorff space $X$. For\n  every $x\\in O \\subset X$, there is a neighborhood $U$ of $x$ whose closure is\n  compact in $X$ and contained by $O$. Note that $\\cl U$ is also compact in\n  $O$. Thus, $O$ is locally compact.\n\\end{proof}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "6cfad6276ac50138c5127aa9b0e22bcfbb034ff2", "size": 9154, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "real_analysis_3rd/ch9_compact_and_locally_compact_spaces.tex", "max_stars_repo_name": "Engineev/solutions", "max_stars_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-07-13T08:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T17:37:17.000Z", "max_issues_repo_path": "real_analysis_3rd/ch9_compact_and_locally_compact_spaces.tex", "max_issues_repo_name": "Engineev/solutions", "max_issues_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "real_analysis_3rd/ch9_compact_and_locally_compact_spaces.tex", "max_forks_repo_name": "Engineev/solutions", "max_forks_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-28T00:05:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-28T00:05:28.000Z", "avg_line_length": 40.8660714286, "max_line_length": 79, "alphanum_fraction": 0.6381909548, "num_tokens": 3284, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7879311906630568, "lm_q1q2_score": 0.4399232534259974}}
{"text": "\\documentclass[a4paper,titlepage]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{fullpage}\n\\usepackage{indentfirst}\n\\usepackage[per-mode=symbol]{siunitx}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage{amsmath}\n\\usepackage{array}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage[format=plain,font=it]{caption}\n\\usepackage{subcaption}\n\\usepackage{standalone}\n\\usepackage[nottoc]{tocbibind}\n\\usepackage[noabbrev,capitalize,nameinlink]{cleveref}\n\\usepackage{listings}\n\\usepackage{titlesec}\n\\usepackage{minted}\n\\usepackage{booktabs}\n\\usepackage{csvsimple}\n\\usepackage{siunitx}\n\\usepackage[super]{nth}\n\\usepackage[titletoc]{appendix}\n\n% Custom commands\n\\newcommand\\numberthis{\\addtocounter{equation}{1}\\tag{\\theequation}}\n\\newcommand{\\code}[1]{\\texttt{#1}}\n\\newcolumntype{P}[1]{>{\\centering\\arraybackslash}p{#1}}\n\n\\setminted{linenos,breaklines,fontsize=auto}\n\n%\\titleformat*{\\section}{\\normalsize\\bfseries}\n%\\titleformat*{\\subsection}{\\small\\bfseries}\n\\renewcommand{\\thesubsection}{\\thesection.\\alph{subsection}}\n\\providecommand*{\\listingautorefname}{Listing}\n\\newcommand*{\\Appendixautorefname}{Appendix}\n\n%opening\n\\title{\\textbf{ECSE 543 \\\\ Assignment 1}}\n\\author{Sean Stappas \\\\ 260639512}\n\\date{October \\nth{21}, 2017}\n\n\\begin{document}\n\t\\sloppy\n\t\\maketitle\n\t\n\t\\tableofcontents\n\t\n\t\n\t\\twocolumn\n\t\n\t\\section*{Introduction}\n\t\n\tThe code for this assignment was created in Python 2.7 and can be seen in \\autoref{appendix:code}. To perform the required tasks in this assignment, a custom \\mintinline{python}{Matrix} class was created, with useful methods such as add, multiply, transpose, etc. This package can be seen in the \\mintinline{python}{matrices.py} file shown in \\autoref{lst:matrices}. The structure of the rest of the code will be discussed as appropriate for each question. Output logs of the program are provided in \\autoref{appendix:logs}.\n\t\n\tThe only packages used that are not built-in are those for fitting curves and creating the plots for this report. These include \\mintinline{python}{matplotlib} for plotting, \\mintinline{python}{numpy} for curve fitting and \\mintinline{python}{sympy} for printing mathematical symbols on the plots. Curve fitting was used to fit the $R(N)$ function in Question 2 and to fit polynomial complexity functions to the number of iterations or runtime of various parts of the program. For any curve fit, the fitting function is given in the legend of the associated plot.\n\t\n\t\\section{Choleski Decomposition}\n\t\n\tThe source code for the Question 1 program can be seen in the \\mintinline{python}{q1.py} file, shown in \\autoref{lst:q1}.\n\t\n\t\\subsection{Choleski Program}\n\t% Write a program to solve the matrix equation Ax=b by Choleski decomposition. A is a real, symmetric, positive-definite matrix of order n.\n\t\n\tThe code relating specifically to Choleski decomposition can be seen in the \\mintinline{python}{choleski.py} file shown in \\autoref{lst:choleski}. It is separated into \\mintinline{python}{elimination} and \\mintinline{python}{back_substitution} methods.\n\t\n\t\n\t\\subsection{Constructing Test Matrices}\n\t% Construct some small matrices (n = 2, 3, 4, or 5) to test the program. Remember that the matrices must be real, symmetric and positive-definite. Explain how you chose the matrices.\n\t\n\tThe matrices were constructed with the knowledge that, if $A$ is positive-definite, then $A = LL^T$ where L is a lower triangular non-singular matrix. The task of choosing valid $A$ matrices then boils down to finding non-singular lower triangular $L$ matrices. To ensure that $L$ is non-singular, one must simply choose nonzero values for the main diagonal. The Choleski decomposition algorithm then validates that the matrix is positive definite during the elimination phase, throwing an error if it is not. The positive definite validation of these test matrices can be seen in \\autoref{lst:q1_log}.\n\t\n\t\\subsection{Test Runs}\n\t% Test the program you wrote in (a) with each small matrix you built in (b) in the following way: invent an x, multiply it by A to get b, then give A and b to your program and check that it returns x correctly.\n\t\n\tThe matrices were tested by inventing $x$ matrices, and checking that the program solves for that $x$ correctly. The output of the program, comparing expected and obtained values of $x$, can be seen in \\autoref{lst:q1_log}.\n\t\n\t\\subsection{Linear Networks}\n\t% Write a program that reads from a file a list of network branches (Jk, Rk, Ek) and a reduced incidence matrix, and finds the voltages at the nodes of the network. Use the code from part (a) to solve the matrix problem. Explain how the data is organized and read from the file. Test the program with a few small networks that you can check by hand. Compare the results for your test circuits with the analytical results you obtained by hand. Cleary specify each of the test circuits used with a labeled schematic diagram.\n\t\n\tThe code relating to solving linear networks can be found in the \\mintinline{python}{linear_networks.py} file and is shown in \\autoref{lst:linear_networks}. Here, the \\mintinline{python}{csv_to_network_branch_matrices} method reads from a CSV file where row $k$ contains the $J_k$, $R_k$ and $E_k$ values. It then converts the resistances to a diagonal admittance matrix $Y$ and produces the $J$ and $E$ column vectors. The incidence matrix $A$ is also read directly from file, as seen in \\autoref{lst:q1}.\n\t\n\tFirst, the program was tested with various circuits. These circuits are labeled 1 to 6 and can be seen in \\cref{fig:q1_circuit_1,fig:q1_circuit_2,fig:q1_circuit_3,fig:q1_circuit_4,fig:q1_circuit_5,fig:q1_circuit_6}. The corresponding voltages solved by SPICE at each node can be seen in \\cref{table:q1_circuit_1,table:q1_circuit_2,table:q1_circuit_3,table:q1_circuit_4,table:q1_circuit_5,table:q1_circuit_6}. Each circuit has corresponding incidence matrix and network branch CSV files, located in the \\mintinline{python}{network_data} directory. For each circuit, the program obtains the expected voltages, as seen in the output in \\autoref{lst:q1_log}.\n\t\n\t% TODO: Add listings of program output here?\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.5\\columnwidth]{plots/q1_circuit_1.pdf}\n\t\t\\caption\n\t\t{Test circuit 1 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_1}\n\t\\end{figure}\n\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 1.}\n\t\t\\csvautobooktabular{csv/q1_circuit_1.csv}\n\t\t\\label{table:q1_circuit_1}\n\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.5\\columnwidth]{plots/q1_circuit_2.pdf}\n\t\t\\caption\n\t\t{Test circuit 2 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_2}\n\t\\end{figure}\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 2.}\n\t\t\\csvautobooktabular{csv/q1_circuit_2.csv}\n\t\t\\label{table:q1_circuit_2}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.5\\columnwidth]{plots/q1_circuit_3.pdf}\n\t\t\\caption\n\t\t{Test circuit 3 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_3}\n\t\\end{figure}\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 3.}\n\t\t\\csvautobooktabular{csv/q1_circuit_3.csv}\n\t\t\\label{table:q1_circuit_3}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\columnwidth]{plots/q1_circuit_4.pdf}\n\t\t\\caption\n\t\t{Test circuit 4 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_4}\n\t\\end{figure}\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 4.}\n\t\t\\csvautobooktabular{csv/q1_circuit_4.csv}\n\t\t\\label{table:q1_circuit_4}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\columnwidth]{plots/q1_circuit_5.pdf}\n\t\t\\caption\n\t\t{Test circuit 5 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_5}\n\t\\end{figure}\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 5.}\n\t\t\\csvautobooktabular{csv/q1_circuit_5.csv}\n\t\t\\label{table:q1_circuit_5}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\columnwidth]{plots/q1_circuit_6.pdf}\n\t\t\\caption\n\t\t{Test circuit 6 with labeled nodes.}\n\t\t\\label{fig:q1_circuit_6}\n\t\\end{figure}\n\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Voltage at labeled nodes of circuit 6.}\n\t\t\\csvautobooktabular{csv/q1_circuit_6.csv}\n\t\t\\label{table:q1_circuit_6}\n\t\\end{table}\n\t\n\t\\section{Finite Difference Resistive Mesh}\n\t\n\tThe source code for the Question 2 program can be seen in the \\mintinline{python}{q2.py} file shown in \\autoref{lst:q2}.\n\t\n\t\\subsection{Equivalent Resistance}\n\t% Using the program you developed in question 1, find the resistance, R, between the node at the bottom left corner of the mesh and the node at the top right corner of the mesh, for N = 2, 3, …, 10. (You will probably want to write a small program that generates the input file needed by the network analysis program. Constructing by hand the incidence matrix for a 200-node network is rather tedious).\n\t\n\tThe code for creating all the network matrices and for finding the equivalent resistance of an $N$ by $2N$ mesh can be seen in the \\mintinline{python}{linear_networks.py} file shown in \\autoref{lst:linear_networks}. To find the equivalent resistance of the mesh, a current source between the top right node and ground was added. Finding the resistance is then simply measuring the voltage at that node and dividing by the test current, which is \\SI{10}{\\milli\\ampere}. The \\mintinline{python}{create_network_matrices_mesh} method creates the incidence matrix $A$, the admittance matrix $Y$, the current source matrix $J$ and the voltage source matrix $E$. The matrix $A$ is created by reading the associated numbered \\mintinline{python}{incidence_matrix} CSV files inside the \\mintinline{python}{network_data} directory. Similarly, the $Y$, $J$ and $E$ matrices are created by reading the \\mintinline{python}{network_branches} CSV files in the same directory. Each of these files contains a list of network branches $(J_k, R_k, E_k)$. The resistances found by the program for values of $N$ from 2 to 10 can be seen in \\autoref{table:q2a}.\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Mesh equivalent resistance R versus mesh size N.}\n\t\t\\csvautobooktabular{csv/q2a.csv}\n\t\t\\label{table:q2a}\n\t\\end{table}\n\n\tThe resistance values returned by the program for small meshes were validated using simple SPICE circuits. The voltage found at the $V_{test}$ node for the 2x4 mesh shown in \\autoref{fig:q2a_mesh_2} is \\SI{1.875}{\\volt} and the equivalent resistance is therefore \\SI{1875}{\\ohm}. Similarly, for the 3x6 mesh (\\autoref{fig:q2a_mesh_3}), $V_{test} = \\SI{2.37955}{\\volt}$ and the equivalent resistance is \\SI{2379.55}{\\ohm}. These match the results found by the program, as seen in \\autoref{table:q2a}. Bigger mesh circuits were not tested, but these results give at least some confidence that the program is working correctly.\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2a_mesh_2.pdf}\n\t\t\\caption\n\t\t{SPICE circuit used to test the 2x4 mesh.}\n\t\t\\label{fig:q2a_mesh_2}\n\t\\end{figure}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2a_mesh_3.pdf}\n\t\t\\caption\n\t\t{SPICE circuit used to test the 3x6 mesh.}\n\t\t\\label{fig:q2a_mesh_3}\n\t\\end{figure}\n\t\n\t\\subsection{Time Complexity}\n\t% In theory, how does the computer time taken to solve this problem increase with N, for large N? Are the timings you observe for your practical implementation consistent with this? Explain your observations.\n\t\n\tThe runtime data for the mesh resistance solver is plotted in \\autoref{fig:q2b}. The overall runtime of the program is dominated by the initial matrix multiplication to form $AYA^T$, which is $O(N^6)$, and this will be true for the banded and non-banded versions of the Choleski program. This matches the results seen in \\autoref{fig:q2b}.\n\t\n%\t\\begin{table}[!htb]\n%\t\t\\centering\n%\t\t\\caption{Runtime of non-banded mesh resistance solver program versus mesh size $N$.}\n%\t\t\\csvautobooktabular{csv/q2b.csv}\n%\t\t\\label{table:q2b}\n%\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2b.pdf}\n\t\t\\caption\n\t\t{Runtime of non-banded mesh resistance solver program versus mesh size $N$.}\n\t\t\\label{fig:q2b}\n\t\\end{figure}\n\n\tTo better display the benefits of banded Choleski elimination, we will look specifically at the runtime of the Choleski elimination and back-substitution, which is plotted in \\autoref{fig:q2b_choleski}. Theoretically, the time complexity of the non-banded Choleski program should be $O(N^6)$. However, as can be seen in \\autoref{fig:q2b_choleski}, $O(N^5)$ more closely matches the obtained data. The simple Choleski program is therefore more efficient than expected. This may be because of successful branch prediction on the repeated zeros of the matrix when performing elimination, or because of the relatively small amount of data points.\n\t\n%\t\\begin{table}[!htb]\n%\t\t\\centering\n%\t\t\\caption{Runtime of non-banded Choleski program versus mesh size $N$.}\n%\t\t\\csvautobooktabular{csv/q2b_choleski.csv}\n%\t\t\\label{table:q2b_choleski}\n%\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2b_choleski.pdf}\n\t\t\\caption\n\t\t{Runtime of non-banded Choleski program versus mesh size $N$.}\n\t\t\\label{fig:q2b_choleski}\n\t\\end{figure}\n\t\n\t\\subsection{Sparsity Modification}\n\t% Modify your program to exploit the sparse nature of the matrices to save computation time. What is the half-bandwidth b of your matrices? In theory, how does the computer time taken to solve this problem increase now with N, for large N? Are the timings you for your practical sparse implementation consistent with this? Explain your observations.\n\t\n\t By inspection of the constructed network matrices, a half-bandwidth of $b = 2N + 1$ was chosen for the banded version of the program. The runtime data for the banded mesh resistance solver is plotted in \\autoref{fig:q2c}. Once again, the program is dominated by the $O(N^6)$ initial matrix multiplication, which matches the obtained results. The runtime of the banded Choleski program is plotted in \\autoref{fig:q2c_choleski}. Theoretically, the banded version of the Choleski program should have a time complexity of $O(N^4)$, which also matches the experimental results.\n\t\n%\t\\begin{table}[!htb]\n%\t\t\\centering\n%\t\t\\caption{Runtime of banded mesh resistance solver program versus mesh size $N$.}\n%\t\t\\csvautobooktabular{csv/q2c.csv}\n%\t\t\\label{table:q2c}\n%\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2c.pdf}\n\t\t\\caption\n\t\t{Runtime of banded mesh resistance solver program versus mesh size $N$.}\n\t\t\\label{fig:q2c}\n\t\\end{figure}\n\n%\t\\begin{table}[!htb]\n%\t\t\\centering\n%\t\t\\caption{Runtime of banded Choleski program versus mesh size $N$.}\n%\t\t\\csvautobooktabular{csv/q2c_choleski.csv}\n%\t\t\\label{table:q2c_choleski}\n%\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2c_choleski.pdf}\n\t\t\\caption\n\t\t{Runtime of banded Choleski program versus mesh size $N$.}\n\t\t\\label{fig:q2c_choleski}\n\t\\end{figure}\n\n\tThe runtime of the banded and non-banded versions of the Choleski program are plotted together in \\autoref{fig:q2bc_choleski}, showing the clear benefits of banded elimination.\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2bc_choleski.pdf}\n\t\t\\caption\n\t\t{Comparison of runtime of banded and non-banded Choleski programs versus mesh size $N$.}\n\t\t\\label{fig:q2bc_choleski}\n\t\\end{figure}\n\t\n\t\\subsection{Resistance vs. Mesh Size}\n\t% Plot a graph of R versus N. Find a function R(N) that fits the curve reasonably well and is asymptotically correct as N tends to infinity, as far as you can tell.\n\t\n\tThe equivalent mesh resistance $R$ is plotted versus the mesh size $N$ in \\autoref{fig:q2d}. The function $R(N)$ appears logarithmic, and a log function does indeed fit the data well. As shown in \\autoref{fig:q2d}, $R(N) = 1260.81\\log{N} + 996.28$ is a good fit, where $R$ is in $\\Omega$.\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q2d.pdf}\n\t\t\\caption\n\t\t{Resistance of mesh versus mesh size $N$.}\n\t\t\\label{fig:q2d}\n\t\\end{figure}\n\t\n\t\\section{Coaxial Cable}\n\t\n\tThe source code for the Question 3 program can be seen in the \\mintinline{python}{q3.py} file shown in \\autoref{lst:q3}.\n\t\n\t\\subsection{SOR Program}\n\t% Write a computer program to find the potential at the nodes of a regular mesh in the air between the conductors by the method of finite differences. Use a five-point difference formula. Exploit at least one of the planes of mirror symmetry that this problem has. Use an\tequal node-spacing, h, in the x and y directions. Solve the matrix equation by successive\tover-relaxation (SOR), with SOR parameter w. Terminate the iteration when the magnitude\tof the residual at each free node is less than 10^-5.\n\t\n\tThe source code for the finite difference methods can be seen in the \\mintinline{python}{finite_diff.py} file shown in \\autoref{lst:finite_diff}. Horizontal and vertical symmetries were exploited by only solving for a quarter of the coaxial cable, and reproducing the results where necessary. The initial potential values are guessed based on a simple function which decreases radially from the center conductor.\n\t\n\t\\subsection{Varying $\\omega$}\n\t% With h = 0.02, explore the effect of varying w. For 10 values of w between 1.0 and 2.0,\ttabulate the number of iterations taken to achieve convergence, and the corresponding value\tof potential at the point (x ,y) = (0.06, 0.04). Plot a graph of number of iterations versus w.\n\t\n\tThe number of iterations to achieve convergence for 10 values of $\\omega$ between 1 and 2 are tabulated in \\autoref{table:q3b_iterations} and plotted in \\autoref{fig:q3b}. Based on these results, the value of $\\omega$ yielding the minimum number of iterations is 1.3.\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Number of iterations of SOR versus $\\omega$.}\n\t\t\\csvautobooktabular{csv/q3b_iterations.csv}\n\t\t\\label{table:q3b_iterations}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3b.pdf}\n\t\t\\caption\n\t\t{Number of iterations of SOR versus $\\omega$.}\n\t\t\\label{fig:q3b}\n\t\\end{figure}\n\n\tThe potential values found at (0.06, 0.04) versus $\\omega$ are tabulated in \\autoref{table:q3b_potential}. It can be seen that all the potential values are identical to 3 decimal places, which shows that the program is converging correctly.\n\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Potential at (0.06, 0.04) versus $\\omega$ when using SOR.}\n\t\t\\csvautobooktabular{csv/q3b_potential.csv}\n\t\t\\label{table:q3b_potential}\n\t\\end{table}\n\t\n\t\\subsection{Varying $h$}\n\t% With an appropriate value of w, chosen from the above experiment, explore the effect of\tdecreasing h on the potential. Use values of h = 0.02, 0.01, 0.005, etc, and both tabulate and\tplot the corresponding values of potential at (x, y) = (0.06, 0.04) versus 1/h. What do you think is the potential at (0.06, 0.04), to three significant figures? Also, tabulate and plot the number of iterations versus 1/h. Comment on the properties of both plots.\n\t\n\tWith $\\omega = 1.3$, the number of iterations of SOR versus $1/h$ is tabulated in \\autoref{table:q3c_iterations} and plotted in \\autoref{fig:q3c_iterations}. Note that $h$ is in meters in all shown plots and tables. It can be seen that the smaller the node spacing is, the more iterations the program will take to run. Theoretically, the time complexity of the program should be $O(N^3)$, where the finite difference mesh is NxN. However, the experimental data shows a complexity closer to $O(1/h^2) = O(N^2)$. The discrepancy can perhaps be because of the relatively small amount of data points.\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Number of iterations of SOR versus $1/h$. Note that $\\omega=1.3$.}\n\t\t\\csvautobooktabular{csv/q3c_iterations.csv}\n\t\t\\label{table:q3c_iterations}\n\t\\end{table}\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3c_iterations.pdf}\n\t\t\\caption\n\t\t{Number of iterations of SOR versus $1/h$. Note that $\\omega=1.3$.}\n\t\t\\label{fig:q3c_iterations}\n\t\\end{figure}\n\n\tThe potential values found at (0.06, 0.04) versus $1/h$ are tabulated in \\autoref{table:q3c_potential} and plotted in \\autoref{fig:q3c_potential}. By examining these values, the potential at (0.06, 0.04) to three significant figures is converging to approximately \\SI{5.24}{\\volt}. It can be seen that the smaller the node spacing is, the more accurate the calculated potential is. However, by inspecting \\autoref{fig:q3c_potential} it is apparent that the potential converges relatively quickly to around \\SI{5.24}{\\volt}. There are therefore diminishing returns to decreasing the node spacing too much, since this will also greatly increase the runtime of the program. This of course depends on the level of precision needed in the program.\n\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Potential at (0.06, 0.04) versus $1/h$ when using SOR.}\n\t\t\\csvautobooktabular{csv/q3c_potential.csv}\n\t\t\\label{table:q3c_potential}\n\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3c_potential.pdf}\n\t\t\\caption\n\t\t{Potential at (0.06, 0.04) found by SOR versus $1/h$. Note that $\\omega=1.3$.}\n\t\t\\label{fig:q3c_potential}\n\t\\end{figure}\n\t\n\t\\subsection{Jacobi Method}\n\t% Use the Jacobi method to solve this problem for the same values of h used in part (c). Tabulate and plot the values of the potential at (x, y) = (0.06, 0.04) versus 1/h and the number of iterations versus 1/h. Comment on the properties of both plots and compare to those of SOR.\n\t\n\tThe number of iterations of the Jacobi method versus $1/h$ is tabulated in \\autoref{table:q3d_iterations} and plotted in \\autoref{fig:q3d_iterations}. Similarly to SOR, the smaller the node spacing is, the more iterations the program will take to run. We can see however that the Jacobi method takes a much larger number of iterations to converge. Theoretically, the Jacobi method should have a time complexity of $O(N^4)$. However, the experimental data shows a complexity closer to $O(1/h^3) = O(N^3)$. The discrepancy can perhaps be because of the relatively small amount of data points.\n\t\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Number of iterations versus $\\omega$ when using the Jacobi method.}\n\t\t\\csvautobooktabular{csv/q3d_iterations.csv}\n\t\t\\label{table:q3d_iterations}\n\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3d_iterations.pdf}\n\t\t\\caption\n\t\t{Number of iterations of the Jacobi method versus $1/h$.}\n\t\t\\label{fig:q3d_iterations}\n\t\\end{figure}\n\n\tThe potential values found at (0.06, 0.04) versus $1/h$ with the Jacobi method are tabulated in \\autoref{table:q3d_potential} and plotted in \\autoref{fig:q3d_potential}. These potential values are almost identical to the SOR ones, which suggests that it is converging correctly. Similarly to SOR, the smaller the node spacing is, the more accurate the calculated potential is.\n\n\t\\begin{table}[!htb]\n\t\t\\centering\n\t\t\\caption{Potential at (0.06, 0.04) versus $1/h$ when using the Jacobi method.}\n\t\t\\csvautobooktabular{csv/q3d_potential.csv}\n\t\t\\label{table:q3d_potential}\n\t\\end{table}\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3d_potential.pdf}\n\t\t\\caption\n\t\t{Potential at (0.06, 0.04) versus $1/h$ when using the Jacobi method.}\n\t\t\\label{fig:q3d_potential}\n\t\\end{figure}\n\n\tA comparison of the number of iterations of SOR and Jacobi can be seen in \\autoref{fig:q3d_iterations_comparison}, which shows the clear benefits of SOR.\n\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3d_iterations_comparison.pdf}\n\t\t\\caption\n\t\t{Comparison of number of iterations when using SOR and Jacobi methods versus $1/h$. Note that $\\omega=1.3$ for the SOR program.}\n\t\t\\label{fig:q3d_iterations_comparison}\n\t\\end{figure}\n\t\n\t\\subsection{Non-uniform Node Spacing}\n\t% Modify the program you wrote in part (a) to use the five-point difference formula derived in\tclass for non-uniform node spacing. An alternative to using equal node spacing, h, is to use\tsmaller node spacing in more “difficult” parts of the problem domain. Experiment with a\tscheme of this kind and see how accurately you can compute the value of the potential at (x, y)\t= (0.06, 0.04) using only as many nodes as for the uniform case h = 0.01 in part (c).\n\t\n\tFirst, we adjust the equation derived in class to set $a_1 = \\Delta_x\\alpha_1$, $a_2 = \\Delta_x\\alpha_2$, $b_1 = \\Delta_y\\beta_1$ and $b_2 = \\Delta_y\\beta_2$. These values \\footnote{Note that, in the program, index $i$ is associated to position $y$ and index $j$ is associated to position $x$. This is purely for easier handling of the matrices.} correspond to the distances between adjacent nodes, and can be easily calculated by the program. Then, the five-point difference formula for non-uniform spacing can be seen in \\autoref{eq:non_uniform}.\n\t\n\t\\begin{align} \\label{eq:non_uniform}\n\t\t\\begin{split}\n\t\t\t\\phi^{k + 1}_{i,j} = \n\t\t\t&\\frac{1}{a_1 + a_2}\\left(\\frac{\\phi^k_{i - 1,j}}{a_1} + \\frac{\\phi^k_{i + 1,j}}{a_2}\\right) + \\\\\n\t\t\t&\\frac{1}{b_1 + b_2}\\left(\\frac{\\phi^k_{i, j - 1}}{b_1} + \\frac{\\phi^k_{i, j + 1}}{b_2}\\right)\n\t\t\\end{split}\n\t\\end{align}\n\t\n\tThis was implemented in the finite difference program, as seen in \\mintinline{python}{NonUniformRelaxer} class in the \\mintinline{python}{finite_diff.py} file shown in \\autoref{lst:finite_diff}. As can be seen in this code, many different mesh arrangements were tested. It was also tested that, if the non-uniform program is given a uniformly spaced grid, it finds the same potential as Jacobi. The chosen grid arrangement can be seen in \\autoref{fig:q3e}. This grid was selected because the ``difficult'' regions are close to the inner conductor, where there is a higher concentration of nodes. The potential at (0.06, 0.04) obtained from this arrangement is \\SI{5.243}{\\volt}, which seems like an accurate potential value. Indeed, as can be seen in \\Cref{fig:q3c_potential,fig:q3d_potential}, the potential value for small node spacings tends towards \\SI{5.24}{\\volt} for both the Jacobi and SOR methods.\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\includegraphics[width=\\columnwidth]{plots/q3e.pdf}\n\t\t\\caption\n\t\t{Final mesh arrangement used for non-uniform node spacing. Each point corresponds to a mesh point. The $x$ and $y$ coordinate are in meters. Points are positioned closer to the inner conductor, since this is a more difficult area. Note that this arrangement only represents one fourth of the entire grid, which is symmetric in $x$ and $y$.}\n\t\t\\label{fig:q3e}\n\t\\end{figure}\n\t\n\t\\onecolumn\n\t\n%\t\\appendix\n\t\n\t\\begin{appendices}\n\t\t\n\t\t\\section{Code Listings} \\label{appendix:code}\n\t\t\n\t\t\\setminted{linenos,breaklines,fontsize=\\footnotesize}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Custom matrix package (\\texttt{matrices.py}).}\n\t\t\t\\inputminted{python}{../matrices.py}\n\t\t\t\\label{lst:matrices}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{CSV manipulation utilities (\\texttt{csv\\_saver.py}).}\n\t\t\t\\inputminted{python}{../csv_saver.py}\n\t\t\t\\label{lst:csv_saver}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Choleski decomposition (\\texttt{choleski.py}).}\n\t\t\t\\inputminted{python}{../choleski.py}\n\t\t\t\\label{lst:choleski}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Linear resistive networks (\\texttt{linear\\_networks.py}).}\n\t\t\t\\inputminted{python}{../linear_networks.py}\n\t\t\t\\label{lst:linear_networks}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Question 1 (\\texttt{q1.py}).}\n\t\t\t\\inputminted{python}{../q1.py}\n\t\t\t\\label{lst:q1}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Question 2 (\\texttt{q2.py}).}\n\t\t\t\\inputminted{python}{../q2.py}\n\t\t\t\\label{lst:q2}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Finite difference method (\\texttt{finite\\_diff.py}).}\n\t\t\t\\inputminted{python}{../finite_diff.py}\n\t\t\t\\label{lst:finite_diff}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Question 3 (\\texttt{q3.py}).}\n\t\t\t\\inputminted{python}{../q3.py}\n\t\t\t\\label{lst:q3}\n\t\t\\end{center}\n\t\t\n\t\t\\section{Output Logs} \\label{appendix:logs}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Output of Question 1 program (\\texttt{q1.txt}).}\n\t\t\t\\inputminted{pycon}{logs/q1.txt}\n\t\t\t\\label{lst:q1_log}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Output of Question 2 program (\\texttt{q2.txt}).}\n\t\t\t\\inputminted{pycon}{logs/q2.txt}\n\t\t\t\\label{lst:q2_log}\n\t\t\\end{center}\n\t\t\n\t\t\\begin{center}\n\t\t\t\\captionof{listing}{Output of Question 3 program (\\texttt{q3.txt}).}\n\t\t\t\\inputminted{pycon}{logs/q3.txt}\n\t\t\t\\label{lst:q3_log}\n\t\t\\end{center}\n\t\\end{appendices}\n\n\\end{document}\n", "meta": {"hexsha": "f6849ed6c9767132a136ee5e868e693a27b0a54e", "size": 28726, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment1/report/report.tex", "max_stars_repo_name": "seanstappas/ecse-543-assignment1", "max_stars_repo_head_hexsha": "14b055eee826f05aeaffbdd4eac70ed8e750288d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment1/report/report.tex", "max_issues_repo_name": "seanstappas/ecse-543-assignment1", "max_issues_repo_head_hexsha": "14b055eee826f05aeaffbdd4eac70ed8e750288d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment1/report/report.tex", "max_forks_repo_name": "seanstappas/ecse-543-assignment1", "max_forks_repo_head_hexsha": "14b055eee826f05aeaffbdd4eac70ed8e750288d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.9962406015, "max_line_length": 1139, "alphanum_fraction": 0.7528719627, "num_tokens": 8700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.787931185683219, "lm_q1q2_score": 0.4399232506456195}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{amsmath}\n\\usepackage{tikz} % for Hasse diagram\n\\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}\n%\\topmargin=0cm\n\\topmargin=-2cm\n\\addtolength{\\textheight}{6.5cm}\n\\addtolength{\\textwidth}{2.0cm}\n%\\setlength{\\leftmargin}{-5cm}\n\\setlength{\\oddsidemargin}{0.0cm}\n\\setlength{\\evensidemargin}{0.0cm}\n\n\\begin{document}\n\t\n\\section*{Student Information } \n%Write your full name and id number between the colon and newline\n%Put one empty space character after colon and before newline\nFull Name : Yavuz Selim YEŞİLYURT \\\\\nId Number : 2259166 \\\\\n\n% Write your answers below the section tags\n\\section*{Answer 1}\n\\qquad Let $f_n$ be the number of ternary strings that contain 3 consecutive 0s, 1s or 2s. $f_1=0$ and $f_2 =0$ because they do not have 3 digits. Let $g_n$ stand for the number of ternary strings that doesn't contain 3 consecutive 0s, 1s or 2s.\\\\\n\nSo for finding $f_n$, we should find $g_n$ and then subtract it from the total number of ternary strings with length n (i.e. $3^n$).\\\\\n\nFind $g_n$ by constructing a ternary string of length n.\\\\\n\nFirst choose first digit. Any of 0,1,2 can be chosen as first digit of the string. Let's choose 0 as first digit, however other digits can be chosen, too. The probability of the string to start with 0 is $1/3$. Since we have 3 of these beginning digits we should multiply our probability by $(1/3) * 3 = 1$. Possibilities for second digit are 0,1,2 too. But we have to analyze 2 cases in this case. We should check for \"1\" and \"2\" as second digit of the string(say case 1) and chech for \"0\" as second digit of the string (say case 2). \\\\\n\nIn case 1, string starts with 01.. or 02.. which are not consecutive numbers (not 00). We can reset the count of first digit in this case (first digit is 0 in this case) at the beginning and go on with any string that does not contain 3 consecutive symbols and starts with 1 or 2. That is $2g_{n-1}$.\\\\\n\nIn case 2, string starts with 00.. which means the first two digits are consecutive. Since we started with 00 our next digit can not be 0 because then our string will contain three consecutive zeros (000). Therefore the rest of the string must start with 1 or 2 and does not contain 3 consecutive digits, which is $2g_{n-2}$.\\\\\n\nAdd this to the other case, multiply by our possibility to choose first digit (which we found at the first part of answer and which is 1) and get $g_n$:\\\\\n$g_n = 1*(2g_{n-1} + 2g_{n-2})$ for $n \\geq 3$\\\\\nwhere $g(1) = 3,\\ g(2) = 9$.\\\\\n\nTurn back to $f_n$ and subtract $g_n$ from $3^n$ to find $f_n$.\\\\\n$f_n = 3^n - g_n$ where $g_n = 2(g_{n-1} + g_{n-2})$ for $n\\geq 3$ \\\\\nAnd initial conditions are:\\\\ \n$f(1) = 0 , f(2) = 0$ and $g(1) = 3,g(2) = 9$\n\n\\section*{Answer 2}\n\\textbf{a)}A tile can be placed horizontally, i.e. as a $1 \\times 2$ tile or vertically, i.e. as a $2 \\times 1$ tile. We need 3 small tiles to tile the board of size $3 \\times 2$. There are three ways to tile:\\\\\n\\begin{tabular}{|cccc|}\n\\hline \n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n\\hline \n\\hline \n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n\\hline \n\\hline \n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n\\hline \n\\end{tabular}\n\\begin{tabular}{|cc|cc|}\n  \\hline\n  & & & \\tabularnewline\n  & & & \\tabularnewline \n  & & & \\tabularnewline\n  & & & \\tabularnewline\n  \\hline \\hline\n  & \\multicolumn{1}{c}{} &  & \\tabularnewline\n  & \\multicolumn{1}{c}{} &  & \\tabularnewline\n  \\hline\n\\end{tabular}\n\\begin{tabular}{|cc|cc|}\n\\hline \n & \\multicolumn{1}{c}{} &  & \\tabularnewline\n & \\multicolumn{1}{c}{} &  & \\tabularnewline\n\\hline \n\\hline \n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n &  &  & \\tabularnewline\n\\hline \n\\end{tabular}\\\\\\\\\\\\\n\\textbf{b)} \nWe have three $3\\times 2$ boards to cover $3\\times n$ board, namely (from part a);\\\\\n- $3\\times 2$ board tiled with 3 horizontal $2\\times 1$ tiles (say type 1 tiling)\\\\\n- $3\\times 2$ board tiled with 1 horizontal tile at the upside of the board and 2 vertical tile at the downside of the board $2\\times 1$ tiles (say type 2 tiling)\\\\\n- $3\\times 2$ board tiled with 2 vertical tile at the upside of the board and 1 horizontal tile at the downside of the board $2\\times 1$ tiles (say type 3 tiling)\\\\\n\nLet $f_n$ be the count of ways to place tiles on a $3\\times n$ board. Since we cover 2 columns in one tiling operation, for odd numbers of $n$, since we can not tile these boards with odd number of columns problem gives $0$ and for even numbers of $n$ problem reduces to $f_{n-2}$.\\\\\n \nFor the even numbers of $n$ now consider placing the first $3\\times 2$ tile to $3\\times n$ board.If the first tiling is of type 1,then we can tile the following part with all types, no restrictions, so problem reduces to $f_{n-2}$, say this is case 1.\\\\\n\nBut, since we have the condition of dropping the same 2 tilings (tilings which can be obtained from one another when mirrored along the side of length-$n$), we should check for the cases when any of the two tilings are the same;\\\\\n\nLet's say we place a tile of type 2 for the first tiling and then we tile the remaining part of $3\\times n$ board with some tilings of any type (i.e. the remaining tiling problem reduces to $f_{n-2}$ and say this is case 2). If we were to place a tile of type 3 for the first and then we continue to tile the remaining part same as in the first case (i.e. the remaining tiling problem reduces to $f_{n-2}$ and say this is case 3) these two tilings (case 2 and case 3) would be same since each tiling can be obtained from one another when mirrored along the side of length-$n$ (figure 1), so we have to delete one of these occurences, therefore, in case-3 problem actually reduces to $f_{n-2}-1$\\\\\n\nSo we have (for even numbers of $n$) $f_n = f_{n-2} + f_{n-2} + f_{n-2}-1$,\\\\\nTherefore we get for $n\\geq 3$, $f_n = 3f_{n-2}-1$ for even numbers of $n$ and $0$ for odd numbers of $n$ . As initial conditions we have $f(0)=0$, $f(1)=0$, $f(2)=2$ .\n\n\\newpage\n\n\\textbf{c)}\tWe have $f_{n}=3f_{n-2}-1$ for even numbers of $n$ and for $n\\geq 3$. Initial conditions were $f(0)=0$, $f(1)=0$, $f(2)=2$ and let's say$<f_{0},f_{1},f_{2}...,f_{n},....><->F(x)$\\\\\n\n$F(x)=\\sum_{n=3}^{\\infty}f_{n}x^{n} + 2x^{2}=2x^{2}+\\sum_{n=3}^{\\infty}(3f_{n-2}-1)x^{n}$\\\\\n\n$F(x)=2x^{2}+\\sum_{n=3}^{\\infty}3f_{n-2}x^{n}-\\sum_{n=3}^{\\infty}1x^{n}$\\\\\n\n$F(x)=2x^{2}+3x^{2}F(x)-x^{3}(1+x^{2}+x^{4}...)$\\\\\n\n$F(x)=2x^{2}+3x^{2}F(x)-x^{3}(\\frac{1}{1-x})$\\\\\n\n$F(x)=\\frac{2x^{2}-3x^{3}}{3x^3-3x^2-x+1}$ Do partial fractions:\\\\\n\n$F(x)=\\frac{1}{2(1-x)}+\\frac{x-1}{2(3x^2-1)}-1$ \\\\\n\nwhere; $\\frac{1}{2}\\frac{1}{1-x}=\\frac{1}{2}(1+x+x^{2}+...)<-><\\frac{1}{2},\\frac{1}{2},\\frac{1}{2},\\frac{1}{2},\\frac{1}{2}...,\\frac{1}{2},...>$ and\\\\\n\n$\\frac{1}{2}\\frac{1}{1-3x^{2}}=\\frac{1}{2}(1+3x^{2}+3^{2}x^{4}+...)<-><\\frac{1}{2},0,\\frac{1}{2}3,0,\\frac{1}{2}3^{2},0...,\\frac{(-1)^{n}+1}{2}\\frac{3^{\\frac{n}{2}}}{2},...>$\nand\\\\\n\n$\\frac{1}{2}\\frac{x}{1-3x^{2}}=\\frac{1}{2}(1+3x^{3}+3^{2}x^{5}+...)<-><0,\\frac{1}{2},0,\\frac{1}{2}3,0,\\frac{1}{2}3^{2},0...,\\frac{(-1)^{n-1}+1}{2}\\frac{3^{\\frac{n-1}{2}}}{2},...>$\nand\\\\\n\n$1=<1,0,0,0,0,0....>$\\\\\n\n\nTherefore (odd coefficients are zero, so they are denoted with $f's$).\\\\  $F(x)<-><0,0,2,f_3,5,f_5,......,\\frac{1}{2}+ \\frac{(-1)^{n}+1}{2}\\frac{3^{\\frac{n}{2}}}{2}-\\frac{(-1)^{n-1}+1}{2}\\frac{3^{\\frac{n-1}{2}}}{2},....>$,\nwhich implies;\\\\ \n\n$f_{n}=\\frac{1}{2}+\\frac{(-1)^{n}+1}{2}\\frac{3^{\\frac{n}{2}}}{2}-\\frac{(-1)^{n-1}+1}{2}\\frac{3^{\\frac{n-1}{2}}}{2}$ for even numbers of n with $n \\geq 3$. With initial conditions $f(0)=0$, $f(1)=0$, $f(2)=2$.\n\\newpage\n\\section*{Answer 3}\nSince a binary relation R on a set S is a partial order iff it is reflexive, antisymmetric and transitive, we should check if the binary relation is reflexive, antisymmetric and transitive on each part seperately. Keep the relations' features in mind;\n\\\\\n- A relation is reflexive if $\\forall a \\in S \\ \\ aRa$\\\\\n- A relation is antisymmetric if $\\forall{a,b} \\in S ((aRb \\land bRa) \\implies a=b)$\\\\\n- A relation is transitive if $\\forall{a,b,c} \\in S ((aRb \\land bRc) \\implies aRc)$\n\\\\\\\\\nUsing these information;\n\\\\\n\\textbf{a)}\n\\\\\\\\\nSet inclusion ($ \\subseteq $) on any set of sets is;\\\\\n-Reflexive, because every set is a subset of itself on any set of sets,\\\\\n-Antisymmetric, since if a subset of the set is the set's superset; the set's subset(also the superset) is the same set as the set on any set of sets,\\\\\n-Transitive, since if any subset of the set's subset is also that set's subset on any set of sets.\n\\\\\\\\\nSo set inclusion ($\\subseteq$) on any set of sets is partial order.\n\\\\\\\\\n\\textbf{b)}\n\\\\\\\\\nEven relation $\"|\"$ of divisibility on integers $Z$ is both reflexive and transitive it is not partial order because;\\\\\nIt is not antisymetric, since $-2|2$ is true and $2|-2$ is true but $2 \\neq -2$. So relation $\"|\"$ of divisbility on integers $Z$ is not a partial order.\n\\\\\\\\\n\\textbf{c)}\n\\\\\\\\\nRelation R is defined as \"$aRb$ if there is a positive integer $r$ such that $b=a^r$\" on $Z$. It is;\\\\\n-Reflexive since for $r=1$, $a=a^1$,\\\\\n-This relation is antisymmetric. Assume that $a$ and $b$ are arbitrarily chosen, such that $aRb$ and $bRa$. Hence $a=b^r$ and $b=a^{r_2}$.\\\\\n$a=a^{r*r_2} \\implies r*r_2 =1$. Since $r \\ \\ and \\ \\ r_2$ are positive integers $r=1$ and $r_2 = 1$ so $a=b^1$ and $a^1=b$ so this relation is antisymmetric.\\\\ \n-Transitive since if $b=a^r$ and $c=b^{\\bar{r}}$, $c=a^{r^{'}}$ is true for every $r^{'}=r*\\bar{r}$.\\\\\n\\\\\nSo this relation on $Z$ is partial ordered.\n\n\\newpage\n\n\\section*{Answer 4}\n\n\\textbf{a)}\\\\\\\\\n\n1-) $1+1+1+1+1$\\\\\n\n2-) $2+1+1+1$\\\\\n\n3-) $2+2+1 $\\\\\n\n4-) $3+1+1$\\\\\n\n5-) $3+2$\\\\\n\n6-) $4+1$\\\\\n\n7-) $5$\\\\\n\nAs can be seen there are 7 partitions of 5.\\\\\\\\\n\n\\textbf{b)}\n\n%Hasse diagram example\n\\begin{figure}[H]\n\\centering\n\\begin{tikzpicture}\n%%   kw   (name)   (x, y)   {text}\n    \\node (md1) at (2, 4)     {5};\n    \\node (md2) at (0, 2)     {3+2};\n    \\node (rt2) at (4, 2)     {4+1};\n    \\node (lt3) at (0, 0)     {3+1+1};\n    \\node (rt3) at (4, 0)     {2+2+1};\n\t\\node (md4) at (2, -2)     {2+1+1+1};\n\t\\node (md5) at (2,-4)     {1+1+1+1+1};\n\n    \\draw (md1) -- (md2);\n    \\draw (md2) -- (lt3);\n    \\draw (md2) -- (rt3);\n    \\draw (rt2) -- (rt3);\n    \\draw (lt3) -- (md4);\n    \\draw (rt3) -- (md4);\n    \\draw (md5) -- (md4);\n    \\draw (lt3) -- (rt2);\n    \\draw (rt2) -- (md1);\n\\end{tikzpicture} \n\\end{figure}\n\n\\end{document}", "meta": {"hexsha": "024cd20023c8f812fa57e7e7296f26c3895474b7", "size": 10373, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "223/the4/hw4.tex", "max_stars_repo_name": "ysyesilyurt/Metu-CENG", "max_stars_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 33, "max_stars_repo_stars_event_min_datetime": "2019-03-19T07:51:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:04:35.000Z", "max_issues_repo_path": "223/the4/hw4.tex", "max_issues_repo_name": "ysyesilyurt/Metu-CENG", "max_issues_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-11-09T18:08:21.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-09T18:08:21.000Z", "max_forks_repo_path": "223/the4/hw4.tex", "max_forks_repo_name": "ysyesilyurt/Metu-CENG", "max_forks_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2019-11-08T06:18:21.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T17:17:38.000Z", "avg_line_length": 48.0231481481, "max_line_length": 696, "alphanum_fraction": 0.6403162055, "num_tokens": 3955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7879311931529758, "lm_q1q2_score": 0.43992324323487114}}
{"text": "\\documentclass[aps,notitlepage,nofootinbib,11pt]{revtex4-1}\n\n% linking references\n\\usepackage{hyperref}\n\\hypersetup{\n  breaklinks=true,\n  colorlinks=true,\n  linkcolor=blue,\n  filecolor=magenta,\n  urlcolor=cyan,\n}\n\n%%% symbols, notations, etc.\n\\usepackage{physics,braket,bm,commath,amssymb} % physics and math\n\\renewcommand{\\t}{\\text} % text in math mode\n\\newcommand{\\f}[2]{\\dfrac{#1}{#2}} % shorthand for fractions\n\\newcommand{\\p}[1]{\\left(#1\\right)} % parenthesis\n\\renewcommand{\\sp}[1]{\\left[#1\\right]} % square parenthesis\n\\renewcommand{\\set}[1]{\\left\\{#1\\right\\}} % curly parenthesis\n\\renewcommand{\\v}{\\bm} % bold vectors\n\\renewcommand{\\c}{\\cdot} % inner product\n\\newcommand{\\bk}{\\braket} % shorthand for braket notation\n\\newcommand{\\Bk}{\\Braket} % shorthand for braket notation\n\n\\renewcommand{\\d}{\\text{d}} % \"d\" for integration measure\n\\newcommand{\\g}{\\text{g}} % ground / excited electronic states\n\\newcommand{\\e}{\\text{e}}\n\n\\newcommand{\\B}{\\mathcal{B}}\n\\newcommand{\\D}{\\mathcal{D}}\n\\newcommand{\\E}{\\mathcal{E}}\n\\newcommand{\\G}{\\mathcal{G}}\n\\newcommand{\\I}{\\mathcal{I}}\n\\newcommand{\\J}{\\mathcal{J}}\n\\renewcommand{\\L}{\\mathcal{L}}\n\\renewcommand{\\O}{\\mathcal{O}}\n\\renewcommand{\\P}{\\mathcal{P}}\n\\newcommand{\\Q}{\\mathcal{Q}}\n\n\\usepackage{dsfont} % for identity operator\n\\newcommand{\\1}{\\mathds{1}}\n\n\n\\usepackage[inline]{enumitem} % for inline enumeration\n\n%%% figures\n\\usepackage{graphicx} % for figures\n\\usepackage{grffile} % help latex properly identify figure extensions\n\\usepackage[caption=false]{subfig} % subfigures (via \\subfloat[]{})\n\\graphicspath{{./figures/squeezing/}} % set path for all figures\n\n% for strikeout text\n% normalem included to prevent underlining titles in the bibliography\n\\usepackage[normalem]{ulem}\n\n% for leaving notes in the text\n\\newcommand{\\note}[1]{\\textcolor{red}{#1}}\n\n\n\n\\begin{document}\n\n\\title{Spin-orbit-coupling-induced squeezing in the optical lattice\n  clock}\n\n\\author{Michael A. Perlin}\n\n\\maketitle\n\nThese are some notes about trying to induce spin squeezing in an\noptical lattice clock by combining spin-orbit coupling, interactions,\nand external drives.  We assume, for now, that\n\\begin{enumerate*}[label=(\\roman*)]\n\\item atoms are fermionic in nature with an alkali-earth(-like)\n  electronic structure,\n\\item atoms are nuclear-spin-polarized, and\n\\item the optical lattice is quasi-one-dimensional, with tight\n  (i.e.~ground-state) confinement in transverse directions.\n\\end{enumerate*}\n\n\n\\section{Spin-orbit coupling}\n\nWe start with two-level atoms loaded into the ground band of an\noptical lattice, and consider interrogating these atoms by a linearly\npolarized plane-wave laser tuned to the relevant electronic (atomic)\ntransition, with wavenumber projection $\\phi$ onto the lattice axis.\nAfter performing a gauge transformation which shifts the on-axis\nmomenta of ground (excited) states by $\\phi/2$ ($-\\phi/2$), and\neliminating (i.e.~turning off) the interrogation laser, one can arrive\nat the Hamiltonian\n\\begin{align}\n  H_{\\t{SOC}}\n  = \\sum_{q,s} E_{qs\\phi} \\hat c_{qs}^\\dag \\hat c_{qs}\n  \\approx -2 J_0\\sum_{q,s} \\cos\\p{q+s\\phi/2}\n  \\hat c_{qs}^\\dag \\hat c_{qs}\n  \\label{eq:H_SOC_start}\n\\end{align}\nwhere $q$ indexes quasi-momentum along the lattice axis,\n$s\\in\\set{\\g\\leftrightarrow-1,\\e\\leftrightarrow1}$ labels the\nelectronic state, $J_0$ is the (positive) ground-band tunneling rate,\n$c_{q\\sigma}$ is a fermionic annihilation operator, and we work in\nunits with the lattice spacing $a=1$.  Defining\n\\begin{align}\n  \\1_q \\equiv \\hat c_{q,\\g}^\\dag \\hat c_{q,\\g}\n  + \\hat c_{q,\\e}^\\dag \\hat c_{q,\\e},\n  &&\n  \\sigma_q^j \\equiv \\sum_{\\alpha,\\beta}\n  \\hat c_{q\\alpha}^\\dag \\sigma^j_{\\alpha\\beta} \\hat c_{q\\beta},\n  \\label{eq:pseudospin}\n\\end{align}\nfor Pauli matrices $\\sigma^j$ (i.e.~such that $\\sigma_q^j$ is a\npseudo-spin-1/2 Pauli operator on the electronic degrees of freedom)\nand expanding the cosine in \\eqref{eq:H_SOC_start}, we thus find\n\\begin{align}\n  H_{\\t{SOC}}\n  = -\\sum_q \\p{\\epsilon_q \\1_q + \\f12 h_q \\sigma_q^z},\n  &&\n  \\epsilon_q \\equiv 2J_0 \\cos\\p{\\phi/2} \\cos q,\n  &&\n  h_q \\equiv -4J_0 \\sin\\p{\\phi/2} \\sin q.\n\\end{align}\nWhen all dynamics conserve the occupations of all quasi-momenta, the\nfirst term in this Hamiltonian merely contributes a constant energy\nshift which we can safely neglect, leaving us with the effective\ninhomogeneous-field Hamiltonian\n\\begin{align}\n  H_{\\t{SOC}} = -\\sum_q h_q s_q^z,\n  &&\n  s_q^z \\equiv \\f12 \\sigma_q^z\n  \\label{eq:H_SOC}\n\\end{align}\n\n\n\\section{Interactions}\n\nAt ultracold temperatures inter-atomic interactions are dominated by\n$s$-wave collisions, which are captured by the Hamiltonian\n\\begin{align}\n  H_{\\t{int}} = G \\int \\d^3x~\n  \\hat\\psi_\\e^\\dag\\p{x} \\hat\\psi_\\g^\\dag\\p{x}\n  \\hat\\psi_\\g\\p{x} \\hat\\psi_\\e\\p{x},\n  &&\n  G \\equiv \\f{4\\pi a_{\\e\\g^-}}{m_A},\n  \\label{eq:H_int_full}\n\\end{align}\nwhere $\\hat\\psi_\\sigma$ is a fermionic field operator for atoms in\nelectronic state $\\sigma\\in\\set{\\g,\\e}$, $a_{eg}^-$ is an scattering\nlength, and $m_A$ is the mass of a single atom.  Considering only\noccupation of the ground band in a lattice, we can expand the field\noperators as\n\\begin{align}\n  \\hat\\psi_\\sigma\\p{x} = \\sum_q \\phi_q\\p{x} \\hat c_{q\\sigma},\n\\end{align}\nfor momentum-space (Bloch) wavefunctions $\\phi_q$ and fermionic\nannihilation operators $\\hat c_{q\\sigma}$.  The interaction\nHamiltonian then becomes\n\\begin{align}\n  H_{\\t{int}} = G \\sum_{p,q,r,s} K^{pq}_{rs}\n  \\hat c_{r,\\e}^\\dag \\hat c_{s,\\g}^\\dag \\hat c_{q,\\g} \\hat c_{p,\\e},\n  &&\n  K^{pq}_{rs} \\equiv \\int \\d^3x~\n  \\phi_r\\p{x}^* \\phi_s\\p{x}^* \\phi_q\\p{x} \\phi_p\\p{x}.\n\\end{align}\nIn a lattice with $L$ sites centered on positions $x_j$ (i.e.~for\n$j=1,\\cdots L$ indexing lattice site) and localized (Wannier)\nwavefunctions $w_j$, we can expand\n$\\phi_p\\p{x}=L^{-1/2}\\sum_je^{-ipx_j}w_j\\p{x}$, which implies\n\\begin{align}\n  K^{pq}_{rs} = L^{-2} \\sum_{j,k,\\ell,m} \\int \\d^3x~\n  \\exp\\sp{-i\\p{px_j+qx_k-rx_\\ell-sx_m}}\n  w_\\ell\\p{x}^* w_m\\p{x}^* w_k\\p{x} w_j\\p{x}.\n\\end{align}\nIf we now assume that we can neglect integrals without $j=k=\\ell=m$,\nwhich is equivalent to neglecting inter-site interactions and\ninteraction-assisted hopping, then we have\n\\begin{align}\n  K^{pq}_{rs} \\approx L^{-2} \\sum_j \\int \\d^3x~\n  \\exp\\sp{-i\\p{p+q-r-s}x_j} \\abs{w_j\\p{x}}^4,\n\\end{align}\nwhere a stationary phase approximation now forces $p+q-r-s=0$ (mod\n$2\\pi$ in units with the lattice spacing $a=1$), which is equivalent\nto conservation of total momentum.  In terms of the Kronecker delta\n$\\delta_{p+q,r+s}$ enforcing $p+q=r+s$, it follows that\n\\begin{align}\n  K^{pq}_{rs} \\approx \\delta_{p+q,r+s} L^{-2}\n  \\sum_j \\int \\d^3x~ \\abs{w_j\\p{x}}^4\n  = \\delta_{p+q,r+s} L^{-1} \\int \\d^3x~ \\abs{w_0\\p{x}}^4,\n\\end{align}\nwhich motivates the definition\n\\begin{align}\n  U \\equiv G \\int \\d^3x~ \\abs{w_0\\p{x}}^4,\n\\end{align}\nin order to express the interaction Hamiltonian in the simple form\n\\begin{align}\n  H_{\\t{int}} = \\f{U}{L} \\sum_{p,q,r,s}\n  \\delta_{p+q,r+s} \\hat c_{r,\\e}^\\dag \\hat c_{s,\\g}^\\dag\n  \\hat c_{q,\\g} \\hat c_{p,\\e}.\n  \\label{eq:H_int_uniform}\n\\end{align}\n\n\n\\section{Collective spin model}\n\nIf the single-particle energy spacings are large compared to the\nstrength of inter-particle interactions, or equivalently if\n$J_0\\gtrsim U$, then by the secular approximation we can neglect terms\nin $H_{\\t{int}}$ which do not conserve the sum of single-particle\nenergies.  By solving this single-particle energy conservation\ncondition, one finds that we must have $\\set{p,q}=\\set{r,s}$; that is,\natoms in different clock states can only interact via\n\\begin{enumerate*}[label=(\\roman*)]\n\\item direct density-density terms, and\n\\item terms which exchange their momenta.\n\\end{enumerate*}\nThe surviving terms in \\eqref{eq:H_int_uniform} are thus\n\\begin{align}\n  H_{\\t{int}}\n  = \\f{U}{L} \\sum_{p,q}\n  \\p{\\hat c_{p,\\e}^\\dag \\hat c_{q,\\g}^\\dag \\hat c_{q,\\g} \\hat c_{p,\\e}\n    + \\hat c_{q,\\e}^\\dag \\hat c_{p,\\g}^\\dag \\hat c_{q,\\g} \\hat c_{p,\\e}}\n  = \\f{U}{L} \\sum_{p,q}\n  \\p{\\hat c_{q,\\g}^\\dag \\hat c_{q,\\g} \\hat c_{p,\\e}^\\dag \\hat c_{p,\\e}\n    - \\hat c_{q,\\e}^\\dag \\hat c_{q,\\g} \\hat c_{p,\\g}^\\dag \\hat c_{p,\\e}},\n\\end{align}\nwhere we can use the single-particle pseudo-spin-1/2 Pauli operators\nin \\eqref{eq:pseudospin} to write\n\\begin{align}\n  H_{\\t{int}} = \\f{U}{L} \\sum_{p,q}\n  \\sp{\\p{\\f{\\1_q-\\sigma_q^z}{2}} \\p{\\f{\\1_p+\\sigma_p^z}{2}}\n    - \\sigma_q^+ \\sigma_p^-}\n  = \\f{U}{L} \\sum_{p,q}\\f14\\p{\\1_q \\1_p - \\v\\sigma_q\\c\\v\\sigma_p},\n  \\label{eq:H_int_pauli}\n\\end{align}\nwith\n\\begin{align}\n  \\v{\\sigma}_p \\equiv \\p{\\sigma_p^x,\\sigma_p^y,\\sigma_p^z}.\n\\end{align}\nFor a fixed total particle number $N$, the identity operators in\n\\eqref{eq:H_int_pauli} contribute only a global shift in energy, which\nallows us to more simply write\n\\begin{align}\n  H_{\\t{int}} = - \\f{U}{L} \\v S\\c\\v S,\n  &&\n  \\v S \\equiv \\f12 \\sum_p \\v{\\sigma}_p.\n\\end{align}\nThis Hamiltonian has electronic eigenstates $\\set{\\ket{Sm}}$ with\ntotal (pseudo-)spin $S$ and projection $m$ onto a quantization axis;\nthe corresponding energies are\n$\\bk{Sm|H_{\\t{int}}|Sm}=-\\p{U/L}S\\p{S+1}$.  In particular, the\nground-state $S=N/2$ manifold is spanned by the Dicke states\n\\begin{align}\n  \\ket{m} \\equiv \\ket{N/2,m} \\propto S_+^{N/2+m} \\ket{\\g}^{\\otimes N},\n  &&\n  S_+ \\equiv \\sum_n \\sigma_n^+,\n  \\label{eq:dicke_states}\n\\end{align}\nwhere $n$ indexes an individual atom,\n$\\sigma_n^+\\equiv\\hat c_{n,\\e}\\hat c_{n,\\g}$ is an individual\nspin-raising operator, and $N/2+m=0,1,\\cdots,N$ is the number of\nelectronic state excitations in the state $\\ket{m}$\n\\cite{swallows2011suppression}.  In words, the Dicke state $\\ket{m}$\nis a uniform superposition of all states with $N/2+m$ total electronic\nexcitations.\n\n\n\\section{Spin squeezing and one-axis twisting}\n\\label{sec:OAT}\n\nIn total, free evolution of atoms on a lattice is governed by the\nHamiltonian\n\\begin{align}\n  H_{\\t{free}}\n  = H_{\\t{int}} + H_{\\t{SOC}}\n  = -\\f{U}{L} \\v S\\c\\v S - \\sum_n h_n s_n^z,\n\\end{align}\nfor $n$ indexing an individual atom.  When the ``local'' fields $h_n$\nare small in magnitude compared to the collective spin gap $\\eta U$\nand we initialize all atoms in the ground-state subspace of\n$H_{\\t{int}}$, we can treat the action of the spin-orbit coupling\nHamiltonian perturbatively, which yields the effective free-evolution\nHamiltonian (see Appendix \\ref{sec:squeezing_derivation} or Peiru's\nnotes)\n\\begin{align}\n  H_{\\t{free,eff}} = -\\bar h S_z + \\chi S_z^2,\n\\end{align}\nwhere\n\\begin{align}\n  \\bar h \\equiv \\f1N \\sum_n h_n,\n  &&\n  \\tilde h^2 \\equiv \\f1N \\sum_n \\p{h_n - \\bar h}^2,\n  &&\n  \\chi \\equiv \\f{\\tilde h^2}{\\p{N-1}\\eta U}.\n\\end{align}\nAt temperatures $T\\gg J_0$, the mean effective field $\\bar h=0$, while\nfor $T\\sim J_0$ the collective rotation due to the $S_z$ term can be\neliminated by use of a rotating frame.  The free-evolution Hamiltonian\nthus simplifies further to the one-axis twisting Hamiltonian\n\\begin{align}\n  H_{\\t{OAT}}^z = \\chi S_z^2,\n  \\label{eq:H_OAT}\n\\end{align}\nwhich generates spin squeezing dynamics with metrological\napplications.  Specifically, one-axis twisting allows for measurements\nof collective spin in the plane orthogonal to the mean spin vector\n$\\bk{\\v S}$ with a spin fluctuation noise floor which scales as\n$\\sim1/N^{2/3}$ (additional info in Peiru's notes\\note{(?)}).\n\nAn example set of parameters for realizing one-axis twisting via\n$H_{\\t{OAT}}^z$ with strontium-87 in a 1-D magic-wavelength lattice is\nprovided in Table \\ref{tab:parameters}, along with the optimal\nsqueezing time\n$t_{\\t{opt}}^{\\t{OAT}}\\sim N^{-2/3}\\chi^{-1}\\sim\\eta\nN^{1/3}=N^{4/3}/L$.  Lattice depths are provided in units of the\nlattice recoil energy $E_R$.\n\n\\begin{table}[h]\n  \\centering\n  \\caption{Example parameters for spin squeezing via one-axis\n    twisting.}\n  \\label{tab:parameters}\n  \\begin{tabular}{|l|c|l|}\n    \\hline\n    Parameter & Symbol & Value \\\\ \\hline\\hline\n    Primary lattice depth & $V_0$ & 5 $E_R$ \\\\\n    Transverse lattice depths & $V_T$ & 60 $E_R$ \\\\\n    SOC strength & $\\phi$ & $\\pi/25$ \\\\\n    Lattice sites & $L$ & 100 \\\\\n    Atom number & $N$ & 100 \\\\ \\hline\\hline\n    Tunneling rate & $J_0$ & $\\approx230\\times2\\pi$ Hz \\\\\n    On-site interaction strength & $U$ & $\\approx1.5\\times2\\pi$ kHz \\\\\n    Twisting strength & $\\chi$ & $\\approx11\\times2\\pi$ mHz \\\\\n    Optimal OAT squeezing time & $t_{\\t{opt}}^{\\t{OAT}}$\n    & $\\approx0.70$ seconds \\\\ \\hline\n  \\end{tabular}\n\\end{table}\n\n\n\\section{Two-axis twisting: continuous drive}\n\\label{sec:continuous_drive}\n\nWe can go beyond the $\\sim1/N^{2/3}$ one-axis twisting noise floor and\nachieve an improved $\\sim1/N$ noise floor via so-called two-axis\ntwisting, which can be achieved with external driving protocols.  By\nturning on a clock laser resonant on the electronic transition of the\natoms, we can realize the Hamiltonian\n\\begin{align}\n  H_{\\t{drive}} = -\\Omega \\sum_n s_n^x + H_{\\t{OAT}}^z\n  = -\\Omega S_x + \\chi S_z^2,\n\\end{align}\nwhere the drive strength $\\Omega$ may generally depend on time, but\nmust always be much smaller in magnitude than the collective spin gap\n$\\eta U$ in order preserve the validity of the effective one-axis\ntwisting Hamiltonian (see Appendix \\ref{sec:squeezing_derivation}).\nFollowing the prescription in ref.~\\cite{huang2015twoaxis} we now\nmodulate the drive as $\\Omega\\p{t}=\\beta\\omega\\cos\\p{\\omega t}$ with\n$\\omega\\gg N\\chi$, and move into the rotating frame of\n$-\\Omega\\p{t}S_x$.  After a single secular approximation which relies\nonly on $\\omega\\gg N\\chi$, this procedure results in the effective\nHamiltonian\n\\begin{align}\n  H_{\\t{drive,eff}}^{\\t{mod}}\n  = \\f{\\chi}{2} \\p{\\sp{\\J_0\\p{2\\beta}+1} S_z^2\n    - \\sp{\\J_0\\p{2\\beta}-1} S_y^2},\n\\end{align}\nwhere $\\J_0$ is the zero-order Bessel function of the first kind.\nChoosing a modulation index $\\beta$ such that $\\J_0\\p{2\\beta}=1/3$ or\n$\\J_0\\p{2\\beta}=-1/3$ then respectively results in the two-axis\ntwisting Hamiltonians\n\\begin{align}\n  H_{\\t{TAT}}^{z,x}\n  = \\f{\\chi}{3} \\p{2 S_z^2 + S_y^2}\n  \\simeq \\f{\\chi}{3} \\p{S_z^2 - S_x^2},\n  &&\n  H_{\\t{TAT}}^{y,x}\n  = \\f{\\chi}{3} \\p{S_z^2 + 2 S_y^2}\n  \\simeq \\f{\\chi}{3}\\p{S_y^2 - S_x^2},\n  \\label{eq:H_TAT_drive}\n\\end{align}\nwhere $\\simeq$ denotes equality up to a global energy shift.  Given\nthe set of parameters in Table \\ref{tab:parameters}, the two-axis\ntwisting Hamiltonian $H_{\\t{TAT}}^{z,x}$ can be achieved with a drive\nfrequency $\\omega=\\abs{\\eta U\\chi}^{1/2}\\approx41\\times2\\pi$ Hz and\nmodulation index $\\beta\\approx0.906$, and has an optimal squeezing\ntime of $t_{\\t{opt}}^{\\t{TAT}}\\approx0.89$ seconds.  The figure of\nmerit for squeezing is the normalized minimal variance of spin in the\nplane orthogonal to the mean spin vector $\\bk{\\v S}$:\n\\begin{align}\n  \\xi^2 \\equiv \\f{N}{\\abs{\\bk{\\v S}}^2}\n  \\min_{\\hat{\\v n}\\perp\\bk{\\v S}} \\bk{\\p{\\v S\\c\\hat{\\v n}}^2}\n\\end{align}\nfor $\\abs{\\hat{\\v n}}=1$.  A comparison of this squeezing parameter\nthrough $H_{\\t{OAT}}^z$ and $H_{\\t{TAT}}^{z,x}$ for the initial state\n$\\ket{Y}\\equiv\\bigotimes_n\\p{\\ket{\\g}_n+i\\ket{\\e}_n}/\\sqrt2$ via the\nparameters in Table \\ref{tab:parameters} is provided in Figure\n\\ref{fig:squeezing_comparison_TAT}.\n\n\\begin{figure}\n  \\centering \\includegraphics{squeezing_comparison_TAT.pdf}\n  \\caption{Comparison of squeezing through $H_{\\t{OAT}}^z$ and\n    $H_{\\t{TAT}}^{z,x}$ via the parameters in Table\n    \\ref{tab:parameters} and the continuous two-axis twisting protocol\n    with $\\omega\\approx\\abs{\\eta U\\chi}^{1/2}$ and $\\beta=0.906$.}\n  \\label{fig:squeezing_comparison_TAT}\n\\end{figure}\n\n\n\\section{Two-axis twisting: pulsed drive}\n\nTwo-axis twisting can also be achieved using the pulsed-drive sequence\ndescribed in ref.~\\cite{liu2011spin}.  This sequence requires the\ndrive strength $\\Omega$ much greater than the collective spin gap, or\n$\\abs{\\Omega}\\gg\\eta\\abs{U}$, which allows us to generate collective\nspin rotations of the form $\\exp\\p{\\pm i\\theta S_x}$ with short pulses\nduring which we can neglect any free evolution of the atoms.  Thus\n\\begin{enumerate*}[label=(\\roman*)]\n\\item acting with $\\exp\\sp{i\\p{\\pi/2}S_x}$,\n\\item waiting for a time $2\\tau/3$,\n\\item acting with $\\exp\\sp{-i\\p{\\pi/2}S_x}$, and\n\\item waiting for a time $\\tau/3$\n\\end{enumerate*}\nrealizes the unitary\n\\begin{align}\n  U_\\tau\n  &= \\exp\\p{-i\\f13\\tau\\chi S_z^2} \\exp\\p{-i\\f{\\pi}{2}S_x}\n  \\exp\\p{-i\\f23\\tau\\chi S_z^2} \\exp\\p{i\\f{\\pi}{2}S_x} \\\\\n  &= \\exp\\p{-i\\f13\\tau\\chi S_z^2} \\exp\\p{-i\\f23\\tau\\chi S_y^2},\n\\end{align}\nwhere if $\\tau\\chi\\ll1$, then\n\\begin{align}\n  U_\\tau \\approx \\exp\\sp{-i\\f13\\tau\\chi\\p{S_z^2 + 2S_y^2}}\n  = \\exp\\p{-i\\tau H_{\\t{TAT}}^{y,x}}.\n\\end{align}\nSuch a sequence thus generates evolution which is equivalent to simply\nevolving for a time $\\tau$ under the two-axis twisting Hamiltonian\n$H_{\\t{TAT}}^{y,x}$.\n\n\n\\section{Benchmarking}\n\nFor small system sizes, we can verify the validity of the effective\none- and two-axis twisting Hamiltonians via direct simulations of a\nsingle-band Fermi-Hubbard (FH) model, using the spin-orbit coupling\nHamiltonian $H_{\\t{SOC}}$ and interaction Hamiltonian $H_{\\t{int}}$\nrespectively given in \\eqref{eq:H_SOC_start} and\n\\eqref{eq:H_int_full}.  Figure \\ref{fig:squeezing_comparison_FH} shows\na comparison of the squeezing parameter $\\xi^2$ after evolution of the\ninitial state $\\ket{Y}$ for $N=8$ particles in a 1-D lattice with\n$L=8$ sites (and remaining system parameters as given in the top half\nof Table \\ref{tab:parameters}) after evolution under\n\\begin{enumerate*}[label=(\\roman*)]\n\\item the one-axis twisting Hamiltonian $H_{\\t{OAT}}^z$,\n\\item the two-axis twisting Hamiltonian $H_{\\t{OAT}}^{z,x}$,\n\\item free evolution of the Fermi-Hubbard model under\n  $H_{\\t{SOC}}+H_{\\t{int}}$, and\n\\item driven evolution of the Fermi-Hubbard model using the\n  continuous-drive protocol in Section \\ref{sec:continuous_drive} with\n  drive frequency $\\omega=\\abs{\\eta U\\chi}^{1/2}$ and modulation index\n  $\\beta=0.906$.\n\\end{enumerate*}\nThese simulation results show essentially perfect agreement between\nthe Fermi-Hubbard model and the one- and two-axis twisting\nHamiltonians for the given parameters.\n\n\\begin{figure}\n  \\centering\n  \\includegraphics{squeezing_comparison_FH.pdf}\n  \\caption{Benchmarking squeezing under the one- and two-axis\n    Hamiltonians $H_{\\t{OAT}}^z$ and $H_{\\t{TAT}}^{z,x}$ against\n    direct simulations of the Fermi-Hubbard model with $N=L=8$ and the\n    remaining system parameters as given in the top half of Table\n    \\ref{tab:parameters}.}\n  \\label{fig:squeezing_comparison_FH}\n\\end{figure}\n\n\n\\section{Last thoughts}\n\nIt may be possible to further enhance the twisting strength $\\chi$ by\nplacing the atoms in an optical cavity, as in\nref.~\\cite{hu2017vacuum}.  Both squeezing times and twisting strengths\nmight also be further enhanced by using a 2-D lattice, although more\nbenchmarking is necessary to verify the validity of the collective\nspin model in 2-D.  Figure \\ref{fig:squeezing_comparison_2D} shows a\ncomparison of squeezing strengths via one- and two-axis squeezing in a\n2-D lattice with $100\\times100$ sites.\n\n\\begin{figure}\n  \\centering\n  \\includegraphics{squeezing_comparison_2D.pdf}\n  \\caption{Squeezing via one- and two-axis twisting in a $V_0=7E_R$\n    depth 2-D lattice with $100\\times100$ sites at unit filling\n    ($N=10^4$), transverse confinement depth $V_T=80E_R$, and\n    spin-orbit coupling strength $\\phi=\\pi/25$.}\n  \\label{fig:squeezing_comparison_2D}\n\\end{figure}\n\n\n\\newpage\n\\appendix\n\n\\section{Effective spin squeezing in the presence of a weak drive}\n\\label{sec:squeezing_derivation}\n\nSuppose we have a Hamiltonian of the form\n\\begin{align}\n  H = H_0 + V,\n  &&\n  H_0 = - \\f{U}{L} \\v S\\c\\v S,\n  &&\n  V = - \\sum_n h_n s_n^z - \\Omega S_x,\n\\end{align}\nand we consider $N$-particle states initially in the ground-state\nmanifold $\\G_0$ of $H_0$, which have total spin $S\\equiv N/2$.  If the\nlargest eigenvalue of $V$ is smaller in magnitude than half of the\ncollective spin gap $N\\abs{U}/L=\\eta\\abs{U}$, i.e.~the energy gap\nunder $H_0$ between $\\G_0$ and its orthogonal complement $\\E_0$, then\nwe can formally develop a perturbative treatment for the action of $V$\non $\\G_0$.  Such a treatment yields an effective Hamiltonian on $\\G_0$\nof the form $H_{\\t{eff}}=\\sum_pH_{\\t{eff}}^{(p)}$, where\n$H_{\\t{eff}}^{(p)}$ is order $p$ in $V$.  Letting $\\P_0$ ($\\Q_0$) be a\nprojector onto $\\G_0$ ($\\E_0$) and $X$ denote any operator on\n$\\G_0\\cup\\E_0$ (i.e.~the entire Hilbert space), we define the\nsuperoperators\n\\begin{align}\n  \\D X \\equiv \\P_0 X \\P_0 + \\Q_0 X \\Q_0,\n  &&\n  \\O X \\equiv \\P_0 X \\Q_0 + \\Q_0 X \\P_0,\n\\end{align}\nwhich select the diagonal ($\\D$) and off-diagonal ($\\O$) parts of $X$\nwith respect to $\\G_0$ and $\\E_0$, and\n\\begin{align}\n  \\L X \\equiv \\sum_{\\alpha,\\beta}\n  \\f{\\op{\\alpha}\\O X\\op{\\beta}}{E_\\alpha-E_\\beta},\n  &&\n  \\t{where}\n  &&\n  H_0 = \\sum_\\alpha E_\\alpha \\op\\alpha.\n\\end{align}\nThe first few terms in the expansion of the effective Hamiltonian\n$H_{\\t{eff}}$ are then, as derived in\nref.~\\cite{bravyi2011schrieffer},\n\\begin{align}\n  H_{\\t{eff}}^{(0)} = \\P_0 H_0 \\P_0,\n  &&\n  H_{\\t{eff}}^{(1)} = \\P_0 V \\P_0,\n  &&\n  H_{\\t{eff}}^{(2)} = -\\f12 \\P_0 \\sp{\\O V,\\L V} \\P_0.\n  \\label{eq:H_eff_012}\n\\end{align}\nIf we add a constant to $H_0$ such that $E_\\psi=0$ for all\n$\\ket\\psi\\in\\G_0$, or equivalently we measure all energies relative to\nthat of the ground-state manifold $\\G_0$ with respect to $H_0$, it\nimmediately follows that $H_{\\t{eff}}^{(0)}=0$.  To calculate\n$H_{\\t{eff}}^{(1)}$, we note that the ground-state manifold $\\G_0$ is\nspanned by the Dicke states $\\ket{m}$ defined in\n\\eqref{eq:dicke_states}, in terms of which we can expand the\ncollective spin-$z$ operator as $S_z=\\sum_mm\\op{m}$.  We can likewise\nexpand the collective spin-$x$ operator $S_x$ in terms of $x$-oriented\nDicke states $\\ket{m_x}$ as $S_x=\\sum_mm\\op{m_x}$.  The ground-state\nprojector $\\P_0$ onto $\\G_0$ can be expanded in either basis as\n$\\P_0=\\sum_m\\op{m}=\\sum_m\\op{m_x}$.  Defining the mean and residual\nfields\n\\begin{align}\n  \\bar h \\equiv \\f1N \\sum_n h_n,\n  &&\n  b_n \\equiv h_n - \\bar h,\n\\end{align}\nwe can then write\n\\begin{align}\n  V = -\\sum_n \\p{b_n+\\bar h} s_n^z - \\Omega S_x\n  = -\\sum_n b_n s_n^z - \\bar h S_z - \\Omega S_x,\n\\end{align}\nand in turn\n\\begin{align}\n  H_{\\t{eff}}^{(1)}\n  = \\P_0\\p{-\\sum_n b_n s_n^z - \\bar h S_z - \\Omega S_x} \\P_0\n  = -\\sum_n b_n \\P_0 s_n^z\\P_0 - \\bar h S_z - \\Omega S_x,\n\\end{align}\nwhere we used the fact that $\\P_0 S_{j=z,x} \\P_0 = S_j$.  By\nconstruction, the residual fields are mean-zero, i.e.~$\\sum_nb_n=0$.\nUsing the particle-exchange symmetry of the Dicke states, we can thus\nexpand\n\\begin{align}\n  \\sum_n b_n \\P_0 s_n^z \\P_0\n  = \\sum_{n,m,m'} b_n \\op{m} s_n^z \\op{m'}\n  = \\sum_n b_n \\sum_{m,m'} \\op{m} s_1^z \\op{m'}\n  = 0,\n\\end{align}\nwhich implies\n\\begin{align}\n  H_{\\t{eff}}^{(1)} = - \\bar h S_z - \\Omega S_x.\n\\end{align}\nTo calculate the second-order effective Hamiltonian\n$H_{\\t{eff}}^{(2)}$, we let $\\B_0\\p{\\E_0}$ denote an eigenbasis of\n$H_0$ for the excited subspace $\\E_0$, define the operator\n\\begin{align}\n  \\I \\equiv \\sum_{\\ket\\alpha\\in\\B_0\\p{\\E_0}} \\f{\\op\\alpha}{E_\\alpha},\n\\end{align}\nwhich sums over projections onto excited states with corresponding\nenergetic suppression factors, and expand\n\\begin{align}\n  \\L X = \\O\\p{\\L X}\n  = \\Q_0 \\L X \\P_0 + \\P_0 \\L X \\Q_0\n  = \\I X \\P_0 - \\P_0 X \\I.\n\\end{align}\nThe expression for $H_{\\t{eff}}^{(2)}$ in \\eqref{eq:H_eff_012} then\nsimplifies to\n\\begin{align}\n  H_{\\t{eff}}^{(2)}\n  = -\\f12 \\P_0 \\p{\\sp{\\O V, \\I V \\P_0} - \\sp{\\O V, \\P_0 V \\I}} \\P_0\n  = -\\P_0 V \\I V \\P_0.\n\\end{align}\nThe only part of $V$ which is off-diagonal with respect to the ground-\nand excited-state manifolds $\\G_0$ and $\\E_0$ is $-\\sum_nb_ns_n^z$,\nand the individual operators in this term can only change the total\nspin $S$ by at most 1.  It is therefore sufficient to expand $\\I$ in a\nbasis for states with total spin $S=N/2-1$, which is provided by the\nspin-wave states\n\\begin{align}\n  \\ket{mk}\n  \\equiv \\ket{N/2-1,m,k}\n  \\equiv {N-1 \\choose \\p{N/2-m}\\p{N/2-m+1}}^{-1/2}\n  \\sum_{n=1}^N e^{2\\pi ikn/N} s_n^+ \\ket{N/2,m-1},\n\\end{align}\nfor $k=1,2,\\cdots,N-1$ \\cite{swallows2011suppression}.  Using the fact that all spin-$z$ operators preserve the projection of total spin onto the $z$ axis, we then have that\n\\begin{align}\n  H_{\\t{eff}}^{(2)}\n  = -\\f1{\\eta U} \\sum_{m,m',k,n,n'} b_n b_{n'}\n  \\Bk{m| s_n^z \\op{m'k} s_{n'}^z |m} \\op{m}.\n  \\label{eq:general_H_eff_2}\n\\end{align}\nThe relevant matrix elements between the Dicke states and the\nspin-wave states are \\cite{swallows2011suppression}\n\\begin{align}\n  \\bk{m|s_n^z|m'k}\n  = e^{2\\pi i k n/N} \\sqrt{\\f{(N/2)^2-m^2}{N^2 (N-1)}}~ \\delta_{m,m'},\n\\end{align}\nwhich implies\n\\begin{align}\n  H_{\\t{free,eff}}^{(2)}\n  = -\\f1{\\eta U} \\sum_m \\f{(N/2)^2-m^2}{N^2 (N-1)} \\op{m}\n  \\sum_{k,n,n'} b_n b_{n'} e^{2\\pi ik\\p{n-n'}/N}.\n\\end{align}\nUsing the fact that $\\sum_nb_n=0$, we can expand\n\\begin{align}\n  \\sum_{k,n,n'} b_n b_{n'} e^{2\\pi ik\\p{n-n'}/N}\n  = \\sum_{n,n'} b_n b_{n'} \\sum_{k=1}^{N-1} e^{2\\pi ik\\p{n-n'}/N}\n  = \\sum_{n,n'} b_n b_{n'} \\sum_{k=0}^{N-1} e^{2\\pi ik\\p{n-n'}/N},\n\\end{align}\nwhere the sum over $k$ vanishes for $n\\ne n'$ and equals $N$ when\n$n=n'$, so\n\\begin{align}\n  \\sum_{k,n,n'} b_n b_{n'} e^{2\\pi ik\\p{n-n'}/N}\n  = N \\sum_n b_n^2 = N^2 \\tilde h^2,\n  &&\n  \\tilde h^2 \\equiv \\f1N \\sum_n b_n^2 = \\f1N \\sum_n \\p{h_n - \\bar h}^2.\n  \\label{eq:sum_knn}\n\\end{align}\nWe therefore have that\n\\begin{align}\n  H_{\\t{free,eff}}^{(2)}\n  = -\\sum_m \\f{\\p{N/2}^2-m^2}{\\p{N-1}\\eta U}~ \\tilde h^2 \\op{m},\n\\end{align}\nwhere the term $\\p{N/2}^2$ term contributes a global energy shift\nwhich we can neglect, while the $m^2$ term is proportional to\n$m^2\\op{m}=S_z^2$.  In total, the effective Hamiltonian is thus\n\\begin{align}\n  H_{\\t{free,eff}} = - \\bar h S_z - \\Omega S_x + \\chi S_z^2,\n  &&\n  \\chi \\equiv \\f{\\tilde h^2}{\\p{N-1}\\eta U}.\n\\end{align}\n\n\\bibliography{\\jobname}\n\n\\end{document}\n", "meta": {"hexsha": "c46aa8ce3962fdb9d0b3677d0ab2f9094578eb9a", "size": 25661, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "soc_squeezing/soc_squeezing_notes.tex", "max_stars_repo_name": "perlinm/rey_research", "max_stars_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "soc_squeezing/soc_squeezing_notes.tex", "max_issues_repo_name": "perlinm/rey_research", "max_issues_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "soc_squeezing/soc_squeezing_notes.tex", "max_forks_repo_name": "perlinm/rey_research", "max_forks_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9039881832, "max_line_length": 173, "alphanum_fraction": 0.6857877713, "num_tokens": 9282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6261241911813151, "lm_q1q2_score": 0.43987106396713577}}
{"text": "\n\\documentclass{article}\n\\usepackage[intlimits]{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts,amstext,amsthm}\n\\usepackage{paralist}        % {inparaenum} environment\n\\usepackage{mathtools}       % {dcases} environment\n\\usepackage{wasysym}         % \\clock\n\\usepackage[normalem]{ulem}  % \\sout\n\\usepackage[usenames,dvipsnames]{xcolor} % Named colors\n\\usepackage{hyperref}\n\\usepackage{booktabs}\n\\usepackage[margin=2.5cm]{geometry}\n\n\\usepackage{tikz}\n\\usetikzlibrary{arrows.meta}\n\\usetikzlibrary{decorations.pathmorphing}\n\\usetikzlibrary{patterns}\n\n% ~~ Styling ~~\n\\renewcommand{\\geq}{\\geqslant}\n\\renewcommand{\\leq}{\\leqslant}\n\n\\newcommand{\\ignore}[1]{}\n\\newcommand{\\nolabel}[1]{}\n\\newcommand{\\set}[1]{\\left\\{ #1 \\right\\}}\n% Set with condition and automatically scaled braces: {... | ...}.\n\\newcommand{\\cset}[3][:]{\\left\\{#2 \\,#1\\, #3\\right\\}}\n\n\\renewcommand{\\Pr}{{\\sf P}}           % Probability measure.\n\\DeclareMathOperator{\\EV}{{\\sf E}}    % Expected value.\n\\DeclareMathOperator{\\Var}{{\\sf Var}} % Variance.\n\\DeclareMathOperator{\\Cov}{{\\sf Cov}} % Covariance.\n\\DeclareMathOperator{\\SE}{{\\sf SE}}   % Standard error.\n\\DeclareMathOperator{\\Hyp}{\\mathcal{H}}\n\\DeclareMathOperator{\\DNormal}{\\mathcal{N}} % Normal distribution.\n\n% ~~ Linear Algebra ~~\n\\renewcommand{\\vec}[1]{\\boldsymbol{#1}}\n\\newcommand{\\One}{\\mathchoice{\\rm 1\\mskip-4.2mu l}{\\rm 1\\mskip-4.2mu l}{\\rm 1\\mskip-4.6mu l}{\\rm 1\\mskip-5.2mu l}}\n\\newenvironment{algorithm}[1][]{\\paragraph*{Algorithm#1.}}{\\vspace{1ex}}\n\n% ~~ Paper-specific ~~\n\\newcommand{\\hlambda}{\\hat{\\lambda}}\n\\newcommand{\\hmu}{\\hat{\\mu}}\n\\newcommand{\\htau}{\\hat{\\tau}}\n\\newcommand{\\ESS}{\\mathrm{ESS}}\n\\newcommand{\\PFA}{\\mathrm{PFA}}\n\\newcommand{\\PMS}{\\mathrm{PMS}}\n\\newcommand{\\PrFA}{\\Pr _\\mathrm{FA}}\n\\newcommand{\\PrMS}{\\Pr _\\mathrm{MS}}\n\n% Styling.\n\\hypersetup{\n    colorlinks=true,%\n    bookmarksnumbered=true,%\n    bookmarksopen=true,%\n    citecolor=blue,%\n    urlcolor=blue,%\n    unicode=true,           % enable unicode encoded PDF strings\n    breaklinks=true         % allow links to break over lines by making\n                            % links over multiple lines into PDF\n                            % links to the same target\n}\n\n\\begin{document}\n\n\n\\section*{Formulation.}\n\nThe objective of this project is to simulate target detection in a noisy environment.\nThe signal, $S_n$, $n \\geq 1$, is assumed to be known and deterministic.\nTo model the environment we assume additive i.i.d.\\ standard Gaussian noise $W_n$.\nThe observed process $X_n$, $n \\geq 1$, is defined by\n\\begin{align*} \\nolabel{eq:observed_process}\n    X_n = \\mu S_n + W_n,\n\\end{align*}\nwhere $\\mu$ is unknown (representing signal strength).\n%Note that $X_n$ are independent $\\DNormal(\\mu S_n, 1)$.\n\nWe are now in position to formulate the hypothesis testing problem.\n%\nLet $\\mu_0 = 0$, and $\\mu_1 > \\mu_0$ be given. We are interested in testing\n\\begin{align} \\label{eq:model}\n    \\Hyp_0 : \\mu = \\mu_0\n    \\quad \\text{vs.} \\quad\n    \\Hyp_1 : \\mu \\geq \\mu_1.\n\\end{align}\nIn what follows we will also need to introduce auxiliary hypotheses $\\set{\\Hyp_\\theta : \\mu = \\theta }$.\n%\nIt is not hard to see that the log-likelihood ratio (LLR) process between $\\Hyp_\\mu$ and $\\Hyp_{\\mu'}$ has the form\n\\begin{align} \\label{eq:LLR:general}\n    \\lambda_n(\\mu, \\mu')\n        &= (\\mu - \\mu') \\sum_{i = 1}^{n} S_i X_i\n        - \\frac{\\mu^2 - {\\mu'}^2}{2} \\sum_{i = 1}^{n} S_i^2.\n\\end{align}\n\n\\section*{Estimation and Stopping.}\n\nLet $\\hmu_n$ denote the unconstrained maximum likelihood estimator (MLE) of $\\mu$:\n\\begin{align*} \\nolabel{eq:mle:unconstrained}\n    \\hmu_n &= \\max\\set{0, \\frac{\\sum_{i = 1}^n S_i X_i}{\\sum_{i = 1}^n S_i^2}}.\n\\end{align*}\nFurthermore, let $\\hmu_{n, j}$ be the constrained MLE's under $\\Hyp_j$, $j = 0, 1$:\n\\begin{align*} \\nolabel{eq:mle:constrained}\n    \\hmu_{n, 0} = \\mu_0 = 0, \\quad\n    \\hmu_{n, 1} = \\max \\set{\\mu_1, \\hmu_n}.\n\\end{align*}\n\nThe adaptive versions of log-likelihood ratio \\eqref{eq:LLR:general} are given by\n\\begin{align} \\label{eq:LLR:adaptive}\n    \\hlambda_{n, j}\n        &= \\sum_{i = 1}^{n} (\\hmu_{i - 1} - \\hmu_{n, j}) S_i X_i\n        - \\frac{1}{2} \\sum_{i = 1}^{n} (\\hmu_{i - 1}^2 - \\hmu_{n, j}^{2}) S_i^2 \\\\\n        %&= \\sum_{i = 1}^{n} \\hmu_{i - 1} S_i (X_i - \\hmu_{i - 1} S_i / 2)\n        %- \\hmu_{n, j} \\sum_{i = 1}^{n} S_i X_i\n        %+ \\frac{\\hmu_{n, j}^2}{2} \\sum_{i = 1}^{n} S_i^2 \\nonumber \\\\\n        &= \\sum_{i = 1}^{n} \\hmu_{i - 1} S_i (X_i - \\hmu_{i - 1} S_i / 2)\n        + \\lambda_n(0, \\hmu_{n, j}) \\nonumber\n\\end{align}\nfor $j = 0, 1$. The initial estimator $\\hmu_0$ is chosen differently for $\\hlambda_{n, 0}$ and $\\hlambda_{n, 1}$, so that $\\hlambda_{1, 0} = \\hlambda_{1, 1} = 0$.\n\nWe consider the following decision rules.\nThe stopping time of the adaptive two-SPRT detection procedure is $\\htau = \\min\\set{\\htau_0,\\htau_1}$, where\n\\begin{align} \\label{eq:sprt:adaptive}\n    \\begin{split}\n        \\htau_0 &= \\inf \\cset{n \\geq 1}{\\hlambda_{n, 1} \\geq a_0}, \\\\\n        \\htau_1 &= \\inf \\cset{n \\geq 1}{\\hlambda_{n, 0} \\geq a_1}.\n    \\end{split}\n\\end{align}\nThe stopping time of the generalized two-SPRT detection procedure is $\\tau = \\min\\set{\\tau_0,\\tau_1}$, where\n\\begin{align} \\label{eq:sprt:adaptive}\n    \\begin{split}\n        \\tau_0 &= \\inf \\cset{n \\geq 1}{\\lambda_n(\\hmu_n, \\hmu_{n, 1}) \\geq a_0}, \\\\\n        \\tau_1 &= \\inf \\cset{n \\geq 1}{\\lambda_n(\\hmu_n, \\hmu_{n, 0}) \\geq a_1}.\n    \\end{split}\n\\end{align}\n\n\n\\paragraph*{Change of measure.}\nSuppose $(t, d)$ is the decision rule, and let\n\\begin{align*}\n    \\PFA &= \\Pr_{\\mu_0} (d \\neq 0), \\\\\n    \\PMS &= \\sup_{\\mu \\geq \\mu_1} \\Pr_{\\mu} (d \\neq 1) = \\Pr_{\\mu_1} (d \\neq 1)\n\\end{align*}\ndenote the probability of false alarm and probability of missed signal, respectively.\nTo facilitate assessing error probabilities, we employ the change of measure approach. Expected sample sizes $\\ESS_j = \\EV_{\\mu_j}(t)$, $j = 0, 1$, do not require importance sampling. The following table summarizes the strategies (simulated signal strength vs.\\ analyzed signal strength) in use:\n\\begin{center}\n    \\begin{tabular}{@{} l l l @{}} \\toprule\n                  & \\multicolumn{2}{c}{Analyzed} \\\\ \\cmidrule{2-3}\n        Simulated & $\\mu_0$           & $\\mu_1$         \\\\ \\midrule\n        $\\mu_0$   & $\\ESS_0$          & $\\PMS $         \\\\\n        $\\mu_1$   & $\\PFA $           & $\\ESS_1$        \\\\ \\bottomrule\n    \\end{tabular}\n\\end{center}\n\n\n\\end{document}\n", "meta": {"hexsha": "dc8613fb2be8c7acea5ba39b2a5f0bfc5ea9959e", "size": 6360, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/gaussian_mean_hypotheses.tex", "max_stars_repo_name": "ropufu/sequential", "max_stars_repo_head_hexsha": "67163cf1accf967c8bf91b6700c1d5f97d1a7e0a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documentation/gaussian_mean_hypotheses.tex", "max_issues_repo_name": "ropufu/sequential", "max_issues_repo_head_hexsha": "67163cf1accf967c8bf91b6700c1d5f97d1a7e0a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/gaussian_mean_hypotheses.tex", "max_forks_repo_name": "ropufu/sequential", "max_forks_repo_head_hexsha": "67163cf1accf967c8bf91b6700c1d5f97d1a7e0a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0, "max_line_length": 295, "alphanum_fraction": 0.6316037736, "num_tokens": 2325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4398710541647257}}
{"text": "\\documentclass[twoside,10pt,a4paper]{article}\n\\input{macros.tex}\n\n% For adding \"DRAFT\" to each page uncomment the following\n% --------\n\\usepackage{eso-pic}\n\\makeatletter\n\\AddToShipoutPicture{%\n  \\setlength{\\@tempdimb}{.5\\paperwidth}%\n  \\setlength{\\@tempdimc}{.5\\paperheight}%\n  \\setlength{\\unitlength}{1pt}%\n  \\put(\\strip@pt\\@tempdimb,\\strip@pt\\@tempdimc){%\n    \\makebox(0,0){\\rotatebox{45}{\\textcolor[gray]{0.9}%\n      {\\fontsize{6cm}{6cm}\\selectfont{DRAFT}}}}%\n  }%\n}\n\\makeatother\n% --------\n\n\\begin{document}\n\\DeclareGraphicsExtensions{.jpg,.pdf}\n\n\\title{Cam-Clay model based on Borja et al. 1997}\n\\author{Biswajit Banerjee}\n\\maketitle\n\\tableofcontents\n\\newpage\n\n\\section{Introduction}\nIntroduce the equations and how they differ from Fossum-Brannon.\n\n\\section{Quantities that are needed in a Uintah implementation}\n\\subsection{Elasticity}\nThe elastic strain energy density in Borja's model has the form\n\\[\n  W(\\Ve^e_v,\\Ve^e_s) = W_\\Tvol(\\Ve^e_v) + W_\\Tdev(\\Ve^e_v, Ve^e_s)\n\\]\nwhere\n\\[\n   \\Bal\n    W_\\Tvol(\\Ve^e_v) & = -p_0\\kappatilde\\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \\\\\n    W_\\Tdev(\\Ve^e_v,\\Ve^e_s) & =  \\tfrac{3}{2}\\,\\mu\\,(\\Ve^e_s)^2\n   \\Eal\n\\]\nwhere $\\Ve^e_{v0}$ is the volumetric strain corresponding to a mean normal compressive stress $p_0$ \n(tension positive), $\\kappatilde$ is the elastic compressibility index, and the shear modulus is given by\n\\[\n  \\mu = \\mu_0 + \\frac{\\alpha}{\\kappatilde}\\,W_\\Tvol(\\Ve^e_v) \n      = \\mu_0 - \\alpha p_0\\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \n      = \\mu_0 - \\mu_\\Tvol\\,.\n\\]\nThe parameter $\\alpha$ determines the extent of coupling between the volumetric and deviatoric \nresponses.  For consistency with isotropic elasticity, Rebecca Brannon suggests that $\\alpha = 0$ (citation?). \n\nThe stress invariants $p$ and $q$ are defined as\n\\[\n  \\Bal\n    p &= \\Partial{W}{\\Ve^e_v} = p_0\\left[1 + \\tfrac{3}{2}\\,\\frac{\\alpha}{\\kappatilde}\\,(\\Ve^e_s)^2\\right]\n         \\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \n       = p_0\\,\\beta\\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \\\\\n    q &= \\Partial{W}{\\Ve^e_s} = 3\\left[\\mu_0 - \\alpha p_0\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \n         \\right]\\Ve^e_s  = 3\\mu\\,\\Ve^e_s\\,.\n  \\Eal\n\\]\nThe derivatives of the stress invariants are\n\\[\n  \\Bal\n    \\Partial{p}{\\Ve^e_v} & = -\\frac{p_0}{\\kappatilde}\n         \\left[1 + \\tfrac{3}{2}\\,\\frac{\\alpha}{\\kappatilde}\\,(\\Ve^e_s)^2\\right]\n         \\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \n        = -\\frac{p}{\\kappatilde} \\\\\n    \\Partial{p}{\\Ve^e_s} & = \\Partial{q}{\\Ve^e_v} = \\frac{3\\alpha p_0 \\Ve^e_s}{\\kappatilde}\n         \\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) = \\frac{3\\alpha p}{\\beta \\kappatilde}\\,\\Ve^e_s \n         = \\frac{3\\mu_\\Tvol}{\\kappatilde}\\,\\Ve^e_s\\\\\n    \\Partial{q}{\\Ve^e_s} & = 3 \\left[\\mu_0 - \\alpha p_0\n         \\,\\exp\\left(-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right) \\right] = 3 \\mu\\,.\n  \\Eal\n\\]\n\n\\subsection{Plasticity}\nFor plasticity we use a Cam-Clay yield function of the form\n\\[\n   f = \\left(\\frac{q}{M}\\right)^2 + p(p-p_c) \n\\]\nwhere $M$ is the slope of the critical state line and the consolidation pressure $p_c$ is an internal variable that \nevolves according to \n\\[\n   \\frac{1}{p_c}\\,\\Deriv{p_c}{t} = \\frac{1}{\\lambdatilde - \\kappatilde}\\,\\Deriv{\\Ve^p_v}{t} \\,.\n\\]\nThe derivatives of $f$ that are of interest are\n\\[\n   \\Bal\n     \\Partial{f}{p} & = 2p - p_c \\\\\n     \\Partial{f}{q} & = \\frac{2q}{M^2} \\,.\n   \\Eal\n\\]\nIf we integrate the equation for $p_c$ from $t_{n}$ to $t_{n+1}$, we can show that\n\\[\n   (p_c)_{n+1} = (p_c)_n \\exp\\left[\\frac{(\\Ve_v^e)_\\Trial - (\\Ve_v^e)_{n+1}}{\\lambdatilde - \\kappatilde}\\right] \\,.\n\\]\nThe derivative of $p_c$ that is of interest is\n\\[\n   \\Partial{p_c}{(\\Ve_v^e)_{n+1}} = -\\frac{(p_c)_n}{\\lambdatilde-\\kappatilde}\\,\\exp\\left[\\frac{(\\Ve^e_v)_\\Trial - (\\Ve_v^e)_{n+1}}{\\lambdatilde-\\kappatilde}\\right] \\,.\n\\]\n\n\\section{Why these quantities are needed: stress update based Rich Reguiero's notes}\nThe volumetric and deviatoric components of the elastic strain $\\Beps^e$ are defined\nas follows:\n\\[\n   \\BeT^e = \\Beps^e - \\tfrac{1}{3}\\Ve^e_v\\,\\Bone = \\Beps^e - \\tfrac{1}{3}\\Tr(\\Beps^e)\\,\\Bone\n   \\quad \\Tand \\quad\n   \\Ve^e_s = \\sqrt{\\tfrac{2}{3}}\\Norm{\\BeT^e}{}  = \\sqrt{\\tfrac{2}{3}}\\sqrt{\\BeT^e:\\BeT^e} \\,.\n\\]\nThe stress tensor is decomposed into a volumetric and a deviatoric component\n\\[\n   \\Bsig = p\\,\\Bone + \\sqrt{\\tfrac{2}{3}}\\, q\\, \\BnT \\quad \\text{with} \\quad\n   \\BnT = \\cfrac{\\BeT^e}{\\Norm{\\BeT^e}{}} = \\sqrt{\\tfrac{2}{3}}\\, \\cfrac{\\BeT^e}{\\Ve^e_s} \\,.\n\\]\nThe models used to determine $p$ and $q$ are\n\\[\n  \\Bal\n    p &= p_0\\beta\\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right] \\quad \\text{with} \\quad\n     \\beta = 1 + \\tfrac{3}{2}\\,\\frac{\\alpha}{\\kappatilde}\\,(\\Ve^e_s)^2 \\\\\n    q &= 3\\mu\\Ve^e_s \\,.\n  \\Eal\n\\]\nThe strains are updated using\n\\[\n  \\Beps^e = \\Beps^e_{\\rm trial} - \\Delta\\gamma\\,\\Partial{f}{\\Bsig}\n  \\quad \\text{where} \\quad \\Beps^e_{\\rm trial} = \\Beps^e_n + \\Delta\\Beps\n     = \\Beps^e_n + (\\Beps - \\Beps_n) \\,.\n\\]\n\n{\\footnotesize\n{\\bf Remark 1:}  The interface with MPMICE, among other things in Uintah, requires the \ncomputation of the quantity $dp/dJ$.  Since $J$ does not appear in the above equation we\nproceed as explained below.\n\\[\n  \\Bal\n   J & = \\det(\\BF) = \\det(\\Bone + \\GradX{\\Bu}) = \\det(\\Bone + \\Beps) \\\\\n     & = 1 + \\Tr\\Beps + \\Half\\left[(\\Tr\\Beps)^2 - \\Tr(\\Beps^2)\\right] + \\det(\\Beps) \\,.\n     & = 1 + \\Ve_v + \\Half\\left[\\Ve_v^2 - \\Tr(\\Beps^2)\\right] + \\det(\\Beps) \\,.\n  \\Eal\n\\]\nAlso,\n\\[\n   J = \\frac{\\rho_0}{\\rho} = \\frac{V}{V_0} \\quad \\Tand \\quad\n   \\Ve_v = \\frac{V-V_0}{V_0} = \\frac{V}{V_0} - 1 = J - 1 \\,.\n\\]\nWe use the relation $J = 1 + \\Ve_v$ while keeping in mind that this is {\\em true only for\ninfinitesimal strains and plastic incompressibility} for which \n$\\Ve_v^2$, $\\Tr(\\Beps^2)$, and $\\det(\\Beps)$ are zero.  Under these conditions\n\\[\n   \\Partial{p}{J} = \\Partial{p}{\\Ve_v}\\,\\Partial{\\Ve_v}{J} = \\Partial{p}{\\Ve_v} \\quad \\Tand \n   \\quad\n   \\Partial{p}{\\rho} = \\Partial{p}{\\Ve_v}\\,\\Partial{\\Ve_v}{J}\\,\\Partial{J}{\\rho} \n      = -\\frac{J}{\\rho}\\,\\Partial{p}{\\Ve_v} \\,.\n\\]\n\n{\\bf Remark 2:} MPMICE also needs the density at a given pressure.  For the Borja model, with\n$\\Ve_v = J-1 = \\rho_0/\\rho -1$, we have\n\\[\n  \\rho = \\rho_0\\left[1 + \\Ve_{v0} + \\kappatilde\\ln\\left(\\frac{p}{p_0\\beta}\\right)\\right]^{-1}\\,.\n\\]\n\n{\\bf Remark 3:}  The quantity $q$ is related to the deviatoric part of the Cauchy stress, $\\BsT$\nas follows:\n\\[\n   q = \\sqrt{3J_2} \\quad \\text{where} \\quad J_2 = \\Half\\,\\BsT:\\BsT \\,.\n\\]\nThe shear modulus relates the deviatoric stress $\\BsT$ to the deviatoric strain $\\BeT^e$.  We\nassume a relation of the form\n\\[\n   \\BsT = 2\\mu\\BeT^e \\,.\n\\]\nNote that the above relation assumes a linear elastic type behavior.  Then we get the Borja \nshear model:\n\\[\n  q = \\sqrt{\\tfrac{3}{2}\\,\\BsT:\\BsT} = \\sqrt{\\tfrac{3}{2}}\\,(2\\mu)\\,\\sqrt{\\BeT^e:\\BeT^e}\n     = \\sqrt{\\tfrac{3}{2}}\\,(2\\mu)\\,\\sqrt{\\tfrac{3}{2}}\\,\\Ve^e_s = 3\\mu\\Ve^e_s \\,.\n\\]\n}\n\n\n\n\\subsection{Elastic-plastic stress update}\nFor elasto-plasticity we start with a yield function of the form\n\\[\n   f = \\left(\\frac{q}{M}\\right)^2 + p(p-p_c) \\le 0 \n   \\quad \\text{where} \\quad\n  \\frac{1}{p_c}\\,\\Deriv{p_c}{t} = \\frac{1}{\\lambdatilde- \\kappatilde}\\,\\Deriv{\\Ve_v^p}{t} \\,.\n\\]\nIntegrating the ODE for $p_c$ with the initial condition $p_c(t_n) = (p_c)_n$, at $t = t_{n+1}$, \n\\[\n   (p_c)_{n+1} = (p_c)_n \\exp\\left[\\frac{(\\Ve_v^p)_{n+1} - (\\Ve_v^p)_n}{\\lambdatilde - \\kappatilde}\\right] \\,.\n\\]\nFrom the additive decomposition of the strain into elastic and plastic parts, and if the elastic trial \nstrain is defined as \n\\[\n   (\\Ve_v^e)_\\Trial := (\\Ve_v^e)_n + \\Delta\\Ve_v\n\\]\nwe have\n\\[\n   \\Ve_v^p = \\Ve_v - \\Ve_v^e \\quad \\implies \\quad\n   (\\Ve_v^p)_{n+1} - (\\Ve_v^p)_n = (\\Ve_v)_{n+1} - (\\Ve_v^e)_{n+1} - (\\Ve_v)_{n} + (\\Ve_v^e)_{n} \n                               = \\Delta\\Ve_v + (\\Ve_v^e)_{n} - (\\Ve_v^e)_{n+1} \n                               = (\\Ve_v^e)_\\Trial - (\\Ve_v^e)_{n+1} \\,.\n\\]\nTherefore we can write\n\\[\n   (p_c)_{n+1} = (p_c)_n \\exp\\left[\\frac{(\\Ve_v^e)_\\Trial - (\\Ve_v^e)_{n+1}}{\\lambdatilde - \\kappatilde}\\right] \\,.\n\\]\nThe flow rule is assumed to be given by\n\\[\n   \\Partial{\\Beps^p}{t} = \\gamma\\,\\Partial{f}{\\Bsig} \\,.\n\\]\nIntegration of the PDE with backward Euler gives\n\\[\n  \\Beps^p_{n+1} = \\Beps^p_n + \\Delta t\\,\\gamma_{n+1}\\,\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \n             = \\Beps^p_n + \\Delta\\gamma\\,\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \\,.\n\\]\nThis equation can be expressed in terms of the trial elastic strain as follows.\n\\[\n  \\Beps_{n+1}-\\Beps^e_{n+1} = \\Beps_n - \\Beps^e_n + \\Delta\\gamma\\,\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \n\\]\nor\n\\[\n  \\Beps^e_{n+1} = \\Delta\\Beps + \\Beps^e_n - \\Delta\\gamma\\,\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \n             = \\Beps^e_\\Trial - \\Delta\\gamma\\,\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \\,.\n\\]\nIn terms of the volumetric and deviatoric components\n\\[\n  (\\Ve_v^e)_{n+1} = \\Tr(\\Beps^e_{n+1}) = \\Tr(\\Beps^e_\\Trial) - \\Delta\\gamma\\,\\Tr\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} = (\\Ve_v^e)_\\Trial - \\Delta\\gamma\\,\\Tr\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \n\\]\nand\n\\[\n  \\BeT^e_{n+1} = \\BeT^e_\\Trial - \\Delta\\gamma\\,\\left[\\left(\\Partial{f}{\\Bsig}\\right)_{n+1}\n      - \\tfrac{1}{3}\\,\\Tr\\left(\\Partial{f}{\\Bsig}\\right)_{n+1}\\Bone\\right] \\,.\n\\]\nWith $\\BsT = \\Bsig - p\\Bone$, we have\n\\[\n  \\Partial{f}{\\Bsig} = \\Partial{f}{\\BsT}:\\Partial{\\BsT}{\\Bsig} + \\Partial{f}{p}\\,\\Partial{p}{\\Bsig}\n    = \\Partial{f}{\\BsT}:[\\SfI^{(s)} - \\tfrac{1}{3}\\,\\Bone\\otimes\\Bone] \n      + \\Partial{f}{p}\\,\\Bone\n    = \\Partial{f}{\\BsT} - \\tfrac{1}{3}\\,\\Tr\\left[\\Partial{f}{\\BsT}\\right]\\Bone\n      + \\Partial{f}{p}\\,\\Bone\n\\]\nand\n\\[\n  \\tfrac{1}{3}\\,\\Tr\\left[\\Partial{f}{\\Bsig}\\right]\\Bone = \n    \\tfrac{1}{3}\\left(\\Tr\\left[\\Partial{f}{\\BsT}\\right] - \\Tr\\left[\\Partial{f}{\\BsT}\\right]\n      + 3\\Partial{f}{p}\\right)\\Bone  =  \\Partial{f}{p}\\,\\Bone \\,.\n\\]\n\n{\\footnotesize\n{\\bf Remark 4:}  Note that, because $\\Bsig = \\Bsig(p, q, p_c)$ the \nchain rule should contain a contribution from $p_c$:\n\\[\n  \\Partial{f}{\\Bsig} = \\Partial{f}{q}\\,\\Partial{q}{\\Bsig} + \\Partial{f}{p}\\,\\Partial{p}{\\Bsig}\n                       + \\Partial{f}{p_c}\\,\\Partial{p_c}{\\Bsig} \\,.\n\\]\nHowever, the Borja implementation does not consider that extra term.  Also note that for the present model\n\\[\n  \\Bsig = \\Bsig(p(\\Ve^e_v,\\Ve^e_s,\\Ve^p_v, \\Ve^p_s), \\BsT(\\Ve^e_v, \\Ve^e_s, \\Ve^p_v,\\Ve^p_s), p_c(\\Ve^p_v))\n\\]\n}\n\nTherefore, for situations where $\\Tr(\\partial f/\\partial \\BsT) = \\Bzero$, we have\n\\[\n  \\Partial{f}{\\Bsig} - \\tfrac{1}{3}\\,\\Tr\\left[\\Partial{f}{\\Bsig}\\right]\\Bone = \n     \\Partial{f}{\\BsT} - \\tfrac{1}{3}\\,\\Tr\\left[\\Partial{f}{\\BsT}\\right]\\Bone =\n     \\Partial{f}{\\BsT} \\,.\n\\]\nThe deviatoric strain update can be written as\n\\[\n  \\BeT^e_{n+1} = \\BeT^e_\\Trial - \\Delta\\gamma\\,\\left(\\Partial{f}{\\BsT}\\right)_{n+1} \n\\]\nand the shear invariant update is\n\\[\n  (\\Ve_s^e)_{n+1} = \\sqrt{\\tfrac{2}{3}}\\,\n  \\sqrt{\\BeT^e_{n+1}:\\BeT^e_{n+1}}\n  = \\sqrt{\\tfrac{2}{3}}\\,\\sqrt{\\BeT^e_\\Trial:\\BeT^e_\\Trial \n     - 2\\Delta\\gamma\\,\\left[\\Partial{f}{\\BsT}\\right]_{n+1}:\\BeT^e_\\Trial\n     + (\\Delta\\gamma)^2\\left[\\Partial{f}{\\BsT}\\right]_{n+1}:\\left[\\Partial{f}{\\BsT}\\right]_{n+1}}\n\\]\nThe derivative of $f$ can be found using the chain rule (for smooth $f$):\n\\[\n   \\Partial{f}{\\Bsig} = \\Partial{f}{p}\\,\\Partial{p}{\\Bsig} + \\Partial{f}{q}\\,\\Partial{q}{\\Bsig}\n     = (2p - p_c)\\,\\Partial{p}{\\Bsig} + \\frac{2q}{M^2}\\,\\Partial{q}{\\Bsig} \\,.\n\\]\nNow, with $p = 1/3\\,\\Tr(\\Bsig)$ and $q = \\sqrt{3/2\\,\\Bs:\\Bs}$, we have\n\\[\n  \\Bal\n   \\Partial{p}{\\Bsig} & = \\Partial{}{\\Bsig}\\left[\\tfrac{1}{3}\\,\\Tr(\\Bsig)\\right] = \\tfrac{1}{3}\\,\\Bone \\\\\n   \\Partial{q}{\\Bsig} & = \\Partial{}{\\Bsig}\\left[\\sqrt{\\tfrac{3}{2}\\,\\BsT:\\BsT}\\right]\n     = \\sqrt{\\tfrac{3}{2}}\\,\\frac{1}{\\sqrt{\\BsT:\\BsT}}\\,\\Partial{\\BsT}{\\Bsig}:\\BsT\n     = \\sqrt{\\tfrac{3}{2}}\\,\\frac{1}{\\Norm{\\BsT}{}}\\,\\left[\\SfI^{(s)}-\\tfrac{1}{3}\\Bone\\otimes\\Bone\\right]:\\BsT\n     = \\sqrt{\\tfrac{3}{2}}\\,\\frac{\\BsT}{\\Norm{\\BsT}{}}\\,.\n  \\Eal\n\\]\nTherefore,\n\\[\n   \\Partial{f}{\\Bsig} = \\frac{2p - p_c}{3}\\,\\Bone + \\sqrt{\\tfrac{3}{2}}\\,\\frac{2q}{M^2}\\,\\frac{\\BsT}{\\Norm{\\BsT}{}} \\,.\n\\]\nRecall that\n\\[\n   \\Bsig = p\\,\\Bone + \\sqrt{\\tfrac{2}{3}}\\, q\\, \\BnT = p\\,\\Bone + \\BsT \\,.\n\\]\nTherefore,\n\\[\n   \\BsT = \\sqrt{\\tfrac{2}{3}}\\,q\\,\\BnT \n   \\quad \\Tand \\quad\n   \\Norm{\\BsT}{} = \\sqrt{\\BsT:\\BsT} = \\sqrt{\\tfrac{2}{3}\\,q^2\\,\\BnT:\\BnT} = \n     \\sqrt{\\tfrac{2}{3}\\,q^2\\,\\frac{\\BeT^e:\\BeT^e}{\\Norm{\\BeT^e}{}^2}}\n     = \\sqrt{\\tfrac{2}{3}\\,q^2} = \\sqrt{\\tfrac{2}{3}}\\,q \\,.\n\\]\nSo we can write\n\\Beq\n   \\Partial{f}{\\Bsig} = \\frac{2p - p_c}{3}\\,\\Bone + \\sqrt{\\tfrac{3}{2}}\\,\\frac{2q}{M^2}\\,\\BnT \\,.\n\\Eeq\nUsing the above relation we have\n\\[\n   \\Partial{f}{p} = \\tfrac{1}{3}\\,\\Tr\\left[\\Partial{f}{\\Bsig}\\right] = 2p-p_c \n   \\quad \\Tand \\quad\n   \\Partial{f}{\\BsT}  = \\Partial{f}{\\Bsig} - \\Partial{f}{p}\\Bone\n                      = \\sqrt{\\tfrac{3}{2}}\\,\\frac{2q}{M^2}\\,\\BnT \\,.\n\\]\nThe strain updates can now be written as\n\\[\n  \\Bal\n  (\\Ve_v^e)_{n+1} & =  (\\Ve_v^e)_\\Trial - \\Delta\\gamma\\,[2p_{n+1} - (p_c)_{n+1}] \\\\\n  \\BeT^e_{n+1} & = \\BeT^e_\\Trial - \\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\n           \\BnT_{n+1}  \\\\\n  (\\Ve_s^e)_{n+1} & = \n    \\sqrt{\\tfrac{2}{3}}\\,\\sqrt{\\BeT^e_\\Trial:\\BeT^e_\\Trial \n     - \\sqrt{6}\\,(\\Delta\\gamma)^2\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\\BnT_{n+1}:\\BeT^e_\\Trial\n     + \\tfrac{3}{2}\\,(\\Delta\\gamma)^4\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)^2 } \\,.\n  \\Eal\n\\]\nFrom the second equation above,\n\\[\n  \\BnT_{n+1}:\\BeT^e_\\Trial = \n   \\BnT_{n+1}:\\BeT^e_{n+1} + \\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\n           \\BnT_{n+1}:\\BnT_{n+1} = \n   \\frac{\\BeT^e_{n+1}:\\BeT^e_{n+1}}{\\Norm{\\BeT^e_{n+1}}{}} + \n      \\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right) =\n   \\Norm{\\BeT^e_{n+1}}{} + \n      \\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right) \\,.\n\\]\nAlso notice that\n\\[\n  \\BeT^e_\\Trial:\\BeT^e_\\Trial = \\BeT^e_{n+1}:\\BeT^e_{n+1} + 2\\,\\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\n     \\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\\BeT^e_{n+1}:\\BnT_{n+1} +\n     \\left[\\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\\right]^2\n\\]\nor,\n\\[\n  \\Norm{\\BeT^e_\\Trial}{}^2 = \\left[\\Norm{\\BeT^e_{n+1}}{} + \\sqrt{\\tfrac{3}{2}}\\,\\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\\right]^2 \\,.\n\\]\nTherefore,\n\\[\n  \\BnT_{n+1}:\\BeT^e_\\Trial = \\Norm{\\BeT^e_\\Trial}{} \n\\]\nand we have\n\\[\n  (\\Ve_s^e)_{n+1} = \n    \\sqrt{\\tfrac{2}{3}}\\,\\sqrt{\\Norm{\\BeT^e_\\Trial}{}^2\n     - \\sqrt{6}\\,(\\Delta\\gamma)^2\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)\\Norm{\\BeT^e_\\Trial}{}\n     + \\tfrac{3}{2}\\,(\\Delta\\gamma)^4\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right)^2 } \n    = \\sqrt{\\tfrac{2}{3}}\\,\\Norm{\\BeT^e_\\Trial}{} - \\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right) \\,.\n\\]\nThe elastic strain can therefore be updated using\n\\[\n  \\Bal \n    (\\Ve_v^e)_{n+1} & =  (\\Ve_v^e)_\\Trial - \\Delta\\gamma\\,[2p_{n+1} - (p_c)_{n+1}] \\\\\n    (\\Ve_s^e)_{n+1} & =  (\\Ve_s^e)_\\Trial - \\Delta\\gamma\\,\\left(\\frac{2q_{n+1}}{M^2_{n+1}}\\right) \\,.\n  \\Eal \n\\]\nThe consistency condition is needed to close the above equations\n\\[\n   f = \\left(\\frac{q_{n+1}}{M}\\right)^2 + p_{n+1}[p_{n+1}-(p_c)_{n+1}] = 0  \\,.\n\\]\nThe unknowns are $(\\Ve_v^e)_{n+1}$, $(\\Ve_s^e)_{n+1}$ and $\\Delta\\gamma$.  Note that we can express\nthe three equations as\n\\Beq\n  \\Bal \n    (\\Ve_v^e)_{n+1} & =  (\\Ve_v^e)_\\Trial - \\Delta\\gamma\\,\\left[\\Partial{f}{p}\\right]_{n+1} \\\\\n    (\\Ve_s^e)_{n+1} & =  (\\Ve_s^e)_\\Trial - \\Delta\\gamma\\,\\left[\\Partial{f}{q}\\right]_{n+1} \\\\\n    f_{n+1} & = 0 \\,.\n  \\Eal \n\\Eeq\n\n\\subsection{Newton iterations}\nThe three nonlinear equations in the three unknowns can be solved using Newton iterations\nfor smooth yield functions.  Let us define the residual as\n\\[\n   \\Mr(\\Mx) = \\begin{bmatrix} \n    (\\Ve_v^e)_{n+1} -  (\\Ve_v^e)_\\Trial + \\Delta\\gamma\\,\\left[\\Partial{f}{p}\\right]_{n+1} \\\\\n    (\\Ve_s^e)_{n+1} -  (\\Ve_s^e)_\\Trial + \\Delta\\gamma\\,\\left[\\Partial{f}{q}\\right]_{n+1} \\\\\n    f_{n+1} \\end{bmatrix} =: \\begin{bmatrix} r_1 \\\\ r_2 \\\\ r_3 \\end{bmatrix}\n   \\quad \\text{where} \\quad\n   \\Mx = \\begin{bmatrix} (\\Ve_v^e)_{n+1} \\\\ (\\Ve_s^e)_{n+1} \\\\ f_{n+1} \\end{bmatrix} \n        =: \\begin{bmatrix} x_1 \\\\ x_2 \\\\ x_3 \\end{bmatrix} \\,.\n\\]\nThe Newton root finding algorithm is :\n\\begin{algorithm}\n  \\begin{algorithmic}\n    \\REQUIRE $\\Mx^0$\n    \\STATE $k \\leftarrow 0$\n    \\WHILE {$\\Mr(\\Mx^k) \\ne 0$}\n      \\STATE $\\Mx^{k+1} \\Leftarrow \\Mx^k - \\left[\\left(\\Partial{\\Mr}{\\Mx}\\right)^{-1}\\right]_{\\Mx^k}\\cdot\n              \\Mr(\\Mx^k)$\n      \\STATE $k \\leftarrow k+1$\n    \\ENDWHILE\n  \\end{algorithmic}\n\\end{algorithm}\n\nTo code the algorithm we have to find the derivatives of the residual with respect to the primary variables.\nLet's do the terms one by one.  For the first row,\n\\[\n  \\Bal\n  \\Partial{r_1}{x_1} & = \\Partial{}{\\Ve_v^e}\\left[\\Ve_v^e -  (\\Ve_v^e)_\\Trial + \\Delta\\gamma\\,(2p-p_c)\\right] \n     = 1 + \\Delta\\gamma\\left(2\\Partial{p}{\\Ve_v^e} - \\Partial{p_c}{\\Ve_v^e}\\right) \\\\\n  \\Partial{r_1}{x_2} & = \\Partial{}{\\Ve_s^e}\\left[\\Ve_v^e -  (\\Ve_v^e)_\\Trial + \\Delta\\gamma\\,(2p-p_c)\\right] \n     = 2\\Delta\\gamma\\,\\Partial{p}{\\Ve_s^e}\\\\\n  \\Partial{r_1}{x_3} & = \\Partial{}{\\Delta\\gamma}\\left[\\Ve_v^e -  (\\Ve_v^e)_\\Trial + \\Delta\\gamma\\,(2p-p_c)\\right]\n     = 2p - p_c = \\Partial{f}{p}\n  \\Eal\n\\]\nwhere\n\\[\n  \\Bal\n   \\Partial{p}{\\Ve_v^e} & = -\\frac{p_0\\,\\beta}{\\kappatilde}\\,\\exp\\left[-\\frac{\\Ve_v^e - \\Ve_{v0}^e}{\\kappatilde}\\right] = \\frac{p}{\\kappatilde} \\quad, \\quad\n   \\Partial{p_c}{\\Ve_v^e} = \\frac{(p_c)_n}{\\kappatilde-\\lambdatilde}\\,\\exp\\left[\\frac{\\Ve_v^e - (\\Ve_{v}^e)_\\Trial}{\\kappatilde-\\lambdatilde}\\right] \\quad \\Tand \\\\\n   \\Partial{p}{\\Ve_s^e} & = \\frac{3\\,p_0\\,\\alpha\\,\\Ve_s^e}{\\kappatilde}\\,\\exp\\left[-\\frac{\\Ve_v^e - \\Ve_{v0}^e}{\\kappatilde}\\right] \\,.\n  \\Eal\n\\]\nFor the second row,\n\\[\n  \\Bal\n  \\Partial{r_2}{x_1} & = \\Partial{}{\\Ve_v^e}\\left[\\Ve_s^e -  (\\Ve_s^e)_\\Trial + \\Delta\\gamma\\,\\frac{2q}{M^2}\\right] \n     = \\frac{2\\Delta\\gamma}{M^2}\\,\\Partial{q}{\\Ve_v^e} \\\\\n  \\Partial{r_2}{x_2} & = \\Partial{}{\\Ve_s^e}\\left[\\Ve_s^e -  (\\Ve_s^e)_\\Trial + \\Delta\\gamma\\,\\frac{2q}{M^2}\\right] \n     = 1 + \\frac{2\\Delta\\gamma}{M^2}\\,\\Partial{q}{\\Ve_s^e}\\\\\n  \\Partial{r_2}{x_3} & = \\Partial{}{\\Delta\\gamma}\\left[\\Ve_s^e -  (\\Ve_s^e)_\\Trial + \\Delta\\gamma\\,\\frac{2q}{M^2}\\right]\n     = \\frac{2q}{M^2} = \\Partial{f}{q}\n  \\Eal\n\\]\nwhere\n\\[\n  \\Partial{q}{\\Ve_v^e} = -\\frac{3p_0\\,\\alpha\\,\\Ve_s^e}{\\kappatilde}\\,\\exp\\left[-\\frac{\\Ve_v^e - \\Ve_{v0}^e}{\\kappatilde}\\right] = \\Partial{p}{\\Ve_s^e}\n  \\quad \\Tand \\quad \n  \\Partial{q}{\\Ve_s^e} = 3\\mu_0 + 3p_0\\,\\alpha\\,\\exp\\left[-\\frac{\\Ve_v^e - \\Ve_{v0}^e}{\\kappatilde}\\right] = 3\\mu \\,.\n\\]\nFor the third row, \n\\[\n  \\Bal\n  \\Partial{r_3}{x_1} & = \\Partial{}{\\Ve_v^e}\\left[\\frac{q^2}{M^2} + p\\,(p - p_c)\\right]\n     = \\frac{2q}{M^2}\\,\\Partial{q}{\\Ve_v^e} + (2p - p_c)\\,\\Partial{p}{\\Ve_v^e} - p\\,\\Partial{p_c}{\\Ve_v^e} \n     = \\Partial{f}{q}\\,\\Partial{q}{\\Ve_v^e} + \\Partial{f}{p}\\,\\Partial{p}{\\Ve_v^e} - p\\,\\Partial{p_c}{\\Ve_v^e} \\\\\n  \\Partial{r_3}{x_2} & = \\Partial{}{\\Ve_s^e}\\left[\\frac{q^2}{M^2} + p\\,(p - p_c)\\right]\n     = \\frac{2q}{M^2}\\,\\Partial{q}{\\Ve_s^e} + (2p - p_c)\\,\\Partial{p}{\\Ve_s^e} \n     = \\Partial{f}{q}\\,\\Partial{q}{\\Ve_s^e} + \\Partial{f}{p}\\,\\Partial{p}{\\Ve_s^e} \\\\\n  \\Partial{r_3}{x_3} & = \\Partial{}{\\Delta\\gamma}\\left[\\frac{q^2}{M^2} + p\\,(p - p_c)\\right]\n     =  0 \\,.\n  \\Eal\n\\]\nWe have to invert a matrix in the Newton iteration process.  Let us see whether we can make this \nquicker to do.  The Jacobian matrix has the form\n\\[\n  \\Partial{\\Mr}{\\Mx} = \\begin{bmatrix}\\Partial{r_1}{x_1} & \\Partial{r_1}{x_2} & \\Partial{r_1}{x_3} \\\\\n     \\Partial{r_2}{x_1} & \\Partial{r_2}{x_2} & \\Partial{r_2}{x_3} \\\\\n     \\Partial{r_3}{x_1} & \\Partial{r_3}{x_2} & \\Partial{r_3}{x_3} \\end{bmatrix} \n     = \\begin{bmatrix} \\MAmat & \\MBmat \\\\ \\MCmat & 0 \\end{bmatrix}\n\\]\nwhere\n\\[\n  \\MAmat = \\begin{bmatrix}\\Partial{r_1}{x_1} & \\Partial{r_1}{x_2} \\\\\n                       \\Partial{r_2}{x_1} & \\Partial{r_2}{x_2} \\end{bmatrix} \\,,\\quad\n  \\MBmat = \\begin{bmatrix}\\Partial{r_1}{x_3} \\\\ \\Partial{r_2}{x_3} \\end{bmatrix} \\,,\\quad \\Tand \\quad\n  \\MCmat = \\begin{bmatrix}\\Partial{r_3}{x_1} & \\Partial{r_3}{x_2} \\end{bmatrix} \\,.\n\\]\nWe can also break up the $\\Mx$ and $\\Mr$ matrices:\n\\[\n  \\Delta\\Mx = \\Mx^{k+1}-\\Mx^k = \\begin{bmatrix} \\Delta\\Mx^{vs} \\\\ \\Delta x_3 \\end{bmatrix} \\,, \\quad\n  \\Mr = \\begin{bmatrix} \\Mr^{vs} \\\\ r_3 \\end{bmatrix}\n  \\quad \\text{where} \\quad \\Mr^{vs} = \\begin{bmatrix} r_1 \\\\ r_2 \\end{bmatrix}  \n   \\quad \\Tand \\quad \\Delta\\Mx^{vs} = \\begin{bmatrix}\\Delta x_1 \\\\\\Delta x_2 \\end{bmatrix}  \\,.\n\\]\nThen\n\\[\n  \\begin{bmatrix} \\Delta\\Mx^{vs} \\\\ \\Delta x_3 \\end{bmatrix} \n   = - \\begin{bmatrix} \\MAmat & \\MBmat \\\\ \\MCmat & 0 \\end{bmatrix}^{-1} \n                    \\begin{bmatrix} \\Mr^{vs} \\\\ r_3 \\end{bmatrix} \n  \\quad \\implies \\quad \n   \\begin{bmatrix} \\MAmat & \\MBmat \\\\ \\MCmat & 0 \\end{bmatrix} \n  \\begin{bmatrix} \\Delta\\Mx^{vs} \\\\ \\Delta x_3 \\end{bmatrix}  = \n                    -\\begin{bmatrix} \\Mr^{vs} \\\\ r_3 \\end{bmatrix} \n\\]\nor\n\\[\n   \\MAmat\\,\\Delta\\Mx^{vs} + \\MBmat\\,\\Delta x_3 = -\\Mr^{vs} \\quad \\Tand \\quad\n   \\MCmat\\,\\Delta\\Mx^{vs} = -r_3 \\,.\n\\]\nFrom the first equation above,\n\\[\n  \\Delta\\Mx^{vs} = -\\MAmat^{-1}\\,\\Mr^{vs} - \\MAmat^{-1}\\,\\MBmat\\,\\Delta x_3 \\,.\n\\]\nPlugging in the second equation gives\n\\[\n   r_3 = \\MCmat\\,\\MAmat^{-1}\\,\\Mr^{vs} + \\MCmat\\,\\MAmat^{-1}\\,\\MBmat\\,\\Delta x_3 \\,.\n\\]\nRearranging,\n\\[\n  \\Delta x_3 = x_3^{k+1} - x_3^k = \\frac{-\\MCmat\\,\\MAmat^{-1}\\,\\Mr^{vs} + r_3}{\\MCmat\\,\\MAmat^{-1}\\,\\MBmat} \\,.\n\\]\nUsing the above result,\n\\[\n  \\Delta\\Mx^{vs} = -\\MAmat^{-1}\\,\\Mr^{vs} - \\MAmat^{-1}\\,\\MBmat\\,\\left(\\frac{-\\MCmat\\,\\MAmat^{-1}\\,\\Mr^{vs} + r_3}{\\MCmat\\,\\MAmat^{-1}\\,\\MBmat}\\right) \\,.\n\\]\nWe therefore have to invert only a $2 \\times 2 $ matrix.\n\n\\subsection{Tangent calculation: elastic}\nWe want to find the derivative of the stress with respect to the strain:\n\\Beq\n   \\Partial{\\Bsig}{\\Beps} = \\Bone\\otimes\\Partial{p}{\\Beps} + \n      \\sqrt{\\tfrac{2}{3}}\\,\\BnT\\otimes\\Partial{q}{\\Beps} + \n      \\sqrt{\\tfrac{2}{3}}\\,q\\,\\Partial{\\BnT}{\\Beps}  \\,.\n\\Eeq\nFor the first term above,\n\\[\n   \\Partial{p}{\\Beps} = p_0\\,\\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\Partial{\\beta}{\\Beps}\n      - p_0\\,\\frac{\\beta}{\\kappatilde}\\,\n        \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\Partial{\\Ve^e_v}{\\Beps} \n     = p_0\\,\\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\left(\\Partial{\\beta}{\\Beps} -\n            \\frac{\\beta}{\\kappatilde}\\,\\Partial{\\Ve^e_v}{\\Beps} \\right) \\,.\n\\]\nNow,\n\\[\n   \\Partial{\\beta}{\\Beps} = \\frac{3\\alpha}{\\kappatilde}\\,\\Ve^e_s\\,\\Partial{\\Ve^e_s}{\\Beps} \\,.\n\\]\nTherefore, \n\\[\n  \\Partial{p}{\\Beps} = \\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\left(3\\alpha\\,\\Ve^e_s\\Partial{\\Ve^e_s}{\\Beps} -\n            \\beta\\,\\Partial{\\Ve^e_v}{\\Beps} \\right) \\,.\n\\]\nWe now have to figure out the other derivatives in the above expression.  First,\n\\[\n  \\Partial{\\Ve^e_s}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\sqrt{\\BeT^e:\\BeT^e}}\\,\\Partial{\\BeT^e}{\\Beps}:\\BeT^e =\n     \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Norm{\\BeT^e}{}}\\,\n     \\left(\\Partial{\\Beps^e}{\\Beps} - \\tfrac{1}{3}\\Bone\\otimes\\Partial{\\Ve^e_v}{\\Beps} \\right):\\BeT^e\\,.\n\\]\nFor the special situation where all the strain is elastic, $\\Beps = \\Beps^e$, and (see Wikipedia \narticle on tensor derivatives)\n\\[\n  \\Partial{\\Beps^e}{\\Beps} = \\Partial{\\Beps}{\\Beps} = \\SfI^{(s)} \\quad \\Tand \\quad\n  \\Partial{\\Ve^e_v}{\\Beps} = \\Partial{\\Ve_v}{\\Beps} = \\Bone \\,.\n\\]\nThat gives us\n\\[\n  \\Partial{\\Ve^e_s}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Norm{\\BeT^e}{}}\\,\n     \\left(\\SfI^{(s)} - \\tfrac{1}{3}\\Bone\\otimes\\Bone \\right):\\BeT^e\n   = \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Norm{\\BeT^e}{}}\\,\n     \\left[\\BeT^e - \\tfrac{1}{3}\\Tr(\\BeT^e)\\Bone\\right] \\,.\n\\]\nBut $\\Tr(\\BeT^e)=0$ because this is the deviatoric part of the strain and we have\n\\[\n  \\boxed{\n  \\Partial{\\Ve^e_s}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\frac{\\BeT^e}{\\Norm{\\BeT^e}{}} = \\sqrt{\\tfrac{2}{3}}\\,\\BnT \n  }\n  \\quad \\Tand \\quad\n  \\boxed{\n  \\Partial{\\Ve^e_v}{\\Beps} = \\Bone \\,.\n  }\n\\]\nUsing these, we get\n\\Beq\n  \\Partial{p}{\\Beps} = \\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\left(\\sqrt{6}\\,\\alpha\\,\\Ve^e_s\\,\\BnT -\n            \\beta\\,\\Bone \\right) \\,.\n\\Eeq\nThe derivative of $q$ with respect to $\\Beps$ can be calculated in a similar way, i.e.,\n\\[\n  \\Partial{q}{\\Beps} = 3\\mu\\,\\Partial{\\Ve^e_s}{\\Beps} + 3\\Ve^e_s\\,\\Partial{\\mu}{\\Beps}\n   = 3\\mu\\,\\Partial{\\Ve^e_s}{\\Beps} - 3\\frac{p_0}{\\kappatilde}\\,\\alpha\\,\\Ve^e_s\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\,\\Partial{\\Ve^e_v}{\\Beps} \\,.\n\\]\nUsing the expressions in the boxes above, \n\\Beq\n  \\Partial{q}{\\Beps} = \\sqrt{6}\\,\\mu\\,\\BnT - 3\\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\,\\alpha\\,\\Ve^e_s\\,\\Bone \\,.\n\\Eeq\nAlso,\n\\[\n   \\Partial{\\BnT}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\left[\\frac{1}{\\Ve^e_s}\\,\\Partial{\\BeT^e}{\\Beps}\n     - \\frac{1}{(\\Ve^e_s)^2}\\,\\BeT^e\\otimes\\Partial{\\Ve^e_s}{\\Beps}\\right] \\,.\n\\]\nUsing the previously derived expression, we have\n\\[\n   \\Partial{\\BnT}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Ve^e_s}\\,\\left[\n        \\SfI^{(s)} - \\tfrac{1}{3}\\,\\Bone\\otimes\\Bone\n     - \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Ve^e_s}\\,\\frac{\\BeT^e\\otimes\\BeT^e}{\\Norm{\\BeT^e}{}}\\right] \n\\]\nor\n\\Beq\n   \\Partial{\\BnT}{\\Beps} = \\sqrt{\\tfrac{2}{3}}\\,\\frac{1}{\\Ve^e_s}\\,\\left[\n        \\SfI^{(s)} - \\tfrac{1}{3}\\,\\Bone\\otimes\\Bone - \\BnT\\otimes\\BnT\\right] \\,.\n\\Eeq\nPlugging the expressions for these derivatives in the original equation, we get\n\\[\n  \\Bal\n   \\Partial{\\Bsig}{\\Beps} & = \\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\n      \\left(\\sqrt{6}\\,\\alpha\\,\\Ve^e_s\\,\\Bone\\otimes\\BnT - \\beta\\,\\Bone\\otimes\\Bone \\right) + \n      2\\mu\\,\\BnT\\otimes\\BnT - \\sqrt{6}\\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\,\\alpha\\,\\Ve^e_s\\,\\BnT\\otimes\\Bone +\\\\\n      & \\qquad \\qquad \\tfrac{2}{3}\\,\\frac{q}{\\Ve^e_s}\\,\\left[\n        \\SfI^{(s)} - \\tfrac{1}{3}\\,\\Bone\\otimes\\Bone - \\BnT\\otimes\\BnT\\right] \\,.\n  \\Eal\n\\]\nReorganizing,\n\\Beq\n  \\boxed{\n  \\Bal\n   \\Partial{\\Bsig}{\\Beps} & = \\frac{\\sqrt{6}\\,p_0\\,\\alpha\\,\\Ve^e_s}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right](\\Bone\\otimes\\Bn + \\Bn\\otimes\\Bone) - \n      \\left(\\frac{p_0\\beta}{\\kappatilde}\\, \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\n       +\\tfrac{2}{9}\\,\\frac{q}{\\Ve_s^e}\\right) \\Bone\\otimes\\Bone + \\\\\n     & \\qquad \\qquad 2\\left(\\mu - \\tfrac{1}{3}\\,\\frac{q}{\\Ve^e_s}\\right)\\,\\BnT\\otimes\\BnT \n           + \\tfrac{2}{3}\\,\\frac{q}{\\Ve^e_s}\\,\\SfI^{(s)}\\,.\n  \\Eal\n  }\n\\Eeq\n\n\\subsection{Tangent calculation: elastic-plastic}\nFrom the previous section recall that \n\\[\n   \\Partial{\\Bsig}{\\Beps} = \\Bone\\otimes\\Partial{p}{\\Beps} + \n      \\sqrt{\\tfrac{2}{3}}\\,\\BnT\\otimes\\Partial{q}{\\Beps} + \n      \\sqrt{\\tfrac{2}{3}}\\,q\\,\\Partial{\\BnT}{\\Beps}  \n\\]\nwhere\n\\[\n  \\Bal\n  \\Partial{p}{\\Beps} & = \\frac{p_0}{\\kappatilde}\\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\left(3\\alpha\\,\\Ve^e_s\\Partial{\\Ve^e_s}{\\Beps} -\n            \\beta\\,\\Partial{\\Ve^e_v}{\\Beps} \\right) \\,,\\qquad\n  \\Partial{q}{\\Beps}  = 3\\mu\\,\\Partial{\\Ve^e_s}{\\Beps} - 3\\frac{p_0}{\\kappatilde}\\,\\alpha\\,\\Ve^e_s \\,\n      \\exp\\left[-\\frac{\\Ve^e_v - \\Ve^e_{v0}}{\\kappatilde}\\right]\\,\\Partial{\\Ve^e_v}{\\Beps} \\quad \\Tand \\\\\n   \\Partial{\\BnT}{\\Beps} & = \\sqrt{\\tfrac{2}{3}}\\,\\left[\\frac{1}{\\Ve^e_s}\\,\\Partial{\\BeT^e}{\\Beps}\n     - \\frac{1}{(\\Ve^e_s)^2}\\,\\BeT^e\\otimes\\Partial{\\Ve^e_s}{\\Beps}\\right] \\,.\n  \\Eal\n\\]\nThe total strain is equal to the elastic strain for the purely elastic case and the tangent is relatively\nstraightforward to calculate.  For the elastic-plastic case we have\n\\[\n   \\Beps^e_{n+1} = \\Beps^e_\\Trial - \\Delta\\gamma\\left[\\Partial{f}{\\Bsig}\\right]_{n+1} \\,.\n\\]\nDropping the subscript $n+1$ for convenience, we have\n\\[\n   \\Partial{\\Beps^e}{\\Beps} = \\Partial{\\Beps^e_\\Trial}{\\Beps} \n     - \\Partial{f}{\\Bsig}\\otimes\\Partial{\\Delta\\gamma}{\\Beps}\n     - \\Delta\\gamma\\,\\Partial{}{\\Beps}\\left[\\Partial{f}{\\Bsig}\\right]\n     = \\SfI^{(s)}\n     - \\left[\\frac{2p-p_c}{3}\\,\\Bone + \\sqrt{\\tfrac{3}{2}}\\,\\frac{2q}{M^2}\\,\\BnT\\right]\n       \\otimes\\Partial{\\Delta\\gamma}{\\Beps}\n     - \\Delta\\gamma\\,\\Partial{}{\\Beps}\n     \\left[\\frac{2p-p_c}{3}\\,\\Bone + \\sqrt{\\tfrac{3}{2}}\\,\\frac{2q}{M^2}\\,\\BnT\\right] \\,.\n\\]\n\n\n%\\begin{figure}[htb!]\n%  \\centering\n%  %\\includegraphics[width=0.4\\linewidth]{./FIGS/SimpleBurnWithoutPressCC.png}\n%  %\\includegraphics[width=0.4\\linewidth]{./FIGS/SimpleBurnWithPressCC.png}\n%  \\caption{Simulation of an explosion in a half space overlaid by a thin layer with a\n%           simple burn model and compressible neo-Hookean behavior.  There is no apparent\n%           fast moving shock wave in the material because the speed of sound in the half space\n%           is low.  Movies of this simulation can be found in the Dropbox folder\n%           SoilWithLayerSimpleBurn2D.}\n%  \\label{fig:SimpleBurn}\n%\\end{figure}\n\n\n\\end{document}\n", "meta": {"hexsha": "aa2d167ca441b7900848987100c2ca28b14c6752", "size": 29024, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/CCA/Components/MPM/Materials/ConstitutiveModel/Biswajit/Documents/CamClayBorja.tex", "max_stars_repo_name": "abagusetty/Uintah", "max_stars_repo_head_hexsha": "fa1bf819664fa6f09c5a7cd076870a40816d35c9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-06-10T08:21:31.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-23T18:33:16.000Z", "max_issues_repo_path": "src/CCA/Components/MPM/Materials/ConstitutiveModel/Biswajit/Documents/CamClayBorja.tex", "max_issues_repo_name": "abagusetty/Uintah", "max_issues_repo_head_hexsha": "fa1bf819664fa6f09c5a7cd076870a40816d35c9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CCA/Components/MPM/Materials/ConstitutiveModel/Biswajit/Documents/CamClayBorja.tex", "max_forks_repo_name": "abagusetty/Uintah", "max_forks_repo_head_hexsha": "fa1bf819664fa6f09c5a7cd076870a40816d35c9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-12-30T05:48:30.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-12T16:24:16.000Z", "avg_line_length": 42.2474526929, "max_line_length": 194, "alphanum_fraction": 0.5821733738, "num_tokens": 12876, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.43987105026513895}}
{"text": "\\section{Experimental results}\nIn this latter analysis, we did not care about the validation of the model: the company's experience guaranteed the correctness of the model itself. On the contrary, our goal was to study how the result of the previous model affected the final measure of the diameter, and how the same is influenced by the position of the three points on the wheel. \\\\\n\nThe main problem encountered in this set of tests, was due to the lack of availability of a complete \\acs{WPMS} to perform acquisitions of real rolling points of the \\textit{DIMA}. The only system we could use was one under development, and incomplete. Furthermore, it was also bad calibrated, so the performed measures of the diameter was more or less $40 \\, mm$ bigger than the nominal size of the target. Thus, was impossible for us to make any comparison with real data.\n\nDespite that, \\textsc{Matlab} allowed us to simulate a plausible scenario, in which three laser was involved, and the rolling points was obtained as the intersection between the laser line and a circumference comparable with the wheel. In Figure \\ref{fig:diam:virtual} is shown an example of a simulation. In tests described bellow, we tried to generate real scenario to determine points that could be comparable with sets of real data.\n  \\begin{figure}[t!]\n    \\centering\n    \\includegraphics[width=0.75\\textwidth]{./images/diameter/virtual.jpg}\n    \\caption{Example of the simulation used to detect the three rolling points to estimate the diameter of the wheel. The black dotted lines are the rail, while the coloured ones are the laser beams.}\n    \\label{fig:diam:virtual}\n  \\end{figure}\n\n\\subsection{Effects of points' positions} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nThe first experiments was focus on study the variation of the error with respect to the location of the reference points in the circle. To do that, we analysed two different type of situations:\n  \\begin{itemize}\n    \\item in the first one, we moved the wheel in a reasonable range, maintaining the configuration of the acquisition system fixed;\n    \\item in the second one, we change the positions of the projectors one by one, keeping the others fixed, in order to look for some relations of interest between the configuration of the system and the computed error.\n  \\end{itemize}\n\nIn Figure \\ref{fig:diam:dists} we reported the distribution of the errors, obtained with three different setups, moving the wheel along the virtual rail. The first thing we can see, is that these distributions were not linear. Thinking a while, it is easy to understand why: the motion of the points of a circumference, that moves with pure round motion, is a cycloid. So, the relationship between two points determined by the same laser at different times, will have to take into account this quadratic trend. Furthermore, we have to consider that the first order derivative of the Equation \\ref{eq:diam:erone} is characterized by the presence of several sine and cosine factors, which prohibit linear distributions. \\\\\nBy improving our analysis, we have tried to determine what conditions reduce the final error, and which ones increase it. Initially, we decided to focus on the Distribution \\ref{fig:diam:dists1}, because of the presence of a (maybe global) minimum. In Figure \\ref{fig:diam:scenarios} we shown the best and the worst scenarios, accordingly with the error. Concerning the worst case, we can notice that a two points was very close to each other, while the third one is far with respect to the others. Looking at all the motion of the wheel, we observed that the error increased as the two points approached. Opposite considerations can be made in the best case: the error decreases as the reciprocal points distance increases. All these consideration suggested us that probably the error was minimum when the points are equally distributed along an arc. Same considerations was reached analysing the scenarios for Distributions \\ref{fig:diam:dists2} and \\ref{fig:diam:dists3}. Unfortunately, the collected data did not help us. All the attempts made to find a mathematical relation between the location of the points, and the error, failed. \\\\\n\nThus, we changed our approach. The great number of parameters we had to consider (the angles of the lasers, their distances from the origin of the reference system, and the length of the $y_i$ vectors) suggested us to simplify the problem. So, we decided to change only one parameter per times, and try to determine the effect of the variation in the final result. Because of the lengths of the vectors $y_i$ strictly depend by the angles $\\theta_i$ and by the offsets $H_i$, we decided to ignore them and to focus only in the last parameters. In Figure \\ref{fig:diam:hs} we reported the graphical results obtained moving one projector with respect to the others. In this case, we can see how the error decreases increasing the distances between the projectors: differently from the previous scenarios, this is due to the increasing in the length of the arc involved by the three points. However, as we can see from the Figure \\ref{fig:diam:hs} (bottom)  the matter is not that simple. It seems that the distribution could be a discontinuous function. The only thing that, in our opinion, may had influence the result, is the angle of the projector with respect of the rail (that is $90\\degree$). Many attempt was made to understand how the angle influences the error, but no\n  \\clearpage\n  \\begin{figure}[t!]\n    \\centering\n    \\begin{minipage}[c]{0.9\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/distrib1.jpg}\n      \\subcaption{Distribution \\#1}\n      \\label{fig:diam:dists1}\n    \\end{minipage}\n    \\vfill\n    \\begin{minipage}[c]{0.9\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/distrib2.jpg}\n      \\subcaption{Distribution \\#2}\n      \\label{fig:diam:dists2}\n    \\end{minipage}\n    \\vfill\n    \\begin{minipage}[c]{0.9\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/distrib3.jpg}\n      \\subcaption{Distribution \\#3}\n      \\label{fig:diam:dists3}\n    \\end{minipage}\n    \n    \\caption{Examples of distributions of the final error varying the position of the wheel with respect to the systems.}\n    \\label{fig:diam:dists}\n  \\end{figure}\n\\clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n  \\begin{figure}[t!]\n    \\centering\n    \\begin{minipage}[c]{\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/c1_better.jpg}\n    \\end{minipage}\n    \\vfill\n    \\begin{minipage}[c]{\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/c1_worst.jpg}\n    \\end{minipage}\n    \n    \\caption{Better (on the top) and worst (on the bottom) scenarios, accordingly with the error distribution.}\n    \\label{fig:diam:scenarios}\n  \\end{figure}\n\\clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n  \\begin{figure}[t!]\n    \\centering\n    \\begin{minipage}[c]{0.9\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/H1_1.jpg}\n    \\end{minipage}\n    \\vfill\n    \\begin{minipage}[c]{0.9\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/diameter/H2_1.jpg}\n    \\end{minipage}\n    \n    \\caption{Error distributions as the position of the first laser projector (top) and the second (bottom).}\n    \\label{fig:diam:hs}\n  \\end{figure}\n  \\input{./src/chapters/ch6-Diameter/tab.tex}\n\\clearpage\n\\noindent\nremarkable result was found. \\\\\n\nTo conclude this first part of the analysis, we can say that an at least quadratic relation exists between the error made using Erone's formula and the reciprocal distances between the points involved by the measure. Nevertheless, the number of factors that influenced this measures, is big enough to make tricky the definition of a mathematical relation among the involved components. From our point of view, this could be modelled as a linear programming minimum search problem. \\\\\n\nAs we can realize from the analysis above, we were not interested in the numerical results, but only in the distribution of the error over the position of the points. In fact, in the case of study we knew the performance of the model in real scenarios. However, the results in our possession did not take into account the error due to $y_i$'s estimates. So we performed a last set of test to introduce this last factor.\n\n\\subsection{Error propagation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nTo conclude our analysis on this last part of the model, we correctly set al the parameters with typical values, that we had seen work properly for our systems. The empirical data that we initially used to study the problems, the \\textit{bad calibrated ones}, where obtained using a device like the one described in Section \\ref{sec:exp2}, so the values used for estimate $\\sigma_{y_i}$ was the ones shown in Table \\ref{tab:exp2:refereces}. \nAs we said in the previous subsection, we didn't find a useful relation between the error and the input parameters, so they are too much to synthesize the results in a simple table. Furthermore, as we shown in the figures above, there wasn't a distribution for witch the data could take sense. In Table \\ref{tab:diam:tab1} we reported an example of data, collected keeping fix the system, and moving the wheel along the rails. In this case, as well as in the others, we noticed that the $\\sigma_{y_i}$ did not heavily affect the final error of the measure, which always remains within the range $\\left(0.1, \\, 1.0\\right) \\, mm$. The cases where the error became greater, were in limit working condition for the system, such with the wheel over the projector. The $Y_i$ columns are the lengths of the simulated $y_i$ vectors, while the $L_i$ columns are the lengths of the sides of the triangle inscribed in the circumference; $P$ and $A$ are the perimeter and the area, respectively. Furthermore, we preferred not to return the diameter of the wheel, because the wheel being simulated, and this value was always perfectly accurate.\n\n%", "meta": {"hexsha": "a3a811d714c74340a3a20410910d3b5a067aed63", "size": 10200, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/src/chapters/ch6-Diameter/results.tex", "max_stars_repo_name": "extoxesses/LaserMat", "max_stars_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-12T08:53:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T06:36:55.000Z", "max_issues_repo_path": "report/thesis/src/chapters/ch6-Diameter/results.tex", "max_issues_repo_name": "extoxesses/LaserMat", "max_issues_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/src/chapters/ch6-Diameter/results.tex", "max_forks_repo_name": "extoxesses/LaserMat", "max_forks_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 105.1546391753, "max_line_length": 1275, "alphanum_fraction": 0.7457843137, "num_tokens": 2365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4398710443623155}}
{"text": "\n\n\n\n\\subsection{Numerics}\n\nFrom a numerical point of view, it is convenient to solve for the\neigenmodes of the linear operator $\\hat q$ and $\\hat a_\\pm = \\hat a\n/2 \\pm \\omega_l \\hat d /(2i)$.\n%\nWe thus consider the following modified governing equations\n\\begin{eqnarray}\n\\bigl( \\p_t  + \\fdiss(\\kk) \\bigl) \\hat q  \n&=& \\hat N_q  ,\\label{eqqnum} \\\\\n\\bigl( \\p_t  + \\fdiss(\\kk) \\pm  i \\omega_l \\bigl)  \\hat a_\\pm  \n&=& \\hat N_{\\pm} + \\hat f_{\\pm}, \\label{eqapmnum}\n\\end{eqnarray}\nwhere $\\hat f_{\\pm}$ are forcing terms and %\n$\\hat N_q$ and %\n$\\hat N_\\pm = \\hat N_a /2 \\pm \\omega_l \\hat N_d/(2i)$ %\nare non-linear terms computed from %\n$\\hat \\NN_\\uu = - \\zeta \\eez \\wedge \\uu - \\bnabla |\\uu|^2/2$ and %\n$\\hat N_\\eta = - \\bnabla \\cdot (\\eta \\uu)$.\n%\nWe have removed the Newtonian viscous operator in (\\ref{eq_uu}) and\nadded more general dissipative operators in (\\ref{eq_uu}) and\n(\\ref{eq_h}).  There is no strong physical motivations for this\nmodification but, as discussed by \\cite{FargeSadourny1989}, molecular\ndissipation of the form $\\nu \\bnabla^2 \\uu$ is not necessarily a\nrelevant model of the actual small-scale dissipation for shallow-water\nflows, which should rather be described as a transition from\ntwo-dimensional to three-dimensional motions before reaching the\nscales where dissipation actually occurs.\n\n\n\n\nEquations (\\ref{eqqnum}-\\ref{eqapmnum}) are simulated by means of a\npseudo-spectral method with periodic boundary conditions.\n%\nTime advancement is carried out by a classical fourth-order\nRunge-Kutta scheme for the nonlinear term and an exact integration for\nthe linear and dissipative terms.  This explicit integration is\nespecially interesting at very high resolution and very large $c$ when\nthe shortest waves are very fast with frequency of the order of\n$\\omega \\simeq c \\max(k)$.\n%\nWe use an adaptable time step method which maximizes the time step\nover a standard Courant-Friedrichs-Lewy condition\n\\cite[]{Lundbladh1999, AugierChomazBillant2012}.\n%\nMost of the aliasing is removed by truncating 8/9 of the modes along\neach direction \\cite[for a detail discussion on the issues of the\nnon-conservation of the non-quadratic energy and the aliasing errors\nin the truncated one-layer shallow water model,\nsee][]{FargeSadourny1989}.\n\n\n\n\n\\subsection{Forced dissipative statistically stationary simulations}\n\nWe have carried out a number of simulations \nwith large-scale forcing and small-scale dissipation\nfor different resolutions and different values of the wave speed.\n%\nThe resolution is characterized by the number of nodes in the each\ndirection, $n$, and has been varied from 240 to 7680.\n%\nThe wave speed $c$ has been varied over two orders of magnitude from\n10 to 1000.\n%\nTable~\\ref{tab} presents the parameters for a set of representative\nsimulations.\n\n\\begin{table}\n  \\begin{center}\n% \\def~{\\hphantom{0}}\n\\begin{tabular}{cc@{\\hskip 8mm}c@{\\hskip 8mm}cccc@{\\hskip 8mm}cc}\n$n$ & $c$ & $\\nu_8$ & $\\eps$ & $\\displaystyle\\frac{\\kmax}{\\kdiss}$ & $\\displaystyle\\frac{\\kdiss}{k_f}$ & $F_f$ & $\\min h$ & $\\displaystyle\\frac{\\max |\\uu|}{c}$ \\\\[3mm]\n~960 &   10 & 1.5e-10 & 1.03 & 2.46 &  29 &  0.111 & 0.25 & 0.96 \\\\\n1920 &   10 & 9.6e-13 & 1.00 & 2.46 &  58 &  0.110 & 0.37 & 0.92 \\\\\n3840 &   10 & 6.0e-15 & 1.01 & 2.46 & 116 &  0.110 & 0.39 & 1.01 \\\\\n7680 &   10 & 3.7e-17 & 1.03 & 2.46 & 231 &  0.111 & 0.32 & 0.95 \\\\[1mm]\n~960 &   20 & 1.5e-10 & 0.98 & 2.47 &  29 &  0.055 & 0.65 & 0.51 \\\\\n1920 &   20 & 9.6e-13 & 0.84 & 2.48 &  57 &  0.052 & 0.66 & 0.81 \\\\\n3840 &   20 & 6.0e-15 & 0.99 & 2.46 & 115 &  0.055 & 0.56 & 0.68 \\\\[1mm]\n~960 &   40 & 1.5e-10 & 0.99 & 2.46 &  29 &  0.027 & 0.81 & 0.24 \\\\\n1920 &   40 & 9.6e-13 & 1.01 & 2.46 &  58 &  0.028 & 0.78 & 0.28 \\\\\n3840 &   40 & 6.0e-15 & 0.98 & 2.47 & 115 &  0.027 & 0.77 & 0.29 \\\\\n7680 &   40 & 3.7e-17 & 0.94 & 2.47 & 230 &  0.027 & 0.76 & 0.32 \\\\[1mm]\n~960 &  100 & 1.5e-10 & 0.99 & 2.46 &  29 &  0.011 & 0.89 & 0.09 \\\\\n1920 &  100 & 9.6e-13 & 0.98 & 2.47 &  58 &  0.011 & 0.90 & 0.11 \\\\\n3840 &  100 & 6.0e-15 & 0.97 & 2.47 & 115 &  0.011 & 0.87 & 0.13 \\\\[1mm]\n~960 &  200 & 1.5e-10 & 0.99 & 2.46 &  29 &  0.005 & 0.95 & 0.05 \\\\\n1920 &  200 & 9.6e-13 & 0.99 & 2.46 &  58 &  0.005 & 0.94 & 0.06 \\\\\n3840 &  200 & 6.0e-15 & 0.90 & 2.47 & 115 &  0.005 & 0.94 & 0.06 \\\\[1mm]\n~960 &  400 & 1.5e-10 & 0.97 & 2.47 &  29 &  0.003 & 0.97 & 0.03 \\\\\n1920 &  400 & 9.6e-13 & 0.99 & 2.46 &  58 &  0.003 & 0.96 & 0.03 \\\\[1mm]\n~960 & 1000 & 1.5e-10 & 1.16 & 2.45 &  29 &  0.001 & 0.98 & 0.01 \\\\\n1920 & 1000 & 9.6e-13 & 0.91 & 2.47 &  57 &  0.001 & 0.98 & 0.01 \\\\\n\\end{tabular}\n\\caption{Overview of parameters for a set of representative simulations. \nThe number of nodes in the each direction is denoted by $n$. \nThe size of the numerical domain is equal to $L_h = 50$.\nOnly the wave numbers $5\\delta k\\leqslant|\\kk|\\leqslant8\\delta k$ are forced\nand the forcing wave number is defined as \n$k_f \\equiv 6 \\delta k$ \ncorresponding to a characteristic forcing scale of approximately \n$L_f \\equiv \\pi/k_f = 3.57$.\n%\n$F_f = \\eps^{1/3}/({k_f}^{1/3}c)$ is the forcing Froude number and\n$\\max |\\uu|/c$ is the spatial and temporal maximum of a local Froude\nnumber.  }\n\\label{tab}\n\\end{center}\n\\end{table}\n\n\n\nThe ageostrophic variable $a$ is forced in a shell in spectral space\ncorresponding to relatively small wave numbers $5\\delta k\\leqslant\n|\\kk| \\leqslant 8\\delta k$, where $\\delta k = 2\\pi/L_h$.\n%\n\\Add{In the following, we use $L_h = 50$ in order to obtain a\ncharacteristic forcing wave number of order unity, $k_f \\equiv 6\n\\delta k \\simeq 0.75$. The corresponding forcing scale is $L_f \\equiv\n\\pi/k_f \\simeq 4.2$.}\n%\nSince only the ageostrophic variable is forced ($\\hat f_d = 0$),%\n(i) only the thickness fluctuation $\\eta$ is forced in the\nnon-rotating case and %\n(ii) the force terms in (\\ref{eqapmnum}) are simply equal to $\\hat\nf_\\pm = \\hat f_a/2$.\n%\nIn order to compute the force $\\hat f_a$, we start from a\npre-normalized force $\\hat f_{0}$ obtained from a normal random\nprocess decorrelated in time.\n%\nThe force is then normalized such that the quadratic part of the total\nenergy $\\langle|\\uu|^2 + c^2 \\eta^2\\rangle/2$ is injected at a\nconstant rate.\n%\nThe spectral injection rate of the quadratic energy averaged over one\ntime step is (see appendix~\\ref{app_comp})\n\\begin{equation}\nP_q(\\kk, t) \n= \n\\Re\\{ \\hat \\uu(\\kk)^* \\cdot \\hat \\ff(\\kk) \n+\nc^2 \\hat \\eta(\\kk)^* \\hat f_\\eta(\\kk) \\}\n+ \n(|\\hat\\ff|^2 + c^2 |\\hat f_\\eta|^2) \\delta t /2,\n\\end{equation}\nwhere $\\Re$ denotes the real part.\n%\nWriting $\\hat f_a = \\alpha \\hat f_{0}$, it is straightforward to solve\na second-order equation for the coefficient $\\alpha$ in order to fix\nthe injection rate $\\Add{P_0 \\equiv} \\sum_\\kk P_q(\\kk, t)$ to unity.\n\n\nThe energy is dissipated at the smallest resolved scales by a\nhyper-viscous operator, corresponding to a dissipative frequency equal\nto $\\fdiss(\\kk) = \\nu_n |\\kk|^n$, with $n = 8$.  The value of the\nhyperviscosity $\\nu_8$ is chosen such as the hyper-Kolmogorov wave\nnumber\n\\begin{equation}\nk_{Kn} = \\left( \\frac{{\\nu_n}^3}{\\eps} \\right)^\\frac{1}{3n-2},\n\\end{equation}\nis well resolved, $\\kdiss =k_{K8} \\simeq \\kmax/ 2.5$, where $\\kmax =\n(8/9)\\pi n/L_h$ is the maximum resolved wave number.\n\nWe have observed that when only the waves are forced, the vorticity\ndoes not increase and that when the vorticity is small enough, it does\nnot significantly influence the waves.  Therefore, we have chosen not\nto simulate a negligible vorticity field and to only solve equations\n(\\ref{eqapmnum}) with $\\zeta = 0$.\n\n\n\n\n\n\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=13cm]{../Figs/fig_Emean_time}}\n\\caption{Space averaged energy \n$\\langle h|\\uu|^2 + c^2 h^2 \\rangle/2$ versus time \nfor different wave speeds $c$ and resolutions $n$.\n%\nThe energy and the time are normalized by \n$E_f\\equiv (P_0/k_f)^{2/3}$ and $T_f\\equiv (P_0 {k_f}^2)^{-1/3}$,\nwith $P_0 = 1 \\simeq \\eps$.\n%\nThe colors corresponds to different wave speeds as indicated in the figure\n$c= 10$, 20, 40, 70, 100, 200, 400, 700 and 1000.\n%\nThe different resolutions are represented by different types of lines:\n\\Add{thin continuous lines, $n = 240$;\nthick dashed lines, $n = 480$;\nthin dotted lines, $n = 960$;\nthick continuous lines, $n = 1920$;\nthin dashed lines, $n = 3840$;\nthick dotted lines, $n = 5760$ \nand\nthin dotted dashed lines, $n = 7680$.}\n}\n\\label{fig_Evstime}\n\\end{figure}\n\n\n\n\n\n\nThe time evolution of the instantaneous total energy is shown in\nfigure~\\ref{fig_Evstime} for different wave speeds $c$.\n%\nThe resolution \\Add{and the dissipation wave number are} progressively\nincreased: %\n$n = 240$ ($0\\leqslant t/T_f \\leqslant 100$), %\n$n = 480$ ($100\\leqslant t/T_f \\leqslant 125$), %\n$n = 960$ ($125\\leqslant t/T_f \\leqslant 140$), %\n$n = 1920$, %\n$n = 3840$, %\n$n = 5760$ and %\n$n = 7680$\\Add{, where $T_f\\equiv\n(P_0 {k_f}^2)^{-1/3}$ is the characteristic forcing time}.\n%\nEach time the resolution is increased, the energy first sharply\nincreases and then fluctuates.  For most of the simulations, it is\nclear that a statistically stationary regime is reached.\n%\nHowever, \n%\n\\Remove{in the relatively short simulations at the highest\nresolution for the largest wave speeds ($n = 1920$, $c = 700$ and\n1000),}\n%\n\\Add{for some relatively short simulations with very large wave speed\nand/or very large resolution,}\n%\nthere are large fluctuations and it is not absolutely certain whether\na statistically stationary regime is reached.\n%\n\\Add{This is in particular the case for the simulations for $c = 700$, $n\n= 1920$ (thick red continuous line), $c = 200$, $n = 3840$ (thin\nmagenta dashed line) and $c=40$, $n = 7680$ (thin blue dotted dashed\nline).}\n%\n\\Add{Note that these simulations are already quite numerically\ncostly. For example, the simulation for $c=1000$ and $n = 1920$\nduring slightly less than $20T_f$ corresponds to approximately\n$8\\times 10^5$ time steps.}\n\n\nSince the energy is injected at large scales and dissipated only at\nthe smallest resolved scales, the existence of a statistically\nstationary regime implies a downscale flux of energy, which is equal\nto the large-scale energy injection rate.\n%\nFor the same energy injection rate and resolution, the mean energy\nincreases with the wave speed, implying that when $c$ increases the\nmean energy has to be larger to lead to the same downscale energy\nflux.\n%\nThe results presented in the following are from the statistically\nstationary regime.  Apart from the snapshots, all shown quantities are\naveraged over a period corresponding to this regime.\n\n\n\nTable~\\ref{tab} presents numerical and physical quantities for a set\nof representative simulations.\n%\nWe characterize the simulations by the forcing Froude number\n\\begin{equation}\nF_f \\Add{\\equiv} \\frac{\\eps^{1/3}}{{k_f}^{1/3}c}.\n\\end{equation}\n\\Add{Since the characteristic forcing wave number and the dissipation\nrate are approximately equal to $k_f \\equiv 6 \\delta k \\simeq 0.75$\nand $\\eps \\simeq P_0 = 1$, the forcing Froude number is approximately\ninversely proportional to the wave speed: $F_f \\simeq 1.1/c$. This\nallows us to simply use the wave speed to denote the simulations.}\n% where $k_f \\equiv 6 \\delta k = 0.75$ is a wave number characterizing\n% the forcing.\n%\nThe ratio $\\kdiss/k_f$ gives an order of magnitude of the width of the\ninertial range.  It is a physical quantity related to the numerical\nresolution on which the flow can depend.\n%\nTable~\\ref{tab} also displays the minimum thickness $\\min(h)$\ncharacterizing the importance of the non-quadraticity of the energy,\nand $\\max(|\\uu|/c)$, which can be interpreted as the maximum of a\nlocal Froude number.\n\n\n\n\n", "meta": {"hexsha": "4f668567beef31f780a415f97ed8341c4ac4a4cd", "size": 11531, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Old/section_methods.tex", "max_stars_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_stars_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-23T11:06:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-23T11:06:53.000Z", "max_issues_repo_path": "Old/section_methods.tex", "max_issues_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_issues_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-08-23T13:00:31.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-23T13:00:31.000Z", "max_forks_repo_path": "Old/section_methods.tex", "max_forks_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_forks_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.4366666667, "max_line_length": 167, "alphanum_fraction": 0.6952562657, "num_tokens": 3978, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4398710365631421}}
{"text": "\\documentclass[12pt]{article}\n\\newcommand{\\N}{\\mathrm{N}}\n\\newcommand{\\m}{\\mathrm{m}}\n\\newcommand{\\cm}{\\mathrm{cm}}\n\\newcommand{\\s}{\\mathrm{s}}\n\\renewcommand{\\min}{\\mathrm{min}}\n\\renewcommand{\\l}{\\ell}\n\\newcommand{\\C}{\\mathrm{deg\\,C}}\n\\newcounter{problem}\n\\begin{document}\\thispagestyle{empty}\n\n\\section*{NYU General Physics 1---Problem set 13}\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nIn lecture we discussed the pressure gradient in a bus accelerating at\n$2\\,\\m\\,\\s^{-2}$.\n\n\\textsl{(a)} By thinking about the size of the interior of the bus,\nthe density of air, and so on, compute roughly the \\emph{horizontal}\npressure difference inside the bus.  That is, how much larger is the\npressure at the back of the bus than the front of the bus?  (If it is\nat all confusing to you that the equal-pressure surfaces are slanted,\nconsider the pressure difference between a point at the front of the\nbus and a point at the back of the bus, where both points are at the\nsame height above ``sea level''.)  Give your answer in both\n$\\N\\,\\m^{-2}$ and atmospheres.\n\n\\textsl{(b)} What things did you have to assume to give your answer?\nWhy did we assume that the windows on the bus are all closed?\nWhat do you think happens if the windows all along the bus\n\\emph{aren't} closed?\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nBlood flows through the aorta at a volumetric rate of something like\n$5\\,\\l\\,\\min^{-1}$.\n\n\\textsl{(a)} If the aorta has a diameter of $3.5\\,\\cm$, at what speed\n$v$ does the blood flow?  Did you have to make any assumptions to\nanswer that?\n\n\\textsl{(b)} Imagine that, because of a pathology, over a $20\\,\\cm$\nlength, the aorta narrows to $2.5\\,\\cm$ in diameter.  What is the\nvelocity change $\\Delta v$ from one end of this to the other?\n\n\\textsl{(c)} Consider a little cube of blood in the part of the aorta\nthat is getting narrower.  Give the cube a side length $\\Delta x$ and\nnote that it is \\emph{accelerating}.  What---qualitatively---does this\nmean about the pressure in the aorta?  Ignore gravity for this\nproblem; imagine that all blood flow is driven by blood pressure (this\nis true if the patient is lying down).\n\n\\textsl{(d)} In preparation for part \\textsl{(e)}, find a combination\nof speed $v$ and mass density (mass per volume) $\\rho$ that has\ndimensions of pressure.  Look up the density of blood and compute the\npressure corresponding to the velocity $v$ you found in\npart \\textsl{(a)}.\n\n\\textsl{(e)} Compute the pressure change from one end of this\nnarrowing aorta to the other end, by thinking about the pressure\ngradient at each point that produces the necessary local acceleration.\n\\emph{Note: This is not easy!}  Compare your result to normal mean\nhuman blood pressure.  Discuss with your friends and colleagues.\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\n[\\textsl{optional}] What is the most expensive ingredient of a\nstandard American Thanksgiving dinner, \\emph{by weight}?  (That is, by\ndollars per pound.)  How does this value compare to the dollars per\npound of gold we computed in Problem~Set~1?  What does all this have\nto do with the history of Western Civilization?\n\n\\end{document}\n", "meta": {"hexsha": "5ab181b6eab2c1919260bed0f5cd48ac4850ec77", "size": 3167, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/gp1_ps13.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/gp1_ps13.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/gp1_ps13.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9861111111, "max_line_length": 70, "alphanum_fraction": 0.748658036, "num_tokens": 867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7718434978390747, "lm_q1q2_score": 0.43983706372037396}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{September 14 2018}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Continuity}\n\n\\begin{definition}\n  Consider a function \\[f: A \\to \\reals^n\\]\n\\end{definition}\n\\(f\\) is \\underline{continuous} at \\(A\\) if for every \\(\\epsilon > 0\\), \\(\\exists \\delta > 0\\) such that \\(|f(x) - f(a)| < \\epsilon\\) whenever \\(|x - a| < \\delta, x \\in A\\).\n\\begin{theorem}\n  \\(f\\) is continuous if and only if for every open \\(U \\subset \\reals^n\\), \\(f^{-1}(U) = A \\cap V\\) where \\(V\\) is open in \\(\\reals^n\\).\n\\end{theorem}\n\\begin{proof}\n\n  \\begin{itemize}\n\n    \\item [\\(\\implies\\)] consider \\(U\\) open in \\(\\reals^n\\). Let \\(a \\in f^{-1}(U)\\). For some \\(\\epsilon > 0\\), \\(\\exists\\) a ball \\(B_{f(a)} = B(f(a), \\epsilon) \\subset U\\) because \\(U\\) is open.\n\n    Since \\(f\\) is continuous at \\(a\\), \\(\\exists \\delta > 0\\) such that \\(f(x) \\in B_{f(a)}\\) for every \\(x \\in A \\cap B(a, \\delta) = B_a\\). We can define\n    \\[V = \\bigcup_{a \\in f^{-1}(U)}B_a\\]\n\n    \\item [\\(\\impliedby\\)] Consider \\(a \\in A\\) and let \\(\\epsilon > 0\\). Let \\(U = B(f(a), \\epsilon)\\). Then \\(f^{-1}(U) = A \\cap V\\) for some open \\(V \\subset \\reals^n\\).\n    \\[a \\in V \\implies \\exists \\delta > 0, B(a, \\delta) \\subset V\\]\n    But everything which lies inside \\(V\\) gets mapped inside \\(U\\) which is that first ball that we started with. And this is the condition that we want.\n\n  \\end{itemize}\n\\end{proof}\n\n\\begin{corollary}\n  A composite of continuous functions is continuous\n\\end{corollary}\n\\begin{proof}\n  Let\n  \\[f: A \\to \\reals^n, g: B \\to \\reals^p\\]\n  be continuous functions where \\(B \\subset \\reals^n\\) and \\(f(A) \\subset B\\).\n\n  Consider open \\(U \\subset \\reals^p\\). We know\n  \\[\\exists V \\subset \\reals^n \\text{ open, } g^{-1}(U) = B \\cap V\\]\n  So we can write\n  \\[(g \\circ f)^{-1}(U) = f^{-1}(g^{-1}(U)) = f^{-1}(B \\cap V) = f^{-1}(V)\\]\n  We know that\n  \\[\\exists W \\subset \\reals^n \\text{ open, }, f^{-1}(V) = A \\cap W = (g \\circ f)^{-1}(U)\\]\n  But this is exactly what we wanted to show\n\\end{proof}\n\n\\begin{exercise}\n  Let \\(f = (f_1,...,f_n)\\) be a function from \\(\\reals\\) to \\(\\reals^n\\). Then \\(f\\) is continuous if and only if \\(\\forall i \\in \\{1,...,n\\}\\), \\(f_i\\) is continuous.\n\\end{exercise}\n\\begin{proof}\n  \\begin{itemize}\n\n    \\item [\\(\\impliedby\\)] We need to estimate the norm \\(|f(x) - f(a)|\\) with the differences between \\(f_i(x_i)\\) and \\(f_i(a_i)\\). We could use a variety of inequalities for this, including\n    \\[|f(x) - f(a)| \\leq \\sum_{i = 1}^n|f_i(x) - f_i(a)|\\]\n    The full \\(\\epsilon\\)-\\(\\delta\\) argument is left as an exercise.\n\n    \\item [\\(\\implies\\)] We need to estimate the norm \\(|f_i(x) - f_i(a)| < |f(x) - f(a)|\\). Alternatively, we can do this topologically. The full argument is left as an exercise.\n\n  \\end{itemize}\n\n\\end{proof}\n\\begin{exercise}\n  A linear transformation \\(T: \\reals^m \\to\\reals^n\\) is \\underline{uniformly} continuous\n\\end{exercise}\n\\begin{definition}\n   There is a norm \\(M > 0\\) such that \\(|T(x)| \\leq M|x|\\). Hence,\n   \\[|T(x) - T(y)| = |T(x - y)| \\leq M|x - y|\\]\n   Given \\(\\epsilon\\), take \\(\\delta = \\frac{\\epsilon}{M}\\).\n\\end{definition}\n\\begin{exercise}\n  Are the following functions continuous?\n  \\begin{enumerate}\n    \\item \\(f(x, y) = \\frac{x^2 - y^2}{x^2 + y^2}\\) - No\n    \\item \\(f(x, y) = \\frac{x^2 + 3xy + y^2}{x^2 + 4xy + y^2}\\) - No\n    \\item \\(f(x, y) = e^{-\\frac{|x - y|}{x^2 - 2xy + y^2}} = e^{-\\frac{1}{|x - y|}}\\) - Yes\n  \\end{enumerate}\n\\end{exercise}\n\\begin{proof}\n  \\begin{enumerate}\n    \\item \\(f\\) is 1 along the line \\(\\{f(x, 0) : x \\in \\reals\\}\\), but -1 along the line \\(\\{f(0, y) : y \\in \\reals\\}\\), both of which traverse the origin.\n    \\item No for the same reason, but we can't check on the axes, since each axis is 1. Instead, we can check on the \\(x\\) axis and compare that with any line except the \\(y\\) axis, such as \\(y = x\\), where the value is \\(\\frac{5}{6}\\)\n    \\item Composite of \\(z \\mapsto e^{\\frac{1}{|z|}}\\) and \\((x, y) \\mapsto x - y\\)\n  \\end{enumerate}\n\\end{proof}\n\\begin{exercise}\n  Let \\(X \\subseteq \\reals^n\\). We define the \\underline{distance function}\n  \\[d(x, X) = \\inf_{a \\in X}|x - a|\\]\n  \\(\\forall X \\in \\mc{P}(\\reals^n), d(x, X)\\) is uniformly continuous on \\(\\reals^n\\)\n\\end{exercise}\n\n\\end{document}\n", "meta": {"hexsha": "6d58372099ee04384f34fb16fecb49e4aa9c123e", "size": 4994, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/september14.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/september14.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/september14.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.952, "max_line_length": 235, "alphanum_fraction": 0.6081297557, "num_tokens": 1844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.4398370577389472}}
{"text": "\\documentclass{article}\r\n\\usepackage[utf8]{inputenc}\r\n\\usepackage{mathtools}\r\n\\usepackage{titlesec}\r\n% \\usepackage{amsmath,amssymb}\r\n\\usepackage{amsfonts,amsmath,amssymb}\r\n\\usepackage{cleveref}\r\n\\usepackage{bm}\r\n\\usepackage{algorithm}\r\n\\usepackage{algpseudocode}\r\n\\usepackage{pifont}\r\n\\usepackage{color}\r\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\r\n\r\n% TODO\r\n% check that \\*z_k = (z_{k,1} ... z_{k,J}) is introduced correctly\r\n% handle initial states in M-Step section\r\n\r\n\r\n\r\n\r\n\\crefname{section}{§}{§§}\r\n\r\n\\DeclareMathOperator{\\E}{\\mathbb{E}}\r\n\\DeclareMathOperator{\\Pp}{\\mathbb{P}}\r\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\r\n\r\n\r\n\\newcommand{\\g}{\\mathbf{g}}\r\n\\newcommand{\\m}{\\mathbf{m}}\r\n\\newcommand{\\vv}{\\mathbf{v}}\r\n\\newcommand{\\n}{\\mathbf{n}}\r\n% \\newcommand{\\*x}{\\mathbf{x}}\r\n\\newcommand{\\z}{\\mathbf{z}}\r\n\\newcommand{\\G}{\\mathbf{G}}\r\n\\newcommand{\\Hh}{\\mathbf{H}}\r\n% \\newcommand{\\*x}{\\mathbf{X}}\r\n\\newcommand{\\W}{\\mathbf{W}}\r\n\\newcommand{\\V}{\\mathbf{V}}\r\n\\newcommand{\\data}{\\mathcal{D}}\r\n\\newcommand{\\tr}{\\text{T}}\r\n\r\n\\def\\code#1{\\texttt{#1}}\r\n\\def\\*#1{\\mathbf{#1}}\r\n\r\n\r\n\r\n\\title{Spectrogram Estimation for Spiking Data}\r\n\\author{Andrew Song, John Tauber}\r\n\\date{2021}\r\n\r\n\\begin{document}\r\n\r\n\\maketitle\r\n\r\n\\section{Notation}\r\nThe goal of this document will be to outline a generative model and inference\r\nframework for estimating a spectrogram from spiking observations. This will\r\nserve as the basis for combining with lfp data. The notation is as follows:\r\n\r\n\\begin{align*}\r\n   &\\text{window } k = 1, \\ldots, K \\\\\r\n   &\\text{timebin } j = 1, \\ldots, J \\text{ time within window K} \\\\\r\n   &n^c_{k,j} \\in \\{0,1\\} := \\text{spike data at time $j$ within window $k$ for neuron $c$} \\\\\r\n   &\\lambda^c_{k,j} := \\text{CIF at time $j$ in window $k$ for neuron c} \\\\\r\n   &\\W \\in \\mathbb{C}^{J \\times J} := \\text{inverse-DFT matrix} \\\\\r\n   &\\*x^{\\text{T}} := \\text{transpose of vector } \\*x \\\\\r\n   &\\*z_k\\in\\mathbb{C}^J := (z_{k,1} \\ldots, z_{k,J} )^{\\text{T}} \r\n      \\text{as in \\cite{Kim2018}}\\\\\r\n   &\\mathcal{L}(\\cdot \\mid \\cdot) - \\text{emphasizes likelihood function}\r\n\\end{align*}\r\n\r\n\\section{Generative Model}\r\nAssume we have a time series of spiking observations of length $T$ consisting of\r\ndata from $C$ neurons. We divide the data into $K$ windows of length $J$, such\r\nthat $T = KJ$.  We denote the full set of\r\nspiking observations as \r\n\\begin{equation*}\r\n   \\data = \\{n^c_{k,j}\\}_{k=1, j=1, c=1}^{K,J,C}\r\n\\end{equation*}\r\n\r\nWe assume as our model for $\\data$ a discrete-time approximation to a\r\npoint process, where the conditional intensity function (CIF) for neuron $c$ at time $t = k+j$\r\nis a logistic function of a latent process $X_t$\r\n\\begin{equation}\r\n   \\lambda^c_{k,j} = \\frac{1}{1 + \\exp(-(\\mu^c + \\beta^c x_{k,j}))}\r\n\\end{equation}\r\nsuch that, for $c = 1, \\ldots, C$: \r\n\\begin{equation}\r\n   n^c_{k,j} \\sim \\text{Bernoulli}(\\lambda^c_{k,j})\r\n\\end{equation}\r\n\r\nWe assume that in each window $k$ the latent process $X_k,j$ is second-order\r\nstationary. Letting $\\*x_k$ denote $(x_{k,1}, \\ldots, x_{k,J})^{\\text{T}}$, and\r\nfollowing the approach of \\cite{Kim2018}, we let: \r\n\\begin{equation}\r\n   \\*x_k = \\W \\*z_k\r\n\\end{equation}\r\nwhere $\\W$ is an inverse spectral transformation matrix (see Appendix B1), and\r\n$\\*z_k$ is the random walk process across the windows:\r\n\\begin{equation}\r\n   \\*z_k = \\*z_{k-1} + \\nu_k \\quad \\quad \\nu_k \\sim \\mathcal{N}(0, \r\n      \\operatorname{diag}(\\sigma_{\\nu,1}^2,\\ldots, \\sigma_{\\nu,J}^2))\r\n\\end{equation}\r\n\r\nNote that without the prior $\\*z_k = \\*z_{k-1} + \\nu_k$, we\r\ncould estimate the $\\*z_k$ independently across the windows as in\r\n\\cite{Miran2017}. However, we would like to have the stochastic continuity\r\nconstraint, as this provides denoising of the spectrogram - when estimating a\r\nspectrogram in a specific window, the algorithm effectively pools together\r\nestimates from neighboring windows~\\cite{Kim2018}. We also add there are\r\ndifferent ways to encode stochastic continuity, such as through integrated\r\nWiener Process (IWP)~\\cite{Song18}. This completes the setup of the generative\r\nmodel. \r\n\r\n\\section{Inference}\r\nLet $\\theta = \\{\\sigma^2_{\\nu,j}, \\mu^c, \\beta^c \\}_{j=1,c=1}^{J,C}$. For\r\ninference, we are interested in 1) parameter estimation of $\\theta$ to obtain\r\n$\\widehat{\\theta}$ and 2) computation of the posterior distribution $\\Pp\r\n(\\*z_k\\mid \\data, \\widehat{\\theta})$. The complete-data likelihood can be\r\nexpressed as:\r\n\\begin{align}\r\n   \\log \\mathcal{L}(\\theta) &= \\log \\Pp(\\data, \\*z_{1:K} \\mid \\theta) \\nonumber \\\\\r\n   &= \\log \\Pp (\\data \\mid \\*z_{1:K}, \\theta) + \\log \\Pp(\\*z_{1:K} \\mid \\theta),\r\n\\end{align}\r\nwhich under our generative model is:\r\n\\begin{align}\r\n      \\sum_{k=1}^K & \\sum_{c=1}^C \\sum_{j=1}^J  n_{k,j}^c (\\mu^c + \\beta^c (\\text{W}\\*z_k)_j)\r\n      - \\log \\big(1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k)_j) \\big) \\nonumber \\\\\r\n   &-(K\\sum_{j=1}^J\\log(\\pi \\sigma^2_{\\nu,j}) - \\sum_{k=1}^K \\sum_{j=1}^J \\frac{\\mid \\mid z_{k,j}  - \r\n      z_{k-1,j} \\mid \\mid^2}{\\sigma_{\\epsilon, j}^2} \r\n\\end{align}\r\nBecause we do not observe the $\\*z_k$'s, however, we will look to\r\nexpectation maximization for a solution, which leads us to a state space model\r\nconstruction. \r\n\r\nHowever, the point-process likelihood (using either Poisson or binomial forms)\r\npresents a challenge, since the Gaussian prior on $\\*z_k$ is not a conjugate\r\nprior to the likelihood. For this reason, we don't have access to the analytical\r\nform for the posterior distribution. A few solutions exist. First, one could use\r\ndata-augmentation scheme via Polya-Gamma data augmentation~\\cite{Polson13} and\r\nobtain Monte Carlo (MC) samples from the exact posterior distribution. With MC\r\nsamples, one can approximate the required expectations in the E-step, leading to\r\nMonte Carlo EM (MCEM)~\\cite{Zhang18}.\\\\\\\\\r\nThe second option is to be make a Laplace approximation to the binomial\r\nlikelihood. The naive approach (Laplace approximation to the entire data) would\r\nbe computationally expensive, as this results in a covariance matrix of dimension\r\n$KJ\\times KJ$. Rather, we make the following observations: 1) if the\r\nobservations were instead complex Gaussian instead of Binomial, the problem\r\nwould be reduced to a frequency domain Kalman filter (FDKF) as in\r\n\\cite{Kim2018}, and 2) for a given window $k$, we can use a Laplace\r\napproximation to the point process spectra as in \\cite{Miran2017}. See Appendix\r\nB2 for details. \r\n\\newline\r\n\r\n\\section{Algorithm}\r\n\r\n\r\nAt the $(s+1)^{\\text{th}}$ iteration of the EM algorithm, we want to take the\r\nexpectation of the complete data log-likelihood $\\log \\mathcal{L}(\\theta)$ with\r\nrespect to the posterior distribution $\\Pp(\\*z_{1:K}|\\data,\\theta^{(s)})$. We\r\nthus have\r\n\\begin{align}\r\n   \\E [\\log \\mathcal{L}(\\theta)\\,|\\,\\data,\\theta^{(s)}] &= \\E [\\log \\Pp(\\data, \\*z_{1:K} \\mid \\theta)\\,|\\,\\data,\\theta^{(s)}] \\nonumber \\\\\r\n   &= \\E [\\log \\Pp (\\data \\mid \\*z_{1:K}, \\theta) + \\log \\Pp(_{1:K} \\mid \\theta)\\,|\\,\\data,\\theta^{(s)} ], \\nonumber\r\n\\end{align}\r\nwhich under our model is\r\n\\begin{align}\\label{eq:qfunc}\r\n   \\E [\\log \\mathcal{L}(\\theta)|\\data,\\theta^{(s)}]=\\E & \\Bigg[ \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C n_{k,j}^c (\\mu^c + \\beta^c (\\text{W}\\*z_k)_j) \r\n      - \\log \\big(1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k)_j ) \\big) \\nonumber \\\\  \r\n   & -(K\\sum_{j=1}^J\\log(\\pi \\sigma^2_{\\nu,j}) - \\sum_{k=1}^K \\sum_{j=1}^J \\frac{\\mid \\mid z_{k,j}  - \r\n      z_{k-1,j}  \\mid \\mid^2}{\\sigma_{\\nu, j}^2} \\,\\Big|\\,\\data,\\theta^{(s)}\\Bigg].\r\n\\end{align}\r\nThe following quantities are needed for computing the expectation in\r\nEq.~(\\ref{eq:qfunc})\r\n\\begin{equation}\\label{eq:exps}\r\n   \\begin{split}\r\n   \\*z_{k \\mid K}  &= \\E [ \\*z_k \\mid \r\n      \\data, \\theta^{(s)}] \\\\\r\n   \\Lambda_{k \\mid K} &= \\E [ || \\*z_k ||^2 \r\n      \\mid \\data, \\theta^{{(s)}}] \\\\\r\n   \\Lambda_{k, k-1 \\mid K} &= \\E [ \\*z_k \\*z^*_{k-1}  \r\n      \\mid \\data, \\theta^{{(s)}}]\r\n   \\end{split}\r\n\\end{equation}\r\n\\subsection{Filter}\r\nThese quantities can be efficiently computed using a Kalman filtering and\r\nsmoothing algorithm. Let us focus primarily on the Kalman filtering, as the\r\nKalman smoother is straightforward once we compute the prediction/update\r\nquantities in the filter step. First the one-step prediction for filtering is\r\nsimply given as\r\n\\begin{equation}\r\n    \\begin{split}\r\n    \\*z_{k \\mid k-1} &= \\*z_{k-1 \\mid k-1}  \\\\\r\n   \\sigma^2_{k \\mid k-1,j} &= \\sigma^2_{k-1 \\mid k-1, j} + \\sigma^2_{\\nu, j}. \\\\\r\n   \\end{split}\r\n\\end{equation}\r\nThe one-step update requires more attention, due to the fact that $\\Pp\r\n(\\data_k|\\*z_k)$ is not a Gaussian distribution. To this end, we perform\r\nGaussian approximation, i.e., Laplace approximation, to the posterior\r\ndistribution $\\Pp (\\*z_k \\mid \\data_{1:k},\\theta)$, such that $\\Pp (\\*z_k \\mid\r\n\\data_{1:k},\\theta)\\sim\r\n\\mathcal{N}(\\*z_{k|k},\\operatorname{diag}(\\sigma_{k|k,1}^2,\\ldots,\\sigma_{k|k,J}^2))$~\\cite{Smith03}.\\\\\r\n\r\nUsing Bayes's rule on $\\Pp (\\*z_k \\mid \\data_{1:k})$ (we drop $\\theta$ for notational simplicity), we have\r\n\\begin{equation}\\label{eq:kf_bayes}\r\n    \\begin{split}\r\n   \\Pp ( \\*z_k \\mid \\data_{1:k}) & \\propto\\int\\Pp(\\data_k,\\*z_k, \\*z_{k-1}|\\data_{1:k-1})\\,d(\\*z_{k-1})\\\\\r\n   & =\r\n      \\int\\Pp (\\data_k \\mid\\*z_k) \r\n      \\Pp (\\*z_k \\mid\\*z_{k-1})\\Pp(\\*z_{k-1}| \\data_{1:k-1}) \\,d(\\*z_{k-1}) \\\\\r\n  & =\r\n      \\Pp (\\data_k \\mid\\*z_k) \\underbrace{\\int\r\n      \\Pp (\\*z_k \\mid\\*z_{k-1})\\overbrace{\\Pp(\\*z_{k-1}| \\data_{1:k-1})}^{\\data(\\*z_{k-1|k-1},\\Sigma_{k-1|k-1})} \\,d(\\*z_{k-1})}_{\\Pp (\\*z_k \\mid \\data_{1:k-1})=\\data(\\*z_{k|k-1},\\Sigma_{k|k-1})} \\\\\r\n   &= \\Pp (\\data_k \\mid \\*z_k) \\Pp (\\*z_k \\mid \\data_{1:k-1}).\r\n      \\end{split}\r\n\\end{equation}\r\nNote that all conditional independence relations follow from our generative\r\nmodel. With Eq.~(\\ref{eq:kf_bayes}), we can proceed with the Laplace\r\napproximation as follows\r\n\\begin{equation}\r\n    \\begin{split}\r\n      \\*z_{k|k}&=\\argmax_{\\*z_k}\\log \\Pp(\\*z_k | \\data_{1:k})\\\\\r\n      &=\\argmax_{\\*z_k}\\{\\log\\Pp (\\data_k \\mid \\*z_k) +\\log\\Pp (\\*z_k \\mid \\data_{1:k-1})\\}\\\\\r\n      &= \\argmax_{\\*z_k} \\Big\\{ \\sum_{c=1}^C \\sum_{j=1}^J n_{k,j}^c ( \\mu^c + \\beta^c (\\W \\*z_k)_j) \r\n         - \\log \\big(1 + \\exp ( \\mu^c + \\beta^c(\\W \\*z_k )_j ) \\big)\\\\\r\n      &\\quad \\quad \\quad \\quad \\quad \\quad - \\sum_{j=1}^J \\frac{|| z_{k,j} - \r\n         z_{k|k-1,j}||^2} {\\sigma^2_{\\nu,j}}\\Big\\}.\r\n    \\end{split}\r\n\\end{equation}\r\nTo compute $\\Sigma_{k|k}$, we compute Hessian of both sides. The full details are given in \\ref{Newton}\r\n\r\n% TODO Update for pp params\r\n\\subsection{Newton's Method for State Update}\r\n\\begin{algorithm}\r\n\\caption{Newton's Method for Window $k$ Gaussian Approximation}\r\n\\label{Newton}\r\n\\begin{algorithmic}[1]\r\n\\State $\\z^{(0)} = \\mathbf{0}; \\quad i=0$\r\n\\State $\\bar{n} = \\sum_{c=1}^C n^c_{k,j}$\r\n\\While {$\\text{crit} = 0$}\r\n\\State $i \\leftarrow i + 1$\r\n\\State $\\*x = \\W \\z^{(i-1)}$\r\n\\State $\\lambda = \\frac{1}{1 + e^{\\*x}}$\r\n\\State $\\vv = \\Big(\\frac{z_1^{(i-1)} - \\*z_{k-1 \\mid k-1}(\\omega_1)}{\\sigma^{2(s)}_{\\nu,1}},\r\n   \\cdots, \\frac{z_J^{(i-1)} - \\*z_{k-1 \\mid k-1}(\\omega_J)}{\\sigma^{2(s)}_{\\nu,J}} \\Big)^{\\tr}$\r\n\\State $\\g = C\\W^{\\tr}(\\bar{\\n} - \\lambda) - \\vv \\quad$ \r\n\\State $\\V = \\text{diag}\\Big( \\frac{1}{\\sigma^{2(s)}_{\\nu,1}}, \\cdots, \r\n   \\frac{1}{\\sigma^{2(s)}_{\\nu,J}}\\Big)$\r\n\\State $\\G = \\text{diag}\\Big(\\frac{e^{x_1}}{(1+e^{x_1})^2}, \\cdots, \\frac{e^{x_K}}{(1+e^{x_K})^2} \\Big) $\r\n\\State $\\Hh = -C \\W^{\\tr} \\G \\W - \\V \\quad$ \r\n\\State $\\z^{(i)} = \\z^{(i-1)} - \\Hh^{-1}\\g$\r\n\\EndWhile\r\n\\State $\\*z^{(s+1)}_{k \\mid k} = \\z^{(i)}$\r\n\\State $\\*x = \\W \\z^{(1)}$\r\n\\State $\\G = \\text{diag}\\Big(\\frac{e^{x_1}}{(1+e^{x_1})^2}, \\cdots, \\frac{e^{x_K}}{(1+e^{x_K})^2} \\Big) $\r\n\\State $\\Hh = -C \\W^{\\tr} \\G \\W - \\V \\quad$ \r\n\\State $\\sigma^{2(s+1)}_{k \\mid k, j} = - \\frac{1}{\\Hh_{(j,j)}}$\r\n\\end{algorithmic}\r\n\\end{algorithm}\r\n\r\n\\subsection{Smoother}\r\nThe smoothing algorithm is performed as in \\cite{Kim2018}:\r\n\\begin{equation}\r\n   \\begin{split}\r\n      G_{k,j} &= \\sigma^2_{k \\mid k, j} (\\sigma^2_{k + 1\\mid k, j})^{-1} \\\\\r\n      z_{k \\mid K,j} &= z_{k \\mid k, j} \r\n         + G_{k,j} ( z_{k+1 \\mid K, j} - z_{k+1 \\mid k,j} ) \\\\\r\n      \\sigma^2_{k \\mid K,j} &= \\sigma^2_{k\\mid k,j} + G^2_{k,j}(\\sigma^2_{k+1 \\mid K} \r\n         - \\sigma^2_{k+1 \\mid k, j})\r\n   \\end{split}\r\n\\end{equation}\r\n\r\n% TODO update/understand sigmas (add summation over j) to Q func\r\n% TODO check sigma MLE with new babadi paper\r\n\\subsection{M-Step}\r\nIn the M-Step, we maximize the expected log-likelihood of Eq.~(\\ref{eq:qfunc}),\r\nusing the values computed in Eqs.~(\\ref{eq:exps}). Omitting the initial state\r\nand variance for now, for a given frequency $j$ we have:\r\n% TODO - need to add initial state \r\n\\begin{equation}\\label{eq:Q}\r\n   \\begin{split}\r\n      Q(\\theta \\mid \\theta^{(s)}) &= \\E [\\log \\mathcal{L}_j(\\theta)|\\data,\\theta^{(s)}] \\\\\r\n      &= \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C n_{k,j}^c (\\mu^c + \\beta^c (\\text{W}\\*z_{k \\mid K})_j) \\\\\r\n      &- \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C \\E \\Big[ \\log \\big(1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k)_j ) \\big) \\Big ]\\\\\r\n      &- \\sum_{j=1}^J (K)\\log(\\sigma^2_{\\nu,j}) - \\frac{1}{\\sigma^2_{\\nu,j}}\r\n      \\sum_{k=1}^K \\Big(\\Lambda_{k \\mid K,j} + -2\\Lambda_{k,k-1 \\mid K, j} + \\Lambda_{k-1 \\mid K, j}\\Big) %\\\\\r\n      % & + \\text{const.}\r\n   \\end{split}\r\n\\end{equation}\r\n% TODO write out expectations in (8) as is done in Abbas\r\n% ok, approach here: let SSMT code/paper guide this\r\nFor the process variances we calculate a closed-form maximum likelihood estimate (MLE):\r\n% TODO fix for initial state\r\n\\begin{equation}\\label{eq:sigma_mle}\r\n   \\hat{\\sigma}^2_{\\nu,j} = \\frac{1}{K} \\sum_{k=1}^K \\Big(\\Lambda_{k \\mid K,j} + \r\n   -2\\Lambda_{k,k-1 \\mid K, j} + \\Lambda_{k-1 \\mid K, j}\\Big) \\\\\r\n\\end{equation}\r\nwhere the values in Eqs.~(\\ref{eq:exps}) are computed as\r\n\\begin{equation}\\label{exps_est}\r\n   \\begin{split}\r\n      \\Lambda_{k\\mid K,j} &= z_{k \\mid K,j}^2  + \\sigma^2_{k \\mid K,j} \\\\\r\n      \\Lambda_{k,k-1 \\mid K, j} &= z_{k \\mid K,j}  z^*_{k-1 \\mid K,j} \r\n         + G_{k-1,j} \\sigma^2_{k\\mid K,j}\r\n   \\end{split}\r\n\\end{equation}\r\n\r\nThe remaining expectation in Eq.~(\\ref{eq:Q}) does not have a simple closed form\r\nsolution. In order to find estimates for $\\mu^c$ and $\\beta^c$, we proceed with\r\na Monte-Carlo EM procedure to approximate the expectation and find the MLE\r\nnumerically. We maximize the function $R$:\r\n\\begin{equation}\r\n   \\begin{split}\r\n      R(\\mu^1, \\beta^1, \\ldots, \\mu^C, \\beta^C) &= \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C n_{k,j}^c (\\mu^c + \\beta^c (\\text{W}\\*z_{k \\mid K})_j) \\\\\r\n      &- \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C \\sum_{m=1}^M \\log \\big(1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k^{(m)})_j ) \\big) \\\\\r\n      \\simeq \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C n_{k,j}^c &(\\mu^c + \\beta^c (\\text{W}\\*z_{k \\mid K})_j) \r\n         - \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{c=1}^C \\E \\Big[ \\log \\big(1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k)_j ) \\big) \\Big ]\\\\\r\n   \\end{split}\r\n\\end{equation}\r\n\r\n\\noindent where $\\*z_1^{(m)}, \\ldots, \\*z_K^{(m)}$ are draws from the posterior\r\ndistribution over $\\*z_1, \\ldots, \\*z_K$ computed during the E-Step. The gradients are computed using\r\n\\begin{equation}\r\n   \\begin{split}\r\n      \\frac{\\partial R}{\\partial \\mu^c} &= \\sum_{k=1}^K \\sum_{j=1}^J n_{k,j}^c \r\n         - \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{m=1}^M \\frac{\\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k^{(m)})_j )}{1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k^{(m)})_j ) } \\\\\r\n      \\frac{\\partial R}{\\partial \\beta^c} &= \\sum_{k=1}^K \\sum_{j=1}^J n_{k,j}^c(\\text{W} \\*z_{k \\mid K})_j \r\n         - \\sum_{k=1}^K \\sum_{j=1}^J \\sum_{m=1}^M \\frac{(\\text{W} \\*z_k^{(m)})_j \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k)_j )}{1 + \\exp( \\mu^c + \\beta^c (\\text{W} \\*z_k^{(m)})_j ) } \\\\\r\n   \\end{split}\r\n\\end{equation}\r\n\r\n% TODO \r\n\r\n\r\n\r\n% I am unsure about the form / derivation of Eqs.~(\\ref{exps_est}), although it seems to be what is\r\n% implemented in the code for \\cite{Kim2018}. Also, note that in \\cite{Kim2018},\r\n% they use Re$(\\Lambda_{k,k-1 \\mid K, j})$. I have been unable to figure out why\r\n% that is the case, or what ramifications that may have on our implementation.  \r\n\r\n\\newpage\r\n\\bibliographystyle{unsrt}\r\n\\bibliography{specspike}\r\n\r\n\\end{document}\r\n\r\n", "meta": {"hexsha": "8a05ab998170052a1db572baaec80c02f84fc92d", "size": 16094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latent_spec_betas.tex", "max_stars_repo_name": "johntauber/jls_spec_docs", "max_stars_repo_head_hexsha": "6dcb59ccff1a2455b74f55b8aaa07c9554ba9c1e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "latent_spec_betas.tex", "max_issues_repo_name": "johntauber/jls_spec_docs", "max_issues_repo_head_hexsha": "6dcb59ccff1a2455b74f55b8aaa07c9554ba9c1e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latent_spec_betas.tex", "max_forks_repo_name": "johntauber/jls_spec_docs", "max_forks_repo_head_hexsha": "6dcb59ccff1a2455b74f55b8aaa07c9554ba9c1e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.3804034582, "max_line_length": 199, "alphanum_fraction": 0.6125885423, "num_tokens": 6250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.43973113307926326}}
{"text": "\\input{../header.tex}\n\\title{\\vspace{-2cm}INF3490/INF4490 Exercises - Particle Swarms \\& Cartesian Genetic Programming}\n\\author{Eivind Samuelsen\\input{../author_footnote.tex}}\n\\date{}\n\n% Removing paragraph indents is sometimes useful:\n\\setlength\\parindent{0pt}\n% ==============================================================================\n\n% ================================= DOCUMENT ===================================\n\\begin{document}\n    \\renewcommand\\marginsymbol[1][0pt]{%\n  \\tabto*{0cm}\\makebox[-1cm][c]{$\\mathbb{P}$}\\tabto*{\\TabPrevPos}}\n\n\\maketitle\n\\input{../intro.tex}\n\n\\section{Particle Swarm Optimizations}\nThe particle swarm velocity update formula is\n\\begin{equation}\n    v_i^{(t+1)} \\leftarrow \\alpha v_i ^{(t)} + U(0,\\beta)(p_i-x_i^{(t)}) + U(0,\\beta)(p_g - x_i^{(t)})\n\\end{equation}\nIf we replaced the random terms related to personal and global best with a term proportional to the local objective function gradient, like this:\n\\begin{equation}\n    v_i^{(t+1)} \\leftarrow \\alpha v_i ^{(t)} + \\gamma \\nabla f(x_i^{(t)})\n\\end{equation}\nHow would the particles behave? How does this compare to gradient ascent?\n\n\\section{Cartesian Genetic Programming}\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{cartesian.png}\n\\end{center}\n\\end{figure}\nUsing the setup above, construct circuits from the Cartesian genetic programming genotypes below:\n\\begin{itemize}\n    \\item 231 110 323 121 165 046 154 176 11 5 8 9\n    \\item 003 332 123 010 167 075 345 365 9 10 11 4\n\\end{itemize}\n\n\\input{../contact.tex}\n\\end{document}\n% ==============================================================================\n", "meta": {"hexsha": "4a640310d9a6df91c1701c7dbede8ef599334d1a", "size": 1633, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "material/week10/inf3490-ex10.tex", "max_stars_repo_name": "mpambasange/MachineLearning", "max_stars_repo_head_hexsha": "8b813345264513a57934317b01e1311628dc5b01", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2016-09-01T08:50:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T20:56:07.000Z", "max_issues_repo_path": "material/week10/inf3490-ex10.tex", "max_issues_repo_name": "olehermanse/INF3490-PythonAI", "max_issues_repo_head_hexsha": "8b813345264513a57934317b01e1311628dc5b01", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-20T09:36:19.000Z", "max_issues_repo_issues_event_max_datetime": "2017-08-29T00:28:54.000Z", "max_forks_repo_path": "material/week10/inf3490-ex10.tex", "max_forks_repo_name": "olehermanse/INF3490-PythonAI", "max_forks_repo_head_hexsha": "8b813345264513a57934317b01e1311628dc5b01", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2016-10-31T12:30:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-15T12:12:50.000Z", "avg_line_length": 37.1136363636, "max_line_length": 145, "alphanum_fraction": 0.6227801592, "num_tokens": 460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863698, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4397311325767045}}
{"text": "\\subsubsection{Formal encoding of recursive datatypes.}\n\nWe define the compilation scheme for recursive datatype bindings in\n\\cref{fig:compile-recursive-datatypes}, along with a number of auxiliary\nfunctions. We will reuse some of the functions from\n\\cref{fig:compile-datatypes}, but many of them need variants for the\nrecursive case, which are denoted with a $\\rec$ superscript.\n\n\\begin{figure}[!t]\n  \\centering\n  \\begin{displaymath}\n  \\begin{array}{l@{\\ }l@{\\ }l}\n  \\multicolumn{3}{l}{\\textsf{Throughout this figure when $l$, $d$, or $c$ is an argument}}\\\\\n  \\multicolumn{3}{l}{l = \\tlet\\, \\rec\\, \\seq{d} \\tin\\, t} \\\\\n  \\multicolumn{3}{l}{d = \\datatype{X}{(\\seq{Y :: K})}{x}{(\\seq{c})}} \\\\\n  \\multicolumn{3}{l}{c = x(\\seq{T})}\\\\\n  \\\\\n  \\multicolumn{3}{l}{\\textsc{Auxiliary functions}}\\\\\n  \\tagKind{l}\n  &=& \\seqKindArr{\\dataKind{d}}{\\Type}\\\\\n  \\dtTag{l}{d}{k}\n  &=& \\lambda (\\seq{Y::K}) . \\lambda (\\seq{X :: \\dataKind{d}}) . X_k\\ \\seq{Y}\\\\\n  \\dtInst{f}{l}{d}{k}\n  &=& \\lambda (\\seq{Y::K}). f\\ (\\dtTag{l}{d}{k}\\ \\seq{Y})\\\\\n  \\dtFamily{l}\n  &=& \\lambda (r :: \\seqKindArr{\\dataKind{d}}{\\Type})\\ . \\lambda (t :: \\tagKind{l}) . \n  \\tlet\\, \\seq{X = \\dtInst{\\fixed{r}}{\\fixed{l}}{d_j}{j}}^j\\, \\tin\\, t\\  \\seq{\\scottTy{d}}\\\\\n  \\dtInstFinal{l}{d}{k}\n  &=& \\lambda (\\seq{Y::K}) . \\ifix\\ \\dtFamily{l}\\ (\\dtTag{l}{d}{k}\\ \\seq{Y})\\\\\n  \\unveilRec{l}{t}\n  &=& t\\seq{\\subst{X}{\\dtInstFinal{\\fixed{l}}{d_j}{j}}}^j \\\\\n  \\constrRec{l}{d}{c}{k}{m}\n  &=&\\Lambda (\\seq{Y::K}) . \n  \\lambda (\\seq{a : T}) . \n  \\wrap\\ \\dtFamily{l}\\ (\\dtTag{l}{d}{k}\\ \\seq{Y})\\\n  (\\Lambda R . \n  \\lambda (\\seq{b : \\branchTy{c}{\\fixed{R}}}) . \n  ~b_m ~ \\seq{a})\\\\\n  \\constrsRec{l}{d}{k} &=& \\seq{\\constrRec{\\fixed{l}}{\\fixed{d}}{c_j}{k}{j}}^j\\\\\n  \\matchRec{l}{d}{k}\n  &=& \\Lambda (\\seq{Y::K}). \\lambda (x : \\dtInstFinal{l}{d}{k}\\ \\seq{Y}) . \\unwrap x\\\\\n  \\\\\n  \\multicolumn{3}{l}{\\textsc{Compilation function}}\\\\\n  \\compiledatarec(l)\n  &=&(\\Lambda (\\seq{\\dataBind{d}}) . \\lambda (\\seq{\\constrBinds{d}}) . \\lambda (\\seq{\\matchBind{d}}) . t)\\\\\n  &&\\{ \\seq{\\dtInstFinal{l}{d_j}{j}}^j \\} \\\\\n  &&\\seq{\\constrsRec{\\fixed{l}}{d_j}{j}}^j\\\\\n  &&\\seq{\\matchRec{\\fixed{l}}{d_j}{j}}^j\n  \\end{array}\n  \\end{displaymath}\n\n  \\captionof{figure}{Compilation of recursive datatype bindings}\n  \\label{fig:compile-recursive-datatypes}\n\\end{figure}\n\n\\noindent Let's go through the functions again, this time using $\\Tree$ and\n$\\Forest$ as examples:\n\\begin{align*}\nd_1 &\\defeq \\datatype{\\Tree}{A}{\\textsf{matchTree}}{(\\Node (A, \\Forest A))}\\\\\nd_2 &\\defeq \\datatype{\\Forest}{A}{\\textsf{matchForest}}{(\\NNil(), \\CCons(\\Tree A, \\Forest A))}\n\\end{align*}\n\\begin{itemize}\n  \\item $\\tagKind{l}$ defines the kind of the type-level tags for our\n    datatype family, which is a Scott-encoded tuple of types.\n    $$\\tagKind{l} = (\\Type \\kindArrow \\Type) \\kindArrow (\\Type \\kindArrow \\Type) \\kindArrow \\Type$$\n  \\item $\\dtTag{l}{d}{k}$ defines the tag type for the datatype $d$ in the family.\n    \\begin{align*}\n    \\dtTag{l}{\\Tree}{1} &= \\lambda A . \\lambda (v_1 :: \\Type \\kindArrow \\Type) (v_2 :: \\Type \\kindArrow \\Type) . v_1\\ A\\\\\n    \\dtTag{l}{\\Forest}{2} &= \\lambda A . \\lambda (v_1 :: \\Type \\kindArrow \\Type) (v_2 :: \\Type \\kindArrow \\Type) . v_2\\ A\n    \\end{align*}\n  \\item $\\dtInst{f}{l}{d}{k}$ instantiates the family type $f$ for the\n    datatype $d$ in the family by applying it to the datatype tag.\n    \\begin{align*}\n    \\dtInst{f}{l}{\\Tree}{1} &= \\lambda A . f\\ (\\dtTag{l}{\\Tree}{1}\\ A)\\\\\n    \\dtInst{f}{l}{\\Forest}{2} &= \\lambda A . f\\ (\\dtTag{l}{\\Forest}{2}\\ A)\n    \\end{align*}\n  \\item $\\dtFamily{l}$ defines the datatype family itself. This takes a\n    recursive argument and a tag argument, and applies the tag to the\n    Scott-encoded types of the datatype components, where the types themselves\n    are instantiated using the recursive argument.\n    \\begin{align*}\n    \\dtFamily{l} =&\\ \\lambda r\\ t . \\tlet \\\\\n        &\\quad\\Tree = \\dtInst{r}{l}{\\Tree}{1}\\\\\n        &\\quad\\Forest = \\dtInst{r}{l}{\\Forest}{2}\\\\\n      &\\tin\\, t\\ \\scottTy{d_1}\\ \\scottTy{d_2}\\\\\n    \\scottTy{d_1} =&\\ \\lambda A . \\forall R . (A \\rightarrow \\Forest A \\rightarrow R) \\rightarrow R\\\\\n    \\scottTy{d_2} =&\\ \\lambda A . \\forall R . R \\rightarrow (\\Tree A \\rightarrow \\Forest A \\rightarrow R) \\rightarrow R\n    \\end{align*}\n  \\item $\\dtInstFinal{l}{d}{k}$ is the full recursive datatype family\n    instantiated for the datatype $d$, much like $\\dtInst{f}{l}{d}{k}$, but\n    with the full datatype family.\n    $$\\dtInstFinal{l}{\\Tree}{1} = \\lambda A . \\ifix\\  (\\dtFamily{l})\\ (\\dtTag{l}{\\Tree}{1}\\ A)$$\n  \\item $\\unveilRec{l}{t}$ ``unveils'' the datatypes as before, but\n    unveils all the datatypes and replaces them with the full recursive\n    definition instead of just the Scott-encoded type.\n  \\item $\\constrRec{l}{d}{c}{k}{m}$ defines the constructor $c$ of the \n    datatype $d$ in the family. It is similar to before, but includes a use of $\\wrap$.\n    \\begin{align*}\n    \\constrRec{l}{\\Tree}{\\Node}{1}{1} =&\\ \\Lambda A . \\lambda (v_1 : A) (v_2 : \\Forest A) .\\\\\n                               &\\wrap\\  (\\dtInstFinal{l}{\\Tree}{1})\\ A\\\\\n                               &(\\Lambda R . \\lambda (b_1 : A \\rightarrow \\Forest A \\rightarrow R) . b_1\\ v_1\\ v_2)\\\\\n    \\constrRec{l}{\\Forest}{\\NNil}{2}{1} =&\\ \\Lambda A . \\\\\n                               &\\wrap\\  (\\dtInstFinal{l}{\\Forest}{2})\\ A\\\\\n                               &(\\Lambda R . \\lambda (b_1 : R) (b_2 : \\Tree A \\rightarrow \\Forest A \\rightarrow R) . b_1)\\\\\n      \\constrRec{l}{\\Forest}{\\CCons}{2}{2} =&\\ \\Lambda A . \\lambda (v_1 : \\Tree A) (v_2 : \\Forest A) . \\\\\n                               &\\wrap\\  (\\dtInstFinal{l}{\\Forest}{2})\\ A\\\\\n                               &(\\Lambda R . \\lambda (b_1 : R) (b_2 : \\Tree A \\rightarrow \\Forest A \\rightarrow R) . b_2\\ v_1\\ v_2)\n    \\end{align*}\n  \\item $\\matchRec{l}{d}{k}$ defines the matcher of the datatype $d$ as\n    before, but includes a use of $\\unwrap$.\n    \\begin{align*}\n    \\matchRec{l}{\\Tree}{1} &= \\Lambda A . \\lambda (v : \\Tree A) . \\unwrap\\ v\\\\\n    \\matchRec{l}{\\Forest}{2} &= \\Lambda A . \\lambda (v : \\Forest A) . \\unwrap\\ v\n    \\end{align*}\n\\end{itemize}\n", "meta": {"hexsha": "87c85082fca48263487b0ed55443a3236c5ac445", "size": 6094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/unraveling-recursion/RecursiveDataFormal.tex", "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1299, "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_issues_repo_path": "papers/unraveling-recursion/RecursiveDataFormal.tex", "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2493, "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_forks_repo_path": "papers/unraveling-recursion/RecursiveDataFormal.tex", "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 399, "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "avg_line_length": 52.5344827586, "max_line_length": 131, "alphanum_fraction": 0.5836888743, "num_tokens": 2235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.737158174177441, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4396655691193379}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{tikz}\n\\usetikzlibrary{arrows, automata, graphs}\n\\usetikzlibrary{arrows,%\n                petri,%\n                topaths}%\n\n\\usepackage[latin1]{inputenc}\n\n\\title{Riddler Express \\\\ Precipitation Permutations}\n\\author{Samuel Eklund\\\\linkedin.com/in/sameklund\\\\ \\\\Travis Chambers\\\\linkedin.com/in/travisjchambers}\n\\date{2018-12-07}\n\n\\begin{document}\n\\maketitle\n\n\\section{Problem}\nLouie walks to and from work every day. In his city, there is a 50 percent chance of rain each morning and an independent 40 percent chance each evening. His habit is to bring (and use) an umbrella if it's raining when he leaves the house or office, but to leave them all behind if not. Louie owns three umbrellas.\n\nOn Sunday night, two are with him at home and one is at his office. Assuming it never starts raining during his walk to his home or office, what is the probability that he makes it through the work week without getting wet?\n\n\\section{Description}\nWe start by describing the various states of the system. We  distinguish between Morning $(M)$ and Evening $(E)$. We also count how many umbrellas are at Home $(H_{n})$ and at the Office $(O_{n})$. Using this notation, we describe the starting state as $(M; H_{2}, O_{1})$. We also designate $W_{0}$ and $W_{1}$ as the absorbing states that represent Louie getting wet (as he is traveling with no umbrella while it is raining).\n\n\\newpage\n\n\\section{Solution}\nWe construct a graph of all states, along with their transition probabilities. Blue transitions represent rain and black transitions represent no rain. We also mark the absorbing states $(W_{0}, W_{1})$ in red.\n\n\\begin{center}\n\\begin{tikzpicture}[\nstate/.style={rectangle, draw, node distance = 2cm},\nrain/.style={bend left, auto, ->, color=blue},\nno_rain/.style={bend left, auto, ->}\n]\n% States\n\t\\node[state] (w0) [color=red] {$W_{0}$};\n\t\\node[state] (e1) [below left of=w0] {$E; H_{3}, O_{0}$}; \n\t\\node[state] (m1) [below left of=e1] {$M; H_{3}, O_{0}$};\n\t\\node[state] (e2) [below left of=m1] {$E; H_{2}, O_{1}$};\n\t\\node[initial, state] (m2) [below left of=e2] {$M; H_{2}, O_{1}$};\n\t\\node[state] (e3) [below right of=m2] {$E; H_{1}, O_{2}$};\n\t\\node[state] (m3) [below right of=e3] {$M; H_{1}, O_{2}$};\n\t\\node[state] (e4) [below right of=m3] {$E; H_{0}, O_{3}$};\n\t\\node[state] (m4) [below right of=e4] {$M; H_{0}, O_{3}$};\n\t\\node[state] (w1) [below right of=m4, color=red] {$W_{1}$};\n\n%Transitions\n\t\\path[rain] (e1) edge node [draw=none] {0.4} (w0);\n\t\\path[no_rain] (e1) edge node [draw=none] {0.6} (m1);\n\t\\path[no_rain] (m1) edge node [draw=none] {0.5} (e1);\n\t\\path[rain] (m1) edge node [draw=none] {0.5} (e2);\n\t\\path[rain] (e2) edge node [draw=none] {0.4} (m1);\n\t\\path[no_rain] (e2) edge node [draw=none] {0.6} (m2);\n\t\\path[no_rain] (m2) edge node [draw=none] {0.5} (e2);\n\t\\path[rain] (m2) edge node [draw=none] {0.5} (e3);\n\t\\path[rain] (e3) edge node [draw=none] {0.4} (m2);\n\t\\path[no_rain] (e3) edge node [draw=none] {0.6} (m3);\n\t\\path[no_rain] (m3) edge node [draw=none] {0.5} (e3);\n\t\\path[rain] (m3) edge node [draw=none] {0.5} (e4);\n\t\\path[rain] (e4) edge node [draw=none] {0.4} (m3);\n\t\\path[no_rain] (e4) edge node [draw=none] {0.6} (m4);\n\t\\path[no_rain] (m4) edge node [draw=none] {0.5} (e4);\n\t\\path[rain] (m4) edge node [draw=none] {0.5} (w1);\n\\end{tikzpicture}\n\\end{center}\n\n\\newpage\nWe can create a table of the probabilities of each state based on the previous state, as below. Day 0 represents the initial state, when the probability of moving to $M; H_{2}, O_{1}$ is 1. We omit unnecessary values to reduce calculation, as we only need the values for $W_{0}$ and $W_{1}$.\n\n\\begin{center}\n{\\footnotesize\n\\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|} \n\\multicolumn{10}{c}{State} \\\\ \\cline{2-11}\n\\multicolumn{1}{l|}{Day} & \\rotatebox{90}{$W_{0}$} & \\rotatebox{90}{$E; H_{3}, O_{0}$} & \\rotatebox{90}{$M; H_{3}, O_{0}$} & \\rotatebox{90}{$E; H_{2}, O_{1}$} & \\rotatebox{90}{$M; H_{2}, O_{1}$} & \\rotatebox{90}{$E; H_{1}, O_{2}$} & \\rotatebox{90}{$M; H_{1}, O_{2}$} & \\rotatebox{90}{$E; H_{0}, O_{3}$} & \\rotatebox{90}{$M; H_{0}, O_{3}$} & \\rotatebox{90}{$W_{1}$} \\\\ \\hline\n0.0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n0.5 & 0 & 0 & 0 & 0.5 & 0 & 0.5 & 0 & 0 & 0 & 0 \\\\\n1.0 & 0 & 0 & 0.2 & 0 & 0.5 & 0 & 0.3 & 0 & 0 & 0 \\\\\n1.5 & 0 & 0.1 & 0 & 0.35 & 0 & 0.4 & 0 & 0.15 & 0 & 0 \\\\\n2.0 & 0.04 & 0 & 0.2 & 0 & 0.37 & 0 & 0.3 & 0 & 0.09 & 0 \\\\\n2.5 & 0.04 & 0.1 & 0 & 0.285 & 0 & 0.335 & 0 & 0.195 & 0 & 0.045 \\\\\n3.0 & 0.08 & 0 & 0.174 & 0 & 0.305 & 0 & 0.279 & 0 & 0.117 & 0.045 \\\\\n3.5 & 0.08 & 0.087 & 0 & 0.2395 &  &  & 0 & 0.198 & 0 & 0.1035 \\\\\n4.0 & 0.1148 & 0 & 0.148 &  &  &  &  & 0 & 0.1188 & 0.1035 \\\\\n4.5 & 0.1148 & 0.074 &  &  &  &  &  &  & 0 & 0.1629 \\\\\n5.0 & 0.1444 &  &  &  & &  & &  & & 0.1629 \\\\ \\hline\n\\end{tabular}\n}\n\\end{center}\n\nThe probability that Louie does not get wet during the workweek is:\n\\begin{equation*}\nPr(\\text{Dry}) = 1 - Pr(\\text{Wet}) = 1 - (W_{0} + W_{1}) = 1 - (0.1444 + 0.1629) = 0.6927 = 69.27\\%\n\\end{equation*}\n\n\\end{document}\n", "meta": {"hexsha": "681e3e581eb7a4ba24a08b9e13403124db6caf7e", "size": 5077, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "precipitation permutations/Precipitation Permutations.tex", "max_stars_repo_name": "samueldeklund/riddler", "max_stars_repo_head_hexsha": "a4957907b33d86e8d8296614453629fb95dcb425", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "precipitation permutations/Precipitation Permutations.tex", "max_issues_repo_name": "samueldeklund/riddler", "max_issues_repo_head_hexsha": "a4957907b33d86e8d8296614453629fb95dcb425", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "precipitation permutations/Precipitation Permutations.tex", "max_forks_repo_name": "samueldeklund/riddler", "max_forks_repo_head_hexsha": "a4957907b33d86e8d8296614453629fb95dcb425", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.77, "max_line_length": 427, "alphanum_fraction": 0.6180815442, "num_tokens": 2104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.43964754776526466}}
{"text": "% !TEX root =  centrtutorial.tex\n\n\\section{Exact Algorithms}\n\\begin{frame}\n  \\frametitle{Outline}\n  \\begin{enumerate}\n    \\item Exact algorithms for static graphs\n      \\begin{enumerate}\n        \\item the standard algorithm for closeness\n        \\item the standard algorithm for betweenness\n        \\item a faster betweenness algorithm through shattering and compression\n        \\item a GPU-Based algorithm for betweenness\n      \\end{enumerate}\n    \\item Exact algorithms for dynamic graphs\n      \\begin{enumerate}\n        \\item a dynamic algorithm for closeness\n        \\item four dynamic algorithms for betweenness\n        \\item a parallel streaming algorithm for betweenness\n      \\end{enumerate}\n  \\end{enumerate}\n\\end{frame}\n\n\\subsection{Exact Algorithms for Static Graphs}\n\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Exact Algorithm for Closeness Centrality}\n  \\vfill\n  {\\Large(folklore)}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Exact Algorithm for Closeness}\n    \\vfill\n    Recall the definition:\n    \\[\n      \\closeness(x)=\\frac{1}{\\sum_{y\\neq x}d(x,y)}\n    \\]\n    \\vfill\n    \\pause\n    Fastest known algorithm for closeness: \\emph{All-Pairs Shortest Paths}\n    \\begin{itemize}\n      \\item Runtime: $O(nm+n^2\\log n)$\n    \\end{itemize}\n    \\vfill\n    \\pause\n    Too slow for \\emph{web-scale} graphs!\n    \\begin{itemize}\n      \\item Later we'll discuss an \\emph{approximation algorithm}\n    \\end{itemize}\n    \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge A Faster Algorithm for Betweenness Centrality}\n  \\vfill\n  {\\Large U.~Brandes}\n  \\vfill\n  {\\large Journal of Mathematical Sociology (2001)}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Why {\\red faster}?}\n  \\vfill\n  Let's take a step back. Recall the definition\n  \\[\n    \\sum_{\\substack{s\\neq x\\neq t \\in V\\\\s\\neq t}}\\frac{\\sigma_{st}(x)}{\\sigma_{st}}\n    \\vspace{-10pt}\n  \\]\n  \\begin{itemize}\n    \\item $\\sigma_{st}$: no.~of \\spath (SPs) from $s$ to $t$\n    \\item $\\sigma_{st}(x)$: no.~of \\spath from $s$ to $t$ that go through $x$\n  \\end{itemize}\n  \\pause\n  We could:\n  \\begin{enumerate}\n    \\item obtain all the $\\sigma_{st}$ and $\\sigma_{st}(x)$ for all $x$, $s$,\n      $t$ via APSP; and then\n    \\item perform the aggregation to obtain $\\betw(x)$ for all $x$.\n  \\end{enumerate}\n  \\pause\n  The first step takes $O(nm+n^2\\log n)$, but the second step takes\\ldots\\pause\n  $\\Theta(n^3)$ (a sum of $O(n^2)$ terms for each of the $n$ vertices).\n  \\pause\n  \\vfill\n  Brandes' algorithm interleaves the SP computation with the aggregation,\n  achieving runtime $O(nm+n^2\\log n)$\\\\\n  \\quad I.e., it is \\emph{faster} than the APSP approach\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Dependencies}\n  Define: \\emph{Dependency} of $s$ on $v$:\n  \\[\n    \\dep_s(v)=\\sum_{t\\neq s\\neq v}\\frac{\\sigma_{st}(v)}{\\sigma_{st}}\n  \\]\n  Hence:\n  \\[\n    \\betw(v)=\\sum_{s\\neq v}\\dep_s(v)\n  \\]\n  \\pause\n  Brandes proved that $\\delta_s(v)$ obeys a \\emph{recursive relation}:\n  \\[\n    \\dep_s(v)=\\sum_{w:v\\in\\pred_s(w)}\\frac{\\sigma_{sv}}{\\sigma_{sw}}\\left(1+\\dep_s(w)\\right)\n  \\]\n  We can leverage this relation for efficient computation of betweenness\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Recursive relation}\n  \\begin{theorem}[Simpler form]\n    If there is exactly one \\spath from $s$ to each $t$, then\n    \\[\n      \\dep_s(v)=\\sum_{w: v\\in\\pred_s(w)}\\left(1+\\dep_s(w)\\right)\n    \\]\n  \\end{theorem}\n  \\pause\n  \\emph{Proof sketch:}\n  \\begin{itemize}\n    \\item The \\spdag from $s$ is a tree;\n    \\item Fix $t$. $v$ is either on the single \\spath from $s$ to $t$ or not.\n    \\item $v$ lies on all and only the SPs to vertices $w$ for which $v$ is a\n      predecessor (one \\spath for each $w$) and the SPs that these lie on. Hence the\n      thesis.\n  \\end{itemize}\n  \\pause\n  The general version must take into account that not all SPs from $s$ to $w$ go\n  trough $v$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Brandes' Algorithm}\n  \\begin{enumerate}\n    \\item Initialize $\\dep_s(v)$ to $0$ for each $v,s$ and $\\betw(w)$ to $0$ for\n      each $w$.\n    \\item Iterate the following loop for each vertex $s$:\n      \\begin{enumerate}\n        \\item Run Dijkstra's algorithm from $s$, keeping track of $\\sigma_{sv}$ for\n          each encountered vertex $v$, and inserting the vertices in a max-heap $H$ by\n          distance from $s$;\n        \\item While $H$ is not empty:\n          \\begin{enumerate}\n            \\item Pop the max vertex $t$ in $H$;\n            \\item For each $w\\in\\pred_s(t)$, increment $\\dep_s(w)$ by\n              $\\frac{\\sigma_{sw}}{\\sigma_{st}}(1+\\dep_s(t))$;\n            \\item Increment $\\betw(t)$ by $\\dep_s(t)$;\n          \\end{enumerate}\n      \\end{enumerate}\n  \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Shattering and Compressing Networks for Betweenness Centrality}\n  \\vfill\n  {\\Large A.~E.~Sar\\i y\\\"uce, E.~Saule, K.~Kaya, \\\"U.~V.~\\c{C}ataly\\\"urek}\n  \\vfill\n  {\\large SDM '13: SIAM Conference on Data Mining}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Intuition}\n  \\emph{Observations:}\n  \\begin{itemize}\n    \\item There are vertices with predictable betweenness (e.g., 0, or equal to one\n      of their neighbors). We can remove them from the graph (\\emph{compression})\n    \\item Partitioning the (compressed) graph into small components allows for\n      faster SP computation (\\emph{shattering})\n  \\end{itemize}\n  \\pause\n  \\emph{Idea}:\n  We can iteratively compress \\& shatter until we can't reduce the graph any\n  more.\\\\\n  \\qquad Only at this point we run (a modified) Brandes's algorithm and then\n  aggregate the ``partial'' betweenness in different components.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Introductory definitions}\n  \\vfill\n  \\begin{itemize}\n    \\item Graph $G=(V,E)$\n    \\item \\emph{Induced graph} by $V'\\subseteq V$: $G_{V'}=(V', E'=V'\\times V'\\cap E)$\n    \\pause\n    \\item Neighborhood of a vertex $v$: $\\neighbors(v)=\\{u~:~(v,u)\\in E\\}$\n    \\pause\n  \\item \\emph{Side vertex}: a vertex $v$ such that $G_{\\neighbors(v)}$ is a clique\n    \\pause\n  \\item \\emph{Identical vertices}: two vertices $u$ and $v$ such that either\n      $\\neighbors(u)=\\neighbors(v)$ or\n      $\\neighbors(u)\\cup\\{u\\}=\\neighbors(v)\\cup\\{v\\}$\n  \\end{itemize}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Compression}\n  \\vfill\n  Empirical / intuitive observations\n  \\begin{itemize}\n    \\item if $v$ has degree $1$, then $\\betw(v)=0$\n    \\item if $v$ is a side vertex, then $\\betw(v)=0$\n    \\item if $u$ and $v$ are identical, then $\\betw(v)=\\betw(w)$\n  \\end{itemize}\n  \\pause\n  \\vfill\n  \\emph{Compression}:\n  \\begin{itemize}\n    \\item remove degree-1 vertices and side vertices; and\n    \\item merge identical vertices\n  \\end{itemize}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Shattering}\n  \\vfill\n  \\begin{itemize}\n    \\item \\emph{Articulation vertex}: vertex $v$ whose deletion makes the graph disconnected\n    \\item \\emph{Bridge edge:} an edge $e=(u,v)$ such that $G'=(V,E\\setminus\\{e\\})$ has\n      more components than $G$ ($u$ and $v$ are articulation vertexes)\n  \\end{itemize}\n  \\pause\n  \\vfill\n  \\emph{Shattering}:\n  \\begin{itemize}\n    \\item remove bridge edges\n    \\item split articulation vertices in two copies, one per resulting component\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example of shattering and compression}\n  \\begin{figure}\n    \\includegraphics{imgs/shatteringbadios.pdf}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Issues}\n  Issues to take care of when iteratively compressing \\& shattering:\n  \\begin{block}{Example of issue}\n    A vertex may have degree 1 only after we removed another vertex: we can't\n    just remove and forget it, as its original betweenness was not 0.\n  \\end{block}\n  \\pause\n  \\begin{block}{Example of issue}\n    When splitting an articulation vertex into component copies, we need to know,\n    for each copy, how many vertices in other components are reachable through\n    that vertex.\n  \\end{block}\n  ...and more\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Solution}\n  (Sketch)\n  \\begin{itemize}\n    \\item When we remove a vertex $u$, one of its neighbors (or an identical vertex)\n      $v$ is elected as the representative for $u$ (and for all vertices that $u$\n      was a representative of)\n    \\item We adjust the (current) values of $\\betw(v)$ and $\\betw(u)$ to\n      appropriately take into account the removal of $u$\\\\\n      \\qquad the details are too hairy for a talk\\ldots\n    \\item When splitting articulation vertices or removing bridges, similar\n      adjustments take place\n    \\item Brandes' algorithm is slightly modified to take the number of vertices\n      that a vertex represents into consideration when computing the\n      dependencies and the betweenness values\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Speedup}\n  ``org.'' is Brandes' algorithm, ``best'' is compress \\& shatter\n  \\begin{figure}\n    \\includegraphics{imgs/runtimebadios.pdf}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Composition of runtime}\n  \\begin{itemize}\n    \\item Preproc is the time needed to compress \\& shatter, Phase 1 is SSSP,\n      Phase 2 is aggregation\n    \\item Different column for different variants of the algorithm (e.g., only\n      compression of 1-degree vertices, only shattering of edges)\n    \\item the lower the better\n  \\end{itemize}\n  \\begin{figure}\n    \\includegraphics[width=0.9\\textwidth]{imgs/runtimesplitbadios.pdf}\n  \\end{figure}\n\\end{frame}\n\n%\\begin{frame}\n%  \\frametitle{A Divide-and-Conquer Algorithm for Betweenness Centrality}\n%  \\centering\n%  \\vfill\n%  {\\huge D.~Erd\\H{o}s, V.~Ishakian, A.~Bestravros, E.~Terzi}\n%  \\vfill\n%  {\\large SIAM Data Mining Conference (2015)}\n%\\end{frame}\n\n%% Sariyüce et al.\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Betweenness Centrality on GPUs and Heterogeneous Architectures}\n  \\vfill\n  {\\Large A.~E.~Sar\\i y\\\"uce, K.~Kaya, E.~Saule, \\\"U.~V.~\\c{C}ataly\\\"urek}\n  \\vfill\n  {\\large GPGPU '13: Workshop on General Purpose Processing Using GPUs}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Parallelism}\n\n  \\begin{itemize}\n    \\item Fine grained: single concurrent BFS\n    \\item Only one copy of auxiliary data structures\n    \\item Synchronization needed\n    \\item Better for GPUs, which have small memory\n  \\end{itemize}\n  \\begin{itemize}\n    \\item Coarse grained: many independent BFSs\n    \\item Sources are independent, embarrassingly parallel\n    \\item More memory needed\n    \\item Better for CPUs, which have large memory\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{GPU}\n\n  \\begin{quote}\n    A GPU is especially well-suited to address problems that can be expressed as \\textbf{data-parallel computations} - the same program is executed on many data elements in parallel - with \\textbf{high arithmetic intensity} - the ratio of arithmetic operations to memory operations.\n\n    Because the same program is executed for each data element, there is a lower requirement for sophisticated flow control, and because it is executed on many data elements and has high arithmetic intensity, the memory access latency can be hidden with calculations instead of big data caches.\\footnote{\\url{docs.nvidia.com/cuda/cuda-c-programming-guide/index.html}}\n  \\end{quote}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Execution model}\n  \\begin{columns}[onlytextwidth]\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item One thread per data element\n        \\item Thread scheduled in blocks with barriers (wait for others at the end)\n        \\item Program runs on the whole data (kernel)\n      \\end{itemize}\n      \\begin{itemize}\n        \\item Minimize synchronization\n        \\item Balance load\n        \\item Coalesce memory access\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/cuda}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item GPUs have huge number of cores\n    \\item Use them to parallelize BFS\n    \\item One core per vertex, or one core per edge\n    \\item Vertex-based parallelism creates load imbalance for graphs with skewed degree distribution\n    \\item Edge-based parallelism requires high memory usage\n  \\end{itemize}\n  \\begin{itemize}\n    \\item Use vertex-based parallelism\n    \\item Virtualize high-degree vertices to address load imbalance\n    \\item Reduce memory usage by removing predecessors lists\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Difference}\n\n  \\begin{columns}[onlytextwidth]\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/gpu-vertex-bfs}\n        \\caption{Vertex-based BFS}\n      \\end{figure}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/gpu-edge-bfs}\n        \\caption{Edge-based BFS}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Vertex-based}\n\n  \\begin{columns}[onlytextwidth]\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item For each level, for each vertex in parallel\n        \\item If vertex is on level\n        \\item For each neighbor, \\\\ adjust \\pred and \\paths\n        \\item Atomic update on \\paths needed (multiple paths can be discovered concurrently)\n        \\item While backtracking, if $u \\in \\pred(v)$ accumulate $\\dep(u) = \\dep(u) + \\dep(v)$\n        \\item Possible load imbalance if degree skewed\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/gpu-algo-vertex}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Edge-based}\n\n  \\begin{columns}[onlytextwidth]\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item For each level, for each edge in parallel\n        \\item If edge endpoint is on level\n        \\item Same as above...\n        \\item While backtracking, if $u \\in \\pred(v)$ accumulate $\\dep(u) = \\dep(u) + \\dep(v)$ \\emph{atomically}\n        \\item Multiple edges can try to update \\dep concurrently\n        \\item More memory (edge-based layout) and more atomic operations\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/gpu-algo-edge}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Vertex virtualization}\n\n  \\begin{columns}[onlytextwidth]\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item AKA, edge batching, \\\\ hybrid between vertex- and edge-based\n        \\item Split high degree vertices into virtual ones with maximum degree $mdeg$\n        \\item Equivalently, pack up to $mdeg$ edges belonging to the same vertex together\n        \\item Very small $mdeg = 4$\n        \\item Need additional auxiliary maps\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/gpu-algo-hybrid}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Benefits}\n\n  \\begin{itemize}\n    \\item Compared to vertex-based:\n      \\begin{itemize}\n        \\item Reduce load imbalance\n      \\end{itemize}\n    \\item Compared to edge-based:\n      \\begin{itemize}\n        \\item Reduce number of atomic operations\n        \\item Reduce memory footprint\n      \\end{itemize}\n    \\item Predecessors stored implicitly in the \\spdag level (reduced memory usage)\n    \\item Memory layout can be further optimized to coalesce latency via \\emph{striding}:\n      \\begin{itemize}\n        \\item Distribute edges to virtual vertices in round-robin\n        \\item When accessed in parallel, they create faster sequential memory access pattern\n      \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/gpu-results1}\n    \\caption{Speedup over Brandes' on CPU on real graphs with 32-core GPU ($s= 1k, \\ldots, 100k$)}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Results computed only on a sample of sources and extrapolated linearly\n  \\end{itemize}\n\\end{frame}\n\n\n%\\begin{frame}\n%  \\frametitle{Results}\n%\n%  \\begin{figure}[t]\n%    \\centering\n%    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/gpu-results2}\n%    \\caption{Speedup over Brandes' on CPU on real graphs with 32-core GPU}\n%  \\end{figure}\n%\n%\\end{frame}\n\n\n\n\\subsection{Exact Algorithms for Dynamic Graphs}\n\n%% Green et al.\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge A Fast Algorithm for Streaming Betweenness Centrality}\n  \\vfill\n  {\\Large O. Green, R. McColl, D. A. Bader}\n  \\vfill\n  {\\large SocialCom '12: International Conference on Social Computing}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item Make Brandes' algorithm incremental\n    \\item Keep additional data structures to avoid recomputing partial results\n      \\begin{itemize}\n        \\item Rooted \\spdag for each source $s \\in V$\n        \\item Depth in the tree for $t$ = distance of $t$ from $s$\n      \\end{itemize}\n    \\item Re-run parts of modified Brandes' algorithm on edge update\n    \\item Support only edge addition (on unweighted graphs)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Data structures}\n\n  \\begin{itemize}\n    \\item One $\\spdag_s$ for each source $s \\in V$, which contains for each other vertex $t \\in V$:\n      \\begin{itemize}\n        \\item Distance $\\dist_{st}$, paths $\\paths_{st}$, dependencies $\\dep_{s}(t)$, predecessors $\\pred_{s}(t)$\n        \\item Additional per-level queues for exploration\n      \\end{itemize}\n  \\end{itemize}\n  \\begin{itemize}\n    \\item On addition of edge $(u,v)$, let $dd = |d_{su} - d_{sv}|$:\n      \\begin{itemize}\n        \\item $dd = 0$ same~level\n        \\item $dd = 1$ adjacent~level\n        \\item $dd > 1$ non-adjacent~level\n      \\end{itemize}\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Same level addition}\n  \\begin{columns}[onlytextwidth]\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item $dd = 0$\n        \\item Edge creates no new shortest paths\n        \\item No change to betweenness \\\\ due to this source\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/green-0lvl-compressed}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Adjacent level addition}\n  \\begin{columns}[onlytextwidth]\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item $dd = 1$\n        \\item Let $u_{high} = u ,\\, u_{low} = v$\n        \\item Edge creates new shortest paths\n        \\item \\spdag unchanged\n        \\item Changes in \\paths confined to sub-dag rooted in $u_{low}$\n        \\item Changes in \\dep also spread above to decrease old dependency and account for new dependency\n        \\item Example: $w$ and predecessors have now only $\\sfrac{1}{2}$ of dependency on sub-dag rooted in $u_{low}$\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/green-1lvl-compressed}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Algorithm}\n  \\begin{columns}[onlytextwidth]\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item During exploration:\n          \\begin{itemize}\n            \\item Fix \\paths\n            \\item Mark visited vertices\n            \\item Enqueue for further processing\n          \\end{itemize}\n      \\end{itemize}\n    \\end{column}\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item During backtracking:%\n          \\begin{itemize}\n            \\item Fix \\dep and \\betw\n            \\item Recurse up the whole \\spdag\n          \\end{itemize}\n      \\end{itemize}\n    \\end{column}\n  \\end{columns}\n      \\begin{figure}[t]\n        \\centering\n        %        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/green-algo}\n        \\includegraphics[width=0.45\\textwidth, height=0.6\\textheight, keepaspectratio, valign=t]{imgs/green-algo1}\n        \\includegraphics[width=0.6\\textwidth, height=0.6\\textheight, keepaspectratio, valign=t]{imgs/green-algo2}\n      \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Non-adjacent level addition}\n\n  \\begin{columns}[onlytextwidth]\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item $dd > 1$\n        \\item Edge creates new shortest paths\n        \\item Changes to \\spdag (new distances)\n        \\item Algorithm only sketched \\\\ (most details missing)\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics<1>[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/green-2lvl-before-compressed}\n        \\includegraphics<2>[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/green-2lvl-after-compressed}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Complexity}\n\n  \\begin{itemize}\n    \\item Time: $O(n^2 + nm)$ $\\leftarrow$ same as Brandes'\n    \\item In practice, algorithm is much faster\n  \\end{itemize}\n  \\begin{itemize}\n    \\item Space: $O(n^2 + nm)$ $\\leftarrow$ higher than Brandes'\n    \\item For each source, a \\spdag of complexity $n + m$\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/green-results1}\n    \\caption{Speedup over Brandes' on synthetic graphs ($n = 4096$)}\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Conclusions}\n\n  \\begin{itemize}\n    \\item Up to 2 orders of magnitude speedup\n    \\item Super-quadratic space bottleneck\n  \\end{itemize}\n\n\\end{frame}\n\n\n%% QUBE\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge QUBE: a Quick algorithm for Updating BEtweenness centrality}\n  \\vfill\n  {\\Large M. Lee, J. Lee, J. Park, R. Choi, C. Chung}\n  \\vfill\n  {\\large WWW '12: International World Wide Web Conference}\n  \\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item No need to update all vertices when a new edge is added\n    \\item Prune vertices whose \\betw does not change\n    \\item Large reduction in all-pairs shortest paths to be re-computed\n    \\item Support both edge additions and removals\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Minimum Cycle Basis}\n\n  \\begin{itemize}\n    \\item $G=(V,E)$ undirected graph\n    \\item \\emph{Cycle} $C \\subseteq E$ s.t. $\\forall v \\in V$, $v$ incident to even number of edges in $C$\n    \\item Represented as edge incidence vector $\\nu \\in \\{ 0,1 \\}^{|E|}$, where $\\nu(e) = 1 \\iff e \\in C$\n    \\item \\emph{Cycle Basis} = set of linearly independent cycles\n    \\item \\emph{Minimum Cycle Basis} = on weighted graph with non-negative weights $w_e$, cycle basis of minimum total weight $w(C) = \\sum_{i} w(C_i)$ where $w(C_i) = \\sum_{e \\in C_i} w_e$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Minimum Cycle Basis Example}\n  \\begin{itemize}\n    \\item Three cycle basis sets: $\\{C_1, C_2\\} , \\{C_1, C_3\\} , \\{C_2, C_3\\}$\n    \\item If all edges have same weight $w_e = 1$, $MCB = \\{C_1, C_2\\}$\n  \\end{itemize}\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=2]{imgs/qube-mcb}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Minimum Union Cycle}\n\n  \\begin{itemize}\n    \\item Given a MCB $C$ and minimum cycles $C_i \\in C$\n    \\item Let $V_{C_i}$ be the set of vertices induced by $C_i$\n    \\item Recursively union two $V_{C_i}$ if they share at least one vertex\n    \\item The final set of vertices is a \\emph{Minimum Union Cycle} $MUC$\n  \\end{itemize}\n\n  \\begin{itemize}\n    \\item $MUC$s are disjoint sets of vertices\n    \\item $MUC(v)$ = the $MUC$ which contains vertex $v$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Connection Vertex}\n\n  \\begin{itemize}\n    \\item \\emph{Articulation Vertex} = vertex $v$ whose deletion makes the graph disconnected\n    \\item Biconnected graph = graph with no articulation vertex\n    \\item Vertex $v$ is an articulation vertex $\\iff$ v belongs to two biconnected components\n  \\end{itemize}\n\n  \\begin{itemize}\n    \\item \\emph{Connection Vertex} = vertex $v$ that\n      \\begin{itemize}\n        \\item is an articulation vertex\n        \\item has an edge to vertex $w \\not\\in MUC(v)$\n      \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Connection Vertex Example}\n\n  \\begin{columns}[onlytextwidth]\n    \\begin{column}{0.5\\textwidth}\n      \\begin{itemize}\n        \\item If $(v_3, v_4)$ is added, $MUC(v_3) = \\{ v_1, v_2, v_3, v_4 \\}$\n        \\item $v_1, v_2, v_3$ are connection vertices of $MUC(v_3)$\n        \\item Let $G_i$ be the disconnected subgraph generated by removing $v_i$\n      \\end{itemize}\n    \\end{column}\n\n    \\begin{column}{0.5\\textwidth}\n      \\begin{figure}[t]\n        \\centering\n        \\includegraphics[width=\\textwidth, height=0.8\\textheight, keepaspectratio]{imgs/qube-biconnected}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Finding MUCs}\n\n  \\begin{itemize}\n    \\item Finding an $MCB$ is well studied\n    \\item Kavitha, Mehlhorn, Michail, Paluch. ``A faster algorithm for minimum cycle basis of graphs''. ICALP 2004\n    \\item Finding $MUC$ from $MCB$ relatively straightforward (just union sets of vertices)\n    \\item Also find connection vertices for each $MUC$\n    \\item All done as a preprocessing step\n    \\item Need to be updated at runtime\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Updating MUCs -- Addition}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/qube-addition}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Adding $a$ does not affect the $MUC$ (endpoints in the same $MUC$)\n    \\item Adding $b$ creates a new $MUC$ (endpoints do not belong to a $MUC$)\n    \\item Adding $c$ merges two $MUC$s (merge $MUC$s of vertices on the \\spath between endpoints)\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Updating MUCs -- Removal}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/qube-removal}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Removing $a$ destroys the $MUC$ (cycle is removed $\\rightarrow$ no biconnected component)\n    \\item Removing $b$ does not affect the $MUC$ ($MUC$ is still biconnected)\n    \\item Removing $c$ splits the $MUC$ in two (single vertex appears in all \\spath between endpoints)\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Betweenness Centrality Dependency}\n\n  \\begin{itemize}\n    \\item Only vertexes inside the $MUC$s of the updated endpoints need to be updated\n    \\item However, recomputing all centralities for the $MUC$ still requires new shortest paths to the rest of the graph\n      \\begin{itemize}\n        \\item Shortest paths to vertices outside the $MUC$\n        \\item Shortest paths that pass through the $MUC$\n      \\end{itemize}\n  \\end{itemize}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/qube-btwmuc}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Betweenness Centrality outside the MUC}\n\n  \\begin{itemize}\n    \\item Let $s \\in V_{G_j}$, $t \\in MUC$,\n    \\item Let $j \\in MUC$ be a connection vertex to subgraph $G_j$\n    \\item Each vertex in $\\spath_{jt}$ is also in $\\spath_{st}$\n    \\item Therefore, betweenness centrality due to vertices outside the $MUC$:\n  \\end{itemize}\n\n  \\begin{align*}\n    %\\large\n    \\betw_{o}(v) = \\begin{cases}\n      \\frac{|V_{G_j}|}{\\paths_{st}}\t\t& \\text{ if } v \\in\\{ \\spath_{jt} \\setminus t \\} \\\\\n      0 \t\t\t\t\t\t& \\text{ otherwise }\n    \\end{cases}\n  \\end{align*}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Betweenness Centrality trough the MUC}\n\n  \\begin{itemize}\n    \\item Let $s \\in V_{G_j}$, $t \\in V_{G_k}$,\n    \\item Let $j \\in MUC$ be a connection vertex to subgraph $G_j$\n    \\item Let $k \\in MUC$ be a connection vertex to subgraph $G_k$\n    \\item Each vertex in $\\spath_{jk}$ is also in $\\spath_{st}$\n    \\item Therefore, betweenness centrality due to paths through the $MUC$:\n  \\end{itemize}\n\n  \\begin{align*}\n    \\betw_{x}(v) = \\begin{cases}\n      \\frac{ |V_{G_j}| |V_{G_k}| }{ \\paths_{st} }\t\t& \\text{ if } v \\in \\spath_{jk} \\\\\n      0 \t\t\t\t\t\t& \\text{ otherwise }\n    \\end{cases}\n  \\end{align*}\n\n  More caveats apply for subgraphs that are disconnected, as every path that connects vertices in different connected component passes through $v$\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Updating Betweenness Centrality}\n\n  {\\Large\n    \\begin{align*}\n      \\betw(v) = \\betw_{MUC}(v) + \\sum_{G_j \\subset G} \\betw_{o}(v) + \\sum_{G_j, G_k \\subset G} \\betw_{x}(v)\n    \\end{align*}\n  }\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{QUBE algorithm}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/qube-algorithm1}\n  \\end{figure}\n\n  %  \\begin{columns}[onlytextwidth]\n  %    \\begin{column}{0.5\\textwidth}\n  %      \\begin{figure}[t]\n  %        \\centering\n  %        \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/qube-algorithm1}\n  %      \\end{figure}\n  %    \\end{column}\n\n  %    \\begin{column}{0.5\\textwidth}\n  %      \\begin{figure}[t]\n  %        \\centering\n  %        \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/qube-algorithm2}\n  %      \\end{figure}\n  %    \\end{column}\n  %  \\end{columns}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{QUBE algorithm}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=\\textheight, keepaspectratio]{imgs/qube-algorithm2}\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{QUBE + Brandes}\n\n  \\begin{itemize}\n    \\item QUBE is a pruning rule that reduces the search space for betweenness recomputation\n    \\item Can be paired with any existing betweenness algorithm to compute $\\betw_{MUC}$\n    \\item In the experiments, Brandes' is used\n    \\item Quantities computed by Brandes' (e.g., \\paths) reused by QUBE for $\\betw_o$ and $\\betw_x$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/qube-results1}\n    \\caption{Update time as a function of the percentage of vertices of the graph in the updated $MUC$ for synthetic Erd\\\"{o}s-R\\'{e}nyi graphs ($n = 5000$)}\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Conclusions}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/qube-results2}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Improvement depends highly on structure of the graph (bi-connectedness)\n    \\item From 2 orders of magnitude (best) to 2 times (worst) faster than Brandes'\n  \\end{itemize}\n\n\\end{frame}\n\n\n%% Kas et al.\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Incremental Algorithm for Updating Betweenness Centrality in Dynamically Growing Networks}\n  \\vfill\n  {\\Large M. Kas, M. Wachs, K. M. Carley, L. R. Carley}\n  \\vfill\n  {\\large ASONAM '13: International Conference on Advances \\\\in Social Networks analysis and Mining}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item Extend an existing dynamic all-pairs shortest path algorithm to betweenness\n    \\item G. Ramalingam and T. Reps, ``\\emph{On the Computational Complexity of Incremental Algorithms},'' CS, Univ. of Wisconsin at Madison, Tech. Report 1991\n    \\item Relevant quantities: number of shortest paths \\paths, distances \\dist, predecessors \\pred\n    \\item Keep a copy of the old quantities while updating\n    \\item Support only edge addition (on weighted graphs)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Edge update}\n\n  \\begin{itemize}\n    \\item Compute new shortest paths from updated endpoints $(u,v)$\n    \\item If a new shortest path of the same length is found, updated number of paths as\n  \\end{itemize}\n  {\\Large\n    \\begin{align*}\n      \\paths_{st} = \\paths_{st} + \\paths_{su} \\times \\paths_{vt}\n    \\end{align*}\n  }\n  \\begin{itemize}\n    \\item If a new \\emph{shorter} shortest path to any vertex is found, update \\dist, clear \\paths\n    \\item Betweenness decreased if new shortest path found\n    \\item Edge betweenness updates backtrack via DFS over $\\pred_s(t)$\n  \\end{itemize}\n  {\\Large\n    \\begin{align*}\n      \\betw(w) = \\betw(w) - \\paths_{sw} \\times \\paths_{wt} / \\paths_{st}\n    \\end{align*}\n  }\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Edge update}\n\n  \\begin{itemize}\n    \\item Complex bookkeeping: need to consider all affected vertices which have new alternative shortest paths of equal length (not covered in the original algorithm)\n    \\item Amend \\pred during update propagation $\\rightarrow$ concurrent changes to the \\spdag\n    \\item Need to track now-unreachable vertices separately\n  \\end{itemize}\n\n  \\begin{itemize}\n    \\item After having fixed \\dist, \\paths, \\betw, increase \\betw due to new paths\n    \\item Update needed $\\forall s,t \\in V$ affected by changes (tracked from previous phase)\n    \\item Betweenness increase analogous to above decrease\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/kas-results1}\n    \\caption{Speedup over Brandes' on real-world graphs}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Speedup depends on topological characteristics (e.g., diameter, clust. coeff.)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Comparison with QUBE}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/kas-results2}\n    \\caption{Speedup over Brandes' in comparison with QUBE}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Datasets from the QUBE paper\n    \\item About 1 order of magnitude faster than QUBE\n  \\end{itemize}\n\n\\end{frame}\n\n\n%% Nasre et al.\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Betweenness Centrality -- Incremental and Faster}\n  \\vfill\n  {\\Large M. Nasre, M. Pontecorvi, V. Ramachandran}\n  \\vfill\n  {\\large MFCS '14: Mathematical Foundations of Computer Science}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item Keep \\spdag for each vertex\n    \\item Re-use information from \\spdag of updated edge endpoints\n    \\item Adding new edges will \\emph{not} make old edges part of a \\spath\n    \\item Support only edge addition (on weighted graphs)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Main Result}\n\n  %  \\begin{figure}[H]\n  %    \\centering\n  %    \\includegraphics[width=0.5\\textwidth]{imgs/npr14-main-result}\n  %  \\end{figure}\n\n  \\begin{itemize}\n    \\item Let $\\displaystyle E^* = \\bigcup_{e \\in \\allspath} e \\subseteq E$ be the set of edges that are part of any shortest path\n    \\item Let $\\displaystyle m^* = |E^*|$ and $\\displaystyle \\nu^* = \\max_{v \\in V} |\\spdag_v|$ the maximum number of edges in shortest paths through any single vertex $v$\n    \\item $n < \\nu^* < m^* < m$\n    \\item After incremental update, betweenness can be recomputed in\n      \\begin{itemize}\n        \\item $O(\\nu^* n)$ time using $O(\\nu^* n)$ space\n        \\item $O(m^* n)$ time using $O(n^2)$ space\n      \\end{itemize}\n    \\item Bounded by $O(mn + n^2)$\n    \\item Logarithmic factor better than Brandes' (on weighted graphs)\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Lemma 1}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, trim={0 8cm 0 0}, clip]{imgs/npr14-lemmas}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Edge $(u,v) \\not\\in \\spath_{xu} \\, \\wedge \\, (u,v)\\not\\in \\spath_{vx}$ as edge weights are positive\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Lemma 2}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, trim={0 0 0 3.5cm}, clip]{imgs/npr14-lemmas}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Updates to \\paths and \\dist in constant time\n    \\item Need to update \\pred to complete \\spdag update\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{\\spdag Update}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{imgs/npr14-algo3}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item UN-changed $\\rightarrow dd=0$\n    \\item NUM-changed $\\rightarrow dd=1$\n    \\item WT-changed $\\rightarrow dd>1$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Edge Update}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{imgs/npr14-algo4}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Space-Efficient Variant $O(n^2)$}\n\n  \\begin{itemize}\n    \\item Do not store the \\spdag\n    \\item Store only $E^*$\n    \\item Updated \\spdag can be build in $O(m^*)$ time\n      \\begin{itemize}\n        \\item Time $O(m^* \\, n)$\n        \\item Compute ${E'}^*$ from $E^*$, then $\\spdag'_{s}$ from ${E'}^*$\n      \\end{itemize}\n    \\item Space $O(m^* + n^2)$ to store $E^*$ and $n^2$ distances $\\dist(s,t)$ and shortest paths $\\paths_{st}$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Comparison}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{imgs/npr14-comparison}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Conclusions}\n\n  \\begin{itemize}\n    \\item Provably faster than Brandes' on weighted graphs\n    \\item However $m^*$ can be large in practice\n    \\item No experiments\n    \\item Hard to parallelize (need to access pairs of \\spdag at a time)\n    \\item Still has main bottleneck of most algorithms: $O(n^2)$ memory\n  \\end{itemize}\n\\end{frame}\n\n\n%% Sariyuce et al. (incremental closeness)\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Incremental Algorithms for Closeness Centrality}\n  \\vfill\n  {\\Large A. E. Sar\\i y\\\"uce, K. Kaya, E. Saule, U.~V.~\\c{C}ataly\\\"urek }\n  \\vfill\n  {\\large IEEE BigData '13: International Conference on Big Data}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item Algorithm with pruning based on level difference (similar to Green et al.)\n    \\item Additional pruning by bi-connected decomposition (similar to QUBE)\n    \\item Applied to closeness centrality (still solves APSP)\n    \\item Reminder: closeness centrality\n    \\item $\\displaystyle \\closeness(v)=\\frac{1}{\\displaystyle  \\sum_{u \\in V} d(u,v)}$\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Preliminaries}\n\n  \\begin{itemize}\n    \\item Best static algorithm $O(nm)$ time\n  \\end{itemize}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/sksc-algo1}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Cases}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{imgs/sksc-cases}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Usual cases: $dd=0$, $dd=1$, $dd>1$\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Pruning - level difference}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.7\\textheight, keepaspectratio]{imgs/sksc-algo2}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Pruning - biconnected components}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/sksc-biconnected}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item If graph has articulation points\n    \\item Change in $A$ can change closeness of any vertex in $B$\n    \\item It is enough to compute change for $u$ (constant factor is added for the rest of $B$)\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Maintaining biconnected decomposition}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/sksc-bidecomp}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Assume edge $(b,d)$ added\n    \\item Similar to QUBE\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{\\sssp hybridization}\n\n  \\begin{itemize}\n    \\item BFS can be performed in two ways\n    \\item \\emph{Top-down:} process vertices at distance $d$ to find vertices at distance $d+1$\n    \\item \\emph{Bottom-up:} after vertices at distance $d$ are found, process all unprocessed vertices to see if they are neighbors of the frontier\n    \\item Top-down is better for initial rounds, bottom-up better for final rounds\n    \\item Hybridization: use best option at each round\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Fraction of cases}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/sksc-results1}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Probability distribution for level difference $dd$\n    \\item Most edges are easy cases\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Speedup}\n\n  \\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/sksc-results2}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Speedup of 2 orders of magnitude\n    \\item Mostly due to level pruning\n    \\item Biconnected decomposition and hybridization also give good speedups\n  \\end{itemize}\n\\end{frame}\n\n\n%% Kourtellis et al.\n\\begin{frame}\n  \\centering\n  \\vfill\n  {\\huge Scalable Online Betweenness Centrality in Evolving Graphs}\n  \\vfill\n  {\\Large N. Kourtellis, G. De-Francisci-Morales, F. Bonchi}\n  \\vfill\n  {\\large TKDE: IEEE Transactions on Knowledge and Data Engineering (2015)}\n  \\frametitle{Scalable Online Betweenness Centrality in Evolving Graphs}\n  \\vfill\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Intuition}\n\n  \\begin{itemize}\n    \\item Incremental, exact, space-efficient, out-of-core, parallel version of Brandes'\n    \\item Handles edge addition and removal\n    \\item Vertex and edge betweenness\n    \\item Scalable to graphs with millions of vertices\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Algorithm}\n\n  \\begin{itemize}\n    \\item Run a modified Brandes' on the initial graph\n    \\item Keep track of \\dist, \\paths, \\dep in a \\spdag (no \\pred)\n    \\item On edge update, adjust the \\spdag and update \\betw\n  \\end{itemize}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/kdb-algo}\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Data structure}\n\n  \\begin{itemize}\n    \\item $\\spdag_s$ for each source $s \\in V$\n    \\item \\spdag contains \\dist, \\paths, \\dep for each other vertex $t \\in V$\n    \\item No predecessors \\pred, re-scan neighbors and use \\dist to find them\n      \\begin{itemize}\n        \\item Save memory - space complexity $O(n^2)$\n        \\item Fixed size data structure - efficient out-of-core management\n        \\item Same time complexity $O(nm)$ - in practice, makes the algorithm faster\n      \\end{itemize}\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Pivot}\n\n  \\begin{itemize}\n    \\item When adding or removing an edge, consider $dd = |d_{su} - d_{sv}|$\n    \\item Three cases: $dd=0$, $dd=1$, $dd>1$ (analogous to Green et al.)\n    \\item Last case $dd>1$ hardest - structural changes in \\spdag\n    \\item Find \\emph{pivots} to discover structural changes\n  \\end{itemize}\n\n  \\begin{definition}[Pivot]\n    Let $s$ be the current source, let $\\dist$ and $\\dist'$ be the distance before and after an update, respectively, we define \\emph{pivot} a vertex $p \\mid \\dist(s,p) = \\dist'(s,p) \\wedge \\exists \\, w \\in \\neighbors(p)$$: \\dist(s,w)$$\\neq$$\\dist'(s,w)$.\n  \\end{definition}\n\n  \\begin{itemize}\n    \\item Pivots' distance unchanged $\\rightarrow$ use as starting points to correct distances\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Finding pivots}\n\n  \\begin{itemize}\n    \\item Addition - pivots in sub-dag rooted in $u_L = v$\n    \\item vertices moved closer must be reachable from $u_L$\n    \\item Can be found during exploration while fixing \\paths\n  \\end{itemize}\n  \\begin{itemize}\n    \\item Removal - pivots may be anywhere\n    \\item Need one exploration to find them\n    \\item Need separate exploration from found pivots to correct distances\n  \\end{itemize}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/kdb-bfs}\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Structural changes}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.5\\textheight, keepaspectratio]{imgs/kdb-cases}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Consider $x \\in \\neighbors(y)$, $x$ can either be a sibling or a predecessor of $y$\n    \\item Each case requires slightly different combination of corrections for \\dist, \\paths, \\dep\n    \\item $y$ is pivot in 1d, 2e, 2f\n    \\item Removal for case 1d can be optimized (pivot $y$ is sibling of $x$)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Scalability}\n\n  \\begin{itemize}\n    \\item Out-of-core - stream \\spdag from disk\n      \\begin{itemize}\n        \\item In-place update on disk to minimize writes\n      \\end{itemize}\n    \\item Columnar storage for \\dist, \\paths, \\dep\n      \\begin{itemize}\n        \\item Read only \\dist, skip rest if $dd=0$\n      \\end{itemize}\n    \\item Parallelization - coarse grained over $s$\n      \\begin{itemize}\n        \\item Implementation in MapReduce\n        \\item Amenable to Apache Storm/Flink/Spark\n      \\end{itemize}\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.6\\textheight, keepaspectratio]{imgs/kdb-results1}\n    \\caption{Speedup over Brandes' on synthetic and real graphs ($n = 10k$)}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item In-memory (M-) version faster than out-of-core (D-)\n    \\item Without predecessor (-O) always faster than with predecessors (-P)\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Results}\n\n  \\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=\\textwidth, height=0.3\\textheight, keepaspectratio]{imgs/kdb-results21}\n    \\\\ \\qquad \\quad\n    \\includegraphics[width=\\textwidth, height=0.3\\textheight, keepaspectratio]{imgs/kdb-results22}\n    \\caption{Speedup over Brandes' for out-of-core version on synthetic and real graphs ($n = 1M$)}\n  \\end{figure}\n\n  \\begin{itemize}\n    \\item Out-of-core version scales up to 1M vertices\n    \\item Speedup up to 2 orders of magnitude\n  \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Conclusions}\n\n  \\begin{itemize}\n    \\item Fully dynamic (addition and removal)\n    \\item Algorithm can scale to graphs with realistic size\n    \\item Ideal horizontal scalability\n    \\item $O(n^2)$ space bottleneck\n  \\end{itemize}\n\\end{frame}\n", "meta": {"hexsha": "4a2e580316a028aa9612a24803d7b2f89b81fa0d", "size": 47434, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WWW16/slides/exact.tex", "max_stars_repo_name": "rionda/centrtutorial", "max_stars_repo_head_hexsha": "cfb9b21ce83e03f66a9249d126b166f2b906f099", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WWW16/slides/exact.tex", "max_issues_repo_name": "rionda/centrtutorial", "max_issues_repo_head_hexsha": "cfb9b21ce83e03f66a9249d126b166f2b906f099", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "WWW16/slides/exact.tex", "max_forks_repo_name": "rionda/centrtutorial", "max_forks_repo_head_hexsha": "cfb9b21ce83e03f66a9249d126b166f2b906f099", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-08-25T05:46:16.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-25T05:46:16.000Z", "avg_line_length": 29.1184775936, "max_line_length": 367, "alphanum_fraction": 0.6744950879, "num_tokens": 14709, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4396475442010581}}
{"text": "\\ifpdf\n\\graphicspath{{Chapter5/Figs/}}\n\\else\n\\graphicspath{{Chapter5/Figs/}}\n\\fi\n\n\\chapter{Contribution 1: A more Efficient Serial Number Signature of Knowledge}\n\\label{ch:Contribution 1: A more Efficient Serial Number Signature of Knowledge}\n\\section{Problem with Original SNSoK}\n\\label{sec:5-Problem with Original SNSoK}\nThe most problematic NIZK proof out of the three proofs in Zerocoin is the SNSoK as it has the biggest size and takes the longest time to verify. The inefficiency in the SNSoK is mainly due to the proof requiring 80 iterations of the same proof process (\\S\\ref{sec:3-Serial Number Signature of Knowledge}), which means that 80 sets of proof parameters are generated and verified to in one SNSoK. This differs from the standard scheme of the Fiat-Shamir heuristic, where the verification of the resultant proof only requires a single iteration.\n\n\\section{Construction of Proposed SNSoK}\n\\label{sec:5-Construction of Proposed SNSoK}\nThis research proposes a more efficient SNSoK that modifies the ZK proof for a committed value in a Pedersen commitment outlined by Hohenberger \\cite{Hohenberger2002}. The standard Fiat Shamir Heuristics is used to make the proof non-interactive and the resultant proof can be verified in a single iteration.\n\nThe proposed SNSoK starts off in a same way as the original SNSoK. In order to hide the \\kwCoin{} $c$ that is being proven, the prover creates a Pedersen commitment $y$ of $c$ using a random trapdoor $z\\in\\expIntGroup{\\varQSok}$, such that $y=\\expSoKCoinComm{c}=\\expSoKCoinComm{\\expPedCommCoin}$. Also, like in the original proof, the SNSoK proves in zero-knowledge that $y$ contains a $c$ that is a commitment of the serial number $S$ and trapdoor $r$ as follows:\n\n$$\\eqnSNSoKActual$$\n\nHowever of the proposed SNSoK does not required 80 $(t,s,s')$ values to be included in the proof. Instead, alluding to the methods by Hohenberger, the prover computes a single $t=\\varGSok^{\\varGComm^{S}\\varHComm^{v_1}}\\varHSok^{v_2}$ where $v_1\\in\\expIntGroup{\\varQComm},v_2\\in\\expIntGroup{\\varQSok}$. Following the principle of the Fiat-Shamir heuristics, the prover then computes the challenge string $\\varChallenge=H(\\expConcatSNSoKImproved)$ which also doubles up as the signature for the transaction contents $m$ (\\S\\ref{sec:3-Serial Number Signature of Knowledge}). The prover then computes a single $s=\\varHComm^{v_1}-\\varChallenge\\varHComm^{r}$ and $s'=v_2-\\varChallenge z$. The prover writes $y,t,s,s'$ and the transaction content $m$ into the \\kwTransaction{Spend }{}. Upon receiving the \\kwTransaction{Spend }{}, the verifying node recomputes $\\varChallenge=H(\\expConcatSNSoKImproved)$ using the received $y,t,m$, the serial number $S$ of the \\kwCoin{} and the public parameters $\\varGSok,\\varHSok$. The verifier then verifies the proof by checking $t=y^{\\varChallenge}\\varGSok^{\\varGComm^{S}s}\\varHSok^{s'}$.\n\nSince only a single tuple $(t,s,s')$ is included in the proposed SNSoK as opposed to the 80 $(t,s,s')$ in the original SNSoK, the proof size of the proposed SNSoK should be smaller by about 80 times. Similarly, the time needed to verify the proposed SNSoK should also decrease by a similar amount since verification is done in one iteration instead of the 80 iterations in the original SNSoK. The exact improvements in performance brought by the proposed SNSoK is shown in \\S\\ref{sec:5-Performance of Proposed SNSoK and Future Work}.\n\n\\section{Zero-Knowledge Properties of Proposed SNSoK}\n\\label{sec:5-Zero-Knowledge Properties of Proposed SNSoK}\nIn order for the proposed SNSoK to be valid, it must satisfy the three ZK properties defined in \\S\\ref{sec:3-Properties of Zero-Knowledge Proofs}.\n\n\\subsection{Completeness}\nThe completeness property of the improved SNSoK can be shown by demonstrating that the proof produced by an honest prover who knows $S,r,z$ can always to be verified. Hence it suffices to show that the verification equation is correct. To prove that $t=y^{\\varChallenge}\\varGSok^{\\varGComm^{S}s}\\varHSok^{s'}$, the equation can be expanded as such:\n\n\\begin{equation*}\n\t\\begin{split}\n\tt &= y^{\\varChallenge}\\varGSok^{\\varGComm^{S}s}\\varHSok^{s'} \\\\\n\t&= (\\expSoKCoinComm{\\expPedCommCoin})^{\\varChallenge}\\varGSok^{\\varGComm^{S}(\\varHComm^{v_1}-\\varChallenge\\varHComm^{r})}\\varHSok^{v_2-\\varChallenge z} \\\\\n\t&= \\varGSok^{\\varChallenge\\varGComm^{S}\\varHComm^{r}}\\varHSok^{\\varChallenge z}\\varGSok^{\\varGComm^{S}\\varHComm^{v_1}-\\varChallenge\\varGComm^{S}\\varHComm^{r})}\\varHSok^{v_2-\\varChallenge z} \\\\\n\t&= \\varGSok^{\\varGComm^{S}\\varHComm^{v_1}}\\varHSok^{v_2} \\\\\n\t&= t\n\t\\end{split}\n\\end{equation*}\n\nAs seen, the verification equation is indeed correct and the proposed SNSoK is complete.\n\n\\subsection{Soundness}\nThe soundness property of improved SNSoK can be shown by demonstrating that a hypothetical knowledge extractor can obtain $c$ and $z$ from two accepting proofs that uses the same $t$ but different $(\\varChallenge,s,s')$ (\\S\\ref{sec:3-Properties of Zero-Knowledge Proofs}). Given these conditions, and let the two different $(\\varChallenge,s,s')$ be $(\\varChallenge_1,s_1,s'_1)$ and $(\\varChallenge_2,s_2,s'_2)$, the following equations be can constructed:\n\n$$t=y^{\\varChallenge_1}\\varGSok^{\\varGComm^{S}s_1}\\varHSok^{s'_1}=y^{\\varChallenge_2}\\varGSok^{\\varGComm^{S}s_2}\\varHSok^{s'_2}$$\n\nHence it can be derived that:\n\n\\begin{align*}\ny^{\\varChallenge_{1}}\\varGSok^{\\varGComm^{S}s_{1}}\\varHSok^{s'_{1}} &= y^{\\varChallenge_{2}}\\varGSok^{\\varGComm^{S}s_{2}}\\varHSok^{s'_{2}} \\\\\ny^{\\varChallenge_{1}-\\varChallenge_{2}} &= \\varGSok^{\\varGComm^{S}(s_{2}-s_{1})}\\varHSok^{s'_{2}-s'_{1}} \\\\\ny &= \\varGSok^{\\frac{\\varGComm^{S}(s_2-s_1)}{\\varChallenge_1-\\varChallenge_2}}\\varHSok^{\\frac{s'_2-s'_1}{\\varChallenge_1-\\varChallenge_2}}\n\\end{align*}\n\n\nSince $y=\\expSoKCoinComm{c}$, the knowledge extractor can successfully determine that $c=\\frac{\\varGComm^{S}(s_2-s_1)}{\\varChallenge_1-\\varChallenge_2}$ and $z=\\frac{s'_2-s'_1}{\\varChallenge_1-\\varChallenge_2}$. Hence the success of the knowledge extractor in extracting the secret \\kwCoin{} $c$ and the secret trapdoor $z$ shows that the proposed proof is sound.\n\n\\subsection{Statistical Zero-Knowledge}\nThe statistical zero-knowledge property of the improved SNSoK can be shown by demonstrating that a hypothetical simulator can generate $s$ and $s'$ that are statistically indistinguishable from the $s$ and $s'$ generated by the prover (\\S\\ref{sec:3-Properties of Zero-Knowledge Proofs}). \n\nFirstly it can be shown that the $s$ and $s'$ generated by the prover are random numbers. Since $\\varHComm$ is the generator for the subgroup of order $\\varQComm$, $\\varHComm^{x}$ produces all element in the subgroup exactly once for $x$ from 1 to $\\varQComm$. Thus there is a one-to-one mapping between $v_1$ and $\\varHComm^{v_1}$ and since $v_1\\in\\expIntGroup{\\varQComm}$ and $v_1$ is random, $\\varHComm^{v_1}$ is also random. As a random number added with a constant still produces a random number, $s=\\varHComm^{v_1}-\\varChallenge\\varHComm^{r}$ is also random. Similarly, since $v_2$ is random, $s'=v_2-\\varChallenge z$ is also random. \n\nAs such the simulator can be just a random number generator that produces random numbers $s\\in\\expIntGroup{\\varQComm}$ and $s'\\in\\expIntGroup{\\varQSok}$. Since the $s$ and $s'$ produced by the simulator and the $s$ and $s'$ produced by the prover are both uniformly distributed, they are statistically indistinguishable. Hence the proposed SNSoK achieves statistical zero-knowledge.\n\n\\section{Performance of Proposed SNSoK and Future Work}\n\\label{sec:5-Performance of Proposed SNSoK and Future Work}\nThe performance of the proposed SNSoK is measured using some basic performance metrics defined in \\S\\ref{sec:4-Performance Metrics and Benchmarks}. The results are shown in Table~\\ref{tab:SNSoK_improvement_performance}.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{ l | c | c }\n\t\t\\multirow{2}{*}{} & \\multicolumn{2}{c}{\\textit{Average over 50 iterations}} \\\\\n\t\t& \\textbf{Proposed} & \\textbf{Original} \\\\ \t\t\n\t\t\\hline \n\t\t\\hline\n\t\tSize of one SNSoK & 390 bytes & 17,420 bytes \\\\\n\t\t\\hline\n\t\tVerification time of one SNSoK & 1.8ms & 163ms \\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Performance of proposed SNSoK using basic performance metrics}\n\t\\label{tab:SNSoK_improvement_performance}\n\\end{table}\n\nAs seen, the proposed SNSoK has drastically reduced the verification time and size of one SNSoK. The verification time is reduced by about 80 times. This is within expectation as the proposed SNSoK essentially reduces the 80 iterations required for each verification to one iteration. The size of the SNSoK is reduced by about 44 times. While this is a huge improvement, it does not match up to expectations as the proposed SNSoK should have reduced the size of the proof by 80 times since it reduces the 80 sets of proof parameters $(t,s,s')$ to just a single set. \n\nThe original SNSoK is smaller than expected because it has been optimised. The idea of the original SNSoK is the same as the standard NIZK proof, where the verifier test whether the $t$ sent by the prover equals to the one that it computes using the response $s$ from the prover and the challenge $\\varChallenge$. Specifically the verifier of the original SNSoK checks for the equality between the received $t$ and the $t'$ computed based on the received $s_i,s'_i,\\varChallenge$ (\\S\\ref{sec:3-Serial Number Signature of Knowledge}). However, the verifier in the original SNSoK does not check for this equality directly. Since the $\\varChallenge$ sent by the prover is a hash that contains of all the $t_i$ (\\S\\ref{sec:3-Serial Number Signature of Knowledge}), the verifier simply checks that the $\\varChallenge'$ obtained by hashing all the $t'_i$ equals to $\\varChallenge$. Under this scheme, a single 256 bits $\\varChallenge$ is included in the proof instead of the 80 1024 bits $t_i$, resulting in a much smaller proof size. Currently, the proposed SNSoK does not make use of this optimisation and includes $t$ in the proof. However such optimisation is likely to be applicable to the proposed SNSoK and will be explored in the subsequent phase of the research. \n\nThe tests conducted to evaluate the proposed SNSoK are still preliminary. This research has yet to show the effects of the proposed SNSoK on the Zerocoin network. Going forward, the research will conduct experiments to examine the performance of the original and the improved Zerocoin protocol on a network level using the performance metrics outlined in \\S\\ref{sec:4-Performance Metrics and Benchmarks}.\n", "meta": {"hexsha": "dc6d82db44670be25015e45cda7a0f9e150da06c", "size": 10510, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter5/chapter5.tex", "max_stars_repo_name": "shaofeinus/fyp-report", "max_stars_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter5/chapter5.tex", "max_issues_repo_name": "shaofeinus/fyp-report", "max_issues_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter5/chapter5.tex", "max_forks_repo_name": "shaofeinus/fyp-report", "max_forks_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 114.2391304348, "max_line_length": 1266, "alphanum_fraction": 0.7648905804, "num_tokens": 3024, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4396475442010581}}
{"text": "\\subsection{String resonance angular distributoon}\n\n\\begin{figure}[htb]\n\\begin{center}\n\\includegraphics[width=0.45\\linewidth]{../figures/strings/angle_gg_gg}\n\\includegraphics[width=0.45\\linewidth]{../figures/strings/angle_qq-bar_gg}\n\\includegraphics[width=0.45\\linewidth]{../figures/strings/angle_gq_gq}\n\\includegraphics[width=0.45\\linewidth]{../figures/strings/angle_gg_qq-bar}\n\\end{center}\n\\caption{Angular distribution of the outgoing partons from string\nresonances in the centre of mass system: \n(top-left) $gg\\to gg$,\n(top-right) $q\\bar{q}\\to gg$,\n(bottom-left) $gq\\to gq$,\n(bottom-right) $gg\\to q\\bar{q}$.}\n\\label{fig:stringangle}\n\\end{figure}\n\nThe string resonance consist of a combination excited quark, excited\ngluon, and colour singlet states, depending on the subprocess.\nIn choosing the $y^*$ cut it is useful to examine the decay angular\ndistributions. \nFigure~\\ref{fig:stringangle} shows the angular distribution of the outgoing partons\nin the center of mass system for four different string resonance\nsubprocesses. \nThe case of string scale $\\Ms = 8$~TeV is shown but the distributions\nare similar for the other generated string scales.\nThe angular distribution for the process $g\\bar{q}\\to g\\bar{q}$ (not\nshown) is similar to $gq\\to gq$.\nThe red curves show the calculated angular distributions for a string\nmass equal to \\Ms.\n", "meta": {"hexsha": "8b7d91f219467d474e2234d0dcdc7a67a915b11f", "size": 1343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/stringangles.tex", "max_stars_repo_name": "krybacki/IntNote2", "max_stars_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/stringangles.tex", "max_issues_repo_name": "krybacki/IntNote2", "max_issues_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/stringangles.tex", "max_forks_repo_name": "krybacki/IntNote2", "max_forks_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.96875, "max_line_length": 83, "alphanum_fraction": 0.7758749069, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.43964754063685135}}
{"text": "\\documentclass{slnotes}\r\n\\newcommand*{\\slbx}[1]{{\\ifmmode\\smash{\\boxed{#1\\vphantom{X}}}\\else\\smash{\\fbox{#1\\vphantom{X}}}\\fi}}\r\n\\newcommand*{\\ve}[1]{\\mathbf{#1}}\r\n\\newcommand*\\cve[3][]{\\begin{pmatrix}\\ifx\\relax#1\\relax\\else#1\\\\\\fi#2\\\\#3\\end{pmatrix}}\r\n\\newcommand*{\\im}{\\mathrm{i}}\r\n\\DeclareMathOperator*{\\Prb}{P}\r\n\\DeclareMathOperator*{\\Pois}{Po}\r\n\\DeclareMathOperator*{\\Binom}{B}\r\n\\DeclareMathOperator*{\\Norm}{N}\r\n\\DeclareMathOperator*{\\Exp}{E}\r\n\\DeclareMathOperator*{\\Var}{Var}\r\n\\begin{document}\r\n\\chapter{Functions}\r\nA relation \\(f \\colon X \\to Y\\) where \\(X, Y \\subseteq \\mathbb R\\) is a function if, \\(\\mathrel\\forall a \\in X\\), the vertical line \\(x = a\\) cuts the graph of \\(f\\) at exactly one point.\r\n\r\nA relation \\(f\\) can be proven to be not a function if there is some \\(a \\in X\\) for which the vertical line \\(x = a\\) cuts the graph of \\(f\\) zero times or more than once.\r\n\r\nA function \\(f\\) is one-one if, \\(\\mathrel\\forall a \\in \\mathbb R\\), the horizontal line \\(y = a\\) cuts the graph of \\(f\\) at most once.\r\n\r\nA function \\(f\\) can be proven to be not one-one if there is some \\(a \\in \\mathbb R\\) for which the horizontal line \\(y = a\\) cuts the graph of \\(f\\) more than once.\r\n\\chapter{APGP}\r\nFor a series \\(S_n\\), the \\(n\\)th term of the corresponding progression \\[T_n = S_n - S_{n-1}\\]\r\n\r\nFor an arithmetic progression \\(T_n\\) and an arithmetic series \\(S_n\\) the \\(n\\)th term \\begin{align*}T_n &= a + (n-1)d\\\\S_n &= \\frac{n}{2}(a + l)\\\\&= \\frac{n}{2}(2a+(n-1)d)\\end{align*} where \\(a\\) is the first term, \\(l\\) is the last term and \\(d\\) is the common difference. To prove that a series \\(S_n\\) is an arithmetic series, \\[T_n - T_{n-1}\\text{ is a constant} \\iff S_n\\text{ is an arithmetic series}\\]\r\n\r\nFor a geometric progression \\(T_n\\) and a geometric series \\(S_n\\) the \\(n\\)th term \\begin{align*}T_n &= ar^{n-1}\\\\S_n &= a\\frac{r^n-1}{r-1}\\end{align*} where \\(a\\) is the first term and \\(r\\) is the common ratio. To prove that a series \\(S_n\\) is a geometric series, \\[\\frac{T_n}{T_{n-1}}\\text{ is a constant} \\iff S_n\\text{ is a geometric series}\\]\r\n\r\nFor a geometric progression with \\(|r| < 1\\) the sum to infinity \\[S_\\infty = \\frac{a}{1-r}\\]\r\n\\chapter{Induction format}\r\nLet \\(P_n\\) be the statement \\(\\slbx{\\text{LHS}} = \\slbx{\\text{RHS}}\\text{, }n \\in \\slbx{X}\\).\r\n\r\n\\begin{tabbing}\r\nWhen \\(n = \\slbx{n}\\), \\=\\(\\text{LHS} = \\slbx{\\text{LHS}} = \\slbx{\\text{LHS value}}\\).\\\\\r\n\\>\\(\\text{RHS} = \\slbx{\\text{RHS}} = \\slbx{\\text{RHS value}} = \\text{LHS}\\).\\\\\r\n\\>\\(\\mathrel\\therefore P_\\slbx{n}\\text{ is true.}\\)\\\\\r\n\\end{tabbing}\r\n\r\nAssume \\(P_k\\) is true for some \\(k \\in \\slbx{X}\\) i.e. \\(\\slbx{\\text{LHS}} = \\slbx{\\text{RHS}}\\).\r\n\r\nTo prove \\(P_{k+1}\\) is also true i.e. \\(\\slbx{\\text{LHS}} = \\slbx{\\text{RHS}}\\) \\begin{align*}\\text{LHS} &= \\slbx{\\text{LHS}} = \\cdots\\\\&= \\slbx{\\text{RHS}} = \\text{RHS}\\end{align*} \\(\\mathrel\\therefore P_k\\text{ is true} \\implies P_{k+1}\\text{ is true}\\).\r\n\r\nSince \\(P_\\slbx{n}\\) is true, and \\(P_k\\text{ is true} \\implies P_{k+1}\\text{ is true}\\), by mathematical induction, \\(P_n\\text{ is true}\\mathrel\\forall n \\in \\slbx{\\mathrm X}\\).\r\n\\chapter{Vectors}\r\nLet there be two points \\(A\\) and \\(B\\) which have position vectors \\(\\ve a\\) and \\(\\ve b\\).\r\n\r\nFor the vectors \\(\\ve a\\) and \\(\\ve b\\), their dot product where \\(\\theta\\) is the angle between them \\begin{align*}\\ve a \\cdot \\ve b &= |\\ve a||\\ve b|\\cos\\theta\\\\&=\\cve[x_{\\ve a}]{y_{\\ve a}}{\\vdots} \\cdot \\cve[x_{\\ve b}]{y_{\\ve b}}{\\vdots} = x_{\\ve a}x_{\\ve b} + y_{\\ve a}y_{\\ve b} + \\cdots\\end{align*}\r\n\r\nTheir cross product where \\(\\theta\\) is the angle between them and \\(\\ve{\\hat n}\\) is a unit vector perpendicular to both in the direction of a right-handed screw turned from \\(\\ve a\\) to \\(\\ve b\\) \\begin{align*}\\ve a \\times \\ve b &= \\ve{\\hat n}|\\ve a||\\ve b|\\sin\\theta\\\\&= \\cve[x_{\\ve a}]{y_{\\ve a}}{z_{\\ve a}} \\times \\cve[x_{\\ve b}]{y_{\\ve b}}{z_{\\ve b}} = \\cve[y_{\\ve a}z_{\\ve b} - y_{\\ve b}z_{\\ve a}]{z_{\\ve a}x_{\\ve b} - z_{\\ve b}x_{\\ve a}}{x_{\\ve a}y_{\\ve b} - x_{\\ve b}y_{\\ve a}}\\end{align*}\r\n\r\nFrom the above definitions \\begin{align*}\\ve a \\mathrel\\bot \\ve b &\\iff \\ve a \\cdot \\ve b = 0\\\\\\ve a \\parallel \\ve b &\\iff \\mathrel\\exists \\lambda \\in (\\mathbb{R} \\setminus \\{0\\}): \\ve b = \\lambda\\ve a\\end{align*}\r\n\r\nThe angle between the vectors \\[\\theta = \\cos^{-1}\\frac{\\ve a \\cdot \\ve b}{|\\ve a||\\ve b|}\\]\r\n\r\nThe length of projection and the projection vector of \\(\\ve a\\) onto \\(\\ve b\\) where \\(F\\) is the foot of the perpendicular from \\(A\\) to \\(OB\\)\\begin{align*}OF &= |\\ve a \\cdot \\ve{\\hat b}|\\\\\\overrightarrow{OF} &= (\\ve a \\cdot \\ve{\\hat b})\\ve{\\hat b}\\end{align*} The perpendicular distance from \\(A\\) to \\(OB\\) \\[AF = |\\ve a \\times \\ve{\\hat b}|\\]\r\n\r\nA vector normal to \\(\\ve a\\) and \\(\\ve b\\) is simply \\(\\ve a \\times \\ve b\\).\r\n\r\nIf \\(ABCD\\) is a parallelogram then \\begin{align*}\\text{area of }ABD &= \\frac{1}{2}\\left|\\overrightarrow{AB} \\times \\overrightarrow{AD}\\right|\\\\\\text{area of }ABCD &=  \\left|\\overrightarrow{AB} \\times \\overrightarrow{AD}\\right|\\end{align*}\r\n\r\nFor three points \\(A\\), \\(B\\) and \\(C\\), {\\jot0pt\\begin{multline*}A\\text{, }B\\text{ and }C\\text{ are collinear}\\\\\\iff \\mathrel\\exists\\lambda\\in(\\mathbb R \\setminus \\{0\\}): \\overrightarrow{AB} = \\lambda\\overrightarrow{AC}\\end{multline*}}\r\n\r\nThe general equation of a line is \\[\\ve r = \\ve a + \\lambda\\ve d\\quad\\lambda\\in\\mathbb R\\] where \\(\\ve d\\) is the direction vector of the line.\r\n\r\nThe parametric equation of a plane is \\[\\ve r = \\ve a + \\lambda\\ve m_1 + \\mu\\ve m_2\\quad\\lambda,\\mu\\in\\mathbb R\\] The vector equation of the same plane is \\[\\ve r \\cdot \\ve n = D\\quad D = \\ve a \\cdot \\ve n\\] The cartesian equation of the plane is \\[\\ve r = \\cve[x]{y}{z} \\wedge \\ve a = \\cve[a]{b}{c} \\implies ax+by+cz = D\\]\r\n\\chapter{Complex Numbers}\r\nFor a complex number \\begin{align*}z &= x + \\im y\\\\&= |z|(\\cos(\\arg z) + \\im\\sin(\\arg z)) \\\\&= |z|e^{\\im(\\arg z)}\\end{align*} its conjugate and magnitude \\begin{align*}z^* &= x - \\im y\\\\zz^* &= |z|^2 = x^2 + y^2 \\implies |z| = \\sqrt{x^2+y^2}\\end{align*} and its argument \\[\\arg z = \\begin{cases}\\tan^{-1} \\frac{y}{x} & x > 0\\\\\\pi + \\tan^{-1} \\frac{y}{x} & x < 0 \\wedge y \\geq 0\\\\-\\pi + \\tan^{-1} \\frac{y}{x} & x < 0 \\wedge y < 0\\end{cases}\\]\r\n\r\nThe properties of the argument \\(\\arg z\\) are identical to the properties of the logarithm.\r\n\r\nIf a polynomial with real coefficients has complex root \\(\\alpha\\), then \\(\\alpha^*\\) is also a root.\r\n\r\nThe fundamental theorem of algebra states that every polynomial equation of degree \\(n\\) has \\(n\\) roots that may not be distinct.\r\n\\chapter{Probability}\r\nSome useful results are \\begin{gather*}\\Prb(A') = 1-\\Prb(A)\\\\\\Prb(A\\cup B) = \\Prb(A) + \\Prb(B) - \\Prb(A \\cap B)\\\\\\Prb(A | B) = \\frac{\\Prb(A \\cap B)}{\\Prb(B)}\\end{gather*}\r\n\r\nIf \\(A\\) and \\(B\\) are independent events then \\[\\Prb(A|B) = \\Prb(A) \\wedge \\Prb(B|A) = \\Prb(B) \\wedge \\Prb(A\\cap B) = \\Prb(A)\\Prb(B)\\]\r\n\r\nIf \\(A\\) and \\(B\\) are mutually exclusive events then \\[\\Prb(A\\cap B) = 0 \\wedge \\Prb(A \\cup B) = \\Prb(A) + \\Prb(B)\\]\r\n\\chapter{Distributions}\r\nFor an random variable to be modelled by a binomial distribution, it must have \\begin{slinenum}\r\n\\item a fixed number of trials\r\n\\item independent trials\r\n\\item identical trials\r\n\\item the same probability of success for each trial\r\n\\item two possible outcomes.\r\n\\end{slinenum}\r\n\r\nFor an event to be modelled by a Poisson distribution, it must \\begin{slinenum}\r\n\\item occur at a constant average rate\r\n\\item occur singly\r\n\\item have independent occurrences.\r\n\\end{slinenum}\r\n\r\nFor an event \\(X\\) \\begin{gather*}X \\sim \\Norm(\\mu, \\sigma^2) \\implies Z = \\frac{X-\\mu}{\\sigma} \\sim\\Norm(0, 1)\\\\\\Prb(X \\leq x) = \\Prb(Z \\leq \\frac{x- \\mu}{\\sigma})\\end{gather*}\r\n\\chapter{Expectation and Variance}\r\nThe expected value of a random variable is the prob\\-ability-weighted average of all possible values: \\[\\Exp(X) = \\sum x \\Prb(X = x) = \\int_{-\\infty}^\\infty xf(x)\\slid x\\] where \\(f(x)\\) is the probability density function of weighing \\(X\\), if it is a continuous random variable..\r\n\r\nIf \\(X\\) and \\(Y\\) are independent random variables, \\(X_1\\) and \\(X_2\\) are independent observations of \\(X\\), and \\(a\\) and \\(b\\) are constants then \\begin{align*}\\Exp(a) &= a\\\\\\Exp(aX + bY) &= a\\Exp(X) + b\\Exp(Y)\\\\\\Var(a) &= 0\\\\\\Var(aX + bY) &= a^2\\Var(X) + b^2\\Var(Y)\\\\\\Var(X_1 + X_2) &= \\Var(X_1) + \\Var(X_2) = 2\\Var(X)\\end{align*}\r\n\\chapter{Approximations}\r\nIf \\(X\\) is a random discrete variable such that \\[X \\sim \\Binom(n, p)\\] then if \\(n\\) is large and \\(p\\) is small such that \\(np < 5\\), \\[X \\sim \\Pois(np)\\text{ approximately}\\]\r\n\r\nIf \\(X\\) is a random discrete variable such that \\[X \\sim \\Binom(n, p)\\] then if \\(n\\) is large such that \\(np > 5 \\wedge nq > 5\\), \\[X \\sim \\Norm(np,npq)\\text{ approximately}\\]\r\n\r\nIf \\(X\\) is a random discrete variable such that \\[X \\sim \\Pois(\\lambda)\\] then if \\(\\lambda > 10\\), \\[X \\sim \\Norm(\\lambda,\\lambda)\\text{ approximately}\\]\r\n\r\nWhen a normal distribution is used to approximate a discrete distribution, continuity correction must be done.\r\n\\chapter{Sampling}\r\nIf \\(X\\) is a random variable with unknown or non-normal distribution where \\[\\Exp(X) = \\mu\\text{ and }\\Var(X) = \\sigma^2\\] central limit theorem states that if sample size \\(n\\) is large, \\[\\overline{X} \\sim \\Norm(\\mu,\\frac{\\sigma^2}{n})\\text{ approximately}\\]\r\n\r\nUnbiased estimates of \\(\\mu\\) and \\(\\sigma^2\\) are sample mean \\(\\overline{x}\\) and \\(s^2\\) respectively. \\[s^2 = \\frac{n}{n-1}(\\text{sample variance})\\]\r\n\\chapter{Hypothesis Testing}\r\n\\section{Format}\r\nLet \\(X\\) be the \\slbx{something} of a randomly chosen \\slbx{thing}.\r\n\r\nLet \\(\\mu\\) be the population mean \\slbx{something} of \\slbx{things}.\r\n\r\n{\\fboxsep=3pt\\fbox{\\begin{varwidth}{0.5\\textwidth}\\begin{tabbing}\r\n\\textbf{One of} \\=Given \\(X \\sim \\Norm(\\mu, \\sigma^2)\\),\\\\\r\n\\textbf{or}\\>Assume \\(X \\sim \\Norm(\\mu, \\sigma^2)\\),\\\\\r\n\\textbf{or}\\>Since \\(n = \\slbx{n}\\), by central limit theorem,\\end{tabbing}\\end{varwidth}}}\r\n\\[\\overline{X} \\sim \\Norm\\left(\\mu, \\frac{\\sigma^2}{n}\\right)\\ \\slbx{\\text{approximately}}\\]\r\n\r\n\\textbf{H}\\textsubscript0: \\(\\mu = \\mu_0\\); \\textbf{H}\\textsubscript1: \\slbx{\\(\\mu < \\mu_0\\) \\textbf{or} \\(\\mu > \\mu_0\\) \\textbf{or} \\(\\mu \\neq \\mu_0\\)}\r\n\r\nTest statistic:\r\n\r\n{\\fboxsep=3pt\\fbox{\\begin{varwidth}{0.5\\textwidth}\\begin{tabbing}\r\n\\textbf{One of} \\=\\(T = \\dfrac{\\overline{X}-\\mu}{S/\\sqrt{n}} \\sim t_{n-1}\\)\\\\\\\\\r\n\\textbf{or}\\>\\(Z = \\dfrac{\\overline{X}-\\mu}{\\sigma/\\sqrt{n}}\\)\\\\\\\\\r\n\\textbf{or}\\>\\(Z = \\dfrac{\\overline{X}-\\mu}{S/\\sqrt{n}}\\)\\end{tabbing}\\end{varwidth}}}\r\n\r\nLevel of significance: \\slbx{\\(100\\alpha\\%\\)}; reject H\\textsubscript0 if p-value < \\slbx{\\(\\alpha\\)}.\r\n\r\nUnder H\\textsubscript0, p-value = \\slbx{p-value}.\r\n\r\nSince p-value = \\slbx{p-value} \\slbx{\\(<\\) \\textbf{or} \\(>\\)} \\(\\alpha\\), we \\slbx{do not} reject H\\textsubscript0 and conclude that there is \\slbx{in}sufficient evidence, at \\slbx{\\(100\\alpha\\%\\)} level, that \\slbx{H\\textsubscript1}.\r\n\\section{Definitions}\r\nIf the level of significance is \\(100\\alpha\\%\\), there is a probability of \\(\\alpha\\) of concluding that H\\textsubscript1 is true when in fact, H\\textsubscript0 is true.\r\n\r\nThe p-value is the probability of obtaining a sample mean \\textbf(less than or equal to \\textbf{or} more than or equal to \\textbf{or} as extreme or more extreme than\\textbf) \\(\\overline{x}\\), assuming H\\textsubscript0 is true.\r\n\\chapter{Sampling Methods}\r\nA population is a collection of individuals or objects from which we may collect data.\r\n\r\nA random sample is a small representative of the population in which every member in the population has an equal probability of being selected.\r\n\r\nWe often take a sample instead of collecting data from the entire population as \\begin{slinenumor}\r\n\\item it may be too costly or time consuming to collect the information from the whole population\r\n\\item the population may be infinite or too large.\r\n\\end{slinenumor}\r\n\\section{Quota sampling}\r\nTo take a quota sample, we \\begin{slinenum}\r\n\\item divide the population into mutually exclusive subgroups called strata, namely \\slbx{group} and \\slbx{group}\r\n\\item select \\slbx{number} \\slbx{group} and \\slbx{number} \\slbx{group} to form the sample. The sample from each stratum is non-random.\r\n\\end{slinenum}\r\n\r\nQuota sampling is advantageous as \\begin{slinenum}\r\n\\item it is easy to select the sample and administer the survey\r\n\\item no sampling frame needed\r\n\\item it incurs low cost.\r\n\\end{slinenum}\r\n\r\nHowever, it is bad in that \\begin{slinenum}\r\n\\item the sample obtained is non-random\r\n\\item it is likely to result in selection bias as interviewer may select those who are easier to interview.\r\n\\end{slinenum}\r\n\\section{Simple random sampling}\r\nTo take a simple random sample, we \\begin{slinenum}\r\n\\item obtain the list of \\slbx{samplees} and number all \\slbx{samplees} from 1 to \\slbx{number}\r\n\\item use a random number generator to randomly select \\slbx{number} numbers\r\n\\item select the \\slbx{samplees} corresponding to the numbers to form the sample.\r\n\\end{slinenum}\r\n\r\nSimple random sampling is advantageous as \\begin{slinenum}\r\n\\item the data collected generally free from bias\r\n\\item analysis of data is relatively easy.\r\n\\end{slinenum}\r\n\r\nHowever, it is bad in that \\begin{slinenum}\r\n\\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population\r\n\\item it may be difficult to get access to members who have been chosen for the sample\r\n\\end{slinenum}\r\n\\section{Systematic sampling}\r\nTo take a systematic sample, we \\begin{slinenum}\r\n\\item obtain the list of \\slbx{samplees} and number all \\slbx{samplees} from 1 to \\slbx{number}\r\n\\item compute the sampling interval \\(k = \\slbx{\\text{calculation}}\\)\r\n\\item randomly select an integer from 1 to \\slbx{number} as the start\r\n\\item select every \\slbx{\\(k\\)}th member of the population thereafter until the sample of \\slbx{number} is obtained.\r\n\\end{slinenum}\r\n\r\nSystematic sampling is advantageous as \\begin{slinenum}\r\n\\item the data collected is generally free from bias\r\n\\item analysis of data is relatively easy.\r\n\\end{slinenum}\r\n\r\nHowever, it is bad in that \\begin{slinenum}\r\n\\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population\r\n\\item it may be difficult to get access to members who have been chosen for the sample\r\n\\item there may be selection bias if the members of the population is arranged in a periodic or cyclic pattern.\r\n\\end{slinenum}\r\n\\section{Stratified sampling}\r\nTo take a stratified sample, we \\begin{slinenum}\r\n\\item obtain the list of \\slbx{samplees} and divide the population into mutually exclusive subgroups called strata, namely \\slbx{group} and \\slbx{group}\r\n\\item calculate the sample size that should be taken for each stratum, proportional to their size i.e. \\(\\slbx{\\text{calculation}} = \\slbx{\\text{number}}\\) for \\slbx{group}, and \\slbx{number} for \\slbx{group}\r\n\\item select the sample from each stratum using simple random sampling.\r\n\\end{slinenum}\r\n\r\nStratified sampling is advantageous as \\begin{slinenum}\r\n\\item it is more likely to give a good representative sample of the population\r\n\\item when there are clear strata present, it usually gives more reliable estimates of the population parameters than random or systematic sampling.\r\n\\end{slinenum}\r\n\r\nHowever, it is bad in that \\begin{slinenum}\r\n\\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population\r\n\\item it is more difficult to conduct than random sampling\r\n\\item it may be difficult to identify appropriate strata\r\n\\item strata may not be clearly defined.\r\n\\end{slinenum}\r\n\\end{document}\r\n", "meta": {"hexsha": "414c5bc9a94ef06fa625eb40c7424368b8bde976", "size": 15577, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX/Mathematics/Mathematics.tex", "max_stars_repo_name": "oliverli/A-Level-Notes", "max_stars_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-05T11:44:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-05T11:44:33.000Z", "max_issues_repo_path": "TeX/Mathematics/Mathematics.tex", "max_issues_repo_name": "oliverli/A-Level-Notes", "max_issues_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX/Mathematics/Mathematics.tex", "max_forks_repo_name": "oliverli/A-Level-Notes", "max_forks_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.1278538813, "max_line_length": 499, "alphanum_fraction": 0.6739423509, "num_tokens": 5132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.43960612293024154}}
{"text": "\\subsection{Spline basis sets}\n\\label{sec:spo_spline}\nIn this section we describe the use of spline basis sets to expand the \\texttt{sposet}.\nSpline basis sets are designed to work seamlessly with plane wave DFT code, e.g.\\ Quantum ESPRESSO as a trial wavefunction generator.\n\nIn QMC algorithms, all the SPOs $\\{\\phi(\\vec{r})\\}$ need to be updated every time a single electron moves.\nEvaluating SPOs takes very large portion of computation time.\nIn principle, PW basis set can be used to express SPOs directly in QMC like in DFT.\nbut it introduces an unfavorable scaling due to the fact \nthat the basis set size increases linearly as the system size.\nFor this reason, it is efficient to use a localized basis with compact\nsupport and a good transferability from plane wave basis. \n\nIn particular, 3D tricubic B-splines provide a basis in which only\n64 elements are nonzero at any given point in space~\\cite{blips4QMC}.\nThe one-dimensional cubic B-spline is given by,\n\\begin{equation}\nf(x) = \\sum_{i'=i-1}^{i+2} b^{i'\\!,3}(x)\\,\\,  p_{i'},\n\\label{eq:SplineFunc}\n\\end{equation}\nwhere $b^{i}(x)$ are the piecewise cubic polynomial basis functions\nand $i = \\text{floor}(\\Delta^{-1} x)$ is the index of\nthe first grid point $\\le x$.  Constructing a tensor product in each Cartesian\ndirection, we can represent a 3D orbital as\n\\begin{equation}\n  \\phi_n(x,y,z) = \n  \\!\\!\\!\\!\\sum_{i'=i-1}^{i+2} \\!\\! b_x^{i'\\!,3}(x) \n  \\!\\!\\!\\!\\sum_{j'=j-1}^{j+2} \\!\\! b_y^{j'\\!,3}(y) \n  \\!\\!\\!\\!\\sum_{k'=k-1}^{k+2} \\!\\! b_z^{k'\\!,3}(z) \\,\\, p_{i', j', k',n}.\n\\label{eq:TricubicValue}\n\\end{equation}\nThis allows the rapid evaluation of each orbital in constant time.\nFurthermore, this basis is systematically improvable with a single spacing\nparameter, so that accuracy is not compromised compared with plane wave basis.\n\nThe use of 3D tricubic B-splines greatly improves the computational efficiency.\nThe gain in computation time from plane wave basis set to an equivalent B-spline basis set \nbecomes increasingly large as the system size grows.\nOn the downside, this computational efficiency comes at\nthe expense of increased memory use, which is easily overcome by the large\naggregate memory available per node through OpenMP/MPI hybrid QMC.\n\nThe input xml block for the spline SPOs is give in Listing~\\ref{listing:splineSPOs}. A list of options is given in \nTable~\\ref{table:splineSPOs}. \\texttt{QMCPACK} has a very useful command line option \\texttt{--save\\_wfs} which allows to dump \nthe real space B-spline coefficient table into a h5 file on the disk.\nWhen the orbital transformation from k space to B-spline requires more than available amount of scratch memory on the compute nodes, \nusers can perform this step on fat nodes and transfer back the h5 file for QMC calculations.\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabularx}{\\textwidth}{l l l l l l }\n\\hline\n\\multicolumn{6}{l}{\\texttt{determinantset} element} \\\\\n\\hline\n\\multicolumn{2}{l}{parent elements:} & \\multicolumn{4}{l}{\\texttt{wavefunction}}\\\\\n\\multicolumn{2}{l}{child  elements:} & \\multicolumn{4}{l}{\\texttt{slaterdeterminant}}\\\\\n\\multicolumn{2}{l}{attribute      :} & \\multicolumn{4}{l}{}\\\\\n   &   \\bfseries name                   & \\bfseries datatype & \\bfseries values & \\bfseries default & \\bfseries description \\\\\n   &   \\texttt{type}                    &  text              &   bspline        &                   &  Type of \\texttt{sposet}. \\\\\n   &   \\texttt{href}                    &  text              &                  &                   &  Path to the h5 file made by pw2qmcpack.x. \\\\\n   &   \\texttt{tilematrix}              &  9 integers        &                  &                   &  Tiling matrix used to expand supercell. \\\\\n   &   \\texttt{twistnum}                &  integer           &                  &                   &  Index of the super twist. \\\\\n   &   \\texttt{twist}                   &  3 floats          &                  &                   &  Super twist. \\\\\n   &   \\texttt{meshfactor}              &  float             &  $\\le 1.0$       &                   &  Grid spacing ratio. \\\\\n   &   \\texttt{precision}               &  text              &  single/double   &                   &  Precision of spline coefficients. \\\\\n   &   \\texttt{gpu}                     &  text              &  yes/no          &                   &  GPU switch. \\\\\n   &   \\texttt{Spline\\_Size\\_Limit\\_MB} &  integer           &                  &                   &  Limit B-spline table size on GPU. \\\\\n   &   \\texttt{check\\_orb\\_norm}        &  text              &  yes/no          &  yes              &  Check norms of orbitals from h5 file. \\\\\n   &   \\texttt{source}                  &  text              &  \\textit{any}    &  ion0             &  Particle set with atomic positions. \\\\\n  \\hline\n\\end{tabularx}\n\\end{center}\n\\caption{Options for the \\texttt{determinantset} xml-block associated with B-spline single particle orbital sets.}\n\\label{table:splineSPOs}\n\\end{table}\n\n%%\\begin{lstlisting}[caption=.]\n%%<sposet_builder type=\"bspline\" href=\"pwscf.h5\" tilematrix=\"2 0 0 0 2 0 0 0 2\" twistnum=\"0\"\n%%                 source=\"i\" meshfactor=\"1.0\" precision=\"float\" truncate=\"no\">\n%%   <sposet type=\"bspline\" name=\"spo_ud\" size=\"208\" spindataset=\"0\"/>\n%%</sposet_builder>\n%%<determinantset>\n%%   <slaterdeterminant>\n%%      <determinant id=\"updet\" group=\"u\" sposet=\"spo_ud\" size=\"208\"/>\n%%      <determinant id=\"downdet\" group=\"d\" sposet=\"spo_ud\" size=\"208\"/>\n%%   </slaterdeterminant>\n%%</determinantset>\n%%\\end{lstlisting}\n\n\\begin{lstlisting}[caption=Determinant set XML element.\\label{listing:splineSPOs}]\n<determinantset type=\"bspline\" source=\"i\" href=\"pwscf.h5\"\n                tilematrix=\"1 1 3 1 2 -1 -2 1 0\" twistnum=\"-1\" gpu=\"yes\" meshfactor=\"0.8\"\n                twist=\"0  0  0\" precision=\"double\">\n  <slaterdeterminant>\n    <determinant id=\"updet\" size=\"208\">\n      <occupation mode=\"ground\" spindataset=\"0\">\n      </occupation>\n    </determinant>\n    <determinant id=\"downdet\" size=\"208\">\n      <occupation mode=\"ground\" spindataset=\"0\">\n      </occupation>\n    </determinant>\n  </slaterdeterminant>\n</determinantset>\n\\end{lstlisting}\n\nAdditional information:\n\\begin{itemize}\n\\item \\texttt{precision}. Only effective on CPU version without mixed precision, `single' is always imposed with mixed precision. Using single precision not only saves memory usage but also speeds up the B-spline evaluation. It is recommended to use single precision since we saw little chance of really compromising the accuracy of calculation.\n\\item \\texttt{meshfactor}. It is the ratio of actual grid spacing of B-splines used in QMC calculation with respect to the original one calculated from h5. Smaller meshfactor saves memory usage but reduces accuracy. The effects are similar to reducing plane wave cutoff in DFT calculation. Use with caution! \n\\item \\texttt{twistnum}. If positive, it is the index. It is recommended not to take this way since the indexing may show some uncertainty. If negative, the super twist is referred by \\texttt{twist}.\n\\item \\texttt{Spline\\_Size\\_Limit\\_MB}. Allows to distribute the B-spline coefficient table between the host and GPU memory. The compute kernels access host memory via zero-copy. Though the performance penaty introduced by it is significant but allows large calculations to go.\n\\end{itemize}\n", "meta": {"hexsha": "0b8644190d39eecdcd9e6e1033632506b46c67d3", "size": 7301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/spo_spline.tex", "max_stars_repo_name": "markdewing/qmcpack", "max_stars_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_stars_repo_licenses": ["NCSA"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manual/spo_spline.tex", "max_issues_repo_name": "markdewing/qmcpack", "max_issues_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_issues_repo_licenses": ["NCSA"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/spo_spline.tex", "max_forks_repo_name": "markdewing/qmcpack", "max_forks_repo_head_hexsha": "4bd3e10ceb0faf8d2b3095338da5a56eda0dc1ba", "max_forks_repo_licenses": ["NCSA"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-07-23T17:44:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-23T17:44:39.000Z", "avg_line_length": 64.0438596491, "max_line_length": 345, "alphanum_fraction": 0.6537460622, "num_tokens": 2027, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867729389245, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4394875162529763}}
{"text": "\\hypertarget{lab-02-variables-arrays-and-scripts}{%\n\\section{Lab 02: Variables, Arrays, and\nScripts}\\label{lab-02-variables-arrays-and-scripts}}\n\n\\hypertarget{variables}{%\n\\subsection{Variables}\\label{variables}}\n\n\\begin{frame}{}\n\\protect\\hypertarget{section}{}\nVariables help us represent quantities or expressions in order to make\ntheir use and re-use more convenient.\n\\end{frame}\n\n\\begin{frame}[fragile]{Naming Variables}\n\\protect\\hypertarget{naming-variables}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  Must start with a letter.\n\\item\n  Followed by letters (a-z, A-Z) or numbers (0-9) or underscores (\\_).\n\\item\n  Maximum 65 characters (excluding the .m extension).\n\\item\n  Must not be the same as any MATLAB reserved word.\n\\item\n  Space is not permitted.\n\\item\n  Case sensitive, i.e., \\texttt{a\\ \\textasciitilde{}=\\ A}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Naming Variables}\n\\protect\\hypertarget{naming-variables-1}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  Be as descriptive as possible with your variable names.\n\\item\n  Avoid built-in function/variable names (reserved keywords) such as\n  \\texttt{pi}, \\texttt{sin}, \\texttt{exp}, etc.\n\\item\n  Check if a name is already in use: \\texttt{which\\ variableName} or\n  \\texttt{exist\\ variableName}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Naming Conventions}\n\\protect\\hypertarget{naming-conventions}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  snake\\_case: writing compound words or phrases in which the elements\n  are separated with one underscore character (\\_) and no spaces,\n  e.g.~``foo\\_bar''.\n\\item\n  camelCase: writing compound words or phrases such that each word or\n  abbreviation in the middle of the phrase begins with a capital letter,\n  with no intervening spaces or punctuation, e.g.~``fooBar''\n\\item\n  Other conventions: Hungarian notation, positional notation, etc.\n\\item\n  Reference:\n  \\url{https://en.wikipedia.org/wiki/Naming_convention_(programming)}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Default Variable Definitions}\n\\protect\\hypertarget{default-variable-definitions}{}\n\\begin{table}[!hbtp]\n    \\begin{tabular}{rl}\n        Command & Description \\\\\n        \\hline\n        \\texttt{pi} & variable defining $\\pi$ \\\\\n        \\texttt{i} or \\texttt{1i} & imaginary number $i = \\sqrt{-1}$ \\\\\n        \\texttt{j} or \\texttt{1j} & imaginary number $j = \\sqrt{-1}$\n    \\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\hypertarget{arrays}{%\n\\subsection{Arrays}\\label{arrays}}\n\n\\begin{frame}[fragile]{Array, Vector, and Matrix}\n\\protect\\hypertarget{array-vector-and-matrix}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  An array is a data form that can hold several values, all of one type.\n\\item\n  A vector is a \\(1\\)-D array: we can define row vectors, column\n  vectors.\n\\item\n  A matrix is a \\(2\\)-D array.\n\\item\n  Also, we can define \\(N\\)-D array.\n\\item\n  The general notation for a vector or matrix is a list of values\n  enclosed in square brackets \\texttt{{[}{]}} separated by commas\n  (space) or semi-colons (or the combination).\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Vector: \\texttt{{[}{]}}}\n\\protect\\hypertarget{vector}{}\n\\begin{itemize}[<+->]\n\\item\n  Row vector: \\(x = \\begin{bmatrix} 1 & 2 & 3 & 4 \\end{bmatrix}\\)\n\n\\begin{verbatim}\nx = [1,2,3,4]\nx = [1 2 3 4]\n\\end{verbatim}\n\\item\n  Column vector: \\(y = \\begin{bmatrix} 1 \\\\ 2 \\\\ 3 \\\\ 4 \\end{bmatrix}\\)\n  or \\(y = \\begin{bmatrix} 1 & 2 & 3 & 4\\end{bmatrix}^{\\top}\\) or\n  \\(y = x^{\\top}\\).\n\n\\begin{verbatim}\ny = [1;2;3;4]\ny = transpose([1 2 3 4])\ny = [1 2 3 4]'\ny = x'\ny = x(:)\n\\end{verbatim}\n\n  Note: \\texttt{\\textquotesingle{}} and \\texttt{.\\textquotesingle{}} are\n  the infix notation for \\texttt{ctrasnpose}, \\texttt{transpose}\n  operation.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Vector: \\texttt{linspace} vs.~\\texttt{colon}}\n\\protect\\hypertarget{vector-linspace-vs.-colon}{}\n\\begin{itemize}[<+->]\n\\item\n  \\texttt{linspace(from,\\ to,\\ n)} generates \\texttt{n} points between\n  \\texttt{from} (inclusive) and \\texttt{to} (inclusive). For example,\n\n  \\texttt{a\\ =\\ linspace(2,\\ 6,\\ 5)\\ \\ \\%\\ same\\ as\\ a\\ =\\ {[}2\\ 3\\ 4\\ 5\\ 6{]}}\n\\item\n  \\texttt{colon(from,\\ step,\\ upper\\_bound)} generates points between\n  \\texttt{from} (inclusive) and \\texttt{upper\\_bound} (may not be\n  inclusive) with spacing \\texttt{step}. For example,\n\n\\begin{verbatim}\na = colon(2, 1, 6)  % same as a = [2 3 4 5 6]\na = colon(2, 2, 6)  % same as a = [2 4 6]\na = colon(2, 1, 7)  % same as a = [2 3 4 5 6 7]\na = colon(2, 2, 7)  % same as a = [2 4 6]\n\\end{verbatim}\n\\item\n  \\texttt{from:step:upper\\_bound} is same as\n  \\texttt{colon(from,\\ step,\\ upper\\_bound)}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Vector: \\texttt{linspace} vs.~\\texttt{colon}}\n\\protect\\hypertarget{vector-linspace-vs.-colon-1}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  \\texttt{linspace(from,\\ to,\\ n)} is equivalent to\n  \\texttt{colon(from,\\ (to\\ -\\ from)\\ /\\ (n\\ -\\ 1),\\ to)}\n\\item\n  \\texttt{colon(from,\\ step,\\ upper\\_bound)} is equivalent to\n  \\texttt{linspace(from,\\ floor((upper\\_bound\\ -\\ from)\\ /\\ step)\\ *\\ step\\ +\\ from,\\ floor((upper\\_bound\\ -\\ from)\\ /\\ step))}\n\\item\n  Use \\texttt{linspace} when the number of points is given.\n\\item\n  Use \\texttt{colon} when the spacing/step size is given.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Matrix: \\texttt{{[}{]}}}\n\\protect\\hypertarget{matrix}{}\nDefine a \\(2 \\times 3\\) matrix\n\\(A = \\begin{bmatrix} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\end{bmatrix}\\)\n\n\\begin{verbatim}\nA = [1,2,3;4,5,6]\n\\end{verbatim}\n\nor\n\n\\begin{verbatim}\nrow1 = [1,2,3]\nrow2 = [4,5,6]\nA = [row1;row2]\n\\end{verbatim}\n\nor\n\n\\begin{verbatim}\ncol1 = [1;4]\ncol2 = [2;5]\ncol3 = [3;6]\nA = [col1,col2,col3]\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{Matrix: \\texttt{zeros}, \\texttt{ones},\n\\texttt{eye}, \\texttt{rand}, \\texttt{randn}, \\texttt{magic}}\n\\protect\\hypertarget{matrix-zeros-ones-eye-rand-randn-magic}{}\n\\begin{itemize}[<+->]\n\\item\n  \\texttt{zeros(m,\\ n)}: define a \\texttt{m}-by-\\texttt{n} matrix with\n  zeros.\n\n\\begin{verbatim}\nzeroRowVec = zeros(5, 1)\nzeroColVec = zeros(1, 5)\nzeroMatrix = zeros(5, 5)\nzeroMatrix = zeros(5)\n\\end{verbatim}\n\\item\n  \\texttt{ones(m,\\ n)}: define a \\texttt{m}-by-\\texttt{n} matrix with\n  ones.\n\\item\n  \\texttt{eye(m,\\ n)}: define a \\texttt{m}-by-\\texttt{n} matrix with\n  diagonals being ones.\n\\item\n  \\texttt{rand(m,\\ n)}: define a \\texttt{m}-by-\\texttt{n} matrix with\n  uniformly distributed numbers.\n\\item\n  \\texttt{randn(m,\\ n)}: define a \\texttt{m}-by-\\texttt{n} matrix with\n  normally distributed numbers.\n\\item\n  \\texttt{magic(n)}: define a \\texttt{n}-by-\\texttt{n} magic square with\n  row sum, column sum and diagonal sum being equal.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Dimension: \\texttt{size}, \\texttt{length},\n\\texttt{reshape}}\n\\protect\\hypertarget{dimension-size-length-reshape}{}\n\\begin{itemize}[<+->]\n\\item\n  \\texttt{size(array)}: size of \\texttt{array}. If \\texttt{array} is\n  \\texttt{n}-dimensional, \\texttt{size} will return a vector of length\n  \\texttt{n}.\n\\item\n  \\texttt{size(array,\\ 1)}: number of rows of \\texttt{array}.\n\\item\n  \\texttt{size(array,\\ 2)}: number of columns of \\texttt{array}.\n\\item\n  \\texttt{length(vec)}: length of vector \\texttt{vec}, equivalent to\n  \\texttt{max(size(vec))}.\n\\item\n  \\texttt{reshape(array,\\ dim1,\\ dim2,\\ dim3,\\ ...)}.\n\n\\begin{verbatim}\nrowVec = 1:8\nmatrix = reshape(rowVec, 2, 4)\n% same as matrix = [1,3,5,7;2,4,6,8]\n\\end{verbatim}\n\\item\n  \\texttt{reshape(array,\\ prod(size(array)),\\ 1)} is same as\n  \\texttt{array(:)}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{\\(N\\)-D array: \\texttt{reshape}}\n\\protect\\hypertarget{n-d-array-reshape}{}\nDefine 3-D array:\n\n\\begin{verbatim}\nrowVec = 1:8\narray = reshape(rowVec, 2, 2, 2);\nlength(size(array))  % check the dimension\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{1-D Array: Slicing}\n\\protect\\hypertarget{d-array-slicing}{}\n\\begin{itemize}[<+->]\n\\item\n  Define a row vector \\texttt{rowVec}:\n\n\\begin{verbatim}\nrowVec = [2,4,6,8,10]\nrowVec = linspace(2,10,5)\nrowVec = colon(2,2,10)    % or rowVec = 2:2:10\n\\end{verbatim}\n\\item\n  \\texttt{array(i)}: the \\texttt{i}-th entry of \\texttt{array}, where\n  \\texttt{i} is called the index:\n\n  \\begin{table}[!hbtp]\n    \\centering\n    \\begin{tabular}{cccccc}\n      \\toprule\n      \\verb|i|         & 1 & 2 & 3 & 4 & 5 \\\\\n      \\midrule\n      \\verb|rowVec(i)| & 2 & 4 & 6 & 8 & 10 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{1-D Array: Slicing}\n\\protect\\hypertarget{d-array-slicing-1}{}\n\\begin{table}[!hbtp]\n  \\centering\n  \\begin{tabular}{cccccc}\n    \\toprule\n    \\verb|i|         & 1 & 2 & 3 & 4 & 5 \\\\\n    \\midrule\n    \\verb|rowVec(i)| & 2 & 4 & 6 & 8 & 10 \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n\\begin{itemize}[<+->]\n\\item\n  Extract one entry from a vector: For example, to extract \\texttt{6}\n  from \\texttt{rowVec} and assign it to \\texttt{x}:\n\n  \\texttt{x\\ =\\ rowVec(3)}\n\\item\n  Extract multiple entries from a vector: For example, to extract\n  \\texttt{2}, \\texttt{6}, \\texttt{8} from \\texttt{rowVec} and assign it\n  to \\texttt{x}:\n\n  \\texttt{x\\ =\\ rowVec({[}1,3,4{]})}\n\\item\n  Extract multiple continguous entries from a vector: For example, to\n  extract \\texttt{4}, \\texttt{6}, \\texttt{8} from \\texttt{rowVec} and\n  assign it to \\texttt{x}:\n\n\\begin{verbatim}\nx = rowVec([2,3,4])\nx = rowVec(2:4)\n\\end{verbatim}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{2-D array: Slicing}\n\\protect\\hypertarget{d-array-slicing-2}{}\n\\begin{itemize}[<+->]\n\\item\n  Define a matrix \\texttt{mat}\n\n\\begin{verbatim}\nmat = reshape(1:8, 2, 4)\n\\end{verbatim}\n\\item\n  \\texttt{array(i,\\ j)}: the entry of \\texttt{array} at row \\texttt{i}\n  and column \\texttt{j}, where \\texttt{i} is colled row index,\n  \\texttt{j} is called column index:\n\n  \\begin{table}[!hbtp]\n    \\centering\n    \\begin{tabular}{c|cccc}\n      \\toprule\n      \\diagbox{\\texttt{i}}{\\texttt{mat(i, j)}}{\\texttt{j}} & 1 & 2 & 3 & 4 \\\\\n      \\hline\n      1 & 1 & 3 & 5 & 7 \\\\\n      2 & 2 & 4 & 6 & 8 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{2-D array: Slicing}\n\\protect\\hypertarget{d-array-slicing-3}{}\n\\begin{table}[!hbtp]\n  \\centering\n  \\begin{tabular}{c|cccc}\n    \\toprule\n    \\diagbox{\\texttt{i}}{\\texttt{mat(i, j)}}{\\texttt{j}} & 1 & 2 & 3 & 4 \\\\\n    \\hline\n    1 & 1 & 3 & 5 & 7 \\\\\n    2 & 2 & 4 & 6 & 8 \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\nExtract multiple rows and multiple columns from \\texttt{mat}: For\nexample, to extract entries at row \\texttt{1}, row \\texttt{2}, and\ncolumn \\texttt{2}, column \\texttt{4}:\n\n\\begin{verbatim}\nA = mat([1,2], [2,4])\nA = mat(1:2, [2,4])\nA = mat(1:end, [2,4])\nA = mat(:, [2,4])\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{Generate a \\(3\\)-D Array using Slicing}\n\\protect\\hypertarget{generate-a-3-d-array-using-slicing}{}\n\\begin{verbatim}\nslice1 = [1,2;3,4]\nslice2 = [5,6;7,8]\nC(:,:,1) = slice1\nC(:,:,2) = slice2\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{Concatenate Arrays}\n\\protect\\hypertarget{concatenate-arrays}{}\n\\begin{verbatim}\nrow1 = [1,2,3]\nrow2 = [4,5,6]\nrowVec = [row1,row2]  % rowVec = [1,2,3,4,5,6]\nmatrix = [row1;row2]  % matrix = [1,2,3;4,5,6]\nmatrix1 = [matrix1;matrix2]\n% same as matrix1 = [1,2,3;4,5,6;1,2,3;4,5,6]\nmatrix2 = [matrix1,matrix2]\n% same as matrix2 = [1,2,3,1,2,3;4,5,6,4,5,6]\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{1-D Array: Append/Delete Element}\n\\protect\\hypertarget{d-array-appenddelete-element}{}\n\\begin{verbatim}\n% 1-D array\nrowVec = 1:5\nrowVec(end + 1) = 6  % append 6 to rowVec\nrowVec = [rowVec,7]  % append 7 to rowVec\nrowVec(5) = []       % delete 5 from rowVec\nrowVec(2:4) = []     % delete 2, 3, 4 from rowVec\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{2-D Array: Append/Delete Element}\n\\protect\\hypertarget{d-array-appenddelete-element-1}{}\n\\begin{verbatim}\n% 2-D array\nmatrix = magic(5)\nmatrix(:, end + 1) = 1:5   % append a column vector\nmatrix = [matrix,[6:10]']  % append a column vector\nmatrix(end + 1, :) = 1:7   % append a row vector\nmatrix = [matrix;8:14]     % append a row vector\nmatrix(:,6) = []           % delete column 2\nmatrix(:,3:5) = []         % delete column 3, 4, 5\nmatrix(2:4,:) = []         % delete row 2, 3, 4\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{Char Array vs.~String Array}\n\\protect\\hypertarget{char-array-vs.-string-array}{}\n\\begin{verbatim}\nstr = \"abc\"\narrayOfChars1 = 'abc'\narrayOfChars2 = ['a','b','c']\narrayOfChars1 == arrayOfChars2 % return logical 1 (true)\narrayOfChars1 == str           % return logical 1 (true)\nclass(str)                     % string\nclass(arrayOfChars1)           % char\n[arrayOfChars1,arrayOfChars2]  % return 'abcabc'\n[arrayOfChars1;arrayOfChars2]  % return ['abc';'abc']\n[str,str]                      % return [\"abc\",\"abc\"]\n[str;str]                      % return [\"abc\";\"abc\"]\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}[fragile]{Cell Array: array of elements of different types}\n\\protect\\hypertarget{cell-array-array-of-elements-of-different-types}{}\n\\begin{itemize}[<+->]\n\\item\n  \\texttt{cell(n)}: create 1-D cell array of length \\texttt{n}\n\\item\n  \\texttt{cell(m,n)}: create 2-D cell array of size \\texttt{m} by\n  \\texttt{n}\n\\item\n  Create a cell array of types \\texttt{char}, \\texttt{string},\n  \\texttt{double}:\n\n\\begin{verbatim}\ncellArray = {[1,2,3], \"abc\", 'def'}\ncellArray{1}          % return [1,2,3]\ncellArray{2}          % return \"abc\"\ncellArray{3}          % return 'def'\ncellArray{4} = 'ghi'\ncellArray{4}          % return 'ghi'\n\\end{verbatim}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Array Operations: 1-D Array}\n\\protect\\hypertarget{array-operations-1-d-array}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  \\texttt{sum(vec)}/\\texttt{prod(vec)}: sum/product of all elements of\n  \\texttt{vec}.\n\\item\n  \\texttt{max(vec)}/\\texttt{min(vec)}: maximum/minimum of \\texttt{vec}.\n\\item\n  \\texttt{rowVec\\ =\\ rowVec1\\ .*\\ rowVec2}: elementwise multiplication,\n  where \\texttt{rowVec(i)\\ =\\ rowVec1(i)\\ *\\ rowVec2(i)}.\n\\item\n  \\texttt{rowVec\\ .*\\ colVec}: Kronecker product. If \\texttt{rowVec} has\n  length \\texttt{m} and \\texttt{colVec} has length \\texttt{n}, then the\n  resulting matrix is \\texttt{m}-by-\\texttt{n}.\n\\item\n  \\texttt{dot(vec1,\\ vec2)}: dot product of \\texttt{vec1} and\n  \\texttt{vec2}, \\texttt{vec1} and \\texttt{vec2} must be of the same\n  length.\n\\item\n  \\texttt{sum(rowVec1\\ .*\\ rowVec2)}: \\texttt{dot(rowVec1,\\ rowVec2)}.\n\\item\n  \\texttt{rowVec1\\ *\\ rowVec2\\textquotesingle{}}:\n  \\texttt{dot(rowVec1,\\ rowVec2)}.\n\\item\n  \\texttt{indices\\ =\\ find(vec\\ \\textgreater{}\\ n)}: find indices of\n  elements greater than \\texttt{n} in \\texttt{vec}. Note:\n  \\texttt{\\textgreater{}} can also be \\texttt{\\textless{}}, \\texttt{==}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Array Operations: 2-D Array}\n\\protect\\hypertarget{array-operations-2-d-array}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  \\texttt{mat\\ =\\ mat1\\ .*\\ mat2}: elementwise multiplication, where\n  \\texttt{mat(i,\\ j)\\ =\\ mat1(i,\\ j)\\ *\\ mat2(i,\\ j)}.\n\\item\n  \\texttt{mat\\ =\\ mat1\\ *\\ mat2}: matrix multiplication, where\n  \\texttt{mat1} is \\texttt{m}-by-\\texttt{p}, \\texttt{mat2} is\n  \\texttt{p}-by-\\texttt{n}, and \\texttt{mat} is\n  \\texttt{m}-by-\\texttt{n}.\n\\item\n  \\texttt{sum/prod(mat,\\ \\textquotesingle{}all\\textquotesingle{})}:\n  sum/product of all elements of \\texttt{mat}.\n\\item\n  \\texttt{sum/prod(mat,\\ 1)}: column sums/products.\n\\item\n  \\texttt{sum/prod(mat,\\ 2)}: row sums/products.\n\\item\n  \\texttt{max/min(mat,\\ {[}{]},\\ \\textquotesingle{}all\\textquotesingle{})}:\n  maximum/minimum of \\texttt{mat}.\n\\item\n  \\texttt{max/min(mat,\\ {[}{]},\\ 1)}: column maximums/minimums.\n\\item\n  \\texttt{max/min(mat,\\ {[}{]},\\ 2)}: row maximums/minimums.\n\\item\n  \\texttt{{[}row,\\ col{]}\\ =\\ find(mat\\ \\textgreater{}\\ n)}: find\n  indices of elements greater than \\texttt{n} in \\texttt{mat},\n  \\texttt{row}/\\texttt{col} stores row/column indices.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Array Operations: 2-D Array}\n\\protect\\hypertarget{array-operations-2-d-array-1}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  \\texttt{{[}V,\\ D{]}\\ =\\ eig(mat)}: \\texttt{V(:,\\ i)} and\n  \\texttt{D(i,\\ i)} are the \\texttt{i}-th eigenvector and eigenvalue of\n  \\texttt{mat}.\n\\item\n  \\texttt{d\\ =\\ diag(mat,\\ k)}: extract \\texttt{k}-th diagonal elements\n  that is above (\\texttt{k\\ \\textgreater{}\\ 0}) / below\n  (\\texttt{k\\ \\textless{}\\ 0}) the main diagonal.\n\\item\n  \\texttt{mat\\ =\\ diag(d,\\ k)}: construct a matrix with \\texttt{k}-th\n  diagonal elements being \\texttt{d}.\n\\item\n  \\texttt{mat\\ =\\ diag(diag(mat,\\ k))}: set elements to zero except the\n  \\texttt{k}-th diagonal elements.\n\\item\n  \\texttt{fliplr(mat)}: flip \\texttt{mat} in left/right direction.\n\\item\n  \\texttt{flipud(mat)}: flip \\texttt{mat} in up/down direction.\n\\item\n  \\texttt{rot90(mat,\\ k)}: rotate \\texttt{mat} \\texttt{k\\ *\\ 90}\n  degrees.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Application: Image Processing}\n\\protect\\hypertarget{application-image-processing}{}\n\\begin{itemize}[<+->]\n\\item\n  A grayscale image is a 2-D array of pixels, each pixel has a integer\n  value that represent depth of color.\n\\item\n  A colored image is a 3-D array of pixels with RGB channels, each\n  channel is a 2-D array.\n\\item\n  \\texttt{img\\ =\\ imread(filename)}: read image from graphics file\n  \\texttt{filename} and assign it \\texttt{img}.\n\\item\n  \\texttt{imshow(img)}: display image \\texttt{img} in handle graphics\n  figure.\n\\item\n  \\texttt{imwrite(img,\\ filename)}: write image \\texttt{img} to graphics\n  file named \\texttt{filename}.\n\n\\begin{verbatim}\nuw = imread('UW.png');\nuwFlipud = flipud(uw);\nimshow(uwFlipud);\nimwrite(uwFlipud, 'UW_flipud.png');\n\\end{verbatim}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Summary}\n\\protect\\hypertarget{summary}{}\n\\begin{table}[!hbtp]\n  \\begin{tabular}{rl}\n    Command                          & Description \\\\\n    \\hline\n    \\texttt{transpose} or \\texttt{'} & Non-conjugate transpose of a vector \\\\\n    \\texttt{linspace}                & Linearly spaced vector \\\\\n    \\texttt{logspace}                & Logarithmically spaced vector \\\\\n    \\texttt{colon} or \\texttt{:}     & Colon \\\\\n    \\texttt{zeros}                   & Zeros array \\\\\n    \\texttt{ones}                    & Ones array \\\\\n    \\texttt{eye}                     & Identity matrix \\\\\n    \\texttt{rand}                    & Uniformly distributed pseudorandom numbers \\\\\n    \\texttt{randn}                   & Normally distributed pseudorandom numbers \\\\\n    \\texttt{magic}                   & Magic square \\\\\n    \\texttt{size}                    & Size of array \\\\\n    \\texttt{length}                  & Length of vector \\\\\n    \\texttt{reshape}                 & Reshape array \\\\\n  \\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\begin{frame}{Summary}\n\\protect\\hypertarget{summary-1}{}\n\\begin{table}[!hbtp]\n  \\begin{tabular}{rl}\n    Command                          & Description \\\\\n    \\hline\n    \\texttt{diag}                    & Diagonal matrices and diagonals of a matrix \\\\\n    \\texttt{cell}                    & Create cell array \\\\\n    \\texttt{sum}/\\texttt{prod}       & Sum/Product of elements \\\\\n    \\texttt{min}/\\texttt{max}        & Minimum/Maximum of elements \\\\\n    \\texttt{dot}                     & Vector dot product \\\\\n    \\texttt{find}                    & Find indices of nonzero elements \\\\\n    \\texttt{eig}                     & Find eigenvalues and eigenvectors \\\\\n    \\texttt{diag}                    & Diagonal matrices and diagonals of a matrix \\\\\n    \\texttt{fliplr}/\\texttt{flipud}  & Flip an array \\\\\n    \\texttt{rot90}                   & Rotate an array 90 degrees \\\\\n    \\texttt{imread}/\\texttt{imwrite} & Read/Write image from graphics file \\\\\n    \\texttt{imshow}                  & display image in Handle Graphics figure \\\\\n    \\texttt{uint8}                   & Convert to unsigned 8-bit integer \\\\\n  \\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\begin{frame}{Additional Commands}\n\\protect\\hypertarget{additional-commands}{}\n\\begin{table}[!hbtp]\n  \\begin{tabular}{rl}\n    Command            & Description \\\\\n    \\hline\n    \\texttt{iskeyword} & Check if input is a keyword \\\\\n    \\texttt{who}       & List current variables \\\\\n    \\texttt{whos}      & List current variables, long form \\\\\n    \\texttt{which}     & Locate functions and files \\\\\n    \\texttt{clear}     & Clear variables and functions from memory \\\\\n    \\texttt{clc}       & Clear command window \\\\\n    \\texttt{clf}       & Clear current figure \\\\\n    \\texttt{close}     & Close figure \\\\\n    \\texttt{exist}     & Check existence of variable/script/function/folder/class \\\\\n    \\texttt{disp}      & Display array \\\\\n  \\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\hypertarget{script-files}{%\n\\subsection{Script Files}\\label{script-files}}\n\n\\begin{frame}{}\n\\protect\\hypertarget{section-1}{}\nA script file is simply a file that contains a chain of commands that\nyou edit in a separate window, then execute with a single mouse click or\ncommand. This is where we can define variables, perform calculations and\nleave comments to remind us what the file calculates.\n\\end{frame}\n\n\\begin{frame}{File Naming Conventions}\n\\protect\\hypertarget{file-naming-conventions}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  Start with a letter, followed by letters or numbers or underscore,\n  maximum 63 characters (excluding the .m extension), and must not be\n  the same as any MATLAB reserved word.\n\\item\n  None of the conventions matter to MATLAB itself: they only matter to\n  the people writing the code, and the people maintaining the code\n  (usually a much harder task), and to the people paying for the code\n  (you'd be amazed how much gets written into contract specifications.)\n\\item\n  Reference:\n  \\url{https://www.mathworks.com/matlabcentral/answers/30223-what-are-the-rules-for-naming-script-files}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Put Comments to Your Script File}\n\\protect\\hypertarget{put-comments-to-your-script-file}{}\n\\begin{verbatim}\n% MATH 3341, Semester Year\n% Lab 02: Variables, Arrays, and Scripts\n% Author: first_name last_name\n% Date: mm/dd/yyyy\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}{Useful MATLAB Shortcuts}\n\\protect\\hypertarget{useful-matlab-shortcuts}{}\n\\begin{itemize}[<+->]\n\\tightlist\n\\item\n  Windows shortcuts\n\n  \\begin{itemize}[<+->]\n  \\tightlist\n  \\item\n    Press \\fbox{\\texttt{Ctrl}} + \\fbox{\\texttt{A}} to select all\n  \\item\n    Press \\fbox{\\texttt{Ctrl}} + \\fbox{\\texttt{I}} to adjust indentation\n  \\item\n    Press \\fbox{\\texttt{Ctrl}} + \\fbox{\\texttt{R}} to comment\n  \\item\n    Press \\fbox{\\texttt{Ctrl}} + \\fbox{\\texttt{T}} to uncomment\n  \\end{itemize}\n\\item\n  macOS shortcuts\n\n  \\begin{itemize}[<+->]\n  \\tightlist\n  \\item\n    Press \\fbox{\\texttt{command}} + \\fbox{\\texttt{A}} to select all\n  \\item\n    Press \\fbox{\\texttt{command}} + \\fbox{\\texttt{I}} to adjust\n    indentation\n  \\item\n    Press \\fbox{\\texttt{command}} + \\fbox{\\texttt{/}} to comment\n  \\item\n    Press \\fbox{\\texttt{command}} + \\fbox{\\texttt{T}} to uncomment\n  \\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\hypertarget{primer}{%\n\\subsection{\\texorpdfstring{\\LaTeX~Primer}{~Primer}}\\label{primer}}\n\n\\begin{frame}[fragile]{\\texttt{table} Environment}\n\\protect\\hypertarget{table-environment}{}\n\\begin{verbatim}\n\\begin{table}[!hbtp]\n  \\caption{This is a table}\n  \\begin{tabular}{rcl}\n  \\toprule\n  Column 1 & Column 2 & Column 3 \\\\\n  \\midrule\n  1        & 1        & 1        \\\\\n  12       & 12       & 12       \\\\\n  123      & 123      & 123      \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}{\\texttt{table} Environment}\n\\protect\\hypertarget{table-environment-1}{}\n\\begin{table}[!hbtp]\n  \\caption{This is a table}\n  \\begin{tabular}{rcl}\n  \\toprule\n  Column 1 & Column 2 & Column 3 \\\\\n  \\midrule\n  1        & 1        & 1        \\\\\n  12       & 12       & 12       \\\\\n  123      & 123      & 123      \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\begin{frame}[fragile]{\\texttt{figure} Environment}\n\\protect\\hypertarget{figure-environment}{}\n\\begin{verbatim}\n\\begin{figure}[!hbtp]\n  \\centering\n  \\includegraphics[height=0.3\\textheight]{figure.pdf}\n  \\caption{Plot of $\\sin{x}$}\n  \\label{fig:sin}\n\\end{figure}\n\\end{verbatim}\n\ngenerates\n\n\\begin{figure}[!hbtp]\n  \\centering\n  \\includegraphics[height=0.3\\textheight]{figure.pdf}\n  \\caption{Plot of $\\sin{x}$}\n  \\label{fig:sin}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}[fragile]{\\texttt{\\textbackslash{}left} and\n\\texttt{\\textbackslash{}right} vs.~\\texttt{\\textbackslash{}big},\n\\texttt{\\textbackslash{}Big}, \\texttt{\\textbackslash{}Bigg}}\n\\protect\\hypertarget{left-and-right-vs.-big-big-bigg}{}\n\\begin{verbatim}\n\\begin{align*}\n\\|x\\|_2 & = \\big(\\sum_{i = 1}^{n} x_i^2 \\big)^{1/2},\n\\|x\\|_2 = \\Big(\\sum_{i = 1}^{n} x_i^2 \\Big)^{1/2}, \\\\\n\\|x\\|_2 & = \\Bigg(\\sum_{i = 1}^{n} x_i^2 \\Bigg)^{1/2},\n\\|x\\|_2 = \\left(\\sum_{i = 1}^{n} x_i^2 \\right)^{1/2}.\n\\end{align*}\n\\end{verbatim}\n\ngenerates \\begin{align*}\n\\|x\\|_2 & = \\big(\\sum_{i = 1}^{n} x_i^2 \\big)^{1/2},\n\\|x\\|_2 = \\Big(\\sum_{i = 1}^{n} x_i^2 \\Big)^{1/2}, \\\\\n\\|x\\|_2 & = \\Bigg(\\sum_{i = 1}^{n} x_i^2 \\Bigg)^{1/2},\n\\|x\\|_2 = \\left(\\sum_{i = 1}^{n} x_i^2 \\right)^{1/2}.\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]{Links}\n\\protect\\hypertarget{links}{}\n\\begin{verbatim}\n\\href{https://www.google.com}{Google}\n\\end{verbatim}\n\n\\href{https://www.google.com}{Google}\n\nOr simply\n\n\\begin{verbatim}\n\\url{https://www.google.com}\n\\end{verbatim}\n\n\\url{https://www.google.com}\n\\end{frame}\n\n\\begin{frame}[fragile]{\\texttt{case} Environment}\n\\protect\\hypertarget{case-environment}{}\n\\begin{verbatim}\n$$\nf(x) =\n\\begin{cases}\n5 x + 4   & \\text{if~} x \\leq 1, \\\\\n3 x^2 + 6 & \\text{if~} x > 1\n\\end{cases}\n$$\n\\end{verbatim}\n\ngenerates \\[\nf(x) =\n\\begin{cases}\n5 x + 4   & \\text{if~} x \\leq 1, \\\\\n3 x^2 + 6 & \\text{if~} x > 1\n\\end{cases}\n\\]\n\\end{frame}\n\n\\begin{frame}[fragile]{Cross-Reference}\n\\protect\\hypertarget{cross-reference}{}\n\\begin{verbatim}\n\\begin{equation}\n\\label{eq:ls}\nA \\mathbf{x} = \\mathbf{b}.\n\\end{equation}\n\nThe expression \\eqref{eq:ls} is a linear system.\n\\end{verbatim}\n\ngenerates\n\n\\begin{equation}\n\\label{eq:ls}\nA \\mathbf{x} = \\mathbf{b}.\n\\end{equation}\n\nThe expression \\eqref{eq:ls} is a linear system.\n\\end{frame}\n\n\\begin{frame}[fragile]{Cross-Reference}\n\\protect\\hypertarget{cross-reference-1}{}\n\\begin{verbatim}\n\\begin{table}[!hbtp]\n\\caption{$y = 2x$}\n\\label{tab:xy}\n  \\begin{tabular}{cc}\n  \\toprule\n  $x$ & $y$ \\\\\n  \\midrule\n  $6$ & $12$ \\\\\n  $7$ & $14$ \\\\\n  $8$ & $16$ \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\nTable \\ref{tab:xy} gives the result of $y = 2x$.\n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}{Cross-Reference}\n\\protect\\hypertarget{cross-reference-2}{}\n\\begin{table}[!hbtp]\n\\caption{$y = 2x$}\n\\label{tab:xy}\n  \\begin{tabular}{cc}\n  \\toprule\n  $x$ & $y$ \\\\\n  \\midrule\n  $6$ & $12$ \\\\\n  $7$ & $14$ \\\\\n  $8$ & $16$ \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\n\nTable \\ref{tab:xy} gives the result of \\(y = 2x\\).\n\\end{frame}\n", "meta": {"hexsha": "4245b3f214846bba9d0737bb0753401661fe1d51", "size": 26789, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "courses/template/MATH3341/Math.3341.Lab.02/slides/body.tex", "max_stars_repo_name": "butlerm0405/math3341", "max_stars_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "courses/template/MATH3341/Math.3341.Lab.02/slides/body.tex", "max_issues_repo_name": "butlerm0405/math3341", "max_issues_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "courses/template/MATH3341/Math.3341.Lab.02/slides/body.tex", "max_forks_repo_name": "butlerm0405/math3341", "max_forks_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0238353196, "max_line_length": 127, "alphanum_fraction": 0.6457874501, "num_tokens": 9431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.8459424295406088, "lm_q1q2_score": 0.43948512929030237}}
{"text": "\\documentclass[english]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin1]{inputenc}\n\\usepackage{geometry}\n\\geometry{verbose,letterpaper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}\n\\usepackage{amsmath}\n\n\\makeatletter\n\\usepackage{babel}\n\\makeatother\n\\begin{document}\n\n\\section{FEM model}\n\n\\begin{quote}\nThe problem is\n\n\\begin{align*}\n\\Delta\\bar{p}-\\frac{1}{c_{0}^{2}}\\frac{\\partial^{2}\\bar{p}}{\\partial^{2}t} & =f\\end{align*}\n\n\nwith initial condition \n\n\\begin{eqnarray*}\n\\bar{p}(0,\\mathbf{r}) & = & b(r)\\end{eqnarray*}\n\n\nLet \n\n\\begin{eqnarray*}\nv & = & \\frac{\\partial\\bar{p}}{\\partial t}\\end{eqnarray*}\n\n\nthen we have\n\n\\begin{alignat*}{1}\n\\bar{p}_{t}-v & =0\\\\\n\\Delta\\bar{p}-\\frac{1}{c_{0}^{2}}\\, v_{t} & =f\\end{alignat*}\n\n\nand absorbing boundary condition \n\n\\begin{eqnarray*}\n\\frac{\\partial\\bar{p}}{\\partial\\mathbf{n}} & =- & \\frac{1}{c_{0}}\\frac{\\partial\\bar{p}}{\\partial t}\\end{eqnarray*}\n\n\n$\\frac{\\partial\\bar{p}}{\\partial\\mathbf{n}}$ is the normal derivative\nat the boundary. This is a the time-varying FEM model. by discretizing\naccording to $t$, we have\n\n\\begin{eqnarray*}\n(\\frac{\\bar{p}^{n}-\\bar{p}^{n-1}}{\\delta t},\\phi)_{\\Omega}-\\,(\\theta v^{n}+(1-\\theta)v^{n-1},\\phi)_{\\Omega} & = & 0\\\\\n-(\\Delta((\\theta\\bar{p}^{n}+(1-\\theta)\\bar{p}^{n-1}),\\bigtriangledown\\phi)_{\\Omega}-\\frac{1}{c_{0}}(\\frac{\\bar{p}^{n}-\\bar{p}^{n-1}}{\\delta t},\\phi)_{\\partial\\Omega}-\\frac{1}{c_{0}^{2}}(\\frac{v^{n}-v^{n-1}}{\\delta t},\\phi)_{\\Omega} & = & (\\theta f^{n}+(1-\\theta)f^{n-1},\\phi)_{\\Omega}\\end{eqnarray*}\n\n\nwe obtain\n\n\\begin{eqnarray*}\nM\\bar{p}^{n}-(\\delta t\\,\\theta)Mv^{n} & = & M\\bar{p}^{n-1}+\\delta t\\,(1-\\theta)\\, M\\, v^{n-1}\\\\\n(-c_{0}^{2}\\,\\delta t\\,\\theta A-c_{0}\\, B)\\bar{p}^{n}-Mv^{n} & = & (c_{0}^{2}\\,\\delta t\\,(1-\\theta)A-c_{0}B)\\bar{p}^{n-1}-M\\, v^{n-1}+c_{0}^{2}\\delta t(\\theta F^{n}+(1-\\theta)F^{n-1})\\end{eqnarray*}\n\n\nWrite the above two equations as a matrix form\n\n\\begin{eqnarray*}\n\\left(\\begin{array}{cc}\nM & -(\\delta t\\,\\theta)M\\\\\nc_{0}^{2}\\,\\delta t\\,\\theta A+c_{0}\\, B & M\\end{array}\\right)\\left(\\begin{array}{c}\n\\bar{p}^{n}\\\\\nv^{n}\\end{array}\\right) & = & \\left(\\begin{array}{c}\nG_{1}\\\\\nG_{2}\\end{array}\\right)\\end{eqnarray*}\n\n\nwhere \n\n\\begin{center}$\\left(\\begin{array}{c}\nG_{1}\\\\\nG_{2}\\end{array}\\right)=\\left(\\begin{array}{c}\nM\\bar{p}^{n-1}+\\delta t\\,(1-\\theta)Mv^{n-1}\\\\\n(-c_{0}^{2}\\,\\delta t\\,(1-\\theta)A+c_{0}B)\\bar{p}^{n-1}+M\\, v^{n-1}-c_{0}^{2}\\delta t(\\theta F^{n}+(1-\\theta)F^{n-1})\\end{array}\\right)$\\end{center}\n\nFrom the above matrix, we can obtain\n\n\\begin{eqnarray*}\n(M+(\\delta t\\,\\theta\\, c_{0})^{2}A+c_{0}\\,\\delta t\\,\\theta\\, B)\\bar{p}^{n} & = & G_{1}+(\\delta t\\,\\theta)G_{2}\\\\\nMv^{n} & = & -(c_{0}^{2}\\,\\delta t\\,\\theta\\, A+c_{0}B)\\bar{p}^{n}+G_{2}\\end{eqnarray*}\n\n\\end{quote}\n\n\\end{document}\n", "meta": {"hexsha": "23b3609b1a6d9d4d254fd1668666f21b3bb7db5d", "size": 2731, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MHD/examples/step-24/doc/project-1.tex", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/examples/step-24/doc/project-1.tex", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/examples/step-24/doc/project-1.tex", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 29.6847826087, "max_line_length": 299, "alphanum_fraction": 0.6012449652, "num_tokens": 1219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949467848392, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4394438331248143}}
{"text": "\\documentclass{article}\n\\usepackage{amsfonts}\n\\usepackage{mathtools}\n\\usepackage{amsthm}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\usepackage{proof}\n\\usepackage{cite}\n\\usepackage{hyperref}\n\n\\begin{document}\n\n\\title{CS292C Final Project proof of type soundness}\n\\author{Daniel Zhang}\n\\maketitle\n\n\\section{Introduction}\n\nFor this project I've decided to prove type soundness for and implement the Calculus of Constructions. Extensions of the Calculus of Constructions are used in Coq and Agda \\cite{Casinghino10}, so understanding it will help with understanding those systems. I will not be describing extensions such as inductive types or universes.\n\nThe Calculus of Constructions is a Pure Type System. Pure Type Systems have a set of sorts. The Calculus of Constructions has three sorts: terms, types and kinds (the type of types).\n\n$\\star$ is a constant of sort kind. Note that it is not the only kind. $\\star\\rightarrow\\star$ is a different kind. This corresponds to the type of a type constructor: a function that takes in a type and outputs a type.\n\nThe notation $\\lambda x:A.B$ is used both for a function that takes in a term and a function that takes in a type.\n$\\Pi x:A.B$ is a dependent product. If $x$ does not occur in $B$, it is the same as $A\\rightarrow B$. When $A$ is $\\star$, it is equivalent to a universal type. \\cite{Jones97}\n\nAn example of a term would be $\\lambda T:*.(\\lambda x:T.x)$. Types include expressions such as $\\lambda x:\\star.x$ and $\\Pi x:\\star.x$. An example of a kind would be $\\Pi x:\\star.\\star$.\n\nThe Calculus of Constructions is the most powerful system in the Lambda Cube. Both types and terms can depend on types and terms.\nThe Calculus of Constructions is known to be strongly-normalizing, but the proof is considered difficult \\cite{Casinghino10}.\n\n\\section{Syntax}\n\nExpressions are considered equivalent up to $\\alpha$-conversion.\nVariables names are assumed to all be distinct (implementation uses de Bruijn indices, so substitution doesn't cause issues).\n\n\n\\[k\\in \\text{Const} \\rightarrow \\star \\mid \\square\\]\n\\[e\\in \\text{Exp}\\rightarrow k\\in \\text{Const} \\mid x\\in \\text{Variable} \\mid A B \\mid \\lambda x:A.B \\mid \\Pi x:A.B\\]\nThis is the syntax for both terms and types.\n\n\\[v\\in \\text{Values}\\rightarrow k\\in \\text{Const} \\mid x\\in \\text{Variable} \\mid \\lambda x:A.B \\mid \\Pi x: A. B\\]\nwhere $A,B\\in\\text{Values}$.\n\\section{Semantics}\n\nThese rules are from \\cite{Casinghino10}, modifed to be deterministic.\n\n\\[\\infer[(LAM1)]{(\\lambda x:A.B)\\rightarrow (\\lambda x:A'.B)}{A\\rightarrow A'}\\]\n\\[\\infer[\\text{if $A\\in\\text{Values}$}(LAM2)]{(\\lambda x:A.B)\\rightarrow (\\lambda x:A.B')}{B\\rightarrow B'}\\]\n\\[\\infer[(PI1)]{(\\Pi x:A.B)\\rightarrow (\\Pi x:A'.B)}{A\\rightarrow A'}\\]\n\\[\\infer[\\text{if $A\\in\\text{Values}$}(PI2)]{(\\Pi x:A.B)\\rightarrow (\\Pi x:A.B')}{B\\rightarrow B'}\\]\n\\[\\infer[\\text{if APP3 cannot apply}(APP1)]{A B\\rightarrow A' B}{A\\rightarrow A'}\\]\n\\[\\infer[\\text{if $A\\in \\text{Values}$ and APP3 cannot apply}(APP2)]{A B\\rightarrow A B'}{B\\rightarrow B'}\\]\n\\[\\infer[(APP3)]{(\\lambda x:A.B) C\\rightarrow B[x\\mapsto C]}{}\\]\n\n\\section{Substitution}\n\n\\[k[x\\mapsto D]=k\\]\n\\[\ny[x\\mapsto D]=\n\\begin{cases}\n  D & \\text{if $x=y$}\\\\\n  y & \\text{if $x\\ne y$}\n\\end{cases}\n\\]\n\\[(A B)[x\\mapsto D]=A[x\\mapsto D] B[x\\mapsto D]\\]\n\\[(\\lambda y:A.B)[x\\mapsto D]=\\lambda y:A[x\\mapsto D].B[x\\mapsto D]\\]\n\\[(\\Pi y:A.B)[x\\mapsto D]=\\Pi y:A[x\\mapsto D].B[x\\mapsto D]\\]\n\n\\[(\\Gamma,y:B)[x\\mapsto D]=\\Gamma[x\\mapsto D],y:B[x\\mapsto D]\\]\n\n\\section{Typing rules}\n\n\\[\\infer[(STAR)]{\\vdash\\star:\\square}{}\\]\n\\[\\infer[(VAR)]{\\Gamma,x:A\\vdash x:A}{\\Gamma\\vdash A:s}\\]\n\\[\\infer[(WEAK)]{\\Gamma,x:A\\vdash B:C}{\\Gamma\\vdash B:C & \\Gamma\\vdash A:s}\\]\n\\[\\infer[(APP)]{\\Gamma\\vdash f a:B[x\\mapsto a]}{\\Gamma\\vdash f:(\\Pi x:A.B) & \\Gamma\\vdash a:A}\\]\n\\[\\infer[(LAM)]{\\Gamma\\vdash(\\lambda x:A.b):(\\Pi x:A.B)}{\\Gamma,x:A\\vdash b:B & \\Gamma\\vdash(\\Pi x:A.B):t}\\]\n\\[\\infer[(PI)]{\\Gamma\\vdash(\\Pi x:A.B):t}{\\Gamma\\vdash A:s & \\Gamma,x:A\\vdash B:t & s,t\\in\\{\\star,\\square\\}}\\]\n\\[\\infer[(CONV)]{\\Gamma\\vdash a:B}{\\Gamma\\vdash a:A & \\Gamma\\vdash B:s & A=_\\beta B}\\]\n\n\\[\\infer[(=_\\beta LAM)]{(\\lambda x:A.B)C=_\\beta B[x\\mapsto C]}{}\\]\nand its symmetric transitive closure.\n\nThese rules are taken from \\cite{Jones97} with some modifications. The notation for substitution was changed to match what was used in this class. The version in the paper had a relation on $s$ and $t$ in rule (PI) to restrict to other type systems in the Lambda Cube. The eight systems of the Lambda Cube correspond to all choices of pairs of valid $(s,t)$ in rule PI, where $(\\star,\\star)$ must be taken. The Calculus of Constructions allows all pairs of sorts on $\\{\\star,\\square\\}$.\n\n\\section{Proof of progress}\n\n\\begin{lemma}\n  Let $e$ be a value.\n  If $\\Gamma\\vdash e:\\Pi x:A.B$, then $e=(\\lambda x:C.D)$.\n\\end{lemma}\n\n\\begin{proof}\n  Since $e$ is a value, it must either be of the form $\\lambda x:C.D$ or $\\Pi x:C.D$. Let $T$ the last type before trailing applications of CONV or WEAK: $\\Gamma'\\vdash e:T$ and $T=_\\beta \\Pi x.A:B$. If $e=\\Pi x:C.D$, then $T\\in\\{\\star,\\square\\}$ since $PI$ is the only rule that could be applied based on the form of $e$. But since neither of $\\star$ or $\\square$ is $\\beta$-equivalent to $\\Pi x:C.D$, this is a contradiction. Therefore, $e=\\lambda x:C.D$.\n\n\\end{proof}\n  \n\\begin{theorem}\n  $(\\forall e \\in Exp)(\\vdash e:\\tau)\\Rightarrow(e \\in Values\\vee(\\exists e'\\in Exp)(e\\rightarrow e'))$\n\\end{theorem}\n\n\\begin{proof}\n  Use structural induction on $e$:\n  \n  Case $e\\in Const$: $e\\in Values$\n\n  Case $e\\in Variable$: A variable can only have a type if it is in the context. Since we are in the empty context, a variable cannot be well-typed. Thus, this case cannot happen.\n\n  Case $e=A B$: \n  \\begin{itemize}\n  \\item If $A$ is not a value, then $A\\rightarrow A'$ by the inductive hypothesis. $e\\rightarrow e'$ where $e'=A' B$ (rule APP1).\n  \\item If $A$ is a value but $B$ is not a value, then $B\\rightarrow B'$ by the inductive hypothesis. Thus, $e\\rightarrow e'$ where $e'=A B'$ (rule APP2).\n  \\item If $A$ and $B$ are both values: After removing trailing application of CONV from the typing derivation for $\\tau$, we get $A B=\\tau'$ where $\\tau=_\\beta \\tau'$. The last rule used in the typing derivation for $\\tau'$ is not CONV, so it must be APP. Thus, $A:\\Pi x: C.D$. Then by Lemma 1, $A=(\\lambda x:\\tau.e_3)$, so $e=(\\lambda x:\\tau.e_3)B$. Finally, $e\\rightarrow e'$ where $e'=e_3[x\\mapsto B]$ (rule APP3).\n  \\end{itemize}\n  \n  Case $e=(\\lambda x:A.B)$: If $A$ is not a value, then $A\\rightarrow A'$ by the inductive hypothesis. $e\\rightarrow e'$ where $e'=(\\lambda x:A'.B)$. Otherwise, if $B$ is not a value, then $B\\rightarrow B'$ by the inductive hypothesis. $e\\rightarrow e'$ where $e'=(\\lambda x:A.B')$. If both $A$ and $B$ are values, then $e\\in Values$.\n  \n  Case $e=(\\Pi x:A.B)$: If $A$ is not a value, then $A\\rightarrow A'$ by the inductive hypothesis. $e\\rightarrow e'$ where $e'=(\\Pi x:A'.B)$. Otherwise, if $B$ is not a value, then $B\\rightarrow B'$ by the inductive hypothesis. $e\\rightarrow e'$ where $e'=(\\Pi x:A.B')$. If both $A$ and $B$ are values, then $e\\in Values$.\n\n  This exhausts all the cases, so the theorem is true by induction.\n  \n\\end{proof}\n\n\\section{Proof of preservation}\n\nCompared to simply-typed lambda calculus, a major differences in the proving the Substitution Lemma is the type of a variable can depend on the value of another variable. This means order of variables in the context matters. Also, we must use the version of substitution that allows substituting arbitrary terms because rule APP requires it.\n\n\\begin{lemma}[Substitution Lemma for Terms]\n  If $y$ is fresh in $D$,\n  \\[e[x\\mapsto D][y\\mapsto C[x\\mapsto D]]=e[y\\mapsto C][x\\mapsto D]\\]\n\\end{lemma}\n\\begin{proof}\n  The proof is by induction on the structure of $e$.\n  \n  Case $e=k$: $k[x\\mapsto D][y\\mapsto C[x\\mapsto D]]=k=k[y\\mapsto C][x\\mapsto D]$, as desired.\n\n  Case $e=A B$:\n  \\begin{align*}\n    (A B)[x\\mapsto D][y\\mapsto C[x\\mapsto D]]&=A[x\\mapsto D][y\\mapsto C[x\\mapsto D]]B[x\\mapsto D][y\\mapsto C[x\\mapsto D]]\\\\\n    &=A[y\\mapsto C][x\\mapsto D]B[y\\mapsto C][x\\mapsto D]\\\\\n    &=(A B)[y\\mapsto C][x\\mapsto D]\n  \\end{align*}\n  Using the inductive hypothesis on $A$ and $B$.\n  \n  Case $e=(\\lambda x:A.B)$: identical to $A B$.\n  \n  Case $e=(\\Pi x:A.B)$: identical to $A B$.\n\n  Case $e=x$:\n  \\begin{align*}\n    x[x\\mapsto D][y\\mapsto C[x\\mapsto D]]&=D[y\\mapsto C[x\\mapsto D]]\\\\\n    &=D\\\\\n    &=x[x\\mapsto D]\\\\\n    &=x[y\\mapsto C][x\\mapsto D]\n  \\end{align*}\n  \n  Case $e=y$ where $y\\ne x$:\n  \\begin{align*}\n    y[x\\mapsto D][y\\mapsto C[x\\mapsto D]]&=y[y\\mapsto C[x\\mapsto D]]\\\\\n    &=C[x\\mapsto D]\\\\\n    &=y[y\\mapsto C][x\\mapsto D]\n  \\end{align*}\n  \n\\end{proof}\n\n\n\\begin{lemma}[Substitution preserves $\\beta$-equivalence]\n  \\[\\text{If $A=_\\beta B$, then $A[x\\mapsto D]=_\\beta B[x\\mapsto D]$}\\]\n\\end{lemma}\n\\begin{proof}\n  It suffices to show that $((\\lambda y:A.B)C)[x\\mapsto D]=_\\beta(B[y\\mapsto C])[x\\mapsto D]$\n\n  \\begin{align*}\n  ((\\lambda y:A.B)C)[x\\mapsto D]&=((\\lambda y:A.B)[x\\mapsto D]C[x\\mapsto D])\\\\\n    &=((\\lambda y:A[x\\mapsto D].B[x\\mapsto D])C[x\\mapsto D])\\\\\n    &=_\\beta B[x\\mapsto D][y\\mapsto C[x\\mapsto D]]\\\\\n    &=B[y\\mapsto C][x\\mapsto D]\n  \\end{align*}\n  since $y$ is fresh in $D$ (Substitution Lemma for Terms).\n\\end{proof}\n\n\n\\begin{lemma}[Substitution Lemma]\n  \\[\\text{If $\\Gamma,x:A,\\Delta\\vdash B:C$ and $\\Gamma\\vdash D:A$, then $\\Gamma,\\Delta[x\\mapsto D]\\vdash B[x\\mapsto D]:C[x\\mapsto D]$}\\]\n\\end{lemma}\nThis is Lemma 5.2.1 in \\cite{Barendregt92}.\n\\begin{proof}\n  Use induction on the length of the derivation of $\\Gamma,x:A,\\Delta,\\vdash B:C$.\n\n  Abbreviate $M[x\\mapsto D]$ as $M^*$. Note if $x$ is fresh in $M$, then $M=M^*$.\n\n  Look at the last rule used in the derivation of $\\Gamma,x:A,\\Delta,\\vdash B:C$.\n  \n  Case STAR: This case cannot apply because STAR only applies in the empty context, but the context contains $x$.\n\n  Case WEAK: If $\\Delta=<>$, the last rule was\n  \\[\\infer{\\Gamma,x:A\\vdash B:C}{\\Gamma\\vdash B:C & \\Gamma\\vdash A:s}\\]\n  Since $x$ is fresh in $B$ and $C$, $B=B^*$, and $C=C^*$. Thus,\n  \\[\\Gamma\\vdash B^*:C^*\\]\n  as desired.\n  On the other hand, if $\\Delta=\\Delta',y:E$, the last rule was\n  \\[\\infer{\\Gamma,x:A,\\Delta',y:E\\vdash B:C}{\\Gamma,x:A,\\Delta'\\vdash B:C & \\Gamma\\vdash E:s}\\]\n\n  By the inductive hypothesis, $\\Gamma,\\Delta'^*\\vdash B^*:C^*$. Also, since $x$ is fresh in $E$, $E=E^*$. By rule WEAK,\n\n  \\[\\infer{\\Gamma,\\Delta'^*,y:E^*\\vdash B^*:C^*}{\\Gamma,\\Delta'^*\\vdash B^*:C^* & \\Gamma\\vdash E^*:s}\\]\n\n  Since $\\Delta^*=\\Delta'^*,y:E^*$,\n  \\[\\Gamma,\\Delta^*\\vdash B^*:C^*\\]\n  as desired.\n\n  Case VAR: If $\\Delta=<>$, the last rule was\n  \\[\\infer{\\Gamma,x:A\\vdash x:A}{\\Gamma\\vdash A:s}\\]\n  Since $\\Gamma\\vdash D:A$, $x^*=D$, and $A=A^*$,\n  \\[\\Gamma\\vdash x^*:A^*\\]\n  as desired.\n  On the other hand, if $\\Delta=\\Delta',y:E$, the last rule was\n  \\[\\infer{\\Gamma,x:A,\\Delta',y:E\\vdash y:E}{\\Gamma,x:A,\\Delta'\\vdash E:s}\\]\n  By the inductive hypothesis,\n  \\[\\Gamma,\\Delta'^*\\vdash E^*,s^*\\]\n  Now apply rule VAR:\n  \\[\\infer{\\Gamma,\\Delta'^*,y:E^*\\vdash y:E^*}{\\Gamma,\\Delta'^*\\vdash E^*,s^*}\\]\n  Since $\\Delta^*=\\Delta'^*,y:E^*$ and $y=y^*$,\n  \\[\\Gamma,\\Delta^*\\vdash y^*:E^*\\]\n  \n  as desired.\n\n  Case PI: The last rule was\n  \\[\\infer{\\Gamma,x:A,\\Delta\\vdash(\\Pi y:E.F):t}{\\Gamma,x:A,\\Delta\\vdash A:s & \\Gamma,x:A,\\Delta,y:E\\vdash F:t}\\]\n  By the inductive hypothesis, $\\Gamma,\\Delta^*\\vdash A^*:s^*$ and $\\Gamma,\\Delta^*,y:E^*\\vdash F^*:t^*$\n  Applying rule PI, we get\n  \\[\\infer{\\Gamma,\\Delta^*\\vdash (\\Pi y:E^*:F^*):t^*}{\\Gamma,\\Delta^*\\vdash A^*:s^* & \\Gamma,\\Delta^*,y:E^*\\vdash F^*:t^*}\\]\n  as desired\n\n  Case LAM: The last rule was\n  \\[\\infer{\\Gamma,x:A,\\Delta\\vdash(\\lambda y:E.f):(\\Pi y:E.F)}{\\Gamma,x:A,\\Delta,y:E\\vdash f:F & \\Gamma,x:A,\\Delta\\vdash(\\Pi y:E.F):t}\\]\n  By the inductive hypothesis, $\\Gamma,\\Delta^*,y:E^*\\vdash f^*:F^*$ and $\\Gamma,\\Delta^*\\vdash(\\Pi y:E^*.F^*):t^*$\n  Applying rule LAM,\n  \\[\\infer{\\Gamma,\\Delta^*\\vdash(\\lambda y:E^*,f^*):(\\Pi y:E^*:F^*)}{\\Gamma,\\Delta^*,y:E^*\\vdash f^*:F^* & \\Gamma,\\Delta^*\\vdash(\\Pi y:E^*.F^*):t^*}\\]\n  as desired.\n\n  Case CONV: The last rule was\n  \\[\\infer{\\Gamma,x:A,\\Delta\\vdash e:F}{\\Gamma,x:A,\\Delta\\vdash e:E & \\Gamma,x:A,\\Delta\\vdash F:s & E=_\\beta F}\\]\n  By the inductive hypothesis, $\\Gamma,\\Delta^*\\vdash e^*:E^*$ and $\\Gamma,\\Delta^*\\vdash F^*:s^*$. Also, $E^*=_\\beta F^*$ since substitution preserves $\\beta$-equivalence. By rule LAM,\n  \\[\\infer{\\Gamma,\\Delta^*\\vdash e^*:F^*}{\\Gamma,\\Delta^*\\vdash e^*:E^* & \\Gamma,\\Delta^*\\vdash F^*:s^* & E^*=_\\beta F^*}\\]\n  \n  This exhausts all the cases, so the lemma is true by induction.\n\\end{proof}\n\n\n\\begin{theorem}[Preservation]\n  $(\\Gamma\\vdash A:B)\\wedge(A\\rightarrow A')\\Rightarrow(\\Gamma\\vdash A':B)$\n\\end{theorem}\n\nThis is based on Theorem 5.2.15 in \\cite{Barendregt92}.\n\n\\begin{proof}\n  Because the types of variables can contains other variables, we cannot just prove this by induction. Instead, we need to prove two statements simultaneously by induction on generation of $\\Gamma\\vdash A:B$:\n  \\[(\\Gamma\\vdash e:\\tau)\\wedge(e\\rightarrow e')\\Rightarrow(\\Gamma\\vdash e':\\tau)\\]\n  \\[(\\Gamma\\vdash e:\\tau)\\wedge(\\Gamma\\rightarrow \\Gamma')\\Rightarrow(\\Gamma'\\vdash e:\\tau)\\]\n  where $\\Gamma\\rightarrow\\Gamma'$ if $\\Gamma=x_1:A_1,\\ldots x_n:A_n$ and $\\Gamma'=x_1:A_1'\\ldots x_n:A_n'$ where $A_i\\rightarrow A_i'$ for exactly one $i$ and for all $j\\ne i$ $A_j=_\\beta A_j'$. In other words, the type of exactly one variable in the context takes a step.\n\n  Case STAR: This case cannot occur because neither the context nor the term may take a step.\n\n  Case VAR:\n  \n  \\[\\infer{\\Gamma,x:A\\vdash x:A}{\\Gamma\\vdash A:s}\\]\n\n  Since $x$ cannot take a step, we only need to handle $(\\Gamma,x:A)\\rightarrow(\\Gamma,x:A)'$\n  This can happen in two ways:\n  \n  If $\\Gamma\\rightarrow\\Gamma'$: By the inductive hypothesis, $\\Gamma'\\vdash A:s$. Thus,\n  \\[\\infer{\\Gamma',x:A\\vdash x:A}{\\Gamma'\\vdash A:s}\\]\n  as desired.\n  \n  If $A \\rightarrow A'$: By the inductive hypothesis, $\\Gamma\\vdash A':s$. Thus,\n  \\[\\infer{\\Gamma,x:A'\\vdash x:A'}{\\Gamma\\vdash A':s}\\]\n  as desired.\n  \n  Case WEAK:\n\n  \\[\\infer{\\Gamma,x:A\\vdash B:C}{\\Gamma\\vdash B:C & \\Gamma\\vdash A:s}\\]\n\n  First, consider the case where the term takes a step: $B\\rightarrow B'$.\n  By the inductive hypothesis, $\\Gamma\\vdash B':C$. By WEAK, $\\Gamma,x:A\\vdash B':C$, as desired.\n  Now consider if the context takes a step. There are two cases. If $\\Gamma\\rightarrow\\Gamma'$, then by the inductive hypothesis, $\\Gamma'\\vdash B:C$ and $\\Gamma'\\vdash A:s$. By WEAK, $\\Gamma'\\vdash B:C$.\n  If $A\\rightarrow A'$, then by the inductive hypothesis, $\\Gamma\\vdash A':s$. By WEAK, $\\Gamma,x:A'\\vdash B:C$, as desired.\n  \n  Case APP:\n  \\[\\infer{\\Gamma\\vdash f a:B[x\\mapsto a]}{\\Gamma\\vdash f:(\\Pi:A.B) & \\Gamma\\vdash a:A}\\]\n\n  If $\\Gamma\\rightarrow \\Gamma'$, by the inductive hypothesis, $\\Gamma'\\vdash f:(\\Pi:A.B)$ and $\\Gamma'\\vdash a:A$. Thus,\n  \\[\\Gamma\\vdash f a:B[x\\mapsto a]\\]\n  as desired.\n\n  There are three ways for the term to take a step.\n\n  If $e'=f' a$ where $f\\rightarrow f'$ (APP1), then by the inductive hypothesis, $\\Gamma\\vdash f':(\\Pi:A.B)$, so by APP, $\\Gamma\\vdash f' a:B[x\\mapsto a]$, as desired.\n  If $e'=f a'$ where $a\\rightarrow a'$ (APP2), then by the inductive hypothesis, $\\Gamma\\vdash a':A$, so by APP, $\\Gamma\\vdash f a':B[x\\mapsto a']$, as desired.\n\n  If $e'=b[x\\mapsto a]$ where $f=(\\lambda x:A.b)$ (APP3), then by rules APP and LAM (and possible WEAK and CONV), we have\n\n  \\[\\infer{\\Gamma\\vdash(\\lambda x:A.b) a:B[x\\mapsto a]}{\\infer{\\Gamma\\vdash (\\lambda x:A.b):(\\Pi x:A.B)}{\\infer{\\cdots}{\\infer{\\Delta\\vdash (\\lambda x:A.b):(\\Pi x:A.B)}{\\Delta,x:A\\vdash b:B & \\Delta\\vdash (\\Pi x:A.B):t}}} & \\Gamma\\vdash x:A}\\]\n\n  We can add back variables to $\\Delta$ to get $\\Gamma, x:A\\vdash b:B$. Also, $\\Gamma\\vdash a:A$. By the Substitution Lemma. $\\Gamma\\vdash b[x\\mapsto a]:B[x\\mapsto a]$, as desired.\n\n  \n  Case LAM: By rules LAM and PI (and possible WEAK and CONV).\n  \\[\\infer{\\Gamma\\vdash(\\lambda x:A.b):(\\Pi x:A.B)}{\\Gamma,x:A\\vdash b:B & \\infer{\\Gamma\\vdash (\\Pi x:A.B):t}{\\infer{\\cdots}{\\infer{\\Delta\\vdash (\\Pi x:A.B):u}{\\Delta\\vdash A:s & \\Delta,x:A\\vdash B:u}}}}\\]\n\n  There are two ways for the term to take a step. If $e'=(\\lambda x:A'.b)$ where $A\\rightarrow A'$ (LAM1), then by the inductive hypothesis, $\\Gamma,x:A'\\vdash b:B$, $\\Delta\\vdash A':s$ and $\\Delta,x:A'\\vdash B:t$. Thus,\n    \n  \\[\\infer{\\Gamma\\vdash(\\lambda x:A'.b):(\\Pi x:A'.B)}{\\Gamma,x:A'\\vdash b:B & \\infer{\\Gamma\\vdash (\\Pi x:A'.B):t}{\\infer{\\cdots}{\\infer{\\Delta\\vdash (\\Pi x:A'.B):u}{\\Delta\\vdash A':s & \\Delta,x:A'\\vdash B:u}}}}\\]\n  as desired.\n\n  If $e'=(\\lambda x:A.b')$ where $b\\rightarrow b'$ (LAM2), then by the inductive hypothesis, $\\Gamma,x:A\\vdash b':B$, Thus,\n    \n  \\[\\infer{\\Gamma\\vdash(\\lambda x:A.b'):(\\Pi x:A.B)}{\\Gamma,x:A\\vdash b':B & \\Gamma\\vdash (\\Pi x:A.B):t}\\]\n    as desired.\n\n    If $\\Gamma\\rightarrow\\Gamma'$, by the inductive hypothesis, $\\Gamma',x:A\\vdash b:B$ and $\\Gamma'\\vdash (\\Pi x:A.B):t$.\n\n    Thus,\n    \\[\\infer{\\Gamma'\\vdash(\\lambda x:A.b):(\\Pi x:A.B)}{\\Gamma',x:A\\vdash b:B & \\Gamma'\\vdash (\\Pi x:A.B):t}\\]\n    as desired.\n\n    Case PI: $e=(\\Pi x:A_1.A_2)$.\n  \n  \\[\\infer{\\Gamma\\vdash(\\Pi x:A_1.A_2):t}{\\Gamma\\vdash A_1:s & \\Gamma,x:A_1\\vdash A_2:t}\\]\n\n  Suppose $e\\rightarrow e'$. This can happen in two ways.\n\n  If $e'=A_1' A_2$ where $A_1\\rightarrow A_1'$ (rule PI1): By the inductive hypothesis, $\\Gamma\\vdash A_1':s$, $\\Gamma,x:A_1'\\vdash A_2:t$. Thus, by rule PI,\n\n  \\[\\infer{\\Gamma\\vdash(\\Pi x:A_1'.A_2):t}{\\Gamma\\vdash A_1':s & \\Gamma,x:A_1'\\vdash A_2:t}\\]\n  as desired.\n\n  If $e'=A_1 A_2'$ where $A_2\\rightarrow A_2'$ (rule PI2): By the inductive hypothesis,  $\\Gamma,x:A_1\\vdash A_2':t$. Thus, by rule PI,\n  \\[\\infer{\\Gamma\\vdash(\\Pi x:A_1.A_2'):t}{\\Gamma\\vdash A_1:s & \\Gamma,x:A_1\\vdash A_2':t}\\]\n  as desired.\n\n  Suppose $\\Gamma\\rightarrow\\Gamma'$. By the inductive hypothesis, $\\Gamma'\\vdash A_1:s$, $\\Gamma',x:A_1\\vdash A_2:t$. Thus, by rule PI,\n\n  \\[\\infer{\\Gamma'\\vdash(\\Pi x:A_1.A_2):t}{\\Gamma'\\vdash A_1:s & \\Gamma',x:A_1\\vdash A_2:t}\\]\n  as desired.\n\n  Case CONV:\n  \\[\\infer{\\Gamma\\vdash a:B}{\\Gamma\\vdash a:A & \\Gamma\\vdash B:s & A=_\\beta B}\\]\n\n  Suppose $a\\rightarrow a'$.\n  \n  By the inductive hypothesis, $\\Gamma\\vdash a':A$, so by rule CONV,\n  \\[\\infer{\\Gamma\\vdash a':B}{\\Gamma\\vdash a':A & \\Gamma\\vdash B:s & A=_\\beta B}\\]\n  as desired.\n  \n  Suppose $\\Gamma\\rightarrow\\Gamma'$.\n  By the inductive hypothesis, $\\Gamma'\\vdash a:A$ and $\\Gamma'\\vdash B:s$, so by rule CONV,\n  \\[\\infer{\\Gamma\\vdash a':B}{\\Gamma\\vdash a':A & \\Gamma\\vdash B:s & A=_\\beta B}\\]\n  as desired.\n\\end{proof}\n\n\n\\bibliography{citations}{}\n\\bibliographystyle{plain}\n\\end{document}\n", "meta": {"hexsha": "6d7a8215b150ae33c1a0bec832cbe200ff168b8e", "size": 18688, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "soundness-proof.tex", "max_stars_repo_name": "dragonslayerintraining/calculus-of-constructions", "max_stars_repo_head_hexsha": "177b68d5458b800902c9abb7aeecf893e5d27962", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "soundness-proof.tex", "max_issues_repo_name": "dragonslayerintraining/calculus-of-constructions", "max_issues_repo_head_hexsha": "177b68d5458b800902c9abb7aeecf893e5d27962", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "soundness-proof.tex", "max_forks_repo_name": "dragonslayerintraining/calculus-of-constructions", "max_forks_repo_head_hexsha": "177b68d5458b800902c9abb7aeecf893e5d27962", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.7826086957, "max_line_length": 486, "alphanum_fraction": 0.647848887, "num_tokens": 6667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43944382371202767}}
{"text": "\\subsection{Evaluation Metrics}\n\n\\subsubsection{Multiclass classification}\nFor the multiclass dataset we use accuracy and macro-averaged F1 score.\n\n\\subsubsection{Accuracy} Accuracy is the percentage of labels for which the class is correctly predicted. Note that for multiclass classification the micro-averaged F1 score is equal to the accuracy.\n\n\\subsubsection{Macro-averaged F1 score} \nMacro-averaged F1 score is computed by first computing the F1 score for each class independently and then take an averaging all the F1 scores. This metric treats all the classes as equal, independent of their frequency in the test set.\n\n\\subsubsection{Multilabel classification}\nFor multilabel classification we use three metrics - hamming loss, micro-averaged F1 score and macro-averaged F1 score. \n\n\\subsubsection{Hamming loss} Hamming loss is the proportion of mis-classified examples in the dataset.\n\\subsubsection{Micro-averaged F1 score} F-measure averaging on the prediction matrix.\n\n\\subsubsection{Macro-averaged F1 score} Macro-averaged F1 score is calculated by computing the F1 score for each of the labels, then averaging the label wise F1 scores.", "meta": {"hexsha": "62369b55b49cf0cc3338a3b599e3b024b6cb8237", "size": 1149, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "skai/temp.tex", "max_stars_repo_name": "aayn/codeforces-clean", "max_stars_repo_head_hexsha": "2152e3a7e52b3fb067d4068ee69f9edac2925d49", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "skai/temp.tex", "max_issues_repo_name": "aayn/codeforces-clean", "max_issues_repo_head_hexsha": "2152e3a7e52b3fb067d4068ee69f9edac2925d49", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "skai/temp.tex", "max_forks_repo_name": "aayn/codeforces-clean", "max_forks_repo_head_hexsha": "2152e3a7e52b3fb067d4068ee69f9edac2925d49", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.5882352941, "max_line_length": 235, "alphanum_fraction": 0.819843342, "num_tokens": 259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6406358548398979, "lm_q1q2_score": 0.4394438154861355}}
{"text": "\\chapter{Derived Inference Rules}\n\\label{derived-rules}\n\nThe notion of {\\it proof\\/} is defined abstractly in the manual\n\\LOGIC: a proof of a sequent $(\\Gamma,t)$ from a set of sequents\n$\\Delta$ (with respect to a deductive system ${\\cal D}$) was defined\nto be a chain of sequents culminating in $(\\Gamma,t)$, such that every\nelement of the chain either belongs to $\\Delta$ or else follows from\n$\\Delta$ and earlier elements of the chain by deduction.  The notion\nof a {\\it theorem\\/} was also defined in \\LOGIC: a theorem of a\ndeductive system is a sequent that follows from the empty set of\nsequents by deduction; \\ie, it is the last element of a proof from the\nempty set of sequents, in the deductive system.  In this section,\nproofs and theorems are made concrete in \\HOL.\n\nThe deductive system of \\HOL\\\nwas sketched in Section~\\ref{rules}, where\nthe eight families of primitive inferences making up the\ndeductive system were specified by diagrams. It was explained that\nthese families of inferences are represented in \\HOL\\ via\n\\ML\\ functions, and that theorems\nare represented by an \\ML\\ abstract type called \\ml{thm}.\\index{thm@\\ml{thm}}\nThe eight \\ML\\ functions corresponding to the inferences\nare operations of the type \\ml{thm}, and each of the eight\nreturns a value of type \\ml{thm}. It was explained that the\ntype \\ml{thm} has primitive destructors, but no primitive\nconstructor; and that in that way, the logic is protected against\nthe computation of theorems except by functions representing\nprimitive inferences, or compositions of these.\n\nFinally, the primitive \\HOL\\ logic was supplemented by three primitive\nconstants and four axioms, to form the basic logic.  The primitive\ninferences, together with the primitive constants, the five axioms,\nand a collection of definitions, give a starting point for\nconstructing proofs, and hence computing theorems. However, proving\neven the simplest theorems from this minimal basis costs considerable\neffort. The basis does not immediately provide the transitivity of\nequality, for example, or a means of universal quantification; both of\nthese themselves have to be derived.\n\n\\section{Simple Derivations}\n\nAs an illustration of a proof in \\HOL{}, the following chain of\ntheorems forms a proof (from the empty set, in the \\HOL{} deductive\nsystem), for the particular terms \\ml{``}$t_1$\\ml{``}%''\nand \\ml{``}$t_2$\\ml{``},%''\nboth of \\HOL\\ type \\ml{``:bool``}:%''\n\n\\begin{enumerate}\n\\item $t_1$\\ml{ ==> }$t_2$\\ml{ |- }$t_1$\\ml{ ==> }$t_2$\n\n\\item $t_1$\\ml{ |- }$t_1$\n\n\\item $t_1$\\ml{ ==> }$t_2$\\ml{, }$t_1$\\ml{ |- }$t_2$\n\\end{enumerate}\n\n\\noindent That is, the third theorem follows from the first and second.\n\nIn the session below, the proof is performed in the \\HOL\\ system,\nusing the \\ML\\ functions \\ml{ASSUME}\\index{ASSUME@\\ml{ASSUME}} and\n\\ml{MP}.\n\n\\setcounter{sessioncount}{1}\n\\begin{session}\n\\begin{verbatim}\n- show_assums := true;\n> val it = () : unit\n\n- val th1 = ASSUME ``t1 ==> t2``;\n> val th1 = [t1 ==> t2] |- t1 ==> t2 : thm\n\n- val th2 = ASSUME ``t1:bool``\n> val th2 = [t1] |- t1 : thm\n\n- MP th1 th2;\n> val it = [t1 ==> t2, t1] |- t2 : thm\n\\end{verbatim}\n\\end{session}\n\n\\noindent More briefly, one could evaluate the following, and `count'\\index{counting inferences, in HOL proofs@counting inferences, in \\HOL{} proofs} the\ninvocations of functions representing primitive inferences.\n\n\\begin{session}\n\\begin{verbatim}\n#set_flag(`timing`, true);;\nfalse : bool\nRun time: 0.0s\n\n#MP(ASSUME \"t1 ==> t2\")(ASSUME \"t1:bool\");;\nt1 ==> t2, t1 |- t2\nRun time: 0.0s\nIntermediate theorems generated: 3\n\\end{verbatim}\n\\end{session}\n\n\\noindent Each of the three inference steps of the abstract proof\ncorresponds to the application%\n%\n\\index{inferences, in HOL logic@inferences, in \\HOL{} logic!as ML function applications@as \\ML\\ function applications}%\n\\index{proof steps, as ML function applications@proof steps, as \\ML\\ function applications}%\n\\index{proof!the notion of, in HOL system@the notion\n  of, in \\HOL\\ system}%\n%\nof an \\ML\\ function in the performance of the proof in \\HOL; and each\nof the \\ML\\ functions corresponds to a primitive inference of the\ndeductive system.\n\nIt is worth emphasising that, in either case, every\nprimitive inference in the proof chain is made, in the sense\nthat for each inference, the corresponding \\ML\\ function is evaluated.  That is,\n\\HOL\\ permits no short-cut around the necessity of performing\ncomplete proofs.  The short-cut provided by derived\n\\index{inferences, in HOL logic@inferences, in \\HOL{} logic!in derived rules}\ninference rules (as implemented in \\ML) is around the necessity of\n\\emph{specifying} every step; something that would be impossible for\na proof of any length. It can be seen from this that the derived\nrule,%\n%\n\\index{proofs, in HOL logic@proofs, in \\HOL{} logic!as ML function applications@as \\ML\\ function applications}\n\\index{proofs, in HOL logic@proofs, in \\HOL{} logic!as generated by derived rules}\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!importance of}\n%\nand its representation as an \\ML{} function, is essential to the\n\\HOL{} methodology; theorem proving would be otherwise impossible.\n\nThere are, of course, an infinite number of proofs, of the `form'\nshown in the example, that can be conducted in \\HOL: one for every\npair of \\ml{``:bool``}-typed terms. %''\nMoreover, every time a theorem of the form\n\n$$t_1 \\ \\imp \\ t_2, \\ t_1 \\ \\vdash \\ t_2$$\n\n\\noindent is required, its proof must be constructed anew. To capture the\ngeneral pattern of inference, an \\ML\\ function can be written to\nimplement an inference rule as a derivation from the primitive inferences.\nAbstractly, a \\emph{derived inference rule}\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!justification of}\n%\nis a rule that can be justified on the basis of the primitive\ninference rules (and/or the axioms).  In the present case, the rule\nrequired `undischarges' assumptions.  It is specified for \\HOL{} by\n\n\\bigskip\n\n\\begin{center}\n\\begin{tabular}{c}\n$\\Gamma${\\small\\verb% |- %}$t_1${\\small\\verb% ==> %}$t_2$\\\\ \\hline\n$\\Gamma\\cup\\{t_1\\}${\\small\\verb% |- %}$t_2$\n\\end{tabular}\n\\end{center}\n\n\\bigskip\n\n\\noindent This general rule is valid because from a \\HOL\\ theorem of the\nform $\\Gamma${\\small\\verb% |- %}$t_1${\\small\\verb%==>%}$t_2$, the theorem\n$\\Gamma\\cup\\{t_1\\}${\\small\\verb% |- %}$t_2$ can be derived\nas for the specific instance above.\nThe rule can be implemented in \\ML\\ as a function (\\ml{UNDISCH},\nsay)\\index{UNDISCH@\\ml{UNDISCH}} that calls the\nappropriate sequence of primitive\ninferences. The \\ML\\ definition of \\ml{UNDISCH} is simply\n\n\\begin{session}\n\\begin{verbatim}\n- val UNDISCH th = MP th (ASSUME(fst(dest_imp(concl th))));;\n> val UNDISCH = fn : thm -> thm\n\\end{verbatim}\n\\end{session}\n\n\\noindent This provides a function that maps a theorem to a theorem;\nthat is, performs proofs in \\HOL.\nThe following session illustrates the use of the derived rule, on\na consequence of the axiom \\ml{IMP\\_ANTISYM\\_AX}. (The inferences are\ncounted.%\n\\index{counting inferences, in HOL proofs@counting inferences, in \\HOL{} proofs}%\n%\n) Assume that the printing of theorems has been adjusted as above and\n\\ml{th} is bound as shown below:\n\n\\setcounter{sessioncount}{1}\n\\begin{session}\n\\begin{verbatim}\n#th;;\n|- (t1 ==> t2) ==> (t2 ==> t1) ==> (t1 = t2)\nRun time: 0.0s\n\n#set_flag(`timing`,true);;\ntrue : bool\nRun time: 0.0s\n\n#UNDISCH th;;\nt1 ==> t2 |- (t2 ==> t1) ==> (t1 = t2)\nRun time: 0.1s\nIntermediate theorems generated: 2\n\n#UNDISCH it;;\nt1 ==> t2, t2 ==> t1 |- t1 = t2\nRun time: 0.0s\nIntermediate theorems generated: 2\n\\end{verbatim}\n\\end{session}\n\n\\noindent Each successful application of {\\small\\verb%UNDISCH%}\nto a theorem invokes an application\nof {\\small\\verb%ASSUME%}, followed by an application of {\\small\\verb%MP%};\n\\ml{UNDISCH} constructs the\n2-step proof for any given theorem (of appropriate form).\nAs can be\nseen, it relies on the class of \\ML\\ functions that access \\HOL\\ syntax:\nin particular, \\ml{concl} to produce the conclusion\nof the theorem, \\ml{dest\\_imp} to separate the implication, and the\nselector \\ml{fst} to choose the antecedent.\n\nThis particular example is very simple, but a derived inference rule\ncan perform proofs of arbitrary length.  It can also make use of\npreviously defined rules.  In this way, the normal inference patterns\ncan be developed much more quickly and easily; transitivity,\ngeneralization, and so on, support the familiar patterns of inference.\n\nA number of derived inference rules are pre-defined when the \\HOL\\\nsystem is entered (of which \\ml{UNDISCH} is one of the first).  In\nSection~\\ref{avra_standard}, the abstract derivations are given for\nthe pre-defined rules that reflect the more usual inference patterns\nof the predicate (and lambda) calculi.  Like those shown, some of the\npre-defined derived rules in \\HOL\\ generate relatively short proofs.\nOthers invoke thousands of primitive inferences, and clearly save a\ngreat deal of effort. Furthermore, rules can be defined by the user to\nmake still larger steps, or to implement more specialized patterns.\n\nAll of the pre-defined derived rules in \\HOL\\ are described\nin \\REFERENCE.\n\n\\section{Rewriting}\n\\label{avra_rewrite}\n\n\\index{rewriting!rules for|(}\n\\index{REWRITE_RULE@\\ml{REWRITE\\_RULE}|(}\nIncluded in the set of derived inferences that are pre-defined in\n\\HOL\\ is a group of rules with complex definitions that do a limited\namount of `automatic' theorem-proving in the form of rewriting.  The\nideas and implementation were originally developed by\nMilner\\index{Milner, R.}  and Wadsworth\\index{Wadsworth, C.} for\nEdinburgh \\LCF,\\index{LCF@\\LCF!Edinburgh} and were later implemented\nmore flexibly and efficiently by Paulson\\index{Paulson, L.} and\nHuet\\index{Huet, G.} for Cambridge \\LCF.\\index{LCF@\\LCF!Cambridge}\nThey appear in \\HOL{} in the Cambridge form. The basic rewriting rule\nis \\ml{REWRITE\\_RULE}.  All of the rewriting rules are described in\ndetail in \\REFERENCE.\n\n\\ml{REWRITE\\_RULE} uses a list of equational theorems\n\\index{equational theorems, in HOL logic@equational theorems, in \\HOL{} logic!use of in rewriting}\n\\index{theorems, in HOL logic@theorems, in \\HOL{} logic!equational}\n(theorems whose conclusions can be regarded as having the form\n$t_1${\\small\\verb% = %}$t_2$) to replace\nany subterms of an object theorem that `match' $t_1$ by the\ncorresponding instance of $t_2$. The rule matches recursively and to any depth,\nuntil no more replacements can be made,\nusing internally defined search, matching and\ninstantiation\\index{type instantiation, in HOL logic@type instantiation, in \\HOL{} logic!in rewriting rule} algorithms.  The validity\n of \\ml{REWRITE\\_RULE} rests\nultimately on the primitive rules \\ml{SUBST} (for making the substitutions);\n\\ml{INST\\_TYPE}\\index{INST_TYPE@\\ml{INST\\_TYPE}} (for instantiating types); and the derived rules for\ngeneralization and specialization (see Sections~\\ref{avra_gen}\nand \\ref{avra_spec}) for instantiating terms.  The definition\nof \\ml{REWRITE\\_RULE} in \\ML\\\nalso relies on a large number of general and \\HOL-oriented\n\\ML\\ functions.\n%The implementation is partly described in Chapter~\\ref{avra_conv}.\n\nIn practice, the derived rule \\ml{REWRITE\\_RULE} plays a central role\nin proofs, because it takes over a very large number of inferences\nwhich may happen in a complex and unpredictable order. It is unlike\nany other primitive or pre-defined rule, first because of the number\nof inferences it generates\\footnote{The number of inferences performed\n  by this rule is generally `inflated'; \\ie\\ is generally greater than\n  the length of the proof itself, if the proof could be `seen'.  This\n  is because, in the current implementation, some inference is done\n  during the search phase that is not necessarily in support of\n  successful replacements.}; and second because its outcome is often\nunexpected. Its power is increased by the fact that any existing\nequational theorem can be supplied as a `rewrite rule', including a\nstandard \\HOL\\ set of pre-proved tautologies; and these rewrite rules\ncan interact with each other in the rewriting process to transform the\noriginal theorem.\n\nThe application of \\ml{REWRITE\\_RULE}, in the session below,\nillustrates that replacements are made at all levels of the\nstructure of a term.\nThe example is numerical;\nthe infixes {\\small\\verb%\"$>\"%} and {\\small\\verb%\"$<\"%} are\nthe usual `greater than'  and `less than' relations, respectively,\nand \\ml{\"SUC\"}, the\nusual successor function.\nUse is made of the pre-existing definition of {\\small\\verb%\"$>\"%}:\n\\ml{GREATER} (see \\REFERENCE).\nThe timing\\index{counting inferences, in HOL proofs@counting inferences, in \\HOL{} proofs} facility is used again, for interest, and the printing\nof theorems is adjusted as above.\n\n\n\\setcounter{sessioncount}{1}\n\\begin{session}\n\\begin{verbatim}\n#top_print print_all_thm;;\n- : (thm -> void)\n\n#set_flag(`timing`,true);;\nfalse : bool\nRun time: 0.0s\n\n#REWRITE_RULE\n [GREATER]\n (ASSUME \"SUC 4 > 0 = (SUC 3 > 0 = (SUC 2 > 0 = (SUC 1 > 0 = SUC 0 > 0)))\");;\n##Definition GREATER autoloaded from theory `arithmetic`.\nGREATER = |- !m n. m > n = n < m\nRun time: 1.5s\nIntermediate theorems generated: 1\n\n(SUC 4) > 0 =\n((SUC 3) > 0 = ((SUC 2) > 0 = ((SUC 1) > 0 = (SUC 0) > 0)))\n|- 0 < (SUC 4) =\n   (0 < (SUC 3) = (0 < (SUC 2) = (0 < (SUC 1) = 0 < (SUC 0))))\nRun time: 0.3s\nIntermediate theorems generated: 23\n\\end{verbatim}\n\\end{session}\n\n\\noindent Notice that rewriting\nequations can be extracted from\nuniversally quantified theorems.\nTo construct the\nproof step-wise, with all of the instantiations,\nsubstitutions, and uses of transitivity, \\etc,\nwould be a lengthy process. The rewriting rules make it easy,\nand do so whilst still generating the entire chain of inferences.\n\\index{REWRITE_RULE@\\ml{REWRITE\\_RULE}|)}\n\\index{rewriting!rules for|)}\n\n\\section{Derivation of the Standard Rules}\n\\label{avra_standard}\n\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!pre-defined|(}\n%\nThe \\HOL{} system provides all the standard introduction and\nelimination rules of the predicate calculus pre-defined as derived\ninferences.  It is these derived rules, rather than the primitive\nrules, that one normally uses in practice.  In this section, the\nderivations of some of the standard rules are given, in sequence.\nThese derivations only use the axioms and definitions in the theory\n\\theoryimp{bool} (see Section~\\ref{boolfull}), the eight primitive\ninferences of the \\HOL\\ logic, and inferences defined earlier in the\nsequence.\n\nTheorems,%\n%\n\\index{theorems, in HOL logic@theorems, in \\HOL{} logic!as inference rules}%\n%\nin accordance with the definition given at the beginning of this\nchapter, are treated as rules without hypotheses; thus the derivation\nof a theorem resembles the derivation of a rule except in not having\nhypotheses. (The derivation of \\ml{TRUTH}, Section~\\ref{avra_T}, is\nthe only example given of this, but there are several others in \\HOL.)\nThere are also some rules that are intrinsically more general than\ntheorems.  For example, for any two terms $t_1$ and $t_2$, the theorem\n$\\vdash(\\lquant{x}t_1)t_2 = t_1[t_2/x]$ follows by the primitive rule\n\\rul{BETA\\_CONV}. The rule \\ml{BETA\\_CONV} returns a theorem for each\npair of terms $t_1$ and $t_2$, and is therefore equivalent to an\ninfinite family%\n%\n\\index{families of inferences, in HOL logic@families of inferences, in \\HOL{} logic}%\n%\nof theorems. No single theorem can be expressed in the \\HOL{} logic\nthat is equivalent to \\rul{BETA\\_CONV}.%\n\\index{theorems, in HOL logic@theorems, in \\HOL{} logic!rules inexpressible as}\n\\index{beta-conversion, in HOL logic@beta-conversion, in \\HOL{} logic!not expressible as a theorem}%\n%\n%(See Chapter~\\ref{avra_conv} for further discussion of this point.)\n(\\ml{UNDISCH} is not a rule of this sort, as it can, in fact, be\nexpressed as a theorem.)\n\nFor each derivation given below, there is an \\ML\\ function definition\nin the \\HOL\\ system that implements the derived rule as a procedure in\n\\ML. The actual implementation in the \\HOL\\ system differs in some\ncases from the derivations given here, since the system code has been\noptimised for improved performance.\n\nIn addition, for reasons that are mostly historical, not all the\ninferences that are derived in terms of the abstract logic are\nactually derived in the current version of the \\HOL\\ system.  That is,\nthere are currently about forty rules that are installed in the system\non an `axiomatic' basis, all of which should be derived by explicit\ninference.  Although the current status of these rules is not\nsatisfactory, and it is planned, as a high priority, to derive them\nproperly in a future version, their current status does not actually\ncompromise the consistency of the logic.  In effect, the existing\n\\HOL\\ system has a deductive system more comprehensive than the one\npresented abstractly, but the model outlined in \\LOGIC{} would easily\nextend to cover it.%\n%\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!pre-defined|)}\n\nFor reference, in \\HOL\\ Version 2.0 the following rules that should be\nderived\n%\n\\index{inference rules, of HOL logic@inference rules, of \\HOL{} logic!some not properly derived|(}\n\\index{rules in HOL logic, some not properly derived@rules in \\HOL{} logic, some not properly derived|(}\n%\nare not derived, but (for efficiency) are implemented as\nprimitives. The list includes some conversions and conversion-valued\nfunctions. % (conversions are discussed in Chapter~\\ref{avra_conv}).\n\\vfill \\newpage\n\n\\begin{hol}\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!list of axiomatic}\n\\index{AP_TERM@\\ml{AP\\_TERM}}\n\\index{AP_THM@\\ml{AP\\_THM}}\n\\index{CCONTR@\\ml{CCONTR}}\n\\index{CHOOSE@\\ml{CHOOSE}}\n\\index{CONJ@\\ml{CONJ}}\n\\index{CONJUNCT1@\\ml{CONJUNCT1}}\n\\index{CONJUNCT2@\\ml{CONJUNCT2}}\n\\index{DISJ_CASES@\\ml{DISJ\\_CASES}}\n\\index{DISJ1@\\ml{DISJ1}}\n\\index{DISJ2@\\ml{DISJ2}}\n\\index{EQ_IMP_RULE@\\ml{EQ\\_IMP\\_RULE}}\n\\index{EQ_MP@\\ml{EQ\\_MP}}\n\\index{EQT_INTRO@\\ml{EQT\\_INTRO}}\n\\index{ETA_CONV@\\ml{ETA\\_CONV}}\n\\index{EXISTS@\\ml{EXISTS}}\n\\index{EXT@\\ml{EXT}}\n\\index{GEN@\\ml{GEN}}\n\\index{MK_ABS@\\ml{MK\\_ABS}}\n\\index{MK_COMB@\\ml{MK\\_COMB}}\n\\index{num_CONV@\\ml{num\\_CONV}}\n\\index{SPEC@\\ml{SPEC}}\n\\index{SUBS@\\ml{SUBS}}\n\\index{SUBS_OCCS@\\ml{SUBS\\_OCCS}}\n\\index{SUBST_CONV@\\ml{SUBST\\_CONV}}\n\\index{SYM@\\ml{SYM}}\n\\index{TRANS@\\ml{TRANS}}\n\\begin{verbatim}\n   ADD_ASSUM              CONTR                  IMP_ANTISYM_RULE\n   ALPHA                  DEF_EXISTS_RULE        IMP_TRANS\n   AP_TERM                DISJ_CASES             INST\n   AP_THM                 DISJ1                  MK_ABS\n   SUBS                   DISJ2                  MK_COMB\n   SUBS_OCCS              EQ_IMP_RULE            MK_EXISTS\n   CCONTR                 EQ_MP                  NOT_ELIM\n   CHOOSE                 EQT_INTRO              NOT_INTRO\n   CONJ                   ETA_CONV               num_CONV\n   EXISTS                 SPEC                   TRANS\n   EXT                    SUBST_CONV             CONJUNCT1\n   GEN                    SYM                    CONJUNCT2\n\\end{verbatim}\\end{hol}\n\\index{inference rules, of HOL logic@inference rules, of \\HOL{} logic!some not properly derived|)}\n\\index{rules in HOL logic, some not properly derived@rules in \\HOL{} logic, some not properly derived|)}\n\n\\index{inference rules, of HOL logic@inference rules, of \\HOL{} logic!derived|(}\nThe derivations that follow consist of sequences of numbered steps each of\nwhich\n\\begin{enumerate}\n\\item is an axiom, or\n\\item is a hypothesis of the rule being derived, or\n\\item follows from preceding steps by a rule of inference (either primitive\nor previously derived).\n\\end{enumerate}\n\n\\noindent Note that the abbreviation \\ml{conv} (standing for\n`conversion') is used for the \\ML\\ type \\ml{term ->\n  thm}.%\n% \\footnote{This stands for `conversion', as explained in\n% Chapter~\\ref{avra_conv}.}\n\n\\subsection{Adding an assumption}\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!list and derivations of some|(}\n\n\\begin{holboxed}\n\\index{ADD_ASSUM@\\ml{ADD\\_ASSUM}|pin}\n\\begin{verbatim}\n   ADD_ASSUM : term -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t\\over \\Gamma,\\ t'\\turn t$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $t'\\turn t'$ \\hfill [\\rul{ASSUME}]\n\\item $\\Gamma\\turn t$ \\hfill [Hypothesis]\n\\item $\\Gamma\\turn t'\\imp t$ \\hfill [\\rul{DISCH} 2]\n\\item $\\Gamma,\\ t'\\turn t$ \\hfill [\\rul{MP} 3,1]\n\\end{proof}\n\n\n\n%\\subsection{Undischarging [\\rul{UNDISCH}]}\n\\subsection{Undischarging}\n\n\n\\begin{holboxed}\n\\index{implication, in HOL logic@implication, in \\HOL{} logic!inference rules for}\n\\index{UNDISCH@\\ml{UNDISCH}|pin}\n\\begin{verbatim}\n   UNDISCH : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1\\imp t_2 \\over\\Gamma,\\ t_1\\turn t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $t_1\\turn t_1$ \\hfill [\\rul{ASSUME}]\n\\item $\\Gamma\\turn t_1\\imp t_2$ \\hfill [Hypothesis]\n\\item $\\Gamma,\\ t_1\\turn t_2$ \\hfill [\\rul{MP} 2,1]\n\\end{proof}\n\n\n\n\n\\subsection{Symmetry of equality}\n\n\n\\begin{holboxed}\n\\index{SYM@\\ml{SYM}|pin}\n\\index{symmetry of equality rule, in HOL logic@symmetry of equality rule, in \\HOL{} logic}\n\\index{equality, in HOL logic@equality, in \\HOL{} logic!symmetry rule for}\n\\begin{verbatim}\n   SYM : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1 = t_2\\over \\Gamma\\turn t_2 = t_1$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t_1=t_2$\\hfill [Hypothesis]\n\\item $\\turn t_1=t_1$ \\hfill [\\rul{REFL}]\n\\item $\\Gamma\\turn t_2=t_1$\\hfill [\\rul{SUBST} 1,2]\n\\end{proof}\n\n\n\n\\subsection{Transitivity of equality}\n\n\n\\begin{holboxed}\n\\index{transitivity of equality rule, in HOL logic@transitivity of equality rule, in \\HOL{} logic}\n\\index{equality, in HOL logic@equality, in \\HOL{} logic!transitivity rule for}\n\\index{TRANS@\\ml{TRANS}|pin}\n\\begin{verbatim}\n   TRANS : thm -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma_1\\turn t_1=t_2\\qquad\\qquad\\qquad \\Gamma_2\\turn t_2=t_3 \\over\n\\Gamma_1\\cup\\Gamma_2\\turn t_1=t_3$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma_2\\turn t_2=t_3$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\turn t_1=t_2$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\cup\\Gamma_2\\turn t_1=t_3$\\hfill [\\rul{SUBST} 1,2]\n\\end{proof}\n\n\n\n\\subsection{Application of a term to a theorem}%\n\\index{function application, in HOL logic@function application, in \\HOL{} logic!inference rules for}\n\n\\begin{holboxed}\n\\index{AP_TERM@\\ml{AP\\_TERM}|pin}\n\\begin{verbatim}\n   AP_TERM : term -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1=t_2\\over\\Gamma\\turn t\\ t_1 = t\\ t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t_1=t_2$\\hfill [Hypothesis]\n\\item $\\turn t\\ t_1 = t\\ t_1$ \\hfill [\\rul{REFL}]\n\\item $\\Gamma\\turn t\\ t_1 = t\\ t_2$ \\hfill [\\rul{SUBST} 1,2]\n\\end{proof}\n\n\n\n\\subsection{Application of a theorem to a term}\n\n\\begin{holboxed}\n\\index{AP_THM@\\ml{AP\\_THM}|pin}\n\\begin{verbatim}\n   AP_THM : thm -> conv\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1=t_2\\over \\Gamma\\turn t_1\\ t = t_2\\ t$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t_1=t_2$\\hfill [Hypothesis]\n\\item$\\turn t_1\\ t = t_1\\ t$\\hfill [\\rul{REFL}]\n\\item $\\Gamma\\turn t_1\\ t = t_2\\ t$\\hfill [\\rul{SUBST} 1,2]\n\\end{proof}\n\n\n\n\\subsection{Modus Ponens for equality}\n\\label{avra_eq_mp}\n\n\\begin{holboxed}\n\\index{EQ_MP@\\ml{EQ\\_MP}|pin}\n\\index{equality, in HOL logic@equality, in \\HOL{} logic!MP rule for@\\ml{MP} rule for}\n\\begin{verbatim}\n   EQ_MP : thm -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma_1\\turn t_1=t_2\\qquad\\qquad\\qquad \\Gamma_2\\turn t_1\\over\n\\Gamma_1\\cup\\Gamma_2\\turn t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma_1\\turn t_1=t_2$ \\hfill [Hypothesis]\n\\item $\\Gamma_2\\turn t_1$ \\hfill [Hypothesis]\n\\item $\\Gamma_1\\cup\\Gamma_2\\turn t_2$ \\hfill [\\rul{SUBST} 1,2]\n\\end{proof}\n\n\n\n\n\\subsection{Implication from equality}\n\\index{equality, in HOL logic@equality, in \\HOL{} logic!other rules for|(}\n\\index{implication, in HOL logic@implication, in \\HOL{} logic!inference rules for}\n\\begin{holboxed}\n\\index{EQ_IMP_RULE@\\ml{EQ\\_IMP\\_RULE}|pin}\n\\begin{verbatim}\n   EQ_IMP_RULE : thm -> (thm # thm)\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1=t_2\\over\n\\Gamma\\turn t_1\\imp t_2 \\qquad\\qquad\\qquad \\Gamma\\turn t_2\\imp t_1$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t_1=t_2$ \\hfill [Hypothesis]\n\\item $t_1\\turn t_1$ \\hfill [\\rul{ASSUME}]\n\\item $\\Gamma,\\ t_1\\turn t_2$ \\hfill [\\rul{EQ\\_MP} 1,2]\n\\item $\\Gamma\\turn t_1\\imp t_2$ \\hfill [\\rul{DISCH} 3]\n\\item $\\Gamma\\turn t_2=t_1$ \\hfill [\\rul{SYM} 1]\n\\item $t_2\\turn t_2$ \\hfill [\\rul{ASSUME}]\n\\item $\\Gamma,\\ t_2\\turn t_1$ \\hfill [\\rul{EQ\\_MP} 5,6]\n\\item $\\Gamma\\turn t_2\\imp t_1$ \\hfill [\\rul{DISCH} 7]\n\\item $\\Gamma\\turn t_1\\imp t_2$ and $\\Gamma\\turn t_2\\imp t_1$\\hfill [4,8]\n\\end{proof}\n\n\n\n\\subsection{\\T-Introduction}\n\\label{avra_T}\n\n\\index{T@\\holtxt{T}!rules of inference for|(}\n\\begin{hol}\n\\begin{verbatim}\n   TRUTH\n\\end{verbatim}\n\\end{hol}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\turn\\T$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\T = ((\\lquant{x}x)=(\\lquant{x}x))$\\hfill [Definition of \\T]\n\\item $\\turn ((\\lquant{x}x)=(\\lquant{x}x)) = \\T$\\hfill [\\rul{SYM} 1]\n\\item $\\turn (\\lquant{x}x)=(\\lquant{x}x)$\\hfill [\\rul{REFL}]\n\\item $\\turn\\T$ \\hfill [\\rul{EQ\\_MP} 2,3]\n\\end{proof}\n\n\n\n\n\\subsection{Equality-with-\\T\\ elimination}\n\n\\begin{holboxed}\n\\index{EQT_ELIM@\\ml{EQT\\_ELIM}|pin}\n\\begin{verbatim}\n   EQT_ELIM : thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t = \\T\\over \\Gamma\\turn t$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t = \\T$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn \\T = t$\\hfill [\\rul{SYM} 1]\n\\item $\\turn \\T$\\hfill [\\rul{TRUTH}]\n\\item $\\Gamma\\turn t$\\hfill [\\rul{EQ\\_MP} 2,3]\n\\end{proof}\n\n\n\\subsection{\\texorpdfstring{Specialization ($\\forall$-elimination)}{Specialization (forall-elimination)}}\n\n\\begin{holboxed}\n\\index{SPEC@\\ml{SPEC}|pin}\n\\index{specialization rule, in HOL logic@specialization rule, in \\HOL{} logic}\n\\begin{verbatim}\n   SPEC : term -> thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\n\\label{avra_spec}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn \\uquant{x}t\\over \\Gamma\\turn t[t'/x]$$\n\\begin{itemize}\n\\item $t[t'/x]$ denotes the result of substituting $t'$ for free\\index{free variables, in HOL logic@free variables, in \\HOL{} logic}\noccurrences of $x$ in $t$, with the restriction that no free variables in $t'$\nbecome bound after substitution.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\forall = (\\lquant{P}P = (\\lquant{x}\\T))$ \\hfill\n[\\rul{INST\\_TYPE} applied to the definition of $\\forall$]\n\\item $\\Gamma\\turn \\forall(\\lquant{x}t)$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn (\\lquant{P}P=(\\lquant{x}\\T))(\\lquant{x}t)$\\hfill\n[\\rul{SUBST} 1,2]\n\\item $\\turn  (\\lquant{P}P=(\\lquant{x}\\T))(\\lquant{x}t) =\n((\\lquant{x}t)=(\\lquant{x}\\T))$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\Gamma\\turn (\\lquant{x}t)=(\\lquant{x}\\T)$\\hfill [\\rul{EQ\\_MP} 4,3]\n\\item $\\Gamma\\turn (\\lquant{x}t)\\ t' = (\\lquant{x}\\T)\\ t'$ \\hfill\n[\\rul{AP\\_THM} 5]\n\\item $\\turn (\\lquant{x}t)\\ t' = t[t'/x]$ \\hfill [\\rul{BETA\\_CONV}]\n\\item $\\Gamma\\turn t[t'/x] = (\\lquant{x}t)\\ t'$ \\hfill [\\rul{SYM} 7]\n\\item $\\Gamma\\turn t[t'/x] = (\\lquant{x}\\T)\\ t'$ \\hfill [\\rul{TRANS} 8,6]\n\\item $\\turn (\\lquant{x}\\T)\\ t' = \\T$ \\hfill [\\rul{BETA\\_CONV}]\n\\item $\\Gamma\\turn t[t'/x] = \\T$ \\hfill [\\rul{TRANS} 9,10]\n\\item $\\Gamma\\turn t[t'/x]$ \\hfill [\\rul{EQT\\_ELIM} 11]\n\\end{proof}\n\n\n\n\n\\subsection{Equality-with-\\T\\ introduction}\n\n\\begin{holboxed}\n\\index{EQT_INTRO@\\ml{EQT\\_INTRO}|pin}\n\\begin{verbatim}\n   EQT_INTRO : thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t\\over\\Gamma\\turn t=\\T$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn\\uquant{b_1\\ b_2}(b_1\\imp b_2)\\imp(b_2\\imp b_1)\\imp(b_1=b_2)$\n\\hfill [Axiom]\n\\item $\\turn\\uquant{b_2}(t\\imp b_2)\\imp(b_2\\imp t)\\imp(t=b_2)$\n\\hfill [\\rul{SPEC} 1]\n\\item $\\turn(t\\imp\\T)\\imp(\\T\\imp t)\\imp(t=\\T)$\\hfill [\\rul{SPEC} 2]\n\\item $\\turn\\T$\\hfill [\\rul{TRUTH}]\n\\item $\\turn t\\imp\\T$\\hfill [\\rul{DISCH} 4]\n\\item $\\turn(\\T\\imp t)\\imp(t=\\T)$\\hfill [\\rul{MP} 3,5]\n\\item $\\Gamma \\turn t$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn\\T\\imp t$\\hfill [\\rul{DISCH} 7]\n\\item $\\Gamma\\turn t=\\T$\\hfill [\\rul{MP} 6,8]\n\\end{proof}\n\\index{equality, in HOL logic@equality, in \\HOL{} logic!other rules for|)}\n\\index{T@\\holtxt{T}!rules of inference for|)}\n\n\n\\subsection{\\texorpdfstring{Generalization ($\\forall$-introduction)}{Generalization (forall-introduction)}}%\n\\index{universal quantifier, in HOL logic@universal quantifier, in \\HOL{} logic!inference rules for}\n\n\n\\begin{holboxed}\n\\index{GEN@\\ml{GEN}|pin}\n\\index{generalization rule, in HOL logic@generalization rule, in \\HOL{} logic}\n\\begin{verbatim}\n   GEN : term -> thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\n\\label{avra_gen}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t\\over\\Gamma\\turn\\uquant{x} t$$\n\\begin{itemize}\n\\item Where $x$ is not free in $\\Gamma$.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn t = \\T$\\hfill [\\rul{EQT\\_INTRO} 1]\n\\item $\\Gamma\\turn(\\lquant{x}t)=(\\lquant{x}\\T)$\\hfill [\\rul{ABS} 2]\n\\item $\\turn \\forall(\\lquant{x}t) = \\forall(\\lquant{x}t)$\\hfill [\\rul{REFL}]\n\\item $\\turn \\forall = (\\lquant{P} P =(\\lquant{x}\\T))$\\hfill\n[\\rul{INST\\_TYPE} applied to the definition of $\\forall$]\n\\item $\\turn\\forall(\\lquant{x}t)=(\\lquant{P} P=(\\lquant{x}\\T))(\\lquant{x}t)$\n\\hfill [\\rul{SUBST} 5,4]\n\\item $\\turn(\\lquant{P} P=(\\lquant{x}\\T))(\\lquant{x}t)=((\\lquant{x}t)\n=(\\lquant{x}\\T))$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\turn\\forall(\\lquant{x}t) = ((\\lquant{x}t)=(\\lquant{x}\\T))$\n\\hfill [\\rul{TRANS} 6,7]\n\\item $\\turn((\\lquant{x}t)=(\\lquant{x}\\T)) = \\forall(\\lquant{x}\\T)$\n\\hfill [\\rul{SYM} 8]\n\\item $\\Gamma\\turn\\forall(\\lquant{x}t)$\\hfill [\\rul{EQ\\_MP} 9,3]\n\\end{proof}\n\n\n\n\\subsection{\\texorpdfstring{Simple $\\alpha$-conversion}{Simple alpha-conversion}}\n\n\\begin{holboxed}\n\\begin{verbatim}\n   SIMPLE_ALPHA\n\\end{verbatim}\n\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\turn(\\lquant{x_1}t\\ x_1) = (\\lquant{x_2}t\\ x_2)$$\n\\begin{itemize}\n\\item Where neither $x_1$ nor $x_2$ occurs free in $t$.\\footnote{\\ml{SIMPLE\\_ALPHA} is\nincluded here because it is\nused in a subsequent derivation, but it is not actually in the\n\\HOL\\ system, as it is subsumed by other functions.}\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item$\\turn(\\lquant{x_1}t\\ x_1)\\ x = t\\ x$\\hfill [\\rul{BETA\\_CONV}]\n\\item$\\turn(\\lquant{x_2}t\\ x_2)\\ x = t\\ x$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\turn t\\ x = (\\lquant{x_2}t\\ x_2)\\ x$\\hfill [\\rul{SYM} 2]\n\\item $\\turn (\\lquant{x_1}t\\ x_1)\\ x = (\\lquant{x_2}t\\ x_2)\\ x$\n\\hfill [\\rul{TRANS} 1,3]\n\\item $\\turn(\\lquant{x}(\\lquant{x_1}t\\ x_1)\\ x) =\n(\\lquant{x}(\\lquant{x_2}t\\ x_2)\\ x)$\\hfill [\\rul{ABS} 4]\n\\item $\\turn\\uquant{f}(\\lquant{x}f\\ x) = f$\\hfill\n[Appropriately type-instantiated axiom]\n\\item $\\turn(\\lquant{x}(\\lquant{x_1}t\\ x_1)x) = \\lquant{x_1}t\\ x_1$\n\\hfill [\\rul{SPEC} 6]\n\\item $\\turn(\\lquant{x}(\\lquant{x_2}t\\ x_2)x) = \\lquant{x_2}t\\ x_2$\n\\hfill [\\rul{SPEC} 6]\n\\item $\\turn (\\lquant{x_1}t\\ x_1) = (\\lquant{x}(\\lquant{x_1}t\\ x_1)x)$\n\\hfill [\\rul{SYM} 7]\n\\item $\\turn (\\lquant{x_1}t\\ x_1) = (\\lquant{x}(\\lquant{x_2}t\\ x_2)x)$\n\\hfill [\\rul{TRANS} 9,5]\n\\item $\\turn(\\lquant{x_1}t\\ x_1)=(\\lquant{x_2}t\\ x_2)$\\hfill\n[\\rul{TRANS} 10,8]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{$\\eta$-conversion}{Eta-conversion}}\n\n\\begin{holboxed}\n\\index{ETA_CONV@\\ml{ETA\\_CONV}|pin}\n\\begin{verbatim}\n   ETA_CONV : conv\n\\end{verbatim}\n\\end{holboxed}\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\turn(\\lquant{x'}t\\ x') = t$$\n\\begin{itemize}\n\\item Where $x'$ does not occur free\\index{free variables, in HOL logic@free variables, in \\HOL{} logic} in $t$ (we use $x'$ rather than just $x$\nto motivate the use of \\rul{SIMPLE\\_ALPHA} in the derivation below).\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn\\uquant{f}(\\lquant{x}f\\ x) = f$\\hfill\n[Appropriately type-instantiated axiom]\n\\item  $\\turn(\\lquant{x}t\\ x) = t$\\hfill [\\rul{SPEC} 1]\n\\item $\\turn(\\lquant{x'}t\\ x')=(\\lquant{x}t\\ x)$\\hfill [\\rul{SIMPLE\\_ALPHA}]\n\\item $\\turn(\\lquant{x'}t\\ x')=t$\\hfill [\\rul{TRANS} 3,2]\n\\end{proof}\n\n\n\n\\subsection{Extensionality}\n\\index{universal quantifier, in HOL logic@universal quantifier, in \\HOL{} logic!inference rules for}\n\n\\begin{holboxed}\n\\index{EXT@\\ml{EXT}|pin}\n\\index{extensionality rule, in HOL logic@extensionality rule, in \\HOL{} logic}\n\\begin{verbatim}\n   EXT : thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn\\uquant{x} t_1\\ x = t_2\\ x\\over\\Gamma\\turn t_1=t_2$$\n\\begin{itemize}\n\\item Where $x$ is not free\\index{free variables, in HOL logic@free variables, in \\HOL{} logic} in $t_1$ or $t_2$.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn\\uquant{x}t_1\\ x=t_2\\ x$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn t_1\\ x'=t_2\\ x'$\\hfill [\\rul{SPEC} 1 ($x'$ is a fresh)]\n\\item $\\Gamma\\turn(\\lquant{x'}t_1\\ x') = (\\lquant{x'}t_2\\ x')$\\hfill\n        [\\rul{ABS} 2]\n\\item $\\turn(\\lquant{x'}t_1\\ x') = t_1$\\hfill [\\rul{ETA\\_CONV}]\n\\item $\\turn t_1 = (\\lquant{x'}t_1\\ x')$\\hfill [\\rul{SYM} 4]\n\\item $\\Gamma\\turn t_1 = (\\lquant{x'}t_2\\ x')$\\hfill [\\rul{TRANS} 5,3]\n\\item $\\turn(\\lquant{x'}t_2\\ x') = t_2$\\hfill [\\rul{ETA\\_CONV}]\n\\item $\\Gamma\\turn t_1=t_2$\\hfill [\\rul{TRANS} 6,7]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{$\\hilbert$-introduction}{Hilbert-introduction}}\n\n\\begin{holboxed}\n\\index{choice operator, in HOL logic@choice operator, in \\HOL{} logic!inference rules for}\n\\index{SELECT_INTRO@\\ml{SELECT\\_INTRO}|pin}\n\\begin{verbatim}\n   SELECT_INTRO : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1\\ t_2\\over\\Gamma\\turn t_1(\\hilbert\\ t_1)$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn\\uquant{P\\ x}P\\ x\\imp P(\\hilbert\\ P)$\\hfill [Suitably\ntype-instantiated axiom]\n\\item $\\turn t_1\\ t_2 \\imp t_1(\\hilbert\\ t_1)$\\hfill [\\rul{SPEC} 1 (twice)]\n\\item $\\Gamma\\turn t_1\\ t_2$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn t_1(\\hilbert\\ t_1)$\\hfill [\\rul{MP} 2,3]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{$\\hilbert$-elimination}{Hilbert-elimination}}\n\n\\begin{holboxed}\n\\index{choice operator, in HOL logic@choice operator, in \\HOL{} logic!inference rules for}\n\\index{SELECT_ELIM@\\ml{SELECT\\_ELIM}|pin}\n\\begin{verbatim}\n   SELECT_ELIM : thm -> (term # thm) -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma_1\\turn t_1(\\hilbert\\ t_1)\\qquad\\qquad\\qquad\\Gamma_2,\\ t_1\\ v\\turn t\n\\over \\Gamma_1\\cup\\Gamma_2\\turn t$$\n\\begin{itemize}\n\\item Where $v$ occurs nowhere except in the assumption $t_1\\ v$ of the second\nhypothesis.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma_2,\\ t_1\\ v\\turn t$ \\hfill [Hypothesis]\n\\item $\\Gamma_2\\turn t_1\\ v\\imp t$\\hfill [\\rul{DISCH} 1]\n\\item $\\Gamma_2\\turn\\uquant{v}t_1\\ v\\imp t$\\hfill [\\rul{GEN} 2]\n\\item $\\Gamma_2\\turn t_1(\\hilbert\\ t_1)\\imp t$\\hfill [\\rul{SPEC} 3]\n\\item $\\Gamma_1\\turn t_1(\\hilbert\\ t_1)$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\cup\\Gamma_2\\turn t$\\hfill [\\rul{MP} 4,5]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{$\\exists$-introduction}{Exists-introduction}}\n\\index{existential quantifier, in HOL logic@existential quantifier, in \\HOL{} logic!inference rules for|(}\n\n\\begin{holboxed}\n\\index{EXISTS@\\ml{EXISTS}|pin}\n\\begin{verbatim}\n   EXISTS : (term # term) -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1[t_2]\\over \\Gamma\\turn \\equant{x}t_1[x]$$\n\\begin{itemize}\n\\item Where $t_1[t_2]$ denotes a term $t_1$ with some free\\index{free variables, in HOL logic@free variables, in \\HOL{} logic}\noccurrences of $t_2$\nsingled out, and $t_1[x]$ denotes the result of replacing these\noccurrences of $t_1$ by $x$, subject to the restriction that $x$\ndoesn't become bound after substitution.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn(\\lquant{x}t_1[x])t_2= t_1[t_2]$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\turn t_1[t_2] = (\\lquant{x}t_1[x])t_2$\\hfill [\\rul{SYM} 1]\n\\item $\\Gamma\\turn t_1[t_2]$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn(\\lquant{x}t_1[x])t_2$\\hfill [\\rul{EQ\\_MP} 2,3]\n\\item $\\Gamma\\turn(\\lquant{x}t_1[x])(\\hilbert(\\lquant{x}t_1[x]))$\\hfill\n[\\rul{SELECT\\_INTRO} 4]\n\\item $\\turn \\exists = \\lquant{P} P(\\hilbert\\ P)$\\hfill\n[\\rul{INST\\_TYPE} applied to the definition of $\\exists$]\n\\item $\\turn\\exists(\\lquant{x}t_1[x]) =\n(\\lquant{P}P(\\hilbert\\ P))(\\lquant{x}t_1[x])$\\hfill [\\rul{AP\\_THM} 6]\n\\item $\\turn(\\lquant{P}P(\\hilbert\\ P))(\\lquant{x}t_1[x]) =\n(\\lquant{x}t_1[x])(\\hilbert(\\lquant{x}t_1[x]))$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\turn\\exists(\\lquant{x}t_1[x]) =\n(\\lquant{x}t_1[x])(\\hilbert(\\lquant{x}t_1[x]))$\\hfill [\\rul{TRANS} 7,8]\n\\item $\\turn(\\lquant{x}t_1[x])(\\hilbert(\\lquant{x}t_1[x])) =\n\\exists(\\lquant{x}t_1[x])$\\hfill [\\rul{SYM} 9]\n\\item $\\Gamma\\turn\\exists(\\lquant{x}t_1[x])$\\hfill [\\rul{EQ\\_MP} 10,5]\n\\end{proof}\n\n\n\n\\subsection{\\texorpdfstring{$\\exists$-elimination}{Exists-elimination}}\n\n\\begin{holboxed}\n\\index{CHOOSE@\\ml{CHOOSE}|pin}\n\\begin{verbatim}\n   CHOOSE : (term # thm) -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma_1\\turn\\equant{x}t[x]\\qquad\\qquad\\qquad \\Gamma_2,\\ t[v]\\turn t'\n\\over \\Gamma_1\\cup\\Gamma_2\\turn t'$$\n\\begin{itemize}\n\\item Where $t[v]$ denotes a term $t$ with some free\\index{free variables, in HOL logic@free variables, in \\HOL{} logic}\noccurrences of the variable $v$\nsingled out, and $t[x]$ denotes the result of replacing these\noccurrences of $v$ by $x$, subject to the restriction that $x$ doesn't become\nbound after substitution.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\exists = \\lquant{P} P(\\hilbert\\ P)$\\hfill\n[\\rul{INST\\_TYPE} applied to the definition of $\\exists$]\n\\item $\\turn\\exists(\\lquant{x}t[x]) =\n(\\lquant{P}P(\\hilbert\\ P))(\\lquant{x}t[x])$\\hfill [\\rul{AP\\_THM} 1]\n\\item $\\Gamma_1\\turn\\exists(\\lquant{x}t[x])$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\turn (\\lquant{P}P(\\hilbert\\ P))(\\lquant{x}t[x])$\n\\hfill [\\rul{EQ\\_MP} 2,3]\n\\item $\\turn(\\lquant{P}P(\\hilbert\\ P))(\\lquant{x}t[x]) =\n(\\lquant{x}t[x])(\\hilbert(\\lquant{x}t[x]))$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\Gamma_1\\turn(\\lquant{x}t[x])(\\hilbert(\\lquant{x}t[x])$\\hfill\n[\\rul{EQ\\_MP} 5,4]\n\\item $\\turn(\\lquant{x}t[x])v = t[v]$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\turn t[v] =(\\lquant{x}t[x])v$\\hfill [\\rul{SYM} 7]\n\\item $\\Gamma_2,\\ t[v]\\turn t'$\\hfill [Hypothesis]\n\\item $\\Gamma_2\\turn t[v]\\imp t'$\\hfill [\\rul{DISCH} 9]\n\\item $\\Gamma_2\\turn(\\lquant{x}t[x])v\\imp t'$\\hfill [\\rul{SUBST} 8,10]\n\\item $\\Gamma_2,\\ (\\lquant{x}t[x])v\\turn t'$\\hfill [\\rul{UNDISCH} 11]\n\\item $\\Gamma_1\\cup\\Gamma_2\\turn t'$\\hfill [\\rul{SELECT\\_ELIM} 6,12]\n\\end{proof}\n\\index{existential quantifier, in HOL logic@existential quantifier, in \\HOL{} logic!inference rules for|)}\n\n\\subsection{Use of a definition}\n\n\\begin{holboxed}\n\\index{RIGHT_BETA@\\ml{RIGHT\\_BETA}|pin}\n\\begin{verbatim}\n   RIGHT_BETA : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t = \\lquant{x}t'[x]\n\\over \\Gamma\\turn t\\ t = t'[t]$$\n\\begin{itemize}\n\\item Where  $t$ does not contain $x$.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t = \\lquant{x} t'[x]$\\hfill\n[Suitably type-instantiated hypothesis]\n\\item $\\Gamma\\turn t\\ t =\n(\\lquant{x}t'[x])\\ t$\\hfill\n[\\rul{AP\\_THM} 1 ]\n\\item $\\turn(\\lquant{x}t'[x])\\ t =\nt'[t]$\\hfill [\\rul{BETA\\_CONV}]\n\\item $\\Gamma\\turn t\\ t = t'[t]$\\hfill\n[\\rul{TRANS} 2,3]\n\\end{proof}\n\n\n\\subsection{Use of a definition}\n\n\\begin{holboxed}\n\\index{RIGHT_LIST_BETA@\\ml{RIGHT\\_LIST\\_BETA}|pin}\n\\begin{verbatim}\n   RIGHT_LIST_BETA : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t = \\lquant{x_1\\cdots x_n}t'[x_1,\\ldots,x_n]\n\\over \\Gamma\\turn t\\ t_1\\cdots t_n = t'[t_1,\\ldots,t_n]$$\n\\begin{itemize}\n\\item Where none of the $t_i$ contain any of the $x_i$.\n\\end{itemize}\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\Gamma\\turn t = \\lquant{x_1\\cdots x_n} t'[x_1,\\ldots,x_n]$\\hfill\n[Suitably type-instantiated hypothesis]\n\\item $\\Gamma\\turn t\\ t_1\\cdots t_n =\n(\\lquant{x_1\\cdots x_n}t'[x_1,\\ldots,x_n])\\ t_1\\cdots t_n$\\hfill\n[\\rul{AP\\_THM} 1 (n times)]\n\\item $\\turn(\\lquant{x_1\\cdots x_n}t'[x_1,\\ldots,x_n])\\ t_1\\cdots t_n =\nt'[t_1,\\ldots,t_n]$\\hfill [\\rul{BETA\\_CONV} (n times)]\n\\item $\\Gamma\\turn t\\ t_1\\cdots t_n = t'[t_1,\\ldots,t_n]$\\hfill\n[\\rul{TRANS} 2,3]\n\\end{proof}\n\n\n\n\n\n\\subsection{\\texorpdfstring{$\\wedge$-introduction}{Conjunction-introduction}}\n\\label{avra_conj}\n\n\n\\begin{holboxed}\n\\index{CONJ@\\ml{CONJ}|pin}\n\\index{conjunction, in HOL logic@conjunction, in \\HOL{} logic!inference rule for}\n\\begin{verbatim}\n   CONJ : thm -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma_1\\turn t_1\\qquad\\qquad\\qquad\\Gamma_2\\turn t_2\\over\n\\Gamma_1\\cup\\Gamma_2 \\turn t_1\\conj t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\conj = \\lquant{b_1\\ b_2}\\uquant{b}(b_1\\imp(b_2\\imp b))\\imp b$\n\\hfill [Definition of $\\conj$]\n\\item $\\turn t_1\\conj t_2 = \\uquant{b}(t_1\\imp(t_2\\imp b))\\imp b$\\hfill\n[\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $t_1\\imp(t_2\\imp b)\\turn t_1\\imp(t_2\\imp b)$\\hfill [\\rul{ASSUME}]\n\\item $\\Gamma_1\\turn t_1$\\hfill [Hypothesis]\n\\item $\\Gamma_1,\\ t_1\\imp(t_2\\imp b)\\turn t_2\\imp b$\\hfill [\\rul{MP} 3,4]\n\\item $\\Gamma_2\\turn t_2$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\cup\\Gamma_2,\\ t_1\\imp(t_2\\imp b)\\turn b$\\hfill [\\rul{MP} 5,6]\n\\item $\\Gamma_1\\cup \\Gamma_2\\turn(t_1\\imp(t_2\\imp b))\\imp b$\\hfill\n[\\rul{DISCH} 7]\n\\item $\\Gamma_1\\cup \\Gamma_2\\turn \\uquant{b}(t_1\\imp(t_2\\imp b))\\imp b$\\hfill\n[\\rul{GEN} 8]\n\\item $\\Gamma_1\\cup \\Gamma_2\\turn t_1\\conj t_2$\\hfill\n[\\rul{EQ\\_MP} (\\rul{SYM} 2),9]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{$\\wedge$-elimination}{Conjunction-elimination}}\n\n\n\\begin{holboxed}\n\\index{CONJUNCT1@\\ml{CONJUNCT1}|pin}\n\\index{CONJUNCT2@\\ml{CONJUNCT2}|pin}\n\\begin{verbatim}\n   CONJUNCT1 : thm -> thm, CONJUNCT2 : thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1\\conj t_2\\over\n\\Gamma\\turn t_1\\qquad\\qquad\\qquad \\Gamma\\turn t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\conj = \\lquant{b_1\\ b_2}\\uquant{b}(b_1\\imp(b_2\\imp b))\\imp b$\n\\hfill [Definition of $\\conj$]\n\\item $\\turn t_1\\conj t_2 = \\uquant{b}(t_1\\imp(t_2\\imp b))\\imp b$\\hfill\n[\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $\\Gamma\\turn t_1\\conj t_2$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn \\uquant{b}(t_1\\imp(t_2\\imp b))\\imp b$\\hfill\n[\\rul{EQ\\_MP} 2,3]\n\\item $\\Gamma\\turn (t_1\\imp(t_2\\imp t_1))\\imp t_1$\\hfill [\\rul{SPEC} 4]\n\\item $t_1\\turn t_1$\\hfill [\\rul{ASSUME}]\n\\item $t_1 \\turn t_2\\imp t_1$\\hfill [\\rul{DISCH} 6]\n\\item $\\turn t_1\\imp(t_2\\imp t_1)$\\hfill [\\rul{DISCH} 7]\n\\item $\\Gamma\\turn t_1$\\hfill [\\rul{MP} 5,8]\n\\item $\\Gamma\\turn (t_1\\imp(t_2\\imp t_2))\\imp t_2$\\hfill [\\rul{SPEC} 4]\n\\item $t_2\\turn t_2$\\hfill [\\rul{ASSUME}]\n\\item $\\turn t_2\\imp t_2$\\hfill [\\rul{DISCH} 11]\n\\item $\\turn t_1\\imp(t_2\\imp t_2)$\\hfill [\\rul{DISCH} 12]\n\\item $\\Gamma\\turn t_2$\\hfill [\\rul{MP} 10,13]\n\\item $\\Gamma\\turn t_1$ and $\\Gamma\\turn t_2$\\hfill [9,14]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{Right $\\vee$-introduction}{Right disjunction-introduction}}\\index{disjunction, in HOL logic@disjunction, in \\HOL{} logic!inference rule for|(}\n\n\\begin{holboxed}\n\\index{DISJ1@\\ml{DISJ1}|pin}\n\\begin{verbatim}\n   DISJ1 : thm -> conv\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1\\over \\Gamma\\turn t_1\\disj t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\disj =\n\\lquant{b_1\\ b_2}\\uquant{b}(b_1\\imp b)\\imp(b_2\\imp b)\\imp b$\n\\hfill [Definition of $\\disj$]\n\\item $\\turn t_1\\disj t_2 = \\uquant{b}(t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\n\\hfill [\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $\\Gamma\\turn t_1$\\hfill [Hypothesis]\n\\item $t_1\\imp b\\turn t_1\\imp b$\\hfill [\\rul{ASSUME}]\n\\item $\\Gamma,\\ t_1\\imp b\\turn b$\\hfill [\\rul{MP} 4,3]\n\\item $\\Gamma,\\ t_1\\imp b\\turn(t_2\\imp b)\\imp b$\\hfill [\\rul{DISCH} 5]\n\\item $\\Gamma\\turn (t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\\hfill [\\rul{DISCH} 6]\n\\item $\\Gamma\\turn \\uquant{b}(t_1\\imp b)\n\\imp(t_2\\imp b)\\imp b$\\hfill [\\rul{GEN} 7]\n\\item $\\Gamma\\turn t_1\\disj t_2$\\hfill [\\rul{EQ\\_MP} (\\rul{SYM} 2),8]\n\\end{proof}\n\n\n\n\n\\subsection{\\texorpdfstring{Left $\\vee$-introduction}{Left disjunction-introduction}}\n\n\n\\begin{holboxed}\n\\index{DISJ2@\\ml{DISJ2}|pin}\n\\begin{verbatim}\n   DISJ2 : term -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_2\\over \\Gamma\\turn t_1\\disj t_2$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\disj =\n\\lquant{b_1\\ b_2}\\uquant{b}(b_1\\imp b)\\imp(b_2\\imp b)\\imp b$\n\\hfill [Definition of $\\disj$]\n\\item $\\turn t_1\\disj t_2 = \\uquant{b}(t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\n\\hfill [\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $\\Gamma\\turn t_2$\\hfill [Hypothesis]\n\\item $t_2\\imp b\\turn t_2\\imp b$\\hfill [\\rul{ASSUME}]\n\\item $\\Gamma,\\ t_2\\imp b\\turn b$\\hfill [\\rul{MP} 4,3]\n\\item $\\Gamma\\turn(t_2\\imp b)\\imp b$\\hfill [\\rul{DISCH} 5]\n\\item $\\Gamma\\turn (t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\\hfill [\\rul{DISCH} 6]\n\\item $\\Gamma\\turn \\uquant{b}(t_1\\imp b)\n\\imp(t_2\\imp b)\\imp b$\\hfill [\\rul{GEN} 7]\n\\item $\\Gamma\\turn t_1\\disj t_2$\\hfill [\\rul{EQ\\_MP} (\\rul{SYM} 2),8]\n\\end{proof}\n\n\n\\subsection{\\texorpdfstring{$\\vee$-elimination}{Disjunction-elimination}}\n\n\\begin{holboxed}\n\\index{DISJ_CASES@\\ml{DISJ\\_CASES}|pin}\n\\begin{verbatim}\n   DISJ_CASES : thm -> thm -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma\\turn t_1\\disj t_2\\qquad\\qquad\\qquad\\Gamma_1,\\ t_1\\turn t\n\\qquad\\qquad\\qquad \\Gamma_2,\\ t_2\\turn t\\over\n\\Gamma\\cup\\Gamma_1\\cup\\Gamma_2\\turn t$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\disj =\n\\lquant{b_1\\ b_2}\\uquant{b}(b_1\\imp b)\\imp(b_2\\imp b)\\imp b$\n\\hfill [Definition of $\\disj$]\n\\item $\\turn t_1\\disj t_2 = \\uquant{b}(t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\n\\hfill [\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $\\Gamma\\turn t_1\\disj t_2$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn\\uquant{b}(t_1\\imp b)\\imp(t_2\\imp b)\\imp b$\\hfill\n[\\rul{EQ\\_MP} 2,3]\n\\item $\\Gamma\\turn(t_1\\imp t)\\imp(t_2\\imp t)\\imp t$\\hfill [\\rul{SPEC} 4]\n\\item $\\Gamma_1,\\ t_1\\turn t$\\hfill [Hypothesis]\n\\item $\\Gamma_1\\turn t_1\\imp t$\\hfill [\\rul{DISCH} 6]\n\\item $\\Gamma\\cup \\Gamma_1\\turn (t_2\\imp t)\\imp t$\\hfill [\\rul{MP} 5,7]\n\\item $\\Gamma_2,\\ t_2\\turn t$\\hfill [Hypothesis]\n\\item $\\Gamma_2\\turn t_2\\imp t$\\hfill [\\rul{DISCH} 9]\n\\item $\\Gamma\\cup \\Gamma_1\\cup \\Gamma_2\\turn t$\\hfill [\\rul{MP} 8,10]\n\\end{proof}\n\\index{disjunction, in HOL logic@disjunction, in \\HOL{} logic!inference rule for|)}\n\n\n\n\n\\subsection{Classical contradiction rule}\n\\index{F (falsity), the HOL constant@\\holtxt{F} (falsity), the \\HOL{} constant!rules of inference for}\n\n\\begin{holboxed}\n\\index{CCONTR@\\ml{CCONTR}|pin}\n\\index{contradiction rule, in HOL logic@contradiction rule, in \\HOL{} logic}\n\\begin{verbatim}\n   CCONTR : term -> thm -> thm\n\\end{verbatim}\\end{holboxed}\n\n\\vspace{12pt plus2pt minus1pt}\n\n$$\\Gamma,\\ \\neg t\\turn \\F\\over \\Gamma\\turn t$$\n\n\\vspace{12pt plus2pt minus1pt}\n\n\\begin{proof}\n\\item $\\turn \\neg = \\lquant{b}b\\imp\\F$\\hfill [Definition of $\\neg$]\n\\item $\\turn \\neg t = t\\imp\\F$\\hfill [\\rul{RIGHT\\_LIST\\_BETA} 1]\n\\item $\\Gamma,\\ \\neg t\\turn\\F$\\hfill [Hypothesis]\n\\item $\\Gamma\\turn \\neg t\\imp\\F$\\hfill  [\\rul{DISCH} 3]\n\\item $\\Gamma\\turn (t\\imp\\F)\\imp\\F$\\hfill [\\rul{SUBST} 2,4]\n\\item $t = \\F\\turn t = \\F$\\hfill [\\rul{ASSUME}]\n\\item $\\Gamma,\\ t=\\F\\turn (\\F\\imp\\F)\\imp\\F$\\hfill [\\rul{SUBST} 6,5]\n\\item $\\F\\turn\\F$\\hfill [\\rul{ASSUME}]\n\\item $\\turn \\F\\imp\\F$\\hfill [\\rul{DISCH} 8]\n\\item $\\Gamma,\\ t=\\F\\turn\\F$\\hfill [\\rul{MP} 7,9]\n\\item $\\turn \\F = \\uquant{b}b$\\hfill [Definition of $\\F$]\n\\item $\\Gamma,\\ t=\\F\\turn \\uquant{b}b$\\hfill [\\rul{SUBST} 11,10]\n\\item $\\Gamma,\\ t=\\F\\turn t$\\hfill [\\rul{SPEC} 12]\n\\item $\\turn \\uquant{b} (b = \\T)\\disj(b = \\F)$\\hfill [Axiom]\n\\item $\\turn (t = \\T)\\disj(t = \\F)$\\hfill [\\rul{SPEC} 14]\n\\item $t=\\T\\turn t=\\T$\\hfill [\\rul{ASSUME}]\n\\item $t=\\T\\turn t$\\hfill [\\rul{EQT\\_ELIM} 16]\n\\item $\\Gamma\\turn t$\\hfill [\\rul{DISJ\\_CASES} 15,17,13]\n\\end{proof}\n\\index{derived rules, in HOL logic@derived rules, in \\HOL{} logic!list and derivations of some|)}\n\\index{inference rules, of HOL logic@inference rules, of \\HOL{} logic!derived|)}\n\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"description\"\n%%% End:\n", "meta": {"hexsha": "20f0ce64400fc8f6724f8416cf5680d4d94b8540", "size": 48460, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manual/Description/drules.tex", "max_stars_repo_name": "LiLiming/HOL", "max_stars_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-27T07:51:47.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-27T07:51:47.000Z", "max_issues_repo_path": "Manual/Description/drules.tex", "max_issues_repo_name": "LiLiming/HOL", "max_issues_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manual/Description/drules.tex", "max_forks_repo_name": "LiLiming/HOL", "max_forks_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6886184681, "max_line_length": 170, "alphanum_fraction": 0.7013000413, "num_tokens": 17606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.43944381137318944}}
{"text": "%!TEX root = forallx-ubc.tex\n\\chapter{Entailment and Models for SL}\n\\label{ch.SLmodels}\n\nThis chapter offers a formal semantics for SL, allowing us to be more precise about the notion of truth in SL. We'll also highlight some important features of \\emph{entailment}, a key concept in formal logic.\n\nA formal, logical language is built from two kinds of elements: logical symbols and non-logical symbols. Connectives like `\\eand' and `\\eif' are logical symbols, because their meaning is specified within the formal language. When writing a symbolization key, you are not allowed to change the meaning of the logical symbols. You cannot say, for instance, that the `\\enot' symbol will mean `not' in one argument and `perhaps' in another. The `\\enot' symbol always means logical negation. It is used to translate the English language word `not', but it is a symbol of a formal language and is defined by its truth conditions.\n\nThe sentence letters in SL are non-logical symbols, because their meaning is not defined by the logical structure of SL. When we translate an argument from English to SL, for example, the sentence letter $M$ does not have its meaning fixed in advance; instead, we provide a symbolization key that says how $M$ should be interpreted in that argument.\n\nIn translating from English to a formal language, we provided symbolization keys which were interpretations of all the non-logical symbols we used in the translation. An \\define{interpretation} gives a meaning to all the non-logical elements of the language. We'll also use the term `\\define{model}' as another word for an interpretation. In our simple formal language SL, meaning is simply a matter of truth and falsity, relative to a given interpretation. These notions too need to be characterized in a formal way.\n\n%\n%\n%When we gave definitions for a sentence of SL and for a sentence of QL, we distinguished between the \\define{object language} and the \\define{metalanguage}. The object language is the language that we are \\emph{talking about}: either SL or QL. The metalanguage is the language that we use to talk about the object language: English, supplemented with some mathematical jargon. It will be important to keep this distinction in mind.\n\n\n%\\nix{box about Tarski? The logician Alfred Tarksi introduced this distinction ca.~1940. Tarski argued that the truth conditions for a language could never be expressed in the language itself --- the metalanguage needed to be more powerful than the object language. So it's simply not possible to give a definition of truth for SL that is itself a sentence of SL --- describing the semantics of SL requires a more powerful language.}\n\n\n\\section{Semantics for SL}\n\\label{sec.semanticsSL}\n\nThis section provides a rigorous, formal characterization of \\emph{truth in SL} which builds on what we already know from doing truth tables. We were able to use truth tables to reliably test whether a sentence was a tautology in SL, whether two sentences were equivalent, whether an argument was valid, and so on. For instance: \\metaA{} is a tautology in SL if and only if it is assigned `1' on every line of a complete truth table.\n\nThis worked because each line of a truth table corresponds to a way the world might be. We considered all the possible combinations of 1s and 0s for the sentence letters that made a difference to the sentences we cared about. The truth table allowed us to determine what would happen given these different combinations. An \\emph{interpretation} in SL provides a truth value to each atomic sentence in use; and every combination of truth values is represented by an interpretation.\n\n(Technical side note: one might be tempted to \\emph{identify} interpretations with assignments of truth values to atomic sentences. (In past versions of this book, that's actually what I did.) For a variety of reasons, this is not (any longer) my preference. One reason is that there can be different ways to assign truth values to atomic sentences, corresponding to one and the same row of the truth table, if one includes values for atoms that are not mentioned in the truth table. In a truth table for a sentence that doesn't include an $R$, for instance, these two assignments of truth values to atoms are effectively equivalent, and correspond to the same row of the truth table: \\{$P=1$, $Q=1$, $R=1$\\}, \\{$P=1$, $Q=1$, $R=0$\\}. So there could be different interpretations corresponding to the same row of the truth table, but an interpretation \\emph{determines} a row of a truth table.\n\nA more complex motivation for my terminological choice here has to do with the relationship between SL and QL, a more complex language we'll learn later in the textbook. I'll return to this connection in \\S\\ref{sec.0PlaceModels}.)\n\nOnce we construct a truth table, the symbols `1' and `0' are divorced from their metalinguistic meaning of `true' and `false'. We interpret `1' as meaning `true', but the formal properties of 1 are defined by the characteristic truth tables for the various connectives.  The symbols in a truth table have a formal meaning that we can specify entirely in terms of how the connectives operate. For example, if $A$ is value 1, then $\\enot A$ is value 0.\n\nTo formally define truth in SL, then, we want a function that assigns, for each interpretation, a 1 or 0 to each of the sentences of SL. We can interpret this function as a definition of truth for SL if it assigns 1 to all of the true sentences of SL and 0 to all of the false sentences of SL. Call this function `$v$' (for `valuation'). We want $v$ to be a function such that for any sentence \\metaA{}, $v(\\metaA{})=1$ if \\metaA{} is true and $v(\\metaA{})=0$ if \\metaA{} is false.\n\nRecall that the recursive definition of a wff for SL had two stages: The first step said that atomic sentences (solitary sentence letters) are wffs. The second stage allowed for wffs to be constructed out of more basic wffs. There were clauses of the definition for all of the sentential connectives. For example, if \\metaA{} is a wff, then \\enot\\metaA{} is a wff.\n\nOur strategy for defining the truth function, $v$, will also be in two steps. The first step will handle truth for atomic sentences; the second step will handle truth for compound sentences.\n\n\n\\section{Defining truth in SL}\nHow can we define truth for an atomic sentence of SL? Consider, for example, the sentence $M$. Without an interpretation, we cannot say whether $M$ is true or false. It might mean anything. If we use $M$ to symbolize `The moon orbits the Earth', then $M$ is true. If we use $M$ to symbolize `The moon is a giant turnip', then $M$ is false.\n\nWhen we give a symbolization key for SL, we provide a translation into English of the sentence letters that we use. In this way, the interpretation specifies what each of the sentence letters \\emph{means}. However, this is not enough to determine whether or not that sentence is true. The sentences about the moon, for instance, require that you know some rudimentary astronomy. Imagine a small child who became convinced that the moon is a giant turnip. She could understand what the sentence `The moon is a giant turnip' means, but mistakenly think that it was true.\n\nSo a symbolization key alone does not determine whether a sentence is true or false. Truth or falsity depends also on what the world is like. If $M$ meant `The moon is a giant turnip' and the real moon were a giant turnip, then $M$ would be true. To get a truth value via the symbolization key, one has to first translate the sentence into English, and then rely on one's knowledge of what the world is like.\n\nWe want a logical system that can proceed without astronomical investigation. Moreover, we want to abstract away from the specific commitments of a given symbolization key. So our logical definition of truth will proceed in a different way. We ignore any proffered symbolization key, and take, from a given interpretation, a \\emph{truth value assignment}. Formally, this is just a function that tells us the truth value of all the atomic sentences. Call this function `$a$' (for `assignment'). We define $a$ for all sentence letters \\script{P}, such that\n\\begin{displaymath}\na(\\script{P}) =\n\\left\\{\n\t\\begin{array}{ll}\n\t1 & \\mbox{if \\script{P} is true},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\n\\right.\n\\end{displaymath}\nThis means that $a$ takes any atomic sentence of SL and assigns it either a one or a zero; one if the sentence is true, zero if the sentence is false. \n\nYou can think of $a$ as being like a row of a truth table. Whereas a truth table row assigns a truth value to a few atomic sentences, the truth value assignment assigns a value to every atomic sentence of SL. There are infinitely many sentence letters, and the truth value assignment gives a value to each of them. When constructing a truth table, we only care about sentence letters that affect the truth value of sentences that interest us. As such, we ignore the rest.\n\nIt is important to note that the truth value assignment, $a$, is not part of the language SL. Rather, it is part of the mathematical machinery that we are using to describe SL. It encodes which atomic sentences are true and which are false.\n\n\nWe now define the truth function, $v$, using the same recursive structure that we used to define a wff of SL.\n\n\\begin{enumerate}\n\\item If \\metaA{} is a sentence letter, then $v(\\metaA{})=a(\\metaA{})$.\n%\\setcounter{Example}{\\arabic{enumi}}\\end{enumerate}\n%...\n% Break out of the {enumerate} environment to say something about what is\n% going on. Using \\setcounter in this way preserves the numbering, so\n% that the list can resume after the comments.\n\n%This is a mathematical equals sign, not the identity predicate we defined for QL.\n\n% Resume the {enumerate} environment and restore the counter.\n%...\n%\\begin{enumerate}\\setcounter{enumi}{\\arabic{Example}}\n\\item If \\metaA{} is ${\\enot}\\metaB{}$ for some sentence \\metaB{}, then\n\\begin{displaymath}v(\\metaA{}) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $v(\\metaB{}) = 0$},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eand\\metaC{})$ for some sentences \\metaB{}, \\metaC{}, then\n\\begin{displaymath}v(\\metaA{}) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $v(\\metaB{}) = 1$ and $v(\\metaC{}) = 1$,}\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\\setcounter{Example}{\\arabic{enumi}}\\end{enumerate}\n%...\n\\label{truthdefinition}\nYou may be tempted to worry that this definition is circular, because it uses the word `and' in trying to define `and.' But remember, we are not attempting to give a definition of the English word `and'; we are giving a definition of truth for sentences of SL containing the logical symbol `\\eand.' We define truth for object language sentences containing the symbol `\\eand' using the metalanguage word `and.' There is nothing circular about that.\n\n%...\n\\begin{enumerate}\\setcounter{enumi}{\\arabic{Example}}\n\\item If \\metaA{} is $(\\metaB{}\\eor\\metaC{})$ for some sentences \\metaB{}, \\metaC{}, then\n\\begin{displaymath}v(\\metaA{}) =\n\t\\left\\{\\begin{array}{ll}\n\t0 & \\mbox{if $v(\\metaB{}) = 0$ and $v(\\metaC{}) = 0$,}\\\\\n\t1 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n%\\setcounter{Example}{\\arabic{enumi}}\\end{enumerate}\n%...\n%Notice that this defines truth for sentences containing the symbol `\\eor' using the word `and.'\n%...\n%\\begin{enumerate}\\setcounter{enumi}{\\arabic{Example}}\n\\item If \\metaA{} is $(\\metaB{}\\eif\\metaC{})$ for some sentences \\metaB{}, \\metaC{}, then\n\\begin{displaymath}v(\\metaA{}) =\n\t\\left\\{\\begin{array}{ll}\n\t0 & \\mbox{if $v(\\metaB{}) = 1$ and $v(\\metaC{}) = 0$,}\\\\\n\t1 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\n\\item If \\metaA{} is $(\\metaB{}\\eiff\\metaC{})$ for some sentences \\metaB{}, \\metaC{}, then\n\\begin{displaymath}v(\\metaA{}) =\n\t\\left\\{\\begin{array}{ll}\n\t1 & \\mbox{if $v(\\metaB{}) = v(\\metaC{})$},\\\\\n\t0 & \\mbox{otherwise.}\n\t\\end{array}\\right.\n\\end{displaymath}\n\\end{enumerate}\n\nSince the definition of $v$ has the same structure as the definition of a wff, we know that $v$ assigns a value to \\emph{every} wff of SL. Since the sentences of SL and the wffs of SL are the same, this means that $v$ returns the truth value of every sentence of SL.\n\nTruth in SL is always truth \\emph{relative to} some interpretation, because the definition of truth for SL does not say whether a given sentence is true or false. Rather, it says how the truth of that sentence relates to a truth value assignment.\n\n\\section{Semantic entailment}\n\nWe are now in a position to give more precise definitions of terms like `tautology', `contradiction', and so on. Truth tables provided a way to \\emph{check} whether a sentence was a tautology in SL, but they did not \\emph{define} what it means to be a tautology in SL. We will give definitions of these concepts for SL in terms of \\define{entailment}.\n\nThe relation of semantic entailment is about satisfiability --- that is, whether there is any possible interpretation that meets a certain set of conditions. `\\metaA{} entails \\metaB{}', means that there is no interpretation for which \\metaA{} is true and \\metaB{} is false. An interpretation provides a valuation function that gives truth values to atomic sentences; so \\metaA{} entails \\metaB{} if and only if every assignment of truth values to atomic sentences that makes \\metaA{} true also makes \\metaB{} true. (We could just as well say that  `\\metaA{} entails \\metaB{}', means that there is no \\emph{valuation function} that makes \\metaA{} true and \\metaB{} false. Interpretations specify valuation functions.)\n\nWe abbreviate entailment with a symbol called the \\emph{double turnstile}:\n$\\metaA{}\\models\\metaB{}$ means `\\metaA{} semantically entails \\metaB{}.'\n\nThe double turnstile, like `\\metaA{}', etc., is part of the \\emph{metalanguage} we use to discuss SL; it is not part of SL itself.\n\n\\section{Entailment, validity, and informally good arguments}\n\nEntailment is a formal notion. It is connected in important ways to the informal notion of a good argument, but when considering entailment in SL, it is important to remember to apply the definitions rigorously and precisely, rather than relying on your sense of whether the argument is a good one. The notions can come apart in some surprising ways.\n\nLet's start with a straightforward example. Consider whether this entailment claim is true: $$(P\\eand Q) \\models (P\\eor Q)$$ This is true if and only if every interpretation that satisfies $(P\\eand Q)$, also satisfies  $(P\\eor Q)$. Hopefully it is obvious to you that this is true. Only an interpretation that assigns 1 to both $P$ and $Q$ will satisfy the left, and any such interpretation will certainly satisfy the right as well. (You could draw the truth table to verify this if you want the practice.) So, as one might naturally expect, $(P\\eand Q) \\models (P\\eor Q)$.\n\nHere is a less intuitive example. What should we make of this claim?\n\n\\begin{quote}\n$(P\\eand Q) \\models (A\\eiff\\enot\\enot A)$\n\\end{quote}\n\nNotice that the sentence letters on the left-hand-side here are completely different letters from those on the right-hand-side. So there is a straightforward sense in which the two sides of the turnstile have \\emph{nothing to do with one another}. Nevertheless, this \\emph{is} a true entailment claim. This is because it satisfies the definition: every interpretation that satisfies the left (i.e., every interpretation with a valuation function assigns `1' to both $P$ and $Q$), also satisfies $(A\\eiff\\enot\\enot A)$. This for the simple reason that every valuation \\emph{whatsoever} satisfies $(A\\eiff\\enot\\enot A)$; it is a tautology.\n\nFrom this example we can see that a tautology will be entailed by anything whatsoever. If the right-hand-side of the entailment claim is a tautology, it doesn't matter what's on the left --- you know it's going to be true.\n\nSo these are all true:\n\n\\begin{earg}\n\\item[] $P \\models (P \\eor \\enot P)$\n\\item[] $Q \\models (P \\eor \\enot P)$\n\\item[] $(P \\eand \\enot P) \\models (P \\eor \\enot P)$\n\\end{earg}\n\n\\section{Tautologies are entailed by the empty set}\n\nIn the examples so far, we've been talking about one sentence entailing another. But we can also describe a set of several sentences as jointly entailing an SL sentence: $$\\metaA{}_1,\\metaA{}_2,\\metaA{}_3,\\cdots\\models\\metaB{}$$ means that there is no truth value assignment for which all of the sentences in the set $\\{\\metaA{}_1,\\metaA{}_2,\\metaA{}_3,\\cdots\\}$ are true and \\metaB{} is false. It will sometimes be convenient to use a variable that can stand in for any set of sentences; just as `\\metaA{}' can stand for any sentence of SL, we can let `\\metaSetX{}' stand in for any set of sentences in SL. (In the case of `$\\metaA{}\\models\\metaB{}$' above, `\\metaSetX{}' is the singleton set containing just \\metaA{}.)\n\nIn general, we may say that $$\\metaSetX{}\\models\\metaB{}$$ means that there's no interpretation satisfying every member of set \\metaSetX{} without also satisfying sentence \\metaB{}.\n\nWe saw in the previous section that a tautology ---  an SL sentence that is true in every interpretation --- is entailed by any sentence. The reasoning applies more generally: a tautology will be entailed by any set of sentences. This includes the \\emph{empty set}, which can be written `$\\emptyset$'. In general `$\\metaSetX{} \\models \\metaA{}$' says that every interpretation that satisfies everything in \\metaSetX{}, satisfies \\metaA{}; in the special case where \\metaSetX{} is $\\emptyset$, every interpretation trivially satisfies everything in \\metaSetX{}. So `$\\emptyset \\models \\metaA{}$' says that absolutely every interpretation satisfies \\metaA{}. That is, it says that \\metaA{} is a tautology.\n\nBy convention, we can leave the left side of an entailment claim blank, instead of writing in $\\emptyset$. In other words, $$\\models \\metaA{} $$ is shorthand for $$ \\emptyset \\models \\metaA{}.$$\n\nSo these entailment claims are true, because in each case the sentence on the right is a tautology:\n\n\\begin{earg}\n\\item[] $\\models (P \\eor \\enot P)$\n\\item[] $\\models (P \\eiff P)$\n\\item[] $\\models ((P \\eand\\enot P)\\eif (A \\eor B))$\n\\end{earg}\n\nAnd these entailment claims are not true, because each sentence on the right is not a tautology:\n\n\\begin{earg}\n\\item[] $\\models P$\n\\item[] $\\models (P \\eand \\enot P)$\n\\item[] $\\models \\enot(P \\eif \\enot P)$\n\\end{earg}\n\n(If you need help seeing why a given sentence is or is not a tautology, draw out the truth table and check to see whether it has a 1 on every row. See \\S\\ref{sec.usingtruthtables}.)\n\n\\section{Inconsistent sentences entail absurdities}\n\nConsider this entailment claim: $$(P \\eand \\enot P) \\models Q$$This statement is true. It says that every interpretation satisfying $(P \\eand \\enot P)$ also satisfies $Q$. But $(P \\eand \\enot P)$ is a contradiction --- no interpretations satisfy it. So trivially, `every' interpretation that satisfies it satisfies $Q$.\n\nThis explanation had nothing to do with the specifics of the sentence $Q$. Exactly the same considerations would demonstrate that, for any sentence \\metaB{}, $(P \\eand \\enot P) \\models \\metaB{}$. And the same goes for any other contradictory sentence, or any set of sentences that are mutually inconsistent. These are all true:\n\n\\begin{earg}\n\\item[] $(P \\eand \\enot P) \\models (\\enot Q \\eif R)$\n\\item[] $P, (\\enot Q \\eand \\enot P) \\models (Q \\eiff P)$\n\\item[] $(P \\eand\\enot P) \\models ((A_1 \\eor A_2) \\eif \\enot (A_3 \\eiff (A_4 \\eand \\enot A_2)))$\n\\end{earg}\n\nYou can think of evaluating an entailment claim as like checking to see whether a rule is being violated or not. If there's a rule that says every student with a dog has to have a permit, you check each student with a dog, and make sure they have a permit. If you find someone without a dog, it doesn't matter whether they have a permit or not. (If you don't have a dog, you're not breaking the rule.) Or if you find someone with a permit, it doesn't matter whether they have a dog. (Nobody with a permit can be breaking the rule.) An entailment claim is like a rule that says every interpretation that satisfies the left-hand-side must also satisfy the right-hand-side. To verify it, you can ignore any interpretation that falsifies the left, or that satisfies the right.\n\nIn each of the cases above, you don't even need to examine the sentence at the right to confirm that the entailment claim is true, since you already know that no interpretations satisfy the sentences on the left. (This is analogous to knowing that no students have a dog --- in this case you don't have to check to see whether anyone has a permit to confirm that the rule is being respected.) Any entailment claim with an unsatisfiable set of sentences on the left is true. Unsatisfiable sets of sentences entail \\emph{every} sentence.\n\nWe have a special notation for describing this situation. We write: $$\\metaSetX{} \\models \\bot$$ to indicate that the set \\metaSetX{} entails an \\emph{absurdity}; think of `$\\bot$' as standing in for an arbitrary unsatisfiable SL wff. So you can think of `$\\metaSetX{} \\models \\bot$' as saying that every interpretation that satisfies $\\metaSetX{}$ satisfies the unsatisfiable. That's just another way of saying that \\emph{no} interpretation satisfies $\\metaSetX{}$. (Compare: `the only Klingons who hate honour are the Klingons who aren't Klingons at all.')\n\n%By convention, we treat $$\\metaSetX{} \\models$$ as shorthand for $$\\metaSetX{} \\models \\bot.$$ So if you see an entailment claim with nothing on the right, read it as saying that the left is unsatisfiable.\n%\\label{sec.botshorthand}\n\nSo these entailment claims are true, because the set of sentences on the left is not satisfiable:\n\n\\begin{earg}\n\\item[] $(P \\eand \\enot P) \\models \\bot$\n\\item[] $P, (\\enot Q \\eand \\enot P) \\models\\bot$\n\\item[] $(P \\eiff\\enot P) \\models\\bot$\n\\end{earg}\n\nAnd these entailment claims are not true, because the sentences on the left \\emph{can} be satisfied:\n\n\\begin{earg}\n\\item[] $(P \\eor \\enot P) \\models\\bot$\n\\item[] $P, \\enot Q, (R \\eor Q) \\models\\bot$\n\\item[] $\\enot P, \\enot Q, (P \\eif \\enot\\enot Q) \\models\\bot$\n\\end{earg}\n\n(If you need help seeing why a given set of sentences can be satisfied, draw out the truth table and check to see if any row assigns a 1 to each sentence. See \\S\\ref{sec.usingtruthtables}.)\n\n\n\n\n\\section{Defining concepts in terms of entailment}\n\n\nThe double turnstile symbol allows us to give concise definitions for various concepts in SL:\n\\begin{quote}\nA \\define{tautology in SL} is a sentence \\metaA{}  such that $\\emptyset\\models\\metaA{}$.\n\nA \\define{contradiction in SL} is a sentence \\metaA{} such that $\\metaA{}\\models\\bot$.\n\nA sentence is \\define{contingent in SL} if and only if it is neither a tautology nor a contradiction.\n\nAn argument with premises \\metaSetX{} and conclusion \\metaA{} is \\define{valid in SL} if and only if $\\metaSetX{}\\models\\metaA{}$.\n\nTwo sentences \\metaA{} and \\metaB{} are \\define{logically equivalent in SL} if and only if both $\\metaA{}\\models\\metaB{}$ and $\\metaB{}\\models\\metaA{}$.\n\nA set of sentences $\\metaSetX{}$ is \\define{inconsistent in SL} if and only if $\\metaSetX{}\\models \\bot$. Otherwise $\\metaSetX{}$ is \\define{consistent in SL}.\\label{def.consistencySL}\n\n \\end{quote}\n\n\n\n\n\\practiceproblems\n\n\n\n\\problempart\n\\label{HW3.C}\nEach of the following claims can be evaluated with truth tables. For each, what would you look for in a completed truth table to evaluate it? The Greek letters can stand for any arbitrary sentence of SL. The first claim has the answer filled out for you.\n\n\\begin{earg}\n\t\t\\item[0.] $\\Phi$ is a tautology.\n\t\tTo evaluate this claim, check to see whether the main connective of $\\Phi$ has a 1 under it in every row. If so, it is true.\n\t\t\\item $\\Phi \\models \\Psi$. \n\t\tTo evaluate this claim, check to see whether... \n\t\t\n\t\t\\item $\\Phi$ is contingent.\n\\item $\\Phi \\models \\bot$\n\t\t\\item $\\emptyset \\models \\Phi$\n\t\\end{earg}\n\n\n\\problempart\nDetermine whether each entailment claim is true. You may construct a truth table to test it if you like, but these examples are simple enough so that you may be able to just think it through and get the right answer.\n\\begin{earg}\n\\item $Q \\models (P \\eor Q)$\n\\item $P, Q \\models (P \\eor P)$\n\\item $P \\eiff Q, P \\models Q$ %  \\textcolor{red}{True.}\n\\item $S \\models (Q \\eif Q)$   %\\textcolor{red}{True.}\n\\item $P \\eand \\enot P \\models (Q \\eor \\enot Q)$%   \\textcolor{red}{True.}\n\\item $(P \\eand \\enot P) \\models (Q \\eand \\enot Q)$\n\\item $(P \\eor \\enot P) \\models \\bot$\n\\item $P \\eor \\enot P \\models Q$%   \\textcolor{red}{False: $\\{P=1, Q=0\\}$.}\n\\item $\\models (P \\eor \\enot P)$\n\\item $\\models (P \\eand \\enot P)$\n\\item $(A \\eor B) \\eif \\enot P \\models (P \\eor \\enot P)$\n\\item $(P \\eiff Q) \\models ((P \\eand Q) \\eor \\enot (P \\eor Q))$\n\\end{earg}\n\n", "meta": {"hexsha": "ba222be766af1e46bb94eb53793002c2797ba3c7", "size": 24753, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Latex-Files/forallx-ubc-4-SLmodels.tex", "max_stars_repo_name": "jonathanichikawa/for-all-x", "max_stars_repo_head_hexsha": "b7cc18e497065e45e54af30c615999941941b23d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2019-03-29T14:57:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:58:11.000Z", "max_issues_repo_path": "Latex-Files/forallx-ubc-4-SLmodels.tex", "max_issues_repo_name": "jonathanichikawa/for-all-x", "max_issues_repo_head_hexsha": "b7cc18e497065e45e54af30c615999941941b23d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2019-02-18T21:45:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-13T23:39:59.000Z", "max_forks_repo_path": "Latex-Files/forallx-ubc-4-SLmodels.tex", "max_forks_repo_name": "jonathanichikawa/for-all-x", "max_forks_repo_head_hexsha": "b7cc18e497065e45e54af30c615999941941b23d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-06-19T20:30:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T16:39:29.000Z", "avg_line_length": 82.7859531773, "max_line_length": 892, "alphanum_fraction": 0.7445562154, "num_tokens": 6559, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398982, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4394438072602434}}
{"text": "%\n% body.tex\n%\n% Copyright © 2020 Libao Jin <jinlibao@outlook.com>\n% Distributed under terms of the MIT license.\n%\nPlease note that the deadline will be enforced as per the previous homework. Remember that you are allowed to work in teams of two on this assignment. You are encouraged to prepare your work in \\LaTeX{}; a template will be provided to help you put it all together. If you choose  to submit a hard copy, you may submit only one copy for a team, indicating the names of both contributors. Online submission is encouraged, however, in that case both members of a team should submit the PDF file containing  their work and showing both their names. \\\\[20pt]\n\\textbf{Instruction}\n\\begin{enumerate}[label={\\arabic*.}]\n  \\item Go to \\url{https://www.overleaf.com} and sign in (required).\n  \\item Open \\href{https://www.overleaf.com/read/qczrkwtzpxft}{template}, click \\emph{Menu} (up left corner), then \\emph{Copy Project}.\n  \\item Go to \\verb|LaTeX/meta.tex| (the file \\verb|meta.tex| under the folder \\verb|LaTeX|) to change the section and your name, e.g.,\n    \\begin{itemize}\n      \\item change title to \\verb|\\title{MATH 3340-01 Scientific Computing Homework 3}|\n      \\item change author to \\verb|\\author{Albert Einstein \\& Carl F. Gauss}|\n    \\end{itemize}\n  \\item For Problem 1, 2, 3, you need to write function/script files, store results to output files, and save graphs to figure files. Here are suggested names for function files, script files, output files, and figure files:\n    \\begin{table}[!hbtp]\n      \\centering\n      % \\caption{caption}\n      % \\label{tab:label}\n      \\begin{tabular}{cllll}\n        \\toprule\n        Problem & Function File        & Script File     & Output File       & Figure File       \\\\\n        \\midrule\n        1       & \\verb|jacobi.m|      & \\verb|hw3_p1.m| & \\verb|hw3_p1.txt| & \\verb|hw3_p1.pdf| \\\\\n        2       & \\verb|gaussSeidel.m| & \\verb|hw3_p2.m| & \\verb|hw3_p2.txt| & \\verb|hw3_p2.pdf| \\\\\n        3       &                      & \\verb|hw3_p3.m| & \\verb|hw3_p3.txt| & \\verb|hw3_p3.pdf| \\\\\n        \\bottomrule\n      \\end{tabular}\n    \\end{table}\n\n    Once finished, you need to upload these files to the folder \\verb|src| on Overleaf. If you have different filenames, please update the filenames in \\verb|\\lstinputlisting{../src/your_script_name.m}| accordingly. You can code in the provided files in \\href{https://libaoj.in/courses/2021s/MATH3340/Homework/3/hw3.zip}{hw3.zip}, and use the MATLAB script \\verb|save_results.m| to generate the output files and store the graphs to \\verb|.pdf| files automatically (the script filenames should be exactly same as listed above).\n  \\item Recompile, download, and submit the generated PDF.\n  \\item You may find \\href{https://libaoj.in/files/LaTeX.Mathematical.Symbols.pdf}{\\LaTeX{}.Mathematical.Symbols.pdf} and the second part of \\href{https://libaoj.in/courses/2021s/MATH3341/slides/Math.3341.Lab.01.Slides.pdf}{Lab 01 Slides} and \\href{https://libaoj.in/courses/2021s/MATH3341/slides/Math.3341.Lab.02.Slides.pdf}{Lab 02 Slides} helpful.\n\\end{enumerate}\n\n\\newpage\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Problem 1\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Problem 1}%\n\\label{sec:problem_1}\nSolve, using a MATLAB code, the following system:\n\\begin{equation*}\n  \\begin{cases}\n    5x - y + z + w   = 9 \\\\\n    x + 7y + 2z + 2w = 3 \\\\\n    2x + y + 5z + w  = 7 \\\\\n    x - y + z + 4w   = 6\n  \\end{cases}\n\\end{equation*}\nUse the Jacobi method with with a tolerance of $10^{-5}$ for the norm of the residual. Arrange your results in a table of the form\n\\begin{table}[!hbtp]\n  \\centering\n  \\caption{caption}\n  \\label{tab:label}\n  \\begin{tabular}{ccccc}\n    \\toprule\n    iteration & $x$      & $y$      & $z$      & $w$      \\\\\n    \\midrule\n    $0$       & $0$      & $0$      & $0$      & $0$      \\\\\n    $1$       & $1$      & $2$      & $3$      & $4$      \\\\\n    $\\vdots$  & $\\vdots$ & $\\vdots$ & $\\vdots$ & $\\vdots$ \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\nso that you can see how $x$, $y$, $z$ and $w$ change with each iteration. You can create such a table using \\verb|disp| in a loop; you may also use variants of \\verb|printf| (in C Language), i.e., \\verb|fprintf| or \\verb|sprintf| if you are familiar with these functions, but do not use the MATLAB \\verb|table| command as it does not do quite what is expected here. Also, as obvious from the table above, start with the zero guess. Moreover, plot the norm of the residual versus the iteration number; use a logarithmic scale on the vertical axis (the residual axis). Turn in your code and the output as described. The code can be organized as:\n\\begin{enumerate}\n  \\item a function file that implements Jacobi's method; and\n  \\item a script that calls the function with with the appropriate inputs and processes the results.\\end{enumerate}\nYour plot should have a plot title, axes labels and a legend. Use the \\verb|help plot| command and the class notes  to investigate the various options  available when plotting.\n\\begin{solution}\n  \\quad\n  \\begin{itemize}\n    \\item\n      Function file \\verb|jacobi.m|\n      \\lstinputlisting[style=MATLAB]{../src/jacobi.m}\n    \\item\n      Script file \\verb|hw3_p1.m|\n      \\lstinputlisting[style=MATLAB]{../src/hw3_p1.m}\n    \\item\n      Output file \\verb|hw3_p1.txt|\n      \\lstinputlisting[style=Plain]{../src/hw3_p1.txt}\n      \\begin{figure}[!hbtp]\n        \\centering\n        \\includegraphics[width=0.8\\linewidth]{../src/hw3_p1.pdf}\n        \\caption{}%\n        \\label{fig:}\n      \\end{figure}\n  \\end{itemize}\n\\end{solution}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Problem 2\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Problem 2}%\n\\label{sec:problem_2}\nSolve again the system above, in MATLAB, using the Gauss-Seidel method. Produce the same results as for the previous problem.\n\\begin{solution}\n  \\quad\n  \\begin{itemize}\n    \\item\n      Function file \\verb|gaussSeidel.m|\n      \\lstinputlisting[style=MATLAB]{../src/gaussSeidel.m}\n    \\item\n      Script file \\verb|hw3_p2.m|\n      \\lstinputlisting[style=MATLAB]{../src/hw3_p2.m}\n    \\item\n      Output file \\verb|hw3_p2.txt|\n      \\lstinputlisting[style=Plain]{../src/hw3_p2.txt}\n      \\begin{figure}[!hbtp]\n        \\centering\n        \\includegraphics[width=0.8\\linewidth]{../src/hw3_p2.pdf}\n        \\caption{}%\n        \\label{fig:}\n      \\end{figure}\n  \\end{itemize}\n\\end{solution}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Problem 3\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Problem 3}%\n\\label{sec:problem_3}\nSolve the twenty-one systems of equations:\n\\begin{equation*}\n  \\begin{cases}\n    7x + y + 2z = 0.01 m^{2} - 2m \\\\\n    x - 5y + 2z = 2 - m \\\\\n    2x + y + 5z = 9\n  \\end{cases}\n\\end{equation*}\nobtained by setting, in turn, the value of the quantity $m$ on the right-hand side to all integers in between, and including, $m = 0$ and $m = 20$. This time use the LU-decomposition of the system matrix that is implemented in MATLAB by the \\verb|lu| function. Perform the decomposition only once, then use the lower- and upper-triangular factors repeatedly to find each successive solution. Turn in the code and a plot of the first and second components of the solution (that is, the values of $x$ and $y$) as a function of thee right-hand side parameter $m$.\n\\begin{solution}\n  \\quad\n  \\begin{itemize}\n    \\item\n      Script file \\verb|hw3_p3.m|\n      \\lstinputlisting[style=MATLAB]{../src/hw3_p3.m}\n    \\item\n      Output file \\verb|hw3_p3.txt|\n      \\lstinputlisting[style=Plain]{../src/hw3_p3.txt}\n      \\begin{figure}[!hbtp]\n        \\centering\n        \\includegraphics[width=0.8\\linewidth]{../src/hw3_p3.pdf}\n        \\caption{}%\n        \\label{fig:}\n      \\end{figure}\n  \\end{itemize}\n\\end{solution}\n\n", "meta": {"hexsha": "6dbdb3e11d6b8e76ba8ff0fa31b269cd275a4ce6", "size": 7741, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "courses/template/MATH3340/Homework/3/LaTeX/body.tex", "max_stars_repo_name": "butlerm0405/math3341", "max_stars_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "courses/template/MATH3340/Homework/3/LaTeX/body.tex", "max_issues_repo_name": "butlerm0405/math3341", "max_issues_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "courses/template/MATH3340/Homework/3/LaTeX/body.tex", "max_forks_repo_name": "butlerm0405/math3341", "max_forks_repo_head_hexsha": "524d4e23cd8fab4ab8368df8b7e6b4442f8436f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.5947712418, "max_line_length": 643, "alphanum_fraction": 0.6444903759, "num_tokens": 2295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.815232489352, "lm_q1q2_score": 0.4393966327201791}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{January 24, 2014}\n\\maketitle\n\\section*{page 26 number 2}\n\nnotice that pde is stated for the interior of the region\nmodel can break down on the edges\nu stays at zero for time zero which is consistent with initial condition\nnotice that the slope at $x=1$ for initial condition is $-\\pi$ but is 1 for boundary condition\n\nheat is flowing in (proportional to negative slope).\n\nsecond boundary condition says that heat flow into the rod at x=1 (temperature gradient at $x=1$ is positive) which means low temperature inside, high temperature outside\n\nnotice boundary conditions are $0<t<\\infty$ so initial condition doesn't intersect boundary condition, because solution is discontinuous at $t=0$\n\n\\section*{last time}\nlessons 2 and 3 where PDE is $u_t=\\alpha^2 u_{xx}$ IC is $u(x,0)$ for different types of pde's and different types of bc's\n\n\\section*{lesson 4}\nderivation of pde\npage 28\nletter A is area of cross section\n\\subsection*{condition 1}\nrod consists of homogeneous conducting material.  temperature varies in rod, but substrate doesn't. homogeneous medium.\n\\subsection*{condition 2}\nlaterally insulated-no heat flow across lateral surface\n\\subsection*{condtion 3}\nthin rod, temperature is uniform across cross section.\n\\begin{align*}\n  u_t&=\\alpha^2u_{xx} \\text{on} 0<x<L, 0<t<\\infty\\\\\n  u(x,t)=\\text{temperature in degrees}& u(x,t)& \\text{is degrees}\\\\\n  \\text{total heat energy in} [x_1,x_2]=\\int_{x_1}^{x_2}{cupA,\\mathrm{d}x} & c&=\\text{specific heat}=\\frac{\\text{calories}}{\\text{degree of mass}}\\\\\n  &&p&=\\text{density}\\\\\n  \\text{rate of change of energy}&=\\frac{\\mathrm{d}}{\\mathrm{d}t}\\int_{x_1}^{x_2}{cupA,\\mathrm{d}x}=\\int_{x_1}^{x_2}{cpu_t A,\\mathrm{d}x}\\\\\n  \\intertext{law of conservation of energy}\n  &=\\text{flow rate of energy at end points}+\\text{generation rate of energy(internal)}\\\\\n  \\text{generation rate}&=\\int_{x_1}^{x_2}{f(s,t)A,\\mathrm{d}s} & f&=\\frac{\\text{cal}}{\\text{sec cm}^3}\\\\\n  \\text{flow rate}&=-DA(c\\rho u)_x \\frac{\\text{cal}}{\\text{cm}^2}\\\\\n  \\intertext{D is thermal diffusivity}\n  &=-DA(c\\rho u)_x-(-DA(c\\rho u)_x)+\\int_{x_1}^{x_2}{f(s,t)A,\\mathrm{d}s}\n\\end{align*}\n\nwe are thinking of stuff flowing into and out of the region $[x_1,x_2]$\n\\subsection*{condition 1}\ntube of solution of stuff. homogeneous medium (liquid)\n\\subsection*{condition 2}\ntube (glass or whatever) allows no flow of stuff through it. similar to insulation above.\n\\subsection*{condition 3}\nconcentration of stuff is uniform by symmetry\n\\begin{align*}\n  \\omega_t=D\\omega_{xx} \\text{on} 0<x<L, 0<t<+\\infty\\\\\n  \\omega(x,t)=\\text{density of stuff}\\\\\n  \\text{total stuff in} [x_1,x_2]=\\int_{x_1}^{x_2}{\\omega(x,t)A,\\mathrm{d}x}\n  \\text{rate of change of stuff}&=\\frac{\\mathrm{d}}{\\mathrm{d}t}\\int_{x_1}^{x_2}{\\omega A,\\mathrm{d}x}=\\int_{x_1}^{x_2}{\\omega_t A,\\mathrm{d}x}\\\\\n  \\intertext{law of conservation of stuff (mass or whatever)}\n  &=\\text{flow rate of stuff at endpoints}+\\text{generation rate of stuff}\n  \\text{generation rate}&=\\frac{\\text{stuff}}{\\text{sec}}=\\int_{x_1}^{x_2}{f(s,t)A,\\mathrm{d}s} & f&=\\frac{\\text{stuff}}{\\text{sec cm}^3}\\\\\n  \\text{flow rate of stuff at x}&=-DA\\omega_x\\\\\n  \\intertext{D is diffusion coefficient cm squared per second, this is Fick's law}\n  &=-DA\\omega_x(x_1,t)-(-DA\\omega_x(x_2,t))+\\int_{x_1}^{x_2}{f(s,t)A,\\mathrm{d}s}\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "a57132e4538d6361d1cdd36a7efe966ba22513e3", "size": 3497, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "partial differential equations/pde-notes-2014-01-24.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "partial differential equations/pde-notes-2014-01-24.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "partial differential equations/pde-notes-2014-01-24.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.904109589, "max_line_length": 170, "alphanum_fraction": 0.7128967687, "num_tokens": 1189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.4393931463621581}}
{"text": "\\chapter{Legendre expansions of energy-angle probability densities\nin the laboratory frame}\n\\label{Sec:Legendre-lab}\nAnother representation of joint energy-angle probability densities\n$\\pi(E', \\mu \\mid E)$ in \\xendl\\ is as a table of the Legendre \ncoefficients $\\pi_\\ell(E' \\mid E)$ in the expansion\n\\begin{equation}\n  \\pi( E', \\mu \\mid E) = \\sum_\\ell\n  \\left(\n    \\ell + \\frac{1}{2}\n  \\right)\n  \\pi_\\ell( E' \\mid E) P_\\ell( \\mu ).\n \\label{piLegendre}\n\\end{equation}\nHere, $E$ denotes the energy of the incident particle in the\nlaboratory frame.  For the outgoing particle, the energy $E'$ and \ndirection cosine $\\mu$ may be given in either center-of-mass or laboratory\ncoordinates.  The treatment of laboratory-frame data is discussed in this section, \ncenter-of-mass data in the next.  Data given in the laboratory frame are\nmuch easier to deal with because no boost is involved.\n\nThis type of data is ordered according to\n\\begin{equation}\n\\{ E, \\{ E', \\{ \\pi_\\ell(E' \\mid E) \\} \\} \\}.\n \\label{ENDF-I4}\n\\end{equation}\nAll of the data for the lowest incident energy $E$\nis given first, ordered according to outgoing energy~$E'$.  For\ngiven values of $E$ and $E'$, the data consist of Legendre coefficients\n$\\pi_\\ell(E', \\mid E)$.  Note that for this data format, the number\nof Legendre coefficients may vary, depending on the energies $E$ and~$E'$.\n\nThe {\\gettransfer} code also handles data for Legendre expansions of\nenergy-angle probability densities in the {\\ENDL} format~\\cite{Omega},\n\\begin{equation}\n\\{ \\ell, \\{ E, \\{ E', \\pi_\\ell(E', \\mid E) \\} \\} \\}.\n \\label{ENDL-I4}\n\\end{equation}\nThat is, the $\\ell = 0$ data are given first, ordered according to\nincident energy~$E$.  The data then consist of pairs\n$\\{ E', \\pi_\\ell(E', \\mid E) \\}$ for given $\\ell$ and $E$.\n%This data format is deprecated, however.\n\n\\section{Computation of the transfer matrices for data in the laboratory frame}\nThe calculation of the transfer\nmatrices for laboratory-frame data proceeds as follows.\nIn terms of $\\pi_\\ell(\\Elab'   \\mid E)$,\nthe integral Eq.~(\\ref{Inum}) for the number-preserving transfer matrix\ntakes the form\n\\begin{equation}\n   \\Inum_{g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E)\n   \\int_{\\calE_h' } d\\Elab'   \\, \\pi_\\ell(\\Elab'   \\mid E),\n \\label{InumI4}\n\\end{equation}\nand Eq.~(\\ref{Ien}) for the energy-preserving transfer matrix becomes\n\\begin{equation}\n   \\Ien_{g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E) \n     \\int_{\\calE_h' } d\\Elab'   \\, \\pi_\\ell(\\Elab'   \\mid E) \\Elab'  .\n \\label{IenI4}\n\\end{equation}\n\nComputation of the integrals Eqs.~(\\ref{InumI4}) and~(\\ref{IenI4})\ndepends on the type of interpolation used with respect to the\nenergy $E$ of the incident particle, and the procedures are\nexactly the same as for integration in Eqs.~(\\ref{InumI4-0}) \nand~(\\ref{IenI4-0}) of the isotropic energy probability densities\n$\\pi_0(\\Elab'   \\mid E)$.  Thus, if unit-base interpolation is to\nbe used for $\\pi_\\ell(\\Elab'   \\mid E)$, then the map Eq.~(\\ref{unitbaseMap})\nconverts \nthe integrals Eqs.~(\\ref{InumI4}) and~(\\ref{IenI4}) to the form\n\\begin{equation}\n   \\Inum_{g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E) \n   \\int_{\\widehat\\calE_h' } d\\widehat \\Elab'   \\,\n     \\widehat\\pi_\\ell(\\widehat \\Elab'   \\mid E)\n \\label{InumhatI4}\n\\end{equation}\nand\n\\begin{equation}\n   \\Ien_{g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma ( E ) M(E) w(E) \\widetilde \\phi_\\ell(E) \n   \\int_{\\widehat\\calE_h' } d\\widehat \\Elab'   \\,\n     \\widehat\\pi_\\ell(\\widehat \\Elab'   \\mid E) \\Elab'  .\n \\label{IenhatI4}\n\\end{equation}\nIn these intergrals $\\widehat\\calE_h'$ denotes result of mapping the \noutgoing energy bin $\\calE_h'$ with the transformation Eq.~(\\ref{unitbaseMap}).\nFurthermore, $\\Elab'  $ in Eq.~(\\ref{IenhatI4}) is to be obtained from $\\widehat \\Elab'  $\nusing the inverse unit-base mapping Eq.~(\\ref{unitbaseInvert}).\n\nThe geometrical considerations involved in integrating \nEqs.~(\\ref{InumhatI4}) and~(\\ref{IenhatI4}) over the incident energy bin~$\\calE_g$\nand the mapped outgoing energy bin~$\\widehat\\calE_h'$ are illustrated\nin Figure~\\ref{Fig:unit-base-region}.\n\n\\section{Form of the input file for Legendre coefficient data in the laboratory frame}\nThese data may be input in either of two forms, the format \nin Eq.~(\\ref{ENDF-I4}) from \\ENDF\\ with all Legendre\ncoefficients given together at each incident energy $E$ and outgoing energy~$E'$\nor that  in Eq.~(\\ref{ENDL-I4}) with\none Legendre order at a time.\nFor both formats, all energies must be in the same units as the energy groups.\n\n\\subsection{Input of all Legendre coefficients together}\\label{Sec:ENDF-I4-data}\nFor energy-angle tables in the standard format of Eq.~(\\ref{ENDF-I4}), \nthe Section~\\ref{data-model} line in the input\nfile to identify the data is\\\\\n      \\Input{Process: Legendre energy-angle data}{}\\\\\nand the model-dependent data in Section~\\ref{model-info} consists of the\nLegendre coefficients $\\pi_\\ell(E' \\mid E)$ in Eq.~(\\ref{ENDF-I4}) at incident energies~$E$\nand outgoing energies~$E'$.\n\nThe format for the Legendre coefficient data in\nSection~\\ref{model-info} given at $K$ values of $E$ is\\\\\n  \\Input{Product Frame: lab}{}\\\\\n  \\Input{Legendre data by incident energy:}{$n = K$}\\\\\n  \\Input{Incident energy interpolation:}{probability interpolation flag}\\\\\n  \\Input{Outgoing energy interpolation:}{list interpolation flag}\\\\\nwhere the interpolation flag for incident energy is one for probability density\ntables as in Section~\\ref{interp-flags-probability}, and that for outgoing energy \nis for a simple list.\nThese lines are followed by $K$ sections of the form\\\\\n  \\Input{ Ein: $E$:}{\\texttt{n = $J_k$}}\\\\\nfor $J_k$ outgoing energies $E$.  For each value of $E$ there is\ndata\\\\\n  \\Input{  Eout: $E'$:}{\\texttt{n = $L$}}\\\\\nwith Legendre coefficients $\\pi_\\ell(E' \\mid E)$ for $\\ell = 0$, 1, \\ldots\\ , $L - 1$.\n\nAn example of these data with energies in MeV is\\\\\n  \\Input{Legendre data by incident energy:  n = 26}{}\\\\\n   \\Input{Incident energy interpolation: lin-lin cumulativepoints}{}\\\\\n  \\Input{Outgoing energy interpolation: flat}{}\\\\\n   \\Input{Ein: 1.140200e+01:  n = 2}{}\\\\\n  \\Input{  Eout: 0.000000e+00:  n = 5}{}\\\\\n \\Input{ \\indent  1.000000e+11}{}\\\\\n \\Input{ \\indent  0.000000e+00}{}\\\\\n \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n    \\Input{ Eout: 1.000000e-11:  n = 5}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n\\Input{}{$\\cdots$}\\\\\n   \\Input{Ein: 2.000000e+01:  n = 27}{}\\\\\n    \\Input{ Eout: 0.000000e+00:  n = 5}{}\\\\\n   \\Input{ \\indent  4.179200e-02}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  4.179200e-06}{}\\\\\n   \\Input{ \\indent  0.000000e+00}{}\\\\\n   \\Input{ \\indent  3.395500e-07}{}\\\\\n \\Input{ \\indent}{ etc.}\n \n \\subsection{Input of one Legendre coefficient at a time}\\label{sec:ENDL-I4}\nFor data given one Legendre coefficient at a time as in Eq.~(\\ref{ENDL-I4}),\nthe line in Section~\\ref{data-model} of the input\nfile identifying the data is\\\\\n      \\Input{Process: Legendre EEpP data transfer matrix}{}\\\\\nThe first lines in the data for Section~\\ref{model-info} are\\\\\n  \\Input{Product Frame: lab}{}\\\\\n \\Input{LEEpPData:}{$n = L$}\\\\\nwhere $L$ is the number of Legendre coefficients, one greater than the\norder of the Legendre expansion.  The interpolation flags as\nin Section~\\ref{interp-flags-probability} are\\\\\n   \\Input{Incident energy interpolation:}{probability interpolation flag}\\\\\n  \\Input{Outgoing energy interpolation:}{list interpolation flag}\\\\\nThe interpolation flag for incident energy is one for probability density\ntables as in Section~\\ref{interp-flags-probability}, and that for outgoing energy \nis for a simple list.\n\nThe data are then given in $L$ sections, each of the form\\\\\n   \\Input{ order: l = $\\ell$:}{\\texttt{n = $K$}}\\\\\nwhere $K$ is the number of incident energies.\nFor each incident energy $E'$ there is a block of data\\\\\n    \\Input{ Ein:}{$E$: \\quad \\texttt{n = $J_k$}}\\\\\nfor $J_k$ pairs of values of outgoing energy $E'$ and\nLegendre coefficient $\\pi_\\ell(E' \\mid E)$.  For energies measured in MeV,\nthese data may look like\\\\\n  \\Input{LEEpPData: n = 4}{}\\\\\n  \\Input{Incident energy interpolation: lin-lin unitbase}{}\\\\\n  \\Input{Outgoing energy interpolation: lin-lin}{}\\\\\n  \\Input{order: l = 0: n = 10}{}\\\\\n   \\Input{Ein:  3.350000000000e+00 : n = 3}{}\\\\\n  \\Input{ \\indent   3.716500000000e-01   0.000000000000e+00}{}\\\\\n  \\Input{ \\indent   3.716800000000e-01   2.857140000000e+04}{}\\\\\n  \\Input{ \\indent   3.717200000000e-01   0.000000000000e+00}{}\\\\\n  \\Input{Ein:  4.460200000000e+00 : n = 2}{}\\\\\n  \\Input{ \\indent   1.238900000000e-01   1.008970000000e+00}{}\\\\\n   \\Input{ \\indent  1.115000000000e+00   1.008970000000e+00}{}\\\\\n \\Input{$\\cdots$}{}\\\\\n  \\Input{Ein:  2.000000000000e+01 : n = 2}{}\\\\\n     \\Input{ \\indent  1.699600000000e-02  1.232820000000e-01}{}\\\\\n     \\Input{ \\indent  8.128500000000e+00  1.232820000000e-01}{}\\\\\n   \\Input{order: l = 1: n = 10}{}\\\\\n    \\Input{Ein:  3.350000000000e+00 : n = 3}{}\\\\\n     \\Input{ \\indent  3.716500000000e-01  0.000000000000e+00}{}\\\\\n     \\Input{ \\indent  3.716800000000e-01  2.690500000000e+04}{}\\\\\n     \\Input{ \\indent  3.717200000000e-01  0.000000000000e+00}{}\\\\\n\\Input{$\\cdots$}{}\\\\\n    \\Input{order:l = 3: n = 10}{}\\\\\n    \\Input{Ein:  3.350000000000e+00 : n = 3}{}\\\\\n     \\Input{ \\indent  3.716500000000e-01  0.000000000000e+00}{}\\\\\n     \\Input{ \\indent  3.716800000000e-01  2.690500000000e+04}{}\\\\\n     \\Input{ \\indent  3.717200000000e-01  0.000000000000e+00}{}\\\\\n\\Input{$\\cdots$}{}\\\\\n  \\Input{Ein:  2.000000000000e+01 : n = 28}{}\\\\\n     \\Input{ \\indent  1.699600000000e-02  1.172400000000e-01}{}\\\\\n     \\Input{ \\indent  3.283800000000e-02 -8.646000000000e-03}{}\\\\\n     \\Input{ \\indent  4.868100000000e-02 -3.589400000000e-02}{}\\\\\n     \\Input{ \\indent  6.452400000000e-02 -4.528500000000e-02}{}\\\\\n     \\Input{ \\indent  8.036700000000e-02 -4.921500000000e-02}{}\\\\\n     \\Input{ \\indent  1.120500000000e-01 -5.186400000000e-02}{}\\\\\n    \\Input{ \\indent }{$\\cdots$}\\\\\n    \\Input{ \\indent  7.082900000000e+00  7.783200000000e-02}{}\\\\\n     \\Input{ \\indent  8.128500000000e+00  1.172400000000e-01}{}\n\n \n ", "meta": {"hexsha": "d2fc4a6fca4a6ebce9f7f59eaf7687652288e9bc", "size": 10343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Merced/Doc/legendre-lab.tex", "max_stars_repo_name": "brown170/fudge", "max_stars_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2019-08-29T23:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T10:16:25.000Z", "max_issues_repo_path": "Merced/Doc/legendre-lab.tex", "max_issues_repo_name": "brown170/fudge", "max_issues_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-08-04T16:14:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T01:54:34.000Z", "max_forks_repo_path": "Merced/Doc/legendre-lab.tex", "max_forks_repo_name": "brown170/fudge", "max_forks_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-03-03T22:41:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T22:54:43.000Z", "avg_line_length": 46.5900900901, "max_line_length": 91, "alphanum_fraction": 0.674949241, "num_tokens": 3759, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.5888891307678321, "lm_q1q2_score": 0.4393931430378646}}
{"text": "\\documentclass[../research.tex]{subfile}\n\n\\subsection{Lebesgue Integration}\n\\label{sec:4.1}\n\n\\subsection{The Banach-Tarski Paradox}\n\\label{sec:4.3}\n\n\\subsection{Order Theory}\n\\label{sec:4.4}\n\n    \\begin{definition}[Partial order]\n        Given a set $P$, a \\textit{partial order}, $\\leq$, is a binary relation on $P$ satisying the \n        following:\n        \\begin{enumerate}\n            \\item Reflexivity: $p\\leq p \\quad\\forall p\\in P$\n            \\item Antisymmetry: $p\\leq q\\wedge q\\leq p\\Rightarrow$ $p=q\\quad\\forall p,q\\in P$\n            \\item Transitivity: $p\\leq q$, $q\\leq r$ $\\Rightarrow$ $p\\leq r\\quad\\forall p,q,r\\in P$\n        \\end{enumerate}\n        We call a set with a partial order a \\textit{poset}, $(P,\\leq)$.\n    \\end{definition}\n\n    \\begin{definition}[Lattice]\n    \\end{definition}\n\n\\subsection{Diffeology}\n\\label{sec:4.5}\n\n\\subsection{Tensors}\n\\label{sec:4.6}\n\n    \\subsubsection{Dual space of a vector space}\n    \\label{sec:4.6.1}\n\n        \\begin{definition}[Linear functional]\n        \\end{definition}\n\n    \\subsubsection{Cotangent vectors}\n    \\label{sec:4.6.2}\n\n    \\subsubsection{Differential Forms}\n    \\label{sec:4.6.3}\n\n\n", "meta": {"hexsha": "c6f643154aba25a84d5d67e6a4ec13abd26ecbcf", "size": 1152, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "04-topics.tex", "max_stars_repo_name": "Jerrycaster/maths", "max_stars_repo_head_hexsha": "29706561f90442846e67348a75094e840a8124b2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-topics.tex", "max_issues_repo_name": "Jerrycaster/maths", "max_issues_repo_head_hexsha": "29706561f90442846e67348a75094e840a8124b2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-topics.tex", "max_forks_repo_name": "Jerrycaster/maths", "max_forks_repo_head_hexsha": "29706561f90442846e67348a75094e840a8124b2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6, "max_line_length": 101, "alphanum_fraction": 0.640625, "num_tokens": 376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4393356650970946}}
{"text": "\\begin{intro}\n  In the previous chapter, we studied discretizations with\n  $\\div V_h = Q_h$ with two advantages. First, due to\n  \\slideref{Corollary}{galerkin-mixed-u-kerb} the velocity error is\n  independent of the pressure. Second, the divergence converges faster\n  than the gradient. A natural question arising is whether we can do\n  something similar for the Stokes problem. There, the equation\n  \\begin{gather}\n    \\form(\\div v_h, q_h) = 0 \\qquad\\forall q_h\\in Q_h,\n  \\end{gather}\n  would immediately imply $\\div v_h=0$, that is, the discrete solution\n  is exactly divergence free.\n  \n  The answer to this question is a current research topic. So far,\n  beginning with the element by Scott and Vogelius, several methods\n  have been proposed for special mesh geometry or macro meshes. The\n  difficulty is balancing the condition $\\div V_h = Q_h$ with the\n  $H^1$-conformity of the velocity space. All the spaces in the\n  previous chapter were only $\\Hdiv$-conforming with discontinuous\n  tangential components.\n  \n  A fairly simple solution to this question though can be obtained by\n  using discontinuous Galerkin methods. These were introduced to\n  obtain formulations \\emph{consistent} with $H^1$ while not\n  \\emph{conforming}. Thus, we can apply them directly to\n  Raviart-Thomas and Brezzi-Douglas-Marini elements to obtain a\n  consistent method with divergence free solutions.\n\n  We begin this chapter by a quick review of the interior penalty\n  method before diving into divergence conforming methods.\n\\end{intro}\n\n\\section{The interior penalty method}\n\\input{../fem/ip}\n\\subsection{Bounded formulation in $H^1$}\n\\input{../fem/ip-lifting}\n\n\\section{Divergence conforming IP}\n\\begin{remark}\n  The extension of the interior penalty method to vector-valued\n  problems is obvious. Furthermore, since the method generates an\n  elliptic bilinear form on the discontinuous space $V_h$, this\n  ellipticity is inherited by any subspace of\n  $V_h\\cap\\Hdiv(\\domain)$. Thus, we can write down the weak\n  formulation of a divergence conforming DG method for the Stokes\n  equations. In the following definition, we assume slip or no-slip\n  boundary conditions, that is, $v\\cdot\\n=0$ on the whole boundary.\n\\end{remark}\n\n\\begin{Definition}{hdiv-ip}\n  A divergence conforming DG method for the Stokes equations consists\n  of a discrete velocity space $V_h\\subset \\Hdiv_0(\\domain)$ and a\n  pressure space $Q_h\\subset L^2_0(\\domain)$ such that\n  \\begin{gather}\n    \\label{eq:hdivdg:1}\n    \\div V_h = Q_h.\n  \\end{gather}\n  Using the interior penalty bilinear form $a_h(.,.)$, we search for\n  solutions $(u_h,p_h)\\in V_h\\times Q_h$ such that for all $(v,q)\\in\n  V_h\\times Q_h$ there holds\n  \\begin{gather}\n    \\label{eq:hdivdg:2}\n    a_h(u_h,v) +\\form(\\div v,p_h)+\\form(\\div u_h,q) = f(v).\n  \\end{gather}\n\\end{Definition}\n\n\\begin{remark}\n  Due to the fact that $V_h\\not\\subset V$, we have introduced the  norm\n  $\\norm{.}_{1,h}$ on $V_h$. In particular, the norm $\\norm{.}_1$ is\n  not defined for all elements of $V_h$. Therefore, we need a\n  modification of Fortin's lemma (\\slideref{Lemma}{fortin}), where the\n  norm on the left hand side of the stability\n  estimate~\\eqref{eq:galerkin:16} uses the discrete norm, namely,\n  \\begin{gather}\n    \\norm{\\Pi_{V_h}v}_{V_h} \\le c \\norm{v}_V,\n  \\end{gather}\n\\end{remark}\n\n\\begin{Lemma}{dg-fortin}\n  Let $\\{\\mesh_h\\}$ be a shape-regular sequence of meshes. Then, the\n  \\putindex{canonical interpolation} operators of the\n  Brezzi-Douglas-Marini and Raviart-Thomas elements admit the bound\n  \\begin{gather}\n    \\label{eq:hdivdg:4}\n    \\norm{I_h v}_{1,h} \\le c \\snorm{v}_1\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  First, we note that all degrees of freedom are defined as cell or\n  face integrals with smooth weight functions. Thus, they are bounded\n  on $H^1$. Thus, since the local polynomial spaces are finite\n  dimensional, there holds on the reference cell $\\refcell$ and its\n  faces $\\refface$:\n  \\begin{align}\n    \\norm{I_{\\refcell} v}_{1;\\refcell} &\\le c \\snorm{v}_{1;\\refcell},\n    \\\\\n    \\norm{I_{\\refcell} v}_{0;\\refface} &\\le c \\snorm{v}_{1;\\refcell}.   \n  \\end{align}\n  On shape regular meshes, we have the scaling property\n  \\begin{align}\n    \\snorm{f}_{m;\\cell} &\\simeq h_\\cell^{\\frac{d}{2}-m},\n    \\\\\n    \\snorm{f}_{m;\\face} &\\simeq h_\\face^{\\frac{d-1}{2}-m},\n  \\end{align}\n  such that for a face $\\face$ of cell $\\cell$\n  \\begin{align}\n    \\norm{I_{\\cell} v}_{1;\\cell} & \\le c \\snorm{v}_{1;\\cell},\n    \\\\\n    \\norm{I_{\\cell} v}_{0;\\refface} &\\le c h^{\\frac12} \\snorm{v}_{1;\\cell}.\n  \\end{align}\n  We conclude\n  \\begin{gather}\n    \\norm{I_h v}_{1,h}^2 \\le \\sum_{\\cell\\in\\mesh_h}\n    \\biggl[\\norm{I_{\\cell} v}_{1;\\cell}^2\n    + 4 \\sum_{\\face\\subset\\d\\cell}\n    \\norm*{\\tfrac{\\ipp_0}{h_F} I_{\\cell} v}_{0;\\face}^2\n    \\biggr] \\le c \\snorm{v}_{1}^2.\n  \\end{gather}\n\\end{proof}\n\n\\begin{Corollary}{hdivdg-infsup}\n  Assume that the inf-sup condition~\\eqref{eq:stokes:1} in\n  \\slideref{Theorem}{stokes-infsup} holds.\n  Then, the method in \\slideref{Definition}{hdiv-ip}\n  admits the inf-sup condition\n  \\begin{gather}\n    \\label{eq:hdivdg:3}\n    \\inf_{q_h\\in Q_h} \\sup_{v_h\\in V_h}\n    \\frac{\\form(\\div v_h,q_h)}{\\norm{v_h}_{1,h}\\norm{q_h}_0} \\ge \\beta,\n  \\end{gather}\n  with a constant $\\beta >0$ independent of $h$.\n\\end{Corollary}\n\n\\begin{proof}\n  First, we make use of the fact that $q_h\\in Q_h \\subset Q$ to deduce\n  from \\slideref{Theorem}{stokes-infsup} the there is a function $w\\in\n  V$ with $\\div v=q_h$ and $\\norm{v}_1 \\le \\norm{q_h}_0$. To this\n  function, we apply the \\putindex{Fortin operator} to define $v_h =\n  I_h v$. By the preceding lemma, we have\n  \\begin{gather}\n    \\norm{v_h}_{1,h} \\le c \\norm{v}_1 \\le \\norm{q_h}_0,\n  \\end{gather}\n  which proves the inf-sup condition.\n\\end{proof}\n\n\\begin{Theorem}{hdivdg-convergence}\n  Assume that $(u_h,p_h)\\in V_h\\times Q_h$ is the solution to the\n  divergence conforming DG method in \\slideref{Definition}{hdiv-ip} and\n  that the continuous Stokes problem is well-posed as in\n  \\slideref{Theorem}{stokes-infsup}. Then, for the Raviart-Thomas\n  pairs $RT_k/\\P_k$ and $RT_{[k]}/\\Q_k$ with $k\\ge 1$ and\n  $u$ sufficiently smooth there holds\n  \\begin{align}\n    \\label{eq:hdivdg:5}\n    \\norm{u-u_h}_{1,h} &\\le h^k \\snorm{u}_{k+1}, \\\\\n    \\label{eq:hdivdg:7}\n    \\norm{p-p_h}_{0} &\\le h^k \\bigl(\\snorm{u}_{k+1} + \\snorm{p}_{k}\\bigr).\n  \\end{align}\n  Furthermore,\n  \\begin{gather}\n    \\label{eq:hdivdg:6}\n    \\div u_h = 0.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  The proof follows the lines of the abstract theory of\n  \\slideref{Theorem}{galerkin-mixed-u-kerbh} and\n  \\slideref{Theorem}{galerkin-mixed-p}. But since the setting with\n  $V_h\\not\\subset V$ exceeds the assumptions of the abstract theory,\n  we adapt the proofs instead of using the results.\n\n  Due to consistency of the method, we have\n  \\begin{gather}\n    a_h(u-u_h, v_h) + \\form(\\div v_h, p-p_h)\n    + \\form(\\div u-\\div u_h, q_h) = 0.\n  \\end{gather}\n  Testing with $v_h=0$ and using $\\div V_h = Q_h$ immediately yields\n  $\\div u_h = \\div u = 0$, or\n  \\begin{gather}\n    \\ker{B_h} \\subset \\ker B.\n  \\end{gather}\n  In order to use the ellipticity of $a_h(.,.)$, we insert\n  arbitrary functions $w_h \\in \\ker{B_h}$ and $r_h\\in Q_h$. Choosing\n  $q_h = 0$ yields the error equation\n  \\begin{gather}\n    \\label{eq:hdivdg:8}\n    a_h(u_h-w_h, v_h) + \\form(\\div v_h, p_h-r_h)\n    = a_h(u-w_h, v_h) + \\form(\\div v_h, p-r_h).\n  \\end{gather}\n  Testing with $v_h=u_h-w_h$ and employing $\\div v_h=0$, we obtain\n  \\begin{gather}\n    \\ellipa \\norm{u_h-w_h}_{1,h}^2\n    \\le a_h(u_h-w_h,u_h-w_h)\n    = a_h(u-w_h,u_h-w_h).\n  \\end{gather}\n  Now, we use the canonical interpolation $w_h = I_h u$ to obtain\n  \\begin{gather}\n    \\ellipa \\norm{u_h-w_h}_{1,h}^2\n    \\le \\frac\\ellipa2 \\norm{u_h-w_h}_{1,h}^2\n    + \\frac{c}{2\\ellipa} h^{2k} \\snorm{u}_{k+1}^2.\n  \\end{gather}\n\n  Finally, we use the inf-sup condition to find a test function\n  $v_h\\in V_h$ such that $\\div v_h = p_h-r_h$ and $\\beta \\norm{v_h}_{1,h}\n  \\le \\norm{p_h-r_h}$. Then, the error equation~\\eqref{eq:hdivdg:8}\n  yields\n  \\begin{multline}\n    \\norm{p_h-r_h}\n    = \\frac{\\form(\\div v_h,p_h-r_h)}{\\norm{p_h-r_h}}\n    \\\\\n    = \\frac{a_h(u-u_h, v_h) + \\form(\\div v_h, p-r_h)}\n    {\\norm{p_h-r_h}}\n    \\le \\tfrac{\\norm{a_h}}\\beta \\norm{u-u_h}_{1,h}\n    + \\norm{p-r_h}_0\n    .\n  \\end{multline}\n  Using the previously proven error estimate for $u_h$ and the\n  $L^2$-projection $r_h = \\Pi_h p$ yields the result.\n\\end{proof}\n\n\\section{Error estimates by duality}\n\n\\begin{intro}\n  So far, we have only considered estimates in the so called\n  \\putindex{energy norm}, that is, a norm such that $a_h(.,.)$ is\n  bounded and elliptic\\footnote{We use the term energy norm loosely\n    here. Strictly speaking, the energy norm would be\n    $\\norm{v}_A = \\sqrt{a_h(v,v)}$.}.\n\n  In the context of elliptic equations, we have seen the duality\n  argument of Aubin and Nitsche, which allows us to obtain optimal\n  estimates in weaker norms, for instance in $L^2$.\n\n  A particular difficulty here is the fact, that we have to test the\n  dual solution with the error \\emph{and} exploit some kind of\n  Galerkin orthogonality. Thus, we cannot use consistency as before\n  and will introduce residual operators later. The analysis here is a\n  simplified version of the corresponding results\n  in~\\cite{GiraultKanschatRiviere14}.\n\\end{intro}\n\n\\begin{Definition}{dual-stokes}\n  The \\putindex{dual problem} to the Stokes problem in weak for\n  consists of finding $(u^*,p^*)\\in V_h\\times Q_h$ such that for all\n  $v\\in V$ and $q\\in Q$ there holds\n  \\begin{gather}\n    \\label{eq:hdivdg:9}\n    \\form(\\nabla v,\\nabla u^*) + \\form(\\div u^*,q) + \\form(\\div v,p^*)\n    = \\form(\\psi,v).\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Assumption}{stokes-regularity}\n  The dual Stokes problem admits the elliptic regularity estimate\n  \\begin{gather}\n    \\label{eq:hdivdg:10}\n    \\norm{u^*}_{2} \\le c \\norm{f}_0.\n  \\end{gather}\n\\end{Assumption}\n\n\\begin{remark}\n  Like for scalar elliptic equations, the elliptic regularity\n  assumption holds for domains with smooth boundary or with piecewise\n  smooth boundary where every corner is convex.\n\\end{remark}\n\n\\begin{Definition}{hdivdg-residual-operators}\n  For the solutions $(u,p)\\in V\\times Q$ and $(u^*,p^*)\\in V\\times Q$\n  of the primal and dual Stokes problem, respectively, we define the\n  residual operators\n  \\begin{align}\n    \\operatorname{Res}(u,p;v) &= a_h(u,v)+\\form(\\div v,p) - \\form(f,v),\n    \\\\\n    \\operatorname{Res}^*(v;u^*,p^*)\n                              &= a_h(v,u^*)+\\form(\\div v,p^*) -\n                                \\form(\\psi,v),\n  \\end{align}\n  for $v\\in V+V_h$.\n\\end{Definition}\n\n% From Girault/Kanschat/Riviere\n\n\\begin{Lemma}{hdivdg-residual-1}\n  Let $(u,p)\\in V\\times Q$ be the solution to the Stokes problem with\n  right hand side $f\\in L^2(\\domain;\\R^d)$. Assume $u\\in\n  H^s(\\domain;\\R^d)$ and $p\\in H^{s-1}(\\domain)$ with $s>3/2$. Then,\n  we have for $v\\in V+V_h$:\n  \\begin{gather}\n    \\label{eq:hdivdg:11}\n    \\form(f,v) = \\form(\\nabla u,\\nabla v)_{\\mesh_h}\n    -\\forme(\\nabla u,\\mvl{v\\otimes n})_{\\faces_h^i}\n    -\\forme(\\d_n u,v)_{\\faces_h^\\d}\n    + \\form(\\div v,p).\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  We set out from the strong form of the Stokes equations and\n  integrate by parts.\n  \\begin{align}\n    \\form(f,v) &= \\form(-\\Delta u + \\nabla p, v)\n    \\\\\n    &= \\form(\\nabla u,\\nabla v)_{\\mesh_h}\n      - \\sum_{\\cell\\in\\mesh_h} \\forme(\\d_n u,v)_{\\d\\cell}\n      - \\form(\\div v,p)\n      .\n  \\end{align}\n  Under the regularity assumptions of the lemma, all of these\n  integrals make sense at least as duality pairings. In particular,\n  $\\d_n u\\in L^2(\\d\\cell)$, and thus we can split $\\d\\cell$ into\n  individual faces. Therefore,\n  \\begin{gather}\n    \\sum_{\\cell\\in\\mesh_h} \\forme(\\d_n u,v)_{\\d\\cell}\n    = \\forme(\\nabla u,\\mvl{v\\otimes n})_{\\faces_h^i}\n    +\\forme(\\d_n u,v)_{\\faces_h^\\d}.\n  \\end{gather}\n  The proof concludes by collecting the results.\n\\end{proof}\n\n\\begin{Corollary}{hdivdg-residual-2}\n  The residual operators can be expressed as\n  \\begin{gather}\n    \\label{eq:hdivdg:12}\n    \\begin{split}\n    \\operatorname{Res}(u,p;v)\n    &= a_h(u,v)\n      - \\form(\\nabla u,\\nabla v)_{\\mesh_h}\n      \\\\\n      &\\qquad\n      + \\forme(\\nabla u,\\mvl{v\\otimes n})_{\\faces_h^i}\n      +\\forme(\\d_n u,v)_{\\faces_h^\\d}.\n      \\\\\n    \\operatorname{Res}^*(u^*,p^*;v)\n    &= a_h(v,u^*)\n      - \\form(\\nabla u,\\nabla v)_{\\mesh_h}\n      \\\\\n      &\\qquad\n      + \\forme(\\nabla u,\\mvl{v\\otimes n})_{\\faces_h^i}\n      +\\forme(\\d_n u,v)_{\\faces_h^\\d}.      \n    \\end{split}\n  \\end{gather}\n  In particular, the residual operators do not depend on the pressure\n  solutions.\n\\end{Corollary}\n\n\\begin{Theorem}{hdivdg-l2}\n  Let the assumptions of \\slideref{Theorem}{hdivdg-convergence}\n  and \\slideref{Assumption}{stokes-regularity} hold. Then,\n  \\begin{gather}\n    \\norm{u-u_h}_0 \\le c h^{k+1} \\snorm{u}_{k+1}.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{Problem}{hdivdg-l2}\n  Adapt the proof of \\slideref{Theorem}{ip-lifting-l2} to prove\n  \\slideref{Theorem}{hdivdg-l2}.\n\\begin{solution}\n   We again consider the auxiliary problem\n  \\begin{gather}\n    a(v,u^*) +(\\nabla\\cdot v, p^*)= \\form(u-u_h,v),\\qquad\\forall v\\in V.\n  \\end{gather}\n  Using the definition of the dual residual, we obtain the equation\n  \\begin{gather}\n    \\form(u-u_h, v) = a_h(v,u^*) +(\\nabla\\cdot v, p^*)- \\Res^*(u^*,p^*;v),\\qquad\\forall v\\in V+V_h.\n  \\end{gather}\n  Testing with $v=u-u_h$ yields\n  \\begin{gather}\n    \\norm{u-u_h}^2 = a_h(u-u_h,u^*) +(\\nabla\\cdot (u-u_h), p^*)- \\Res^*(u^*, p^*;u-u^*).\n  \\end{gather}\n  Additionally, we us the error equation\n  \\begin{gather}\n    a_h(u-u_h, v_h)+(\\nabla\\cdot v_h, p-p_h) = \\Res(u,p;v_h),\n  \\end{gather}\n  tested with $v_h = I_h u^*$, to obtain\n  \\begin{align}\n    \\norm{u-u_h}^2 &= a_h(u-u_h,u^*-I_h u^*) +(\\nabla\\cdot (u-u_h), p^*-q_h)\\\\\n    &\\quad- \\Res^*(u^*, p^*;u-u^*)\n    -\\underbrace{(\\nabla\\cdot I_h u^*, p-p_h)}_{0} + \\Res(u,p;I_h u^*).    \n  \\end{align}\n  Using the regularity of $u^*$, the first term on the right\n  admits the estimate\n  \\begin{gather}\n    \\abs{a_h(u-u_h, u^*-I_h u^*)}\n    \\le \\norm{u-u_h}_{1,h}\\norm{u^*-I_hu^*}_{1,h}\n    \\le c h \\norm{u-u_h}_{1,h}.\n  \\end{gather}\n  as before.\n  \n  For the second term consider $q_h=\\Pi_{Q_h} p^*$\n  \\begin{align}\n   (\\nabla\\cdot (u-u_h), p^*-\\Pi_{Q_h} p^*)\\leq \\norm{\\nabla \\cdot  (u-u_h)} \\norm{p^*-\\Pi_{Q_h} p^*}=0\n  \\end{align}\n  \n  For the third term we use \\slideref{Lemma}{ip-lifting-residual-2}\n  to obtain\n  \\begin{gather}\n    \\abs{\\Res^*(u^*,u-u_h)} \\le c h \\snorm{u^*}_2 \\norm{u-u_h}_{1,h}.\n  \\end{gather}\n  Finally, using $\\jmp{u^*} = 0$, the same lemma yields\n  \\begin{align}\n    \\abs{\\Res(u, I_h u^*)}\n    &\\le c h \\snorm{u}_2\n      \\bigl(\\norm{\\sqrt{\\ipp_h}\\jmp{I_h u^*}}_{\\faces_h^i}\n      + \\norm{\\sqrt{\\ipp_h}I_h u^*}_{\\faces_h^\\d}\\bigr)\n    \\\\\n    & = c h \\snorm{u}_2\n      \\bigl(\\norm{\\sqrt{\\ipp_h}\\jmp{u^*-I_h u^*}}_{\\faces_h^i}\n      + \\norm{\\sqrt{\\ipp_h}(u^*-I_h u^*)}_{\\faces_h^\\d}\\bigr)\n    \\\\\n    & \\le c h \\snorm{u}_2 h^k \\snorm{u^*}_{k+1}\n  \\end{align}\n  This is exactly the same proof we used before.\n  Using the energy estimate in \\slideref{Theorem}{ip-lifting-h1} we\n  can conclude the prove.\n\\end{solution}\n\n\\end{Problem}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End: \n", "meta": {"hexsha": "bfa5394e6b98f73122a7712567f38ae58779ab22", "size": 15243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mixed/hdivdg.tex", "max_stars_repo_name": "arimiftari/notes", "max_stars_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mixed/hdivdg.tex", "max_issues_repo_name": "arimiftari/notes", "max_issues_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-05-24T07:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-31T12:58:14.000Z", "max_forks_repo_path": "mixed/hdivdg.tex", "max_forks_repo_name": "arimiftari/notes", "max_forks_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-05-15T19:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-05T19:07:29.000Z", "avg_line_length": 35.8658823529, "max_line_length": 103, "alphanum_fraction": 0.6565636686, "num_tokens": 5449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.43933566422010023}}
{"text": "\\subsubsection{\\stid{3.15} Sake: Trilinos/PEEKS} \\label{subsubsect:trilinos}\n\\paragraph{Overview} \nTrilinos is a large and widely used toolkit for scientific computing, with many users both at DOE labs, in academia, and in industry. \nThis project is focused on making Trilinos ready for exascale. One part is to port a core set of Trilinos packages to relevant architectures \n(including NVIDIA, AMD, and Intel GPUs). The other part is to design algorithms that work well on accelerators and at large scale (the focus of \nthe PEEKS sub-project).\n\n\n\\paragraph{Key  Challenges}\nThe Trilinos software library needs to be adapted to the new architectures. This is a large undertaking as there are many packages. Therefore, we focus on a core subset of Trilinos related to linear algebra and solvers. We are sensitive that Trilinos has a large user base and therefore need to minimize any user interface changes. Performance portability across a wide range of platforms is a key challenge.\n\nDeveloping scalable iterative (Krylov) solvers for the US leadership supercomputers \ndeployed in ECP, we acknowledge three major challenges coming from the hardware \narchitecture:\n\\begin{enumerate}\n\\item \nPerformance portability for Krylov solvers to perform well on different architectures with a single code base\nsuch that the applications relying on Trilinos for their linear solver needs can smoothly transition to \nthe new ECP machines.\n\\item \nFine-grained parallelism in a single node that has to be exploited efficiently \nby the iterative solver and the preconditioner.\n\\item\nRising communication and synchronization cost as the\ncomputational power is growing much faster than memory power, resulting in \nincreased pressure on the bandwidth of all cache/memory levels.\n\\end{enumerate}\n\nThese challenges require the redesign of existing iterative solvers with respect \nto higher parallelism, a reduced number of \ncommunication and synchronization points, favoring computations over \ncommunication, and possibly adopting multiprecision algorithms for efficient hardware \nutilization. \n\n\n\\paragraph{Solution Strategy}\n\nThe primary thrusts of the Trilinos/PEEKS project are:\n\\begin{enumerate}\n  \\item Performance portability:\n        We plan to rely heavily on the Kokkos and Kokkos Kernels libraries as that provide kernels that are performance portable across a variety of platforms, including CPU and GPU (NVIDIA, AMD, Intel). There is still much porting work, as some packages rely on UVM (Unified Virtual Memory), which is not widely supported.\n        We will ensure the readiness of the following four solver packages on ECP platforms:\n        distributed linear algebra (Tpetra), Krylov solvers (Belos), algebraic preconditioners and smoothers (Ifpack2), \n        and direct solver interfaces (Amesos2).\n  \\item Low-synchronization Krylov methods:\n    \tWe will develop and deploy pipelined and \n\tcommunication-avoiding Krylov methods in production-quality code, and \n\twe are actively collaborating with the ECP ExaWind project to integrate \n        our new features into their application. Another bottleneck we will address is the orthogonalization needed in GMRES (such as CGS and MGS).\n\\end{enumerate}\n\n\\paragraph{Recent Progress}\n\\begin{enumerate}\n\\item Removal of dependency on UVM:\nwe have removed the dependence of the four solver packages on UVM.\nOn NVIDIA GPUs, UVM simplifies coding by providing automatic data migration between the CPU and GPU memory. However, there are concerns about how well this will be supported, especially in term of performance, on future GPU systems such as Frontier and Aurora. Hence, removing UVM usage was a prerequisite for preparation to run on Frontier and Aurora platforms. \nMore generally, the dependence on UVM posed a risk in term of the solver performance, while explicitly managing the data movement will likely improve solver performance. \n\n\\item HIP backend support:\nwe have ensured the Trilinos solver stacks run on the Frontier early access system (Spock) using HIP backend (without UVM) and resolved initial performance problems. Several performance optimizations remain open which we plan to address this year.\n\n\\item Polynomial preconditioning: We implemented and deployed a GMRES-based polynomial preconditioner in Trilinos/Belos. This can be used as a preconditioner by itself, as a smoother in multigrid (MueLu), or be combined (nested) with any existing preconditioner. Our code is portable to both CPU and GPU. We showed the method is robust and it does not need any user knowledge of eigenvalues of the matrix/operator, unlike the Chebyshev method. In collaboration with the Exagraph ECP project, it has been integrated into the Sphynx spectral partitioner (Trilinos/Zoltan2).\n\n\\item Low-synch orthogonalization: In collaboration with CU Denver and NREL, we developed and implemented a novel low-synch version of Classical Gram-Schmidt (CGS), called DCGS2. By delaying orthonalization and norms, we reduce the synchronization requirement to once per iteration (even with two passes of CGS). The method is more numerically stable than previous attempts at low-synch orthogonalization. Preliminary results on Summit show that the new DCGS2 outperforms the current CGS2 and MGS methods, and achieves up to 66 Gflop/s on 192 GPUs.\n\\end{enumerate}\n\n\\paragraph{Next Steps}\nOur next efforts are:\n\\begin{enumerate}\n\\item Support OpenMP and SYCL backends and\n      perform baseline performance assessments to determine which kernels or algorithms need performance optimization\n      on platforms that are relevant to ECP.\n\\item Conduct performance optimization using HIP, SYCL, and OpenMP backends on the platforms and problems\n      that are relevant to ECP.\n\\item Implement graph assembly on a GPU to enable faster matrix assembly and to avoid data movement between host and device.\n\\item Design an unified solver interface to all the Trilinos solvers in order to ease the effort of ECP applications\n      to switch between solvers and also to compose different solvers in one framework, both of which are needed for the success of ECP application projects especially when the solver options differ across architectures.\n\\item Deploy DCGS2 (or related orthogonalization method) in Trilinos/Belos, likely as an option in GMRES (which is used by many ECP applications).\n\\item Study Block Krylov methods, which may be particularly well suited to GPUs, and also appear to reduce communication.\n\\end{enumerate}\n\n", "meta": {"hexsha": "13253eacff77f090d47194f9149d5112929b4302", "size": 6458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/2.3.3-MathLibs/2.3.3.15-Sake/2.3.3.15-Trilinos.tex", "max_stars_repo_name": "egboman/ECP-ST-CAR-PUBLIC", "max_stars_repo_head_hexsha": "6ac85f302f3f5b1fbf51191f99392a5502a164fa", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/2.3.3-MathLibs/2.3.3.15-Sake/2.3.3.15-Trilinos.tex", "max_issues_repo_name": "egboman/ECP-ST-CAR-PUBLIC", "max_issues_repo_head_hexsha": "6ac85f302f3f5b1fbf51191f99392a5502a164fa", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/2.3.3-MathLibs/2.3.3.15-Sake/2.3.3.15-Trilinos.tex", "max_forks_repo_name": "egboman/ECP-ST-CAR-PUBLIC", "max_forks_repo_head_hexsha": "6ac85f302f3f5b1fbf51191f99392a5502a164fa", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.756097561, "max_line_length": 571, "alphanum_fraction": 0.8062867761, "num_tokens": 1385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.439335657728082}}
{"text": "%\\begin{document}\n\\section{Integrated Autocorrelation Time}%\n\\label{sec:integrated_autocorrelation_time}\n%\nWe include below plots of the integrated autocorrelation time for the\ntopological charge, \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\), for \\(\\mathcal{Q}\n\\in \\mathbb{Z}\\).\n%\n\\begin{figure}[htpb]\n  \\centering\n  \\begin{subfigure}{\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{autocorrs/tau_int_vs_draws}%\n    \\caption{\\label{fig:tau_int_vs_draws}Estimate of \\(\\tau_\\mathrm{int}\\) vs\n      number of draws (length of chain) across \\(\\beta = 5\\) (left), \\(\\beta =\n      6\\) (center), and \\(\\beta = 7\\) (right), for both HMC (grayscale) and the\n    trained sampler (pink).}\n    % \\caption{Estimate of \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\) vs number of\n    %   samples, $N$ for \\(\\beta = 5\\) (left), \\(6\\) (middle), and \\(7\\)\n    %   (right).}%\n  \\end{subfigure}\n  \\begin{subfigure}{\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{autocorrs/tau_int_vs_traj_len}\n    \\caption{\\label{fig:tau_int_vs_traj_len}Estimate of \\(\\tau_{\\mathrm{int}}\\)\n      vs trajectory length, \\(\\lambda\\) across \\(\\beta = 5\\) (left), \\(\\beta =\n      6\\) (center), and \\(\\beta = 7\\) (right), for both HMC (grayscale) and the\n    trained sampler (pink).}\n    % \\caption{Estimate of \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\) vs trajectory\n    %   length, \\(N_\\mathrm{LF} \\cdot \\varepsilon\\) for \\(\\beta = 5\\) (left), \\(6\\)\n    %   (middle), and \\(7\\) (right).}%\n      % \\label{fig:tau_int_vs_traj_len}\n  \\end{subfigure}%\n  \\caption{Intermediate steps in the calculation of the integrated\n    autocorrelation time \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\) vs \\(\\beta\\) for\n  \\(\\beta = 5\\) (left), \\(6\\) (middle) \\(7\\) (right).}\n  % \\begin{subfigure}{\\textwidth}\n  %   \\centering\n  %   \\includegraphics[width=0.7\\textwidth]{autocorrs/tau_int_vs_beta}\n  %   \\caption{Estimate of \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\) vs \\(\\beta\\) for\n  %     both HMC and L2HMC samplers.}%\n  %   \\label{fig:tau_int_vs_beta}\n  % \\end{subfigure}\n\\end{figure}\n%\n\\begin{figure}[htpb]\n  \\centering\n  \\includegraphics[width=0.475\\textwidth]{autocorrs/tau_int_vs_beta}\n  \\caption{Estimate of \\(\\tau_{\\mathrm{int}}^{\\mathcal{Q}}\\) vs \\(\\beta\\) for both\n    HMC and L2HMC samplers.}%\n  \\label{fig:tau_int_vs_beta}\n\\end{figure}\n", "meta": {"hexsha": "5302a2e0751084471e09f17223fb36085e991d71", "size": 2296, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/autocorrs/autocorrs.tex", "max_stars_repo_name": "saforem2/l2hmc-qcd", "max_stars_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 32, "max_stars_repo_stars_event_min_datetime": "2019-04-18T18:50:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T18:30:48.000Z", "max_issues_repo_path": "doc/autocorrs/autocorrs.tex", "max_issues_repo_name": "saforem2/l2hmc-qcd", "max_issues_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2019-09-09T21:10:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:43:51.000Z", "max_forks_repo_path": "doc/autocorrs/autocorrs.tex", "max_forks_repo_name": "saforem2/l2hmc-qcd", "max_forks_repo_head_hexsha": "b5fe06243fae663607b6c88e71373b68b19558fc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-10-31T02:25:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-25T00:49:14.000Z", "avg_line_length": 43.320754717, "max_line_length": 83, "alphanum_fraction": 0.6463414634, "num_tokens": 804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43933565035906913}}
{"text": "% First parameter can be changed eg to \"Glossary\" or something.\n% Second parameter is the max length of bold terms.\n\\begin{mclistof}{List of Variables}{3.2cm}\n\n\\section*{Network Theory}\n\n\\item[$k$] Node degree, ring size\n\\item[$p_k$] Node degree distribution, ring statistics\n\\item[$q_k$] Edge degree distribution\n\\item[$e_{jk}$] Edge joint degree distribution\n\\item[$N,E,V$] Number of rings, edges, vertices\n\\item[$c$] Coordination number\n\\item[$x_c$] Coordination distribution\n\\item[$\\chi$] Euler characteristic\n\\item[$m_k$] Mean ring size distribution\n\\item[$\\alpha$] \\aw{} parameter\n\\item[$r$] Assortativity\n\n\\section*{Stat Mech}\n\\item[$\\mathcal{U}$] Potential energy\n\\item[$\\mathcal{S}$] Entropy\n\n\\end{mclistof} \n", "meta": {"hexsha": "ad9e52a472429944584f25c27a0fd47bdd9b39f3", "size": 718, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/variables.tex", "max_stars_repo_name": "dormrod/Thesis", "max_stars_repo_head_hexsha": "77ddd9fcb3b563a5dc93457682724046053e1137", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-14T11:17:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-14T11:17:18.000Z", "max_issues_repo_path": "text/variables.tex", "max_issues_repo_name": "dormrod/Thesis", "max_issues_repo_head_hexsha": "77ddd9fcb3b563a5dc93457682724046053e1137", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/variables.tex", "max_forks_repo_name": "dormrod/Thesis", "max_forks_repo_head_hexsha": "77ddd9fcb3b563a5dc93457682724046053e1137", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9166666667, "max_line_length": 63, "alphanum_fraction": 0.7311977716, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018545, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4393224725476016}}
{"text": "% intro:\n\\section{Introduction}\n\\label{sec:intro}\n% context, problem defn:\nMany critical problems in program verification can be reduced to\nsolving systems of Constrained Horn Clauses (CHCs), a class of\nlogic-programming\nproblems~\\cite{bjorner13,flanagan03,rummer13a,rummer13b}.\n%\nA CHC is a logical implication with the following form:\n$$\n  R_1(\\vec{v_1}) \\leftarrow R_2(\\vec{v_2}) \\land R_3(\\vec{v_3}) \\land\n  ... \\land \\varphi(\\vec{v_0}, \\vec{v_1}, \\vec{v_2}, \\vec{v_3},...)\n$$\nHere, the left side of the implication, called the head, contains an\nuninterpreted relational predicate applied to a vector of variables.\n%\nThe right side has any number of such predicates conjoined together\nwith a \\emph{constraint} ($\\varphi$). The constraint is a logical formula in a background\ntheory and may use variables named by the predicates.\n%\nA CHC system is a set of CHCs.\n%\nThe goal of the CHC solving problem is to find suitable interpretations\nfor each predicate such that each CHC is logically\nconsistent in isolation.\n\n% introduce the problem of solving recursion-free systems:\nIn this work we focus on the subclass of CHC systems which are known\nas \\emph{recursion-free}. In a recursion-free CHC system, no\nderivation of a predicate will invoke that predicate.\n%\nLess formally, a recursion-free CHC system is one where following\nimplication arrows through the system will never reach the same clause\ntwice.\n%\nRecursion-free CHC systems are an important subclass for two reasons.\n%\nFirst, recursion-free systems can be used to model safety properties\nfor hierarchical programs~\\cite{lal-qadeer15,lal-qadeer-lahiri12}\n(programs with only bounded iteration and recursion).\n%\nSecond and most importantly, a well-known approach for solving a\ngeneral CHC system reduces the input problem to solving a sequence\nof recursion-free systems.\n%\nSuch approaches attempt to synthesize a solution for the   original\nsystem from the solutions of recursion-free systems~\\cite{bjorner13}.\n%\nThe performance of such solvers relies\nheavily on the performance of solving recursion-free CHC systems.\n%\n\n% current general techniques for solving recursion-free systems\nTypically, even recursion-free CHC systems are not solved directly.\n%\nInstead, they are reduced to a more specific subclass of\nrecursion-free CHC system.\n%\nThese classes include those of\n\\emph{body-disjoint} (or \\emph{derivation tree})\nsystems~\\cite{heizmann10,bjorner13,mcmillan14,rummer13a,rummer13b} and\nof \\emph{linear} systems~\\cite{albarghouthi12a}.\n%\nWe will discuss these classes in \\autoref{sec:overview} and\n\\autoref{sec:related-work}.\n%\nSuch classes can be solved by issuing\n\\emph{interpolation queries} to find suitable definitions for the\nuninterpreted predicates.\n%\n\n% Time complexity\nIn general, solving a recursion-free CHC system for\npropositional logic and the theory of linear integer arithmetic is\nco-NEXPTIME-complete~\\cite{rummer13b}.\n%\nIn contrast, solving a linear system or body-disjoint system with the\nsame logic and theories is in co-NP~\\cite{rummer13b}.\n%\nWe refer to such classes that are solvable in co-NP time as\n\\emph{directly solvable}.\n%\nBecause solving an arbitrary recursion-free system is harder than\nsolving a directly solvable system, solvers which reduce to directly\nsolvable systems are highly reliant on the size of the reductions.\n\n% contribution of this paper: CDD systems:\nThe first contribution of this paper is the introduction of a novel\nclass of directly solvable systems that we refer to as\n\\emph{Clause-Dependence Disjoint} (CDD).\n%\nThe formal definition of CDD is given at ~\\autoref{defn:cdds}.\n%\nCDD is a strict superset of the union of previously introduced classes\nof directly solvable systems.\n%\nThe key characteristic of this class is that when an arbitrary\nrecursion-free system is reduced to a CDD system and to a system from\na different directly solvable class, the CDD system is frequently the\nsmaller of the two.\n%\nTherefore, solving recursion-free systems by reducing them to CDD form\nis often less computationally expensive than reducing them to a\nsystem in a different class.\n\n% a new solver\nThe second contribution of this paper is a solver for CHC systems,\nnamed \\sys.\n%\nGiven a recursion-free system $S$, \\sys reduces the problem of solving\n$S$ to solving a CDD system $S'$.\n%\nIn the worst case, it is possible that the size of $S'$ may be\nexponential in the size of $S$.\n%\nHowever, empirically we have found that the size of $S'$ is usually\nclose enough to the size of $S$ that \\sys frequently outperforms\n\\duality, one of the best known CHC solvers.\n%\nThe procedure implemented in \\sys is a generalization of existing\ntechniques that synthesize compact verification conditions for\nhierarchical programs~\\cite{flanagan01,lal-qadeer15}.\n%\nGiven a general (possibly recursive) CHC system, \\sys solves a\nsequence of recursion-free systems.\n%\nEach subsystem is a bounded unwinding of the original system. \\sys\nattempts to combine the solutions of these recursion-free systems to\nsynthesize a solution to the original problem, as has been proposed\nin previous work~\\cite{rummer13b}.\n\n% experience:\nWe implemented \\sys within the \\duality CHC solver~\\cite{bjorner13},\nwhich is implemented within the \\zthree automatic theorem\nprover~\\cite{moura08}.\n%\nWe evaluated the effectiveness of \\sys on standard benchmarks drawn\nfrom SVCOMP15~\\cite{svcomp15}.\n%\nThe results indicate that \\sys outperforms modern solvers many cases.\n%\nFuthermore, the results indicate that combining the strengths of \\sys\nwith that of other existing approaches (as discussed in\n\\autoref{sec:evaluation}) is a promising direction for the future of\nCHC solving.\n\n% paper outline:\nThe rest of this paper is organized as follows.\n%\n\\autoref{sec:overview} illustrates the operation of \\sys on a\nrecursion-free CHC system.\n%\n\\autoref{sec:background} reviews technical work on which \\sys is\nbased.\n%\n\\autoref{sec:approach} describes \\sys in technical detail.\n%\n\\autoref{sec:evaluation} gives the results of our empirical evaluation\nof \\sys.\n%\n\\autoref{sec:related-work} compares \\sys to related work.\n", "meta": {"hexsha": "f1d40fdc43bb1b622ed29cd4c923cbc982594634", "size": 6074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/introduction.tex", "max_stars_repo_name": "DAHeath/shara", "max_stars_repo_head_hexsha": "030d7e94d19e9cb015f9f85b3a2e3c7f796e8a5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/introduction.tex", "max_issues_repo_name": "DAHeath/shara", "max_issues_repo_head_hexsha": "030d7e94d19e9cb015f9f85b3a2e3c7f796e8a5f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/introduction.tex", "max_forks_repo_name": "DAHeath/shara", "max_forks_repo_head_hexsha": "030d7e94d19e9cb015f9f85b3a2e3c7f796e8a5f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.263803681, "max_line_length": 89, "alphanum_fraction": 0.7899242674, "num_tokens": 1516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506472514406, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.43927222331329474}}
{"text": "\\documentclass{llncs}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n\\usepackage{llncsdoc}\n% \\usepackage{color}\n% \\everymath{\\color{blue}}\n%\\everydisplay{\\color{blue}}\n\\let\\displaystyle\\textstyle\n\n\n\\newcommand{\\ie}[1] {\n  \\begin{itemize}\n    #1\n  \\end{itemize}\n}\n% \\usepackage{aaai}\n\\usepackage{times}\n\\usepackage{helvet}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{courier}\n\\usepackage{multirow}\n    \\usepackage[bottom]{footmisc}\n\\usepackage{microtype}\n\\usepackage{tikz}\n\\usepackage{comment}\n\\usepackage{chngcntr}\n\\usepackage{float}\n\\usepackage[algo2e,ruled,linesnumbered,vlined]{algorithm2e}\n\\counterwithin{figure}{section}\n\\usepackage{algorithmic}\n\\usepackage{algorithm}\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}}\n\n% \\usepackage[timestamp, dark]{draftcopy}\n% \\usepackage{doc}\n\\usepackage{url}\n% \\usepackage[sort]{natbib}\n%\\usepackage{amsmath,amssymb, amsthm}\n\\usepackage{balance}\n% \\usepackage[switch, pagewise, mathlines, displaymath]{lineno}\n\n% \\setcounter{secnumdepth}{2}\n \\usepackage{fancyvrb}\n\\usepackage{graphicx}\n\n\\usepackage{listings}\n%opening\n\\title{}\n\\author{}\n\n\\begin{document}\n\n\n\n\\section{Definitions}\n\\begin{definition}[Formula] \\label{formula}\n{\\rm\n\\ie{\n\\item $\\emptyset$ is a {\\em formula}\n\\item \\ $T \\in D$, where T is a variable, a %\\sparc\\\nground term or an arithmetic term,\nand $D$ is a set of %\\sparc\\\nground terms, is a {\\em formula},\n\\item  $t_1\\diamond t_2$, where $t_1$ and $t_2$ are terms and\n$\\diamond \\in \\{ = ,\\neq,  \\prec, \\preceq\\}$, is a {\\em formula}, and\n\\item if $A$ and $B$ are formulas then ($A$ $\\land$ $B$), ($A$ $\\lor$ $B$), and  $\\neg A$ are {\\em formulas}.\n}\n}\n\\end{definition}\n\n\\begin{definition}[Empty Formula] \\label{empty formula}\n\\begin{itemize}\n \\item $\\emptyset$ is an  {\\em empty formula}\n \\item if $A$ and $B$ are empty formulas then ($A$ $\\land$ $B$), ($A$ $\\lor$ $B$), and  $\\neg A$ are {\\em empty formulas}.\n\\end{itemize}\n \\end{definition}\n In what follows  any empty formula is interpreted as \\textbf{false}.\n \n \n \n \\begin{definition}[Primitive Formula] \\label{primitive formula}\n  {\\rm\n\\ie{\n\\item \\ $T \\in D$, where T is a variable, a %\\sparc\\\nground term or an arithmetic term,\nand $D$ is a set of %\\sparc\\\nground terms, is a {\\em primitive formula},\n\\item  $t_1\\diamond t_2$, where $t_1$ and $t_2$ are terms and\n$\\diamond \\in \\{ = ,\\neq,  \\prec, \\preceq\\}$, is a {\\em primitive formula}, and\n\\item if $A$ and $B$ are formulas then    $\\neg A$  is a {\\em  primitive formula}.\n}\n}\n \\end{definition}\n \n\n\n \\begin{definition}[Primitive Conjunction] \\label{primitive conjunction}\\\\\n {\\rm\n  A formula $\\mathcal{F}$ is  a \\textit{primitive conjunction} if it is of the form $G_1 \\land \\dots \\land G_n$, where $G_1,\\dots,G_n$ are primitive formulas.\n}\n \\end{definition}\n \n \\begin{definition}[Arithmetic Variable] \\label{arithmetic variable} \\\\\n  {\\rm\n    A variable $X$ occuring in a primitive conjunction $\\mathcal{C}=G_1 \\land \\dots \\land G_n$ is called arithmetic with respect to $\\mathcal{C}$ if one of the following conditions holds:\n    \\begin{itemize}\n      \\item X occurs in an arithmetic term containing at least one arithmetic operation.\n      \\item one of $G_i$ is of the form  $X \\in D$, where $D$ is a range of natural numbers.\n      \\item one of $G_i$ is of the form  $X \\diamond Y$ or $Y \\diamond X$, where Y is an arithmetic variable and $\\diamond \\in \\{ \\prec,<,\\preceq,=\\}$. \n   \\end{itemize}\n \n  }\n \\end{definition}\n\\begin{definition}[Arithmetic Term] \\label{aterm}\n{\\rm\n A term $t$ occuring in a primitive conjunction $\\mathcal{C}=G_1 \\land \\dots \\land G_n$ is called \\textit{arithmetic} \nwith respect to $\\mathcal{C}$ if one of the following conditions holds:\n \\begin{enumerate}\n  \\item $t$ is a number\n  \\item $t$ contains an arithmetic operation ('+','-', or '*').\n  \\item $t$ is not a record and all variables in $t$ are arithmetic with respect to $\\mathcal{C}$\n \\end{enumerate}\n}\n\\end{definition}\n\n \\begin{definition}[Primitive Arithmetic Constraint] \\label{primitive arithmetic constraint}\n{\\rm\n   A primitive constraint $G$ occurring in a primitive conjunction $\\mathcal{C}=G_1 \\land \\dots \\land G_n$  \nis called \\textit{arithmetic} with respect to $\\mathcal{C}$ if one of the following conditions holds:\n \\begin{itemize}\n  \\item $G$ is of the form $T \\in D$, where $T$ is an arithmetic term with respect to $\\mathcal{C}$ and $D$ is of the form $n1..n2$.\n  \\item $G$ is of the form $t_1\\diamond t_2$, where both $t_1$ and $t_2$ are arithmetic terms with respect to $\\mathcal{C}$. \n \\end{itemize}\n}\n \\end{definition}\n\n\n\\section{Algorithms}\n\\begin{algorithm2e}[H]\\caption{ExpandSolve}\n \\DontPrintSemicolon\n %\\SetAlgoBlockMarkers{begin}{end}\n \\KwIn{Formulas $\\mathcal{F}$, ${\\cal TODO}$, ${\\cal C}$, \n         such that $\\mathcal{F} \\land {\\cal TODO} \\land {\\cal C}$ is non-empty}\n \\KwOut{\\textbf{True} if $\\mathcal{F} \\land {\\cal TODO} \\land {\\cal C}$ is satisfiable and \\textbf{false} otherwise }\n\\If{ $\\mathcal{F}=\\emptyset$}\n{\n \\If{$\\mathcal{TODO}=\\emptyset$}\n {\n   \\Return Solve(Simplify($\\mathcal{C}$),$maxint$) \\;\n }\n \\Else \n {\n   Let $\\mathcal{TODO}$ be $G_1 \\land \\dots \\land  G_n$ \\;\n   \\Return {ExpandSolve($G_1$,$G_2 \\land \\dots \\land G_n$,$\\mathcal{C}$)}\\;\n }\n}\n\\ElseIf{$\\mathcal{F}=\\neg(A \\land B)$} {\n  ExpandSolve($\\neg A \\lor \\neg B, \\mathcal{TODO},\\mathcal{C})$\\;\n}\n\\ElseIf{$\\mathcal{F}=\\neg(A \\lor B)$} {\n    ExpandSolve($\\neg A \\land \\neg B, \\mathcal{TODO},\\mathcal{C})$\\;\n}\n\\ElseIf{$\\mathcal{F}=A \\lor B$} {\n  \\If{ExpandSolve($A,\\mathcal{TODO},\\mathcal{C})$=\\textbf{false}}\n  {\n   \\Return ExpandSolve($B,\\mathcal{TODO},\\mathcal{C}$) \\;\n  }\n  \\Else {\n   \\Return \\textbf{true}\\;\n  }   \n}\n\\ElseIf{$\\mathcal{F}=A \\land B$} {\n  \\Return ExpandSolve($A, B\\land \\mathcal{TODO},\\mathcal{C}$) \\;\n}\n\\Else \n{\n\\Return ExpandSolve($\\emptyset,\\mathcal{TODO},\\mathcal{F} \\land \\mathcal{C}$)\n}\n \\Return {\\em true} \\;\n\\end{algorithm2e}\n\n\\begin{algorithm2e}[H]\\caption{Simplify}\n \\DontPrintSemicolon\n  \\KwIn{Primitive conjunction $G_1 \\land \\dots \\land G_n$, the upper limit for natural numbers} \n  \\KwOut {Primitive conjunction $G_1 \\land \\dots \\land G_m$ after simplification}\n  $\\mathcal{C}$ := $G_1 \\land \\dots \\land G_n$ \\;\n  \n  \n  \\ForEach {$G_i$ in $G_1 \\land \\dots \\land G_n$}\n  {\n    \\If{$G_i$ is of the form $T \\in D$, and T is a ground term }\n   {\n      \\If{T is in D}\n      {\n        Remove $G_i$ from $\\mathcal{C}$\\;\n      }\n      \\Else\n      {\n      \\Return \\textbf{false}\\;\n      }\n   }\n   \n   \n   \\If{$G_i$ is of the form $X \\in D$, X is an arithmetic variable in $\\mathcal{C}$, and D does not contain a number}\n   {\n     \\Return \\textbf{false}\n   }\n   \n   \\If{$G_i$ is of the form $T \\in D$, T is an arithmetic term with at least one operation, and D does not contain a number}\n   {\n      \\Return \\textbf{false}\\;\n   }\n  \\If{$G_i$ is of the form  $t_1 \\diamond t_2$ and both $t_1$ and $t_2$ are ground terms}\n   {\n     Let $G_i^\\prime$ be obtained from $G_i$ where $<,\\leq$ replaced with $\\prec,\\preceq$ respectively.\n     \\If {$G_i^\\prime$ is true}\n     {\n        Remove $G_i$ from $\\mathcal{C}$\\;\n     }\n     \\Else {\n        \\Return \\textbf{false} \\;\n     }\n   } \n   \n   \n    \\If{$G_i$ is of the form  $t_1 \\diamond t_2$, where one of $t_1$ and $t_2$ is an arithmetic term with at least one operation, number, arithmetic variable; and another one is a symbolic term (a string constant or a term built from a functional symbol),\n    and diamond is either $=,<,\\leq,\\prec, or \\preceq$ }\n   {\n        \\Return \\textbf{false} \\;\n   }\n   \n   \\Return $\\mathcal{C}$\n  }  \n\\end{algorithm2e}\n\n\n\n\\begin{algorithm2e}[H]\\caption{Split}\n \\DontPrintSemicolon\n  \\KwIn{A clingcon rule of the form $r(X_1,\\dots X_n):-BODY$} \n  \\KwOut{A collection of clingcon rules $R$} \n  Let $BODY$ be $A_1,A_2,\\dots A_m$.\n  Let $\\mathcal{G}$ be undirected graph with m nodes $N_1,\\dots N_m$, such that there is an edge between $N_i$ and $N_j$ iff atoms $A_i$ and $A_j$ share a common variable.\n  Let $C_1,\\dots, C_k$ be connected components of $\\mathcal{G}$. \\;\n  $R:=\\emptyset$ \\;\n  \\ForEach {connected component $C_i$ in   $C_1,\\dots, C_k$} \n  {\n    Let $C_i$ consists of nodes $N_{i_1},\\dots N_{i_t}$.\n    Let $X_1,\\dots, X_p$ be all variables in $A_{i_1},\\dots A_{i_t}$. \\;\n    $R:=R \\cup r_i:-A_{i_1},\\dots A_{i_t}$ \\;\n  } \n  $R:=R \\cup r:-r_1,\\dots,r_k.$ \\;\n  $R:=R \\cup  :-not~r.$ \\;\n\\end{algorithm2e}\n\n  \n\n\\begin{algorithm2e}[H]\\caption{Solve}\n \\DontPrintSemicolon\n  \\KwIn{Primitive conjunction $G_1 \\land \\dots \\land G_n$, the upper limit for natural numbers $maxint$.}\n  \\KwOut{\\textbf{true} if $G_1 \\land \\dots \\land G_n$ is satisfiable and \\textbf{false} otherwise.}\n   \\tcc*[l]{Build rules for arithmetic constraints}\n   $\\Pi_{prolog}:= :-use\\_module(library(clpfd)).$ \\;\n   $BODY:= {\\bf true}$ \\;\n\n\n   \\ForEach{primitive arithmetic $G_i$   of the form $t_1 \\diamond t_2$}\n   { \n     Replace $\\prec, = , !=,<=$ with $\\#<,\\#=,\\#=,\\#=<$ respectively \\;\n     $BODY := BODY \\land G_i$ \\;\n   }\n   \n\n\n   \\ForEach{primitive arithmetic  $G_i$   of the form $(t\\in D)$,where $D$ is of the form $[n1..n2]$}{\n   $BODY := BODY \\land  t~in~n_1..n_2$ \\;\n   }\n\n\n   \\ForEach{primitive arithmetic  $G_i$   of the form $\\neg(t\\in D)$,where $D$ is of the form $[n1..n2]$, and $g_i$ is an unique label for $G_i$}{\n      $\\Pi_{prolog} := \\Pi_{prolog} \\cup g_i(t) :- n\\#>n_2. \\cup g_i(t) :- n\\#<n_2$.  \n      $BODY := BODY \\land  g_i(t)$ \\;\n   }\n\n\n   \\ForEach{primitive arithmetic $G_i$ of the form $(t \\in D)$ and $\\neg(t \\in D)$ , where $D$ is not of the form $[n1..n2]$}\n   {\n      Remove all symbolic terms from D\\; \n      Add the following rule to $\\Pi_{prolog}$: (d is an unique label for D) \\;\n     \\texttt{ set\\_d(X):-member(X,[t1,\\dots tn]).}\\;  \n     \n   }\n \n   \\ForEach{primitive non-arithmetic $G_i$ of the form $\\neg (t \\in D)$:}\n   {\n    $BODY:=BODY \\land \\\\+~set_d(t)$ \\;\n   }\n   \n  \\ForEach{primitive non-arithmetic $G_i$ of the form $t \\in D$:}\n   {\n    $BODY:=BODY \\land set_d(t)$ \\;\n   }\n   \n   \n   \\ForEach{primitive non-arithmetic $G_i$ of the form $t_1 \\diamond t_2$:}\n   {\n    $BODY:=BODY \\land G_i$ \\;\n   }\n \n    \\ForEach {arithmetic variable $X$ in $BODY$} {\n      $BODY:=integer(X) \\land BODY$\n    }\n  \n   \n   Let $Y_1,\\dots Y_n$ be the set of all variables in $BODY$ \\;\n   $\\mathcal{R}:= p :-BODY$ \\;\n   \n   $\\Pi_{prolog}:=\\Pi_{prolog} ~\\cup~ \\mathcal{R} $\\;\n   \\If{$\\Pi_{prolog}$ outputs 'yes' for query ?-p}\n   {\n     \\Return \\textbf{true} \\;\n   }\n   \\Else \n   {\n     \\Return \\textbf{false}\\;\n   }\n \\end{algorithm2e}\n\\end{document}\n", "meta": {"hexsha": "45f4817eddff0dd45a8eb5eda5111d38ac08bd74", "size": 10511, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/sparc_to_formula/sparc_spec_pr.tex", "max_stars_repo_name": "hharithaki/sparc", "max_stars_repo_head_hexsha": "bc8eff62c64921be5b3d029ed78caf148dbe0934", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2015-12-02T02:39:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T18:01:35.000Z", "max_issues_repo_path": "docs/sparc_to_formula/sparc_spec_pr.tex", "max_issues_repo_name": "hharithaki/sparc", "max_issues_repo_head_hexsha": "bc8eff62c64921be5b3d029ed78caf148dbe0934", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2015-09-11T19:19:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-29T04:26:18.000Z", "max_forks_repo_path": "docs/sparc_to_formula/sparc_spec_pr.tex", "max_forks_repo_name": "hharithaki/sparc", "max_forks_repo_head_hexsha": "bc8eff62c64921be5b3d029ed78caf148dbe0934", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2015-06-07T22:33:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-18T14:01:37.000Z", "avg_line_length": 31.5645645646, "max_line_length": 255, "alphanum_fraction": 0.6366663495, "num_tokens": 3673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7606506418255927, "lm_q1q2_score": 0.4392722091175955}}
{"text": "\\documentclass[fontsize=11pt]{article}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=0.75in]{geometry}\n\n\\title{CSC110 Fall 2021 Assignment 2: Logic, Constraints, and Nested Data}\n\\author{Azalea Gui & Peter Lin}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\section*{Part 1: Predicate Logic}\n\n\\begin{enumerate}\n\n\\item[1.]\n    \\begin{enumerate}\n        \\item[1.] When $D_1 = [0,\\infty) $ \\\\\n            Statement 1 is True because every number $x \\in D_1$ is smaller than a $y \\in D_1$ (For example, $y=x+1>x$). \\\\\n            Statement 2 is False because when $y=0$, there isn't an $x \\in D_1$ smaller than $y$. \n        \\item[2.] When $D_2 = \\mathbb{Z}$ \\\\\n            Statement 1 is True because every integer $x$ is smaller than some integer $y$ (For example, $y=x+1>x$). \\\\\n            Statement 2 is True because every integer $y$ is greater than some integer $x$ (For example, $x=y-1<y$).\n        \\item[3.] When $D_3 = \\{0\\}$ \\\\\n            Statement 1 is False because when $x=0$, there isn't a $y \\in D_3$ greater than $x$. \\\\\n            Statement 2 is False because when $y=0$, there isn't an $x \\in D_3$ smaller than $y$. \n    \\end{enumerate}\n\n\\item[2.]\n    \\begin{enumerate}\n        \\item[1.] $P(x): 1 < x < 8$ where $x \\in S$\n        \\item[2.] $Q(x): x < 8$ where $x \\in S$\n    \\end{enumerate}\n    When $x \\leq 1$ and $x \\geq 8$, $P(x)$ is False, so $P(x) \\land Q(x)$ would be False and $P(x) \\implies Q(x)$ would be True. \\\\\n    When $1 < x < 8$, $P(x)$ and $Q(x)$ are both True, so both $P(x) \\land Q(x)$ and $P(x) \\implies Q(x)$ would be True. \\\\\n    Since $S = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\}$, \\\\\n    Statement 3 would be False because $P(x) \\land Q(x)$ is False when $x=0$, \\\\ \n    Statement 4 would be True because $P(x) \\implies Q(x)$ is true for all values of $x \\in S$.\n\n\\item[3.]\nComplete this part in the provided \\texttt{a2\\_part1.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\n\\item[4.]\nComplete this part in the provided \\texttt{a2\\_part1.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\n\\end{enumerate}\n\n\\section*{Part 2: Conditional Execution}\n\nComplete this part in the provided \\texttt{a2\\_part2.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\n\\newpage\n\n\\section*{Part 3: Generating a Timetable}\n\n\\begin{enumerate}\n\n\\item[1.]\nComplete this part in the provided \\texttt{a2\\_part3.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\n\\item[2.]\n\n\\begin{enumerate}\n\\item[(a)]\n\n\\emph{IMPORTANT DEFINITIONS/NOTATION} (don't change this text!)\n\nWe define the following sets:\n\n\\begin{itemize}\n\\item $C$: the set of all possible courses\n\\item $S$: the set of all possible sections\n\\item $M$: the set of all possible meeting times\n\\item $SC$: the set of all possible schedules\n\\end{itemize}\n\nWe also define the following notation for expressions involving the elements of these sets:\n\n\\begin{itemize}\n\\item\nThe first three (courses/sections/meeting times) are represented as tuples (as described in the assignment handout), and you can use the indexing operation on these values. For example, you could translate ``every section term is in $\\{'F', 'S', 'Y'\\}$'' into predicate logic as the statement:\n\n    \\[\\forall s \\in S,~ s[1] \\in \\{'F', 'S', 'Y' \\} \\]\n\n\\item\nThe start and end times of a meeting time can be compared chronologically using the standard $<$, $\\leq$, $>$, and $\\geq$ operators.\n\n\\item\nFor a section $s \\in S$, $s[2]$ represents a tuple of meeting times.\nYou may use standard set operations and quantifiers for these tuples (pretend they are sets).\nFor example, we can say:\n\n    \\begin{itemize}\n    \\item $\\forall s \\in S,~ s[2] \\subseteq M$\n    \\item $\\forall s \\in S,~ \\forall m \\in s[2],~ m[1] < m[2]$\n    \\end{itemize}\n\n\\item\nFinally, for a schedule $sc \\in SC$, you can use the notation $sc.sections$ to refer to a set of all sections in that schedule.\nYou can use quantifiers with that set of schedules as well, e.g.\n$\\forall s \\in sc.sections,~ ...$\n\\end{itemize}\n\n\\textbf{Predicate for meeting times conflicting:}\n% TODO: fill in the predicate definition for two meeting times conflicting\n\n\\begin{align*}\nMeetingTimesConflict(m_1, m_2) : m_1[0] == m_2[0] \\land m_1[2] > m_2[1] \\land m_2[2] > m_1[1] \\\\\n\\qquad \\text{where $m_1, m_2 \\in M$}\n\\end{align*}\n\n\\smallskip\n\n\\textbf{Predicate for sections conflicting:}\n% TODO: fill in the predicate definition for two sections conflicting.\n% Use the MeetingTimesConflict predicate in your response.\n\n\\begin{align*}\nSectionsConflict(s_1, s_2) : (s_1[1]=\\text{'Y'} \\lor s_2[1]=\\text{'Y'} \\lor s_1[1] = s_2[1]) \\land \\\\\n\\exists m_1 \\in s_1[2], \\exists m_2 \\in s_2[2], \\text { s.t. } MeetingTimesConflict(m_1, m_2) \\\\\n\\qquad \\text{where $s_1, s_2 \\in S$}\n\\end{align*}\n\n\\smallskip\n\n\\textbf{Predicate for valid schedule:}\n% TODO: fill in the predicate definition for a schedule being valid.\n% Use the SectionsConflict predicate in your response.\n\n\\begin{align*}\nIsValidSchedule(sc) : \\forall s_1, s_2 \\in sc.sections, SectionsConflict(s_1, s_2) \\Rightarrow s_1 = s_2\n\\qquad \\text{where $sc \\in SC$}\n\\end{align*}\n\n\n\\item[(b)]\nComplete this part in the provided \\texttt{a2\\_part3.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\\end{enumerate}\n\n\\item[3.]\n\n\\begin{enumerate}\n\\item[(a)]\n\nYou may use all notation from question 2(a).\nNote that a course $c \\in C$ is a tuple, and $c[2]$ is a set of sections, and so can be quantified over: $\\forall s \\in c[2], ...$.\n\n\\smallskip\n\n\\textbf{Predicate for section-schedule compatibility:}\n% TODO: fill in the predicate definition for a section being compatible with a schedule.\n\n\\begin{align*}\nIsCompatibleSection(sc, s) : \\forall s_1 \\in sc.sections, \\neg SectionsConflict(s, s_1)\n\\qquad \\text{where $sc \\in SC, s \\in S$}\n\\end{align*}\n\n\\smallskip\n\n\\textbf{Predicate for course-schedule compatibility:}\n% TODO: fill in the predicate definition for a course being compatible with a schedule.\n% Use IsCompatibleSection in your response.\n\n\\begin{align*}\nIsCompatibleCourse(sc, c) : \\exists s \\in c[2] \\text{ s.t. } IsCompatibleSection(sc, s)\n\\qquad \\text{where $sc \\in SC, c \\in C$}\n\\end{align*}\n\n\\item[(b)]\nComplete this part in the provided \\texttt{a2\\_part3.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\\end{enumerate}\n\n\\end{enumerate}\n\n\\section*{Part 4: Processing Raw Data}\nComplete this part in the provided \\texttt{a2\\_part4.py} starter file.\nDo \\textbf{not} include your solution in this file.\n\n\\end{document}\n", "meta": {"hexsha": "c71d2ae71f65789c2abd834567cd2bded351afea", "size": 6515, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignments/a2/a2.tex", "max_stars_repo_name": "hykilpikonna/CSC110", "max_stars_repo_head_hexsha": "12a4f9361e0c79fe03cafa3c283eb96706359f46", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assignments/a2/a2.tex", "max_issues_repo_name": "hykilpikonna/CSC110", "max_issues_repo_head_hexsha": "12a4f9361e0c79fe03cafa3c283eb96706359f46", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignments/a2/a2.tex", "max_forks_repo_name": "hykilpikonna/CSC110", "max_forks_repo_head_hexsha": "12a4f9361e0c79fe03cafa3c283eb96706359f46", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6542553191, "max_line_length": 293, "alphanum_fraction": 0.6824251727, "num_tokens": 2083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.8267117876664789, "lm_q1q2_score": 0.4391570506870081}}
{"text": "\\documentclass[addpoints,12pt]{exam}\n\\usepackage[]{graphicx}\\usepackage[]{color}\n%% maxwidth is the original width if it is less than linewidth\n%% otherwise use linewidth (to make sure the graphics do not exceed the margin)\n\\makeatletter\n\\def\\maxwidth{ %\n  \\ifdim\\Gin@nat@width>\\linewidth\n    \\linewidth\n  \\else\n    \\Gin@nat@width\n  \\fi\n}\n\\makeatother\n\n\\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}\n\\newcommand{\\hlnum}[1]{\\textcolor[rgb]{0.686,0.059,0.569}{#1}}%\n\\newcommand{\\hlstr}[1]{\\textcolor[rgb]{0.192,0.494,0.8}{#1}}%\n\\newcommand{\\hlcom}[1]{\\textcolor[rgb]{0.678,0.584,0.686}{\\textit{#1}}}%\n\\newcommand{\\hlopt}[1]{\\textcolor[rgb]{0,0,0}{#1}}%\n\\newcommand{\\hlstd}[1]{\\textcolor[rgb]{0.345,0.345,0.345}{#1}}%\n\\newcommand{\\hlkwa}[1]{\\textcolor[rgb]{0.161,0.373,0.58}{\\textbf{#1}}}%\n\\newcommand{\\hlkwb}[1]{\\textcolor[rgb]{0.69,0.353,0.396}{#1}}%\n\\newcommand{\\hlkwc}[1]{\\textcolor[rgb]{0.333,0.667,0.333}{#1}}%\n\\newcommand{\\hlkwd}[1]{\\textcolor[rgb]{0.737,0.353,0.396}{\\textbf{#1}}}%\n\n\n\\usepackage{alltt}\n\\usepackage{mathtools}\n%%\\usepackage{marginnote}\n%%\\usepackage[top=1in, bottom=1in, outer=5.5in, inner=1in, heightrounded, marginparwidth=1in, marginparsep=1in]{geometry}\n\\usepackage{enumerate}\n%% mess with the fonts\n%%\\usepackage{fontspec}\n%%\\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n% For package xtable\n\\usepackage{booktabs}  % Nice toprules and bottomrules\n\\heavyrulewidth=1.5pt  % Change the default to heavier lines\n\\usepackage{longtable} \n%%\\usepackage{tabularx}  % To control the width of the table\n% this should make caption font bold.\n%%\\usepackage{xstring}\n%%\\usepackage{etoolbox}\n%%\\usepackage{url}\n%% xetex only \\usepackage{breakurl}\n\\usepackage{float} % for fig.pos='H'\n%%\\usepackage{wrapfig}\n%%\\usepackage{tikz}\n\\usepackage{colortbl,xcolor}\n\n\\newcommand{\\dev}[1] {Dev_{\\bar{#1}}}\n\n\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}\n\\begin{document}\n\\header{Math 2300 Section 2}{Equations 1}{February 27, 2015}\n\\section{Measures of Center}\nMean\n\\begin{equation*}\n\\bar{x}=\\frac{\\sum\\limits_{i=1}^{N} x_i }{N} \n\\end{equation*}\n\\section{Measures of Spread}\nDeviation\n\\begin{equation*}\nDev_{\\bar{x}}=(x_i-\\bar{x}) \n\\end{equation*}\n\\begin{equation*}\nDev_{\\bar{x}}^2=(x_i-\\bar{x})^2 \n\\end{equation*}\nVariance\n\\begin{multline*}\nVar(X)=\\frac{\\sum_{i=1}^{N} Dev_{\\bar{x}}^2}{N}=\\frac{\\sum_{i=1}^{N} (x_i-\\bar{x})^2}{N}\n\\end{multline*}\nStandard Deviation\n\\begin{equation*}\nStdDev(X)=\\sqrt{Var(X)} \n\\end{equation*}\n\\section{Measures of Association}\nCovariance\n\\begin{equation*}\nCov(X,Y)=\\frac{\\Sigma_{i=1}^{N} Dev_{\\bar{x}}Dev_{\\bar{y}}}{N}\n\\end{equation*}\nCorrelation\n\\begin{equation*}\nCorr(X,Y)=\\frac{Cov(Y,X)}{(StdDev(X)StdDev(Y))}\n\\end{equation*}\nRegression Equation\n\\begin{equation*}\nY=\\alpha + \\beta X + \\epsilon\n\\end{equation*}\n\\begin{equation*}\n{\\beta}=\\frac{Cov(X,Y)}{Var(X)}=Corr(X,Y)\\frac{StdDev(Y)}{StdDev(X)}\n\\end{equation*}\n\\begin{equation*}\n{\\alpha}=\\bar{y}-{\\beta}\\bar{x}\n\\end{equation*}\n\\end{document}\n", "meta": {"hexsha": "ae0ddf0e7f10030597afa6c196b1282fd3eb6828", "size": 3011, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exam1equations.tex", "max_stars_repo_name": "KateDavis/MA2300", "max_stars_repo_head_hexsha": "d58bdd7ff72c8b259f0d5bceb22586aa676c456a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exam1equations.tex", "max_issues_repo_name": "KateDavis/MA2300", "max_issues_repo_head_hexsha": "d58bdd7ff72c8b259f0d5bceb22586aa676c456a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exam1equations.tex", "max_forks_repo_name": "KateDavis/MA2300", "max_forks_repo_head_hexsha": "d58bdd7ff72c8b259f0d5bceb22586aa676c456a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7244897959, "max_line_length": 121, "alphanum_fraction": 0.6977748256, "num_tokens": 1187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8031738034238807, "lm_q1q2_score": 0.43912576100642603}}
{"text": "%%\n%%  appendixPolarCalib.tex - Obstacle Detection and Planning for Autonomous Vehicles based on Computer Vision Techniques\n%%\n%%  Copyright 2014 Néstor Morales <nestor@isaatc.ull.es>\n%%\n%%  This work is licensed under a Creative Commons Attribution 4.0 International License.\n%%\n\n\\graphicspath{{./images/chapter04/bmps/}{./images/chapter04/vects/}{./images/chapter04/}}\n\n\\chapter{Polar Rectification}\\label{ch:appendix_polar_calib}\n\nIn chapter \\ref{ch:chapter04}, we registered a pair of images obtained between frames, with the aim of distinguishing real from fake obstacles. The best way to do such a registration is through a polar rectification process \\citep{pollefeys1999simple}. This non-linear polar rectification method allows registering the images along the time, helping in the detection of motion. The basis of this method is to reparameterize the images by setting the coordinates of their pixels in terms of the epipoles of a stereo pair. In this process, a linear transformation has to be found for every wedge part of the image with vertex at the epipole. This allows rectifying the whole image for every possible epipolar configuration, while keeping the size of resulting image reasonably large. The algorithm is designed in such way that no pixel loss is guaranteed. Also the length of original epipolar lines is preserved. The resulting image is upper-bounded by a size of $(2 (W + H) \\times \\sqrt{W^2 + H^2})$, where $W$ is the image width and $H$ its height. An implementation of this method is made available at \\url{https://github.com/nestormh/PolarCalibration}.\n\nIn order to reduce the matching ambiguity to a half of the epipolar line in a case of epipole inside the image, it uses the concept of oriented epipolar geometry. To do this, one point correspondence is needed in both views. With this information, just positive coordinates over the epipolar line will be taken into account. The transfer of corresponding epipolar lines is obtained from the expression:\n\n\\begin{equation}\\label{eq:cp04_epipolar_lines}\nl_{t - 1} \\sim H^{-T}l_t\\text{, or }l_t \\sim H^T l_{t - 1}\n\\end{equation}\n\nHere, $l'$ is the epipolar line at image at frame $t$, and $l$ the corresponding epipolar line at frame $t - 1$. $H$ is an homography for an arbitrary plane, which can be obtained from the fundamental matrix $F$ \\citep{luong1996fundamental}:\n\n\\begin{equation}\\label{eq:cp04_homography}\nH = [e_{t - 1}] \\times F + e_{t - 1}^T a\n\\end{equation}\n\n, where $a$ is a random vector for which $det(H) \\neq 0$, so that $H$ is invertible. $e$ is the epipole.\n\nThe first step in the polar rectification process consists on the definition of the common region between both images. To do that, we first need to compute the epipoles for both images and the homography $H$. So we need to know first the fundamental matrix $F$. The epipolar geometry is described by the following equation:\n\n\\begin{equation}\\label{eq:cp04_fundamental_matrix}\nm_{L,t - 1}^T \\cdot F \\cdot m_{L,t}= 0\n\\end{equation}\n\n, where $m_{L,t - 1}$ and $m_{L,t}$ are homogenous representations of corresponding image points in the left image of the frames $t$ and $t - 1$, respectively. So we need to compute these matches. To ensure that we just get correct matches, we compute the correspondences between image pairs in the following order: $I_{L, t} \\rightarrow I_{R, t} \\rightarrow I_{R, t - 1} \\rightarrow I_{L, t - 1} \\rightarrow I_{L, t}$, where $I_{\\{L,R\\},t}$ is the left ($L$) or right ($R$) image at frame $t$. From a initial set of features in $I_{L, t}$, we get the valid matches in $I_{R, t}$, and the cycle is completed until we reach $I_{L, t}$ again, keeping just the valid matches. A match is valid if satisfies the following rules:\n\\begin{itemize}\n \\item At the end of the cycle, points obtained should be the same as those from which we started the process. If not, a wrong match was found in the way.\n \\item Features in $I_{L, t}$ must be in the same row as $I_{R, t}$. As images are rectified, the vertical component should be the same. Same applies to $I_{L, t - 1}$ and $I_{R, t - 1}$.\n \\item The 2D distance between features from frame $t$ and $t - 1$ should not be too big, since the frame rate is high and images do not change too much between frames.\n\\end{itemize}\n\nThe result of this matching process is represented at figure \\ref{fig:cp04_polar_fund_matrix_computation}. There, each matching cycle is represented by the same random color.\n\n\\begin{figure*}[h!]\n\\centering\n\\includegraphics{fundamentalMatrixComputation}\n\\captionof{figure}{Looking for the common points in frames $t$ and $t - 1$.}\\label{fig:cp04_polar_fund_matrix_computation}\n\\end{figure*}\n\n\\begin{figure}[p]\n\\centering\n\\includegraphics[width=\\textwidth]{polar_common_region}\n\\captionof{figure}{Three possible cases depending on the position of the epipoles.}\\label{fig:cp04_polar_common_region}\n\\end{figure}\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{tabular}{ cc }\n      \\includegraphics[width=0.6\\textwidth]{polarRectification}\\label{fig:cp04_polarRectification} &\n      \\includegraphics[width=0.3\\textwidth]{polarDiff}\\label{fig:cp04_polarDiff}\n    \\end{tabular}\n  \\caption{Example of a rectified pair of frames. Red line shows that the alignment is correct. On the right, the absolute difference of both rectified images is shown.}\\label{fig:cp04_polarRectification_example}\n\\end{figure}\n\nOnce we get these matches, we solve the system described by equation \\ref{eq:cp04_fundamental_matrix}, obtaining $F$. From $F$, it is possible to get also the homography $H$ and the epipoles $e_t$ and $e_{t-1}$. So we can start looking for the common region between the images. This common region will be determined by the extremal epipolar lines, which will be those that touch the outer image corners. We must deal with three possible cases depending on\nwhether the epipoles are located inside or outside the image. These three cases are shown at figure \\ref{fig:cp04_polar_common_region}.\n\nThere, $I_i^j$ refer to the extremal lines for each image, where $i$ indicates if it is the current ($t$) or the previous ($t - 1$) image, and $j$ is the corner with which the line intersects (1 and 2 for the current image and 3 and 4 for the previous one), so $I_i^j = [e_i] \\times c_j$. If the epipole is located inside the image we need to decide which half-epipolar lines, pointing in oposite direction, is the correct one.\n\n\n% \\begin{figure}[h!]\n% \\centering\n% \\begin{tabular}{cc}\n% \\includegraphics[width=0.40\\textwidth]{epipolarExtremeLeft1}\\label{fig:cp04_epipolarExtremeLeft1} &\n% \\includegraphics[width=0.40\\textwidth]{epipolarExtremeRight1}\\label{fig:cp04_epipolarExtremeRight1} \\\\\n% \\includegraphics[width=0.40\\textwidth]{epipolarExtremeLeft2}\\label{fig:cp04_epipolarExtremeLeft2} &\n% \\includegraphics[width=0.40\\textwidth]{epipolarExtremeRight2}\\label{fig:cp04_epipolarExtremeRight2} \\\\\n% \\end{tabular}\n% \\captionof{figure}{Two examples of the external epipolar lines found for a case in which the epipole is inside the image for both images (top row); and out, also in both images (bottom row).}\\label{fig:cp04_epipolarExtreme}\n% \\end{figure}\n\n% In image \\ref{fig:cp04_epipolarExtreme}, two examples of the outer epipolar lines found are shown. \nFrom these, the common region is defined, which will be represented by the beginning and ending epipolar lines $I_i^B$ and $I_i^E$. If both epipoles are inside the image, an arbitrary epipolar line can be used. In that case, we can avoid boundary effects by adding a small overlap. That is, we will use a region a little bit bigger than $360\\textdegree$.\n\nThen, starting from $I_i^B$, we start constructing the rectified image, line by line, until we reach the epipolar line $I_i^E$. This process is repeated for $i=t$ and $i=t-1$ so, at the end of it, we will have both images rectified. In these images, each of the rows will have a correspondence with a certain epipolar line. The distance between two consecutive epipolar lines is determined independently for each of the lines so we avoid pixel compression. The benefits of doing such non-linear warping are that this allows getting the smallest image without information loss.\n\nUsing this method, we compute a transformation map that allows knowing the correspondences of the pixels of each image in euclidean and in polar coordinates easily and without a meaningful computational cost. With such a map, we compute a pair of images as those shown in the left side of figure \\ref{fig:cp04_polarRectification_example}. Red line demonstrates that the alignment obtained is correct. \n", "meta": {"hexsha": "ce471feffca56141a398798686d774d7b0c71391", "size": 8549, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "appendixPolarCalib.tex", "max_stars_repo_name": "nestormh/thesis", "max_stars_repo_head_hexsha": "7e1d9c79d6cb456d98bb156ff2750ed70b179db2", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-21T08:28:23.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-21T08:28:23.000Z", "max_issues_repo_path": "appendixPolarCalib.tex", "max_issues_repo_name": "nestormh/thesis", "max_issues_repo_head_hexsha": "7e1d9c79d6cb456d98bb156ff2750ed70b179db2", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "appendixPolarCalib.tex", "max_forks_repo_name": "nestormh/thesis", "max_forks_repo_head_hexsha": "7e1d9c79d6cb456d98bb156ff2750ed70b179db2", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.1477272727, "max_line_length": 1154, "alphanum_fraction": 0.7690958007, "num_tokens": 2303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.43910891283240555}}
{"text": "\n\\subsection{Choosing Ewald Sum Variables}\n\\label{ewaldoptim}\n\n\\subsubsection{Ewald sum and SPME}\n\nThis section outlines how to optimise the accuracy of the Ewald sum\nparameters for a given simulation. In what follows the directive {\\bf\nspme} may be used anywhere in place of the directive {\\bf ewald} if\nthe user wishes to use the Smoothed Particle Mesh Ewald\n\\index{Ewald!SPME} method.\n\nAs a guide\\index{Ewald!optimisation} to beginners \\D{} will calculate\nreasonable parameters if the {\\bf ewald precision} directive is used\nin the CONTROL file (see section \\ref{controlfile}). A relative error\n(see below) of 10$^{-6}$ is normally sufficient so the directive\n\n\\vskip 1em\n\\noindent\n{\\bf ewald precision 1d-6} \n\n\n\\vskip 1em\n\\noindent\nwill cause \\D{} to evaluate its best guess at the Ewald parameters \n$\\alpha$, {\\tt kmax1}, {\\tt kmax2} and {\\tt kmax3}. \n(The user should note that this represents an {\\em estimate}, and there\nare sometimes circumstances where the estimate can be improved\nupon. This is especially the case when the system contains a strong\ndirectional anisotropy, such as a surface.) These four parameters\nmay also be set explicitly by the {\\bf ewald sum } directive in the \nCONTROL file. For example the directive\n\n\\vskip 1em\n\\noindent\n{\\bf ewald sum 0.35 6 6 8}\n\n\\vskip 1em\n\\noindent\nwould set $\\alpha= 0.35$ \\AA$^{-1}$, {\\tt kmax1} = 6, {\\tt kmax2 = 6}\nand {\\tt kmax3 } = 8. The quickest check on the accuracy of the Ewald\nsum\\index{Ewald!summation} is to compare the Coulombic energy ($U$) and the coulombic virial\n($\\cal W$) in a short simulation.  Adherence to the relationship $U =\n-{\\cal W}$ shows the extent to which the Ewald sum\\index{Ewald!summation} is correctly\nconverged. These variables can be found under the columns headed {\\tt\neng\\_cou} and {\\tt vir\\_cou} in the OUTPUT file (see section\n\\ref{outputfile}). \n\nThe remainder of this section explains the meanings of these\nparameters and how they can be chosen.  The Ewald\nsum\\index{Ewald!summation} can only be used in a three dimensional\nperiodic system.  There are three variables that control the accuracy:\n$\\alpha$, the Ewald convergence parameter; $r_{\\rm cut}$ the real\nspace forces cutoff; and the {\\tt kmax1,2,3} integers \\footnote{{\\bf\nImportant note:} For the SPME method the values of {\\tt kmax1,2,3}\nshould be double those obtained in this prescription, since they\nspecify the sides of a cube, not a radius of convergence.}  that\neffectively define the range of the reciprocal space sum (one integer\nfor each of the three axis directions).  These variables are not\nindependent, and it is usual to regard one of them as pre-determined\nand adjust the other two accordingly. In this treatment we assume that\n$r_{\\rm cut}$ (defined by the {\\bf cutoff} directive in the CONTROL\nfile) is fixed for the given system.\n\nThe Ewald sum splits the (electrostatic) sum for the infinite,\nperiodic, system into a damped real space sum and a reciprocal space\nsum. The rate of convergence of both sums is governed by $\\alpha$.\nEvaluation of the real space sum is truncated at $r=r_{\\rm cut}$ so it\nis important that $\\alpha$ be chosen so that contributions to the real\nspace sum are negligible for terms with $r>r_{\\rm cut}$.  The relative\nerror ($\\epsilon$) in the real space sum truncated at $r_{\\rm cut}$ is\ngiven approximately by\\index{Ewald!optimisation}\n\\begin{equation}\n\\epsilon \\approx {\\rm erfc}(\\alpha r_{\\rm cut})/r_{\\rm cut} \n\\approx \\exp[-(\\alpha.r_{\\rm cut})^2]/r_{\\rm cut} \\label{relerr}\n\\end{equation}\n\nThe recommended value for $\\alpha$ is 3.2/$r_{\\rm cut}$ or greater\n(too large a value will make the reciprocal space sum very slowly\nconvergent). This gives a relative error in the energy of no greater\nthan $\\epsilon = 4\\times 10^{-5}$ in the real space sum. When using\nthe directive {\\bf ewald precision} \\D{} makes use of a more sophisticated\napproximation:\n\\begin{equation}\n{\\rm erfc}(x) \\approx 0.56 \\exp(-x^2)/x\n\\end{equation}\nto solve recursively for $\\alpha$, using equation \\ref{relerr} to give\nthe first guess.\n\nThe relative error in the reciprocal space term is approximately\n\\begin{equation}\n\\epsilon \\approx \\exp(- k_{max}^2/4\\alpha^2)/k_{max}^2\n\\end{equation}\nwhere\n\\begin{equation}\nk_{max} = \\frac{2\\pi}{L}~{\\tt kmax}\n\\end{equation}\nis the largest $k$-vector considered in reciprocal space, $L$ is the\nwidth of the cell in the specified direction and {\\tt kmax} is an integer. \n\nFor a relative error of $4\\times 10^{-5}$ this means using $k_{max}\n\\approx 6.2 \\alpha$.  {\\tt kmax} is then\n\\begin{equation}\n{\\tt kmax} > 3.2~L/r_{\\rm cut}\n\\end {equation}\n\nIn a cubic system, $r_{\\rm cut}~=~L/2$ implies ${\\tt kmax}~=~7$.  In\npractice the above equation slightly over estimates the value of {\\tt\nkmax} required, so optimal values need to be found experimentally.  In\nthe above example {\\tt kmax}~=~5 or 6 would be adequate.\n\nIf your simulation cell is a truncated octahedron or a rhombic\ndodecahedron then the estimates for the {\\tt kmax} need to be\nmultiplied by $2^{1/3}$. This arises because twice the normal number\nof $k$-vectors are required (half of which are redundant by symmetry)\nfor these boundary contributions \\cite{smith-93b}.\n\nIf you wish to set the Ewald parameters manually (via the {\\bf ewald\nsum} or {\\em spme sum} directives) the recommended approach is as follows\\index{Ewald!optimisation}. Preselect the\nvalue of $r_{\\rm cut}$, choose a working a value of $\\alpha$ of about\n$3.2/r_{\\rm cut}$ and a large value for the {\\tt kmax} (say 10 10 10\nor more).  Then do a series of ten or so {\\em single} step simulations\nwith your initial configuration and with $\\alpha$ ranging over the\nvalue you have chosen plus and minus 20\\%. Plot the Coulombic energy\n(and $-{\\cal W}$) versus $\\alpha$. If the Ewald sum\\index{Ewald!summation} is correctly\nconverged you will see a plateau in the plot.  Divergence from the\nplateau at small $\\alpha$ is due to non-convergence in the real space\nsum. Divergence from the plateau at large $\\alpha$ is due to\nnon-convergence of the reciprocal space sum.  Redo the series of\ncalculations using smaller {\\tt kmax} values. The optimum values for\n{\\tt kmax} are the smallest values that reproduce the correct\nCoulombic energy (the plateau value) and virial at the value of\n$\\alpha$ to be used in the simulation.\n\nNote that one needs to specify the three integers ({\\tt kmax1, kmax2,\nkmax3}) referring to the three spatial directions, to ensure the\nreciprocal space sum is equally accurate in all directions. The values\nof {\\tt kmax1}, {\\tt kmax2} and {\\tt kmax3} must be commensurate with\nthe cell geometry to ensure the same minimum wavelength is used in all\ndirections.  For a cubic cell set {\\tt kmax1} = {\\tt kmax2} = {\\tt\nkmax3}.  However, for example, in a cell with dimensions $2A = 2B = C$\n(ie. a tetragonal cell, longer in the c direction than the a and b\ndirections) use 2{\\tt kmax}1 = 2{\\tt kmax}2 = ({\\tt kmax}3).\n\nIf the values for the {\\tt kmax} used are too small, the Ewald sum\\index{Ewald!summation} will\nproduce spurious results. If values that are too large are used, the\nresults will be correct but the calculation will consume unnecessary\namounts of {\\em cpu} time. The amount of {\\em cpu} time increases with\n${\\tt kmax1}\\times{\\tt kmax2} \\times {\\tt kmax3}$.\n\n\\subsubsection{Hautman Klein Ewald Optimisation}\n\nSetting the HKE \\index{Ewald!Hautman Klein} parameters can also be\nachieved rather simply, by the use of a {\\bf hke precision}\ndirective in the CONTROL file e.g.\n\n\\vskip 1em\n\\noindent\n{\\bf hke precision 1d-6 1 1} \n\n\n\\vskip 1em\n\\noindent\nwhich specifies the required accuracy of the HKE convergence\nfunctions, plus two additional integers; the first specifying the\norder of the HKE expansion ({\\tt nhko}) and the second the maximum\nlattice parameter ({\\tt nlatt}). \\D{} will permit values of {\\tt nhko}\nfrom 1-3, meaning the HKE Taylor series expansion may range from\nzeroth to third order. Also {\\tt nlatt} may range from 1-2, meaning\nthat (1) the nearest neighbour, and (2) and next nearest neighbour,\ncells are explicitly treated in the real space part of the Ewald\nsum. Increasing either of these parameters will increase the accuracy,\nbut also substantially increase the cpu time of a simulation. The\nrecommended value for both these parameters is 1 and if {\\em both} these\nintegers are left out, the default values will be adopted.\n\nAs with the standard Ewald and SPME methods, the user may set alternative\ncontrol parameters with the CONTROL file {\\bf hke sum} directive e.g.\n\n\\vskip 1em\n\\noindent\n{\\bf hke sum 0.05 6 6 1 1} \n\n\n\\vskip 1em\n\\noindent\nwhich would set $\\alpha=0.05~$\\AA$^{-1}$, {\\tt kmax1 = 6}, {\\tt kmax2 =\n6}. Once again one may check the accuracy by comparing the Coulombic\nenergy with the virial, as described above. The last two integers\nspecify, once again, the values of {\\tt nhko} and {\\tt nlatt}\nrespectively. (Note it is possible to set either of these to zero in\nthis case.)\n \nEstimating the parameters required for a given simulation follows a\nsimilar procedure as for the standard Ewald method (above), but is\ncomplicated by the occurrence of higher orders of the convergence\nfunctions. Firstly a suitable value for $\\alpha$ may be obtained when\n{\\tt nlatt}=0 from the rule: $\\alpha=\\beta/r_{cut}$, where $r_{cut}$\nis the largest real space cutoff compatible with a single MD cell and\n$\\beta$=(3.46,4.37,5.01,5.55) when {\\tt nhko}=(0,1,2,3)\nrespectively. Thus in the usual case where {\\tt nhko}=1, $\\beta$=4.37.\nWhen {\\tt nlatt}$\\ne$0, this $\\beta$ value is multiplied by a factor\n$1/(2*nlatt+1)$.\n\nThe estimation of {\\tt kmax1,2} is the same as that for the standard\nEwald method above. Note that if any of these parameters prove to be\ninsufficiently accurate, \\D{} will issue an error in the OUTPUT file,\nand indicate whether it is the real or reciprocal space sums that is\nquestionable. \n", "meta": {"hexsha": "5da040506ae417eb27ba1e38429a3f6e595b3bb7", "size": 9811, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/ewald.tex", "max_stars_repo_name": "zzalscv2/DL_POLY_Classic", "max_stars_repo_head_hexsha": "f2712ca1cdddd154f621f9f5a3c2abac94e41e58", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manual/ewald.tex", "max_issues_repo_name": "zzalscv2/DL_POLY_Classic", "max_issues_repo_head_hexsha": "f2712ca1cdddd154f621f9f5a3c2abac94e41e58", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/ewald.tex", "max_forks_repo_name": "zzalscv2/DL_POLY_Classic", "max_forks_repo_head_hexsha": "f2712ca1cdddd154f621f9f5a3c2abac94e41e58", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.719047619, "max_line_length": 114, "alphanum_fraction": 0.7496687392, "num_tokens": 2796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.43910891013469955}}
{"text": "\\XtoCBlock{I}\r\n\\label{block:I}\r\n\\begin{figure}[H]\\includegraphics{I}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Control error input\\tabularnewline\r\n\\hline\r\nInit & Value which is loaded at initialization function call\\tabularnewline\r\n\\hline\r\nEnable & Enable == 0: Deactivation of block; Out set to 0\n\nEnable 0->1: Preload of integral part\n\nEnable == 1: Activation of block\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & Control value\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nKi & Integral Factor\\tabularnewline\r\n\\hline\r\nts\\_fact & Multiplication factor of base sampling time (in integer format)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nI controller:\n\n    G(s) = Ki/s = 1/(Ti*s)\r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/I_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!3200}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 3200 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & I\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & I\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nsfr & Shift factor for I coefficient b0\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value from previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     int8          *Init;\r\n     int8          *Enable;\r\n     int8          Out;\r\n     int8          b0;\r\n     int8          sfr;\r\n     int16         i_old;\r\n     int8          enable_old;\r\n} I_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_I_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!3201}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 3201 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & I\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & I\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nsfr & Shift factor for I coefficient b0\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value from previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     int16         *Init;\r\n     int8          *Enable;\r\n     int16         Out;\r\n     int16         b0;\r\n     int8          sfr;\r\n     int32         i_old;\r\n     int8          enable_old;\r\n} I_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_I_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!3202}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 3202 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & I\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & I\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\nsfr & Shift factor for I coefficient b0\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value from previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     int32         *Init;\r\n     int8          *Enable;\r\n     int32         Out;\r\n     int32         b0;\r\n     int8          sfr;\r\n     int64         i_old;\r\n     int8          enable_old;\r\n} I_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_I_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!3203}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 3203 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & I\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & I\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value from previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *In;\r\n     float32       *Init;\r\n     int8          *Enable;\r\n     float32       Out;\r\n     float32       b0;\r\n     float32       i_old;\r\n     int8          enable_old;\r\n} I_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_I_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!3204}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 3204 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & I\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & I\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Integral coefficient\\tabularnewline\r\n\\hline\r\ni\\_old & Integrator value from previous cycle\\tabularnewline\r\n\\hline\r\nenable\\_old & Enable value of previous cycle\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *In;\r\n     float64       *Init;\r\n     int8          *Enable;\r\n     float64       Out;\r\n     float64       b0;\r\n     float64       i_old;\r\n     int8          enable_old;\r\n} I_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_I_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "c57acb10bd4ec6fd2b89624b89960ba52c9065df", "size": 7184, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Control/Doc/I.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Control/Doc/I.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Control/Doc/I.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9063670412, "max_line_length": 90, "alphanum_fraction": 0.6943207127, "num_tokens": 2164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4391089047006233}}
{"text": "\\documentclass{article}\n\n\\usepackage{arxiv}\n\n\\usepackage[utf8]{inputenc} % allow utf-8 input\n\\usepackage[T1]{fontenc}    % use 8-bit T1 fonts\n\\usepackage{hyperref}       % hyperlinks\n\\usepackage{url}            % simple URL typesetting\n\\usepackage{booktabs}       % professional-quality tables\n\\usepackage{amsfonts}       % blackboard math symbols\n\\usepackage{nicefrac}       % compact symbols for 1/2, etc.\n\\usepackage{microtype}      % microtypography\n\\usepackage{lipsum}\t\t% Can be removed after putting your text content\n\\usepackage{amssymb,amsmath}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\\usepackage{subfig}\n\\usepackage{apacite}\n\n\\title{Finding the maximum a-posteriori orbit of an agent-based model\\\\\n*** UNFINISHED DRAFT ***}\n\n%\\date{September 9, 1985}\t% Here you can change the date presented in the paper title\n%\\date{} \t\t\t\t\t% Or removing it\n\n\\author{\n  Daniel Tang\\\\\n  Leeds Institute for Data Analytics\\\\\n  University of Leeds\\\\\n  Leeds, UK\\\\\n  \\texttt{D.Tang@leeds.ac.uk} \\\\\n  %% examples of more authors\n  %% \\AND\n  %% Coauthor \\\\\n  %% Affiliation \\\\\n  %% Address \\\\\n}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nWe describe an algorithm to find the orbit from time $t=0$ to $t=T$ of an agent based model that has the maximum posterior probability given partial observations of the state at time $t=T$.\n\nThis is an unfinished draft which may contain errors and is subject to change.\n\\end{abstract}\n\n% keywords can be removed\n\\keywords{Data assimilation, Agent based model, Quantum field theory, Probabilistic programming}\n\n\\section{Introduction}\n%##########################################\n\nIt has been shown\\cite{tang2019data} that a probability distribution over states of an agent based model can be described as an operator made up of creation and annihilation operators acting on an empty model-state, $\\emptyset$. For a certain class of agent-based models, the behaviour of the agents can be expressed as a Hamiltonian operator that transforms a probability distribution over model states into the rate-of-change of that distribution.\n\nGiven the Hamiltonian, $H$, the probability distribution over the agent-based model states at time $t$ is given by\n\\[\n\\psi_t = e^{Ht}\\psi_0\n\\]\nwhere $\\psi_0$ is the distribution at time $t=0$.\n\n\\section{Factorized integration}\n%################################\n\nSuppose we want to calculate\n\\[\ne^{Ht}S_0\\emptyset\n\\]\n\nFrom equation \\ref{Hcommutation} we have\n\\[\ne^{Ht}S_0\\emptyset = e^{[H,.]t}S_0\\emptyset\n\\]\n\nNow using equation \\ref{uniformisation} we have\n\\[\ne^{Ht}S_0\\emptyset = \\sum_{n=0}^\\infty  \\frac{(\\gamma t)^n e^{-\\gamma t}}{n!}\\left(I + \\frac{[H,.]}{\\gamma}\\right)^nS_0\\emptyset\n\\]\nBut if we set $\\gamma = \\sum_n \\rho_n$ we can split the term inside the brackets into separate acttions and interactions of the form\n\\[\nI + \\frac{[H,.]}{\\gamma} = \n\\sum_a \\frac{\\rho_a}{\\gamma}\\left(I + [(a^\\dag_{j_a}\\ldots - a^\\dag_{i_a})a_{i_a},.] \\right) + \n\\sum_b \\frac{\\rho_b}{\\gamma}\\left(I + [(a^\\dag_{k_b}\\dots a^\\dag_{l_b} - a^\\dag_{j_b}a^\\dag_{i_b})a_{j_b}a_{i_b},.] \\right)\n\\]\n\nSo, if we let\n\\[\n\\alpha = \\left\\{ \\frac{\\rho_a}{\\gamma}\\left(I + [(a^\\dag_{j_a}\\ldots - a^\\dag_{i_a})a_{i_a},.] \\right) \\right\\}\n\\]\nbe the set of commutated, uniformatized actions of $H$ and\n\\[\n\\beta = \\left\\{ \\frac{\\rho_b}{\\gamma}\\left(I + [(a^\\dag_{k_b}\\dots a^\\dag_{l_b} - a^\\dag_{j_b}a^\\dag_{i_b})a_{j_b}a_{i_b},.] \\right) \\right\\}\n\\]\nbe the set of commutated, uniformatized interactions of $H$, and let $\\chi = \\alpha \\cup \\beta$ we have\n\\[\ne^{Ht}S_0\\emptyset = \\sum_{n=0}^\\infty  \\frac{(\\gamma t)^n e^{-\\gamma t}}{n!}\\left(\\sum_{A\\in \\chi} A\\right)^nS_0\\emptyset\n\\]\nAs long as multiple agents do not occupy the same state, each term in the expansion of this sum (in terms of products of commutated, uniformatized actions and interactions) represents a possible orbit of the model from $S_0$ over time $t$.\n\n\\section{Finding the MAP over the orbits}\n%##########################################\n\nSuppose we have a posterior distribution\n\\[\n\\Omega e^{Ht}S_0\\emptyset = \\Omega \\sum_{n=0}^\\infty  \\frac{(\\gamma t)^n e^{-\\gamma t}}{n!}\\left(\\sum_{A\\in \\chi} A\\right)^nS_0\\emptyset\n\\]\nand we wish to find the term in the expansion of\n\\[\n\\left(\\sum_{A\\in \\chi} A\\right)^n\n\\]\nthat has maximum probability.\n\nSuppose we label the memebers of $\\chi$, $A_1...A_m$ and let $w_i = \\frac{\\rho_i}{\\gamma}$ be the weight of the $i^{th}$ act, $A_i$. Let $R_k$ be the number of annihilation operators of state $k$ in $\\Omega$, and let $S_k$ be the number of creation operators of state $k$ in $S_0$.\n\nLet an orbit consist of a list of integers $t_1...t_n$ where $1 \\le t_i \\le m$, corresponding to the acts $A_{t_1}\\dots A_{t_n}$.\n\nLet $r_{ik}$ be the number of annihilation operators of state $k$ in $A_i$, and let $c_{ik}$ be the number of creation operators of state $k$ in the term $A_i\\prod_j a^{\\dag r_{ij}}_j$.\n\nAn orbit is feasible iff\n\\[\n\\forall i,k: S_k- r_{t_ik} + \\sum_{j=i+1}^n c_{t_jk} -r_{t_jk}  \\ge 0\n\\]\nand for the observations\n\\[\n\\forall k: S_k + \\sum_{i=1}^n c_{t_ik} - r_{t_ik} \\ge R_k\n\\]\n\nThis can be expressed as a constrained optimisation problem in the following way. Let\n\\[\n0 \\le b_{ij} \\le 1\n\\]\nbe a set of integer indicator variables.\n\nFor each pair of acts $(A_p,A_q)$ that do not commute, add the constraint\n\\[\nb_{ip} + b_{iq} \\le 1\n\\]\nand we want $n$ terms in total, so\n\\[\n\\sum_i\\sum_j b_{ij} = n\n\\]\n\nThe feasibility constraints can be expressed as\n\\[\n\\forall i,k:    S_k - \\sum_j r_{jk}b_{ij} + \\sum_{l=i+1}^n\\sum_m \\left(c_{mk} - r_{mk}\\right)b_{lm}  \\ge 0\n\\]\nand\n\\[\n\\forall k: S_k + \\sum_{l=1}^n\\sum_j \\left(c_{jk} - r_{jk}\\right)b_{lj} -R_k \\ge 0\n\\]\n\nWithin these constraints, we wish to find the assignment to the $b_{ij}$ that maximises\n\\[\nW = \\sum_i\\sum_j b_{ij}\\log(w_j)\n\\]\n\nThis is an integer programming problem which can be solved by the branch-and-cut algorithm.\n\nOnce we have a solution, we can read off the $t_1...t_n$ by taking the set $\\left\\{(i,j): b_{ij}=1\\right\\}$ and ordering the members $(i_1,j_1) \\dots (i_n,j_n)$ such that $\\forall k: i_k \\le i_{k+1}$\\footnote{Since members with the same $i$ value correspond to acts that commute, it doesn't matter which order they are put in.}. The orbit is now given by $j_1\\dots j_n$ which corresponds to acts $A_{j_1}\\dots A_{j_n}$.\n\nBy solving for different values of $n$ and adding\n\\[\n\\log\\left(\\frac{(\\gamma t)^n e^{-\\gamma t}}{n!}\\right)\n\\]\nto each solution, we then simply choose the maximum to give the MAP orbit. As $n$ increases above $\\gamma t$ it becomes increasingly unlikely that we'll find a better orbit.\n\n\\section{Extension to any timestepping ABM}\n\nAlthough this algorithm was developed for use with models whose dynamics are described in terms of annihilation and creation operators, it would seem that the same approach could be used with a little modification to find the MAP orbit of any timestepping agent based model. In place of the observation operator we add the relevant constraints to the integer programming problem and in place of the commutated, uniformatised actions and interactions we put the timesteps of an agent along with its pre-requisites. As long as all these can be expressed as linear constraints, we can perform the same optimisation to find the MAP. Finally, rather than summing over all path lengths, we have a fixed number of timesteps.\n\nMore formally, suppose we have an ABM such that the probability that the model in state $S_t$ will transition into state $S_{t+1}$ in a timestep can be expressed in the form\n\\[\nP(S_{t+1},S_t) = \\sum_{S_{t+1} = \\cup_a C_a \\cup \\cup_{ab} C_{ab}} \\prod_a P(C_{a} | s_{a}) + \\prod_{a,b} P(C_{ab}|s_a, s_b)\n\\]\n\ni.e. each agent has a set of \"proprensities to act\", while pairs of agents have additional propensities to act as a group. In this case we can express the timestep on the model state as an operator that is the sum of commutated, uniformised acts.\n\nOr, even more generally, we have a single primary requirement (i.e. the agent itself) and a set of secondary requirements. A legel timestep then consists of a set of acts whose primary and secondary requirements are met, with the additional constraint that the set of primary requirements should exactly cover the set of agents (i.e. there is a matching between agents and primary requirements). This is equivalent, in the quantum version, to saying that an interaction must replace at least one agent back in its original state. So, in-fact it is less general than the operator that is a set of acts! (but the requirement allows us to activate multiple acts in one factor when performing branch-and-cut)\n\n\n%\\bibliographystyle{unsrtnat}\n%\\bibliographystyle{apalike} \n\\bibliographystyle{apacite}\n\\bibliography{references}\n\n\\newpage\n\\appendix\n\n\\section{Appendix: Proof that $e^{Ht}X\\emptyset = e^{[H,.]t}X\\emptyset$}\n% ####################################################\n\nBy definition\n\\begin{equation}\ne^{Ht}X\\emptyset = \\sum_{n=0}^\\infty \\frac{t^n}{n!} H^nX\\emptyset\n\\label{exponential}\n\\end{equation}\nbut\n\\[\nH^nX\\emptyset = H^{n-1}(XH + [H,X])\\emptyset\n\\]\nHowever, since all terms in $H$ have annihilation operators, $XH\\emptyset = 0$ for all $X$ so\n\\begin{equation}\nH^nX\\emptyset = H^{n-1}[H,X]\\emptyset\n\\label{recurrence}\n\\end{equation}\n\nLet $[H,.]$ be the ``commute H with'' operator, so that\n\\[\n[H,\\,.\\,](X) = [H,X]\n\\]\nand\n\\[\n[H,\\,.\\,]^n(X) = [H,\\dots [H,[H,X]]\\dots ]\n\\]\nis the $n$-fold application of the commutator to $X$. Note that $[H,.](X)Y \\ne [H,.](XY)$ so we use brackets where there is any ambiguity.\n\nFrom equation \\ref{recurrence}\n\\[\nH^nX\\emptyset = [H,.]^n(X)\\emptyset\n\\]\nSubstituting into equation \\ref{exponential}\n\\begin{equation}\ne^{Ht}X\\emptyset = \\sum_{n=0}^\\infty \\frac{t^n}{n!} [H,.]^n X\\emptyset = e^{[H,.]t}X\\emptyset\n\\label{Hcommutation}\n\\end{equation}\n\n\\section{Uniformisation of the Hamiltonian}\n% ####################################################\nThe numerical properties of the exponential of the Hamiltonian can be improved in a way analogous to that of a continuous time Markov chain \\cite{reibman1988numerical}. \n\nLet $I$ be the identity operator. By definition\n\\[\ne^{kI} = \\sum_{n=0}^\\infty \\frac{(kI)^n}{n!}\n\\]\nbut since $I^n=I$ for all $n$\n\\[\ne^{kI} = \\sum_{n=0}^\\infty \\frac{k^n}{n!}I = e^k\n\\]\nSo\n\n\\begin{equation*}\ne^{At} = e^{\\frac{A}{\\gamma}\\gamma t} = e^{\\left(I - I + \\frac{A}{\\gamma}\\right)\\gamma t} = e^{-\\gamma t}e^{\\left( I + \\frac{A}{\\gamma}\\right)\\gamma t}\n\\end{equation*}\n\n\\begin{equation}\ne^{At} = \\sum_{n=0}^\\infty  \\left(I + \\frac{A}{\\gamma}\\right) ^n\\frac{(\\gamma t)^n e^{-\\gamma t}}{n!}\n\\label{uniformisation}\n\\end{equation}\n\n\n\\end{document}\n", "meta": {"hexsha": "66afff7712c4241395bcd767555b72a848bffc89", "size": 10562, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/QuantumMAPOrbitDraft.tex", "max_stars_repo_name": "danftang/MaxAPosteriori", "max_stars_repo_head_hexsha": "af3dbd9bb397b337f838b248094544028002559a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/QuantumMAPOrbitDraft.tex", "max_issues_repo_name": "danftang/MaxAPosteriori", "max_issues_repo_head_hexsha": "af3dbd9bb397b337f838b248094544028002559a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/QuantumMAPOrbitDraft.tex", "max_forks_repo_name": "danftang/MaxAPosteriori", "max_forks_repo_head_hexsha": "af3dbd9bb397b337f838b248094544028002559a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-28T13:33:10.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-28T13:33:10.000Z", "avg_line_length": 41.9126984127, "max_line_length": 717, "alphanum_fraction": 0.6913463359, "num_tokens": 3356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.43910889656884067}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[margin=1in]{geometry} \n\\usepackage{amsmath,amsthm,amssymb,amsfonts}\n\\usepackage{listings}\n \n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n \n\\newenvironment{problem}[2][Problem]{\\begin{trivlist}\n\\item[\\hskip \\labelsep {\\bfseries #1}\\hskip \\labelsep {\\bfseries #2.}]}{\\end{trivlist}}\n%If you want to title your bold things something different just make another thing exactly like this but replace \"problem\" with the name of the thing you want, like theorem or lemma or whatever\n \n\\begin{document}\n \n%\\renewcommand{\\qedsymbol}{\\filledbox}\n%Good resources for looking up how to do stuff:\n%Binary operators: http://www.access2science.com/latex/Binary.html\n%General help: http://en.wikibooks.org/wiki/LaTeX/Mathematics\n%Or just google stuff\n \n\\title{Assignment 2\\\\ MEEN 357}\n\\author{Jacob Hartzer}\n\\maketitle\n \n\\section*{Task 4}\n\n\\begin{lstlisting}\n format long e;\n(0.6 + 0.6 + 0.6) - 1.8\n\nans = \n\n\t-2.220446049250313e-16\n\n\\end{lstlisting}\n\n\nThis is not the result that one would expect from the perspective of mathematics. From a math point of view, the answer is clearly exactly zero. However, these floating point numbers aren’t representable as a simple, finite string of binary code. Therefore, there is rounding during each of the above operations. The total rounding is summarized by the above non-zero answer.\n\n\\end{document}", "meta": {"hexsha": "f8a92cd4f12e7b4ff7ab0cc7e984daf321343188", "size": 1379, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "A2/a2task4.tex", "max_stars_repo_name": "JHartzer/MEEN_345", "max_stars_repo_head_hexsha": "794890ee37ada10d97280c794508e4c7a4d61337", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "A2/a2task4.tex", "max_issues_repo_name": "JHartzer/MEEN_345", "max_issues_repo_head_hexsha": "794890ee37ada10d97280c794508e4c7a4d61337", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "A2/a2task4.tex", "max_forks_repo_name": "JHartzer/MEEN_345", "max_forks_repo_head_hexsha": "794890ee37ada10d97280c794508e4c7a4d61337", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.475, "max_line_length": 375, "alphanum_fraction": 0.7585206672, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.4388344008828972}}
{"text": "% \\documentclass[11pt,a4paper,DIV=12]{scrartcl}\n% \\usepackage[utf8]{inputenc}\n% \\usepackage{fouriernc}\n% \\usepackage[T1]{fontenc}\n% \\usepackage[english]{babel}\n% \\usepackage[hidelinks]{hyperref}\n% \\usepackage{natbib}\n% \\usepackage{url}\n% \\usepackage{amsmath}\n% \\usepackage{amsfonts}\n% \\usepackage{amssymb}\n% \\usepackage{trfsigns}\n% \\usepackage{nicefrac}\n% \\usepackage{graphicx}\n% \\usepackage{caption}\n% \\usepackage{subcaption}\n% \\usepackage{xcolor}\n% \\usepackage{comment}\n% \\usepackage{mdframed}\n% \\usepackage{tikz}\n% \\usepackage{verbatim}\n% %\\usepackage{chngcntr}\n% %\\counterwithout{figure}{subsection}\n% %\\counterwithout{table}{subsection}\n\n% \\numberwithin{equation}{subsection}\n% \\numberwithin{figure}{subsection}\n\n\n% \\bibliographystyle{dinat}\n\n% \\newcommand\\fsd{\\mathrm{d}} %Ableitungsoperator\n% \\renewcommand{\\vec}[1]{\\mathbf{#1}} %Vektor\n% \\newcommand{\\eq}[1]{Eq. (\\ref{#1})}\n% \\newcommand{\\fig}[1]{Fig. \\ref{#1}} %Zitat Abbildung\n% \\newcommand{\\red}{\\textcolor{red}}\n% \\newcommand{\\fscom}[2][red]{\\textcolor{#1}{#2}}\n\n% \\usetikzlibrary{shapes.misc}\n% \\tikzset{cross/.style={cross out, draw,\n%          minimum size=2*(#1-\\pgflinewidth),\n%          inner sep=0pt, outer sep=0pt}}\n\n% \\definecolor{CalcColor}{rgb}{0.0,0.0,0.5}\n% \\newcommand{\\ExCalcCol}[2][CalcColor]{\\textcolor{#1}{#2}}\n% %\\excludecomment{calc}\n% \\includecomment{calc}\n\n% %##############################################################################\n% \\title{Signal- und Systemtheorie\\\\\n% Übung\\thanks{\n% This tutorial is provided as Open Educational Resource (OER), to be found at\n% \\url{https://github.com/spatialaudio/signals-and-systems-exercises}\n% accompanying the OER lecture\n% \\url{https://github.com/spatialaudio/signals-and-systems-lecture}.\n% %\n% Both are licensed under a) the Creative Commons Attribution 4.0 International\n% License for text and graphics and b) the MIT License for source code.\n% %\n% Please attribute material from the tutorial as \\textit{Frank Schultz,\n% Continuous- and Discrete-Time Signals and Systems - A Tutorial Featuring\n% Computational Examples, University of Rostock} with\n% \\texttt{main file, github URL, commit number and/or version tag, year}.\n% }\n% \\\\\n% \\small Universität Rostock Vst.-Nr. 24015}\n% %\n% \\author{Dr. Frank Schultz, Prof. Sascha Spors\\\\\n% \\small Institut für Nachrichtentechnik (INT)\\\\\n% \\small Fakultät für Informatik und Elektrotechnik (IEF)\\\\\n% \\small Universität Rostock\n% }\n% %\n% \\date{Sommersemester 2020, Version: \\today}\n\n% %##############################################################################\n% \\begin{document}\n% \\setcounter{section}{2}  % UE 3 in our current sequence\n% \\maketitle\n% \\tableofcontents\n\\clearpage\n\\section{UE 3: Solving 2nd Order, Linear, Ordinary Differential Equation with\nConstant Coefficients}\n\\subsection{Problem Statement}\n\\subsubsection{Electric RLC Circuit}\nFor a voltage source $u_0(t)=x(t)$---system input in Volt---connected to a\nseries circuit consisting of\na resistor with resistance $R$,\nan inductor with inductance $L$ and\na capacitor with capacitance $C$,\nKirchhoff's voltage law yields\n\\begin{align}\n\\label{eq:KirchhoffLaw}\nu_0(t) = u_R(t) + u_L(t) + u_C(t),\n\\end{align}\nfor the system output $y(t) = u_C(t)$ in Volt according to Fig. \\ref{fig:lowpass}.\nIf assuming ideal elements, the circuit constitutes a linear and time-invariant\n(LTI) system describable by impulse response $h(t)$ and step response\n$h_\\epsilon(t)$.\n%\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.5\\textwidth]{../laplace_transform/lowpass.png}\n\\caption{Electric RLC circuit with current $i(t)$, input voltage $x(t)$\nand output voltage $y(t)$.}\n\\label{fig:lowpass}\n\\end{figure}\n\n\n\n%##############################################################################\n\\subsubsection{Ordinary Differential Equation (ODE)}\nThere is one current $i(t)$ flowing in the RLC circuit under discussion.\nThe corresponding current-voltage laws for the components are\n$u_R(t) = R\\,i(t)$,\n$u_L = L\\,\\frac{\\mathrm{d}i(t)}{\\mathrm{d} t}$ and\n$u_C(t) = \\frac{1}{C} \\, \\int i(t) \\mathrm{d}t$.\\\\\nWith the fundamental theorem of calculus we can find the differential representation\n\\begin{align}\n\\label{eq:u_c}\nu_C(t) &= \\frac{1}{C}\\int\\limits_{t_0}^{t} i(t) \\fsd t+u_C(t_0) \\bigg | \\cdot C\\frac{\\fsd}{\\fsd t} \\nonumber \\\\\nC\\dot u_C(t) &= i(t) \\nonumber\n\\end{align}\nbetween voltage and current of the capacitor.\n%\nWe can insert this into \\eq{eq:KirchhoffLaw}\n%\n\\begin{align}\nRC \\dot u_C(t)+LC\\frac{\\mathrm{d}\\dot u_C(t)}{\\mathrm{d}t}+u_C(t)=L C \\cdot \\ddot{u}_C(t) + R C \\cdot \\dot{u}_C(t) + u_C(t) = u_0(t)\n\\end{align}\nusing\n$\\ddot{u}_C(t) = \\frac{\\mathrm{d}^2 u_C(t)}{\\mathrm{d}t^2}$ and\n$\\dot{u}_C(t) = \\frac{\\mathrm{d} u_C(t)}{\\mathrm{d}t}$\nas temporal derivative notations.\n%\nWith\nthe system input $x(t)$ and\nthe system output $y(t)$ this 2nd order, linear ODE with\nconstant coefficients is rewritten\n\\begin{align}\n\\label{eq:ODE_RLC}\nL C \\cdot \\ddot{y}(t) + R C \\cdot \\dot{y}(t) + y(t) = x(t).\n\\end{align}\n\n\n\n%##############################################################################\n\\subsubsection{Tasks}\nThe ODE in \\eq{eq:ODE_RLC} with\n$R = 3\\,\\nicefrac{\\text{V}}{\\text{A}}$,\n$L=2\\,\\nicefrac{\\text{V s}}{\\text{A}}$,\n$C=\\frac{8}{25}\\,\\nicefrac{\\text{A s}}{\\text{V}}$\nis to be solved for $t\\geq 0$ and the cases\n\\begin{itemize}\n\\item[a)] $y_\\text{particular}(t)$ when $x(t)=\\delta(t)$\n\\item[b)] $y(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t)$ when\n$x(t)=1$ and initial conditions $\\dot{y}(0) = 0$, $y(0)=0$\n\\item[c)] $y(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t)$ when $x(t)=0$\nand initial conditions $\\dot{y}(0) = 2$, $y(0)=1$\n\\item[d)] $y(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t)$ when $x(t)=1$\nand initial conditions $\\dot{y}(0) = 2$, $y(0)=1$\n\\item[e)] $y(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t)$ when $x(t)=\\sin(t)$\nand initial conditions $\\dot{y}(0) = 0$, $y(0)=0$\n\\end{itemize}\ndenoting the Dirac-Delta impulse $\\delta(t)$.\n%and Heaviside step function\n%$\\epsilon(t)= \\{0\\,\\,\\text{for}\\,\\,t < 0;\\,\\,\\, 1\\,\\,\\text{for}\\,\\,t \\geq 0\\}$.\n%\n\nFor Dirac impulse initial conditions refer to $t=0-0$ (left limit) since excitation is at $t=0$.\nFor other signals, initial conditions refer to the exact time instance $t=0$,\nexcitation signals start at right limit $t=0+0$ (right limit).\n%\n\nThe calculations shall be performed with help of the\n\\begin{itemize}\n\\item \\textbf{fundamental system of solutions}\n\\item \\textbf{Laplace transform with tabulated correspondence}\n\\item \\textbf{Laplace transform with residue theorem}\n\\item \\textbf{convolution integral}, i.e. particular solution for tasks b and e.\n\\end{itemize}\n\n\n%##############################################################################\n%##############################################################################\n\\newpage\n\\subsection{Preliminaries for Fundamental System of Solutions}\n\n\n\n%##############################################################################\n\\subsubsection{Helping Variables}\nBefore solving any of the requested tasks, it is good scientific and engineering\npractice to adapt the ODE for convenient handling and result's interpretation.\nThus (by some experience dealing with such problems and reading text books, cf.\n\\cite{LangeSigSys1}, \\cite{Goeldner1987},  \\cite{Oppenheim1997}, \\cite{Strang2014}),\nwe introduce\n\\begin{equation}\n\\omega_0^2 = \\frac{1}{L C} \\rightarrow \\omega_0 = \\frac{1}{\\sqrt{L C}}\n\\end{equation}\n(this is the \\textbf{resonance frequency} of the system when no damping would occur)\nand\n\\begin{equation}\n\\sigma_0 = \\frac{1}{2}\\frac{R}{L},\n\\qquad\nD = \\frac{\\sigma_0}{\\omega_0}.\n\\end{equation}\n(these are related to the \\textbf{damping quality} of the system).\n%\nFurthermore,\n\\begin{equation}\n\\omega_D^2 = \\omega_0^2 (1-D^2) \\qquad \\rightarrow \\qquad \\omega_D = \\omega_0\n\\sqrt{1-D^2}\n\\end{equation}\nbecomes convenient for the case $\\sigma_0^2 - \\omega_0^2 < 0$.\nWe will later experience the usefulness of these helping variables.\nFor now, it is worth to note that $\\omega_0$ and $\\sigma_0$ intentionally share\n\\textbf{similarities} with the variable $s=\\sigma + \\im \\omega$ used for the\n\\textbf{Laplace transform}.\n\nBy introducing the variables into \\eq{eq:ODE_RLC}, we have nice formatted\n\\begin{align}\n\\label{eq:ODE_sigma0}\n\\boxed{\n\\frac{\\ddot{y}}{\\omega_0^2} + \\frac{2 \\sigma_0}{\\omega_0^2} \\dot{y} + y = x\n}\\,,\n\\end{align}\nand\n\\begin{align}\n\\label{eq:ODE_D}\n\\boxed{\n\\frac{\\ddot{y}}{\\omega_0^2} + \\frac{2 D}{\\omega_0} \\dot{y} + y = x}\\,,\n\\end{align}\nwhen omitting the temporal dependence $t$ in $y$ and $x$ for brevity.\n%\nThis generalisation allows for discussion of the ODE's characteristics detached\nfrom the underlying physical representation and helps for communication between\nscientists and engineers with different job specialisation.\n\n\n\n%##############################################################################\n\\subsubsection{Specific Parameters}\nWith the given values for the electric elements\n$R = 3\\,\\nicefrac{\\text{V}}{\\text{A}}$,\n$L=2\\,\\nicefrac{\\text{V s}}{\\text{A}}$,\n$C=\\frac{8}{25}\\,\\nicefrac{\\text{A s}}{\\text{V}}$\nwe can rewrite \\eq{eq:ODE_RLC}\n\\begin{align}\n\\boxed{\n(\\frac{16}{25} \\cdot \\text{s}^2) \\, \\ddot{y} + (\\frac{24}{25} \\cdot \\text{s})\n\\, \\dot{y} + y = x.\n}\n\\end{align}\nNote that the straight letter s here represents the unit seconds, \\textbf{not the Laplace\nvariable}, which is typeset as italic $s$.\n%\nThe above variables have the quantities\n\\begin{equation}\n\\omega_0^2 = \\frac{25}{16} \\cdot \\frac{\\text{rad}^2}{\\text{s}^2}\n\\rightarrow \\omega_0 = \\frac{5}{4} \\cdot \\frac{\\text{rad}}{\\text{s}}\n\\end{equation}\nand\n\\begin{equation}\n\\sigma_0 = \\frac{3}{4}\\cdot \\frac{\\text{1}}{\\text{s}}\n\\qquad D = \\frac{3}{5}\n\\end{equation}\nand since $\\sigma_0^2 - \\omega_0^2 = -1 \\cdot \\frac{1}{\\text{s}^2}< 0\\cdot \\frac{1}{\\text{s}^2}$\n\\begin{equation}\n\\omega_D = 1 \\cdot \\frac{\\text{rad}}{\\text{s}}.\n\\end{equation}\n%\nThe chosen values for $R$, $L$, $C$ lead to convenient quantities, which is on\npurpose for the upcoming manual calculus. For practical problems we should not\nexpect such nice numbers.\n%\nIn the remainder we omit the physical units in the calculus, but it is always\nuseful to check if units are still meaningful after calculus.\n\n\n\n%##############################################################################\n\\subsubsection{Homogeneous Solution}\n\\label{Sec:FundamentalSet}\nThe present 2nd order ODE can be solved by means of the\nfundamental set of solutions\nconsidering the eigenfunctions\n\\begin{align}\ny = \\mathrm{e}^{\\lambda t}, \\quad \\lambda\\in\\mathbb{C}\n\\end{align}\nof the system. Note the (intentional) similarity to $\\mathrm{e}^{s t}$,\nwhich is the integral kernel of the Laplace transform.\n%\nDerivatives with respect to time $t$ become (this is the nice part, why this\nworks at all)\n\\begin{align}\ny = \\mathrm{e}^{\\lambda t},\\quad\n\\dot{y} = \\lambda \\cdot \\mathrm{e}^{\\lambda t},\\quad\n\\ddot{y} = \\lambda^2 \\cdot \\mathrm{e}^{\\lambda t}.\n\\end{align}\n%\nWe insert these in \\eq{eq:ODE_sigma0} with $x=0$, to obtain the\nso called \\textbf{homogeneous solution} $y_\\text{homogeneous}$, also denoted as\n$y_h$.\nThus,\n\\begin{align}\n\\frac{1}{\\omega_0^2} (\\lambda^2 \\cdot \\mathrm{e}^{\\lambda t}) +\n\\frac{2 \\sigma_0}{\\omega_0^2} (\\lambda \\cdot \\mathrm{e}^{\\lambda t}) +\n\\mathrm{e}^{\\lambda t} = 0,\\nonumber\\\\\n\\label{eq:CharEq}\n\\left(\\underbrace{\\frac{\\lambda^2}{\\omega_0^2} +\n\\frac{2 \\sigma_0 \\lambda}{\\omega_0^2} + 1}_\\text{characteristic equation}\\right)\n\\cdot \\mathrm{e}^{\\lambda t} = 0.\n\\end{align}\n%\nWe are not able to force the left side of this equation to zero with the $\\mathrm{e}^{\\lambda t}$\nfunction.\nThus, we calculate the zeros of the term within brackets, which is well known as\n\\textbf{characteristic equation}.\n%\nThe zeros of this 2nd order polynomial are\n\\begin{align}\n\\label{eq:lambda12}\n\\lambda_{1,2} = -\\sigma_0 \\pm \\sqrt{\\sigma_0^2 - \\omega_0^2}.\n\\end{align}\n%\nThe homogeneous solution $y_h$ depends on the characteristics\nof the term $\\sigma_0^2 - \\omega_0^2$.\nThree cases need to be considered.\n\n\\paragraph{Case I for Homogeneous Solution (Kriechfall, starke Dämpfung if $\\sigma_0<0$)}\nFor\n\\begin{align}\n\\sigma_0^2 - \\omega_0^2 > 0\n\\end{align}\nthe Ansatz reads\n\\begin{align}\ny_h=\nA \\mathrm{e}^{\\lambda_1 t} + B \\mathrm{e}^{\\lambda_2 t}\n=\n\\mathrm{e}^{-\\sigma_0 t} [A \\mathrm{e}^{+t\\,\\sqrt{\\sigma_0^2 - \\omega_0^2}}\n+ B \\mathrm{e}^{-t\\,\\sqrt{\\sigma_0^2 - \\omega_0^2}}]\n\\end{align}\nwith the two constants $A$ and $B$ to be defined by the initial conditions\n$\\dot{y}(t)$ and $y(t)$ for a given $t$ (very often $t=0$)\nof the the complete solution\n$y(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t)$.\n\n\\paragraph{Case II for Homogeneous Solution (Aperiodischer Grenzfall)}\nFor\n\\begin{align}\n\\sigma_0^2 - \\omega_0^2 = 0\n\\end{align}\na double zero\n\\begin{align}\n\\lambda_{1} = \\lambda_{2} = -\\sigma_0\n\\end{align}\nresults for \\eq{eq:lambda12}.\nThen the Ansatz reads\n\\begin{align}\ny_h = \\mathrm{e}^{-\\sigma_0 t} [A t + B].\n\\end{align}\n\n\\paragraph{Case III for Homogeneous Solution (Schwingungsfall,\nschwache Dämpfung if $\\sigma_0<0$)}\n\\label{pg:caseIII}\nFor\n\\begin{align}\n\\sigma_0^2 - \\omega_0^2 < 0,\n\\end{align}\nthe already introduced helping variable\n\\begin{align}\n\\omega_D^2 = \\omega_0^2 - \\sigma_0^2 > 0\n\\end{align}\nrearranges \\eq{eq:lambda12} to\n\\begin{align}\n\\label{eq:lmb12_caseIII}\n\\lambda_{1,2} = -\\sigma_0 \\pm \\sqrt{-\\omega_D^2}\n= -\\sigma_0 \\pm \\mathrm{j}\\,\\omega_D,\n\\end{align}\nyielding a complex conjugate zero pair.\nThen the Ansatz reads (cf. case I)\n\\begin{align}\n\\label{eq:Ansatz_caseIIIkomplex}\n\\boxed{\ny_h = A \\mathrm{e}^{\\lambda_1 t} + B \\mathrm{e}^{\\lambda_2 t}.\n}\n\\end{align}\nor (by using other coefficients $A$, $B$!)\n\\begin{align}\n\\label{eq:Ansatz_caseIIIsincos}\ny_h = \\mathrm{e}^{-\\sigma_0 t}\n\\left[ A \\sin(\\omega_D t) + B \\cos(\\omega_D t)\\right].\n\\end{align}\nWhile \\eq{eq:Ansatz_caseIIIkomplex} is more elegant to perform calculus,\n\\eq{eq:Ansatz_caseIIIsincos} directly reveals the \\textbf{damped}\n(parameter $\\sigma_0$) sine and cosine \\textbf{oscillations}\n(with angular frequency $\\omega_D$).\n%\nCase III covers the characteristics of the majority of practical systems\nfor signal processing.\n\n\n\n%##############################################################################\n\\subsubsection{Inhomogeneous Solution}\nNow, let the ODE be of form\n\\begin{align}\na \\, \\ddot{y} + b \\, \\dot{y} + c \\, y = x.\n\\end{align}\nwith constant coefficients $a, b, c\\in \\mathbb{R}$.\n%\nThere are different suitable approaches for solving such an ODE for\ndifferent inhomogeneities $x$.\nWe restrict our discussion to the most often asked cases.\nWe should check our math lecture notes for e.g. the method\n\\textit{variation of parameters / Variation der Konstanten} for a general\nsolution concept, cf. \\cite{Burg2013}.\n\n\\paragraph{Polynomial Function}\nThe particular solution $y_p$ for the inhomogeneous ODE with\npolynomial $x = P_n(t)$ of degree $n$\n(for example $x = p_n t^n + p_{n-1} t^{n-1} + ... +p_0$)\nrequires the Ansatz\n\\begin{align}\ny_p =\n\\begin{cases}\nQ_n(t)&\\quad a\\neq 0, c\\neq 0 \\rightarrow \\lambda_{1,2} \\neq 0\\\\\nt Q_n(t)&\\quad a\\neq 0, b\\neq 0, c=0 \\rightarrow \\lambda_1=0,\\lambda_2 = -\\frac{b}{a}\\\\\nt^2 Q_n(t)&\\quad a\\neq 0, b=0, c=0  \\rightarrow \\lambda_{1,2} = 0\n\\end{cases}\n\\end{align}\nand solving for the coefficients $q_n, q_{n-1},...,q_0$ by comparing\ncoefficients in\n\\begin{align}\na \\, \\ddot{y}_p + b \\, \\dot{y}_p + c \\, y_p = x.\n\\end{align}\n\n\\paragraph{Exponential Function (i.e. Eigenfunctions of the ODE)}\nThe particular solution $y_p$ for the inhomogeneous ODE with\n$x = \\e^{s_x t}$\nrequires the Ansatz\n\\begin{align}\ny_p =\n\\begin{cases}\nA \\cdot \\e^{s_x t}&\\quad \\text{if} \\quad  s_x \\notin \\lambda_{1,2}\\\\\nA t \\cdot \\e^{s_x t}&\\quad \\text{if} \\quad s_x \\in \\lambda_{1 \\text{ or } 2}\\\\\nA t^2 \\cdot \\e^{s_x t}&\\quad \\text{if} \\quad s_x \\in \\lambda_{1 \\text{ and } 2}\n\\end{cases}\n\\end{align}\nand solving for the coefficient $A$ by comparing coefficients.\n\n\\paragraph{Cosine / Sine Functions (i.e. Special Case of ODE's Eigenfunctions)}\n\\label{Sec:CosSineAnsatzInhomo}\nThe particular solution $y_p$ for the inhomogeneous ODE with\n$x=\\sin(\\omega_x t)$ or $x=\\cos(\\omega_x t)$\nrequires the Ansatz\n\\begin{align}\ny_p =\n\\begin{cases}\nA \\cdot \\cos(\\omega_x t) + B \\cdot \\sin(\\omega_x t)&\\quad \\text{if}\n\\quad \\im \\omega_x \\notin \\lambda_{1,2}\\\\\nA t \\cdot \\cos(\\omega_x t) + B t \\cdot \\sin(\\omega_x t)&\\quad \\text{if}\n\\quad \\im \\omega_x \\in \\lambda_{1,2}\n\\end{cases}\n\\end{align}\nand solving for the coefficients $A, B$ by comparing coefficients.\n\n\n\n%##############################################################################\n\\subsubsection{Full ODE Solution}\nThe full solution of an ODE is the superposition of the homogeneous solution\nand inhomogeneous (particular) solution\n\\begin{align}\ny(t) = y_\\text{homogeneous}(t)+y_\\text{particular}(t) \\qquad \\rightarrow \\qquad\ny = y_h + y_p\n\\end{align}\nand then resolving for the initial conditions $\\dot{y}(t)$ and $y(t)$ for a\ngiven $t$ (very often $t=0$) to obtain the specific solution $y$.\n\n\n\n%##############################################################################\n%##############################################################################\n\\newpage\n\\subsection{Solutions Using Fundamental System}\n\\label{sec:SolutionsUsingFundameltalSystem}\n\n\n%##############################################################################\n\\subsubsection{Task a) with Fundamental System / Impulse Response}\nWe shall solve\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = \\delta(t)\n\\end{align}\nfor the particular solution $y_p$ in the time domain.\n\n%\nA brilliant didactical approach tailored for engineers to solve this task is\nfound in \\cite{Strang2014}.\n%\nIn short, the \\textbf{particular solution} $y_p(t)$ of this equation\nwith \\textbf{Dirac impulse excitation} is named the \\textbf{Green's function} $g(t)$.\n%\nWhen the homogeneous solutions of the ODE are known, the Green's function can be found\nby variation of parameters.\nMaking use of the important sifting property\n$\\int\\limits_{-\\infty}^{+\\infty} \\delta(t-t_0) \\cdot f(t) \\, \\mathrm{d} t \\stackrel{\\mathrm{def}}= f(t_0)$\nbecomes a vital part when doing this.\n%\nHowever, we will not go into detail here, cf. \\cite[p.133]{Strang2014} instead.\n%\n\\label{pg:sig_sys_ex_03AddOn:convolution}\nThe important part of the story is:\nOnce $g(t)$ is known,\nthe \\textbf{particular solution} $y_p$ \\textbf{for any other inhomogeneity}\n$x(t)$ can be derived with the \\textbf{convolution} operation\n$y_p(t) = x(t) * g(t)$.\n%\nThis constitutes a fundamental (if not the most important) theorem for ODEs.\n%\nFor our discussed ODEs in signal and\nsystem theory (where we only handle time dependence), we call the Green's\nfunction $g(t)$ typically the \\textbf{impulse response} $h(t)$ of the\n\\textbf{LTI system} and use the convolution $y_p(t) = x(t) * h(t)$.\n\n\\textbf{Important detail}: Actually the problem\n$\\frac{16}{25} \\ddot{h}(t) + \\frac{24}{25} \\dot{h}(t) + h(t) = \\delta(t),\\,\\,\\,\n\\dot{h}(0-0)=0,\\,\\,\\,h(0-0)=0$\nsolves for the impulse response, where we need the \\textbf{left sided}\nlimit $t=0-0$, since the Dirac impulse excites at $t=0$.\n%\nThis proof is a little bit off-topic due to lack of time.\n%\nInstead, we can use the particular solution only by keeping in\nmind that the system was in rest before excitation.\n\nSaid that, we can make our life even more convenient, since according to\n\\cite[p.97]{Strang2014},\nthe \\textbf{Green's function is also found by the homogeneous solution}\n(instead of Dirac excitation)\n\\textbf{and new specific initial conditions}.\nIn general for a 2nd order ODE this means\n%\\begin{align}\n$a \\, \\ddot{y} + b \\, \\dot{y} + c \\, y = 0,\n\\quad y(0)=0,\n\\quad \\dot{y}(0)=\\frac{1}{a}$,\n%\\end{align}\nand thus for our specified example\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = 0,\n\\quad y(0)=0,\n\\quad \\dot{y}(0)=\\frac{25}{16}\n\\end{align}\nfor $t\\geq 0$.\n%\nFeel free to explore the solution by usage of \\url{https://www.wolframalpha.com}\nwith the input \\verb|16/25*y’’(t)+24/25*y’(t)+y(t)=0, y(0)=0, y'(0)=25/16|\nor with other tools that can handle symbolic math on a computer.\n%\nWe are going to calculate this manually in the following.\n%\n\n\n\\paragraph{Homogeneous Solution}\n\\label{Sec:TaskaHomo}\nFirst, we need the homogeneous solution of the ODE for this subtask.\n%\nWe will also need this in general, so it is anyway a good idea to calculate\nthis first.\n%\nAccording to Sec. \\ref{Sec:FundamentalSet} the characteristic equation for the\nODE is \\eq{eq:lambda12}\n\\begin{align}\n\\lambda_{1,2} = -\\sigma_0 \\pm \\sqrt{\\sigma_0^2 - \\omega_0^2}.\n\\end{align}\nand with the chosen quantities, we get\n\\begin{align}\n\\lambda_{1,2} = -\\frac{3}{4} \\pm \\im,\n\\end{align}\ni.e. a complex conjugate zero pair with intentionally very simple numbers.\nThus, we deal with \\textbf{case III} (page \\pageref{pg:caseIII})\nfor the homogeneous solution, this is the case of \\textbf{damped oscillation}.\nThe corresponding zero pair is depicted in Fig.~\\ref{fig:sketch_lambda_plane},\nleft.\n%\nRepeating \\eq{eq:lmb12_caseIII}\n$\\lambda_{1,2} = -\\sigma_0 \\pm \\mathrm{j}\\omega_D$,\nwe identify $\\sigma_0 = \\frac{3}{4}$ and $\\omega_D = 1$.\nRepeating \\eq{eq:Ansatz_caseIIIkomplex}\n$y_h = A \\mathrm{e}^{\\lambda_1 t} + B \\mathrm{e}^{\\lambda_2 t}$,\nwe therefore have to deal with\n\\begin{align}\ny_h = A \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t} + B \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t},\n\\end{align}\nand since $y_p=0$\n\\begin{align}\ny = y_h + y_p = A \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t} + B \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t}.\n\\end{align}\n\n\\paragraph{Initial Conditions}\n\\label{Sec:TaskaInitCond}\nThe initial conditions $y(0)=0$ and $\\dot{y}(0)=\\nicefrac{25}{16}$ require to find\nthe derivative\n\\begin{align}\n\\dot{y} =\n(-\\frac{3}{4}+\\im) A \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t} +\n(-\\frac{3}{4}-\\im) B \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t}.\n\\end{align}\n%\nThe ease of performing this derivation makes the Ansatz \\eq{eq:Ansatz_caseIIIkomplex}\nmore elegant than \\eq{eq:Ansatz_caseIIIsincos}.\n%\nHowever, we now have slightly more effort to find the coefficients $A$ and $B$,\nbut it is actually more enlightening, how our final result evolves.\n%\nApplying the initial conditions yields\n%\n\\begin{align}\ny(0) = 0 = A + B\n\\qquad\n\\dot{y}(0) = \\nicefrac{25}{16} =\n(-\\frac{3}{4}+\\im) \\, A + (-\\frac{3}{4}-\\im) \\, B\n\\end{align}\nor in matrix notation\n\\begin{align}\n\t\\begin{pmatrix}\n\t\t1 & 1 \\\\\n\t\t-\\frac{3}{4}+\\im & -\\frac{3}{4}-\\im\n\t\\end{pmatrix}\n\t\\cdot\n\t\\begin{pmatrix}\n\t\tA \\\\\n\t\tB\n\t\\end{pmatrix}\n\t=\n\t\\begin{pmatrix}\n\t\t0 \\\\\n\t\t\\frac{25}{16}\n\t\\end{pmatrix}. \\nonumber\n\\end{align}\nThus, comparing coefficients and using one Euler identity\n$\\sin(x) = \\frac{\\e^{\\im x}-\\e^{-\\im x}}{2\\im}$\n\\begin{align}\nA = \\frac{\\nicefrac{25}{16}}{2\\im}\\qquad B = -\\frac{\\nicefrac{25}{16}}{2\\im}\n\\quad\\rightarrow\\quad\ny = y_h + y_p =\n \\frac{\\nicefrac{25}{16}}{2\\im} \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t}\n-\\frac{\\nicefrac{25}{16}}{2\\im} \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t},\n\\end{align}\nyields the \\textbf{impulse response} of the 2nd order system / ODE under discussion\n\\begin{align}\n\\boxed{\nh = y_\\text{Task a} = \\nicefrac{25}{16} \\cdot \\mathrm{e}^{-\\frac{3}{4} t} \\sin(t) \\qquad t\\geq0\n}\\,.\n\\end{align}\n\n\n\n%##############################################################################\n\\subsubsection{Task b) with Fundamental System / Step Response}\nWe shall solve\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = 1, \\quad\n\\dot{y}(0) = 0,\\quad y(0)=0\n\\end{align}\nfor $y$ with the Ansatz of fundamental set of solutions.\n\n\\paragraph{Inhomogeneous Solution}\nThe source term $x(t\\geq 0+0)=1$ exhibits unit\namplitude over time. This can be stated as the most simple polynomial $p_0=1$.\nThus, the polynomial Ansatz $y_p = q_0$ leads to\n\\begin{align}\n\\frac{16}{25} \\ddot{y}_p + \\frac{24}{25} \\dot{y}_p + y_p = 1\n\\rightarrow q_0 = 1 \\rightarrow  y_p = 1.\n\\end{align}\n\n\\paragraph{Specific Solution with Initial Conditions}\nThe superposition of the homogeneous (this time we use the sin/cos-Ansatz\n\\eq{eq:Ansatz_caseIIIsincos} for demonstration purpose) and the inhomogeneous\nsolution is\n\\begin{align}\n\\label{eq:SpecificyTaskb}\ny = y_h + y_p = \\underbrace{\n\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left[ A \\sin(t) + B  \\cos(t)\\right]}_{y_h} +\\underbrace{1}_{y_p}.\n\\end{align}\nThe initial condition $\\dot{y}(0) = 0$ again requires to find the derivative\n\\begin{align}\n\\dot{y}\n=\n-\\frac{3}{4}\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left[ A \\sin(t) + B \\cos(t)\\right]\n+\n\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left[ A \\cos(t)  - B \\sin(t)\\right].\n\\end{align}\nThe initial condition $\\dot{y}(0) = 0$ yields\n\\begin{align}\n0 = -\\frac{3}{4}\\cdot B + A \\rightarrow A = \\frac{3}{4}\\cdot B.\n\\end{align}\nThe initial condition ${y}(0) = 0$ yields\n\\begin{align}\n0 = B  + 1 \\rightarrow B = -1.\n\\end{align}\nThe resulting coefficients\n\\begin{align}\nA = -\\frac{3}{4}\\qquad B = -1\n\\end{align}\nare inserted into \\eq{eq:SpecificyTaskb}\n\\begin{align}\n\\label{eq:stepResponse}\n\\boxed{\nh_\\epsilon = y_\\text{Task b} =\n1 - \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left(\\frac{3}{4} \\sin(t) + \\cos(t)\\right) \\qquad t \\geq 0\n}\\,,\n\\end{align}\ngiving the final result for task b) with $h_\\epsilon(t\\to\\infty) = 1$.\n\nIn Fig.~\\ref{fig:step_response_parts} the solution $y_\\text{Task b}$ is depicted\nas the thick, non-dashed orange graph. It results from the superposition of the\nfunctions\na) unit amplitude (black),\nb) exponentially damped, negative sine (green, diamonds),\nc) exponentially damped, negative cosine (red, stars).\nIn grey colour, the pure sine and cosine functions with negative amplitude,\nas well as the exponential\ndamping with different initial amplitude are indicated.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/step_response_parts}\n\\caption{Response of task b for ODE under discussion.}\n\\label{fig:step_response_parts}\n\\end{figure}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\n16/25*y''(t)+24/25*y'(t)+y(t)=1,       y'(0)=0, y(0)=0\n16/25*y''(t)+24/25*y'(t)+y(t)=Step[t], y'(0)=0, y(0)=0\n\\end{verbatim}\n\n\n\n\n%##############################################################################\n\\subsubsection{Task a) Revisited with Fundamental System / Impulse Response}\n%\nThe Heaviside step function (with left / right limit definition with respect to\ntime instance $t=0$)\n\\begin{equation}\n\\epsilon(t) =\n\\begin{cases}\n  0 & t\\leq 0-0\\\\\n  1 & t\\geq 0+0\n\\end{cases}\n\\end{equation}\nand\nthe Dirac impulse $\\delta(t)$ are related by\n\\begin{align}\n\\dot{\\epsilon}(t) = \\frac{\\fsd \\epsilon(t)}{\\fsd t} = \\delta(t).\n\\end{align}\nIn fact, in task a and b we just derived the impulse response $h(t)$ and step response\n$h_\\epsilon(t)$ of the ODE, respectively.\n%\nWe can also relate the step and impulse response by\n\\begin{align}\n\\dot{h_\\epsilon}(t) = h(t).\n\\end{align}\n%\nThe \\textbf{temporal derivative of the step response} $h_\\epsilon=y_\\text{Task b}$\n\\textbf{yields the impulse response} $h$.\nThus, for the step response\n\\begin{align}\nh_\\epsilon = y_\\text{Task b} =\n1 - \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{3}{4} \\sin(t) + \\cos(t)\\right)\n\\end{align}\nthe derivative is the impulse response\n\\begin{align}\nh = \\dot{h_\\epsilon} = \\dot{y}_\\text{Task b} =\n - (-\\frac{3}{4})\\,\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{3}{4} \\sin(t) + \\cos(t)\\right)\n- \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{3}{4} \\cos(t) - \\sin(t)\\right).\n\\end{align}\nRearranging yields the expected result identical to task a\n\\begin{align}\n\\boxed{\nh = y_\\text{Task a} = \\frac{25}{16} \\mathrm{e}^{-\\frac{3}{4} t} \\sin(t) \\qquad t\\geq 0\n}\\,.\n\\end{align}\n%\nIn Fig. \\ref{fig:impulse_step_response} the impulse response is depicted as\nthe dashed blue graph, whereas the step response is plotted in thick\norange again.\nThe impulse response is a weighted and exponentially damped sine function\nwith $h(t\\to\\infty) = 0$.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/impulse_step_response}\n\\caption{Impulse response (task a, blue, dotted) and step response (task b, orange, thick)\nof the ODE under discussion.}\n\\label{fig:impulse_step_response}\n\\end{figure}\n\nFeel free to verify that Wolfram Alpha returns the particular solution to the\ninput\n\\begin{verbatim}\n16/25*y''(t)+24/25*y'(t)+y(t)=DiracDelta[t]\n\\end{verbatim}\nprecisely identical to the manually calculated impulse response.\n\n\n\n%##############################################################################\n\\subsubsection{Task c) with Fundamental System}\nNow, we shall solve\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = 0,\n\\quad \\dot{y}(0) = 2,\\quad y(0)=1\n\\end{align}\nfor $y$.\n%\nSince $y_p=0$, we can immediately adapt the solution of Sec.\n\\ref{Sec:TaskaHomo} and \\ref{Sec:TaskaInitCond} as\n%\n\\begin{align}\ny_h + y_p = y =& A \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t} + B \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t}\\\\\n\\dot{y} =&\n(-\\frac{3}{4}+\\im) A \\, \\mathrm{e}^{(-\\frac{3}{4}+\\im)\\,t} +\n(-\\frac{3}{4}-\\im) B \\, \\mathrm{e}^{(-\\frac{3}{4}-\\im)\\,t}\n\\end{align}\n%\nApplying the initial conditions yields\n%\n\\begin{align}\n\\dot{y}(0) = 2 =\n(-\\frac{3}{4}+\\im) A+\n(-\\frac{3}{4}-\\im) B\n\\qquad\ny(0) = 1 = A + B.\n\\end{align}\nor as system of equations in matrix notation\n\\begin{align}\n\t\\begin{pmatrix}\n\t\t1 & 1 \\\\\n\t\t-\\frac{3}{4}+\\im & -\\frac{3}{4}-\\im\n\t\\end{pmatrix}\n\t\\cdot\n\t\\begin{pmatrix}\n\t\tA \\\\\n\t\tB\n\t\\end{pmatrix} =\n\t\\begin{pmatrix}\n\t\t1 \\\\\n\t\t2\n\t\\end{pmatrix}. \\nonumber\n\\end{align}\nThus, the coefficients become\n\\begin{align}\nA = \\frac{1}{2} + \\frac{11}{8\\im}\\qquad B = 1-A = \\frac{1}{2} - \\frac{11}{8\\im}.\n\\end{align}\n%\nInserting these and applying the Euler identities\n$\\cos(x) = \\frac{\\e^{\\im x}+\\e^{-\\im x}}{2}$,\n$\\sin(x) = \\frac{\\e^{\\im x}-\\e^{-\\im x}}{2\\im}$\nyields\n\\begin{align}\n\\boxed{\ny_\\text{Task c} = \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{11}{4} \\sin(t) + \\cos(t)\\right) \\qquad t\\geq 0\n}\\,.\n\\end{align}\nIn Fig.~\\ref{fig:initial_conditions_response_parts} the brown graph depicts the\nresponse $y_\\text{Task c}$, which is decaying to zero since the inductor $L$ and capacitor $C$ are\njust discharging. As typical for such ODEs, again\nweighted and exponentially damped cosine (red, stars) and sine (green, diamonds)\nfunction are superimposed.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/initial_conditions_response_parts}\n\\caption{Response of task c for the ODE with initial conditions but no external input.}\n\\label{fig:initial_conditions_response_parts}\n\\end{figure}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\n16/25*y''(t)+24/25*y'(t)+y(t)=0, y'(0)=2, y(0)=1\n\\end{verbatim}\n\n\n\n%##############################################################################\n\\subsubsection{Task d) with Fundamental System}\nIn this task we shall solve\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = 1, \\quad\n\\dot{y}(0) = 2,\\quad y(0)=1\n\\end{align}\nfor $y$.\n%\nThis task is the \\textbf{superposition} of the solution from \\textbf{task b} (exterior source\nbut vanishing initial conditions) and the solution of \\textbf{task c} (no exterior\nsource, but initial conditions). Thus, we should expect\n\\begin{align}\n&y_\\text{Task d} =\ny_\\text{Task b} +\ny_\\text{Task c} = 1 + 2\\mathrm{e}^{-\\frac{3}{4} t} \\sin(t) = \\nonumber\\\\\n&\\left[1 - \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{3}{4} \\sin(t) + \\cos(t)\\right)\\right]\n+\\left[\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( \\frac{11}{4} \\sin(t) + \\cos(t)\\right)\\right].\n\\end{align}\n%\nIn order to reassure this result, we can start with \\eq{eq:SpecificyTaskb} from\ntask b and rearrange this for the differing initial conditions:\nThe superposition of the homogeneous and inhomogeneous solution is\n\\begin{align}\ny = y_h + y_p = \\underbrace{\n\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( A \\sin(t) + B \\cos(t)\\right)}_{y_h} + \\underbrace{1}_{y_p}\n\\end{align}\nAgain, derivation with respect to time is\n\\begin{align}\n\\dot{y}\n=\n-\\frac{3}{4}\\,\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( A \\sin(t) + B \\cos(t)\\right)\n+\n\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left( A \\cos(t)  - B \\sin(t)\\right).\n\\end{align}\nThe initial condition $\\dot{y}(0) = 2$ yields\n\\begin{align}\n2 = -\\frac{3}{4}\\cdot B + A \\rightarrow A = 2 +  \\frac{3}{4}\\cdot B.\n\\end{align}\nThe initial condition ${y}(0) = 1$ yields\n\\begin{align}\n1 = B  + 1 \\rightarrow B = 0.\n\\end{align}\nThus,\n\\begin{align}\nA = 2\\qquad B = 0\n\\end{align}\ninserted\n\\begin{align}\n\\boxed{\ny_\\text{Task d} =\n1+\\mathrm{e}^{-\\frac{3}{4} t}\n\\, 2 \\sin(t)\\qquad t \\geq 0\n}\n\\end{align}\nleads to the final result for task d) as expected.\n%\n\\begin{figure}[b!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/response_full}\n\\caption{Response of task d for the ODE with initial conditions and step input.}\n\\label{fig:response_full}\n\\end{figure}\n%\nIn Fig.~\\ref{fig:response_full} the response $y_\\text{Task d} $ is depicted as\nmagenta graph. This is the result of the superposition of the Heaviside step\nfunction and an exponentially damped, weighted sine function.\nThe final result asymptotically converges to unit amplitude.\n%\nThis is expected: as the effects of initial conditions have been vanished at $t\\to\\infty$\nthe external excitation of the step function is the dominant part for the system\nresponse.\n%\nWe can see this in the equations: $y_\\text{Task d}(t\\to\\infty) = y_\\text{Task b}(t\\to\\infty)$\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\n16/25*y''(t)+24/25*y'(t)+y(t)=1, y'(0)=2, y(0)=1\n\\end{verbatim}\n\n\n\n\n\n%##############################################################################\n\\subsubsection{Task e) with Fundamental System}\n\\label{sec:TaskeWithFundamentalSystem}\nIn this task we shall solve\n\\begin{align}\n\\label{eq:InHomoODE_sin}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = \\sin(t), \\quad\n\\dot{y}(0) = 0,\\quad y(0)=0\n\\end{align}\nfor $y$.\n%\nWe already know the homogeneous solution\n$y_h = \\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left[ A \\sin(t) + B \\cos(t)\\right]$.\n%\nThe inhomogeneity in this case can be solved with the Ansatz (cf.\nSec. \\ref{Sec:CosSineAnsatzInhomo})\n\\begin{align}\ny_p = C \\sin(t) + D \\cos(t).\n\\end{align}\nInserting this into \\eq{eq:InHomoODE_sin}, the\ncoefficients are solved to (still somehow nice numbers, but we see that this can\nbecome a mess for even more complicated excitations\n)\n\\begin{align}\nC = \\frac{25}{73}\\qquad D = -\\frac{200}{219}.\n\\end{align}\n%\nThe solution then becomes\n\\begin{align}\ny = y_h + y_p = \\underbrace{\\mathrm{e}^{-\\frac{3}{4} t} \\cdot\n\\left[ A \\sin(t) + B \\cos(t)\\right]}_{\\text{damped solution} \\, y_h}+\n\\underbrace{\\frac{25}{73} \\sin(t) - \\frac{200}{219} \\cos(t)}_{\\text{oscillating solution} \\, y_p}.\n\\end{align}\nBy considering the initial conditions the remaining unknown coefficients solve to\n\\begin{align}\nA = \\frac{25}{73}\\qquad B = \\frac{200}{219}\n\\end{align}\ngiving the final result\n\\begin{align}\n\\boxed{\ny_\\text{Task e} = \\frac{25}{73} \\mathrm{e}^{-\\frac{3}{4} t} \\sin(t) +\n\\frac{200}{219} \\mathrm{e}^{-\\frac{3}{4} t} \\cos(t) +\n\\frac{25}{73} \\sin(t) -\n\\frac{200}{219} \\cos(t) \\qquad t\\geq 0\n}\\, ,\n\\end{align}\n%\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/sine_excitation_response}\n\\caption{Response of task e for the ODE with zero initial conditions and\n$\\sin(t)$ input.}\n\\label{fig:sine_excitation_response}\n\\end{figure}\n\nThe response is depicted in Fig.~\\ref{fig:sine_excitation_response} in\nthick/blue.\nIt results from the superposition of a) weighted and \\textbf{exponentially damped}\nsine and cosine functions (yellow and green graphs) and b) weighted but \\textbf{undamped}\nsine and cosine functions (brown and purple graphs).\n\n\\subsubsection{Steady State of the System}\n%\nIn this example it is important to realise that the initial conditions\n(exponentially damped sine and cosine) contribute\nto the system response only up to approximately $t=2\\pi$\nseconds, i.e. in the first period $T=\\frac{2\\pi}{\\omega_D}=2\\pi$ of the\nexcitation's frequency here.\n%\nFor times $t\\gg2\\pi$ seconds the system response is determined by the\nundamped sine and cosine functions, yielding a system response of\n\\begin{align}\n\\label{eq:steadystate_timedomain}\ny(t\\gg 2\\pi, t\\to\\infty) = \\frac{25}{3 \\sqrt{73}}\\cdot\n\\sin\\left(t-\\tan^{-1}\n\\left[\\frac{\\nicefrac{200}{219}}{\\nicefrac{25}{73}}\\right]\\right),\n\\end{align}\ndepicted as the red dotted graph in Fig.~\\ref{fig:sine_excitation_response}.\nThis constitutes the so called \\textbf{steady-state} of the system response\nfor $t\\to\\infty$.\nFor that, we see that the excitation signal $x=\\sin(t)$ is altered in amplitude\n(very subtle damping of about 0.975) and\na time delay (in terms of phase: about -70 degrees or about $-0.386 \\pi$ in\nradian), cf. the black line indicator in the figure.\nNote that $\\frac{\\nicefrac{200}{219}}{\\nicefrac{25}{73}} = \\nicefrac{8}{3}$ again\nresults in simple numbers for the chosen example. We will rather not see such\nfor real practical problems.\n\nThe two parameters in the\n\\textbf{steady state}---\\textbf{the amplitude and the phase offset}---and\ntheir specific quantities are very important for the\ninterpretation of ODEs as LTI systems. Each excitation frequency has its own\nquantity set, yielding frequency dependent system characteristics.\nWe will deal with it in detail when discussing ODEs in Laplace domain.\n%\nThe so called Bode plot or \\textbf{Bode diagram} is one important tool\nto visualize amplitude and phase over frequency in approximated manner.\n%\nNowadays, exact computation of amplitude and phase over frequency is convenient\nusing computers.\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\n16/25*y''(t)+24/25*y'(t)+y(t)=Sin[t], y'(0)=0, y(0)=0\n\\end{verbatim}\n\n\n\n\n\n%##############################################################################\n\\newpage\n\\subsection{Preliminaries for Laplace Transform}\nWe should now study the problem with the help of the Laplace transform.\nFor the chosen ODE and input signals the calculus effort is about the same,\nhowever for slightly more complicated cases, the approach via Laplace transform\nis often the more convenient approach for the solution.\n%\nFor instance, Laplace transform is more powerful, when the \\textbf{steady state}\nsystem response for oscillations \\textbf{at many different frequencies} is\nsearched for.\n%\nInstead of solving each individual problem with the approach that we took before,\nthe problem is conveniently solved by means of the \\textbf{transfer function},\nwhich stores amplitude and phase offset for each arbitrary oscillation frequency.\n%\nWe will discover this, when solving tasks a) to e) with the help of the Laplace\ntransform. The solutions must be of course identical to these we have found so far.\n\nTo obtain the time functions the inverse Laplace function needs to be calculated.\n%\nWe do not need to use the complex integral and application of the\n\\textbf{residue theorem}\nhere in SigSys, but rather make use of \\textbf{correspondence tables for Laplace transforms}.\n%\nThe English and German textbooks\n\\cite{Strang2007,Strang2010,Strang2014,GirodRabensteinStenger2007,Girod2001,Oppenheim1997,Fliege1991,\nGoeldner1987,LangeSigSys1,Wunsch1972}\ncan be considered classics and cover the Laplace transform very well for our\npurpose.\n\n\n\n\n%##############################################################################\n\\subsubsection{Laplace Transform Fundamentals}\nThe Laplace transform pair reads\n\\begin{align}\nY(s) = \\mathcal{L}\\{y(t)\\}= \\int\\limits_{-\\infty}^{\\infty} y(t) \\e^{-s t}\n\\mathrm{d} t\\qquad\ny(t) = \\mathcal{L}^{-1}\\{Y(s)\\}= \\frac{1}{2\\pi\\im}\\int\n\\limits_{\\sigma-\\im \\infty}^{\\sigma+\\im\\infty} Y(s) \\e^{+s t} \\mathrm{d} s.\n\\end{align}\nWe use the operators\n$y(t) \\quad \\laplace \\quad Y(s)$ and\n$Y(s) = \\mathcal{L}\\{y(t)\\}$\nto indicate forward Laplace transform.\nWe use the operators\n$Y(s) \\quad \\Laplace \\quad y(t)$ and\n$y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nto indicate inverse Laplace transform.\n\nTo make the Laplace transform helpful for solving ODEs, we first reconsider\nthat the Laplace transform is linear, i.e. it preserves scaling and\nsuperposition in both signal domains\n\\begin{align}\nA y_1(t) + B y_2(t) \\quad \\laplace \\quad A Y_1(s) + B Y_2(s).\n\\end{align}\nThe second, fundamental important characteristics of the Laplace transform is\n\\begin{align}\n\\mathcal{L}\\{\\frac{\\mathrm{d}^n y(t)}{\\mathrm{d} t^n}\\}=\ns^n Y(s) - \\sum_{k=1}^{n} s^{n-k} \\cdot\n\\frac{\\mathrm{d}^{k-1} y(t)}{\\mathrm{d} t^{k-1}}\\bigg|_{t=0},\n\\end{align}\nThe temporal derivation operation will be transformed to a multiplication\noperation with Laplace variable $s$ (\\textbf{differential equations} essentially \\textbf{become\nalgebraic equations}, that is the key idea and a special case of\nso called operator theory, we have seen a similar concept already for the\ncharacteristic polynomial).\n%\nFor typical systems up to 2nd order, we will need\n\\begin{align}\n\\label{eq:Laplace0thd}\n\\boxed{\\mathcal{L}\\{{y(t)}\\} = Y(s)},\n\\end{align}\n\\begin{align}\n\\label{eq:Laplace1std}\n\\mathcal{L}\\{\\frac{\\mathrm{d} y(t)}{\\mathrm{d} t}\\}=\ns \\cdot Y(s) - \\sum_{k=1}^{1} s^{1-k} \\cdot\n\\frac{\\mathrm{d}^{k-1} y(t)}{\\mathrm{d} t^{k-1}}\\bigg|_{t=0}\n= \\boxed{\\mathcal{L}\\{\\dot{y}\\} = s \\cdot Y(s) - y(0)}\n\\end{align}\nand\n\\begin{align}\n\\label{eq:Laplace2ndd}\n\\mathcal{L}\\{\\frac{\\mathrm{d}^2 y(t)}{\\mathrm{d} t^2}\\}=\ns^2 \\cdot Y(s) - \\sum_{k=1}^{2} s^{2-k} \\cdot\n\\frac{\\mathrm{d}^{k-1} y(t)}{\\mathrm{d} t^{k-1}}\\bigg|_{t=0}\n= \\boxed{\\mathcal{L}\\{\\ddot{y}\\} = s^2 \\cdot Y(s) - s \\cdot y(0) - \\dot{y}(0)}\\,.\n\\end{align}\n\nNote the \\textbf{application of the initial conditions} in these transform rules!\n\n%##############################################################################\n\\subsubsection{Algorithm for Solving ODEs via Laplace Transform}\n\nSolving an ODE problem via the indirect way of Laplace transform is then as follows\n\\begin{itemize}\n\\item[1.] transform the ODE equation to the Laplace domain by applying rules of linearity and\nderivatives\n\\item[2.] insert the initial conditions of $y(0)$  and $\\dot{y}(0)$ and ...\n(if they are zero, actually the additional terms immediately become zero,\nthis is very nice)\n\\item[3.] find the Laplace transform $X(s)$ of inhomogeneity $x(t)$ and insert\nit (note that we are most often interested in $x(t)=\\delta(t)$,\n$x(t)=\\epsilon(t)$, $x(t)=\\exp(s_1 t)$ with $s_1\\in\\mathbb{C}$\nas they tell us the most interesting things of the ODE)\n\\item[4.] reorganize the transformed equation for $Y(s)$\n\\item[5.] perform \\textbf{inverse transformation} $y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nby means of either \\textbf{partial fraction decomposition} and usage of\n\\textbf{transform tables}\nor if this fails by means of the residue theorem...if this even fails we have a\nvery delicate problem at hand.\n\\footnote{For many systems we deal with in engineering,\nsomeone very likely calculated the inverse Laplace transform already and we\nmight find it in formularies, list of integrals and textbooks.\nSo before trying to solve the integral of the inverse Laplace transform\nmanually, try to find the tabulated solution.\nThough, very often the solution must be tweaked to fit into the tabulated\ntransforms.\nAnyway, deriving solutions with residue theorem by our own is a\ngood exercise and enlightening.}\n\\end{itemize}\n\nWe aim at \\textbf{right-sided}, and more specifically \\textbf{causal systems and signals}.\nThus the region of convergence (ROC) is placed right of the most right pole of a\nLaplace transform's function.\n%\nA stable LTI system requires poles only left of the $\\Im(s)$-axis, i.e. only in\nthe left half of the $s$-plane.\n%\nThis inherently implies, that $\\Im(s)$-axis is part of the region of convergence (ROC),\nand we can evaluated the frequency response of the system.\n\n%##############################################################################\n\\subsubsection{Laplace Transform of the 2nd Order Linear ODE with Constant Coefficients}\nThe ODE under discussion is still \\eq{eq:ODE_sigma0}\n\\begin{align}\n\\frac{\\ddot{y}}{\\omega_0^2} + \\frac{2 \\sigma_0}{\\omega_0^2} \\dot{y} + y = x\n\\end{align}\nfor which task a) to e) are to be solved by means of Laplace transform.\nThe general Ansatz valid for all tasks is sketched here.\n%\nFirst, considering linearity (scaling, superposition) yields\n\\begin{align}\n\\frac{1}{\\omega_0^2} \\ddot{y} +\n\\frac{2 \\sigma_0}{\\omega_0^2} \\dot{y} + y = x\n\\quad \\laplace \\quad\n\\frac{1}{\\omega_0^2} \\mathcal{L}\\{\\ddot{y}\\} +\n\\frac{2 \\sigma_0}{\\omega_0^2} \\mathcal{L}\\{\\dot{y}\\} + \\mathcal{L}\\{y\\} =\n\\mathcal{L}\\{x\\}.\n\\end{align}\n%\nSecond, the temporal derivative rules \\eq{eq:Laplace0thd}, \\eq{eq:Laplace1std}\nand \\eq{eq:Laplace2ndd} are applied to functions $y$ and $x$ yielding\n\\begin{align}\n\\frac{1}{\\omega_0^2} \\left[ s^2 \\cdot Y(s) - s \\cdot y(0) - \\dot{y}(0)\\right]  +\n\\frac{2 \\sigma_0}{\\omega_0^2} \\left[ s \\cdot Y(s) - y(0) \\right] + Y(s) = X(s).\n\\end{align}\n%\nRearranging for $Y(s)$ yields (we must \\textbf{savely distinguish} between $Y$, $y$ and $\\dot{y}$\nin that equation, pay special attention with handwriting!)\n\\begin{align}\nY(s) = \\frac{X(s)}{\\frac{1}{\\omega_0^2} s^2 +\n\\frac{2 \\sigma_0}{\\omega_0^2} s + 1}\n+ \\frac{\\frac{1}{\\omega_0^2} s \\cdot y(0) + \\frac{2 \\sigma_0}{\\omega_0^2} \\cdot y(0) +\n\\frac{1}{\\omega_0^2} \\cdot \\dot{y}(0)}{\\frac{1}\n{\\omega_0^2} s^2 + \\frac{2 \\sigma_0}{\\omega_0^2} s + 1}.\n\\end{align}\n%\nIt is now important to realise (and that shows the links in a beautiful way)\nthat the \\textbf{characteristic equation} (\\ref{eq:CharEq})\nappears as the \\textbf{denominator in the Laplace function}, we only have to change\nvariable $\\lambda\\rightarrow s$.\nTherefore, discussions of the characteristic equation in terms of its zeros become\ndiscussions in terms of poles in the Laplace domain,\ncf. Fig.~\\ref{fig:sketch_lambda_plane} left vs. right.\n\n\\begin{figure}[h!]\n\\captionsetup[subfigure]{font=footnotesize}\n\\centering\n\\subcaptionbox{\\textbf{Zeros} in complex $\\lambda$-plane of ODE's characteristic\nequation \\eq{eq:CharEq}.}[.4\\textwidth]{%\n\\begin{tikzpicture}\n\\draw [-latex] (-2,0) -- (3.5,0) node [right]  {$\\Re(\\lambda)$};\n\\draw [-latex] (0,-2) -- (0,2) node [above] {$\\Im(\\lambda)$};\n\\draw[dashed] (0,0) -- node[pos=0.7, right] {$\\omega_0$}(135:2) node[solid, fill=white, circle, draw=blue, ultra thick] {};\n\\draw[dashed] (0,0) -- node[pos=0.6, above right] {$ $}(-135:2) node[solid, fill=white, circle, draw=blue, ultra thick] {};\n\\draw[dashed] (-1.4142,0) -- (-1.4142,+1.4142);\n\\draw[dashed] (-1.4142,-1.4142) -- (-1.4142,-0.5) node [left, above] {$-\\sigma_0$};\n\\draw[dashed] (-1.4142,+1.4142) -- (0,+1.4142) node [right] {$+\\omega_D$};\n\\draw[dashed] (-1.4142,-1.4142) -- (0,-1.4142) node [right] {$-\\omega_D$};\n\\draw[black, -latex] (-0.75,0.75) arc (135:180:1);\n\\node at (1.9,1) {$\\omega_D = \\omega_0 \\sqrt{1-D^2}$};\n\\node at (1.3,0.5) {$\\sigma_0 = D \\omega_0$};\n\\node at (-0.7,0.25) {$\\alpha$};\n\\node at (1.4,-0.25) {$\\cos \\alpha = D$};\n\\end{tikzpicture}}\n\\subcaptionbox{\\textbf{Poles} in complex $s$-plane of LTI system's transfer function, cf. Sec. \\ref{sec:TransferFunction}.}[.4\\textwidth]{%\n\\begin{tikzpicture}\n\\draw [-latex] (-2,0) -- (3.5,0) node [right]  {$\\Re(s)$};\n\\draw [-latex] (0,-2) -- (0,2) node [above] {$\\Im(s)$};\n\\draw[dashed] (0,0) -- node[pos=0.7, right] {$\\omega_0$}(135:2) node[solid, fill=white, cross=6pt, draw=blue, ultra thick] {};\n\\draw[dashed] (0,0) -- node[pos=0.6, above right] {$ $}(-135:2) node[solid, fill=white, cross=6pt, draw=blue, ultra thick] {};\n\\draw[dashed] (-1.4142,0) -- (-1.4142,+1.4142);\n\\draw[dashed] (-1.4142,-1.4142) -- (-1.4142,-0.5) node [left, above] {$-\\sigma_0$};\n\\draw[dashed] (-1.4142,+1.4142) -- (0,+1.4142) node [right] {$+\\omega_D$};\n\\draw[dashed] (-1.4142,-1.4142) -- (0,-1.4142) node [right] {$-\\omega_D$};\n\\draw[black, -latex] (-0.75,0.75) arc (135:180:1);\n\\node at (1.9,1) {$\\omega_D = \\omega_0 \\sqrt{1-D^2}$};\n\\node at (1.3,0.5) {$\\sigma_0 = D \\omega_0$};\n\\node at (-0.7,0.25) {$\\alpha$};\n\\node at (1.4,-0.25) {$\\cos \\alpha = D$};\n\\end{tikzpicture}}\n\\caption{Sketch of ODE's homogeneous solution case III with a complex conjugate\nsolution.}\n\\label{fig:sketch_lambda_plane}\n\\end{figure}\n\n\n%##############################################################################\n\\subsubsection{Specific Parameters}\nFor our chosen quantities\n$\\omega_0=\\frac{5}{4}$,\n$\\sigma_0 = \\frac{3}{4}$,\n$\\omega_D=1$\nthe ODE reads\n\\begin{align}\n\\frac{16}{25} \\ddot{y} + \\frac{24}{25} \\dot{y} + y = x.\n\\end{align}\nSome tasks in this exercise require the initial conditions\n$\\dot{y}(0)=0$ and $y(0)=0$.\nThen the Laplace transform becomes\n\\begin{align}\n\\boxed{\nY(s) = \\frac{X(s)}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}}\\,.\n\\end{align}\nOther tasks require initial conditions $\\dot{y}(0)=2$ and $y(0)=1$.\nThen the Laplace transform reads\n\\begin{align}\n\\boxed{\nY(s) = \\frac{X(s)}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}+\n\\frac{\\frac{16}{25} s + \\frac{56}{25}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}}\\,.\n\\end{align}\n%\nWe require the following input signals for this exercise\n\\begin{itemize}\n  \\item $x(t) = \\delta(t) \\quad \\laplace \\quad X(s) = 1$\n  \\quad ROC: $s \\in \\mathbb{C}$\n  \\item $x(t) = \\epsilon(t) \\quad \\laplace \\quad X(s) = \\frac{1}{s}$\n  \\quad ROC: $\\Re(s)>0$\n  \\item $x(t) =  \\sin(\\omega_D t) \\epsilon(t) \\quad \\laplace \\quad\n   X(s) = \\frac{\\omega_D}{s^2 + \\omega_D^2}$\n   \\quad ROC: $\\Re(s)>0$ with $\\omega_D=1$\n\\end{itemize}\n\n\n%##############################################################################\n%##############################################################################\n\\newpage\n\\subsection{Solutions Using Laplace Transform}\n\\label{sec:SolutionsUsingLaplaceTransform}\n%##############################################################################\n\n\n\\subsubsection{Task a) with Laplace Transform / Impulse Response}\n\\label{sec:TransferFunction}\nWe shall find the inverse Laplace transform\n$y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$ for\n\\begin{align}\nY(s) = \\frac{1}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > -\\frac{3}{4}.\n\\end{align}\nSince the \\textbf{Dirac Delta impulse} is the \\textbf{input signal} here,\n$Y(s)$ is here and only here by definition equivalent with the\n\\textbf{transfer function} $H(s)$, for which the \\textbf{fundamental theorem}\n\\begin{align}\n\\boxed{y(t) = x(t)*h(t) \\quad \\laplace \\quad Y(s) = X(s) \\cdot H(s)}\n\\end{align}\nconnects time domain and Laplace domain.\n%\nThe inverse Laplace transform can be conveniently solved by carefully\nrearranging\n$Y(s)$ to\n\\begin{align}\nH(s) = Y(s) = \\frac{\\frac{25}{16}}{s^2 + \\frac{24}{16} s + \\frac{25}{16}}=\n\\frac{25}{16} \\cdot \\frac{1}{(s + \\frac{3}{4})^2 + 1^2}\n\\end{align}\ncorresponding to a damped sine function (cf. Appendix) as the LTI system's\nimpulse response\n\\begin{align}\n\\boxed{h(t) = y_\\text{Task a}(t) = \\frac{25}{16} \\e^{-\\frac{3}{4} t} \\sin(t)\n\\cdot \\epsilon(t)}\\,.\n\\end{align}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\nInverseLaplaceTransform[1/(16/25*s^2+24/25*s+1)]\n\\end{verbatim}\n\nWe should make ourselves comfortable with the Laplace transform pairs of sine, cosine\nfunctions and its exponentially damped versions in the Appendix.\nThese will often appear as solutions for ODEs under discussion.\n\n\n%##############################################################################\n\\subsubsection{Task b) with Laplace Transform / Step Response}\nWe shall find the inverse Laplace transform $y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nfor\n\\begin{align}\nY(s) = \\frac{\\frac{1}{s}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > 0.\n\\end{align}\n%\nWe solve this problem by means of partial fraction decomposition.\nWe have a single pole in the origin $s_{\\infty,1}=0$ and a complex conjugate\npole pair $s_{\\infty,2,3}=-\\frac{3}{4}\\pm \\im$.\nThus, the Ansatz is\n\\begin{align}\nY(s) = \\frac{1}{s}\n\\cdot \\frac{1}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1} &=\n\\frac{A}{s-s_{\\infty,1}} + \\frac{Bs+C}{(s-s_{\\infty,2})(s-s_{\\infty,3})} \\\\ \\nonumber\n=\\frac{1}{s(s-(-\\frac{3}{4}+\\im))(s-(-\\frac{3}{4}-\\im))}&=\\frac{A}{s}+\\frac{Bs+C}{(s-(-\\frac{3}{4}+\\im))(s-(-\\frac{3}{4}-\\im))}\n.\n\\end{align}\nRearranging yields\n\\begin{align}\n1 =\nA \\cdot (\\frac{16}{25} s^2 + \\frac{24}{25} s + 1) +\n(B s + C) \\cdot s=s^2(\\frac{16}{25}A+B)+s(\\frac{24}{25}A+C)+A.\n\\end{align}\nAgain, we can write this as a system of linear equations\n\\begin{align}\n\t\\begin{pmatrix}\n\t\t\\frac{16}{25} & 1 & 0 \\\\\n\t\t\\frac{24}{25} & 0 & 1 \\\\\n\t\t1 & 0 & 0\n\t\\end{pmatrix}\n\t\\cdot\n\t\\begin{pmatrix}\n\t\tA \\\\\n\t\tB \\\\\n\t\tC\n\t\\end{pmatrix}\n\t=\n\t\\begin{pmatrix}\n\t\t0 \\\\\n\t\t0 \\\\\n\t\t1\n\t\\end{pmatrix}.\n\\end{align}\nComparison of coefficients for $s^2, s^1, s^0$ / solving matrix system yields\n\\begin{align}\n  A = 1\\quad B = -\\frac{16}{25} \\quad C = -\\frac{24}{25}.\n\\end{align}\nInserting these into the Ansatz leads to\n\\begin{align}\nY(s) =\n\\frac{1}{s} - \\left[\\frac{\\frac{16}{25} s + \\frac{24}{25}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\\right]=\n\\frac{1}{s} - \\left[\\frac{s + \\frac{3}{2}}{s^2 + \\frac{3}{2} s + \\frac{25}{16}}\\right]=\n\\frac{1}{s} - \\left[\\frac{s + \\frac{3}{2}}{(s + \\frac{3}{4})^2 + 1^2}\\right].\n\\end{align}\nNow, the denominator of the second fraction looks well for sine or cosine related\nLaplace transforms.\nAnother rearranging step (this is the part, where some experience\nis helpful to bring fractions to a suitable form)\n\\begin{align}\nY(s) =\n\\frac{1}{s} - \\left[\\frac{s + \\frac{3}{4}}{(s + \\frac{3}{4})^2 + 1^2} +\n\\frac{\\frac{3}{4}}{(s+\\frac{3}{4})^2 + 1^2}\\right]\n\\end{align}\nsplits the term in the bracket.\nIndividual inverse Laplace transform of each fraction is allowed due to\nlinearity. Thus, we get\n\\begin{align}\n\\label{eq:stepResponse_Laplace}\n\\boxed{y(t)_\\text{Task b} =\n\\left[1\n- \\e^{-\\frac{3}{4} t} \\cos(t)\n- \\frac{3}{4}\\e^{-\\frac{3}{4} t} \\sin(t) \\right] \\cdot \\epsilon(t)}\\,.\n\\end{align}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\nInverseLaplaceTransform[(1/s)/(16/25*s^2+24/25*s+1)]\n\\end{verbatim}\n\n%##############################################################################\n\\subsubsection{Task c) with Laplace Transform}\nWe shall find the inverse Laplace transform $y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nfor\n\\begin{align}\nY(s) =\n\\frac{\\frac{16}{25} s + \\frac{56}{25}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > -\\frac{3}{4}.\n\\end{align}\nThis particular problem becomes solvable by rearranging the fraction to\n\\begin{align}\nY(s) =\n\\frac{s + \\frac{7}{2}}{s^2 + \\frac{3}{2} s + \\frac{25}{16}} =\n\\frac{s + \\frac{7}{2}}{(s + \\frac{3}{4})^2 + 1^2}\n=\\frac{s + \\frac{3}{4}}{(s + \\frac{3}{4})^2 + 1^2}\n+\\frac{\\frac{11}{4}}{(s + \\frac{3}{4})^2 + 1^2}.\n\\end{align}\nThis results in exponentially damped cosine and sine functions\n\\begin{align}\n\\boxed{y(t)_\\text{Task c} =\n\\left[\\e^{-\\frac{3}{4} t} \\cos(t)\n+\\frac{11}{4}\\e^{-\\frac{3}{4} t} \\sin(t) \\right] \\cdot \\epsilon(t)}\\,.\n\\end{align}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\nInverseLaplaceTransform[(16/25*s+56/25)/(16/25*s^2+24/25*s+1)]\n\\end{verbatim}\n\n\n%##############################################################################\n\\subsubsection{Task d) with Laplace Transform}\nWe shall find the inverse Laplace transform $y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nfor\n\\begin{align}\nY(s) = \\frac{\\frac{1}{s}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}+\n\\frac{\\frac{16}{25} s + \\frac{56}{25}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > 0.\n\\end{align}\nStraightforward superposition is just to be done here:\nWe already have calculated the individual inverse Laplace transforms in task b\nand c. So the solution becomes\n\\begin{align}\n\\boxed{y(t)_\\text{Task d} = y(t)_\\text{Task b} + y(t)_\\text{Task c}\n= \\left[1+\\mathrm{e}^{-\\frac{3}{4} t} \\, 2 \\sin(t) \\right] \\cdot \\epsilon(t)\n}\\,.\n\\end{align}\nWe have observed this characteristics in the time domain as well.\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\nInverseLaplaceTransform[(1/s+16/25*s+56/25)/(16/25*s^2+24/25*s+1)]\n\\end{verbatim}\n\n\n%##############################################################################\n\\subsubsection{Task e) with Laplace Transform}\n\\label{sec:task_e_Laplace}\nWe shall find the inverse Laplace transform $y(t) = \\mathcal{L}^{-1}\\{Y(s)\\}$\nfor\n\\begin{align}\nY(s) = \\frac{\\frac{1}{s^2 + 1^2}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > 0.\n\\end{align}\nHere we deal with two complex conjugate pole pairs (the first one from system\ncharacteristic, the second from the $\\sin(t)$-input signal)\n\\begin{align}\ns_{\\infty,1,2} = -\\frac{3}{4} \\pm \\im \\qquad s_{\\infty,3,4} = \\pm \\im.\n\\end{align}\nWe again try to solve with partial fraction decomposition, here with the Ansatz\n\\begin{align}\nY(s) = \\frac{A s + B}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}+\n\\frac{C s + D}{s^2+1}.\n\\end{align}\nHence,\n\\begin{align}\n1&=\n(A s + B) \\cdot (s^2+1)+\n(C s + D) \\cdot (\\frac{16}{25} s^2 + \\frac{24}{25} s + 1) \\nonumber \\\\\n&= s^3(A+\\frac{16}{25}C)+s^2(B+\\frac{24}{25}C+\\frac{16}{25}D)+s(A+C+\\frac{24}{25}D)+(B+D).\n\\end{align}\nand again setting up a system of linear equations in convenient matrix notation\n%wolfram alpha:\n%inv[[[0, 1, 0, 1], [10/13, 10/13, 1, 1], [250/137, 125/137, 274/137, 1], [750/241, 250/241, 723/241, 1]]]*[1, 5/13, 25/137, 25/241]\n% \\begin{align}\n% \\underbrace{\n% \\begin{pmatrix}\n% 0 & 1 & 0 & 1\\\\\n% \\nicefrac{10}{13} & \\nicefrac{10}{13} & 1 & 1\\\\\n% \\nicefrac{250}{137} & \\nicefrac{125}{137} & \\nicefrac{274}{137} & 1\\\\\n% \\nicefrac{750}{241} & \\nicefrac{250}{241} & \\nicefrac{723}{241} & 1\n% \\end{pmatrix}\n% }_{\\mathbf{M}}\n% \\cdot\n% \\underbrace{\n% \\begin{pmatrix}\n% A \\\\\n% B\\\\\n% C\\\\\n% D\n% \\end{pmatrix}\n% }_{\\mathbf{u}}\n% =\n% \\underbrace{\n% \\begin{pmatrix}\n% 1\\\\\n% \\nicefrac{5}{13}\\\\\n% \\nicefrac{25}{137}\\\\\n% \\nicefrac{25}{241}\n% \\end{pmatrix}\n% }_{\\mathbf{v}}\n% \\end{align}\n% when inserting $s=0,1,2,3$ (included in the ROC) to obtain four equations.\n%\n%\n%\n%inv[[[1, 0, 16/25, 0], [0, 1, 24/25, 16/25], [1, 0, 1, 24/25], [0, 1, 0, 1]]]*[0, 0, 0, 1]\n\\begin{align}\n\\underbrace{\n\\begin{pmatrix}\n1 & 0 & \\nicefrac{16}{25} & 0\\\\\n0 & 1 & \\nicefrac{24}{25} & \\nicefrac{16}{25}\\\\\n1 & 0 & 1 & \\nicefrac{24}{25}\\\\\n0 & 1 & 0 & 1\n\\end{pmatrix}\n}_{\\mathbf{M}}\n\\cdot\n\\underbrace{\n\\begin{pmatrix}\nA \\\\\nB\\\\\nC\\\\\nD\n\\end{pmatrix}\n}_{\\mathbf{u}}\n=\n\\underbrace{\n\\begin{pmatrix}\n0\\\\\n0\\\\\n0\\\\\n1\n\\end{pmatrix}\n}_{\\mathbf{v}}\n.\n\\end{align}\n%\nThe matrix $\\mathbf{M}$ is full rank.\n%\nIf we do not believe this, we can assure us by checking that the reduced row echelon\nform of $\\mathbf{M}$ is the identity matrix.\n%\nSince the system response is unique, the defined linear system of equations must\nhave a unique solution as well.\n%\nThis means that the square $\\mathbf{M}$ has an exact inverse.\n%\nThus, solving $\\mathbf{u} = \\mathbf{M}^{-1} \\cdot \\mathbf{v}$ yields the coefficients\n\\begin{align}\n\\label{eq:coeffABCDsinLaplace}\n  A = \\frac{128}{219}\n  \\quad B = \\frac{48}{73}\n  \\quad C = -\\frac{200}{219}\n  \\quad D = \\frac{25}{73}.\n\\end{align}\n%\nIn later practice\nwe might leave this job for a computer, such as e.g. input to Wolfram Alpha\n\\begin{verbatim}\ninv[[[1, 0, 16/25, 0], [0, 1, 24/25, 16/25], [1, 0, 1, 24/25], [0, 1, 0, 1]]]*[0, 0, 0, 1]\n\\end{verbatim}\n\n%\nInserting these into the Ansatz results in\n\\begin{align}\nY(s) = \\frac{\\frac{128}{219} s +\n\\frac{48}{73}}{\\frac{16}{25} s^2 +\n\\frac{24}{25} s + 1} +\n\\frac{-\\frac{200}{219} s +\n\\frac{25}{73}}{s^2+1}.\n\\end{align}\nThis again needs to be reformulated such that \\textbf{Laplace transforms of\nexponentially damped and undamped sine/cosine functions}\ncan be revealed (this is a very typical exam task).\n%\nThe last fraction is straightforward with regard to that:\n\\begin{align}\nY(s) = \\frac{\\frac{128}{219} s + \\frac{48}{73}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n-\\frac{200}{219}\\frac{s}{s^2+1^2}\n+\\frac{25}{73}\\frac{1}{s^2+1^2}.\n\\end{align}\n%\nThe first fraction is similar to the approaches of tasks a) - d) and can be\nrearranged as\n\\begin{align}\nY(s) = &\n\\frac{\\frac{200}{219} s + \\frac{75}{73}}{s^2 + \\frac{3}{2} s + \\frac{25}{16}}\n-\\frac{200}{219}\\frac{s}{s^2+1^2}\n+\\frac{25}{73}\\frac{1}{s^2+1^2}\\\\\n&\n\\frac{\\frac{200}{219} s + \\frac{75}{73}}{(s + \\frac{3}{4})^2 + 1^2}\n-\\frac{200}{219}\\frac{s}{s^2+1^2}\n+\\frac{25}{73}\\frac{1}{s^2+1^2}\\\\\n&\n\\frac{200}{219} \\frac{s + \\frac{3}{4}}{(s + \\frac{3}{4})^2 + 1^2}+\n\\frac{\\frac{25}{73}}{(s + \\frac{3}{4})^2 + 1^2}\n-\\frac{200}{219}\\frac{s}{s^2+1^2}\n+\\frac{25}{73}\\frac{1}{s^2+1^2}.\n\\end{align}\nThis term now can be conveniently transformed back into time domain,\nfraction by fraction due to the linearity of the Laplace transform\n\\begin{align}\n\\boxed{\n  y_\\text{Task e}(t) =\n  \\left[ \\frac{200}{219} \\e^{-\\frac{3}{4} t} \\cos(t) +\n  \\frac{25}{73} \\e^{-\\frac{3}{4} t} \\sin(t) -\n  \\frac{200}{219} \\cos(t) +\n  \\frac{25}{73} \\sin(t) \\right] \\cdot \\epsilon(t)}\\,.\n\\end{align}\n\nFeel free to double check this solution at Wolfram Alpha with input\n\\begin{verbatim}\nInverseLaplaceTransform[(1/(s^2+1^2))/(16/25*s^2+24/25*s+1)]\n\\end{verbatim}\n\n\n\n%##############################################################################\n\\subsubsection{Transfer Function and Frequency Response of the System}\n%\nWith \\eq{eq:steadystate_timedomain}\n\\begin{align}\ny(t\\gg 2\\pi, t\\to\\infty) = \\frac{25}{3 \\sqrt{73}}\\cdot\n\\sin\\left(t-\\tan^{-1}\n\\left[\\frac{\\nicefrac{200}{219}}{\\nicefrac{25}{73}}\\right]\\right),\n\\end{align}\nwe explored the \\textbf{steady state} of the system giving\namplitude and phase offset for $\\omega=1$.\n%\nA convenient way to calculate the steady state for many (all) $\\omega$, is to evaluate\nthe \\textbf{Laplace transform}, i.e. \\textbf{the transfer function} of the system,\nsee taks a)\n\\begin{align}\nH(s) = \\frac{1}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\end{align}\nalong the\n$\\im\\omega$-axis of the $s$-domain\n\\begin{align}\nH(s)\\bigg|_{s=\\im\\omega} =\nH(\\im\\omega)\n= \\frac{1}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\\bigg|_{s=\\im\\omega}\n= \\frac{1}{\\frac{16}{25} (\\im\\omega)^2 + \\frac{24}{25} \\im\\omega + 1}\n= \\frac{1}{ (1 -\\frac{16}{25} \\omega^2) + \\im (\\frac{24}{25} \\omega)}.\n\\end{align}\nThis constitutes the \\textbf{Fourier transform} $\\mathcal{F}\\{h(t)\\}$\nof the impulse response $h(t)$ and is known as\n\\textbf{frequency response} $H(\\im\\omega)$ of the system.\n%\nTypically, $H(\\im\\omega)$ is complex-valued (only in rare, special cases\nit is real-valued), thus it is meaningful to specify the magnitude and the phase\nof the complex number $H(\\im\\omega)$ at each $\\omega$.\n%\nThis is depicted in Fig. \\ref{fig:frequency_response_mag_phase}: on top magnitude\n$|H(\\im\\omega)|$ over angular frequency $\\omega$, at the bottom plot normalized\nphase $\\angle H(\\im\\omega) / \\pi$ over $\\omega$.\n%\n%We see in the magnitude plot that, lower frequencies ($\\omega<1$) can pass,\n%while higher frequencies $\\omega>3$ are attenuated.\n%\n%The system characteristics is therefore called \\textbf{low-pass} filter or\n%\\textbf{high-cut} filter.\n\nIf we set up $\\omega=1$ in the frequency response\n\\begin{align}\nH(\\im(\\omega=1))\n= \\frac{1}{ (1 -\\frac{16}{25} (1)^2) + \\im (\\frac{24}{25} (1))}\n= \\frac{1}{ \\frac{9}{25} + \\im \\frac{24}{25}}\n= \\frac{\\frac{9}{25} - \\im \\frac{24}{25}}{ \\frac{81}{625} + \\frac{576}{625}}\n\\end{align}\nthe complex number $H(\\im(\\omega=1)) = \\frac{25}{73} - \\im \\frac{200}{219}$ results.\n%\nWe are already familiar with these numbers as they appeared somehow in task e), cf.\n$C$ and $D$ in \\eq{eq:coeffABCDsinLaplace}.\n%\nThe resulting magnitude and phase\n\\begin{equation}\n|H(\\im(\\omega=1))| = \\frac{25}{3 \\sqrt{73}}\n\\qquad\n\\angle H(\\im(\\omega=1)) = -\\tan^{-1}\n\\left[\\frac{\\nicefrac{200}{219}}{\\nicefrac{25}{73}}\\right]\n= -\\tan^{-1}\\left[\\frac{8}{3}\\right]\n\\end{equation}\nare precisely identical with \\eq{eq:steadystate_timedomain},\nproving that the shown concepts are consistent.\n%\nThus, evaluating the frequency response give us information about the steady\nstate of a system.\n%\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.75\\textwidth]{../laplace_transform/frequency_response_mag_phase}\n\\caption{Frequency response for the ODE with Laplace function\n$H(s) = \\left[ \\frac{16}{25} s^2 + \\frac{24}{25} s + 1 \\right]^{-1}$.}\n\\label{fig:frequency_response_mag_phase}\n\\end{figure}\n%##############################################################################\n%##############################################################################\n\\cleardoublepage\n\\subsection{Preliminaries for Inverse Laplace Transform Using Residue Theorem}\n\\label{sec:PrelimResidueTheorem}\n%\n%\nIn the previous section we calculated the inverse Laplace transform by using partial fraction decomposition and correspondence tables. In this subsection we want to find the solution using the complex integral.\nBefore we start, we have to remember stuff from math lectures, most of all from complex analysis.\n%\nWe might have a look into \\cite{Strang2007}, or its german translation \\cite{Strang2010}.\n%\nThe required math tools are summarised below, for which we follow \\cite{Fritzsche2019} and \\cite{UlrichWeber2017}.\n\n\\subsubsection{Isolated Singularity}\n\n\nMay $U \\subset \\mathbb{C}$ be open, $z_0 \\in U$ and $f : U \\setminus \\{z_0\\} \\rightarrow \\mathbb{C}$ holomorph. Then $z_0$ is named \\textbf{isolated singularity} of $f$, cf.~\\cite{Fritzsche2019}.\n\nTypes of isolated singularities, cf.~\\cite{Fritzsche2019}:\n\nMay $U \\subset \\mathbb{C}$ open and $f$ holomorph on $U$ besides an isolated singularity in point $z_0 \\in U$.\n\\begin{enumerate}\n\t\\item $z_0$ is a \\textbf{removable singularity} of $f$, if there is a holomorph function $g$ on $U$, so that $f(z)=g(z)$ for $z \\in U \\subset \\{z_0\\}$.\n\t\\item $z_0$ is a \\textbf{pole} of $f$, if there is a $k >= 1$, a neighbourhood $W = W(z_0) \\subset U$ and a holomorph function $g$ on $W$ with $g(z_0) \\neq $, so is:\n\t\\begin{equation}\n\t\tf(z)\\cdot(z-z_0)^k=g(z)\\quad \\textrm{for }z \\in W \\setminus \\{z_0\\}. \\nonumber\n\t\\end{equation}\n\tThe clear intended $k$ with this property is the pole order of $f$ in $z_0$.\n\t\\item $z_0$ is an \\textbf{essential singularity}, if it is neither a removable singularity nor a pole.\n\\end{enumerate}\n\\subsubsection{Laurent Series}\nA Laurent series is a series of the form, cf.~\\cite{Fritzsche2019},\n\\begin{align}\n\tf(z) = \\sum_{k=-\\infty}^{+\\infty}c_k\\cdot(z-z_0)^k.\n\\end{align}\n\n\\subsubsection{Residue}\nThe following definition and the connection with the Laurent series can be found in \\cite{Fritzsche2019} as well.\nMay $B \\subset \\mathbb{C}$ open, $z_0 \\in B, f: B \\setminus z_0 \\rightarrow \\mathbb{C}$ holomorph and $\\epsilon > 0$, so that it is $D_{\\epsilon}(z_0)\\subset\\subset \\mathbb{C}$. Then\n\\begin{align}\n\t\\mathrm{Res}(f(z),z_0):=\\frac{1}{2\\pi\\im}\\int_{\\partial D_{\\epsilon}(z_0)}f(\\xi)\\mathrm{d}\\xi\n\\end{align}\nis named residue of $f$ in $z_0$.\nThe coefficient $c_{-1}$ of the Laurent series of $f$ around $z_0$ is the residue of $f$ in $z_0$:\n\\begin{align}\n\t\\mathrm{Res}(f(z),z_0)=c_{-1}.\n\\end{align}\n\\subsubsection{Calculation of Residue}\nIf $z_0$ is a \\textbf{removable singularity}, then\n\\begin{align}\n\t\\mathrm{Res}(f(z),z_0)=0,\n\\end{align}\nbecause $c_k$ = 0 for $k<0$, cf.~\\cite{Fritzsche2019}.\n\n\\noindent Example:\n\\begin{align}\n\tf(z) &= \\frac{\\sin(z)}{z} \\nonumber \\\\\n\t\\lim\\limits_{z \\rightarrow 0}f(z) &= \\lim\\limits_{z \\rightarrow 0}\\frac{\\cos(z)}{1}=1 \\Rightarrow \\mathrm{Res}(f(z),0)=0 \\nonumber \\\\\n\t\\sin(z) &= z-\\frac{z^3}{3!}+\\frac{z^5}{5!}-+\\cdot\\cdot\\cdot\\quad \\quad \\textrm{cf.~\\cite{Bronstein}} \\nonumber \\\\\n\t\\frac{\\sin(z)}{z} &= 1 - \\frac{z^2}{3!}+\\frac{z^4}{5!}-+\\cdot\\cdot\\cdot \\nonumber \\\\\n\t&\\rightarrow \\quad \\mathrm{Res}(f(z),0)=c_{-1} = 0. \\nonumber\n\\end{align}\n\n\\noindent If $z_0$ is a \\textbf{pole of order m}, cf.~\\cite{Fritzsche2019}, it follows\n\\begin{align}\n\\label{eq:ResTheorem_pole_order_m}\n\t\\mathrm{Res}(f(z),z_0)=\\lim\\limits_{z \\rightarrow z_0}\\frac{1}{(m-1)!}\\frac{\\mathrm{d}^{m-1}}{\\mathrm{d} z^{m-1}}\\bigg [f(z)\\cdot (z-z_0)^m\\bigg ].\n\\end{align}\n\n\\noindent Example: The order 1 pole at 2\n\\begin{align}\n\tf(z) = \\frac{1}{z-2} \\nonumber\n\\end{align}\nleads to\n\\begin{align}\n\t\\mathrm{Res}(f(z),2)=\\lim\\limits_{z\\rightarrow 2}\\frac{1}{(1-1)!}\\frac{\\mathrm{d}^{1-1}}{\\mathrm{d}z^{1-1}}\\bigg [(z-2)\\cdot\\frac{1}{z-2}\\bigg ] = 1 \\nonumber\n\\end{align}\nAlternatively, we can have a look at its Laurent series expansion\n\\begin{align}\n\t\\frac{1}{z-2}=\\frac{1}{z-2}\\cdot\\frac{\\frac{1}{z}}{\\frac{1}{z}}=\\frac{1}{z}\\cdot\\frac{1}{1-\\frac{2}{z}} \\nonumber\n\\end{align}\nUsing the geometric series, cf.~\\cite{Bronstein}\n\\begin{align}\n\t\\sum_{k=0}^{+\\infty}q^k=\\frac{1}{1-q}\\quad\\quad|q| < 1 \\nonumber,\n\\end{align}\nwe can write our function as a series:\n\\begin{align}\n\tf(z)\\underset{|\\frac{2}{z}|<1}{=}\\frac{1}{z}\\cdot\\sum_{k=0}^{+\\infty}\\bigg (\\frac{2}{z}\\bigg )^k = \\sum_{k=0}^{+\\infty}\\frac{2^k}{z^{k+1}} = z^{-1}+2z^{-2}+4z^{-3}+\\cdot\\cdot\\cdot \\nonumber \\\\\n\t\\rightarrow \\mathrm{Res}(f(z),2)=c_{-1}=1. \\nonumber\n\\end{align}\n\n\\noindent If $z_0$ is an \\textbf{essential singularity}, we have to find the residue by\nLaurent series expansion.\n\n\\noindent Example:\n\\begin{align}\n\tf(z)=\\e^{\\frac{1}{z}} \\nonumber\n\\end{align}\n\\begin{align}\n\t\\e^z=1+z+\\frac{z^2}{2!}+\\frac{z^3}{3!}+\\frac{z^4}{4!}+\\cdot\\cdot\\cdot\\quad\\quad \\textrm{cf.~\\cite{Bronstein}} \\nonumber\n\\end{align}\nSubstituting $z$ with $\\frac{1}{z}$ results in\n\\begin{align}\n\tf(z)=z^{-1}+1+\\frac{z^1}{2!}+\\frac{z^2}{3!}+\\frac{z^3}{4!}+\\dots\\,. \\nonumber\n\\end{align}\n\\begin{align}\n\t\\rightarrow\\mathrm{Res}(f(z),0)=1 \\nonumber\n\\end{align}\n\\subsubsection{Residue Theorem}\nAgain, we utilize \\cite{Fritzsche2019} to give the definition.\nMay $G \\subset \\mathbb{C}$ a connected space, $D \\subset G$ finite, $\\gamma$ a closed curve in $G$ with $|\\gamma| \\cap D = \\emptyset$ and $f: G \\setminus D \\rightarrow \\mathbb{C}$ holomorph. Then\n\\begin{align}\n\t\\frac{1}{2\\pi\\im}\\int_{\\gamma}f(\\xi)\\mathrm{d}\\xi = \\sum_{z\\in D}n(\\gamma,z)\\mathrm{Res}(f(z),z).\n\\end{align}\nThis tells us, that we can calculate complex contour integrals\nby adding $\\mathrm{Res}(f(z),z_1$) to $\\mathrm{Res}(f(z),z_n)$ for all\nsurrounded isolated singularities $z_1$ to $z_n$. \\textbf{This is very important stuff.}\n%\nThe partial fraction decomposition is doing this in essence without bothering\nus too much with the theorem, but it is always a good idea to know where things\ncome from.\n\n\\subsubsection{Inverse Laplace Transform Using Residue Theorem}\nThe inverse Laplace transform is defined as, cf.~\\cite{UlrichWeber2017},\n\\begin{align}\n\\mathcal{L}^{-1}[F(s)]:=\\frac{1}{2\\pi\\im}\\int_{\\sigma-\\im\\infty}^{\\sigma+\\im\\infty}F(s)\\e^{st}\\mathrm{d}s\\quad\\quad \\sigma \\geq \\underset{s \\in \\mathrm{ROC} \\{ F(s) \\} }{\\min}\\big \\{ \\Re \\{ s \\} \\big \\}.\n\\end{align}\n%\nWe choose a curve $C = C_1 + C_2$, where $C_1$ is a curve parallel to the imaginary axes through $\\sigma$ from $\\sigma -\\im\\omega_0$ to $\\sigma + \\im\\omega_0$ and $C_2$ a part of a circle with radius $R$ and with center at $0$ from $\\sigma +\\im\\omega_0$ to $\\sigma - \\im\\omega_0$, cf.~\\cite{UlrichWeber2017}.\nAccording to \\cite[Fig.~3.5]{UlrichWeber2017}, the curves in parameter form are\n\\begin{align}\n\t&C_1:\\quad s = \\sigma+\\im x \\quad x \\in [-\\omega_0,\\omega_0] \\\\\n\t&C_2:\\quad s = \\underbrace{\\sqrt{\\omega_0^2+\\sigma^2}}_R \\e^{\\im x} \\quad x \\in [\\arctan\\bigg (\\frac{\\omega_0}{\\sigma}\\bigg ) ,2\\pi-\\arctan\\bigg ( \\frac{\\omega_0}{\\sigma}\\bigg ) ].\n\\end{align}\n%\nIf $\\omega_0$ is chosen large enough, the complex integral $\\oint_CY(s)\\e^{st}\\mathrm{d}s$ surrounds all isolated singularities $z_1$ to $z_n$ of $Y(s)$ and we can use the residue theorem, cf.~\\cite{UlrichWeber2017}:\n\\begin{align}\n\t\\frac{1}{2\\pi\\im}\\oint_C F(s)\\e^{st}\\mathrm{d}s=\\underbrace{\\frac{1}{2\\pi\\im}\\int_{\\sigma-\\im\\omega_0}^{\\sigma+\\im\\omega_0}F(s)\\e^{st}\\mathrm{d}s}_{A}+\\underbrace{\\frac{1}{2\\pi\\im}\\int_{C_2}F(s)\\e^{st}\\mathrm{d}s}_{B}=\\sum_{k=1}^{n}\\mathrm{Res}(F(s)\\e^{st},z_n).\n\\end{align}\n%\nIf we let $\\omega_0\\rightarrow\\infty$, then also $R\\rightarrow\\infty$ and it can be shown, that $B \\rightarrow 0$ for $R\\rightarrow \\infty$, cf.~\\cite{UlrichWeber2017}.\n%\nFinally, we get\n\\begin{align}\n\\label{eq:InvLaplace2ResidueTheorem}\n\t\\frac{1}{2\\pi\\im}\\oint_C F(s)\\e^{st}\\mathrm{d}s\\underset{\\omega_0\\rightarrow\\infty}{=}\\frac{1}{2\\pi\\im}\\int_{\\sigma-\\im\\infty}^{\\sigma+\\im\\infty}F(s)\\e^{st}\\mathrm{d}s=\\mathcal{L}^{-1}[F(s)]=\\sum_{k=1}^{n}\\mathrm{Res}(F(s)\\e^{st},z_k).\n\\end{align}\n\\subsubsection{Simple Example for Inverse Laplace Transform Using Residue Theorem}\nLet us consider a pole with order 2 at position $(0,0)$\n\\begin{align}\n\tF(s)=\\frac{1}{s^2},\n\\end{align}\nwhich is the only singularity of $F(s)$.\n%\nWe aim at causal time signals, thus region of convergence $\\Re\\{s\\} > 0$.\n%\nThen with \\eqref{eq:ResTheorem_pole_order_m}\n\\begin{align}\n\t\\mathrm{Res}(F(s)\\e^{st},0)=\\lim\\limits_{s\\rightarrow0}\\frac{1}{(2-1)!}\\cdot\\frac{\\mathrm{d}}{\\mathrm{d}s}\\frac{\\e^{st}\\cdot s^2}{s^2}=\\lim\\limits_{s\\rightarrow0}t\\e^{st}=t \\epsilon(t)\n\\end{align}\nWe achieve\n\\begin{align}\n\ty(t)=\\mathcal{L}^{-1}[Y(s)]=t \\epsilon(t).\n\\end{align}\nFeel free to check the solution in a correspondence table.\n\\pagebreak\n\\subsection{Solutions Using Residue Theorem}\n\\label{sec:ResidueTheorem}\n\\subsubsection{Task a) Inverse Laplace Transform with Residue Theorem}\nWe shall find the inverse Laplace transform of\n\\begin{align}\n\tY(s)=\\frac{\\frac{25}{16}}{s^2+\\frac{24}{16}s+\\frac{25}{16}}\n\\quad \\text{ROC}: \\Re(s) > -\\frac{3}{4}\n\t. \\nonumber\n\\end{align}\nFirst, we want to find all singularities $s_i$.\n\\begin{align}\n\tY(s)=\\frac{25}{16}\\cdot\\frac{1}{s^2+\\frac{24}{16}s+\\frac{25}{16}}=\\frac{25}{16}\\cdot \\frac{1}{(s-(-\\frac{3}{4}+\\im))\\cdot(s-(-\\frac{3}{4}-\\im))}\n\\end{align}\nRecall from \\eqref{eq:InvLaplace2ResidueTheorem}, that\n\\begin{align}\n\t\\mathcal{L}^{-1}\\bigg [Y(s)\\bigg ] = \\sum_{i=1}^{n}\\mathrm{Res}(Y(s)\\e^{st},s_i). \\nonumber\n\\end{align}\nUtilizing \\eqref{eq:ResTheorem_pole_order_m}, we get\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\cdot\\e^{st},-\\frac{3}{4}+\\im)=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}+\\im}Y(s)\\e^{st}\\cdot(s-(-\\frac{3}{4}+\\im))=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}+\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{s-(-\\frac{3}{4}-\\im)}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im) t}}{2\\im} \\nonumber \\\\\n\t\\mathrm{Res}(Y(s)\\cdot\\e^{st},-\\frac{3}{4}-\\im)=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}-\\im}Y(s)\\e^{st}\\cdot(s-(-\\frac{3}{4}-\\im))=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}-\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{s-(-\\frac{3}{4}+\\im)}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im) t}}{-2\\im}\n\\end{align}\nWe add the residue to obtain the inverse Laplace transform as\n\\begin{align}\n\ty(t)=\\mathcal{L}^{-1}\\bigg [ Y(s) \\bigg ]= \\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{2\\im}+\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{-2\\im} = \\frac{25}{16}\\e^{-\\frac{3}{4}t}\\bigg (\\frac{1}{2\\im}\\e^{\\im t}-\\frac{1}{2\\im}\\e^{\\im t} \\bigg )=\\frac{25}{16}\\e^{-\\frac{3}{4}t}\\sin(t)\\quad t\\geq 0\n\\end{align}\n\n\\subsubsection{Task b) Inverse Laplace Transform with Residue Theorem}\nWe shall find the inverse Laplace transform of\n\\begin{align}\n\tY(s) = \\frac{1}{s}\\cdot \\frac{1}{\\frac{16}{25}s^+\\frac{24}{25}s+1}=\\frac{25}{16}\\cdot\\frac{1}{s}\\cdot\\frac{1}{s^2+\\frac{3}{2}s+\\frac{25}{16}}=\\frac{25}{16}\\cdot\\frac{1}{s\\cdot(s-(-\\frac{3}{4}+\\im))\\cdot(s-(-\\frac{3}{4}-\\im))}\n\\quad \\text{ROC}: \\Re(s) > 0\n\t. \\nonumber\n\\end{align}\nWe have to find the residue of $Y(s)\\e^{st}$ for $s_{i=1}=0, s_{i=2}=-\\frac{3}{4}+\\im$ and $s_{i=3}=-\\frac{3}{4}-\\im$.\n%\nTherefore:\n%\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\cdot\\e^{st},0)=\\lim\\limits_{s\\rightarrow 0}Y(s)\\cdot\\e^{st} (s-0)=\\lim\\limits_{s\\rightarrow0}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{s^2 +\\frac{3}{2}s+\\frac{25}{16}}=\\frac{25}{16}\\cdot\\frac{e^{0 \\cdot t}}{0^2+\\frac{3}{2}\\cdot0+\\frac{25}{16}}=\\frac{25}{16}\\cdot\\frac{16}{25}=1\n\\end{align}\n\n\\begin{align}\n&\t\\mathrm{Res}(Y(s)\\cdot\\e^{st},-\\frac{3}{4}+\\im)=\\lim\\limits_{s\\rightarrow -\\frac{3}{4}+\\im}Y(s)\\cdot\\e^{st}(s-(-\\frac{3}{4}+\\im))=\\lim\\limits_{s\\rightarrow -\\frac{3}{4}+\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{s\\cdot(s-(-\\frac{3}{4}-\\im))} = \\nonumber \\\\\n&\t\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{(-\\frac{3}{4}+\\im)\\cdot(-\\frac{3}{4}+\\im+\\frac{3}{4}+\\im)}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{-2-\\frac{3}{2}\\im}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{-2-\\frac{3}{2}\\im}\\cdot\\frac{-2+\\frac{3}{2}\\im}{-2+\\frac{3}{2}\\im}=\\frac{25}{16}\\cdot\\e^{(-\\frac{3}{4}+\\im)t}\\cdot\\frac{-2+\\frac{3}{2}\\im}{2^2+\\big (\\frac{3}{2}\\big)^2}=\\nonumber \\\\\n&\t\\frac{25}{16}\\cdot\\e^{(-\\frac{3}{4}+\\im)t}\\cdot\\frac{-2+\\frac{3}{2}\\im}{\\frac{25}{4}}=\\frac{1}{4}\\e^{(-\\frac{3}{4}+\\im)t}(-2+\\frac{3}{2}\\im)\n\\end{align}\n\n\\begin{align}\n&\t\\mathrm{Res}(Y(s)\\cdot\\e^{st},-\\frac{3}{4}-\\im)=\\lim\\limits_{s\\rightarrow -\\frac{3}{4}-\\im}Y(s)\\cdot\\e^{st}(s-(-\\frac{3}{4}-\\im))=\\lim\\limits_{s\\rightarrow -\\frac{3}{4}-\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{s\\cdot(s-(-\\frac{3}{4}+\\im))} = \\nonumber \\\\\n& \\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{(-\\frac{3}{4}-\\im)\\cdot(-\\frac{3}{4}-\\im+\\frac{3}{4}-\\im)}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{-2+\\frac{3}{2}\\im}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{-2+\\frac{3}{2}\\im}\\cdot\\frac{-2-\\frac{3}{2}\\im}{-2-\\frac{3}{2}\\im}=\\frac{25}{16}\\cdot\\e^{(-\\frac{3}{4}-\\im)t}\\cdot\\frac{-2-\\frac{3}{2}\\im}{2^2+\\big (\\frac{3}{2}\\big)^2}=\\nonumber \\\\\n& \\frac{25}{16}\\cdot\\e^{(-\\frac{3}{4}-\\im)t}\\cdot\\frac{-2-\\frac{3}{2}\\im}{\\frac{25}{4}}=\\frac{1}{4}\\e^{(-\\frac{3}{4}-\\im)t}(-2-\\frac{3}{2}\\im)\n\\end{align}\nWe have to add the three residue to get the inverse Laplace transform as\n\\begin{align}\n\ty(t) = \\mathcal{L}^{-1}\\bigg [Y(s) \\bigg]&=1+\\frac{1}{4}\\e^{(-\\frac{3}{4}+\\im)t}(-2+\\frac{3}{2}\\im)+\\frac{1}{4}\\e^{(-\\frac{3}{4}-\\im)t}(-2-\\frac{3}{2}\\im)\\nonumber \\\\\n\t&=1+\\frac{1}{4}\\e^{-\\frac{3}{4}t}\\bigg (-2\\e^{+\\im t}-2\\e^{-\\im t}-\\frac{3}{2\\im}\\e^{+\\im t}+\\frac{3}{2\\im}\\e^{-\\im t}\\bigg )\\nonumber \\\\\n\t&= 1+\\frac{1}{4}\\e^{-\\frac{3}{4}t}\\Bigg [-\\frac{4}{2}\\bigg (\\e^{+\\im t}+\\e^{-\\im t}\\bigg )-\\frac{3}{2\\im}\\bigg (\\e^{+\\im t}-\\e^{-\\im t} \\bigg )\\Bigg ] \\nonumber \\\\\n\t&=1-\\e^{-\\frac{3}{4}t}\\Bigg [\\cos(t)+\\frac{3}{4}\\sin(t) \\Bigg ] \\quad t \\geq 0\n\\end{align}\n\\subsubsection{Task c) Inverse Laplace Transform with Residue Theorem}\nWe shall find the inverse Laplace transform for\n\\begin{align}\n\tY(s) = \\frac{\\frac{16}{25}s+\\frac{56}{25}}{\\frac{16}{25}s^2+\\frac{24}{25}s+1}\n\\quad \\text{ROC}: \\Re(s) > -\\frac{3}{4}\n\t.\n\\end{align}\nThe singularities are again $s_{i=1}=-\\frac{3}{4}+\\im$ and $s_{i=2}=-\\frac{3}{4}-\\im$.\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},-\\frac{3}{4}+\\im)&=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}+\\im}Y(s)\\e^{st}(s-(-\\frac{3}{4}+\\im))=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}+\\im}\\frac{s+\\frac{7}{2}}{(s-(-\\frac{3}{4}-\\im))}\\e^{st}\\nonumber \\\\\n\t&=\\e^{(-\\frac{3}{4}+\\im)t}\\frac{-\\frac{3}{4}+\\im+\\frac{7}{2}}{-\\frac{3}{4}+\\im-(-\\frac{3}{4}-\\im)}=\\frac{\\frac{11}{4}+\\im}{2\\im}\\e^{(-\\frac{3}{4}+\\im)t}\n\\end{align}\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},-\\frac{3}{4}-\\im)&=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}-\\im}Y(s)\\e^{st}(s-(-\\frac{3}{4}-\\im))=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}-\\im}\\frac{s+\\frac{7}{2}}{(s-(-\\frac{3}{4}+\\im))}\\e^{st}\\nonumber \\\\\n\t&=\\e^{(-\\frac{3}{4}-\\im)t}\\frac{-\\frac{3}{4}-\\im+\\frac{7}{2}}{-\\frac{3}{4}-\\im-(-\\frac{3}{4}+\\im)}=-\\frac{\\frac{11}{4}-\\im}{2\\im}\\e^{(-\\frac{3}{4}-\\im)t}\n\\end{align}\nTo obtain the inverse Laplace transform, we have to add both residue\n\\begin{align}\n\ty(t)=\\mathcal{L}^{-1}\\bigg [Y(s)\\bigg]&=\\frac{\\frac{11}{4}+\\im}{2\\im}\\e^{(-\\frac{3}{4}+\\im)t}-\\frac{\\frac{11}{4}-\\im}{2\\im}\\e^{(-\\frac{3}{4}-\\im)t}\\nonumber \\\\\n\t&=\\e^{-\\frac{3}{4}t}\\Bigg [\\frac{1}{2}\\bigg (\\e^{+\\im t}+\\e^{-\\im} \\bigg )+\\frac{11}{4}\\cdot\\frac{1}{2\\im}\\bigg (\\e^{+\\im t}-\\e^{-\\im t} \\bigg )\\Bigg ]\\nonumber \\\\\n\t&= \\e^{-\\frac{3}{4}t}\\Bigg [\\cos(t)+\\frac{11}{4}\\sin(t)\\Bigg ] \\quad t \\geq 0\n\\end{align}\n\\subsubsection{Task d) Inverse Laplace Transform with Residue Theorem}\nWe shall find the inverse Laplace transform for\n\\begin{align}\n\tY(s) = \\frac{\\frac{1}{s}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}+\n\t\\frac{\\frac{16}{25} s + \\frac{56}{25}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > 0\n\t.\n\\end{align}\nThis is a superposition of task b) and task c). Thus, we can add the residue of task b) and task c) to yield the inverse Laplace transform as\n\\begin{align}\n\ty(t) = \\mathcal{L}^{-1}\\bigg [Y(s)\\bigg] &= 1 + \\frac{1}{4}\\e^{(-\\frac{3}{4}+\\im)t}(-2+\\frac{3}{2}\\im) + \\frac{1}{4}\\e^{(-\\frac{3}{4}-\\im)t}(-2-\\frac{3}{2}\\im) + \\frac{\\frac{11}{4}+\\im}{2\\im}\\e^{(-\\frac{3}{4}+\\im)t} - \\frac{\\frac{11}{4}-\\im}{2\\im}\\e^{(-\\frac{3}{4}-\\im)t} \\nonumber \\\\\n\t&= 1 + \\e^{-\\frac{3}{4}t}\\Bigg [\\e^{+\\im t}\\bigg (-\\frac{1}{2}-\\frac{3}{8\\im} +\\frac{11}{8\\im}+\\frac{1}{2}\\bigg ) + \\e^{-\\im t} \\bigg (-\\frac{1}{2}+\\frac{3}{8\\im} -\\frac{11}{8\\im}+\\frac{1}{2} \\bigg ) \\Bigg ] \\nonumber \\\\\n\t&= 1 + \\e^{-\\frac{3}{4}t}\\Bigg [\\frac{8}{8}\\cdot\\frac{2}{2\\im}\\e^{+\\im t}-\\frac{8}{8}\\cdot\\frac{2}{2\\im}\\e^{-\\im t} \\Bigg ] \\nonumber \\\\\n\t&= 1 + 2\\e^{-\\frac{3}{4}t}\\sin(t) \\quad t \\geq 0.\n\\end{align}\n\\subsubsection{Task e) Inverse Laplace Transform with Residue Theorem}\nWe shall find the inverse Laplace transform for\n\\begin{align}\n\tY(s) = \\frac{\\frac{1}{s^2 + 1^2}}{\\frac{16}{25} s^2 + \\frac{24}{25} s + 1}\n\\quad \\text{ROC}: \\Re(s) > 0\n\t.\n\\end{align}\nHere, we deal with the four singularities\n$s_{i=1}=+\\im$, $s_{i=2}=-\\im$, $s_{i=3}=-\\frac{3}{4}+\\im$ and $s_{i=4}=-\\frac{3}{4}-\\im$\n\\begin{align}\n\tY(s) = \\frac{1}{s^2+1^2}\\cdot\\frac{1}{\\frac{16}{25}s^2+\\frac{24}{25}s+1}=\\frac{25}{16}\\cdot\\frac{1}{(s-\\im)\\cdot(s+\\im)\\cdot(s-(-\\frac{3}{4}+\\im))\\cdot(s-(-\\frac{3}{4}-\\im))}\n\\end{align}\nTherefore the individual residue are\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},+\\im)&=\\lim\\limits_{s\\rightarrow+\\im}Y(s)\\e^{st}(s-\\im)=\\lim\\limits_{s\\rightarrow +\\im} \\frac{25}{16}\\cdot\\frac{\\e^{st}}{(s+\\im)\\cdot(s-(-\\frac{3}{4}+\\im))\\cdot(s-(-\\frac{3}{4}-\\im))} \\nonumber \\\\\n\t&= \\frac{25}{16}\\cdot\\frac{\\e^{+\\im t}}{(\\im+\\im)\\cdot(\\im-(-\\frac{3}{4}+\\im))\\cdot(\\im-(-\\frac{3}{4}-\\im))}= \\frac{25}{16}\\cdot \\frac{\\e^{+\\im t}}{2\\im\\cdot\\frac{3}{4}\\cdot(2\\im+\\frac{3}{4})} \\nonumber \\\\\n\t&=\\frac{25}{16}\\cdot\\frac{\\e^{+\\im t}}{-3+\\frac{9}{8}\\im}\\cdot\\frac{-3-\\frac{9}{8}\\im}{-3-\\frac{9}{8}\\im}=\\frac{25}{16}\\e^{+\\im t}\\frac{-3-\\frac{9}{8}\\im}{\\frac{657}{64}}=\\frac{100}{657}\\e^{+\\im t}(-3-\\frac{9}{8}\\im)\n\\end{align}\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},-\\im)&=\\lim\\limits_{s\\rightarrow-\\im}Y(s)\\e^{st}(s+\\im)=\\lim\\limits_{s\\rightarrow -\\im} \\frac{25}{16}\\cdot\\frac{\\e^{st}}{(s-\\im)\\cdot(s-(-\\frac{3}{4}+\\im))\\cdot(s-(-\\frac{3}{4}-\\im))} \\nonumber \\\\\n\t&= \\frac{25}{16}\\cdot\\frac{\\e^{-\\im t}}{(-\\im-\\im)\\cdot(-\\im-(-\\frac{3}{4}+\\im))\\cdot(-\\im-(-\\frac{3}{4}-\\im))}= \\frac{25}{16}\\cdot \\frac{\\e^{-\\im t}}{-2\\im\\cdot\\frac{3}{4}\\cdot(-2\\im+\\frac{3}{4})} \\nonumber \\\\\n\t&=\\frac{25}{16}\\cdot\\frac{\\e^{-\\im t}}{-3-\\frac{9}{8}\\im}\\cdot\\frac{-3+\\frac{9}{8}\\im}{-3+\\frac{9}{8}\\im}=\\frac{25}{16}\\e^{-\\im t}\\frac{-3+\\frac{9}{8}\\im}{\\frac{657}{64}}=\\frac{100}{657}\\e^{-\\im t}(-3+\\frac{9}{8}\\im)\n\\end{align}\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},-\\frac{3}{4}+\\im)&=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}+\\im}Y(s)\\e^{st}(s-(-\\frac{3}{4}+\\im))=\\lim\\limits_{s \\rightarrow -\\frac{3}{4}+\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{(s+\\im)\\cdot(s-\\im)\\cdot(s-(-\\frac{3}{4}-\\im))} \\nonumber \\\\\n\t&= \\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{(-\\frac{3}{4}+\\im+\\im)\\cdot(-\\frac{3}{4}+\\im-\\im)\\cdot(-\\frac{3}{4}+\\im-(-\\frac{3}{4}-\\im))}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{(-\\frac{3}{4}+2\\im)\\cdot(-\\frac{3}{4})\\cdot2\\im} \\nonumber \\\\\n\t&=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}+\\im)t}}{3+\\frac{9}{8}\\im}\\cdot\\frac{3-\\frac{9}{8}\\im}{3-\\frac{9}{8}\\im}=\\frac{25}{16}\\e^{(-\\frac{3}{4}+\\im)t}\\frac{3-\\frac{9}{8}\\im}{\\frac{657}{64}}= \\frac{100}{657}\\e^{(-\\frac{3}{4}+\\im)t}(3-\\frac{9}{8}\\im)\n\\end{align}\n\\begin{align}\n\t\\mathrm{Res}(Y(s)\\e^{st},-\\frac{3}{4}-\\im)&=\\lim\\limits_{s\\rightarrow-\\frac{3}{4}-\\im}Y(s)\\e^{st}(s-(-\\frac{3}{4}-\\im))=\\lim\\limits_{s \\rightarrow -\\frac{3}{4}-\\im}\\frac{25}{16}\\cdot\\frac{\\e^{st}}{(s+\\im)\\cdot(s-\\im)\\cdot(s-(-\\frac{3}{4}+\\im))} \\nonumber \\\\\n\t&= \\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{(-\\frac{3}{4}-\\im+\\im)\\cdot(-\\frac{3}{4}-\\im-\\im)\\cdot(-\\frac{3}{4}-\\im-(-\\frac{3}{4}+\\im))}=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{-\\frac{3}{4}\\cdot(-\\frac{3}{4}-2\\im)\\cdot(-2\\im)} \\nonumber \\\\\n\t&=\\frac{25}{16}\\cdot\\frac{\\e^{(-\\frac{3}{4}-\\im)t}}{3-\\frac{9}{8}\\im}\\cdot\\frac{3+\\frac{9}{8}\\im}{3+\\frac{9}{8}\\im}=\\frac{25}{16}\\e^{(-\\frac{3}{4}-\\im)t}\\frac{3+\\frac{9}{8}\\im}{\\frac{657}{64}}= \\frac{100}{657}\\e^{(-\\frac{3}{4}-\\im)t}(3+\\frac{9}{8}\\im)\n\\end{align}\nAdding all residue leads to the inverse Laplace transform\n\\begin{align}\n\ty(t) = \\mathcal{L}^{-1}\\bigg [Y(s)\\bigg ] &= \\frac{100}{657}\\e^{+\\im t}(-3-\\frac{9}{8}\\im)+\\frac{100}{657}\\e^{-\\im t}(-3+\\frac{9}{8}\\im)+\\frac{100}{657}\\e^{(-\\frac{3}{4}+\\im)t}(3-\\frac{9}{8}\\im)+\\frac{100}{657}\\e^{(-\\frac{3}{4}-\\im)t}(3+\\frac{9}{8}\\im)\\nonumber \\\\\n\t&=\\frac{100}{657}\\Bigg [-3\\cdot\\frac{2}{2}\\bigg (\\e^{+\\im t}+\\e^{-\\im t}\\bigg )+\\frac{9\\cdot 2}{8\\cdot2\\im}\\bigg (\\e^{+\\im t}-\\e^{-\\im t}\\bigg )\\Bigg ]\\nonumber \\\\\n\t&+\\frac{100}{657}\\cdot\\e^{-\\frac{3}{4}t}\\bigg [3\\cdot\\frac{2}{2}\\bigg (\\e^{+\\im t}+\\e^{-\\im t}\\bigg )+\\frac{9\\cdot2}{8\\cdot2\\im}\\bigg (\\e^{+\\im t}-\\e^{-\\im t}\\bigg )\\Bigg ]\\nonumber\\\\\n\t&=\\frac{100}{657}\\Bigg [-6\\cos(t)+\\frac{9}{4}\\sin(t)]+\\frac{100}{657}\\e^{-\\frac{3}{4}t}\\Bigg [6\\cos(t)+\\frac{9}{4}\\sin(t)\\Bigg ] \\nonumber \\\\\n\t&= -\\frac{200}{219}\\cos(t)+\\frac{25}{73}\\sin(t)+\\e^{-\\frac{3}{4}}\\Bigg [\\frac{200}{219}\\cos(t)+\\frac{25}{73}\\sin(t) \\Bigg ]\\quad t \\geq 0\n\\end{align}\nAll results are precisely identical with those derived by help of well known Laplace transform correspondences,\ncf. Section \\ref{sec:SolutionsUsingLaplaceTransform}.\n%##############################################################################\n%##############################################################################\n\\clearpage\n%##############################################################################\n%##############################################################################\n\\subsection{Particular Solution Using the Convolution Integral}\n\\label{sub:ConvSolutions}\n\\subsubsection{Introduction}\nAs mentioned on page~\\pageref{pg:sig_sys_ex_03AddOn:convolution}, we can calculate\nthe particular solution by convolving the inhomogeneous part with the impulse\nresponse of the LTI system (i.e. the Green's function of ODE).\n\n\\subsubsection{Task b) Convolution: Particular Solution with x(t) = Unit Step}\nThe general equation of the convolution is\n\\begin{equation}\n\ty(t) = x(t) \\ast h(t) =\n\t\\int\\limits_{-\\infty}^{\\infty}h(\\tau) \\, x(-\\tau+t)\\mathrm{d}\\tau=\n\t\\int\\limits_{-\\infty}^{\\infty}h(-\\tau+t)\\, x(\\tau)\\mathrm{d}\\tau.\n\\end{equation}\nThe impulse response\n\\begin{align}\nh(t)=\\frac{25}{16}\\e^{-\\frac{3}{4}t}\\sin(t) \\epsilon(t)\n\\end{align}\nconvolved with the Heaviside step function (with left / right limit definition\nwith respect to\ntime instance $t=0$)\n\\begin{equation}\n\\epsilon(t) =\n\\begin{cases}\n  0 & t\\leq 0-0\\\\\n  1 & t\\geq 0+0\n\\end{cases}\n\\end{equation}\nyields the \\textbf{step response}, as we know and derived already.\n%\nIt appears reasonable that we use the impulse response as the non-shifted signal, applying the variable substitution $t \\to \\tau$\n\\begin{align}\nh(\\tau\\geq 0) =& \\frac{25}{16} \\e^{-\\frac{3}{4} \\tau} \\sin(\\tau)\\\\\nh(\\tau < 0) =& 0\n\\end{align}\nand $x(-\\tau + t) = \\epsilon(-\\tau + t)$ as time-mirrored (variable $\\tau$) and shifted (variable $t$)\nsignal in the convolution.\n%\nThe product $x(-\\tau + t) h(\\tau) = \\epsilon(-\\tau + t) h(\\tau) = 0$ for $t<0$ (a little\nsketch is useful here). Thus, we don't have to consider it in the integral, i.e. $y_p(t<0)=0$.\n%\nWe can therefore adapt the limits to $\\int_0^\\infty$ and then the signal $\\epsilon(-\\tau + t)$\nis just a constant with value $1$.\n%\nSo, basically we need to calculate the specific convolution\n%\n\\begin{align}\n\ty_p = x(t) \\ast h(t) =\n\t\\int\\limits_{-\\infty}^{\\infty}h(\\tau)\\cdot x(t-\\tau)\\mathrm{d}\\tau\\rightarrow\n\ty_p(t \\geq 0) = \\frac{25}{16}\\int\\limits_{0}^{t} \\e^{-\\frac{3}{4}\\tau}\\sin(\\tau)\\mathrm{d}\\tau.\n\\end{align}\n%\nWe temporarily put $\\frac{25}{16}$ on the left side for convenience.\n%\n\\begin{align}\n\t\\frac{16}{25}\\cdot y_p &= \\int_0^t\\e^{-\\frac{3}{4}\\tau}\\cdot \\sin(\\tau)\\mathrm{d}\\tau\\nonumber \\\\\n\t&= \\e^{-\\frac{3}{4}\\tau}\\cdot \\sin(\\tau)\\cdot \\bigg (-\\frac{4}{3} \\bigg )\\bigg|_{\\tau=0}^{\\tau=t}-\\bigg (-\\frac{4}{3}\\bigg )\\int_0^t\\e^{-\\frac{3}{4}\\tau}\\cdot \\cos(\\tau)\\mathrm{d}\\tau \\quad\\text{(by partial integration)} \\nonumber \\\\\n\t&= -\\frac{4}{3}\\cdot \\e^{-\\frac{3}{4}t}\\sin(t)-\\Bigg (-\\frac{4}{3} \\bigg [\\e^{-\\frac{3}{4}\\tau}\\cdot \\cos(\\tau)\\cdot \\bigg (-\\frac{4}{3}\\bigg )\\bigg |_{\\tau=0}^{\\tau=t}-\\int_0^t \\frac{4}{3} \\cdot \\e^{-\\frac{3}{4}\\tau}\\cdot \\sin(\\tau)\\mathrm{d}\\tau\\bigg ] \\Bigg ) \\nonumber\n\\end{align}\n%\nAdding $\\frac{16}{9} \\int_0^t\\e^{-\\frac{3}{4}\\tau} \\sin(\\tau) \\mathrm{d}\\tau$ on both\nsides of the equation yields\n%\n\\begin{align}\n\t\\frac{25}{9}\\int_0^t\\e^{-\\frac{3}{4}\\tau}\\sin(\\tau)\\mathrm{d}\\tau=-\\frac{16}{9}\\e^{-\\frac{3}{4}t}\\cos(t)-\\frac{12}{9}\\e^{-\\frac{3}{4}t}\\sin(t)+\\frac{16}{9} \\nonumber\n\\end{align}\nand further\n\\begin{align}\n\t\\int_0^t\\e^{-\\frac{3}{4}\\tau}\\sin(\\tau)\\mathrm{d}\\tau=-\\frac{9}{25}\\frac{16}{9}\\e^{-\\frac{3}{4}t}\\cos(t)-\\frac{9}{25}\\frac{12}{9}\\e^{-\\frac{3}{4}t}\\sin(t)+\\frac{9}{25}\\frac{16}{9} \\nonumber\n\\end{align}\n%\nSince we know from above\n$\\frac{16}{25}\\cdot y_p = \\int_0^t\\e^{-\\frac{3}{4}\\tau} \\sin(\\tau)\\mathrm{d}\\tau\n\\quad\\rightarrow\\quad\ny_p = \\frac{25}{16} \\int_0^t\\e^{-\\frac{3}{4}\\tau} \\sin(\\tau)\\mathrm{d}\\tau$\nwe find that\n\\begin{align}\n\ty_p = \\frac{25}{16} \\int_0^t\\e^{-\\frac{3}{4}\\tau}\\sin(\\tau)\\mathrm{d}\\tau\n\t=-\\frac{25}{16}\\cdot\\frac{9}{25}\\cdot\\frac{16}{9}\\e^{-\\frac{3}{4}t}\\cos(t)-\\frac{25}{16}\\cdot\\frac{9}{25}\\cdot\\frac{12}{9}\\e^{-\\frac{3}{4}t}\\sin(t)+\\frac{25}{16}\\cdot\\frac{9}{25}\\cdot\\frac{16}{9} \\nonumber\n\\end{align}\nand finally\n\\begin{align}\n\\boxed{\n\ty_p(t)=1-\\e^{-\\frac{3}{4}t}\\left(\\frac{3}{4}\\,\\sin(t)+\\cos(t)\\right) \\qquad t \\geq 0.}\n\\end{align}\n%\nThis needs to be and is in fact the same result as in \\eq{eq:stepResponse} and \\eq{eq:stepResponse_Laplace}.\n\n\\subsubsection{Task e) Convolution: Particular Solution with x(t>0) = sin(t)}\n%\nIn this task the convolution of the impulse response with the sine signal\n\\begin{align}\nx(t \\geq 0) =& \\sin(t)\\\\\nx(t<0) =& 0\n\\end{align}\nshall be derived.\n%\nIt again appears reasonable that we use the impulse response as non-shifted signal\n\\begin{align}\nh(\\tau\\geq 0) =& \\frac{25}{16} \\e^{-\\frac{3}{4} \\tau} \\sin(\\tau)\\\\\nh(\\tau < 0) =& 0.\n\\end{align}\nand $x(-\\tau + t)$ as time-mirrored (variable $\\tau$) and shifted (variable $t$)\nsignal in the convolution.\n%\nWe can find, that the product $x(-\\tau + t) h(\\tau)= 0$ for $t<0$.\nThus, we don't have to consider it in the integral, i.e. $y_p(t<0)=0$.\n%\nThe convolution integral thus reads\n\\begin{align}\n\ty_p(t) =x(t) \\ast h(t) = \\int_{-\\infty}^{\\infty}x(-\\tau+t) h(\\tau)\\mathrm{d}\\tau=\n\t\\int_0^t \\e^{-\\frac{3}{4}\\tau}\\sin(\\tau)\\cdot\\sin(-\\tau+t)\\mathrm{d}\\tau \\nonumber\n\\end{align}\nThis looks more complicated than the convolution in Task b), but if we remember Euler identities\n\\begin{align}\n\t\\cos(x)=\\frac{1}{2}\\bigg (\\e^{\\im x}+\\e^{-\\im x} \\bigg ) \\qquad\n\t\\sin(x)=\\frac{1}{2\\im}\\bigg (\\e^{\\im x}-\\e^{-\\im x}\\bigg )\n\\end{align}\nwe can rewrite the sine-functions as exponential functions,\nwich are easier to integrate.\n%\nAgain, we put $\\frac{25}{16}$ on the left site, to make the equation more handy\n\\begin{align}\n\t\\label{eq:sinConvolutionA}\n\t\\frac{16}{25}\\cdot y_p(t)&=\\int_0^t \\e^{-\\frac{3}{4}\\tau}\\frac{1}{2\\im}\\bigg(\\e^{\\im\\tau}-\\e^{-\\im\\tau}\\bigg)\\frac{1}{2\\im}\\bigg(\\e^{\\im(t-\\tau)}-\\e^{-\\im(t-\\tau)}\\bigg)\\mathrm{d}\\tau \\nonumber \\\\\n\t&=\\frac{1}{4}\\int_t^0 \\e^{-\\frac{3}{4}\\tau}\\bigg(\\e^{\\im(\\cancel {\\tau-\\tau}+t)}-\\e^{\\im(\\tau-t+\\tau)}-\\e^{\\im(t-\\tau-\\tau)}+\\e^{\\im(\\cancel {\\tau-\\tau}-t)}\\bigg)\\mathrm{d}\\tau \\quad\\text{ note: limits reversal} \\nonumber \\\\\n\t&=\\frac{1}{4}\\int_t^0 \\left(\\e^{-\\frac{3}{4}\\tau +\\im t}-\\e^{(-\\frac{3}{4}+2\\im)\\tau-\\im t}-\\e^{(-\\frac{3}{4}-2\\im)\\tau+\\im t}+\\e^{-\\frac{3}{4}\\tau-\\im t}\\right)\\mathrm{d}\\tau \\nonumber \\\\\n\t&=\\frac{1}{4}\\bigg[-\\frac{4}{3}\\e^{-\\frac{3}{4}\\tau+\\im t}\\bigg|_t^0 -\\frac{1}{-\\frac{3}{4}+2\\im}\\e^{(-\\frac{3}{4}+2\\im)\\tau-\\im t}\\bigg |_t^0-\\frac{1}{-\\frac{3}{4}-2\\im}\\e^{(-\\frac{3}{4}-2\\im)\\tau+\\im t}\\bigg |_t^0-\\frac{4}{3}\\e^{-\\frac{3}{4}\\tau-\\im t}\\bigg |_t^0\\bigg ]\n\\end{align}\nNow, we make use of a very helpful rearrangement of the complex numbers\n\\begin{align}\n\t\\label{eq:helpfulCalculation}\n\t\\boxed{\\frac{1}{-\\frac{3}{4}+2\\im}=\\frac{1}{-\\frac{3}{4}+2\\im} \\cdot \\frac{-\\frac{3}{4}-2\\im}{-\\frac{3}{4}-2\\im}=\\frac{-\\frac{3}{4}-2\\im}{\\frac{9}{16}+\\frac{64}{16}}=\\frac{16\\cdot (-\\frac{3}{4}-2\\im)}{73}=\\frac{-12-32\\im}{73}}\n\\end{align}\nand (similarly)\n\\begin{align}\n\t\\label{eq:helpfulCalculationAnalog}\n\t\\boxed{\\frac{1}{-\\frac{3}{4}-2\\im}=\\frac{-12+32\\im}{73}}\n\\end{align}\nUsing \\eq{eq:helpfulCalculation} and \\eq{eq:helpfulCalculationAnalog} in \\eq{eq:sinConvolutionA} for the complex coefficients and calculating the boundaries leads to\n\\begin{align}\n\t&= \\frac{1}{3}\\e^{-\\frac{3}{4}t+\\im t}-\\frac{1}{3}\\e^{\\im t}-\\frac{-3-8\\im}{73}\\bigg (\\e^{-\\im t}-\\e^{(-\\frac{3}{4}+\\im)t}\\bigg )-\\frac{-3+8\\im}{73}\\bigg (e^{\\im t}-\\e^{(-\\frac{3}{4}-\\im)t}\\bigg )+\\frac{1}{3}\\e^{-\\frac{3}{4}t-\\im t}-\\frac{1}{3}\\e^{-\\im t} \\nonumber \\\\\n\t&=\\e^{-\\frac{3}{4}t}\\bigg (\\frac{1}{3}\\e^{+\\im t} -\\frac{3}{73}e^{+\\im t}-\\frac{8\\im}{73}\\e^{+\\im t}-\\frac{3}{73}e^{-\\im t}+\\frac{8\\im}{73}\\e^{-\\im t}+\\frac{1}{3}\\e^{-\\im t}\\bigg )\\nonumber \\\\\n\t&\\quad -\\frac{1}{3}\\e^{+\\im t}+\\frac{3}{73}\\e^{-\\im t}+\\frac{8\\im}{73}\\e^{-\\im t}+\\frac{3}{73}\\e^{+\\im t}-\\frac{8\\im}{73}\\e^{+\\im t}-\\frac{1}{3}\\e^{-\\im t} \\nonumber \\\\\n\t&=\\e^{-\\frac{3}{4}t}\\Bigg[\\frac{1}{2}\\cdot\\bigg (\\frac{2\\cdot(73-9)}{219}\\e^{+\\im t}+\\frac{2\\cdot(73-9)}{219}\\e^{-\\im t}\\bigg ) + \\frac{1}{2\\im} \\bigg (-\\frac{2\\im \\cdot 8 \\im}{73}\\e^{+\\im t}+\\frac{2\\im \\cdot 8 \\im}{73}\\e^{-\\im t} \\bigg ) \\Bigg ] \\nonumber \\\\\n\t&\\quad-\\frac{1}{2} \\bigg (\\frac{2\\cdot(73-9)}{73}\\e^{+\\im t}+\\frac{2\\cdot(73-9)}{73}\\e^{-\\im t} \\bigg ) +\\frac{1}{2\\im}\\bigg (-\\frac{2\\im\\cdot 8 \\im}{73}\\e^{+\\im t}+\\frac{2\\im\\cdot 8 \\im}{73}\\e^{-\\im t}\\bigg ) \\nonumber \\\\\n\t\\frac{16}{25}y_p(t)&=\\e^{-\\frac{3}{4}t}\\bigg (\\frac{128}{219}\\cos (t)+\\frac{16}{73}\\sin (t)\\bigg )-\\frac{128}{219}\\cos (t)+\\frac{16}{73}\\sin (t) \\quad \\Bigg | \\cdot \\frac{25}{16} \\nonumber\n\\end{align}\nand finally\n\\begin{align}\n\\boxed{\ny_p(t) = \\e^{-\\frac{3}{4}t}\\left(\\frac{200}{219}\\cos (t)+\\frac{25}{73}\\sin (t)\\right)-\\frac{200}{219}\\cos (t)+\\frac{25}{73}\\sin (t)\\qquad t\\geq 0.\n}\n\\end{align}\nAgain, our particular solution is the same as in sections \\ref{sec:TaskeWithFundamentalSystem} and \\ref{sec:task_e_Laplace}.\n\\\\\n\\\\\n\\\\\nFor the solutions of the differential equations with initial conditions, take a look at section \\ref{sec:SolutionsUsingFundameltalSystem}.\n%##############################################################################\n%##############################################################################\n\\newpage\n\\subsection*{Appendix A}\n\n%##############################################################################\n\\subsubsection*{Important Laplace Transform Pairs for Right-Sided Signals}\nThe Dirac Delta Impulse pair reads\n\\begin{align}\n\\boxed{\\delta(t) \\quad \\laplace \\quad 1 \\quad \\text{ROC}: \\mathbb{C}}\\,.\n\\end{align}\nThe Heaviside step function pair reads\n\\begin{align}\n\\boxed{\\epsilon(t) \\quad \\laplace \\quad \\frac{1}{s} \\quad \\text{ROC}: \\Re(s)>0}\\,.\n\\end{align}\nWith the modulation theorem\n\\begin{align}\n\\e^{s_0 t} x(t) \\quad \\laplace \\quad X(s-s_0) \\quad \\{s \\, | \\, s-\\Re(s_0) \\in \\text{ROC}(X)\\}.\n\\end{align}\nwe get (this notation conveniently indicates a pole at $s_0$)\n\\begin{align}\n\\boxed{\\e^{s_0 t} \\epsilon(t)\\quad \\laplace \\quad \\frac{1}{s-s_0} \\quad \\text{ROC}: \\Re(s)>\\Re(s_0)}\\,,\n\\end{align}\nand with changed sign (this notation conveniently represents right-sided,\ndamped signals for $\\Re(s_0)>0$ due to a pole at $-s_0$)\n\\begin{align}\n\\boxed{\\e^{-s_0 t} \\epsilon(t)\\quad \\laplace \\quad \\frac{1}{s+s_0} \\quad \\text{ROC}: \\Re(s)>\\Re(-s_0)}\\,.\n\\end{align}\n%\nFor the special case of $s_0 = \\im \\omega_0$, the addition of both versions\nyields\n\\begin{align}\n(\\e^{+\\im \\omega_0 t} + \\e^{-\\im \\omega_0 t})  \\epsilon(t)\\quad &\\laplace \\quad \\frac{1}{s-\\im \\omega_0} + \\frac{1}{s+\\im \\omega_0} \\quad \\text{ROC}: \\Re(s)>0\\\\\n(\\e^{+\\im \\omega_0 t} + \\e^{-\\im \\omega_0 t})  \\epsilon(t)\\quad &\\laplace \\quad \\frac{(s+\\im \\omega_0) + (s-\\im \\omega_0)}{(s-\\im \\omega_0)(s+\\im \\omega_0)}\\quad \\text{ROC}: \\Re(s)>0\\\\\n(\\e^{+\\im \\omega_0 t} + \\e^{-\\im \\omega_0 t})  \\epsilon(t)\\quad &\\laplace \\quad \\frac{2 s}{s^2 + \\omega_0^2}\\quad \\text{ROC}: \\Re(s)>0\n\\end{align}\n\\begin{align}\n\\boxed{\\cos(\\omega_0 t) \\epsilon(t)\\quad \\laplace \\quad \\frac{s}{s^2 + \\omega_0^2}\\quad \\text{ROC}: \\Re(s)>0}\\,,\n\\end{align}\nfor which the last is due to the Euler identity $\\cos(\\omega_0 t) = \\frac{1}{2} (\\e^{+\\im \\omega_0 t}+\\e^{-\\im \\omega_0 t})$.\n%\n\n\\noindent For $\\sin(\\omega_0 t) = \\frac{1}{2 \\im} (\\e^{+\\im \\omega_0 t}-\\e^{-\\im \\omega_0 t})$ a similar\nprocedure yields\n\\begin{align}\n\\boxed{\n\\sin(\\omega_0 t)\\epsilon(t)\\quad \\laplace \\quad \\frac{\\omega_0}{s^2 + \\omega_0^2} \\quad \\text{ROC}: \\Re(s)>0}\\,.\n\\end{align}\n%\nModulation theorem leads to (note that $s_0 \\in \\mathbb{C}$, we often encounter $s_0 > 0, \\in \\mathbb{R}$ in ODEs)\n\\begin{align}\n\\boxed{\\e^{-s_0 t} \\cos(\\omega_0) \\epsilon(t)\\quad \\laplace \\quad \\frac{(s+s_0)}{(s+s_0)^2 + \\omega_0^2}\\quad \\text{ROC}: \\Re(s)>\\Re(-s_0)}\\,,\n\\end{align}\nand\n\\begin{align}\n\\boxed{\\e^{-s_0 t} \\sin(\\omega_0) \\epsilon(t)\\quad \\laplace \\quad \\frac{\\omega_0}{(s+s_0)^2 + \\omega_0^2}\\quad \\text{ROC}: \\Re(s)>\\Re(-s_0)}\\,.\n\\end{align}\n\n\n%##############################################################################\n%##############################################################################\n\\newpage\n\\subsection*{Appendix B}\nTBD the big picture ODE 1st/2nd, cf. \\cite[p.117]{Strang2014}\n\n\\subsection*{Acknowledgement}\nThanks to Robert Hauser (\\url{https://github.com/robhau})\nfor adding the sections \\ref{sec:PrelimResidueTheorem}, \\ref{sec:ResidueTheorem} and\n\\ref{sub:ConvSolutions}.\n\n% \\bibliography{literatur}\n% \\end{document}\n", "meta": {"hexsha": "a03f1c4c107e37ebe40aa6b7ede1d6e34bd49fb4", "size": 97418, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tutorial_latex_deu/sig_sys_ex_03AddOn.tex", "max_stars_repo_name": "spatialaudio/signals-and-systems-exercises", "max_stars_repo_head_hexsha": "d1dbeb5bce74abbd211f6888186556cbe46869f2", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-20T10:01:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T17:48:25.000Z", "max_issues_repo_path": "tutorial_latex_deu/sig_sys_ex_03AddOn.tex", "max_issues_repo_name": "spatialaudio/signals-and-systems-exercises", "max_issues_repo_head_hexsha": "d1dbeb5bce74abbd211f6888186556cbe46869f2", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2021-06-23T19:36:40.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T15:39:48.000Z", "max_forks_repo_path": "tutorial_latex_deu/sig_sys_ex_03AddOn.tex", "max_forks_repo_name": "spatialaudio/signals-and-systems-exercises", "max_forks_repo_head_hexsha": "d1dbeb5bce74abbd211f6888186556cbe46869f2", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.7565366481, "max_line_length": 411, "alphanum_fraction": 0.6376029071, "num_tokens": 36191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.43877285234783914}}
{"text": "%!TEX root = ../../dissertation.tex\n\n\\section{Features and parameter values}\n\n\nWe describe some of the salient features of the model\nand the benchmark parameter values we use later on.\n\n\n\\subsection{Features}\n\n{\\textit Consumption frontier.\\/}\nThe resource constraints define a possibilities frontier for consumption.\nWe picture several examples in Figure \\ref{fig:consumption-frontier}\nwith $z_{1t} = z_{2t} = 1$.\nIn each case, we compute the maximum quantity\n$c_{1t}$ consistent with a given quantity $c_{2t}$,\nthe resource constraints (\\ref{eq:resource-a},\\ref{eq:resource-b}),\nand the Armington aggregators (\\ref{eq:armington-1},\\ref{eq:armington-2}).\nThe shape depends on the aggregator.\nWhen $\\omega = 1/2$, the two final goods are the same and the tradeoff is linear.\nWhen $\\omega \\neq 1/2$, the frontier is concave.\nThe degree of concavity depends on the elasticity of substitution $ 1/(1-\\sigma)$\nin the Armington aggregator.\n\n\nIn a competitive equilibrium, the slope of the consumption frontier\nis (minus) the relative price of consumption in the two countries, $p_{2t}/p_{1t} = e_t$,\nthe real exchange rate.\nFrom the figure, we can imagine variation in this price\nproduced either by moving along the frontier or by changing the frontier through\nmovements in the quantities of intermediate goods.\n\n{\\textit Marginal rates of substitution.\\/}\nCompetitive equilibria and Pareto optima equate agents' marginal rates of substitution.\nWith recursive preferences, the intertemporal marginal rate of substitution of agent $j$ is\n\\begin{eqnarray}\n    m_{jt+1} &=& \\beta \\left( \\frac{c_{jt+1}}{c_{jt}}\\right)^{\\rho-1}\n              \\left( \\frac{U_{jt+1}}{\\mu_{t}(U_{jt+1})} \\right)^{\\alpha-\\rho} .\n              \\label{eq:mrs}\n\\end{eqnarray}\nThe last term summarizes the impact of recursive preferences.\nIf $\\alpha=\\rho$, preferences are additive and the term disappears.\nOtherwise anything that affects future utility can play a role in the marginal rate\nof substitution, hence in allocations.\nFor example, a change in risk affects future utility which, in turn, alters optimal consumption allocations and market clearing prices.\nPersistence is critical here, because more persistent shocks have a larger\nimpact on future utility.\nThe discount factor $\\beta$ is similar:  the larger it is, the greater the weight on\nfuture utility and the greater the impact on the marginal rate of substitution.\n\nNote, too, the dynamics built into the recursive term.\nIts log is a risk adjustment plus white noise.\nThe log of the numerator is\n\\begin{eqnarray*}\n    \\log U_{jt+1} &=&  E_t (\\log U_{jt+1}) + \\big[\\log U_{jt+1} - E_t (\\log U_{jt+1})\\big] ,\n\\end{eqnarray*}\nthe mean plus a white noise innovation.\nThe log of the denominator is\n\\begin{eqnarray*}\n    \\log \\mu_t (U_{jt+1})\n            &=&\n            \\alpha^{-1} \\log E_t (e^{\\alpha \\log U_{jt+1}})   \\\\\n                        &=& E_t (\\log U_{jt+1}) +\n            \\alpha^{-1} \\big[ \\log E_t (e^{\\alpha \\log U_{jt+1}}) - E_t (\\alpha \\log U_{jt+1}) \\big] .\n%            \\underbrace{\\mbox{risk adjustment}}_{\\alpha \\mbox{Var}_{t} (\\log U_{t+1})/2}\n\\end{eqnarray*}\nThe term in square brackets is the entropy of $U_{jt+1}^\\alpha$ and is positive.\nWe multiply by $\\alpha$ to get what we term the risk adjustment, which is negative if $\\alpha$ is.\nThe difference then is the innovation minus the risk adjustment.\nThe innovation increases the volatility of the intertemporal marginal rate of substitution,\nwhich is the primary source of success in asset pricing\napplications.\n\nThe marginal rate of substitution (\\ref{eq:mrs}) is measured in units of agent $j$'s consumption good,\nwhose price is $p_{jt}$.\nWe refer to the relative price of the two consumption goods as the real exchange rate:\n$ e_t = p_{2t}/p_{1t} $.\nThe two marginal rates of substitution are then connected by\n$ m_{2t+1} = (e_{t+1}/e_t) m_{1t+1}$.\nWe'll derive this in the next section,\nbut it should be evident here that the dynamics of the exchange rate reflect the\nmarginal rates of substitution.\nIf the two marginal rates of substitution are close to white noise, as we suggested,\nthen the depreciation rate $e_{t+1}/e_t$ has the same property.\n\n\n{\\textit Productivity dynamics.\\/}\nOne way to think about our log productivity process (\\ref{eq:lom-z})\nis that their average is a martingale and their difference is stable.\nDenote half the sum and half the difference by\n\\begin{eqnarray*}\n    \\log \\bar{z} &=& (\\log z_1 + \\log z_2)/2 \\\\\n    \\log \\wh{z}  &=& (\\log z_1 - \\log z_2)/2  .\n\\end{eqnarray*}\nThen we can express the underlying productivities\nby $\\log z_1 = \\log \\bar{z} + \\log \\wh{z}$ and $\\log z_2 = \\log \\bar{z} - \\log \\wh{z} $.\nEquation (\\ref{eq:lom-z}) implies that half the sum,\n\\begin{eqnarray*}\n    \\log \\bar{z}_{t+1} &=& \\log g + \\log \\bar{z}_t + (v_t^{1/2} w_{1t+1} + v^{1/2} w_{2t+1})/2 ,\n\\end{eqnarray*}\nis a martingale with drift.\nThe difference,\n\\begin{eqnarray}\n    \\log \\wh{z}_{t+1}  &=& (1-2\\gamma) \\log \\wh{z}_t + (v_t^{1/2} w_{1t+1} - v^{1/2} w_{2t+1})/2 ,\n    \\label{eq:lom-zhat}\n\\end{eqnarray}\nis stable, which tells us $\\log z_{1t}$ and $\\log z_{2t}$ are cointegrated.\nGiven the linear homogeneity of the model, changes in $\\bar{z}$ affect consumption\nquantities proportionately, with no effect on their relative price, the exchange rate.\nChanges in relative productivity $\\wh{z}$, however,\naffect consumption quantities differentially and therefore affect the real exchange rate\nas well.\n\n{\\textit Pareto problems.\\/}\nWe compute competitive equilibria in this environment by finding\nPareto optimal allocations and their supporting prices.\n In a two-agent Pareto problem,\nwe maximize one agent's utility subject to\n(i)~the other agent getting at least some promised level of utility\n(the promise-keeping constraint)\nand (ii)~the productive capacity of the economy (the resource constraints and shocks).\nThe Lagrangian for this problem is\n\\begin{eqnarray*}\n \\mathcal{L} &=& U_{1t} + \\lambda_{t} (U_{2t} - \\overline{U}) + \\mbox{resource constraints and shocks} ,\n\\end{eqnarray*}\nwith $\\lambda_t$ the multiplier on the promise-keeping constraint.\nIf utility functions are strictly concave,\nthis is equivalent to traditional Mantel-Negishi maximization of their weighted average,\n\\begin{eqnarray*}\n    \\theta_{1t} U_{1t} + \\theta_{2t} U_{2t} ,\n\\end{eqnarray*}\nwith positive Pareto weights ($\\theta_{1t}, \\theta_{2t})$.\nEvidently $\\lambda_t$ in the previous problem plays the same role as $ \\theta_{2t}/\\theta_{1t}$.\nWe refer to $\\lambda_t$ as the Pareto weight,\nalthough in terms of the latter version we might call it the relative Pareto weight.\n\n\n{\\textit Transforming utility.\\/}\nWe find it convenient to use an hd1 time aggregator, but with additive preferences\n(the special case $\\rho = \\alpha$)\nit's more common to transform utility to\n$ {U}^{*}_{jt} = U_{jt}^\\rho/\\rho$.\nWith this transformation, equation (\\ref{eq:time-agg}) becomes\n\\begin{eqnarray}\n    {U}^{*}_{jt} &=& (1-\\beta) c_{jt}^\\rho/\\rho\n            + \\beta \\big[ E_t (U_{jt+1}^{* \\alpha/\\rho}) \\big]^{\\rho/\\alpha} .\n    \\label{eq:utility-additive}\n\\end{eqnarray}\nWhen $\\rho=\\alpha$ this takes the familiar additive form.\n\nThe transformation also changes the look of derivatives.\nWhen we represent preferences with $U_{jt}$, marginal utility is\n\\begin{eqnarray*}\n    \\partial U_{jt} /\\partial c_{jt} &=& U_{jt}^{1-\\rho} (1-\\beta) c_{jt}^{\\rho-1} .\n\\end{eqnarray*}\nWhen we use ${U}^*_{jt}$, marginal utility takes the simpler form\n\\begin{eqnarray*}\n    \\partial {U}^*_{jt} /\\partial c_{jt} &=&  (1-\\beta) c_{jt}^{\\rho-1} .\n\\end{eqnarray*}\nWe'll use this insight later on to simplify some of the expressions we get\nusing the hd1 form of the time aggregator.\nThis includes the Pareto weight, which is defined for a specific\nutility function.\n\n\n\\subsection{Parameter values}\n\nWe make only a modest effort to use realistic parameter values.\nThe goal instead is to highlight the effects of recursive preferences and\nstochastic volatility with parameter values in the ballpark of those used\nelsewhere in the literature.\nWe summarize these choices in Table \\ref{tab:benchmark}.\nThe time interval is one quarter.\n\n{\\textit Preferences.\\/}\nWe use $\\rho=-1$ (implying an IES of one-half)\nand $\\alpha = -9$ (implying risk aversion of 10).\nThe former is a common value in business cycle modeling; \\citet{Kydland1982-xy}, for example.\nThe latter is widely used in asset pricing; \\citet{Bansal2004-mb} is the standard reference.\nThe key feature of this configuration is that $\\alpha-\\rho < 0$.\nWe set $\\beta = 0.98$.\n\n\n{\\textit Technology.\\/}\nThe Armington aggregator plays a central role here,\nspecifically the elasticity of substitution $1/(1-\\sigma)$\nbetween foreign and domestic intermediate goods.\nA wide range of elasticities have been used in the literature.\nSome earlier work used elasticities greater than one.\n\\citet{Colacito2011-zp,Colacito2013-yq} and \\citet{Kollmann2015-sy} use an elasticity of one.\n\\citet[Section 3.2]{Heathcote2002-aw}, \\citet[Table 1]{Tretvoll2018-dj}, and \\citet[Table 3]{Tretvoll2015-lo} suggest\nsmaller values.\nWe start with an elasticity of one ($\\sigma = 0$),\nbut consider other values, particularly when we explore the interaction\nof the elasticity and the dynamics of the Pareto weight.\n\nGiven a choice of $\\sigma$, we set the share parameter $\\omega$ like this.\nFirst-order conditions equate prices to marginal products:\n\\begin{eqnarray*}\n    p_{1t} &=& c_{1t}^{1-\\sigma} (1-\\omega) a_{1t}^{\\sigma-1} \\\\\n    p_{2t} &=& c_{1t}^{1-\\sigma} \\omega b_{1t}^{\\sigma-1}\n\\end{eqnarray*}\nIn a symmetric steady state with import share $s_m = b_1/(a_1 + b_1)$\nand relative price $ p_{2t}/p_{1t} = 1$,\nthe ratio of these two equations implies\n\\begin{eqnarray}\n    \\left( \\frac{1-\\omega}{\\omega} \\right) &=& \\left( \\frac{1-s_m}{s_m} \\right)^{1-\\sigma} .\n    \\label{eq:share-calculation}\n\\end{eqnarray}\nWe set $s_m = 0.1$.  Given a value for $\\sigma$, the import share nails down $\\omega$.\nOne consequence of this calculation is that the parameter $\\omega$ approaches one-half\nas $\\sigma$ approaches one (and the elasticity of substitution approaches infinity).\n\n\n{\\textit Shocks.}\nThe mean growth rate is $\\log g = 0.004 $:  0.4\\% per quarter.\nThe number comes from \\citet[Table 4]{Tallarini2000-xx} and is estimated with US data.\nWe set the persistence parameter $\\gamma$ that governs productivity dynamics equal to 0.1,\nwhich implies an autocorrelation of $1-2\\gamma = 0.8$ for $\\log \\wh{z}$.\n\\citet[Table 5]{Rabanal2011-pm} estimate $\\gamma$ to be less\nthan 0.01, which implies significantly greater persistence.\nThe stochastic volatility process (\\ref{eq:lom-v}) is based on \\citet{Jurado2015-hy}\nas described in \\citet[Section 5.3]{Backus2015-yx}.\n", "meta": {"hexsha": "e2f42aa02208f129b7d0afcf25cdc46872e59d40", "size": 10670, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ms/sections/BCFL/calibration.tex", "max_stars_repo_name": "cc7768/Dissertation", "max_stars_repo_head_hexsha": "813210c2f92122bb0c05f6ad7f5a9ede04993781", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ms/sections/BCFL/calibration.tex", "max_issues_repo_name": "cc7768/Dissertation", "max_issues_repo_head_hexsha": "813210c2f92122bb0c05f6ad7f5a9ede04993781", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ms/sections/BCFL/calibration.tex", "max_forks_repo_name": "cc7768/Dissertation", "max_forks_repo_head_hexsha": "813210c2f92122bb0c05f6ad7f5a9ede04993781", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-12-31T22:54:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-03T18:48:22.000Z", "avg_line_length": 47.4222222222, "max_line_length": 135, "alphanum_fraction": 0.7239925023, "num_tokens": 3113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4387271747454298}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 05/10/21\n\nWe can summarize our characterization thus far by a set of equivalences. The following are equivalent:\n\\begin{itemize}\n\t\\item A finite field extension \\(K / F\\) is Galois\n\t\\item \\(\\left| \\textrm{Aut}(K / F) \\right| = [K:F]\\) \n\t\\item \\(K / F\\) is the splitting field of a separable polynomial over \\(F\\) \n\t\\item \\(K / F\\) is normal and separable\n\t\\item \\(F = K^{\\textrm{Aut}(K / F)}\\)\n\\end{itemize}\n\n\\section{Fundamental Theorem of Galois Theory}\n\\label{sec:fundamental_theorem_of_galois_theory}\n\n\\begin{thm}[Fundamental Theorem of Galois Theory]\n\tLet \\(K / F\\) be Galois and set \\(G:= \\textrm{Gal}(K / F)\\). Then there exists a bijection between the subfields \\(E\\subset K\\) with \\(F\\subset E\\) and the subgroups \\(H \\leq G\\) given by\n\\begin{align*}\n\tE \\mapsto \\textrm{Aut}(K / E)\\\\\n\tH \\mapsto K^{H}\n\\end{align*}\nand these maps are inverses of each other. Furthermore, this bijection has some additonal properties:\n\\begin{itemize}\n\t\\item If \\(E_1 \\leftrightarrow H_1\\) and \\(E_2 \\leftrightarrow H_2\\), then \\(E_1 \\subset E_2 \\iff H_2 \\leq H_1\\).\n\t\\item If \\(E \\leftrightarrow H\\), then \\([K:E] = \\left| H \\right| \\) and \\([E:F] = [G:H]\\).\n\t\\item \\(K / E\\) is always Galois for \\(F \\subset E \\subset  K\\).\n\t\\item \\(E / F\\) is Galois if and only if \\(H \\triangleleft G\\). In this case, \\(\\textrm{Gal}(E / F) \\cong G / H\\).\n\t\\item If \\(E_1 \\leftrightarrow H_1\\) and \\(E_2 \\leftrightarrow H_2\\), then \\(E_1 \\cap E_2 \\leftrightarrow \\langle H_1,H_2 \\rangle \\) and \\(E_1E_2 \\leftrightarrow H_1 \\cap H_2\\).\n\\end{itemize}\n\\end{thm}\nRemember that \\(H \\triangleleft G\\) is equivalent to \\(\\textrm{Aut}(K / E) \\triangleleft \\textrm{Aut}(K / F)\\). Also recaall that \\(\\langle H_1,H_2 \\rangle \\) is the smallest subgroup of \\(G\\) that contains \\(H_1,H_2\\), and \\(E_1E_2\\) is the smallest subfield of \\(K\\) containing \\(E_1,E_2\\). They are not necessarily equivalent!\n\n% Examples here\n\n% Proof here\n\n\\vspace{5mm}\n\n\\end{document}\n", "meta": {"hexsha": "d7f7fdbc3103e4250a48604eb400c4a833e75713", "size": 2382, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture28 - FundThmGalThry.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture28 - FundThmGalThry.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture28 - FundThmGalThry.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.7894736842, "max_line_length": 329, "alphanum_fraction": 0.6863979849, "num_tokens": 812, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4387271709408294}}
{"text": "\\subsection{NL* Execution}\n\\label{sec:nl-exec}\n\\begin{enumerate}\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c}\n            $T_1$              & $\\E$ \\\\\n            \\hline\\hline\n            *$\\E$\\footnotemark & 1    \\\\\n            \\hline\\hline\n            *b                 & 1    \\\\\n            *a                 & 0    \\\\\n          \\end{tabular}\n        \\end{minipage} \\footnotetext{Prime rows are indicated by a leading asterisk} \\quad\n        \\begin{minipage}{0.6\\textwidth}\n          The table is not closed, because $row(a) = 0$ but there is no $s \\in S$ such that $row(s) \\subseteq 0$ . $a$ will be promoted.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c}\n            $T_2$ & $\\E$ \\\\\n            \\hline\\hline\n            *$\\E$ & 1    \\\\\n            *a    & 0    \\\\\n            \\hline\\hline\n            *b    & 1    \\\\\n            *ab   & 0    \\\\\n            *aa   & 1    \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $T_2$ is not consistent: $row(a) \\sqsubseteq row(\\E)$ but $row(a \\cdot a) \\not\\sqsubseteq row(\\E \\cdot a)$. Column $a$ is going to be added because $T(a \\cdot a \\cdot \\E) \\neq row(\\E \\cdot a \\cdot \\E)$.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c |c}\n            $T_3$ & $\\E$ & a \\\\\n            \\hline\\hline\n            *$\\E$ & 1    & 0 \\\\\n            *a    & 0    & 1 \\\\\n            \\hline\\hline\n            *b    & 1    & 1 \\\\\n            *ab   & 0    & 0 \\\\\n            *aa   & 1    & 1 \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $T_3$ is not closed since $row(ab) = 00$ but $\\nexists x \\in S$ such that $x \\sqsubseteq row(ab)$\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c |c}\n            $T_4$ & $\\E$ & a \\\\\n            \\hline\\hline\n            *$\\E$ & 1    & 0 \\\\\n            *a    & 0    & 1 \\\\\n            *ab   & 0    & 0 \\\\\n            \\hline\\hline\n            b     & 1    & 1 \\\\\n            aa    & 1    & 1 \\\\\n            abb   & 1    & 1 \\\\\n            *aba  & 0    & 0 \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $T_4$ is not consistent: $row(ab) \\sqsubseteq row(a)$ but $row(ab \\cdot b) \\not\\sqsubseteq row(a \\cdot b)$. Column $b$ is going to be added because $T(ab \\cdot b \\cdot \\E) \\neq row(a \\cdot b \\cdot \\E)$.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c |c|c}\n            $T_5$ & $\\E$ & a & b \\\\\n            \\hline\\hline\n            *$\\E$ & 1    & 0 & 1 \\\\\n            *a    & 0    & 1 & 0 \\\\\n            *ab   & 0    & 0 & 1 \\\\\n            \\hline\\hline\n            b     & 1    & 1 & 1 \\\\\n            aa    & 1    & 1 & 1 \\\\\n            abb   & 1    & 1 & 1 \\\\\n            *aba  & 0    & 0 & 0 \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $T_5$ is not closed since $row(aba) = 000$ but $\\nexists x \\in S$ such that $x \\sqsubseteq row(aba)$.\\\\\n          $aba$ will be promoted.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\begin{tabular}{c||c |c|c}\n            $T_6$ & $\\E$ & a & b \\\\\n            \\hline\\hline\n            *$\\E$ & 1    & 0 & 1 \\\\\n            *a    & 0    & 1 & 0 \\\\\n            *ab   & 0    & 0 & 1 \\\\\n            *aba  & 0    & 0 & 0 \\\\\n            \\hline\\hline\n            b     & 1    & 1 & 1 \\\\\n            aa    & 1    & 1 & 1 \\\\\n            abb   & 1    & 1 & 1 \\\\\n            *abab & 0    & 0 & 0 \\\\\n            *abaa & 0    & 0 & 0 \\\\\n          \\end{tabular}\n        \\end{minipage}\\quad\n        \\begin{minipage}{0.6\\textwidth}\n          $T_6$ is closed and consistent.\\\\\n          The conjecture will be sent.\n        \\end{minipage}\n\n  \\item \\begin{minipage}{0.3\\textwidth}\n          \\input{sections/automata/NL_aut1.tex}\n        \\end{minipage}\\quad\\\\\n        \\begin{minipage}{1\\textwidth}\n          Construction of this automaton:\n          \\begin{enumerate}\n            \\item $Q = {101,010,001,000}$ which are the Prime rows in $S$;\n            \\item $Q_I = {101,001,000}$ which are all the rows that are covered by $row(\\E)$;\n            \\item $F = {101}$ which is the only prime row having a $1$ in the column of $\\E$;\n            \\item Transitions are more complicated to analyze, we will only describe those starting from the state $101$. We have $row(\\E) = 101$ and we have to calculate the transition when reading:\n                  \\begin{enumerate}\n                    \\item $a \\rightarrow row(\\E \\cdot a) = 010$ and the set of rows that are covered by $010$ is ${010, 000}$, so we draw two transitions labelled with $a$ from $101$ to $010$ and to $000$;\n                    \\item $b \\rightarrow row(\\E \\cdot b) = 111$ and the set of rows that are covered by $111$ is ${010, 000, 101, 001}$, so we draw four transitions labelled with $a$ from $101$ to $010$, $000$, $101$ and $001$.\n                  \\end{enumerate}\n          \\end{enumerate}\n          Moreover, this automaton recognizes precisely the language proposed by the Teacher, so the algorithm can stop.\n        \\end{minipage}\n\\end{enumerate}", "meta": {"hexsha": "bce3665df1f679346b28d2896b065601be51a9e1", "size": 5280, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/annexe/example/NL_example.tex", "max_stars_repo_name": "FissoreD/TER-M1-M1S2", "max_stars_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/sections/annexe/example/NL_example.tex", "max_issues_repo_name": "FissoreD/TER-M1-M1S2", "max_issues_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-21T17:29:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T17:29:10.000Z", "max_forks_repo_path": "report/sections/annexe/example/NL_example.tex", "max_forks_repo_name": "FissoreD/TER-M1-M1S2", "max_forks_repo_head_hexsha": "bfc624f83b2c6e69fe0be42e4a2bf29bbc72218f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.24, "max_line_length": 227, "alphanum_fraction": 0.4553030303, "num_tokens": 1776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4387271633316282}}
{"text": "As early as 1964, Goffman~\\cite{goffman64OnRelevanceAsAMeasure}, a\nmathematical information science pioneer \\cite{harmon08RememberingWG},\nnotes that the relevance of documents in a list has to depend on the\ndocuments preceding it.  More recently, work on\nMMR~\\cite{carbonell98MMR} was one of the first to formalize\ndiversification as a mathematical optimization criterion; MMR has\nproved one of the most popular diversity approaches.  Aside from this\nwork, two of the other notable works are~\\cite{yue081224Predicting},\nwhich formalizes a structured SVM loss function based on a set\ncovering objective, and~\\cite{wang09PortfolioTheory}, which borrows\nconcepts from portfolio theory in economics to treat result set\ndiversification as optimization of a risk minimization objective.  We\nnote that the results as derived in the last section formally motivates these and others somewhat ad-hoc diversification approaches and we discuss\nthese connections more deeply in the following sections.\n\n%\\subsection{MMR}\n%\n%The result in~\\eqref{eq:1call} is strikingly similar to MMR --- it\n%contains two terms, one for query similarity and the other for result\n%set diversification, where each term represents a similarity kernel\n%--- more specifically a \\emph{probability product kernel}\n%(PPK)~\\cite{prodprobkernel} that is an inner product of probability\n%vectors (or more generally, functions).  More formally, let\n%$\\vec{T}'$, $\\vec{T}_k$, and $\\vec{T}_{S_{k-1}^*}$ be respective topic\n%probability vectors $P(t'=t|\\vec{q})$, $P(t_k=t|s_k)$ and\n%$\\tilde{P}(t_k=t | S_{k-1}^*)$ with vector indices for each topic $t\n%\\in T$.  Then the similarity and diversity terms from~\\eqref{eq:1call}\n%can be respectively written as\n%\\begin{align}\n%%\\Sim_1(\\vec{q},s_k) = & \\hspace{-3mm}\n%\\sum_{t \\in T} P(t'=t|\\vec{q}) P(t_k=t|s_{k}) & \\; = \\; \\langle \\vec{T}',\\vec{T}_k \\rangle \\label{eq:sim_term} \\; \\mbox{and}\\\\\n%%\\Sim_2(s_k,S_{k-1}) = & \\hspace{-3mm}\n%\\sum_{t \\in T} P(t|\\vec{q}) P(t_k=t|s_k) \\tilde{P}(t | S_{k-1}^*) & \\; = \\; \\langle \\vec{T}_k, \\vec{T}_{S_{k-1}^*} \\rangle_{\\vec{T}'}. \\label{eq:div_term}\n%\\end{align}\n%Here, we let $\\langle \\cdot,\\cdot \\rangle$ denote an inner product of\n%two vectors and $\\langle \\cdot,\\cdot \\rangle_\\vec{v}$ a\n%\\emph{$\\vec{v}$-reweighted} inner product, defined as\n%in~\\eqref{eq:div_term}.\n%\n%While having similarity and diversity terms similar to MMR,\n%Exp-$1$-call@$k$ in~\\eqref{eq:1call} clearly differs from MMR:\n%\\begin{enumerate}\n%\\item While MMR's definition allows for any similarity function, not\n%just PPKs, we note that \\emph{equating words to subtopics}, popular\n%kernels like TF and TFIDF~\\cite{salton83Introduction} can be viewed\n%directly as PPKs if the TF and TFIDF vectors are $L_1$ normalized to\n%represent probability vectors.\n%\\item MMR uses a maximization term for\n%diversity, whereas optimization of Exp-$1$-call@$k$ instead calls for\n%a product (noisy-or) diversity term $\\tilde{P}(t | S_{k-1}^*)$.\n%We note that a noisy-or reduces to a max when the subtopic\n%probabilities are deterministic (0 or 1).\n%\\item While MMR proposes a $\\lambda$ term to explicitly\n%trade off the similarity and diversity terms, the greedy optimization\n%of Exp-$1$-call@$k$ in~\\eqref{eq:1call} yields no such trade-off term\n%(or alternately, an implicit $\\lambda=.5$).  Although it seems a tunable\n%$\\lambda$ is not needed for maximizing Exp-$1$-call@$k$, it may be\n%desirable when maximizing surrogate retrieval objectives (e.g., ranking\n%objectives).\n%\\item Optimizing Exp-$1$-call@$k$ introduces query-specific relevance into\n%the diversification term as shown\n%by the query topic ($\\vec{T}'$) reweighted\n%diversity function in~\\eqref{eq:div_term}.\n%\\end{enumerate}\n%\n%%To verify whether the differences between MMR and Exp-$1$-call@$k$\n%%matter empirically, we compare the two algorithms across a number of\n%%metrics on three diversity testbeds: the TREC 6-8 Interactive\n%%Track\\footnotemark[1] (17 queries) and 2009 and 2010 ClueWeb Diversity\n%%tasks of the TREC Web Track\\footnotemark[2] (50 queries each).  On\n%%these testbeds, we evaluate \\emph{mean subtopic\n%%recall@$k$}~\\cite{zhai03Beyond} (fraction of total annotated\n%%aspects/subtopics covered by a result set at rank $k$, averaged over\n%%queries), which is an appropriate loss function for the\n%%\\emph{set-level} metric~\\eqref{eq:setRelevance}~\\cite{chen06Less}.  We\n%%also evaluate a variety of more recent \\emph{rank-based} diversity evaluation\n%%metrics such as intent-aware expected reciprocal rank\n%%(ERR-IA@$k$)~\\cite{err-ia}, $\\alpha$-nDCG@$k$~\\cite{clarke08Novelty},\n%%and intent-aware mean average precision\n%%(MAP-IA)~\\cite{agrawal09diversifying}.\n%%\n%%We use MMR with $\\lambda = 0.5$ to match the equal weighting of\n%%similarity and diversity in Exp-$1$-call@$k$.  An\n%%LDA~\\cite{blei03Latent} topic model is trained on the top-100 OKAPI\n%%BM25~\\cite{bm25} results for each query (on its respective collection)\n%%and these subtopic distributions are used for the similarity and\n%%diversity kernels in both algorithms: for MMR we choose $\\Sim_1$ and\n%%$\\Sim_2$ kernels as in~\\eqref{eq:sim_term} --- effectively LDA\n%%variants of latent semantic indexing (LSI)~\\cite{deerwester90LSA}\n%%kernels; for Exp-$1$-call@$k$, we use the similarity and diversity\n%%kernels respectively defined in~\\eqref{eq:sim_term}\n%%and~\\eqref{eq:div_term}.  Both MMR and Exp-$1$-call@$k$ are used to\n%%rank the top-20 documents from the top-100 OKAPI BM25 results.\n%%\n%%Results in Table~\\ref{table:different_metrics} and\n%%Figure~\\ref{fig:mmr_vs_1call} show the performances of MMR and\n%%Exp-$1$-call@$k$ on the three diversity testbeds across various\n%%diversity measures; although there are minor performance differences,\n%%we note that these differences are not statistically significant\n%%w.r.t.\\ 95\\% confidence intervals.  Nonetheless, the results appear to\n%%indicate that the structural similarities in the use of MMR and the\n%%optimization of Exp-$1$-call@$k$ outweigh the differences in this\n%%evaluation.\n%\n\\subsection{Relations of Exp-$1$-call@$k$ and Other Diversification Approaches}\n\nRecent years have seen numerous proposals for diversification\napproaches and here we summarize the relationship between optimization\nof Exp-$1$-call@$k$ and representatives of these alternative\napproaches:\n\n\\subsubsection{Diversifying Search Results}\n\\cite{agrawal09diversifying} proposes a set-based objective function\nto answer ambiguous web queries in a setting where there exists a predefined taxonomy of information, and that both queries and documents\nmay belong to more than one category according to this taxonomy. The proposed set-based objective function aims at maximizing the probability that the average user finds at least one useful resulting document retrieved within the top $k$ results. Mathematically, this objective function (a.k.a., IA-Select) is defined below:\n\\begin{align}\n\tP(S|\\vec{q}) = \\sum_{c} P(c|\\vec{q}) \\left( 1 - \\prod_{s\\in S}(1-V(s| q, c))\\right) \n\\label{eq:diversifykObjectiveFunction}\n\\end{align}\nwhere $S$ is a set of documents, and $V(s|q, c)$ broadly defines the likelihood that a document $s$ satisfies the query $\\vec{q}$ given the taxonomy (or category) $c$ of the query and the document. Note first that we have slightly adapted notations in the above equation for consistency, and note also that the taxonomy of $c$ given the query and document is not learnt by some unsupervised model, but hand-crafted. \n\nNow we show that our expected 1-call@$k$ objective in Equation~\\eqref{eq:setRelevance} is equivalent to the objective function in Equation \\eqref{eq:diversifykObjectiveFunction} by simply writing out the mathematical expectation in terms of the sum over all possible topics (e.g., taxomony in \\cite{agrawal09diversifying}) the weighted relevance where weights are the topic distributions below\n\\begin{align*}\n    \\ExpOneCall(S_k,\\vec{q}) & = \\mathbb{E} \\left[\\left. \\bigvee_{i=1}^{k}r_i=1 \\right| s_{1},\\dots, s_{k},\\vec{q} \\right], \\\\\n    \t\t\t\t\t\t\t\t\t\t\t\t & = \\sum_{t\\in T} P(t|\\vec{q}) \\left( 1 - \\prod_{i=1}^{k}(1-p(t_i = t| q, s_i))\\right) \n\\end{align*}\nClearly our proposed objective is equivalent to the objective Equation~\\eqref{eq:diversifykObjectiveFunction} proposed in \\cite{agrawal09diversifying} when one replaces the likelihood function $V(s|\\vec{q}, c)$ by $p(t_i = t| \\vec{q}, s_i)$. More recently, Vargas et al~\\cite{Vargas:SIGIR2012} propose variants of IA-Select by introducing several interesting formal probabilistic relevance models to instantiate $V(s| q, c)$, which are more appopriate in modeling the relevance in a probabilistic framework. Furthermore, \\cite{Vallet:SIGIR2012} propose to introduce a user as an explicit random variable in state of the art diversification methods, thus developing a generalized framework for personalized diversification.\n\nAnother recent interesting instantiation of $V(s|q,c)$ is proposed in \\cite{Zuccon:ECIR2012} motivated by the facilitation location problem~\\cite{Gonzalez:Handbook2007} taken from Operation Research: for a set of customer ``locations\" $D$, one aims at choosing a subset $S$ in $D$ to open $k$ ``facilities\" that optimize a graph-theoretic objective that depends on the cost of opening a facility at each location and also the distance between each pair of locations. However all of the three described methods do not derive their objective functions from the expected 1-call@$k$ objective as we have achieved. \n\n\\subsubsection{Portfolio Theory}\n\\cite{wang09PortfolioTheory} motivates\ndiversification in set-based information retrieval by a\nrisk-minimizing portfolio selection approach.  Viewing a result set as\nan investment portfolio with the objective to maximize return while\nminimizing risk, the derived result of~\\cite{wang09PortfolioTheory}\nmimics both MMR and Exp-$1$-call@$k$ in that the similarity term may\nbe viewed as \\emph{expected portfolio payoff} (relevance) and the\ndiversity term may be viewed as \\emph{expected portfolio risk}, which\nincreases as the correlations between documents in the result set\nincrease. Note that diversification based on portfolio theory is extended in \\cite{Shi:SIGIR2012} by introducing latent factors for collaborative filtering tasks. One major difference in the framework~\\cite{wang09PortfolioTheory} is that rather than\ncomputing the diversity term via a max (MMR) or product\n(Exp-$1$-call@$k$) the portfolio theory derivation uses a summation\n--- we examine the implications of this next.\n\n\\subsubsection{Set Covering:}\nYue and Joachims~\\cite{yue081224Predicting} propose a set covering\napproach for training SVMs to predict diverse result sets for\ninformation retrieval.  In their work, they equate subtopics with\nwords and build a loss function for SVM training that penalizes\nresult sets according to the sum of weights of query-relevant words\n\\emph{not} covered by the result set.  While their approach provides a\n``hard'' set-covering view of diversity, we note that an expansion of\n$\\tilde{P}(t | S_{k-1}^*)$ used in the diversity term\nof~\\eqref{eq:1call} provides a ``soft'' latent set-covering\ninterpretation; that is, $s_k$ is chosen so as to best cover (in a\nprobabilistic sense) the latent topic space not already covered by $\\{\ns_1^*,\\ldots,s_{k-1}^* \\}$.  Formally, expanding the product in\n$\\tilde{P}(t | S_{k-1}^*) = \\prod_{i=1}^{k-1} \\left(1 -\nP(t_{i}=t|s_{i}^{*})\\right)$, collecting terms and writing it as a\nseries, we arrive at a form that reflects the inclusion-exclusion\nprinciple applied to the calculation of probability that topic $t$ is\ncovered by $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$:\n\\begin{align}\n& \\prod_{i=1}^{k-1} \\left(1 - P(t_{i}=t|s_{i}^{*})\\right) \\nonumber \\\\\n& = 1 - \\left[ \\sum_{i=1}^{k-1} P(t_{i}= t|s_{i}^{*}) - \\sum_{i=1}^{k-1}\\sum_{j=1}^{k-1}P(t_{i}= t|s_{i}^{*})P(t_{j}= t|s_{j}^{*}) + \\dots - (-1)^{k-1}\\prod_{i=1}^{k-1}P(t_{i}=t|s_{i}^{*})\\right] \\label{eq:setcover}\n\\end{align}\n\nThis result has a natural interpretation: the first summation term\ndetermines the coverage of topic $t$ by each document $s_i$ ($1 \\leq i\n\\leq k-1$) currently in the result set, the second double summation\nterm corrects the first term by removing the joint probability mass\nfrom all pairs of documents that was double counted, and so on\naccording to the principle of inclusion-exclusion.\n\\eqref{eq:setcover} not only provides a probabilistic set covering\nview of Exp-$1$-call@$k$, but it also suggests that a portfolio\napproach to diversity using only the first summation would overcount\neach document's contribution to the diversity metric according to this\nset covering perspective.\n\nThe inclusion-exclusion principle calculation provided by the second term in Equation~\\ref{eq:setcover}\nis illustrated in~Figure~\\ref{fig:inclusionExclusionPrinciple}. In words, this term is calculating the total topic probability coverage of $t$ by all\nselected items $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$ by properly applying the\ninclusion-exclusion principle to ensure that overlapping probability coverage\nis not double counted. Then referring back to Equation~\\ref{eq:partial_simp}, we note that $s_k$ is chosen by maximizing a weighted\nsum over topics, where each topic weight is determined by its relevance\nto the query $\\vec{q}$, the item $s_k$, and penalized (i.e., due to the $1 - $)\nby the topic coverage of $t$ by the set $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$ to\nnaturally encourage diversity.  We note that this is a soft probabilistic\nversion of the ``in or out'' topic coverage approach of WSL.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[t!]\n\\begin{center}\n\\centerline{\\includegraphics[scale = 0.4]{inclusionExclusionPrinciple}}\n\\caption[Inclusion-exclusion principle.]{Inclusion-exclusion principle. The sets represent candidate\nitems $s$ for a query, and the area covered by each set is the\n``information\" covered by that item for query topic $t$. Numbers on different areas\nindicates the number of sets that share these areas. }\n\\label{fig:inclusionExclusionPrinciple}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection{Subtopic Relevance Models} \nWe use a subtopic relevance\nmodel that is a simplified version of the model in~\\cite{plmmr} with\nfewer dependence assumptions.  In other work, Zhai {\\it et\nal}~\\cite{zhai03Beyond} present an empirical risk minimization view of\ndependent document retrieval from a subtopic perspective,\nwhere they derive a formalization of the\n\\emph{greedy} selection step that is similar to MMR and to a lesser\nextent, Exp-$1$-call@$k$.\n\n\\subsubsection{Set-based Relevance Objectives} \nChen and Karger~\\cite{chen06Less}, whose derivation we extended, directly\noptimize $1$-call@$k$, but their intention is not to formalize MMR and\ninstead use na\\\"{i}ve Bayes to directly evaluate\n\\eqref{eq.ncall}.  Agrawal et al~\\cite{agrawal09diversifying}\nand Santos et al (xQuad)~\\cite{santos2010xquad} both specify set-based\ndiversity metrics \\emph{very} similar to Exp-$1$-call@$k$ but do not provide\nformal derivations as we have done in this work. \n\n\\subsubsection{Ranking Based Objectives} \nFinally, returning to our introductory motivation, Wang and Zhu~\\cite{wangzhu10} have shown that\nnatural forms of result set diversification arise via the optimization\nof average precision~\\cite{ap} and reciprocal rank~\\cite{mrr}.  Both\nof these methods share the view of directly optimizing a\n\\emph{ranking-based} objective, whereas this paper proposes a novel\nderivation from the alternate view of optimizing a \\emph{set-based}\nobjective w.r.t.\\ a subtopic model of relevance.  However, even though\nExp-$1$-call@$k$ is a set-based objective, an indirect consequence of\n(and motivation for) greedily optimizing it is that documents added\nearlier yield a greater increase in objective than those added later;\nthis yields a natural rank ordering on the greedy Exp-$1$-call@$k$\nresult set.\n\n\\subsection{Four Aspects of Diversifying Approaches}\nAs the last part of the related work, we identify four key aspects for a diversifying approach and categorize existing approaches against these categories in Table~\\ref{table:comparisonAlgorithms}. Specifically, we breakdown the\ndifferent proposals according to whether they are probabilistic, use\nlatent models for determining similarity, use adaptive learning\ntechniques, and finally whether they are unsupervised, i.e., they do\nnot require labeled data or feedback. We note that our model is the first\nproposal (that we are aware of) to combine all four traits in the\naffirmative. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{table}[htbp!]\n\\tbl{Dimensions of diversified set-based retrieval\nsystems: \\emph{Probabilistic}: uses probabilistic models?; \\emph{Latent}: use\nlatent topic models?; \\emph{Learning}: uses some form of learning?;\n\\emph{Unsupervised}: does not require labeled topic data or feedback?}{\n\\begin{tabular}{lcccc}\n\\hline\nDiversity Paper                                    &Probabilistic&  Latent & Learning & Unsupervise  \\\\\n\\hline\nCarbonell \\cite{carbonell98MMR}                    &             &         &         & $\\surd$\\\\\nAnagnostop \\cite{anagnostopoulos05245Sampling}\t\t & $\\surd$     &         &         & $\\surd$\\\\\nRadlinski \\cite{radlinski06691Improving}           &             &         &         & $\\surd$\\\\\nRadlinski \\cite{radlinski08LearningDiverse}        & $\\surd$     &         & $\\surd$ & \\\\\nClarke \\cite{clarke08Novelty}                      & $\\surd$     &$\\surd$  &         & $\\surd$\\\\\nYue \\cite{yue081224Predicting}                     &             &$\\surd$  & $\\surd$ & \\\\\nBai \\cite{bai08Adapting}                           &             &         & $\\surd$ & $\\surd$\\\\\nSanderson \\cite{sanderson08Ambiguous}              &             &         &         & $\\surd$\\\\\nYu \\cite{yu09368}                                  &             &         &         & $\\surd$\\\\\nAgrawal \\cite{agrawal09diversifying}               & $\\surd$     & $\\surd$ &         & $\\surd$\\\\\nGollapudi \\cite{gollapudi09AnAxiomatic}            &             &         &         & $\\surd$\\\\\nClough \\cite{clough09734Multiple}                  & $\\surd$     &         &         & $\\surd$\\\\\nSong \\cite{song09Identification}                   & $\\surd$     &         & $\\surd$ & \\\\\nWang \\cite{wang09PortfolioTheory}                  &             & $\\surd$ &         & $\\surd$\\\\\nNeal \\cite{lathia10TemporalDiversity}              &             &         &         & \\\\\nZhao \\cite{Zhao:SIGIR2012}                         &             &         &         & \\\\\nDang \\cite{Dang:SIGIR2012}                         & $\\surd$     & $\\surd$ &         & $\\surd$ \\\\\nVargas \\cite{Vargas:SIGIR2012}\t\t\t\t\t\t\t\t\t\t & $\\surd$     &         & $\\surd$ & $\\surd$    \\\\\nOur model (this paper)                             & $\\surd$     & $\\surd$ & $\\surd$ & $\\surd$ \\\\\n\\hline\n\\end{tabular}}\n\\label{table:comparisonAlgorithms}\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%\\subsection{Temporal Diversification in Recommender Systems}\n%Another closely related line of study on diversification applies into recommender systems, thus we discuss these approaches here. \n%\\subsubsection{Static Diversification in Recommender Systems}\n%\n%\\subsubsection{Temporal Diversification in Recommender Systems}\n", "meta": {"hexsha": "83aa099e2af43039a9901d9c8aabe983343ba5f5", "size": 19248, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/ACM_TIST_diversity/related_work_unused.tex", "max_stars_repo_name": "antoine-tran/diversify", "max_stars_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/ACM_TIST_diversity/related_work_unused.tex", "max_issues_repo_name": "antoine-tran/diversify", "max_issues_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/ACM_TIST_diversity/related_work_unused.tex", "max_forks_repo_name": "antoine-tran/diversify", "max_forks_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-04T16:27:43.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-04T16:27:43.000Z", "avg_line_length": 67.0662020906, "max_line_length": 722, "alphanum_fraction": 0.7163341646, "num_tokens": 5347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.43872653313426013}}
{"text": "\\documentclass{article}\n\n\\input{../header.tex}\n\n\\begin{document}\n\nIt might be more accurate for the Coulomb term in the SEMF to be proportional to \\(Z(Z-1)\\), since, modeling the protons as point particles, the proper expression for the energy would be:\n\n\\begin{equation} \\label{eq:SEMF-coulomb-correction}\n    U = \\frac{e^2}{4 \\pi \\varepsilon_0} \\sum _{i=1}   ^{Z} \\sum _{j<i} \\frac{1}{\\abs{r_i - r_j} }  \\propto \\frac{Z(Z-1)}{\\abs{\\overline{r} } }  \\propto \\frac{Z(Z-1)}{A^{1/3}}\n\\end{equation}\n\nwhere \\(\\overline{r} \\) is the average distance between the protons in the nucleus. We do not know what its expression looks like, but surely \\(\\overline{r} \\propto r _{\\text{nucleus}}  \\propto A^{1/3}\\).\n\n\\paragraph{Specular nuclei}\n\nThey are pairs of nuclei with odd \\(A\\) and \\(Z\\)s equal to \\((A \\pm 1)/2\\).\n\nThe only term which changes in the SEMF between them is the Coulomb, therefore (using the modified Coulomb term given in \\eqref{eq:SEMF-coulomb-correction}) their difference in energy is given by\n\n\\begin{subequations}\n\\begin{align}\n  \\Delta B  &= \\frac{a_C}{A^{1/3}} \\qty(\\frac{(A+1)(A-1)}{4} - \\frac{(A-1)(A-3)}{4})  \\\\\n  &= \\frac{a_C}{A^{1/3}} \\qty(\\frac{4A -4}{4})  \\\\\n  &= a_C \\qty(A^{2/3} - A^{-1/3})\n\\end{align}\n\\end{subequations}\n\nWith the Coulomb term which models the nucleus as a uniformly charged sphere, \\(a_C Z^2 A^{-1/3}\\), we get \\(\\Delta B = a_C A^{2/3}\\) instead.\n\nWe can plot the data for \\(\\Delta B\\) wrt \\(x \\defeq A^{2/3}\\). The plot will be of the form\n\n\\begin{equation} \\label{eq:delta-B-options}\n    \\Delta B  = a_C x - \\frac{a_C}{\\sqrt{x}} \\qquad \\text{or} \\qquad \\Delta B = a_C x\n\\end{equation}\n\nWe fit the two options given in equation \\eqref{eq:delta-B-options}: the results are shown in figure \\ref{fig:odd-A-fit}.\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{subfigure}{0.5\\textwidth}\n        \\includegraphics[width=\\textwidth]{figures/odd_A_fit.pdf}\n        \\caption{Fit}\n    \\end{subfigure}%\n    \\begin{subfigure}{0.5\\textwidth}\n        \\includegraphics[width=\\textwidth]{figures/odd_A_residuals.pdf}\n        \\caption{Residuals}\n    \\end{subfigure}%\n    \\caption{Fit of the difference in \\(B\\) between symmetric nuclei. The chi square is \\(\\SI{0.136}{MeV^2} \\) for the \\(Z^2\\) model, and \\(\\SI{0.062}{MeV^2}\\) for the \\(Z(Z-1)\\) model.}\n    \\label{fig:odd-A-fit}\n\\end{figure}\n\n\nThe fit gives us \\(a_C = \\SI{631(5)}{keV}\\) in the new parametrization (the error is only indicative, as I did not have errorbars for the binding energies).\n\n\\begin{flushright}\n    Jacopo Tissino, 21 june 2019\n\\end{flushright}\n\n\n\\end{document}\n", "meta": {"hexsha": "aae85748c5830f16399f6de5143e22acd0825e6b", "size": 2565, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quick_files/coulomb/Coulomb-term-correction.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "quick_files/coulomb/Coulomb-term-correction.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quick_files/coulomb/Coulomb-term-correction.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 41.3709677419, "max_line_length": 204, "alphanum_fraction": 0.6639376218, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.43872653158534247}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage[colorlinks,\npdfauthor=\"Len Thomas\",\npdftitle=\"MT4113 Lecture notes\"]{hyperref}\n\\usepackage[a4paper,margin=2cm,footskip=.5cm]{geometry}\n\\usepackage[english]{babel}\n\\usepackage[latin1]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{epsf,graphics,graphicx,fancyhdr,color,amsmath,url,enumerate,alltt}\n\n\\begin{document}\n\n\\section*{MT4113 Lecture 4 Computer arithmetic\\\\Solutions to practice questions} \n\n\\begin{enumerate}\n    \\item Write out -15-3=-18 in binary using an 8-bit signed integer system\n\\begin{verbatim}  -15 10001111\n-  +3 00000011\n= -18 10010010\n\\end{verbatim}\t\t\n    \\item What is the largest positive number that can be represented in this system?\\\\ \\\\\n\\texttt{01111111 = 127}\n    \\item Why is it very fast to multiply numbers represented as integers by 2?  What manipulation is required to the bits making up the number to achieve this operation?\\\\\n\n\\texttt{The computer just needs to shift the bits to the left (apart from the sign bit and the most significant digit -- if the latter is already 1 then you get an overflow), and put a 0 in the least significant digit bit}\n\n    \\item What is the machine epsilon on a 32-bit floating point system where 1 bit is for the sign, 16 bits for the exponent and 16 bits\\footnote{using the same trick as in the IEEE standard to get one extra bit for free; note that this is not a very sensible allocation as it gives far too much of the space to the exponent} for the fraction?\\\\\n\t\t\n\\texttt{epsilon = $2^{(1-d)}=2^{(-15)}$}\n\n    \\item In this system, what would be the result of computing $2* 2^{-17} + 1$?\\\\\n\t\t\n\\texttt{$2\\times2^{-17} = 1\\times2{^-16}$.  This is below the machine epsilon so the result would be 1.}\n\n    \\item What do you get if you compute $512 * 0.25$ in the above floating point system, and then convert it into the above signed integer system?\\footnote{A calculation like this once cost the EU space program about \\$500 million: \\href{https://www.ima.umn.edu/~arnold/disasters/ariane.html}{https://www.ima.umn.edu/$\\sim$arnold/disasters/ariane.html}}\\\\\n\t\t\n\\texttt{$512 \\times 0.25$ is easily evaluated exactly in the floating point system, giving 128.  This is larger than the largest integer, however, so you'd get an overflow}\n\n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "7c9d7b3219ea0295f86abca04e57a9769e13d288", "size": 2285, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lectures/Lecture 4/Lect4PracticeQsWithSolutions.tex", "max_stars_repo_name": "yc59/2018", "max_stars_repo_head_hexsha": "4c74a67a4d0dadecc4213dd57289120b31806aa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lectures/Lecture 4/Lect4PracticeQsWithSolutions.tex", "max_issues_repo_name": "yc59/2018", "max_issues_repo_head_hexsha": "4c74a67a4d0dadecc4213dd57289120b31806aa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lectures/Lecture 4/Lect4PracticeQsWithSolutions.tex", "max_forks_repo_name": "yc59/2018", "max_forks_repo_head_hexsha": "4c74a67a4d0dadecc4213dd57289120b31806aa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.7317073171, "max_line_length": 356, "alphanum_fraction": 0.7461706783, "num_tokens": 647, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.438576764544153}}
{"text": "\\chapter{Problem Formalization}\n\n\n\n\\section{Input Data}\n\n\n\\subsubsection{Notes}\n\\begin{itemize}\n    \\item The geographical information will be loaded in the form of a map, obtained in OpenStreetMap and converted to a graph\n    \\item The words 'street', 'road' and 'way' are used interchangeably\n    \\item The words 'node' and 'vertex' ('nodes' and 'vertices') are used interchangeably\n    \\item The words 'range' and 'autonomy' are used interchangeably\n    \\irem The words 'route' and 'itinerary' are used interchangeably\n\\end{itemize}\n\n\n\\subsubsection{Graph}\n\\paragraph{G = (N, E)} - weighted directed (roads may be one way only) graph that represents the map. It is composed by Nodes and Edges\n\\begin{itemize}\n\n\t\\item N - set of Nodes (a node represents an \\uline{\\textit{interest point}} or simply a point in the road network) (N(i) is the ith element). For each node:\n\\begin{itemize}\n\t\\item Adj - edges whose origin is N(i)\n\t\\item lat - the latitude of the point it represents in the map\n\t\\item long - the longitude of the point it represents in the map\n\\end{itemize}\n\n\t\\item A - set of Edges (an edge represents a way/street/road) (E(i) is the ith element). For each edge:\n\\begin{itemize}\n\t\\item w - weight (represents the length of the way) (measured in meters)\n\t\\item dest - origin node of the edge\n\t\\item orig - destination node of the edge\n\\end{itemize}\n\n\\end{itemize}\n\n\\uline{Interest Points} (special nodes)\n\\begin{itemize}\n\t\\item base - base/garage of the company\n\t\\item rp - recharge points\n\t\\item pup - pick up point\n\t\\item dp - delivery point\n\\end{itemize}\n\n\n\\subsubsection{Vehicles}\n\\paragraph{V} - set of vehicles that make the fleet of the company (Ve(i) is the ith element). For each vehicle:\n\\begin{itemize}\n\t\\item range - current range of the vehicle (in meters)\n\t\\item license-plate - plate that identifies the car\n\\end{itemize}\n\n\\subsubsection{Orders}\n\\paragraph{O} - set of orders for the day (O(i) is the ith element). For each order:\n\\begin{itemize}\n    \\item pup - pick up point\n\t\\item dp - delivery point\n\t\\item orderID - id that represents the order\n\\end{itemize}\n\n\n\n\\section{Output Data}\nEach vehicle is assigned a \\textit{path} that represents the best sequence of nodes for the orders \\textit{Ov} he's been assigned to. The path and orders are distributed taking to account the optimization of the distance travelled and the range of each vehicle at any given time.\nFor each Vehicle V(i):\n\\begin{itemize}\n\t\\item path - sequence of nodes that represents the path to be taken by a vehicle on a day (path(i) is the ith element). Path has to be connected and finish on the starting point.\n\t\\item Ov - set of orders assigned to the vehicle (Ov(i) is the ith element)\n\\end{itemize}\n\n\n\n\\section{Restrictions}\n\n\n\\subsection{Input Restrictions}\n\n\\subsubsection{General}\n\\begin{itemize}\n    \\item The sets' indexes are implicitly limited by their sizes and 0\\\\ \\uline{Example:}\n    $ 0 \\leq i < |N| $\n\\end{itemize}\n\n\\subsubsection{Graph}\n\\begin{itemize}\n    \\item Node\n    \\begin{itemize}\n        \\item $ |N| > 0 $ \n        \\item $ \\forall n \\in N, Adj(n) \\subseteq E $ (Adj is the set of edges originated in N(i))\n        \\item $ \\forall n \\in N, \\ang{0} \\leq lat \\leq \\ang{360} $\n        \\item $ \\forall n \\in N, \\ang{0} \\leq long \\leq \\ang{360} $\n    \\end{itemize}   \n    \n    \\item{Edge}\n    \\begin{itemize}\n        \\item $ |E| > 0 $\n        \\item $ \\forall e \\in E, w > 0 $ (the length of a way or road must be always bigger than 0)\n        \\item $ \\forall e \\in E, orig \\in N $ \n        \\item $ \\forall e \\in E, dest \\in N $\n    \\end{itemize}\n    \n    \\item $ base \\in N $\n    \\item $ rp \\in N $\n    \\item $ pup \\in N $\n    \\item $ dp \\in N $\n    \\item $ \\exists! n \\in N, n = base $\n    \n\\end{itemize}\n\n\\subsubsection{Vehicles}\n\\begin{itemize}\n    \\item $ |V| > 0 $\n    \\item $ \\forall v \\in V, range > 0 $\n\\end{itemize}\n\n\\subsubsection{Orders}\n\\begin{itemize}\n    \\item $ |O| \\geq 0 $\n    \\item $ \\forall o \\in O, pup \\in N $\n    \\item $ \\forall o \\in O, dp \\in N $\n\\end{itemize}\n\n\n\\subsection{Output Restrictions}\n\n\\subsubsection{Path}\n\\begin{itemize}\n    \\item $ |path| > 0 $\n    \\item $ path \\subseteq N $\n    \\item $ \\forall p \\in path, p \\in N $\n\\end{itemize}\n\n\\subsubsection{Vehicle Orders}\n\\begin{itemize}\n    \\item $ |Ov| \\geq 0 $\n    \\item $ Ov \\subseteq O $\n    \\item $ \\forall o \\in Ov, o \\in O$\n\\end{itemize}\n\n\n\n\\section{Objective Function}\n\nThe company's goal for this system is to optimize the use of their vehicles. As we will not consider different speeds of travel for the vehicles, the time to fulfill a order behaves in parallel to the distance of its path. In our interpretation of the problem, optimizing the use of the vehicles would mean to find the shortest paths between two interest points in a route, as well as minimizing the distance of the route itself. In an optimal solution, the maximum distance travelled by a vehicle in a day would also be minimized. As such, there must be three functions to optimize (ones depend on the others). Being $ f $ the function that represents the most distance travelled by a vehicle; $ g $ the sum of the distances between the points in an itinerary; $ h $ the function that represents the distance between two interest points: the objective is to minimize them:\n\\[ f = \\max(D) \\]\n\\begin{itemize}\n    \\item $ D $ being the set of distances travelled by each vehicle in a day\n\\end{itemize}\n\\[ g = \\max(sum(d)) \\]\n\\[ h = \\max(d) \\]\n\\begin{itemize}\n    \\item $ d_1 $ being the distance from one interest point to another\n\\end{itemize}\n", "meta": {"hexsha": "5a2f447e43b5805dcb1e67107a03eeffccaa9a9c", "size": 5527, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Project/report/LaTeX/ProblemFormalization.tex", "max_stars_repo_name": "marhcouto/FEUP-CAL", "max_stars_repo_head_hexsha": "e02775eb69f0b5fc268c80084e85b5f18177dd78", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Project/report/LaTeX/ProblemFormalization.tex", "max_issues_repo_name": "marhcouto/FEUP-CAL", "max_issues_repo_head_hexsha": "e02775eb69f0b5fc268c80084e85b5f18177dd78", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Project/report/LaTeX/ProblemFormalization.tex", "max_forks_repo_name": "marhcouto/FEUP-CAL", "max_forks_repo_head_hexsha": "e02775eb69f0b5fc268c80084e85b5f18177dd78", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6580645161, "max_line_length": 873, "alphanum_fraction": 0.6886195043, "num_tokens": 1591, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.43857676454415295}}
{"text": "\\documentclass[titlepage]{article}\r\n\\newcommand{\\var}{\\textrm{Var}}\r\n\\newcommand{\\E}{\\textrm{E}}\r\n\\newcommand{\\Normal}{\\mathcal{N}}\r\n\\newcommand{\\Ito}{It\\^{o}~}\r\n\r\n\\usepackage{amsmath, amsthm, amssymb}\r\n\\usepackage[pdftex]{graphicx}\r\n\\usepackage{epstopdf}\r\n\r\n%IEEE compliance:\r\n\\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf --gsopt=-dPDFSETTINGS=/prepress #1}\r\n\r\n\\author{Yuriy Sverchkov}\r\n\\title{Modeling Flagellar Growth as a Stochastic Process}\r\n\r\n\\newtheorem*{clthm}{Central Limit Theorem for Renewal Processes}\r\n\\newtheorem*{itoform}{The \\Ito Formula}\r\n\r\n\\begin{document}\r\n\r\n%\\maketitle\r\n\r\n\\begin{titlepage}\r\n\\begin{center}\r\n\r\n\\vspace*{2.5in}\r\n{\\Large Modeling Flagellar Growth as a Stochastic Process}\r\n\r\n\\vspace{0.5in}\r\n{\\large Yuriy Sverchkov}\r\n\r\n\\vfill\r\n{\\Large Senior Thesis\\\\ }\r\n\r\n\\vspace{0.25in}\r\n{\\large Advisor: Dr. Muruhan Rathinam\r\n\r\n\\vspace{0.25in}\r\nMathematics Department\\\\ University of Maryland, Baltimore County}\r\n\r\n\\vspace{0.5in}\r\n\\today\r\n\r\n\\end{center}\r\n\\end{titlepage}\r\n\r\n\\input{Intro.tex}\r\n\r\n\\section{Discrete Stochastic Model}\r\n\\label{sec:OriginalModel}\r\n\r\nFollowing an approach similar to \\cite{bressloff},\r\nwe model the process as a discrete-state continuous-time Markov process as follows:\r\nWe view the flagellum as having $N = L / a$ segments.\r\nEach transporter has a position between $0$ (the flagellum base) and $N$ (the flagellum tip).\r\nWe also keep track of the direction of a transporter.\r\nIf a transporter $i$ ($i=1,...,n$) is moving anterograde, we consider the time it takes it to move from position $x$ to its next position $x+1$ to be an exponential random variable $T_{i,x+}$ with rate $\\lambda_+ = v_+ / a$.\r\nSimilarly,  retrograde  movement from position $x$ to position $x-1$ is represented by discrete jumps a random exponential time period $T_{i,x-}$ apart (with a rate of $\\lambda_- = v_- / a$).\r\nDisassembly is similarly represented by a discrete shortening of the flagellum length at random exponentially distributed time intervals $S$ with the corresponding rate of $\\mu = V / a$.\r\nThe direction of movement of a transporter changes only at the tip and at the base as follows:\r\nWhen a transporter at the tip (position $N$) is moving anterograde jumps to its next position, $N$ is incremented, the transporter's new position is the new value of $N$, and its direction of movement becomes retrograde.\r\nWhen a transporter at position $1$ is moving retrograde jumps to its next position, its new position becomes $0$ and its direction becomes anterograde.\r\n\r\nNote that the resulting state-space for this Markov process has $M+1$ dimensions.\r\n\r\n\r\n\\subsection{Monte Carlo Simulation}\r\n\r\nThe most intuitive way to simulate a Markov Process is through the means of a Monte Carlo method, by generating values for the random variables $T_{i,x-}$, $T_{i,x+}$ and $S$ with a pseudorandom number generator (PRNG) and using those values to simulate the positions of the transporters and the flagellum length at any given moment in time.\r\n\r\nWe have encountered some challenges regarding the implementation of the simulation due to the number of steps the simulation must take to simulate a reasonably long time period.\r\nInitially, MATLAB was used for the simulation. However, the MATLAB simulation took an unreasonably long period of time to run, and the simulation had to be re-written in C.\r\nThe C code ran considerably faster.\r\nIn writing the simulation code it was also important to make sure that the simulation does not exceed the PRNG's period.\r\nIn our simulation, we used the SIMD-oriented Fast Mersenne Twister algorithm~\\cite{matsumoto} with a period of $2^{216091}-1$ iterations.\r\nThe number of random numbers generated per simulation run is as follows:\r\nA step (a transporter moves or the flagellum shortens) occurs between $10 \\times 350+1$ and $10 \\times 200+1$ times per simulation second.\r\nTwo random numbers are generated per step: one to select the event that happens, and one to determine the waiting time until the next event.\r\nWe run simulations with time limits of $15000$ and $50000$ simulation seconds, resulting in about $10^7$ to $10^8$ random numbers generated per each trajectory.\r\nAdding that we would like to get final distributions by running thousands of trajectories, and then compare several such sets of runs, adds three or more orders of magnitude to the number of random numbers to be generated.\r\n\r\n\r\n\\subsection{Trajectories}\r\nAt first glance, the stochastic IFT model seems to be in agreement with the ODE model. Figure~\\ref{fig:originalTrajs} shows some sample trajectories created by the simulation with their ODE solution counterparts.\r\n\r\n\\begin{figure}[!h]\r\n\\centering\r\n\\includegraphics[width=\\textwidth]{OriginalModelTrajs}\r\n\\caption{\r\nFour representative trajectories generated by the stochastic IFT simulation and corresponding solutions to the ODE.\r\nThe four different trajectories start from four different initial lengths: 100, 1000, 1300, and 1900, running to a time limit of 50000.\r\n}\r\n\\label{fig:originalTrajs}\r\n\\end{figure}\r\n\r\n\\subsection{Distribution at a Given Time}\r\n%Table~\\ref{tab:original} shows\r\nFigure~\\ref{fig:orig_ic8_15Ks} shows data from running the simulation of 5000 independent trajectories starting with the same initial conditions and taking the length at a particular predetermined time (15000 simulation seconds in this case).\r\n%See Table~\\ref{tab:ic} for a list of initial conditions. Sets of initial conditions were generated so that the IFTs are distributed uniformly.\r\n\r\n%\\begin{table}[t]\r\n%\\centering\r\n%\\begin{tabular}{crr}\r\n%Name & Initial Length & Number of IFTs \\\\ \\hline\r\n%ic2 & 100 & 10 \\\\\r\n%ic5 & 1300 & 10 \\\\\r\n%ic8 & 1300 & 10\r\n%\\end{tabular}\r\n%\\caption{List of names for the different sets of initial conditions used for %simulations.}\r\n%\\label{tab:ic}\r\n%\\end{table}\r\n\r\n%\\begin{table}[!htbp]\r\n%\\centering\r\n%\\begin{tabular}{c*6{r}}%{cc*6{r}}\r\n% Fig. &\r\n% I.C. &\r\n% \\parbox{50pt}{Time Limit (seconds)} &\r\n% \\parbox{40pt}{Number of Runs} &\r\n% Mean &\r\n% \\parbox{50pt}{Standard deviation} &\r\n% Skewness &\r\n% Kurtosis\r\n%\\\\ \\hline\r\n% \\ref{fig:orig_ic5_50Ks} &\r\n%  ic5 & 50000 & 1200 & 1272.1 & 25.3665 & 0.0294 & 3.1540 \\\\\r\n% \\ref{fig:orig_ic8_15Ks} &\r\n%  ic8 & 15000 & 5000 & 1273.3 & 25.2790 & 0.0045 & 2.8647 \\\\\r\n% \\ref{fig:orig_ic8_50Ks_1} &\r\n%  ic8 & 50000 & 1800 & 1272.3 & 24.7195 & 0.1595 & 3.0236 \\\\\r\n% \\ref{fig:orig_ic8_50Ks_2} &\r\n%  ic8 & 50000 & 2400 & 1273.1 & 25.1025 & 0.0554 & 2.9257 \\\\\r\n% \\ref{fig:orig_ic2_50Ks} &\r\n%  ic2 & 50000 & 3500 & 1271.9 & 25.1562 & 0.0442 & 2.9342 \\\\\r\n% \\ref{fig:orig_ic2_15Ks} &\r\n%  ic2 & 15000 & 5000 & 1273.0 & 25.3101 & -0.0020 & 2.9549\r\n\r\n%\\end{tabular}\r\n%\\caption{Data from ensemble runs of the IFT simulation.}\r\n%\\label{tab:original}\r\n%\\end{table}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{ic5_50Ks.eps}\r\n%\\caption{Distribution of final lengths given by the original simulation. See Table~\\ref{tab:original} for details. 30 bin histogram for a sample of 1200.}\r\n%\\label{fig:orig_ic5_50Ks}\r\n%\\end{figure}\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[height=3in]{ic8_15Ks}\r\n\\caption{Distribution of final lengths given by the original simulation. The simulation was initialized at an initial length $N(0) = 1300$. 70 bin histogram for a sample of 5000.}\r\n\\label{fig:orig_ic8_15Ks}\r\n\\end{figure}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{ic8_50Ks.eps}\r\n%\\caption{Distribution of final lengths given by the original simulation. See Table~\\ref{tab:original} for details. 30 bin histogram for a sample of 1800.}\r\n%\\label{fig:orig_ic8_50Ks_1}\r\n%\\end{figure}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{ic8_50Ks_2.eps}\r\n%\\caption{Distribution of final lengths given by the original simulation. See Table~\\ref{tab:original} for details. 40 bin histogram for a sample of 2400.}\r\n%\\label{fig:orig_ic8_50Ks_2}\r\n%\\end{figure}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{ic2_50Ks.eps}\r\n%\\caption{Distribution of final lengths given by the original simulation. See Table~\\ref{tab:original} for details. 50 bin histogram for a sample of 3500.}\r\n%\\label{fig:orig_ic2_50Ks}\r\n%\\end{figure}\r\n\r\n%\\begin{figure}%[!htbp]\r\n%\\centering\r\n%\\includegraphics[height=3in]{ic2_15Ks.eps}\r\n%\\caption{Distribution of final lengths given by the original simulation. The simulation was initialized at an initial length $N(0) = 1300$. 70 bin histogram for a sample of 5000.}\r\n%\\label{fig:orig_ic2_15Ks}\r\n%\\end{figure}\r\n\r\n\\subsection{Comparing Different Distributions}\r\nWe generated multiple sets of data with the simulation starting at various initial lengths $N(0)$.\r\nWe also compared simulations with time limits of both 50000 and 15000 seconds.\r\n\r\nUsing the Kolmogorov-Smirnov test (the MATLAB \\texttt{kstest2} command) to compare the distributions given by the simulation we can conclude several things:\r\n\r\nSince the test cannot reject the hypothesis that the samples come from the same distribution when comparing two samples from different initial lengths and identical time limit shows that starting at different initial conditions leads to the same stationary probabilities as suggested by the trajectory plots.\r\n%(Comparing the distribution in Figure~\\ref{fig:orig_ic2_50Ks} to the distribution in Figure~\\ref{fig:orig_ic5_50Ks} or Figure~\\ref{fig:orig_ic8_50Ks_1} or Figure~\\ref{fig:orig_ic8_50Ks_2})\r\n\r\nThe test also cannot reject the hypothesis when comparing two samples with different time limits (50000s vs. 15000s), leading to believe that the stationary probabilities are reached before 15000s, as suggested by the trajectory plots.\r\n%(Comparing the distribution in Figure~\\ref{fig:orig_ic8_15Ks} to the distribution in Figure~\\ref{fig:orig_ic5_50Ks} or Figure~\\ref{fig:orig_ic8_50Ks_1} or Figure~\\ref{fig:orig_ic8_50Ks_2})\r\n\r\n%In fact, the test cannot reject the hypothesis when comparing any pair of distributions from Table~\\ref{tab:original}.\r\n\r\n\\subsection{The Crowding Model}\r\nThe crowding model is a modified version of the original model with the major difference being that transporters are not allowed to occupy the same position at the same time. This is accomplished by adding a check every time a transporter is selected to move---if there is another transporter in the position in front of it, the transporter does not move. When the flagellum length decreases, transporters are bumped back (that is, if there is an transporter at the very end and another directly behind it, both are moved back).\r\n\r\n\\subsubsection{Trajectories}\r\nFigure~\\ref{fig:crowdTrajs} shows some sample trajectories created by the simulation with their ODE solution counterparts. Visually, the crowding model also apparently agrees with the ODE model.\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[width=\\textwidth]{CrowdingModelTrajs}\r\n\\caption{\r\nFour representative trajectories generated by the stochastic IFT simulation with crowding and corresponding solutions to the ODE.\r\nThe four different trajectories start from four different initial lengths: 100, 1000, 1300, and 1900, running to a time limit of 50000.\r\n}\r\n\\label{fig:crowdTrajs}\r\n\\end{figure}\r\n\r\n\\subsubsection{Distribution at a Given Time}\r\nFigure~\\ref{fig:crowd_ic8_15Ks} shows data from running the simulation repeatedly starting with the same initial conditions and taking the length at a particular predetermined time (15000s).\r\nThe dataset shown in Figure~\\ref{fig:crowd_ic8_15Ks} had a mean of 1268.6 and a standard deviation of 25.4275,\r\nwith 95\\% confidence intervals of [1268.0, 1269.2] and [25.0211, 25.8474] for the mean and standard deviation respectively.\r\nWhen compared to the non-crowding model simulation results (see Table~\\ref{tab:ci} on page~\\pageref{tab:ci}) it can be seen that the crowding model yields a lower mean, but a similar standard deviation.\r\n\r\n%\\begin{table}[!htbp]\r\n%\\centering\r\n%\\begin{tabular}{c*6{r}}%{cc*6{r}}\r\n% Fig. &\r\n% I.C. &\r\n% \\parbox{50pt}{Time Limit (seconds)} &\r\n% \\parbox{40pt}{Number of Runs} &\r\n% Mean &\r\n% \\parbox{50pt}{Standard deviation} &\r\n% Skewness &\r\n% Kurtosis\r\n%\\\\ \\hline\r\n% \\ref{fig:crowd_ic8_50Ks} &\r\n%  ic8 & 50000 & 2100 & 1268.1 & 25.4904 & 0.0176 & 2.8749 \\\\\r\n% \\ref{fig:crowd_ic8_15Ks} &\r\n%  ic8 & 15000 & 7280 & 1268.6 & 25.4275 & 0.0064 & 2.9586 \\\\\r\n% \\ref{fig:crowd_ic2_50Ks} &\r\n%  ic2 & 50000 & 1270 & 1269.6 & 24.8842 & -0.0928 & 2.8579 \\\\\r\n% \\ref{fig:crowd_ic2_15Ks} &\r\n%  ic2 & 15000 & 4200 & 1268.8 & 25.1056 & 0.0304 & 2.8689\r\n\r\n%\\end{tabular}\r\n%\\caption{Data from ensemble runs of the crowding simulation.}\r\n%\\label{tab:crowd}\r\n%\\end{table}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{c_ic8_50Ks.eps}\r\n%\\caption{Distribution of final lengths given by the crowding simulation. See Table~\\ref{tab:crowd} for details. 60 bin histogram for a sample of 2100.}\r\n%\\label{fig:crowd_ic8_50Ks}\r\n%\\end{figure}\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[height=3in]{c_ic8_15Ks}\r\n\\caption{Distribution of final lengths given by the crowding simulation.\r\nThe simulation was initialized at an initial length $N(0) = 1300$.\r\n80 bin histogram for a sample size of 7280.}\r\n\\label{fig:crowd_ic8_15Ks}\r\n\\end{figure}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{c_ic2_50Ks.eps}\r\n%\\caption{Distribution of final lengths given by the crowding simulation. See Table~\\ref{tab:crowd} for details. 30 bin histogram for a sample of 1270.}\r\n%\\label{fig:crowd_ic2_50Ks}\r\n%\\end{figure}\r\n\r\n%\\begin{figure}[!htbp]\r\n%\\centering\r\n%\\includegraphics[width=\\textwidth]{c_ic2_15Ks.eps}\r\n%\\caption{Distribution of final lengths given by the crowding simulation. See Table~\\ref{tab:crowd} for details. 60 bin histogram for a sample of 4200.}\r\n%\\label{fig:crowd_ic2_15Ks}\r\n%\\end{figure}\r\n\r\n\\subsubsection{Comparing Different Distributions}\r\n%The Kolmogorov-Smirnov test cannot reject the hypothesis that two samples come from the same distribution when any pair of samples from Table~\\ref(tab:crowd).\r\nAccording to the Kolmogorov-Smirnov test, the same final distribution are reached by trajectories run from different initial conditions.\r\nSimilarly, the test cannot reject the hypothesis that distributions at 15000s and at 50000s are the same.\r\n\r\n\\subsection{Crowding vs. Non-Crowding}\r\nSince the crowding model yields a lower mean for the stationary distribution, it is clear that the two models do not give strictly the same distribution.\r\nHowever, when the distributions are shifted so that their means match, the Kolmogorov-Smirnov test cannot reject the hypothesis that the two samples (one from the crowding model and one from the original model) come from the same distribution.\r\n\r\n\\section{Naive Birth-Death Model}\r\n\r\nDue to the complexity of the discrete model, it is of interest whether this model can be simplified.\r\nWe are particularly interested in the length of the flagellum as a function of time, and the stationary distribution of the length, hence we attempt to write a model that is dependent on length and time alone.\r\n\r\nOne of the simpler forms of such a model is a birth-death model (see~\\cite{ross} for a definition) where the death rate is the rate of disassembly and the birth rate is the total rate of assembly.\r\n\r\n\\subsection{Exact Stationary PDF Derivation}\r\n\r\nIn the birth-death model the state number $n$ represents the length of the flagellum in number of proteins ($N$ from the discrete model), the birth rate is the assembly rate, and the death rate is the disassembly rate.\r\n\r\nThe assembly rate is indicated in the ODE: since the frequency at which one transporter will arrive at the end of the flagellum with proteins for assembly is the mean speed of the transporter, $\\bar{v}$, divided by the total distance to be traveled from the tip down and back to the tip again, $2 L$.\r\nThe frequency of assembly with $M$ transporters will then be $M$ times that rate, giving an assembly rate of $\\frac{M \\bar{v}}{2 L}$, or, using the notation in the discrete model, $\\frac{M \\bar\\lambda}{2 N}$.\r\nThe disassembly rate is similarly simply $\\mu$ from the discrete model.\r\n\r\nFrom this we can get the following balance conditions for all positive-numbered states:\r\n\r\n\\begin{equation*}\r\n \\mu \\pi_{n+1} = \\frac{M \\bar\\lambda }{2 n} \\pi_n \\qquad \\forall n > 0\r\n\\end{equation*}\r\n\r\nSince the rate of assembly is inversely proportional to the length (and the state number), there is a question of what the rate of assembly should be when the length is zero. For example, if we allow for the rate of assembly at zero to be the same as the rate of assembly at 1, we get a Poisson Distribution with mean equal to the ODE-predicted mean, since then we can get an expression for $\\pi_n$ in terms of $\\pi_0$:\r\n\\begin{equation*}\r\n \\pi_n = \\left(\\frac{M\\bar\\lambda}{2 \\mu}\\right)^n \\frac{1}{n!} \\pi_0\r\n\\end{equation*}\r\nwhich allows us to get:\r\n\\begin{align*}\r\n \\sum_{n=0}^\\infty \\pi_n\r\n &= \\sum_{n=0}^\\infty \\left(\\frac{M\\bar\\lambda}{2 \\mu}\\right)^n \\frac{1}{n!} \\pi_0 \\\\\r\n &= \\pi_0 e^{\\frac{M\\bar\\lambda}{2 \\mu}} \\\\\r\n &= 1\r\n\\end{align*}\r\ngiving:\r\n\\begin{equation*}\r\n \\pi_n = e^{-(\\frac{M\\bar\\lambda}{2 \\mu})} \\left(\\frac{M\\bar\\lambda}{2 \\mu }\\right)^n \\frac{1}{n!}\r\n\\end{equation*}\r\nmeaning that the stationary distribution is Poisson with mean and variance equal to the ODE mean.\r\n\r\nAnother possible value for the assembly rate at zero can be taken from the detailed simulation: When the length is zero all transporters are at the same position, all are moving anterograde, and once any transporter moves assembly will occur. Hence the rate of assembly will be the number of transporters $M$ times the anterograde movement rate, $\\lambda_+$.\r\n\r\n\\begin{equation*}\r\n M \\lambda_+ \\pi_0 = \\mu \\pi_1\r\n\\end{equation*}\r\n\r\n\\begin{align*}\r\n \\forall n > 0: \\\\\r\n \\pi_{n+1} &= \\frac{M \\bar\\lambda}{2 \\mu n} \\pi_n \\\\\r\n \\pi_n &= \\left( \\frac{M \\bar\\lambda}{2 \\mu} \\right)^{n-1} \\frac{1}{n!} \\pi_1\r\n\\end{align*}\r\n\r\n\\begin{align*}\r\n \\sum_{n = 0}^\\infty \\pi_n\r\n &= \\pi_0 + \\sum_{n = 1}^\\infty \\left( \\frac{M \\bar\\lambda}{2 \\mu} \\right)^{n-1} \\frac{1}{n!} \\pi_1 \\\\\r\n &= \\pi_0 + \\sum_{n = 1}^\\infty \\left( \\frac{M \\bar\\lambda}{2 \\mu} \\right)^{n} \\frac{2 \\mu}{M \\bar\\lambda} \\frac{1}{n!} \\pi_1 \\\\\r\n &= \\pi_0 + \\left( e^\\frac{M \\bar\\lambda}{2 \\mu} - 1 \\right) \\frac{2 \\mu}{M \\bar\\lambda} \\pi_1 \\\\\r\n &= \\pi_0 \\left( 1 + \\left( e^\\frac{M \\bar\\lambda}{2 \\mu} - 1 \\right) \\frac{2 \\mu}{M \\bar\\lambda} \\frac{M \\lambda_+}{\\mu} \\right) \\\\\r\n &= \\pi_0 \\left( 1 + \\left( e^\\frac{M \\bar\\lambda}{2 \\mu} - 1 \\right) \\frac{2 \\lambda_+}{\\bar\\lambda} \\right) \\\\\r\n &= 1\r\n\\end{align*}\r\n\r\n\\begin{equation*}\r\n\\pi_0 = \\frac{1}{ 1 + \\left( e^\\frac{M \\bar\\lambda}{2 \\mu} - 1 \\right) \\frac{2 \\lambda_+}{\\bar\\lambda} }\r\n\\end{equation*}\r\n\r\n\\begin{equation*}\r\n\\forall n > 0 \\qquad \\pi_n = \\frac{M \\lambda+}{ \\left( 1 + \\left( e^\\frac{M \\bar\\lambda}{2 \\mu} - 1 \\right) \\frac{2 \\lambda_+}{\\bar\\lambda} \\right) \\mu n! } \\left( \\frac{M \\bar\\lambda}{2 \\mu} \\right)^{n-1}\r\n\\end{equation*}\r\n\r\nNote that the resulting distribution is very similar to a Poisson distribution in shape.\r\nIn fact, the only difference is that the probability that $n=0$ is different, and the probabilities for $n>0$ are a constant multiple of the Poisson probabilities for $n>0$.\r\nAdditionally, noting that $\\frac{M\\bar\\lambda}{2\\mu} \\gg 1$, and that $2\\lambda_+ / \\bar\\lambda = 1 + ( \\lambda_+ / \\lambda_- ) > 1$, we can see that\r\n\\begin{equation*}\r\n( 1 + ( e^\\frac{M\\bar\\lambda}{2\\mu} - 1 ) \\frac{2 \\lambda_+}{\\bar\\lambda} )\r\n\\approx \\frac{2 \\lambda_+}{\\bar\\lambda} e^\\frac{M\\bar\\lambda}{2\\mu}\r\n\\end{equation*}\r\nWhich means that the distribution is very close to a Poisson distribution, that is, the scaling is not very significant.\r\n\r\nThe birth-death model gives a stationary distribution with a variance of $\\bar{N}$, which is about twice the variance observed from simulations of the detailed model.\r\n\r\n\\subsection{Simulation Results}\r\nFigure~\\ref{fig:bdTrajs} shows that the trajectory of the birth-death model does not match the ODE like the detailed stochastic model does; however, it does approach the same mean in the long run.\r\nThe major difference between the models is the fact that the standard deviation predicted by the birth-death model is twice the standard deviation observed from simulations of the detailed model.\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[width=\\textwidth]{BirthDeathTrajs}\r\n\\caption{\r\nFour representative trajectories generated by the birth-death simulation and corresponding solutions to the ODE.\r\nThe four different trajectories start from four different initial lengths: 100, 1000, 1300, and 1900, running to a time limit of 50000.\r\n}\r\n\\label{fig:bdTrajs}\r\n\\end{figure}\r\n\r\n\\section{Stochastic Differential Equation Model}\r\n\r\nAfter seeing that the simple birth-death model is inadequate, we try a different approach, which yields a stochastic differential equation (SDE) of the length as a function of time.\r\n\r\nFirst, consider a time interval $[t,t+\\tau]$, where $\\tau$ is small enough so that the length of the flagellum $L$, and hence the number of segments $N$, does not change appreciably.\r\nDenote the number of assemblies performed by transporter $i$ during the time interval $[t,t+\\tau]$ by $X_i(\\tau)$, $i=1,...,M$.\r\n\r\nIn a model without crowding effects, since the transporters are only affected by each other via the changing length of the flagellum, our assumption that $N$ does not change appreciably during the time interval allows us to say that $X_1(\\tau),...,X_n(\\tau)$ are almost i.i.d. random variables.\r\n\r\nTreating $X_i(\\tau)$ as a renewal process (see Ross~\\cite{ross} for the definition of a renewal process) where $T_i$ is the random waiting time between increments of $X_i(\\tau)$, we can find the mean and variance of the renewal time $T_i$ as follows:\r\nTo guarantee an assembly, the transporter must complete an entire loop around the flagellum, consisting of $N$ anterograde jumps and $N$ retrograde jumps. Using the notation from Section~\\ref{sec:OriginalModel}, we can express $T_i$ as:\r\n\r\n\\begin{equation*}\r\nT_i = \\sum_{x=0}^N{T_{i,x+}} + \\sum_{x=0}^N{T_{i,x-}}\r\n\\end{equation*}\r\n\r\nSince the times between individual jumps $T_{i,x+}$ and $T_{i,x-}$ are independent exponential random variables with rates $\\lambda_+$ and $\\lambda_-$ respectively, the mean of one assembly can be expressed as the sum of their means:\r\n\r\n\\begin{equation*}\r\n\\E(T_i) = \\sum_{x=0}^N{\\E(T_{i,x+})} + \\sum_{x=0}^N{\\E(T_{i,x-})} = N \\frac{1}{\\lambda_+} + N \\frac{1}{\\lambda_-} = \\frac{2N}{\\bar{\\lambda}}\r\n\\end{equation*}\r\n\r\nAnd the variance can be expressed as:\r\n\\begin{equation*}\r\n\\var(T_i) = \\sum_{x=0}^N{\\var(T_{i,x+})} + \\sum_{x=0}^N{\\var(T_{i,x-})} = N \\frac{1}{\\lambda_+^2} + N \\frac{1}{\\lambda_-^2} = \\frac{2N}{{\\lambda^*}^2}\r\n\\end{equation*}\r\n\r\nWhere $\\bar{\\lambda}$ is the harmonic mean of $\\lambda_+$ and $\\lambda_-$, and $\\lambda^*$ is defined as $\\sqrt{\\frac{2}{(\\frac{1}{\\lambda_+})^2+(\\frac{1}{\\lambda_-})^2}}$.\r\n\r\nWe now suppose that the time interval $[t,t+\\tau]$ is such that the number of assemblies that the transporter performs in the time interval, $X_i(\\tau)$, is sufficiently large to make use of the central limit theorem for renewal processes (see Appendix~\\ref{sec:ren}).\r\n\r\nWe use the central limit theorem for renewal processes to approximate $X_i(\\tau)$, as a normal distribution with mean and variance given by:\r\n\r\n\\begin{equation*}\r\n\\frac{\\E(X_i(\\tau))}{\\tau}\r\n\\approx \\lim_{s \\to \\infty}\\frac{\\E(X_i(s))}{s}\r\n= \\frac{1}{\\E(T_i)}\r\n= \\frac{\\bar{\\lambda}}{2N}\r\n\\end{equation*}\r\n\r\n\\begin{equation*}\r\n\\frac{\\var(X_i(\\tau))}{\\tau}\r\n\\approx \\lim_{s \\to \\infty}\\frac{\\var(X_i(s))}{s}\r\n= \\frac{\\var(T_i)}{\\E^3(T_i)}\r\n= \\frac{2N}{{\\lambda^*}^2} \\left(\\frac{\\bar{\\lambda}}{2N}\\right)^3\r\n= \\frac{\\bar{\\lambda}^3}{4N^2{\\lambda^*}^2}\r\n\\end{equation*}\r\n\r\nHence we can say that:\r\n\\begin{equation*}\r\nX_i(\\tau) \\sim \\Normal\\left( \\frac{\\bar{\\lambda}}{2N}\\tau, \\frac{\\bar{\\lambda}^3}{4N^2{\\lambda^*}^2}\\tau \\right)\r\n\\end{equation*}\r\n\r\nIn the same interval of time $[t, t+\\tau]$, the number of disassemblies, denoted by $Y(\\tau)$ is Poisson with mean and variance $\\mu\\tau$.\r\nWhen $\\tau$ is large enough, this can also be approximated by a normal distribution with mean and variance $\\mu\\tau$.\r\nHence $Y(\\tau) \\sim \\Normal(\\mu\\tau,\\mu\\tau)$.\r\n\r\nWe can then write an expression for the change in length during the time interval $[t,t+\\tau]$:\r\n\\begin{equation*}\r\n\\delta N = N(t+\\tau) - N(t) = \\sum_{i=1}^M{X_i(\\tau)} - Y(\\tau)\r\n\\end{equation*}\r\n\r\nSince $X_i(\\tau)$ are almost i.i.d. and independent from $Y(\\tau)$, $\\delta N$ is a linear combination of mutually independent normal distributions and is therefore itself a normal distribution:\r\n\\begin{equation*}\r\n\\delta N \\sim \\Normal\\left( \\frac{M\\bar{\\lambda}\\tau}{2N} - \\mu\\tau, \\frac{M\\bar{\\lambda}^3\\tau}{4N^2{\\lambda^*}^2} + \\mu\\tau \\right)\r\n\\end{equation*}\r\n \r\nWhich can be rewritten as an SDE for $N(t)$:\r\n\r\n\\begin{equation*}\r\ndN(t) = \\left( \\frac{M\\bar{\\lambda}}{2N(t)} - \\mu \\right)dt + \\sqrt{ \\frac{M \\bar{\\lambda}^3}{4N^2(t){\\lambda^*}^2} + \\mu } \\phantom{.} dB(t)\r\n\\end{equation*}\r\n\r\nWhere $B(t)$ is Brownian motion.\r\n\r\nRecalling that we used a conversion from physical units of length to multiples of the segment length $a$, we can convert the SDE back to physical units of length ($dN(t) = dL(t)/a$, $(\\bar{\\lambda}) = (\\bar{v})/a$, $\\lambda^* = v^*/a$, $\\mu = V/a$)\r\n\r\n\\begin{equation*}\r\ndL(t) = \\left( \\frac{M\\bar{v}a}{2L(t)} - V \\right)dt + \\sqrt{ \\frac{M \\bar{v}^3a^3}{4L^2(t){v^*}^2} + aV } \\phantom{.} dB(t)\r\n\\end{equation*}\r\n\r\n\\subsection{SDE Simulation}\r\n\r\nTo compare the results predicted by the SDE to the results given by the (Non-Crowding) Monte Carlo simulation we use Euler's method to simulate the SDE trajectories.\r\n\r\nEuler's method for solving an ODE such as $dy(x) = f(y(x))dx$ consists of viewing the ODE as a difference equation\r\n\\[ y(x_n) - y(x_{n-1}) = f(y(x_{n-1}))\\cdot(x_n - x_{n-1}) \\]\r\nfor some constant step size $(x_n - x_{n-1})$.\r\nSimilarly, we can view the SDE as a difference equation of random variables, that is, for the SDE\r\n\\[ dN(t) = f(N(t))dt + g(N(t))dB \\]\r\nwe have a difference equation:\r\n\\[ N(t_n) - N(t_{n-1}) = f(N(t_{n-1}))\\cdot(t_n - t_{n-1}) + g(N(t_{n-1}))\\cdot(B(t_n) - B(t_{n-1})) \\]\r\nwhere $(B(t_n) - B(t_{n-1})) \\sim \\Normal(0, t_n - t_{n-1})$ by the properties of Brownian motion.\r\nThen by choosing a step size $(t_n - t_{n-1})$ and an initial condition $N(0)$ we can simulate the SDE by generating random numbers for the Brownian motion term and iteratively generating $N(t_n)$ for each $n$.\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[width=\\textwidth]{SDEtraj}\r\n\\caption{\r\nFour representative SDE trajectories generated using Euler's method and corresponding solutions to the ODE.\r\nThe four different trajectories start from four different initial lengths: 100, 1000, 1300, and 1900, running to a time limit of 50000.}\r\n\\label{fig:SDEtraj}\r\n\\end{figure}\r\n\r\nIn the same manner in which we could generate a distribution for the length of the flagellum at a given time by running the Monte Carlo trajectories repeatedly and recording final length, we generate a distribution for the length of the flagellum at a given time by simulating a large number of trajectories for the SDE.\r\n\r\n\\begin{figure}%[!htbp]\r\n\\centering\r\n\\includegraphics[height=3in]{SDEdist}\r\n\\caption{\r\nDistribution of final lengths given by the SDE simulation.\r\nThe initial length was set to $N(0)=700$ and the time limit was set to 15000 seconds.\r\n100 bin histogram for a sample size of 10000.\r\nMean: 1273.4\r\nStandard deviation: 25.6482 }\r\n\\label{fig:SDEens}\r\n\\end{figure}\r\n\r\n%Since the SDE suggests that the distribution is lognormal, and since the mean of the distribution is large, in finding how well the distributions agree, it is useful to approximate the distribution as normal, which allows us to compare confidence intervals for the mean and standard deviation of the distribution.\r\nSince the distributions produced by the models and the distribution predicted by the SDE resemble Gaussians, we used the Gaussian assumption to compute the confidence intervals for the means and standard deviations of the simulation results.\r\nThe distribution generated by the SDE simulation has a mean and standard deviation that is within the confidence intervals corresponding to distributions from the detailed stochastic model (see Table~\\ref{tab:ci}).\r\n\r\n\\section{Linear Noise Approximation}\r\n\r\nAlthough the SDE simulation can be used to get the variance of the stationary distribution of flagellum lengths given a specific set of parameters, we are interested in getting an expression for the variance analytically.\r\nFor this purpose, we approximate the SDE with a linear noise approximation.\r\n\r\nFirst we observe that near the equilibrium length, $\\bar{N}$, the diffusion due to the assembly rate is very small.\r\nRecall that $\\bar{N}=\\frac{\\bar\\lambda M}{2\\mu}$.\r\nThen:\r\n\r\n\\begin{align*}\r\n\\frac{M \\bar{\\lambda}^3}{4\\bar{N}^2{\\lambda^*}^2}\r\n&= \\frac{M \\bar{\\lambda}^3}{4{\\lambda^*}^2}\\left(\\frac{2\\mu}{\\bar\\lambda M}\\right)^2 \\\\\r\n&= \\frac{\\mu^2 \\bar\\lambda}{{\\lambda^*}^2 M} \\\\\r\n%\\frac{M \\bar{\\lambda}^3}{4\\bar{N}^2{\\lambda^*}^2}\r\n&\\ll \\mu\r\n\\end{align*}\r\nsince $\\mu$ is orders of magnitude smaller than $\\lambda_+$ and $\\lambda_-$, and since $\\frac{\\bar\\lambda}{\\lambda^*}$ is bounded.\r\n\r\nWe can then rewrite the SDE near $N = \\bar{N}$ as\r\n\\begin{equation*}\r\ndN(t)=A(N(t))dt+\\sqrt{\\mu}dB(t)\r\n\\end{equation*}\r\nwhere\r\n\\begin{equation*}\r\nA(N(t)) := \\left( \\frac{M\\bar{\\lambda}}{2N(t)} - \\mu \\right)\r\n\\end{equation*}\r\nThen let $\\triangle N(t) := N(t)-\\bar{N}$, which gives:\r\n\\begin{align*}\r\nd \\triangle N(t) = dN(t)\r\n&= A(N(t))dt + \\sqrt{\\mu}dB(t) \\\\\r\n&= A(\\bar{N} + \\triangle N(t))dt + \\sqrt{\\mu}dB(t)\r\n\\end{align*}\r\nTaylor expanding $A(\\bar{N} + \\triangle N(t))$ around $\\bar{N}$, and omitting terms after the second (since we are considering the case where $\\triangle N(t)$ is small):\r\n\\begin{equation*}\r\nd \\triangle N(t) \\approx\r\nA(\\bar{N}) + A'(\\bar{N}) \\triangle N(t)dt +  \\sqrt{\\mu}dB(t)\r\n\\end{equation*}\r\nObserving that\r\n\\begin{align*}\r\nA(\\bar{N})\r\n&= \\frac{M\\bar{\\lambda}}{2\\bar{N}} - \\mu \\\\\r\n&= \\frac{M\\bar{\\lambda}}{2} \\frac{2\\mu}{\\bar\\lambda M} - \\mu \\\\\r\n&= \\mu - \\mu \\\\\r\nA(\\bar{N}) &= 0\r\n\\end{align*}\r\nThe above gives us the following linear SDE for the perturbation:\r\n\\begin{equation*}\r\nd \\triangle N(t) =\r\n-\\frac{M\\bar\\lambda}{2\\bar{N}^2} \\triangle N(t)dt + \\sqrt{\\mu}dB(t)\r\n\\end{equation*}\r\n\r\nBy taking the expectation of both sides, using linearity of expectation, and noting that $\\E dB(t) = 0$ we get an ODE for $\\E \\triangle N(t)$:\r\n\\begin{equation*}\r\nd \\E \\triangle N(t) =\r\n-\\frac{M\\bar\\lambda}{2\\bar{N}^2} \\E( \\triangle N(t) )dt + \\sqrt{\\mu} \\E( dB(t) )\r\n\\end{equation*}\r\n\\begin{equation*}\r\n\\frac{d \\E( \\triangle N(t) )}{dt} +\r\n\\frac{M\\bar\\lambda}{2\\bar{N}^2} \\E( \\triangle N(t) )\r\n= 0\r\n\\end{equation*}\r\nSolving the equation gives:\r\n\\begin{equation*}\r\n\\E \\triangle N(t) = C \\exp \\left( -\\frac{M\\bar\\lambda}{2\\bar{N}^2} t \\right)\r\n\\end{equation*}\r\nTaking the limit gives:\r\n\\begin{equation*}\r\n\\lim_{t \\rightarrow \\infty} \\E \\triangle N(t) = 0\r\n\\end{equation*}\r\n\r\nSimilarly, we can get an ODE and a solution for $\\E( (\\triangle N(t))^2 )$ (see Appendix~\\ref{sec:deriv}).\r\nThis allows us to arrive at an expression for $\\var( N(t) )$ as $t \\rightarrow \\infty$, and noting that $\\E(N(t)) \\rightarrow \\bar{N}$:\r\n\r\n\\begin{align*}\r\n\\var( N(t) ) &= \\E( ( N(t) - \\E(N(t)) )^2 ) \\\\\r\n&= \\E( ( \\bar{N} + \\triangle N(t) - \\bar{N} )^2 ) \\\\\r\n&= \\E( (\\triangle N(t))^2 ) \\\\\r\n\\var( N(t) ) &\\rightarrow \\frac{M \\bar{\\lambda}}{4 \\mu}\r\n\\qquad \\textrm{as } t \\rightarrow \\infty\r\n\\end{align*}\r\n\r\nNote that the above shows that the variance of the stationary distribution is approximated to be half the mean.\r\nTable~\\ref{tab:ci} compares different data from the discrete model and nonlinear SDE simulations to the mean and variance predicted by this approximation through the use of confidence intervals.\r\nIt can be seen that the distributions are close, and in most cases their means and variances are in each other's confidence intervals.\r\n\r\n\\begin{table}%[!htbp]\r\n\\centering\r\n\\begin{tabular}{c|rrr|cc}\r\n Model & \\multicolumn{1}{c}{$N(0)$} & \\multicolumn{1}{c}{Time Limit}\r\n & \\multicolumn{1}{c}{Data} &\r\n \\multicolumn{2}{c}{95\\% Confidence Intervals for} \\\\\r\n & & \\multicolumn{1}{c}{(seconds)} & \\multicolumn{1}{c}{Points}\r\n & \\multicolumn{1}{c}{Mean} &\r\n \\multicolumn{1}{c}{Standard Deviation}\r\n\\\\ \\hline\r\n LNA & & & & 1272.7 & 25.2262 \\\\\r\n SDE & 100 & 15000 & 5000 & [1272.4, 1273.8] & [24.6917, 25.6790] \\\\\r\n SDE & 700 & 15000 & 100000 & [1273.1, 1273.4] & [25.1371, 25.3584]\\\\\r\n MAR & 100 & 15000 & 5000 & [1272.3, 1273.7] & [24.8236, 25.8162] \\\\\r\n MAR & 100 & 50000 & 3500 & [1271.1, 1272.7] & [24.5804, 25.7598] \\\\\r\n MAR & 1300 & 15000 & 5000 & [1271.6, 1273.0] & [24.7931, 25.7845] \\\\\r\n MAR & 1300 & 50000 & 2400 & [1272.1, 1274.1] & [24.4120, 25.8336]\r\n\r\n\\end{tabular}\r\n\\caption{Confidence intervals from various distributions.\r\nThe models are as follows:\r\nLNA---linear noise approximation (only the mean and the variance, as calculated above, are given);\r\nSDE---nonlinear SDE simulation;\r\nMAR---Markov Chain simulation.}\r\n\\label{tab:ci}\r\n\\end{table}\r\n\r\n\\section{Conclusion}\r\n\r\nWe see the discrete model for flagellar length that was based on a Markov Chain can be approximated well by a nonlinear SDE that showed that the mean flagellum length predicted by the ODE a can be further approximated by a linear SDE.\r\nThe linear SDE was used to show that as long as the mean flagellar length is significantly greater than the length added by each transporter, and as long as the degeneration rate is much lower than the rates at which transporters move, the stationary distribution of the flagellum length has a variance of about half the mean.\r\nThis also provides an example of an instance where a simple birth-death model constructed from an ODE is inadequate (since the birth-death model yields a distribution with equal mean and variance).\r\n\r\nIt should be noted that although in the Markov Chain model we assumed the waiting times for transporters to move from one point to the next to be exponentially distributed random variables, since the SDE approximation makes use of the Central Limit Theorem for Renewal Processes, this approximation still holds for a more general case where those waiting times have variances equal to their mean squared.\r\nThe process of approximation here can also be generalized further for waiting times of any given mean and variance, yielding SDEs in terms of those means and variances.\r\n\r\nHere we concentrated on the model's behavior near it's equilibrium.\r\nIt may be of interest to study how the model behaves at the other extreme, how fast it reaches its equilibrium, and what parameters affect these behaviors.\r\nIt would also be of interest to look for biological confirmation of the accuracy of this model (or the lack thereof).\r\n\r\n\\appendix\r\n\r\n\\section{Renewal Processes}\\label{sec:ren}\r\n\r\n\\begin{clthm}[Ross~\\cite{ross}, 7.3]\r\nLet $\\{N(t), t \\leq 0 \\}$ be a renewal process and let $\\mu$ and $\\sigma$ be, respectively, the mean and standard deviation of the interarrival distribution. Then the following holds:\r\n\r\n\\begin{equation*}\r\n\\lim_{t \\rightarrow \\infty} P \\left\\{\r\n\\frac{N(t)-t/\\mu}{\\sqrt{t\\sigma^2/\\mu^3}} < x\r\n\\right\\}\r\n= \\frac{1}{\\sqrt{2\\pi}} \\int_{-\\infty}^x e^{-x^2/2} dx\r\n\\end{equation*}\r\n\\end{clthm}\r\n\r\nNote that this means that as $t \\rightarrow \\infty$, $N(t)$ approaches a normal distribution with mean $\\frac{1}{\\mu}t$ and variance $\\frac{\\sigma^2}{\\mu^3}t$, or, equivalently:\r\n\\begin{equation*}\r\n\\lim_{t \\rightarrow \\infty} \\frac{\\E(N(t))}{t} = \\frac{1}{\\mu}\r\n\\end{equation*}\r\nand\r\n\\begin{equation*}\r\n\\lim_{t \\rightarrow \\infty} \\frac{\\var(N(t))}{t} = \\frac{\\sigma^2}{\\mu^3}\r\n\\end{equation*}\r\n\r\n\\section{ $\\E( (\\triangle N(t))^2 )$ derivation }\\label{sec:deriv}\r\n\r\nGiven the equation\r\n\\begin{equation*}\r\nd \\triangle N(t) =\r\n-\\frac{M\\bar\\lambda}{2\\bar{N}^2} \\triangle N(t)dt + \\sqrt{\\mu}dB(t)\r\n\\end{equation*}\r\nFirst, a change of notation is convenient.\r\nLet\r\n\\begin{align*}\r\nB_t &= B(t) \\\\\r\n\\xi_t &= \\triangle N(t) \\\\\r\n\\alpha &= -\\frac{M\\bar\\lambda}{2\\bar{N}^2} \\\\\r\n\\beta &= \\sqrt{\\mu}\r\n\\end{align*}\r\nGiving\r\n\\begin{equation*}\r\nd \\xi_t = \\alpha \\xi_t dt + \\beta dB_t\r\n\\end{equation*}\r\n\r\nAt this point we make use of the \\Ito Formula, in particular, the 1-dimensional \\Ito formula, in order to calculate $d(\\xi_t^2)$:\r\n\\begin{itoform}[{\\O}ksendal~\\cite{oksendal}, Theorem 4.1.2]\r\nFor an \\Ito process $\\xi_t$ given by\r\n\\begin{equation*}\r\nd \\xi_t = u_t \\xi_t dt + v_t dB_t\r\n\\end{equation*}\r\nLet $g(t,x) \\in C^2([0,\\infty) \\times \\mathbb{R})$ (i.e. $g$ is twice continuously differentiable on $[0,\\infty) \\times \\mathbb{R}$). Then\r\n\\begin{equation*}\r\n\\zeta_t = g(t,\\xi_t)\r\n\\end{equation*}\r\nis again an \\Ito process, and\r\n\\begin{equation*}\r\nd\\zeta_t = \\frac{\\partial g}{\\partial t}(t,\\xi_t)dt + \\frac{\\partial g}{\\partial x}(t, \\xi_t)d\\xi_t + \\frac{1}{2}\\frac{\\partial^2 g}{\\partial x^2}(t,\\xi_t) \\cdotp (d\\xi_t)^2\r\n\\end{equation*}\r\nwhere $(d\\xi_t)^2 = (d\\xi_t) \\cdotp (d\\xi_t)$ is computed according to the rules\r\n\\begin{equation*}\r\ndt \\cdotp dt = dt \\cdotp dB_t = dB_t \\cdotp dt = 0~, \\quad dB_t \\cdot dB_t = dt\r\n\\end{equation*}\r\n\\end{itoform}\r\n\r\nWe apply this formula to the particular case when $g(t,x) = x^2$, and we get:\r\n\\begin{align*}\r\nd \\zeta_t &= 0 dt + 2 \\xi_t d \\xi_t + \\frac{1}{2} 2 (d \\xi_t)^2 \\\\\r\n&= 2 \\xi_t (\\alpha \\xi_t dt + \\beta dB_t) + (\\alpha \\xi_t dt + \\beta dB_t)(\\alpha \\xi_t dt + \\beta dB_t) \\\\\r\n&= 2 \\alpha \\xi_t^2 dt + 2 \\beta \\xi dB_t + \\alpha^2 \\xi_t^2 (dt \\cdotp dt) + \\alpha \\beta \\xi_t (dt \\cdotp dB_t + dB_t \\cdotp dt) + \\beta^2 (dB_t \\cdot dB_t) \\\\\r\n&= 2 \\alpha \\zeta_t dt + 2 \\beta \\xi_t dB_t + \\beta^2 dt\r\n\\end{align*}\r\nTaking the expected value of both sides gives\r\n\\begin{equation*}\r\nd \\E( \\zeta_t ) = \\E( d \\zeta_t )\r\n= 2 \\alpha \\E( \\zeta_t )dt + \\beta^2 dt\r\n\\end{equation*}\r\nThe general solution to the resulting ODE is\r\n\\begin{equation*}\r\n\\E \\zeta_t = C e^{-2\\alpha t} - \\frac{\\beta^2}{2\\alpha}\r\n\\end{equation*}\r\nThen we can finally arrive at an expression for $\\lim_{t \\rightarrow \\infty} \\E( (\\triangle N(t))^2 )$:\r\n\\begin{align*}\r\n\\lim_{t \\rightarrow \\infty} \\E( (\\triangle N(t))^2 )\r\n&= \\lim_{t \\rightarrow \\infty} \\E \\zeta_t \\\\\r\n&= - \\frac{\\beta^2}{2\\alpha} \\\\\r\n&= \\frac{\\mu}{2}\\frac{2\\bar{N}^2}{M\\bar\\lambda} \\\\\r\n&= \\frac{\\mu}{M\\bar\\lambda} \\bar{N}^2 \\\\\r\n&= \\frac{\\mu}{M\\bar\\lambda} \\left( \\frac{\\bar\\lambda M}{2\\mu} \\right)^2 \\\\\r\n&= \\frac{M\\bar\\lambda}{4\\mu}\r\n\\end{align*}\r\n\r\n\\input{bibliography.tex}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "f449fdfe7c0a764826bf4bb1457a7c4ee3febd31", "size": 38479, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Senior Thesis/Report.tex", "max_stars_repo_name": "sverchkov/flagellar-growth-model", "max_stars_repo_head_hexsha": "b1886180d7be11932882b6a95d7a4e4d12c965a5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Senior Thesis/Report.tex", "max_issues_repo_name": "sverchkov/flagellar-growth-model", "max_issues_repo_head_hexsha": "b1886180d7be11932882b6a95d7a4e4d12c965a5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Senior Thesis/Report.tex", "max_forks_repo_name": "sverchkov/flagellar-growth-model", "max_forks_repo_head_hexsha": "b1886180d7be11932882b6a95d7a4e4d12c965a5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.3689320388, "max_line_length": 529, "alphanum_fraction": 0.7094259206, "num_tokens": 11955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.43857676454415295}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[english]{babel} % for hyphenation dictionary\n%\\setdefaultlanguage{english} % polyglossia command for use with XeTeX / LuaTeX\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n% title information\n\\title{Phys 221A -- Quantum Mechanics -- Lec16}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{26}{11}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{Rotations and Angular Momentum in Quantum Mechanics}\n\n\\subsection{Group theory}\n\nOrthogonal transformations are Euclidean transformations which do not change distances, i.e. rotations and reflections. Suppose we have a transformation $R$ taking\n\\begin{eqn}\n\\v x \\mapsto \\v x' = R \\cdot \\v x.\n\\end{eqn}\nFor the transformation to be orthogonal, we must have\n\\begin{eqn}\n\\norm{\\v x} = \\sqrt{x_i x_i} = \\norm{\\v x'} = \\sqrt{R_{ij} x_j R_{ij'} x_{j'}},\n\\end{eqn}\nwhich implies that\n\\begin{eqn}\nR_{ij} R_{ij'} = \\delta_{jj'}.\n\\end{eqn}\nIn other words, we have\n\\begin{eqn}\nR^\\top R = 1 \\qquad\n\\implies \\qquad\nR^\\top = R\\inv,\n\\end{eqn}\nso $R$ is an orthogonal matrix. Thus rotations and reflections are parametrized by orthogonal matrices. The set of all orthogonal matrices in 3 dimensions is a \\textit{group} called $O(3)$. \n\n\\begin{definition}\nA \\textit{group} is a set $G = \\set{g_\\alpha}$ with an operation $*$ with the following properties. \n\\begin{itemize}\n\\item (Identity) There is an identity $1 \\in G$ such that for all $g_\\alpha \\in G$ we have $g_\\alpha * 1 = 1 * g_\\alpha = g_\\alpha$. \n\\item (Closure) For each $g_\\alpha, g_\\beta \\in G$, we have $g_\\alpha * g_\\beta \\in G$.\n\\item (Invertibility) For each $g_\\alpha \\in G$ we have an inverse $g_\\alpha\\inv \\in G$ such that $g_\\alpha * g_\\alpha\\inv = g_\\alpha\\inv * g_\\alpha = 1$.\n\\item (Associativity) For $g_\\alpha, g_\\beta, g_\\gamma \\in G$, we have $(g_\\alpha * g_\\beta) * g_\\gamma = g_\\alpha * (g_\\beta * g_\\gamma)$.\n\\end{itemize}\nIn general, $g_\\alpha * g_\\beta \\neq g_\\beta * g_\\alpha$, i.e. group elements must not necessarily commute. If all elements commute, the group is called \\textit{Abelian}. A subset of a group $G$ that is itself a group is called a \\textit{subgroup} of $G$. \n\\end{definition}\n\nNotice that for an orthogonal matrix $R$, we have $\\det R = \\pm 1$. The subgroup of $O(3)$ with determinant 1 is the group of proper rotations $SO(3)$. If $R \\in O(3)$ and $\\det R = -1$ then we call $R$ an improper rotation. If furthermore $R^2 = 1$, then $R$ is a reflection. Note that in three dimensions, parity is an improper rotation, but in two dimensions, parity is a proper rotation---it's just a rotation by $\\pi$. In general, parity is a proper rotation in even dimensions and improper in odd dimensions. \n\nFor now we will consider rotations in three dimensions. A rotation $R_z (\\phi)$ about the $z$-axis can be written\n\\begin{eqn}\nR_z (\\phi) = \n\\begin{pmatrix}\n\\cos\\phi & -\\sin\\phi & 0 \\\\\n\\sin\\phi & \\cos\\phi & 0 \\\\\n0 & 0 & 1\n\\end{pmatrix}.\n\\end{eqn}\nFor an infinitesimal angle $\\epsilon$ we have\n\\begin{eqn}\nR_z (\\epsilon) = \n\\begin{pmatrix}\n1 - \\epsilon^2 / 2 & -\\epsilon & 0 \\\\\n\\epsilon & 1 - \\epsilon^2 / 2 & 0 \\\\\n0 & 0 & 1\n\\end{pmatrix}\n+ \\bigO(\\epsilon^2).\n\\end{eqn}\nSimilarly for the other axes the infinitesimal rotations are (to quadratic order)\n\\begin{eqn}\nR_x (\\epsilon) = \n\\begin{pmatrix}\n1 & 0 & 0 \\\\\n0 & 1 - \\epsilon^2 / 2 & -\\epsilon \\\\\n0 & \\epsilon & 1 - \\epsilon^2 / 2 \\\\\n\\end{pmatrix}, \\qquad\nR_y (\\epsilon) =\n\\begin{pmatrix}\n1 - \\epsilon^2 / 2 & 0 & \\epsilon \\\\\n0 & 1 & 0 \\\\\n-\\epsilon & 0 & 1 - \\epsilon^2 / 2 \\\\\n\\end{pmatrix}.\n\\end{eqn}\nIf we look at the commutators of the rotations about the axes, we find\n\\begin{eqn}\n[R_x(\\epsilon), R_y(\\epsilon)] = R_z(\\epsilon^2) - 1 = \n\\begin{pmatrix}\n0 & -\\epsilon^2 & 0 \\\\\n\\epsilon^2 & 0 & 0 \\\\\n0 & 0 & 0\n\\end{pmatrix}.\n\\end{eqn}\nOne can generalize to other permutations of the elementary rotations by cyclic permutation of $(xyz)$. These commutator relations will be useful in our applications to quantum mechanics. \n\n\n\\subsection{Angular momentum in QM}\n\nRecall that the infinitesimal evolution operator can be written\n\\begin{eqn}\nU(\\epsilon) = 1 - \\frac{i}{\\hbar} \\epsilon H + \\bigO(\\epsilon^2),\n\\end{eqn}\nso we call $H$ the \\textit{generator of time evolution}. From now on we will assume that $H$ is time-independent. We can recover the full time evolution by repeatedly composing infinitesimal time evolutions\n\\begin{eqn}\nU(t) = \\lim_{n \\rightarrow \\infty} \\left[ U(t/n) \\right]^n.\n\\end{eqn}\nNow, recall the identity\n\\begin{eqn}\ne^\\phi = \\lim_{n \\rightarrow \\infty} \\left( 1 + \\frac{\\phi}{n} \\right)^n,\n\\end{eqn}\nwhich also works for operators so that we have\n\\begin{eqn}\nU(t) = \\lim_{n \\rightarrow \\infty} \\left( 1 - \\frac{i}{\\hbar} \\, \\frac{t}{n} H \\right)^n = e^{i t H / \\hbar}.\n\\end{eqn}\nThus we have\n\\begin{eqn}\nH = i \\hbar \\partial_t U(t).\n\\end{eqn}\n\nSimilarly, momentum is the generator of translations,\n\\begin{eqn}\nT (\\v \\epsilon) = 1 - \\frac{i}{\\hbar} \\v \\epsilon \\cdot \\v p = 1 - \\v \\epsilon \\cdot \\v \\nabla,\n\\end{eqn}\nsince $\\v p = - i \\hbar \\v \\nabla$. Thus similarly we have\n\\begin{eqn}\n\\v p = i \\hbar \\v \\nabla_{\\v x} T(\\v x).\n\\end{eqn}\nWe can now define the angular momentum operator $\\v J$ in quantum mechanics in a similar way, as the generator of rotations\n\\begin{eqn}\n\\v J = i \\hbar \\v \\nabla_{\\v \\phi} R(\\v \\phi)\n\\end{eqn}\nwhere $R(\\v \\phi)$ is a rotation about $\\uv \\phi$ by angle $\\abs{\\v \\phi}$. \n\nQuantum mechanically, the general state of a particle in some rotation state is described by a ket\n\\begin{eqn}\n\\ket{\\alpha} = \\ket{\\sigma} \\otimes \\ket{\\psi},\n\\end{eqn}\nwhere $\\ket{\\psi}$ is the usual $L_2$ Euclidean wavefunction giving dynamics in real space, while $\\ket{\\sigma}$ is a spin ket, or spinor, giving us dynamics in ``spin space''. In the absence of the spinor component we just have the Euclidean wavefunction. Furthermore, since $\\v L = \\v r \\times \\v p$ and $\\v p = -i\\hbar \\v \\nabla$, an infinitesimal rotation can be written\n\\begin{eqn}\nR(\\v \\epsilon) = 1 - \\frac{i}{\\hbar} \\v \\epsilon \\cdot \\v L = 1 - \\v \\epsilon \\cdot (\\v r \\times \\v \\nabla).\n\\end{eqn}\nIn general, when we include the spin structure the angular momentum $\\v J$ is decomposed\n\\begin{eqn}\n\\v J = \\v L + \\v S,\n\\end{eqn}\nwhere $\\v L$ is the ``orbital'' angular momentum and $\\v S$ is the ``spin'' angular momentum. \n\nThe only remaining task is to construct the (irreducible) representations of $SO(3)$. We define a \\textit{representation} $D(g)$ of a group element $g \\in G$ if $D$ is a homomorphism, i.e. given $g, h \\in G$ we have\n\\begin{eqn}\nD(g*h) = D(g) * D(h).\n\\end{eqn}\nIn the case of spin rotations, given a spin ket $\\ket{\\sigma}$ we have under rotations\n\\begin{eqn}\n\\ket{\\sigma} \\rightarrow D(R) \\ket{\\sigma}\n\\end{eqn}\nIt turns out that the irreducible representations of $D(R)$ are $N \\times N$ matrices with $N = 2s + 1$ where $s = 0, \\frac{1}{2}, 1, \\frac{3}{2}, \\dots$ is the spin of the particle. In terms of elementary particles, bosons have integer-valued spin while fermions have half-integer-valued spin. \n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "97d368b8cdd1b73fe8adff329eff5dc0ee54db04", "size": 7229, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quantum/lec16.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "quantum/lec16.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quantum/lec16.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.0290697674, "max_line_length": 515, "alphanum_fraction": 0.6861253285, "num_tokens": 2400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.43857675792497747}}
{"text": "% Created 2021-09-02 Thu 17:27\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=169, usenames, dvipsnames]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\usepgfplotslibrary{groupplots}\n\\newcommand*{\\shift}{\\operatorname{q}}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.6,0.1}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{\\today}\n\\title{Process Automation Laboratory - PID control}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Process Automation Laboratory - PID control},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section{Repetition - Second-order model critically damped}\n\\label{sec:orgd8c85bb}\n\\begin{frame}[label={sec:org8c495f4}]{Second-order models}\n\\end{frame}\n\\begin{frame}[label={sec:org4130cf8}]{Two first-order models in series}\n\\begin{center}\n\\begin{tikzpicture}\n  \\node {\\includegraphics[width=0.4\\linewidth]{../../figures/tank-with-hole-no-variables}};\n  \\node at (5.3,-2.05) {\\includegraphics[width=0.4\\linewidth]{../../figures/tank-with-hole-no-variables}};\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[block, right of=input, node distance=20mm] (plant1)  {$G_1(s)$};\n    \\node[block, right of=plant1, node distance=26mm] (plant2)  {$G_2(s)$};\n    \\node[coordinate, right of=plant2, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$u(t)$} (plant1);\n    \\draw[->] (plant1) -- node[coordinate, ] (mp) { } (plant2);\n    \\draw[->] (plant2) -- node[above, near end] {$y(t)$} (output);\n    \\draw[red] (plant1.south west) ++(-4mm,-10mm) rectangle ++(49mm, 20mm);\n\n    \\node[red,below of=mp, node distance=10mm] {$G(s) = G_1(s)G_2(s)$};\n  \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org51bc4e6}]{Fitting second-order critically-damped model}\n\\alert{Model with two identical time-constants.}\nAssuming model \n\\[ \\textcolor{green!50!black}{Y(s)} = \\frac{K}{(s\\tau + 1)^2}\\textcolor{blue!80!black}{U(s)} \\quad \\overset{U(s) = \\frac{u_f}{s}}{\\Longrightarrow} \\quad \\textcolor{green!50!black}{y(t)} = u_f K\\Big( 1 - (1+\\frac{t}{\\tau}\\big)\\mathrm{e}^{-\\frac{t}{\\tau}}\\Big)u_H(t)\\]\n\\def\\Tcnst{2}\n\\def\\tdelay{0.0}\n\\def\\ggain{2}\n\\def\\uampl{0.8}\n\\pgfmathsetmacro{\\yfinal}{\\uampl*\\ggain}\n\\pgfmathsetmacro{\\ytwo}{\\yfinal*(1-2*exp(-1))}\n\\pgfmathsetmacro{\\ytwofactor}{(1-2*exp(-1))}\n\\pgfmathsetmacro{\\two}{\\tdelay + \\Tcnst}\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\begin{axis}[\n    width=14cm,\n    height=4.5cm,\n    grid = both,\n    xtick = {0, \\two},\n    xticklabels = {0,  $\\tau$},\n    ytick = {0, \\ytwo, \\uampl, \\yfinal},\n    yticklabels = {0, $\\ytwofactor y_f$, $u_f$, $y_f$},\n    xmin = -0.2,\n    clip = false,\n    %minor y tick num=9,\n    %minor x tick num=9,\n    %every major grid/.style={red, opacity=0.5},\n    ]\n      \\addplot [thick, green!50!black, no marks, domain=0:11, samples=100] {\\uampl*\\ggain*(x>\\tdelay)*(1 - (1+x/\\Tcnst)*exp(-(x-\\tdelay)/\\Tcnst)} node [coordinate, pos=0.9, pin=-90:{$y(t)$}] {};\n      \\addplot [const plot, thick, blue!80!black, no marks, domain=-1:11, samples=100] coordinates {(-1,0) (0,0) (0,\\uampl) (11,\\uampl)} node [coordinate, pos=0.9, pin=-90:{$u(t)$}] {};\n      \\node at (axis cs: 11, -0.3) {$t$};\n    \\end{axis}\n  \\end{tikzpicture}\n\\end{center}\n\n\\[ y_f = \\lim_{t\\to\\infty} y(t) = u_f K \\quad \\Rightarrow \\quad K = \\frac{y_f}{u_f}. \\]\n\\end{frame}\n\n\n\\section{PID parameter intuition}\n\\label{sec:org9124c70}\n\\begin{frame}[label={sec:org21ee677}]{Feedback control}\n   \\begin{center}\n   \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n  { \n  \\node[coordinate] (input) {};\n  \\node[sumnode, right of=input] (sum) {\\tiny $\\sum$};\n  \\node[block, right of=sum, node distance=2.6cm] (reg) {$F(s)$};\n  \\node[block, right of=reg, node distance=2.6cm] (plant) {$G(s)$};\n  \\node[coordinate, right of=plant, node distance=2cm] (output) {};\n  \\node[coordinate, below of=plant, node distance=12mm] (feedback) {};\n \n  \\draw[->] (plant) -- node[coordinate, inner sep=0pt] (meas) {} node[near end, above] {$y(t)$} (output);\n  \\draw[->] (meas) |- (feedback) -| node[very near end, left] {$-$} (sum);\n  \\draw[->] (input) -- node[very near start, above] {$r(t)$} (sum);\n  \\draw[->] (sum) -- node[above] {$e(t)$} (reg);\n  \\draw[->] (reg) -- node[above] {$u(t)$}(plant);\n}\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\n\n\\begin{frame}[label={sec:org2fb2529}]{The PID controller}\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt},scale=0.8, every node/.style={scale=0.8}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum, node distance=20mm] (pid)  {$F(s)$};\n    \\node[coordinate, below of=sum, node distance=12mm] (feedback) {};\n    \\node[coordinate, right of=pid, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$r(t)$} (sum);\n    \\draw[->] (sum) -- node[above] {$e(t)$} (pid);\n    \\draw[->] (pid) -- node[above, near end] {$u(t)$} (output);\n    \\draw[->] (feedback) -- node[left, near start] {$y(t)$} node[right, pos=0.95] {-} (sum);\n  \\end{tikzpicture}\n\\end{center}\n\n\\alert{Parallel form (ISA)}\n\\[   F(s) &= k_c\\left( 1 + \\frac{1}{\\tau_i s} + \\tau_d s\\right) \\]\n\n\\alert{Series form}\n\\[F(s) = K_c \\left( \\frac{ \\tau_I s + 1}{\\tau_I s} \\right) (\\tau_D s + 1) \n= \\underbrace{\\frac{K_c(\\tau_I + \\tau_D)}{\\tau_I}}_{k_c} \\left(1 + \\frac{1}{\\underbrace{(\\tau_I + \\tau_D)}_{\\tau_i} s} + \\underbrace{\\frac{\\tau_I\\tau_D}{\\tau_I + \\tau_D}}_{\\tau_d}s \\right) \\]\n\\end{frame}\n\n\n\\begin{frame}[label={sec:orgae39394}]{The PID - Parallel form}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.6,0.1}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[color=iic,block, right of=sum, node distance=28mm] (ii)  {$\\frac{1}{\\tau_is}$};\n    \\node[color=ppc, coordinate, above of=ii, node distance=10mm] (pp)  {};\n    \\node[color=ddc,block, below of=ii, node distance=10mm] (dd)  {$\\tau_ds$};\n    \\node[sumnode, right of=ii, node distance=20mm] (sum2) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum2, node distance=20mm] (gain)  {$k_c$};\n    \\node[coordinate, below of=sum, node distance=12mm] (feedback) {};\n    \\node[coordinate, right of=gain, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$r(t)$} (sum);\n    \\draw[->] (sum) -- node[above, pos=0.2] {$e(t)$} node[coordinate] (mm) {}  (ii);\n    \\draw[->] (gain) -- node[above, near end] {$u(t)$} (output);\n    \\draw[->] (feedback) -- node[left, near start] {$y(t)$} node[right, pos=0.95] {-} (sum);\n    \\draw[->, color=ppc] (mm) |- (pp) -| node[right,] {$u_P(t)$} (sum2);\n    \\draw[->, color=ddc] (mm) |- (dd) -| node[right,] {$u_D(t)$} (sum2);\n    \\draw[->, color=iic] (ii)  -- node[above,] {$u_I(t)$} (sum2);\n    \\draw[->] (sum2) -- node[above, near end] {} (gain);\n\n  \\end{tikzpicture}\n\\end{center}\n\n\\begin{align*}\nu(t) &= k_c\\Big( \\textcolor{ppc}{e(t)} + \\textcolor{iic}{\\frac{1}{\\tau_i} \\int_0^{t} e(\\xi) d\\xi} + \\textcolor{ddc}{\\tau_d \\frac{d}{dt} e(t)} \\Big)\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}[label={sec:orga5afc99}]{The PID - Parallel form, modified D-part}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.6,0.1}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[color=iic,block, right of=sum, node distance=28mm] (ii)  {$\\frac{1}{\\tau_is}$};\n    \\node[color=ppc, coordinate, above of=ii, node distance=10mm] (pp)  {};\n    \\node[color=ddc,block, below of=ii, node distance=10mm] (dd)  {$\\tau_ds$};\n    \\node[sumnode, right of=ii, node distance=20mm] (sum2) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum2, node distance=20mm] (gain)  {$k_c$};\n    \\node[coordinate, below of=sum, node distance=12mm] (feedback) {};\n    \\node[coordinate, right of=gain, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$r(t)$} (sum);\n    \\draw[->] (sum) -- node[above, pos=0.2] {$e(t)$} node[coordinate] (mm) {}  (ii);\n    \\draw[->] (gain) -- node[above, near end] {$u(t)$} (output);\n    \\draw[->] (feedback) -- node[left, near start] {$y(t)$} node[right, pos=0.95] {-} (sum);\n    \\draw[->, color=ppc] (mm) |- (pp) -| node[right,] {$u_P(t)$} (sum2);\n    \\draw[->, color=ddc] (feedback |- dd) -- node[above, pos=0.95] {-} (dd);\n    \\draw[->, color=ddc] (dd) -| node[right,] {$u_D(t)$} (sum2)  ;\n    \\draw[->, color=iic] (ii)  -- node[above,] {$u_I(t)$} (sum2);\n    \\draw[->] (sum2) -- node[above, near end] {} (gain);\n\n  \\end{tikzpicture}\n\\end{center}\n\n\\[    u(t) = k_c\\Big( \\textcolor{ppc}{e(t)} + \\textcolor{iic}{\\overbrace{\\frac{1}{\\tau_i} \\int_0^{t} e(\\xi) d\\xi}^{u_I(t)}} + \\textcolor{ddc}{ \\underbrace{\\tau_d \\frac{d}{dt} \\big(-y(t)\\big)}_{u_D(t)}} \\Big) \\]\n\\end{frame}\n\n\\begin{frame}[label={sec:org320807c}]{The PID - Parallel form}\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}, scale=0.6, every node/.style={scale=0.6}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[color=iic,block, right of=sum, node distance=28mm] (ii)  {$\\frac{1}{\\tau_is}$};\n    \\node[color=ppc, coordinate, above of=ii, node distance=10mm] (pp)  {};\n    \\node[color=ddc,block, below of=ii, node distance=10mm] (dd)  {$\\tau_ds$};\n    \\node[sumnode, right of=ii, node distance=20mm] (sum2) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum2, node distance=20mm] (gain)  {$k_c$};\n    \\node[coordinate, below of=sum, node distance=12mm] (feedback) {};\n    \\node[coordinate, right of=gain, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$r(t)$} (sum);\n    \\draw[->] (sum) -- node[above, pos=0.2] {$e(t)$} node[coordinate] (mm) {}  (ii);\n    \\draw[->] (gain) -- node[above, near end] {$u(t)$} (output);\n    \\draw[->] (feedback) -- node[left, near start] {$y(t)$} node[right, pos=0.95] {-} (sum);\n    \\draw[->, color=ppc] (mm) |- (pp) -| node[right,] {$u_P(t)$} (sum2);\n    \\draw[->, color=ddc] (feedback |- dd) -- node[above, pos=0.95] {-} (dd) -| node[right,] {$u_D(t)$}   (sum2);\n    \\draw[->, color=iic] (ii)  -- node[above,] {$u_I(t)$} (sum2);\n    \\draw[->] (sum2) -- node[above, near end] {} (gain);\n\n  \\end{tikzpicture}\n  \\small\n  \\(  u(t) = k_c\\Big( \\textcolor{ppc}{e(t)} + \\textcolor{iic}{\\overbrace{\\frac{1}{\\tau_i} \\int_0^{t} e(\\xi) d\\xi}^{u_I(t)}} + \\textcolor{ddc}{ \\underbrace{\\tau_d \\frac{d}{dt} \\big(-y(t)\\big)}_{u_D(t)}} \\Big)\\)\n\\end{center}\n\n   \\begin{center}\n   \\def\\TT{1}\n   \\begin{tikzpicture}\n   \\begin{axis}[\n    clip=false,\n    width=14cm,\n    height=4.5cm,\n    ylabel={},\n    xlabel={$t$},\n    ymax = 2,\n    ymin = -0.5,\n    ]\n      \\addplot[black, no marks, domain=-0.1:8, samples=200] {(x>0)*(1 - (1+x/\\TT)*exp(-x/\\TT)} node[coordinate, pin=-20:{$y(t)$}, pos=0.4] {};\n      \\addplot[magenta!70!black, no marks, domain=-0.1:8, samples=200] coordinates {(-0.1, 0) (0,0) (0,1) (8,1)} node[coordinate, pin=90:{$r(t)$}, pos=0.4] {};\n    \\end{axis}\n\n \\end{tikzpicture}\n\\end{center}\n\\alert{Activity} Sketch the error signal \\(e(t)\\), the derivative signal \\(u_D(t)\\) and the integral signal \\(u_I(t)\\) (use \\(\\tau_i=\\tau_d=1\\))\n\\end{frame}\n\n\\begin{frame}[label={sec:org0429488}]{The PID - Parallel form, solution}\n\\end{frame}\n\\begin{frame}[label={sec:orgb2e7e1a}]{The PID - Parallel form, solution}\n\\(u(t) = k_c\\Big( \\textcolor{ppc}{e(t)} + \\textcolor{iic}{\\overbrace{\\frac{1}{\\tau_i} \\int_0^{t} e(\\xi) d\\xi}^{u_I(t)}} + \\textcolor{ddc}{ \\underbrace{\\tau_d \\frac{d}{dt} \\big(-y(t)\\big)}_{u_D(t)}} \\Big)\\)\n   \\begin{center}\n   \\def\\TT{1}\n   \\begin{tikzpicture}\n   \\begin{axis}[\n    clip=false,\n    width=14cm,\n    height=5cm,\n    ylabel={},\n    xlabel={$t$},\n    ymax = 2,\n    ]\n      \\addplot[black, no marks, domain=-0.1:8, samples=200] {(x>0)*(1 - (1+x/\\TT)*exp(-x/\\TT)} node[coordinate, pin=-20:{$y(t)$}, pos=0.4] {};\n      \\addplot[magenta!70!black, no marks, domain=-0.1:8, samples=200] coordinates {(-0.1, 0) (0,0) (0,1) (8,1)} node[coordinate, pin=90:{$r(t)$}, pos=0.21] {};\n      \\addplot[color=ppc, no marks, domain=0:8, samples=200] {(x>=0)*( (1+x/\\TT)*exp(-x/\\TT)} node[coordinate, pin=20:{$e(t)$}, pos=0.7] {};\n      \\addplot[color=iic, no marks, domain=-0.1:8, samples=200] {(x>0)*(2*(1-exp(-x/\\TT)) - \\x/\\TT*exp(-x/\\TT))} node[coordinate, pin=-20:{$u_I(t)$}, pos=0.6] {};\n      \\addplot[color=ddc, no marks, domain=-0.1:8, samples=200] {(x>0)*(-\\x/\\TT*exp(-x/\\TT))} node[coordinate, pin=-20:{$u_D(t)$}, pos=0.4] {};\n    \\end{axis}\n\n \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org586fa5e}]{The PID - practical form}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.5,0.1}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[color=iic,block, right of=sum, node distance=28mm] (ii)  {$\\frac{1}{\\tau_is}$};\n    \\node[color=ppc, coordinate, above of=ii, node distance=10mm] (pp)  {};\n    \\node[color=ddc,block, below of=ii, node distance=13mm] (dd)  {$\\frac{\\tau_ds}{\\frac{\\tau_d}{N}s + 1}$};\n    \\node[sumnode, right of=ii, node distance=20mm] (sum2) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum2, node distance=20mm] (gain)  {$k_c$};\n    \\node[coordinate, below of=sum, node distance=12mm] (feedback) {};\n    \\node[coordinate, right of=gain, node distance=20mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {$r(t)$} (sum);\n    \\draw[->] (sum) -- node[above, pos=0.2] {$e(t)$} node[coordinate] (mm) {}  (ii);\n    \\draw[->] (gain) -- node[above, near end] {$u(t)$} (output);\n    \\draw[->] (feedback) -- node[left, near start] {$y(t)$} node[right, pos=0.95] {-} (sum);\n    \\draw[->, color=ppc] (mm) |- (pp) -| node[right,] {$u_P(t)$} (sum2);\n    \\draw[->, color=ddc] (feedback |- dd) -- node[above, pos=0.95] {-} (dd);\n    \\draw[->, color=ddc] (dd) -| node[right,] {$u_D(t)$} (sum2)  ;\n    \\draw[->, color=iic] (ii)  -- node[above,] {$u_I(t)$} (sum2);\n    \\draw[->] (sum2) -- node[above, near end] {} (gain);\n\n  \\end{tikzpicture}\n\\end{center}\n\nThe parameter \\(N\\) is chosen to limit the influence of noisy measurements. Typically,\n\\[  3 < N < 10 \\]\n\\end{frame}\n\n\\section{PID tuning - (Smith and Corripio) Ziegler Nichols}\n\\label{sec:orga158d8d}\n\\begin{frame}[label={sec:orgd1f6a5d}]{PID tuning}\n\\end{frame}\n\\begin{frame}[label={sec:org71a4d7d}]{Method by Smith \\& Corripio using table by Ziegler-Nichols}\n\\small\n\nGiven process model (fitted to response of the system) \\[ G(s) = K \\frac{\\mathrm{e}^{-s\\theta}}{\\tau s + 1} \\] and PID controller\n   \\[ F(s) = k_c\\left( 1 + \\frac{1}{\\tau_i s} + \\tau_d s\\right) \\]\n   Choose the PID parameters according to the following table (Ziegler-Nichols, 1943)\n   \\begin{center}\n   \\setlength{\\tabcolsep}{20pt}\n   \\renewcommand{\\arraystretch}{1.5}\n   \\begin{tabular}{llll}\n   Controller & \\(k_c\\) & \\(\\tau_i\\) & \\(\\tau_d\\)\\\\\n  \\hline\\hline\n  P & \\(\\frac{\\tau}{\\theta K}\\) &  & \\\\\n  PI & \\(\\frac{0.9\\tau}{\\theta K}\\) & \\(\\frac{\\theta}{0.3}\\) & \\\\\n  PID & \\(\\frac{1.2\\tau}{\\theta K}\\) & \\(2\\theta\\) & \\(\\frac{\\theta}{2}\\)\\\\\n  \\hline\n\\end{tabular}\n\\end{center}\n\nGives good control for \\[0.1 < \\frac{\\theta}{\\tau} < 0.6.\\]\n\\end{frame}\n\n\n\n\\section{SIMC}\n\\label{sec:org627d95f}\n\n\\begin{frame}[label={sec:org62fb5a1}]{SIMC-PID tuning rule}\n[ SIMC stands for \\emph{SIMple Control} or \\emph{Skogestad Internal Model Control} ]\n   \\begin{center}\n   \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}scale=0.5, every node/.style={scale=0.5}]\n  { \n  \\node[coordinate] (input) {};\n  \\node[sumnode, right of=input] (sum) {\\tiny $\\sum$};\n  \\node[block, right of=sum, node distance=2.6cm] (reg) {$F(s)$};\n  \\node[block, right of=reg, node distance=2.6cm] (plant) {$G(s)$};\n  \\node[coordinate, right of=plant, node distance=2cm] (output) {};\n  \\node[coordinate, below of=plant, node distance=12mm] (feedback) {};\n \n  \\draw[->] (plant) -- node[coordinate, inner sep=0pt] (meas) {} node[near end, above] {$y(t)$} (output);\n  \\draw[->] (meas) |- (feedback) -| node[very near end, left] {$-$} (sum);\n  \\draw[->] (input) -- node[very near start, above] {$r(t)$} (sum);\n  \\draw[->] (sum) -- node[above] {$e(t)$} (reg);\n  \\draw[->] (reg) -- node[above] {$u(t)$}(plant);\n}\n\\end{tikzpicture}\n\\end{center}\n\nGiven model of the process and desired closed-loop system \\[G(s) = K \\frac{\\mathrm{e}^{-s\\theta}}{(\\tau_1 s + 1)(\\tau_2 s + 1)}, \\quad \\tau_1 \\ge \\tau_2; \\qquad G_c(s) = \\frac{\\mathrm{e}^{-s\\theta}}{\\tau_c s + 1} \\] Good robustness is obtained with PID controller\n\n\\[F(s) = K_c \\left( \\frac{ \\tau_I s + 1}{\\tau_I s} \\right) (\\tau_d s + 1) \n= \\frac{K_c(\\tau_I + \\tau_d)}{\\tau_I} \\left(1 + \\frac{1}{(\\tau_I + \\tau_D) s} + \\frac{\\tau_I\\tau_D}{\\tau_I + \\tau_D}s \\right) \\]\nwith \n\\[ K_c = \\frac{\\tau_1}{K(\\tau_c + \\theta)}, \\qquad \\tau_I = \\min\\{\\tau_1, 4(\\tau_c + \\theta)\\}, \\qquad \\tau_d = \\tau_2 \\]\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "f76fc801550275fe14153b3853d5092abbe30897", "size": 18297, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pid/slides/lecture-pid.tex", "max_stars_repo_name": "kjartan-at-tec/mr2015", "max_stars_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pid/slides/lecture-pid.tex", "max_issues_repo_name": "kjartan-at-tec/mr2015", "max_issues_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pid/slides/lecture-pid.tex", "max_forks_repo_name": "kjartan-at-tec/mr2015", "max_forks_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8571428571, "max_line_length": 266, "alphanum_fraction": 0.6125047822, "num_tokens": 7108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.43857675727018297}}
{"text": "\\documentclass[12pt]{article}\n    \\usepackage{mathtools}\n    \\usepackage[hidelinks]{hyperref}\n    \\usepackage{color}\n    \\usepackage{fancyref}\n    \\usepackage{lastpage}\n    \\usepackage{fancyhdr}\n    \n    \\usepackage{pagecolor}\n    % \\pagecolor{black}\n    % \\color{white}\n\n    \\pagestyle{fancy}\n    \\fancyhf{}\n    \\fancyhead[LO]{TMA4140: Homework set 8}\n    \\fancyhead[RO]{Henry S. Sjøen \\& Toralf Tokheim}\n    \\fancyfoot[CO]{\\thepage\\ of \\pageref{LastPage}}\n\n    \\definecolor{darkred}{RGB}{200, 0, 0}\n\n  \\author{Henry S. Sjøen \\& Toralf Tokheim}\n  \\title{\n  \\textbf{TMA4140 - Homework Exercise Set 8}}\n\\begin{document}\n    \\maketitle\n    \\thispagestyle{empty}\n    \\pagebreak\n    \\tableofcontents\n    \\pagebreak\n\n    \\section{Section 5.2}\n    %  Obligatoriske: 4, 14; Anbefalte: 7, 19, 23\n    \\subsection{Exercise 4}\n    Let $P(n)$ be the statement that a postage of $n$ cents can be formed using just 4-cent stamps and 7-cent stamps. The parts of this exercise outline a strong induction proof that $P(n)$ is $true$ for $n\\geq 18$.\\\\\n    \n    \\textbf{a)} Show statements $P(18),P(19),P(20)$ and $P(21)$ are $true$, completing the basis step of the proof.\n    \n    \\begin{equation}\n        \\begin{split}\n            P(n)=4a+7b=n\\\\\n            P(18)=(4\\times 1)+(7\\times 2)=18\\\\\n            P(19)=(4\\times 3)+(7\\times 1)=19\\\\\n            P(20)=(4\\times 5)+(7\\times 0)=20\\\\\n            P(21)=(4\\times 0)+(7\\times 3)=21\\\\\n        \\end{split}\n    \\end{equation}\n    \n    \\textbf{b)} What is the inductive hypothesis of the proof?\\\\\n    If for every i in $18 \\leq i \\leq k $, where $k \\leq 21$, there is an \"a\" and \"b\" so that $i= 4a+7b$. Then there is an  \"c\" and \"b\" so that $k+1 = 4c+7d$ is \\textit{true}.\\\\\n\n    \\textbf{c)} What do you need to prove in the inductive step?\\\\\n    In the inductive step, we assume that the inductive hypothesis holds, and use that to prove $k+1$. \\\\\n    \n    \\textbf{d)} Complete the inductive step for $k \\geq 21$.\\\\\n    For $k = 21$ then $P(k+1)$ should still be \\textit{true}.\n    \\begin{equation}\n        \\begin{split}\n                    P(k)=(4\\times 0)+(7\\times 3)=21\\\\\n                    P(k+1)=4+(k-3)=(4\\times 2)+(7\\times 2)=22\\\\\n        \\end{split}\n    \\end{equation}\n    \\textit{True} for base step $P(21)$ and the first inductive step $P(22)$.\\\\\n    \n    \\textbf{e)} Explain why these steps show that this statement is $true$ whenever $n\\geq 18$.\\\\\n    Since the base step and the inductive step are true, by the principle of strong induction all amount of postage where $n \\geq 18$ can be obtained using only 4- and 7-cent stamps.\n\n    % \\subsection{Todo: Exercise 14}\n    % Suppose you begin with a pile of $n$ stones and split this pile into $n$ piles of one stone each by successively splitting a pile of stones into two smaller piles.\\\\\n    % Each time you split a pile you multiply the number of stones in each of the two smaller piles you form, so that if these piles have $r$ and $s$ stones in them, respectively, you compute $rs$. Show that no matter how you split the piles, the sum of the products computed at each step equals $n(n-1)/2$.\n\n    \\section{Section 5.3}\n    %  Obligatoriske: 12, 18; Anbefalte: 13, 14, 15\n    \\subsection{Exercise 12}\n    Prove that $f_1^2 +f_2^2 +\\cdots+f_n^2 =f_nf_{n+1}$ when $n$ is a positive integer.\n    \\begin{equation}\n        \\begin{split}\n                    f_{0} = 0\\\\\n                    f_{1} = 1\\\\\n                    \\\\\n                    f_{2} = f_{1}+f_{0}=1+0=1 \\\\\n                    f_{3} = f_{2}+f_{1}=1+1=2 \\\\\n                    f_{4} = f_{3}+f_{1}=2+1=3 \\\\\n        \\end{split}\n    \\end{equation}\n    \n    \\textbf{Base step:} \\\\\n    $P(1)$ is true because $f_{1}^2 = f_{1}f_{1}$\\\\\n    $= 1.1$\\\\\n    $= 1$\\\\\n    $= f_1*f_2$\\\\\n    \\\\\n    \n    \\textbf{Inductive step:}\\\\\n    Assume that $P(k)$  is true.\\\\\n    Show that $P(k+1)$ is true:\n    \\begin{equation}\n        \\begin{split}\n              f_{1}^2 + f_{2}^2 + \\cdots + f_k^2 + f_{k+1}^2 = f_k * f_{k+1} + f_{k+1}^2\\\\\n            = f_k * f_{k+1} + f_{k+1} * f_{k+1}\\\\\n            = f_{k+1} (f_k+f_{k+1})\n            =f_{k+1} * f_{k+2}\n        \\end{split}\n    \\end{equation}\n    Therefore, $P(k+1)$ is true. \\\\\n    Hence by the principle of strong induction, we conclude that the statement is true. \\\\\n    And therefor $f_1^2 +f_2^2 +\\cdots+f_n^2 =f_nf_{n+1}$ is true.\n\n    \\subsection{Exercise 18}\n    Let \n    $ A =\n    \\begin{bmatrix}\n        1 & 1 \\\\\n        1 & 0  \n    \\end{bmatrix}\n    $,\n    Show that \n    $ A^n = \\begin{bmatrix}\n                    f_{n+1} & f_n\\\\\n                    f_n & f_{n-1}\n                    \\end{bmatrix}\n    $   when $n$ is a positive integer.\n    \n    Let $A=\\begin{bmatrix}\n    1&1\\\\\n    1&0\n    \\end{bmatrix}$\n    Let $P(n)$ be a statement that $A^n=\\begin{bmatrix}\n        f_{n+1}&f_{n}\\\\\n        f_{1}&f_{1-1}\n    \\end{bmatrix}$\n    \n    \\begin{equation}\n        A^1= \\begin{bmatrix}\n            f_{2}&f_{1}\\\\\n            f_{1}&f_{0}\n        \\end{bmatrix}\\\\\n        =\\begin{bmatrix}\n            1&1\\\\\n            1&0\n        \\end{bmatrix}\n        = A\n    \\end{equation}\n    A is true.\\\\\n    Inductive step...\n    Assume that $P(k)$ is true.\n    i.e., $A^k=\\begin{bmatrix}\n    f_{k+1}&f_k\\\\\n    f_k & f_k-1\n    \\end{bmatrix}$\\\\\n    We have to prove that $P(k+1)$ is true.\n    \\begin{equation}\n        \\begin{split}\n            A^{k+1}&=A.A^k\\\\\n            &=\\begin{bmatrix}\n            1&1\\\\\n            1&0\n            \\end{bmatrix}\n            \\begin{bmatrix}\n            f_{k+1}& f_k\\\\\n            f_k&f_{k-1}\n            \\end{bmatrix}\\\\\n            &=\\begin{bmatrix}\n            1.f_{k+1}+1.f_k &1.f_{k}+1.f_{k-1}\\\\\n            1.f_{k+1}+ 0.f_k & 1.f_k+0.f_{k-1}\n            \\end{bmatrix}\\\\\n            &=\\begin{bmatrix}\n            f_{k+1}+f_k & f_{k-1}+f_k\\\\\n            f_{k+1}+0 & f_{k}+0\n            \\end{bmatrix}\\\\\n            &=\\begin{bmatrix}\n            f_{k+2} & f_{k+1}\\\\\n            f_{k+1} & f_{k}\n            \\end{bmatrix}\n        \\end{split}\n    \\end{equation}\n    Therefore $P(k+1)$ is \\textbf{true}.\\\\\n    And from the principle of mathematical induction we can conclude that the given statement is true.\n    \n    \\section{Section 5.4}\n    %  Obligatoriske: 3\n    \\subsection{Exercise 3}\n    Trace Algorithm 3 when it finds $\\gcd(8,13)$. That is, show all the steps used by Algorithm 3 to find $\\gcd(8,13)$.\n    \n            \\textbf{Input:} $\\gcd(8, 13)$ \\\\\n            \\begin{equation}\n                \\begin{split}\n                   since(8 < 13) &\\\\\n                        \\gcd(8, 13) &= \\gcd(13 \\textbf{mod} 8,8)\\\\\n                        \\gcd(8, 13) &= \\gcd(5, 8) \\\\\n                        \\\\\n                   since(5 < 8) &\\\\\n                        \\gcd(5, 8) &= \\gcd(8 \\textbf{mod} 5,5)\\\\\n                        \\gcd(5, 8) &= \\gcd(3, 5) \\\\\n                        \\\\\n                   since(3 < 5) &\\\\\n                        \\gcd(3, 5) &= \\gcd(5 \\textbf{mod} 3,3)\\\\\n                        \\gcd(3, 5) &= \\gcd(2, 3) \\\\\n                        \\\\\n                   since(2 < 3) &\\\\\n                        \\gcd(2, 3) &= \\gcd(3 \\textbf{mod} 2,2)\\\\\n                        \\gcd(2, 3) &= \\gcd(1, 2) \\\\\n                        \\\\\n                   since(1 < 2) &\\\\\n                        \\gcd(1, 2) &= \\gcd(2 \\textbf{mod} 1,1)\\\\\n                        \\gcd(1, 2) &= \\gcd(0, 1) \\\\\n                        \\\\\n                   since(a = 0) &\\\\\n                        \\gcd(0, 1) &= 1\\\\\n                        \\gcd(8, 13) &= \\textbf{1}\n                \\end{split}\n            \\end{equation}\n\n\n    \\section{Section 9.1}\n    %  7, 40a, 40c (4, 28a, 28c); Anbefalte: 4, 25, 32\n    \\subsection{Exercise 7}\n    Determine whether the relation $R$ on the set of all integers is \\textit{reflexive}, \\textit{symmetric}, \\textit{antisymmetric}, and/or \\textit{transitive}, where $(x,y) \\in R$ if and only if\\\\\n    \\textbf{a)} $ x \\neq y$.\\\\\n        $R$ is \\textbf{Not reflective}. $x \\neq x$ can never be true\\\\\n        $R$ is \\textbf{symetric}, since if $x, y$ are integers and $ x \\neq y$; then $ y \\neq x$. \\\\\n        $R$ is \\textbf{not antisymetric}, as $1\\neq 5$, $5 \\neq 1$ while $1$ and $5$ are not the same. \n        $R$ is \\textbf{not transitive}, as $1\\neq 5$, $5 \\neq 1$ while $1 = 1$\\\\\n        \\\\\n    \\textbf{b)} $ xy \\geq 1$.\\\\\n        $R$ is \\textbf{not reflexive} \\\\\n        $R$ is \\textbf{symetric} \\\\\n        $R$ is \\textbf{not antisymetric} \\\\\n        $R$ is \\textbf{transitive} \\\\\n        \\\\\n    \\textbf{c)} $ x=y + 1$ or $ x=y-1$.\\\\\n        $R$ is \\textbf{not reflexive} \\\\\n        $R$ is \\textbf{symetric} \\\\\n        $R$ is \\textbf{not asymetric} \\\\\n        $R$ is \\textbf{not transitive} \\\\\n        \\\\\n    \\textbf{d)} $ x \\equiv y (mod 7) $.\\\\\n        $R$ is \\textbf{reflexive} \\\\\n        $R$ is \\textbf{symetric} \\\\\n        $R$ is \\textbf{not asymetric} \\\\\n        $R$ is \\textbf{transitive} \\\\\n        \\\\\n    \\textbf{e)} $ x $ is a multiple of $y$.\\\\\n        $R$ is \\textbf{reflective} \\\\\n        $R$ is \\textbf{not symmetric} \\\\\n        $R$ is \\textbf{not antisymetric} \\\\\n        $R$ is \\textbf{transitive} \\\\\n        \\\\\n    \\textbf{f)} $ x $ and $y$ are both negative or both nonnegative.\\\\\n        $R$ is \\textbf{reflexitive} \\\\\n        $R$ is \\textbf{symmetric} \\\\\n        $R$ is \\textbf{not asymmetric} \\\\\n        $R$ is \\textbf{transitive} \\\\\n        \\\\\n    \\textbf{g)} $ x=y^2 $.\\\\\n        $R$ is \\textbf{not reflexive} \\\\\n        $R$ is \\textbf{not symmetric} \\\\\n        $R$ is \\textbf{asymmetric} \\\\\n        $R$ is \\textbf{not transitive} \\\\\n        \\\\\n    \\textbf{h)} $ x \\geq y^2 $.\n        $R$ is \\textbf{not reflexive} \\\\\n        $R$ is \\textbf{not symmetric} \\\\\n        $R$ is \\textbf{asymmetric} \\\\\n        $R$ is \\textbf{transitive} \\\\\n        \\\\\n\n    \\subsection{Exercise 40}\n    Let $R_1$ and $R_2$ be the \"divides\" and \"is a multiple of\" relations on the set of all positive integers, respectively.\\\\\n    That is, $R_1 = \\{(a,b)|a $ divides $ b\\}$ and $R_2=\\{(a,b)|a$ is a multiple of $b\\}$. Find...\n    \n    \\subsubsection{Exercise 40.a}\n    $R_1 \\cup R_2$.\\\\\n    An ordered pair $(a,b)\\in R_1\\cup R_2 $ if and only if $(a,b)\\in R_1$ or $(a,b)\\in R_2$.\\\\\n    If $a$ divides $b$ for some integer $k$, $b=ka$.\\\\\n    If $a$ is an multiple of $b$, then for some integer k,\n    $b=\\frac{1}{k}a $\\\\\n    Therefore, $R_1 \\cup R_2=\\{(a,b)|b=ka$ or $ b=\\frac{1}{k}a$, where $k$ is an integer.$\\}$\n    \n    \\subsubsection{Exercise 40.c}\n    $R_1 - R_2$.\\\\\n    An ordered pair $(a,b)\\in R_1-R_2$ if and only if $(a,b)\\in R_1$ and $(a,b)\\notin R_2$.\\\\\n    That is, if and only if \\textit{a divides b} and \\textit{a} is not a multiple of \\textit{b}.\\\\\n    Therefore,\n    $R_1-R_2 = \\{(a,b) | a$ is a proper divisor of $b \\}$.\n\n    \\section{Section 9.3}\n    %  10, 14a, 14b, 14c (6, 10a, 10b, 10c); Anbefalte: 15\n    \\subsection{Exercise 10}\n    How many nonzero entries does the matrix representing the relation $R$ on $A=\\{1,2,3,...,1000\\}$ consisting of the first 1000 positive integers have if $R$ is...\\\\\n    \\textbf{a)} $\\{(a,b) | A \\leq b \\}$?\n    \\begin{equation}\n        \\begin{split}\n            \\{(a,b) | A \\leq b \\}&=1000+999+998+\\cdots + 2 + 1\\\\\n            &=\\frac{(1000)(1000+1)}{2}\\\\\n            &=(500)(1001)\\\\\n            &=500,500\n        \\end{split}\n    \\end{equation}\n    \n    \\textbf{b)} $\\{(a,b) | a=b \\pm 1 \\}$?\n    \\begin{equation}\n        \\begin{split}\n            \\{(a,b) | a=b \\pm 1 \\}&=1+2(998)+1\\\\\n            &=1+1996+1\\\\\n            &=1998\n        \\end{split}\n    \\end{equation}\n    \n    \\textbf{c)} $\\{(a,b) | a+b = 1000 \\}$?\n    \\begin{equation}\n        \\begin{split}\n            \\{(a,b) | a+b = 1000 \\}&=1+1+1+\\cdots + 1(999)\\\\\n            &=999\n        \\end{split}\n    \\end{equation}\n    \n    \\textbf{d)} $\\{(a,b) | a+b \\leq 1001 \\}$?\n        \\begin{equation}\n            \\begin{split}\n            \\{(a,b) | a+b \\leq 1001 \\} &=1000+999+998+\\cdots+2+1\\\\\n            &=\\frac{(1000)(1000+1)}{2}\\\\\n            &=(500)(1001)\\\\\n            &=500,500\n            \\end{split}\n        \\end{equation}\n   \n    \\textbf{e)} $\\{(a,b) | a \\neq 0 \\}$?\n        \\begin{equation}\n            \\begin{split}\n            \\{(a,b) | a \\neq 0 \\}&=1000+1000+1000+\\cdots + 1000+1000 (1000 times)\\\\\n            &=(1000)(1000)\\\\\n            &= 1,000,000\n            \\end{split}\n    \\end{equation}\n     \n    \\subsection{Exercise 14}\n    \n    Let $R_1$ and $R_2$ be the relations represented by the matrices... \\\\\n    $M_{R_1}=\\begin{bmatrix}\n        0 & 1 & 0\\\\\n        1 & 1 & 1\\\\\n        1 & 0 & 0\n    \\end{bmatrix}$ and $M_{R_2} = \\begin{bmatrix}\n        0 & 1 & 0 \\\\\n        0 & 1 & 1 \\\\\n        1 & 1 & 1\n    \\end{bmatrix}\n    $\\\\\n    Find the matrices that represent...\n    \\subsubsection{Exercise 14.a}\n    $R_1 \\cup R_2$\n    \\begin{equation}\n        M_{R_1 \\cup R_2} = \\begin{bmatrix}\n            0 & 1 & 0 \\\\\n            1 & 1 & 1 \\\\\n            1 & 1 & 1\n        \\end{bmatrix}\n    \\end{equation}\n\n    \\subsubsection{Exercise 14.b}\n    $ R_1 \\cap R_2 $.\n    \\begin{equation}\n        M_{ R_1 \\cap R_2}=\n        \\begin{bmatrix}\n            0 & 1 & 0\\\\\n            0 & 1 & 1\\\\\n            1 & 0 & 0\n        \\end{bmatrix}\n    \\end{equation}\n    \n    \\subsubsection{Exercise 14.c}\n    $ R_2 \\circ R_1$.\n    \\begin{equation}\n       M_{R_2 \\circ R_1}=\n        \\begin{bmatrix}\n        0&1&1\\\\\n        1&1&1\\\\\n        0&1&0\n        \\end{bmatrix}\n    \\end{equation}\n\\end{document}", "meta": {"hexsha": "cf1b96687fe300e9fdd973cf8186f1d1d8795a53", "size": 13340, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "O8/o8.tex", "max_stars_repo_name": "SjoenH/TMA4140-2018", "max_stars_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "O8/o8.tex", "max_issues_repo_name": "SjoenH/TMA4140-2018", "max_issues_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-09-16T20:12:23.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-24T09:17:53.000Z", "max_forks_repo_path": "O8/o8.tex", "max_forks_repo_name": "SjoenH/TMA4140-2018", "max_forks_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0131233596, "max_line_length": 307, "alphanum_fraction": 0.485982009, "num_tokens": 4875, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7799929002541068, "lm_q1q2_score": 0.4384936793806191}}
{"text": "\\subsection{Task 7: Triangle Counting}\nAccording to the algorithms in \\cite{tsourakakis2008fast}, we know that the number of triangles in a network is proportional to the sum of eigenvalue of its adjacency matrix, which is $\\frac{\\sum_{i}\\lambda_{i}^{3}}{6}$. Figure \\ref{t7:timedata} shows the running time of global triangle counting with regards to the size of graph. We can see that as the size of graph increases, the running time also grows nearly linearly with the size. For the largest graph, which is Roadnet-PA, it runs nearly for an hour to complete. However, the predicted result for Roadnet-PA is unsatisfactory. We conduct both global and local triangle counting, all the data is listed as follows.\n\n\\subsubsection{Detailed Plots}\n{\\bf Proof of Correctness: } In this experiment, we run our algorithm on the dataset, and verify that the predicted number of triangles is a good approximate of the true count. The full result is in Table \\ref{t7:globalpredict}. As we can see, most of the result is near to each other. So we are aure about the correctness of the implementation. \n\nTable \\ref{t7:timedata} lists run time of global triangle counting. Figure \\ref{t7:globaltime} plots the run time of global triangle counting on each dataset.\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{ | c | c | }\n    \\hline\n    graph size & run time(seconds) \\\\ \\hline\n    7115 & 45.199s \\\\ \\hline\n    36692 & 72.76 \\\\ \\hline\n    82168 & 596.046 \\\\ \\hline\n    334863 & 1288.703 \\\\ \\hline\n    1088092 & 2980.985 \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{Task 7 run time(global)}\n\\label{t7:timedata}\n\\end{table}\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular} {| c | c | c | c | }\n    \\hline\n    dataset & size & predict & truth \\\\ \\hline\n    wiki-Vite & 7115 & 661282 & 608389 \\\\ \\hline\n    Enron-email & 36692 & 756757 & 727044 \\\\ \\hline\n    slash-dot & 82168 & 635792 & 602592 \\\\ \\hline\n    Amazon-com & 334863 & 675778 & 667129 \\\\ \\hline\n    Roadnet-PA & 1088092 & 72134 & 67150 \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{Predicted triangle count(global)}\n\\label{t7:globalpredict}\n\\end{table}\n\n% \\begin{table}\n% \\begin{center}\n% \\begin{tabular} {| c | c | c | c | }\n%     \\hline\n%     dataset & predict & truth \\\\ \\hline\n%     wiki-Vote & 661282 & 608389 \\\\ \\hline\n%     youtube & 3122234 & 3056386 \\\\ \\hline\n%     slashdot0922 & 631667 & 602592\\\\ \\hline\n%     com-DBLP & 2451225 & 2224385 \\\\ \\hline\n%     wiki-Talk & 9778534 & 9203519\\\\ \\hline\n% \\end{tabular}\n% \\end{center}\n% \\caption{Predicted triangle count(global)}\n% \\label{t7:globalpredict}\n% \\end{table}\n\n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.6\\textwidth]{FIG/t7_time.png}\n\\end{tabular}\n\\caption{Task 7: Run time VS graph size(global)}\n\\label{t7:globaltime}\n\\end{center}\n\\end{figure}\n\n\\subsubsection{Local triangle counting}\nWe plot the rank-frequency plot of local triangle counting, that x-axis represent the rank of the count of local triangle, y-axis represents the number of local triangles at that rank. \n\n\\paragraph{Amazon}\nFigure \\ref{t7:amazon} plots the rank-frequency of Amazon. We can observe from the figure that it follows {\\bf power law}. \n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.4\\textwidth]{FIG/t7_amazon.png}\n\\end{tabular}\n\\caption{Local triangle counting for Amazon}\n\\label{t7:amazon}\n\\end{center}\n\\end{figure}\n\n\\paragraph{Enron mail}\nFigure \\ref{t7:enron} plots the rank-frequency of Enron Mail. We can observe from the figure that it follows {\\bf power law}. \n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.4\\textwidth]{FIG/t7_enron.png}\n\\end{tabular}\n\\caption{Local triangle counting for Enron mail}\n\\label{t7:enron}\n\\end{center}\n\\end{figure}\n\n\\paragraph{Slashdot}\nFigure \\ref{t7:slashdot} plots the rank-frequency of Slashdot. We can observe from the figure that it follows {\\bf power law}. \n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.4\\textwidth]{FIG/t7_slashdot.png}\n\\end{tabular}\n\\caption{Local triangle counting for Slashdot}\n\\label{t7:slashdot}\n\\end{center}\n\\end{figure}\n\n\\paragraph{wiki-Vote}\nFigure \\ref{t7:wikivote} plots the rank-frequency of wiki-Vote. We can observe from the figure that it follows {\\bf power law}. \n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.4\\textwidth]{FIG/t7_wikivote.png}\n\\end{tabular}\n\\caption{Local triangle counting for wiki-Vote}\n\\label{t7:wikivote}\n\\end{center}\n\\end{figure}\n\n\\paragraph{Youtube}\nFigure \\ref{t7:youtube} plots the rank-frequency of Youtube. We can observe from the figure that it follows {\\bf power law}. \n\\begin{figure}[!htbf]\n\\begin{center}\n\\begin{tabular}{c}\n     \\includegraphics[width=0.4\\textwidth]{FIG/t7_youtube.png}\n\\end{tabular}\n\\caption{Local triangle counting for youtube}\n\\label{t7:youtube}\n\\end{center}\n\\end{figure}\n\n% \\begin{figure}[!htbf]\n% \\begin{center}\n% \\begin{tabular}{cc}\n%      \\includegraphics[width=0.4\\textwidth]{FIG/t7_amazon.png} &\n%      \\includegraphics[width=0.4\\textwidth]{FIG/t7_enron.png} \\\\\n%      (a) & (b) \\\\\n%      \\includegraphics[width=0.4\\textwidth]{FIG/t7_slashdot.png} &\n%      \\includegraphics[width=0.4\\textwidth]{FIG/t7_wikivote.png} \\\\\n%      (c) & (d) \\\\\n%      \\includegraphics[width=0.4\\textwidth]{FIG/t7_youtube.png} & \\\\\n%      (e)\n% \\end{tabular}\n% \\caption{Local triangle counting. (a) Amazon (b) Enron Mail (c) Slashdot (d) Wiki Vote (e) Youtube}\n% \\label{t7:local}\n% \\end{center}\n% \\end{figure}\n\n\\subsubsection{Observation}\nWe can see that the rank-frequency plot of local triangle count also follows {\\bf power law}, it just matches our intuition. And we can observe that the run time grows nearly linearly with the graph size. \n", "meta": {"hexsha": "6a17f509ed5c30f5c1af41437ca8bb7673ea7f97", "size": 5745, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/phase-3/doc/t7_exp.tex", "max_stars_repo_name": "spininertia/graph-mining-rdbms", "max_stars_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/phase-3/doc/t7_exp.tex", "max_issues_repo_name": "spininertia/graph-mining-rdbms", "max_issues_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/phase-3/doc/t7_exp.tex", "max_forks_repo_name": "spininertia/graph-mining-rdbms", "max_forks_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-16T18:23:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-16T18:23:24.000Z", "avg_line_length": 38.5570469799, "max_line_length": 673, "alphanum_fraction": 0.7150565709, "num_tokens": 1805, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.4384285554376051}}
{"text": "%!TEX root = ../../common/main.tex\n\n\\section{Decay time resolution and acceptance}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance}\n\nIn the following sections the parametrisation of the decay time resolution and\nthe model to describe the decay time acceptance are studied. \n\n% ------------------------------------------------------------------------------\n\\subsection{Resolution}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance:resolution}\n\nIn this section the applicability of the \\dtfpv output variable $\\obsTimeError$ as\nthe per-event decay time error resolution estimate is checked and a model to\ncalibrate the estimate is developed. The model is determined in a two step\nprocedure. At first, different calibration models are tested using a binned fit\non the decay time resolution determined on data as a function of the resolution\nestimate $\\obsTimeError$. Then the found resolution model is used in an unbinned\nlikelihood fit to determine the calibration parameter values.\n\nThe study is performed on $\\BdToJpsiKS$ candidates passing the pre-scaled\nstripping line and the unbiased trigger lines only. The nominal selection is\napplied, except the decay time cut at $\\obsTime < \\SI{0.3}{\\pico\\second}$, all\nremaining candidates are considered irrespective of their tagging information.\nWithout cuts restricting the reconstructed decay time of the \\Bd candidates, the\nsample consists mainly of combinatorial background candidates promptly produced\nat the \\PV. As these candidates quasi decay instantaneously at $t = 0$ their\ndecay time distribution should give a proper handle on the decay time\nresolution. A fit to the $\\Jpsi$ candidate's reconstructed mass is applied to\nget signal \\sweights that are subsequently used in a weighted likelihood fit to\nthe reconstructed \\Bd candidates' decay time distribution.\n\nThe $\\Jpsi$ mass distribution is described by a \\Ipatia \\PDF (\\cf\n\\cref{sec:measurement_of_sin2beta:likelihood_fit:pdfs:ipatia}) for the signal\ncomponent and an exponential \\PDF for the background candidates. The fit is\nperformed on the reconstructed invariant dimuon mass $m_{\\mumu}$ in a range from\n$\\num{3040}$ to $\\SI{3155}{\\MeVcc}$. The fitted distribution and the \\PDF\nprojections split into the \\catDD and \\catLL categories are shown in \n\\cref{fig:measurement_of_sin2beta:resolution_and_acceptance:resolution:jpsi_mass}. \nAlthough, the pion track types have no influence on the mass distribution of the\n$\\Jpsi$ candidates, the separation is justified by the different decay time\nresolutions expected in these categories.\n%\n\\begin{figure}[h]\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_mass_jpsi_dd.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_mass_jpsi_ll.pdf}\n\\caption{Invariant $\\Jpsi$ candidates' mass distribution in the (left) \\catDD\nand (right) \\catLL subsample. Data are shown in black, the projection of the\ntotal \\acs{PDF} as solid black line, the signal component described by a \\Ipatia\n\\acs{PDF} as dashed blue line, and the exponential background component as\ndotted green line.}\n\\label{fig:measurement_of_sin2beta:resolution_and_acceptance:resolution:jpsi_mass}\n\\end{figure}\n%\nUsing a simultaneous fit in $\\num{20}$ equally filled bins of the decay time\nerror prediction $\\obsTimeError$ the width of the prompt peak in the decay time\ndistribution is fitted. This choice is based on the assumption that the decay\ntime resolution behaves alike for all candidates combined into one bin. As the\nlast bin is too wide, this assumption does not hold not any more, thus the last\nbin is left out from then on. The fit model consists of two Gaussian \\acp{PDF}\nsharing a common mean parameter to model the prompt peak and two additional\ndecay \\acp{PDF} as parametrisation of the non-prompt components. The decay \\PDF\nis convoluted with the same double-Gaussian \\PDF used to model the prompt peak.\nThe two widths---one narrow and one wider---are then both employed in the\ncalibration.\n\nFor both widths a binned $\\chisq$-fit of the $\\num{19}$ per-bin parameter values\nagainst the per-bin $\\obsTimeError$ averages is performed. One linear and two\nparabolic calibration models (with and without offset) are tested. For both\nwidths ($i = \\{1,2\\}$) as well as for both the \\catDD and \\catLL candidates the linear model\n$\\sigma^\\prime(\\obsTimeError) = c_i + b_i \\obsTimeError$ describes the data at\nleast equally well \\wrt the other parametrisations, such that the simpler model\nis chosen in case of comparable results.\n\\Cref{fig:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration} \nshows the calibration function for both track types and both Gaussian width\nparameters.\n%\n\\begin{figure}[h]\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_calibration_dd_narrow.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_calibration_dd_wide.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_calibration_ll_narrow.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/resolution_calibration_ll_wide.pdf}\n\\caption{Decay time error estimate calibration for (top) \\catDD and (bottom)\n\\catLL candidates. Different calibration functions are fitted to the (left)\nnarrow and the (right) wide Gaussian width parameters. In green the linear\nfunction $\\sigma^\\prime(\\obsTimeError) = c_i + b_i \\obsTimeError$ is shown, blue\nand yellow describe the parabolic function with and without offset.}\n\\label{fig:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration}\n\\end{figure}\n%\nResults of the depicted fits are given in \n\\cref{tab:app:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration:dd,tab:app:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration:ll}\nin \\cref{sec:app:measurement_of_sin2beta:resolution_and_acceptance:resolution}.\n\nUsing the determined calibration model, the nominal decay time resolution model\nis developed. An unbinned maximum likelihood fit to the \\Bd decay time is\nperformed on the same $\\Jpsi$ signal \\sweighted dataset as described before\nusing the resolution model\n%\n\\begin{equation}\\label{eq:measurement_of_sin2beta:resolution_and_acceptance:resolution}\n\\begin{split}\n  \\Resolution{}{}\\!\\left(\\obsTime;\\obsTimeError\\right)\n  &= \\sum_{i=1}^{2}{g_i\\,\\cdot\\,\\frac{1}{\\sqrt{2\\pi}(c_i + b_i \\cdot \\obsTimeError)}\\exp\\left(-\\frac{(\\obsTime - \\mu_t)^2}{2(c_i + b_i \\cdot \\obsTimeError)^2}\\right)}\\\\\n  &+ f_{\\text{PV}} \\frac{1}{\\sqrt{2\\pi} \\sigma_{\\text{PV}}} \\exp\\left(-\\frac{(\\obsTime - \\mu_t)^2}{2 \\sigma_{\\text{PV}}^2}\\right) \\eqpd\n\\end{split}\n\\end{equation}\n%\nThe first two Gaussian components describe the prompt peak resolution, the third\ncomponent models the distribution of candidates associated to the wrong \\PV.\nDifferent calibration parameters $c_i$ and $b_i$ are chosen for the width of the\nnarrow ($i=1$) and the wide ($i=2$) Gaussian \\PDF. The fractions $g_i$ add up to\nunity together with the fraction $f_\\text{\\acs*{PV}}$ of candidates associated\nto the wrong \\PV. The offset $\\mu_{\\obsTime}$ of the Gaussian central value is\nshared between all three Gaussian \\acp{PDF}. Finally,\n$\\sigma_{\\text{\\acs*{PV}}}$ describes the width of the wrong \\PV component. The\ndecay time distribution is modelled using two decay \\acp{PDF} that are\nconvoluted with the resolution model\n$\\Resolution{}{}\\!\\left(\\obsTime;\\obsTimeError\\right)$ and with pseudo-lifetimes\n$\\tau_{1,2}$.\n\\Cref{tab:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration:results} \nlists the results that are used from now on in the decay time resolution model.\nIt is tested how the choice of the calibration model influences the measurement\nusing a \\ToyMC study\n(\\cref{sec:measurement_of_sin2beta:systematics:systematics:resolution}).\n%\n\\begin{table}[h]\n  \\centering\n  \\caption{Results of the fit of the parameters described in the decay time\n  resolution model.}\n  \\label{tab:measurement_of_sin2beta:resolution_and_acceptance:resolution:calibration:results}\n  \\sisetup{\n    table-number-alignment    = center,\n    table-figures-integer     = 1,\n    table-figures-decimal     = 5,\n    table-figures-uncertainty = 5,\n    table-sign-mantissa,\n  }\n  \\begin{tabular}{llSS}\n    \\toprule\n    \\multicolumn{2}{c}{Parameter}       &   {\\catDD sample}     &   {\\catLL sample}   \\\\\n    \\midrule\n    $\\mu_t$             &   (\\si{\\ps})  &   -0.00291 +- 0.00026 & -0.00169 +- 0.00026 \\\\\n    $b_{1}$             &               &    0.88    +- 0.09    &  1.04    +- 0.14    \\\\\n    $c_{1}$             &   (\\si{\\ps})  &    0.0077  +- 0.0028  &  0.0045  +- 0.0028  \\\\\n    $b_{2}$             &               &    1.33    +- 0.33    &  1.8     +- 0.4     \\\\\n    $c_{2}$             &   (\\si{\\ps})  &    0.019   +- 0.008   &  0.007   +- 0.005   \\\\\n    $g_{2}$             &               &    0.251   +- 0.020   &  0.24    +- 0.023   \\\\\n    $\\sigma_\\text{PV}$  &   (\\si{\\ps})  &    1.6     +- 0.7     &  1.40    +- 0.14    \\\\\n    $f_\\text{PV}$       &               &    0.048   +- 0.004   &  0.0488  +- 0.0024  \\\\\n    \\midrule\n    $\\tau_1$            &   (\\si{\\ps})  &   0.7      +- 0.5     &  0.29    +- 0.06    \\\\\n    $\\tau_2$            &   (\\si{\\ps})  &   2.1      +- 1.3     &  1.82    +- 0.12    \\\\\n    $f_1$               &               &   0.08     +- 0.10    &  0.046   +- 0.006   \\\\\n    $f_2$               &               &   0.08     +- 0.11    &  0.079   +- 0.009   \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n% ------------------------------------------------------------------------------\n\\subsection{Decay time acceptance}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance:acceptance}\n\nAcceptance effects that alter the distribution of the decay time might result\nfrom selection requirements or inefficiencies in the event reconstruction. This\nsection summarises acceptance effects stemming from lifetime biasing selection\ncuts of trigger requirements (\\cf\n\\cref{sec:measurement_of_sin2beta:data_preparation:trigger}) and reconstruction\ninefficiencies mainly caused by the \\VELO track reconstruction algorithms (\\cf\n\\cref{sec:lhcb_experiment:tracking}).\n\n% ..............................................................................\n\\subsubsection{Trigger induced decay time acceptance}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower}\n\nThe biased trigger lines (\\cf\n\\cref{sec:measurement_of_sin2beta:data_preparation:trigger}) and the stripping\ncut on the reconstructed decay time of the $\\Bd$ candidates result in a non-flat\ndecay time acceptance.\n\nIn order to correctly describe these effects, the data sample is split into two\ndisjoint categories of candidates that show a substantially different behaviour\nregarding their decay time acceptance. All candidates passing the \\emph{almost\nunbiased} (\\textbf{\\catAU}) trigger requirements show nearly no decay time\nacceptance effects, in contrast to the sample of candidates passing the\n\\emph{exclusively biased} (\\textbf{\\catEB}) trigger requirements. The addressed\nrequirements are:\n%\n\\begin{description}\n  \\item[\\catAU] \\TriggerReqAU\n  \\item[\\catEB] \\TriggerReqEB\n\\end{description}\n%\nTo construct the acceptance in terms of ratios, a sample of candidates that pass\na set of unbiased trigger requirements is needed:\n%\n\\begin{description}\n  \\item[Unbiased] \\TriggerReqUB\n\\end{description}\n%\nThe acceptance of the \\catAU subsample can be computed using the overlap of\nevents which pass the biased and the unbiased \\HLTTwo di-muon lines. Both\nlines are using the same trigger cuts except for an additional cut on the flight\ndistance significance (see\n\\cref{tab:measurement_of_sin2beta:data_preparation:trigger:hlt2:cuts}) in the\ncase of the biased line. The acceptance can then be written as a time-dependent\nefficiency $\\varepsilon_\\text{\\catAU}$, with\n%\n\\begin{align}\n    \\varepsilon_\\text{\\catAU} &= \\frac{\\text{\\VerbAU\\VerbAnd \\HLTTwoDiMuonJpsi}}{\\text{\\VerbUB}}\\\\\n                              &= \\frac{\\text{\\TriggerReqAUEnumerator}}{\\text{\\TriggerReqUB}}\\eqpd \\nonumber\n\\end{align} \n%\nFor the \\catEB subsample, there is no corresponding reference sample available,\nso strictly speaking only a relative efficiency can be computed. Nonetheless,\nthe ratio of the \\catEB subsample and the unbiased subsample can be computed as\n$\\varepsilon_\\text{\\catEB}$.\n%\n\\begin{align}\n    \\varepsilon_\\text{\\catEB} &= \\frac{\\text{\\VerbEB}}{\\text{\\VerbUB}}\\\\\n                              &= \\frac{\\text{\\TriggerReqEB}}{\\text{\\TriggerReqUB}}\\eqpd \\nonumber\n\\end{align}\n%\nIn other words $\\varepsilon_\\text{\\catAU}$ quantifies the efficiency due to the\nrequirements by the biased \\HLTTwo line for events that pass the unbiased\n\\HLTOne line, whereas $\\varepsilon_\\text{\\catEB}$ effectively quantifies the\nrelative efficiency introduced by both, the \\HLTOne and \\HLTTwo, biased trigger\nlines.\n\n\\subsubsection{Methodology}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower:methodology}\n\nThe data set for studying the trigger acceptance effects consists of all events\nthat are selected by the \\StrippingDetached stripping line and pass the\noffline selection. As the tagged and untagged candidates are expected to behave\nequally concerning the studied effect all available candidates are used.\nOn the remaining multiple candidates, a random candidate selection is applied.\nAll candidates are selected by either one of the four considered trigger lines.\n\nThe efficiencies are time-dependent and, since the focus lies on the acceptance\nof the signal component's decay time distribution, have to be determined through\na fit to separate signal from background. To do so, a simultaneous fit for the\nsignal yield is performed in ten bins of decay time. The bin boundaries are\nchosen in a way that each bin contains the same number of events (before\nsplitting the data into the different fit categories). The fit is also performed\nsimultaneously in categories of track type, tagger, and both trigger sets given\nby the numerators and the denominator of $\\varepsilon_\\text{\\catAU}$ and\n$\\varepsilon_\\text{\\catEB}$. The yields for the different tagger and track type\ncategories are summed up (including error propagation). Then the efficiency per\ntime bin is calculated. For $\\varepsilon_{\\catAU}$ a binomial error is\nestimated, while a Gaussian error propagation is used for\n$\\varepsilon_{\\catEB}$.\n\nIn the mass fit, the signal peak is described by a \\Ipatia \\PDF, while a single\nexponential is used to describe the combinatorial background.\n\\Cref{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower:mass_fits} \nshows both mass distributions and fit projections for the biased and unbiased\nsample, respectively. In both plots the sum over all categories is displayed.\n%\n\\begin{figure}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/mass_trigger_efficiency_biased.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/mass_trigger_efficiency_unbiased.pdf}\n\\caption{Mass distribution and fit projection summed over all categories for\nthe (left) biased (\\catAU and \\catEB) and the (right) unbiased sample.}\n\\label{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower:mass_fits}\n\\end{figure}\n%\n\\Cref{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower:splines} \nshows the acceptance histograms for the \\catAU and the \\catEB sample. In the\nnominal fit cubic splines \\cite{Karbach:2014qba} are used instead of the\nhistograms themselves. Each bin centre is used as a knot for the splines. The\nbin contents determine the shape of the splines. However, the bin contents\naren't fixed but constrained with a Gaussian function where the width is given\nby the uncertainty on the bin content. As there is no information about the\nacceptance at the decay time limits, the efficiency is assumed to be flat\nbetween the lower decay time limit at \\SI{0.3}{\\ps} and the first bin\ncentre/knot and the last bin centre/knot and the upper decay time limit at\n\\SI{18.3}{\\ps}, respectively.\n%\n\\begin{figure}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/trigger_acceptance_spline_AU.pdf}\n\\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/trigger_acceptance_spline_EB.pdf}\n\\caption{Histograms of the trigger acceptance for the (left) almost unbiased and\nthe (right) exclusively biased sample. The blue curve shows the fitted\nacceptance using cubic splines.}\n\\label{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:lower:splines}\n\\end{figure}\n\n% ..............................................................................\n\\subsubsection{Upper decay time acceptance}\n\\label{sec:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}\n\nDue to a decrease in the \\VELO reconstruction efficiency for tracks with a\nlarger offset to the beam line, a second decay time acceptance effect has to be\nmodelled. To account for this a correction factor $\\beta_\\tau$ is included into\nthe fit model by implementing the modified lifetime\n%\n\\begin{equation}\\label{eq:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}\n  \\widetilde{\\tau} = \\frac{\\tau}{1 + \\beta_\\tau \\tau} \\eqpd\n\\end{equation}\n%\nThe value of $\\beta_\\tau$ is determined using an unbinned fit to simulated data\nwhile fixing the lifetime $\\tau$ to its generation value. Based on the\n\\BdToJpsiKS signal \\MC data set, only candidates passing the\n\\StrippingPrescaled stripping line and the unbiased trigger lines\n\\HLTOneDiMuonHighMass and \\HLTTwoDiMuonJpsi are chosen to avoid any\nadditional lifetime bias for events with short decay times. Only candidates\nbeing matched on \\MC as true signal events are considered. The nominal offline\nselection is applied and from the remaining multiple (\\acs{PV},\\,\\Bd) candidate\npairs, one is chosen randomly. To avoid wrong-\\acs{PV} associations of the\nreconstructed \\BdToJpsiKS candidate the true \\MC decay time is used in the fit.\nTo reduce the statistical uncertainties, and as no deviations of the decay time\ndistributions are expected, all untagged events are included. The number of\nremaining \\MC candidates available for this study is roughly \\num{60000}. Due to\ndifferences in the reconstruction efficiency the factor $\\beta_\\tau$ is\ndetermined separately for \\catOO/\\catOT and \\catDD/\\catLL events. The results\nare collected in\n\\cref{tab:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}.\n%\n\\begin{table}\n  \\centering\n  \\caption{Decay time correction factor $\\beta_\\tau$ in \\si{\\per\\pico\\second}.}\n  \\label{tab:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}\n  \\sisetup{\n    table-number-alignment    = center,\n    table-figures-integer     = 1,\n    table-figures-decimal     = 4,\n    table-figures-uncertainty = 4,\n  }\n  \\begin{tabular}{cSS}\n    \\toprule\n           & {2011}           & {2012} \\\\\n    \\midrule\n    \\catDD & 0.0036 +- 0.0029 & 0.0084 +- 0.0032 \\\\\n    \\catLL & 0.018  +- 0.004  & 0.035  +- 0.005  \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n\\subsubsection*{Influence of higher order effects}\n\n\\cref{eq:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}\nexpands to\n%\n\\begin{equation}\\label{eq:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper:linear}\n\\begin{split}\n  \\Prob{}{}\\left(t\\right) &= \\exponential{-\\frac{t}{\\tau}\\left(1+\\beta_{\\tau}\\tau\\right)} \\\\\n                          &= \\exponential{-\\frac{t}{\\tau}-\\beta_{\\tau}t} = \\exponential{-\\frac{t}{\\tau}} \\exponential{-\\beta_{\\tau}t} \\\\\n                          &= \\exponential{-\\frac{t}{\\tau}}\\left(1-\\beta_{\\tau} t+\\frac{\\beta_{\\tau}^2 t^2}{2}+\\order{(\\beta_{\\tau} t)^3}\\right).\n\\end{split}\n\\end{equation}\n%\nTo check the influence of higher order terms, a quadratic correction function is\ntested where the second order term has an own degree of freedom given by\n$\\gamma_\\tau^\\prime$,\n%\n\\begin{equation}\\label{eq:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper:quadratic}\n  \\Prob{}{}\\left(t\\right) = \\exponential{-\\frac{t}{\\tau}}\\left(1-\\beta_\\tau^\\prime t+ \\gamma_\\tau^\\prime t^2\\right).\n\\end{equation}\n%\nAgain the parameters $\\beta_\\tau^\\prime$ and $\\gamma_\\tau^\\prime$ are fitted\nwhile fixing the lifetime $\\tau$. In \\cref{tab:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper:quadratic} \nthe results are listed for \\catOO/\\catOT and \\catDD/\\catLL events. To visualise\nthe effect, the per-bin ratio of the decay time distributions of signal \\MC\nevents to events generated from \\ToyMC is calculated and shown in\n\\cref{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}.\nThe \\ToyMC decay time distribution follows an exponential function with the same\nlifetime as used in the generation of the signal \\MC. As the uncertainties on\n$\\beta_\\tau^\\prime$ and $\\gamma_\\tau^\\prime$ are large and the parameters are\nstrongly correlated ($\\rho>\\SI{90}{\\percent}$), the linear model is selected. A\npossible bias due to this choice is investigated in\n\\cref{sec:measurement_of_sin2beta:systematics:systematics:acceptance}.\n%\n\\begin{table}\n  \\centering\n  \\caption{Decay time correction factors $\\beta_\\tau^\\prime$ (in\n  \\si{\\per\\pico\\second}) and $\\gamma_\\tau^\\prime$ (in\n  \\si{\\per\\square\\pico\\second}).}\n  \\label{tab:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper:quadratic}\n  \\sisetup{\n    table-number-alignment    = center,\n    table-figures-integer     = 1,\n    table-figures-decimal     = 3,\n    table-figures-uncertainty = 3,\n    table-sign-mantissa,\n  }\n  \\begin{tabular}{\n    c\n    S\n    S[\n    table-figures-decimal     = 4,\n    table-figures-uncertainty = 4,\n    ]\n    S\n    S[\n    table-figures-decimal     = 4,\n    table-figures-uncertainty = 4,\n    ]\n  }\n    \\toprule\n           & \\multicolumn{2}{c}{2011}                          & \\multicolumn{2}{c}{2012}                        \\\\\n           & {$\\beta_\\tau^\\prime$}  & {$\\gamma_\\tau^\\prime$}   & {$\\beta_\\tau^\\prime$}  & {$\\gamma_\\tau^\\prime$} \\\\\n    \\midrule\n    \\catDD & -0.016 +- 0.007        & -0.0030 +- 0.0008        & -0.001 +- 0.007        & -0.0014 +- 0.0009      \\\\ \n    \\catLL & -0.001 +- 0.009        & -0.0028 +- 0.0012        &  0.01  +- 0.06         & -0.0027 +- 0.0008      \\\\ \n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n%\n\\begin{figure}\n  \\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/velo_acceptance_11_DD.pdf}\\hfill\n  \\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/velo_acceptance_11_LL.pdf}\n  \\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/velo_acceptance_12_DD.pdf}\\hfill\n  \\includegraphics[width=0.49\\textwidth]{private/content/measurement-of-sin2beta/figs/velo_acceptance_12_LL.pdf}\n\\caption{\nDecay time ratio in bins of decay time for (left/right) \\catDD/\\catLL and\n(top/bottom) \\catOO/\\catOT. The blue (red) curve shows a linear (quadratic) fit\nto the data points.}\n\\label{fig:measurement_of_sin2beta:resolution_and_acceptance:acceptance:upper}\n\\end{figure}\n", "meta": {"hexsha": "a53c4923b19497318d8931610ceb507e1b346c8d", "size": 23185, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/measurement-of-sin2beta/resolution-and-acceptance.tex", "max_stars_repo_name": "ccauet/thesis", "max_stars_repo_head_hexsha": "96d26639af0c4aa4badc6a55be952edc72a5eebd", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/measurement-of-sin2beta/resolution-and-acceptance.tex", "max_issues_repo_name": "ccauet/thesis", "max_issues_repo_head_hexsha": "96d26639af0c4aa4badc6a55be952edc72a5eebd", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-05-25T15:49:05.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-12T07:42:52.000Z", "max_forks_repo_path": "content/measurement-of-sin2beta/resolution-and-acceptance.tex", "max_forks_repo_name": "ccauet/thesis", "max_forks_repo_head_hexsha": "96d26639af0c4aa4badc6a55be952edc72a5eebd", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.2023809524, "max_line_length": 174, "alphanum_fraction": 0.736898857, "num_tokens": 6293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303236047048, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.43832571609441767}}
{"text": "\\section{Exploring Errors}\n\n%Introduction\n\\begin{frame}{Exploring Errors}\n\\begin{itemize}\n    % \\item After building and understanding all three of our models, we began to explore the errors associated with them\n    \\item Our definition of error:\n\n    \\begin{align*}\n        \\mbox{error} = \\frac{||v_{observed} - v_{predicted}||}{||v_{observed}||}\n    \\end{align*}\n    \\item While this is not the only metric we used (we also used error square and angular velocity error), this was our primary one\n    % \\item In the following slides, we will present some of the experiments we conducted to better understand and reduce predictive error from the models\n\n\\end{itemize}  \n\n\\end{frame}\n\n%Experiment 1: Errors and Positions\n%\\subsection{Experiment 1: Errors and Positions}\n\\begin{frame}{Experiment 1: Errors and Position}\n    \\begin{itemize}\n        \\item Question: Could measurement errors in position and velocity explain the difference between our $v_{predicted}$ and the $v_{observed}$\n        \\item To this end, we began to iteratively change the measured x and y COM and contact positions of the ellipse by a percentage\n    \\end{itemize} \n\n    \\begin{figure}[!htb]\n    \\minipage{0.32\\textwidth}\n      \\includegraphics[width=\\linewidth]{figures/changeInXPos.jpg}\n      \\caption{Changing the contact x position in Wang}\n      \\label{fig:awesome_image1}\n    \\endminipage\\hfill\n    \\minipage{0.32\\textwidth}%\n      \\includegraphics[width=\\linewidth]{figures/errorVsOptMethod.png}\n      \\caption{Changing the contact x position in IRB}\n      \\label{fig:awesome_image3}\n    \\endminipage\\hfill\n    \\minipage{0.32\\textwidth}\n      \\includegraphics[width=\\linewidth]{figures/trial900.jpg}\n      \\caption{Changing the angle of the ellipse in IRB}\n      \\label{fig:awesome_image2}\n    \\endminipage\n    \\end{figure}        \n    \n\\end{frame}\n\n\\begin{frame}{Experiment 1: Errors and Position}\nFindings: across all three models, changing by a percentage the positions of the ellipse had a big impact on the accuracy of the results \\\\\n\\vspace{\\baselineskip}\nIn general, this is what we saw:\n    \\begin{itemize}\n        \\item The measured position already gave a small error (few cases)\n        \\item Changing the measured position by a little bit gave a large drop in error (most cases)\n        \\item Changing the measured position by a lot to give a noticeable drop in error (few cases)\n    \\end{itemize} \n\\vspace{\\baselineskip}\nConclusion: the data we were provided is not completely accurate!\n\n\\end{frame}\n\n%Experiment 2: Errors and Moments\n%\\subsection{Experiment 2: Errors and Moments}\n\\begin{frame}{Experiment 2: Errors and Impact Angle}\nAt first, we were able to find a relationship between the error and the impact angle. \n\n    \\begin{itemize}\n%        \\item The pre-impact angle is related to both the moment arm and the geometry of the ellipse, which in turn directly affects the torque resulting from the impulse pair\n        \\item After running our models, we saw a relation between impact angles and the normalized errors (AP and Classic IRB)\n        %\\item For IRB with torque, the average width (the error offset) was also related to the impact angle.\n    \\end{itemize} \n\\vspace{0.5\\baselineskip}\nWhich means that Some impact angles prevented some of the models from accurately predicting the post-impact states.\n    \n    \\vspace{0.5\\baselineskip}\n     We will be exploring HOW that link came to be in later slides, but we are still unsure of WHY exactly the models systematically mispredict at certain angles.\n\\end{frame}\n\n\\begin{frame}{Experiment 2: Errors and Impact Angle}\n    \n \\begin{figure}\n \\centering\n        \\includegraphics[scale=0.12]{figures/IRBWidthAngle.jpg}\n        \\caption{IRB With Torque}\n        \\label{fig:IRBAngle}\n\\end{figure}\n\\vspace{-1\\baselineskip}\n\n\\begin{itemize}\n    \\item Width can be interpreted as Error\n    \\item We can see that peaks here occur around -110, -60, 60, 110\n\n\\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}{Experiment 2: Errors and Impact Angle}\n\\begin{itemize}\n    \\item Does this trend extend to other models we have looked at?\n\\end{itemize}\n\n\\begin{figure}\n    \\centering\n    \\quad\n    \\begin{subfigure}[b]{0.45\\linewidth}\n        \\includegraphics[scale=0.11]{figures/APAngleVsError.jpg}\n        \\caption{AP Poisson}\n        \\label{fig:AP_angle}\n    \\end{subfigure}\n    \\quad\n    \\begin{subfigure}[b]{0.45\\linewidth}\n        \\includegraphics[scale=0.11]{figures/CIRBAngleVsError.jpg}\n        \\caption{Classical IRB}\n        \\label{fig:WangAngle}\n    \\end{subfigure}\n\\end{figure}\n\\vspace{-1\\baselineskip}\n\n\\begin{itemize}\n    \\item The answer is, kind of!\n\\end{itemize}\n\n\\end{frame}\n\n% \\begin{frame}{The Link}\n\n% Overall, this is the link that we have observed between all of our variables\n% \\vspace{0.5\\baselineskip}\n\n% %NEEDS INFO CHECK TO MAKE SURE THIS IS CORRECT\n\n% \\begin{itemize}\n%     \\item  Experiment 3 ($\\Delta \\dot \\theta$ and Impact Angles) - At specific angles, the change in angular velocity is greater than at others. $\\Rightarrow$ \n%     \\item Experiment 4 ($\\Delta \\dot \\theta$ and Torque) - There is a smaller change in angular velocity at certain angles because at those angles the resultant torque is smaller. $\\Rightarrow$ \n%     \\item Experiment 5 ($\\Delta \\dot \\theta$ and Errors) - The smaller the change in angular velocity, the greater the prediction error. $\\Rightarrow$\n%     \\item  Experiment 6 (Moments and Errors) - The smaller the Torque, the greater the prediction error. \n% \\end{itemize}\n\n% \\vspace{0.25\\baselineskip}\n% %\\begin{itemize}\n%         %\\item In summary: pre-impact angle is related to both the moment arm and the geometry of the ellipse, which in turn directly affects the torque resulting from the impulse pair\n%         In summary: At specific angles, there are smaller resultant torques, and at these smaller resultant torques, the prediction error of the IRB model is greater.\n%     %\\end{itemize} \n\n% \\end{frame}\n\n\n%Experiment 3: Impact angles and Change in angular velocity\n\\begin{frame}{Experiment 3: $\\Delta \\dot \\theta$ and Impact Angles}\n\n\\begin{itemize}\n    \\item We expected the ellipse to have a greater change in angular velocity if it didn't fall right on its center of mass.\n    \\item The greater the moment arm, the greater the change in angular velocity.\n\\end{itemize}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.12]{figures/impact angle vs change in angular velocity.jpg}\n    \\caption{All moments vs Error}\n    \\label{fig:MomentsError}\n\\end{figure}\n\\item At around -110, 60, 110 the change in angular velocity is close to 0.\n\\end{frame}\n\n%Experiment 4: Change in angular velocity and Torque\n\\begin{frame}{Experiment 4: $\\Delta \\dot \\theta$ and Torque}\n%this kind of ties in to the previous slide/it's already been said that greater change in angular velocity leads is related to greater moment/torque so maybe just delete this one?\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.21]{figures/AngularVvsMoment.jpg}\n    \\caption{Classic IRB: Change in Angular Velocity vs Total Moment}\n    \\label{fig:MomentsError}\n\\end{figure}\n\n\\end{frame}\n\n%Experiment 5: Link between angular velocity and error\n\\begin{frame}{Experiment 5: $\\Delta \\dot \\theta$ and Errors}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.17]{figures/changeInOmegaEllipse.jpg}\n    \\caption{Classic IRB: Change in Angular Velocity vs Error}\n    \\label{fig:AngularVError}\n\\end{figure}\n\\end{frame}\n\n%The important part about this slide is the idea of overcompensation. The width isn't just helping adjust for changes in angular velocity that are too large for the IRB to predict and need more torque.... It is allowing for the IRB to change the impulses and create large torques/changes in omega which the width can then cancel out potentially \n\n%Experiment 6: Link between Moments and Error [editttttttt]\n\\begin{frame}{Experiment 6: Moments and Errors}\n\n% Since a greater angular velocity change led to a smaller error, and the angular velocity change is directly related to the net torque, As a sanity check, we graphed the net torque vs the normalized error hoping to see the same trend.\n\n%\\vspace{0.25\\baselineskip} [PRESENTATION NOTES]\n%The difference between these next 2 plots is the magnitude of the normalized error. IRB torque has a minor error magnitude compared to the classical model, because the compression width applies a moment to \"Correct\" the angular velocity.\n \n\\begin{figure}\n    \\centering\n    \\quad\n    \\begin{subfigure}[b]{0.4\\linewidth}\n        \\includegraphics[scale=0.105]{figures/IRB Classic Net torque vs error.jpg}\n        \\caption{Net Torque vs Error}\n        \\label{fig:AP_angle}\n    \\end{subfigure}\n    \\quad\n    \\begin{subfigure}[b]{0.5\\linewidth}\n        \\includegraphics[scale=0.13]{figures/MomentProp2.jpg}\n        \\caption{IRB Moment vs Torque}\n        \\label{fig:MomentIRB}\n    \\end{subfigure}\n\\end{figure}    \n    \n    \n\\end{frame}\n\n\\begin{frame}{The Link}\n\n\\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=2.5cm, minimum height=1.75cm, text centered, text width = 4cm, draw=black]\n\\tikzstyle{arrow} = [thick,->,>=stealth]\n\\begin{tikzpicture}[node distance=2cm]\n\n\\node (exp2) [startstop, xshift = 3.5cm, yshift = 11cm] {\\textbf{Experiment 2:} \\\\ Error is maximized at specific angles};\n\\node (exp3) [startstop, xshift = 7.25cm, yshift = 8.5 cm] {\\textbf{Experiment 3:} \\\\ $\\Delta \\dot \\theta$ is min at these angles};\n\\node (exp4) [startstop, xshift = 6.35cm, yshift = 6cm] {\\textbf{Experiment 4:} \\\\  $\\Delta \\dot \\theta$ decreases as the res. torque decreases};\n\\node (exp5) [startstop, xshift = 0.65cm, yshift = 6cm] {\\textbf{Experiment 5:} \\\\ $\\Delta \\dot \\theta$ decreases as prediction error increases};\n\\node (exp6) [startstop,xshift = 0.25cm, yshift = 8.5cm] {\\textbf{Experiment 6:} \\\\ Therefore as torque decreases, error increases};\n\n\n\\draw [arrow] (exp3) -- (exp4);\n\\draw [arrow] (exp4) -- (exp5);\n\\draw [arrow] (exp5) -- (exp6);\n\\draw [arrow] (exp6) -- (exp2);\n\\draw [arrow] (exp2) -- (exp3);\n\n\\end{tikzpicture}\n\\end{frame}\n", "meta": {"hexsha": "ac02b5fe37045e604ccfbe4f61991e35376b5450", "size": 10006, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Presentation/sec5.tex", "max_stars_repo_name": "DAIRLab/ImpactModeling", "max_stars_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-19T21:01:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-02T08:56:34.000Z", "max_issues_repo_path": "Presentation/sec5.tex", "max_issues_repo_name": "DAIRLab/ImpactModeling", "max_issues_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Presentation/sec5.tex", "max_forks_repo_name": "DAIRLab/ImpactModeling", "max_forks_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T21:01:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T21:01:28.000Z", "avg_line_length": 42.0420168067, "max_line_length": 345, "alphanum_fraction": 0.7212672397, "num_tokens": 2731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.43829689456121296}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n\\graphicspath{{figures/}}\n\\DeclareGraphicsRule{*}{mps}{*}{}\n\n\\usepackage{color}\n\\newcommand{\\red}[1]{{\\color{red} #1}}\n\n\\begin{document}\n\\section{Increasing numbers}\nThe graphs are generated by a sequence of numbers $\\alpha_i\\in\\mathbb{Z}$ appearing in random (not sorted) order from left to right.\n\\[\\{\\alpha_1,...,\\alpha_n\\}\\]\nWe set $s=\\alpha_1$ and $t=\\alpha_n$. Odd numbers are red.\nTwo numbers $\\alpha_i,\\alpha_j$ are connected if:\n\\begin{itemize}\n\\item $i<j$\n\\item $\\alpha_i<\\alpha_j$\n\\end{itemize}\nThe edges are directed from the smaller to the larger number.\nSome examples:\n\\begin{figure}[h]\n  \\centering\n\\includegraphics{increase_n8_1.0}  \n  \\caption{increase_n8_1, n=8}\n\\end{figure}\n\\begin{figure}[h]\n  \\centering\n\\includegraphics{increase_n8_2.0}  \n  \\caption{increase_n8_2, n=8}\n\\end{figure}\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics{increase_n8_3.0}\n  \\caption{increase_n8_3, n=8}\n\\end{figure}\n\n\n\\end{document}\n", "meta": {"hexsha": "1c8a70a80593c5ff5ba50a09b8330d6378e39cd7", "size": 1000, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "red-scare/instance-generators/increase/increase.tex", "max_stars_repo_name": "Sebastian-ba/DoDoBing", "max_stars_repo_head_hexsha": "6edcc18de22ad76505d2c13ac6a207a2c274cc95", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-09-25T11:59:20.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-20T12:55:21.000Z", "max_issues_repo_path": "red-scare/instance-generators/increase/increase.tex", "max_issues_repo_name": "ITU-2019/DoDoBing", "max_issues_repo_head_hexsha": "6edcc18de22ad76505d2c13ac6a207a2c274cc95", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2017-09-25T12:04:51.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-13T07:51:40.000Z", "max_forks_repo_path": "red-scare/instance-generators/increase/increase.tex", "max_forks_repo_name": "ITU-2019/DoDoBing", "max_forks_repo_head_hexsha": "6edcc18de22ad76505d2c13ac6a207a2c274cc95", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0, "max_line_length": 132, "alphanum_fraction": 0.728, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.43829689369670366}}
{"text": "\\begin{appendix}\n\t\n\\chapter{Algorithm for balancing lookup tables train set}\\label{Chapter:results}\n\nSince the dataset for the lookup tables is small -- even if length 2 compositions was created using tables \\textit{t1} to \\textit{t8}, there could only be 64 compositions which would bijectively map 8 \\lq  3 bit inputs to 3 bit outputs\\rq{} thereby leading to a total of 512 samples only -- we try to ensure that the compositions present in the training data are uniformly distributed while simultaneously keeping the distribution of the output strings in the training data uniform as well. This ensures that the model doesn't get biased towards any particular composition or an output string. As has been explained in section \\ref{lt:splits}, the heldout inputs set is created by randomly taking out 2 inputs for each of the 28 compositions in training. Therefore the resultant training set should have the following properties:\n\\begin{itemize}\n\t\\item The total number of data points  $= 28*6 = 168$.\n\t\\item There are 8 outputs. The total number of compositions that lead to a particular output $=168/8 = 21$.\n\\end{itemize}\n\n.\n\\begin{algorithm}\n\t\\caption{Create training with uniform distribution of both compositions and outputs}\n\t\\begin{algorithmic}\n\t\t\\STATE We start with 28 compositions with 8 inputs each.\n\t\t\\STATE Create an empty dataframe of dimension (21,8) with the 8 output strings as it's columns.\n\t\t\\STATE Create a dictionary Y with compositions as it's keys and values=0.\n\t\t\\FOR {i in range [0, 21)}\n\t\t\\FOR {output in dataframe column}\n\t\t\\STATE Sample composition\n\t\t\\IF{composition \\textbf{not in} row[i] AND composition \\textbf{not in} output column AND Y[composition] $<$ 21 }\n\t\t\\STATE dataframe[i][output] = composition\n\t\t\\STATE Y[composition] += 1\n\t\t\\ELSE\n\t\t\\STATE continue\n\t\t\\ENDIF\n\t\t\\ENDFOR\n\t\t\\ENDFOR\t\t\n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\end{appendix}", "meta": {"hexsha": "95ded88eb906b5d2c57375df17c23879bcc88865", "size": 1874, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "results.tex", "max_stars_repo_name": "Anand191/Thesis", "max_stars_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "results.tex", "max_issues_repo_name": "Anand191/Thesis", "max_issues_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "results.tex", "max_forks_repo_name": "Anand191/Thesis", "max_forks_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.5625, "max_line_length": 829, "alphanum_fraction": 0.7641408751, "num_tokens": 489, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.43829687694630276}}
{"text": "%\n% Complete documentation on the extended LaTeX markup used for Insight\n% documentation is available in ``Documenting Insight'', which is part\n% of the standard documentation for Insight.  It may be found online\n% at:\n%\n%     http://www.itk.org/\n\n\\documentclass{InsightArticle}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%  hyperref should be the last package to be loaded.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\usepackage[dvips,\nbookmarks,\nbookmarksopen,\nbackref,\ncolorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue},\n]{hyperref}\n% to be able to use options in graphics\n\\usepackage{graphicx}\n% for pseudo code\n\\usepackage{listings}\n% subfigures\n\\usepackage{subfigure}\n\n\n%  This is a template for Papers to the Insight Journal. \n%  It is comparable to a technical report format.\n\n% The title should be descriptive enough for people to be able to find\n% the relevant document. \n\\title{Parallel algorithms for erosion and dilation of label images.}\n\n\\newcommand{\\IJhandlerIDnumber}{3399}\n\n% Increment the release number whenever significant changes are made.\n% The author and/or editor can define 'significant' however they like.\n\\release{0.00}\n\n% At minimum, give your name and an email address.  You can include a\n% snail-mail address if you like.\n\\author{Richard Beare{$^1$} {\\small and} Paul Jackway{$^2$}}\n\\authoraddress{Richard.Beare@monash.edu\\\\Department of Medicine\\\\Monash University\\\\Melbourne\\\\Australia{$^1$}\\\\CSIRO Mathematics Informatics and Statistics\\\\Dutton Park\\\\Queensland\\\\Australia{$^2$}}\n\n\\begin{document}\n\n\\IJhandlefooter{\\IJhandlerIDnumber}\n\n\\maketitle\n\n\\ifhtml\n\\chapter*{Front Matter\\label{front}}\n\\fi\n\n\n\\begin{abstract}\n\\noindent\nIt is sometimes useful to be able to apply binary morphological\noperations, such as erosions and dilations, to labelled images in a\nfashion that preserves the labels. This article introduces a\nspecialised class implementing parallel methods described in\n\\cite{beare2011parallel} that provide very fast dilations by circles\nand spheres of arbitary size. Comparisons with other implementations\nusing currently available building blocks are also made.\n\\end{abstract}\n\\IJhandlenote{\\IJhandlerIDnumber}\n\\tableofcontents\n\n\\section{Introduction}\nThe link between Euclidean distance transforms and binary\nmorphological operations is well known - erosions and dilations by\ncircles and spheres can be performed by thresholding the distance\ntransform. Efficient and readily parallelizable distance transform\nalgorithms can, in turn, be based on erosions and dilations by\nparabolic structuring elements. The classes outlined in this article\nextend the contact point algorithm used for parabolic erosions and\ndilations to facilitate operations on label images. A more complete\ndiscussion is available in \\cite{beare2011parallel}. The classes\nintroduced here are able to separate touching labels during erosion\nand split touching labels at the midpoint during dilation.\n\n\\section{The classes}\nThe {\\em itk::LabelSetDilateImageFilter} and {\\em\n  itk::LabelSetErodeImageFilter} implement dilation and erosion of\nlabel images. They share a common parent class. The methods controlling class behaviour are:\n\\begin{itemize}\n\\item {\\em UseImageSpacing}: Defines whether the radius refers to voxels or world dimensions. Default is false, meaning radius is in voxels.\n\\item {\\em Set/GetRadius}: Set the size of the dilation or erosion. There are versions to set the size in all directions to be the same, corresponding to a circular or spherical structuring element, and independently, corresponding to an ellipsoid structuring element (with axes parallel to image axes).\n\\end{itemize}\n\nExamples of use are available with the package.\n\nPlease note that these are specialised classes which cannot use\narbitrary structuring elements.\n\nThe code from this contribution is also available at\n\\url{https://github.com/richardbeare/LabelErodeDilate}.\n\n\\subsection{Notes for label erosion}\nThe class provided for label erosion {\\bf will separate} touching\nlabels. If this is not the desired behaviour, then implement label\nerosion via binary erosion and masking.\n\n\\section{Alternative approaches to label dilation}\nAs advised on the ITK mailing list, label dilation can be implemented\nvia distance transforms and watershed transforms. This algorith is\nillustrated in SimpleITK python code below (courtesy of Bradely\nLowekamp):\n\n\\lstset{language=Python}\n\\begin{lstlisting}\ndef MultilabelDilation(img, radius=1,kernel=sitk.BinaryDilateImageFilter.Ball):\n    distImg = sitk.SignedMaurerDistanceMap(img != 0,\n                                           insideIsPositive=False, \n                                           squaredDistance=False, \n                                           useImageSpacing=False)\n    dilatImg = sitk.BinaryDilate(img!=0, radius, kernel)\n    wsImg = sitk.MorphologicalWatershedFromMarkers(distImg, img)\n    return dilatImg*wsImg\n\\end{lstlisting}\n\nThere are a couple of altnernatives to this algorithm implemented in\nC++ and provided in {\\em multilabelDilation.h}. The first version is a\nvariant of the code above, which avoids using the binary dilate\noperation and thresholds the distance transform instead. This version\nis called {\\em multilabelDilation}. The second version uses the {\\em\nDanielssonDistanceMapImageFilter} to produce both a distance map and a\nVoronoi tesselation. The distance map is thresholded to produce a\ndilation which is then used to mask the Voronoi tesselation. This\nversion is called {\\em multilabelDilationDanielsson}. The Danielsson\nfilter is slower than the Maurer filter, but this approach avoids the\nwatershed transform step as the information provided by the Voronoi\nmap is removes the need for the watershed. Comparisons of performance\nare below.\n\n\\subsection{Problems with the watershed approach}\nIt turns out that the distance transform followed by watershed\ntransform approach to label dilation only works reliably for smaller\ndilations, say 10. For larger dilations there is a chance of regions\nleaking across borders and becoming incorrect. Leaks of this kind\nresult from the nature of propagation in the border zone combined with\ntied distance values. The test image {\\em vCenters10.mha} demonstates\nthis issue.\n\n\\subsection{Dilations via distance maps versus binary dilation}\nThere are subtle differences between the effective structuring element\nproduced when thresholding distance maps versus those provided by the\n{\\em BinaryBallStructuringElement}. The latter is a Bresenham circle\nor sphere, which means that any voxel which is partly inside the\nspecified radius is included in the structuring elements. Distance\nmaps, on the other hand, typically compute distances to voxel\ncentres. Thus any voxel whos centre is closer than the specified\nradius is included, resulting in a slightly smaller structuring\nelement. \n\nIn addition, the parabolic dilation used in the LabelDilate tool\ntreats voxels with centres exactly the dilation radius from the seed\nas ``outside''. This results from the optimized use of the contact\npoint algorithm to avoid computation of a complete distance\ntransform. There may be some fudge factors that can be added to avoid\nthis behaviour, which will be investigated in the future.\n\n\\subsection{Other differences}\nThere are minor differences in results obtained from the Danielsson\napproach and the new approach discussed here. Some of those\ndifferences are along boundaries. My investigations suggest that the\nDanielsson approach is wrong in these cases. Explicit calculation of\nthe distance between the locations of seeds and differences in\nlabelling indicate that the points are incorrectly labelled by the\nDanielsson approach. The {\\em reportNonZero} tool and {\\em check.R}\nfunctions were used to investigate these problems.\n\n\\section{Performance}\nThe specialised version was developed due to ease of parallel\nimplementation and performance results show that it is indeed much\nfaster than versions that can be built using existing tools. It also\nscales moderately well with increased execution threads. The execution\ntimes and speedups for a 12 core Intel(R) Xeon(R) CPU X5650 @ 2.67GHz\non a $182 \\times 218 \\times 182$ brain atlas are shown in Figures\n\\ref{fig:exec}. None of the methods have a\nsignificant dependence on dilation size, as the structuring element is\nnot explicit. Speedup at 8 cores for the Maurer method is 1.86\nversus 4.71 for the parabolic method. The lack of scalability of the\nMaurer method is likely to be largely caused by the watershed step,\nwhich is not parallel. The Danielsson approach is much slower, despite\navoiding the need for an explicit watershed transform. There is some\nredundancy in the Maurer approach, as a signed distance transform is\ncomputed by not used. In the single threaded the specialised version\nis 7 times faster than the Mauer approach and 180 times faster than\nthe Danielsson-based method.\n\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.35]{exectimes}\n\\includegraphics[scale=0.35]{speedups}\n\\caption{Execution times and speedups for all methods.\\label{fig:exec}}\n\\end{figure}\n\n\n\\section{Sample results}\nLabel images occur in many situations. This is an example of a brain\natlas in which different labels represent different anatomical\nregions. Examples of 2D processing (operations applied to a single\nslice of the atlas) are shown in Figure \\ref{fig:2d}. Examples of a 3D\nprocessing are shown in Figures \\ref{fig:3dorig} to \\ref{fig:3ddil}.\n\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.75]{axial_color}\n\\includegraphics[scale=0.75]{laberode2d_color}\n\\includegraphics[scale=0.75]{labdilate2d_color}\n\\caption{Original, eroded and dilated atlases - a single slice with a 2d circular structuring element.\\label{fig:2d}}\n\\end{figure}\n\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.15]{atlas_orig}\n\\caption{Axial, sagittal and coronal slices through a labelled brain atlas.\\label{fig:3dorig}}\n\\end{figure}\n\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.15]{atlas_erode_color}\n\\caption{Atlas in Figure \\ref{fig:3dorig} after applying 3d labelled erosion. \\label{fig:3dero}}\n\\end{figure}\n\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.15]{atlas_dilate_color}\n\\caption{Atlas in Figure \\ref{fig:3dorig} after applying 3d labelled dilation. \\label{fig:3ddil}}\n\\end{figure}\n\n\n\n\\section{Conclusion}\nThis article provides two classes for erosions and dilations of label\nimages using algorithms developed in a previously published\nwork. These methods use parallel, scan-line base algorithms that offer\nvery fast operations.\n\\bibliographystyle{plain}\n\\bibliography{local,InsightJournal}\n\\nocite{ITKSoftwareGuide}\n\n\\end{document}\n\n", "meta": {"hexsha": "55eeafd2536c52fdc7e5f71457867cdb14eb9669", "size": 10713, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "article/Article.tex", "max_stars_repo_name": "mseng10/ITKLabelErodeDilate", "max_stars_repo_head_hexsha": "eafe0c50544b6e75e7f4b6c4cf17ca9b726eea68", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-10-17T15:38:09.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-13T21:01:08.000Z", "max_issues_repo_path": "article/Article.tex", "max_issues_repo_name": "mseng10/ITKLabelErodeDilate", "max_issues_repo_head_hexsha": "eafe0c50544b6e75e7f4b6c4cf17ca9b726eea68", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2016-03-13T15:18:58.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-18T23:05:34.000Z", "max_forks_repo_path": "article/Article.tex", "max_forks_repo_name": "mseng10/ITKLabelErodeDilate", "max_forks_repo_head_hexsha": "eafe0c50544b6e75e7f4b6c4cf17ca9b726eea68", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-05-18T15:22:31.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-17T06:52:01.000Z", "avg_line_length": 42.852, "max_line_length": 303, "alphanum_fraction": 0.785960982, "num_tokens": 2504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.4382918103861229}}
{"text": "\\subsubsection{\\stid{3.06} PETSc-TAO} \\label{subsubsect:petsc}\r\n\\paragraph{Overview} \r\n\r\nAlgebraic solvers (generally nonlinear solvers that use sparse linear solvers) and integrators form the \r\ncore computation of many numerical simulations. No scalable ``black box'' sparse solvers or integrators \r\nwork for all applications, nor are there single implementations that work well for all problem sizes. \r\nHence, algebraic solver and integrator packages provide a wide variety of algorithms and implementations \r\nthat can be customized for the application and range of problem sizes. PETSc/TAO~\\cite{petsc:homepage,petsc-man} \r\nis a widely used numerical library for the scalable solution of linear, nonlinear, and variational systems,\r\nfor integration of ODE/DAE systems and computation of their adjoints, and for numerical optimization. \r\nThis project focuses on three topics: (1) partially matrix-free scalable solvers to efficiently use \r\nmany-core and GPU-based systems; (2) reduced synchronization algorithms that can scale to larger \r\nconcurrency than solvers with synchronization points; and (3) performance and data structure \r\noptimizations for all the core data structures to better utilize many-core and GPU-based \r\nsystems as well as provide scalability to the exascale systems.\r\n\r\nThe availability of systems with over 100 times the processing power of today's machines compels the utilization \r\nof these systems not just for a single ``forward solve'' (as discussed above), but rather within a tight loop \r\nof optimization, sensitivity analysis (SA), and uncertain quantification (UQ). This requires the implementation \r\nof a new scalable library for managing a dynamic hierarchical collection of running scalable simulations, where \r\nthe simulations directly feed results into the optimization, SA, and UQ solvers.  This library, which we call \r\nlibEnsemble, directs the multiple concurrent ``function evaluations'' through the tight coupling and \r\nfeedback. This work consist of two parts: (1) the development of libEnsemble; and (2) the development \r\nof application-relevant algorithms to utilize libEnsemble.\r\n\r\n\\paragraph{Key Challenges}\r\n\r\nA key challenge for scaling the PETSc/TAO numerical libraries to Exascale systems is that traditional \r\n``sparse-matrix-based'' techniques for linear, nonlinear, and ODE solvers, as well as optimization \r\nalgorithms, are memory-bandwidth limited.  Another difficulty is that any synchronizations \r\nrequired across all compute units---for example, an inner product or a norm---can \r\ndramatically affect the scaling of the solvers.  Another challenge is the need to\r\nsupport the variety of accelerators that will be available on the exascale systems\r\nand the programming models that application teams use for performance\r\nportability.\r\n\r\nRunning an ensemble of simulations requires a coordination layer that handles load balancing and\r\nallows the collection of running simulations to grow and shrink based on feedback. Thus, our\r\nlibEnsemble library must be able to dynamically start simulations with different parameters, \r\nresume simulations to obtain more accurate results, prune running simulations that the solvers \r\ndetermine can no longer provide useful information, monitor the progress of the simulations, \r\nand stop failed or hung simulations, and collect data from the individual simulations both \r\nwhile they are running and at the end.\r\n\r\n\\paragraph{Solution Strategy}\r\n\r\nTo address the scalability of the numerical libraries, we implemented new solvers and data \r\nstructures including: pipeline Krylov methods that delay the use of the results of inner \r\nproducts and norms, allowing overlapping of the reductions and other computation; partially \r\nmatrix-free solvers using high-order methods that have high floating-point-to-memory-access \r\nratios and good potential to use many-core and GPU-based systems; and in-node optimizations \r\nof sparse matrix-matrix products needed by algebraic multigrid to better utilize many-core \r\nsystems.\r\n\r\nOur strategy for coordinating ensemble computations has been to develop libEnsemble\r\nto satisfy our needs.  This library should not be confused with workflow-based \r\nscripting systems; rather it is a library that, through the tight coupling and \r\nfeedback, directs the multiple concurrent ``function evaluations'' needed by \r\noptimization, SA, and UQ solvers.\r\n\r\n\\paragraph{Recent Progress}\r\n\r\nIn the past year, we have released PETSc/TAO 3.14 (available at \\url{http://www.mcs.anl.gov/petsc}),\r\nwhich features enhanced GPU support.  The library now supports CUDA-11 and HIP, along with CUDA-aware \r\nMPI, which allows direct communication of data between Summit GPUs, bypassing the previously needed \r\nstep of first copying the data to the CPU memory. This enhancement reduces the latency of the \r\ncommunication and improves bandwidth.  An experimental Kokkos backend for some matrix and \r\nvector operations using KokkosKernels was also provided, as one step in the refactoring \r\nprocess to support the variety of accelerators needed for exascale systems and the \r\nprogramming models for performance portability wanted by applications.\r\n\r\n\\begin{figure}\r\n\\centering\r\n\\includegraphics[trim = 0in .2in 1.7in .2in, clip, width=0.9\\textwidth]{projects/2.3.3-MathLibs/2.3.3.06-PETSc-TAO/petsc_arch}\r\n\\caption{The improved PETSc/TAO architecture enables users to utilize a variety of programming \r\nmodels for GPUs independently of PETSc's internal programming model.}\r\n\\label{fig:petsc-tao-fig}\r\n\\end{figure}\r\n\r\nWe have also release libEnsemble 0.7.1 (available at \\url{https://github.com/Libensemble/libensemble}).\r\nThis release includes new generator functions and examples, changes to become xSDK compatible, and \r\nimproved testing across available platforms.\r\n\r\n\\paragraph{Next Steps}\r\n\r\nOur next efforts are:\r\n\\begin{enumerate}\r\n  \\item \\textbf{Performance and application assessment}: \r\n  We will provide updated performance reports of PETSc/TAO on the architectures available to us.\r\n  We will work with our applications to assess the usage of our software technologies and our \r\n  progress toward reaching our impact goals.\r\n  We will add a libEnsemble guide for function writer users to the documentation and survey \r\n  the libEnsemble user community.\r\n  \\item \\textbf{PETSc/TAO release with full-functionality on available hardware}:\r\n  We will release a version of PETSc/TAO that fully supports the hardware and software on the \r\n  architectures available to us. \r\n  We will begin testing important kernels using different backends and prepare more methods to utilize accelerators.\r\n  \\item \\textbf{libEnsemble release with enhanced capabilities}:\r\n  We will release a version of libEnsemble that implements a method for Bayesian calibration. \r\n  We will connect libEnsemble to continuous integration tools and demonstrate capabilities.\r\n  \\item \\textbf{PETSc/TAO release focused on performance on available hardware}:\r\n  We will release a version of PETSc/TAO with performance improvements on the architectures available to us. \r\n  We will continue testing important kernels using different backends and optimize more methods to \r\n  utilize accelerators.\r\n\\end{enumerate}\r\n\r\n", "meta": {"hexsha": "54f87336a5b272593519f20ce293727abbaab2ae", "size": 7195, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/2.3.3-MathLibs/2.3.3.06-PETSc-TAO/2.3.3.06-PETSc-TAO.tex", "max_stars_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_stars_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/2.3.3-MathLibs/2.3.3.06-PETSc-TAO/2.3.3.06-PETSc-TAO.tex", "max_issues_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_issues_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/2.3.3-MathLibs/2.3.3.06-PETSc-TAO/2.3.3.06-PETSc-TAO.tex", "max_forks_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_forks_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.2429906542, "max_line_length": 127, "alphanum_fraction": 0.8, "num_tokens": 1499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4382917929923089}}
{"text": "\\section{Understanding ``Out Of Thin Air'' using Temporal Logic}\n\\label{sec:logic}\n\nA significant challenge for a software memory model is to relax order enough\nto allow efficient implementation without admitting anomalous\nbehaviors---called \\emph{out of thin air} (\\oota) in the literature\n\\cite{vacuous,DBLP:conf/esop/BattyMNPS15,BoehmOOTA}.  The most famous example\nis \\ref{OOTA3} from \\textsection\\ref{sec:intro}.  Here we inline\ninitialization in order to fit the format of our proof rules:\n\\begin{align}\n  \\label{OOTA3} \\tag{\\textsc{oota1}}\n  \\PW{y}{0}\\SEMI \n  \\PW{y}{x}\n  \\!\\PAR\\!\n  \\PW{x}{0}\\SEMI\n  \\PR{y}{r}\\SEMI \\PW{x}{r}  \n  &&\n  %\\nonumber\n  \\smash{\\hbox{\\begin{tikzinline}[node distance=1.2em]\n  \\event{rx}{\\DR{x}{1}}{}\n  \\event{wy}{\\DW{y}{1}}{right=of rx}\n  \\po{rx}{wy}\n  \\event{y0}{\\DW{y}{0}}{left=of rx}\n  \\event{x0}{\\DW{x}{0}}{right=2em of wy}\n  \\event{ry}{\\DR{y}{1}}{right=2em of x0}\n  \\event{wx}{\\DW{x}{1}}{right=of ry}\n  \\po{ry}{wx}\n  \\rf[out=10,in=170]{wy}{ry}\n  \\rf[out=170,in=10]{wx}{rx}\n  \\wk[out=-15,in=-165]{y0}{wy}\n  \\wk[out=-15,in=-165]{x0}{wx}\n    \\end{tikzinline}}}\n\\end{align}\nAlthough Java does not allow \\oota{} behaviors of \\ref{OOTA3},\n\\citet{DBLP:journals/toplas/Lochbihler13} showed that it does allow \\oota\\\nbehaviors of \\ref{OOTA1}, also from \\textsection\\ref{sec:intro}.  In\n\\cite{DBLP:conf/lics/JeffreyR16}, we described a logic that rules out\n\\ref{OOTA3} but not \\ref{OOTA1} or its variant \\ref{OOTA4}.  In this section,\nwe provide a more accurate test of \\oota{} behaviors by enhancing our\nprevious logic with temporal features.\n\nOn first read, we suggest that readers skip to the examples and the\ndiscussion that follows, coming back to the definitions as necessary.\nExample~\\ref{ex:thin} discusses the canonical \\oota{} example \\ref{OOTA3};\nthe analysis is trivial and well-known \\cite{DBLP:conf/lics/JeffreyR16,\n  DBLP:conf/popl/KangHLVD17}.  Example~\\ref{ex:lochb} is more interesting.\nThere, we discuss \\ref{OOTA4}, which is a variant of\n\\citeauthor{DBLP:journals/toplas/Lochbihler13}'s \\ref{OOTA1}.\n% In this case, the violation is a subtler\n% temporal property.  We develop a logic sufficient to prove that our semantics\n% disallows \\oota\\ on \\eqref{lochbihler}.  \n\nThe logic given here is not meant to be definitive; in\n\\textsection\\ref{sec:limits}, we discuss \\oota{} examples that appear to\nrequire non-trivial extensions\n\\cite{DBLP:conf/esop/SvendsenPDLV18,DBLP:journals/pacmpl/ChakrabortyV19}.\n\n\\noparagraph{Definitions}\nWe adapt past linear temporal logic (\\pLTL)\n\\cite{Lichtenstein:1985:GP:648065.747612} to pomsets by dropping the previous\ninstant operator and adopting strict versions of the temporal operators.\nThe atoms of our logic are write and read events.\n% \\begin{displaymath}\n%   \\afo \\QUAD::=\\QUAD\n%   \\DR{\\aLoc}{\\aVal}\n%   \\mid\n%   \\DW\\aLoc\\aVal\n%   \\afo \\wedge\\bfo\n%   \\mid \\lnot \\afo\n%   \\once\\afo\n%   \\mid \\always\\afo\n% \\end{displaymath}\n%\\begin{definition} %[Satisfaction]\nGiven a pomset $\\aPS$ and event $\\aEv$, define:\\nofootnote{Let $\\FALSE$, $\\lor$,\n  $\\Rightarrow$ and $\\once$ as usual;\n  for example,\n  $\\once\\afo = \\lnot(\\always\\lnot\\afo)$.}\n\\begin{displaymath}\n  \\renewcommand{\\arraycolsep}{.2ex}\n    \\begin{array}{lrll}\n      \\aPS,\\aEv &\\models& \\DW{\\aLoc}{\\aVal} &\\text{ if } \\labelingAct(\\aEv) = \\DW{\\aLoc}{\\aVal} \\text{ and } \\TRUE \\text{ implies } \\labelingForm(\\aEv) \\\\\n      \\aPS,\\aEv &\\models& \\DR{\\aLoc}{\\aVal} &\\text{ if } \\labelingAct(\\aEv) = \\DR{\\aLoc}{\\aVal} \\text{ and } \\TRUE \\text{ implies } \\labelingForm(\\aEv) \\\\\n      \\aPS,\\aEv &\\models& \\afo\\land\\bfo &\\text{ if } \\aPS,\\aEv \\models  \\afo \\text{ and } \\aPS,\\aEv \\models  \\bfo \\\\\n      \\aPS,\\aEv &\\models& \\TRUE\\\\\n      \\aPS,\\aEv &\\models& \\lnot\\afo &\\text{ if } \\aPS,\\aEv \\not\\models \\afo \\\\\n      \\aPS,\\aEv &\\models& \\always\\afo &\\text{ if } \\forall \\bEv \\lt \\aEv.\\; \\aPS,\\bEv \\models \\afo\\\\\n      \\aPS,\\aEv &\\models& \\once\\afo &\\text{ if } \\exists \\bEv \\lt \\aEv.\\;  \\aPS,\\bEv \\models \\afo \n    \\end{array} \n  \\end{displaymath}\n\n  Define $\\FALSE$, $\\lor$, and $\\Rightarrow$ as usual.\n\n  % \\begin{definition}\n  Let $\\aPS \\models \\afo$ if\n  $\\aPS,\\aEv \\models\\afo$, for all $\\aEv \\in \\Event$.\n\n  Let $\\aPSS\\models \\afo$\n  if $\\aPS \\models\\afo$, for all $\\aPS \\in \\aPSS$.\n  \nLet\n  \\begin{math}\n    \\afo, \\aPSS \\models \\bfo  \\text{ if } \\{ \\aPS \\mid \\aPS \\models \\afo \\} \\parallel \\aPSS \\models \\bfo.\n  \\end{math}\n%\\end{definition}\n\n  Let $\\afo$ be \\emph{downclosed} when\n  $\\{ \\aPS \\mid \\aPS \\models \\afo \\}$ is.\n\n% Thus, $\\aPS\\models \\afo \\land \\always\\afo$ whenever $\\aPS \\models\n  % \\afo$. This fact relies on the use of universal quantification in the definition.\n\n% We define other connectives as standard:\n% $\\once\\afo = \\lnot(\\always\\lnot\\afo)$,\n% %$\\FALSE = \\lnot(\\TRUE)$\n% $\\afo\\lor\\bfo = \\lnot(\\lnot(\\afo)\\land\\lnot(\\bfo))$, and\n% $\\afo\\Rightarrow\\bfo = \\lnot(\\afo) \\lor\\ \\bfo$.\n% \\begin{displaymath}\n% \\begin{array}{lrl}\n% \\once\\afo &=& \\lnot(\\always\\lnot\\afo) \\\\\n% \\FALSE &=& \\lnot(\\TRUE) \\\\\n% \\afo\\lor\\bfo &=& \\lnot(\\lnot(\\afo)\\land\\lnot(\\bfo)) \\\\\n% \\afo\\Rightarrow\\bfo &=& \\lnot(\\afo) \\lor\\ \\bfo\n% \\end{array}\n% \\end{displaymath}\n%Let $$ be defined as $$. \n%In addition, let $\\FALSE$, $\\lor$ and $$ be defined in the\n%standard way.\n% $\\afo\\lor\\bfo$ for $\\lnot(\\lnot \\afo \\land \\lnot \\bfo)$,\n% and $\\afo \\Rightarrow \\bfo$ for $\\lnot \\afo \\lor \\bfo$.\n  The past operators do not include the current instant, and so\n  do \\emph{not} satisfy\n  $(\\always\\afo\\Rightarrow\\once\\afo)$. The order-minimal elements always validate\n    $\\always\\afo$ and invalidate\n    $\\once\\afo$.\n  However, we can prove the following:\n% \\begin{align*}  \n%   \\frac{\\aPS \\models \\afo \\Rightarrow\\once{\\afo}}{\\aPS \\models \\lnot \\afo}\\text{(Coinduction)}\n%   &&\n%   \\frac{\\aPS \\models \\always\\afo \\Rightarrow\\afo}{\\aPS \\models \\afo}\\text{(Induction)}\n% \\end{align*}\n% \\begin{lemma}\n% Given an pomset $\\aPS$.  \n\\begin{align*}\n  \\tag{Induction}\n  \\aPS \\models& (\\always\\afo \\Rightarrow\\afo) \\Rightarrow\\afo\n  \\\\[-1ex]\n  \\tag{Coinduction}\n  \\aPS \\models& (\\afo \\Rightarrow\\once{\\afo}) \\Rightarrow\\lnot \\afo\n  \\\\[-1ex]\n  \\tag{Weakening}\n  \\aPS \\models& (\\afo \\Rightarrow\\once{\\bfo}) \\Rightarrow (\\once\\afo \\Rightarrow\\once{\\bfo})\n\\end{align*}\n% \\end{lemma}\n% \\begin{proof}\n% We prove that any node in a pomset satisfies these formulas.  \n%The proof for both rules proceeds by induction on the length of the maximal path from a root to a node. \n%\\end{proof}\n\n% \\begin{description}\n% \\item[Coinduction.]\n%   \\begin{math}\n%     (\\afo \\Rightarrow\\once{\\afo}) \\Rightarrow\\lnot \\afo\n%   \\end{math}\n% \\item[Induction.] \n%   \\begin{math}\n%     (\\always\\afo \\Rightarrow\\afo) \\Rightarrow\\afo\n%   \\end{math}\n% \\end{description}\n\n\n%We now present two proof rules for programs. \n\n%\\paragraph*{Proof rules for programs}\nWe present two additional proof rules. \nThe first provides a logical view of \\emph{$\\aLoc$-closure} (Def.~\\ref{def:rf}):\n%The soundness proof is straightforward.\n% \\begin{math}\n%   \\closed(\\aLoc) = (\\DR{\\aLoc}{\\aVal} \\Rightarrow \\once \\DW{\\aLoc}{\\aVal}).\n% \\end{math}\n% Although this definition does not mention intervening writes, it is\n% sufficient for our example.  \n\\begin{displaymath}\n  %\\tag{Closing $\\aLoc$}\n  \\frac{\n    \\afo \\text{ is independent of } \\aLoc\n    \\qquad\n    %\\aPS \\models \\closed(\\aLoc) \\Rightarrow \\afo\n    \\aPS \\models (\\DR{\\aLoc}{\\aVal} \\Rightarrow \\once \\DW{\\aLoc}{\\aVal}) \\Rightarrow \\afo\n  }{\n    \\nu \\aLoc \\DOT \\aPS \\models \\afo\n  }\n\\end{displaymath}\n%It is straightforward to establish that this rule is sound.\n% Although it does\n% not mention intervening writes, the rule is sufficient for our examples.\n\nThe second rule describes concurrent composition, in the style of~\\citet{Abadi:1993:CS:151646.151649}.  To simplify the presentation, we\nconsider the special case with a single invariant.\n% We view the\n% composition result as capturing key aspects of no-ThinAirRead, as will become\n% clearer in the examples below.\n% In order to state the theorem, we generalize the satisfaction relation to\n% include environment assumptions.\n\n\\begin{proposition}%[Composition]\n  Let $\\afo$ be downclosed.  Let $\\aPSS_1, \\aPSS_2$ be\n  augmentation\\hyp{}closed. %\\footnote{$\\aPS'$ is an augmentation of $\\aPS$ if\n %   $\\Event'=\\Event$, $\\aEv\\le\\bEv$ implies $\\aEv\\le'\\bEv$, $\\aEv\\gtN\\bEv$\n %   implies $\\aEv\\gtN'\\bEv$, and\n %   % $\\labeling'(\\aEv)=\\labeling(\\aEv)$\n %   if $\\labeling(\\aEv) = (\\bForm \\mid \\bAct)$ then\n %   $\\labeling'(\\aEv) = (\\bForm' \\mid \\bAct)$ where $\\bForm'$ implies\n %   $\\bForm$.}\n  Then:\n  \\begin{displaymath}\n    %\\tag{Composition}\n    \\frac{\n      \\afo, \\aPSS_1 \\models\\afo\n      \\qquad\n      \\afo, \\aPSS_2 \\models\\afo\n    }{\\aPSS_1 \\parallel \\aPSS_2 \\models \\afo}\n  \\end{displaymath}\n\\end{proposition}\n\\begin{proof}[Proof sketch]\n  We will show that all downsets in the downset closures of\n  $\\aPSS_1 \\parallel \\aPSS_2$ satisfy the required property.  Proof proceeds\n  by induction on downsets of $\\aPS \\in \\aPSS_1 \\parallel \\aPSS_2$.\n  %\n  The case for empty downset  follows from assumption that  $\\afo$ is downset closed.  \n  %\n  For the inductive case, consider %$\\aPS$ in the downset closure of $\\aPSS_1 \\parallel \\aPSS_2$, i.e.\n  $\\aPS \\in \\aPS_1 \\parallel \\aPS_2$ where\n  $\\aPS_i \\in \\aPSS_i$.  Since $\\aPSS_1$ and $\\aPSS_2$ are augmentation\n  closed, we can assume that the restriction of $\\aPS$ to the events of\n  $\\aPS_i$ coincides with $\\aPS_i$, for $i=1,2$.\n  %\n  Consider a downset $\\aPS'$ derived by removing a maximal element $\\aEv$ from\n  $\\aPS$.  Suppose $\\aEv$ comes from $\\aPS_1$ (the other case is\n  symmetric). Since $\\aPS_2$ is a downset of $\\aPS'$ and $\\aPS' \\models \\afo$\n  by induction hypothesis, we deduce that $\\aPS_2 \\models \\afo$.\n  % Thus, $\\aPS_2 \\in \\mods{(\\afo)}$.\n  Since $\\aPS_1 \\in \\aPSS_1$, by assumption $\\afo, \\aPSS_1 \\models\\afo$ we\n  deduce that $\\aPS \\models \\afo$.\n\\end{proof}\n\n% The logic is defined with respect to downclosed sets, but $\\sem{\\aCmd}$\n% includes only completed pomsets.  For reasoning in the logic, we downclose\n% the semantics, considering pomsets that may not be completed.  Let\n% $\\semdown{\\aCmd}=\\{\\aPS'\\mid\\aPS'$ is a downset of some\n% $\\aPS \\in \\sem{\\aCmd}\\}$.\n\n\\begin{example}\n\\label{ex:thin}\n\\noparagraph{Basic Examples}\nWith all variables initialized to $0$, we show that \\ref{OOTA3}\nsatisfies\n\\begin{math}\n  \\lnot\\DW{x}{1}.\n\\end{math}\n\nWe start with the invariant:\n\\begin{displaymath}\n  [\\DW{x}{1}\\Rightarrow\\once\\DR{y}{1}]\n  \\land\n  [\\DW{y}{1}\\Rightarrow\\once\\DR{x}{1}]\n\\end{displaymath}\nThis invariant holds for each thread; thus, it holds for the\naggregate program by composition.  Closing $y$ yields\n\\begin{math}\n  \\DR{y}{1} \\Rightarrow \\once\\DW{y}{1}.\n\\end{math}\nWeakening the right conjunct: % yields\n\\begin{math}\n  \\once\\DW{y}{1}\\Rightarrow\\once\\DR{x}{1}.\n\\end{math}\nChaining these together: %yields\n\\begin{math}\n  \\DR{y}{1} \\Rightarrow \\once\\DR{x}{1}.\n\\end{math}\nWeakening:  %yields\n\\begin{math}\n  \\once\\DR{y}{1} \\allowbreak\\Rightarrow \\once\\DR{x}{1}. \n\\end{math}\nChaining into the left conjunct:  %yields\n\\begin{math}\n  \\DW{x}{1} \\Rightarrow \\once\\DR{x}{1}. \n\\end{math}\nClosing $x$, \n% \\begin{math}\n%   \\DR{x}{1} \\Rightarrow \\once\\DW{x}{1}.\n% \\end{math}\nweakening, \n% \\begin{math}\n%   \\once\\DR{x}{1} \\Rightarrow \\once\\DW{x}{1}.\n% \\end{math}\nthen chaining: %, yields\n\\begin{math}\n  \\DW{x}{1} \\Rightarrow \\once\\DW{x}{1}. \n\\end{math}\nBy coinduction, \n\\begin{math}\n  \\lnot\\DW{x}{1}.\n\\end{math}\n%as required.\n\\end{example}\n\n% The same reasoning can be applied to the control flow variant of \\ref{OOTA3}\n% \\cite[CYC]{DBLP:conf/popl/VafeiadisBCMN15}:\n% \\begin{math}\n%   %\\tag{\\textsc{cyc}}\\label{CYC}\n%   \\IF{x}\\THEN \\PW{y}{1} \\FI \\!\\PAR\\! \\IF{y}\\THEN \\PW{x}{1} \\FI.\n%   % &&\n%   % %\\nonumber\n%   % \\hbox{\\begin{tikzinline}[node distance=1.5em]\n%   % \\event{rx}{\\DR{x}{1}}{}\n%   % \\event{wy}{\\DW{y}{1}}{right=of rx}\n%   % \\po{rx}{wy}\n%   % \\event{ry}{\\DR{y}{1}}{right=2em of wy}\n%   % \\event{wx}{\\DW{x}{1}}{right=of ry}\n%   % \\po{ry}{wx}\n%   % \\rf{wy}{ry}\n%   % \\rf[out=170,in=10]{wx}{rx}\n%   %   \\end{tikzinline}}\n% \\end{math}\n% The program is data-race-free. Thus, allowing an execution that writes $1$\n% would violate \\drfsc{}.\n\n\\begin{example}\n  \\label{ex:lochb}\n  \\noparagraph{Lochbihler's Example} %The essential temporal property of\n  % \\ref{OOTA1} is: \\emph{A write of $1$ to $y$ must be preceded by a read of\n  %   $1$ from $x$, and if $1$ is written to $z$ then a write of $1$ to $x$\n  %   must be preceded by a read of $1$ from $y$.}\n  % \\emph{allocation at type $\\classC$ is preceded by reading $0$ for\n  % $b$}.  \n  Because our language lacks object creation, we cannot consider\n  \\citeauthor{DBLP:journals/toplas/Lochbihler13}'s example (\\ref{OOTA1}) directly.  Instead we study \\ref{OOTA4}, which has the same\n  temporal structure.\n  The essential temporal property of\n  \\ref{OOTA4} is: \\emph{A write of $1$ to $y$ must be preceded by a read of\n    $1$ from $x$, and if $1$ is written to $z$ then a write of $1$ to $x$\n    must be preceded by a read of $1$ from $y$.}\n  % : \\emph{writing $1$ for $x$ is preceded by reading $0$ for\n  % $b$}.  \n  We show an attempted execution that violates this invariant, eliding\n  initialization:\n% A more general principle, in the spirit of~\\citet{Abadi:1993:CS:151646.151649} can be proved.  We chose the simple case of temporal invariants to illustrate the idea in a simple form.  Even this simple version has interesting consequences. \n\\begin{gather}\n  %\\tag{\\textsc{oota4}}\n  \\label{OOTA4}\\tag{\\textsc{oota4}}\n  %   Z=1;\n  % ||\n  %   a=X; // 1\n  %   Y=a;\n  % ||\n  %   b=Z; // 0\n  %   if(b){\n  %     X=1\n  %   } else {\n  %     c=Y; // 1\n  %     X=c;\n  %     W=c;\n  %   }\n  %     \\VAR  \\PW{x}{0}\\SEMI \\VAR  \\PW{y}{0}\\SEMI \\VAR  \\PW{z}{0}\\SEMI\n  \\begin{gathered}\n    %\\PW{y}{0}\\SEMI\n    \\PW{y}{x}\n  \\PAR\n  % \\PW{x}{0}\\SEMI\n  % \\PW{z}{0}\\SEMI\n  \\PR{y}{r} \\SEMI \\IF{b}\\THEN  \\PW{x}{r} \\SEMI \\PW{z}{r} \\ELSE \\PW{x}{1} \\FI\n  \\PAR\n  %\\PW{b}{0}\\SEMI\n    \\PW{b}{1}\n  \\\\[-1ex]\n% \\hbox{\\begin{tikzinline}[node distance=1.25em]\n%   \\event{wy0}{\\DW{y}{0}}{}\n%   \\event{rx}{\\DR{x}{1}}{right=.5em of wy0}\n%   \\event{wy}{\\DW{y}{1}}{right=of rx}\n%   \\po{rx}{wy}\n%   \\event{wx0}{\\DW{x}{0}}{right=2em of wy}\n%   \\event{wz0}{\\DW{z}{0}}{right=.5em of wx0}\n%   \\event{ry}{\\DR{y}{1}}{right=of wz0}\n%   \\event{wx}{\\DW{x}{1}}{right=of ry}\n%   \\event{wz}{\\DW{z}{1}}{right=of wx}\n%   \\po{ry}{wx}\n%   \\event{rb}{\\DR{b}{1}}{right=of wz}\n%   \\event{wb0}{\\DW{b}{0}}{right=2em of rb}\n%   \\event{wb1}{\\DW{b}{1}}{right=.8em of wb0}\n%   \\wk{wb0}{wb1}\n%   \\rf[out=15,in=165]{wy}{ry}\n%   \\rf[out=-170,in=-10]{wx}{rx}\n%   \\po[out=25,in=25]{ry}{wz}\n%   \\wk[out=25,in=155]{wy0}{wy}\n%   \\wk[out=19,in=161]{wx0}{wx}\n%   \\wk[out=19,in=161]{wz0}{wz}\n%   \\rf[out=-170,in=-17]{wb1}{rb}\n%   \\po{rb}{wz}\n% \\end{tikzinline}}\n\\hbox{\\begin{tikzinline}[node distance=1.5em]\n      \\event{rx}{\\DR{x}{1}}{}\n      \\event{wy}{\\DW{y}{1}}{right=of rx}\n      \\po{rx}{wy}\n      \\event{ry}{\\DR{y}{1}}{right=3em of wy} \n      \\event{wx}{\\DW{x}{1}}{right=of ry}\n      \\event{wz}{\\DW{z}{1}}{right=of wx}\n      \\event{rb}{\\DR{b}{1}}{right=of wz}\n      \\event{wb1}{\\DW{b}{1}}{right=3em of rb}\n      \\po{ry}{wx}\n      \\rf{wb1}{rb}\n      \\rf{wy}{ry}\n      \\rf[out=-170,in=-10]{wx}{rx}\n      \\po{rb}{wz}\n      \\po[out=15,in=165]{ry}{wz}\n\\end{tikzinline}}\n  \\end{gathered}  \n\\end{gather}\nAs we discussed in \\textsection\\ref{sec:pop} there is a dependency from\n$(\\DR{y}{1})$ to $(\\DW{x}{1})$; thus, the outcome is disallowed.  This\noutcome is also disallowed by our event structures model\n\\citep[\\textsection9]{DBLP:journals/lmcs/JeffreyR19}, although the logic\ngiven in that paper is insufficient to establish this fact.  The outcome is\n\\emph{allowed} by \\citet{Manson:2005:JMM:1047659.1040336}, \\citet{DBLP:conf/esop/JagadeesanPR10},\n\\citet{DBLP:conf/popl/KangHLVD17}, and\n\\citet{DBLP:journals/pacmpl/ChakrabortyV19}.\n% , demonstrating a lack of\n% compositionality in these models.\n% \\begin{tikzdisplay}[node distance=1.5em]\n%   \\event{wy0}{\\DW{y}{0}}{}\n%   \\event{rx}{\\DR{x}{1}}{right=4.5em of wy0}\n%   \\event{wy}{\\DW{y}{1}}{right=of rx}\n%   \\po{rx}{wy}\n%   \\wk[bend left]{wy0}{wy}\n%   \\event{wx0}{\\DW{x}{0}}{below=of wy0}\n%   \\event{rz}{\\DR{z}{0}}{right=of wx0}\n%   \\event{ry}{\\DR{y}{1}}{right=of rz}\n%   \\event{wx}{\\DW{x}{1}}{right=of ry}\n%   \\event{ry1}{\\DR{y}{1}}{right=of wx}\n%   \\event{wa}{\\DW{a}{1}}{right=of ry1}\n%   \\rf{wy}{ry1}\n%   \\po{ry}{wx}\n%   \\wk[bend right]{wx0}{wx}\n%   \\rf{wy}{ry}\n%   \\rf{wx}{rx}\n%   \\event{wz0}{\\DW{z}{0}}{below=of wx0}\n%   \\event{wz1}{\\DW{z}{1}}{right=of wz0}\n%   \\rf{wz0}{rz}\n%   \\wk{wz0}{wz1}\n%   \\po{ry1}{wa}\n%   \\po[bend right]{rz}{wa}\n% \\end{tikzdisplay}\n\nTo establish that this outcome is disallowed here, we prove \n\\begin{math}\n  \\lnot\\DW{z}{1},\n\\end{math}\nstarting with invariant:\n% which holds for each of the three threads, and thus, by composition, for the\n% aggregate program:\n\\begin{align*}\n  [\\once\\DW{y}{1} \\Rightarrow \\once\\DR{x}{1}]\n  \\land\n  [\\notonce\\DW{z}{1} \\Rightarrow (\\once\\DR{y}{1} \\land \\always(\\DW{x}{1} \\Rightarrow \\once\\DR{y}{1}))]\n\\end{align*}\nClosing $y$ and chaining into the left conjunct:\n% \\begin{math}\n%   \\once\\DR{y}{1} \\Rightarrow \\once\\DW{y}{1}. % \\Rightarrow \\once\\DR{x}{1}\n% \\end{math}\n% Chaining this implication on the left:\n\\begin{math}\n  \\once\\DR{y}{1} \\Rightarrow \\once\\DR{x}{1}.\n\\end{math}\n% We can weaken this to:\n% \\begin{math}\n%   \\once\\DR{y}{1} \\Rightarrow \\once\\DR{x}{1}. % \\Rightarrow \\once\\DR{x}{1}\n% \\end{math}\nChaining into the right conjunct:\n\\begin{displaymath}\n  \\notonce\\DW{z}{1} \\Rightarrow (\\once\\DR{x}{1} \\land \\always(\\DW{x}{1} \\Rightarrow \\once\\DR{x}{1}))\n\\end{displaymath}\nClosing $x$:\n% \\begin{math}\n%   \\once\\DR{x}{1} \\Rightarrow \\once\\DW{x}{1}.\n% \\end{math}\n%  Weakening and chaining again:\n%we can replace $\\once\\DR{x}{1}$ with $\\once\\DW{x}{1}$:\n\\begin{math}\n  \\notonce\\DW{z}{1} \\Rightarrow (\\once\\DW{x}{1} \\land \\always(\\DW{x}{1} \\Rightarrow \\once\\DW{x}{1}).\n\\end{math}\nApplying coinduction to the right conjunct:\n\\begin{displaymath}\n  \\notonce\\DW{z}{1} \\Rightarrow (\\once\\DW{x}{1} \\land \\always(\\lnot \\DW{x}{1}))\n\\end{displaymath}\nSimplifying:\n\\begin{math}\n  \\notonce\\DW{z}{1} \\Rightarrow \\FALSE,\n\\end{math}\nas required.\n\\end{example}\n\n\n\\begin{comment}\n  \\color{red} Need to sort this out.\n  Alan proposes:\n\\begin{verbatim}\n     (W y 2) => <>(R x 1)\n     (W y 1) => <>(R x 0)\n     (W x 1) => <>(R y 1)\n   <>(W x 1) => not(<>(W x 2))  --- which should be???  <>(W x 0) => not(<>(W x 1))\n\\end{verbatim}\n\n2020/09/30: This seems to go bad because of initialization...\nThe formula\n\\begin{verbatim}\n<>Wx0 => not(<>Wx1)\n\\end{verbatim}\ndoes not hold for\n\\begin{verbatim}\nx=0; x=y\n\\end{verbatim}\n\n2020/09/10:  I am worried about the compositionality of this predicate:\n\\begin{verbatim}\nI think\n   <>(W x 0 => not(<>(W x 1)))\nholds for \n   x=0; r=y \nand\n   x=1\nbut not\n   x=0; r=y || x=1\nas shown by the execution\n   Wx1 < Wx0 < Ry0\n\\end{verbatim}\n  \nIt is impossible to fulfill $(\\DR{y}{1})$ in the following\n\\cite[RNG]{DBLP:conf/esop/SvendsenPDLV18}:\n\\begin{align*}\n  \\taglabel{OOTA5}\n    ( \\PW{y}{x{+}1}\n    \\PAR\n    \\PW{x}{y} ) && \\hbox{\\begin{tikzinline}[node distance=1.5em]\n        \\event{rx}{\\DR{x}{1}}{}\n        \\event{wy}{\\DW{y}{2}}{right=of rx}\n        \\po{rx}{wy}\n        \\event{ry}{\\DR{y}{1}}{right=3em of wy}\n        \\event{wx}{\\DW{x}{1}}{right=of ry}\n        \\po{ry}{wx}\n        \\rf[out=170,in=10]{wx}{rx}\n      \\end{tikzinline}}\n\\end{align*}\nThe proof proceeds as before, starting with the following invariant:\n\\begin{gather*}\n  [\\DW{y}{2} \\Rightarrow \\once\\DR{x}{1}] \\land\n  [\\once\\DW{x}{1} \\Rightarrow \\once\\DR{y}{1}] \\land\n  [\\once\\DW{y}{1} \\Rightarrow \\once\\DR{x}{0}] \\land\n  [\\once\\DW{x}{0} \\Rightarrow \\lnot(\\once\\DW{x}{1})]\n\\end{gather*}\n\\begin{verbatim}\n  Wy2 => <>Rx1  /\\  <>Wx1 => <>Ry1  /\\  <>Wy1 => <>Rx0  \nclose x and y                                          \n  Wy2 => <>Wx1  /\\  <>Wx1 => <>Wy1  /\\  <>Wy1 => <>Wx0  \nchain\n  Wy1 => <>Wx0  \nchain with <>Wx0 => not(<>Wx1)\n\\end{verbatim}\n\\end{comment}\n\n% Many examples are superficially similar, but in fact have fewer dependencies.\n% A referee for a previous version of this paper expected that the following example is\n% ``the same'':\n% \\begin{gather*}\n%   \\tag{OOTA?}\\label{OOTA?}\n%     \\PW{y}{x}\n%   \\PAR\n%     \\IF{y}\\THEN \\PR{y}{r}\\SEMI \\PW{x}{r}\\SEMI a\\GETS r \\ELSE \\PW{x}{1} \\FI\n%   \\\\\n%   \\hbox{\\begin{tikzinline}[node distance=1.5em]\n%   \\event{rx}{\\DR{x}{1}}{}\n%   \\event{wy}{\\DW{y}{1}}{right=of rx}\n%   \\po{rx}{wy}\n%   \\event{ry}{\\DR{y}{1}}{right=2em of wy}\n%   \\event{wx}{\\DW{x}{1}}{right=of ry}\n%   \\event{wa}{\\DW{a}{1}}{right=of wx}\n%   \\rf[out=-15,in=-165]{wy}{ry}\n%   \\rf[out=170,in=10]{wx}{rx}\n%   \\po[out=-15,in=-165]{ry}{wa}\n%     \\end{tikzinline}}\n% \\end{gather*}\n% In this execution, $\\DW{x}{1}$ is independent of $\\DR{y}{1}$, thus there is no\n% \\oota{} behavior.\n\nMany examples are superficially similar, but in fact have fewer dependencies,\nsuch as \\eqref{OOTA?} from \\textsection\\ref{sec:intro}.\n\n\\noparagraph{RFUB: Register assignment From an Unexecuted Branch}\n\\citeauthor{BoehmOOTA}'s [\\citeyear{BoehmOOTA}] \\ref{RFUB} example presents\nanother potential form of \\oota{} behavior.\n% , in the context of compiler\n% optimization.\nOur analysis shows that there is no \\oota{} behavior in\n\\ref{RFUB}, only a false dependency:\n%\\citet{BoehmOOTA} \\labeltext{considers}{page:rfub} the following programs:\n\\begin{gather*}\n  \\tag{\\textsc{rfub}}\\label{RFUB}\n  \\sem{\\PR{y}{r}\\SEMI \\PW{x}{r}}\n  \\not\\supseteq\n  \\sem{\\PR{y}{r}\\SEMI \\IF{r \\NOTEQ 1} \\THEN \\PW{z}{1}\\SEMI \\LET{r}{1}\\FI \\SEMI \\PW{x}{r}}\n\\end{gather*}\nThe left command is half of \\ref{OOTA3}. %, from \\textsection\\ref{sec:logic}.\nThe right command is dubbed \\rfub{}, for \\emph{Register assignment From an\n  Unexecuted Branch}.  \\citeauthor{BoehmOOTA} observes that in the context\n$\\PW{x}{y} \\PAR \\hole{}$, these programs have different behaviors.  Yet the\n\\oota{} example on the left never writes $1$.  Why should the unexecuted\nbranch change that?  Because of the conditional, the write to $x$ in\n\\ref{RFUB} is independent of the read from $y$.  It useful to considering the\nHoare logic formulas satisfied by the two threads above: we have\n$\\hoare{\\TRUE}{\\ref{RFUB}}{x=1}$ for the right thread of \\ref{RFUB}, but not\n$\\hoare{\\TRUE}{\\ref{OOTA3}}{x=1}$ for the right thread of \\ref{OOTA3}.  The\nchange in the thread from \\ref{OOTA3} to \\ref{RFUB} is not a valid refinement\nunder Hoare logic; thus, it is expected that \\ref{RFUB} may have additional\nbehaviors.\n\nUnderstanding \\oota{} behavior is notoriously difficult, even for the\ngreatest minds in the field!  % We believe that \\emph{logic} is the only tool\n% that can cut the horrible knot that semanticists have tied themselves in.\n% Preconditions provide a \\emph{natural} solution to working out these\n% dependencies.\nThis example shows the wisdom of using existing tools, such as preconditions\nand Hoare logic, to model new problems, such as relaxed memory.\n% We don't\n% need to abandon established ideas; we only need to adapt them!\n% On page \\pageref{page:rfub}, we discuss \\citeauthor{BoehmOOTA}'s\n% [\\citeyear{BoehmOOTA}] \\ref{RFUB} example, which presents another potential\n% form of \\oota{} behavior, in the context of compiler optimization.  Our\n% analysis shows that there is no \\oota{} behavior in \\ref{RFUB}, instead\n% \\citeauthor{BoehmOOTA}'s analysis has a false dependency.\n\n% Understanding \\oota{} behavior is notoriously difficult, even for the\n% greatest minds in the field!  We believe that \\emph{logic} is the only tool\n% that can cut the horrible knot that semanticists have tied themselves in.\n% Preconditions provide a \\emph{natural} solution to working out these\n% dependencies.\n\n% \\endinput\n\n% \\paragraph{Load buffering and thin air.}\n% The program\n% \\begin{math}\n%   %\\PW{x}{0}\\SEMI \\PW{y}{0}\\SEMI\n%   (\\PW{y}{x} \\PAR \\bReg\\GETS y\\SEMI \\PW{x}{1})\n% \\end{math}\n% has top level executions that result in the final outcome $x = y = 1$, such as:\n% \\begin{tikzdisplay}[node distance=1.5em]\n%   % \\event{wx0}{\\DW{x}{0}}{}\n%   % \\event{wy0}{\\DW{y}{0}}{below=wx0}\n%   \\event{rx}{\\DR{x}{1}}{}\n%   \\event{wy}{\\DW{y}{1}}{right=of rx}\n%   \\po{rx}{wy}\n%   \\event{ry}{\\DR{y}{1}}{right=3em of wy}\n%   \\event{wx}{\\DW{x}{1}}{right=of ry}\n%   \\rf{wy}{ry}\n%   \\rf[out=170,in=10]{wx}{rx}\n%   %\\po{rx}{wy}\n% \\end{tikzdisplay}\n% In \\textsection\\ref{sec:logic} we provide machinery to prove that this\n% outcome is impossible if there is order from read to write in both\n% threads.  This order can be achieved by replacing the second thread\n% \\begin{math}\n%   (\\bReg\\GETS y\\SEMI \\PW{x}{1})\n% \\end{math}\n% with \n% \\begin{math}\n%   (\\bReg\\GETS y^\\mRA\\SEMI \\PW{x}{1})\n% \\end{math}\n% or\n% \\begin{math}\n%   (\\IF{y}\\THEN \\PW{x}{1}\\FI)\n% \\end{math}\n% or\n% \\begin{math}\n%   (\\PW{x}{y}).\n% \\end{math}\n\n% A more interesting example is the following variant of \\eqref{types}:\n% \\begin{displaymath}\n%   %\\label{OOTA4}\n%   % \\PW{x}{0}\\SEMI\n%   %\\PW{y}{0}\\SEMI   \n%   (\n%     \\PW{y}{x}\n%   \\PAR\n%     \\IF{z}\\THEN \\PW{x}{1} \\ELSE \\PW{x}{y}\\SEMI a\\GETS y \\FI\n%   \\PAR\n%     \\PW{z}{0}\\SEMI \\PW{z}{1}\n%   )\n% \\end{displaymath}\n% This program is allowed to write $1$ to $a$ under many speculative\n% memory models\n% \\cite{Manson:2005:JMM:1047659.1040336,DBLP:conf/esop/JagadeesanPR10,DBLP:conf/popl/KangHLVD17},\n% even though the read of $1$ from $y$ in the else branch of the second\n% thread arises out of thin air.   \\citet{DBLP:journals/toplas/Lochbihler13}\n% argues that such executions compromise type safety unless object allocation\n% partitions memory by type.\n% In our model, the attempted execution is:\n% \\begin{tikzdisplay}[node distance=1.5em]\n%   \\event{rx}{\\DR{x}{1}}{}\n%   \\event{wy}{\\DW{y}{1}}{below=of rx}\n%   \\po{rx}{wy}\n%   \\event{ry}{\\DR{y}{1}}{right=of rx}\n%   \\event{wx}{\\DW{x}{1}}{below=of ry}\n%   \\po{ry}{wx}\n%   \\rf{wy}{ry}\n%   \\rf{wx}{rx}\n%   \\event{rz}{\\DR{z}{0}}{right=of ry}\n%   \\event{wz0}{\\DW{z}{0}}{right=of rz}\n%   \\rf{wz0}{rz}\n%   \\event{wz1}{\\DW{z}{1}}{right=of wz0}\n%   \\wk{wz0}{wz1}\n%   \\event{ry1}{\\DR{y}{1}}{below=of rz}\n%   \\rf[bend right]{wy}{ry1}\n%   \\event{wa}{\\DW{a}{1}}{right=of ry1}\n%   \\po{ry1}{wa}\n%   \\po{rz}{wa}\n% \\end{tikzdisplay}\n% This is forbidden by the evident cycle.\n\n\n% \\begin{verbatim}\n\n\n\n% y=x+1; a=y || x=y\n% prove a!=2\n\n% Wyv_1 /\\ Wyv_2 => v_1 == v_2 (and maybe v_1==0 \\/ v_2==0)\n% Wx1 => <>-1 Ry1\n% Wy1 => <>-1 Rx1\n% \\end{verbatim}\n\n% Local Variables:\n% mode: latex\n% TeX-master: \"paper\"\n% End:\n", "meta": {"hexsha": "29a908280421495c1292bb146c66052dde0c8e45", "size": 26281, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "logic.tex", "max_stars_repo_name": "chicago-relaxed-memory/memory-model", "max_stars_repo_head_hexsha": "fd606fdb6a04685d9bb0bee61a5641e4623b10be", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-08-13T02:36:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-25T12:46:13.000Z", "max_issues_repo_path": "logic.tex", "max_issues_repo_name": "chicago-relaxed-memory/memory-model", "max_issues_repo_head_hexsha": "fd606fdb6a04685d9bb0bee61a5641e4623b10be", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "logic.tex", "max_forks_repo_name": "chicago-relaxed-memory/memory-model", "max_forks_repo_head_hexsha": "fd606fdb6a04685d9bb0bee61a5641e4623b10be", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2765100671, "max_line_length": 242, "alphanum_fraction": 0.6415281001, "num_tokens": 9900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4382917929923089}}
{"text": "\\chapter{Theory of Algebraic Diagrammatic Construction}\n\nEssentially, ADC is a kind of many-body perturbation theory, whose basic idea is to divide Hamiltonian to unperturbed part and perturbed part, and the sum over different orders of contribution.\nIf the summation is over all the contributions from infinite orders, then the exact energy will be obtained.\nObviously, numerically it is impossible to do so, thus a simple idea is to truncate the summation to some particular order.\nHowever, when the order increases, on one hand, the expression for a direct perturbation become very complicated, on the other hand, the size inconsistency problem appears again.\nAlthough it is shown that in the first few order all ill-behaved terms that break size consistency are canceled finally, a reason and proof is needed for higher orders.\n\nOn the other hand, instead of designed for solving ground state like what all the methods we discussed previously does, ADC is designed for ionization potential, electron affinity or excited state.\nInterestingly, all these different purposes are based on a same theoretical framework, which is propagator, Green function and Feynman diagram.\nThere similarity is that all these processes include gain and loss of electrons, which is obvious in the ionization potential and electron affinity case.\nIn the excited state case, it can be viewed as gain of an electron with higher energy and loss with lower energy.\nThus, number of electrons is never conserved in ADC, which is hard to deal with in the formal quantum mechanics framework, which means a new tool is needed.\n\nIn order to finish these purposes, a many-body field theory approach is required, which originates from quantum field theory which is developed for a theoretical elementary particle physics.\nAfter quantum field theory is constructed, the idea of field theory is quickly transferred to many-body physics, which becomes the basis of many-body perturbation theory.\n\nIn many-body field theory, a language of second quantization is used.\nWe have used a little second quantization when discussing the Post-Hartree Fock part for convenience.\nHowever, we didn't give a formal definition for the notations we give.\n\nThus, in this chapter, we will firstly formally introduce second quantization, Green function and Feynman diagram.\nThen we will discuss how these concepts are applied to ADC and to calculate the three kinds of energies mentioned above.\nFinally, we will discuss the concept intermediate state and its relation with size consistency and compactness, and prove that ADC is both a canonical and size consistent method.\n\n\n", "meta": {"hexsha": "95543b476d46be5c16e0514874d71e2e78191550", "size": 2625, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/theory.tex", "max_stars_repo_name": "SUSYUSTC/bachelor_thesis", "max_stars_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/theory.tex", "max_issues_repo_name": "SUSYUSTC/bachelor_thesis", "max_issues_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/theory.tex", "max_forks_repo_name": "SUSYUSTC/bachelor_thesis", "max_forks_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.2222222222, "max_line_length": 197, "alphanum_fraction": 0.8167619048, "num_tokens": 506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4382624182771787}}
{"text": "\\documentclass{article}\n\n\\usepackage{enumitem}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{parskip}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\usepackage{mathrsfs}\n\\usepackage{amsmath,amsthm,hyperref}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\DeclareMathOperator{\\Tr}{tr}\n\\usepackage{bbm}\n\n% Margins\n\\usepackage[top=2.5cm, left=3cm, right=3cm, bottom=4.0cm]{geometry}\n% Colour table cells\n\\usepackage[table]{xcolor}\n\n% Get larger line spacing in table\n\\newcommand{\\tablespace}{\\\\[1.25mm]}\n\\newcommand\\Tstrut{\\rule{0pt}{2.6ex}}         % = `top' strut\n\\newcommand\\tstrut{\\rule{0pt}{2.0ex}}         % = `top' strut\n\\newcommand\\Bstrut{\\rule[-0.9ex]{0pt}{0pt}}   % = `bottom' /\n\n% my new commands\n\\newcommand\\partialkj{\\frac{\\partial^2}{\\partial\\theta_k\\partial\\theta_j}}\n\\makeatletter\n\\newcommand*\\bigcdot{\\mathpalette\\bigcdot@{.5}}\n\\newcommand*\\bigcdot@[2]{\\mathbin{\\vcenter{\\hbox{\\scalebox{#2}{$\\m@th#1\\bullet$}}}}}\n\\makeatother\n\\newcommand{\\minus}{\\scalebox{0.5}[1.0]{$-$}}\n\\newcommand{\\zero}{\\scalebox{0.6}[0.75]{$^{(0)}$}}\n\\newcommand{\\supi}[1]{\\scalebox{0.6}[0.75]{$^{(#1)}$}}\\newcommand{\\supi}{\\scalebox{0.6}[0.75]{$^{(i)}$}}\n\\newcommand{\\bigDash}{\\scalebox{3.0}[1.0]{$-$}}\n\n\n\n%%%%%%%%%%%%%%%%%\n%     Title     %\n%%%%%%%%%%%%%%%%%\n\\title{Problem Set #2: Kernels, SVMs, and Theory}\n\\author{Eitan Joseph \\and Caroline Wang}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n%%%%%%%%%%%%%%%%%\n%   Problem 1   %\n%%%%%%%%%%%%%%%%%\n\\section{Problem 1}\n\\textbf{Kernel ridge regression\\\\\\\\}\nIn contrast to ordinary least squares which has a cost function\\begin{equation}\n    J(\\theta) = \\frac{1}{2}\\sum_{i=1}^{m}\\left(\\theta^T x^{(i)}-y^{(i)}\\right )^2\n\\end{equation}we can also add a term that penalizes large weights in $\\theta $. In \\textit{ridge regression}, our least\nsquares cost is regularized by adding a term $\\lambda ||\\theta ||^2$\n, where $\\lambda>0$ is a fixed (known) constant\n(regularization will be discussed at greater length in an upcoming course lecutre). The ridge regression cost function is then\\begin{equation*}\n     J(\\theta) = \\frac{1}{2}\\sum_{i=1}^{m}\\left(\\theta^T x^{(i)}-y^{(i)}\\right )^2 + \\frac{\\lambda}{2}||\\theta ||^2\n\\end{equation*}\n\\begin{enumerate}[label=(\\alph*)]\n    \\item Use the vector notation described in class to find a closed-form expreesion for the\nvalue of $\\theta$ which minimizes the ridge regression cost function.\\\\\n\\textit{answer}: \\\\\n\nWe know that the cost function without the penalty term can be written in closed form as\n\\begin{align*}\n    \\frac{1}{2}\\left(X\\theta-\\Vec{y}\\right)^T\\left(X\\theta-\\Vec{y}\\right)\n\\end{align*}\nWe can then rewrite the penalty term to be\n\\begin{align*}\n    \\frac{\\lambda}{2}\\theta^T\\theta\n\\end{align*}\nTherefore, together with the penalty term, the $J(\\theta)$ will be as follows: \\begin{align*}\n    J(\\theta) = \\frac{1}{2}\\left(X\\theta-\\Vec{y}\\right)^T\\left(X\\theta-\\Vec{y}\\right) + \\frac{\\lambda}{2}\\theta^T\\theta\n\\end{align*}\nSo we can now evaluate the gradient respect to $J(\\theta)$: \n\\begin{align*}\n    \\nabla_\\theta J(\\theta) = X^TX\\theta -X^T\\Vec{y} + \\lambda\\theta\n\\end{align*}\nUsing the knowledge from lecture 2 that\n\\begin{align*}\n    \\nabla_\\theta \\frac{1}{2}\\left(X\\theta-\\Vec{y}\\right)^T\\left(X\\theta-\\Vec{y}\\right) = X^TX\\theta -X^T\\Vec{y}\n\\end{align*}\nTo find the optimization point, we want to set the gradient vector to zero \\begin{align*}\n    \\Vec{0} = &X^TX\\theta -X^T\\Vec{y} + \\lambda\\theta\n\\end{align*}\nAnd then solve for $\\theta$ to get\n\\begin{align*}\n    \\theta =& \\left(X^TX+\\lambda I\\right)^{\\minus1}X^T\\Vec{y}\n\\end{align*}\n\\item Suppose that we want to use kernels to implicitly represent our feature vectors in a\nhigh-dimensional (possibly infinite dimensional) space. Using a feature mapping $\\phi$,\nthe ridge regression cost function becomes\\begin{align*}\n     J(\\theta) = \\frac{1}{2}\\left(X\\theta-\\Vec{y}\\right)^T\\left(X\\theta-\\Vec{y}\\right) + \\frac{\\lambda}{2}\\theta^T\\theta\n\\end{align*}Making a prediction on a new input $x_{new}$ would now be done by computing $\\theta^T\\phi (x_{new})$.\nShow how we can use the “kernel trick” to obtain a closed form for the prediction on the new input without ever explicitly computing $\\phi (x_{new})$. You may assume that the parameter vector $\\theta$ can be expressed as a linear combination of the input feature\nvectors; i.e.$ \\sum_{i=1}^{m}\\alpha_i \\phi (x^{(i)})$ for some set of parameters $\\alpha_i$.\\\\\\\\\n\\textit{Answer:}\\\\\nFrom part a, we know that the optimized $\\theta$ can be written as: \\begin{align*}\n     \\theta =& \\left(X^TX+\\lambda I\\right)^{\\minus1}X^T\\Vec{y}\n\\end{align*}\nBy using the identity $\\left(\\lambda I +BA\\right)^{\\minus1}B = B\\left(\\lambda I +AB\\right)^{\\minus1}$ we can rewrite $\\theta$ as: \\begin{align*}\n    \\theta =& X^T\\left(XX^T+\\lambda I\\right)^{\\minus1}\\Vec{y}\n\\end{align*}\nThe kernel algorithm maps the feature matrix (training data set matrix) to a higher dimension before applying the linear classification algorithm. Therefore, we will denote the new feature matrix $\\Phi$ with columns $\\phi(x^{(i)})$. \\\\\\\\Then we can use our new feature matrix to redefine $\\theta$ as follows: \\begin{align*}\n    \\theta =&{}\\: \\Phi^T\\left(\\Phi\\Phi^T+\\lambda I\\right)^{\\minus1}\\Vec{y}\n\\end{align*}\nWe know that the kernel matrix is the covariance matrix of $\\Phi$ with itself: $K = \\Phi\\Phi^T$. Therefore: \\begin{align*}\n    \\theta =&{}\\: \\Phi^T\\left(K+\\lambda I\\right)^{\\minus1}\\Vec{y}\n\\end{align*} \nGiven that the prediction on $x_{new}$ denoted $y_{new}$ = $\\theta^T \\phi(x_{new})$, we can substitute for $\\theta$ and solve \\begin{align*}\n    y_{new} = y^T\\left(K+\\lambda I\\right)^{\\minus1}\\Phi \\phi(x_{new})\n\\end{align*} To use the assumption that that the parameter vector $\\theta$ can be expressed as a linear combination of the input feature vectors, we rewrite $\\theta$ in the form $ \\sum_{i=1}^{m}\\alpha_i \\phi (x^{(i)})$ by defining some feature set $\\alpha$.\\\\\\\\\nWe can define the set of parameters $\\alpha$ to be: $\\left(K+\\lambda I\\right)^{\\minus1}y$. Thus, \\begin{align*}\n     y_{new}=\\sum_{i=1}^{m}\\alpha_i \\phi (x^{(i)})^T \\phi(x_{new})\n\\end{align*}\nFinally, we can use the fact that the kernel function is defined as $K(x^{(i)},x_{new}) = \\phi (x^{(i)})^T \\phi(x_{new})$ to rewrite the equation as\n\\begin{align*}\n     y_{new}=\\sum_{i=1}^{m}\\alpha_i K(x^{(i)},x_{new})\n\\end{align*}\n\\end{enumerate}\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%\n%   Problem 2   %\n%%%%%%%%%%%%%%%%%\n\\section{Problem 2}\n\\textbf{$l_2$ norm soft margin SV\\\\\\\\}\nIn class, we saw that if our data is not linearly separable, then we need to modify our\nsupport vector machine algorithm by introducing an error margin that must be minimized.\nSpecifically, the formulation we have looked at is known as the $l_1$ norm soft margin SVM.\nIn this problem we will consider an alternative method, known as the $l_2$ norm soft margin\nSVM. This new algorithm is given by the following optimization problem (notice that the\nslack penalties are now squared:\\begin{align*}\n    \\min_{w,b,\\xi} \\quad &\\frac{1}{2}||w||^2+\\frac{C}{2}\\sum_{i=1}^{m}x_i^2\\\\\n    \\textrm{s.t.} \\quad &y^{(i)}(w^Tx^{(i)}+b) \\geq 1-\\xi_i, i=1,\\dots m\n\\end{align*}\n\n\\begin{enumerate}[label=(\\alph*)]\n    \\item Notice that we have dropped the $\\xi_i \\geq 0$ constraint in the $l_2$ problem. Show that these non-negativity constraints can be removed. That is, show that the optimal value of the objective will be the same whether or not these constraints are present.\\\\\\\\\n    \\textit{answer:}\\\\\n    For any $\\xi_i < 0$ that satisfies the convex constraint, the value $\\xi_i = 0$ also satisfies the constraint and minimizes the objective function.\n    \\item What is the Lagrangian of the $l_2$ soft margin SVM optimization problem?\n    \\begin{equation*}\n        \\mathcal{L}(w,b,\\alpha, \\xi) = \\frac{1}{2}w^Tw + \\frac{C}{2}\\sum_{i=1}^{m}\\xi_i^2-\\sum_{i=1}^{m}\\alpha_i[y^{(i)}(w^Tx^{(i)}+b)-1+\\xi_i]\n    \\end{equation*}\n    \\item Minimize the Lagrangian with respect to $w$, $b$, and $\\xi$ by taking the following gradients: $\\nabla_w\\mathcal{L}$, $\\frac{\\partial}{\\partial b}\\mathcal{L}$, and $\\nabla_\\xi\\mathcal{L}$, and then setting them equal to 0.\\\\\\\\\n    \\textit{answer:}\n    \\begin{align*}\n        \\nabla_w \\mathcal{L} =&{} w - \\sum_{i=1}^m\\alpha_iy^{\\supi{i}}x^{\\supi{i}} \\overset{set}=\\: 0\n    \\end{align*}\n    By using the fact that we set the gradient to $0$ we can solve for $w$\n    \\begin{align*}\n        w =&{}\\sum_{i=1}^m\\alpha_iy^{\\supi{i}}x^{\\supi{i}}\n    \\end{align*}\n    And solve for $b$ by taking the partial derivative\n    \\begin{align*}\n        \\frac{\\partial}{\\partial b}\\mathcal{L} =&{} \\sum_{i=1}^m\\alpha_iy^{\\supi{i}} = 0\\\\\n    \\end{align*}\n    And finally solve for $\\xi$ by taking the gradient\n    \\begin{align*}\n        \\nabla_\\xi \\mathcal{L} =&{} C\\sum_{i=1}^m\\xi_i - \\sum_{i=1}^m\\alpha_i =\\: 0\\\\\n        C\\sum_{i=1}^m\\xi_i =&{}\\sum_{i=1}^m\\alpha_i\n    \\end{align*}\n    \\item What is the dual of the $l_2$ soft margin SVM optimization problem?\\\\\\\\\n    \\textit{answer:} To compute the dual problem, we need to reparameterize the Lagrangian as a function of $w$ on $\\alpha$ \\begin{align*}\n        W(\\alpha)=&\\frac{1}{2}\\sum_{i=1}^{m}\\sum_{j=1}^{m}(\\alpha_i y^{\\supi{i}}x^{\\supi{i}})^T (\\alpha_j y^{\\supi{j}}x^{\\supi{j}})+\\frac{1}{2}\\sum_{i=1}^{m}\\frac{\\alpha_i}{\\xi_i}\\xi_i^2\\\\\n        &\\: -\\sum_{i=1}^{m}\\alpha_i\\left[y^{\\supi{i}}\\left(\\left(\\sum_{j=1}^{m}(\\alpha_j y^{\\supi{j}}x^{\\supi{j}})\\right)^T x^{\\supi{i}}+b\\right)-1+\\xi_i\\right]\\\\\n        =&\\frac{1}{2}\\sum_{i=1}^{m}\\sum_{j=1}^{m}\\alpha_i\\alpha_jy^{\\supi{i}}y^{\\supi{j}}(x^{\\supi{i}})^Tx^{\\supi{j}}+\\frac{1}{2}\\sum_{i=1}^{m}\\alpha_i\\xi_i-\\sum_{i=1}^{m}\\sum_{j=1}^{m}\\alpha_i\\alpha_jy^{\\supi{i}}y^{\\supi{j}}(x^{\\supi{i}})^Tx^{\\supi{j}}\\\\&\\:-b\\sum_{i=1}^{m}a_iy^{\\supi{i}} + \\sum_{i=1}^{m}a_i-\\sum_{i=1}^{m}\\alpha_i\\xi_i\\\\\n        =&\\sum_{i=1}^{m}a_i-\\frac{1}{2}\\sum_{i=1}^{m}\\sum_{j=1}^{m}\\alpha_i\\alpha_jy^{\\supi{i}}y^{\\supi{j}}(x^{\\supi{i}})^Tx^{\\supi{j}}-\\frac{1}{2}\\sum_{i=1}^{m}\\alpha_i\\xi_i\\\\\n        =&\\sum_{i=1}^{m}a_i-\\frac{1}{2}\\sum_{i=1}^{m}\\sum_{j=1}^{m}\\alpha_i\\alpha_jy^{\\supi{i}}y^{\\supi{j}}(x^{\\supi{i}})^Tx^{\\supi{j}}-\\frac{1}{2}\\sum_{i=1}^{m}\\frac{\\alpha_i^2}{C}\n    \\end{align*} \n   Now to formulate the dual optimization problem, we simply add the constraints derived in part c to our objective function\\begin{align*}\n        \\max_{\\alpha }\\quad &\\sum_{i=1}^{m}a_i-\\frac{1}{2}\\sum_{i=1}^{m}\\sum_{j=1}^{m}\\alpha_i\\alpha_jy^{\\supi{i}}y^{\\supi{j}}(x^{\\supi{i}})^Tx^{\\supi{j}}-\\frac{1}{2}\\sum_{i=1}^{m}\\frac{\\alpha_i^2}{C}\\\\\n        s.t. \\quad &\\sum_{i=1}^{m}a_iy^{\\supi{i}}=0\n    \\end{align*}\n\\end{enumerate}\n\n\n%%%%%%%%%%%%%%%%%\n%   Problem 4   %\n%%%%%%%%%%%%%%%%%\n\\section{Problem 3}\n\\textbf{SVM with Gaussian kernel}\\\\\\\\\nConsider the task of training a support vector machine using the Gaussian kernel $K(x,z) = \\exp(-||x-z||^2/\\tau^2)$. We will show that as long as there are no two identical points in the\ntraining set, we can always find a value for the bandwidth parameter $\\tau$ such that the SVM\nachieves zero training error.\n\n\\begin{enumerate}[label=(\\alph*)]\n\\item Recall from class that the decision function learned by the support vector machine can be written as\n\\begin{align*}\n    f(x) = \\sum_{i=1}^{m}\\alpha_iy\\supi{i}K(x\\supi{i},x)+b\n\\end{align*}\nAssume that the training data $f\\{(x\\supi{1}, y\\supi{1}),\\dots , (x\\supi{m}, y\\supi{m})\\}$ consists of points which\nare separated by at least a distance of $\\epsilon$; that is, $||x\\supi{j}-x\\supi{i}||\\geq \\epsilon$ for any $i\\neq j$.\nFind values for the set of parameters $\\{\\alpha_1, \\dots, \\alpha_m,b\\}$ and Gaussian kernel width $\\tau$ such that $x\\supi{i}$ is correctly classified, for all $i=1, \\dots, m$. [Hint: Let $\\alpha_i=1$ for all i\nand $b=0$. Now notice that for $y\\in \\{-1,1\\}$ the prediction on $x\\supi{i}$ will be correct if $|f(x\\supi{i})-y\\supi{i}|<1$ , so find a value of $\\tau$ that satisfies this inequality for all $i$.\\\\\\\\\n\\textit{answer:}\\\\\\\\\nWe will first let $\\alpha_i = 1 \\forall i$ and we will let $b = 0$. We notice here that since $y \\in \\{-1,+1\\}$, the prediction on $x\\supi{i}$ will be correct if $\\Big|f\\left(x\\supi{i}\\right)-y\\supi{i}\\Big| < 1$.\\\\\\\\\nNow we can substitute in our $f\\left(x\\supi{i} )\\right)$ to get the equation\n\\begin{align*}\n     \\Big|f\\left(x\\supi{i}\\right)-y\\supi{i}\\Big|= &\\left|\\left(\\sum_{k=1}^{m}\\alpha_ky\\supi{k}K(x\\supi{k},x\\supi)+b\\right)-y\\supi{i}\\right| <1\\\\\n   \\Longrightarrow &\\left|\\left(\\sum_{k=1}^{m}y\\supi{k}K(x\\supi{k},x\\supi)\\right)-y^\\supi{i}\\right| <1\n\\end{align*}\nSubstituting the Gaussian Kernel for K gives\n\\begin{align*}\n    \\left|\\left(\\sum_{k=1}^{m}y\\supi{k}\\exp\\left(-\\frac{||x\\supi{k}-x\\supi{i}||^2}{\\tau^2}\\right)\\right)-y^\\supi{i}\\right| <1\n\\end{align*}\nBy pulling out $y^\\supi{i}$ from the sum we get\n\\begin{align*}\n    &\\left|y\\supi{i} + \\left(\\sum_{\\substack{k=1\\\\k\\neq i}}^{m} y\\supi{k}\\exp\\left(-\\frac{||x\\supi{k}-x\\supi{i}||^2}{\\tau^2}\\right)\\right)-y^\\supi{i}\\right| <1\\\\\n    \\Longrightarrow &\\left|  \\sum_{\\substack{k=1\\\\k\\neq i}}^{m} y\\supi{k}\\exp\\left(-\\frac{||x\\supi{k}-x\\supi{i}||^2}{\\tau^2}\\right)\\right| <1\n\\end{align*}\nSince each $y\\supi{k}$ is either $-1$ or $+1$ in the worse case for the inequality all $y\\supi{k}$s are the same.\\\\Essentially, $\\sum_{k=1}^{m}y\\supi{i}\\leq |\\sum_{k=1}^{m}y\\supi{i} |$, and since $||x\\supi{j}-x\\supi{i}||\\geq \\epsilon$ for any $i\\neq j$, we can write \\begin{align*}\n    &\\left|  \\sum_{\\substack{k=1\\\\k\\neq i}}^{m} y\\supi{k}\\right|\\exp\\left(-\\frac{\\epsilon^2}{\\tau^2}\\right) <1\\\\\n    \\Longrightarrow & (m-1)\\exp\\left(-\\frac{\\epsilon^2}{\\tau^2}\\right)<1\n\\end{align*}\nThen we can solve for $\\tau$:\n\\begin{align*}\n    \\tau <\\frac{\\epsilon}{\\sqrt{\\log (m-1)}}\n\\end{align*}\nFor simplification, we can choose: \\begin{align*}\n    \\tau = \\frac{\\epsilon}{\\log m}\n\\end{align*}\n\\item Suppose we run a SVM with slack variables using the parameter $\\tau$ you found in part (a). Will the resulting classifier necessarily obtain zero training error? Why or why not? A short explanation (without proof) will suffice. \\\\\\\\\n\\textit{answer: }\\\\\\\\\nThe classifier will obtain zero training error. We can verify this by observing that the SVM algorithm WITHOUT any slack variable will achieve zero training error if it can satisfy the convex constraint. If we can find a solution that satisfies the convex constraint without a slack variable, then we have proved that the classifier will still obtain zero training error. This is because in order to minimize the objective function, the algorithm will necessarily choose the slack variables to be equal to zero if possible.\\\\\\\\To do this we first observe that our convex constraint is\n\\begin{align*}\n    y\\supi{i}\\left(w^Tx\\supi{i} + b\\right) = y\\supi{i}f(x\\supi{i}) > 1\n\\end{align*}\nBy using our $\\tau$ from part (a) we can ensure that $y\\supi{i}f(x\\sup{i}) > 0 \\;\\forall i$ (meaning that every classification of $x\\supi{i}$ is correct), and therefore we can take each $\\alpha_i$ to be large enough to satisfy the inequality. Since we can satisfy this constraint, it is clear that we can satisfy the same constraint with a slack variable.\n\n\\item Suppose we run the SMO algorithm to train an SVM with slack variables, under the conditions stated above, using the value of $\\tau$ you picked in the previous part, and using some arbitrary value of $C$ (which you do not know beforehand). Will this necessarily result in a classifier that achieve zero training error? Why or why not? Again, a short explanation is sufficient.\\\\\\\\\n\\textit{answer}: \\\\\\\\\nThe classifier will not be able to obtain zero training error because there exists a constant $C$ in front of $(C\\sum_{i=1}^{m}\\xi_i)$ for which we have no information on. If the constant $C$ happened to be $\\leq 0$, then the minimization of the objective function could be achieved with non-zero slack variables.\n\\end{enumerate}\n\\section{Problem 5}\n\\textbf{Uniform convergence}\\\\\nIn class we proved that for any finite set of hypotheses $\\mathcal{H} = \\{h_1,\\dots, h_k\\}$, if we pick the hypothesis $\\hat{h}$ that minimizes the training error on a set of m examples, then with probability at least $1-\\delta$,\\begin{align*}\n    \\epsilon(\\hat{h})\\leq \\left(\\min_{i}\\epsilon(h_i)\\right)+2\\sqrt{\\frac{1}{2m}\\log\\frac{2k}{\\delta}}\n\\end{align*}where $\\epsilon(h_i)$ is the generalization error of hypothesis $h_i$. Now consider a special case (often called the \\textit{realizable} case) where we know, a priori, that there is some hypothesis in our class $\\mathcal{H}$ that achieves zero error on the distribution from which the data is drawn. Then we could obviously just use the above bound with $\\min_i\\epsilon(h_i)=0$; however, we can prove a better bound than this.\n\n\\begin{enumerate}[label=(\\alph*)]\n    \\item Consider a learning algorithm which, after looking at $m$ training examples, chooses some hypothesis $\\hat{h}\\in \\mathcal{H}$ that makes zero mistakes on this training data. (By our assumption, there is at least one such hypothesis, possibly more.) Show that with probability $1-\\delta$\\begin{align*}\n        \\epsilon(\\hat{h})\\leq \\frac{1}{m}\\log\\frac{k}{\\delta}\n    \\end{align*}\n    Notice that since we do not have a square root here, this bound is much tighter. [Hint: Consider the probability that a hypothesis with generalization error greater than $\\gamma$ makes no mistakes on the training data. Instead of the Hoeffding bound, you might also find the following inequality useful: $(1-\\gamma)m\\leq e^{-\\gamma m}$].\\\\\\\\\n    \\textit{answer:}\\\\\\\\\nThe problem states that the probability that $h$ incorrectly predicts some training example $(x\\supi{i}, y\\supi{i})$ from the distribution $D$ is $\\gamma$. Therefore we have that \\begin{align*}\n    P(h\\in \\mathcal{H} \\text{ that h predicts correctly})=1-\\gamma\n\\end{align*}\nFor $h$ to predict correctly $m$ times, once for each training example, we have \\begin{align*}\n    P( h\\in \\mathcal{H} \\text{ that h predicts correctly m times})=(1-\\gamma)^m \\leq e^{-\\gamma m}\n\\end{align*}\nSince there are total $k$ hypothesis in $\\mathcal{H}$, \\begin{align*}\n    P(\\forall h\\in \\mathcal{H} \\text{ that h predicts correctly m times})=k(1-\\gamma)^m \\leq ke^{-\\gamma m}\n\\end{align*}\nAfter setting this probability to $\\delta$ and solving for $\\gamma$ we obtain the following:\\begin{align*}\n    &ke^{-\\gamma m} = \\delta\\\\\n    \\Longrightarrow &\\gamma = \\frac{1}{m}\\log\\frac{k}{\\delta}\n\\end{align*}\nFrom the lecture we know that $|\\hat{\\epsilon}(\\hat{h})-\\epsilon(\\hat{h})|> \\gamma$ with probability $1-\\delta$, therefore since $\\hat{\\epsilon}{(\\hat{h})}= 0$ we obtain the inequality \\begin{align*}\n    \\epsilon(\\hat{h})\\leq \\frac{1}{m}\\log\\frac{k}{\\delta}\n\\end{align*}\n    \\item Rewrite the above bound as a sample complexity bound, i.e., in the form: for fixed $\\delta$ and $\\gamma$, for $\\epsilon(\\hat{h}) \\leq \\gamma$ to hold with probability at least $(1 - \\delta)$, it suffices that $m \\leq f(k,\\gamma,\\delta)$.\n    \\textit{answer:}\\\\\\\\\n    From part (a) we have that $\\gamma \\leq \\frac{1}{m}\\log\\frac{k}{\\delta}$ We now simply need to rewrite this as an inequality on $m$ as follows\n    \\begin{align*}\n        m \\leq \\frac{1}{\\gamma}\\log\\frac{k}{\\delta}\n    \\end{align*}\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "bbeef822c4a987f0d900389de2d280aadf7adf98", "size": 19052, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Kernels, SVMs, and Theory/Problem Set 2 - Kernals, SVM and Theory.tex", "max_stars_repo_name": "EitanJoseph/Standford-Machine-Learning", "max_stars_repo_head_hexsha": "5b1609a3fc1c7f32494a70ebc3f89d2ed8aed941", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-01T02:53:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-01T02:53:32.000Z", "max_issues_repo_path": "Kernels, SVMs, and Theory/Problem Set 2 - Kernals, SVM and Theory.tex", "max_issues_repo_name": "EitanJoseph/Standford-Machine-Learning", "max_issues_repo_head_hexsha": "5b1609a3fc1c7f32494a70ebc3f89d2ed8aed941", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Kernels, SVMs, and Theory/Problem Set 2 - Kernals, SVM and Theory.tex", "max_forks_repo_name": "EitanJoseph/Standford-Machine-Learning", "max_forks_repo_head_hexsha": "5b1609a3fc1c7f32494a70ebc3f89d2ed8aed941", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.8007117438, "max_line_length": 584, "alphanum_fraction": 0.6690636154, "num_tokens": 6492, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.4382624182771787}}
{"text": "\\documentclass{article}\n\\usepackage[section]{placeins}\n\\usepackage{graphicx}\n\n\\author{Yaghoub Shahmari}\n\\title{Report - Problem Set no 1}\n\\date{\\today}\n\\graphicspath{ {../Figs/} }\n\n\\begin{document}\n    \\maketitle\n    \\section*{Problem 1}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Koch curve using computational methods.\n    In that case, we have to follow the algorithm which leads us to the solution.\n    At first, we have a list of 2 points that create a single line.\n    Then we have to create three more points between them and transmit them to the position they have to go.\n    At first, we divide the line into third.\n    Add the final point of the line in the middle of our list.\n    Then we will do that again but we will divide the first line to two-thirds instead of third.\n    Then we will rotate the final spot in 60 degrees and add the point before the last point in the list.\n    And finally, we will do the previous operation without rotation.\n    We have to repeat these operations for every point side by side in the initial list (the initial list in every step will be updated and will contain more points).\n\n    I implemented the algorithm for the few shapes, apart from the line,\n    I also applied the algorithm in some triangles\n    (the rotation degrees for them were 60, -60, and 120).\n    The results are as follows:\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve1O1}\n        \\label{fig:1.1.1}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve1O2}\n        \\label{fig:1.1.2}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve1O5}\n        \\label{fig:1.1.3}\n        \\caption{Koch curve for a single line. The figures belong to the first, second, and fifth stages, respectively.}\n    \\end{figure}\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve2O1}\n        \\label{fig:1.2.1}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve2O2}\n        \\label{fig:1.2.2}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve2O5}\n        \\label{fig:1.2.3}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve3O1}\n        \\label{fig:1.3.1}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve3O2}\n        \\label{fig:1.3.2}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve3O5}\n        \\label{fig:1.3.3}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve4O1}\n        \\label{fig:1.4.1}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve4O2}\n        \\label{fig:1.4.2}\n        \\includegraphics[scale = 0.15]{/Q1/KochCurve4O5}\n        \\label{fig:1.4.3}\n        \\caption{Koch curve for triangles (The rotation degrees are 60, -60, and 120 respectively, from up to down). The figures belong to the first, second, and fifth stages, respectively.}\n    \\end{figure}\n\n    \\section*{Problem 2}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Heiway dragon using computational methods.\n    As before we have to transmit and rotate our points to create what we want.\n    We must note that our rotation degree is 45 degrees.\n    We have to rotate the whole structure one by one with 45 and -45 degrees.\n    However, if we change both rotation degrees to -45 we will have the Lévy C curve.\n    The results are as follows:\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.13]{/Q2/Heighway-dragon-O1}\n        \\label{fig:2.1.1}\n        \\includegraphics[scale = 0.13]{/Q2/Heighway-dragon-O5}\n        \\label{fig:2.1.2}\n        \\includegraphics[scale = 0.13]{/Q2/Heighway-dragon-O10}\n        \\label{fig:2.1.3}\n        \\includegraphics[scale = 0.13]{/Q2/Heighway-dragon-O15}\n        \\label{fig:2.1.3}\n        \\caption{The Heighway dragon fractal. The figures belong to the 1st, 5th, 10th, and 15th stages, respectively.}\n    \\end{figure}\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.13]{/Q2/Lévy-C-curve-O1}\n        \\label{fig:2.2.1}\n        \\includegraphics[scale = 0.13]{/Q2/Lévy-C-curve-O5}\n        \\label{fig:2.2.2}\n        \\includegraphics[scale = 0.13]{/Q2/Lévy-C-curve-O10}\n        \\label{fig:2.2.3}\n        \\includegraphics[scale = 0.13]{/Q2/Lévy-C-curve-O15}\n        \\label{fig:2.2.3}\n        \\caption{The Lévy C curve fractal. The figures belong to the 1st, 5th, 10th, and 15th stages, respectively.}\n    \\end{figure}\n    \\section*{Problem 3}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Sierpinski triangle using computational methods.\n    In that case, we must define a list of triangles that initially have only one triangle.\n    In each step of our algorithm, the list will be updated and will contain more triangles.\n    So we have to apply an algorithm that takes a single triangle from the list,\n    makes it in four smaller triangles, and returns three of them (the center one won't return).\n    You have to define a triangle as a list of the points that\nmake up our triangle\n    And the coordinates of the points have to be divided in half.\n    That would be enough for the first triangle but the others still need a transmission.\n    And after all of our operations, a single triangle changed to three.\n    we have to repeat these operations for every single triangle we have at the beginning of each stage.\n    The results are as follows:\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.027]{/Q3/SPT-O1}\n        \\label{fig:3.1.1}\n        \\includegraphics[scale = 0.027]{/Q3/SPT-O3}\n        \\label{fig:3.1.2}\n        \\includegraphics[scale = 0.027]{/Q3/SPT-O5}\n        \\label{fig:3.1.3}\n        \\includegraphics[scale = 0.027]{/Q3/SPT-O7}\n        \\label{fig:3.1.3}\n        \\caption{The Sierpinski triangle fractal. The figures belong to the 1st, 3th, 5th, and 7th stages, respectively.}\n    \\end{figure}\n    \\section*{Problem 4}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Sierpinski triangle using random computational methods.\n    In that case, we will choose some random points on the surface.\n    Then we will transit the points with three transmission functions.\n    For each point, we will do this operation P times.\n    We must note that in each step,\n    we will choose a random function for applying.\n    Our functions are as follows:\n\n    $f_{1} = [x, y] \\div 2$\n\n    $f_{2} = [x, y] \\div 2 + [1, 0]$\n\n    $f_{3} = [x, y] \\div 2 + [0, 1]$\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.1]{/Q4/RSPTp5num10000}\n        \\label{fig:4.1.1}\n        \\includegraphics[scale = 0.1]{/Q4/RSPTp500num10000}\n        \\label{fig:4.1.2}\n        \\caption{The of deployed points is 10000 and P is 5 and 500 respectively.}\n    \\end{figure}\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.1]{/Q4/RSPTp5num100000}\n        \\label{fig:4.2.1}\n        \\includegraphics[scale = 0.1]{/Q4/RSPTp500num100000}\n        \\label{fig:4.2.2}\n        \\caption{The of deployed points is 100000 and P is 5 and 500 respectively.}\n    \\end{figure}\n    \\section*{Problem 5}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Sierpinski triangle using the Khayyam-Pascal's triangle.\n    We know that if we separate the odd and even numbers of the Khayyam-Pascal's triangle we have the Sierpinski triangle.\n    If we continue the Khayyam-Pascal's triangle up to $2^n$ ser stage our Sierpinski triangle will complete up to the nth stage.\n    \n    here is the results:\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.05]{/Q5/SPTKP-O1}\n        \\label{fig:5.1.1}\n        \\includegraphics[scale = 0.05]{/Q5/SPTKP-O2}\n        \\label{fig:5.1.2}\n        \\includegraphics[scale = 0.05]{/Q5/SPTKP-O3}\n        \\label{fig:5.1.3}\n        \\caption{The Sierpinski triangle fractal. The $n$ equals 1, 2, and 3, respectively.}\n    \\end{figure}\n    \\section*{Problem 6}\n    \\textbf{Basic description:}\n\n    There we want to simulate the Barnsley fern fractal using random computational methods.\n    The method is the same as the random method for creating the Sierpinski triangle.\n    Our functions are as follows:\n\n    $f_{1}(x, y)=\\left[\\begin{array}{cc}0.00 & 0.00 \\\\ 0.00 & 0.16\\end{array}\\right]\\left[\\begin{array}{l}x \\\\ y\\end{array}\\right]$\n    \n    $f_{2}(x, y)=\\left[\\begin{array}{cc}0.85 & 0.04 \\\\ -0.04 & 0.85\\end{array}\\right]\\left[\\begin{array}{l}x \\\\ y\\end{array}\\right]+\\left[\\begin{array}{l}0.00 \\\\ 1.60\\end{array}\\right]$\n    \n    $f_{3}(x, y)=\\left[\\begin{array}{cc}0.20 & -0.26 \\\\ 0.23 & 0.22\\end{array}\\right]\\left[\\begin{array}{l}x \\\\ y\\end{array}\\right]+\\left[\\begin{array}{l}0.00 \\\\ 1.60\\end{array}\\right]$\n    \n    $f_{4}(x, y)=\\left[\\begin{array}{cc}-0.15 & 0.28 \\\\ 0.26 & 0.24\\end{array}\\right]\\left[\\begin{array}{l}x \\\\ y\\end{array}\\right]+\\left[\\begin{array}{l}0.00 \\\\ 0.44\\end{array}\\right]$\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.1]{/Q6/RandomBarnsleyFern-p10num10000}\n        \\label{fig:6.1.1}\n        \\includegraphics[scale = 0.1]{/Q6/RandomBarnsleyFern-p100num10000}\n        \\label{fig:6.1.2}\n        \\caption{The of deployed points is 10000 and P is 10 and 100 respectively.}\n    \\end{figure}\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.1]{/Q6/RandomBarnsleyFern-p10num1000000}\n        \\label{fig:6.2.1}\n        \\includegraphics[scale = 0.1]{/Q6/RandomBarnsleyFern-p100num1000000}\n        \\label{fig:6.2.2}\n        \\caption{The of deployed points is 1000000 and P is 10 and 100 respectively.}\n    \\end{figure}\n\\end{document}", "meta": {"hexsha": "1ae3fa43d1c571499086f0351a872440c816b77e", "size": 9492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProblemSet1/TEXfiles/report.tex", "max_stars_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_stars_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ProblemSet1/TEXfiles/report.tex", "max_issues_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_issues_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProblemSet1/TEXfiles/report.tex", "max_forks_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_forks_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-21T11:07:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-21T11:07:08.000Z", "avg_line_length": 45.8550724638, "max_line_length": 190, "alphanum_fraction": 0.6564475348, "num_tokens": 3067, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7690802423634961, "lm_q1q2_score": 0.43826241526108084}}
{"text": "\\documentclass[12pt]{amsart}\n\\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.\n\\usepackage{bsymb}\n\\usepackage{unitb}\n\\usepackage{calculational}\n\\usepackage{ulem}\n\\usepackage{hyperref}\n\\normalem\n\\geometry{a4paper} % or letter or a5paper or ... etc\n% \\geometry{landscape} % rotated page geometry\n\n% See the ``Article customise'' template for some common customisations\n\n\\title{}\n\\author{}\n\\date{} % delete this line to display the current date\n\n%%% BEGIN DOCUMENT\n\\setcounter{tocdepth}{4}\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\newcommand{\\G}{\\text{G}}\n\\renewcommand{\\H}{\\text{H}}\n\n\\section{Initial model}\n\\begin{machine}{m0}\n\n\\with{functions}\n\\with{sets}\n\\with{intervals}\n\\newset{\\G}\n\n\\begin{align*}\n& \\variable{p,q : \\Int } \n\\\\ & \\variable{qe : \\Int \\pfun \\G }\n\\\\ & \\variable{ emp : \\Bool }\n\\\\ & \\variable{ res : \\G }\n\\end{align*}\n\n\\begin{align*}\n\\invariant{m0:inv0}{ qe &\\1\\in \\intervalR{p}{q} \\tfun \\G }\n% \\invariant{m0:inv0}{ \\dom.qe = \\intervalR{p}{q} }\n\\\\ \\invariant{m0:inv1}{ p &\\1\\le q }\n\\end{align*}\n\n\\begin{align*}\n\\initialization{m0:init0}{p = 0 \\land q = 0 \\land qe = \\emptyfun }\n\\end{align*}\n\n\\newevent{m0:push:left}{push\\_left}\n\\param{m0:push:left}{x : \\G}\n\n\\begin{align*}\n\\evassignment{m0:push:left}{m0:act0}{ qe' &\\2= qe \\2| p\\0-1 \\fun x }\n\\\\ \\evassignment{m0:push:left}{m0:act1}{ p' &\\1= p-1 }\n\\\\ \\evassignment{m0:push:left}{m0:act2}{ q' &\\1= q }\n\\\\ \\evassignment{m0:push:left}{m0:act3}{ res' = res }\n\\\\ \\evassignment{m0:push:left}{m0:act4}{ emp' = emp }\n\\end{align*}\n\n\\newevent{m0:push:right}{push\\_right}\n\\param{m0:push:right}{ x : \\G }\n\n\\begin{align*}\n\\evassignment{m0:push:right}{m0:act0}{ qe' &\\2= qe \\2| q \\fun x }\n\\\\ \\evassignment{m0:push:right}{m0:act1}{ p' & \\1= p }\n\\\\ \\evassignment{m0:push:right}{m0:act2}{ q' & \\1= q+1 }\n\\\\ \\evassignment{m0:push:right}{m0:act3}{ res' = res }\n\\\\ \\evassignment{m0:push:right}{m0:act4}{ emp' = emp }\n\\end{align*}\n\n\\newevent{m0:pop:left}{pop\\_left}\n\n\\begin{align*}\n\\evassignment{m0:pop:left}{m0:act0}{ qe' &\\1= \\{ p \\} \\domsub qe }\n\\\\ \\evassignment{m0:pop:left}{m0:act1}{ p' &\\1= p+1 }\n\\\\ \\evassignment{m0:pop:left}{m0:act2}{ q' &\\1= q }\n\\\\ \\evguard{m0:pop:left}{m0:grd0}{ p < q }\n\\\\ \\evassignment{m0:pop:left}{m0:act3}{ (p = q \\land res' = res) \\lor (p < q \\land res' = qe.p) }\n\\\\ \\evassignment{m0:pop:left}{m0:act4}{ emp' = (p = q) }\n\\end{align*}\n\n\\newevent{m0:pop:right}{pop\\_right}\n\n\\begin{align*}\n\\evassignment{m0:pop:right}{m0:act0}{ qe' &\\1= \\{ q-1 \\} \\domsub qe }\n\\\\ \\evassignment{m0:pop:right}{m0:act1}{ p' &\\1= p }\n\\\\ \\evassignment{m0:pop:right}{m0:act2}{ q' &\\1= q-1 }\n\\\\ \\evguard{m0:pop:right}{m0:grd0}{ p &< q }\n\\\\ \\evassignment{m0:pop:right}{m0:act3}{ (p = q \\land res' = res) \\lor (p < q \\land res' = qe.(q\\1-1)) }\n\\\\ \\evassignment{m0:pop:right}{m0:act4}{ emp' = (p = q) }\n\\end{align*}\n\n% \\begin{align*}\n\\input{m0_m0-push-left}\n% \\end{align*}\n\n\\end{machine}\n\n\\newcommand{\\REQ}{\\text{REQ}}\n\n\\begin{machine}{m1}\n\\refines{m0} \\\\\n\\newset{\\REQ}\n\n\\[ \\variable{pshL,pshR : \\REQ \\pfun \\G} \\]\n\n\\hide{ \\dummy{r : \\REQ}; \\dummy{x : \\G} }\n\\begin{align*}\n\\progress{m1:prog0}\n\t{ r \\in \\dom.pshL \\1\\land pshL.r = x }\n\t{ p < q \\land qe.p = x \\1\\land \\neg r \\in \\dom.pshL }\n\\\\ \\progress{m1:prog1}\n\t{ r \\in \\dom.pshR \\1\\land pshR.r = x }\n\t{ p < q \\1\\land qe.(q-1) = x \\1\\land \\neg r \\in \\dom.pshR }\n\\end{align*}\n\n\\indices{m0:push:left}{ r : \\REQ }\n\\indices{m0:push:right}{ r : \\REQ }\n\\begin{align*}\n\\refine{m1:prog0}{ensure}{m0:push:left}{ \\index{r}{r'=r} }\n\\end{align*}\n\\begin{align*}\n\\\\ \\evassignment{m0:push:left}{m1:a0}{ pshL' = \\{ r \\} \\domsub pshL }\n\\\\ \\evassignment{m0:push:left}{m1:a1}{ pshR' = pshR }\n\\\\ \\evassignment{m0:push:right}{m1:a0}{ pshR' = \\{ r \\} \\domsub pshR }\n\\\\ \\evassignment{m0:push:right}{m1:a1}{ pshL' = pshL }\n\\\\ \\evguard{m0:push:left}{m1:grd0}{ x = pshL.r }\n\\\\ \\evguard{m0:push:left}{m1:grd1}{ r \\in \\dom.pshL }\n\\\\ \\cschedule{m0:push:left}{m1:sch0}{ r \\in \\dom.pshL }\n\\end{align*}\n\\begin{align*}\n% \\removecoarse{m0:push:left}{default} % \\weakento{m0:push:left}{default}{m1:sch0}\n\\\\ \\evassignment{m0:pop:right}{m1:a0}{ pshL' = pshL }\n\\\\ \\evassignment{m0:pop:right}{m1:a1}{ pshR' = pshR }\n\\\\ \\evassignment{m0:pop:left}{m1:a0}{ pshL' = pshL }\n\\\\ \\evassignment{m0:pop:left}{m1:a1}{ pshR' = pshR }\n\\end{align*}\n\n\\begin{align*}\n\\refine{m1:prog1}{ensure}{m0:push:right}{ \\index{r}{r'=r} }\n\\end{align*}\n\n\\begin{align*}\n% \\removecoarse{m0:push:left}{default} % \\weakento{m0:push:left}{default}{m1:sch0}\n\\\\ \\cschedule{m0:push:right}{m1:sch0}{ r \\in \\dom.pshR }\n\\\\ \\evguard{m0:push:right}{m1:grd0}{ r \\in \\dom.pshR }\n\\\\ \\evguard{m0:push:right}{m1:grd1}{ pshR.r = x }\n\\end{align*}\n\n\\begin{align*}\n\\variable{ popR, popL : \\set [\\REQ]}\n\\end{align*}\n\n\\begin{align*}\n\\progress{m1:prog2}{ r \\in popR }{ \\neg r \\in popR \\land emp = (p = q) \\land (emp \\lor res = qe.(q\\0-1))  }\n\\\\ \\progress{m1:prog3}{ r \\in popL }{ \\neg r \\in popL \\land emp = (p = q) \\land (emp \\lor res = qe.p)  }\n\\end{align*}\n\\begin{align*}\n\\refine{m1:prog2}{ensure}{m0:pop:right}{ \\index{r}{r'=r} }\n\\end{align*}\n% \\refine{m1:prog3}{ensure}{m0:pop:left}{}\n\\indices{m0:pop:right}{ r : \\REQ }\n\\begin{align*}\n\\cschedule{m0:pop:right}{m1:sch0}{ r \\in popR }\n% \\\\ \\removecoarse{m0:pop:right}{default} % \\weakento{m0:pop:right}{default}{m1:sch0}\n\\\\ \\evguard{m0:pop:right}{m1:sch0}{ r \\in popR }\n\\\\ \\evassignment{m0:pop:right}{m1:a2}{ popR' = popR \\setminus \\{ r \\} }\n\\\\ \\evassignment{m0:pop:right}{m1:a3}{ (emp' = (p = q)) \\land (p < q \\implies res' = qe.(q\\0-1)) }\n\\end{align*}\n\n\\end{machine}\n \n\\input{m1_m0-push-right}\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "581dbede0ea2fb799d763c88507d10c4871f4364", "size": 5519, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Tests/lock-free deque/main5.tex", "max_stars_repo_name": "literate-unitb/literate-unitb", "max_stars_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-07-27T11:05:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-20T14:53:33.000Z", "max_issues_repo_path": "Tests/lock-free deque/main5.tex", "max_issues_repo_name": "unitb/literate-unitb", "max_issues_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 32, "max_issues_repo_issues_event_min_datetime": "2017-06-25T03:53:02.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-25T04:28:38.000Z", "max_forks_repo_path": "Tests/lock-free deque/main5.tex", "max_forks_repo_name": "literate-unitb/literate-unitb", "max_forks_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5958549223, "max_line_length": 107, "alphanum_fraction": 0.6204022468, "num_tokens": 2380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.43826240621278706}}
{"text": "\\hypertarget{hypothesis-testing}{%\n\\chapter{Hypothesis Testing}\\label{hypothesis-testing}}\n\nThis chapter introduces hypothesis testing, which has been a\ncontroversial topic in the last decade or so. What I present here is\ndifferent from what you might see in a statistics book. Instead of\nmathematical analysis, we will use computational simulations. This\napproach has two advantages and one disadvantage:\n\n\\begin{itemize}\n\\item\n  PRO: The standard statistics curriculum includes many different tests,\n  and many people find it hard to remember which one to use. In my\n  opinion, simulation makes it clearer that there is only one testing\n  framework.\n\\item\n  PRO: Simulations make modeling decision explicit. All statistical\n  methods are based on models, but when we use mathematical methods, it\n  is easy to forget the assumptions they are based on. With computation,\n  the assumptions are more visible, and it is easier to try different\n  models.\n\\item\n  CON: Simulation uses a lot of computation. Some of the examples in\n  this notebook take several seconds to run and the results are only\n  approximate. For some problems, there are analytic methods that are\n  faster and more accurate.\n\\end{itemize}\n\nThe examples in this chapter include results from a clinical trial\nrelated to peanut allergies, and survey data from the National Survey of\nFamily Growth (NSFG) and the Behavioral Risk Factor Surveillance System\n(BRFSS).\n\n\\hypertarget{peanut-allergies}{%\n\\section{Peanut Allergies}\\label{peanut-allergies}}\n\nThe LEAP study was a randomized trial that tested the effect of eating\npeanut snacks on the development of peanut allergies (see\n\\url{http://www.leapstudy.co.uk/leap-0\\#.YEJax3VKikA}). The subjects\nwere infants who were at high risk of developing peanut allergies\nbecause they had been diagnosed with other food allergies. Over a period\nof several years, half of the subjects were periodically given a snack\ncontaining peanuts; the other half were given no peanuts at all.\n\nThe conclusion of the study, reported in 2015 is:\n\n\\begin{quote}\nOf the children who avoided peanut, 17\\% developed peanut allergy by the\nage of 5 years. Remarkably, only 3\\% of the children who were randomized\nto eating the peanut snack developed allergy by age 5. Therefore, in\nhigh-risk infants, sustained consumption of peanut beginning in the\nfirst 11 months of life was highly effective in preventing the\ndevelopment of peanut allergy.\n\\end{quote}\n\nThese results seem impressive, but as skeptical data scientists we\nshould wonder whether it is possible that we are getting fooled by\nrandomness. Maybe the apparent difference between the groups is due to\nchance, not the effectiveness of the treatment. To see whether this is\nlikely, we will simulate the experiment using a model where the\ntreatment has no effect, and see how often we see such a big difference\nbetween the groups.\n\nDetailed results of the study are reported in the \\emph{New England\nJournal of Medicine} (see\n\\url{https://www.nejm.org/doi/full/10.1056/NEJMoa1414850}). In that\narticle, Figure 1 shows the number of subjects in the treatment and\ncontrol groups, which happened to be equal.\n\n\\begin{lstlisting}[language=Python,style=source]\nn_control = 314\nn_treatment = 314\n\\end{lstlisting}\n\nAnd from Figure 2 we can extract the number of subjects who developed\npeanut allergies in each group. Specifically, we'll use the numbers from\nthe ``intention to treat analysis for both cohorts''.\n\n\\begin{lstlisting}[language=Python,style=source]\nk_control = 54\nk_treatment = 10\n\\end{lstlisting}\n\nUsing these numbers, we can compute the risk in each group as a\npercentage.\n\n\\begin{lstlisting}[language=Python,style=source]\nrisk_control = k_control / n_control * 100\nrisk_control\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n17.197452229299362\n\\end{lstlisting}\n\n\\begin{lstlisting}[language=Python,style=source]\nrisk_treatment = k_treatment / n_treatment * 100\nrisk_treatment\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n3.1847133757961785\n\\end{lstlisting}\n\nThese are consistent with the percentages reported in the paper. To\nquantify the difference between the groups, we'll use relative risk,\nwhich is the ratio of the risks in the two groups.\n\n\\begin{lstlisting}[language=Python,style=source]\nrelative_risk_actual = risk_treatment / risk_control\nrelative_risk_actual\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.1851851851851852\n\\end{lstlisting}\n\nThe risk in the treatment group is about 18\\% of the risk in the control\ngroup. So it seems like the treatment is highly effective. To check,\nlet's imagine a world where the treatment is completely ineffective, so\nthe risk is actually the same in both groups, and the difference we saw\nis due to chance. If that's true, we can estimate the hypothetical risk\nby combining the two groups:\n\n\\begin{lstlisting}[language=Python,style=source]\nn_all = n_control + n_treatment\nk_all = k_control + k_treatment\nrisk_all = k_all / n_all\nrisk_all\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.10191082802547771\n\\end{lstlisting}\n\nIf the risk is the same for both groups, it is close to 10\\%. Now we can\nuse this hypothetical risk to simulate the experiment. Here's\n\\passthrough{\\lstinline!simulate\\_group\\_percent!}, which we saw in\nChapter 11. It takes as parameters the size of the group,\n\\passthrough{\\lstinline!n!}, and the risk, \\passthrough{\\lstinline!p!}.\nIt simulates the experiment and returns the number of cases as a\npercentage of the group, which is the observed risk.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport numpy as np\n\ndef simulate_group_percent(n, p):\n    xs = np.random.random(size=n)\n    k = np.sum(xs < p)\n    return k / n * 100\n\\end{lstlisting}\n\nIf we call this function many times, the result is a list of observed\nrisks, one for each simulated experiment. Here's the list for the\ntreatment group.\n\n\\begin{lstlisting}[language=Python,style=source]\nt1 = [simulate_group_percent(n_treatment, risk_all)\n      for i in range(1000)]\n\\end{lstlisting}\n\nAnd the control group.\n\n\\begin{lstlisting}[language=Python,style=source]\nt2 = [simulate_group_percent(n_control, risk_all)\n      for i in range(1000)]\n\\end{lstlisting}\n\nIf we divide these lists elementwise, the result is a list of relative\nrisks, one for each simulated experiment.\n\n\\begin{lstlisting}[language=Python,style=source]\nrelative_risks = np.divide(t2, t1)\n\\end{lstlisting}\n\nWe can use a KDE plot to visualize the distribution of these results.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nsns.kdeplot(relative_risks)\n\nplt.xlabel('Relative risk')\nplt.ylabel('Probability density')\nplt.title('Relative risks from simulation with risk_all');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{13_hypothesis_files/13_hypothesis_28_0.pdf}\n\\end{center}\n\nRemember that these simulations are based on the assumption that the\nrisk is the same for both groups, so we expect the relative risk to be\nnear 1 most of the time. And it is.\n\nIn some simulated experiments, the relative risk is as low as 0.5 or as\nhigh as 2, which means it is plausible we could see results like that by\nchance, even if there is no difference between groups.\n\nBut the relative risk in the actual experiment was 0.18, and we never\nsee a result as small as that in the simulated experiment. We can\nconclude that the relative risk we saw is unlikely if the risk is\nactually the same in both groups.\n\n\\hypertarget{p-values}{%\n\\section{p-values}\\label{p-values}}\n\nNow suppose that in addition to the treatment and control groups, the\nexperiment included a placebo group that was given a snack that\ncontained no peanuts. Suppose this group was the same size as the\nothers, and 42 of the subjects developed peanut allergies.\n\nTo be clear, there was no third group, and I made up these numbers, but\nlet's see how this hypothetical works out. Here's the risk in the\nplacebo group.\n\n\\begin{lstlisting}[language=Python,style=source]\nn_placebo = 314\nk_placebo = 42\n\nrisk_placebo = k_placebo / n_placebo * 100\nrisk_placebo\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n13.375796178343949\n\\end{lstlisting}\n\nAnd here's the relative risk compared to the control group.\n\n\\begin{lstlisting}[language=Python,style=source]\nrelative_risk_placebo = risk_placebo / risk_control\nrelative_risk_placebo\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.7777777777777778\n\\end{lstlisting}\n\nThe relative risk is less than 1, which means the risk in the placebo\ngroup is a bit lower than in the control group. So we might wonder\nwhether the placebo was actually effective. To answer that question, at\nleast partially, we can go back to the results from the simulated\nexperiment.\n\nUnder the assumption that there is actually no difference between the\ngroups, it would not be unusual to see a relative risk as low as 0.77 by\nchance. In fact, we can compute the probability of seeing a relative\nrisk as low or lower than\n\\passthrough{\\lstinline!relative\\_risk\\_placebo!}, even if the two\ngroups are the same, like this:\n\n\\begin{lstlisting}[language=Python,style=source]\np_value = (relative_risks <= relative_risk_placebo).mean()\np_value\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.137\n\\end{lstlisting}\n\nThis probability is called a \\textbf{p-value} (see\n\\url{https://en.wikipedia.org/wiki/P-value}). In this case, the p-value\nis about 14\\%, which means that even if the two groups are the same, we\nexpect to see a relative risk as low as 0.77 about 14\\% of the time. So,\nfor this imagined experiment, we can't rule out the possibility that the\napparent difference is due to chance.\n\n\\hypertarget{are-first-babies-more-likely-to-be-late}{%\n\\section{Are first babies more likely to be\nlate?}\\label{are-first-babies-more-likely-to-be-late}}\n\nIn the previous example, we saw a difference in proportion between two\ngroups. As a second example, let's consider a difference in means.\n\nWhen my wife and I were expecting our first child, we heard that first\nbabies are more likely to be born late. But we also heard that first\nbabies are more likely to be born early. So which is it? As a data\nscientist with too much time on my hands, I decided to find out. I got\ndata from the National Survey of Family Growth (NSFG), the same survey\nwe have used in previous chapters. I've put the results from the\n2015-2017 survey in an HDF file. Here are the first few rows.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport pandas as pd\n\nnsfg = pd.read_hdf('nsfg.hdf', 'nsfg')\nnsfg.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lrrrrrrrrrrr}\n\\toprule\n{} &  CASEID &  OUTCOME &  BIRTHWGT\\_LB1 &  BIRTHWGT\\_OZ1 &  PRGLNGTH &  NBRNALIV &  AGECON &  AGEPREG &  BIRTHORD &  HPAGELB &  WGT2015\\_2017 \\\\\n\\midrule\n0 &   70627 &        1 &           7.0 &           8.0 &        40 &       1.0 &      28 &     29.0 &       1.0 &      5.0 &  19877.457610 \\\\\n1 &   70627 &        4 &           NaN &           NaN &        14 &       NaN &      32 &     32.0 &       NaN &      NaN &  19877.457610 \\\\\n2 &   70627 &        1 &           9.0 &           2.0 &        39 &       1.0 &      33 &     33.0 &       2.0 &      5.0 &  19877.457610 \\\\\n3 &   70628 &        1 &           6.0 &           9.0 &        39 &       1.0 &      17 &     18.0 &       1.0 &      1.0 &   4221.017695 \\\\\n4 &   70628 &        1 &           7.0 &           0.0 &        39 &       1.0 &      19 &     20.0 &       2.0 &      2.0 &   4221.017695 \\\\\n\\bottomrule\n\\end{tabular}\n\nI'll use the \\passthrough{\\lstinline!OUTCOME!} column to select\npregnancies that ended with a live birth.\n\n\\begin{lstlisting}[language=Python,style=source]\nlive = (nsfg['OUTCOME'] == 1)\nlive.sum()\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n6693\n\\end{lstlisting}\n\nAnd I'll use \\passthrough{\\lstinline!PRGLNGTH!} to select babies that\nwere born full term, that is, during or after the 37th week of\npregnancy.\n\n\\begin{lstlisting}[language=Python,style=source]\nfullterm = (nsfg['PRGLNGTH'] >= 37) & (nsfg['PRGLNGTH'] < 48)\n\\end{lstlisting}\n\nThis dataset includes data from 2724 first babies.\n\n\\begin{lstlisting}[language=Python,style=source]\nfirst = live & fullterm & (nsfg['BIRTHORD'] == 1)\nn_first = first.sum()\nn_first\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n2724\n\\end{lstlisting}\n\nAnd 3115 other (not first) babies.\n\n\\begin{lstlisting}[language=Python,style=source]\nother = live & fullterm & (nsfg['BIRTHORD'] > 1)\nn_other = other.sum()\nn_other\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n3115\n\\end{lstlisting}\n\nWe can use \\passthrough{\\lstinline!loc!} to select pregnancy lengths for\nthe first babies and others.\n\n\\begin{lstlisting}[language=Python,style=source]\nlength_first = nsfg.loc[first, 'PRGLNGTH']\nlength_other = nsfg.loc[other, 'PRGLNGTH']\n\\end{lstlisting}\n\nHere are the mean pregnancy lengths for the two groups, in weeks.\n\n\\begin{lstlisting}[language=Python,style=source]\nprint(length_first.mean(), length_other.mean())\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n39.39647577092511 39.19775280898877\n\\end{lstlisting}\n\nIn this dataset, first babies are born a little later on average. The\ndifference is about 0.2 weeks, or 33 hours.\n\n\\begin{lstlisting}[language=Python,style=source]\ndiff_actual = length_first.mean() - length_other.mean()\ndiff_actual, diff_actual * 7 * 24\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(0.19872296193634043, 33.38545760530519)\n\\end{lstlisting}\n\nRelative to an average length of 39 weeks, that's not a very big\ndifference. We might wonder if a difference as big as this would be\nlikely, even if the two groups are the same. To answer that question,\nlet's imagine a world where there is no difference in pregnancy length\nbetween first babies and others. How should we model a world like that?\nAs always with modeling decisions, there are many options. A simple one\nis to combine the two groups and compute the mean and standard deviation\nof pregnancy length, like this:\n\n\\begin{lstlisting}[language=Python,style=source]\nlength = nsfg.loc[live&fullterm, 'PRGLNGTH']\nmean = length.mean()\nstd = length.std()\nmean, std\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(39.29046069532454, 1.1864094701037655)\n\\end{lstlisting}\n\nNow we can use \\passthrough{\\lstinline!simulate\\_sample\\_mean!} from\nChapter 11 to draw a random sample from a normal distribution with the\ngiven parameters and return the mean.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef simulate_sample_mean(n, mu, sigma):\n    sample = np.random.normal(mu, sigma, size=n)\n    return sample.mean()\n\\end{lstlisting}\n\nIf we run it 1000 times, it simulates the sampling and measurement\nprocess and returns a list of results from 1000 simulated experiments.\nHere are the simulated results with sample size\n\\passthrough{\\lstinline!n\\_first!}:\n\n\\begin{lstlisting}[language=Python,style=source]\nt_first = [simulate_sample_mean(n_first, mean, std)\n           for i in range(1000)]\n\\end{lstlisting}\n\nAnd with sample size \\passthrough{\\lstinline!n\\_other!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nt_other = [simulate_sample_mean(n_other, mean, std)\n           for i in range(1000)]\n\\end{lstlisting}\n\nIf we subtract the simulated means elementwise, the result is a list of\nobserved differences from simulated experiments where the distribution\nis the same for both groups.\n\n\\begin{lstlisting}[language=Python,style=source]\ndiffs = np.subtract(t_first, t_other)\n\\end{lstlisting}\n\nWe can use a KDE plot to visualize the distribution of these values.\n\n\\begin{lstlisting}[language=Python,style=source]\nsns.kdeplot(diffs)\n\nplt.xlabel('Difference in pregnancy length (weeks)')\nplt.ylabel('Probability density')\nplt.title('Distribution of differences');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{13_hypothesis_files/13_hypothesis_66_0.pdf}\n\\end{center}\n\nThe center of this distribution is near zero, which makes sense if the\ndistribution in both group is the same. Just by chance, we sometimes see\ndifferences as big as 0.1 weeks, but in 1000 simulations, we never see a\ndifference as big as the observed difference in the data, which is\nalmost 0.2 weeks.\n\nBased on this result, we can pretty much rule out the possibility that\nthe difference we saw is due to random sampling. But we should remember\nthat there are other possible sources of error. For one, pregnancy\nlengths in the NSFG are self-reported. When the respondents are\ninterviewed, their recollection of first babies might be less accurate\nthan their recollection of more recent babies. Or the estimation of\npregnancy length might be less accurate with less experienced mothers.\n\nA correspondent of mine, who knows more than me about giving birth,\nsuggested yet another possibility. If a first baby is born by\n\\href{https://en.wikipedia.org/wiki/Caesarean_section}{Caesarean\nsection}, it is more likely that subsequent deliveries will be\nscheduled, and less likely that they will go much past 39 weeks. So that\ncould bring the average down for non-first babies.\n\nIn summary, the results in this section suggest that the observed\ndifference is unlikely to be due to chance, but there are still several\nother possible explanations.\n\n\\hypertarget{the-hypothesis-testing-framework}{%\n\\section{The Hypothesis Testing\nFramework}\\label{the-hypothesis-testing-framework}}\n\nThe examples we've done so far fit into the framework shown in this\ndiagram:\n\n\\includegraphics{figs/hypothesis_testing.png}\n\nUsing data from an experiment, we compute a \\textbf{test statistic} (see\n\\url{https://en.wikipedia.org/wiki/Test_statistic}). In the peanut\nallergy example, the test statistic is relative risk. In the pregnancy\nlength example, it is the difference in the means. In both cases, the\ntest statistic quantifies the size of the observed effect, denoted\n\\(\\delta^*\\) in the diagram.\n\nThen we build a model of a world where the effect does not exist. This\nmodel is called the \\textbf{null hypothesis} (see\n\\url{https://en.wikipedia.org/wiki/Exclusion_of_the_null_hypothesis})\nand denoted \\(H_0\\). In the peanut allergy example, the model assumes\nthat the risk is the same in both groups. In the pregnancy example, it\nassumes that the lengths are drawn from the same normal distribution.\n\nNext we use the model to simulate the experiment many times. Each\nsimulation generates a dataset which we use to compute the test\nstatistic, \\(\\delta\\). Finally, we collect the test statistics from the\nsimulations and compute a p-value, which is the probability under the\nnull hypothesis of seeing a test statistic as big as the observed\neffect, \\(\\delta*\\).\n\nIf the p-value is small, we can usually rule out the possibility that\nthe observed effect is due to random variation. But often there are\nother explanations we can't rule out, including measurement error and\nunrepresentative sampling.\n\nI emphasize the role of the model in this framework because for a given\nexperiment there might be several possible models, each including some\nelements of the real world and ignoring others. For example, we used a\nnormal distribution to model variation in pregnancy length. If we don't\nwant to make this assumption, an alternative is to simulate the null\nhypothesis by shuffling the pregnancy lengths.\n\nThe following function takes two sequences representing the pregnancy\nlengths for the two groups. It appends them into a single sequence,\nshuffles it, and then splits it again into groups with the same size as\nthe originals. The return value is the difference in means between the\ngroups.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef simulate_two_groups(data1, data2):\n    n, m = len(data1), len(data2)\n    data = np.append(data1, data2)\n    np.random.shuffle(data)\n    group1 = data[:n]\n    group2 = data[n:]\n    return group1.mean() - group2.mean()\n\\end{lstlisting}\n\nIf we call this function once, we get a random difference in means from\na simulated world where the distribution of pregnancy lengths is the\nsame in both groups.\n\n\\begin{lstlisting}[language=Python,style=source]\nsimulate_two_groups(length_first, length_other)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n-0.03111395525888838\n\\end{lstlisting}\n\n\\textbf{Exercise:} Using this function to run 1000 simulations of the\nnull hypothesis and save the results as \\passthrough{\\lstinline!diff2!}.\nMake a KDE plot to compare the distribution of\n\\passthrough{\\lstinline!diff2!} to the results from the normal model,\n\\passthrough{\\lstinline!diff!}.\n\nCompute the probability of seeing a difference as big as\n\\passthrough{\\lstinline!diff\\_actual!}. Is this p-value consistent with\nthe results we got with the normal model?\n\n\\textbf{Exercise:} Are first babies more likely to be \\emph{light}? To\nfind out, we can use the birth weight data from the NSFG. The variables\nwe need use special codes to represent missing data, so I'll replace\nthem with \\passthrough{\\lstinline!NaN!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nnsfg['BIRTHWGT_LB1'].replace([0, 98, 99], np.nan, inplace=True)\nnsfg['BIRTHWGT_OZ1'].replace([0, 98, 99], np.nan, inplace=True)\n\\end{lstlisting}\n\nAnd combine pounds and ounces into a single variable.\n\n\\begin{lstlisting}[language=Python,style=source]\nbirthwgt = nsfg['BIRTHWGT_LB1'] + nsfg['BIRTHWGT_OZ1'] / 16\n\\end{lstlisting}\n\nWe can use \\passthrough{\\lstinline!first!} and\n\\passthrough{\\lstinline!other!} to select birth weights for first babies\nand others, dropping the \\passthrough{\\lstinline!NaN!} values.\n\n\\begin{lstlisting}[language=Python,style=source]\nbirthwgt_first = birthwgt[first].dropna()\nbirthwgt_other = birthwgt[other].dropna()\n\\end{lstlisting}\n\nIn this dataset, it looks like first babies are a little lighter, on\naverage.\n\n\\begin{lstlisting}[language=Python,style=source]\nprint(birthwgt_first.mean(), birthwgt_other.mean())\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n7.3370276162790695 7.507115749525616\n\\end{lstlisting}\n\nBut as usual, we should wonder whether we are being fooled by\nrandomness. To find out, compute the actual difference between the\nmeans. Then use \\passthrough{\\lstinline!simulate\\_two\\_groups!} to\nsimulate a world where birth weights for both groups are drawn from the\nsame distribution. Under the null hypothesis, how often does the\ndifference in means exceed the actual difference in the dataset? What\nconclusion can you draw from this result?\n\n\\hypertarget{testing-correlation}{%\n\\section{Testing Correlation}\\label{testing-correlation}}\n\nThe method we used in the previous section is called a\n\\textbf{permutation test} because ``permutation'' is another word for\nshuffling (see\n\\url{https://en.wikipedia.org/wiki/Resampling_(statistics)\\#Permutation_tests}).\nPermutation tests are also useful for testing whether an observed\ncorrelation might be do to chance.\n\nAs an example, let's look again at the correlations we computed in\nChapter 9, using data from the Behavioral Risk Factor Surveillance\nSystem (BRFSS). The following cell reads the data.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport pandas as pd\n\nbrfss = pd.read_hdf('brfss.hdf', 'brfss')\nbrfss.shape\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(418268, 9)\n\\end{lstlisting}\n\nThe correlations we computed were between height, weight and age.\n\n\\begin{lstlisting}[language=Python,style=source]\ncolumns = ['HTM4', 'WTKG3', 'AGE']\nsubset = brfss[columns]\ncorr_actual = subset.corr()\ncorr_actual\n\\end{lstlisting}\n\n\\begin{tabular}{lrrr}\n\\toprule\n{} &      HTM4 &     WTKG3 &       AGE \\\\\n\\midrule\nHTM4  &  1.000000 &  0.477151 & -0.135980 \\\\\nWTKG3 &  0.477151 &  1.000000 & -0.064951 \\\\\nAGE   & -0.135980 & -0.064951 &  1.000000 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe correlation between height and weight is about 0.48, which is\nmoderately strong; if you know someone's height, you can make a better\nguess about their weight. The other correlations are weaker; for\nexample, knowing someone's age would not substantially improve your\nguesses about their height or weight.\n\nBecause these correlations are so small, we might wonder whether they\nare due to chance. To answer this question, we can use permutation to\nsimulate a world where there is actually no correlation between two\nvariables.\n\nBut first we have to take a detour to figure out how to shuffle a Pandas\n\\passthrough{\\lstinline!Series!}. As an example, I'll extract the height\ndata.\n\n\\begin{lstlisting}[language=Python,style=source]\nseries = brfss['HTM4']\nseries.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &   HTM4 \\\\\n\\midrule\n0 &  157.0 \\\\\n1 &  163.0 \\\\\n2 &  165.0 \\\\\n3 &  165.0 \\\\\n4 &  152.0 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe idiomatic way to shuffle a \\passthrough{\\lstinline!Series!} is to\nuse \\passthrough{\\lstinline!sample!} with the argument\n\\passthrough{\\lstinline!frac=1!}, which means that the fraction of the\nelements we want is \\passthrough{\\lstinline!1!}, that is, all of them\n(see\n\\url{https://stackoverflow.com/questions/29576430/shuffle-dataframe-rows}).\nBy default, \\passthrough{\\lstinline!sample!} chooses elements without\nreplacement, so the result contains all of the elements in a random\norder.\n\n\\begin{lstlisting}[language=Python,style=source]\nshuffled = series.sample(frac=1)\nshuffled.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &   HTM4 \\\\\n\\midrule\n205593 &  170.0 \\\\\n292620 &  175.0 \\\\\n44585  &  185.0 \\\\\n13394  &  165.0 \\\\\n67403  &  173.0 \\\\\n\\bottomrule\n\\end{tabular}\n\nIf we check the first few elements, it seems like a random sample, so\nthat's good. But let's see what happens if we use the shuffled\n\\passthrough{\\lstinline!Series!} to compute a correlation.\n\n\\begin{lstlisting}[language=Python,style=source]\ncorr = shuffled.corr(brfss['WTKG3'])\ncorr\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.47715146283881443\n\\end{lstlisting}\n\nThat result looks familiar: it is the correlation of the unshuffled\ncolumns. The problem is that when we shuffle a\n\\passthrough{\\lstinline!Series!}, the index gets shuffled along with it.\nWhen we compute a correlation, Pandas uses the index to line up the\nelements from the first \\passthrough{\\lstinline!Series!} with the\nelements of the second \\passthrough{\\lstinline!Series!}. For many\noperations, that's the behavior we want, but in this case it defeats the\npurpose of shuffling!\n\nThe solution is to use \\passthrough{\\lstinline!reset\\_index!}, which\ngives the \\passthrough{\\lstinline!Series!} a new index, with the\nargument \\passthrough{\\lstinline!drop=True!}, which drops the old one.\nSo we have to shuffle \\passthrough{\\lstinline!series!} like this.\n\n\\begin{lstlisting}[language=Python,style=source]\nshuffled = series.sample(frac=1).reset_index(drop=True)\n\\end{lstlisting}\n\nNow we can compute a correlation with the shuffled\n\\passthrough{\\lstinline!Series!}.\n\n\\begin{lstlisting}[language=Python,style=source]\ncorr = shuffled.corr(brfss['WTKG3'])\ncorr\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.003117718945752242\n\\end{lstlisting}\n\nThe result is small, as we expect it to be when the elements are aligned\nat random.\n\nRather than repeat this awful idiom, let's put it in a function and\nnever speak of it again.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef shuffle(series):\n    return series.sample(frac=1).reset_index(drop=True)\n\\end{lstlisting}\n\nThe following function takes a \\passthrough{\\lstinline!DataFrame!} and\ntwo column names, makes a shuffled copy of one column, and computes its\ncorrelation with the other.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef simulate_correlation(df, var1, var2):\n    corr = shuffle(df[var1]).corr(df[var2])\n    return corr\n\\end{lstlisting}\n\nWe only have to shuffle one of the columns; it doesn't get any more\nrandom if we shuffle both. Now we can use this function to generate a\nsample of correlations with shuffled columns.\n\n\\begin{lstlisting}[language=Python,style=source]\nt = [simulate_correlation(brfss, 'HTM4', 'WTKG3')\n     for i in range(200)]\n\\end{lstlisting}\n\nHere's the distribution of the correlations.\n\n\\begin{lstlisting}[language=Python,style=source]\nsns.kdeplot(t)\n\nplt.xlabel('Correlation')\nplt.ylabel('Probability density')\nplt.title('Correlation from simulations with permutation');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{13_hypothesis_files/13_hypothesis_108_0.pdf}\n\\end{center}\n\nThe center of the distribution is near 0, and the largest values\n(positive or negative) are around 0.005. If we compute the same\ndistribution with different columns, the results are pretty much the\nsame. With samples this big, the correlation between shuffled columns is\ngenerally small.\n\nHow do these values compare to the observed correlations?\n\n\\begin{itemize}\n\\item\n  The correlation of height and weight is about 0.48, so it's extremely\n  unlikely we would see a correlation as big as that by chance.\n\\item\n  The correlation of height and age is smaller, around -0.14, but even\n  that value would be unlikely by chance.\n\\item\n  And the correlation of weight and age is even smaller, about -0.06,\n  but that's still 10 times bigger than the biggest correlation in the\n  simulations.\n\\end{itemize}\n\nWe can conclude that these correlations are probably not due to chance.\nAnd that's useful in the sense that it rules out one possible\nexplanation. But this example also demonstrates a limitation of this\nkind of hypothesis testing. With large sample sizes, variability due to\nrandomness tends to be small, so it seldom explains the effects we see\nin real data.\n\nAnd hypothesis testing can be a distraction from more important\nquestions. In Chapter 9, we saw that the relationship between weight and\nage is nonlinear. But the coefficient of correlation only measures\nlinear relationships, so it does not capture the real strength of the\nrelationship. So testing a correlation might not be the more useful\nthing to do in the first place. We can do better by testing a regression\nmodel.\n\n\\hypertarget{testing-regression-models}{%\n\\section{Testing Regression Models}\\label{testing-regression-models}}\n\nIn the previous sections we used permutation to simulate a world where\nthere is no correlation between two variables. In this section we'll\napply the same method to regression models.\n\nAs an example, we'll use NSFG data to explore the relationship between a\nmother's age and her baby's birth weight.\n\nIn previous sections we computed birth weight and a Boolean variable\nthat identifies first babies. Now I'll store them as columns in\n\\passthrough{\\lstinline!nsfg!}, so we can use them with StatsModels.\n\n\\begin{lstlisting}[language=Python,style=source]\nnsfg['BIRTHWGT'] = birthwgt\nnsfg['FIRST'] = first\n\\end{lstlisting}\n\nI'll select the subset of the rows that represent live, full-term\nbirths.\n\n\\begin{lstlisting}[language=Python,style=source]\nsubset = nsfg[live & fullterm].copy()\nn = len(subset)\nn\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n5839\n\\end{lstlisting}\n\nI tried a few different ways to visualize the relationship between\nmother's age and birth weight, including a scatter plot and a violin\nplot. The one that worked best is a box plot with mother's age grouped\ninto 3-year bins.\n\nI used \\passthrough{\\lstinline!np.arange!} to make the bin boundaries,\nand \\passthrough{\\lstinline!pd.cut!} to put the values from\n\\passthrough{\\lstinline!AGECON!} into bins.\n\n\\begin{lstlisting}[language=Python,style=source]\nbins = np.arange(15, 40, 3)\nlabels = (bins + 1)[:-1]\n\nsubset['AGEGRP'] = pd.cut(subset['AGECON'], \n                          bins, labels=labels)\n\\end{lstlisting}\n\nThe label for each bin is the midpoint of the range; I used a slice to\nremove the last label because the number of bins is one less than the\nnumber of bin boundaries.\n\nHere's the box plot.\n\n\\begin{lstlisting}[language=Python,style=source]\nsns.boxplot(x='AGEGRP', y='BIRTHWGT', data=subset, \n            whis=None, color='plum')\n\nplt.xlabel(\"Mother's age (years)\")\nplt.ylabel('Birthweight (pounds)');\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{13_hypothesis_files/13_hypothesis_118_0.pdf}\n\\end{center}\n\nIt looks like the average birth weight is highest if the mother is 25-31\nyears old, and lower if she is younger or older. So the relationship\nmight be nonlinear. Nevertheless, let's start with a linear model and\nwork our way up. Here's a simple regression of birth weight as a\nfunction of the mother's age at conception.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport statsmodels.formula.api as smf\n\nresults = smf.ols('BIRTHWGT ~ AGECON', data=subset).fit()\nresults.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept &  7.025486 \\\\\nAGECON    &  0.016407 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe slope of the regression line is 0.016 pounds per year, which means\nthat if one mother is a year older than another, we expect her baby to\nbe about 0.016 pounds heavier, which is about a quarter of an ounce.\n\nThis parameter is small, so we might wonder whether the apparent effect\nis due to chance. To answer that question, we will use permutation to\nsimulate a world where there is no relationship between mother's age and\nbirth weight.\n\nAs a test statistic, we'll use the coefficient of determination, denoted\n\\(R^2\\), which quantifies the predictive power of the model (see\n\\url{https://en.wikipedia.org/wiki/Coefficient_of_determination}). The\nregression results include \\(R^2\\) in a variable called\n\\passthrough{\\lstinline!rsquared!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nresults.rsquared\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.007578923866134457\n\\end{lstlisting}\n\nThe value of \\(R^2\\) for this model is very small, which means that our\nguesses about a baby's weight are barely improved if we know the\nmother's age (and use a linear model). So it seems possible that the\napparent relationship between these variables is due to chance. We can\ntest this possibility by using permutation to simulate a world where\nthere is no such relationship.\n\nThe following function takes a \\passthrough{\\lstinline!DataFrame!},\nshuffles the \\passthrough{\\lstinline!AGECON!} column, computes a linear\nregression model, and returns \\(R^2\\).\n\n\\begin{lstlisting}[language=Python,style=source]\ndef simulate_rsquared(df):\n    df['SHUFFLED'] = shuffle(df['AGECON'])\n    formula = 'BIRTHWGT ~ SHUFFLED'\n    results = smf.ols(formula, data=df).fit()\n    return results.rsquared\n\\end{lstlisting}\n\nIf we call it many times, we get a sample from the distribution of\n\\(R^2\\) under the null hypothesis.\n\n\\begin{lstlisting}[language=Python,style=source]\nrsquared_null = [simulate_rsquared(subset)\n                 for i in range(200)]\n\\end{lstlisting}\n\nAfter 200 attempts, the largest value of \\(R^2\\) is about 0.003, which\nis smaller than the observed value of \\(R^2\\), about 0.008. We conclude\nthat the observed effect is bigger than we would expect to see by\nchance.\n\n\\begin{lstlisting}[language=Python,style=source]\nprint(np.max(rsquared_null), results.rsquared)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.003366669516827181 0.007578923866134457\n\\end{lstlisting}\n\n\\textbf{Exercise:} The box plot suggests that the relationship between\nmother's age and birth weight is nonlinear, so let's try a nonlinear\nmodel. I'll add a column to the \\passthrough{\\lstinline!DataFrame!} with\nthe square of mother's age.\n\n\\begin{lstlisting}[language=Python,style=source]\nsubset['AGECON2'] = subset['AGECON']**2\n\\end{lstlisting}\n\nAnd run the model again with both the linear and quadratic terms.\n\n\\begin{lstlisting}[language=Python,style=source]\nformula = 'BIRTHWGT ~ AGECON + AGECON2'\nresults2 = smf.ols(formula, data=subset).fit()\nresults2.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept &  5.894125 \\\\\nAGECON    &  0.109487 \\\\\nAGECON2   & -0.001810 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe parameter of \\passthrough{\\lstinline!AGECON2!} is quite small, so we\nmight wonder whether it actually improves the model, or might be the\nproduct of randomness. One way to answer this question is to look at the\nimprovement in \\(R^2\\).\n\n\\begin{lstlisting}[language=Python,style=source]\nresults2.rsquared\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.01186101019657615\n\\end{lstlisting}\n\nThe value of \\(R^2\\) is about 0.012, compared to 0.008 with the linear\nmodel. By this criterion, the quadratic model is a better, but when we\nadd variables to a model, we might get some improvement just by chance.\nTo see how much, write a function called\n\\passthrough{\\lstinline!simulate\\_rsquared2!} that takes a\n\\passthrough{\\lstinline!DataFrame!} as a parameter, shuffles\n\\passthrough{\\lstinline!AGECON2!}, runs a regression model with\n\\passthrough{\\lstinline!AGECON!} and the shuffled values, and returns\n\\(R^2\\). Run your function 200 times and count how often \\(R^2\\) from\nthe model exceeds the observed value from the dataset. What conclusion\ncan you draw?\n\n\\hypertarget{controlling-for-age}{%\n\\section{Controlling for Age}\\label{controlling-for-age}}\n\nIn a previous exercise, you computed the difference in birth weight\nbetween first babies and others, which is about 0.17 pounds, and you\nchecked whether we are likely to see a difference as big as that by\nchance. If things went according to plan, you found that it is very\nunlikely.\n\nBut that doesn't necessarily mean that there is anything special about\nfirst babies that makes them lighter than others. Rather, knowing a\nbaby's birth order might provide information about some other factor\nthat is related to birth weight. The mother's age could be that factor.\n\nFirst babies are likely to have younger mothers than other babies, and\nyounger mothers tend to have lighter babies. The difference we see in\nfirst babies might be explained by their mothers' ages. So let's see\nwhat happens if we control for age. Here's a simple regression of birth\nweight as a function of the Boolean variable\n\\passthrough{\\lstinline!FIRST!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nformula = 'BIRTHWGT ~ FIRST'\nresults = smf.ols(formula, data=subset).fit()\nresults.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept     &  7.507116 \\\\\nFIRST[T.True] & -0.170088 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe parameter associated with \\passthrough{\\lstinline!FIRST!} is -0.17\npounds, which is the same as the difference in means we computed. But\nnow we can add \\passthrough{\\lstinline!AGECON!} as a control variable.\n\n\\begin{lstlisting}[language=Python,style=source]\nformula = 'BIRTHWGT ~ FIRST + AGECON'\nresults = smf.ols(formula, data=subset).fit()\nresults.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept     &  7.163240 \\\\\nFIRST[T.True] & -0.121771 \\\\\nAGECON        &  0.013145 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe age effect accounts for some of the difference between first babies\nand others. After controlling for age, the remaining difference is about\n0.12 pounds. Since the age effect is nonlinear, we can can control for\nage more effectively by adding \\passthrough{\\lstinline!AGECON2!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nformula = 'BIRTHWGT ~ FIRST + AGECON + AGECON2'\nresults = smf.ols(formula, data=subset).fit()\nresults.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept     &  6.128590 \\\\\nFIRST[T.True] & -0.099338 \\\\\nAGECON        &  0.096781 \\\\\nAGECON2       & -0.001615 \\\\\n\\bottomrule\n\\end{tabular}\n\n\\begin{lstlisting}[language=Python,style=source]\nslope_actual = results.params['FIRST[T.True]']\nslope_actual\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n-0.09933806121560089\n\\end{lstlisting}\n\nWhen we use a quadratic model to control for the age effect, the\nremaining difference between first babies and others is smaller again,\nabout 0.10 pounds.\n\nOne of the warning signs of a spurious relationship between two\nvariables is that the effect gradually disappears as you add control\nvariables. So we should wonder whether the remaining effect might be due\nto chance. To find out, I'll use the following function, which simulates\na world where there is no difference in weight between first babies and\nothers. It takes a \\passthrough{\\lstinline!DataFrame!} as a parameter,\nshuffles the \\passthrough{\\lstinline!FIRST!} column, runs the regression\nmodel with \\passthrough{\\lstinline!AGECON!} and\n\\passthrough{\\lstinline!AGECON2!}, and returns the estimated difference.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef simulate_slope(df):\n    df['SHUFFLED'] = shuffle(df['FIRST'])\n    formula = 'BIRTHWGT ~ AGECON + AGECON2 + C(SHUFFLED)'\n    results = smf.ols(formula, data=df).fit()\n    return results.params['C(SHUFFLED)[T.True]']\n\\end{lstlisting}\n\nIf we run it many times, we get a sample from the distribution of the\ntest statistic under the null hypothesis.\n\n\\begin{lstlisting}[language=Python,style=source]\nslopes_null = [simulate_slope(subset)\n               for i in range(200)]\n\\end{lstlisting}\n\nThe range of values is wide enough that it occasionally exceeds the\nobserved effect size.\n\n\\begin{lstlisting}[language=Python,style=source]\nprint(min(slopes_null), max(slopes_null))\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n-0.10810723399824093 0.12738249958193887\n\\end{lstlisting}\n\nOur estimate of the p-value is only approximate, but it looks like it's\nbetween 1\\% and 2\\%.\n\n\\begin{lstlisting}[language=Python,style=source]\np_value = (np.abs(slopes_null) > np.abs(slope_actual)).mean()\np_value\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n0.015\n\\end{lstlisting}\n\nThis result indicates that an observed difference of 0.1 pounds is\npossible, but not likely, if the actual difference between the groups is\nzero.\n\nSo how should we interpret a result like this? In the tradition of\nstatistical hypothesis testing, it is common to use 5\\% as the threshold\nbetween results that are considered ``statistically significant'' or not\n(see\n\\url{https://en.wikipedia.org/wiki/Statistical_hypothesis_testing}). By\nthat standard, the weight difference between first babies and others is\nstatistically significant.\n\nHowever, there are several problems with this practice:\n\n\\begin{itemize}\n\\item\n  First, the choice of the threshold should depend on the context. For a\n  life-and-death decision, we might choose a more stringent threshold.\n  For a topic of idle curiosity, like this one, we could be more\n  relaxed.\n\\item\n  But it might not be useful to apply a threshold at all. An alternative\n  (which is common in practice) is to report the p-value and let it\n  speak for itself. It provides no additional value to declare that the\n  result is significant or not.\n\\item\n  Finally, the use of the word ``significant'' is dangerously\n  misleading, because it implies that the result is important in\n  practice. But a small p-value only means that an observed effect would\n  be unlikely to happen by chance. It doesn't mean it is important.\n\\end{itemize}\n\nThis last point is particularly problematic with large datasets, because\nvery small effects can be statistically significant. We saw an example\nwith the BRFSS dataset, where the correlations we tested were \\emph{all}\nstatistically significant, even the ones that are too small to matter in\npractice.\n\n\\hypertarget{summary}{%\n\\section{Summary}\\label{summary}}\n\nLet's review the examples in this chapter:\n\n\\begin{enumerate}\n\\def\\labelenumi{\\arabic{enumi}.}\n\\item\n  We started with data from LEAP, which studied the effect of eating\n  peanuts on the development of peanut allergies. The test statistic was\n  relative risk, and the null hypothesis was that the treatment was\n  ineffective.\n\\item\n  Then we looked at the difference in pregnancy length for first babies\n  and others. We used the difference in means as the test statistic, and\n  two models of the null hypothesis: one based on a normal model and the\n  other based on permutation of the data. As an exercise, you tested the\n  difference in weight between first babies and others.\n\\item\n  Next we used permutation to test correlations, using height, weight,\n  and age data from the BRFSS. This example shows that with large sample\n  sizes, observed effects are often ``statistically significant'', even\n  if they are too small to matter in practice.\n\\item\n  We used regression models to explore the maternal age effect on birth\n  weight. To see whether the effect might be due to chance, we used\n  permutation to model the null hypothesis and \\(R^2\\) as a test\n  statistic.\n\\item\n  Finally, we explored the possibility that the first baby effect is\n  actually an indirect maternal age effect. After controlling for the\n  mother's age, we tested whether the remaining difference between first\n  babies and others might happen by chance. We used permutation to model\n  the null hypothesis and the estimated slope as a test statistic.\n\\end{enumerate}\n\nAs an exercise, below, you can use the same methods to explore the\npaternal age effect.\n\n\\textbf{Exercise:} A\n\\href{https://en.wikipedia.org/wiki/Paternal_age_effect}{paternal age\neffect} is a relationship between the age of a father and a variety of\noutcomes for their children. There is some evidence that young fathers\nand old fathers tend to have lighter babies than fathers in the middle.\nLet's see if that's true for the babies in the NSFG dataset. The\n\\passthrough{\\lstinline!HPAGELB!} column encodes the father's age. Here\nare the values, after replacing the codes for missing data with\n\\passthrough{\\lstinline!NaN!}.\n\n\\begin{lstlisting}[language=Python,style=source]\nsubset['HPAGELB'].replace([98, 99], np.nan, inplace=True)\nsubset['HPAGELB'].value_counts().sort_index()\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  HPAGELB \\\\\n\\midrule\n1.0 &      478 \\\\\n2.0 &     1391 \\\\\n3.0 &     1650 \\\\\n4.0 &     1225 \\\\\n5.0 &      592 \\\\\n6.0 &      411 \\\\\n\\bottomrule\n\\end{tabular}\n\nAnd here's what the codes mean:\n\n\\begin{longtable}[]{@{}ll@{}}\n\\toprule\nCode & Age\\tabularnewline\n\\midrule\n\\endhead\n1 & Under 20 years\\tabularnewline\n2 & 20-24 years\\tabularnewline\n3 & 25-29 years\\tabularnewline\n4 & 30-34 years\\tabularnewline\n5 & 35-39 years\\tabularnewline\n6 & 40 years or older\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nI'll create a new column that's true for the fathers in the youngest and\noldest groups.\n\n\\begin{lstlisting}[language=Python,style=source]\nsubset['YO_DAD'] = subset['HPAGELB'].isin([1, 6])\n\\end{lstlisting}\n\nWe can use this column in a regression model to compute the difference\nin birth weight for young and old fathers compared to the others.\n\n\\begin{lstlisting}[language=Python,style=source]\nformula = 'BIRTHWGT ~ YO_DAD'\nresults = smf.ols(formula, data=subset).fit()\nresults.params\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &         0 \\\\\n\\midrule\nIntercept      &  7.447477 \\\\\nYO\\_DAD[T.True] & -0.140045 \\\\\n\\bottomrule\n\\end{tabular}\n\nThe difference is negative, which is consistent with the theory, and\nabout 0.14 pounds, which is comparable in size to the (apparent) first\nbaby effect. But there is a strong correlation between father's age and\nmother's age. So what seems like a paternal age effect might actually be\nan indirect maternal age effect. To find out, let's see what happens if\nwe control for the mother's age. Run this model again with\n\\passthrough{\\lstinline!AGECON!} and \\passthrough{\\lstinline!AGECON2!}\nas predictors. Does the observed effect of paternal age get smaller?\n\nTo see if the remaining effect could be due to randomness, write a\nfunction that shuffles \\passthrough{\\lstinline!YO\\_DAD!}, runs the\nregression model, and returns the parameter associated with the shuffled\ncolumn. How often does this parameter exceed the observed value? What\nconclusion can we draw from the results?\n\n", "meta": {"hexsha": "5c57419cc156433d5cc70911419617eb43a0aec7", "size": 47391, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "book/13_hypothesis.tex", "max_stars_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_stars_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2021-05-06T13:57:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T18:21:30.000Z", "max_issues_repo_path": "book/13_hypothesis.tex", "max_issues_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_issues_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "book/13_hypothesis.tex", "max_forks_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_forks_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-27T10:41:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T10:41:22.000Z", "avg_line_length": 35.7128862095, "max_line_length": 145, "alphanum_fraction": 0.7637315102, "num_tokens": 12554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7690802264851918, "lm_q1q2_score": 0.438262406212787}}
{"text": "\\chapter{Nambu String}\n\nNow, we want to step over from field theory to string theory. In classical field theory, we got information about our fields in different points of spacetime. Here, we don't have points anymore but one-dimensional objects, called strings. At a given moment, one can move along the string that may change with time. So we need two coordinates, if we want to describe an event on the string. Nevertheless, it is important to keep the theory Lorentz invariant, so we have to work in four-dimensional spacetime. A very practical way is to take the two-dimensional surface and embed it into Minkowski spacetime:\n\\begin{figure}[H]\n\\includegraphics[width=\\textwidth]{img/string.pdf}\n\\caption{Embedding of the Nambu string into Minkowski spacetime}\n\\label{fig:8}\n\\end{figure}\nHere, $\\sigma$ and $\\tau$ denote the coordinates of the string at rest (the parametrization) and $x^{\\mu}(\\sigma, \\tau)$ are the coordinates in spacetime. They depend on the inertial observer and can be transformed into each other by a Lorentz transformation. The sections of all embedded points with surfaces of constant time define the string at that moment. We choose $\\sigma \\in [0,\\pi]$ because it is very practical for Fourier transformation which is often used in string theory, but we also could have chosen a different range. \\\\\n\nLet us see now which conditions the embedding functions $x^{\\mu}(\\sigma, \\tau)$ have to fulfill. First of all, it is very common to consider a closed string, that means identifying the endpoints \n\\begin{align}\nx^{\\mu}(0, \\tau) = x^{\\mu}(\\pi, \\tau).\n\\end{align}\nSo the worldsheet of the string builds a kind of tube. \\\\\n\nThe second condition is that the string is not allowed to move faster than light ($\\bar{v} \\leq 1$). If a light signal is emitted on the string, the worldsheet is a cone with apex angle of $90^{\\circ}$. The point of emission has to stay in the cone and is not allowed to exit (see Fig.~\\ref{fig:8}). This corresponds to\n\\begin{align}\n\\dot{x}^2 = (\\dot{x}^0)^2 - \\dot{\\bar{x}}^2 = \\left( \\frac{dx^0}{d\\tau} \\right)^2 - \\left( \\frac{d\\bar{x}}{d\\tau} \\right)^2 \\geq 1 - \\left( \\frac{d\\bar{x}}{dx^0} \\right)^2 \\geq 0.\n\\end{align}\n\n\\pagebreak\n\nAnd the last condition is that we want to have one time-like and one space-like vector. We found the time-like vector already which is just $\\dot{x}^{\\mu}$ because of the above condition. So we set the limitation \n\\begin{align}\n(x')^2 < 0,\n\\end{align}\nand define $x'$ to be the space-like vector. The square should be understand as the inner product with Minkowski metric like in the condition above.\n\n\n\\section{Lagrangian}\nWhat is the Lagrangian for such a string? \nWe can try to rewrite the known Lagrangian of a relativistic point particle.\nFrom special relativity, we know that the action of a point particle is \n\\begin{align}\nS = - m \\int \\sqrt{1 - \\bar{v}^2} \\ dt = - m \\int \\sqrt{(dt)^2 - (d\\bar{x})^2} = - m \\int \\sqrt{dx_{\\mu}dx^{\\mu}} = - m \\int ds. \n\\end{align}\nWe see that the action corresponds to the \"length\" of the worldline of the particle, measured with Minkowski metric.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width=\\textwidth]{img/string_action.pdf}\n\\end{center}\n\\caption{Action of a relativistic point particle and a relativistic string}\n\\label{fig:9}\n\\end{figure}\nSince now, we don't have a point which forms a worldline but a string which forms a \"worldsuface\", it is reasonable to take the area element instead of the line element and define\n\\begin{align}\nS_{\\text{str}} \\equiv - \\gamma \\int dA,\n\\end{align}\nwhere $\\gamma$ is a proportionality constant. We will see later that this constant corresponds to the energy per unit length of the string.\nBut how to find the area element on the worldsheet of the string in Minkowski spacetime? \\\\\n\nWe will need a bit of differential geometry here. The area element on our flat parametrization would be given by $dA = d\\sigma d\\tau$. When we embed our surface into Minkowski spacetime, we have to consider the changing line elements (see Fig.~\\ref{fig:10}):\n\\begin{align}\nda^{\\mu} &= \\dot{x}^{\\mu} d\\tau \\\\\ndb^{\\mu} &= x'^{\\mu} d\\sigma.\n\\end{align}\nWe could take this into account by using the generalized Jacobian determinant but we would like to show a more geometrical way.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=1.1]{img/string_area.pdf}\n\\end{center}\n\\caption{Finding the area element $dA$}\n\\label{fig:10}\n\\end{figure}\nIf an area is spanned by two vectors $\\bar{a}, \\bar{b}$ in three-dimensional euclidean space, the area is just\n\\begin{align}\nA = |\\bar{a} \\times \\bar{b}| = |\\bar{a}| |\\bar{b}| \\sin(\\measuredangle(\\bar{a},\\bar{b})) = |\\bar{a}| |\\bar{b}| \\sqrt{1 - \\left( \\frac{\\bar{a} \\cdot \\bar{b}}{|\\bar{a}| |\\bar{b}|} \\right)^2} = \\sqrt{|\\bar{a}|^2 |\\bar{b}|^2 - \\left( \\bar{a} \\cdot \\bar{b} \\right)^2}.\n\\end{align}\nBut how to do it in four-dimensional Minkowski spacetime? If we want to know the area element of an embedded surface, we have to know the induced metric $g_{a b}$ on the surface. In our case, the area element turns out to be very similar to the three-dimensional case\n\\begin{align}\ndA = \\sqrt{|g|} \\ d\\sigma \\wedge \\tau = \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\ d\\sigma \\wedge \\tau,\n\\end{align}\nas we will see later. Here $(\\dot{x}x')$ denotes the inner product with our Minkowski metric and $x^{\\mu}$ still depends on $\\sigma$ and $\\tau$. So the action for the Nambu string is\n\\begin{align}\nS_{\\text{str}} = - \\gamma \\int dA &= - \\gamma \\int \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\ d\\sigma d\\tau \\notag \\\\\n&= - \\gamma \\displaystyle\\int\\limits_{\\tau_1}^{\\tau_2} d\\tau \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}.\n\\end{align}\n\n\nIf we identify $\\tau$ as the proper time, we can read off the Lagrangian for the Nambu string:\n\\begin{align}\nL[x^{\\mu}(\\sigma), \\dot{x}^{\\mu}(\\sigma)] = - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}.\n\\end{align}\n\n\n\n\n\\section{Hamiltonian}\n\nNow that we have the Lagrangian for the Nambu string, we can continue to find the Hamiltonian and see which constraints we get. In some sense, the description of string theory is similar to that of electrodynamics, we just take the coordinates $x^{\\mu}$ instead of the fields $A_{\\mu}$ and get\n\\begin{align}\nq_i(t) \\ \\ \\longrightarrow \\ \\ x^{\\mu}(\\sigma, \\tau),\n\\end{align}\nso the index $i$ is now given by $\\mu$ and the position $\\sigma$ on the string. The generalized momentum is therefore\n\\begin{align}\np_{\\mu}(\\sigma) = \\frac{\\delta L}{\\delta \\dot{x}^{\\mu}(\\sigma)}.\n\\end{align}\nLet us calculate it for the Nambu string:\n\\begin{align}\np_{\\mu}(\\sigma) &= \\frac{\\delta L}{\\delta \\dot{x}^{\\mu}(\\sigma)} =  - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ \\frac{2 (\\dot{x}x') \\frac{\\delta(\\dot{x}^{\\nu}x'_{\\nu})}{\\delta \\dot{x}^{\\mu}(\\sigma)} - (x')^2 \\frac{\\delta (\\dot{x}^{\\nu}\\dot{x}_{\\nu})}{\\delta \\dot{x}^{\\mu}(\\sigma)}}{2 \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}} \\notag \\\\\n&= - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ \\frac{(\\dot{x}x') \\delta_{\\mu}^{\\nu} \\delta(\\sigma - \\tilde{\\sigma}) x'_{\\nu} - (x')^2 \\dot{x}_{\\mu} \\delta(\\sigma - \\tilde{\\sigma})}{\\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}} \\notag \\\\\n&= - \\gamma \\ \\frac{(\\dot{x}x') x'_{\\mu} - (x')^2 \\dot{x}_{\\mu}}{\\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}},\n\\end{align}\nwhere the $x^{\\mu}$ in the first and second line depend on $\\tilde{\\sigma}$ and in the last line on $\\sigma$. It would be a difficult task to invert this equation and find $\\dot{x}_{\\mu}(p_{\\mu})$ but fortunately we notice that\n\\begin{align}\npx' \\equiv p_{\\mu}(\\sigma) x'^{\\mu}(\\sigma) = - \\gamma \\ \\frac{(\\dot{x}x') (x')^2 - (x')^2 (\\dot{x}x')}{\\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}} = 0.\n\\end{align}\n\nMoreover we have\n\\begin{align}\np^2 \\equiv p_{\\mu}(\\sigma) p^{\\mu}(\\sigma) &= \\gamma^2 \\ \\frac{(\\dot{x}x')^2 (x')^2 - 2 (x')^2 (\\dot{x}x')^2 + (x')^4 \\dot{x}^2}{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\notag \\\\\n&= - \\gamma^2 \\ \\frac{(x')^2 \\left[ (\\dot{x}x')^2 - (x')^2 \\dot{x}^2 \\right]}{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\notag  \\\\\n&= - \\gamma^2 (x')^2.\n\\end{align}\nSo we get two primary constraints \n\\begin{align}\n\\phi_1(\\sigma) &= p(\\sigma) x'(\\sigma) = 0 \\\\\n\\phi_2(\\sigma) &= p^2(\\sigma) + \\gamma^2 x'^2(\\sigma) = 0.\n\\end{align}\n\nThese are already all constraints that we can find because in our case:\n\\begin{align}\n\\text{Number of constraints} = 4 - \\text{rank} \\left( \\frac{\\delta^2 L}{\\delta\\dot{x}^{\\mu} \\delta\\dot{x}^{\\nu}} \\right).\n\\end{align}\nOne can show by explicit calculation that the rank of this matrix is two and that we only have two constraints but we won't do it here. \\\\\n\nThe next step is to find the Hamiltonian:\n\\begin{align}\nH[x^{\\mu}(\\sigma), p^{\\mu}(\\sigma)] &\\equiv \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\ \\dot{x}_{\\mu}(\\sigma)p^{\\mu}(\\sigma) + \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\notag \\\\\n&= \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\left( - \\gamma \\frac{(\\dot{x}x')^2 - (x')^2 \\dot{x}^2}{\\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2}} + \\gamma \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\right) \\notag \\\\\n&= 0.\n\\end{align}\nWe notice that it is zero and in fact, we didn't even had to calculate the Hamiltonian because we know from theorem~\\ref{Theorem} that \n\\begin{equation}\n\\text{if} \\ \\ \\ L[x^{\\mu}(\\sigma), \\lambda \\dot{x}^{\\mu}(\\sigma)] = \\lambda L[x^{\\mu}(\\sigma), \\dot{x}^{\\mu}(\\sigma)] \\ \\ \\ \\ \\Longrightarrow \\ \\ \\ \\ H[x^{\\mu}(\\sigma), p^{\\mu}(\\sigma)] = 0.\n\\end{equation}\n\nThe total Hamiltonian is therefore\n\\begin{align}\nH_T[x^{\\mu}(\\sigma), p^{\\mu}(\\sigma)] = \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\Bigg( u_1(\\sigma)\\underbrace{(p(\\sigma)x'(\\sigma))}_{=\\phi_1(\\sigma)} + u_2(\\sigma) \\underbrace{(p^2(\\sigma) + \\gamma^2 x'^2(\\sigma))}_{=\\phi_2(\\sigma)}  \\Bigg).\n\\end{align}\n\nAre these constraints conserved at every moment or do we have secondary constraints? \\\\\nWe get the equation of motion by\n\\begin{align}\n\\dot{g} = \\left \\{ g,H_T \\right \\} = \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\left( u_1(\\sigma) \\left \\{ g,\\phi_1(\\sigma) \\right \\}  + u_2(\\sigma) \\left \\{ g,\\phi_2(\\sigma) \\right \\} \\right),\n\\end{align}\n\nwhere\n\\begin{align}\n\\left \\{ f,g \\right \\} \\equiv \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\left( \\frac{\\delta f}{\\delta x^{\\mu}(\\sigma)} \\frac{\\delta g}{\\delta p_{\\mu}(\\sigma)} - \\frac{\\delta g}{\\delta x^{\\mu}(\\sigma)} \\frac{\\delta f}{\\delta p_{\\mu}(\\sigma)} \\right).\n\\end{align}\n\n\nWe have to check whether\n\\begin{align}\n0 &\\overset{?}{=} \\dot{\\phi}_1(\\tilde{\\sigma}) = \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\left( u_1(\\sigma) \\left \\{ \\phi_1(\\tilde{\\sigma}),\\phi_1(\\sigma) \\right \\}  + u_2(\\sigma) \\left \\{ \\phi_1(\\tilde{\\sigma}),\\phi_2(\\sigma) \\right \\} \\right) \\\\\n0 &\\overset{?}{=} \\dot{\\phi}_2(\\tilde{\\sigma}) = \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\left( u_1(\\sigma) \\left \\{ \\phi_2(\\tilde{\\sigma}),\\phi_1(\\sigma) \\right \\}  + u_2(\\sigma) \\left \\{ \\phi_2(\\tilde{\\sigma}),\\phi_2(\\sigma) \\right \\} \\right).\n\\end{align}\n\n\\pagebreak\n\nUsing the identity $\\left \\{ x^{\\mu}(\\sigma) , p_{\\nu}(\\tilde{\\sigma}) \\right \\} = \\delta_{\\nu}^{\\mu} \\delta(\\sigma - \\tilde{\\sigma})$ and calculating the poisson brackets accurately, one gets:\n\\begin{align}\n\\left \\{ \\phi_1(\\tilde{\\sigma}),\\phi_1(\\sigma) \\right \\} &=  (\\phi_1(\\sigma) + \\phi_1(\\tilde{\\sigma})) \\frac{\\partial}{\\partial \\sigma}\\delta(\\sigma - \\tilde{\\sigma}) \\\\\n\\left \\{ \\phi_2(\\tilde{\\sigma}),\\phi_2(\\sigma) \\right \\} &= (\\phi_1(\\sigma) + \\phi_1(\\tilde{\\sigma})) \\frac{\\partial}{\\partial \\sigma}\\delta(\\sigma - \\tilde{\\sigma}) \\\\\n\\left \\{ \\phi_1(\\tilde{\\sigma}),\\phi_2(\\sigma) \\right \\} &= (\\phi_2(\\sigma) + \\phi_2(\\tilde{\\sigma})) \\frac{\\partial}{\\partial \\sigma}\\delta(\\sigma - \\tilde{\\sigma}).\n\\end{align}\nSo when we insert this in the above equations for $\\dot{\\phi}_1$ and $\\dot{\\phi}_2$, we see that they can be expressed by the constraints themself and therefore vanish on the constraint surface. \\\\\nSo these two constraints are first-class constraints and we get no secondary constraints, $u_1$ and $u_2$ stay arbitrary. \\\\\n\n\nSince we have two arbitrary functions in our Hamiltonian, we have mathematical degrees of freedom or gauge freedom. The constraints are generators of gauge transformations. \n\nWhat transformations do they generate?\n\\begin{align}\n\\delta g = \\varepsilon_m \\left\\{ g,\\phi_m \\right\\} \\ \\ \\ \\Longrightarrow \\ \\ \\ \\delta g = \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ \\varepsilon(\\tilde{\\sigma}) \\left\\{ g,\\phi(\\tilde{\\sigma}) \\right\\}.\n\\end{align}\n\nLet's see which transformations $\\phi_1$ generates for the coordinates $x^{\\mu}$:\n\\begin{align}\n\\delta x^{\\mu}(\\sigma) &=  \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ \\varepsilon_1(\\tilde{\\sigma}) \\left \\{ x^{\\mu}(\\sigma),(p_{\\nu}(\\tilde{\\sigma}) x'^{\\nu}(\\tilde{\\sigma}) ) \\right \\} \\notag \\\\\n&=  \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ \\varepsilon_1(\\tilde{\\sigma}) x'^{\\nu}(\\tilde{\\sigma}) \\left \\{ x^{\\mu}(\\sigma),p_{\\nu}(\\tilde{\\sigma}) \\right \\} \\notag \\\\\n&= \\varepsilon_1(\\sigma) x'^{\\mu}(\\sigma) .\n\\end{align}\nHow to interpret this result? One can see that this is just the first order of the Taylor expansion of $x^{\\mu}(\\sigma + \\varepsilon_1(\\sigma))$:\n\\begin{align}\nx^{\\mu}(\\sigma) \\ \\longrightarrow \\ \\tilde{x}^{\\mu}(\\sigma) = x^{\\mu}(\\sigma) + \\varepsilon_1(\\sigma) x'^{\\mu}(\\sigma) = x^{\\mu}(\\overbrace{\\sigma + \\varepsilon_1(\\sigma)}^{= \\tilde{\\sigma}}).\n\\end{align}\nSo the transformation corresponds to a shift of the variable $\\sigma$. That's why we have to impose the conditions\n\\begin{align}\n\\varepsilon_1(0) = \\varepsilon_1(\\pi) = 0,\n\\end{align}\nto not exit the interval $[0,\\pi]$:\n\\begin{align}\n\\tilde{\\sigma}(0) &= 0 \\\\\n\\tilde{\\sigma}(\\pi) &= \\pi.\n\\end{align}\n\nIt turns out that this transformation is a map from the string to itself. What changes effectively is the parametrization of the string but not the form of the string itself. \\\\\nIt's like we would reparametrize a path. Since we have many possible ways to choose a parametrization, this corresponds to a high degree of freedom. \\\\\n\nFor this moment, we don't want to concentrate on the possible gauge transformations. The other transformations can be found easily, analog to the above procedure. Rather, we want to consider a concrete gauge (a concrete value of the arbitrary functions) and see what dynamics follow from it. \n\n\n\\section{Dynamics}\n\nLet us choose the gauge:\n\\begin{align}\nu_1(\\sigma) &= 0 \\\\\nu_2(\\sigma) &= \\frac{1}{2 \\gamma} \n\\end{align}\n\nand calculate the Hamiltonian equations of motion for the coordinates:\n\\begin{align}\\label{eq:78}\n\\dot{x}^{\\mu}(\\sigma) &= \\left \\{ x^{\\mu}(\\sigma), \\frac{1}{2 \\gamma} \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\left( p^2(\\tilde{\\sigma}) + \\gamma^2 x'^2(\\tilde{\\sigma}) \\right) \\right \\} \\notag \\\\\n&= \\frac{1}{2 \\gamma} \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ 2 p^{\\mu}(\\tilde{\\sigma}) \\delta(\\sigma - \\tilde{\\sigma}) \\notag \\\\\n&= \\frac{p^{\\mu}(\\sigma)}{\\gamma}\n\\end{align}\n\nand for the momenta:\n\\begin{align}\\label{eq:79}\n\\dot{p}^{\\mu}(\\sigma) &= \\left \\{ p^{\\mu}(\\sigma), \\frac{1}{2 \\gamma} \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\left( p^2(\\tilde{\\sigma}) + \\gamma^2 x'^2(\\tilde{\\sigma}) \\right) \\right \\} \\notag \\\\\n&= \\frac{1}{2 \\gamma} \\displaystyle\\int\\limits_{0}^{\\pi} d\\tilde{\\sigma} \\ 2 \\gamma^2 x'^{\\nu}(\\tilde{\\sigma}) (- \\delta^{\\mu}_{\\nu}) \\frac{\\partial}{\\partial \\tilde{\\sigma}}\\delta(\\sigma - \\tilde{\\sigma}) \\notag \\\\\n&= \\gamma x''^{\\mu}(\\sigma).\n\\end{align}\n\nInserting these results into our constraints $\\phi_1(\\sigma)$ and $\\phi_2(\\sigma)$, we get the conditions\n\\begin{align}\n\\dot{x}^2 + (x')^2 &= 0 \\\\\n\\dot{x} x' &= 0,\n\\end{align}\nwhich means that $x'$ and $\\dot{x}$ are orthogonal. That is why we call them \\textit{orthonormal gauge}.\n\nMoreover we can take the time-derivative of equation \\eqref{eq:78} and insert equation \\eqref{eq:79} to get the equation of motion\n\\begin{equation}\\label{eq:eom}\n\\ddot{x}^{\\mu}(\\sigma, \\tau) - x''^{\\mu}(\\sigma, \\tau) = 0.\n\\end{equation}\n\nThis looks much like the equation $\\partial_a \\partial^a x^{\\mu}(\\sigma, \\tau) = 0$, where $a = 1,2$ denote the derivative with respect to $\\tau$ and $\\sigma$, with signature $(+ -)$. That's why we would like to show the connection between $1+1$ gravity and the Nambu string before continuing with the dynamics. \n\n\\begin{example}[$1+1$ Gravity] \nWe want to illustrate the connection between the string and $1+1$ gravity, that is, one time-dimension and one space-dimension.\nWhen we embed the string in Minkowski space, it can have curvature. What is the metric? \nThe easiest way to find out the components of the metric is to look at the invariant line element  \n\\begin{align}\ndx^{\\mu} &= \\dot{x}^{\\mu} d\\tau + x'^{\\mu} d\\sigma \\\\\nds^2 &= dx_{\\mu}dx^{\\mu} = \\dot{x}^2 (d\\tau)^2 + 2 \\dot{x} x' d\\tau d\\sigma + (x')^2 (d\\sigma)^2.\n\\end{align}\nFrom here we can read off the metric since $ds^2 = g_{ab} \\ dx^a dx^b$:\n\\begin{align}\ng_{ab} = \n\\begin{pmatrix}\n    \\dot{x}^2 & \\dot{x} x' \\\\\n    \\dot{x} x' & (x')^2\n  \\end{pmatrix}\n\\end{align}\nand with our orthonormal gauge conditions, we get\n\\begin{align}\ng_{ab} = \n\\begin{pmatrix}\n    \\dot{x}^2 & 0 \\\\\n    0 & - \\dot{x}^2\n  \\end{pmatrix}\n= \\dot{x}^2\n\\begin{pmatrix}\n    1 & 0 \\\\\n    0 & -1\n  \\end{pmatrix},\n\\end{align}\nwhich is a conformally flat metric.\nSo we showed that the \"worldsurface\" of the string (like every two-dimensional Riemannian manifold) is conformally flat. This means that for every point on this surface, one can find a neighborhood that can be mapped to flat space by a conformal transformation (one that preserves orientation and angles locally). \nThe signature is $(+ -)$ like expected.\n\nLet's take a closer look at the action of the string again:\n\\begin{align}\nS = - \\gamma \\int d\\tau d\\sigma \\sqrt{(\\dot{x} x')^2 - \\dot{x}^2 (x')^2}.\n\\end{align}\nWe notice that the expression under the square root is exactly the negative of the determinant of the metric:\n\\begin{align}\ng \\equiv \\mbox{det}(g_{ab}) = \\dot{x}^2(x')^2 - (\\dot{x}x')^2.\n\\end{align}\nSo we can write the action of the string as\n\\begin{align}\nS = - \\gamma \\int d\\tau d\\sigma \\sqrt{- g}\n\\end{align}\nwhich is a kind of Einstein-Hilbert action for $1+1$ gravity, where $\\gamma$ plays the role of a gravity constant. In $3+1$ gravity it takes the form \n\\begin{align}\nS = \\frac{1}{2 \\kappa} \\int d^4 x \\ \\sqrt{- g} \\ (R + \\Lambda).\n\\end{align}\nThe string can be easily generalized to higher dimensions.\n\\end{example}\n\n\nLet us continue with the dynamics of the Nambu string. We have still enough gauge freedom to set \n\\begin{align}\nt = x^0(\\sigma, \\tau) = \\tau.\n\\end{align}\nThis choice is often used and leads to some simplifications in our dynamics. \\\\\n\nIt implies that\n\\begin{align}\n\\arraycolsep=1.4pt\\def\\arraystretch{1.5}\n\\begin{array}{ll}\n\\dot{x}^0 = \\frac{\\partial x^0}{\\partial \\tau} = \\frac{\\partial \\tau}{\\partial \\tau} = 1 \\ \\ \\ & \\ \\ \\ x'^0 = 0 \\\\\n\\dot{\\bar{x}} = \\frac{\\partial \\bar{x}}{\\partial \\tau} = \\frac{\\partial \\bar{x}}{\\partial t} = \\bar{v} \\ \\ \\ & \\ \\ \\ \\bar{x}' = \\frac{\\partial \\bar{x}}{\\partial \\sigma},\n\\end{array} \n\\end{align}\nwhich leads in connection with our constraints to\n\\begin{align}\n\\dot{x} x' = - (\\dot{\\bar{x}} \\bar{x}') = 0\n\\end{align}\nand \n\\begin{align}\n\\dot{x}^2 + (x')^2 = (1 - \\dot{\\bar{x}}^2) - (\\bar{x}')^2 = 0.\n\\end{align}\nSo we can replace our orthonormal gauge conditions by\n\\begin{align}\n\\dot{\\bar{x}}^2 + (\\bar{x}')^2 &= 1 \\\\\n\\dot{\\bar{x}} \\bar{x}' &= 0\n\\end{align}\nand the equation of motion \\eqref{eq:eom} turns to\n\\begin{align}\n\\ddot{\\bar{x}}(\\sigma, \\tau) - \\bar{x}''(\\sigma, \\tau) = 0.\n\\end{align}\n\nSo all our constraints and the equation of motion reduced to three dimensions.\nLet's see how we can rewrite our Lagrangian:\n\\begin{align}\nL &= - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\sqrt{(\\dot{x}x')^2 - \\dot{x}^2(x')^2} \\notag \\\\\n&= - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\ \\sqrt{0 - (1 - \\bar{v}^2) (- (\\bar{x}')^2)} \\notag \\\\\n&= - \\gamma \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\ \\left| \\bar{x}' \\right|  \\sqrt{1 - \\bar{v}^2}.\n\\end{align}\nIt reduces also to three dimensions and looks quite similar to the Lagrangian of a relativistic point particle: $L = - m \\sqrt{1 - \\bar{v}^2}$. Let us define the length $S$ of the string:\n\\begin{align}\nS = \\displaystyle\\int\\limits_{0}^{\\pi} d\\sigma \\ \\left| \\bar{x}' \\right| = \\displaystyle\\int\\limits_{0}^{S} ds.\n\\end{align} \n\nThen we get in analogy to the relativitic point particle:\n\\begin{align}\ndm = \\gamma \\ ds \\ \\ \\ \\Longrightarrow \\ \\ \\ \\gamma = \\frac{dm}{ds}.\n\\end{align}\n\nWe see that $\\gamma$ corresponds to the mass/energy of the string per unit length as mentioned before. ", "meta": {"hexsha": "80621ea3544a812e80f28cac4015048af9d38928", "size": 20601, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "06_string.tex", "max_stars_repo_name": "Spektralzerleger/Hamilton-Systems", "max_stars_repo_head_hexsha": "53ba6a624bda7a6e03acdecbd48d43f79e221823", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-11T22:55:50.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-11T22:55:50.000Z", "max_issues_repo_path": "06_string.tex", "max_issues_repo_name": "Spektralzerleger/Hamilton-Systems", "max_issues_repo_head_hexsha": "53ba6a624bda7a6e03acdecbd48d43f79e221823", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "06_string.tex", "max_forks_repo_name": "Spektralzerleger/Hamilton-Systems", "max_forks_repo_head_hexsha": "53ba6a624bda7a6e03acdecbd48d43f79e221823", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.7130434783, "max_line_length": 606, "alphanum_fraction": 0.6653560507, "num_tokens": 7082, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.6619228891883799, "lm_q1q2_score": 0.4381419024025094}}
{"text": "\\documentclass{article}[12]\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{suetterl}\n\\usepackage[T1]{fontenc}\n%\\usepackage{showframe}\n\\title{S\\\"utterlin and Fraktur Characters in Mathematics.}\n\\author{James Waddington}\n\\date{Last updated: \\today}\n\\begin{document}\n\\maketitle\n\\section{Introduction} Back in Spring 2014 I audited a course with John Steele at Berkeley. One minor stumbling block I had was his use of S\\\"utterlin in lieu of Fraktur for models on the board, so I thought I would collect them. If anyone knows of any common usages of Fraktur you should let me know.\n\n\\section{Tables of Characters}\n\\subsection{Common Characters}\n\n\n\\begin{tabular}{c | c | c | p{6cm}}\n    Fraktur & Latin & S\\\"utterlin & Common Instances\\\\\\hline\n    $\\mathfrak{A}$ & $A$ &\\suetterlin{A} & Models\\\\\n    $\\mathfrak{B}$ & $B$ &\\suetterlin{B} & Models\\\\\n    $\\mathfrak{C}$ & $C$ &\\suetterlin{C} & Models\\\\\n    $\\mathfrak{H}$ & $H$ &\\suetterlin{H} & \\\\\n    $\\mathfrak{L}$ & $L$ &\\suetterlin{L} & \\\\\n    $\\mathfrak{M}$ & $M$ &\\suetterlin{M} & Models\\\\\n    $\\mathfrak{N}$ & $N$ &\\suetterlin{N} & Models (Often models of arithmetic)\\\\\n    $\\mathfrak{R}$ & $R$ &\\suetterlin{R} & Models (Often of Real Closed Fields), Jacobson Radical\\\\\n    $\\mathfrak{a}$ & $a$ &\\suetterlin{a} & Ideals\\\\\n    $\\mathfrak{b}$ & $b$ &\\suetterlin{b} & Ideals\\\\\n    $\\mathfrak{c}$ & $c$ &\\suetterlin{c} & Ideals, Cardinality of $\\mathbb{R}$\\\\\n    $\\mathfrak{m}$ & $m$ &\\suetterlin{m} & Maximal Ideals\\\\\n    $\\mathfrak{p}$ & $p$ &\\suetterlin{p} & Prime Ideals\\\\\n\\end{tabular}\n\n\\subsection{Exhaustive List}\n\\begin{tabular}{c | c | c || c | c | c }\n    Fraktur & Latin & S\\\"utterlin & Fraktur & Latin & S\\\"utterlin \\\\\\hline\n    $\\mathfrak{A}$ & $A$ &\\suetterlin{A} & \n    $\\mathfrak{B}$ & $B$ &\\suetterlin{B} \\\\\n    $\\mathfrak{C}$ & $C$ &\\suetterlin{C} & \n    $\\mathfrak{D}$ & $D$ &\\suetterlin{D} \\\\\n    $\\mathfrak{E}$ & $E$ &\\suetterlin{E} & \n    $\\mathfrak{F}$ & $F$ &\\suetterlin{F} \\\\\n    $\\mathfrak{G}$ & $G$ &\\suetterlin{G} & \n    $\\mathfrak{H}$ & $H$ &\\suetterlin{H} \\\\\n    $\\mathfrak{I}$ & $I$ &\\suetterlin{I} & \n    $\\mathfrak{J}$ & $J$ &\\suetterlin{J} \\\\\n    $\\mathfrak{K}$ & $K$ &\\suetterlin{K} & \n    $\\mathfrak{L}$ & $L$ &\\suetterlin{L} \\\\ \n    $\\mathfrak{M}$ & $M$ &\\suetterlin{M} & \n    $\\mathfrak{N}$ & $N$ &\\suetterlin{N} \\\\ \n    $\\mathfrak{O}$ & $O$ &\\suetterlin{O} & \n    $\\mathfrak{P}$ & $P$ &\\suetterlin{P} \\\\ \n    $\\mathfrak{Q}$ & $Q$ &\\suetterlin{Q} & \n    $\\mathfrak{R}$ & $R$ &\\suetterlin{R} \\\\ \n    $\\mathfrak{S}$ & $S$ &\\suetterlin{S} & \n    $\\mathfrak{T}$ & $T$ &\\suetterlin{T} \\\\ \n    $\\mathfrak{U}$ & $U$ &\\suetterlin{U} & \n    $\\mathfrak{V}$ & $V$ &\\suetterlin{V} \\\\ \n    $\\mathfrak{W}$ & $W$ &\\suetterlin{W} & \n    $\\mathfrak{X}$ & $X$ &\\suetterlin{X} \\\\ \n    $\\mathfrak{Y}$ & $Y$ &\\suetterlin{Y} & \n    $\\mathfrak{Z}$ & $Z$ &\\suetterlin{Z} \\\\ \n\n    $\\mathfrak{a}$ & $a$ &\\suetterlin{a} & \n    $\\mathfrak{b}$ & $b$ &\\suetterlin{b} \\\\\n    $\\mathfrak{c}$ & $c$ &\\suetterlin{c} & \n    $\\mathfrak{d}$ & $d$ &\\suetterlin{d} \\\\\n    $\\mathfrak{e}$ & $e$ &\\suetterlin{e} & \n    $\\mathfrak{f}$ & $f$ &\\suetterlin{f} \\\\\n    $\\mathfrak{g}$ & $g$ &\\suetterlin{g} & \n    $\\mathfrak{h}$ & $h$ &\\suetterlin{h} \\\\\n    $\\mathfrak{i}$ & $i$ &\\suetterlin{i} & \n    $\\mathfrak{j}$ & $j$ &\\suetterlin{j} \\\\\n    $\\mathfrak{k}$ & $k$ &\\suetterlin{k} & \n    $\\mathfrak{l}$ & $l$ &\\suetterlin{l} \\\\ \n    $\\mathfrak{m}$ & $m$ &\\suetterlin{m} & \n    $\\mathfrak{n}$ & $n$ &\\suetterlin{n} \\\\ \n    $\\mathfrak{o}$ & $o$ &\\suetterlin{o} & \n    $\\mathfrak{p}$ & $p$ &\\suetterlin{p} \\\\ \n    $\\mathfrak{q}$ & $q$ &\\suetterlin{q} & \n    $\\mathfrak{r}$ & $r$ &\\suetterlin{r} \\\\ \n    $\\mathfrak{s}$ & $s$ &\\suetterlin{s} & \n    $\\mathfrak{t}$ & $t$ &\\suetterlin{t} \\\\ \n    $\\mathfrak{u}$ & $u$ &\\suetterlin{u} & \n    $\\mathfrak{v}$ & $v$ &\\suetterlin{v} \\\\ \n    $\\mathfrak{w}$ & $w$ &\\suetterlin{w} & \n    $\\mathfrak{x}$ & $x$ &\\suetterlin{x} \\\\ \n    $\\mathfrak{y}$ & $y$ &\\suetterlin{y} & \n    $\\mathfrak{z}$ & $z$ &\\suetterlin{z} \\\\ \n\\end{tabular}\n\\end{document}\n", "meta": {"hexsha": "079654f44da2972fba498a63533aeb16be1ffefd", "size": 4025, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FrakSutt.tex", "max_stars_repo_name": "sugarfrosted/Suetterlin-Fraktur-Table", "max_stars_repo_head_hexsha": "286eb6878ae5a2ffc60b8997133abda7af4f7307", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FrakSutt.tex", "max_issues_repo_name": "sugarfrosted/Suetterlin-Fraktur-Table", "max_issues_repo_head_hexsha": "286eb6878ae5a2ffc60b8997133abda7af4f7307", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FrakSutt.tex", "max_forks_repo_name": "sugarfrosted/Suetterlin-Fraktur-Table", "max_forks_repo_head_hexsha": "286eb6878ae5a2ffc60b8997133abda7af4f7307", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.2795698925, "max_line_length": 301, "alphanum_fraction": 0.5505590062, "num_tokens": 1805, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4381418979880182}}
{"text": "\\paragraph{Accounting for Uncertainty:} \\label{sec:acct_uncertainty}\nAn AIA that can predict its performance on different tasks can provide assurances about competence, predictability, and the situational normality of a given task. Several researchers have worked to improve this ability in visual classification \\cite{Zhang2014-he,Gurau2016-hs,Churchill2015-ei,Kaipa2015-hy}. \nFor example, to ensure that visual classifiers don't fail silently in novel scenarios, \\citet{Zhang2014-he} learned models of errors on training images to predict errors on test images. \\citet{Kaipa2015-hy} consider 3D visual classification of assembly line parts for robotic pick and place tasks, and develop statistical goodness-of-fit tests to estimate the likelihood that robots can use their sensors to find parts matching desired ones. These approaches allow the AIA to assess capability and present appropriate assurances to users, though without any formal notions of trust. \n\n\\citet{Mitchell2018-jw}, discuss, in the context of a `never ending learning problem' (i.e. where the AIA perpetually learns over time), how an agent can quantify uncertainty on unlabeled data given three requirements: 1) three or more approximations of a function are available, 2) the assumption that these functions are more accurate than chance, and 3) these functions have independent errors. The rates at which these functions agree on classification of unlabeled examples can be used to solve for their exact accuracies. Doing this allows the system to actively reduce uncertainty, by seeking relevant data.\nIn the context of image classification, \\citet{Paul2011-vr} introduced `perplexity' as a metric that represents uncertainty in predicting a single class and is used to select the `most perplexing' images for further learning. There have also been several attempts to use Gaussian processes (GPs) to actively learn and assign probabilistic classifications \\cite{MacKay1992-sp,Triebel2016-kj,Triebel2013-ow,Triebel2013-ku,Grimmett2013-gj,Grimmett2016-yc,Berczi2015-rd,Dequaire2016-kh}. As with perplexity-based classifiers, the key insight is that if a classifier possesses a measure of uncertainty, then that uncertainty can be used for efficient instance searching, comparison, and learning, as well as reporting a measure of confidence to users. The key property of GPs to this end is their ability to produce output confidence/uncertainty estimates that grow more uncertain away from the training data. This information can be readily assessed and conveyed to users, even in high-dimensional problems. This property has also found much use in other AIA active learning problems, e.g. Bayesian optimization \\cite{Snoek2012-tt, Brochu2010-tj,Israelsen2017-zb}.\n\nNeural network (NN) models are commonly considered black-box models, and methods to represent uncertainty have not historically been available. However, there have been several recent advances to make this possible to some extent~\\cite{Gal2016-om,Gal2016-eq}. Bayesian neural networks (BNNs) are a method by which we can draw insight about the uncertainty of a neural network's predictions; this is possible by placing prior distributions over the weights in a NN. \\citet{Kendall2017-ry}, in the context of computer vision, also use deep BNNs to help visualize epistemic (input) and aleatoric (model) uncertainty for each pixel of an image. \nSimilarly, \\citet{Kahn2017-vy} use deep BNNs to learn about the probability (with uncertainty) of an autonomous vehicle colliding in an environment given its current state, observations, and sequence of controls. Using this model they formulate a `velocity-dependent collision cost' that is used for model-based reinforcement learning. \nIn order to help predict uncertainty in real-time robotic applications that learn from demonstrations, \\citet{Choi2017-th} use mixture density networks (MDNs)---neural networks that learn parameters of a Gaussian mixture distribution---to model complex distributions from human demonstrations.\n\nModels and logic are not trustworthy by themselves; they may be flawed to begin with, or become invalid when assumptions or specifications are violated. Thus, there is great interest in providing assurances that the models and assumptions underlying different AIA processes are in fact sound. \\citet{Laskey1991-mf}---with the intention of communicating model validity to users of `probability-based decision aids'---notes that it is infeasible to perform a decision-theoretic calculation to determine if model revision is necessary. She presents a class of theoretically justified model revision indicators, based on the idea of constructing a computationally simple alternate model and then initiating model revision if the likelihood ratio of the alternate model becomes too large (see also \\citet{Zagorecki2015-qy,Habbema1976-xd}). \\citet{Ghosh2016-dl}  present `model repair' and `data repair' strategies that can be used when the current model does not match the observed data, at which point the model and data can be repaired, and control actions can be replanned in order to conform with the formal method specifications. One challenge is how the `trustable' constraints should be identified, as this places a strong burden on the certifying authorities and system designer to foresee all possible failures.\n", "meta": {"hexsha": "c27faa1fcc2992ec11b5813b9a4d0b00dcf971c7", "size": 5330, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quantify_uncertainty.tex", "max_stars_repo_name": "bisraelsen/OnAssurances", "max_stars_repo_head_hexsha": "4411dda583ba35cb688105c274f40d329548ec94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "quantify_uncertainty.tex", "max_issues_repo_name": "bisraelsen/OnAssurances", "max_issues_repo_head_hexsha": "4411dda583ba35cb688105c274f40d329548ec94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quantify_uncertainty.tex", "max_forks_repo_name": "bisraelsen/OnAssurances", "max_forks_repo_head_hexsha": "4411dda583ba35cb688105c274f40d329548ec94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 410.0, "max_line_length": 1315, "alphanum_fraction": 0.8202626642, "num_tokens": 1150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4381418891590354}}
{"text": "\\newcommand{\\flexible}{\\em{Flexible}}\n\n\\newcommand{\\pos}{\\vect{x}}\n\\newcommand{\\dx}{\\vect{\\Delta x}}\n\\newcommand{\\xcur}{\\vect{x}_{n}}\n\\newcommand{\\xnext}{\\vect{x}_{n+1}}\n\\newcommand{\\vel}{\\vect{v}}\n\\newcommand{\\dv}{\\vect{\\Delta v}}\n\\newcommand{\\vcur}{\\vect{v}_{n}}\n\\newcommand{\\vnext}{\\vect v_{n+1}}\n\\newcommand{\\acc}{\\vect{a}}\n\\newcommand{\\force}{\\vect{f}}\n\\newcommand{\\forcext}{\\vect{f}_{ext}}\n\\newcommand{\\lam}{\\vect{\\lambda}}\n\\newcommand{\\lcur}{\\lam_{n}}\n\\newcommand{\\lnext}{\\lam_{n+1}}\n\\newcommand{\\avlam}{\\bar{\\lam}}\n\\newcommand{\\fcur}{\\vect{f}_{n}}\n\\newcommand{\\fnext}{\\vect f_{n+1}}\n\\newcommand{\\Minv}{\\mat M^{-1}}\n\\renewcommand{\\P}{\\mat P}\n\\newcommand{\\cmp}{c}\n\\newcommand{\\dampingratio}{d}\n\n\\newcommand{\\p}{\\vect{p}}  % moving point\n\\newcommand{\\polynomial}[2]{{#1}^{#2}}  % polynomial coordinates of a point\n\\newcommand{\\pp}{\\polynomial{\\p}{*}}  % polynomial coordinates of point p\n\\newcommand{\\ppinit}{\\polynomial{\\pinit}{*}}  % polynomial coordinates of point \\bar p\n\\newcommand{\\initial}[1]{\\bar{#1}}  % initial coordinates of a point\n\\newcommand{\\pinit}{\\initial{\\p}}  % initial coordinates of a point\n\\newcommand{\\pref}{\\initial{\\p}}  % reference (undeformed) point\n\\newcommand{\\disp}{\\vect{u}}  % displacement\n\\newcommand{\\f}{\\vect{f}}    % forces\n\n\\newcommand{\\dof}{q}           % independent DOF\n\\newcommand{\\dofinit}{\\initial\\dof}           % independent DOF\n\\newcommand{\\dofpos}{\\ensuremath{\\vect{x}} }           % posititon in 3d of an independent DOF\n\\newcommand{\\dofposinit}{\\initial\\dofpos }           % posititon in 3d of an independent DOF\n\\newcommand{\\pdofposinit}{\\polynomial{\\dofposinit}{*}}\n\\newcommand{\\pdofposinitcov}[1]{\\polynomial{\\dofposinit_#1}{*}\\polynomial{\\dofposinit_#1}{*T}}\n\\newcommand{\\vdof}{\\vect{\\dof}}           % vector of independent DOF\n\\newcommand{\\vdofinit}{\\vect{\\dofinit}}          % independent DOF\n\\newcommand{\\fdof}{\\f}           % force on independent DOF\n\\newcommand{\\vfdof}{\\vect{\\fdof}}           % vector of independent DOF force\n\\newcommand{\\dofm}{\\mat{A}}         % DOF matrix\n\\newcommand{\\dofmrel}{\\mat{A^r}}         % DOF matrix\n\\newcommand{\\mparam}{\\theta}           % material parameter\n\\newcommand{\\vmparam}{\\vect{\\mparam}}           % material points\n\\newcommand{\\defograd}{F}           % deformation gradient\n\\newcommand{\\fdefograd}{\\mathcal{F}}           % deformation gradient generalized force\n\\newcommand{\\strain}{\\epsilon}           % strain\n\\newcommand{\\stress}{\\sigma}           % stress\n\\newcommand{\\W}{\\mathcal{W}}           % elastic energy\n\\newcommand{\\C}{\\mat{C}}           % damping matrix\n\n\\newcommand{\\volume}{\\ensuremath{\\mathcal{V}}} \n\\newcommand{\\sample}{\\ensuremath{{\\mathcal{V}e}}} \n\\newcommand{\\vol}{\\ensuremath{\\Delta v}}\n\\newcommand{\\volmass}{\\ensuremath{\\rho}}\n\\newcommand{\\mass}{\\mat{M}}\n\n\\newcommand{\\ddof}{\\ensuremath{\\dot{\\dof}}}\n\\newcommand{\\dddof}{\\ensuremath{\\ddot{\\dof}}}\n\\newcommand{\\diff}{\\ensuremath{\\boldsymbol{\\nabla}_i}}\n\n\\newcommand{\\Jt}{\\J^T}\n\n\\newcommand{\\mCoord}{\\vect{\\Theta}}\n\\newcommand{\\shapef}{w}\n\n\\newcommand{\\MappingArrows}{\\ensuremath{\\left. \\begin{array}{c} \\stackrel{\\JNL}{\\longrightarrow} \\\\ \\stackrel{\\J}{\\longrightarrow} \\\\ \\stackrel{\\Jt}{\\longleftarrow} \\end{array}\\right.} }\n\n\\begin{abstract}\nThis plugin provides a unified approach to the simulation of deformable solids using a multi-layer kinematic structure: control nodes, deformation gradients, strains, and new mappings between these.\nThis approach maximizes the modularity of the implementation.\nFEM and meshless models use different position-deformation mappings. The remaining components (strain measures, constitutive laws) are common to the two approaches.\n\\end{abstract}\n\n\\section{Introduction Example}\n\nThe goal of this plugin is to improve the modularity of deformable solid simulation.\nFigure~\\ref{fig modularity mass-spring} shows an example of the increased modularity.\nIn \\sofa{}, mass-spring systems are traditionally modeled using three components for  state, mass and penalty force respectively. \nThe force component $F_s$ in fig.\\ref{fig mass-spring-traditional} is in charge of computing the distance and its gradient between the two particles, as well as to apply a constitutive law (typically linear viscoelastic).\nIn this plugin, we provide new components to split these computations and make the framework more modular.\nIn the example shown in fig.\\ref{fig mass-spring-flexible}, a mapping represented by an arrow is used to compute spring extensions $X_e$ based on particle positions $X_p$. \nA constitutive law $F_e$ is applied to the extensions, and the corresponding force is mapped upward to the particles through the mapping.\nThis is more modular since the linear viscoelastic constitutive law can be replaced with a different one, while re-using the same mapping from positions to extensions. In the traditional approach, extension computation would have to be re-implemented in the new force field.\nMoreover, in the new approach, the penalty force can also be replaced with a hard constraint, while re-using the same mapping (see also the Compliant plugin about soft and hard constraints).\nMore generally, complex components are decomposed in simple and re-usable components using mappings, to allow a unified approach to the simulation of deformable solids using mass-spring, FEM and mesh-less models.\n\\begin{figure}\n \\centering\n \\begin{subfigure}[t]{0.36\\linewidth} \\centering\n   \\includegraphics[clip,trim=0mm 285mm 155mm 0mm]{mass-spring.pdf}\n   \\caption{Two masses and a spring.} \\label{fig mass-spring}\n \\end{subfigure}\n \\begin{subfigure}[t]{0.3\\linewidth} \\centering\n   \\includegraphics[clip,trim=50mm 285mm 130mm 0mm]{mass-spring.pdf}\n   \\caption{Traditional \\sofa{} scene graph.} \\label{fig mass-spring-traditional}\n \\end{subfigure}\n \\begin{subfigure}[t]{0.3\\linewidth} \\centering\n   \\includegraphics[clip,trim=80mm 280mm 100mm 0mm]{mass-spring.pdf}\n   \\caption{A more modular data structure.} \\label{fig mass-spring-flexible}\n \\end{subfigure}\n \\caption{Improved modularity. $X$ denotes a state component, $M$ is mass, and $F$ a force field, while arrows represent mappings. $X_p$ represents particle positions while $X_e$ represents spring extensions, and $F_s$ represents spring forces while $F_e$ represent extension forces.}\n \\label{fig modularity mass-spring}\n\\end{figure}\n\n\n\n\\section{Three-layer Continuum Mechanics}\nThe Flexible plugin provides components to model Lagrangian deformable solids using three layers, as illustrated in fig.\\ref{fig tree levels}.\nWe present an overview of these and refer to subsequent sections for more detail.\n\\begin{figure}\n \\centering\n \\includegraphics[height=0.3\\linewidth]{threeLevels.pdf}\n \\caption{The deformable solid in the left is modeled using the three kinematic levels shown in the right.\n The red disks, the grey squares and the local frames respectively represent the control nodes, the integration points and the deformation gradients at these points.\n }\\label{fig tree levels}\n\\end{figure}\n\nThe top level contains the control nodes, which carry the independent degrees of freedom (DOF) of the object in state vectors $\\vect \\dof$ \nand $\\dot{\\vect\\dof}$ for positions and velocities, respectively . \nIn this example we use standard finite element (FE) nodes, but these could be any set of generalized coordinates such as moving frames, or deformation modes.\nThe shape functions represent how the material space of the object is mapped to the world space, based on the DOF. They are discussed in sec.\\ref{sec shape functions}.\n\nThe second level contains deformation gradients, which represent the local state of the continuum, like small reference frames painted on the object.\nEach of these is typically influenced by several control nodes in the upper level.\nTheir basis vectors are orthonormal in the undeformed configuration, while departure from unity corresponds to compression or extension, and departure from orthogonality corresponds to shear.\n\nThe deformation gradients are computed using a mapping based on the control nodes and their associated shape functions.\nDifferent mappings are used depending on the type of control nodes (points, frame, etc.) and shape functions (linear or higher level interpolation, RBF, etc.). These mappings are presented in sec.\\ref{sec deformation mapping}.\nThe deformation gradients are evaluated at carefully chosen sample points associated with object regions, which volumes are used to compute spatial integrals across the object. Sampling and quadrature are discussed in sec.\\ref{sec quadrature}.\n\nThe lower level contains measures of deformation, typically called strains.\nEach of these typically correspond to one deformation gradient at the upper level.\nThere are several ways of measuring deformation, including the well-known Cauchy strain, Green-Lagrange strain and corotational strain which for 3D objects are $3 \\times 3$ symmetric tensors, or scalar values such as the determinant of the deformation gradient.\nDifferent mappings are used to evaluate the different types of strain, as presented in sec.\\ref{sec strain mapping}.\n\nThe constitutive law of the object material is applied at the lower level to compute stress $\\stress$ based on strain $\\strain$. \nMore detail is given in sec.\\ref{sec materials}.\nThe vector of stresses $\\vect \\stress$ is mapped upward to generalized forces $\\vect \\fdefograd$ homogeneous to deformation gradients, which are multiplied by the sample size and possibly other volume moments to integrate across the object volume.\nThese generalized forces are then mapped upward to node forces.\n\nMass can be integrated at the middle level using volume samples, or set at the top level.\n\nThis flexible architecture allows us to easily create models by re-using available parts. In the example shown in fig.\\ref{fig tree levels frame}, the frame-based meshless model~\\cite{gilles:frame:TOG11,faure:framesteak:11} can be modeled using the same type of deformation gradients, strains and material laws as the FEM model in fig.\\ref{fig tree levels}.\nOnly the top layer (independent DOFs and associated shape functions), the mapping to the deformation gradients and the sampling method differ.\n\\begin{figure}\n \\centering\n \\includegraphics[page=2,height=0.3\\linewidth]{threeLevels.pdf}\n \\caption{A frame-based meshless model}\\label{fig tree levels frame}\n\\end{figure}\n\n\n\n\n\n\n\n\n\n%--------------------------------------------------------------------------------------------\n\\section{Shape functions} \\label{sec shape functions}\n\n\\subsection{Shepard}\n\nShepard shape functions correspond to inverse distance weights (\\url{http://en.wikipedia.org/wiki/Inverse_distance_weighting}).\n\nThey are defined as $\\shapef_i(\\mCoord)=1/|| \\mCoord-\\mCoord_i ||^p$ followed by normalization.\n\n\\subsection{Barycentric}\n\nBarycentric shape functions are the barycentric coordinates of points inside cells (can be edges, triangles, quads, tetrahedra, hexahedra).\nThey achieve first order consistency: $\\mCoord= \\sum \\shapef_i \\mCoord_i$\n \n\\subsection{Natural Neighbors}\n\nNatural neighbor interpolants are based on Voronoi diagrams.\nCurrently, Voronoi diagrams are computed from an image (a rasterized object).\n\n\\subsection{to do}\n\n\\begin{itemize}\n \\item higher order FEM\n \\item clarify material vs. spatial coordinates\n \\item \n\\end{itemize}\n\n\n\n\n\n\n\n%--------------------------------------------------------------------------------------------\n\\section{Deformation mapping} \\label{sec deformation mapping}\n\n\\subsection{linear mapping}\n\nChild positions are computed as a linear combination of parent node dofs.\nFor instance, the mapping from points to points is : $\\p = \\sum_i w_i (\\vdof - \\vdofinit)$.\nThe mapping from affine frames to points in homogeneous coordinates is : $\\p = \\sum_i w_i \\vdof \\vdofinit^{-1} \\pinit$.\n\n\\subsection{Extension mapping}\n\n\\subsection{Distance mapping}\n\n\\subsection{Log rigid mapping}\n\n\\subsection{Relative rigid mapping}\n\n\\subsection{Triangle deformation mapping}\n\n\\subsection{to do}\n\n\\begin{itemize}\n \\item Moving Least squares\n \\item non-linear skinning\n \\item clarify material vs. spatial coordinates\n \\item model plasticity/control using relative mappings\n \\item \n\\end{itemize}\n\n\n\n\n\n%--------------------------------------------------------------------------------------------\n\\section{Strain mapping} \\label{sec strain mapping}\n\n\\subsection{Green-Lagrangian strain}\n\nThe strain is mapped from the deformation gradient as : $\\mat{E} = (\\defograd^T\\defograd - \\mat{I} )/2$.\nHere the strain is stored into vectors using Voigt notation. In 3d, we have: $\\strain = [\\strain_{xx} , \\strain_{yy} , \\strain_{zz} , 2\\strain_{xy} , 2\\strain_{yx} , 2\\strain_{xz} ] $\nThe energy conjugate SPK stress vector is $\\stress = [\\stress_{xx} , \\stress_{yy} , \\stress_{zz} , \\stress_{xy} , \\stress_{yx} , \\stress_{xz} ] $\n\n\\subsection{Corotational strain}\n\nThe rigid displacement $\\mat{R}$ is first extracted from the deformation gradient using, for instance, SVD, polar or QR decomposition.\nThen, supposing that the non-rigid deformation $\\mat{R}^T \\defograd$ is small enough, we can apply the Cauchy strain formulation:  $\\mat{E} = [\\mat{R}^T \\defograd + \\defograd^T \\mat{R} ) /2 - \\mat{I} $.\n\n\nThe geometric stiffness contribution does not seem necessary because it does not visually change the behaviour but can compromise the stability.\n\\begin{itemize}\n\\item analytical QR decomposition jacobians given in \"Finite Random Matrix Theory, Jacobians of Matrix Transforms (without wedge products)\", Alan Edelman, 2005, http://web.mit.edu/18.325/www/handouts/handout2.pdf (UNSTABLE)\n\\item Polar decomposition gradients inspired by Jernej Barbic, Yili Zhao, \"Real-time Large-deformation Substructuring\" SIGGRAPH 2011 (UNSTABLE)\n\\item SVD gradients given in Christopher Twigg, Zoran Kacic-Alesic, \"Point Cloud Glue: Constraining simulations using the Procrustes transform\", SCA'10 (QUITE STABLE)\n\\end{itemize}\n\n\\subsection{Principal stretches}\n\nThe principles streches $\\mat{U}$ are directly extracted from the deformation gradient using a SVD, where the principal streches can be deduce from the eigen-values.\nNote that the corresponding stress is also represented by 3 values, so isotropic materials are not applicable.\n\nThe geometric stiffness contribution is important.\n\\begin{itemize}\n\\item SVD gradients given in T. Papadopoulo, M.I.A. Lourakis, \"Estimating the Jacobian of the Singular Value Decomposition: Theory and Applications\", European Conference on Computer Vision, 2000 (STABLE)\n\\end{itemize}\n\n\\subsection{Diagonal strain}\n\nThe diagonal strain $\\mat{D}$ is the principles streches + additional terms to allow anisotropic materials. \n\n\n\\subsection{Invariants of deformation tensor}\n\nThe elastic energy of some materials are expressed using the three invariants of the right Cauchy deformation tensor $\\mat{C}=\\defograd^T \\defograd$ :\n\n\\begin{itemize}\n \\item $I1(\\mat{C}) = trace(\\mat{C})$\n \\item $I2(\\mat{C}) = ( trace(\\mat{C}^2)+trace(\\mat{C})^2 )/2$\n \\item $I3(\\mat{C}) = det(\\mat{C})$\n\\end{itemize}\n\nIn practice, deviatoric invariants are used:\n\\begin{itemize}\n \\item $\\tilde{I1}(\\mat{C}) = I1(\\mat{C})/det(\\defograd)^{2/3}$\n \\item $\\tilde{I2}(\\mat{C}) = I2(\\mat{C})/det(\\defograd)^{4/3}$\n\\end{itemize}\n\nInvariants are homogeneous with energies, so we use their squared roots as the state vectors.\n\n\\subsection{to do}\n\n\\begin{itemize}\n \\item fix undefined invariants for inverted/flat elements\n \\item \n \\item \n\\end{itemize}\n\n\n\n\n\n\n\n%--------------------------------------------------------------------------------------------\n\\section{Materials} \\label{sec materials}\n\n\\subsection{Hooke Force field}\n\nHooke materials have linear strain/stress relationships: $\\stress=\\mat{H}\\strain$. \nThe potential energy is $W= \\int_{\\volume} \\strain^T\\mat{H}\\strain /2$. \n\n\\subsection{Mooney Rivlin}\n\nThe potential energy is $W= \\int_{\\volume} [ C1 ( I1 - 3)  + C2 ( I2 - 3) ]$, where $C1$ and $C2$ are material constants.\n\n\\subsection{Volume preservation}\n\nPossible energy formulations for volume conservation are :\n\\begin{itemize}\n \\item $W= \\frac{k}{2} \\int_{\\volume} log( det(\\defograd) )^2$\n \\item $W= \\frac{k}{2} \\int_{\\volume} (det(\\defograd)-1)^2$\n\\end{itemize}\nwhere $k$ is the bulk modulus.\n\n\\subsection{to do}\n\n\\begin{itemize}\n \\item merge with implemented fem materials (Costa, Arruda-Boyce, NeoHookean, Veronda)\n \\item \n \\item \n\\end{itemize}\n\n\\newpage\n%--------------------------------------------------------------------------------------------\n\\section{Quadrature} \\label{sec quadrature}\n\nQuadrature points are sampled using one of the GaussPointSampler component.\nCurrently, samplers can take meshes or images as inputs.\n\nQuadrature methods estimate integrals using a sum of weighted evaluations at sample positions: $\\int_{\\volume} f(\\pinit) d\\volume \\approx \\sum_i v_i f(\\pinit_i) $\n\n\\subsection{Mid-point}\n\nThe simplest method is to take one point per region and weight the value by its volume.\nThis is exact only for constant functions (e.g., elastic energy in a first order tetrahedral FEM)\n\n\\subsection{Gauss-Legendre}\n\nSeveral points are used to approximate the intergral of higher order functions.\nCurrently only first order Gauss-Legendre quadrature on hexahedra is implemented.\n\n\\subsection{Elastons}\n\nThe idea is to decompose $f$ on a basis: $f(\\pinit)=\\mat{c}(\\pinit_0) \\polynomial{(\\pinit-\\pinit_0)}{*}$, \nwhere $\\mat{c}$ are the coeficients and $\\polynomial{()}{*}$ the basis vector (for instance the first order polynomial basis $[1,x,y,z]$).\nThe integral is then estimated as  $\\int_{\\volume} f(\\pinit) d\\volume \\approx \\mat{c}(\\pinit_0)  \\int_{\\volume} \\polynomial{(\\pinit-\\pinit_0)}{*} d\\volume = \\sum_i v_i c_i(\\pinit_0) $\nwhere the coeeficient $v_i$ part can be precomputed using an arbitrary fine discretization.\n\n\\subsection{to do}\n\n\\begin{itemize}\n \\item Newton Cotes\n \\item Finish implementation of elastons. Required instanciations for all force fields..\n \\item \n\\end{itemize}\n\n\\appendix\n\n\\section{Background - to rephrase}\nThis section contains material which needs rephrasing.\n\nThe numerical simulation of continuous deformable objects is based on a discrete number of independent degrees of freedom (DOFs) which we will call the nodes. They are kinematic primitives (can be points, frames, etc.).\n\nNodes are associated with shape functions which are combined to produce the displacement function of material points in the solid.\n\nWe introduce the following notations:\n\\begin{itemize}\n \\item $\\vdofinit$, $\\vdof$ and $\\fdof$ : the initial positions, current positions, and forces of the nodes.\n \\item $\\mCoord$ : the material coordinates of a point according the chosen parameterization of the solid.\n \\item $\\pinit(\\mCoord)$, $\\p (\\mCoord)$ : the initial and current position of a point in space\n \\item $\\disp (\\mCoord) =\\p-\\pinit$ : the displacement of a point\n \\item $\\shapef_i(\\mCoord)$ : the shape function associated with node $i$\n\\end{itemize}\n\nThe local deformation is computed by differentiation with respect to material coordinates. The deformation gradient is: $\\defograd = \\partial \\p / \\partial \\mCoord$.\n\nThe elastic deformation is described using a strain measure based on the deformation gradient. \n\nThese three stages can be modeled using \\sofa{} mappings:\n\n\\begin{equation}\n\\left. \\begin{array}{ccccc}\n\\mbox{Nodes}  & \\MappingArrows &   \\mbox{Deformation gradients} & \\MappingArrows &  \\mbox{Strains}\n\\end{array}\\right. \n\\end{equation}\n\nThe elastic potential energy is computed from the strain. \n\nAfter spatial integration (quadrature), we obtain associated forces (total stress), that can be back propagated to the nodes using transposed jacobians.\n\n\\begin{equation}\\label{eq:f}\n \\vfdof = - \\frac{\\partial \\W}{\\partial \\vdof}^T =  - \\Jt_0\\Jt_1 \\int_{\\volume} \\stress\n\\end{equation}\n\nForce variations are updated at each mapping by combining material and geometric stiffnesses. For a mapping from $p$ to $c$, we have:\n\n\\begin{equation}\n \\delta(\\vfdof_p) = ( \\Jt \\K_c \\J + \\frac{\\partial \\Jt}{\\partial \\vdof_p} \\vfdof_c ) \\delta(\\vdof_p) \n\\end{equation}\n\n\\newpage\n%--------------------------------------------------------------------------------------------\n\\section{Scene graph}\n\n\\begin{itemize}\n \\item \\textbf{State =} nodes\n \\item Shape function\n\n \\item \\textbf{ELASTICITY:}\n  \\begin{itemize}\n  \\item Gauss point sampler\n  \\item \\textbf{State =} deformation gradients\n  \\item \\textbf{Mapping =} deformation mapping\n\n  \\item \\textbf{MATERIAL:}\n    \\begin{itemize}\n    \\item \\textbf{State =} strains\n    \\item \\textbf{Force field}\n    \\item \\textbf{Mapping =} strain mapping\n    \\end{itemize}\n  \\end{itemize}\n\n \\item \\textbf{MASS:}\n    \\begin{itemize}\n    \\item \\textbf{State =} points \n    \\item Mass\n    \\item \\textbf{Mapping =} deformation mapping\n    \\end{itemize}\n \\item \\textbf{COLLISION:}\n    \\begin{itemize}\n    \\item \\textbf{State =} points \n    \\item \\textbf{Mapping =} deformation mapping\n    \\end{itemize}\n \\item \\textbf{VISU:}\n    \\begin{itemize}\n    \\item \\textbf{State =} points \n    \\item \\textbf{Mapping =} deformation mapping\n    \\end{itemize}\n\n\\end{itemize}\n\n\n\\bibliographystyle{plain}\n\\bibliography{Flexible}\n", "meta": {"hexsha": "973105d7e2447c9faa7c2f8d1820883231f9175b", "size": 21030, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "applications/plugins/Flexible/doc/flexible_body.tex", "max_stars_repo_name": "sofa-framework/issofa", "max_stars_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_stars_repo_licenses": ["OML"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "applications/plugins/Flexible/doc/flexible_body.tex", "max_issues_repo_name": "sofa-framework/issofa", "max_issues_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_issues_repo_licenses": ["OML"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "applications/plugins/Flexible/doc/flexible_body.tex", "max_forks_repo_name": "sofa-framework/issofa", "max_forks_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_forks_repo_licenses": ["OML"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.8374164811, "max_line_length": 357, "alphanum_fraction": 0.7300998573, "num_tokens": 5497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709251, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.43812184740325516}}
{"text": "\\documentclass{beamer}\n\\usetheme{Madrid}\n\\usepackage[utf8]{inputenc}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator{\\sign}{sign}\n\n\\title[Multi-agent Dynamics in the SFBP]{Multi-agent Dynamics in the Santa Fe Bar Problem}\n\\subtitle{Fairness and efficiency}\n\\author{Angelo Ortiz}\n\\institute{SMA @ LIP6}\n\\date{\\today}\n\n\\begin{document}\n\n\\begin{frame}\n\\titlepage\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Outline}\n\\tableofcontents\n\\end{frame}\n\n\\section{Presentation}\n\\subsection{Definitions}\n\\begin{frame}\n\\frametitle{The SFBP}\n\\begin{block}<1->{Brian Arthur:}\n\\begin{quote}\n $N$ people decide independently each week whether to go to a bar that offers entertainment on a certain night... Space is limited, and the evening is enjoyable if things are not too crowded -- especially, if fewer than $c$ percent of the possible $N$ are present... a person or agent goes if she expects fewer than $c$ percent to show up and stays home if she expects more than $c$ percent to go.\n\\end{quote}\n\\end{block}\n\n\\begin{block}<2->{Only datum}\n Previous attendance numbers.\n\\end{block}\n\n\\begin{alertblock}<3->{Restrictions}\n \\begin{itemize}\n  \\item Choices are unaffected by previous visits.\n  \\item No collusion among the agents.\n \\end{itemize}\n\\end{alertblock}\n\n\\end{frame}\n\n\\begin{frame}\n\\begin{definition}[Fairness]\nAn outcome is said to be fair if agents with identical utilities are equally likely to attend the bar.\n\\end{definition}\n\n\\begin{definition}[Efficiency]\nEfficiency is a measure of collective, or total agent, utility achieved relative to its maximum value.\n\\end{definition}\n\n\\end{frame}\n \n\\subsection{Formalisation}\n\\begin{frame}\n \\frametitle{Formalisation}\n \\begin{block}{Notations}\n \\begin{itemize}\n  \\item Agents: $\\mathcal{N}=\\{1,...,N\\}$, with $n \\in \\mathcal{N}$.\n  \\item The strategy set $S_n = \\{0, 1\\}$ for agent $n$, where 0 denotes \\textit{stay home} while 1, \\textit{go to the bar}.\n  \\item $Q_n$ denotes the set of probability distributions over $S_n$, with mixed strategy $q_n \\in Q_n$.\n  \\item $s_n$ denotes the realisation of agent $n$'s mixed strategy $q_n$; thus, the bar attendance is $s=\\sum_{n \\in \\mathcal{N}} s_n$.\n  \\item Externality : if $s \\leq c$, then $E(s) = 0$; otherwise, $E(s) = 1$.\n  \\item $\\alpha_n \\in ]0,1[$ denotes the value to player $n$ of attending the bar.\n  \\item Payoff function: $\\pi(s_n, s) = s_n (\\alpha_n - E(s))$.\n \\end{itemize}\n\n The agents population is denoted by $\\mathcal{N}=\\{1,...,N\\}$, with $n \\in \\mathcal{N}$.\n \\end{block}\n\\end{frame}\n\n\\section{Efficient outcome}\n\\begin{frame}\n \\frametitle{Fictitious play}\n \\begin{block}{Notations}\n \\begin{itemize}\n  \\item Uncrowdedness time: $a^0 = 0$, $a^{t+1}=a^t + E(s^t)$.\n  \\item Probability that the bar is uncrowded: $p^t = \\frac{a^t}{t}$ \\textcolor{red}{(Convergence)}.\n  \\item Conditioned on its own action: $b^0_n = c^0_n = 0$, $c^{t+1}_n = c^t_n + s^t_n$,  \n  $\\left .b^{t+1}_n = b^t_n + \\begin{cases} \n      1 & \\text{if } s^t \\leq c \\text{ and } s^t_n = 1 \\\\\n      0 & \\text{if } s^t > c \\text{ and } s^t_n = 1\n   \\end{cases} \\right.$, $p^t_n = \\frac{b^t_n}{c^t_n}$.\n   \\item Expected utility at time $t+1$: $\\mathbb{E}^{t+1}[\\pi_n(s_n, s^t)] = \\begin{cases} \n      p^t_n\\alpha_n - (1-p^t_n)(1-\\alpha_n) & \\text{if } s_n = 1 \\\\\n      0 & \\text{otherwise}\n   \\end{cases}$\n   \\item Chosen action at time $t+1$: $s^{t+1}_n \\in \\argmax_{s_n \\in S_n} \\mathbb{E}^{t+1}[\\pi_n(s_n, s^t)]$\n \\end{itemize}\n \\end{block}\n\\end{frame}\n\n\\begin{frame}\n \\begin{block}{Features}\n \\begin{itemize}\n  \\item Rationality.\n  \\item Utility-maximising: bar attendance $\\sim \\frac{c}{N}$.\n  \\item Unfair: personal attendance likelihood converges to either 0 or 1.\n  \\item Pure strategy Nash equilibrium.\n \\end{itemize}\n \\end{block}\n\\end{frame}\n\n\\section{Fair outcome}\n\\begin{frame}\n \\frametitle{No-regret learning}\n \\begin{block}<1->{Notations}\n \\begin{itemize}\n  \\item Cumulative utility through time $t$ with strategy $s_n$: $P^t_n(s_n) = \\sum_{x=1}^t \\pi_n(s_n, s^x)$.\n  \\item Weight assigned to strategy $s_n$ at time $t+1$, for $\\beta > 0$: $q^{t+1}_n(s_n) = \\frac{(1+\\beta)^{P^t_n(s_n)}}{\\sum_{s'_n \\in S_n} (1+\\beta)^{P^t_n(s'_n)}}$.\n \\end{itemize}\n \\end{block}\n \n \\begin{block}<2->{Features}\n \\begin{itemize}\n  \\item Bounded rationality.\n  \\item Fair: personal attendance $\\sim \\frac{c}{N}$.\n  \\item Inefficient: collective utility near 0.\n  \\item Mixed strategy Nash equilibrium.\n \\end{itemize}\n \\end{block}\n\\end{frame}\n\n\\section{Fair \\& efficient mechanism}\n\\begin{frame}\n \\frametitle{Q-learning}\n \\begin{block}<1->{Notations}\n \\begin{itemize}\n  \\item Utility function, for the bar attendance $\\lambda \\in \\mathbb{N}$ and $\\sigma_i \\geq 0$: $u_i(\\lambda) = \\max\\{1-\\frac{(\\lambda - \\mu_i)^2}{\\sigma_i^2}, 0\\}$, where $\\mu_i$ is agent $i$'s utility-peak bar attendance.\n  \\item Taxation scheme: charge people attending the bar an entrance fee, and distribute this sum among those that stayed home.\n  \\item \\textit{Derivative-following} approach: $f_{t+1} = f_t+\\gamma[\\sign(f_t-f_{t-1})\\sign(u_t-u_{t-1})]$, where $u_t$ is the agents' average utility at time $t$.\n \\end{itemize}\n \\end{block}\n \n \\begin{block}<2->{Features}\n \\begin{itemize}\n  \\item Bounded rationality.\n  \\item Fee and average utility per agent converge to about 0.5.\n  \\item Fair and approximately efficient.\n \\end{itemize}\n \\end{block}\n\\end{frame}\n\n\\section{Some results \\& foreseeable work}\n\\begin{frame}\n\\frametitle{Some results \\& foreseeable work}\n\\begin{definition}[Predictivity]\n Given $\\epsilon > 0$, a belief-based learning algorithm is said to be $\\epsilon$-predictive for player $n$ iff it generates a sequence of probabilistic beliefs $\\{p^t_n\\}$ s.t.: \n \\[\n \\lim_{t \\to \\infty} |p^t_n - p^t_0| < \\epsilon.\n \\]\n\\end{definition}\n\n\\begin{block}{Rationality vs Learning}\n Rationality precludes learning.\n\\end{block}\n\\end{frame}\n\n\\begin{frame}\n\\begin{block}{Envisioned tasks}\n \\begin{itemize}\n  \\item Implement the aforementioned algorithms and replicate the results.\n  \\item Analyse a variable-utility setup.\n  \\item Work with other fairness and/or efficiency definitions.\n  \\item (Optimise the setup with heterogeneous agents.)\n  \\item (Transpose to the two-bar problem setup.)\n \\end{itemize}\n\n\\end{block}\n\\end{frame}\n\n\\section*{References}\n\\begin{frame}\n\\frametitle{References}\n\\begin{enumerate}\n \\item W.B. Arthur. Inductive reasoning and bounded rationality. Complexity in Economic Theory, 84(2):406–411,\n1994.\n\\item A. Greenwald, A. Jafari, G. Ercal, and D. Gondek. On no-regret learning, Nash equilibrium, and fictitious play.\nIn Proceedings of Eighteenth International Conference on Machine Learning, pages 226–233, June 2001.\n\\item A. Greenwald, B. Mishra, and R. Parikh. The Santa Fe bar problem revisited: Theoretical and practical implica-\ntions. Presented at Stonybrook Festival on Game Theory: Interactive Dynamics and Learning, July 1998.\n\\item Farago, Julie \\& Greenwald, Amy \\& Hall, Keith. (2003). Fair and Efficient Solutions to the Santa Fe Bar Problem. \n\\end{enumerate}\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "0467fddeaa43de55fe198f716a717a531d1412f5", "size": 7036, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentations/june_18/Initial_presentation.tex", "max_stars_repo_name": "angelo-ortiz/Internship-on-the-SFBP", "max_stars_repo_head_hexsha": "e2d79e95ac936fe4194a0c05bc3dd3fdb854cb74", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentations/june_18/Initial_presentation.tex", "max_issues_repo_name": "angelo-ortiz/Internship-on-the-SFBP", "max_issues_repo_head_hexsha": "e2d79e95ac936fe4194a0c05bc3dd3fdb854cb74", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentations/june_18/Initial_presentation.tex", "max_forks_repo_name": "angelo-ortiz/Internship-on-the-SFBP", "max_forks_repo_head_hexsha": "e2d79e95ac936fe4194a0c05bc3dd3fdb854cb74", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4559585492, "max_line_length": 397, "alphanum_fraction": 0.7009664582, "num_tokens": 2284, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.43811795693743016}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\n\\onlyinsubfile{\n\\title{NeuroData SIMPLEX Report: Subfile}\n}\n\n\\begin{document}\n\\onlyinsubfile{\n\\maketitle\n\\thispagestyle{empty}\n\nThe following report documents the progress made by the labs of Randal~Burns and Joshua~T.~Vogelstein at Johns Hopkins University towards goals set by the DARPA SIMPLEX grant.\n\n%%%% Table of Contents\n\\tableofcontents\n\n%%%% Publications\n\\bibliographystyle{IEEEtran}\n\\begin{spacing}{0.5}\n\\section*{Publications, Presentations, and Talks}\n%\\vspace{-20pt}\n\\nocite{*}\n{\\footnotesize\t\\bibliography{simplex}}\n\\end{spacing}\n%%%% End Publications\n}\n\n\\subsection{Nonparametric Network Dependence Test} \n\nDeciphering the association between network structures and corresponding nodal attributes of interest is a core problem in network science. We propose a new nonparametric procedure for testing dependence between network topology and nodal attributes, via diffusion maps and \\texttt{MGC}. Specifically, under an exchangeable graph, we verify that the diffusion maps provide a set of conditionally independent multivariate coordinates for the nodes, which can be combined with \\texttt{MGC} (or in general, any distance-based correlation measures) to yield consistent statistic for network dependence testing. In simulation, the new approach achieves superior testing performance under a variety of common network models than existing benchmarks. The diffusion maps provides a robust metric compared to adjacency matrix or geodesic distance, while \\texttt{MGC} can better capture nonlinear dependencies, with their combined advantages shown in Figure~\\ref{fig:threeSBM}.  \n\n\\begin{figure}[h!]\n\\begin{cframed}\n\t\t\\centering\n\t\t\\includegraphics[width=0.6\\textwidth]{../../figs/ThreeSBM.png}\n\t\t\\caption{Power comparison for all possible combinations of metrics and correlation measure, under the stochastic block model with three blocks. \\texttt{MGC} with the diffusion maps (DM) yields the best power, comparing to using other metrics like adjacency matrix (AM), latent factors (LF), and other test statistics like distance correlation (mcorr), Heller-Heller-Gorfine (HHG) test, or Fosdick and Hoff (FH) method.}\n\t\t\\label{fig:threeSBM}\n\t\t\\end{cframed}\n\\end{figure}\n\n%In order to show that \\texttt{MGC} combined with diffusion maps as a network metrics perform better even in the case arbitrary noisy is added to edges or the attributes in real data, we are doing an experiment on brain network with physical locations as nodal attributes. Our proposed method not only detects the dependence between network topology and nodal attributes but also helps us to reveal possibly diverse dependence patterns through multiscale correlation maps or multiscale statistics as a function of diffusion time.\n\nThis month we made significant progress in writing the manuscript and improving the exposition. The current draft was submitted to ASA Nonparametric Statistics Section Student Paper Awards, and we are notified as finalists for awards and special presentation section in the Joint Statistical Meeting this year. \n\n\\end{document}\n", "meta": {"hexsha": "4b30de6eb0a8a0dce8aa19ea5865bb26048c65ef", "size": 3171, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2017-01/multiscaleNetworkTest.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2017-01/multiscaleNetworkTest.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2017-01/multiscaleNetworkTest.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.0625, "max_line_length": 969, "alphanum_fraction": 0.8054241564, "num_tokens": 713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6654105521116445, "lm_q1q2_score": 0.4381179525687185}}
{"text": "\\section{Parameters Summary}\\label{app:parameters}\n\nAll the parameters used in this manuscript alongside their explanation are\ngiven by Table~\\ref{table:parameters_summary}.\n\n\\begin{table}[!htbp]\n    \\begin{center}\n    \\resizebox{.7\\textwidth}{!}{\n    \\begin{tabular}{ll}\n    \\toprule\nFeature & Explanation \\\\\n \\midrule\nSSE                       & A measure of how far a strategy is from extortionate behaviour defined in~\\cite{Knight2019}. \\\\\n$C_{\\text{max}}$          & The biggest cooperating rate in the tournament. \\\\\n$C_{\\text{min}}$          & The smallest cooperating rate in the tournament. \\\\\n$C_{\\text{median}}$       & The median cooperating rate in the tournament. \\\\\n$C_{\\text{mean}}$         & The mean cooperating rate in the tournament. \\\\\n$C_r$ / $C_{\\text{max}}$    & A strategy's cooperating rate divided by the maximum cooperating rate in the tournament. \\\\\n$C_{\\text{min}}$ / $C_r$    & The minimum in the tournament divided by a strategy's cooperating rate. \\\\\n$C_r$ / $C_{\\text{median}}$ & A strategy's cooperating rate divided by the median cooperating rate in the tournament. \\\\\n$C_r$ / $C_{\\text{mean}}$   & A strategy's cooperating rate divided by the mean cooperating rate in the tournament. \\\\\n$C_r$                       & The cooperating rate of a strategy. \\\\\n$CC$ to $C$ rate            & The probability a strategy will cooperate after a mutual cooperation. \\\\\n$CD$ to $C$ rate            & The probability a strategy will cooperate after being betrayed by the opponent. \\\\\n$DC$ to $C$ rate            & The probability a strategy will cooperate after betraying the opponent. \\\\\n$DD$ to $C$ rate            & The probability a strategy will cooperate after a mutual defection. \\\\\n$p_n$                       & The probability of a player's action being flipped at each interaction. \\\\\n$n$                         & The number of turns in a match. \\\\\n$p_e$                       & The probability of a match ending in the next turn. \\\\\n$N$                         & The number of strategies in the tournament. \\\\\n$k$                         & The number that a given tournament is repeated. \\\\\n    \\bottomrule\n        \\end{tabular}}\n    \\end{center}\n    \\caption{The features which are included in the performance evaluation analysis.}\\label{table:parameters_summary}\n\\end{table}\n", "meta": {"hexsha": "adc50e01ff6466edfadf1a15c419c75b34be26c9", "size": 2314, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/parameters_section.tex", "max_stars_repo_name": "Nikoleta-v3/meta-analysis-of-prisoners-dilemma-tournaments", "max_stars_repo_head_hexsha": "0e7c9949d996cf3822072321b603fcff707e97d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/parameters_section.tex", "max_issues_repo_name": "Nikoleta-v3/meta-analysis-of-prisoners-dilemma-tournaments", "max_issues_repo_head_hexsha": "0e7c9949d996cf3822072321b603fcff707e97d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2020-03-29T14:42:49.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-08T11:23:19.000Z", "max_forks_repo_path": "paper/parameters_section.tex", "max_forks_repo_name": "Nikoleta-v3/meta-analysis-of-prisoners-dilemma-tournaments", "max_forks_repo_head_hexsha": "0e7c9949d996cf3822072321b603fcff707e97d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-03-30T08:13:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-30T08:13:32.000Z", "avg_line_length": 62.5405405405, "max_line_length": 123, "alphanum_fraction": 0.6443388073, "num_tokens": 548, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4381179525687184}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n      \\subsection{getPlotDistr\\_cp.m}\n\n\\begin{par}\n\\textbf{Summary:} Compute means and covariances of the Cartesian coordinates of the tips both the inner and outer pendulum assuming that the joint state $x$ of the cart-double-pendulum system is Gaussian, i.e., $x\\sim N(m, s)$\n\\end{par} \\vspace{1em}\n\n\\begin{verbatim}   function [M, S] = getPlotDistr_cp(m, s, ell)\\end{verbatim}\n    \\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}m       mean of full state                                    [4 x 1]\ns       covariance of full state                              [4 x 4]\nell     length of pendulum\\end{verbatim}\n\\begin{verbatim}Note: this code assumes that the following order of the state:\n       1: cart pos.,\n       2: cart vel.,\n       3: pendulum angular velocity,\n       4: pendulum angle\\end{verbatim}\n\\begin{par}\n\\textbf{Output arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}M      mean of tip of pendulum                               [2 x 1]\nS      covariance of tip of pendulum                         [2 x 2]\\end{verbatim}\n\\begin{par}\nCopyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.\n\\end{par} \\vspace{1em}\n\\begin{par}\nLast modification: 2013-03-27\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{High-Level Steps} \n\n\\begin{enumerate}\n\\setlength{\\itemsep}{-1ex}\n   \\item Augment input distribution to complex angle representation\n   \\item Compute means of tips of pendulums (in Cartesian coordinates)\n   \\item Compute covariances of tips of pendulums (in Cartesian coordinates)\n\\end{enumerate}\n\n\\begin{lstlisting}\nfunction [M, S] = getPlotDistr_cp(m, s, ell)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\n% 1. Augment input distribution to complex angle representation\n[m1 s1 c1] = gTrig(m,s,4,ell); % map input distribution through sin/cos\nm1 = [m; m1];        % mean of joint\nc1 = s*c1;           % cross-covariance between input and prediction\ns1 = [s c1; c1' s1]; % covariance of joint\n\n% 2. Compute means of tips of pendulums (in Cartesian coordinates)\nM = [m1(1)+m1(5); -m1(6)];\n\n% 3. Compute covariances of tips of pendulums (in Cartesian coordinates)\ns11 = s1(1,1) + s1(5,5) + s1(1,5) + s1(5,1); % x+l sin(theta)\ns22 = s1(6,6); % -l*cos(theta)\ns12 = -(s1(1,6)+s1(5,6)); % cov(x+l*sin(th), -l*cos(th)\n\nS = [s11 s12; s12' s22];\ntry\n  chol(S);\ncatch\n  warning('matrix S not pos.def. (getPlotDistr)');\n  S = S + (1e-6 - min(eig(S)))*eye(2);\nend\n\\end{lstlisting}\n", "meta": {"hexsha": "41385cd80c3ab37395759c7d876fc81769d4a8a2", "size": 2604, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/getPlotDistr_cp.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/getPlotDistr_cp.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/getPlotDistr_cp.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 32.55, "max_line_length": 226, "alphanum_fraction": 0.653609831, "num_tokens": 827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.438095210342548}}
{"text": "\\documentclass[11pt,answers]{exam}\n\n% Preamble % (fold)\n\n\\usepackage[paper=letterpaper,margin=.75in,twoside=false,includehead]{geometry}\n\n\\usepackage{amsfonts,amsmath,amsthm,amssymb} \n\\usepackage{enumerate}\n\\usepackage{graphicx}\n\n\\usepackage{paralist}\n\\usepackage{multicol}\n\\usepackage{bm}\n\n\n\\let\\svthefootnote\\thefootnote\n\n\\newtheorem*{thm}{Theorem}\n\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\E}{\\mathbb{E}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\cP}{\\mathcal{P}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\e}{\\varepsilon}\n\n\n%\\printsolutions\n\n\\title{Communicating in Mathematics (MTH 210) Exam 2}\n\\date{April 8, 2020}\n\n\n\\begin{document}\n\n\n\n\\maketitle\n\n\\section*{Instructions}  \n\n\n\n\\noindent The following are very important, please read carefully!\n\\begin{itemize}\n\\item This exam must be uploaded to Blackboard by \\textbf{April 9 at 5PM}. Please plan to try to upload before then so you can get help if there are issues.\n\\item Your exam should be scanned as a single PDF (with the app of your choosing) in black and white. Other file formats or color scans are sometimes too large for Blackboard to accept, and having to flip through multiple files makes grading difficult for Dr. Keough. You do not want to make grading difficult for your professors :)\n\\item You can write your answers on whatever paper you have, or print the exam if you've got a printer. \n\\item You do not need to write down the whole question, but you should do the following:\n\t\\begin{itemize}\n\t\\item Start each section on a new page.\n\t\\item Clearly label at the top of \\emph{every} page the section from which the problems are from.\n\t\\item Number each problem as it is numbered on the exam.\n\t\\end{itemize}\n\\item You may use your notes and your textbook for this exam. However, you may NOT use any other resources, including, but not limited to, your classmates, friends you know in other sections, Blackboard, the internet, your mom, your dog, etc. Violation of this policy will be penalized and could result in failure of the course.\n\\item There is no time limit on the exam, and you do not have to take it in one sitting. I do not expect this to take you more than 2 hours though!\n\\end{itemize} \n\n\\begin{center}\n\\textbf{If you aren't sure what to do, take a deep breath and just show me what you know. You'll be able to revise!}\n\\end{center}\n\n\n\n\n\\begin{center}\n\n\n\\begin{tabular}{|c|c|c|}\n\\hline\nSection &Score\\\\\n\\hline\nSets &\\\\\n&\\\\\n\\hline\nFunctions &\\\\\n&\\\\\n\\hline\nWhich Proof Technique &\\\\\n&\\\\\n\\hline\nProof Section &\\\\\n&\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\n\\pagebreak\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Sets}\n\n\\begin{questions}\n\n\n\\question This question is about definitions (and their negations) related to sets.  Describe precisely what you need to prove if you were trying to prove the following.\n\nLet $A$ and $B$ be subsets of some universal set $U$.\n\n\\begin{parts}\n\\part   If I needed to prove that $A\\subset B$ I would need to... \n\\vspace{.5in}\n\\part  If I needed to prove that $A= B$ I would need to...\n\\vspace{.5in}\n\\part If I needed to prove that $x\\notin A \\cap B$ I would need to...\n\\vspace{.5in}\n\\part  If I needed to prove that $x\\in A - B$ I would need to...\n\\vspace{.5in}\n\\end{parts}\n\n\\question Let $U = \\{x\\in\\Z : 1\\leq x \\leq 20\\}$. Define $A = \\{1,3,5,7,9,11,13,15,17,19\\}$, $B = \\{7,10,13\\}$, and $C = \\{x,y\\}$. Make sure to use proper notation in each of the following!\n\n\\begin{parts}\n\\part Show $B\\not\\subseteq A$.\n\\vfill\n\\part Find $\\mathcal{P}(C)$.\n\\vfill\n\\part Find $B\\times C$.\n\\vfill\n\\part Find $|A\\cup B|$, that is, the cardinality of $A\\cup B$.\n\\vfill\n\\end{parts}\n\n\\end{questions}\n\\newpage\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Functions}\n\n\\begin{questions}\n\n\\question \n\nLet $f: \\R\\to\\R$ be defined by $f(x) = \\sin(x)$. (You may use graphing software to graph this.)\n\t\n\\begin{parts}\n\\part Explain why $f$ is a function. You should state the definition of function in your answer.\n\\vfill\n\\vfill\n\\part What is the codomain of $f$?\n\\vspace{.2in}\n\\part Use the word preimage in a sentence about the function $f$.\n\\vfill\n\\part Is $f$ an injection? Justify your answer using the definition of injection.\n\\vfill\n\\part Is $f$ a surjection? Justify your answer using the definition of surjection.\n\\vfill\n\n%\\part Is $f$ a bijection? Justify your answer using the definition of bijection.\n%\\vfill\n\\end{parts}\n\n\\question Let $A = \\{1,2,3\\}$ and $B = \\{x,w\\}$. \n Give an example of a function $f:A\\to B$ that is a bijection or explain why no such example exists.\n\\vfill\n\n\n\\end{questions}\n\n\\newpage\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Which Proof Technique When?}\n\nOver the next 2 pages are 4 theorem statements with which you will need to do 3 things:\n\t\\begin{itemize}\n\t\\item State which proof technique you would use. Your options are: direct, contrapositive, contradiction, cases, and induction.\n\t\\item Explain your choice of proof technique.\\footnote{As a reminder - for the second bullet you should be specific - what was the key? Something about the hypothesis or conclusion?\n}\n\t\\item Outline the steps in a proof using the proof technique (but you should not actually attempt to prove the statement). You should say what you would assume and what you would try to prove. \\footnote{In the third bullet you need to be detailed - for a proof by cases, what cases would you use? For a proof by induction, what steps would you use (and what's $P(k)$?)? In each case you need to be as specific as possible - do not say ``I would assume the negation\", say what the negation actually is. }\n\t \n\t\\end{itemize}\n\\emph{You should NOT actually prove any of the following theorems.}\n\n\\begin{questions}\n\\question Let $f_n$ be the $n^{th}$ Fibonacci number. For all natural numbers $n$, $3\\mid f_{4n}$.\n\n\\vfill\n\n\\question For each integer $a$, $a^3 \\equiv a \\pmod{3}$.\n\\vfill\n\\newpage\n\n%\\question If $A = \\{x\\in\\Z : x\\equiv 0 \\pmod{2}\\}$ and $B = \\{y\\in \\Z: y \\equiv 0\\pmod{4}\\}$ then $A\\subseteq B$.\n%\\vfill\n\\question For all integers $a$, if $a^2\\not\\equiv  0\\pmod{3}$ then $a\\not\\equiv 0\\pmod{3}$.\n\\vfill\n\n\\question For all $x,y\\in \\mathbb{R}$, and for all integers $a$ and $b$ with $b\\neq 0$, if $x$ is rational and $y$ is irrational, then $ax+by$ is irrational.\n\\vfill\n\n\\end{questions}\n\n\\newpage\n\n\\section{Proofs}\n\nIMPORTANT DIRECTIONS: You need to do both of the following proofs. Each proof needs to be written according to our writing guidelines.  Don't forget to include a theorem statement (which should always be declarative sentences)! The next page is for the first proof and the page after is for the second proof. Please include any scratch work you have in the PDF, but label it ``scratch work\".\n\n\\begin{enumerate}\n\\item Prove the following theorem. The proof needs to be written according to our writing guidelines.\n\n\\begin{center}\nFor each $n\\in\\N$, $5\\mid n^5+4n$.\n\\end{center}\nIt will probably be helpful for you to know that \n\\[(k+1)^5 = k^5+5k^4+10k^3+10k^2+5k+1.\\]\nYou can use this without showing work for it.\n\n\n\\item Determine the relationship between the sets $A$ and $B$ and prove it. You should write your proof according to our writing guidelines.\n\n\\begin{center}\nLet $A = \\{x\\in\\Z : x\\equiv 3 \\pmod{6} \\}$ and $B = \\{ x\\in \\Z : 4\\mid x\\}$ . Determine a relationship between the sets $A$ and $B$, state the relationship as a theorem, and prove it.\n\\end{center}\n\n\n\n\n\\end{enumerate}\n\n\\newpage\n\n\\emph{If you printed the exam you can write your proof for  on this page. }\n\n\n\\newpage\n\n\\emph{If you printed the exam you can write your proof for 2 on this page. }\n\n\\end{document}\n", "meta": {"hexsha": "23102fe3b4a9b22c9a128ef86d25ef8a5c4c02c7", "size": 7529, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "from LDK/5-Exams/Exam2/210W20Exam2.tex", "max_stars_repo_name": "mkjanssen/discrete", "max_stars_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "from LDK/5-Exams/Exam2/210W20Exam2.tex", "max_issues_repo_name": "mkjanssen/discrete", "max_issues_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "from LDK/5-Exams/Exam2/210W20Exam2.tex", "max_forks_repo_name": "mkjanssen/discrete", "max_forks_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.7679324895, "max_line_length": 504, "alphanum_fraction": 0.7123123921, "num_tokens": 2248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7956580976404297, "lm_q1q2_score": 0.43809520900857807}}
{"text": "The main interest of interactive simulation is that the user can modify the course of the computations in real-time.\nThis is essential for surgical simulation : during a training procedure, when a virtual medical instrument comes into contact with some models of a soft-tissue, \\emph{instantaneous} deformations must be computed.\nThis visual feedback of the contact can be enhanced by haptic rendering so that the surgeon can really \"feel\" the contact.\n\nThere are two main issues for a platform like SOFA for providing haptic: The first is that haptic forces need to be computed at $1kHz$ whereas real-time visual feedback (without haptic) is obtained at $30Hz$. The second is that haptic feedback can add artificially some energy inside the simulation and can create instabilities, if the control is not \\emph{passive}. \n\nThus two different approaches are currently implemented into SOFA. The first one is the \\emph{Virtual Coupling} technique and the other, more advanced, allows for rendering the constraints presented in section \\ref{lm}.\n\n\n\n\\section{Virtual Coupling} Plugging of a haptic device is bidirectional: the user applies some motions or some forces on the device and this device, in return, applies forces and/or motions to the user.\nThe majority of the haptic devices propose a \\emph{Impedance} coupling: the position of the device is provided by the API and this API asks for force values from the application.\nA very simple scheme of coupling, presented in Fig\\ref{fig:haptic1}, could have been used.\nIn this \\emph{Direct coupling} case, the simulation would play the role of a controller in an open loop. \n\n\\begin{figure}\n\\centering\n \\includegraphics[width=0.7\\linewidth]{haptic1.png}\n \\caption{Direct coupling}\n \\label{fig:haptic1}\n\\end{figure}\n\nSuch design is not suitable when stable and robust haptic feedback on a virtual environment is desired. Indeed some combination of the environment impedance and human user reactions can destabilize the system \\cite{Adams99}. \nTo avoid this, a virtual mechanical coupling is set. It corresponds to the use of a damped-stiffness between the position measured on the device and the simulated position in the virtual environment (see Fig\\ref{fig:haptic2}). If very stiff constraints are being simulated then, the stiffness perceived by the user will not be infinite but will correspond to the stiffness of this virtual coupling. \nHence, a compromise between stability and performance must be found by tuning the stiffness value of the coupling.\n\n\\begin{figure}\n\\centering\n \\includegraphics[width=\\linewidth]{haptic2.png}\n \\caption{Virtual coupling technique. A 6 DoFs Damped spring is placed between the haptic loop and the simulation.}\n \\label{fig:haptic2}\n\\end{figure}\n\nThe damped spring is simulated two times. One time in the haptic loop and one time in the simulation loop. \nIf the two loops are synchronized, then the result is the same. But it can also be used in asynchronous mode: fast update of the haptic loop and low rates in the simulation.\nIn such case, the haptic feedback remains stable but the delay between the two loop is creating an artificial damping.\nThere is an option to cancel this artificial damping if no contact is detected in the simulation. However, this option can create a sensation of sticking contacts. \nThe main advantage of the virtual coupling technique is that it can be easily employed with every simulation of SOFA. The main drawback is that the haptic rendering is not transparent.\n \n\\section{Constraint-based rendering} An innovative way of dealing with haptic rendering for medical simulation has been proposed in the context of SOFA (see\\footnote{The implementation of  \\cite{Saupin08} is available in open-source, for the implementation of \\cite{Peterlik11}, please contact: christian.duriez@inria.fr }  \\cite{Saupin08} and \\cite{Peterlik11}). \nThe approach deals with the mechanical interactions using appropriate force and/or motion transmission models named \\emph{compliant mechanisms} (see Fig\\ref{fig:haptic3}). \nThese mechanisms are formulated as a constraint-based problem (like presented in section \\ref{lm}) that is solved in two separate threads running at different frequencies. \nThe first thread processes the whole simulation including the soft-tissue deformations, whereas the second one only deals with computer haptics. \nWith this approach, it is possible to describe the specific behavior of various medical devices while relying on a unified method for solving the mechanical interactions between deformable objects and haptic rendering.  \n\\begin{figure}\n\\centering\n \\includegraphics[width=\\linewidth]{haptic3.png}\n \\caption{Compliant mechanisms technique. The simulation shares the mechanical compliance of the objects and the constraints between them. The constraint response is being computed at low rate within the simulation and at high rates within a separate haptic thread. A 6 DoFs Damped spring is still used to coupled the position of the device to its position in the simulation}\n \\label{fig:haptic3}\n\\end{figure}\n\n\\section{How to use it in SOFA ?}\nPlease see the web page: http://wiki.sofa-framework.org/wiki/Haptic  and use the tutorial \"dentistry\".\n\n", "meta": {"hexsha": "26940d5e556dfd773cbd044d27aa4f724f5476c1", "size": 5189, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/haptic/hapticRendering.tex", "max_stars_repo_name": "sofa-framework/issofa", "max_stars_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_stars_repo_licenses": ["OML"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/haptic/hapticRendering.tex", "max_issues_repo_name": "sofa-framework/issofa", "max_issues_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_issues_repo_licenses": ["OML"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/haptic/hapticRendering.tex", "max_forks_repo_name": "sofa-framework/issofa", "max_forks_repo_head_hexsha": "94855f488465bc3ed41223cbde987581dfca5389", "max_forks_repo_licenses": ["OML"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.3454545455, "max_line_length": 399, "alphanum_fraction": 0.8043939102, "num_tokens": 1125, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.43808537434722866}}
{"text": "\\section{Conclusions and Future Work}\nThe goal of this research is to find out what the best move is in the casino game Blackjack with each hand value and to confirm the thought that the dealer always wins more games than the player. \\\\\nFirst the total number of wins: The simulation of Blackjack gives an accurate representation of the game. After playing one million games in this simulation, it shows that the dealer indeed wins more games than the player. 22 percent more games to be exact in the case of this simulation. So this proves the hypothesis, in Blackjack, the dealer wins more games than the player. \\\\\n\\\\\nThe best move for the player is the move with the highest probability to win. For the values bellow 12 and over 17 this is clear, draw if under 12 and pass if over 17. Between these values these choice gets more difficult. The results shows for 12 and 13 a clear advantage to draw a card and for 16 and 17 a clear advantage by passing. But for 14 and 15 things get very close. On the long run, one should draw a card with a value of 14 and pass at a value of 15. So in short:\n\\begin{itemize}\n    \\item < 12: Draw\n    \\item 12: Draw\n    \\item 13: Draw\n    \\item 14: Draw\n    \\item 15: Pass\n    \\item 16: Pass\n    \\item 17: Pass\n    \\item > 17: Pass\n\\end{itemize}\nThis paper is based on generation one time, one million games of Blackjack. To further proof the working of this experiment in more depth, one could generate multiple sets of one million games of Blackjack and compare the differences between these sets. Expected is that the differences between these sets should be minimal. The only differences in the data will be coincidences, which should be canceled out by the large size of the dataset.\n\n", "meta": {"hexsha": "29d0eebe18032d4406454d34cb3aaeaf763df170", "size": 1727, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/sec/5_Conclusion.tex", "max_stars_repo_name": "obin1000/Black-Jack-DataResearch", "max_stars_repo_head_hexsha": "3b29aecf8b7e5b782f3c1042c8cf49d45005ec74", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-08T19:11:58.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-08T19:11:58.000Z", "max_issues_repo_path": "Paper/sec/5_Conclusion.tex", "max_issues_repo_name": "obin1000/Black-Jack-DataResearch", "max_issues_repo_head_hexsha": "3b29aecf8b7e5b782f3c1042c8cf49d45005ec74", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/sec/5_Conclusion.tex", "max_forks_repo_name": "obin1000/Black-Jack-DataResearch", "max_forks_repo_head_hexsha": "3b29aecf8b7e5b782f3c1042c8cf49d45005ec74", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.9444444444, "max_line_length": 475, "alphanum_fraction": 0.7666473654, "num_tokens": 408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.4380853630759724}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\lstset{gobble=2}\n\n\\begin{document}\n\n% =================================================================================================\n% create checkpoint file\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   import cdblib\n   checkpoint_file = 'tests/semantic/output/geodesic-ivp.json'\n   cdblib.create (checkpoint_file)\n   checkpoint = []\n\\end{cadabra}\n\\egroup\n\n% =================================================================================================\n\\section*{Geodesic IVP}\n\nOur game here is to find the solution of\n\\begin{align*}\n   0 = \\frac{d^2 x^{a}}{ds^2} + \\Gamma^{a}_{bc}(x) \\frac{dx^b}{ds} \\frac{dx^c}{ds}\n\\end{align*}\nsubject to the initial conditions $x^{a}(s) = x^a$ and $dx^a(s)/ds={\\Dot x}^{a}$ at $s=0$.\n\n% =================================================================================================\n\\section*{Algorithm}\n\nBy successive differentiation of the above equation we can compute\n\\begin{align*}\n   \\frac{d^n x^{a}}{ds^n} = -\\Gamma^{a}_{\\udn}\\frac{dx^{\\udn}}{ds}\n\\end{align*}\nat $s=0$ for $n=2,3,4,\\dotsc$. The $\\Gamma^{a}_{\\udn}$ are the \\emph{generalised connections}.\n\nWe can then construct the Taylor series solution for $x^{a}(s)$\n\\begin{align*}\n   x^a(s) = x^a + s {\\Dot x}^a - \\sum_{k=2}^\\infty\\>\\frac{s^{k}}{k!} \\Gamma^{a}_{\\udk}{\\Dot x}^{\\udk}\n\\end{align*}\n\n\\clearpage\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   \\nabla{#}::Derivative.\n\n   import cdblib\n\n   # change signs to account for - sign in front of the sum for x^a(s), see above preamble\n\n   def flip_sign (obj):\n       return Ex(0) - obj\n\n   sterm21 = flip_sign (cdblib.get ('genGamma01','genGamma.json'))\n   sterm22 = flip_sign (cdblib.get ('genGamma02','genGamma.json'))\n   sterm23 = flip_sign (cdblib.get ('genGamma03','genGamma.json'))\n   sterm24 = flip_sign (cdblib.get ('genGamma04','genGamma.json'))\n\n   sterm31 = flip_sign (cdblib.get ('genGamma11','genGamma.json'))\n   sterm32 = flip_sign (cdblib.get ('genGamma12','genGamma.json'))\n   sterm33 = flip_sign (cdblib.get ('genGamma13','genGamma.json'))\n\n   sterm41 = flip_sign (cdblib.get ('genGamma21','genGamma.json'))\n   sterm42 = flip_sign (cdblib.get ('genGamma22','genGamma.json'))\n\n   sterm51 = flip_sign (cdblib.get ('genGamma31','genGamma.json'))\n\n   sterm2 := @(sterm21) + @(sterm22) + @(sterm23) + @(sterm24).  # cdb (sterm2.000,sterm2)\n   sterm3 := @(sterm31) + @(sterm32) + @(sterm33).               # cdb (sterm3.000,sterm3)\n   sterm4 := @(sterm41) + @(sterm42).                            # cdb (sterm4.000,sterm4)\n   sterm5 := @(sterm51).                                         # cdb (sterm5.000,sterm5)\n\n   factor_out (sterm2,$A^{a?}$)                                  # cdb (sterm2.001,sterm2)\n   factor_out (sterm3,$A^{a?}$)                                  # cdb (sterm3.001,sterm3)\n   factor_out (sterm4,$A^{a?}$)                                  # cdb (sterm4.001,sterm4)\n   factor_out (sterm5,$A^{a?}$)                                  # cdb (sterm5.001,sterm5)\n\n   sterm2 := 360 @(sterm2).\n   sterm3 := 360 @(sterm3).\n   sterm4 :=  90 @(sterm4).\n   sterm5 :=   3 @(sterm5).\n\n   substitute (sterm2,$A^{a}->1$)                                # cdb (sterm2.002,sterm2)\n   substitute (sterm3,$A^{a}->1$)                                # cdb (sterm3.002,sterm3)\n   substitute (sterm4,$A^{a}->1$)                                # cdb (sterm4.002,sterm4)\n   substitute (sterm5,$A^{a}->1$)                                # cdb (sterm5.002,sterm5)\n\n\\end{cadabra}\n\n% =================================================================================================\n% the remaining code is just for pretty printing\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The geodesic ivp}\n\n\\begin{align*}\n   x^{a}(s) = x^{a}\n            + s {\\dot{x}^a}\n            + \\frac{s^2}{2!} {\\dot{x}^b} {\\dot{x}^c} A^{a}_{bc}\n            + \\frac{s^3}{3!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} A^{a}_{bcd}\n            + \\frac{s^4}{4!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} {\\dot{x}^e} A^{a}_{bcde}\n            + \\frac{s^5}{5!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} {\\dot{x}^e} {\\dot{x}^f} A^{a}_{bcdef}\n            + \\dotsb\n\\end{align*}\n\\begin{dgroup*}\n   \\begin{dmath*} 360 A^{a}_{bc} = \\cdb{sterm2.002} \\end{dmath*}\n   \\begin{dmath*} 360 A^{a}_{bcd} = \\cdb{sterm3.002} \\end{dmath*}\n   \\begin{dmath*}  90 A^{a}_{bcde} = \\cdb{sterm4.002} \\end{dmath*}\n   \\begin{dmath*}   3 A^{a}_{bcdef} = \\cdb{sterm5.002} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n% export selected objects, these will later be imported into a library\n% these are the objects that will appear in the paper\n\n\\begin{cadabra}\n   sterm2short := @(sterm21) + @(sterm22).             # cdb (sterm2.short.001,sterm2short)\n   sterm3short := @(sterm31).                          # cdb (sterm3.short.001,sterm3short)\n   sterm2shortscaled := 12 @(sterm2short).             # cdb (sterm2.short.scaled.002,sterm2shortscaled)\n   sterm3shortscaled :=  2 @(sterm3short).             # cdb (sterm3.short.scaled.002,sterm3shortscaled)\n\n   substitute (sterm2shortscaled,$A^{a}->1$)           # cdb (sterm2.short.scaled.003,sterm2shortscaled)\n   substitute (sterm3shortscaled,$A^{a}->1$)           # cdb (sterm3.short.scaled.003,sterm3shortscaled)\n\n   cdblib.create ('geodesic-ivp.export')\n\n   # 4th order ivp terms scaled\n   cdblib.put ('ivp42',sterm2shortscaled,'geodesic-ivp.export')\n   cdblib.put ('ivp43',sterm3shortscaled,'geodesic-ivp.export')\n\n   # 6th order ivp terms scaled\n   cdblib.put ('ivp62',sterm2,'geodesic-ivp.export')\n   cdblib.put ('ivp63',sterm3,'geodesic-ivp.export')\n   cdblib.put ('ivp64',sterm4,'geodesic-ivp.export')\n   cdblib.put ('ivp65',sterm5,'geodesic-ivp.export')\n\n   checkpoint.append (sterm2shortscaled)\n   checkpoint.append (sterm3shortscaled)\n\n   checkpoint.append (sterm2)\n   checkpoint.append (sterm3)\n   checkpoint.append (sterm4)\n   checkpoint.append (sterm5)\n\\end{cadabra}\n\n% just to check that we are exporting the correct 4th order terms\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{sterm2.short.001} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{sterm3.short.001} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{sterm2.short.scaled.002} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{sterm3.short.scaled.002} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{sterm2.short.scaled.003} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{sterm3.short.scaled.003} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n% export checkpoints in json format\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   for i in range( len(checkpoint) ):\n      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)\n\\end{cadabra}\n\\egroup\n\n\\end{document}\n", "meta": {"hexsha": "13fbe094e262c0893a3643b8cdb2781ca8b7c832", "size": 6917, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/geodesic-ivp.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/geodesic-ivp.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/geodesic-ivp.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8595505618, "max_line_length": 104, "alphanum_fraction": 0.541564262, "num_tokens": 2288, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.43804615687729936}}
{"text": "% !TEX root = altosaar-2020-thesis.tex\n\\chapter{Discussion}\n\\label{ch:discussion}\n\\lettrine[image=true,lines=3]{design/P}{robabilistic} modeling is useful across scientific domains. However, probabilistic modeling methods that do not take into account the structure of a problem, the form of individual datapoints, or information about probability distributions during optimization leave performance gains on the table.\n\nAs a motivating example, we built the structure of a statistical physics model into a probabilistic modeling method with \\acrlongpl{hvm}. Efficient use of the connectivity patterns in physics models enabled scaling variational approximations to models with millions of random variables.\n\nThere is also utility in constructing probabilistic models with knowledge about individual datapoints. \\acrlong{rfs} outperforms competitive recommendation models that either fail to take into account the goals of recommendation or the structure of items with sets of attributes.\n\nWe also improved variational inference, by making use of information about probability distributions within the \\acrlong{PVI} algorithm. This enabled accurate inferences about probability distributions.\n\nTo further unify the thesis of problem structure as utile in probabilistic modeling, we test \\acrlong{PVI} to measure whether the benefits of leveraging knowledge about a probability distributions are additive to performance gains from developing applied methods.\n\n\\input{table/tab_pvi_hvm}\nConsider an Ising model studied in \\Cref{ch:hvm}, where the goal is accurate inference of the free energy. \\Cref{tab:pvi-hvm} shows a comparison between \\gls{vi} and \\gls{PVI} in an \\gls{hvm}. This is a result of testing the best-performing settings from \\Cref{ch:pvi} with the entropy constraint on both the variational prior and recursive variational approximation in an \\gls{hvm}. The additional information \\gls{PVI} makes available to the variational approximation during optimization leads to more accurate inference of the free energy.\n\nFurther, \\gls{PVI} can be applied to probability models fit with maximum likelihood estimation. \\Cref{tab:pvi-rfs} reports the performance of a \\gls{rfs} model from \\Cref{sec:rfs-experiments} fit to arXiv user behavior data. Fitting the recommendation model using the \\gls{PVI} entropy proximity constraint improves top-10 recommendation recall. Metrics other than out-matrix recall (e.g. in-matrix recall) were comparable between these methods. With the \\gls{PVI} entropy constraint, the recommendation performance of \\gls{rfs} also improved in the meal recommendation task. \\Cref{tab:pvi-rfs-meals} reports these results. The best-performing settings from \\Cref{ch:pvi} generalize to maximum likelihood estimation in recommender systems, here giving a $6.9\\%$ boost in top-$1$ recommender recall.\n\nThat \\gls{PVI} yielded improvements when applied to both \\glspl{hvm} applied to statistical physics problems and the \\gls{rfs} recommendation model highlights several directions for further research. First, might \\gls{PVI} yield further gains in accuracy when applied to statistical physics models with millions of random variables? Practitioners are willing to trade off diminished accuracy for scale in some cases, and \\gls{PVI} is straightforward to test in new probability models and might help reduce the need for such trade-offs.\n\\input{table/tab_pvi_rfs}\n\nStudying where \\gls{PVI} yields marginal gains is also worth considering. For example, the entropy proximity constraint yielded less-significant improvements when applied to \\gls{rfs} fit to the meal recommendation data in \\Cref{sec:rfs-experiments}. This may be because the large size of data helped prevent overfitting, leading to reduced benefits of constraining parameter updates. In contrast, \\glspl{hvm} fit to statistical physics models in \\Cref{sec:hvm-experiments} converged to a solution very quickly, so monitoring convergence rates may be an additional source of information for proximity statistics.\n\\input{table/tab_pvi_rfs_meals}\n\nWhile \\Cref{ch:hvm} studied classical statistical physics models, future work in computational materials science and computational drug discovery will need to incorporate or approximate quantum effects. Density functional theory calculations based on quantum mechanics are expensive~\\citep{schmidt2019recent} and limit the length of time that a material or drug binding to a protein can be simulated. Future work in this area should include study of the trade-off between the size of a system and the accuracy needed to study the behavior of a system to achieve a materials design or drug design goal. For example, suppose the behavior of a drug binding to a protein over the course of several seconds is of clinical interest. Then a practitioner might tolerate more inaccuracy in an \\gls{hvm} approximation than they would if the short-run behavior could be accurately captured in a density functional theory calculation. One way of improving the trade-off may be to reduce the cost of fitting \\glspl{hvm} by derive objective functions with better gradient signal-to-noise ratio~\\citep{tucker2018doubly,rainforth2018tighter}. A similar trade-off occurs for system size, and it is unclear where \\glspl{hvm} may provide the only way to model a large-scale physical system.\n\n\\Cref{ch:rfs} developed \\gls{rfs}, and there remain several directions for future work on recommendation models for items with sets of attributes. Probabilistic generative models for use in recommendation may enable better recommendations under uncertainty, or easier incorporation of prior knowledge. However, probability distributions of sets of attributes are difficult to parameterize. One example of a distribution defined on sets is the Wallenius distribution~\\citep{wallenius1963biased,junqu2000wallenius}. It is interesting to consider how a distribution on sets might be parameterized using a permutation-invariant model such as \\gls{rfs}~\\citep{bloem-reddy2019probabilistic,lee2018set-transformer}. Further, generalization bounds are necessary follow-up work to universal approximation properties. A model may be able to represent a distribution, but for practical purposes a key desideratum is finding functions, nonlinearities, and architectures that make optimization easy and generalization feasible~\\citep{dziugaite2017computing}.\n\nAnother line of work is in developing robust negative sampling-based objective functions. The numeric value of the negative log-likelihood objective function used in \\gls{rfs} or other models that use negative samples and embeddings cannot reliably assess convergence. This is due to embeddings that are used in both positive and negative examples, leading stochastic gradient updates to increase and decrease Monte Carlo estimates of the objective during optimization. Reliable methods to estimate the value of objective functions may help reduce the need for expensive recommender systems evaluation metrics where a model may need to be evaluated on every item in an evaluation set. While \\gls{rfs} was designed for the recall evaluation metric, connecting binary classification objective functions with negative examples to ranking-based metrics such as normalized discounted cumulative gain would make these models useful broadly.\n\nIn \\Cref{ch:rfs}, we found that \\gls{rfs} outperforms \\gls{lstm} recurrent neural networks in the task of recommending arXiv documents to users. This is counterintuitive, as the order of item attributes (words in abstracts) should carry significant information.  However, the computational budget was fixed for both models, and it is unclear which recommendation model to use with a large computational budget. Models such as transformers~\\citep{vaswani2017attention,devlin2019bert:,lee2018set-transformer} might lead to improved recommendation performance, but at a greater computational cost than models such as \\gls{rfs} with inner product parameterizations. Analyzing these trade-offs will help make informed choices of computational budget given performance requirements in practice. Under computational constraints due to monetary budget or privacy regulation, such as in clinical settings~\\citep{huang2019clinicalbert:}, models such as \\gls{rfs} that make fast, accurate, predictions may be preferable to more accurate, slower models.\n\nThrough careful consideration of how to build problem structure into probabilistic models, we were able to scale variational methods to statistical physics models with millions of random variables, fit recommender systems to tens of millions of datapoints, and improve the accuracy of variational inference. This highlights the need to ensure that progress in probabilistic modeling continues to be translated into progress in applied domains such as statistical physics and recommender systems.", "meta": {"hexsha": "382a3d42176c35b5933897893c6ab27474884429", "size": 8832, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch_discussion.tex", "max_stars_repo_name": "altosaar/thesis", "max_stars_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-21T18:56:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T12:18:53.000Z", "max_issues_repo_path": "ch_discussion.tex", "max_issues_repo_name": "altosaar/thesis", "max_issues_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch_discussion.tex", "max_forks_repo_name": "altosaar/thesis", "max_forks_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 267.6363636364, "max_line_length": 1271, "alphanum_fraction": 0.8258605072, "num_tokens": 1848, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.43804615687729936}}
{"text": "\\documentclass[12pt]{article}\n\n% packages\n\\usepackage{setspace}\n\\usepackage{array}\n\\usepackage[margin=0.75in]{geometry}\n\\usepackage{amsmath,bm}\n\\usepackage{amssymb}\n\\usepackage{bbold}\n\\usepackage{physics}\n\\usepackage{xcolor}\n\\usepackage{indentfirst}\n\\usepackage{enumerate}\n\\usepackage{mathtools}\n\\usepackage{fancyhdr}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Creative Destruction Lab}\n\\lhead{Introductions to Projects}\n\\rfoot{Page \\thepage}\n\n\\allowdisplaybreaks\n\n\\title{Project 3: Calculating Franck-Condon Factors}\n\n\\begin{document}\n\n\\maketitle\n\n\\thispagestyle{empty}\n\n\\subsection*{Motivation}\n\nSpectroscopy is the study of how light and matter (atoms and molecules) interact.\nLight can be absorbed by matter (\\textit{absorption}) or matter can emit light (\\textit{emission}).\nIt turns out that spectroscopy is scientists' main tool for discovering properties of molecules (e.g. their molecular structure, bond strengths, etc.) and for chemical identification. Picture for instance an astronomer taking spectroscopic measurements from a gas cloud located millions of light years away from the Earth. To determine what chemicals this gas cloud comprises of, they certainly cannot travel there and take a physical sample of the gas cloud. The astronomer is tasked with utilizing spectroscopic theory (i.e. models wherein numerical studies can be carried out efficiently) to explain what they see.\n\nCountless other applications like drug discovery, magnetic-resonance imaging (MRI) and climate science rely heavily on spectroscopic methods and theory. This week, you'll familiarize yourself with calculating Franck Condon Factors (FCFs), which are useful in studying {\\it vibronic} transitions in molecules. You'll also get to compare your calculations to real experiments.\n\n\\subsection*{Your Tasks}\n\n\\subsubsection*{Task \\#1}\n\nIn this task, you will calculate Franck-Condon Factors for H$_2-$H$_2^+$ using the harmonic oscillator approximation and compare to a real experiment! In a real experiment, we can excite many different vibronic transitions. We would therefore be able to calculate many FCFs that describe different vibronic transitions. For example, it could be that we see excitations corresponding to an H$_2$ molecule in its $n = 0$ vibrational state to H$_2^+$ in its $n = 2$ vibrational state (green line in Fig.~\\ref{fig:visualize_vibronic}) and its $n = 4$ vibrational state. In this task, we will look at only transitions that have a high FCF (i.e. the corresponding transition is very intense).\n\n\\begin{figure} \n    \\begin{center}\n        \\includegraphics[width=0.5\\linewidth]{../figures/potential_energy_curve.pdf}\n    \\end{center}\n    \\caption{A visualization of vibronic transitions. The blue and red curves represent H$_2$ and H$_2^+$, respectively.}\n        \\label{fig:visualize_vibronic}\n\\end{figure}\n\nYou are provided with a \\texttt{python} notebook called \\texttt{Task1.ipynb} which calculates all of the information you require. The \\texttt{FCF\\_helper.py} file contains all of the calculations done under the hood. \\footnote{Calculating FCFs comes down to calculating the overlap between the wavefunctions before and after the vibronic transition. The overlap calculation is an integral which we chose to evaluate numerically. We emphasize that molecular parameters like the reduced mass of H$_2$ and fundamental frequencies of H$_2$ and H$_2^+$ are hard-coded in \\texttt{FCF\\_helper.py}} Currently, the \\texttt{spectrum\\_analysis} function in \\texttt{FCF\\_helper.py} only outputs the following.\n\\begin{itemize}\n    \\item \\texttt{n\\_0} and \\texttt{n\\_p}: The vibrational state numbers of H$_2$ and H$_2^+$, respectively, involved in the vibronic transition\n    \\item \\texttt{FCF}: The corresponding FCF associated to the vibronic transition\n\\end{itemize}\nHere's what we'd like you to do:\n\\begin{enumerate}\n    \\item Open up \\texttt{FCF\\_helper.py} and navigate to the \\texttt{spectrum\\_analysis} function. Modify the \\texttt{data} variable so that it also includes the spectral intensity (\\texttt{Ep - E0}).\n    \\item Plot the corresponding FCF versus spectral intensity (i.e. plot \\texttt{FCF} versus \\texttt{Ep - E0}) and show the results for \\texttt{n\\_0}=0 and \\texttt{n\\_p}=10. \\footnote{You may need to adjust the input bounds on the maximum vibrational state numbers. For now, start with both being 2.}\n\\end{enumerate}\n\nCongratulations, you have now successfully predicted the Franck-Condon Factors of H$_2-$H$_2^+$! Figure \\ref{fig:h2_spectrum} shows the photoionization spectrum for H$_2$. Does it look like the real data in Fig.~\\ref{fig:h2_spectrum}?\n\n\\begin{figure}\n    \\begin{center}\n        \\includegraphics[width=\\linewidth]{../figures/H2-expspectrum.pdf}\n    \\end{center}\n    \\caption{\n    Experimental photoionization spectrum of H$_2$-H$_2^+$ from Ref.~\\cite{berkowitz1973comparison} with the vibrational level of H$_2$=0.\n    }\n    \\label{fig:h2_spectrum}\n\\end{figure}\n\n\\subsubsection*{Task \\#2}\n\nYou are provided with a \\texttt{C++} code \\texttt{FC.cxx} created by P.-N. Roy \\cite{yang1995structure}, which calculates the photoionization spectrum for any molecule up to triple excitations and goes beyond the harmonic oscillator approximation. The theory is based on the paper by Ref~\\cite{doktorov1977dynamical}. The molecule you will be investigating is $V_3$.\nThis code takes as input a file which requires the results of diagonalizing the mass-weighted hessian/force-constant matrix (2nd derivative of the Hamiltonian with respect to position). This input file is provided for you (V3).\n\nBrowse the following references to understand how the code works, as you will need a basic understanding of this for the next task, but it's not necessary to fully understand it. Compile and run the code \\texttt{./FC\\_quick V3}. This code outputs the spectrum \\texttt{V3.spec.out}. Plot it in your favourite plotting program. \n\n\\subsubsection*{Task \\#3}\n\nYou are provided with a \\texttt{python} notebook code Sample\\_Vibronic.py which calculates all of the information you require.\n\\noindent This code takes as input a file which requires the following information:\n\\begin{enumerate}\n    \\item Number of atoms in the molecule\n    \\item Vibrational frequencies of the molecule in the ground electronic state\n    \\item Vibrational frequencies of the molecule in the excited electronic state\n    \\item Duschinsky Matrix (encodes information on transformation between ground and excited electronic states)\n    \\item Displacement vector\n\\end{enumerate}\n\n\\noindent This code outputs the spectrum in HTML format.\n\nHowever, to be able to use this code, you require an input file. To create this input file, you will need to generate results from another code, \\texttt{FC.cxx}. This code calculates the Franck-Condon Factors using matrix elements and recursive Hermite polynomial relations. Feel free to look around this code, but it is not necessary to completely understand it to achieve this task (the reference(s) noted in this code are Refs~\\cite{yang1995structure,doktorov1977dynamical,quesadaFranckCondonFactorsCounting2019}. Each piece of information that you need to output has been clearly marked in the code and your task is to write that information to a file, which will then be used as your input file to \\texttt{Sample\\_Vibronic.py}. Once you have that input file, you should be able to produce the spectrum for $V_3$. Compare this spectrum to the previous method. What happens if you decrease the number of samples to 10? 100? 1000? At what number of samples do you feel the spectrum is converged?\n\n\\section*{Challenges}\n\n\\begin{enumerate}\n    \\item An alternative and analogous method to calculating these Franck-Condon Factors using matrix elements is to use a loop hafnian approach. This loop hafnian approach uses Gauss Boson Sampling which would allow these Factors to be calculated using a quantum circuit. Use the result of Task 3 to provide data to a skeleton code provided that uses loop hafnians to calculate the Franck-Condon Factors.\n    \\item Explain briefly the similarities and differences between these three methods.\n\\end{enumerate}\n\n\\section*{Possible Business Outcomes}\n\n\\begin{enumerate}\n    \\item Explain to a layperson what theoretical chemistry/physics is, in the general context of Franck-Condon Factors\n    \\item What is the importance of theoretical chemistry/physics from an economic point of view\n    \\item Explain to a layperson what a quantum circuit is and it's relationship to theoretical chemistry/physics\n    \\item What are advantages and disadvantages of codes licensed for the public domain and those that are licensed for private use\n\\end{enumerate}\n\n\\newpage\n\n\\bibliography{refs}\n\\bibliographystyle{unsrt}\n\n\\end{document}\n", "meta": {"hexsha": "dfda8afc0f83d247c40712b9d19b9d9d785ac8a7", "size": 8703, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Project_3_Franck_Condon_Factors/Project3_LandingPage.tex", "max_stars_repo_name": "CDLQuantum2020Week1Team1/CohortProject_2020", "max_stars_repo_head_hexsha": "54c860d7be9797ddc95d9a8d1e55a129037af5d9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Project_3_Franck_Condon_Factors/Project3_LandingPage.tex", "max_issues_repo_name": "CDLQuantum2020Week1Team1/CohortProject_2020", "max_issues_repo_head_hexsha": "54c860d7be9797ddc95d9a8d1e55a129037af5d9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Project_3_Franck_Condon_Factors/Project3_LandingPage.tex", "max_forks_repo_name": "CDLQuantum2020Week1Team1/CohortProject_2020", "max_forks_repo_head_hexsha": "54c860d7be9797ddc95d9a8d1e55a129037af5d9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.756097561, "max_line_length": 997, "alphanum_fraction": 0.7851315638, "num_tokens": 2117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.43804615687729936}}
{"text": "% Copyright 2019 by Mark Wibrow\n%\n% This file may be distributed and/or modified\n%\n% 1. under the LaTeX Project Public License and/or\n% 2. under the GNU Free Documentation License.\n%\n% See the file doc/generic/pgf/licenses/LICENSE for more details.\n\n\n\\section{Math Library}\n\\label{section-library-math}\n\n\\begin{tikzlibrary}{math}\n    This library defines a simple mathematical language to define simple\n    functions and perform sequences of basic mathematical operations.\n\\end{tikzlibrary}\n\n\n\\subsection{Overview}\n\n\\pgfname\\ and \\tikzname\\ both use the \\pgfname\\ mathematical engine which\nprovides many commands for parsing expressions. Unfortunately the \\pgfname\\\nmath engine is somewhat cumbersome for long sequences of mathematical\noperations, particularly when assigning values to multiple variables. The\n\\tikzname\\ |calc| library provides some additional ``convenience'' operations\nfor doing calculations (particularly with coordinates), but this can only be\nused inside \\tikzname\\ path commands.\n\nThis |math| library provides a means to perform sequences of mathematical\noperations in a more `user friendly' manner than the \\pgfname\\ math engine. In\naddition, the coordinate calculations of the |calc| library can be accessed\n(provided it is loaded).\n%\nHowever as the |math| library uses the \\pgfname\\ math engine -- which uses pure\n\\TeX\\ to perform all its calculations -- it is subject to the same speed and\naccuracy limitations. It is worth bearing this in mind, before trying to\nimplement algorithms requiring intensive and highly accurate computation. You\ncan, of course use the |fp| or the |fpu| libraries to increase the accuracy\n(but not necessarily the speed) of computations.\n\nFor most purposes, the features provided by this library are accessed using the\nfollowing command:\n\n\\begin{command}{\\tikzmath\\texttt{\\{}\\meta{statements}\\texttt{\\}}}\n    This command process  a series of \\meta{statements} which can represent\n    assignments, function definitions, conditional evaluation, and iterations.\n    It provides, in effect, a miniature mathematical language to perform basic\n    mathematical operations. Perhaps the most important thing to remember is\n    that \\emph{every statement should end with a semi-colon}. This is likely to\n    be the most common reason why the |\\tikzmath| command fails.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  % Adapted from http://www.cs.northwestern.edu/academics/courses/110/html/fib_rec.html\n  function fibonacci(\\n) {\n    if \\n == 0 then {\n      return 0;\n    } else {\n       return fibonacci2(\\n, 0, 1);\n     };\n  };\n  function fibonacci2(\\n, \\p, \\q) {\n    if \\n == 1 then {\n      return \\q;\n    } else {\n      return fibonacci2(\\n-1, \\q, \\p+\\q);\n    };\n  };\n  int \\f, \\i;\n  for \\i in {0,1,...,20}{\n    \\f = fibonacci(\\i);\n    print {\\f, };\n  };\n}\n\\end{codeexample}\n    %\n\\end{command}\n\nIn addition to this command the following key is provided:\n\n\\begin{key}{/tikz/evaluate={\\meta{statements}}}\n    This key simply executes |\\tikzmath{|\\meta{statements}|}|.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikz[x=0.25cm,y=0.25cm,\n  evaluate={\n    int \\i, \\j;\n    for \\i in {0,...,10}{\n      for \\j in {0,...,10}{\n        \\a{\\i,\\j} = (\\i+\\j)*5;\n      };\n    };\n  }\n]\n\\foreach \\i in {0,...,10}\n  \\foreach \\j in {0,...,10}\n    \\fill [red!\\a{\\i,\\j}!yellow]  (\\i,\\j) rectangle ++(1, 1);\n\\end{codeexample}\n    %\n\\end{key}\n\nThe following sections describe the miniature language that this library\nprovides and can be used in the |\\tikzmath| command and the |evaluate| key.\nThe language consists only of simple keywords and expressions but the\nmini-parser allows you to format code in a reasonably versatile way (much like\nthe |tikz| parser) except that \\emph{all the keywords must be followed by at\nleast one space}. This is the second most important thing to remember (after\nremembering to insert semi-colons at the end of every statement).\n\n\n\\subsection{Assignment}\n\nIn the simplest case, you will want to evaluate an expression and assign it to\na macro, or a \\TeX\\ count or dimension register. In this case, use of the\n|math| library is straightforward:\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\newcount\\mycount\n\\newdimen\\mydimen\n\\tikzmath{\n  \\a = 4*5+6;\n  \\b = sin(30)*4;\n  \\mycount = log10(2048) / log10(2);\n  \\mydimen = 15^2;\n}\n\\a, \\b, \\the\\mycount, \\the\\mydimen\n\\end{codeexample}\n\nIn addition, \\TeX-macros (\\emph{not} \\TeX\\ registers) can be suffixed with an\nindex, similar to indices in mathematical notation, for example, $x_1$, $x_2$,\n$x_3$:\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  \\x1 = 3+4; \\x2 = 30+40; \\x3 = 300+400;\n}\n\\x1, \\x2, \\x3\n\\end{codeexample}\n\nThe index does not have to be a number. By using braces |{}|, more\nsophisticated indices can be created:\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  \\c{air} = 340; \\c{water} = 1435; \\c{steel} = 6100;\n}\n\\foreach \\medium in {air,steel}{The speed of sound in \\medium\\ is \\c{\\medium} m/s. }\n\\end{codeexample}\n\nYou should not, however, try to mix indexed and non-indexed variables. Once an\nassignment is made using an index, the |math| library expects all instances of\nthe variable on the right hand side of an assignment to be followed by an\nindex. This effect is reversed if you subsequently make an assignment to the\nvariable without an index: the |math| library (or to be precise the \\pgfname\\\nmath-engine) will then ignore any index following the variable on the right\nhand side of an assignment.\n\nIn some cases, you may wish to assign a value or expression to a variable\nwithout evaluating it with the \\pgfname\\ math-engine. In this case, you can use\nthe following keyword:\n\n\\begin{math-keyword}{{let} \\meta{variable} \\texttt{=} \\meta{expression}\\texttt{;}}\n    This keyword assigns \\meta{expression} to \\meta{variable} without\n    evaluation. The \\meta{expression} is however fully expanded using |\\edef|.\n    Any spaces preceding \\meta{expression} are removed, but any trailing spaces\n    (before the semi-colon) are included.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  let \\x = (5*4)+1;\n  let \\c1 = blue;\n}\n\\x, ``\\c1''\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\n\n\\subsection{Integers, ``Real'' Numbers, and Coordinates}\n\nBy default, assignments are made by evaluating expressions using the \\pgfname\\\nmath-engine and results  are usually returned as number with a decimal point\n(unless you are assigning to a count register or use the |int| function).\n%\nAs this is not always desirable, the |math| library allows variables -- which\n\\emph{must} be \\TeX\\ macros -- to be `declared' as being a particular `type'.\nThe library recognizes three types: integers (numbers without a decimal point),\nreal numbers (numbers with a decimal point\\footnote{Strictly speaking, due to\nthe finite range and precision of \\TeX\\ numerical capabilities, the term\n``real'' is not correct.}), and coordinates.\n\nTo declare a variable as being one of the three types, you  can use the\nkeywords shown below. It is important to remember that by telling the |math|\nlibrary you want it to do a particular assignment for a variable, it will also\ndo the same assignment when the variable is indexed.\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  integer \\x;\n  \\x1 = 3+4; \\x2 = 30+40; \\x3 = 300+400;\n}\n\\x1, \\x2, \\x3\n\\end{codeexample}\n\n%But, if you want integer results without using a count register or the\n%|int| function, you can use a keyword to indicate this:\n\n\\begin{math-keyword}{{integer} \\meta{variable}\\opt{\\texttt{,} \\meta{additional variables}}\\texttt{;}}\n    The |integer| keyword indicates that assignments to the \\meta{variable} or\n    the comma separated list of \\meta{additional variables} should be truncated\n    (not rounded) to integers. The variables should be ordinary macros --\n    \\emph{not} \\TeX\\ registers. In addition the variables should \\emph{not} be\n    indexed.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n   integer \\x, \\y, \\z;\n   \\x = 4*5+6;\n   \\y = sin(30)*4;\n   \\z = log10(512) / log10(2);\n   print {$x=\\x$, $y=\\y$, $z=\\z$};\n}\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\n\\begin{math-keyword}{{int} \\meta{variable}\\opt{\\texttt{,} \\meta{additional variables}}\\texttt{;}}\n    Short version of the |integer| keyword.\n\\end{math-keyword}\n\nHaving declared a variable as an integer, the |math| library will continue to\nassign only integers to that variable within the current \\TeX\\ scope. If you\nwish to assign non-integer (i.e., \\emph{real}) numbers to the same variable,\nthe following keyword can be used.\n\n\\begin{math-keyword}{{real} \\meta{variable}\\opt{\\texttt{,} \\meta{additional variables}}\\texttt{;}}\n    The |real| keyword ensures that assignments \\meta{variable} (and\n    \\meta{additional variables}) will not be truncated to integers.\n\\end{math-keyword}\n\nIn order to take advantage of |math| library interface to the |calc| library\nyou must indicate that a variable is to be assigned coordinates, using the\nfollowing keyword.\n\n\\begin{math-keyword}{{coordinate} \\meta{variable}\\opt{\\texttt{,} \\meta{additional variables}}\\texttt{;}}\n    This keyword enables \\tikzname-style coordinates such as |(2cm,3pt)| or\n    |(my node.east)| to be parsed and assigned to \\meta{variable} in the form\n    $x,y$, which can then be used in a |tikzpicture|:\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n   coordinate \\c;\n   \\c = (45:10pt);\n}\n\\tikz\\draw (0,0) -- (\\c);\n\\end{codeexample}\n\n    If the \\tikzname\\ |calc| library is loaded, coordinate calculations can be\n    performed; the coordinate expression does not have to be surrounded by\n    |($|\\ldots|$)|.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n   coordinate \\c, \\d;\n   \\c = (-1,2)+(1,-1);\n   \\d = (4,1)-(2,-1);\n}\n\\tikz\\draw (\\c) -- (\\d);\n\\end{codeexample}\n\n    In addition to assigning the $x$ and $y$ coordinates to \\meta{variable}\n    (possibly with an optional index), two further variables are defined. The\n    first takes the name of \\meta{variable} (e.g., |\\c|) suffixed with |x|\n    (i.e., |\\cx|) and is assigned the $x$ coordinate of |\\c|. The second takes\n    the name of \\meta{variable} suffixed with |y| (i.e., |\\cy|) and is assigned\n    the $y$ coordinate of |\\c|.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n   coordinate \\c;\n   \\c1 = (30:20pt);\n   \\c2 = (210:20pt);\n}\n\\tikz\\draw (\\cx1,\\cy1) -- (\\cx2,\\cy1) -- (\\cx2,\\cy2) -- (\\cx1,\\cy2);\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\n%\\begin{math-keyword}{{point} \\meta{variable}\\opt{\\texttt{,} \\meta{additional variables}}\\texttt{;}}\n%    The |point| keyword is a synonym for the |coordinate| keyword and performs\n%    the same function.\n%\\end{math-keyword}\n\n\n\\subsection{Repeating Things}\n\n\\begin{math-keyword}{{for} \\meta{variable} \\texttt{in \\{}\\meta{list}\\texttt{\\}\\{}\\meta{expressions}\\texttt{\\};}}\n    This is a ``trimmed down'' version of the |\\foreach| command available as\n    part of \\pgfname\\ and \\tikzname, but cannot currently be used outside of\n    the |\\tikzmath| command. It is important to note the following:\n    %\n    \\begin{itemize}\n        \\item Every value in \\meta{list} is evaluated using the \\pgfname\\\n            mathematical engine. However, if an item in \\meta{list} contains a\n            comma, it \\emph{must} be surrounded by braces, for example,\n            |{mod(5, 2)}|.\n            %\n\\begin{codeexample}[pre={\\pgfmathsetseed{1}},preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  int \\x, \\v;\n  \\v=1;\n  for \\x in {1,...,{random(3,10)}}{\n     \\v=\\v*2;\n  };\n  print {$x=\\x, v=\\v$};\n}\n\\end{codeexample}\n            %\n        \\item Because each item is evaluated, you cannot use \\tikzname\\\n            coordinates in \\meta{list}.\n        \\item Only single variable assignment is supported.\n        \\item The ``dots notation'' (e.g., |1,2,...,9|) can be used in\n            \\meta{list}, but is not as sophisticated as the \\pgfname\\\n            |\\foreach| command. In particular, contextual replacement is not\n            possible.\n        \\item Assignments that occur in the loop body \\emph{are not scoped}.\n            They last beyond the body of each iteration and the end of the\n            |for| statement. This includes the values assigned to the\n            \\meta{variable}.\n            %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  int \\x, \\y;\n  \\y = 0;\n  for \\x1 in {1,...,5}{\n    for \\x2 in {10,20,...,50}{\n      \\y = \\y+\\x1*\\x2;\n    };\n  };\n}\n$x_1=\\x1, x_2=\\x2, y=\\y$\n\\end{codeexample}\n    \\end{itemize}\n\\end{math-keyword}\n\n\n\\subsection{Branching Statements}\n\nSometimes you may wish to execute different statements depending on the value\nof an expression. In this case the following keyword can be used:\n\n\\begin{math-keyword}{{if} \\meta{condition} \\texttt{then \\{}\\meta{if-non-zero-statements}\\texttt{\\};}}\n    This keyword executes \\meta{if-non-zero-statements} if the expression in\n    \\meta{condition} evaluates to any value other than zero.\n\\end{math-keyword}\n\n\\begin{math-keyword}{{if} \\meta{condition} \\texttt{then \\{}\\meta{if-non-zero-statements}\\texttt{\\}} \\texttt{else} \\texttt{\\{}\\meta{if-zero-statements}\\texttt{\\}}\\texttt{;}}\n    This keyword executes \\meta{if-non-zero-statements} if the expression in\n    \\meta{condition} evaluates to any value other than zero and the\n    \\meta{if-zero-statements} are executed if the expression in\n    \\meta{condition} evaluates to zero.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n  \\begin{tikzpicture}\n  \\tikzmath{\n    int \\x;\n    for \\k in {0,10,...,350}{\n      if \\k>260 then { let \\c = orange; } else {\n        if \\k>170 then { let \\c = blue; } else {\n          if \\k>80 then { let \\c = red; } else {\n            let \\c = green; }; }; };\n      {\n        \\path [fill=\\c!50, draw=\\c] (\\k:0.5cm) -- (\\k:1cm) --\n          (\\k+5:1cm) -- (\\k+5:0.5cm) -- cycle;\n      };\n    };\n  }\n  \\end{tikzpicture}\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\n\n\\subsection{Declaring Functions}\n\nYou can add functions by using the following keywords:\n\n\\begin{math-keyword}{{function} \\meta{name}\\texttt{(}\\meta{arguments}\\texttt{) \\{} \\meta{definition} \\texttt{\\};}}\n    This keyword works much like the |declare function| provided by the\n    \\pgfname\\ math-engine. The function \\meta{name} can be any name that is not\n    already a function name in the current scope. The list of \\meta{arguments}\n    are comma separated \\TeX\\ macros such as |\\x|, or |\\y| (it is not possible\n    to declare functions that take variable numbers of arguments). If the\n    function takes no arguments then the parentheses need not be used. It is\n    very important to note that the arrays that the \\pgfname\\ math engine\n    supports \\emph{cannot currently be passed as arguments to functions}.\n\n    The function \\meta{definition} should be a sequence of statements that can\n    be parsed by the |\\tikzmath| command and should use the commands specified\n    in the \\meta{arguments}. The |return| keyword (described below) should be\n    used to indicate the value returned by the function.\n    %\n    Although \\meta{definition} can take any statements accepted by |\\tikzmath|,\n    it is not advisable try to define functions inside other functions.\n    %\n\\begin{codeexample}[pre={\\pgfmathsetseed{1}},preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  function product(\\x,\\y) {\n    return \\x*\\y;\n  };\n  int \\i, \\i, \\k;\n  \\i = random(1,10);\n  \\j = random(20, 40);\n  \\k = product(\\i, \\j);\n  print { $\\i\\times \\j = \\k$ };\n}\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\n\\begin{math-keyword}{{return} \\meta{expression}\\texttt{;}}\n    This keyword should be used as the last executed statement in a function\n    definition to indicate the value that should be returned.\n\\end{math-keyword}\n\n\n\\subsection{Executing Code Outside the Parser}\n\nSometimes you may wish to do ``something'' outside the parser, perhaps display\nsome intermediate result or execute some code. In this case you have two\noptions. Firstly, the following keyword can be used:\n\n\\begin{math-keyword}{{print} \\texttt{\\{}\\meta{code}\\texttt{\\};}}\n    Execute \\meta{code} immediately. This is intended as convenience keyword\n    for displaying information in a document (analogous to the |print| command\n    in real programming languages). The \\meta{code} is executed inside a \\TeX\\\n    group.\n    %\n\\begin{codeexample}[pre={\\pgfmathsetseed{1}},preamble={\\usetikzlibrary{math}}]\n\\tikzmath{\n  int \\x, \\y, \\z;\n  \\x = random(2, 5);\n  for \\y in {0,...,6}{\n    \\z = \\x^\\y;\n    print {$\\x^\\y=\\z$, };\n  };\n}\n\\end{codeexample}\n    %\n\\end{math-keyword}\n\nSecondly, if a statement begins with  a brace |{|, then everything up to the\nclosing brace |}| is collected and executed (the closing brace \\emph{must} be\nfollowed by a semi-colon). Like the |print| keyword, the contents of the braces\nis executed inside a \\TeX\\ group. Unlike the |print| keyword, the brace\nnotation can be used in functions so that |tikz| path commands can be safely\nexecuted inside a |tikzpicture|.\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{math}}]\n\\begin{tikzpicture}\n\\draw [help lines] grid (3,2);\n\\tikzmath{\n  coordinate \\c;\n  for \\x in {0,10,...,360}{\n    \\c = (1.5cm, 1cm) + (\\x:1cm and 0.5cm);\n    { \\fill (\\c) circle [radius=1pt]; };\n  };\n}\n\\end{tikzpicture}\n\\end{codeexample}\n", "meta": {"hexsha": "7f0b429f1be6c86e431ff17226a5802f38081d38", "size": 17288, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex", "max_stars_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_stars_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex", "max_issues_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_issues_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex", "max_forks_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_forks_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.6271186441, "max_line_length": 172, "alphanum_fraction": 0.6893799167, "num_tokens": 5014, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.43804615687729936}}
{"text": "\\section{Numerical Tests}\n\\label{sec:numerical}\n\nIn this section we present numerical results obtained with the DG-IMEX scheme developed in this paper.  \nThe first set of tests (Section~\\ref{sec:smoothProblems}) are included to compare the time integration schemes in various regimes.  \nWe are not concerned with moment realizability in Section~\\ref{sec:smoothProblems}, and we do not apply the realizability-enforcing limiter in these tests.  \nThe tests in Sections~\\ref{sec:packedBeam} and \\ref{sec:fermionImplosion} are designed specifically to demonstrate the robustness of the scheme to dynamics near the boundary of the realizable set $\\cR$.  \nThe test in Section~\\ref{sec:homogeneousSphere} (Homogeneous Sphere) is of astrophysical interest.  \nHere we consider moment realizability and compare results obtained with various moment closures.  \n\n\\subsection{Problems with Known Smooth Solutions}\n\\label{sec:smoothProblems}\n\nTo compare the accuracy of the IMEX schemes, we present results from smooth problems in streaming, absorption, and scattering dominated regimes in one spatial dimension.  \nFor all tests in this subsection, we use third order accurate spatial discretization (polynomials of degree $k=2$) and we employ the maximum entropy closure in the low occupancy limit (i.e., the Minerbo closure).  \nWe compare results obtained using IMEX schemes proposed here (PA2+ and PD-ARS) with IMEX schemes from Hu et al. \\cite{hu_etal_2018} (PA2), McClarren et al. \\cite{mcclarren_etal_2008} (PC2), Pareschi \\& Russo \\cite{pareschiRusso_2005} (SSP2332), and Cavaglieri \\& Bewley \\cite{cavaglieriBewley2015} (RKCB2).  \nIn the streaming test, we also include results obtained with second-order and third-order accurate explicit strong stability-preserving Runge-Kutta methods \\cite{gottlieb_etal_2001} (SSPRK2 and SSPRK3, respectively).  \nSee \\ref{app:butcherTables} for further details.  \nThe time step is set to $\\dt=0.1\\times\\dx$.  \n\nWhen comparing the numerical results to analytic solutions, errors are computed in the $L^{1}$-error norm.  \nWe compare results either in the absolute error ($E_{\\mbox{\\tiny Abs}}^{1}$) or the relative error ($E_{\\mbox{\\tiny Rel}}^{1}$), defined for a scalar quantity $u_{h}$ (approximating $u$) as\n\\begin{equation}\n  E_{\\mbox{\\tiny Abs}}^{1}[u_{h}](t)\n  =\\f{1}{|D|}\\sum_{\\bK\\in\\mathscr{T}}\\int_{\\bK}|u_{h}(\\vect{x},t)-u(\\vect{x},t)|\\,d\\vect{x}\n  \\label{eq:errorNormAbsolute}\n\\end{equation}\nand\n\\begin{equation}\n  E_{\\mbox{\\tiny Rel}}^{1}[u_{h}](t)\n  =\\f{1}{|D|}\\sum_{\\bK\\in\\mathscr{T}}\\int_{\\bK}|u_{h}(\\vect{x},t)-u(\\vect{x},t)|/|u(\\vect{x},t)|\\,d\\vect{x},\n  \\label{eq:errorNormRelative}\n\\end{equation}\nrespectively.  \nThe integrals in Eqs.~\\eqref{eq:errorNormAbsolute} and \\eqref{eq:errorNormRelative} are computed with a simple $3$-point equal weight quadrature.  \n\n\\subsubsection{Sine Wave: Streaming}\n\nThe first test involves the streaming part only, and does not include any collisions ($\\sigma_{\\Ab}=\\sigma_{\\Scatt}=0$).  \nWe consider a periodic domain $D=\\{x:x\\in[0,1]\\}$, and let the initial condition be given by\n\\begin{equation}\n  \\cJ(x,t=0)=\\cH_{x}(x,t=0)=0.5+0.49\\times\\sin\\big(2\\pi\\,x\\big).  \n  \\label{eq:initialConditionStreaming}\n\\end{equation}\nWe evolve until $t=10$, when the sine wave has completed 10 crossings of the computational domain.  \nWe vary the number of elements ($N$) from $8$ to $128$ and compute errors for various time stepping schemes.  \n\nIn Figure~\\ref{fig:SineWaveStreaming}, the absolute error for the number density $E_{\\mbox{\\tiny Abs}}^{1}[\\cJ_{h}](t=10)$ is plotted versus $N$ (see figure caption for details).  \nErrors obtained with SSPRK3 are smallest and decrease as $N^{-3}$ (cf. bottom black dash-dot reference line), as expected for a scheme combining third-order accurate time stepping with third-order accurate spatial discretization.  \nFor all the other schemes, using second-order accurate explicit time stepping, the error decreases as $N^{-2}$.  \nAmong the second-order accurate methods, SSP2332 has the smallest error, followed by RKCB2.  \nErrors for the remaining schemes (including SSPRK2) are indistinguishable on the plot.  \n\\begin{figure}[H]\n  \\centering\n    \\includegraphics[width=\\textwidth]{figures/SineWaveStreaming}\n   \\caption{Absolute error (cf. Eq.~\\eqref{eq:errorNormAbsolute}) versus number of elements $N$ for the streaming sine wave test.  Results employing various time stepping schemes are compared: SSPRK2 (cyan triangles pointing up), SSPRK3 (cyan triangles pointing down), PA2 (red), PA2+ (purple), PC2 (blue), RKCB2 (dark green), SSP2332 (green), and PD-ARS (light red circles).  Black dash-dot reference lines are proportional to $N^{-1}$ (top), $N^{-2}$ (middle), and $N^{-3}$ (bottom), respectively.}\n  \\label{fig:SineWaveStreaming}\n\\end{figure}\n\n\\subsubsection{Sine Wave: Damping}\n\nThe next test we consider, adapted from \\cite{skinnerOstriker_2013}, consists of a sine wave propagating with unit speed in a purely absorbing medium ($f_{0}=0$, $\\sigma_{\\Scatt}=0$), which results in exponential damping of the wave amplitude.  \nWe consider a periodic domain $D=\\{x:x\\in[0,1]\\}$, and let the initial condition ($t=0$) be given as in Eq.~\\eqref{eq:initialConditionStreaming}.  \nFor a constant absorption opacity $\\sigma_{\\Ab}$, the analytical solution at $t>0$ is given by\n\\begin{equation}\n  \\cJ(x,t)=\\cJ_{0}(x-t)\\times\\exp(-\\sigma_{\\Ab} t)\n  \\quad\\text{and}\\quad\n  \\cH_{x}(x,t)=\\cJ(x,t),\n\\end{equation}\nwhere $\\cJ_{0}(x)=\\cJ(x,0)$.  \n\nWe compute numerical solutions for three values of the absorption opacity ($\\sigma_{\\Ab}=0.1$, $1$, and $10$), and adjust the end time $t_{\\mbox{\\tiny end}}$ so that $\\sigma_{\\Ab}t_{\\mbox{\\tiny end}}=10$, and the initial condition has been damped by factor $e^{-10}$.  \nThus, for $\\sigma_{\\Ab}=0.1$ the sine wave crosses the domain 100 times, while for $\\sigma_{\\Ab}=10$, it crosses the grid once.  \n\nFigure~\\ref{fig:SineWaveDamping} shows convergence results, obtained using different values of $\\sigma_{\\Ab}$, for various IMEX schemes at $t=t_{\\mbox{\\tiny end}}$.  \nResults for $\\sigma_{\\Ab}=0.1$, $1$, and $10$ are plotted with red, green, and blue lines, respectively (see figure caption for further details).  \nAll the second-order accurate schemes (PA2, PA2+, RKCB2, and SSP2332) display second-order convergence rates (cf. bottom, black dash-dot reference line).  \nFor $\\sigma_{\\Ab}=0.1$, SSP2332 is the most accurate among these schemes, while PA2+ is the most accurate for $\\sigma_{\\Ab}=10$.  \nOn the other hand, PC2 and PD-ARS are indistinguishable and display at most first-order accurate convergence, as expected.  \n(For $\\sigma_{\\Ab}=0.1$, PC2 and PD-ARS are the most accurate schemes for $N=8$ and $N=16$.)\n\n\\begin{figure}[H]\n  \\centering\n    \\includegraphics[width=\\textwidth]{figures/SineWaveDamping}\n   \\caption{Relative error (cf. Eq.~\\eqref{eq:errorNormRelative}) versus number of elements for the damping sine wave test.  Results for different values of the absorption opacity $\\sigma_{\\Ab}$, employing various IMEX time stepping schemes, are compared.  Errors for $\\sigma_{\\Ab}=0.1$, $1$, and $10$ are plotted with red, green, and blue lines, respectively.  The IMEX schemes employed are: PA2 (triangles pointing left), PA2+ (triangles pointing right), PC2 (asterisk), RKCB2 ($\\times$), SSP2332 ($+$), and PD-ARS (circles).  Black dash-dot reference lines are proportional to $N^{-1}$ (top) and $N^{-2}$ (bottom), respectively.}\n  \\label{fig:SineWaveDamping}\n\\end{figure}\n\n\\subsubsection{Sine Wave: Diffusion}\n\nThe final test with known smooth solutions, adopted from \\cite{radice_etal_2013}, is diffusion of a sine wave in a purely scattering medium ($f_{0}=0$, $\\sigma_{\\Ab}=0$).  \nThe computational domain $D=\\{x:x\\in[-3,3]\\}$ is periodic, and the initial condition is given by\n\\begin{equation}\n  \\cJ_{0}(x)=0.5+0.49\\times\\sin\\big(\\f{\\pi\\,x}{3}\\big)\n  \\quad\\text{and}\\quad\n  \\cH_{x,0}\n  =-\\f{1}{3\\sigma_{\\Scatt}}\\pderiv{\\cJ_{0}}{x}.  \n  \\label{eq:initialConditionDiffusion}\n\\end{equation}\nFor a sufficiently high scattering opacity, the moment equations limit to a diffusion equation for the number density (deviations appear at the $1/\\sigma_{\\Scatt}^{2}$-level).  \nWith the initial conditions in Eq.~\\eqref{eq:initialConditionDiffusion}, the analytical solution to the limiting diffusion equation is given by\n\\begin{equation}\n  \\cJ(x,t)=\\cJ_{0}(x)\\times\\exp\\big(-\\f{\\pi^{2}\\,t}{27\\,\\sigma_{\\Scatt}}\\big),\n\\end{equation}\nand $\\cH_{x}=(3\\,\\sigma_{\\Scatt})^{-1}\\pd{\\cJ}{x}$.  \nWhen computing errors for this test, we compare the numerical results obtained with the two-moment model to the analytical solution to the limiting diffusion equation.  \nWe compute numerical solutions using three values of the scattering opacity ($\\sigma_{\\Scatt}=10^{2}$, $10^{3}$, and $10^{4}$), and adjust the end time so that $t_{\\mbox{\\tiny end}}/\\sigma_{\\Scatt}=1$.  \nThe initial amplitude of the sine wave has then been reduced by a factor $e^{-\\pi^{2}/27}\\approx0.694$ for all values of $\\sigma_{\\Scatt}$.  \n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=1.0\\textwidth]{figures/SineWaveDiffusionN}\n   \\caption{Absolute error (cf. Eq.~\\eqref{eq:errorNormAbsolute}) for the number density $\\cJ$ versus number of elements for the sine wave diffusion test.  Results with different values of the scattering opacity $\\sigma_{\\Scatt}$, employing different IMEX schemes, are compared.  Errors with $\\sigma_{\\Scatt}=10^{2}$, $10^{3}$, and $10^{4}$ are plotted with red, green, and blue lines, respectively.  The IMEX schemes employed are: PA2 (triangle pointing left), PA2+ (triangle pointing right), PC2 (asterisk), RKCB2 (cross), SSP2332 (plus), and PD-ARS (circle).  Black dash-dot reference lines are proportional to $N^{-1}$ (top) and $N^{-2}$ (bottom), respectively.}\n  \\label{fig:SineWaveDiffusionJ}\n\\end{figure}\n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=1.0\\textwidth]{figures/SineWaveDiffusionG}\n   \\caption{Same as in Figure~\\ref{fig:SineWaveDiffusionJ}, but for the number flux $\\cH_{x}$.}\n  \\label{fig:SineWaveDiffusionH}\n\\end{figure}\n\nIn Figures~\\ref{fig:SineWaveDiffusionJ} and \\ref{fig:SineWaveDiffusionH} we plot the absolute error, obtained using different values of $\\sigma_{\\Scatt}$, for various IMEX schemes at $t=t_{\\mbox{\\tiny end}}$.  \nResults for $\\sigma_{\\Scatt}=10^{2}$, $10^{3}$, and $10^{4}$ are plotted with red, green, and blue lines, respectively (see figure caption for further details).  \n(Scheme PC2 has been shown to work well for this test \\cite{radice_etal_2013}, but is included here for comparison with the other IMEX schemes.)\nSchemes PD-ARS, RKCB2, and SSP2332 are accurate for this test, and display third-order accuracy for the number density $\\cJ$ and second-oder accuracy for $\\cH_{x}$.  \nFor $\\sigma=10^{2}$, the errors do not drop below $10^{-6}$ because of differences between the two-moment model and the diffusion equation used to obtain the analytic solution.  \nFor larger values of the scattering opacity, the two-moment model agrees better with the diffusion model, and we observe convergence over the entire range of $N$.  \nSchemes PA2 and PA2+ do not perform well on this test (for reasons discussed in Section~\\ref{sec:imex}).  \nFor $\\sigma_{\\Scatt}=10^{2}$, errors in $\\cJ$ and $\\cH_{x}$ decrease with increasing $N$, but for $\\sigma_{\\Scatt}=10^{4}$, errors remain constant with increasing $N$ over the entire range.  \n\n\\subsection{Packed Beam}\n\\label{sec:packedBeam}\n\nNext we consider a one-dimensional test with discontinuous initial conditions.  \nThe purpose of this test is to further gauge the accuracy of the two-moment model and demonstrate the robustness of the DG scheme for dynamics close to the boundary of the realizable set $\\cR$.  \nThe computational domain is $D=\\{x:x\\in[-1,1]\\}$, and the initial condition is obtained from a distribution function given by\n\\begin{equation}\n  f(x,\\mu)\n  =\\left\\{\n  \\begin{array}{cl}\n    1        & \\text{if} ~ x\\le x_{\\mbox{\\tiny D}}, ~ \\mu\\ge\\mu_{\\mbox{\\tiny D}} \\\\\n    \\delta & \\text{if} ~ x\\le x_{\\mbox{\\tiny D}}, ~ \\mu<   \\mu_{\\mbox{\\tiny D}} \\\\\n    \\delta & \\text{otherwise},\n  \\end{array}\n  \\right.\n\\end{equation}\nso that, with $\\mu_{\\mbox{\\tiny D}}=0$, $\\vect{\\cM}\\equiv\\vect{\\cM}_{\\mbox{\\tiny L}}=\\big(0.5\\,(1+\\delta),0.25\\,(1-\\delta)\\big)^{T}$ for $x\\le x_{\\mbox{\\tiny D}}$, and $\\vect{\\cM}\\equiv\\vect{\\cM}_{\\mbox{\\tiny R}}=\\big(\\delta,0\\big)^{T}$ for $x> x_{\\mbox{\\tiny D}}$, where $\\delta>0$ is a small parameter ($\\delta\\ll1$).  \nWe let $\\delta=10^{-8}$, so that the initial conditions are very close to the boundary of the realizable domain (cf. Figure~\\ref{fig:RealizableSetFermionic}).  \nThe analytical solution can be easily obtained by solving the transport equation for all angles $\\mu$ (independent linear advection equations), and taking the angular moments.  \nThe numerical results shown in this section were obtained with the third-order scheme (polynomials of degree $k=2$ and the SSPRK3 time stepper) using $400$ elements.  \nThe time step is set to $\\dt=0.1\\times\\dx$\n\nFigure~\\ref{fig:PackedBeam} shows results for various times obtained with the two-moment model.  \nIn the upper panels we plot the number density, while the number flux density is plotted in the lower panels.  \nNumerical solutions are plotted with solid lines, while the analytical solution is plotted with dashed lines.  \nIn the left panels, the algebraic maximum entropy closure of Cernohorsky \\& Bludman (CB) \\cite{cernohorskyBludman_1994} (cf. Eqs.~\\eqref{eq:eddingtonFactor} and \\eqref{eq:closureMECB}) was used, while in the right panels the Minerbo closure (cf. Eqs.~\\eqref{eq:eddingtonFactorLow} and \\eqref{eq:closureMECB}) was used.  \nFor this test, the use of the realizability-preserving limiter described in Section~\\ref{sec:limiter} was essential in order to avoid numerical problems.  \nFor the results obtained with the CB closure, the limiter was enacted whenever moments ventured outside the realizable set given by Eq.~\\eqref{eq:realizableSet}.  \nFor the results obtained with the Minerbo closure, which is not based on Fermi-Dirac statistics, we used a modified limiter, which was enacted when the moments ventured outside the realizable domain of positive distributions; i.e., not bounded by $f < 1$, so that $\\cJ > 0$ and $\\cJ > \\vect{\\cH}|$ (e.g., \\cite{levermore_1984}; see red line in Figure~\\ref{fig:RealizableSetFermionic}).  \n\n\\begin{figure}[H]\n  \\centering\n  \\begin{tabular}{cc}\n    \\includegraphics[width=0.5\\textwidth]{figures/PackedBeam_ME_CB} &\n    \\includegraphics[width=0.5\\textwidth]{figures/PackedBeam_ME_MI}\n  \\end{tabular}\n   \\caption{Numerical results from the packed beam problem at various times: $t=0$ (cyan), $t=0.2$ (magenta), $t=0.4$ (blue), and $t=0.8$ (black).  Results obtained with the Cernohorsky \\& Bludman closure are displayed in the left panels, while results obtained with the Minerbo closure are displayed in the right panels.  The analytical solution (dashed lines) is also plotted.}\n  \\label{fig:PackedBeam}\n\\end{figure}\n\nAs can be seen in Figure~\\ref{fig:PackedBeam}, with the CB closure the numerical solution obtained with the two-moment model tracks the analytic solution well, while with the Minerbo closure the numerical solution deviates substantially from the analytic solution.  \nWith the Minerbo closure, the solution also evolves outside the realizable domain for Fermi-Dirac statistics.  \n\nIn the left panel in Figure~\\ref{fig:PackedBeam_Realizability} we plot $\\gamma(\\vect{\\cM})=\\big(1-\\cJ\\big)\\,\\cJ-|\\vect{\\cH}|$ versus position for various times.  \nWith the Minerbo closure, $\\gamma(\\vect{\\cM})$ becomes negative in regions of the computational domain (dashed lines), while $\\gamma(\\vect{\\cM})$ remains positive for all $x$ and $t$ the CB closure.  \nIn the right panel of Figure~\\ref{fig:PackedBeam_Realizability} we plot the numerical solutions in the $(\\cH,\\cJ)$-plane.  \nInitially, the moments are located in two points: $\\vect{\\cM}_{\\mbox{\\tiny L}}$ and $\\vect{\\cM}_{\\mbox{\\tiny R}}$, for $x\\le0$ and $x>0$, respectively (marked by circles in Figure~\\ref{fig:PackedBeam_Realizability}).  \nFor $t>0$, the solutions trace out curves in the $(\\cH,\\cJ)$-plane, connecting $\\vect{\\cM}_{\\mbox{\\tiny L}}$ and $\\vect{\\cM}_{\\mbox{\\tiny R}}$.  \nWith the CB closure, the solution curve (blue points) follows the boundary of the realizable set $\\cR$ defined in Eq.~\\eqref{eq:realizableSet} (cf. black line in Figure~\\ref{fig:PackedBeam_Realizability}).  \nWith the Minerbo closure (magenta points), the solution follows a different curve --- outside the realizable domain for distribution functions bounded by $f\\in(0,1)$, but inside the realizable domain of positive distributions (cf. red line in Figure~\\ref{fig:PackedBeam_Realizability}).  \nWe have also run this test using the algebraic maximum entropy closure of Larecki \\& Banach \\cite{lareckiBanach_2011} and the simpler Kershaw-type closure in \\cite{banachLarecki_2017a}.  \nThe numerical solutions obtained with both of these closures follow the analytic solution well, and remain within the realizable set $\\cR$.  \nWe point out that simply using the realizability-preserving limiter described in Section~\\ref{sec:limiter} with the Minerbo closure does not result in a realizability-preserving scheme for Fermi-Dirac statistics because of the properties of this closure discussed in Section~\\ref{sec:algebraicClosure}, and plotted in the right panel of Figure~\\ref{fig:MabWithDifferentClosure}.  \n\n\\begin{figure}[H]\n  \\centering\n  \\begin{tabular}{cc}\n    \\includegraphics[width=0.485\\textwidth]{figures/PackedBeam_Realizability} &\n    \\includegraphics[width=0.485\\textwidth]{figures/PackedBeam_RealizableDomain}\n  \\end{tabular}\n   \\caption{In the left panel, $\\gamma(\\vect{\\cM})=(1-\\cJ)\\,\\cJ-|\\vect{\\cH}|$ is plotted versus $x$ for various times in the packed beam problem: $t=0$ (cyan), $t=0.2$ (magenta), $t=0.4$ (blue), and $t=0.8$ (black).  Results obtained with the CB closure, which remain positive throughout the evolution, are plotted with solid lines, while results obtained with the Minerbo closure are plotted with dashed lines.  In the right panel, the moments are plotted in the $(\\cH,\\cJ)$-plane for the same times as in the left panel.  Results obtained with the CB and Minerbo closures are plotted in blue and magenta, respectively.  The solid black and red lines are contours where $(1-\\cJ)\\,\\cJ=\\cH$ and $\\cJ=\\cH$, respectively.  The initial states are marked with black circles.}\n  \\label{fig:PackedBeam_Realizability}\n\\end{figure}\n\n\\subsection{Fermion Implosion}\n\\label{sec:fermionImplosion}\n\nThe next test is inspired by line source benchmark (cf. \\cite{brunner_2002,garrettHauck_2013}), which is a challenging test for approximate transport algorithms.  \nThe original line source test consists of an initial delta function particle distribution in radius $R=|\\vect{x}|$; i.e., $f_{0}=\\delta(R)$.  \nFor $t>0$, a radiation front propagates in the radial direction, away from $R=0$.  \nApart from capturing details of the exact transport solution, maintaining realizability of the two-moment solution is challenging.  \n\nHere, a modified version of the line source --- dubbed \\emph{Fermion Implosion},  designed to test the realizability-preserving properties of the two-moment model for fermion transport --- is computed on a two-dimensional domain $D=\\{\\vect{x}\\in\\bbR^{2}:x^{1}\\in[-1.28,1.28], x^{2}\\in[-1.28,1.28]\\}$.  \nInstead of initializing with a delta function, we follow the initialization procedure in \\cite{garrettHauck_2013}, and approximate the initial condition using an isotropic Gaussian distribution function.  \nHowever, different from \\cite{garrettHauck_2013}, the initial distribution function is bounded $f_{0}\\in(0,1)$, and reaches a minimum in the center of the computational domain (hence implosion)\n\\begin{equation}\n  f_{0}\n  =1-\\max\\Big[\\,e^{-R^{2}/(2\\,\\sigma_{0}^{2})},10^{-8}\\,\\Big].  \n\\end{equation}\nWe set $\\sigma_{0}=0.03$, and evolve to a final time of $t=1.0$.  \nWe run this test using a grid of $512^{2}$ elements, polynomials of degree $k=1$, and the SSPRK2 time stepping scheme with $\\dt=0.1\\times\\dx^{1}$.  \n(There are no collisions included in this test; i.e., $\\sigma_{\\Ab}=\\sigma_{\\Scatt}=0$.)  \nFor comparison, we present results using the algebraic closures of Cernohorsky \\& Bludman (CB) and Minerbo.  \n\n\\begin{figure}[H]\n  \\centering\n  \\begin{tabular}{cc}\n    \\includegraphics[width=0.495\\textwidth]{figures/Implosion_Image} &\n    \\includegraphics[width=0.495\\textwidth]{figures/Implosion_Lineout} \\\\\n    \\includegraphics[width=0.495\\textwidth]{figures/Implosion_RealizableDomain} &\n    \\includegraphics[width=0.495\\textwidth]{figures/Implosion_LimiterParameters}\n  \\end{tabular}\n   \\caption{Numerical results for the Fermion Implosion problem, computed both the CB and Minerbo closures.  Spatial distribution of the number density $\\cJ$ (CB closure only) at $t=1$ (upper left panel).  In the upper right panel we plot the number density $\\cJ$ versus radius $R=|\\vect{x}|$ for various times ($t=0$, $0.1$, $0.2$, and $0.4$) for the CB (blue), the Minerbo (magenta) closures, and the reference transport solution (dashed black lines).  (The initial condition, which is the same for all models, is plotted with cyan.)  Numerical solutions in the $(\\cH_{x},\\cJ)$-plane (lower left panel), for the same times as plotted in the upper right panel are plotted for CB and Minerbo.  Limiter parameters $\\vartheta_{1}$ (solid) and $\\vartheta_{2}$ (dashed) in Section~\\ref{sec:limiter} (minimum over the whole computational domain) versus time (lower right panel).}\n  \\label{fig:Implosion}\n\\end{figure}\n\nNumerical results for the Fermion Implosion problem are plotted in Figure~\\ref{fig:Implosion}.  \nFor $t>0$, the low-density region in the center of the computational domain is quickly filled in, and a cylindrical perturbation propagates radially away from the center.  \nFor the model with the CB closure, this perturbation, seen as a depression in the density relative to the ambient medium, has reached $R\\approx1$ for $t=1$ (upper left panel in Figure~\\ref{fig:Implosion}).  \nThe right panel in Figure~\\ref{fig:Implosion} illustrates the difference in dynamics resulting from the two closures.  \n(We also plot a reference transport solution obtained using the filtered spherical harmonics scheme described in \\cite{garrettHauck_2013}; dashed black lines.\\footnote{Kindly provided by Dr. Ming Tse Paul Laiu (private communications).})  \nWith the CB closure (blue lines), the central density increases towards the maximum value of unity, and an low-density pulse propagates radially.  \nThe amplitude of the pulse decreases with time due to the geometry of the problem.  \nFor $t=0.4$, the peak depression in located around $R=0.34$ (with $\\cJ\\approx0.96$).  \nWith the Minerbo closure, the central density continues to increase beyond unity, and reaches a maximum of about $\\cJ\\approx1.37$ at $t=0.1$.  \nThe central density starts to decrease beyond this point in time, and a steepening pulse propagates radially away from the center.  \n(This pulse is trailing the pulse in the model computed with the CB closure.)  \nAt $t=0.4$, a discontinuity appears to have formed around $R=0.2$, resulting in numerical oscillations.  \nExcept for the realizability-enforcing limiter (which is not triggered for this model), no other limiters are used to prevent numerical oscillations.  \nAlthough the solutions obtained with the two-moment model differ from the reference transport solution, the results obtained with the CB closure are in closer agreement with the transport solution.  \nThis is likely because the CB closure is consistent with the bound $f<1$ satisfied by the transport solution in this test.  \n(For tests involving lower occupancies, the CB and Minerbo closures are expected to perform similarly.)  \nIn the lower left panel in Figure~\\ref{fig:Implosion}, the moments are plotted in the $(\\cH_{x},\\cJ)$-plane for the same times as plotted in the upper left panel.  \n(Each dot represents the moments at a specific spatial point and time.)  \nInitially, $\\vect{\\cH}=0$, and all the moments lie on the line connecting $(0,0)$ and $(0,1)$; cyan points.  \nWith the CB closure (blue points), the moments are confined to evolve inside the realizable domain $\\cR$ (black), while with the Minerbo closure, the moments are not confined to $\\cR$, but to the region above the red lines (the realizable domain for moments of positive distribution functions), and this is the reason for the difference in dynamics in the two models.  \nFor the model with the CB closure, some moments evolve very close to the boundary of the realizable domain, and the positivity limiter is continuously triggered to damp these moments towards the cell average, which is realizable by the design of the numerical scheme.  \nIn the lower right panel in Figure~\\ref{fig:Implosion} we plot the limiter parameters $\\vartheta_{1}$ (solid) and $\\vartheta_{2}$ (dashed) (cf. \\eqref{eq:limitDensity} and \\eqref{eq:limitMoments}) versus time for the CB closure model (blue) and the Minerbo closure model (magenta); the minimum over the whole computational domain is plotted.  \nFor the CB closure model, the limiter is triggered to prevent both density overshoots and $\\gamma(\\cM)<0$.  \nLate in the simulation ($t\\gtrsim0.7$), the minimum value of $\\vartheta_{2}$ is around $0.1$.  \nFor the model using the Minerbo closure, the limiter is not triggered ($\\vartheta_{1}=\\vartheta_{2}=1$).  \n\n\\subsection{Homogeneous Sphere}\n\\label{sec:homogeneousSphere}\n\nThe homogeneous sphere test (e.g., \\cite{smit_etal_1997}) considers a sphere with radius $R$.  \nInside the sphere (radius $<R$), the absorption opacity $\\sigma_{\\Ab}$ and the equilibrium distribution function $f_{0}$ are set to constant values.  \nThe scattering opacity $\\sigma_{\\Scatt}$ is set to zero in this test (i.e., $\\xi=1$).  \nOutside the sphere, the absorption opacity is zero.  \nThe steady state solution, obtained by solving the transport equation in spherical symmetry, is given by\n\\begin{equation}\n  f_{\\mbox{\\tiny A}}(r,\\mu)=f_{0}\\,\\big(1-e^{-\\chi_{0}\\,s(r,\\mu)}\\big),\n  \\label{eq:distributionHomogeneousSphere}\n\\end{equation}\nwhere $r=|\\vect{x}|$, \n\\begin{equation}\n  s(r,\\mu)\n  =\\left\\{\n  \\begin{array}{lll}\n    r\\,\\mu+R\\,g(r,\\mu) & \\mbox{if}\\quad r<R, & \\mu\\in[-1,+1], \\\\\n    2\\,R\\,g(r,\\mu) & \\mbox{if}\\quad r \\ge R, & \\mu\\in[(1-(R/r)^{2})^{1/2},+1], \\\\\n    0 & \\mbox{otherwise},\n  \\end{array}\n  \\right.\n\\end{equation}\nand $g(r,\\mu)=[1-(r/R)^{2}(1-\\mu^{2})]^{1/2}$.  \nThus, $f_{\\mbox{\\tiny A}}(r,\\mu)\\in(0,f_{0})~\\forall~r,\\mu$.  \n\nHere, this test is computed using a three-dimensional Cartesian domain $D=\\{\\vect{x}\\in\\bbR^{3}:x^{1}\\in[0,2], x^{2}\\in[0,2], x^{3}\\in[0,2]\\}$.  \nBecause of the symmetry of the problem, and to save computational resources, we only compute the solution in one octant.  \nOn the inner boundaries, we impose reflecting boundary conditions, while we impose 'homogeneous' boundary conditions on the outer boundary in all three coordinate dimensions; i.e., values for all moments in a boundary element are set equal to the corresponding values in the nearest element just inside $D$.  \nSince this test is computed with Cartesian coordinates using a relatively low spatial resolution ($64^{3}$), we have found it necessary to smooth out the opacity over a finite radial extent to avoid numerical artifacts due to a discontinuous absorption opacity.  \nSpecifically, we use an absorption opacity of the following form\n\\begin{equation}\n  \\sigma_{\\Ab}(r)=\\f{\\sigma_{\\Ab,0}}{(r/R_{0})^{p}+1}.  \n\\end{equation}\nWe set $f_{0}=1$, and compute three versions of this test: one with $\\sigma_{\\Ab,0}=1$, $R_{0}=1$, and $p=80$ (Test~A), one with $\\sigma_{\\Ab,0}=10$, $R_{0}=1$, and $p=80$ (Test~B), and one with $\\sigma_{\\Ab}=10^{3}$, $R_{0}=0.85$, and $p=40$ (Test~C).  \n(These values for $R_{0}$ and $p$ result in similar radius for where the optical depth equals $2/3$ in Test~B and Test~C.)\nWe compute until $t=5$, when the system has reached an approximate steady state.  \nIn all the tests, we use the IMEX scheme PD-ARS with $\\dt=0.1\\times\\dx^{1}$ --- the least compute-intensive of the convex-invariant IMEX schemes presented here.  \nThe main purpose of this test is to compare the results obtained using the different algebraic closures discussed in Section~\\ref{sec:algebraicClosure}.  \n\nIn Figure~\\ref{fig:HomogeneousSphere}, we plot results obtained for all tests at $t=5$: Test~A (top panels), Test~B (middle panels), and Test~C (bottom panels).  \nThe particle density $\\cJ$ and the flux factor $h=|\\vect{\\cH}|/\\cJ$ (left and right panels, respectively) are plotted versus radius $r=|\\vect{x}|$.  \nIn each panel, results obtained with the various algebraic closures discussed in Section~\\ref{sec:algebraicClosure} are plotted: Minerbo (magenta), CB (blue), BL (green), and Kershaw (cyan).  \nThe analytical solution is also plotted (dashed black lines).  \n\\begin{figure}[H]\n  \\centering\n  \\begin{tabular}{cc}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e0_Density}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e0_FluxFactor} \\\\\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e1_Density}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e1_FluxFactor} \\\\\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e3_Density}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_ClosureComparison_Chi_1e3_FluxFactor}\n  \\end{tabular}\n   \\caption{Results obtained for the homogeneous sphere problem with the two-moment model for different values of the absorption opacity $\\sigma_{\\Ab,0}$: $1$ (top panels), $10$ (middle panels), and $1000$ (bottom panels).  The particle density (left panels) and the flux factor (right panels) are plotted versus radius.  Numerical results obtained with the algebraic closures of Minerbo (magenta), CB (blue), BL (green), and Kershaw (cyan) are compared with the analytic solution (dashed black lines).}\n  \\label{fig:HomogeneousSphere}\n\\end{figure}\n\nWe find good overall agreement between the results obtained with the two-moment model and the analytical solution.  \nPartly due to the smoothing of the absorption opacity around the surface, the numerical and analytical solutions naturally differ around $r=1$.  \nAside from some differences discussed in more detail below, the numerical and analytical solutions --- for all values of the absorption opacity $\\sigma_{\\Ab,0}$ and all closures --- agree well as $r$ tends to zero, as well as when $r\\gg1$.  \nThe results obtained with the maximum entropy closures CB and BL are practically indistinguishable on the plots.  \nThis is consistent with the similarity of the Eddington factors for these two closures, as shown in Figure~\\ref{fig:EddingtonFactorsWithDifferentClosure}.  \nWe also find that the results obtained with the fermionic Kershaw closure agree well with the maximum entropy closures based on Fermi-Dirac statistics (CB and BL).  \nFrom the plots of the particle density (left panels in Figure~\\ref{fig:HomogeneousSphere}), the results obtained with all the closures, including Minerbo, appear very similar.  \n(For Test~A, the particle density obtained with the Minerbo closure deviates the most from the analytic solution inside $r\\approx0.75$; upper left panel).  \nFrom the plots of the flux factor (right panels in Figure~\\ref{fig:HomogeneousSphere}), it is evident that the results obtained with the Minerbo closure --- the only closure not based on Fermo-Dirac statistics --- deviates the most from the analytic solution outside $r=1$, where the flux factor is consistently higher than the analytical solution for all values of $\\sigma_{\\Ab,0}$.  \nThe fermionic closures (CB, BL, and Kershaw) track the analytic solution better.  \nSimilar agreement between the numerical and analytical solutions was reported by Smit et al. \\cite{smit_etal_1997}, when using the CB maximum entropy closure with $f_{0}=0.8$ and an unsmoothed absorption opacity $\\sigma_{\\Ab}=4$.  \nWe also note that our results appear to be somewhat at odds with the results recently reported by Murchikova et al. \\cite{murchikova_etal_2017}, who compared results obtained with the two-moment model using a large number of algebraic closures for this same problem (albeit using an unsmoothed and slightly different value for the absorption opacity).  \nMurchikova et al. do not plot the particle density, but find essentially no difference in the flux factor and the Eddington factor when comparing results obtained with the maximum entropy closures of Minerbo and Cernohorsky \\& Bludman (CB).  \n\nIn Figure~\\ref{fig:HomogeneousSphereRealizability}, we further compare the results obtained when using the Minerbo and CB closures by plotting the solutions to the homogeneous sphere problem for Test~C at $t=5$ in the $(|\\vect{\\cH}|,\\cJ)$-plane (cf. the realizable domain in Figure~\\ref{fig:RealizableSetFermionic}).  \nThe numerical solution at each spatial point is represented by a blue (CB) or magenta (Minerbo) dot in the panels.  \nIn the lower two panel we zoom in on the results obtained with the two closures around the top and lower right regions of the realizable domain (lower left and lower right panel, respectively; cf. green boxes in the upper right panel).  \n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=1.0\\textwidth]{figures/HomogeneousSphere_Realizability_Chi_1e3_CBandMinerbo}\n  \\begin{tabular}{cc}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_Realizability_Chi_1e3_CBandMinerbo_Box1}\n    \\includegraphics[width=0.5\\textwidth]{figures/HomogeneousSphere_Realizability_Chi_1e3_CBandMinerbo_Box2}\n  \\end{tabular}\n   \\caption{Scatter plots of the numerical solution to the homogeneous sphere problem for Test~C in the $(|\\vect{\\cH}|,\\cJ)$-plane.  Results obtained with the CB and Minerbo closures are plotted in the upper panel, blue and magenta points, respectively.  Zoom-ins on the solutions obtained with the two closures are plotted in the lower two panels (cf. green boxes in the upper panel).  The boundaries of the realizable domains $\\cR$ and $\\cR^{+}$ are indicated with solid black and solid red curves, respectively.  See text for further details.  }\n  \\label{fig:HomogeneousSphereRealizability}\n\\end{figure}\nAs can be seen in the upper panel in Figure~\\ref{fig:HomogeneousSphereRealizability}, the solutions to the homogeneous sphere problem obtained with the two closures trace out distinct curves relative to the realizable domain $\\cR$, whose boundary is indicated by solid black curves in each panel.  \nWhen using the CB closure, the realizability-preserving DG-IMEX scheme developed here maintains solutions within $\\cR$.  \nWhen using the Minerbo closure, the appropriate realizable domain is given by $\\cR^{+}$ (cf. Eq.~\\eqref{eq:realizableSetPositive}), whose boundary is indicated by solid red lines in Figure~\\ref{fig:HomogeneousSphereRealizability}, and we find that the numerical solution ventures outside $\\cR$.  \nNear the surface around $r=1$, the number density slightly exceeds unity (lower left panel), while for larger radii, the computed flux may exceed the value allowed by Fermi-Dirac statistics (lower right panel).  ", "meta": {"hexsha": "0944d210cc7bf877cc03d51fd5381e30bd4e0b97", "size": 35295, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/realizableFermionicM1/sections/numerical.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/realizableFermionicM1/sections/numerical.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/realizableFermionicM1/sections/numerical.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 102.9008746356, "max_line_length": 874, "alphanum_fraction": 0.7493129338, "num_tokens": 9807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4380461525545998}}
{"text": "\\documentclass[a4paper, 12pt]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\n\\usepackage[]{amsfonts}\n\\usepackage[]{graphicx}\n\n\\title{CS231A Course Notes 5: Active and Volumetric Stereo}\n\\author{Kenji Hata and Silvio Savarese}\n\\date{}\n\n\\renewcommand\\emph{\\textbf}\n\n\\numberwithin{equation}{section}\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\nIn traditional stereo, the main idea is to use corresponding points $p$ and $p'$ to estimate the location of a 3D point $P$ by triangulation. A key challenge here, is to solve the correspondence problem: how do we know whether a point $p$ actually corresponds to a point $p'$ in another image? This problem is further accentuated by the fact that we need to handle the many 3D points that are present in the scene. The focus of these notes will discuss alternative techniques that work well in reconstructing the 3D structure.\n\n\\section{Active stereo}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/active_stereo_setup.png}\n    \\caption{The active stereo setup that projects a point into 3D space.}\n    \\label{fig:active_stereo_setup}\n\\end{figure}\n\nFirst, we will an introduce a technique known as \\emph{active stereo} that helps mitigate the correspondence problem in traditional stereo. The main idea of active stereo is to replace one of the two cameras with a device that interacts with the 3D environment, usually by projecting a pattern onto the object that is easily identifiable from the second camera.  This new projector-camera pair defines the same epipolar geometry that we introduced for camera pairs, whereby the image plane of the replaced camera is replaced with a \\emph{projector virtual plane}. In Figure~\\ref{fig:active_stereo_setup}, the projector is used to project a point $p$ in the virtual plane onto the object in 3D space, producing a point in 3D space $P$. This 3D point $P$ should be observed in the second camera as a point $p'$. Because we know what we are projecting (e.g. the position of $p$ in the virtual plane, the color and intensity of the projection, etc.), we can easily discover the corresponding observation in the second camera $p'$. \n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/active_stereo_line.png}\n    \\caption{The active stereo setup that projects a line into 3D space.}\n    \\label{fig:active_stereo_line}\n\\end{figure}\n\nA common strategy in active stereo is to project from the virtual plane a vertical stripe $s$ instead of a single point. This case is very similar to the point case, where the line $s$ is projected to a stripe in 3D space $S$ and observed as a line in the camera as $s'$. If the projector and camera are parallel or rectified, then we can discover the corresponding points easily by simply intersecting $s'$ with the horizontal epipolar lines. From the correspondences, we can use the triangulation methods introduced in the previous course notes to reconstruct all the 3D points on the stripe $S$. By swiping the line across the scene and repeating the process, we can recover the entire shape of all visible objects in the scene. \n\nNotice that one requirement for this algorithm to work is that the projector and the camera need to be calibrated. An active stereo system can be calibrated using similar techniques as described in previous notes. We can first calibrate the camera using a calibration rig. Then, by projecting known stripes onto the calibration rig, and using the corresponding observations in the newly calibrated camera, we can set up constraints for estimating the projector intrinsic and extrinsic parameters. Once calibrated, this active stereo setup can produce very accurate results. In 2000, Marc Levoy and his students at Stanford demonstrated that by using a finely tuned laser scanner, they could recover the shape of Michaelangelo's Pieta with sub-millimeter accuracy.\n\nHowever, in some cases, having a finely tuned projector may be too expensive or cumbersome. An alternative approach that uses a much cheaper setup leverages shadows to produce active patterns to the object we want to recover. By placing a stick between the object and a light source at a known position, we can effectively project a stripe onto the object as before. Moving the stick allows us to project different shadow stripes onto the object and recover the object in a similar manner as before. This method, although much cheaper, tends to produce less accurate results because it requires very good calibration between the stick, camera, and light source, while needing to maintain a tradeoff between the length and thinness of the stick's shadow.\n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/active_multicolor_setup.png}\n    \\caption{The active stereo setup that uses multiple colored lines to reconstruct an object from a single projection.}\n    \\label{fig:active_multicolor_setup}\n\\end{figure}\n\nOne limitation of projecting a single stripe onto objects is that it is rather slow, as the projector needs to swipe across the entire object. Furthermore, this means that this method cannot capture deformations in real time. A natural extension is to instead attempt to reconstruct the object from projecting a single frame or image. The idea is to project a known pattern of different stripes to the entire visible of the object, instead of a single stripe. The colors of these stripes are designed in such a way that the stripes can be uniquely identified from the image. Figure~\\ref{fig:active_multicolor_setup} illustrates this multiple color-coded stripes method. This concept powered many versions of modern depth sensors, such as the original version of the Microsoft Kinect. In practice, these sensors use infrared laser projectors , which  allow it to capture video data in 3D under any ambient light conditions. \n\n\\section{Volumetric stereo}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/volumetric_setup.png}\n    \\caption{The setup of volumetric stereo, which takes points from a limited, working volume and performs consistency checks to determine 3D shape.}\n    \\label{fig:volumetric_setup}\n\\end{figure}\nAn alternative to both the traditional stereo and active stereo approach is \\emph{volumetric stereo}, which inverts the problem of using correspondences to find 3D structure. In volumetric stereo, we assume that the 3D point we are trying to estimate is within some contained, known volume. We then project the hypothesized 3D point back into the calibrated cameras and validate whether these projections are consistent across the multiple views. Figure~\\ref{fig:volumetric_setup} illustrates the general setup of the volumetric stereo problem. Because these techniques assume that the points we want to reconstruct are contained by a limited volume, these techniques are mostly used for recovering the 3D models of specific objects as opposed to recovering models of a scene, which may be unbounded. \n\nThe main tenet of any volumetric stereo method is to first define what it means to be ``consistent'' when we reproject a 3D point in the contained volume back into the multiple image views. Thus, depending on the definition of the concept of consistent observations, different techniques can be introduced. In these notes, we will briefly outline three major techniques, which are known as space carving, shadow carving, and voxel coloring.\n\n\\subsection{Space carving}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/visual_cone.png}\n    \\caption{The silhouette of an object we want to reconstruct contains all pixels of the visible portion of the object in the image. The visual cone is the set of all possible points that can project into the silhouette of the object in the image.}\n    \\label{fig:visual_cone}\n\\end{figure}\nThe idea of space carving is mainly derived from the observation that the contours of an object provide a rich source of geometric information about the object. In the context of multiple views, let us first set up the problem illustrated in Figure~\\ref{fig:visual_cone}. Each camera observes some visible portion of an object, from which a contour can be determined. When projected into the image plane, this contour encloses a set of pixels known as the \\emph{silhouette} of the object in the image plane. Space carving ultimately uses the silhouettes of objects from multiple views to enforce consistency.\n\nHowever, if we do not have the information of the 3D object and only images, then how can we obtain silhouette information? Luckily, one practical advantage of working with silhouettes is that they can be easily detected in images if we have control of the background behind the object that we want to reconstruct. For example, we can use a ``green screen\" behind the object to easily segment the object from its background.\n\nNow that we have the silhouettes, how can we actually use them? Recall that in volumetric stereo, we have an estimate of some volume that we guarantee that the object can reside within. We now introduce the concept of a \\emph{visual cone}, which is the enveloping surface defined by the camera center and the object contour in the image plane. By construction, it is guaranteed that the object will lie completely in both the initial volume and the visual cone. \n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/visual_hull.png}\n    \\caption{The process of estimating the object from multiple views involves recovering the visual hull, which is the intersection of visual cones from each camera.}\n    \\label{fig:visual_hull}\n\\end{figure}\n\nTherefore, if we have multiple views, then we can compute visual cones for each view. Since, by definition, the object resides in each of these visual cones, then it must lie in the intersection of these visual cones, as illustrated in Figure~\\ref{fig:visual_hull}. Such an intersection is often called a \\emph{visual hull}. \n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/space_carving.png}\n    \\caption{The result of space carving when done on a voxel grid. The region is the reconstructed object after carving from two views, while the shaded part on the inside is the actual object. Notice that the reconstruction is always conservative.}\n    \\label{fig:space_carving}\n\\end{figure}\n\nIn practice, we first begin by defining a working volume that we know the object is contained within. For example, if our cameras encircle the object, then we can simply say that the working volume is the entire interior of the space enclosed by the cameras. We divide this volume into small units known as \\emph{voxels}, defining what is known as a voxel grid. We take each voxel in the voxel grid and project it into each of the views. If the voxel is not contained by the silhouette in a view, then it is discarded. Consequently, at the end of the space carving algorithm, we are left with the voxels that are contained within the visual hull.\n\nAlthough the space carving method avoids the correspondence problem and is relatively straightforward, it still has many limitations. One limitation of space carving is that it scales linearly with the number of voxels in the grid. As we reduce the size of each voxel, the number of voxels required by the grid increases cubically. Therefore, to get finer reconstruction results in much larger run time. However, some methods such as using octrees can be used mitigate this problem. Related, but simpler methods include doing iterative carvings to reduce the size of the initial voxel grid. \n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/concavity.png}\n    \\caption{Space carving cannot handle some concavities, as demonstrated here, because it cannot carve into that region, as doing so will carve through the object. Note this means that generally the only concavities that space carving can handle are holes through an object. }\n    \\label{fig:concavity}\n\\end{figure}\n\nAnother limitation is that the efficacy of space carving is dependent on the number of views, the preciseness of the silhouette, and even the shape of the object we are trying to reconstruct. If the number of views is too low, then we end of up with a very loose estimate of the visual hull of the object. As the number of views increases, the more extraneous voxels can be removed by the consistency check. Furthermore, the validity of the consistency check is solely upheld by the fact that we believe that the silhouettes are correct. If the silhouette is too conservative and contains more pixels than necessary, then our carving may not be precise. In a potentially even worse case, the silhouette misses portions of the actual object, resulting in a reconstruction that is overly carved. Finally, a major drawback of space carving is that it is incapable of modeling certain concavities of an object, as shown in Figure~\\ref{fig:concavity}.\n\n\\subsection{Shadow carving}\nTo circumvent the concavity problem posed by space carving, we need to look to other forms of consistency checks. One important cue for determining the 3D shape of an object that we can use is the presence of \\emph{self-shadows}. Self-shadows are the shadows that an object projects on itself. For the case of concave objects, an object will often cast self-shadows in the concave region. \n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/shadow_carving.png}\n    \\caption{The setup of shadow carving, which augments space carving by adding a new consistency check from an array of lights surrounding the camera.}\n    \\label{fig:shadow_carving}\n\\end{figure}\n\n\\emph{Shadow carving} at its core augments space carving with the idea of using self-shadows to better estimate the concavities. As shown in Figure~\\ref{fig:shadow_carving}, the general setup of shadow carving is very similar to space carving. An object is placed in a turntable that is viewed by a calibrated camera. However, there is an array of lights in known positions around the camera whose states can be appropriately turned on and off. These lights will be used to make the object cast self-shadows.\n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/shadow_carving_detailed.png}\n    \\caption{Shadow carving relies on a new consistency check that removes voxels that are in the self-shadow visual cone of the camera and the visual cone of the light.}\n    \\label{fig:shadow_carving_detailed}\n\\end{figure}\n\nAs shown in Figure~\\ref{fig:shadow_carving_detailed}, the shadow carving process begins with an initial voxel grid, which is trimmed down by using the same approach as in space carving. However, in each view, we can turn on and off each light in the array surrounding the camera. Each light will produce a different self-shadow on the object. Upon identifying the shadow in the image plane, we can then find the voxels on the surface of our trimmed voxel grid that are in the visual cone of the shadow. These surface voxels allow us to then make a new visual cone with the image source. We then leverage the useful fact that a voxel that is part of both visual cones cannot be part of the object to eliminate voxels in the concavity. \n\nLike space carving, the runtime of shadow carving is dependent on the resolution of the voxel grid. The runtime scales cubically with the resolution of the voxel grid. However, if there are $N$ lights, then shadow carving takes approximately $N+1$ times longer than space carving, as each voxel needs to be projected into the camera and each of the $N$ lights can be turned on and off.\n\nIn summary, shadow carving always produces a conservative volume estimate that better reconstructs 3D shapes with concavities. The quality of the results depends on both the number of views and the number of light sources. Some disadvantages of this approach are that it cannot handle cases where the object contains reflective or low albedo regions. This is because shadows cannot be detected accurately in such conditions.\n\n\\subsection{Voxel coloring}\nThe last technique we cover in volumetric stereo is \\emph{voxel coloring}, which uses color consistency instead of contour consistency in space carving.\n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.8\\textwidth]{figures/voxel_coloring.png}\n    \\caption{The setup of voxel coloring, which makes a consistency check of the color of all projections of a voxel.}\n    \\label{fig:voxel_coloring}\n\\end{figure}\n\nAs illustrated in Figure~\\ref{fig:voxel_coloring}, suppose that we are given images from multiple views of an object that we want to reconstruct. For each voxel, we look at its corresponding projections in each of the images and compare the color of each of these projections. If the colors of these projections sufficiently match, then we mark the voxel as part of the object. One benefit of voxel coloring not present in space carving is that color associated with the projections can be transferred to the voxel, giving a colored reconstruction.\n\nOverall, there are many methods that one could use for the color consistency check. One example would be to set a threshold between the color similarity between the projections. However, there exists a critical assumption for any color consistency check used: the object being reconstructed must be \\emph{Lambertian}, which means that the perceived luminance of any part of the object does not change with viewpoint location or pose. For non-Lambertian objects, such as those made of highly reflective material, it is easy to conceive that the color consistency check would fail on voxels that are actually part of the object.\n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width = 0.4\\textwidth]{figures/ambiguity1.png}\n    \\includegraphics[width = 0.4\\textwidth]{figures/ambiguity2.png}\n    \\caption{An example of an ambiguous case of vanilla voxel coloring.}\n    \\label{fig:ambiguity}\n\\end{figure}\n\nOne drawback of vanilla voxel coloring is that it produces a solution that is not necessarily unique, as shown in Figure~\\ref{fig:ambiguity}. Finding the true, unique solution complicates the problem of reconstruction by voxel coloring. It is possible to remove the ambiguity in the reconstruction by introducing a visibility constraint on the voxel, which requires that the voxels be traversed in a particular order. \n\nIn particular, we want to traverse the voxels layer by layer, starting with voxels closer to the cameras and then progress to further away voxels. When using this order, we perform the color consistency check. Then, we check if the voxel is viewable by at least two of the cameras, which constructs our visibility constraint. If the voxel was not viewable by at least two cameras, then it must be occluded and thus not part of the object. Notice that our order of processing the closer voxels allows us to make sure that we keep the voxels that can occlude later processed voxels to enforce this visibility constraint. \n\nTo conclude, voxel coloring has the advantage of simultaneously capturing the shape and texture of an object. Some of the drawbacks include that the object is assumed to be Lambertian and that the cameras cannot be in certain locations, as the voxels need to be processed in a certain order due to the visibility constraint.\n\\end{document}\n", "meta": {"hexsha": "70708ce2c1a5e4febd552e75a2fe73bfc55f14ab", "size": 19449, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "05-active-volumetric-stereo/05-active-volumetric-stereo.tex", "max_stars_repo_name": "zishanqin/cs231a-notes", "max_stars_repo_head_hexsha": "b864cfb7c472573ec1fb7da780748348fc320dab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 287, "max_stars_repo_stars_event_min_datetime": "2017-04-03T00:30:48.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T03:52:04.000Z", "max_issues_repo_path": "05-active-volumetric-stereo/05-active-volumetric-stereo.tex", "max_issues_repo_name": "zishanqin/cs231a-notes", "max_issues_repo_head_hexsha": "b864cfb7c472573ec1fb7da780748348fc320dab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-06-26T11:23:10.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-16T09:00:43.000Z", "max_forks_repo_path": "05-active-volumetric-stereo/05-active-volumetric-stereo.tex", "max_forks_repo_name": "zishanqin/cs231a-notes", "max_forks_repo_head_hexsha": "b864cfb7c472573ec1fb7da780748348fc320dab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 112, "max_forks_repo_forks_event_min_datetime": "2017-04-09T10:44:14.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T09:19:59.000Z", "avg_line_length": 120.801242236, "max_line_length": 1027, "alphanum_fraction": 0.7955678955, "num_tokens": 4267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4380461525545997}}
{"text": "\\documentclass[10pt, compress]{beamer}\n\n\\usetheme{amii}\n\n\\usepackage[scale=2]{ccicons}\n\\usepackage{booktabs}\n\\usepackage{minted}\n\\usepackage{tikz}\n\n\\usemintedstyle{trac}\n\\usetikzlibrary{arrows,automata,shapes.geometric,shapes.multipart}\n\n\\title{{\\large Comparing Direct and Indirect Temporal-Difference Methods for Estimating the Variance of the Return}}\n\\subtitle{}\n\\date{\\vspace{-0.5em}}\n\\author{Craig Sherstan, Dylan R. Ashley$^{*}$, Brendan Bennett$^{*}$, Kenny Young, \\newline\n        Adam White, Martha White, Richard S. Sutton}\n\\institute{Reinforcement Learning and Artificial Intelligence Laboratory, University of Alberta}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Background}\n\n\\begin{frame}{What is reinforcement learning?}\n    Reinforcement learning considers an agent interacting with an environment:\n\n    \\begin{figure}\n        \\centering\n        \\includegraphics[height=8em]{{images/reinforcement_learning.pdf}}\n    \\end{figure}\n\n    The function the agent uses to pick actions in states is known as the policy. Often the challenge is to find a \"good\" policy.\n\\end{frame}\n\n\\begin{frame}{What is a good policy?}\\vspace{1em}\n    In reinforcement learning the return is defined as follows:\n    \\begin{equation*}\n        G_{\\,t} = R_{\\,t + 1} + \\gamma_{\\,t + 1} \\,R_{\\,t + 2} + \\gamma_{\\,t + 1} \\,\\gamma_{\\,t + 2} \\,R_{\\,t + 3} + \\ldots\n    \\end{equation*}\n\n    Often we want to maximize the \\alert{expected value} of the return. But \"good\" does depend on what we want.\n\\end{frame}\n\n\\begin{frame}{How can we learn it's expected value?}\\vspace{1em}\n    Temporal-difference (TD) methods have been fairly successful in tackling reinforcement learning problems so far. TD methods use predictions to update predictions.\n\n    \\vspace{1em}\n    One of the most straightforward TD methods is TD($\\lambda$):\n    \\begin{align*}\n        \\delta_{\\,t} &= R_{\\,t + 1} + \\gamma_{\\,t + 1} \\,w_{\\,t}^{\\,T} \\,x_{\\,t + 1} - w_{\\,t}^{\\,T} \\,x_{\\,t} \\\\\n        z_{\\,t} &= \\gamma_{\\,t} \\,\\lambda_{\\,t} \\,z_{\\,t - 1} + x_{\\,t} \\\\\n        w_{\\,t + 1} &= w_{\\,t} + \\alpha_{\\,t + 1} \\,\\delta_{\\,t} \\,z_{\\,t} \\\\\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}{So what's this presentation about?}\\vspace{1em}\n    Recall what the return is:\n    \\begin{equation*}\n        G_{\\,t} = R_{\\,t + 1} + \\gamma_{\\,t + 1} \\,R_{\\,t + 2} + \\gamma_{\\,t + 1} \\,\\gamma_{\\,t + 2} \\,R_{\\,t + 3} + \\ldots\n    \\end{equation*}\n\n    We're not limited to learning only it's expected value. We could also learn more parts of its distribution such as its \\alert{variance}.\n\\end{frame}\n\n\\section{Motivation}\n\n\\begin{frame}{Why might we want to learn its variance?}\n    The variance might tell us things about the distribution that the expected value can't. Sometimes these things are \\alert{interesting}. For example it could differentiate these two domains:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\centering\n        \\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm,semithick]\n\n            \\tikzstyle{every state}=[draw=black,text=black]\n            \\tikzstyle{every text node part}=[align=center]\n            \\tikzstyle{terminal}=[regular polygon,regular polygon sides=4,thick,minimum size=1.5cm,draw=black]\n\n            \\node[initial,state] (0)              {$s_0$};\n            \\node[terminal]      (1) [right of=0] {};\n\n            \\small\n            \\draw[-latex]  (0) edge node [align=center,above] {\\(R_{\\,t + 1} = 0\\)} (1);\n        \\end{tikzpicture}\n    \\end{figure}\n\n    \\begin{figure}\n        \\centering\n        \\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm,semithick]\n\n            \\tikzstyle{every state}=[draw=black,text=black]\n            \\tikzstyle{every text node part}=[align=center]\n            \\tikzstyle{terminal}=[regular polygon,regular polygon sides=4,thick,minimum size=1.5cm,draw=black]\n\n            \\node[initial,state] (0)              {$s_0$};\n            \\node[terminal]      (1) [right of=0] {};\n\n            \\small\n            \\draw[-latex]  (0) edge node [align=center,above] {\\(R_{\\,t + 1} = \\mathcal{N}(0, 1)\\)} (1);\n        \\end{tikzpicture}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Any better reasons?}\n    The variance can give us \\alert{useful} information about the distribution. It can tell us how risky an action is to take in a state.\n\n    \\vspace{1em}\n    Humans take risk into decisions and don't necessarily act in a way that maximizes the expected value.\n\\end{frame}\n\n\\begin{frame}{Anything else?}\n    We can use an estimate of the variance to \\alert{learn} how to learn. For example here is an algorithm that uses an estimate of the variance to tune $\\lambda$ on the fly:\n\n    \\begin{figure}\n        \\centering\n        \\href{https://arxiv.org/abs/1607.00446}{\\includegraphics[height=15em]{{images/lambda_greedy.png}}}\n    \\end{figure}\n\\end{frame}\n\n\\section{Learning the Variance}\n\n\\begin{frame}{How can we learn its variance?}\n    We can use this identity:\n    \\begin{equation*}\n        Var(X) = \\mathbb{E}\\big[X^{\\,2}\\big] - \\big(\\mathbb{E}\\big[X\\big]\\big)^2\n    \\end{equation*}\n\n    If we are learning \\(\\mathbb{E}_{\\pi} [G_{\\,t} \\,|\\, S_{\\,t} = s]\\) then we can just learn \\(\\mathbb{E}_{\\pi} [G_{\\,t}^{\\,2} \\,|\\, S_{\\,t} = s]\\) on the side and use both our estimates to try to estimate \\(Var_{\\pi}(G_{\\,t} \\,|\\, S_{\\,t} = s)\\).\n\\end{frame}\n\n\\begin{frame}{What would this look like?}\n   Using the identity \\(Var(X) = \\mathbb{E}\\big[X^{\\,2}\\big] - \\big(\\mathbb{E}\\big[X\\big]\\big)^2\\) one can estimate the variance using the following structure:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[height=8em]{{images/indirect.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Is there another way?}\n    We can also use this identity:\n    \\begin{equation*}\n        Var(X) = \\mathbb{E}\\big[\\big(X - \\mathbb{E}\\big[X\\big]\\big)^{\\,2}]\n    \\end{equation*}\n\n    If we are learning \\(\\mathbb{E}_{\\pi} [G_{\\,t} \\,|\\, S_{\\,t} = s]\\) then we can approximate the variance using the following:\n    \\vspace{1em}\n    \\begin{equation*}\n        Var_{\\pi}(G_{\\,t} \\,|\\, S_{\\,t} = s) \\approx \\mathbb{E}_{\\pi} \\left[\\delta_{\\,t}^{\\,2} + \\sum\\limits_{i \\,= \\,t + 1}^{\\infty} \\left(\\delta_{\\,i} \\prod\\limits_{j \\,=\\, t + 1}^{i} \\gamma_{\\,j} \\,\\right)^{2} \\,\\Bigg|\\, S_{\\,t} = s\\right]\n    \\end{equation*}\n\\end{frame}\n\n\\begin{frame}{So how would this look?}\n    Using the identity \\(Var(X) = \\mathbb{E}\\big[\\big(X - \\mathbb{E}\\big[X\\big]\\big)^{\\,2}]\\) one can estimate the variance using the following structure:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[height=7.277em]{{images/direct.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{What would be the update equations for this?}\n    Using TD($\\lambda$) with $\\overline{w}$ as the parameter vector for estimating the variance we obtain the following update equations:\n    \\vspace{1em}\n    \\begin{align*}\n        \\delta_{\\,t} &= R_{\\,t + 1} + \\gamma_{\\,t + 1} \\,w_{\\,t}^{\\,T} \\,x_{\\,t + 1} - w_{\\,t}^{\\,T} \\,x_{\\,t} \\\\\n        z_{\\,t} &= \\gamma_{\\,t} \\,\\lambda_{\\,t} \\,z_{\\,t - 1} + x_{\\,t} \\\\\n        w_{\\,t + 1} &= w_{\\,t} + \\alpha_{\\,t + 1} \\,\\delta_{\\,t} \\,z_{\\,t} \\\\[1em]\n        %\n        \\overline{\\delta}_{\\,t} &= \\delta_{\\,t}^{\\,2} + \\gamma_{\\,t + 1}^{\\,2} \\,\\overline{w}_{\\,t}^{\\,T} \\,x_{\\,t + 1} - \\overline{w}_{\\,t}^{\\,T} \\,x_{\\,t} \\\\\n        \\overline{z}_{\\,t} &= \\gamma_{\\,t}^{\\,2} \\,\\overline{\\lambda}_{\\,t} \\,\\overline{z}_{\\,t - 1} + x_{\\,t} \\\\\n        \\overline{w}_{\\,t + 1} &= \\overline{w}_{\\,t} + \\overline{\\alpha}_{\\,t + 1} \\,\\overline{\\delta}_{\\,t} \\,\\overline{z}_{\\,t}\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}{How do they compare visually?}\n    \\vspace{1em}\n    \\begin{figure}\n        \\flushleft\n        \\includegraphics[height=8em]{{images/indirect.pdf}}\n    \\end{figure}\n    \\vspace{1em}\n    \\begin{figure}\n        \\flushleft\n        \\includegraphics[height=7.277em]{{images/direct.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\section{Empirical Comparison}\n\n\\begin{frame}{What do we want to know?}\\vspace{1em}\n    Ideally we want to know if the direct method\n\n    \\begin{itemize}\n        \\item is faster or slower to converge than the indirect method,\n        \\item is more robust or less robust to differences in the value and variance learner, and\n        \\item performs better or worse under linear function approximation.\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{What is the simplest domain we can compare them on?}\\vspace{1em}\n    We begin by comparing them on the following simple Markov chain with gaussian rewards:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\hspace{-2.5em}\\includegraphics[width=0.8\\linewidth]{{images/chain/state_diagram.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{How do they compare when \\(\\alpha = \\overline{\\alpha}\\) ?}\\vspace{1em}\n    When \\(\\alpha = \\overline{\\alpha} = 0.001\\) both perform roughly the same:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\hspace{-2.5em}\\includegraphics[width=0.9\\linewidth]{{images/chain/same_step_size.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{What about when \\(\\alpha > \\overline{\\alpha}\\) ?}\\vspace{1em}\n    When \\(\\alpha = 0.01\\) and \\(\\overline{\\alpha} = 0.001\\) the variance of the indirect method is higher:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\includegraphics[width=0.9\\linewidth]{{images/chain/value_step_size_greater.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{So what about when \\(\\alpha < \\overline{\\alpha}\\) ?}\\vspace{1em}\n    When \\(\\alpha = 0.001\\) and \\(\\overline{\\alpha} = 0.01\\) the variance of the indirect method is higher and the direct method is more stable:\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\includegraphics[width=0.9\\linewidth]{{images/chain/variance_step_size_greater.pdf}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Does this result generalize?}\\vspace{1em}\n    In this domain we only see the two perform similarly when both step sizes are equal (note that the dotted line represents the indirect method and the solid line represents the direct method):\n\n    \\vspace{1em}\n    \\begin{figure}\n        \\includegraphics[width=0.7\\linewidth]{{images/chain/sweep.png}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{What about under function approximation?}\\vspace{1em}\n    We use the following domain previously used to evaluate the indirect method:\n\n    \\begin{figure}\n        \\hspace{-2.5em}\\includegraphics[width=0.9\\linewidth]{{images/random_walk/state_diagram.pdf}}\n    \\end{figure}\n\n    For each state $s_{\\,i}$ we use \\(\\phi(s_{\\,i}) = [1, \\,i / 30]^{\\,T}\\) for our value estimator and \\(\\phi_{\\,2}(s_{\\,i}) = [1, \\,i / 30, \\,(i / 30)^{\\,2}]^{\\,T}\\) for our variance estimator.\n\\end{frame}\n\n\\begin{frame}{How do they perform on this domain?}\\vspace{0.75em}\n    Here the direct method vastly outperforms the indirect method:\n\n    \\vspace{0.5em}\n    \\begin{figure}\n        \\includegraphics[height=17em]{{images/random_walk/performance.png}}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{What is the quality of the solutions reached?}\\vspace{0.75em}\n    The direct method reaches a much better fixed point and exhibits much less variance in its variance estimates:\n\n    \\vspace{0.5em}\n    \\begin{figure}\n        \\includegraphics[height=17em]{{images/random_walk/quality.pdf}}\\hspace{2.5em}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{What is the parameter sensitivity?}\\vspace{0.75em}\n    In this domain, the direct method is much less sensitive to the choice of step sizes than the indirect method:\n\n    \\vspace{0.5em}\n    \\begin{figure}\n        \\includegraphics[height=17em]{{images/random_walk/sensitivity.pdf}}\\hspace{2.5em}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Summary}\n    We have described a method of directly estimating the variance of the return using temporal-difference methods. We have argued that learning the variance of the return can\n\n    \\begin{itemize}\n        \\item tell us \\alert{interesting} information about our domain,\n        \\item tell us \\alert{useful} information about the distribution of our return, and\n        \\item can be used to \\alert{learn} how to learn.\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Summary (continued)}\n    We have furthermore shown evidence that the direct method:\n\n    \\begin{itemize}\n        \\item learns just as fast and occasionally \\alert{faster} than the indirect method,\n        \\item is \\alert{more robust} to inconsistencies in the value and variance learner, and\n        \\item exhibits substantially \\alert{better} performance under linear function approximation.\n    \\end{itemize}\n\\end{frame}\n\n\\plain{}{Questions?}\n\n\\end{document}\n", "meta": {"hexsha": "bd97830b45c6c8a49daba3a3c0dce3857c1d6b72", "size": 12506, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/main.tex", "max_stars_repo_name": "dylanashley/variance-learning", "max_stars_repo_head_hexsha": "ebc0af25f5a92819db472958c61ee1c9905f7ba8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-12T10:49:48.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T10:49:48.000Z", "max_issues_repo_path": "presentation/main.tex", "max_issues_repo_name": "dylanashley/variance-learning", "max_issues_repo_head_hexsha": "ebc0af25f5a92819db472958c61ee1c9905f7ba8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/main.tex", "max_forks_repo_name": "dylanashley/variance-learning", "max_forks_repo_head_hexsha": "ebc0af25f5a92819db472958c61ee1c9905f7ba8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3419354839, "max_line_length": 249, "alphanum_fraction": 0.6420917959, "num_tokens": 4052, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.43804614823190013}}
{"text": "\\section{Sums of Products}\n\\todo[inline]{Add a description of what a universe is}\n\nA different way of describing datatypes in a generic representation, besides pattern functors, are \\textit{Sums of Products}\\cite{vries2014sums} (SOP). SOP is a generic representation with additional constraints which more faithfully reflects the Haskell datatypes: each datatype is a single n-ary sum, where each component of the sum is a single n-ary product. The SOP universe is described using \\textit{codes} of kind \\texttt{[[*]]}. The outer list describes an n-ary sum, representing the choice between constructors and each inner list an n-ary products, representing the constructor arguments.  The code of kind \\inlinehaskell{[[*]]} can then be interpreted to describe Haskell datatypes of kind \\inlinehaskell{*}. To define a code, the tick mark \\inlinehaskell{`} is used to lift the list to a type-level. \n\n\\begin{minted}{haskell}\nCode (Tree a) = `[`[a], `[Tree a, a, Tree a]]\n\\end{minted}\n\nThe usage of SOP has a positive effect on expressing generic functions easily or at all. Additionally, the SOP completely divides the structural representation from the metadata. As a result, you do not have to deal with metadata while writing generic functions. However, the additional constraints on the generic representation makes the SOP universe size comparatively bigger than pattern functors. Therefore, it is more complex to extend the SOP than for pattern functors.\n\n% \\begin{itemize}\n%     \\item While many of the libraries that are\n%     commonly in use today represent datatypes as arbitrary combinations of binary sums and products, SOP reflects the structure of datatypes more faithfully: each datatype is a single n-ary sum, where each component of the sum is a single n-ary product.\n%     \\item A major plus of the SOP view is that it allows separating function-specific metadata from the main structural representation and recombining this information later.\n%     \\item In this paper, we introduce a view (which we call SOP) which is based on a single, n-ary, sum, where each component of the sum is a single, n-ary, product.\n%     \\item The SOP view also takes a very interesting approach to metadata. In most generic views, metadata is intertwined with the structural representation, which means that every generic function has to deal with it in some way—even if it is just ignored, as in the M1 case for \\texttt{garities} shown above. Furthermore, metadata sometimes leads to additional implicit assumptions about the shape of the data.\n%     \\item In the SOP view, metadata is completely independent from the data representation. This means that functions which do not need it, don't have to deal with it; conversely, it also means that we can easily define application-specific metadata, i.e., type-directed additional information that “configures” how a particular generic function should behave.\n%     \\item The tick marks are used to explicitly indicate that we mean the promoted type.\n%     \\item The fundamental idea of the SOP universe is that the kind of codes is a (promoted) list of list of types, written [[*]]. The goal of the universe is to provide descriptions of Haskell datatypes (of kind *)\n% \\end{itemize}\n\n", "meta": {"hexsha": "036b1ea21c451fca891cf3b103aac4ab7e6b0aaf", "size": 3231, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/generic_programming/sums_of_products.tex", "max_stars_repo_name": "jortvangorkum/thesis-paper", "max_stars_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/generic_programming/sums_of_products.tex", "max_issues_repo_name": "jortvangorkum/thesis-paper", "max_issues_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/generic_programming/sums_of_products.tex", "max_forks_repo_name": "jortvangorkum/thesis-paper", "max_forks_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 140.4782608696, "max_line_length": 813, "alphanum_fraction": 0.7793252863, "num_tokens": 711, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4380461478667437}}
{"text": "\\section{Herbie: Improving Floating Point Accuracy}\n\\label{sec:herbie}\n\nHerbie automatically improves accuracy\n  for floating-point expressions,\n  using random sampling to measure error,\n  a set of rewrite rules for generating program variants,\n  and algorithms that prune and combine program variants\n  to achieve minimal error.\nHerbie received PLDI 2015's Distinguished Paper award~\\cite{herbie}\n  and has been continuously developed since then,\n  sporting hundreds of Github stars, hundreds of downloads,\n  and thousands of users on its online version.\nHerbie uses \\egraphs for algebraic simplification of mathematical expressions,\n  which is especially important for avoiding floating-point errors\n  introduced by cancellation, function inverses, and redundant computation.\n\nUntil our case study,\n  Herbie used a custom \\egraph implementation\n  written in Racket (Herbie's implementation language)\n  that closely followed traditional \\egraph implementations.\nWith timeouts disabled,\n  \\egraph-based simplification consumed\n  the vast majority of Herbie's run time.\nAs a fix, Herbie sharply limits the simplification process,\n  placing a size limit on the \\egraph itself and a time limit on the whole\n  procedure.\nWhen the timeout is exceeded, simplification fails altogether.\nFurthermore, the Herbie authors knew of several features\n  that they believed would improve Herbie's output\n  but could not be implemented because\n  they required more calls to simplification\n  and would thus introduce unacceptable slowdowns.\nTaken together, slow simplification reduced Herbie's performance, completeness,\n  and efficacy.\n\nWe implemented a \\egg simplification backend for Herbie.\nThe \\egg backend is over $3000\\times$ faster than Herbie's initial simplifier and\n  is now used by default as of Herbie 1.4.\nHerbie has also backported some of \\egg's features like batch simplification and\n  rebuilding to its \\egraph implementation\n  (which is still usable, just not the default),\n  demonstrating the portability of \\egg's conceptual improvements.\n% This has led to over a $200\\times$ speedup over its initial design,\n%   demonstrating that \\egg's\n\n\\subsection{Implementation}\n\nHerbie is implemented in Racket while \\egg is in Rust;\n  the \\egg simplification backend is thus implemented as a Rust library that\n  provides a C-level API for Herbie to access via foreign-function interface (FFI).\nThe Rust library defines the Herbie expression grammar\n  (with named constants, numeric constants, variables, and operations)\n  as well as the \\eclass analysis necessary to do constant folding.\nThe library is implemented in under 500 lines of Rust.\n\nHerbie's set of rewrite rules is not fixed;\n  users can select which rewrites to use using command-line flags.\nHerbie serializes the rewrites to strings,\n  and the \\egg backend parses and instantiates them on the Rust side.\n\nHerbie separates exact and inexact program constants:\n  exact operations on exact constants\n  (such as the addition of two rational numbers)\n  are evaluated and added to the \\egraph,\n  while operations on inexact constants or that yield inexact outputs\n  are not.\nWe thus split numeric constants in the Rust-side grammar\n  between exact rational numbers and inexact constants,\n  which are described by an opaque identifier,\n  and transformed Racket-side expressions into this form\n  before serializing them and passing them to the Rust driver.\nTo evaluate operations on exact constants,\n  we used the constant folding \\eclass analysis\n  to track the ``exact value'' of each \\eclass.%\n\\footnote{Herbie's rewrite rules guarantee that different exact values\n  can never become equal; the semilattice \\textsf{join} checks this invariant on the Rust side.}\nEvery time an operation \\enode is added to the \\egg \\egraph,\n  we check whether all arguments to that operation have exact value (using the analysis data),\n  and if so do rational number arithmetic to evaluate it.\nThe \\eclass analysis is cleaner than the corresponding code in Herbie's implementation,\n  which is a built-in pass over the entire \\egraph.\n\n\\subsection{Results}\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[height=8cm]{herbie}\n  \\caption{\n    Herbie sped up its expression simplification phase\n      by adopting \\egg-inspired features like\n      batched simplification and rebuilding\n      into its Racket-based \\egraph implementation.\n    Herbie also supports using \\egg itself for additional speedup.\n    Note that the y-axis is log-scale.\n  }\n  \\label{fig:herbie-results}\n\\end{figure}\n\nOur \\egg simplification backend\n  is a drop-in replacement to the existing Herbie simplifier,\n  making it easy to compare speed and results.\nWe compare using\n  Herbie's standard test suite of roughly 500 benchmarks,\n  with timeouts disabled.\n\\autoref{fig:herbie-results} shows the results.\nThe \\egg simplification backend is over\n  $3000\\times$ faster than Herbie's initial simplifier.\nThis speedup eliminated Herbie's largest bottleneck:\n  the initial implementation dominated Herbie's total run time at $98.1\\%$,\n  backporting \\egg improvements into Herbie cuts\n  that to about half the total run time,\n  and \\egg simplification takes under $5\\%$ of the total run time.\nPractically, the run time of Herbie's initial implementation was smaller, since\n  timeouts cause tests failures when simplification takes too long.\nTherefore, the speedup also improved Herbie's completeness,\n  as simplification now never times out.\n\nSince incorporating \\egg into Herbie, the Herbie developers have backported some\n  of \\egg's key performance improvements into the Racket \\egraph implementation.\nFirst, batch simplification gives a large speedup because Herbie simplifies many\n  similar expressions.\nWhen done simultaneously in one equality saturation, the \\egraph's structural\n  sharing can massively deduplicate work.\nSecond, deferring rebuilding (as discussed in \\autoref{sec:rebuilding}) gives a\n  further $2.2\\times$ speedup.\nAs demonstrated in \\autoref{fig:eval-iter}, rebuilding offers an asymptotic\n  speedup, so Herbie's improved implementation (and the \\egg backend as well)\n  will scale better as the search size grows.\n\n%%% Local Variables:\n%%% TeX-master: \"../thesis\"\n%%% End:", "meta": {"hexsha": "344204573e18ec9b35e73e2333ad24b7ec6c13dd", "size": 6198, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/case-herbie.tex", "max_stars_repo_name": "mwillsey/thesis", "max_stars_repo_head_hexsha": "1706ea16107f60d8c43caff13ecdb57950896872", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-17T01:00:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-17T01:00:20.000Z", "max_issues_repo_path": "chapters/case-herbie.tex", "max_issues_repo_name": "mwillsey/thesis", "max_issues_repo_head_hexsha": "1706ea16107f60d8c43caff13ecdb57950896872", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/case-herbie.tex", "max_forks_repo_name": "mwillsey/thesis", "max_forks_repo_head_hexsha": "1706ea16107f60d8c43caff13ecdb57950896872", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6015037594, "max_line_length": 96, "alphanum_fraction": 0.7904162633, "num_tokens": 1376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837689358857, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.43799415267897873}}
{"text": "\\documentclass[9pt, a4paper, oneside]{amsart}\n\n\n\\usepackage{enumitem}\n\\usepackage{parskip}\n\\usepackage{fancyhdr}\n\\usepackage{color}\n\\usepackage{multicol}\n\\pagestyle{fancy}\n\n\\newlist{questions}{enumerate}{1}\n\\setlist[questions, 1]{label = \\bf Q.\\arabic*., itemsep=1em}\n\n\n% \\setlength{\\topmargin}{-10mm}\n% \\setlength{\\textheight}{235mm}\n% \\setlength{\\oddsidemargin}{-3mm}\n% \\setlength{\\textwidth}{165mm}\n% \\setlength{\\footskip}{10mm}\n\n\n\n\n\n\n\\lhead{\\scshape Apurva Nakade}\n\\rhead{\\scshape Honors Single Variable Calculus}\n\\renewcommand*{\\thepage}{\\small\\arabic{page}}\n\\title{Problem Set 03}\n\n\\begin{document}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\n\\section*{Part 1 - Continuity}\n\n\\begin{questions}[resume]\n\n\t\\item\n\t\\begin{enumerate}\n\t\t\\item Use the $ \\epsilon - \\delta$ definition to show that the constant function $ f(x) = c $ is continuous everywhere.\n\n\t\t\\item Use the $ \\epsilon - \\delta$ definition to show that the function $ f(x) = x $ is continuous everywhere.\n\n\t\t\\item Let $ p(x)$ a polynomial of degree $ n$. Use Theorem 2 to prove that $p(x)$ is continuous everywhere.\n\t\\end{enumerate}\n\n\tTrigonometric functions, exponential functions and logarithms are also continuous wherever they are defined. We will assume this fact without proof for now and perhaps come back to it later.\n\n\t\\item\n\t\\begin{enumerate}\n\t\t\\item Prove that if $ \\lim \\limits_{x \\rightarrow 0} f(x)/x = l$ and $ b \\neq 0$ then $$ \\lim \\limits_{x \\rightarrow 0} f(bx)/x = bl$$\n\t\t\\item Assuming $ \\lim \\limits_{x \\rightarrow 0} \\sin x / x = 1$ find  $ \\lim \\limits_{x \\rightarrow 0}$ for each of the following functions,\n\t\t      \\begin{multicols}{3}\n\t\t      \t\\begin{enumerate}\n\t\t      \t\t\\item $\\sin (2x)/ x$\n\t\t      \t\t\\item $\\sin (ax)/ \\sin(bx)$\n\t\t      \t\t\\item $\\sin^2 (2x)/ x$\n\t\t      \t\t\\item $\\sin^2 (2x)/ x^2$\n\t\t      \t\\end{enumerate}\n\t\t      \\end{multicols}\n\n\t\\end{enumerate}\n\n\n\t\\item Determine, with proof, the points at which the following function is continuous.\n\t$$ f(x) = \\begin{cases} 0 & \\mbox{ if $ x$ is rational } \\\\ x & \\mbox{ otherwise }\\end{cases}$$\n\n\n\t\\item Suppose that $ g$ is continuous on $[a,b]$ and $ h$ is continuous on $[b,c]$ and that $ g(b) = h(b)$. Define a new function\n\t\\begin{align*}\n\t\tf(x) = \\begin{cases} g(x) & \\mbox{ if }a \\le x < b \\\\ h(x) & \\mbox{ if }b \\le x \\le c  \\end{cases}\n\t\\end{align*}\n\tShow that $ f(x)$ is continuous on $ [a,c]$. (Thus, continuous functions can be `glued'.)\n\n\\end{questions}\n\n\n\n\n\n\n\n\n\n\n\\newpage\n\\section*{Part 2 - Three Hard Theorems}\nIn this HW you can use any of the Theorems 1-9 from Chapter 7 to solve the problems.\n\\begin{questions}[resume]\n\t\\item For each of the polynomial functions $ f$, find (by trial and error) an integer $ n$ such that $ f(x) = 0$ for some $ x$ in  $[n,n+1]$.\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}\n\t\t\t\\item $ x^3 - x + 3$\n\t\t\t\\item $ x^5 + 5x^4 + 2x + 1$\n\t\t\t\\item $ x^5 + x +1$\n\t\t\t\\item $ 4x^2 - 4x + 1$\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\t\\item Suppose $ f$ and $ g$ are continuous on $ [a,b]$ and that $ f(a) < g(a)$ and $ f(b) > g(b)$. Prove that $ f(x) = g(x)$ for some $ x$ in $ (a,b)$.\n\n\t\\item Suppose that $ f$ is a continuous function with $ f(x) > 0$ for all $ x$, and $ \\lim \\limits_{x \\rightarrow \\infty} f(x) = 0 = \\lim \\limits_{x \\rightarrow -\\infty} f(x)$. (Draw a picture.) We want to prove that there is some number $ y$ such that $ f(y) \\ge f(x)$ for all $ x$.\n\t\\begin{enumerate}\n\t\t\\item Choose an arbitrary positive real number $s$. Using the $ \\epsilon - \\delta $ definition of $ \\lim \\limits _ {x \\rightarrow \\infty}$ and $ \\lim \\limits _ {x \\rightarrow -\\infty}$ show that there is a number $ N$ such that $f(s) > f(x)$ for all $ |x| > N$.\n\t\t\\item Let $ M = \\max(N,s)$ and let $ y$ be the real number in the the interval $ [-M,M]$ such that $ f(y) \\ge f(x)$ for all $ x$ in $[-M,M]$. Why does such a $ y$ exist?\n\t\t\\item Using the fact that $ s \\le M$ show that $ f(y) > f(x)$ for all $ |x| > M$.\n\t\t\\item  Using part (2) and (3) conclude that $ f(y) \\ge f(x)$ for all real numbers $ x$.\n\n\t\t\\item (Optional) Does there exist a real number $ y$ such that $ f(y) \\le f(x)$ for all $ x$?\n\t\\end{enumerate}\n\n\t\\item Suppose that $ f(x)$ is continuous on $ [a,b]$ and that $ f(x)$ is always rational. What can be said about $ f$? (Hint: Use the intermediate value theorem.)\n\n\\end{questions}\n\n\n\n\n\n\n\n\n\n\n\\newpage\n\\section*{Part 3 - Least Upper Bounds}\n\\begin{questions}[resume]\n\t\\item In this problem we'll prove the following theorem.\n\t\\begin{quote}\n\t\t\\textbf{Theorem 9.} For every polynomial $ p(x)$ of odd degree $ n$ there is a real number $ x$ such that $ p(x)=0$.\n\t\\end{quote}\n\tThe idea of the proof is to show that for large values of $|x|$ the polynomial $ p(x)$ behaves like $ x^n$. Without any loss of generality assume that the polynomial is of the form\n\t\\begin{align*}\n\t\tp(x) & = x^n + a_{1} x^{n-1} + a_{2} x^{n-2} + \\cdots + a_{n-1} x + a_n                                                      \\\\\n\t\t     & = x^n\\left( 1 + \\dfrac{a_{1}} {x} + \\dfrac{a_{2}} {x^2} + \\cdots + \\dfrac{a_{n-1}}{x^{n-1}} + \\dfrac{a_n}{x^n}\\right)\n\t\\end{align*}\n\t\\begin{enumerate}\n\t\t\\item Argue that there exists a number $ N$ such that $ \\left|\\dfrac{a_{i}}{x^{i}}\\right| < \\dfrac{1}{2n}$ for all $ |x| > N$ and for all $1 \\le i \\le n$. \\\\(It's ok to not be completely rigorous for this part.)\n\t\t\\item Show that for all $ |x| > N$,\n\t\t      \\begin{align*}\n\t\t      \t-\\dfrac{1}{2} < \\dfrac{a_{1}} {x} + \\dfrac{a_{2}} {x^2} + \\cdots + \\dfrac{a_{n-1}}{x^{n-1}} + \\dfrac{a_n}{x^n} < \\dfrac{1}{2}\n\t\t      \\end{align*}\n\t\t\\item\n\t\t      Show that for all $ |x| > N$,\n\t\t      \\begin{align*}\n\t\t      \t\\dfrac{1}{2} < \\dfrac{p(x)}{x^n} < \\dfrac{3}{2}\n\t\t      \\end{align*}\n\t\t\\item Argue that because $ n$ is odd this implies that there exist real numbers $ a > N$, $b < -N$ with $ p(a) > 0 > p(b)$. Conclude that $ p(x) = 0$ for some number $ x$.\n\t\\end{enumerate}\n\n\t\\item\n\tFind the supremum (least upper bound) and infimum (greatest lower bound) of the following sets. (Proofs are not required, it's enough to draw pictures.)\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}\n\t\t\t\\item $ \\left\\{ 1/n : n \\in \\mathbb{N} \\right\\}$\n\t\t\t\\item $ \\left\\{ 1/n : n \\in \\mathbb{Z} \\mbox{ and } n \\neq 0 \\right\\}$\n\t\t\t\\item $ \\left\\{ 1/n + (-1)^n: n \\in \\mathbb{N} \\right\\}$\n\t\t\t\\item $ \\left\\{ x : x^2 < 2 \\mbox{ and } x \\mbox{ is rational} \\right\\}$\n\t\t\t\\item $ \\left\\{ x : x^2 + x - 2 \\ge 0  \\right \\}$\n\t\t\t\\item $ \\left\\{ x : x^2 + x - 2 \\le 0  \\right \\}$\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\t%\n\t% \\item For a non-empty set $ A$ let $ -A$ denote the set of all $ -x$ for $ x$ in $ A$. Prove that\n\t% \\begin{enumerate}\n\t% \t\\item $ \\sup (-A) = - \\inf A$\n\t% \t\\item $ \\inf (-A) = - \\sup A$\n\t% \\end{enumerate}\n\n\t\\item In this problem we'll prove the Intermediate Value Theorem using (P13).\n\t\\begin{quote}\n\t\t\\textbf{Intermediate Value Theorem.} If $ f$ is a continuous function on $ [a,b]$ satisfying $ f(a) < c < f(b)$, then there exists some $ x$ in $ [a,b]$ such that $ f(x) = c$.\n\t\\end{quote}\n\n\t\\begin{enumerate}\n\t\t\\item Let $ A$ be the set of $ x$ in $ [a,b]$ such that $ f(x) \\le c$. Why is the set $ A$ non-empty?\n\n\t\t\\item \tAs $ A$ is a non-empty subset of $ [a,b]$ by (P13) $ A$ has a least upper bound, let $ y = \\sup A$. We want to show that $ f(y) = c$. We'll prove this by contradiction, assume on the contrary that $ f(y) \\neq c$.\n\t\t      \\begin{description}\n\t\t      \t\\item[Case I $ f(y) < c$ ] In this case argue that for some $ \\delta$ the number $ y + \\delta$ is in $ A$ and hence $ y$ cannot be an upper bound.\n\t\t      \t\\item[Case II $ f(y) > c$ ] In this case argue that for some $ \\delta$ the number $ y - \\delta$ is also an upper bound of $ A$ and hence $ y$ cannot be the \\emph{least} upper bound.\n\t\t      \\end{description}\n\n\t\t\\item Give an example to show that the Intermediate Value Theorem does not hold if the function $ f$ is discontinuous. Also describe the set $ A$, defined as above, for your example and explain why the above proof fails for this case.\n\t\\end{enumerate}\n\n\n\t% \\item Proofs are not required for this problem, however describe your answers as precisely as possible.\n\t%\n\t% \\begin{enumerate}\n\t% \t\\item Find a function which is discontinuous at $1, \\frac{1}{2}, \\frac{1}{3},\\frac{1}{4}, \\ldots$ but continuous at all other points.\n\t% \t\\item Find a function which is discontinuous at $1, \\frac{1}{2}, \\frac{1}{3},\\frac{1}{4}, \\ldots$ and 0 but continuous at all other points.\n\t% \\end{enumerate}\n\t% If $ \\lim \\limits _ {x \\rightarrow a} f(x)$ exists but is $ \\neq f(a)$ then $ f$ is said to have a \\textbf{removable singularity} at $ a$.\n\t% \\begin{enumerate}[resume]\n\t% \t\\item Give an example of a function $ f$ with a removable discontinuity at 0.\n\t% \t\\item Given an example of a function $ f$ with a discontinuity at 0\twhich is not removable.\n\t% \\end{enumerate}\n\n\\end{questions}\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "6a934926bfd2dba8d43ec3f6bd6aa15f196da312", "size": 8768, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2017/PSet03.tex", "max_stars_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_stars_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2017/PSet03.tex", "max_issues_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_issues_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2017/PSet03.tex", "max_forks_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_forks_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5925925926, "max_line_length": 284, "alphanum_fraction": 0.6190693431, "num_tokens": 3081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.8558511506439708, "lm_q1q2_score": 0.43795324493968585}}
{"text": "Fig. \\ref{fig:siso-channels} illustrates the frequency response of a SISO FF and FS channel based on the same tap delays and tap gains.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[FF channel]{\n    \\includegraphics[width=0.48\\textwidth]{siso_frequency_flat_channel}\\label{fig:siso-ff}}\n  \\subfigure[FS channel]{\n    \\includegraphics[width=0.48\\textwidth]{siso_frequency_selective_channel}\\label{fig:siso-fs}}\n  \\caption{Frequency response of the SISO FF and FS channels}\\label{fig:siso-channels}\n\\end{figure}\n\nIn the following R-E plots, the rightmost point of each curve indicates the maximum achievable rate with zero harvested DC current. It corresponds to WIT that allocates all available power to the modulated information waveform by the water-filling algorithm with $\\rho  = 0$. Note that the x-axis here refers to the per-subband rate and is normalized w.r.t. bandwidth. With a fixed power budget, the power received by each subband decreases as $N$ increases. Therefore, the rate achieved by each subband decreases but the total rate increases. On the other hand, the leftmost point corresponds to the maximum output DC current with zero information rate, which correspond to allocating all power to the multisine waveform with $\\rho  = 1$ (WPT).\n\nNevertheless, the discrete rate constraint \\eqref{eqn:original_rate_constraint} in the optimization problem prevent the solutions from achieving the absolute WIT points using the proposed WIPT approach. Therefore, we perform an individual WIT and combine the results to obtain closed R-E plots.\n\n\\subsection{R-E Region vs Subband}\\label{sec:re-region-vs-subband}\nFig. \\ref{fig:siso-subband} illustrates the R-E region against subband $N = 1,2,4,8,16$ for superposed waveform and no power waveform over FF and FS channels respectively.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[FF: Superposed waveform]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_subband_superposed_waveform}\\label{fig:subband-ff-superposed}}\n  \\subfigure[FF: No power waveform]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_subband_no_power_waveform}\\label{fig:subband-ff-no-power}}\n  \\quad\n  \\subfigure[FS: Superposed waveform]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_subband_superposed_waveform}\\label{fig:subband-fs-superposed}}\n  \\subfigure[FS: No power waveform]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_subband_no_power_waveform}\\label{fig:subband-fs-no-power}}\n  \\caption{R-E region vs $N$ for FF and FS channels}\\label{fig:siso-subband}\n\\end{figure}\n\nIt can be observed that the introduction of multisine power waveform boosts the harvested energy for $N > 4$ where the superposed waveform outperforms the modulated signal for WIPT. In contrast, the R-E performance of both signals are very close for $N \\leqslant 4$ so that multisine is unnecessary. The reason is that the fourth order terms of power and information waveforms \\eqref{eqn:power_waveform_fourth_order} and \\eqref{eqn:information_waveform_fourth_order} have different contribution to the harvested DC current. Despite both posynomials consist of monomials of similar magnitude (${\\prod\\nolimits_{j = 0}^3 {{s_{P,{n_j},{m_j}}}{A_{{n_j},{m_j}}}} }$ and $\\prod\\nolimits_{j = 0,2} {{s_{I,{n_0},{m_j}}}{A_{{n_0},{m_j}}}} \\prod\\nolimits_{j = 1,3} {{s_{I,{n_1},{m_j}}}{A_{{n_1},{m_j}}}} $ ), the power posynomial contains $(2{N^3} + N)/3$ monomials but the information posynomial only holds ${N^2}$ monomials. Therefore, the energy benefit of multisine is amplified with a large $N$. Although it seems that a very large $N$ can significantly increases the output DC current, this is not true because each subband will receive less power such that the magnitude of monomials decreases accordingly.\n\nA contrast of R-E plots on FF and FS channels also indicates the benefit of frequency selectivity on the harvested power. The gain is particularly obvious in the low-rate region, where all the power is allocated to the subband with the strongest amplitude. We observe from the FS channel instance in Fig. \\ref{fig:siso-fs} that some edge frequencies enjoy a larger gain than the center frequency, whose advantage is exploited when more subbands are used. In comparison, the small amplitude at the center frequency accounts for the lower output DC current when $N = 1$ (indicated by the blue curves in Fig. \\ref{fig:subband-fs-superposed} and \\ref{fig:subband-fs-no-power}).\n\nWithout power waveform, the R-E region appears convex such that PS dominates TS over all $N$. On the other hand, the R-E region achieved by superposed waveform with PS is convex for $N = 2,4$ but concave-convex for $N = 8,16$. Therefore, the optimal strategy is using PS for a small $N$, TS for a large $N$, and a combination of PS and TS for a medium $N$. As shown in Fig. \\ref{fig:siso-subband-optimal}, the best curve for medium $N$ consists of two parts. The straight part is achieved by TS between WPT (multisine only with $\\rho  = 1$) that corresponds to the leftmost point and WIPT (superposed waveform with $0 < \\rho  < 1$) that corresponds to the tangent point, while the convex part is the contribution of WIPT only. The characteristics of the optimal R-E region comes from the rectifier nonlinearity.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[Optimal strategy for $N = 8$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_subband_8_optimal}\\label{fig:subband-8-optimal}}\n  \\subfigure[Optimal strategy for $N = 16$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_subband_16_optimal}\\label{fig:subband-16-optimal}}\n  \\caption{Optimal R-E region for FF channel with medium $N$}\\label{fig:siso-subband-optimal}\n\\end{figure}\n\nMoreover, the plots over the FS channel suggests that for single-carrier transmission, the modulated waveform outperforms the superposed waveform for WPT. At a zero-approaching rate, the modulated waveform produces a DC current of \\SI{2.69}{\\uA} while the superposed waveform only delivers \\SI{2.64}{\\uA}. The actual current gap is even larger since the former still guarantees a slightly higher rate. On the contrary, the superposed waveform leads to a larger harvested current for $N \\geqslant 2$. It demonstrates that modulation is beneficial in single-carrier transmission but can be detrimental in multi-carrier transmission. The reason is that the modulation gain \\eqref{eqn:modulation_gain} of modulated waveform outperforms the energy benefit of multisine in single-carrier transmission but is outperformed in multi-carrier transmission. The result is inline with the scaling laws proposed in \\cite{Clerckx2018}.\n\nOne problem is that the leftmost point of some curves did not start from the y-axis. Although a zero rate constraint is employed in WIPT, a candidate solution may achieve a nonzero rate. It is because the current gain of the next iteration is smaller than the threshold $\\varepsilon$ so that the algorithm terminates and outputs the existing R-E pair. This phenomenon occurs at the low-rate region with a small $N$, where the current gain is relatively small in each iteration and the output current is almost saturated. It can be fixed either by reducing the threshold $\\varepsilon$ or developing an individual function for WPT.\n\n\n\n\\subsection{R-E Region vs SNR}\\label{sec:re-region-vs-snr}\nFig. \\ref{fig:siso-ff-snr} and \\ref{fig:siso-fs-snr} contrast the performance of the modulated waveform, ideal superposed waveform and its lower bound for $N = 16$ and ${\\text{SNR}} = 10,20,30,40$ dB over the example FF and FS channels.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[FF: ${\\text{SNR}} = 10$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_snr_10dB}\\label{fig:snr-ff-10db}}\n  \\subfigure[FF: ${\\text{SNR}} = 20$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_snr_20dB}\\label{fig:snr-ff-20db}}\n  \\quad\n  \\subfigure[FF: ${\\text{SNR}} = 30$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_snr_30dB}\\label{fig:snr-ff-30db}}\n  \\subfigure[FF: ${\\text{SNR}} = 40$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_snr_40dB}\\label{fig:snr-ff-40db}}\n  \\caption{R-E region vs SNR for FF channel}\\label{fig:siso-ff-snr}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[FS: ${\\text{SNR}} = 10$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_snr_10dB}\\label{fig:snr-fs-10db}}\n  \\subfigure[FS: ${\\text{SNR}} = 20$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_snr_20dB}\\label{fig:snr-fs-20db}}\n  \\quad\n  \\subfigure[FS: ${\\text{SNR}} = 30$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_snr_30dB}\\label{fig:snr-fs-30db}}\n  \\subfigure[FS: ${\\text{SNR}} = 40$ dB]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_snr_40dB}\\label{fig:snr-fs-40db}}\n  \\caption{R-E region vs SNR for FS channel}\\label{fig:siso-fs-snr}\n\\end{figure}\n\nThanks to the contribution of multisine waveform, the R-E region of the superposed signal is enlarged in both cases. This phenomenon is especially obvious in the low-rate region, where the multisine dominates the transmission. It results from the fact that the nonlinear rectifier favors the deterministic multisine with high PAPR. On the contrary, there is some randomness involved in the modulated waveform that produces fluctuations to the rectifier and leads to some power loss \\cite{Clerckx2018}. This phenomenon is in sharp contrast to the conclusion based on linear harvester model that both waveforms are equally suitable for WPT \\cite{Xu2014a}. As shown in the plots, even with the assumption that the deterministic power waveform creates some interference to the information waveform, the rate loss is compensated by the power gain such that the superposed waveform strictly outperforms the modulated waveform.\n\nAnother observation is the performance gap between the ideal superposed waveform and its lower bound widens as SNR increases. This is as expected because the rate is dominated by noise at low SNR and by interference at high SNR. For ${\\text{SNR}} = 10$ dB, the interference is much lower than noise even if a large amount of power is allocated to the multisine component. Hence, the curves almost overlap with each other. On the other hand, at a higher SNR, the rate loss by interference increases while the energy benefit of power waveform remains unchanged. To obtain the optimal R-E tradeoff, the transmitter tends to allocate less power to the multisine so that the harvested current drops. Therefore, the rate boost of deterministic power waveform grows as SNR increases.\n\nThe plots also demonstrate that for the superposed waveform with a sufficiently large $N$, TS is preferred at low SNR and PS is favored at high SNR, while a combination of TS and PS is generally optimal for medium SNR. On the other hand, the R-E region is strictly convex for the modulated waveform-only transmission due to its inefficiency to boost the harvested energy. It corresponds to the conventional opinion that PS always outperforms TS for no power waveform transmission. In this case, the R-E curve is approximately straight at low SNR but with large curvature at high SNR. The reason is that at a low SNR, the water-filling strategy concentrates the power to the best subband to maximize the rate, and the region boundary is obtained by varying $\\rho $ only. In comparison, more subbands are utilized in the transmission as SNR increases. Therefore, only a small portion of power is required to achieve a decent rate while the remaining part can be used to boost the output current.\n\nA comparison between the results over FF and FS channels emphasizes the benefit of frequency selectivity on the harvested current. The gain is more significant for modulated waveform (around \\SI{1}{\\uA}) than superposed waveform (around \\SI{0.25}{\\uA}). One possible reason is that the power are concentrated in few subbands such that the number of terms in \\eqref{eqn:power_waveform_fourth_order} and \\eqref{eqn:information_waveform_fourth_order} are comparable. In such cases, the impact of channel amplitude on each monomial is more significant on the information waveform and contributes to a larger gain in the harvested current.\n\n\n\n\\subsection{R-E Region vs PAPR}\\label{sec:re-region-vs-papr}\nFig. \\ref{fig:re-papr} investigates the relationship between PAPR and R-E region for $N = 8, 16$ over the FF and FS channels.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[FF: $N = 8$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_papr_8}\\label{fig:re-ff-papr-8}}\n  \\subfigure[FF: $N = 16$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_ff_papr_16}\\label{fig:re-ff-papr-16}}\n  \\quad\n  \\subfigure[FS: $N = 8$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_papr_8}\\label{fig:re-fs-papr-8}}\n  \\subfigure[FS: $N = 16$]{\n    \\includegraphics[width=0.48\\textwidth]{siso_re_fs_papr_16}\\label{fig:re-fs-papr-16}}\n  \\caption{R-E region vs PAPR for FF channel}\n  \\label{fig:re-papr}\n\\end{figure}\n\nA first observation is that a large enough PAPR is required to fully exploit the power gain of the multisine waveform. For $N = 16$, the R-E region is convex for a PAPR no larger than 20 dB and is concave-convex when it increases to 30 dB. For instance, with a small PAPR of 10 dB, the use of multisine waveform is strictly constrained such that the modulated waveform dominates the transmit signal. Hence, the corresponding R-E plot is similar to the result without power waveform. On the contrary, a PAPR of 30 dB is large enough to achieve the optimal performance of the superposed signal in the low-rate region. It can be concluded that the energy benefit of the multisine waveform indeed comes from the high PAPR. In each cycle, the peak pushes the rectifier output voltage to a high level which decreases slowly in the rest of the period.\n\nA contrast of the R-E plots of $N = 8$ and 16 also suggests a larger $N$ requires higher PAPR to improve the performance. When PAPR increases from 20 to 30 dB, the current gain is more significant for $N = 16$ than $N = 8$. On the other hand, the impact of PAPR for small $N$ is not as significant as for large $N$. This verifies the positive correlation between $N$ and PAPR discussed in Section \\ref{sec:rectifier-behavior}. Although increasing $N$ in a proper range can effectively boost the harvested energy, the PAPR constraint may limit the use of a large $N$ in practice.\n\nIt is interesting to notice that the frequency selectivity helps to achieve the optimal R-E region with a lower PAPR. As shown in Fig. \\ref{fig:re-fs-papr-8}, a PAPR constraint of 20 dB is enough to guarantee the best tradeoff and a larger budget is unnecessary. However, the transmission over the FF channel requires a larger PAPR of 30 dB to achieve optimum behavior. This is because frequency selective channel can further amplify the difference of frequency components such that the received signal is with enhanced PAPR.\n\nThe main disadvantage of the proposed approach is that the oversampling procedure further increases the overall computational complexity in the optimization. ", "meta": {"hexsha": "04c5f16e01ad36cc296ae1cb5880f4860b70065f", "size": 15019, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/thesis/performance-evaluation/siso.tex", "max_stars_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_stars_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2019-07-10T21:31:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T18:01:41.000Z", "max_issues_repo_path": "tex/thesis/performance-evaluation/siso.tex", "max_issues_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_issues_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/thesis/performance-evaluation/siso.tex", "max_forks_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_forks_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2020-06-12T23:20:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T18:01:46.000Z", "avg_line_length": 126.2100840336, "max_line_length": 1203, "alphanum_fraction": 0.777814768, "num_tokens": 4003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.672331705744791, "lm_q1q2_score": 0.4379265363065896}}
{"text": "\\documentclass[./\\jobname.tex]{subfiles}\n\\begin{document}\n\n\\section{Multimodality and Symmetry}\n\\label{chap:multimodality_and_symmetry}\nThe optimisation algorithm tries to find the best approximation of $N$ kernels to the solution of a differential equation. Assume, that a kernel $K$ is fully defined by a vector of parameters $\\mathbf{p}$. The best fit is defined as \n\\begin{equation}\n\\mathbf{\\hat{p}_{apx}} = \\left[\\underbrace{\\left[ \\mathbf{\\hat{p}}_{K_0} \\right] }_{\\text{kernel 0}}, \\cdots \\underbrace{\\left[ \\mathbf{\\hat{p}}_{K_i} \\right] }_{\\text{kernel i}}, \\cdots \\underbrace{\\left[ \\mathbf{\\hat{p}}_{K_N} \\right]}_{\\text{kernel N}} \\right]^T\n\\end{equation}\nwhere the parameters $\\mathbf{\\hat{p}}$ of every kernel are chosen optimally. The optimal kernel functions $K(\\mathbf{\\hat{p}}_{K_i}, \\mathbf{x})$ are summed up to form the optimal approximation $\\hat{u}_{apx}(\\mathbf{x})$. \n\\begin{equation}\n\\label{eq:uapx_kernel_sum}\n\\hat{u}_{apx}(\\mathbf{x}) = \\sum_{i=0}^{N} K(\\mathbf{\\hat{p}}_{K_i}, \\mathbf{x})\n\\end{equation}\nSince the order of the summation is irrelevant, any kernel-wise permutation describes an optimal solution $\\mathbf{\\hat{p}_{apx}}$. Thus, the fitness function $F(u_{apx}(\\mathbf{x}))$ has at least $N!$ number of local optima and all of them share the same function value. Further, a symmetry in the location of the optima is observed. All optima lay on the surface of the hypersphere that is centred at the origin and has a radius of $r = || \\mathbf{\\hat{p}_{apx}} ||$. The following 3D plot in figure \\ref{fig:optima_distribution} shows an exemplary distribution of optima on the fitness function. For the sake of simplicity, a kernel now consists of only one parameter. As an example, the vector $\\mathbf{\\hat{p}_{apx}} = \\left[ 2, 1, -1 \\right]^T$ describes an optimal solution that consists of 3 kernels. Any permutation of these three coordinates is itself a perfect fit. \n\\begin{figure}[h]\n\t\\centering\n\t\\noindent\\adjustbox{max width=0.7\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../img/pdf/symmetry.pdf}\n\t}\n\t\\unterschrift{Distribution of exemplary optima on the fitness function in 3D space.}{}{}\n\t\\label{fig:optima_distribution}\n\\end{figure}\nThis symmetry is independent of the kernel type. Large parts of the fitness function, such as the weighting and penalty factors or the number of collocation points, have no influence on the actual radial arrangement of the optima. The symmetry is a fundamental property of the sum of \\gls{rbf}. Thus, it could even be applied in other fields that use this kind of representation. One of these could be non-linear function approximation. \\\\ Obviously, the order of summation is not only true for the optimum, but also for every other point in between. Thus, the entire fitness function exhibits this radial symmetry. More work investigating the structure of the fitness function must be done. With more knowledge about the features of this function, it might be possible to design algorithms specifically to that problem. \n\n\\end{document}", "meta": {"hexsha": "e5ff5aed5a6c2a7191d8755e1133ba8e84b845a2", "size": 3026, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "master_thesis_paper/tex/Multimodality_and_Symmetry.tex", "max_stars_repo_name": "nicolai-schwartze/Masterthesis", "max_stars_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-13T10:02:02.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-13T10:02:02.000Z", "max_issues_repo_path": "master_thesis_paper/tex/Multimodality_and_Symmetry.tex", "max_issues_repo_name": "nicolai-schwartze/Masterthesis", "max_issues_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "master_thesis_paper/tex/Multimodality_and_Symmetry.tex", "max_forks_repo_name": "nicolai-schwartze/Masterthesis", "max_forks_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 116.3846153846, "max_line_length": 877, "alphanum_fraction": 0.7554527429, "num_tokens": 832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4379265314825691}}
{"text": "\\documentclass[11pt, oneside]{article}   \t% use \"amsart\" instead of \"article\" for AMSLaTeX format\n\n\n% \\usepackage{draftwatermark}\n% \\SetWatermarkText{Draft}\n% \\SetWatermarkScale{5}\n% \\SetWatermarkLightness {0.95} \n% \\SetWatermarkColor[rgb]{0.7,0,0}\n\n\n\\usepackage{geometry}                \t\t% See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}                   \t\t% ... or a4paper or a5paper or ... \n%\\geometry{landscape}                \t\t% Activate for for rotated page geometry\n%\\usepackage[parfill]{parskip}    \t\t% Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\t\t\t\t% Use pdf, png, jpg, or eps� with pdflatex; use eps in DVI mode\n\t\t\t\t\t\t\t\t% TeX will automatically convert eps --> pdf in pdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{authblk}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{fixltx2e}\n\\usepackage{hyperref}\n\\usepackage{alltt}\n\\usepackage{color}\n\\usepackage{bigints}\n\n\\newcommand{\\argmax}{\\operatornamewithlimits{argmax}}\n\\newcommand{\\argmin}{\\operatornamewithlimits{argmin}}\n\n\\title{Notes on MSE Gradients for Neural Networks}\n\\author{David Meyer \\\\ dmm@\\{1-4-5.net,uoregon.edu,...\\}}\n% \\date{17 Jan 2016}\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\n\n\\section{Mean Squared Error (MSE)}\n\\noindent\nFirst, notation: scalars are represented in regular math font, e.g., $y_i$, where vectors are in bold, e.g., $\\mathbf{x}_i$. Given these definitions we can define our \\emph{labelled data} or \\emph{training examples} as a set of $n$ tuples where the $i^\\text{th}$ tuple has the form $(\\mathbf{x}_i,y_i)$, where $\\mathbf{x}_i \\in \\mathbb{R}^n$ is a vector of inputs and $y_i \\in \\mathbb{R}$ is the observed output.\n\n\\bigskip\n\\noindent\nIdeally our neural network should output $y_i$ when given $\\mathbf{x}_i$ as an input. Of course, during training this doesn't always happen so we need to define an \\emph{error or cost} function that quantifies the difference between the actual observed output and the prediction of the neural network. A simple measure of the error is the Mean Squared Error, or MSE.  We define the MSE as follows:\n\n\\begin{flalign}\nE := \\frac{1}{m} \\sum\\limits_{i = 1}^{m} (h(\\mathbf{x}_i) - y_i)^2\n\\end{flalign}\n\n\\bigskip\n\\noindent\nwhere $h(\\mathbf{x}_i)$ is the output of the neural network.\n\n\\section{Basic Building Blocks: Perceptrons}\n\\noindent\nThe simplest classifiers out of which we will build our neural network are perceptrons \\cite{Rosenblatt1958}. In reality, a perceptron is a linear classifier.   A perceptron takes an input vector $\\mathbf{x}$ which is multiplied pairwise by  a weight vector $\\mathbf{w}$, then sums the products up together with a bias term $b$. This sum (the \\emph{dot product}, Equation \\ref{eqn:dot_product}) is then fed through  an activation function $\\sigma:\\mathbb{R} , \\mathbb{R}$. This is depicted in Figure \\ref{fig:perceptron}.  Note here that $w_0 = b$ and $a_0 = 1$;  I like Figure \\ref{fig:perceptron} but I will use the more conventional $\\mathbf{x}$ for the input vector  rather than $\\mathbf{a}$ as is used in the figure.  The behavior of the perceptron can then be described as $\\sigma(\\mathbf{w} \\cdot \\mathbf{x})$, where $\\mathbf{w}$ and $\\mathbf{x}$ have the following form\\footnote{Again noting that $\\mathbf{a}$ in Figure \\ref{fig:perceptron} is frequently\ncalled $\\mathbf{x}$, the input vector; I'll use $\\mathbf{x}$ here.}:\n\n\\begin{flalign*}\n\\boldsymbol{w}  & = \\begin{bmatrix}  w_{1}  \\\\ w_{2} \\\\  \\vdots \\\\ w_{n}   \\end{bmatrix}  \\\\ \\\\\n\\boldsymbol{x}   & = \\begin{bmatrix}  x_{1}  \\\\  x_{2}   \\\\ \\vdots \\\\  x_{n}   \\end{bmatrix}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\n$\\mathbf{w}^\\text{T}$ ($\\mathbf{w}$ transpose) is defined to be\n\n\\begin{flalign*}\n\\boldsymbol{w}^T  & = \\begin{bmatrix}  w_{1}, & w_{2}, & \\hdots, &  w_{n}  \\end{bmatrix}\n\\end{flalign*}\n\n\n\\bigskip\n\\noindent\nThe  \\emph{dot product} between $\\mathbf{w}$ and $\\mathbf{x}$, $\\mathbf{w} \\cdot \\mathbf{x}$, is defined as\n\n\\begin{equation*}\n\\label{eqn:dot_product}\n\\mathbf{w} \\cdot \\mathbf{x} = \\boldsymbol{w}^T\\boldsymbol{x} = \n\\left[\\begin{array}{cccc} w_{1}, & w_{2}, & \\cdots, & w_{n} \\end{array} \\right]  \n\\left[ \\begin{array}{cccc} x_1 \\\\ x_2 \\\\ \\vdots \\\\ x_n \\end{array} \\right] =\n\\sum\\limits_{i = 1}^{n}w_{i}x_{i} = w_{1}x_1 + w_{2}x_2 +  \\ldots + w_{n}x_n\n\\end{equation*}\n\n\\bigskip\n\\noindent\nNote that the weight vector, $\\mathbf{w}$ will be a $M \\times N$ matrix if there is more than one layer of artificial neurons.\n\n\\bigskip\n\\noindent\nThe last piece of the puzzle are the kinds of activation functions\\footnote{Activation functions are sometimes called \\emph{link} functions in a Generalized Linear Model setting.} that $\\sigma$ might be:\n\\begin{itemize}\n\\item Sigmoid: $\\sigma(x) = \\frac{1}{1+e^{-x}}$\n\\item Hyperbolic tangent: $\\sigma(x) = \\tanh(x)$\n\\item Linear: $\\sigma(x) = x$\n\\item  Rectified Linear Unit: $\\sigma(x) = \\max(0,x)$\n\\item  Exponential Linear Unit: \n$\\sigma(x) =\\left \\{ \n        \\begin{array}{ll}\n\t\tx   & \\text{if } x \\ge 0 \\\\\n\t\ta(e^x - 1)     & \\text{otherwise }\n\t\\end{array}\n\\right. $\n\\item ...\n\\end{itemize}\n\n\\begin{figure}\n\\center{\\includegraphics[scale=0.8] {images/perceptron.png}}\n\\caption{Basic Perceptron/Linear Classifier}\n\\label{fig:perceptron}\n\\end{figure}\n\n\\section{Building a Single Layer Neural Network}\n\\noindent\nSo far we've defined the error $E$ as the MSE, namely, $E := \\frac{1}{m} \\sum\\limits_{i = 1}^{m} (h(\\mathbf{x}_i) - y_i)^2$. Here both the error and the output of the network \n($h_{\\mathbf{w}}(\\mathbf{x}_i) = \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)$) depend on the weight vector $\\mathbf{w}$. We write the error function, parameterized by $\\mathbf{w}$, as\n\n\\begin{flalign}\nE(\\mathbf{w}) := \\frac{1}{m} \\sum\\limits_{i = 1}^{m} (h_{\\mathbf{w}}(\\mathbf{x}_i)  - y_i)^2\n\\end{flalign}\n\n\\bigskip\n\\noindent\nNow, our goal is to find a weight vector $\\mathbf{w}$ such that $E(\\mathbf{w})$ is minimized. In effect this means that the perceptron will correctly predict the output for the inputs in the training set. Of course, we want the perceptron to  \\emph{generalize}, so that it makes correct predictions on the test set and on new examples. But how to do this\nminimization?\n\n\n\\begin{figure}\n\\center{\\includegraphics[scale=0.65] {images/optimization.jpg}}\n\\caption{Non-Convex Error Surface}\n\\label{fig:non-convex}\n\\end{figure}\n\n\\bigskip\n\\noindent\nWe do the minimization by applying the \\emph{gradient descent} algorithm.  In effect we will treat the error as a surface in $n$-dimensional space and search for the greatest downwards slope at the current point $\\mathbf{w}_t$ and will go in that direction to obtain $\\mathbf{w}_{t+1}$. Following this process we will hopefully find a minimum point on the error surface and we will use the coordinates of that point as the final weight vector\\footnote{Consider, however, the situation in which the error surface is non-convex, such as is in Figure \\ref{fig:non-convex}.}. In any event, the update rule can be stated as follows (in both \\emph{partial derivative} and \\emph{gradient} notations):\n\n\\begin{flalign}\n\\mathbf{w}_{t+1} & := \\mathbf{w}_t - \\eta \\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w}}} \n\\quad \\qquad \\qquad  \\mathbin{\\#} \\text{partial derivative notation} \\\\\n\\mathbf{w}_{t+1} & := \\mathbf{w}_t - \\eta \\nabla_{\\mathbf{w}} E(\\mathbf{w}) \n\\:  \\qquad \\qquad  \\mathbin{\\#} \\text{gradient (nabla) notation} \n\\end{flalign}\n\n\\bigskip\n\\noindent\nwhere $\\eta$ is the \\emph{learning rate}. Now, notice that the \\emph{gradient} of $E$ on $w$ is\n\n\\begin{flalign}\n\\nabla_{w} E(\\mathbf{w}) = \\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w}}} = \\Bigg[\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_0}}}, \n\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_1}}}, \\cdots,  \\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_n}}} \\Bigg ]\n\\end{flalign}\n\n\\bigskip\n\\noindent\nNow we can calculate the gradient, $\\nabla_{\\mathbf{w}} E(\\mathbf{w})$.  We start by calculating $\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_j}}}$ for each $j$.  So first....\nNote that the \\emph{chain rule} states that if $h(x) = f(g(x))$ then the derivative $\\frac{d h(x)}{dx} = h^\\prime(x) = f^\\prime(g(x)) g^\\prime(x)$.  We will also use the \\emph{power rule}: If $y = u^n$, then $\\frac{dy}{dx} = n u^{n-1} \\frac{du}{dx}$. So the partial derivative $\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_j}}}$ can be computed as follows: So for example element of the gradient $0 \\le j \\le n$\n\n\\begin{flalign}\n\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_j}}} & = \\frac{\\partial}{\\partial w_j}\n\\frac{1}{m}\\sum\\limits_{i = 1}^m (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i)^2 \n \\qquad \\qquad \\qquad \\qquad  \\qquad \\mathbin{\\#} \\text{definition of } E\\\\\n&=\\frac{1}{m}\\ \\sum\\limits_{i = 1}^m 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\frac{\\partial}{\\partial w_j} (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i)  \\qquad \\quad \\:  \\: \\mathbin{\\#} \\text{power rule} \\\\\n&= \\frac{1}{m}\\ \\sum\\limits_{i = 1}^m 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\frac{\\partial}{\\partial w_j} \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)  \\; \\quad \\qquad \\qquad  \\mathbin{\\#} h_{\\mathbf{w}}(\\mathbf{x}_i) = \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i) \\\\\n&= \\frac{1}{m}\\ \\sum\\limits_{i = 1}^m 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\sigma^\\prime (\\mathbf{w} \\cdot \\mathbf{x}_i)  \\frac{\\partial}{\\partial w_j} \\mathbf{w} \\cdot \\mathbf{x}_i  \\: \\:  \\qquad  \\mathbin{\\#} \\text{chain rule} \\\\\n&= \\frac{1}{m}\\ \\sum\\limits_{i = 1}^m 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\sigma^\\prime (\\mathbf{w}  \\cdot \\mathbf{x}_i)\\frac{\\partial}{\\partial w_j} \\sum\\limits_{k =1}^{n} w_k x_{i,k}  \\:  \\mathbin{\\#} \\text{defn dot product} \\\\\n&= \\frac{1}{m}\\ \\sum\\limits_{i = 1}^m 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\sigma^\\prime (\\mathbf{w} \\cdot \\mathbf{x}_i) x_{i,j}   \\qquad \\quad \\quad \\quad   \\mathbin{\\#} \\frac{\\partial w_k x_{i,k}}{\\partial w_j} \\ne 0 \\text { when } k = j\n\\end{flalign}\n\n\\bigskip\n\\noindent\nNote that going from Equation 7 to Equation 8 uses the \\emph{sum rule}\n\n\\bigskip\n\\begin{flalign}\n\\frac{d}{dx} (f(x) + g(x)) &= \\frac{d}{dx} f(x) + \\frac{d}{dx} g(x)\n\\end{flalign}\n\n\\bigskip\n\\noindent\nHere $f(x) = h_{\\mathbf{w}}(\\mathbf{x}_i)$ and $g(x) = -y_i$. $\\frac{\\partial}{\\partial w_j} h_{\\mathbf{w}}(\\mathbf{x}_i) = \\frac{\\partial}{\\partial w_j}  \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)$ and $\\frac{\\partial y_i}{\\partial w_j} = 0$, so we're left with term  $\\frac{\\partial}{\\partial w_j} \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)$ as we see in Equation 8.\n\n\\bigskip\n\\noindent\nNow, using the sigmoid activation function $\\sigma(x) = \\frac{1}{1+e^{-x}}$, who's derivative \n$\\sigma^\\prime(x) = \\sigma(x) (1 - \\sigma(x))$, gives us\n\\begin{flalign}\n\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w_j}}} \n& = \\frac{2}{m} \\sum\\limits_{i = 1}^m (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i)  \\sigma^\\prime (\\mathbf{w} \\cdot \\mathbf{x}_i) x_{i,j}  \\\\\n&=  \\frac{2}{m} \\sum\\limits_{i = 1}^m (\\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i) -y_i) \\sigma(\\mathbf{w} \\cdot \\mathbf{x})  (1 - \\sigma(\\mathbf{w} \\cdot \\mathbf{x})) x_{i,j} \\\\\n\\end{flalign}\n\n\\noindent\nNow, we can compute the gradient $\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w}}}$ as follows:\n\n\\begin{flalign}\n\\frac{\\partial E(\\mathbf{w})}{\\partial{\\mathbf{w}}} &=\\frac{2}{m} \\sum\\limits_{i = 1}^m (\\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i) -y_i) \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)  (1 - \\sigma(\\mathbf{w} \\cdot \\mathbf{x}_i)) \\mathbf{x}_i \\\\\n\\end{flalign}\n\n\\noindent\nFinally, let the update rate $\\eta = 0.1$. Then the update to $\\mathbf{w}$ is computed as\n\\begin{flalign}\n\\mathbf{w}_{t+1} := \\mathbf{w}_t - \\frac{0.2}{m} \\sum\\limits_{i = 1}^m (h_\\mathbf{w}(\\mathbf{x}_i) - y_i) \nh_\\mathbf{w}(\\mathbf{x}_i ) (1 - h_\\mathbf{w}(\\mathbf{x}_i ) ) \\mathbf{x}_i\n\\end{flalign}\nwhere $h_\\mathbf{w}(\\mathbf{x}_i) = \\sigma(\\mathbf{w}_t \\cdot \\mathbf{x}_i)$.\n\n\n\\section{What About Multilayer Networks?}\n\nConsider a more general multilayer neural network, such as shown in Figure \\ref{fig:multi-layer-perceptron}. Here we are using the notation $w_{i , j}$ to denote the weights on the connection between perceptrons (nodes) $i$ and $j$. Note that the notation  $w_{i \\rightarrow j} \\equiv w_{i, j}$ in Figure \\ref{fig:multi-layer-perceptron}.  Now,  armed with this notation we can write the sum of the inputs to perceptron (node) $j$ as \n\n\\begin{flalign}\ns_j := \\sum\\limits_{k} z_k w_{k, j}\n\\end{flalign}\n\n\\noindent\nHere $k$ iterates over all the perceptrons connected to $j$. The output of $j$ is written as $z_j = \\sigma (s_j)$, where $\\sigma$ is $j$'s activation (link) function.\n\n\\bigskip\n\\noindent\nNow, we can use the same error (cost) function for the multlayer network, $E(\\mathbf{w})$\n\n\\begin{flalign}\nE(\\mathbf{w}) := \\frac{1}{m} \\sum\\limits_{i = 1}^{m} (h_{\\mathbf{w}}(\\mathbf{x}_i)  - y_i)^2\n\\end{flalign}\n\\noindent\nexcept that now $\\mathbf{w}$ is a matrix that contains all the weights for the network: \\\\\n$\\mathbf{w} = [w_{i , j}] \\; \\forall i,j$.\n \n \\bigskip\n \\noindent\nThe goal is again to find the $\\mathbf{w}$ that minimizes $E(\\mathbf{w})$ using gradient descent. So we need to calculate $\\frac{\\partial E(\\mathbf{w})}{\\partial \\mathbf{w}}$. The first step is to separate the contributions of each of the $m$ training examples using the following observation:\n\n\\begin{flalign}\n\\frac{\\partial E(\\mathbf{w})}{\\partial \\mathbf{w}} = \\frac{1}{m}\\sum\\limits_{i = 1}^m \\frac{\\partial E_i(\\mathbf{w})}{\\partial \\mathbf{w}}\n\\end{flalign}\n\n\\noindent\nwhere $E_i(\\mathbf{w}) = (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i)^2$. Then\n\n\\begin{flalign}\n\\frac{\\partial E_i(\\mathbf{w})}{\\partial w_{j , k}} \n&= \\frac{\\partial}{\\partial w_{j , k}} (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i)^2  \\qquad \\qquad \\qquad \\qquad  \\: \\: \\mathbin{\\#} \\text{definition of } E\\\\\n& = 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial w_{j , k}} \\\\\n& = 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_k} \\frac{\\partial s_k}{\\partial w_{j , k}}  \\qquad \\quad \\quad \\quad   \\mathbin{\\#} \\text{chain rule} \n\\label{eqn:cr} \\\\\n&= 2 (h_{\\mathbf{w}}(\\mathbf{x}_i) - y_i) \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_k} z_j\n\\label{eqn:z}\n\\end{flalign}\n\n\\begin{figure}\n\\center{\\includegraphics[scale=0.6] {images/multi-layer-perceptron.png}}\n\\caption{Multi-Layer Perceptron}\n\\label{fig:multi-layer-perceptron}\n\\end{figure}\n\n\n\n\\bigskip\n\\noindent\nNote that in going from Equation \\ref{eqn:cr} to  Equation \\ref{eqn:z},  $s_k = \\sum\\limits_{i} z_i w_{i , k}$, so $\\frac{\\partial s_k}{\\partial w_{j , k}} \\ne 0$ where $i = j$ and 0 otherwise.\n\n\\bigskip\n\\noindent\nNow, if the $k^\\text{th}$ node is an output node,  then\n\n\\bigskip\n\\begin{flalign}\n\\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_k}   \n&= \\frac{\\partial \\sigma(s_k)}{\\partial s_k}  = \\sigma^\\prime(s_k)\n\\end{flalign}\n\n\\bigskip\n\\noindent\nso that \n\\begin{flalign}\n\\frac{\\partial E_i(\\mathbf{w})} {\\partial w_{j , k}} = 2 (h{\\mathbf{w}}(\\mathbf{x}_i) -y_i) \\sigma^\\prime(s_k) z_j\n\\end{flalign}\n\n\\bigskip\n\\noindent\nOn the other hand, if $k$ is not an output node, then changes to $s_k$ can affect all the nodes which are connected to $k$'s output, as follows\n\n\\begin{flalign}\n\\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_k} &= \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial z_k} \\frac{\\partial z_k}{\\partial s_k}  \\qquad \\qquad \\quad \\qquad \\qquad \\qquad   \\mathbin{\\#} \\text{chain rule again} \\\\\n&= \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial z_k}  \\sigma^\\prime(s_k)\n \\qquad  \\qquad \\qquad  \\qquad \\qquad  \\mathbin{\\#}  z_k = \\sigma(s_k) \\\\\n &= \\sum\\limits_{o \\in \\{v \\mid v \\rightarrow  k\\}} \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_o} \\frac{\\partial s_o}{\\partial z_k} \\sigma^\\prime(s_k)  \\qquad \\quad \\quad  \\:  \\mathbin{\\#} v \\text{ is connected to } k\n\\label{eqn:zo0} \\\\\n &= \\sum\\limits_{o \\in \\{v \\mid v \\rightarrow  k\\}} \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_o} w_{k , o}  \\sigma^\\prime(s_k)  \\qquad \\quad \\quad  \\:  \\mathbin{\\#} s_o = \\sum\\limits_{i} z_i w_{i , o}\n\\label{eqn:zo1}\n\\end{flalign}\n\n\\bigskip\n\\noindent\nNote that in going from Equation \\ref{eqn:zo0} to Equation \\ref{eqn:zo1} we see that  \n\\bigskip\n\\begin{flalign}\n\\frac{\\partial s_o}{\\partial z_k} &= \\frac{\\partial}{\\partial z_k} \\sum\\limits_i z_i w_{i , o}\n\\end{flalign}\n\\bigskip\n\\noindent\nwhich is only non-zero when $i = k$, so that $\\frac{\\partial s_o}{\\partial z_k} = w_{k , o}$ (Equation \\ref{eqn:zo1}).\n\n\\noindent\nSo what is left is to calculate $s_k$ and $z_k$ (feeding forward) and then work backwards from the output calculating \n$\\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_k}$ and back propagate the error down the network (\"backprop\"). The summary looks like:\n\n\\bigskip\n\\begin{itemize}\n\\item $k$ is an output node: $\\frac{\\partial E_i(\\mathbf{w})} {\\partial w_{j , k}} = 2 (h{\\mathbf{w}}(\\mathbf{x}_i) -y_i) \\sigma^\\prime(s_k) z_j$\n\\item otherwise: $\\frac{\\partial E_i(\\mathbf{w})} {\\partial w_{j , k}} = 2 (h{\\mathbf{w}}(\\mathbf{x}_i) -y_i) \\sigma^\\prime(s_k) z_j \\sum\\limits_{o \\in \\{v \\mid v , k\\}} \\frac{\\partial h_{\\mathbf{w}}(\\mathbf{x}_i)}{\\partial s_o} w_{k , o}$\n\\end{itemize}\n\n\\bigskip\n\\noindent\nUsing these results we see that\n\n\\bigskip\n\\begin{flalign}\n\\frac{\\partial E_i(\\mathbf{w})}{\\partial \\mathbf{w}} = \\Bigg [\\frac{\\partial E_i(\\mathbf{w})} {\\partial w_{j , k}} \\Bigg ] \\: \\: \\forall j,k\n\\end{flalign}\n\n\\bigskip\n\\noindent\nFinally, the weights can be updated in batch mode, in which case the update rule  for batch size of $m$ is\n\\begin{flalign}\n\\mathbf{w}_{t+1} & := \\mathbf{w}_t - \\eta \\frac{\\partial E(\\mathbf{w})}{\\partial \\mathbf{w}} \\\\\n& := \\mathbf{w}_t - \\eta \\sum\\limits_{i = 1}^m \\frac{\\partial E_i(\\mathbf{w})}{\\partial \\mathbf{w}}\n\\end{flalign}\n\n\\bigskip\n\\noindent\nOr if we take a Stochastic Gradient Descent (SGD) approach (one training example at a time):\n\\begin{flalign}\n\\mathbf{w}_{t+1} & := \\mathbf{w}_t - \\eta \\frac{\\partial E(\\mathbf{w})}{\\partial \\mathbf{w}} \n\\end{flalign}\n\n\\bigskip\n\\section{Acknowledgements}\n\\noindent \nThanks to Armin Wasicek for his careful reading of earlier versions of this document.\n\n% \\newpage\n\\bibliographystyle{plain}\n\\bibliography{/Users/dmm/papers/bib/ml}\n\n\n\\end{document} \n\n", "meta": {"hexsha": "bde5138e1473c9c3db80bacb68f56879057aa6dc", "size": 18174, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_my_stuff/papers/ml/mse/mse.tex", "max_stars_repo_name": "davidmeyer/davidmeyer.github.io", "max_stars_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_my_stuff/papers/ml/mse/mse.tex", "max_issues_repo_name": "davidmeyer/davidmeyer.github.io", "max_issues_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_my_stuff/papers/ml/mse/mse.tex", "max_forks_repo_name": "davidmeyer/davidmeyer.github.io", "max_forks_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.9075630252, "max_line_length": 962, "alphanum_fraction": 0.6711786068, "num_tokens": 6676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017746, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.4379265277536424}}
{"text": "\\documentclass{beamer}\n\\usetheme{Warsaw}\n\\usepackage{nhtvslides}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\lstset{language=CAML,\nbasicstyle=\\ttfamily\\footnotesize,\nframe=shadowbox,\nbreaklines=true}\n\\usepackage[utf8]{inputenc}\n\n\\title{Integration, rotation matrices, and quaternions}\n\n\\author{Dr. Giuseppe Maggiore}\n\n\\institute{NHTV University of Applied Sciences \\\\ \nBreda, Netherlands}\n\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\begin{frame}{Table of contents}\n\\tableofcontents\n\\end{frame}\n\n\\section{Integration and rotation}\n\\begin{slide}{Integration and rotation}{Integration and rotation}{\n\\item We integrate $L$ from $\\tau$\n\\item We integrate $w$ from $L$ and $J^-1$\n\\item We integrate $R$ from $w$\n}\\end{slide}\n\n\\begin{slide}{Integration and rotation}{Issues}{\n\\item \\textit{Issue 1:} recomputing $J$ from every particle of the body and at every tick is too slow\n\\item \\textit{Issue 2:} integrating $R$ slowly ``breaks it'', meaning that $[T\\ N\\ B]$ is not a rotation anymore\n}\\end{slide}\n\n\\section{Caching J}\n\\begin{slide}{Caching J}{Issue 1: body shape}{\n\\item $J$ represents the tendency of the body to resist rotation\n\\item But the body just moves and rotates, it does not change shape\n\\item We should be able to simply recompute $J$ from its initial value and the rotation\n}\\end{slide}\n\n\\begin{frame}{Caching J}\n\\begin{block}{$J$ from $J_{body}$}\n\\begin{eqnarray}\nJ &=& \\sum_i(|r_i(t)|^2I - r_i(t) r_i^T(t)) \\\\\n&=& \\sum_i(|R r_i(t_0)|^2I - R r_i(t_0) r_i^T(t_0) R^T) \\\\\n&=& \\sum_i(|r_i(t_0)|^2I - R r_i(t_0) r_i^T(t_0) R^T) \\\\ % rotation keeps length\n&=& \\sum_i(|r_i(t_0)|^2 R R^T - R r_i(t_0) r_i^T(t_0) R^T) \\\\ % R R^T = I\n&=& \\sum_i(R |r_i(t_0)|^2 R^T - R r_i(t_0) r_i^T(t_0) R^T) % scalar and matrix multiplication is commutative\n\\end{eqnarray}\n\\end{block}\n\\end{frame}\n\n\\begin{frame}{Caching J}\n\\begin{block}{$J$ from $J_{body}$}\n\\begin{eqnarray}\nJ &=& \\sum_i(R |r_i(t_0)|^2 R^T - R r_i(t_0) r_i^T(t_0) R^T) \\\\ % scalar and matrix multiplication is commutative\n&=& \\sum_i R(|r_i(t_0)|^2 - r_i(t_0) r_i^T(t_0)) R^T \\\\ % grouping\n&=& R \\left( \\sum_i (|r_i(t_0)|^2 - r_i(t_0) r_i^T(t_0)) \\right) R^T \\\\ % grouping\n&=& R J_{body} R^T\n\\end{eqnarray}\n\\end{block}\n\\end{frame}\n\n\\begin{slide}{Caching J}{$J^{-1}$ from $J_{body}{-1}$}{\n\\item We need $J^{-1}$ more than $J$\n\\item We can compute it without an inversion though\n\\item We compute (just once) $J_{body}^{-1}$\n\\item $J^{-1} (R J_{body} R^T)^{-1} = R J_{body}^{-1} R^T$\n}\\end{slide}\n\n\\section{Orthonormalization of $R$}\n\\begin{slide}{Orthonormalization of $R$}{Issue 2: $R$ is a rotation matrix}{\n\\item $R = [T\\ N\\ B]$\n\\item The vectors $T$, $N$, and $B$ must be of unit length and orthonormal ($T \\cdot N = 0, T \\cdot B = 0, \\dots$)\n\\item As we integrate $R$, this stops being true\n\\item $R$ stops being just a rotation matrix, and also incorporates some scale and some skew\n\\item This is very bad!\n}\\end{slide}\n\n\\begin{frame}{Boxes stop being boxes}\n\\center\n\\includegraphics[height=5cm]{Pics/Kill_me_please.png}\n\\end{frame}\n\n\\begin{slide}{Orthonormalization of $R$}{Gram-Schimdt method}{\n\\item $\\hat R = [\\hat T\\ \\hat N\\ \\hat B]$\n\\item We normalize $T = \\frac{\\hat T}{|\\hat T|}$\n\\item We remove the projection of $\\hat N$ over $T$: $\\hat N' = \\hat N - \\hat N (\\hat N \\cdot T)$\n\\item We normalize $N = \\frac{\\hat N'}{|\\hat N'|}$\n\\item We compute $B = T \\times N$\n}\\end{slide}\n\n\\begin{slide}{Orthonormalization of $R$}{Gram-Schimdt method}{\n\\item Lot of useless computation\n\\item Matrix representation very redundant\n\\item $\\hat B$ is completely unneeded and is ignored!\n}\\end{slide}\n\n\\section{Using quaternions}\n\\begin{slide}{Using quaternions}{About quaternions}{\n\\item We just need a single rotation around an axis (which is an arbitrary rotation in 3D)\n\\item Less degrees of freedom means less drift and less need for normalization\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Let us consider a rotation matrix around the Z axis\n\\item $R_0 = \\left[ \\begin{matrix}\n\\cos \\theta & -\\sin \\theta & 0 \\\\\n\\sin \\theta & \\cos \\theta & 0 \\\\\n0 & 0 & 1\\\\\n\\end{matrix} \\right] = \n\\left[ \\begin{matrix}\nc & -s & 0 \\\\\ns & c & 0 \\\\\n0 & 0 & 1 \\\\\n\\end{matrix} \\right]$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Any vector $v$ on the XY plane rotated by $R_0$ remains on XY, rotated around Z by an angle $\\theta$\n\\item Any vector $v$ on the Z axis rotated by $R_0$ remains (identical) on Z\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Let us transform this rotation into an arbitrary rotation $R_1$ around an axis $d$ and of angle $\\theta$\n\\item We consider an \\textit{orthonormal basis} $a,b,d$\n\\item We perform a \\textit{basis change} of $R_0$ onto $a,b,d$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item We need to build $R_1$ such that\n\\begin{itemize}\n\\item $R_1 a = ca + sb$\n\\item $R_1 b = -sa + cb$\n\\item $R_1 d = d$\n\\end{itemize}\n\\item That is $R_1 \\underbrace{[a\\ b\\ d]}_P = \\underbrace{[a\\ b\\ d]}_P R_0$\n\\item $P^{-1} = P^T$, so $R_1 = P R_0 P^T = c(aa^T + bb^T) + s(ba^T - ab^T) + dd^T$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item $R_1 = c(aa^T + bb^T) + s(ba^T - ab^T) + dd^T$\n\\item This means that we can now construct a rotation matrix from an axis and an angle\n\\item Unfortunately we also need two ``dummy'' vectors $a$ and $b$\n\\item Any pair of those suffices, as long as they are correctly related to $d$\n\\item We now remove the explicit dependency on them\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Consider a vector expressed in relationship to $a,b,d$: $v = \\underbrace{\\alpha}_{a \\cdot v} a + \\underbrace{\\beta}_{b \\cdot v} b + \\underbrace{\\delta}_{d \\cdot v} d$\n\\item We now consider two arbitrary but useful quantities:\n\\item $d \\times v = d \\times (\\alpha a + \\beta b + \\delta d) = \\alpha d \\times a + \\beta d \\times b + \\delta d \\times d = -\\beta a + \\alpha b = Dv = \\left[ \\begin{matrix}\n0 & -d_z & d_y \\\\\nd_z & 0 & -d_x \\\\\n-d_y & d_x & 0 \\\\\n\\end{matrix} \\right] v$\n\\item $d \\times (d \\times v) = d \\times (-\\beta a + \\alpha b) = -\\alpha a - \\beta b = D^2v$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Now let us study the progression of $Iv, Dv, D^v$\n\\item $Iv = v = \\alpha a + \\beta b + \\delta d = aa^Tv + bb^Tv + dd^Tv$, so $I = aa^T + bb^T + dd^T$\n\\item $Dv = \\alpha b - \\beta a = ba^Tv - ab^Tv$, so $D = ba^T-ab^T$\n\\item $D^2v = -\\alpha a - \\beta b = \\delta d - v = dd^Tv - v$, so $D^2 = dd^T - I$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item We combine those three into $R_1 = c(aa^T + bb^T) + s(ba^T - ab^T) + dd^T$\n\\item $I = aa^T + bb^T + dd^T$, $D = ba^T-ab^T$, $D^2 = dd^T - I$\n\\pause \n\\item $R_1 = c(I - dd^T) + sD + dd^T$\n\\item $R_1 = I + sD + (1-c)D^2$\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item We can now compute $R_1 = I + sD + (1-c)D^2$ from just $d, \\theta$\n\\item Moreover, we can rotate a vector without even building $R_1$\n\\begin{eqnarray}\nR_1v &=& (I + s D + (1-c)D^2)v \\\\\n&=& Iv + s D v + (1-c)D^2 v \\\\\n&=& v + s d\\times v + (1-c)d \\times (d \\times v)\n\\end{eqnarray}\n}\\end{slide}\n\n\\begin{slide}{Using quaternions}{Quaternion primer}{\n\\item Any representation of $d$ and $\\theta$ would be fine\n\\item A particularly convenient one is $[\\cos \\frac{\\theta}{2}, \\sin \\frac{\\theta}{2} d]$\n}\\end{slide}\n\n\\section{Time derivative of a quaternion}\n\\begin{slide}{Deriving quaternions}{Derivative of rotation matrix}{\n\\item We studied how to compute $\\dot R$ from $R$ and $\\omega$\n\\item If we represent rotations with quaternions, we need to compute $\\dot q$\n}\\end{slide}\n\n\\begin{slide}{Deriving quaternions}{Derivative of quaternion}{\n\\item Given the current orientation $q(t_0)$ and angular velocity $\\omega(t_0)$\n\\item Assuming very small $t-t_0$\n\\item The derivative of the original quaternion is $\\frac{d}{dt}\\underbrace{[\\cos \\frac{|\\omega(t_0)|(t-t_0)}{2}, \\frac{\\omega(t_0)}{|\\omega(t_0)|} \\sin \\frac{|\\omega(t_0)|(t-t_0)}{2}]}_{\\omega \\text{ converted to a quaternion}} q(t_0)$\n}\\end{slide}\n\n\\begin{slide}{Deriving quaternions}{Derivative of quaternion}{\n\\item $\\frac{d}{dt}[\\cos \\frac{|w(t_0)|(t-t_0)}{2}, \\frac{w(t_0)}{|w(t_0)|} \\sin \\frac{|w(t_0)|(t-t_0)}{2}] q(t_0)$\n\\item We now derive the $w$ part ($q(t_0)$ is a constant) and replace $t$ with $t_0$ because we want to know the value of the derivative at the current time $t_0$\n\\item $[-\\frac{|\\omega(t_0)|}{2} \\sin \\frac{|\\omega(t_0)|(t_0-t_0)}{2}, \\frac{\\omega(t_0)}{|\\omega(t_0)|} \\frac{|\\omega(t_0)|}{2} \\cos \\frac{|\\omega(t_0)|(t-t_0)}{2}] q(t_0)$\n\\item $[-\\frac{|\\omega(t_0)|}{2} \\sin 0, \\frac{\\omega(t_0)}{|\\omega(t_0)|} \\frac{|\\omega(t_0)|}{2} \\cos 0] q(t_0)$\n\\item $[0, \\frac{\\omega(t_0)}{2}] q(t_0) = \\frac{1}{2} [0, \\omega(t_0)] q(t_0)$\n}\\end{slide}\n\n\\begin{slide}{Deriving quaternions}{Derivative of quaternion}{\n\\item At least remember this:\n\\item $\\dot q = \\frac{1}{2} [0, \\omega] q$\n}\\end{slide}\n\n\\section{Kinematics source code}\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n// initialization \nRigidBody* body[n]; \ndouble t = <your choice of initial time>; \ndouble dt = <your choice of time step>; \nfor (int i = 0; i < n; ++i) { \n  // Set the initial state of the rigid bodies. \n  body[i] = new RigidBody(...);\n\n// Part of the physics tick. \nfor (i = 0; i < n; ++i) { \n  body[i].Update(t, dt);\n  t += dt;\n}\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\nstruct RigidBody {\n  RigidBody (double m, matrix inertia, Function force, Function torque);\n\n  // force/torque function format \n  typedef vector ( *Function ) (\n    double, // time of application\n    point, // position\n    quaternion, // orientation\n    ... // whole state of body, one var at a time\n    )\n  );\n\n  // Runge-Kutta fourth order differential equation solver \n  void Update (double t, double dt);\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\nprotected: \n  // convert (Q,P,L) to (R,V,W) \n  void Convert (quaternion Q, vector P, vector L, matrix& R, vector& V, vector& W) const;\n  // constant quantities \n  double m_mass, m_invMass; \n  matrix m_inertia, m_invInertia;\n  // state variables \n  vector m_X; // position \n  quaternion m_Q; // orientation \n  vector m_P; // linear momentum \n  vector m_L; // angular momentum\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n  // derived state variables \n  matrix m_R; // orientation matrix \n  vector m_V; // linear velocity vector \n  m_W; // angular velocity\n  // force and torque functions \n  Function m_force; Function m_torque;\n};\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\nvoid RigidBody::Convert (quaternion Q, vector P, vector L, matrix& R, vector& V, vector& W) const { \n  Q.ToRotationMatrix(R); \n  V = m_invMass*P; \n  W = R*m_invInertia*Transpose(R)*L; \n}\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\nvoid RigidBody::Update (double t, double dt) { \n  double halfdt = 0.5 * dt, sixthdt = dt / 6.0;\n  double tphalfdt = t + halfdt, tpdt = t + dt;\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n  vector XN, PN, LN, VN, WN; \n  quaternion QN; \n  matrix RN;\n  // A1 = G(t,S0), B1 = S0 + (dt / 2) * A1 \n  vector A1DXDT = m_V; \n  quaternion A1DQDT = 0.5 * m_W * m_Q; \n  vector A1DPDT = m_force(t,m_X,m_Q,m_P,m_L,m_R,m_V,m_W); \n  vector A1DLDT = m_torque(t,m_X,m_Q,m_P,m_L,m_R,m_V,m_W); \n  XN = m_X + halfdt * A1DXDT; \n  QN = m_Q + halfdt * A1DQDT; \n  PN = m_P + halfdt * A1DPDT; \n  LN = m_L + halfdt * A1DLDT; \n  Convert(QN,PN,LN,RN,VN,WN);\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n  // A2 = G(t + dt / 2,B1), B2 = S0 + (dt / 2) * A2 \n  vector A2DXDT = VN; \n  quaternion A2DQDT = 0.5 * WN * QN; \n  vector A2DPDT = m_force(tphalfdt,XN,QN,PN,LN,RN,VN,WN); \n  vector A2DLDT = m_torque(tphalfdt,XN,QN,PN,LN,RN,VN,WN); \n  XN = m_X + halfdt * A2DXDT; \n  QN = m_Q + halfdt * A2DQDT; \n  PN = m_P + halfdt * A2DPDT; \n  LN = m_L + halfdt * A2DLDT; \n  Convert(QN,PN,LN,RN,VN,WN);\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n  // A3 = G(t + dt / 2,B2), B3 = S0 + dt * A3 \n  vector A3DXDT = VN; \n  quaternion A3DQDT = 0.5 * WN * QN;\n\n  vector A3DPDT = m_force(tphalfdt,XN,QN,PN,LN,RN,VN,WN); \n  vector A3DLDT = m_torque(tphalfdt,XN,QN,PN,LN,RN,VN,WN); \n  XN = m_X + dt * A3DXDT; \n  QN = m_Q + dt * A3DQDT; \n  PN = m_P + dt * A3DPDT; \n  LN = m_L + dt * A3DLDT; \n  Convert(QN,PN,LN,RN,VN,WN);\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Kinematics source code}\n\\begin{lstlisting}\n  // A4 = G(t + dt,B3), \n  // S1 = S0 + (dt / 6) * (A1 + 2 * A2 + 2 * A3 + A4) \n  vector A4DXDT = VN; \n  quaternion A4DQDT = 0.5 * WN * QN; \n  vector A4DPDT = m_force(tpdt,XN,QN,PN,LN,RN,VN,WN); \n  vector A4DLDT = m_torque(tpdt,XN,QN,PN,LN,RN,VN,WN); \n  m_X = m_X + sixthdt*(A1DXDT + 2.0*(A2DXDT + A3DXDT) + A4DXDT); \n  m_Q = m_Q + sixthdt*(A1DQDT + 2.0*(A2DQDT + A3DQDT) + A4DQDT); \n  m_P = m_P + sixthdt*(A1DPDT + 2.0*(A2DPDT + A3DPDT) + A4DPDT); \n  m_L = m_L + sixthdt*(A1DLDT + 2.0*(A2DLDT + A3DLDT) + A4DLDT); \n  Convert(m_Q,m_P,m_L,m_R,m_V,m_W);\n}\n\\end{lstlisting}\n\\end{frame}\n\n\n\\begin{frame}{That's it}\n\\center\n\\fontsize{18pt}{7.2}\\selectfont\nThank you!\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "49ec984888ad4347fb3b039bcb38b0234a1aa596", "size": 13423, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/Lecture 3/Lecture 3.tex", "max_stars_repo_name": "hogeschool/TINWIS01-7", "max_stars_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2015-10-02T23:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T04:08:27.000Z", "max_issues_repo_path": "Slides/Lecture 3/Lecture 3.tex", "max_issues_repo_name": "hogeschool/TINWIS01-7", "max_issues_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-08-16T10:05:36.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-16T10:05:47.000Z", "max_forks_repo_path": "Slides/Lecture 3/Lecture 3.tex", "max_forks_repo_name": "hogeschool/TINWIS01-7", "max_forks_repo_head_hexsha": "410b0064f541474f102a3037866e625725fed4c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-25T02:31:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-04T07:48:25.000Z", "avg_line_length": 35.4168865435, "max_line_length": 236, "alphanum_fraction": 0.6576026224, "num_tokens": 4979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.4379265277536423}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\begin{document}\n\n\\title{Dynamics and Relativity}\n\\date{Lent 2016}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{System of masses}\n\\subsection{System of masses}\n\\subsubsection{Motion relative to the centre of mass}\nLet $\\mathbf{r_{i}}=\\mathbf{R}+\\mathbf{r_{i}}^c$, where $\\mathbf{r_{i}}^c$ is the position of particle relative to the centre of mass.\\\\\nThen\\\\\n\\begin{equation*}\n\\begin{aligned}\n\\sum_{i} m_{i}\\mathbf{r_{i}}^c &= \\sum_{i}m_{i} \\mathbf{r_{i}}^c - \\sum_{i} m_{i} \\mathbf{R}\\\\\n&=M\\mathbf{R} - M\\mathbf{R}\\\\\n&=\\mathbf{0}\\\\\n& \\implies \\sum_{i}m_{i}\\mathbf{\\dot{r_{i}}}^c = \\mathbf{0}.\n\\end{aligned}\n\\end{equation*}\nThe total linear momentum, angular momentum and kinetic energy are :\\\\\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{P} &= \\sum_{i} m_{i}\\left(\\dot{\\mathbf{R}}+\\dot{\\mathbf{r_{i}}}^c\\right)\\\\\n&= M\\dot{\\mathbf{R}}\n\\end{aligned}\n\\end{equation*}\n\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{L} &= \\sum_{i} m_{i} \\left(\\mathbf{R}+ \\mathbf{r_{i}}^c \\right) \\times \\left(\\dot{\\mathbf{R}} + \\dot{\\mathbf{r_{i}}}^c\\right)\\\\\n&= \\sum_{i} m_{i} \\mathbf{R} \\times \\dot{\\mathbf{R}} + \\mathbf{R} \\times \\sum_{i} m_{i} \\dot{\\mathbf{r_{i}}}^c\\\\\n&= M\\mathbf{R}\\times \\dot{\\mathbf{R}} + \\sum_{i} m_{i} \\mathbf{r_{i}}^c \\times \\dot{\\mathbf{r_{i}}}^c.\n\\end{aligned}\n\\end{equation*}\n\n\\begin{equation*}\n\\begin{aligned}\nT &= \\frac{1}{2} \\sum_{i} m_{i} |\\dot{\\mathbf{r_{i}}}|^2\\\\\n&= \\frac{1}{2} \\sum_{i} m_{i} \\left( \\dot{\\mathbf{R}} + \\dot{\\mathbf{r_{i}}}^c \\right) \\cdot \\left( \\dot{\\mathbf{R}} + \\dot{\\mathbf{r_{i}}}^c \\right)\\\\\n&= \\frac{1}{2} \\sum_{i} m_{i} \\dot{\\mathbf{R}} \\cdot \\dot{\\mathbf{R}} + \\dot{\\mathbf{R}}\\cdot \\sum_{i} m_{i}\\dot{\\mathbf{r_{i}}}^c + \\frac{1}{2} \\sum_{i} m_{i} \\dot{\\mathbf{r_{i}}}^c \\cdot \\dot{\\mathbf{r_{i}}}^c\\\\\n&= \\frac{1}{2} M |\\dot{\\mathbf{R}}|^2 + \\frac{1}{2} \\sum_{i} m_{i} |\\dot{\\mathbf{r_{i}}}^c|^2\\\\\n&= \\text{KE of centre of mass + KE of motion relative to centre of mass.}\n\\end{aligned}\n\\end{equation*}\n\nIf the forces are conservative in the sense that \n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{F_{i}}^{ext} = -\\nabla_{i} V_{i} \\left(\\mathbf{r_{i}}\\right)\n\\end{aligned}\n\\end{equation*}\nand $\\mathbf{F_{ij}} = -\\nabla_{i} V_{ij} \\left(\\mathbf{r_{i}}-\\mathbf{r{j}}\\right)$,\\\\\nwhere $\\nabla_{i}$ is the gradient with respect to $\\mathbf{r_{i}}$, then energy is conserved in the form\n\n\\begin{equation*}\n\\begin{aligned}\nE &= T + \\sum_{i} V_{i} \\left(\\mathbf{r_{i}}\\right) + \\frac{1}{2} \\sum_{i} \\sum_{j} V_{ij}\\left(\\mathbf{r_{i}}-\\mathbf{r_{j}}\\right) &= constant.\n\\end{aligned}\n\\end{equation*}\n\n\\subsubsection{The two-body problem}\nConsider two particles with no external forces.\\\\\nThe centre of mass is at \\\\\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{R} = \\frac{1}{M}\\left(m_{1}\\mathbf{r_{1}}+m_{2}\\mathbf{r_{2}}\\right)\n\\end{aligned}\n\\end{equation*}\nwith $M=m_{1}+m_{2}$.\\\\\nDefine the separation vector(relative position vector):\\\\\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{r} = \\mathbf{r_{1}}-\\mathbf{r_{2}}.\n\\end{aligned}\n\\end{equation*}\n\\includegraphics[scale=0.15]{Rel01}\\\\\nThen \n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{r_{1}} = \\mathbf{R} + \\frac{m_{2}}{M}\\mathbf{r},\\\\\n\\mathbf{r_{2}} = \\mathbf{R} + \\frac{m_{1}}{M}\\mathbf{r}.\n\\end{aligned}\n\\end{equation*}\n\nSince $\\mathbf{F}=\\mathbf{0}$ (no external forces), $\\ddot{\\mathbf{R}} = \\mathbf{0}$.\\\\\nThe centre of mass moves uniformly.\\\\\nMeanwhile,\n\\begin{equation*}\n\\begin{aligned}\n\\ddot{\\mathbf{r}} &= \\ddot{\\mathbf{r_{1}}} - \\ddot{\\mathbf{r_{2}}}\\\\\n&= \\frac{1}{m_{1}} \\mathbf{F_{12}} - \\frac{1}{m_{2}} \\mathbf{f_{21}}\\\\\n&= \\left(\\frac{1}{m_{1}}+\\frac{1}{m_{2}}\\right)\\mathbf{F_{12}} \\text{ (using N3L)}\n\\end{aligned}\n\\end{equation*}\n\nThus\n\\begin{equation*}\n\\begin{aligned}\n\\mu \\ddot{\\mathbf{r}} &= \\mathbf{F_{12}}\\left(\\mathbf{r}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere \n\\begin{equation*}\n\\begin{aligned}\n\\mu = \\frac{m_{1}m_{2}}{m_{1}+m_{2}}\n\\end{aligned}\n\\end{equation*}\nis the \\emph{reduced mass}.\\\\\nThis is the same as the equation of motion for one particle of mass $\\mu$ with position vector $\\mathbf{r}$ relative to a fixed origin as studied previously.\\\\\n\n\\begin{eg} with gravity:\n\\begin{equation*}\n\\begin{aligned}\n\\mu \\ddot{\\mathbf{r}} &= -\\frac{G m_{1} m_{2} \\mathbf{r}}{|\\mathbf{r}|^3} \\implies \\ddot{\\mathbf{r}} = -\\frac{GM\\mathbf{\\hat{r}}}{|\\mathbf{r}|^2}\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\n\\begin{eg} planet orbiting the Sun:\\\\\nBoth planet and Sun move in an ellipse about their centre of mass. Because the Sun is much more massive, its ellipse is much smaller. Orbital period depends on the total mass (Sun + planet).\\\\\n\\includegraphics[scale=0.15]{Rel02}\\\\\\\\\nOr binary black hole:\\\\\n\\includegraphics[scale=0.15]{Rel03}\\\\\\\\\nIt can be shown that\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{L} = M\\mathbf{R}\\times \\dot{\\mathbf{R}} + \\mu \\mathbf{r} \\times \\dot{\\mathbf{r}}\n\\end{aligned}\n\\end{equation*}\n\\begin{equation*}\n\\begin{aligned}\nT = \\frac{1}{2} M |\\dot{\\mathbf{R}}|^2 + \\frac{1}{2} \\mu |\\dot{\\mathbf{r}}|^2\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\n\\subsubsection{Variable-mass problems}\nNewton's Second Law is\\\\\n\\begin{equation*}\n\\begin{aligned}\n\\dot{\\mathbf{p}} = \\mathbf{F} \\text{ with } \\mathbf{p} = m \\dot{\\mathbf{r}}\n\\end{aligned}\n\\end{equation*}\nbut we cannot simply apply this equation if $m$ depends on $t$ because that implies that the system is not closed.\\\\\nConsider a rocket moving in one dimension, with mass $m\\left(t\\right)$ and velocity $v\\left(t\\right)$.\\\\\nThe rocket propels itself by burning fuel and ejecting the exhaust at velocity $-u$ relative to the rocket.\\\\\nAt time $t$:\\\\\n\\includegraphics[scale=0.15]{Rel04}\\\\\\\\\nAt time $t+\\delta t$:\\\\\n\\includegraphics[scale=0.15]{Rel05}\\\\\\\\\nThe change in total momentum of the system (rocket+exhaust) is\n\\begin{equation*}\n\\begin{aligned}\n\\delta p &= m\\left(t+\\delta t\\right) v\\left(t+\\delta t\\right) + \\left(m\\left(t\\right)-m\\left(t+\\delta t\\right)\\right)\\left(v\\left(t\\right)-u+O\\left(\\delta t\\right)\\right)-m\\left(t\\right)v\\left(t\\right)\\\\\n&=\\left(m+\\dot{m}\\delta t+O\\left(\\delta t^2\\right)\\right)\\left(v+\\dot{v}\\delta t+O\\left(\\delta t^2\\right)\\right) - \\left(\\dot{m} \\delta t\\right)\\left(v-u\\right) + O\\left(\\delta t^2\\right) - mv\\\\\n&=\\left(\\dot{m}v+m\\dot{v}-\\dot{m}v+\\dot{m}u\\right)\\delta t + O\\left(\\delta t^2\\right)\\\\\n&=\\left(m\\dot{v}+\\dot{m}u\\right)\\delta t + O\\left(\\delta t^2\\right).\n\\end{aligned}\n\\end{equation*}\n\nNewton's Second Law then gives\n\\begin{equation*}\n\\begin{aligned}\n\\lim_{\\delta t\\to 0} \\frac{\\partial p}{\\partial t} &= F \\text{ (external force acting on rocket)}\\\\\n& \\implies m\\frac{dv}{dt} + u\\frac{dm}{dt} = F\n\\end{aligned}\n\\end{equation*}\nknown as the \\emph{rocket equation}.\n\n\\begin{eg}\nwhere $F=0$, we have\n\\begin{equation*}\n\\begin{aligned}\nm\\frac{dv}{dt} &= -u\\frac{dm}{dt}\\\\\n& \\implies v=v_{0} + u\\log \\left(\\frac{m_{0}}{m\\left(t\\right)}\\right)\n\\end{aligned}\n\\end{equation*}\n(constant such that $v=v_{0}$ when $m=m_{0}$).\\\\\n\n\\end{eg}\n\n\\subsection{Rigid bodies}\nA \\emph{rigid body} is an extended object, consisting of $N$ particles that are constrained such that the distance $|\\mathbf{r_i}-\\mathbf{r_j}|$ between any two particles is fixed.\\\\\nThe possible motions of a rigid body are the continuous isometries of Euclidean space: \\emph{translations} and \\emph{rotations}.\\\\\n\n\\subsubsection{Angular velocity}\nConsider a single particle moving in a circle of radius $s$ about the $z$ axis.\\\\\n\\includegraphics[scale=0.15]{Rel06}\\\\\nIts position and velocity are\\\\\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{r}&=\\left(s\\cos \\theta,s\\sin\\theta,z\\right)\\\\\n\\mathbf{\\dot{r}}\\left(-s\\dot{\\theta}\\sin\\theta,s\\dot{\\theta}cos\\theta,0\\right)\n\\end{aligned}\n\\end{equation*}\nThen $\\mathbf{\\dot{r}}=\\mathbf{\\omega}\\times\\mathbf{r}$,\\\\\nwhere $\\mathbf{\\omega}=\\dot{\\theta}\\hat{\\mathbf{z}}$ is the angular velocity vector. In general, $\\mathbf{\\omega}=\\dot{\\theta}\\hat{\\mathbf{n}}=\\omega \\hat{\\mathbf{n}}$ where $\\hat{\\mathbf{n}}$ is a unit vector parallel to rotation axis.\\\\\nThe kinetic energy of the particle is\\\\\n$T=\\frac{1}{2}m\\left(\\dot{\\mathbf{r}}\\right)^2=\\frac{1}{2}ms^2\\dot{\\theta}^2=\\frac{1}{2}I\\omega ^2$\\\\\nwhere $I=ms^2=m|\\hat{\\mathbf{n}}\\times\\mathbf{r}|^2$\\\\\nis the \\emph{moment of inertia}.\n\n\\subsubsection{Moment of inertia}\nConsider a rigid body in which all $N$ particles rotate about the same axis with the same angular velocity:\\\\\n$\\dot{\\mathbf{r_i}}=\\mathbf{\\omega}\\times\\mathbf{r_i}$\\\\.\nThis ensures that:\n\\begin{equation*}\n\\begin{aligned}\n\\frac{d}{dt}|\\mathbf{r_i}-\\mathbf{r_j}|^2 &= 2\\left(\\mathbf{\\dot{r_i}}-\\mathbf{\\dot{r_j}}\\right)\\cdot\\left(\\mathbf{r_i}-\\mathbf{r_j}\\right)\\\\\n&=2\\left(\\mathbf{\\omega}\\times\\left(\\mathbf{r_i}-\\mathbf{r_j}\\right)\\right)\\cdot\\left(\\mathbf{r_i}-\\mathbf{r_j}\\right)\\\\\n&=0\n\\end{aligned}\n\\end{equation*}\nas required for a rigid body.\\\\\nThe rotational kinetic energy is\\\\\n\\begin{equation*}\n\\begin{aligned}\nT &= \\frac{1}{2}\\sum_{i=1}^N m_i |\\dot{\\mathbf{r_i}}|^2\\\\\n&= \\frac{1}{2}I\\omega^2\n\\end{aligned}\n\\end{equation*}\nwhere $I=\\sum_{i=1}^N m_i s_i^2=\\sum_{i=1}^N m_i |\\hat{\\mathbf{n}}\\times\\mathbf{r_i}|^2$\\\\\nis the moment of inertia of the body about the rotation axis.\\\\\nThe angular momentum is\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{L}&=\\sum_i m_i \\mathbf{r_i}\\times \\dot{\\mathbf{r_i}}\\\\\n&= \\sum_i m_i \\mathbf{r_i}\\times\\left(\\mathbf{\\omega}\\times\\mathbf{r_i}\\right)\n\\end{aligned}\n\\end{equation*}\nwith $\\mathbf{\\omega} = \\omega \\hat{\\mathbf{n}}$, we have\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{L}\\cdot\\hat{\\mathbf{n}}&=\\omega \\sum_i m_i \\hat{\\mathbf{n}}\\cdot\\left(\\mathbf{r_i}\\times\\left(\\hat{\\mathbf{n}}\\times\\mathbf{r_i}\\right)\\right)\\\\\n&= \\omega \\sum_i m_i \\left(\\hat{\\mathbf{n}}\\times\\mathbf{r_i}\\right)\\cdot\\left(\\hat{\\mathbf{n}}\\times\\mathbf{r_i}\\right)\\\\\n&= I\\omega\n\\end{aligned}\n\\end{equation*}\nIn general, though, $\\mathbf{L}$ may not be parallel to $\\mathbf{\\omega}$. We can write\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{L}&=\\sum_i m_i \\left(\\left(\\mathbf{r_i}\\cdot\\mathbf{r_i}\\right)\\mathbf{\\omega}-\\left(\\mathbf{r_i}\\cdot\\mathbf{\\omega}\\right)\\mathbf{r_i}\\right)\\\\\n&=\\underline{\\underline{I}}\\mathbf{\\omega}\n\\end{aligned}\n\\end{equation*}\nwhere $\\underline{\\underline{I}}$ is the \\emph{inertia tensor} represented by the symmetric matrix with components\n\\begin{equation*}\n\\begin{aligned}\nI_{jk}&= \\sum_i m_i\\left(|\\mathbf{r_i}|^2\\delta_{jk}-\\left(\\mathbf{r_i}\\right)_j\\left(\\mathbf{r_i}\\right)_k\\right)\n\\end{aligned}\n\\end{equation*}\nIf the body rotates about a principal axis (one of the three orthogonal eigenvectors of $\\underline{\\underline{I}}$) e.g. on axis of symmetry if the body has one, then $\\mathbf{L}$ is parallel to $\\mathbf{\\omega}$.\\\\\nThe relations $T=\\frac{1}{2}I\\omega^2$ and $L=I\\omega$ for angular motion are analogous to the relations $T=\\frac{1}{2}mv^2$ and $p=mv$ for linear motion.\n\n\\subsubsection{Calculating the moment of inertia}\nFor a solid body, we replace the sum over particle by a volume integral, weighted by the mass density $\\rho\\left(\\mathbf{r}\\right)$.\\\\\nThe mass\n\\begin{equation*}\n\\begin{aligned}\nM=\\int \\rho dV,\n\\end{aligned}\n\\end{equation*}\nthe centre of mass is at\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{R}=\\frac{1}{M}\\int \\rho\\mathbf{r}dV\n\\end{aligned}\n\\end{equation*}\nand the moment of inertia is\n\\begin{equation*}\n\\begin{aligned}\nI=\\int \\rho s^2 dV=\\int \\rho |\\hat{\\mathbf{n}}\\times\\mathbf{r}|^2 dV\n\\end{aligned}\n\\end{equation*}\nWe mainly consider homogeneous bodies within which $\\rho$ is a constant.\\\\\n$\\bullet$ Thin circular ring:\\\\\nMass $M$, radius $a$, rotation axis through centre, perpendicular to the plane of ring.\\\\\n\\includegraphics[scale=0.10]{Rel07}\\\\\n$I=Ma^2$.\\\\\n\n$\\bullet$ Thin rod:\\\\\nMass $M$, length $l$, rotation axis through one end, perpendicular to the rod.\\\\\n\\includegraphics[scale=0.10]{Rel08}\\\\\n\\begin{equation*}\n\\begin{aligned}\nI &= \\int_0^l \\frac{M}{l} x^2 dx\\\\\n&= \\frac{1}{3}Ml^2.\n\\end{aligned}\n\\end{equation*}\n\n$\\bullet$ Thin disc:\\\\\nMass $M$, radius $a$, rotation axis through center of disc perpendicular to the plane of disc:\\\\\n\\includegraphics[scale=0.10]{Rel09}\\\\\n\\begin{equation*}\n\\begin{aligned}\nI&=\\int_0^{2\\pi} \\int_0^a \\frac{M}{\\pi a^2}r^2 rdrd\\theta\\\\\n&= \\frac{M}{\\pi a^2}\\int_0^a r^3 dr \\int_0^{2\\pi} d\\theta\\\\\n&= \\frac{M}{\\pi a^2}\\frac{1}{4}a^4\\cdot 2\\pi\\\\\n&= \\frac{1}{2}Ma^2.\n\\end{aligned}\n\\end{equation*}\n\nRotation axis through centre, in plane of disc:\\\\\n\\includegraphics[scale=0.10]{Rel10}\\\\\n\\begin{equation*}\n\\begin{aligned}\nI&=\\int_0^{2\\pi} \\int_0^a \\frac{M}{\\pi a^2}\\left(r\\sin \\theta\\right)^2 rdrd\\theta\\\\\n&= \\frac{M}{\\pi a^2} \\int_0^a r^2 dr \\int_0^{2\\pi} \\sin^2 \\theta d\\theta\\\\\n&= \\frac{M}{\\pi a^2}\\frac{1}{4}a^4\\cdot \\pi\\\\\n&=\\frac{1}{4}Ma^2.\n\\end{aligned}\n\\end{equation*}\n\n$\\bullet$ Solid sphere:\\\\\nMass $M$, radius $a$, rotation axis through centre:\\\\\n\\includegraphics[scale=0.10]{Rel11}\\\\\nUsing spherical polar coordinates based on rotation axis:\\\\\n\\begin{equation*}\n\\begin{aligned}\nI&= \\int_0^{2\\pi} \\int_0^\\pi \\int_0^a \\frac{M}{\\frac{4}{3}\\pi a^3}\\left(r\\sin\\theta\\right)^2 r^2 \\sin\\theta dr d\\theta d\\varphi\\\\\n&=\\frac{M}{\\frac{4}{3}\\pi a^3}\\int_0^a r^4 dr \\int_0^\\pi \\left(1-\\cos^2\\theta\\right)\\sin\\theta d\\theta \\int_0^{2\\pi} d\\varphi\\\\\n&=\\frac{M}{\\frac{4}{3}\\pi a^3}\\frac{1}{5}a^5\\cdot \\frac{4}{3}\\cdot 2\\pi\\\\\n&=\\frac{2}{5}Ma^2.\n\\end{aligned}\n\\end{equation*}\n\n\\begin{thm}(Perpendicular Axis Theorem)\nFor a two-dimensional object (a lamina) in the xy plane, and for three perpendicular axes through the same point,\n\\begin{equation*}\n\\begin{aligned}\nI_z=I_x+I_y.\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\n\\begin{equation*}\n\\begin{aligned}\nI_x &= \\int \\rho y^2 dA\\\\\nI_y &= \\int \\rho x^2 dA\\\\\nI_z &= \\int \\rho r^2 dA = \\int \\rho \\left(x^2+y^2\\right)dA=I_x + I_y.\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\ne.g. for a disc, $I_x = I_y$ by symmetry, so $I_z = 2I_x$.\\\\\nImportant: this does not apply to 3D objects (e.g. sphere, for which $I_x=I_y=I_z$).\n\\end{thm}\n\n\\begin{thm}(Parallel Axis Theorem)\nIf a rigid body of mass $M$ has moment of inertia $I^c$ about an axis passing through the centre of mass, then its moment of inertia about a parallel axis a distance $d$ away is $I=I^c + Md$.\n\\begin{proof}\nWith a convenient choice of Cartesian coordinates such that the centre of mass is at the origin and the two rotation axes are $x=y=0$ and $x=d, y=0$,\n\\begin{equation*}\n\\begin{aligned}\nI^c &= \\int \\rho\\left(x^2+y^2\\right) dV\n\\end{aligned}\n\\end{equation*}\nand\n\\begin{equation*}\n\\begin{aligned}\n\\int \\rho\\mathbf{r} dV = \\mathbf{0}\n\\end{aligned}\n\\end{equation*}\nThen\n\\begin{equation*}\n\\begin{aligned}\nI &= \\int \\rho\\left(\\left(x-d\\right)^2+y^2\\right)dV\\\\\n&= \\int \\rho\\left(x^2+y^2\\right)dV - 2d\\int \\rho x dV + d^2 \\int \\rho dV\\\\\n&= I^c + Md^2.\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\nDisc of mass $M$ and radius $a$:\\\\\nrotation axis through point on circumference perpendicular to plane of the disc.\n\\begin{equation*}\n\\begin{aligned}\nI&=I^c + Ma^2\\\\\n&=\\frac{1}{2}Ma^2 + Ma^2\\\\\n&=\\frac{3}{2}Ma^2\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\n\\subsubsection{Motion of a rigid body}\nThe general motion of a rigid body can be described as a translation of its centre of mass, following a trajectory $\\mathbf{R}\\left(t\\right)$, together with a rotation about an axis through the centre of mass.\\\\\nWe write\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{r_i} &= \\mathbf{R}+\\mathbf{r_i}^c\\\\\n\\implies \\mathbf{\\dot{r_i}} &= \\mathbf{\\dot{R}}+\\mathbf{\\dot{r_2}}^c\n\\end{aligned}\n\\end{equation*}\nIf the body rotates with angular velocity $\\mathbf{w}$ about the centre of mass, then\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{\\dot{r_i}}^c &= \\mathbf{\\omega} \\times \\mathbf{r_i}^c\\\\\n\\implies \\mathbf{\\dot{r_i}} &= \\mathbf{\\dot{R}} + \\mathbf{\\omega} \\times\\mathbf{r_i}^c\\\\\n&=\\mathbf{\\dot{R}}+\\mathbf{\\omega}\\times\\left(\\mathbf{r_i}-\\mathbf{R}\\right)\n\\end{aligned}\n\\end{equation*}\nThe kinetic energy is\n\\begin{equation*}\n\\begin{aligned}\nT &= \\frac{1}{2} M|\\mathbf{\\dot{R}}|^2 + \\frac{1}{2}\\sum_i m_i |\\mathbf{\\dot{r_i}}^c|^2\\\\\n&= \\frac{1}{2} M|\\mathbf{\\dot{R}}|^2 + \\frac{1}{2}I^c \\omega^2\\\\\n&=\\text{translational kinetic energy + rotational kinetic energy}\n\\end{aligned}\n\\end{equation*}\nwhere $I^c$ is the moment of inertia about an axis parallel to $\\mathbf{\\omega}$ through the centre of mass.\\\\\n\nConsider any point $Q$, with position vector $\\mathbf{Q}\\left(t\\right)$, that is not the centre of mass but moves with the rigid body, i.e. \n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{\\dot{Q}}&=\\mathbf{\\dot{R}}+\\mathbf{\\omega}\\times\\left(\\mathbf{Q}-\\mathbf{R}\\right)\n\\end{aligned}\n\\end{equation*}\nThen we can write\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{\\dot{r_i}}&=\\mathbf{\\dot{R}}+\\mathbf{\\omega}\\times\\left(\\mathbf{r_i}-\\mathbf{R}\\right)\\\\\n&= \\mathbf{\\dot{Q}}-\\mathbf{\\omega}\\times\\left(\\mathbf{Q}-\\mathbf{R}\\right)+\\mathbf{\\omega}\\times\\left(\\mathbf{r_i}-\\mathbf{R}\\right)\\\\\n&= \\mathbf{\\dot{Q}}+\\mathbf{\\omega}\\times\\left(\\mathbf{r_i}-\\mathbf{Q}\\right).\n\\end{aligned}\n\\end{equation*}\nTherefore the motion can be considered as a translation of the point (with a different velocity $\\mathbf{\\dot{Q}}\\neq\\mathbf{\\dot{R}}$) together with a rotation about $Q$ (with the same angular velocity $\\mathbf{\\omega}$).\\\\\n\nAs shown previously, the linear and angular momentum evolve according to\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{\\dot{P}}&=\\mathbf{F} \\text{  (total external force)}\\\\\n\\mathbf{\\dot{L}}&=\\mathbf{G} \\text{  (total external torque)}\n\\end{aligned}\n\\end{equation*}\nThese two equations determine the translational and rotational motion of a rigid body. In some cases energy conservation is easier to apply.\\\\\n\n$\\mathbf{L}$ and $\\mathbf{G}$ depend on the choice of origin, which could be any point that is fixed in an inertial frame, or the centre of mass, even if this is accelerated.\n\\begin{equation*}\n\\begin{aligned}\nm\\mathbf{\\ddot{r_i}}=\\mathbf{F_i} &\\implies m_i \\mathbf{\\ddot{r_i}}^c = \\mathbf{F_i}-\\mathbf{m_i}\\mathbf{\\ddot{R}}\n\\end{aligned}\n\\end{equation*}\nThe last term is a fictitious force in the centre-of-mass frame. But the total torque of the fictitious forces about the centre of mass is\n\\begin{equation*}\n\\begin{aligned}\n\\sum_i \\mathbf{r_i}^c \\times \\left(-m_i\\mathbf{\\ddot{R}}\\right) &= -\\sum_i m_i\\mathbf{r_i}^c \\times \\mathbf{\\ddot{R}} = \\mathbf{0}.\n\\end{aligned}\n\\end{equation*}\nIn a uniform gravitational field $\\mathbf{g}$, the total gravitational force and torque are the same as these would act on a single particle of mass $M$ located at the centre of mass (which is also the centre of gravity):\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{F}&= \\sum_i \\mathbf{F_i}^{ext} = \\sum_i m_i \\mathbf{g} = M\\mathbf{g}\\\\\n\\mathbf{G}&= \\sum_i \\mathbf{G_i}^{ext} = \\sum_i \\mathbf{v_i}\\times\\left(m_i\\mathbf{g}\\right)=M\\mathbf{R}\\times\\mathbf{g}.\n\\end{aligned}\n\\end{equation*}\nSimilarly for the gravitational potential energy, the gravitational potential in a uniform $\\mathbf{g}$ is $-\\mathbf{r}\\cdot\\mathbf{g}$(+ constant):\n\\begin{equation*}\n\\begin{aligned}\nV^{ext} &= \\sum_i V_i^{ext} = \\sum_i m_i\\left(-\\mathbf{r}\\cdot\\mathbf{g}\\right)=M\\left(-\\mathbf{R}\\cdot\\mathbf{g}\\right)\n\\end{aligned}\n\\end{equation*}\nIn particular, the gravitational torque about the centre of mass vanishes:\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{G}^c = \\mathbf{0}.\n\\end{aligned}\n\\end{equation*}\n\n\\begin{eg}\nthrown stick:\nThe centre of the stick moves in a parabola.\\\\\nMeanwhile, it rotates with constant angular velocity about its centre, because the gravitational torque about the centre is zero.\n\\end{eg}\n\n\\begin{eg} swinging rod:\\\\\n\\includegraphics[scale=0.25]{Rel12}\\\\\nThis is an example of a compound pendulum.\\\\\nConsidering the rod to be rotating about the pivot (and not translating), its angular momentum is\n\\begin{equation*}\n\\begin{aligned}\nL=I\\dot{\\theta}, I=\\frac{1}{3}Ml^2\n\\end{aligned}\n\\end{equation*}\nThe gravitational torque about the pivot is\n\\begin{equation*}\n\\begin{aligned}\nG=-Mg\\frac{l}{2}\\sin\\theta\n\\end{aligned}\n\\end{equation*}\nThe equation of motion is\n\\begin{equation*}\n\\begin{aligned}\n&\\dot{L}=G\\\\\n&\\implies I\\ddot{\\theta}=-Mg\\frac{l}{2}\\sin\\theta\\\\\n&\\implies \\ddot{\\theta}=-\\frac{3g}{2l}\\sin\\theta\n\\end{aligned}\n\\end{equation*}\nis exactly equivalent to a simple pendulum of length $\\frac{2l}{3}$. The angular frequency of small oscillations is\n\\begin{equation*}\n\\begin{aligned}\n\\sqrt{\\frac{3g}{2l}}.\n\\end{aligned}\n\\end{equation*}\nCan also be obtained from an energy argument:\n\\begin{equation*}\n\\begin{aligned}\nE=T+V = \\frac{1}{2}I \\dot{\\theta}^2 - Mg\\frac{l}{2}\\cos\\theta\n\\end{aligned}\n\\end{equation*}\nDifferentiate:\n\\begin{equation*}\n\\begin{aligned}\n\\frac{dE}{dt}&=\\dot{\\theta}\\left(I\\ddot{\\theta}+Mg\\frac{l}{2}\\sin\\theta\\right) = 0\\\\\n\\implies I\\ddot{\\theta}&=-Mg\\frac{l}{2}\\sin\\theta\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\n\\subsubsection{Sliding versus rolling}\nConsider a cylinder or sphere of radius $a$ moving along a stationary horizontal surface.\\\\\n\\includegraphics[scale=0.20]{Rel13}\\\\\nIn general, the motion consists of a translation of the centre of mass (with velocity $v$) together with a rotation about the centre of mass (with angular velocity $\\omega$).\\\\\nThe horizontal velocty at the point of contact is \n\\begin{equation*}\n\\begin{aligned}\nv_{slip} = v-a\\omega\n\\end{aligned}\n\\end{equation*}\nFor a pure sliding motion, $v\\neq 0$ and $\\omega =0$, in which case $v-a\\omega \\neq 0$: the point of contact slips on the surface and kinetic friction may occur.\\\\\nFora pure rolling motion, $v\\neq 0$ and $w\\neq 0$, such that $v-a\\omega =0$. The point of contact is stationary (instantaneously). This is the \\emph{no-slip condition}.\\\\\nThe rolling body can alternatively be considered to be rotating instantaneously about the point of contact (with angular velocity $\\omega$) and not translating.\n\n\\begin{eg} (rolling downhill)\\\\\nCylinder or sphere of mass $M$ and radius $a$ rolling down a rough plane inclined at angle $\\alpha$.\\\\\nNo-slip (rolling) condition: $v-a\\omega = 0$.\\\\\nKinetic energy:\n\\begin{equation*}\n\\begin{aligned}\nT&=\\frac{1}{2}Mv^2+\\frac{1}{2}I\\omega^2\\\\\n&=\\frac{1}{2}\\left(M+\\frac{I}{a^2}\\right)v^2\n\\end{aligned}\n\\end{equation*}\nTotal energy:\n\\begin{equation*}\n\\begin{aligned}\nE&=\\frac{1}{2}\\left(M+\\frac{I}{a^2}\\right)\\dot{x}^2-Mgx\\sin\\alpha\n\\end{aligned}\n\\end{equation*}\n($x$ is distance down slope).\n\\end{eg}\n\nEnergy is conserved (see later):\n\\begin{equation*}\n\\begin{aligned}\n&\\frac{dE}{dt}=\\dot{x}\\left(\\left(M+\\frac{I}{a^2}\\right)\\ddot{x}-Mg\\sin\\alpha\\right)=0\\\\\n\\implies &\\left(M+\\frac{I}{a^2}\\right)\\ddot{x}=Mg\\sin\\alpha.\n\\end{aligned}\n\\end{equation*}\n\n\\begin{eg} uniform solid cylinder:\\\\\n\\begin{equation*}\n\\begin{aligned}\n&I=\\frac{1}{2}Ma^2\\\\\n\\implies & \\ddot{x}=\\frac{2}{3}g\\sin\\alpha\n\\end{aligned}\n\\end{equation*}\nFor a hollow cylinder (thin cylindrical shell),\n\\begin{equation*}\n\\begin{aligned}\n&I=Ma^2\n\\implies &\\ddot{x}=\\frac{1}{2}g\\sin\\alpha\n\\end{aligned}\n\\end{equation*}\n\\end{eg}\n\\includegraphics[scale=0.20]{Rel14})\\\\\n\nIn terms of forces and torques:\n\\begin{equation*}\n\\begin{aligned}\nM\\dot{v}&=Mg\\sin\\alpha-F\\\\\nI\\dot{\\omega}&=aF\n\\end{aligned}\n\\end{equation*}\nWhile rolling, $\\dot{v}-a\\dot{\\omega}=0$. Thus\n\\begin{equation*}\n\\begin{aligned}\nM\\dot{v}=Mg\\sin\\alpha-\\frac{I}{a^2}\\dot{v}\n\\end{aligned}\n\\end{equation*}\nleading to the same result. Here $F$ is a \\emph{static} frictional force. It does no work (so energy is conserved) because $v_{slip}=0$.\n\n\\begin{eg}(snooker ball)\\\\\n\\includegraphics[scale=0.20]{Rel16}\\\\\nStruck centrally so as to initiate translation but no rotation. Sliding occurs initially.\\\\\nConstant frictional force\n\\begin{equation*}\n\\begin{aligned}\nF=\\mu_k Mg\n\\end{aligned}\n\\end{equation*}\napplies while $v-a\\omega >0$. ($\\mu_k$: coefficient of kinetic friction)\\\\\nMoment of inertia is\n\\begin{equation*}\n\\begin{aligned}\nI=\\frac{2}{5}Ma^2\n\\end{aligned}\n\\end{equation*}\nabout centre of mass.\\\\\nEquations of motion:\n\\begin{equation*}\n\\begin{aligned}\n&M\\dot{v}=-F\\\\\n&I\\dot{\\omega}=aF\n\\end{aligned}\n\\end{equation*}\nInitially $v=v_0$ and $\\omega =0$.\\\\\nSolution:\n\\begin{equation*}\n\\begin{aligned}\n&v=v_0-\\mu_k gt\\\\\n&\\omega=\\frac{5}{2}\\frac{\\mu_k g}{a}t\n\\end{aligned}\n\\end{equation*}\nSlipping velocity\n\\begin{equation*}\n\\begin{aligned}\nv_{slip} &= v-a\\omega\\\\\n&= v_0 - \\frac{7}{2}\\mu_k gt\\\\\n&= v_0 \\left(1-\\frac{t}{t_{roll}}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere\n\\begin{equation*}\n\\begin{aligned}\nt_{roll} = \\frac{2}{7}\\frac{v_0}{\\mu_k g}.\n\\end{aligned}\n\\end{equation*}\nThe solution applies until $t=t_{roll}$, at which time rolling begins and friction ceases.\\\\\nAt this point,\n\\begin{equation*}\n\\begin{aligned}\nv=a\\omega = \\frac{5}{7}v_0\n\\end{aligned}\n\\end{equation*}\nThe kinetic energy is\n\\begin{equation*}\n\\begin{aligned}\n\\frac{1}{2}Mv^2 + \\frac{1}{2}I\\omega^2 &= \\frac{1}{2}\\left(1+\\frac{2}{5}\\right)Mv^2\\\\\n&=\\frac{5}{14}Mv_0^2 < \\frac{1}{2}Mv_0^2\n\\end{aligned}\n\\end{equation*}\nSo energy has been lost to friction.\n\\end{eg}\n\n\\newpage\n\\section{Special relativity}\nWhen particles move extremely fast, Newtonian Dynamics becomes inaccurate and is replaced by Einstein's Special Theory of Relativity (1905).\\\\\nIts effects are noticeable only when particles approach the speed of light,\n\\begin{equation*}\n\\begin{aligned}\nc=299792458 ms^{-1} \\approx 3\\times 10^8 ms^{-1}\n\\end{aligned}\n\\end{equation*}\nThe Special Theory of Relativity rests on two postulates:\\\\\n$\\bullet$ Postulate 1: The laws of physics are the same in all inertial frames (the principle of relativity, as considered by Galileo).\\\\\n$\\bullet$ Postulate 2: The speed of light in vacuum is the same in all inertial frames.\\\\\nThe second postulate is not compatible with Galilean relativity and requires a complete revision of our ideas about space and time.\\\\\n\nConsider two inertial frames, $S$ and $S'$, related by the Galilean transformation\n\\begin{equation*}\n\\begin{aligned}\nx'&=x-vt\\\\\ny'&=y\\\\\nz'&=z\\\\\nt'&=t\n\\end{aligned}\n\\end{equation*}\nIn $S$, a light ray (or photon) travels in the $x$ direction with speed $c$. Its trajectory is\n\\begin{equation*}\n\\begin{aligned}\n\\frac{x}{t}=c.\n\\end{aligned}\n\\end{equation*}\nThe Galilean transformation gives\n\\begin{equation*}\n\\begin{aligned}\n\\frac{x'}{t'}=\\frac{x-vt}{t}=c-v\n\\end{aligned}\n\\end{equation*}\nSo the speed of light in $S'$ would be $c-v$. How can this common sense result be wrong?\n\n\\subsection{The Lorentz transformation}\n\\subsubsection{The Lorentz transformation}\nConsider again inertial frames $S$ and $S'$ in standard configuration. Assume that the origins coincide at $t=t'=0$.\\\\\n\\includegraphics[scale=0.25]{Rel17}\\\\\nFor now, neglect $y$ and $z$, and consider the relationship between $\\left(z,t\\right)$ and $\\left(x',t'\\right)$.\\\\\nThe most general form is\n\\begin{equation*}\n\\begin{aligned}\nx'=f\\left(x,t\\right)\\\\\nt'=g\\left(x,t\\right)\n\\end{aligned}\n\\end{equation*}\nfor some functions $f$ and $g$.\\\nIn any inertial frame, a free particle moves with constant velocity. Straight lines in $\\left(x,t\\right)$ must map into straight lines in $\\left(x',t'\\right)$. Therefore the relationship must be linear.\\\\\nGiven that the origins of $S$ and $S'$ coincide (at $t=t'=0$) and $S'$ moves with velocity $v$ relative to $S$, the line $x=vt$ must map into $x'=0$.\\\\\nTherefore\n\\begin{equation}\\label{eq:1}\n\\begin{aligned}\nx'=\\gamma \\left(x-vt\\right)\n\\end{aligned}\n\\end{equation}\nfor some factor $\\gamma$ that may depend on $|v|$.\nNow reverse the roles of the two frames.\\\\\nFrom the perspective of $S'$, $S$ moves with velocity $-v$. A similar argument leads to\n\\begin{equation}\\label{eq:2}\n\\begin{aligned}\nx=\\gamma\\left(x'+vt\\right)\n\\end{aligned}\n\\end{equation}\nwith the same $\\gamma$ since it only depends on $|v|$.\\\\\nNow consider a light ray (or photon) passing through the origin $x=x'=0$ at $t=t'=0$. Its trajectory in $S$ is\n\\begin{equation*}\n\\begin{aligned}\nx=ct\n\\end{aligned}\n\\end{equation*}\nWe demand that its trajectory in $S'$ be\n\\begin{equation*}\n\\begin{aligned}\nx'=ct'\n\\end{aligned}\n\\end{equation*}\nso that the speed of light is the same in each frame.\\\\\nSubstituting these equations into (\\ref{eq:1}) and (\\ref{eq:2}), we have\n\\begin{equation*}\n\\begin{aligned}\nct' = \\gamma \\left(c-v\\right)t\n\\end{aligned}\n\\end{equation*}\nand\n\\begin{equation*}\n\\begin{aligned}\nct = \\gamma \\left(c+v\\right) t'\n\\end{aligned}\n\\end{equation*}\nSo\n\\begin{equation*}\n\\begin{aligned}\n&c^2 = \\gamma^2 \\left(c^2-v^2\\right)\\\\\n\\implies &\\gamma = \\frac{1}{\\sqrt{1-\\frac{v^2}{c^2}}}\n\\end{aligned}\n\\end{equation*}\nThis is the \\emph{Lorentz factor} $\\gamma\\left(v\\right)$.\n\nNote that:\n$\\bullet$ $\\gamma \\geq 1$ is an increasing function of $|v|$;\\\\\n$\\bullet$ when $|v| \\ll c$, $\\gamma \\approx 1$ and we recover the Galilean transformation;\\\\\n$\\bullet$ when $|v| \\to c$, $r\\to\\infty$;\\\\\n$\\bullet$ when $|v| > c$, $\\gamma$ is imaginary, which is impossible.\\\\\n\\includegraphics[scale=0.20]{Rel18}\\\\\n($\\gamma = 2$ when $\\frac{v}{c} \\approx 0.866$,\\\\\n$\\gamma = 5$ when $\\frac{v}{c} \\approx 0.980$,\\\\\n$\\gamma = 10$ when $\\frac{v}{c} \\approx 0.995$,\\\\\n$\\gamma = 20$ when $\\frac{v}{c} \\approx 0.999$.)\\\\\nEliminate $x'$ between (\\ref{eq:1}) and (\\ref{eq:2}):\n\\begin{equation*}\n\\begin{aligned}\nx&=\\gamma \\left(\\gamma \\left(x-vt\\right)+vt'\\right)\\\\\n\\implies t'&=\\gamma t-\\left(1-\\frac{1}{\\gamma^2}\\right) \\frac{\\gamma x}{v}\\\\\n&= \\gamma t - \\frac{\\gamma v}{c^2}x\n\\end{aligned}\n\\end{equation*}\nThe equations\n\\begin{equation*}\n\\begin{aligned}\nx'=\\gamma\\left(x-vt\\right), t'=\\gamma\\left(t-\\frac{v}{c^2}x\\right)\n\\end{aligned}\n\\end{equation*}\nrepresent the \\emph{Lorentz transformation} in standard configuration (in one spatial dimension). In the limit $\\frac{v}{c}\\to 0$ ($\\gamma \\to 1$), they reduce to the Galilean transformation.\\\\\nWe can invert this linear mapping to find (after some algebra)\n\\begin{equation*}\n\\begin{aligned}\nx=\\gamma\\left(x'+vt'\\right), t=\\gamma\\left(t'+\\frac{v}{c^2}x'\\right)\n\\end{aligned}\n\\end{equation*}\ni.e. the same but with $v\\to -v$.\\\\\nDirections perpendicular to the relative motion of the frames are unaffected:\n\\begin{equation*}\n\\begin{aligned}\ny'=y, z'=z\n\\end{aligned}\n\\end{equation*}\n\n\\subsubsection{Checking the speed of light}\nFor a light ray travelling in the $x$ direction in $S$:\\\\\nIn $S$:\n\\begin{equation*}\n\\begin{aligned}\nx=ct, y=0, z=0\n\\end{aligned}\n\\end{equation*}\nIn $S'$:\n\\begin{equation*}\n\\begin{aligned}\n\\frac{x'}{t'}=\\frac{\\gamma\\left(x-vt\\right)}{\\gamma\\left(t-\\frac{v}{c^2}x\\right)} - \\frac{\\left(c-v\\right)t}{\\left(1-\\frac{v}{c}\\right)t} = c\n\\end{aligned}\n\\end{equation*}\nand $y'=0$, $z'=0$ as required.\\\\\n\nFor a light ray travelling in the $y$ direction in $S$:\\\\\nIn $S$:\n\\begin{equation*}\n\\begin{aligned}\nx=0,y=ct,z=0\n\\end{aligned}\n\\end{equation*}\nIn $S'$:\n\\begin{equation*}\n\\begin{aligned}\n&\\frac{x'}{t'}=\\frac{\\gamma\\left(x-vt\\right)}{\\gamma\\left(t-\\frac{v}{c^2}x\\right)} = -v\\\\\n&\\frac{y'}{t'}=\\frac{y}{\\gamma\\left(t-\\frac{v}{c^2}x\\right)}=\\frac{c}{\\gamma}\\\\\n&z'=0\\\\\n\\implies &\\frac{\\sqrt{x'^2 + y'^2}}{t} = \\sqrt{v^2 + \\frac{c^2}{\\gamma^2}}=c\n\\end{aligned}\n\\end{equation*}\nas required.\\\\\n\nMore generally, the Lorentz transformation implies\n\\begin{equation*}\n\\begin{aligned}\nc^2 t'^2 - r'^2 &= c^2 t'^2 - x'^2 - y'^2 - z'^2\\\\\n&= c^2 \\gamma^2\\left(t-\\frac{v}{c^2}x\\right)^2 - \\gamma^2\\left(x-vt\\right)^2 - y^2 - z^2\\\\\n&=\\gamma^2 \\left(1-\\frac{v^2}{c^2}\\right)\\left(c^2 t^2 - x^2\\right) - y^2 - z^2\\\\\n&=c^2 t^2 - x^2 - y^2 - z^2\\\\\n&=c^2 t^2 - r^2\n\\end{aligned}\n\\end{equation*}\nSo, if $\\frac{r}{t}=c$, then $\\frac{r'}{t'}=c$ as well.\n\n\\subsubsection{Space-time diagrams}\nWhen considering one spatial dimension ($x$) and time($t$) in an inertial frame $S$, we plot $x$ on the horizontal axis and $ct$ on the vertical axis.\\\\\n(diagram to be inserted -- rel19)\\\\\nThe union of space and time in special relativity is called \\emph{Minkowski spacetime}.\\\\\nEach point $p$ represents an \\emph{event}, labelled by coordinates $\\left(ct,x\\right)$.\\\\\nA particle traces out a \\emph{world line} in spacetime, which is straight if the particle moves uniformly.\\\\\nLight rays moving in the $x$ direction have world lines inclined at $45^\\circ$.\\\\\nWe will see later that particles cannot travel with speed $v>c$.\\\\\n(diagram to be inserted -- rel20)\\\\\nWe can also draw the axes of $S'$, moving with velocity $v$ in the $x$ direction relative to $S$.\\\\\nThe $t'$ axis corresponds to $x'=0$, i.e.\n\\begin{equation*}\n\\begin{aligned}\nx=\\frac{v}{c}ct\n\\end{aligned}\n\\end{equation*}\nThe $x'$ axis corresponds to $t'=0$, i.e.\n\\begin{equation*}\n\\begin{aligned}\nct = \\frac{v}{c}x\n\\end{aligned}\n\\end{equation*}\n(these are simply obtained by the previous Lorentz transformation equations)\\\\\n(diagram to be inserted -- rel 21)\\\\\nThe axes are symmetric about the diagonal. This reflects the fact that the speed of light in $S'$ is also $c$.\n\n\\subsection{Relativity physics}\n\\subsubsection{Simultaneity}\nTwo events $P_1$ and $P_2$ are \\emph{simultaneous} in the frame $S$ if $t_1 = t_2$.\\\\\n(diagram to be inserted -- rel22)\\\\\nHowever, events that are simultaneously in $S'$ have equal values of $t'$, and so they lie in lines\n\\begin{equation*}\n\\begin{aligned}\nct-\\frac{v}{c}x=\\text{   constant}\n\\end{aligned}\n\\end{equation*}\n(diagram to be inserted -- rel23)\\\\\nTherefore \\emph{simultaneity is relative}.\n\n\\subsubsection{Causality}\nAlthough differently moving observers may disagree on the temporal ordering of events, the consistent ordering of cause and effect can be ensured.\\\\\nLines of simultaneity cannot be inclined at more than $45^\\circ$, because Lorentz boosts are possible only for $|v|<c$.\\\\\n(diagram to be inserted -- rel24)\\\\\nThe lines at $45^\\circ$ emerging from $P$ from the \\emph{past light cone} and \\emph{future light cone} of $P$.\\\\\nAll observers agree that $Q$ occurs after $P$. Different observers may disagree on the temporal ordering of $P$ and $R$.\\\\\nIf nothing can travel faster than light, than $P$ and $R$ cannot influence each other.\\\\\n$P$ can only influence events within its future light cone, and $P$ can only be influenced by events within its past light cones.\n\n\\subsubsection{Time dilation}\nA clock that is stationary in $S'$ ticks at constant intervals $\\triangle t'$.\\\\\nWhat is the interval between ticks in $S$?\\\\\nThe inverse Lorentz transformation gives\n\\begin{equation*}\n\\begin{aligned}\nt = \\gamma\\left(t'+\\frac{v}{c^2}x'\\right)\n\\end{aligned}\n\\end{equation*}\nSince $x'$ is constant for the clock, we have\n\\begin{equation*}\n\\begin{aligned}\n\\triangle t = \\gamma \\triangle t' > \\triangle t'\n\\end{aligned}\n\\end{equation*}\nTherefore \\emph{moving clocks run slowly}.\n\n\\begin{defi} (Proper time)\\\\\n\\emph{Proper time} is the time measured in an object's rest frame.\n\\end{defi}\n\n\\subsubsection{The twin paradox}\nConsider two twins: Luke and Leia. Luke stays at home while Leia travels at constant speed $v$ to a distant planet $P$, then turns around and returns at the same speed.\\\\\n(diagram to be inserted -- rel25)\\\\\nLeia's arrival(A) at $P$ has\n\\begin{equation*}\n\\begin{aligned}\n\\left(ct,x\\right) = \\left(cT,vT\\right).\n\\end{aligned}\n\\end{equation*}\nThe time experienced by Leia on her outward journey is\n\\begin{equation*}\n\\begin{aligned}\nT' = \\gamma \\left(T-\\frac{v}{c^2}vT\\right) = \\frac{T}{\\gamma}\n\\end{aligned}\n\\end{equation*}\nBy Leia's return (R), Luke has aged by $2T$, but Leia has aged by $\\frac{2T}{\\gamma}<2T$ so she is younger than Luke because of time dilation.\\\\\nParadox: from Leia's perspective, Luke travelled away from her at speed $v$ and then returned, so he should be younger than her!\\\\\nWhy is the problem not symmetric?\\\\\n(diagram to be inserted -- rel26)\\\\\nIn the frame of reference of Leia's outward journey, her arrival $A$ is simultaneous with Luke's event $X$, which has $x=0$ and $t'=T'=\\frac{T}{\\gamma}$. So\n\\begin{equation*}\n\\begin{aligned}\nt' = \\gamma\\left(t-\\frac{v}{c^2}x\\right) \\implies t=\\frac{T'}{\\gamma}=\\frac{T}{\\gamma^2}\n\\end{aligned}\n\\end{equation*}\nThis is how much Luke has aged from Leia's perspective when she arrives at $P$.\\\\\nAt this stage the problem is symmetric: each thinks the other has aged less by a factor of $\\frac{1}{\\gamma}$.\\\\\nThings change when Leia turns around and changes frame of reference. Suppose Leia meets a friend Han who is just leaving $P$ at speed $v$.\\\\\n(diagram to be inserted -- rel27)\\\\\nOn his journey, Han thinks that Luke ages by $\\frac{T}{\\gamma^2}$. But in his frame of reference, his departure is simultaneous with Luke's event $Z$.\\\\\nThe asymmetry between Luke and Leia occurs when Leia turns around.\\\\\nAt this point she sees Luke age rapidly from $X$ to $Z$.\n\n\\subsubsection{Length contraction}\nSuppose we have a rod of length $L'$ stationary in frame $S'$. What is its length in frame $S$?\\\\\nIn $S'$:\\\\\n(diagram to be inserted -- rel28)\\\\\nThe length of the rod is the distance between the two ends at the same time!\\\\\nIn frame $S$:\\\\\n(diagram to be inserted -- rel29)\\\\\nThe lines $x'=0$ and $x'=L'$ map into (using the Lorentz transformation $x'=\\gamma\\left(x-vt\\right)$):\n\\begin{equation*}\n\\begin{aligned}\nx=vt, x=vt+\\frac{L'}{\\gamma}\n\\end{aligned}\n\\end{equation*}\nSo the length in $S$ is\n\\begin{equation*}\n\\begin{aligned}\nL=\\frac{L'}{\\gamma} < L'\n\\end{aligned}\n\\end{equation*}\nTherefore \\emph{moving objects are contracted in the direction of motion}.\n\n\\begin{defi} (Proper length)\\\\\nThe \\emph{proper length} is the length measured in an object's rest frame.\n\\end{defi}\n\nDoes a train of length $2L$ fit alongside a platform of length $L$ if it travels through the station at a speed $v$ such that $\\gamma=2$?\\\\\nFor the system of observers on the platform, the train contracts to a length $\\frac{2L}{\\gamma} = L$. So it fits!\\\\\nBut for the system of observers on the train, the platform contracts to a length $\\frac{L}{\\gamma} = \\frac{L}{2}$, which is much too short!\\\\\n(diagram to be inserted -- rel30)\\\\\nNo paradox here -- lengths are different because simultaneity is relative.\n\n\\subsubsection{Composition of velocities}\nA particle moves with constant velocity $u'$ in frame $S'$, which moves with velocity $v$ relative to $S$.\\\\\nWhat is its velocity $u$ in $S$?\\\\\nThe world line of the particle in $S'$ is\n\\begin{equation*}\n\\begin{aligned}\nx' = u't'\n\\end{aligned}\n\\end{equation*}\nIn $S$,\n\\begin{equation*}\n\\begin{aligned}\nu=\\frac{x}{t}&=\\frac{\\gamma\\left(x'+vt'\\right)}{\\gamma\\left(t'+\\frac{v}{c^2}x'\\right)}\\\\\n&=\\frac{u't'+vt'}{t'+\\frac{v}{c^2}u't'}\\\\\n&=\\frac{u'+v}{1+\\frac{u'v}{c^2}}\n\\end{aligned}\n\\end{equation*}\nThis is the formula for the relativistic composition of parallel velocities.\\\\\nThe inverse transformation is found by swapping $u$ and $u'$ and changing the sign of $v$.\\\\\nNote that:\\\\\n$\\bullet$ When $u'v \\ll c^2$, it reduces to the standard Galilean addition of velocities.\\\\\n$\\bullet$ For given $v$ ($|v|<c$ always) $u$ is a monotonically increasing function of $u'$.\\\\\n$\\bullet$ When $u'=\\pm c$, $u=u'$ for any $v$.\\\\\n$\\bullet$ Therefore, when $|u'|<c$, $|u|<c$ also.\\\\\n(You cannot reach or exceed light speed by any combination of boosts.)\\\\\n(diagram to be inserted -- rel31)\n\n\\subsection{Geometry of spacetime}\n\\subsubsection{The invariant interval}\nConsider events $P$ and $Q$ with coordinates $\\left(ct_1,x_1\\right)$ and $\\left(ct_2,x_2\\right)$ separated by\n\\begin{equation*}\n\\begin{aligned}\n\\triangle t = t_2 - t_1, \\triangle x = x_2 - x_1\n\\end{aligned}\n\\end{equation*}\nThe \\emph{invariant interval} between $P$ and $Q$ is defined as\n\\begin{equation*}\n\\begin{aligned}\n\\triangle s^2 = c^2 \\triangle t^2 - \\triangle x^2\n\\end{aligned}\n\\end{equation*}\nAll inertial observers agree on the value of $\\triangle s^2$:\n\\begin{equation*}\n\\begin{aligned}\nc^2 \\triangle t'^2 -\\triangle x'^2 &= c^2 \\gamma^2 \\left(\\triangle t-\\frac{v}{c^2}\\triangle x\\right)^2 - \\gamma^2 \\left(\\triangle x-v\\triangle t\\right)^2\\\\\n&= \\gamma^2 \\left(1-\\frac{v^2}{c^2}\\right)\\left(c^2\\triangle t^2 - \\triangle x^2\\right)\\\\\n&= c^2 \\triangle t^2 - \\triangle x^2\n\\end{aligned}\n\\end{equation*}\nIn three spatial dimensions, the invariant interval is\n\\begin{equation*}\n\\begin{aligned}\n\\triangle s^2 = c^2 \\triangle t^2 - \\triangle x^2 - \\triangle y^2 - \\triangle z^2\n\\end{aligned}\n\\end{equation*}\nFor two infinitesimally separated events, we have the \\emph{line elements}\n\\begin{equation*}\n\\begin{aligned}\nds^2 = c^2dt^2 - dx^2 - dy^2 - dz^2\n\\end{aligned}\n\\end{equation*}\nSpacetime is topologically equivalent to $\\R^4$. When endowed with the distant measure $\\triangle s^2$ (which is not positive definite), it is called the \\emph{Minkowski spacetime}.\\\\\nWe say it has dimension $d=1+3$.\\\\\nEvents with $\\triangle s^2 > 0$ are \\emph{timelike separated}.\\\\\n(There is a frame in which they occur at the same position).\\\\\n(diagram to be inserted -- rel32)\\\\\nEvents with $\\triangle s^2 < 0$ are \\emph{spacelike separated}.\\\\\n(There is a frame in which they occur at the same time).\\\\\n(diagram to be inserted -- rel33)\\\\\nEvent with $\\triangle s^2=0$ are \\emph{lightlike separated} (or \\emph{null separated}). (They could be connected by a light ray).\\\\\n(diagram to be inserted -- rel34)\\\\\n(Note that $\\triangle s^2 = 0$ does not imply that $P$ and $Q$ are the same event.)\n\n\\subsubsection{The Lorentz group}\nThe coordinates of an event $P$ in frame $S$ can be written as a \\emph{4-vector} (4-component vector) $X$.\n\\begin{equation*}\n\\begin{aligned}\nX^\\mu = \\left(\n\\begin{array}{ll}\nct\\\\\nx\\\\\ny\\\\\nz\n\\end{array}\n\\right), \\mu = 0,1,2,3\n\\end{aligned}\n\\end{equation*}\nThe invariant interval between the origin and $P$ can be written as an inner product\n\\begin{equation*}\n\\begin{aligned}\nX\\cdot X = X^T \\eta X = X^\\mu \\eta_{\\mu\\mu} X^\\mu\n\\end{aligned}\n\\end{equation*}\n(summation convention) where\n\\begin{equation*}\n\\begin{aligned}\n\\eta = \\left(\n\\begin{matrix}\n1&0&0&0\\\\\n0&-1&0&0\\\\\n0&0&-1&0\\\\\n0&0&0&-1\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nis the \\emph{Minkowski metric}.\\\\\nWe see that\n\\begin{equation*}\n\\begin{aligned}\nX\\cdot X = c^2 t^2 - x^2 - y^2 - z^2\n\\end{aligned}\n\\end{equation*}\nas required.\\\\\n\n4-vectors with $X\\cdot X > 0$ are called timelike;\\\\\n4-vectors with $X\\cdot X < 0$ are called spacelike;\\\\\n4-vectors with $X\\cdot X = 0$ are called lightlike.\\\\\n\nA Lorentz transformation is a linear transformation of the coordinates from one frame $\\left(S\\right)$ to another $\\left(S'\\right)$, represented by a $4\\times 4$ matrix:\n\\begin{equation*}\n\\begin{aligned}\nX' = \\Lambda X\n\\end{aligned}\n\\end{equation*}\nLorentz transformations can be defined as those that leave the inner product invariant:\n\\begin{equation*}\n\\begin{aligned}\nX' \\cdot X' = X \\cdot X\n\\end{aligned}\n\\end{equation*}\nfor all $X$, which implies the matrix equation\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda^T \\eta \\Lambda = \\eta\n\\end{aligned}\n\\end{equation*}\nTwo classes of solution of this equation are:\\\\\n1)\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda = \\left(\n\\begin{matrix}\n1&0&0&0\\\\\n0& & &\\\\\n0& &R&\\\\\n0& & &\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\n\nWith $R$ a $3\\times 3$ matrix satisfying\n\\begin{equation*}\n\\begin{aligned}\nR^T R = I\n\\end{aligned}\n\\end{equation*}\nThese are spatial rotations (improper, since they include reflections).\\\\\n2)\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda = \\left(\n\\begin{matrix}\n\\gamma & -\\gamma\\beta & 0&0\\\\\n-\\gamma\\beta & \\gamma & 0&0\\\\\n0&0&1&0\\\\\n0&0&0&1\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nwhere we define\n\\begin{equation*}\n\\begin{aligned}\n\\beta = \\frac{v}{c}, \\gamma = \\frac{1}{\\sqrt{1-\\beta^2}}\n\\end{aligned}\n\\end{equation*}\nThese are Lorentz boosts in the $x$ direction.\\\\\n\nThe set of all matrices satisfying\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda^T \\eta \\Lambda = \\eta\n\\end{aligned}\n\\end{equation*}\nform the \\emph{Lorentz group} $O\\left(1,3\\right)$. It is generated by rotations and boosts, and includes spatial reflections and time reversals.\\\\\nThe subgroup with $\\det \\Lambda = +1$ is the \\emph{proper Lorentz group} $SO\\left(1,3\\right)$;\\\\\nThe subgroup that preserves spatial orientation and the direction of time is the \\emph{restricted Lorentz group} $SO^+ \\left(1,3\\right)$.\n\n\\subsubsection{Rapidity}\nFocus on the upper $2\\times 2$ matrix of Lorentz boosts in the $x$ direction.\\\\\nWrite\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda\\left[\\beta\\right] = \\left(\n\\begin{matrix}\n\\gamma & -\\gamma\\beta\\\\\n-\\gamma\\beta & \\gamma\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nwith\n\\begin{equation*}\n\\begin{aligned}\n\\gamma = \\frac{1}{\\sqrt{1-\\beta^2}}\n\\end{aligned}\n\\end{equation*}\nCombining two boosts in the $x$ direction, we have\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda\\left[\\beta_1\\right] \\Lambda \\left[\\beta_2\\right]& = \n\\left(\\begin{matrix}\n\\gamma_1 & -\\gamma_1 \\beta_1\\\\\n-\\gamma_1 \\beta_1 & \\gamma_1\n\\end{matrix}\\right)\n\\left(\\begin{matrix}\n\\gamma_2 & -\\gamma_2 \\beta_2\\\\\n-\\gamma_2 \\beta_2 & \\gamma_2\n\\end{matrix}\\right)\\\\\n&=\\Lambda\\left[\\frac{\\beta_1 + \\beta_2}{1+\\beta_1 \\beta_2}\\right]\n\\end{aligned}\n\\end{equation*}\nafter \\emph{some} messy algebra. This is just the velocity composition formula in dimensionless form.\\\\\nRecall that, for spatial rotations,\n\\begin{equation*}\n\\begin{aligned}\nR\\left(\\theta\\right) = \\left(\\begin{matrix}\n\\cos\\theta & \\sin\\theta\\\\\n-\\sin\\theta & \\cos\\theta\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nand\n\\begin{equation*}\n\\begin{aligned}\nR\\left(\\theta_1\\right) R\\left(\\theta_2\\right) = R\\left(\\theta_1 + \\theta_2\\right)\n\\end{aligned}\n\\end{equation*}\nFor Lorentz boosts, define the \\emph{rapidity} $\\phi$ such that\n\\begin{equation*}\n\\begin{aligned}\n\\beta = \\tanh\\phi, \\gamma = \\cosh \\phi, \\gamma\\beta = \\sinh \\phi\n\\end{aligned}\n\\end{equation*}\nThen\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda\\left[\\beta\\right] = \\left(\\begin{matrix}\n\\cosh\\phi & \\sinh\\phi\\\\\n-\\sinh\\phi & \\cosh\\phi\n\\end{matrix}\\right)=\\Lambda\\left(\\phi\\right)\n\\end{aligned}\n\\end{equation*}\nand the rapidities add like rotation angles:\n\\begin{equation*}\n\\begin{aligned}\n\\Lambda\\left(\\phi_1\\right) \\Lambda \\left(\\phi_2\\right) = \\Lambda \\left(\\phi_1+\\phi_2\\right)\n\\end{aligned}\n\\end{equation*}\nThis shows the close relationship between rotations and boosts. A boost is a hyperbolic notation in spacetime.\n\n\\subsection{Relativistic kinematics}\nA particle moves along a trajectory $\\mathbf{x}\\left(t\\right)$ in $S$. Its velocity is\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{u}\\left(t\\right) = \\frac{d\\mathbf{x}}{dt}\n\\end{aligned}\n\\end{equation*}\nHowever, there is a better way to describe its trajectory.\\\\\n\\subsubsection{Proper time}\nFirst consider a particle at rest in an inertial frame $S'$ with $\\mathbf{x}' = \\mathbf{0}$. The invariant interval between points on its world line is\n\\begin{equation*}\n\\begin{aligned}\n\\triangle s^2 = c^2 \\triangle t'^2\n\\end{aligned}\n\\end{equation*}\nDefine \\emph{proper time} $\\tau$ such that\n\\begin{equation*}\n\\begin{aligned}\n\\triangle \\tau = \\frac{\\triangle s}{c}\n\\end{aligned}\n\\end{equation*}\nThis is the time experienced by the particle. But the equation\n\\begin{equation*}\n\\begin{aligned}\n\\triangle \\tau = \\frac{\\triangle s}{c}\n\\end{aligned}\n\\end{equation*}\nholds in all fames, because $\\triangle s$ is Lorentz-invariant (and real for particles that travel slower than light).\\\\\nThe world line of a particle can be parameterised using the proper time $\\tau$: $\\mathbf{x}\\left(\\tau\\right)$ and $t\\left(\\tau\\right)$:\\\\\n(diagram to be inserted -- rel35)\\\\\nInfinitesimal changes are related by\n\\begin{equation*}\n\\begin{aligned}\nd\\tau &= \\frac{ds}{c}\\\\\n&=\\frac{\\sqrt{c^2dt^2 - |d\\mathbf{x}|^2}}{c}\\\\\n&=\\sqrt{1-\\frac{|\\mathbf{u}|^2}{c^2}} dt\n\\end{aligned}\n\\end{equation*}\nThus\n\\begin{equation*}\n\\begin{aligned}\n\\frac{dt}{d\\tau} = \\gamma_u\n\\end{aligned}\n\\end{equation*}\nwith\n\\begin{equation*}\n\\begin{aligned}\n\\gamma_u = \\frac{1}{\\sqrt{1-\\frac{|\\mathbf{u}|}{c^2}}}\n\\end{aligned}\n\\end{equation*}\nThe total time experienced by the particle along a segment of its world line is\n\\begin{equation*}\n\\begin{aligned}\nT=\\int d\\tau = \\int \\frac{dt}{\\gamma_u}\n\\end{aligned}\n\\end{equation*}\n\n\\subsubsection{4-velocity}\nThe \\emph{position 4-vector} of a particle is\n\\begin{equation*}\n\\begin{aligned}\nX\\left(\\tau\\right) = \\left(\\begin{matrix}\nct\\left(\\tau\\right)\\\\\n\\mathbf{x}\\left(\\tau\\right)\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nIts \\emph{4-velocity is defined as}\n\\begin{equation*}\n\\begin{aligned}\nU = \\frac{dX}{d\\tau} &= \\left(\\begin{matrix}\nc\\frac{dt}{d\\tau}\\\\\\\\\n\\frac{d\\mathbf{x}}{d\\tau}\n\\end{matrix}\\right)\\\\\n&= \\frac{dt}{d\\tau} \\left(\\begin{matrix}\nc\\\\\n\\mathbf{u}\n\\end{matrix}\\right)\\\\\n&=\\gamma_u\\left(\\begin{matrix}\nc\\\\\n\\mathbf{u}\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere \n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{u} = \\frac{d\\mathbf{x}}{dt}\n\\end{aligned}\n\\end{equation*}\n\nAnother common notation is\n\\begin{equation*}\n\\begin{aligned}\nX=\\left(ct,\\mathbf{x}\\right), U=\\gamma_u\\left(c,\\mathbf{u}\\right)\n\\end{aligned}\n\\end{equation*}\n\nIf frame $S$ and $S'$ are related by\n\\begin{equation*}\n\\begin{aligned}\nX' = \\Lambda X\n\\end{aligned}\n\\end{equation*}\nthen the 4-velocity also transforms as\n\\begin{equation*}\n\\begin{aligned}\nU' = \\Lambda U\n\\end{aligned}\n\\end{equation*}\n\nAny 4-component vector that transforms in this way under a Lorentz transformation is called a 4-vector. $U$ is a 4-vector because $X$ is a 4-vector and $\\tau$ is Lorentz-invariant. Note that $\\frac{dX}{dt}$ is \\emph{not} a 4-vector.\\\\\n\nThe inner product\n\\begin{equation*}\n\\begin{aligned}\nU \\cdot U = U' \\cdot U'\n\\end{aligned}\n\\end{equation*}\nis a Lorentz invariant, which is the same in all inertial frames.\\\\\nIn the rest frame of the particle,\n\\begin{equation*}\n\\begin{aligned}\nU= \\left(\\begin{matrix}\nc\\\\\n\\mathbf{0}\n\\end{matrix}\\right) \\implies U\\cdot U = c^2\n\\end{aligned}\n\\end{equation*}\nIn any other frame,\n\\begin{equation*}\n\\begin{aligned}\nU&=\\gamma_u \\left(\\begin{matrix}\nc\\\\\n\\mathbf{u}\n\\end{matrix}\\right)\\\\\n\\implies U\\cdot U &= \\gamma_u^2 \\left(c^2-u^2\\right)\\\\\n&= c^2\n\\end{aligned}\n\\end{equation*}\nagain as expected.\n\n\\subsubsection{Transformation of velocities revisited}\nWe've seen that velocities cannot simply be added in relativity. However, the 4-velocity does transform linearly according to the Lorentz transformation\n\\begin{equation*}\n\\begin{aligned}\nU' = \\Lambda U\n\\end{aligned}\n\\end{equation*}\nIn frame $S$, consider a particle moving at speed $u$ at angle $\\theta$ to the $x$ axis in the $xy$ plane.\\\\\n(diagram rel-36)\\\\\nIts 4-velocity is\n\\begin{equation*}\n\\begin{aligned}\nU=\\left(\\begin{matrix}\n\\gamma_u c\\\\\n\\gamma_u u\\cos \\theta\\\\\n\\gamma_u u\\sin \\theta\\\\\n0\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nwith\n\\begin{equation*}\n\\begin{aligned}\n\\gamma_u = \\frac{1}{\\sqrt{1-\\frac{u^2}{c^2}}}.\n\\end{aligned}\n\\end{equation*}\nWith frames $S$ and $S'$ in standard configuration,\n\\begin{equation*}\n\\begin{aligned}\n\\left(\\begin{matrix}\n\\gamma_{u'} c\\\\\n\\gamma_{u'}u'\\cos\\theta'\\\\\n\\gamma_{u'}u'\\sin\\theta'\\\\\n0\n\\end{matrix}\\right)\n=\n\\left(\\begin{matrix}\n\\gamma_v & -\\gamma_v \\frac{v}{c} & 0 & 0\\\\\n-\\gamma_v\\frac{v}{c} & \\gamma_v & 0 & 0\\\\\n0&0&1&0\\\\\n0&0&0&1\n\\end{matrix}\\right)\n\\left(\\begin{matrix}\n\\gamma_u c\\\\\n\\gamma_u u\\cos\\theta\\\\\n\\gamma_u u\\sin\\theta\\\\\n0\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\n(diagram rel-37)\\\\\nThe ration of the second and first lines $\\left(x c\\right)$ gives\n\\begin{equation*}\n\\begin{aligned}\nu'\\cos\\theta' = \\frac{u\\cos\\theta - v}{1-\\frac{uv}{c^2}\\cos\\theta}\n\\end{aligned}\n\\end{equation*}\njust like the composition of parallel velocities.\\\\\nThe ratio of the thirs and second lines is\n\\begin{equation*}\n\\begin{aligned}\n\\tan \\theta' = \\frac{u\\sin \\theta}{\\gamma_v \\left(u\\cos\\theta - v\\right)}\n\\end{aligned}\n\\end{equation*}\nwhich describes \\emph{aberration}: a change in the apparent direction of motion of a particle due to the motion of the observer.\\\\\nAberration of starlight ($u=c$) due to the Earth's orbital motion causes small annual changes in the apparent positions of stars.\n\n\\subsubsection{4-momentum}\nThe \\emph{4-momentum} of a particle of mass $m$ is\n\\begin{equation*}\n\\begin{aligned}\nP=mU=m\\gamma_u \\left(\n\\begin{array}{ll}\nc\\\\\n\\mathbf{u}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nwith\n\\begin{equation*}\n\\begin{aligned}\n\\gamma_u = \\frac{1}{\\sqrt{1-\\frac{|\\mathbf{u}|^2}{c^2}}}\n\\end{aligned}\n\\end{equation*}\nThe 4-momentum of a system of particles is the sum of the 4-momentum of the particles, and is conserved in the absence of external forces.\\\\\nThe spatial components of $P$ are the \\emph{relativistic 3-momentum}\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{p} = m\\gamma_u\\mathbf{u}\n\\end{aligned}\n\\end{equation*}\nwhich differs from the Newtonian expression by a factor of $\\gamma_u$.\\\\\nNote that $|\\mathbf{p}| \\to \\infty$ as $|\\mathbf{u}| \\to c$.\\\\\nWhat is the interpretation of the time-component $p^\\circ$? Expand for $|\\mathbf{u}| \\ll c$:\n\\begin{equation*}\n\\begin{aligned}\np^\\circ = m\\gamma_u c &= \\frac{mc}{\\sqrt{1-\\frac{|\\mathbf{u|^2}}{c^2}}}\\\\\n&=\\frac{1}{c}\\left(mc^2+\\frac{1}{2}m|\\mathbf{u}|^2+...\\right)\n\\end{aligned}\n\\end{equation*}\nSince $p^\\circ$ is conserved, this strongly suggests that we should interpret $P$ as\n\\begin{equation*}\n\\begin{aligned}\nP = \\left(\n\\begin{array}{ll}\n\\frac{E}{c}\\\\\n\\mathbf{p}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere $E$ is the \\emph{relativistic energy}.\\\\\nThen\n\\begin{equation*}\n\\begin{aligned}\nE&=m\\gamma_u c^2\\\\\n&=mc^2 + \\frac{1}{2}m|\\mathbf{u}|^2 + ...\n\\end{aligned}\n\\end{equation*}\nfor $|\\mathbf{u}| \\ll c$.\\\\\nNote that $E\\to \\infty$ as $|\\mathbf{u}| \\to c$.\\\\\nFor a stationary particle,\n\\begin{equation*}\n\\begin{aligned}\nE=mc^2\n\\end{aligned}\n\\end{equation*}\nThis implies that mass is a form of energy.\\\\\n$m$ is sometimes called the \\emph{rest mass}.\\\\\nThe energy of a moving particle,\n\\begin{equation*}\n\\begin{aligned}\nE=m\\gamma_u c^2\n\\end{aligned}\n\\end{equation*}\nis the sum of the \\emph{rest energy} $mc^2$ and the \\emph{kinetic energy}\n\\begin{equation*}\n\\begin{aligned}\nm\\left(\\gamma_u-1\\right)c^2\n\\end{aligned}\n\\end{equation*}\n\nSince\n\\begin{equation*}\n\\begin{aligned}\nP\\cdot P = \\frac{E^2}{c^2} - |\\mathbf{p}|^2\n\\end{aligned}\n\\end{equation*}\nis a Lorentz invariant and equals $m^2c^2$ in the particle's rest frame, we have the general relation between energy and momentum:\n\\begin{equation*}\n\\begin{aligned}\nE^2 = |\\mathbf{p}|^2 c^2 + m^2 c^4\n\\end{aligned}\n\\end{equation*}\n\nIn Newtonian physics, mass and energy are separately conserved. In relativity, \\emph{mass is not conserved}; it is just another form of energy. Mass can be converted into kinetic energy and vice versa.\n\n\\subsubsection{Massless particles}\nParticles with zero mass ($m=0$), e.g. photons, can have non-zero momentum and energy because they travel at the speed of light ($\\gamma = \\infty$).\\\\\nIn case $P \\cdot P = 0$.\\\\\nMassless particles have lightlike (null) trajectories and no proper time.\\\\\nEnergy and momentum are related by\n\\begin{equation*}\n\\begin{aligned}\nE^2 = |\\mathbf{p}|^2 c^2 \\implies E=|\\mathbf{p}|c\n\\end{aligned}\n\\end{equation*}\nThus\n\\begin{equation*}\n\\begin{aligned}\nP=\\frac{E}{c}\\left(\n\\begin{array}{ll}\n1\n\\mathbf{n}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere $\\mathbf{n}$ is a unit vector in the direction of propagation.\\\\\nAccording to quantum mechanics, particles can be regarded as waves and vice versa.\\\\\nThe \\emph{de Broglie relation} between momentum and wavelength $\\lambda$ is\n\\begin{equation*}\n\\begin{aligned}\n|\\mathbf{p}| = \\frac{h}{\\lambda}\n\\end{aligned}\n\\end{equation*}\nwere\n\\begin{equation*}\n\\begin{aligned}\nh \\approx 6.63\\times 10^{-34} m^2 kg s^{-1}\n\\end{aligned}\n\\end{equation*}\nis the Planck's constant. For massless particles, this is consistent with Planck's relation\n\\begin{equation*}\n\\begin{aligned}\nE=\\frac{hc}{\\lambda} = h\\upsilon\n\\end{aligned}\n\\end{equation*}\nwhere\n\\begin{equation*}\n\\begin{aligned}\n\\upsilon = \\frac{c}{\\lambda}\n\\end{aligned}\n\\end{equation*}\nis the wave frequency.\n\n\\subsubsection{Newton's second law in special relativity}\nThis has the form\n\\begin{equation*}\n\\begin{aligned}\n\\frac{dP}{dt} = F\n\\end{aligned}\n\\end{equation*}\nwhere $F$ is the \\emph{4-force}.\\\\\nIt is related to the 3-force $\\mathbf{F}$ by\n\\begin{equation*}\n\\begin{aligned}\nF=\\gamma_u \\left(\n\\begin{array}{ll}\n\\frac{\\mathbf{F}\\cdot\\mathbf{u}}{c}\\\\\n\\mathbf{F}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nThus\n\\begin{equation*}\n\\begin{aligned}\n&\\frac{dE}{d\\tau} = \\gamma_u \\mathbf{F}\\cdot\\mathbf{u} \\implies \\frac{dE}{dt} = \\mathbf{F}\\cdot\\mathbf{u}\\\\\n&\\frac{d\\mathbf{p}}{d\\tau} = \\gamma_u \\mathbf{F} \\implies \\frac{d\\mathbf{p}}{dt} = \\mathbf{F}\n\\end{aligned}\n\\end{equation*}\nEquivalently, for a particle of mass $m$,\n\\begin{equation*}\n\\begin{aligned}\nF=mA\n\\end{aligned}\n\\end{equation*}\nwhere\n\\begin{equation*}\n\\begin{aligned}\nA=\\frac{dU}{d\\tau}\n\\end{aligned}\n\\end{equation*}\nis the \\emph{4-acceleration}.\\\\\nWe have\n\\begin{equation*}\n\\begin{aligned}\n&U=\\gamma_u \\left(\n\\begin{array}{ll}\nc\\\\\n\\mathbf{u}\n\\end{array}\\right)\\\\\n&A = \\gamma_u \\frac{dU}{dt}=\\gamma_u \\left(\n\\begin{array}{ll}\n\\dot{\\gamma_u}c\\\\\n\\gamma_u\\mathbf{a}+\\dot{\\gamma_u}\\mathbf{u}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nwhere\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{a} = \\frac{d\\mathbf{u}}{dt}\n\\end{aligned}\n\\end{equation*}\nand\n\\begin{equation*}\n\\begin{aligned}\n\\gamma_u = \\left(1-\\frac{|\\mathbf{u}|^2}{c^2}\\right)^{-\\frac{1}{2}} \\implies \\dot{\\gamma_u} = \\gamma_u^3 \\frac{\\mathbf{a}\\cdot\\mathbf{u}}{c^2}\n\\end{aligned}\n\\end{equation*}\nFor any massive particle, there is an inertial frame in which the particle is at rest at a given time $t$. This is the \\emph{instantaneous rest frame}. In this frame $\\mathbf{u} = \\mathbf{0}$, so $\\gamma_u = 1$ and $\\dot{\\gamma_u} = 0$. So\n\\begin{equation*}\n\\begin{aligned}\n\\end{aligned}\nU = \\left(\\begin{array}{ll}\nc\\\\\n\\mathbf{0}\n\\end{array}\\right),A=\\left(\\begin{array}{ll}\n0\\\\\n\\mathbf{a}\n\\end{array}\\right)\n\\end{equation*}\nSince $U\\cdot A$ is invariant,\n\\begin{equation*}\n\\begin{aligned}\nU\\cdot A = 0\n\\end{aligned}\n\\end{equation*}\nin all frames.\n\n\\subsection{Particle physics}\nMany problems can be solved using the conservation of 4-momentum\n\\begin{equation*}\n\\begin{aligned}\nP=\\left(\\begin{array}{ll}\n\\frac{E}{c}\\\\\n\\mathbf{p}\n\\end{array}\\right)\n\\end{aligned}\n\\end{equation*}\nfor a system of particles. The \\emph{centre-of-momentum (CM) frame} is an inertial frame in which the total 3-momentum $\\mathbf{p}$ is $\\mathbf{0}$ (this exists unless the system consists of one or more massless particles travelling in a single direction).\n\n\\end{document}", "meta": {"hexsha": "46445149e519fc2e5775d41dec16271ff71e3723", "size": 57580, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Relativity.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Relativity.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Relativity.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0710059172, "max_line_length": 256, "alphanum_fraction": 0.6921674192, "num_tokens": 20747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4379265229296222}}
{"text": "% ansys, 12543*2 2nd order 4.92747\n% ansys(1st)\n% 100*2 - 4.82274\n% 361*2 - 4.89143 \n% 1369*2 -4.91566\n% 5328*2 -4.92411\n% err_a1 = abs([4.82274,4.89143,4.91566,4.92411]-4.92747)/4.92747; dof_a1 = [100,361,1369,5328]*2; polyfit(log(dof_a1), log(err_a1),1)\n\n\n% ansys(2nd)\n% 133*2 - 4.88648\n% 481*2 - 4.91409\n% 1825*2 - 4.92356\n% 7105*2 -  4.92685\n% err_a2 = abs([4.88648,4.91409,4.92356,4.92685]-4.92747)/4.92747; dof_a2 = [133,481,1825,7105]*2; polyfit(log(dof_a2),log(err_a2),1)\n\n% svm\n% 162 - 4.82\n% 426 - 4.8945\n% 992 - 4.9131\n% 1780 - 4.9175\n% 2614 - 4.9208\n% err = abs([4.82,4.8945,4.9131,4.9175,4.9208] - 4.92747)/4.92747; dof=[162,426,992,1780,2614]; polyfit(log(dof),log(err),1)\n\n% mlp\n% 162-4.82\n% 496-4.8884\n% 1014-4.9090\n% 1202-4.9151\n% 3146-4.9226\n% err = abs([4.82,4.8842,4.9060,4.9180,4.9226] - 4.92747)/4.92747; dof=[162,420,808,1484,3146]; polyfit(log(dof),log(err),1)\n\n\\subsection{Short cantilever beam}\n\\paragraph{}\nA two-dimensional short cantilever beam subjected to a uniformly distributed load at the top is examined as shown in Fig.~\\ref{adp_fig:ex_cantilever_beam_geo_bc}.\n    \\begin{figure}[h!]\n    \\centering\n        \\scalebox{0.5}{\\includegraphics{adaptivity/ex_images/ex_short_cant_geo_bc.eps}}\n        \\caption{ Short cantilever beam: Geometry and boundary conditions.}\n        \\label{adp_fig:ex_cantilever_beam_geo_bc}\n    \\end{figure}\n\nThe geometry is: length $L = \\SI{1}{\\meter} $, height $ D = \\SI{1}{\\meter} $.\nThe material properties are: Young’s modulus $ E = \\SI{20}{\\newton \\per \\meter^2} $ , Poisson’s ratio $ \\nu =0.3 $.\nThe uniformly distributed load is $w = \\SI{10}{\\newton \\per \\meter} $.\nPlane stress condition is assumed.\n\nThe reference strain energy of \\SI{4.02079}{\\joule} is determined by the help of the ANSYS.\nIn the ANSYS, a mesh with $17930$ DOF using 2 \\textsuperscript{nd} order plane element $183$ is used to calculate the result.\n\nDue to the fact that the geometry of the cantilever beam can be described by four points and four straight lines, drawing in AutoCAD may not be necessary.\nAs a result, the input geometry is defined manually.\n\n\n\\paragraph{}\nThe numerical convergence of the the relative error in the energy norm is shown in Fig.~\\ref{adap_fig:ex_short_cantilever_convergence}.\nIt can be observed that data mining based adaptive SBFEM yields superior convergence rate when compared to the result calculated in ANSYS.\n\n\\begin{figure}[h!]\n    \\centering\n    \\scalebox{0.75}{\n        \\includegraphics{adaptivity/ex_images/ex_short_cantilever_conv.eps}\n    }\n    \\caption{the relative error in the energy norm}\n    \\label{adap_fig:ex_short_cantilever_convergence}\n\\end{figure}\n\nCorresponding mesh development are plotted in Fig.~\\ref{adap_fig:ex_short_cantilever_mesh_develpment} (SBFEM 1\\textup{st} order element) and Fig.~\\ref{adap_fig:ex_short_cantilever_mesh_develpment_ansys} (ANSYS 9-node quadrilateral element).\nStress contour plotted in ANSYS using 9-node quadrilateral elements (17930 DOFs) are shown in Fig.~\\ref{adap_fig:ex_chole_stress_ansys}\n\\begin{figure}[h!]\n\\centering\n    \\begin{subfigure}[b]{0.4\\linewidth}\n        \\centering\n        \\scalebox{0.25}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_mesh_162.eps}\n        }\n        \\caption{Initial mesh (162 DOF)}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.4\\linewidth}\n        \\centering\n        \\scalebox{0.25}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_mesh_462.eps}\n        }\n        \\caption{1st refinement (462 DOF)}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.4\\linewidth}\n        \\centering\n        \\scalebox{0.25}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_mesh_992.eps}\n        }\n        \\caption{2nd mesh (992 DOF)}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.4\\linewidth}\n        \\centering\n        \\scalebox{0.25}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_mesh_1780.eps}\n        }\n        \\caption{3rd refinement (1780 DOF)}\n    \\end{subfigure}\n    \\caption{ Short cantilever beam: mesh development (SBFEM)}\n    \\label{adap_fig:ex_short_cantilever_mesh_develpment}\n\\end{figure}\n\n\\begin{figure}[h!]\n    \\centering\n    \\begin{subfigure}[b]{0.48\\linewidth}\n        \\centering\n        \\scalebox{0.35}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_ansys_2_133.png}\n        }\n        \\caption{Initial mesh, 266 DOFs}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.48\\linewidth}\n        \\centering\n        \\scalebox{0.35}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_ansys_2_481.png}\n        }\n        \\caption{1st refinement, 962 DOFs}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.48\\linewidth}\n        \\centering\n        \\scalebox{0.35}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_ansys_2_1825.png}\n        }\n        \\caption{2nd refinement, 3650 DOFs}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{0.48\\linewidth}\n        \\centering\n        \\scalebox{0.35}{\n            \\includegraphics{adaptivity/ex_images/ex_short_cantilever_ansys_2_7105.png}\n        }\n        \\caption{3rd refinement, 14210 DOFs}\n    \\end{subfigure}\n    \\caption{Short cantilever beam: mesh development (Ansys)}\n    \\label{adap_fig:ex_short_cantilever_mesh_develpment_ansys}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\scalebox{0.35}{\n        \\includegraphics{adaptivity/ex_images/ex_short_cantilever_stress_ansys.png}\n    }\n    \\caption[Von-mises stress contour using 9-node quadrilateral element in ANSYS]{Von-mises stress contour using 9-node quadrilateral element in ANSYS (17930 DOFs)}\n    \\label{adap_fig:ex_chole_stress_ansys}\n\\end{figure}\n", "meta": {"hexsha": "7495480fdf32f288a7b51013fd7ebb148e46b062", "size": 5660, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "adaptivity/ex_short_cantilever.tex", "max_stars_repo_name": "fa93hws/thesis", "max_stars_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-30T12:14:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-30T12:14:47.000Z", "max_issues_repo_path": "adaptivity/ex_short_cantilever.tex", "max_issues_repo_name": "fa93hws/thesis", "max_issues_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "adaptivity/ex_short_cantilever.tex", "max_forks_repo_name": "fa93hws/thesis", "max_forks_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7671232877, "max_line_length": 240, "alphanum_fraction": 0.6929328622, "num_tokens": 1907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4379265229296221}}
{"text": "%\n% API Documentation for Peach - Computational Intelligence for Python\n% Module peach.optm.optm\n%\n% Generated by epydoc 3.0beta1\n% [Mon Dec 21 08:51:38 2009]\n%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                          Module Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}|(}\n\\section{Module peach.optm.optm}\n\n    \\label{peach:optm:optm}\n\nBasic definitons and base class for optimizers\n\nThis sub-package exports some auxiliary functions to work with cost functions,\nnamely, a function to calculate gradient vectors and hessian matrices, which are\nextremely important in optimization.\n\nAlso, a base class, \\texttt{Optimizer}, for all optimizers. Sub-class this class if\nyou want to create your own optmizer, and follow the interface. This will allow\neasy configuration of your own scripts and comparison between methods.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                               Functions                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsection{Functions}\n\n    \\label{peach:optm:optm:gradient}\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.gradient \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{gradient}(\\textit{f}, \\textit{dx}=\\texttt{1e-05})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nCreates a function that calculates the gradient vector of a scalar field.\n\nThis function takes as a parameter a scalar function and creates a new\nfunction that is able to calculate the derivative (in case of single\nvariable functions) or the gradient vector (in case of multivariable\nfunctions. Please, note that this function takes as a parameter a\n\\emph{function}, and returns as a result \\emph{another function}. Calling the returned\nfunction on a point will give the gradient vector of the original function\nat that point:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\n>{}>{}>~def~f(x):~\\\\\n~~~~~~~~return~x{\\textasciicircum}2~\\\\\n~\\\\\n>{}>{}>~df~=~gradient(f)~\\\\\n>{}>{}>~df(1)~\\\\\n2\n}\\end{quote}\n\nIn the above example, \\texttt{df} is a generated function which will return the\nresult of the expression \\texttt{2*x}, the derivative of the original function.\nIn the case \\texttt{f} is a multivariable function, it is assumed that its\nargument is a line vector.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[f]\n\n\nAny function, one- or multivariable. The function must be an scalar\nfunction, though there is no checking at the moment the function is\ncreated. If \\texttt{f} is not an scalar function, an exception will be\nraised at the moment the returned function is used.\n          \\item[dx]\n\n\nOptional argument that gives the precision of the calculation. It is\nrecommended that \\texttt{dx = sqrt(D)}, where \\texttt{D} is the machine precision.\nIt defaults to \\texttt{1e-5}, which usually gives a good estimate.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA new function which, upon calling, gives the derivative or gradient\nvector of the original function on the analised point. The parameter of\nthe returned function is a real number or a line vector where the gradient\nshould be calculated.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{peach:optm:optm:hessian}\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.hessian \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{hessian}(\\textit{f}, \\textit{dx}=\\texttt{1e-05})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nCreates a function that calculates the hessian matrix of a scalar field.\n\nThis function takes as a parameter a scalar function and creates a new\nfunction that is able to calculate the second derivative (in case of single\nvariable functions) or the hessian matrix (in case of multivariable\nfunctions. Please, note that this function takes as a parameter a\n\\emph{function}, and returns as a result \\emph{another function}. Calling the returned\nfunction on a point will give the hessian matrix of the original function\nat that point:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\n>{}>{}>~def~f(x):~\\\\\n~~~~~~~~return~x{\\textasciicircum}4~\\\\\n~\\\\\n>{}>{}>~ddf~=~hessian(f)~\\\\\n>{}>{}>~ddf(1)~\\\\\n12\n}\\end{quote}\n\nIn the above example, \\texttt{ddf} is a generated function which will return the\nresult of the expression \\texttt{12*x**2}, the second derivative of the original\nfunction. In the case \\texttt{f} is a multivariable function, it is assumed that\nits argument is a line vector.\n    \\vspace{1ex}\n\n      \\textbf{Parameters}\n      \\begin{quote}\n        \\begin{Ventry}{xx}\n\n          \\item[f]\n\n\nAny function, one- or multivariable. The function must be an scalar\nfunction, though there is no checking at the moment the function is\ncreated. If \\texttt{f} is not an scalar function, an exception will be\nraised at the moment the returned function is used.\n          \\item[dx]\n\n\nOptional argument that gives the precision of the calculation. It is\nrecommended that \\texttt{dx = sqrt(D)}, where \\texttt{D} is the machine precision.\nIt defaults to \\texttt{1e-5}, which usually gives a good estimate.\n        \\end{Ventry}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\nA new function which, upon calling, gives the second derivative or hessian\nmatrix of the original function on the analised point. The parameter of\nthe returned function is a real number or a line vector where the hessian\nshould be calculated.\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                               Variables                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsection{Variables}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-d\\-o\\-c\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt \\texttt{...}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                           Class Description                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.Optimizer \\textit{(class)}|(}\n\\subsection{Class Optimizer}\n\n    \\label{peach:optm:optm:Optimizer}\n\\begin{tabular}{cccccc}\n% Line for object, linespec=[False]\n\\multicolumn{2}{r}{\\settowidth{\\BCL}{object}\\multirow{2}{\\BCL}{object}}\n&&\n  \\\\\\cline{3-3}\n  &&\\multicolumn{1}{c|}{}\n&&\n  \\\\\n&&\\multicolumn{2}{l}{\\textbf{peach.optm.optm.Optimizer}}\n\\end{tabular}\n\n\\textbf{Known Subclasses:}\npeach.optm.stochastic.CrossEntropy,\n    peach.optm.quasinewton.BFGS,\n    peach.optm.quasinewton.DFP,\n    peach.optm.quasinewton.SR1,\n    peach.optm.multivar.Direct,\n    peach.optm.multivar.Gradient,\n    peach.optm.multivar.Newton,\n    peach.optm.linear.Direct1D,\n    peach.optm.linear.Fibonacci,\n    peach.optm.linear.GoldenRule,\n    peach.optm.linear.Interpolation,\n    peach.optm.sa.ContinuousSA,\n    peach.optm.sa.DiscreteSA\n\n\nBase class for all optimizers.\n\nThis class does nothing, and shouldn't be instantiated. Its only purpose is\nto serve as a template (or interface) to implemented optimizers. To create\nyour own optimizer, subclass this.\n\nThis class defines 3 methods that should be present in any subclass. They\nare defined here:\n\\begin{quote}\n\\begin{description}\n%[visit_definition_list_item]\n\\item[{{\\_}{\\_}init{\\_}{\\_}}] %[visit_definition]\n\nInitializes the optimizer. There are three usual parameters in this\nmethod, which signature should be:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\n{\\_}{\\_}init{\\_}{\\_}(self,~f,~...,~emax=1e-8,~imax=1000)\n}\\end{quote}\n\\begin{description}\n%[visit_definition_list_item]\n\\item[{where:}] %[visit_definition]\n\\begin{itemize}\n\\item {} \n\\texttt{f} is the cost function to be minimized;\n\n\\item {} \n\\texttt{...} represent additional configuration of the optimizer, and it\nis dependent of the technique implemented;\n\n\\item {} \n\\texttt{emax} is the maximum allowed error. The default value above is\nonly a suggestion;\n\n\\item {} \n\\texttt{imax} is the maximum number of iterations of the method. The\ndefault value above is only a suggestions.\n\n\\end{itemize}\n\n%[depart_definition]\n%[depart_definition_list_item]\n\\end{description}\n\n%[depart_definition]\n%[depart_definition_list_item]\n%[visit_definition_list_item]\n\\item[{step}] %[visit_definition]\n\nThis method should take an estimate and calculate the next, possibly\nbetter, estimate. Notice that the next estimate is strongly dependent of\nthe method, the optimizer state and configuration, and two calls to this\nmethod with the same estimate might not give the same results. The\nmethod signature is:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\nstep(self,~x)\n}\\end{quote}\n\nand the implementation should keep track of all the needed parameters.\nThe method should return a tuple \\texttt{(x, e)} with the new estimate of the\nsolution and the estimate of the error.\n\n%[depart_definition]\n%[depart_definition_list_item]\n%[visit_definition_list_item]\n\\item[{{\\_}{\\_}call{\\_}{\\_}}] %[visit_definition]\n\nThis method should take an estimate and iterate the optimizer until one\nof the stop criteria is met: either less than the maximum error or more\nthan the maximum number of iterations. Error is usually calculated as an\nestimate using the previous estimate, but any technique might be used.\nUse a counter to keep track of the number of iterations. The method\nsignature is:\n\\begin{quote}{\\ttfamily \\raggedright \\noindent\n{\\_}{\\_}call{\\_}{\\_}(self,~x)\n}\\end{quote}\n\nand the implementation should keep track of all the needed parameters.\nThe method should return a tuple \\texttt{(x, e)} with the final estimate of\nthe solution and the estimate of the error.\n\n%[depart_definition]\n%[depart_definition_list_item]\n\\end{description}\n\\end{quote}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                Methods                                %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Methods}\n\n    \\label{peach:optm:optm:Optimizer:__call__}\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.Optimizer \\textit{(class)}!peach.optm.optm.Optimizer.\\_\\_call\\_\\_ \\textit{(method)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_call\\_\\_}(\\textit{self}, \\textit{x})\n\n    \\end{boxedminipage}\n\n    \\label{object:__delattr__}\n    \\index{object.\\_\\_delattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_delattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}delattr{\\_}{\\_}('name') {\\textless}=={\\textgreater} del x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__getattribute__}\n    \\index{object.\\_\\_getattribute\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_getattribute\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}getattribute{\\_}{\\_}('name') {\\textless}=={\\textgreater} x.name\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__hash__}\n    \\index{object.\\_\\_hash\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_hash\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhash(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_init\\_\\_}(\\textit{self}, \\textit{f}=\\texttt{None}, \\textit{emax}=\\texttt{1e-08}, \\textit{imax}=\\texttt{1000})\n\n\nx.{\\_}{\\_}init{\\_}{\\_}(...) initializes x; see x.{\\_}{\\_}class{\\_}{\\_}.{\\_}{\\_}doc{\\_}{\\_} for signature\n    \\vspace{1ex}\n\n      Overrides: object.\\_\\_init\\_\\_ \textit{(inherited documentation)}\n\n    \\end{boxedminipage}\n\n    \\label{object:__new__}\n    \\index{object.\\_\\_new\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_new\\_\\_}(\\textit{T}, \\textit{S}, \\textit{...})\n\n      \\textbf{Return Value}\n      \\begin{quote}\n\\begin{alltt}\na new object with type S, a subtype of T\n\\end{alltt}\n\n      \\end{quote}\n\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce__}\n    \\index{object.\\_\\_reduce\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__reduce_ex__}\n    \\index{object.\\_\\_reduce\\_ex\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_reduce\\_ex\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nhelper for pickle\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__repr__}\n    \\index{object.\\_\\_repr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_repr\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nrepr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__setattr__}\n    \\index{object.\\_\\_setattr\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_setattr\\_\\_}(\\textit{...})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nx.{\\_}{\\_}setattr{\\_}{\\_}('name', value) {\\textless}=={\\textgreater} x.name = value\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{object:__str__}\n    \\index{object.\\_\\_str\\_\\_ \\textit{(function)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{\\_\\_str\\_\\_}(\\textit{x})\n\n    \\vspace{-1.5ex}\n\n    \\rule{\\textwidth}{0.5\\fboxrule}\n\nstr(x)\n    \\vspace{1ex}\n\n    \\end{boxedminipage}\n\n    \\label{peach:optm:optm:Optimizer:step}\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.Optimizer \\textit{(class)}!peach.optm.optm.Optimizer.step \\textit{(method)}}\n\n    \\vspace{0.5ex}\n\n    \\begin{boxedminipage}{\\textwidth}\n\n    \\raggedright \\textbf{step}(\\textit{self}, \\textit{x})\n\n    \\end{boxedminipage}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                              Properties                               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \\subsubsection{Properties}\n\n\\begin{longtable}{|p{.30\\textwidth}|p{.62\\textwidth}|l}\n\\cline{1-2}\n\\cline{1-2} \\centering \\textbf{Name} & \\centering \\textbf{Description}& \\\\\n\\cline{1-2}\n\\endhead\\cline{1-2}\\multicolumn{3}{r}{\\small\\textit{continued on next page}}\\\\\\endfoot\\cline{1-2}\n\\endlastfoot\\raggedright \\_\\-\\_\\-c\\-l\\-a\\-s\\-s\\-\\_\\-\\_\\- & \\raggedright \\textbf{Value:} \n{\\tt {\\textless}attribute '\\_\\_class\\_\\_' of 'object' objects{\\textgreater}}&\\\\\n\\cline{1-2}\n\\end{longtable}\n\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}!peach.optm.optm.Optimizer \\textit{(class)}|)}\n    \\index{peach \\textit{(package)}!peach.optm \\textit{(package)}!peach.optm.optm \\textit{(module)}|)}\n", "meta": {"hexsha": "9748320900c8411bdee97f2df2b731cfe445429b", "size": 16147, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/peach/doc/ref/pdf/peach.optm.optm-module.tex", "max_stars_repo_name": "serddmitry/goog_challenge", "max_stars_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_stars_repo_licenses": ["Apache-1.1"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-08-09T21:34:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-09T21:34:05.000Z", "max_issues_repo_path": "lib/peach/doc/ref/pdf/peach.optm.optm-module.tex", "max_issues_repo_name": "serddmitry/goog_challenge", "max_issues_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_issues_repo_licenses": ["Apache-1.1"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/peach/doc/ref/pdf/peach.optm.optm-module.tex", "max_forks_repo_name": "serddmitry/goog_challenge", "max_forks_repo_head_hexsha": "3d81460e815d8adfea1e43c59906adbd402ee3c2", "max_forks_repo_licenses": ["Apache-1.1"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6819852941, "max_line_length": 200, "alphanum_fraction": 0.6440824921, "num_tokens": 4758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.437853226226211}}
{"text": "\\chapter{Introduction}\n\nIf I asked you to imagine a collection of things, you might think of the books on your shelf, all the different kinds of shoes you have, the things you would bring with you on your next trip, and so on. More abstractly, those collections of things can be thought of as a clearly defined set of items. We have a perfectly good mathematical theory about this: set theory.\n\nNow what if I asked you to think of the collection of all groups? Surely, there are very many groups, so one might restrict to groups of a certain size. But there is something much more fundamental than matters of size. Our group theory teachers also taught us to not bother too much with different presentations of isomorphic groups. Having an isomorphism between two groups $G$ and $H$ makes these groups the same for all practical purposes. At this point the teacher will usually assure you that this is okay, even if set theory insists that the two isomorphic groups with different presentations are different objects in the collection of all groups. Your teacher was right to do so, because it helped you focus on the more important aspects of groups.\n\nHomotopy Type Theory (HoTT) is an emerging field of mathematics and computer science that extends Martin-Löf's dependent type theory by the addition of the univalence axiom and higher inductive types. In HoTT we think of types as spaces, dependent types as fibrations, and of the identity types as path spaces.\n\n\\section{The main results in this book}\nWe begin the book with an explanation of the rules of type theory\n\\begin{enumerate}\n\\item The fact that $0\\neq 1$.\n\\item The fundamental theorem of identity types.\n\\item The type of natural numbers is a set.\n\\item The uncountability of $2^\\N$.\n\\item The infinitude of primes\n\\item The structure identity principle for groups.\n\\item The construction of the fundamental cover of the circle.\n\\item The descent theorem for pushouts\n\\item The irrationality of $\\sqrt{2}$.\n\\item The equivalence of the category of groups and the category of pointed connected $1$-types.\n\\item The construction of the Hopf fibration.\n\\item The Blakers-Massey theorem.\n\\item The stabilization theorem of higher groups.\n\\end{enumerate}\n\n\n\\section{The Curry-Howard correspondence}\n%Dependent type theory is designed to reflect closely on actual mathematical practice and is compatible with classical logic. The foundational issue that isomorphic objects may have wildly different encodings in set-theoretic language, complicating the verification of mathematics, is addressed in type theory, where objects can only ever be defined up to equivalence. Despite the fact that dependent type theory is of constructive nature, it is important to note that type theory is not anti-classical: at the loss of certain properties of constructive type theory constructivists may care about, the axiom of choice may be assumed in type theory and it is in fact consistent with the univalence axiom. This may be helpful to obtain some classical results in type theory.\n\n%One of the important properties that dependent type theory has (when the axiom of choice is not assumed) is that  \n\n%From a logical point of view, type theory can be seen as a deductive system for constructive logic, in which types are propositions of which the constituents are precisely its proofs. In the view of Heyting, `to know the meaning of a proposition is to know which constructions can be considered as proofs of that proposition'. For instance, a proof of the proposition $A\\to B$ is an algorithm that transforms proofs of $A$ into proofs of $B$.\n\nFrom a syntactic point of view, type theory is a just a deductive system, or a language with enough structure to encode (most) mathematical practice. If one thinks of type theory as a deductive system, then it is natural to think of types as propositions. The terms of a type are then its proofs. However, one important difference between types and propositions is that types may have different terms, whereas propositions are completely determined by their truth value, and therefore do not have intrinsic structure beyond their provability. In other words, if there are two proofs of a given proposition $P$, then these two proofs are never regarded as distinct elements of that proposition (although they might be distinct in a syntactic sense). Nevertheless, the analogy between types and propositions holds up quite well, and is made precise in the \\define{Curry-Howard correspondence}, see \\cref{table:ch}.\n\nThe phenomenon that types may have distinct terms is known as \\define{proof-relevance}: to construct a term of a given type with a certain property it often matters how that term is constructed. This is of course no different in mathematical practice. For example, every now and then one encounters in a mathematical exposition a proposition that of the form `structures $A$ and $B$ are isomorphic', with the isomorphism being constructed in the proof. Here it matters of course how that isomorphism is constructed, and that specific isomorphism might even be used later on. Thus, the idea of proof-relevance is nothing new.\n\nSince types may possess many terms, one might observe that there are also formal similarities between types and sets. Indeed, a set is completely determined by how one can give an element of that set, in a similar way that a proposition is determined by how one can give a proof of that proposition. The Curry-Howard correspondence also provides a translation between types and sets.\n\nAn important difference between type theory and set theory, which makes type theory more useful as a language for formalizing mathematical constructions, is that the theory of types is itself a deductive system, whereas the theory of sets is formulated on a \\emph{separate} deductive system: first order logic. Moreover, one may extract programs from proofs: a proof of the existence of an object with a certain property yields a construction of that object together with a proof that the constructed object indeed satisfies the stated property.\n\n\\begin{table}\\label{table:ch}\n\\caption{The Curry-Howard correspondence}\n\\begin{center}\n\\begin{tabular}{lll}\n\\toprule\n\\emph{First order logic} & \\emph{Set theory} & \\emph{Type theory}\\\\\n\\midrule\nPropositions & Sets & Types\\\\\nPredicates & Families of sets & Dependent types\\\\\nProofs & Elements & Terms \\\\\n$\\top$ & $\\{\\emptyset\\}$ & $\\unit$\\\\\n$\\bot$ & $\\emptyset$ & $\\emptyt$ \\\\\n$P \\land Q$ & $A \\times B$ & $A \\times B$ \\\\\n$P \\vee Q$ & $A \\sqcup B$ & $A + B$ \\\\\n$\\exists x.P(x)$ & $\\coprod_{i\\in I}A_i$ & $\\sm{x:A}B(x)$ \\\\\n$\\forall x.P(x)$ & $\\prod_{i\\in I}A_i$ & $\\prd{x:A}B(x)$\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{table}\n\n\\section{Types in mathematical practice}\n\n\nTo illustrate the concept of type dependency, let us have a closer look at the anatomy of the following purposefully simple lemma.\n\n\\begin{lem}\\label{lem:unit}\nGiven a binary operation $\\mu:A\\times A\\to A$ on a set $A$, any $u_l\\in A$ satisfying satisfying the left unit law $\\mu(u_l,x)=x$, and any $u_r\\in A$ satisfying the right unit law $\\mu(x,u_r)=x$, one has $u_l=u_r$. \n\\end{lem}\n\n\\begin{proof}\nSince $u_l$ is a left unit, we have in particular $u_l=\\mu(u_l,u_r)$. Furthermore, since $u_r$ is a right unit we have in particular $\\mu(u_l,u_r)=u_r$. Thus, we have $u_l=\\mu(u_l,u_r)=u_r$. \n\\end{proof}\n\n\\begin{samepage}\nBy the hypotheses of \\cref{lem:unit}, we start the proof with the following set of presuppositions:\n\\begin{align*}\nA & : \\mathbf{Set} \\\\\n\\mu & : A\\times A\\to A \\\\\nu_l & : A \\\\\np & : \\forall x.\\,\\mu(u_l,x)=x\\\\\nu_r & : A \\\\\nq & : \\forall x.\\,\\mu(x,u_r)=x,\n\\end{align*}\nand the task is to show that $u_l=u_r$.\n\\end{samepage}\n\nThis list of assumptions is called the context of our proof, and the goal $u_l=u_r$ is a type in this context. \nNote that $\\mathbf{Set}$ is a type in the empty context (where no assumptions are made), $A\\times A\\to A$ is a type in the context $A:\\mathbf{Set}$, also $A$ is a type in the context $A:\\mathrm{Set}$, and $\\forall x.\\,\\mu(u_l,x)=x$ is a type in context $A:\\mathbf{Set},\\mu:A\\times A\\to A,u_l:A$, and so on.\nIn principle, one could give such a finite list of presumed structure for any mathematical text at any position in the text.\n\nMore generally, \\define{contexts} are lists of `typed' variable declarations. By `typed' we mean that any variable is assigned a (unique) type. A context is always finite, and the variables in a context can have any type, possibly depending on variables that have been declared previously. In our example, the variable $p:\\forall x.\\,\\mu(u_l,x)=x$ depends on $A:\\mathbf{Set}$, $\\mu:A\\times A\\to A$, and $u_l:A$. \n", "meta": {"hexsha": "93d62312c38cfcf07c9f20cb6b8d91f5935045a6", "size": 8646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Book/intro.tex", "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 333, "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_issues_repo_path": "Book/intro.tex", "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_forks_repo_path": "Book/intro.tex", "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "avg_line_length": 91.0105263158, "max_line_length": 912, "alphanum_fraction": 0.7668285913, "num_tokens": 2086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195152660688, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4378532122244031}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{longtable}\n\\usepackage[hyphens,spaces,obeyspaces]{url}\n\n\\usepackage{amsmath,amsthm,amssymb,amsfonts}\n\\usepackage{booktabs}\n\\usepackage{array}\n\\usepackage{fancyhdr}\n\\usepackage[a4paper, margin=1in]{geometry}\n\\usepackage{enumerate}\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{hyperref}\n\\graphicspath{ {./images/} }\n\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\mat}[1]{\\mathbf{#1}}\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\\newcommand{\\PreserveBackslash}[1]{\\let\\temp=\\\\#1\\let\\\\=\\temp}\n\\newcolumntype{C}[1]{>{\\PreserveBackslash\\centering}p{#1}}\n\\newcolumntype{R}[1]{>{\\PreserveBackslash\\raggedleft}p{#1}}\n\\newcolumntype{L}[1]{>{\\PreserveBackslash\\raggedright}p{#1}}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{TSE, Ho Nam}\n\\chead{Project \\#3}\n\\lhead{MATH4828B}\n\\cfoot{\\thepage}\n\\title{\n  {\\large MATH4828B Machine Learning for Natural Language Processing}\\\\\n  \\textbf{\\large Project 3 -- Language Model}\\\\\n  \\textbf{Report}\n  }\n\\author{ \n  \\begin{tabular}{R{0.4\\textwidth}L{0.4\\textwidth}}\n    \\textbf{Name:} & TSE, Ho Nam \\\\\n    \\textbf{Student ID:} & 20423612 \\\\\n    \\textbf{Dev Set Score:} & 1.3916\n  \\end{tabular}\n }\n  \n\\date{}\n\n\\begin{document}\n\\maketitle\\thispagestyle{fancy}\n\\tableofcontents\n\\section{Architectures}\nThere are two main types of architecture that I tried, and they are (i) LSTM and (ii) TCN.\n\n\\subsection{LSTM}\nLong Short Term Memory (LSTM) is a type of Recurrent Neural Network (RNN) that aims to solve the problem of gradient explosion and diminishing problems in simple RNN. Comparing with simple RNN, LSTM can be trained using a longer sequence and usually performs better. In a LSTM cell (Figure~\\ref{fig:LSTM}), there are four gates \\(i, f, o, g\\) and two hidden states \\(c_t, h_t\\). The equations for forward pass is as follows, with \\(\\odot\\) being the elementwise multiplication, \\(\\sigma\\) being the sigmoid activation and \\(\\tanh\\) being the \\(\\tanh\\) activation.\n\\[\n\t\\begin{bmatrix}\n\t\ti \\\\ f \\\\ o \\\\ g\n\t\\end{bmatrix}\n\t=\n\t\\begin{bmatrix}\n\t\t\\sigma \\\\ \\sigma \\\\ \\sigma \\\\ \\tanh\n\t\\end{bmatrix}\n\t\\mat W\n\t\\begin{bmatrix}\n\t\t\\mat h_{t-1} \\\\ \\mat x_t\n\t\\end{bmatrix}\n\t,\\qquad\n\tc_t = f \\odot c_{t-1} + i \\odot g\n\t,\\qquad\n\th_t = o \\odot \\tanh(c_t)\n\\]\nThe intuitive idea behind these equations is that, \\(i\\) governs how much information of \\(x_t\\) should be written to \\(c_t\\) and \\(f\\) governs how much information of \\(c_{t-1}\\) should be forgotten. \\(g\\) governs how much \\(x_t\\) is reach revealed to \\(c_t\\) and \\(o\\) governs how much \\(c_t\\) is written to \\(h_t\\). This new model works better than simple RNN because of the gradient highway along the \\(c_t\\) line which help solves the problem of gradient issues.\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.5\\linewidth]{LSTM}\n\t\\caption{A LSTM cell.\\protect\\footnotemark}\n\t\\label{fig:LSTM}\n\\end{figure}\n\\footnotetext{From Stanford cs231n lecture notes.}\n\nEven LSTM is a better choice than simple RNN, it has a lot more parameters than simple RNN and generally it takes longer to train these models. Therefore, another alternative is explored for this project.\n\\subsection{TCN}\nTemporal Convolutional Network (TCN) is a novel Convolutional Neural Network (CNN) modified to work on temporal domain introduced in early 2018. It uses a sequence of dilated convolutional layers, normalization layers, dropout layers and ReLU activations. From the authors\\footnote{Bai, Shaojie, J. Zico Kolter, and Vladlen Koltun.``An empirical evaluation of generic convolutional and recurrent networks for sequence modeling.'' arXiv preprint arXiv:1803.01271 (2018).} of TCN, their experimental results show TCN outperforms simple RNN, LSTM and GRU in different sequence modelling tasks significantly. It can also exhibit a longer memory, and has stable gradients.\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{TCN}\n\t\\caption{TCN strcuture.\\protect\\footnotemark}\n\t\\label{fig:TCN}\n\\end{figure}\n\\footnotetext{From \\url{https://github.com/philipperemy/keras-tcn}.}\n\n\\section{Experiments}\nThere were two phases of experiments. During the first phase, I used the provided sample code for generating training and validation data; while in the second phase, I reprogrammed these parts. There were in total around 200 sets of training records.\n\n\\subsection{Training with Provided Code}\nThere were multiple types of architectures attempted during this phase. They are constructed by LSTM, and/or TCN layers mentioned in the previous section. All models have a Embedding layer with various intermediate layer(s), then is finally fed into a Dense layer with softmax activation. The models include:\n\n\\begin{table}[h!]\n\t\\centering\n\t\\begin{tabular}{C{0.25\\textwidth}C{0.65\\textwidth}}\n\t\t\\toprule\n\t\tModel Type                    & Architecture                                                      \\\\\\midrule\n\t\t\\texttt{lstm}                 & Embedding \\(\\to\\) LSTM1 \\(\\to\\) Dense                             \\\\\\midrule\n\t\t\\texttt{lstm2}                & Embedding \\(\\to\\) LSTM1 \\(\\to\\) LSTM2 \\(\\to\\) Dense               \\\\\\midrule\n\t\t\\texttt{lstm3}                & Embedding \\(\\to\\) LSTM1 \\(\\to\\) LSTM2 \\(\\to\\) LSTM3 \\(\\to\\) Dense \\\\\\midrule\n\t\t\\texttt{lstm\\_embed}          & Embedding \\(\\to\\) LSTM1                                           \\\\\n\t\t                              & LSTM1 + Embedding \\(\\to\\) Dense                                   \\\\\\midrule\n\t\t\\texttt{tcn}                  & Embedding \\(\\to\\) TCN1 \\(\\to\\) Dense                              \\\\\\midrule\n\t\t\\texttt{tcn\\_embed}           & Embedding \\(\\to\\) TCN1                                            \\\\\n\t\t                              & TCN1 + Embedding \\(\\to\\) Dense                                    \\\\\\midrule\n\t\t\\texttt{tcn\\_lstm}            & Embedding \\(\\to\\) LSTM1                                           \\\\ & Embedding \\(\\to\\) TCN1 \\\\ & TCN1 + LSTM1 \\(\\to\\) Dense                                   \\\\\\midrule\n\t\t\\texttt{tcn\\_lstm\\_embed}     & Embedding \\(\\to\\) LSTM1                                           \\\\ & Embedding \\(\\to\\) TCN1 \\\\ & TCN1 + LSTM1  + Embedding \\(\\to\\) Dense                                    \\\\\\midrule\n\t\t\\texttt{tcn\\_lstm12\\_embed}   & Embedding \\(\\to\\) LSTM1 \\(\\to\\) LSTM2                             \\\\ & Embedding \\(\\to\\) TCN1 \\\\ & TCN1 + LSTM1 + LSTM2 + Embedding \\(\\to\\) Dense            \\\\\\midrule\n\t\t\\texttt{tcn\\_lstm2\\_embed}    & Embedding \\(\\to\\) LSTM1 \\(\\to\\) LSTM2                             \\\\ & Embedding \\(\\to\\) TCN1 \\\\ & TCN1 + LSTM2 + Embedding \\(\\to\\) Dense       \\\\\\midrule\n\t\t\\texttt{tcn12\\_lstm12\\_embed} & Embedding \\(\\to\\) LSTM1 \\(\\to\\) LSTM2                             \\\\ & Embedding \\(\\to\\) TCN1 \\(\\to\\) TCN2 \\\\ & TCN1 + TCN2 + LSTM1 + LSTM2 + Embedding \\(\\to\\) Dense           \\\\\\bottomrule\n\t\\end{tabular}\n\t\\caption{List of attempted models.}\n\\end{table}\n\nFor parameter tuning, I mainly tweak the embedding size, hidden size (size of \\(h_t, c_t\\) in LSTM and number of kernels used in TCN) and dropout rate. Here some selected results are shown.\n\n\\begin{longtable}[c]{@{}>{\\ttfamily}cccccc@{}}\n\t\\toprule\n\t\\textrm{Model Type}  & Embedding Size & Hidden Size & Dropout Rate & Log Loss & Score \\\\*\n\t\\midrule\n\t\\endhead\n\t%\n\t\\bottomrule\n\t\\endfoot\n\t%\n\t\\endlastfoot\n\t%\n\tlstm                 & 100            & 512         & 0.5          & 1.7566   & 90\\%  \\\\\n\tlstm                 & 100            & 512         & 0.2          & 1.7676   & 90\\%  \\\\\n\tlstm                 & 100            & 256         & 0.2          & 1.7812   & 90\\%  \\\\\n\tlstm                 & 100            & 256         & 0.5          & 1.8009   & 80\\%  \\\\\n\tlstm                 & 100            & 128         & 0.2          & 1.8620   & 80\\%  \\\\\n\tlstm                 & 100            & 128         & 0.5          & 1.9194   & 60\\%  \\\\\\midrule\n\tlstm\\_embed          & 100            & 256         & 0.2          & 1.7413   & 90\\%  \\\\\n\tlstm\\_embed          & 100            & 128         & 0.2          & 1.7811   & 90\\%  \\\\\n\tlstm\\_embed          & 100            & 256         & 0.5          & 1.7887   & 80\\%  \\\\\n\tlstm\\_embed          & 100            & 128         & 0.5          & 1.7980   & 80\\%  \\\\\\midrule\n\tlstm2                & 100            & 500         & 0.3          & 1.8401   & 80\\%  \\\\\n\tlstm2                & 100            & 500         & 0.4          & 1.8668   & 80\\%  \\\\\n\tlstm2                & 100            & 500         & 0.5          & 1.8830   & 80\\%  \\\\\n\tlstm2                & 100            & 500         & 0.2          & 1.8861   & 80\\%  \\\\\n\tlstm2                & 100            & 500         & 0.6          & 1.9672   & 60\\%  \\\\\\midrule\n\tlstm3                & 100            & 500         & 0.3          & 1.8723   & 80\\%  \\\\\n\tlstm3                & 100            & 500         & 0.5          & 1.8924   & 80\\%  \\\\\n\tlstm3                & 100            & 500         & 0.2          & 1.9035   & 60\\%  \\\\\n\tlstm3                & 100            & 500         & 0.4          & 1.9099   & 60\\%  \\\\\n\tlstm3                & 100            & 500         & 0.6          & 1.9784   & 60\\%  \\\\\\midrule\n\ttcn                  & 100            & 512         & 0.5          & 1.8067   & 80\\%  \\\\\n\ttcn                  & 100            & 128         & 0.2          & 1.8217   & 80\\%  \\\\\n\ttcn                  & 100            & 512         & 0.2          & 1.8362   & 80\\%  \\\\\n\ttcn                  & 100            & 256         & 0.2          & 1.8472   & 80\\%  \\\\\n\ttcn                  & 100            & 256         & 0.5          & 1.8505   & 80\\%  \\\\\n\ttcn                  & 100            & 128         & 0.5          & 1.9228   & 60\\%  \\\\\\midrule\n\ttcn\\_embed           & 100            & 256         & 0.2          & 1.8105   & 80\\%  \\\\\n\ttcn\\_embed           & 100            & 256         & 0.5          & 1.8287   & 80\\%  \\\\\n\ttcn\\_embed           & 100            & 128         & 0.5          & 1.8428   & 80\\%  \\\\\n\ttcn\\_embed           & 100            & 128         & 0.2          & 1.8497   & 80\\%  \\\\\\midrule\n\ttcn\\_lstm            & 100            & 512         & 0.5          & 1.7346   & 90\\%  \\\\\n\ttcn\\_lstm            & 100            & 256         & 0.2          & 1.7385   & 90\\%  \\\\\n\ttcn\\_lstm            & 100            & 256         & 0.5          & 1.7424   & 90\\%  \\\\\n\ttcn\\_lstm            & 100            & 512         & 0.2          & 1.7569   & 90\\%  \\\\\n\ttcn\\_lstm            & 100            & 128         & 0.2          & 1.7640   & 90\\%  \\\\\n\ttcn\\_lstm            & 100            & 128         & 0.5          & 1.7677   & 90\\%  \\\\\\midrule\n\ttcn\\_lstm\\_embed     & 256            & 256         & 0.5          & 1.7036   & 100\\% \\\\\n\ttcn\\_lstm\\_embed     & 100            & 256         & 0.5          & 1.7130   & 100\\% \\\\\n\ttcn\\_lstm\\_embed     & 100            & 512         & 0.5          & 1.7365   & 90\\%  \\\\\n\ttcn\\_lstm\\_embed     & 128            & 256         & 0.5          & 1.7439   & 90\\%  \\\\\n\ttcn\\_lstm\\_embed     & 100            & 128         & 0.2          & 1.7516   & 90\\%  \\\\\n\ttcn\\_lstm\\_embed     & 100            & 256         & 0.2          & 1.7563   & 90\\%  \\\\\n\ttcn\\_lstm\\_embed     & 100            & 512         & 0.2          & 1.7861   & 80\\%  \\\\\n\ttcn\\_lstm\\_embed     & 100            & 128         & 0.5          & 1.7952   & 80\\%  \\\\\\midrule\n\ttcn\\_lstm12\\_embed   & 256            & 256         & 0.2          & 1.6785   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 256         & 0.5          & 1.6844   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 128         & 0.5          & 1.7210   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 256         & 0.5          & 1.7244   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 128         & 0.2          & 1.7262   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 128         & 0.5          & 1.7305   & 100\\% \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 256         & 0.2          & 1.7557   & 90\\%  \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 128         & 0.2          & 1.7659   & 90\\%  \\\\\\midrule\n\ttcn\\_lstm2\\_embed    & 256            & 256         & 0.5          & 1.7322   & 100\\% \\\\\n\ttcn\\_lstm2\\_embed    & 128            & 256         & 0.5          & 1.7373   & 90\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 256            & 128         & 0.5          & 1.7405   & 90\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 128            & 128         & 0.2          & 1.7614   & 90\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 256            & 128         & 0.2          & 1.7726   & 90\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 128            & 256         & 0.2          & 1.7785   & 90\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 256            & 256         & 0.2          & 1.7840   & 80\\%  \\\\\n\ttcn\\_lstm2\\_embed    & 128            & 128         & 0.5          & 1.7926   & 80\\%  \\\\\\midrule\n\ttcn12\\_lstm12\\_embed & 128            & 256         & 0.5          & 1.7154   & 100\\% \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 256         & 0.2          & 1.7304   & 100\\% \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 128         & 0.2          & 1.7561   & 90\\%  \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 256         & 0.5          & 1.6899   & 100\\% \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 128         & 0.2          & 1.744    & 90\\%  \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 256         & 0.2          & 1.7633   & 90\\%  \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 128         & 0.5          & 1.7322   & 100\\% \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 128         & 0.5          & 1.749    & 90\\%  \\\\* \\bottomrule\n\t\\caption{Selected results trained with skeleton code. All models listed are trained with 25 epochs (may be early stopped, usually stops within 10 epochs) and batch size 32.}\n\t\\label{tb:p1-results}                                                                 \\\\\n\\end{longtable}\n\n\\noindent Some results we can see from Table~\\ref{tb:p1-results} are as follows.\n\\begin{itemize}\n\t\\item For all pure LSTM models, the more the layers, the worse it generally performs.\n\t\\item Pure TCN models outperform most of the LSTM models (except a few \\texttt{lstm} ones).\n\t\\item Pure TCN/LSTM models with concatenating Embedding generally performs better than those without. This is similar to what we see with ResNet.\n\t\\item Concatenating all TCN, LSTM and Embedding works the best among all models. \\texttt{tcn\\_lstm\\_embed} hits 100\\% score constantly.\n\\end{itemize}\n\nEven I have reached 100\\% multiple times, I still wish to achieve the bonus score for validation set. Hence, I started to modify the provided skeleton code for generating data.\n\n\\subsection{Training with Altered Code}\nAfter reading through the skeleton code, I believe this is how it works for sampling training/validation data.\n\\begin{enumerate}\n\t\\item Converts all words into IDs.\n\t\\item Fixes the input temporal dimension as \\(10\\).\n\t\\item Concatenates next sentences to fill in the remaining space if current sentence is too short, or break the current sentence into two if it is too long.\n\\end{enumerate}\n\nOne of the advantages of RNN and TCN is they support varying temporal dimension. With step 3 above, each input sentence is longer a complete sentence since either some of them are truncated, or some unrelated sentences are mixed in with them. This could affect the performance of the model since the models are looking for contexts through the whole sentence, which now the words can be unrelated. Hence, I modified the code and now it works as follows.\n\\begin{enumerate}\n\t\\item Converts all words into IDs.\n\t\\item Gets a batch of sentences and pad \\(0\\) to shorter sentences such that all sentences in the batch has the same temporal dimension during training.\n\\end{enumerate}\n\nAfter the modification, the performance of the models improved by a lot. This implementation is not the best though, because ID \\(0\\) is given to word \\texttt{L0127}, meaning in the perspective of the model, those words become \\texttt{L0127}. However, this is still acceptable because the model eventually learns to neglect this word towards the end of a sentence. From the table of selected results below, we can see an improvement in performance comparing with the previous table.\n\\begin{longtable}[c]{@{}>{\\ttfamily}ccc@{}}\n\t\\toprule\n\t\\textrm{Model Type}  & Log Loss & Score \\\\*\n\t\\midrule\n\t\\endfirsthead\n\t%\n\t\\endhead\n\t%\n\t\\bottomrule\n\t\\endfoot\n\t%\n\t\\endlastfoot\n\t%\n\ttcn\\_lstm\\_embed     & 1.6699   & Bonus \\\\\\midrule\n\ttcn\\_embed           & 1.7355   & 90\\%  \\\\\\midrule\n\tlstm\\_embed          & 1.7165   & 100\\% \\\\\\midrule\n\ttcn\\_lstm12\\_embed   & 1.6131   & Bonus \\\\\\midrule\n\ttcn12\\_lstm12\\_embed & 1.6053   & Bonus \\\\*\\bottomrule\n\t\\caption{Selected empirical results trained with altered code. All models listed are trained with 1 epoch, batch size 32, embedding size 128, hidden size 256 and dropout rate 0.2.}\n\t\\label{tb:p2-1epoch-results}\n\\end{longtable}\n\\begin{longtable}[c]{@{}>{\\ttfamily}cccccc@{}}\n\t\\toprule\n\t\\textrm{Model Type}  & Embedding Size & Hidden Size & Dropout Rate & Log Loss & Score \\\\*\\midrule\n\t\\endhead\n\t%\n\t\\bottomrule\n\t\\endfoot\n\t%\n\t\\endlastfoot\n\t%\n\tlstm\\_embed          & 256            & 256         & 0.2          & 1.4165   & Bonus \\\\\n\tlstm\\_embed          & 256            & 128         & 0.2          & 1.4395   & Bonus \\\\\n\tlstm\\_embed          & 128            & 128         & 0.2          & 1.4457   & Bonus \\\\\n\tlstm\\_embed          & 128            & 256         & 0.2          & 1.422    & Bonus \\\\\n\tlstm\\_embed          & 128            & 128         & 0.5          & 1.4729   & Bonus \\\\\n\tlstm\\_embed          & 256            & 128         & 0.5          & 1.4641   & Bonus \\\\\n\tlstm\\_embed          & 256            & 256         & 0.5          & 1.4173   & Bonus \\\\\n\tlstm\\_embed          & 128            & 256         & 0.5          & 1.4414   & Bonus \\\\\\midrule\n\ttcn\\_embed           & 256            & 256         & 0.2          & 1.5162   & Bonus \\\\\n\ttcn\\_embed           & 128            & 256         & 0.2          & 1.5249   & Bonus \\\\\n\ttcn\\_embed           & 256            & 128         & 0.2          & 1.5414   & Bonus \\\\\n\ttcn\\_embed           & 256            & 128         & 0.5          & 1.5772   & Bonus \\\\\n\ttcn\\_embed           & 128            & 128         & 0.2          & 1.5507   & Bonus \\\\\n\ttcn\\_embed           & 128            & 128         & 0.5          & 1.5785   & Bonus \\\\\n\ttcn\\_embed           & 128            & 256         & 0.5          & 1.5334   & Bonus \\\\\n\ttcn\\_embed           & 256            & 256         & 0.5          & 1.5479   & Bonus \\\\\\midrule\n\ttcn\\_lstm\\_embed     & 128            & 128         & 0.5          & 1.4297   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 128            & 128         & 0.2          & 1.4231   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 128            & 256         & 0.5          & 1.4296   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 256            & 128         & 0.2          & 1.426    & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 256            & 256         & 0.2          & 1.4218   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 128            & 256         & 0.2          & 1.4596   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 256            & 128         & 0.5          & 1.4223   & Bonus \\\\\n\ttcn\\_lstm\\_embed     & 256            & 256         & 0.5          & 1.4027   & Bonus \\\\\\midrule\n\ttcn\\_lstm12\\_embed   & 256            & 128         & 0.2          & 1.4032   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 128         & 0.2          & 1.4325   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 256         & 0.2          & 1.3916   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 256         & 0.2          & 1.4308   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 128         & 0.5          & 1.4152   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 256         & 0.5          & 1.4038   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 256            & 256         & 0.5          & 1.3968   & Bonus \\\\\n\ttcn\\_lstm12\\_embed   & 128            & 128         & 0.5          & 1.4262   & Bonus \\\\\\midrule\n\ttcn12\\_lstm12\\_embed & 256            & 128         & 0.2          & 1.4235   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 128         & 0.2          & 1.4557   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 256         & 0.2          & 1.4447   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 256         & 0.2          & 1.4123   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 128         & 0.5          & 1.431    & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 256         & 0.5          & 1.4218   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 128            & 128         & 0.5          & 1.4229   & Bonus \\\\\n\ttcn12\\_lstm12\\_embed & 256            & 256         & 0.5          & 1.3963   & Bonus \\\\* \\bottomrule\n\t\\caption{Selected results trained with altered code. All models listed are trained with 100 epochs (may be early stopped, usaully stops within 10 epochs) and batch size 32.}\n\t\\label{tb:ph2-results}\n\\end{longtable}\n\\noindent From Tables~\\ref{tb:p2-1epoch-results}~and~\\ref{tb:ph2-results}, we may find these observations.\n\\begin{itemize}\n\t\\item All architectures performed significantly better even when trained with 1 epoch only. Some of them even got to bonus already.\n\t\\item \\texttt{lstm\\_embed} outperforms \\texttt{tcn\\_embed} despite it is shown TCN are better. This could be because our task does not require a long memory so the advantages of TCN are somewhat lost.\n\t\\item Combining LSTM and TCN together are better than pure LSTM/TCN.\n\t\\item The best model seems to be \\texttt{tcn\\_lstm12\\_embed} with embedding size 256, hidden size 256 and dropout 0.2. It would be best to check this by running the same model setups multiple times, but this is not performed due to the lack of time.\n\\end{itemize}\nAfter these evaluations, \\texttt{tcn\\_lstm12\\_embed} with embedding size 256, hidden size 256 and dropout 0.2 model setup is used for the inference of the test data.\n\n\\section{Implementations}\nIn this project, the following libraries are used.\n\\begin{center}\n\t\\begin{tabular}{ccl}\n\t\t\\toprule\n\t\tName                  & Version                 & Descriptions                                   \\\\\\midrule\n\t\t\\texttt{Python      } & \\texttt{3.6.6}          & Language used                                  \\\\\\midrule\n\t\t\\texttt{numpy       } & \\texttt{1.15.3}         & For handling data matrices                     \\\\\\midrule\n\t\t\\texttt{pandas      } & \\texttt{0.23.4}         & For handling \\texttt{csv} files                \\\\\\midrule\n\t\t\\texttt{tensorflow}   & \\texttt{1.12.0}         & Deep learning library                          \\\\\\midrule\n\t\t\\texttt{keras}        & \\texttt{2.2.4}          & High level API wrapper for \\texttt{tensorflow} \\\\\\midrule\n\t\t\\texttt{keras-tcn}    & commit \\texttt{6d71e19} & \\texttt{keras} implementation of TCN           \\\\\\bottomrule\n\t\\end{tabular}\n\\end{center}\nSome notes for in the implementations are:\n\\begin{itemize}\n\t\\item \\texttt{keras.callbacks.EarlyStopping} is used to stop training when the validation loss does not increase for \\(3\\) consecutive epochs.\n\t\\item \\texttt{keras.callbacks.TensorBoard} is used to visualize the models during implemen\\-tation.\n\t\\item \\texttt{Python} generators are used so data do not need to be fetched to memory before training. This speeds up the training time. In particular, \\texttt{model.fit\\allowbreak\\_generator} is used instead of \\texttt{model.fit}. Unfortunately, \\texttt{model.predict\\_gener\\-ator} does not currently support varying dimension inference so \\texttt{model.predict} is still used.\n\\end{itemize}\n\n\\begin{center}\n\t\\textbf{End of Report}\n\\end{center}\n\n\\end{document}\n\n", "meta": {"hexsha": "272c4b55facd56bf48aefe1da9ce19e7fb95cc1a", "size": 23575, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Proj3/report/proj3.tex", "max_stars_repo_name": "mcreng/COMP4901K-ML4NLP", "max_stars_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-08-03T15:09:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-20T07:04:28.000Z", "max_issues_repo_path": "Proj3/report/proj3.tex", "max_issues_repo_name": "mcreng/COMP4901K-ML4NLP", "max_issues_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Proj3/report/proj3.tex", "max_forks_repo_name": "mcreng/COMP4901K-ML4NLP", "max_forks_repo_head_hexsha": "14664b4545f2c2ed9437a1869bb675eed0081fca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-20T04:58:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-20T04:58:51.000Z", "avg_line_length": 68.5319767442, "max_line_length": 667, "alphanum_fraction": 0.5278897137, "num_tokens": 7518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.437820112739519}}
{"text": "%% Based on a TeXnicCenter-Template by Gyorgy SZEIDL.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%------------------------------------------------------------\n%\n\\documentclass[a4paper]{article}\n%\n\\usepackage{etex,etoolbox}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}%\n\\usepackage{amssymb}%\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{url}\n%\\usepackage[numbers]{natbib}\n\\usepackage{verbatimbox}\n\n\\usepackage[margin=1in]{geometry}\n\n\\numberwithin{equation}{section}\n%--------------------------------------------------------\n\\begin{document}\n\\title{Constant-Time AES}\n\\author{David Rufino}\n\\newcommand{\\nn}{\\nonumber}\n\\newcommand{\\mbbF}{\\mathbb{F}}\n\\setlength{\\parindent}{0pt}\n\\maketitle\n\n\\section{Introduction}\n\nIt's known that a naive software implementation of the AES symmetric cipher \\cite{NISTAES} is vulnerable to timing attacks \\cite{bernstein2005cache}. \\cite{Hamburg2009AES} presents a constant-time implementation using SSSE3 instructions. This note simply expands on the details required to implement such a routine. \n\n\\section{Background}\n\nRecall that the AES symmetric encryption algorithm works on a  16-byte (128-bit) block, with either a 128,192 or 256-bit key size. The bytes are considered to be elements of the finite field $\\mathbb{F}_{2^8}$ of order 256, with respect to the polynomial basis associated to the canonical representation\n\n\\begin{eqnarray}\n\\label{aespoly}\n\t \\mbbF_{2^8} &\\simeq& \\mbbF_2\\left[ X \\right] / \\left( m(X) \\right) \\, , \\nn \\\\\n          m(X) &=& X^8 + X^4 + X^3 + X + 1 \\, . \n\\end{eqnarray}\n\nFor example\n\n\t$$ 01101010 b =  0\\text{x}6A = X^6 + X^5 + X^3 + X $$\n\nAddition is defined in the obvious way, and multiplication is defined modulo the polynomial $m(X)$. In this paper we make a distinction between the $\\mbbF_2$-vector space $\\mbbF_{2}^8$ and the field $\\mbbF_{2^8}$. In plain terms the former does not have a preferred definition of multiplication a-priori. It's only after choosing a basis for the field $\\mbbF_{2^8}$ that we can identify the two.\n\nThe ``state'' of the AES algorithm is conceptually a $4 \\times 4$ matrix with elements in $\\mbbF_{2^8}$. The convention is that the elements are with respect to the canonical basis, and that it is stored as a $16$-byte array in which the columns are contiguous. Each round of the encryption algorithm consists of the following transformations on the state\n\n\\begin{itemize}\n\\item {\\bf{SubBytes}}\n\nTo each element of the state apply the transformation (in the canonical basis)\n   \n   $$ z \\rightarrow A z^{-1} + b $$\n   \n where the elements $A,b$ are defined in the original spec \\cite{NISTAES} and inversion is understood to take place in the finite field discussed above.\n \n\\item {\\bf{ShiftRows}}\n\nRotate the rows of the state matrix\n\n\\item {\\bf{MixColumns}}\n\nPre-multiply the state matrix by the following\n\n\\[\n\\left( \\begin{array}{cccc}\n2 & 3 & 1 & 1 \\\\\n1 & 2 & 3 & 1 \\\\\n1 & 1 & 2 & 3 \\\\\n3  & 1 & 1 & 2 \n\\end{array} \\right)\n\\]\n\nwhere we identify a number with its binary expansion in the polynomial basis. For example \n\n\\begin{eqnarray*}\n  5 &=& 1 + X^2 \\\\\n  10 &=& X + X^3\n\\end{eqnarray*}\n\t\nNB. this step is omitted on the final round.\n\n\\item {\\bf{AddRoundKey}}\n\nThe key expansion (see \\cite{NISTAES} for details) for this round is added (i.e. XOR-ed) with the state.\n\n\\end{itemize}\n\nThe first is non-linear and so typically implemented with lookup tables. It's discussed below that in order to avoid lookup tables it's easier to work in a different basis. For efficiency reasons then, we work consistently in the tower basis (defined below). This requires a number of changes\n\n\\begin{itemize}\n\\item The key expansion must be converted to the tower basis\n\\item The input cipher text or plaintext must be converted at the start of the algorithm\n\\item The output cipher text or plaintext must be converted to the polynomial basis at the end of the algorithm\n\\item The lookup tables (for example, scalar multiplication) must be with respect to tower basis\n\\end{itemize}\n\n\\section{PSHUFB Instruction}\n\nThe PSHUFB (shuffle) instruction operations on two 128-bit (16-byte) registers as follows\n\n\\begin{verbatim}\nunsigned char a[16],b[16],r[16];\nfor (i = 0; i < 16; ++i)\n  r[i] = (b[i] & 0x80) ? 0 : a[b[i] & 0x0f];\n\\end{verbatim}\n\nAs the choice of the register $a$ is arbitrary, due to the presence of the mask on $b$ this may be viewed as an arbitrary function\n\n\t$$ \\mbbF_2^4 \\rightarrow \\mbbF_2^8 $$\n\nor alternatively as an appropriately restricted function\n\n\t$$ \\mbbF_2^4 \\oplus \\mbbF_2^4 \\rightarrow \\mbbF_2^8 $$\n\t\nwhere points with the most significant bit set are mapped to zero. Implementing a function\n\n  $$\\mbbF^8_{2} \\rightarrow \\mbbF^8_{2}$$\n  \nis in general difficult, but if it is linear (e.g. basis change) then two shuffle operations will suffice, as with the following pseudo-code\n\n\\begin{verbatim}\n\tout1 = pshufb(lookup_lo, and(in,0x0f0f0f0f0f0f0f0f));\n\tout2 = pshufb(lookup_hi, and(in,0xf0f0f0f0f0f0f0f0)>>4);\n\tout = xor(out1,out2)\n\\end{verbatim}\n\n\\section{Inversion with Permutations}\n\nInversion in $\\mbbF_{2^8}$ is not linear (in any basis), but \\cite{Hamburg2009AES} shows it is possible to reduce this operation to a linear combination of such functions with domain $\\mbbF_2^4$ by considering an alternative (``tower'') representation of $\\mbbF_{2^8}$\n\n\\begin{eqnarray*}\n\t\\mbbF_{2^4} &\\simeq& \\mbbF_2[\\zeta] / (\\zeta^4 + \\zeta^3 + \\zeta^2 + \\zeta + 1) \\\\\n\t\\mbbF_{2^8} &\\simeq& \\mbbF_{2^4}[t] / (t^2 + t + \\zeta) \\, . \n\\end{eqnarray*}\n\nNote in this representation every element $z \\in \\mbbF_{2^8}$ may be represented uniquely as\n\n\\begin{eqnarray*}\n   z &=&  x t + y \\bar{t} \\quad x,y \\in \\mbbF_4\n\\end{eqnarray*}\n\nwhere $\\bar{t} = t + 1$ is the conjugate of $t$. The addition law is clear and multiplication is given by\n\n\\begin{eqnarray*}\n (x_1 t + y_1 \\bar{t}) \\cdot (x_2 t + y_2 \\bar{t} ) &=& x_1 x_2 t + y_1 y_2 \\bar{t} + \\left( x_1 + y_1 \\right) \\left( x_2 + y_2 \\right) \\zeta\n\\end{eqnarray*}\n\nThe inverse of a general element is given by\n\n\\begin{eqnarray*}\n\\left( xt + y \\bar{t} \\right)^{-1} = \\frac{yt + x \\bar{t}}{xy + \\left(x^2 + y^2\\right)\\zeta}\n\\end{eqnarray*}\n\nAlternatively it is shown in \\cite{Hamburg2009AES} that inversion in $\\mbbF_{2^8}$ may be expressed in terms of inversions over $\\mbbF_{2^4}$  with the following formula\n\n\\begin{eqnarray}\n\\label{nestedinversion}\n\\frac{1}{xt + y \\bar{t}} &=& \\frac{t + \\zeta}{\\frac{1}{1 / y  + 1/\\zeta(x+y)} + x}+\\frac{\\bar{t} + \\zeta}{\\frac{1}{1 / x  + 1/\\zeta(x+y)} + y}\n\\end{eqnarray}\n\nprovided one is careful about dividing by zero. The advantage of this formula is it does not require any explicit multiplications, which are more difficult to implement using shuffle instructions.\n\nTo implement the inversion formula \\eqref{nestedinversion} consider the four maps\n\n\t$$ \\psi_i : \\mbbF_{2^4}  \\rightarrow \\mbbF_{2^8} $$\n\ncorresponding to the inversions \n\n\\begin{eqnarray*}\n & z &\\rightarrow z^{-1} \\\\\n & z &\\rightarrow \\left( \\zeta z \\right)^{-1} \\\\\n & z &\\rightarrow \\frac{t + \\zeta}{z} \\\\\n & z &\\rightarrow \\frac{\\bar{t} + \\zeta}{z}\n\\end{eqnarray*}\n\nIn practice these are implemented with respect to the basis $\\{ 1, \\zeta, \\zeta^2, \\zeta^3 \\}$ for $\\mbbF_{2^4}$ and the one already noted for $\\mbbF_{2^8}$. Further we ensure that $\\psi_i(0) = 128$ so that $\\psi_j(\\psi_i(0)) = 0 $ and\\eqref{nestedinversion} is correct in all cases. It's clear that together with addition (XOR) this is enough to implement equation \\eqref{nestedinversion}.\n\n\\section{Basis Change}\n\nThis section discusses the conversion between canonical basis and the tower basis. The simplest way is to find a root of the AES polynomial \\eqref{aespoly} in the tower basis. Using this allows one to easily construct an isomorphism between the two representation. For concreteness consider the unique isomorphism generated by\n\n\t$$ X \\rightarrow \\left( \\zeta + \\zeta^3 \\right) t \\,. $$\n\nIn practice we are interested in the basis change from the polynomial basis to the tower basis\n\n\\begin{eqnarray}\n\\{ t, \\zeta t, \\zeta^2 t , \\zeta^3 t ,  \\bar{t}, \\zeta \\bar{t}, \\zeta^2 \\bar{t} , \\zeta^3 \\bar{t} \\} \\, .\n\\end{eqnarray}\n\nCall this $\\hat{\\phi} : \\mathbb{F}^8_2 \\rightarrow \\mathbb{F}^8_2$. Actually this function is a linear isomorphism, and so may be decomposed as follows\n\n\\begin{eqnarray*}\n\t \\hat{\\phi}(x) &=& \\hat{\\phi}_{\\text{lo}} (x_{\\text{lo}}) \\oplus \\hat{\\phi}_{\\text{hi}} (x_{\\text{hi}}) \\\\\n\t\\hat{\\phi}_{\\text{lo}}, \\hat{\\phi}_{\\text{hi}} &:& \\mathbb{F}^4_2 \\rightarrow \\mathbb{F}^8_2 \\, .\n\\end{eqnarray*}\n\nThe two functions are then in a form which may be implemented with the nstruction PSHUFB. For future reference we note the inverse of the basis change given above is generated by\n\n\\begin{eqnarray*}\nt &\\rightarrow& X + X^5 + X^7 \\\\\n\\bar{t} &\\rightarrow& 1 + X + X^5 + X^7 \\\\\n\\zeta &\\rightarrow& X^4 + X^6 \\, . \n\\end{eqnarray*}\n\nIt may be preferable to consistently work in the ``tower'' basis to avoid converting representations on each round. In this case the state must be converted to and from the tower basis at the start and the end of the algorithm, and they key expansion must also be converted.\n\n\\section{Affine component of SubBytes}\n\nAs the affine map is linear, it may be implemented with two shuffle instructions followed by an XOR. If it is adjacent to another linear map in the algorithm then clearly the two maps may be merged for efficiency reasons. For example in the inversion algorithm described above, the final two operations are shuffles, and the linear portion of the affine map may be incorporated directly. Note that must be careful when working in the tower basis.\n\n\\section{Shift Rows}\n\nThe ShiftRows transformation and its inverse can naturally be implemented with a single shuffle instruction.\n\n\\section{Mix Columns}\n\nRecall that the mix columns operation corresponds to multiplication by a circulant matrix over $\\mbbF_{2^8}$ \n\n\\[ M :=\n\\left( \\begin{array}{cccc}\n2 & 3 & 1 & 1 \\\\\n1 & 2 & 3 & 1 \\\\\n1 & 1 & 2 & 3 \\\\\n3 & 1 & 1 & 2\n\\end{array} \\right)\n\\]\n\nIt may be shown that the inverse operation is multiplication by the circulant matrix\n\n\\[ M^{-1} := \n\\left( \\begin{array}{cccc}\n14 & 11 & 13 & 9 \\\\\n9 & 14 & 11 & 13 \\\\\n13 & 9 & 14 & 11 \\\\\n11 & 13 & 9 & 14\n\\end{array} \\right)\n\\]\n\nLet $P$ denote the elementary circulant matrix \n\n\\[\n\\left( \\begin{array}{cccc}\n0 & 1 & 0 & 0 \\\\\n0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 1 \\\\\n1 & 0 & 0 & 0 \n\\end{array} \\right)\n\\]\n\nThis, and its powers, are easy to implement using the shuffle instruction. Recalling that $n \\times n$ matrices form a $\\mbbF_{2^8}$-algebra (with elements acting point wise), then we see\n\n\\begin{eqnarray*}\n M &=& 2 I + 3 P + P^2 + P^3 \\\\\n     &=& \\left(I + P\\right)\\left(2I + P\\right) + P^3\n\\end{eqnarray*}\n\nand\n\n\\begin{eqnarray*}\n M^{-1} &=& \\left(8+4+2\\right)I + \\left(8+2+1\\right)P + \\left(8+4+1\\right)P^2 + \\left(8+1\\right)P^3 \\\\\n    &=& \\left(I + P^2\\right)\\left[ 9 \\cdot \\left(I + P\\right) +4 \\cdot I \\right] + 2 \\cdot \\left(I + P\\right) + I\n\\end{eqnarray*}\n\nCalculation of $M$ requires one doubling, three shuffles and three additions.\n\nCalculation of $M^{-1}$ requires three scalar multiplications, two shuffles and five additions.\n\nNote in the canonical basis the scalar multiplications can be calculated as follows\n\n\t$$ X^k \\sum_{i=0}^7 a_i X^i = \\sum_{i=0}^3 a_i X^{i+k} + X^k \\left( \\sum_{i=4}^7 a_i X^i \\right) \\quad k \\leq 4 $$\n\t\nThe first term is a left shift and the final term may be calculated by a lookup table as with the following pseudocode.\n\n\\begin{verbatim}\n         mult1 = and(x,0x0f)<<k\n         mult2 = pshufb(lookup_k,and(x,0xf0)>>4)\n         mult  = xor(mult1,mult2)\n\\end{verbatim}\n\nWorking in the tower basis requires two shuffle instructions.\n\n\\bibliographystyle{alpha}\n\\bibliography{bibentry}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "51a6d7a5b7815f4e62fcd8a7ad811fa442a418a4", "size": 11731, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/vpaes_details.tex", "max_stars_repo_name": "drufino/libtinfoil", "max_stars_repo_head_hexsha": "f15d92a501791023edbd1b2cb1660a33572b1c73", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-06T14:34:23.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-06T14:34:23.000Z", "max_issues_repo_path": "docs/vpaes_details.tex", "max_issues_repo_name": "davidr83/libtinfoil", "max_issues_repo_head_hexsha": "f15d92a501791023edbd1b2cb1660a33572b1c73", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/vpaes_details.tex", "max_forks_repo_name": "davidr83/libtinfoil", "max_forks_repo_head_hexsha": "f15d92a501791023edbd1b2cb1660a33572b1c73", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9013605442, "max_line_length": 446, "alphanum_fraction": 0.6916716392, "num_tokens": 3753, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.43782010690695883}}
{"text": "\n\\chapter{Mutating algorithms} \\Label{cha:mutating}\n\nLet us now turn our attention to another class of algorithms,\nviz.\\ \\emph{mutating} algorithms of the \\cxx Standard Library \\cite[\\S\n28.6]{cxx-17-draft}, i.e.,\nalgorithms that change one or more ranges.\n%\nIn \\framac, you can explicitly specify that, e.g., entries in an array\n\\inl{a} may be modified by a function\n\\inl{f},\nby including the following \\emph{assigns clause} into the \n\\inl{f}'s specification:\n\n\\begin{lstlisting}[style=acsl-block]\n\n     assigns a[0..length-1];\n\\end{lstlisting} %\nThe expression \\inl{length-1} refers to the value of \\inl{length}\nwhen \\inl{f} is entered, see \n\\cite[\\S2.3.2]{ACSLSpec}.\nBelow are the algorithms we will discuss in this chapter.\n\n\\begin{itemize}\n\n\\item\nIn order to allow for a finer control of which parts of an array,\nwe introduce in \\S\\ref{sec:unchanged} the auxiliary predicate \\Unchanged.\n\n\\item \\filli in \\S\\ref{sec:filli}\ninitializes each element of an array by a given fixed value.\n\n\\item \\swap in \\S\\ref{sec:swap} exchanges two values.\n\n\\item \\swapranges \nin \\S\\ref{sec:swapranges} exchanges the contents of the arrays of equal length, element\nby element.\nWe use this example to present ``modular verification'',\nas \\swapranges reuses the verified properties of \\swap.\n\n\\item \\copyi \nin \\S\\ref{sec:copyi} \ncopies a source array to a destination array.\n\n\\item \\copybackward \nin \\S\\ref{sec:copybackward} also\ncopies a source array to a destination array. \nThis version, however, uses another separation condition than \\copyi.\n\n\\item \\reversecopy and \\reverse \nin \\S\\ref{sec:reversecopy} and~\\S\\ref{sec:reverse}, respectively,\nreverse an array.\nWhereas \\reversecopy copies the result to a separate destination array, \nthe \\reverse algorithm works in place.\n\n\\item \\rotatecopy \nin \\S\\ref{sec:rotatecopy}\nrotates a source array by \\inl{m} positions and copies the results to a\ndestination array.\n\n\\item \\rotatei \nin \\S\\ref{sec:rotatei}\nrotates \\emph{in place} a source array by \\inl{m} positions.\n\n\\item \\replacecopy and \\replace\nin \\S\\ref{sec:replacecopy} and~\\S\\ref{sec:replace}, respectively,\nsubstitute each occurrence of a value by a given new value.\nWhereas \\replacecopy copies the result to a separate array, \nthe \\replace algorithm works in place.\n\n\\item \\removecopy and \\remove in \\S\\ref{sec:removecopy}--\\S\\ref{sec:remove}\n\\emph{filter} all occurrences of a given value from an array.\nWhereas \\removecopy copies the result to a separate array, \nthe \\remove algorithm works in place.\nNote that we provide altogether three versions of how to specify \\removecopy.\nThis shall help the reader to understand that finding appropriate contracts\nis an iterative process and that it is usually a good idea to \\emph{not} strive\nfor a ``complete'' contract right from the beginning.\n\n\\item \\shuffle in \\S\\ref{sec:shuffle} randomly reorders the elements of an array\nthereby relying on the simple random number generator \\randomnumber in \n\\S\\ref{sec:randomnumber}.\n\n\\end{itemize}\n\n\\clearpage\n\n\\input{mutating/unchanged}\n\\input{mutating/fill}\n\\input{mutating/swap}\n\\input{mutating/swap_ranges}\n\\input{mutating/copy}\n\\input{mutating/copy_backward}\n\\input{mutating/reverse_copy}\n\\input{mutating/reverse}\n\\input{mutating/rotate_copy}\n\\input{mutating/rotate}\n\\input{mutating/replace_copy}\n\\input{mutating/replace}\n\\input{mutating/remove_copy}\n\\input{mutating/remove_copy2}\n\\input{mutating/remove_copy3}\n\\input{mutating/remove}\n\\input{mutating/shuffle}\n\\input{mutating/random_number}\n\n", "meta": {"hexsha": "cf9472730be31054272cd692b725556bb5177d19", "size": 3476, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/mutating/mutating-algorithms.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/mutating/mutating-algorithms.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/mutating/mutating-algorithms.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 32.4859813084, "max_line_length": 87, "alphanum_fraction": 0.7698504028, "num_tokens": 979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283033, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4378200951345236}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Moving Average Convergence Divergence} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{Moving average convergence divergence (MACD) is a trend-following momentum indicator that\nshows the relationship between two moving averages of a security’s price.\nThe MACD is calculated by subtracting the 26-period exponential moving average (EMA) from the 12-period EMA.\n}\n\n\\howtotrade\n{The strategy is to identify bullish and bearish crossovers.\nBullish crossover - when MACD line cross above the signal line\nBearish Crossover - when signal line cross above the MACD line.\n}\n\n\\ruleparameters\n{Short term look back Length}{12}{Short term look back length used to compute EMA.}{$\\lookbacklength_{s}$}\n{Long term look back Length}{26}{Long term look back length used to compute EMA.}{$\\lookbacklength_{l}$}\n{Signal look back Length}{9}{Look back length used to generate Signal line.}{$S_{l}$}\n\\stoptable\n\n\\newpage\n\\section{Equation}\nBelow are the equations which govern how this specific trading rule calculates a trading position.\n\n\\begin{equation}\nMACD = EMA(\\lookbacklength_{s}) - EMA(\\lookbacklength_{l})\n\\end{equation}\n\\\\\n\\begin{equation}\nSignal = EMA(S_{l})\n\\end{equation}\n\\\\ % creates some space after equation\nwith:\n\n$EMA(\\lookbacklength_{s})$: is the short term exponentially weighted average.\n\n$EMA(\\lookbacklength_{l})$: is the long term exponentially weighted average.\n\n$EMA(S_{l})$: is the exponentially weighted average computed to generate signal line.\n\n\n\\keyterms\n\\furtherlinks %The footer\n\\end{document}\n", "meta": {"hexsha": "6775fbd1075f72feaade4015aada42328537c530", "size": 1683, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/MovingAverageConvergenceDivergence.tex", "max_stars_repo_name": "GirijaDas9/infertrade", "max_stars_repo_head_hexsha": "9245eaae202aea997e62d4eeb299f70516da35e0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-07T14:40:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-07T14:40:51.000Z", "max_issues_repo_path": "docs/strategies/tex/MovingAverageConvergenceDivergence.tex", "max_issues_repo_name": "GirijaDas9/infertrade", "max_issues_repo_head_hexsha": "9245eaae202aea997e62d4eeb299f70516da35e0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/strategies/tex/MovingAverageConvergenceDivergence.tex", "max_forks_repo_name": "GirijaDas9/infertrade", "max_forks_repo_head_hexsha": "9245eaae202aea997e62d4eeb299f70516da35e0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3653846154, "max_line_length": 108, "alphanum_fraction": 0.7807486631, "num_tokens": 436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4378200912103785}}
{"text": "\\section{Maintenance Models}\n\\label{sec:MaintenanceModels}\n\n\\textbf{Maintenance Models} are models designed to model maintenance and testing from a reliability perspective.\nThese models are designed to optimize preventive maintenance at the system level.\n\nTwo classes of models are considered here:\n\\begin{itemize}\n\t\\item Operating, i.e. model \\xmlAttr{type} is \\xmlString{Operating}\n\t\\item Standby, i.e. model \\xmlAttr{type} is \\xmlString{Standby}\n\\end{itemize}\n\nThe specifications of these models must be defined within a RAVEN \\xmlNode{ExternalModel}. This\nXML node accepts the following attributes:\n\\begin{itemize}\n\t\\item \\xmlAttr{name}, \\xmlDesc{required string attribute}, user-defined identifier of this model.\n\t\\nb As with other objects, this identifier can be used to reference this specific entity from other\n\tinput blocks in the XML.\n\t\\item \\xmlAttr{subType}, \\xmlDesc{required string attribute}, defines which of the subtypes should\n\tbe used. For maintenance models, the user must use \\xmlString{SR2ML.MaintenanceModel} as subtype.\n\\end{itemize}\nIn the maintenance \\xmlNode{ExternalModel} input block, the following XML subnodes are required:\n\\begin{itemize}\n\t\\item \\xmlNode{variable}, \\xmlDesc{string, required parameter}. Comma-separated list of variable\n\tnames. Each variable name needs to match a variable used or defined in the maintenance model or variable\n\tcoming from other RAVEN entities (i.e., Samplers, DataObjects, and Models).\n\t\\nb For all the maintenance models, the following outputs variables would be available. If the user\n\tadded these output variables in the node \\xmlNode{variables}, these variables would be also available to\n\tfor use anywhere in the RAVEN input to refer to the maintenance model output variables.\n\t\\begin{itemize}\n\t\t\\item \\xmlString{avail}, variable that contains the calculated availability value\n\t\t\\item \\xmlString{unavail}, variable that contains the calculated unavailability value\n\t\\end{itemize}\n\t\\nb When the external model variables are defined, at run time, RAVEN initializes\n\tthem and tracks their values during the simulation.\n\t\\item \\xmlNode{MaintenanceModel}, \\xmlDesc{required parameter}. The node is used to define the maintenance\n\tmodel, and it contains the following required XML attribute:\n\t\\begin{itemize}\n\t\t\\item \\xmlAttr{type}, \\xmlDesc{required string attribute}, user-defined identifier of the maintenance model.\n\t\t\\nb the types for different maintenance models can be found at the beginning of this section.\n\t\\end{itemize}\n\\end{itemize}\nIn addition, if the user wants to use the \\textbf{alias} system, the following XML block can be input:\n\\begin{itemize}\n\t\\item \\xmlNode{alias} \\xmlDesc{string, optional field} specifies alias for\n\tany variable of interest in the input or output space for the ExternalModel.\n\t%\n\tThese aliases can be used anywhere in the RAVEN input to refer to the ExternalModel\n\tvariables.\n\t%\n\tIn the body of this node, the user specifies the name of the variable that the ExternalModel is\n\tgoing to use (during its execution).\n\t%\n\tThe actual alias, usable throughout the RAVEN input, is instead defined in the\n\t\\xmlAttr{variable} attribute of this tag.\n\t\\\\The user can specify aliases for both the input and the output space. As a sanity check, RAVEN\n\trequires an additional required attribute \\xmlAttr{type}. This attribute can be either ``input'' or ``output.''\n\t%\n\t\\nb The user can specify as many aliases as needed.\n\t%\n\t\\default{None}\n\\end{itemize}\n\n\n\\subsection{Operating Model}\nFor an operating model, the unavailability $u$ is calculated as\n\\begin{equation}\n\tu = lambda*Tr/(1.0+lambda*Tr) + Tpm/Tm\n\\end{equation}\nwhere:\n\\begin{itemize}\n  \\item lambda: is the component failure rate\n  \\item Tr: mean time to repair\n  \\item Tpm: mean time to perform preventive maintenance\n  \\item Tm: preventive maintenance interval\n\\end{itemize}\n\nExample XML:\n\\begin{lstlisting}[style=XML]\n    <ExternalModel name=\"PMmodelOperating\" subType=\"SR2ML.MaintenanceModel\">\n      <variables>lambda,Tm,avail,unavail</variables>\n      <MaintenanceModel type=\"PMModel\">\n        <type>operating</type>\n        <Tr>24</Tr>\n        <Tpm>10</Tpm>\n        <lambda>lambda</lambda>\n        <Tm>Tm</Tm>\n      </MaintenanceModel>\n    </ExternalModel>\n\\end{lstlisting}\n\n\\subsection{Standby Model}\nFor an operating model, the unavailability $u$ is calculated as:\n\\begin{equation}\n  u = rho + 0.5*lambda*Ti + Tt/Ti + (rho+lambda*Ti)*Tr/Ti + Tpm/Tm\n\\end{equation}\nwhere:\n\\begin{itemize}\n  \\item rho: failure probability per demand\n  \\item Ti: surveillance test interval\n  \\item Tr: mean time to repair\n  \\item Tt: test duration\n  \\item Tpm: mean time to perform preventive maintenance\n  \\item Tm: preventive maintenance interval\n  \\item lamb: component failure rate\n\\end{itemize}\n\nExample XML:\n\\begin{lstlisting}[style=XML]\n    <ExternalModel name=\"PMmodelStandby\" subType=\"SR2ML.MaintenanceModel\">\n      <variables>lambda,Tm,Ti,avail,unavail</variables>\n      <MaintenanceModel type=\"PMModel\">\n        <type>standby</type>\n        <Tr>24</Tr>\n        <Tpm>10</Tpm>\n        <Tt>5</Tt>\n        <rho>0.01</rho>\n        <lambda>lambda</lambda>\n        <Ti>Ti</Ti>\n        <Tm>Tm</Tm>\n      </MaintenanceModel>\n    </ExternalModel>\n\\end{lstlisting}\n", "meta": {"hexsha": "5ad337f78ab07abd0db1958d536a77ac49897002", "size": 5207, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user_manual/include/MaintenanceModels.tex", "max_stars_repo_name": "idaholab/SR2ML", "max_stars_repo_head_hexsha": "2aa5e0be02786523cdeaf898d42411a7068d30b7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-01-25T02:01:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T03:14:49.000Z", "max_issues_repo_path": "doc/user_manual/include/MaintenanceModels.tex", "max_issues_repo_name": "idaholab/SR2ML", "max_issues_repo_head_hexsha": "2aa5e0be02786523cdeaf898d42411a7068d30b7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 32, "max_issues_repo_issues_event_min_datetime": "2021-01-12T18:43:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-17T19:45:27.000Z", "max_forks_repo_path": "doc/user_manual/include/MaintenanceModels.tex", "max_forks_repo_name": "idaholab/SR2ML", "max_forks_repo_head_hexsha": "2aa5e0be02786523cdeaf898d42411a7068d30b7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.9919354839, "max_line_length": 112, "alphanum_fraction": 0.7487996927, "num_tokens": 1364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.43777224228394257}}
{"text": "\\section{Systems comparison}\n\\label{sec:sys-cmp}\nNowadays, we can find several products on the market, developed by several companies around the world. Many of them are patented to protect the invention itself, some others are protected by corporate secrets, the remaining are available as academic publications. Commercial cameras and lasers are sufficiently powerful and accurate that the hardware could be considered negligible when we want to compare these systems. What really characterises each of them is the software, i.e. the mathematical model used to extract the wheel profile and to approximate the diameter. \\\\\n\nIn the following of this section, we will present some mathematical models used to evaluate the diameter of the wheels, starting from the rolling points determined by the wheels profiles. To avoid infringing patents, we will present the models without ever mentioning who the owners are. However, some of the corporations that are analysed are: % Beena Vision\\footnote{ Corporation available at \\url{http://www.beenavision.com/}}, Danobat\\footnote{ Corporation available at \\url{https://www.danobatgroup.com/en/danobat}}, Graw\\footnote{ Corporation available at \\url{http://www.graw.com/}}, IEM\\footnote{ Corporation available at \\url{http://www.iem.net/}}, KLD Labs\\footnote{ Corporation available at \\url{http://www.kldlabs.com/}}, MERMEC\\footnote{ Corporation available at \\url{http://www.mermecgroup.com/}} and MRX\\footnote{ Corporation available at \\url{http://www.mrxtech.com.au/}}.\n  \\begin{itemize}\n    \\item Beena Vision\\footnote{\\url{http://www.beenavision.com/}}\n    \\item Danobat\\footnote{\\url{https://www.danobatgroup.com/en/danobat}}\n    \\item Graw\\footnote{\\url{http://www.graw.com/en/}}\n    \\item IEM\\footnote{\\url{http://www.iem.net/}}\n    \\item KLD Labs\\footnote{\\url{http://www.kldlabs.com/}}\n    \\item MER MEC\\footnote{\\url{http://www.mermecgroup.com/}}\n    \\item MRX\\footnote{\\url{http://www.mrxtech.com.au/}}\n  \\end{itemize}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{System \\#1} % BeenaVision\nThe first considered system uses an approach a bit different from the others. It is based on three laser-camera pairs: two are used to reconstruct the section of the wheel, while the third takes a section of the wheel parallel to its sides (perpendicular to the wheelset axis). The two sections visible from the outer side are shown in Figure \\ref{fig:cmp-sys1}. In this way, line 28 allows to collect a number of points greater than three, as suggested in \\cite{wpms-giuseppe}. To simplify the fitting of this last set of point on the wheel, its section is modelled as a cylinder of equation:\n  \\begin{equation}\n    \\left( y - y_0 \\right) + \\left( z - z_0 \\right) = r^2\n    \\label{eq:cylinder}\n  \\end{equation}\ninstead as a cone, but this requires some corrections in order to get the exact wheel diameter. Equation \\ref{eq:cylinder} is the same as a circle, whose axis passes through the center point $\\left( y_0, z_0 \\right)$. This equation can be solved using only three points, but it is more precise if the number of used points is greater.\n  \\begin{figure}[t!]\n    \\centering\n    \\includegraphics[width=0.6\\textwidth]{./images/wpms/lasers1.png}\n    \\caption{System \\#1, outer side collected sections}\n    \\label{fig:cmp-sys1}\n  \\end{figure}\nLasers lines are extracted from the (simultaneous) acquired images, after a preprocessing. This data elaboration consists of image resizing, laser spots detection, image equalization using threshold filters and rejection of noisy points. In particular, the detection of the laser spots is performed using edge-detection algorithms instead of subpixel filters; in this case the subpixel precision is guaranteed by the image resizing. Note that line 28 generally is not perpendicular to the axis of the wheel, because of the inclination of the same with respect to the rail. This situation introduces an error when we compute the diameter. Thus, the profile has to be projected in a plane perpendicular to the axis of the wheel, before compute the Equation \\ref{eq:cylinder}. This correction is called \\textit{radial compensation}. \\\\\nThe presentations of the commercial products of this corporation offer a precision greater of $96\\%$ for each measure of interest (diameter, flange width and height, \\ldots).\n\n%%%\n% If it is the case to do that, I've some other notes about BeenaVision\n%%%\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{System \\#2} % Danobat\nDifferently from the previous system, this one proposes a method that can be used with many different structured light projectors, even if all proposed solutions are focused on laser stripes. This proposal basically uses at least two laser-camera pair in order to reconstruct the entire profile of the wheel, and solve the occlusion problem. \\\\\nOnce the laser spots are detected from the two different acquisitions, they are converted in a common 3D reference system, where $X$ is the longitudinal direction, $Y$ is the transverse direction and $Z$ the vertical direction. Converted data are then corrected, by aligning the profile with the ideal reference system: this corrects distortions due to the wheel inclination with respect to its axis (angle $\\alpha$ and $\\beta$, as shown in Figure \\ref{fig:cmp-sys2}).\n  \\begin{figure}[t!]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{./images/wpms/wheel-rotation.png}\n    \\caption{System \\#2, wheel rotations with respect to ideal axis. $R$ is the ideal rotation axis, $1$ is the wheel and $2$ the rail.}\n    \\label{fig:cmp-sys2}\n  \\end{figure}\nThis is performed by correcting the rotation of the tensors parallel to the inner and outer side, with respect to the ideal ones. Furthermore this correction allows to analyse the profile in a well known position, regardless of how the profile is acquired by the camera (remember that the train is running on the sensor). At this point, for each detected laser spot, from the flange to the wheel contact surface, a radius is computed. Radius is understood as the distance between a point of light reflected on the section of the wheel and a transverse height $Y$ of the axis $R$ of the wheel, and it is computed using the equation:\n  \\begin{equation*}\n    Radius = \\sqrt{x^2 + z^2}\n  \\end{equation*}\nwhere $x$ and $z$ are respectively the longitudinal and the transverse heights of each point of light of the laser line.\nWhen all the parameters of interest are rough estimated, a Gauss-Newton algorithm is used in order to minimize the error on the computed radii, and in this way to refine the angles $\\left( \\alpha, \\beta \\right)$ and the position and orientation of each profile. At the end, the measures of interests are computed. The presentations of the commercial products of this corporation offer a precision around of $0.2 \\, mm$ for measures concerning profile of the wheel (flange height and thickness, qR factor, \\ldots) and a precision around of $1 \\, mm$ for the diameter.\n \n \n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{System \\#3} % IEM\nLike the system \\#2, also this approach is thought to be used both with laser beams and with structured light. Even the order with which the operations are performed is about the same:\n  \\begin{itemize}\n    \\item detection of the laser stripe;\n    \\item data conversion into the 3D $\\left(XYZ\\right)$ reference system and alignment to the ideal orientation;\n    \\item interpolation of the raw data using standard shape fitting algorithms;\n    \\item evaluation of the measures of interests.\n  \\end{itemize}\nWhat distinguishes this system from others, is the approach used to detect the laser spot and to reconstruct the profile of the wheel. In fact, it uses standard geometric fitting algorithms to find each part that dial the profile, as flange, rim, wheel inner and outer sides, \\ldots Once the entire profile is built from each acquired image (generally, one for each laser-camera pair used), the diameter of the wheel is determined using a standard circle fitting algorithm\\footnote{Not specified in the patent} that allows to approximate the rolling circle. \\\\\n\nUnfortunately, in the website of the manufacturer we have found only commercial description about the products, but no information about their precision, or accuracy. However, these informations could be meaningless. This corporation is the owner of many patents regarding laser-triangulation systems, each one of them proposes a different approach to the problem. For example, some of them are based on expert system or on neural network. Furthermore, different sensors are suggested, such as electromagnetic or acoustic devices. \\\\\nAll the patents analysed described a complete system, but avoid to study in details the algorithms used to process collected data, thus we can only speculate on how proposed systems really work.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{System \\#4} % Mermec\nLike the previous systems, also this last one is based on, at least, a couple of a laser-camera pair, that allow to reconstruct the entire profile of the wheel, similarly as shown in Figure \\ref{fig:cmp-sys4}.\nThe laser beams are collected by the three cameras, and the spots are located using sup-pixel approximation algorithms, that increase the accuracy of the laser estimation, starting from the acquired images. Thus, the entire profile is rebuilt merging the inner and outer laser lines, and aligned to the ideal orientation. At this point, some keypoints are determined in order to evaluate the measures of interest. \\\\\n\nOne of the most meaningful points, is the rolling point: in fact it allows to estimate the diameter of the wheel. As in the previous case, this operation requires at least three points, taken from at least three synchronous acquisitions. Also in this case, a radial compensation is needed, in order to reduce the measurement error; if the system provides many triangulation groups, it is possible to estimate different diameters, and then average along this values. Note that, in this way it is possible to approximate the wheel circle, but it is not possible to consider wheel ovalization.\n% Concerning the estimation of the diameter, given at least three different rolling points, belonging to the rebuilt profiles and taken in different positions, the Erone's formula is used:\n%  \\begin{equation*}\n%    D = \\frac{2\\cdot a\\cdot b\\cdot c}{\\sqrt{(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}}\n%  \\end{equation*}\n%where $a$, $b$ and $c$ are the sides of the triangle with vertexes the three point above. In this way it is possible to approximate the wheel circle, but it is not possible to consider wheel ovalizations.\n  \\begin{figure}[t!]\n    \\centering\n    \\begin{minipage}[c]{.49\\textwidth}\n      \\centering\n      %\\includegraphics[width=\\textwidth]{./images/wpms/mm-wpms.jpg}\n      \\includegraphics[width=0.8\\textwidth]{./images/wpms/test2_cut.jpg}\n    \\end{minipage}%\n    \\hfill\n    \\begin{minipage}[c]{.49\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{./images/wpms/laser_pts.png}\n    \\end{minipage}\n    \n    \\caption{System \\#4, example of system configuration.}\n    \\label{fig:cmp-sys4}\n  \\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{System \\#5} % \\cite{wpms-giuseppe}\nThis last system proposes an alternative process to extract the laser stripe. Instead of improving the accuracy of the peak detection working on sub-pixel approximation, it uses an edge detector presented in \\cite{chen2013efficient} and \\cite{659930}. In this way, it is possible to detect the maximum of the second derivative of the grey level perpendicular to the laser stripe. Thus, it is possible to improve the peak detection even when the beam is not perpendicular to the pixel direction in the sensor, specially when the laser line bends (e.g. in the flange side). The system boast of reaching the precision of $0.1$ pieces of pixels, regardless of the variations in the width or light intensity (i.e. grey values) of the beam. Furthermore, the approach is more robust with respect to noise.\n\nIn order to correctly determine the diameter of the wheel, the system needs to rotate the profile, so that the rim plane segment can be parallel to the y-axis of the 2D coordinate frame on the laser plane. Hence, three rim plane segments can be determined, and using the 3D coordinates in the world reference system, it is possible to obtain the equation of the wheel rim plane by fitting all of the rim plane segments:\n  \\begin{equation}\n    \\pi_rim : a_rx + b_ry + c_rz + d_r = 0\n    \\label{eq:sys5-plane}\n  \\end{equation}\nAt the end, the diameter can be determined by projecting the flange vertexes and at least two contact points on the plane described in the Equation \\ref{eq:sys5-plane}. Each of the point $p$ is projected in the rim plane accordingly with:\n  \\begin{equation*}\n    p' = p + t\\cdot\\frac{N^T}{||N||}\n  \\end{equation*}\nwhere $N = \\begin{bmatrix} a_r, b_r, c_r \\end{bmatrix}$, and $t$ is the distance from $p$ to the wheel rim plane. Thus, a maximum likelihood criterion is used against the noise, so as the approximation of the center of the wheel is improved, and a non-linear optimization method (e.g. Levenberg–Marquardt) can be performed to solve the problem. \\\\\nThe Levenberg–Marquardt algorithm (\\acs{LMA} from the names of its inventors) is used to solve generic curve-fitting problems, and it always finds a local minima at least. This algorithm is slower that the Gauss-Newton one, but it is more precise. It is based on a least-squares method: given a set of $m$ empirical datum pairs $\\left( x_i, y-i \\right)$ of independent and dependent variables, find the parameters $\\beta$ of the model curve $f(x,\\beta)$ so that the sum of the squares of the deviations is minimized. \\\\\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Conclusion to the chapter\n~\\\\\n\nAs we can see, the proposed systems are less than the number of the corporations analysed. As just mentioned before, many companies prefer to protect their products with corporation secrets instead using patents. Furthermore, many of the patents found are related to different systems or approaches (for example regarding static systems). These choices prevented us to comment all the products on the market. However, the systems discussed above, and summarised in Table \\ref{tab:wpms:summaries}, are a good sample of the possible solutions for measuring the world using laser triangulation-based systems.\n  \\input{./src/chapters/ch3-WPMS/tab-summary.tex}\n%  \\begin{table}\n%    \\includegraphics[width=\\textwidth]{./images/wpms/tab.PNG}\n%    \\caption{Summery of the systems above.}\n%    \\label{tab:wpms:summaries}\n%  \\end{table}", "meta": {"hexsha": "10cc9b362629e5740c0d0b82f07f2a316cd1636a", "size": 14585, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/src/chapters/ch3-WPMS/1_cmps.tex", "max_stars_repo_name": "extoxesses/LaserMat", "max_stars_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-12T08:53:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T06:36:55.000Z", "max_issues_repo_path": "report/thesis/src/chapters/ch3-WPMS/1_cmps.tex", "max_issues_repo_name": "extoxesses/LaserMat", "max_issues_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/src/chapters/ch3-WPMS/1_cmps.tex", "max_forks_repo_name": "extoxesses/LaserMat", "max_forks_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 116.68, "max_line_length": 888, "alphanum_fraction": 0.7618786424, "num_tokens": 3468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4377722351049116}}
{"text": "\\input{def.tex}\n\n\\DeclareMathOperator{\\supp}{supp}\n\n\\title{Solutions to \\\\ \\textit{Introduction to the Theory of Distirbutions}}\n\\author{Yunwei Ren}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\vspace{1cm}\n\n\\section{Test Functions and Distributions}\n\\paragraph{1.2}\n\\begin{proof}\n  It suffices to show that $f \\equiv 0$ on an open set $O$ iff the restriction\n  of the distribution $\\langle f, \\cdot\\rangle$ onto $O$ is the zero\n  distribution. Suppose that $\\langle f, \\cdot\\rangle|_O \\equiv 0$ since the\n  other direction is obvious. Assume, to obtain a contradiction, that\n  $f(x) > 0$ for some $x \\in O$. Since $f$ is continuous, there is an open\n  neighborhood $U \\subset O$ s.t. $f > \\vep$ on $U$ for some $\\vep > 0$. Choose\n  a small closed ball $B \\subset U$ centered at $x$ and let $\\psi$ be the \n  cutoff function with $\\supp\\psi \\subset U$, $0 \\le \\psi \\le 1$ and\n  $\\psi \\equiv 1$ on $B$. Then\n  \\[\n    0 = \\langle f, \\psi\\rangle = \\int_U f\\psi > \\vep\\mu(B) > 0,\n  \\]\n  where $\\mu(B)$ is the measure of $B$. Contradiction. Thus, $f \\le 0$.\n  Similarly, we can show $f \\ge 0$. Therefore, $f \\equiv 0$ on $O$.\n  \n  The result is not true for $f \\in L_1^{\\mrm{loc}}(\\mathbb{R}^n)$ in general\n  since add a function which is zero a.e. to $f$ does not change the\n  distribution but will change the support of $f$. \n\\end{proof}\n\n\\paragraph{1.5}\n\\begin{proof}\n  For every compact $K \\subset (0, \\infty)$, there is an integer $N$ s.t. \n  $1/k \\notin K$ for all $k > N$. Hence, for every $\\phi \\in C^\\infty_c(0,\n  \\infty)$ with $\\supp \\phi \\subset K$, \n  \\[\n    |\\langle u, \\phi\\rangle| \n    = \\left|\\sum_{k=0}^N \\partial^k \\phi(1/k)\\right|\n    \\le \\sum_{k=0}^N \\sup|\\partial^k \\phi|.\n  \\]\n  Thus, $u$ is a distribution on $(0, \\infty)$. \n  \n  Assume, to obtain a contradiction, that $u = v|_{(0, \\infty)}$ for some \n  $v \\in \\mscr{D}\\hp(\\R)$. Let $f \\in C^\\infty_c(\\R)$ be a cutoff function\n  with $f \\equiv 1$ on $[-1, 1]$. Then, the distribution $fu$ (cf. Sec. 2.5)\n  is of infinite order since its restriction to $1/m$ is $\\delta^{(m)}$ for\n  every positive integer $m$. However, since $fu$ is compactly supported, it\n  must have a finite order (cf. Sec. 3.1). Contradiction. \n\\end{proof}\n\n\\paragraph{1.6}\n\\begin{proof}\n  It follows immediately from the Riesz-Markov theorem.\n\\end{proof}\n\n\\paragraph{1.7}\n  I am not sure whether the second part can be proved since if we put\n  $f_\\vep \\equiv 0$ for some $\\vep \\in (0, 1)$, the asymptotic behavior will\n  not change.\n\\begin{proof}\n  It suffices to show $\\int f_\\vep\\phi \\to \\phi(0)$ as $\\vep\\to 0$. Let \n  $B_\\vep = \\{|x| \\le \\vep\\}$. We have\n  \\begin{align*}\n    \\left|\\int f_\\vep \\phi - \\phi(0)\\right|\n    &= \\left|\\int_{B_\\vep} f_\\vep (\\phi - \\phi(0)) \\right| \\\\\n    &\\le \\sup_{x \\in B_\\vep}|\\phi(x) - \\phi(0)| \\int|f_\\vep| \\\\\n    &\\le \\mu\\sup_{x \\in B_\\vep}|\\phi(x) - \\phi(0)| .\n  \\end{align*}\n  Since $\\phi\\in C^\\infty(\\R^n)$, $\\sup_{x\\in B_\\vep}|\\phi(x) - \\phi(0)|\n  \\to 0$ as $\\vep \\to 0$. Thus, $f_\\vep \\to \\delta$ in $\\mscr{D}\\hp(\\R^n)$.\n\\end{proof}\n\n\\paragraph{1.9}\n\\begin{proof}\n  Let $u_n(x) := \\sum_{k=-n}^n c_ke^{ikx}$. For every $\\phi \\in\n  C^\\infty_c(\\R)$, by repeatedly using integration by parts, we have\n  \\begin{align*}\n    \\langle u_n, \\phi\\rangle \n    &= \\int\\sum_{k=-n}^n c_k e^{ikx}\\phi(x)\\rd x \\\\\n    &= \\sum_{k=-n}^n c_k \\int e^{ikx}\\phi(x)\\rd x \\\\\n    &= \\sum_{k=-n}^n c_k \\left(\\frac{-1}{ik}\\right)^{m+2}\n      \\int e^{ikx}\\partial^{m+2}\\phi(x)\\rd x. \\\\\n  \\end{align*}\n  Note that $c_k \\left(\\frac{-1}{ik}\\right)^{m+2} \\le O(1/k^2)$ and the \n  $\\int e^{ikx}\\partial^{m+2}\\phi(x)\\rd x$ is bounded. Thus, $\\lim \n  \\langle u_n, \\phi\\rangle$ converges for every $\\phi$, whence $u$ converges\n  in $\\mscr{D}\\hp(\\R)$.\n\\end{proof}\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "427f960ad119aaaecd1e06fbd13a8049f23d37ca", "size": 3742, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "introduction_to_the_theory_of_distributions_2nd/main.tex", "max_stars_repo_name": "Engineev/solutions", "max_stars_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-07-13T08:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T17:37:17.000Z", "max_issues_repo_path": "introduction_to_the_theory_of_distributions_2nd/main.tex", "max_issues_repo_name": "Engineev/solutions", "max_issues_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "introduction_to_the_theory_of_distributions_2nd/main.tex", "max_forks_repo_name": "Engineev/solutions", "max_forks_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-28T00:05:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-28T00:05:28.000Z", "avg_line_length": 34.9719626168, "max_line_length": 79, "alphanum_fraction": 0.6143773383, "num_tokens": 1450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.4377722247702025}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{amsmath}\n\n\n\\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}\n%\\topmargin=0cm\n\\topmargin=-2cm\n\\addtolength{\\textheight}{6.5cm}\n\\addtolength{\\textwidth}{2.0cm}\n%\\setlength{\\leftmargin}{-5cm}\n\\setlength{\\oddsidemargin}{0.0cm}\n\\setlength{\\evensidemargin}{0.0cm}\n\n%misc libraries goes here\n%\\usepackage{fitch}\n\n\n\\begin{document}\n\n\\section*{Student Information } \n%Write your full name and id number between the colon and newline\n%Put one empty space character after colon and before newline\nFull Name : Zeynep Özalp \\\\\nId Number : 2237691 \\\\\n\n% Write your answers below the section tags\n\\section*{Answer 1}\n\\subsection*{1.1}\n\n\\begin{table}[H]\n\\small\n\\centering\n\\caption{ a) Tautology }\n\\label{table:example}\n\\begin{tabular}\n{|c|c|c|c|c|c|c|c|c|}\t%% specify column number and vertical lines\n\\hline \t\t\t\t\t\t\t%% line draw\n\\textbf{p} & \\textbf{q} & \\textbf{r} & \\textbf{$\\neg$ r} & \\textbf{p $\\rightarrow$ q} & \\textbf{p $\\wedge$ $\\neg$ r} & \\textbf{(p $\\rightarrow$ q) $\\leftrightarrow$ (p $\\wedge$ $\\neg$ r)} & \\textbf{$\\neg$ (q $\\wedge$ r)}  & \\textbf{RESULT}\\\\\n\\hline \nT & T & T & F & T & F & F & F & T \\\\\t\t\t%% separate columns by &\nT & T & F & T & T & T & T & T & T \\\\\nT & F & T & F & F & F & T & T & T \\\\\nT & F & F & T & F & T & F & T & T \\\\\nF & T & T & F & T & F & F & F & T \\\\\nF & T & F & T & T & F & F & T & T \\\\\nF & F & T & F & T & F & F & T & T \\\\\nF & F & F & T & T & F & F & T & T \\\\\n\n\\hline \n\n\\end{tabular}\n\\end{table}\n\\quad \\textbf{RESULT:} $\\textbf{((p $\\rightarrow$ q) $\\leftrightarrow$ (p $\\wedge$ $\\neg$ r))} \\rightarrow \\textbf{$\\neg$ (p $\\wedge$ r)}$\n\n\\begin{table}[H]\n\\small\n\\centering\n\\caption{ b) Contradiction }\n\\label{table:example}\n\\begin{tabular}\n{|c|c|c|c|c|c|c|c|}\t%% specify column number and vertical lines\n\\hline \t\t\t\t\t\t\t%% line draw\n\\textbf{p} & \\textbf{q} & \\textbf{$\\neg$ p} & \\textbf{p $\\vee$ q} & \\textbf{p $\\rightarrow$ q} & \\textbf{(p $\\vee$ q) $\\wedge$ (p $\\rightarrow$ q)} & \\textbf{q $\\rightarrow$ $\\neg$ p} & \\textbf{RESULT}\\\\\n\\hline \nT & T & F & T & T & T & F & F \\\\\t\t\t%% separate columns by &\nT & F & F & T & F & F & T & F \\\\\nF & T & T & T & T & T & T & F \\\\\nF & F & T & F & T & F & T & F \\\\\n\\hline \n\n\\end{tabular}\n\\end{table}\n\\textbf{RESULT:} \\textbf{$\\neg$((p $\\vee$ q) $\\wedge$ (p $\\rightarrow$ q) $\\vee$ (\\textbf{q $\\rightarrow$ $\\neg$ p}))}\n\n\\subsection*{1.2}\n\\textbf{a)} This argument is \\textbf{invalid}. Let $D=\\{-1,1\\}$ be a domain for $P(x)$ and $Q(x)$. Suppose $P(x) : x<0 $ and $Q(x) : x>0 $. Note that $P(x)$ is true for $x=-1$ and $Q(x)$ is true for $x=1$ in domain $D$. So, there exists at least one $x$ which $P(x)$ is true and there exists at least some other $x$ which $Q(x)$ is true. Note that first and second quantifiers' scopes are different on the left hand side so that one can choose different $x$ values. Thus, the argument $\\exists x P(x) \\wedge \\exists x Q(x)$ is valid for different choices of $x$. However, since on the right hand side, one quantifier's scope is $(P(x) \\wedge Q(x))$, one can choose only one $x$ for both $P(x)$ and $Q(x)$. Therefore, the argument $\\exists x (P(x) \\wedge Q(x))$ is invalid for $x=-1$ and $x=1$. In conclusion, the argument $\\exists x P(x) \\wedge \\exists x Q(x) \\rightarrow \\exists x (P(x) \\wedge Q(x))$ is invalid.\\\\\\\\\n\\textbf{b)} This argument is \\textbf{valid}. This argument is invalid if one can prove that the left hand side is true but the right hand side is false. Choose some arbitrary constant c in the domain of $P(x)$ and suppose the left hand side is true. This means for all choices of $x$, $P(x)$ is true; moreover, $P(c)$ is true. So, there exist at least one $x$ that $P(x)$ is true. Thus, the argument $\\exists x P(x)$ is true. Hence, if the left hand side is true, the right hand side must be true and the argument $\\forall x P(x) \\rightarrow \\exists x P(x)$ is valid.\n\n\n\\section*{Answer 2}\n\\begin{table}[H]\n\t\\begin{tabular}{*6{l}}\n\t\t$1.$ & $(\\neg p \\vee p) \\rightarrow ((p \\wedge \\neg q) \\rightarrow r)$ &  & Premise \\\\ \n\t\t$2.$ & $T \\rightarrow ((p \\wedge \\neg q) \\rightarrow r)$ &  & Negation Law\\\\ \n\t\t$3.$ & $\\neg T \\vee ((p \\wedge \\neg q) \\rightarrow r)$ &  & Table 7/Line 1\\\\\n\t\t$4.$ & $F \\vee ((p \\wedge \\neg q) \\rightarrow r)$ &  & Negation\\\\\n\t\t$5.$ & $(p \\wedge \\neg q) \\rightarrow r$ &  & Identity Law\\\\ \n\t\t$6.$ & $\\neg (p \\wedge \\neg q) \\vee r$ &  & Table 7/Line 1\\\\\n\t\t$7.$ & $(\\neg p \\vee q) \\vee r$ & & De Morgan's Law\\\\ \n\t\t$8.$ & $\\neg p \\vee q \\vee r$ & & Associative Law\\\\\n\t\t$9.$ & $q \\vee r \\vee \\neg p$ & & Commutative Law \\\\\n\t\t$10.$ & $(q \\vee r) \\vee \\neg p$ & & Associative Law \\\\ \n\t\\end{tabular}\n\\end{table}\n\n\n\\section*{Answer 3}\n1. $\\forall x (W(x) \\rightarrow Has\\_CS\\_Degree(x))$ \\\\\n2. $\\forall x \\forall y ((Phd(x) \\wedge Phd(y) \\wedge W(x) \\wedge W(y) \\wedge (x \\neq y))\\rightarrow Knows(x,y))$\\\\\n3. $\\forall x ((W(x) \\wedge (x \\neq Cenk)) \\rightarrow Older(Cenk,x))$\\\\\n4. $\\forall x ((W(x) \\wedge (x \\neq Selen))\\rightarrow Phd(x))$\\\\\n5. $\\neg (\\forall x \\forall y ((W(x) \\wedge W(y) \\wedge (x\\neq y))\\rightarrow Knows(x,y)))$\\\\\n6. $(\\exists x Phd(x) \\wedge \\exists y Phd(y) \\wedge (x\\neq y))\\rightarrow \\forall z ((z \\neq x)\\wedge (z \\neq y)\\rightarrow \\neg Phd(z))$\\\\\n7. $(\\exists x \\exists y \\exists z ((x \\neq y \\neq z \\neq Gizem) \\wedge Older(x,Gizem) \\wedge Older(y,Gizem) \\wedge Older(z,Gizem)))$\\\\\n8. $\\exists x (Phd(x) \\wedge W(x))\\rightarrow (\\forall y ((y \\neq x) \\rightarrow \\neg(Phd(y) \\wedge W(y))))$\n\n\\section*{Answer 4}\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lllllll}\n\t\t1. & & & $(p \\rightarrow r) \\vee (q \\rightarrow r)$ & premise & & \\\\ \\cline{3-7}\n\t\t2. & \\multicolumn{1}{c|}{} & & $p \\rightarrow r$ & assumed & & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t3. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $p \\wedge q$ & assumed & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t4. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $p$ & $\\wedge e, 3$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t5. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $r$ & $\\rightarrow e,  2, 4$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t6. & \\multicolumn{1}{c|}{} & & $(p \\wedge q) \\rightarrow r$ & $\\rightarrow i, 3-5$ & & \\multicolumn{1}{c|}{} \\\\ \\cline{3-7} \\\\ \\cline{3-7}\n\t\t7. & \\multicolumn{1}{c|}{} & & $q \\rightarrow r$ & assumed & & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t8. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $p \\wedge q$ & assumed & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t9. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $q$ & $\\wedge e, 8$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t10. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $r$ & $\\rightarrow e, 7, 9$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t11. & \\multicolumn{1}{c|}{} & & $(p \\wedge q) \\rightarrow r$ & $\\rightarrow i, 8-10$ & & \\multicolumn{1}{c|}{} \\\\ \\cline{3-7}\n\t\t12. & & & $(p \\wedge q) \\rightarrow r$ & $\\vee e, 1, 2-6, 7-11$ & & \\\\\n\t\t\n\t\\end{tabular}\n\\end{table}\n\n\n\\section*{Answer 5}\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lllllll}\n\t\t1. & & & $(\\neg p \\vee \\neg q)$ & premise & & \\\\ \\cline{3-7}\n\t\t2. & \\multicolumn{1}{c|}{} & & $p \\wedge q$ & assumed & & \\multicolumn{1}{c|}{} \\\\ \n\t\t3. & \\multicolumn{1}{c|}{} &  & $p$ & $\\wedge e, 2$ &  & \\multicolumn{1}{c|}{} \\\\\n\t\t4. & \\multicolumn{1}{c|}{} &  & $q$ & $\\wedge e, 2$ &  & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t5. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $\\neg p$ & assumed & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \n\t\t6. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $\\perp$ & $\\neg e, 5, 3$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \n\t\t7. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $r$ & $lemma \\ \"\\perp  \\ \\vdash X\"$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t& \\multicolumn{1}{c|}{} &  &  &  &  & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t8. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $\\neg q$ & assumed & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t9. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $\\perp$ & $\\neg e, 8, 4$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t10. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $r$ & $lemma \\ \"\\perp  \\ \\vdash X\"$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t11. & \\multicolumn{1}{c|}{} & & $r$ & $\\vee e, 1, 5-7, 8-10$ & & \\multicolumn{1}{c|}{} \\\\ \\cline{3-7}\n\t\t12. & & & $(p \\wedge q) \\rightarrow r$ & $\\rightarrow i, 2-11$ & & \\\\\n\t\t\n\t\\end{tabular}\n\\end{table}\n\n\\textbf{Proof for $lemma \\ \"\\perp  \\ \\vdash X\"$ :} \\\\\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lllllll}\n\t\t1. & & & $\\perp$ & premise & & \\\\ \\cline{3-7}\n\t\t2. & \\multicolumn{1}{c|}{} & & $\\neg A$ & assumed & & \\multicolumn{1}{c|}{} \\\\ \n\t\t3. & \\multicolumn{1}{c|}{} &  & $\\perp$ & $copy 1$ &  & \\multicolumn{1}{c|}{} \\\\ \\cline{3-7}\n\t\t4. &  &  & $\\neg \\neg A$ & $\\neg i, 2-3$ &  & \\\\ \n\t\t5. &  &  & $A$ & $\\neg \\neg e, 4$ &  &  \\\\ \n\t\t\n\t\\end{tabular}\n\\end{table}\n\n\\section*{Answer 6}\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{lllllll}\n\t\t1. & & & $\\forall x (P(x) \\rightarrow (Q(x) \\rightarrow R(x)))$ & premise & & \\\\\n\t\t2. & & & $\\exists x P(x)$ & premise & & \\\\  \n\t\t3. & & & $\\forall x (\\neg R(x))$ & premise & & \\\\ \\cline{3-7}\n\t\t4. & \\multicolumn{1}{c|}{} &  & $P(c)$ & assumed &  & \\multicolumn{1}{c|}{} \\\\ \n\t\t5. & \\multicolumn{1}{c|}{} & & $(P(c) \\rightarrow (Q(c) \\rightarrow R(c)))$ & $\\forall e,1 $ &  & \\multicolumn{1}{c|}{} \\\\ \n\t\t6. & \\multicolumn{1}{c|}{} &  & $Q(c) \\rightarrow R(c)$ & $\\rightarrow e, 5, 4$ &  & \\multicolumn{1}{c|}{} \\\\ \n\t\t7. & \\multicolumn{1}{c|}{} &  & $\\neg R(c)$ & $\\forall e, 3$ &  & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t8. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $Q(c)$ & assumed & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t9. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $R(c)$ & $\\rightarrow e,6,8 $ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\\n\t\t10. & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} & $\\perp$ & $\\neg e, 9, 7$ & \\multicolumn{1}{c|}{} & \\multicolumn{1}{c|}{} \\\\ \\cline{4-6}\n\t\t11. & \\multicolumn{1}{c|}{} & & $\\neg Q(c)$ & $\\neg i,8-10$ & & \\multicolumn{1}{c|}{} \\\\ \n\t\t12. & \\multicolumn{1}{c|}{} & & $\\exists x (\\neg Q(x))$ & $\\exists i,11$ & & \\multicolumn{1}{c|}{} \\\\ \\cline{3-7}\n\t\t13. & & & $\\exists x (\\neg Q(x))$ & $\\exists e, 2,4-12$ & & \\\\\n\t\t\n\t\\end{tabular}\n\\end{table}\n\n\n\\end{document}\n\n​\n\n", "meta": {"hexsha": "fcc0781d0de2ca90b210e076ac7d773f88a0f808", "size": 10381, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ceng223/hw1/the1.tex", "max_stars_repo_name": "zeynepozalp/Coursework", "max_stars_repo_head_hexsha": "d2526229a757a926c311e49c7ffec995ebb9f365", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ceng223/hw1/the1.tex", "max_issues_repo_name": "zeynepozalp/Coursework", "max_issues_repo_head_hexsha": "d2526229a757a926c311e49c7ffec995ebb9f365", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ceng223/hw1/the1.tex", "max_forks_repo_name": "zeynepozalp/Coursework", "max_forks_repo_head_hexsha": "d2526229a757a926c311e49c7ffec995ebb9f365", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.6368421053, "max_line_length": 917, "alphanum_fraction": 0.5511029766, "num_tokens": 4500, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8006919925839875, "lm_q1q2_score": 0.43776886033424744}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{setspace}\n\\usepackage{pxfonts}\n\\usepackage{graphicx}\n\\usepackage{geometry}\n\n\\geometry{letterpaper,left=.5in,right=.5in,top=1in,bottom=.75in,headsep=5pt,footskip=20pt}\n\n\\title{Lecture 5 -- Extensions of the Hodgkin-Huxley model}\n\\author{Computational Neuroscience Summer Program}\n\\date{June, 2011}\n\n\\begin{document}\n\\maketitle\n\n\\paragraph{Motivation.}  The Hodgkin-Huxley model gave us a way to explicitly model ionic currents using the expected conductances of each ion and the driving forces on those ions.  We will now go one step further by explicitly simulating the stochastic actions of individual subunits of the potassium and sodium ion channels.\n\n\\paragraph{Potassium channel review.}  The potassium channel is comprised of four identical subunits.  In the Hodgkin-Huxley model, the probability that a given channel is open is equal to $p_K = n^4$, where $n$ is the probability of a single subunit being open.  Recall that $n$ increases when the cell is depolarized and decreases when the cell is hyperpolarized.  The opening rate of each subunit is $\\alpha_n$ and the closing rate is $\\beta_n$:\n\n\\[\n\\alpha_n(V) = \\frac{0.01(V + 55)}{1 - e^{-0.1(V+55)}}\n\\]\n\n\\[\n\\beta_n(V) = 0.125e^{-0.0125(V+65)}\n\\]\n\n\\paragraph{Stochastic model.}  In the stochastic model, we represent each potassium channel using a state diagram:\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{hodgkin_huxley_advanced/K_state_diagram}\n\\end{center}\n\\end{figure}\nwhere the labels represent the probability of transitioning between\neach state in the indicated direction.  We simulate a state transition\nfrom state $X$ to $Y$ during a time interval $dt$ if a random number,\nchosen with each new timestep of the simulation, is less than the\nprobability of transitioning between $X$ and $Y$.  The channel is\nconsidered to be open at time $t$ if the ion channel is in the\n5$^{th}$ state at time $t$.  In simulations, we'll need to keep track\nof how many of the ion channels are open vs. closed during each time\nstep.  As the number of channels ($N$) increases, this model becomes\narbitrarily similar to the Hodgkin-Huxley version (you'll be verifying\nthis in the problem set).  Note that you can compute $P_K$ for the\nstochastic model at time $t$ by simply computing the fraction of\nchannels that are in state 5 at time $t$.\n\n\\paragraph{Sodium channel review.}  The sodium channel is comprised of three identical subunits and an inactivation gate.  The three identical subunits each open with probability $m$ (where $m$ increases as the cell is depolarized and decreases as the cell is hyperpolarized).  The opening rates for the three subunits are $\\alpha_m$, and the closing rates are $\\beta_m$.  The inactivation gate is open with probability $h$, where $h$ decreases as the cell is depolarized and increases when the cell is hyperpolarized.  The opening and closing rates are $\\alpha_h$ and $\\beta_h$, respectively.\n\n\\[\n\\alpha_m(V) = \\frac{0.1(V+40)}{1 - e^{-.1(V+40)}}\n\\]\n\\[\n\\beta_m(V) = 4e^{-0.0556(V + 65)}\n\\]\n\n\n\\[\n\\alpha_h(V) = 0.07e^{-.05(V+65)}\n\\]\n\\[\n\\beta_n(V) = \\frac{1}{1 + e^{-.1(V+35)}}\n\\]\n\n\\paragraph{Stochastic sodium channel model.}  In the Hodgkin-Huxley model, the three subunits and the inactivation gate are assumed to be independent (that's why the probabilities are multiplied into $m^3h$).  However, this is not quite true.  A more accurate description is something like the following:\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{hodgkin_huxley_advanced/Na_state_diagram}\n\\end{center}\n\\end{figure}\n\nIn particular, the ball mechanism of the inactivation gate is located inside the cell membrane, and cannot be directly affected by potential across the membrane.  The inactivation gate only comes into play when at least one of the subunits is open (i.e., when the channel occupies states 2, 3, or 4 in the diagram).  In addition, according to this model, if the neuron is in the inactivate state (state 5), it can only transition to state 3.\n\nWhereas the transitions of the three subunits between states 1, 2, 3, and 4 in the stochastic model are identical to in the Hodgkin-Huxley model, the behavior of the inactivation gate is much different -- in particular, the inactivation gate in the stochastic model depends on the states of the three subunits.\n\nAs in the stochastic potassium channel model, you can compute the\n$P_{Na}$ for the stochastic sodium channel at time $t$ by computing\nthe fraction of sodium channels which occupy state 4 at that time.\n\n\\paragraph{Replacing the Hodgkin-Huxley channels with stochastic\n  channels.}  In the Hodgkin-Huxley model, we computed $P_K = n^4$ and\n$P_{Na} = m^3h$ with each time step, updating $n, m,$ and $h$ as we\nstepped through the model.  In the stochastic model, we compute $P_K$\nand $P_{Na}$ directly, so we no longer need to compute $n$, $m$, or\n$h$.  Other than the difference in computing $P_K$ and $P_{Na}$, the\nstochastic model is identical to the Hodgkin-Huxley model.\n\n\\paragraph{Some implementation suggestions.}  There are a number of\npossible ways to implement the stochastic channel models, with some\nmethods being more efficient than others.  Particularly when the\nnumber of channels is large, it becomes very important to code the\nsimulation efficiently (read: vectorize!) if the simulation is to\nfinish running in a reasonable amount of time.  To start you off,\nwe'll go through a simple two-state example.  The states are $x$\n(closed) and $y$ (open).  Let's suppose that the probability of\ntransitioning from state $x$ to state $y$ is $p_{xy}$ and the\nprobability of transisitioning from $y$ to $x$ is $p_{yx}$.  To\nsimulate $N = 1000$ of these simple two-state channels, we could write\nsomething like the following:\n\\newpage\n\\begin{verbatim}\ndt = 0.1;\nt = 0:dt:1000;\nstates = ones(1,N);\nn_open = zeros(size(t));\n\npOpen = [p_xy 0];\npClose = [0 p_yx];\nfor i = 1:length(t)\n  open_chooser = rand(size(states)) < (dt*pOpen(states));\n  states(open_chooser) = states(open_chooser) + 1;\n  \n  close_chooser = rand(size(states)) < (dt*pClose(states));\n  states(close_chooser) = states(close_chooser) - 1;\n  \n  n_open(i) = sum(states == 2);\nend\n\\end{verbatim}\n\nThe potasium channel simulation is identical to the above code, but\nwith the \\texttt{pOpen} and \\texttt{pClose} variables modified as in\nthe state diagram.  To implement the stochastic sodium channel model,\nyou need to seperately compute the probabilities of opening subunits and opening the inactivation gate.\n\n\\end{document}\n\n\n", "meta": {"hexsha": "563970393e8b5a4d08371333db60cabef2668af9", "size": 6538, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hodgkin_huxley_advanced/hodgkin_huxley_advanced_lecture.tex", "max_stars_repo_name": "ContextLab/computational-neuroscience", "max_stars_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2018-01-22T21:51:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T20:44:42.000Z", "max_issues_repo_path": "hodgkin_huxley_advanced/hodgkin_huxley_advanced_lecture.tex", "max_issues_repo_name": "ContextLab/computational-neuroscience", "max_issues_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-10-31T02:19:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-31T14:03:00.000Z", "max_forks_repo_path": "hodgkin_huxley_advanced/hodgkin_huxley_advanced_lecture.tex", "max_forks_repo_name": "ContextLab/computational-neuroscience", "max_forks_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-08-11T20:56:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-24T09:23:11.000Z", "avg_line_length": 50.2923076923, "max_line_length": 593, "alphanum_fraction": 0.7549709391, "num_tokens": 1781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4377590997003496}}
{"text": "\\section{2K Analysis (90 pts)\\label{sec:6}}\n\n    In this section a 2k3 analysis (2k analysis with 3 repetitions) is performed on throughput and response time for\n    experimental parameters listed in table \\ref{tab:6_setup} using single keys for GET requests. In a 2k analysis\n    factors are used as parameters to infer system behaviour. Table \\ref{tab:6_2k-factors} lists these factors and their\n    interpretation as per sign table (this approach was chosen for the 2k analysis). It is important to note that for a\n    $2^k r$ experiment with $k = 3$ (3 factors observed) and $r = 3$ (three repetitions) the data gets appropriately\n    normalized for the calculation of the q-values (multiplication by $\\tfrac{1}{2^3}$) and the sum of squares (SSQ) is\n    multiplied by $2^3 * 3$ to be able to infer the variation explained.\n\n    \\begin{table}\n        \\scriptsize{\n            \\begin{tabular}{|l|c|}\n                \\hline Number of servers                & 1 and 3 \\\\\n                \\hline Number of client machines        & 3 \\\\\n                \\hline Instances of memtier per machine & 1 (1 middleware) or 2 (2 middlewares) \\\\\n                \\hline Threads per memtier instance     & 2 (1 middleware) or 1 (2 middlewares) \\\\\n                \\hline Virtual clients per thread       & 32 \\\\\n                \\hline Workload                         & Write-only and Read-only \\\\\n                \\hline Multi-Get behavior               & N/A \\\\\n                \\hline Multi-Get size                   & N/A \\\\\n                \\hline Number of middlewares            & 1 and 2 \\\\\n                \\hline Worker threads per middleware    & 8 and 32 \\\\\n                \\hline Repetitions                      & 3 or more (at least 1 minute each) \\\\\n                \\hline\n            \\end{tabular}\n        \\caption{Experimental parameters for 2k analysis.\\label{tab:6_setup}}\n        }\n    \\end{table}\n\n    \\begin{table}\n        \\small{\n            \\begin{tabular}{r l l l }\n                \\toprule\n                Sign & Number of \\srv{}s (\\textbf{A}) & Number of \\mw{}s (\\textbf{B}) & Number of worker threads (\\textbf{C})   \\\\\n                \\midrule\n                -1  & 1                            & 1                           & 8   \\\\\n                1   & 3                            & 2                           & 32  \\\\\n                \\bottomrule\n            \\end{tabular}\n            \\caption{Sign table interpretation with respective configuration value.\\label{tab:6_2k-factors}}\n        }\n    \\end{table}\n\n    For 2k analysis two models exist, the additive and multiplicative one. Considering the factors to analyse, it\n    becomes clear that increasing \\textbf{A} and either \\textbf{B} or \\textbf{C}, an additive relationship exists\n    whereas increasing \\textbf{B} also modifies \\textbf{C} (but not necessarily vice-versa\\textemdash a\n    quasi-multiplicative relationship). A mixed model would therefore be optimal under these considerations. Looking at\n    the expected data and including the strength of the multiplicative model for expected values $y$ to exist only for\n    a large enough threshold of $\\tfrac{y_{max}}{y_{min}}$ it is reasonable to evaluate the system with an additive\n    model.\n\n    \\begin{table}\n          \\def\\sym#1{\\ifmmode^{#1}\\else\\(^{#1}\\)\\fi}%\n        \\footnotesize{\n            \\centering\n            \\begin{subfigure}[t!]{0.45\\textwidth}\n                \\centering\n                \\begin{tabular}{l*{4}{c}}\n                    \\toprule\n                    & \\multicolumn{2}{c}{Throughput}  & \\multicolumn{2}{c}{Response Time} \\\\\n                    \\cmidrule(lr){2-3}\\cmidrule(lr){4-5}\n                    & \\multicolumn{1}{c}{Effect} & \\multicolumn{1}{c}{Variation} & \n                      \\multicolumn{1}{c}{Effect} & \\multicolumn{1}{c}{Variation} \\\\\n                    \\midrule\n                    q0            & 5695 & \\textemdash & 44.1  & \\textemdash \\\\\n                    \\addlinespace\n                    qA            & 2760 & 98.24\\%     & -21.3 & 99.73\\% \\\\\n                    qB            & 173  & 0.38\\%      & -0.5  & 0.05\\% \\\\\n                    qC            & 138  & 0.25\\%      & -0.4  & 0.04\\% \\\\\n                    \\addlinespace\n                    qAB           & 175  & 0.40\\%      & -0.5  & 0.06\\% \\\\\n                    qAC           & 137  & 0.24\\%      & -0.4  & 0.04\\% \\\\\n                    qBC           & -136 & 0.24\\%      & 0.4  & 0.04\\% \\\\\n                    \\addlinespace\n                    qABC          & -136 & 0.24\\%      & 0.4   & 0.03\\% \\\\\n                    \\addlinespace\n                    Error         & \\textemdash & 0.01\\% & \\textemdash & 0.00\\% \\\\\n                    \\bottomrule\n                \\end{tabular}\n                \\caption{2k3 factors with variation for GET requests.\\label{tab:6_get-factors}}\n            \\end{subfigure}\n            \\hspace{4em}\n            \\begin{subfigure}[t!]{0.45\\textwidth}\n                \\centering\n                \\begin{tabular}{l*{4}{c}}\n                    \\toprule\n                    & \\multicolumn{2}{c}{Throughput}  & \\multicolumn{2}{c}{Response Time} \\\\\n                    \\cmidrule(lr){2-3}\\cmidrule(lr){4-5}\n                    & \\multicolumn{1}{c}{Effect} & \\multicolumn{1}{c}{Variation} & \n                      \\multicolumn{1}{c}{Effect} & \\multicolumn{1}{c}{Variation} \\\\\n                    \\midrule\n                    q0            & 7775 & \\textemdash & 26.4 & \\textemdash \\\\\n                    \\addlinespace\n                    qA            & -574 & 7.87\\%      & 2.1  & 9.55\\% \\\\\n                    qB            & 1149 & 31.56\\%     & -3.9 & 32.81\\%\\\\\n                    qC            & 1530 & 55.93\\%     & -5.0 & 54.85\\% \\\\\n                    \\addlinespace\n                    qAB           & 171  & 0.70\\%      & -1.0 & 2.41\\% \\\\\n                    qAC           & -177 & 0.75\\%      & -0.0 & 0.00\\% \\\\\n                    qBC           & 341  & 2.77\\%      & 0.3  & 0.17\\% \\\\\n                    \\addlinespace\n                    qABC          & 115  & 0.32\\%      & -0.2 & 0.11\\% \\\\\n                    \\addlinespace\n                    Error         & \\textemdash & 0.09\\% & \\textemdash & 0.10\\% \\\\\n                    \\bottomrule\n                \\end{tabular}\n                \\caption{2k3 factors with variation for SET requests.\\label{tab:6_set-factors}}\n            \\end{subfigure}\n        \\caption{2k3 factor analysis summaries for GET and SET requests. Numbers are rounded for throughput to integers,\n                 for latency to a single decimal.\\label{tab:6_factor-analysis}}\n        \\vspace*{-0.75\\baselineskip}\n        }\n    \\end{table}\n\n    In the case of GET packets the factor \\textbf{A} is with nearly 100\\% variational effect for throughput and\n    response time the only relevant factor in determining the system behaviour. Of interesting note is the switch in\n    sign yet including the interpretation that high throughput implies low response times it becomes apparent why a\n    change in sign must happen for corresponding factors. As previously observed we see for three \\cli{}s and one\n    \\srv{} immediately a saturation point and the middleware has no measurable effect, either good or bad on the\n    system performance for GET. This matches the results observed. Visualizing the residuals (Figure\n    \\ref{fig:6_r_get_tp}) and doing a QQ plot (figure \\ref{fig:6_qq_get_tp}) of the measured data for the\n    throughput and response time (the latter omitted for behaving similar to the former) shows very consistent\n    behaviour at either ends of the request throughputs on the residual plot. A few outliers are observed but these\n    cannot be ruled out in a cloud environment. The QQ plot has a very shallow line in the center where the highest\n    likelihood of an observation is for a standard distribution. Both of these plots show an insufficient model\n    according to the book referenced in the lecture (Box 18.1) and a multiplicative model is recommended to be observed.\n    After evaluating that model no reasonable gains were able to be found and the resulting plots are apart from a change\n    of axis labels very similar. Even though the results indicate problems, when including the real system behaviour,\n    both numbers make sense and are not only verified by the 2k3 analysis but also empirically to correlate.\n\n    In the case of SET requests a mixture of factors \\textbf{C} and \\textbf{B} shows to be mostly significant with\n    around 55.9\\%/54.9\\% and 31.6\\%/32.8\\% for throughput and response time respectively. Of minor significance yet\n    measurable are \\textbf{A} with around 7.8\\%/9.6\\% for throughput and response time and \\textbf{BC} for\n    throughput with 2.8\\% (which interprets as increasing the number of \\mw{}s and worker threads simultaneously).\n    The change in sign occurs again correctly. The analysis aligns with previous observations and conclusions while\n    bringing up the hypothesis that worker threads result in a larger gain in performance compared to adding more\n    \\mw{}s. The hypothesis seems to not hold though as in Experiment 3 we expect for the case of two \\mw{}s and 16\n    worker threads less performance than for one \\mw{} and 32 worker threads. This is clearly not the case and as\n    such the belief is the model is unable to correctly differentiate between these two parameters (assuming both\n    \\mw{}s have the exact same throughput and response time behaviour). The factor \\textbf{A}, adding more \\srv{}s to\n    the system, does align with results from experiments \\ref{sec:3} and \\ref{sec:4} where the number of \\srv{}s changes\n    from one to three and a decrease in throughput is observed. The factor proposes an increase in \\srv{}s introduces a\n    negative effect as the \\mw{} is designed to share the SET operation with each \\srv{} in the system. This key\n    distribution introduces additional latencies into the system. Again residual (figure \\ref{fig:6_r_set_tp}) and QQ\n    plots (figure \\ref{fig:6_qq_set_tp}) were created but only the throughput ones are presented (similar behaviour in\n    either case). The residuals are scattered without anything being possible to interpret and the QQ plot shows a\n    quasi-linear behaviour. Both great signs according to the book as the residual error must be IID and small (it is\n    smaller by a magnitude than the x-labels) and the distribution of errors being uniform at random. As such the model\n    should be good enough to describe system performance per the book. Given empirical data the trend is clearly visible\n    and overlaps but the strength of individual components is questioned to be correct.\n\n    \\begin{figure*}\n        \\vspace*{-.5\\baselineskip}\n            \\centering\n        \\begin{subfigure}[t!]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{../data_analysis/figures/6-0_throughput-set-residual.png}\n            \\caption{Residual plot for SET Throughput.\\label{fig:6_r_set_tp}}\n            \\includegraphics[width=\\textwidth]{../data_analysis/figures/6-0_throughput-get-residual.png}\n            \\caption{Residual plot for GET Throughput.\\label{fig:6_r_get_tp}}\n        \\end{subfigure}\n        \\begin{subfigure}[t!]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{../data_analysis/figures/6-0_throughput-set-qq.png}\n            \\caption{QQ-Plot for SET Throughput.\\label{fig:6_qq_set_tp}}\n            \\includegraphics[width=\\textwidth]{../data_analysis/figures/6-0_throughput-get-qq.png}\n            \\caption{QQ-Plot for GET Throughput.\\label{fig:6_qq_get_tp}}\n        \\end{subfigure}\n        \\caption{Residual and QQ plots based on memtier measurements for experiment 6.0. Only throughput plots\n                 are depicted.\\label{fig:6_tp}}\n    \\end{figure*}\n", "meta": {"hexsha": "46afbaf78bb20c9204e88abd0ad4fd838cbd909c", "size": 11789, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/06_2k-analysis.tex", "max_stars_repo_name": "mvaenskae/asl2018", "max_stars_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/06_2k-analysis.tex", "max_issues_repo_name": "mvaenskae/asl2018", "max_issues_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/06_2k-analysis.tex", "max_forks_repo_name": "mvaenskae/asl2018", "max_forks_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.1445086705, "max_line_length": 130, "alphanum_fraction": 0.5941131563, "num_tokens": 3047, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.43775909510544125}}
{"text": "% !TEX root = ../ms.tex\n\n\\defmath\\B{\\mathbb B}\n\n\\vspace{-1em}\n\\section{Introduction~\\label{sec:introduction}}\n\n%The simulation of quantum computing circuits is important for studying noise, synthesizing and optimizing circuits and \n\nClassical simulation of quantum computing is useful for circuit design~\\cite{zulehner2017one} and studying noise resilience in the era of Noisy Intermediate-Scale Quantum (NISQ) computers~\\cite{preskill2018quantum}.\nMoreover, identifying classes of quantum circuits that are classically simulatable, helps in excluding regions where a quantum computational advantage cannot be obtained.\nFor example, circuits containing only Clifford gates (a non-universal quantum gate set), using an all-zero initial state, only compute the so-called `stabilizer states' and can be simulated in polynomial time\n\\cite{gottesman1998heisenberg,aaronson2008improved,gottesman1997stabilizer}.\n%Stabilizer states arise when computing using only Clifford gates (a non-universal quantum gate set), and\nStabilizer states, and associated formalisms for expressing them, are fundamental to many quantum error correcting codes~\\cite{gottesman1997stabilizer} and play a role in measurement-based quantum computation~\\cite{raussendorf2001oneway}.\n% circuit limited to the Clifford gate set stay in a tractable region of the so-called stabilizer states , which forms the basis for measurement-based quantum computation~\\cite{raussendorf2001oneway} and many quantum error correction codes.\nIn fact, simulation of general quantum circuits is fixed-parameter tractable in the number of non-Clifford gates~\\cite{bravyi2016trading}, a principle on which many modern simulators are based~\\cite{bravyi2016trading,bravyi2017improved,bravyi2019simulation, huang2019approximate,kocia2018stationary,kocia2020improved}.\n\n\\begin{wrapfigure}{R}{.35\\textwidth}\\vspace{-1.5em}\n\t\\includegraphics[width=.24\\textwidth]{pics/venn-diagram.pdf}\n    \\centering\n    \\vspace{-1em}\n\t\\caption{\n        The set of stabilizer states and states represented as:\n        poly-sized \\limdds and QMDDs.\n        \\vspace{-\\baselineskip}\n\t}%\\vspace{-.5em}\n    \\label{fig:venn-diagram} \n\\end{wrapfigure}\n\nAnother method for simulating universal quantum computation is based on (algebraic) decision diagrams (DDs)~\\cite{akers1978binary,bryant86,580054,bryant1995verification,sanner,10.1145/157485.164569,fujita1997multi,viamontes2003improving,viamontes2004high,miller2006qmdd,zulehner2018advanced}.\nA DD is a directed acyclic graph (DAG) in which each path represents a quantum amplitude, enabling the succinct representation of many quantum states through the combinatorial nature of these paths.\nVarious manipulation operations for DDs exist which implement any quantum gate operation in polynomial time\nin the size of the DD. Together with other DD operations that can be used for measurement,\nstrong simulation is easily implemented using a DD data structure~\\cite{miller2006qmdd,zulehner2018advanced}.\nIndeed, DD-based simulation was empirically shown to be competitive with state-of-the-art simulators~\\cite{viamontes2004high,zulehner2018advanced} and is used in several simulator implementations~\\cite{viamontes2009quantum}.\n%\\todo{Vedran: at-the time? I mean, simulators have advanced a lot since 2018... As I mentioned they simulated shor on 60 qubits. good luck with that in any other method.}.\nDDs and the stabilizer formalism are introduced in \\autoref{sec:preliminaries}.\n%However, in contrast to the stabilizer formalism, little is known about which quantum circuits are efficiently simulatable with DD-based approaches.\n\n\nIn this paper, we show that certain stabilizer states, called cluster states \\cite{briegel2000persistent}, yield exponentially large \\qmdds, the currently most succinct version of DDs\n(see \\autoref{sec:exponential-separations}).\nIn order to unite the strengths of DDs and the stabilizer formalism,\nin \\autoref{sec:isomorphism-qmdd}, we propose \\limdd: a new DD for quantum computing simulation using local invertible maps (LIMs).\nSpecifically, \\limdds eliminate the need to store multiple states which are equivalent up to LIMs, allowing more succinct DD representations.\n%\\todo{Tim: please check, it might sound a bit like \\limdds only can encode stabilizer states now}\nWe prove that the set of quantum states that can be \\emph{represented} by poly-sized \\limdds \nis larger than those that can be expressed in either the stabilizer formalism or a poly-sized \\qmdd.\n\\autoref{fig:venn-diagram} shows the resulting separation.\nIn \\autoref{sec:quantum-simulation}, we give procedures for analyzing and simulating quantum \ncircuits using \\limdds and conclude in \\autoref{sec:discussion} with evidence that \\limdd-based simulation can be powerful than modern techniques using low-rank stabilizer decomposition~\\cite{bravyi2019simulation}.\n\nThe workhorse behind \\limdds is a novel algorithm which merges two DD nodes when they are `isomorphic:'\nTwo quantum states $\\ket{\\phi}$ and $\\ket{\\psi}$ are isomorphic when there is a series of Pauli operators $P_j$ and a complex nonzero number $\\lambda$ such that $\\ket{\\phi}=\\lambda P_n\\otimes\\cdots\\otimes P_1\\ket \\psi$.\nThere is a plethora of work on investigating the effect of similar local operations in the context of stabilizer states \\cite{nest2005local, englbrecht2020symmetries}; we emphasize that here we consider arbitrary quantum states $\\ket{\\phi}, \\ket{\\psi}$.%\\todo{Tim: should rephrase, now it looks like no-one ever thought of considering locally-equivalent states beyond stabilizer states...}\nTo find such an isomorphism, we compute (generators of) the stabilizer (sub)group $\\Stab(\\ket \\psi)$ of the state $\\ket \\psi$ represented by each DD node, and then we exploit the fact that the set of all such isomorphisms can be expressed as the coset $\\pi\\cdot \\Stab(\\ket \\psi)$ for some isomorphism $\\pi$.\nTo make the diagram canonical ---an important property for realizing efficient manipulation operations~\\cite{darwiche2002knowledge}---\nour algorithm then chooses a ``lexicographically smallest'' element from a Pauli coset.\n\n%\\todo[inline]{Vedran: general comment: i am a bit worried that nothing about efficiency of algorithms for all the manipulations is said for such a long time... I lose the connection to simulation of circuits... The Introduction for me is missing a link and clarification of the relationship between representation and simulation.\"}\n\n\n%\\todo[inline]{Give another / better example of polytime simulatable QC; introduce stabilizer states before they are mentioned.}\n\n%\\todo[inline]{Process Vedran's feedback, so write something about Clifford gates that's actually true.}\n\n%This work is organized as follows.\n%After providing the necessary background in \\autoref{sec:preliminaries}, we formally introduce \\limdds in \\autoref{sec:isomorphism-qmdd}.\n%In \\autoref{sec:exponential-separations}, we prove the exponential separation between QMDDs and \\limdds, by showing that there is a sequence of $n$-qubit stabilizer states that can only be represented with exponentially-sized QMDDs.\n\n\n\n\n\n\n", "meta": {"hexsha": "26977bebe71851c3008c069a0cf2e51962473aa5", "size": 7068, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Src/CS/sections/introduction.tex", "max_stars_repo_name": "Katafotic/latex_parsing", "max_stars_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Src/CS/sections/introduction.tex", "max_issues_repo_name": "Katafotic/latex_parsing", "max_issues_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Src/CS/sections/introduction.tex", "max_forks_repo_name": "Katafotic/latex_parsing", "max_forks_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.7922077922, "max_line_length": 389, "alphanum_fraction": 0.8048953028, "num_tokens": 1732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4376435626062647}}
{"text": "\\documentclass[pdf]{beamer}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{tcolorbox}\n\\usepackage[all]{xy}\n\n\\mode<presentation>{}\n\n% ------------------------------------------------------------------------------\n% Theme\n\n\\usetheme[usetitleprogressbar, nosmallcapitals, usetotalslideindicator]{m}\n\n\\lstloadlanguages{Haskell}\n\\lstnewenvironment{code}\n    {\\lstset{}%\n      \\csname lst@SetFirstLabel\\endcsname}\n    {\\csname lst@SaveFirstLabel\\endcsname}\n    \\lstset{\n      basicstyle=\\ttfamily\\footnotesize,\n      flexiblecolumns=false,\n      basewidth={0.5em,0.45em},\n      literate={+}{{$+$}}1 {/}{{$/$}}1 {*}{{$*$}}1\n               {\\\\\\\\}{{\\char`\\\\\\char`\\\\}}1\n               {=>}{{$\\Rightarrow$}}2\n               {forall}{{$\\forall$}}2\n               {->}{{$\\rightarrow$}}2\n               {<-}{{$\\leftarrow$}}2\n               {>>}{{>>}}3 {>>=}{{>>=}}3,\n      commentstyle={\\ttfamily\\color{gray}},\n      language=haskell\n    }\n    \n% ------------------------------------------------------------------------------\n% Presentation\n\n\\title{Give me freedom!}\n\\subtitle{Or let me forget}\n\\date{\\today}\n\\author{Joseph Tel Abrahamson}\n\n\\renewcommand{\\to}{\\ensuremath{\\rightarrow}}\n\\DeclareMathOperator{\\Free}{\\texttt{Free}}\n\\DeclareMathOperator{\\Forget}{\\texttt{Forget}}\n\\DeclareMathOperator{\\Monad}{\\texttt{Monad}}\n\\DeclareMathOperator{\\Functor}{\\texttt{Functor}}\n\\DeclareMathOperator{\\ty}{\\texttt{ :: }}\n\n\\begin{document}\n\n\n\\maketitle\n\n\\begin{frame}\n  \\frametitle{Synopsis}\n  \\begin{itemize}\n  \\item Freedom: a \\textit{noun}, no an \\textit{adjective}, no a \\textit{verb}!\n  \\item Knowing about Freedom by Forgetting what we know\n  \\item Putting Forgetfulness to work\n  \\end{itemize}\n\\end{frame}\n\n\\section{\\texttt{Free} is a noun}\n\n\\begin{frame}[fragile]\n  \\frametitle{The \\texttt{Free} monad}\n\\begin{lstlisting}\ndata Free f a\n  = Return a\n  | Free (f (Free f a))\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Construction and destruction}\n\n  \\begin{itemize}\n  \\item<1> When \\texttt{f} is a \\texttt{Functor}, \\texttt{Free f} is a\n    \\texttt{Monad}\n  \\item<2> For any value \\texttt{x :: f a} we have \\texttt{lift x :: Free f a}\n  \\item<3> For any \n    \\begin{enumerate}\n    \\item \\texttt{Monad} \\texttt{m} and\n    \\item \\textit{interpretation} of \\texttt{f} into \\texttt{m}, \\texttt{phi ::\n        forall x. f x -> m x},\n    \\end{enumerate}\n    we have \\texttt{fold phi :: forall a . Free f a -> m a}.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{e.g.}\n\\begin{lstlisting}\nlift :: Functor f => f a -> Free f a\nfold :: Monad m => (forall x . f x -> m x) -> (forall x . Free f x -> m x)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Very nice embedded DSLs... for \\textit{less}!}\n\\begin{lstlisting}\ndata TeletypeF a \n  = PutStrLn String a \n  | GetLine (String -> a)\n    deriving ( Functor )\n                     \ntype Teletype = Free TeletypeF\n\nputStrLnTT :: String -> Teletype ()\nputStrLnTT line = lift (PutStrLn line ())\n\ngetLineTT :: Teletype String\ngetLineTT = lift (GetLine id)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Very nice embedded DSLs... for \\textit{less}!}\n\\begin{lstlisting}\nechoTT :: Teletype ()\nechoTT = forever $ do\n  line <- getLineTT\n  putStrLineTT line\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Very nice embedded DSLs... for \\textit{less}!}\n\\begin{lstlisting}\ninterp :: TeletypeF a -> IO a\ninterp x = case x of\n  PutStrLn line a -> putStrLn line >> return a\n  GetLine next -> do\n    line <- getLine\n    return (next line)\n\nechoIO :: IO ()\nechoIO = fold interp echoTT\n\\end{lstlisting}\n\\end{frame}\n\n\\section{Free is an adjective}\n\n\\begin{frame}\n  \\begin{center}\n    \\texttt{Free}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Other Freedoms we have}\n  \\begin{enumerate}\n  \\pause\\item Free \\texttt{Monad}s\n  \\pause\\item Free \\texttt{MonadPlus}es\n  \\pause\\item Free \\texttt{Applicative}s\n  \\pause\\item Free \\texttt{Alternative}s\n  \\pause\\item Free \\texttt{Monoid}s (``lists'')\n  \\pause\\item Free \\texttt{Category}s\n  \\pause\\item ...\n  \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{What does it mean to be free?}\n  \\pause\n\n  \\textit{This is the wrong question!}\n\\end{frame}\n\n\\section{Free is a verb}\n\n\\begin{frame}[fragile]\n  \\frametitle{What is \\texttt{Free}, really?}\n  \n  \\uncover<3->{But really more like...}\n\n  \\begin{align*}\n    & \\action<+->{\\mathtt{>}\\ \\mathtt{:kind}\\ \\Free_{\\Monad}} \\\\\n    & \\action<+->{\n        \\Free_{\\Monad} \\ty \n          (\\star \\to \\star)_{\\uncover<3->{\\Functor}} \\to\n          (\\star \\to \\star)_{\\uncover<3->{\\Monad}}\n      }\n  \\end{align*}\n  \n\\pause\n\n\\begin{tcolorbox}[boxrule=0pt, arc=0pt, outer arc=0pt]\n\\begin{lstlisting}\n-- remember...\ninstance Functor f => Monad (Free f)\n\\end{lstlisting}\n\\end{tcolorbox}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Freedom is a process}\n\n\\begin{lstlisting}\ndata IsAFunctor f\n  = IsAFunctor \n    { fmap :: forall a b . (a -> b) -> (f a -> f b) \n    }\n\ndata IsAMonad f\n  = IsAMonad\n    { return :: forall a   . a -> f a\n    , bind   :: forall a b . (a -> f b) -> (f a -> f b)\n    }\n\nfree :: IsAFunctor f -> IsAMonad (Free f)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Other ``Freedoms'' we have}\n  \\begin{enumerate}\n  \\item Free \\texttt{Monad}s\n  \\item Free \\texttt{MonadPlus}es\n  \\item Free \\texttt{Applicative}s\n  \\item Free \\texttt{Alternative}s\n  \\item Free \\texttt{Monoid}s\n  \\item Free \\texttt{Category}s\n  \\end{enumerate}\n  \n  \\pause\n\n  All \\textit{underdefined}. Freedom goes from a source to a target!\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{A picture of ``Free monads\"}\n  \\begin{description}\n  \\item[$\\Free_{\\Monad}$] \n    \\begin{displaymath}\n      \\mathtt{Functor}\\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Monad}\n    \\end{displaymath}\n  \\pause\n  \\item[$\\mathtt{List}$]\n    \\begin{displaymath}\n      \\mathtt{Hask}\\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Monoid}\n    \\end{displaymath}\n  \\pause\n  \\item[$\\mathtt{Coyoneda}$] \n    \\begin{displaymath}\n      \\mathtt{Hask}_{(\\star\\to\\star)} \\xymatrix{\\bullet \\ar[r]^{\\Free} & \\bullet}\\mathtt{Functor}\n    \\end{displaymath}\n  \\end{description}\n  \n\\end{frame}\n\n\\section{Gaining Freedom and Forgetting it all}\n\n\\begin{frame}\n  \\begin{center}\n    \\begin{displaymath}\n      \\mathtt{Functor}\n      \\xymatrix{\n        \\bullet \\ar@/^/[r]^{\\Free} & \n        \\bullet\n      }\n      \\mathtt{Monad}\n    \\end{displaymath}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{center}\n    \\begin{displaymath}\n      \\mathtt{Functor}\n      \\xymatrix{\n        \\bullet \\ar@/^/[r]^{\\Free} & \n        \\bullet \\ar@/^/[l]^{\\Forget}\n      }\n      \\mathtt{Monad}\n    \\end{displaymath}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{It's easy to forget}\n  \\begin{align*}\n    \\Forget_{\\Monad} \\ty \n        (\\star \\to \\star)_{{\\Monad}} \\to\n        (\\star \\to \\star)_{{\\Functor}}\n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\begin{lstlisting}\ntype Forget f a = f a\n\nforget :: IsAMonad f -> IsAFunctor (Forget f)\nforget (IsAMonad { bind, return }) = IsAFunctor fmap where\n  fmap f = bind (return . f)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Too much to ask for}\n  \\begin{align*}\n    (\\Free \\circ \\Forget)(M) &\\neq M \\\\\n    (\\Forget \\circ \\Free)(F) &\\neq F\n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Just right}\n  If\n  \\begin{flalign*}\n    M = \\Free(F)\n  \\end{flalign*}\n  for some \\texttt{Functor} $F$, then\n  \\begin{flalign*}\n    (\\Free \\circ \\Forget)(M) = M\n  \\end{flalign*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Just right}\n  If\n  \\begin{flalign*}\n    F = \\Forget(M)\n  \\end{flalign*}\n  for some \\texttt{Monad} $M$, then\n  \\begin{flalign*}\n    (\\Forget \\circ \\Free)(F) = F\n  \\end{flalign*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Adjunctions}\n  \\begin{align*}\n    F \\circ G \\circ F &= Id \\\\\n    G \\circ F \\circ G &= Id \n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Adjunctions}\n  \n\\end{frame}\n\n\\end{document}\n\n%%% Local Variables: \n%%% coding: utf-8\n%%% mode: latex\n%%% TeX-engine: xetex\n%%% End: ", "meta": {"hexsha": "aa3e888b1139da3f0aa7f0bcfbb8843dc6567603", "size": 8086, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "speakers/tel/freedom.tex", "max_stars_repo_name": "jamondouglas/lamdaconf2015", "max_stars_repo_head_hexsha": "8363906b10285f78448387ee067fc81542dc9ea1", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "speakers/tel/freedom.tex", "max_issues_repo_name": "jamondouglas/lamdaconf2015", "max_issues_repo_head_hexsha": "8363906b10285f78448387ee067fc81542dc9ea1", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "speakers/tel/freedom.tex", "max_forks_repo_name": "jamondouglas/lamdaconf2015", "max_forks_repo_head_hexsha": "8363906b10285f78448387ee067fc81542dc9ea1", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.9715909091, "max_line_length": 97, "alphanum_fraction": 0.6166213208, "num_tokens": 2757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4376435626062647}}
{"text": "\\section{Grand Unification and SUSY}\n\n\\begin{frame}{Gauge Couplings in the Standard Model}\n\\addtocounter{framenumber}{-1}\nThe Standard Model is described as the most general renormalizable \tfield theory with gauge group \n\\begin{equation*}\n\t\\mathcal{G}_{\\mathrm{SM}} = \\mathrm{SU}(3) \\times \\mathrm{SU}(2) \\times \\mathrm{U}(1),\n\\end{equation*}\nwith  associated gauge couplings $\\alpha_3$, $\\alpha_2$ and $\\alpha_1$,\nthree generations of fermions and a scalar \\cite{Hebecker2020}. \\\\[2em]\n\\begin{itemize}\n\\item The couplings are larger for the larger component of the gauge group, i.\\,e. \\begin{equation*}\n\t\\alpha_3(m_Z) > \\alpha_2(m_Z) > \\alpha_1(m_Z)\n\t\\end{equation*}\n\t\\item Interesting observation: Values of the running couplings come close together at some high energy scale $\\Lambda_{\\mathrm{GUT}} \\sim 10^{16}\\ \\mathrm{GeV}$ (cf. next slide).\\\\[1em]\n\t\\item \\alert{\\textsc{Georgi-Glashow}} \\cite{GeorgiGlashow1974}: Embed $\\mathcal{G}_{\\mathrm{SM}}$ in larger gauge group, i.\\,e. $\\operatorname{SU}(5) \\implies \\mathrm{GUT?}$  \n \\end{itemize}\n \\end{frame}\n\n\\begin{frame}{One Loop Running of the SM Gauge Couplings I}\n\t\\begin{figure}\n\t\\centering\n\t\\includegraphics[scale = 0.6]{figures/dgut-1}%\\hspace{3em}\n\t\\caption{Running of the (inverse) SM gauge couplings, plot inspired by \\cite{Kazakov2000}.}\n\t\\end{figure}\n\\end{frame}\n\n\\begin{frame}{One Loop Running of the SM Gauge Couplings II}\n\t\\begin{itemize}\n\t\t\t\\item In the Georgi-Glashow model, we need $-\\mu^2 \\sim -(100\\ \\mathrm{GeV})^2$ to reproduce the correct $W$ and $Z$ masses $\\implies$ \\alert{Gauge hierarchy problem!} \\cite{PeskinSchroeder1995}\\\\[1em]\n\t\t\\item SUSY provides way out: If SUSY breaking works such that the mass differences between the superpartners are large enough, one can reproduce the correct Higgs mass $\\implies$ superpartners influence the running of the (MS)SM gauge couplings (cf. next slide)\n\t\\end{itemize}\n\\begin{figure}\n\t\\centering\n\t\\includegraphics{figures/running_diagrams.pdf}\n\t\\begin{itemize}\n\t\t\\item In the end it remains a complicated \\alert{fine tuning} task!\n\t\\end{itemize}\n\n\t\\end{figure}\t\n\n\\end{frame}\n\n\n\\begin{frame}{Comparison: SM vs. MSSM}\n\t\\begin{figure}\n\t\\begin{subfigure}\n\t\t\\centering\n\t\\includegraphics[scale = 0.55]{figures/dgut-1}\n\t\\end{subfigure}\n\t\\begin{subfigure}\n\t\t\\centering\n\t\\includegraphics[scale = 0.55]{figures/dgut-2}\n\t\\end{subfigure}\n\n\t\\caption{Running of the (inverse) gauge couplings in the SM and the MSSM, plots inspired by \\cite{Kazakov2000}.}\n\t\\end{figure}\n\\end{frame}\n\n", "meta": {"hexsha": "cfb1aa3466b2afcfee29866507e0ffb479977ec5", "size": 2490, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "talk_mathieu/content/03_unification.tex", "max_stars_repo_name": "mathieukaltschmidt/SUSY", "max_stars_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "talk_mathieu/content/03_unification.tex", "max_issues_repo_name": "mathieukaltschmidt/SUSY", "max_issues_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "talk_mathieu/content/03_unification.tex", "max_forks_repo_name": "mathieukaltschmidt/SUSY", "max_forks_repo_head_hexsha": "038c8564a27a1925e738595a8e39857dbc39e082", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5, "max_line_length": 263, "alphanum_fraction": 0.7321285141, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4376435626062647}}
{"text": "\\chapter{Introduction}\n\\label{chap:intro}\n\nThe major goal of this line of research is to develop\nhigh order, numerically stable fast algorithms for solving elliptic\npartial differential equations using the Minimum Sobolev norm (MSN).\nThis will require much more work than can be completed in one dissertation.\nThe present work focuses on developing fast algorithms to solve interpolation\nand ordinary differential equation problems using the MSN method,\nwhich will be a stepping stone to understand the\nstructure of the matrices arising in 2D and 3D PDEs.\nWe introduce these ideas by discussing some of the problems\npresent in interpolation methods and how the MSN method\nattempts to solve them.\n\n\n\n\\section{Lagrange Interpolation and Known Difficulties}\n\\label{sec:int_class_interp}\n\nThe well-known Weierstrass Approximation Theorem, which we reproduce for\ncompleteness, says continuous functions on compact, connected intervals can\nbe approximated arbitrarily well by polynomials:\n\n\\begin{thm}[Weierstrass Approximation Theorem;\n    Theorem 7.26 in \\cite{baby_rudin}]\n\\label{thm:WeierstrassThm}\nIf $f\\in C[a,b]$, then there exists a sequence\nof polynomials $\\braces{P_{n}}_{n=1}^{\\infty}$ such that\n\n\\begin{equation}\n    \\lim_{n\\to\\infty} \\norm{f-P_{n}}_{\\infty,[a,b]} = 0.\n\\end{equation}\n\\end{thm}\n\n\\noindent\nHere,\n\n\\begin{equation}\n    \\norm{g}_{\\infty,[a,b]} \\equiv \\sup_{x\\in\\brackets{a,b}} \\abs{g(x)}\n\\end{equation}\n\n\\noindent\nis the supremum norm.\nWhen the interval $\\brackets{a,b}$ is understood, we may\nwrite $\\norm{\\cdot}_{\\infty}$ in place of $\\norm{\\cdot}_{\\infty,[a,b]}$.\nThis theorem shows that the set of polynomials $\\mathcal{P}$\nis dense in $C[a,b]$, the space of continuous functions on $[a,b]$.\nWe let $\\mathcal{P}_{n}$ denote all polynomials of degree at most $n$.\nThis gives rise to an important concept: degree of\napproximation.\nWe also have the following theorem:\n\n\\begin{thm}[Best Uniform Approximation of Continuous Functions;\n    Section 1.1 in~\\cite{rivlin2003introduction}]\nIf $f\\in C[a,b]$ and $n\\in\\N_{0}$, then there exists\na unique $q_{n}\\in\\mathcal{P}_{n}$ so that\n%\n\\begin{equation}\n    \\norm{f-q_{n}}_{\\infty} = \\inf_{p\\in\\mathcal{P}_{n}}\\norm{f-p}_{\\infty}.\n\\end{equation}\n%\nWe set\n%\n\\begin{equation}\n    E_{n}(f) \\equiv \\inf_{p\\in\\mathcal{P}_{n}}\\norm{f-p}_{\\infty}\n\\end{equation}\n%\nand have\n%\n\\begin{equation}\n    E_{0}(f)\\ge E_{1}(f)\\ge E_{2}(f) \\ge \\cdots \\to 0.\n\\end{equation}\n\\end{thm}\n\nThere are many ways to prove the Weierstrass Approximation theorem.\nIn~\\cite[Chapter 7]{baby_rudin}, Rudin convolves against a polynomial kernel.\nThis is useful theoretically but in practice, one may only\nhave function and derivative information at particular points.\nIn order to reconstruct the underlying function, we want to use\nthese function and derivative values to build an approximation,\nfrequently chosen to be a polynomial.\nThis is interpolation.\n\n\\textbf{Interpolation Problem:} Let $f\\in C[-1,1]$ be continuous\nand specify a sequence of grid points\n\n\\begin{equation}\n    -1\\le x_{1;n} < x_{2;n} < \\cdots < x_{n;n}\\le1.\n\\end{equation}\n\n\\noindent\nfor $n\\in\\N$.\nDetermine a polynomial $p_{n}$ with $\\deg p_{n} = m(n)$\nwhich satisfies the conditions\n\n\\begin{equation}\n    f(x_{k;n}) = p_{n}(x_{k;n}),\n\\end{equation}\n\n\\noindent\nand ascertain under what restrictions on $f$ and $\\braces{x_{k;n}}_{k=1}^{n}$\nensure\n\n\\begin{equation}\n    \\norm{f-p_{n}}_{\\infty} \\to0,\\quad n\\to\\infty.\n\\end{equation}\n\nA popular choice is to set $m(n) = n-1$, resulting in Lagrange\ninterpolation.\nIn Fig.~\\ref{fig:intro_runge_plot}, we see an example of Lagrange\ninterpolation on equally-spaced nodes of the Runge function\n$\\brackets{1+25x^{2}}^{-1}$ on $[-1,1]$.\nThis function is analytic; even so, in~\\cite{runge1901} Runge\nproved that Lagrange interpolation diverges in this case.\nIn particular, there are large oscillations near the boundary points.\n\n% Plot of Runge phenomenon\n\\input{plots/runge_figure.tex}\n\nIn fact, much more is known about Lagrange interpolation,\nand we introduce notation which will make this discussion easier.\nLet\n\n\\begin{equation}\n    X = \\braces{x_{k;n} \\mid k=1,\\cdots,n; n\\in\\N}\n\\end{equation}\n\n\\noindent\nbe an interpolatory matrix. Then, given $f\\in C[-1,1]$,\nwe have the following standard\ndefinitions~\\cite[Chapter 1]{interpFunctionsBook}:\n\n\\begin{samepage}\n\\begin{align}\n    L_{n}(f,X,x) &= \\sum_{k=1}^{n}\\ell_{k,n}(X,x)f(x_{k;n}) \\nonumber\\\\\n    \\Omega_{n}(X,x) &= \\prod_{i=1}^{n}\\parens{x-x_{i;n}}\n        \\nonumber\\\\\n    \\ell_{k,n}(X,x) &= \\frac{\\Omega_{n}(X,x)}{\\Omega_{n}'(X,x_{k;n})(x-x_{k;n})}\n        \\nonumber\\\\\n    \\lambda_{n}(X,x) &= \\sum_{k=1}^{n}\\abs{\\ell_{k,n}(X,x)} \\nonumber\\\\\n    \\Lambda_{n}(X) &= \\norm{\\lambda_{n}(X,x)}_{\\infty,[-1,1]}.\n\\end{align}\n\\end{samepage}\n\n\\noindent\nNaturally, $L_{n}(f,X,x)$ is the Lagrange interpolating polynomial\nof degree at most $n-1$ for the interpolation matrix $X$.\nThe Lebesgue constants $\\Lambda_{n}(X)$ are of\ncritical importance, as we see\n\n\\begin{align}\n    \\abs{L_{n}(f,X,x) - f(x)} &\\le \\abs{L_{n}(f,X,x) - q_{n-1}(x)}\n            + \\abs{f(x) - q_{n-1}(x)} \\nonumber\\\\\n    &\\le \\abs{L_{n}(f-q_{n-1},X,x)} + E_{n-1}(f) \\nonumber\\\\\n    &\\le \\brackets{\\Lambda_{n}(X)+1}E_{n-1}(f).\n    \\label{eq:Ln_upper_bound_err}\n\\end{align}\n\n\\noindent\nHere, $q_{n-1}\\in\\mathcal{P}_{n-1}$ is the minimizer in the supremum norm,\nand we note $L_{n}:\\mathcal{P}_{n-1}\\to\\mathcal{P}_{n-1}$ is the identity map.\nBecause $E_{n}(f)\\to0$, Lagrange interpolation converges when\n$\\Lambda_{n}(X)E_{n-1}(f)\\to0$.\n\nIf we could find an interpolatory matrix $Y$ so that $\\Lambda_{n}(Y)$ is\nbounded, then $L_{n}(f,Y)\\to f$ uniformly. Unfortunately, this is not\nthe case. In~\\cite{vertesi1990optimal}, V\\'{e}rtesi references Faber (1914)\nas proving\n\n\\begin{equation}\n    \\Lambda_{n}(X) > \\frac{1}{8\\sqrt{\\pi}}\\log n\n\\end{equation}\n\n\\noindent\nfor every $X$, showing $\\Lambda_{n}(X)$ is unbounded.\nOne popular set of interpolation nodes is the zeros\nof the Chebyshev polynomials:\n\n\\begin{align}\n    T &= \\braces{z_{k}^{n} \\mid k=1,\\cdots,n; n\\in\\N} \\nonumber\\\\\n    z_{k}^{n} &= \\cos\\brackets{\\frac{\\pi}{n}\\parens{n-k+\\frac{1}{2}}}.\n\\end{align}\n\n\\noindent\nThe Chebyshev polynomials $T_{n}(x)$ are a set of orthogonal polynomials\nwhich will be discussed in detail in Sec.~\\ref{ssec:kar_cheby}.\nIn~\\cite{Brutman1978}, it was shown\n\n\\begin{equation}\n    \\Lambda_{n}(T) < 8 + \\frac{2}{\\pi}\\log n,\n\\end{equation}\n\n\\noindent\nFor this reason, we see that the interpolatory matrix $T$\nis close to optimal and,\ncoupled with fast interpolation methods, gives reason\nfor its popularity. Better bounds for Lebesgue\nconstants can be found in~\\cite{smith2006lebesgue}.\n\nWe also give bounds for equally-spaced points, setting\n\n\\begin{equation}\n    E = \\braces{\\left. -1+2\\frac{k-1}{n-1} \\right| k=1,\\cdots,n; n\\in\\N}.\n\\end{equation}\n\n\\noindent\nIn~\\cite{trefethen1991two}, Trefethen and Weideman give the bounds\n\n\\begin{equation}\n    \\frac{2^{n-2}}{n^{2}} < \\Lambda_{n}(E) < \\frac{2^{n+3}}{n}\n\\end{equation}\n\n\\noindent\nas well as referencing the asymptotic result and some of the history\nof equally-spaced interpolation.\nClearly, the exponential growth of\n$\\Lambda_{n}(E)$ helps quantify how much worse $E$ is when\ncompared with $T$.\n\nThis divergence is not restricted to equally-spaced point\ndistributions, though.\nIn fact, we have the following result:\n\n\\begin{thm}[Theorem 4.3 in~\\cite{interpFunctionsBook}]\nFor an interpolatory matrix $X\\subset[-1,1]$, there exists $h\\in C[-1,1]$\nso that\n%\n\\begin{equation}\n    \\limsup_{n\\to\\infty} \\abs{L_{n}(h,X,x)} = \\infty\n\\end{equation}\n%\nfor almost every $x\\in[-1,1]$.\n\\end{thm}\n\n\\noindent\nSo, there is no interpolatory matrix $Y$ so that\n$\\norm{L_{n}(f,Y)-f}_{\\infty}\\to0$ for all continuous functions $f$\nand the approximation error can be arbitrarily bad.\n\n\n\n\\section{Possible Solutions to Divergence of Lagrange Interpolation}\n\\label{sec:poss_lagrange_sol}\n\nAlthough the previous result paints a bleak picture of Lagrange interpolation,\nthis is true only in extreme situations.\nFrom~\\cite[Chapter 1]{rivlin2003introduction}, we have the following theorem\ndiscussing how the degree of approximation is related to smoothness:\n\n\\begin{thm}[Jackson Inequality]\n\\label{thm:best_uni_err}\nIf $g\\in C^{k}[-1,1]$ and $g^{(k)}$ is $\\alpha$-H\\\"{o}lder\nwith H\\\"{o}lder constant $L$, then for $n>k$, we have\n%\n\\begin{equation}\n    E_{n}(g) \\le \\frac{c}{n^{k}}\\parens{\\frac{1}{n-k}}^{\\alpha}\n\\end{equation}\n%\nwith $c=6^{k+1}e^{k}(1+k)^{-1}L$.\n\\end{thm}\n\n\\noindent This theorem shows that if $g$ is merely $\\alpha$-H\\\"{o}lder\ncontinuous, then $\\norm{L_{n}(g,T)-g}_{\\infty}\\to0$ by\nEq.~\\eqref{eq:Ln_upper_bound_err}.\nAs noted above, we can have $\\norm{L_{n}(f,E)-f}_{\\infty}\\not\\to0$\neven when $f$ is analytic.\n\nWe previously noted $L_{n}(f,E)$ has large oscillations in the Runge example.\nBecause of this, there has been interest in Hermite-Fej\\'{e}r interpolation.\nGiven an interpolatory matrix $X$, we let $H_{n}(f,X,x)\\in\\mathcal{P}_{2n-1}$\nso that\n\n\\begin{align}\n    H_{n}(f,X,x_{k;n}) &= f(x_{k;n}) \\nonumber\\\\\n    H_{n}'(f,X,x_{k;n}) &= 0.\n\\end{align}\n\n\\noindent\nIn this case, it can be shown $\\norm{H_{n}(f,T)-f}_{\\infty}\\to0$\nas $n\\to\\infty$ for all $f\\in C[-1,1]$~\\cite[Chapter 5]{interpFunctionsBook}.\nUnfortunately, this does not hold in general; in fact,\nfor equally-spaced nodes we have the particularly bad\nresult\n\n\\begin{align}\n    f(x) &= x \\nonumber\\\\\n    \\limsup_{n\\to\\infty} \\abs{H_{n}(f,E,x)} &= \\infty,\\quad 0 <\\abs{x}\\le1,\n\\end{align}\n\n\\noindent\nwhich is discussed in~\\cite[Chapter 6]{interpFunctionsBook}.\nControlling the derivative of the interpolation polynomial\nat the Chebyshev nodes appears to give sufficient control of the polynomial\nin order to obtain convergence for all continuous functions.\nEven so, while this gives convergence in the limit,\nit is not useful in practice because we purposefully limit the\naccuracy of interpolation near, but not at, interpolation nodes.\n\nIn another direction, Bernstein polynomials give up interpolation\nto get overall approximation.\nIn fact, \\cite{davis_interpolation,rivlin2003introduction}\nuse Bernstein polynomials to prove the Weierstrass Approximation Theorem.\nThe downside is that convergence to the solution is slow:\n\n\\begin{thm}[Error Estimate for Berstein polynomials;\n    Theorem 1.2 in \\cite{rivlin2003introduction}]\n\\label{thm:berstein_polynomial_error}\nSuppose $g\\in C[0,1]$ is $\\alpha$-H\\\"{o}lder\nwith H\\\"{o}lder constant $L$ and $B_{n}g$ is the Berstein\npolynomial of degree $n$ for $g$; then \n%\n\\begin{equation}\n    \\norm{g - B_{n}g}_{\\infty,[0,1]} \\le\n        \\frac{3L}{2}\\frac{1}{n^{\\alpha/2}},\n\\end{equation}\n%\nand this bound in $n$ cannot be improved.\n\\end{thm}\n\n\\noindent\nThis precludes it from being of much use in practice,\nespecially when $f$ is smooth.\n\nBy relaxing the condition $\\deg L_{n}(f,X) \\le n-1$,\nErd\\H{o}s was able to prove in~\\cite{erdos1943some} that,\nunder some conditions on $X$, one could prove convergence\nfor all continuous functions by choosing $p_{n}$ so that\n$\\deg p_{n} = c(X)n$, with $c$ a constant depending only on $X$.\nThe extension to all matrices $X$ is shown\nin~\\cite[Theorem 2.7]{interpFunctionsBook}.\nThis is important in practice, because we can not\nalways choose the interpolation nodes.\nIt is beneficial for a method to work well independent of\nnode location, especially if, because of instrument specifications,\ndata collection location cannot be modified.\nUnfortunately, these results require function values at arbitrary points,\nand this is not possible in practice.\n\n\n\n\\section{Interpolation in Higher Dimensions}\n\\label{sec:Interp_MD}\n\nUp to this point, we have only talked about methods for approximating\nfunctions on $[a,b]$; even so, many problems in science and engineering\nare inherently two- and three-dimensional.\nA review of recent methods for multivariable polynomial interpolation\ncan be found in~\\cite{gasca2001history,gasca2000polynomial}.\nOne challenge of interpolation in higher dimensions is choosing \nthe correct polynomial space and point distribution.\nNow, the fact $\\dim \\mathcal{P}_{n-1}=n$ makes this easy in 1D\nbut in higher dimensions there does not appear to be a simple way to\nchoose a multivariable polynomial space of arbitrary dimension.\nNaturally, this is a topic of great interest.\nIn~\\cite{gasca2000polynomial}, some standard methods discussed include\ntensor products of univariate polynomials, Gr\\\"{o}bner bases,\nand ideal interpolation schemes.\n\n\n\n\\section{Hermite and Birkhoff Interpolation}\n\\label{sec:Birkhoff_MD}\n\nHermite or Birkhoff interpolation problems involve interpolating\nfunction and derivative values.\nHermite interpolation consists of interpolating function and derivative\nvalues up to a certain degree at interpolation nodes.\nBirkhoff interpolation is more general, allowing any combination\nof specified function and derivative values at nodes.\nHermite interpolation is well-posed and can easily be solved in 1D.\nThis is not the case for Birkhoff interpolation, where only\ncertain combinations ensure a unique\nsolution~\\cite{karlin1972hermite,lorentz1971birkhoff}.\nThe problem is even more complicated in dimension 2 and larger;\nsee~\\cite{lorentz2000multivariate,rudy} for a review of these topics.\nAn additional challenge in multidimensional interpolation\ncomes from proving error bounds and determining sufficient conditions for\nconvergence.\n\n\n\n\\section{Characteristics of Good Algorithms}\n\\label{sec:Good_Alg_Details}\n\nThis dissertation focuses on the development, implementation,\nand analysis of fast MSN methods. The ideas behind the MSN method\nwill be discussed in the Sec.~\\ref{sec:msn_intro}, but here\nwe discuss good qualities that numerical algorithms should have,\nespecially algorithms for approximation.\nThese are high-order convergence, low computational complexity,\nand numerical stability.\n\nGiven a low-order method and a high-order method of similar computational cost,\na faster-converging method is more effective and useful.\nIn practice, there is always a limit to the amount of computational\nresources (memory, processor speed, or bandwidth), so a high-order\nmethod would be preferred as it would lead to less work overall.\nAs mentioned before, Bernstein polynomials converge to all\ncontinuous function but do so at a slow rate. This alone does not\nnecessarily disqualify the algorithm, but from Thm.~\\ref{thm:best_uni_err},\nwe know smoother functions can have better polynomial\napproximations. This incentivizes developing accurate approximations\nand algorithms to compute them.\n\nWhile some methods may be of theoretical importance, algorithms will only\nbe of practical value if there are efficient methods to compute them.\nThe total cost should be of reasonable size, so that both the \nasymptotic growth ($O(\\log n)$ or $O(n^{3})$) and\nthe explicit cost ($10^{6}\\log n$ and $\\frac{2}{3}n^{3}$) are important.\nBecause computational resources are always limited, asymptotics\nmay not be as important as the prefactor hidden by Big O notation.\n\nFinally, numerical stability is of critical importance.\nAlmost all algorithms are implemented on computers using\nfloating-point arithmetic, inevitably leading to small errors.\nIt is necessary for practical algorithms to be immune to these\nchanges; namely, small changes in inputs should lead to small changes\nin outputs.\nThe condition number quantifies how much changes in outputs come\nfrom changes in inputs; a standard reference for numerical stability\nis~\\cite{HighamASNA}.\n\n\n\n\\section{The Minimum Sobolev Norm Method}\n\\label{sec:msn_intro}\n\nWe previously showed Lagrange interpolation\ndoes not work, for there can be large oscillations in the interpolating\npolynomial as seen in the Runge phenomenon, while using a polynomial\nof higher degree allows continuous functions to be approximated\narbitrarily well.\nBy combining these observations, the \nMinimum Sobolev norm (MSN) method was developed: a general\nmethod for computing approximate solutions to problems\nwith linear constraints.\n\nThe MSN method has been used to solve problems in\ninterpolation~\\cite{msnInterp},\nBirkhoff interpolation~\\cite{msnBirkhoff}, and\npartial differential equations~\\cite{msnPDE},\nFor simplicity,\nwe assume we are performing approximations using algebraic polynomials,\neven though theoretical work often uses trigonometric polynomials.\nThe main idea is this: given $N$ linear constraints and polynomials\nof up to degree $M(N)$ contained in $V$, unknown coefficients $a$,\ncorrect values $f$, and a diagonal matrix $D_{s}$ with\ncondition number $O(M^{s})$, the MSN solution solves the equation\n\n\\begin{equation}\n    \\min_{Va=f} \\norm{D_{s}a}_{2}.\n    \\label{eq:msn_def}\n\\end{equation}\n\n\\noindent\nWe choose $D_{s}$ so that $\\norm{D_{s}a}_{2}$ is a Sobolev norm.\nThis implies that we seek an approximation which satisfies the linear\nconstraints as well as having the smallest derivative norm.\nHere we focus on computing the minimum 2-norm solution\nbecause this dissertation investigates efficient numerical algorithms\nfor MSN equations and we explicitly compute LQ factorizations;\nmethods for $p$-norm minimization are discussed in~\\cite{msnInterp,msnBirkhoff}.\nAdditionally, this description is independent of dimension and node location.\nThe parameter $s$ determines which derivative of the\npolynomial approximation we wish to control.\nLarger $s$ gives more derivative control on the approximation\nbut leads Eq.~\\eqref{eq:msn_def} to have higher condition\nnumbers. Great care is required to limit the effects of these\ncondition numbers in order to ensure convergence to the underlying\nsolution~\\cite{msnBirkhoff}.\n\nThe technical challenge of this method is to determine\nthe explicit form of $M(N)$ to ensure convergence to the solution.\nThe methods in~\\cite{msnInterp,msnBirkhoff} involve the close\napproximation of integral kernels by polynomials.\nThe end result is that it is sufficient to choose $M(N) = C\\eta^{-1}$,\nwhere $\\eta$ is the minimum separation between between\ninterpolation nodes. Although this is a theoretically optimal result,\nknowing from~\\cite{interpFunctionsBook} that this result cannot\nbe improved except in the constant, it is not useful in practice\nbecause the constants from~\\cite{msnInterp,msnBirkhoff}\nare difficult to explicitly compute.\nIn practice, we have found that choosing the $M(N) = 2\\pi\\eta^{-d}$\nis sufficient, where $d$ is the dimension of the space.\nThese details, along with\nimplementation issues, will be discussed more in the next section.\n\nOne advantage of the MSN method is that we do not insist on forming\na square linear system.\nIn fact, it is necessary\nto take enough columns (more than twice the number of rows)\nin order to ensure a good approximation. Choosing the proper\npolynomial space was a challenge mentioned in Secs.~\\ref{sec:Interp_MD}\nand \\ref{sec:Birkhoff_MD}.\n\n\n\n\\section{MSN Interpolation Examples}\n\\label{sec:MSN_slow_examples}\n\nWe present some results of MSN interpolation on equally-spaced\nnodes in single and double precision for 1D and 2D.\nWe do this to show that the difficulty of approximating\nfunctions on equally-spaced points arises from using suboptimal methods\nof interpolation rather than node location.\nThese and similar results were published in~\\cite{msnInterp,msnBirkhoff}.\n\nWe can rewrite Eq.~\\eqref{eq:msn_def} as\n\n\\begin{align}\n    &\\min_{VD_{s}^{-1}x=f} \\norm{x}_{2} \\nonumber\\\\\n    &\\quad a = D_{s}^{-1}x.\n    \\label{eq:msn_def_rework}\n\\end{align}\n\n\\noindent\nIn order to compute the MSN solution,\nwe must compute the minimum norm solution from Eq.~\\eqref{eq:msn_def_rework}.\nTo do this, we must compute an LQ factorization of $VD_{s}^{-1}$,\nwhere $L$ is a lower triangular matrix and $Q$ is orthogonal.\nAs previously mentioned, large $s$ leads to greater derivative control\nbut also gives $VD_{s}^{-1}$ high condition number. Because\nof this, the standard pivoted LQ factorization based on QR with\nColumn Pivoting is insufficient. A Rank-Revealing QR factorization\nbased on~\\cite{gu1996efficient} would be better, but an \nimplementation is not readily available so we use another method presented\nhere and described in~\\cite{msnBirkhoff}; see Alg.~\\ref{alg:slow_msn_lq}.\n\n\\input{algs/slow_msn_alg.tex}\n\nThe unique feature of the algorithm may be Lines 4 and 5.\nClearly, $VD_{s}^{-1}$ is badly column-scaled.\nLQ factorizations can deal with poor row-scaling but not poor column-scaling.\nWe compute the singular value decomposition\n$U\\Sigma V^{*} = Q_{1}D_{s}^{-1}\\Pi$ in Line 4 and\nsee $U^{*}Q_{1}D_{s}^{-1}\\Pi \\approx \\Sigma V^{*}$ to machine precision.\nThis ensures we can accurately compute the pivoted LQ\nfactorization $P_{2}L_{2}Q_{2} = U^{*}Q_{1}D_{s}^{-1}\\Pi$ in Line 5.\nThus, $U$ is a preconditioner for numerical stability, showing\nthat we can safely convert poor column-scaling to poor row-scaling.\nUsing Alg.~\\ref{alg:slow_msn_lq}, the effective condition number of this\nproblem appears to be that of $V$ and not $VD_{s}^{-1}$.\n\nLooking at the algorithm, we see two pivoted LQ factorizations\nand one SVD are required.\nBecause we have $N$ interpolation requirements\nand $cN$ columns, this gives us $O(N^{3})$ floating-point operations\nand $O(N^{2})$ units of memory.\nAt first glance, this does not seem too bad.\nIf we are in dimension $d$ with $n^{d}$ tensor grid points, then $N = n^{d}$ and\nwe require $O(n^{3d})$ flops and $O(n^{2d})$ units of memory.\nWhile these costs may be acceptable for $d=1$ and bearable for $d=2$,\nwhen $d=3$ this is too great.\nParallel computation would not be\nof much use here because the communication required for pivoted LQ\nand the SVD would cause the entire process to be extremely slow,\nalthough there has been recent work in reducing the communication cost\nin pivoted QR factorizations~\\cite{demmel2015communication}.\nIn order for these algorithms to be used when solving large, difficult\nproblems, we need to investigate other methods.\nSimilar costs arise when solving differential equations and\nthis necessitates fast, structured algorithms.\nWhen developing fast algorithms, it is critical\nthat we are able to convert the poor columns scaling to poor row scaling.\nThe inherent structure of the linear system allows us to do this\nusing careful factorizations.\n\nWe present some examples of MSN interpolation and Birkhoff interpolation.\nThe functions we approximate are\n\n\\begin{samepage}\n\\begin{align}\n    f(x) &= \\frac{1}{1+25x^{2}} \\nonumber\\\\\n    g(x,y) &= \\frac{1}{1+ 25(x^2 + y - 0.3)^{2}}\n       + \\frac{1}{1+ 25(x + y - 0.4)^{2}} \\nonumber\\\\\n       &\\quad + \\frac{1}{1+ 25(x + y^{2} - 0.5)^{2}}\n       + \\frac{1}{1+ 25(x^{2} + y^{2} - 0.25)^{2}}\n        \\nonumber\\\\\n    h(x) &= g(x,-0.96).\n    \\label{eq:intro_runge_functions}\n\\end{align}\n\\end{samepage}\n\n\\noindent\nNaturally, $f$ is the usual Runge function. Here, $g$ is a 2D\nfunction with Runge functions on one line, one circle, and two\nparabolas.\n\nWe remember machine precision is $2^{-23}\\approx 1.2\\times10^{-7}$ in single\nprecision and $2^{-52}\\approx 2.2\\times10^{-16}$ in double precision.\nThis is the smallest relative error that we could expect for\nany nonzero result. All of the plots show results for\n$\\norm{f-p}_{\\infty}/\\norm{f}_{\\infty}$ for true function $f$\nand approximation $p$. The sup-norm is approximated\nby sampling the function at a large number of locations and taking\nthe maximum.\n\nThe results for interpolating $f$ are shown in Fig.~\\ref{fig:intro_msn_interp}.\nFor single precision, all error curves decay toward $10^{-7}$ as\nwe increase the number of points. The main exception is for $s=6$,\nwhich starts to increase around 60 points. We believe this occurs\nbecause of rounding error. This would also make sense given for\n$s\\in\\braces{3,4,5}$, the error curves hover close to $10^{-6}$.\nWe see a similar results for double precision.\nIn this case, the beginnings of the U-shaped error curve seem\npresent for $s\\in\\braces{8,10,12}$.\n\nIn Fig.~\\ref{fig:intro_msn_birkhoff_1d}, we have the results\nof MSN Birkhoff interpolation in 1D for $h$.\nAlthough the error curve for $s=2$ in single and double precision hovers around\n$10^{-3}$, the other error curves decay to machine precision.\nThe beginning of a U-shaped error curve may be seen\nfor $s\\in\\braces{4,5}$ in single precision and $s\\in\\braces{10,12}$\nin double precision. The errors are low, although they may be slightly\nlarger than those we see in regular MSN interpolation.\nThis could stem from the fact the condition number is inherently larger for\nBirkhoff interpolation than for interpolation.\n\nIn Fig.~\\ref{fig:intro_msn_birkhoff_2d},\nwe have results for MSN Birkhoff interpolation in 2D\nfor $g$ from Eq.~\\eqref{eq:intro_runge_functions}.\nIn every case the error decreases with increasing data except\nfor $s=5$ with single precision. In this case, we may start\nto see the beginning of the effects of roundoff error.\nThe challenge for 2D problems is the long time required to\nrun Alg.~\\ref{alg:slow_msn_lq}.\n\n\\input{plots/msn_interp_examples_slow.tex}\n\n\n\n\\section{Dissertation Outline}\n\\label{sec:dis_outline}\n\nAs we noted above, the slow methods for solving problems using\nMSN become difficult in 2D and practically impossible in 3D\ndue to memory requirements and flop count. With the eventual\ndesire to use MSN to solve 3D PDEs,\nwe will need to take advantage of \\emph{everything} we can.\nKeeping this in mind, the focus of this dissertation\nwill be developing fast algorithms for solving interpolation\nand differential equations using the MSN method on Chebyshev nodes\nand express our solution in a Chebyshev polynomial basis.\nWe review notation conventions and structured\nmatrices in Chapter~\\ref{chap:K_and_R}.\nIn Chapter~\\ref{chap:CV_Prop}, we review some of the properties\nof Chebyshev-Vandermonde matrices which arise when developing\nthese fast algorithms.\nMatrix factorizations important for interpolation problems are\ndiscussed in Chapters~\\ref{chap:CV_mat_1D_I} and \\ref{chap:CV_mat_HD_I}.\nUsing these factorizations, we present examples of MSN approximation\nin Chapter~\\ref{chap:func_interp}.\nNext, we present new proofs showing that our fast methods\nwill converge to the solution under minimal smoothness assumptions\nof the underlying function in Chapter~\\ref{chap:cvip_converge}.\nWe investigate fast algorithms for Boundary Value Problems for ODEs\nin Chapter~\\ref{chap:fast_ode}.\n\nIn the Chapter~\\ref{chap:random}, we discuss results related\nto randomized low-rank approximations, unrelated to the previous work.\nSome of this was discussed in~\\cite{randomHSSLBL}\nbut more details and examples will be shown here.\n\n\n\n\\section{Algorithms Similar to the MSN Method}\n\\label{sec:similar_methods}\n\nThe ideas pursued in this dissertation are similar to those\nused by Chebfun~\\cite{driscoll2014chebfun}, a software package\nin \\textsc{Matlab}~\\cite{guide1998mathworks} which attempts\nto have the ``feel'' of symbolic software with the speed\nof numerics.\nThe book Approximation Theory and Approximation Practice~\\cite{ATAP}\nuses Chebfun to introduce the field of  Approximation Theory.\nHere, we focus on investigating fast algorithms based\non values computed on Chebyshev polynomial roots.\nThis is similar to the fast algorithms present in Chebfun,\nwhich computes values on the Chebyshev polynomial extrema.\nThe book Exploring ODEs~\\cite{ExpODEs} also uses\nChebfun to introduce advanced differential equation topics.\nThe methods in~\\cite{ExpODEs} are built on the work\nfrom~\\cite{driscoll2015rectangular,aurentz2017block,xu2015explicit}\nand are incorporated into Chebfun.\nAlthough spectral methods are well-known~\\cite{boyd2001chebyshev},\n\\cite{aurentz2017block} \\emph{adds} additional rows\nto the square linear system to impose boundary or other requirements\ninstead of replacing rows.\nNaturally, this requires increasing the degree of the approximation.\nThe work presented here does not force a square system, which allows\nus to add a finite number of additional requirements which do not\naffect the asymptotic complexity of the overall algorithm.\nFrom~\\cite[Appendix A]{ExpODEs}, it appears that Chebfun uses\nstandard dense linear algebra algorithms to solve its ODEs.\nThis is unfortunate, because the linear systems arising from ODEs\nare highly structured when approximated on Chebyshev nodes.\nThis dissertation will show this structure and construct associated\nfast algorithms.\nThe work here could be used to speedup the Chebfun ODE solver.\n", "meta": {"hexsha": "29092c9e5493c5274439f44bf92f8f66f74bd198", "size": 28236, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/introduction.tex", "max_stars_repo_name": "chgorman/UCSB-Dissertation-Template", "max_stars_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/introduction.tex", "max_issues_repo_name": "chgorman/UCSB-Dissertation-Template", "max_issues_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/introduction.tex", "max_forks_repo_name": "chgorman/UCSB-Dissertation-Template", "max_forks_repo_head_hexsha": "c57b9e5209e93ecb79abb364dbad29037a2aed03", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2796005706, "max_line_length": 80, "alphanum_fraction": 0.758251877, "num_tokens": 7990, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.43762274349277697}}
{"text": "\\vssub\n\\subsubsection{~Curvilinear grids} \\label{sub:num_space_curv}\n\\conthead{\\ws (NRL Stennis)}{W. E. Rogers, T. J. Campbell}\n\n\\noindent \nAs an extension to traditional ``regular'' grids, computations may be made on ``irregular'' \ngrids within \\ws\\ . This makes it possible to run the model on alternate grid\nprojections (e.g. Lambert conformal conic), rotated grids, or\nshoreline-following grids with higher resolution near shore, though the\nrestrictions on time step from the conditionally stable schemes still\napply. The same propagation schemes are utilized for irregular grids as for\nregular grids (\\para\\ref{sub:num_space_trad}).\n\nThe implementation is described in detail in \\cite{rep:RC09}, and summarized\nhere: a Jacobian is used to convert the entire domain between the normal,\ncurving space, and a straightened space. This conversion is performed only\nwithin the propagation routine, rather than integrating the entire model in\nstraightened space. A simple, three step process is used every time the\npropagation subroutine is called (i.e. every time step and every spectral\ncomponent): first, the dependent variable (wave action density) is converted\nto straightened space using a Jacobian; second, the wave action density is\npropagated via subroutine calls for each (of two) grid axes; third, the wave\naction density is converted back to normal, curved space. The actual flux\ncomputation is not significantly modified from its original, regular grid\nform. The same process occurs, regardless of grid type (regular or irregular);\nfor regular grids, the Jacobian is unity.\n\nRegarding the user interface: in {\\file ww3\\_grid.inp}, a string is used to\nindicate the grid type. In cases where this grid string is `{\\code RECT}', the\nmodel processes input for a regular grid. In case where this grid string is\n`{\\code CURV}' , the model processes input for an irregular grid. [Note that\nwith \\ws\\ version 4.00, the coordinate system (i.e. degrees vs. meters) and\nthe closure type (e.g. global/wrapping grid) are also specified in {\\file\nww3\\_grid.inp} ; the switches {\\code LLG} and {\\code XYG} are deprecated.]\n\nWith \\ws\\ version 5, capability is added to run on a special type of curvilinear grid, the ``tripole grid'' using the first-order propagation scheme. In the northern hemisphere, this grid type uses two poles instead of one, and both are over land to prevent singularities in grid spacing. This type of grid is sometimes used in ocean models, e.g. \\citep{art:Murr96} and \\citep{art:Metz14}. No special switch is required, and the grid is read in as any other irregular grid would be, but the user must specify a closure type ({\\code CSTRG}) of {\\code TRPL} in {\\file ww3\\_grid.inp}. Specific details can be found in the documentation for {\\file ww3\\_grid.inp} in \\para\\ref{sub:ww3grid}. Propagation and gradient calculations are modified to deal with the new closure method. The {\\code TRPL} closure type is compatible only with the first-order {\\code PR1} propagation scheme. An attractive feature of the tripole grid is that it allows the user to run a single grid which extends all the way to the North Pole.  However, though the three poles are over land, there is still a convergence of meridians at the sea points nearest to them, meaning that the grid spacing in terms of real distances (which determines the maximum propagation time step) is still highly variable. More efficient grid spacing (meaning: with less variation of grid spacing in terms of real distances) can be achieved through the use of the multi-grid capability. Though this scheme addresses singularities in grid spacing at the pole, it does not address the singularity associated with definition of wave direction.\n", "meta": {"hexsha": "8aa476ae4cb98f931548bc24ff6eef8993dcea1a", "size": 3710, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/num/space_curv.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/num/space_curv.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/num/space_curv.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 100.2702702703, "max_line_length": 1589, "alphanum_fraction": 0.7867924528, "num_tokens": 864, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.43762273085722525}}
{"text": "%\n% Copyright (c) Facebook, Inc. and its affiliates.\n%\n% This source code is licensed under the MIT license found in the LICENSE file\n% in the root directory of this source tree. \n%\n\n\\documentclass{article}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{amsthm,amsmath,amssymb}\n\\usepackage{graphicx}\n\\usepackage[hidelinks,breaklinks]{hyperref}\n\\pdfsuppresswarningpagegroup=1\n\n\n\n\n\\newtheorem{theorem}{Theorem}[]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{observe}[theorem]{Observation}\n\\newtheorem{remark1}[theorem]{Remark}\n\\newenvironment{remark}{\\begin{remark1} \\rm}{\\end{remark1}}\n\n\n\n\n\\DeclareMathOperator{\\Bernoulli}{Bernoulli}\n\\DeclareMathOperator{\\E}{\\mathop{}\\mathbb{E}}\n\n\n\n\n\\newlength{\\vertsep}\n\\setlength{\\vertsep}{.085in}\n\\newlength{\\imsize}\n\\setlength{\\imsize}{.365\\textwidth}\n\n\n\n\n\\title{A graphical method of cumulative differences\\\\between two subpopulations}\n\\author{Mark Tygert\\\\{\\normalsize Facebook Artificial Intelligence Research}\\\\\n{\\normalsize 1 Facebook Way, Menlo Park, CA 94025}\\\\\n{\\normalsize Main e-mail address:\\ \\ {\\tt mark\\symbol{64}tygert.com}}}\n\n\n\n\n\\begin{document}\n\n\n\n\\maketitle\n\n\n\n\\begin{abstract}\nComparing the differences in outcomes (that is, in ``dependent variables'')\nbetween two subpopulations\nis often most informative when comparing outcomes only for individuals\nfrom the subpopulations who are similar according to ``independent variables.''\nThe independent variables are generally known as ``scores,''\nas in propensity scores for matching or as in the probabilities predicted\nby statistical or machine-learned models, for example.\nIf the outcomes are discrete, then some averaging is necessary\nto reduce the noise arising from the outcomes varying randomly\nover those discrete values in the observed data.\nThe traditional method of averaging is to bin the data according to the scores\nand plot the average outcome in each bin against the average score in the bin.\nHowever, such binning can be rather arbitrary and yet greatly impacts\nthe interpretation of displayed deviation between the subpopulations\nand assessment of its statistical significance.\nFortunately, such binning is entirely unnecessary in plots\nof cumulative differences and in the associated scalar summary metrics that are\nanalogous to the workhorse statistics of comparing probability distributions\n--- those due to Kolmogorov and Smirnov and their refinements due to Kuiper.\nThe present paper develops such cumulative methods\nfor the common case in which no score of any member\nof the subpopulations being compared is exactly equal to the score\nof any other member of either subpopulation.\n\n\\bigskip\n\n\\noindent {\\bf Keywords:} calibration, fairness, equity, forecast,\nprediction, stochastic, reliability diagram, histogram, plot, visualization\n\n\\end{abstract}\n\n\n\n\\section{Introduction}\n\\label{intro}\n\nA fundamental problem in statistics is to compare outcomes\nattained by two different subpopulations whose members are matched\nvia numerical values known as ``scores.''\nIn this context, the scores are the independent variables,\nand the outcomes are the dependent variables.\nPropensity scores are a popular method for matching,\nas are the likelihoods assigned by statistical or machine-learned models.\nSynonyms for ``outcome'' include ``response'' and ``result,''\nand the present paper will use all these synonyms interchangeably.\nThe responses are {\\it random} variables,\nwhereas the scores are viewed as given, non-random.\nIn many practical settings, no score from among either subpopulation's members\nis exactly equal to any score from among the two subpopulations' other members,\ncomplicating the comparison and very concept of ``matching'';\nthe present paper addresses precisely these practical settings.\nSome simpler settings are addressed already by~\\cite{tygert} and others.\n\nProminent practical applications include the analysis of equity\nfor subpopulations (often the subpopulations considered are sensitive groups,\nperhaps based on protected classes such as race, color, religion, gender,\nnational origin, age, disability, veteran status, or genetic information),\nas by~\\cite{corbett-davies-pierson-feller-goel-huq} and others,\nas well as the comparison of control to treated subpopulations\nin medical trials, as by~\\cite{xu-kalbfleisch} and the references\nin their introduction. Observational studies are another popular application,\nespecially when investigating differences between healthy, diseased, infected,\nor treated subpopulations in biomedicine,\nas reviewed by~\\cite{luo-gardiner-bradley}.\n\nStatistical questions arise when the responses are discrete,\ntaking values at random according to probability distributions\nwhose parameter values can only be estimated from the observed data.\nPerhaps the most common scenario is when each response is either a success\nor a failure, typically encoded as taking the values 1 or 0, respectively.\nIf the underlying probability of success is 0.5, for example,\nthen the actual observation will be 1 half the time and 0 half the time.\nThus, some averaging is necessary to obtain reliable estimates\nwhen the responses are discrete.\n\nThe traditional ``reliability diagram'' plots binned responses\nagainst binned scores. Namely, the diagram partitions the real line\ninto disjoint intervals known as ``bins'' and takes the (arithmetic) average\nof the scores in each bin paired with the average\nof the responses corresponding to the scores in that bin.\nThe reliability diagram then graphs the average responses\nagainst the average scores.\nTypically, each subpopulation under consideration gets its own graph,\nsuperimposed on the same diagram.\nCopious examples are available in the figures below,\nas detailed in Section~\\ref{results} below.\nAnother name for ``reliability diagram''\n(popularized by~\\cite{corbett-davies-pierson-feller-goel-huq})\nis ``calibration plot,'' especially when the responses are Bernoulli variates.\nA comprehensive, textbook review of reliability diagrams\nfor plotting calibration is available in Chapter~8 of~\\cite{wilks}.\n\nThere are two canonical choices for the bins that partition the real line\nin the reliability diagram: \\{1\\} make the width of every bin be the same\nor \\{2\\} set the widths of the bins such that each bin contains\nroughly the same number of scores from the observed data set.\nNaturally, the second choice can adapt to each subpopulation\nunder consideration. In both cases, increasing the number of bins\ntrades off statistical confidence in the estimates\nfor enhanced resolution in detecting deviations as a function of score;\nafter all, narrower bins perform less averaging, averaging away less\nof the randomness in the observations.\nThe trade-off between resolution and statistical confidence\nis inherent in methods based on binning or kernel density estimation\nsuch as that of~\\cite{srihera-stute}.\nThe methods proposed in the present paper avoid making\nsuch an explicit trade-off and also avoid the rather arbitrary decisions\nabout which bins or kernels to use.\nThe present paper extensively compares its methods against\nboth standard choices of bins for the classical methods.\n\nThe present paper follows the cumulative approach introduced into statistics\nby~\\cite{kolmogorov} and~\\cite{smirnov}.\nThe methodology of Kolmogorov and Smirnov,\nas well as the refinement (``Kuiper's statistic'') introduced by~\\cite{kuiper},\nyields scalar summary statistics useful for screening large numbers\nof data sets and subpopulations. After identification via the scalar statistics\nof potentially statistically significant deviations in a data set\nfor two subpopulations, graphical methods allow for in-depth investigation\ninto the variation of the deviations as a function of score.\nThe graphical methods (and hence an intuitive interpretation\nof the associated scalar summary statistics) rely on the weighting\nused by~\\cite{delgado}, \\cite{diebolt}, and~\\cite{stute},\nwhich is different from the weighting used by the otherwise\nclosely related approach of~\\cite{scheike} and the others\ncited by~\\cite{gonzalez-manteiga-crujeiras}.\nThe scalar summary statistics of~\\cite{delgado} are almost the same\nas those in the present paper, but for the simpler setting in which each score\ncomes with precisely one observation from one subpopulation\nand one observation from the other subpopulation.\nThe scalar summary statistics of~\\cite{diebolt} and~\\cite{stute} are analogues\nof those from the appendix of~\\cite{tygert}\nin the special case that the parametric regression function they consider\nis nothing but the identity function on the unit interval $[0, 1]$.\n\nThe graphs introduced in the present paper are easy to interpret.\nFor instance, in the topmost plots (a and b) of Figure~\\ref{ex0},\nthe deviation between the two subpopulations over a range of scores\nis simply the expected slope of the secant line for the graph\nover that range of scores, as a function of the index $k/n$\n(positive slope indicates that the responses\nfor one subpopulation are greater on average than those\nfor the other subpopulation, while negative slope indicates\nthat the responses for the former subpopulation are less than the latter's\non average).\nLong ranges of steep slopes correspond to ranges of scores for which\nthe average responses are significantly different\nbetween the two subpopulations;\nthe triangle along the vertical axis on the left of each plot\nindicates the magnitude of the deviation across the full range of scores\nthat would be statistically significant at around the 95\\% confidence level.\nThe connection with statistical significance also motivated related works,\nincluding that of~\\cite{gupta-rahimi-ajanthan-mensink-sminchisescu-hartley}\nand~\\cite{roelofs-cain-shlens-mozer}, which offer Kolmogorov-Smirnov metrics\nto help gauge calibration of probabilistic predictions,\nmuch like in the appendix of~\\cite{tygert}.\nSimilarly, Section~3.2 of~\\cite{gneiting-balabdaoui-raftery} and\nChapter~8 of~\\cite{wilks} propose cumulative reliability diagrams,\nalbeit without leveraging the key to the approach of the present paper,\nnamely that slope is easy to assess visually even when the constant offset\nof the part of a graph under consideration is arbitrary and uninformative.\nDetailed explanation of statistical significance and Figure~\\ref{ex0}\nis available in Sections~\\ref{methods} and~\\ref{results} below.\n\nSection~\\ref{methods} introduces the methodology of cumulative differences,\nboth for graphs of the differences and for the scalar metrics\nof Kuiper and of Kolmogorov and Smirnov that summarize the graphs' deviation\naway from being perfectly flat.\nSection~\\ref{results} presents several illustrative examples,\nvia both simple synthetic and complicated real data sets.\\footnote{Permissively\nlicensed open-source software that can automatically reproduce all figures\nand statistics reported below is available at\n\\url{https://github.com/facebookresearch/fbcddisgraph}}\nSection~\\ref{conclusion} concludes the paper with a brief discussion.\nTable~\\ref{notation} summarizes the notation used throughout the present paper.\nReaders interested mainly in seeing results and comparisons\nof the proposed methods to the old standbys may wish to start\nwith Section~\\ref{results}.\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_0/cumulative.pdf}}\n\\quad\\quad\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_0/cumulative_exact.pdf}}\n\n\\vspace{\\vertsep}\n\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_0/equisamps.pdf}}\n\\quad\\quad\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_0/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_0/equisamps.pdf}}\n\\quad\\quad\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_0/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_0/exact.pdf}}\n\n\\end{centering}\n\\caption{$n =$ 6,451; Kuiper's statistic is $0.09740 / \\sigma = 7.823$,\n         Kolmogorov's and Smirnov's is $0.09724 / \\sigma = 7.810$;\n         the reliability diagrams with only 10 bins each (c and d) smooth out\n         the jumps at high scores, and while the reliability diagrams\n         with 50 bins each (e and f) give some indication of the jumps,\n         the jumps still get smoothed over, while the bins for lower scores are\n         too narrow to average away noise well. The cumulative graph (a)\n         clearly displays the jumps, while remaining easily interpretable\n         at lower scores.\n         The statistics of Kuiper and of Kolmogorov and Smirnov are both\n         several times greater than $\\sigma$,\n         so both reflect that the deviation displayed in the graphs\n         is highly statistically significant.\n}\n\\label{ex0}\n\\end{figure}\n\n\n\\begin{table}\n\\caption{Notational conventions\n(The symbols in the table are in alphabetical order.)}\n\\label{notation}\n\\vspace{-.5em}\n\\begin{center}\n\\resizebox{\\textwidth}{!}{%\n\\begin{tabular}{llll}\n\\hline\n& & equation for the & equation for the \\\\\nsymbol & meaning & unweighted case & case with weights \\\\\\hline\n$A_k$ & abscissa for the cumulative graph in the case with weights &\n(Not applicable) & (\\ref{abscissae}) \\\\\n$C_k$ & cumulative average difference between the subpopulations &\n(\\ref{cumulative}) & (\\ref{cumulativew}) \\\\\n$D_k$ & average difference between the subpopulations &\n(\\ref{diff_even}) and~(\\ref{diff_odd}) &\n(\\ref{diff_even}) and~(\\ref{diff_odd}) \\\\\n$\\Delta_k$ & expected slope of $C_j$ from $j = k$ to $j = k+1$ &\n(\\ref{delta}) & (\\ref{deltaw}) \\\\\n$G$ & Kolmogorov-Smirnov statistic & (\\ref{Kolmogorov-Smirnov}) &\n(\\ref{Kolmogorov-Smirnov}) \\\\\n$H$ & Kuiper statistic & (\\ref{Kuiper}) & (\\ref{Kuiper}) \\\\\n$R^j_k$ & (average) response for subpopulation $j$'s $k$th block &\n(Step~\\ref{defining} within & (Readjusted in \\\\\n& --- random dependent variable, outcome, or result &\nSubsection~\\ref{unweighted}) & Subsection~\\ref{weighted}) \\\\\n$S^j_k$ & (average) score for subpopulation $j$'s $k$th block &\n(Step~\\ref{defining} within & (Readjusted in \\\\\n& --- non-random independent variable & Subsection~\\ref{unweighted}) &\nSubsection~\\ref{weighted}) \\\\\n$\\sigma$ & scale of random fluctuations over the full range of scores &\n(\\ref{stddev}) & (\\ref{stddevw}) \\\\\n$T_k$ & total weight for $R^0_{k/2}$ or $R^1_{(k-1)/2}$ &\n(Not applicable) & (\\ref{aggregatew}) \\\\\n$W_k$ & aggregated weight & (Not applicable) & (\\ref{aggregatew}) \\\\\n\\hline\n\\end{tabular}}\n\\end{center}\n\\end{table}\n\n\n\n\\section{Methods}\n\\label{methods}\n\nThis section details the methodology proposed in the present paper.\nSubsection~\\ref{high-level} breaks data analysis into two stages:\na first, broad-brush stage of screening for potentially significant deviations\nacross many data sets and pairs of subpopulations,\nand a second, finely detailed investigation of the variations\nin the deviations as a function of score.\nSubsection~\\ref{unweighted} develops the graphical method\nfor the second stage, in the simplest case of unweighted sampling.\nSubsection~\\ref{scalarstats} then collapses the graphs\nof Subsection~\\ref{unweighted} into scalar statistics\nuseful for the first, broad-brush stage.\nSubsection~\\ref{significance} explains how to gauge statistical significance.\nFinally, Subsection~\\ref{weighted} treats the case of weighted sampling,\ngeneralizing the previous subsections to the more complicated case\nof data with weights.\n\n\n\\subsection{Approach to big data}\n\\label{high-level}\n\nThis subsection proposes a two-step approach to analyzing\nmultiple data sets and subpopulations (the same approach taken by~\\cite{tygert}\nin a related setting):\n%\n\\begin{enumerate}\n\\item Calculate a single scalar summary statistic\nfor each data set for each pair of subpopulations of interest,\nsuch that the size of the statistic\nmeasures the deviation between the subpopulations.\n\\item Analyze in graphic detail each data set and pair of subpopulations\nwhose scalar summary statistic is large, graphing how the deviation\nbetween the subpopulations varies as a function of score.\n\\end{enumerate}\n\nThe scalar statistic for the first step simply summarizes\nthe overall deviation across all scores,\nas either the maximum absolute deviation of the second step's graph\nor the size of the range of deviations in the graph.\nThus, both steps rely on a graph, with the first stage collapsing\nthe graphical display into a single scalar summary statistic.\nThe following subsection details the construction of this graph,\nfor the case of unweighted sampling (later, Subsection~\\ref{weighted} treats\nthe weighted case).\n\n\n\\subsection{Unweighted sampling}\n\\label{unweighted}\n\nThis subsection presents the special case in which the observations\nare unweighted (or, equivalently, uniformly or equally weighted).\nSubsection~\\ref{weighted} treats the more general case\nof weighted observations, which is more complicated.\n\nThe present and all following subsections focus on a single data set\ntogether with a single pair of subpopulations;\nthe previous subsection outlines a strategy for handling multiple data sets\nand pairs of subpopulations, based on the processing of individual cases.\nThe data being considered should be observations of independent responses,\nwith each response taking one of finitely many real-valued possibilities,\nand with each (random) response being paired with a real-valued score\nviewed as given not random\n(the responses across the different scores should be independent).\nHence, the scores can take on any real values,\nwhereas the responses should be drawn from discrete distributions.\n{\\it In the present paper, the scores from the observations\nin both subpopulations put together must be distinct\n--- the score for every observation from either subpopulation must be unique\nor else slightly perturbed to become different from all the other scores\n(perturbing as little as possible while accounting for roundoff,\nfor instance).}\n\nUnder this assumption of uniqueness, a graphical method for analyzing\ndeviation between the outcomes of the two subpopulations as a function\nof score comprises the following procedure:\n%\n\\begin{enumerate}\n%\n\\item Merge all scores into a single sequence.\n%\n\\item Sort the merged sequence into ascending order and\nlet ``subpopulation 0'' denote the subpopulation associated\nwith the first (the least) score in the sorted sequence.\n%\n\\item Partition the sorted sequence into blocks such that\nthe scores in every other block all come from subpopulation 0,\ninterleaved with blocks in which all scores come from subpopulation 1;\nthat is to say:\n%\n\\begin{enumerate}\n\\item the scores in the first (lowest) block all come from subpopulation 0,\n\\item the scores in the second lowest block all come from subpopulation 1,\n\\item the scores in the third lowest block all come from subpopulation 0,\n\\item the scores in the fourth lowest block all come from subpopulation 1,\n\\item and so on, alternating between the two subpopulations,\nwith all scores in each block coming from only one of the subpopulations.\n\\end{enumerate}\n%\n\\item\\label{defining} Denote by $S^0_k$ the (arithmetic) average of the scores\nin the $(2k+1)$th block\nand denote by $S^1_k$ the average of the scores in the $(2k+2)$th block;\ndenote by $R^0_k$ the average of the responses (the random outcomes)\ncorresponding to the scores in the $(2k+1)$th block and denote by $R^1_k$\nthe average of the responses (the random outcomes) corresponding to the scores\nin the $(2k+2)$th block.\n%\n\\item Form the sequence of average differences with even-indexed entries\n%\n\\begin{equation}\n\\label{diff_even}\nD_{2k} = \\frac{(R^0_k - R^1_k) + (R^0_{k+1} - R^1_k)}{2}\n       = \\frac{R^0_k + R^0_{k+1} - 2R^1_k}{2}\n\\end{equation}\n%\nand odd-indexed entries\n%\n\\begin{equation}\n\\label{diff_odd}\nD_{2k+1} = \\frac{(R^0_{k+1} - R^1_k) + (R^0_{k+1} - R^1_{k+1})}{2}\n         = \\frac{2R^0_{k+1} - R^1_k - R^1_{k+1}}{2}.\n\\end{equation}\n%\n\\item Graph as a function of $j/n$ the sequence\nof cumulative average differences\n%\n\\begin{equation}\n\\label{cumulative}\nC_j = \\frac{1}{n} \\sum_{k=0}^{j-1} D_k\n\\end{equation}\n%\nfor $j = 1$, $2$, \\dots, $n$,\nwhere $n$ is the length of the sequence $D_0$,~$D_1$, \\dots, $D_{n-1}$\nfrom the previous step. Supplement $C_1$, $C_2$, \\dots, $C_n$ with\n%\n\\begin{equation}\n\\label{cumulative0}\nC_0 = 0.\n\\end{equation}\n%\n\\end{enumerate}\n\n\nFigure~\\ref{partition} illustrates Steps~1--4,\nwhile Figure~\\ref{diffs} illustrates Step~5.\nThe increment in the expected cumulative average difference\nfrom $j = k$ to $j = k+1$ is\n%\n\\begin{equation}\n\\label{fundamental}\n\\E[ C_{k+1} - C_k ] = \\frac{\\E[D_k]}{n},\n\\end{equation}\n%\nso that the expected slope of a graph of $C_k$ versus $k/n$ is\n%\n\\begin{equation}\n\\label{delta}\n\\Delta_k = \\E[D_k],\n\\end{equation}\n%\nwhich is simply the expected value of the difference\nbetween the two subpopulations.\nThus, {\\it the slope of a secant line over a long range of $k/n$\nfor the graph of $C_k$ versus $k/n$ becomes the average difference\nin responses between the subpopulations}.\n\nFigure~\\ref{ex0} presents a synthetic example\nfrom Subsection~\\ref{synthetic} below for which the ground-truth\nis known explicitly.\nIn accord with~(\\ref{fundamental}),\nthe topmost plots (a and b) of Figure~\\ref{ex0}\ndisplay deviation between the two subpopulations over a range of scores\nas the expected slope of the secant line for the graph\nover that range of scores, as a function of the index $k/n$\ngiven along the horizontal axis.\nAs mentioned in the introduction,\nlong ranges of steep slopes correspond to ranges of scores for which\nthe average responses are significantly different\nbetween the two subpopulations,\nwith the triangle along the vertical axis on the left of each plot\nindicating the magnitude of the deviation across the full range of scores\nthat would be statistically significant at around the 95\\% confidence level.\nSubsection~\\ref{significance} below provides details\non statistical significance and the computation of the triangle's height.\n\n\n\\begin{remark}\nThe blocked sequence of responses is\n$R^0_0$, $R^1_0$, $R^0_1$, $R^1_1$, $R^0_2$, $R^1_2$, \\dots.\nThe backward differences are\n%\n\\begin{equation}\n\\label{back0}\nR^0_k - R^1_k\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n\\label{back1}\nR^1_k - R^0_{k+1},\n\\end{equation}\n%\nwhile the forward differences are\n%\n\\begin{equation}\n\\label{forward0}\nR^0_{k+1} - R^1_k\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n\\label{forward1}\nR^1_{k+1} - R^0_{k+1},\n\\end{equation}\n%\nso that $D_{2k}$ from~(\\ref{diff_even}) is the average of~(\\ref{back0})\nand~(\\ref{forward0}) while $D_{2k+1}$ from~(\\ref{diff_odd}) is the negative\nof the average of~(\\ref{back1}) and~(\\ref{forward1}).\nThe reason for $D_{2k+1}$ to be the negative\nis to align with $D_{2k}$ when summing them in~(\\ref{cumulative})\n--- the differences need to be in the same direction for the sum to make sense,\nand the negative synchronizes the directions of the differences\n(which would otherwise be alternating or staggered in the sequence);\nwith the negative, the differences always compare\nsubpopulation 0 to subpopulation 1, in that order.\n\\end{remark}\n\n\\begin{remark}\nIn the absence of any reason to prefer backward differences\nto forward differences (or vice versa),\nwe opt to average the two possibilities together.\nIn the absence of any reason to prefer entries in the sequence\nwith even indices ($D_0$, $D_2$, $D_4$, \\dots) to entries with odd indices\n($D_1$, $D_3$, $D_5$, \\dots), we include both.\n\\end{remark}\n\n\n\\begin{figure}\n\\begin{centering}\n\\hfil\\parbox{0.65\\textwidth}\n{\\includegraphics[width=0.65\\textwidth]{./figures/partition.pdf}}\n\\end{centering}\n\\caption{The crosses (``x'') indicate the scores for subpopulation 0\nwhile the circles (``o'') indicate the scores for subpopulation 1.\nThe averages of the scores for subpopulation 0 for the indicated blocks\nof observed scores are $S^0_0$, $S^0_1$, \\dots, $S^0_9$,\nwhile the averages of the scores for subpopulation 1 are\n$S^1_0$, $S^1_1$, \\dots, $S^1_9$.\nThe averages of the responses for subpopulation 0 corresponding\nto the indicated blocks of observed scores are\n$R^0_0$, $R^0_1$, \\dots, $R^0_9$, while the averages of the responses\nfor subpopulation 1 are $R^1_0$, $R^1_1$, \\dots, $R^1_9$.\nThe scores need not range from 0 to 1 as in the present figure,\nbut that is a common case.\n}\n\\label{partition}\n\\end{figure}\n\n\n\\begin{figure}\n\\vspace{.2in}\n\\begin{centering}\n\\hfil\n(a) \\parbox{0.111\\textwidth}\n{\\includegraphics[width=0.111\\textwidth]{./figures/diffs0.pdf}}\n\\hfil\n(b) \\parbox{0.111\\textwidth}\n{\\includegraphics[width=0.111\\textwidth]{./figures/diffs1.pdf}}\n\\end{centering}\n\\caption{In each of these subfigures, the operation indicated by ``$+$'' sums\nits two inputs and the operations indicated by ``$-$'' subtract their inputs,\nwith one of these ``$-$'' operations subtracting its rightmost input\nfrom its leftmost input, while the other subtracts its leftmost input\nfrom its rightmost input.\nIn all cases, the operations indicated by ``$-$'' subtract\nsubpopulation 1 from subpopulation 0, in that order.\nThe operation indicated by ``$\\div 2$'' divides its input by 2.\nThese subfigures depict visually formulae~(\\ref{diff_even})\nand~(\\ref{diff_odd}), respectively.\n}\n\\label{diffs}\n\\end{figure}\n\n\n\\subsection{Scalar summary statistics}\n\\label{scalarstats}\n\nThis subsection constructs standardized statistics\nwhich summarize in single scalars the plots of the previous subsection.\n\nTwo standard metrics for the overall deviation between the two subpopulations\nover the full range of scores\nand that take into account expected random fluctuations are that due\nto Kolmogorov and Smirnov, the maximum absolute deviation\n%\n\\begin{equation}\n\\label{Kolmogorov-Smirnov}\nG = \\max_{1 \\le k \\le n} |C_k|,\n\\end{equation}\n%\nand that due to Kuiper, the size of the range of the deviations\n%\n\\begin{equation}\n\\label{Kuiper}\nH = \\max_{0 \\le k \\le n} C_k - \\min_{0 \\le k \\le n} C_k,\n\\end{equation}\n%\nwhere $C_0$ is defined in~(\\ref{cumulative0})\nand $C_1$, $C_2$, \\dots, $C_n$ are defined in~(\\ref{cumulative}).\nUnder appropriate statistical models,\n$G$ and $H$ can form the basis for tests of statistical significance,\nthe context in which they originally appeared;\nsee, for example, Section~14.3.4 of~\\cite{press-teukolsky-vetterling-flannery}.\nTo assess statistical significance (rather than absolute effect size),\n$G$ and $H$ should be rescaled larger by a factor proportional to $\\sqrt{n}$;\nfurther discussion of the rescaling is available in the next subsection.\nNeedless to say, if the graph constructed in the previous subsection\nis fairly flat for all scores (which indicates a lack of deviation\nbetween the subpopulations for all scores),\nthen both the maximum absolute deviation of the graph and the size of the range\nof deviations ($G$ and $H$, respectively) will be close to 0.\nThe captions of the figures report the values of these scalar statistics\nfor numerical examples.\n\n\\begin{remark}\nRemark~1 of~\\cite{tygert} explains the reason for including $C_0$\nin the definition of Kuiper's statistic $H$ in~(\\ref{Kuiper}),\nas well as why $H$ is often slightly preferable to $G$.\n\\end{remark}\n\n\n\\subsection{Significance of stochastic fluctuations}\n\\label{significance}\n\nThis subsection discusses statistical significance\nboth for the graphical methods of Subsection~\\ref{unweighted}\nand for the summary statistics of Subsection~\\ref{scalarstats}.\n\nThe graph of $C_k$ as a function of $k/n$ generally displays\nsome ``confidence bands'' due to $C_k$ fluctuating randomly\nas the index $k$ increments; the ``thickness'' of the plot\narising from the random fluctuations gives some sense of ``error bars.''\nTo indicate the rough size of the fluctuations\nof the maximum deviation expected under the hypothesis that\nthe actual underlying response distributions of the two subpopulations\nare the same, the plots should include a triangle centered at the origin\nwhose height above the origin is proportional to $1/\\sqrt{n}$.\nThe triangle is similar to the conventional confidence bands\naround an empirical cumulative distribution function\nintroduced by Kolmogorov and Smirnov, as reviewed by~\\cite{doksum}\n--- a driftless, purely random walk deviates from zero\nby roughly $\\sqrt{n}$ after $n$ steps, so a random walk scaled by $1/n$\ndeviates from zero by roughly $1/\\sqrt{n}$.\nIdentification of deviation between the two subpopulations\nis reliable when focusing on long ranges of steep slopes\n(as a function of $k/n$) for $C_k$; the triangle gives a sense\nof the length scale for the largest stochastic variations that\nare likely to happen even when there is no underlying deviation\nbetween the subpopulations. The remainder of the present subsection\nderives this conservative upper bound on the length scale\nin cases for which the value of every observed response is either 0 or 1.\n\nThe long-range deviations of $C_0$, $C_1$, $C_2$, \\dots, $C_n$ from zero\ncan be biased even when the two subpopulations are drawn\nfrom the same underlying distribution as a function of score;\nhowever, the use of centered, second-order differences in~(\\ref{diff_even})\nand~(\\ref{diff_odd}) makes this a second-order effect.\nIn the sequel, we make two assumptions about bias:\n\\{1\\} the bias arising from averaging together multiple responses\nat slightly different scores into a single $R^0_k$ or $R^1_k$ is offset\nby the reduction in variance due to the averaging, and\n\\{2\\} the bias arising from taking differences of responses\nfrom the different subpopulations at slightly different scores\nis negligible in comparison with the square root of the accumulated variance.\nThe first assumption can be especially reasonable when the scores\nconsidered for a single $R^0_k$ or $R^1_k$\nare in reality drawn at random from some probability distribution,\nsuch that the variance in the probabilities of success\nfor the associated Bernoulli responses is comparable\nto the variance of a Bernoulli variate with a given probability of success.\nIn such cases, the first assumption permits us to regard each $R^0_k$\nor $R^1_k$ as contributing no more to the long-range deviation\nthan a single Bernoulli variate would.\nThe second assumption means that we will neglect\nthe second-order effect of accumulated bias,\nwhich is often reasonable due to the use of second-order differences\nin~(\\ref{diff_even}) and~(\\ref{diff_odd}).\n\nIn cases for which the value of every observed response is either 0 or 1,\nthe tip-to-tip height of the triangle centered at the origin should be $8/n$\ntimes the standard deviation of the sum of $n$ independent Bernoulli variates.\nThis is simply $8/n$ times the square root of the sum of the variances\nof $n$ Bernoulli variates, which could be at most\n$(8/n)(\\sqrt{n/4}) = 4\\sigma$, where\n%\n\\begin{equation}\n\\label{stddev}\n\\sigma = \\frac{1}{\\sqrt{n}},\n\\end{equation}\n%\nsince the variance of a Bernoulli variate is $p(1-p) \\le 1/4$,\nwhere $p$ is the unknown probability of success.\nNote that the factor 8 incorporates a factor of 2 for the triangle\nextending both above and below the origin, a factor of 2 to extend\nfor 2 standard deviations rather than just 1\n(setting the confidence level at approximately 95\\%), a factor of $\\sqrt{2}$\ndue to the dependency between the even- and odd-indexed entries\nin the sequence of second-order differences from~(\\ref{diff_even})\nand~(\\ref{diff_odd}), and a factor of $\\sqrt{2}$ to account\nfor having 2 independently drawn subpopulations.\nNeedless to say, the upper bound of $4\\sigma$ is often somewhat loose\nin practice, as the two assumptions discussed in the previous paragraph\nyield rather conservative guarantees.\nTighter bounds may exist in settings for which the scores are drawn\nfrom a specified probability distribution\n(unlike in the setting of the present paper).\n\n\n\\subsection{Weighted sampling}\n\\label{weighted}\n\nThis subsection presents the general case in which the observations\ncome with weights, where each weight is a positive real number\nassociated with the corresponding observation.\nSubsection~\\ref{unweighted} treats the special case of unweighted\n(or, equivalently, uniformly or equally weighted) observations,\nwhich is simpler.\n\nThe weighted case uses the same procedure as in Subsection~\\ref{unweighted},\nbut with $S^0_k$, $S^1_k$, $R^0_k$, and $R^1_k$ being weighted averages rather\nthan unweighted averages (the weighted average for each $S^0_k$, $S^1_k$,\n$R^0_k$, and $R^1_k$ should be normalized separately).\nThen, we define $T_{2k}$ to be the average of the weights associated\nwith the scores whose weighted average is $S^0_k$,\nand define $T_{2k+1}$ to be the average of the weights associated\nwith the scores whose weighted average is $S^1_k$.\nSetting $W_k$ to be the sum of the weights associated\nwith $D_k$ defined in~(\\ref{diff_even}) and~(\\ref{diff_odd}), that is,\n%\n\\begin{equation}\n\\label{aggregatew}\nW_k = T_k + 2T_{k+1} + T_{k+2},\n\\end{equation}\n%\nthe formula~(\\ref{cumulative}) generalizes to\n%\n\\begin{equation}\n\\label{cumulativew}\nC_j = \\frac{\\sum_{k=0}^{j-1} W_k D_k}{\\sum_{k=0}^{n-1} W_k}\n\\end{equation}\n%\nfor $j = 1$, $2$, \\dots, $n$,\nwhile $C_0 = 0$ exactly as before in formula~(\\ref{cumulative0}).\nIn the weighted case, the abscissae (that is, the horizontal coordinates)\nfor the graph consist of the normalized aggregated weights\n%\n\\begin{equation}\n\\label{abscissae}\nA_j = \\frac{\\sum_{k=0}^{j-1} W_k}{\\sum_{k=0}^{n-1} W_k}\n\\end{equation}\n%\nfor $j = 1$, $2$, \\dots, $n$, and\n%\n\\begin{equation}\nA_0 = 0.\n\\end{equation}\n%\nThe original, unweighted procedure of Subsection~\\ref{unweighted}\nyields precisely the same results as the weighted procedure\nof the present subsection in the special case that the weights\nfor the original observations are all the same.\n\nThe increment in the expected cumulative weighted average difference\nfrom $j = k$ to $j = k+1$ is\n%\n\\begin{equation}\n\\label{fundamentalw}\n\\E[ C_{k+1} - C_k ] = \\frac{W_k \\E[D_k]}{\\sum_{j=0}^{n-1} W_j},\n\\end{equation}\n%\nwhile the increment in the normalized aggregated weights\nfrom $j = k$ to $j = k+1$ is\n%\n\\begin{equation}\n\\label{fundamentala}\nA_{k+1} - A_k = \\frac{W_k}{\\sum_{j=0}^{n-1} W_j},\n\\end{equation}\n%\nso that the expected slope of a graph of $C_k$ versus $A_k$ is\nthe ratio of~(\\ref{fundamentalw}) to~(\\ref{fundamentala}), that is,\n%\n\\begin{equation}\n\\label{deltaw}\n\\Delta_k = \\E\\left[\\frac{C_{k+1} - C_k}{A_{k+1} - A_k}\\right] = \\E[D_k],\n\\end{equation}\n%\nwhich is none other than the expected value\nof the difference between the two subpopulations.\nThus, {\\it the slope of a secant line over a long range of $k$\nfor the graph of $C_k$ versus $A_k$ becomes the average difference\nin responses between the subpopulations}.\n\nThe scalar summary statistics in the weighted case are given\nby the same formulae from Subsection~\\ref{scalarstats}\nas for the unweighted case, just using $C_j$ from~(\\ref{cumulativew})\nin place of $C_j$ from~(\\ref{cumulative}).\nIn cases for which the value of every observed response is either 0 or 1,\nthe tip-to-tip height of the triangle centered at the origin\nanalogous to that from Subsection~\\ref{significance}\ncould be set conservatively at $4\\sigma$, where\n%\n\\begin{equation}\n\\label{stddevw}\n\\sigma = \\frac{\\sqrt{\\sum_{k=0}^{n-1} (W_k)^2}}{\\sum_{k=0}^{n-1} W_k},\n\\end{equation}\n%\nwhich is an upper bound on the worst case under the same two assumptions\nas in Subsection~\\ref{significance}.\n\n\n\\begin{remark}\n\\label{weightedremark}\nThe classical methods for reliability diagrams discussed in the introduction\neasily adapt to the case of weighted sampling.\nRather than plotting the plain, unweighted average of responses\nagainst the unweighted average of scores in each bin,\nthe weighted case involves plotting the weighted average of responses\nagainst the weighted average of scores in each bin.\nTwo natural choices of bins in the weighted case are\n\\{1\\} make the widths of the bins all be the same or\n\\{2\\} use the binning of the following remark (Remark~\\ref{equierrs}).\nAs in the unweighted case, the second choice can adapt to each subpopulation\nunder consideration, with each subpopulation having its own binning.\n\\end{remark}\n\n\n\\begin{remark}\n\\label{equierrs}\nIn the case of weighted sampling, the most useful reliability diagrams\nare usually those entitled,\n``reliability diagram ($\\|W\\|_2/\\|W\\|_1$ is similar for every bin).''\nThese diagrams construct bins such that, for every bin,\nthe ratio of the sum of the squares of the bin's weights\nto the square of the sum of the bin's weights is similar for every bin.\nRemark~5 of~\\cite{tygert} details the specific procedure employed\nfor setting the bins.\n\\end{remark}\n\n\n\n\\section{Results and discussion}\n\\label{results}\n\n\nThis section illustrates via numerous examples\nthe previous section's methods, including comparisons\nwith the canonical plots --- the ``reliability diagrams'' ---\ndiscussed in the introduction.\\footnote{Permissively licensed open-source\nsoftware that can automatically reproduce all figures and statistics reported\nin the present paper is available at\n\\url{https://github.com/facebookresearch/fbcddisgraph}}\nSubsection~\\ref{synthetic} presents several synthetic examples.\nSubsection~\\ref{imagenetex} gives examples\nfrom a popular, unweighted data set of images, ImageNet.\nSubsection~\\ref{census} considers a weighted data set,\nthe year 2019 American Community Survey of the United States Census Bureau.\nFinally, Subsection~\\ref{caution} issues a warning\nabout possible overinterpretations of the plots (both for the cumulative graphs\nand for the classical reliability diagrams)\nand suggests following~\\cite{tygert} by comparing a subpopulation\nto the full population (when apposite).\n\nThe figures display the reliability diagrams\n(that is, the classical calibration plots)\nas well as both the graphs of cumulative differences and the exact expectations\nin the absence of the random sampling's noise (the figures include\nthe exact expectations only when they are known, as for the synthetic data).\nThe captions of the figures discuss the numerical results depicted.\n\nThe title, ``subpopulation deviation is the slope as a function of $k/n$,''\nlabels a plot of $C_k$ from~(\\ref{cumulative}) as a function of $k/n$.\nIn each such plot, the upper axis specifies $k/n$,\nwhile the lower axis specifies the score for the corresponding value of $k$.\nThe title, ``subpopulation deviation is the slope as a function of $A_k$,''\nlabels a plot of $C_k$ from~(\\ref{cumulativew}) versus \nthe cumulative weight $A_k$ from~(\\ref{abscissae}).\nIn each such plot, the major ticks on the upper axis specify $k/n$,\nwhile the major ticks on the lower axis specify the score\nfor the corresponding value of $k$; the points in the plot\nare the ordered pairs $(A_k, C_k)$ for $k = 1$,~$2$, \\dots, $n$,\nwith $A_k$ being the abscissa and $C_k$ being the ordinate.\n(The abscissa is the horizontal coordinate;\nthe ordinate is the vertical coordinate.)\n\nIn all cases, if the second subpopulation ends up being subpopulation 0\nin the notation of Section~\\ref{methods}, then the cumulative graph technically\nactually plots $-C_k$ rather than $C_k$\n(in the same notation of Section~\\ref{methods}).\n\nThe titles, ``reliability diagram,''\n``reliability diagram (equal number of subpopulation scores per bin),''\nand ``reliability diagram ($\\|W\\|_2/\\|W\\|_1$ is similar for every bin),''\nlabel plots of the pairs from the introduction (in the unweighted case)\nor from Remark~\\ref{weightedremark} (in the case of weighted sampling),\nwith the pairs from the first subpopulation in black\nand the pairs from the second subpopulation in gray.\n\nIn the traditional, binned plots,\nwe vary the number of bins to see how the plotted values vary.\nDisplaying the bin frequencies is another way to indicate uncertainties,\nas suggested, for example, by~\\cite{murphy-winkler}.\nStill other possibilities for uncertainty quantification could use\nkernel density estimation, as suggested, for example,\nby~\\cite{brocker}, \\cite{srihera-stute}, and~\\cite{wilks}.\nSuch uncertainty estimates involve setting widths for the bins\nor kernel smoothing; such settings are fairly arbitrary\nand actually unnecessary when varying the widths as in the plots\nof the present paper.\nA comprehensive review of the various possibilities is available\nin Chapter~8 of~\\cite{wilks}.\n\nAs the introduction discusses, there are two standard choices for the bins\nwhen the sampling is unweighted (or uniformly weighted):\n\\{1\\} make the average of the scores in each bin\nbe roughly equidistant from the average of the scores\nin each neighboring bin or\n\\{2\\} make the number of scores in every bin\n(except perhaps for the last) be the same.\nThe figures label the first, more conventional possibility\nwith the short title, ``reliability diagram,'' and the second possibility\nwith the longer title,\n``reliability diagram (equal number of subpopulation scores per bin).''\nAs noted in Remark~\\ref{weightedremark}, there are two typical choices\nfor the bins when the sampling is weighted:\n\\{1\\} make the weighted average of the scores in each bin\nbe roughly equidistant from the weighted average of the scores\nin each neighboring bin or\n\\{2\\} follow Remark~\\ref{equierrs} above.\nThe figures label the first possibility with the short title,\n``reliability diagram,'' and the second possibility\nwith the longer title,\n``reliability diagram ($\\|W\\|_2/\\|W\\|_1$ is similar for every bin).''\n\nNeedless to say, reliability diagrams with fewer bins provide estimates\nthat are less noisy, at the cost of restricting the resolution\nfor detecting deviations and for resolving variations\nas a function of the score.\n\n\n\\subsection{Synthetic}\n\\label{synthetic}\n\nThis subsection presents several toy examples\nthat consider instructive ``ground-truth'' statistical models\nand generate observations at random from them.\nThe examples set values for the scores and expected values of the responses,\nand then independently draw the observed responses\nfrom the Bernoulli distributions whose probabilities of success\nare those expected values.\n\nEach top row of Figures~\\ref{ex0} and \\ref{ex1}--\\ref{ex3}\nplots $C_1$, $C_2$, \\dots, $C_n$\nfrom~(\\ref{cumulative}) as a function of $k/n$,\nwith the rightmost plot displaying its noiseless expected value\nrather than using the random observations ($R^0_k$ and $R^1_k$).\n(Technically speaking, the top row of Figure~\\ref{ex2} actually plots\n$-C_1$, $-C_2$, \\dots, $-C_n$, since for Figure~\\ref{ex2}\nthe second subpopulation ends up being subpopulation 0\nin the notation of Section~\\ref{methods}.)\nEach bottom row of Figures~\\ref{ex0} and \\ref{ex1}--\\ref{ex3} plots the pairs\nof scores and expected values for the first subpopulation in black,\nand plots the pairs for the second subpopulation in gray,\nproducing ground-truth diagrams that the middle two rows of plots\nare trying to estimate using only the observations,\nwithout access to the underlying probabilities.\n\nThe first three examples include substantial deviations\nin the expected responses between the two subpopulations,\nwhile the fourth example omits any deviation\nin the expected responses between the two subpopulations.\nThe first three examples illustrate how well the various plots can detect\nsubstantial deviations, while the fourth example illustrates how the plots look\nin the absence of any deviation.\n\nFor the first example, corresponding to Figure~\\ref{ex0},\nthe scores for the first subpopulation\nare $0.5 (1 + 2^3 (x - 0.5)^3)$ for 10,000 values of $x$\ndrawn uniformly at random from the unit interval $[0, 1]$,\nwhereas the scores for the second subpopulation are 7,000 values\ndrawn uniformly at random from the unit interval $[0, 1]$\n(the latter values are also equal to $0.5 (1 + 2 (x - 0.5))$\nfor 7,000 values of $x$ drawn uniformly at random from the unit interval\n$[0, 1]$).\nThe expected values are as indicated in the lowermost plot of Figure~\\ref{ex0},\nwith the expected values for each subpopulation varying smoothly\nas a function of the score, aside from swapping the values between\nthe two subpopulations for scores in a short range near 0.9.\nThe deviation in the expected values between the subpopulations\nis substantial for this example.\n\nFor the second example, corresponding to Figure~\\ref{ex1},\nthe scores for the first subpopulation\nare $x^5$ for 10,000 values of $x$\ndrawn uniformly at random from the unit interval $[0, 1]$,\nwhereas the scores for the second subpopulation are 7,000 values\ndrawn uniformly at random from the unit interval $[0, 1]$.\nThe expected values are as indicated in the lowermost plot of Figure~\\ref{ex1},\nwith several discontinuities in the expected values.\nThe deviation in the expected values between the subpopulations\nis substantial for this example, too.\n\nFor the third example, corresponding to Figure~\\ref{ex2},\nthe scores for the first subpopulation\nare $0.5 (1 + 2^{1/3} (x - 0.5)^{1/3})$ for 10,000 values of $x$\ndrawn uniformly at random from the unit interval $[0, 1]$,\nwhereas the scores for the second subpopulation are 7,000 values\ndrawn uniformly at random from the unit interval $[0, 1]$\n(the latter values are also equal to $0.5 (1 + 2 (x - 0.5))$\nfor 7,000 values of $x$ drawn uniformly at random from the unit interval\n$[0, 1]$).\nThe lowermost plot of Figure~\\ref{ex2} displays the expected values,\nwith the expected values for the first subpopulation varying sinusoidally\nwithin an envelope bounded below by 0 and bounded above by the diagonal line\non the plot extending from the origin $(0, 0)$ to the point $(1, 1)$,\nand with the expected values for the second subpopulation drawn uniformly\nat random from the unit interval $[0, 1]$.\nThe deviation in the expected values between the subpopulations\nis substantial for this example, as well.\n\nFor the fourth example, corresponding to Figure~\\ref{ex3},\nthe scores are the same as in the first example,\nand the expected values are equal to the scores.\nSince the expected values are equal to the scores, the expected values\nare given by the same function of the score for both subpopulations,\nand thus there is no deviation between the expected responses\nfor the subpopulations in this example.\n\nThe captions of the figures comment on the numerical results displayed.\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_1/cumulative.pdf}}\n\\quad\\quad\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_1/cumulative_exact.pdf}}\n\n\\vspace{\\vertsep}\n\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_1/equisamps.pdf}}\n\\quad\\quad\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_1/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_1/equisamps.pdf}}\n\\quad\\quad\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_1/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_1/exact.pdf}}\n\n\\end{centering}\n\\caption{$n =$ 5,472; Kuiper's statistic is $0.1531 / \\sigma = 11.32$,\n         Kolmogorov's and Smirnov's is $0.1531 / \\sigma = 11.32$;\n         the reliability diagrams all have trouble resolving the sharp behavior\n         corresponding to the relatively sharp corners in the cumulative graphs\n         (a and b), though the reliability diagram with 50 bins that\n         has an equal number of subpopulation scores per bin (e) is decent.\n         The metrics of Kuiper and of Kolmogorov and Smirnov\n         report extremely statistically significant deviation,\n         taking values of many times $\\sigma$.\n}\n\\label{ex1}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_2/cumulative.pdf}}\n\\quad\\quad\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_2/cumulative_exact.pdf}}\n\n\\vspace{\\vertsep}\n\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_2/equisamps.pdf}}\n\\quad\\quad\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_2/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_2/equisamps.pdf}}\n\\quad\\quad\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_2/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_2/exact.pdf}}\n\n\\end{centering}\n\\caption{$n =$ 6,637; Kuiper's statistic is $0.2730 / \\sigma = 22.24$,\n         Kolmogorov's and Smirnov's is $0.2730 / \\sigma = 22.24$;\n         the reliability diagrams with 10 bins each (c and d) smooth\n         the black curve too much, while the reliability diagrams\n         with 50 bins each (e and f) display overly noisy variations\n         in the gray curve. The empirical cumulative graph (a) matches\n         its ground-truth expectations (b) well, though the oscillations\n         at low scores are a bit hard to discern in the cumulative graphs.\n         The metrics of Kuiper and of Kolmogorov and Smirnov\n         report profoundly statistically significant deviation,\n         taking values many times larger than $\\sigma$.\n}\n\\label{ex2}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_3/cumulative.pdf}}\n\\quad\\quad\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_3/cumulative_exact.pdf}}\n\n\\vspace{\\vertsep}\n\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_3/equisamps.pdf}}\n\\quad\\quad\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_3/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_3/equisamps.pdf}}\n\\quad\\quad\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_50_3/equiscore.pdf}}\n\n\\vspace{\\vertsep}\n\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/10000_7000_10_3/exact.pdf}}\n\n\\end{centering}\n\\caption{$n =$ 6,451; Kuiper's statistic is $0.01429 / \\sigma = 1.148$,\n         Kolmogorov's and Smirnov's is $0.01046 / \\sigma = 0.8402$;\n         the stochastic variations in the empirical cumulative graph (a)\n         are clearly within the expectations indicated by the triangle\n         at the origin --- the graph looks like a perfectly random walk,\n         and indeed really is a drift-free, perfectly random walk.\n         The statistics of Kuiper and of Kolmogorov and Smirnov\n         give no indication of any statistically significant deviation\n         between the subpopulations, as both are less than $1.25 \\sigma$ ---\n         the expected value for the metric of Kolmogorov and Smirnov\n         in the absence of any deviation between the subpopulations'\n         expected responses, as detailed by Remark~2 of~\\cite{tygert}.\n}\n\\label{ex3}\n\\end{figure}\n\n\n\n\\subsection{ImageNet}\n\\label{imagenetex}\n\nThis subsection applies the methods of Section~\\ref{methods}\nto the training data set ``ImageNet-1000'' of~\\cite{imagenet},\nwhich contains a thousand labeled classes.\nEach class forms a natural subpopulation to consider,\nwith each class considered consisting of 1,300 images of a particular noun\n(such as a ``cheetah,'' a ``night snake,'' or an ``Eskimo Dog or Husky'').\nThe total number of members of the data set over all classes is 1,281,167,\nas some classes in the data set contain fewer than 1,300 images,\nbut each subpopulation considered below comes from a class with 1,300 images.\nThe images are unweighted (or, equivalently, uniformly or equally weighted),\nnot requiring the methods of Subsection~\\ref{weighted} above.\nWe calculate the scores using the pretrained ResNet18 classifier\nof~\\cite{he-zhang-ren-sun} from the computer-vision module, ``torchvision,''\nin the PyTorch software library of~\\cite{pytorch};\nthe score for an image is the negative of the natural logarithm\nof the probability assigned by the classifier\nto the class predicted to be most likely,\nwith the scores randomly perturbed by about one part in $10^8$ to guarantee\ntheir uniqueness.\nThe response (also known as ``result'' or ``outcome'') corresponding\nto a given score takes the value 1 when the class predicted to be most likely\nis the correct class; the response takes the value 0 otherwise.\nFigures~\\ref{Eskimo-dog-husky_cheetah}--\\ref{monarch-butterfly_wild-boar}\npresent three examples; the captions first list the names of the classes\nfor the subpopulations and then compare the different kinds of plots.\n\n\n\n\\clearpage\n\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatus.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequisamps10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequiscore10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequisamps30.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequiscore30.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequisamps50.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-248-Eskimo-dog-husky_293-cheetah-chetah-Acinonyx-jubatusequiscore50.pdf}}\n\n\\end{centering}\n\\caption{Eskimo Dog (or Husky) vs.\\ Cheetah (Acinonyx jubatus); $n =$ 455;\n         Kuiper's statistic is $0.3738 / \\sigma = 7.974$,\n         Kolmogorov's and Smirnov's is $0.3738 / \\sigma = 7.974$;\n         in this case, the reliability diagrams with many bins can resolve\n         the phenomena displayed in the graph of cumulative differences (a),\n         but only by sacrificing confidence in their estimates,\n         as they exhibit wild fluctuations.\n         The metrics of Kuiper and of Kolmogorov and Smirnov both report\n         extremely statistically significant deviations\n         between the subpopulations.\n}\n\\label{Eskimo-dog-husky_cheetah}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequisamps10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequiscore10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequisamps30.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequiscore30.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequisamps50.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-60-night-snake-Hypsiglena-torquata_323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippusequiscore50.pdf}}\n\n\\end{centering}\n\\caption{Night snake (Hypsiglena torquata) vs.\\ Monarch (or milkweed) butterfly\n         (Danaus plexippus); $n =$ 304;\n         Kuiper's statistic is $0.3138 / \\sigma = 5.471$,\n         Kolmogorov's and Smirnov's is $0.3138 / \\sigma = 5.471$;\n         the lack of deviation at large scores is hard to detect\n         without 30 bins or more (d, e, f, and g),\n         but then the reliability diagrams are too noisy for other scores.\n         Moreover, the diagrams with only 10 or 30 bins (b, c, d, and e)\n         smooth away the extreme deviation for the lowest scores.\n         The graph of cumulative differences (a) captures all phenomena nicely\n         simultaneously. The statistics of Kuiper and of Kolmogorov and Smirnov\n         both report very highly statistically significant deviations\n         between the subpopulations.\n}\n\\label{night-snake_monarch-butterfly}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofa.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequisamps10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequiscore10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequisamps30.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequiscore30.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequisamps50.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/unweighted/nll-1-323-monarch-monarch-butterfly-milkweed-butterfly-Danaus-plexippus_342-wild-boar-boar-Sus-scrofaequiscore50.pdf}}\n\n\\end{centering}\n\\caption{Monarch (or milkweed) butterfly (Danaus plexippus) vs.\n         Wild boar (Sus scrofa); $n =$ 315;\n         Kuiper's statistic is $0.1292 / \\sigma = 2.294$,\n         Kolmogorov's and Smirnov's is $0.1292 / \\sigma = 2.294$;\n         the reliability diagrams with 30 bins or less (b, c, d, and e)\n         underestimate (or fail to resolve) the extreme deviation\n         at the lowest scores, whereas the diagrams with 50 bins (f and g)\n         are far too noisy for the other scores.\n         The graph of cumulative differences (a) resolves\n         all these behaviors clearly.\n         The metrics of Kuiper and of Kolmogorov and Smirnov both report\n         somewhat statistically significant deviations\n         between the subpopulations, though much less extreme than in\n         Figures~\\ref{Eskimo-dog-husky_cheetah}\n         and~\\ref{night-snake_monarch-butterfly}.\n}\n\\label{monarch-butterfly_wild-boar}\n\\end{figure}\n\n\n\n\\subsection{American Community Survey of the U.S. Census Bureau}\n\\label{census}\n\nThis subsection applies the methods of Subsection~\\ref{weighted}\nto the latest (year 2019) microdata from the American Community Survey\nof the United States Census Bureau;\\footnote{All microdata\nfrom the United States Census Bureau's American Community Survey of 2019\nis available for download at\n\\url{https://www.census.gov/programs-surveys/acs/microdata.html}}\nspecifically, we consider each subpopulation to be the observations\nfrom a county in California. The sampling in this survey is weighted,\nand we retain only those members whose weights (``WGTP'' in the microdata)\nare nonzero, omitting any member whose household personal income\n(``HINCP'') is zero or for which the adjustment factor to income (``ADJINC'')\nis missing. The scores are the logarithm to base 10\nof the adjusted household personal income\n(the adjusted income is ``HINCP'' times ``ADJINC,'' divided by one million\nwhen ``ADJINC'' omits its decimal point in the integer-valued microdata),\nand we randomly perturb the scores by about one part in $10^8$ to guarantee\ntheir uniqueness.\nThe response (also known as ``result'' or ``outcome'') for a given score\ntakes the value 1 when the corresponding household has limited English speaking\n(limited English speaking refers to a household in which every member\nstrictly older than 13 has some difficulty speaking English);\nthe response takes the value 0\nwhen the corresponding household is fully English speaking.\nTable~\\ref{sizes} lists the numbers of scores in the subpopulations\nprior to any binning.\nFigures~\\ref{Alameda-Placer}--\\ref{Riverside-Butte} present several examples;\nthe captions first list the names of the counties corresponding\nto the subpopulations considered and then compare the reliability diagrams\nwith the cumulative graph.\n\n\n\\begin{table}\n\\caption{Numbers of observations in the original data sets}\n\\label{sizes}\n\\begin{center}\n\\begin{tabular}{rrr}\n\\hline\nnumber of & number of scores for & number of scores for \\\\\nthe figure & the first subpop. & the second subpop. \\\\\\hline\n\\ref{ex0}, \\ref{ex1}, \\ref{ex2}, \\ref{ex3} & 10,000 & 7,000 \\\\\n\\ref{Eskimo-dog-husky_cheetah}, \\ref{night-snake_monarch-butterfly},\n\\ref{monarch-butterfly_wild-boar} & 1,300 & 1,300 \\\\\n\\ref{Alameda-Placer} & 6,415 & 1,616 \\\\\n\\ref{San_Francisco-Kern} & 3,440 & 2,276 \\\\\n\\ref{San_Francisco-Contra_Costa} & 3,440 & 3,697 \\\\\n\\ref{San_Francisco-San_Joaquin} & 3,440 & 2,282 \\\\\n\\ref{San_Francisco-San_Mateo} & 3,440 & 2,888 \\\\\n\\ref{Riverside-Butte} & 7,826 & 843 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n%\n\\vspace{-1.5em}\n%\n\\end{table}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Alameda_vs_Placer-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{Alameda County vs.\\ Placer County; $n =$ 2,536;\n         Kuiper's statistic is $0.05192 / \\sigma = 2.450$,\n         Kolmogorov's and Smirnov's is $0.05192 / \\sigma = 2.450$;\n         the behavior for small scores is interesting,\n         as the cumulative graph (a) shows a big spike\n         at the very lowest scores and then a very flat part, and\n         only the reliability diagrams with 100 bins (f and g) reflect those.\n         Yet the latter reliability diagrams are very, very noisy\n         for the other scores. \n         The metrics of Kuiper and of Kolmogorov and Smirnov report\n         mildly statistically significant deviation between the subpopulations.\n}\n\\label{Alameda-Placer}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Kern-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{San Francisco County vs.\\ Kern County; $n =$ 2,260;\n         Kuiper's statistic is $0.07882 / \\sigma = 3.454$,\n         Kolmogorov's and Smirnov's is $0.07863 / \\sigma = 3.445$;\n         only the cumulative graph (a) and the reliability diagrams\n         with 100 bins (f and g) resolve both the extreme deviation\n         for many low scores and the relatively small deviation\n         for the very lowest scores, whereas 100 bins (f and g) produce\n         far too much noise for most scores.\n         The statistics of Kuiper and of Kolmogorov and Smirnov report\n         statistically significant deviation between the subpopulations.\n}\n\\label{San_Francisco-Kern}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_Contra_Costa-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{San Francisco County vs.\\ Contra Costa County; $n =$ 3,407;\n         Kuiper's statistic is $0.06395 / \\sigma = 3.488$,\n         Kolmogorov's and Smirnov's is $0.06395 / \\sigma = 3.488$;\n         only the cumulative graph (a) fully captures the relatively small\n         deviation for the very lowest scores, and having even just 100 bins\n         in a reliability diagram (f and g) already produces far too much noise\n         for most scores.\n         The metrics of Kuiper and of Kolmogorov and Smirnov report\n         statistically significant deviation between the subpopulations.\n}\n\\label{San_Francisco-Contra_Costa}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Joaquin-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{San Francisco County vs.\\ San Joaquin County; $n =$ 2,358;\n         Kuiper's statistic is $0.06160 / \\sigma = 2.794$,\n         Kolmogorov's and Smirnov's is $0.06025 / \\sigma = 2.733$;\n         only the cumulative graph (a) and the otherwise extremely noisy\n         reliability diagrams each with 100 bins (f and g) fully detail\n         the sharp spike at scores just slightly greater than 4.\n         The metrics of Kuiper and of Kolmogorov and Smirnov report\n         some statistically significant deviation between the subpopulations.\n}\n\\label{San_Francisco-San_Joaquin}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_San_Francisco_vs_San_Mateo-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{San Francisco County vs.\\ San Mateo County; $n =$ 3,147;\n         Kuiper's statistic is $0.03688 / \\sigma = 1.923$,\n         Kolmogorov's and Smirnov's is $0.03631 / \\sigma = 1.893$;\n         resolving the full extent of the spike\n         at some of the lowest scores in the cumulative graph (a) requires\n         at least 100 bins in the reliability diagrams (f and g),\n         but then the reliability diagrams are too noisy at the other scores.\n         The statistics of Kuiper and of Kolmogorov and Smirnov do not report\n         very statistically significant deviation between the subpopulations.\n}\n\\label{San_Francisco-San_Mateo}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centering}\n\n(a)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/cumulative.pdf}}\n\n\\vspace{\\vertsep}\n\n(b)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equierrs10.pdf}}\n\\quad\\quad\n(c)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equiscores10.pdf}}\n\n\\vspace{\\vertsep}\n\n(d)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equierrs20.pdf}}\n\\quad\\quad\n(e)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equiscores20.pdf}}\n\n\\vspace{\\vertsep}\n\n(f)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equierrs100.pdf}}\n\\quad\\quad\n(g)\n\\parbox{\\imsize}{\\includegraphics[width=\\imsize]\n{../codes/weighted/County_of_Riverside_vs_Butte-LNGI/equiscores100.pdf}}\n\n\\end{centering}\n\\caption{Riverside County vs.\\ Butte County; $n =$ 1,478;\n         Kuiper's statistic is $0.04624 / \\sigma = 1.650$,\n         Kolmogorov's and Smirnov's is $0.04624 / \\sigma = 1.650$;\n         resolving both the phenomena corresponding to the fairly flat part\n         and the phenomena corresponding to the very steep part\n         of the cumulative graph (a) for the lowest scores requires\n         at least 100 bins in the reliability diagrams (f and g),\n         but then the rest of the diagrams is very noisy.\n         The statistics of Kuiper and of Kolmogorov and Smirnov do not report\n         much statistically significant deviation between the subpopulations.\n}\n\\label{Riverside-Butte}\n\\end{figure}\n\n\n\n\\subsection{Cautions}\n\\label{caution}\n\nThis subsection warns about some limitations of both the methods\nof the present paper and the conventional reliability diagrams.\n\nThe fourth example from Subsection~\\ref{synthetic},\nwith its corresponding Figure~\\ref{ex3}, emphasizes a cautionary note:\navoid hallucinating deviations between the subpopulations\non account of statistically insignificant random fluctuations!\nThe indicators such as $\\sigma$ and the triangle at the origin\ndiscussed in Subsections~\\ref{scalarstats},\n\\ref{significance}, and~\\ref{weighted} are critical\nfor the proper interpretation of statistical significance.\n(Note that similar questions of significance also arise\nfor the conventional reliability diagrams, on account of multiple testing:\nerror bars for each bin could report 95\\% confidence intervals, for instance,\nbut then 1 out of every 20 such bins would be expected to report results\nexceeding its error bar.)\n\nA chief drawback of the approach of the present paper\nis the limitation highlighted in the abstract, in the introduction,\nand in an italicized sentence of Section~\\ref{methods}, too:\nthe score for every observation in either subpopulation\nmust not be exactly equal to the score for any other observation\nfrom the subpopulations. Of course, one way to enforce the required uniqueness\nof scores is to perturb them at random slightly.\nAnother drawback is that the observations\nfrom one subpopulation get compared to observations\nfrom the other subpopulation at slightly different scores;\nalthough the bias that this introduces in the cumulative approach\nis less than in the classical reliability diagrams, the bias is still there\nand potentially worrisome.\nAn ideal means of circumventing such drawbacks is to compare\na subpopulation to the full population as detailed by~\\cite{tygert}.\nThe approach of~\\cite{tygert} is effectively ideal\nand should be the method of choice whenever applicable.\nThe approach of the present paper is only relevant\nwhen comparing subpopulations directly is necessary.\n\n\n\n\\section{Conclusion}\n\\label{conclusion}\n\nThe plot of cumulative differences between the two subpopulations\nis easy to interpret --- the slope of a secant line for the graph over\na long range becomes the average difference between the two subpopulations,\nand slope is easy to gauge irrespective of any constant offset\nof the secant line. The plots for the examples of Section~\\ref{results}\nclearly demonstrate many advantages of the cumulative approach\nover the classical reliability diagrams, and the scalar summary statistics\nof Kuiper and of Kolmogorov and Smirnov usually faithfully reflect\nsignificant differences between the subpopulations if any occur\nacross the full range of scores in the plots.\nThe graphs of cumulative differences avoid explicitly making\na trade-off between statistical confidence and resolution as a function\nof score --- a trade-off that is inherent to the traditional binned diagrams.\n\n\n\n\\bibliography{paper}\n\\bibliographystyle{siam}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "9ae24c749f7d08032efdf5e6a3bccfb27677d146", "size": 75522, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/paper.tex", "max_stars_repo_name": "facebookresearch/fbcddisgraph", "max_stars_repo_head_hexsha": "82644381c59cfb3bff5a37656a6d7b00e6313511", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-08-06T18:05:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-01T17:39:01.000Z", "max_issues_repo_path": "tex/paper.tex", "max_issues_repo_name": "facebookresearch/fbcddisgraph", "max_issues_repo_head_hexsha": "82644381c59cfb3bff5a37656a6d7b00e6313511", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/paper.tex", "max_forks_repo_name": "facebookresearch/fbcddisgraph", "max_forks_repo_head_hexsha": "82644381c59cfb3bff5a37656a6d7b00e6313511", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-05T16:55:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-05T16:55:00.000Z", "avg_line_length": 39.9587301587, "max_line_length": 144, "alphanum_fraction": 0.7669288419, "num_tokens": 20525, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.43754397443878434}}
{"text": "\\section{Framing}\n\nFraming is the process of taking a data stream and reading a frame (or\nwindow) of data rather than a single datum.  Further processing is\nthen done on the frame rather than the individual data.  In fact,\ntracter refers to all data as frames; this is a precedent taken from\nALSA.\n\n\\begin{figure}[htb]\n  \\centering\n  \\begin{tikzpicture}[scale=.5,domain=0:19,samples=19]\n    \\draw[gray,->] (-.66,0) -- (19.66,0);\n    \\draw[gray] plot[ycomb,mark=*] (\\x, {2*sin(\\x r/2)});\n    \\foreach \\x in {0,...,4} \\draw (\\x,0) node [gray, below] {$\\x$};\n    \\draw (5,0) node [gray, below] {$\\cdots$};\n    \\draw (-.3,-2.2) rectangle (9.3,2.2) node [above left] {Frame 0};\n    \\draw (9.7,-2.2) rectangle (19.3,2.2) node [above left] {Frame 1};\n    \\draw (0,-2.2) -- (0,-2.5) node [below] {$0$};\n    \\draw (10,-2.2) -- (10,-2.5) node [below] {$1$};\n  \\end{tikzpicture}\n  \\caption{Frame indexing is aligned with the first sub-frame within\n    each frame.  Framing components hence look ahead in time.}\n  \\label{fig:Frame}\n\\end{figure}\n\nBy convention, the frame index is assumed to be aligned with that of\nthe first component frame, as illustrated in figure \\ref{fig:Frame}.\nThis means that framing components look ahead in time.  This in turn\nhas to be indicated in the {\\tt MinSize()} call.\n\n\n\\begin{figure}[htb]\n  \\centering\n  \\begin{tikzpicture}[scale=.5,domain=0:15,samples=15]\n    \\draw (0,0) -- (15,0);\n    \\foreach \\x in {0,...,15} \\draw (\\x,0) node [below] {$\\x$};\n    \\draw plot[ycomb, mark=*] (\\x, {2*(.54 - .46 * cos(360*\\x/15))});\n  \\end{tikzpicture}\n  \\caption{Hamming window\n    $f(x)=0.54-0.46\\cos\\left(2\\pi\\frac{x}{N-1}\\right)$ with $N=16$}\n  \\label{fig:Hamming}\n\\end{figure}\n\n\n\\begin{figure}\n  \\centering\n  \\begin{tikzpicture}\n    \\foreach \\x in {-5,...,5}\n    {\n      \\draw (\\x,0) +(-.5,-.5) rectangle ++(.5,.5);\n      \\draw (\\x,0) node{$t_{\\x}$};\n    }\n  \\end{tikzpicture}\n  \\caption{Useful looking boxes in a row.}\n\\end{figure}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"tracter\"\n%%% TeX-PDF-mode: t\n%%% End: \n", "meta": {"hexsha": "afd1896009317cb7f6328ecf158184cdf2fc2273", "size": 2041, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/framing.tex", "max_stars_repo_name": "mcernak/tracter", "max_stars_repo_head_hexsha": "56b30159099cda6000b9d2977925883cada7f0b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/framing.tex", "max_issues_repo_name": "mcernak/tracter", "max_issues_repo_head_hexsha": "56b30159099cda6000b9d2977925883cada7f0b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/framing.tex", "max_forks_repo_name": "mcernak/tracter", "max_forks_repo_head_hexsha": "56b30159099cda6000b9d2977925883cada7f0b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9193548387, "max_line_length": 70, "alphanum_fraction": 0.6217540421, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.43754397398299555}}
{"text": "\\chapter{Lay Summary}\n\nWhile people communicate to one another by speaking or writing in natural languages,\nwe communicate with computers via programming languages to tell them to, say, perform a calculation.\nJust as what is said or written needs to be grammatically correct to make any sense,\nprograms written in these programming languages need to be checked to ensure that they behave nicely.\nOne desirable property of programs might be termination:\nwe want to be certain that they will eventually finish running at some point.\nIt's impossible to devise a check that can always pick out all terminating programs,\nbut termination checks can be improved upon to accept more and more programs.\nThe topic of this thesis is using \\emph{sized types}, a powerful strategy for termination checking,\nin the setting of a programming language for mathematicians to write computer-verified proofs,\nand proving that the programs it accepts will actually terminate.", "meta": {"hexsha": "3e7d3a8c87b8c6283bbd70085a842a89bda102a5", "size": 954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/laysummary.tex", "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/laysummary.tex", "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/laysummary.tex", "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.3846153846, "max_line_length": 101, "alphanum_fraction": 0.820754717, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.43754396052105576}}
{"text": "\\documentclass[revision-guide.tex]{subfiles}\n%% Current Author: PS\n\\setcounter{chapter}{3}\n\\begin{document}\n\\chapter{Energy Concepts}\n\\raggedbottom\n\\begin{content}\n    \\item work\n    \\item power\n    \\item potential and kinetic energy\n    \\item energy conversion and conservation\n    \\item specific latent heat\n\\item specific heat capacity\n\\end{content}\n\n\\section*{Candidates should be able to}\n\n\\spec{recall and use the concept of work in terms of the product of a force and a displacement in the direction of that force, including situations where the force is not along the line of motion}\n\nWork, in a scientific sense, is done whenever a force, $F$ acts on an object which moves through a displacement $s$. When the force and the displacement are acting along the same line then work is simply calculated using $W=Fs$. However, when the force does not act in the same direction as the displacement, the work done is calculated by multiplying the component of the force in the direction of the displacement by the displacement as shown in figure \\ref{work}.\n\n\\begin{figure}[h]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\draw[thick, ->] (0,2) -- (5,2) node[anchor=north west] {$s$};\n      \\draw[very thick, ->, red] (0,2) -- (2.5,4) node[anchor=east] {$F$};\n      \\draw (1,2) arc [start angle=0, end angle=38.66, radius=1cm];\n      \\draw (.7,2.5) node[anchor=north] {$\\theta$};\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{Non-aligned force doing work}\n  \\label{work}\n\\end{figure}\n\nIn this case the work done is given by\n \\begin{equation}\\label{eq:work}\n W = Fs\\cos{\\theta}\n \\end{equation}.\n\nNote that this means that the following cases work is \\emph{not} done:\n\\begin{itemize}\n  \\item any stationary object (no displacement);\n  \\item an object in circular motion (the force is acting at right angles to the displacement).\n\\end{itemize}\n\nWhenever work is done energy is transferred to or from the object. The type of energy this is transferred to or from varies depending on the circumstances.\n\n\\spec{calculate the work done in situations where the force is a function of displacement using the area under a force-displacement graph}\n\nEquation \\ref{eq:work} applies whenever a constant force acts over a displacement; however, if the force varies then a different approach is needed. Force a constant force acting in the same direction as the displacement, it can be seen that the area under a force-displacement graph is equal to $Fs$, i.e. the work done. This is generally true and work can be written in an integral form as:\n\\begin{equation}\\label{eq:work-integral}\n  W = \\int F \\ud s\n\\end{equation}\n\n\\begin{figure}[h]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\draw[<->] (0,3) node[anchor=east] {$F$} -- (0,0) -- (4,0) node[anchor=north] {$s$};\n      \\filldraw[fill=blue!20!white] (.5,0) -- (.5,2) .. controls (2.5,2) and (1.5,3) .. (3.5,3) -- (3.5,0) -- cycle;\n      \\draw (2,1.5) node {Area = $W$};\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{Work as area under a graph}\n  \\label{fig:work-graph}\n\\end{figure}\n\n\\spec{understand that a heat engine is a device that is supplied with thermal energy and converts some of this energy into useful work}\n\nA heat engine is a device which uses heat to do work. This is shown schematically in figure \\ref{fig:heat}. The energy for the work done comes from the difference between $Q_1$ and $Q_2$.\nExamples of heat engines include internal combustion engines, jet engines and steam turbines.\n\n\\begin{figure}[h]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\draw[very thick, red, ->] (0,2) node[anchor=south] {$Q_1$} -- (0,.5);\n      \\draw (0,0) circle (.5cm);\n      \\draw[bend right, very thick, gray, ->] (0,.5) to (1,0) node[anchor=west] {$W$};\n      \\draw[very thick, blue, ->] (0,-.5) -- (0,-2) node[anchor=north] {$Q_2$};\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{A heat engine}\n  \\label{fig:heat}\n\\end{figure}\n\n\\spec{calculate power from the rate at which work is done or energy is transferred}\n\nPower is defined as the rate at which energy is transferred and is measured in watts (\\si{\\watt}).\n\\begin{equation}\\label{eqn:power}\n  P = \\frac{W}{t}\n\\end{equation}\n\n\\spec{recall and use $P = Fv$}\n\nFor a constant force, this equation can be shown from equation \\ref{eqn:power} and \\ref{eq:work}:\n\\[ P = \\frac{W}{t} = F\\ \\frac{s}{t} = Fv \\]\n\n\\spec{recall and use $\\Delta E = mg\\Delta h$ for the gravitational potential energy transferred near the Earth's surface}\n\nThis is familiar from GCSE.\n\n\\spec{recall and use $g\\Delta h$ as change in gravitational potential}\n\nGravitational potential is defined as the energy per unit mass. Hence, the change in gravitational potential is given by \\[\\frac{mg\\Delta h}{m} = g\\Delta h\\]\n\n\\spec{recall and use $E = \\frac{1}{2}Fx$ for the elastic strain energy in a deformed material sample obeying Hooke's law}\n\\spec{use the area under a force-extension graph to determine elastic strain energy}\n\nThis relies on equating the work done straining an object with the elastic strain energy stored in the object. Once this is done, the statement follows from equation \\ref{eq:work-integral} and figure \\ref{fig:work-graph}.\n\nThe area of such a graph when the material obeys Hooke's Law is $\\frac{1}{2}Fx$.\n\n\\begin{figure}[h]\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\draw[<->] (0,3) node[anchor=east] {$F$} -- (0,0) -- (4,0) node[anchor=north] {$x$};\n      \\filldraw[fill=blue!20!white] (0,0) -- (3.5,3) --(3.5,0) -- cycle;\n      \\draw (2,.5) node {Area = $\\frac{1}{2}Fx$};\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{Work as area under a graph}\n  \\label{fig:hooke's law}\n\\end{figure}\n\n\\spec{derive, recall and use $E=\\frac{1}{2}kx^2$}\n\nThis can be arrived at from Hooke's Law ($F=kx$) and the definition of work in equation \\ref{eq:work-integral}, noticing that the extension of the spring is equal to the displacement of the object.\n\\[ W = \\int F \\ud s = \\int_0^x kx \\ud x = \\frac{1}{2}kx^2 \\]\n\nThis integration could equally be done by substituting $F=kx$ into the expression for elastic strain energy derived above from the graph.\n\n\\spec{derive, recall and use $E=\\frac{1}{2}mv^2$ for the kinetic energy of a body}\n\nConsider the work done accelerating an object from rest to a velocity $v$. Using the equations for uniform acceleration with $u=0$ we can see that $ a = \\frac{v}{t} $ and $ s = \\frac{v}{2}\\cdot t $ so:\n\n\\[ W = Fs = mas = m\\ \\frac{v}{t}\\ \\frac{v}{2}\\ t = \\frac{1}{2}mv^2 \\]\n\nSince this work has gone into the kinetic energy of the object this formula gives us this kinetic energy.\n\n\\spec{apply the principle of conservation of energy to solve problems}\n\nThe principle of conservation of energy states that energy cannot be created or destroyed, only transferred between different forms.\n\n\\spec{recall and use \\[\\%\\  \\text{efficiency} = \\frac{\\text{useful energy out}}{\\text{total energy in}} \\times 100\\]\n\\[\\%\\  \\text{efficiency} = \\frac{\\text{useful power out}}{\\text{total power in}} \\times 100\\]}\n\nThis is familiar from GCSE.\n\n\\spec{recognise and use $\\Delta E = mc \\Delta\\theta$, where c is the specific heat capacity}\n\nThe specific heat capacity is defined as the energy required to heat \\SI{1}{\\kilo\\gram} of a substance by \\SI{1}{\\celsius}.\n\n\\begin{example}\n  A kettle with a power rating of \\SI{2}{\\kilo\\watt} heats \\SI{500}{\\gram} of water from \\SI{15}{\\celsius} to boiling. If the kettle is 80\\% efficient, calculate the time take for the water to boil.\n\n  The specific heat capacity of water is \\SI{4200}{\\joule\\per\\kilogram\\per\\celsius}\n\n  \\answer\n\n  Total heat energy required by the water:\n  \\[ \\Delta E = \\SI{0.5}{\\kilogram} \\times \\SI{4200}{\\joule\\per\\kilogram\\per\\celsius} \\times \\SI{85}{\\celsius} = \\SI{178.5}{\\kilo\\joule} \\]\n\n  Useful power provided by the kettle:\n\n  \\[ P = 0.8 \\times \\SI{2}{\\kilo\\watt} = \\SI{1.6}{\\kilo\\watt} \\]\n\n  Therefore the time taken is:\n  \\[ t = \\frac{\\Delta E}{P} = \\frac{\\SI{178.5}{\\kilo\\joule}}{\\SI{1.6}{\\kilo\\watt}} = \\SI{112}{\\second} \\]\n\n\\end{example}\n\n\\spec{recognise and use $\\Delta E = mL$, where L is the specific latent heat of fusion or of vaporisation}\n\nWhen a substance changes state it releases or absorbs energy. This energy is known as the latent heat. The specific latent heat is the energy absorbed or released when \\SI{1}{\\kilogram} of the substance changes state.\n\n\n\\end{document}\n", "meta": {"hexsha": "8916efdf3395f20be912de19e1057e07c9b2abee", "size": 8279, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "4-energy-concepts.tex", "max_stars_repo_name": "sirioq/physics-PreU", "max_stars_repo_head_hexsha": "d0f993750d660df38f05085ccf3b351d2ea3dd7d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "4-energy-concepts.tex", "max_issues_repo_name": "sirioq/physics-PreU", "max_issues_repo_head_hexsha": "d0f993750d660df38f05085ccf3b351d2ea3dd7d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "4-energy-concepts.tex", "max_forks_repo_name": "sirioq/physics-PreU", "max_forks_repo_head_hexsha": "d0f993750d660df38f05085ccf3b351d2ea3dd7d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7740112994, "max_line_length": 466, "alphanum_fraction": 0.7028626646, "num_tokens": 2488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.43754396052105576}}
{"text": "\\section{Stochastic Boolean satisfiability}\n\\label{sect:related-work-ssat}\n\nSSAT~\\cite{Littman2001,SATHandbook-SSAT} is first formulated by Papadimitriou\nand interpreted as \\textit{games against nature}~\\cite{Papadimitriou1985}.\nIt lies in the same PSPACE-complete~\\cite{Stockmeyer1973} complexity class as QBF.\n\nExploiting randomized quantifiers,\nSSAT is capable of modeling a variety of computational problems inherent with uncertainty~\\cite{Hnich2011},\nsuch as probabilistic planning~\\cite{Kushmerick1995,Littman1998},\nBayesian-network inference~\\cite{Cooper1990,Jensen1996,Dechter1998,Bacchus2003},\nand trust management~\\cite{SATHandbook-SSAT}.\nRecently, the quantitative information-flow analysis for software security is also formulated\nas E-MAJSAT~\\cite{Fremont2017},\nand bi-directional polynomial-time reductions between SSAT and POMDP are established~\\cite{Salmon2020}.\n\nA number of SSAT solvers have been developed.\nAmong the prior efforts made to approach SSAT,\nmost of them are based on Davis-Putnam-Logemann-Loveland (DPLL) search~\\cite{Davis1962}.\nFor example,\nsolver \\maxplan~\\cite{Majercik1998} encodes a conformant planning problem as an E-MAJSAT formula\nand improves the solving efficiency by pure variables, unit propagation, and subproblem memorization;\nsolver \\zander~\\cite{Majercik2003} deals with partially observable probabilistic planning by formulating the problem as a general SSAT formula and incorporates several threshold-pruning heuristics to reduce the search space.\nSolver \\dcssat~\\cite{Majercik2005} divides an SSAT formula into several smaller SSAT formulas and conquers them with a DPLL-based algorithm.\nThe solutions to the separate SSAT problems are then combined into an optimal solution to the entire formula.\nThe formula splitting is tailored to exploit the structural characteristics of probabilistic planning problems,\nwhich often contain similar clauses to encode the state-transition mechanism across different stages.\nThe divide-and-conquer approach of \\dcssat achieves several orders of magnitude speedup than its predecessor \\zander.\nApproximate solving~\\cite{Majercik2007} and resolution rules~\\cite{Teige2010} for SSAT have also been addressed.\nTechniques from \\textit{knowledge compilation} have also been exploited to solve E-MAJSAT formulas.\nSolver \\complan~\\cite{Huang2006} compiles the matrix of an E-MAJSAT formula into its\n\\textit{deterministic, decomposable negation normal form} (d-DNNF)~\\cite{Darwiche2001,Darwiche2002dDNNF},\nand performs a branch-and-bound search.\nIt is further improved by an enhanced bound computation method~\\cite{Pipatsrisawat2009}.", "meta": {"hexsha": "34259e7b5a5e55ccdc64063a2d316eb6ab1ca7dd", "size": 2614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/related-work/ssat.tex", "max_stars_repo_name": "nianzelee/PhD-Dissertation", "max_stars_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-11T19:38:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T19:38:13.000Z", "max_issues_repo_path": "paper/related-work/ssat.tex", "max_issues_repo_name": "nianzelee/PhD-Dissertation", "max_issues_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/related-work/ssat.tex", "max_forks_repo_name": "nianzelee/PhD-Dissertation", "max_forks_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.8823529412, "max_line_length": 224, "alphanum_fraction": 0.8301453711, "num_tokens": 668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43739733428408634}}
{"text": "\\chapter{Algorithmic Design}\nIn this chapter are given the guidelines on how to implement the most important functionalities that the components of the system will offer. The pseudocode of the relevant method is shown. \n\n\\section{Login}\nThe Login involves the application the application server and the database. The last one is located outside the application server. \nTo login in to the application the following steps must be done:\n\\begin{enumerate}\n\\item the user presses the Login button in the Login view;\n\\item the Identity manager (Login method) sends a request to the Application Server for authentication\n\\item A query on the database is performed to check the validity of the user credential and a response to the client is returned;\n\\end{enumerate}\n\n\\begin{lstlisting}\n//client side\nLogin(username, password)\n\tresponse = SendRequest(\"api/login\", username, password)\n\tif response.isValid \n\t\ttoken = response.GetToken\n\t\tShow(HomeView)\n\telse\n\t\tShow(ErrorMessage , \"Invalid Credentials\")\n\n//server side\nLoginRequest(username, password)\n\tresult = database.query(username, password)\n\tif result == 1\n\t\tSendAuthenticationResponse (token)\n\telse\n\t\tsendAuthenticationError(error code)\n\\end{lstlisting}\n\n\\section{CreateSchedule}\nThe process of computing a schedule is composed by the following steps:\n\n\\begin{enumerate}\n\\item Create the predecessor matrix (P) in which every cell (i,j) contains:\n\n\\[\n    P_{ij}=\n    \\begin{cases}\n      1, &\\text{if $Appointment_i$ must precede $Appointment_j$} \\\\\n      0, &\\text{if $Appointment_i$ must follows $Appointment_j$} \\\\\n      -1, &\\text{if $Appointment_i$ can be scheduled both before or after $appointment_j$}\n    \\end{cases}\n\\]\n\n\\item Compute all the possible ordered arrangements of appointments with respect to the predecessor matrix\n\\item For each appointment in each arrangement, set the starting time according to travel time. This is estimated considering the euclidean distance and heuristics on the kind of travel mean between every pair of consecutive appointments in the arrangement, considering the bestTravelMean; \\ref{def:bestTravelMean}\n\\item Check the feasibility of the arrangements and discard the ones which have overlapping appointments;\n\\item Choose the most convenient one, according to the optimization criteria.\n\\item Call mapping service Api to fix the effective routes between the appointments\n\\end{enumerate}\n\n\\begin{lstlisting}\nComputeSchedule(wakeUpTime, startingLocation, appts, constraints, optCriteria)\n\tp=CalculatePredecessorMatrix(appts)\n\ta=CalculateArrangements(appts, p, 0, 1)\n\tSetStartingTime(a, startingTime, startingLocation, constraint, optCriteria)\n\ts=ChooseBestSchedule(a)\n\tMappingServiceRequest(s)\n\treturn s\n\nCalculatePredecessorMatrix(appts)\n\tp=new Matrix[appt.size,appt.size]\n\tfor(i=0 .. appts.size)\n\t\tfor(j=i+1 .. appts.size)\n\t\t\ta1=appts[i]\n\t\t\ta2=appts[j]\n\t\t\tif a1.deterministic && a2.deterministic\n\t\t\t\tif a1.startingTime < a2.startingTime\n\t\t\t\t\tpred[i,j]=1\n\t\t\t\telse\n\t\t\t\t\tpred[i,j]=0\n\t\t\telseif a1.deterministic && !a2.deterministic\n\t\t\t\tif a1.startingTime < a2.timeSlot.start\n\t\t\t\t\tpred[i,j]=1\n\t\t\t\telseif a1.endingTime > a2.timeSlot.end\n\t\t\t\t\tpred[i,j]=0\n\t\t\t\telse\n\t\t\t\t\tpred[i,j]=-1\n\t\t\telseif !a1.deterministic && a2.deterministic\n\t\t\t\t\tif a1.timeslot.end < a2.endingTime\n\t\t\t\t\t\tpred[i,j]=1\n\t\t\t\t\telseif a1.timeSlot.start > a2.startingTime\n\t\t\t\t\t\tpred[i,j]=0\n\t\t\t\t\telse\n\t\t\t\t\t\tpred[i,j]=-1\n\t\t\telseif !a1.deterministic && !a2.deterministic\n\t\t\t\t\tif a1.timeSlot.end < a2.timeSlot.start\n\t\t\t\t\t\tpred[i,j]=1\n\t\t\t\t\telseif a1.timeSlot.start > a2.timeSlot.end\n\t\t\t\t\t\tpred[i,j]=0\n\t\t\t\t\telse\n\t\t\t\t\t\tpred[i,j]=-1\n\treturn p\n\t\t\n\t\t\nCalculateArrangements(appts, p, curri, currj)\n\tarrangement=new List\t\n\tfor(i=curri .. appts.size-1)\n\t\tfor(j=currj-1 .. appts.size)\n\t\t\tif p[i,j]==-1\n\t\t\t\tp0=p\n\t\t\t\tp0[i,j]=0\n\t\t\t\tCalculateArrangements(appts, p0, i, j)\n\t\t\t\t\n\t\t\t\tp1=p\n\t\t\t\tp1[i,j]=1\n\t\t\t\tCalculateArrangements(appts, p1, i, j)\n\t\t\t\t\n\t\t\t\treturn\n\t\t\t\t\n\ta=ConvertPredMatrixToList(appts,p)\n\tarrangement.addLast(a)\n\treturn arrangement\n\n\t\t \nConvertPredMatrixToList(appts, p)\n//converts a \"-1 free\" predecessor matrix to an ordered list of appointments\n\n\nSetStartingTime(a, startingTime, startingLocation, constraint, optCriteria)\n\tfor(arr in a)\n\t\tdummyStartingAppt = new appointment(startingTime, startingLocation, duration=0)\n\t\tarr.addFirst(dummyStartingAppt)\n\t\tfor(i=1 .. arr.size)\n\t\t\tappt1=arr[i-1]\n\t\t\tappt2=arr[i]\n\t\t\ttravelMean=getBestTravelMean(appt1, appt2, constraint, optCriteria)\n\t\t\ttravelTime=travelMean.estimateTime(appt1, appt2)\n\t\t\tif appt2.deterministic \n\t\t\t\tappt2.startingTravelTime = appt2.startingTime-travelTime\n\t\t\t\tappt2.travelMean=travelMean\n\t\t\t\tif appt1.endingTime > appt2.startingTravelTime\n\t\t\t\t\terror(\"schedule not feasible\")\n\t\t\telse\n\t\t\t\tappt2.startingTravelTime = max(appt1.endingTime,appt2.timeSlot.start-travelTime)\n\t\t\t\tappt2.travelMean=travelMean\n\t\t\t\tif appt2.startingTravelTime > appt2.timeSlot.end\n\t\t\t\t\terror(\"schedule not feasible\")\n\t\t\t\t\t\n\t\t\t\t\t\ngetBestTravelMean(appt1, appt2, constraint, optCriteria)\n\tl=getNotConstrainedTravelMeans(constraint)\n\tfor(t in l)\n\t\tswitch optCriteria\n\t\t\tcase \"MoneySpent\"\n\t\t\t\tt.cost=estimateMoney(t, appt1, appt2)\n\t\t\tcase \"Time\"\n\t\t\t\tt.cost=estimateTime(t, appt1, appt2)\n\t\t\tcase \"CarbonFootprint\"\n\t\t\t\tt.cost=estimateCarbon(t, appt1, appt2)\n\tsortByCriteria(l, optCriteria)\n\treturn l\n\t\nChooseBestSchedule(a)\n\tbest=a[0]\n\tfor(i = 0 .. a.size)\n\t\tsum=0\n\t\tfor(appt in a[i])\n\t\t\tsum+=appt.travelMean.cost\n\t\ta[i].totalCost=sum\n\t\tif sum<a[0].totalCost\n\t\t\tbest=a[i]\n\treturn best\n\t\nMappingServiceRequest(s)\n\tfor (i=0 .. s.size-1)\n\t\tresponse=MappingServiceRequest(s[i], s[i+1])\n\t\ts[i].path=response.path\n\t\ts[i].startingTime=response.startingTime\n\n\\end{lstlisting}\n\n\\section{Registration}\nThe Registration involves the application the application server and the database. The last one is located outside the application server. \nTo register in to the application the following steps must be done:\n\\begin{enumerate}\n\\item The user presses the Registration button in the Login view;\n\\item The Identity manager (Registration method) sends a request to the Application Server for authentication\n\\item A query on the database is performed to check the presence of the user credential and a confirmation email is sent\n\\item The user confirms the email by clicking on the designated link\n\\item The user's state on the database becomes confirmed\n\\end{enumerate}\n\n\\begin{lstlisting}\n//client side\nRegister(username, password)\n\tresponse = SendRequest(\"api/registration\", username, password)\n\tif !response.valid\n\t\tShow(ErrorMessage , \"User Already Registered\")\n\t\t\n\n\t\n//server side\nRegistrationRequest(username, password)\n\tresult = database.query(username, password)\n\tif result == 0\n\t\tdatabase.insertTuple(username, password)\n\t\tsendEmail(username)\n\telse\n\t\tsendAuthenticationError(error code)\n\t\t\nEmailConfirmationRequest(username)\n\tresult = database.modifyTuple(username, confirmed=true)\n\\end{lstlisting}\n\n\n\\section{Synchronize}\nThe synchronization in our system is the process that aims to keep the data consistent and updated between different devices. For example, when a user inserts an appointment on one of his devices, then the changes must be propagated to all his other devices, once the login is performed. \nThe Synchronization involves the application, the application server and the database. The last one is located outside the application server. To sinchronize data across multiple devices two actions must be carried out:\n\\begin{itemize}\n\\item Upload of local data on the database when a single change on the  client's local data occours(Synchronize Upwards);\n\\item Download of data from the database, if an update is necessary, when login is performed(Synchronize Downwards).\n\\end{itemize}\n\n\\begin{lstlisting}\n//client background processes\n\nSynchronizeUpwards(changedData)\n\tupdate = false\n\twhile !update\n\t\tresponse = SendRequest(\"api/sync/up\", token, changedData)\n\t\tif response\t \n\t\t\tupdate = true\n\t\t\t\nSynchronizeDownwards()\n\tnewData=SendRequest(\"api/sync/down\", token)\n\tlocalData=newData\n\t\t\n\t\t\n//server side\n\nSynchUpwardsRequest(token, changedData)\n\tuserID = database.getUser(token)\n\tif changedData.action == insert\n\t\t//changedData is a newly inserted element\n\t\tdatabase.insert(changedData, userID)\n\telse if changedData.action == edit\n\t\tdatabase.update(changedData, userID)\n\telse\n\t\tdatabase.delete(changedData, userID)\n\tsendResponse(\"syncresult\", true)\n\t\nSynchUpwardsRequest(token, changedData)\n\tuserID = database.getUser(token)\n\tdata=database.getUserData(userID)\n\tsendResponse(data)\n\n\\end{lstlisting}\n\n\n\n\n\t\t", "meta": {"hexsha": "fa79590930f1915725fc2926b7b75135f573592c", "size": 8497, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DD/cap3_algdesign.tex", "max_stars_repo_name": "keyblade95/DamicoGabboliniParroni", "max_stars_repo_head_hexsha": "85a52acdefa1df6355ee05dd67240297d99356a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DD/cap3_algdesign.tex", "max_issues_repo_name": "keyblade95/DamicoGabboliniParroni", "max_issues_repo_head_hexsha": "85a52acdefa1df6355ee05dd67240297d99356a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DD/cap3_algdesign.tex", "max_forks_repo_name": "keyblade95/DamicoGabboliniParroni", "max_forks_repo_head_hexsha": "85a52acdefa1df6355ee05dd67240297d99356a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-06T15:07:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-19T08:25:23.000Z", "avg_line_length": 33.3215686275, "max_line_length": 314, "alphanum_fraction": 0.7557961634, "num_tokens": 2168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43739733428408634}}
{"text": "% !TEX root =main.tex\n\n\n\n\n\\section{Multi-instance  Time-lock Puzzle}\n\n\\vspace{-2mm}\n\n\n\\subsection{Strawman Solution}\\label{C-TLP-overview}\n\nIn the following, we elaborate on the  problems that would arise if an existing time-lock puzzle is used directly to handle  multiple puzzles at once.  Without loss of generality, to illustrate the problems, we use the well-known TLP scheme presented in Section \\ref{Time-lock-Encryption}. \n\n\n\nConsider the case where a client wants a server to learn a vector of messages: $\\vv{\\bm{m}}=[m_{\\scriptscriptstyle 1},...,m_{\\scriptscriptstyle z}]$ at times  $[f_{\\scriptscriptstyle 1},...,f_{\\scriptscriptstyle z}]$ respectively, where the client is available and online only at an earlier time $f_{\\scriptscriptstyle 0}< f_{\\scriptscriptstyle 1}$.  For the sake of simplicity, let $\\Delta=f_{\\scriptscriptstyle 1}-f_{\\scriptscriptstyle 0}$ and $\\Delta=f_{\\scriptscriptstyle j+1}-f_{\\scriptscriptstyle j}$, where $1\\leq j \\leq z$. A naive way to address the problem is that the client uses the TLP  to encrypt each message $m_{\\scriptscriptstyle j}$ separately, such that it can be decrypted at time $f_{\\scriptscriptstyle j}$ if  all ciphertexts and public keys are passed on to the server at time $t_{\\scriptscriptstyle 0}$.  For the server to decrypt the messages  on time, it needs to start decrypting \\emph{all of them} as soon as the ciphertexts and public keys are given to it. \n\n\n\n\\noindent\\textit{\\textbf{Parallel Composition Problem}}. The above naive approach yields two serious issues: (a) imposing a high computation cost, as  the server has to perform $S\\Delta \\sum\\limits_{\\scriptscriptstyle j=1}^{\\scriptscriptstyle z}j$ squaring to decrypt all   messages, and (b) demanding a high level of parallelisation, as each puzzle has to be dealt with separately in parallel to the rest.  The  issues can be cast  as  ``\\emph{parallel composition problem}'', where $z$ instances of a puzzle scheme are given at once to a server whose only option, to find solutions on time, is to solve them in parallel\\footnote{It should not be confused with the ``universally composable'' notion put forth in \\cite{Canetti01}.}. Also, for the client  to efficiently compute $a_{\\scriptscriptstyle j}$  for each  message $m_{\\scriptscriptstyle j}$,  where $j>1$, it has to perform at least one modular multiplication, i.e. $a_{\\scriptscriptstyle j}=a_{\\scriptscriptstyle 1} a_{\\scriptscriptstyle j-1}=2^{\\scriptscriptstyle j  T}$, where $a_{\\scriptscriptstyle 1}=2^{\\scriptscriptstyle T}$. In this step, in total $z-1$ modular multiplications are required  to compute all $a_{\\scriptscriptstyle j}$ values, for $z$ messages (which is not optimal). Note, we do not see the above issues as  previous schemes' flaws, because they were not initially designed for the multi-puzzle setting.  \n \n\\vspace{-3mm}\n\n%\n\n \\subsection{An Overview of our Solutions}\\label{Overview-of-our-Solutions}\n Our key observation is, in the naive approach, the process of decrypting  messages has many overlaps  leading to a high  computation cost. So,  by removing the overlaps, we can considerably lower the overall cost both in \\emph{puzzle solving} and \\emph{puzzle creating} phases.  One of our core ideas  is to chain the puzzles. While chaining different puzzles may seem a relatively obvious approach to tackle the  issues, designing a secure protocol that also can make black-box use of a standard time-lock puzzle scheme, supports public verifiability, and has low costs is challenging. In our solution, a client  first encrypts the message  that is supposed to be decrypted after the rest and embeds the information needed for decrypting it into the ciphertext of the message that will be decrypted before that message. In other words, the client integrates the information (i.e. a part of public keys) needed to decrypt message $m_{\\scriptscriptstyle j}$ into the ciphertext related to message $m_{\\scriptscriptstyle j-1}$. In this case, the server after learning message $m_{\\scriptscriptstyle j-1}$ at time $f_{\\scriptscriptstyle j-1}$ learns the public key needed to perform the sequential squaring to decrypt the next message: $m_{\\scriptscriptstyle j}$. This means after fully decrypting $m_{\\scriptscriptstyle j-1}$, the server starts  squaring sequentially to decrypt $m_{\\scriptscriptstyle j}$\n  \n  \n  \n  \\noindent\\textit{\\textbf{Addressing Parallel Composition Problem}}.  The above approach solves the parallel composition problem for two main reasons.  First, the total  number of squaring required to decrypt all $z$ messages is now much lower, i.e. $S \\Delta z$, and is equivalent to the number of squaring needed to solve only the last puzzle,  i.e. $z\\text{-th}$ one. Second, it does not call for  high parallelisation. Because now the server does not need to deal with all of the puzzles in parallel; instead, it solves them sequentially one after another.  \n  \n  \n  \n  \\noindent\\textit{\\textbf{Adding Efficient Publicly Verifiable Algorithm}}. To let the  scheme  support  efficient public verifiability, we use the following novel trick. The client uses a commitment scheme to commit to every message: $m_{\\scriptscriptstyle i}$ and publishes the  commitment. Then, it uses the time-lock encryption to encrypt the commitment's opening, i.e. a combination of $m_{\\scriptscriptstyle i}$ and a random value. But, unlike the traditional commitment, the client does not open the commitment itself. Instead, the server does that, after it discovers the puzzle's solution.  When it finds a solution, it decodes the solution to find the opening and sends it to the public who can check the solution correctness. So, to verify  a solution's correctness,   a verifier  only needs to run the commitment's verification algorithm that is: (a)  publicly verifiable, and (b)   efficient. It can be built in the random oracle  or  the standard model.\n  \n    The approach also allows  the client at the setup to compute only a single $a=2^{\\scriptscriptstyle T}$  reusable for all $z$ puzzles, imposing only $O(1)$  cost. \n\n\\vspace{-3mm}\n\n\\subsection{Multi-instance   Time-lock Puzzle Definition}\\label{Section::Multi-instance-Time-lock Puzzle-Definition}\nIn this section, we provide a formal definition of a multi-instance time-lock puzzle. Our starting point is the  time-lock puzzle definition, i.e. Definition \\ref{Def::Time-lock-Puzzle}, but we extend it from several  perspectives, so it can: (a) handle multiple  solutions/messages in setup, (b)  produce multiple puzzles for the messages,   (c) solve the puzzles given the puzzles and public parameters, and (d) support public verifiability. In the following, we provide the formal definition of a multi-instance  time-lock puzzle.\n\\begin{definition}[Multi-instance Time-lock Puzzle] A multi-instance time-lock puzzle has the following  five algorithms and satisfies completeness and efficiency properties. \n\\begin{itemize}[leftmargin=.43cm]\n\\item \\textbf{Algorithms}:\n\\begin{itemize} \n\\item[$\\bullet$]$\\mathtt{Setup}(1^{\\scriptscriptstyle\\lambda},\\Delta,z)\\rightarrow (pk,sk,\\vv{\\bm{d}})$:  a probabilistic algorithm that takes as input  security: $1^{\\scriptscriptstyle\\lambda}$ and time:  $\\Delta$ parameters and the total number of solutions/puzzles: $z$. Let     $j \\Delta$ be a time period after which $j\\text{\\small{-th}}$ solution is found.   It outputs public-private key pair: $(pk,sk)$ and a vector of fixed size  secret witnesses: $\\vv{\\bm{d}}$\n\n\n%\\vv{\\bm{s}}\n\\item[$\\bullet$]$\\mathtt {GenPuz}(\\vv{\\bm{m}}, pk, sk,\\vv{\\bm{d}})\\rightarrow \\ddot{o}$:  a probabilistic algorithm that takes as an input  a  message vector: $\\vv{\\bm{m}}=[m_{\\scriptscriptstyle 1},...,m_{\\scriptscriptstyle z}]$,  the public-private key pair: $(pk,sk)$, and the witness vector: $\\vv{\\bm{d}}$. It  outputs $\\ddot{o}:(\\vv{\\bm{o}},\\vv{\\bm{h}})$, where $\\vv{\\bm{o}}$ is a puzzle vector, and $\\vv{\\bm{h}}$ is a commitment vector. Each $j\\text{\\small{-th}}$ element in  vectors $\\vv{\\bm{o}}$ and $\\vv{\\bm{h}}$ corresponds to a solution $s_{\\scriptscriptstyle j}$ of the form: $s_{\\scriptscriptstyle j}=m_{\\scriptscriptstyle j}||d_{\\scriptscriptstyle j}$ %Given $s_{\\scriptscriptstyle j}$ and $b$, a public decoding function, $\\mathtt{Decode}()$ returns $m_{\\scriptscriptstyle j}$, i.e. $\\mathtt{Decode}(s_{\\scriptscriptstyle j},b)\\rightarrow m_{\\scriptscriptstyle j}$. \n \n\\item[$\\bullet$]$\\mathtt {SolvPuz}(pk,\\vv{\\bm{o}})\\rightarrow \\vv{\\bm{s}}$:   a deterministic algorithm that takes as input  the public key: $pk$ and  puzzle vector: $\\vv{\\bm{o}}$. It outputs a solution vector: $\\vv{\\bm{s}}$\n\n\\item[$\\bullet$]$\\mathtt {Prove}(pk,s_{\\scriptscriptstyle j})\\rightarrow \\ddot{p}_{\\scriptscriptstyle j}$:  a deterministic algorithm that takes the public key: $pk$ and a solution: $s_{\\scriptscriptstyle j}\\in\\vv{\\bm{s}}$. It outputs a proof, $\\ddot{p}_{\\scriptscriptstyle j}:(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$\n\n\\item[$\\bullet$]$\\mathtt {Verify}(pk,\\ddot{p}_{\\scriptscriptstyle j},h_{\\scriptscriptstyle j})\\rightarrow \\{0,1\\}$:  a deterministic algorithm that takes  public key: $pk$,  proof: $\\ddot{p}_{\\scriptscriptstyle j}$ and commitment: $h_{\\scriptscriptstyle j}\\in \\vv{\\bm{h}}$. It outputs  $0$ if it rejects, or $1$ if it accepts. \n\\end{itemize}\n\\item \\textbf{Completeness}: for any honest prover and verifier, it always holds that: \n\\begin{itemize}\n\\item$\\mathtt{SolvPuz}(pk,[o_{\\scriptscriptstyle 1},...,o_{\\scriptscriptstyle j}])=[s_{\\scriptscriptstyle1},...,s_{\\scriptscriptstyle j}]$, for every $j$, $1\\leq j\\leq z$\n\n\\item $\\mathtt {Verify}(pk,\\mathtt {Prove}(pk,s_{\\scriptscriptstyle j}),h_{\\scriptscriptstyle j})\\rightarrow 1$\n\\end{itemize}\n\\item \\textbf{Efficiency}: the run-time of algorithm $\\mathtt {SolvPuz}(pk,[o_{\\scriptscriptstyle 1},...,o_{\\scriptscriptstyle j}])=[s_{\\scriptscriptstyle1},...s_{\\scriptscriptstyle j}]$ is bounded by:  $ poly(j\\Delta,\\lambda)$, where $poly(.)$ is a fixed polynomial and  $1\\leq j\\leq z$\n\\end{itemize}\n\\end{definition}\n \nInformally, a multi-instance time-lock puzzle is secure if it satisfies two properties:  a solution's \\emph{privacy} and  \\emph{validity}. The former  requires  its $j\\text{\\small{-th}}$ solution   to remain hidden from all adversaries running in parallel within  time period: $j \\Delta$, while the latter one requires that it is  infeasible for  a PPT adversary to come up with an invalid solution  and passes the verification. The two properties are formally defined in Definitions \\ref{Def::Solution-Privacy} and \\ref{Def::Solution-Validity}.\n \n\n \n \n \n% \\begin{definition}[Chained Time-lock Puzzle's Sequentiality] For functions  $\\pi(t)$ and $\\delta(t)$, a  chained time-lock puzzle is $(\\pi,\\delta)$-sequential if for any pair of randomised algorithm $\\mathcal{A} : (\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$, where $\\mathcal{A}_{\\scriptscriptstyle 1}$ runs in total time $O(poly(t,\\lambda))$ and $\\mathcal{A}_{\\scriptscriptstyle 2}$ runs in  time $\\delta(t)$ using at most $\\pi(t)$ parallel processors, there exists a negligible function $\\mu(.)$ such that: \n% \n \n \n% $$ Pr\\left[    \\begin{array}{l}  \\mathcal{A}_{\\scriptscriptstyle 2}(pk, \\ddot{o},state)\\rightarrow s \\\\\n% s.t.\\\\\n% s=\\mathtt {SolvPuz}(pk,\\theta)\n% \n%   \\end{array}\n%   \\middle |\n%    \\begin{array}{l}\n%\\mathtt{Setup}(1^{\\scriptscriptstyle\\lambda},\\Delta,1)\\rightarrow (pk,sk,\\vv{\\bm{d}})\\\\\n%\\mathcal{A}_{\\scriptscriptstyle 1}(1^{\\scriptscriptstyle\\lambda},pk, \\Delta,1)\\rightarrow state\\\\\n%m\\stackrel{\\scriptscriptstyle\\$}\\leftarrow \\mathcal{M}\\\\\n%\\mathtt {GenPuz}(m, pk, sk)\\rightarrow \\ddot{o}\\\\\n%\\end{array}    \\right]\\leq \\mu(\\lambda)$$\n%  \\end{definition}\n%  where $\\theta\\in \\ddot{o}$.\n  \n%   $$ Pr\\left[    \\begin{array}{l}  \\mathcal{A}_{\\scriptscriptstyle 2}(pk, \\ddot{o},state)\\rightarrow a \\\\\n% s.t.\\\\\n%m'=\\mathtt{Decode}(\\mathtt {SolvPuz}(pk,\\theta),b)\\\\\n% a=m'\n% \n%   \\end{array}\n%   \\middle |\n%    \\begin{array}{l}\n%\\mathtt{Setup}(1^{\\scriptscriptstyle\\lambda},\\Delta,1)\\rightarrow (pk,sk,\\vv{\\bm{d}})\\\\\n%\\mathcal{A}_{\\scriptscriptstyle 1}(1^{\\scriptscriptstyle\\lambda},pk, \\Delta,1)\\rightarrow state\\\\\n%m\\stackrel{\\scriptscriptstyle\\$}\\leftarrow \\mathcal{M}\\\\\n%\\mathtt {GenPuz}(m, pk, sk)\\rightarrow \\ddot{o}\\\\\n%\\end{array}    \\right]\\leq \\mu(\\lambda)$$\n%  \\end{definition}\n%  where $\\theta\\in \\ddot{o}$.\n%  \n%  \n%  \n%  xxx The above definition also captures the sequentiality for a single solution as well that means the adversary cannot find a single solution significantly less than required steps. \n%  \n \n  \n  \n\\begin{definition}[Multi-instance Time-lock Puzzle's Solution-Privacy]\\label{Def::Solution-Privacy} A multi-instance time-lock puzzle  is privacy-preserving  if for all $\\lambda$ and  $\\Delta$,  any number of puzzle: $z\\geq1$, any pair of randomised algorithm $\\mathcal{A} : (\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$, where $\\mathcal{A}_{\\scriptscriptstyle 1}$ runs in  time $O(poly(j\\Delta,\\lambda))$ and $\\mathcal{A}_{\\scriptscriptstyle 2}$ runs in  time $\\delta(j\\Delta)<j\\Delta$ using at most $\\pi(\\Delta)$ parallel processors, there exists a negligible function $\\mu(.)$, such that: \n\\small{\n$$ Pr\\left[  \\begin{array}{l} \n \\mathcal{A}_{\\scriptscriptstyle 2}(pk,\\ddot{o},\\text{state})\\rightarrow \\ddot{a}\\\\\n \\text{s.t.}\\\\\n\\ddot{a}:(b_{\\scriptscriptstyle i},i)\\\\\n  m_{\\scriptscriptstyle b_{\\scriptscriptstyle i},i}=m_{\\scriptscriptstyle b_{\\scriptscriptstyle j},j} \n  \\end{array}\n \\middle |\n    \\begin{array}{l}\n\\mathtt{Setup}(1^{\\scriptscriptstyle\\lambda},\\Delta,z)\\rightarrow (pk,sk,\\vv{\\bm{d}})\\\\\n%\\mathcal{A}_{\\scriptscriptstyle 1}(1^{\\scriptscriptstyle\\lambda},pk,z)\\rightarrow ([(m_{\\scriptscriptstyle 0,1},m_{\\scriptscriptstyle 1,1}),...,(m_{\\scriptscriptstyle 0,z},m_{\\scriptscriptstyle 1,z})],state)\\\\\n\\mathcal{A}_{\\scriptscriptstyle 1}(1^{\\scriptscriptstyle\\lambda},pk,z)\\rightarrow (\\vv{\\bm{m}},\\text{state})\\\\\n\\left[b_{\\scriptscriptstyle 1},...,b_{\\scriptscriptstyle z}\\right], b_{\\scriptscriptstyle j}\\stackrel{\\scriptscriptstyle\\$}\\leftarrow \\{0,1\\}\\\\\n%\\mathtt {GenPuz}((m_{\\scriptscriptstyle b_{\\scriptscriptstyle 1},\\scriptscriptstyle 1},..., m_{\\scriptscriptstyle b_{\\scriptscriptstyle z},\\scriptscriptstyle z}), pk, sk,\\vv{\\bm{d}})\\rightarrow \\ddot{o}\\\\\n\\mathtt {GenPuz}(\\vv{\\bm{m}}', pk, sk,\\vv{\\bm{d}})\\rightarrow \\ddot{o}\\\\\n\\end{array}    \\right]\\leq \\frac{1}{2}+\\mu(\\lambda)$$\n}\nwhere  $\\vv{\\bm{m}}: [(m_{\\scriptscriptstyle 0,1},m_{\\scriptscriptstyle 1,1}),...,(m_{\\scriptscriptstyle 0,z},m_{\\scriptscriptstyle 1,z})]$, $\\vv{\\bm{m}}':(m_{\\scriptscriptstyle b_{\\scriptscriptstyle 1},\\scriptscriptstyle 1},..., m_{\\scriptscriptstyle b_{\\scriptscriptstyle z},\\scriptscriptstyle z})$, $1\\leq j\\leq z$ and $1\\leq i\\leq z$\n%$b_{\\scriptscriptstyle j'}\\in \\left[b_{\\scriptscriptstyle 1},...,b_{\\scriptscriptstyle z}\\right]$. \n\\end{definition}\n\n%all probabilistic polynomial time adversaries $\\mathcal{A}=(\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$ whose run-time is  bounded by  $T_{\\scriptscriptstyle j}=j\\cdot poly(\\lambda,\\Delta)$, where  $j\\in [ 1,z]$, \n\n\nThe  definition above also ensures  the  solutions to appear after $j\\text{\\small{-th}}$ one,  remain hidden from the adversary with a high probability, as well. Similar to \\cite{BonehBBF18,MalavoltaT19,garay2019}, it captures that even if     $\\mathcal{A}_{\\scriptscriptstyle 1}$ computes on the public parameters for a polynomial time,  $\\mathcal{A}_{\\scriptscriptstyle 2}$  cannot find $j\\text{\\small{-th}}$  solution in time $\\delta(j\\Delta)<j\\Delta$ utilising $\\pi(\\Delta)$ parallel processors, with a probability significantly greater than $\\frac{1}{2}$. As highlighted in  \\cite{BonehBBF18}, we can set $\\delta(\\Delta)=(1-\\epsilon)\\Delta$ for a small  $\\epsilon$, where $0<\\epsilon<1$\n\\begin{definition}[Multi-instance Time-lock Puzzle's Solution-Validity]\\label{Def::Solution-Validity}\nA multi-instance time-lock puzzle preserves a   solution validity,   if  for all $\\lambda$ and  $\\Delta$,  any number of puzzles: $z\\geq1$, all probabilistic polynomial-time adversaries $\\mathcal{A}=(\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$ that run in  time $O(poly(\\Delta,\\lambda))$ there is  negligible function $\\mu(.)$, such that: \n\\small{\n$$ Pr\\left[\n    \\begin{array}{l}\n \\mathcal{A}_{\\scriptscriptstyle 2}(pk,\\vv{\\bm{s}}, \\ddot{o},\\text{state})\\rightarrow a\\\\ \n \n \\text{s.t.}\\\\ \na:(j,\\ddot{p}_{\\scriptscriptstyle j} ,\\ddot{p}')\\\\\n \\ddot{p}_{\\scriptscriptstyle j}: (m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j}), \n\\ddot{p}':(m',d') \\\\\n m_{\\scriptscriptstyle j}\\in \\vv{{\\bm{m}}}, d_{\\scriptscriptstyle j}\\in\\vv{{\\bm{d}}},\nm\\neq m'\\\\\n\\mathtt {Verify}(pk,\\ddot{p},h_{\\scriptscriptstyle j})= 1\\\\\n\\mathtt {Verify}(pk,\\ddot{p}',h_{\\scriptscriptstyle j})= 1\\\\\n\\end{array} \n\\middle |\n\\begin{array}{l}\n\n\\mathtt{Setup}(1^{\\scriptscriptstyle\\lambda},\\Delta,z)\\rightarrow (pk,sk,\\vv{\\bm{d}})\\\\\n\\mathcal{A}_{\\scriptscriptstyle 1}(1^{\\scriptscriptstyle\\lambda},pk, \\Delta,z)\\rightarrow (\\vv{{\\bm{m}}},\\text{state})\\\\\n\n\\mathtt {GenPuz}(\\vv{{\\bm{m}}}, pk, sk,\\vv{\\bm{d}})\\rightarrow \\ddot{o} \\\\\n\\mathtt {SolvPuz}(pk,\\vv{\\bm{o}})\\rightarrow \\vv{\\bm{s}}\n\n\\end{array} \n   \\right]\\leq  \\mu(\\lambda)$$\n   }\nwhere $\\vv{{\\bm{m}}}=[m_{\\scriptscriptstyle 1},...,m_{\\scriptscriptstyle z}]$, and $h_{\\scriptscriptstyle j}\\in \\vv{\\bm{h}}\\in \\ddot{o}$\n\\end{definition}\n\n\n%In Definition \\ref{Def::Solution-Validity}, we do not need to bound the adversaries' parallel computation power, as it does not need to solve any puzzles, in fact  puzzles' solutions are provided to them. Therefore, they can run in polynomial time $O(poly(\\Delta,\\lambda))$.\n% \n\\begin{definition}[Multi-instance Time-lock Puzzle Security]\\label{def::C-TLP-security} A multi-instance time-lock puzzle scheme  is secure if it meets solution-privacy and solution-validity properties. \n\\end{definition}\n\n\\vspace{-4mm}\n\n\\subsection{Chained  Time-lock Puzzle (C-TLP) Protocol}\\label{Section::C-TLP-protocol}\n\nIn this section, we present the chained  time-lock puzzle (C-TLP), an instantiation of the multi-instance time lock puzzle. Since we have already presented an outline of C-TLP (in Section \\ref{Overview-of-our-Solutions}), in this section we present C-TLP protocol in detail.  Recall, a client wants a server to learn a vector of messages: $\\vv{\\bm{m}}=[m_{\\scriptscriptstyle 1},...,m_{\\scriptscriptstyle z}]$ at times  $[f_{\\scriptscriptstyle 1},...,f_{\\scriptscriptstyle z}]$ respectively, where the client is available and online only at an earlier time $f_{\\scriptscriptstyle 0}< f_{\\scriptscriptstyle 1}$.  Also, the client wants to ensure that anyone can validate a solution found by the  server, i.e. supports public verifiability. For the sake of simplicity, let $\\Delta=f_{\\scriptscriptstyle 1}-f_{\\scriptscriptstyle 0}$ and $\\Delta=f_{\\scriptscriptstyle j+1}-f_{\\scriptscriptstyle j}$, where $1\\leq j \\leq z$ and $T=S \\Delta$. Below, we provide C-TLP protocol. We refer readers to Appendix \\ref{discussion-C-TLP} for further remarks on the protocol. \n\n\\input{CR-TLP-protocol-v2.tex}\n\n\n   \\begin{theorem}[C-TLP Security]\\label{C-TLP-Sec}  C-TLP  is a secure multi-instance time-lock puzzle. \n   \\end{theorem}\n   \n\\begin{proof}[Outline]\nThe proof of Theorem \\ref{C-TLP-Sec} relies on the security of the TLP, symmetric key encryption, and commitment schemes. It is also based on the fact that the probability to  find a certain random generator is negligible. It shows both C-TLP's solution privacy (due to security of the above three schemes) and validity (due to the security of the commitment) are satisfied.  We refer readers to Appendix \\ref{CR-TLP-Proof} for  detailed proof. \n\\end{proof}\n\n\\vspace{-2.5mm}\n%\n%\\begin{remark} Recall, to make each  puzzle instance, a distinct random generator: $r_{\\scriptscriptstyle j}$, is used. This is the reason, in  Fig. \\ref{fig:CTE}, before a puzzle  is  generated   in step \\ref{call-RTLP-GenPuz},  a new public key is set in step \\ref{set-pk-in-loop}.  Also, at the beginning of the protocol only $r_{\\scriptscriptstyle 1}$ is public and the rest of the generators are kept secret. They are found and used sequentially after their related puzzle is solved. \n%\\end{remark}\n%\n%\n%\\begin{remark} The commitments opening, including the commitment random values, are not known to other verifiers (than the puzzle generator) at the beginning of the protocol. At this point,  only the committed values are public. Once a solver solves each puzzle,  it  extracts one of the commitments' opening, and sends it to a public verifier who can check if the opening matches the commitment.  \n%\\end{remark}\n%\n%\\begin{remark}\n% In Fig. \\ref{fig:CTE}, we use the folklore hash-based commitment scheme, in the random oracle model, only to achieve more computation improvement than that can be achieved in the standard model. But C-TLP can utilise any efficient non-interactive commitment scheme in the \\emph{standard model} as well, e.g. Pedersen Commitment.\n%\\end{remark}\n%\n%\n%\\begin{remark}\n%The efficiency of  C-TLP scheme stems from three crucial factors: (a) removing computation overlaps when solving different puzzles: even though solving $j\\text{\\small{-th}}$ puzzle, where $j>1$, requires $jT$ squaring, $(j-1) T$ of the squaring is used to solve previous puzzles that leads to $\\frac{z+1}{2}$ times computation cost reduction at the server-side,  (b)  supporting reusable single  public parameter: $a=2^{\\scriptscriptstyle T}$, generated only once that costs $O(1)$, as opposed to the RSA TLP whose cost is linear: $O(z)$, and (c) supporting efficient verification: due to the way each message is encoded (i.e. embedding the opening in a solution). \n%\\end{remark}\n%\n%\\begin{remark}\n%C-TLP also can efficiently  be used in a multi-server setting,  where there are $z$ servers: $\\{S_{\\scriptscriptstyle 1},...,S_{\\scriptscriptstyle z}\\}$,  each $S_{\\scriptscriptstyle j}$ needs to solve puzzle $\\ddot{o}_{\\scriptscriptstyle j}$ at time $f_{\\scriptscriptstyle j}$ and passes on the solution to the next server $S_{\\scriptscriptstyle j+1}$ to solve the next puzzle by time $f_{\\scriptscriptstyle j+1}>f_{\\scriptscriptstyle j}$. In this setting,  due to the scalability property of C-TLP (and unlike using the existing time-lock puzzles naively), other servers do not need to start solving the puzzle   as soon as the client releases puzzles public parameters. Instead, they can wait until the previous solution is issued that saves them significant cost. Furthermore, a  server can first  verify the correctness  of the solution found by the previous server (due to the public verifiability of C-TLP),  if accepted then   it starts finding the next solution. \n%\\end{remark}\n%\n%\n%\\begin{remark}\n%In the following, we outline an  approach that looks an option to construct an efficient C-TLP; however, as we will show it would not be secure. In particular,  one uses the TLP to generate $z$ public and secret key pairs. Then, it uses the TLP to compute $z\\text{\\small{-th}}$ puzzle as $\\mathtt{TLP.GenPuZ}(m_{\\scriptscriptstyle z},pk_{\\scriptscriptstyle z},sk_{\\scriptscriptstyle z})\\rightarrow \\ddot{o}_{\\scriptscriptstyle z}$.  Then, it embeds $\\ddot{o}_{\\scriptscriptstyle z}$ into $(z-1)\\text{\\small{-th}}$ one, i.e. $\\mathtt{TLP.GenPuZ}(m_{\\scriptscriptstyle z-1}||\\ddot{o}_{\\scriptscriptstyle z},pk_{\\scriptscriptstyle z-1},sk_{\\scriptscriptstyle z-1})\\rightarrow \\ddot{o}_{\\scriptscriptstyle z-1}$. This process goes on until $\\ddot{o}_{\\scriptscriptstyle 1}$  is created. It sends the combined puzzles and public key (including all random generators) to the server; with the hope that puzzles can be solved sequentially and the time gap between finding two solutions will be $\\Delta$.  This approach is not secure, because as soon as the server accesses $\\ddot{o}_{\\scriptscriptstyle 1}$ and public parameters, it can in parallel perform $T$ squaring on every generator, i.e. $r^{\\scriptscriptstyle 2^{\\scriptscriptstyle T}}_{\\scriptscriptstyle i}$, for all $i, 1\\leq i\\leq z$. In this case, as soon as $\\ddot{o}_{\\scriptscriptstyle 1}$ is solved and  $\\ddot{o}_{\\scriptscriptstyle 2}$  is extracted, it has enough information to  immediately solve $\\ddot{o}_{\\scriptscriptstyle 2}$ and accordingly the rest of the puzzles without doing any further exponentiation. \n %\\end{remark}\n \n \n \\input{CR-TLP-cost-summary}\n % \\input{CR-TLP-proof}\n", "meta": {"hexsha": "71c46f0885230b398f1ab8b3ebf2b31b5b2ad44b", "size": 24287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/FC/multi-instance-TLP.tex", "max_stars_repo_name": "AydinAbadi/CR-LP", "max_stars_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/FC/multi-instance-TLP.tex", "max_issues_repo_name": "AydinAbadi/CR-LP", "max_issues_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/FC/multi-instance-TLP.tex", "max_forks_repo_name": "AydinAbadi/CR-LP", "max_forks_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.9911894273, "max_line_length": 1577, "alphanum_fraction": 0.7326965043, "num_tokens": 7036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43739733428408634}}
{"text": "\\chapter{Related work}\n\\label{sec:related-work}\nIn the Related work section, we introduce selected literature relevant in the scope of our thesis. In particular, we present two general-purpose survival methods, the Cox Proportional Hazards (\\emph{Cox PH}) model and the \\glsxtrfull{rsf}. Beyond general-purpose survival models, we also establish literature methods used for multi-omics integration in survival models. Lastly, we survey relevant miscellaneous literature related to our study, chiefly on \\glsxtrfull{sgl} regularization and supervised autoencoders.\n\nPlease note that some of this section might seem like background but was deliberately kept in the Related work section. We had to define specific algorithms (for example, survival trees) to do justice to specific related work. Since these topics are not background needed for \\emph{our} work, we chose to keep them in the Related work section, allowing users only interested in our work to skip over them.\n\n\\section{General purpose survival models}\n\\label{sec:gp-surv-models}\n\\subsection{Regression-based methods}\nSome of the earliest work in survival analysis goes back to the Cox Proportional Hazards (Cox PH) model \\citep{cox1972regression, breslow1975analysis}, which was derived by assuming that the \\glsxtrlong{hf} $\\lambda(t)$ can be decomposed multiplicatively into a time-dependent baseline hazard $\\lambda_0(t)$ and a patient (and thus covariate) specific partial hazard (Equation \\ref{eq:cox}). \n\n\\begin{equation}\\label{eq:cox}\n    \\lambda(t\\mid X_i) = \\underbrace{\\lambda_0(t)}_{\\text{baseline hazard}} \\ \\underbrace{\\text{exp}(X_i \\beta)}_{\\text{partial hazard}}\n\\end{equation}\n\nWhere $X_i$ is the covariate vector for patient $i$ and $\\beta$ are the parameters to be estimated. We also call the $X_i \\beta$ term the log-partial hazard. \n\nAssume we have our data given as a triplet, $(U_j, \\delta_j, X_j), \\ \\ j = 1, ..., n$. $U_j = \\text{min}(T_j, C_j)$ where $T_j$ is the time to event for patient $j$ and $C_j$ is the time to right-censoring for patient $j$. Further, let us assume noninformative censoring as defined in Chapter \\ref{sec:surv-intro}, that is the event is independent of the censoring time conditional on the covariates. Denote the ordered event times by $t_1 < ... < t_D$ and let $X_{(i)k}$ be the k-th feature for the patient who experienced the event at $t_i$. Lastly, define the risk set $R(t_i)$, as all patients who had not been censored and for whom the event had not occured immediately prior to $t_i$ (\\emph{i.e.,} who were \"at risk\" of experiencing the event at $t_i$) \\citep[p. 253]{klein2003survival}. Assuming for simplicity that there are no tied event times, we can then write the partial likelihood (Equation \\ref{eq:orig-pl}) based on the \\gls{hf}: \n\n\\begin{equation}\n\\label{eq:orig-pl}\n    L(\\beta) = \\prod_{i=1}^D \\frac{\\text{exp}(\\sum_{k=1}^p\\beta_k X_{(i)k})}{\\sum_{j \\in R(t_i)} \\text{exp}(\\sum_{k=1}^p\\beta_k X_{jk})}\n\\end{equation}\n\nWe can treat this partial-likelihood as a \"usual likelihood\" \\citep[p. 253]{klein2003survival} resorting to the standard technique of maximum likelihood to find the parameters which maximize it. In particular, most often the partial \\emph{log}-likelihood is maximized for numerical reasons (Equation \\ref{eq:pl-efron}):\n\n\n\\begin{equation}\\label{eq:pl-efron}\n    \\ell(\\beta) = \\text{log}(L(\\beta)) = \\sum_{i=1}^D \\sum_{k=1}^p \\beta_k X_{(i)k} - \\sum_{i=1}^D\\text{log}\\left(\\sum_{j \\in R(t_i)} \\text{exp}\\left(\\sum_{k=1}^p \\beta_k X_{jk}\\right)\\right)\n\\end{equation}\n\nWhich follows by basic algebra \\citep[p. 253]{klein2003survival}.\n\nUp to this point, we know only the partial hazard $\\text{exp}(X_i \\beta)$, but have not specified the baseline hazard $\\lambda_0$. While the baseline hazard is generally treated non-parametrically \\citep[p. 244]{klein2003survival}, at times it is not even specified since clinicians or researchers might be interested \"only\" in a direct interpretation of the regression coefficients found by maximizing the partial (log-)likelihood. In particular, we can investigate two patients with differing feature vectors $X$ and $X^*$ and compare their hazard functions according to the Cox PH model \\citep[p. 245]{klein2003survival}:\n\n\\begin{equation}\n    \\frac{\\lambda(t \\mid X)}{\\lambda(t \\mid X^*)} = \\frac{\\text{exp}(\\sum_{k=1}^p \\beta_k X_k)}{\\text{exp}(\\sum_{k=1}^p \\beta_k X^*_k)} = \\text{exp}\\left(\\sum_{k=1}^p \\beta_k (X_k - X_k^*)\\right)\n\\end{equation}\n\nSince this is a constant, this also directly gives the reason why the Cox PH model is called \"proportional hazards\" - because the hazard functions for any two patients are proportional to each other \\citep[p. 245]{klein2003survival}. A further interpretation of each coefficient $\\beta_i \\in \\beta$ is easiest to expose for binary covariates: Suppose we have two patients with covariate vectors $X = [1, x_2, ..., x_p]$ and $X^* = [0, x_2, ..., x_p]$. Then we have:\n\n\\begin{equation}\n    \\frac{\\lambda(t \\mid X)}{\\lambda(t \\mid X^*)} = \\frac{\\text{exp}(\\sum_{k=2}^p \\beta_k X_k) \\text{exp}(\\beta_1)}{\\text{exp}(\\sum_{k=2}^p \\beta_k X^*_k)} = \\text{exp}(\\beta_1)\n\\end{equation}\n\nThus, the natural interpretation of $\\beta_1$ is the risk of experiencing the event of a patient who had $x_1=1$ (whatever this may be) relative to another patient who had identical covariates except for $x_0 = 0$. While the exact interpretation of risk is not straightforward in this context, this interpretation of coefficients is nevertheless popular among clinicians and researchers. Reporting the effect of covariates on the hazard function like this is often deemed a \\emph{hazard ratio}. Equivalently, \"The hazard ratio is an estimate of the ratio of the hazard rate in the treated versus the control group\" \\citep{spruance2004hazard} (in the case when $X_0$ is a binary treatment).\n\nAbove, we assumed no ties were present (that is, no two patients experienced the event simultaneously). In real data, there are, however, usually ties present. The two most common strategies to handle these are the Breslow (Equation \\ref{eq:breslow-approx}) and Efron approximations (Equation \\ref{eq:efron-approx}).\\footnote{Note that all methods for tie handling collapse to the partial likelihood previously introduced in the presence of no ties \\citep[p. 260]{klein2003survival}.}\n\nLet $t_1 < ... < t_D$ denote $D$ \\emph{distinct} and ordered event times. Further, let $D_i$ be set number of patients who experienced the event at $t_i$, and $R_j$ be the set of patients who were at risk immediately prior to $t_j$ \\citep[p. 259]{klein2003survival}. Then, Breslow's approximation is \\citep[p. 259]{klein2003survival}:\n\n\\begin{equation}\\label{eq:breslow-approx}\n\\begin{split}\n        L_\\text{Breslow}(\\beta) = \\prod_{i=1}^D \\frac{\\text{exp}(\\beta \\sum_{j \\in D_i} X_j)}{\\left(\\sum_{j_ \\in R_i} \\text{exp}(\\beta X_j)\\right)}\n\\end{split}\n\\end{equation}\n\nAnd Efron's approximation is \\citep[p. 259]{klein2003survival}:\n\n\\begin{equation}\\label{eq:efron-approx}\n\\begin{split}\n        L_\\text{Efron}(\\beta) = \\prod_{i=1}^D \\frac{\\text{exp}(\\beta \\sum_{j \\in D_i} X_j)}{\\prod_{j=1}^{|D_i|}\\left(\\sum_{k \\in R_i} \\text{exp}(\\beta X_k) - \\frac{j-1}{d_i}\\sum_{k \\in D_i} \\text{exp}(\\beta X_k)\\right)}\n\\end{split}\n\\end{equation}\n\nWhere $\\beta$ are the coefficients to be estimated and $X_j$ is the covariate vector corresponding to patient $j$. Recall that in this case, the $i$s we multiply over are distinct events. It can be seen quite easily (Equation \\ref{eq:breslow-equivalence}) that the Breslow approximation is in effect the same thing as applying the original partial log-likelihood despite the presence of ties. Although the Efron approximation is slightly more accurate, it is also more challenging to program.\n\n\\begin{equation}\\label{eq:breslow-equivalence}\n    \\begin{split}\n            L_\\text{Breslow}(\\beta) = \\prod_{i=1}^D \\frac{\\text{exp}(\\beta \\sum_{j \\in D_i} X_j)}{\\left(\\sum_{j_ \\in R_i} \\text{exp}(\\beta X_j)\\right)} = \\prod_{i=1}^D \\prod_{j \\in D_i}\\frac{\\text{exp}(\\beta X_j)}{\\sum_{k \\in R_i} \\text{exp}(\\beta X_k)} = L(\\beta)\n    \\end{split}\n\\end{equation}\n\nDepending on the number of ties in a dataset, it thus makes sense to use the Efron approximation when available, especially since it is implemented in most common software packages for survival analysis today \\citep{polsterl2020scikit, survival-package-2020}.\n\nDue to colinearity leading to non-unique solutions, the unregularized Cox PH model can effectively only be used in $n \\geq p$ settings, similar to linear and logistic regression. However, there have been proposals to regularize the Cox model to handle high-dimensional data. \\citet{tibshirani1997lasso} proposed to use the Lasso \\citep{tibshirani1996regression} for regularization of Cox PH models (Equation \\ref{eq:cox-lasso}) and showed in simulations that the Lasso regularized Cox PH could outperform stepwise selection in estimating the true coefficients under the presence of noise variables while simultaneously providing a more stable model with respect to data changes. \\citet{simon2011regularization} later made an \\gls{en} regularized Cox PH model (Equation \\ref{eq:cox-en}) available as part of their \\emph{glmnet} \\citep{friedman2010regularization} software implementation, which is still one (if not the) most popular implementations of regularized Cox PH models used by researchers today.\n\n\\begin{equation}\\label{eq:cox-lasso}\n    \\beta \\in \\argmin_\\beta - \\ell(\\beta) + \\lambda ||\\beta||_1\n\\end{equation}\n\n\\begin{equation}\\label{eq:cox-en}\n    \\beta \\in \\argmin_\\beta - \\ell(\\beta) + \\alpha \\lambda ||\\beta||_1 + (1-\\alpha) \\lambda ||\\beta||^2_2, \\ \\ \\ \\alpha \\in [0, 1]\n\\end{equation}\n\nWhere $\\beta$ are the parameters to be estimated, $\\ell(\\beta)$ is a partial log-likelihood (depending on which tie approximation is used), $\\lambda$ is a regularization hyper-parameter and $\\alpha$ is a tradeoff hyper-parameter between the Lasso (for $\\alpha = 1$) and Ridge (for $\\alpha = 0$).\n\nRegularized Cox PH models are among the most used models for survival analysis today, both in studies predicting survival from a single input group (mostly gene expression) \\citep{ching2018cox} as well as in multi-omics work \\citep{herrmann2021large, hornung2019block, huang2019salmon}. Beyond preventing convergence issues seen in highly correlated or generally high-dimensional datasets, regularized Cox PH (especially the Lasso) is, of course, also popular for feature selection in survival analysis \\citep{tibshirani1997lasso}. Furthermore, regularized Cox PH has been extended in various ways for multi-omics data. We will cover these methods in Section \\ref{sec:multi-omics-stat}.\n\n\\subsection{Tree-based survival methods}\nAn alternative method for the prediction of survival times is the method of survival trees. Survival trees are a natural extension of regression and classification decision trees to survival data. Since the general way of fitting survival trees is identical to that of regression or classification trees, we first briefly introduce decision trees more broadly and then highlight what distinguishes survival trees.\n\n\\subsubsection{Decision trees}\nA decision tree \"aims to partition the covariate space recursively to form groups (nodes in the tree) of subjects which are similar according to the outcome of interest\" \\citep{bou2011review}. The partitioning is performed by optimizing a measure of node impurity specific to the task being performed. Depending on the particular algorithm used, trees are generally built starting with all observations. An exhaustive search is performed to find the best binary split (according to the split point criterion). The algorithm runs until some stopping criterion is met, \\emph{e.g.,} the minimum size of a leaf node (Algorithm \\ref{alg:decision-tree}) \\citep{bou2011review, friedman2001elements}. All stopping criteria are designed to prevent trees from overfitting the data too much, as would be possible by assigning each sample its own leaf node.\n\n\\begin{algorithm}\n\\centering\n    \\caption{Decision tree training algorithm \\citep{bou2011review, friedman2001elements}.}\\label{alg:decision-tree}\n        \\begin{algorithmic}\n        \\Require $X, y, \\text{split point criteria}, \\text{stopping criteria}, m$\n        \\State Initialize tree\n        \\For{each terminal node}\n            \\While{none of the stopping criteria is met}\n                \\State Select $m$ variables at random from all $p$ available variables (a split is performed on only $1$ variable out of the $m$)\n                \\State Pick the binary split maximizing the split-point criterion\n                \\State Split the terminal node into two daughter nodes\n            \\EndWhile\n        \\EndFor\n        \\State \\Return tree\n    \\end{algorithmic}\n\\end{algorithm}\n\nWhere $m$ is the number of variables to be considered at each split (where $m \\leq p$). After training, a decision tree \\emph{may} have overfitted the data, depending on the stopping criteria. The tree can then be pruned (\\emph{i.e.,} have some of its splits removed) if desired to enhance generalizability \\citep{bou2011review}. Alternatively, ensembles of overfit decision trees may be used to improve generalization capabilities. Since pruning is less used today and most implementations rely on tree ensembles, we neglect to develop pruning further. \n\nOnce the tree has been fitted, the prediction for a new sample that ends in leaf node \\(i\\) is made using a suitable summary statistic of the target of all training samples in the same leaf node, \\emph{e.g.,} the majority class within the leaf node in classification (Figure \\ref{fig:rpart-iris-class}).\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_iris_class_tree.png} \\caption{Example classification tree grown on the \\emph{iris} dataset \\citep{fisher1936use, anderson1936species}.}\\label{fig:rpart-iris-class}\n\\end{figure}\n\n\\subsubsection{Survival trees}\nSurvival trees differ from decision trees primarily in the split point criterion used, their stopping criteria, and how the final prediction is made, all of which \\emph{may} be specific to survival data. \n\nWhile there are various possibilities for split-point criteria in survival trees (we refer to \\citet{bou2011review} for a review), we focus on the log-rank splitting rule, as this is both the most common and also the one employed by \\emph{ranger} \\citep{wright2015ranger} and \\emph{BlockForest} \\citep{hornung2019block}, two tree-based survival methods which we included in our study for purposes of benchmarking. \n\nTo define the log-rank statistic used for survival trees, we follow the exposition in \\citet{segal1988regression} and draw the readers attention to Figure \\ref{fig:surv-table}. Let $A_i$ be the random variable denoting the number of deaths in population $1$ for survival table $i$. Let $\\{1, ..., k\\}$ be all distinct, uncensored observations (for each of which there will be a table). Our null hypothesis is that \"the death rates for the two populations are equal\" \\citep{segal1988regression}. Under $H_0$ and for all marginal totals fixed, $A_i$ can be shown to be hypergeometric, with the following expected value and variance \\citep{segal1988regression, fisher1935logic}:\n\n\\begin{equation}\n    \\mathbbm{E}_0(A_i) = \\frac{m_{i1} n_{i1}}{n_i}\n\\end{equation}\n\nand \n\n\\begin{equation}\n    \\mathbbm{V}_0(A_i) = \\frac{m_{i1} (n_i - m_{i1})}{n_i -1 } \\cdot \\left(\\frac{n_{i1}}{n_i} \\left(1- \\frac{n_{i1}}{n_i} \\right)\\right)\n\\end{equation}\n\nwhere $n_i = n_{i1} + n_{i2}$. The log-rank statistic $T_{\\text{LR}}$ is then (Equation \\ref{eq:log-rank}) \\citep{segal1988regression}:\n\n\\begin{equation}\n    T_{\\text{LR}} = \\frac{\\sum_{i=1}^k (a_i - \\mathbbm{E}_0(A_i))}{\\sqrt{\\sum_{i=1}^k \\mathbbm{V}_0(A_i)}}\n    \\label{eq:log-rank}\n\\end{equation}\n\n\n\\begin{figure}\n\\centering\n\\begin{tikzpicture}[\nbox/.style={draw,rectangle,minimum size=2cm,text width=1.5cm,align=center}]\n\\matrix (conmat) [row sep=.1cm,column sep=.1cm] {\n\\node (tpos) [box,\n    label=left:\\( \\textbf{Population 1} \\),\n    label=above:\\( \\textbf{Dead} \\),\n    ] {$a_i$};\n&\n\\node (fneg) [box,\n    label=above:\\textbf{Alive},\n    label=above right:,\n    label=right:\\( n_{i1} \\)] {};\n\\\\\n\\node (fpos) [box,\n    label=left:\\textbf{Population 2},\n    label=below left:,\n    label=below:\\(m_{i1}\\)] {};\n&\n\\node (tneg) [box,\n    label=right:\\(\\),\n    label=below:] {};\n\\\\\n};\n\\end{tikzpicture}\n\\caption{Survival table to define the log-rank statistic. Reproduced from \\citet{segal1988regression}.}\n\\label{fig:surv-table}\n\\end{figure}\n\nOn a more practical note, one may imagine our training samples being stratified by the variable under consideration (for example, if one was to split on gender, population one might be female and population two male). Further, recall that since we consider only \\emph{distinct} censored observations, it is possible that multiple samples from each population died at a specific time $t^* \\in \\{1, ..., k\\}$.\n\nFor stopping criteria, the standard \\emph{Python} implementation of survival trees, \\emph{sksurv} \\citep{polsterl2020scikit}, uses a specific number of minimum samples to be contained in a leaf for a split to be attempted, combined with a minimum number of samples to be included in each leaf node after the split. Another option is setting a max depth (\\emph{e.g.,} a max depth of $x$ means the tree can perform at most $x$ splits in total). In survival trees, another possible stopping criterion is requiring each leaf node after a split to contain at last $d_0 > 0$ unique event times \\citep{ishwaran2008random}.\n\nFor the final prediction for a new individual $i$, survival trees most often return either an estimate of the \\gls{chf} (Definition \\ref{def:cumulative-hazard}) or an estimate of the \\gls{sf} (Definition \\ref{def:surv-funct}), both of which are estimated based on all training samples falling into the same leaf node as $i$. The \\gls{chf} function is usually estimated using the \\emph{Nelson-Aalon} estimator \\citep[p. 93-95]{klein2003survival} (Equation \\ref{eq:nelson-aalon}). Meanwhile, the survival function is usually estimated using the \\emph{Kaplan-Meier} estimator \\citep[p. 92]{klein2003survival} (Equation \\ref{eq:km}).\n\n\\begin{equation}\n    \\hat \\Lambda(t) = \\left\\{\\begin{array}{lr}\n        0, & \\text{if }  t \\leq t_1\\\\\n        \\sum_{t_i \\leq t} \\frac{|D_i|}{|R_i|}, & \\text{if } t_1 \\leq t\n        \\end{array}\\right.\n    \\label{eq:nelson-aalon}\n\\end{equation}\n\n\\begin{equation}\n    \\hat S(t) = \\left\\{\\begin{array}{lr}\n        1, & \\text{if }  t < t_1\\\\\n        \\prod_{t_i \\leq t} \\left(1 - \\frac{|D_i|}{|R_i|}\\right), & \\text{if } t_1 \\leq t\n        \\end{array}\\right.\n    \\label{eq:km}\n\\end{equation}\n\nWhere $D_i$ is the set of patients who experienced an event at $t_i$ and $R_i$ is the set of patients which were at risk at time $t_i$ (\\emph{i.e.,} patients who had not been censored or experienced the event immediately prior to $t_i$) \\citep[p. 91-92]{klein2003survival}. Both the Kaplan-Meier and the Nelson-Aalen estimator are not defined for $t > t_\\text{max}$, where $t_\\text{max} = \\text{max}\\{t_1, ..., t_n\\}$ \\citep[p. 91-94]{klein2003survival}.\n\nFigure \\ref{fig:ctree-surv} shows an example survival tree built using \\emph{partykit} \\citep{hothorn2015partykit} on the veteran \\citep{kalbfleisch2011statistical} dataset contained in the \\emph{R} \\emph{survival} package \\citep{survival-package-2020}. In addition to the splits, Figure \\ref{fig:ctree-surv} also shows the p-value of the log-rank test (middle) and the Kaplan-Meier estimations of the survival curves for each leaf node.\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_veteran_surv_tree.png} \\caption{Example survival tree grown on the \\emph{veteran} dataset \\citep{kalbfleisch2011statistical}.}\\label{fig:ctree-surv}\n\\end{figure}\n\nWe now introduce random (survival) forests, the most common ensemble of decision trees (hence the name forest), and, more broadly, the most common usage of decision trees today. \n\n\\subsubsection{Random (survival) forests}\nIn random forests \\citep{breiman2001random}, a few adjustments are made to decision trees to de-correlate the trees from each other while keeping the variance of each tree as small as possible \\citep{friedman2001elements}.\\footnote{This analysis can be made much more rigorous, essentially showing that the bias of a random forest is equal to that of any individual bootstrapped tree within the forest. Furthermore, it can be shown that as $B \\to \\infty$, the variance of the prediction (in the case of regression trees; since this is a mean) is equal to the pairwise correlation between trees times the variance of each tree. Thus, the goal is to reduce the correlation between trees as much as possible while keeping variance moderate.}\n\nFirst, each split within each tree is made using only a subset of input features.\\footnote{While this is also possible with singular decision trees, it is much more common in random forests.} Standard options include only considering the square root or logarithm of all input features (randomly sampled) at each split in each tree. Secondly, random forests randomly sample input samples (with replacement) until the number of samples equals a certain fraction of the original number of input samples. Both of these adjustments decrease the pairwise correlation among decision trees in the random forest, which can improve overall performance \\citep{breiman2001random}. Algorithm \\ref{alg:random-forest} gives a full overview \\citep{friedman2001elements}.\n\n\\begin{algorithm}[H]\n\\centering\n    \\caption{Random forest training algorithm \\citep{friedman2001elements}.}\\label{alg:random-forest}\n        \\begin{algorithmic}\n        \\Require $X, y, \\text{split point criterion}, \\text{stopping criteria}, m, B, u$\n        \\State Initialize forest\n        \\For{$i = 1, ..., {B}$}\n            \\State Draw a bootstrap sample $X^*$ of size $u * n$ from $X$\n            \\State Initialize $T_i$\n            \\State $T_i \\gets \\text{train decision tree}(X^*, y, \\text{split point criterion}, \\text{stopping criteria}, m)$ (Algorithm \\ref{alg:decision-tree})\n            \\State forest[i] $\\gets T_i$\n        \\EndFor\n        \\State \\Return forest\n    \\end{algorithmic}\n\\end{algorithm}\n\nWhere $B$ is the number of trees in the random forest, $u$ is the size of each bootstrapped dataset relative to the original dataset (which is of size $n$), and $m$ is the number of variables to consider at each split (where $m \\leq p$).\n\nTo get a final prediction using a random forest, the predictions from all decision trees in the forest are ensembled using a summary statistic. This can be done using the majority class for classification problems, while the mean may be used for regression problems.\n\n\\citet{ishwaran2008random} introduced random survival forests, an extension of random forests to survival trees. The researchers grew a forest of survival trees, using a split point criterion and stopping criteria of choice. Afterward, the ensemble prediction (for the \\gls{chf} or the \\gls{sf}) is made by taking the mean of the respective predictions (for either the \\gls{chf} or the \\gls{sf}) of each tree in the forest \\citep{ishwaran2008random}. \\citet{ishwaran2008random} showed that their new methods of random survival forests could outperform the Cox PH model across various survival datasets in terms of Harrell's concordance index \\citep{harrell1982evaluating}. Since survival random forests have shown to perform well without excessive tuning, they are often included when performing benchmarks on survival data \\citep{herrmann2021large, hornung2019block, huang2019salmon}.\n\nHaving covered the general-purpose survival models needed in the scope of our thesis, we now move on to survival models specifically designed for multi-omics integration.\n\n\\section{Multi-omics survival models}\nAs explained in Chapter \\ref{sec:multi-omics}, multi-omics data needs specific methods to properly integrate it due to factors such as strong correlations between and within groups of variables and vastly differing dimensions of input variable groups \\citep{boulesteix2017ipf, herrmann2021large}. We start by surveying statistical methods for multi-omics integration in survival models before moving on to neural networks.\n\n\\subsection{Statistical methods}\n\\label{sec:multi-omics-stat}\n\\citet{hornung2019block} proposed five variations of the random survival forest algorithm tailored for multi-omics integration. All of their models change the way variables are sampled in the random forest for split point selection by considering that the input variables belong to different blocks (\\emph{i.e.,} groups). The basic idea is thus to account for the fact that some variable groups (\\emph{e.g.,} clinical data) may be of much smaller dimension but contain a lot of prognostic information. Two of their five proposed variants (in particular, \\glsxtrfull{bf} and \\emph{RandomBlock}) performed significantly better than \\glsxtrfull{rsf} across 20 \\gls{tcga} datasets as measured by Harrell's concordance \\citep{harrell1982evaluating}. Furthermore, \\gls{bf}, their best performing method, has been shown to perform state-of-the-art among statistical models for multi-omics survival analysis in both their work and a large-scale benchmarking study considering only non-neural methods \\citep{hornung2019block, herrmann2021large}. \\emph{BlockForest} and its variants are non-sparse. That is, they use all variables initially selected for prediction, which may make the transfer to clinical settings more difficult. Some variants, in particular \\emph{RandomBlock}, expose block selection probabilities, however, which allow for an assessment of the importance of each modality \\citep{hornung2019block}.\n\n\\citet{boulesteix2017ipf} proposed a Lasso model which scales the Lasso penalty \\(\\lambda\\) with a group-specific penalty factor that can be chosen either through \\emph{a priori} knowledge or determined using cross-validation. Their new model, termed \\emph{ipflasso}, performed better than Lasso regularized Cox PH, separate Lasso fits to each modality combined using logistic regression and \\glsxtrlong{sgl} regularized Cox PH on \\gls{tcga} as measured by the integrated brier score \\citep{brier1950verification} when integrating clinical data, gene expression and CNV for \\gls{tcga}-\\gls{laml}. Furthermore, \\emph{ipflasso} yielded among the sparsest models of all methods considered in their benchmark, selecting only $7.3$ variables on average on the \\gls{tcga}-\\gls{laml} dataset.\n\n\\citet{klau2018priority} introduced a sequential regression approach based on so-called offsetting, \\emph{prioritylasso}, which considers input modalities one at a time in a specific order and uses the previous model prediction as an offset. The authors showed that their model could perform as well as or better than Lasso regularized Cox PH on an acute myeloid leukemia dataset. Furthermore, \\emph{prioritylasso} on average selected sparser models relative to Lasso regularized Cox PH and, in particular, also allows clinicians to give preference to certain blocks by assigning them a higher priority order (that is, considering them first, or at least earlier in the sequential modeling process). Both \\emph{prioritylasso} and \\emph{ipflasso} might thus be more suitable for clinics, as they emphasize their \\emph{transportability}, that is the fact that they can be used by simply communicating the selected features, preprocessing strategy, and coefficients. This can be a big advantage relative to other models, which might require clinics to run their code, which might become deprecated over the years \\citep{klau2018priority, boulesteix2017ipf}.\n\n\\subsection{Neural networks}\nEspecially starting with \\citet{ching2018cox}, there has been much interest in applying neural networks to estimating the log-partial hazard term, $X_i\\beta$, in the Cox PH model by minimizing the partial log-likelihood. \\citet{ching2018cox} used a neural network architecture with one hidden layer, dropout, and L2 regularization to predict survival from only gene expression.\\footnote{The work of \\citet{ching2018cox} is thus not a multi-omics model, but we felt compelled to include it anyway since it was formative for a lot of other work in the literature.} Their architecture outperformed \\gls{rsf}, Ridge regularized Cox PH (Equation \\ref{eq:cox-en} with $\\alpha=0$), and \\emph{coxboost} \\citep{binder2015package} on ten \\gls{tcga} cancers in terms of Harrell's concordance and Inverse Probability of Censoring Weighting concordance \\citep{uno2011c}.\n\n\\citet{xie2019group} proposed an architecture similar to \\citet{ching2018cox} for multi-omics data including gene expression, CNV, RPPA, mutation and clinical data. Their model uses Group-Lasso regularization on the edges going from the input to the first hidden layer. The authors showed that Group-Lasso regularization prevented overfitting relative to Lasso and using no regularization and statistically significantly outperformed the same architecture with Lasso regularization as well as no regularization on $3$ out of $14$ considered \\gls{tcga} cancers.\n\n \\citet{cheerla2019deep} proposed a novel neural network architecture that integrates gene expression, miRNA, clinical data, and whole slide images to cancer survival on 20 \\gls{tcga} cancer types by optimizing the partial log-likelihood. Their model benefitted (\\emph{i.e.,} exhibited an increased Harrell's concordance index) from pan-cancer training relative to training on each cancer for most considered cancers. Although \\citet{cheerla2019deep} did not consider direct benchmarks in their study since they were able to handle missing modalities (which none of the benchmarks would have been able to), they note that in direct comparisons, they generally performed as well as or better than comparable studies.\n \n \\citet{kim2020improved} proposed an architecture based on a \\gls{vae} \\citep{kingma2013auto} on which they applied transfer learning. The authors trained their \\gls{vae} on 20 \\gls{tcga} cancers using gene expression only and transferred the weights of the first two layers to a neural survival model with an additional hidden layer, which was fine-tuned on each of the same ten \\gls{tcga} cancers on which \\emph{cox-nnet} \\citep{ching2018cox} was benchmarked.\\footnote{The work of \\citet{kim2020improved} was similarly not a multi-omics method. Still, we once again felt compelled to include it as it was one of the few examples of transfer learning in neural models for survival analysis.} Their model outperformed both \\emph{cox-nnet} and regularized Cox PH in terms of Harrell's concordance on seven out of the ten cancers considered. The models of \\citet{tong2020deep} were trained sequentially, meaning that not everything was trained jointly as would be the case with supervised autoencoders.\n\n\\citet{tong2020deep} explored multi-modal autoencoders for the integration of multi-omics data in \\gls{tcga}-\\gls{brca} survival. The authors proposed two architectures, each of which uses a dedicated autoencoder per input modality. The first, termed \\emph{CrossAE}, tries to reconstruct both its own input and all other input variable groups. Afterward, \\emph{CrossAE} mean pools the latent representations and uses the result to predict the log-partial hazard. In their second architecture, \\emph{ConcatAE}, each autoencoder only reconstructs its input. Afterward, the model concatenates all latent representations and uses them to predict the log-partial hazard. When comparing different combined modalities and their different architectures, \\emph{ConcatAE} performed the best in terms of Uno's concordance index \\citep{uno2011c} when integrating methylation and miRNA and using \\gls{pca} for dimensionality reduction. \n\n\\citet{huang2019salmon} modelled \\gls{tcga}-\\gls{brca} survival by integrating \\gls{mirna}, \\gls{mrna}, \\gls{cnv}, and mutation data. They proposed an architecture that takes the \\gls{mrna}-seq eigengene and the \\gls{mirna}-seq eigengene matrices, both passed through a hidden layer individually (\\emph{i.e.,} \\gls{mirna} does not interact with \\gls{mrna}). Afterward, a final layer predicts the log-partial hazard from the output of the hidden layer of \\gls{mirna}, the hidden layer of \\gls{mrna}, \\gls{cnv}, mutation, and selected clinical variables. Their new model outperformed \\gls{rsf}, regularized Cox PH and \\emph{deepsurv} \\citep{katzman2018deepsurv} as measured by Harrell's concordance.\n\n\\citet{jiang2020tlsurv} performed survival analysis of TCGA-LUAD by integrating a combination of CNV, DNA methylation, miRNA, and mRNA.\\footnote{Please note that the authors always combined a maximum of two input modalities at a time.} In particular, they proposed a \"super-hybrid network\" based on the idea of sequentially training each part of the network. They integrated each multi-omics modality by first fitting a one-hidden layer neural network (\\emph{i.e.,} not an autoencoder) on each block to predict survival. Afterward, the hidden nodes from each modality's network were fused by a multi-modal autoencoder using mean-pooling or concatenation. The fused view of all modalities was then passed into a survival network which mirrors the architecture of \\emph{coxnnet} \\citep{ching2018cox} to predict the log-partial hazard for each patient. \\citet{jiang2020tlsurv} showed that their mean-pooling approach, \\emph{TLSurv (MAE)}, was able to outperform the best \\emph{coxnnet} model in terms of time-dependent concordance \\citep{antolini2005time} when integrating methylation and miRNA, methylation and mRNA as well as mRNA and miRNA.\\footnote{The authors fit \\emph{coxnnet} on each modality individually, the best performing of which was mRNA.} \\emph{TLSurv (MAE)} was not able to outperform the best \\emph{coxnnet} model when integrating any of the other two modalities combined. Similarly, \\emph{TLSurv (VAE)}, their model leveraging concatenation based on a \\gls{vae}, was not able to outperform the best performing \\emph{coxnnet} model using any combination of modalities.\n\nHaving covered the work we deemed relevant in terms of general-purpose and multi-omics survival methods, we come to miscellaneous related work, chiefly on the topic of supervised autoencoders and \\gls{sgl} regularization.\n\n\\section{Miscellaneous}\n\\subsection{Supervised autoencoders}\n\\citet{tan2020multi} presented an application of supervised autoencoders on \\gls{tcga} data. The authors predicted binarized clinical endpoints (\\emph{e.g.,} overall survival, disease-free survival) from \\gls{tcga} data using methylation, \\gls{mirna}, \\gls{mrna}, and \\gls{rppa}. They trained one supervised autoencoder for each omics modality and fused their latent spaces using mean pooling, from which they then predicted the endpoint. Their new architecture outperformed other machine learning models such as random forests and support vector machines on binary endpoint classification in terms of \\emph{ROC AUC} \\citep{bradley1997use}.\n\n\\subsection{Sparse-Group-Lasso (SGL) regularization}\n\\gls{sgl} \\citep{friedman2010note, simon2013sparse} regularization is a convex combination of the Lasso \\citep{tibshirani1996regression} and the Group-Lasso \\citep{yuan2006model} (Equation \\ref{eq:sgl}):\n\n{\n\\begin{equation} \n  \\beta \\in \\argmin_{\\beta} \\sum_{i=1}^n L(y_i, \\hat y_i) + (1-\\alpha)\\lambda \\sum_{l=1}^m \\sqrt{p_l}||\\beta^{(l)}||_2 + \\alpha \\lambda ||\\beta||_1, \\ \\ \\ \\alpha \\in [0, 1]\n  \\label{eq:sgl}\n\\end{equation}\n}\n\nWhere $L$ is a loss function appropriate for the task we are interested in,  $\\beta$ are the parameters to be estimated, $\\lambda$ is a regularization hyper-parameter, and $\\alpha$ is a trade-off hyper-parameter between the Lasso (for $\\alpha = 1$) and the Group-Lasso (for $\\alpha = 0$). $\\beta$ is the full parameter vector to be estimated, $\\beta^{(l)}$ are the parameters corresponding to variable group $l$, and $p_l = |\\beta^{(l)}|$. \n\nInitially introduced by \\citet{friedman2010note}, \\gls{sgl} regularization tries to promote sparsity within groups (through the Lasso) and between groups (through the Group-Lasso). The hope is that incorporating the group structure of the input variables can increase accuracy and sparsity \\citep{simon2013sparse}. \\citet{simon2013sparse} showed that \\gls{sgl} could perform as well as or better than the Lasso and the Group-Lasso when grouped inputs (\\emph{e.g.,} pathways) were available, depending on the exact problem at hand. In addition, \\gls{sgl} was generally able to achieve at least as high group-level sparsity as the Group-Lasso while achieving higher overall sparsity (since \\gls{sgl} was able to include only some variables from a specific group). \\citet{simon2013sparse} made their code available in an \\emph{R} package, \\emph{SGL} \\citep{sgl2019}, in which they set $\\alpha=0.95$ as the default.\n\n\\gls{sgl} regularization can also be applied to neural networks, as done for example by \\citet{scardapane2017group}, who treated \"all outgoing weights from a neuron as a single group\" \\citep{scardapane2017group} and showed that this regularization combined with clipping weights below a certain threshold to zero produced much sparser networks at comparable accuracy relative to L1, L2, and Group-Lasso regularization. \\gls{sgl} regularization has also been used in more applied settings. \\citet{lemsara2020pathme} proposed a multi-modal autoencoder, deemed \\emph{PathME}, which leverages \\gls{sgl} regularization between different multi-omics feature groups to perform, in combination with sparse non-negative matrix factorization, clustering of \\gls{tcga} patients.\n\nThere is also work on the weighted \\gls{sgl}, that is, using different penalty factors for the variables (or group of variables) in the Group-Lasso or Lasso terms, similar to what \\emph{ipflasso} \\citep{boulesteix2017ipf} proposed to do for the Lasso. \\citet{che2020genetic} used the weighted Sparse-Group-Lasso for genetic variant detection and placed a prior information weight on each element of the vector \\(\\beta\\) in the Lasso term based on prior biological information which they obtained from their input data  (Equation \\ref{eq:weighted-sgl}).\n\n{\n\\begin{equation} \n  \\beta \\in \\argmin_\\beta \\sum_{i=1}^n L(y_i, \\hat y_i) + (1-\\alpha)\\lambda \\sum_{l=1}^m \\sqrt{p_l}||\\beta^{(l)}||_2 + \\alpha \\lambda ||\\omega \\beta||_1, \\ \\ \\ \\alpha \\in [0, 1]\n  \\label{eq:weighted-sgl}\n\\end{equation}\n}\n\nWhere $\\omega$ is a weight vector adjusting the weight of the Lasso penalty for each variable. $\\beta$ is the full parameter vector to be estimated, $\\beta^{(l)}$ are the parameters corresponding to variable group $l$, and $p_l = |\\beta^{(l)}|$. Although \\citet{che2020genetic} chose to only weight the coefficients within the Lasso penalty, the same is possible for the Group-Lasso term (Equation \\ref{eq:weighted-sgl-both})\n\n{\n\n\\begin{equation} \n  \\beta \\in \\argmin_\\beta \\sum_{i=1}^n L(y_i, \\hat y_i) + (1-\\alpha)\\lambda \\sum_{l=1}^m \\sqrt{p_l \\zeta^{(l)}}||\\beta^{(l)}||_2 + \\alpha \\lambda ||\\omega \\beta||_1, \\ \\ \\ \\alpha \\in [0, 1]\n  \\label{eq:weighted-sgl-both}\n\\end{equation}\n}\n\nWhere $\\zeta$ is a weight vector adjusting the weight of the Group-Lasso penalty for each input variable group.\n", "meta": {"hexsha": "fb251397ffed1e72a60a83dd7a40b89214029832", "size": 39244, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/content/chapter-related-work.tex", "max_stars_repo_name": "dnwissel/msc_thesis", "max_stars_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/content/chapter-related-work.tex", "max_issues_repo_name": "dnwissel/msc_thesis", "max_issues_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/content/chapter-related-work.tex", "max_forks_repo_name": "dnwissel/msc_thesis", "max_forks_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-24T20:41:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-24T20:41:39.000Z", "avg_line_length": 127.8306188925, "max_line_length": 1583, "alphanum_fraction": 0.7664101519, "num_tokens": 10552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43739732686493005}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\date{}\n\\title{NUMERIC}\n\\author{Herbert Melenk \\\\\nKonrad--Zuse--Zentrum f\\\"ur Informationstechnik Berlin \\\\\nTakustra\\\"se 7 \\\\\nD--14195 Berlin -- Dahlem \\\\\nFederal Republic of Germany \\\\[0.05in]\nE--mail: melenk@zib.de}\n\\begin{document}\n\\maketitle\n\n\\index{NUMERIC package}\nThe {\\small NUMERIC} package implements some numerical (approximative)\nalgorithms for \\REDUCE, based on the \\REDUCE\\ rounded mode\narithmetic. These algorithms are implemented for standard cases.\nThey should not be called for ill-conditioned problems;\nplease use standard mathematical libraries for these.\n\n\\section{Syntax}\n\n\\subsection{Intervals, Starting Points}\n\nIntervals are generally coded as lower bound and\nupper bound connected by the operator \\verb+`..'+, usually\nassociated to a variable in an\nequation. E.g.\n\n\\begin{verbatim}\n     x= (2.5 .. 3.5)\n\\end{verbatim}\n\nmeans that the variable x is taken in the range from 2.5 up to\n3.5. Note, that the bounds can be algebraic\nexpressions, which, however, must evaluate to numeric results.\nIn cases where an interval is returned as the result, the lower\nand upper bounds can be extracted by the \\verb+PART+ operator\nas the first and second part respectively.\nA starting point is specified by an equation with a numeric\nrighthand side, e.g.\n\n\\begin{verbatim}\n     x=3.0\n\\end{verbatim}\n\nIf for multivariate applications several coordinates must be\nspecified by intervals or as a starting point, these\nspecifications can be collected in one parameter (which is then\na list) or they can be given as separate parameters\nalternatively. The list form is more appropriate when the\nparameters are built from other REDUCE calculations in an\nautomatic style, while the flat form is more convenient\nfor direct interactive input.\n\n\\subsection{Accuracy Control}\n\nThe keyword parameters $accuracy=a$ and $iterations=i$, where\n$a$ and $i$ must be positive integer numbers, control the\niterative algorithms: the iteration is continued until\nthe local error is below $10^{-a}$; if that is impossible\nwithin $i$ steps, the iteration is terminated with an\nerror message. The values reached so far are then returned\nas the result.\n\n\\subsection{tracing}\n\nNormally the algorithms produce only a minimum of printed\noutput during their operation. In cases of an unsuccessful\nor unexpected long operation a trace of the iteration can be\nprinted by setting\n\n\\begin{verbatim}\n    on trnumeric;\n\\end{verbatim}\n\n\n\\section{Minima}\n\nThe Fletcher Reeves version of the $steepest\\ descent$\nalgorithms is used to find the minimum of a\nfunction of one or more variables. The\nfunction must have continuous partial derivatives with respect to all\nvariables. The starting point of the search can be\nspecified; if not, random values are taken instead.\nThe steepest descent algorithms in general find only local\nminima.\n\nSyntax:\n\n\\begin{description}\n\\item[NUM\\_MIN] $(exp, var_1[=val_1] [,var_2[=val_2] \\ldots]$\n\n$             [,accuracy=a][,iterations=i]) $\n\nor\n\n\\item[NUM\\_MIN] $(exp, \\{ var_1[=val_1] [,var_2[=val_2] \\ldots] \\}$\n\n$             [,accuracy=a][,iterations=i]) $\n\n\nwhere $exp$ is a function expression,\n\n$var_1, var_2, \\ldots$ are the variables in $exp$ and\n$val_1,val_2, \\ldots$ are the (optional) start values.\n\nNUM\\_MIN tries to find the next local minimum along the descending\npath starting at the given point. The result is a list\nwith the minimum function value as first element followed by a list\nof equations, where the variables are equated to the coordinates\nof the result point.\n\\end{description}\n\nExamples:\n\n\\begin{verbatim}\n   num_min(sin(x)+x/5, x);\n\n   {4.9489585606,{X=29.643767785}}\n\n   num_min(sin(x)+x/5, x=0);\n\n   { - 1.3342267466,{X= - 1.7721582671}}\n\n   % Rosenbrock function (well known as hard to minimize).\n   fktn := 100*(x1**2-x2)**2 + (1-x1)**2;\n   num_min(fktn, x1=-1.2, x2=1, iterations=200);\n\n   {0.00000021870228295,{X1=0.99953284494,X2=0.99906807238}}\n\n\\end{verbatim}\n\n\\section{Roots of Functions/ Solutions of Equations}\n\nAn adaptively damped Newton iteration is used to find\nan approximative zero of a function, a function vector or the solution\nof an equation or an equation system. Equations are\ninternally converted to a difference of lhs and rhs such\nthat the Newton method (=zero detection) can be applied. The expressions\nmust have continuous derivatives for all variables.\nA starting point for the iteration can be given. If not given,\nrandom values are taken instead. If the number of\nforms is not equal to the number of variables, the\nNewton method cannot be applied. Then the minimum\nof the sum of absolute squares is located instead.\n\nWith ON COMPLEX solutions with imaginary parts can be\nfound, if either the expression(s) or the starting point\ncontain a nonzero imaginary part.\n\nSyntax:\n\n\\begin{description}\n\\item[NUM\\_SOLVE]  $(exp_1, var_1[=val_1][,accuracy=a][,iterations=i])$\n\nor\n\n\\item[NUM\\_SOLVE]  $(\\{exp_1,\\ldots,exp_n\\},\n   var_1[=val_1],\\ldots,var_n[=val_n]$\n\\item[\\ \\ \\ \\ \\ \\ \\ \\ ]$[,accuracy=a][,iterations=i])$\n\nor\n\n\\item[NUM\\_SOLVE]  $(\\{exp_1,\\ldots,exp_n\\},\n   \\{var_1[=val_1],\\ldots,var_n[=val_n]\\}$\n\\item[\\ \\ \\ \\ \\ \\ \\ \\ ]$[,accuracy=a][,iterations=i])$\n\nwhere $exp_1, \\ldots,exp_n$ are function expressions,\n\n      $var_1, \\ldots, var_n$ are the variables,\n\n      $val_1, \\ldots, val_n$ are optional start values.\n\nNUM\\_SOLVE tries to find a zero/solution of the expression(s).\nResult is a list of equations, where the variables are\nequated to the coordinates of the result point.\n\nThe Jacobian matrix is stored as a side effect in the shared\nvariable JACOBIAN.\n\n\\end{description}\n\nExample:\n\n\\begin{verbatim}\n    num_solve({sin x=cos y, x + y = 1},{x=1,y=2});\n\n    {X= - 1.8561957251,Y=2.856195584}\n\n    jacobian;\n\n    [COS(X)  SIN(Y)]\n    [              ]\n    [  1       1   ]\n\\end{verbatim}\n\n\\section{Integrals}\n\nFor the numerical evaluation of univariate integrals over a finite\ninterval the following strategy is used:\n\\begin{enumerate}\n\\item If the function has an antiderivative in close form\n    which is bounded in the integration interval, this\n    is used.\n\\item Otherwise a Chebyshev approximation is computed,\n    starting with order 20, eventually up to order 80.\n    If that is recognized as sufficiently convergent\n    it is used for computing the integral by directly\n    integrating the coefficient sequence.\n\\item If none of these methods is successful, an\n    adaptive multilevel quadrature algorithm is used.\n\\end{enumerate}\nFor multivariate integrals only the adaptive quadrature is used.\nThis algorithm tolerates isolated singularities.\nThe value $iterations$ here limits the number of\nlocal interval intersection levels.\n$Accuracy$ is a measure for the relative total discretization\nerror (comparison of order 1 and order 2 approximations).\n\nSyntax:\n\n\\begin{description}\n\\item[NUM\\_INT] $(exp,var_1=(l_1 .. u_1)[,var_2=(l_2 .. u_2)\\ldots]$\n\\item[\\ \\ \\ \\ \\ \\ ]$[,accuracy=a][,iterations=i])$\n\nwhere $exp$ is the function to be integrated,\n\n$var_1, var_2 , \\ldots$ are the integration variables,\n\n$l_1, l_2 , \\ldots$ are the lower bounds,\n\n$u_1, u_2 , \\ldots$ are the upper bounds.\n\nResult is the value of the integral.\n\n\\end{description}\n\nExample:\n\n\\begin{verbatim}\n    num_int(sin x,x=(0 .. pi));\n\n    2.0000010334\n\\end{verbatim}\n\n\\section{Ordinary Differential Equations}\n\nA Runge-Kutta method of order 3 finds an approximate graph for\nthe solution of a ordinary differential equation\nreal initial value problem.\n\nSyntax:\n\\begin{description}\n\\item[NUM\\_ODESOLVE]($exp$,$depvar=dv$,$indepvar$=$(from .. to)$\n\n$                   [,accuracy=a][,iterations=i]) $\n\nwhere\n\n$exp$ is the differential expression/equation,\n\n$depvar$ is an identifier representing the dependent variable\n(function to be found),\n\n$indepvar$ is an identifier representing the independent variable,\n\n$exp$ is an equation (or an expression implicitly set to zero) which\ncontains the first derivative of $depvar$ wrt $indepvar$,\n\n$from$ is the starting point of integration,\n\n$to$ is the endpoint of integration (allowed to be below $from$),\n\n$dv$ is the initial value of $depvar$ in the point $indepvar=from$.\n\nThe ODE $exp$ is converted into an explicit form, which then is\nused for a Runge Kutta iteration over the given range. The\nnumber of steps is controlled by the value of $i$\n(default: 20).\nIf the steps are too coarse to reach the desired\naccuracy in the neighborhood of the starting point, the number is\nincreased automatically.\n\nResult is a list of pairs, each representing a point of the\napproximate solution of the ODE problem.\n\\end{description}\n\n\nExample:\n\n\\begin{verbatim}\n\n    num_odesolve(df(y,x)=y,y=1,x=(0 .. 1), iterations=5);\n\n {{0.0,1.0},{0.2,1.2214},{0.4,1.49181796},{0.6,1.8221064563},\n\n  {0.8,2.2255208258},{1.0,2.7182511366}}\n\n\\end{verbatim}\n\nRemarks:\n\n\\begin{enumerate}\n\n\\item[--] If in $exp$ the differential is not isolated on the lefthand side,\nplease ensure that the dependent variable is explicitly declared\nusing a \\verb+DEPEND+ statement, e.g.\n\n\\begin{verbatim}\n    depend y,x;\n\\end{verbatim}\n\notherwise the formal derivative will be computed to zero by REDUCE.\n\n\\item[--] The REDUCE package SOLVE is used to convert the form into\nan explicit ODE. If that process fails or has no unique result,\nthe evaluation is stopped with an error message.\n\n\\end{enumerate}\n\n\\section{Bounds of a Function}\n\nUpper and lower bounds of a real valued function over an\ninterval or a rectangular multivariate domain are computed\nby the operator BOUNDS. The algorithmic basis is the computation\nwith inequalities: starting from the interval(s) of the\nvariables, the bounds are propagated in the expression\nusing the rules for inequality computation. Some knowledge\nabout the behavior of special functions like ABS, SIN, COS, EXP, LOG,\nfractional exponentials etc. is integrated and can be evaluated\nif the operator BOUNDS is called with rounded mode on\n(otherwise only algebraic evaluation rules are available).\n\nIf BOUNDS finds a singularity within an interval, the evaluation\nis stopped with an error message indicating the problem part\nof the expression.\n\nSyntax:\n\n\n\\begin{description}\n\\item[BOUNDS]$(exp,var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2) \\ldots])$\n\n\\item[{\\it BOUNDS}]$(exp,\\{var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2)\\ldots]\\})$\n\nwhere $exp$ is the function to be investigated,\n\n$var_1, var_2 , \\ldots$ are the variables of exp,\n\n$l_1, l_2 , \\ldots$  and  $u_1, u_2 , \\ldots$ specify the area (intervals).\n\n$BOUNDS$ computes upper and lower bounds for the expression in the\ngiven area. An interval is returned.\n\n\\end{description}\n\nExample:\n\n\\begin{verbatim}\n\n    bounds(sin x,x=(1 .. 2));\n\n    {-1,1}\n\n    on rounded;\n    bounds(sin x,x=(1 .. 2));\n\n    0.84147098481 .. 1\n\n    bounds(x**2+x,x=(-0.5 .. 0.5));\n\n     - 0.25 .. 0.75\n\n\\end{verbatim}\n\n\\section{Chebyshev Curve Fitting}\n\nThe operator family $Chebyshev\\_\\ldots$ implements approximation\nand evaluation of functions by the Chebyshev method.\nLet $T_n^{(a,b)}(x)$ be the Chebyshev polynomial of order $n$\ntransformed to the interval $(a,b)$. Then a function $f(x)$ can be\napproximated in $(a,b)$ by a series\n\n$f(x) \\approx \\sum_{i=0}^N c_i T_i^{(a,b)}(x)$\n\nThe operator $Chebyshev\\_fit$ computes this approximation and\nreturns a list, which has as first element the sum expressed\nas a polynomial and as second element the sequence\nof Chebyshev coefficients ${c_i}$.\n$Chebyshev\\_df$ and $Chebyshev\\_int$ transform a Chebyshev\ncoefficient list into the coefficients of the corresponding\nderivative or integral respectively. For evaluating a Chebyshev\napproximation at a given point in the basic interval the\noperator $Chebyshev\\_eval$ can be used. Note that\n$Chebyshev\\_eval$ is based on a recurrence relation which is\nin general more stable than a direct evaluation of the\ncomplete polynomial.\n\n\\begin{description}\n\\item[CHEBYSHEV\\_FIT] $(fcn,var=(lo .. hi),n)$\n\n\\item[CHEBYSHEV\\_EVAL] $(coeffs,var=(lo .. hi),var=pt)$\n\n\\item[CHEBYSHEV\\_DF] $(coeffs,var=(lo .. hi))$\n\n\\item[CHEBYSHEV\\_INT] $(coeffs,var=(lo .. hi))$\n\nwhere $fcn$ is an algebraic expression (the function to be\nfitted), $var$ is the variable of $fcn$, $lo$ and $hi$ are\nnumerical real values which describe an interval ($lo < hi$),\n$n$ is the approximation order,an integer $>0$, set to 20 if missing,\n$pt$ is a numerical value in the interval and $coeffs$ is\na series of Chebyshev coefficients, computed by one of\n$CHEBYSHEV\\_COEFF$, $\\_DF$ or $\\_INT$.\n\\end{description}\n\nExample:\n\n\\begin{verbatim}\n\non rounded;\n\nw:=chebyshev_fit(sin x/x,x=(1 .. 3),5);\n\n               3           2\nw := {0.03824*x  - 0.2398*x  + 0.06514*x + 0.9778,\n\n      {0.8991,-0.4066,-0.005198,0.009464,-0.00009511}}\n\nchebyshev_eval(second w, x=(1 .. 3), x=2.1);\n\n0.4111\n\n\\end{verbatim}\n\n\\section{General Curve Fitting}\n\nThe operator $NUM\\_FIT$ finds for a set of\npoints the linear combination of a given set of\nfunctions (function basis) which approximates the\npoints best under the objective of the least squares\ncriterion (minimum of the sum of the squares of the deviation).\nThe solution is found as zero of the\ngradient vector of the sum of squared errors.\n\nSyntax:\n\n\\begin{description}\n\\item[NUM\\_FIT] $(vals,basis,var=pts)$\n\nwhere $vals$ is a list of numeric values,\n\n$var$ is a variable used for the approximation,\n\n$pts$ is a list of coordinate values which correspond to $var$,\n\n$basis$ is a set of functions varying in $var$ which is used\n  for the approximation.\n\n\\end{description}\n\nThe result is a list containing as first element the\nfunction which approximates the given values, and as\nsecond element a list of coefficients which were used\nto build this function from the basis.\n\nExample:\n\n\\begin{verbatim}\n\n     % approximate a set of factorials by a polynomial\n    pts:=for i:=1 step 1 until 5 collect i$\n    vals:=for i:=1 step 1 until 5 collect\n            for j:=1:i product j$\n\n    num_fit(vals,{1,x,x**2},x=pts);\n\n                   2\n    {14.571428571*X  - 61.428571429*X + 54.6,{54.6,\n\n         - 61.428571429,14.571428571}}\n\n    num_fit(vals,{1,x,x**2,x**3,x**4},x=pts);\n\n                   4                 3\n    {2.2083333234*X  - 20.249999879*X\n\n                      2\n      + 67.791666154*X  - 93.749999133*X\n\n      + 44.999999525,\n\n     {44.999999525, - 93.749999133,67.791666154,\n\n       - 20.249999879,2.2083333234}}\n\n\n\\end{verbatim}\n\n\\section{Function Bases}\n\nThe following procedures compute sets of functions\ne.g. to be used for approximation.\nAll procedures have\ntwo parameters, the expression to be used as $variable$\n(an identifier in most cases) and the\norder of the desired system.\nThe functions are not scaled to a specific interval, but\nthe $variable$ can be accompanied by a scale factor\nand/or a translation\nin order to map the generic interval of orthogonality to another\n(e.g. $(x- 1/2 ) * 2 pi$).\nThe result is a function list with ascending order, such that\nthe first element is the function of order zero and (for\nthe polynomial systems) the function of order $n$ is the $n+1$-th\nelement.\n\n\\begin{verbatim}\n\n     monomial_base(x,n)       {1,x,...,x**n}\n     trigonometric_base(x,n)  {1,sin x,cos x,sin(2x),cos(2x)...}\n     Bernstein_base(x,n)      Bernstein polynomials\n     Legendre_base(x,n)       Legendre polynomials\n     Laguerre_base(x,n)       Laguerre polynomials\n     Hermite_base(x,n)        Hermite polynomials\n     Chebyshev_base_T(x,n)    Chebyshev polynomials first kind\n     Chebyshev_base_U(x,n)    Chebyshev polynomials second kind\n\n\\end{verbatim}\n\nExample:\n\n\\begin{verbatim}\n Bernstein_base(x,5);\n\n         5      4       3       2\n    { - X  + 5*X  - 10*X  + 10*X  - 5*X + 1,\n\n           4      3      2\n     5*X*(X  - 4*X  + 6*X  - 4*X + 1),\n\n         2      3      2\n     10*X *( - X  + 3*X  - 3*X + 1),\n\n         3   2\n     10*X *(X  - 2*X + 1),\n\n        4\n     5*X *( - X + 1),\n\n      5\n     X }\n\n\\end{verbatim}\n\n\\end{document}\n\n", "meta": {"hexsha": "7115d89d2b9be0346f1ee119dad8e0944e8e87d2", "size": 15818, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/numeric/numeric.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/numeric/numeric.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/numeric/numeric.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3476702509, "max_line_length": 77, "alphanum_fraction": 0.7156404097, "num_tokens": 4519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.43729639250866376}}
{"text": "\\section{Isostatic Adjustment}\nThe ice sheet model includes simple approximations for calculating isostatic adjustment. These approximations depend on how the lithosphere and the mantle are treated. For each subsystem there are two models. The lithosphere can be described as a\n\\begin{description}\n\\item[\\textbf{local lithosphere:}] the flexural rigidity of the lithosphere is ignored, i.e. this is equivalent to ice floating directly on the asthenosphere;\n\\item[\\textbf{elastic lithosphere:}] the flexural rigidity is taken into account;\n\\end{description}\nwhile the mantle is treated as a\n\\begin{description}\n\\item [\\textbf{fluid mantle:}] the mantle behaves like a non-viscous fluid, isostatic equilibrium is reached instantaneously;\n\\item [\\textbf{relaxing mantle:}] the flow within the mantle is approximated by an exponentially decaying hydrostatic response function, i.e. the mantle is treated as a viscous half space.\n\\end{description}\n\n\\subsection{Calculation of ice-water load}\nAt each isostasy time-step, the load of ice and water is calculated, as an\nequivalent mantle-depth ($L$). If the basal elevation is above sea-level, then the\nload is simply due to the ice:\n\\begin{equation}\nL=\\frac{\\rho_i}{\\rho_m}H,\n\\label{load_land_ice}\n\\end{equation}\nwhere $H$ is the ice thickness, with $\\rho_i$ and $\\rho_m$ being the densities\nof the ice and mantle respectively. In the case where the bedrock is below\nsea-level, the load is calculated is that due to a change in sea-level rise and/or\nthe presence of non-floating ice. When the ice is floating ($\\rho_i\nH<\\rho_o(z_0-h)$), the load is only due to sea-level changes\n\\begin{equation}\nL=\\frac{\\rho_o}{\\rho_m}z_0,\n\\label{load_sea_float}\n\\end{equation}\nwhereas when the ice is grounded, it displaces the water, and adds an\nadditional load:\n\\begin{equation}\nL=\\frac{\\rho_i H+\\rho_o h}{\\rho_m}.\n\\label{load_sea_grounded}\n\\end{equation}\nhere, $\\rho_o$ is the density of sea water, $z_0$ is the change in sea-level\nrelative to a reference level and $h$ is the bedrock elevation relative to the\nsame reference level. The value of $h$ will be negative for submerged bedrock,\nhence the plus sign in (\\ref{load_sea_grounded}).\n\n\\subsection{Elastic lithosphere model}\nThis is model is selected by setting \\texttt{lithosphere = 1} in the\nconfiguration file. By simulatuing the deformation of the lithosphere, the\ndeformation seen by the aesthenosphere beneath is calculated. In the absence of this\nmodel, the deformation is that due to Archimedes' Principle, as though the\nload were floating on the aesthenosphere.\n\nThe elastic lithosphere model is based on work by \\cite{Lambeck1980}, and its\nimplementation is fully described in \\cite{Hagdorn2003}. The lithosphere\nmodel only affects the geometry of the deformation --- the timescale for\nisostatic adjustment is controlled by the aesthenosphere model. \n\nThe load due to a single (rectangular) grid point is approximated as being\napplied to a disc of the same area. The deformation due to a disc of ice of\nradius $A$ and thickness $H$ is given by these expressions. For $r<A$:\n\\begin{equation} \nw(r)=\\frac{\\rho_i H}{\\rho_m}\\left[1+C_1\\,\\mathrm{Ber}\\left(\\frac{r}{L_r}\\right)+C_2\\,\\mathrm{Bei}\\left(\\frac{r}{L_r}\\right)\\right],\n\\end{equation}\nand for $r\\geq A$:\n\\begin{equation}\nw(r)=\\frac{\\rho_i\n  H}{\\rho_m}\\left[D_1\\,\\mathrm{Ber}\\left(\\frac{r}{L_r}\\right)+D_2\\,\\mathrm{Bei}\\left(\\frac{r}{L_r}\\right)\n+D_3\\,\\mathrm{Ker}\\left(\\frac{r}{L_r}\\right)+D_4\\,\\mathrm{Kei}\\left(\\frac{r}{L_r}\\right)\\right],\n\\end{equation}\nwhere $\\mathrm{Ber}(x)$, $\\mathrm{Bei}(x)$, $\\mathrm{Ker}(x)$ and\n$\\mathrm{Kei}(x)$ are Kelvin functions of zero order, $L_r=(D/\\rho_m\ng))^{1/4}$ is the radius of relative stiffness, and $D$ is the flexural\nrigidity. The constants $C_i$ and $D_i$ are given by\n\\begin{equation}\n\\begin{array}{rcl}\nC_1&=&a\\,\\mathrm{Ker}'(a)\\\\\nC_2&=&-a\\,\\mathrm{Ker}'(a)\\\\\nD_1&=&0\\\\\nD_2&=&0\\\\\nD_3&=&a\\,\\mathrm{Ber}'(a)\\\\\nD_4&=&-a\\,\\mathrm{Ber}'(a).\n\\end{array}\n\\end{equation}\nHere, the prime indicates the first spatial derivative of the Kelvin functions.\n\n\\subsection{Relaxing aesthenosphere model}\nIf a fluid mantle is selected, it adjusts instantly to changes in lithospheric\nloading. However, a relaxing mantle is also available.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"isos\"\n%%% End: \n", "meta": {"hexsha": "f185b2458cdfeeb045f8ec68438789efc772e425", "size": 4293, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "models/glc/cism/glimmer-cism/doc/num/isos.tex", "max_stars_repo_name": "fmyuan/clm-microbe", "max_stars_repo_head_hexsha": "9faee9ed7d6c092c4a9e4a207f32cbffab78b85c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-03-12T01:58:26.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-16T03:08:25.000Z", "max_issues_repo_path": "models/glc/cism/glimmer-cism/doc/num/isos.tex", "max_issues_repo_name": "fmyuan/clm-microbe", "max_issues_repo_head_hexsha": "9faee9ed7d6c092c4a9e4a207f32cbffab78b85c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-21T01:51:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-21T01:51:13.000Z", "max_forks_repo_path": "models/glc/cism/glimmer-cism/doc/num/isos.tex", "max_forks_repo_name": "email-clm/CLM-Microbe", "max_forks_repo_head_hexsha": "711c87faec2c1bfe2cea1a7ebd07e4373e82a184", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2016-03-08T21:04:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-16T03:29:35.000Z", "avg_line_length": 48.2359550562, "max_line_length": 246, "alphanum_fraction": 0.7528534824, "num_tokens": 1268, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.43729638967542006}}
{"text": "\\chapter{Syntactic Model of \\lang} \\label{ch:model}\n\n\\input{figures/cic.tex}\n\\input{figures/definitions.tex}\n\\input{figures/translation.tex}\n\n\\lang is modelled in\n\\CICE,\\index{Calculus of Inductive Constructions!Extensional \\textasciitilde}\nas briefly described in \\cref{ch:introduction}.\nThe key idea is that sizes in \\lang can themselves be represented as a inductive type in \\CICE,\nand naturals and well-founded trees are then inductives with an additional size parameter.\nSizes are represented as a (generalization of) the Brouwer notation for ordinals in type theory,\nand their order as an inductive type indexed by sizes.\nThe order is \\emph{well founded}:\nthere is no infinite sequence of ever-smaller sizes,\nand there is always a ``smallest'' size (or many of them).\nThis property allows for \\emph{well-founded induction}\\index{well-founded induction},\nwhere to prove some property on sizes, one supposes that it holds for all strictly smaller sizes.\n\nEvery fixpoint expression in \\lang is modelled as an instance of well-founded induction in \\CICE.\nTo prove well-foundedness and in turn the induction principle,\nI show that sizes satisfy an \\emph{accessibility predicate}\\index{accessibility predicate}~\\citep{accessibility}.\nFor the type preservation proof to go through,\n\\emph{definitional proof irrelevance}\\index{proof irrelevance} of accessibility predicates\nis required---every proof of accessibility is definitionally equal to one another.\nThis holds in extensional type theory via equality reflection\\index{equality reflection}\nbut not in intensional type theory,\nwhich is why an extensional CIC is used.\n\nThe first half of this chapter provides the syntax and judgements of \\CICE.\nIn addition to the notation used in \\cref{ch:sized-dep-types},\ngiven variables $\\vec{\\xT} = \\xT_1 \\seq \\xT_n$,\nterms $\\vec{\\eT} = \\eT_1 \\seq \\eT_n$,\nand types $\\vec{\\tauT} = \\tauT_1 \\seq \\tauT_n$,\n\\new{$\\annotT{\\vec{\\xT}}{\\vec{\\tauT}}$} denotes the assumption environment\n$\\annotT*{\\xT_1}{\\tauT_1}, \\seq, \\annotT*{\\xT_n}{\\tauT_n}$,\n\\new{$\\subst{\\eT}{\\vec{\\xT}}{\\vec{\\eT}}$} denotes the simultaneous substitution\n$\\subst{\\eT}{\\xT_1, \\seq, \\xT_n}{\\eT_1, \\seq, \\eT_n}$, \n\\new{$\\funT{\\vec{\\xT}}{\\vec{\\tauT}}{\\eT}$} denotes the $n$-ary function\n$\\funT{\\xT_1}{\\tauT_1}{\\seq \\funT{\\xT_n}{\\tauT_n}{\\eT}}$, and\n\\new{$\\type{\\GammaT}{\\vec{\\eT}}{\\vec{\\tauT}}$} denotes the $n$ typing judgements\n$(\\type{\\GammaT}{\\eT_1}{\\tauT_1})$, \\seq, $(\\type{\\GammaT, \\annotT{\\eT_1}{\\tauT_1}, \\seq, \\annotT{\\eT_{n-1}}{\\tauT_{n-1}}}{\\eT_n}{\\tauT_n})$.\n\nThe second half then describes the translation from \\lang to \\CICE,\nwhich is a metafunction from typing derivations of \\lang to terms of \\CICE.\nTherefore, the translation is only defined for well-typed \\lang terms,\nbut the type preservation theorem only applies to well-typed terms anyway.\n\n\\section{Target Type Theory} \\label{sec:target}\n\n\\FigSyntaxCIC{fig:syntax-cic}\nThe syntax of \\CICE\nis given in \\cref{fig:syntax-cic};\ndifferences from \\lang include a 1-based index for the recursive argument of fixpoint expressions,\n$\\tg{case}$ expression motives abstracted over the target's inductive type indices,\nand a homogeneous propositional equality\\index{propositional equality} type with the reflexivity constructor and $\\JT*$ eliminator.\nNew inductive types are defined using data definitions $\\DT$,\nwhose syntax resembles the informal presentation used in \\cref{ch:sized-dep-types}.\nMetavariable usage convention is roughly the same as for \\lang,\nwith the addition of $\\pT$ for inductive type parameters or proofs of equality\nand $\\aT$ for inductive type indices.\n\nThe well-formedness conditions on inductive data definitions,\nsuch as well-typedness and \\emph{strict positivity}\\index{strict positivity},\nare entirely standard, so I omit them here;\nsee pCIC\\index{Calculus of Inductive Constructions!Predicative \\textasciitilde}~\\citep{pCIC}\nfor instance for a full description.\nInductive definitions in their full generality are not needed,\nand nonmutual, nonnested inductives suffice.\nIndeed, only six inductive definitions are used for the translation,\nfor representing sizes, their order, their well-foundedness,\nand the empty type, naturals, and well-founded trees.\n\nThe typed equivalence\\index{equivalence}, subtyping, and typing judgements are defined mutually:\nequivalence depends on typing and subtyping,\nsubtyping depends on equivalence,\nand typing depends on subtyping and equivalence.\nThe mutual dependence is due to typed equivalence,\nsince with untyped conversion as seen in \\lang has no typing premises.\nI present first the equivalence rules in \\cref{fig:equivalence},\nwith the subtyping and typing rules to follow.\n\nEquivalence is, by definition, an equivalence relation,\nsatisfying reflexivity, symmetry, and transitivity.\nEquivalence is also congruent, using the same summary of congruence rules as for \\lang via \\rref{equiv-cong};\nthe full set of rules can similarly be found in \\cref{app:cong:equiv}.\nAn equivalence judgement can be converted to one annotated by a supertype via \\rref{equiv-conv}.\nThe key rule for extensionality is equality reflection\\index{equality reflection} in \\rref{equiv-reflect},\nwhich definitionally equates two terms whenever there exists some proof of their propositional equality.\n\n\\FigEquiv{fig:equivalence}\n\n\\clearpage\nTyped equivalence is required in the presence of equality reflection since\ninconsistencies are derivable when using untyped conversion\\index{conversion}.\nFor instance, supposing that \\lang had equality reflection and using \\new{$\\approx$} to denote conversion,\nin the empty environment, freely using transitivity,\n%\n\\begin{align*}\n  \\const{0'} &\\approx \\app{(\\fun{p}{\\eq{\\const{0'}}{\\N{\\hat{\\hat{\\circ}}}}{\\const{1}}}{\\const{0'}})}{\\refl{\\const{0'}}} &&\\textrm{by $\\beta$-reduction} \\\\\n  &\\approx \\app{(\\fun{p}{\\eq{\\const{0'}}{\\N{\\hat{\\hat{\\circ}}}}{\\const{1}}}{\\const{1}})}{\\refl{\\const{0'}}} &&\\textrm{by congruence and reflection of $p$} \\\\\n  &\\approx \\const{1} &&\\textrm{by $\\beta$-reduction},\n\\end{align*}\nsince reduction and therefore conversion occurs even when its terms are ill typed,\nas the second and third terms are.\nAn alternate solution would be to disallow transitivity of conversion~\\citep{CCE},\nbut this is too limiting when trying to prove type preservation,\nand equivalence would no longer be an equivalence relation.\n\nUntyped conversion with equality reflection also violates subject reduction\nunder certain environments.\nFor example, suppose the environment contains the equality $\\eq{\\arr*{\\N{\\sss{\\circ}}}{\\N{\\sss{\\circ}}}}{}{\\arr*{\\N{\\sss{\\circ}}}{\\Prop}}$.\nThen $\\app{(\\fun{x}{\\N{\\sss{\\circ}}}{x})}{\\const{0}}$ can be assigned type $\\Prop$\nby equality reflection and conversion of the function's type,\nbut this term reduces to $\\const{0}$ which \\emph{cannot} be assigned type $\\Prop$.\nThis can be resolved by adding\n\\emph{injectivity of type constructors}\\index{injectivity of type constructors},\nwhich would allow deriving the equality $\\eq{\\N{\\sss{\\circ}}}{}{\\Prop}$\nfrom the above, but doing so is generally undesirable since it's inconsistent with\nthe axioms of both excluded middle and univalence \\citep{unification}.\n\nThe remaining equivalence rules are typed versions of the usual reduction rules,\nwith typing premises to ensure well-typedness of both sides.\nFunctions have both a $\\beta$-equivalence rule and an $\\eta$-equivalence rule,\nthe latter of which is only possible since equivalence is typed.\nEquivalence rules for $\\tg{let}$ expressions are exactly the same as in \\lang.\nThe $\\JT*$ eliminator and $\\tg{case}$ expressions reduce when applied to\nreflexivity and inductive constructors, respectively.\n\n\\rref{equiv-mu} for fixpoint expressions is \\emph{unguarded}\\index{guarded reduction},\nmeaning that fixpoints are equivalent to the substitution of itself into its own body\nregardless of what they are applied to.\nTo maintain normalization,\nthe usual guarded reduction rule in intensional CIC reduces fixpoints\nonly when applied to a literal constructor in the recursive argument position.\n\\vspace{-0.25\\baselineskip}\n\\begin{mathpar}\n\\inferrule[\\rlabel{$\\equiv$-$\\mu$-guarded}{equiv-mu-guarded}]{\\cdots \\\\ \\card{\\vec{\\eT}'} + 1 = \\nT}{\n  \\defeq{\\GammaT}{\\app{(\\fixT{\\nT}{\\fT}{\\tauT}{\\eT})}{\\vec{\\eT}'}{(\\app{\\cT}{\\vec{\\aT}})}}{\\app{(\\subst{\\eT}{\\fT}{\\fixT{\\nT}{\\fT}{\\tauT}{\\eT}})}{\\vec{\\eT}'}{(\\app{\\cT}{\\vec{\\aT}})}}{\\tauT}\n}\n\\end{mathpar}\n\nEvidently \\rref{equiv-mu-guarded} can be derived from \\rref{equiv-mu} by congruence.\nOn the other hand, for any particular inductive type $\\XT$,\nletting $\\tauT$ be $\\arr{\\vec{\\xT}}{\\vec{\\sigmaT}}{\\funtypeT{\\xT}{\\app{\\XT}{\\vec{\\pT}}{\\vec{\\aT}}}{\\tauT'}}$,\n\\rref{equiv-mu} can be derived from \\rref{equiv-mu-guarded} via reflection of the following provable propositional equality,\nfreely using transitivity:\n\n\\begin{align*}\n\\fixT{\\nT}{\\fT}{\\tauT}{\\eT} &\\eq{}{}{} \\funT{\\vec{\\xT}}{\\vec{\\sigmaT}}{\\funT{\\xT}{\\app{\\XT}{\\vec{\\pT}}{\\vec{\\aT}}}{\\app{(\\fixT{\\nT}{\\fT}{\\tauT}{\\eT})}{\\vec{\\xT}}{\\xT}}}\n\\qquad \\textrm{definitionally by \\rref{equiv-eta}} \\\\\n& \\eq{}{}{} \\funT{\\vec{\\xT}}{\\vec{\\sigmaT}}{\\funT{\\xT}{\\app{\\XT}{\\vec{\\pT}}{\\vec{\\aT}}}{\\matchT*{\\xT}{\\seq(\\app{\\cT}{\\vec{\\zT}} \\RightarrowT \\app{(\\fixT{\\nT}{\\fT}{\\tauT}{\\eT})}{\\vec{\\xT}}{(\\app{\\cT}{\\vec{\\pT}}{\\vec{\\zT}})})\\seq}}} \\\\\n& \\phantom{\\eq{}{}{}} \\textrm{by congruence and case analysis on $\\xT$} \\\\\n& \\eq{}{}{} \\funT{\\vec{\\xT}}{\\vec{\\sigmaT}}{\\funT{\\xT}{\\app{\\XT}{\\vec{\\pT}}{\\vec{\\aT}}}{\\matchT*{\\xT}{\\seq(\\app{\\cT}{\\vec{\\zT}} \\RightarrowT \\app{(\\subst{\\eT}{\\fT}{\\fixT{\\nT}{\\fT}{\\tauT}{\\eT}})}{\\vec{\\xT}}{(\\app{\\cT}{\\vec{\\pT}}{\\vec{\\zT}})})\\seq}}} \\\\\n& \\phantom{\\eq{}{}{}} \\textrm{definitionally by \\rref{equiv-cong, equiv-mu-guarded}} \\\\\n& \\eq{}{}{} \\funT{\\vec{\\xT}}{\\vec{\\sigmaT}}{\\funT{\\xT}{\\app{\\XT}{\\vec{\\pT}}{\\vec{\\aT}}}{\\app{(\\subst{\\eT}{\\fT}{\\fixT{\\nT}{\\fT}{\\tauT}{\\eT}})}{\\vec{\\xT}}{\\xT}}} \\\\\n& \\phantom{\\eq{}{}{}} \\textrm{by congruence and case analysis on $\\xT$} \\\\\n& \\eq{}{}{} \\subst{\\eT}{\\fT}{\\fixT{\\nT}{\\fT}{\\tauT}{\\eT}}\n\\qquad \\textrm{definitionally by \\rref{equiv-eta}}\n\\end{align*}\n\nSince \\rref{equiv-mu} and \\rref{equiv-mu-guarded} are metatheoretically equivalent,\nI choose to use \\rref{equiv-mu} for its simplicity.\n\n\\FigSubtypingCIC{fig:subtyping-cic}\nAs opposed to \\lang, for \\CICE I use\npCIC's\\index{Calculus of Inductive Constructions!Predicative \\textasciitilde}\npresentation of subtyping\\index{subtyping} in \\cref{fig:subtyping-cic},\nwhich has a typed equivalence premise in \\rref{subtype-conv}.\nIt also has an explicit rule for transitivity of subtyping since judgements such as\n$\\subtype{\\mt}{\\app{(\\funT{P}{\\TypeT{\\tg{1}}}{P})}{\\PropT}}{\\TypeT{\\tg{0}}}$ would fail to hold otherwise.\nLike \\rref{acum-pi}, \\rref{subtype-pi} is invariant in the domain of function types.\n\nThe typing and environment well-formedness rules are in \\cref{fig:typing-cic}.\nExcept for \\rref{fix*}, the starred rules are the same as for \\lang,\nwith metafunctions $\\axioms{\\mt}$ and $\\rules{\\mt}{\\mt}$ operating similarly on universes $\\UT$\nas in \\cref{fig:rules-axioms}.\nAn additional premise to \\rref{fix*} ensures that the $\\nT$th argument is indeed an inductive type.\n% in addition to checking well-typedness of fixpoint bodies with possible recursive references.\n\nAs previously mentioned, fixpoints must also be guarded\\index{guardedness}:\nrecursive calls can only occur on structurally smaller arguments of elements of inductives.\nThe guard condition is well studied \\citep{guard, guard-relax, Coq} and so omitted here.\nTo justify uses of fixpoint expressions in the translation,\nI will provide either a mechanization or present a brief argument of guardedness.\n\n\\FigTypingCIC{fig:typing-cic}\n\nThe new \\rref{eq, refl, J} are for the propositional equality\\index{propositional equality} type,\nits constructor, and its eliminator.\nGiven some equality proof $\\pT$ of $\\eqT{\\eT_1}{\\tauT}{\\eT_2}$\nand a motive $\\PT$ dependent on a proof of equality\nwhose left-hand side is fixed at $\\eT_1$ and right-hand side is variable\\punctstack{,}%\n\\footnote{Occasionally referred to as \\emph{Paulin-Mohring}'s equality~\\citep{CIC},\nas opposed to \\emph{Martin-L\\\"of}'s equality~\\citep{MLTT}\nwhere the left-hand side is variable as well.}\nto prove $\\app{\\PT}{\\eT_2}{\\pT}$ it suffices to provide to $\\JT*$ a proof that\n$\\app{\\PT}{\\eT_1}{\\refl{\\eT_1}}$ holds.\nOther usual functions on proofs of equality can be derived from it,\nsuch as coercion (when the motive is \\mbox{$\\funT{A}{\\UT}{\\funT{\\any}{\\any}{A}}$})\nor substitution (when the motive ignores the second argument),\nas well as its symmetry, transitivity, and congruence.\nThe proof of type preservation eliminates propositional equalities mostly through\nreflection\\index{equality reflection} rather than using $\\JT*$,\nbut I retain $\\JT*$ in \\CICE for completeness\\punctstack{.}%\n\\footnote{The combined presence of $\\JT*$ and equality reflection also allows proving the\n\\emph{uniqueness of identity proofs} (UIP)\\index{uniqueness of identity proofs},\nor that all proofs of an equality $\\eqT{a}{A}{b}$ are themselves equal to one another,\nby reflecting $p$ in the term $\\JT{(\\funT{b}{A}{\\funT{p}{\\eqT{a}{A}{b}}{\\eqT{\\reflT{a}}{}{p}}})}{\\reflT{\\reflT{a}}.}{}$}\n\n\\rref{ind, constr, case} assign types to inductive types, their constructors,\nand $\\tg{case}$ expressions, under the premise that\nthe relevant inductive data definition exists and is well formed.\nHere, the difference between the parameters and the indices of inductive types becomes apparent:\nthe motive\\index{motive} of a $\\tg{case}$ expression is abstracted over the indices by $\\vec{\\yT}$\nin addition to the target by $\\xT$, while the parameters $\\vec{\\pT}$ are fixed throughout.\nTherefore, when dealing with the types of indices and constructor arguments,\nthe parameters are first substituted in place of $\\vec{\\wT}$.\n\nA $\\tg{case}$ expression is well typed if its target is,\nif its motive is for any indices and target with those indices,\nand if each branch is well typed for that branch's constructor arguments,\nwhere its type is the motive with the appropriate indices and reconstructed target.\nFor notational simplicity, the rule assumes that the binding variable names\n$\\vec{\\yT}$ and $\\vec{\\zT}$ are those found in the data definition,\nbut of course these can be renamed at the expense of additional renaming substitutions.\n\nAdditionally, the motive of a $\\tg{case}$ expression is restricted by the metarelation $\\elim{\\mt}{\\mt}{\\mt}$,\nwhich indicates when \\emph{large elimination}\\index{large elimination} is allowed.\n$\\elim{\\any}{\\TypeT{\\iT}}{\\any}$ and $\\elim{\\any}{\\PropT}{\\PropT}$ always hold,\nso that inductives in $\\TypeT{}$ can be eliminated to any universe\nand inductives in $\\PropT$ can be eliminated to $\\PropT$,\nwhile $\\elim{\\XT}{\\PropT}{\\TypeT{\\iT}}$ holds if the inductive $\\XT$ in $\\PropT$ satisfies further conditions.\nFor the purposes of the translation, the only relevant conditions are that $\\XT$ either have no constructors\nor have a single constructor whose arguments are all in $\\PropT$.\nThey can be loosened while still retaining consistency (see \\eg \\citet{SProp}).\n\nThe typing premises of\n\\rref{equiv-beta, equiv-zeta, equiv-rho, equiv-iota, equiv-mu}\ncorresponding to some of the reduction rules duplicate the premises found in many of the typing rules,\ntrivially ensuring that both sizes of these equivalences are well typed with the same type\n(a property known as \\emph{subject equivalence}\\index{subject reduction}).\n\n\\section{Preliminary Definitions}\n\nBefore defining the translation from \\lang terms to \\CICE terms,\nin this section I describe how the \\CICE terms are constructed,\nwhich comprises the aforementioned six inductive data definitions\nand well-founded induction principle\nas well as the various properties which the order on sizes satisfies.\n\n\\FigData{fig:data-defns}\n\nThe inductive definitions are listed in \\cref{fig:data-defns}\nalong with some basic definitions I treat as global.\n$\\botT$ is the usual empty type.\n$\\SizeT$ is a generalization of the $\\Ord*$ type introduced in \\cref{sec:examples},\nwith the domain of the function passed to the limit size $\\limT$ replaced by some arbitrary type.\nAlthough limit sizes aren't strictly necessary for the translation,\nsince \\lang only has successor sizes and size variables,\nI include them so that various solutions to the problem of the infinite size\ncan be explored in \\cref{sec:infinity}.\nFurthermore, this allows for a simplification of the definition,\nsince the zero size $\\baseT$ can be defined as a limit size rather than as another constructor.\n\nThe order on sizes $\\mt \\szleT \\mt$ is defined by the three properties that must hold~\\citep{ordinals}:\n\\begin{itemize}[noitemsep]\n  \\item $\\monoT$: The successor operator $\\sucT$ is monotone with respect to the order;\n  \\item $\\coconeT$: The limit operator $\\limT$ constructs an upper bound in that\n    given some function $f$ returning a size,\n    any size smaller than any size returned by $f$ is also smaller than the limit of $f$;\n  \\item $\\limitT$: The limit operator on $f$ constructs a \\emph{least} upper bound such that\n    if a size is larger than \\emph{all} sizes returned by $f$\n    then it must also be larger than the limit of $f$.\n\\end{itemize}\n\nOther properties of the order can be derived by induction from these constructors alone.\nA corresponding strict order $\\mt \\szltT \\mt$ is also defined,\nand an accessibility predicate\\index{accessibility predicate} $\\AccT$ is specialized to sizes and the strict order.\nNote that it lives in $\\PropT$, as does the argument of its sole constructor $\\accT$,\nso accessibility predicates are intended to be interpreted as proof irrelevant\\index{proof irrelevance},\nand their large elimination\\index{large elimination} is allowed.\n\n\\FigDefns{fig:defns}\n\nBefore moving on to naturals and well-founded trees,\n\\cref{fig:defns} lists the names and types of a number of provable definitions.\nFirst is \\emph{function extensionality}\\index{function extensionality},\nasserting that two functions $\\annot{f, g}{\\funtypeT{x}{A}{\\app{B}{x}}}$ are propositionally equal if they are pointwise equal.\nIn \\CICE, they are in fact equivalent (\\ie definitionally equal):\ngiven some proof $h$ of their pointwise equality,\nunder the assumption $\\annot{x}{A}$,\nthe propositional equality $\\eq{\\app{f}{x}}{}{\\app{g}{x}}$ by $\\app{h}{x}$\ncan be reflected into the corresponding definitional equality,\nwhich by \\rref{equiv-eta} is then a definitional equality of $f$ and $g$.\n\nThe remaining definitions have been mechanized in either Agda and Coq in\n\\cref{app:mechanization:agda:prelim} and \\cref{app:mechanization:coq:prelim}, respectively,\nunder the assumption of function extensionality as an axiom\n(which cannot be proven in intensional CIC).\nThe mechanizations don't use any additional type-theoretic features beyond CIC,\nand the proofs could theoretically be written in plain CIC,\nbut they would be far less comprehensible without the ergonomics provided by the proof assistants.\nAs an example, the Coq proof for $\\accessible$ consists of a dozen lines of tactics,\nwhile the full proof term generated from the tactics is 129 lines long.\n\nThe definitions themselves describe properties of the order on sizes\nand of the accessibility predicate:\n\\begin{itemize}[noitemsep]\n  \\item $\\baseleq$, $\\reflleq$, $\\transleq$, and $\\sucleq$:\n    The order is reflexive and transitive (\\ie a preorder)\n    such that $\\baseT$ is smaller than or equal to all sizes\n    and the successor of a size is greater or equal to itself.\n  \\item $\\accIsProp$: Accessibility predicates are \\emph{mere propositions}\\index{mere proposition}:\n    any two proofs of accessibility of a size are propositionally equal.\n  \\item $\\accleq$: Any size smaller or equal to an accessible size is itself accessible.\n  \\item $\\accessible$: All sizes are accessible; in other words, the order on sizes is well founded.\n  \\item $\\wfind$ and $\\wfacc$: The well-founded induction principle\\index{well-founded induction} on sizes with respect to the order,\n    proven by structural induction on the accessibility of sizes.\n\\end{itemize}\n\nThe only time equality reflection\\index{equality reflection} is needed is to prove $\\accIsProp$ (via $\\funext$),\nwhich in turn is the only other equality that is reflected for proving type preservation.\nSince $\\AccT$ is in already $\\PropT$, \\CICE could be replaced by an intensional CIC\nwith a universe of \\emph{strict propositions}\\index{strict proposition} $\\SPropT$\nof types whose elements are definitionally equal~\\citep{SProp},\nthen placing $\\AccT$ in $\\SPropT$.\nThis is disallowed by \\opcit because it breaks normalization;\nhowever, it doesn't break consistency,\nso it would remain suitable as the target language of a syntactic model.\nIn any case, I use \\CICE because equality reflection is more established in the literature\nand it allows me to use \\rref{equiv-mu} in place of \\rref{equiv-mu-guarded}.\n\nFinally, the naturals and the well-founded trees in \\CICE are parametrized by a $\\SizeT$.\nTheir definitions respect the translation in the upcoming section,\nso that the types of $\\NatT$ and $\\WT$ and their constructors are preserved.\n\n\\section{Translation}\n\nThe key type preservation\\index{type preservation} theorem states that well-typed terms of \\lang translate to\ncorresponding well-typed terms of CICE.\nHowever, terms are not the only thing requiring translation:\nwell-typedness holds under some environment, so term environments need translations;\nsizes and their environments translate to terms and term environments as well;\nand derivations of size orders translate to terms which represent them.\n\n\\FigTransSize{fig:trans:size}\nI begin with the translation of sizes and their environments in \\cref{fig:trans:size},\nwhich are straightforward recursive metafunctions over their syntax.\nI use an asterisk superscript \\new{$\\mt^\\ast$} on a variable $\\alphaT$ to represent\na fresh variable uniquely associated with $\\alphaT$.\nGiven some bound size variable $\\alphaT$,\n$\\alphaT^\\ast$ represents the proof that the translated size is strictly smaller\nthan its size bound.\n\n\\FigTransSubsize{fig:trans:subsize}\nThe translation of subsizing judgements, on the other hand,\nis a recursive metafunction over the \\emph{subsizing derivation}.\n\\cref{fig:trans:subsize} defines the translation to \\CICE terms\nby induction on the subsizing rules, which recursively translates subderivations\n(omitting irrelevant size well-scopedness premises).\n\nThe translation of terms and term environments are similarly defined\nas recursive metafunctions over the typing and well-formedness derivations,\ndenoted by\n\\mbox{$\\typeto{\\Phi; \\Gamma}{e}{\\tau}{\\eT}$} and \\mbox{$\\wfto{\\Phi}{\\Gamma}{\\GammaT}$}\nrespectively.\nHowever, for concision, I use $\\compile{e}$ to mean the translation of $e$\nwhen well typed under the current implicit environments,\n$\\compile{e}_{\\Phi}$ or $\\compile{e}_{\\Gamma}$ to mean the translation of $e$\nwith the current implicit environments extended with $\\Phi$ or $\\Gamma$,\nand $\\compile{\\Gamma}$ to mean the translation of $\\Gamma$\nwhen well formed under the current implicit size environment.\n\n\\FigTransTerm{fig:trans:term}\n\nThe translation for base \\lang without inductives is given in \\cref{fig:trans:term}\nin the more concise notation translated terms follow directly from subderivations\nand in the usual notation otherwise.\nTerms not involving sizes are translated in a straightforward recursive manner.\nUnbounded size quantifications and abstractions translate to quantifications and abstractions over $\\SizeT$,\nwhile bounded ones have additional quantifications and abstractions over a proof of $\\szltT$.\nSize applications translate to an additional application to a proof of $\\szltT$\nwhen the size abstraction applied is bounded.\n\nFinally, \\cref{fig:trans:ind} gives the translation for naturals, well-founded trees,\n$\\kw{case}$ expressions, and fixpoint expressions from their typing derivations\nto a \\CICE term (again omitting irrelevant premises).\nAside from fixpoints, the translations are fairly straightforward,\nwith an additional proof term from subsizing for constructors\nand dually an additional abstraction over such terms in the branches of $\\tg{case}$ expressions.\n\n\\FigTransInd{fig:trans:ind}\n\nFixpoints in \\lang are not translated as fixpoints in \\CICE.\nDoing so while preserving types would mean that \\lang fixpoints\nneed to be subject to the same guard conditions as \\CICE fixpoints,\nwhich is clearly undesirable and not the case in the examples from \\cref{sec:examples}.\nInstead, every single \\lang fixpoint, regardless of the inductive on which they recur,\nis translated to well-founded induction\\index{well-founded induction},\nwhich is defined via a \\CICE fixpoint on accessibility predicates\\index{accessibility predicate}.\nIntuitively, the return type of a fixpoint corresponds to the motive of well-founded induction,\nwhile recursion on a strictly smaller size corresponds to the induction hypothesis,\nwhere the motive holds for all strictly smaller sizes.\n\nThe main challenge with this translation is showing that the translations of a fixpoint\nand of its $\\mu$-reduction are equivalent in \\CICE,\nbecause this requires showing that the computational behaviour of well-founded induction\nis equivalent to the computational behaviour of the fixpoint.\nOnce that has been established,\nshowing type preservation of the translation is more or less going through the motions of the proof,\nsince the remaining \\lang terms translate almost directly to their syntactically corresponding terms.", "meta": {"hexsha": "cef948e1fff233b7d53caccf57c22df3306568a5", "size": 25449, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/model.tex", "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/model.tex", "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/model.tex", "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.7694174757, "max_line_length": 251, "alphanum_fraction": 0.7599512751, "num_tokens": 6833, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.43729638967542006}}
{"text": "\\subsection{Vector space geometry}\\label{subsec:vector_space_geometry}\n\n\\begin{remark}\\label{rem:real_field_extensions}\n  When speaking about vector spaces, we usually restrict ourselves to vector spaces over \\( \\BbbR \\) or, at most, \\( \\BbbC \\). This restriction may seem arbitrary, however important concepts like \\hyperref[def:geometric_ray]{rays} or \\hyperref[def:convex_set]{convexity} requires the field to be an extension of \\( \\BbbR \\), and it just so happens that, by \\fullref{thm:fundamental_theorem_of_algebra} and \\fullref{thm:no_finite_extensions_of_closed_fields}, the only nontrivial finite \\hyperref[def:field_extension]{extension field} of \\( \\BbbR \\) is \\( \\BbbC \\). It is technically possible to work with infinite extension fields, however in practice vector spaces over \\( \\BbbC \\) are esoteric enough. A benefit of considering only \\( \\BbbC \\) is given in \\fullref{rem:linear_functionals_over_c}.\n\\end{remark}\n\n\\begin{definition}\\label{def:geometric_shape}\n  A \\term{geometric shape} is an informal notion that refers to certain special subsets of a vector space, usually defined in a coordinate-independent manner. Shapes in two-dimensional spaces are called \\term{figures} and shapes in three dimensions are called \\term{surfaces}.\n\n  When two geometric shapes shapes intersect, we say that they are \\term{incident}.\n\\end{definition}\n\n\\begin{definition}\\label{def:point}\n  A \\term{point} is a simple geometric \\hyperref[def:geometric_shape]{shape} comprising a singleton subset of any set (usually a vector space or a topological space). We use the convention \\fullref{rem:singleton_sets} and, unless the distinction is important, we do not distinguish between singleton sets and their only element - e.g. in \\fullref{def:simplex/point}.\n\n  Points are also called vectors, which is justified by \\fullref{def:euclidean_plane_coordinate_system}.\n\\end{definition}\n\n\\begin{definition}\\label{def:euclidean_transformation}\n  The following bijections from \\( \\BbbR^n \\) to \\( \\BbbR^n \\) are collectively called \\term{Euclidean transformations} or \\term{rigid motions} in \\( \\BbbR^n \\):\n\n  \\begin{thmenum}\n    \\thmitem{def:euclidean_transformation/translation} For any vector \\( v \\in \\BbbR^n \\), the function\n    \\begin{equation*}\n      \\op{t}_v(x) \\coloneqq x + v\n    \\end{equation*}\n    is called a \\term{translation} along the \\term{direction} \\( v \\).\n\n    This easily generalizes to an arbitrary \\hyperref[def:magma]{magma} \\( (M, \\cdot) \\) by setting\n    \\begin{equation*}\n      \\op{t}_v(x) \\coloneqq v \\cdot x\n    \\end{equation*}\n    for some \\( v \\in M \\).\n\n    \\thmitem{def:euclidean_transformation/dilation} For any scalar \\( \\lambda \\in \\BbbR^n \\), the function\n    \\begin{equation*}\n      \\op{d}_\\lambda(x) \\coloneqq \\lambda x\n    \\end{equation*}\n    is called a \\term{dilation} or \\term{scaling} by \\( \\lambda \\).\n\n    This easily generalizes to an arbitrary (left) \\hyperref[def:magma]{module} \\( (M, +, \\cdot) \\).\n\n    \\thmitem{def:euclidean_transformation/homothety} A composition of a \\hyperref[def:euclidean_transformation/dilation]{dilation} with a \\hyperref[def:euclidean_transformation/translation]{translation} is called a \\term{homothety}.\n\n    \\thmitem{def:euclidean_transformation/rotation} For any point \\( p \\in \\BbbR^n \\) and any special (i.e. \\hyperref[def:matrix_determinant]{determinant} one) \\hyperref[def:orthogonal_matrix]{orthogonal matrix} \\( A \\in \\op{O}_n(\\BbbR) \\), the function\n    \\begin{equation*}\n      \\op{rot}_{A,p}(x) \\coloneqq p + A (x - p)\n    \\end{equation*}\n    is called a \\term{rotation} by \\( A \\) around \\( p \\).\n\n    \\thmitem{def:euclidean_transformation/reflection} For any point \\( p \\in \\BbbR^n \\), the function\n    \\begin{equation*}\n      \\op{ref}_p(x) \\coloneqq 2p - x\n    \\end{equation*}\n    is called a \\term{point reflection} or \\term{inversion} with respect to the point \\( p \\).\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:zero_locus}\n  Let \\( S \\) be an arbitrary set and let \\( M \\) be a \\hyperref[def:unital_magma]{unital} \\hyperref[def:magma]{magma} with identity \\( e \\).\n\n  The \\term{zero locus} or \\term{set of zeros} of a function \\( f: S \\to M \\) is the preimage\n  \\begin{equation*}\n    f^{-1}(e) = \\{ x \\in X \\colon f(x) = e \\}.\n  \\end{equation*}\n\n  In practice, \\( M \\) is usually a \\hyperref[def:semiring/ring]{ring} or a \\hyperref[def:left_module]{module}, in which case the zero locus is defined for the additive group, i.e.\n  \\begin{equation*}\n    f^{-1}(0_M) = \\{ x \\in X \\colon f(x) = 0_M \\}.\n  \\end{equation*}\n\n  See also \\fullref{def:pointed_set_kernel}, \\fullref{def:semiring_kernel} and \\fullref{def:left_module_kernel}.\n\\end{definition}\n\n\\begin{definition}\\label{def:hypersurface}\n  A \\term{hypersurfaces} can have different meanings depending on the context. We are interested in\n\n  \\begin{thmenum}\n    \\thmitem{def:hypersurface/parametric} A parametric hypersurface (\\fullref{def:parametric_hypersurface}) is a purely topological definition.\n    \\thmitem{def:hypersurface/algebraic} An affine variety (\\fullref{def:affine_variety}) is a purely algebraic definition.\n    \\thmitem{def:hypersurface/geometric} A manifold (\\fullref{def:topological_manifold}) can be regarded as a geometric definition.\n  \\end{thmenum}\n\n  Note that all of the enumerated hypersurfaces have a concept of dimension. Hypersurfaces of dimension \\( 2 \\) are simply called \\term{surfaces} (see \\fullref{def:affine_variety/algebraic_surface}) and hypersurfaces of dimension \\( 1 \\) are called \\term{curves} (see also \\fullref{def:affine_variety/algebraic_curve} and \\fullref{def:affine_variety/algebraic_curve}).\n\\end{definition}\n\n\\begin{definition}\\label{def:geometric_line}\n  A particularly important \\hyperref[def:hypersurface]{curve} is a \\term{line} in a vector space \\( X \\) over any field \\( \\BbbK \\), which can be defined equivalently as\n\n  \\begin{thmenum}\n    \\thmitem{def:geometric_line/subspace} A subspace of \\( X \\) of \\hyperref[def:vector_space_dimension]{dimension} one. Note that this is not consistent with the other definitions because this defines only lines through the origin \\( 0_X \\). Hence, if \\( L \\subseteq X \\) is a line (a subspace of dimension one) and if \\( a \\in X \\) is any point, we define a line with origin \\( a \\) to be the translation \\( a + L \\).\n\n    \\thmitem{def:geometric_line/algebraic} An \\hyperref[def:affine_variety/algebraic_curve]{algebraic curve} in \\( X \\) given by a polynomial of degree one.\n\n    \\thmitem{def:geometric_line/parametric} If the field \\( \\BbbK \\) is ordered (usually when \\( \\BbbK = \\BbbR \\)), we can define a line with \\term{directional vector} \\( x \\) and \\term{origin} \\( a \\) as the parametric curve\n    \\begin{balign*}\n       & l: \\BbbK \\to X   \\\\\n       & l(t) = tx + a.\n    \\end{balign*}\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:geometric_ray}\n  If \\( X \\) is a vector space over \\( \\BbbK \\in \\{ \\BbbR, \\BbbC \\} \\), we define \\term{closed rays} with a vertex \\( a \\) as the parametric curves\n  \\begin{balign*}\n     & l^+: [0, \\infty) \\to X \\\\\n     & l^+(t) = tx + a\n  \\end{balign*}\n  and\n  \\begin{balign*}\n     & l^-: (-\\infty, 0] \\to X \\\\\n     & l^-(t) = tx + a\n  \\end{balign*}\n\n  If the inequalities are strict, we instead obtain \\term{open rays}.\n\n  Unless explicitly noted otherwise, we assume that the vertex of the ray is \\( 0 \\) because every ray is a translation of a ray centered at \\( 0 \\).\n\\end{definition}\n\n\\begin{definition}\\label{def:geometric_cone}\n  An open (resp. closed) \\term{cone} in a vector space over \\( \\BbbK \\in \\{ \\BbbR, \\BbbC \\} \\) is a union of open (resp. closed) \\hyperref[def:geometric_ray]{rays} with a common vertex, called the \\term{vertex} of the cone.\n\\end{definition}\n\n\\begin{definition}\\label{def:hyperplane}\n  Dually to \\hyperref[def:geometric_line]{lines}, another particularly important \\hyperref[def:hypersurface]{hypersurface} is a \\term{hyperplane} in a vector space \\( X \\) over any field.\n\n  \\begin{thmenum}\n    \\thmitem{def:hyperplane/subspace} A \\term{linear hyperplane} is simply a subspace of \\( X \\) of \\hyperref[def:vector_space_dimension]{codimension} one. As in \\fullref{def:geometric_line/subspace}, we define a \\term{affine hyperplane} to be a \\hyperref[def:euclidean_transformation/translation]{translation} of a linear hyperplane.\n\n    \\thmitem{def:hyperplane/kernel} Linear hyperplanes (as defined in \\fullref{def:hyperplane/subspace}) are simply zero \\hyperref[def:zero_locus]{loci} (\\hyperref[def:semiring_kernel]{kernels}) of linear \\hyperref[def:linear_operator]{functionals}. and affine hyperplanes are zero loci of \\hyperref[def:affine_operator]{affine functionals}.\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{example}\\label{ex:hyperplanes}\n  Affine \\hyperref[def:hyperplane]{hyperplanes} in \\( \\BbbR^2 \\) are \\hyperref[def:geometric_line]{lines} and affine hyperplanes in \\( \\BbbR^3 \\) are planes.\n\n  Linear \\hyperref[def:hyperplane]{hyperplanes} in \\( \\BbbR^2 \\) are the lines passing through the origin \\( (0, 0) \\) and linear hyperplanes in \\( \\BbbR^3 \\) are the planes incident to \\( (0, 0, 0) \\).\n\\end{example}\n\n\\begin{definition}\\label{def:half_space}\n  Vector spaces over \\( \\BbbR \\) have the concept of \\term{half-spaces}. Given a \\hyperref[def:hyperplane]{hyperplane} \\( H \\) of the real vector space \\( X \\), defined by the affine functional \\( l(x) = \\inprod {x^*} x + a \\), its closed half-spaces are defined as\n  \\begin{equation*}\n    H^+ \\coloneqq \\{ l(x) \\geq 0 \\} = \\{ \\inprod {x^*} x \\geq -a \\}\n  \\end{equation*}\n  and\n  \\begin{equation*}\n    H^- \\coloneqq \\{ l(x) \\leq 0 \\} = \\{ \\inprod {x^*} x \\leq -a \\}.\n  \\end{equation*}\n\n  If the inequalities are strict, we instead obtain \\term{open half-spaces}.\n\\end{definition}\n\n\\begin{definition}\\label{def:polyhedron}\n  A \\term{polyhedron} in a real vector space is an intersection of \\hyperref[def:half_space]{half-spaces}.\n\\end{definition}\n\n\\begin{definition}\\label{def:hyperplane_separation}\n  Although \\hyperref[def:hyperplane]{hyperplanes} are defined for vector spaces over an arbitrary field \\( \\BbbK \\), we define \\term{hyperplane separation} only for \\( \\BbbK \\in \\{ \\BbbR, \\BbbC \\} \\) (see \\fullref{rem:real_field_extensions}).\n\n  We say that the sets \\( A, B \\subseteq X \\) are \\term{separated} by the linear functional \\( l \\in X^* \\) if there exists a real number \\( c \\in \\BbbR \\) such that\n  \\begin{equation}\\label{def:hyperplane_separation/normal}\n    \\real l(x) < c \\leq \\real l(y) \\quad\\forall x \\in A, y \\in B.\n  \\end{equation}\n\n  See \\fullref{rem:linear_functionals_over_c} for a justification of only considering the real part of \\( l \\).\n\n  The asymmetry in the inequalities \\fullref{def:hyperplane_separation/normal} can be inverted by considering \\( -l(x) \\) and \\( -c \\).\n\n  We say that \\( A \\) and \\( B \\) are \\term{strongly separated} by \\( l \\) if both inequalities in \\fullref{def:hyperplane_separation/normal} are strict:\n  \\begin{equation}\\label{def:hyperplane_separation/strong}\n    \\real l(x) < c < \\real l(y) \\quad\\forall x \\in A, y \\in B.\n  \\end{equation}\n\n  We can regard \\( l \\) as a hyperplane as in \\fullref{def:hyperplane/kernel}, which justifies the terminology \\enquote{hyperplane separation}. It is more correct, however, especially if \\( \\BbbK = \\BbbR \\), to say that they are separated by the affine hyperplane \\( l(x) + c \\).\n\n  If \\( \\BbbK = \\BbbR \\) \\fullref{def:hyperplane_separation/normal} is equivalent to requiring that \\( A \\) is contained in an open \\hyperref[def:half_space]{half-space} relative to \\( l(x) + c \\) and that \\( B \\) is contained in the complementing closed half-space (or vice-versa). \\Fullref{def:hyperplane_separation/strong} then states that both \\( A \\) and \\( B \\) are contained in opposite open half-spaces.\n\\end{definition}\n\n\\begin{definition}\\label{def:convex_set}\n  \\hfill\n  \\begin{thmenum}\n    \\thmitem{def:convex_set/line_segment} Given two points \\( x, y \\in X \\) in a Banach space \\( X \\), we define the \\term{line segment} between \\( x \\) and \\( y \\) as the parametric curve \\( t \\mapsto tx + (1-t)y, t \\in [0, 1] \\). The image\n    \\begin{equation*}\n      [x, y] \\coloneqq \\{ tx + (1-t)y \\colon t \\in [0, 1] \\}\n    \\end{equation*}\n    of this parametric curve is called the \\term{convex hull} of \\( x \\) and \\( y \\). We usually use the term \\enquote{line segment} to refer to the convex hull itself.\n\n    The length \\( \\len([x, y]) \\) of a line segment is defined as \\( \\norm{x - y} \\).\n\n    \\thmitem{def:convex_set/hull} We define the convex hull \\( \\conv A \\) of a set \\( A \\subseteq X \\) as the union of all line segments with endpoints in \\( A \\).\n\n    \\thmitem{def:convex_set/set} We call a set \\term{convex} if it coincides with its convex hull, that is, if it contains the line segment between any two of its points.\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{proposition}\\label{thm:def:convex_set/properties}\n  \\hyperref[def:convex_set]{Convex sets} have the following basic properties:\n\n  \\begin{thmenum}\n    \\thmitem{thm:def:convex_set/properties/closed_under_combinations} A convex set is closed under convex \\hyperref[def:linear_combination/convex]{combinations}.\n    \\thmitem{thm:def:convex_set/properties/cone_closed_under_combinations} A closed \\hyperref[def:convex_set]{convex} \\hyperref[def:geometric_cone]{cone} is closed under conic \\hyperref[def:linear_combination/conic]{combinations}.\n    \\thmitem{thm:def:convex_set/properties/closed_under_intersections} Any intersection of convex sets is convex.\n  \\end{thmenum}\n\\end{proposition}\n\\begin{proof}\n  \\SubProofOf{thm:def:convex_set/properties/closed_under_combinations} Fix a convex set \\( C \\). Let \\( \\sum_{k=1}^n t_k x_k \\) be a convex combination of elements of \\( C \\).\n\n  We will use induction on \\( n \\). If \\( n = 1 \\), this is obvious. If \\( n = 2 \\), this is given by definition. Assume that it is true for \\( n - 1 \\). Denote \\( s \\coloneqq \\sum_{k=1}^{n-1} t_k \\). If \\( s = 0 \\), take another convex combination in order to handle all the possible cases of the induction. Suppose \\( s \\neq 0 \\). Then\n  \\begin{equation*}\n    \\sum_{k=1}^n t_k x_k\n    =\n    s \\sum_{k=1}^n \\frac {t_k} s x_k\n    =\n    s \\underbrace{\\sum_{k=1}^{n-1} \\frac {t_k} s x_k}_{\\eqqcolon y} + t_n x_n.\n  \\end{equation*}\n\n  By the inductive hypothesis, \\( y \\in C \\). Note that \\( s \\in [0, 1] \\) and that \\( s + t_n = 1 \\) by definitions of \\( s \\). Then \\( s y + t_n x_n \\) is a binary convex combination that we know is contained in \\( C \\) by definition.\n\n  \\SubProofOf{thm:def:convex_set/properties/cone_closed_under_combinations} Fix a cone \\( C \\). Let \\( \\sum_{k=1}^n t_k x_k \\) be a conic combination of elements of \\( C \\). Each vector \\( x_k \\) lies on a closed ray, say \\( r_k \\), thus \\( t_k x_k \\) also lies on \\( r_k \\).\n\n  Therefore, we only need to show that the sum of two elements \\( x_1, x_2 \\in C \\) is again in \\( C \\). This is true because \\( x_1 + x_2 \\) is a convex combination of \\( 2x_1 \\in r_1 \\) and \\( 2x_2 \\in r_2 \\).\n\n  \\SubProofOf{thm:def:convex_set/properties/closed_under_intersections} Let \\( X = \\cap_{\\alpha \\in \\mscrK} X_\\alpha \\) be an intersection of convex sets. Take \\( x, y \\in X \\) and \\( t \\in [0, 1] \\). Then \\( tx + (1-t)y \\in X_\\alpha \\) for all \\( \\alpha \\in \\mscrK \\), hence \\( tx + (1-t)y \\in X \\). Therefore, \\( X \\) is convex.\n\\end{proof}\n\n\\begin{definition}\\label{def:simplex}\n  A \\( k \\)-\\term{simplex} is the convex \\hyperref[def:convex_set/hull]{hull} of \\( k + 1 \\) affinely \\hyperref[affine_independence]{independent} vectors called the \\term{vertices} of the simplex. The convex hull of any subset of the vertices is called a \\term{face} of the simplex.\n\n  \\begin{thmenum}\n    \\thmitem{def:simplex/point} A \\( 0 \\)-simplex is a \\hyperref[def:point]{point}.\n    \\thmitem{def:simplex/line_segment} A \\( 1 \\)-simplex is a line segment as defined in \\fullref{def:convex_set/line_segment}.\n    \\thmitem{def:simplex/triangle} A \\( 2 \\)-simplex is a triangle as defined in \\fullref{def:triangle}.\n    \\thmitem{def:simplex/tetrahedron} A \\( 3 \\)-simplex is called a \\term{tetrahedron}.\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:k_cell}\n  A \\( k \\)-cell is a \\hyperref[def:cartesian_product]{Cartesian product} of \\( k \\) nonempty \\hyperref[def:partially_ordered_set_interval/closed]{closed intervals} of real numbers.\n\n  \\begin{thmenum}\n    \\thmitem{def:k_cell/point} A \\( 0 \\)-cell is a \\hyperref[def:point]{point}.\n    \\thmitem{def:k_cell/interval} A \\( 1 \\)-cell is a closed interval.\n    \\thmitem{def:k_cell/rectangle} A \\( 2 \\)-cell is called a \\term{rectangle}. If a rectangle \\( R \\) is a product of two copies of the same interval, i.e. if \\( R = [a, b]^2 \\), we say that \\( R \\) is a \\term{square} with side \\( b - a \\).\n    \\thmitem{def:k_cell/parallelepiped} A \\( 3 \\)-cell is called a \\term{parallelepiped}. If \\( R = [a, b]^3 \\), we say that \\( R \\) is a \\term{cube} with side \\( b - a \\).\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:neighborhood_set_types}\n  The following topology-independent definitions are often used for neighborhoods in a topological vector space \\( X \\):\n\n  \\begin{thmenum}\n    \\thmitem{def:neighborhood_set_types/absorbing} \\( A \\) is \\term{absorbing} if \\( \\bigcup_{k=0}^\\infty kA = X \\).\n    \\thmitem{def:neighborhood_set_types/symmetric} \\( A \\) is \\term{symmetric} if \\( -A = A \\).\n    \\thmitem{def:neighborhood_set_types/balanced} \\( A \\) is \\term{balanced} if \\( tA \\subseteq A \\) for any \\( t \\in [0, 1] \\).\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:collinear_complanar}\n  The geometric version of \\hyperref[def:left_module_linear_dependence]{linear independence} has two special names: we say that the set \\( A \\subseteq X \\) of any vector space \\( X \\) is \\term{collinear} (on the same line) if \\( \\dim(\\linspan(A)) \\leq 1 \\) and \\term{complanar} (on the same plane) if \\( \\dim(\\linspan(A)) \\leq 2 \\).\n\\end{definition}\n\n\\begin{proposition}\\label{thm:moment_curve}\n  Consider \\hyperref[def:parametric_curve]{curve}\n  \\begin{equation*}\n    \\begin{aligned}\n      &\\gamma: \\BbbR \\to \\BbbR^n \\\\\n      &\\gamma(t) \\coloneqq (t, t^2, \\ldots, t^n).\n    \\end{aligned}\n  \\end{equation*}\n\n  For any \\( t_1 < \\ldots < t_n \\), the points \\( \\gamma(t_1), \\ldots, \\gamma(t_n) \\) are linearly independent.\n\n  This curve is called the \\term{moment curve} of dimension \\( n \\).\n\\end{proposition}\n\\begin{proof}\n  Follows from \\fullref{ex:vandermonde_matrix}.\n\\end{proof}\n", "meta": {"hexsha": "b48298def3b793167f5bb2754f3b3e4dc3c30fd3", "size": 18366, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/vector_space_geometry.tex", "max_stars_repo_name": "v--/notebook", "max_stars_repo_head_hexsha": "d9bdfbab9f35095db2721f991a3418f58f997a56", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/vector_space_geometry.tex", "max_issues_repo_name": "v--/notebook", "max_issues_repo_head_hexsha": "d9bdfbab9f35095db2721f991a3418f58f997a56", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/vector_space_geometry.tex", "max_forks_repo_name": "v--/notebook", "max_forks_repo_head_hexsha": "d9bdfbab9f35095db2721f991a3418f58f997a56", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.0647482014, "max_line_length": 798, "alphanum_fraction": 0.6981923119, "num_tokens": 5862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4372963720813387}}
{"text": "\\newpage\r\n\\section{Groebner package}\r\n\\begin{Introduction}{Groebner bases}\r\nThe GROEBNER package calculates \\nameindex{Groebner bases} using the\r\n\\nameindex{Buchberger algorithm} and provides related algorithms\r\nfor arithmetic with ideal bases, such as ideal quotients,\r\nHilbert polynomials (\\nameindex{Hollmann algorithm}), \r\nbasis conversion (\r\n\\nameindex{Faugere-Gianni-Lazard-Mora algorithm}), independent  \r\nvariable set (\\nameindex{Kredel-Weispfenning algorithm}).\r\n\r\n\r\n\r\nSome routines of the Groebner package are used by \\nameref{solve} - in\r\nthat context the package is loaded automatically. However, if you\r\nwant to use the package by explicit calls you must load it by\r\n\\begin{verbatim}\r\n    load_package groebner;\r\n\\end{verbatim}\r\n\r\nFor the common parameter setting of most operators in this package \r\nsee \\nameref{ideal parameters}.\r\n\\end{Introduction}\r\n\r\n\r\n\r\n\\begin{Concept}{Ideal Parameters}\r\n\\index{polynomial}\r\nMost operators of the \\name{Groebner} package compute expressions in a\r\npolynomial ring which given as \\meta{R}[\\meta{var},\\meta{var},...] where\r\n\\meta{R} is the current REDUCE coefficient domain.  All algebraically\r\nexact domains of REDUCE are supported.  The package can operate over rings\r\nand fields.  The operation mode is distinguished automatically.  In\r\ngeneral the ring mode is a bit faster than the field mode.  The factoring\r\nvariant can be applied only over domains which allow you factoring of\r\nmultivariate polynomials.\r\n\r\nThe variable sequence \\meta{var} is either declared explicitly as argument\r\nin form of a \\nameref{list} in \\nameref{torder}, or it is extracted\r\nautomatically from the expressions.  In the second case the current REDUCE\r\nsystem order is used (see \\nameref{korder}) for arranging the variables.\r\nIf some kernels should play the role of formal parameters (the ground\r\ndomain \\meta{R} then is the polynomial ring over these), the variable\r\nsequences must be given explicitly.\r\n\r\nAll REDUCE \\nameref{kernel}s can be used as variables.  But please note,\r\nthat all variables are considered as independent.  E.g. when using\r\n\\name{sin(a)} and \\name{cos(a)} as variables, the basic relation\r\n\\name{sin(a)^2+cos(a)^2-1=0} must be explicitly added to an equation set\r\nbecause the Groebner operators don't include such knowledge automatically.\r\n\r\nThe terms (monomials) in polynomials are arranged according to the current\r\n\\nameref{term order}.  Note that the algebraic properties of the computed\r\nresults only are valid as long as neither the ordering nor the variable\r\nsequence changes.\r\n\r\nThe input expressions \\meta{exp} can be polynomials \\meta{p}, rational\r\nfunctions \\meta{n}/\\meta{d} or equations \\meta{lh}=\\meta{rh} built from\r\npolynomials or rational functions.  Apart from the \\name{tracing}\r\nalgorithms \\nameref{groebnert} and \\nameref{preducet}, where the equations\r\nhave a specific meaning, equations are converted to simple expressions by\r\ntaking the difference of the left-hand and right-hand sides\r\n\\meta{lh}-\\meta{rh}=>\\meta{p}.  Rational functions are converted to\r\npolynomials by converting the expression to a common denominator form\r\nfirst, and then using the numerator only \\meta{n}=>\\meta{p}.  So eventual\r\nzeros of the denominators are ignored.\r\n\r\nA basis on input or output of an algorithm is coded as \\nameref{list} of\r\nexpressions \\{\\meta{exp},\\meta{exp},...\\} . \\end{Concept}\r\n\r\n%-----------------------------------------------------------------\r\n\\subsection{Term order}\r\n%-----------------------------------------------------------------\r\n\\begin{Introduction}{Term order}\r\n\\index{distributive polynomials}\r\nFor all \\name{Groebner} operations the polynomials are \r\nrepresented in distributive form: a sum of terms (monomials).\r\nThe terms are ordered corresponding to the actual \\name{term order}\r\nwhich is set by the \\nameref{torder} operator, and to the\r\nactual variable sequence which is either given as explicit\r\nparameter or by the system \\nameref{kernel} order. \r\n\\end{Introduction}\r\n\r\n\\begin{Operator}{torder}\r\nThe operator \\name{torder} sets the actual variable sequence and term order.\r\n\r\n1. simple term order:\r\n\\begin{Syntax}\r\n  \\name{torder}\\(\\meta{vl}, \\meta{m}\\)\r\n\\end{Syntax}\r\n\r\nwhere  \\meta{vl} is a \\nameref{list} of variables (\\nameref{kernel}s) and\r\n\\meta{m} is the name of a simple \\nameref{term order} mode \r\n\\ref{lex term order}, \\ref{gradlex term order}, \r\n\\ref{revgradlex term order} or another implemented parameterless mode.\r\n\r\n2. stepped term order:\r\n\\begin{Syntax}\r\n  \r\n  \\name{torder} \\(\\meta{vl},\\meta{m},\\meta{n}\\)\r\n\r\n\\end{Syntax}\r\n  \r\nwhere \\meta{m} is the name of a two step term order, one of\r\n\\nameref{gradlexgradlex term order}, \\nameref{gradlexrevgradlex term order},\r\n\\nameref{lexgradlex term order} or \\nameref{lexrevgradlex term order}, and\r\n\\meta{n} is a positive integer.\r\n\r\n3. weighted term order\r\n\\begin{Syntax}\r\n \\name{torder} \\(\\meta{vl}, \\name{weighted}, \\meta{n},\\meta{n},...\\); \r\n\\end{Syntax}\r\n\r\nwhere the \\meta{n} are positive integers, see \\nameref{weighted term order}.\r\n\r\n4. matrix term order\r\n\\begin{Syntax}\r\n \\name{torder} \\(\\meta{vl}, \\name{matrix}, \\meta{m}\\); \r\n\\end{Syntax}\r\n\r\nwhere \\meta{m} is a matrix with integer elements, see \r\n\\nameref{torder_compile}.\r\n\r\n5. compiled term order\r\n\\begin{Syntax}\r\n \\name{torder} \\(\\meta{vl}, \\name{co}\\); \r\n\\end{Syntax}\r\n\r\nwhere \\meta{co} is the name of a routine generated by \r\n\\nameref{torder_compile}.\r\n\r\n\\name{torder} sets the variable sequence and the term order mode. If the\r\nan empty list is used as variable sequence, the automatic variable extraction\r\nis activated. The defaults are the empty variable list an the \r\n\\nameref{lex term order}. \r\nThe previous setting is returned as a list. \r\n\r\nAlternatively to the above syntax the arguments of \\name{torder} may be \r\ncollected in a \\nameref{list} and passed as one argument to \r\n\\name{torder}.\r\n\r\n\\end{Operator}\r\n%------------------------------------------------------------\r\n\\begin{Operator}{torder_compile}\r\n\\index{term order}\r\nA matrix can be converted into\r\na compilable LISP program for faster execution by using\r\n\\begin{Syntax}\r\n    \\name{torder\\_compile}\\(\\meta{name},\\meta{mat}\\)\r\n\\end{Syntax}\r\nwhere \\meta{name} is an identifier for the new term order and \\meta{mat}\r\nis an integer matrix to be used as \\nameref{matrix term order}. Afterwards\r\nthe term order can be activated by using \\meta{name} in a \\nameref{torder}\r\nexpression. The resulting program is compiled if the switch \\nameref{comp}\r\nis on, or if the  \\name{torder\\_compile} expression is part of a compiled\r\nmodule.\r\n\\end{Operator}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{lex term order}\r\n\\index{term order}\\index{variable elimination}\r\nThe terms are ordered lexicographically: two terms t1 t2 \r\nare compared for their degrees \r\nalong the fixed variable sequence: t1 is higher than t2\r\nif the first different degree is higher in t1.\r\nThis order has the \\name{elimination property}\r\nfor \\name{groebner basis} calculations.\r\nIf the ideal has a univariate polynomial in the last\r\nvariable the groebner basis will contain\r\nsuch polynomial. \\name{Lex} is best\r\nsuited for solving of polynomial equation systems.\r\n\r\n\\end{Concept}\r\n\r\n%------------------------------------------------------------\r\n\\begin{Concept}{gradlex term order}\r\n\\index{term order}\r\nThe terms are ordered first with their total\r\ndegree, and if the total degree is identical\r\nthe comparison is \\nameref{lex term order}.\r\nWith \\name{groebner} basis calculations this term order\r\nproduces polynomials of lowest degree.\r\n\\end{Concept}\r\n\r\n%------------------------------------------------------------\r\n\\begin{Concept}{revgradlex term order}\r\n\\index{term order}\r\nThe terms are ordered first with their total\r\ndegree (degree sum), and if the total degree is identical\r\nthe comparison is the inverse of \\nameref{lex term order}.\r\nWith \\nameref{groebner} and \\nameref{groebnerf} \r\ncalculations this term order\r\nis similar to \\nameref{gradlex term order}; it is known\r\nas most efficient ordering with respect to computing time.\r\n\\end{Concept}\r\n\r\n%------------------------------------------------------------\r\n\\begin{Concept}{gradlexgradlex term order}\r\n\\index{term order}\r\nThe terms are separated into two groups where the\r\nsecond parameter of the \\nameref{torder} call determines\r\nthe length of the first group. For a comparison first\r\nthe total degrees of both variable groups are compared.\r\nIf both are equal \r\n\\nameref{gradlex term order} comparison is applied to the first\r\ngroup, and if that does not decide \\nameref{gradlex term order}\r\nis applied for the second group. This order has the elimination\r\nproperty for the variable groups. It can be used e.g. for\r\nseparating variables from parameters.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{gradlexrevgradlex term order}\r\n\\index{term order}\r\nSimilar to \\nameref{gradlexgradlex term order}, but using\r\n\\nameref{revgradlex term order} for the second group.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{lexgradlex term order}\r\n\\index{term order}\r\nSimilar to \\nameref{gradlexgradlex term order}, but using\r\n\\nameref{lex term order} for the first group.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{lexrevgradlex term order}\r\n\\index{term order}\r\nSimilar to \\nameref{gradlexgradlex term order}, but using\r\n\\nameref{lex term order} for the first group\r\n\\nameref{revgradlex term order} for the second group.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{weighted term order}\r\n\\index{term order}\r\nestablishes a graduated ordering\r\nsimilar to \\nameref{gradlex term order}, where the exponents first are\r\nmultiplied by the given weights. If there are less weight values than\r\nvariables, the weight list is extended by ones. If the weighted degree\r\ncomparison is not decidable, the \r\n\\nameref{lex term order} is used.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{graded term order}\r\n\\index{term order}\r\nestablishes a cascaded term ordering:  first a graduated ordering\r\nsimilar to \\nameref{gradlex term order} is used, where the exponents first are\r\nmultiplied by the given weights. If there are less weight values than\r\nvariables, the weight list is extended by ones. If the weighted degree\r\ncomparison is not decidable, the term ordering described in the following\r\nparameters of the \\nameref{torder} command is used.\r\n\\end{Concept}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{matrix term order}\r\n\\index{term order}\r\nAny arbitrary term order mode can be installed by a matrix with\r\ninteger elements where the row length corresponds to the variable\r\nnumber. The matrix must have at least as many rows as columns.\r\nIt must have full rank, and the top nonzero element of each column\r\nmust be positive.\r\n\r\nThe matrix \\name{term order mode}\r\ndefines a term order where the exponent vectors of the monomials are\r\nfirst multiplied by the matrix and the resulting vectors are compared\r\nlexicographically.\r\n\r\nIf the switch \\nameref{comp} is on, the matrix is converted into\r\na compiled LISP program for faster execution. A matrix can also be\r\ncompiled explicitly, see \\nameref{torder_compile}.\r\n\\end{Concept}\r\n%--------------------------------------------------------------- \r\n%------------------------------------------------------------\r\n\\subsection{Basic Groebner operators}\r\n%-------------------------------------------------------------\r\n\\begin{Operator}{gvars}\r\n\\begin{Syntax}\r\n\r\n  \\name{gvars}\\(\\{\\meta{exp},\\meta{exp},... \\}\\)\r\n\r\n\\end{Syntax}\r\n where \\meta{exp} are expressions or \\nameref{equation}s.\r\n\r\n\\name{gvars} extracts from the expressions the \\nameref{kernel}\\name{s} \r\nwhich can \r\nplay the role of variables for a \\nameref{groebner} or \\nameref{groebnerf} \r\ncalculation. \r\n\\end{Operator}\r\n\r\n%---------------------------------------------------------------\r\n\r\n\\begin{Operator}{groebner}\r\n\\index{Buchberger algorithm}\r\n\\begin{Syntax}\r\n\r\n  \\name{groebner}\\(\\{\\name{exp}, ...\\}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\{\\name{exp}, ... \\} is a list of\r\nexpressions or equations.\r\n\r\n\r\nThe operator \\name{groebner} implements the Buchberger algorithm\r\nfor computing Groebner bases for a given set of\r\nexpressions with respect to the given set of variables in the order\r\ngiven.  As a side effect, the sequence of variables is stored as a REDUCE list\r\nin the shared variable \\nameref{gvarslast} - this is important in cases\r\nwhere the algorithm rearranges the variable sequence because \\nameref{groebopt}\r\nis \\name{on}.\r\n\r\n\\begin{Examples}\r\n   groebner({x**2+y**2-1,x-y})  &  \\{X - Y,2*Y**2 -1\\}\r\n\\end{Examples}\r\n\\begin{Related}\r\n\\item[ \\nameref{groebnerf} operator]\r\n\\item[ \\nameref{gvarslast} variable]\r\n\\item[ \\nameref{groebopt} switch]\r\n\\item[ \\nameref{groebprereduce} switch]\r\n\\item[ \\nameref{groebfullreduction} switch]\r\n\\item[ \\nameref{gltbasis} switch]\r\n\\item[ \\nameref{gltb} variable]\r\n\\item[ \\nameref{glterms} variable]\r\n\\item[ \\nameref{groebstat} switch]\r\n\\item[ \\nameref{trgroeb} switch]\r\n\\item[ \\nameref{trgroebs} switch]\r\n\\item[ \\nameref{groebprot} switch]\r\n\\item[ \\nameref{groebprotfile} variable]\r\n\\item[ \\nameref{groebnert} operator]\r\n\\end{Related}\r\n\\end{Operator}\r\n%-------------------------------------------------------\r\n\r\n\\begin{Operator}{groebner\\_walk}\r\nThe operator \\name{groebner\\_walk} computes a \\nameref{lex} basis\r\nfrom a given \\nameref{graded} (or \\nameref{weighted}) one.\r\n\\begin{Syntax}\r\n   \\name{groebner\\_walk}\\(\\meta{g}\\)\r\n\\end{Syntax}\r\n\r\nwhere \\meta{g} is a \\nameref{graded} basis (or \\nameref{weighted} basis\r\nwith a weight vector with one repeated element) of the polynomial ideal. \r\n\\name{Groebner\\_walk} computes a sequence of monomial bases, each\r\ntime lifting the full system to a complete basis.  \\name{Groebner\\_walk}\r\nshould be called only in cases, where a normal \\nameref{kex} computation\r\nwould take too much computer time.\r\n\r\nThe operator \\nameref{torder} has to be called before in order to\r\ndefine the variable sequence and the term order mode of \\meta{g}. \r\n\r\nThe variable \\nameref{gvarslast} is not set.\r\n\r\nDo not call \\name{groebner\\_walk} with \\name{on} \\nameref{groebopt}.\r\n\r\n\\name{Groebner\\_walk} includes some overhead (such as e. g. \r\ncomputation with division). On the other hand, sometimes\r\n\\name{groebner\\_walk} is faster than a direct \\nameref{lex} computation.\r\n\\end{Operator}\r\n\r\n%-------------------------------------------------------\r\n\r\n\\begin{Switch}{groebopt}\r\nIf \\name{groebopt} is set ON, the sequence of variables is optimized\r\nwith respect to execution speed of \\name{groebner} calculations; \r\nnote that the final list of variables is available in \\nameref{gvarslast}.\r\nBy default \\name{groebopt} is off, conserving the original variable\r\nsequence.\r\n\r\nAn explicitly declared dependency using the \\nameref{depend}\r\ndeclaration  supersedes the variable optimization.\r\n\\begin{Examples}\r\n\r\n   depend a, x, y;\r\n\r\n\\end{Examples}\r\nguarantees that a will be placed in front of x and y.\r\n\\end{Switch}\r\n\r\n\r\n%-------------------------------------------------------\r\n\r\n\\begin{Variable}{gvarslast}\r\nAfter a \\nameref{groebner} or \\nameref{groebnerf} calculation\r\nthe actual variable sequence is stored in the variable \r\n\\name{gvarslast}. If \\nameref{groebopt} is \\name{on}\r\n\\name{gvarslast} shows the variable sequence after reordering.\r\n\\end{Variable}\r\n\r\n%--------------------------------------------------------------\r\n\r\n\\begin{Switch}{groebprereduce}\r\nIf \\name{groebprereduce} set ON, \\nameref{groebner} \r\nand \\nameref{groebnerf} try to simplify the\r\ninput expressions: if the head term of an input expression is a\r\nmultiple of the head term of another expression, it can be reduced;\r\nthese reductions are done cyclicly as long as possible in order to\r\nshorten the main part of the algorithm.\r\n\r\nBy default \\name{groebprereduce} is off.\r\n\\end{Switch}\r\n\r\n%---------------------------------------------------------------\r\n\r\n\\begin{Switch}{groebfullreduction}\r\nIf \\name{groebfullreduction} set off, the polynomial reduction steps during\r\n\\nameref{groebner} and \\nameref{groebnerf} are limited to the pure head\r\nterm reduction; subsequent terms are reduced otherwise.\r\n\r\nBy default \\name{groebfullreduction} is on.\r\n\\end{Switch}\r\n\r\n%----------------------------------------------------------------\r\n\r\n\\begin{Switch}{gltbasis}\r\nIf \\name{gltbasis} set on, the leading terms of the result basis \r\nof a \\nameref{groebner} or \\nameref{groebnerf} calculation are\r\nextracted. They are collected as a basis of monomials, which is\r\navailable as value of the global variable \\nameref{gltb}.\r\n\\end{Switch}\r\n%------------------------------------------------------------------\r\n\\begin{Variable}{gltb}\r\nSee \\nameref{gltbasis}\r\n\\end{Variable}\r\n%------------------------------------------------------------------\r\n\r\n\\begin{Variable}{glterms}\r\nIf the expressions in a \\nameref{groebner} or \\nameref{groebnerf} \r\ncall contain parameters (symbols\r\nwhich are not member of the variable list), the share variable\r\n\\name{glterms} is set to a list of expression which during the\r\ncalculation were assumed to be nonzero. The calculated bases \r\nare valid only under the assumption that all these expressions do\r\nnot vanish.\r\n\\end{Variable}\r\n\r\n%-----------------------------------------------------------\r\n\\begin{Switch}{groebstat}\r\nif \\name{groebstat} is on, a summary of the \r\n\\nameref{groebner} or \\nameref{groebnerf} computation is printed\r\nat the end \r\nincluding the computing time, the number of intermediate\r\nH polynomials and the counters for the criteria hits.\r\n\\end{Switch}\r\n\r\n%-----------------------------------------------------------\r\n\\begin{Switch}{trgroeb}\r\nif \\name{trgroeb} is on, intermediate H polynomials are \r\nprinted during a \\nameref{groebner} \r\nor \\nameref{groebnerf} calculation.\r\n\\end{Switch}\r\n\r\n%-----------------------------------------------------------\r\n\\begin{Switch}{trgroebs}\r\nif \\name{trgroebs} is on, intermediate H and S polynomials are \r\nprinted during a \\nameref{groebner} or \\nameref{groebnerf} calculation.\r\n\\end{Switch}\r\n\r\n%-----------------------------------------------------------\r\n\\begin{Operator}{gzerodim?} \r\n\\begin{Syntax}\r\n\r\n  \\name{gzerodim!?}\\(\\meta{basis}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\meta{bas} is a Groebner basis in the current \r\n\\nameref{term order} with the actual setting \r\n(see \\nameref{ideal parameters}). \r\n\r\n\r\n\\name{gzerodim!?} tests whether the ideal spanned by the given basis \r\nhas dimension zero. If yes, the number of zeros is returned,\r\n\\nameref{nil} otherwise.\r\n\\end{Operator}\r\n\r\n%---------------------------------------------------------------\r\n\r\n\\begin{Operator}{gdimension}\r\n\\index{ideal dimension}\\index{groebner}\r\n\\begin{Syntax}\r\n\r\n     \\name{gdimension}\\(\\meta{bas}\\) \r\n\r\n\\end{Syntax}\r\nwhere \\meta{bas} is a \\nameref{groebner} basis in the current\r\nterm order (see \\nameref{ideal parameters}). \r\n\\name{gdimension} computes the dimension of the ideal\r\nspanned by the given basis and returns the dimension as an integer\r\nnumber. The Kredel-Weispfenning algorithm is used: the dimension\r\nis the length of the longest independent variable set,\r\nsee \\nameref{gindependent\\_sets}\r\n\\end{Operator}\r\n\r\n\r\n%---------------------------------------------------------------\r\n\r\n\\begin{Operator}{gindependent\\_sets}\r\n\\index{ideal variables}\\index{ideal dimension}\\index{groebner}\r\n\\index{Kredel-Weispfenning algorithm}\r\n\\begin{Syntax}\r\n\r\n  \\name{gindependent\\_sets}\\(\\meta{bas}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\meta{bas} is a \\nameref{groebner} basis in any \\name{term order} \r\n(which must be the current \\name{term order}) with the specified\r\nvariables (see \\nameref{ideal parameters}). \r\n\r\n\r\n\\name{Gindependent_sets} computes the maximal\r\nleft independent variable sets of the ideal, that are \r\nthe variable sets which play the role of free parameters in the\r\ncurrent ideal basis. Each set is a list which is a subset of the\r\nvariable list. The result is a list of these sets. For an\r\nideal with dimension zero the list is empty.\r\nThe Kredel-Weispfenning algorithm is used.\r\n\\end{Operator}\r\n\r\n%--------------------------------------------------------------\r\n\r\n\\begin{Operator}{dd_groebner}\r\nFor a homogeneous system of polynomials under \r\n\\nameref{graded term order}, \\nameref{gradlex term order}, \r\n\\nameref{revgradlex term order} \r\nor \\nameref{weighted term order} \r\na Groebner Base can be computed with limiting the grade\r\nof the intermediate S polynomials: \r\n\\begin{Syntax}\r\n\\name{dd_groebner}\\(\\meta{d1},\\meta{d2},\\meta{plist}\\)\r\n\\end{Syntax}\r\nwhere \\meta{d1} is a non negative integer and \\meta{d2} is an integer\r\nor ``infinity\". A pair of polynomials is considered\r\nonly if the grade of the lcm of their head terms is between\r\n\\meta{d1} and \\meta{d2}.\r\nFor the term orders \\name{graded} or \\name{weighted} the (first) weight\r\nvector is used for the grade computation. Otherwise the total\r\ndegree of a term is used.\r\n\\end{Operator}\r\n\r\n%--------------------------------------------------------------\r\n\r\n\r\n\\begin{Operator}{glexconvert}\r\n\\index{ideal variables}\\index{term order}\r\n\\begin{Syntax}\r\n\r\n\\name{glexconvert}\\(\\meta{bas}[,\\meta{vars}][,MAXDEG=\\meta{mx}]\r\n[,NEWVARS=\\meta{nv}]\\)\r\n\r\n\\end{Syntax}\r\nwhere \\meta{bas} is a \\nameref{groebner} basis\r\nin the current term order,  \\meta{mx} (optional) is a positive\r\ninteger and \\meta{nvl} (optional) is a list of variables \r\n(see \\nameref{ideal parameters}).\r\n\r\n\r\nThe operator \\name{glexconvert} converts the basis \r\nof a zero-dimensional ideal (finite number\r\nof isolated solutions) from arbitrary ordering into a basis under \r\n\\nameref{lex term order}. \r\n\r\n\r\nThe parameter \\meta{newvars} defines the new variable sequence. \r\nIf omitted, the\r\noriginal variable sequence is used. If only a subset of variables is\r\nspecified here, the partial ideal basis is evaluated. \r\n\r\nIf \\meta{newvars} is a list with one element, the minimal\r\n\\nameindex{univariate polynomial} is computed.\r\n\r\n\\meta{maxdeg} is an upper limit for the degrees. The algorithm stops with\r\nan error message, if this limit is reached.\r\n\r\nA warning occurs, if the ideal is not zero dimensional.\r\n\\begin{Comments}\r\nDuring the call the \\name{term order} of the input basis must\r\nbe active.\r\n\\end{Comments}\r\n\\end{Operator}\r\n\r\n%--------------------------------------------------------------\r\n\r\n\\begin{Operator}{greduce}\r\n\\begin{Syntax}\r\n\r\n\\name{greduce}\\(exp, \\{exp1, exp2, \\ldots , expm\\}\\)\r\n\r\n\\end{Syntax}\r\n\r\nwhere exp is an expression, and \\{exp1, exp2, ... , expm\\} is\r\na list of expressions or equations.\r\n\r\n\r\n\\name{greduce} is functionally equivalent with a call to\r\n\\nameref{groebner} and then a call to \\nameref{preduce}.\r\n\\end{Operator}\r\n\r\n%---------------------------------------------------------\r\n\r\n\\begin{Operator}{preduce}\r\n\\begin{Syntax}\r\n\r\n \\name{preduce}\\(\\meta{p}, \\{\\meta{exp}, \\ldots \\}\\)\r\n\r\n\\end{Syntax}\r\n\r\nwhere \\meta{p} is an expression, and \\{\\meta{exp}, ... \\} is\r\na list of expressions or equations.\r\n\r\n\r\n\\name{Preduce} computes the remainder of \\name{exp}\r\nmodulo the given set of polynomials resp. equations.\r\nThis result is unique (canonical) only if the given set\r\nis a \\name{groebner} basis under the current \\nameref{term order}\r\n\r\nsee also: \\nameref{preducet} operator.\r\n\r\n\\end{Operator}\r\n\r\n\r\n%-------------------------------------------\r\n\r\n\\begin{Operator}{idealquotient}\r\n\\begin{Syntax}\r\n\r\n\\name{idealquotient}\\(\\{\\meta{exp}, ...\\}, \\meta{d}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\{\\meta{exp},...\\} is a list of \r\nexpressions or equations,  \\meta{d} is a single expression or equation.\r\n\r\n\r\n\\name{Idealquotient} computes the ideal quotient:\r\nideal spanned by the expressions \\{\\meta{exp},...\\}\r\ndivided by the single polynomial/expression \\meta{f}. The result\r\nis the \\nameref{groebner} basis of the quotient ideal.\r\n\\end{Operator}\r\n\r\n%-------------------------------------------------------------\r\n\r\n\\begin{Operator}{hilbertpolynomial}\r\n\\index{Hollmann algorithm}\r\n\\begin{Syntax}\r\n\r\n  hilbertpolynomial\\(\\meta{bas}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\meta{bas} is a \\nameref{groebner} basis in the\r\ncurrent \\nameref{term order}.\r\n\r\nThe degree of the \\name{Hilbert polynomial} is the\r\ndimension of the ideal spanned by the basis. For an\r\nideal of dimension zero the Hilbert polynomial is a\r\nconstant which is the number of common zeros of the\r\nideal (including eventual multiplicities).\r\nThe \\name{Hollmann algorithm} is used.\r\n\\end{Operator}\r\n\r\n%-------------------------------------------\r\n\r\n\\begin{Operator}{saturation}\r\n\\begin{Syntax}\r\n\r\n\\name{saturation}\\(\\{\\meta{exp}, ...\\}, \\meta{p}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\{\\meta{exp},...\\} is a list of\r\nexpressions or equations,  \\meta{p} is a single polynomial.\r\n\r\n\\name{Saturation} computes the quotient of the polynomial \\meta{p}\r\nand a power (with unknown but finite exponent) of the ideal built from\r\n\\{\\meta{exp}, ...\\}. The result is the computed quotient. \\name{Saturation}\r\ncalls \\nameref{idealquotient} several times until the result does not change\r\nany more.\r\n\\end{Operator}\r\n\r\n%-------------------------------------------------------------\r\n\\subsection{Factorizing Groebner bases}\r\n%-------------------------------------------------------------\r\n\r\n\\begin{Operator}{groebnerf}\r\n\\begin{Syntax}\r\n\r\n\\name{groebnerf}\\(\\{\\meta{exp}, ...\\}[,\\{\\},\\{\\meta{nz}, ... \\}]\\);\r\n\r\n\\end{Syntax}\r\nwhere \\{\\meta{exp}, ... \\} is a list of expressions or\r\nequations, and \\{\\meta{nz},... \\} is\r\nan optional list of polynomials to be considered as non zero\r\nfor this calculation. An empty list must be passed as second argument\r\nif the non-zero list is specified.\r\n\r\n\r\n\\name{groebnerf} tries to separate polynomials into individual factors and\r\nto branch the computation in a recursive manner (factorization tree).\r\nThe result is a list of partial Groebner bases. \r\nMultiplicities (one factor with a higher power, the same partial basis\r\ntwice) are deleted as early as possible in order to speed up the\r\ncalculation. \r\n\r\nThe third parameter of \\name{groebnerf} declares some polynomials\r\nnonzero. If any of these is found in a branch of the calculation\r\nthe branch is canceled. \r\n\r\n\\begin{Bigexample}\r\ngroebnerf({ 3*x**2*y+2*x*y+y+9*x**2+5*x = 3,  \r\n            2*x**3*y-x*y-y+6*x**3-2*x**2-3*x = -3, \r\n            x**3*y+x**2*y+3*x**3+2*x**2 }, {y,x});\r\n\r\n       {{Y - 3,X},\r\n\r\n                      2\r\n    {2*Y + 2*X - 1,2*X  - 5*X - 5}}\r\n\\end{Bigexample}\r\n\r\n\\begin{Related}\r\n\\item[ \\nameref{groebresmax} variable]\r\n\\item[ \\nameref{groebmonfac} variable]\r\n\\item[ \\nameref{groebrestriction} variable]\r\n\\item[ \\nameref{groebner} operator]\r\n\\item[ \\nameref{gvarslast} variable]\r\n\\item[ \\nameref{groebopt} switch]\r\n\\item[ \\nameref{groebprereduce} switch]\r\n\\item[ \\nameref{groebfullreduction} switch]\r\n\\item[ \\nameref{gltbasis} switch]\r\n\\item[ \\nameref{gltb} variable]\r\n\\item[ \\nameref{glterms} variable]\r\n\\item[ \\nameref{groebstat} switch]\r\n\\item[ \\nameref{trgroeb} switch]\r\n\\item[ \\nameref{trgroebs} switch]\r\n\\item[ \\nameref{groebnert} operator]\r\n\\end{Related}\r\n\r\n\\end{Operator}\r\n\r\n% ------------------------------------------------------------------\r\n\r\n\\begin{Variable}{groebmonfac}\r\nThe variable \\name{groebmonfac} is connected to\r\nthe handling of monomial factors.  A monomial factor is a product\r\nof variable powers as a factor, e.g. x**2*y  in  x**3*y -\r\n2*x**2*y**2.  A monomial factor represents a solution of the type\r\n x = 0  or  y = 0 with a certain multiplicity.  With\r\n\\nameref{groebnerf} the multiplicity of monomial factors is lowered \r\nto the value of the shared variable \\name{groebmonfac}\r\nwhich by default is 1 (= monomial factors remain present, but their\r\nmultiplicity is brought down). With\r\n\\name{groebmonfac}:= 0\r\nthe monomial factors are suppressed completely.\r\n\\end{Variable}\r\n\r\n% ----------------------------------------------------------------\r\n\\begin{Variable}{groebresmax}\r\nThe variable \\name{groebresmax}\r\ncontrols  during \\nameref{groebnerf} calculations\r\nthe number of partial results. Its default value is 300. If\r\nmore partial results are calculated, the calculation is\r\nterminated.\r\n\\end{Variable}\r\n\r\n% ----------------------------------------------------------------\r\n\\begin{Variable}{groebrestriction}\r\nDuring \\nameref{groebnerf} calculations \r\nirrelevant branches can be excluded\r\nby setting the variable \\name{groebrestriction}. The\r\nfollowing restrictions are implemented:\r\n\\begin{Syntax} \r\n     \\name{groebrestriction} := \\name{nonnegative} \\\\\r\n     \\name{groebrestriction} := \\name{positive}\\\\\r\n     \\name{groebrestriction} := \\name{zeropoint}\r\n\\end{Syntax}\r\nWith \\name{nonnegative} branches are excluded where one\r\npolynomial has no nonnegative real zeros; with \\name{positive}\r\nthe restriction is sharpened to positive zeros only.\r\nThe restriction \\name{zeropoint} excludes all branches\r\nwhich do not have the origin (0,0,...0) in their solution\r\nset.\r\n\\end{Variable}\r\n\r\n%---------------------------------------------------------\r\n\\subsection{Tracing Groebner bases}\r\n%---------------------------------------------------------\r\n\\index{tracing Groebner}\r\n\\begin{Switch}{groebprot}\r\nIf \\name{groebprot} is \\name{ON} the computation steps during\r\n\\nameref{preduce}, \\nameref{greduce} and \\nameref{groebner}\r\nare collected in a list which is assigned to the variable\r\n\\nameref{groebprotfile}.\r\n\\end{Switch}\r\n%----------------------------------------------------------\r\n\\begin{Variable}{groebprotfile}\r\nSee \\nameref{groebprot} switch.\r\n\\end{Variable}\r\n%----------------------------------------------------------\r\n\r\n\\begin{Operator}{groebnert}\r\n\\begin{Syntax}\r\n\r\n  \\name{groebnert}\\(\\{\\meta{v}=\\meta{exp},...\\}\\)\r\n\r\n\\end{Syntax}\r\nwhere \\meta{v} are \\nameref{kernel}\\name{s} (simple or indexed variables),\r\n\\meta{exp} are polynomials.\r\n\r\n\r\n\\name{groebnert} is functionally equivalent to a \\nameref{groebner}\r\ncall for \\{\\meta{exp},...\\}, but the result is a set of\r\nequations where the left-hand sides are the basis elements while\r\nthe right-hand sides are the same values expressed as combinations\r\nof the input formulas, expressed in terms of the names \\meta{v}\r\n\\begin{Bigexample}\r\n    groebnert({p1=2*x**2+4*y**2-100,p2=2*x-y+1});\r\n\r\n   GB1 := {2*X - Y + 1=P2,\r\n\r\n           2\r\n        9*Y  - 2*Y - 199= - 2*X*P2 - Y*P2 + 2*P1 + P2}\r\n\\end{Bigexample}\r\n\\end{Operator}\r\n%----------------------------------------------------------\r\n\r\n\\begin{Operator}{preducet}\r\n\\begin{Syntax}\r\n\r\n\\name{preduce}\\(\\meta{p},\\{\\meta{v}=\\meta{exp}...\\}\\)\r\n\\end{Syntax}\r\nwhere \\meta{p} is an expression, \\meta{v} are kernels \r\n(simple or indexed variables),\r\n\\name{exp} are polynomials.\r\n\r\n\\name{preducet} computes the remainder of \\meta{p} modulo \\{\\meta{exp},...\\}\r\nsimilar to \\nameref{preduce}, but the result is an equation\r\nwhich expresses the remainder as combination of the polynomials.\r\n\\begin{Bigexample}\r\n                             \r\n   GB2 := {G1=2*X - Y + 1,G2=9*Y**2  - 2*Y - 199}\r\n   preducet(q=x**2,gb2);\r\n\r\n - 16*Y + 208= - 18*X*G1 - 9*Y*G1 + 36*Q + 9*G1 - G2\r\n\\end{Bigexample}\r\n\\end{Operator}\r\n\r\n%------------------------------------------------------------\r\n\\subsection{Groebner Bases for Modules}\r\n%------------------------------------------------------------\r\n\\begin{Concept}{Module}\r\nGiven a polynomial ring, e.g. R=Z[x,y,...] and an integer n>1.\r\nThe vectors with n elements of R form a free MODULE under\r\nelementwise addition and multiplication with elements of R.\r\n\r\nFor a submodule given by a finite basis a Groebner basis\r\ncan be computed, and the facilities of the GROEBNER package\r\nare available except the operators \\nameref{groebnerf}\r\nand \\name{groesolve}. The vectors are encoded using auxiliary\r\nvariables which represent the unit vectors in the module.\r\nThese are declared in the share variable \\nameref{gmodule}.\r\n\r\n\\end{Concept}\r\n\r\n\\begin{Variable}{gmodule}\r\nThe vectors of a free \\nameref{module} over a polynomial ring R \r\nare encoded as linear combinations with unit vectors of\r\nM which are represented by auxiliary variables. These\r\nmust be collected in the variable \\name{gmodule} before\r\nany call to an operator of the Groebner package.\r\n\r\n\\begin{verbatim}\r\n   torder({x,y,v1,v2,v3})$\r\n   gmodule := {v1,v2,v3}$\r\n   g:=groebner({x^2*v1 + y*v2,x*y*v1 - v3,2y*v1 + y*v3});\r\n\\end{verbatim}\r\n\r\ncompute the Groebner basis of the submodule\r\n\r\n\\begin{verbatim}\r\n      ([x^2,y,0],[xy,0,-1],[0,2y,y])\r\n\\end{verbatim}\r\nThe members of the list \\name{gmodule} are automatically\r\nappended to the end of the variable list, if they are not\r\nyet members there. They take part in the actual term ordering.\r\n\\end{Variable}\r\n\r\n%------------------------------------------------------------\r\n\\subsection{Computing with distributive polynomials}\r\n%------------------------------------------------------------\r\n\r\n\\begin{Operator}{gsort}\r\n\\index{distributive polynomials}\r\n\\begin{Syntax}\r\n\r\n \\name{gsort}\\(\\meta{p}\\)\r\n\\end{Syntax}\r\nwhere \\meta{p} is a polynomial or a list of polynomials.\r\n\r\nThe polynomials are reordered and sorted corresponding to\r\nthe current \\nameref{term order}.\r\n\\begin{Examples}\r\n\r\n  torder lex;\\\\  \r\n  gsort(x**2+2x*y+y**2,{y,x});  &  {y**2+2y*x+x**2}\r\n\r\n\\end{Examples}\r\n\\end{Operator}\r\n\r\n%------------------------------------------------------------\r\n\r\n\\begin{Operator}{gsplit}\r\n\\index{distributive polynomials}\r\n\\begin{Syntax}\r\n\r\n \\name{gsplit}\\(\\meta{p}[,\\meta{vars}]\\);\r\n\\end{Syntax}\r\nwhere \\meta{p} is a polynomial or a list of polynomials.\r\n\r\nThe polynomial is reordered corresponding to the \r\nthe current \\nameref{term order} and then\r\nseparated into leading term and reductum. Result is\r\na list with the leading term as first and the reductum\r\nas second element.\r\n\\begin{Examples}\r\n\r\n  torder lex;\\\\  \r\n  gsplit(x**2+2x*y+y**2,{y,x});  &  \\{y**2,2y*x+x**2\\}\r\n\r\n\\end{Examples}\r\n\\end{Operator}\r\n%-------------------------------------------------------\r\n\r\n\\begin{Operator}{gspoly}\r\n\\index{distributive polynomials}\r\n\\begin{Syntax}\r\n\r\n \\name{gspoly}\\(\\meta{p1},\\meta{p2}\\);\r\n\r\n\\end{Syntax}\r\nwhere \\meta{p1} and \\meta{p2} are polynomials.\r\n\r\nThe \\name{subtraction} polynomial of p1 and p2 is computed\r\ncorresponding to the method of the Buchberger algorithm for\r\ncomputing \\name{groebner bases}: p1 and p2 are multiplied\r\nwith terms such that when subtracting them the leading terms \r\ncancel each other.\r\n\\end{Operator}\r\n", "meta": {"hexsha": "471bf8c977ecdca945c7c6c5a6044424d180138b", "size": 34151, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pk-groeb.tex", "max_stars_repo_name": "nilqed/REDHELP", "max_stars_repo_head_hexsha": "0c98a32bf21fa060ccd67ce82f638d6a1bc47a52", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pk-groeb.tex", "max_issues_repo_name": "nilqed/REDHELP", "max_issues_repo_head_hexsha": "0c98a32bf21fa060ccd67ce82f638d6a1bc47a52", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pk-groeb.tex", "max_forks_repo_name": "nilqed/REDHELP", "max_forks_repo_head_hexsha": "0c98a32bf21fa060ccd67ce82f638d6a1bc47a52", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.447171825, "max_line_length": 80, "alphanum_fraction": 0.6601856461, "num_tokens": 8745, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.7025300449389327, "lm_q1q2_score": 0.43729637208133865}}
{"text": "\\documentclass[accepted]{uai2021}\n\\usepackage[british]{babel}\n\\usepackage{natbib}\n\\bibliographystyle{plainnat}\n\\renewcommand{\\bibsection}{\\subsubsection*{References}}\n\\usepackage{mathtools} % amsmath with fixes and additions\n\\usepackage{booktabs} % commands to create good-looking tables\n\\usepackage{tikz} % nice language for creating drawings and diagrams\n\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage[capitalise]{cleveref}\n\n\\DeclareMathOperator{\\im}{im}\n\n\\newtheorem{innercustomthm}{Theorem}\n\\newenvironment{customthm}[1]\n{\\renewcommand\\theinnercustomthm{#1}\\innercustomthm}\n{\\endinnercustomthm}\n\\newtheorem{innercustomlemma}{Lemma}\n\\newenvironment{customlemma}[1]\n{\\renewcommand\\theinnercustomlemma{#1}\\innercustomlemma}\n{\\endinnercustomlemma}\n\n\\title{Weighted Model Counting with Conditional Weights for Bayesian Networks\n  (Supplementary Material)}\n\n\\author{Paulius~Dilkas}\n\\author{Vaishak~Belle}\n\\affil{%\n  University of Edinburgh\\\\\n  Edinburgh, UK\n}\n\n\\begin{document}\n\\maketitle\n\n\\section{Proofs}\n\n\\begin{customthm}{1}\n  The function $\\mu_\\nu$ is a measure.\n\\end{customthm}\n\\begin{proof}\n  Note that $\\mu_\\nu(\\bot) = 0$ since there are no atoms below $\\bot$. Let $a, b\n  \\in 2^{2^{U}}$ be such that $a \\land b = \\bot$. By elementary properties of\n  Boolean algebras, all atoms below $a \\lor b$ are either below $a$ or below\n  $b$. Moreover, none of them can be below both $a$ and $b$ because then they\n  would have to be below $a \\land b = \\bot$. Thus\n  \\begin{align*}\n    \\mu_\\nu(a \\lor b) &= \\sum_{\\{u\\} \\le a \\lor b} \\nu(u) = \\sum_{\\{u\\} \\le a} \\nu(u) + \\sum_{\\{u\\} \\le b} \\nu(u) \\\\\n                      &= \\mu_\\nu(a) + \\mu_\\nu(b)\n  \\end{align*}\n  as required.\n\\end{proof}\n\n\\begin{customthm}{3}\n  For any set $U$ and measure $\\mu\\colon 2^{2^U} \\to \\mathbb{R}_{\\ge 0}$, there\n  exists a set $V \\supseteq U$, a factorable measure $\\mu'\\colon 2^{2^V} \\to\n  \\mathbb{R}_{\\ge 0}$, and a formula $f \\in 2^{2^V}$ such that $\\mu(x) = \\mu'(x\n  \\land f)$ for all formulas $x \\in 2^{2^U}$.\n\\end{customthm}\n\\begin{proof}\n  Let $V = U \\cup \\{ f_m \\mid m \\in 2^U \\}$, and $f = \\bigwedge_{m \\in 2^U} \\{ m\n  \\} \\leftrightarrow f_m$. We define weight function $\\nu\\colon 2^V \\to\n  \\mathbb{R}_{\\ge 0}$ as $\\nu = \\prod_{v \\in V} \\nu_v$, where $\\nu_v(\\{v\\}) =\n  \\mu(\\{m\\})$ if $v = f_m$ for some $m \\in 2^U$ and $\\nu_v(x) = 1$ for all other\n  $v \\in V$ and $x \\in 2^{\\{v\\}}$. Let $\\mu'\\colon 2^{2^V} \\to \\mathbb{R}_{\\ge\n    0}$ be the measure induced by $\\nu$. It is enough to show that $\\mu$ and $x\n  \\mapsto \\mu'(x \\land f)$ agree on the atoms in $2^{2^U}$. For any $\\{ a \\} \\in\n  2^{2^U}$,\n  \\begin{align*}\n    \\mu'(\\{ a \\} \\land f) &= \\sum_{\\{ x \\} \\le \\{ a \\} \\land f} \\nu(x) = \\nu(a \\cup \\{ f_a \\}) \\\\\n                          &= \\nu_{f_a}(\\{ f_a \\}) = \\mu(\\{ a \\})\n  \\end{align*}\n  as required.\n\\end{proof}\n\n\\begin{customlemma}{1} \\label{lemma:cpt}\n  Let $X \\in \\mathcal{V}$ be a random variable with parents $\\mathrm{pa}(X) = \\{ Y_1,\n  \\dots, Y_n \\}$. Then $\\mathrm{CPT}_X\\colon 2^{\\mathcal{E}^*(X)} \\to\n  \\mathbb{R}_{\\ge 0}$ is such that for any $x \\in \\im X$ and $(y_1, \\dots, y_n)\n  \\in \\prod_{i=1}^n \\im Y_i$,\n  \\[\n    \\mathrm{CPT}_X (T) = \\Pr(X = x \\mid Y_1 = y_1, \\dots, Y_n = y_n),\n  \\]\n  where $T = \\{ \\lambda_{X=x} \\} \\cup \\{ \\lambda_{Y_i=y_i} \\mid i = 1, \\dots, n\n  \\}$.\n\\end{customlemma}\n\\begin{proof}\n  If $X$ is binary, then $\\mathrm{CPT}_X$ is a sum of $2\\prod_{i=1}^n |\\im\n  Y_i|$ terms, one for each possible assignment of values to variables $X, Y_1,\n  \\dots, Y_n$. Exactly one of these terms is nonzero when applied to $T$, and\n  it is equal to $\\Pr(X = x \\mid Y_1 = y_1, \\dots, Y_n = y_n)$ by definition.\n\n  If $X$ is not binary, then $\\left( \\sum_{i=1}^m [\\lambda_{X = x_i}]\n  \\right)(T) = 1$, and $\\left( \\prod_{i=1}^m \\prod_{j=i+1}^m\n    (\\overline{[\\lambda_{X = x_i}]} + \\overline{[\\lambda_{X = x_j}]})\n  \\right)(T) = 1$, so $\\mathrm{CPT}_X(T) = \\Pr(X = x \\mid Y_1 = y_1,\n  \\dots, Y_n = y_n)$ by a similar argument as before.\n\\end{proof}\n\n\\begin{customlemma}{2} \\label{lemma:full_distribution}\n  Let $\\mathcal{V} = \\{X_1, \\dots, X_n\\}$. Then\n  \\[\n    \\phi(T) =\n    \\begin{cases}\n      \\Pr(x_1, \\dots, x_n) &\n      \\begin{aligned}\n        &\\text{if } T = \\{ \\lambda_{X_i=x_i} \\}_{i = 1}^n \\text{ for} \\\\\n        &\\text{some } \\textstyle (x_i)_{i=1}^n \\in \\prod_{i=1}^n \\im X_i\n      \\end{aligned} \\\\\n      0 & \\text{otherwise,}\n    \\end{cases}\n  \\]\n  for all $T \\in 2^U$.\n\\end{customlemma}\n\\begin{proof}\n  If $T = \\{ \\lambda_{X=v_X} \\mid X \\in \\mathcal{V} \\}$ for some $(v_X)_{X\n    \\in \\mathcal{V}} \\in \\prod_{X \\in \\mathcal{V}} \\im X$, then\n  \\begin{align*}\n    \\phi(T) &= \\prod_{X \\in \\mathcal{V}} \\Pr \\left( X=v_X \\;\\middle|\\; \\bigwedge_{Y \\in \\mathrm{pa}(X)} Y=v_Y \\right) \\\\\n            &= \\Pr \\left( \\bigwedge_{X \\in \\mathcal{V}} X=v_X \\right)\n  \\end{align*}\n  by \\cref{lemma:cpt} and the definition of a Bayesian network. Otherwise there\n  must be some non-binary random variable $X \\in \\mathcal{V}$ such that\n  $|\\mathcal{E}(X) \\cap T| \\ne 1$. If $\\mathcal{E}(X) \\cap T = \\emptyset$, then\n  $\\left( \\sum_{i=1}^m [\\lambda_{X = x_i}] \\right)(T) = 0$, and so\n  $\\mathrm{CPT}_X(T) = 0$, and $\\phi(T) = 0$. If $|\\mathcal{E}(X) \\cap T| > 1$,\n  then we must have two different values $x_1, x_2 \\in \\im X$ such that\n  $\\{\\lambda_{X=x_1}, \\lambda_{X=x_2} \\} \\subseteq T$ which means that\n  $(\\overline{[\\lambda_{X=x_1}]} + \\overline{[\\lambda_{X=x_2}]})(T) = 0$, and\n  so, again, $\\mathrm{CPT}_X(T) = 0$, and $\\phi(T) = 0$.\n\\end{proof}\n\n\\begin{customthm}{4}\n  For any $X \\in \\mathcal{V}$ and $x \\in \\im X$,\n  \\[\n    (\\exists_U(\\phi \\cdot [\\lambda_{X=x}]))(\\emptyset) = \\Pr(X = x).\n  \\]\n\\end{customthm}\n\\begin{proof}\n  Let $\\mathcal{V} = \\{ X, Y_1, \\dots, Y_n \\}$. Then\n  \\begin{align*}\n    (\\exists_U (\\phi \\cdot [\\lambda_{X=x}]))(\\emptyset) &= \\sum_{T \\in 2^U} (\\phi \\cdot [\\lambda_{X=x}])(T) \\\\\n                                                        &= \\sum_{\\lambda_{X=x} \\in T \\in 2^U} \\phi(T) \\\\\n                                                        &= \\sum_{\\lambda_{X=x} \\in T \\in 2^U} \\left( \\prod_{Y \\in \\mathcal{V}} \\mathrm{CPT}_Y \\right)(T) \\\\\n                                                        &= \\sum_{(y_i)_{i=1}^n \\in \\prod_{i=1}^n \\im Y_i} \\Pr(x, y_1, \\dots, y_n) \\\\\n                                                        &= \\Pr(X = x)\n  \\end{align*}\n  by:\n  \\begin{itemize}\n  \\item the proof of Theorem~1 by \\citet{DBLP:conf/aaai/DudekPV20};\n  \\item if $\\lambda_{X=x} \\not\\in T \\in 2^U$, then $(\\phi \\cdot\n    [\\lambda_{X=x}])(T) = \\phi(T) \\cdot [\\lambda_{X=x}](T \\cap \\{\n    \\lambda_{X=x} \\}) = \\phi(T) \\cdot 0 = 0$;\n  \\item \\cref{lemma:full_distribution};\n  \\item marginalisation of a probability distribution.\n  \\end{itemize}\n\\end{proof}\n\n\\bibliography{paper}\n\\end{document}", "meta": {"hexsha": "d944539cd57bf3945cbdd6e242d44a38d10f1709", "size": 6732, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/UAI_paper/supp.tex", "max_stars_repo_name": "dilkas/wmc-without-parameters", "max_stars_repo_head_hexsha": "931cff03bd47debb93b4f472f201d320fa94d568", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/UAI_paper/supp.tex", "max_issues_repo_name": "dilkas/wmc-without-parameters", "max_issues_repo_head_hexsha": "931cff03bd47debb93b4f472f201d320fa94d568", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/UAI_paper/supp.tex", "max_forks_repo_name": "dilkas/wmc-without-parameters", "max_forks_repo_head_hexsha": "931cff03bd47debb93b4f472f201d320fa94d568", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5555555556, "max_line_length": 155, "alphanum_fraction": 0.5797682709, "num_tokens": 2643, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.43728121197319847}}
{"text": "\\section{Instances}\n\\label{sec:instances}\n\nAs mentioned before, the design of ARX ciphers ensures they are efficient at both\nhardware and software levels. Hardware efficiency enables ARX can be run on most\nconstrained platforms, who typically equips with several KBs RAM and limited CPU power.\nOn the other hand, being efficient at software level also accelerate the PC applications\nand services, for example, easing the burden of a busy Web server who accepts intensive\nTLS connections.\n\nIn this section, two instances of ARX ciphers are introduced. The first one, called\n\\textsc{Speck}\\cite{beaulieu2015simon2}, is designated on IoT devices. The second one,\ncalled ChaCha\\cite{bernstein2008chacha}, is a general-purposed stream cipher family,\nand it is recently selected as the replacement of RC4 in the\nTLS\\footnote{\\url{https://tools.ietf.org/html/rfc7905}} standard.\n\n\\subsection{The \\textsc{\\textbf{Speck}} Block Cipher}\n\n\\textsc{Speck} is designed specifically for encrypting data on constrained platforms.\nIt is also able to offer security services on diverse platforms with different security\nlevels, which are controlled by two security parameters.\n\n\\textsc{Speck} block cipher adopts the notation \\textsc{Speck}$2n/nm$, where $2n$ is the\nblock size and $mn$ is the key size (in bits). In the design, $n\\in\\{16,24,32,48,64\\}$\nand each $n$ corresponds to a set of options for $m$. The \\textsc{Speck} round function\nis the (Feistel-based) map\n$$R_k(x,y)=((\\mathrm{r}^{-\\alpha}x+y)\\oplus k,\\ \\mathrm{r}^\\beta y\\oplus(\\mathrm{r}^{-\\alpha}x+y)\\oplus k)$$\nwhere $x$ and $y$ are $n$-bits quantities, and $k$ is the round key. The rotation\nparameters $\\alpha$ and $\\beta$, and the number of rounds are specified along with\nblock size $n$.\n\n\\textsc{Speck} with $m$-size words accepts the initial key $K=(\\ell_{m-2},\\dots,\\ell_0,k_0)$,\nit then generates round keys as follows:\n\n\\begin{equation*}\n\\setlength{\\abovedisplayshortskip}{0em}\n\\setlength{\\abovedisplayskip}{0em}\n\\begin{split}\n\\ell_{i+m-1} &= (k_i+\\mathrm{r}^{-\\alpha}\\ell_i)\\oplus i\\\\\nk_{i+1} &= \\mathrm{r}^\\beta k_i \\oplus \\ell_{i+m-1}\n\\end{split}\n\\end{equation*}\n\n\\noindent The value $k_i$ is the $i$-th round key.\n\n\\textsc{Speck}, by designed, uses \\textit{simple} round function with necessary times\nof rounds for security, as it offers compact implementation hence is suited for\nconstrained platforms. The use of uniform parameters (across different security levels)\nalso approves this purpose. Moreover, \\textsc{Speck} can be done entirely in-place, so\nunnecessary moves of word can be avoided to obtain better performance.\n\n\\subsection{The ChaCha Stream Cipher}\n\nThe cryptosystem ChaCha is a successor of the stream cipher Salsa20\n\\cite{bernstein2008salsa20}, which is designed to improve diffusion at each round. By\ndesign, ChaCha is faster than existing standard ciphers, and is aimed at users who\nvalue speed more than secrecy. ChaCha offers 3 variants, they are differed in the number\nof rounds: 8, 12 and 20 rounds versions.\n\nChaCha itself computes a quarter-round to update 4 32-bits state words $(a,b,c,d)$ as:\n\n\\begin{equation*}\n\\setlength{\\abovedisplayshortskip}{0em}\n\\setlength{\\abovedisplayskip}{0em}\n\\begin{split}\na &= a+b\\\\[1pt]\nc &= c+d\\\\[1pt]\na &= a+b\\\\[1pt]\nc &= c+d\\\\[1pt]\n\\end{split}\n\\quad\n\\begin{split}\nd &= \\mathrm{r}^{16}(d\\oplus a)\\\\\nb &= \\mathrm{r}^{12}(b\\oplus c)\\\\\nd &= \\mathrm{r}^{8}(d\\oplus a)\\\\\nb &= \\mathrm{r}^{7}(b\\oplus c)\\\\\n\\end{split}\n\\end{equation*}\n\nA ChaCha quarter-round gives each input word a chance to affect each output word, hence\nachieves efficient diffusion at each round: every 1-bit input difference changes 12.5\noutput bits on average. This is the major difference between ChaCha and its predecessor\nSalsa20, who affects on 8 bits per round.\n\nChaCha adopts the strategy that the plaintext and ciphertext do not affect the key stream,\nin other word, it is a synchronous stream cipher. To apply the stream, ChaCha simply xor\nit to the plaintext, as how a pseudorandom-OTP will work.\n\nGoogle proposed ChaCha20 along with Poly1305 MAC as a replacement for RC4 in TLS, to\nsecures TLS/SSL traffic between the Chrome browser on Android and Google's websites.\nShortly after Google, both the ChaCha20 and Poly1305 were implemented for a new\ncipher in OpenSSH. These adoptions imply that the ARX cipher family does not only\nessential for hardware efficiency, but also important for software performance.\n", "meta": {"hexsha": "62c999c4dbb9e617fa0de8a7f2a4fbeee7b701f3", "size": 4407, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "instances.tex", "max_stars_repo_name": "CirQ/arx_latex", "max_stars_repo_head_hexsha": "5d76131975d6a24ff71c1fff4c26d2ebbf16da0d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "instances.tex", "max_issues_repo_name": "CirQ/arx_latex", "max_issues_repo_head_hexsha": "5d76131975d6a24ff71c1fff4c26d2ebbf16da0d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "instances.tex", "max_forks_repo_name": "CirQ/arx_latex", "max_forks_repo_head_hexsha": "5d76131975d6a24ff71c1fff4c26d2ebbf16da0d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.8829787234, "max_line_length": 108, "alphanum_fraction": 0.7608350352, "num_tokens": 1246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.43728121197319847}}
{"text": "\\chapter{Expressions}\n\n{\\REDUCE} expressions\\index{Expression} may be of several types and consist\nof sequences of numbers, variables, operators, left and right parentheses\nand commas.  The most common types are as follows:\n\n\\section{Scalar Expressions}\n\n\\index{Scalar}Using the arithmetic operations {\\tt + - * / \\verb|^|}\n(power) and parentheses, scalar expressions are composed from numbers,\nordinary ``scalar'' variables (identifiers), array names with subscripts,\noperator or procedure names with arguments and statement expressions.\n\n{\\it Examples:}\n\\begin{verbatim}\n        x\n        x^3 - 2*y/(2*z^2 - df(x,z))\n        (p^2 + m^2)^(1/2)*log (y/m)\n        a(5) + b(i,q)\n\\end{verbatim}\nThe symbol ** may be used as an alternative to the caret symbol (\\verb+^+)\nfor forming powers, particularly in those systems that do not support a\ncaret symbol.\n\nStatement expressions, usually in parentheses, can also form part of\na scalar\\index{Scalar} expression, as in the example\n\\begin{verbatim}\n        w + (c:=x+y) + z .\n\\end{verbatim}\nWhen the algebraic value of an expression is needed, {\\REDUCE} determines it,\nstarting with the algebraic values of the parts, roughly as follows:\n\nVariables and operator symbols with an argument list have the algebraic\nvalues they were last assigned, or if never assigned stand for themselves.\nHowever, array elements have the algebraic values they were last assigned,\nor, if never assigned, are taken to be 0.\n\nProcedures are evaluated with the values of their actual parameters.\n\nIn evaluating expressions, the standard rules of algebra are applied.\nUnfortunately, this algebraic evaluation of an expression is not as\nunambiguous as is numerical evaluation. This process is generally referred\nto as ``simplification''\\index{Simplification} in the sense that the\nevaluation usually but not always produces a simplified form for the\nexpression.\n\nThere are many options available to the user for carrying out such\nsimplification\\index{Simplification}.  If the user doesn't specify any\nmethod, the default method is used.  The default evaluation of an\nexpression involves expansion of the expression and collection of like\nterms, ordering of the terms, evaluation of derivatives and other\nfunctions and substitution for any expressions which have values assigned\nor declared (see assignments and {\\tt LET} statements).  In many cases,\nthis is all that the user needs.\n\nThe declarations by which the user can exercise some control over the way\nin which the evaluation is performed are explained in other sections.  For\nexample, if a real (floating point) number is encountered during\nevaluation, the system will normally convert it into a ratio of two\nintegers.  If the user wants to use real arithmetic, he can effect this by\nthe command {\\tt on rounded;}.\\ttindex{ROUNDED} Other modes for\ncoefficient arithmetic are described elsewhere.\n\nIf an illegal action occurs during evaluation (such as division by zero)\nor functions are called with the wrong number of arguments, and so on, an\nappropriate error message is generated.\n% A list of such error messages is given in an appendix.\n\n\\section{Integer Expressions}\n\n\\index{Integer}These are expressions which, because of the values of the\nconstants and variables in them, evaluate to whole numbers.\n\n{\\it Examples:}\n\\begin{verbatim}\n        2,      37 * 999,       (x + 3)^2 - x^2 - 6*x\n\\end{verbatim}\nare obviously integer expressions.\n\\begin{verbatim}\n        j + k - 2 * j^2\n\\end{verbatim}\nis an integer expression when {\\tt J} and {\\tt K} have values that are\nintegers, or if not integers are such that ``the variables and fractions\ncancel out'', as in\n\\begin{verbatim}\n        k - 7/3 - j + 2/3 + 2*j^2.\n\\end{verbatim}\n\n\\section{Boolean Expressions}\n\\label{sec-boolean}\nA boolean expression\\index{Boolean} returns a truth value.  In the\nalgebraic mode of {\\REDUCE}, boolean expressions have the syntactical form:\n\\begin{verbatim}\n        <expression> <relational operator> <expression>\n\\end{verbatim}\nor\n\\begin{verbatim}\n        <boolean operator> (<arguments>)\n\\end{verbatim}\nor\n\\begin{verbatim}\n        <boolean expression> <logical operator>\n        <boolean expression>.\n\\end{verbatim}\nParentheses can also be used to control the precedence of expressions.\n\nIn addition to the logical and relational operators defined earlier as\ninfix operators, the following boolean operators are also defined:\\\\\n\\mbox{}\\\\\n\\ttindex{EVENP}\\ttindex{FIXP}\\ttindex{FREEOF}\\ttindex{NUMBERP}\n\\ttindex{ORDP}\\ttindex{PRIMEP}\n{\\renewcommand{\\arraystretch}{2}\n\\begin{tabular}{lp{\\redboxwidth}}\n{\\tt EVENP(U)} & determines if the number {\\tt U} is even or not; \\\\\n\n{\\tt FIXP(U)} & determines if the expression {\\tt U} is integer or not; \\\\\n\n{\\tt FREEOF(U,V)} & determines if the expression\n{\\tt U} does not contain the kernel {\\tt V} anywhere in its\nstructure; \\\\\n\n{\\tt NUMBERP(U)} & determines if {\\tt U} is a number or not; \\\\\n\n{\\tt ORDP(U,V)} & determines if {\\tt U} is ordered\nahead of {\\tt V} by some canonical ordering (based on the expression structure\nand an internal ordering of identifiers); \\\\\n\n{\\tt PRIMEP(U)} & true if {\\tt U} is a prime object, i.e., any object\nother than 0 and plus or minus 1 which is only exactly divisible\nby itself or a unit.\n \\\\\n\\end{tabular}}\n\n{\\it Examples:}\n\\begin{verbatim}\n        j<1\n        x>0  or  x=-2\n        numberp x\n        fixp x and evenp x\n        numberp x and x neq 0\n\\end{verbatim}\nBoolean expressions can only appear directly within {\\tt IF}, {\\tt FOR},\n{\\tt WHILE}, and {\\tt UNTIL} statements, as described in other sections.\nSuch expressions cannot be used in place of ordinary algebraic expressions,\nor assigned to a variable.\n\nNB:  For those familiar with symbolic mode, the meaning of some of\nthese operators is different in that mode.  For example, {\\tt NUMBERP} is\ntrue only for integers and reals in symbolic mode.\n\nWhen two or more boolean expressions are combined with {\\tt AND}, they are\nevaluated one by one until a {\\em false\\/} expression is found. The rest are\nnot evaluated. Thus\n\\begin{verbatim}\n        numberp x and numberp y and x>y\n\\end{verbatim}\ndoes not attempt to make the {\\tt x>y} comparison unless {\\tt X} and {\\tt Y}\nare both verified to be numbers.\n\nSimilarly, evaluation of a sequence of boolean expressions connected by\n{\\tt OR} stops as soon as a {\\em true\\/} expression is found.\n\nNB:  In a boolean expression, and in a place where a boolean expression is\nexpected, the algebraic value 0 is interpreted as {\\em false}, while all\nother algebraic values are converted to {\\em true}.  So in algebraic mode\na procedure can be written for direct usage in boolean expressions,\nreturning say 1 or 0 as its value as in\n\n\\begin{verbatim}\n        procedure polynomialp(u,x);\n           if den(u)=1 and deg(u,x)>=1 then 1 else 0;\n\\end{verbatim}\n\nOne can then use this in a boolean construct, such as\n\\begin{verbatim}\n        if polynomialp(q,z) and not polynomialp(q,y) then ...\n\\end{verbatim}\n\nIn addition, any procedure that does not have a defined return value\n(for example, a block without a {\\tt RETURN} statement in it)\nhas the boolean value {\\em false}. \n\n\\section{Equations}\n\nEquations\\index{Equation} are a particular type of expression with the syntax\n\n\\begin{verbatim}\n        <expression> = <expression>.\n\\end{verbatim}\n\nIn addition to their role as boolean expressions, they can also be used as\narguments to several operators (e.g., {\\tt SOLVE}), and can be\nreturned as values.\n\nUnder normal circumstances, the right-hand-side of the equation is\nevaluated but not the left-hand-side.  This also applies to any substitutions\nmade by the {\\tt SUB}\\ttindex{SUB} operator.  If both sides are to be\nevaluated, the switch {\\tt EVALLHSEQP}\\ttindex{EVALLHSEQP} should be\nturned on.\n\nTo facilitate the handling of equations, two selectors, {\\tt LHS}\n\\ttindex{LHS} and {\\tt RHS},\\ttindex{RHS} which return the left- and\nright-hand sides of a equation\\index{Equation} respectively, are provided.\nFor example,\n\\begin{verbatim}\n        lhs(a+b=c) -> a+b\nand\n        rhs(a+b=c) -> c.\n\\end{verbatim}\n\n\\section{Proper Statements as Expressions}\n\nSeveral kinds of proper statements\\index{Proper statement} deliver\nan algebraic or numerical result of some kind, which can in turn be used as\nan expression or part of an expression.  For example, an assignment\nstatement itself has a value, namely the value assigned.  So\n\\begin{verbatim}\n        2 * (x := a+b)\n\\end{verbatim}\nis equal to {\\tt 2*(a+b)}, as well as having the ``side-effect''\\index{Side\neffect} of assigning the value {\\tt a+b} to {\\tt X}.  In context,\n\\begin{verbatim}\n        y := 2 * (x := a+b);\n\\end{verbatim}\nsets {\\tt X} to {\\tt a+b} and {\\tt Y} to {\\tt 2*(a+b)}.\n\nThe sections on the various proper statement\\index{Proper statement} types\nindicate which of these statements are also useful as expressions.\n\n", "meta": {"hexsha": "b5bde79b2da6c09ce14b381ec5801f9e171d1442", "size": 8819, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "atomic_Decomp/Redlog/reduce.doc/exprn.tex", "max_stars_repo_name": "Korosensei42/AtomicDecomposition", "max_stars_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "atomic_Decomp/Redlog/reduce.doc/exprn.tex", "max_issues_repo_name": "Korosensei42/AtomicDecomposition", "max_issues_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "atomic_Decomp/Redlog/reduce.doc/exprn.tex", "max_forks_repo_name": "Korosensei42/AtomicDecomposition", "max_forks_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3434782609, "max_line_length": 78, "alphanum_fraction": 0.737158408, "num_tokens": 2220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.43728120892956907}}
{"text": "\\documentclass[11pt, oneside]{article}   \t% use \"amsart\" instead of \"article\" for AMSLaTeX format\n\\usepackage{geometry}                \t\t% See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}                   \t\t% ... or a4paper or a5paper or ... \n%\\geometry{landscape}                \t\t% Activate for rotated page geometry\n%\\usepackage[parfill]{parskip}    \t\t% Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\t\t\t\t% Use pdf, png, jpg, or eps§ with pdflatex; use eps in DVI mode\n\t\t\t\t\t\t\t\t% TeX will automatically convert eps --> pdf in pdflatex\t\t\n\\usepackage{amssymb, amsmath}\n\n%SetFonts\n\n%SetFonts\n\n\n\\title{Secure MPC Protocol for (Sample) Standard Deviation}\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\nRecall that for a database of size $n$ with data points $x_i$ indexed by $i \\in {1, \\dots, n},$ the sample variance $\\sigma^2$ is defined to be:\n$$\\sigma^2 = \\frac{1}{n-1} \\sum_{i=1}^n (x_i - \\bar{x})^2$$\nwhere $\\bar{x}$ is the sample mean:\n$$ \\bar{x} = \\frac{1}{n} \\sum_{i=1}^n x_i$$ \nThe sample standard deviation of a database, $\\sigma$, is the square root of the sample variance. \\\\\n\nIn the setting of MPC, rather than considering a single database of entries, we consider the case in which there is a set of parties where each party $P_i$ holds entry $x_i$. The parties wish to compute the standard deviation of their inputs, but do not wish to reveal their inputs to anyone. The inputs are allowed to be negative or positive, and they may not be whole numbers.\n\n\\paragraph{MPC-friendly formulation} However, there exists a well-known alternative formulation of the equation above, that show that $\\sigma^2$ can be written as:\n$$ \\sigma^2 = \\text{E}[X^2] -(\\text{E}[X])^2$$\n$$ = \\frac{\\sum{X^2}}{n} - \\frac{(\\sum{X})^2}{n^2}$$\n$$ = \\frac{n\\sum{X^2} - (\\sum{X})^2}{n^2} $$\n\n\\section{Secure Building Blocks}\nThe following building blocks that are implemented in JIFF are useful to us here:\n\n\\begin{itemize}\n\\item share(input): secret-shares input between all parties\n\\item share1.sadd(share2): secure addition of shares, which returns a share of results.\n\\item share1.ssub(share2): secure subtraction of shares, which returns a share of results.\n\\item share1.smult(share2, $<$op\\_id$>$, $<$truncate$>$): secure multiplication of shares, which returns a share of results.\n\nThe fixed-point extension supports the optional $<$truncate$>$ parameter, which determines whether the result of the multiplication is truncated to within the precision or not.\n\nIt is unsafe to use a non-truncated value in a subsequent multiplication or division without truncating it, as well as in an addition or subtraction where the two operands do not have the same truncation/precision.\n\\item share.cmult(n, $<$op\\_id$>$, $<$truncate$>$): secure multiplication of share by a constant, with a similar truncate optional parameter to the above.\n\\end{itemize}\n\n\\section{Basic Implementation}\nWe use the alternative MPC-friendly formulation from above. This alternative formulation is friendlier for MPC for the following reasons:\n\\begin{enumerate}\n    \\item It has only a single division by a public constant, furthermore the division is the very last operation. Since division by a public constant is reversible, we can have our MPC computation output the numerator only, and perform the division after the MPC concludes locally at every party. This avoids performing an MPC division which is one of the most expensive operations under MPC.\n    \\item The formulation contains $2 + n$ multiplications: (1) $n$ of them for squaring independent inputs, which can be performed locally by every party prior to sharing their input. (2) a multiplication by a public constant $n$ which is efficient to perform under MPC. (3) Squaring the average: this is the only secret multiplication that needs to be performed.\n    \\item Since we allow decimals as inputs, we must use the fixed-point extension of JIFF (as well as the negative number extension for negative inputs). This changes the performance behavior of the underlying primitives: namely, every multiplication by a secret requires an internal division to shift the decimal point to the left and truncate the portion of the result that is beyond the specified accuracy. However, we are in luck: the only such multiplication here is the one for squaring the average. The result of that multiplication is not used for any division (the division is in the clear!) or multiplication. So we can instruct JIFF to not shift the decimal point so that the expensive division is skipped. In order for the following subtraction operation to be meaningful, the decimal point on both operands need to be at the same location, we can shift the decimal point to the right for the minuend, which is a communication-free operation, making both operands consistent, and then truncate and shift to the left locally after the output of the MPC was revealed to the parties.\n\\end{enumerate}\n\nHence, our entire protocol operates as follows:\n\\paragraph{Local stage}\nEvery party $i$ shares both $X_i$ and $X_i^2$\n\n\\paragraph{MPC} The parties together compute and reveal the following quantity:\n$$\\Delta = (n \\otimes \\sum{X_i^2}) - (\\sum{X_i} \\otimes \\sum{X_i})$$\nWhere $\\otimes$ is the un-truncated fixed-point multiplication operator:\n$$ x \\otimes y = x \\times y \\times 10^{\\text{precision}}$$\n\n\\paragraph{Local stage} Every party receives revealed $\\Delta$ and computes:\n$$\\sigma = \\sqrt{\\frac{\\Delta}{n \\times 10^\\text{precision}}}$$\n\n\\subsection{Decimal Errors}\nAll the operations used through out the protocol, both under MPC and locally, except for $\\otimes$ are fixed point operations. They are guaranteed to satsify the following relation:\n$$x \\bigoplus y = \\text{truncate}(x \\oplus y, \\text{precision})$$\n\nWhere truncate floors to the nearest fixed-point number towards $-\\infty$. \\\\\n\n\\noindent In other words, they satisfy the following error bound:\n$$(x \\bigoplus y) - (x \\oplus y) < 10^\\text{precision}$$\n\n\\noindent Finally, the non-truncated multiplication is a perfectly accurate operation and introduces no error in-of-itself. Instead, it introduces an implicit error since it requires a division by an additional $10^\\text{precision}$ afterwards. Note that this additional division is the only operation added to our MPC protocol compared to the fixed-point non-MPC version, which does not perform that division and uses truncated fixed point multiplication instead. \\\\\n\n\\noindent This means that the overall error introduced by our protocol is smaller or equal to that introduced by the non-MPC fixed point version of it.\n\n\\subsection{Security} The only thing learned by any semi-honest party after the execution of our protocol is the standard deviation. The intermediate value revealed by our MPC computation is deducible from the standard deviation knowing the number of parties, which is public information. Nothing else is revealed.\n\n\\end{document}  \n", "meta": {"hexsha": "1d4ba7c0900282afb90d9488bcfb97d3671cabb2", "size": 6960, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "demos/standard-deviation/standdevprotocol.tex", "max_stars_repo_name": "zwang3583/jiff", "max_stars_repo_head_hexsha": "e22bb1b46fa2bf4fa464baec881a9553d65081b1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 169, "max_stars_repo_stars_event_min_datetime": "2017-11-16T14:09:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T20:42:10.000Z", "max_issues_repo_path": "demos/standard-deviation/standdevprotocol.tex", "max_issues_repo_name": "emilyji/jiff", "max_issues_repo_head_hexsha": "2fc9231b45a497196c9d636964810e8a2f23d705", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 110, "max_issues_repo_issues_event_min_datetime": "2017-11-06T04:25:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T13:18:26.000Z", "max_forks_repo_path": "demos/standard-deviation/standdevprotocol.tex", "max_forks_repo_name": "emilyji/jiff", "max_forks_repo_head_hexsha": "2fc9231b45a497196c9d636964810e8a2f23d705", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 38, "max_forks_repo_forks_event_min_datetime": "2017-12-05T03:59:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T21:48:42.000Z", "avg_line_length": 81.8823529412, "max_line_length": 1093, "alphanum_fraction": 0.758045977, "num_tokens": 1672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4372812078365008}}
{"text": "\\chapter{Homotopy images}\\label{chap:image}\n\nWe have observed in \\cref{eg:rcoeq} that the reflexive coequalizer of the pre-kernel of a map $f:A\\to X$ is the fiberwise join $\\join[X]{A}{A}$, i.e.~we have a reflexive coequalizer diagram\n\\begin{equation*}\n\\begin{tikzcd}\nA\\times_X A \\arrow[r,yshift=1ex] \\arrow[r,yshift=-1ex] & A \\arrow[l] \\arrow[r] & \\join[X]{A}{A}.\n\\end{tikzcd}\n\\end{equation*}\nIt can also be shown that the colimit of the 2-pre-kernel of a map $f:A\\to X$ is the triple fiberwise join $\\join[X]{A}{\\join[X]{A}{A}}$, i.e.~we have a colimiting \n\\begin{equation*}\n\\begin{tikzcd}\nA\\times_{X} A \\times_{X} A \\arrow[r,yshift=2ex] \\arrow[r] \\arrow[r,yshift=-2ex] & A \\times_X A \\arrow[l,yshift=1ex] \\arrow[l,yshift=-1ex] \\arrow[r,yshift=1ex] \\arrow[r,yshift=-1ex] & A \\arrow[l] \\arrow[r] & \\join[X]{A}{\\join[X]{A}{A}},\n\\end{tikzcd}\n\\end{equation*}\nalthough one has to take care to use the right amount of coherence data.\nThese results suggest that geometric realization of the Cech nerve of a map $f:A\\to X$, i.e.~the homotopy image of $f$, is the sequential colimit of the type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[r] & \\join[X]{A}{A} \\arrow[r] & \\join[X]{A}{(\\join[X]{A}{A})} \\arrow[r] & \\cdots\n\\end{tikzcd}\n\\end{equation*}\nand its sequential colimit. We do not have a way of presenting the Cech nerve of a map in type theory, due to the infinite coherence problem of presenting simplicial types in type theory. Nevertheless, we \\emph{can} analyze this type sequence and its colimit in homotopy type theory, since it is constructed entirely in terms of known operations. We will show in \\cref{thm:image} that for any map $f:A\\to X$, the infinite fiberwise join-power $\\join[X]{\\cdots}{\\join[X]{A}{\\join[X]{A}{A}}}$ is the image of $f$. We conclude that the image of a map always exists in univalent type theory with homotopy pushouts. We note that an earlier construction of the propositional truncation in a similar setting is due to van Doorn \\cite{vanDoorn2016}, and another one is due to Kraus \\cite{Kraus2016}. The present construction of the image of $f$ is called the join construction implies, as we show in \\cref{thm:image_small}, that the image of an essentially small type mapping into a locally small type is again essentially small. In particular, the image of a map from a small type into the universe is essentially small. This corollary should be viewed as a type theoretic replacement axiom. This fact has the important consequence that any connected component of the universe is essentially small. We also note that the join construction leads to new constructions of set quotients and of Rezk completions, see \\cite{joinconstruction}, where also a construction of the $n$-truncations is given as an application of the join construction.\n\n\\section{The universal property of the image}\n\\begin{defn}\\label{defn:image_up}\nConsider a commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=small]\nA \\arrow[rr,\"i\"] \\arrow[dr,swap,\"f\"] & & U \\arrow[dl,\"m\"] \\\\\n& X\n\\end{tikzcd}\n\\end{equation*}\nwith $I:f\\htpy m\\circ i$, and where $m$ is an embedding\\index{embedding}.\nWe say that $m$ has the \\define{universal property of the image of $f$}\\index{universal property!of the image|textit} if the map\n\\begin{equation*}\n(i,I)^\\ast : \\mathrm{hom}_X(m,m')\\to\\mathrm{hom}_X(f,m')\n\\end{equation*}\ndefined by $(i,I)^\\ast(h,H)\\defeq (h\\circ i,\\ct{I}{(i\\cdot H)})$,\nis an equivalence for every embedding $m':U'\\to X$. \n\\end{defn}\n\n\\begin{lem}\nFor any $f:A\\to X$ and any embedding\\index{embedding} $m:U\\to X$, the type $\\mathrm{hom}_X(f,m)$ is a proposition.\n\\end{lem}\n\n\\begin{proof}\nFrom \\cref{cor:fib_triangle} we obtain that the type $\\mathrm{hom}_X(f,m)$ is equivalent to the type\n\\begin{equation*}\n\\prd{x:X}\\fib{f}{x}\\to\\fib{m}{x},\n\\end{equation*}\nso it suffices to show that this is a proposition. \nRecall from \\cref{thm:prop_emb} that a map is an embedding if and only if its fibers are propositions.\nThus we see that the type $\\prd{x:X}\\fib{f}{x}\\to\\fib{m}{x}$ is a product of propositions, so it is a proposition by \\cref{thm:prop_pi}.\n\\end{proof}\n\n\\begin{cor}\\label{cor:image_up}\nConsider a commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=small]\nA \\arrow[rr,\"i\"] \\arrow[dr,swap,\"f\"] & & U \\arrow[dl,\"m\"] \\\\\n& X\n\\end{tikzcd}\n\\end{equation*}\nwith $I:f\\htpy m\\circ i$, and where $m$ is an embedding. Then $m$ satisfies the universal property of the image of $f$ if and only if the implication\n\\begin{equation*}\n\\mathrm{hom}_X(f,m')\\to\\mathrm{hom}_X(m,m')\n\\end{equation*}\nholds for every embedding $m':U'\\to X$. \n\\end{cor}\n\nRecall that embeddings into the unit type are just propositions.\nTherefore, the universal property of the image of the map $A\\to\\unit$ is a proposition $P$ satisfying the universal property of the propositional truncation:\n\n\\begin{defn}\nLet $A$ be a type, and let $P$ be a proposition that comes equipped with a map $f:A\\to P$. We say that $f:A\\to P$ satisfies the \\define{universal property of propositional truncation}\\index{universal property!of propositional truncation|textit} if for every proposition $Q$, the precomposition map\n\\begin{equation*}\n\\blank\\circ f:(P\\to Q)\\to (A\\to Q)\n\\end{equation*}\nis an equivalence.\n\\end{defn}\n\n\\section{The join construction}\n\\subsection{Step one: constructing the propositional truncation}\n\n\\begin{lem}\\label{lem:extend_join_prop}\nSuppose $f:A\\to P$, where $A$ is any type, and $P$ is a proposition.\nThen the map\n\\begin{equation*}\n(\\join{A}{B}\\to P)\\to (B\\to P)\n\\end{equation*}\ngiven by $h\\mapsto h\\circ \\inr$ is an equivalence, for any type $B$.\n\\end{lem}\n\n\\begin{proof}\nSince both types are propositions by \\cref{thm:prop_pi} it suffices to construct a map\n\\begin{equation*}\n(B\\to P)\\to (\\join{A}{B}\\to P).\n\\end{equation*}\nLet $g:B\\to P$. Then the square\n\\begin{equation*}\n\\begin{tikzcd}\nA\\times B \\arrow[r,\"\\proj 2\"] \\arrow[d,swap,\"\\proj 1\"] & B \\arrow[d,\"g\"] \\\\\nA \\arrow[r,swap,\"f\"] & P\n\\end{tikzcd}\n\\end{equation*}\ncommutes since $P$ is a proposition. Therefore we obtain a map $\\join{A}{B}\\to P$ by the universal property of the join.\n\\end{proof}\n\nThe idea of the construction of the propositional truncation is that if we are given a map $f:A\\to P$, where $P$ is a proposition, then it extends uniquely along $\\inr:A\\to \\join{A}{A}$ to a map $\\join{A}{A}\\to P$. This extension again extends uniquely along $\\inr:\\join{A}{A}\\to \\join{A}{(\\join{A}{A})}$ to a map $\\join{A}{(\\join{A}{A})}\\to P$ and so on, resulting in a diagram of the form\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[dr] \\arrow[r,\"\\inr\"] & \\join{A}{A} \\arrow[d,densely dotted] \\arrow[r,\"\\inr\"] & \\join{A}{(\\join{A}{A})} \\arrow[dl,densely dotted] \\arrow[r,\"\\inr\"] & \\cdots \\arrow[dll,densely dotted,bend left=10] \\\\\n& P\n\\end{tikzcd}\n\\end{equation*}\n\n\\begin{defn}\nThe \\define{join powers} $A^{\\ast n}$ of a type $X$ are defined by\n\\begin{align*}\nA^{\\ast 0} & \\defeq \\emptyt \\\\\nA^{\\ast 1} & \\defeq A \\\\\nA^{\\ast (n+1)} & \\defeq \\join{A}{A^{\\ast n}}.\n\\end{align*}\nFurthermore, we define $A^{\\ast\\infty}$ to be the sequential colimit of the type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA^{\\ast 0} \\arrow[r] & A^{\\ast 1} \\arrow[r,\"\\inr\"] & A^{\\ast 2} \\arrow[r,\"\\inr\"] & \\cdots.\n\\end{tikzcd}\n\\end{equation*}\n\\end{defn}\n\nOur goal is now to show that $A^{\\ast\\infty}$ is a proposition and satisfies the universal property of the propositional truncation.\n\n\\begin{lem}\nConsider a type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA_0 \\arrow[r,\"f_0\"] & A_1 \\arrow[r,\"f_1\"] & A_2 \\arrow[r,\"f_2\"] & \\cdots\n\\end{tikzcd}\n\\end{equation*}\nwith sequential colimit $A_\\infty$, and let $P$ be a proposition. Then the map\n\\begin{equation*}\n\\seqin^\\ast: (A_\\infty\\to P)\\to \\Big(\\prd{n:\\N}A_n\\to P\\Big)\n\\end{equation*}\ngiven by $h\\mapsto \\lam{n}(h\\circ \\seqin_n)$ is an equivalence. \n\\end{lem}\n\n\\begin{proof}\nBy the universal property of sequential colimits established in \\cref{thm:sequential_up} we obtain that $\\coconemap$ is an equivalence. Note that we have a commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=tiny]\n\\phantom{\\Big(\\prd{n:\\N}A_n\\to P\\Big).} & P^{A_\\infty} \\arrow[dl,swap,\"\\coconemap\"] \\arrow[dr,\"\\seqin^\\ast\"] & \\phantom{\\cocone(P)} \\\\\n\\cocone(P) \\arrow[rr,swap,\"\\proj 1\"] & & \\Big(\\prd{n:\\N}A_n\\to P\\Big)\n\\end{tikzcd}\n\\end{equation*}\nNote that for any $g:\\prd{n:\\N}A_n\\to P$ the type \n\\begin{equation*}\n\\prd{n:\\N} g_n\\htpy g_{n+1}\\circ f_n\n\\end{equation*}\nis a product of contractible types, since $P$ is a proposition. Therefore it is contractible by \\cref{thm:funext_wkfunext}, and it follows that the projection is an equivalence. We conclude by the 3-for-2 property of equivalences that $\\seqin^\\ast$ is an equivalence.\n\\end{proof}\n\n\\begin{lem}\\label{lem:infjp_up}\nLet $A$ be a type, and let $P$ be a proposition. Then the function\n\\begin{equation*}\n\\blank\\circ \\seqin_0: (A^{\\ast\\infty}\\to P)\\to (A\\to P)\n\\end{equation*}\nis an equivalence. \n\\end{lem}\n\n\\begin{proof}\nWe have the commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=0]\n& P^{A^{\\ast\\infty}} \\arrow[dl,swap,\"\\seqin^\\ast\"] \\arrow[dr,\"\\blank\\circ\\seqin_0\"] & \\phantom{\\Big(\\prd{n:\\N}A^{\\ast n} \\to P\\Big)} \\\\\n\\Big(\\prd{n:\\N}A^{\\ast n} \\to P\\Big) \\arrow[rr,swap,\"\\lam{h}h_0\"] & & P^A.\n\\end{tikzcd}\n\\end{equation*}\nTherefore it suffices to show that the bottom map is an equivalence. Since this is a map between propositions, it suffices to construct a map in the converse direction. Let $f:A\\to P$. We will construct a term of type\n\\begin{equation*}\n\\prd{n:\\N}A^{\\ast n} \\to P\n\\end{equation*}\nby induction on $n:\\N$. The base case is trivial. Given a map $g:A^{\\ast n}\\to P$, we obtain a map $g:A^{\\ast(n+1)}\\to P$ by \\cref{lem:extend_join_prop}.\n\\end{proof}\n\n\\begin{lem}\\label{lem:seqcolim_contr}\nConsider a type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA_0 \\arrow[r,\"f_0\"] & A_1 \\arrow[r,\"f_1\"] & A_2 \\arrow[r,\"f_2\"] & \\cdots\n\\end{tikzcd}\n\\end{equation*}\nand suppose that each $A_n$ is equipped with a base point $a_n:A_n$, and each $f_n$ is equipped with a homotopy $H_n:\\mathsf{const}_{a_{n+1}}\\htpy f_n$. Then the sequential colimit $A_\\infty$ is contractible.\\qed\n\\end{lem}\n\n\\begin{lem}\\label{lem:isprop_infjp}\nThe type $A^{\\ast\\infty}$ is a proposition for any type $A$.\n\\end{lem}\n\n\\begin{proof}\nBy \\cref{lem:prop_char} it suffices to show that $A^{\\ast\\infty}\\to \\iscontr(A^{\\ast\\infty})$, and by \\cref{lem:infjp_up} it suffices to show that\n\\begin{equation*}\nA\\to \\iscontr(A^{\\ast\\infty}),\n\\end{equation*}\nbecause $\\iscontr(A^{\\ast\\infty})$ is a proposition. \n\nLet $x:A$. To see that $A^{\\ast\\infty}$ is contractible it suffices by \\cref{lem:seqcolim_contr} to show that $\\inr:A^{\\ast n}\\to A^{\\ast(n+1)}$ is homotopic to the constant function $\\const_{\\inl(x)}$. However, we get a homotopy $\\const_{\\inl(x)}\\htpy \\inr$ immediately from the path constructor $\\glue$.  \n\\end{proof}\n\n\\begin{thm}\nFor any type $A:\\UU$ there is a proposition $\\brck{A}:\\UU$ that comes equipped with a map $\\eta:A\\to \\brck{A}$, and satisfies the universal property of propositional truncation.\n\\end{thm}\n\n\\begin{proof}\nLet $A$ be a type. Then we define $\\brck{A}\\defeq A^{\\ast\\infty}$, and we define $\\eta\\defeq \\seqin_0:A\\to A^{\\ast\\infty}$. Then $\\brck{A}$ is a proposition by \\cref{lem:isprop_infjp}, and $\\eta:A\\to \\brck{A}$ satisfies the universal property of propositional truncation by \\cref{lem:infjp_up}.\n\\end{proof}\n\n\\subsection{Step two: constructing the image of a map}\\label{sec:join_stage2}\nFollowing Definition 7.6.3 of \\cite{hottbook}, we recall that the image of a map $f:A\\to X$ can be defined using the propositional truncation:\n\\begin{defn}\nFor any map $f:A\\to X$ we define the \\define{image}\\index{image|textbf} of $f$ to be the type\n\\begin{equation*}\n\\im(f) \\defeq \\sm{x:X}\\brck{\\fib{f}{x}}\n\\end{equation*}\nand we define the \\define{image inclusion} to be the projection $\\proj 1 :\\im(f)\\to X$. \n\\end{defn}\nHowever, the construction of the fiberwise join in \\cref{defn:fib_join} suggests that we can also define the image of $f$ as the infinite join power $f^{\\ast\\infty}$, where we repeatedly take the fiberwise join of $f$ with itself. Our reason for defining the image in this way is twofold: \n\\begin{itemize}\n\\item We use this construction to show that the image of a map $f:A\\to B$ from an essentially small type $A$ into a locally small type $B$ is again essentially small.\n\\item Some interesting types, such as the real and complex projective spaces, appear in specific instances of this construction.\n\\end{itemize}\n\n\\begin{lem}\nConsider a map $f:A\\to X$, an embedding $m:U\\to X$, and $h:\\mathrm{hom}_X(f,m)$. Then the map\n\\begin{equation*}\n\\mathrm{hom}_X(\\join{f}{g},m)\\to \\mathrm{hom}_X(g,m)\n\\end{equation*}\nis an equivalence for any $g:B\\to X$.\n\\end{lem}\n\n\\begin{proof}\nNote that both types are propositions, so any equivalence can be used to prove the claim. Thus, we simply calculate\n\\begin{align*}\n\\mathrm{hom}_X(\\join{f}{g},m) & \\eqvsym \\prd{x:X}\\fib{\\join{f}{g}}{x}\\to \\fib{m}{x} \\\\\n& \\eqvsym \\prd{x:X}\\join{\\fib{f}{x}}{\\fib{g}{x}}\\to\\fib{m}{x} \\\\\n& \\eqvsym \\prd{x:X}\\fib{g}{x}\\to\\fib{m}{x} \\\\\n& \\eqvsym \\mathrm{hom}_X(g,m).\n\\end{align*}\nThe first equivalence holds by \\cref{cor:fib_triangle}; the second equivalence holds by \\cref{defn:join-fiber}; the third equivalence holds by \\cref{lem:extend_join_prop}; the last equivalence again holds by \\cref{cor:fib_triangle}.\n\\end{proof}\n\nFor the construction of the image of $f:A\\to X$ we observe that if we are given an embedding $m:U\\to X$ and a map $(i,I):\\mathrm{hom}_X(f,m)$, then $(i,I)$ extends uniquely along $\\inr:A\\to \\join[X]{A}{A}$ to a map $\\mathrm{hom}_X(\\join{f}{f},m)$. This extension again extends uniquely along $\\inr:\\join[X]{A}{A}\\to \\join[X]{A}{(\\join[X]{A}{A})}$ to a map $\\mathrm{hom}_X(\\join{f}{(\\join{f}{f})},m)$ and so on, resulting in a diagram of the form\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[dr] \\arrow[r,\"\\inr\"] & \\join[X]{A}{A} \\arrow[d,densely dotted] \\arrow[r,\"\\inr\"] & \\join[X]{A}{(\\join[X]{A}{A})} \\arrow[dl,densely dotted] \\arrow[r,\"\\inr\"] & \\cdots \\arrow[dll,densely dotted,bend left=10] \\\\\n& U\n\\end{tikzcd}\n\\end{equation*}\n\n\\begin{defn}\nSuppose $f:A\\to X$ is a map. Then we define the \\define{fiberwise join powers} \n\\begin{equation*}\nf^{\\ast n}\\defeq A_X^{\\ast n}\\to X.\n\\end{equation*}\n\\end{defn}\n\n\\begin{proof}[Construction]\nNote that the operation $(B,g)\\mapsto (\\join[X]{A}{B},\\join{f}{g})$ defines an endomorphism on the type\n\\begin{equation*}\n\\sm{B:\\UU}B\\to X.\n\\end{equation*}\nWe also have $(\\emptyt,\\ind{\\emptyt})$ and $(A,f)$ of this type. For $n\\geq 1$ we define\n\\begin{align*}\nA_X^{\\ast (n+1)} & \\defeq \\join[X]{A}{A_X^{\\ast n}} \\\\\nf^{\\ast (n+1)} & \\defeq \\join{f}{f^{\\ast n}}.\\qedhere\n\\end{align*}\n\\end{proof}\n\n\\begin{defn}\nWe define $A_X^{\\ast\\infty}$ to be the sequential colimit of the type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA_X^{\\ast 0} \\arrow[r] & A_X^{\\ast 1} \\arrow[r,\"\\inr\"] & A_X^{\\ast 2} \\arrow[r,\"\\inr\"] & \\cdots.\n\\end{tikzcd}\n\\end{equation*}\nSince we have a cocone\n\\begin{equation*}\n\\begin{tikzcd}\nA_X^{\\ast 0} \\arrow[r] \\arrow[dr,swap,\"f^{\\ast 0}\" near start] & A_X^{\\ast 1} \\arrow[r,\"\\inr\"] \\arrow[d,swap,\"f^{\\ast 1}\" near start] & A_X^{\\ast 2} \\arrow[r,\"\\inr\"] \\arrow[dl,swap,\"f^{\\ast 2}\" xshift=1ex] & \\cdots \\arrow[dll,bend left=10] \\\\\n& X\n\\end{tikzcd}\n\\end{equation*}\nwe also obtain a map $f^{\\ast\\infty}:A_X^{\\ast\\infty}\\to X$ by the universal property of $A_X^{\\ast\\infty}$. \n\\end{defn}\n\n\\begin{lem}\\label{lem:finfjp_up}\nLet $f:A\\to X$ be a map, and let $m:U\\to X$ be an embedding. Then the function\n\\begin{equation*}\n\\blank\\circ \\seqin_0: \\mathrm{hom}_X(f^{\\ast\\infty},m)\\to \\mathrm{hom}_X(f,m)\n\\end{equation*}\nis an equivalence. \n\\end{lem}\n\n\\begin{thm}\\label{thm:image}\nFor any map $f:A\\to X$, the map $f^{\\ast\\infty}:A_X^{\\ast\\infty}\\to X$ is an embedding that satisfies the universal property of the image inclusion of $f$.\n\\end{thm}\n\n\\subsection{Step three: establishing the smallness of the image}\n\nRecall from \\cref{defn:ess_small} that a type is said to be locally small if its identity types are equivalent to small types.\n\n\\begin{lem}\nConsider a commuting square\n\\begin{equation*}\n\\begin{tikzcd}\nA \\arrow[r] \\arrow[d] & B \\arrow[d] \\\\\nC \\arrow[r] & D.\n\\end{tikzcd}\n\\end{equation*}\n\\begin{enumerate}\n\\item If the square is cartesian, $B$ and $C$ are essentially small, and $D$ is locally small, then $A$ is essentially small.\n\\item If the square is cocartesian, and $A$, $B$, and $C$ are essentially small, then $D$ is essentially small. \n\\end{enumerate}\n\\end{lem}\n\n\\begin{cor}\nSuppose $f:A\\to X$ and $g:B\\to X$ are maps from essentially small types $A$ and $B$, respectively, to a locally small type $X$. Then $A\\times_X B$ is again essentially small. \n\\end{cor}\n\n\\begin{lem}\nConsider a type sequence\n\\begin{equation*}\n\\begin{tikzcd}\nA_0 \\arrow[r,\"f_0\"] & A_1 \\arrow[r,\"f_1\"] & A_2 \\arrow[r,\"f_2\"] & \\cdots\n\\end{tikzcd}\n\\end{equation*}\nwhere each $A_n$ is essentially small. Then its sequential colimit is again essentially small. \n\\end{lem}\n\n\\begin{thm}\\label{thm:image_small}\nFor any map $f:A\\to X$ from a small type $A$ into a locally small type $X$, the image $\\im(f)$ is an essentially small type.\n\\end{thm}\n\nRecall that in set theory, the replacement axiom asserts that for any family of sets $\\{X_i\\}_{i\\in I}$ indexed by a set $I$, there is a set $X[I]$ consisting of precisely those sets $x$ for which there exists an $i\\in I$ such that $x\\in X_i$. In other words: the image of a set-indexed family of sets is again a set. Without the replacement axiom, $X[I]$ would be a class. In the following corollary we establish a type-theoretic analogue of the replacement axiom: the image of a family of small types indexed by a small type is again (essentially) small.\n\n\\begin{cor}\\label{cor:im_small}\nFor any small type family $B:A\\to\\UU$, where $A$ is small, the image $\\im(B)$ is essentially small. We call $\\im(B)$ the \\define{univalent completion} of $B$. \n\\end{cor}\n\n\\endinput\n\n\\section{Set quotients}\\label{sec:set-quotients}\n\n\\subsection{Sets in homotopy type theory}\n\\begin{defn}\nA type $A$ is said to be a \\define{set} if there is a term of type\n\\begin{equation*}\n\\isset(A)\\defeq \\prd{x,y:A}\\isprop(\\id{x}{y}).\n\\end{equation*}\n\\end{defn}\n\n\\begin{lem}\\label{lem:prop_to_id}\nLet $A$ be a type, and let $(R,\\rho):\\mathsf{rRel}(A)$ be a reflexive relation on $A$ such that $R(x,y)$ is a proposition for each $x,y:A$. Then any fiberwise map\n\\begin{equation*}\n\\prd{x,y:A}R(x,y)\\to (\\id{x}{y})\n\\end{equation*}\nis a fiberwise equivalence. Consequently, if there is such a fiberwise map, then $A$ is a set.\n\\end{lem}\n\n\\begin{proof}\nLet $f:\\prd{x,y:A}R(x,y)\\to(\\id{x}{y})$. \nSince $R$ is assumed to be reflexive, we also have a fiberwise transformation\n\\begin{equation*}\n\\ind{x{=}}(\\rho(x)):\\prd{y:A}(\\id{x}{y})\\to R(x,y).\n\\end{equation*}\nSince each $R(x,y)$ is assumed to be a proposition, it therefore follows that each $R(x,y)$ is a retract of $\\id{x}{y}$. We conclude by \\autoref{cor:id_fundamental_retr} that for each $x,y:A$, the map $f(x,y):R(x,y)\\to(\\id{x}{y})$ must be an equivalence.\n\nNow it also follows that $A$ is a set, since its identity types are (equivalent to) propositions.\n\\end{proof}\n\n\\begin{eg}\nOne can apply \\cref{lem:prop_to_id} using the \\define{observational equality} $\\mathrm{Eq}_\\N:\\N\\to (\\N\\to\\UU)$ given by\n\\begin{align*}\n\\mathrm{Eq}_\\N(0,0) & \\defeq \\unit & \\mathrm{Eq}_\\N(\\mathsf{succ}(n),0) & \\defeq \\emptyt \\\\\n\\mathrm{Eq}_\\N(0,\\mathsf{succ}(m)) & \\defeq \\emptyt & \\mathrm{Eq}_\\N(\\mathsf{succ}(n),\\mathsf{succ}(m)) & \\defeq \\mathrm{Eq}_\\N(n,m)\n\\end{align*}\nto show that $\\N$ is a set. A routine induction argument shows that $\\mathrm{Eq}_\\N$ implies identity.\n\\end{eg}\n\n\\subsection{Equivalence relations}\n\n\\begin{defn}\\label{defn:eq_rel}\nLet $R:A\\to (A\\to\\prop)$ be a binary relation valued in the propositions. We say that $R$ is an \\define{($0$-)equivalence relation}\\index{equivalence relation|textbf}\\index{0-equivalence relation|see {equivalence relation}} if $R$ comes equipped with\n\\begin{align*}\n\\rho & : \\prd{x:A}R(x,x) \\\\\n\\sigma & : \\prd{x,y:A} R(x,y)\\to R(y,x) \\\\\n\\tau & : \\prd{x,y,z:A} R(x,y)\\to (R(y,z)\\to R(x,z)).\n\\end{align*}\nGiven an equivalence relation $R:A\\to (A\\to\\prop)$, the \\define{equivalence class}\\index{equivalence class|textbf} $[x]_R:A\\to\\prop$ of $x:A$ is defined to be\n\\begin{equation*}\n[x]_R\\defeq R(x).\n\\end{equation*}\n\\end{defn}\n\n\\begin{defn}\nLet $R:A\\to (A\\to\\prop)$ be a $0$-equivalence relation. \nWe define for any $x,y:A$ a map\\index{class_eq@{$\\mathsf{eq\\usc{}class}$}|textbf}\n\\begin{equation*}\n\\mathsf{eq\\usc{}class}:R(x,y)\\to ([x]_R=[y]_R).\n\\end{equation*}\n\\end{defn}\n\n\\begin{proof}[Construction.]\nLet $r:R(x,y)$. By function extensionality, the identity type $R(x)=R(y)$ is equivalent to the type\n\\begin{equation*}\n\\prd{z:A}R(x,z)=R(y,z).\n\\end{equation*}\nLet $z:A$. By the univalence axiom, the type $R(x,z)=R(y,z)$ is equivalent to the type\n\\begin{equation*}\n\\eqv{R(x,z)}{R(y,z)}.\n\\end{equation*}\nWe have the map $\\tau_{y,x,z}(\\sigma(r)):R(x,z)\\to R(y,z)$. Since this is a map between propositions, we only have to construct a map in the converse direction to show that it is an equivalence. The map in the converse direction is just $\\tau_{x,y,z}(r):R(y,z)\\to R(x,z)$. \n\\end{proof}\n\n\\begin{prp}\\label{thm:equivalence_classes}\nLet $R:A\\to (A\\to\\prop)$ be a $0$-equivalence relation. \nThen for any $x,y:A$ the map\n\\begin{equation*}\n\\mathsf{eq\\usc{}class} : R(x,y)\\to ([x]_R=[y]_R)\n\\end{equation*}\nis an equivalence.\n\\end{prp}\n\n\\begin{proof}\nBy the 3-for-2 property of equivalences, it suffices to show that the map\n\\begin{equation*}\n\\lam{r}{z}\\tau_{y,x,z}(\\sigma(r)) : R(x,y)\\to \\prd{z:A} \\eqv{R(x,z)}{R(y,z)}\n\\end{equation*}\nis an equivalence. Since this is a map between propositions, it suffices to construct a map of type\n\\begin{equation*}\n\\Big(\\prd{z:A} \\eqv{R(x,z)}{R(y,z)}\\Big)\\to R(x,y).\n\\end{equation*}\nThis map is simply $\\lam{f} \\sigma_{y,x}(f_x(\\rho(x)))$. \n\\end{proof}\n\n\\subsection{The universal property of set quotients}\n\n\\begin{defn}\nLet $R:A\\to (A\\to \\prop)$ be an equivalence relation\\index{equivalence relation|textit}, for $A:\\UU$, and consider a map $q:A\\to B$ where the type $B$ is a set, for which we have\n\\begin{equation*}\n\\prd{x,y:A}R(x,y)\\to q(x)=q(y).\n\\end{equation*}\nWe will define a map\n\\begin{equation*}\n\\quotientrestr:(B\\to X) \\to \\Big(\\sm{f:A\\to X}\\prd{x,y:A}R(x,y)\\to (f(x)=f(y))\\Big).\n\\end{equation*}\n\\end{defn}\n\n\\begin{proof}[Construction]\nLet $h:B\\to X$. Then we have $h\\circ q : A\\to X$, so it remains to show that\n\\begin{equation*}\n\\prd{x,y:A}R(x,y)\\to (h(q(x))=h(q(y)))\n\\end{equation*}\nConsider $x,y:A$ which are related by $R$. Then we have an identification $p:q(x)=q(y)$, so it follows that $\\ap{h}{p}:h(q(x))=h(q(y))$.  \n\\end{proof}\n\n\\begin{defn}\nLet $R:A\\to (A\\to \\prop)$ be an equivalence relation\\index{equivalence relation|textit}, for $A:\\UU$, and consider a map $q:A\\to B$ satisfying\n\\begin{equation*}\n\\prd{x,y:A}R(x,y)\\to q(x)=q(y),\n\\end{equation*}\nwhere the type $B$ is a set. We say that the map $q:A\\to B$ satisfies the universal property of the \\define{set quotient}\\index{set quotient}\\index{universal property!of set quotients|textit} $A/R$ if for any set $X$ the map\n\\begin{equation*}\n\\quotientrestr : (B\\to X) \\to \\Big(\\sm{f:A\\to X}\\prd{x,y:A}R(x,y)\\to (f(x)=f(y))\\Big)\n\\end{equation*}\nis an equivalence.\n\\end{defn}\n\n\\begin{lem}\nLet $R:A\\to (A\\to \\prop)$ be an equivalence relation\\index{equivalence relation|textit}, for $A:\\UU$, and consider a commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=tiny]\nA \\arrow[rr,\"q\"] \\arrow[dr,swap,\"R\"] & & U \\arrow[dl,\"m\"] \\\\\n& \\prop^A\n\\end{tikzcd}\n\\end{equation*}\nwith $H:R\\htpy m\\circ q$, where $m$ is an embedding. Then we have\n\\begin{equation*}\n\\prd{x,y:A}R(x,y)\\to (q(x)=q(y)).\n\\end{equation*}\n\\end{lem}\n\n\\begin{prp}\\label{thm:quotient_up}\nLet $R:A\\to (A\\to \\prop)$ be an equivalence relation\\index{equivalence relation|textit}, for $A:\\UU$, and consider a commuting triangle\n\\begin{equation*}\n\\begin{tikzcd}[column sep=tiny]\nA \\arrow[rr,\"q\"] \\arrow[dr,swap,\"R\"] & & U \\arrow[dl,\"m\"] \\\\\n& \\prop^A\n\\end{tikzcd}\n\\end{equation*}\nwith $H:R\\htpy m\\circ q$, where $m$ is an embedding. Then the following are equivalent:\n\\begin{enumerate}\n\\item The embedding $m:U\\to \\prop^A$ satisfies the universal property of the image of $R$.\n\\item The map $q:A\\to U$ satisfies the universal property of the set quotient $A/R$.\n\\end{enumerate}\n\\end{prp}\n\n\\begin{proof}\nSuppose $m:U\\to \\prop^A$ satisfies the universal property of the image of $R$. Then it follows by \\cref{thm:surjective}\\marginnote{Need lemma that states that universal property of image inclusion iff the map into it is surjective} that the map $q:A\\to U$ is surjective. Our goal is to prove that $U$ satisfies the universal property of the set quotient $A/R$. \\marginnote{Proof incomplete}\n\\end{proof}\n\n\\begin{rmk}\n\\cref{thm:quotient_up} suggests that we can define the quotient of an equivalence relation $R$ on a type $A$ as the image of a map. However, the type $\\prop^A$ of which the quotient is a subtype is not a small type, even if $A$ is a small type.\nTherefore it is not clear that the quotient $A/R$ is essentially small\\index{essentially small}, as it should be. Luckily, our construction of the image of a map allows us to show that the image is indeed essentially small, using the fact that $\\prop^A$ is locally small\\index{locally small}.\n\\end{rmk}\n\n\\section{The Rezk completion}\n\nWe recall from \\cite{AhrensKapulkinShulman} that a pre-category $\\mathcal{A}$ consists of a type $A$ of objects, a $\\set$-valued binary relation $\\mathsf{hom}:A\\to A\\to\\set$ of morphisms, equipped with identity morphisms\n\\begin{equation*}\n\\mathsf{id} : \\prd{x:A} \\mathsf{hom}(x,x)\n\\end{equation*}\nand a composition operation\n\\begin{equation*}\n\\mathsf{comp} : \\prd{x,y,z:A} \\mathsf{hom}(y,z)\\to \\mathsf{hom}(x,y)\\to \\mathsf{hom}(x,z),\n\\end{equation*}\nwhich is associative and satisfies the unit laws. The isomorphisms $x \\cong y$ from $x$ to $y$ in a pre-category are defined in the expected way, and the pre-category $\\mathcal{A}$ is said to be \\define{Rezk-complete} if the canonical map\n\\begin{equation*}\n\\prd{x,y:A} (x=y)\\to (x\\cong y)\n\\end{equation*}\nis an equivalence. Rezk-complete pre-categories are also called \\define{categories}. By the univalence axiom, the pre-category $\\mathbf{Set}$ of small sets is Rezk-complete. \n\nA pre-category is said to be \\define{(essentially) small} if its types of objects and morphisms are (essentially) small, and a pre-category is said to be \\define{locally small} if its hom-types are essentially small. Thus, the category $\\mathbf{Set}$ is locally small. \n\n\\begin{defn}\nLet $\\mathcal{A}$ be a pre-category. A functor $\\mathcal{F}:\\mathcal{A}\\to\\mathcal{B}$ into a (Rezk-complete) category $\\mathcal{B}$ is said to be a \\define{Rezk-completion} if the pre-composition map\n\\begin{equation*}\n\\mathsf{Functor}(\\mathcal{B},\\mathcal{C})\\to\\mathsf{Functor}(\\mathcal{A},\\mathcal{C})\n\\end{equation*}\nis an equivalence, for every (Rezk-complete) category $\\mathcal{C}$. \n\\end{defn}\n\n\\begin{thm}\\label{cor:rezkcompletion}\nThe Rezk completion $\\hat{A}$ of any small pre-category $A$ can be constructed in any \nunivalent universe that is closed under graph quotients,\nand $\\hat{A}$ is again a small category. \n\\end{thm}\n\n\\begin{proof}\nIn the first proof of Theorem 9.9.5 of \\cite{hottbook}, the Rezk completion of\na precategory $A$ is constructed as the image of the action on objects of the\nYoneda embedding $\\mathbf{y}:A\\to\\mathbf{Set}^{\\op{A}}$.\n\nThe hom-set $\\mathbf{Set}^{\\op{A}}(F,G)$ is the type of natural transformations\nfrom $F$ to $G$. It is clear from Definition 9.9.2 of \\cite{hottbook}, that the\ntype $\\mathbf{Set}^{\\op{A}}(F,G)$ is in $\\UU$ for any two presheaves $F$ and $G$\non $A$. In particular, the type $F\\cong G$ of isomorphisms from $F$ to $G$\nis small for any two presheaves on $A$.\n\nSince $\\mathbf{Set}$ is a category, it follows from Theorem 9.2.5 of\n\\cite{hottbook} that the presheaf pre-category $\\mathbf{Set}^{\\op{A}}$ is a category.\nSince the type of isomorphisms between any two objects is\nsmall, it follows that the type of objects of\n$\\mathbf{Set}^{\\op{A}}$ is locally small. \n\nHence we can use \\autoref{thm:modified-join} to construct the image of the\naction on objects of the Yoneda-embedding. The image constructed in this way\nis of course equivalent to the type $\\hat{A}_0$ defined in the first proof of\nTheorem 9.9.5. Hence the arguments presented in the rest of that proof apply\nas well to our construction of the image. We therefore conclude that the Rezk completion\nof any small precategory is a small category.\n\\end{proof}\n\n\\begin{eg}\\label{eg:emspaces}\nAny group $G$ can be seen as a pre-category $\\mathcal{G}$ with a single object and the group $G$ as morphisms. The Rezk-completion of $\\mathcal{G}$ is the Eilenberg-Mac Lane space $K(G,1)$. Thus we conclude that any univalent universe closed under pushouts contains the Eilenberg-Mac Lane spaces $K(G,1)$ for any small group $G$. \n\\end{eg}\n", "meta": {"hexsha": "d23a326a21fba88384bbe6a68a3860690ca085d2", "size": 28837, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "image.tex", "max_stars_repo_name": "EgbertRijke/dissertation", "max_stars_repo_head_hexsha": "f2c087ba8983205d3dd336bbc194be5b7218c2c5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-07-06T10:37:12.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-06T10:37:12.000Z", "max_issues_repo_path": "image.tex", "max_issues_repo_name": "EgbertRijke/dissertation", "max_issues_repo_head_hexsha": "f2c087ba8983205d3dd336bbc194be5b7218c2c5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "image.tex", "max_forks_repo_name": "EgbertRijke/dissertation", "max_forks_repo_head_hexsha": "f2c087ba8983205d3dd336bbc194be5b7218c2c5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.9774696707, "max_line_length": 1531, "alphanum_fraction": 0.7011478309, "num_tokens": 9937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.682573734412324, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43728120783650076}}
{"text": "\\hypertarget{meshgen}{%\n\\section{Meshgen}\\label{meshgen}}\n\nThe \\texttt{meshgen} module is used to create \\texttt{Mesh} objects\ncorresponding to a specified domain. It provides the \\texttt{MeshGen}\nclass to perform the meshing, which are created with the following\narguments:\n\n\\begin{lstlisting}\nMeshGen(domain, boundingbox)\n\\end{lstlisting}\n\nDomains are specified by a scalar function that is positive in the\nregion to be meshed and locally smooth. For example, to mesh the unit\ndisk:\n\n\\begin{lstlisting}\nvar dom = fn (x) -(x[0]^2+x[1]^2-1)\n\\end{lstlisting}\n\nA \\texttt{MeshGen} object is then created and then used to build the\n\\texttt{Mesh} like this:\n\n\\begin{lstlisting}\nvar mg = MeshGen(dom, [-1..1:0.2, -1..1:0.2])\nvar m = mg.build()\n\\end{lstlisting}\n\nA bounding box for the mesh must be specified as a \\texttt{List} of\n\\texttt{Range} objects, one for each dimension. The increment on each\n\\texttt{Range} gives an approximate scale for the size of elements\ngenerated.\n\nTo facilitate convenient creation of domains, a \\texttt{Domain} class is\nprovided that provides set operations \\texttt{union},\n\\texttt{intersection} and \\texttt{difference}.\n\n\\texttt{MeshGen} accepts a number of optional arguments:\n\n\\begin{itemize}\n\n\\item\n  \\texttt{weight} A scalar weight function that controls mesh density.\n\\item\n  \\texttt{quiet} Set to \\texttt{true} to suppress \\texttt{MeshGen}\n  output.\n\\item\n  \\texttt{method} a list of options that controls the method used.\n\\end{itemize}\n\nSome method choices that are available include:\n\n\\begin{itemize}\n\n\\item\n  \\texttt{\"FixedStepSize\"} Use a fixed step size in optimization.\n\\item\n  \\texttt{\"StartGrid\"} Start from a regular grid of points (the\n  default).\n\\item\n  \\texttt{\"StartRandom\"} Start from a randomly generated collection of\n  points.\n\\end{itemize}\n\nThere are also a number of properties of a \\texttt{MeshGen} object that\ncan be set prior to calling \\texttt{build} to control the operation of\nthe mesh generation:\n\n\\begin{itemize}\n\n\\item\n  \\texttt{stepsize}, \\texttt{steplimit} Stepsize used internally by the\n  \\texttt{Optimizer}\n\\item\n  \\texttt{fscale} an internal ``pressure''\n\\item\n  \\texttt{ttol} how far the vertices are allowed to move before\n  retriangulation\n\\item\n  \\texttt{etol} energy tolerance for optimization problem\n\\end{itemize}\n\n\\texttt{MeshGen} picks default values that cover a reasonable range of\nuses.\n\n\\hypertarget{domain}{%\n\\section{Domain}\\label{domain}}\n\nThe \\texttt{Domain} class is used to conveniently build a domain by\ncomposing simpler elements.\n\nCreate a \\texttt{Domain} from a scalar function that is positive in the\nregion of interest:\n\n\\begin{lstlisting}\nvar dom = Domain(fn (x) -(x[0]^2+x[1]^2-1))\n\\end{lstlisting}\n\nYou can pass it to \\texttt{MeshGen} to specify the region to mesh:\n\n\\begin{lstlisting}\nvar mg = MeshGen(dom, [-1..1:0.2, -1..1:0.2])\n\\end{lstlisting}\n\nYou can combine \\texttt{Domain} objects using set operations\n\\texttt{union}, \\texttt{intersection} and \\texttt{difference}:\n\n\\begin{lstlisting}\nvar a = CircularDomain(Matrix([-0.5,0]), 1)\nvar b = CircularDomain(Matrix([0.5,0]), 1)\nvar c = CircularDomain(Matrix([0,0]), 0.3)\nvar dom = a.union(b).difference(c)\n\\end{lstlisting}\n\n\\hypertarget{circulardomain}{%\n\\section{CircularDomain}\\label{circulardomain}}\n\nConveniently constructs a \\texttt{Domain} object correspondiong to a\ndisk. Requires the position of the center and a radius as arguments.\n\nCreate a domain corresponding to the unit disk:\n\n\\begin{lstlisting}\nvar c = CircularDomain([0,0], 1)\n\\end{lstlisting}\n\n\\hypertarget{halfspacedomain}{%\n\\section{HalfSpaceDomain}\\label{halfspacedomain}}\n\nConveniently constructs a \\texttt{Domain} object correspondiong to a\nhalf space defined by a plane at \\texttt{x0} and a normal \\texttt{n}:\n\n\\begin{lstlisting}\nvar hs = HalfSpaceDomain(x0, n)\n\\end{lstlisting}\n\nNote \\texttt{n} is an ``outward'' normal, so points into the\n\\emph{excluded} region.\n\nHalf space corresponding to the allowed region \\texttt{x\\textless{}0}:\n\n\\begin{lstlisting}\nvar hs = HalfSpaceDomain(Matrix([0,0,0]), Matrix([1,0,0]))\n\\end{lstlisting}\n\nNote that \\texttt{HalfSpaceDomain}s cannot be meshed directly as they\ncorrespond to an infinite region. They are useful, however, for\ncombining with other domains.\n\nCreate half a disk by cutting a \\texttt{HalfSpaceDomain} from a\n\\texttt{CircularDomain}:\n\n\\begin{lstlisting}\nvar c = CircularDomain([0,0], 1)\nvar hs = HalfSpaceDomain(Matrix([0,0]), Matrix([-1,0]))\nvar dom = c.difference(hs) \nvar mg = MeshGen(dom, [-1..1:0.2, -1..1:0.2], quiet=false)\nvar m = mg.build()\n\\end{lstlisting}\n\n\\hypertarget{mshgndim}{%\n\\section{MshGnDim}\\label{mshgndim}}\n\nThe \\texttt{MeshGen} module currently supports 2 and 3 dimensional\nmeshes. Higher dimensional meshing will be available in a future\nrelease; please contact the developer if you are interested in this\nfunctionality.\n", "meta": {"hexsha": "654d410cef7f52c65af184790cfd74148cc266ad", "size": 4821, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/src/Reference/meshgen.tex", "max_stars_repo_name": "mattsep/morpho", "max_stars_repo_head_hexsha": "50bb935653c0675b81e9f2d78573cf117971a147", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manual/src/Reference/meshgen.tex", "max_issues_repo_name": "mattsep/morpho", "max_issues_repo_head_hexsha": "50bb935653c0675b81e9f2d78573cf117971a147", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/src/Reference/meshgen.tex", "max_forks_repo_name": "mattsep/morpho", "max_forks_repo_head_hexsha": "50bb935653c0675b81e9f2d78573cf117971a147", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6964285714, "max_line_length": 72, "alphanum_fraction": 0.7527483924, "num_tokens": 1415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6825737279551493, "lm_q1q2_score": 0.43728120369980306}}
{"text": "\\iffalse\nThis is a big-ish template that I've been using for years now.\nA lot of the includes are redundant, so if you're reading this and have no idea why\nI've included most things, don't worry - I don't either.\nAlso, compiling this (to PDF, for instance) relies on CSS files present on my\ncomputer (coming from the packages). So it might not look as nice if you\ndo it on yours (especially if you don't have all the packages).\n\nYa'll've been warned.\n\\fi\n\n\\documentclass{article}\n\n    \\usepackage{tikz}\n    \\usetikzlibrary{%\n        decorations.pathreplacing,%\n        decorations.pathmorphing%\n    }\n    \\usepackage{subcaption}\n    \\usepackage{todonotes}\n    \\usepackage{amsmath}\n    \\usepackage{amssymb}\n    \\usepackage{color}\n    \\usepackage{bm}\n    % \\usepackage[dvipsnames]{xcolor}\n    \\usepackage{graphicx,float}\n    \\usepackage{caption}\n    \\usepackage{float}\n    \\usepackage[hidelinks]{hyperref}\n    \\usepackage{enumitem}\n    \\usepackage[bottom]{footmisc}\n    \\usepackage{flexisym}\n    \\usepackage{cancel}\n    \\usepackage[braket]{qcircuit}\n    \\usepackage[margin=.8in, tmargin=.3in]{geometry}\n    \\usepackage{mathtools}  %\n    \\renewcommand{\\baselinestretch}{1.2}\n    \\newcommand{\\eps}{\\epsilon}\n\n\n    \\newcommand{\\vq}{\\mathbf{q}}\n    \\newcommand{\\vqdot}{\\mathbf{\\dot{q}}}\n    \\newcommand{\\vqddot}{\\mathbf{\\ddot{q}}}\n    \\newcommand{\\vx}{\\mathbf{x}}\n    \\newcommand{\\vy}{\\mathbf{y}}\n    \\newcommand{\\vystar}{\\mathbf{y}^*}\n    \\newcommand{\\vu}{\\mathbf{u}}\n    \\newcommand{\\vv}{\\mathbf{v}}\n    \\newcommand{\\vf}{\\mathbf{f}}\n    \\newcommand{\\vr}{\\mathbf{r}}\n    \\newcommand{\\vp}{\\mathbf{p}}\n    \\newcommand{\\vg}{\\mathbf{G}}\n    \\newcommand{\\bM}{\\mathbf{M}}\n    \\newcommand{\\bC}{\\mathbf{C}}\n    \\renewcommand{\\vec}{\\bm}\n    \\newcommand{\\dotvec}[1]{\\bm{\\dot{#1}}}\n    \\newcommand{\\bS}{\\mathbf{S}}\n    \\newcommand{\\bJ}{\\mathbf{J}}\n    \\newcommand{\\vlam}{\\pmb{\\lambda}}\n    \\newcommand{\\vxdot}{\\mathbf{\\dot{x}}}\n    \\newcommand{\\argmin}{\\operatornamewithlimits{arg\\ min}}\n\n    % \\newcommand{\\tens}{\\otimes}\n\n\n\\newcommand{\\tens}[1]{%\n  \\mathbin{\\mathop{\\otimes}\\limits_{#1}}%\n}\n\n    \\setlength{\\parskip}{\\baselineskip}\n    % \\newcommand{\\l}{\\left(}\n    \n    \\usepackage{titlesec}\n    \\usepackage{physics}\n    \\usepackage{multicol}\n    \n    \\setlength\\parindent{0pt}\n    \\captionsetup{justification=centering}\n    \n    \\title{Classical Mechanics: From Newton to Euler-Lagrange}\n    \\date{\\today}\n    \\author{Traiko Dinev \\textless traiko.dinev@gmail.com\\textgreater}\n\n\\begin{document}\n\\begin{multicols}{2}[Classical Mechanics: From Newton to Euler-Lagrang]\n\\maketitle\n\\textit{NOTE: These notes are a summary of Classical Mechanics: A Theoretical Minimum. They also contain some of David Morrin. Some of the notebooks are exercises I did through my own research.}\n\n\\textit{NOTE: Note this \"summary\" is NOT a reproduction of the course materials nor is it copied from the corresponding courses. It was entirely written and typeset from scratch.}\n\n\\textit{License: Creative Commons public license; See README.md of repository}\n\nHey, it is me, the author of these notes. I used to think reading physics was pointless practically speaking, so I did it a bit sparingly. But then.. I actually needed it in my own research! So I'm citing my work here~\\cite{dinev2020modeling}. Hopefully it encourages more academics to read physics at a moderate to advanced level, as you never know when you'll need it!\n\n\n\\section{Basics}\nA position of a particle in space is $\\bm{r} = (x, y, z)$, its velocity is $\\bm{v} = \\dot{\\bm{r}} = \\frac{d\\bm{r}}{d t}$. By (almost) definition of derivatives, we have:\n\n\\begin{equation}\n    \\bm{r}(t) = \\bm{r}_0 + \\bm{v}_0 t\n\\end{equation}\n\nif $\\bm{v}(t) = \\bm{v}_0$ is independent of time. Adding acceleration to this, by \\textbf{Newton's second law}, $\\bm{a} = \\dot{\\bm{v}} = \\bm{F}/m$, we can arrive at the following differential equation:\n\n\\begin{equation}\n    \\dot{\\bm{r}}_t = \\bm{v}(t) = \\bm{v}_0 + \\bm{a}_0 t\n\\end{equation}\n\nIntegrating this, we obtain:\n\n\\begin{align}\n    \\bm{r}(t) &= \\bm{r}_0 + \\int_0^t \\bm{v}(t) dt = \\bm{r}_0 +  \\int_0^t \\bm{v}_0 + \\bm{a}_0 t\\ dt \\\\\n    &= \\bm{r}_0 + \\bm{v}_0 t + \\frac{\\bm{a}_0}{2} t^2 = \\bm{r}_0 +  \\bm{v}_0 t + \\frac{\\bm{F}}{2m} t^2\n\\end{align}\n\nassuming that the acceleration is not a function of time. Otherwise you'd integrate the above ODE for each timestep.\n\n\\section{Generalized Co-ordinates and Equations of Motion}\n\\textit{The following is from a robotics summary of mine}\n\n    A system's dynamics are most generally described by a second-order non-linear equation:\n\n    \\begin{equation} \\label{eq:dynamics}\n        \\ddot{\\vec{q}} = \\vec{f}(\\vec{q}, \\dot{\\vec{q}}, \\vec{u}, t)\n    \\end{equation}\n\n    where $\\dot{\\vec{q}}$ and $\\ddot{\\vec{q}}$ are the first and second derivative of $\\vec{q}(t)$ -- the state of the system and $\\vec{u}(t)$ -- the control inputs at time $t$. $\\vec{f}$ is a matrix describing the dynamics. \\autoref{eq:dynamics} describes the time-evolution of the world's configuration. This depends on the state at time $t$ as well as the control inputs we apply. We derive the equations of motion by using Newton's second law of motion. For all robots without kinematic chains (loop mechanical connections), the above can be generally written as the following product:\n\n    \\begin{equation} \\label{eq:dynamics_standard}\n        \\vec{M}(\\vec{q}) \\ddot{\\vec{q}} + \\vec{C}(\\vec{q}, \\dot{\\vec{q}}) \\dot{\\vec{q}} =\n            \\tau_g(\\vec{q}) + \\vec{B}\\vec{u}\n    \\end{equation}\n\n    Here $\\vec{M}$ is the inertia matrix, $\\vec{C}$ is the Coriolis matrix, $\\tau_g$ is the gravity vector and $\\vec{B}$ maps control inputs $\\vec{u}$ into forces. For many systems this simplifies even further:\n\n    \\begin{equation} \\label{eq:affine}\n        \\ddot{\\vec{q}} = \\vec{f}_1(\\vec{q}, \\dotvec{q}, t) + \\vec{f}_2(\\vec{q}, \\dotvec{q}, t)\\ \\vec{u}\n    \\end{equation}\n\n    We call such systems \\textbf{control affine}. Such systems have dynamics that are affine (linear plus offset) in $\\vec{u}$.\n\n\\section{Lagrange}\nSo how do we obtain the equations of motion of a system? They all obey Newton's second law, but there is another way of stating that is more general. Define the Lagrangian of a system as the difference of its kinetic energy and potential energy:\n\n\\begin{equation*}\n    \\mathcal{L} = T - V\n\\end{equation*}\n\nThe fundamental law then states that for any system the motion from point A to point B is that which minimizes the integral of this difference along the path. In a sence it is a \\textbf{stationary action principle}, that is the action (the integral) is stationary (not necessarily a minimum or maximum). Firstly, let's start with conservative forces (which as we'll see will make a certain term equal to 0). We write the integral of the lagrangian as:\n\n\\begin{equation*}\n    S = \\int_{t_A}^{t_B} \\mathcal{L}\\ dt\n\\end{equation*}\n\nand we call $S$ the \\textbf{action}. The principle states that the action is stationary, i.e.:\n\n\\begin{equation*}\n    \\delta S = 0\n\\end{equation*}\n\nIn generalized coordinates the system's kinetic energy is $\\frac{1}{2} \\dot{q}^T M \\dot{q}$. For readability we will stick to the one-dimensional case, trusting that this extends (and it does) to any dimensions. For now, all we need to know is that the Lagrangian $\\mathcal{L}$ is a function of time, generalized positions, and generalized velocities:\n\n\\begin{equation*}\n    \\mathcal{A} = \\mathcal{A}(t, q(t), \\dot{q}(t))\n\\end{equation*}\n\nFirstly, we need to be clear that the path a system takes must start and end at a fixed point (otherwise this doesn't work), that is $q(t_A) = q_A, q(t_B) = q_B$ and the same for velocities. We want to find the minimum of the action, that is:\n\n\\begin{equation*}\n    \\min_{q(t)} S = \\min \\int_{t_A}^{t_B} \\mathcal{L}\\ dt\n\\end{equation*}\n\nwhere we note two things. 1) we are minimizing w.r.t. a function and 2) -- we are minimizing an integral.\nConsider a petrubation of the path the system takes (the thing under the min above):\n\n\\begin{align*}\n    q'(t) &= q(t) + \\epsilon \\eta(t) \\\\\n    \\dot{q}'(t) &= \\dot{q}(t) + \\epsilon \\eta'(t)\n\\end{align*}\n\nwhere we need to have $\\eta(t_A) = \\eta(t_B) = 0$, because we've fixed the start and end points. At the minimum any variation must yield a greater action (flip for maximum), that is:\n\n\\begin{equation*}\n    S[t, q(t), \\dot{q}(t)] \\leq S[t, q(t) + \\epsilon \\eta(t), \\dot{q}(t) + \\epsilon \\eta'(t)]\n\\end{equation*}\n\nwhich means that the minimum is at $\\epsilon = 0$. Minimum means that the derivative needs to be $0$. First we define the thing that's at the minimum to be a function of $\\epsilon$:\n\n\\begin{equation*}\n    f(\\epsilon) = S[t, q'(t), \\dot{q}'(t)]\n\\end{equation*}\n\nNow we can say that this is minimized at $\\epsilon = 0$ (follows from the assumption that action is minimized). Then we calculate its total derivative:\n\n\\begin{equation}\n    \\frac{d f}{d \\epsilon} = \\frac{d}{d \\epsilon}\\int_{t_A}^{t_B} \\mathcal{L}(t, q'(t), \\dot{q}'(t))\\ dt = \\int_{t_A}^{t_B} \\frac{d \\mathcal{L}}{d \\epsilon}\\ dt\n\\end{equation}\n\nThe derivative of the Lagrangian w.r.t $\\epsilon$ is:\n\n\\begin{equation*}\n    \\frac{d \\mathcal{L}}{d \\epsilon} = \\frac{\\partial \\mathcal{L}}{\\partial t} \\frac{d t}{d \\epsilon} + \\frac{\\partial \\mathcal{L}}{\\partial q'} \\frac{dq'}{d \\epsilon} + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}'} \\frac{d \\dot{q}'}{d \\epsilon}\n\\end{equation*}\n\nThe first term is $0$ since $\\epsilon$ has no effect on $t$. We can do a substitution of the pertrubation derivatives to obtain:\n\n\\begin{equation*}\n    \\frac{d \\mathcal{L}}{d \\epsilon} = \\frac{\\partial \\mathcal{L}}{\\partial q'} \\eta(t) + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}'} \\eta'(t)\n\\end{equation*}\n\nnote the slighly confusing notation, where $q'$ stands for variation in $q$ and $\\eta'$ stands for $\\eta$'s derivative. At least we consistenly use the inconsistency. Now the derivative of $f(\\epsilon)$ needs to be $0$ at $\\epsilon = 0$. This means we can remove all the pertrubations in the Lagrangian (set $q' = q, \\dot{q}' = \\dot{q}$) Meaning:\n\n\\begin{equation*}\n    \\left. \\frac{d \\mathcal{L}}{d \\epsilon} \\right\\vert_{\\epsilon = 0} = \\int_{t_A}^{t_B} \\left[ \\frac{\\partial \\mathcal{L}}{\\partial q} \\eta(t) + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta'(t) \\right] dt = 0\n\\end{equation*}\n\nNext we need to integrate by parts. Remembering that if we have:\n\n\\begin{equation*}\n    \\frac{d\\ \\eta f}{dt} = \\eta \\frac{df}{dt} + f \\frac{d\\eta}{dt}\n\\end{equation*}\n\nthen we can integrate to get:\n\n\\begin{equation*}\n    \\int f \\frac{d \\eta}{dt} dt = \\eta f - \\int \\eta \\frac{df}{dt} dt\n\\end{equation*}\n\nWe apply integration by parts on the second term:\n\n\\begin{align*}\n    & \\int_{t_A}^{t_B} \\left[ \\frac{\\partial \\mathcal{L}}{\\partial q} \\eta(t) + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta'(t) \\right] dt \\\\\n    & = \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial q} \\eta(t)\\ dt +\n        \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta'(t) dt \\\\\n    & = \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial q} \\eta(t)\\ dt + \n        \\left[ \\frac{\\partial \\mathcal{L}}{\\partial\\dot{q}} \\eta(t) \\right]_{t_A}^{t_B}\n        - \\int_{t_A}^{t_B} \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta(t) \\ dt \\\\\n    & = \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial q} \\eta(t)\\ dt\n    - \\int_{t_A}^{t_B}  \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta(t)\\ dt \\\\\n    & = \\int_{t_A}^{t_B} \\left[ \\frac{\\partial \\mathcal{L}}{dq} \\eta(t) - \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\eta(t) \\right] \\ dt = \\\\\n    & = \\int_{t_A}^{t_B} \\left[ \\frac{\\partial \\mathcal{L}}{\\partial q} - \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial\\dot{q}} \\right] \\eta(t) \\ dt\n\\end{align*}\n\nwhere we apply the bundary conditions $\\eta(t_A) = \\eta(t_B) = 0$. Now we have this remaining:\n\n\\begin{equation*}\n    \\int_{t_A}^{t_B} \\left[ \\frac{\\partial \\mathcal{L}}{\\partial q} - \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} \\right] \\eta(t) \\ dt = 0\n\\end{equation*}\n\nwhere this is true at $\\epsilon = 0$. Feynman has the best visual proof but the idea is that if it's true for any $\\eta(t)$ I can make it any delta function (peak) $\\eta(t_i) =  1$ for any $i$ I choose then the first thing must be 0. Meaning:\n\n\\begin{equation}\n    \\frac{\\partial \\mathcal{L}}{\\partial q} - \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} = 0\n\\end{equation}\n\nNormally this is written the other way around:\n\n\\begin{equation}\n    \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} - \\frac{\\partial \\mathcal{L}}{\\partial q} = 0\n\\end{equation}\n\nThe conservative forces show as potential energies. Namely:\n\n\\begin{align*}\n    \\mathcal{L} &= T - V \\\\\n    T &= \\frac{1}{2} m \\dot{q}^2 \\\\\n    F_{pot} &= -\\frac{d V}{dt}\n\\end{align*}\n\nwith a negative sign convention in physics. This is just Newton's second law for a particle:\n\n\\begin{align*}\n    \\mathcal{L} &= \\frac{1}{2} m v^2 - V(x) \\\\\n    \\frac{d}{dt} m v&= -\\frac{d V(x)}{dt} \\\\\n    m a &= F\n\\end{align*}\n\n\nLastly, remember external (non-conservative) forces? They show up on the right:\n\n\\begin{equation}\n    \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}} - \\frac{\\partial \\mathcal{L}}{\\partial q} = F_{ext}\n\\end{equation}\n\n\\section{Example}\n\n\\begin{figure}[H]\n    \\centering\n    \\begin{tikzpicture}[\n        media/.style={font={\\footnotesize\\sffamily}},\n        interface/.style={\n            postaction={draw,decorate,decoration={border,angle=-45,\n                        amplitude=0.3cm,segment length=2mm}}},\n        scale=1.2\n        ]\n        \n        % Round rectangle\n        % \\fill[gray!10,rounded corners] (-4,-3) rectangle (4,0);\n        % Interface\n        \\draw[blue,line width=.5pt,interface](-3,0)--(3,0);\n        % Vertical dashed line\n        \\draw[dashed,gray](0,0)--(0,3);\n\n\n        % Coordinates system\n        % \\draw(0,0.15)node[above]{$x$};\n        \\draw[<->,line width=1pt, shift={(-3cm, 0cm)}] (1,0) node[above]{$x$}-|(0,1) node[left]{$z$};\n\n\n        \\path (0,0)++(80:2.cm)node{$\\theta$};\n        \\draw[->] (0,2.5) arc (90:30:.75cm);\n\n\n        \\path (0,0)++(-1.2, 1)node{$\\phi$};\n        \\draw[->] (-.6,.55) arc (-120:-250:.5cm);\n\n        \\draw[gray,dashed](0,1)--(1,.7);\n        \\path (1.3, .6)node{$x,z$};\n\n\n\n        \\draw[line width=1pt](0,1cm)circle(.5cm);\n        \\draw[gray](0,1)--(1.5,2.5);\n\n        \\draw[gray, line width=1pt](1.1, 1.9)--(0.9,2.1);\n        \\draw[gray, line width=1pt](0.9,2.1)--(0.6,1.8);\n        \\draw[gray, line width=1pt](1.1,1.9)--(0.8,1.6);\n\n        \\draw[line width=1pt](1.5,2.5)circle(.1cm);\n        \\path(1.1, 2.6) node{$m_b$};\n\n\n        \\draw[<->,line width=.5pt,blue,dashed](0.2,0.7)--(1.8, 2.2);\n        \\path (1.25, 1.25) node{$l$};\n    \\end{tikzpicture}\n\n    \\caption{A Variable-Length Wheeled Inverted Pendulum (VL-WIP) model.}\n    \\label{fig:dynamics}\n\\end{figure}\n\n\nWe use the Lagrangian method to derive the dynamics of the system.\nFirst, we define the position $x_b, z_b$ of the mass $m_b$ and its velocity $\\dot{x}_b, \\dot{z}_b$:\n% \n% \\vskip 0.1in\n\\begin{align}\n    x_b &= x + l\\ \\sin(\\theta) \\\\\n    z_b &= z + l\\ \\cos(\\theta) \\nonumber \\\\\n    \\dot{x}_b &= \\dot{x} + \\dot{l}\\ \\sin(\\theta) +\n        l\\ cos(\\theta)\\ \\dot{\\theta} \\nonumber \\\\\n    \\dot{z}_b &= \\dot{z} + \\dot{l}\\ \\cos(\\theta) -\n        l\\ sin(\\theta)\\ \\dot{\\theta} \\nonumber\n\\end{align}\n% \\vskip 0.1in\n% \nLagrange's method states that for a system with total kinetic energy $T$ and potential energy $U$:\n% \n\\vskip 0.1in\n\\begin{equation} \\label{eq:lagrange}\n    \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\vqdot_i} - \\frac{\\partial \\mathcal{L}}{\\partial \\vq_i} = \\vf_{ext},\n\\end{equation}\n\\vskip 0.1in\n% \nwhere $\\mathcal{L} = T - U$ is the system's Lagrangian and $\\vf_{ext}$ are external forces applied to the system. We now need to compute the system's kinetic and potential energy.\n\nIn general, every link will have a rotational and translational kinetic energy component. For the wheel we include a rotational kinetic energy term $I_w \\dot{\\phi}^2$ where $I_w = m_w R_w^2$ is the moment of inertia of the wheel. Since the point mass has a zero moment of inertia, it only has a translational kinetic energy $m_b \\vv_b^T \\vv_b$, where $\\vv_b$ is the velocity of the point mass.\n\nThe only potential energy component is due to gravity $g$ acting on the wheel and the point mass. This leads to:\n% \n\\begin{align} \\label{eq:energy1}\n    T &= \\frac{1}{2}(I_w \\ \\dot{\\phi}^2 + m_w \\dot{x}^2 +\n        m_w \\dot{z}^2 + m_b \\dot{x}_b^2 + m_b \\dot{z}_b^2) \\\\\n    U &= m_w g z + m_b g z_b \\label{eq:energy2} \\\\\n    \\mathcal{L} &= T - U \\label{eq:energy3}\n\\end{align}\n\n\\textit{Note} I haven't written it out here, but you will obtain a system of equations, which you can solve however you want (scipy has a package to check your working). Then you can obtain the mass matrix, the coriolis matrix and the gravity vector.\n\n\n\\section{Conservation Laws (Noether)}\n\\subsection{Generic Proof (Simplified)}\nA symmetry is defined as $\\delta S = 0$ for a certain variation in the path. As before, we define:\n\n\\begin{align*}\n    q_i'(t) &= q_i(t) + \\eta_i(q(t), t) \\\\\n    \\delta q_i &= q_i'(t) - q_i(t) = \\eta_i(q(t), t)\n\\end{align*}\n\nfor all the generalized coordinates $q_i$. Then, since the action is invariant under the symmetry, we have:\n\n\\begin{equation*}\n    \\delta S = S[q'] - S[q] = 0\n\\end{equation*}\n\nNoether's theorem states that the quantity (Q):\n\n\\begin{equation*}\n    Q = \\sum_i \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\eta_i\n\\end{equation*}\n\nStarting with the action vanishing, we have:\n\n\\begin{align*}\n    &\\delta S = \\sum_i \\int_{t_A}^{t_B} \\delta \\mathcal{L}\\ dt\n         = \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial q_i} \\delta q_i + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\delta \\dot{q}_i\\ dt = \\\\\n    &= \\sum_i \\int_{t_A}^{t_B} \\frac{\\partial \\mathcal{L}}{\\partial q_i} \\eta_i + \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\eta'_i \\ dt = \\\\\n    &= \\sum_i \\int_{t_A}^{t_B} \\left[ \\frac{d}{dt} \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} - \\frac{\\partial \\mathcal{L}}{\\partial q_i} \\right] \\eta_i\\ dt - \\left. \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\eta_i \\right\\vert_{t_A}^{t_B}\n\\end{align*}\n\nwhere we used the same integration by parts trick as before. Now, if the system obeys the Newton-Euler equation of motion, then the integral vanishes and we have:\n\n\\begin{align*}\n    \\delta S = \\sum_i \\left. \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\eta_i \\right\\vert_{t_A}^{t_B} = Q(t_B) - Q(t_A) = 0\n\\end{align*}\n\nSince we did not specify or impose any constraints on $t_A$ and $t_B$, this is valid for any path. Thus:\n\n\\begin{align*}\n    \\frac{d}{dt} \\sum_i \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\eta_i = 0\n\\end{align*}\n\nand $Q$ is conserved as its derivative is $0$ everywhere along the path.\n\n\n\\subsection{Back to Physics}\nFirst we need a couple of definitions. A \\textbf{cyclic coordinate} is one that does not occur in the Lagrangian, i.e.:\n\n\\begin{equation}\n    \\frac{\\partial \\mathcal{L}}{\\partial q} = 0\n\\end{equation}\n\nThe \\textbf{conjugate momemtum} is defined as:\n\n\\begin{equation}\n    p = \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}}\n\\end{equation}\n\n\n\\subsubsection{Translational Invariance Leads to Conservation of Linear Momentum}\nConsider a translation transformation:\n\n\\begin{equation*}\n    q_i' = q_i + \\epsilon_i\n\\end{equation*}\n\nThen if the Lagrangian is invariant under such a transformation, the quantinity:\n\n\\begin{equation*}\n    Q = \\sum_i \\frac{\\partial \\mathcal{L}}{\\partial \\dot{q}_i} \\epsilon_i\n\\end{equation*}\n\nis conserved and so is the conjugate momentum, since $\\epsilon$ is a constant.\n\n\\subsubsection{Total Linear Momentum Conservation}\nConsider a vector potential that only depends on the relative distance between $N$ particles $\\bm{x}_i$, where $i \\in [1, N]$:\n\n\\begin{equation*}\n    \\mathcal{L} = \\sum_i \\left[ m_i \\frac{1}{2} \\dot{\\bm{x}}_i^T \\dot{\\bm{x}}_i - \\sum_{b \\neq a} V(\\bm{x}_a - \\bm{x}_b) \\right] \n\\end{equation*}\n\nThen shifting the entire system by the same vector does not change the lagrangian and the action. The velocity change is $0$ and the potential change is also $0$ as:\n\n\\begin{align*}\n    \\bm{x}_i' &= \\bm{x}_i + \\bm{\\epsilon} \\\\\n    \\bm{x}_a' - \\bm{x}_b' &= (\\bm{x}_a + \\bm{\\epsilon}) - (\\bm{x}_b + \\bm{\\epsilon}) = \\bm{x}_a - \\bm{x}_b\n\\end{align*}\n\nwhich means that:\n\n\\begin{equation*}\n    Q = \\sum_i \\frac{\\partial L}{\\partial \\dot{\\bm{x}}_i} = \n        \\sum_i m_i \\bm{\\dot{x}}_i\n\\end{equation*}\n\nis conserved. This is the sum linear momentum of the system.\n\n\\subsubsection{Rotational Invariance Leads to Angular Momentum Conservation}\nTODO\n\n\\section{Time-Translational Invariance Leads to Energy Convervation}\n\n\\section{Harmonic Oscillator: Hamiltonians}\n\n\\section{Gibbs Liouville}\n\n\\section{Poisson Brackets}\n\n\\section{Electromagnetic Force}\n\\subsection{Lorentz Force Law}\n\\subsection{Vector Potential}\n\\subsection{Gauge Invariance}\n\n\\bibliographystyle{IEEEtran}\n\\bibliography{IEEEabrv,IEEEconf,bib}\n\\end{multicols}\n\\end{document}\n", "meta": {"hexsha": "2c811dce5207957ace3fa9107c5d08fdc5c21262", "size": 20953, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "physics/classical_mechanics/summary.tex", "max_stars_repo_name": "include4eto/topic_summaries", "max_stars_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-13T20:04:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-03T20:57:56.000Z", "max_issues_repo_path": "physics/classical_mechanics/summary.tex", "max_issues_repo_name": "include4eto/topic_summaries", "max_issues_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "physics/classical_mechanics/summary.tex", "max_forks_repo_name": "include4eto/topic_summaries", "max_forks_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.1589537223, "max_line_length": 589, "alphanum_fraction": 0.6565169665, "num_tokens": 7069, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43728119956310535}}
{"text": "\\chapter*{Conclusions and perspectives} \n\\label{chap_conclusion_perspectives} \nThis work lies in between the two research domains of turbulence and image processing. The main objective was to explore a large spectrum of approaches to estimate small-scale turbulence from given measurements at large scales only. One contribution of the thesis is to review conventional methods. We have also adapted other models inspired from recent works in image processing and proposed new methods to our context. \n\nThe estimation of small-scale turbulence from measurements has been addressed via two problems described in chapter \\ref{chap_problem_definition}. The first problem is to find a relationship between large and small scales of turbulence given training samples at all scales. The second is to measure and combine complementary information, which are from space and time in this case. DNS data of an isotropic turbulence and a channel flow are used to setup different numerical experiments. These data give access to all scales of turbulence, which are used as the reference to qualify different approaches. Low-resolution fields of large scales are virtually extracted from the reference ones to which the reconstructions are compared. \n\nFor the two problems, we have proposed two families of approaches. The first one is to learn an empirical relationship between large and small scales through simple regression models or through learning coupled representations of different scales using dictionary learning. The second group of methods is based on the fusion of information. Different assumptions are exploited to propose schemes to combine available measured data. Two fusion models are developed, which use either similarity of structures in the flows or probabilistic models to find compromise estimates given the measurements. \n\nChapter \\ref{chap_linearregression} reviewed regression models, which find mapping functions between low-resolution and high-resolution fields. The function can be linear (via a set of coefficients) or nonlinear (using fixed kernel spaces). Model performances are usually sensitive to some hyper-parameters. This problem was addressed by optimizing a bias-variance trade-off using the cross-validation technique. Comparing reconstruction results, these models work better than standard spline interpolation. Nonlinear regressions also give more accurate reconstruction than linear ones. \n\nChapter \\ref{chap_dictionarylearning} discussed \\textit{dictionary learning}, a generalization of principal component analysis (called \\textit{proper orthogonal decomposition} in turbulence studies) to learn redundant bases that better represent turbulent fields in a sparse manner. A couple of representations are learned and used to reconstruct the high-resolution fields from low-resolution measurements. In the case of direct subsampling that could happen in real experiments, the aliasing problem appears. We observe that the coupled dictionary learning method does not permit to de-alias. The model has not brought significant improvements compared to spatial interpolation. Once avoiding this problem by a prefiltering step, dictionary learning gives significant improvements compared to interpolation. In the range of scale between 0.5 and 1.5 the cutoff, it reduces the energy loss by about $ 60 \\% $ and the total error by about $ 15 \\% $. \n\nChapter \\ref{chap_NLM} discussed a non-local means-based propagation model as the first fusion model. The model was based on the hypothesis of \\textit{rapid distortion}, which assumes that small scales are advected by large ones. These small-scale information from the LTHS planes are propagated in time based on the similarity level of large scales in space. The model works very well at low subsampling ratios in space and time (corresponding to about $ 1\\% $ of energy loss) where it significantly improves the reconstruction accuracy (by about $ 40\\% $) compared to single interpolation in space. However, the model is not very robust when the energy losses are more severe. With large subsampling ratios in space (for instance $ \\dimsh/\\dimsl =6 \\times 6 $), it suffers from severe losses and can not recover completely even at large-scale. With large ratios in time (for instance $ \\dimth/\\dimtl = 8 $) , similarities of large scales decay rapidly and make propagation models less accurate.\n\nTo further exploit all available information from measurements, a simple yet efficient fusion model was proposed in chapter \\ref{chap_BayesianFusion}. The model estimates a high-resolution field that maximizes its \\textit{posterior} probability given the measurements. A Bayesian framework is used and further simplifications lead to a linear fusion formula, a weighted sum of the two single interpolations from the two measured data. Weighted coefficients are covariance matrices of unknown small scales, which are learned from measurements. The model reconstructs high-resolution fields with significant improvement compared to single interpolations from either sources. The superiority of this model is emphasized in the case where energy losses are balanced in space and time. In such cases, improvements are observed both at large and small scales.\n\nChapter \\ref{chap_comparisons} provided a more global view of all proposed methods. We synthesized reconstructions by all approaches for the same setups where measurements in space and time are subsampled in a balanced manner. Dictionary learning is omitted in this comparison because of its slightly different configuration of numerical experiments. Single models to solve the reconstruction problem can be predefined (interpolation) or learned adaptively from the training data (regression). Adaptive models reconstruct the fields more accurately. More significant improvements are observed when combining complementary measurements in space and time. NLM-based model gives very accurate reconstructions at low energy losses. At higher subsampling ratios, this model is not able to over-perform temporal interpolation. Bayesian fusion model is simpler yet more efficient, and gives the best reconstruction in all cases. \n\n\\subsection{Suggestions for future works}\nThe main purpose of this work was a first exploration of a set of methods for the reconstruction of fully resolved turbulent fields from low resolution measurements. Turbulent fields are highly disordered and much less regular than natural images, therefore the inverse problem of reconstruction is even more difficult in our case. This thesis has opened many new directions to develop tools for turbulence studies. Results have suggested also some new directions for signal/image processing studies to provide even more adapted tools. The present work gives rise to the following suggestions for future works.\n\n\\subsubsection*{Extending to the reconstruction of three-component velocity fields?} \nThe whole thesis has dealt with the reconstruction of streamwise velocity fields. All results can be reproduced for the other two components independently. However, all components are connected physically through Navier-Stokes equations. Further investigations are needed to exploit the information such as cross-correlation between components, vorticities and divergence of the velocity fields. One idea is to impose the prior of \\textit{divergence-free}. Another idea would be to use vorticities as features instead of derivatives to learn coupled dictionaries.  \n\n\\subsubsection*{Ensemble of models as generalizing Bayesian fusion model?} \nChapter \\ref{chap_comparisons} has compared performances of all proposed models. It has shown that different models, though exploiting different sources of information or assumptions, give better results than single interpolations. Combining multi-sources of measurements through their interpolations gives more accurate reconstructions compared to one complex single model. This observation suggests to further ensemble different models and take advantage of each single model. Regressions, by learning an adaptive interpolator, could replace spline interpolations. NLM-based propagation models by exploiting the similarity information also appear as a good candidate to replace simple interpolation. \n\n\\subsubsection*{Highly nonlinear mapping function between large and small scales of turbulence?} This thesis has reviewed regression models, but they remain rather simplistic to describe this highly nonlinear relation between scales. This is suggested when observing advantages of kernel regressions in chapter \\ref{chap_comparisons}. Other ideas, especially \\textit{neural network} and \\textit{deep learning} \\citep{dong2014image}, could be studied. Such approaches permit much more complex and highly nonlinear mapping functions between input low-resolution and output high-resolution fields, not restricted to a fixed kernel space as the KRR model. However, such a model requires an extremely large amount of training samples. The patch-wise approach is potentially a good candidate to give access to more samples and to localize the information. Such models could be combined with sparse prior \\citep{wang2015deep} discussed in chapter \\ref{chap_dictionarylearning} and proven to further improve reconstruction accuracy. \n\n\\subsubsection*{Dictionary learning for other inverse problems in turbulence?} As a more efficient representation compared to PCA and predefined wavelets, dictionary learning has demonstrated its possibility to solve the inverse problem of reconstructing high-resolution velocities from low-resolution measurements. The improvement is significant when aliasing is handled carefully but inoperative in the case of direct subsampling. This approach is not limited to super-resolution only. Other inverse problems such as removing noise or estimating missing pixels could be studied. One particular idea is to apply dictionary learning to D time-resolved experimental data of ``\\textit{Shake-The-Box}''-PIV \\citep{schroder2015advances}. By following the particles, the method resolves till pixel size. However, velocity fields in a uniform grid is estimated by simple interpolations. This could be done with dictionary learning. Viewing the fields with many missing pixels as random sensing, the approach could learn the missing small scales from the position it ``\\textit{sees}'' and propose better estimates than interpolation. Also, measurements noise could be separated from the true information in the same step. \n\n\\subsubsection*{Dictionary learning to deal with aliasing from direct subsampling?} Aliasing is a known problem when the sensing system directly subsamples the fields without the prefiltering step. The first attempt of dictionary learning to reconstruct the high-resolution fields from the subsampled measurements has failed potentially due to aliasing. Without its presence, the model gives clear improvements compared to single interpolation. The problem of removing aliasing could be addressed and solved using dictionary learning as well. Coupled dictionaries could be learned to represent the fields with and without aliasing. The model in chapter \\ref{chap_dictionarylearning} would become a three-stage super-resolution model, with an intermediate step to remove aliasing.\n\n\\subsubsection*{A more complete fusion model, a Bayesian way?} The fusion model proposed in this work uses only a very simple weighted sum formula. The prior of the estimated field is omitted from the formula due to the assumption of a non-informative prior. Full covariance matrices to represent all sources of space-time correlations are also simplified to diagonal ones. Some work remains to be done to further exploit the information from measurements by building more complete covariance matrices. Also, a good prior could further improve further the reconstruction. The prior could carry physical properties of the flow, for example divergence free, energy spectra or even full Navier-Stokes equations. In case the full fields are given as training data, covariance matrices could also be learned adaptively. In such cases, the weights of the fusion model could be learned to take the properties of turbulence into account. \n\n\\subsubsection*{Combining fusion and dictionary learning?} Dictionary learning has shown to be a good representation of turbulent fields using a sparsity prior. This prior helps in solving the ill-posed problem of reconstructing high-resolution fields. Fusion models by combining multi-sources of measurements are simple but also very efficient to solve the problem. The idea of combining sparse prior and fusion could be studied, inspired by \\citet{wei2015hyperspectral}. In chapter \\ref{chap_BayesianFusion}, the optimization problem is:\n\\begin{equation}\n\t\\z = \\argmin_{\\z} \\left\\lbrace \\frac{1}{2} \\Mdist{\\z -\\Interp_t\\x}{\\Sigma_{\\h_t}} + \\frac{1}{2}\\Mdist{\\z -\\Interp_s\\y}{\\Sigma_{\\h_s}} \\right\\rbrace\n\\end{equation}\nBy imposing the sparse prior, the problem could be rewriten as:\n\\begin{equation}\n\t\\z = \\dict \\dictco \\subjectto \\{\\dict,\\dictco\\} = \\argmin_{\\dict,\\dictco} \\left\\lbrace \\frac{1}{2} \\Mdist{\\dict \\dictco -\\Interp_t\\x}{\\Sigma_{\\h_t}} + \\frac{1}{2}\\Mdist{\\dict\\dictco -\\Interp_s\\y}{\\Sigma_{\\h_s}} + \\lambda \\normone{\\dictco} \\right\\rbrace\n\\end{equation}\nor avoiding the interpolations, hence not bringing aliasing terms into the system, as:\n\\begin{equation}\n\t\t\\z = \\dict \\dictco \\subjectto \\{\\dict,\\dictco\\} = \\argmin_{\\dict,\\dictco} \\left\\lbrace \\frac{1}{2} \\Mdist{\\Sub_t\\dict \\dictco -\\x}{\\Sigma_{\\h_t}} + \\frac{1}{2}\\Mdist{\\Sub_s\\dict\\dictco -\\y}{\\Sigma_{\\h_s}} + \\lambda \\normone{\\dictco} \\right\\rbrace\n\\end{equation}\nSolving the above highly non-convex problem could be addressed thanks to recent progresses in solving alternating optimization problems \\citep{boyd2011distributed,parikh2014proximal}. \n\n\\subsubsection*{Increase resolution of PIV measurements using different setups?} Regression and interpolation are restricted to reconstruct high-resolution fields from low-resolution ones at the same scene, while it is not the case for coupled dictionaries learning. One very promising setup would be to combine high-resolution PIV with time-resolved PIV (Tr-PIV). High-resolution PIV can measure the flow at a small field-of-view but at very high spatial resolution. These measurements could be used to train the dictionaries. Then Tr-PIV measures the flow at a much larger field-of-view but at lower resolution. Using the trained dictionaries, one could estimate time-resolved velocity fields at large field-of-view and high spatial resolution. One should notice also the limitation of such an approach in de-aliasing to carefully design the sensing system. Another configuration could be to use two different PIV systems to measure HTLS and LTHS fields (see figure \\ref{fig:space-time_measurements}) and apply fusion models to maximize the level of useful information.\n\n\\subsubsection*{Co-conception design of experiments?} The thesis has studied the performances of various models for different configurations at various subsampling ratios. This gives an idea of which method to choose for one particular setup. From a certain loss of energy due to subsamplings, this work suggests the maximum level of accuracy and scale one could expect to reconstruct. This information is very useful to design new challenging experiments in order to maximize the expected level of small scale content after post-processing. This thesis connects to the current research area of co-conception. The idea is to co-design the measurement system with respect to some pre-defined post-processing procedure. ", "meta": {"hexsha": "867aa1bc97ac3a46cc8cc83a83e6114deb9d16f2", "size": 15615, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/manuscripts/final_ver1/corps/conclusions.tex", "max_stars_repo_name": "linhvannguyen/PhDworks", "max_stars_repo_head_hexsha": "9336e5257f5ddc3c899a6fb68b1028c905d13ff9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-01-01T14:41:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T07:08:06.000Z", "max_issues_repo_path": "thesis/manuscripts/final_ver1/corps/conclusions.tex", "max_issues_repo_name": "vanlinhnguyen/PhDworks", "max_issues_repo_head_hexsha": "9336e5257f5ddc3c899a6fb68b1028c905d13ff9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/manuscripts/final_ver1/corps/conclusions.tex", "max_forks_repo_name": "vanlinhnguyen/PhDworks", "max_forks_repo_head_hexsha": "9336e5257f5ddc3c899a6fb68b1028c905d13ff9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 300.2884615385, "max_line_length": 1215, "alphanum_fraction": 0.8197246238, "num_tokens": 3096, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.43728119956310535}}
{"text": "\\chapter{Results}\n\\label{sec:results}\nWe will now first investigate the performance of our models compared to our chosen reference models on the $17$ \\gls{tcga} datasets considered in our benchmark. In addition to the absolute performance as measured by Harrell's concordance index (Equation \\ref{eq:concordance}), we also calculated the rank of each model (by mean concordance, lower rank implies higher mean concordance) on each cancer to get an overview of how the models compared to each other in relative terms. We also compared the computation times of all models. Further, we tested for a statistically significant difference in performance between our newly proposed supervised autoencoders and all non-integrative baseline models (that is, \\gls{rsf}, \\gls{cox} and \\gls{lasso}).\n\nAfterward, we tried to understand our models better by applying a few different techniques. Note that due to the sheer number of models we have in total (six), we only investigated these topics for the non-residual version of our best model since the differences overall were minor (data not shown). In addition, since it is impossible to show results for every single cancer when investigating a latent space, we restricted ourselves to two cancers. We visualized the information contained in the latent space for the best test split of \\gls{blca} and \\gls{kirp} to understand better what kind of information is learned and carried through the model.\n\nLastly, we show the results of our Lasso surrogate models. We only fitted the surrogate models on our best overall model variant, as this would be done in a clinical setting. For the surrogate results, we show the performance of the resulting surrogates in terms of approximating our architectures (as measured by train and test $R^2$) and in terms of test concordance. Furthermore, we investigated the sparsity levels of the surrogate models and compared them to (non-surrogate) Lasso. Finally, we checked the performance of arbitrary survival models fitted using the feature set discovered by the surrogate models to deconstruct to which extent multi-omics integration can be reduced to feature selection.\n\n\\section{Performance on \\gls{tcga} datasets}\n\\label{sec:tcga-performance}\nWe start this section by comparing the performances of our three proposed architectures to each other before evaluating the effect of the residual variants and lastly putting the overall performance of our models into perspective by comparing them to the reference models.\n\n\\begin{table}\n\\caption{Test concordance of all methods across the 10 test splits of all 17 considered TCGA cancers rounded to three decimals. Best value bolded by column.}\n\\label{tab:tcga-mo-performance-overall}\n\\centering\n\\begin{tabular}[t]{cccc}\n\\toprule\nModel & Mean & Median & SD\\\\\n\\midrule\nSHAE (ours) & 0.661 & 0.656 & 0.111\\\\\nSHAE residual (ours) & 0.660 & \\textbf{0.657} & 0.113\\\\\nMSAE (ours) & 0.627 & 0.613 & 0.111\\\\\nMSAE residual (ours) & 0.636 & 0.627 & 0.114\\\\\nCSAE (ours) & 0.620 & 0.612 & \\textbf{0.100}\\\\\n\\addlinespace\nCSAE residual (ours) & 0.621 & 0.613 & \\textbf{0.100}\\\\\nBF & 0.649 & 0.637 & 0.118\\\\\nRB favoring & \\textbf{0.663} & 0.648 & 0.113\\\\\nRSF & 0.595 & 0.578 & 0.125\\\\\nLasso & 0.614 & 0.590 & 0.120\\\\\n\\addlinespace\nClin. Cox PH & 0.622 & 0.626 & 0.112\\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\n\\subsection{Performance of \\gls{shae}, \\gls{msae} and \\gls{csae} compared}\nOverall, the \\glsxtrfull{shae} performed by far the best out of our three proposed architectures, outperforming the \\glsxtrfull{msae} and the \\glsxtrfull{csae} in terms of both overall concordance across all cancers (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}) and mean rank per cancer (Figure \\ref{fig:tcga-ranks}). \n\nWe found that even on a per-cancer level, neither \\gls{msae} nor \\gls{csae} were able to outperform \\gls{shae} consistently, except on very rare occasions such as \\gls{lgg} (at least for \\gls{msae}) (Figure \\ref{fig:overall-tcga-performance-by-cancer} and Table \\ref{tab:tcga-mean-performance}). These results were consistent with those of \\citet{simidjievski2019variational} who similarly found that their hierarchical autoencoder architecture worked best for multi-omics integration on a different task.\n\n\\subsection{Performance of residual architecture variants}\nThe residual variants of \\gls{shae} and \\gls{csae} performed virtually identical to their non-residual version in terms of both overall concordance (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}) and rank (Figure \\ref{fig:tcga-ranks}).\\footnote{Although the ranks sometimes suggests that there was a difference between models, this should be interpreted with caution, as even a tiny performance delta will show up in terms of higher rank. Thus, Figure \\ref{fig:tcga-ranks} should always be investigated in conjunction with Figure \\ref{fig:overall-tcga-performance} or Table \\ref{tab:tcga-mo-performance-overall}.}For \\gls{msae} on the other hand, there was a noticeable difference in terms of both overall concordance (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}) and rank (Figure \\ref{fig:tcga-ranks}). We will not muse on potential reasons for this and leave this instead to the Discussion in Chapter \\ref{sec:discussion}.\n\nSomewhat interestingly, we did not see a one-to-one correspondence between \\gls{cox} performing especially well and the residual variants of our architectures outperforming the non-residual variants. On \\gls{ucec} for example, even though \\gls{cox} performed quite well compared to the other models, \\gls{shae} residual underperformed \\gls{shae} (Figure \\ref{fig:overall-tcga-performance-by-cancer} and Table \\ref{tab:tcga-mean-performance}).\\footnote{If \\gls{cox} performs especially well on a cancer, we would naturally expect the skipping of clinical variables to improve concordance more than on cancers where clinical data has limited predictive value.} There were also examples to the contrary, but the pattern was less strong than expected.\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_tcga_overall_multi_omics_performance.png} \\caption{Test concordance of all methods across the 10 test splits of all 17 considered TCGA cancers.}\\label{fig:overall-tcga-performance}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_tcga_mean_ranks.png} \\caption{Mean test concordance rank per cancer across the 17 considered \\gls{tcga} cancers (lower is better).}\\label{fig:tcga-ranks}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=15.7463cm]{./content/figures/fig_plot_tcga_overall_performance_by_cancer.png} \\caption{Test concordance of all methods across the 10 test splits of each of the 17 considered TCGA cancers.}\\label{fig:overall-tcga-performance-by-cancer}\n\\end{figure}\n\n\\subsection{Performance of the supervised autoencoders relative to the non-multi-omics reference models}\nWe tested for an overall statistically significant outperformance of each of our proposed architectures relative to each non-multi-omics baseline method as described in Chapter \\ref{sec:testing}. We found that none of our models was able to statistically significantly outperform \\gls{cox} after multiple testing correction (Table \\ref{tab:stat-sig}). This may have partially been due to the number of tests performed (a total of $6 * 3 = 18$ tests were performed).\nBoth \\gls{shae} and \\gls{shae} residual statistically significantly outperformed both \\gls{lasso} and \\gls{rsf} after multiple testing correction, validating that \\gls{shae} performed its job of multi-omics integration. Furthermore, we saw a clear gain in performance when comparing \\gls{shae} and \\gls{shae} residual to  \\gls{cox}, even though this difference was not statistically significant after correction (Table \\ref{tab:tcga-mo-performance-overall} and Figure \\ref{fig:overall-tcga-performance}). \n\nWith the other two architectures, \\gls{msae} and \\gls{csae}, the situation was a bit more nuanced. For \\gls{csae}, neither the regular variant nor the residual version was able to statistically significantly outperform any of the non-multi-omics baseline methods after correction. For \\gls{msae}, the situation was very similar, except that \\gls{msae} residual statistically significantly outperformed \\gls{rsf} after correction at the $10\\%$ level (Table \\ref{tab:stat-sig}).\n\n\nThere was no major pattern visible by specific cancers except for the fact that we generally saw a split between cancers on which a dedicated multi-omics integration model (such as \\gls{shae}) seemed to help, for example, on \\gls{blca} or \\gls{hnsc} and those for which it did not make a difference (\\emph{\\emph{e.g.,}} \\gls{sarc}).\n\n\\subsection{Performance of the supervised autoencoders compared to \\glsxtrfull{bf} and its variants}\n\n\\begin{table}\n\\caption{Mean test concordance of all methods across the 10 test splits of each of the 17 considered TCGA cancers rounded to three decimals. Best value bolded by column.}\n\\centering\n\\label{tab:tcga-mean-performance}\n\\resizebox{\\linewidth}{!}{\n\\begin{tabular}[t]{cccccccccccccccccc}\n\\toprule\nModel & BLCA & BRCA & COAD & ESCA & HNSC & KIRC & KIRP & LGG & LIHC & LUAD & LUSC & OV & PAAD & SARC & SKCM & STAD & UCEC\\\\\n\\midrule\nSHAE (ours) & \\textbf{0.655} & 0.636 & 0.711 & \\textbf{0.648} & 0.639 & 0.765 & 0.853 & 0.800 & 0.565 & 0.634 & 0.597 & 0.600 & 0.538 & 0.638 & 0.639 & \\textbf{0.559} & 0.751\\\\\nSHAE residual (ours) & 0.653 & 0.644 & 0.724 & 0.641 & \\textbf{0.641} & 0.766 & \\textbf{0.854} & 0.815 & 0.565 & 0.638 & 0.588 & 0.602 & 0.535 & 0.615 & 0.645 & 0.556 & 0.739\\\\\nMSAE (ours) & 0.622 & 0.624 & 0.652 & 0.596 & 0.591 & 0.681 & 0.827 & 0.821 & 0.557 & 0.598 & 0.558 & 0.564 & 0.526 & 0.628 & 0.643 & 0.519 & 0.648\\\\\nMSAE residual (ours) & 0.624 & 0.642 & 0.684 & 0.569 & 0.629 & 0.700 & 0.829 & 0.821 & 0.562 & 0.604 & 0.591 & 0.584 & 0.519 & 0.612 & \\textbf{0.649} & 0.521 & 0.671\\\\\nCSAE (ours) & 0.601 & 0.596 & 0.655 & 0.626 & 0.562 & 0.622 & 0.760 & 0.809 & 0.522 & 0.607 & 0.589 & \\textbf{0.627} & 0.509 & 0.610 & 0.626 & 0.554 & 0.668\\\\\n\\addlinespace\nCSAE residual (ours) & 0.600 & 0.599 & 0.660 & 0.631 & 0.568 & 0.628 & 0.761 & 0.808 & 0.517 & 0.612 & 0.592 & 0.619 & 0.496 & 0.622 & 0.626 & 0.553 & 0.664\\\\\nBF & 0.624 & 0.626 & 0.696 & 0.525 & 0.602 & 0.779 & 0.852 & 0.840 & 0.566 & 0.651 & 0.573 & 0.584 & 0.539 & \\textbf{0.678} & 0.620 & 0.541 & 0.731\\\\\nRB favoring & 0.633 & \\textbf{0.655} & 0.717 & 0.552 & 0.634 & \\textbf{0.784} & 0.853 & \\textbf{0.851} & \\textbf{0.603} & \\textbf{0.655} & 0.602 & 0.613 & 0.535 & 0.660 & 0.649 & 0.557 & 0.724\\\\\nRSF & 0.532 & 0.591 & 0.594 & 0.500 & 0.494 & 0.668 & 0.834 & 0.837 & 0.594 & 0.551 & 0.471 & 0.489 & \\textbf{0.555} & 0.644 & 0.569 & 0.521 & 0.667\\\\\nLasso & 0.593 & 0.556 & 0.667 & 0.505 & 0.540 & 0.778 & 0.812 & 0.847 & 0.575 & 0.574 & 0.497 & 0.535 & 0.553 & 0.631 & 0.596 & 0.518 & 0.658\\\\\n\\addlinespace\nClin. Cox PH & 0.642 & 0.629 & \\textbf{0.731} & 0.575 & 0.594 & 0.760 & 0.590 & 0.759 & 0.542 & 0.641 & \\textbf{0.614} & 0.610 & 0.533 & 0.453 & 0.629 & 0.528 & \\textbf{0.752}\\\\\n\\bottomrule\n\\end{tabular}\n}\n\\end{table}\n\n\\begin{table}\n\\caption{P-Values of testing the non-inferiority of each baseline method (rounded to four digits). $H_0$: The baseline method performed as well as our respective model it is being compared to. Bonferroni-Holm \\citep{holm1979simple} used for multiple testing correction.}\n\\label{tab:stat-sig}\n\\centering\n\\resizebox{\\linewidth}{!}{\n\\begin{tabular}[t]{cccc}\n\\toprule\nModel & Comparison model & P-Value (before correction) & P-Value (after correction)\\\\\n\\midrule\nSHAE (ours) & RSF & 0.0002 & 0.0041\\\\\nSHAE (ours) & Lasso & 0.0007 & 0.0098\\\\\nSHAE (ours) & Clin. Cox PH & 0.0265 & 0.2911\\\\\nSHAE residual (ours) & RSF & 0.0003 & 0.0045\\\\\nSHAE residual (ours) & Lasso & 0.0006 & 0.0095\\\\\n\\addlinespace\nSHAE residual (ours) & Clin. Cox PH & 0.0243 & 0.2911\\\\\nMSAE (ours) & RSF & 0.0079 & 0.1027\\\\\nMSAE (ours) & Lasso & 0.1274 & 0.8919\\\\\nMSAE (ours) & Clin. Cox PH & 0.4215 & 1.0000\\\\\nMSAE residual (ours) & RSF & 0.0040 & 0.0560\\\\\n\\addlinespace\nMSAE residual (ours) & Lasso & 0.0352 & 0.3516\\\\\nMSAE residual (ours) & Clin. Cox PH & 0.2446 & 1.0000\\\\\nCSAE (ours) & RSF & 0.0742 & 0.6360\\\\\nCSAE (ours) & Lasso & 0.3491 & 1.0000\\\\\nCSAE (ours) & Clin. Cox PH & 0.5475 & 1.0000\\\\\n\\addlinespace\nCSAE residual (ours) & RSF & 0.0707 & 0.6360\\\\\nCSAE residual (ours) & Lasso & 0.3314 & 1.0000\\\\\nCSAE residual (ours) & Clin. Cox PH & 0.5302 & 1.0000\\\\\n\\bottomrule\n\\end{tabular}\n}\n\\end{table}\n\nWhen comparing our newly suggested architectures to \\gls{bf} and \\gls{rbf}, we found that \\gls{shae} and \\gls{shae} residual alone were able to perform on par with them. In particular, both of them performed better than \\gls{bf} in terms of overall concordance (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}) and rank (Figure \\ref{fig:tcga-ranks}). \\gls{rbf} performed very similar to \\gls{shae} and its residual variant in terms of overall concordance across all cancers (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}), but was able to capture the best performance in terms of mean concordance rank per dataset (Figure \\ref{fig:tcga-ranks}). When investigating the performance per individual cancers, we found that for most cancers, the performance of \\gls{shae} (residual), \\gls{bf} and \\gls{rbf} was qualitatively similar (Table \\ref{tab:tcga-mean-performance}). There were however a few examples on which one of the models four clearly outperformed the others: On Esophageal carcinoma (ESCA), \\gls{shae} (and in fact even \\gls{msae} and \\gls{csae}) \\gls{shae} strongly outperformed not just \\gls{bf} and \\gls{rbf} but in fact all other non-autoencoder models. A few similar existed for \\gls{bf} and \\gls{rbf}: On \\gls{kirc} and \\gls{lgg} we clearly saw \\gls{bf} and \\gls{rbf} outperform all of the neural models.\n\n\\gls{msae}, \\gls{csae} and their respective residual versions did not perform well when compared to either \\gls{bf} or \\gls{rbf}. All of them were clearly outperformed by \\gls{bf} and especially \\gls{rbf} in terms of overall concordance (Figure \\ref{fig:overall-tcga-performance} and Table \\ref{tab:tcga-mo-performance-overall}) and rank (Figure \\ref{fig:tcga-ranks}). Only \\gls{msae} residual performed somewhat close to \\gls{bf} in terms of overall concordance but was still inferior in terms of rank. When investigating the performances by individual cancers, we found that \\gls{msae} and \\gls{csae} underperformed \\gls{bf} and \\gls{rbf} on virtually all cancers, save for \\gls{esca}, on which all supervised autoencoders performed especially well (Table \\ref{tab:tcga-mean-performance} and Figure \\ref{fig:overall-tcga-performance-by-cancer}).\n\nOverall, we found that we could classify the $17$ considered \\gls{tcga} cancers roughly into three different categories: \n\n\\begin{enumerate}\n    \\item Cancers on which (proper) multi-omics integration models outperformed non-integrative multi-omics models but not \\gls{cox}. Examples of this included \\gls{blca} and \\gls{coad}.\n    \\item Cancers on which non-integrative multi-omics models performed as well as multi-omics integration models but \\gls{cox} underperformed. Examples for this group included \\gls{lgg} and \\gls{kirp}.\n    \\item Cancers on which all three groups of models performed roughly equally. Examples for this one included \\gls{paad} and \\gls{lihc}.\n\\end{enumerate}\n\nWe found that \\gls{shae} and \\gls{shae} residual belonged to the same group as \\gls{bf} and \\gls{rbf} in that they behaved all in a similar manner of well-working multi-omics methods. \\gls{msae} and \\gls{csae} were a bit harder to pin down in that they sometimes performed similar to \\gls{shae}, \\gls{rbf} and \\gls{bf} (\\emph{e.g.,} on \\gls{blca}) but sometimes also strongly underperformed them (\\emph{e.g.,} on \\gls{kirc}). In that sense, we would put \\gls{msae} and \\gls{csae} in a separate category of multi-omics integration methods which do not work consistently. They could perhaps be grouped with some of the less well-working variants of \\gls{bf} introduced in the study of \\citet{hornung2019block}.\n\n\\subsection{Computation times}\nLastly, before we move on, we briefly look at the computation times of all respective models. Overall, \\gls{bf} and \\gls{rbf} were by far the slowest models, which is consistent with the timings done in the study by \\citet{herrmann2021large} (Figure \\ref{fig:computation-times}). Interestingly, we found that \\gls{rbf} was quite a bit faster than \\gls{bf} which could be due to the fact the clinical block does not have to be considered in sampling but is instead included mandatorily at every split.\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_computation_times.png} \\caption{Mean computation time in seconds across the 10 test splits of each of the 17 considered \\gls{tcga} cancers (lower is better).}\\label{fig:computation-times}\n\\end{figure}\n\nThe supervised autoencoder architectures were the next slowest, with \\gls{csae} and \\gls{csae} residual (they had virtually identical computation times) the slowest, likely due to the high dimensionality of their second level latent space. \\gls{shae} and \\gls{msae} came next, although it should be noted that for \\gls{msae}, we only had to tune one parameter instead of two (since \\gls{msae} does not use \\gls{sgl}) which naturally made it faster than the other two architectures. Interestingly, for \\gls{msae}, the difference between its residual version and the regular version was quite noticeable, which was not the case for \\gls{shae} and \\gls{csae}. Of course, \\gls{rsf}, \\gls{lasso} and \\gls{cox} were the fastest models across all datasets, with \\gls{cox} always being the fastest, followed by \\gls{rsf} and \\gls{lasso}. These fast computation times of all non-integrative models came at the price of decreased concordance (Figure \\ref{sec:tcga-performance}), except for \\gls{cox} which performed quite well overall, despite its virtually instant computation times.\n\nThe ordering of methods in terms of computation times stayed constant across all datasets (except for one negligible switch between \\gls{lasso} and \\gls{rsf}), suggesting that all methods scaled similarly across datasets of different sizes. We note that \\gls{shae} (residual) performed approximately equal to \\gls{rbf} while achieving mean computation times across splits which were on average a factor of four times lower. Although \\citet{hornung2019block} argued in their study that the speed of \\gls{bf} and its variants could be improved by performing feature selection on the higher dimensional blocks (since they contain redundant information), the same argument holds for \\gls{shae}, thus likely keeping overall computation times in a similar range. \n\nSince our overall best models were \\gls{shae} and \\gls{shae} residual, we restrict the following investigations in the main text to \\gls{shae}.\n\n\\section{Learned representations}\nWe now investigate the learned representations of our best model, \\gls{shae} on two exemplary cancers.\\footnote{Since \\gls{shae} and \\gls{shae} residual were so similar, we only investigated the non-residual variant here and added a short section on differences between the residual and non-residual variant at the end of this chapter.} Specifically, we picked \\gls{blca} and \\gls{kirp} since they exemplify two of the main variants of cancers we identified in the previous section.  We argue that studying these two cancers gives a representative picture of the subset of cancers considered here. Specifically, on \\gls{blca}, \\gls{cox} performed as well or better than the multi-omics models (Figure \\ref{fig:overall-tcga-performance-by-cancer} and Table \\ref{tab:tcga-mo-performance-overall}), suggesting that there was limited additional information contained in the molecular omics groups. On \\gls{kirp}, on the other hand, all multi-omics models (even the non-integrative ones) strongly outperformed \\gls{cox}, suggesting that there was considerable additional information contained in the molecular data. When this added additional information, we also tied the learned latent representations back to group-wise permutation importance (Algorithm \\ref{alg:fi-group}) to validate whether the learned representation matched the feature importances calculated through permutation.\n\nThroughout this section, we show results only for the best split of \\gls{shae} (in terms of test concordance) since the data for other splits did not differ in a meaningful way (data not shown). Tables S1-S3 contain results for the top correlated features with each latent space dimension for the best split of all cancers and the train- and test-permutation importances for the best split of every cancer (for \\gls{shae} only).\n\n\\subsection{\\gls{blca}}\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=15.7463cm]{./content/figures/fig_plot_shae_heatmap_blca.png} \\caption{Correlation heatmap of all features which had the highest correlation with at least one of the 64 latent space dimensions of \\gls{shae} on the best test split of \\glsxtrfull{blca}.}\\label{fig:BLCA-SHAE-heatmap}\n\\end{figure}\n\nThe highest correlated features for each latent dimension for the best split of bladder cancer included only features belonging to methylation, clinical, and gene expression (Figure \\ref{fig:BLCA-SHAE-heatmap}). This does not necessarily imply that the other variable groups, such as mutation, were disregarded by \\gls{shae}; since we only looked at the top correlated feature for each dimension, this did not capture all information present in latent space.\n\nNevertheless, the features with the highest correlations included multiple with proven consequences for survival. Almost trivially, all clinical features contained in the top correlated features are relevant for survival in bladder cancer. The \\citet{ncipathologicstage2021} defines pathologic stage as the \"stage of cancer (amount or spread of cancer in the body) that is based on how different from normal the cells in samples of tissue look under a microscope\", which is highly relevant to survival. Diagnosis subtype, that is, whether a bladder cancer was papillary or non-papillary, is also highly clinically relevant, where the \\citet{ncipapillary2021} defines a papillary tumor as a \"tumor that looks like long, thin 'finger-like' growths.\" Non-papillary tumors have been shown to imply an increased risk of progression and may act as an independent prognostic factor for disease-free survival \\citep{andius2007prognostic}. The female gender has also been shown to be associated with worse survival rates in \\gls{blca} \\citep{mungan2000gender, dobruch2016gender}, which may not be fully explained by more \"by the more frequent diagnosis of higher stages at first presentation among women\" \\citep{mungan2000gender}. Interestingly, \\citet{datta2006gender} found that when adjusting for socioeconomic factors, five-year survival rates were not significantly different for men and women in pathologic stages one to three but stayed significantly different for patients in stage four. This additionally validates the fact that our model's latent space contained not just gender but also pathologic stage (Figure \\ref{fig:BLCA-SHAE-heatmap}).\n\nThe remaining features primarily contained in the latent space were all strongly associated with gender (Figure \\ref{fig:BLCA-SHAE-heatmap}). All captured methylation features overlap genes on the $X$ chromosome. The single gene expression feature captured among the highest correlated features with the latent space, CYorf15B, has been shown to differ significantly between male and female cancer patients \\citep{tabernero2007patient}. Some of these features have also been shown to potentially have independent prognostic value, however: For example, L1CAM (overlapped by cg10926623) methylation has been shown to have an inverse relationship with L1CAM gene expression in cancers \\citep{notaro2016evaluating}, which is associated with bad prognosis \\citep{schirmer2013epigenetic}. Future work is needed to disentangle the directionality of these relationships, \\emph{i.e.,} whether the methylation and gene expression features contained in our model's latent space were present \\emph{only} due to a strong correlation with gender or whether they were genuinely independent prognostic factors. \n\nThe group-wise permutation importance for \\gls{blca} revealed no additional insights, similarly suggesting that \\gls{shae} was relying virtually exclusively on clinical data to predict survival (Figure \\ref{fig:SHAE-BLCA-permutation-importance}).\n\n\\gls{shae} also captured pathway activations in its latent space (Figure \\ref{fig:BLCA-SHAE-pathways}). Out of the $50$ pathways in the hallmarks of cancers gene sets, $36$ were enriched in at least one of the latent dimensions of \\gls{shae} in the best split of \\gls{blca}. This behavior of strong enrichment was coherent with \\citet{ching2018cox}, and \\citet{kim2020improved}, who both performed GSEA on \\emph{KEGG} pathways and found that most pathways were enriched in at least one of their top hidden nodes.\\footnote{Both \\citet{ching2018cox} and \\citet{kim2020improved} only looked at a certain number of hidden nodes which had maximal variance among all nodes, which they deemed the \"top\" nodes.}\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=15.7463cm]{./content/figures/fig_plot_shae_pathways_blca.png} \\caption{Enriched hallmarks of cancer pathways for each of the 64 latent dimension of  \\gls{shae} on the best split of \\glsxtrfull{blca}.}\\label{fig:BLCA-SHAE-pathways}\n\\end{figure}\n\n\\subsection{\\glsxtrfull{kirp}}\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=15.7463cm]{./content/figures/fig_plot_shae_heatmap_kirp.png} \\caption{Correlation heatmap of all features which had the highest correlation with at least one of the 64 latent space dimensions of \\gls{shae} on the best test split of \\glsxtrfull{kirp}.}\\label{fig:KIRP-SHAE-heatmap}\n\\end{figure}\n\nEven though \\gls{cox} performed much worse on \\gls{kirp} compared to \\gls{blca}, we saw a similar picture when investigating the latent space of \\gls{kirp} on the best split for \\gls{shae} (Figure \\ref{fig:KIRP-SHAE-heatmap}). In particular, the top correlated features with the latent space contained various clinical features like age, gender, and laterality. Similar to bladder cancer, gender is a vital prognostic factor in \\gls{kirp}, with men not only being diagnosed more frequently but also having worse outcomes overall \\citep{mancini2020gender, rampersaud2014effect}. In addition, \\citet{rampersaud2014effect} showed that not only is age an independent prognostic factor for women (but not men), but also that survival differences between men and women were no longer statistically significant for patients older than $59$. This validates the fact that \\gls{shae} picked up on clinical features in our study since both for \\gls{blca} and \\gls{kirp}, direct clinical connections (between gender and stage for \\gls{blca} and between age and gender for \\gls{kirp}) were apparent in the top correlated features of the models latent space. Similar to the latent space for \\gls{blca}, the one for \\gls{kirp} again contained mainly methylation features that overlap genes contained on the $X$ chromosome. Another clinical feature with prognostic value included laterality, which \\citet{roychoudhuri2006cancer} showed to be relevant for cancers of virtually every paired organ (including the kidneys). \n\nThere were only a few other features that were among the highest correlated with any of the latent space dimensions, despite \\gls{cox}'s relatively poor performance on \\gls{kirp} (compared to models having access to multi-omics data). These included multiple potentially cancer-associated features, all from the gene expression group: GPATCH2, a gene newly discovered only a bit over a decade ago, has been shown to be highly expressed in breast cancer patient samples \\citep{lin2009involvement}. It was also demonstrated that downregulation of GPATCH2 expression resulted in decreased growth of breast cancer cells \\citep{lin2009involvement}. The SHMT1 gene plays a role in various human cancers such as lung \\citep{paone2014shmt1}, liver \\citep{dou2019shmt1}, and ovarian \\citep{gupta2017serine}, although no involvement in kidney cancer has been reported thus far. Lastly, the KHSRP gene has similarly been found to play a role in cancer invasion. In particular low expression levels were shown to be associated with better prognosis in lung cancer and other cancers \\citep{yan2019rna, briata2016diverse}.\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_shae_permutation_importance_kirp.png} \\caption{Group permutation feature importance for each input group of \\gls{shae} on the best split of \\glsxtrfull{kirp} using 10 permutations.}\\label{fig:SHAE-KIRP-permutation-importance}\n\\end{figure}\n\nThe permutation importance for kidney cancer told a more nuanced picture than the latent space's heatmap. The train permutation importance suggested that mutation was the most crucial feature group. Still, when comparing this to the test permutation importance (which we care about in the end, the predictions on the test set, that is), we quickly saw that the situation was more complicated (Figure \\ref{fig:SHAE-KIRP-permutation-importance}). Specifically, clinical was still one of the most critical input groups (which matches the many clinical features in Figure \\ref{fig:KIRP-SHAE-heatmap}), but gene expression, methylation, miRNA, and especially \\gls{rppa} also seemed to play a prominent role in the prediction of survival in \\gls{kirp}. We did not see any features from \\gls{mirna} or \\gls{rppa} reflected in the top correlated feature set with the latent space (Figure \\ref{fig:KIRP-SHAE-heatmap}), even though these also had reasonably high group permutation importance (Figure \\ref{fig:SHAE-KIRP-permutation-importance}). This result drives home the point that while plotting the top correlated features in a heatmap can give an interesting first overview of the latent space learned by the model, this kind of plot is in no way a perfect representation of all features used by the model. At the same time, the permutation importance showed that \\gls{shae} was relying on most (although not quite all, \\gls{cnv} and mutation had a test permutation importance close to one) input omics groups on \\gls{kirp} and was thus presumably able to achieve good performance because of this.\n\n\\gls{shae} similarly captured pathway activations for \\gls{kirp}. Of course, some of the activations themselves were different (because \\gls{kirp} is another cancer, and thus the specific pathways which are essential would be different) (Figure \\ref{fig:KIRP-SHAE-pathways}).\n\nThe latent spaces of \\gls{shae} residual looked virtually identical to that of the non-residual variant on both \\gls{blca} (Figure \\ref{fig:BLCA-SHAE-residual-heatmap}) and \\gls{kirp} (Figure \\ref{fig:KIRP-SHAE-residual-heatmap}). This may come as somewhat of a surprise as the goal of the residual models was that clinical data would not have to be \"carried through\" the model and into the latent space (or only insofar as it was useful to learn connections to other features). We will discuss this issue further in Chapter \\ref{sec:discussion}.\n\nOverall, within this section, we showed that \\gls{shae} learned distinct clinical (and, at times, molecular) features relevant for cancer survival. In addition, we showed that \\gls{shae} captured pathway activity, even if gene expression was not among the feature groups most highly correlated with its latent space.\n\n\\section{Surrogate models}\n\\label{sec:surrogate-results}\nRecall that to judge the clinical applicability of our best architecture, the \\glsxtrfull{shae}, we fitted surrogate Lasso linear regression models on clinical and gene expression only. We then compared their performance to all other models trained on clinical and gene expression only. Note that we fitted the Lasso with no penalties on the clinical variables (using the \\emph{relative\\_penalties} argument in \\emph{python-glmnet} \\citep{glmnet, py-glmnet}). We did not fit any surrogate models for \\gls{msae} or \\gls{csae}, since \\gls{shae} was shown to perform much better on \\gls{tcga} in Chapter \\ref{sec:tcga-performance}.\n\n\\begin{table}\n\\caption{Test concordance of all methods trained on clinical and gene expression only across the 10 test splits of all 17 considered TCGA cancers rounded to three decimals. Clin. Cox PH trained on clinical only. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only. Best value bolded by column.}\n\\label{tab:overall-perform-surrogates}\n\\centering\n\\begin{tabular}[t]{cccc}\n\\toprule\nModel & Mean & Median & SD\\\\\n\\midrule\nSHAE (ours) & 0.643 & 0.636 & 0.116\\\\\nSHAE residual (ours) & 0.641 & 0.635 & 0.113\\\\\nSHAE surrogate (ours) & 0.657 & \\textbf{0.652} & \\textbf{0.107}\\\\\nSHAE residual surrogate (ours) & 0.660 & 0.649 & 0.109\\\\\nBF & \\textbf{0.663} & 0.651 & 0.113\\\\\n\\addlinespace\nRB favoring & 0.652 & 0.633 & 0.113\\\\\nRSF & 0.610 & 0.598 & 0.117\\\\\nLasso & 0.623 & 0.610 & 0.119\\\\\nClin. Cox PH & 0.622 & 0.626 & 0.112\\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_surrogate_performance.png} \\caption{Test concordance of all methods trained on clinical and gene expression only across the 10 test splits of all 17 considered TCGA cancers. Clin. Cox PH trained on clinical only. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only.}\\label{fig:surrogate-performance}\n\\end{figure}\n\nThe performance of our surrogate models exceeded that of any other model trained on clinical and gene expression except \\gls{bf} (Figure \\ref{fig:surrogate-performance} and Table \\ref{tab:overall-perform-surrogates}). However, \\gls{bf} beat both of the surrogate models in terms of mean concordance, while it achieved roughly the same median concordance. All multi-omics models and surrogate models beat \\gls{lasso}, \\gls{rsf} and \\gls{cox} when trained on clinical and gene expression only (Figure \\ref{fig:surrogate-performance} and Table \\ref{tab:overall-perform-surrogates}). \n\nInterestingly, \\gls{bf} actually performed \\emph{better} with only clinical and gene expression relative to the \\gls{bf} model with multi-omics data (Table \\ref{tab:tcga-mo-performance-overall} and Table \\ref{tab:overall-perform-surrogates}). To be specific, \\gls{bf} achieved an approximately $0.014$ higher mean as well as $0.014$ higher median concordance across all \\gls{tcga} cancers when trained on clinical and gene expression only, relative to the full multi-omics model. With that, it would have been about as good as the best models (\\gls{shae} and \\gls{rbf}) on the multi-omics data. This result is in line with what \\citet{hornung2019block} found in their study. \\citet{hornung2019block} showed that \\gls{bf} performed better when trained on clinical and gene expression only (relative to multi-omics) and stated that this might be due to the limited information contained in groups beyond clinical and gene expression. That said, it is not always straightforward which input variable groups are important for each cancer, and so expecting researchers or clinicians to choose which groups to use \\emph{a priori} might be challenging.\n\n\\begin{table}\n\\caption{Mean test concordance of all methods trained on clinical and gene expression only across the 10 test splits of each of the 17 considered TCGA cancers rounded to three decimals. Clin. Cox PH trained on clinical only. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only. Best value bolded by column.}\n\\label{tab:surrogate-performance-by-cancer}\n\\centering\n\\resizebox{\\linewidth}{!}{\n\\begin{tabular}[t]{cccccccccccccccccc}\n\\toprule\nModel & BLCA & BRCA & COAD & ESCA & HNSC & KIRC & KIRP & LGG & LIHC & LUAD & LUSC & OV & PAAD & SARC & SKCM & STAD & UCEC\\\\\n\\midrule\nSHAE (ours) & 0.652 & 0.616 & 0.722 & 0.498 & 0.589 & 0.771 & 0.752 & 0.842 & 0.575 & 0.646 & \\textbf{0.628} & 0.593 & 0.536 & 0.594 & 0.636 & 0.546 & 0.735\\\\\nSHAE residual (ours) & 0.653 & 0.613 & 0.729 & 0.515 & 0.599 & 0.769 & 0.749 & 0.838 & 0.556 & 0.645 & 0.627 & 0.602 & 0.536 & 0.558 & 0.631 & 0.549 & 0.727\\\\\nSHAE surrogate (ours) & 0.650 & 0.630 & \\textbf{0.746} & 0.588 & 0.628 & 0.773 & 0.820 & 0.770 & 0.604 & 0.640 & 0.592 & 0.629 & 0.543 & 0.605 & \\textbf{0.657} & \\textbf{0.568} & 0.733\\\\\nSHAE residual surrogate (ours) & \\textbf{0.655} & 0.638 & 0.744 & \\textbf{0.595} & \\textbf{0.645} & 0.781 & 0.814 & 0.795 & 0.610 & 0.644 & 0.583 & \\textbf{0.639} & 0.521 & 0.608 & 0.647 & 0.565 & 0.730\\\\\nBF & 0.637 & \\textbf{0.644} & 0.708 & 0.564 & 0.568 & 0.784 & 0.825 & 0.844 & 0.615 & \\textbf{0.679} & 0.572 & 0.611 & \\textbf{0.599} & 0.658 & 0.640 & 0.560 & \\textbf{0.757}\\\\\n\\addlinespace\nRB favoring & 0.635 & 0.631 & 0.710 & 0.569 & 0.581 & \\textbf{0.789} & \\textbf{0.829} & \\textbf{0.847} & \\textbf{0.622} & 0.621 & 0.544 & 0.575 & 0.583 & 0.664 & 0.623 & 0.554 & 0.713\\\\\nRSF & 0.572 & 0.595 & 0.621 & 0.584 & 0.463 & 0.694 & 0.810 & 0.832 & 0.609 & 0.545 & 0.495 & 0.513 & 0.579 & \\textbf{0.666} & 0.588 & 0.541 & 0.662\\\\\nLasso & 0.584 & 0.589 & 0.662 & 0.470 & 0.597 & 0.784 & 0.822 & 0.830 & 0.568 & 0.592 & 0.527 & 0.552 & 0.563 & 0.655 & 0.606 & 0.545 & 0.645\\\\\nClin. Cox PH & 0.642 & 0.629 & 0.731 & 0.575 & 0.594 & 0.760 & 0.590 & 0.759 & 0.542 & 0.641 & 0.614 & 0.610 & 0.533 & 0.453 & 0.629 & 0.528 & 0.752\\\\\n\\bottomrule\n\\end{tabular}\n}\n\\end{table}\n\nSince we fitted our surrogate models by leaving the clinical variables unpenalized, we also compared the performance in terms of concordance to a \\gls{lasso} model fit on clinical and gene expression, which did not penalize the clinical variables (that is, not a surrogate model, but a Lasso model directly predicting survival). Our surrogate models clearly outperformed Lasso variant which left clinical variables unpenalized (Figure \\ref{fig:surrogate-performance-favor-clinical}). Lasso with unpenalized clinical variables did, however, perform slightly better than Lasso with penalized clinical variables, albeit with higher variance (Figure \\ref{fig:surrogate-performance-favor-clinical}). Lasso with unpenalized clinical variables still performed slightly worse than \\gls{cox}, again with higher variance.\n\nThus, our surrogate models did not merely perform well due to leaving the clinical variables unpenalized, as they easily outperformed Lasso with unpenalized clinical variables. The inferior performance of Lasso with unpenalized clinical variables seemed to be primarily due to a few cancers on which it virtually failed completely (for example, \\gls{sarc}, \\gls{esca} and \\gls{lusc}) (Figure \\ref{fig:surrogate-performance-favor-clinical-by-cancer}).\n\n\\begin{figure}[h]\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_surrogate_performance_favor_lasso.png} \\caption{Test concordance of all methods trained on clinical and gene expression only across the 10 test splits of all 17 considered TCGA cancers. Clin. Cox PH trained on clinical only. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only. Lasso unpenalized clinical trained on clinical and gene expression only to predict survival while leaving clinical variables unpenalized. Surrogate models also left clinical variabes unpenalized.}\\label{fig:surrogate-performance-favor-clinical}\n\\end{figure}\n\n\nMoving on to the surrogate performance of our models, that is how well the surrogate models performed in reproducing the predictions of the \\gls{shae} and \\gls{shae} residual models in terms of $R^2$. The training $R^2$ of our surrogate models for most cancers was generally quite good, with an overall median train $R^2$ across all cancers and splits of $0.909$ for the \\gls{shae} surrogate, and $0.934$ for the \\gls{shae} residual surrogate. However, closer inspection revealed that there was some more nuance. While for most cancers, the surrogate models did perform well in terms of training $R^2$, there were a few cancers where it did quite badly (Figure \\ref{fig:surrogate-train-r2}). These cancers were more-or-less consistent across both surrogate models and included \\gls{esca}, \\gls{lgg} (for the non-residual surrogate) and \\gls{lusc} (although to a lesser extent). While \\gls{lusc} and \\gls{paad} were still acceptable with at least a median train $R^2$ above $0.5$, the train $R^2$ for \\gls{esca} was below $0.5$ for both models. \n\n\\begin{figure}[h]\n    \\centering\n        \\includegraphics[width=15.7463cm,height=10.49753cm]{./content/figures/fig_plot_surrogate_train_r2.png} \\caption{Train $R^2$ of the \\gls{shae} (residual) surrogate models across the 10 test splits of each of the 17 considered \\gls{tcga} cancers.}\\label{fig:surrogate-train-r2}\n\\end{figure}\n\nThe test $R^2$ was more mixed overall, although we did see a fairly direct correspondence between high train $R^2$ and high test $R^2$, for example on \\gls{blca}, \\gls{brca} and \\gls{coad} (Figure \\ref{fig:surrogate-test-r2}). Even though the surrogate models had quite high train $R^2$ overall, on some cancers they also strongly overfit the training data, as evidenced by particularly low test $R^2$ (relative to the corresponding train $R^2$). Some examples for this included \\gls{hnsc} and \\gls{ov}, for both of which the surrogate models achieved a train $R^2$ around $0.9$, while only achieving a test $R^2$ below $0.5$. This suggests that while the models effectively reproduced the predictions of \\gls{shae} and \\gls{shae} residual on the training set for almost all cancers, they struggled to do so on the test set for additional cancers (beyond the set which already had low train $R^2$). Some of the cancers which already had fairly low train $R^2$ predictably turned out with even worse test $R^2$, which was, for example, the case for \\gls{esca} (both surrogates had a median test $R^2$ below $0$). \n\n\\begin{figure}[h]\n    \\centering\n        \\includegraphics[width=15.7463cm,height=10.49753cm]{./content/figures/fig_plot_surrogate_test_r2.png} \\caption{Test $R^2$ of the \\gls{shae} (residual) surrogate models across the 10 test splits of each of the 17 considered \\gls{tcga} cancers.}\\label{fig:surrogate-test-r2}\n\\end{figure}\n\n\nThe fact that most cancers on which the surrogate models achieved a median test $R^2$ of below $0.5$ had a sample size of below $200$ suggests that this issue of low test $R^2$ might be at least partially due to low sample size (Figure \\ref{fig:surrogate-test-r2} and Table \\ref{tab:tcga-overview}). We saw overall high test $R^2$ values for cancers such as \\gls{blca} and \\gls{brca}, both of which contained over $300$ samples (Table \\ref{tab:tcga-overview}). Additionally, various other cancers (\\emph{e.g.,} \\gls{skcm}, \\gls{stad} and most others) had acceptably high test $R^2$, suggesting that the surrogate models were indeed replicating the predictions of the full \\gls{shae} models well, despite only having had access to two input groups (clinical and gene expression).\n\nInterestingly, low test $R^2$ did not necessarily correspond to lower performance relative to the full \\gls{shae} model (Figure \\ref{fig:surrogate-multi-omics-shae-comparison}). For example, even though the surrogate models clearly overfitted to the training set and thus had quite low test $R^2$ on \\gls{ov}, they slightly outperformed the original multi-omics \\gls{shae} models in terms of test concordance. The same held for \\gls{lihc}. This, in turn, validated that low test $R^2$ does not necessarily imply bad performance on the target task. There were, however, also examples, such as \\gls{esca} and \\gls{kirp}, where the surrogate models fell short in terms of both test $R^2$ and test concordance.\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=15.7463cm]{./content/figures/fig_plot_surrogate_performance_compared_to_full_model.png} \\caption{Test concordance of all methods trained on clinical and gene expression only across the 10 test splits of all 17 considered TCGA cancers. Clin. Cox PH trained on clinical only. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only. \\gls{shae} (residual) multi-omics models trained on full multi-omics data.}\\label{fig:surrogate-multi-omics-shae-comparison}\n\\end{figure}\n\nOverall, our surrogate models were very sparse, with the median number of variables selected being $35$ and $37$ across all cancers for the \\gls{shae} surrogate and the \\gls{shae} residual surrogate, respectively (Figure \\ref{fig:overall-surrogate-sparsity}). Lasso and Lasso with unpenalized clinical variables selected a median number of $34$ and $33$ variables, respectively. Still, they had much higher means and variances in the number of features selected (Figure \\ref{fig:overall-surrogate-sparsity}).\\footnote{Recall that since clinical variables were unpenalized, they were always selected for both surrogate models and the Lasso model with unpenalized clinical variables.}\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_surrogate_overall_sparsity_compared.png} \\caption{Overall model sparsity of the surrogate models and the \\gls{lasso}. Surrogates trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} (residual) using clinical and gene expression data only. \\gls{lasso} trained on clinical and gene expression only to predict survival.}\\label{fig:overall-surrogate-sparsity}\n\\end{figure}\n\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_shae_residual_surrogate_sparsity.png} \\caption{Model sparsity of the \\gls{shae} residual surrogate model across the 10 test splits of each of the 17 \\gls{tcga} cancers when trained on clinical and gene expression to predict the predictions $\\hat \\varphi(\\tilde C)$ of \\gls{shae} residual.}\\label{fig:shae-surrogate-sparsity-by-cancer}\n\\end{figure}\n\nOverall, we found that the number of features selected by the surrogate models was fairly stable across splits (that is, there was generally a similar number of variables selected across splits) (Figure \\ref{fig:shae-surrogate-sparsity-by-cancer}). There were no great differences between the overall coefficient structure between the surrogates for \\gls{shae} and \\gls{shae} residual, hence we relegated the plot for \\gls{shae} to the Supplement (Figure \\ref{fig:shae-residual-surrogate-sparsity-by-cancer}). The Lasso more often picked quite different numbers of coefficients between splits, with some splits for a particular cancer having less than ten features while the next had over a hundred selected (Figure \\ref{fig:lasso-sparsity-by-cancer}). In addition, it was readily apparent that the \\gls{lasso} model picked considerably fewer clinical features compared to both \\gls{shae} surrogate and \\gls{shae} residual surrogate since the surrogate models did not penalize clinical variables. The Lasso model which did not penalize clinical variables looked similar to the Lasso in that it had considerable jumps in between the number of variables selected across splits (\\ref{fig:lasso-sparsity-by-cancer-unpenalized}). Of course, the Lasso model with unpenalized clinical variables chose all clinical variables for all cancers and thus picked more clinical variables overall (relative to the Lasso model with penalized clinical variables).\n\n\\begin{figure}\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_lasso_sparsity.png} \\caption{Model sparsity of the \\gls{lasso} model across the the 10 test splits of each of the 17 \\gls{tcga} cancers when trained on clinical and gene expression to predict survival.}\\label{fig:lasso-sparsity-by-cancer}\n\\end{figure}\n\nSeeing that our surrogate models were able to maintain high performance comparable to black-box multi-omics methods while enabling high sparsity, we were interested in explaining this good performance. As mentioned in Chapter \\ref{sec:arch-search}, there are essentially two main possible contributor patterns to the excellent performance achieved by our surrogate models:\n\n\\begin{enumerate}\n    \\item The sparsity pattern, that is, the features selected by our surrogate model.\n    \\item The magnitude of the coefficients (\\emph{i.e.,} weights) learned by our surrogate models.\n\\end{enumerate}\n\nMost likely is that both of these factors play a role. Nevertheless, we wanted to establish how much the performance came down to the features selected instead of the specific weights learned.\n\n\\begin{figure}[h]\n    \\centering\n        \\includegraphics[width=15.7463cm,height=7.87315cm]{./content/figures/fig_plot_feature_selection_performance.png} \\caption{\n        Test concordance of the \\gls{shae} residual surrogate model, \\gls{cox} and a \\gls{rsf} and Ridge regularized Cox PH model across the 10 test splits of all 17 considered TCGA cancers. Clin. Cox PH trained on clinical only. Surrogate trained on the predictions $\\hat \\varphi(\\tilde C)$ from multi-omics \\gls{shae} residual using clinical and gene expression data only. \\gls{rsf} and Ridge regularized Cox PH trained using the same feature set as the \\gls{shae} residual model but to predict survival directly.}\\label{fig:feature-selection-performance}\n\\end{figure}\n\nWe found that if we fitted a Ridge regularized Cox PH model as well as a \\gls{rsf} model with only the features selected by our \\gls{shae} residual surrogate model, we were able to outperform \\gls{cox}, but not quite reach the same performance as the surrogate model (Figure \\ref{fig:feature-selection-performance}). The fact that \\gls{rsf} and Ridge regularized Cox PH with feature selection were able to outperform \\gls{cox} was primarily due to a few cancers on which \\gls{cox} vastly underperformed (presumably due to lack of access to gene expression data) (Figure \\ref{fig:feature-selection-performance-by-cancer}). This was the case for example on \\gls{kirp}, \\gls{sarc} and \\gls{lgg}. On most other cancers, the feature selected \\gls{rsf} and Ridge models in fact underperform \\gls{cox}, while the surrogate model continued to outperform \\gls{cox} (Figure \\ref{fig:feature-selection-performance-cancers-excluded}).\n\nThus, using the same features as our surrogate model clearly helped the performance of the \\gls{rsf} and Ridge regularized Cox PH models (recall that before feature selection, both \\gls{rsf} and \\gls{lasso} underperformed \\gls{cox}). Specifically, the Ridge with feature selection had median and mean test concordances across all cancers of $0.647$ and $0.635$ while the results for \\gls{lasso} fitted on all clinical and gene expression features were $0.623$ and $0.610$ respectively. For \\gls{rsf}, the values for the feature selected model were $0.636$ and $0.625$ while the model fitted on all features from the clinical and gene expression groups achieved scores of $0.610$ and $0.598$. However, the feature-selected models did still not perform \\emph{on par} with the surrogate model.\\footnote{We admit that the comparison between \\gls{lasso} and the Ridge model with feature selection is limited since they use different forms of regularization. We did not, however, want to fit a Lasso on the features selected by the surrogate model to ensure that the model used all features (the \\gls{lasso} might have set additional coefficients to zero).} This implies that the magnitude of the weights learned by the surrogate model may have played an additional role in their good performance. We will further discuss this result and possible meanings and implications within the Discussion in Chapter \\ref{sec:discuss-arch-search}. \n\nHaving presented our three main groups of results, we now discuss some of the takeaways of our study before concluding the thesis with a summary.", "meta": {"hexsha": "d5205983edab03c0bdfed69cb32353cc6628e116", "size": 52660, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/content/chapter-results.tex", "max_stars_repo_name": "dnwissel/msc_thesis", "max_stars_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/content/chapter-results.tex", "max_issues_repo_name": "dnwissel/msc_thesis", "max_issues_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/content/chapter-results.tex", "max_forks_repo_name": "dnwissel/msc_thesis", "max_forks_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-24T20:41:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-24T20:41:39.000Z", "avg_line_length": 152.1965317919, "max_line_length": 1643, "alphanum_fraction": 0.7678883403, "num_tokens": 14900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.43728119956310535}}
{"text": "\\graphicspath{ {./img/intro/} }\r\n\r\n\\chapter{Introduction}\r\n\r\nThis set of lecture notes for the course {\\bf Introduction to the Finite \r\nElement Method} is part of the learning resources used in the flipped \r\nclassroom\\footnote{``Inverting the classroom means that events that have \r\ntraditionally taken place inside the classroom now take place outside the \r\nclassroom and vice versa.'' \\citep{lage2000}.} version of the subject \r\nadopted at Universidad EAFIT. In the flipped class approach, the students cover \r\nmost of the theoretical aspects through independent home study, while the class \r\ntime is invested in various learning activities conducted with support from the \r\ninstructor and strongly based on peer-to-peer interaction. In this context, by \r\ncollecting and summarizing fundamental numerical, theoretical and computational \r\naspects required in the formulation of finite element algorithms, the lecture \r\nnotes are intended to serve as a self-study guide. The notes are not as \r\nrigorous as material existing in published literature and are certainly not \r\nclose in quality to excellent textbooks available in the subject.\r\n\r\nThis introductory version of the course covers fundamental theoretical and \r\ncomputational aspects required in the formulation of finite element methods as \r\na numerical solution technique of boundary value problems. Although the studied \r\nalgorithms are general the course evolves around the model of the linearized \r\ntheory of elasticity. The fundamental theoretical framework is mainly covered \r\nin the lecture notes and some referenced complementary material. The various \r\ntheoretical topics are then associated with in-class learning activities \r\ninvolving some degree of computational work. Most of these activities are given \r\nin the form of Jupyter Notebooks.\\footnote{Jupyter notebooks are open-source \r\nweb applications used to create and share documents that contain live code, \r\nequations, visualizations, and narrative text.} In addition to the lecture \r\nnotes and notebooks, the authors have also developed {\\bf \r\nSolidsPy}\\footnote{Check the documentation in \r\n\\url{https://solidspy.readthedocs.io} \\cite{solidspy}.} which \r\nis a complete Python-based finite element code to conduct stress analysis over \r\narbitrary two-dimensional elastic domains. The code, which follows a modular \r\nstructure facilitates the realization of learning activities in the form of (i) \r\nfull stress analysis simulations (ii) implementation of intermediate steps \r\naimed at covering the various steps in the FE algorithm and (iii) extensions to \r\nincorporate additional kinematic models. In the rest of this introductory \r\nchapter, we present a simple problem of a mechanical spring-mass system that \r\nresembles the final form of a finite element algorithm and which serves to \r\njustify why we cover the material in the specific order proposed here. Then we \r\ndescribe the topics covered in the notes and in the final part we indicate how \r\nto use the material.\r\n\r\n\\section*{Introductory problem}\r\n\\subsection*{A simple discrete system}\r\nThe simple case of a mechanical spring-mass system considered next resembles most of the algorithmic aspects of a finite element code. This system serves as a nice motivational example since the problem is already discrete thus avoiding the discussion of mathematical complexities. As will be presented throughout the course one of the goals of the finite element algorithm, when applied to a continuous system represented in terms of a boundary value problem, is to reformulate it as a discrete system fully analogous to the simple problem.\r\n\r\nThe system consists of an assemblage of masses joined by different springs submitted to time varying loads. For later purposes it is convenient to associate a spring with the concept of a finite element and a mass with a nodal point in a finite element algorithm.\r\n\r\nThe system may be like the one shown in \\cref{fig:bathe} where the masses are \r\nrepresented by ``cars'' connected by springs (or finite elements) of different \r\nstiffness coefficients.\r\n\r\n\\begin{figure}[h]\r\n\\centering\r\n\\includegraphics[width=8cm]{spring_system.pdf}\r\n\\caption{Typical assemblage of springs and masses.}\r\n\\label{fig:bathe}\r\n\\end{figure}\r\n\r\n\r\nConsidering a typical spring (or finite element), \\cref{fig:springel}\r\n\r\n\\begin{figure}[h]\r\n\\centering\r\n\\includegraphics[width=6cm]{springel.pdf}\r\n\\caption{Typical spring element.}\r\n\\label{fig:springel}\r\n\\end{figure}\r\n\r\none finds that under a relative displacement $\\delta u = u_1 - u_2$  the spring develops a force :\r\n\r\n\\[f_1 = K(u_1 - u_2)\\]\r\n\r\nwhile equilibrium of the spring requires\r\n\r\n\\[f_1 + f_2 = 0.\\]\r\n\r\nThe force-displacement and equilibrium equations can be combined into:\r\n\r\n\\begin{equation}\r\n    \\begin{Bmatrix}\r\n        f_1\\\\\r\n        f_2\r\n    \\end{Bmatrix} =\r\n    K\\begin{bmatrix}\r\n          1.0 & -1.0\\\\\r\n        - 1.0 & 1.0\r\n    \\end{bmatrix}\r\n    \\begin{Bmatrix}\r\n        u_1\\\\\r\n        u_2\r\n    \\end{Bmatrix}.\r\n    \\label{eq:Kspring}\r\n\\end{equation}\r\n\r\n\\Cref{eq:Kspring} resembles a first fundamental aspect displacement based finite element methods which is the fact that the problem is described in terms of displacements of specific points (or nodes) and where internal element forces are found from these nodal displacements via a constitutive relationship. In the case of a continuous problem an analogous force-displacement relationship is established using interpolation theory together with equilibrium statements.\r\n\r\n\r\nOn the other hand, the equilibrium equation for a typical mass $m_j$ with displacement $u_j$  (see \\cref{fig:dclmass}) and assumed to be attached to springs $i$ and $i+1$ reads\r\n\\begin{equation}\r\nf_2^i + f_1^{i + 1} + m_j \\dv{V_j}{t} = P_j.\r\n\\label{eq:equilmass}\r\n\\end{equation}\r\n\r\nThis equation can be written in terms of displacements after expressing the involved forces $f_2^i$ and $f_1^{i + 1}$ using terms from equations like \\ref{eq:Kspring}\r\n\r\n\\[(K^i + K^{i + 1}) u_j - K^i u_{j - 1} - K^{i + 1} u_{j + 1} + m_j\\dv{V_j}{t} = P_j .\\]\r\n\r\n\r\n\\begin{figure}[H]\r\n\\centering\r\n\\includegraphics[width=6cm]{dcl_mass.pdf}\r\n\\caption{Free body diagram for a typical mass connected to springs $i$ and $i+1$.}\r\n\\label{fig:dclmass}\r\n\\end{figure}\r\n\r\n\r\nWriting the elemental equilibrium equations for the springs in terms of the corresponding mass displacements $u_{j - 1}$, $u_j$ and $u_{j + 1}$ and generalizing the coefficients notation we get:\r\n\r\n\\[\\left\\{ {\\begin{array}{*{20}{c}}\r\n{f_1^i}\\\\\r\n{f_2^i}\r\n\\end{array}} \\right\\} = \\left[ {\\begin{array}{*{20}{c}}\r\n{k_{11}^i}&{k_{12}^i}\\\\\r\n{k_{21}^i}&{k_{22}^i}\r\n\\end{array}} \\right]\\left\\{ {\\begin{array}{*{20}{c}}\r\n{{u_{j - 1}}}\\\\\r\n{{u_j}}\r\n\\end{array}} \\right\\}\\]\r\n\r\nand\r\n\r\n\\[\\left\\{ {\\begin{array}{*{20}{c}}\r\n{f_1^{i + 1}}\\\\\r\n{f_2^{i + 1}}\r\n\\end{array}} \\right\\} = \\left[ {\\begin{array}{*{20}{c}}\r\n{k_{11}^{i + 1}}&{k_{12}^{i + 1}}\\\\\r\n{k_{21}^{i + 1}}&{k_{22}^{i + 1}}\r\n\\end{array}} \\right]\\left\\{ {\\begin{array}{*{20}{c}}\r\n{{u_j}}\\\\\r\n{{u_{j + 1}}}\r\n\\end{array}} \\right\\}\\]\r\n\r\nwhich gives for the equilibrium equation of the $m_j$ mass:\r\n\r\n\\[k_{21}^i{u_{j - 1}} + (k_{22}^i + k_{11}^{i + 1}){u_j} + k_{12}^{i + 1}{u_{j + 1}} + {m_j}\\frac{{d{V_j}}}{{dt}} = {P_j}.\\]\r\n\r\nIf one the other hand we also consider the contributions from the springs $K^i$ and $K^{i+1}$ to the equilibrium of masses $m_{j-1}$ and $m_{j+1}$ respectively we have the following matrix block:\r\n\r\n\r\n\r\n\\[\\left[ {\\begin{array}{*{20}{c}}\r\n{}&{}&{}&{}\\\\\r\n{}&{k_{11}^i}&{k_{12}^i}&{}\\\\\r\n{}&{k_{21}^i}&{k_{22}^i + k_{11}^{i + 1}}&{k_{12}^{i + 1}}\\\\\r\n{}&{}&{k_{21}^{i + 1}}&{k_{22}^{i + 1}}\r\n\\end{array}} \\right].\\]\r\n\r\nConsideration of the complete system of masses leads to a system of linear equations of the general form\r\n\r\n\r\nConsidering now the complete system of masses and springs leads to a system of linear equations of the form\r\n\\begin{equation}\r\n\\left[ {{K_G}} \\right]\\left\\{ {{U_G}} \\right\\} + \\left[ M \\right]\\left\\{ {{A_G}} \\right\\} = \\left\\{ {{F_G}} \\right\\}.\r\n\\label{eq:global}\r\n\\end{equation}\r\nwhere each equation represents the equilibrium of a given mass.\r\n\r\nThe process of forming these global coefficient matrices by adding the contribution from different elements (springs) to the equilibrium equations of the different masses is known as element assembly and this can be achieved in a systematic way by establishing the connection between the global and local degrees of freedom. This can be accomplished through an operator storing in each row the global degrees of freedom corresponding to each element. For instance, \\cref{fig:IBC} shows elements $K^i$ and $K^{i+1}$ and the global degrees of freedom corresponding to masses $m_{j-1}$, $m_j$ and $m_{j+1}$. The corresponding entries of the $DME$ operator for these elements are given by:\r\n\r\n\r\n\\[DME = \\left[ {\\begin{array}{*{20}{c}}\r\n{}&{}\\\\\r\n{j - 1}&j\\\\\r\nj&{j + 1}\\\\\r\n{}&{}\r\n\\end{array}} \\right]\\]\r\n\r\n\\begin{figure}[H]\r\n\\centering\r\n\\includegraphics[width=12cm]{ibc}\r\n\\caption{Global degrees of freedom connected to the spring elements $K^i$ and $K^{i+1}$ respectively.}\r\n\\label{fig:IBC}\r\n\\end{figure}\r\n\r\nand the assembly process from the contribution of these elements to the global coefficient matrix for elements $i$ and $i+1$ proceeds as:\r\n\r\n\r\n\\[\\begin{array}{l}\r\n{K_{j - 1,j - 1}} \\leftarrow {K_{j - 1,j - 1}} + k_{11}^i\\\\\r\n{K_{j - 1,j}} \\leftarrow {K_{j - 1,j}} + k_{12}^i\\\\\r\n{K_{j,j - 1}} \\leftarrow {K_{j,j - 1}} + k_{21}^i\\\\\r\n{K_{j,j}} \\leftarrow {K_{j,j}} + k_{22}^i\r\n\\end{array}\\]\r\n\r\nand\r\n\r\n\\[\\begin{array}{l}\r\n{K_{j,j}} \\leftarrow {K_{j,j}} + k_{11}^{i + 1}\\\\\r\n{K_{j,j + 1}} \\leftarrow {K_{j,j + 1}} + k_{12}^{i + 1}\\\\\r\n{K_{j + 1,j}} \\leftarrow {K_{j + 1,j}} + k_{21}^{i + 1}\\\\\r\n{K_{j + 1,j + 1}} \\leftarrow {K_{j + 1,j + 1}} + k_{22}^{i + 1}\r\n\\end{array}\\]\r\n\r\nThe system given by \\cref{eq:global} and assembled with the aid of the $DME$ operator can be solved for the global displacements $U_G$ and later use these displacements to compute the element forces.\r\n\r\nThis algorithmic strategy of assembling the contribution from all the elements to formulate the global equilibrium equations of the system is typical of finite element methods. However in the case of a BVP the continuous system must be converted first into a discrete system through different numerical and mathematical methods. A broad description of the method is described in \\cref{algo:springs}.\r\n\r\n\\begin{algorithm}[H]\r\n    \\SetAlgoLined\r\n    \\KwData{Problem parameters; NUMNP, NUMEL, NMATP}\r\n    \\KwResult{Displacements and spring forces}\r\n    Create $DM$E operator\\;\r\n    Assemble $K^G$, $F^G$\\;\r\n    \\While{$j \\leq 1, NUMEL$}{\r\n        $K^G \\leftarrow K^G+K^i$\\\\\r\n        $F^G \\leftarrow F^G+F^i$\\\\\r\n    }\r\n    Solve $[K^G]U=F^G$\\\\\r\n    Find internal forces\r\n    \\caption{Springs Algorithm.}\r\n    \\label{algo:springs}    \r\n\\end{algorithm}\r\n\r\nThe full implementation of the mass-springs system is given in an accompanying notebook in the course REPO.\r\n\\newpage\r\n\\section*{Contents of the course}\r\nThe course is divided in three parts as follows:\r\n\r\n\\begin{itemize}\r\n\\item Part 1 covers classical numerical methods such as interpolation theory and numerical integration within the context of finite element methods. These methods are shown to be fundamental in the conversion of the continuous system into a discrete system analogous to the discussed mass-springs system. The numerical methods are studied from its theoretical and computational aspects and the suggested learning activities are described in notebooks 1 through 6.\r\n\r\n\\item Part 2 presents the boundary value problem corresponding to the model of the linearized theory of elasticity and in particular its description through formulations which are suitable for a solution in terms of finite elements algorithms. The boundary value problem is covered in notebook 7.\r\n\r\n\\item Part 3 concentrates on the formulation of the elasticity boundary value \r\nproblem in a finite element algorithm. The algorithm and several related \r\naspects are covered in notebooks 8 through 11, while notebook 12 contains a \r\nbrief reference to the course finite element code SolidsPy.\r\n\\end{itemize}\r\n\r\nThe main set of accompanying notebooks also includes NB-0 which makes an introduction to the use of notebooks and a quick reference to data flow structures in Python. The set of lecture notes also include an appendix section presenting some more mathematical aspects of the method and additional tools that may result useful depending on the student's abilities.\r\n\r\n\r\n\\paragraph*{How to follow the course?\\footnote{This set of lecture notes and \r\nadditional course material has been developed as part of the sabatical period \r\nof the first author and with the collaboration of the second author Nicolas \r\nGuarin-Zapata. The development of the notebooks and design of the learning \r\nactivities in these notebooks has been developed thanks to the advisory of \r\nCamilo Vieira.}}\r\n\r\nThe course and its different resources have been created to be used in a flipped class environment or as a self study material. In the formal course, as thought in the graduate program at Universidad EAFIT, it is recommended to follow the proposed sequence of activities starting with the section covering numerical methods as described previously.This same sequence is also recommended for independent learners with no previous knowledge on fundamental numerical methods like interpolation theory and numerical integration. More advanced students, with previous backgrounds on mathematical analysis and numerical methods can test their actual abilities by developing the activities proposed on NB-4 and NB-6 and then moving directly into Chapter 4 discussing the boundary value problem.\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "43183c24061b16cf0e6e292610424bb2c0f96363", "size": 13675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "course_notes/src/intro.tex", "max_stars_repo_name": "AppliedMechanics-EAFIT/Introductory-Finite-Elements", "max_stars_repo_head_hexsha": "a4b44d8bf29bcd40185e51ee036f38102f9c6a72", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2019-11-26T13:28:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T17:57:11.000Z", "max_issues_repo_path": "course_notes/src/intro.tex", "max_issues_repo_name": "jgomezc1/Introductory-Finite-Elements", "max_issues_repo_head_hexsha": "a4b44d8bf29bcd40185e51ee036f38102f9c6a72", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "course_notes/src/intro.tex", "max_forks_repo_name": "jgomezc1/Introductory-Finite-Elements", "max_forks_repo_head_hexsha": "a4b44d8bf29bcd40185e51ee036f38102f9c6a72", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-02-17T07:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T07:54:28.000Z", "avg_line_length": 52.7992277992, "max_line_length": 788, "alphanum_fraction": 0.7305301645, "num_tokens": 3573, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.43714723009917383}}
{"text": "%!TEX root =  ../main.tex\n\\subsection{Chapter Review}\nThis chapter was about functions, and how they model so much of reality.  Functions can be\ndescribed numerically (tables), algebraically (formula), graphically (Cartesian plane curves), or\nverbally (technical language).  Some functions we have seen before or will see in this course\nare linear, quadratic, exponential, power, rational, logarithmic, and periodic.\nYou need to have memorized the simplest form of each type of equation (Tab.~\\ref{tab:generalequations}).\n\n\\columntable[-0.75in]{2.8in}{\n    \\textbf{Linear:}\\\\  $y=m\\cdot{}b$\n\n    \\medskip\n\n    \\textbf{Inversely Proportional:}\\\\\n    $y=\\frac{k}{x}$\n\n    \\medskip\n\n    \\textbf{Power:}\\\\\n    $y=a\\cdot{}x^b$\n\n    \\medskip\n\n    \\textbf{Quadratic:}\\\\\n    $y=ax^2+bx+c$\n\n    \\medskip\n\n    \\textbf{Exponential:}\\\\\n    $y=a\\cdot{}b^x$\n\n    \\medskip\n\n    \\textbf{Logarithmic:}\\\\\n    $y=a+b\\ln{x}$\n\n    \\medskip\n\n    \\textbf{Periodic:}\\\\\n    $y=a\\cdot\\sin(b(x-c))+d$\n    }{General equations\\label{tab:generalequations}}\n\n\nYou should review the graphs of each of these.  In fact, you should attempt to engage all\nthese forms in all four ways.\n\nFunctions are written in function notation, which looks annoyingly like multiplication.\nFunctions can have operations done on them, as numbers do, only they have two place where\noperators may be applied: inside (before) and outside (afterwards).  Outside effects the output\n(y) and is reasonable.  Inside effects x and is contrarian!  Adding translates (moves) the graph.\nMultiplying stretches (dilates) the graph.  Negatives `flip' the graph.  Graphs that are the same when flipped\nleft/right are called even, like even powers of x.  Graphs that look the same when they are\nflipped left/right \\emph{and} up/down are called odd, like odd powers of x.  The calculator can help us turn\nnumerical data into function notation via its many regression functions.\n\nSome questions you should be prepared to address are:\nWhat are functions?  What are some of the basic types of functions?  What are the four ways\nwe describe functions in this chapter?  How do we move between the various descriptions?\nWhat happens to $f(x)$ as we vary four constants, like this: $a\\cdot{}f(b(x+c))+d$?\nWhat are some of the differences between our models and reality?  What have previous classes\nshown you to be the nature of the mathematic task?  What is technical (vs ordinary or poetic)\nlanguage?  What role does technical language play in your life, now and presumably in the future?\n\n\n\\begin{figure}\n\\begin{centering}\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=5cm, semithick]\n  \\tikzstyle{every state}=[fill=red,draw=none,text=white]\n\n  \\node[state,minimum size=2cm] (A)                    {Graph};\n  \\node[state,minimum size=2cm]         (B) [above right of=A] {Data};\n  \\node[state,minimum size=2cm]         (D) [above left of=B] {Equation};\n  \\node[state,minimum size=2cm]         (C) [above left of=A] {Verbal};\n\n  \\path (A) edge [bend right=5]              node[below,sloped] {``read''} (B)\n            edge [bend right=5] node[above,sloped] {``describe''} (C)\n            edge [bend right=5,dotted]  node[below,sloped]  {``find''} (D)\n            edge [loop below]\tnode {``change''} (A)\n           (B) edge[bend right=5] node [above,sloped] {``plot''} (A)\n           edge [loop right] node {``convert''} (B)\n           edge [bend right=5]  node[above,sloped] {``regress''} (D)\n           edge [bend right=20] node [above,sloped] {``characterize''} (C)\n           (C) edge[bend right=5] node[below,sloped] {``sketch''} (A)\n           edge [bend right=5] node[below,sloped] {``build''} (D)\n           edge [bend right=20] node[below,sloped] {``estimate''} (B)\n           edge [loop left] node {``paraphrase''} (C)\n           (D) edge [loop above] node {``algebra''} (D)\n           edge [bend right=5] node[below, sloped] {``tabulate''} (B)\n           edge [bend right=5] node[above,sloped] {``explain''} (C)\n           edge [bend right=5,dotted] node[below,sloped] {``graph''} (A);\n\\end{tikzpicture}\n\\caption{Some possible words to describe moving among the four representations\\label{fig:16relationships}}\n\\end{centering}\n\\end{figure}\n\nFigure~\\ref{fig:16relationships} is not the final word(s) on relating the four representations,\nbut it is supposed to get you thinking.  We often manipulate symbols and change one\nequation type into another, but we can do the same with graphs.  Paper does not\nallow it, but couldn't we build an object that changes color over time, in order to\nrepresent a function?  Data could be changed from absolute $x$ and $y$ to\n``number of steps since last'' and ``percent change.''  Try to come up with a simple \nmodel of a natural phenomenon and see how many relationships you can\nfulfill.\n\n\\subsection{Chapter Test}\n\\noindent\\makebox[\\textwidth]{\\includegraphics[width=\\paperwidth]{ch01/01testA.pdf}}\n\\newpage\n\\noindent\\makebox[\\textwidth]{\\includegraphics[width=\\paperwidth]{ch01/01testB.pdf}}\n \n \n ", "meta": {"hexsha": "bbf3d11133b396e87dd873c350503bc66ded146a", "size": 4988, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch01/0106.tex", "max_stars_repo_name": "aquatiki/AnalysisTextbook", "max_stars_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-10-08T15:05:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-07T12:32:53.000Z", "max_issues_repo_path": "ch01/0106.tex", "max_issues_repo_name": "aquatiki/AnalysisTextbook", "max_issues_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch01/0106.tex", "max_forks_repo_name": "aquatiki/AnalysisTextbook", "max_forks_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.9369369369, "max_line_length": 110, "alphanum_fraction": 0.6868484362, "num_tokens": 1445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7826624789529375, "lm_q1q2_score": 0.43698158945286686}}
{"text": "\\documentclass{article}\n\n%%%%%% Include Packages %%%%%%\n\\usepackage{sectsty}\n\\usepackage{amsmath,amsfonts,amsthm,amssymb}\n\\usepackage{fancyhdr}\n\\usepackage{lastpage}\n\\usepackage{setspace}\n\\usepackage{graphicx}\n\\usepackage{array}\n\n%%%%%% Formatting Modifications %%%%%%\n\n\\usepackage[margin=2.5cm]{geometry} %% Set margins\n\\sectionfont{\\sectionrule{0pt}{0pt}{-8pt}{0.8pt}} %% Underscore section headers\n\\setstretch{1.2} %% Set 1.2 spacing\n\n%%%%%% Set Homework Variables %%%%%%\n\n\\newcommand{\\hwkNum}{11}\n\\newcommand{\\hwkAuthors}{Ben Drucker}\n\n%%%%%% Set Header/Footer %%%%%%\n\n\\pagestyle{fancy} \n\\lhead{\\hwkAuthors} \n\\rhead{Homework \\#\\hwkNum}\n\\rfoot{\\textit{\\footnotesize{\\thepage /\\pageref{LastPage}}}}\n\\cfoot{}\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n%%%%%% Document %%%%%%\n\n\\begin{document}\n\n\\title{Homework \\#\\hwkNum}\n\\author{\\hwkAuthors}\n\\date{}\n\n\\maketitle\n\n%%%%%% Begin Content %%%%%%\n\n\\section*{7.3}\n\t\\subsection*{32}\n\t\tCI: $\\overline{X} \\pm t \\frac{S}{\\sqrt{n}} = 1584 \\pm t_{19, .005} \\frac{607}{\\sqrt{20}} = 1584 \\pm 2.861 \\frac{607}{\\sqrt{20}} = (1195.68, 1972.32)$\n\t\\subsection*{34}\n\t\t\\subsubsection*{a)}\t\t\t\t\n\t\t\t$8.48-1.771 \\frac{.79}{\\sqrt{14}} = 8.11.$ With 95\\% confidence, the true mean of all joints is in the interval (8.11, $\\infty$). For an infinite number of sample confidence intervals, 95\\% will include the true mean.  A normal distribution is assumed.\n\t\t\\subsubsection*{b)}\n\t\t\t$8.48 - 1.771 * .79 \\sqrt{1+\\frac{1}{14}} = 7.03$. If we calculate this bound for an infinite number of samples, 95\\% will give the lower bound for future values of a joint.\n\\section*{7 Supplement}\n\t\\subsection*{50}\n\t\t$\\overline{x} = \\frac{229.764+233.502}{2} 231.63; t_{.025, 5-1} = 2.78\\\\\n\t\t233.502 - 229.764 = 3.74; 2*2.78 \\frac{s}{\\sqrt{5}} =s \\rightarrow s = \\frac{\\sqrt{5}*3.74}{2*2.78} = 1.51\\\\\n\t\tt_{.005,4} = 4.604 \\\\\n\t\t231.63 \\pm 4.604 \\frac{1.51}{\\sqrt{5}} = 213.63 \\pm 3.1$\n\t\t\n\t\\subsection*{60}\t\t\t \n\t\t$(z_Y+z_{\\alpha - Y} \\frac{s}{\\sqrt{n}}) \\rightarrow \\min(z_Y+z_{\\alpha - Y} \\frac{s}{\\sqrt{n}}) \\rightarrow \\min[\\Phi^{-1}(1-Y) + \\Phi^{-1} (1-\\alpha + Y).$\n\t\t\\\\ Setting the derivative equal to 0:\n\t\t\\\\ $ \\frac{1}{\\Phi(1-Y)} = \\frac{1}{\\Phi(1-\\alpha+Y)} \\Rightarrow Y = \\frac{\\alpha}{2}$\n\\section*{8.1}\n\t\\subsection*{2}\n\t\t\\subsubsection*{a)}\n\t\t\tYes.\n\t\t\\subsubsection*{b)}\n\t\t\tNo, because $H_0$ is not an equality claim.\n\t\t\\subsubsection*{c)}\n\t\t\tNo, because $H_a$ is the equality claim instead of $H_0$.\n\t\t\\subsubsection*{d)}\n\t\t\tNo. $\\mu_1 -\\mu_2$ should appear in $H_a$.\n\t\t\\subsubsection*{e)}\n\t\t\tNo because $S^2$ is a statistic and shouldn't be into a hypothesis.\n\t\t\\subsubsection*{f)}\n\t\t\tNo, both $H_0$ and $H_a$ can't be equality claims.\n\t\t\\subsubsection*{g)}\n\t\t\tYes\n\t\t\\subsubsection*{h)}\n\t\t\tYes\n\t\\subsection*{4}\t\n\t\tVersus $H_a: \\mu < 5$. In this case, the type I error should be avoided at all costs whereas the type II error is not as serious.\n\t\\subsection*{6}\n\t\t$H_0: \\mu  = 40; H_a: \\mu \\not = 40. \\mu \\not = 40$ is interesting for the manufacturer in either direction. A type I error would be rejected a fuse where $\\mu$ is actually 40. A type 2 error would be letting a fuse through where $\\mu$ is 40.\n\t\t\t\t\n\t\t\t\t \n\t \t\t\n%%%%%% End Content %%%%%%      \n\\end{document}", "meta": {"hexsha": "aecd2313ddca1a19535afde85af54234e311d041", "size": 3214, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Spring 2013/STAT W1211 - Statistics/Homework/Homework 11/Homework 11.tex", "max_stars_repo_name": "bendrucker/columbia", "max_stars_repo_head_hexsha": "0661e729fa0c7cb792fc31a2da77f2b44874d8a1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-05-09T03:30:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T03:38:03.000Z", "max_issues_repo_path": "Spring 2013/STAT W1211 - Statistics/Homework/Homework 11/Homework 11.tex", "max_issues_repo_name": "bendrucker/columbia", "max_issues_repo_head_hexsha": "0661e729fa0c7cb792fc31a2da77f2b44874d8a1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Spring 2013/STAT W1211 - Statistics/Homework/Homework 11/Homework 11.tex", "max_forks_repo_name": "bendrucker/columbia", "max_forks_repo_head_hexsha": "0661e729fa0c7cb792fc31a2da77f2b44874d8a1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-01-24T17:48:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-09T01:38:54.000Z", "avg_line_length": 35.7111111111, "max_line_length": 255, "alphanum_fraction": 0.643434972, "num_tokens": 1212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7772998714925403, "lm_q1q2_score": 0.4369797218946569}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\n \\addtolength{\\oddsidemargin}{-.5in}\n\\addtolength{\\evensidemargin}{-.5in}\n\\addtolength{\\textwidth}{1.0in}\n\\addtolength{\\topmargin}{-.5in}\n\\addtolength{\\textheight}{1.0in}\n\n\n\\usepackage{cite}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{xcolor}\n\\usepackage{color}\n\\usepackage{bbding}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}{Corollary}\n\n\\begin{document}\n\n\\title{Group 4: The Kaczmarz Algorithm}\n\\author{Wei Deng, Nicole Eikmeier, Nate Veldt, and Xiaokai Yuan}\n\\maketitle{}\n\n\n\\section{Introduction}\nProject Objective:\n\nGiven a large sparse linear system $Ax = f$, of order $n = 10^6$ that can be effectively reduced to a banded matrix using the reordering scheme ``reverse Cuthill-McKee\", use the method of Row Projection, accelerated via the Conjugate Algorithm to yield a parallel solver. Compare the robustness and parallel scalability/speed with preconditioned Krylov subspace methods preconditioned via approximate LU-factorization.\n\n\\vspace{.2in}\n\nThe Kaczmarz Algorithm is a row projection method which is equivalent to solving $AA^Ty = f$ using the Gauss-Siedel iteration, with $x = A^Ty$. In Kaczmarz we consider each equation as a hyperplane:\n$$S_i=\\{x:A_ix-b_i=0\\}$$ for $i=1,2,...$, where $A_i$ and $b_i$ are $i$th row of matrix $A$ and vector $b$. So the problem is transformed into finding the coordinates of the point of intersection of these hyperplanes.  See figure \\ref{fig:ClassKacz} for a visualization of the problem.\n\n\\begin{figure}[htbp]\n\\begin{centering}\n%\\begin{minipage}[b]{0.8\\linewidth}\n\\includegraphics[width=5in]{Images/Classical_Kaczmarz}\n\\caption{2-Partition Case of the Kaczmarz Algorithm}\n\\label{fig:ClassKacz}\n%\\end{minipage}\n\\end{centering}\n\\end{figure}\n\nFrom this basic idea we use symmetrization and acceleration via the CG method to improve the procedure. The details will be given carefully in the following sections.\n\n\n\n\n\\section{Implementation}\n\n\n%------------------------------------------------\n%------------------------------------------------\n% REVERSE CUTHILL-MCKEE\n%------------------------------------------------\n%------------------------------------------------\n\n\\subsection{Reverse Cuthill-McKee and the Woodbury Formula}\nThe first step in our implementation is to transform the sparse matrix $A$ to a banded form using Reverse Cuthill-McKee. We can perform a symmetric permutation with matrix $P$ so that $P^TAP$ is banded. In figure \\ref{fig:v3}, we see the result from Matlab of Reverse Cuthill Mckee on the stomach data set. The band size is nice and small.\n\n%\\begin{figure}[ht]\n%\\centering\n%\\begin{minipage}[b]{0.45\\linewidth}\n%\\includegraphics[width=2in]{Images/SparseA.jpg}\n%\\caption{$A$ sparse, non-symmetric}\n%\\end{minipage}\n%\\quad\n%\\begin{minipage}[b]{0.45\\linewidth}\n%\\includegraphics[width=2in]{Images/Arcm.jpg}\n%\\caption{$P^TAP$ (banded)}\n%\\label{fig:banded}\n%\\end{minipage}\n%\\end{figure}\n\n\\begin{figure}[ht]\n\\centering\n\\begin{minipage}[b]{0.45\\linewidth}\n\\includegraphics[width=2in]{Images/SparseA_v5.jpg}\n\\caption{$A$ sparse, non-symmetric}\n\\label{fig:v5}\n\\end{minipage}\n\\quad\n\\begin{minipage}[b]{0.45\\linewidth}\n\\includegraphics[width=2in]{Images/Arcm_v3.jpg}\n\\caption{$P^TAP$ (banded)}\n\\label{fig:v3}\n\\end{minipage}\n\\end{figure}\n\nFor some problems the bandwidth could be too large after using Reverse Cuthill Mckee. See for example figure \\ref{fig:approxbanded}, where we see the result of RCM on the lns$\\_$131 data set, again in Matlab.  If this is the case, instead we could choose $P$ so that $P^TAP$ is narrow banded plus a low rank matrix. See figure \\ref{fig:woodbury}. \n\n\\begin{figure}[ht]\n\\centering\n\\begin{minipage}[b]{0.45\\linewidth}\n\\includegraphics[width=2in]{Images/SparseA_v4.jpg}\n\\caption{$A$ is sparse and non-symmetric}\n\\label{sparseA}\n\\end{minipage}\n\\quad\n\\begin{minipage}[b]{0.45\\linewidth}\n\\includegraphics[width=2in]{Images/ApproxBanded_v2.jpg}\n\\caption{$P^TAP$ narrow band+low rank}\n\\label{fig:approxbanded}\n\\end{minipage}\n\\end{figure}\n\n\n%\\begin{figure}[ht]\n%\\centering\n%\\begin{minipage}[b]{0.45\\linewidth}\n%\\includegraphics[width=2in]{Images/SparseA.jpg}\n%\\caption{$A$ is sparse and non-symmetric}\n%\\end{minipage}\n%\\quad\n%\\begin{minipage}[b]{0.45\\linewidth}\n%\\includegraphics[width=2in]{Images/ApproxBanded.jpg}\n%\\caption{$P^TAP$ narrow band + low rank}\n%\\end{minipage}\n%\\label{fig:bandedplus}\n%\\end{figure}\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[trim = 5mm 30mm 0mm 40mm, clip, width=4in]{Images/Slide1.jpg}\n    \\caption{Breaking up $A$ into a banded matrix plus a low rank matrix}\n    \\label{fig:woodbury}\n\\end{figure}\n\nIn this case we use the Woodbury Formula to solve $Ax = b$. Recall first that $ Ax = b$  implies $x = A^{-1} b$. Then,\n%\\begin{block}{Woodbury Formula}\n\\begin{align*}\nA^{-1} &= (B - USV^T)^{-1}\\\\\n\t  &= B^{-1} - B^{-1}UTV^TB^{-1}\n\\end{align*}\nwhere $T = (V^TB^{-1}U - S^{-1})^{-1}$. And \n%\\end{block}\n\\begin{align*}\nx &= A^{-1}b\\\\\n  &= {\\bf B^{-1} b} - B^{-1}UTV^T {\\bf B^{-1} b} \\\\\n   &= {\\bf a} - B^{-1}UT(V^T {\\bf a}) \\\\\n   &= {\\bf a} - B^{-1}UT {\\bf c}  \\hspace{.5cm} \\mbox{( solve ($V^TB^{-1}U-S^{-1}) \\textbf{d} = \\textbf{c}$)}\\\\\n   &= {\\bf a} - B^{-1}U\\textbf{d}\\\\\n   &= {\\bf a} - B^{-1}\\textbf{h}\n\\end{align*}\n\nThe Woodbury formula is useful because all systems involving $B$ are relatively easy to solve. We did not implement the Woodbury formula in our experiments, due to time contraints. This means that we transformed $A$ to a completely banded matrix, no matter how large the band size. We expect there would be improvements in our final results if the Woodbury formula was implemented.\n\nIn table \\ref{tab:Bandsize}, the band size after permutation is shown. Matlab performed the best across the board, but all three permutations did well for our largest test case. You can see also that for the bayer01 matrix, our band size is very large, and so we did not get reasonable results in our parallel Kaczmarz implementation.\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| l | l | c  c  c |}\n\\hline\n\n    matrix           & size         &    Matlab & PETSc     &  rcm.cpp        \\\\\n \\hline\n lns                   & 131             &     32        &       \\color{red} $\\times$ 111         & \\color{red} $\\times$ 113  \\\\\n Jac2-db            & 21,982     &         545       &     \\color{red} $\\times$            &  \\color{red} $\\times$  \\\\\n bayer01           & 57,735      &     \\color{red} $\\times$ 18,322        &     \\color{red} $\\times$     &  \\color{red} $\\times$   \\\\\n venkat25         & 62,424      &     1,515        &    1,515    & 1,495                   \\\\\n stomach          & 213,360    &      1,133      & 2,216 & 2,239                    \\\\\n atmosmodd     & 1,270,432 &    7,772       & 7,772&  7,772                   \\\\\n \\hline\n\n\\end{tabular}\n\\caption{Bandsize after RCM using various codes}\n\\label{tab:Bandsize}\n\\end{center}\n\n\\end{table}\n\n\n%------------------------------------------------\n%------------------------------------------------\n%KACZMARZ\n% NEEDS SOME RE-WRITING\n%------------------------------------------------\n%------------------------------------------------\n% \n\\subsection{The Kaczmarz method}\n\nOnce we have a banded matrix, $A$, we move on to the Kaczmarz algorithm, which was introduced earlier. Suppose we partition $A$ into two pieces $$A = \\begin{pmatrix} A_1^T \\\\ A_2^T \\end{pmatrix}  $$ and we also partition the right hand size vector $f^T = (f_1^T, f_2^T)$.\n\n\nIn the classical Kaczmarz method at each iteration we compute:\n$$x_k=x_k+\\overrightarrow{n_k}=x_k+\\frac{r_k^i}{||A_i||^2}A_i^T$$\nwhere  $\\overrightarrow{n_k}=\\bigtriangleup{x_k}cos\\theta=\\frac{\\langle\\,A_i{,}\\,\\bigtriangleup{x_k}\\rangle}{||A_i||^2}A_i^T=\\frac{b_i-\\langle\\,A_i{,}\\,x_k\\rangle}{||A_i||^2}A_i^T=\\frac{r_k^i}{||A_i||^2}A_i^T$.\n$$\n\\left\\{\n\\begin{array}{ll}\n                  AA^Ty = f\\\\\n                  x = A^Ty\\\\\n \\end{array}\n \\right.\n \\implies AA^T = \\begin{pmatrix} A_1^T \\\\ A_2^T \\end{pmatrix} \\begin{pmatrix} A_1, A_2 \\end{pmatrix}\n  $$\n  \n  From Gauss-Seidel, use $x^{k+1} = \\begin{pmatrix} A_1, A_2 \\end{pmatrix} \\begin{pmatrix} y_1^{k+1} \\\\ y_2^{k+1} \\end{pmatrix} $.\n  \n  $$ \\begin{pmatrix} A_1^TA_1 & 0 \\\\ A_2^T A_1 & A_2^T A_2 \\end{pmatrix} \\begin{pmatrix} y_1^{k+1} \\\\ y_2^{k+1} \\end{pmatrix} =  \\begin{pmatrix} 0 & -A_1A_2 \\\\ 0 & 0\\end{pmatrix} + \\begin{pmatrix} y_1^{k+1} \\\\ y_2^{k+1} \\end{pmatrix}\\begin{pmatrix} f_1 \\\\ f_2 \\end{pmatrix}$$\n  \n  Replacing some parameters with projection operator $P_i$, we can get:\n  $$x^{k+1} = A_1y_1^{k+1} + A_2y_2^{k+1} = Qx_k +b$$ where $Q = (I-P_2)(I-P_1)$. Similarly, for an m-partition, $$x^{k+1} = Q_u x^k + f_u = (I-P_m)(I-P_{m-1}) \\ldots (I-P_1)x^k + f_u.$$\n  \n  However, the spectral radius of $Q_u$ may interfere with the convergence speed, and the distribution of eigenvalues could also influence the performance. To handle this, we can symmetric $Q_u$ to get an accelerated iteration: \n  $$ x^{k+1} = Q(\\omega)x^k + T(\\omega) f$$ where $Q(\\omega) = (I-\\omega P_1)(I-\\omega P_2) \\ldots (I-\\omega P_m) \\ldots (I-\\omega P_2) (I-\\omega P_1)$, and $T(\\omega) = A^T(D+\\omega L)^{-T}D(D+\\omega L)^{-1},$ where $A^TA = L+ D+L^T$ is the splitting into block lower, block upper, and block diagonal pieces of $A^TA$. Since $(I-Q)$ is symmetric positive definite, the conjugate gradient method is suitable to accelerate the basic scheme. \n  \n Once we have a banded matrix, we considered using various partitions of the rows. A very simple example is shown in figure \\ref{fig:permutation}. A permutation like this gives several benefits. The first is that we can have an outer level of parallelism for each projection. Also, when we split the matrix this way we create several small independent least squares problems, which reduces the time. \n \n \\begin{figure}[htbp]\n\\begin{minipage}[b]{1\\linewidth}\n\\centering\n\\includegraphics[width=4in]{Images/permutation}\n\\end{minipage}\n\\caption{Re-ordering the banded matrix}\n\\label{fig:permutation}\n\\end{figure}\n \n In Figure \\ref{quality} we consider different types of partitions, both in the inner and outer levels. We found that have more independent blocks resulted in faster implementation of Kaczmarz. We also found that more partitions, i.e. taking 4 partitions: $$A = \\begin{pmatrix} A_1^T  \\\\A_2 ^T \\\\ A_3^T \\\\ A_4^T \\end{pmatrix} $$ instead of 2 partitions is slower. \n \n  Furthermore, it has been proven that the optimal value of $\\omega$ is 1.0 if we use two partitions, and $Q(1)$ has the minimal spectral radius. For these reasons we decided to use 2 outer partitions for our implementation. In this case the problem can be simplified as follows: $$(I-Q)x = Tf$$\n\n\n\\begin{figure}[ht]\n\\begin{centering}\n%\\begin{minipage}[b]{1\\linewidth}\n\\includegraphics[width=6in]{Images/quality.jpg}\n%\\end{minipage}\n\\end{centering}\n\\caption{Speed for different partition types.}\n\\label{quality}\n\\end{figure}\n\n\n%\\begin{figure}[ht]\n%\\centering\n%\\begin{minipage}[b]{1.0\\linewidth}\n%\\includegraphics[width=4.8in]{Images/permute.jpg}\n%\\caption{$A$ is partitioned into 2 parts with several independent submatrices}\n%\\end{minipage}\n%\\end{figure}\n\n\n%------------------------------------------------\n%------------------------------------------------\n% SYMMETRIZE KACZMARZ\n% NEEDS SOME HELP\n%------------------------------------------------\n%------------------------------------------------\n\\subsection{Calculation of $c$}\nTo transform the system $Ax = f$ into solving the symmetric positive definite system $(I-Q)x = c$, we need to get the new right hand side vector $c$. Recall that we use $m=2$ partitions in our work. We let\n\n $$A = \\begin{pmatrix} A_1^T \\\\ A_2^T \\end{pmatrix}  $$ and we also partition the right hand size vector $$f^T = (f_1^T, f_2^T).$$\n \n For two partitions, if we expand $c = Tf$ to be:\n \n $$\\textbf{Tf} = \\begin{bmatrix} (I + (I-P_2)(I-P_1))(A_1^T)^+ && (I-P_1)(A_2^T)^+ \\end{bmatrix} \\begin{bmatrix} f_1  \\\\ f_2 \\end{bmatrix}= c $$\n \n We see that in order to perform this we need to solve two pseudo inverse problems:\n \n $$\\hat{f}_i = (A_i^T)^+f_i$$\n \n and whenever we see a product of the form $(I-P_i)u = v$ we are really performing a least squares operation involving the block $A_i$. We will discuss this least squares problem in more detail later.\n \nComputing $c$ can be accomplished by solving a saddle point problem. In our implementation we spent some of our efforts trying to compute $c$, but due to time constraints and difficulties with other parts of our algorithm we were not able to ever correctly incorporate a proper computation of $c$ in our work. For this reason, for our code we generated a right hand side vector $c$ by setting $u$ to be the all ones vector, and then performing $c := (I-Q)\\cdot u$ via a sequence of least squares operations. Then we were able to use our conjugate gradient framework to solve the system $(I-Q)x = c.$ \n\nIn general for Kaczmarz we expect the time taken in running the CG scheme and calling the least squares function to be the bottleneck in our computations. So even though we were unable to properly generate the right hand side vector from a starting vector $f$, we chose to instead focus on the CG scheme and least squares framework in our implementation. \n \n\n\\subsection{Least Squares Computations}\nRecall that the new system we are dealing with is $(I-Q)x = c$, where $c = Tf$, and $$Q=(I-P_{1})(I-P_{2})(I-P_{1})$$\n with $P_{i}=A_{i}(A_{i}^{T}A_{i})^{-1}A_{i}^{T}$.\n\nIt is not stable to form $P_{i}$ directly since it will square the condition number of $A_{i}$, and at the same time will cost time in solving a system with the matrix $(A^{T}_{i}A_{i})$. Instead, given a vector $u$ we note that $v=(I-P_{j})u \\Leftrightarrow \\min\\limits_{v}||u-A_{j}w||_{2}$. We therefore solve $\\min\\limits_{v}||u-A_{j}w||_{2}$ to obtain the vector $v$. \n\n%In PETSc, we use the CG method on the normal equations: $A_{j}^{T}A_{j}w=A_{j}^{T}u$. The parallel step is:\n%        \\begin{equation*}\n%            \\begin{split}\n%                v&=\\min\\limits_{v}||u-A_{j}w||_{2}\\Leftrightarrow \\min\\limits_{v_{i}}||u_{i}-A_{j,i}w_{i}||_{2},\\\\\n%                v&^{T}=[v_{1}^{T},v_{2}^{T},...,v_{k}^{T}],\\\\\n%                w&^{T}=[w_{1}^{T},w_{2}^{T},...,w_{k}^{T}].\n%            \\end{split}\n%        \\end{equation*}\n\nBecause of the way we have split our matrix, when we solve a least squares problem $(I-P_i)u = v$ we in theory can do so independently because $A_i$ is a matrix with many independent blocks. For proper parallel implementation, we would perform the following steps:\n\n\\begin{enumerate}\n\\item At the beginning of the algorithm, send different blocks of $A_i$ (for each sub matrix $i$) to different processors.\n\\item In each least squares computation, independently perform least squares operations on the blocks, and then gather the final result after the simultaneous, independent least squares operations.\n\\end{enumerate}\n\n\\subsubsection*{QR Factorizations}\nOne very effective way to compute the least squares problem in parallel is to use the QR factorization via Given's rotations on each independent block of each sub matrix $A_i$. The computation and storage of the QR factorization of the entire matrix $Q$ would be extremely expensive. However, because $A_i$ is made up of independent diagonal blocks that are all very small in size, we can perform QR factorizations of each of these blocks with great success.\n\nThere are two clear benefits of using the QR factorization on the independent sub blocks of $A_i$. First of all, we can find this factorization simultaneously for each block of $A_i$ at the very beginning of the algorithm, then in all future calls to our least squares function we can use the factorization without needing to recompute it. Secondly, the storage required for the factorization of the blocks is very small in comparison with the overall system.\n\n\\subsubsection*{Difficulties}\n\nUnfortunately in our project we were not able to make full use of the parallelism that is theoretically possible by the Kaczmarz framework. Our difficulty was that splitting up a parallel matrix $A_i$ into independent pieces is extremely difficult in PETSc. This causes a number of issues in our final code, including the following:\n\n\\begin{itemize}\n\\item We cannot be sure that the blocks are perfectly split up among different processors, since PETSc assigns rows automatically by itself without our control.\n\\item Even though we have multiple processors at work on a least squares problem, the least squares computation is still performed globally on the entire sub matrix $A_i,$ rather than simultaneously on independent blocks of $A_i$.\n\\item We are unable to factorize pieces of $A_i$ ahead of time to save time in later calls to our sequential least squares algorithm\n\\end{itemize}\n\nWith a better knowledge of PETSc these problems could be remedied, but time constraints rendered it impossible to master the software enough so that we could reach the full potential of the Kaczmarz framework.\n\n\\subsubsection{Attempt to Improve Speed by LSQR}\n\nIn the end, in order to solve the least squares problem, we implemented LSQR. LSQR is an iterative method for solving $Ax = b$ where $A$ is large, sparse, and overdetermined. It is equivalent at each iteration to CG. \n\n\n\\begin{algorithm}\n\\caption{LSQR}\n\\begin{algorithmic}[1]\n%\\Require{$P_1$ an initiator matrix; $n$, where we want to use $P_n$}\n\\State{$\\beta_{1}u_{1}=b, \\alpha_{1}v_{1}=A^{T}u_{1}, w_{1}=v_{1}, x_{0}=0, \\bar{\\phi_{1}}=\\beta_{1},\\bar{\\rho_{1}}=\\alpha_{1}$}\n\\For{$i = 1,2,3,\\cdots$}\n\\State{Bidiagonalization:}\n\\State{$\\beta_{i+1}u_{i+1}=Av_{i}-\\alpha_{i}u_{i}$}\n\\State{$\\alpha_{i+1}v_{i+1}=A^{T}u_{i+1}-\\beta_{i+1}v_{i}$}\n\\State{Orthogonal Transformation:}\n\\State{$\\rho_{i}=\\sqrt{(\\bar{\\rho_{i}^2}+\\beta_{i+1}^2)}$}\n\\State{$c_{i}=\\bar{\\rho_{i}}/\\rho_{i},$}\n\\State{$s_{i}=\\beta_{i+1}/\\rho_{i},$}\n\\State{$\\theta_{i+1}=s_{i}\\alpha_{i+1},$}\n\\State{ $\\bar{\\rho_{i+1}}=-c_{i}\\alpha_{i+1},$}\n\\State{$\\phi_{i}=c_{i}\\bar{\\phi_{i}},$}\n\\State{$\\bar{\\phi_{i+1}}=s_{i}\\bar{\\phi_{i}}.$}\n\\State{Update x:}\n\\State{$x_{i}=x_{i-1}+(\\phi_{i}/\\rho_{i})w_{i},$}\n\\State{$w_{i+1}=v_{i+1}-(\\theta_{i+1}/\\rho_{i})w_{i}.$}\n\\EndFor\n\n\\end{algorithmic}\n\\end{algorithm}\n\n    \\begin{figure}[htbp]\n    \\begin{center}\n        %\\begin{minipage}[b]{0.8\\linewidth}\n            \\includegraphics[width=3in]{Images/LSQR}\n        %\\end{minipage}\n        \\caption{Convergence of LSQR}\n        \\label{fig:LSQR}\n        \\end{center}\n    \\end{figure}\n    \nWe had hoped that using this method and truncating the number of iterations used in the least squares calculations would allow us to obtain good overall results for our Kaczmarz algorithm. Note the plot of the convergence of the LSQR method in Figure \\ref{fig:LSQR}. We can see that the algorithm mostly converges in the first several iterations, so we hoped that by truncating the number of steps taken we would make the least squares computation faster without harming the accuracy too much. We know that Krylov subspace methods are robust against poor matrix-vector products, so the hope was that our outer CG scheme would still progress towards an accurate overall solution of $(I-Q)x = c.$ . However, our final results are still far from satisfactory in terms of accuracy if we truncate the computations too much.\n\nOne thing we tried was to increase the maximum number of inner LSQR iterations used as the number of outer CG scheme iterations increased. We did this to try to find a balance between speed and accuracy. However, to achieve any type reasonable accuracy for our larger test cases, we did eventually need to make the iterative least squares method run for many iterations (over 100 for each least squares computation). This leads to very slow runtimes. We provide our results in a later section.\n\n %------------------------------------------------\n%------------------------------------------------\n% ACCELERATION VIA CG\n%MAYBE NEEDS SOME HELP\n%------------------------------------------------\n%------------------------------------------------\n\n \\subsection{Acceleration via the CG Method}\nAs stated previously, since $(I-Q)$ is symmetric positive definite, we accelerate solving $(I-Q)x = Tf$  using the conjugate gradient method. This is the framework of our entire algorithm. The outline follows:\n\n\\vspace{.2in}\n \\noindent \\textbf{Step 1} : $x_0 = c$ \\\\\n\\hspace{.5in} Compute $r_0 = Tf - \\boxed{(I-Q)c} = Qc$\\\\\n\\hspace{.5in} Set $p_0 = r_0, i = 0$ \\\\\n\\textbf{Step 2}:  Compute: \\\\\n\\hspace{.5in} $\\alpha_i = (r_i, r_i)/(p_i,\\boxed{(I-Q)p_i})$ \\\\\n\\hspace{.5in} $ x_{i+1} = x_i + \\alpha_i p_i $ \\\\\n\\hspace{.5in} $\\beta_i = (r_{i+1}, r_{i+1})/(r_i, r_i) $ \\\\\n\\hspace{.5in} $p_{i+1} = r_{i+1} + \\beta_i p _i $ \\\\\n\\textbf{Step 3}: If convergence criterion is satisfied, terminate the iterations; else set $i = i+1$ and return to Step 2.\n\n We can take a convergence criterion as : $$ \\frac{ ||r_i||}{||r_0||} \\leq \\epsilon$$\n\n\nThe boxed out portions in our framework are very important. Remember that whenever we see: $$(I - Q) u$$ for any vector $u$, we really mean to solve multiple least squares problems:\n$$(I-Q) u = (I-P_1)(I-P_2)(I-P_1) u $$\n$$(I-P_i) u \\Rightarrow \\text{min}_{v} ||u-A_i w|| $$\n\n %------------------------------------------------\n%------------------------------------------------\n% LAST SECTION: RESULTS\n%------------------------------------------------\n%------------------------------------------------\n\n\\section{Results and Conclusions}\n\n\\subsection{Results}\n\nWe will now discuss the results of our parallel solver. Because of our slow least squares computations, we did not reach a very low tolerance for any of our test cases. For this reason we chose to simply truncate our CG loop at 100 iterations and report the runtime and the tolerance attained by this point. The results are given in table $\\ref{tab:badresults}$.\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| l | l | c  c | c  c |}\n\\hline\n                         &                & Our Parallel & Solver & Krylov & ILU\\\\\n                          \\hline\n    matrix           & size         &  tol achieved & time (s)     &  num-its & time (s)        \\\\\n \\hline\n lns                   & 131             &     $7.5E{-03}$   &         5.6  & \\color{red} $\\times$  &  \\color{red} $\\times$\\\\\n Jac2-db            & 21,982     &   $2.0E{-04}$     &    283    &  \\color{red} $\\times$  & \\color{red} $\\times$ \\\\\n venkat25         & 62,424      & $2.5E{-03}$      &     874  & 374                   & 14.17 \\\\\n stomach          & 213,360    &   $2.1E{-06}$    & 194 & 16                   & 2.21 \\\\\n atmosmodd     & 1,270,432 &  $3.0E{-03}$     &7100 &  266                   & 130.72 \\\\\n \\hline\n\n\\end{tabular}\n\\end{center}\n\\caption{Runtimes of our algorithm (100 iterations of CG) in comparison with GMRES}\n\\label{tab:badresults}\n\\end{table}\n\nTo find a benchmark of how our method performed, we compared with a Krylov Subspace method. The implementation of this consisted of first using the MC64 software to re-order the matrix. This software finds a permutation which brings non-zeros to the diagonal. Once this permutation is used, then we called a Krylov Subspace method with ILU pre-conditioner in PETSc. The Krylov subspace method used is GMRES.\n\nNote that the ILU preconditioner fails for some of our data. The reason for this could be that the eigenvalues of these matrices are distributed too much across the positive and negative spectrum. The ILU preconditioner is not well equipped to handle these so called ``highly indefinite'' matrices. Table \\ref{tab:MC64} shows which of our data failed with this method.\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| l | l | c |}\n\\hline\nmatrix             & size        & Converged? \\\\\n\\hline\nlns                  & 131         &    \\color{red} $\\times$  \\\\\nstd1-Jac2-db  & 21,982    & \\color{red}  $\\times$  \\\\\nvenkat25        & 62,424     & \\color{green} \\Checkmark   \\\\\nstomach         & 213,360   &  \\color{green}  \\Checkmark  \\\\\natmosmodd    & 1,270,432 &  \\color{green} \\Checkmark  \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{ILU preconditioner}\n\\label{tab:MC64}\n\\end{table}\n\nWe note that the one success of our algorithm was its ability to make progress in solving the first few test cases where we failed to converge for GMRES. We see that the framework of our algorithm is good for solving these difficult systems, though runtimes are terrible for reasons already addressed.\n\n\\subsection{Conclusions}\nIn conclusion, it was a mistake to use PETSc. PETSc is better for high level implementation, not for optimization and efficiency. PETSc was also not well suited specifically for grabbing the exact sub-matrices that we needed in order to call the parallel Least Squares. \n\nIn the end we tried to salvage our project by implementing LSQR, but even with this attempt we did not obtain the desired outcome. If we had left PETSc out of our project we know our results would have been even better.\n\n\\nocite{KamathSameh1988,GallopoulosPhilippeSameh2016,Paige,HSL}\n\n\\newpage\n\n\\bibliography{Ref}\n\\bibliographystyle{plain}\n\n\\end{document}\n\n\n", "meta": {"hexsha": "310299b3e947e4712a403ce0350904c1ceeb38f1", "size": 25098, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Parallel Solver for a Large Sparse Linear System/slides/Group4_Final_Report_Complete.tex", "max_stars_repo_name": "WayneDW/parallelism_in_matrix_computations", "max_stars_repo_head_hexsha": "5d598422dc99122ac1322923018d6cc8506e8fbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2017-09-29T06:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T02:31:27.000Z", "max_issues_repo_path": "Parallel Solver for a Large Sparse Linear System/slides/Group4_Final_Report_Complete.tex", "max_issues_repo_name": "WayneDW/parallelism_in_matrix_computations", "max_issues_repo_head_hexsha": "5d598422dc99122ac1322923018d6cc8506e8fbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Parallel Solver for a Large Sparse Linear System/slides/Group4_Final_Report_Complete.tex", "max_forks_repo_name": "WayneDW/parallelism_in_matrix_computations", "max_forks_repo_head_hexsha": "5d598422dc99122ac1322923018d6cc8506e8fbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2018-04-16T03:40:53.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-18T02:59:06.000Z", "avg_line_length": 54.6797385621, "max_line_length": 818, "alphanum_fraction": 0.668300263, "num_tokens": 7430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.4369797160942046}}
{"text": "\\subsection{Simulation}\n\nTo verify the validity of the \\textbf{PD} controller for this task, simulations were run in MATLAB. The simulation set the motors to a common speed, so that the controller always makes the robot move forward when $\\theta=0$ and lower the speed of a motor on one side to turn. This is the same way as the controller is implemented on the robot. Both motors speed can therefore be set into one variable that is defined as the difference between the motor speeds ($\\Delta v = v_L-v_R$). \\\\\n\\indent The simulation used a sinusoid as input to the controller, simulating that the robot travelled along a line that consistently turn from left to right and back again. The results can be seen in Fig. \\ref{fig:sim_t_error} and \\ref{fig:sim_LR_motor}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{img/theta_error.eps}\n    \\caption{The error between the robots pose and the line.}\n    \\label{fig:sim_t_error}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{img/LR_motors.eps}\n    \\caption{The motor output for the results in Fig.\\ref{fig:sim_t_error}.}\n    \\label{fig:sim_LR_motor}\n\\end{figure}\n\nThe results presented above is evidence that a \\textbf{PD} controller can be used for a line follower. \n", "meta": {"hexsha": "d3596f99e12c0635b414afac8c0f58ea66422b6e", "size": 1286, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/finished/chapters/base_simulation.tex", "max_stars_repo_name": "kottz/D7039E", "max_stars_repo_head_hexsha": "d86848a037a07e97122c92e3c80c980c58c41d52", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/finished/chapters/base_simulation.tex", "max_issues_repo_name": "kottz/D7039E", "max_issues_repo_head_hexsha": "d86848a037a07e97122c92e3c80c980c58c41d52", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 72, "max_issues_repo_issues_event_min_datetime": "2020-09-15T13:32:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-01T08:06:16.000Z", "max_forks_repo_path": "report/finished/chapters/base_simulation.tex", "max_forks_repo_name": "kottz/D7039E", "max_forks_repo_head_hexsha": "d86848a037a07e97122c92e3c80c980c58c41d52", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-11-16T16:06:15.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-16T16:06:15.000Z", "avg_line_length": 61.2380952381, "max_line_length": 486, "alphanum_fraction": 0.7604976672, "num_tokens": 330, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.43697093447685714}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{tcolorbox}\n\\usepackage{float}\n\\usepackage{amsfonts}\n\\usepackage{svg}\n\\date{}\n\n\\usepackage{qcircuit}\n\n\\title{\\textbf{Quantum Computing: An Applied Approach}\\\\\\vspace*{1cm}\nChapter 8 Problems: Building a Quantum Computer\n}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{}\n\nThe circuit model can be defined as the union of three distinct components: (1) a set of $n$ initialized input qubits, (2) a set of qubit lines consisting of one- or multi-qubit unitary gate operations, and (3) a set of up to $n$ observables to measure that project the qubit states onto the subspace spanned by $n$ classical bits.\n\nThe query model, on the other hand, describes some function that maps $n$ input qubits onto $n$ output qubits via the action of some oracle. In this sense, it consists of an input state $\\{|x_i\\rangle\\}_{i=1}^n$ and a corresponding collection of classical bits $\\{c_i\\}_{i=1}^n$.\n\n\\section{}\n\nThis proof appears relatively elementary. The query complexity involves up to a single oracle call on each of the $n$ input qubits. The circuit, or gate, complexity involves an unbounded number of operations on each of $n$ qubit lines. The query model complexity then represents a lower bound on the circuit complexity, as the circuit complexity involves at least $O(1)$ unitary operations on each qubit.\n\n\\section{}\n\nThere is a single single-qubit gate per line in the quantum Fourier transform (QFT), so there are $n$ single-qubit gates. The second part of the question clearly means to ask how many double-qubit gates are needed; there are $i-1$ double-qubit gates on the $i^\\text{th}$ line yielding $\\sum_{i=1}^{n-1}i=\\boxed{\\frac{n^2-n}{2}}$ gates overall.\n\n\\section{}\n$n=1$ qubits:\n\\newline\n\\Qcircuit @C=1em @R=.7em {\n& \\gate{H} & \\qw\n}\n\\newline\\newline\n$n=2$ qubits:\n\\newline\n\\Qcircuit @C=1em @R=.7em {\n& \\gate{H} & \\gate{R_{\\pi/2}} & \\qw & \\qw \\\\\n& \\qw & \\ctrl{-1} & \\gate{H} & \\qw\n}\n\\newline\\newline\n$n=3$ qubits:\n\\newline\n\\Qcircuit @C=1em @R=.7em {\n& \\gate{H} & \\gate{R_{\\pi/2}} & \\gate{R_{\\pi/4}} & \\qw & \\qw & \\qw & \\qw \\\\\n& \\qw & \\ctrl{-1} & \\qw & \\gate{H} & \\gate{R_{\\pi/2}} & \\qw & \\qw \\\\\n& \\qw & \\qw & \\ctrl{-2} & \\qw & \\ctrl{-1} & \\gate{H} & \\qw\n}\n\n\\section{}\n\nThe intuition behind this proof is that, when initialized in the zero-state $|0\\rangle^{\\otimes n}$, all of the controlled-rotation gates reduce to the identity. Consequently, the QFT reduces to a set of one Hadamard operation per line yielding:\n$$\nQFT_n|0\\rangle^{\\otimes n}=H^{\\otimes n}|0\\rangle ^{\\otimes n}\n$$\nas described.\n\n\\section{}\n\n\\subsection{}\n\nThe approach of period finding proposed in this paper by Ekera and Hastad addresses the modular exponentation step and offers several different proposals for reducing the complexity of this step. Overall, especially for low-bit ($n$) inputs, their approach greatly reduces the number of Toffoli gates required and in doing so, lowers the overall number of qubits required to solve problems such as 2048-bit RSA encryption.\n\n\\subsection{}\n\nIn terms of the complexity of the modular exponentiation step, Shor's Algorithm involves a Toffoli gate count of $20n_en^2$, where $n_e$ is the number of modular multiplication operations to perform and $n$ is the number of input bits in the integer to be factored. This step dominates the complexity of Shor's Algorithm as a whole.\n\n\\subsection{}\n\nThe square-and-multiply approach begins with an initial register qubit $x$ in the state $|1\\rangle$. Afterwards, a controlled modular multiplication is run for each exponent qubit $e_j$, with $j$ iterating from 0 to $n_e-1$. After this process, including multiple iterations of the modular multiplication subprocess, the initial qubit $x$ stores the exponentiated value $x=g^e$.\n\n\\subsection{}\n\nWindowed arithmetic scales down the number of qubits needed for operations in intermediate steps, by replacing subprocesses such as modular multiplication with lookup functions that operate in clusters. In the example shown, a window size of 4 is used to lookup classically known values for the expression $g^{e[4n:4(n+1)]2^{4n}}$, reducing computation time by a factor of 4.\n\nIn this paper, this technique is used in both the modular addition and modular multiplication subroutines, modifying the Toffoli gate count from $4n^2n_e$ to $\\frac{2n_en}{c_\\text{mul}c_\\text{exp}}(2n+2^{c_\\text{mul}+c_\\text{exp}})$. A tradeoff takes place, as the scalar decrease in the gate counts with the window sizes $c$ is balanced by the number of Toffoli gates involved in the lookup operation (factor of $2^{c_\\text{mul}+c_\\text{exp}}$).\n\n\\subsection{}\n\nThese implications are explored in Table 1. Although the complexity of the approach studied in this paper is asymptotically greater than the others, for small values of $n$ it reaches a practical baseline for gate complexity in solving 2048-bit RSA decryption around two orders of magnitude lower than the next best.\n\nSpecifically, the minimum number of abstract qubits necessary to factor a 2048-bit key has been reduced from 340 in Fowler et al. (2012) to 2.7.\n\n\\section{}\n\nUnder the approximate QFT, there are at most $m$ two-qubit gates per line, and there are $n$ lines in total. There is also one single-qubit gate per line, yielding a gate complexity of $O(nm+n)=O(nm)$.\n\nIn determining the total number of gates exactly, first notice that the number of single-qubit gates remains the same at $n$. The number of double-qubit gates continues to increase by 1 per line beginning at 0, but stops at $m$ since there are at most $m$ rotations $\\theta_{jk}$ where $j-k>m$.\n\nThere are then $\\frac{m(m-1)}{2}$ double-qubit gates in the first $m$ lines, and $(n-m)m$ in the remaining $n-m$. Overall, including the $n$ single-qubit gates this yields\n$$\n\\frac{m^2-m}{2}+\\frac{2m(n-m)}{2}=\\boxed{\\frac{m(2n-m+1)}{2}}\n$$\ngates.\n\nSince $n>m$ is assumed, this expression has complexity $O(mn)$ as described. It disagrees with the expression listed in the problem set assignment, but matches my own calculations for various values of $m$ and $n$.\n\nFor example, setting $m=2$ and $n=5$ for the AQFT yields a quantum circuit with 5 single-qubit gates and 0+1+2+2+2=9 two-qubit gates. Assigning these values into the expression above, this yields $5+\\frac{2(2\\cdot 5-2+1)}{2}=5+9=14$ gates, as expected.\n\n\\end{document}\n", "meta": {"hexsha": "210111bd136795310aee56668cd54f4d0685638f", "size": 6364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter_8/main.tex", "max_stars_repo_name": "Alekxos/qc_applied_approach", "max_stars_repo_head_hexsha": "c56ce4d1cfc9fcf0fc926e330bb28186cebdb799", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-04-20T18:48:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-14T18:28:57.000Z", "max_issues_repo_path": "chapter_8/main.tex", "max_issues_repo_name": "Alekxos/qc_applied_approach", "max_issues_repo_head_hexsha": "c56ce4d1cfc9fcf0fc926e330bb28186cebdb799", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter_8/main.tex", "max_forks_repo_name": "Alekxos/qc_applied_approach", "max_forks_repo_head_hexsha": "c56ce4d1cfc9fcf0fc926e330bb28186cebdb799", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.9259259259, "max_line_length": 446, "alphanum_fraction": 0.7415147706, "num_tokens": 1779, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.436970930387056}}
{"text": "\\documentclass[a4paper,12pt]{report}\n\n\\usepackage{amsmath,amsfonts,mathtools}\n\\usepackage{amssymb}\n\\usepackage{amsbsy}\n\\usepackage{hyperref}\n\n\\begin{document}\n\\title{PHY294 Abridged}\n\\author{Aman Bhargava}\n\\date{Janaury 2020}\n\\maketitle\n\n\\tableofcontents\n\n\\chapter{Wave Applications}\n\\section{Polarization}\n\nWe learned last year that wave-particle duality leads to \\textbf{predictable probabilities} and unpredictable individual behavior. The simplest example of this is polarization.\n\\begin{itemize}\n\\item Light oscillates perpendicular to its direction of propagation.\n\\item There are two possible polarization states: $\\{\\uparrow, \\rightarrow\\}$. A diagonal state is just a superposition of these two.\n\\item A \\textbf{polarizer} allows only one polarization state through.\n\\end{itemize}\n$$I = I_0 \\cos^2(\\theta)$$\n\n\\paragraph{What's with the $\\cos^2$? } Remember how we learned that the energy of a wave is proportional to the amplitude$^2$? It's just like that here. There's this idea of a \\textbf{probability amplitude}. If you square the probability amplitude, you get the actual \\textbf{probability} (kind of like how squaring the amplitude gets you energy when considering oscillators). \n\n\\paragraph{What's the point of probability amplitudes? } The utility of using probability amplitudes is that, when you have two probabilities that affect eachother (e.g. in an additive way), you get the \\textbf{correct answer} when you add the probability \\textbf{amplitudes} and THEN square them to get the actual probabilities. This becomes particularly important in interference problems where probability waves can \\textit{interfere} with eachother. \n\n\\paragraph{A note on unpolarized light: } All the light that we deal with in this course will be polarized. Unpolarized light doesn't have as nice of a mathematical characterization and is overall a pain to deal with.\n\n\\section{Interference}\n\\section{Double Slit}\nRemember the double slit experiment? If you do, then you just need to know the following formula: \n\n$$I(y) = 4I_0 \\cos^2(\\frac{\\pi d y}{D \\lambda})$$\n\n\\textit{Where $y$ is how far along the screen away from the centre you are, $d$ is the slit distance, $D$ is the distance to the screen}\n\nThe interference patterns occur due to a difference in path length. The probability waves of the photons interfere with eachother because they are not in phase, leading to the patterns. Just takes some trigonometry to derive! The $\\cos^2$ is there, as again, due to the difference between probability amplitudes and probabilities.\n\n\\chapter{Schroedinger's Equation}\nThis chapter discusses the mathematical background required to understand, validate, and use Schroedinger's equation.\n\\section{Fourier Series}\n\nWe're going to re-do Fourier series with complex exponentials instead of the usual sin and cos functions because that's going to make actual analysis a lot easier.\n\\paragraph{Handy formulae: }\n$$e^{i2\\pi n x/L} = \\cos(2\\pi n x / L) + i\\sin(2\\pi n x/L)$$\n$$cos(x) = \\frac{1}{2}[e^{ix} + e^{-ix}]$$\n$$\\sin(x) = \\frac{1}{2i}[e^{ix} - e^{-ix}]$$\n\n\\paragraph{Fourier Equations:}\n$$f(x) = \\sum_{n=-\\infty}^{\\infty} c_n e^{i2\\pi n x / L} $$\n$$c_0 = \\frac{1}{L} \\int_0^L f(x) dx$$\n$$c_n = \\frac{1}{L} \\int_0^L f(x) e^{-i 2\\pi n x /L}dx$$\n\nWhere $c_0 = A_0$, $c_n = \\frac{a_n-ib_n}{2}$ for $n > 0$ and $c_n = \\frac{a_n + ib_n}{2}$ for $n < 0$. \n\nOne of the main benefits of this complex exponential form is that it makes it easier for us to solve for when $L \\to \\infty$.\n\n\\subsection{Infinite Fourier Coefficients}\n\nSince we have uncountably infinite Fourier bands when we expand the limits to $\\pm \\infty$, we can make a \\textbf{function} that gives us the Fourier coefficients for any real number. \n\n$$\\phi(x) = \\int_{-\\infty}^{\\infty} \\frac{1}{\\sqrt{2\\pi}} \\tilde{\\psi(k)} e^{ikx} dk $$\n$$\\tilde{\\phi(k)} = \\int_{-\\infty}^{\\infty} \\frac{1}{\\sqrt{2\\pi}} \\phi(x) e^{-ikx} dx $$\n\n\\section{Matter Waves}\n\nThat Fourier series stuff becomes quite useful when we start thinking of \\textbf{matter as waves}. The \\textbf{de Broglie Hypothesis} states that all particles have wavelengths ($\\lambda$). \n\n$$p = \\hslash k = \\frac{h}{\\lambda}; \\,\\,\\, k = \\frac{n\\pi}{L}=\\frac{\\omega}{c};\\,\\,\\,$$\n$$\\hslash = \\frac{h}{2\\pi}$$\n\nTherefore, if we can represent a particle as a wave, we are good to go to analyze the components using fourier analysis! If the particle is described as a non-repeating pulse, then you need to use the $\\lim_{L\\to\\infty}$ we talked about at the end of the Fourier series section. This allows us to convert from a plot that shows \\textbf{location} and another that shows the \\textbf{frequency (momentum)}. \n\n\\subsection{Uncertainty Principle}\n\nRemember R.M.S. from ECE159? Me neither. Basically it's just a way of denoting how spread out a distribution of values on a graph is. For the example of a particle that is described by a local \\textbf{pulse} of probability, we can find the RMS value for its position $\\Delta x$. \n\nWe can also take the \\textit{infinite bounds Fourier transform} and to get a distribution of the wave number intensities ($k$) and get the RMS value for that. But the wave number is just momenutum times a constant! So really, we know both the $\\Delta x$ and the $\\Delta k$ values! \n\nHere's the really cool thing: We can derive a mathemtical relationship between the two! And that is: $$\\Delta k \\Delta x \\geq \\frac{1}{2}$$\n\n\nWhich makes a lot of sense! If you think about a function with an infinitely small RMS in the $k$-domain, you think of a function described with just one Fourier coefficient. That's just an infinite wave -- it has literally infinite RMS in the real domain. Same goes vice-versa. We did the actual math with a Gaussian function in class, but that's kind of extra for a review document like this. Just take my word for it and know it's pretty cool.\n\n\n\\subsection{Solving Problems with Uncertainty Principle}\n\nPersonally I didn't remember a lot of this stuff from PHY293, so here goes. In the real world, the uncertainty principle is: $\\Delta x \\Delta p \\geq \\frac{\\hslash}{2}$. They key to solving is having an intuition for what happens to a randomly distributed variable when you square it. \n\nLet's say that $x$ is normally distributed around $0$. The average value of $x$ ($<x>$) is obviously zero. But what about the average value of $x^2$? All those negative $x$ values turn positive when you square them, so $<x^2>$ must be positive. Here's the expression for a general variable: \n$$<x^2> = <x>^2 + <\\Delta x>^2$$\n\nIt makes a lot of sense for the square of the uncertainty to correlate with the mean squared value. The fact that $<x^2>$ is non-zero for anything where $\\Delta x > 0$ is really important when you start thinking about \\textbf{minimizing energy} in a system. If kinetic energy is $KE = \\frac{1}{2m}p^2$, you're in a good position to solve some interesting problems if you know the bounds on $x$!\n\nIf you have an expression for energy that relies on momentum and/or position and you have some other boundary condition in place to fully constrain $p$ and $x$, you can generally use the uncertainty principle to deduce the \\textbf{minimum possible allowable energy}. \n\n\\section{Schroedinger Equation}\n\n\\paragraph{GOAL: } Specify the \\textbf{state} of the system and predict the \\textbf{future state} of the system perfectly. \n\nIn classical terms, we would achieve this goal via the equations of motion ($\\vec{F} = m\\vec{a}$). For quantum, however, we have more of a focus on \\textbf{probability amplitudes} rather than absolute values. Therefore, we have an equation for a wave function:\n\n$$i\\hslash \\frac{\\partial}{\\partial t} \\Psi(x, t)  =   \\frac{-\\hslash^2}{2m} \\frac{\\partial^2}{\\partial x^2} \\Psi(x, t) + V(x) \\Psi(x, t)$$\n\n$$E\\phi(x) = \\frac{-\\hslash^2}{2m} \\frac{d^2\\phi(x)}{dx^2} + V(x)\\phi(x)$$ % TODO: Populate this with the time-independent Schroedinger equation.\n\n\\begin{itemize}\n\\item Term 1: Representative of Total Energy.\n\\item Term 2: Representative of Kinetic Energy.\n\\item Term 3: Representative of Potential Energy.\n\\end{itemize}\n\nSchroedinger arrived at this conclusion via educated trial and error. The solutions are of the form:\n\n$$\\Psi(x, t) = e^{i(kx-\\omega t)}$$\n\nThis reduces to the following relationships:\n$$\\hslash \\omega = \\frac{( \\hslash k )^2}{2m};\\,\\,\\, \\hslash \\omega = E;\\,\\,\\, (\\hslash k)^2 = p^2$$\n\n\\paragraph{Separation of variables: } To find more solutions, we can try $\\Psi(x, t) = \\phi(x)f(t)$. We arrive at\n$$\\frac{i\\hslash}{f(t)} \\frac{df}{dt} = -\\frac{\\hslash^2}{2m}\\frac{1}{\\psi(x)}\\frac{d^2\\phi}{dx^2} + V(x) = C_{onst}$$\n\nSince the left side is time dependent and the right side is space dependent, they must be equal to a constant. Bsed on this we have the following constraints:\n\\begin{enumerate}\n\\item $i \\hslash \\frac{df}{dt} = af(t)$\n\\item $\\frac{-\\hslash^2}{2m} \\frac{d^2 \\phi}{dx^2} + v(x)\\phi(x) = a\\phi(x)$\n\\item $a = \\hslash \\omega = E_{tot}$\n\\item Therefore, $$\\Psi(x, t) = \\phi_a(x) f(0)e^{-iat/\\hslash}$$\n\\end{enumerate}\n\nKnow that $a$ can only come in \\textbf{quantized} energy states. This is due to the fact that a non-quantized $a$ makes the equation very difficult to solve, and the experiments tend to agree that this is the case in quantum mechanics. \n\n\n\\subsection{Particle in a Box}\nWe now know the Schroedinger equation. When we try to `solve' it for a particle in an infinite square well, we must apply the following boundary conditions and assumptions:\n\\begin{enumerate}\n\\item For $0 < x < L$, $V = 0$. Elsewhere $V = \\infty$ \n\\item $\\phi(x)$ is continuous.\n\\item $\\phi(x) = 0$ for $x = L;\\,\\, x=0$.\n\\end{enumerate}\n\nHandily, the equation simplifies to the following (we can use our amazing knowledge of wave mathematics to solve it): \n\n$$\\frac{-\\hslash^2}{2m}\\frac{d^2\\phi(x)}{dx^2} = E\\phi(x)$$\n\nSo clearly $\\phi(x) = A e^{i\\alpha x} + B e^{-i\\alpha x}$ where $\\alpha = \\sqrt{\\frac{2mE}{\\hslash}}$. The solutions, including time-dependence, are as follows:\n\n$$\\Psi_n(x, t) = \\sqrt{\\frac{2}{L}} \\sin(\\frac{n\\pi x}{L}) f_n(0) e^{-i E_n t/\\hslash}$$\n\nAnd the most general form is $\\Psi = \\sum_{n=1}^{\\infty} \\Psi_n(x, t)$. The coefficients that describe the varying intensity of each component wave is inside of $f_n(0)$. Also, make sure you know the \\textbf{energy levels for a particle in a box}: \n\n$$E_n = \\frac{\\hslash^2 n^2 \\pi^2}{2mL^2},\\,\\,\\,\\, n \\in N^*$$\n\n\\subsection{Time Dependence in Superposition}\n\nWhen we just have one $n$ value (i.e. $\\Psi$ is a perfect sinusoidal wave), it's not really time dependent. When we take the superposition of \\textbf{more than one energy level}, we get time dependence in the form of what our professor calls `cross terms'.\n\n$$P = \\Psi^*(x, t) \\Psi(x, t)$$ \n\nThe rate at which time-dependent \\textbf{sloshing} that occurs when you superimpose two energy levels is: $\\omega = \\frac{E_1-E_2}{\\hslash}$. \n\n\\subsection{Determining the Likelihood of a Given Superposition}\n\nWhen you make an observation of a particle whose state is described as superposition of many energy levels/states, it will collapse to just one of those states.\n\nThe probability of a given state being actualized can be deduced using the following steps:\n\\begin{enumerate}\n\\item We begin with a general wave function $\\Psi(x)$ and a specific state $\\psi_n(x)$. We wish to deduce the probability $P(\\phi_n)$.\n\\item Remember that each $\\phi_n$ comprises a basis set. $\\Psi = \\sum c_n \\phi_n$. We can deduce $c_n$ by the inner product of $\\Psi$, $\\phi_n$ which is \n$$c_n = \\int_0^L \\phi_n^*(x)\\Psi(x)dx$$\n\\item $c_n$ gives the probability amplitude of $\\phi_n$. We get $P(\\phi_n)$ via $$P(\\phi_n) = |c_n|^2$$.\n\\end{enumerate}\n\nIf we want to get the \\textbf{expected value} of energy or wavelength, we just need to take the weighted average of that value with its associated probability.\n\n\\subsection{Quantum Harmonic Oscillator}\n\nThis classic example gives you a curve that describes the potential energy of a particle at a given distance from an atom. It's generally bowl shaped, but slightly irregular. Here are the steps taken to solve it:\n\n\\begin{itemize}\n\\item To simplify the potential energy curve, we Taylor expand at $r_0$. We use this as the $V(x)$ term in the Schroedinger equation such that $V(r) = V(r_0) + \\frac{1}{2}\\frac{d^V}{dr^2}$\n\\item Set $m$ to the \\textbf{reduced mass} of the system ($\\frac{1}{\\frac{1}{m_1} + \\frac{1}{m_2}}$)\n\\item Plug that value into the \\textbf{time-independent} Schroedinger equation.\n\\item $\\frac{-\\hslash^2}{2m} \\frac{d^2\\phi}{dx^2} + \\frac{1}{2}Kx^2 \\phi(x) = E\\phi(x)$ where $K$ is the spring constant.\n\\item Boundary conditions: $lim_{|x|\\to\\infty}\\phi(x) = 0$\n\\item At large $|x|$, the first term might be there, the second term is definitely there due to the $x^2$, and the last term is definitely not there since it's finite.\n\\item We make a guess that, at large $x$, $\\phi(x) \\approx \\exp(-\\sqrt{\\frac{mk}{\\hslash^2}\\frac{x^2}{2}})$\n\\item Since that function is $\\approx 1$ at around $x = 0$, we can say that the final form is $\\phi(x) = g(x) \\exp(-\\sqrt{\\frac{mk}{\\hslash^2}}\\frac{x^2}{2})$. $g(x) = \\beta_n$.\n\\end{itemize}\n\n\\paragraph{ENERGY OF A QHO: } $$E_n = (n+\\frac{1}{2})\\hslash \\omega$$\n\\paragraph{Useful Facts: }\n\\begin{itemize}\n\\item $\\omega = \\frac{2\\pi c}{\\lambda}$\n\\item $\\omega_0^2 = \\frac{k}{m}$\n\\item Reduced mass: $$\\frac{1}{ \\frac{1}{m_1} + \\frac{1}{m_2} }$$\n\\end{itemize}\n\n\\subsection{Probability Density and Current}\n\nDo you remember anything whatsoever from the fluid dynamics portion of AER210? Me neither. Anyway, the idea here is that flowing incompressible fluids have similar behavior to probability moving in time and space. \n\n$$\\frac{\\partial P}{\\partial t} = -\\frac{\\partial J_x}{\\partial x}$$\n\nWhere $P$ is the fluid density and $J_x$ is the current density. We can make the analogy that probability is equivalent to fluids. From Schroedinger's equation, we can simplify:\n\n$$\\frac{\\partial P}{\\partial t} = \\frac{\\hslash}{2mi} (\\Psi\\frac{\\partial^2 \\Psi^*}{\\partial x^2} - \\Psi^* \\frac{\\partial^2 \\Psi}{\\partial x^2})$$\n\nFrom this we get that the \\textbf{probability current} is $J_x = \\frac{\\hslash}{2mi} (\\Psi^* \\frac{\\partial \\Psi}{\\partial x} - \\Psi \\frac{\\partial \\Psi^*}{\\partial x})$\n\n\\subsection{Eherenfeist Theorem}\n\nThe macroscopic manifestations of quantum probabilities are usefully approximated as the \\textbf{expected values} of the wavefunctions. For example:\n$$\\frac{d<x>}{dt} = \\frac{<p>}{m};\\,\\,\\, \\frac{d<p>}{dt} = <\\frac{-\\partial V}{\\partial x}>$$\nIn order to find the average value of a given variable in quantum, you must take the following integral:\n$$<x> = \\int \\Psi^*\\Psi x dx$$\nSo, for example: $<p> = \\int P(x, t) [-i\\hslash \\frac{d}{dx}dx = \\int \\Psi^*(k, t) \\Psi(k, t) \\hslash k dk$\n\n\\chapter{Quantum Wave Transmission}\n\\section{Index of Refraction}\nGenerally speaking, the light phenomena taught in Grade 10 Ontario High School (e.g. index of refraction, optics, etc.) have solid analogues in quantum mechanics. That should make sense intuitively because light is best characterized by quantum mechanical models in many cases.\n\nThe refraction index for light is characterized by the varying \\textbf{speeds of light} that exist in different media. That difference causes refraction, reflection, and a whole lot of other jazz. \n\n\\paragraph{Quantum version: } Instead of varying the speed of light in media, we consider a \\textbf{potential energy step function}. The following attributes apply:\n\\begin{itemize}\n\\item Total energy remains the same from region I to II.\n\\item Potential energy goes from $V_{I} \\to V_{II}$.\n\\item $P_I = \\sqrt{2m(E-V_I)}$ and $P_{II} = \\sqrt{2m(E-V_{II}}$.\n\\item $\\lambda_I = h/P_I$, $\\lambda_{II} = h/P_{II}$.\n\\end{itemize}\n\n\\paragraph{Wave function form: }\n$$\\phi_I(x) = Ae^{ik_1x} + Be^{-ik_1x}$$\n$$\\phi_{II}(x) = Ce^{ik_2x}$$\nThat second equation for after the potential energy step only has one term because only transmitted light gets through (by definition) and it's only characterized by one wavelength.\n\n\\subsection{Case I: $E > V_0$}\n\n\\paragraph{Boundary conditions: }\n\\begin{itemize}\n\\item $\\phi(x)$ is continuous.\n\\item $\\phi'(x)$ is continuous.\n\\end{itemize}\n\nThe continuity arises because a discontinuous function would lead to an infinite $\\frac{d^2\\phi}{dx^2}$ in the Schroedinger equation that doesn't make sense because all the other terms definitely go to zero when integrated over very short periods.\n\n\\paragraph{Conclusions on the wave functions: } \n\\begin{enumerate}\n\\item $A + B = C$\n\\item $(A-B) = \\frac{k_2}{k_1}C$\n\\end{enumerate}\n\nClassically, transmission coefficient is $T = \\frac{J_{transmitted}}{J_{incident}}$ and the reflection coefficient is $R = \\frac{J_{reflected}}{J_{incident}}$. When we apply \\textbf{quantum equations...}\n\n$$J_{trans} = |C|^2\\frac{\\hslash k_2}{m};\\,\\,\\, J_{inc} = |A|^2\\frac{\\hslash k_1}{m};\\,\\,\\, J_{refl} = |B|^2 \\frac{-\\hslash k_1}{m}$$\n$$T = \\frac{|C|^2}{|A|^2}(\\frac{k_2}{k_1});\\,\\,\\, R = \\frac{|B|^2}{|A|^2}$$\n\n\\subsection{Case II: $E < V_0$}\n\n$$A = \\frac{1}{2}C(1 + \\frac{i\\beta}{k_1});\\,\\,\\, B = \\frac{1}{2}C(1-\\frac{i\\beta}{})$$\n$$\\frac{J_{refl}}{J_{inc}} = \\frac{|B|^2}{|A|^2} = 1$$\n\nUnexpectedly, the results are what one would intuitively reason given your experience with the material world. If the ball doesn't have enough energy to overcome the potential energy of a step, it's not getting up there. All particles in that situation are reflected back.\n\n\\paragraph{HOWEVER: } There's a weird pooling of probability right around the cusp of the step function. The wave coming to the step is a regular complex exponential (it's oscillating. The wave function right after the step is a \\textbf{non-complex decaying exponential}! Because of course there has to be comething confusing about each topic in quantum :)\n\nSo yeah, $J_trans$, the probability current of the particle going above $x = 0$ is still 0, but the actual probability is greater than 1. \n\nLow key this is actually seen in lens optics. When you have total internal reflection, there is this thing called the \\textbf{evanescent wave} that is $\\approx \\lambda$ distance away from the surface of the medium that does have EM radiation.\n\n\n\\section{Quantum Tunneling}\n\n\\chapter{Quantum Measurements, Operators and the Like}\n\n\\section{Hamiltonians and Eigen Things}\n\nIf we manipulate the time-independent Schroedinger equation, we can get the following: $$[-\\frac{\\hslash^2}{2m} \\nabla^2 + V(r)]\\phi_n(x) = E_n\\phi_n$$\n\nIf you look carefully, you can see the Eigen value form! Remember how the whole thing was that $\\pmb{A}\\vec{x} = \\lambda \\vec{X}$? Well here we have this big \n\\textbf{operator} in the square brackets times the \\textbf{state} $\\phi_n(x)$ being set equal to the scalar value for total energy $E$ times the same state $\\phi_n(x)$\n\nWe call the stuff in the brackets the \\textbf{Hamiltonian operator}. The state $\\phi_n(x)$ is an \\textbf{eigen state} or \\textbf{eigen vector} of the Hamiltonian and the value of $E_n$ is an \\textbf{eigen value} of the Hamiltonian. \n\n\\paragraph{Problem Solving Tips: }\n\\begin{itemize}\n\\item You can always re-derive the conventional Hamiltonian operator from the time-independent Schroedinger equation.\n\\item If you are asked to confirm that a state is an \\textbf{eigen state}, just run it through the given operator. You should get a scalar multiple of the original state.\n\\item If you are asked to find the energy level of a given state, use the Hamiltonian operator (or whatever other operators you have access to, the rest will be discussed later) \n\\end{itemize}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "f7b4ecec94e3d750681cf4872d5200bce912643e", "size": 19512, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/PHY294.tex", "max_stars_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_stars_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2020-10-25T06:03:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-15T02:14:13.000Z", "max_issues_repo_path": "tex/PHY294.tex", "max_issues_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_issues_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/PHY294.tex", "max_forks_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_forks_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-05-05T14:21:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-06T19:01:31.000Z", "avg_line_length": 57.3882352941, "max_line_length": 454, "alphanum_fraction": 0.7204284543, "num_tokens": 5721, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4369709215703981}}
{"text": "In this chapter we describe how the solver for the MKC problem were\nimplemented. This implementation is a sample for a column generation scheme;\nno cut generation is done. Since this problem is not so well known, first we\nwill describe the problem setting then the implementation details.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{The MKC Problem}\n\\label{mkc:problem}\n\nMKC stands for {\\em Multiple Knapsack problem with Color constraints} as it is\nderived by generalizing the multiple knapsack problem along two directions:\n(i) adding assignment restrictions on items which can be assigned to a\nknapsack, (ii) adding a new attribute (called ``color'') to the items and then\nadding the associated ``color'' constraints which restrict the number of\ndistinct colors which can be assigned to a knapsack to two.\n\nThis problem is motivated by the surplus inventory matching problem in the\nsteel industry (\\cite{KDTL}): before planning production, an attempt is made\nto satisfy orders using leftover slabs from surplus inventory. The goal of\ninventory matching is to maximize the total weight of the orders satisfied\nfrom the leftover and to minimize the leftover weight of each slab used in the\nmatching. For each order we can identify a set of applicable slabs from the\nsurplus inventory.  These assignment restrictions are based on quality and\nphysical dimension considerations.  For any given order only slabs which are\nof the same quality or better can be applied.  In addition, the thickness and\nwidth requirements for each order need to be compatible with those of the slab\napplicable.  These considerations restrict the number of applicable slabs for\neach order. The color constraints place restrictions on the sets of orders\nthat can be matched to the same slab in the surplus inventory. Because of\nprocessing considerations in the finishing line of a steel mill not all orders\nassignable to a slab can be packed together on the slab. There is a route\nassociated with each order that specifies the set of process operations that\nneed to be applied in the finishing mill. Orders with different routes require\ndifferent process operations and are referred to as being of different types.\nSlabs packed with different order types need to be cut before they are\nprocessed in the finishing mill.  Since cutting slabs is expensive and often\nthe cutting machine is a bottleneck, strong constraints are posed in terms of\nthe number of allowed cuts per slab. The simplest and most commonly used\nconstraint used is to limit the number of required cuts to one; i.e., no more\nthat two order types are allowed on a slab.  In order to describe this\nconstraint formally we associate a unique {\\em color} with each route code and\nrestrict the number of colors on a slab to be no more than two.  Notice that\nthis implies that we associate a color with each order based on its route\ncode.  This restricts the number of different order types on a slab to two and\nthe number of required cuts to be no more than one.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Natural formulation for MKC}\n\nThis formulation has three sets of variables and four sets of constraints\nmodeling the various restrictions.\n\\begin{eqnarray}[r@{\\eqsep}c@{\\eqsep}lqql]\n\\multicolumn{3}{c}{\n\\max \\sum_{i = 1}^{N}\\sum_{j \\in N^i} w^i x^i_j -\n     \\sum_{i = 1}^{N} (W_j - \\sum_{j \\in N^i} w^i x^i_j) z_j\n} & \\nonumber \\\\\n\\sum_{i \\in N_j} w^i x^i_j & \\le & W_j z_j & 1 \\le j \\le M \\label{con-ks} \\\\\n\\sum_{j \\in N^i} x^i_j     & \\le & 1       & 1 \\le i \\le N \\label{con-order} \\\\\n\\sum_{c \\in C_j} y^c_j     & \\le & 2       & 1 \\le j \\le M \\label{con-col1} \\\\\nx^i_j & \\le & y^{c^i}_{j}  & 1 \\le i \\le N, ~j \\in N_{i} \\label{con-col2} \\\\\nx^i_j & \\in & \\{0,1\\}      & 1 \\le i \\le N, ~j \\in N_{i} \\nonumber \\\\\ny^c_j & \\in & \\{0,1\\}      & \\forall c \\in C_j, ~1 \\le j \\le M \\nonumber \\\\\nz_j   & \\in & \\{0,1\\}      & 1 \\le j \\le M \\nonumber \n\\end{eqnarray}\n\n\\begin{table}[ht]\n\\caption{List of notations}\n\\begin{center}\n\\begin{tabular}{|l@{ : }l|} \n\\hline\n$N$ & Total number of orders.\\\\\n$M$ & Total number of slabs. \\\\\n$N^i$ & Set of slabs incident to order $i$. \\\\\n$N_j$ & Set of orders incident to slab $j$. \\\\\n$w^i$ & Weight of order $i$. \\\\\n$W_j$ & Weight of slab $j$. \\\\ \n$C_j$ & Set of colors incident on slab $j$. \\\\\n$c^i$ & The color of order $i$. \\\\\n$x^i_j$ & 1 if order $i$ is assigned to slab $j$; 0 otherwise. \\\\\n$y^c_j$ & 1 if orders of color $c$ obtain material from slab $j$; 0\notherwise.\\\\\n$z_j$ & 1 if any order is incident to slab $j$; 0 otherwise. \\\\\n\\hline \n\\end{tabular}\n\\end{center}\n\\end{table}\n\nThe total number of variables in this formulation is \n$$\n\\sum_{i=1}^{N} |N^i| + \\sum_{j=1}^{M} |C_j| + M \\quad=\\quad \n\\sum_{j=1}^{M} |N_j| + \\sum_{j=1}^{M} |C_j| + M\n$$\nwhile the total number of constraints is $2\\sum_{i=1}^{N} |N^i| + 2M + N$.\n\nConstraints (\\ref{con-ks}) specify that if a slab is used then the total\nweight of the orders assigned to the slab cannot exceed the weight of the\nslab; Constraint (\\ref{con-order}) describes that each order will be made at\nmost once; while constraints (\\ref{con-col1}) and (\\ref{con-col2}) enforce the\ncoloring restriction.\n\nNotice that the objective function is non-linear. However, since $z_j = 0$\nforces $x^i_j$ to be zero for all $i \\in N_j$ and $z_j = 1$ implies\n$x^i_j z_j = x^i_j$, for all feasible solutions the objective function is\nequivalent to \n$$\n\\sum_{i = 1}^{N}\\sum_{j \\in N^i} w^i x^i_j -\n    \\sum_{i = 1}^{N} ( W_j z_j - \\sum_{j \\in N^i} w^i x^i_j ) =\n\\sum_{i = 1}^{N}\\sum_{j \\in N^i} 2w^i x^i_j - \\sum_{i = 1}^{N} W_j z_j \n$$.\n\nThe final observation is that the objective function just combines the two\nstated goals (maximizing satisfied orders and minimizing wasted parts of\nslabs) with equal weights. This may or may not be the best composite\nobjective, but this is how the creator of the application specified the\nproblem. Also, all that a different composite weight would change is the\nmultiplier $2$ for $w^i$ (the coefficient of $x^i_j$) and the multiplier $1$\nfor $W_j$ (the coefficient of $z_j$); nothing in the proposed algorithms would\nneed to be changed.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{A formulation suitable for column generation}\n\nThis new formulation has significantly more columns than the original\nformulation, on the other hand it results in a well studied problem, the set\npacking problem (\\cite{NW}).\n\nThere are two types of constraints in this formulation. The first type\ncorresponds to the slabs in the problem, the second type to the orders. The\nvariables represent feasible production patterns, that is, variable $u$ has a\n$1$ in the row corresponding to the slab the production pattern is to be made\nof and $1$'s in the rows corresponding to the orders in the production\npattern. Each variable is a binary variable indicating whether that production\npattern is chosen in the solution or not. Let us introduce the following\nnotation:\n\\begin{itemize}\n\\item $P$ is the set of feasible production patterns;\n\\item $P_j$ is the set of set of feasible patterns manufacturable from slab\n  $j$;\n\\item $P^i$ is the set of set of feasible patterns containing order $i$;\n\\item $R_k$ is the row (constraint) corresponding to the slab the production\n  pattern corresponding to $u_k$ is made of; and\n\\item $R^k$ is the set of rows (constraints) corresponding to the orders in\n  the production pattern corresponding to $u_k$.\n\\end{itemize}\nLet the cost of variable $u_k$ be $\\bar{c}_k = \\sum_{i\\in R^k} 2w^i - W_{R_k}$\nand create the following set packing problem:\n\\begin{eqnarray}[rclqql]\n\\multicolumn{3}{l}{\\max \\sum_{k\\in P} \\bar{c}_k u_k} & \\nonumber \\\\\n\\sum_{k\\in P^i} u_k & \\le & 1 & \\forall 1 \\le i \\le N \\\\\n\\sum_{k\\in P_j} u_k & \\le & 1 & \\forall 1 \\le j \\le M \\\\\n\\multicolumn{3}{l}{u_k\\in\\{0,1\\}} & \\forall k \\in P \\nonumber\n\\end{eqnarray}\n\nIt is very easy to see that there is a one to one correspondence between the\nfeasible solutions of this set packing problem and the feasible solutions of\nthe original formulation. Moreover, the construction of the $\\bar c$ cost\nvector ensures that the corresponding solutions have identical objective\nvalues. Therefore optimizing this problem is the same as optimizing the\noriginal formulation.\n\nThe obvious problem with this formulation is that the number of feasible\nproduction patterns is enormous. \n\n\\subsection{Generating columns with positive reduced costs}\nTo improve the solution evenly, for each slab we generate a production pattern\nwhose corresponding column has the highest reduced cost, i.e., the most\npositive if there is one with positive reduced cost. Finding these columns is\nagain a set of optimization problems, since for a dual vector $\\pi$ the\nreduced cost of variable $u_k$ whose production pattern is made of slab $j$ is\nsimply\n\\begin{equation}\n\\bar{c}_k - \\pi_j - \\sum_{i\\in R^k} \\pi^i = \n\\sum_{i\\in R^k}2w^i - W_j - \\pi_j - \\sum_{i\\in R^k} \\pi^i =\n- (W_j + \\pi_j) + \\sum_{i\\in R^k} (2w^i - \\pi^i)\n\\end{equation}\nand we want to maximize this over the set of production patterns that can be\nmanufactured from slab $j$. For a fixed $j$ the first term is constant. The\nfeasible production patterns from slab $j$ are those that satisfy the capacity\nand color constraints, thus this problem is equivalent to (using the notation\nfrom the original formulation):\n\\begin{eqnarray}[rcl]\n\\multicolumn{3}{l}{\\max\\sum_j (2w^i - \\pi_i) x^i_j} \\\\\n\\sum_i w^i x^i_j & \\le & W_j \\\\\n\\sum_i y^{c(i)}_j & \\le & 2 \\\\\n\\multicolumn{3}{l}{x^i_j \\in \\{0,1\\}}\n\\end{eqnarray}\nwhich is a knapsack problem with the side constraint that selected objects\nmust have no more than two different colors. Moreover, the constant term in\nthe reduced cost implies that we are only looking for production patterns\nwhose reduced cost exceeds $W_j + \\pi_j$. Since solving the LP relaxation of\nthe knapsack problem (even with the side constraint) is rather simple, this\nrequired lower bound on the reduced cost can be very helpful in quickly\nconcluding that there is no improving pattern for a particular slab.\n\n\\subsection{Upper bounding}\n\nThe previous subsection addresses the issue of how to solve the full LP\nrelaxation by iteratively solving smaller LP relaxations and generating\ncolumns, but we need something more. We need to be able to derive an upper\nbound on the optimal objective value of the full LP relaxation in every\niteration. There are two reasons for this. The first is that in a\nBranch-and-Price algorithm we can fathom a search tree node if the upper bound\non the optimal objective value of the LP relaxation at the node is already\nlower than the value of a currently known feasible solution. Since we may not\nbe able to solve the subproblems that generate the columns (after all, even\nthough the knapsack problem is considered relatively easy, it {\\em is}\nNP-complete) we still want to have an upper bound for fathoming purposes. The\nsecond reason is that without an upper bound on the optimal value of the LP\nrelaxation of the full problem we couldn't tell how close we are to\noptimality, we wouldn't have a proven gap.\n\nFortunately, upper bounding is very easy using Dantzig-Wolfe decomposition\n\\cite{dantzig-wolfe}. Since the sum of all variables in $P_i$ is not more than\n$1$, the objective value of the LP relaxation cannot change more than the\nhighest reduced cost (or an upper bound on that value) as a result of changing\nthe values of the variables in $P_i$. To get an upper bound on the reduced\ncost we can use the LP relaxation of the subproblem (the side constrained\nknapsack problem) which is very easy to solve. Now adding all ``per slab''\nupper bounds to the optimal objective value of the current LP relaxation\nyields an upper bound on the optimum of the full LP relaxation.\n\n\\subsection{Finding integral feasible solutions}\n\nAnother advantage of the column generation based formulation is that it is\nvery easy to generate feasible solutions. In each iteration we considered the\nfractional solution and started by including every variable above $0.5$ in the\nsolution. From the set of remaining fractional variables we exluded all that\nintersected the already selected variables. Whatever remained afterwards was\nalways such a small set that we could solve the set packing problem on that\nset by enumeration.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Implementation details}\n\n\\subsection{Cuts, variables and solutions}\nFirst of all, we did not have to worry about anything cut generation related,\nsince we were not generating cuts. Since the number of constraints is not too\ngreat (number of orders + number of slabs) we decided to treat all of them as\ncore constraints, thus completely eliminating the need to bother about cuts.\n\nFor the variables first we had to decide which ones are going to be core\nvariables and which ones will be extra variables. Since we had no\nreason to believe that any one particular pattern was more likely to be in\nan optimal solution than some other pattern we decided not to have core\nvariables at all (this also simplified coding somewhat). Since the variables\nare the feasible production patterns, they do not lend themselves to any\nenumeration scheme, so we decided not to have indexed variables either.\nTherefore all our variables are algorithmic ones. Actually, we had two kind of\nalgorithmic variables, one for the production patterns and another one for\nbranching, but we will discuss that latter in Section \\ref{mkc:branching}. Both\ntypes of variables are derived from \\code{BCP\\_var\\_algo} and are defined in\n\\code{MKC\\_var.hpp}.\n\nWe have defined our solution class for two reasons. First, all our pattern\nvariables are binary variables so there is no reason to include the value of\nthe non-zero ones. Second, there might be branching variables (not pattern\nvariables) that are at nonzero level as we go down in the tree, and we didn't\nwant to include those in a feasible solution. Still, if we wanted to, we could\nhave used a generic solution type. We just thought that using our own solution\ntype makes the code clearer. \n\n\\subsection{Branching}\nThe problem with branching when generating columns is that we must be able to\ngenerate columns after branching, too. In other words, every generated column\nmust conform to whatever branching decisions have been made to that point.\nThat means that branching on a regular variable is out of question. On one\nside (when it is fixed to 1) we'd have great results, it would significantly\nshrink the search space. However, on the other side (fixing the variable to 0)\nthe restriction is that we cannot regenerate that variable. But that variable\nwill almost always ``want to be regenerated'' (definitely immediately after\nbranching), since its reduced cost will make it attractive (after all, we have\nforcibly moved it away from where it ended up in the LP-optimal solution). So\nfor our problem this would mean that after one branching we have to check the\noptimal solution to the knapsack subproblem and if it is the forbidden\nvariable then we have to find the second best solution. After two branchings\nwe may have to find the third best solution, etc. This is impossible. \n\nInstead, the following logic is introduced. A branching object will specify\nwhether a particular order $O$ is manufactured from slab $S$ or not.\n\n\\subsection{Packing and unpacking}\n\nPacking and unpacking of user objects is really straightforward. For example,\nlook at the \\code{MKC\\_var\\_(un)pack()} functions. The packing function packs\nthe \ntype of each variable and invokes the pack member of the variables while the\nunpacking function unpacks the types and invokes the appropriate constructor. \n\nIn general, when an object is packed it is simply torn down to built-in types\nand those are packed. On the other side the date is unpacked in the same order\nand the appropriate objects are constructed. In the following subsection we\nwill not mention the (un)packing member methods.\n\n\\subsection{MKC\\_init}\n\nThis is the implementation of the intializer class. The TM initializer reads\nin the problem and the parameters. Unfortunately this piece is rather\ncomplicated since the problem is specified as an MPS file and we have to\nextract order and slab information from it. The problem is loaded into the\n\\code{kss} member of the \\code{MKC\\_tm} class. See the \\code{MKC\\_knapsack.hpp}\nfile for data structures. Once the problem is read in a pointer to the \n\\code{MKC\\_tm} class is returned. The LP initializer just returns a pointer to\nan empty \\code{MKC\\_lp} object.\n\n\\subsection{MKC\\_tm}\n\nThere were only four methods (besides the (un)packing ones) we had to deal\nwith. Initializing the core consisted of simply specifying the core cuts as we\nhad no core variables (hence no core matrix). Since we had no core variables\nwe had to add some extra variable in creating the root. There are two options\nfor this, one is to add those variables that were read in from a file (maybe\nas a result of a previous run), or we could generate columns for the all zero\ndual solution (which is in some sense the optimal solution if we have no\nvariables...). Displaying the solution has the option to test the solution\nthat it really satisfies the original formulation (we have used this for\ndebugging purposes) and then the solution is printed in two different ways.\nFinally, there will be only one phase and we will generate columns in it, so\nwe set this in the \\code{init\\_new\\_phase()} method.\n\n\\subsection{MKC\\_lp}\n\n\n\n\n\n", "meta": {"hexsha": "07dd5f206ac1598cdb8a2531f8bdc581d6e9931a", "size": 17568, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gsa/wit/COIN/Bcp/Doc/Manual/man-mkc.tex", "max_stars_repo_name": "kant/CMMPPT", "max_stars_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-25T05:25:23.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-25T05:25:23.000Z", "max_issues_repo_path": "gsa/wit/COIN/Bcp/Doc/Manual/man-mkc.tex", "max_issues_repo_name": "kant/CMMPPT", "max_issues_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-09-04T17:34:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-16T08:10:57.000Z", "max_forks_repo_path": "gsa/wit/COIN/Bcp/Doc/Manual/man-mkc.tex", "max_forks_repo_name": "kant/CMMPPT", "max_forks_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2019-07-22T19:01:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T15:36:11.000Z", "avg_line_length": 53.2363636364, "max_line_length": 79, "alphanum_fraction": 0.7474385246, "num_tokens": 4501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4369709181176522}}
{"text": "\\chapter{Natural Gas Flow}\n\\label{chap:fund_NGF}\n\nThe steady-state Natural Gas Flow (NGF) problem for transmission networks is aimed at finding the value for a set of state-variables that satisfy the flow balance in all nodes. We show how the NGF can be derived in a similar way as the Power Flow (PF) problem is introduced for power systems. In  particular, a set of nonlinear equations must be solved where the definition of the state-variables depends on the selected models for all of the elements of the system. In this section, we derive the NGF problem and introduce the modeling for the main elements considered in \\mpng{}: nodes, wells, pipelines, compressors, and storage units.\n\n\\section{Modeling}\n\\label{sec:gas_modeling}\n\nAn exact description of the natural gas flow in transmission networks requires applying the laws of fluid mechanics and thermodynamics \\cite{Osiadacz2001}. Complex analyses provide an accurate description for variables such as temperature, pressure, flow, adiabatic head, among others, for all time instants. However, as the primary concern of \\matpower{} (and of \\mpng{}) is the system operation in steady-state, we define some models to describe the main elements of the default natural gas network, as explained below. \n\n\\subsection{Nodes}\n\\label{subsec:nodes}\n\nBy definition, a node is the location of a natural gas system where one or more elements are connected. Users are commonly associated with a node where a stratified demand is modeled as different market segments that get different priorities. Figure \\ref{fig:node} shows the $i$-th node of a gas network with some traditional markets connected to form the nodal demand $f_{dem}=\\sum_{j} f_{\\text{dem}_j}$. The primary variable related to a node is pressure $p_i$, although, as explained later, the actual state variable used in \\mpng{} is the quadratic pressure. \n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=1.2]{Figures/Node}\n\t\\caption{A natural gas node and some traditional markets.}\t\n\t\\label{fig:node}\n\\end{figure}\n\n\n\\subsection{Wells}\n\\label{subsec:wells}\n\nNatural gas is extracted from deep underground and injected into the system from wells. Depending on the well capacity, the injection can be made either at constant pressure, where a control system regulates the amount of gas flow such that pressure behaves constant, or at constant flow, where pressure is adjusted such that injected flow remains constant. Figure \\ref{fig:well} shows a well connected to the $i$-th node whose operation depends on two principal variables, the injected gas flow $f_{inj}^w$, and the nodal pressure $p_i$.\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=0.9]{Figures/Well}\n\t\\caption{A natural gas well.}\t\n\t\\label{fig:well}\n\\end{figure}\n\n\\subsection{Pipelines}\n\\label{subsec:pipelines}\n\nIn general, the flow of gas through pipes is studied using the energy equation of fluid mechanics~\\cite{Banda2006}. However, in practice, the relationship between the gas flow in the pipe and the upstream and downstream pressures can be described by various equations. The Weymouth's general flow equation is a frequent choice in gas industry applications to model the steady-state flow in pipes in gas transports networks~\\cite{Woldeyohannes2011}. Figure \\ref{fig:pipeline} shows a pipeline $o$ whose gas flow from node $i$ to node $j$ is represented by $f_{ij}^o$. The Weymouth equation states the relationship between $f_{ij}^o$, $p_i$, and $p_j$ in the following form:\n\n\\begin{equation}\n\t\\label{eq:Weymouth_eq1}\n\t\\text{sgn}(f_{ij}^o)(f_{ij}^o)^2 = K_{ij}(p_i^2-p_j^2). \n\t\\vspace{0.3cm}\n\\end{equation}\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=1]{Figures/Pipeline}\n\t\\caption{A natural gas pipeline.}\t\n\t\\label{fig:pipeline}\n\\end{figure}\n\nIn Equation \\ref{eq:Kij}, $\\text{sgn}(\\cdot)$ represents the sign function, and $K_{ij}$ is the  Weymouth constant\\footnote{Measured in Million Standard Cubic Feet per Day (MMSCFD) over psia. Different expressions for $K_{ij}$ can be derived depending on the parameters used in the flow equations. See \\cite{Woldeyohannes2011} and reference therein for details.} of the pipeline defined in terms of the pipe length and diameter as below~\\cite{Wolf2000}:\n\n\\begin{equation}\n\t\\label{eq:Kij}\n\tK_{ij} = \\sqrt{5.695756510\\times 10^{-13}\\:\\frac{D^5}{\\lambda Z T L\\delta}}\\quad \\left[\\frac{\\text{MSCFD}}{\\text{psia}}\\right],\n\t\\vspace{0.3cm}\n\\end{equation}\n\nwhere: \n\n\\begin{equation}\n\t\\label{eq:lambda_Kij}\n\t\\frac{1}{\\lambda} = \\left[2\\log \\left(\\frac{3.7D}{\\varepsilon}\\right)\\right]^2,\n\t\\vspace{0.3cm}\n\\end{equation}\n\nwith:\n\n\\begin{labeling}{alligator}\n\t\\item [$\\qquad \\qquad  D$]  \\hspace{0.8cm} Diameter [in].\n\t\\item [$\\qquad \\qquad  L$]  \\hspace{0.8cm} Length [km]. \n\t\\item [$\\qquad \\qquad  T$] \\hspace{0.8cm} Gas temperature [K].\n\t\\item [$\\qquad \\qquad  \\varepsilon$] \\hspace{0.8cm} Absolute rugosity [mm].\n\t\\item [$\\qquad \\qquad  \\delta$] \\hspace{0.8cm} Gas density relative to air [-].\n\t\\item [$\\qquad \\qquad  Z$] \\hspace{0.8cm} Gas compressibility factor [-].\n\\end{labeling}\n\nFor mathematical convenience, we rewrite Equation \\ref{eq:Weymouth_eq1} as follows:\n\n\\begin{equation}\n\t\\label{eq:Wymouth_eq_2}\n\tf_{ij}^o = K_{ij} \\;\\text{sgn}(\\pi_i - \\pi_j)\\sqrt{|\\pi_i-\\pi_j|},\n\t\\vspace{0.3cm}\n\\end{equation}\n\n\\noindent where $\\pi=p^2$ is defined as the quadratic pressure. \n\nAs seen, the gas flow through a pipeline is a nonlinear function of the quadratic pressures of the initial and final nodes, that is, $f_{ij}^o=g(\\pi_i,\\pi_j)$. \n\n\\subsection{Compressors}\n\\label{subsec:compressors}\nAs seen in Equation \\ref{eq:Wymouth_eq_2}, there exists a downstream pressure drop when transporting large flows through pipes caused by energy losses. Analogous to the transformer in power systems, compressors are installed in the gas network to compensate pressure drops. Figure \\ref{fig:compressor} shows a compressor $c$ that increases the discharge pressure $p_j$ with respect to the suction pressure $p_i$ by compressing gas in a way that a flow $f_{ij}^c$ passes through it. Assuming an adiabatic process, the power demanded by the compressor, $\\psi_c$, states the relationship between the flow and the suction and discharge pressures in the following way~\\cite{Shabanpour2016}:\n\n\\begin{equation}\n\t\\label{eq:comp_flow}\n\tf_{ij}^c = \\frac{\\psi_c}{B_c \\left[\\left(\\frac{\\pi_j}{\\pi_i}\\right)^{\\frac{Z_c}{2}}-1\\right]},\n\t\\vspace{0.3cm}\n\\end{equation}\n\nwhere $B_c$ is the compressor constant that describes its construction features, $Z_c$ is the compressibility factor, and $\\pi=p^2$ is again the quadratic pressure.\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=0.9]{Figures/Compressor}\n\t\\caption{A natural gas compressor.}\t\n\t\\label{fig:compressor}\n\\end{figure}\n\nMoreover, the compressor ratio, $\\beta_c$, is defined as below:\n\n\\begin{equation}\n\t\\label{eq:comp_ratio}\n\t\\beta_c = \\frac{\\pi_j}{\\pi_i}, \\quad \\beta_c\\geq 1.\n\t\\vspace{0.3cm}\n\\end{equation}\n\nIn general, there exist two types of compressors: the power-driven compressors, whose demanded energy is supplied from the power system, and the gas-driven compressors, that require additional gas to operate. In the latter, the additional gas demanded at the suction node, $\\phi_c$, can be expressed as a quadratic function of the power as~\\cite{Chen2017}:\n\n\\begin{equation}\n\t\\label{eq:f_cons_gas_comp}\n\t\\phi_c = x+y\\psi_c+z\\psi_c^2, \n\t\\vspace{0.3cm}\n\\end{equation}\n\nwhere $x,y,z \\in \\Real$.\n\nNotice that the gas flow through a compressor (as well as the consumed flow for a gas-driven compressor) is a function of the consumed power and the quadratic suction and discharge pressures, that is, $f_{ij}^c=h(\\pi_i,\\pi_j,\\psi_c)$. \n\n\\subsection{Storage Units}\n\\label{subsec:sto_units}\n\nThe possibility of storing natural gas provides flexibility with regards to production and transportation decisions~\\cite{Midthun2007}. A storage unit is a reservoir that allows both storing from and injecting gas to the gas network. Figure \\ref{fig:storage} shows a storage unit located at node $i$ with an associated gas flow $f_s$ that could be either an \\textit{outflow} in the case of injection to the system or an \\textit{inflow} in the case of a storing operation. Then, in a node with a specific demand and injection, the (known) value of $f_s$ could be added to the nodal demand when it is a storage inflow or could be summed to the injection flow of a constant-flow well when it is a storage outflow.\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=1]{Figures/Storage_unit}\n\t\\caption{A natural gas storage unit.}\t\n\t\\label{fig:storage}\n\\end{figure}\n\n\\section{Deriving the Natural Gas Flow Problem}\n\\label{sec:NGF_problem}\n\nLet us consider the transmission natural gas network shown in Figure \\ref{fig:nodal_balance}. According to the principle of conservation of mass, the balance equation applied to the node $i$ states:\n\n\\begin{equation}\n\t\\label{eq:balance_eq}\n\tf_{inj} - f_{dem} \\pm f_s = \\sum_{\\substack{j=1 \\\\ j \\neq i}}^{m} f_{ij},\n\\end{equation}\n\nwhere $f_{dem}$ is the known demand flow, $f_s$ is either the  inflow (negative) or outflow (positive) of the storage unit, and $f_{inj}$ is the injected flow of the well. \n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=0.95]{Figures/Gas_flow_problem}\n\t\\caption{Nodal balance in a transmission natural gas network.}\t\n\t\\label{fig:nodal_balance}\n\\end{figure}\n\nNotice in equation \\ref{eq:balance_eq} that the left hand side is a known value if injection is produced by a constant-flow well. However, for a constant-pressure well, the value of $f_{iny}$ must be determined. In turn, the algebraic sum of the right hand side depends on the nature of the elements connected between nodes $i$ and $j$ such that $f_{ij}$ takes the form of $f_{ij}^o$ or $f_{ij}^c$, according to Equations \\ref{eq:Wymouth_eq_2} and \\ref{eq:comp_flow}, for a pipeline or a compressor, respectively. Moreover, for a gas-driven compressor, the additional gas consumption $\\phi_c$ must be considered as an outflow in Equation \\ref{eq:balance_eq} if node $i$ matches the suction node for compressor $c$.\n\n%such that $f_{ij}$ is $g(\\pi_i,\\pi_j)$, $h(\\pi_i,\\pi_j,\\psi_c)$, or $h(\\pi_i,\\pi_j,\\psi_c)+\\phi_c(\\psi_c)$ for a pipeline, a power-driven compressor, and a gas-driven-compressor, respectively.\n\nAs a consequence, we can rewrite the balance equation applied at node $i$ in a functional form as follows:\n\n\\begin{equation}\n\t\\label{eq:balance_eq_funtional}\n\t\\mathbb{F}_i\\left(\\pi,\\psi_c,f_{iny}^{w}\\right) = 0.\n\t\\vspace{0.3cm}\n\\end{equation}\n\nIn practice, for a given gas network with $n_n$ nodes, $n_c$ compressors, and $n_{w_p}$ constant-pressure wells, the application of the balance equation for all nodes will produce a set of $n_n$ nonlinear equations with a number of $(n_n-n_{w_p})+n_c+n_{w_p} = n_n+n_c$ unknown variables. To get a square system with the same number of equations and variables, the $n_c$ missing equations are obtained from the compressor ratios of all compressors. Then, the NGF problem can be formulated as follows:\n\n\\begin{equation}\n\t\\label{eq:F_i=0}\n\t\\mathbb{F}_i\\left(\\pi,\\psi_c,f_{iny}^{w}\\right) = 0, \\quad \\forall i\\in\\mathcal{N}, c\\in\\mathcal{C}; w\\in\\mathcal{W}_p, \t\n\\end{equation}\n\n\\begin{equation}\n\t\\label{eq:R_c=0}\n\t\\beta_c = \\frac{\\pi_j}{\\pi_i}, \\quad \\forall c\\in\\mathcal{C}, \\;  i,j\\in\\mathcal{N},\n\t\\vspace{0.3cm}\n\\end{equation}\n\nwhere\n\n\\begin{labeling}{alligator}\n\t\\item [$\\qquad \\qquad  \\mathcal{N}$]  \\hspace{0.85cm} Set of gas nodes, $|\\mathcal{N}|=n_n$.\n\t\\item [$\\qquad \\qquad  \\mathcal{C}$]  \\hspace{1cm} Set of compressors, $|\\mathcal{C}|=n_c$. \n\t\\item [$\\qquad \\qquad  \\mathcal{W}_p$] \\hspace{0.65cm} Set of constant-pressure wells, $|\\mathcal{W}_p|=n_{w_p}$.\t\n\\end{labeling}\n\n\n\n", "meta": {"hexsha": "abb444974d48acf99796f74fecd092047a5c6280", "size": 11672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MPNG_User's_Manual/Chapters/Natural_Gas_Flow.tex", "max_stars_repo_name": "MATPOWER/mpng", "max_stars_repo_head_hexsha": "550370c8dda85c3aea0e86a63a907a09955aa3ce", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-10-01T16:05:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-06T10:57:21.000Z", "max_issues_repo_path": "MPNG_User's_Manual/Chapters/Natural_Gas_Flow.tex", "max_issues_repo_name": "Segama/mpng", "max_issues_repo_head_hexsha": "0c99baa5ee8c43851a0b12192476fc5d7beeaa37", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MPNG_User's_Manual/Chapters/Natural_Gas_Flow.tex", "max_forks_repo_name": "Segama/mpng", "max_forks_repo_head_hexsha": "0c99baa5ee8c43851a0b12192476fc5d7beeaa37", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-01T16:09:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-20T04:16:02.000Z", "avg_line_length": 58.9494949495, "max_line_length": 714, "alphanum_fraction": 0.7491432488, "num_tokens": 3439, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.43692239734481736}}
{"text": "\\documentclass{subfile}\n\n\\begin{document}\n\t\\section{AzNO}\\label{sec:azno}\n\t\n\t\t\\begin{problem}[$2020$ National Olympiad, problem $3$]\n\t\t\t$a,b,c$ are positive real numbers such that $a+b+c=3$. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\sum\\dfrac{a^{2}+6}{2a^{2}+2b^{2}+2c^{2}+2a-1}\n\t\t\t\t\t\t& \\leq3\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2015$ National Olympiad, problem $1$]\n\t\t\tLet $a,b,c$ be positive real numbers such that $abc=\\frac{1}{8}$. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\ta^{2}+b^{2}+c^{2}+a^{2}b^{2}+b^{2}c^{2}+c^{2}a^{2}\n\t\t\t\t\t\t& \\geq\\dfrac{15}{16}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2016$ Team Selection Test, problem $1$, day $3$]\n\t\t\tLet $a_{1},a_{2},\\ldots$ be a sequence of positive real numbers such that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\ta_{k+1}\n\t\t\t\t\t\t& \\geq\\dfrac{ka_{k}}{a_{k}^{2}+k-1}\n\t\t\t\t\\end{align*}\n\t\t\tfor every positive integer $k$. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\ta_{1}+\\ldots+a_{n}\n\t\t\t\t\t\t& \\geq n\n\t\t\t\t\\end{align*}\n\t\t\tfor every positive integer $n$.\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2016$ Balkan Mathematical Olympiad Team Selection Test $4$, problem $1$]\n\t\t\tLet $a,b,c$ be non-negative real numbers. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t3(a^{2}+b^{2}+c^{2})\n\t\t\t\t\t\t& \\geq (a+b+c)\\left(\\sqrt{ab}+\\sqrt{bc}+\\sqrt{ca}\\right)+(a-b)^{2}+(b-c)^{2}+(c-a)^{2}\n\t\t\t\t\t\t  \\geq (a+b+c)^{2}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\\end{document}", "meta": {"hexsha": "e1f009f0ee3e6f134a5fe9bd514788d05b4d4c15", "size": 1364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "azno.tex", "max_stars_repo_name": "ineq-tech/inequality", "max_stars_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-06T08:29:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-06T08:29:30.000Z", "max_issues_repo_path": "azno.tex", "max_issues_repo_name": "ineq-tech/inequality", "max_issues_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "azno.tex", "max_forks_repo_name": "ineq-tech/inequality", "max_forks_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0, "max_line_length": 92, "alphanum_fraction": 0.5784457478, "num_tokens": 581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.43692239713061193}}
{"text": "\\section{Conclusions}\n\nFor what about the SVM formulations, it is known, in general, that the \\emph{primal formulation}, is suitable for large linear training since the complexity of the model grows with the number of features or, more in general, when the number of examples $n$ is much larger than the number of features $m$, i.e., $n \\gg m$; meanwhile the \\emph{dual formulation}, is more suitable in case the number of examples $n$ is less than the number of features m, i.e., $n < m$, since the complexity of the model is dominated by the number of examples, or more in general when the training data are not linearly separable in the input space.\n\n\\bigskip\n\nFrom all these experiments we can see as all the \\emph{custom} implementations underperforms all the others, i.e., both \\emph{cvxopt}~\\cite{vandenberghe2010cvxopt} and \\emph{sklearn} implementations, i.e., \\emph{liblinear}~\\cite{fan2008liblinear} and \\emph{libsvm}~\\cite{chang2011libsvm} implementations, in terms of \\emph{time} obviously due to the different core implementation languages, i.e., Python and C respectively.\n\nIn the \\emph{primal} formulations the \\emph{liblinear}~\\cite{fan2008liblinear} implementation uses an optimization method called \\emph{Coordinate Gradient Descent} which minimizes one coordinate at a time.\n\nMeanwhile, for what about the \\emph{Wolfe dual} formulations we can notice as \\emph{cvxopt}~\\cite{vandenberghe2010cvxopt} underperforms the \\emph{sklearn} implementation, i.e., \\emph{libsvm}~\\cite{chang2011libsvm} implementation, in terms of \\emph{time} since it is a general-purpose QP solver and it does not exploit the structure of the problem, as SMO does. An intresting consideration can be made about the number of \\emph{iterations} of \\emph{custom} SMO implementation wrt that in \\emph{libsvm} which seems to be always lower thanks to the improvements described in~\\cite{keerthi2001improvements, shevade1999improvements} for classification and regression respectively.\n\nFinally, in the \\emph{Lagrangian dual} formulations the goodness of the solution in terms of \\emph{accuracy} or \\emph{r2} values depends on the residue in the solution of the \\emph{Lagrangian dual} at each step provided by \\emph{minres} algorithm. Moreover, we can see as fitting the intercept in an explicit way, i.e., by adding Lagrange multipliers to control the equality constraint always get lower scores wrt the \\emph{Lagrangian dual} of the same problem with the bias term embedded into the weight matrix.\n\n", "meta": {"hexsha": "1c6961abd0a07ea8a711eea1454122cc7cff0b08", "size": 2487, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_stars_repo_name": "AF207/optiml", "max_stars_repo_head_hexsha": "f8860d90d4f5b6d35a3ed0ef3c1d014a2b517a72", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-06T13:59:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-06T13:59:03.000Z", "max_issues_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_issues_repo_name": "AF207/optiml", "max_issues_repo_head_hexsha": "f8860d90d4f5b6d35a3ed0ef3c1d014a2b517a72", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notebooks/optimization/tex/conclusions.tex", "max_forks_repo_name": "AF207/optiml", "max_forks_repo_head_hexsha": "f8860d90d4f5b6d35a3ed0ef3c1d014a2b517a72", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 165.8, "max_line_length": 675, "alphanum_fraction": 0.791716928, "num_tokens": 658, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.4369223867184759}}
{"text": "\\section{Equations}\n\t\\label{sec:typesetting_equations}\n\t\n\tTypesetting equations is one of the things that LaTeX does best. It has packages for different fonts and symbols for many different mathematical notations. However, to person learning how to typeset in LaTeX for the first time it can be a daunting and unwieldy user experience. Almost all LaTeX packages have documentation available in pdf format online, and documentation for packages specifically relating to fonts and symbols usually have tables enumerating the names and codes for all of the fonts symbols, organized by intended usage. \n\t\n\t\\subsection{Inline equations}\n\t\n\tSmall equations like $x = 0$ can be written directly within the text by using LaTeX's maths mode shorthand controlled by dollar signs \\lstinline|$ math mode $|. As long as it is not becoming cumbersome to the reader, equations such as $\\mathbb{P}({A} \\cap {B}) = \\mathbb{P}({B} \\cap {A})$ are quite neatly displayed in this fashion. \n\t\n\t\\newpage \n\t\n\t\\subsection{Block equations}\n\t\n\t\tFor long equations it is best to provide a break in the main text of the document and format the equation using a \\lstinline|\\begin{equation}...\\end{equation}| environment. \n\t\t\n\t\t\\begin{equation} \\label{eq:veclen}\n\t\t\t\\left\\lvert a \\right\\rvert = \\left\\lvert \\left[\\begin{array}{c} a_0\\\\ a_1\\\\ \\vdots\\\\ a_n\\end{array}\\right] \\right\\rvert = \\sqrt{a_0^2 + a_1^2 + \\hdots + a_n^2}\n\t\t\\end{equation}\n\t\t\n\t\tEquation \\ref{eq:veclen} demonstrates formatting a larger equation and uses an \\lstinline|\\begin{array}...\\end{array}| environment to structure a column vector of sub-equations. Block equations should be located at a relevant point directly as they are being referred to in the text. When referred to from other locations in the document you should use the \\lstinline|\\ref{key}| command to insert the correct equation number.\n\t\t\n\t\t\\subsubsection{Aligning multi-line block equations}\n\t\t\n\t\t\tWhen equations become even larger they may need cross over multiple new lines. When this happens it is desirable to align relevant parts of the equation on each line to one another for aesthetic reasons and to help imply structure to the reader. \n\t\t\n\t\t\t\\begin{equation} \\label{eq:rendering_equation}\n\t\t\t\t\\begin{split}\n\t\t\t\t\t\\mathcal{L}_o\\left(x, \\omega_o, \\lambda, t\\right) &= \\mathcal{L}_e\\left(x, \\omega_o, \\lambda, t\\right)\\\\\n\t\t\t\t\t&+ \\int_\\Omega f\\left(x, \\omega_i, \\omega_o, \\lambda, t\\right) \\mathcal{L}_i\\left(x, \\omega_i, \\lambda, t\\right) \\left(\\omega_i \\bullet n\\right) d\\omega_i\\\\\n\t\t\t\t\t&\\text{where} \\quad \\mathcal{L}_i\\left(x, \\omega_i, \\lambda, t\\right) = \\mathcal{L}_o\\left(x^\\prime, -\\omega_i, \\lambda, t\\right)\\\\\n\t\t\t\t\\end{split}\n\t\t\t\\end{equation}\n\t\t\t\n\t\t\tEquation \\ref{eq:rendering_equation}, known as Kajiya's Rendering Equation \\cite{kaj86} demonstrates the use of the \\lstinline|\\begin{split}...\\end{split}| environment which uses a single un-escaped \\& symbol placed on each line of the equations LaTeX code to indicate where each line should be co-aligned. In this example the \\&'s were placed on the =, +, and w (in where) characters.\n\t\t\t\n\t\\subsection{A masochistic approach to learning to typeset mathematics in LaTeX}\n\t\n\t\t\\input{./graphics/texnique}\n\t\t\n\t\tTeXnique \\cite{texnique} is web-browser based game for practising how to typeset equations in LaTeX. The game will present you with a rendered equation and your task is to type LaTeX code into the box below it such that your code produces the same (or closely matching / pixel equivalent) rendered equation. Figure \\ref{fig:texnique} shows the game during play, the bottom rendered equation is bordered in green to indicate it is a valid match with the target. \n\n\t\t% An example of how to center a passage of text, control local fontsize, \n\t\t% and create a properly formatted and clickable URL.\n\t\t\\begin{center}\n\t\t{\\small \\url{https://texnique.xyz}}\n\t\t\\end{center}\n\t\t\n\t\tThis is one of the more painful parts of typesetting a document, so it really takes a special kind of sadism to come up with such a game. Least to say, graduate students and researchers can be an odd bunch, and when we found this it was surprisingly addictive to compete over. \n\t\t\n\t\t", "meta": {"hexsha": "0bd864c03c5c2a9d332e2eedeed5bae061b325c5", "size": 4134, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis-templates/LaTeX/chapter/thesis_typesetting_equations.tex", "max_stars_repo_name": "CS-Swansea/Computer-Vision-and-Machine-Learning-Wiki", "max_stars_repo_head_hexsha": "490cb0bdbf0ae62dc541b743a1e48cf530be34a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 37, "max_stars_repo_stars_event_min_datetime": "2019-06-12T20:41:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T01:17:07.000Z", "max_issues_repo_path": "thesis-templates/LaTeX/chapter/thesis_typesetting_equations.tex", "max_issues_repo_name": "CS-Swansea/Computer-Vision-and-Machine-Learning-Wiki", "max_issues_repo_head_hexsha": "490cb0bdbf0ae62dc541b743a1e48cf530be34a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-10-21T14:14:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-09T19:27:02.000Z", "max_forks_repo_path": "thesis-templates/LaTeX/chapter/thesis_typesetting_equations.tex", "max_forks_repo_name": "CS-Swansea/Computer-Vision-and-Machine-Learning-Wiki", "max_forks_repo_head_hexsha": "490cb0bdbf0ae62dc541b743a1e48cf530be34a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 29, "max_forks_repo_forks_event_min_datetime": "2019-04-26T10:08:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T15:28:59.000Z", "avg_line_length": 82.68, "max_line_length": 541, "alphanum_fraction": 0.748427673, "num_tokens": 1108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.4369223798484535}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{III}\n\n\\def\\ntitle{Elliptic Curves}\n\\def\\nlecturer{T.\\ A.\\ Fisher}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2019}\n\n\\input{header}\n\n% define \\Sh to be Cyrillic sha\n% https://tex.stackexchange.com/a/124746\n\n\\DeclareFontFamily{U}{wncy}{} \\DeclareFontShape{U}{wncy}{m}{n}{<->wncyr10}{} \\DeclareSymbolFont{mcy}{U}{wncy}{m}{n} \\DeclareMathSymbol{\\Sh}{\\mathord}{mcy}{\"58}\n\n\\theoremstyle{definition}\n\\newtheorem*{fact}{Fact}\n\n\\theoremstyle{theorem}\n\\newtheorem*{conjecture}{Conjecture}\n\n\\renewcommand*{\\P}{\\mathbb{P}}\n\\DeclareMathOperator{\\ord}{ord}\n\\DeclareMathOperator{\\Div}{Div} % divisor\n\\DeclareMathOperator{\\Pic}{Pic} % Picard group\n\\newcommand{\\rational}{\\dashrightarrow} % rational map\n\\renewcommand*{\\O}{\\mathcal{O}}\n\\DeclareMathOperator{\\Cl}{Cl} % Class group\n\\DeclareMathOperator{\\Sum}{sum} % sum map\n\n\\begin{document}\n\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\section{Fermat's method of infinite descent}\n\nLet \\(\\Delta = (a, b, c)\\) be a right angle triangle with sides \\(a, b, c\\) where \\(c\\) is the hypotenuse.\n\n\\begin{definition}\n  \\(\\Delta\\) is rational if \\(a, b, c \\in \\Q\\). \\(\\Delta\\) is primitive if \\(a, b, c \\in \\Z\\) and coprime.\n\\end{definition}\n\n\\begin{lemma}\n  Every primitive triangle is of the form \\((u^2 - v^2, 2uv, u^2 + v^2)\\) for some \\(u, v \\in \\Z, u > v > 0\\).\n\\end{lemma}\n\n\\begin{proof}\n  \\(a\\) and \\(b\\) cannot be both even. They cannot be both odd as then \\(c^2 = 2 \\mod 4\\). Thus wlog \\(a\\) is odd and \\(b\\) is even, so \\(c\\) odd. Then\n  \\[\n    \\left(\\frac{b}{2}\\right)^2 = \\frac{c + a}{2} \\cdot \\frac{c - a}{2}\n  \\]\n  and the two terms on RHS are coprime positive integers. By unique factorisation in \\(\\Z\\), there exist \\(u, v \\in \\Z\\) such that\n  \\begin{align*}\n    \\frac{c + a}{2} &= u^2 \\\\\n    \\frac{c - a}{2} &= v^2\n  \\end{align*}\n  Rearrange.\n\\end{proof}\n\n\\begin{definition}\n  \\(D \\in \\Q_{> 0}\\) is a \\emph{congruent number} if there exists a right angle triangle whose area is \\(D\\).\n\\end{definition}\n\n\\begin{note}\n  Suffices to consider \\(D \\in \\Z_{> 0}\\) square-free.\n\\end{note}\n\n\\begin{eg}\n  \\(D = 5, 6\\) are congruent.\n\\end{eg}\n\n\\begin{lemma}\n  \\(D \\in \\Q_{> 0}\\) is congruent if and only if \\(D y^2 = x^3 - x\\) for some \\(x, y \\in \\Q, y \\neq 0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Lemma 1 shows that \\(D\\) is congruent if and only if \\(Dw^2 = uv(u^2 - v^2)\\) for some \\(u, v, w \\in \\Q, w \\neq 0\\). Let \\(x = \\frac{u}{v}, y = \\frac{w}{v^2}\\).\n\\end{proof}\n\nFermat showed that \\(1\\) is not a congruent number.\n\n\\begin{theorem}\n  There are no solutions to\n  \\begin{equation}\n    \\label{eqn:fermat}\n    w^2 = uv (u - v)(u + v)\n    \\tag{\\ast}\n  \\end{equation}\n  for \\(u, v, w \\in \\Z, w \\neq 0\\).\n\\end{theorem}\n\n\\begin{proof}\n  wlog \\(u, v \\) coprime, \\(u > 0, w > 0\\). If \\(v < 0\\) then replace \\((u, v, w)\\) by \\((-v, u, w)\\). If \\(u = v \\mod 2\\) then replace \\((u, v, w)\\) by \\((\\frac{u + v}{2}, \\frac{u - v}{2}, \\frac{w}{2})\\). Then \\(u, v, u - v, u + v\\) are positive coprime integers whose product is a square. By unique prime factorisation, \\(u = a^2, v = b^2, u + v = c^2, u - v = d^2\\) for some \\(a, b, c, d \\in \\Z_{> 0}\\). As \\(u \\neq v \\mod 2\\), \\(c, d\\) are both odd. Consider a new triangle with sides \\(\\frac{c + d}{2}, \\frac{c - d}{2}\\). Then\n  \\[\n    \\left( \\frac{c + d}{2} \\right)^2 + \\left( \\frac{c - d}{2} \\right)^2 = \\frac{c^2 + d^2}{2} = u = a^2\n  \\]\n  so this is another primitive triangle. Its area is\n  \\[\n    \\frac{c^2 - d^2}{8} = \\frac{v}{4} = \\left( \\frac{b}{2} \\right)^2.\n  \\]\n\n  Let \\(w_1 = \\frac{b}{2}\\) so by lemma 1\n  \\[\n    w_1^2 = u_1v_1 (u_1 - v_1)(u_1 + v_1),\n  \\]\n  i.e.\\ we have a new solution to \\eqref{eqn:fermat}. But \\(4 w_1^2 = b^2 = v \\divides w^2\\) so \\(w_1 \\leq \\frac{1}{2} w\\). So by Fermat's method of infinite descend, there is no solution to \\eqref{eqn:fermat}.\n\\end{proof}\n\n\\subsection{A variant for polynomials}\n\nLet \\(K\\) be a field with \\(\\ch K \\neq 2\\). Let \\(\\overline K\\) be an algebraic closure of \\(k\\).\n\n\\begin{lemma}\n  Let \\(u, v \\in K[t]\\) coprime. If \\(\\alpha u + \\beta v\\) is a square for four distinct \\((\\alpha: \\beta) \\in \\P^1\\) then \\(u, v \\in K\\).\n\\end{lemma}\n\n\\begin{proof}\n  wlog \\(K = \\overline K\\). Changing coordinates on \\(\\P^1\\), we may assume the ratio \\((\\alpha: \\beta)\\) are \\((1: 0), (0: 1), (1: -1), (1: -\\lambda)\\) for some \\(\\lambda \\in K \\setminus \\{0, 1\\}\\). Thus we have\n  \\begin{align*}\n    u &= a^2 \\\\\n    v &= b^2 \\\\\n    u - v &= (a - b)(a + b) \\\\\n    u - \\lambda v &= (a - \\mu b)(a + \\mu b)\n  \\end{align*}\n  where \\(\\mu = \\sqrt \\lambda\\). Use unqiue factorisation in \\(K[t]\\),  as \\(a, b\\) are coprime, \\(a + b, a - b, a - \\mu b, a + \\mu b\\) are squares. But\n  \\[\n    \\max (\\deg (a), \\deg (b)) \\leq \\frac{1}{2} \\max (\\deg (u), \\deg (v))\n  \\]\n  so by Fermat's method of infinite descend, \\(u, v \\in K\\).\n\\end{proof}\n\n\\begin{definition}[elliptic curve]\\index{ellptic curve}\\leavevmode\n  \\begin{enumerate}\n  \\item An \\emph{elliptic curve} \\(E/K\\) is the projective closure of a plane affine curve \\(y^2 = f(x)\\) where \\(f \\in K[x]\\) is a monic cubic polynomial with distinct roots in \\(\\overline K\\). The equation \\(y^2 = f(x)\\) is called a \\emph{Weierstrass function}\\index{Weierstrass function}.\n  \\item For \\(L/K\\) a field extension,\n    \\[\n      E(L) = \\{(x, y) \\in L^2: y^2 = f(x)\\} \\cup \\{0\\}\n    \\]\n    where \\(0\\) is the point at infinity in the projective closure.\n  \\end{enumerate}\n\\end{definition}\n\nFact: \\(E(L)\\) is naturally an abelian group.\n\nIn this course we study \\(E(L)\\) for \\(L\\) finite field, local field (meaning \\(L/\\Q_p\\) finite in this course) or number field (\\(L/\\Q\\) finite).\n\n\\begin{theorem}\n  If \\(E: y^2 = x^3 - x\\) then \\(E(\\Q) = \\{0, (0, 0), (\\pm 1, 0)\\}\\).\n\\end{theorem}\n\n\\begin{corollary}\n  Let \\(E/K\\) be an elliptic curve. Then \\(E(K(t)) = E(K)\\).\n\\end{corollary}\n\n\\begin{proof}\n  wlog \\(K = \\overline K\\). By a change of coordinates we may assume\n  \\[\n    E: y^2 = x(x - 1)(x - \\lambda)\n  \\]\n  for some \\(\\lambda \\in K \\setminus \\{0, 1\\}\\). Suppose \\((x, y) \\in E(K(t))\\). Write \\(x = \\frac{u}{v}\\) where \\(u, v \\in K[t]\\) coprime. Then\n  \\[\n    w^2 = uv(u - v)(u - \\lambda v)\n  \\]\n  for some \\(w \\in K[t]\\). Using same unique factorisation argument as before, \\(u, v, u - v, u - \\lambda v\\) are all squares so by lemma \\(u, v \\in K\\) so \\(x, y \\in K\\).\n\\end{proof}\n\n\\section{Some remarks on algebraic curves}\n\nLet \\(K = \\overline K, \\ch K \\neq 2\\).\n\n\\begin{definition}[rational plane curve]\\index{rational plane curve}\n  A plane algebraic curve (always assumed to be irreducible)\n  \\[\n    C = \\{f(x, y) = 0\\} \\subseteq \\A^2\n  \\]\n  is \\emph{rational} if it has a rational parameterisation, i.e.\\ there exist \\(\\phi, \\psi \\in K(t)\\) such that\n  \\begin{enumerate}\n  \\item \\(\\A^1 \\to \\A^2, t \\mapsto (\\phi(t), \\psi(t))\\) is injective on \\(\\A^1 \\setminus \\{\\text{finite set}\\}\\).\n  \\item \\(f(\\phi(t), \\psi(t)) = 0\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Any nonsingular plane conic is rational. For example \\(x^2 + y^2 = 1\\). Pick a point \\((-1, 0)\\). Putting a line through the point with slope \\(t\\), i.e.\\ \\(y = t(x + 1)\\). Solve for the intersection. In general we will get a root, which is not rational. But in the quadratic case we already have one solution so the other solution can be expressed as a rational function. we have\n    \\[\n      x^2 + t^2(x + 1)^2 = 1\n    \\]\n    which is saying\n    \\[\n      (x + 1)(x - 1 + t^2(x + 1)) = 0\n    \\]\n    so \\(x = -1\\) or \\(x = \\frac{1 - t^2}{1 + t^2}\\). Similarly one can solve \\(y\\). Then we get rational parameterisation\n    \\[\n      (x, y) = \\left( \\frac{1 - t^2}{1 + t^2}, \\frac{2t}{1 + t^2} \\right).\n    \\]\n  \\item Any singular plane curve is rational. Two examples: \\(y^2 = x^3, y^2 = x^2 (x + 1)\\). Same recipe as before except that we have to pick the singular point, which is the origin in both cases. The line \\(y = tx\\) intersects the curve. We get rational parameterisation \\((x, y) = (t^2, t^3)\\) for the first one. The second is an exercise.\n  \\item Corollary 1.6 shows that elliptic curves are \\emph{not} rational.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{remark}\n  The genus \\(g(C) \\in \\Z_{\\geq 0}\\) is an invariant of a smooth projective curve \\(C\\). Some facts:\n  \\begin{enumerate}\n  \\item if \\(k = \\C\\) then \\(g(C)\\) is the genus of the Riemann surface.\n  \\item a smooth plane curve \\(C \\subseteq \\P^2\\) of degree \\(d\\) has genus \\(g(C) = \\frac{(d - 1)(d - 2)}{2}\\).\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{proposition}\n  Let \\(C\\) be a smooth projective curve.\n  \\begin{enumerate}\n  \\item \\(C\\) is rational if and only if \\(g(C) = 0\\).\n  \\item \\(C\\) is an elliptic curve if and only if \\(g(C) = 1\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Omitted.\n  \\item For only if, check the projective closure is smooth and use remark. For if, see later.\n  \\end{enumerate}\n\\end{proof}\n\n\\subsection{Order of vanishing}\n\nLet \\(C\\) be an algebraic curve with function field \\(K(C)\\). Let \\(P \\in C\\) be a smooth point. We write \\(\\ord_P(f)\\) to be the order of vanishing to be the order of vanishing of \\(f \\in K(C)\\) at \\(P\\). It is negative if \\(f\\) has a pole at \\(P\\).\n\nSome facts: \\(\\ord_P(f): K(C)^* \\to \\Z\\) is a discrete valuation, i.e.\n\\begin{align*}\n  \\ord_P(f_1f_2) &= \\ord_P(f_1) + \\ord_P(f_2) \\\\\n  \\ord_P(f_1 + f_2) & \\geq \\min(\\ord_P(f_1), \\ord_P(f_2))\n\\end{align*}\n\n\\begin{definition}[uniformiser]\\index{uniformiser}\n  \\(t \\in K(C)^*\\) is a \\emph{uniformiser} at \\(P\\) if \\(\\ord_P(t) = 1\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(C = \\{g = 0\\} \\subseteq \\A^2\\) for some \\(g \\in K[x, y]\\) irreducible. Then\n  \\[\n    K(C) = \\operatorname{Frac} \\frac{K[x, y]}{(g)}.\n  \\]\n  Write\n  \\[\n    g = g_0 + g_1(x, y) + g_2(x, y) + \\dots\n  \\]\n  where \\(g_i\\) is homogeneous of degree \\(i\\). Suppose \\(P = (0, 0) \\in C\\) is smooth, i.e.\\ \\(g_0 = 0, g_1(x, y) = \\alpha x + \\beta y\\) where \\(\\alpha, \\beta\\) not both zero. (Picture). Let \\(\\gamma, \\delta \\in K\\). It is a fact that \\(\\gamma x + \\delta y \\in K(C)\\) is a uniformiser at \\(P\\) if and only if \\(\\alpha \\delta - \\beta \\gamma \\neq 0\\).\n\\end{eg}\n\n\\begin{eg}\n  Consider \\(\\{y^2 = x(x - 1)(x - \\lambda)\\} \\subseteq \\A^2\\) where \\(\\lambda \\neq 0, 1\\). Its projective closure is \\(\\{Y^2Z = X(X - Z)(X - \\lambda Z)\\} \\subseteq \\P^2\\), then we get one point \\(P = (0: 1: 0)\\) at infinity. We can compute \\(\\ord_P(x)\\) and \\(\\ord_P(y)\\). We work on the affine piece \\(\\{Y \\neq 0\\}\\). Put \\(w = \\frac{Z}{Y}, t = \\frac{X}{Y}\\), then the equation becomes\n  \\[\n    w = t(t - w)(t - \\lambda w).\n  \\]\n  Now \\(P\\) is the point \\((t, w) = (0, 0)\\). This is a smooth point and using the fact in the above example,\n  \\[\n    \\ord_P(t) = \\ord_P(t - w) = \\ord_P(t - \\lambda w) = 1,\n  \\]\n  so \\(\\ord_P(w) = 3\\). Finally,\n  \\begin{align*}\n    \\ord_P(x) &= \\ord_P \\frac{X}{Z} = \\ord_P \\frac{t}{w} = -2 \\\\\n    \\ord_P(y) &= \\ord_P \\frac{Y}{Z} = \\ord_P \\frac{1}{w} = -3\n  \\end{align*}\n\\end{eg}\n\nLet \\(C\\) be a smooth projective curve.\n\n\\begin{definition}[divisor]\\index{divisor}\n  A \\emph{divisor} is a formal sum of points on \\(C\\), say \\(D = \\sum_{P \\in C} n_P P\\) with \\(n_P \\in \\Z\\) and \\(n_P = 0\\) for all but finitely many \\(P\\). The \\emph{degree} of \\(D\\) is\n  \\[\n    \\deg D = \\sum n_P.\n  \\]\n\\end{definition}\n\n\\begin{definition}[effective divisor]\\index{divisor!effective}\n  A divisor \\(D\\) is \\emph{effective}, written \\(D \\geq 0\\), if \\(n_P \\geq 0\\) for all \\(P\\).\n\\end{definition}\n\nIf \\(f \\in K(C)^*\\) then we write\n\\[\n  \\div(f) = \\sum_{P \\in C} \\ord_P(f) P.\n\\]\n\nThe \\emph{Riemann-Roch space} of \\(D \\in \\Div(C)\\) is\n\\[\n  \\mathcal L(D) = \\{f \\in K(C)^*: \\div(f) + D \\geq 0\\} \\cup \\{0\\},\n\\]\ni.e.\\ the \\(K\\)-vector space of rational functions on \\(C\\) with ``pole no worse than specified by \\(D\\)''.\n\nRiemann-Roch for genus \\(1\\) curve says that\n\\[\n  \\dim \\mathcal L(D) =\n  \\begin{cases}\n    \\deg D & \\deg D > 0 \\\\\n    0 \\text{ or } 1 & \\deg D = 0 \\\\\n    0 & \\deg D < 0 \n  \\end{cases}\n\\]\n\n\\begin{eg}\n  Let us revisit some of the previous example. Consider \\(\\{y^2 = x(x - 1)(x - \\lambda)\\} \\subseteq \\A^2\\) and let \\(P\\) the point at infinity. We calculated \\(\\ord_P(x) = -2, \\ord_P(y) = -3\\). Then\n  \\begin{align*}\n    \\mathcal L(2P) &= \\langle 1, x \\rangle \\\\\n    \\mathcal L(3P) &= \\langle 1, x, y \\rangle\n  \\end{align*}\n\\end{eg}\n\n\\begin{proposition}\n  Let \\(C \\subseteq \\P^2\\) be a smooth plane cubic and \\(P \\in C\\) a point of inflection. Then we can change coordinates such that \\(C: Y^2Z = X(X - Z)(X - \\lambda Z)\\) and \\(P = (0: 1: 0)\\).\n\\end{proposition}\n\n\\begin{fact}\n  The points of inflection on \\(C = \\{F = 0\\} \\subseteq \\P^2\\) are given by\n  \\[\n    F = \\det \\frac{\\p^2 F}{\\p x_i \\p x_j} = 0.\n  \\]\n\\end{fact}\n\n\\begin{proof}\n  We change coordinates such that \\(P = (0 : 1 : 0)\\) and \\(T_pC = \\{Z = 0\\}\\), where \\(C = \\{F(X, Y, Z) = 0\\}\\). \\(P \\in C\\) is a point of inflection, meaning that the intersection of the tangent at \\(P\\) with \\(C\\) has multiplicity \\(3\\), so \\(F(t, 1, 0)\\) is a constant multiple of \\(t^3\\). Thus there is no \\(X^2Y, XY^2\\) and \\(Y^3\\) term, so\n  \\[\n    F \\in \\langle Y^2Z, XYZ, YZ^2, X^3, X^2Z, XZ^2, Z^3 \\rangle.\n  \\]\n  The coefficient of \\(X^3\\) is nonzero as otherwise \\(\\{Z = 0\\} \\subseteq C\\). The coefficient of \\(Y^2Z\\) is nonzero as otherwise \\(P \\in C\\) is singular. We are free to rescale \\(X, Y, Z\\) and \\(F\\), so wlog \\(C\\) is defined by\n  \\[\n    Y^2Z + a_1 XYZ + a_3 YZ^2 = X^3 + a_2 X^2Z + a_4 XZ^2 + a_6 Z^3.\n  \\]\n  Making substitutions \\(Y \\mapsto Y - \\frac{1}{2} a_1X - \\frac{1}{2} a_3 X\\), w may asssume \\(a_1 = a_3 = 0\\). Now \\(C: Y^2Z = Z^3 f(X/Z)\\) where \\(f\\) is a monic cubic polynomial. As \\(C\\) is smooth, \\(f\\) has distinct roots so wlog \\(0, 1, \\lambda\\) so \\(C\\) is\n  \\[\n    Y^2Z = X(X - Z)(X - \\lambda Z).\n  \\]\n\\end{proof}\n\nThe equation\n\\[\n  Y^2Z + a_1 XYZ + a_3 YZ^2 = X^3 + a_2 X^2Z + a_4 XZ^2 + a_6 Z^3\n\\]\nis called \\emph{Weierstrass form}\\index{Weierstrass equation} and\n\\[\n  Y^2Z = X(X - Z)(X - \\lambda Z)\n\\]\nis called \\emph{Legendre form}.\n\n\\subsection{Degree of a morphism}\n\nLet \\(\\phi: C_1 \\to C_2\\) be a nonconstant morphism of smooth projective curves. Let \\(\\phi^*: K(C_2) \\to K(C_1)\\) be the pullback by \\(\\phi\\).\n\n\\begin{definition}[degree of morphism]\n  The \\emph{degree} of \\(\\phi\\) is\n  \\[\n    \\deg \\phi = [K(C_1): \\phi^*K(C_2)],\n  \\]\n  the degree of the field extension. \\(\\phi\\) is \\emph{separable} if the corresponding field extension is separable (which is automatic if \\(\\ch K = 0\\)).\n\\end{definition}\n\n\\begin{fact}\n  \\(\\deg \\phi = 1\\) if and only if \\(\\phi\\) is an isomorphism.\n\\end{fact}\n\n\\begin{definition}[ramification index]\\index{ramification index}\n  Suppose \\(P \\in C_1, Q \\in C_2\\) are such that \\(\\phi(P) = Q\\). Let \\(t \\in K(C_2)\\) be an uniformiser at \\(Q\\). The \\emph{ramification index} of \\(\\phi\\) at \\(P\\) is\n  \\[\n    e_\\phi(P) = \\ord_P(\\phi^*t).\n  \\]\n\\end{definition}\n\nIt is independent of the choice of uniformiser and is always greater than \\(0\\).\n \n\\begin{theorem}\n  Let \\(\\phi: C_1 \\to C_2\\) be a nonconstant morphism of smooth projective curves. Then\n  \\[\n    \\sum_{P \\in \\phi^{-1}(Q)} e_\\phi(P) = \\deg \\phi\n  \\]\n  for all \\(Q \\in C_2\\).\n\n  Moreover, if \\(\\phi\\) is separable then \\(e_\\phi(P) = 1\\) for all but finitely many \\(P \\in C_1\\).\n\\end{theorem}\n\nIn particular,\n\\begin{enumerate}\n\\item \\(\\phi\\) is surjective (note that we are working over algebraically closed fields).\n\\item \\(\\# \\phi^{-1}(Q) \\leq \\deg \\phi\\) with equality for all but finitely many \\(Q \\in C_2\\).\n\\end{enumerate}\n\n\\begin{remark}\n  Let \\(C\\) be an algebraic curve. A rational map is given by\n  \\begin{align*}\n    \\phi: C &\\rational \\P^n \\\\\n    P &\\mapsto (f_0(P) : f_1(P) : \\cdots : f_n(P))\n  \\end{align*}\n  where \\(f_0, \\dots, f_n \\in K(C)\\) not all zero.\n\\end{remark}\n\n\\begin{fact}\n  If \\(C\\) is smooth then \\(\\phi: C \\rational \\P^n\\) is a morphism.\n\\end{fact}\n\n\\section{Weierstrass equations}\n\nWe assume \\(K\\) is a perfect field with algebraic closure \\(\\overline K\\) in this chapter.\n\n\\begin{definition}[elliptic curve]\\index{elliptic curve}\n  An \\emph{elliptic curve} \\(E\\) over \\(K\\) is a smooth projective curve of genus \\(1\\) defined over \\(K\\) with a specified \\(K\\)-rational point \\(0_E\\).\n\\end{definition}\n\n\\begin{eg}\n  \\(\\{X^3 + pY^3 + p^2Z^3 = 0\\} \\subseteq \\P^2\\) is smooth but is \\emph{not} an elliptic curve over \\(\\Q\\) since it has no \\(\\Q\\)-rational pionts.\n\\end{eg}\n\n\\begin{theorem}\n  Every elliptic curve \\(E\\) is isomorphic over \\(K\\) to a curve in Weierstrass form via an isomorphism taking \\(0_E\\) to \\((0 : 1 : 0)\\).\n\\end{theorem}\n\n\\begin{remark}\n  Proposition 2.7 treated the special case \\(E\\) is a smooth plane cubic and \\(0_E\\) is a point of inflection.\n\\end{remark}\n\n\\begin{fact}\n  If \\(D \\in \\Div(E)\\) is defined over \\(K\\) (i.e. it is fixed by \\(\\operatorname{Gal}(\\overline K/K)\\)) then \\(\\mathcal L(D)\\) has a basis in \\(K(E)\\) (not just \\(\\overline K(E)\\).\n\\end{fact}\n\n\\begin{proof}\n  We have \\(\\mathcal L(2 \\cdot 0_E) \\subseteq \\mathcal L(3 \\cdot 0_E)\\) with dimension \\(2\\) and \\(3\\) respectively. Pick basis \\(1, x\\) for \\(\\mathcal L(2 \\cdot 0_E)\\) and \\(1, x, y \\in \\mathcal L(3 \\cdot 0_E)\\). Note that this implies \\(\\ord_{0_E}(x) = 2, \\ord_{0_E}(y) = 3\\). The seven elements \\(1, x, y, x^2, xy, x^3, y^2\\) in the \\(6\\)-dim vector space \\(\\mathcal L(6 \\cdot 0_E)\\) must satisfy a dependence relation. Leaving out \\(x^3\\) or \\(y^2\\) gives a basis for \\(\\mathcal L(6 \\cdot 0_E)\\) since each term has a different order of pole at \\(0_E\\), so coefficients of \\(x^3\\) and \\(y^2\\) are nonzero. Rescaling \\(x\\) and \\(y\\), we get\n  \\[\n    y^2 + a_1 xy + a_3 y = x^3 + a_2 x^2 + a_4 x + a_6.\n  \\]\n  By the fact above, we can take \\(a_i \\in K\\).\n\n  Let \\(E'\\) be the projective closure of the curve defined by Weierstrass form. There is a morphism\n  \\begin{align*}\n    \\phi: E &\\to E' \\\\\n    p &\\mapsto (x(P) : y(P) : 1)\n  \\end{align*}\n  Left to show \\(\\phi\\) is an isomorphism, i.e.\\ \\(\\deg \\phi = 1\\). We have\n  \\begin{align*}\n    [K(E) : K(x)] &= \\deg (x: E \\to \\P^1) = \\ord_{0_E}(\\frac{1}{x}) = 2 \\\\\n    [K(E) : K(y)] &= \\deg (y: E \\to \\P^1) = \\ord_{0_E}(\\frac{1}{y}) = 3\n  \\end{align*}\n  So by tower law\n  \\[\n    [K(E): K(x, y)] = 1.\n  \\]\n  As \\(K(x, y) = \\phi^* K(E')\\) so \\(\\deg \\phi = 1\\) so \\(\\sigma\\) is birational. If \\(E'\\) is singular then (? genus 0) \\(E\\) and \\(E'\\) are both rational. So \\(E'\\) is nonsingular and \\(\\phi^{-1}\\) is a morphism.\n\n  To find the image of \\(0_E\\), we cannot simply plug \\(0_E\\) in as \\(x, y\\) both have poles at infinity. Instead, we multiply through to get\n  \\begin{align*}\n    \\phi: E &\\to E' \\\\\n    P &\\mapsto (\\frac{x}{y} (P) : 1 : \\frac{1}{y} (P))\n  \\end{align*}\n  so \\(\\phi(0_E) = (0 : 1 : 0)\\).\n\\end{proof}\n\n\\begin{proposition}\n  Let \\(E\\) and \\(E'\\) be elliptic curves over \\(K\\) in Weierstrass form. Then \\(E \\cong E'\\) over \\(K\\) if and only if the equations are related by a change of variables\n  \\begin{align*}\n    x &= u^2 x' + r \\\\\n    y &= u^3 y' + u^2 s x' + t\n  \\end{align*}\n  where \\(u, r, s, t \\in K, u \\neq 0\\).\n\\end{proposition}\n\n\\begin{proof}\n  We check the process of putting a single elliptic curve in Weierstrass form and see what choices we can make. Suppose\n  \\begin{align*}\n    \\langle 1, x \\rangle &= \\mathcal L(2 \\cdot 0_E) = \\langle 1, x' \\rangle \\\\\n    \\langle 1, x, y \\rangle &= \\mathcal L(3 \\cdot 0_E) = \\langle 1, x', y' \\rangle\n  \\end{align*}\n  so\n  \\begin{align*}\n    x &= \\lambda x' + r \\\\\n    y &= \\mu y' + \\sigma x' + t\n  \\end{align*}\n  where \\(\\lambda, r, \\mu, \\sigma, t \\in K, \\lambda, \\mu \\neq 0\\). Looking at coefficients of \\(x^3\\) and \\(y^2\\), must have \\(\\lambda^3 = \\mu^2\\) so \\((\\lambda, \\mu) = (u^2, u^3)\\) for some \\(u \\in K^*\\). Finally put \\(s = \\sigma/u^2\\).\n\\end{proof}\n\nA Weierstrass equation defines an elliptic curve if and only if it defines a smooth curve, if and only if \\(\\Delta(a_1, \\dots a_6) \\neq 0\\) where \\(\\Delta \\in \\Z[a_1, \\dots, a_6]\\) is a certain polynomial. Details can be found out in the lecture handout.\n\nIf \\(\\ch K \\neq 2, 3\\) then we can reduce the curve to \\(E: y^2 = x^3 + ax + b\\) with discriminant \\(\\Delta = -16(4a^3 + 27b^2)\\).\n\n\\begin{corollary}\n  Assume \\(\\ch k \\neq 2, 3\\). Elliptic curves\n  \\begin{align*}\n    E: y^2 &= x^3 + ax + b \\\\\n    E': y^2 &= x^3 + a'x + b'\n  \\end{align*}\n  are isomorphic over \\(K\\) if and only if\n  \\begin{align*}\n    a' &= u^4a \\\\\n    b' &= u^6b\n  \\end{align*}\n  for some \\(u \\in K^*\\).\n\\end{corollary}\n\n\\begin{proof}\n  \\(E\\) and \\(E'\\) are related as in proposition 3.2 with \\(r = s = t = 0\\).\n\\end{proof}\n\n\\begin{definition}[\\(j\\)-invariant]\\index{\\(j\\)-invariant}\n  The \\emph{\\(j\\)-invariant} of an elliptic curve \\(E\\) is\n  \\[\n    j(E) = \\frac{1728 (4a^3)}{4a^3 + 27b^2}.\n  \\]\n\\end{definition}\n\nThis is just the ratio \\((a^3 : b^2)\\) up to a Möbius transform.\n\n\\begin{corollary}\n  If \\(E \\cong E'\\) then \\(j(E) = j(E')\\) and the converse holds if \\(K = \\overline K\\).\n\\end{corollary}\n\n\\begin{proof}\n  \\(E \\cong E'\\) if and only if \\(a' = u^4 a, b' = u^6 b\\) for some \\(u \\in K^*\\), which implies that \\((a^3: b^2) = ((a')^3 : (b')^2)\\), which holds if and only if \\(j(E) = j(E')\\). If \\(K = \\overline K\\) then we can extract roots and the converse of the second implication holds.\n\\end{proof}\n\n\\section{The group law}\n\nLet \\(E \\subseteq \\P^2\\) be a smooth plane cubic and \\(0_E \\in E(K)\\). \\(E\\) meets each line in 3 points, counted with multiplicity. Given \\(P, Q \\in E\\), let \\(S\\) be the third point of intersection of \\(PQ\\) and \\(E\\). Let \\(R\\) be the third point of intersection of \\(0_ES\\) and \\(E\\). We define\n\\[\n  P \\oplus Q = R.\n\\]\nIf \\(P = Q\\) then take the tangent at \\(P\\) instead of \\(PQ\\). This is the ``chord and tangent process''.\n\n\\begin{theorem}\n  \\((E, \\oplus)\\) is an abelian group.\n\\end{theorem}\n\nHere we recall a convention: if we don't specify the field extension the we mean the algebraic claosure. In notation: \\(E = E(\\overline K)\\).\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(P \\oplus Q = Q \\oplus P\\).\n  \\item \\(0_E\\) is the identity.\n  \\item For inverse, let \\(S\\) be the point of intersection of \\(T_{0_E}E\\) and \\(E\\), \\(Q\\) the third point of intersection of \\(PS\\) and \\(E\\). Then \\(P \\oplus Q = 0_E\\).\n  \\item Associativity is much harder, and we'll prove it using divisors.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{definition}[linearly equivalent divisor]\\index{divisor!linearly equivalent}\n  \\(D_1, D_2 \\in \\Div(E)\\) are \\emph{linearly equivalent}, written \\(D_1 \\sim D_2\\), if exists \\(f \\in \\overline K(E)^*\\) such that \\(\\div (f) = D_1 - D_2\\).\n\\end{definition}\n\nThis is an equivalence relation and we define\n\n\\begin{definition}[Picard group]\\index{Picard group}\n  The \\emph{Picard group} is defined to be\n  \\[\n    \\Pic(E) = \\Div (E)/\\sim.\n  \\]\n\\end{definition}\n\n\\begin{definition}\n  We let\n  \\[\n    \\Div^0(E) = \\ker (\\deg: \\Div(E) \\to \\Z)\n  \\]\n  and\n  \\[\n    \\Pic^0(E) = \\Div^0(E)/\\sim.\n  \\]\n\\end{definition}\n\n\\begin{proposition}\n  Let\n  \\begin{align*}\n    \\phi: E &\\to \\Pic^0(E) \\\\\n    P &\\mapsto [P - 0_E]\n  \\end{align*}\n  then\n  \\begin{enumerate}\n  \\item \\(\\phi(P \\oplus Q) = \\phi(P) + \\phi(Q)\\).\n  \\item \\(\\phi\\) is a bijection.\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\ell\\) be the line \\(PQ\\) and \\(m\\) the curve \\(0_ES\\). Then\n    \\[\n      \\div (\\frac{\\ell}{m})\n      = (P) + (S) + (Q) - (R) - (S) - (0_E)\n      = (P) + (Q) - (P \\oplus Q) - (0_E)\n    \\]\n    so \\((P) + (Q) \\sim (P \\oplus Q) + (0_E)\\) and so\n    \\[\n      (P) - (0_E) + (Q) - (0_E) = (P \\oplus Q) - (0_E)\n    \\]\n    so \\(\\phi(P \\oplus Q) = \\phi(P) + \\phi(Q)\\).\n  \\item For injectivity, suppose \\(\\phi(P) = \\phi(Q)\\) for \\(P \\neq Q\\). Then exists \\(f \\in \\overline K(E)^*\\) such that \\(\\div (f) = P - Q\\). Then\n    \\[\n      \\deg (f: E \\to \\P^1) = \\ord_P(f) = 1\n    \\]\n    so \\(E \\cong \\P^1\\), absurd.\n\n    For surjectivity, let \\([D] \\in \\Pic^0(E)\\). Then \\(D + (0_E)\\) has degree \\(1\\). Riemann-Roch tells us that \\(\\mathcal L(D + (0_E)) = 1\\) so exists \\(f \\in \\overline K(E)^*\\) such that\n    \\[\n      \\div(f) + D + (0_E) \\geq 0\n    \\]\n    and furthermore LHS has degree \\(1\\). Thus it has to be \\((P)\\) for some \\(P \\in E\\). It follows that \\((P) - (0_E) \\sim D\\).\n  \\end{enumerate}\n\\end{proof}\n\nIn a nutshell, \\(\\phi\\) identifies \\((E, \\oplus)\\) with \\((\\Pic^0(E), +)\\) so \\(\\oplus\\) is associative.\n\n\\subsection{Explicit formula for the group law}\n\nWe consider \\(E\\) in Weierstrass form and \\(0_E\\) the point at infinity.\n\\[\n  y^2 + a_1xy + a_3 y = x^3 + a_2x^2 + a_4x + a_6\n\\]\n\n\\begin{remark}\n  \\(0_E\\) is a point of inflection so now we can characterise the group law as \\(P_1 \\oplus P_2 \\oplus P_3 = 0_E\\) if and only if \\(P_1, P_2, P_3\\) are colinear.\n\\end{remark}\n\nThe inverse of \\(P = (x_1, y_1)\\) is the intersection of \\(P0_E\\), which is the vertical line, and \\(E\\) so is given by\n\\[\n  \\ominus P = (x_1, -(a_1x_1 + a_3) - y_1).\n\\]\nGiven \\(P_1 = (x_1, y_1), P_2 = (x_2, y_2)\\), want to find an expression for \\(P_3 = P_1 \\oplus P_2\\). Let \\(P_1P_2\\) intersect \\(E\\) at \\(P' = (x', y')\\). Then \\(P_3 = P_1 \\oplus P_2 = \\ominus P'\\). Substitute \\(y = \\lambda x + \\nu\\) into * and looking at the coefficient of \\(x^2\\) gives\n\\[\n  \\lambda^2 + a_1 \\lambda - a_2 = x_1 + x_2 + x'\n\\]\nwhich gives\n\\begin{align*}\n  x_3 &= \\lambda^2 + a_1 \\lambda - a_2 - x_1 - x_2 \\\\\n  y_3 &= -(a_1x' + a_3) - (\\lambda x' + \\nu) = -(\\lambda + a_1) x_3 - \\nu - a_3\n\\end{align*}\nIt remains to find formula for \\(\\lambda\\) and \\(\\nu\\). If \\(x_1 = x_2\\) and \\(P_1 \\neq P_2\\) then \\(P_1 \\oplus P_2 = 0_E\\). For the general case \\(x_1 \\neq x_2\\), have\n\\begin{align*}\n  \\lambda &= \\frac{y_2 - y_1}{x_2 - x_1} \\\\\n  \\nu &= y_1 - \\lambda x_1 = \\frac{x_2y_1 - x_1 y_2}{x_2 - x_1}\n\\end{align*}\nFinally the case \\(P_1 = P_2\\) is left as an exercise.\n\n\\begin{corollary}\n  \\(E(K)\\) is an abelian group.\n\\end{corollary}\n\n\\begin{proof}\n  It is a subgroup of \\(E\\):\n  \\begin{itemize}\n  \\item identity: \\(0_E \\in E(K)\\) by definition,\n  \\item closure/inverses: see formula above.\n  \\item associativity/commutativity: inherited.\n  \\end{itemize}\n\\end{proof}\n\n\\begin{theorem}\n  Elliptic curves are group varieties, i.e.\\ \\([-1]: E \\to E, +: E \\times E \\to E\\) are morphisms of algebraic varieties.\n\\end{theorem}\n\n\\begin{proof}\n  The above formulae show \\([-1]\\) and \\(+\\) are rational maps. \\([-1]: E \\to E\\) is a map from a smooth curve to a projective variety so is a morphism. Unfortunately there is no such result for surfaces. Instead, the formulae also show \\(+\\) is regular on\n  \\[\n    U = \\{(P, Q) \\in E \\times E: P, Q, P + Q, P - Q \\neq 0_E\\}.\n  \\]\n  For \\(P \\in E\\), let \\(\\tau_P: E \\to E, X \\mapsto P + X\\) be translation by \\(P\\). \\(\\tau_P\\) is a rational map so a morphism. We factor \\(+\\) as\n  \\[\n    \\begin{tikzcd}\n      E \\times E \\ar[r, \"\\tau_{-A} \\times \\tau_{-B}\"] & E \\times E \\ar[r, \"+\"] & E \\ar[r, \"\\tau_{A + B}\"] & E\n    \\end{tikzcd}\n  \\]\n  so \\(+\\) is regular on \\((\\tau_A, \\tau_B)(U)\\) for all \\(A, B \\in E\\) so \\(+\\) is regular on \\(E \\times E\\).\n\\end{proof}\n\n\\begin{definition}[torsion subgroup]\\index{torsion subgroup}\n  For \\(n \\in \\Z\\), let \\([n]: E \\to E\\) be the ``\\(n\\) times'' map. The \\emph{\\(n\\)-torsion subgroup} of \\(E\\) is \\(E[n] = \\ker([n]: E \\to E)\\).\n\\end{definition}\n\n\\begin{lemma}\n  Assume \\(\\ch k \\neq 2\\) and \\(E: y^2 = f(x) = (x - e_1)(x - e_2)(x - e_3)\\) where \\(e_i \\in \\overline K\\) distinct. Then\n  \\[\n    E[2] = \\{0_E, (e_1, 0), (e_2, 0), (e_3, 0)\\} \\cong (\\Z/2\\Z)^2.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(P = (x, y) \\in E\\). Then \\([2] P = 0\\) if and only if \\(P = - P\\) so \\((x, y) = (x, -y)\\) so \\(y = 0\\).\n\\end{proof}\n\n\\paragraph{Elliptic curves over \\(C\\)}\n\nLet \\(\\Lambda = \\{a \\omega_1 + b \\omega_2: a, b \\in \\Z\\}\\) be a lattice, where \\(\\omega_1, \\omega_2\\) is a basis for \\(\\C\\) as an \\(\\R\\)-vector space. The the set of meromorphic functions on the Riemann surface \\(\\C/\\Lambda\\) is the same as \\(\\Lambda\\)-invariant meromorphisc functions on \\(\\C\\). This field is generated by \\(\\wp(z)\\) and \\(\\wp'(z)\\) where\n\\[\n  \\wp(z) = \\frac{1}{z^2} + \\sum_{\\lambda \\in \\Lambda \\setminus \\{0\\}} \\left(\\frac{1}{(z - \\lambda)^2} - \\frac{1}{\\lambda^2}\\right)\n\\]\nThey satisfy\n\\[\n  \\wp'(z)^2 = 4 \\wp(z)^3 - g_2 \\wp(z) - g_3\n\\]\nfor some \\(g_2, g_3 \\in \\Lambda\\) depending on \\(\\Lambda\\). One shows \\(\\C/\\Lambda \\cong E(\\C)\\) where \\(E\\) is the elliptic curve\n\\[\n  y_2 = 4x^3 - g_2x - g_3.\n\\]\nThe isomorphism is understood as isomorphism of Riemann surfaces and isomorphism of groups.\n\n\\begin{theorem}\n  Every elliptic curve over \\(\\C\\) arises this way.\n\\end{theorem}\n\nFor elliptic curve \\(E/\\C\\) we have\n\\begin{enumerate}\n\\item \\(E[n] \\cong (\\Z/n\\Z)^2\\).\n\\item \\(\\deg [n] = n^2\\).\n\\end{enumerate}\nWe'll show 2 holds for any field \\(K\\), and 1 holds if \\(\\ch k \\ndivides n\\).\n\nStatement of results\n\\begin{enumerate}\n\\item If \\(K = \\C\\) then \\(E(\\C) \\cong \\C/\\Lambda \\cong \\R/\\Z \\cong \\R/\\Z\\).\n\\item If \\(K = \\R\\) then \\(E(\\R) \\cong\n  \\begin{cases}\n    \\Z/2\\Z \\times \\R/\\Z & \\Delta > 0 \\\\\n    \\R/\\Z & \\Delta < 0\n  \\end{cases}\n  \\)\n\\item If \\(K = \\F_q\\) then \\(|E(\\F_q) - (q + 1)| \\leq 2 \\sqrt q\\). This is Hasse's theorem.\n\\item If \\([K: \\Q_p] < \\infty\\) with rings of integers \\(\\mathcal O_K\\) then \\(E(K)\\) has a subgroup of finite index isomorphic to \\((\\mathcal O_K, +)\\).\n\\item If \\([K: \\Q] < \\infty\\) then \\(E(K)\\) is a finitely generated abelian group. This is Mordell-Weil theorem.\n\\end{enumerate}\n\n\\begin{remark}\n  The isomorphisms in 1, 2 and 4 resepcted the relevant topologies.\n\\end{remark}\n\n\\section{Isogenies}\n\nLet \\(K\\) be any perfect field in this chapter.\n\nLet \\(E_1, E_2\\) be elliptic curves.\n\n\\begin{definition}[isogeny]\\index{isogeny}\n  An \\emph{isogeny} \\(\\phi: E_1 \\to E_2\\) is a nonconstant morphism with \\(\\phi(0_{E_1}) = 0_{E_2}\\). We say \\(E_1\\) and \\(E_2\\) are \\emph{isogenous} if there exists an isogeny from \\(E_1\\) to \\(E_2\\).\n\n  We define \\(\\Hom(E_1, E_2)\\) to the be set of all isogenies \\(E_1 \\to E_2\\) plus \\(0\\). This is a group under\n  \\[\n    (\\phi + \\psi)(P) = \\phi(P) + \\psi(P).\n  \\]\n\\end{definition}\nNote that nonconstant implies that surjectivity on \\(\\overline K\\)-points. The composition of isogenies is an isogeny.\n\n\\begin{lemma}\n  If \\(0 \\neq n \\in \\Z\\) then \\([n]: E \\to E\\) is an isogeny.\n\\end{lemma}\n\n\\begin{proof}\n  We have checked that \\([n]\\) is a morphism. We must show \\([n] \\neq 0\\). There is a trick that we can use, if we assume \\(\\ch K \\neq 2\\). If \\(n = 2\\) then we computed last time that \\(\\E[2]\\) has 4 points so \\([2] \\neq 0\\). If \\(n\\) is odd then let \\(T \\in E[2]\\) be nonzero then \\(nT = T \\neq 0\\) so again \\([n] \\neq 0\\). Now use \\([mn] = [m] \\compose [n]\\).\n\n  If \\(\\ch K = 2\\), we can compute \\(E[3]\\) as in the lemma before.\n\\end{proof}\n\n\\begin{corollary}\n  \\(\\Hom(E_1, E_2)\\) is torsion-free as a \\(\\Z\\)-module.\n\\end{corollary}\n\n\\begin{lemma}\n  Let \\(\\phi: E_1 \\to E_2\\) be an isogeny. Then \\(\\phi(P + Q) = \\phi(P) + \\phi(Q)\\) for all \\(P, Q \\in E\\).\n\\end{lemma}\n\n\\begin{proof}[Sketch proof]\n  \\(\\phi\\) induces a map\n  \\begin{align*}\n    \\phi_*: \\Div^0(E_1) &\\to \\Div^0(E_2) \\\\\n    \\sum n_P P &\\mapsto \\sum n_P \\phi(P)\n  \\end{align*}\n  Recall we have a field extension \\(\\phi^*: K(E_2) \\to K(E_1)\\) so there is a norm map \\(N_{K(E_1)/K(E_2)}: K(E_1) \\to K(E_2)\\). It is a fact that if \\(f \\in K(E_1)^*\\) then\n  \\[\n    \\div (N_{K(E_1)/K(E_2)} f) = \\phi_*(\\div f)\n  \\]\n  so \\(\\phi_*\\) takes principal divisors to principal divisors. Since \\(\\phi(0_{E_1}) = 0_{E_2}\\), we have a commutative diagram\n  \\[\n    \\begin{tikzcd}\n      E_1 \\ar[r, \"\\phi\"] \\ar[d, \"\\cong\"] & E_2 \\ar[d, \"\\cong\"] \\\\\n      \\Pic^0(E_1) \\ar[r, \"\\phi_*\"] & \\Pic^0(E_2)\n    \\end{tikzcd}\n  \\]\n  As \\(\\phi_*\\) is a group homomorphism, so is \\(\\phi\\).\n\\end{proof}\n\n\\begin{eg}\n  Let \\(E/K\\) be an elliptic curve. Suppose \\(\\ch K \\neq 2\\) and exists \\(0 \\neq T \\in E(K)[2]\\). wlog assume \\(E: y^2 = x(x^2 + ax + b)\\) with \\(a, b \\in K, b(a^2 - 4b) \\neq 0\\) so \\(T = (0, 0)\\). If \\(P = (x, y)\\) and \\(P' = P + T = (x', y')\\) then\n  \\begin{align*}\n    x' &= \\left( \\frac{y}{x} \\right)^2 - a - x = \\frac{b}{x} \\\\\n    y' &= - \\left( \\frac{y}{x} \\right) x' = \\frac{-by}{x^2}\n  \\end{align*}\n  We define two variables that remain unchanged under (?) swapping\n  \\begin{align*}\n    \\xi &= x + x' + a = \\left( \\frac{y}{x} \\right)^2 \\\\\n    \\eta &= y + y' = \\frac{y}{x} (x - \\frac{b}{x})\n  \\end{align*}\n  Then\n  \\begin{align*}\n    \\eta^2 &= \\left( \\frac{y}{x} \\right)^2 ((x + \\frac{b}{x})^2 - 4b) \\\\\n           &= \\zeta ((\\zeta - a)^2 - 4b) \\\\\n           &= \\zeta (\\zeta^2 - 2a\\zeta + a^2 - 4b)\n  \\end{align*}\n  Let \\(E': y^2 = (x^2 + a'x + b')\\) where \\(a' = -2a, b' = a^2 - 4b\\). Then there is an isogeny\n  \\begin{align*}\n    \\phi: E &\\to E' \\subseteq \\P^2 \\\\\n    (x, y) &\\mapsto (\\xi : \\eta : 1)\n  \\end{align*}\n  Left to show \\(\\phi(0_E) = 0_{E'}\\). The three coordinates has a pole of order \\(-2, -3, 0\\) respectively at \\(0_E\\) so multiply by uniformiser to the power of three we get \\((0:1:0)\\).\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(\\phi: E_1 \\to E_2\\) be an isogeny. Then exists morphism \\(\\xi\\) making the following diagram commute\n  \\[\n    \\begin{tikzcd}\n      E_1 \\ar[r, \"\\phi\"] \\ar[d, \"x_1\"] & E_2 \\ar[d, \"x_2\"] \\\\\n      \\P^1 \\ar[r, \"\\xi\"] & \\P^1\n    \\end{tikzcd}\n  \\]\n  where \\(x_i\\) is the \\(x\\) coordinate on a Weierstrass equation for \\(E_i\\). Moreover if \\(\\xi(t) = \\frac{r(t)}{s(t)}\\) where \\(r, s \\in K[t]\\) coprime then\n  \\[\n    \\deg \\phi = \\deg \\xi = \\max (\\deg (r), \\deg (s)).\n  \\]\n\\end{lemma}\n\n\\begin{eg}\n  In the example above we just have \\(\\xi = \\frac{x^2 + ax + b}{x}\\) so in particular it has degree \\(2\\).\n\\end{eg}\n\n\\begin{proof}\n  For \\(i = 1, 2\\), \\(K(E_i)/K(x_i)\\) is a degree \\(2\\) Galois extension with Galois group generated by \\([-1]^*\\).\n\n  \\[\n    \\begin{tikzcd}\n      & K(E_1) \\ar[dd] \\\\\n      K(x_1) \\ar[ur] \\ar[dd, dashed] \\\\\n      & K(E_2) \\\\\n      K(x_2) \\ar[ur]\n    \\end{tikzcd}\n  \\]\n  If \\(f \\in K(x_2)\\) then \\([-1]^* f = f\\) so\n  \\[\n    [-1]^*(\\phi^* f) = \\phi^*([-1]^* f) = \\phi^* f\n  \\]\n  so indeed \\(\\phi^*f \\in K(x_1)\\). Taking \\(f = x_2\\) gives \\(\\phi^*x_2 = \\xi(x_1)\\) for some rational function \\(\\xi\\). By tower law \\(\\deg \\phi = \\deg \\xi\\). Now \\(K(x_2) \\embed K(x_1), x_2 \\mapsto \\xi(x_1) = \\frac{r(x_1)}{s(x_1)}\\) for some \\(r, s \\in K[t]\\) coprime. Claim the minimal polynomial of \\(x_1\\) over \\(K(x_2)\\) is\n  \\[\n    f(t) = r(t) - s(t)x_2 \\in K(x_2)[t].\n  \\]\n  Check \\(f(x_1) = 0\\). \\(f\\) is irreducible in \\(k[x_2, t]\\) (since \\(r, s\\) are corpime) so by Gauss' lemma \\(f\\) is irreducible in \\(K(x_2)[t]\\). Therefore\n  \\[\n    \\deg \\phi = \\deg \\xi = [K(x_1): K(x_2)] = \\deg(f) = \\max(\\deg(r), \\deg(s)).\n  \\]\n\\end{proof}\n\nThe lemma shows that the example \\(\\phi\\) above has degree 2. We say \\(\\phi\\) is a \\emph{\\(2\\)-isogeny}.\n\n\\begin{lemma}\n  \\(\\deg [2] = 4\\).\n\\end{lemma}\n\n\\begin{proof}\n  Assume \\(\\ch K \\neq 2, 3\\) so write \\(E: y^2 = f(x) = x^3 + ax + b\\). If \\(P = (x, y)\\) then\n  \\[\n    x(2P)\n    = \\left( \\frac{2x^2 + a}{2y} \\right)^2 - 2x\n    = \\frac{(3x^2 + a)^2 - 8x f(x)}{4 f(x)} \n    = \\frac{x^4 + \\cdots}{4 f(x)}\n  \\]\n  The numerator and the denominator are coprime. Indeed otherwise exists \\(\\theta \\in \\overline K\\) with \\(f(\\theta) = f'(\\theta) = 0\\), so \\(f\\) has a multiple root, absurd. Therefore by the lemma \\(\\deg [2] = max(4, 3) = 4\\).\n\\end{proof}\n\nWe will show that \\(\\deg [n] = n^2\\) by showing that \\(\\deg\\) is a quadratic form. This will also be useful when we prove Hasse's theorem later.\n\n\\begin{definition}\n  Let \\(A\\) be an abelian group. \\(q: A \\to \\Z\\) is a quadratic form if\n  \\begin{enumerate}\n  \\item \\(q(nx) = n^2 q(x)\\) for all \\(n \\in \\Z, x \\in A\\).\n  \\item \\((x, y) \\mapsto q(x + y) - q(x) - q(y)\\) is \\(\\Z\\)-bilinear.\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{lemma}\n  \\(q: A \\to \\Z\\) is a quadratic form if and only if it satisfies the parallelogram law\n  \\[\n    q(x + y) + q(x - y) = 2q(x) + 2q(y)\n  \\]\n  for all \\(x, y \\in A\\).\n\\end{lemma}\n\n\\begin{proof}\n  Only if is an easy exercise. If will be on example sheet 2.\n\\end{proof}\n\n\\begin{theorem}\n  \\(\\deg: \\Hom(E_1, E_2) \\to \\Z\\) is a quadratic form.\n\\end{theorem}\nHere by convention the 0 map has degree \\(0\\).\n\nFor the proof we assume \\(\\ch K \\neq 2, 3\\) and write \\(E_2: y^2 = f(x) = x^3 + ax + b\\). Let \\(P, Q \\in E_2\\) with \\(P, Q, P + Q, P - Q \\neq 0\\). Let \\(x_1, \\dots, x_4\\) be the \\(x\\) coordinates of these four points.\n\n\\begin{lemma}\n  There exist \\(W_0, W_1, W_2 \\in \\Z[a, b][x_1, x_2]\\) of degree \\(\\leq 2\\) in \\(x_1\\) and of degree \\(\\leq 2\\) in \\(x_2\\) such that\n  \\[\n    (1: x_3 + x_4: x_3x_4) = (W_0: W_1: W_2).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Method 1 is to calculate directly and get \\(W_0 = (x_1 - x_2)^2, \\dots\\). See formula sheet.\n\n  Method 2: let \\(y = \\lambda x + \\nu\\) be the line through \\(P\\) and \\(Q\\) so\n  \\[\n    f(x) - (\\lambda x + \\nu)^2 = (x - x_1)(x - x_2)(x - x_3).\n  \\]\n  By comparing coefficients we get\n  \\begin{align*}\n    \\lambda^2 &= s_1 \\\\\n    -2 \\lambda \\nu &= s_2 - a \\\\\n    \\nu^2 &= s_3 + b\n  \\end{align*}\n  where \\(s_i\\) is the \\(i\\)th elementary symmetric polynomial in \\(x_1, x_2, x_3\\). Eliminating \\(\\lambda\\) and \\(\\mu\\) gives\n  \\[\n    \\underbrace{(s_2 - a)^2 - 4s_1 (s_3 + b)}_{F(x_1, x_2, x_3)} = 0\n  \\]\n  where \\(F\\) has degree \\(\\leq 2\\) in each \\(x_i\\). \\(x_3\\) is a root of the quadratic \\(W(t) = F(x_1, x_2, t)\\). Repeating for line through \\(P\\) and \\(-Q\\) shows \\(x_4\\) is also a root of \\(W(t)\\). Write \\(W(t) = W_0t^2 - W_1t + W_2\\) and then\n  \\[\n    (1: x_3 + x_4: x_3x_4) = (W_0: W_1: W_2).\n  \\]\n\\end{proof}\n\nWe show that if \\(\\phi, \\psi \\in \\Hom(E_1, E_2)\\) then\n\\[\n  \\deg (\\phi + \\psi) + \\deg (\\phi - \\psi) \\leq 2 \\deg(\\phi) + 2 \\deg(\\psi).\n\\]\nWe may assume \\(\\phi, \\psi, \\phi + \\psi, \\phi - \\psi \\neq 0\\) as the other cases are trivial or we may use \\(\\deg [2] = 4\\). Let the \\(x\\) coordinate of \\(\\phi(x, y), \\psi(x, y), (\\phi + \\psi)(x, y), (\\phi - \\psi)(x, y)\\) be \\(\\xi_1(x), \\dots, \\xi_4(x)\\) respectively. Put \\(\\xi_i = \\frac{r_i}{s_i}\\) where \\(r_i, s_i \\in K[x]\\) coprime and use the above lemma, we get\n\\[\n  (s_3s_4: r_3s_4 + r_4s_3: r_3r_4) = ((r_1s_2 - r_2s_1)^2: \\cdots ).\n\\]\nNote that the three coordinates on LHS are coprime. We have\n\\begin{align*}\n  &\\deg (\\phi + \\psi) + \\deg (\\phi - \\psi) \\\\\n  &= \\max(\\deg (r_3), \\deg (s_3)) + \\max (\\deg (r_4), \\deg (s_4)) \\\\\n  &= \\max(\\deg (s_3s_4), \\deg (r_3s_4 + r_4s_3), \\deg (r_3r_4)) \\quad \\text{case checking} \\\\\n  &\\leq 2 \\max(\\deg(r_1), \\deg(s_1)) + 2 \\max(\\deg (r_2), \\deg (s_2)) \\quad \\text{as terms on LHS are coprime} \\\\\n  &= 2 \\deg (\\phi) + 2 \\deg (\\psi)\n\\end{align*}\n\nNow replace \\(\\phi, \\psi\\) by \\(\\phi + \\psi\\) and \\(\\phi - \\psi\\) to get\n\\[\n  \\deg (2\\phi) + \\deg (2\\psi) \\leq 2 \\deg (\\phi + \\psi) + 2 \\deg(\\phi - \\psi)\n\\]\nSince \\(\\deg [2] = 4\\) we get\n\\[\n  2 \\deg (\\phi) + 2 \\deg (\\psi) \\leq \\deg (\\phi + \\psi) + \\deg (\\phi - \\psi)\n\\]\nTogether they show \\(\\deg\\) satisfies the parallelogram law, so \\(\\deg\\) is a quadratic form.\n\n\\begin{corollary}\n  \\(\\deg (n\\phi) = n^2 \\deg (\\phi)\\) for all \\(n \\in \\Z, \\phi \\in \\Hom(E_1, E_2)\\). In particular \\(\\deg [n] = n^2\\).\n\\end{corollary}\n\n\\section{Invariant differential}\n\nWe want to find out when a morphism is separable so we may apply Riemann-Hurwitz. To do so we use differentials.\n\nLet \\(C\\) be an algebraic curve over \\(K = \\overline K\\). The space of differentials \\(\\Omega_C\\) is the \\(K(C)\\)-vector spaces generated by \\(df\\) for \\(f \\in K(C)\\) subject to the relations\n\\begin{enumerate}\n\\item \\(d(f + g) = df + dg\\),\n\\item \\(d(fg) = f dg + g df\\),\n\\item \\(da = 0\\) for all \\(a \\in K\\).\n\\end{enumerate}\n\n\\begin{fact}\n  \\(\\Omega_C\\) is a \\(1\\)-dimensional \\(K(C)\\)-vector space.\n\\end{fact}\n\nLet \\(0 \\neq \\omega \\in \\Omega_C\\). Let \\(P \\in C\\) be a smooth point with uniformiser \\(t \\in K(C)\\). It is a fact that \\(dt \\neq 0\\) so we may write \\(\\omega = f dt\\) for some \\(f \\in K(C)^*\\). We define \\(\\ord_p(\\omega) = \\ord_p(f)\\). This is independent of choice of \\(t\\).\n\n\\begin{fact}\n  Suppose \\(f \\in K(C)^*\\) and \\(\\ord_P(f) = n \\neq 0\\). If \\(\\ch K \\ndivides n\\) then \\(\\ord_P(df) = n - 1\\).\n\\end{fact}\n\nWe now assume \\(C\\) is a smooth projective curve.\n\n\\begin{fact}\n  \\(\\ord_p(\\omega) = 0\\) for all but finitely many \\(P \\in C\\).\n\\end{fact}\n\n\\begin{definition}\n  We define \\(\\div(\\omega) = \\sum_{P \\in C} \\ord_P(\\omega) P \\in \\Div(C)\\).\n\\end{definition}\n\n\\begin{definition}\n  We define the genus of \\(C\\) to be\n  \\[\n    g(C) = \\dim_K \\{\\omega \\in \\Omega_C: \\div(\\omega) \\geq 0\\},\n  \\]\n  the dimension of the space of \\emph{regular differentials}.\n\\end{definition}\n\nAs a consequence of Riemann-Roch, we have if \\(0 \\neq \\omega \\in \\Omega_C\\) then \\(\\deg(\\div(\\omega)) = 2 g(C) - 2\\).\n\n\\begin{lemma}\n  Assume \\(\\ch k \\neq 2\\) and \\(E: y^2 = (x - e_1)(x - e_2)(x - e_3)\\). Then \\(\\omega = \\frac{dx}{y}\\) is a differential on \\(E\\) with no zeros or poles. In particular \\(g(E) = 1\\) and the \\(K\\)-vector space of regular differentials on \\(E\\) is \\(1\\)-dimensional, spanned by \\(\\omega\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(T_i = (e_i, 0)\\) and we know \\(E[2] = \\{0, T_1, T_2, T_3\\}\\). We have\n  \\[\n    \\div (y) = (T_1) + (T_2) + (T_3) - 3(0_E)\n  \\]\n  \\(T_i\\) appears with multiplicity \\(1\\) in \\(\\div y\\) since we know \\(\\deg \\div y = 0\\). If \\(P \\in E \\setminus \\{0\\}\\) then\n  \\[\n    \\div (x - x_P) = (P) + (-P) - 2(0_E).\n  \\]\n  If \\(P \\in E \\setminus E[2]\\) then \\(\\ord_P(x - x_P) = 1\\) so \\(\\ord_P(dx) = 0\\). If \\(P = T_i\\) then \\(\\ord_P(x - x_P) = 2\\) so \\(\\ord_P(dx) = 1\\). Finally if \\(P = 0_E\\) then \\(\\ord_P(x) = -2\\) so \\(\\ord_P(dx) = -3\\). Therefore\n  \\[\n    \\div(dx) = (T_1) + (T_2) + (T_3) - 3(0_E).\n  \\]\n  It follows that \\(\\div (\\frac{dx}{y}) = 0\\).\n\\end{proof}\n\n\\begin{definition}\n  If \\(\\phi: C_1 \\to C_2\\) is a nonconstant morphism then we have \\emph{pullback of differentials} defined by\n  \\begin{align*}\n    \\phi^*: \\Omega_{C_2} &\\to \\Omega_{C_1} \\\\\n    f dg &\\mapsto (\\phi^* f) d(\\phi^*g)\n  \\end{align*}\n\\end{definition}\n\n\\begin{lemma}\n  Let \\(P \\in E\\) and \\(\\tau_P: E \\to E, X \\mapsto P + X\\). If \\(\\omega = \\frac{dx}{y}\\) then \\(\\tau_P^* \\omega = \\omega\\). \\(\\omega\\) is called the \\emph{invariant differential}\\index{invariant differential}.\n\\end{lemma}\n\n\\begin{proof}\n  \\(\\tau_p^*\\omega\\) is again a regular differential on \\(E\\) so \\(\\tau_P^* \\omega = \\lambda_P \\omega\\) for some \\(\\lambda_P \\in K^*\\). The map \\(E \\to \\P^1, P \\mapsto \\lambda_P\\) (after a calculation we know the map is rational) is a morphism of smooth projective curve but \\emph{not} surjective, as it misses \\(0, \\infty\\). Therefore it is constant. Thus exists \\(\\lambda \\in K^*\\) such that \\(\\tau_P^* \\omega = \\lambda \\omega\\) for all \\(P \\in E\\). Taking \\(P = 0_E\\) shows \\(\\lambda = 1\\).\n\\end{proof}\n\n\\begin{remark}\n  If \\(K = \\C\\) then remember we have an isomorphism \\(\\C/\\Lambda \\cong E(\\C), z \\mapsto (\\wp(z), \\wp'(z))\\) so\n  \\[\n    \\frac{dx}{y} = \\frac{\\wp'(z) dz}{\\wp'(z)} = dz,\n  \\]\n  which is manifestly invariant under \\(z \\mapsto z + \\text{ constant}\\).\n\\end{remark}\n\n\\begin{lemma}\n  Let \\(\\phi, \\psi \\in \\Hom(E_1, E_2)\\) and \\(\\omega\\) the invariant differential on \\(E_2\\). Then \\((\\phi + \\psi)^* \\omega = \\phi^*\\omega + \\psi^*\\omega\\).\n\\end{lemma}\n\n\\begin{proof}\n  Write \\(E = E_2\\). We have three maps\n  \\begin{align*}\n    E \\times E &\\to E \\\\\n    \\mu: (P, Q) &\\mapsto P + Q \\\\\n    \\pi_1: (P, Q) &\\mapsto P \\\\\n    \\pi_2: (P, Q) &\\mapsto Q\n  \\end{align*}\n  As \\(E \\times E\\) is \\(2\\)-dimensional, it is a fact that \\(\\Omega_{E \\times E}\\) is a \\(2\\)-dimensional \\(K(E \\times E)\\)-vector space with basis \\(\\pi_1^* \\omega, \\pi_2^* \\omega\\). Then \\(\\mu^* \\omega = f \\pi_1^* \\omega + g \\pi_2^* \\omega\\) for some \\(f, g \\in K(E \\times E)\\). For \\(Q \\in E\\) let \\(\\iota_Q: E \\to E \\times E, P \\mapsto (P, Q)\\). Applying \\(\\iota_Q^*\\) gives\n  \\[\n    (\\mu \\iota_Q)^* \\omega = (\\iota_Q^* f) (\\pi_1 \\iota_Q)^* \\omega + (\\iota_Q^* g) (\\pi_2 \\iota_Q)^* \\omega,\n  \\]\n  i.e.\n  \\[\n    \\tau_Q^* \\omega = (\\iota_Q^* f) \\omega + 0\n  \\]\n  so \\(\\iota_Q^*f = 1\\) for all \\(Q \\in E\\), so \\(f(P, Q) = 1\\) for all \\(P, Q \\in E\\). Similarly \\(g(P, Q) = 1\\). Thus \\(\\mu^*\\omega = \\pi_1^* \\omega + \\pi_2^* \\omega\\). Now pullback by \\(E \\to E \\times E, P \\mapsto (\\phi(P), \\psi(P))\\) to get\n  \\[\n    (\\phi + \\psi)^*\\omega = \\phi^*\\omega + \\psi^*\\omega.\n  \\]\n\\end{proof}\n\n\\begin{lemma}\n  Let \\(\\phi: C_1 \\to C_2\\) be a nonconstant morphism. Then \\(\\phi\\) is separable if and only if \\(\\phi^*: \\Omega_{C_2} \\to \\Omega_{C_1}\\) is non-zero.\n\\end{lemma}\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\n\\begin{eg}\n  Consider the group variety \\(\\mathbb G_m = \\A^1 \\setminus \\{0\\} = \\P^1 \\setminus \\{0, \\infty\\}\\) with group law being multiplication. Let \\(n \\geq 2\\) be an intger and consider \\(\\phi(x) = x^n\\). We know from Galois theory that if \\(\\ch K \\ndivides n\\) then \\(\\ker \\phi\\) has \\(n\\) elements. This can also be deducted geometrically using differentials: \\(\\phi^* (dx) = dx^n = nx^{n - 1}dx\\) so if \\(\\ch K \\ndivides n\\) then \\(\\phi\\) is separable. Then \\(\\#\\phi^{-1}(Q) = \\deg \\phi\\) for all but finitely many \\(Q \\in \\mathbb G_m\\). \\(\\phi\\) is a group homomorphism so \\(\\# \\phi^{-1}(Q) = \\ker \\phi\\) for all \\(Q \\in \\mathbb G_m\\) so in fact \\(\\# \\ker \\phi = \\deg \\phi= n\\). Thus \\(K\\) (which is algebraically closed) contains exactly \\(n\\) \\(n\\)th roots of unity.\n\\end{eg}\n\n\\begin{theorem}\n  If \\(\\ch K \\ndivides n\\) then \\(E[n] \\cong (\\Z/n\\Z)^2\\).\n\\end{theorem}\n\n\\begin{proof}\n  By induction \\([n]^*\\omega = n\\omega\\) so if \\(\\ch K \\ndivides n\\) then \\([n]: E \\to E\\) is separable. Thus by the theorem \\(\\# [n]^{-1}(Q) = \\deg [n]\\) for all but finitely many \\(Q \\in E\\). But \\([n]\\) is a group homomorphism so \\(\\#[n]^{-1}(Q) = \\# E[n]\\) for all \\(Q \\in E\\). Thus\n  \\[\n    \\# E[n] = \\deg [n] = n^2.\n  \\]\n  By classification of finitely generated abelian groups,\n  \\[\n    E[n] \\cong \\Z/d_1\\Z \\times \\Z/d_2\\Z \\times \\cdots \\times \\Z/d_t\\Z\n  \\]\n  with \\(d_1 \\divides d_2 \\divides \\cdots \\divides d_t \\divides n\\) and \\(\\prod d_i = n^2\\). If \\(p\\) is a prime with \\(p \\divides d_1\\) then \\(E[p] \\cong (\\Z/p\\Z)^t\\). But \\(\\#E[p] = p^2\\) so \\(t = 2\\) and \\(d_1 \\divides d_2 \\divides n\\), \\(d_1d_2 = n^2\\) so \\(d_1 = d_2 = n\\).\n\\end{proof}\n\n\\begin{remark}\n  If \\(\\ch K = p\\) then \\([p]\\) is inseparable. It can be shown that either \\(E[p^r] \\cong \\Z/p^r\\Z\\) for all \\(r \\geq 1\\), or \\(E[p^r] = 0\\) for all \\(r \\geq 1\\). They are called ordinary and supersingular.\n\\end{remark}\n\n\\section{Elliptic curves over finite fields}\n\nWe begin by proving a form of Cauchy-Schwarz.\n\n\\begin{lemma}\n  Let \\(A\\) be an abelian group and \\(q: A \\to \\Z\\) a positive definite quadratic form. If \\(x, y \\in A\\) then\n  \\[\n    |q(x + y) - q(x) - q(y)| \\leq 2 \\sqrt{q(x) q(y)}.\n  \\]\n\\end{lemma}\n\n\\begin{notation}\n  \\(\\langle x, y \\rangle = q(x + y) - q(x) - q(y)\\) and note that \\(\\langle x, x \\rangle = 2q(x)\\).\n\\end{notation}\n\n\\begin{proof}\n  We may assume \\(x \\neq 0\\) as otherwise the result is clear. Let \\(m, n \\in \\Z\\). Then\n  \\begin{align*}\n    0 &\\leq q(mx + ny) \\\\\n      & \\frac{1}{2} \\langle mx + ny, mx + ny \\rangle \\\\\n      &= m^2 qx + mn \\langle x, y \\rangle + n62 q(y) \\\\\n      &= q(x) (m + \\frac{n \\langle x, y \\rangle}{2q(x)})^2 + n^2 (q(y) - \\frac{\\langle x, y\\rangle^2}{4q(x)}\n  \\end{align*}\n  Take \\(m = \\langle x, y \\rangle, n = -2q(x)\\) to deduce\n  \\[\n    \\langle x, y \\rangle^2 \\leq 4q(x)q(y).\n  \\]\n\\end{proof}\n\nLet \\(\\F_q\\) be the field with \\(q\\) elements where \\(q = p^m\\) for some \\(p\\) prime. Then \\(\\gal(\\F_{q^r}/\\F_q)\\) is cyclic of order \\(r\\) generated by the Frobenius map \\(x \\mapsto x^q\\).\n\n\\begin{theorem}[Hasse]\\index{Hasse's theorem}\n  Let \\(E/\\F_q\\) be an elliptic curve. Then\n  \\[\n    |\\#E(\\F_q) - (q + 1)| \\leq 2 \\sqrt q.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(E\\) have Weierstrass equation with coefficients \\(a_1, \\dots, a_6 \\in \\F_q\\) so \\(a_i^q = a_i\\) for all \\(i\\). Define the \\emph{Frobenius endomorphism}\\index{Frobenius endomorphism} \\(\\phi: E \\to E, (x, y) \\mapsto (x^q, y^q)\\) which is an isogeny of degree \\(q\\). Then\n  \\[\n    E(\\F_q) = \\{P \\in E: \\phi(P) = P\\} = \\ker (1 - \\phi).\n  \\]\n  Note \\(\\phi\\) is not separable as\n  \\[\n    \\phi^*\\omega = \\phi^* (\\frac{dx}{y}) = \\frac{d x^q}{y^q} = \\frac{qx^{q - 1} dx}{y^q} = 0\n  \\]\n  but\n  \\[\n    (1 - \\phi)^* \\omega = \\omega - \\phi^* \\omega = \\omega \\ne 0\n  \\]\n  so \\(1 - \\phi\\) is separable. Same as before, we have \\(\\# \\ker (1 - \\phi) = \\deg (1 - \\phi)\\).\n\n  Recall that \\(\\deg: \\End(E) \\to \\Z\\) is a positive definite quadratic form so by Cauchy-Schwarz\n  \\[\n    |\\deg (1 - \\phi) - \\deg [1] - \\deg [\\phi]| \\leq 2 \\sqrt{\\deg [1] \\deg [\\phi]}\n  \\]\n  so\n  \\[\n    |\\#E(\\F_q) - 1 - q| \\leq 2 \\sqrt q\n  \\]\n  as required.\n\\end{proof}\n\n\\subsection{Zeta function}\n\nFor \\(K\\) a number field, define\n\\[\n  \\zeta_K(s) = \\sum_{\\mathfrak a \\subseteq \\O_K} \\frac{1}{N(\\mathfrak a)^s} = \\prod_{\\mathfrak p \\subseteq \\O_K \\text{ prime}} \\left( 1- \\frac{1}{(N(\\mathfrak p))^s} \\right)^{-1}\n\\]\nFor \\(K\\) a function field, i.e.\\ \\(K = \\F_q(C)\\) where \\(C/\\F_q\\) is a smoth projective curve, we define\n\\[\n  \\zeta_K(s) = \\prod_{x \\in |C|} \\left(1 - \\frac{1}{(Nx)^s} \\right)^{-1}\n\\]\nwhere \\(|C|\\) is the set of closed points of \\(C\\), and is the same as the orbits of \\(\\gal(\\overline \\F_q/\\F_q)\\) on \\(C(\\overline F_q)\\). Have \\(Nx = q^{\\deg x}\\) where \\(\\deg x\\) is the size of the orbit.\n\nWe have \\(\\zeta_K(s) = F(q^{-s})\\) for some \\(F \\in \\Q[[T]]\\). Explicitly\n\\[\n  F(T) = \\prod_{x \\in |C|} (1 - T^{\\deg x})^{-1}.\n\\]\nTake logarithm of the formal power series, we get\n\\begin{align*}\n  \\log F(T) &= \\sum_{x \\in |C|} \\sum_{m = 1}^\\infty \\frac{1}{m} T^{m \\deg x} \\\\\n  T \\frac{d}{dT} \\log F(T) &= \\sum_{x \\in |C|} \\sum_{m = 1}^\\infty (\\deg x) T^{m \\deg x} \\\\\n            &= \\sum_{n = 1}^\\infty (\\sum_{x \\in |C|, \\deg x|n} \\deg x) T^n \\\\\n            &= \\sum_{n = 1}^\\infty \\# C(\\F_{q^n}) T^n\n\\end{align*}\nNow reverse the process,\n\\[\n  F(T) = \\exp \\sum_{n = 1}^\\infty \\frac{\\# C(\\F_{q^n})}{n} T^n.\n\\]\n\nWe define \\(\\tr: \\End(E) \\to \\Z, \\phi \\mapsto \\langle \\phi, 1 \\rangle\\).\n\n\\begin{lemma}\n  If \\(\\phi \\in \\End(E)\\) then\n  \\[\n    \\phi^2 - (\\tr \\phi) \\phi + \\deg \\phi = 0.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Example sheet 2.\n\\end{proof}\n\n\\begin{definition}[zeta function]\\index{zeta function}\n  The \\emph{zeta function} of a variety \\(V/\\F_q\\) is the formal power series (?)\n  \\[\n  Z_V(T) = \\exp \\sum_{n = 1}^\\infty \\frac{\\# V(\\F_{q^n})}{n} T^n.\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  Suppose \\(E/\\F_q\\) is an elliptic curve, \\(\\# E(\\F_q) = q + 1 - a\\). Then\n  \\[\n    Z_E(T) = \\frac{1 - aT + qT^2}{(1 - T)(1 - qT)}.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(\\phi: E \\to E\\) be the \\(q\\)-power Frobenius. By the proof of Hasse's theorem\n  \\[\n    \\#E(\\F_q) = \\deg (1 - \\phi) = q + 1 - \\tr \\phi\n  \\]\n  so \\(a = \\tr \\phi\\) and \\(\\deg \\phi = q\\). By the above lemma \\(\\phi^2 - a\\phi + q = 0\\) so \\(\\phi^{n + 2} - a \\phi^{n + 1} + q \\phi^n = 0\\). Upon taking trace,\n  \\[\n    \\tr \\phi^{n + 2} - a \\tr \\phi^{n + 1} + q \\tr \\phi^n = 0.\n  \\]\n  This second order difference equation with initial condition \\(\\tr 1 = 2, \\tr \\phi = q\\) has solution \\(\\tr \\phi^n = \\alpha^n + \\beta^n\\) where \\(\\alpha, \\beta \\in \\C\\) ar roots of \\(X^2 - aX + q = 0\\). Then\n  \\[\n    \\# E(\\F_{q^n}) = \\deg (1 - \\phi^n)\n    = \\deg \\phi^n + 1 - \\tr \\phi^n\n    = q^n + 1 - \\alpha^n - \\beta^n\n  \\]\n  Thus the zeta function is\n  \\[\n    Z_V(T) = \\exp \\sum_{n = 1}^\\infty \\frac{1}{n} (T^n + (qT)^n - (\\alpha T)^n - (\\beta T)^n)\n    = \\frac{(1 - \\alpha T)(1 - \\beta T)}{(1 - T)(1 - qT)}\n  \\]\n  using \\(-\\log (1 - x) = \\sum_{m = 1}^\\infty \\frac{x^m}{m}\\). Expand.\n\\end{proof}\n\n\\begin{remark}\n  Hasse's theorem as Riemann hypothesis for finite fields: Hasse's theorem gives a bound \\(|a| \\leq 2 \\sqrt q\\) so \\(\\alpha = \\overline \\beta\\). As \\(\\alpha\\beta = q\\), have \\(|\\alpha| = |\\beta| = sqrt q\\). Let \\(K = \\F_q(E)\\). Then \\(\\zeta_K(s) = 0\\) if and only if \\(Z_E(q^{-s}) = 0\\), so \\(q^s = \\alpha \\text{ or } \\beta\\) so \\(q^{\\Re s} = \\sqrt q\\), i.e.\\ \\(\\Re s = \\frac{1}{2}\\). Thus we have proven the Riemann hypothesis.\n\\end{remark}\n\n\\section{Formal groups}\n\n\\begin{definition}[\\(I\\)-adic topology]\\index{\\(I\\)-adic topology}\n  Let \\(R\\) be a ring and \\(I \\subseteq R\\) an ideal. The \\emph{\\(I\\)-adic topology} is the topology on \\(R\\) with basis \\(\\{r + I^n: r \\in R, n \\geq 1\\}\\)\n\\end{definition}\n\n\\begin{definition}\n  A sequence \\((x_n)\\) in \\(R\\) is \\emph{Cauchy} if for all \\(k\\) exists \\(N\\) such that for all \\(m, n \\geq N\\), have \\(x_m - x_n \\in I^k\\).\n\\end{definition}\n\n\\begin{definition}\n  \\(R\\) is \\emph{complete} if\n  \\begin{enumerate}\n  \\item \\(\\bigcap_{n \\geq 0} I^n = \\{0\\}\\) (Hausdorff condition),\n  \\item every Cauchy sequence converges.\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{remark}\n  Suppose \\(R\\) is complete. If \\(x \\in I\\) then \\(\\frac{1}{1 - x} = 1 + x + x^2 + \\cdots\\) so \\(1 - x \\in R^*\\).\n\\end{remark}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(R = \\Z_p\\) with \\(I = p\\Z_p\\). This is complete by construction.\n  \\item \\(R = \\Z[[t]]\\) with \\(I = (t)\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{lemma}[Hensel's lemma]\\index{Hensel's lemma}\n  Let \\(R\\) be an integral domain and is complete with respect to the ideal \\(I\\). Let \\(F \\in R[X]\\), \\(s \\geq 1\\). Suppose \\(a \\in R\\) satisfies \\(F(a) = 0 \\pmod{I^s}, F'(a) \\in R^\\times\\). Then there exists a unique \\(b \\in R\\) satisfying \\(F(b) = 0, b = a \\pmod{I^s}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(u \\in R^\\times\\) with \\(F'(a) = u \\pmod I\\). Replacing \\(F\\) by \\(\\frac{X + A}{u}\\), we may assume \\(a = 0\\) and \\(F'(0 = 1 \\pmod I\\). We define\n  \\[\n    x_0 = 0, \\quad x_{n + 1} = x_n - F(x_n).\n  \\]\n  An easy induction shows \\(x_n = 0 \\pmod{I^s}\\) for all \\(n\\). Also\n  \\[\n    F(X) - F(Y) = (X - Y) (F'(0) + X G(X, Y) + Y H(X, Y))\n  \\]\n  for some \\(G, H \\in R[X, Y]\\). Claim that \\(x_{n + 1} = x_n \\pmod{I^{n + s}}\\) for all \\(n \\geq 0\\).\n\n  \\begin{proof}\n    Induction on \\(n\\). \\(n = 0\\) holds. Suppose \\(x_n = x_{n - 1} \\pmod{I^{n + s - 1}}\\). Then\n    \\[\n      F(x_n) - F(x_{n - 1}) = (x_n - x_{n - 1})(1 + c)\n    \\]\n    for some \\(c \\in I\\). Modulo \\(I^{n + s}\\), get\n    \\[\n      F(x_n) - F(x_{n - 1}) = x_n - x_{n - 1} \\pmod{I^{n + s]}}.\n    \\]\n    Rearrange to get\n    \\[\n      x_{n + 1} = x_n - F(x_n) = x_{n - 1} - F(x_{n - 1}) = x_n \\pmod{I^{n + s}}.\n    \\]\n  \\end{proof}\n  Thus by completeness \\(x_n \\to b\\) as \\(n \\to \\infty\\) for some \\(b \\in R\\). Taking limit of the recurrence relation and use the continuity of \\(F\\) to get \\(F(b) = 0\\). Taking limit in \\(x_n = 0 \\pmod{I^s}\\) gives \\(b = 0 \\pmod{I^s}\\). Uniqueness follows from the assumption \\(R\\) is an integral domain.\n\\end{proof}\n\nConsider \\(E: Y^2Z + a_1 XYZ + a_3 yZ^2 = X^3 + a_2X^2Z + a_4XZ^2 + a_6Z^3\\). We want to study the behaviour near \\(0_E\\) so use the affine piece \\(Y \\neq 0\\). Let \\(t = -X/Y, w = -Z/Y\\). Then\n\\[\n  w = f(t, w) = t^3 + a_1tw + a_2t^2w + a_3w^2 + a_4tw^2 + a_6w^3.\n\\]\nApply Hensel's lemma to \\(R = \\Z[a_1, \\dots, a_6][[t]], I = (t)\\) and \\(F(X) = X - f(t, X)\\). The approximate root is \\(a = 0\\) for \\(s = 3\\). Check \\(F(0) = -t^3, F'(0) = 1 - a_1t - a_2t^2 \\in R^\\times\\). Then there exists a unique \\(w(t) \\in \\Z[a_1, \\dots, a_6][[t]]\\) such that \\(w(t) = f(t, w(t))\\) and \\(w(t) = 0 \\pmod{t^3}\\).\n\nTo see \\(w(t)\\) explicitly, we follow the proof of Hensel's lemma (with \\(u = 1\\)) and get \\(w(t) = \\lim_{n \\to \\infty} w_n(t)\\) where\n\\[\n  w_0(t) = 0, \\quad w_{n + 1}(t) = f(t, w_n(t)).\n\\]\nIn fact\n\\[\n  \\omega(t) = t^3 (1 + A_1t + A_2t^2 + \\dots) = \\sum_{n = 2}^\\infty A_{n - 2}t^{n + 1}\n\\]\nwhere \\(A_1 = a_1, A_2 = a_1^2 + a_2, A_3 = a_1^3 + 2a_1a_2 + a_3, \\dots\\)\n\n\\begin{lemma}\n  Let \\(R\\) be an integral domain, complete with respect to an ideal \\(I\\). Let \\(a_1, \\dots, a_6 \\in R\\) and \\(K\\) the field of fraction of \\(R\\). Then\n  \\[\n    \\hat E(I) = \\{(t, w) \\in E(K): t, w \\in I\\}\n  \\]\n  is a subgroup of \\(E(K)\\).\n\\end{lemma}\n\n\\begin{remark}\n  By unqiueness in Hensel's lemma (with \\(s = 1\\)), we can also describe \\(\\hat E(I)\\) as\n  \\[\n    \\hat E(I) = \\{(t, w(t)) \\in E(K): t \\in I\\}.\n  \\]\n\\end{remark}\n\n\\begin{proof}\n  Taking \\((t, w) = (0 0)\\) shows \\(0_E \\in \\hat E(I)\\), so suffices to show if \\(P_1, P_2 \\in \\hat E(I)\\) then \\(-P_1 - P_2 \\in \\hat E(I)\\). Suppose \\(P_i = (t_i, w_i)\\). The line \\(P_1P_2\\) is given by \\(\\omega = \\lambda t + \\nu\\) where\n  \\[\n    \\lambda =\n    \\begin{cases}\n      \\frac{w(t_2) - w(t_1)}{t_2 - t_1} & t_1 \\neq t_2 \\\\\n      w'(t_1) & t_1 = t_2\n    \\end{cases}\n  \\]\n  so\n  \\begin{align*}\n    \\lambda &= \\sum_{n = 2}^\\infty A_{n - 2}(t_1^n + t_1^{n - 1}t_2 + \\dots + t_2^n) \\in I \\\\\n    \\nu &= w_1 - \\lambda t_1 \\in I\n  \\end{align*}\n  Subsituting \\(w = \\lambda t + \\nu\\) into \\(w = f(t, w)\\), we get\n  \\begin{align*}\n    A &= \\text{ coefficient of } t^3 = 1 + a_2 \\lambda + a_4 \\lambda^2 + a_6 \\lambda^3 \\\\\n    B &= \\text{ coefficient of } t^2 = a_1 \\lambda + a_2 \\nu + a_3 \\lambda^2 + 2a_4 \\lambda \\nu + 3a_6 \\lambda^2 \\nu\n  \\end{align*}\n  we have \\(A \\in R^\\times, B \\in I\\) so \\(t_3 = -B/A - t_1 - t_2 \\in I\\) and \\(w_3 = \\lambda t_3 + \\nu \\in I\\).\n\\end{proof}\n\nTaking \\(R = \\Z[a_1, \\dots, a_t][[t]], I = (t)\\). The lemma shows that there exists \\(\\iota(t) \\in \\Z[a_1, \\dots, a_6][[t]]\\) with \\(\\iota(0) = 0\\) such that \\([-1] (t, w(t)) = (\\iota(t), w(\\iota(t)))\\). Taking \\(R = \\Z[a_1, \\dots, a_6][[t_1, t_2]], I = (t_1, t_2)\\), the lemma says there exists \\(F \\in \\Z[a_1, \\dots, a_6][[t]]\\) with \\(F(0, 0) = 0\\) such that\n\\[\n  (t_1, w(t_1)) + (t_2, w(t_2)) = (F(t_1, t_2), w(F(t_1, t_2))).\n\\]\nIn fact\n\\begin{align*}\n  \\iota(X) &= - X - a_1X^2 - a_2X^3 - (a_1^3 + a_3) X^4 + \\dots \\\\\n  F(X, Y) &= X + Y - a_1XY - a_2(X^2Y + XY^2) + \\dots\n\\end{align*}\nBy properties of the group law we deduce\n\\begin{enumerate}\n\\item \\(F(X, Y) = F(Y, X)\\).\n\\item \\(F(X, 0) = X\\) and \\(F(0, Y) = Y\\).\n\\item \\(F(F(X, Y), Z) = F(X, F(Y, Z))\\).\n\\item \\(F(X, \\iota(X)) = 0\\).\n\\end{enumerate}\n\n\\begin{definition}[formal group]\\index{formal group}\n  Let \\(R\\) be a ring. A \\emph{formal group} over \\(R\\) is a power series \\(F(X, Y) \\in R[[X, Y]]\\) satisfying 1, 2, 3.\n\\end{definition}\n\nA question on example sheet 2 shows that for any formal group, there exists a unique \\(\\iota(t) = -t + \\dots \\in R[[t]]\\) satisfying 4.\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(F(X, Y) = X + Y\\). We call this formal group \\(\\hat{\\mathbb G_a}\\).\n  \\item \\(F(X, Y) = X + Y + XY = (1 + X)(1 + Y) - 1\\) so is secretly the same as above. We call this formal group \\(\\hat{\\mathbb G_m}\\).\n  \\item \\(F\\) arising from an elliptic curve. We call it \\(\\hat E\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}\n  Let \\(\\mathcal F\\) and \\(\\mathcal G\\) be formal groups, given by power series \\(F\\) and \\(G\\).\n  \\begin{enumerate}\n  \\item A \\emph{morphism} \\(f: \\mathcal F \\to \\mathcal G\\) is a power series \\(f(T) \\in R[[T]]\\) with \\(f(0) = 0\\) satisfying \\(f(F(X, Y)) = G(f(X), f(Y))\\).\n  \\item \\(\\mathcal F \\cong \\mathcal G\\) if there exists morphisms \\(f: \\mathcal F \\to \\mathcal G, g: \\mathcal G \\to \\mathcal F\\) such that \\(f(g(X)) = X, g(f(X)) = X\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{theorem}\n  If \\(\\ch R = 0\\) then every formal group \\(\\mathbb F\\) over \\(R\\) is isomorphic to \\(\\hat{\\mathbb G_a}\\) over \\(R \\otimes \\Q\\). More precisely,\n  \\begin{enumerate}\n  \\item there is a unique power series \\(\\log(T) = T + \\frac{a_2}{2} T^2 + \\frac{a_3}{3}T^3 + \\cdots\\) with \\(a_i \\in R\\) such that\n    \\[\n      \\log F(X, Y) = \\log(X) + \\log(Y).\n      \\tag{\\ast}\n    \\]\n  \\item there is a unique power series \\(\\exp(T) = T + \\frac{b_2}{2!} T^2 + \\frac{b_3}{3!} T^3 + \\cdots\\) with \\(b_i \\in R\\) such that\n    \\[\n      \\exp \\log (T) = \\log \\exp (T) = T.\n    \\]\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Write \\(F_1(X, Y) = \\frac{\\partial F}{\\partial X}(X, Y)\\). For uniqueness, let\n    \\[\n      p(T) = \\frac{d}{dT} \\log T = 1 + a_2 T + a_3 T^2 + \\dots.\n    \\]\n    Differentiating \\((\\ast)\\) with respect to \\(X\\) gives\n    \\[\n      p(F(X, Y)) F_1(X, Y) = p(X).\n    \\]\n    Putting \\(X = 0\\) gives \\(p(Y) F_1(0, Y) = 1\\) so \\(p(Y) = F_1(0, Y)^{-1}\\) is unqiue. Thus \\(\\log\\) is unique.\n\n    For existence, let \\(p(T) = F_1(0, T)^{-1} = 1 + a_2 T + a_3 T^2 + \\dots\\) for some \\(a_i \\in R\\). Let \\(\\log T = T + \\frac{a_2}{2}T^2 + \\dots\\). Differentiate the associativity law with respect to \\(X\\) we get\n    \\[\n      F_1(F(X, Y), Z) F_1(X, Y) = F_1(X, F(Y, Z)).\n    \\]\n    Sub \\(X = 0\\) and use identity law,\n    \\[\n      F_1(Y, Z) F_1(0, Y) = F_1(0, F(Y, Z))\n    \\]\n    so\n    \\[\n      F_1(Y, Z) p(F(Y, Z)) = p(Y).\n    \\]\n    Integrate with repsect to \\(Y\\) to get\n    \\[\n      \\log (F(Y, Z)) = \\log Y + h(Z)\n    \\]\n    for some power series \\(h\\). By symmetry in \\(Y, Z\\) have \\(h(Z) = \\log Z\\).\n  \\item\n    We use\n    \\begin{lemma}\n      Let \\(f = aT + \\cdots \\in R[[t]]\\) with \\(a \\in R^\\times\\). Then exists a unique \\(g = a^{-1}T + \\cdots \\in R[[T]]\\) such that \\(f(g(T)) = g(f(T)) = T\\).\n    \\end{lemma}\n\n    \\begin{proof}\n      We construct polynomials \\(g_n(T)\\) such that \\(f(g_n(T)) = T \\pmod{T^{n + 1}}\\) and \\(g_{n + 1}(T) = g_n(T) \\pmod{T^{n + 1}}\\). Then \\(g(T) = \\lim_{n \\to \\infty} g_n(T)\\) exists and satisfies \\(f(g(T)) = T\\).\n\n      To start the induction set \\(g_1(T) = a^{-1}T\\). Now suppose \\(n \\geq 2\\) and \\(g_{n - 1}(T)\\) exists so \\(f(g_{n - 1}(T)) = T + bT^n \\pmod{T^{n + 1}}\\) for some \\(b \\in R\\). We put \\(g_n(T) = g_{n - 1}(T) + \\lambda T^n\\) for some \\(\\lambda \\in R\\) to be chosen later. Then\n      \\begin{align*}\n        f(g_n(T))\n        &= f(g_{n - 1}(T) + \\lambda T^n) \\\\\n        &= f(g_{n - 1}(T)) + \\lambda aT^n \\pmod{T^{n + 1}} \\\\\n        &= T + (b + \\lambda a)T^n \\pmod{T^{n + 1}}\n      \\end{align*}\n      so we take \\(\\lambda = -b/a\\).\n\n      We get \\(g(T) = a^{-1}T + \\cdots \\in R[[T]]\\) such that \\(f(g(T)) = T\\). Applying the same argument to \\(g\\) gives \\(h(T) = aT + \\cdots \\in R[[T]]\\) such that \\(g(h(T)) = T\\). Then\n      \\[\n        f(T) = f(g(h(T))) = h(T).\n      \\]\n    \\end{proof}\n    The theorem then follows except for showing \\(b_n \\in R\\) (not just \\(R \\otimes \\Q\\)). This is on example sheet 2.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{notation}\n  Let \\(\\mathcal F\\) (e.g.\\ \\(\\hat{\\mathbb G_a}, \\hat{\\mathbb G_m}, \\hat E\\)) be a formal group given by \\(F \\in R[[X, Y]]\\). Suppose \\(R\\) is complete with respect to \\(I\\). For \\(x, y \\in I\\) put \\(x \\oplus_{\\mathcal F} y = F(x, y) \\in I\\). Then \\(\\mathcal F(I) = (I, \\oplus_{\\mathcal F})\\) is an abelian group. For example \\(\\hat{\\mathbb G(I)} = (I, +), \\hat{\\mathbb G_m(I)} \\cong (1 + I, \\times)\\) and \\(\\hat E(I) \\subseteq E(K)\\) as in lemma 8.2. This also explains the earlier choice of notation.\n\\end{notation}\n\n\\begin{corollary}\n  Let \\(\\mathcal F\\) be a formal group over \\(R\\) and \\(n \\in \\Z\\). Suppose \\(n \\in R^\\times\\). Then\n  \\begin{enumerate}\n  \\item \\([n]: \\mathcal F \\to \\mathcal F\\) is an isomorphism.\n  \\item If \\(R\\) is complete with respect to an ideal \\(I\\) then \\(\\times n: \\mathcal F(I) \\to \\mathcal F(I)\\) is an isomorphism. In particular \\(\\mathcal F(I)\\) has no \\(n\\)-torsion.\n  \\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n  We first explain the notation \\([n]\\). We inductively define \\([1](T) = T, [n](T) = F([n - 1] T, T)\\) for \\(n \\geq 2\\) (for \\(n < 0\\), use \\([-1](T) = \\iota(T)\\)). An easy induction show \\([n](T) = nT + \\cdots \\in R[[T]]\\) so by Lemma 8.4 it is an isomorphism.\n\\end{proof}\n\n\\section{Elliptic curves over local fields}\n\nLet \\(K\\) be a field, complete with respect to a a discrete valuation \\(v: K^* \\surj \\Z\\). The valuation ring, also known as ring of integers, is\n\\[\n  \\O_K = \\{x \\in K^*: v(x) \\geq 0\\} \\cup \\{0\\}\n\\]\nwith unit group\n\\[\n  \\O_K^* = \\{x \\in K^*: v(x) = 0\\}\n\\]\nand maximal ideal \\(\\pi \\O_K\\) where \\(v(\\pi) = 1\\). It has residue field \\(k = \\O_k/\\pi\\O_K\\). We assume \\(\\ch K = 0, \\ch k = p > 0\\). For example \\(K = \\Q_p, \\O_K = \\Z_p, k = \\F_p\\).\n\nLet \\(E/K\\) be an elliptic curve.\n\n\\begin{definition}[integral/minimal Weierstrass equation]\\index{Weierstrass equation!integral}\\index{Weierstrass equation!minimal}\n  A Weierstrass equation for \\(E\\) with coefficients \\(a_1, \\dots, a_6 \\in K\\) is \\emph{integral} if \\(a_1, \\dots, a_6 \\in \\O_K\\) and is \\emph{minimal} if \\(v(\\Delta)\\) is minimal among all integral equations for \\(E\\).\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item Putting \\(x = u^2 x', y = u^3 y'\\) gives \\(a_i = u^i a_i'\\) so integral equation exists.\n  \\item If \\(a_1, \\dots, a_6 \\in \\O_K\\) then \\(\\Delta \\in \\O_K\\) so \\(v(\\Delta) \\geq 0\\) so minimal Weierstrass equations exist.\n  \\item If \\(\\ch k \\neq 2, 3\\) then exists a minimal Weierstrass equation of the form \\(y^2 = x^3 + ax + b\\).\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{lemma}\n  Let \\(E/K\\) have integral Weierstrass equation\n  \\[\n    y^2 + a_1 xy + a_3 y = x^3 + a_2 x^2 + a_4x + a_6.\n  \\]\n  Let \\(0 \\neq P \\in E(K)\\), say \\(P = (x, y)\\). Then either \\(x, y \\in \\O_K\\) or \\(v(x) = -2s, v(y) = -3s\\) for some \\(s \\geq 1\\).\n\\end{lemma}\n\n\\begin{proof}\n  First we deal with the case \\(v(x) \\geq 0\\) (or \\(x = 0\\)). If \\(v(y) < 0\\) then \\(v(\\mathrm{LHS}) = 0\\) while \\(v(\\mathrm{RHS}) > 0\\), absurd so \\(x, y \\in \\O_K\\).\n\n  Now suppose \\(v(x) < 0\\). Then\n  \\[\n    v(\\mathrm{LHS}) \\geq \\min(2 v(y), v(x) + v(y), v(y)), \\quad v(\\mathrm{RHS}) = 3v(x).\n  \\]\n  In each of the three cases, \\(v(y) < v(x)\\) so \\(2v(y) = 3v(x)\\).\n\\end{proof}\n\n\\begin{remark}\n  See example sheet 1.\n\\end{remark}\n\nFix a minimal Weierstrass equation for \\(E/K\\), we get a formal group \\(\\hat E\\) over \\(\\O_K\\), and\n\\begin{align*}\n  \\hat E (\\pi^r \\O_K)\n  &= \\{(x, y) \\in E(K): -\\frac{x}{y}, -\\frac{1}{y} \\in \\pi^r \\O_K\\} \\cup \\{0\\} \\\\\n  &= \\{(x, y) \\in E(K): v(\\frac{x}{y}) \\geq r, v(\\frac{1}{y}) \\geq r\\} \\cup \\{0\\} \\\\\n  &= \\{(x, y) \\in E(K): v(x) \\leq -2r, v(y) \\leq -2r\\} \\cup \\{0\\}\n\\end{align*}\nby using the lemma. This is a \\(\\pi\\)-neighbourhood of \\(0\\). By theorem 8.2 this is a subgroup of \\(E(K)\\), say \\(E_r(K)\\). Then we have a nested sequence of groups\n\\[\n  E_1(K) \\supseteq E_2(K) \\supseteq \\cdots\n\\]\nMore generally for \\(\\mathcal F\\) a formal group over \\(\\O_K\\), we have\n\\[\n  \\mathcal F(\\pi \\O_K) \\supseteq \\mathcal F(\\pi^2 \\O_K) \\supseteq \\cdots\n\\]\nWe will show that \\(\\mathcal F(\\pi^r \\O_K) \\cong (\\O_K, +)\\) for \\(r\\) sufficiently large and\n\\[\n  \\frac{\\mathcal F(\\pi^r \\O_K)}{\\mathcal F (\\pi^{r + 1} \\O_K)} \\cong (k, +)\n\\]\nfor all \\(r \\geq 1\\).\n\nA reminder we are working over \\(\\ch K = 0, \\ch k = p\\).\n\n\\begin{proposition}\n  Let \\(\\mathcal F\\) be a formal group over \\(\\O_K\\). Let \\(e = v(p)\\). If \\(r > \\frac{e}{p - 1}\\) then\n  \\[\n    \\log: \\mathcal F(\\pi^r \\O_K) \\to \\hat{\\mathbb G_a}(\\pi^r \\O_K)\n  \\]\n  is an isomorphism with inverse \\(\\exp\\).\n\\end{proposition}\n\n\\begin{proof}\n  For \\(x \\in \\pi^r \\O_K\\) we must show that the power series \\(\\exp\\) and \\(\\log\\) in theorem 8.3 converge. Recall \\(\\exp(T) = T + \\frac{b_2}{2!} T^2 + \\dots\\) where \\(b_n \\in \\O_K\\). Note that while a ``big'' denominator is good in Archimedean analysis, the situation is the opposite in the non-Archimedean case. Claim \\(v_p(n!) = \\frac{n - 1}{p - 1}\\).\n\n  \\begin{proof}\n    \\[\n      v_p(n!) = \\sum_{r = 1}^\\infty \\floor*{\\frac{n}{p^r}} < \\sum_{r = 1}^\\infty \\frac{n}{p^r} = \\frac{n}{p - 1}\n    \\]\n    so \\((p - 1) v_p(n!) < n\\). By noting that it is integer valued we get the required inequality.\n  \\end{proof}\n\n  Now\n  \\[\n    v(\\frac{b_n x^n}{n!} \\geq nr - e \\left(\\frac{n - 1}{p - 1}\\right) = (n - 1) \\underbrace{(r - \\frac{e}{p - 1})}_{> 0} + r\n  \\]\n  This is always \\(\\geq r\\) and goes to infinity as \\(n \\to \\infty\\) so \\(\\exp x\\) converges and belongs to \\(\\pi^r \\O_K\\). \\(\\log x\\) is similar but easier.\n\\end{proof}\n\n\\begin{proposition}\n  For \\(r \\geq 1\\),\n  \\[\n    \\frac{\\mathcal F(\\pi^r \\O_K)}{\\mathcal F (\\pi^{r + 1} \\O_K)} \\cong (k, +).\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  Recall \\(F(X, Y) = X + Y + XY (\\cdots)\\) so if \\(x, y \\in \\O_K\\),\n  \\[\n    F(\\pi^rx, \\pi^ry) = \\pi^r(x + y) \\pmod{\\pi^{r + 1}}.\n  \\]\n  Thus\n  \\begin{align*}\n    \\mathcal F(\\pi^r \\O_K) &\\to (k, +) \\\\\n    \\pi^r x &\\mapsto x \\pmod \\pi\n  \\end{align*}\n  is a surjective homomorphism with kernel \\(\\mathcal F(\\pi^{r + 1}\\O_K)\\).\n\\end{proof}\n\n\\begin{corollary}\n  If \\(k\\) is finite then \\(\\mathcal F(\\pi \\O_K)\\) contains a subgroup of finite index and is isomorphic to \\((\\O_K, +)\\).\n\\end{corollary}\n\n\\begin{notation}\n  We denote reduction mod \\(\\pi\\) by \\(x \\mapsto \\tilde x\\).\n\\end{notation}\n\n\\begin{proposition}\n  Suppose \\(E/K\\) is an elliptic curve. The reduction mod \\(\\pi\\) of two minimal Weierstrass equations for \\(E\\) define isomorphic curves over \\(k\\).\n\\end{proposition}\n\n\\begin{proof}\n  Say Weierstrass equations are related by \\([u; r, s, t]\\) where \\(u \\in K^\\times, r, s, t \\in K\\). Then \\(\\Delta_1 = u^{12} \\Delta_2\\). Minimality of equations implies that \\(u \\in \\O_K^*\\). By transformation formula for \\(a_i\\) and \\(b_i\\), we conclude \\(r, s, t \\in \\O_K\\). Then the Weierstrass equation for the reductions mod \\(\\pi\\) are related by \\([\\tilde u; \\tilde r, \\tilde s, \\tilde t]\\). Note that all these are to ensure that things work in characteristic \\(2\\) or \\(3\\).\n\\end{proof}\n\n\\begin{definition}[reduction]\\index{reduction}\n  The \\emph{reduction} \\(\\widetilde E/k\\) of \\(E/K\\) is defined to be the reduction of a minimal Weierstrass equation.\n\n  \\(E\\) has \\emph{good reduction} if \\(\\widetilde E\\) is nonsingular (and so is an elliptic curve), otherwise \\emph{bad reduction}.\n\\end{definition}\n\nFor an integral Weierstras equation, \\(v(\\Delta) = 0\\) is a sufficient condition for good reduction. On the other hand if \\(0 < v(\\Delta) < 12\\) then by \\(\\Delta_1 = u^{12} \\Delta_2\\) we have bad reduction. If \\(v(\\Delta) \\geq 12\\) then the equation might not be minimal.\n\nThere is a well-defined map\n\\begin{align*}\n  \\P^2(K) &\\to \\P^2(k) \\\\\n  (x:y:z) &\\mapsto (\\tilde x: \\tilde y: \\tilde z)\n\\end{align*}\nwhere we choose representatives with \\(\\min(v(x), v(y), v(z)) = 0\\) to ensure we do not get \\((0: 0: 0)\\). We restrict to get \\(E(K) \\to E(k), P \\mapsto \\widetilde P\\). If \\(P = (x, y) \\in E(K)\\) then either \\(x, y \\in \\O_K\\) so \\(\\widetilde P = (\\tilde x, \\tilde y)\\), or \\(v(x) = -2s, v(y) = -3s\\) and we choose \\(P = (\\pi^{3s} x: \\pi^{3s}y: \\pi^{3s})\\) which reduces to \\(\\widetilde P = (0: 1: 0)\\). Thus\n\\[\n  E_1(K) = \\hat E(\\pi \\O_K) = \\{P \\in E(K): \\widetilde P = 0\\}\n\\]\nis the \\emph{kernel of reduction}\\index{kernel of reduction}.\n\nLet \\(\\widetilde E_{\\mathrm{ns}}\\) be the set of nonsingular points on \\(\\widetilde E\\). If \\(E\\) has good reduction then this is the same as \\(\\widetilde E\\). Otherwise we delete the singular points. The chord and tangent process still defines a group law on \\(\\widetilde E_{\\mathrm{ns}}\\) (since the third intersection point only has multiplicity \\(1\\)). In case of bad reduction \\(\\widetilde E_{\\mathrm{ns}} \\cong \\mathbb G_a\\) or \\(\\mathbb G_m\\) (over \\(\\overline k\\)), called additive reduction or multiplicative reduction. For simpicity suppose \\(\\ch k \\neq 2\\) and we have \\(\\widetilde E: y^2 = f(x)\\). Then \\(\\widetilde E\\) is singular if and only if \\(f\\) has a repeated root. For double root (\\(y^2 = x^2(x + 1)\\)) we have a curve with a node and we use multiplicative reduction. For triple root (\\(y^2 = x^3\\)) we have a curve with a cusp and we use additive reduction\n\\begin{align*}\n  \\widetilde E_{\\mathrm{ns}} &\\to \\mathbb G_a \\\\\n  (x, y) &\\mapsto \\frac{x}{y} \\\\\n  (t^{-2}, t^{-3}) &\\mapsfrom t \\\\\n  \\infty &\\mapsfrom 0\n\\end{align*}\nWe check this is a group homomorphism. Let \\(P_1, P_2, P_3\\) be on the line \\(ax + by = 1\\). Write \\(P_i = (x_i, y_i), t_i = \\frac{x_i}{y_u}\\). Then \\(x_i^3 = y_i^2 = y_i^2(ax_i + by_i)\\) so \\(t_1, t_2, t_3\\) are roots of \\(X^3 - aX - b = 0\\). Looking at the coefficient of \\(X^2\\) gives \\(t_1 + t_2 + t_3 = 0\\).\n\nThe node case is on example sheet.\n\n\\begin{definition}\n  We define\n  \\[\n    E_0(K) = \\{P \\in E(K): \\widetilde P \\in \\widetilde E_{\\mathrm{ns}}(k)\\},\n  \\]\n  the points that do not become singular upon reduction.\n\\end{definition}\n\n\\begin{proposition}\n  \\(E_0(K)\\) is a subgroup of \\(E(K)\\) and reduction mod \\(\\pi\\) is a surjective group homomorphism \\(E_0(K) \\to \\widetilde E_{\\mathrm{ns}}(k)\\).\n\\end{proposition}\n\n\\begin{proof}\n  First check this is a group homomorphism. A line \\(\\ell\\) in \\(\\P^2\\) defined over \\(K\\) has equation \\(aX + bY + cZ = 0\\) where \\(a, b, c \\in K\\). We may assume \\(\\min (v(a), v(b), v(c)) = 0\\). Reduction mod \\(\\pi\\) given the line \\(\\tilde \\ell\\) \\(\\tilde a X + \\tilde b Y + \\tilde c Z = 0\\). If \\(P_1, P_2, P_3 \\in E(K)\\) with \\(P_1 + P_2 + P_3 = 0\\) then they lie on a line \\(\\ell\\). Then \\(\\widetilde P_1, \\widetilde P_2, \\widetilde P_3\\) lie on \\(\\tilde \\ell\\). If \\(\\widetilde P_1, \\widetilde P_2 \\in \\widetilde E_{\\mathrm{ns}}(k)\\) then \\(\\widetilde P_3 \\in \\widetilde E_{\\mathrm{ns}}(k)\\) so if \\(P_1, P_2 \\in E_0(K)\\) then \\(P_3 \\in E_0(K)\\) and \\(\\widetilde P_1 + \\widetilde P_2 + \\widetilde P_3 = 0\\). It is an exercise to check that this still works when \\(\\widetilde P_1, \\widetilde P_2, \\widetilde P_3\\) are not necessarily distinct.\n\n  Now we show surjectivity. Let \\(f(x, y) = y^2 + a_1xy + a_3y - (x^3 + \\dots)\\) be the Weierstrass equation. Let \\(\\widetilde P \\in \\widetilde E_{\\mathrm{ns}}(k) \\setminus \\{0\\}\\), say \\(\\widetilde P = (\\tilde x_0, \\tilde y_0)\\) for some \\(x_0, y_0 \\in \\O_K\\). \\(\\widetilde P\\) nonsingular implies that either \\(\\frac{\\partial f}{\\partial x}(x_0, y_0) \\neq 0 \\pmod \\pi\\) or \\(\\frac{\\partial f}{\\partial y}(x_0, y_0) \\neq 0 \\pmod \\pi\\). In the first case put \\(g(t) = f(t, y_0) \\in \\O_K[t]\\). Then\n  \\[\n    g(x_0) = 0 \\pmod \\pi, \\quad g'(x_0) \\in \\O_K^*\n  \\]\n  so by Hensel's lemma exists \\(b \\in \\O_K\\) such that \\(g(b) = 0, b = x_0 \\pmod \\pi\\). Then \\(P = (b, y_0) \\in E(K)\\) has reduction \\(\\widetilde P\\). The second case is similar.\n\\end{proof}\n\nRecall that for \\(r \\geq 1\\) we put\n\\[\n  E_r(K) = \\{(x, y) \\in E(K): v(x) \\leq -2r, v(y) \\leq -3r\\} \\cup \\{0\\}\n\\]\nand we have a nested sequence of groups\n\\[\n  (\\O_K, +) \\cong E_r(K) \\subseteq \\cdots \\subseteq E_2(K) \\subseteq E_1(K) \\subseteq E_0(K) \\subseteq E(K)\n\\]\nfor \\(r > \\frac{e}{p - 1}\\). The quotient \\(\\frac{E_0(K)}{E_1(K)} \\cong \\widetilde E_{\\mathrm{ns}}(K)\\) and all quotients \\(\\frac{E_{t + 1}}{E_t} \\cong (k, +)\\). What about \\(E_0(K) \\subseteq E(K)\\)? There are much to be said about this but we only cover a special case here. More can be found is Silverman's sequel.\n\n\\begin{lemma}\n  If \\(|k| < \\infty\\) then \\(\\P^n(K)\\) is compact (with respect to \\(\\pi\\)-adic topology).\n\\end{lemma}\n\n\\begin{proof}\n  If \\(|k| < \\infty\\) then \\(\\frac{\\O_K}{\\pi^r \\O_K}\\) is finite for \\(r \\geq 1\\) so \\(\\O_K \\cong \\varprojlim_r \\O_K/\\pi^r \\O_K\\) is compact. \\(\\P^n(K)\\) is the union of compact sets\n  \\[\n    \\{(a_0: a_1: \\cdots : a_{i - 1}: 1 : a_{i + 1}: \\cdots: a_n): a_j \\in \\O_K\\}\n  \\]\n  and hence compact.\n\\end{proof}\n\n\\begin{lemma}\n  If \\(|k| < \\infty\\) then \\(E_0(K) \\subseteq E(K)\\) has finite index.\n\\end{lemma}\n\n\\begin{proof}\n  \\(E(K) \\subseteq \\P^2(K)\\) is a closed subset so \\((E(K), +)\\) is a compact topological group. If \\(\\widetilde E\\) has singular point \\((\\tilde x_0, \\tilde y_0)\\) then\n  \\[\n    E(K) \\setminus E_0(K) = \\{(x, y) \\in E(K): v(x - x_0) \\geq 1, v(y - y_0) \\geq 1\\}\n  \\]\n  (?) is a closed subset of \\(E(K)\\) and so \\(E_0(K)\\) is an open subgroup of \\(E(K)\\). The cosets of \\(E_0(K)\\) are an open cover of \\(E(K)\\), and thus \\(E_0(K)\\) has finite index in \\(E(K)\\) by compactness. The index is called \\emph{Tamagawa number} and is denoted \\(c_K(E)\\).\n\\end{proof}\n\n\\begin{remark}\n  Good reduction implies that \\(c_K(E) = 1\\) but the converse is false.\n\\end{remark}\n\n\\begin{fact}\n  For these facts it is essential that \\(E\\) is defined by a minimal Weierstrass equation, but we don't need \\(|k| < \\infty\\).\n\n  Either \\(c_K(E) = v(\\Delta)\\) or \\(c_K(E) \\leq 4\\)\n\\end{fact}\n\n\\begin{theorem}\n  If \\([K: \\Q_p] < \\infty\\) then \\(E(K)\\) contains a subgroup \\(E_r(K)\\) of finite index with \\(E_r(K) \\cong (\\O_K, +)\\).\n\\end{theorem}\n\n\\begin{proof}\n  We have \\(|k| < \\infty\\). Combine all results in this chapter.\n\\end{proof}\n\n\\begin{corollary}\n  \\(E(K)_{\\mathrm{tors}}\\) injects into \\(\\frac{E(K)}{E_r(K)}\\) and is therefore finite.\n\\end{corollary}\n\nWe now quote some results from algebraic number theory. Let \\([K: \\Q_p] < \\infty\\) and \\(L/K\\) a finite extension. Then \\([L: K] = ef\\) where \\(v_L|_{K^*} = e v_K\\) and \\(f = [k': k]\\) where \\(k'\\) and \\(k\\) are the residue fields of \\(L\\) and \\(K\\) respectively. If \\(L/K\\) is Galois then there is a natural group homomorphism \\(\\gal(L/K) \\to \\gal(k'/k)\\). This map is surjective with kernel of order \\(e\\).\n\n\\begin{definition}[unramified extension]\\index{unramified extension}\n  \\(L/K\\) is \\emph{unramified} if \\(e = 1\\).\n\\end{definition}\n\n\\begin{fact}\n  For each integer \\(m \\geq 1\\),\n  \\begin{enumerate}\n  \\item \\(k\\) has a unique extension of degree \\(m\\), say \\(k_m\\).\n  \\item \\(K\\) has a unique unramified extension of degree \\(m\\), say \\(K_m\\).\n  \\end{enumerate}\n\\end{fact}\n\n\\begin{definition}[maximal unramified extension]\\index{maximal unramified extension}\n  We define the \\emph{maximal unramified extension} to be \\(K^{\\mathrm{nr}} = \\bigcup_{m \\geq 1} K_m\\) (inside \\(\\overline K\\)).\n\\end{definition}\n\n\\begin{theorem}\n  Suppose \\([K: \\Q_p] < \\infty\\), \\(E/K\\) an elliptic curve with good reduction and \\(p \\ndivides n\\). If \\(P \\in E(K)\\) then \\(K([n]^{-1}P)/K\\) is unramified.\n\\end{theorem}\n\nRecall that when we do not specify a base field then we refer to the algebraic closure so\n\\[\n  [n]^{-1}P = \\{Q \\in E(\\overline K) = nQ = P\\}.\n\\]\nAlso we denote\n\\[\n  K(\\{P_1, \\dots, P_r\\}) = K(X_1, \\dots, x_r, y_1, \\dots, y_r)\n\\]\nwhere \\(P_i = (x_i, y_i)\\).\n\n\\begin{proof}\n  For each \\(m \\geq 1\\) there is a short exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & E_1(K_m) \\ar[r] & E(K_m) \\ar[r] & \\widetilde E(k_m) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  Taking union over all \\(m \\geq 1\\) gives a commutative diagram with exact rows\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & E_1(K^{\\mathrm{nr}}) \\ar[d, \"n\"] \\ar[r] & E(K^{\\mathrm{nr}}) \\ar[r] \\ar[d, \"n\"] & \\widetilde E(\\overline k) \\ar[r] \\ar[d, \"n\"] & 0 \\\\\n      0 \\ar[r] & E_1(K^{\\mathrm{nr}}) \\ar[r] & E(K^{\\mathrm{nr}}) \\ar[r] & \\widetilde E(\\overline k) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  The left vertical map is an isomorphism by corollary 8.5, which applies since \\(p \\ndivides n\\) implies \\(n \\in \\O_K^*\\). The right vertical map is surjective by Theorem 2.8 and has kernel isomorphic to \\((\\Z/n\\Z)^2\\) by theorem 6.5. Then by snake lemma\n  \\[\n    E(K^{\\mathrm{nr}})[n] \\cong (\\Z/n\\Z)^2, \\frac{E(K^{\\mathrm{nr}})}{n E(K^{\\mathrm{nr}})} = 0\n  \\]\n  so if \\(P \\in E(K)\\) then \\(P = nQ\\) for some \\(Q \\in E(K^{\\mathrm{nr}})\\) so\n  \\[\n    [n]^{-1} P = \\{Q + T: T \\in E[n]\\} \\subseteq E(K^{\\mathrm{nr}})\n  \\]\n  so \\(K([n]^{-1} P) \\subseteq K^{\\mathrm{nr}}\\) so \\(K([n]^{-1}P)/K\\) is unramified.\n\\end{proof}\n\n\\section{Elliptic curves over number fields}\n\nSuppose \\([K: \\Q] < \\infty\\) and \\(E/K\\) is an elliptic curve. Throughout we let \\(\\mathfrak p\\) be a prime of \\(K\\) (i.e.\\ of \\(\\O_K\\)), \\(K_{\\mathfrak p}\\) the \\(\\mathfrak p\\)-adic completion of \\(K\\) and \\(k_{\\mathfrak p} = \\O_k/\\mathfrak p\\).\n\n\\begin{definition}[prime of good reduction]\\index{good reduction}\n  \\(\\mathfrak p\\) is a prime of \\emph{good reduction} for \\(E/K\\) if \\(E/K_{\\mathfrak p}\\) has good reduction.\n\\end{definition}\n\n\\begin{lemma}\n  \\(E/K\\) has only finitely many primes of bad reduction.\n\\end{lemma}\n\n\\begin{proof}\n  Take a Weierstrass equation for \\(E\\) with coefficients \\(a_1, \\dots, a_6 \\in \\O_K\\). \\(E\\) is nonsingular implies that \\(0 \\neq \\Delta \\in \\O_K\\). Write \\((\\Delta) = \\mathfrak p_1^{\\alpha_1} \\cdots \\mathfrak p_r^{\\alpha_r}\\) for the factorisation into prime ideals. Let \\(S = \\{\\mathfrak p_1, \\dots, \\mathfrak p_r\\}\\). If \\(\\mathfrak p \\notin S\\) then \\(v_{\\mathfrak p}(\\Delta) = 0\\) so \\(E/K_{\\mathfrak p}\\) has good reduction.\n\\end{proof}\n\n\\begin{remark}\n  If \\(K\\) has class number \\(1\\) (e.g.\\ \\(K = \\Q\\)) then we can always find a Weierstrass equation for \\(a_1, \\dots, a_6 \\in \\O_K\\) which is minimal at all primes \\(\\mathfrak p\\).\n\\end{remark}\n\n\\begin{lemma}\n  \\(E(K)_{\\mathrm{tor}}\\) is finite.\n\\end{lemma}\n\n\\begin{proof}\n  Take any \\(\\mathfrak p\\). Note \\(K \\subseteq K_{\\mathfrak p}\\) and apply theorem 9.8.\n\\end{proof}\n\n\\begin{lemma}\n  Let \\(\\mathfrak p\\) be a prime of good reduction with \\(\\mathfrak p \\ndivides n\\). Then reduction modulo \\(\\mathfrak p\\) gives an injection \\(E(K)[n] \\embed \\widetilde E(k_{\\mathfrak p})[n]\\).\n\\end{lemma}\n\n\\begin{proof}\n  Proposition 9.5 says that \\(E(K_{\\mathfrak p}) \\to \\widetilde E(k_{\\mathfrak p})\\) is a group homomorphism with kernel \\(E_1(K_{\\mathfrak p})\\). Then corollary 8.5 implies that \\(E_1(K_{\\mathfrak p})\\) has no \\(n\\)-torsion.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(E/\\Q: y^2 + y = x^3 - x^2\\). \\(\\Delta = -11\\). \\(E\\) has good reduction at all primes \\(p \\neq 11\\).\n  \\begin{table}[h]\n    \\centering\n    \\begin{tabular}{c|cccccc}\n      p & 2 & 3 & 5 & 7 & 11 & 13 \\\\ \\hline\n      \\(\\# \\widetilde E(\\F_p)\\) & 5 & 5 & 5 & 10 & - & 10\n    \\end{tabular}\n  \\end{table}\n  so by looking at \\(2\\) and \\(3\\), \\(\\#E(\\Q)_{\\mathrm{tor}} \\divides 5 \\cdot 2^a\\) for some \\(a \\geq 0\\). \\(\\#E(\\Q)_{\\mathrm{tor}} \\divides 5 \\cdot 3^b\\) for some \\(b \\geq 0\\), so \\(\\#E(\\Q)_{\\mathrm{tor}} \\divides 5\\). Let \\(T = (0, 0) \\in E(\\Q)\\). We can check that \\(5T = 0\\) so \\(E(\\Q)_{\\mathrm{tor}} \\cong \\Z/5\\Z\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(E/\\Q: y^2 + y = x^3 + x\\). \\(\\Delta = -43\\). \\(E\\) has good reduction at all \\(p \\neq 43\\).\n  \\begin{table}[h]\n    \\centering\n    \\begin{tabular}{c|cccccc}\n      p & 2 & 3 & 5 & 7 & 11 & 13 \\\\ \\hline\n      \\(\\# \\widetilde E(\\F_p)\\) & 5 & 6 & 10 & 8 & 9 & 19\n    \\end{tabular}\n  \\end{table}\n  By considering \\(p = 2, 11\\) we show \\(E(\\Q)_{\\mathrm{tor}} = \\{0\\}\\). Thus \\(P = (0, 0) \\in E(\\Q)\\) is a point of infinite order. Thus rank of \\(E(\\Q) \\geq 1\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(E_D: y^2 = y^2 = x^3 - D^2 x\\) where \\(D \\in \\Z\\) square free and \\(\\Delta = 2^6 D^6\\). We know the torsion group contains \\(\\{0, (0, 0), (\\pm d, 0)\\} \\cong (\\Z/2\\Z)^2\\). Let \\(f(x) = x^3 - D^2x\\). We can count the number of points using Legendre symbol. If \\(p \\ndivides 2D\\) then\n  \\[\n    \\# \\widetilde E_D(\\F_p) = 1 + \\sum_{x \\in \\F_p} (\\legendre{f(x)}{p} + 1).\n  \\]\n  If \\(p = 3 \\pmod 4\\) then since \\(f(x)\\) is an odd function,\n  \\[\n    \\legendre{f(-x)}{p} = \\legendre{-f(x)}{p} = \\legendre{-1}{p} \\legendre{f(x)}{p} = - \\legendre{f(x)}{p}\n  \\]\n  so \\(\\# \\widetilde E_D(\\F_p) = p + 1\\).\n\n  Let \\(m = \\# E_D(\\Q)_{\\mathrm{tor}}\\). We have \\(4 \\divides m \\divides (p + 1)\\) for all sufficiently large primes \\(p\\) with \\(p = 3 \\pmod 4\\). Then by \\(m = 4\\) as otherwise we will get a contradiction to Dirichlet's theorem on primes in arithmetic progression. Thus \\(E_D(\\Q)_{\\mathrm{tor}} \\cong (\\Z/2\\Z)^2\\). Thus rank \\(E_D(\\Q) \\geq 1\\) if and only if there exists \\(x, y \\in \\Q\\) with \\(y \\neq 0\\) and \\(y^2 = x^3 - D^2x\\), if and only if \\(D\\) is a congruent number.\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(E/\\Q\\) be given by a Weierstrass equation with \\(a_1, \\dots, a_6 \\in \\Z\\). Suppose \\(0 \\neq T = (x, y) \\in E(\\Q)_{\\mathrm{tor}}\\). Then\n  \\begin{enumerate}\n  \\item \\(4x, 8y \\in \\Z\\),\n  \\item if \\(2 \\divides a_1\\) or \\(2T \\neq 0\\) then \\(x, y \\in \\Z\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof} \\leavevmode\n  \\begin{enumerate}\n  \\item The Weierstrass equation defines a formal group \\(\\hat E\\) over \\(\\Z\\). For \\(r \\geq 1\\), recall\n    \\[\n      \\hat E(p^r \\Z_p) = \\{(x, y) \\in E(\\Q_p): v_p(x) \\leq -2r, v_p(y) \\leq -3r\\} \\cup \\{0\\}.\n    \\]\n    Proposition 9.2 says \\(\\hat E(p^r\\Z_p) \\cong (\\Z_p, +)\\) if \\(r > \\frac{1}{p - 1}\\). Thus \\(\\hat E(4 \\Z_2)\\) and \\(\\hat E(p\\Z_p)\\) for \\(p\\) odd are torsion free. Thus if \\(0 \\neq T = (x, y) \\in E(\\Q)_{\\mathrm{tors}}\\) then \\(T \\notin \\hat E(4\\Z_2)\\), so \\(v_2(x) \\geq -2, v_2(y) \\geq -3\\). \\(T \\notin \\hat E(p\\Z_p)\\) so \\(v_p(X) \\geq 0, v_p(y) \\geq 0\\).\n  \\item Suppose \\(T \\in \\hat E(2 \\Z_2)\\), i.e.\\ \\(v_2(x) = -2, v_3(y) = -3\\). Since \\(\\frac{\\hat E(2\\Z_2)}{\\hat E(4\\Z_2)} \\cong (\\F_2, +)\\) and \\(\\hat E(4\\Z_2)\\) is torsion free, we get \\(2T = 0\\). Also\n    \\[\n      (x, y) = T = -T = (x, -y - a_1x - a_3)\n    \\]\n    so \\(2y + a_1x + a_3 = 0\\). Thus \\(8y + a_1 (4x) + 4a_3 = 0\\), and \\(8y, 4x\\) are both odd and \\(4a_3 = 0\\) so \\(a_1\\) is odd. Thus if \\(2T \\neq 0\\) or \\(a_1\\) is even then \\(T \\in \\hat E(2\\Z_2)\\) and so \\(x, y \\in \\Z\\).\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{eg}\n  \\(y^2 + xy + x^3 + 4x + 1\\) has \\((-\\frac{1}{4}, \\frac{1}{8}) \\in E(\\Q)[2]\\).\n\\end{eg}\n\n\\begin{theorem}[Lutz Nagell]\n  Let \\(E/\\Q: y^2 = x^3 + ax + b\\) where \\(a, b \\in \\Z\\). Suppose \\(0 \\neq T = (x, y) \\in E(\\Q)_{\\mathrm{tors}}\\). Then \\(x, y \\in \\Z\\) and either \\(y = 0\\) or \\(y^2 \\divides (4a^2 + 27b^2)\\).\n\\end{theorem}\n\n\\begin{proof}\n  Lemma 10.4 implies \\(x, y \\in \\Z\\). If \\(2T = 0\\) then \\(y = 0\\). Otherwise \\(0 \\neq 2T = (x_2, y_2)\\) is torsion so \\(x_2, y_2 \\in \\Z\\). Then \\(x_2 = \\left(\\frac{f'(x)}{2y}\\right)^2 - 2x\\). Everything is integer so \\(y \\divides f'(x)\\). \\(E\\) is nonsingular so \\(f(X)\\) and \\(f'(X)\\) are coprime. \\(f(X)\\) and \\(f'(X)^2\\) are coprime so exists \\(g, h \\in \\Q[X]\\) such that \\(g(X) f(X) + h(X) f'(X)^2 = 1\\). A calculation gives\n  \\[\n    (3X^3 + 4a) f'(X)^2 - 27(X^3 + aX - b)f(X) = 4a^3 + 27b^2.\n  \\]\n  Since \\(y \\divides f'(x)\\) and \\(y^2 = f(x)\\) we get \\(y^2 \\divides (4a^3 + 27b^2)\\).\n\\end{proof}\n\n\\begin{remark}\n  Mazur has shown that if \\(E/\\Q\\) is an elliptic curve then \\(E(\\Q)_{\\mathrm{tors}}\\) is isomorphic to one of the below:\n  \\[\n    \\Z/n\\Z \\text{ for } 1 \\leq n \\leq 12, n \\neq 11 \\text{ or } \\Z/2\\Z \\times \\Z/2n\\Z \\text{ for } 1 \\leq n \\leq 4.\n  \\]\n  Moreover all 15 possibilities occur.\n\\end{remark}\n\n\\section{Kummer theory}\n\nLet \\(K\\) be a field with \\(\\ch K \\ndivides n\\). Assume \\(\\mu_n \\subseteq K\\).\n\n\\begin{lemma}\n  Let \\(\\Delta \\subseteq K^*/(K^*)^n\\) be a finite subgroup. Let \\(L = K(\\sqrt[n]{\\Delta})\\). Then \\(L/K\\) is Galois and\n  \\[\n    \\gal(L/K) \\cong \\Hom(\\Delta, \\mu_n).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  \\(L/K\\) is Galois since \\(\\mu_n \\subseteq K\\) and \\(\\ch K \\ndivides n\\). Define the \\emph{Kummer pairing}\\index{Kummer pairing}\n  \\begin{align*}\n    \\langle \\cdot , \\cdot \\rangle: \\gal(L/K) \\times \\Delta &\\to \\mu_n \\\\\n    (\\sigma, x) &\\mapsto \\frac{\\sigma(\\sqrt[n]{x})}{\\sqrt[n]{x}}\n  \\end{align*}\n  Check this is well-defined: if \\(\\alpha, \\beta \\in L\\) with \\(\\alpha^n = \\beta^n = x\\) then \\((\\frac{\\alpha}{\\beta})^n = 1\\) so \\(\\frac{\\alpha}{\\beta} \\in \\mu_n \\subseteq K\\) so \\(\\sigma(\\frac{\\alpha}{\\beta}) = \\frac{\\alpha}{\\beta}\\) so \\(\\frac{\\sigma(\\alpha)}{\\alpha} = \\frac{\\sigma(\\beta)}{\\beta}\\). It is bilinear:\n  \\begin{align*}\n    \\langle \\sigma\\tau, x \\rangle\n    &= \\frac{\\sigma(\\tau \\sqrt[n]{x})}{\\tau \\sqrt[n]x} \\frac{\\tau \\sqrt[n]x}{\\sqrt[n]x}\n      = \\langle \\sigma, x \\rangle \\langle \\tau, x \\rangle \\\\\n    \\langle \\sigma, xy \\rangle\n    &= \\frac{\\sigma \\sqrt[n]{xy}}{\\sqrt[n]{xy}}\n      = \\frac{\\sigma \\sqrt[n]x}{\\sqrt[n]x} \\frac{\\sigma \\sqrt[n]y}{\\sqrt[n]y}\n      = \\langle \\sigma, x\\rangle \\langle \\sigma, y\\rangle\n  \\end{align*}\n  The pairing is nondegenerate in both arguments: let \\(\\sigma \\in \\gal(L/K)\\). If \\(\\langle \\sigma, x\\rangle = 1\\) for all \\(x \\in \\Delta\\) then \\(\\sigma \\sqrt[n]x = \\sqrt[n]x\\) for all \\(x \\in \\Delta\\) so \\(\\sigma\\) fixes \\(L\\) pointwise so \\(\\sigma = 1\\). Conversely let \\(x \\in \\Delta\\). If \\(\\langle \\sigma, x \\rangle = 1\\) for all \\(\\sigma \\in \\gal(L/K)\\) then \\(\\sigma \\sqrt[n]x = \\sqrt[n]x\\) for all \\(\\sigma\\) so \\(\\sqrt[n]x \\in K^*\\) so \\(x \\in (K^*)^n\\).\n\n  To put it in another way \\(\\gal(L/K)\\) and \\(\\Delta\\) are dual groups to each other and we have two injective group homomorphisms\n  \\begin{enumerate}\n  \\item \\(\\gal(L/K) \\embed \\Hom(\\Delta, \\mu_n)\\),\n  \\item \\(\\Delta \\embed \\Hom(\\gal(L/K), \\mu_n)\\).\n  \\end{enumerate}\n  Statement 1 implies \\(\\gal(L/K)\\) is an abelian group of exponent dividing \\(n\\). Now similar to the fact that the dual group of a finite abelian group has the same size, we have \\(|\\Hom(\\Delta, \\mu_n)| = |\\Delta|\\) and same for the other so\n  \\[\n    |\\gal(L/K)| \\leq |\\Delta| \\leq |\\gal(L/K)|\n  \\]\n  so 1 and 2 are isomorphisms.\n\\end{proof}\n\n\\begin{eg}\n  \\(\\gal(\\Q(\\sqrt 2, \\sqrt 3, \\sqrt 5)/\\Q) \\cong (\\Z/2\\Z)^3\\).\n\\end{eg}\n\n\\begin{theorem}\n  There is a bijection\n  \\begin{align*}\n    \\left\\{\n    \\begin{tabular}{c}\n      finite subgroups \\\\\n      \\(\\Delta \\subseteq K^*/(K^*)^n\\)\n    \\end{tabular}\n    \\right\\}\n    &\\longleftrightarrow\n      \\left\\{\n      \\begin{tabular}{c}\n        finite abelian extensions \\\\\n        \\(L/K\\) of exponent \\\\\n        dividing \\(n\\)\n      \\end{tabular}\n    \\right\\} \\\\\n    \\Delta &\\mapsto K(\\sqrt[n] \\Delta) \\\\\n    \\frac{(L^*)^n \\cap K^*}{(K^*)^n} &\\mapsfrom L\n  \\end{align*}\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(\\Delta \\subseteq K^*/(K^*)^n\\) be a finite subgroup. Let \\(L = K(\\sqrt[n]\\Delta)\\) and \\(\\Delta' = \\frac{(L^*)^n \\cap K^*}{(K^*)^n}\\). Clearly \\(\\Delta \\subseteq \\Delta'\\). To show equality,\n  \\[\n    L = K(\\sqrt[n]\\Delta) \\subseteq K(\\sqrt[n]{\\Delta'}) \\subseteq L\n  \\]\n  so \\(K(\\sqrt[n]\\Delta) = K(\\sqrt[n]{\\Delta'})\\) so \\(|\\Delta| = |\\Delta'|\\) by the lemma. Thus equality.\n\n  Conversely let \\(L/K\\) be a finite abelian extension of exponent dividing \\(n\\). Let \\(\\Delta\\) be as defined in the statement. Then \\(K(\\sqrt[n]{\\Delta}) \\subseteq L\\). We aim to show equality by showing \\([K(\\sqrt[n]{\\Delta}) : K] = [L : K]\\). Let \\(G = \\gal(L/K)\\). The Kummer pairing defines an injective group homomorphism \\(\\Delta \\embed \\Hom(G, \\mu_n)\\). Claim this is surjective.\n\n  \\begin{proof}\n    Let \\(\\chi: G \\to \\mu_n\\) be a group homomorphism. From basic Galois theory distinct automorphisms are linearly independent so exists \\(a \\in L\\) such that \\(y = \\sum_{\\tau \\in G} \\chi(\\tau)^{-1} \\tau(a) \\neq 0\\). Let \\(\\sigma \\in G\\). Then\n    \\[\n      \\sigma(y)\n      = \\sum_{\\tau \\in G} \\chi(\\tau)^{-1} \\sigma \\tau(a)\n      = \\sum_{\\tau \\in G} \\chi(\\sigma^{-1} \\tau)^{-1} \\tau(a)\n      = \\chi(\\sigma) y\n    \\]\n    Thus \\(\\sigma(y^n) = y^n\\) for all \\(\\sigma \\in G\\) so \\(x = y^n \\in K^* \\cap (L^*)^n\\). Then \\(x \\in \\Delta\\) and \\(\\chi: \\sigma \\mapsto \\frac{\\sigma(y)}{y} = \\frac{\\sigma \\sqrt[n]{x}}{\\sqrt[n]{x}}\\).\n  \\end{proof}\n\n  Now\n  \\[\n    [K(\\sqrt[n]{\\Delta}) : K] = |\\Delta| = |\\Hom(G, \\mu_n)| = |G| = [L : K].\n  \\]\n\\end{proof}\n\n\\begin{proposition}\n  Let \\(K\\) be a number field and \\(\\mu_n \\subseteq K\\). Let \\(S\\) be a finite set of primes of \\(K\\). There are only finitely many extensions \\(L/K\\) such that\n  \\begin{enumerate}\n  \\item \\(L/K\\) is abelian of exponent dividing \\(n\\).\n  \\item \\(L/K\\) is unramified at all primes \\(\\mathfrak p \\notin S\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n  By 11.2 \\(L = K(\\sqrt[n]{\\Delta})\\) for some finite subgroup \\(\\Delta \\subseteq K^*/(K^*)^n\\). Let \\(\\mathfrak p\\) be a prime of \\(K\\) with\n  \\[\n    \\mathfrak p \\O_L = \\mathfrak P_1^{e_1} \\cdots \\mathfrak P_r^{e_r}\n  \\]\n  for distinct primes \\(\\mathfrak P_i\\) of \\(L\\). If \\(x \\in K^*\\) represents an element of \\(\\Delta\\) then\n  \\[\n    n v_{\\mathfrak P_i}(\\sqrt[n]{x}) = v_{\\mathfrak P_i}(x) = e_i v_{\\mathfrak p}(x).\n  \\]\n  If \\(\\mathfrak p \\notin S\\) then \\(e_i = 1\\) for all \\(i\\) so \\(v_{\\mathfrak p}(x) = 0 \\pmod n\\). Thus \\(\\Delta \\subseteq K(S, n)\\) where\n  \\[\n    K(S, n) = \\{x \\in K^*/(K^*)^n: v_{\\mathfrak p}(x) = 0 \\pmod n \\text{ for all } \\mathfrak p \\notin S\\}.\n  \\]\n\n  \\begin{lemma}\n    \\(K(S, n)\\) is finite.\n  \\end{lemma}\n\n  \\begin{proof}\n    The map\n    \\begin{align*}\n      K(S, n) &\\to (\\Z/n\\Z)^{|S|} \\\\\n      x &\\mapsto (v_{\\mathfrak p}(x) \\pmod n)_{\\mathfrak p \\in S}\n    \\end{align*}\n    is a group homomorphism with kernel \\(K(\\emptyset, n)\\) so suffice to prove the lemma with \\(S = \\emptyset\\). If \\(x \\in K^*\\) represents an element of \\(K(\\emptyset, n)\\) then \\((x) = \\mathfrak a^n\\) for some ideal \\(\\mathfrak a\\). There is an exact sequence\n    \\[\n      \\begin{tikzcd}\n        0 \\ar[r] & \\O_K^*/(\\O_K^*)^n \\ar[r] & K(\\emptyset, n) \\ar[r] & \\Cl_K[n] \\ar[r] & 0\n      \\end{tikzcd}\n    \\]\n    From algebraic number theory \\(|\\Cl_K| < \\infty\\) and \\(\\O_K^*\\) is finitely generated (Dirichlet's unit theorem) so \\(K(\\emptyset, n)\\) is finite.\n  \\end{proof}\n\\end{proof}\n\n\\section{Elliptic curves over number fields II}\n\nMordell-Weil Theorem\n\n\\begin{lemma}\n  Let \\(E/K\\) be an elliptic curve and \\(L/K\\) be a finite Galois extension. Then the map \\(\\frac{E(K)}{n E(K)} \\to \\frac{E(L)}{n E(L)}\\) has finite kernel.\n\\end{lemma}\n\n\\begin{proof}\n  For each element in the kernel we pick a coset representative \\(P \\in E(K)\\) and then exists \\(Q \\in E(L)\\) such that \\(n Q = P\\). \\(\\gal(L/K)\\) is finite and \\(E[n]\\) is finite so there are only finitely many possibilities for the map \\(\\gal(L/K) \\to E[n], \\sigma \\mapsto \\sigma Q - Q\\). But if \\(P_1, P_2 \\in E(K)\\) with \\(P_i = nQ_i\\) and \\(\\sigma Q_1 - Q_2 = \\sigma Q_2 - Q_2\\) for all \\(\\sigma \\in \\gal(L/K)\\) then \\(\\sigma(Q_1 - Q_2) = Q_2 - Q_2\\) so \\(Q_1 - Q_2 \\in E(K)\\), and hence \\(P_1 - P_2 \\in n E(K)\\).\n\\end{proof}\n\n\\begin{theorem}[weak Mordell-Weil theorem]\\index{Mordell-Weil theorem}\n  Let \\(K\\) be a number field and \\(E/K\\) an elliptic curve. Then for \\(n \\geq 2\\), \\(|\\frac{E(K)}{n E(K)}| < \\infty\\).\n\\end{theorem}\n\n\\begin{proof}\n  By lemma wlog we can assume \\(\\mu_n \\subseteq K\\) and \\(E[n] \\subseteq E(K)\\). Let \\(S = \\{\\mathfrak p \\divides n\\} \\cup \\{\\text{primes of bad reduction for } E\\}\\). For each \\(P \\in E(K)\\) the extension \\(K([n]^{-1}P)/K\\) is unramified outside \\(S\\) by theorem 9.9.\n\n  Let \\(Q \\in [n]^{-1}P\\). Since \\(E[n] \\subseteq E(K)\\), \\(K(Q) = K([n]^{-1}P)\\) is a Galois extension of \\(K\\). Define\n  \\begin{align*}\n    \\gal(K(Q)/K) &\\to E[n] \\cong (\\Z/n\\Z)^2 \\\\\n    \\sigma &\\mapsto \\sigma Q - Q\n  \\end{align*}\n  Check this is a homomorphism:\n  \\[\n    \\sigma\\tau Q - Q = \\sigma(\\tau Q - Q) + \\sigma Q - Q = (\\tau Q - Q) + (\\sigma Q - Q).\n  \\]\n  It is injective as \\(\\sigma Q = Q\\) implies \\(\\sigma\\) fixes \\(K(Q)\\) so \\(\\sigma = 1\\). Thus \\(K(Q)/K\\) is an abelian extension of exponent dividing \\(n\\), unramified outside \\(S\\). By 11.3 only there are only finitely many possibilities for \\(K(Q)\\). Let \\(L\\) be the composite of all such extensions (i.e.\\ for all \\(P \\in E(K)\\)). Then \\(L/K\\) is finite (and Galois) and \\(\\frac{E(K)}{nE(K)} \\to \\frac{E(L)}{nE(L)}\\) is the zero map. Apply lemma 12.1.\n\\end{proof}\n\n\\begin{remark}\n  If \\(K = \\R\\) or \\(\\C\\) or \\([K : \\Q_p] < \\infty\\) then \\(|\\frac{E(K)}{nE(K)}| < \\infty\\), yet \\(E(K)\\) is not finitely generated (even uncountable).\n\\end{remark}\n\n\\begin{fact}\n  Let \\(E/K\\) be a elliptic curve over a number field. Then there exists a quadratic form, called \\emph{canonical height}\\index{canonical height} \\(\\hat h: E(K) \\to \\R_{\\geq 0}\\) with the property that for any \\(B \\geq 0\\), \\(\\{P \\in E(K): \\hat h(P) \\leq B\\}\\) is finite.\n\\end{fact}\n\n\\begin{theorem}[Mordell-Weil]\\index{Mordell-Weil theorem}\n  Let \\(K\\) be a number field and \\(E/K\\) an elliptic curve. Then \\(E(K)\\) is a finitely generated abelian group.\n\\end{theorem}\n\n\\begin{proof}\n  Fix an integer \\(n \\geq 2\\). Weak Mordell-Weil implies that \\(|\\frac{E(K)}{nE(K)}| < \\infty\\). Pick coset representatives \\(P_1, \\dots, P_m\\). Let \\(\\Sigma = \\{P \\in E(K): \\hat h(P) \\leq \\max_{1 \\leq i \\leq n} \\hat h(P_i)\\}\\). Claim \\(\\Sigma\\) generates \\(E(K)\\).\n\n  \\begin{proof}\n    Suppose not. Then exists \\(P \\in E(K) \\setminus \\{\\text{subgroup generated by }\\Sigma\\}\\) of minimal height. Then \\(P = P_i + nQ\\) for some \\(1 \\leq i \\leq m\\) where \\(Q \\in E(K) \\setminus \\{\\text{subgroup generated by } \\Sigma\\}\\). Then \\(\\hat h(P) \\leq \\hat h(Q)\\). Then\n    \\begin{align*}\n      4 \\hat h(P)\n      &\\leq 4 \\hat h(Q) \\\\\n      &\\leq n^2 \\hat(Q) \\\\\n      &= \\hat h(nQ) \\\\\n      &= \\hat h(P - P_2) \\\\\n      &\\leq \\hat h(P - P_i) + \\hat h(P + P_i) \\\\\n      &= 2 \\hat h(P) + 2 \\hat h(P_1) \\text{ parallalogram law}\n    \\end{align*}\n    so \\(\\hat h(P) \\in \\hat h(P_i)\\) so \\(P \\in \\Sigma\\), contradiction.\n  \\end{proof}\n  \\(\\Sigma\\) is finite so done.\n\\end{proof}\n\n\\section{Heights}\n\nFor simplicity take \\(K = \\Q\\). Write \\(P \\in \\P^n(\\Q)\\) as \\(P = (a_1: \\cdots: a_n)\\) where \\(a_0, \\dots, a_n \\in \\Z, \\gcd(a_0, \\dots, a_n) = 1\\).\n\n\\begin{definition}[height]\\index{height}\n  We define the \\emph{height} of \\(P\\) to be\n  \\[\n    H(P) = \\max_{0 \\leq i \\leq n} |a_i|.\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  Let \\(f_1, f_2 \\in \\Q[X_1, X_2]\\) be coprime homogeneous polynomials of degree \\(d\\). Let\n  \\begin{align*}\n    F: \\P^1 &\\to \\P^1 \\\\\n    (x_1: x_2) &\\mapsto (f_1(x_1, x_2): f_2(x_1, x_2))\n  \\end{align*}\n  Then exists \\(c_1, c_2 > 0\\) such that\n  \\[\n    c_1 H(P)^d \\leq H(F(P)) \\leq c_2 H(P)^d\n  \\]\n  for all \\(P \\in \\P^1(\\Q)\\).\n\\end{lemma}\n\n\\begin{proof}\n  wlog \\(f_1, f_2 \\in \\Z[X_1, X_2]\\). We prove the upper bound first. Write \\(P = (a: b)\\) where \\(a, b \\in \\Z\\) coprime. Then\n  \\[\n    H(F(P))\n    \\leq \\max(|f_1(a, b)|, |f_2(a, b)|)\n    \\leq c_2 \\max(|a|^d, |b|^d)\n    = c_2 H(P)^d\n  \\]\n  where \\(c_2\\) is the maximum of the sum of absolute values of coefficients of \\(f_1\\) and \\(f_2\\).\n\n  For the lower bound, we claim exists \\(g_{ij} \\in \\Z[X_1, X_2]\\) homogeneous of degree \\(d - 1\\) and \\(\\kappa \\in \\Z_{> 0}\\) such that\n  \\[\n    \\sum_{j = 1}^2 g_{ij}f_j = \\kappa  X_i^{2d - 1}.\n    \\tag{\\(\\dagger\\)}\n  \\]\n  \\begin{proof}\n    Indeed running Euclid's algorihm on \\(f_1(X, 1)\\) and \\(f_2(X, 1)\\) gives \\(r, s \\in \\Q[X]\\) such that\n    \\[\n      r(X) f_1(X, 1) + s(X) f_2(X, 1) = 1.\n    \\]\n    Homgogenising and clearing denominators gives (\\(\\dagger\\)) for \\(i = 2\\) Likewise for \\(i = 1\\).\n  \\end{proof}\n\n  Write \\(P = (a_1: a_2)\\) where \\(a_1, a_2 \\in \\Z\\) coprime. Then (\\(\\dagger\\)) gives\n  \\[\n    \\sum_{j = 1}^w g_{ij}(a_i, a_2) f_j(a_1, a_2) = \\kappa a_i^{2d - 1}.\n  \\]\n  Thus \\(\\gcd(f_1(a_1, a_2), f_2(a_1, a_2))\\) divides \\(\\gcd(\\kappa a_1^{2d - 1}, \\kappa a_2^{2d - 1}) = \\kappa\\). But also\n  \\[\n    |\\kappa a_i^{2d - 1}| \\leq \\underbrace{\\max_{j = 1, 2} |f_j (a_i, a_2)|}_{\\leq \\kappa H(F(P))} \\underbrace{\\sum_{j = 1}^2 |g_{ij}(a_1, a_2)|}_{\\leq \\gamma_i H(P)^{d - 1}}.\n  \\]\n  where \\(\\gamma_i\\) is the sum over \\(j\\) of absolute values of coefficients of \\(g_{ij}\\). Thus\n  \\[\n    |a_i|^{2d - 1} \\leq \\gamma_i H(F(P)) H(P)^{d - 1}\n  \\]\n  for \\(i = 1, 2\\). Thus\n  \\[\n    H(P)^{2d - 1} \\leq \\max(\\gamma_1, \\gamma_2) H(F(P)) H(P)^{d - 1}.\n  \\]\n  Take \\(c_1 = \\max(\\gamma_1, \\gamma_2)^{-1}\\).\n\\end{proof}\n\n\\begin{notation}\n  For \\(x \\in \\Q\\) we define \\(H(x) = H((x: 1)) = \\max(|u|, |v|)\\) where \\(x = \\frac{u}{v}\\) for \\(u, v \\in \\Z\\) coprime.\n\\end{notation}\n\nLet \\(E/\\Q\\) be an elliptic curve of the form \\(y^2 = x^3 + ax + b\\).\n\n\\begin{definition}[height]\\index{height}\n  The \\emph{height} is defined as the map\n  \\begin{align*}\n    H: E(\\Q) &\\to \\R_{\\geq 1} \\\\\n    P &\\mapsto\n        \\begin{cases}\n          H(x) & P = (x, y) \\\\\n          1 & P = 0_E\n        \\end{cases}\n  \\end{align*}\n\n  We define the \\emph{logarithmic height} to be \\(h = \\log H\\).\n\\end{definition}\n\n\\begin{lemma}\n  Let \\(E, E'\\) be elliptic curves over \\(\\Q\\), \\(\\phi: E \\to E'\\) an isogeny defined over \\(\\Q\\). Then exists \\(c > 0\\) such that\n  \\[\n    |h(\\phi(P)) - \\deg(\\phi) h(P)| \\leq c\n  \\]\n  for all \\(P \\in E(\\Q)\\). Note that \\(c\\) depends on \\(E, E'\\) and \\(\\phi\\).\n\\end{lemma}\n\n\\begin{proof}\n  Recall (Lemma 5.4) we have commutative diagram\n  \\[\n    \\begin{tikzcd}\n      E \\ar[r, \"\\phi\"] \\ar[d, \"x\"] & E' \\ar[d, \"x\"] \\\\\n      \\P^1 \\ar[r, \"\\xi\"] & \\P^1\n    \\end{tikzcd}\n  \\]\n  and \\(\\deg \\phi = \\deg \\xi = d\\), say. Lemma 13.1 says that there exist \\(c_1, c_2 > 0\\) such that\n  \\[\n    c_1 H(P)^d \\leq H(\\phi(P)) \\leq c_2 H(P)^d\n  \\]\n  for all \\(P \\in E(\\Q)\\). Taking logs gives\n  \\[\n    |h(\\phi(P)) - d h(P)| \\leq \\max(\\log c_2, -\\log c_1).\n  \\]\n\\end{proof}\n\n\\begin{eg}\n  Let \\(\\phi = [2]: E \\to E\\). Then exists \\(c > 0\\) such that\n  \\[\n    |h(2P) - 4h(P)| < c\n  \\]\n  for all \\(P \\in E(\\Q)\\).\n\\end{eg}\n\n\\begin{definition}[canonical height]\\index{canonical height}\n  The \\emph{canonical height} is\n  \\[\n    \\hat h(P) = \\lim_{n \\to \\infty} \\frac{1}{4^n} h(2^nP).\n  \\]\n\\end{definition}\n\nCheck convergence: for \\(m \\geq n\\),\n\\begin{align*}\n  |\\frac{1}{4^m} h(2^m P) - \\frac{1}{4^n} h(2^n P)|\n  &\\leq \\sum_{r = n}^{m - 1} |\\frac{1}{4^{r + 1}} h(2^{r + 1}P) - \\frac{1}{4^r} h(2^r P)| \\\\\n  &\\leq \\sum_{r = n}^{m - 1} \\frac{1}{4^{r + 1}} |h(2^{r + 1}P) - 4h(2^r P)| \\\\\n  &\\leq c \\sum_{r = n}^\\infty \\frac{1}{4^{r + 1}} \\\\\n  &\\to 0\n\\end{align*}\nas \\(n \\to \\infty\\) so the sequence is Cauchy so \\(\\hat h(P)\\) exists.\n\n\\begin{lemma}\n  \\(|h(P) - \\hat h(P)|\\) is bounded for \\(P \\in E(\\Q)\\).\n\\end{lemma}\n\n\\begin{proof}\n  Put \\(n = 0\\) in the above calcultion to give\n  \\[\n    |\\frac{1}{4^m} h(2^m P) - h(P)| \\leq \\frac{c}{3}.\n  \\]\n  Take limit as \\(m \\to \\infty\\).\n\\end{proof}\n\n\\begin{corollary}\n  For any \\(B > 0\\), \\(\\# \\{P \\in E(\\Q): \\hat h(P) < B\\} < \\infty\\).\n\\end{corollary}\n\n\\begin{proof}\n  By the lemma \\(\\hat h(P)\\) is bounded implies \\(h(P)\\) is bounded, so only finitely many possibilities for \\(x\\). Each \\(x\\) leaves at most 2 choices for \\(y\\).\n\\end{proof}\n\n\\begin{lemma}\n  Suppose \\(\\phi: E \\to E'\\) is an isogeny defined over \\(\\Q\\). Then\n  \\[\n    \\hat h(\\phi P) = (\\deg \\phi) \\hat h(P)\n  \\]\n  for all \\(P \\in E(\\Q)\\).\n\\end{lemma}\n\n\\begin{proof}\n  By lemma 13.2 exists \\(c > 0\\) such that\n  \\[\n    |h(\\phi P) - (\\deg \\phi) h(P)| < c\n  \\]\n  for all \\(P \\in E(\\Q)\\). Replace \\(P\\) by \\(2^nP\\), divide by \\(4^n\\) and take limit as \\(n \\to \\infty\\).\n\\end{proof}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item The case \\(\\deg \\phi = 1\\) shows that \\(\\hat h\\), unlike \\(h\\), is independent of the choice of Weierstrass equation.\n  \\item Taking \\(\\phi = [n]: E \\to E\\) gives \\(\\hat h(nP) = n^2 \\hat h(P)\\) for all \\(P \\in E(\\Q)\\).\n  \\end{enumerate}\n\\end{remark}\n\n(Going to prove \\(\\hat h\\) is a quadratic form by showing that it satisfies the parallelogram law).\n\n\\begin{lemma}\n  Let \\(E/\\Q\\) be an ellitpic curve. There exists \\(c > 0\\) such that\n  \\[\n    H(P + Q) H(P - Q) \\leq c H(P)^2 H(Q)^2\n  \\]\n  for all \\(P, Q, P + Q, P - Q \\ne 0_E\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(E\\) have Weierstrass equation \\(y^2 = x^3 + ax + b\\), \\(a, b \\in \\Z\\). Let \\(P, Q, P + Q, P - Q\\) has \\(x\\) coordinates \\(x_1, \\dots, x_4\\). By lemma 5.8 there exist \\(W_0, W_1, W_2 \\in \\Z[x_1, x_2]\\) of degree \\(\\leq 2\\) in \\(x_1\\) and degree \\(\\leq 2\\) in \\(x_2\\) such that\n  \\[\n    (1: x_3 + x_4: x_3x_4) = (W_0: W_1: W_2)\n  \\]\n  and\n  \\(W_0 = (x_1 - x_2)^2\\). Write \\(x_i = \\frac{r_i}{s_i}\\) where \\(r_i, s_i \\in \\Z\\) coprime. Then we get\n  \\[\n    (s_3s_4: r_3s_4 + r_4s_3: r_3r_4) = ((r_1s_2 - r_2s_1)^2: \\cdots ).\n  \\]\n  So\n  \\begin{align*}\n    H(P + Q) H(P - Q)\n    &= \\max(|r_3|, |s_3|) \\max(|r_4|, |s_4|) \\\\\n    &\\leq 2 \\max(|s_3s_4|, |r_3s_4 + r_4s_3|, |r_3r_4|) \\\\\n    &\\leq 2 \\max(|r_1s_2 - r_2s_1|, \\cdots) \\\\\n    &\\leq c H(P)^2 H(Q)^2\n  \\end{align*}\n  where \\(c\\) depends on \\(E\\) but not on \\(P\\) and \\(Q\\).\n\\end{proof}\n\n\\begin{theorem}\n  \\(\\hat h: E(\\Q) \\to \\R_{\\geq 0}\\) is a quadratic form.\n\\end{theorem}\n\n\\begin{proof}\n  Lemma 13.6 and \\(|h(2P) - 4h(P)|\\) bounded implies that\n  \\[\n    h(P + Q) + h(P - Q) \\leq 2 h(P) + 2h(Q) + c\n  \\]\n  for \\(P, Q \\in E(\\Q)\\) (there are several special cases to check). Replacing \\(P, Q\\) by \\(2^n P, 2^n Q\\), dividing by \\(4^n\\) and taking limit \\(n \\to \\infty\\) gives\n  \\[\n    \\hat h(P + Q) + \\hat h(P - Q) \\leq 2 \\hat h(P) + 2 \\hat h(Q).\n  \\]\n  Replacing \\(P, Q\\) by \\(P + Q, P - Q\\) and writing \\(\\hat h(2P) = 4 \\hat h(P)\\) gives the reverse inequality. Thus \\(\\hat h\\) satisfies the parallelogram law and \\(\\hat h\\) is a quadratic form.\n\\end{proof}\n\n\\begin{remark}\n  For \\(K\\) a number field, \\(P = (a_0: \\cdots :a_n) \\in \\P^n(K)\\), define\n  \\[\n    H(P) = \\prod_v \\max_{0 \\leq i \\leq n} |a_i|_v\n  \\]\n  where the product is over all places \\(v\\) and the absolute values \\(|\\cdot|_v\\) are normalised such that \\(\\prod_v |\\lambda|_v = 1\\) for all \\(\\lambda \\in K^*\\). Then all results in this section generalises to \\(K\\).\n\\end{remark}\n\n\\section{Dual isogenies \\& Weil pairing}\n\nLet \\(K\\) be a perfect field and \\(E/K\\) an elliptic field.\n\n\\begin{proposition}\n  Let \\(\\Phi \\subseteq E(\\overline K)\\) be a finite \\(\\gal(\\overline K/K)\\)-stable subgroup. Then exists an elliptic curve \\(E'/K\\) and a separable isogeny \\(\\phi: E \\to E'\\) defined over \\(K\\) with kernel \\(\\Phi\\) such that for every \\(\\psi: E \\to E''\\) with \\(\\psi \\subseteq \\ker \\psi\\) factors uniquely via \\(\\phi\\).\n  \\[\n    \\begin{tikzcd}\n      E \\ar[d, \"\\phi\"] \\ar[r, \"\\psi\"] & E'' \\\\\n      E' \\ar[ur, dotted, \"\\exists !\"']\n    \\end{tikzcd}\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  Omitted. See Silverman Chapter 3.\n\\end{proof}\n\n\\begin{proposition}\n  Let \\(\\phi: E \\to E'\\) be an isogeny of degree \\(n\\). Then exists a unique isogeny \\(\\hat \\phi: E' \\to E\\) such that \\(\\hat \\phi \\phi = [n]\\). \\(\\hat \\phi\\) is called the \\emph{dual isogeny}\\index{dual isogeny}.\n\\end{proposition}\n\n\\begin{proof}\n  Case \\(\\phi\\) separable: \\(|\\ker \\phi| = n\\) so \\(\\ker \\phi \\subseteq \\E[n]\\). Apply proposition 14.1 with \\(\\psi = [n]\\). The \\(\\phi\\) inseparble case is omitted (see Silverman. Suffice to check for Frobenius map). For uniqueness if \\(\\psi_1 \\phi = \\psi_2 \\phi = [n]\\) then \\((\\psi_1 - \\psi_2) \\phi = 0\\) so \\(\\psi_1 = \\psi_2\\) since \\(\\phi\\) nonconstant is surjective.\n\\end{proof}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item The relation of elliptic curves being isogenous is an equivalence relation.\n  \\item If \\(\\deg \\phi = n\\) then \\(\\deg [n] = n^2\\) implies that \\(\\deg \\hat \\phi = \\deg \\phi\\) and \\(\\widehat{[n]} = [n]\\).\n  \\item \\(\\phi \\hat \\phi \\phi = \\phi [n]_E = [n]_{E'} \\phi\\) implies that \\(\\phi \\hat \\phi = [n]_{E'}\\). In particular \\(\\hat{\\hat \\phi} = \\phi\\).\n  \\item If \\(E \\xrightarrow{\\psi} E' \\xrightarrow{\\phi} E''\\) then \\(\\widehat{\\phi\\psi} = \\hat \\psi \\hat \\phi\\).\n  \\item If \\(\\phi \\in \\End(E)\\) then by example sheet 2\n    \\[\n      \\phi^2 - (\\tr \\phi) \\phi + \\deg \\phi = 0\n    \\]\n    so\n    \\[\n      \\underbrace{([\\tr \\phi] - \\phi)}_{\\hat \\phi} \\phi = [\\deg \\phi]\n    \\]\n    and hence \\(\\tr \\phi = \\phi + \\hat \\phi\\).\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{lemma}\n  If \\(\\phi, \\psi \\in \\Hom(E, E')\\) then \\(\\widehat{\\phi + \\psi} = \\hat \\phi + \\hat \\psi\\).\n\\end{lemma}\n\n\\begin{proof}\n  If \\(E = E'\\) then this follows from \\(\\tr(\\phi + \\psi) = \\tr \\phi + \\tr \\psi\\). In general let \\(\\alpha: E' \\to E\\) be any isogeny (e.g.\\ \\(\\hat \\phi\\)). Thus\n  \\[\n    \\widehat{(\\alpha \\phi + \\alpha \\psi)} = \\widehat{\\alpha \\phi} + \\hat{\\alpha \\psi}\n  \\]\n  so\n  \\[\n    \\widehat{\\phi + \\psi} \\hat \\alpha = (\\hat \\phi + \\hat \\psi) \\hat \\alpha.\n  \\]\n\\end{proof}\n\n\\begin{remark}\n  In Silverman's book, he proves Lemma 14.3 first and uses this to show \\(\\deg: \\Hom(E, E') \\to \\Z\\) is a quadratic form.\n\\end{remark}\n\n\\begin{definition}[sum]\\index{sum}\n  The \\emph{sum map} is defined as\n  \\begin{align*}\n    \\Sum: \\Div(E) &\\to E \\\\\n    \\sum n_P(P) &\\mapsto \\sum n_P P\n  \\end{align*}\n  where LHS is a formal sum and RHS is sum using group law.\n\\end{definition}\n\nRecall that we have a group isomorphism \\(E \\to \\Pic^0(E), P \\mapsto [P - 0]\\). Thus \\(\\Sum D \\mapsto [D]\\) for all \\(D \\in \\Div^0(E)\\).\n\n\\begin{lemma}\n  Let \\(D \\in \\Div(E)\\). Then \\(D \\sim 0\\) if and only if \\(\\deg D = 0\\) and \\(\\Sum D = 0\\).\n\\end{lemma}\n\nLet \\(\\phi: E \\to E'\\) be an isogeny of degree \\(n\\) with dual isogeny \\(\\hat \\phi: E' \\to E\\). Assume \\(\\ch K \\ndivides n\\). We define the \\emph{Weil pairing}\\index{Weil pairing} \\(e_\\phi: E[\\phi] \\times E'[\\hat \\phi] \\to \\mu_n\\). Let \\(T \\in E'[\\hat \\phi]\\). Then \\(nT = 0\\) so exists \\(f \\in \\overline K(E')\\) such that \\(\\div(f) = n(T) - n(0)\\). Pick \\(T_0 \\in E(\\overline K)\\) with \\(\\phi(T_0) = T\\). Then\n\\[\n  \\phi^*(T) - \\phi^*(0) = \\sum_{P \\in E[\\phi]} (P + T_0) - \\sum_{P \\in E[\\phi]}(P)\n\\]\nhas sum \\(nT_0 = \\hat \\phi \\phi T_0 = \\hat \\phi T = 0\\) so exists \\(g \\in \\overline K(E)\\) such that \\(\\div(g) = \\phi^*(T) - \\phi^*(0)\\). Now \\(\\div(\\phi^*f) = \\phi^*(\\div f) = n(\\phi^*(T) - \\phi^*(0)) = \\div (g^n)\\) so \\(\\phi^* f = c g^n\\) for some \\(c \\in \\overline K^*\\). Recaling \\(f\\), wlog \\(c = 1\\), i.e.\\ \\(\\phi^*f = g^n\\).\n\nIf \\(S \\in E[\\phi]\\) then \\(\\tau_S^*(\\div g) = \\div g\\) so \\(\\div(\\tau_S^* g) = \\div g\\) so \\(\\tau_S^* g = \\zeta g\\) for some \\(\\zeta \\in \\overline K^*\\), i.e.\\ \\(\\zeta = \\frac{g(X + S)}{g(X)}\\) independent of choice of \\(X \\in E(\\overline K)\\). Now\n\\[\n  \\zeta^n = \\frac{g(X + S)^n}{g(X)^n} = \\frac{f(\\phi(X + S))}{f(\\phi(X))} = 1\n\\]\nsince \\(S \\in E[\\phi]\\). Thus \\(\\zeta \\in \\mu_n\\). Finally we define\n\\[\n  e_\\phi(S, T) = \\frac{g(X + S)}{g(X)}\n\\]\nfor any \\(X \\in E\\).\n\n\\begin{proposition}\n  \\(e_\\phi\\) is bliniear and nondegenerate.\n\\end{proposition}\n\n\\begin{proof}\n  Linearity in first argument:\n  \\[\n    e_\\phi(S_1 + S_2, T) = \\frac{g(X + S_1 + S_2)}{g(X + S_2)} \\frac{g(X + S_2)}{g(X)} = e_\\phi(S_1, T) e_\\phi(S_2, T).\n  \\]\n\n  Linearity in second argument: let \\(T_1, T_2 \\in E'[\\hat \\phi]\\). We can find \\(f_i, g_i\\) such that \\(\\div (f_i) = n(T_i) - n(0), \\phi^* f_i = g_n^n\\). There exists \\(h \\in \\overline K(E')\\) such that\n  \\[\n    \\div (h) = (T_1) + (T_2) - (T_1 + T_2) - (0).\n  \\]\n  Then put \\(f = \\frac{f_1f_2}{h^n}, g = \\frac{g_1g_2}{\\phi^*(h)}\\). Check\n  \\begin{align*}\n    \\div (f) &= n(T_1 + T_2) - n(0) \\\\\n    \\phi^*f &= \\frac{\\phi^*f_1 \\phi^* f_2}{(\\phi^* h)^n} = \\left(\\frac{g_1g_2}{\\phi^*(h)}\\right)^n = g^n\n  \\end{align*}\n  so\n  \\begin{align*}\n    e_\\phi(S, T_1 + T_2) &= \\frac{g(X + S)}{g(X)} \\\\\n                         &= \\frac{g_1(X + S)}{g_1(X)} \\frac{g_2(X + S)}{g_2(X)} \\underbrace{\\frac{h(\\phi(X))}{h(\\phi(X + S))}}_{= 1} \\\\\n                         &= e_\\phi(S, T_1) e_\\phi(S, T_2)\n  \\end{align*}\n\n  \\(e_\\phi\\) is nondegenerate: fix \\(T \\in E'[\\hat \\phi]\\). Suppose \\(e_\\phi(S, T) = 1\\) for all \\(S \\in E[\\phi]\\), so \\(\\tau_S^*g = g\\) for all \\(S \\in E[\\phi]\\). Thus\n  \\[\n    \\begin{tikzcd}\n      \\overline K(E) \\ar[d, dash] \\\\\n      \\phi^*\\overline K(E')\n    \\end{tikzcd}\n  \\]\n  is a Galois extension with group \\(E[\\phi]\\), with \\(S \\in E[\\phi]\\) acting as \\(\\tau_S^*\\). Thus \\(g = \\phi^*h\\) for some \\(h \\in \\overline K(E')^*\\). Thus \\(\\phi^*f = g^n = \\phi^* h^n\\) so \\(f = h^n\\). Thus \\(\\div h = (T) - (0)\\) so \\(T = 0_E\\).\n\n  For the other direction, we've show \\(E'[\\hat \\phi] \\embed \\Hom(E[\\phi], \\mu_n)\\). It is an isomorphism by counting.\n\\end{proof}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(E, E'\\) and \\(\\phi\\) are defined over \\(K\\) then \\(e_\\phi\\) is Galois equivariant, i.e.\\ \\(e_\\phi(\\sigma S, \\sigma T) = \\sigma(e_\\phi(S, T))\\).\n  \\item Taking \\(\\phi = [n]: E \\to E\\) (so \\(\\hat \\phi = [n]\\)) gives \\(e_n: E[n] \\times E[n] \\to \\mu_{n^2} = \\mu_n\\) since \\(e_n\\) is bilinear.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{corollary}\n  If \\(E[n] \\subseteq E(K)\\) then \\(\\mu_n \\subseteq K\\).\n\\end{corollary}\n\n\\begin{proof}\n  We claim exists \\(S, T \\in E[n]\\) such that \\(e_n(S, T)\\) is a primitive \\(n\\)th root of unit, say \\(\\zeta_n\\). We pick \\(T \\in E[n]\\) of order \\(n\\). The group homomorphism \\(E[n] \\to \\mu_n, S \\mapsto e_n(S, T)\\) has image \\(\\mu_d\\) for some \\(d \\divides n\\). Then \\(e_n(S, dT) = 1\\) for all \\(S \\in E[n]\\). By nondegeneracy \\(dT = 0\\) so \\(d = n\\), proving the claim. To show \\(\\zeta_n \\in K\\) we use Galois equivariance: for all \\(\\sigma \\in \\gal(\\overline K/K)\\),\n  \\[\n    \\sigma(\\zeta_n) \\sigma(e_n(S, T)) = e_n(\\sigma S, \\sigma T) = e_n(S, T) = \\zeta_n\n  \\]\n  so \\(\\zeta_n \\in K\\).\n\\end{proof}\n\n\\begin{eg}\n  There does not exist \\(E/\\Q\\) with \\(E(\\Q)_{\\mathrm{tor}} \\cong (\\Z/3\\Z)^2\\).\n\\end{eg}\n\n\\begin{remark}\n  In fact \\(e_n\\) is alternating, i.e.\\ \\(e_n(T, T) = 1\\) for all \\(T \\in E[n]\\). By expanding \\(e_n(S + T, S + T)\\), we have \\(e_n\\) alternating: \\(e_n(S, T) = e_n(T, S)^{-1}\\).\n\\end{remark}\n\n\\section{Galois cohomology}\n\nLet \\(G\\) be a group and \\(A\\) a \\(G\\)-module, i.e.\\ an abelian group with an action of \\(G\\) via group homomorphism (in other words a \\(\\Z[G]\\)-module). We begin with a very practical definition of group cohomology (or more precisely, \\(H^0\\) and \\(H^1\\)).\n\n\\begin{definition}[group cohomology]\\index{group cohomology}\n  We define\n  \\[\n    H^0(G, A) = A^G = \\{a \\in A: \\sigma(a) = a \\text{ for all } \\sigma \\in G\\}.\n  \\]\n  We define the first cochains, cocyles and coboundaries \n  \\begin{align*}\n    C^1(G, A) &= \\{G \\to A\\} \\\\\n    Z^1(G, A) &= \\{(a_\\sigma)_{\\sigma \\in G}: a_{\\sigma\\tau} = \\sigma(a_\\tau) + a_\\sigma\\} \\\\\n    B^1(G, A) &= \\{(\\sigma b - b)_{\\sigma \\in G}: b \\in A\\}\n  \\end{align*}\n  Then we define\n  \\[\n    H^1(G, A) = \\frac{Z^1(G, A)}{B^1(G, A)}.\n  \\]\n\\end{definition}\n\n\\begin{remark}\n  If \\(G\\) acts trivially on \\(A\\) then \\(H^1(G, A) = \\Hom(G, A)\\).\n\\end{remark}\n\nWe quote some elementary results from homological algebra:\n\n\\begin{theorem}\n  A short exact sequence of \\(G\\)-modules\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & A \\ar[r, \"\\phi\"] & B \\ar[r, \"\\psi\"] & C \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  gives rise to a long exact sequence of abelian groups\n  \\[\n    \\begin{tikzcd}[column sep=small]\n      0 \\ar[r] & A^G \\ar[r] & B^G \\ar[r] & C^G \\ar[r] & H^1(G, A) \\ar[r] & H^1(G, B) \\ar[r] & H^1(G, C)\n    \\end{tikzcd}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Omitted. We note the definition of \\(\\delta: C^G \\to H^1(G, A)\\): given \\(c \\in C^G\\), exists \\(b \\in B\\) such that \\(\\psi(b) = c\\). Then\n  \\[\n    \\tau(\\sigma b - b) = \\sigma c - c = 0\n  \\]\n  for all \\(\\sigma \\in G\\) so \\(\\sigma b - b = \\phi(a_\\sigma)\\) for some \\(a_\\sigma \\in A\\). Can show \\((a_\\sigma)_{\\sigma \\in G} \\in Z^1(G, A)\\). We define \\(\\delta(c)\\) to be the class of \\((a_\\sigma)_{\\sigma \\in G}\\) in \\(H^1(G, A)\\).\n\\end{proof}\n\n\\begin{theorem}\n  Let \\(A\\) be a \\(G\\)-module and \\(H \\normal G\\) be a normal subgroup. Then there is an \\emph{inflation-restriction exact sequence}\\index{inflation-restriciton exact sequence}\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H^1(G/H, A^H) \\ar[r, \"\\mathrm{inf}\"] & H^1(G, A) \\ar[r, \"\\mathrm{res}\"] & H^1(H, A)\n    \\end{tikzcd}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\nLet \\(K\\) be a perfect field. Then \\(\\gal(\\overline K/K)\\) is a topological group with basis of open subgroups \\(\\gal(\\overline K/L)\\) for \\([L: K] < \\infty\\). If \\(G = \\gal(\\overline K/K)\\) we modify the definition of \\(H^1(G, A)\\) by insisting\n\\begin{enumerate}\n\\item the stabiliser of each \\(a \\in A\\) is an open subgroup of \\(G\\),\n\\item all cochains \\(G \\to A\\) are continuous, where \\(A\\) is given the discrete topology.\n\\end{enumerate}\nThen\n\\[\n  H^1(\\gal(\\overline K/K), A) = \\varinjlim_{L/K \\text{ finite Galois}} H^1(\\gal(L/K), A^{\\gal(\\overline K/L)}).\n\\]\nHere the direct limit is with respect to inflation maps.\n\n\\begin{theorem}[Hilbert theorem 90]\\index{Hilbert theorem 90}\n  Suppose \\(L/K\\) is a finite Galois extension. Then\n  \\[\n    H^1(\\gal(L/K), L^*) = 0.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(G = \\gal(L/K)\\) and \\((a_\\sigma)_{\\sigma \\in G} \\in Z^1(G, L^*)\\). Distinct automorphisms are linearly independent so exists \\(y\\) such that\n  \\[\n    x = \\sum_{\\tau \\in G} a_\\tau^{-1} \\tau(y) \\neq 0.\n  \\]\n  For \\(\\sigma \\in G\\),\n  \\[\n    \\sigma(x) = \\sum_{\\tau \\in G} \\sigma(a_\\tau)^{-1} \\sigma\\tau(y)\n    = a_\\sigma \\sum_{\\tau \\in G} a_{\\sigma\\tau}^{-1} \\sigma\\tau(y)\n    = a_\\sigma x.\n  \\]\n  Thus \\(a_\\sigma = \\frac{\\sigma(x)}{x}\\) so \\((a_\\sigma)_{\\sigma \\in G} \\in B^1(G, L^*)\\). Thus \\(H^1(G, L^*) = 0\\).\n\\end{proof}\n\n\\begin{corollary}\n  \\(H^1(\\gal(\\overline K/K), \\overline K^*) = 0\\).\n\\end{corollary}\n\nAs an application, assume \\(\\ch K \\ndivides n\\). There is a short exact sequence of \\(\\gal(\\overline K/K)\\)-modules\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\mu_n \\ar[r] & \\overline K^* \\ar[r, \"x \\mapsto x^n\"] & \\overline K^* \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nso we have a long exact sequence\n\\[\n  \\begin{tikzcd}\n    K^* \\ar[r, \"x \\mapsto x^n\"] & K^* \\ar[r] & H^1(\\gal(\\overline K/K), \\mu_n) \\ar[r] & H^1(\\gal(\\overline K/K), \\overline K^*) = 0\n  \\end{tikzcd}\n\\]\nso\n\\[\n  H^1(\\gal(\\overline K/K), \\mu_n) \\cong K^*/(K^*)^n.\n\\]\nNow let's revisit Kummer theory. If \\(\\mu_n \\subseteq K\\) then\n\\[\n  \\Hom(\\gal(\\overline K/K), \\mu_n) \\cong K^*/(K^*)^n.\n\\]\nFinite subgroups of LHS are of the form \\(\\Hom(\\gal(L/K), \\mu_n)\\) for \\(L/K\\) a finite abelian extension of exponent dividing \\(n\\). Thus we get another proof of Theorem 11.2.\n\n\\begin{remark}\n  Every continuous group homomorphism \\(\\chi: \\gal(\\overline K/K) \\to \\mu_n\\) factorises uniquely as\n  \\[\n    \\gal(\\overline K/K) \\surj \\gal(L/K) \\embed \\mu_n\n  \\]\n  for \\(L\\) the fixed field of \\(\\ker \\chi\\).\n\\end{remark}\n\n\\begin{notation}\n  Since we are dealing with Galois cohomology, write \\(H^1(K, -)\\) for \\(H^1(\\gal(\\overline K/K), -)\\).\n\\end{notation}\n\nLet \\(\\phi: E \\to E'\\) be an isogeny of elliptic curves over \\(K\\). There is a short exact sequence of \\(\\gal(\\overline K/K)\\)-modules\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & E[\\phi] \\ar[r] & E \\ar[r, \"\\phi\"] & E' \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nwhich induces a long exact seqeucne\n\\[\n  \\begin{tikzcd}\n    E(K) \\ar[r, \"\\phi\"] & E'(K) \\ar[r, \"\\delta\"] & H^1(K, E[\\phi]) \\ar[r] & H^1(K, E) \\ar[r, \"\\phi_*\"] & H^1(K, E')\n  \\end{tikzcd}\n\\]\nfrom which we get a short exact sequence\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\frac{E'(K)}{\\phi E(K)} \\ar[r] & H^1(K, E[\\phi]) \\ar[r] & H^1(K, E)[\\phi_*] \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nNow take \\(K\\) a number field. For each place \\(v\\) of \\(K\\) we fix an embedding \\(\\overline K \\subseteq \\overline K_v\\). Then \\(\\gal(\\overline K_V/K_V) \\subseteq \\gal(\\overline K/K)\\). We get a commutative diagram\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\frac{E'(K)}{\\phi E(K)} \\ar[r] \\ar[d] & H^1(K, E[\\phi]) \\ar[r] \\ar[d, \"\\mathrm{res}_V\"] & H^1(K, E)[\\phi_*] \\ar[r] \\ar[d, \"\\mathrm{res}_V\"] & 0 \\\\\n    0 \\ar[r] & \\frac{E'(K_v)}{\\phi E(K_v)} \\ar[r] & H^1(K_v, E[\\phi]) \\ar[r] & H^1(K_v, E)[\\phi_*] \\ar[r] & 0\n  \\end{tikzcd}\n\\]\n\n\\begin{definition}[Selmer group]\\index{Selmer group}\n  The \\emph{\\(\\phi\\)-Selmer group} \\(S^{(\\phi)}(E/K)\\) is the kernel of the dotted arrow in\n  \\[\n    \\begin{tikzcd}[column sep=scriptsize]\n      0 \\ar[r] & \\frac{E'(K)}{\\phi E(K)} \\ar[r] \\ar[d] & H^1(K, E[\\phi]) \\ar[r] \\ar[d, \"\\mathrm{res}_V\"] \\ar[dr, dotted] & H^1(K, E)[\\phi_*] \\ar[r] \\ar[d, \"\\mathrm{res}_V\"] & 0 \\\\\n      0 \\ar[r] & \\prod_v \\frac{E'(K_v)}{\\phi E(K_v)} \\ar[r, \"\\delta_v\"] & \\prod_v H^1(K_v, E[\\phi]) \\ar[r] & \\prod_v H^1(K_v, E)[\\phi_*] \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  so\n  \\begin{align*}\n    S^{(\\phi)}(E/K)\n    &= \\ker(H^1(K, E[\\phi]) \\to \\prod_v H^1(K_v, E)) \\\\\n    &= \\{\\alpha\\in H^1(K, E[\\phi]): \\mathrm{res}_V(\\alpha) \\in \\im (\\delta_v) \\text{ for all } v\\}\n  \\end{align*}\n\\end{definition}\n\n\\begin{definition}[Tate-Shafarevich group]\\index{Tate-Shafarevich group}\n  The \\emph{Tate-Shafarevich group} is\n  \\[\n    \\Sh (E/K) = \\ker(H^1(K, E) \\to \\prod_v H^1(K_v, E)).\n  \\]\n\\end{definition}\n\nWe get a short exact sequence\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\frac{E'(K)}{\\phi E(K)} \\ar[r] & S^{(\\theta)}(E/K) \\ar[r] & Ш(E/K)[\\phi_*] \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nIn particular we can specialise to \\(\\phi = [n]\\). Rearranging our proof of weak Mordell-Weil gives\n\n\\begin{theorem}\n  \\(S^{(n)}(E/K)\\) is finite.\n\\end{theorem}\n\n\\begin{proof}\n  For \\(L/K\\) a finite Galois extension there is an exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H^1(\\gal(L/K), E(L)[n]) \\ar[r, \"\\mathrm{inf}\"] & H^1(K, E[n]) \\ar[d, \"\\supseteq\"] \\ar[r, \"\\mathrm{res}\"] & H^1(L, E[n]) \\ar[d, \"\\supseteq\"] \\\\\n      & & S^{(n)}(E/K) \\ar[r] & S^{(n)}(E/K)\n    \\end{tikzcd}\n  \\]\n  As \\(H^1(\\gal(L/K), E(L)[n])\\) is finite, we we extend our field \\(K\\) and assume \\(E[n] \\subseteq E(K)\\) and hence \\(\\mu_n \\subseteq K\\). Thus \\(E[n] \\cong \\mu_n \\times \\mu_n\\) as Galois modules. Thus\n  \\[\n    H^1(K, E[n]) \\cong H^1(K, \\mu_n) \\times H^1(K, \\mu_n) \\cong K^*/(K^*)^n \\times K^*/(K^*)^n.\n  \\]\n\n  Let \\(S\\) be the union of primes of bad reduction for \\(E\\), \\(v\\) such that \\(v \\divides n\\) and the infinite places. Note \\(S\\) is a finite set of places.\n\n  \\begin{definition}\n    The subgroup of \\(H^1(K, A)\\) unramified outside \\(S\\) is\n    \\[\n      H^1(K, A; S) = \\ker(H^1(K, A) \\to \\prod_{v \\notin S} H^1(K_v^{\\mathrm{nr}}, A)).\n    \\]\n  \\end{definition}\n  There is a commutative diagram with exact rows\n  \\[\n    \\begin{tikzcd}\n      E(K_v) \\ar[r, \"\\times n\"] \\ar[d, hook] & E(K_v) \\ar[r, \"\\delta_v\"] \\ar[d, hook] & H^1(K_v, E[n]) \\ar[d, \"\\mathrm{res}\"] \\\\\n      E(K_v^{\\mathrm{nr}}) \\ar[r, \"\\times n\"] & E(K_v^{\\mathrm{nr}}) \\ar[r, \"0\"] & H^1(K_v^{\\mathrm{nr}}, E[n])\n    \\end{tikzcd}\n  \\]\n  Multiplication by \\(n\\) on the second row is surjective for all \\(v \\notin S\\) (Thm 9.9). Thus\n  \\begin{align*}\n    S^{(n)}(E/K) &= \\{\\alpha \\in H^1(K, E[n]): \\mathrm{res}_v(\\alpha) \\in \\im(\\delta_v) \\text{ for all } v\\} \\\\\n                 &\\subseteq H^1(K, E[n]; S) \\\\\n                 &\\cong H^1(K, \\mu_n; S) \\times H^1(K, \\mu_n; S)\n  \\end{align*}\n  (?using the fact that \\(\\mathrm{res} \\compose \\delta_v = 0\\)) But\n  \\[\n    H^1(K, \\mu_n; S)\n    = \\ker(K^*/(K^*)^n \\to \\prod_{v \\notin S} (K_v^{\\mathrm{nr}})^*/(K_v^{\\mathrm{nr}})^{*n})\n    = K(S, n)\n  \\]\n  which is finite.\n\\end{proof}\n\n\\begin{remark}\n  \\(S^{(n)}(E/K)\\) is finite and effectively computable. It is conjectured that \\(|Ш(E/K)| < \\infty\\). This would imply that \\(\\mathrm{rank} E(K)\\) is effctively computable.\n\\end{remark}\n\n\\section{Descent by cyclic isogeny}\n\nLet \\(E, E'\\) be elliptic curves over a number field \\(K\\). Let \\(\\phi: E \\to E'\\) be an isogeny of degree \\(n\\). Suppose \\(E'[\\hat \\phi] \\cong \\Z/n\\Z\\) is generated by \\(T \\in E'(K)\\). Then \\(E[\\phi] \\cong \\mu_n, S \\mapsto e_\\phi(S, T)\\) as a \\(\\gal(\\overline K/K)\\)-module. We have a short exact sequence of \\(\\gal(\\overline K/K)\\)-modules\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\mu_n \\ar[r] & E \\ar[r, \"\\phi\"] & E' \\ar[r] & 0\n  \\end{tikzcd}\n\\]\ngiving rise to long exact sequence\n\\[\n  \\begin{tikzcd}\n    E(K) \\ar[r] & E'(K) \\ar[r, \"\\delta\"] \\ar[dr, \"\\alpha\"'] & H^1(K, \\mu_n) \\ar[r] \\ar[d, \"\\cong\"] & H^1(K, E) \\\\\n    & & K^*/(K^*)^n\n  \\end{tikzcd}\n\\]\n\n\\begin{theorem}\n  Let \\(f \\in K(E')\\) and \\(g \\in K(E)\\) with \\(\\div (f) = n(T) - n(0)\\) and \\(\\phi^* f = g^n\\). Then \\(\\alpha(P) = f(P) \\pmod{(K^*)^n}\\) for all \\(P \\in E'(K) \\setminus \\{0, T\\}\\).\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(Q \\in \\phi^{-1}P\\). Then \\(\\delta(P) \\in H^1(K, \\mu_n)\\) is represented by the cocyle \\(\\sigma \\mapsto \\sigma Q - Q \\in E[\\phi] \\cong \\mu_n\\). For any \\(X \\in E\\) not a zero or pole of \\(g\\),\n  \\[\n    e_\\phi(\\sigma Q - Q, T)\n    = \\frac{g(\\sigma Q - Q + X)}{g(X)}\n    = \\frac{g(\\sigma Q)}{g(Q)}\n    = \\frac{\\sigma(g(Q))}{g(Q)}\n    = \\frac{\\sigma(\\sqrt[n]{f(P)})}{\\sqrt[n]{f(P)}}\n  \\]\n  But\n  \\begin{align*}\n    H^1(K, \\mu_n) &\\cong K^*/(K^*)^n \\\\\n    \\sigma \\mapsto \\frac{\\sigma \\sqrt[n]{x}}{\\sqrt[n]{x}} &\\mapsfrom x\n  \\end{align*}\n  so \\(\\alpha(P) = f(P) \\pmod{(K^*)^n}\\).\n\\end{proof}\n\n\\paragraph{Descent by \\(2\\)-isogeny}\n\nLet \\(E: y^2 = x(x^2 + ax + b), E': y^2 = x(x^2 + a'x + b')\\) where \\(b(a^2 - 4b) \\ne 0, a' = -2a, b' = a^2 - 4b\\). Define\n\\begin{align*}\n  \\phi: E &\\to E' \\\\\n  (x, y) &\\mapsto ((\\frac{y}{x})^2, \\frac{y(x^2 - b)}{x^2}) \\\\\n  \\hat \\phi: E' &\\to E \\\\\n  (x, y) &\\mapsto (\\frac{1}{4} (\\frac{y}{x})^2, \\frac{y(x^2 - b')}{8x^2})\n\\end{align*}\nCheck they are dual to each other. Have \\(E[\\phi] = \\{0, T\\}, E'[\\hat \\phi] = \\{0, T'\\}\\) where \\(T = (0, 0) \\in E(K), E' = (0, 0) \\in E'(K)\\).\n\n\\begin{proposition}\n  There is a group homomorphism\n  \\begin{align*}\n    E'(K) &\\to K^*/(K^*)^2 \\\\\n    (x, y) &\\mapsto\n             \\begin{cases}\n               x \\pmod{(K^*)^2} & x \\ne 0 \\\\\n               b' \\pmod{(K^*)^2} & x = 0\n             \\end{cases}\n  \\end{align*}\n  with kernel \\(\\phi(E(K))\\).\n\\end{proposition}\n\n\\begin{proof}\n  Either apply theorem 16.1 with \\(f = x \\in K(E'), g = \\frac{y}{x} \\in K(E)\\), or direct calculation, see example sheet 4.\n\\end{proof}\n\nLet\n\\[\n  \\alpha_E: \\frac{E(K)}{\\hat \\phi(E'(K))} \\embed K^*/(K^*)^2, \\alpha_{E'}: \\frac{E'(K)}{\\phi(E(K))} \\embed K^*/(K^*)^2.\n\\]\n\n\\begin{lemma}\n  \\(2^{\\mathrm{rank} E(K)} = \\frac{1}{4} |\\im \\alpha_E| \\cdot |\\im \\alpha_{E'}|\\).\n\\end{lemma}\n\n\\begin{proof}\n  Since \\(\\hat \\phi \\phi = [2]_E\\) there is an exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & E(K)[\\phi] \\ar[r] & E(K)[2] \\ar[r, \"\\phi\"] & E'(K)[\\hat \\phi] \\ar[dll, overlay, out=0, in=180] \\\\\n      & \\frac{E'(K)}{\\phi E(K)} \\ar[r, \"\\hat \\phi\"] & \\frac{E(K)}{2E(K)} \\ar[r] & \\frac{E(K)}{\\hat E'(K)} \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  so the alternative product of group orders is \\(1\\). Thus\n  \\[\n    \\frac{|E(K)/2E(K)|}{E(K)[2]} = \\frac{|\\im \\alpha_E| \\cdot |\\im \\alpha_{E'}|}{4}.\n  \\]\n\n  By Mordell-Weil \\(E(K) \\cong \\Delta \\times \\Z^r\\) where \\(\\Delta\\) is finite and \\(r\\) is the rank of \\(E(K)\\). Thus\n  \\[\n    \\frac{E(K)}{2E(K)} \\cong \\frac{\\Delta}{2\\Delta} \\times (\\Z/2\\Z)^r, E(K)[2] \\cong \\Delta[2].\n  \\]\n  Since \\(\\Delta\\) is finite, \\(\\frac{\\Delta}{2\\Delta}\\) and \\(\\Delta[2]\\) have the same order. The result thus follows.\n\\end{proof}\n\n\\begin{lemma}\n  If \\(K\\) is a number field and \\(a, b \\in \\O_K\\) then \\(\\im \\alpha_E \\subseteq K(S, 2)\\) where \\(S = \\{\\text{primes dividing } b\\}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Must show if \\(x, y \\in K\\), \\(y^2 = x(x^2 + ax + b)\\) and \\(v_{\\mathfrak p}(b) = 0\\) then \\(v_{\\mathfrak p}(x)\\) is even. If \\(v_{\\mathfrak p}(x) < 0\\) then by lemma 9.1 \\(v_{\\mathfrak p}(x) = -2r, v_{\\mathfrak p}(y) = -3r\\) for some \\(r \\geq 1\\). If \\(v_{\\mathfrak p}(x) > 0\\) then \\(v_{\\mathfrak p}(x^2 + ax + b) = 0\\) so \\(v_{\\mathfrak p}(x) = v_{\\mathfrak p}(y^2) = 2 v_{\\mathfrak p}(y)\\).\n\\end{proof}\n\n\\begin{lemma}\n  If \\(b_1b_2 = b\\) then \\(b_1(K^*)^2 \\in \\im \\alpha_E\\) if and only if\n  \\[\n    w^2 = b_1 u^4 + au^2v^2 + b_2v^4\n  \\]\n  is soluble for \\(u, v, w \\in K\\) not all zero.\n\\end{lemma}\n\n\\begin{proof}\n  If \\(b_1 \\in (K^*)^2\\) or \\(b_2 \\in (K^*)^2\\) then both conditions are satisfied so may assume \\(b_1, b_2 \\notin (K^*)^2\\). \\(b_1(K^*)^2 \\in \\im \\alpha_E\\) if and only if exists \\((x, y) \\in E(K)\\) such that \\(x = b_1t^2\\) for some \\(t \\in K^*\\), so\n  \\[\n    y^2 = b_1t^2 ((b_1t^2)^2 + ab_1t^2 + b)\n  \\]\n  so\n  \\[\n    (\\frac{y}{b_1t})^2 = b_1t^4 + at^2 + b_2\n  \\]\n  so have solution \\((u, v, w) = (t, 1, \\frac{w}{b_1t})\\).\n\n  Conversely if \\((u, v, w)\\) is a solution then \\(uv \\ne 0\\). Check \\((b_1 (\\frac{u}{v})^2, b_1 \\frac{uw}{v^3}) \\in E(K)\\).\n\\end{proof}\n\nNow take \\(K = \\Q\\).\n\n\\begin{eg}\n  \\(E: y^2 = x^3 - x\\). By lemma 16.4, \\(\\im \\alpha_E \\subseteq \\langle -1 \\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). But we know \\((0, 0) \\in \\im \\alpha_E\\), equality. \\(E': y^2 = x^3 + 4x\\), \\(\\im \\alpha_{E'} \\subseteq \\langle -1, 2 \\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). Need to check\n  \\begin{align*}\n    b_1 = 1, & w^2 = - u^4 - 4u^4 \\\\\n    b_1 = 2, & w^2 = 2u^4 + 2v^4 \\\\\n    b_1 = -2, & w^2 = -2u^4 - 2v^4\n  \\end{align*}\n  The first and third are not soluble over \\(\\R\\). The second has solution \\((u, v, w) = (1, 1, 2)\\) so \\(\\im \\alpha_{E'} = \\langle 2\\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). Thus \\(\\mathrm{rank} E(\\Q) = 0\\) so \\(1\\) is not a congurent number.\n\\end{eg}\n\n\\begin{eg}\n  \\(E: y^2 = x^3 + px\\) where \\(p\\) is a prime, \\(p = 5 \\pmod 8\\). \\(b_1 = -1, w^2 = -u^4 - pv^4\\) is insoluble over \\(\\R\\) so \\(\\im \\alpha_E = \\langle p\\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). \\(E': y^2 = x^3 - 4px\\) so \\(\\im \\alpha_{E'} \\subseteq \\langle -1, 2, p \\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). Note \\(\\alpha_{E'}(T') = (-4p) (\\Q^*)^2 = (-p) (\\Q^*)^2\\) so only need to consider\n  \\begin{align*}\n    b_1 = 2, & w^2 = 2u^4 - 2pv^4 \\\\\n    b_1 = -2, & w^2 = -2u^4 + 2pv^4 \\\\\n    b_1 = p, & w^2 = pu^4 - 4v^4\n  \\end{align*}\n  Suppose equation 1 is soluble. wlog \\(u, v, w \\in \\Z, \\gcd(u, v) = 1\\). If \\(p \\divides u\\) then \\(p \\divides w\\) and then \\(p \\divides v\\), absurd. Thus \\(w^2 = 2u^4 \\ne 0 \\pmod p\\) so \\(\\legendre{2}{p} = 1\\), contradicting \\(p = 5 \\pmod 8\\).\n\n  Likewise 2 has no solution since \\(\\legendre{-2}{p} = -1\\).\n\\end{eg}\n\nTo recall, for \\(E: y^2 = x(x^2 + ax + b)\\), \\(\\phi: E \\to E'\\) a \\(2\\)-isogeny. \\(w^2 = b_1 u^4 + au^2v^2 + b_2v^4 (*)\\). Have a short exact sequence\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\frac{E'(\\Q)}{\\phi E(\\Q)} \\ar[r] \\ar[dr, \"\\alpha_{E'}\"] & S^{(\\phi)} (E/\\Q) \\ar[r] & \\Sh (E/\\Q)[\\phi_*] \\ar[r] & 0 \\\\\n    & & \\Q^*/(\\Q^*)^2\n  \\end{tikzcd}\n\\]\n\\begin{align*}\n  \\im \\alpha_{E'} &= \\{b_1 (\\Q^*)^2: \\text{\\(\\ast\\) is soluble over \\(\\Q\\)}\\} \\\\\n  \\subseteq S^{(\\phi)}(E/\\Q) &= \\{b_1 (\\Q^*)^2: \\text{\\(\\ast\\) is soluble over \\(\\R\\) and over \\(\\Q_p\\) for all \\(p\\)}\\}\n\\end{align*}\n\n\\begin{fact}\n  (Uses example sheet 3 question 9 and Hensel's lemma) If \\(a, b_1, b_2 \\in \\Z\\) and \\(p \\ndivides 2b(a^2 - 4b)\\) then \\(\\ast\\) is solubleover \\(\\Q_p\\).\n\\end{fact}\n\n\\begin{eg}[example 2 continued]\n  \\(E: y^2 = x^3 + px\\), \\(p = 5 \\pmod 8\\), \\(w^2 = pu^4 - 4v^4 \\dagger\\). \\(E(\\Q)\\) has rank \\(0\\) if (\\(\\dagger\\)) is insoluble over \\(\\Q\\) and rank \\(1\\) if soluble. By the fact we only have to look at \\(p\\)- and \\(2\\)-adics.\n  \\begin{itemize}\n  \\item \\(\\dagger\\) is soluble over \\(\\Q_p\\) since \\(\\legendre{-1}{p} = 1\\) so \\(-1 \\in (\\Z_p^*)^2\\) (by Hensel's lemma).\n  \\item soluble over \\(\\Q_2\\) since \\(p - 4 = 1 \\pmod 8\\) so \\(p - 4 \\in (\\Z_2^*)^2\\).\n  \\item soluble over \\(\\R\\) since \\(\\sqrt p \\in \\R\\).\n  \\end{itemize}\n  We can try to spot solutions:\n  \\[\n    \\begin{array}{c|ccc}\n      p & u & v & w \\\\ \\hline\n      5 & 1 & 1 & 1 \\\\\n      13 & 1 & 1 & 3 \\\\\n      29 & 1 & 1 & 5 \\\\\n      37 & 5 & 3 & 151 \\\\\n      53 & 1 & 1 & 7\n    \\end{array}\n  \\]\n  Conjecture: \\(\\mathrm{rank}(E(\\Q)) = 1\\) for all primes \\(p = 5 \\pmod 8\\).\n\\end{eg}\n\n\\begin{eg}[Lind]\n  \\(E: y^2 = x^3 + 17x\\). \\(\\im \\alpha_E = \\langle 17 \\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). \\(E': y^2 = x^3 - 68x\\). \\(\\im \\alpha_{E'} \\subseteq \\langle -1, 2, 17 \\rangle \\subseteq \\Q^*/(\\Q^*)^2\\). Consider \\(b_1 = 2\\). \\(w^2 = 2u^4 - 34v^4\\). Replace \\(w\\) by \\(2w\\) and divide through by \\(2\\) to get \\(C: 2w^2 = u^4 - 17v^4\\). Denote by\n  \\[\n    C(K) = \\{(u, v, w) \\in K^3 \\setminus \\{0\\} \\text{ satisfying } C\\}/\\sim\n  \\]\n  where \\((u, v, w) \\sim (\\lambda u, \\lambda v, \\lambda^2 w)\\) for all \\(\\lambda \\in K^*\\).\n\n  \\(C(\\Q_2) \\ne \\emptyset\\) as \\(17 \\in (\\Z_2^*)^4\\). \\(C(\\Q_{17}) \\neq \\emptyset\\) since \\(2 \\in (\\Z_{17}^*)^2\\). \\(C(\\R) \\ne \\emptyset\\) since \\(\\sqrt 2 \\in \\R\\). Thus \\(C(\\Q_v) \\ne \\emptyset\\) for all places of \\(\\Q\\). However it has no solution over \\(\\Q\\): suppose \\((u, v, w) \\in C(\\Q)\\). wlog \\(u, v\\in \\Z, \\gcd(u, v) = 1\\), then \\(w \\in \\Z\\) and can assume \\(w > 0\\). If \\(17 \\divides w\\) then \\(17 \\divides u\\) and then \\(17 \\divides v\\), absurd. So if \\(p \\divides w\\) then \\(p \\ne 17\\) and \\(\\legendre{17}{p} = 1\\) so by quadratic reciprocity \\(\\legendre{p}{17} = \\legendre{17}{2} = 1\\) (for \\(p\\) odd. For \\(p = 2\\) have \\(\\legendre{2}{17} = 1\\). Thus \\(\\legendre{w}{17} = 1\\). But \\(2w^2 = u^4 \\pmod{17}\\) so \\(2 \\in (\\F_{17}^*)^4 = \\{\\pm 1, \\pm 4\\}\\), absurd. Thus \\(C(\\Q) = \\emptyset\\). \\(C\\) is a counterexample to the Hasse principle. It representes a non-trivial element in \\(\\Sh(E/\\Q)\\).\n\\end{eg}\n\n\\paragraph{Birch Swinnerton-Dyer conjecture}\n\\index{Birch Sinnerton-Dyer conjecture}\n\nLet \\(E/\\Q\\) be an elliptic curve.\n\n\\begin{definition}[\\(l\\)-function]\\index{\\(L\\)-function}\n  The \\emph{\\(L\\)-function} of \\(E\\) is \\(L(E, s) = \\prod_p L_p(E, s)\\) where\n  \\[\n    L_p(E, s) =\n    \\begin{cases}\n      (1 - a_p p^{-s} + p^{1 - 2s})^{-1} & \\text{good reduction} \\\\\n      (1 - p^{-s})^{-1} & \\text{split multiplicative reduction} \\\\\n      (1 + p^{-s})^{-1} & \\text{nonsplit multiplicative reduction} \\\\\n      1 & \\text{additive reduction}\n    \\end{cases}\n  \\]\n  where \\(\\#(\\F_p) = p + 1 - a_p\\).\n\\end{definition}\n\nHasse's theorem says that \\(|a_p| < s \\sqrt p\\) so \\(L(E, s)\\) converges for \\(\\Re s > \\frac{3}{2}\\).\n\n\\begin{theorem}[Wiles, Breuil, Conrad, Diamond, Taylor]\n  \\(L(E, s)\\) is the \\(L\\)-function of a weight \\(2\\) modular form and hence has an analytic continuation to all of \\(\\C\\) (and a functional equation relating \\(L(E, s)\\) and \\(L(E, 2 - s)\\)).\n\\end{theorem}\n\n\\begin{conjecture}[weak Birch Swinnerton-Dyer conjecutre]\n  \\(\\ord_{s = 1} L(E, s) = \\mathrm{rank} E(\\Q)\\).\n\\end{conjecture}\n\nAssuming weak BSD and let \\(r = \\ord_{s = 1} L(E, s)\\) be the analytic rank, we have\n\n\\begin{conjecture}[strong Birch Swinnerton-Dyer conjecutre]\n  \\[\n    \\lim_{s \\to 1} \\frac{1}{(s - 1)^r} L(E, s) = \\frac{\\Omega_E |\\Sh(E/\\Q)| \\mathrm{Reg} E(\\Q) \\prod_P c_p}{|E(\\Q)_{\\mathrm{tors}}|^2}\n  \\]\n  where\n  \\begin{itemize}\n  \\item \\(c_p = [E(\\Q_p): E_0(\\Q_p)] = \\text{ tamagawa number of } E/\\Q_p\\), if \\(\\frac{E(\\Q)}{E(\\Q)_{\\mathrm{tors}}} = \\langle P_1, \\dots, P_r \\rangle\\) then\n    \\[\n      \\mathrm{Reg} E(\\Q) = \\det ([P_i, P_j])_{ij}\n    \\]\n    where \\([P, Q] = \\hat h (P + Q) - \\hat h(P) - \\hat h(Q)\\).\n  \\item \\(\\Omega_E = \\int_{E(\\R)} \\frac{dx}{|2y + a_1x + a_3|}\\) where \\(a_i\\) is the coefficient of a globally minimal Weierstrass equation for \\(E\\).\n  \\end{itemize}\n\\end{conjecture}\n\nBest result so far:\n\n\\begin{theorem}[Kolvragin]\n  If \\(\\ord_{s = 1} L(E, s) = 0\\) or \\(1\\) then weak BSD is trus and \\(|\\Sh (E/\\Q)| < \\infty\\).\n\\end{theorem}\n\n\\printindex\n\\end{document}\n\n% Silverman, The arithmetic of elliptic curves, Springer 1986\n% Cassels, Lectures on ellptic curves, CUP 1991\n\n% Introductory reading\n% Silverman & Tate, Rational points on elliptic curves, Springer 1992\n% Milne, Elliptic curves, Booksurge 2006", "meta": {"hexsha": "666158dfe8b7b086a04877e4fdd90cc42296f269", "size": 132144, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "III/elliptic_curves.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "III/elliptic_curves.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "III/elliptic_curves.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 44.1215358932, "max_line_length": 906, "alphanum_fraction": 0.5627421601, "num_tokens": 54169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.4368890252958126}}
{"text": "\\chapter{Analytical mechanics}\n\n% https://halshs.archives-ouvertes.fr/halshs-00116768/file/chap5.pdf\n\\emph{The origins of analytical mechanics in 18th century}, Marco Panza\n\\cite{panza2003origins}\n\nAbout the name:\nWhy is it ``analytical mechanics'' and not ``analytic mechanics''?\n\n\\emph{Analytical mechanics} is mathematical analysis applied to mechanics.\nCalculus is a part of mathematical analysis.\nCalculus is about limit, derivative, and integral.\nSeveral \\emph{formulations} of mechanics are\nNewtonian, Lagrangian, Hamiltonian, Routhian,\none due to Appell,\nand one due to Udwadia\\textendash{}Kalaba.\n\n% https://en.wikipedia.org/wiki/Analytical_mechanics\n% https://en.wikipedia.org/wiki/Mathematical_analysis\n% https://en.wikipedia.org/wiki/Gauss%27s_principle_of_least_constraint\n\n\\section{Principle of economy}\n\n\\section{Variational principles}\n\n\\emph{D'Alembert's principle of virtual work}?\nVirtual work?\nVirtual displacement?\n% https://en.wikipedia.org/wiki/D%27Alembert%27s_principle\n% https://en.wikipedia.org/wiki/Virtual_displacement\n% http://fy.chalmers.se/~tfemc/mekanikkompendium.pdf\n% https://en.wikipedia.org/wiki/Hamilton%27s_principle\n% https://en.wikipedia.org/wiki/Principle_of_least_action\n% https://en.wikipedia.org/wiki/Routhian_mechanics\n% https://en.wikipedia.org/wiki/Appell%27s_equation_of_motion\n% https://en.m.wikipedia.org/wiki/Udwadia–Kalaba_equation\n\n\\section{Lagrangian mechanics}\n\nIntroduction to analytical mechanics \\cite[p.~43]{varvoglis2014history}\n\n% https://en.wikipedia.org/wiki/Lagrangian_mechanics#From_Newtonian_to_Lagrangian_mechanics\n\n% https://archive.org/details/springer_10.1007-978-94-015-8903-1\n% https://en.m.wikipedia.org/wiki/Mécanique_analytique\nLagrange's \\emph{M\\'ecanique analytique} was published in 1788 \\cite{lagrange1997analytical}.\n\nLagrangian mechanics only works for conservative forces?\n\nThe \\emph{Lagrangian} of a mechanical system is?\n\n% https://en.m.wikipedia.org/wiki/Lagrangian_mechanics\n\nLet \\( e_k \\in \\Real^n \\) be the \\emph{\\(k\\)th basis vector of \\( \\Real^n \\)};\nit is \\( e_k = [\\delta_{ik}]_{i=1}^n \\);\nthe \\(k\\)th component of \\( e_k \\) is one; every other component of \\( e_k \\) is zero;\n\\( (e_k)_k = 1 \\) and \\( (e_k)_i = 0 \\) if \\( i \\neq k \\).\n\nFor example, assume \\( \\Real^3 \\), and let there be a particle \\( M \\)\nwhose mass is \\( m \\)\nand whose position is \\( (0,0,0) \\).\nThe \\emph{gravitational field} of \\( M \\) at \\( x \\) is \\( g(x) = - G m x / |x|^3 \\).\nSuch \\( g \\) is a vector field.\nThe \\emph{gravitational potential} of \\( M \\) is the \\( \\phi \\) such that \\( \\nabla \\phi = g \\).\nSuch \\( \\phi \\) is a scalar field.\nThe \\emph{potential energy of \\( N \\) due to \\( M \\)} is \\( K_{MN} = m_N \\cdot \\phi(x_N) \\).\n\nEvery particle in a system translates to two things in the \\emph{phase space}: a position and a momentum.\nWe can describe a system without explicit reference to time.\nWe describe each particle by a set of \\emph{position-momentum pairs}.\nThis set is the \\emph{phase space} of the system.\n\nWhy bother using phase space if systems of equations work just fine?\n\nWe can \\emph{describe} the trajectory of a particle using a function\nwhose input is a real number representing relative time\nand output is a three-dimensional real vector representing relative position.\nThis is straightforward to imagine.\n\nHowever, we can also describe the same thing by a set of ordered pairs\n\\( \\{ (t,x) ~|~ \\text{the object is at \\(x\\) at time \\(t\\)} \\} \\).\n\nNewton's law of gravity describes the force that a\n\\emph{point mass} exerts on another point mass.\nIt still applies to planets even if when we assume that a planet is a point mass.\n\\[\n    F_{ab} = \\frac{G m_a m_b}{|r_{ab}|^2} \\hat{r}_{ab}\n\\]\n\n% https://en.wikipedia.org/wiki/Gauss%27s_law_for_gravity\n\nNewton's second law:\n\\(F = dp\\) where \\(F(t)\\) is force acting on the point mass at time \\(t\\)\nand \\(p(t)\\) is the momentum of the point mass at time \\(t\\).\n\nThe \\emph{degree of freedom} of a system is the minimum number of parameters required to describe that system.\n\nA system of \\emph{equations of motion} has the form:\n\\begin{align*}\n    x_1(t) &= \\ldots\n    \\\\\n    & \\vdots\n    \\\\\n    x_n(t) &= \\ldots\n\\end{align*}\n\nImagine that in front of you there is a \\emph{pendulum} hanging on a thread attached to the roof.\nTo model that system, we could pick the XYZ coordinate system\nwhere, from your point of view,\nthe positive X axis is rightward, the positive Y axis is forward, and the positive Z axis is upward.\nThus, at all times, the force acting on the pendulum is \\( F = (0,0,-mg) \\).\nThis should be straightforward to imagine.\nBut you have to determine the tension of the thread that constrains the pendulum's motion.\n\nBut we can pick another coordinate system where a point is described by \\( (\\theta) \\).\nLet \\(\\theta\\) be the angle from the vertical axis to the thread:\n\\( \\theta = 0 \\) means that the thread is vertical,\nand positive \\( \\theta \\) means that the pendulum is to your right.\nLet \\( K \\) be the line length.\n\\(h = K - (1 - \\cos \\theta) K = K \\cos \\theta\\).\n\\(P = m g h\\).\n\\(K = \\frac{1}{2} m v^2\\).\nGeneralized coordinates: \\((h,\\theta)\\) instead of \\((x,y)\\).\nTranslation rules: \\(x = K \\sin \\theta\\) and \\(y = K \\cos \\theta\\).\nThe point \\(x,y=0,0\\) is the lowest point of the pendulum.\n\n\\section{Example: Two rigid bodies}\n\nAssume constant mass.\n\\begin{align*}\n    m_1 \\cdot (d^2 x_1)(t) &= G m_1 m_2 \\cdot (x_2(t) - x_1(t)) / \\norm{x_1(t) - x_2(t)}^3\n    \\\\\n    m_2 \\cdot (d^2 x_2)(t) &= G m_1 m_2 \\cdot (x_1(t) - x_2(t)) / \\norm{x_1(t) - x_2(t)}^3\n\\end{align*}\nMatrix form:\n\\begin{align*}\n    \\bmat{\n        m_1 \\cdot (d^2 x_1)(t)\n        \\\\\n        m_2 \\cdot (d^2 x_2)(t)\n    }\n    &=\n    \\frac{G m_1 m_2}{\\norm{x_1(t) - x_2(t)}^3}\n    \\bmat{\n        x_2(t) - x_1(t)\n        \\\\\n        x_1(t) - x_2(t)\n    }\n\\end{align*}\n\n\\paragraph{Example}\nUniform gravitation field.\nPhase space coordinate \\(h\\) where \\(h\\) is height.\n\\(P(h) = m g h\\).\n\\(K(h) = m (v(h))^2 / 2\\).\nConservation of energy: \\(P + K = E\\).\n\\(d_h E = 0 = m g + \\frac{1}{2} m \\cdot (d_h v)(h) \\cdot 2 v(h)\\).\n\\(0 = g + (d_h v)(h) \\cdot v(h)\\).\n\\(- g = d_h v \\cdot v\\).\n\n\\section{Canonical coordinates}\n\n\\section{Poisson bracket}\n\nThe \\emph{Poisson bracket} is ...\n\n\\section{Hamiltonian mechanics}\n\nWith physical laws, we can predict the state of physical systems.\n\nA\n\\index{configuration space}%\n\\emph{configuration space} is a vector space where each vector is a generalized coordinate tuple.\n\nExample of Hamiltonian mechanics:\nIn two-body problem,\nthe state space is ...,\nthe configuration space is ...,\n\n\\section{Noether's theorem}\n\n\\subsection{Conservation of energy}\n\n\\subsection{Newton's third law of motion}\n", "meta": {"hexsha": "e1a9a5f789ec830f99ccc9a41a0c6db4a7febbcd", "size": 6650, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "research/physics/mechanics-analytical.tex", "max_stars_repo_name": "edom/work", "max_stars_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "research/physics/mechanics-analytical.tex", "max_issues_repo_name": "edom/work", "max_issues_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-12-02T18:37:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T00:55:32.000Z", "max_forks_repo_path": "research/physics/mechanics-analytical.tex", "max_forks_repo_name": "edom/work", "max_forks_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-10-02T15:20:22.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-02T15:20:22.000Z", "avg_line_length": 35.9459459459, "max_line_length": 110, "alphanum_fraction": 0.6956390977, "num_tokens": 2047, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.436889021873531}}
{"text": "This appendix presents more complete details and justification for the calibrated parameters in Table~\\ref{table:calibration}.  We begin by calibrating market-level and preference parameters by standard methods, then specify additional parameters to characterize the idiosyncratic income shock distribution.\n\n\\subsection{Macroeconomic Calibration}\n\\label{sec:MacroCal}\n\nWe assume a coefficient of relative risk aversion of\n$\n\\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/CRRA.txt\n$. % $ marks is needed to avoid space between CRRA.txt and \",\" in the pdf\nThe quarterly depreciation rate $\\delta$ is calibrated by assuming annual depreciation of 6 percent,\ni.e.,\n$\n\\DeprFac^{4}= \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/DeprFacAnn.txt\n$.  Capital's share in aggregate output takes its usual value of\n$\n\\kapShare= \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/CapShare.txt\n$.\n\nWe set the variances of the quarterly transitory and permanent shocks at the approximate values respectively:\n\\begin{eqnarray*}\n\t\\sigma^{2}_{\\Theta} & = & \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/TranShkAggVar.txt ,\n\t\\\\ \\sigma^{2}_{\\Psi}  & =  & \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/PermShkAggVar.txt ,\n\\end{eqnarray*}\nwhich allow the model to match high degree of persistence in aggregate labor income.\\footnote{We measure labor income using U.S.\\ NIPA data as wages and salaries plus transfers minus personal contributions for social insurance.} These values are consistent with papers such as \\cite{jermannProduction}, \\cite{bcfHabits}, and \\cite{ckmCritique}, considered standard  in the RBC literature. These authors model the state of technology as either a highly persistent AR(1) process or a random walk; but the underlying calibrations come from the autocorrelation properties of measured aggregate dynamics, which are matched about as well by our specification of the income process.\n\nTo finish the calibration, we consider a simple perfect foresight model (PF-DSGE), with all aggregate and idiosyncratic shocks turned off.  We set the perfect foresight steady state aggregate capital-to-output ratio to \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/KYratioSS.txt on a quarterly basis (corresponding to the usual ratio of 3 for capital divided by annual income).  Along with the calibrated values of $\\kapShare$ and $\\delta$, this choice implies values for the other steady-state characteristics of the PF-DSGE model:\n\\begin{eqnarray*}\n\t{\\KLev} & = & \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/KYratioSS.txt ^{1/(1-\\kapShare)},\n\t\\\\   {\\Wage} & = & (1-\\kapShare) {\\KLev}^{\\kapShare},\n\t\\\\   {\\Rprod} & = & \\DeprFac+\\kapShare {\\KLev}^{\\kapShare-1}\n\t.\n\\end{eqnarray*}\nIn the SOE model, we fix the interest factor $\\Rprod$ and wage rate $\\Wage$ to these PF-DSGE steady state values.\n\nA perfect foresight representative agent would achieve this steady state if his discount factor satisfied ${\\Rprod} \\beta = 1$.  For the SOE model, however, we choose a much lower value of $\\beta$ ($ \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/betaSOE.txt $), resulting in agents with wealth holdings around the median observed in the data;\\footnote{The exact value of the median is depends in part on whether housing equity should be viewed as part of the precautionary buffer stock, the age range of the households being matched, the measure of permanent income, and many other extraneous issues.} the value of $\\beta$ satisfying ${\\Rprod} \\beta = 1$ is used in the closed economy models presented in the online appendix, allowing those models to fit the \\textit{mean}  observed wealth.\n\n\\subsection{Calibration of Idiosyncratic Shocks}\n\nThe annual-rate idiosyncratic transitory and permanent shocks are assumed to be:\n\\begin{eqnarray*}\n\t\\sigma_{\\theta}^{2} & = & \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/TranShkVarAnn.txt ,\n\t\\\\ \\sigma_{\\psi}^{2}             & = & \\input /Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/PermShkVarAnn.txt\n\t.\n\\end{eqnarray*}\n\nOur calibration for the sizes of the idiosyncratic shocks are conservative relative to the literature;\\footnote{See Table~1 in the ECB working paper version of \\cite{cstKS} for a comprehensive overview of estimates of variances of idiosyncratic income shocks; Carroll, Christopher~D., Jiri Slacalek, and Kiichi Tokuoka (2014): ``Buffer-Stock Saving in a Krusell--Smith World,'' working paper 1633, European Central Bank, \\url{https://www.ecb.europa.eu/pub/pdf/scpwps/ecbwp1633.pdf}.} using data from the {\\it Panel Study of Income Dynamics}, for example, \\cite{carroll&samwick:nature} estimate $\\sigma_{\\psi}^{2} = 0.0217$ and $\\sigma_{\\theta}^{2} = 0.0440$; Storesletten, Telmer, and Yaron~(\\citeyear{sty:consumption}) estimate $\\sigma_{\\psi}^{2} \\approx 0.017$, with varying estimates of the transitory component.  But recent work by \\cite{lmpPermShocks} suggests that controlling for participation decisions reduces estimates of the permanent variance somewhat; and using very well-measured Danish administrative data, \\cite{nv:risk} estimate $\\sigma_{\\psi}^{2} \\approx 0.005$ and $\\sigma_{\\theta}^{2} \\approx 0.015$, which presumably constitute lower bounds for plausible values for the truth in the U.S. (given the comparative generosity of the Danish welfare state).\n\nWe assume that the probability of unemployment is 5 percent per quarter.  This approximates the historical mean unemployment rate in the U.S., but model unemployment differs from real unemployment in (at least) two important ways.  First, the model does not incorporate unemployment insurance, so labor income of the unemployed is zero.  Second, model unemployment shocks last only one quarter, so their duration is shorter than the typical U.S.\\ unemployment spell (about 6 months).  The idea of the calibration is that a single quarter of unemployment with zero benefits is roughly as bad as two quarters of unemployment with an unemployment insurance payment of half of permanent labor income (a reasonable approximation to the typical situation facing unemployed workers).  The model could be modified to permit a more realistic treatment of unemployment spells; this is a promising topic for future research, but would involve a considerable increase in model complexity because realism would require adding the individual's employment situation as a state variable.\n\nThe probability of mortality is set at $\\PDies= \\input {/Volumes/Data/Papers/cAndCwithStickyE/cAndCwithStickyE-AEJM/Calibration/DiePrb.txt}$, which implies an expected working life of 50 years; results are not sensitive to plausible alternative values of this parameter, so long as the life length is short enough to permit a stationary distribution of idiosyncratic permanent income.", "meta": {"hexsha": "be0b2920ae7727505ccf3623ed139a1b92f9d5ea", "size": 7005, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/appendices/Calibration.tex", "max_stars_repo_name": "llorracc/cAndCwithStickyE-AEJM", "max_stars_repo_head_hexsha": "c053da06e88dd8c36319ac5976efa89d5d69c8f5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX/appendices/Calibration.tex", "max_issues_repo_name": "llorracc/cAndCwithStickyE-AEJM", "max_issues_repo_head_hexsha": "c053da06e88dd8c36319ac5976efa89d5d69c8f5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX/appendices/Calibration.tex", "max_forks_repo_name": "llorracc/cAndCwithStickyE-AEJM", "max_forks_repo_head_hexsha": "c053da06e88dd8c36319ac5976efa89d5d69c8f5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-05T07:51:31.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-05T07:51:31.000Z", "avg_line_length": 140.1, "max_line_length": 1272, "alphanum_fraction": 0.7911491792, "num_tokens": 1780, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426303, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4368777201063263}}
{"text": "% !TEX root =  paper.tex\r\n\r\n\\begin{figure*}[t!]\r\n\t\\centering\r\n\t\\includegraphics[width=0.45\\linewidth]{./figures/variation_of_information-microns-train-600.png}\r\n\t\\includegraphics[width=0.45\\linewidth]{./figures/variation_of_information-microns-test-600.png}\r\n\t\\includegraphics[width=0.45\\linewidth]{./figures/variation_of_information-FlyEM-train-600.png}\r\n\t\\includegraphics[width=0.45\\linewidth]{./figures/variation_of_information-FlyEM-test-600.png}\r\n\t\\caption{VI scores of our method (red) compared to the baseline segmentation (green) and an oracle (blue) that optimally partitions the graph based on ground truth. Lower scores are better. Our method improves the accuracy of the segmentation in all cases.}\r\n\t\\label{fig:variation-of-information}\r\n\\end{figure*}\r\n\r\n%\\section{Results}\r\n\r\n\\subsection{Error Metric}\r\n\\label{sec:variation-of-information}\r\n\r\nWe evaluate the performance of the different methods using the split variation of information (VI)~\\cite{meila2003comparing}.\r\nGiven a ground truth labeling $GT$ and our automatically reconstructed segmentation $SG$, over- and under-segmentation are quantified by the conditional entropies $H(GT | SG)$ and $H(SG | GT)$, respectively. Since we are measuring the entropies between two clusterings, lower VI scores are better.\r\n\r\n\\subsection{Variation of Information Results}\r\n\r\nIn Fig.~\\ref{fig:variation-of-information}, we show the VI results of the pixel-based reconstructions of the Kasthuri and FlyEM data (Sec.~\\ref{sec:neuroproof}) for varying thresholds of agglomeration (green). We use one of these segmentations (green circle) as out input dataset with an agglomeration threshold of 0.3 for all datasets. The results from our method are shown in red for varying the $\\beta$ parameter. We show comparisons to an oracle (blue) that correctly partitions the graph from our method based on ground truth.\r\n\r\nOur algorithm improves the accuracy of the reconstruction for every dataset, reducing the VI split score on average by 19.3\\% on the three testing datasets. \r\nScores closer to the origin are better for this metric, and in every instance our results are below the green curve.\r\nWe see significant improvements on the Kasthuri datasets (VI split reduction of 27.7\\% and 24.8\\% on the training and testing datasets respectively) and more modest improvements on the FlyEM datasets (reduction of 15.2\\% and 18.0\\%). This is because the baseline segmentation algorithm for the isotropic FlyEM data (Sec.~\\ref{sec:neuroproof}) performs much better, reducing the potential for improvements. Isotropic datasets are easier to segment using state-of-the-art region-based methods than anisotropic ones~\\cite{plaza2014annotating}.\r\n\r\nFig.~\\ref{fig:positive-results} shows successful merges on the Kasthuri Vol. 2 dataset. Several of these examples combine multiple consecutive segments that span the volume.\r\nIn the third example we correct the over-segmentation of a dendrite and attached spine-necks.\r\nFig.~\\ref{fig:negative-results} shows typical failure cases of our method (red circles).\r\nIn two of these examples the algorithm correctly predicted several merges before a single error rendered the segment as wrong.\r\nIn the third example (blue circle) a merge error in the initial segmentation propagated to our output.\r\nWe now analyze how each major component of our method contributes to this final result.\r\n\r\n\\begin{figure}[t]\r\n\t\\centering\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-correct1.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-correct2.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-correct3.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-correct4.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-correct5.png}\r\n\t\\caption{Segments of neurons that were correctly merged by our method.}\r\n\t\\label{fig:positive-results}\r\n\\end{figure}\r\n\r\n\\begin{figure}[t]\r\n\t\\centering\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-incorrect1.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-incorrect2.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-incorrect3.png}\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/VI-results/multicut-incorrect4.png}\r\n\t\\caption{Circles indicate areas of wrong merges by our method (red) or by the initial pixel-based segmentation (blue).}\r\n\t\\label{fig:negative-results}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Graph Pruning Results}\r\n\r\n\r\n\r\nTable \\ref{table:skeletonization} shows the results of pruning the skeleton graph using the algorithm discussed in Sec.~\\ref{sec:skeletonization}. This edge pruning is essential for the graph partitioning algorithm, which has a computational complexity dependence on the number of edges. The baseline algorithm considers all adjacent regions for merging. Our method removes a significant portion of these candidates while maintaining a large number of the true merge locations (e.g., 753 compared to 763). Our pruning heuristic removes at least $6\\times$ the number of edges on all datasets, achieving a maximum removal rate of $20\\times$.\r\n\r\n\\begin{table}\r\n\t\\centering\r\n\t\\small\r\n\t\\begin{tabular}{c c c} \\hline\r\n\t\t\\textbf{Dataset} & \\textbf{Baseline} & \\textbf{After Pruning} \\\\ \\hline\r\n\t\tKasthuri Training & 763 / 21,242 & 753 / 3,459 \\\\\r\n\t\tKasthuri Vol. 2 & 1,010 / 26,073 & 904 / 4,327 \\\\\r\n\t\tFlyEM Vol. 1 & 269 / 14,875 & 262 / 946 \\\\\r\n\t\tFlyEM Vol. 2 & 270 / 16,808 & 285 / 768 \\\\ \\hline\r\n\t\t%\t\tKasthuri Vol. 1 & 763 / 21242 (3.47\\%) & 753 / 3459 (17.88\\%) \\\\\r\n\t\t%\t\tKasthuri Vol. 2 & 1010 / 26073 (3.73\\%) & 904 / 4327 (17.28\\%) \\\\\r\n\t\t%\t\tFlyEM Vol. 1 & 269 / 14875 (1.78\\%) & 262 / 946 (21.69\\%) \\\\\r\n\t\t%\t\tFlyEM Vol. 2 & 270 / 16808 (1.58\\%) & 285 / 768 (27.07\\%)\\\\ \\hline\r\n\t\\end{tabular}\r\n\t\\caption{The results of our graph pruning approach compared to the baseline graph with all adjacent regions. We show the number of true merge locations (e.g., 763) compared to total number of edges in the graph (e.g., 21,242) for each case.}\r\n\t\\label{table:skeletonization}\r\n\\end{table}\r\n\r\nWe generate edges in our graph by using information from the skeletons. \r\nIn particular, we do not enforce the constraint that edges in our graph correspond to adjacent segments.\r\nAlthough neurons are continuous, the EM images often have noisy spots which cause an interruption in the input segmentation.\r\nWe still want to reconstruct these neurons despite the fact that the initial segmentation is non-continuous. \r\nThe second and fourth examples in Fig.~\\ref{fig:positive-results} show correctly reconstructed neurons where two of the segments are non-adjacent. \r\nThis is a large benefit over enforcing segment adjacency. \r\n\r\nThere are some pairs of segments which we do not consider for merging because of our reliance on the skeletons. \r\nFig.~\\ref{fig:skeleton-results} shows such a case. \r\nThe endpoints of both segments are circled.\r\nIn this example the small segment is carved from the larger segment in a location where there are no skeleton endpoints.\r\n\r\n\\begin{figure}[h!]\r\n\t\\centering\r\n\t\\includegraphics[width=0.85\\linewidth]{./figures/merge_candidate1.png}\r\n\t\\caption{A false negative example of our method due to graph pruning. The distance between the endpoints (circled) of the two segments is too far to be flagged as a merge candidate.}\r\n\t\\label{fig:skeleton-results}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{CNN Classification Results}\r\n\r\nFig.~\\ref{fig:receiver-operating-characteristic} shows the receiver operating characteristic (ROC) curve of our CNN classifier for all test datasets.\r\n%We train our CNN using one of the Kasthuri volumes and test using the other three datasets.\r\nSince our CNN only takes as input a region of the label volume we can train on  anisotropic data and test on isotropic data.\r\nThis provides a major benefit given the time-intensive task of manually generating ground truth for each dataset at various resolutions.\r\n\r\nAs shown by the ROC curve, the test results on the Kasthuri data are better than the results for FlyEM.\r\nWe believe this is in part because of the differences in the datasets (i.e., isotropy and $xy$ resolution).\r\nTo test this hypothesis, we also evaluate the performance of the FlyEM datasets when the network trains on FlyEM Vol. 1 and infers on FlyEM Vol. 2.\\footnote{Since the FlyEM datasets have significantly fewer examples, we initialize the network with the weights from the Kasthuri training and have an initial learning rate of $10^{-4}$.}\r\nThe blue dotted curve in the figure shows a slight performance increase in this case. However, the improvement is minor, which led us to use the CNN trained on the anisotropic data for the rest of our experiments.\r\n\r\n\\begin{figure}\r\n\t\\centering\r\n\t\\includegraphics[width=0.95\\linewidth]{./figures/receiver-operating-characteristic.jpg}\r\n\t\\caption{The receiver operating characteristic (ROC) curves of our classifier on three connectomics datasets. The classifier works best on previously unseen data of the Kasthuri volume. The dashed blue line indicates better performance on the FlyEM datasets with retraining compared to without (solid blue).}\r\n\t\\label{fig:receiver-operating-characteristic}\r\n\\end{figure}\r\n\r\n\\subsection{Graph Optimization Results}\r\n\r\nThe graph optimization strategy using multicut increases our accuracy over using just the CNN.\r\nTable \\ref{table:multicut} shows the changes in precision, recall, and accuracy for all four datasets compared to the CNN.\r\nThe precision increases on each dataset, although the recall decreases on all but one of the datasets.\r\nSince it is more difficult to correct merge errors than split errors, it is often desirable to sacrifice recall for precision.\r\nOver the three testing datasets, applying a graph-based partitioning strategy reduced the number of merge errors by 36.1\\%, 12.2\\%, and 13.6\\%, respectively. \r\n\r\n\\begin{table}[h]\r\n\t\\centering\r\n\t\\small\r\n\t\\begin{tabular}{c c c c} \\hline\r\n\t\t\\textbf{Dataset} & $\\Delta$ \\textbf{Precision} & $\\Delta$ \\textbf{Recall} & $\\Delta$ \\textbf{Accuracy} \\\\ \\hline\r\n\t\tKasthuri Training & +3.61\\% & -0.53\\% & +0.60\\% \\\\\r\n\t\tKasthuri Vol. 2 & +7.59\\% & -1.77\\% & +1.38\\% \\\\\r\n\t\tFlyEM Vol. 1 & +2.68\\% & +0.76\\% & +0.66\\% \\\\\r\n\t\tFlyEM Vol. 2 & +2.22\\% & -1.05\\% & +0.29\\% \\\\ \\hline\r\n\t\\end{tabular}\r\n\t\\caption{Precision, recall, and accuracy changes between CNN only and CNN paired with graph-optimized reconstructions for the training and three test datasets. The combined method results in better precision and accuracy.}\r\n\t\\label{table:multicut}\r\n\\end{table}", "meta": {"hexsha": "84c352a556df0431819b9b9280c86906f5a1cc2f", "size": 10581, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/cvpr2018/4_results.tex", "max_stars_repo_name": "romil797/ibex", "max_stars_repo_head_hexsha": "898134a96e299d8106d9deb7b217671c39bfeca2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "papers/cvpr2018/4_results.tex", "max_issues_repo_name": "romil797/ibex", "max_issues_repo_head_hexsha": "898134a96e299d8106d9deb7b217671c39bfeca2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/cvpr2018/4_results.tex", "max_forks_repo_name": "romil797/ibex", "max_forks_repo_head_hexsha": "898134a96e299d8106d9deb7b217671c39bfeca2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.0425531915, "max_line_length": 640, "alphanum_fraction": 0.7634439089, "num_tokens": 2726, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426303, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4368777201063263}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\n\\usepackage{csquotes}\n\\usepackage{graphicx}\n\\graphicspath{ {./figs} }\n\\usepackage{float}\n\\usepackage{wrapfig}\n\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\n\\usepackage{mathrsfs}\n\\usepackage{mathtools}\n\n\\usepackage{color}\n\\usepackage{epsfig}\n\\usepackage{array}\n\\usepackage{multicol}\n\\usepackage{tikz}\n\\usepackage{listings}\n\\usepackage{minted}\n\\usepackage{mdframed}\n\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{0.5em}\n% \\textwidth 6.5in\n% \\textheight 9.in\n% \\oddsidemargin 0in\n% \\headheight 0in\n\n\n\\newtheorem{theorem}{Theorem}[section]\n\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.95}\n\n\\usepackage[hidelinks]{hyperref}\n\\hypersetup{\n    colorlinks=false, %set true if you want colored links\n    linktoc=all,      %set to all if you want both sections & subsections linked\n}\n\\usepackage[nameinlink]{cleveref}\n\n\n\\lstset{ %\n  language=python,                % choose the language of the code\n  basicstyle=\\footnotesize,       % the size of the fonts that are used for the code\n  numbers=left,                   % where to put the line-numbers\n  numberstyle=\\footnotesize,      % the size of the fonts that are used for the line-numbers\n  stepnumber=1,                   % the step between two line-numbers. If it is 1 each line will be numbered\n  numbersep=5pt,                  % how far the line-numbers are from the code\n  backgroundcolor=\\color{white},  % choose the background color. You must add \\usepackage{color}\n  showspaces=false,               % show spaces adding particular underscores\n  showstringspaces=false,         % underline spaces within strings\n  showtabs=false,                 % show tabs within strings adding particular underscores\n  frame=single,                   % adds a frame around the code\n  tabsize=2,                      % sets default tabsize to 2 spaces\n  captionpos=b,                   % sets the caption-position to bottom\n  breaklines=true,                % sets automatic line breaking\n  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace\n  escapeinside={\\%*}{*)}          % if you want to add a comment within your code\n}\n\n\\usemintedstyle{vs}\n\n\n\\begin{document}\n\n\n\\usetikzlibrary{positioning}\n\\tikzset{every picture/.style={line width=0.75pt}}\n\n\\pagestyle{plain}\n\n\\begin{multicols}{2}\n  \\begin{flushleft}\n    MAT360 \\\\\n    Autumn 2021\\\\\n    Prof. Jan Martin Nordbotten\\\\\n    \\underline{University of Bergen}\n  \\end{flushleft}\n  \\vfill\\null\n  \\columnbreak\n\n  \\begin{flushright}\n    \\includegraphics[height=2cm]{assets/uib.logo.png}\n  \\end{flushright}\n\\end{multicols}\n\n\\begin{center}\n\\textbf{\\large Exemplary FEM implementations and convergence analysis}\\\\\nPaul Stryck\\\\\n\\end{center}\n\\rule{\\linewidth}{0.1mm}\n\n\n\n\\begin{abstract}\n    \\noindent\n    This report presents the numerical validation of a custom FEM implementation with polynomial basis\n    functions of arbitrary degree on structured and unstructured grids.\n    The Poisson equation will be considered on the unit square.\n    Different force functions for which the analytical solution is known will be used.\n    Thus, the errors can be computed explicitly, and given convergence rates are verified.\n    To cover a broad spectrum of potential implementation errors, both pure Dirichlet and mixed Dirichlet +\n    Neumann boundary conditions will be used.\n\\end{abstract}\n\n\\begin{multicols}{2}\n\n\\subsection*{Continuous Problem}\nThe PDE under consideration is the homogeneous Poisson equation:\n\\begin{equation} \\label{eq:poisson}\n  \\begin{split}\n    - \\Delta u &= f \\quad \\text{on } \\Omega\\\\\n    u &= 0 \\quad \\text{on } \\partial\\Omega\n  \\end{split}\n\\end{equation}\nWhere $\\Omega \\subset \\mathbb{R}^n$ is an open and bounded set and $f \\in L^2(\\Omega)$.\nA classical solution $u \\in C^2(\\Omega) \\cap C^1(\\bar{\\Omega})$, will at most\nexist if $f$ is at least continuous and restrictive assumptions regarding $\\Omega$ have to be made.\nThus, a less restrictive formulation of the Problem (\\ref{eq:poisson}) based on\nthe variational formulation will be derived.\\\\\n\nMultiplying \\autoref{eq:poisson} with test functions $v \\in C^\\infty_0(\\Omega)$ and\nintegrating over $\\Omega$ yields:\n\n\\begin{equation} \\label{eq:poisson_var}\n    - \\int_\\Omega \\Delta u v\\,dV = \\int_\\Omega fv\\,dV \\\\ \\forall v \\in C^\\infty_0(\\Omega)\n\\end{equation}\n\nIf $\\Omega$ has a Lipschitz boundary, \\autoref{eq:poisson_var} can be simplified\nusing Green's first identity.\n\\begin{multline}\\label{eq:poisson_var_greens}\n    \\int_\\Omega \\nabla u \\cdot \\nabla v \\,dV\n  - \\int_{\\partial\\Omega} v \\frac{\\partial u}{\\partial n} \\,dS\n  = \\int_\\Omega fv\\,dV \\\\ \\forall v \\in C^\\infty_0(\\Omega)\n\\end{multline}\n\nWhere the boundary integral vanishes since $v = 0$ on $\\partial\\Omega$.\nAdditionally, $C^\\infty_0(\\Omega)$ is dense in $H^1_0(\\Omega)$.\nSo \\autoref{eq:poisson_var_greens} can be further simplified to:\n\\begin{equation} \\label{eq:poisson_weak}\n  \\underbrace{\\int_\\Omega \\nabla u \\cdot \\nabla v \\,dV}_{\\eqqcolon a(u,v)}\n  = \\underbrace{\\int_\\Omega fv\\,dV \\quad \\forall v \\in\n  H^1_0(\\Omega)}_{\\eqqcolon b(v) = \\langle b, v \\rangle_{H^{-1}_0, H^1_0}}\n\\end{equation}\nA function $u \\in H^1_0(\\Omega)$ satisfying \\autoref{eq:poisson_weak} is called\nweak solution of \\autoref{eq:poisson}.\nAssuming $u \\in C^2(\\Omega) \\cap C^1(\\bar{\\Omega})$ is a classical solution to\n\\autoref{eq:poisson}. This implies $u \\in H^1_0(\\Omega)$ and thus any classical\nsolution would also satisfy the weak formulation. Thus, the weak formulation\nindeed broadens the set of admissible functions.\n\nExistence and uniqueness of a solution to \\autoref{eq:poisson_weak} is given by\nreformulating \\autoref{eq:poisson_weak} to $a(u,v) = \\langle b,v \\rangle_{H^{-1}_0, H^1_0}$\nand application of Lax-Milgram. The proof is omitted here.\n\n\n\\subsection*{Boundary Conditions}\nIt shall be briefly investigated how boundary conditions can be incorporated.\nFor this, Dirichlet and mixed Dirichlet + Neumann boundary conditions will be\nconsidered.\\\\\nFirst, considering Dirichlet boundary conditions, the problem is given by:\n\\begin{equation} \\label{eq:poisson_dirichlet}\n  \\begin{split}\n    -\\Delta u &= f  \\text{ in } \\Omega\\\\\n    u &= g \\text{ on } \\partial\\Omega\n  \\end{split}\n\\end{equation}\nwith $f \\in L^2(\\Omega)$ and $g \\in L^2(\\partial\\Omega)$.\\\\\nIn addition to the already established Hilbert space $H^1_0$ define the set:\n\\begin{equation*}\n    V_g \\coloneqq \\left\\{ v \\in H^1(\\Omega)\\, :\\, v\\vert_{\\partial\\Omega} = g \\text{ a.e. on } \\partial\\Omega\\right\\}\n\\end{equation*}\nWhich is well-defined for all $g \\in L^2(\\partial\\Omega)$ by the trace\ntheorem. $H^1_0$ is of course a Hilbert space, whereas $V_g$ is not since it is\nnot closed under addition.\n\nBy using test functions from $H^1_0(\\Omega)$, the weak formulation stays the\nsame as in \\autoref{eq:poisson_weak} however, with solutions $u$ sought in $V_g$.\nTo obtain such a solution: Define the bilinear form $a$ and linear\nfunctional $b$ as before:\n\\begin{equation*}\n  \\begin{split}\n    a(u,v) &= \\int_\\Omega \\nabla u \\cdot \\nabla v \\,dx\\\\\n    b(v)   &= \\int_\\Omega fv\\,dx\n  \\end{split}\n\\end{equation*}\n\nNow choose an arbitrary $\\hat{g}\\in V_g$ and solve:\n\\begin{equation*}\n  a(\\hat{u},v) = b(v) - a(\\hat{g},v) \\quad \\forall v \\in H^1_0(\\Omega)\n\\end{equation*}\nWhere the existence of a unique solution $\\hat{u}$ is guaranteed by Lax-Milgram.\n\nThe weak solution to \\autoref{eq:poisson_dirichlet} is obtained by:\n$$u = \\hat{u} + \\hat{g} \\in V_g$$\n\n\\subsubsection*{Neumann Boundary Conditions}\nTo incorporate Neumann boundary conditions the boundary $\\partial\\Omega$ needs\nto be disjointly split into $\\Gamma_0$ and $\\Gamma_1$, such that\n$\\Gamma_0 \\cup \\Gamma_1 = \\partial\\Omega$ and $\\Gamma_0 \\cap \\Gamma_1 = \\emptyset$.\nThe Poisson equation with mixed Neumann and homogeneous Dirichlet boundary\nconditions can then be stated as:\n\\begin{equation} \\label{eq:poisson_neumann}\n  \\begin{split}\n    -\\Delta u &= f  \\text{ in } \\Omega \\\\\n    u &= 0 \\text{ on } \\Gamma_0 \\\\\n    \\frac{\\partial u}{\\partial n} &= h \\text{ on } \\Gamma_1, \\quad h\\in L^2(\\Gamma_1)\n  \\end{split}\n\\end{equation}\n\nThe weak formulation of \\autoref{eq:poisson_neumann} is given by:\n\\begin{multline}\n  \\int_\\Omega \\nabla u \\cdot \\nabla v\\,dx\n  = \\int_\\Omega fv\\,dx + \\int_{\\Gamma_1}hv\\,dx \\\\\n  \\forall v \\in \\left\\{ v \\in H^1(\\Omega)\\, :\\, v\\vert_{\\Gamma_0} = 0 \\text{ a.e. on } \\Gamma_0\\right\\}\n\\end{multline}\n\nBy application of Lax-Milgram, it can be verified that \\autoref{eq:poisson_neumann}\nadmits a unique, weak solution if $\\int_{\\Gamma_0}1\\,dx > 0$.\nIn the case of pure Neumann conditions Lax-Milgram cannot be applied, since the\nbilinear form is no longer coercive and solutions are only unique up to a constant.\nTo extend this to the case of $u = g$ on $\\Gamma_0$ for some $g \\in L^2(\\Gamma_0)$\nthe same idea used for pure Dirichlet boundary conditions can be used.\n\n\\subsection*{Discretizing the Problem}\nTo obtain numerical solutions to \\autoref{eq:poisson_weak}, the problem has to be\ndiscretized. As by the lecture, the Hilbert space $H^1(\\Omega)$ can be\nsuccessively approximated by some sequence of finite dimensional subspaces\n$(V_i)_{i\\in \\mathbb{N}}$.\\\\\nFor now, the $V_i$ will be the space of piecewise linear, continuous\npolynomials defined on a set of nodes obtain by a triangulation of $\\Omega$.\nUnder the assumption that the triangulation is conforming and no triangles\ncollapse, it has been shown in the lecture that $\\lim\\limits_{i\\to\\infty}V_i \\to\nH^1(\\Omega)$.\n\nBy forcing all basis functions to attain a certain value on the boundary, an\napproximation to the set $V_g$ can be obtained. By forcing them to 0 on the\nboundary, the space $H^1_0(\\Omega)$ can be obtained and\n$\\lim\\limits_{i\\to\\infty}V_i \\to H^1_0(\\Omega)$\n\nThus, the continuous problem $a(u,v) = b(v) \\quad \\forall v \\in H^1_0(\\Omega)$\ncan be approximated by the finite dimensional problem $a(u_i,v_i) = b(v_i)$ for all\nbasis vectors $v_i \\in V_i$ (and explicitly enforcing the 0 boundary condition).\n\nSince there are only a finite number of basis functions, this results in a linear system\nwhere the properties of the system heavily depend on the choice of basis of $V_i$.\n\nIn this work, isoparametric Lagrange elements are chosen as a basis,\nwhich results in a sparse system.\n\n\\section*{Numerical Validation with 1\\textsuperscript{st} Order Piecewise Polynomials}\nDifferent convergence rates, shown in the lecture are given by:\n\\begin{equation}\n  \\begin{split}\n    \\left|u-u_h\\right|_{H^1(\\Omega)} &\\lesssim h \\lVert u\\rVert^2_{H^2(\\Omega)}\\\\\n    \\lVert u - u_h \\rVert_{L^2(\\Omega)} &\\lesssim h\\lVert u\\rVert^2_{H^1(\\Omega)}\\\\\n    \\lVert u - u_h \\rVert_{L^2(\\Omega)} &\\lesssim h^2\\lVert u\\rVert^2_{H^2(\\Omega)}\n  \\end{split}\n\\end{equation}\nWhere $h$ is depended on the grid and $u \\in H^2(\\Omega)$ or $u \\in H^1(\\Omega)$\nis the analytical solution to $a(u,v) = b(v)$.\n$u_h$ is the solution to the discretized problem.\n\n\\subsection*{Smooth Solutions $u \\in H^2$}\nThroughout this report, all numerical experiments concerned with convergence rely\non a gradually refined grid. Here, $n$ will always denote the number of vertices\nper edge on the unit square. Resulting in $n^2$ vertices in total and thus $h \\sim \\frac{1}{n}$.\nHow such refinements for structured and unstructured grids works can be seen in \\autoref{fig:grids}\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{structured_grids}\n    \\caption{Structured Grids}\n  \\end{subfigure}%\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{unstructured_grids}\n    \\caption{Unstructured Grids}\n  \\end{subfigure}\n  \\caption{Grid Refinements for $n=4$ and $n=6$}\n  \\label{fig:grids}\n\\end{figure}\n\nConsidering the following problem:\n\\begin{equation}\n  \\label{eq:smooth_poisson_prob}\n  \\begin{split}\n    \\Omega &= \\left[0,1\\right]^2\\\\\n    -\\Delta u &= f\\\\\n    u &= 0 \\quad \\text{on } \\partial \\Omega\\\\\n  \\end{split}\n\\end{equation}\n\nWith given solution\n\\begin{multline*}\n  u(x,y) = 2^{4a} x^a (1-x)^a y^a (1-y)^a \\quad a \\in \\mathbb{N}\\\\\n  u \\in H^2(\\Omega)\\,\\forall a > 0\n\\end{multline*}\nand $f$ accordingly.\nThis solution has the useful property\n$$\\lVert u \\rVert_{H^2(\\Omega)} \\sim a.$$\nThis makes it ideal to verify the above convergence rates.\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{contour_1}\n    \\caption{$a = 1$}\n  \\end{subfigure}%\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{contour_10}\n    \\caption{$a = 10$}\n  \\end{subfigure}\n  \\caption{Solution $u$ with varying parameter $a$}\n  \\label{fig:smooth_dirichlet_solution}\n\\end{figure}\n\nAs seen in \\autoref{fig:smooth_dirichlet_solution}, $u$ is a smooth bump\nfunction where the steepness increases with $a$.\nWe expect a convergence rate of order $C\\cdot h$ for the $H^1$ semi-norm\nand $C\\cdot h^2$ for the $L^2$ norm since $u \\in H^2(\\Omega) \\forall a > 0$.\nC is expected to increase with $a$ as it should stand in some relation to $\\lVert u \\rVert_{H^2}$.\nFor both, structured (\\ref{fig:smooth_dirichlet_errs_str}) and unstructured (\\ref{fig:smooth_dirichlet_errs_unstr})\ngrids exactly this is observed.\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=1\\linewidth]{errors_smooth_reg}\n    \\caption{Structured Grids}\n    \\label{fig:smooth_dirichlet_errs_str}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=1\\linewidth]{errors_smooth_irreg}\n    \\caption{Unstructured Grids}\n    \\label{fig:smooth_dirichlet_errs_unstr}\n  \\end{subfigure}\n  \\label{fig:smooth_dirichlet_errs}\n  \\caption{$L^2$ Norm and $H^1$ Semi-Norm Errors for Smooth Solutions on Structured and Unstructured Grids}\n\\end{figure}\n\nWhere the overall error of the solution on the unstructured grid is significantly worse.\nThis is due to the fact, that no special care has been taken to attain a good quality mesh.\n\n\n\\subsection*{Less Regular Forces}\nConsidering the following problem with mixed Dirichlet and Neumann boundary conditions.\n\\begin{equation}\n  \\label{eq:poisson_less_smooth_prob}\n  \\begin{split}\n    \\Omega &= \\left[-1,1\\right]^2\\\\\n    -\\Delta u &= \\begin{cases}\n      \\frac{\\pi^2}{4} \\operatorname{cos}\\left(\\frac{\\pi}{2} \\cdot y\\right) \\quad &x \\le 0\\\\\n      \\frac{\\pi^2}{4} \\operatorname{cos}\\left(\\frac{\\pi}{2} \\cdot y\\right) - a\\left(a-1\\right)x^{a-2} \\quad &x > 0\n    \\end{cases}\\\\\n    u(x,y) &= 0 \\quad \\text{on } [-1,0] \\times -1 \\cup [-1,0] \\times 1\\\\\n    u(x,y) &= x^a \\quad \\text{on } (0,1] \\times -1 \\cup (0,1] \\times 1\\\\\n    \\frac{\\partial u}{\\partial {\\bf n}} &= 0 \\quad \\text{on } -1 \\times (-1,1)\\\\\n    \\frac{\\partial u}{\\partial {\\bf n}} &= a \\quad \\text{on } 1 \\times (-1,1)\n  \\end{split}\n\\end{equation}\nWith known solution:\n\\begin{equation*}\n  u(x,y) = \\begin{cases}\n    \\operatorname{cos}\\left(\\frac{\\pi}{2} \\cdot y\\right) \\quad &x \\le 0\\\\\n    \\operatorname{cos}\\left(\\frac{\\pi}{2} \\cdot y\\right) + x^a \\quad &x > 0\n  \\end{cases}\n\\end{equation*}\n\nWhere\n$$u \\in H^{a+0.5 - \\epsilon}(\\Omega) \\quad \\forall \\epsilon > 0.$$\nWith increasing $a$, the function $\\Delta u$ will develop a singularity along the $x = 0$ line.\n\\begin{equation}\n  \\begin{split}\n    a \\le 1: \\quad &u \\notin C^0(\\Omega)\\\\\n    1 < a \\le 1.5: \\quad &u \\in H^1(\\Omega), u \\notin H^2(\\Omega) \\\\\n    1.5 < a: \\quad &u\\in H^2(\\Omega)\n  \\end{split}\n\\end{equation}\n$a > 1$ is needed, so the interpolation operator is well-defined, and our established\nconvergence estimates make sense.\nThe varying regularity of the boundary conditions does not pose a problem, since only\nsquare integrability for both, the Neumann, and Dirichlet Boundary is needed.\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{contour_nonsmooth_1}\n    \\caption{$a = 1.1$}\n  \\end{subfigure}%\n  \\begin{subfigure}{.5\\linewidth}\n    \\centering\n    \\includegraphics[width=.9\\linewidth]{contour_nonsmooth_2}\n    \\caption{$a = 2$}\n  \\end{subfigure}\n  \\caption{Solution $u$ with varying parameter $a$}\n  \\label{fig:non_smooth_mixed_solution}\n\\end{figure}\n\nIn the $H^1$ semi-norm, linear convergence is expected for $1.5 < a$.\nFor $1 < a \\le 1.5$ we have $u \\notin H^2(\\Omega)$ and linear convergence in the $L^2$ norm at best.\nAnd for $1.5 < a$ quadratic convergence in the $L^2$ norm at best.\nHowever, the theorem guaranteeing a convergence estimates in its precise form states:\n\\begin{multline}\n    \\exists n \\in \\mathbb{N}: \\, \\lVert u - u_h \\rVert_{L^2} \\in \\mathcal{O}\\left(h\\right), \\\\ \\forall h < \\frac{1}{n}, u \\in H^1(\\Omega)\n\\end{multline}\n\\begin{multline}\n    \\exists n \\in \\mathbb{N}: \\, \\lVert u - u_h \\rVert_{L^2} \\in \\mathcal{O}\\left(h^2\\right), \\\\ \\forall h < \\frac{1}{n}, u \\in H^2(\\Omega)\n\\end{multline}\nThis threshold is likely to increase with less regularity of the solution. So a more natural\nexpectation is for the convergence rate to increase with increasing $a$.\n\n\nExactly linear convergence is observed in \\autoref{fig:err_nonsmooth_h1} for the $H^1$ semi-norm and $1.5 < a$.\nFor $a = 1.3$, it still appears to converge but at a rate of $\\mathcal{O}\\left(h^{0.6}\\right)$.\n\nIn \\autoref{fig:err_nonsmooth_l2} it can be observed how the convergence rate depends on the regularity of the solution.\nFor the highly irregular solution with $a = 1.3$, linear convergence is only given during the first steps.\nA similar behaviour is observed for $1.5 < a < 2.2$ where quadratic convergence is expected, but only given\nduring the first steps.\nTruly quadratic convergence can only be observed for $2.2 < a$.\nThe estimated convergence rates are not exactly observed for the borderline cases.\nThis could be a hint to the fact that our estimates should be improved, or the needed threshold from where on the\nconvergence sets in is not reached if the function is only just in the needed space.\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_nonsmooth_h1}\n    \\caption{Convergence in the $H^1$ Semi-Norm}\n    \\label{fig:err_nonsmooth_h1}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_nonsmooth_l2}\n    \\caption{Convergence in the $L^2$ Norm}\n    \\label{fig:err_nonsmooth_l2}\n  \\end{subfigure}\n  \\caption{Convergence With Varying Regularity of the Solution}\n\\end{figure}\n\n\n\\subsection*{Higher Order Elements}\nTo increase the accuracy of the solution on a coarser mesh, a polynomial basis\nof higher order can be chosen.\nThis may be achieved by considering higher order local basis functions defined on the reference element.\nSo far, linear basis functions had been considered. These local basis functions are visualized in \\autoref{fig:p1_2d_mesh_basis}.\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=.9\\linewidth]{p1_2d_mesh_basis}\n  \\caption{Polynomial Basis of Degree 1 on 2-Simplex}\n  \\label{fig:p1_2d_mesh_basis}\n\\end{figure}\n\nTo obtain a basis for the entire space on the mesh, those local basis functions are mapped to each simplex.\nGlobal continuity is ensured by joining enough nodes on the boundaries of adjacent simplexes.\n3 basis functions of the function space defined on the entire mesh are visualized in \\autoref{fig:p1_2d_stitch_basis}.\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=.9\\linewidth]{p1_2d_stitch_basis}\n  \\caption{3 Piecewise Linear Basis Functions of the Function Space defined on the entire Grid}\n  \\label{fig:p1_2d_stitch_basis}\n\\end{figure}\n\n\nGeneralizing this approach to higher order Polynomials requires the definition of higher order polynomial\nbasis functions on the reference element. For this\n$$N_p = \\frac{(p+d)!}{p! \\cdot d!}$$\nnodes have to be chosen on each element. Where $p$ is the degree of the polynomial basis and $d$ is the spatial dimension.\n\nTo ensure regularity along adjacent simplexes on the mesh,\n$$\\tilde{N}_{p} = \\frac{(p+(d-1))!}{p!\\cdot(d-1)!}$$\nnodes have to lie on each boundary segment of the reference simplex.\n\nExemplary local basis functions for $p=2$ and $p=3$ are visualized in \\autoref{fig:higher_order_basis}.\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{.49\\linewidth}\n    \\includegraphics[width=1\\linewidth]{p2_basis}\n    \\caption{$p=2$ Local Basis Function}\n  \\end{subfigure}\\hfill%\n  \\begin{subfigure}{.49\\linewidth}\n    \\raggedright\n    \\includegraphics[width=1\\linewidth]{p3_basis}\n    \\caption{$p=3$ Local Basis Function}\n  \\end{subfigure}\n  \\caption{Higher Order Local Basis Functions}\n  \\label{fig:higher_order_basis}\n\\end{figure}\n\nTo compare how higher order elements perform compared to their linear counterparts,\nthe same numerical experiments as for the piecewise linears will be repeated with higher order elements.\n\nThe following estimate for the convergence rates of $p$\\textsuperscript{th} order\nelements has been established during the lecture:\n\\begin{equation}\n  \\label{eq:conv_high_order}\n  \\lVert u - u_h \\rVert_{L^2} \\lesssim h^{k'} \\lVert u \\rVert_{H^{k'+1}}\n\\end{equation}\nWhere $k' = \\operatorname{min}\\left(p,m\\right)$ and $m$ is the largest integer s.t. $u \\in H^{m+1}$.\n\nBy using Problem (\\ref{eq:smooth_poisson_prob}) and (\\ref{eq:poisson_less_smooth_prob})\nagain, the parameter $a$ can be adjusted easily to verify the above convergence\nrate for higher order elements.\n\n\\subsubsection*{Smooth Solutions}\nUsing the problem (\\ref{eq:smooth_poisson_prob}) with $a = 5$ we have $u \\in H^k(\\Omega) \\forall k \\in \\mathbb{N}$.\nThus, a convergence rate of $ \\sim h^{p+1}$ for a polynomial basis of arbitrary degree $p$ in the $L^2$ norm is expected.\nThis is verified on a regular grid in \\autoref{fig:err_smooth_highorder_l2}.\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_smooth_highorder_h1}\n    \\caption{Convergence in the $H^1$ Semi-Norm}\n    \\label{fig:err_smooth_highorder_h1}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_smooth_highorder_l2}\n    \\caption{Convergence in the $L^2$ Norm}\n    \\label{fig:err_smooth_highorder_l2}\n  \\end{subfigure}\n  \\caption{Convergence With Smooth Solutions and Higher Order Elements}\n\\end{figure}\n\nAlthough, no specific error bound for the $H^1$ semi-norm was given, the experiments in \\autoref{fig:err_smooth_highorder_h1} suggest,\nthat under the same assumptions as in \\autoref{eq:conv_high_order}, we see convergence in $H^1$ semi-norm\nwith one order less.\n\nIt can be observed, that basis functions of degree $8$ and $10$ do converge very fast.\nHowever, they stop increasing in accuracy after just a few refinement steps which is probably due to other numerical errors\nassociated with bad conditioning of the Vandermonde matrix and its inverse used to evaluate the basis functions.\n\n\\subsubsection*{Varying Regularity}\nBy, again, considering Problem (\\ref{eq:poisson_less_smooth_prob}) and altering $a$, the different\nconvergence rates for varying regularity can be studied for local bases of different degrees.\nThe convergence estimate (\\ref{eq:conv_high_order}) tells that for less regular solutions,\nthe convergence rate is not expected to increase when using higher order polynomials.\nThis is observed in \\autoref{fig:err_ridge_l2}.\n\n\nAs in the smooth case, convergence in the $H^1$ semi-norm is also given at one order less than in the $L^2$ norm.\nEven though no such convergence rate had been theoretically established.\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_26_l2}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_36_l2}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_46_l2}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_66_l2}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_106_l2}\n  \\end{subfigure}\n\n  \\caption{Convergence With Increasing Smoothness and Higher Order Elements}\n  \\label{fig:err_ridge_l2}\n\\end{figure}\n\n\n\\begin{figure}[H]\n  \\centering\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_26_h1}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_36_h1}\n  \\end{subfigure}\n\n  \\begin{subfigure}{1\\linewidth}\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{errors_ridge_46_h1}\n  \\end{subfigure}\n\n  \\caption{$H^1$ Semi-Norm Convergence With Increasing Smoothness and Higher Order Elements}\n  \\label{fig:err_ridge_h1}\n\\end{figure}\n\n\n\\subsection*{Numerical Challenges}\n\\subsubsection*{Choice of Basis}\nAn important step, is the choice of basis functions on the reference element, and how to represent this basis.\nIn this report, Lagrange elements of varying degree have been used.\nThese are defined by a set of distinct nodes $X \\coloneqq \\left\\{x_i \\in \\mathbb{R}^d, i = 1,\\cdots, N_p\\right\\}$ on the reference element.\nAnd the $N_p$ basis functions are defined as:\n$$\\Phi_i(x_j) = \\delta_{i,j}.$$\nWhere certain restrictions apply on how many nodes must be placed on the boundary.\n\nAs the so defined basis does not allow for point evaluation at arbitrary points on the reference element,\nthose $\\Phi_i$ must be explicitly computed.\nOne now has two choices to make: Where to place the nodes, and in which polynomial basis to represent the $\\Phi_i$.\nThe most obvious and popular choice, which was also used in this work, is using equally spaced nodes and the monomial\nbasis for $\\Phi_i$.\n\nTo obtain $\\Phi_i$ in the monomial basis, one could compute the inverse of the Vandermonde matrix evaluated at all\nnodes $x_i \\in X$. Unfortunately, the condition number of the Vandermonde matrix in monomial basis increases rapidly\nas seen in \\autoref{fig:vandermonde_cond}. For higher order elements this introduces a significant error in the point evaluation\nwhich then propagates to the integration process and thus the solution.\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=1\\linewidth]{vandermonde_cond}\n  \\caption{Condition Number of Vandermonde Matrix for increasing Polynomial Degree}\n  \\label{fig:vandermonde_cond}\n\\end{figure}\n\n\\subsubsection*{Singularities}\nFor weak solutions of \\autoref{eq:poisson_weak} to exist, it suffices for the rhs to be square integrable.\nThus, $f$ could potentially be infinite at any countably many points\nand point-evaluation of $f$ is not well-defined. However, the integration schemes employed by this\nimplementation are based on quadrature rules, which rely on point-evaluation. This is remedied by\nsimply setting all infinite values to $0$, which represents $f$ by a different function from\nthe same equivalence class, thus not changing the equation. And the numerical experiments suggest, that\nthis will still lead to convergence to the right solution. As long as only a few points are affected.\n\nNumerical evidence suggests, that elements spanning the singularity give better convergence as seen in\n\\autoref{fig:oscilation}. Where for odd $n$ vertices are placed on the singularity and for $n$ even they are placed right next to it.\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=1\\linewidth]{oscilation}\n  \\caption{Oscillating Error depending on meshing of the singularity}\n  \\label{fig:oscilation}\n\\end{figure}\n\n\n\\subsubsection*{Submanifolds}\nAs outlined during the Wednesday lectures, the entire theory is also applicable to immersed manifolds.\nAs long as they are in some sense well-behaved.\n\\begin{wrapfigure}{r}{0.5\\linewidth}\n  \\begin{center}\n    \\includegraphics[width=1\\linewidth]{submanifold}\n    \\caption{Solution for Smooth Bump Equation on Submanifold}\n  \\end{center}\n\\end{wrapfigure}\nThe code has been adapted to allow the definition of finite element function spaces on submanifolds.\nHowever, the standard reference elements are not well suited for this, because the curvature of the\nsubmanifold is lost during the triangulation process.\n\nAn alternative could be to use non-linear mappings from the reference simplex to the mesh elements.\nThis complicates the integration process a lot, since the pullbacks to the reference element become\ncomputationally harder to evaluate.\n\n\\subsection*{Conclusion}\nThe Code has been verified by a variety of different problems.\nUsing different boundary conditions, varying regularity of the force function\nand differently structured grids.\n\nThe given convergence estimates are exactly met, when expecting solutions clearly falling\ninto the needed class of functions.\nWhen using borderline cases, where the solution is only just about regular enough,\nor just not regular enough any more, the convergence estimates are only exactly met\nfor a finite amount of steps before the convergence slightly deviates from the expected rate.\nAs this only happens for edge cases and given the roughness of the estimates, this is not worrying.\n\n\nTo further optimize the implementation, the integration of non-linear transforms of reference elements could be\nconsidered for immersed submanifolds.\nTo optimize the implementation speed, the global node numbering algorithm should be reconsidered\nto optimize the sparsity pattern of the resulting matrix and to optimize memory access.\n\nBut as a proof of concept and a tool to investigate convergence rates of higher order elements,\nthis implementation is well suited.\n\n\\end{multicols}\n\\end{document}\n", "meta": {"hexsha": "7cbba9f0d6262cdefd376208cca301ecc304a5c1", "size": 29852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/main.tex", "max_stars_repo_name": "PaulStryck/fem", "max_stars_repo_head_hexsha": "df4267989adae58193cc589529e8d9443ecb7cbd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/main.tex", "max_issues_repo_name": "PaulStryck/fem", "max_issues_repo_head_hexsha": "df4267989adae58193cc589529e8d9443ecb7cbd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/main.tex", "max_forks_repo_name": "PaulStryck/fem", "max_forks_repo_head_hexsha": "df4267989adae58193cc589529e8d9443ecb7cbd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2234794908, "max_line_length": 139, "alphanum_fraction": 0.7347916388, "num_tokens": 8794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.43687770880547433}}
{"text": "\\documentclass[]{article}\n\n\\author{Braden Fineberg}\n\\usepackage[pdftex]{graphicx}\n\\usepackage{achicago}\n\\usepackage{fullpage}\n\\usepackage{ amssymb }\n\\usepackage{amsmath} \n%\\usepackage[top=1in, bottom=1in, left= 1 in, right=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage[nopar]{lipsum} % for dummy text\n\\newcommand{\\HRule}{\\rule{\\linewidth}{0.25mm}}\n\n\\usepackage{listings}\n\\usepackage{subfig}\n\\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white\n\\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue\n\\definecolor{mylilas}{RGB}{170,55,241}\n\\renewcommand\\thesection{\\Alph{section}}\n\n\n\\begin{document}\n\t\n\t\\lstset{language=Matlab,%\n\t\t%basicstyle=\\color{red},\n\t\tbreaklines=true,%\n\t\tmorekeywords={matlab2tikz},\n\t\tkeywordstyle=\\color{blue},%\n\t\tmorekeywords=[2]{1}, keywordstyle=[2]{\\color{black}},\n\t\tidentifierstyle=\\color{black},%\n\t\tstringstyle=\\color{mylilas},\n\t\tcommentstyle=\\color{mygreen},%\n\t\tshowstringspaces=false,%without this there will be a symbol in the places where there is a space\n\t\tnumbers=left,%\n\t\tnumberstyle={\\tiny \\color{black}},% size of the numbers\n\t\tnumbersep=9pt, % this defines how far the numbers are from the text\n\t\temph=[1]{for,end,break},emphstyle=[1]\\color{red}, %some words to emphasise\n\t\t%emph=[2]{word1,word2}, emphstyle=[2]{style},  \n\t\tbasicstyle=\\tiny,  \n\t}\n\n\\input{../title.tex} \n\n\\section{Derivation of (3) and (4)}\n\nGiven the fact that the price of a stock can be viewed as a random walk, a form of Brownian Motion, we know that there is some likelihood that tomorrows close price will move up or down in a roughly normal distribution. This concept, combined with the Markovian nature of stock movements allows us to assume that the price is Brownian. Now given the fact that the price is Brownian, with mean $\\mu h$ and variance $\\sigma^2 h$, we know that the expected change in the stocks price tomorrow is $\\mu h$. The equations of (3) and (4) compute the unbiased mean and variance of the Brownian motion over time by looking at independent (due to Markovian stock prices) days of stock change. They capitalize on the central limit theory to compute an expected mean and variance normalized by the number of samples and a scalar h.\n\n\\section{Determination of drift and volatility}\nDrift and volatility are the difference of two logs. Using the following code, I calculated mu and sigma.\n\n\\begin{lstlisting}\ndrift = log(close_price(2:end)) - log(close_price(1:end-1));\nN = length(drift);\nh = 1/365; %stock prices close one day apart\n\nmu = sum(drift)/(N*h);\nmu\n\nsigma = sum((drift-mu*h).^2)/((N-1)*h);\nsigma\n\\end{lstlisting}\n\nThe calculated mean is 0.6275. The variance is 0.2174.\n\n\\section{Is Geometric Brownian motion a good model?}\nUsing the following code, I tested normality. I found the QQ-Plot to be most informative. This data can be considered normal, but it is not strongly normal.\n\n\\begin{lstlisting}\nclose all;\nx = -.12:.01:.12;\nn = histcounts(drift, x);\n\nfigure();\nbar(x(1:end-1), n/N/.01);\nxlim([-.12 .12]);\nhold on;\nnorm = normpdf(x,mu*h,sqrt(sigma*h));\nplot(x, norm, 'linewidth', 2, 'color','r')\ntitle('Normalized Daily Drift vs. Expected Brownian');\nsaveas(gcf, 'brownianHist.png');\n\nfigure();\nqqplot(drift);\ntitle('QQ Plot to Test Normality');\nsaveas(gcf, 'qqplot.png');\n\\end{lstlisting}\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\begin{minipage}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\linewidth]{qqplot}\n\t\t\\caption{Determining Brownian Fit}\n\t\t\\label{fig:test1}\n\t\\end{minipage}%\n\t\\begin{minipage}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\linewidth]{brownianHist}\n\t\t\\caption{Normalized Distribution}\n\t\t\\label{fig:test2}\n\t\\end{minipage}\n\\end{figure}\n \n\n\\section{Expected return}\nExpected return is the log ratio of the return from investing today (t=0) and some future time t minus the market rate. This will determine the premium return. \n\n\\begin{align}\nE(return) =& log(\\frac{X(t)e^{-\\alpha t}}{X(0)})\\\\\n=& (\\mu + \\sigma^2/2 - \\alpha)t\\\\\n=& (0.6275+ 0.2174/2 - 0.375)t\\\\\n=& 0.6987 \\qquad \\square\n\\end{align}\n\nThe likelihood of seeing a 5\\% return next year would require an actual rate of return of 8.75\\%. Given the fact that we can approximate this using Brownian motion, the probability of the return being greater than 8.75\\% can be written as:\n\n\\begin{align}\nP\\{return > .0875\\} =& 1-\\Phi(\\frac{.0875 - 0.6275}{\\sqrt{ 0.2174}})\\\\\n=& 1-\\Phi(-1.15814)\\\\\n=& 87.66\\%\n\\end{align}\n\n\\section{Risk neutral measure}\nRisk, or beta, is essentially a measure of volatility of the stock above market rate. It can be equated as:\n$$\\alpha - \\sigma^2/2 = .0375 - 0.2174/2 = -0.0712$$\n\nThe volatility of the stock remains 0.2174.\n\n\\section{Expected return for risk neutral measure}\nGiven that the expectation of risk-neutral return, $\\mu$, is negative, I would choose not to invest, therefore, my return would be \\$0. I would instead invest in the market and see a return of $\\alpha$, 3.75\\%.\n\n\\section{Derive Black-Scholes formula}\n\n\\begin{align}\n\\mathbb{E}_q[e^{-\\alpha t }[X(t)-K]^+-c]=&0\\\\\nc =& e^{-\\alpha t } \\mathbb{E}_q[X(t)-K]^+\\\\\n=& e^{-\\alpha t } \\mathbb{E}_q[X_0e^{Y(t)}-K]^+\\\\\n=& e^{-\\alpha t } \\frac{1}{\\sqrt{2\\pi t \\sigma^2}}\\int_{-\\infty}^{\\infty} (X_0e^{Y(t)}-K)^+e^{\\frac{-(y-(\\mu t)^2)}{2t\\sigma^2}}\\\\\n=& e^{-\\alpha t } \\frac{1}{\\sqrt{2\\pi t \\sigma^2}}\\int_{log(K/X_0)}^{\\infty} (X_0e^{Y(t)}-K)^+e^{\\frac{-(y-(\\mu t)^2)}{2t\\sigma^2}}\\\\\n\\text{Given the following change of variabeles:}&\\\\\n\\text{let } z =  (y - \\mu t)/\\sqrt{t\\sigma^2}&\\\\\ny = \\sqrt{t\\sigma^2}z + \\mu t&\\\\\ndy = \\sqrt{t\\sigma^2}dz&\\\\\n\\text{int limit: } a = \\frac{log(K/X_0)-\\mu t}{\\sqrt{t\\sigma^2}}&\\\\\n=& e^{-\\alpha t } \\frac{1}{\\sqrt{2\\pi}}\\int_{a}^{\\infty} (X_0e^{\\sqrt{t\\sigma^2}z + \\mu t}-K)^+e^{\\frac{z^2}{2}}dz\\\\\nlet \\quad l1 =& \\frac{1}{\\sqrt{2\\pi}}\\int_{a}^{\\infty} (X_0e^{\\sqrt{t\\sigma^2}z + \\mu t})e^{\\frac{z^2}{2}}dz\\\\\n=& \\frac{X_0e^{\\mu t+t\\sigma^2/2}}{\\sqrt{2\\pi}}\\int_{a}^{\\infty} e^{-(z-\\sqrt{t\\sigma^2})/2)}dz\\\\\n\\text{Given a change of variables: }=& \\\\\nlet \\qquad u = z-\\sqrt{t\\sigma^2}&\\\\\ndu = dz&\\\\\n\\text{int limit: } b = \\frac{log(K/X_0)-\\mu t}{\\sqrt{t\\sigma^2}} - \\sqrt{t\\sigma^2}&\\\\\n=& \\frac{X_0e^{\\mu t+t\\sigma^2/2}}{\\sqrt{2\\pi}}\\int_{b}^{\\infty} e^{-u/2}du\\\\\n=&X_0e^{\\mu t+t\\sigma^2/2}Q(b)\\\\\nlet \\quad l2 =&\\frac{K}{\\sqrt{2\\pi}}\\int_{a}^{\\infty}e^{\\frac{z^2}{2}}dz = KQ(a)\\\\\nc =& e^{-\\alpha t }(l1-l2) = e^{-\\alpha t }(X_0e^{\\mu t+t\\sigma^2/2}Q(b) - KQ(a))\\\\\nc=& X_0Q(a - \\sqrt{t \\sigma^2}) - e^{-\\alpha t }KQ(a) \\qquad \\square\n\\end{align}\n\n\\section{Determine option price}\n\nUsing the following code, I determined c to be 0.7190, 0.2941, and 0.1243 for K =0.8, 1, 1.2 respectively.\n\n\\begin{lstlisting}\nalph = .0375;\n\nX0 = close_price(1);\nEx = X0*exp(mu+var/2);\nK = [0.8 1 1.2]*Ex;\nc = zeros(1, length(K));\nrisk_nuetral = alph - var/2;\n\nfor k=K\na = (log(k/X0)-risk_nuetral)/sqrt(var);\nb = a - sqrt(var);\nQA = 1-normcdf(a, 0, 1);\nQB = 1 - normcdf(b, 0, 1);\n\nc(K==k) = X0*QB-exp(-alph)*k*QA;\nend\n\ndisp(option_price);\n\\end{lstlisting}\n\n\\end{document}\n", "meta": {"hexsha": "bc75be18a8c1e03e2c6709a6452ade3a1f8086e8", "size": 6951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homework13.tex", "max_stars_repo_name": "bfine9618/BlackScholesPricing", "max_stars_repo_head_hexsha": "0c3b3c8db3072a47b323147cd5d8f8c96d6bf73a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homework13.tex", "max_issues_repo_name": "bfine9618/BlackScholesPricing", "max_issues_repo_head_hexsha": "0c3b3c8db3072a47b323147cd5d8f8c96d6bf73a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homework13.tex", "max_forks_repo_name": "bfine9618/BlackScholesPricing", "max_forks_repo_head_hexsha": "0c3b3c8db3072a47b323147cd5d8f8c96d6bf73a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.572972973, "max_line_length": 819, "alphanum_fraction": 0.6760178392, "num_tokens": 2526, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.8104789086703225, "lm_q1q2_score": 0.43683453249456977}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Bollinger Bands} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{Bollinger Bands developed by John Bolinger in the 1980s, is a technical indicator that is used to identify when an asset is overbought and oversold. The bands comprise a volatility indicator that measures the relative high or low of a security’s price in relation to previous trades. It is comprised of the upper, middle, and lower band which envelopes the price range levels. An asset is considered oversold when it breaks below the lower band and considered overbought when it breaks above the upper band.\n}\n\n\\howtotrade\n{The strategy is to identify asset's price cycles.\nBullish Reversal - when Price is above the upper band \\&\nBearish Reversal - when Price is below the lower band.\n}\n\n\\ruleparameters %You can include however many arguments (in groups of 4) as you want!\n{Look Back Length}{20}{Look back length used to compute MA.}{$\\lookbacklength$}\n{Number of standard deviations}{2}{Number of standard deviation used to compute Bollinger Band limits.}{$m$}\n\\stoptable %must be included or Tex engine runs infinitely\n\n\\newpage\n\\section{Equation}\nBelow are the equations which govern how this specific trading rule calculates a trading position.\n\n\\begin{equation}\n    P_{n} = \\frac{H_{n} + L_{n} + C_{n}}{3}\n\\end{equation}\n\\begin{equation}\n    MA(P_{n}, n) = \\frac{1}{n} \\sum_{i = 1}^{n} P_{i}\n\\end{equation}\n\\begin{equation}\n    B_{u} = MA(P_{n}, \\lookbacklength) + m \\times \\sigma[P_{n}, \\lookbacklength]\n\\end{equation}\n\\begin{equation}\n    B_{l} = MA(P_{n}, \\lookbacklength) - m \\times \\sigma[P_{n}, \\lookbacklength]\n\\end{equation}\n\\\\ % creates some space after equation\nwhere:\n\n$P_{n}$: is the price at $n$th period.\n\n$H_{n}$: is the highest price at $n$th period.\n\n$L_{n}$: is the lowest price at $n$th period.\n\n$C_{n}$: is the closing period at $n$th period.\n\n$m$: is the number of standard deviations.\n\n$\\sigma[P_{n}, \\lookbacklength]$: is the standard deviation in $P_{n}$ within \\lookbacklength \\ periods.\n\n\\keyterms\n\\furtherlinks %The footer\n\\end{document}", "meta": {"hexsha": "499255d6cfe21d4367169743a6ef0e165b499de9", "size": 2211, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/BollingerBand.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/BollingerBand.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/BollingerBand.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 38.1206896552, "max_line_length": 524, "alphanum_fraction": 0.7440072365, "num_tokens": 633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832058771035, "lm_q2_score": 0.8104789109591831, "lm_q1q2_score": 0.436834521724564}}
{"text": "%\n% Licensed to the OpenAirInterface (OAI) Software Alliance under one or more\n% contributor license agreements.  See the NOTICE file distributed with\n% this work for additional information regarding copyright ownership.\n% The OpenAirInterface Software Alliance licenses this file to You under\n% the OAI Public License, Version 1.1  (the \"License\"); you may not use this file\n% except in compliance with the License.\n% You may obtain a copy of the License at\n%\n%      http://www.openairinterface.org/?page_id=698\n%\n% Unless required by applicable law or agreed to in writing, software\n% distributed under the License is distributed on an \"AS IS\" BASIS,\n% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n% See the License for the specific language governing permissions and\n% limitations under the License.\n%-------------------------------------------------------------------------------\n% For more information about the OpenAirInterface (OAI) Software Alliance:\n%      contact@openairinterface.org\n%\n\n\\documentclass{article}\n\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{booktabs}\n\\usepackage{url}\n\\usepackage{tcolorbox}\n\n\\usepackage{tikz}\n\\usetikzlibrary{arrows,decorations,shapes,backgrounds,patterns}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=newest}\n\\definecolor{green}{RGB}{32,127,43}\n\\usetikzlibrary{calc}\n\n\\usepackage{listings}\n\\lstdefinestyle{customc}{\n  belowcaptionskip=1\\baselineskip,\n  breaklines=true,\n  frame=L,\n  xleftmargin=\\parindent,\n  language=C,\n  showstringspaces=false,\n  basicstyle=\\footnotesize\\ttfamily,\n  keywordstyle=\\bfseries\\color{green!40!black},\n  commentstyle=\\itshape\\color{purple!40!black},\n  identifierstyle=\\color{blue},\n  stringstyle=\\color{orange},\n}\n\\lstset{escapechar=@,style=customc}\n\n\\title{NR LDPC Decoder}\n\\author{Sebastian Wagner (TCL)}\n\\date{\\today}\n\n\\def\\0{\\mathbf{0}}\n\\def\\b{\\mathbf{b}}\n\\def\\Bbb{\\mathbb{B}}\n\\def\\Bcal{\\mathcal{B}}\n\\def\\c{\\mathbf{c}}\n\\def\\C{\\mathbf{C}}\n\\def\\Cbb{\\mathbb{C}}\n\\def\\Ccal{\\mathcal{C}}\n\\def\\eqdef{\\triangleq}\n\\def\\g{\\mathbf{g}}\n\\def\\G{\\mathbf{G}}\n\\def\\Gcal{\\mathcal{G}}\n\\def\\h{\\mathbf{h}}\n\\def\\H{\\mathbf{H}}\n\\def\\Hbg{\\mathbf{H}_\\mathrm{BG}}\n\\def\\Hbgo{\\mathbf{H}_\\mathrm{BG1}}\n\\def\\Hbgt{\\mathbf{H}_\\mathrm{BG2}}\n\\def\\I{\\mathbf{I}}\n\\def\\Kb{{K_b}}\n\\def\\m{\\mathbf{m}}\n\\def\\Mb{{M_b}}\n\\def\\Nb{{N_b}}\n\\def\\Nbb{\\mathbb{N}}\n\\def\\n{\\mathbf{n}}\n\\def\\nr{{n_{\\rm r}}}\n\\def\\nt{{n_{\\rm t}}}\n\\def\\s{\\mathbf{s}}\n\\def\\SNR{\\mathsf{SNR}}\n\\def\\y{\\mathbf{y}}\n\\def\\z{\\mathbf{z}}\n\\def\\Z{\\mathbf{Z}}\n\\def\\Zc{{Z_c}}\n\n\n\\def\\herm{\\mathsf{H}}\n\\def\\trans{\\mathsf{T}}\n\\def\\EE{\\mathsf{E}}\n\\newcommand{\\sgn}{\\operatorname{sgn}}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{tikzpicture}[remember picture,overlay]\n   \\node[anchor=north west,inner sep=0pt] at (current page.north west)\n              {\\includegraphics[scale=0.5]{logo.png}};\n\\end{tikzpicture}\n\n\n\\begin{center}Currently Supported:\\end{center}\n\\tcbox[center]{\n    \\begin{tabular}{lll}\n      \\toprule\n      \\textbf{BG} & \\textbf{Lifting Size Z} & \\textbf{Code Rate R} \\\\\n      \\midrule\n        1 & all & 1/3, 2/3, 8/9 \\\\\n        2 & all & 1/5, 1/3, 2/3 \\\\\n      \\bottomrule\n    \\end{tabular}\n}\n\n\\tableofcontents\n\n\\newpage\n\\section{Introduction}\n\\label{sec:introduction}\n\nLow Density Parity Check (LDPC) codes have been developed by Gallager in 1963 \\cite{gallager1962low}. They are linear error correcting codes that are capacity-achieving for large block length and are completely described by their Parity Check Matrix (PCM) $\\H^{M\\times N}$. The PCM $\\H$ defines $M$ constraints on the codeword $\\c$ of length $N$ such that\n\\begin{equation}\n  \\label{eq:29}\n  \\H\\c = \\0.\n\\end{equation}\nThe number of information bits $B$ that can be encoded with $\\H$ is given by $B=N-M$. Hence the code rate $R$ of $\\H$ reads\n\\begin{equation}\n  \\label{eq:37}\n  R = \\frac{B}{N} = 1-\\frac{M}{N}.\n\\end{equation}\n\n\n\\subsection{LDPC in NR}\n\\label{sec:ldpc-nr}\n\nNR uses quasi-cyclic (QC) Protograph LDPC codes, i.e. a smaller graph, called Base Graph (BG), is defined and utilized to construct the larger PCM. This has the advantage that the large PCM does not have to be stored in memory and allows for a more efficient implementation while maintaining good decoding properties.\nTwo BGs $\\Hbg\\in\\Nbb^{\\Mb\\times \\Nb}$ are defined in NR:\n\\begin{enumerate}\n\\item $\\Hbgo\\in\\Nbb^{46\\times 68}$\n\\item $\\Hbgt\\in\\Nbb^{42\\times 52}$\n\\end{enumerate}\nwhere $\\Nbb$ is the set of integers. For instance the first 3 rows and 13 columns of BG2 are given by\n\n\\setcounter{MaxMatrixCols}{30}\n\\begin{equation*}\n  \\label{eq:33}\n  \\Hbgt =\n  \\begin{bmatrix}\n    9   & 117       & 204       & 26  & \\emptyset & \\emptyset & 189       & \\emptyset & \\emptyset & 205       & 0         & 0         & \\emptyset & \\emptyset \\\\\n    127 & \\emptyset & \\emptyset & 166 & 253       & 125       & 226       & 156       & 224       & 252       & \\emptyset & 0         & 0         & \\emptyset \\\\\n    81  & 114       & \\emptyset & 44  & 52        & \\emptyset & \\emptyset & \\emptyset & 240       & \\emptyset & 1         & \\emptyset & 0         & 0\n  \\end{bmatrix}.\n\\end{equation*}\n\nTo obtain the PCM $\\H$ from the BG $\\Hbg$, each element $\\Hbg(i,j)$ in the BG is replaced by a lifting matrix of size $\\Zc\\times \\Zc$ according to\n\\begin{equation}\n  \\label{eq:35}\n  \\Hbg(i,j) =\n  \\begin{cases}\n    \\0 & \\textrm{if}~ \\Hbg(i,j)=\\emptyset \\\\\n    \\I_{P_{ij}} & \\textrm{otherwise}\n  \\end{cases}\n\\end{equation}\nwhere $\\I_{P_{ij}}$ is the identity matrix circularly shifted to the right by $P_{ij} = \\Hbg(i,j)\\mod \\Zc$. Hence, the resulting PCM $\\H$ will be of size $\\Mb\\Zc\\times\\Nb\\Zc$.\n\nThe lifting size $\\Zc$ depends on the number of bits to encode. To limit the complexity, a discrete set $\\mathcal{Z}$ of possible values of $\\Zc$ has been defined in \\cite{3gpp2017_38212} and the optimal value $\\Zc$ is calculated according to\n\\begin{equation}\n  \\label{eq:36}\n  \\Zc = \\min_{\\Z\\in\\mathcal{Z}}\\left[Z\\geq\\frac{B}{\\Nb}\\right].\n\\end{equation}\n\nThe base rate of the two BGs is $1/3$ and $1/5$ for BG1 and BG2, respectively. That is, BG1 encodes $K=22\\Zc$ bits and BG2 encodes $K=10\\Zc$ bits. Note that the first 2 columns of BG 1 and 2 are always punctured, that is after encoding, the first $2\\Zc$ bits are discarded and not transmitted.\nFor instance, consider $B=500$ information bits to encode using BG2, \\eqref{eq:36} yields $\\Zc=64$ hence $K=640$. Since $K>B$, $K-B=140$ filler bits are appended to the information bits. The PCM $\\Hbgt$ is of size $2688\\times 3328$ and the $640$ bits $\\b$ are encoded according to \\eqref{eq:29} at a rate $R \\approx 0.192$. To achieve the higher base rate of $0.2$, the first $128$ are punctured, i.e. instead of transmitting all $3328$ bits, only $3200$ are transmitted resulting in the desired rate $R=640/3200=0.2$.\n\n\\subsection{LDPC Decoding}\n\\label{sec:ldpc-decoding}\n\nThe decoding of codeword $\\c$ can be achieved via the classical message passing algorithm. This algorithm can be illustrated best using the Tanner graph of the PCM. The rows of the PCM are called check nodes (CN) since they represent the parity check equations. The parity check equation of each of these check nodes involves various bits in the codeword. Similarly, every column of the PCM corresponds to a bit and each bit is involved in several parity check equations. In the Tanner graph representation, the bits are called bit nodes (BN). Let's go back to the previous example of BG2 and assume $\\Zc=2$, hence the first 3 rows and 13 columns of BG2 $\\Hbgt$ read\n\\begin{equation*}\n  \\label{eq:36}\n  \\Hbgt =\n  \\begin{bmatrix}\n    1 & 1         & 0         & 0 & \\emptyset & \\emptyset & 1         & \\emptyset & \\emptyset & 1         & 0         & 0         & \\emptyset & \\emptyset \\\\\n    1 & \\emptyset & \\emptyset & 0 & 1         & 1         & 0         & 0         & 0         & 0         & \\emptyset & 0         & 0         & \\emptyset \\\\\n    1 & 0         & \\emptyset & 0 & 0         & \\emptyset & \\emptyset & \\emptyset & 0         & \\emptyset & 1         & \\emptyset & 0         & 0\n  \\end{bmatrix}.\n\\end{equation*}\nReplacing the elements according to \\eqref{eq:35}, we obtain the first 6 rows and 26 columns of the PCM as\n\\begin{equation*}\n  \\label{eq:39}\n  \\H =\n  \\begin{bmatrix}\n    0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\\\\n    1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n    0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0\\\\\n    1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0\\\\\n    0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0\\\\\n    1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 1\n  \\end{bmatrix}.\n\\end{equation*}\n\nThe Tanner graph of the first 8 BNs is shown in Figure \\ref{fig:tannergraph}.\n\n\\begin{figure}[ht]\n  \\label{fig:tannergraph}\n  \\centering\n  \\def\\ww{0.3cm}\n  \\def\\hh{0.3cm}\n  \\tikzstyle{cnode}=[fill=white,rectangle,draw=black,thick,inner sep=2pt, minimum height=\\hh,minimum width=\\ww, rounded corners=1pt,text width=\\ww]\n  \\tikzstyle{vnode}=[fill=white,circle,draw=black,thick,inner sep=2pt, minimum height=\\hh,minimum width=\\ww, rounded corners=1pt,text width=\\ww]\n  \\tikzstyle{connector}=[<->,>=latex',semithick]\n\n  \\begin{tikzpicture}\n    \\tikzstyle{every node}=[node distance=1.5cm,text centered]\n    % Check nodes\n    \\node[cnode, label=above:$v_0$] (v0) {};\n    \\node[cnode, label=above:$v_1$, right of=v0] (v1) {};\n    \\node[cnode, label=above:$v_2$, right of=v1] (v2) {};\n    % Variable nodes\n    \\node[vnode, label=below:$c_3$, below of=v1, node distance=1.5cm] (c3) {};\n    \\node[vnode, label=below:$c_2$, left of=c3, node distance=1.5cm] (c2) {};\n    \\node[vnode, label=below:$c_1$, left of=c2, node distance=1.5cm] (c1) {};\n    \\node[vnode, label=below:$c_0$, left of=c1, node distance=1.5cm] (c0) {};\n    \\node[vnode, label=below:$c_4$, right of=c3, node distance=1.5cm] (c4) {};\n    \\node[vnode, label=below:$c_5$, right of=c4, node distance=1.5cm] (c5) {};\n    \\node[vnode, label=below:$c_6$, right of=c5, node distance=1.5cm] (c6) {};\n\n    % Draw edges\n    \\draw (c0) edge[connector] (v1);\n    \\draw (c1) edge[connector] (v0);\n    \\draw (c1) edge[connector] (v2);\n    \\draw (c2) edge[connector] (v1);\n    \\draw (c3) edge[connector] (v0);\n    \\draw (c4) edge[connector] (v0);\n    \\draw (c4) edge[connector] (v2);\n    \\draw (c5) edge[connector] (v1);\n    \\draw (c6) edge[connector] (v0);\n    \\draw (c6) edge[connector] (v2);\n\n  \\end{tikzpicture}\n\n  \\caption{Tanner graph for first 7 bits nodes and 3 check nodes from \\eqref{eq:39}.}\n\\end{figure}\n\nThe message passing algorithm is an iterative algorithm where probabilities of the bits (being either 0 or 1) are exchanged between the BNs and CNs. After sufficient iterations, the probabilities will have either converged to either 0 or 1 and the parity check equations will be satisfied, at this point, the codeword has been decoded correctly.\n\n\\newpage\n\\section{LDPC Decoder Implementation}\n\\label{sec:ldpc-implementation}\n\nThe implementation on a general purpose processor (GPP) has to take advantage of potential instruction extension of the processor architecture. We focus on the Intel x86 instruction set architecture (ISA) and its advanced vector extension (AVX). In particular, we utilize AVX2 with its 256-bit single instruction multiple data (SIMD) format. In order to utilize AVX2 to speed up the processing at the CNs and BNs, the corresponding data has to be ordered/aligned in a specific way. The processing flow of the LDPC decoder is depicted in \\ref{fig:ldpc_decoder_flow}.\n\n\\begin{figure}[ht]\n  \\label{fig:ldpc_decoder_flow}\n  \\centering\n  \\def\\ww{0.3cm}\n  \\def\\hh{0.3cm}\n  \\tikzstyle{func}=[,draw=none]\n  \\tikzstyle{connector}=[->,>=latex',semithick]\n\n  \\begin{tikzpicture}\n    \\tikzstyle{every node}=[node distance=2.5cm,text centered]\n    % Check nodes\n    % First iteration\n    \\node[func]                               (llr2llrProcBuf) {\\texttt{llr2llrProcBuf}};\n    \\node[func, above of=llr2llrProcBuf]      (llr2CnProcBuf)  {\\texttt{llr2CnProcBuf}};\n    \\node[func, above right of=llr2CnProcBuf] (cnProc1)        {\\texttt{cnProc}};\n    \\node[func, below right of=cnProc1]       (cn2bnProcBuf1)  {\\texttt{cn2bnProcBuf}};\n    \\node[func, below  of=cn2bnProcBuf1]      (bnProcPc1)      {\\texttt{bnProcPc}};\n\n    % Iterations\n    \\node[func, right of=cnProc1, node distance=7cm] (cnProc)       {\\texttt{cnProc}};\n    \\node[func, below right of=cnProc]               (cn2bnProcBuf) {\\texttt{cn2bnProcBuf}};\n    \\node[func, below of=cn2bnProcBuf]               (bnProcPc)     {\\texttt{bnProcPc}};\n    \\node[func, below left of=cnProc]                (bn2cnProcBuf) {\\texttt{bn2cnProcBuf}};\n    \\node[func, below  of=bn2cnProcBuf]              (bnProc)       {\\texttt{bnProc}};\n\n    % Post processing\n    \\node[func, below of=bnProcPc]      (llrRes2llrOut) {\\texttt{llrRes2llrOut}};\n    \\node[func, below of=llrRes2llrOut, node distance=1cm] (llr2bit) {\\texttt{llr2bit}};\n\n    % Draw edges\n    \\draw (llr2llrProcBuf)  edge[connector] (llr2CnProcBuf);\n    \\draw (llr2CnProcBuf)   edge[connector] (cnProc1);\n    \\draw (cnProc1)         edge[connector] (cn2bnProcBuf1);\n    \\draw (cn2bnProcBuf1)   edge[connector] (bnProcPc1);\n\n    \\draw (bnProcPc)       edge[connector] (bnProc);\n    \\draw (bnProc)         edge[connector] (bn2cnProcBuf);\n    \\draw (bn2cnProcBuf)   edge[connector] (cnProc);\n    \\draw (cnProc)         edge[connector] (cn2bnProcBuf);\n    \\draw (cn2bnProcBuf)   edge[connector] (bnProcPc);\n\n    \\draw (bnProcPc1)      edge[connector] (bnProc);\n\n    \\draw (bnProcPc) edge[connector] node[left] {iterations done} (llrRes2llrOut);\n    \\draw (llrRes2llrOut) edge[connector] (llr2bit);\n\n    % Boxes\n    \\node[inner sep=0pt,above right of=cn2bnProcBuf1, node distance = 2.5cm] (ref) {};\n\n    \\draw[fill=black,opacity=.2, rounded corners] (llr2llrProcBuf.south west) rectangle ($(ref) + (-.5cm,.5cm)$);\n    \\draw[fill=black,opacity=.2, rounded corners] ($(ref) + (.5cm,.5cm)$) rectangle ($(bnProcPc.south east) + (.4cm,0)$);\n\n    \\node[func, above of=cnProc1, node distance=.8cm] (iter1) {\\textbf{First Iteration}};\n    \\node[func, above of=cnProc , node distance=.8cm] (iterX) {\\textbf{Subsequent Iterations}};\n\n  \\end{tikzpicture}\n\n  \\caption{LDPC Decoder processing flow.}\n\\end{figure}\n\nThe functions involved are described in more detail in table \\ref{tab:sum_func}.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{ll}\n    \\toprule\n    \\textbf{Function} & \\textbf{Description} \\\\\n    \\midrule\n    \\texttt{llr2llrProcBuf} & Copies input LLRs to LLR processing buffer \\\\\n    \\texttt{llr2CnProcBuf}  & Copies input LLRs to CN  processing buffer \\\\\n    \\texttt{cnProc}         & Performs CN signal processing \\\\\n    \\texttt{cn2bnProcBuf}   & Copies the CN results to the BN processing buffer \\\\\n    \\texttt{bnProcPc}       & Performs BN processing for parity check and/or hard-decision \\\\\n    \\texttt{bnProc}         & Utilizes the results of \\texttt{bnProcPc} to compute LLRs for CN processing \\\\\n    \\texttt{bn2cnProcBuf}   & Copies the BN results to the CN processing buffer \\\\\n    \\texttt{llrRes2llrOut}  & Copies the results of \\texttt{bnProcPc} to output LLRs \\\\\n    \\texttt{llr2bit}        & Performs hard-decision on the output LLRs \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Summary of the LDPC decoder functions.}\n  \\label{tab:sum_func}\n\\end{table}\n\nThe input LLRs are assumed to be 8-bit and aligned on 32 bytes. CN processing is carried out in 8-bit whereas BN processing is done in 16 bit. Subsequently, the processing tasks at the CNs and BNs are explained in more detail.\n\n\\newpage\n\\subsection{Check Node Processing}\n\\label{sec:check-node-proc}\n\nDenote $q_{ij}$ the value from BN $j$ to CN $i$ and let $\\Bcal_i$ be the set of connected BNs to the $i$th CN. Then, using the min-sum approximation, CN $i$ has to carry out the following operation for each connected BN.\n\\begin{equation}\n  \\label{eq:40}\n  r_{ji} = \\prod_{j'\\in\\Bcal_i\\setminus j}\\sgn q_{ij'}\\min_{j'\\in\\Bcal_i\\setminus j} |q_{ij'}|\n\\end{equation}\nwhere $r_{ji}$ is the value returned to BN $j$ from CN $i$. There are $\\Mb = \\{46,42\\}$ CNs in BG 1 and BG 2, respectively. Each of these CNs is connected to only a small number of BNs. The number of connected BNs to CN $i$ is $|\\Bcal_i|$. In BG1 and BG2, $|\\Bcal_i|=\\{3,4,5,6,7,8,9,10,19\\}$ and $|\\Bcal_i|=\\{3,4,5,6,8,10\\}$, respectively. The following tables show the number of CNs $M_{|\\Bcal_i|}$ that are connected to the same number of BNs.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{llllllllll}\n    \\toprule\n    $|\\Bcal_i|$   & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 19 \\\\\n    \\midrule\n    $M_{|\\Bcal_i|}^\\mathrm{BG1}$ & 1 & 5  &18 & 8 & 5 & 2 & 2 & 1 & 4 \\\\\n    $M_{|\\Bcal_i|}^\\mathrm{BG2}$ & 6 & 20 & 9 & 3 & 0 & 2 & 0 & 2 & 0 \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Ceck node groups for BG1 and BG2.}\n  \\label{tab:checkNodeGroups}\n\\end{table}\n\nIt can be observed that each CN is at least connected to 3 BNs and there are 9 groups and 5 groups in BG1 and BG2, respectively. Denote the set of CN groups as $\\Gcal$ and $M_k$ the number of CNs in group $k\\in\\Gcal$, e.g. for BG2 $M_4=20\\Zc$. Each CN group will be processed separately. The CN processing buffer $p_C^k$ of group $k$ is defined as\n\\begin{equation}\n  \\label{eq:44}\n  p_C^k = \\{\\underbrace{q_{11}q_{21}\\dots q_{M_k 1}}_{\\text 1. BN},\\underbrace{q_{12}q_{22}\\dots q_{M_k 2}}_{\\text 2. BN},\\dots,\\underbrace{q_{12}q_{22}\\dots q_{M_k k}}_{\\text last BN}\\}\n\\end{equation}\nHence, $|p_C^k| = kM_k$, e.g, $\\Zc=128$, $|p_C^4| = 4\\cdot 20\\cdot 128 = 10240$.\n\n\\begin{lstlisting}[frame=single,caption={Example of CN processing for group 3 from \\texttt{cnProc}.},label=code_cnproc]  % Start your code-block\n\n  const uint8_t lut_idxCnProcG3[3][2] = {{72,144}, {0,144}, {0,72}};\n\n  // =====================================================================\n  // Process group with 3 BNs\n\n  // Number of groups of 32 CNs for parallel processing\n  M = (lut_numCnInCnGroups[0]*Z)>>5;\n  // Set the offset to each bit within a group in terms of 32 Byte\n  bitOffsetInGroup = (lut_numCnInCnGroups_BG2_R15[0]*NR_LDPC_ZMAX)>>5;\n\n  // Set pointers to start of group 3\n  p_cnProcBuf    = (__m256i*) &cnProcBuf   [lut_startAddrCnGroups[0]];\n  p_cnProcBufRes = (__m256i*) &cnProcBufRes[lut_startAddrCnGroups[0]];\n\n  // Loop over every BN\n  for (j=0; j<3; j++)\n  {\n    // Set of results pointer to correct BN address\n    p_cnProcBufResBit = p_cnProcBufRes + (j*bitOffsetInGroup);\n\n    // Loop over CNs\n    for (i=0; i<M; i++)\n    {\n      // Abs and sign of 32 CNs (first BN)\n      ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][0] + i];\n      sgn  = _mm256_sign_epi8(*p_ones, ymm0);\n      min  = _mm256_abs_epi8(ymm0);\n\n      // 32 CNs of second BN\n      ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][1] + i];\n      min  = _mm256_min_epu8(min, _mm256_abs_epi8(ymm0));\n      sgn  = _mm256_sign_epi8(sgn, ymm0);\n\n      // Store result\n      min = _mm256_min_epu8(min, *p_maxLLR); // 128 in epi8 is -127\n      *p_cnProcBufResBit = _mm256_sign_epi8(min, sgn);\n      p_cnProcBufResBit++;\n    }\n  }\n\n}\n\\end{lstlisting}\n\nOnce all results of the check node processing $r_{ji}$ have been calculated, they are copied to the bit node processing buffer.\n\n\\subsection{Bit Node Processing}\n\\label{sec:bit-node-processing}\n\nDenote $r_{ji}$ the value from CN $i$ to BN $j$ and let $\\Ccal_j$ be the set of connected CNs to the $j$th BN. Each BN $j$ has to carry out the following operation for every connected CN $i\\in\\Ccal_j$.\n\\begin{equation}\n  \\label{eq:46}\n  q_{ij} = \\Lambda_j + \\sum_{i'\\in\\Ccal_j\\setminus i}r_{ji'}\n\\end{equation}\n\nThere are $\\Nb = \\{68,52\\}$ BNs in BG 1 and BG 2, respectively. Each of these BNs is connected to only a small number of CNs. The number of connected CNs to BN $j$ is $|\\Ccal_j|$. In BG1 and BG2, $|\\Ccal_j|=\\{1,4,7,8,9,10,11,12,28,30\\}$ and $|\\Ccal_j|=\\{1,5,6,7,8,9,10,12,13,14,16,22,23\\}$, respectively. The following tables show the number of BNs $K_{|\\Ccal_j|}$ that are connected to the same number of CNs.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lllllllllllllllllll}\n    \\toprule\n    $|\\Ccal_j|$ & 1&4&5&6&7&8&9&10&11&12&13 & 14 & 15 & 16 & 22 & 23 &28&30 \\\\\n    \\midrule\n    $K_{|\\Ccal_j|}^\\mathrm{BG1}$ & 42 & 1 & 1 & 2 & 4 & 3 & 1 & 4 & 3 & 4 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\\\\n    $K_{|\\Ccal_j|}^\\mathrm{BG2}$ & 38 & 0 & 2 & 1 & 1 & 1 & 2 & 1 & 0 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 0 & 0\\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Bit node groups for BG1 and BG2 for base rates 1/3 and 1/5, respectively.}\n  \\label{tab:bitNodeGroups}\n\\end{table}\n\nThe BNs that are connected to a single CN do not need to be considered in the BN processing since \\eqref{eq:46} yields $q_{ij} = \\Lambda_j$. It can be observed that the grouping is less compact, i.e. there are many groups with only a small number of elements.\n\nDenote the set of BN groups as $\\Bcal$ and $K_k$ the number of BNs in group $k\\in\\Bcal$, e.g. for BG2 $K_5=2\\Zc$. Each BN group will be processed separately. The BN processing buffer $p_B^k$ of group $k$ is defined as\n\\begin{equation}\n  \\label{eq:47}\n  p_B^k = \\{\\underbrace{r_{11}r_{21}\\dots r_{K_k 1}}_{\\text 1. CN},\\underbrace{r_{12}r_{22}\\dots r_{K_k 2}}_{\\text 2. CN},\\dots,\\underbrace{r_{12}r_{22}\\dots r_{K_k k}}_{\\text last CN}\\}\n\\end{equation}\nHence, $|p_B^k| = kK_k$, e.g, $\\Zc=128$, $|p_B^5| = 5\\cdot 2\\cdot 128 = 1024$.\n\nDepending on the code rate, some parity bits are not being transmitted. For instance, for BG2 with code rate $R = 1/3$ the last $20\\Zc$ bits are discarded. Therefore, the last 20 columns or the last $20\\Zc$ parity check equation are not required for decoding. This means that the BN groups shown in table \\ref{tab:bitNodeGroups} are depending on the rate.\n\n\\begin{lstlisting}[frame=single,caption={Example of BN processing for group 3 from \\texttt{bnProcPc}.},label=code_bnproc]  % Start your code-block\n\n  // If elements in group move to next address\n  idxBnGroup++;\n\n  // Number of groups of 32 BNs for parallel processing\n  M = (lut_numBnInBnGroups[2]*Z)>>5;\n\n  // Set the offset to each CN within a group in terms of 16 Byte\n  cnOffsetInGroup = (lut_numBnInBnGroups[2]*NR_LDPC_ZMAX)>>4;\n\n  // Set pointers to start of group 3\n  p_bnProcBuf  = (__m128i*) &bnProcBuf  [lut_startAddrBnGroups   [idxBnGroup]];\n  p_llrProcBuf = (__m128i*) &llrProcBuf [lut_startAddrBnGroupsLlr[idxBnGroup]];\n  p_llrRes     = (__m256i*) &llrRes     [lut_startAddrBnGroupsLlr[idxBnGroup]];\n\n  // Loop over BNs\n  for (i=0,j=0; i<M; i++,j+=2)\n  {\n    // First 16 LLRs of first CN\n    ymmRes0 = _mm256_cvtepi8_epi16(p_bnProcBuf[j]);\n    ymmRes1 = _mm256_cvtepi8_epi16(p_bnProcBuf[j+1]);\n\n    // Loop over CNs\n    for (k=1; k<3; k++)\n    {\n      ymm0 = _mm256_cvtepi8_epi16(p_bnProcBuf[k*cnOffsetInGroup + j]);\n      ymmRes0 = _mm256_adds_epi16(ymmRes0, ymm0);\n\n      ymm1 = _mm256_cvtepi8_epi16(p_bnProcBuf[k*cnOffsetInGroup + j+1]);\n      ymmRes1 = _mm256_adds_epi16(ymmRes1, ymm1);\n    }\n\n    // Add LLR from receiver input\n    ymm0    = _mm256_cvtepi8_epi16(p_llrProcBuf[j]);\n    ymmRes0 = _mm256_adds_epi16(ymmRes0, ymm0);\n\n    ymm1    = _mm256_cvtepi8_epi16(p_llrProcBuf[j+1]);\n    ymmRes1 = _mm256_adds_epi16(ymmRes1, ymm1);\n\n    // Pack results back to epi8\n    ymm0 = _mm256_packs_epi16(ymmRes0, ymmRes1);\n    // ymm0     = [ymmRes1[255:128] ymmRes0[255:128] ymmRes1[127:0] ymmRes0[127:0]]\n    // p_llrRes = [ymmRes1[255:128] ymmRes1[127:0] ymmRes0[255:128] ymmRes0[127:0]]\n    *p_llrRes = _mm256_permute4x64_epi64(ymm0, 0xD8);\n\n    // Next result\n    p_llrRes++;\n  }\n}\n\n\\end{lstlisting}\n\nThe sum of the LLRs is carried out in 16 bit for accuracy and is then saturated to 8 bit for CN processing. Saturation after each addition results in significant loss of sensitivity for low code rates.\n\n\\subsection{Mapping to the Processing Buffers}\n\\label{sec:mapp-cn-proc}\n\nFor efficient processing with the AVX instructions, the data is required to be aligned in a certain manner. That is the reason why processing buffers have been introduced. The drawback is that the results of the processing need to copied every time to the processing buffer of the next task. However, the speed up in computation with AVX more than makes up for the time wasted in copying data. The copying is implemented using look-up tables (LUTs) which are described in table \\ref{tab:sum_lut}.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{ll}\n    \\toprule\n    \\textbf{LUT} & \\textbf{Description} \\\\\n    \\midrule\n    \\texttt{lut\\_llr2llrProcBuf\\_BGX\\_ZX\\_RX} & Indices for function \\texttt{llr2llrProcBuf} \\\\\n    \\texttt{lut\\_llr2CnProcBuf\\_BGX\\_ZX\\_RX}  & Indices for function \\texttt{llr2CnProcBuf} \\\\\n    \\texttt{lut\\_cn2bnProcBuf\\_BGX\\_ZX\\_RX}   & Indices for functions \\texttt{cn2bnProcBuf} and \\texttt{bn2cnProcBuf} \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{Summary of the LUTs.}\n  \\label{tab:sum_lut}\n\\end{table}\n\nThese LUTs are depending on the BG, the lifting size and the code rate. Assuming 5 rates for BG2 and 7 rates for BG1, the total number of LUTs is 617.\n\n\\newpage\n\\section{Performance Results}\n\\label{sec:performance-results}\n\nIn this section, the performance in terms of BLER and decoding latency of the current LDPC decoder implementation is verified.\n\n\\subsection{BLER Performance}\n\\label{sec:bler-performance}\n\nIn all simulations, we assume AWGN, QPSK modulation and 8-bit input LLRs. The results are averaged over at least $10\\,000$ channel realizations.\n\nThe first set of simulations in Figure \\ref{fig:bler-bg2-15} compares the current LDPC decoder implementation to the reference implementation developed by Kien. This reference implementation is called \\textit{LDPC Ref} and uses the min-sum algorithm with 2 layers and 16 bit for processing. Out current optimized decoder implementation is referred to as \\textit{LDPC Opt}. Moreover, reference results provided by Huawei are also shown.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=-4, xmax=2, xtick={-4,-3.5,...,2}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % HUAWEI merged BG2 2017-06-15\n      \\addplot[black, solid] plot coordinates { (-3.91839,0.01) (-3.5567,0.0001) };\n\n      % Kien's 2-layer 16bit code\n      \\addplot[red, solid, mark=o] plot coordinates { (-2.750000,0.915500) (-2.500000,0.576000) (-2.250000,0.165000) (-2.000000,0.017100) (-1.750000,0.000600) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n\n      % LDPC opt with 16bit BN processing\n      \\addplot[blue, solid, mark=square] plot coordinates { (-2.750000,0.998600) (-2.500000,0.953600) (-2.250000,0.718800) (-2.000000,0.299300) (-1.750000,0.053700) (-1.500000,0.005100) (-1.250000,0.000500) (-1.000000,0.000100)};\n\n      % Matlab\n      \\addplot[green, solid, mark=triangle] plot coordinates {(-2.750000,0.318200) (-2.500000,0.135900) (-2.250000,0.102000) (-2.000000,0.092300) (-1.750000,0.079200) (-1.500000,0.063100) (-1.250000,0.041400) (-1.000000,0.029600) (-0.750000,0.017500) (-0.500000,0.011800) (-0.250000,0.006100) (0.000000,0.004100) (0.250000,0.002800) (0.500000,0.000800) (0.750000,0.000300) (1.000000,0.000400) };\n\n\n%      \\addplot[blue, solid, mark=triangle] plot coordinates {(-2.750000,0.997600) (-2.500000,0.961600) (-2.250000,0.815200) (-2.000000,0.628800) (-1.750000,0.586200) (-1.500000,0.572800) (-1.250000,0.507600) (-1.000000,0.376700) (-0.750000,0.262000) (-0.500000,0.157100) (-0.250000,0.087100) (0.000000,0.045400) (0.250000,0.021000) (0.500000,0.010000) (0.750000,0.004400) (1.000000,0.002600) (1.250000,0.000700) (1.500000,0.000500) (1.750000,0.000000) (2.000000,0.000000) (2.250000,0.000000) (2.500000,0.000000) (2.750000,0.000000) (3.000000,0.000000)};\n\n      % 20 iterations\n      \\addplot[red, solid, mark=o] plot coordinates { (-2.750000,0.330300) (-2.500000,0.067800) (-2.250000,0.006000) (-2.000000,0.000100) (-1.750000,0.000000) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n\n      \\addplot[blue, solid, mark=square] plot coordinates {(-2.750000,0.341300) (-2.500000,0.065100) (-2.250000,0.004100) (-2.000000,0.000200) (-1.750000,0.000100) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n\n      % 5 iterations\n\\addplot[red, solid, mark=o] plot coordinates {(-1.250000,0.781300) (-1.000000,0.421000) (-0.750000,0.140400) (-0.500000,0.028900) (-0.250000,0.003300) (0.000000,0.000300) (0.250000,0.000000) (0.500000,0.000000)};\n\\addplot[blue, solid, mark=square] plot coordinates {(-0.250000,0.705000) (0.000000,0.406200) (0.250000,0.181300) (0.500000,0.061600) (0.750000,0.015900) (1.000000,0.004900) (1.250000,0.000900) (1.500000,0.000200)};\n\\addplot[green, solid, mark=triangle] plot coordinates {(-1.000000,0.778900) (-0.500000,0.226400) (0.000000,0.027400) (0.500000,0.002600) (1.000000,0.000300) };\n\n% 30 iterations\n% \\addplot[blue, dashed, mark=square] plot coordinates {(-3.000000,0.623800) (-2.750000,0.224100) (-2.500000,0.031600) (-2.250000,0.001100) (-2.000000,0.000000)};\n\n\n\\draw (axis cs:-3.3,0.1)  node[fill=white,draw=black] (pint0) {20 iter};\n\\draw (axis cs:-2.3,0.01) node[draw,black,thick,ellipse,minimum height=0.3cm] (ell0) {}; \\draw[black,thick] (pint0) -- (ell0);\n\n\\draw (axis cs:0,0.0001)   node[fill=white,draw=black] (pint1) {10 iter};\n\\draw (axis cs:-1.6,0.002) node[draw,black,thick,ellipse,minimum width=0.8cm] (ell1) {}; \\draw[black,thick] (pint1) -- (ell1);\n\n\\draw (axis cs:1.3,0.2)  node[fill=white,draw=black] (pint2) {5 iter};\n\\draw (axis cs:0.3,0.01) node[draw,black,thick,ellipse,minimum width=2cm] (ell2) {}; \\draw[black,thick] (pint2) -- (ell2);\n\n\n      \\legend{ {Huawei 2017-06-15}\\\\\n               {LDPC Ref}\\\\\n               {LDPC Opt}\\\\\n               {MATLAB 5Glib}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG2, Rate=1/5, \\{5,10,20\\} Iterations, B=1280.}\n  \\label{fig:bler-bg2-15}\n\\end{figure}\n\nFrom Figure \\ref{fig:bler-bg2-15} it can be observed that the reference decoder outperforms the current implementation significantly for low to medium number of iterations. The reason is the implementation of 2 layers in the reference decoder, which results in faster convergence for punctured codes and hence requires less iterations to achieve a given BLER target. Note that there is a large performance loss of nearly 6 dB at BLER $10^{-2}$ between the Huawei reference and the current optimized decoder implementation with 5 iterations.\n\nMoreover, there is a gap of about 1.5 dB between the results provided by Huawei and the current decoder with 20 iterations. The reason is the min-sum approximation algorithm used in both the reference decoder and the current implementation. The gap can be closed by using a tighter approximation like the min-sum with normalization or the lambda-min approach. Moreover, the gap closes for higher code rates which can be observed from Figure \\ref{fig:bler-bg2-r23}. The gap is only about 0.6 dB for 50 iterations.\n\nConcerning the LDPC decoder provided by MATLAB, the performance appears to be rather inconsistent. For 5 iterations, the MATLAB decoder outperforms the optimized decoder most likely due to a tighter approximation used in the check node processing. However, it is inferior to the reference algorithm which suggests that the MATLAB decoder is not optimized for punctured LDPC codes, i.e. no layered processing. For 50 iterations the MATLAB LDPC decoder shows a strange behavior, the slope of the BLER curve is not as expected. This suggests that there might be some internal decoder problems with the NR base graph 2.\n\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=3, xmax=5.5, xtick={3,3.5,...,5.5}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % Kien's 2-layer 16bit code\n      %\\addplot[red, solid] plot coordinates { (-2.750000,0.915500) (-2.500000,0.576000) (-2.250000,0.165000) (-2.000000,0.017100) (-1.750000,0.000600) (-1.500000,0.000000) (-1.250000,0.000000) (-1.000000,0.000000)};\n\n      % Huawei\n      \\addplot[black, solid] plot coordinates { (3.28392,0.01) (3.73319,0.0001) };\n\n      % LDPC opt with 16bit BN processing\n      \\addplot[blue, solid, mark=square] plot coordinates {(4.000000,0.487500) (4.250000,0.163400) (4.500000,0.029800) (4.750000,0.002700) (5.000000,0.000100)};\n\n      %\\addplot[blue, dashed, mark=triangle] plot coordinates {(4.000000,0.487500) (4.250000,0.163700) (4.500000,0.030000) (4.750000,0.002900) (5.000000,0.000100)};\n\n      \\addplot[blue, dashed, mark=square] plot coordinates {(3.000000,0.911600) (3.250000,0.614100) (3.500000,0.230100) (3.750000,0.036900) (4.000000,0.001100) (4.250000,0.000000) (4.500000,0.000000)};\n\n\n      \\legend{ {Huawei 2017-06-15}\\\\\n               {LDPC Opt 5 iter}\\\\\n               {LDPC Opt 50 iter}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG2, Rate=2/3, \\{5,50\\} Iterations, B=1280.}\n  \\label{fig:bler-bg2-r23}\n\\end{figure}\n\nFigure \\ref{fig:bler-bg1-r89} shows the performance of BG1 with largest block size of $B=8448$ and highest code rate $R=8/9$.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}\n  \\tikzstyle{every pin}=[fill=white,draw=black]\n    \\pgfplotsset{every axis legend/.append style={\n        cells={anchor=west}, at={(1.05,1)}, anchor=north west}}\n %   \\pgfplotsset{every axis plot/.append style={smooth}}\n    \\pgfplotsset{every axis/.append style={line width=0.5pt}}\n    \\pgfplotsset{every axis/.append style={mark options=solid, mark size=2.5pt}}\n\n    \\begin{semilogyaxis}[title={}, xlabel={$\\SNR$ [dB]}, ylabel={BLER},\n      grid={both}, xmin=6, xmax=11, xtick={6,6.5,...,11}, ymin=0,\n      ymax=1,ytickten={-5,-4,-3,-2,-1,0},legend columns=1]\n\n      % Huawei\n      \\addplot[black, solid] plot coordinates { (6.118717,0.01) (6.291449,0.0001) };\n\n      % LDPC opt 5 iter\n      \\addplot[blue, solid, mark=square] plot coordinates {(8.500000,0.350000) (8.750000,0.155100) (9.000000,0.062400) (9.250000,0.023000) (9.500000,0.008700) (9.750000,0.003500) (10.000000,0.000900) (10.250000,0.000300) };\n\n      % LDPC opt 50 iter\n      \\addplot[blue, dashed, mark=square] plot coordinates {(6.000000,0.705333) (6.100000,0.353367) (6.200000,0.102100) (6.300000,0.015133) (6.400000,0.000967) (6.500000,0.000000)};\n\n\n      \\legend{ {Huawei}\\\\\n               {LDPC Opt 5 iter}\\\\\n               {LDPC Opt 50 iter}\\\\};\n\n    \\end{semilogyaxis}\n  \\end{tikzpicture}\n  \\caption{BLER vs. SNR, BG1, Rate=8/9 \\{5,50\\} Iterations, B=8448.}\n  \\label{fig:bler-bg1-r89}\n\\end{figure}\n\nFrom \\ref{fig:bler-bg1-r89} it can be observed that the performance gap is only about 0.2 dB if 50 iterations are used. However, for 5 iterations there is still a significant performance loss of about 3.4 dB at BLER $10^{-2}$.\n\n\\newpage\n\\subsection{Decoding Latency}\n\\label{sec:decoding-time}\n\nThis section provides results in terms of decoding latency. That is, the time it takes the decoder to to finish decoding for a given number of iterations. To measure the run time of the decoder we use the OAI tool \\texttt{time\\_meas.h}. The clock frequency is about 2.9 GHZ, decoder is run on a single core and the results are averaged over $10\\,000$ blocks.\n\nThe results in Table \\ref{tab:lat-bg2-r15} show the impact of the number of iterations on the decoding latency. It can be observed that the latency roughly doubles if the number of iterations are doubled.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} & \\textbf{Time [$\\mu s$] (5 it)} & \\textbf{Time [$\\mu s$] (10 it)} & \\textbf{Time [$\\mu s$] (20 it)}\\\\\n    \\midrule\n    \\texttt{llr2llrProcBuf} & 1.1   & 1.1   & 1.1   \\\\\n    \\texttt{llr2CnProcBuf}  & 12.4  & 12.0  & 12.0  \\\\\n    \\texttt{cnProc}         & 11.7  & 22.1  & 43.5  \\\\\n    \\texttt{bnProcPc}       & 6.6   & 12.1  & 23.8  \\\\\n    \\texttt{bnProc}         & 4.2   & 8.1   & 16.2  \\\\\n    \\texttt{cn2bnProcBuf}   & 61.3  & 118.3 & 234.9 \\\\\n    \\texttt{bn2cnProcBuf}   & 38.1  & 82.5  & 172.3 \\\\\n    \\texttt{llrRes2llrOut}  & 3.5   & 3.4   & 3.4   \\\\\n    \\texttt{llr2bit}        & 0.2   & 0.1   & 0.1   \\\\\n    \\midrule\n    \\textbf{Total}          & \\textbf{139.4} & \\textbf{260.3} & \\textbf{508.4} \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG2, Z=128, R=1/5, B=1280, LDPC Opt}\n  \\label{tab:lat-bg2-r15}\n\\end{table}\n\nTable \\ref{tab:lat-bg2-i5} shows the impact of the code rate on the latency for a given block size and 5 iterations. It can be observed that the performance gain from code rate 1/3 to 2/3 is about a factor 2.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} & \\textbf{Time [$\\mu s$] (R=1/5)} & \\textbf{Time [$\\mu s$] (R=1/3)} & \\textbf{Time [$\\mu s$] (R=2/3)}\\\\\n    \\midrule\n    \\texttt{llr2llrProcBuf} & 3.2   & 2.9   & 2.6   \\\\\n    \\texttt{llr2CnProcBuf}  & 36.5  & 25.4  & 14.8  \\\\\n    \\texttt{cnProc}         & 33.6  & 25.2  & 13.3  \\\\\n    \\texttt{bnProcPc}       & 17.6  & 10.2  & 4.5   \\\\\n    \\texttt{bnProc}         & 8.5   & 5.4   & 2.5   \\\\\n    \\texttt{cn2bnProcBuf}   & 175.3 & 110.6 & 50.7  \\\\\n    \\texttt{bn2cnProcBuf}   & 106.6 & 71.2  & 36.1  \\\\\n    \\texttt{llrRes2llrOut}  & 10.2  & 6.3   & 3.3   \\\\\n    \\texttt{llr2bit}        & 0.4   & 0.2   & 0.1   \\\\\n    \\midrule\n    \\textbf{Total}          & \\textbf{392.4} & \\textbf{258.0} & \\textbf{128.2} \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG2, Z=384, B=3840, LDPC Opt, 5 iterations}\n  \\label{tab:lat-bg2-i5}\n\\end{table}\n\nTable \\ref{tab:lat-bg1-i5} shows the results for BG1, larges block size and different code rates. The latency difference betwee code rate 1/3 and code rate 2/3 is less than half because upper left corner of the PCM is more dense than the rest of the PCM.\n\n\\begin{table}[ht]\n  \\centering\n  \\begin{tabular}{lrrr}\n    \\toprule\n    \\textbf{Function} &  \\textbf{Time [$\\mu s$] (R=1/3)} & \\textbf{Time [$\\mu s$] (R=2/3)} & \\textbf{Time [$\\mu s$] (R=8/9)}\\\\\n    \\midrule\n    \\texttt{llr2llrProcBuf}  & 5.5   & 4.9   & 4.6  \\\\\n    \\texttt{llr2CnProcBuf}   & 60.6  & 34.1  & 24.4 \\\\\n    \\texttt{cnProc}          & 102.0 & 74.1  & 56.0 \\\\\n    \\texttt{bnProcPc}        & 26.0  & 11.0  & 6.4  \\\\\n    \\texttt{bnProc}          & 15.7  & 7.4   & 4.5  \\\\\n    \\texttt{cn2bnProcBuf}    & 291.0 & 140.8 & 83.1 \\\\\n    \\texttt{bn2cnProcBuf}    & 193.6 & 100.5 & 63.0 \\\\\n    \\texttt{llrRes2llrOut}   & 13.3  & 6.9   & 5.2  \\\\\n    \\texttt{llr2bit}         & 0.4   & 0.2   & 0.2  \\\\\n    \\midrule\n    \\textbf{Total}           & \\textbf{708.9} & \\textbf{380.6} & \\textbf{248.1}\\\\\n    \\bottomrule\n  \\end{tabular}\n  \\caption{BG1, Z=384, B=8448, LDPC Opt, 5 iterations}\n  \\label{tab:lat-bg1-i5}\n\\end{table}\n\nFrom the above results it can be observed that the data transfer between CNs and BNs takes up a significant amount of the run time. However, the performance gain due to AVX instructions in both CN and BN processing is significantly larger than the penalty incurred by the data transfers.\n\n\\section{Parity Check and early stopping Criteria}\nIt is often unnecessary to carry out the maximum number of iterations. After each iteration a parity check \\eqref{eq:29} can be computed and if a valid code word is found the decoder can stop. This functionality has been implemented and the additional overhead is reasonable. The PC is carried out in the CN processing buffer and the calculation complexity itself is negligible. However, for the processing it is necessary to move the BN results to the CN buffer which takes time, the overall overhead is at most $10\\%$ compared to an algorithm without early stopping criteria with the same number of iterations. The PC has to be activated via the define \\texttt{NR\\_LDPC\\_ENABLE\\_PARITY\\_CHECK}.\n\n\n\\section{Conclusion}\n\\label{sec:conclusion}\n\nThe results in the previous sections show that the current optimized LDPC implementation full-fills the requirements in terms of decoding latency for low to medium number of iterations at the expanse of a significant loss in BLER performance. To improve BLER performance, it is recommended to implement a layered algorithm and a min-sum algorithm with normalization. Further improvements upon the current implementation are detailed in the next section.\n\n\\newpage\n\\section{Future Work}\n\\label{sec:future-work}\n\nThe improvements upon the current LDPC decoder implementation can be divided into two categories:\n\\begin{enumerate}\n\\item Improved BLER performance\n\\item Reduced decoding latency\n\\end{enumerate}\n\n\\subsection{Improved BLER Performance}\n\\label{sec:impr-bler-perf}\n\nThe BLER performance can be improved by using a tighter approximation than the min-sum approximation. For instance, the min-sum algorithm can be improved by adding a correction factor in the CN processing . The min-sum approximation in \\eqref{eq:40} is modified as\n\\begin{equation}\n  \\label{eq:50}\n  r_{ji} = \\prod_{j'\\in\\Bcal_i\\setminus j}\\sgn q_{ij'}\\min_{j'\\in\\Bcal_i\\setminus j} |q_{ij'}| + w(q_{ij'})\n\\end{equation}\nThe correction term $w(q_{ij'})$ is defined as\n\\begin{equation}\n  \\label{eq:51}\n  w(q_{ij'}) =\n  \\begin{cases}\n     c & \\textrm{if}~  \\\\\n    -c & \\textrm{if}~ \\\\\n     0 & \\textrm{otherwise}\n  \\end{cases}\n\\end{equation}\nwhere the constant $c$ is of order $0.5$ typically.\n\n\\subsection{Reduced Decoding Latency}\n\\label{sec:reduc-decod-latency}\n\nThe following improvements will reduce the decoding latency:\n\n\\begin{itemize}\n\\item Adapt to AVX512\n\\item Implement 2/3-layers for faster convergence\n\\end{itemize}\n\n\\paragraph{AVX512:}\nThe computations in the CN and BN processing can be further accelerated by using AVX512 instructions. This improvement will speed-up the CN and BN processing by a approximately a factor of 2.\n\n\\paragraph{Layered processing:}\nThe LDPC code in NR always punctures the first 2 columns of the base graph. Hence, the decoder inserts LLRs with value 0 at their place and needs to retrieve those bits during the decoding process. Instead of computing all the parity equations and then passing the results to the BN processing, it is beneficial to first compute parity equations where at most one punctured BN is connected to that CN. If two punctured BNs are connected than according to \\eqref{eq:40}, the result will be again 0. Thus in a first sub-iteration those parity equation are computed and the results are send to BN processing which calculates the results using only those rows in the PCM. In the second sub-iteration the remaining check equation are used.\nThe convergence of this layered approach is much fast since the bit can be retrieved more quickly while the decoding complexity remains the same. Therefore, for a fixed number of iterations the layered algorithm will have a significantly better performance.\n\n\\newpage\n\\bibliographystyle{IEEEtran}\n\\bibliography{./references}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "98497ee4e555c4bc74915503ca59e0a2413d843c", "size": 43754, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_stars_repo_name": "danghoaison91/openairinterface", "max_stars_repo_head_hexsha": "ca28acccb2dfe85a0644d5fd6d379928d89f72a6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_issues_repo_name": "danghoaison91/openairinterface", "max_issues_repo_head_hexsha": "ca28acccb2dfe85a0644d5fd6d379928d89f72a6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "openair1/PHY/CODING/nrLDPC_decoder/doc/nrLDPC/nrLDPC.tex", "max_forks_repo_name": "danghoaison91/openairinterface", "max_forks_repo_head_hexsha": "ca28acccb2dfe85a0644d5fd6d379928d89f72a6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.7798816568, "max_line_length": 734, "alphanum_fraction": 0.6725785071, "num_tokens": 15497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.4367259733135804}}
{"text": "\\section{Model Description}\n\n\n\\subsection{Problem Statement}\n\nThe formulation assumes that there is a rigid hub, with $N_S$ dual-linked solar panels (or appended rigid bodies) and Subscript $i$ is used to indicated the $i_\\text{th}$ pair of solar panels. Figure~\\ref{fig:Flex_Slosh_Figure} displays the frame and variable definitions used for this formulation.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[]{Figures/Flex_Slosh_Figure}\n\t\\caption{Frame and variable definitions used for formulation}\n\t\\label{fig:Flex_Slosh_Figure}\n\\end{figure} \n\nThere are six coordinate frames defined for this formulation. The inertial reference frame is indicated by \\frameDefinition{N}. The body fixed coordinate frame, \\frameDefinition{B}, which is anchored to the hub and can be oriented in any direction. The first solar panel frame, $\\mathcal{S}_{i1}:\\{\\hat{\\bm s}_{i1,1},\\hat{\\bm s}_{i1,2},\\hat{\\bm s}_{i1,3}\\}$, is a frame with its origin located at its corresponding hinge location, $H_{i1}$. The $\\mathcal{S}_{i1}$ frame is oriented such that $\\hat{\\bm{s}}_{i1,1}$ points antiparallel to the center of mass of the first solar panel, $S_{c,i1}$. The $\\hat{\\bm{s}}_{i1,2}$ axis is defined as the rotation axis that would yield a positive $\\theta_{i1}$ using the right-hand rule. The distance from point $H_{i1}$ to point $S_{c,i1}$ is defined as $d_{i1}$. The total length of the first panel is $l_{i1}$ The hinge frame, $\\mathcal{H}_{i1}:\\{\\hat{\\bm h}_{i1,1}, \\hat{\\bm h}_{i1,2}, \\hat{\\bm h}_{i1,3} \\}$, is a frame fixed with respect to the body frame, and is equivalent to the respective $\\mathcal{S}_{i1}$ frame when the corresponding solar panel is undeflected.\n\nThe other two frames $\\mathcal{S}_{i2}$ and $\\mathcal{H}_{i2}$ are frames attached to the second solar panel. The $\\mathcal{H}_{i2}$ frame is located at the joint between the two solar panels and $\\hat{\\bm h}_{i1,2} = \\hat{\\bm h}_{i2,2}$. The $\\hat{\\bm h}_{i2,1}$ completes the definition of the $\\mathcal{H}_{i2}$ frame and can be oriented in any direction while orthogonal to the $\\hat{\\bm h}_{i2,2}$ axis. This allows for the simulation to model undeployed solar panels for example and defines the undeflected direction of the second solar panel. The $\\mathcal{S}_{i2}$ by being equal to the $\\mathcal{H}_{i2}$ when the second solar panel is undeflected from its equilibrium point and rotates about the $\\hat{\\bm h}_{i2,2}$ axis.\n\nThere are a few more key locations that need to be defined. Point $B$ is the origin of the body frame, and can have any location with respect to the hub. Point $B_c$ is the location of the center of mass of the rigid hub.\n\nUsing the variables and frames defined, the following section outlines the derivation of equations of motion for the spacecraft. \n\n\\subsection{Derivation of Equations of Motion - Newtonian Mechanics}\n\n\\subsubsection{Rigid Spacecraft Hub Translational Motion}\n\nFollowing a similar derivation as in previous work \\cite{Allard2016rz}, the derivation begins with Newton's first law for the center of mass of the spacecraft.\n\\begin{equation}\n\t\\ddot{\\bm r}_{C/N} = \\frac{\\bm{F}}{m_{\\text{\\text{sc}}}}\n\t\\label{eq:Newtons1Law}\n\\end{equation}\nUltimately the acceleration of the body frame or point $B$ is desired\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = \\ddot{\\bm r}_{C/N}-\\ddot{\\bm c}\n\t\\label{eq:RcRbacc}\n\\end{equation}\nThe definition of $\\bm{c}$ the location of the center of mass of the entire spacecraft, can be seen in Eq. (\\ref{eq:c}).\n\\begin{equation}\n\t\\bm{c} = \\frac{1}{m_{\\text{sc}}}\\Big[m_{\\text{\\text{hub}}}\\bm{r}_{B_{c}/B} +\\sum_{i=1}^{N_{S}}\\big(m_{\\text{sp}_{i1}}\\bm{r}_{S_{c,i1}/B}+m_{\\text{sp}_{i2}}\\bm{r}_{S_{c,i2}/B}\\big)\\Big]\n\t\\label{eq:c} \n\\end{equation}\nTo find the inertial time derivative of $\\bm{c}$, it is first necessary to find the time derivative of $\\bm{c}$ with respect to the body frame. A time derivative of any vector, $\\bm{v}$, with respect to the body frame is denoted by $\\bm{v}'$; the inertial time derivative is labeled as $\\dot{\\bm{v}}$. The first and second body-relative time derivatives of $\\bm{c}$ can be seen in Eqs. (\\ref{eq:cprime}) and (\\ref{eq:cdprime}).\n\\begin{align}\n\t\\bm{c}' &= \\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\big(m_{\\text{sp}_{i1}}\\bm{r}'_{S_{c,i1}/B}+m_{\\text{sp}_{i2}}\\bm{r}'_{S_{c,i2}/B}\\big)\n\t\\label{eq:cprime}\n\t\\\\\n\t\\bm{c}'' &= \\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\big(m_{\\text{sp}_{i1}}\\bm{r}''_{S_{c,i1}/B}+m_{\\text{sp}_{i2}}\\bm{r}''_{S_{c,i2}/B}\\big)\n\t\\label{eq:cdprime}\n\\end{align}\nThe vector $\\bm{r}_{S_{c,i1}/B}$ is readily defined using the $\\hat{\\bm{s}}_{i,1}$ axis\n\\begin{equation}\n\t\\bm{r}_{S_{c,{i1}}/B} = \t\\bm{r}_{H_{i1}/B} -d_{i1} \\bm{\\hat{s}}_{i1,1}\n\t\\label{eq:rcgspi1}\n\\end{equation}\nThe vector $\\bm{r}_{S_{c,i2}/B}$ is defined similarly\n\\begin{equation}\n\t\\bm{r}_{S_{c,{i2}}/B} = \t\\bm{r}_{H_{i1}/B} -l_{i1} \\bm{\\hat{s}}_{i1,1} - d_{i2}\\bm{\\hat{s}}_{i2,1}\n\t\\label{eq:rcgspi2}\n\\end{equation}\nNow the first and second time derivatives with respect to the body frame of $\\bm{r}_{S_{c,i1}/B}$ are taken\n\\begin{align}\n\t\\bm{r}'_{S_{c,i1}/B} &= d_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3}\n\t\\label{eq:drcgspi1}\n\t\\\\\n\t\\bm{r}''_{S_{c,i1}/B} &= d_{i1} \\bm{\\hat{s}}_{i1,3} \\ddot{\\theta}_{i1} + d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1}\n\t\\label{eq:ddrcgspi1}\n\\end{align}\nSimilarly the body time derivatives of $\\bm{r}_{S_{c,i2}/B}$ are defined in the following\n\\begin{align}\n\t\\bm{r}'_{S_{c,i2}/B} &= l_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)\\bm{\\hat{s}}_{i2,3}\n\t\\label{eq:drcgspi2}\n\t\\\\\n\t\\bm{r}''_{S_{c,i2}/B} &= (l_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2} \\bm{\\hat{s}}_{i2,3}) \\ddot{\\theta}_{i1} + d_{i2} \\bm{\\hat{s}}_{i2,3} \\ddot{\\theta}_{i2} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\n\t\\label{eq:ddrcgspi2}\n\\end{align}\nEqs.~\\eqref{eq:cprime} and ~\\eqref{eq:cdprime} are next reformulated to include these new definitions:\n\\begin{equation}\n\t\\bm{c}' = \\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}\\Big[d_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3}\\Big]+m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)\\bm{\\hat{s}}_{i2,3}\\Big]\\bigg)\n\t\\label{eq:cprime2}\n\\end{equation}\n\\begin{multline}\n\t\\bm{c}'' = \\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\big(\\ddot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3} + \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1}\\big)\\\\\n\t+m_{\\text{sp}_{i2}}\\Big[l_{i1} \\left(\\ddot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3} + \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1}\\right) + d_{i2}\\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big)\\bm{\\hat{s}}_{i2,3} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\bigg)\n\t\\label{eq:cdprime2}\n\\end{multline}\nUsing the transport theorem\\cite{schaub} yields the following definition for $\\ddot{\\bm c}$\n\\begin{equation}\n\t\\ddot{\\bm c} = \\bm{c}'' + 2\\bm\\omega_{\\cal B/N}\\times\\bm{c}'+\\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c}+\\bm\\omega_{\\cal B/N}\\times\\left(\\bm\\omega_{\\cal B/N}\\times\\bm{c}\\right)\n\t\\label{eq:cddot}\n\\end{equation}\nEq.~\\eqref{eq:RcRbacc} is updated to include Eq.~\\eqref{eq:cddot}\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = \\ddot{\\bm r}_{C/N}-\\bm{c}'' - 2\\bm\\omega_{\\cal B/N}\\times\\bm{c}'-\\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c}-\\bm\\omega_{\\cal B/N}\\times\\left(\\bm\\omega_{\\cal B/N}\\times\\bm{c}\\right)\n\t\\label{eq:Rbddot}\n\\end{equation}\nSubstituting Eq.\\eqref{eq:cdprime2} into Eq.\\eqref{eq:Rbddot} and moving the second order state variables to the left hand side results in\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N} + \\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c} +  \\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\bigg(\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]\\ddot{\\theta}_{i1} +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}\\ddot{\\theta}_{i2}\\bigg) \\\\\n\t= \\ddot{\\bm r}_{C/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\bigg) \\\\\n\t- 2\\bm\\omega_{\\cal B/N}\\times\\bm{c}'-\\bm\\omega_{\\cal B/N}\\times\\left(\\bm\\omega_{\\cal B/N}\\times\\bm{c}\\right)\n\t\\label{eq:Rbddot2}\n\\end{multline}\nIntroducing the tilde matrix\\cite{schaub} to replace the cross product operators and multiplying both sides by $m_\\text{sc}$ simplifies the equation to\n\\begin{multline}\n\tm_\\text{sc} \\ddot{\\bm r}_{B/N} -m_\\text{sc} [\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N} +  \\sum_{i=1}^{N_{S}}\\bigg(\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]\\ddot{\\theta}_{i1} +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}\\ddot{\\theta}_{i2}\\bigg) \\\\\n\t= \\bm F - 2m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'- m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\\\\\n\t-\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\bigg) \n\t\\label{eq:Rbddot3}\n\\end{multline}\n\nEquation~\\eqref{eq:Rbddot3} is the translational motion equation and is the first EOM needed to describe the motion of the spacecraft. The following section develops the rotational EOM.\n\n\\subsubsection{Rigid Spacecraft Hub Rotational Motion}\n\nStarting with Euler's equation when the body fixed coordinate frame origin is not coincident with the center of mass of the body\\cite{schaub}\n\\begin{equation}\n\t\\bm{\\dot{H}}_{\\text{sc},B} = \\bm{L}_B+m_{\\text{\\text{sc}}}\\ddot{\\bm r}_{B/N}\\times\\bm{c}\n\t\\label{eq:Euler}\n\\end{equation}\nwhere $\\bm{L}_B$ is the total external torque about point $B$. The definition of the angular momentum vector of the spacecraft about point $B$ is\n\\begin{multline}\n\t\\bm{H}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times\\bm{\\dot{r}}_{B_c/B} \\\\ +\\sum\\limits_{i=1}^{N_S}\\Big( [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} + \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\dot{\\bm r}_{S_{c,i1}/B}\\\\\n\t+ [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} + \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\dot{\\bm r}_{S_{c,i2}/B}\\Big)\n\t\\label{eq:Hb2}\n\\end{multline}\nBoth solar panel inertia's about their center of masses' are assumed to be defined along principal inertia axes and are of the form\n\\begin{equation}\n\t[I_{\\text{sp}_{i1},S_{c,i1}}] = {\\vphantom{\\begin{bmatrix}\n\t\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}} \n\t\\label{eq:IspMatrix}\n\\end{equation}\n\n\\begin{equation}\n\t[I_{\\text{sp}_{i2},S_{c,i2}}] = {\\vphantom{\\begin{bmatrix}\n\t\t\t\tI_{s_{i2,1}} & 0 & 0 \\\\\n\t\t\t\t0 & I_{s_{i2,2}} & 0 \\\\\n\t\t\t\t0 & 0 & I_{s_{i2,3}}\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i2}\\!}{\\begin{bmatrix}\n\t\t\tI_{s_{i2,1}} & 0 & 0 \\\\\n\t\t\t0 & I_{s_{i2,2}} & 0 \\\\\n\t\t\t0 & 0 & I_{s_{i2,3}}\n\t\\end{bmatrix}} \n\\end{equation}\nNow the inertial time derivative of Eq. \\eqref{eq:Hb2} is taken and yields\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times\\ddot{\\bm r}_{B_c/B}\\\\ +\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} + [I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N}\\\\ \n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} +m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\ddot{\\bm r}_{S_{c,i1}/B}\\\\\n\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} + [I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N}\\\\ \n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+ \\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} +m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i2}/B} \\times \\ddot{\\bm r}_{S_{c,i2}/B}\\biggr)\n\t\\label{eq:Hbdot}\n\\end{multline}\nThe terms $\\ddot{\\bm r}_{B_c/B}$, $\\ddot{\\bm r}_{S_{c,i1}/B}$ and $\\ddot{\\bm r}_{S_{c,i2}/B}$ are found using the transport theorem and knowing that $\\bm{r}_{B_c/B}$ is fixed with respect to the body frame.\n\\begin{align}\n\t\\ddot{\\bm r}_{B_c/B} &= \\bm{\\dot{\\omega}}_{\\cal B/N} \\times \\bm{r}_{B_c/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{B_c/B})\n\t\\label{eq:rbddot}\n\t\\\\\n\t\\ddot{\\bm r}_{S_{c,i1}/B} &= \\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\n\t\\label{eq:rsddot}\n\t\\\\\n\t\\ddot{\\bm r}_{S_{c,i2}/B} &= \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\n\t\\label{eq:rsddot2}\n\\end{align}\nIncorporating Eqs.~\\eqref{eq:rbddot} -~\\eqref{eq:rsddot2} into Eq.~\\eqref{eq:Hbdot} results in\n\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times ( \\dot{\\bm\\omega}_{\\cal B/N}\\times \\bm{r}_{B_c/B}) \\\\+ m_{\\text{hub}} \\bm{r}_{B_c/B}\\times\\Big[\\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{B_c/B})\\Big] +\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} + [I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\cal B/N} \\\\+ \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} \n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B}\\\\ + 2 m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\n\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B}\\Big) \\\\+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big[ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\n\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} + [I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\cal B/N} \\\\+ \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} \n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+ \\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B} + 2 m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\\\\\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B}\\Big) +m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big[\\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\\biggr)\n\t\\label{eq:Hbdot3}\n\\end{multline}\t\n\nApplying the parallel axis theorem the following inertia tensor terms are defined as\n\\begin{align}\n\t[I_{\\text{hub},B}] &= [I_{\\text{hub},B_c}] + m_{\\text{hub}}[\\bm{\\tilde{r}}_{B_c/B}] [\\bm{\\tilde{r}}_{B_c/B}]^T\n\t\\label{eq:IHubB}\n\t\\\\\n\t[I_{\\text{sp}_{i1},B}] &= [I_{\\text{sp}_{i1},S_{c,i1}}] + m_{\\text{sp}_{i1}}[\\bm{\\tilde{r}}_{S_{c,i1}/B}] [\\bm{\\tilde{r}}_{S_{c,{i1}}/B}]^T\n\t\\\\\n\t[I_{\\text{sp}_{i2},B}] &= [I_{\\text{sp}_{i2},S_{c,i2}}] + m_{\\text{sp}_{i2}}[\\bm{\\tilde{r}}_{S_{c,i2}/B}] [\\bm{\\tilde{r}}_{S_{c,{i2}}/B}]^T\n\t\\\\\n\t[I_{\\text{sc},B}] &= [I_{\\text{hub},B}] + \\sum\\limits_{i=1}^{N_S}\\Big( [I_{\\text{sp}_{i1},B}] + [I_{\\text{sp}_{i2},B}]\\Big)\n\t\\label{eq:IscB}\n\\end{align}\nBecause the tilde matrices are skew-symmetric, taking the body-relative time derivative of Equation~\\eqref{eq:IscB} yields\n\\begin{multline}\n\t[I'_{\\text{sc},B}] = \\sum\\limits_{i=1}^{N_S} \\Big[[I'_{\\text{sp}_{i1},S_{c,i1}}] - m_{\\text{sp}_{i1}}\\left([\\bm{\\tilde{r}}'_{S_{c,{i1}}/B}] [\\bm{\\tilde{r}}_{S_{c,{i1}}/B}] + [\\bm{\\tilde{r}}_{S_{c,{i1}}/B}] [\\bm{\\tilde{r}}'_{S_{c,{i1}}/B}]\\right)\\\\\n\t+[I'_{\\text{sp}_{i2},S_{c,i2}}] - m_{\\text{sp}_{i2}}\\left([\\bm{\\tilde{r}}'_{S_{c,{i2}}/B}] [\\bm{\\tilde{r}}_{S_{c,{i2}}/B}] + [\\bm{\\tilde{r}}_{S_{c,{i2}}/B}] [\\bm{\\tilde{r}}'_{S_{c,{i2}}/B}]\\right)\\Big]\n\t\\label{eq:IprimeScB}\n\\end{multline}\n$[I'_{\\text{sp}_{i1},S_{c,i1}}]$ needs to be defined and can be conveniently expressed by leveraging the assumption that the inertia matrix is diagonal (as seen in Eq. \\eqref{eq:IspMatrix}) and is written in terms of its base vectors:\n\\begin{equation}\n\t[I_{\\text{sp}_{i1},S_{c,i1}}] = I_{s_{i1,1}}\\hat{\\bm s}_{i1,1}\\hat{\\bm s}_{i1,1}^{T}+I_{s_{i1,2}}\\hat{\\bm s}_{i1,2}\\hat{\\bm s}_{i1,2}^{T}+I_{s_{i1,3}}\\hat{\\bm s}_{i1,3}\\hat{\\bm s}_{i1,3}^{T}\n\t\\label{eq:iprime}\n\\end{equation}\nTaking the body time derivative of Eq.~\\eqref{eq:iprime} results in\n\\begin{multline}\n\t[I'_{\\text{sp}_{i1},S_{c,i1}}] = I_{s_{i1,1}}\\hat{\\bm s}'_{i1,1}\\hat{\\bm s}_{i1,1}^{T}+I_{s_{i1,1}}\\hat{\\bm s}_{i1,1}\\hat{\\bm s}_{i1,1}'^{T}+I_{s_{i1,2}}\\hat{\\bm s}'_{i1,2}\\hat{\\bm s}_{i1,2}^{T}\\\\\n\t+I_{s_{i1,2}}\\hat{\\bm s}_{i1,2}\\hat{\\bm s}_{i1,2}'^{T}+I_{s_{i1,3}}\\hat{\\bm s}'_{i1,3}\\hat{\\bm s}_{i1,3}^{T}+I_{s_{i1,3}}\\hat{\\bm s}_{i1,3}\\hat{\\bm s}_{i1,3}'^{T}\n\t\\label{eq:iprime2}\n\\end{multline}\nUsing the transport theorem for each basis vector, j, in the $\\bm{\\hat{s}}_{i1}$ frame: $\\hat{\\bm s}'_{i1,j} = \\bm\\omega_{\\cal{S}_{\\textit{i1}}/\\cal{B}}\\times\\hat{\\bm s}_{i1,j}=\\dot{\\theta}_{i1}\\hat{\\bm s}_{i1,2}\\times\\hat{\\bm s}_{i1,j}$, applying this to Eq.~\\eqref{eq:iprime2}, evaluating the cross products, and simplifying results in\n\\begin{equation}\n\t[I'_{\\text{sp}_{i1},S_{c,i1}}] = \\dot{\\theta}_{i1}(I_{s_{i1,3}}-I_{s_{i1,1}})(\\hat{\\bm s}_{i1,1}\\hat{\\bm s}_{i1,3}^{T}+\\hat{\\bm s}_{i1,3}\\hat{\\bm s}_{i1,1}^{T})\n\t\\label{eq:iprime3}\n\\end{equation}\n\nApplying the same methodology for $[I'_{\\text{sp}_{i2},S_{c,i2}}]$ and using the following definition: $\\hat{\\bm s}'_{i2,j} = \\bm\\omega_{\\cal{S}_{\\textit{i2}}/\\cal{B}}\\times\\hat{\\bm s}_{i2,j}=\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2} \\big)\\hat{\\bm s}_{i2,2}\\times\\hat{\\bm s}_{i2,j}$ results in \n\\begin{equation}\n\t[I'_{\\text{sp}_{i2},S_{c,i2}}] = \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big)(I_{s_{i2,3}}-I_{s_{i2,1}})(\\hat{\\bm s}_{i2,1}\\hat{\\bm s}_{i2,3}^{T}+\\hat{\\bm s}_{i2,3}\\hat{\\bm s}_{i2,1}^{T})\n\t\\label{eq:iprime4}\n\\end{equation}\nSubstituting Eq.~\\eqref{eq:iprime3} and Eq.~\\eqref{eq:iprime4} into Eq.~\\eqref{eq:Hbdot3} and using Eq.~\\eqref{eq:IscB} to simplify results in Eq.~\\eqref{eq:Hbdot4}. The Jacobi Identity, $(\\bm a \\times \\bm b)\\times \\bm c = \\bm a \\times (\\bm b\\times \\bm c) - \\bm b \\times (\\bm a\\times \\bm c)$, is used to combine terms.\\\\\nFactoring out $\\dot{\\bm\\omega}_{\\cal B/N}$ and, selectively, $\\bm{\\omega}_{\\cal B/N}$ and utilizing the tilde matrix transforms Eq. \\ref{eq:Hbdot3} into Eq. \\ref{eq:Hbdot17} so that $[I_{\\text{sc},B}]$ can be extracted.\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = \\bigg([I_{\\text{hub},B_c}]  - m_{\\text{hub}} [\\tilde{\\bm{r}}_{B_c/B}] [\\tilde{\\bm{r}}_{B_c/B}] + \n\t\\sum\\limits_{i=1}^{N_S} \\Big([I_{\\text{sp}_{i1},S_{c,i1}}]+ [I_{\\text{sp}_{i2},S_{c,i2}}] - m_{\\text{sp}_{i1}} [\\tilde{\\bm{r}}_{S_{c,i1}/B}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}]   \\Big)\\bigg)\\dot{\\bm\\omega}_{\\cal B/N}\t+ \\bm\\omega_{\\cal B/N} \\times \\bigg([I_{\\text{hub},B_c}] - m_{\\text{hub}} [\\tilde{\\bm{r}}_{B_c/B}] [\\tilde{\\bm{r}}_{B_c/B}] + \\\\\n\t\\sum\\limits_{i=1}^{N_S}\\Big(  [I_{\\text{sp}_{i1},S_{c,i1}}]+ [I_{\\text{sp}_{i2},S_{c,i2}}] - m_{\\text{sp}_{i1}} [\\tilde{\\bm{r}}_{S_{c,i1}/B}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\Big) \\bigg) \\bm\\omega_{\\cal B/N} \\\\ \n\t+\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} \n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B} \\\\\n\t+ 2 m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} \n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+ \\\\\n\t\\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B} + 2 m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\\biggr)\n\t\\label{eq:Hbdot17}\n\\end{multline}\n$[I_{\\text{sc},B}]$ is substituted in from Eq. \\ref{eq:IHubB} through Eq. \\ref{eq:IscB}:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{sc},B}]\\dot{\\bm\\omega}_{\\cal B/N}\t+ \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\ \n\t+\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} \n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B} \\\\\n\t+ 2 m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} \n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+ \\\\\n\t\\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B} + 2 m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\\biggr)\n\t\\label{eq:Hbdot18}\n\\end{multline}\nSplitting the doubled terms:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{sc},B}]\\dot{\\bm\\omega}_{\\cal B/N}\t+ \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\ \n\t+\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N} + m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\t\\\\\n\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B}\n\t+ m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N} \\\\\n\t+ m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} + \n\t\\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B} + m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\\biggr)\n\t\\label{eq:Hbdot19}\n\\end{multline}\nUsing the Jacobi Identity again, followed by tilde matrix substitution:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{sc},B}]\\dot{\\bm\\omega}_{\\cal B/N}\t+ \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\ \n\t+\\sum\\limits_{i=1}^{N_S} \\biggl( [I'_{\\text{sp}_{i1},S_{c,i1}}] \\bm\\omega_{\\cal B/N}  - m_{\\text{sp}_{i1}}\\Big([\\tilde{\\bm{r}}_{S_{c,i1}/B}][\\tilde{\\bm{r'}}_{S_{c,i1}/B}] + [\\tilde{\\bm{r'}}_{S_{c,i1}/B}][\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\Big)\\bm\\omega_{\\cal B/N}\t\n\t+ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B} \n\t+ m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\Big( \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big)\t\\\\\n\t+ [I'_{\\text{sp}_{i2},S_{c,i2}}] \\bm\\omega_{\\cal B/N}  - m_{\\text{sp}_{i2}}\\Big([\\tilde{\\bm{r}}_{S_{c,i2}/B}] [\\tilde{\\bm{r'}}_{S_{c,i2}/B}] + [\\tilde{\\bm{r'}}_{S_{c,i2}/B}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}]                 \\Big)  \\bm\\omega_{\\cal B/N}      \n\t+ \\big(\\ddot{\\theta}_{i1} + \\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B} + m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\Big(\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big)\\biggr)\n\t\\label{eq:Hbdot20}\n\\end{multline}\nFactoring out $\\bm\\omega_{\\cal B/N}$, and substituting in from Eq. \\ref{eq:IprimeScB} leaves:\t\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} + [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t+  \\sum\\limits_{i=1}^{N_S} \\bigg[ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B}\n\t+m_{\\text{sp}_{i1}} \\bm\\omega_{\\cal B/N} \\times \\left(\\bm{r}_{S_{c,i1}/B} \\times \\bm{r}'_{S_{c,i1}/B}\\right)\\\\\n\t+\\big(\\ddot{\\theta}_{i1}+\\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+ \\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B}\n\t+m_{\\text{sp}_{i2}} \\bm\\omega_{\\cal B/N} \\times \\left(\\bm{r}_{S_{c,i2}/B} \\times \\bm{r}'_{S_{c,i2}/B}\\right)\\bigg]\n\t\\label{eq:Hbdot4}\n\\end{multline}\nEqs. (\\ref{eq:Euler}) and (\\ref{eq:Hbdot4}) are equated and yield\n\\begin{multline}\n\t\\bm{L}_B+m_{\\text{sc}}\\ddot{\\bm r}_{B/N}\\times\\bm{c} = [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} + [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t+  \\sum\\limits_{i=1}^{N_S} \\bigg[ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} \\bm{r}_{S_{c,i1}/B} \\times \\bm{r}''_{S_{c,i1}/B}\n\t+m_{\\text{sp}_{i1}} \\bm\\omega_{\\cal B/N} \\times \\left(\\bm{r}_{S_{c,i1}/B} \\times \\bm{r}'_{S_{c,i1}/B}\\right)\\\\\n\t+\\big(\\ddot{\\theta}_{i1}+\\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+ \\bm\\omega_{\\cal B/N} \\times \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+m_{\\text{sp}_{i2}} \\bm{r}_{S_{c,i2}/B} \\times \\bm{r}''_{S_{c,i2}/B}\n\t+m_{\\text{sp}_{i2}} \\bm\\omega_{\\cal B/N} \\times \\left(\\bm{r}_{S_{c,i2}/B} \\times \\bm{r}'_{S_{c,i2}/B}\\right)\\bigg]\n\t\\label{eq:Hbdot5}\n\\end{multline}\nFinally, using tilde matrix and simplifying yields the modified Euler equation, which is the second EOM necessary to describe the motion of the spacecraft.\n\\begin{multline}\n\t[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} = -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} -  \\sum\\limits_{i=1}^{N_S} \\bigg[ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}\\\\\n\t+ [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B}\n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\\\\\n\t+\\big(\\ddot{\\theta}_{i1}+\\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+ [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B}\\bigg]\n\t+ \\bm{L}_B - m_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N}\n\t\\label{eq:Final5}\n\\end{multline}\nHowever, it is desirable to place the second order state variables on the left hand side of the equation. Performing some rearranging of Eq.~\\eqref{eq:Final5} results in an intermediate step. \n\\begin{multline}\n\tm_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N} + [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i=1}^{N_S} \\bigg[ \\ddot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B}\\\\\n\t+\\big(\\ddot{\\theta}_{i1}+\\ddot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \n\t+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\\bigg] = -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\\n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\\\\\n\t+ [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B}\\bigg]\n\t+ \\bm{L}_B \n\t\\label{eq:Finalint}\n\\end{multline}\nThen, the second order terms are factored out:\n\\begin{multline}\n\tm_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N} + [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i=1}^{N_S} \\bigg[\\Big(\n\tI_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \\\\\n\t+m_{\\text{sp}_{i2}} l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i1,3}\n\t+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\Big) \\ddot{\\theta}_{i1}\n\t+\\Big(I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2} \n\t+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big) \\ddot{\\theta}_{i2} \\bigg]\\\\\n\t= -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\dot{\\theta}_{i1} I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} d_{i1} \\dot{\\theta}_{i1}^2 [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\n\t\\\\+m_{\\text{sp}_{i2}} l_{i1} \\dot{\\theta}_{i1}^2 [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i1,1}\n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\n\t+ [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t\\\\\n\t+m_{\\text{sp}_{i2}} d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2 [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,1}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B}\\bigg]\n\t+ \\bm{L}_B\n\t\\label{eq:Finalint}\n\\end{multline}\n\nThe terms $\\bm{r}''_{S_{c,i1}/B}$ and $\\bm{r}''_{S_{c,i2}/B}$ contain second order state variables, therefore replacing their definition seen in Eqs.~\\eqref{eq:ddrcgspi1} and ~\\eqref{eq:ddrcgspi2} and simplifying the expression yields\n\\begin{multline}\n\tm_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N} + [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}\\\\\n\t+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big) \\ddot{\\theta}_{i1}\n\t+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)\\ddot{\\theta}_{i2}\\bigg] \n\t\\\\\n\t= -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t\\dot{\\theta}_{i1} I_{s_{i1,2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B} \\\\\n\t+m_{\\text{sp}_{i1}}d_{i1}\\dot{\\theta}_{i1}^2  [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\n\t+ \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}[\\bm{\\tilde{\\omega}}_{\\cal B/N}]\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \\\\\n\t+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\big(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\big)\\bigg]\n\t+ \\bm{L}_B \n\t\\label{eq:Final6}\n\\end{multline}\n\n\n\\subsubsection{Dual Linked Solar Panel Motion}\n\nThe following section follows the same derivation seen in previous work\\cite{Allard2016rz} and is summarized here for convenience. \nLet $\\bm L_{H_{i1}} = L_{i1,1} \\hat{\\bm s}_{i1,1} + L_{i1,2} \\hat{\\bm s}_{i1,2} + L_{i1,3} \\hat{\\bm s}_{i1,3}$ be the total torque acting on the first solar panel at point $H_{i1}$. The corresponding hinge torque is given through\n\\begin{equation}\n\tL_{i1,2} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + \\hat{\\bm s}_{i1,2} \\cdot \\bm{r}_{H_{i2}/H_{i1}} \\times \\bm F_{1/2i}\n\t\\label{eq:hingeTorque1}\n\\end{equation}\nWhere $\\bm F_{1/2i}$ is the reaction of solar panel 2 acting on solar panel 1. It is important to point out that $\\bm F_{1/2i} = - \\bm F_{2/1i}$. \n\nTo define the $\\bm F_{1/2i}$, $\\bm F_{2/1i}$ needs to be defined. This is done performing the super particle theorem on the second solar panel:\n\\begin{equation}\n\t\\bm F_{2/1i} + \\bm F_{\\text{ext}_{i2}} = m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N}\n\\end{equation}\nThe sum of the external forces on solar panel 2, $\\bm F_{\\text{ext}_{i2}}$, is separate because it does not contribute to the reaction force at the joint. With this definition $\\bm F_{1/2i}$ is defined as\n\\begin{equation}\n\t\\bm F_{1/2i} = \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N} \n\\end{equation}\nPlugging this definition into Eq.~\\eqref{eq:hingeTorque1} yields\n\\begin{equation}\n\tL_{i1,2} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + \\hat{\\bm s}_{i1,2} \\cdot \\Big[\\bm{r}_{H_{i2}/H_{i1}} \\times \\big(\\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N}\\big)\\Big]\n\t\\label{eq:hingeTorque2}\n\\end{equation}\nThe hinge structure produces the other two torques $L_{i1,1}$ and $L_{i1,3}$. $\\bm \\tau_{\\text{ext}_{i1},H_{i1}}$ is the external torque on the solar panel and is projected onto the $\\hat{\\bm s}_{i,2}$ direction to find its contribution to $L_{i1,2}$. Gravity, for example would apply the following torque on the solar panel about point $H_{i1}$\n\\begin{equation}\n\t\\bm \\tau_{g,H_{i1}} = \\bm r_{S_{c,i1}/H_{i1}} \\times \\bm F_g\n\\end{equation}\n\nThe inertial angular velocity vector for the solar panel frame is\n\\begin{equation}\n\t\\bm\\omega_{\\mathcal{S}_{i1}/\\mathcal{N}} = \\bm\\omega_{\\mathcal{S}_{i1}/\\mathcal{H}_{i1}} + \\bm\\omega_{\\mathcal{H}_{i1}/\\mathcal{B}} + \\bm\\omega_{\\cal B/N}\n\\end{equation}\nwhere $\\bm\\omega_{\\mathcal{S}_{i1}/\\mathcal{H}_{i1}} = \\dot\\theta_{i1} \\hat{\\bm s}_{i1,2}$.  \nBecause the hinge frame $\\mathcal{H}_{i1}$ is fixed relative to the body frame $\\mathcal{B}$ the relative angular velocity vector is $\\bm\\omega_{\\mathcal{H}_{i1}/\\mathcal{B}} = \\bm 0$.  The body angular velocity vector is written in $\\mathcal{S}_{i1}$-frame components as\n\\begin{align}\n\t\\bm\\omega_{\\cal B/N} &= ( \\hat{\\bm s}_{i1,1} \\cdot \\bm\\omega_{\\cal B/N}) \\hat{\\bm s}_{i1,1}\n\t+ (\\hat{\\bm s}_{i1,2} \\cdot\\bm\\omega_{\\cal B/N}) \\hat{\\bm s}_{i1,2}\n\t+ (\\hat{\\bm s}_{i1,3} \\cdot\\bm\\omega_{\\cal B/N}) \\hat{\\bm s}_{i1,3}\n\t\\\\\n\t&= \\omega_{s_{i1,1}} \\hat{\\bm s}_{i1,1} + \\omega_{s_{i1,2}} \\hat{\\bm s}_{i1,2} + \\omega_{s_{i1,3}}\\hat{\\bm s}_{i1,3}\n\\end{align}\nUsing this definition greatly simplifies the following algebraic development.  Finally, the inertial solar panel angular velocity vector is written as\n\\begin{equation}\n\t\\bm\\omega_{\\mathcal{S}_{i1}/\\mathcal{N}}  = \\omega_{s_{i1,1}} \\hat{\\bm s}_{{i1},1} + (\\omega_{s_{i1,2}} + \\dot\\theta_{i1})\\hat{\\bm s}_{i1,2} + \\omega_{s_{i1,3}} \\hat{\\bm s}_{i1,3}\n\\end{equation}\nAs $\\hat{\\bm s}_{i1,2}$ is a body-fixed vector, note that\n\\begin{equation}\n\t\\dot\\omega_{s_{i1,2}} = \\frac{\\leftexp{B}\\D}{\\D t} \\left( \\bm\\omega_{\\cal B/N} \\cdot \\hat{\\bm s}_{i1,2} \\right)\n\t= \\frac{\\leftexp{B}\\D}{\\D t} \\left( \\bm\\omega_{\\cal B/N}\\right) \\cdot \\hat{\\bm s}_{i1,2}  = \n\t\\dot{\\bm\\omega}_{\\cal B/N} \\cdot \\hat{\\bm s}_{i1,2}\n\\end{equation}\n\nSubstituting these angular velocity components into the rotational equations of motion of a rigid body with torques taken about its center of mass\\cite{schaub}, the general solar panel equations of motion are written as\n\\begin{align}\n\tI_{s_{i1,1}} \\dot\\omega_{s_{i1,1}} &= - (I_{s_{i1,3}} - I_{s_{i1,2}}) (\\omega_{s_{i1,2}}+\\dot\\theta_{i1})\\omega_{s_{i1,3}} + L_{s_{i1,1}}\n\t\\\\\n\tI_{s_{i1,2}} ( \\dot\\omega_{s_{i1,2}} + \\ddot\\theta_{i1}) &= - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} + L_{s_{i1,2}}\n\t\\\\\n\tI_{s_{i1,3}} \\dot\\omega_{s_{i1,3}} &= - (I_{s_{i1,2}} - I_{s_{i1,1}}) \\omega_{s_{i1,1}}(\\omega_{s_{i1,2}}+ \\dot\\theta_{i1}) + L_{s_{i1,3}}\n\\end{align}\nwhere $\\bm L_{S_{c,i1}} = L_{s_{i1,1}} \\hat{\\bm s}_{i1,1} + L_{s_{i1,2}} \\hat{\\bm s}_{i1,2} + L_{s_{i1,3}} \\hat{\\bm s}_{i1,3}$ is the net torque acting on the solar panel about its center of mass.  The second differential equation is used to get the equations of motion of $\\theta_{i1}$.  The first and third equation could be used to back-solve for the structural hinge torques embedded in $L_{s_{i1,1}}$ and $L_{s_{i1,3}}$ if needed.  \n\nLet $\\bm F_{S_{c,i1}}$ be the net force acting on the first solar panel.  Using the superparticle theorem\\cite{schaub} yields\n\\begin{equation}\n\t\\bm F_{S_{c,i1}} = m_{\\text{sp}_{i1}} \\ddot{\\bm r}_{S_{c,i1}/N}\n\\end{equation}\nThe torque about the solar panel center of mass can be related to the torque about the hinge point $H_{i1}$ using\n\\begin{equation}\n\t\\bm L_{H_i1} = \\bm L_{S_{c,i1}} + \\bm r_{S_{c,i1}/H_{i1}} \\times \\bm F_{S_{c,i1}} \n\\end{equation}\nSolving for the torque about $S_{c,i}$ yields\n\\begin{equation}\n\t\\bm L_{S_{c,i1}} = \\bm L_{H_i1} - \\bm r_{S_{c,i1}/H_{i1}} \\times m_{\\text{sp}_{i1}} \\ddot{\\bm r}_{S_{c,i1}/N}\n\\end{equation}\nTaking the vector dot product with $\\hat{\\bm s}_{i1,2}$ and using $\\bm r_{S_{c,i1}/H_{i1}} = -d_{i1} \\hat{\\bm s}_{i1,1}$ results in\n\\begin{equation}\n\tL_{s_{i1,2}} = \\hat{\\bm s}_{i1,2} \\cdot \\bm L_{S_{c,i1}} =  \\underbrace{\\hat{\\bm s}_{i1,2} \\cdot \\bm L_{H_{i1}}}_{L_{i1,2}}  -  \\hat{\\bm s}_{i1,2} \\cdot \\left(\n\t\\bm r_{S_{c,i1}/H_{i1}} \\times m_{\\text{sp}_{i1}} \\ddot{\\bm r}_{S_{c,i1}/N} \\right)\n\\end{equation}\n\\begin{multline}\n\tL_{s_{i1,2}} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + \\hat{\\bm s}_{i1,2} \\cdot \\Big[\\bm{r}_{H_{i2}/H_{i1}} \\times \\big(\\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N}\\big)\\Big]\\\\\n\t+ m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,2} \\cdot \\left(\\hat{\\bm s}_{i1,1} \\times  \\ddot{\\bm r}_{S_{c,i1}/N} \\right)\n\\end{multline}\nExpanding a couple of definitions\n\\begin{multline}\n\tL_{s_{i1,2}} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} - l_{i1} \\hat{\\bm s}_{i1,2} \\cdot \\big(\\hat{\\bm s}_{i1,1} \\times \\bm F_{\\text{ext}_{i2}}\\big) \\\\\n\t+ m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,2} \\cdot \\Big[\\hat{\\bm s}_{i1,1} \\times \\big( \\ddot{\\bm{r}}_{S_{c,i2}/N}\\big)\\Big]\n\t+ m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,2} \\cdot \\left(\\hat{\\bm s}_{i1,1} \\times  \\ddot{\\bm r}_{S_{c,i1}/N} \\right)\n\\end{multline}\nUsing the double vector cross product identity results in:\n\\begin{multline}\n\tL_{s_{i1,2}} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}} \\\\\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N}\n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3} \\cdot  \\ddot{\\bm r}_{S_{c,i1}/N}\n\\end{multline}\nThe following definitions need to be defined:\n\\begin{multline}\n\t\\ddot{\\bm r}_{S_{c,i1}/N} = \\ddot{\\bm{r}}_{B/N} + \\ddot{\\bm r}_{S_{c,i1}/B} \\\\ \n\t= \\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\n\\end{multline}\n\\begin{multline}\n\t\\ddot{\\bm r}_{S_{c,i2}/N} = \\ddot{\\bm{r}}_{B/N} + \\ddot{\\bm r}_{S_{c,i2}/B} \\\\\n\t= \\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\n\\end{multline}\n\nSubstituting these definitions into the torque equation results in:\n\n\n\\begin{multline}\n\tL_{s_{i1,2}} = - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} + \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}} \n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[\\ddot{\\bm{r}}_{B/N} \\\\\n\t+ \\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B}\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\\\\\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\\end{multline}\n\nSubstituting this torque into the earlier differential equation\n\\begin{equation}\n\tI_{s_{i1,2}} ( \\dot\\omega_{s_{i1,2}} + \\ddot\\theta_{i1}) = - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} + L_{s_{i1,2}}\n\\end{equation}\nleads to the desired scalar hinged solar panel equation of motion\n\n\\begin{multline}\n\tI_{s_{i1,2}} ( \\hat{\\bm s}_{i1,2}^T \\dot{\\bm\\omega}_{\\cal B/N} + \\ddot\\theta_{i1}) = - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} +  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} \\\\\n\t+ \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}\n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} \\\\\n\t+  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B}\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} \\\\\n\t+  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\\end{multline}\n\nMoving second order variable to the left hand side of the equation yields:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T + m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i1,2}} \\hat{\\bm s}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big]\\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t+ I_{s_{i1,2}} \\ddot\\theta_{i1} + m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T \\bm{r}''_{S_{c,i1}/B}\n\t+ m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\bm{r}''_{S_{c,i2}/B} \n\t= - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} \\\\\n\t+  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} \n\t+ \\hat{\\bm s}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}\n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3} \\cdot \\Big[ 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} \n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\\end{multline}\n\nExpanding the $\\bm{r}''_{S_{c,i1}/B}$ and $\\bm{r}''_{S_{c,i2}/B}$ terms, replacing cross products with the tilde matrix and again isolating the second order variables results in: \n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T + m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i1,2}} \\hat{\\bm s}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big]\\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t+ \\Big[I_{s_{i1,2}}+ m_{\\text{sp}_{i1}} d_{i1}^2 + m_{sp_{i2}} l_{i1}^2 + m_{sp_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big] \\ddot\\theta_{i1} + \\Big[m_{sp_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big] \\ddot{\\theta}_{i2}\\\\\n\t= - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} \n\t+  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} \n\t+ \\hat{\\bm s}_{i1,2}^T \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3}^T \\bm F_{\\text{ext}_{i2}}\\\\ \n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i1}/B}\n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i1}/B}\\Big]\n\t\\\\\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\n\t\\label{eq:solar_panel_final10}\n\\end{multline}\n\nEq.~\\eqref{eq:solar_panel_final10} is the EOM that describes the motion of the first solar panel with a linked secondary panel attached at the end. The final step is to find the EOM of the secondary panel. Following a very similar pattern the EOM for the second panel is found. First the torque about point $H_{i2}$ is defined as:\n\\begin{equation}\n\tL_{i2,2} = - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}}\n\t\\label{eq:hingeTorque3}\n\\end{equation}\nThe relationship between the torque about the center of mass of the solar panel and about the hinge point is defined as:\n\\begin{equation}\n\t\\bm L_{H_i2} = \\bm L_{S_{c,i2}} + \\bm r_{S_{c,i2}/H_{i2}} \\times \\bm F_{S_{c,i2}} \n\\end{equation}\nThe torque about $\\hat{\\bm s}_{i2,2}$ is the only torque that is required:\n\\begin{equation}\n\tL_{s_{i2,2}} = \\hat{\\bm s}_{i2,2} \\cdot \\bm L_{S_{c,i2}} =  \\underbrace{\\hat{\\bm s}_{i2,2} \\cdot \\bm L_{H_{i2}}}_{L_{i2,2}}  -  \\hat{\\bm s}_{i2,2} \\cdot \\left(\n\t\\bm r_{S_{c,i2}/H_{i2}} \\times m_{\\text{sp}_{i2}} \\ddot{\\bm r}_{S_{c,i2}/N} \\right)\n\\end{equation}\nSubstituting Eq.~\\eqref{eq:hingeTorque3} into the previous equation yields\n\\begin{equation}\n\tL_{s_{i2,2}} = - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  -  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3} \\cdot \\ddot{\\bm r}_{S_{c,i2}/N}\n\\end{equation}\n\nSubstituting this torque into the modified Euler's equation for the second panel\n\\begin{equation}\n\tI_{s_{i2,2}} ( \\dot\\omega_{s_{i2,2}} + \\ddot\\theta_{i1} + \\ddot\\theta_{i2}) = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} + L_{s_{i2,2}}\n\\end{equation}\n\nResults in:\n\n\\begin{multline}\n\tI_{s_{i2,2}} ( \\dot\\omega_{s_{i2,2}} + \\ddot\\theta_{i1} + \\ddot\\theta_{i2}) = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  \\\\\n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\ddot{\\bm r}_{S_{c,i2}/N}\n\\end{multline}\n\nSubstituting the definition of $\\ddot{\\bm r}_{S_{c,i2}/N}$ yields:\n\n\\begin{multline}\n\tI_{s_{i2,2}} ( \\dot\\omega_{s_{i2,2}} + \\ddot\\theta_{i1} + \\ddot\\theta_{i2}) = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  \\\\\n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\Big[ \\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\\end{multline}\n\nMoving the second order state variables to the left hand side of the equation yields:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T\\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i2,2}} \\hat{\\bm s}_{i2,2}^T - m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}]\\Big] \\dot{\\bm\\omega}_{\\cal B/N} + \\Big[I_{s_{i2,2}}\\Big] \\ddot\\theta_{i1} + \\Big[I_{s_{i2,2}}\\Big] \\ddot\\theta_{i2} \\\\\n\t+ m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T  \\bm{r}''_{S_{c,i2}/B} = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  \\\\\n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\Big[ 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\\end{multline}\n\nExpanding $\\bm{r}''_{S_{c,i2}/B}$, isolating second order state variables to the left hand side and introducing the skew symmetric matrix:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T\\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i2,2}} \\hat{\\bm s}_{i2,2}^T - m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}]\\Big] \\dot{\\bm\\omega}_{\\cal B/N} + \\Big[I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d_{i2}^2 + m_{\\text{sp}_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i2,3}^T \\bm{\\hat{s}}_{i1,3} \\Big] \\ddot\\theta_{i1} \\\\\n\t+ \\Big[I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d_{i2}^2 \\Big] \\ddot\\theta_{i2} \n\t= - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} - k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  \\\\\n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} + [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} \\Big]\n\t\\label{eq:sp2final}\n\\end{multline}\n\nEq.~\\eqref{eq:sp2final} is the last EOM needed to describe the motion of the spacecraft. The next section develops the back substitution method for interconnected panels and gives meaningful insight on how effectors connected to other effectors dynamically couple to the spacecraft. \n\n\\subsection{Derivation of Equations of Motion - Kane's Method}\n\nThe choice of state variables and their respective chosen generalized speeds are:\n\n\\begin{equation}\n\t\\bm X = \n\t\\begin{bmatrix}\n\t\t\\bm r_{B/N}\\\\\n\t\t\\bm \\sigma_{\\cal{B/N}}\\\\\n\t\t\\theta_{1,1}\\\\\n\t\t\\theta_{1,2}\\\\\n\t\t\\cdot\\\\\n\t\t\\theta_{N_S,1}\\\\\n\t\t\\theta_{N_S,2}\n\t\\end{bmatrix}\n\t\\quad\n\t\\bm u = \\begin{bmatrix}\n\t\t\\dot{\\bm r}_{B/N}\\\\\n\t\t\\bm \\omega_{\\cal{B/N}}\\\\\n\t\t\\dot{\\theta}_{1,1}\\\\\n\t\t\\dot{\\theta}_{1,2}\\\\\n\t\t\\cdot\\\\\n\t\t\\dot{\\theta}_{N_S,1}\\\\\n\t\t\\dot{\\theta}_{N_S,2}\n\t\\end{bmatrix}\n\\end{equation} \t\nThe necessary velocities needed to be defined are as follows\n\n\\begin{equation}\n\t\\dot{\\bm r}_{B_c/N} = \\dot{\\bm r}_{B/N} + \\bm \\omega_{\\cal{B/N}} \\times {\\bm r}_{B_c/B} = \\dot{\\bm r}_{B/N}  - [\\tilde{{\\bm r}}_{B_c/B}] \\bm \\omega_{\\cal{B/N}} \\\\\n\\end{equation}\n\n\\begin{equation}\n\t\\bm \\omega_{\\cal{B/N}} = \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\n\\begin{equation}\n\t\\dot{\\bm{r}}_{S_{c,{i1}}/B} = \\dot{\\bm r}_{B/N} + \\bm{r}'_{S_{c,{i1}}/B} + \\bm \\omega_{\\cal{B/N}} \\times \\bm{r}_{S_{c,{i1}}/B} = \\dot{\\bm r}_{B/N} + d_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3}  - [\\tilde{\\bm{r}}_{S_{c,{i1}}/B}] \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\n\\begin{equation}\n\t\\dot{\\bm{r}}_{S_{c,{i2}}/B} = \\dot{\\bm r}_{B/N} + \\bm{r}'_{S_{c,{i2}}/B} + \\bm \\omega_{\\cal{B/N}} \\times \\bm{r}_{S_{c,{i2}}/B} = \\dot{\\bm r}_{B/N} +l_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)\\bm{\\hat{s}}_{i2,3}  - [\\tilde{\\bm{r}}_{S_{c,{i2}}/B}] \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}} = \\bm \\omega_{\\cal{B/N}} + \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}} = \\bm \\omega_{\\cal{B/N}} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\n\\end{equation}\n\n\\begin{equation}\n\t\\dot{\\bm r}_{C/N} = \\dot{\\bm r}_{B/N} + \\dot{\\bm c}\\\\\n\t\\label{eq:rDot_CN}\n\\end{equation}\n\nNow the following partial velocity table can be created:\n\n\\begin{table}[htbp]\n\t\\caption{Partial Velocity Table}\n\t\\label{tab:hub}\n\t\\centering \\fontsize{10}{10}\\selectfont\n\t\\begin{tabular}{ c | c | c | c | c | c | c } % Column formatting, \n\t\t\\hline\n\t\t$r$  & $\\bm v^{B_c}_{r}$  & $\\bm \\omega_{\\textit{r}}^{\\cal{B}}$ & $\\bm v^{S_{c,i1}}_{r}$ & $\\bm \\omega_{r}^{\\mathcal{S}_{i1}}$ & $\\bm v^{S_{c,i2}}_{r}$ & $\\bm \\omega_{r}^{\\mathcal{S}_{i2}}$ \\\\\n\t\t\\hline\n\t\t$1-3$  & $[I_{3\\times 3}]$ & $[0_{3\\times 3}]$ & $[I_{3\\times 3}]$ & $[0_{3\\times 3}]$ & $[I_{3\\times 3}]$ & $[0_{3\\times 3}]$ \\\\\n\t\t$4-6$ & $- [\\tilde{{\\bm r}}_{B_c/B}]$ & $[I_{3\\times 3}]$ & $- [\\tilde{\\bm{r}}_{S_{c,{i1}}/B}]$ & $[I_{3\\times 3}]$ & $- [\\tilde{\\bm{r}}_{S_{c,{i2}}/B}]$ & $[I_{3\\times 3}]$\\\\\n\t\t$7$ &$[0_{3\\times 1}]$ & $[0_{3\\times 1}]$ & $d_{i1} \\bm{\\hat{s}}_{i1,3}$ & $\\bm{\\hat{s}}_{i1,2}$ & $l_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2} \\bm{\\hat{s}}_{i2,3}$ & $\\hat{\\bm s}_{i2,2}$ \\\\\n\t\t$8$ &$[0_{3\\times 1}]$ & $[0_{3\\times 1}]$ & $[0_{3\\times 1}]$ & $[0_{3\\times 1}]$ & $ d_{i2}\\bm{\\hat{s}}_{i2,3}$ & $\\hat{\\bm s}_{i2,2}$ \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\nAn additional partial velocity that is needed is $[\\bm v^C_{1-3}]$ for the external force applied on the spacecraft, $\\bm F_{\\text{ext}}$. Using Eq.\\eqref{eq:rDot_CN} the following is defined:\n\n\\begin{equation}\n\t[\\bm v^C_{1-3}] = [I_{3\\times 3}]\n\\end{equation}\n\nUsing these partial velocity definitions, the follow sections will step through the formulation for the translational, rotational and slosh EOMs developed using Kane's method.\n\n\\subsubsection{Rigid Spacecraft Hub Translational Motion}\n\nStarting with the definition of a generalized force:\n\n\\begin{equation}\n\tF_r = \\sum\\limits_{r}^{N}  \\bm v_r^T \\cdot \\bm F\n\t\\label{eq:genActive}\n\\end{equation}\nUsing this definition the external force applied on the spacecraft for the translational equations is defined as:\n\n\\begin{equation}\n\t\\bm F_{1-3} = [\\bm v^C_{1-3}]^T \\bm F_{\\text{ext}} = \\bm F_{\\text{ext}}\n\\end{equation}\nUsing the definition of generalized inertia forces,\n\\begin{equation}\n\tF^*_r = \\sum\\limits_{r}^{N}\\Big[\\bm \\omega_r^T \\bm T^* +  \\bm v_r^T (- m_r \\bm a_r)\\Big]\n\t\\label{eq:genInert}\n\\end{equation}\nthe inertia forces for the hub translational motion are defined as\n\n\\begin{multline}\n\t\\bm F^*_{1-3} = [\\bm v^{B_c}_{1-3}]^T (-m_{\\text{hub}} \\ddot{\\bm r}_{B_c/N}) + \\sum\\limits_{i}^{N_S}\\Big([\\bm v^{S_{c,i1}}_{1-3}]^T (-m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,{i1}}/N}) + [\\bm v^{S_{c,i2}}_{1-3}]^T (-m_{\\text{sp}_{i2}} \\ddot{\\bm{r}}_{S_{c,{i2}}/N})\\Big) \\\\\n\t= -m_{\\text{hub}} \\ddot{\\bm r}_{B_c/N} + \\sum\\limits_{i}^{N_S} \\Big( -m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,{i1}}/N} -m_{\\text{sp}_{i2}} \\ddot{\\bm{r}}_{S_{c,{i2}}/N}\\Big)\n\\end{multline}\n\nFinally, Kane's equation is:\n\n\\begin{equation}\n\tF_r + F^*_r = 0;\\quad r = 1, 2, ... N\n\t\\label{eq:KanesEq}\n\\end{equation}\ntherefore the equation for the translational motion is:\n\\begin{equation}\n\t\\bm F_{\\text{ext}} -m_{\\text{hub}} \\ddot{\\bm r}_{B_c/N} + \\sum\\limits_{i}^{N_S} \\Big( -m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,{i1}}/N} -m_{\\text{sp}_{i2}} \\ddot{\\bm{r}}_{S_{c,{i2}}/N}\\Big) = 0\n\\end{equation}\nExpanding and rearranging results in\n\\begin{equation}\n\tm_{\\text{hub}} (\\ddot{\\bm r}_{B/N} + \\ddot{\\bm r}_{B_c/B})  + \\sum\\limits_{i}^{N_S} \\Big[ m_{\\text{sp}_{i1}} (\\ddot{\\bm r}_{B/N} + \\ddot{\\bm{r}}_{S_{c,{i1}}/B}) + m_{\\text{sp}_{i2}} (\\ddot{\\bm r}_{B/N} + \\ddot{\\bm{r}}_{S_{c,{i2}}/B})\\Big] = \\bm F_{\\text{ext}}\n\t\\label{eq:KanesTrans}\n\\end{equation}\nPlugging Eq.~\\eqref{eq:rsddot} into Eq.~\\eqref{eq:KanesTrans} results in\n\\begin{multline}\n\tm_{\\text{hub}} \\ddot{\\bm r}_{B/N} + m_{\\text{hub}}\\Big[\\bm{\\dot{\\omega}}_{\\cal B/N} \\times \\bm{r}_{B_c/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{B_c/B})\\Big]\n\t+ \\sum\\limits_{i}^{N_S} \\bigg( m_{\\text{sp}_{i1}} \\Big[\\ddot{\\bm r}_{B/N} + \\bm{r}''_{S_{c,i1}/B} \\\\\n\t+ 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\n\t+ m_{\\text{sp}_{i2}} \\Big[\\ddot{\\bm r}_{B/N} \\\\\n\t+ \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\\bigg) = \\bm F_{\\text{ext}}\n\\end{multline}\nCombining like terms results in:\n\\begin{multline}\n\tm_{\\text{sc}} \\ddot{\\bm r}_{B/N} -m_{\\textnormal{sc}} [\\tilde{\\bm{c}}]\\dot{\\bm\\omega}_{\\cal B/N} \n\t+ \\sum\\limits_{i}^{N_S} \\bigg( m_{\\text{sp}_{i1}} \\Big[d_{i1} \\bm{\\hat{s}}_{i1,3} \\ddot{\\theta}_{i1} + d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1}\\Big] \\\\\n\t+ m_{\\text{sp}_{i2}} \\Big[(l_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2} \\bm{\\hat{s}}_{i2,3}) \\ddot{\\theta}_{i1} + d_{i2} \\bm{\\hat{s}}_{i2,3} \\ddot{\\theta}_{i2} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1} \\Big]\\bigg) \\\\\n\t= \\bm F_{\\text{ext}} - 2 m_{\\textnormal{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}' - m_{\\textnormal{sc}} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c} \n\\end{multline}\nRearranging and putting in final form:\n\\begin{multline}\n\tm_{\\text{sc}} \\ddot{\\bm r}_{B/N} -m_{\\textnormal{sc}} [\\tilde{\\bm{c}}]\\dot{\\bm\\omega}_{\\cal B/N} \n\t+ \\sum\\limits_{i}^{N_S} \\bigg( \\Big[m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3} + m_{\\text{sp}_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}\\Big] \\ddot{\\theta}_{i1} \n\t+ m_{\\text{sp}_{i2}}d_{i2} \\bm{\\hat{s}}_{i2,3} \\ddot{\\theta}_{i2} \\bigg) \\\\\n\t= \\bm F_{\\text{ext}} - 2 m_{\\textnormal{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}' - m_{\\textnormal{sc}} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c} \\\\- \\sum\\limits_{i}^{N_S} \\bigg( m_{\\text{sp}_{i1}} d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + m_{\\text{sp}_{i2}} \\Big[(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1} \\Big]\\bigg)\n\\end{multline}\nWhich is identical to Eq.~\\eqref{eq:Rbddot3} found using Newtonian mechanics.\n\\subsubsection{Rigid Spacecraft Hub Rotational Motion}\n\nThe torque acting on the spacecraft, $\\bm L_B$ needs to be defined as a general active force. Using Eq.~\\eqref{eq:genActive} active forces acting on the spacecraft for the rotational equations can be defined as:\n\n\\begin{equation}\n\t\\bm F_{4-6} = [\\bm \\omega_{4-6}^{\\cal{B}}]^T \\bm L_B = \\bm L_B\n\\end{equation}\n\nTo define the generalized inertia forces, using Eq.~\\eqref{eq:genInert} the definition of $\\bm T^*$ needs to be defined for a rigid body:\n\n\\begin{equation}\n\t\\bm T^* = -[I_c] \\dot{\\bm\\omega}  -[\\bm{\\tilde{\\omega}}] [I_c] \\bm\\omega\n\\end{equation}\n\\begin{multline}\n\t\\bm F^*_{4-6} = [\\bm \\omega_{4-6}^{\\cal{B}}]^T \\bm T^*_{\\text{hub}} + [\\bm v^{B_c}_{4-6}]^T (-m_{\\text{hub}} \\ddot{\\bm r}_{B_c/N}) + \\sum\\limits_{i}^{N_S}\\bigg([\\bm v^{S_{c,i1}}_{4-6}]^T (-m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,{i1}}/N}) + [\\bm \\omega_{4-6}^{\\mathcal{S}_{i1}}]^T \\bm T^*_{\\text{sp}_{i1}} \\\\\n\t+ [\\bm v^{S_{c,i1}}_{4-6}]^T (-m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,{i1}}/N}) + [\\bm \\omega_{4-6}^{\\mathcal{S}_{i1}}]^T \\bm T^*_{\\text{sp}_{i1}}\\bigg) \n\t= -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}}\\bigg)\n\\end{multline}\n\nUsing Kane's equation, Eq.~\\eqref{eq:KanesEq}, the following equations of motion for the rotational dynamics are defined:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}}\\bigg) = 0\n\\end{multline}\n\nRepeated here for convenience:\n\n\\begin{equation}\n\t\\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}} = \\bm \\omega_{\\cal{B/N}} + \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\n\\end{equation}\n\nDefine the inertial derivative:\n\n\\begin{equation}\n\t\\dot{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}} = \\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} + \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\n\\end{equation}\n\nSame for the second panel:\n\n\\begin{equation}\n\t\\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}} = \\bm \\omega_{\\cal{B/N}} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\n\\end{equation}\n\n\\begin{equation}\n\t\\dot{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}} = \\dot{\\bm \\omega}_{\\cal{B/N}} + (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2}\n\\end{equation}\n\nExpand using those terms:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \n\t+ \\sum\\limits_{i}^{N_S}\\bigg(- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} \\\\\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} + \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\Big]  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2}\\Big]  \\\\\n\t-[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}}\\bigg) = 0\n\\end{multline}\n\nExpanding some more terms\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} + \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\Big]  \\\\\n\t-\\Big[\\bm \\omega_{\\cal{B/N}} + \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\\Big] \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\bm \\omega_{\\cal{B/N}} + \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\\Big]\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2}\\Big]  \\\\\n\t-\\Big[\\bm \\omega_{\\cal{B/N}} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\\Big] \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\bm \\omega_{\\cal{B/N}} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\\Big]\\bigg) = 0\n\\end{multline}\n\nFurther expansion:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N}\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} \\\\\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} + \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\Big]  \n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}} \\\\\n\t-\\bm \\omega_{\\cal{B/N}} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} -\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\bm \\omega_{\\cal{B/N}} + \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\\Big]\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} \\\\\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2}\\Big]  \n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}} \\\\\n\t-\\bm \\omega_{\\cal{B/N}} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\bm \\omega_{\\cal{B/N}} + (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\\Big]\\bigg) = 0\n\\end{multline}\n\nRearranging some terms:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[ \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} - \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times \\bm \\omega_{\\cal{B/N}} \\Big]  \\\\\n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2} -\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}]\\bm \\omega_{\\cal{B/N}}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[ (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} - (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})  \\hat{\\bm s}_{i2,2} \\times \\bm \\omega_{\\cal{B/N}}\\Big]  \\\\\n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\bigg) = 0\n\\end{multline}\n\nThis needs to be defined:\n\n\\begin{equation}\n\t[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times \\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} {\\vphantom{\\begin{bmatrix}\n\t\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}} {\\vphantom{\\begin{bmatrix}\n\t\t\t\t0 & 0 & 1 \\\\\n\t\t\t\t0 & 0 & 0 \\\\\n\t\t\t\t-1 & 0 & 0\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\t0 & 0 & 1 \\\\\n\t\t\t0 & 0 & 0 \\\\\n\t\t\t-1 & 0 & 0\n\t\\end{bmatrix}} {\\vphantom{\\bm \\omega_{\\cal{B/N}}}}^{\\mathcal{S}_{i1}\\!}{\\bm \\omega_{\\cal{B/N}}} \n\\end{equation}\n\nWhich simplifies to:\n\n\\begin{equation}\n\t[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times \\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} {\\vphantom{\\begin{bmatrix}\n\t\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\t0 & 0 & I_{s_{i1,1}} \\\\\n\t\t\t0 & 0 & 0 \\\\\n\t\t\t-I_{s_{i1,3}} & 0 & 0\n\t\\end{bmatrix}} {\\vphantom{\\bm \\omega_{\\cal{B/N}}}}^{\\mathcal{S}_{i1}\\!}{\\bm \\omega_{\\cal{B/N}}} \n\\end{equation}\n\nFinal simplification:\n\n\\begin{equation}\n\t[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times \\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} (I_{s_{i1,1}} \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T - I_{s_{i1,3}} \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\nSame for second panel:\n\n\\begin{equation}\n\t[I_{\\text{sp}_{i2},S_{c,i2}}] (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})  \\hat{\\bm s}_{i2,2} \\times \\bm \\omega_{\\cal{B/N}} = (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) (I_{s_{i2,1}} \\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T - I_{s_{i2,3}} \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\nAnother term that needs to be simplified is:\n\n\\begin{equation}\n\t\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}]\\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} {\\vphantom{\\begin{bmatrix}\n\t\t\t\t0 & 0 & 1 \\\\\n\t\t\t\t0 & 0 & 0 \\\\\n\t\t\t\t-1 & 0 & 0\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\t0 & 0 & 1 \\\\\n\t\t\t0 & 0 & 0 \\\\\n\t\t\t-1 & 0 & 0\n\t\\end{bmatrix}} {\\vphantom{\\begin{bmatrix}\n\t\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\tI_{s_{i1,1}} & 0 & 0 \\\\\n\t\t\t0 & I_{s_{i1,2}} & 0 \\\\\n\t\t\t0 & 0 & I_{s_{i1,3}}\n\t\\end{bmatrix}} {\\vphantom{\\bm \\omega_{\\cal{B/N}}}}^{\\mathcal{S}_{i1}\\!}{\\bm \\omega_{\\cal{B/N}}}  \n\\end{equation}\n\nWhich simplifies to:\n\n\\begin{equation}\n\t\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}]\\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} {\\vphantom{\\begin{bmatrix}\n\t\t\t\t0 & 0 & I_{s_{i1,3}} \\\\\n\t\t\t\t0 & 0 & 0 \\\\\n\t\t\t\t-I_{s_{i1,1}} & 0 & 0\n\t\\end{bmatrix}}}^{\\mathcal{S}_{i1}\\!}{\\begin{bmatrix}\n\t\t\t0 & 0 & I_{s_{i1,3}} \\\\\n\t\t\t0 & 0 & 0 \\\\\n\t\t\t-I_{s_{i1,1}} & 0 & 0\n\t\\end{bmatrix}} {\\vphantom{\\bm \\omega_{\\cal{B/N}}}}^{\\mathcal{S}_{i1}\\!}{\\bm \\omega_{\\cal{B/N}}}  \n\\end{equation}\n\nFinal simplification:\n\n\\begin{equation}\n\t\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}]\\bm \\omega_{\\cal{B/N}} = \\dot{\\theta}_{i1} (I_{s_{i1,3}} \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T - I_{s_{i1,1}} \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\nPerforming the same methodology for panel 2:\n\n\\begin{equation}\n\t(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \\times [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}} = (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) (I_{s_{i2,3}} \\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T - I_{s_{i2,1}} \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\nPlugging these in:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} +\\dot{\\theta}_{i1} (I_{s_{i1,1}} \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T - I_{s_{i1,3}} \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}}\\\\\n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2} -\\dot{\\theta}_{i1} (I_{s_{i1,3}} \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T - I_{s_{i1,1}} \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} +(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) (I_{s_{i2,1}} \\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T - I_{s_{i2,3}} \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) (I_{s_{i2,3}} \\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T - I_{s_{i2,1}} \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}}\\bigg) = 0\n\\end{multline}\n\nMoving some terms around:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B_c/N} \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t-\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{S_{c,i1}/N} -[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{S_{c,i2}/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nPlugging in the acceleration terms:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\Big[\\ddot{\\bm r}_{B/N} + \\ddot{\\bm r}_{B_c/B}\\Big] \\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t-\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\ddot{\\bm r}_{B/N} + \\ddot{\\bm r}_{S_{c,i1}/B}\\Big]\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[\\ddot{\\bm r}_{B/N} + \\ddot{\\bm r}_{S_{c,i2}/B}\\Big]\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nExpanding acceleration terms:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N}  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B/N} \\\\\n\t- m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\Big[\\bm{\\dot{\\omega}}_{\\cal B/N} \\times \\bm{r}_{B_c/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{B_c/B})\\Big]\\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} -[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{B/N}- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{B/N}\\\\\n\t-\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big]\\\\\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[ \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\\\\\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nMoving like terms:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{hub},B}] \\dot{\\bm\\omega}_{\\cal B/N} + m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] [\\tilde{{\\bm r}}_{B_c/B}] \\bm{\\dot{\\omega}}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{hub},B}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{{\\bm r}}_{B_c/B}] [\\tilde{{\\bm r}}_{B_c/B}]\\bm\\omega_{\\cal B/N} \\\\\n\t- m_{\\text{hub}} [\\tilde{{\\bm r}}_{B_c/B}] \\ddot{\\bm r}_{B/N} \n\t+ \\sum\\limits_{i}^{N_S}\\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm \\omega}_{\\cal{B/N}} + m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\dot{\\bm\\omega}_{\\cal B/N} -[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm \\omega}_{\\cal{B/N}} \\\\\n\t+ m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\dot{\\bm\\omega}_{\\cal B/N}\n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}\n\t+ m_{\\text{sp}_{i1}} [\\tilde{\\bm \\omega}_{\\cal{B/N}}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm\\omega_{\\cal B/N}\n\t\\\\\n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}} + m_{\\text{sp}_{i2}} [\\tilde{\\bm \\omega}_{\\cal{B/N}}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm\\omega_{\\cal B/N}\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\ddot{\\bm r}_{B/N}\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\ddot{\\bm r}_{B/N}\n\t-\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t-(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big]\n\t\\\\\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[ \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big]\n\t\\\\\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nCombining like terms using the parallel axis theorem:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t- m_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} \n\t+ \\sum\\limits_{i}^{N_S}\\bigg( -\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t-2 m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big] -(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \n\t\\\\\n\t- 2 m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[ \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big]\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B} \n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\n\t\\\\- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nSplitting the $-2 m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big]$ term:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t- m_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} \n\t+ \\sum\\limits_{i}^{N_S}\\bigg( -\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[\\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B}\\Big] + m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] [\\tilde{{\\bm r}}'_{S_{c,i1}/B}] \\bm\\omega_{\\cal B/N} \\\\\n\t-(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[ \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B}\\Big]\\\\\n\t+  m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] [\\tilde{{\\bm r}}'_{S_{c,i2}/B}] \\bm\\omega_{\\cal B/N}\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B} \n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\n\t\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \\bigg) = 0\n\\end{multline}\n\nUsing the Jacobi identity for simplification:\n\n\\begin{multline}\n\t\\bm L_B -[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t- m_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} \n\t+ \\sum\\limits_{i}^{N_S}\\bigg( -\\dot{\\theta}_{i1} (I_{s_{i1,3}} - I_{s_{i1,1}})( \\hat{\\bm s}_{i1,1} \\hat{\\bm s}_{i1,3}^T + \\hat{\\bm s}_{i1,3} \\hat{\\bm s}_{i1,1}^T) \\bm \\omega_{\\cal{B/N}} \\\\\n\t+ m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}'_{S_{c,i1}/B}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm\\omega_{\\cal B/N} + m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] [\\tilde{{\\bm r}}'_{S_{c,i1}/B}] \\bm\\omega_{\\cal B/N} \\\\\n\t-(\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2})(I_{s_{i2,3}} - I_{s_{i2,1}}) (\\hat{\\bm s}_{i2,1} \\hat{\\bm s}_{i2,3}^T + \\hat{\\bm s}_{i2,3} \\hat{\\bm s}_{i2,1}^T) \\bm \\omega_{\\cal{B/N}} \n\t+ m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}'_{S_{c,i2}/B}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm\\omega_{\\cal B/N} \\\\\n\t+  m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] [\\tilde{{\\bm r}}'_{S_{c,i2}/B}] \\bm\\omega_{\\cal B/N}\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B} \n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2} \\\\\n\t- m_{\\text{sp}_{i1}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t\\\\\n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} \n\t- m_{\\text{sp}_{i2}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \\bigg) = 0\n\\end{multline}\n\nCombining terms into $[I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}$:\n\n\\begin{multline}\n\t\\bm L_B - m_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} -[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}''_{S_{c,i1}/B} \n\t\\\\\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2} - m_{\\text{sp}_{i1}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}''_{S_{c,i2}/B}\\\\\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} - m_{\\text{sp}_{i2}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \\bigg) = 0\n\\end{multline}\n\nExpanding the $\\bm{r}''_{S_{c,i1}/B}$ and $\\bm{r}''_{S_{c,i2}/B}$ terms:\n\n\\begin{multline}\n\t\\bm L_B - m_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} -[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t\\\\\n\t+ \\sum\\limits_{i}^{N_S}\\bigg(\n\t- m_{\\text{sp}_{i1}} [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\Big[d_{i1} \\bm{\\hat{s}}_{i1,3} \\ddot{\\theta}_{i1} + d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} \\Big]\n\t-[I_{\\text{sp}_{i1},S_{c,i1}}] \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \n\t\\\\-I_{s_{i1,2}} \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2} - m_{\\text{sp}_{i1}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\n\t\\\\\n\t- m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[(l_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2} \\bm{\\hat{s}}_{i2,3}) \\ddot{\\theta}_{i1} + d_{i2} \\bm{\\hat{s}}_{i2,3} \\ddot{\\theta}_{i2} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\\\\n\t-[I_{\\text{sp}_{i2},S_{c,i2}}] (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2} \n\t-I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i2,2} - m_{\\text{sp}_{i2}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \\bigg) = 0\n\\end{multline}\n\nMoving the second order state derivatives to the left hand side:\n\n\\begin{multline} \n\tm_{\\text{sc}} [\\tilde{\\bm c}] \\ddot{\\bm r}_{B/N} +[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i}^{N_S}\\bigg(\\Big[I_{s_{i1,2}} \\hat{\\bm s}_{i1,2}+\n\tm_{\\text{sp}_{i1}} d_{i1}  [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,3} +I_{s_{i2,2}} \\hat{\\bm s}_{i2,2} \\\\\n\t+ m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] (l_{i1} \\bm{\\hat{s}}_{i1,3} + d_{i2} \\bm{\\hat{s}}_{i2,3}) \\Big] \\ddot{\\theta}_{i1}\n\t+I_{s_{i2,2}}\\hat{\\bm s}_{i2,2} + m_{\\text{sp}_{i2}} d_{i2} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3} \\ddot{\\theta}_{i2} \\bigg)=  -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\\n\t- [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t- \\sum\\limits_{i}^{N_S}\\bigg(\n\tm_{\\text{sp}_{i1}} d_{i1} \\dot{\\theta}_{i1}^2 [\\tilde{{\\bm r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,1} \n\t+I_{s_{i1,2}} \\dot{\\theta}_{i1} [\\tilde{\\bm \\omega}_{\\cal{B/N}}] \\hat{\\bm s}_{i1,2} + m_{\\text{sp}_{i1}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B}\n\t\\\\\n\t+ m_{\\text{sp}_{i2}} [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\Big[ l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big] \n\t+I_{s_{i2,2}}  (\\dot{\\theta}_{i1}  + \\dot{\\theta}_{i2}) [\\tilde{\\bm \\omega}_{\\cal{B/N}}] \\hat{\\bm s}_{i2,2} \\\\\n\t+ m_{\\text{sp}_{i2}} [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{{\\bm r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \\bigg) + \\bm L_B\n\\end{multline}\n\nWhich is the same solution as the equations using Newtonian/Eulerian mechanics.\n\n\\subsubsection{Panel 1 Flexing Equation}\nFollowing the similar pattern for translational and rotational equations the generalized active forces are defined for the first interconnected panel:\n\n\\begin{equation}\n\tF_{7} = \\bm \\omega_{7}^{\\mathcal{S}_{i1}} \\cdot \\Big[ (-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1})\\bm{\\hat{s}}_{i1,2} + (k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2})\\bm{\\hat{s}}_{i2,2} + \\bm \\tau_{\\text{ext}_{i1},H_{i1}} \\Big] + \\bm v^{H_{i2}}_{7} \\cdot \\bm F_{1/2i}\n\\end{equation}\n\nNeed to define this velocity\n\n\\begin{equation}\n\t\\dot{\\bm{r}}_{H_{{i2}}/B} = \\dot{\\bm r}_{B/N} + l_{i1} \\dot{\\theta}_{i1} \\bm{\\hat{s}}_{i1,3}  - [\\tilde{\\bm{r}}_{H_{{i2}}/B}] \\bm \\omega_{\\cal{B/N}}\n\\end{equation}\n\nTherefore:\n\n\\begin{equation}\n\t\\bm v^{H_{i2}}_{7} = l_{i1} \\bm{\\hat{s}}_{i1,3}\n\\end{equation}\n\nThis needs to be defined:\n\n\\begin{equation}\n\t\\bm F_{1/2i} = \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N} \n\\end{equation}\n\nPlugging this in results in:\n\n\\begin{equation}\n\tF_{7} = \\bm{\\hat{s}}_{i1,2} \\cdot \\Big[ (-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1})\\bm{\\hat{s}}_{i1,2} + (k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2})\\bm{\\hat{s}}_{i2,2} + \\bm \\tau_{\\text{ext}_{i1},H_{i1}} \\Big] + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\Big[\\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N} \\Big]\n\\end{equation}\n\nSimplifying:\n\n\\begin{equation}\n\tF_{7} =  -k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}  + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N} \n\\end{equation}\n\nThe generalized inertia forces are defined as: \n\n\\begin{multline}\n\tF^*_{7} = \\bm \\omega_{\\textit{7}}^{\\mathcal{S}_{i1}} \\cdot \\bm T^*_{\\text{sp}_{i1}}  + \\bm v^{S_{c,i1}}_{7} \\cdot (-m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,i1}/N}) \\\\\n\t= \\bm{\\hat{s}}_{i1,2} \\cdot \\Big[-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}} \\Big] + d_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot (-m_{\\text{sp}_{i1}} \\ddot{\\bm{r}}_{S_{c,i1}/N})\n\\end{multline}\n\nUsing Kane's equation the EOM is defined as:\n\n\\begin{multline}\n\t-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}  + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N} \\\\\n\t+ \\bm{\\hat{s}}_{i1,2} \\cdot \\Big[-[I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i1}/\\mathcal{N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\mathcal{S}_{i1}/\\mathcal{N}} \\Big] -m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i1}/N} = 0\n\\end{multline}\n\nExpanding:\n\n\\begin{multline}\n\t-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}  + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N} \\\\\n\t+ \\bm{\\hat{s}}_{i1,2} \\cdot \\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} + \\dot{\\theta}_{i1} \\bm \\omega_{\\cal{B/N}} \\times \\hat{\\bm s}_{i1,2}\\Big] \n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}\\\\\n\t-\\bm \\omega_{\\cal{B/N}} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} -\\dot{\\theta}_{i1} \\hat{\\bm s}_{i1,2} \\times [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}}\\bigg) -m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i1}/N} = 0\n\\end{multline}\n\nSimplifying:\n\n\\begin{multline}\n\t-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}  + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N} \\\\\n\t+ \\bm{\\hat{s}}_{i1,2} \\cdot \\bigg(-[I_{\\text{sp}_{i1},S_{c,i1}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + \\ddot{\\theta}_{i1} \\hat{\\bm s}_{i1,2}\\Big]  \n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i1},S_{c,i1}}] \\bm \\omega_{\\cal{B/N}} \\bigg) -m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i1}/N} = 0\n\\end{multline}\n\nRearranging some common terms:\n\n\\begin{multline}\n\t-k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}  + l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}}  - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i2}/N} \\\\\n\t- I_{s_{i1,2}} \\bm{\\hat{s}}_{i1,2}^T \\dot{\\bm \\omega}_{\\cal{B/N}} - I_{s_{i1,2}} \\ddot{\\theta}_{i1} - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} -m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\ddot{\\bm{r}}_{S_{c,i1}/N} = 0\n\\end{multline}\n\nMoving second order variables to the left hand side:\n\n\\begin{multline}\n\tI_{s_{i1,2}} \\bm{\\hat{s}}_{i1,2}^T \\dot{\\bm \\omega}_{\\cal{B/N}} + I_{s_{i1,2}} \\ddot{\\theta}_{i1} + m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i1}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i1}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i1}/B})\\Big] + m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big]\n\t= -k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} \\\\\n\t+ \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}\n\t+ l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}} \n\\end{multline}\n\nCombing like terms:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T + m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i1,2}} \\bm{\\hat{s}}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big] \\dot{\\bm \\omega}_{\\cal{B/N}} \\\\\n\t+ I_{s_{i1,2}} \\ddot{\\theta}_{i1} + m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big[ \\bm{r}''_{S_{c,i1}/B} \n\t\\Big] + m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big[ \\bm{r}''_{S_{c,i2}/B}\\Big]\n\t= -k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} + k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} \\\\\n\t- (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} \n\t- 2 m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B}\n\t- m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B}\\\\ \n\t- m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i1}/B}\n\t+ \\bm{\\hat{s}}_{i1,2} \\cdot \\bm \\tau_{\\text{ext}_{i1},H_{i1}}\n\t+ l_{i1} \\bm{\\hat{s}}_{i1,3} \\cdot \\bm F_{\\text{ext}_{i2}} \n\\end{multline}\n\nPlugging in the $\\bm{r}''_{S_{c,i1}/B}$ and $\\bm{r}''_{S_{c,i2}/B}$ terms:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T + m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T \\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i1,2}} \\bm{\\hat{s}}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big] \\dot{\\bm \\omega}_{\\cal{B/N}} \\\\\n\t+ \\Big[I_{s_{i1,2}} + m_{\\text{sp}_{i1}} d_{i1}^2 + m_{sp_{i2}} l_{i1}^2 + m_{sp_{i2}} l_{i1} d_{i2} \\bm{\\hat{s}}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big] \\ddot{\\theta}_{i1} + \\Big[m_{sp_{i2}} l_{i1} d_{i2} \\bm{\\hat{s}}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big]\\ddot{\\theta}_{i2}\n\t= - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}}\\\\ -k_{i1} \\theta_{i1} - c_{i1} \\dot{\\theta}_{i1} \n\t+ k_{i2} \\theta_{i2} + c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i1,2}^T \\bm \\tau_{\\text{ext}_{i1},H_{i1}}\n\t+ l_{i1} \\bm{\\hat{s}}_{i1,3}^T \\bm F_{\\text{ext}_{i2}} \n\t- m_{\\text{sp}_{i1}} d_{i1} \\bm{\\hat{s}}_{i1,3}^T [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i1}/B}\\\\\n\t- m_{sp_{i2}} l_{i1} \\bm{\\hat{s}}_{i1,3}^T\\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} + [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + d_{i2} \\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2 \\bm{\\hat{s}}_{i2,1}\\Big]\n\\end{multline}\n\nThis equation is the same equation found using Newtonian/Eulerian mechanics.\n\n\\subsubsection{Panel 2 Flexing Equation}\nFollowing the similar pattern for translational and rotational equations the generalized active forces are defined for the first interconnected panel:\n\n\\begin{equation}\n\tF_{8} = \\bm \\omega_{8}^{\\mathcal{S}_{i2}} \\cdot \\Big[  (-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2})\\bm{\\hat{s}}_{i2,2} + \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \\Big]\n\\end{equation}\n\nSimplifying:\n\n\\begin{equation}\n\tF_{8} = \\bm{\\hat{s}}_{i2,2} \\cdot \\Big[  (-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2})\\bm{\\hat{s}}_{i2,2} + \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \\Big] = -k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}}\n\\end{equation}\n\nThe generalized inertia forces are defined as: \n\n\\begin{multline}\n\tF^*_{8} = \\bm \\omega_{\\textit{8}}^{\\mathcal{S}_{i2}} \\cdot \\bm T^*_{\\text{sp}_{i2}}  + \\bm v^{S_{c,i2}}_{8} \\cdot (-m_{\\text{sp}_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N}) \\\\\n\t= \\bm{\\hat{s}}_{i2,2} \\cdot \\Big[-[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}} \\Big] + d_{i2}\\bm{\\hat{s}}_{i2,3} \\cdot (-m_{\\text{sp}_{i2}} \\ddot{\\bm{r}}_{S_{c,i2}/N})\n\\end{multline}\n\nUsing Kane's equation the EOM is defined as:\n\n\\begin{multline}\n\t-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} + \\bm{\\hat{s}}_{i2,2} \\cdot \\Big[-[I_{\\text{sp}_{i2},S_{c,i2}}] \\dot{\\bm\\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}  -[\\tilde{\\bm \\omega}_{\\mathcal{S}_{i2}/\\mathcal{N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\mathcal{S}_{i2}/\\mathcal{N}} \\Big] \\\\\n\t- m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\ddot{\\bm{r}}_{S_{c,i2}/N} = 0\n\\end{multline}\n\nExpanding:\n\n\\begin{multline}\n\t-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} + \\bm{\\hat{s}}_{i2,2} \\cdot \\bigg(-[I_{\\text{sp}_{i2},S_{c,i2}}] \\Big[\\dot{\\bm \\omega}_{\\cal{B/N}} + (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})\\hat{\\bm s}_{i2,2}\\Big]  \\\\\n\t-[\\tilde{\\bm \\omega}_{\\cal{B/N}}] [I_{\\text{sp}_{i2},S_{c,i2}}] \\bm \\omega_{\\cal{B/N}} \\bigg)\n\t- m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\ddot{\\bm{r}}_{S_{c,i2}/N} = 0\n\\end{multline}\n\nSimplifying:\n\n\\begin{multline}\n\t-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} - I_{s_{i2,2}} \\bm{\\hat{s}}_{i2,2}^T \\dot{\\bm \\omega}_{\\cal{B/N}} - I_{s_{i2,2}} (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2})  \\\\\n\t- (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}}\n\t- m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\ddot{\\bm{r}}_{S_{c,i2}/N} = 0\n\\end{multline}\n\nMoving second order variables to the left hand side:\n\n\\begin{multline}\n\tI_{s_{i2,2}} \\bm{\\hat{s}}_{i2,2}^T \\dot{\\bm \\omega}_{\\cal{B/N}} + I_{s_{i2,2}} (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2}) + m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\ddot{\\bm{r}}_{S_{c,i2}/N} = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} \\\\-k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2}\n\t+ \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \n\\end{multline}\n\nPlugging in accelerations:\n\n\\begin{multline}\n\tI_{s_{i2,2}} \\bm{\\hat{s}}_{i2,2}^T \\dot{\\bm \\omega}_{\\cal{B/N}} + I_{s_{i2,2}} (\\ddot{\\theta}_{i1}  + \\ddot{\\theta}_{i2}) + m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\Big[\\ddot{\\bm{r}}_{B/N} + \\bm{r}''_{S_{c,i2}/B} + 2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{S_{c,i2}/B} +  \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{S_{c,i2}/B})\\Big] = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} -k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2}\n\t+ \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \n\\end{multline}\n\nMoving common terms around:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T\\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i2,2}} \\bm{\\hat{s}}_{i2,2}^T - m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T  [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big] \\dot{\\bm \\omega}_{\\cal{B/N}} + \\Big[I_{s_{i2,2}}\\Big] \\ddot{\\theta}_{i1}  + \\Big[I_{s_{i2,2}}\\Big] \\ddot{\\theta}_{i2} \\\\+ m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\Big[ \\bm{r}''_{S_{c,i2}/B}\\Big] \n\t= - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} -k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2}\n\t+ \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \\\\\n\t- m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B}\\Big]\n\\end{multline}\n\nPlugging in the $\\bm{r}''_{S_{c,i2}/B}$ term and rearranging:\n\n\\begin{multline}\n\t\\Big[m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T\\Big] \\ddot{\\bm{r}}_{B/N} + \\Big[I_{s_{i2,2}} \\bm{\\hat{s}}_{i2,2}^T - m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T  [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big] \\dot{\\bm \\omega}_{\\cal{B/N}} + \\Big[I_{s_{i2,2}}+ m_{\\text{sp}_{i2}} d_{i2}^2 + m_{\\text{sp}_{i2}} l_{i1} d_{i2} \\bm{\\hat{s}}_{i2,3}^T \\bm{\\hat{s}}_{i1,3} \\Big] \\ddot{\\theta}_{i1}  \\\\\n\t+ \\Big[I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d_{i2}^2 \\Big] \\ddot{\\theta}_{i2} \n\t= - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} -k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2}\n\t+ \\bm{\\hat{s}}_{i2,2} \\cdot \\bm \\tau_{\\text{ext}_{i2},H_{i2}} \\\\\n\t- m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1}\\Big]\n\\end{multline}\n\nThey are the EXACT same just found a few other terms to cancel.\n\n\\subsection{Back Substitution Method}\nThe dynamical coupling of this complex system can be visualized in the following equation:\n\n\\begin{equation}\n\t\\begin{bmatrix}\n\t\t[3\\times 3] & [3\\times 3] & 3\\times 1 & 3\\times 1 & 3\\times 1 & 3\\times 1 & . & 3\\times 1 & 3\\times 1\\\\\n\t\t[3\\times 3] & [3\\times 3] & 3\\times 1 & 3\\times 1 & 3\\times 1 & 3\\times 1 & . & 3\\times 1 & 3\\times 1\\\\\n\t\t[1\\times 3] & [1\\times 3] & 1\\times 1 & 1\\times 1  & 0 & 0 & . & 0 & 0\\\\\n\t\t[1\\times 3] & [1\\times 3] & 1\\times 1 & 1\\times 1  & 0 & 0 & . & 0 & 0\\\\\n\t\t[1\\times 3] & [1\\times 3] & 0 & 0  & 1\\times 1 & 1\\times 1 & . & 0 & 0 \\\\\n\t\t[1\\times 3] & [1\\times 3] & 0 & 0  & 1\\times 1 & 1\\times 1 & . & 0 & 0\\\\\n\t\t. & . & . & . & . & . & . & . & .\\\\\n\t\t[1\\times 3] & [1\\times 3] & 0 & 0  & 0 & 0 & . & 1\\times 1 & 1\\times 1\\\\\n\t\t[1\\times 3] & [1\\times 3] & 0 & 0  & 0 & 0 & . & 1\\times 1 & 1\\times 1\\\\\n\t\\end{bmatrix}\n\t\\begin{bmatrix}\n\t\t\\ddot{\\boldsymbol{r}}_{B/N}\\\\\n\t\t\\dot{\\boldsymbol{\\omega}}_{B/N}\\\\\n\t\t\\ddot{\\theta}_{11}\\\\\n\t\t\\ddot{\\theta}_{12}\\\\\n\t\t\\ddot{\\theta}_{21}\\\\\n\t\t\\ddot{\\theta}_{22}\\\\\n\t\t.\\\\\n\t\t\\ddot{\\theta}_{N1}\\\\\n\t\t\\ddot{\\theta}_{N2}\n\t\\end{bmatrix}\n\t=\n\t\\begin{bmatrix}\n\t\t3\\times 1\\\\\n\t\t3\\times 1\\\\\n\t\t1\\times 1\\\\\n\t\t1\\times 1\\\\\n\t\t1\\times 1\\\\\n\t\t1\\times 1\\\\\n\t\t.\\\\\n\t\t1\\times 1\\\\\n\t\t1\\times 1\n\t\\end{bmatrix}\n\\end{equation}\nThis system mass matrix shows that the all of the solar panel modes are fully coupled with the hub, and that the pairs of solar panels are fully coupled with one another. However, the pairs of solar panels are not directly coupled with other pairs of solar panels. To utilize this pattern in the system mass matrix, the following back-substitution is developed. \n\nFirst, Eq.~\\eqref{eq:solar_panel_final10} and ~\\eqref{eq:sp2final} are rearranged so that the second order state variables for the solar panel motions are isolated on the left hand side:\n\\begin{multline}\n\t\\Big[I_{s_{i1,2}}+ m_{\\text{sp}_{i1}} d_{i1}^2 + m_{sp_{i2}} l_{i1}^2 + m_{sp_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big] \\ddot\\theta_{i1} + \\Big[m_{sp_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i1,3}^T \\bm{\\hat{s}}_{i2,3} \\Big] \\ddot{\\theta}_{i2}=\\\\\n\t-\\Big[m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T + m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big] \\ddot{\\bm{r}}_{B/N} - \\Big[I_{s_{i1,2}} \\hat{\\bm s}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big]\\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t- (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} \n\t+  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} \n\t+ \\hat{\\bm s}_{i1,2}^T \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3}^T \\bm F_{\\text{ext}_{i2}}\\\\ \n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i1}/B}\n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i1}/B}\\Big]\n\t\\\\\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\n\t\\label{eq:spMotion1}\n\\end{multline}\n\n\\begin{multline}\n\t\\Big[I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d_{i2}^2 + m_{\\text{sp}_{i2}} l_{i1} d_{i2} \\hat{\\bm s}_{i2,3}^T \\bm{\\hat{s}}_{i1,3} \\Big] \\ddot\\theta_{i1} \n\t+ \\Big[I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d_{i2}^2 \\Big] \\ddot\\theta_{i2} \n\t= \\\\\n\t-\\Big[m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T\\Big] \\ddot{\\bm{r}}_{B/N} - \\Big[I_{s_{i2,2}} \\hat{\\bm s}_{i2,2}^T + m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}]\\Big] \\dot{\\bm\\omega}_{\\cal B/N} - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}} \\\\\n\t- k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}  \n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \\\\\n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} \\Big]\n\t\\label{eq:sp3final}\n\\end{multline}\nNow, defining the elements of a matrix $[A_i]$ as:\n\\begin{subequations}\n\t\\begin{align}\n\t\ta_{i1,1} &= I_{s_{i1,2}} + m_{\\text{sp}_{i1}} d^2_{i1} + m_{sp_{i2}} l^2_{i1}+ m_{sp_{i2}} l_{i1} d_{i2}\\hat{\\bm s}^T_{i1,3}  \\bm{\\hat{s}}_{i2,3} \\\\\n\t\ta_{i1,2} &= m_{sp_{i2}} l_{i1} d_{i2} \\hat{\\bm s}^T_{i1,3}  \\bm{\\hat{s}}_{i2,3}\\\\\n\t\ta_{i2,1} &= I_{s_{i2,2}} + m_{\\text{sp}_{i2}} d^2_{i2}  +  m_{\\text{sp}_{i2}} l_{i1} d_{i2}\\hat{\\bm s}^T_{i2,3}  \\bm{\\hat{s}}_{i1,3} \\\\\n\t\ta_{i2,2} &= I_{s_{i2,2}} +  m_{\\text{sp}_{i2}} d^2_{i2}\n\t\\end{align}\n\\end{subequations}\nAnd defining the row elements of a matrix $[F_i]$ as:\n\\begin{subequations}\n\t\\begin{align}\n\t\t\\bm f_{i1} &= -\\big(m_{sp_{i2}} l_{i1} + m_{\\text{sp}_{i1}} d_{i1} \\big) \\hat{\\bm s}^T_{i1,3}\\\\\n\t\t\\bm f_{i2} &= -m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T\n\t\\end{align}\n\\end{subequations}\nWith a $2\\times 3$ matrix $[G_i]$ which has row elements defined as:\n\\begin{subequations}\n\t\\begin{align}\n\t\t\\bm g_{i1} &= - \\Big[I_{s_{i1,2}} \\hat{\\bm s}_{i1,2}^T - m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i1}/B}] - m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\Big]^T\\\\\n\t\t\\bm g_{i2} &= -  \\Big[I_{s_{i2,2}} \\hat{\\bm s}_{i2,2}^T - m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T [\\tilde{\\bm{r}}_{S_{c,i2}/B}]\\Big]^T\n\t\\end{align}\n\\end{subequations}\nAlso defining the vector $\\bm v_i$ as  as $2\\times1$ with the following components:\n\\begin{multline}\n\tv_{i1} = - (I_{s_{i1,1}} - I_{s_{i1,3}}) \\omega_{s_{i1,3}} \\omega_{s_{i1,1}} - k_{i1} \\theta_{i1} - c_{i1}\\dot{\\theta}_{i1} \n\t+  k_{i2} \\theta_{i2} + c_{i2} \\dot\\theta_{i2} \n\t+ \\hat{\\bm s}_{i1,2}^T \\bm \\tau_{\\text{ext}_{i1},H_{i1}} + l_{i1} \\hat{\\bm s}_{i1,3}^T \\bm F_{\\text{ext}_{i2}}\\\\ \n\t- m_{\\text{sp}_{i1}} d_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i1}/B}\n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i1}/B}\\Big]\n\t\\\\\n\t- m_{sp_{i2}} l_{i1} \\hat{\\bm s}_{i1,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} \n\t+ [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\n\t\\label{eq:solar_panel_final8}\n\\end{multline}\n\\begin{multline}\n\tv_{i2} = - (I_{s_{i2,1}} - I_{s_{i2,3}}) \\omega_{s_{i2,3}} \\omega_{s_{i2,1}}\n\t- k_{i2} \\theta_{i2} - c_{i2} \\dot{\\theta}_{i2} + \\hat{\\bm s}_{i2,2}^T \\bm \\tau_{\\text{ext}_{i2},H_{i2}}\\\\  \n\t-  m_{\\text{sp}_{i2}} d_{i2} \\hat{\\bm s}_{i2,3}^T \\Big[ 2 [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}'_{S_{c,i2}/B} + [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm{r}_{S_{c,i2}/B} + l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} \\Big]\n\\end{multline}\n\nEqs. \\eqref{eq:spMotion1} and \\eqref{eq:sp3final} can now be re-written as:\n\\begin{equation}\n\ta_{i1,1} \\ddot\\theta_{i1} +  a_{i1,2} \\ddot{\\theta}_{i2}=\\bm f_{i1} \\ddot{\\bm{r}}_{B/N} + \\bm g_{i1}\\dot{\\bm\\omega}_{\\cal B/N} \n\t+v_{i1}\n\t\\label{eq:spMotion1Simple}\n\\end{equation}\n\n\\begin{equation}\n\ta_{i2,1} \\ddot\\theta_{i1} \n\t+ a_{i2,2}\\ddot\\theta_{i2} = \\bm f_{i2}\\ddot{\\bm{r}}_{B/N} + \\bm g_{i2}\\dot{\\bm\\omega}_{\\cal B/N} + v_{i2}\n\t\\label{eq:sp3finalSimple}\n\\end{equation}\n\nEqs.~\\eqref{eq:spMotion1Simple} and ~\\eqref{eq:sp3finalSimple} are combined and written in matrix form to utilize some linear algebra techniques.\n\\begin{equation}\n\t[A_i]\\begin{bmatrix}\n\t\t\\ddot \\theta_{i1}\\\\\n\t\t\\ddot \\theta_{i2}\n\t\\end{bmatrix}\n\t= [F_i] \\ddot{\\bm r}_{B/N} + [G_i]\\dot{\\bm\\omega}_{\\cal B/N} + \\bm v_i\n\t\\label{eq:thetadot}\n\\end{equation}\nEq.~\\eqref{eq:thetadot} can now be solved by inverting matrix $[A_i]$. Note the definition $[E_i] = [A_i]^{-1}$.\n\\begin{equation}\n\t\\begin{bmatrix}\n\t\t\\ddot \\theta_{i1}\\\\\n\t\t\\ddot \\theta_{i2}\n\t\\end{bmatrix}\n\t= [E_i][F_i] \\ddot{\\bm r}_{B/N} + [E_i][G_i]\\dot{\\bm\\omega}_{\\cal B/N} + [E_i]\\bm v_i\n\t\\label{eq:thetadot2}\n\\end{equation}\nAnd the subcomponents of $[E]$ are defined as\n\\begin{equation}\n\t[E] = \\begin{bmatrix}\n\t\t\\bm e_{i1}^T\\\\\n\t\t\\bm e_{i2}^T\n\t\\end{bmatrix}\n\t\\label{eq:E}\n\\end{equation}\nSince the modified Euler's equation, Eq.~\\eqref{eq:Final6}, has $\\ddot \\theta_{i1}$ and $\\ddot \\theta_{i2}$ terms, it is more convenient to use the expression for $\\ddot \\theta_i$ as\n\\begin{equation}\n\t\\ddot \\theta_{i1}\n\t= e_{i1}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i1}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} + e_{i1}^T\\bm v_i\n\t\\label{eq:thetadot4}\n\\end{equation}\n\\begin{equation}\n\t\\ddot \\theta_{i2}\n\t= e_{i2}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i2}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} + e_{i2}^T\\bm v_i\n\t\\label{eq:thetadot5}\n\\end{equation}\n\n\nThe next step in the back substitution method is to analytically substitute Eqs.~\\eqref{eq:thetadot4} and ~\\eqref{eq:thetadot5} into the translational and rotational EOMs repeated here for clarity:\n\\begin{multline}\n\tm_\\text{sc} \\ddot{\\bm r}_{B/N} -m_\\text{sc} [\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N} +  \\sum_{i=1}^{N_{S}}\\bigg(\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]\\ddot{\\theta}_{i1} +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}\\ddot{\\theta}_{i2}\\bigg) \\\\\n\t= \\bm F - 2m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'- m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\\\\\n\t-\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\bigg) \n\t\\label{eq:Rbddot4}\n\\end{multline}\n\n\\begin{multline}\n\tm_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N} + [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big) \\ddot{\\theta}_{i1}\n\t+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)\\ddot{\\theta}_{i2}\\bigg] \\\\\n\t= -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\\n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t\\dot{\\theta}_{i1} I_{s_{i1,2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B} +m_{\\text{sp}_{i1}}d_{i1}\\dot{\\theta}_{i1}^2  [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\\\\\n\t+ \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}[\\bm{\\tilde{\\omega}}_{\\cal B/N}]\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \t\\\\+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\big(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\big)\\bigg]\n\t+ \\bm{L}_B \n\t\\label{eq:Final7}\n\\end{multline}\n\nPerforming this substitution for translation yields:\n\\begin{multline}\n\tm_\\text{sc} \\ddot{\\bm r}_{B/N} -m_\\text{sc} [\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N} +  \\sum_{i=1}^{N_{S}}\\bigg(\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]\\Big(e_{i1}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i1}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t+ e_{i1}^T\\bm v_i\\Big) +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}\\Big(e_{i2}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i2}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} + e_{i2}^T\\bm v_i\\Big)\\bigg) \n\t= \\bm F - 2m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'- m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\\\\\n\t-\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\bigg) \n\t\\label{eq:Rbddot5}\n\\end{multline}\nCombining like terms yields:\n\\begin{multline}\n\t\\Bigg \\lbrace m_\\text{sc} [I_{3\\times 3}] +  \\sum_{i=1}^{N_{S}}\\bigg[\\Big(m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big)e_{i1}^T[F_i] +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}e_{i2}^T[F_i] \\bigg] \\Bigg \\rbrace \\ddot{\\bm r}_{B/N} \\\\\n\t+\\Bigg \\lbrace-m_\\text{sc} [\\tilde{\\bm{c}}] +  \\sum_{i=1}^{N_{S}}\\bigg[\\Big(m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big) e_{i1}^T[G_i] +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3} e_{i2}^T[G_i]\\bigg] \\Bigg \\rbrace \\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t= \\bm F - 2m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'- m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\\\\n\t+\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]e_{i1}^T\\bm v_i \n\t+m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}e_{i2}^T\\bm v_i \\bigg) \n\t\\label{eq:Rbddot6}\n\\end{multline}\nSubstitution into the rotational equation of motion:\n\\begin{multline}\n\tm_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N} + [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big[I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big] \\Big(e_{i1}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i1}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} + e_{i1}^T\\bm v_i\\Big)\\\\\n\t+\\big[ I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big]\\Big(e_{i2}^T[F_i] \\ddot{\\bm r}_{B/N} + e_{i2}^T[G_i]\\dot{\\bm\\omega}_{\\cal B/N} + e_{i2}^T\\bm v_i\\Big)\n\t\\bigg] \\\\\n\t= -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \\\\\n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t\\dot{\\theta}_{i1} I_{s_{i1,2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B} +m_{\\text{sp}_{i1}}d_{i1}\\dot{\\theta}_{i1}^2  [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\\\\\n\t+ \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}[\\bm{\\tilde{\\omega}}_{\\cal B/N}]\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \t\\\\+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\big(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\big)\\bigg]\n\t+ \\bm{L}_B \n\t\\label{eq:Final7sub}\n\\end{multline}\nAnd combining like terms yields:\n\\begin{multline}\n\t\\Bigg \\lbrace m_{\\text{sc}} [\\tilde{\\bm{c}}] + \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}\\\\\n\t+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T[F_i]\n\t+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T[F_i] \\bigg]\\Bigg \\rbrace \\ddot{\\bm r}_{B/N}\n\t\\\\+ \\Bigg \\lbrace [I_{\\text{sc},B}] + \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}\\\\\n\t+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T[G_i] +\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T[G_i] \\bigg]\\Bigg \\rbrace \\dot{\\bm\\omega}_{\\cal B/N}\n\t\\\\\n\t= -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} \n\t-  \\sum\\limits_{i=1}^{N_S} \\bigg[\n\t\\dot{\\theta}_{i1} I_{s_{i1,2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B} \\\\\n\t+m_{\\text{sp}_{i1}}d_{i1}\\dot{\\theta}_{i1}^2  [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\n\t+ \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}[\\bm{\\tilde{\\omega}}_{\\cal B/N}]\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \t\\\\+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\big(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\big) +   \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T\\bm v_i+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T\\bm v_i\\bigg]\n\t+ \\bm{L}_B \n\t\\label{eq:Final8}\n\\end{multline}\n\nWith the following definitions:\n\\begin{multline}\n\t[A_{\\text{contr}}] = \\sum_{i=1}^{N_{S}}\\bigg[\\Big(m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big)e_{i1}^T[F_i] +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}e_{i2}^T[F_i] \\bigg]\n\\end{multline}\\begin{multline}\n\t[B_{\\text{contr}}] =  \\sum_{i=1}^{N_{S}}\\bigg[\\Big(m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1}\\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big) e_{i1}^T[G_i] +m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3} e_{i2}^T[G_i]\\bigg]\n\\end{multline}\\begin{multline}\n\t\\bm v_{\\text{trans,contr}} = -\\sum_{i=1}^{N_{S}}\\bigg(m_{\\text{sp}_{i1}}d_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} +m_{\\text{sp}_{i2}}\\Big[l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\Big]\\\\\n\t+\\Big[m_{\\text{sp}_{i1}}d_{i1} \\bm{\\hat{s}}_{i1,3} +m_{\\text{sp}_{i2}}l_{i1} \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}} d_{i2}\\bm{\\hat{s}}_{i2,3}\\Big]e_{i1}^T\\bm v_i \n\t+m_{\\text{sp}_{i2}} d_{i2} \\bm{\\hat{s}}_{i2,3}e_{i2}^T\\bm v_i \\bigg) \n\\end{multline}\\begin{multline}\n\t[C_{\\text{contr}}] = \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}\\\\\n\t+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T[F_i]\n\t+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T[F_i] \\bigg]\n\\end{multline}\\begin{multline}\n\t[D_{\\text{contr}}] = \\sum\\limits_{i=1}^{N_S} \\bigg[  \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}\\\\\n\t+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T[G_i] +\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T[G_i] \\bigg]\\\n\\end{multline}\\begin{multline}\n\t[v_{\\text{rot,contr}}] = -\\sum\\limits_{i=1}^{N_S} \\bigg[\n\t\\dot{\\theta}_{i1} I_{s_{i1,2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{\\hat{s}}_{i1,2} \n\t+m_{\\text{sp}_{i1}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{r}'_{S_{c,i1}/B} +m_{\\text{sp}_{i1}}d_{i1}\\dot{\\theta}_{i1}^2  [\\tilde{\\bm{r}}_{S_{c,i1}/B}] \\bm{\\hat{s}}_{i1,1}\n\t\\\\\n\t+ \\big(\\dot{\\theta}_{i1}+\\dot{\\theta}_{i2}\\big) I_{s_{i2,2}}[\\bm{\\tilde{\\omega}}_{\\cal B/N}]\\bm{\\hat{s}}_{i2,2}\n\t+m_{\\text{sp}_{i2}} [\\bm{\\tilde{\\omega}}_{\\cal B/N}] [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{r}'_{S_{c,i2}/B} \t\\\\+m_{\\text{sp}_{i2}} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\big(l_{i1} \\dot{\\theta}_{i1}^2 \\bm{\\hat{s}}_{i1,1} + d_{i2}\\big(\\dot{\\theta}_{i1} + \\dot{\\theta}_{i2}\\big)^2\\bm{\\hat{s}}_{i2,1}\\big) +   \\big(I_{s_{i1,2}}\\bm{\\hat{s}}_{i1,2}+m_{\\text{sp}_{i1}}d_{i1} [\\tilde{\\bm{r}}_{S_{c,i1}/B}]   \\bm{\\hat{s}}_{i1,3} + I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}\\\\\n\t+m_{\\text{sp}_{i2}}l_{i1} [\\tilde{\\bm{r}}_{S_{c,i2}/B}]  \\bm{\\hat{s}}_{i1,3}+m_{\\text{sp}_{i2}}d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i1}^T\\bm v_i+\\big( I_{s_{i2,2}}\\bm{\\hat{s}}_{i2,2}+m_{\\text{sp}_{i2}} d_{i2} [\\tilde{\\bm{r}}_{S_{c,i2}/B}] \\bm{\\hat{s}}_{i2,3}\\big)e_{i2}^T\\bm v_i\\bigg]\n\\end{multline}\\begin{equation}\n\t[A]  = m_\\text{sc} [I_{3\\times 3}] + [A_{\\text{contr}}]\n\\end{equation}\\begin{equation}\n\t[B] = -m_\\text{sc} [\\tilde{\\bm{c}}] + [B_{\\text{contr}}]\n\\end{equation}\\begin{equation}\n\t\\bm v_{\\text{trans}} = \\bm F - 2m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'- m_\\text{sc} [\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c} + \\bm v_{\\text{trans,contr}}\n\\end{equation}\\begin{equation}\n\t[C] = m_{\\text{sc}} + [C_{\\text{contr}}]\n\\end{equation}\\begin{equation}\n\t[D] =  [I_{\\text{sc},B}] + [D_{\\text{contr}}]\n\\end{equation}\\begin{equation}\n\t\\bm v_{\\text{rot}} = -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} + \\bm{L}_B + \\bm v_{\\text{rot,contr}}\n\\end{equation}\n\n\nThis produces the following simplified equations:\n\n\\begin{equation}\n\t\\begin{bmatrix}\n\t\t[A] & [B]\\\\\n\t\t[C] & [D]\n\t\\end{bmatrix} \\begin{bmatrix}\n\t\t\\ddot{\\bm r}_{B/N}\\\\\n\t\t\\dot{\\bm\\omega}_{\\cal B/N}\n\t\\end{bmatrix} = \\begin{bmatrix}\n\t\t\\bm v_{\\text{trans}}\\\\\n\t\t\\bm v_{\\text{rot}}\n\t\\end{bmatrix}\n\\end{equation}\n\nSolving the system-of-equations by\n\n\\begin{equation}\n\t\\dot{\\bm\\omega}_{\\cal B/N} = \\Big([D] - [C]][A]^{-1}[B]\\Big)^{-1}(\\bm v_{\\text{rot}} - [C][A]^{-1}\\bm v_{\\text{trans}})\n\t\\label{eq:omegaDot}\n\\end{equation}\n\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = [A]^{-1} (\\bm v_{\\text{trans}} - [B]\\dot{\\bm\\omega}_{\\cal B/N})\n\t\\label{eq:rBNDDot}\n\\end{equation}\n\nNow Eq.~\\eqref{eq:omegaDot} and ~\\eqref{eq:rBNDDot} can be used to solve for $\\dot{\\bm\\omega}_{\\cal B/N}$ and $\\ddot{\\bm r}_{B/N}$. Once these second order state variables are solved for, Eqs.~\\eqref{eq:thetadot4} and ~\\eqref{eq:thetadot5} can be used to directly solve for $\\ddot \\theta_{i1}$ and $\\ddot \\theta_{i2}$. This shows that the back substitution method can work seamlessly for interconnected bodies. For this problem the number of interconnected bodies was fixed to be 2, and resulted in an additional $2\\times 2$ matrix inversion for each solar panel pair. This shows that for general interconnected bodies, this method would result in needing to invert a matrix based on the number of interconnected bodies. \n\n\n", "meta": {"hexsha": "1794ade97a6119892af82d27109b2c6844cdb070", "size": 129829, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/simulation/dynamics/dualHingedRigidBodies/_Documentation/secModelDescription.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/simulation/dynamics/dualHingedRigidBodies/_Documentation/secModelDescription.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/simulation/dynamics/dualHingedRigidBodies/_Documentation/secModelDescription.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 80.1908585547, "max_line_length": 1112, "alphanum_fraction": 0.5773979619, "num_tokens": 64246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6187804337438502, "lm_q1q2_score": 0.4367259656549012}}
{"text": "\\documentclass[Economics.tex]{subfiles}\r\n\\begin{document}\r\n\\chapter{Macroeconomic Policies}\r\nIn general, macroeconomic policies can be divided into demand management policies, and supply-side policies.\r\n\r\nDemand management policies in general consist of monetary policies and fiscal policies. Monetary policies involve the manipulation of monetary variables like exchange rate, interest rate and the supply of money to influence \\AD{}. Fiscal policies involve the use of government spending and taxation to influence \\AD{}.\r\n\\section{Exchange rate policy}\r\nDecreasing exchange rate increases net exports, as devaluing the currency reduces the cost of the country's exports in foreign currency while increasing the cost of imports in the country's currency, so assuming \\(\\PEDx{} > 0\\) and \\(\\PEDm{} > 1\\), the quantity demanded of the country's exports in foreign currency rises so export revenue rises, and the quantity demanded of imports in the country falls more than proportionately so import expenditure falls, which reinforce an increase in net export revenue, increasing \\AD{}. The reverse argument applies.\r\n\r\nThe condition that \\(\\PEDx{} > 0\\) and \\(\\PEDm{} > 1\\) can be extended and mathematically proven to simply having the sum of the two be greater than one. This is the Marshall-Lerner condition, which states that for a devaluation of a country's currency to increase net exports, \\(\\PEDx{} + \\PEDm{} > 1\\).\r\n\\subsection{Merits of exchange rate policy}\r\nFor countries with relatively large external demand, like Singapore, exchange rate policy has the greatest effect on \\AD{}, since net exports will make up the greatest proportion of \\AD{}. Net exports takes up about 75\\% of Singapore's \\AD{}, for example.\r\n\\subsection{Problems of exchange rate policy}\r\n\\subsubsection{Imported inflation}\r\nFor countries that import a large proportion of the raw materials used in production of goods, a devaluation of the currency may lead to imported inflation, with prices of goods in domestic currency increasing, because the price of imported raw materials in domestic currency increases, leading to an increased unit cost of production and thus a fall in supply of goods which involve imported raw materials. The price of exports in foreign currency thus may not fall as much, reducing the increase in net exports.\r\n\r\nIf the increase in net exports leads to demand-pull inflation, causing price levels to rise, then the price of export goods in domestic currency may increase, offsetting the fall in price of exports in foreign currency due to the devaluation, similarly reducing the increase in net exports.\r\n\\subsubsection{J-curve effect}\r\nA devaluation, in the short run, causes net exports and trade balance to fall due to the J-curve effect. The main reason for this is time lags, as producers and consumers take a while to adjust their purchases to the changed prices caused by the change in exchange rate. There may also be contractual agreements or planned advance orders, preventing the quantity of exports or imports from changing until the contracts lapse.  This causes export revenue to remain constant, assuming quantity of exports is constant, while import expenditure rises as a constant quantity of imports is combined with increasing prices of imports in domestic currency, so net exports falls. This is in line with the Marshall-Lerner condition, as quantities not changing implies the demands are both price inelastic.\r\n\\section{Interest rate policy}\r\nLowering interest rate increases consumption and investment as interest rate is the cost of borrowing, which when lowered will make consumers more willing and able to borrow to buy expensive items like cars, increasing consumption, and firms invest more as investments with lower expected returns will appear more profitable since the cost of borrowing to undertake those investments have fallen, increasing investment. Thus \\AD{} increases. The reverse argument applies.\r\n\r\nA reduced interest rate will also cause an outflow of hot money as investors seek higher returns from countries with higher interest rates, so the supply of the country's currency increases while the demand falls and so the currency depreciates. Prices of the country's exports in foreign currency falls while prices of imports in the country's currency rises, and assuming the Marshall-Lerner condition holds, net exports increases, also increasing \\AD{}. This is a small point, however.\r\n\\subsection{Merits of interest rate policy}\r\nSince investment increases, capital accumulation increases and this will benefit potential growth in the long run as \\AS{} will increase in future with increased capital accumulation.\r\n\\subsection{Problems with interest rate policy}\r\nIf the economy is in recession, consumer and business confidence may be low, and increasing interest rate may not increase consumption or investment by much as consumers want to save more in case they e.g.\\ become unemployed, and firms are pessimistic about investments. This reduces the effectiveness of interest rate policy.\r\n\r\nSome firms may not need to borrow in order to invest as they may have their own reserves. Changing interest rate will not really affect how much such firms invest, which diminishes the effectiveness of interest rate policy.\r\n\r\nSingapore does not use interest rate policy due to its choice of controlling its exchange rate and having free capital flow. If Singapore were to lower interest rates, for example, hot money would flow out of Singapore, foiling the policy.\r\n\\section{Fiscal policy}\r\nFiscal policies involve the use of government spending and taxation to influence \\AD{}.\r\n\r\nReducing personal and corporate income taxes will increase the disposable income of households and the post-tax profits of firms, increasing their purchasing power and expected yields from investments respectively. For households, they increase consumption of normal goods and so consumption increases. For firms, the marginal efficiency of investment curve shifts right and at every interest rate, investment increases. Thus \\AD{} increases.\r\n\r\nIncreasing government spending directly increases \\AD{}, it being a component of \\AD{}.\r\n\\subsection{Merits of fiscal policy}\r\nA fall in personal income taxes will increase the opportunity cost of leisure, which disincentivises leisure and encourages work. People who are currently not seeking jobs may decide to do so, which will boost \\AS{} in future.\r\n\r\nSince investment increases, capital accumulation increases and this will benefit potential growth in the long run as \\AS{} will increase in future with increased capital accumulation.\r\n\\subsection{Problems with fiscal policy}\r\nIncreasing government spending may lead to the crowding-out effect if government spending is financed by borrowing, as the government will be competing with private firms for loans, which increases the demand for loans and thus the interest rate, reducing investment and diminishing the increase in \\AD{} from increased government spending.\r\n\r\nThe government may also risk running into a budget deficit if it increases government spending. To finance these debts, the government may have to borrow, and then taxes may rise in future in order to repay loans, which will counter an increase in \\AD{} in the present. Too huge a government debt may weaken investor confidence which reduces foreign investment in the country, leading to capital flight, which will destabilise the exchange rate, and a reduced credit rating, which will make it more expensive for the country to borrow.\r\n\r\nFiscal policy may also involve time lags, depending on whether legislation is required to change in government spending or taxes, and how fast the changes cause an effect on consumption and investment.\r\n\r\nIf the economy is in recession, consumer and business confidence may be low, and direct taxes may not increase consumption or investment by much as consumers want to save more in case they e.g.\\ become unemployed, and firms are pessimistic about investments. This reduces the effectiveness of this form of fiscal policy.\r\n\r\nIn Singapore, fiscal policy has limited effect due to its small fiscal multiplier, which in turn is due to having a high marginal propensity to import and marginal propensity to save. The effect of tax cuts is also likely to be small, given that domestic demand is a relatively small component of \\AD{}, and that our tax base is small -- only one-third of the working population. Singapore's tax system is also not very counter-cyclical as taxes are based on the previous year's income: if the current year is a recession year while the previous is a boom year, individuals and firms pay tax in the current year based on higher incomes earned the previous year, when ideally the system should leave them with more money due to the recession.\r\n\\section{Other policies}\r\nTo solve a current account deficit, a government may use export subsidies and tax rebates for export industries to boost the country's exports by making their unit cost of production lower, in turn reducing export prices and thus increasing export revenue, assuming \\(\\PEDx{} > 1\\), boosting the current account and thus the balance of payments.\r\n\r\nThe government can also use protectionism to do so -- the above policy is actually a form of protectionism anyway.\r\n\r\nOf course, this comes with all the demerits of protectionism.\r\n\\section{Supply-side policy}\r\nSupply-side policies are a basket of policies used to influence \\AS{}. They are generally categorised into market-oriented policies and interventionist policies. Market-oriented policies rely on market forces and competition to achieve greater efficiency, while interventionist policies rely on market intervention and the correction of supposed market failures.\r\n\\subsection{Market-oriented policies}\r\nCutting direct tax rates, while primarily a fiscal policy, affects \\AS{} as well. As explained earlier, cutting corporate income taxes results in an increase in investments, increasing capital accumulation, innovation and the development of new technology, leading to an increase in productive capacity and thus \\AS{}. Lower personal income taxes increases the opportunity cost of leisure, increasing the incentive to work for longer or more efficiently and also enticing those previously not in the labour market to work. Supply in individual markets increases and so \\AS{} increases.\r\n\r\n\\paragraph{Problems} However, reducing personal income taxes may also encourage people to work fewer hours since they can get the same amount of disposable income while working less. Reducing corporate income taxes may result in firms paying higher dividends to shareholders instead of investing.\r\n\r\nCutting unemployment benefits will also increase the opportunity cost of leisure, which incentivises work, eventually leading to an increase in \\AS{}.\r\n\r\n\\paragraph{Problems} However, this may increase income inequality especially for those who are structurally unemployed, and if there is low unemployment, this will not help much at all.\r\n\r\nThe government can also encourage competition by introducing pro-competition policies like antitrust laws, removing barriers to entry to regulated markets, privatisation, and reducing trade barriers. The increase in competition encourages firms to become more efficient, producing a greater output from a given amount of resources. Unit cost of production falls, so supply curves shift right, and \\AS{} increases.\r\n\r\n\\paragraph{Problems} In practice, implementing such laws alienates the business community, and it also reduces supernormal profits, making it more difficult for firms to innovate and do research and development as they have less resources to do so.\r\n\r\nThe government can reform trade unions through laws that restrict the extent to which unions can push wages above equilibrium and enforce restrictive practives, increasing employment, labour market flexibility, and efficiency. The reduced labour costs in turn increase firms' profits, enabling more investment, helping \\AS{} increase in future.\r\n\r\n\\paragraph{Problems} In practice, implementing such laws will alienate workers. Flexible labour markets will also increase income inequality as workers are forced to accept jobs at lower wages. It also leads to lower job security as trade unions have less power with regards to retrenchment and the like, which may cause greater stress in the workplace and thus lower efficiency, diminishing the increase in \\AS{}.\r\n\\subsection{Interventionist policies}\r\nThe government can provide subsides for education and training, which will reduce the price of doing so. Employers and workers will be more willing and able to send employees to and attend, respectively, training. If the training helps to improve workers' productivity, each worker can produce more output per man hour, resulting in a lower unit cost of production, increasing supply and thus \\AS{}.\r\n\r\n\\paragraph{Merits} This also increases \\AD{} through an increase in government spending.\r\n\r\n\\paragraph{Problems} However, it requires time to take effect, and it may not be very effective at all, depending on how receptive workers are. It also requires government spending, and so has all the associated issues.\r\n\r\nSubsidising research and development will make firms more willing and able to conduct it as the price of doing so decreases. If the research results in new methods of production that are more efficient, the unit cost of production falls; firms may also be able to produce more from the same amount of resources, so supply and \\AS{} increases. \r\n\r\n\\paragraph{Merits} This also increases \\AD{} through an increase in government spending.\r\n\r\n\\paragraph{Problems} Research and development may not result in any better method of production -- it is uncertain. If this happens, funds used for the research and development by firms would have been wasted since an opportunity cost has been incurred and they could have been used for other purposes like upgrading equipment or giving employees bonuses, but instead they were channeled into research and development which ultimately did not result in an increase in profits or other benefit for the firm.\r\n\r\nTo combat search unemployment, the government can provide information through mass media, job agencies and job fairs, to help unemployed workers be matched to suitable jobs more quickly.\r\n\r\n\\paragraph{Problems} The success of such a policy depends really on how keen the unemployed are about getting unemployed. If they do not really want a job, they may not seek for jobs as actively, and so stay unemployed for longer.\r\n\\subsection{Merits of supply-side policy}\r\nSupply-side policy can act on both \\AD{} and \\AS{}, bringing about non-inflationary growth; the increase in \\AD{} helps to drive the increase in national income, while the increase in \\AS{} prevents inflation, allowing the actual growth to be sustained.\r\n\r\nIf prices are lowered due to supply-side policy, it may also improve the price competitiveness of exports, which will improve the country's current account and thus balance of payments.\r\n\\subsection{Problems with supply-side policy}\r\nSup\\-ply-side policies often involve high costs, which will incur a high opportunity cost, as resources that could be channeled elsewhere are now channeled to these policies, and if the benefits of the policy are less than the benefits that the resources could have brought if used elsewhere, then there is a misallocation of resources.\r\n\r\nIf the costs of supply-side policy are funded through taxes, the government may increase taxes, which may have disincentive effects on work as the opportunity cost of leisure is decreased. Workers now have less incentive to work, which may cause labour productivity to fall, offsetting the benefits from supply-side policy.\r\n\r\nIf the costs are otherwise funded through government borrowing, and taxes may rise in future in order to repay loans, which will lead to disincentive effects as above. Too huge a government debt may weaken investor confidence which reduces foreign investment in the country, leading to capital flight, which will destabilise the exchange rate, and a reduced credit rating, which will make it more expensive for the country to borrow.\r\n\r\nSupply-side policies are also uncertain, as mentioned earlier.\r\n\r\nOn their own, supply-side policies will not cause actual growth if the economy is not near or at full employment. An increase in \\AD{} is needed for the economy to have actual growth.\r\n\\section{Macroeconomic conflict}\r\nMacroeconomic goals can sometimes conflict with each other. Most often, inflation conflicts with everything else as combatting inflation usually involves cooling the economy and reducing pressures while the other goals involve boosting the economy.\r\n\\end{document}\r\n", "meta": {"hexsha": "11738ac58f897d56b5cbdbfe4e6b4b587059632b", "size": 16794, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX/Economics/10_macro_policies.tex", "max_stars_repo_name": "oliverli/A-Level-Notes", "max_stars_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-05T11:44:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-05T11:44:33.000Z", "max_issues_repo_path": "TeX/Economics/10_macro_policies.tex", "max_issues_repo_name": "oliverli/A-Level-Notes", "max_issues_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX/Economics/10_macro_policies.tex", "max_forks_repo_name": "oliverli/A-Level-Notes", "max_forks_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 154.0733944954, "max_line_length": 796, "alphanum_fraction": 0.8073121353, "num_tokens": 3172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4367259656549011}}
{"text": "\\documentclass{article}\n%\\usepackage{fullpage}\n%\\usepackage{nopageno} \n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{tikz}\n\\usetikzlibrary{shapes.geometric, calc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage[normalem]{ulem}\n\\usepackage{fancyhdr}\n\\usepackage{cancel}\n\\usepackage{enumerate}\n%\\renewcommand\\headheight{12pt}\n\\pagestyle{fancy}\n\\lhead{May 2, 2014}\n\\rhead{Jon Allen}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\nPart 2 (3 points): Due in class Friday, May 2.\n\nChapter 8: \\#33 (just the first part where you calculate R7 and R8), and the problems below.\n\nSchroder exercise 1: Draw the dissection of the 11-gon that corresponds to the bracketing ( a1 ( ( a2 a3 a4 a5 ) a6 ) (a7 (a8 a9) a10 ) ).\n\nSchroder exercise 2: Draw the Schroder paths from (0,0) to (6,0). Verify that exactly half have no horizontal steps on the x-axis.\n\\section*{Chapter 8}\n\\begin{enumerate}\n\\setcounter{enumi}{31}\n  \\item\n  Use the recurrence relation (8.31) to compute the small Schr\\\"{o}der numbers $s_8$ and $s_9$.\n\n  We are given the $s_1$ through $s_7$ on page 310. They are $1,1,3,11,45,197,903,\\dots$\n  \\begin{align*}\n    0&=(n+2)s_{n+2}-3(2n+1)s_{n+1}+(n-1)s_n\\\\\n    s_{n+2}&=\\frac{3(2n+1)}{n+2}s_{n+1}+\\frac{1-n}{n+2}s_n\\\\\n    s_{n}&=\\frac{3(2(n-2)+1)}{(n-2)+2}s_{n-1}+\\frac{1-(n-2)}{(n-2)+2}s_{n-2}\\\\\n    s_{n}&=\\frac{3(2n-3)}{n}s_{n-1}+\\frac{3-n}{n}s_{n-2}\\\\\n    s_8&=\\frac{3\\cdot13}{8}\\cdot903-\\frac{5}{8}\\cdot197\\\\\n    &=4279\\\\\n    s_9&=\\frac{3\\cdot15}{9}\\cdot4279-\\frac{6}{9}\\cdot903\\\\\n    &=20793\n  \\end{align*}\n\n  \\item\n  (just the first part where you calculate R7 and R8)\n\n  Use the recurrence relation (8.32) to compute the large Schr\\\"{o}der numbers $R_7$ and $R_8$. Verify that $R_7=2s_8$ and $R_8=2s_9$, as stated in Corollary 8.5.8.\n\\begin{align*}\n  R_n&=R_{n-1}+\\sum\\limits_{k=0}^{n-1}{R_kR_{n-1-k}},\\quad(n\\ge1)\\\\\n  R_0&=1\\\\\n  R_1&=1+1=2\\\\\n  R_2&=2+2+2=6\\\\\n  R_3&=6+6+4+6=22\\\\\n  R_4&=22+22+12+12+22=90\\\\\n  R_5&=90+90+44+36+44+90=270+88+36=394\\\\\n  R_6&=394+394+180+132+132+180+394=1806\\\\\n  R_7&=1806+1806+788+540+484+540+788+1806=8558\\\\\n  R_8&=8558+8558+3612+2364+1980+1980+2364+3612+8558=41586\\\\\n\\end{align*}\nAnd since I accidentally did \\#32 anyhow, I could as well do the second part. $41586/2=20793$ and $8558/2=4279$\n\\end{enumerate}\n\\section*{Schr\\\"{o}der Exercises}\n\\begin{enumerate}\n  \\item\n  Draw the dissection of the 11-gon that corresponds to the bracketing $( a_1 ( ( a_2 a_3 a_4 a_5 ) a_6 ) (a_7 (a_8 a_9) a_{10} ) )$.\n  \n  \\begin{tikzpicture}\n    \\node (pol) [draw, thick, black,rotate=90,minimum size=6cm,regular polygon, regular polygon sides=11] at (0,0) {}; \n\n    \\foreach \\n [count=\\nu from 1, remember=\\n as \\lastn, evaluate={\\nu+\\lastn}] in {1,2,...,10} \n    \\node[anchor=\\n*(360/11)]at(pol.side \\n){$a_{\\nu}$};\n    \\draw (pol.corner 8) -- node[anchor=north]{$(a_8 a_9)$}(pol.corner 10);\n    \\draw (pol.corner 7) -- node[anchor=south]{$(a_7(a_8 a_9)a_{10})$}(pol.corner 11);\n    \\draw (pol.corner 2) -- node[anchor=north]{$(a_2a_3a_4a_5)$}(pol.corner 6);\n    \\draw (pol.corner 2) -- node[anchor=east]{$((a_2a_3a_4a_5)a_6)$}(pol.corner 7);\n    \\node[anchor=360]at(pol.side 11){$(a_1((a_2a_3a_4a_5)a_6)(a_7(a_8 a_9)a_{10}))$};\n  \\end{tikzpicture}\n\n  \\item\n  Draw the Schroder paths from $(0,0)$ to $(6,0)$. Verify that exactly half have no horizontal steps on the $x$-axis.\n\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,0) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,0) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,0) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,0) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,.5) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,0) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,.5) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,0) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,.5) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,.5) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,1.5) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,1) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,0) node (p2) {}\n  (1.5,.5) node (p3) {} (2,0) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,.5) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,.5) node (p2) {}\n  (1.5,.5) node (p3) {} (2,.5) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,1) node (p2) {}\n  (1.5,.5) node (p3) {} (2,.5) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n  \\begin{tikzpicture}[every node/.style={draw,shape=circle,fill=black,inner sep=0pt,minimum size=3pt}]\n  \\path (0,0) node (p0) {} (.5,.5) node (p1) {} (1,.5) node (p2) {}\n  (1.5,.5) node (p3) {} (2,1) node (p4) {} (2.5,.5) node (p5) {} (3,0) node (p6) { };\n  \\draw (p0) -- (p1) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6);\n  \\draw (0,0) -- (0,1.5) -- (3,1.5) -- (3,0);\n  \\end{tikzpicture}\n\n  \\#1,2,3,4,5,6,6,8,9,12,14$\\to$11 out of 22 have horizontal steps on $x$-axis\n\\end{enumerate}\n\\end{document}\n", "meta": {"hexsha": "31424c83be34ddfb7ab9898c403c5e9aa1191566", "size": 11907, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combinatorics/combinatorics-hw-2014-05-02.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "combinatorics/combinatorics-hw-2014-05-02.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combinatorics/combinatorics-hw-2014-05-02.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.8778280543, "max_line_length": 164, "alphanum_fraction": 0.5369110607, "num_tokens": 5878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4367259595607537}}
{"text": "\\chapter{Interaction between an Atom and a Laser Field}\n\\label{AppendixLMI}\n\nWe consider an electromagnetic field with the vector and electrostatic potential\n\\begin{align}\n  \\vec{A}(\\vec{r}, t)\n  &= \\frac{E_{0}}{\\omega} \\vec{e}_z \\sin\\left( ky - \\omega t \\right)\\,, \\\\\n  \\Phi(\\vec{r}, t) &= 0\\,.\n\\end{align}\nThis corresponds to a cosine shape electromagnetic field propagating along the\n$y$-axis, with the electric field oscillating in $z$-direction and the magnetic\nfield oscillating in $y$-direction,\n\\begin{align}\n  \\vec{E}(\\vec{r}, t) &= - \\frac{\\partial}{\\partial t} \\vec{A}(\\vec{r}, t)\n                         - \\vec{\\nabla} \\Phi(\\vec{r}, t)\n                       = E_0 \\vec{e}_z \\cos(ky - \\omega t)\\,, \\\\\n  \\vec{B}(\\vec{r}, t) &= \\vec{\\nabla} \\times \\vec{A}(\\vec{r}, t)\n                       = \\frac{\\partial}{\\partial y} A_z \\vec{e}_x\n                       = B_0 \\vec{e}_x \\cos(ky - \\omega t)\\,,\n\\end{align}\nwith $B_0 = \\frac{E_0}{\\omega} k = \\frac{E_0}{c}$, where $k=\\frac{\\omega}{c}$,\n$c$ is the speed of light and $\\omega$ is the laser frequency.\n\nThe Hamiltonian for an atom's valence electron at position $\\vec{r}$, with\nelectron mass $m$, electron-charge $q$, and $\\vec{r}$ and $\\vec{p}$ now being\noperators, reads\n\\begin{equation}\n\\begin{split}\n\\Op{H}\n  & = \\frac{1}{2m} \\left[\n      \\vecOp{p} - q \\vecOp{A}(\\vecOp{r}, t)\n    \\right]^2\n    + \\Op{V}(\\vecOp{r})\n    - \\frac{q}{m} \\vecOp{S} \\cdot \\vecOp{B}(\\vecOp{r}, t)\n    + \\vec{\\nabla} \\Op{\\Phi}(\\vecOp{r}, t)\n \\\\ &\n  = \\Op{H}_0 - \\frac{q}{m} \\vecOp{p} \\cdot \\vecOp{A}\n             - \\frac{q}{m} \\vecOp{S} \\cdot \\vecOp{B}\n             + \\frac{q}{2m} \\left[ \\vecOp{A}(\\vecOp{r}, t)\\right]^2\\,,\n  \\label{eq:LMI_ham}\n\\end{split}\n\\end{equation}\nwith the electron's drift Hamiltonian\n\\begin{equation}\n  \\Op{H}_0 = \\frac{\\vecOp{p}^{\\,2}}{2m} + \\Op{V}(\\vecOp{r})\\,,\n\\end{equation}\nand the spin operator $\\vecOp{S}$ coupling to the magnetic field.\nThe origin of the coordinate system is in the atoms nucleus.\nSince $\\Norm{\\vec{A}^{\\,2}} \\ll \\Norm{\\vec{A}}$ for realistic laser field\namplitudes, we set the last term to zero.\n\nThe spatial dependence of the vector potential, $ky = \\frac{2\\pi y}{\\lambda}$,\nwhere $y$ is on the order of an atomic radius $a_0$ and $\\lambda$ is the\nwavelength of the laser is extremely small. We can therefore Taylor-expand the\nvector potential as\n\\begin{equation}\n\\begin{split}\n  \\vec{A}(\\vec{r}, t)\n  & = \\frac{E_0}{w} \\vec{e}_z \\sin(ky - \\omega t)\n  \\\\\n  & = \\frac{E_0}{2 \\ii \\omega} \\vec{e}_z \\left(\n        \\ee^{\\ii k y} \\ee^{-\\ii \\omega t} - \\ee^{-\\ii k y} \\ee^{\\ii \\omega t}\n      \\right)\n  \\\\\n  & \\approx\n      \\frac{E_0}{2 \\ii \\omega} \\vec{e}_z \\left(\n        (1 + \\ii k y) \\ee^{-\\ii \\omega t} - (1 - \\ii k y) \\ee^{\\ii \\omega t}\n      \\right)\n  \\\\\n  & = \\frac{E_0}{w} \\vec{e}_z \\sin(\\omega t) + B_0 y \\vec{e}_z \\cos(\\omega t)\\,.\n\\end{split}\n\\label{eq:LMI_taylor}\n\\end{equation}\n\nAlso, since an electron that is localized with a Bohr radius $a_0$\n\\index{Bohr radius}\nmust have a minimum momentum $\\vecOp{p}$ such that $\\frac{\\hbar}{p} \\le a_0$, and\n$\\vecOp{S}$ is on the order of $\\hbar$, we can show\n$\\Norm{\\vecOp{p} \\cdot \\vecOp{A}} \\gg \\Norm{\\vecOp{S}\\cdot \\vecOp{B}}$,\n\\begin{equation}\n  \\frac{\\Norm{\\vecOp{S} \\cdot \\vecOp{B}}}{\\Norm{\\vecOp{p} \\cdot \\vecOp{A}} }\n  \\approx \\frac{\\hbar k E_0/\\omega}{p E_0 / \\omega}\n  = \\frac{\\hbar k}{p}\n  < \\frac{a_0}{\\lambda} \\ll 1\\,.\n\\end{equation}\nTherefore, we are justified in approximating\n\\begin{equation}\n  \\vec{B}(\\vec{r}, t) \\approx B_0 \\vec{e}_x \\cos{\\omega t}\\,.\n\\end{equation}\n\nInserting this and Eq.~\\eqref{eq:LMI_taylor} into Eq.~\\eqref{eq:LMI_ham} yields\n\\begin{equation}\n  \\Op{H}\n  \\approx\n    \\Op{H}_0\n    - \\frac{q}{m} \\frac{E_0}{\\omega} \\Op{p}_z \\sin(\\omega t)\n    - \\frac{q B_0}{m} B_0 \\Op{p}_z \\Op{y} \\cos(\\omega t)\n    - \\frac{q}{2m} \\Op{S}_x B_0 \\cos(\\omega t)\\,.\n\\end{equation}\nFurthermore,\n\\begin{equation}\n  \\Op{p}_z \\Op{y}\n   = \\frac{1}{2} \\left(\\Op{p}_z \\Op{y} - \\Op{z} \\Op{p}_y\\right)\n     +\\frac{1}{2} \\left(\\Op{p}_z \\Op{y} - \\Op{z} \\Op{p}_y\\right)\n  = \\frac{1}{2} \\Op{L}_x +\\frac{1}{2} \\left(\\Op{p}_z \\Op{y}\n     - \\Op{z} \\Op{p}_y\\right)\\,,\n\\end{equation}\nresulting in\n\\begin{equation}\n\\begin{split}\n  \\Op{H}\n &\n  \\approx\n    \\Op{H}_0\n    - \\frac{q}{m} \\frac{E_0}{\\omega} \\Op{p}_z \\sin(\\omega t)\n    - \\frac{q}{2 m c} E_0 \\cos(\\omega t)\n      \\left[ \\Op{p}_z \\Op{y} - \\Op{z} \\Op{p}_y\\right]\n + \\\\ & \\quad\n    - \\frac{q}{2m} \\left(\\Op{L}_x + \\Op{S}_x\\right) B_0 \\cos(\\omega t)\\,.\n\\end{split}\n\\end{equation}\n\nThe three interaction terms are interpreted as follows:\n\\begin{itemize}[noitemsep]\n  \\item\n  \\begin{equation}\n  \\Op{H}_{ED} = \\frac{q}{m} \\frac{E_0}{w} \\Op{p}_z \\sin(\\omega t)\n  \\end{equation}\n  is the \\emph{electric dipole} interaction in momentum space.\n  \\index{dipole moment!electric}\n  It can be rewritten to its more familiar form in coordinate space\n  \\begin{equation}\n  \\Op{H}_{ED} = q \\Op{z} \\, E_0 \\cos(\\omega t) = \\Op{\\mu} E_0 \\cos(\\omega t)\\,,\n  \\end{equation}\n  where $\\Op{\\mu}$ has been introduced as the dipole operator.\n  \\index{dipole operator}\n  \\item\n  \\begin{equation}\n    \\Op{H}_{EQ} = - \\frac{q}{2 m c} E_0 \\cos(\\omega t)\n                    \\left[ \\Op{p}_z \\Op{y} - \\Op{z} \\Op{p}_y\\right]\n  \\end{equation}\n  describes the \\emph{electric quadrupole} interaction.\n  \\index{quadrupole moment!electric}\n  \\begin{item}\n  \\begin{equation}\n    \\Op{H}_{MD} = - \\frac{q}{2m} \\left(\\Op{L}_x\n                  + \\Op{S}_x\\right) B_0 \\cos(\\omega t)\n  \\end{equation}\n  describes the \\emph{magnetic dipole} interaction.\n  \\index{dipole moment!magnetic}\n  \\end{item}\n\\end{itemize}\nBoth the electric quadrupole and the magnetic dipole are negligible compared\nto the electric dipole. Therefore, in the dipole-approximation the total\nHamiltonian becomes\n\\begin{equation}\n  \\Op{H} \\approx \\Op{H}_0 + \\Op{\\mu} E(t)\\,.\n  \\label{eq:LMI_dipole_ham}\n\\end{equation}\nThe dipole approximation results from the assumption that the wavelength of the\nlaser is much larger than the width of the atom, and thus that the spatial\ndependence of the field can be dropped, allowing to define the $z$-component of\nthe electric field as\n\\begin{equation}\n  E(t)  = E_0 \\cos(\\omega t)\\,.\n\\end{equation}\n\nWhen Eq.~\\eqref{eq:LMI_dipole_ham} is written in the energy representation given\nby the eigenstates of $\\Op{H}_0$, the selection rules for the dipole transitions\nare obtained. That is, for certain quantum numbers the corresponding matrix\nelement of $\\Op{\\mu}$ will vanish. For a Hydrogen atom with eigenstates\n$\\Ket{nlm}$, the dipole is zero unless $\\Delta l = 1$ and $\\Delta m = 0, 1$.\n\\index{selection rules}\n\n\\enlargethispage{\\baselineskip}\nFor example, we may consider\na Hamiltonian for a sub-system consisting of three levels $\\Ket{0}$, $\\Ket{1}$,\nand $\\Ket{2}$, with energies $E_0$, $E_1$, $E_2$. The dipole transition $\\Ket{0}\n\\rightarrow \\Ket{1}$ and $\\Ket{2} \\rightarrow \\Ket{3}$ is allowed with\na resulting dipole moment of $\\mu_{01} = \\Braket{0|\\Op{\\mu}|1}$ and\n$\\mu_{12}=\\Braket{1|\\Op{\\mu}|2}$, respectively, but\n$\\Ket{1} \\rightarrow \\Ket{3}$ is forbidden. This Hamiltonian\nwould we written in the energy representation as\n\\begin{equation}\n  \\Op{H} = \\begin{pmatrix}\n    E_0           & \\mu_{01} E(t) &   0           \\\\\n    \\mu_{01} E(t) & E_1           & \\mu_{12} E(t) \\\\\n    0             & \\mu_{12} E(t) & E_2           \\\\\n  \\end{pmatrix}\\,,\n\\end{equation}\nthe form used for the Hamiltonians e.g.\\ in chapters~\\ref{chap:robust}\nand~\\ref{chap:3states}.\n\n\n", "meta": {"hexsha": "023acda5cd64fb7412c215479b2679adf01302b9", "size": 7430, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/appendixLMI.tex", "max_stars_repo_name": "goerz/dissertation", "max_stars_repo_head_hexsha": "ee8ae29b5da1bc6033260224ae6444fd7f4c4a2f", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-05-09T03:22:23.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-11T13:33:43.000Z", "max_issues_repo_path": "chapters/appendixLMI.tex", "max_issues_repo_name": "goerz/dissertation", "max_issues_repo_head_hexsha": "ee8ae29b5da1bc6033260224ae6444fd7f4c4a2f", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/appendixLMI.tex", "max_forks_repo_name": "goerz/dissertation", "max_forks_repo_head_hexsha": "ee8ae29b5da1bc6033260224ae6444fd7f4c4a2f", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1025641026, "max_line_length": 81, "alphanum_fraction": 0.6204576043, "num_tokens": 2847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115012, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4366744581914794}}
{"text": "\\label{sec:experiments}\n\n\\subsection{Toy Problem -- Annulus}\n\\label{sec:annulus}\nWe first demonstrate our approach on a toy problem.\nThe true generative model of the observed data is a constant speed circular orbit around the origin in the $x$-$y$ plane, such that $\\mathbf{x}_t = \\left\\lbrace x_t, y_t, \\dot{x}_t, \\dot{y}_t \\right\\rbrace \\in  \\mathbb{R}^4$.\nTo analyze this data we use a misspecified model that only simulates linear forward motion.\nTo overcome the model mismatch and fit the observed data, we add Gaussian noise to position and velocity.\nWe impose a failure constraint limiting the change in the distance of the point from the origin to a fixed threshold.\nThis condition mirrors our observation that states in brittle simulators have large allowable perturbations in particular directions, but very narrow permissible perturbations in other directions.\nThe true radius is unknown and so we must amortize over possible radii.\n\n\\input{figures/figure_3}\n\nThe results of this experiment are shown in Figure~\\ref{fig:ring}.\nThe interior of the black dashed lines in Figure~\\ref{fig:ring:space} indicates the permissible $\\dot{x}$-$\\dot{y}$ perturbation, for the given position and zero velocity, where we have centered each distribution on the current position for ease of visual inspection.\nRed contours indicate the original density $p(\\mathbf{z}_t | \\mathbf{x}_{t-1})$, and blue contours indicate the learned density $q_{\\phi}(\\mathbf{z}_t | \\mathbf{x}_{t-1})$.\nThe fraction of the probability mass outside the black dashed region is the expected rejection rate.\nFigure~\\ref{fig:ring:ar} shows the rejection rate drops from approximately $75\\%$ under the original model to approximately $4\\%$ using a trained $q_{\\phi}$.\n\n\\input{figures/figure_4}\n\nWe then use the learned $q_{\\phi}$ as the perturbation proposal in an SMC sweep, where we condition on noisy observations of the $x$-$y$ coordinates.\nAs we focus on the sample efficiency of the sweep, we fix the number of calls to the simulator in Algorithm \\ref{alg:rs} to a single call, instead of proposing and rejecting until acceptance.\nFailed particles are then not resampled (with certainty) during the resampling.\nThis means that each iteration of the SMC makes a fixed number of calls to the simulator, and hence we can compare algorithms under a fixed sample budget.\nFigure \\ref{fig:ring:smc:var} shows that we recover lower variance evidence approximations for a fixed sample budget by using $q_{\\phi}$ instead of $p$.\nA paired t-test evaluating the difference in variance returns a p-value of less than $0.0001$, indicating a strong statistical difference between the performance under $p$ and $q_{\\phi}$, confirming that using $q_{\\phi}$ increases the fidelity of inference for a fixed sample budget.\n\n\\subsection{Bouncing Balls}\n\\label{sec:experiments:bb}\nOur second example uses a simulator of balls bouncing elastically, as shown in Figure \\ref{fig:balls:trajectory}.\nWe model the position and velocity of each ball, such that the dimensionality of the state vector, $\\mathbf{x}_t$, is four times the number of balls.\nWe add a small amount of Gaussian noise at each iteration to the position and velocity of each ball.\nThis perturbation induces the possibility that two balls overlap, or, a ball intersects with the wall, representing an invalid physical configuration and results in simulator failure.\nWe note that here, we are conditioning on the state of \\emph{all} balls simultaneously, and proposing the perturbation to the state \\emph{jointly}.\n\nFigure \\ref{fig:balls:space} shows the distribution over position perturbation of a single ball, conditioned on the other ball being stationary.\nBlue contours show the estimated distribution over accepted perturbations learned by autoregressive flow.\nFigure \\ref{fig:balls:rr} shows the rejection rate under $p$ and $q_{\\phi}$ as a function of the position of the first ball, with the second ball fixed in the position shown, showing that rejection has been all but eliminated.\nWe again see a reduction in the variance of the evidence approximation computed by a particle filter when using $q_{\\phi}$ instead of $p$ (figure in the supplementary materials).\n\n\\subsection{MuJoCo}\n\\label{sec:experiments:tosser}\nWe now apply our method to the popular robotics simulator MuJoCo~\\citep{todorov2012mujoco}, specifically using the built-in example ``tosser,'' where a capsule is ``tossed'' by an actuator into a bucket, shown in Figure \\ref{fig:tosser:im}.\nTosser displays ``choatic'' aspects, as minor changes in the position of the object results in large changes in the trajectories achieved by the simulator.\n\nMuJoCo allows some overlap between the objects to simulate contact dynamics. \nThis is an example of model misspecification borne out of the requirements of reasonably writing a simulator.\nWe therefore place a hard limit on the amount objects are allowed to overlap.\nThis is an example of a user-specified constraint that requires the simulator to be run to evaluate.\nWe add Gaussian distributed noise to the position and velocity of the capsule.\n\n\\input{figures/figure_5.tex}\n\nFigure \\ref{fig:tosser} shows the results of this experiment.\nThe capsule is mostly in free space resulting in an average rejection rate under $p$ of $10\\%$.\nFigure \\ref{fig:tosser:ar} shows that the autoregressive flow learns a proposal with a lower rejection rate, reaching $3\\%$ rejection.\nHowever these rejections are concentrated in the critical regions of state-space, where chaotic behavior occurs, and so this reduction yields an large reduction in the variance of the evidence approximation, as shown in Figure \\ref{fig:tosser:smc:var}.\n\n\\input{figures/figure_6.tex}\n\nWe conclude this example by evaluating our method on hypothesis testing using pseudo-marginal evidence estimates.\nThe results for this are shown in Figure \\ref{fig:tosser_hyp}.\nWe test $5$ different hypothesis of the mass of the capsule.\nUsing $p$ results in higher variance evidence approximations than when $q_{\\phi}$ is used. \nAdditionally, under $p$ the wrong model is selected ($2$ instead of $3$), although with low significance ($p=0.125$), while using $q_{\\phi}$ selects the correct hypothesis with $p=0.0127$.\nFor this experiment we note that $q_{\\phi}$ was trained on a single value of mass, and that this ``training mass'' was different to the ``testing mass.''\nWe believe this contributes to the increased variance in hypothesis $1$, which is very light compared to the training mass.\nTraining a $q_{\\phi}$ with a further level of amortization over different mass values would further increase the fidelity of the model selection.\nThis is intimately linked with the larger project of jointly learning the model, and so we defer investigation to future works.\n\n\\subsection{Neuroscience Simulator}\n\\label{sec:sub:wormsim}\nWe conclude by applying our algorithm to a simulator for the widely studied \\emph{Caenorhabditis elegans} roundworm.\nWormSim, presented by \\citet{boyle2012gait}, is a simulator of the locomotion of the worm, using a $510$ dimensional state representation.\nWe apply perturbations to a $98$ dimensional subspace defining the physical position of the worm, while conditioning on the full $510$ dimensional state vector.\nThe expected rate of failure increases sharply as a function of the scale of the perturbation applied, as shown in Figure \\ref{fig:wormsim:bot_rate}, as the integrator used in WormSim is unable to integrate highly perturbed states.\n\nThe rejection rate during training is shown in Figure \\ref{fig:wormsim:bot_nf_rate}.\nWe are able to learn an autoregressive flow with lower rejection rates, reaching approximately $53\\%$ rejection, when $p$ has approximately $75\\%$ rejection.\nAlthough the rejection rate is higher than ultimately desired, we include this example as a demonstration of how rejections occur in simulators through integrator failure.\nWe believe larger flows with regularized parameters can reduce the rejection rate further.\n", "meta": {"hexsha": "9941de194063c67f816d6db81067eca5861107c5", "size": 7982, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/paper/experiments.tex", "max_stars_repo_name": "plai-group/stdr", "max_stars_repo_head_hexsha": "43dabcd3db2f52ac89b8dfa25e850cae25726881", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/paper/experiments.tex", "max_issues_repo_name": "plai-group/stdr", "max_issues_repo_head_hexsha": "43dabcd3db2f52ac89b8dfa25e850cae25726881", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/paper/experiments.tex", "max_forks_repo_name": "plai-group/stdr", "max_forks_repo_head_hexsha": "43dabcd3db2f52ac89b8dfa25e850cae25726881", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.0238095238, "max_line_length": 283, "alphanum_fraction": 0.7934101729, "num_tokens": 1824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4366633464137479}}
{"text": "\n\n\n\\section{Eager Typechecking}\n\nThere are two variations on eager typechecking. \nThey both implement pure Canonical LF, in the sense that\nterms remain canonical throughout the typechecking process.\n(We will admit non-canonical terms during lazy typechecking.)\n\nThe difference between the variations lies in the treatment\nof substitutions. The first variation\nconsiders substitutions as either a $\\Shift^n$ or a $M\\cdot\\sigma$.\nThe second adds a ``lazy'' composition $\\sigma_1\\Comp\\sigma_2$.\nWe write the rules for both versions together, as the majority\nare identical.  Where there are extra rules needed for the\nextra case of a substitution, they will be labelled as such.\n\n%-------------------------------------------------------------------------------\n% Terms                                                                         \n%-------------------------------------------------------------------------------\n\n\\subsection{Terms}\n\n$$\n\\begin{array}{llll}\n\\mathbf{Levels} & L & ::= & \\Type \\Spb \\Kind \\\\\n\\mathbf{Expressions} & U,V & ::= & L \\Spb \\PiTyp{U_1}{U_2} \\Spb \\lambda U \\Spb H\\cdot S \\\\\n\\mathbf{Heads} & H & ::= & c \\Spb i\\\\\n\\mathbf{Spines} & S & ::= & \\Nil \\Spb U;S\\\\\n\\mathbf{Eager\\ Substitutions} & \\sigma & ::= & M\\cdot\\sigma \\Spb \\Shift^n \\\\\n\\mathbf{Lazy\\ Substitutions} & \\sigma & ::= & M\\cdot\\sigma \\Spb \\Shift^n \\Spb \\sigma_1 \\Comp \\sigma_2\\\\\n\\end{array} \n$$\n\n\n%-------------------------------------------------------------------------------\n% Typecheck                                                                     \n%-------------------------------------------------------------------------------\n\n\\subsection{Typechecking}\n\n\\bigskip \n\\framebox{$\\CheckTy{U}{V}$}\n\\bigskip \n\n$$\n\\begin{array}{cc}\n\\infer{\\CheckTy{\\Type}{\\Kind}}{} &\n\\infer{\\CheckTy{\\PiTyp{A}{U}}{V}}{\\CheckTy{A}{\\Type} & \\CheckTy[\\Gamma,A]{U}{V}}\\\\\\\\\n\\infer{\\CheckTy{c\\cdot S}{V}}{\\Sigma(c) = U & \\Focus{S}{U}{V'} & \\Equiv{V'}{V}} &\n\\infer{\\CheckTy{\\Lam{M}}{\\PiTyp{A_1}{A_2}}}{\\CheckTy[\\Gamma,A_1]{M}{A_2}} \\\\\\\\\n\\infer{\\CheckTy{i\\cdot S}{A_2}}{\\Gamma(i)=A_1 & \\Focus{S}{A_1}{A_2'} & \\Equiv{A_2'}{A_2}}\n\\end{array} \n$$\n\n\\bigskip \n\n\\begin{Note}\\label{context:shift} \nNote that you must shift the type you extract from $\\Gamma$, as the\nfree variables (indices) should point to the slots before $i$.  Moving\nthe type $A$ from the context to the consequent must adjust the pointers.\nWe thus define $\\Gamma(i) = A$ as the $i$th element of $\\Gamma$\nunder $\\Shift^i$.\n\\end{Note} \n\n\\bigskip \n\\framebox{$\\Focus{S}{U}{V}$}\n\\bigskip \n\n$$\n\\begin{array}{lr}\n\\infer{\\Focus{\\Nil}{\\Type}{\\Type}}{} & \n\\infer{\\Focus{\\Nil}{P}{P}}{} \\\\\\\\\n\\infer{\\Focus{(M;S)}{\\PiTyp{A}{U}}{V}}{\\CheckTy{M}{A} & \\Focus{S}{U[M\\cdot\\IdSub]}{V}}\n\\end{array} \n$$\n\n%-------------------------------------------------------------------------------\n% Substitutions                                                                 \n%-------------------------------------------------------------------------------\n\n\\subsection{Substitutions}\n\n(The notation $\\Shift$ means $\\Shift^1$, and $\\IdSub$ means $\\Shift^0$.)  \n\nWe \\emph{apply} subsitutions to terms.\n\n\\bigskip\n\\framebox{$U\\Msub = U'$}\n\n\\begin{align*} \n\\Type\\Msub &= \\Type \\\\\n(\\PiTyp{A}{U})\\Msub &= \\PiTyp{(A\\Msub)}{(U\\Ssub)}\\\\\n(c\\cdot S)\\Msub &= c\\cdot (S\\Msub) \\\\\n(\\Lam{M})\\Msub &= \\Lam{(M\\Ssub)}\\\\\n(i\\cdot S)\\Msub &= \\begin{cases}\n                     j\\cdot S\\Msub \\mbox{\\ if $i\\Msub = j$} \\\\\n                     M \\App S\\Msub\\mbox{\\ if $i\\Msub = M$}\n                   \\end{cases} \n\\end{align*} \n\n\n\n\\framebox{$S\\Msub = S'$}\n\n\\begin{align*} \n\\Nil\\Msub &= \\Nil\\\\\n(M;S)\\Msub &= M\\Msub;S\\Msub\n\\end{align*} \n\n\\framebox{$i\\Msub = M$}\n\\bigskip \n\nThis judgment is the first place we distinguish between \nthe different notions of substitution.  The rule (*)\nholds only for the second variant.\n\n\\begin{align*} \n1[M\\cdot\\sigma] &= M\\\\\nn+1[M\\cdot\\sigma] &= n[\\sigma]\\\\\ni[\\Shift^n] &= i+n\\\\\ni[\\sigma_1\\Comp\\sigma_2] &= (i[\\sigma_1])[\\sigma_2]\\tag{*}\n\\end{align*} \n\nWe still need the notion of beta reduction when a \nhead gets instantiated with a lambda.  We show\nonly the possible cases.\n\n\\bigskip \n\\framebox{$M \\App S = M'$}\n\n\\begin{align*} \n(H\\cdot S)\\App\\Nil &= H\\cdot S\\\\\n\\Lam{M}\\App(M';S) &= M[M'\\cdot\\IdSub]\\App S\n\\end{align*} \n\nIn the first case of eager typechecking, composition doesn't\nhave a syntactic existence.  Thus we need to carry out all \ncompositions eagerly.  The rules for composing substitutions are:\n\n\\bigskip \n\\framebox{$\\sigma\\Comp\\sigma' = \\sigma''$}\n\n$$\n\\begin{array}{llll}\n(M\\cdot \\sigma) & \\Comp \\sigma' &= &M[\\sigma']\\cdot (\\sigma\\Comp\\sigma') \\\\\n\\Shift^n & \\Comp \\Shift^m &= &\\Shift^{n+m}\\\\\n\\Shift^0 & \\Comp \\sigma &= &\\sigma\\\\\n\\Shift^{n+1}&\\Comp (M\\cdot\\sigma) &= &\\Shift^n\\Comp\\sigma\n\\end{array} \n$$\n\n%-------------------------------------------------------------------------------\n% Equivalence                                                                   \n%-------------------------------------------------------------------------------\n\n\\subsection{Equivalence} \n\nIf we only allowed constant declarations in a signature then checking equivalence\nof terms would be a simple matter of checking syntactic equality.  \nWith definitions of the form $c : A = M$, we must account\nfor the fact that a focusing phase might return a type $A$ to \ncheck against a type $A'$ that are not syntactically equal, but\nif one expanded all the definitions and normalized the resulting\nterms than they would be identical.  We thus need a judgment for the\nequivalence of types $A$ and terms $M$.  (Since we are not allowing\ntype level definitions, we do not need to check for equivalent kinds.)\n\nWe use the judgment $c\\StepsTo M$  to mean\nthat the constant $c$ has definition $M$. \n\n\\bigskip \n\\framebox{$\\Equiv{U}{U'}$}\n\\bigskip \n\n$$\n\\begin{array}{lcr}\\\n\\infer{\\Equiv{U}{U'}}{\\Equiv{U'}{U}} &  \n\\infer{\\Equiv{\\PiTyp{U_1}{U_2}}{\\PiTyp{U_1'}{U_2'}}}{\\Equiv{U_1}{U_1'} & \\Equiv{U_2}{U_2'}} & \n\\infer{\\Equiv{c\\cdot S}{c\\cdot S'}}{\\Equiv{S}{S'}} \\\\\\\\\n\\infer{\\Equiv{\\Lam{M}}{\\Lam{M'}}}{\\Equiv{M}{M'}} &\n\\infer{\\Equiv{i\\cdot S}{i\\cdot S'}}{\\Equiv{S}{S'}} &\n\\infer{\\Equiv{c\\cdot S}{M}}{c\\StepsTo M' & \\Equiv{M'@S}{M}} \n\\end{array} \n$$\n\n\\bigskip \n\\framebox{$\\Equiv{S}{S'}$}\n\\bigskip \n\n$$\n\\begin{array}{lcr}\n\\infer{\\Equiv{\\Nil}{\\Nil}}{} &\n\\infer{\\Equiv{M;S}{M';S'}}{\\Equiv{M}{M'} & \\Equiv{S}{S'}}\n\\end{array} \n$$\n\n\\subsection{A Note on Implementing Equivalence Checking}\n\n  For various reasons, we need equivalence checking to\nbe as fast as possible.  Equivalence checking is complicated\nby notational definitions.  If checking $A=B$ fails, we might need\nto expand definitions in one or both terms.  One could simply\nexpand all definitions to yield a sound algorithm, but this would\nbe horribly slow.  \n\n  The solution given by Twelf, suggested by \nPfenning and Reed, is to store two extra bits of information \nwith each constant.  The first is the \\emph{height} of a constant.\nThis merely records the definition depth of a constant.  Constants that\ndo not refer to other constants have height 0.  A constant $c$ that refers\nto others has height $1 + \\max\\Set{\\mbox{height of constants occuring in } c}$.\nNote that only constants with the same height can be equal.  \nThe second bit of data is the \\emph{root}, it{i.e.} the head of the term that would be obtained by \nexpanding all definitions.  Note that any two equal terms must have the\nsame root after full expansion. \n\nThese two bits of data yield a natural algorithm for determining \nequivalence of terms.  If, when checking equality of $A=B$,\nwe find that two constants must be equal for $A,B$ to\nbe equivalent, but are not syntactically equal, \nwe check to see if the roots are the same.\nIf not, we fail.  Otherwise, we check the heights.  If the heights\ndiffer, we expand the constant with the greater height until \nthey are equal, and check again.  Once the levels\nare equal, while the constants are still distinct, we \nexpand both definitions, level by level, until all constants\nare expanded.  In the worst case, this will take as much time\nas expanding all the definitions.  In the usual case, however,\nwhere the constants differ\\footnote{indeed, unification fails\naround \\%80 of the time}, the clash will be found long before\nthe terms are fully expanded.  \n\nThis leads to an additional rule \n\n$$\n\\begin{array}{cccc}\n\\infer{\\Equiv{c\\cdot S}{c'\\cdot S'}}{\\Root(c)=\\Root(c') & \\Card{c} \\geq \\Card{c'} & c\\StepsTo M' & \\Equiv{M'@S}{c'\\cdot S'}} \n\\end{array} \n$$\n\nwhere $\\Card{c}$ is the height of $c$, and $\\Root(c)$ is the root.\nThis holds in both the eager and lazy cases.\n", "meta": {"hexsha": "778076dbb21a2e080d0d4aeddb50281cb216c54a", "size": 8536, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/inverse/tex/eagercheck.tex", "max_stars_repo_name": "kryptine/twelf", "max_stars_repo_head_hexsha": "1edad1846921cc962138cd4a5a703d3b1e880af2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 61, "max_stars_repo_stars_event_min_datetime": "2015-01-24T18:10:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-25T12:41:05.000Z", "max_issues_repo_path": "src/inverse/tex/eagercheck.tex", "max_issues_repo_name": "kryptine/twelf", "max_issues_repo_head_hexsha": "1edad1846921cc962138cd4a5a703d3b1e880af2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-02-27T22:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-27T22:17:51.000Z", "max_forks_repo_path": "src/inverse/tex/eagercheck.tex", "max_forks_repo_name": "kryptine/twelf", "max_forks_repo_head_hexsha": "1edad1846921cc962138cd4a5a703d3b1e880af2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2016-05-06T01:32:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T19:33:29.000Z", "avg_line_length": 34.8408163265, "max_line_length": 125, "alphanum_fraction": 0.6032099344, "num_tokens": 2522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.43666334641374777}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage[T1]{fontenc}\n\n% Document Details\n\\newcommand{\\CLASS}{AMATH 563}\n\\newcommand{\\assigmentnum}{Multiple Resolution Analysis}\n\n\\usepackage[margin = 1in, left=0.75in,right=0.75in]{geometry}\n\\input{../../import/title.tex} % Title Styling\n\\input{../../import/styling.tex} % General Styling\n\\input{../../import/code.tex} % Code Display Setup\n\\input{../../import/math.tex} % Math shortcuts\n\n\\usepackage{dblfloatfix}    % To enable figures at the bottom of page\n\n% Problem\n\\newenvironment{problem}[1]{\\vspace{2em}{\\large\\sffamily\\textbf{#1}}\\itshape\\par}{}\n\n\\usepackage{nameref}\n\\newcommand{\\vln}{\\rotatebox{90}{--}}\n\n\\begin{document}\n\n\\twocolumn[{%\n\\begin{@twocolumnfalse}\n\\maketitle\n\\vspace{2em}\n\\begin{abstract}\nWe introduce Multiple Resolution Analysis and the Discrete Wavelet Transform. We then discuss how these might be applied to a data set of global ocean temperatures over the past few decades in order to isolate El Ni\\~no. We find that the Oceanic Ni\\~no Index can be recovered using just a single spatial point. Finally, we train a neural net to predict the next time the ONI will reach a certain value.\n\\end{abstract}\n\n\\vspace{4em}\n%\\tableofcontents\n%\\vspace{3em}\n\\pagebreak\\end{@twocolumnfalse}\n}]\n\n\\section{Introduction and Overview}\nMultiple Resolution Analysis (MRA) provides a way to view data on multiple scales in both the position and frequency domains simultaneously.\n\nThe El Ni\\~no Southern Oscillator (ENSO) is an ``irregularly periodic varaition in winds and sea surface temperatures over the tropical easter Pacific Ocean''. The warm phase is referred to as El Ni\\~no and the cold phase is referred to as La Ni\\~na. When the ENSO is at its extremes, there is often extreme weather throughout part of the world.\n\nWe apply MRA to a ocean surface temperature data set in the hopes of extracting information useful in predicting El Ni\\~no.\n\n\\section{Theoretical Background}\n\n\n\\subsection{Multiple Resolution Analysis (MRA)}\nBroadly, Multiple Resolution Analysis provides a way to obtain information at multiple scales (as the name suggests). We illustrate this with an example.\n\nSuppose we have an audio recording of a piano. The recording tells us the amplitude of the sounds waves at a given time. What if we want to know which notes were played? We could take the Fourier transform of our recording and get information about the frequencies present. However, unless the notes were played through the entire recording, this would not be very useful.\n\nMultiple resolution analysis lets us get information about what notes were played when. Low frequencies, which have periods comparable to the entire recording can be extracted, but without timing information, while high frequencies can be pinpointed in time. This example illustrates the basic principle of MRA.\n\n\n\\begin{figure*}[h]\\centering\n\\foreach \\i in {0,...,7}{\n\\begin{subfigure}{.24\\textwidth}\\centering\n\\includegraphics[width=\\textwidth]{img/haar/basis_\\i.pdf}\n\\end{subfigure}\n}\n\\caption{Haar basis with \\( N=8 \\)}\n\\label{haar}\n\\end{figure*}\n\n\\subsection{Discrete Wavelet Transform}\nOne way to get time frequency information is to split the data into many pieces and take the Fourier transform of each piece. This would tell us information about which frequencies are present, as well as when these frequencies are present. Such a decomposition is often referred to as a spectogram or Short Time Discrete Fourier Transform (STDFT).\n\nIn the discrete case it is easy to see that such a transform is just a change of basis. Figure~\\ref{haar} shows a possible basis for \\( \\RR^8 \\). This basis gives us information about 4 different frequencies, as well as information about where these frequencies occur in time.\n\nFrom this figure it is obvious that these functions are orthogonal, and could be appropriately normalized. It is also clear that such a basis can be generalized to any \\( 2^k \\)-dimensional vectorspace over \\( \\RR \\). This basis has some advantages over a STDFT, namely that it is able to pick up low frequency modes which have a period longer than the windows in a STDFT.\n\nThis approach can be generalized to to a a class of transforms commonly referred to as the Discrete Wavelet Transform. While we show only a class of ``wavelets'' calleed ``Haar Wavelets'', many other shapes can be used. Note that the same ``wavelet'' seen in the first non-constant mode is just shifted and scaled to produce an orthonormal basis. Therefore it should not be surprising that there are many possible wavelets which are used in practice.\n\nLike the Discrete Fourier Transform, there are efficient algorithms for computing the DWT for many wavelets.\n\nSuch a transform can be applied to vector-spaces where the vectors are multi-dimensional arrays (for instance a photo).\nMore specifically, suppose our data lives in \\( \\RR^{k_1\\times k_2\\times\\cdots\\times k_d} \\).\n\nLet \\( \\mB_i = \\{b_{i1},b_{i2},\\ldots, b_{ik_i}\\} \\) be a wavelet basis for \\( \\RR^{k_i} \\). Then,\n\\begin{align}\n    \\mB = \\mB_1\\otimes \\mB_2 \\otimes \\cdots \\otimes \\mB_d\n\\end{align}\nis a basis for \\( \\RR^{k_1\\times k_2\\times\\cdots\\times k_d} \\), where \\( \\otimes \\) denotes the tensor product. In the 2-dimensional case this is simply the collection of all possible outer products of the elements of the bases for each dimension.\n\nSuch a change of basis would give information about the position and frequency/wave number of the data in each dimension. For instance, as discussed later, information about the location of a ocean temperate event in both space (longitude and latitude) and time along with information about frequency (in both spatial dimensions and in time) can be gathered.\n\nSuch a change of basis is not practical to compute for an arbitrary wavelet basis using naive algorithms since the dimension of the vector-space would generally be quite large. In particular, computing the standard inner product of two vectors of size \\( N \\) requires \\( \\mO(2N) \\) operations. Even if these vectors can be accessed in constant time, a change of basis would require \\( N \\) inner products to project the data onto each of the \\( N \\) new basis vectors. Therefore it will require something like \\( \\mO(N^2) \\) operations to compute the change of basis. With vectors with millions of components this is not practical.\n\nThere are almost certainly better algorithms for certain bases to help deal with this problem.\n\n\\subsection{SVD}\nWe can also perform MRA using the SVD.\n\nGiven any vector of the size of a single snapshot of our data we can project our data onto this vector and see how this ``mode'' varies in time. That means, if we are able to isolate a vector which represents El Ni\\~no we would be able to see hot his varies in time.\n\n\\subsection{Filtering}\nFiltering is a common technique in signal processing where the frequency content of a signal is altered. A low pass filter maintains the low frequencies of a signal and attenuates the high frequencies of a signal. This can be useful for de-noising a signal or removing a high frequency periodic piece of a signal.\n\n\\subsection{Oceanic Ni\\~no Index}\n\nThe Oceanic Ni\\~no Index (ONI) is a 3 month running mean of ERSST.v5 SST anomalies in the Ni\\~no 3.4 region (5\\( ^\\circ \\)N-5\\( ^\\circ \\)S, 120\\( ^\\circ \\)-170\\( ^\\circ \\)W) \\cite{oni}. This gives a measure of El Ni\\~no events.\n\n\\begin{figure*}[bh]\\centering\n\\foreach \\j in {0,...,7}{\n\\begin{subfigure}{.24\\textwidth}\\centering\n\\includegraphics[width=\\textwidth]{img/svd/1455/u_\\j.pdf}\n\\end{subfigure}\n}\n\\caption{First 8 modes of SVD of full data (all with same color scale)}\n\\label{full_svd_u}\n\\end{figure*}\n\n\\begin{figure*}[bh]\\centering\n\\foreach \\j in {0,...,7}{\n\\begin{subfigure}{.24\\textwidth}\\centering\n\\includegraphics[width=\\textwidth]{img/svd/1455/vh_\\j.pdf}\n\\end{subfigure}\n}\n\\caption{Weights of first 8 modes of SVD against time}\n\\label{full_svd_vh}\n\\end{figure*}\n\n\\begin{figure*}[t]\\centering\n\\begin{subfigure}{.48\\textwidth}\\centering\n\\foreach \\j in {0,...,3}{\n\\includegraphics[width=.48\\textwidth]{img/svd/smallMN/u_\\j.pdf}\n}\n\\end{subfigure}\n\\begin{subfigure}{.48\\textwidth}\\centering\n\\foreach \\j in {0,...,3}{\n\\includegraphics[width=.48\\textwidth]{img/svd/smallMN/vh_\\j.pdf}\n}\n\\end{subfigure}\n\\caption{First 4 modes of SVD of data localized in space (all with same color scale) and corresponding weights in time}\n\\label{smallMN_svd}\n\\end{figure*}\n\n\\begin{figure*}[t]\\centering\n\\begin{subfigure}{.48\\textwidth}\\centering\n\\foreach \\j in {0,...,3}{\n\\includegraphics[width=.48\\textwidth]{img/svd/shortT/u_\\j.pdf}\n}\n\\end{subfigure}\n\\begin{subfigure}{.48\\textwidth}\\centering\n\\foreach \\j in {0,...,3}{\n\\includegraphics[width=.48\\textwidth]{img/svd/shortT/vh_\\j.pdf}\n}\n\\end{subfigure}\n\\caption{First 4 modes of SVD of data localized in time (all with same color scale) and corresponding weights in time}\n\\label{shortT_svd}\n\\end{figure*}\n\\section{Algorithm Implementation and Development}\nWe create some basic functions to help with out analysis of our data set.\\footnote{I would have preferred to just put this section in with the computational results section, but I wasn't sure how strict the formatting rules Nathan sent out are.}\n\n\\subsection{Discrete Wavelet Transform}\nWe implement a function to generate a wavelet basis of arbitrary size given a mother wavelet. Using these we can construct a basis for our data. However, since the dataset we are working with has over 94 million points, it is not practical at all to use our naive implementation to compute the coefficients in the wavelet basis.\n\nOur function assumes that there are \\( N = 2^k \\) points in the data set for \\( k\\in\\NN \\). A wavelet with period equal to the number of points is then generated. The points are then split, and two wavelets, each with period equal to \\( N/2 \\) but starting positions at 0 and \\( N/2 \\). This process is repeated. We note that we do define our function recursively, but rather using an appropriately indexed loop.\n\nThis function could be used to generate bases for a multi dimensional DWT, however then all of the basis functions would have to be stored.\n\n\\subsection{Singular Value Decomposition}\nWe write a function to take the SVD of a slice of our data. In particular, the array is reshaped so that the spatia axes lie on a single axis prior to taking the SVD.\n\n\\subsection{Filtering}\nWe use Scipy's signal module for filtering.\n\n\\subsection{Prediction}\nBeing able to predict El Ni\\~no events would be of great use as it would allow farmers and others whose livelihoods depend on global climate events to prepare for upcoming changes. In past assignments we have explored methods of predicting time-series data including sparse regression and neural nets.\n\n\\section{Computational Results}\nWe are given ocean surface temperature data of size \\( (M,N,T) = (180,360,1455) \\). Each time point is taken one week apart starting on December 31, 1989 and ending on November 12, 2017.\n\n\\subsection{Discrete Wavelet Transform}\nWe attempt to project a smaller portion of our data. This was inefficient and we did not pursue this approach. Our code is usable in the sense that it will provide the desired information, however it is still a quadratic time algorithm which seemed to be running too slowly to justify spending more time on this approach.\n\n\\subsection{Singular Value Decomposition}\nThe SVD of the entire data set is taken. The 8 most dominant modes are shown in Figure~\\ref{full_svd_u}. The corresponding weights of these modes in time are shown in Figure~\\ref{full_svd_vh}. It is clear that the 5th mode more or less tracks the ONI.\n\nWe now perform some rudimentary MRA by observing a spatial slice of the data over the full time range as well as a temporal slice of the data over the whole earth. Neither give particularly interesting results. More specifically, in space we isolated a region of the Pacific Ocean off the coast of South America near the Ni\\~no 3.4 region and in time we isolated the year 1997 which was a particularly strong El Ni\\~no event.\n\nFigures~\\ref{smallMN_svd} shows the modes and how they vary in time when we localize in space. We see that the coefficients of many of these modes track the ONI well.\nFigures~\\ref{shortT_svd} shows the modes and how they vary in time when we localize in time. We see that the more important modes of the SVD look more like what we expect the El Ni\\~no to look like.\n\nWhile these results were initially encouraging, as discussed later, it turns out that even a single point from this region is enough to track the ONI and so this is not so interesting.\n\n\n\n\n\n\n\n\\subsection{Direct Filtering}\nThe region of the 7th mode of the SVD in the Pacific ocean off the coast of South America looks like what we might expect the El Ni\\~no to look like. We isolate the desired portion of this mode and zero the rest of the data. A small Gaussian blur is then applied to clear the harsh boundaries of the clipping.\n\nThe dataset is then projected onto a normalized version of this mode. We look at the coefficients of this mode in time and find that we are more or less able to recover the The Oceanic Ni\\~no Index (ONI) (with a low pass filter).\n\nWith this as a motivation we try an even simpler vector taking just a single point \\( (90,245) \\) corresponding to the position 0\\(^\\circ\\)S, 145\\(^\\circ\\)W in the center of the Ni\\~no 3.4 region. Again a low pass filter is applied and the ONI is recovered. This is shown in Figure~\\ref{elnino}.\n\n\\begin{figure}[h]\\centering\n%\\begin{subfigure}{.45\\textwidth}\\centering\n%    \\includegraphics[width=\\textwidth]{img/el_nino_mode.pdf}\n%\\end{subfigure}\\hfill\n\\begin{subfigure}{.45\\textwidth}\\centering\n    \\includegraphics[width=\\textwidth]{img/el_nino_filtered.pdf}\n    \\caption{temperature at (90,245) (dark grey), filtered temperature (black) ONI data (light grey fill)}\n\\end{subfigure}\\hfill\n\\begin{subfigure}{.45\\textwidth}\\centering\n    \\includegraphics[width=\\textwidth]{img/el_nino_wavelet_transform.pdf}\n    \\caption{CWT of temperature at (90,245) (ricker wavelet)}\n\\end{subfigure}\n\\caption{Analysis of temperature at (90,245)}\n\\label{elnino}\n\\end{figure}\n\n\\subsection{Prediction}\nWe train a neural net to predict the next time the ONI will be above a fixed threshold. To build the target data we first detect when the ONI reaches the specified threshold. These points are marked, and then the time to reach the next one of these points is found for each time in the given data set. We then train a neural network with the input being the current global ocean temperatures and the output being the next time until the ONI reaches the specified threshold using 5\\% of the data for cross validation.\n\nAs before, since we do not have much time to train a network, and since we do not understand how to pick the proper network architecture, our results are not notable. That said everything we did was designed to be easily scaleable so that it could be adjusted in the future. This seems like an example of where a convolutional neural net might be useful.\n\n\\section{Summary and Conclusions}\n\nThe Discrete Wavelet Transform seems to provide a clean way of detecting and analyzing multi-scale phenomena without and sort of supervision. Given more time we would like to write an efficient algorithm to compute this transform. At the very least rather than projecting using inner products, slicing could be use for some wavelets. This would be more efficient in terms of floating point operations, and given fast memory access might prove feasible on our computing resources. Alternatively, and perhaps more practically , the algorithm could be implemented for parallel computation. Projecting onto a basis amounts to computing many independent inner products, which is the perfect type of problem for a GPU or large cluster. Parallelization would allow the fast computation of the projection onto any basis.\n\nThe Oceanic Ni\\~no Index seems to be almost completely recoverable from a single point. This suggests that the definition of the index could be tightened. However, perhaps taking recordings over a larger area gives more precision.\n\nFinally, we train a neural net to predict the next time the ONI will reach a certain threshold. Due to the limited time this was not very successful. However, our code is easily scaleable if we were to have more time to invest in the project.\n\n\n\\bibliographystyle{plain}\n\\bibliography{hw3}\n\n\\onecolumn\n\\section{Appendix A}\n\\label{AppendixA}\n\\lstinputlisting[linerange=\\#<start:generate_wavelets>-\\#<end:generate_wavelets>]{wavelettest.py}\n\\lstinputlisting[linerange=\\#<start:svd_slice>-\\#<end:svd_slice>]{hw3.py}\n\n%\\pagebreak\n\\section{Appendix B}\n\\lstinputlisting[linerange=\\#<start:wavelet_decomp>-\\#<end:wavelet_decomp>]{wavelettest.py}\n\\lstinputlisting[]{hw3.py}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "48187af4e57fa2c376c4418196b589314696b7c2", "size": 16732, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "amath563/hw3/hw3.tex", "max_stars_repo_name": "interesting-courses/UW_coursework", "max_stars_repo_head_hexsha": "987e336e70482622c5d03428b5532349483f87f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-19T01:59:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T12:32:59.000Z", "max_issues_repo_path": "amath563/hw3/hw3.tex", "max_issues_repo_name": "interesting-courses/UW_coursework", "max_issues_repo_head_hexsha": "987e336e70482622c5d03428b5532349483f87f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "amath563/hw3/hw3.tex", "max_forks_repo_name": "interesting-courses/UW_coursework", "max_forks_repo_head_hexsha": "987e336e70482622c5d03428b5532349483f87f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-31T22:23:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T22:13:01.000Z", "avg_line_length": 67.4677419355, "max_line_length": 812, "alphanum_fraction": 0.7761176189, "num_tokens": 4122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.43666334641374777}}
{"text": "% Created 2021-07-06 Tue 09:03\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=169]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\DeclareMathOperator{\\shift}{q}\n\\DeclareMathOperator{\\diff}{p}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{2021-07-06}\n\\title{Root locus}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Root locus},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section{Pole placement}\n\\label{sec:org9c42cbf}\n\\begin{frame}[label={sec:orgf8465c7}]{Pole-placement and time-response}\n\\alert{Pair the pole-placement with the correct time-response (continuous time)!}\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/pzmap-apollo}\n\\end{center}\n\\end{column}\n\\begin{column}{0.6\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/step-response-apollo}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org6dc2ec2}]{Mapping of poles from continuous time to discrete time}\n\\begin{center}\n\\begin{tabular}{ll}\nContinuous time & Discrete time\\\\\n\\hline\n\\(Y(s) \\triangleq \\laplace{y(t)}\\) & \\(Y(z) \\triangleq \\ztrf{y(kh)}\\)\\\\\n\\(Y(s) = G(s)U(s) = \\frac{b}{s+a}U(s)\\) & \\(Y(z) = H(z)U(z) = \\frac{\\beta}{z+\\alpha}U(z)\\)\\\\\nPole of the system: \\(s+a=0 \\; \\Rightarrow \\; s = -a\\) & Pole of the system: \\(z+\\alpha = 0 \\; \\Rightarrow \\; z = -\\alpha\\)\\\\\n\\includegraphics[width=0.22\\linewidth]{../../figures/cont-stable} & \\includegraphics[width=0.22\\linewidth]{../../figures/discrete-stable}\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nThe \\alert{s-domain} of continuous-time systems is related to the \\alert{z-domain} of discrete-time systems through  \\[z = \\mathrm{e}^{sh}\\]\n\\end{frame}\n\n\\begin{frame}[label={sec:orge1375d9}]{Pole-placement and time-response}\nPair the pole-placement with the correct time-response (discrete time)!\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/pzmap-discrete-apollo}\n\\end{center}\n\\end{column}\n\\begin{column}{0.6\\columnwidth}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/step-reponse-discrete-apollo}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\section{Root locus}\n\\label{sec:orgd424d23}\n\n\n\\begin{frame}[label={sec:org7677301}]{Root locus: A brief review}\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n\n    \\node[coordinate] (input) {};\n    \\node[sumnode, right of=input, node distance=16mm] (sum) {\\tiny $\\Sigma$};\n    \\node[block, right of=sum, node distance=20mm] (plant)  {$H(z)=\\frac{B(z)}{A(z)}$};\n    \\node[block, below of=plant, node distance=12mm] (controller)  {$F(z)=K\\frac{D(z)}{C(z)}$};\n    \\node[coordinate, right of=plant, node distance=30mm] (output) {};\n\n    \\draw[->] (input) -- node[above, pos=0.3] {} (sum);\n    \\draw[->] (sum) -- node[above] {} (plant);\n    \\draw[->] (plant) -- node[coordinate] (measure) {} node[above, near end] {} (output);\n    \\draw[->] (measure) |- (controller);\n    \\draw[->] (controller) -| (sum);\n  \\end{tikzpicture}\n\\end{center}\n\n\n\\begin{itemize}\n\\item The loop pulse-transfer function (loop gain) becomes \\(L(z) = H(z)F(z) = K\\frac{\\overbrace{B(z)D(z)}^{Q(z)}}{\\underbrace{A(z)C(z)}_{P(z)}} = K \\frac{Q(z)}{P(z)}\\).\n\\item The roots of \\(Q(z)\\) are called the \\alert{open loop zeros}.\n\\item The roots of \\(P(z)\\) are called the \\alert{open loop poles}.\n\\item The characteristic equation for the closed-loop system is \\[ 1 + K\\frac{Q(z)}{P(z)} = 0 \\quad \\Leftrightarrow \\quad P(z) + KQ(z) = 0\\]\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org4d6f28e}]{Root locus: Definition}\nLet\n\\[\\begin{cases} P(z)&=z^n+a_1z^{n-1}+\\dots+a_n = (z-p_1)(z-p_2)\\cdots(z-p_n)\\\\ \nQ(z)&=z^m+b_1 z^{m-1}+\\dots+b_m=(s-q_1)(z-q_2)\\cdots(z-q_m) \\end{cases},\\ \\ \\ n\\ge m \\]\n\nThe root locus shows how the \\alert{solution} to the characteristic equation\n\\begin{equation}\n\\label{eq:P(z)+KQ(z)=0}\nP(z)+K\\cdot Q(z)=0,\\ \\ \\ 0\\le K<\\infty\n\\end{equation}\ndepend on the parameter \\(K\\). The root locus consists of the set of all points in the complex plane that are solutions to \\eqref{eq:P(z)+KQ(z)=0} for some non-negative value of \\(K\\).\n\\end{frame}\n\n\\begin{frame}[label={sec:orgaed6fe4}]{Root locus: Characteristics}\n\\begin{description}\n\\item[{Start points}] The \\(n\\) roots of \\(P(z)\\), marked by crosses\n\\item[{End points}] The \\(m\\) roots of \\(Q(z)\\), marked  by circles\n\\item[{Asymptotes}] Number equal to the \\emph{pole excess} \\(n-m\\)\n\\item[{Real axis}] Some segments of the real axis belong to the root locus\n\\end{description}\n\\end{frame}\n\n\\begin{frame}[label={sec:org83ded44}]{Root locus: Direction of the asymptotes}\nThe characteristic equation \\(P(z)+K Q(z)=0\\) can be written \\(\\frac{P(z)}{Q(z)} = -K\\) and for large \\(z\\) it can be approximated as \n\\[ \\frac{z^n}{z^m} = -K \\quad \\Leftrightarrow \\quad z^{n-m} = -K.\\]\n\nTaking the argument of both sides of the equation gives \n\\((n-m)\\arg z = \\pi + k2\\pi, \\; k \\in  \\mathbb{Z}\\)\nSo, the \\alert{directions} of the asymptotes are given by the expression\n\\[ \\theta_k = \\arg z = \\frac{(2k+1)\\pi}{n-m}, \\; k \\in \\mathbb{Z} \\]\n\\end{frame}\n\n\\begin{frame}[label={sec:org7e82366}]{Root locus: The asymptotes' intersection with the real axis}\n\\[ z_{ip} = \\frac{ \\sum_{i=0}^n p_i - \\sum_{i=0}^m q_i}{n-m}, \\]\nwhere \\(\\{p_i\\}\\) are the starting points (open-loop poles) and \\(\\{q_i\\}\\) are the end points (open-loop zeros). \n\\end{frame}\n\n\\begin{frame}[label={sec:org8888ac4}]{Root locus exerise: Pair the pulse-trf fcn and root locus}\n\\begin{columns}\n\\begin{column}{0.35\\columnwidth}\n \\small\n\\begin{align*}\n  G_1(z) &= K\\frac{(z+2.9)(z+0.2)}{(z-1)^2(z-0.3)}\\\\[3mm]\n  G_2(z) &= K\\frac{(z-0.5)(z+0.4)}{(z-1)(z-0.3)(z-0.1)}\\\\[3mm]\n  G_3(z) &= K\\frac{(z-0.5)(z+0.8)}{(z-1)^2(z-0.3)}\\\\[3mm]\n  G_4(z) &= K \\frac{z-0.6}{(z-1)(z-0.3)}\n\\end{align*}\n\\end{column}\n\n\\begin{column}{0.65\\columnwidth}\n\\begin{center}\n\\includegraphics[width=1.04\\linewidth]{../../matlab/rlocus_2x2-crop}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "90df52aa13e80807d9be6b6b14edfd8316e598b0", "size": 6478, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "discrete-time-systems/slides/lecture-root-locus.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "discrete-time-systems/slides/lecture-root-locus.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "discrete-time-systems/slides/lecture-root-locus.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 37.0171428571, "max_line_length": 184, "alphanum_fraction": 0.6748996604, "num_tokens": 2335, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4366633427516528}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 05/20/21\n\n\\section{More Direct Methods}\n\\label{sec:more_direct_methods}\n\nLet \\(u_0 \\in C^{1}(\\overline{\\Omega })\\) with \\(\\Omega \\) some open bounded set. We want to minimize the functional:\n\\begin{align*}\n\t\\inf_{u} \\left\\{\\frac{1}{2} \\int_\\Omega \\left| \\nabla u \\right|^2 \\mid u =u_0 \\text{ on }\\partial\\Omega  \\right\\} \n\\end{align*}\nLet \\(\\left\\{ u_j \\right\\}_j\\) be a minimizing sequence for \\(\\inf_{\\mathcal{A}} \\mathcal{F}\\) that satisfies the boundary conditions, and satisfying\n\\begin{align*}\n\t\\lim_{j \\to \\infty} \\frac{1}{2}\\int_\\Omega \\left| \\nabla u_j \\right|^2 = \\inf_{\\mathcal{A}} \\mathcal{F}.\n\\end{align*}\nBecause the limit supremum of the sequence is finite, we know that there exists a subsequence \\(\\left\\{ \\tilde{u}_j \\right\\}_j\\) and \\(T \\in L^2(\\Omega , \\R^{n})\\) such that\n\\begin{align*}\n\t\\int_\\Omega T \\varphi  = \\lim_{j \\to \\infty} \\int_\\Omega \\varphi \\nabla \\tilde{u}_j \\quad \\forall \\varphi  \\in L^2(\\Omega )\n\\end{align*}\nDoes this subsequence also have a limit of \\(u\\)? And is this \\(T\\) simply \\(\\nabla u\\)?  \n\n\\begin{thm}[Trace Inequality for Minimizers]\n\tIf \\(u \\in C^{1}(\\overline{\\Omega })\\) and \\(\\Omega \\) is bounded with smooth boundary, then\n\t\\begin{align*}\n\t\t\\int_\\Omega u^2 \\leq C(n, \\textrm{diam}\\Omega ) \\left[ \\int_{\\partial \\Omega }u^2 + \\int_\\Omega \\left| \\nabla  u\\right|^2 \\right] .\n\t\\end{align*}\n\\end{thm}\nThis quantifies the restrictions of the boundary conditions \\(\\begin{cases}\n\tu=0 & \\partial\\Omega \\\\\n\t\\nabla u=0 & \\Omega \n\\end{cases} \\implies u \\cong 0\\) on \\(\\Omega \\).\n\n\\begin{proof}[Proof of trace inequality]\n\tChoose \\(X(x) = x\\) so that \\(\\textrm{div}(X) = n\\). We will pick \\(x_0 \\in \\R^{n}\\) later so that the following is satisfied:\n\t\\begin{align*}\n\t\tn \\int_\\Omega u^2 = \\int_\\Omega u^2 \\textrm{div}(x-x_0)\\\\\n\t\t= \\int_\\Omega \\textrm{div}\\left( (x-x_0)u^2 \\right) - \\int_\\omega 2u \\nabla u \\cdot (x-x_0)\\\\\n\t\t\\leq  \\int_{\\partial \\Omega }u^2(x-x_0)\\cdot \\nu_\\Omega + \\int_\\Omega 2 \\left| u \\right| \\left| \\nabla u \\right| (x-x_0)\n\t\\end{align*}\n\tUsing some standard algebraic inequalities (i.e. \\(2ab \\leq \\varepsilon a^2 + \\frac{1}{\\varepsilon}b^2\\) so that \\((\\sqrt{\\varepsilon} a = \\frac{b}{\\sqrt{\\varepsilon} })^2\\geq 0\\)), we can put bounds on both terms individually to get\n\t\\begin{align*}\n\t\t\\int_{\\partial \\Omega } u^2(x-x_0) \\cdot \\nu_\\Omega + \\int_\\Omega 2 \\left| u \\right| \\left| \\nabla u \\right| (x-x_0)\\leq 2 \\textrm{diam} (\\Omega ) \\left[ \\int_{\\partial \\Omega }u^2 + \\int_\\Omega 2\\left| u \\right| \\left| \\nabla u \\right|  \\right]\\\\\n\t\t\\leq 2 \\textrm{diam}(\\Omega ) \\int_{\\partial \\Omega } u^2+ 2 \\textrm{diam}(\\Omega ) \\left[ \\varepsilon \\int_{\\Omega }u^2 + \\frac{1}{\\varepsilon} \\int_{\\Omega } \\left| \\nabla u \\right|^2 \\right]\\\\\n\t\t\\implies \\left( n-2\\varepsilon\\textrm{diam}(\\Omega ) \\right) \\int_{\\Omega } u^2 \\leq 2 \\textrm{diam}(\\Omega )\\left[ \\int_{\\partial \\Omega }u^2 + \\frac{1}{\\varepsilon} \\int_\\Omega  \\left| \\nabla u \\right|^2 \\right] \n\t\\end{align*}\n\tNow we simply choose \\(\\varepsilon = \\dfrac{n}{4 \\textrm{diam}(\\Omega )}\\) and we have the statement\n\t\\begin{align*}\n\t\t\\int_\\Omega u^2 \\leq \\dfrac{4 \\textrm{diam}(\\Omega)}{n} \\left[ \\int_{\\partial \\Omega }u^2 + \\dfrac{4 \\textrm{diam}(\\Omega )}{n} \\int_\\Omega  \\left| \\nabla u \\right|^2 \\right] \n\t\\end{align*}\n\\end{proof}\n\nWhat is the relation between \\(T\\) and \\(u\\)?\n\n\\begin{defn}\n\tLet \\(u \\in L^{1}_{\\textrm{loc}}(\\Omega )\\), and \\(T \\in L^{1}_{\\textrm{loc}}(\\Omega , \\R^{n})\\). We say that \\(T\\) is the unique vector field called the \\textbf{weak} or \\textbf{distributional gradient} of \\(u\\) if the following is satisfied:\n\t\\begin{align*}\n\t\t\\int_\\Omega u \\nabla \\varphi = - \\int_\\Omega \\varphi T \\quad \\forall \\varphi  \\in C^{\\infty}_c (\\Omega )\n\t\\end{align*}\n\\end{defn}\n\nEarlier, we asked if the limit of the subsequence was equivalent to the \\(u\\) earlier. Now we claim that the weak limit \\(T\\) of \\(\\left\\{ \\nabla u_j \\right\\}_j\\) is the weak gradient of\n \\begin{align*}\n\tu = \\lim_{n \\to \\infty}^{w} \\left\\{ u_j \\right\\}_j .\n\\end{align*}\nThis follows because\n\\begin{align*}\n\t\\int_\\omega u \\nabla \\varphi = \\lim_{j \\to \\infty} \\int_\\Omega u_j \\nabla \\varphi  = - \\lim_{j \\to \\infty} \\int_\\Omega \\varphi \\nabla u_j\\\\\n\t= - \\int_\\Omega \\varphi T\n\\end{align*}\nIn summary, by weak compactness in \\(L^2\\) and by Trace inequality, we have\n\\begin{align*}\n\t\\begin{cases}\n\t\tu_j \\to u & L^2(\\Omega )\\quad u \\in W^{1,2}(\\Omega )\\\\\n\t\t\\nabla u_j \\to \\nabla u & L^2(\\Omega ,\\R^{n})\n\t\\end{cases}\n\\end{align*}\nWe need to define a space where these weak objects can live:\n\\begin{defn}[\\(L^2\\) Sobolev Space]\n\tWe define the \\textbf{Sobolev Space in \\(L^2\\)} to be\n\t\\begin{align*}\n\t\tW^{1,2}(\\Omega ) := \\left\\{u \\in L^2(\\Omega ) \\mid \\exists  \\text{ weak gradient }\\nabla u \\in L^2(\\Omega ,\\R^{n}) \\right\\} \n\t\\end{align*}\n\\end{defn}\n\nNow we ask a new question: is it true that\n\\begin{align*}\n\t\\int_\\Omega \\left| \\nabla u \\right|^2 \\leq \\liminf_{j \\to \\infty} \\int_\\Omega  \\left| \\nabla u_j \\right|^2\n\\end{align*}\n\nYes. Pick any \\(T \\in L^2(\\Omega ,\\R^{n})\\). Then\n\\begin{align*}\n\t\\int_\\Omega (\\nabla u) \\cdot T = \\lim_{j \\to \\infty} \\int_\\Omega (\\nabla u_j) \\cdot T\\\\\n\t\\leq \\lim_{j \\to \\infty} \\left( \\int_\\Omega \\left| \\nabla u_j \\right|^2 \\right)^{ \\sfrac{1}{2}} \\left( \\int_{\\Omega } \\left| T \\right|^2 \\right)^{ \\sfrac{1}{2}}\n\\end{align*}\nNow choose\n\\begin{align*}\n\tT = \\frac{\\nabla u}{\\|\\nabla u\\|_{L^2}}\n\\end{align*}\nto get the inequality we desire.\\\\\n\nAnother question. Is \\(u \\in \\mathcal{A}\\), where \n\\begin{align*}\n\t\\mathcal{A} = \\left\\{ \\mid  \\right\\} \n\\end{align*}\n\n\\begin{exmp}\n\tConsider\n\t\\begin{align*}\n\t\tu_\\alpha (x) = \\dfrac{1}{\\left| x \\right|^{\\alpha }}\\\\\n\t\t\\nabla u_\\alpha (x) = \\dfrac{-\\alpha }{\\left| x \\right|^{\\alpha +1}} \\hat{x}\n\t\\end{align*}\n\twhere \\(\\hat{x} = \\dfrac{x}{\\left| x \\right| }\\). Then\n\t\\begin{align*}\n\t\t\\int_{B_\\varepsilon(0)} \\left| \\nabla u_\\alpha  \\right|^2 \\approx \\int_{0}^{\\varepsilon} \\dfrac{\\rho^{n-1}}{\\left( \\rho^{\\alpha +1} \\right)^2} \\,d \\rho < \\infty \\\\\n\t\t\\iff n-1 -2(\\alpha +1) > -1 \\iff\\alpha < \\frac{n}{2}-1\n\t\\end{align*}\n\\end{exmp}\n\n\tNow we ask a seemingly silly question: is \\(\\nabla u_{\\alpha }\\) the weak gradient of \\(u_\\alpha \\)? Yes, but we have to be careful-- if \\(\\nabla u = 0\\) almost everywhere in \\(\\R^2\\), say, \\(u\\) is a step function, then the weak gradient doesn't exist. One can show that\n\t\\begin{align*}\n\t\t\\int \\varphi \\nabla u_{\\alpha } = - \\int u_\\alpha \\nabla \\varphi \\quad \\forall \\varphi \\in C^{\\infty}_c(B_1(0))\t\n\t\\end{align*}\nvia some standards calculations from distribution theory. Because this holds, we have\n\\begin{align*}\n\tu^{(n)} = \\sum_{k=1}^{n} \\dfrac{2^{-k}}{\\left| x-x_k \\right|\\alpha }\n\\end{align*}\nwhere \\(\\left\\{ x_k\\right\\}_{k=1}^{\\infty} \\) is countably dense in \\(B_1(0)\\). We have that \\(u^{(n)} \\in W^{1,2}(\\Omega )\\) if \\(\\alpha < \\frac{n}{2}-1\\).In fact, this is a Cauchy sequence in \\(W^{1,2}(\\Omega )\\) (check this), and so\n\\begin{align*}\n\t\\exists u \\in W^{1,2}(\\Omega ) \\text{ such that{t} } u = \\lim_{N \\to \\infty} u^{(N)}= \\sum_{k=1}^{\\infty} \\dfrac{2^{-k}}{\\left| x-x_k \\right|^{\\alpha }}\n\\end{align*}\n\n\\begin{exmp}\n\tLet \\(u \\not\\in L^{\\omega }_{\\textrm{loc}}(B_{1}(0))\\). For all \\(B_\\varepsilon(x) \\subset B_1(0)\\), we have\n\t\\begin{align*}\n\t\t\\textrm{essential sup}_{B_\\varepsilon} \\left| u \\right|  = \\infty\n\t\\end{align*}\n\\end{exmp}\n\n\\begin{rmrk}\nWhat is the essential supremum? Let \\(f:\\Omega \\to \\R\\). Consider the case when \\(\\tilde{f}:\\Omega \\to \\R\\) by\n\\begin{align*}\n\t\\tilde{f}(x) = \\begin{cases}\n\t\tf(x) & \\Omega \\setminus Q^{n}\\\\\n\t\tj & x = x_j \\in Q^{n}\\cap \\Omega \n\t\\end{cases}\n\\end{align*}\nSo that \\(f = \\tilde{f}\\) almost everywhere in \\(\\Omega \\) and \\(\\sup_{j} \\tilde{f}= \\infty\\). A traditional supremum is unbounded and so won't work nicely here. Instead, notice that\n\\begin{align*}\n\t\\left\\{x \\in \\Omega  \\mid f(x) > t \\right\\} = \\left\\{f > t \\right\\} \\\\\n\t\\mathcal{L}^{n}( \\left\\{ f > t \\right\\} ) = \\mathcal{L}^{n}\\left( \\left\\{ \\tilde{f} > t \\right\\}  \\right)\n\\end{align*}\nWith this in mind, we define\n\\begin{align*}\n\t\\textrm{essential sup}_{\\Omega } f := \\inf_{t} \\left\\{ t\\mid \\mathcal{L}^{n}( \\left\\{f >t \\right\\} ) = 0 \\right\\} .\n\\end{align*}\n\\end{rmrk}\n\n\\begin{exmp}\n\t\\(u=u_0\\) on \\(\\partial \\Omega \\)?\\\\\n\n\t\\(u_j \\to u\\) in \\(L^2(\\Omega )\\) but we do \\textit{not} have convergence of boundary data. To see this, look at the diagram in \\ref{fig:convergence-of-boundary-data}.\n\\end{exmp}\n\n\\begin{figure}[ht]\n    \\centering\n     \\def\\svgwidth{1\\linewidth}\n     \\input{./figures/convergence-of-boundary-data.pdf_tex}\n    \\caption{Convergence of Boundary Data}\n    \\label{fig:convergence-of-boundary-data}\n\\end{figure}\n\n\nThe moral is that we need more properties to hold: if \\(u_j = u_0 \\partial \\Omega \\), \\(\\sup_{j} \\int \\left| \\nabla u_j \\right|^2 < \\infty\\) and\n\\begin{align*}\n\t\\begin{cases}\n\t\tu_j \\to u\\\\\n\t\t\\nabla u_j \\to \\nabla u\n\t\\end{cases}\n\\end{align*}\nthen we can say that \\(u = u_0\\) on \\(\\partial \\Omega \\) in the distributional sense.\\\\\n\nTo summarize the work we've done, if we are working with problems of the form\n\\begin{align*}\n\t\\inf_{u} \\left\\{\\frac{1}{2}\\int_\\Omega \\left| \\nabla u \\right|^2 \\mid u = u_0 \\text{ on }\\partial \\Omega  \\text{ in distribution} \\right\\} \n\\end{align*}\nwhere \\(u \\in W^{1,2}(\\Omega )\\), then the direct method gives you a minimizer. For the restricted problem with \\(u \\in C^{1}(\\overline{\\Omega })\\) :\n\\begin{align*}\n\t\\inf_{u} \\left\\{\\frac{1}{2}\\int_\\Omega \\left| \\nabla u \\right|^2 \\mid u = u_0 \\text{ on }\\partial\\Omega  \\text{ in classical sense} \\right\\} \\\\\n\t= \\frac{1}{2}\\int_\\Omega  \\left| \\nabla u \\right|^2\n\\end{align*}\nwe have the existence of a minimizer \\(u \\in W^{1,2}(\\Omega )\\).\\\\\n\nSome classical results give us some insight:\n\\begin{thm}[Serrin '61]\n\tIf \\(\\left\\{ u_j \\right\\}_j \\subset L^{1}_{\\textrm{loc}}(\\Omega )\\) and \\(\\lim_{j \\to \\infty} u_j = u\\) in \\(L^{1}_{\\textrm{loc}}(\\Omega )\\) and \\(u_j,u\\) have weak gradient in \\(L^{1}(\\Omega ,\\R^{n})\\), then for all \\(f:\\R^{n}\\to [0,\\infty)\\) convex, we have\n\t\\begin{align*}\n\t\t\\int_\\Omega f(\\nabla u) \\leq \\liminf_{j \\to \\infty} \\int_\\Omega f(\\nabla u_j).\n\t\\end{align*}\n\\end{thm}\nWe have a converse too. If \\(f:\\R^{n}\\to [0,\\infty)\\) is continuous and the above result holds, then for all \\(u_j,j\\) as above, \\(f\\) is convex.\n\n\\end{document}\n", "meta": {"hexsha": "337e1daba0bbe089fc07e4bc02986a80fcd205c5", "size": 10656, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture4.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture4.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture4.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.6575342466, "max_line_length": 272, "alphanum_fraction": 0.635792042, "num_tokens": 4221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.43666332887814313}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Copyright (c) 2003-2018 by The University of Queensland\n% http://www.uq.edu.au\n%\n% Primary Business: Queensland, Australia\n% Licensed under the Apache License, version 2.0\n% http://www.apache.org/licenses/LICENSE-2.0\n%\n% Development until 2012 by Earth Systems Science Computational Center (ESSCC)\n% Development 2012-2013 by School of Earth Sciences\n% Development from 2014 by Centre for Geoscience Computing (GeoComp)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{The \\finley Module}\\label{chap:finley}\n%\\declaremodule{extension}{finley}\n%\\modulesynopsis{Solving linear, steady partial differential equations using finite elements}\n\nThe \\finley library allows the creation of domains for solving\nlinear, steady partial differential\nequations\\index{partial differential equations} (PDEs) or systems\nof PDEs using isoparametrical finite elements\\index{FEM!isoparametrical}.\nIt supports unstructured 1D, 2D and 3D meshes.\nThe PDEs themselves are represented by the \\LinearPDE class\nof \\escript.\n\\finley is parallelized under both \\OPENMP and \\MPI.\nA more restricted form of this library ({\\it dudley}) is described in \nSection~\\ref{sec:dudley}.\n\n\\section{Formulation}\nFor a single PDE that has a solution with a single component the linear PDE is\ndefined in the following form:\n\\begin{equation}\\label{FINLEY.SINGLE.1}\n\\begin{array}{cl} &\n\\displaystyle{\n\\int_{\\Omega}\nA_{jl} \\cdot v_{,j}u_{,l}+ B_{j} \\cdot v_{,j} u+ C_{l} \\cdot v u_{,l}+D \\cdot vu \\; d\\Omega }  \\\\\n+ & \\displaystyle{\\int_{\\Gamma} d \\cdot vu \\; d{\\Gamma} }\n+  \\displaystyle{\\int_{\\Gamma^{contact}} d^{contact} \\cdot [v][u] \\; d{\\Gamma} } \\\\\n= & \\displaystyle{\\int_{\\Omega}  X_{j} \\cdot v_{,j}+ Y \\cdot v \\; d\\Omega }\\\\\n+ & \\displaystyle{\\int_{\\Gamma} y \\cdot v \\; d{\\Gamma}}  +\n\\displaystyle{\\int_{\\Gamma^{contact}} y^{contact}\\cdot [v] \\; d{\\Gamma}} \\\\\n\\end{array}\n\\end{equation}\n\n\\section{Meshes}\n\\label{FINLEY MESHES}\n\n\\begin{figure}\n\\centerline{\\includegraphics{FinleyMesh}}\n\\caption{Subdivision of an Ellipse into triangles order 1 (\\finleyelement{Tri3})}\n\\label{FINLEY FIG 0}\n\\end{figure}\n\nTo understand the usage of \\finley one needs to have an understanding of how\nthe finite element meshes\\index{FEM!mesh} are defined.\n\\fig{FINLEY FIG 0} shows an example of the subdivision of an ellipse into\nso-called elements\\index{FEM!elements}\\index{element}.\nIn this case, triangles have been used but other forms of subdivisions can be\nconstructed, e.g. quadrilaterals or, in the three-dimensional case, into\ntetrahedra and hexahedra. The idea of the finite element method is to\napproximate the solution by a function which is a polynomial of a certain order\nand is continuous across its boundary to neighbour elements.\nIn the example of \\fig{FINLEY FIG 0} a linear polynomial is used on each\ntriangle. As one can see, the triangulation is quite a poor approximation of\nthe ellipse. It can be improved by introducing a midpoint on each element edge\nthen positioning those nodes located on an edge expected to describe the\nboundary, onto the boundary.\nIn this case the triangle gets a curved edge which requires a parameterization\nof the triangle using a quadratic polynomial.\nFor this case, the solution is also approximated by a piecewise quadratic\npolynomial (which explains the name isoparametrical elements),\nsee \\Ref{Zienc,NumHand} for more details.\n\\finley also supports macro elements\\index{macro elements}.\nFor these elements a piecewise linear approximation is used on an element which\nis further subdivided (in the case of \\finley halved).\nAs such, these elements do not provide more than a further mesh refinement but\nshould be used in the case of incompressible flows, see \\class{StokesProblemCartesian}.\nFor these problems a linear approximation of the pressure across the element is\nused (use the \\ReducedSolutionFS) while the refined element is used to\napproximate velocity. So a macro element provides a continuous pressure\napproximation together with a velocity approximation on a refined mesh.\nThis approach is necessary to make sure that the incompressible flow has a\nunique solution.\n\nThe union of all elements defines the domain of the PDE.\nEach element is defined by the nodes used to describe its shape.\nIn \\fig{FINLEY FIG 0} the element, which has type \\finleyelement{Tri3}, with\nelement reference number $19$\\index{element!reference number} is defined by the\nnodes with reference numbers $9$, $11$ and $0$\\index{node!reference number}.\nNotice that the order is counterclockwise.\nThe coefficients of the PDE are evaluated at integration nodes with each\nindividual element.\nFor quadrilateral elements a Gauss quadrature scheme is used.\nIn the case of triangular elements a modified form is applied.\nThe boundary of the domain is also subdivided into elements\\index{element!face}.\nIn \\fig{FINLEY FIG 0} line elements with two nodes are used.\nThe elements are also defined by their describing nodes, e.g. the face element\nwith reference number $20$, which has type \\finleyelement{Line2}, is defined by\nthe nodes with the reference numbers $11$ and $0$.\nAgain the order is crucial, if moving from the first to second node the domain\nhas to lie on the left hand side (in the case of a two-dimensional surface\nelement the domain has to lie on the left hand side when moving\ncounterclockwise). If the gradient on the surface of the domain is to be\ncalculated rich face elements need to be used. Rich elements on a face are\nidentical to interior elements but with a modified order of nodes such that the\n'first' face of the element aligns with the surface of the domain.\nIn \\fig{FINLEY FIG 0} elements of the type \\finleyelement{Tri3Face} are used.\nThe face element reference number $20$ as a rich face element is defined by the\nnodes with reference numbers $11$, $0$ and $9$.\nNotice that the face element $20$ is identical to the interior element $19$\nexcept that, in this case, the order of the node is different to align the first\nedge of the triangle (which is the edge starting with the first node) with the\nboundary of the domain.\n\nBe aware that face elements and elements in the interior of the domain must\nmatch, i.e. a face element must be the face of an interior element or, in case\nof a rich face element, it must be identical to an interior element.\nIf no face elements are specified \\finley implicitly assumes homogeneous\nnatural boundary conditions\\index{natural boundary conditions!homogeneous},\ni.e. \\var{d}=$0$ and \\var{y}=$0$, on the entire boundary of the domain.\nFor inhomogeneous natural boundary conditions\\index{natural boundary conditions!inhomogeneous},\nthe boundary must be described by face elements.\n\n\\begin{figure}\n\\centerline{\\includegraphics{FinleyContact}}\n\\caption{Mesh around a contact region (\\finleyelement{Rec4})}\n\\label{FINLEY FIG 01}\n\\end{figure}\n\nIf discontinuities of the PDE solution are considered, contact\nelements\\index{element!contact}\\index{contact conditions} are introduced to\ndescribe the contact region $\\Gamma^{contact}$ even if $d^{contact}$ and\n$y^{contact}$ are zero.\n\\fig{FINLEY FIG 01} shows a simple example of a mesh of rectangular elements\naround a contact region $\\Gamma^{contact}$\\index{element!contact}.\nThe contact region is described by the elements $4$, $3$ and $6$.\nTheir element type is \\finleyelement{Line2_Contact}.\nThe nodes $9$, $12$, $6$ and $5$ define contact element $4$, where the\ncoordinates of nodes $12$ and $5$ and nodes $4$ and $6$ are identical, with the\nidea that nodes $12$ and $9$ are located above and nodes $5$ and $6$ below the\ncontact region.\nAgain, the order of the nodes within an element is crucial.\nThere is also the option of using rich elements if the gradient is to be\ncalculated on the contact region. Similarly to the rich face elements these\nare constructed from two interior elements by reordering the nodes such that\nthe 'first' face of the element above and the 'first' face of the element below\nthe contact regions line up. The rich version of element $4$ is of type\n\\finleyelement{Rec4Face_Contact} and is defined by the nodes $9$, $12$, $16$,\n$18$, $6$, $5$, $0$ and $2$.\n\\tab{FINLEY TAB 1} shows the interior element types and the corresponding\nelement types to be used on the face and contacts.\n\\fig{FINLEY.FIG:1}, \\fig{FINLEY.FIG:2} and \\fig{FINLEY.FIG:4} show the ordering\nof the nodes within an element.\n\n\\begin{table}\n\\centering\n\\begin{tabular}{l|llll}\n\\textbf{interior}&\\textbf{face}&\\textbf{rich face}&\\textbf{contact}&\\textbf{rich contact}\\\\\n\\hline\n\\finleyelement{Line2} & \\finleyelement{Point1} & \\finleyelement{Line2Face} & \\finleyelement{Point1_Contact} & \\finleyelement{Line2Face_Contact}\\\\\n\\finleyelement{Line3} & \\finleyelement{Point1} & \\finleyelement{Line3Face} & \\finleyelement{Point1_Contact} & \\finleyelement{Line3Face_Contact}\\\\\n\\finleyelement{Tri3} & \\finleyelement{Line2} & \\finleyelement{Tri3Face} & \\finleyelement{Line2_Contact} & \\finleyelement{Tri3Face_Contact}\\\\\n\\finleyelement{Tri6} & \\finleyelement{Line3} & \\finleyelement{Tri6Face} & \\finleyelement{Line3_Contact} & \\finleyelement{Tri6Face_Contact}\\\\\n\\finleyelement{Rec4} & \\finleyelement{Line2} & \\finleyelement{Rec4Face} & \\finleyelement{Line2_Contact} & \\finleyelement{Rec4Face_Contact}\\\\\n\\finleyelement{Rec8} & \\finleyelement{Line3} & \\finleyelement{Rec8Face} & \\finleyelement{Line3_Contact} & \\finleyelement{Rec8Face_Contact}\\\\\n\\finleyelement{Rec9} & \\finleyelement{Line3} & \\finleyelement{Rec9Face} & \\finleyelement{Line3_Contact} & \\finleyelement{Rec9Face_Contact}\\\\\n\\finleyelement{Tet4} & \\finleyelement{Tri6} & \\finleyelement{Tet4Face} & \\finleyelement{Tri6_Contact} & \\finleyelement{Tet4Face_Contact}\\\\\n\\finleyelement{Tet10} & \\finleyelement{Tri9} & \\finleyelement{Tet10Face} & \\finleyelement{Tri9_Contact} & \\finleyelement{Tet10Face_Contact}\\\\\n\\finleyelement{Hex8} & \\finleyelement{Rec4} & \\finleyelement{Hex8Face} & \\finleyelement{Rec4_Contact} & \\finleyelement{Hex8Face_Contact}\\\\\n\\finleyelement{Hex20} & \\finleyelement{Rec8} & \\finleyelement{Hex20Face} & \\finleyelement{Rec8_Contact} & \\finleyelement{Hex20Face_Contact}\\\\\n\\finleyelement{Hex27} & \\finleyelement{Rec9} & N/A & N/A & N/A\\\\\n\\finleyelement{Hex27Macro} & \\finleyelement{Rec9Macro} & N/A & N/A & N/A\\\\\n\\finleyelement{Tet10Macro} & \\finleyelement{Tri6Macro} & N/A & N/A & N/A\\\\\n\\finleyelement{Rec9Macro} & \\finleyelement{Line3Macro} & N/A & N/A & N/A\\\\\n\\finleyelement{Tri6Macro} & \\finleyelement{Line3Macro} & N/A & N/A & N/A\\\\\n\\end{tabular}\n\\caption{Finley elements and corresponding elements to be used on domain faces\nand contacts.\nThe rich types have to be used if the gradient of the function is to be\ncalculated on faces and contacts, respectively.}\n\\label{FINLEY TAB 1}\n\\end{table}\n\nThe native \\finley file format is defined as follows.\nEach node \\var{i} has \\var{dim} spatial coordinates \\var{Node[i]}, a reference\nnumber \\var{Node_ref[i]}, a degree of freedom \\var{Node_DOF[i]} and a tag\n\\var{Node_tag[i]}.\nIn most cases \\var{Node_DOF[i]}=\\var{Node_ref[i]} however, for periodic\nboundary conditions, \\var{Node_DOF[i]} is chosen differently, see example below.\nThe tag can be used to mark nodes sharing the same properties.\nElement \\var{i} is defined by the \\var{Element_numNodes} nodes\n\\var{Element_Nodes[i]} which is a list of node reference numbers.\nThe order of these is crucial. Each element has a reference number\n\\var{Element_ref[i]} and a tag \\var{Element_tag[i]}.\nThe tag can be used to mark elements sharing the same properties.\nFor instance elements above a contact region are marked with tag $2$ and\nelements below a contact region are marked with tag $1$.\n\\var{Element_Type} and \\var{Element_Num} give the element type and the number\nof elements in the mesh.\nAnalogue notations are used for face and contact elements.\nThe following \\PYTHON script prints the mesh definition in the \\finley file\nformat:\n\\begin{python}\n  print(\"%s\\n\"%mesh_name)\n  # node coordinates:\n  print(\"%dD-nodes %d\\n\"%(dim, numNodes))\n  for i in range(numNodes):\n     print(\"%d %d %d\"%(Node_ref[i], Node_DOF[i], Node_tag[i]))\n     for j in range(dim): print(\" %e\"%Node[i][j])\n     print(\"\\n\")\n  # interior elements\n  print(\"%s %d\\n\"%(Element_Type, Element_Num))\n  for i in range(Element_Num):\n     print(\"%d %d\"%(Element_ref[i], Element_tag[i]))\n     for j in range(Element_numNodes): print(\" %d\"%Element_Nodes[i][j])\n     print(\"\\n\")\n  # face elements\n  print(\"%s %d\\n\"%(FaceElement_Type, FaceElement_Num))\n  for i in range(FaceElement_Num):\n     print(\"%d %d\"%(FaceElement_ref[i], FaceElement_tag[i]))\n     for j in range(FaceElement_numNodes): print(\" %d\"%FaceElement_Nodes[i][j])\n     print(\"\\n\")\n  # contact elements\n  print(\"%s %d\\n\"%(ContactElement_Type, ContactElement_Num))\n  for i in range(ContactElement_Num):\n     print(\"%d %d\"%(ContactElement_ref[i], ContactElement_tag[i]))\n     for j in range(ContactElement_numNodes): \n         print(\" %d\"%ContactElement_Nodes[i][j])\n     print(\"\\n\")\n  # point sources (not supported yet)\n  print(\"Point1 0\")\n\\end{python}\n\nThe following example of a mesh file defines the mesh shown in \\fig{FINLEY FIG 01}:\n\\begin{verbatim}\nExample 1\n2D Nodes 16\n0   0 0 0.   0.\n2   2 0 0.33 0.\n3   3 0 0.66 0.\n7   4 0 1.   0.\n5   5 0 0.   0.5\n6   6 0 0.33 0.5\n8   8 0 0.66 0.5\n10 10 0 1.0  0.5\n12 12 0 0.   0.5\n9   9 0 0.33 0.5\n13 13 0 0.66 0.5\n15 15 0 1.0  0.5\n16 16 0 0.   1.0\n18 18 0 0.33 1.0\n19 19 0 0.66 1.0\n20 20 0 1.0  1.0\nRec4 6\n 0 1  0  2  6  5\n 1 1  2  3  8  6\n 2 1  3  7 10  8\n 5 2 12  9 18 16\n 7 2 13 19 18  9\n10 2 20 19 13 15\nLine2 0\nLine2_Contact 3\n 4 0  9 12  6 5\n 3 0 13  9  8 6\n 6 0 15 13 10 8\nPoint1 0\n\\end{verbatim}\nNotice that the order in which the nodes and elements are given is arbitrary.\nIn the case that rich contact elements are used the contact element section\ngets the form\n\\begin{verbatim}\nRec4Face_Contact 3\n 4 0  9 12 16 18  6  5  0  2\n 3 0 13  9 18 19  8  6  2  3\n 6 0 15 13 19 20 10  8  3  7\n\\end{verbatim}\nPeriodic boundary conditions\\index{boundary conditions!periodic} can be\nintroduced by altering \\var{Node_DOF}.\nIt allows identification of nodes even if they have different physical locations.\nFor instance, to enforce periodic boundary conditions at the face $x_0=0$ and\n$x_0=1$ one identifies the degrees of freedom for nodes $0$, $5$, $12$ and $16$\nwith the degrees of freedom for $7$, $10$, $15$ and $20$, respectively.\nThe node section of the \\finley mesh now reads:\n\\begin{verbatim}\n2D Nodes 16\n0   0 0 0.   0.\n2   2 0 0.33 0.\n3   3 0 0.66 0.\n7   0 0 1.   0.\n5   5 0 0.   0.5\n6   6 0 0.33 0.5\n8   8 0 0.66 0.5\n10  5 0 1.0  0.5\n12 12 0 0.   0.5\n9   9 0 0.33 0.5\n13 13 0 0.66 0.5\n15 12 0 1.0  0.5\n16 16 0 0.   1.0\n18 18 0 0.33 1.0\n19 19 0 0.66 1.0\n20 16 0 1.0  1.0\n\\end{verbatim}\n\n\\clearpage\n\\input{finleyelements}\n\\clearpage\n\n\\section{Macro Elements}\n\\label{SEC FINLEY MACRO}\n\n\\begin{figure}[th]\n\\begin{center}\n\\includegraphics{FinleyMacroLeg}\\\\\n\\subfigure[Triangle]{\\label{FINLEY MACRO TRI}\\includegraphics{FinleyMacroTri}}\\quad\n\\subfigure[Quadrilateral]{\\label{FINLEY MACRO REC}\\includegraphics{FinleyMacroRec}}\n\\end{center}\n\\caption{Macro elements in \\finley}\n\\end{figure}\n\n\\finley supports the usage of macro elements\\index{macro elements} which can be\nused to achieve LBB compliance when solving incompressible fluid flow problems.\nLBB compliance is required to get a problem which has a unique solution for\npressure and velocity. For macro elements the pressure and velocity are\napproximated by a polynomial of order 1 but the velocity approximation bases on\na refinement of the elements. The nodes of a triangle and quadrilateral element\nare shown in Figures~\\ref{FINLEY MACRO TRI} and~\\ref{FINLEY MACRO REC},\nrespectively. In essence, the velocity uses the same nodes like a quadratic\npolynomial approximation but replaces the quadratic polynomial by piecewise\nlinear polynomials. In fact, this is the way \\finley defines the macro elements.\nIn particular \\finley uses the same local ordering of the nodes for the macro\nelement as for the corresponding quadratic element. Another interpretation is\nthat one uses a linear approximation of the velocity together with a linear\napproximation of the pressure but on elements created by combining elements to\nmacro elements. Notice that the macro elements still use quadratic\ninterpolation to represent the element and domain boundary.\nHowever, if elements have linear boundaries a macro element approximation for\nthe velocity is equivalent to using a linear approximation on a mesh which is\ncreated through a one-step global refinement.\nTypically macro elements are only required to use when an incompressible fluid\nflow problem is solved, e.g. the Stokes problem in \\Sec{STOKES PROBLEM}.\nPlease see \\Sec{FINLEY MESHES} for more details on the supported macro elements.\n\n\\section{Linear Solvers in \\SolverOptions}\n\nTable~\\ref{TAB FINLEY SOLVER OPTIONS 1} and\nTable~\\ref{TAB FINLEY SOLVER OPTIONS 2} show the solvers and preconditioners\nsupported by \\finley through the \\PASO library.\nCurrently direct solvers are not supported under \\MPI.\nBy default, \\finley uses the iterative solvers \\PCG for symmetric and \\BiCGStab\nfor non-symmetric problems.\nIf the direct solver is selected, which can be useful when solving very\nill-posed equations, \\finley uses the \\MKL\\footnote{If the stiffness matrix is\nnon-regular \\MKL may return without a proper error code. If you observe\nsuspicious solutions when using \\MKL, this may be caused by a non-invertible\noperator.} solver package. If \\MKL is not available \\UMFPACK is used.\nIf \\UMFPACK is not available a suitable iterative solver from \\PASO is used.\n\n\\begin{table}\n\\centering\n{\\scriptsize\n\\begin{tabular}{l||c|c|c|c|c|c|c|c}\n\\member{setSolverMethod} & \\member{DIRECT}& \\member{PCG} & \\member{GMRES} & \\member{TFQMR} & \\member{MINRES} & \\member{PRES20} & \\member{BICGSTAB} & lumping \\\\\n\\hline\n \\hline\n \\member{setReordering} & $\\checkmark$ & & & & & &\\\\\n \\hline  \\member{setRestart} &  & & $\\checkmark$ & & & $20$ & \\\\\n \\hline\\member{setTruncation} &  & & $\\checkmark$ & & & $5$ & \\\\\n   \\hline\\member{setIterMax} &  & $\\checkmark$& $\\checkmark$ & $\\checkmark$& $\\checkmark$& $\\checkmark$ & $\\checkmark$ \\\\\n \\hline\\member{setTolerance} &  & $\\checkmark$& $\\checkmark$ & $\\checkmark$& $\\checkmark$& $\\checkmark$ & $\\checkmark$ \\\\\n \\hline\\member{setAbsoluteTolerance} &  & $\\checkmark$& $\\checkmark$ & $\\checkmark$& $\\checkmark$& $\\checkmark$ & $\\checkmark$ \\\\\n\\hline\\member{setReordering} & $\\checkmark$ & & & & & & & \\\\\n\\end{tabular}\n}\n\\caption{Solvers available for \\finley and the \\PASO package and the relevant\noptions in \\class{SolverOptions}.\n\\MKL supports \\member{MINIMUM_FILL_IN}\\index{linear solver!minimum fill-in ordering}\\index{minimum fill-in ordering}\nand \\member{NESTED_DISSECTION}\\index{linear solver!nested dissection ordering}\\index{nested dissection}\nreordering.\nCurrently the \\UMFPACK interface does not support any reordering.\n\\label{TAB FINLEY SOLVER OPTIONS 1}}\n\\end{table}\n\n\\begin{table}\n\\begin{center}\n{\\scriptsize\n\\begin{tabular}{l||c|c|c|c|c|c|c}\n\\member{NO_PRECONDITIONER}&\n\\member{AMG}&\n\\member{JACOBI}&\n\\member{GAUSS_SEIDEL}&\n\\member{REC_ILU}&\n\\member{RILU}&\n\\member{ILU0}&\n\\member{DIRECT}\\\\\n\\hline\nstatus:& $\\checkmark$ &$\\checkmark$&$\\checkmark$&$\\checkmark$&later&$\\checkmark$&later\\\\\n\\hline\n\\hline\n\\member{setLevelMax}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setCoarseningThreshold}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setMinCoarseMatrixSize}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setMinCoarseMatrixSparsity}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setNumSweeps}& &$\\checkmark$&$\\checkmark$& & & &\\\\\n\\hline\n\\member{setNumPreSweeps}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setNumPostSweeps}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setDiagonalDominanceThreshold}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setAMGInterpolation}&$\\checkmark$& & & & & &\\\\\n\\hline\n\\member{setRelaxationFactor}& & & & &$\\checkmark$& &\\\\\n\\end{tabular}\n}\n\\caption{Preconditioners available for \\finley and the \\PASO package and the\nrelevant options in \\class{SolverOptions}.\n\\label{TAB FINLEY SOLVER OPTIONS 2}}\n\\end{center}\n\\end{table}\n\n\\section{Functions}\n\\begin{funcdesc}{ReadMesh}{fileName \\optional{, \\optional{integrationOrder=-1}, optimize=True}}\ncreates a \\Domain object from the FEM mesh defined in file \\var{fileName}.\nThe file must be in the \\finley file format.\nIf \\var{integrationOrder} is positive, a numerical integration scheme is chosen\nwhich is accurate on each element up to a polynomial of degree\n\\var{integrationOrder}\\index{integration order}.\nOtherwise an appropriate integration order is chosen independently.\nBy default the labeling of mesh nodes and element distribution is optimized.\nSet \\var{optimize=False} to switch off relabeling and redistribution.\n\\end{funcdesc}\n\n\\begin{funcdesc}{ReadGmsh}{fileName, numDim, \\optional{, \\optional{integrationOrder=-1}, optimize=True\\optional{, useMacroElements=False}}}\ncreates a \\Domain object from the FEM mesh defined in file \\var{fileName} for\na domain of dimension \\var{numDim}.\nThe file must be in the \\gmshextern file format.\nIf \\var{integrationOrder} is positive, a numerical integration scheme is chosen\nwhich is accurate on each element up to a polynomial of degree\n\\var{integrationOrder}\\index{integration order}.\nOtherwise an appropriate integration order is chosen independently.\nBy default the labeling of mesh nodes and element distribution is optimized.\nSet \\var{optimize=False} to switch off relabeling and redistribution.\nIf \\var{useMacroElements} is set, second order elements are interpreted as\nmacro elements\\index{macro elements}.\n\\end{funcdesc}\n\n\\begin{funcdesc}{MakeDomain}{design\\optional{, integrationOrder=-1\\optional{, optimizeLabeling=True\\optional{, useMacroElements=False}}}}\ncreates a \\finley \\Domain from a \\pycad \\class{Design} object using \\gmshextern.\nThe \\class{Design} \\var{design} defines the geometry.\nIf \\var{integrationOrder} is positive, a numerical integration scheme is chosen\nwhich is accurate on each element up to a polynomial of degree\n\\var{integrationOrder}\\index{integration order}.\nOtherwise an appropriate integration order is chosen independently.\nSet \\var{optimizeLabeling=False} to switch off relabeling and redistribution\n(not recommended).\nIf \\var{useMacroElements} is set, macro elements\\index{macro elements} are used.\nCurrently \\function{MakeDomain} does not support \\MPI.\n\\end{funcdesc}\n\n\\begin{funcdesc}{load}{fileName}\nrecovers a \\Domain object from a dump file \\var{fileName} created by the\n\\function{dump} method of a \\Domain object.\n\\end{funcdesc}\n\n\\begin{funcdesc}{Rectangle}{n0,n1,order=1,l0=1.,l1=1., integrationOrder=-1, \\\\\n  periodic0=\\False, periodic1=\\False, useElementsOnFace=\\False, optimize=\\False}\ngenerates a \\Domain object representing a two-dimensional rectangle between\n$(0,0)$ and $(l0,l1)$ with orthogonal edges.\nThe rectangle is filled with \\var{n0} elements along the $x_0$-axis and\n\\var{n1} elements along the $x_1$-axis.\nFor \\var{order}=1 and \\var{order}=2, elements of type \\finleyelement{Rec4} and\n\\finleyelement{Rec8} are used, respectively.\nIn the case of \\var{useElementsOnFace}=\\False, \\finleyelement{Line2} and\n\\finleyelement{Line3} are used to subdivide the edges of the rectangle, respectively.\nIf \\var{order}=-1, \\finleyelement{Rec8Macro} and \\finleyelement{Line3Macro}\\index{macro elements}\nare used. This option should be used when solving incompressible fluid flow\nproblems, e.g. \\class{StokesProblemCartesian}.\nIn the case of \\var{useElementsOnFace}=\\True (this option should be used if\ngradients are calculated on domain faces), \\finleyelement{Rec4Face} and\n\\finleyelement{Rec8Face} are used on the edges, respectively.\nIf \\var{integrationOrder} is positive, a numerical integration scheme is chosen\nwhich is accurate on each element up to a polynomial of degree\n\\var{integrationOrder}\\index{integration order}.\nOtherwise an appropriate integration order is chosen independently.\nIf \\var{periodic0}=\\True, periodic boundary conditions\\index{periodic boundary conditions}\nalong the $x_0$-direction are enforced.\nThat means for any solution of a PDE solved by \\finley the values on the line\n$x_0=0$ will be identical to the values on $x_0=\\var{l0}$.\nCorrespondingly, \\var{periodic1}=\\True sets periodic boundary conditions in the\n$x_1$-direction.\nIf \\var{optimize}=\\True mesh node relabeling will be attempted to reduce the\ncomputation and also ParMETIS will be used to improve the mesh partition if\nrunning on multiple CPUs with \\MPI.\n\\end{funcdesc}\n\n\\begin{funcdesc}{Brick}{n0,n1,n2,order=1,l0=1.,l1=1.,l2=1., integrationOrder=-1,\n  periodic0=\\False, periodic1=\\False, \\\\ periodic2=\\False, useElementsOnFace=\\False,useFullElementOrder=\\False, optimize=\\False}\ngenerates a \\Domain object representing a three-dimensional brick between\n$(0,0,0)$ and $(l0,l1,l2)$ with orthogonal faces. The brick is filled with\n\\var{n0} elements along the $x_0$-axis,\n\\var{n1} elements along the $x_1$-axis and\n\\var{n2} elements along the $x_2$-axis.\nFor \\var{order}=1 and \\var{order}=2, elements of type \\finleyelement{Hex8} and\n\\finleyelement{Hex20} are used, respectively.\nIn the case of \\var{useElementsOnFace}=\\False, \\finleyelement{Rec4} and\n\\finleyelement{Rec8} are used to subdivide the faces of the brick, respectively.\nIn the case of \\var{useElementsOnFace}=\\True (this option should be used if\ngradients are calculated on domain faces), \\finleyelement{Hex8Face} and\n\\finleyelement{Hex20Face} are used on the brick faces, respectively.\nIf \\var{order}=-1, \\finleyelement{Hex20Macro} and \\finleyelement{Rec8Macro}\\index{macro elements}\nare used. This option should be used when solving incompressible fluid flow\nproblems, e.g. \\class{StokesProblemCartesian}.\nIf \\var{integrationOrder} is positive, a numerical integration scheme is chosen\nwhich is accurate on each element up to a polynomial of degree\n\\var{integrationOrder}\\index{integration order}.\nOtherwise an appropriate integration order is chosen independently.\nIf \\var{periodic0}=\\True, periodic boundary conditions\\index{periodic boundary conditions}\nalong the $x_0$-direction are enforced.\nThat means for any solution of a PDE solved by \\finley the values on the plane\n$x_0=0$ will be identical to the values on $x_0=\\var{l0}$.\nCorrespondingly, \\var{periodic1}=\\True and \\var{periodic2}=\\True sets periodic\nboundary conditions in the $x_1$-direction and $x_2$-direction, respectively.\nIf \\var{optimize}=\\True mesh node relabeling will be attempted to reduce the\ncomputation and also ParMETIS will be used to improve the mesh partition if\nrunning on multiple CPUs with \\MPI.\n\\end{funcdesc}\n\n\\begin{funcdesc}{GlueFaces}{meshList, tolerance=1.e-13}\ngenerates a new \\Domain object from the list \\var{meshList} of \\finley meshes.\nNodes in face elements whose difference of coordinates is less than\n\\var{tolerance} times the diameter of the domain are merged.\nThe corresponding face elements are removed from the mesh.\n\\function{GlueFaces} is not supported under \\MPI with more than one rank.\n\\end{funcdesc}\n\n\\begin{funcdesc}{JoinFaces}{meshList, tolerance=1.e-13}\ngenerates a new \\Domain object from the list \\var{meshList} of \\finley meshes.\nFace elements whose node coordinates differ by less than \\var{tolerance} times\nthe diameter of the domain are combined to form a contact element\\index{element!contact}.\nThe corresponding face elements are removed from the mesh.\n\\function{JoinFaces} is not supported under \\MPI with more than one rank.\n\\end{funcdesc}\n\n\\section{\\dudley}\n\\label{sec:dudley}\nThe {\\it dudley} library is a restricted version of {\\it finley}.\nSo in many ways it can be used as a ``drop-in'' replacement.\nDudley domains are simpler in that only triangular (2D), tetrahedral (3D) and line elements are supported.\nNote, this also means that dudley does not support:\n\\begin{itemize}\n\\item dirac delta functions\n\\item contact elements\n\\item macro elements\n\\end{itemize}\n\n", "meta": {"hexsha": "62958fd485c6eeea98bf2bed88fcb4442ace80b8", "size": 27850, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user/finley.tex", "max_stars_repo_name": "svn2github/Escript", "max_stars_repo_head_hexsha": "9c616a3b164446c65d4b8564ecd04fafd7dcf0d2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/user/finley.tex", "max_issues_repo_name": "svn2github/Escript", "max_issues_repo_head_hexsha": "9c616a3b164446c65d4b8564ecd04fafd7dcf0d2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-14T03:07:43.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T03:07:43.000Z", "max_forks_repo_path": "doc/user/finley.tex", "max_forks_repo_name": "svn2github/Escript", "max_forks_repo_head_hexsha": "9c616a3b164446c65d4b8564ecd04fafd7dcf0d2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.4671403197, "max_line_length": 159, "alphanum_fraction": 0.7554039497, "num_tokens": 8144, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4366132524826857}}
{"text": "\\documentclass[ 12pt, a4paper]{article}\n% Use the option doublespacing or reviewcopy to obtain double line spacing\n% \\documentclass[doublespacing]{elsart}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[backend = biber, maxcitenames=2,uniquelist=minyear]{biblatex}\n\n\\AtEveryBibitem{\\clearfield{number}}\n\\AtEveryBibitem{\\clearfield{doi}}\n\\AtEveryBibitem{\\clearfield{url}}\n\\AtEveryBibitem{\\clearfield{issn}}\n\\AtEveryBibitem{\\clearfield{isbn}}\n\n\\addbibresource{references.bib}\n\n\\usepackage{color,graphicx,tikz}\n\\usetikzlibrary{positioning,arrows}\n% The amssymb package provides various useful mathematical symbols\n\\usepackage{mathtools,amssymb,amsmath,mathdots}\n\\usepackage[mathscr]{eucal} %just for the font \\mathscr\n\\usepackage{setspace}\n\\usepackage{hyperref}\n\n\\usepackage{tikz}\n\n\\renewcommand{\\vec}[1]{\\boldsymbol{#1}}\n\\renewcommand{\\thefootnote}{\\fnsymbol{footnote}}\n\n\\input{macros}\n\n\\begin{document}\n\n\\title{Multiple scattering of waves}\n\\author{\nArtur L. Gower$^{a}$,\\\\\n\\footnotesize{$^{a}$ School of Mathematics, University of Manchester, Oxford Road, Manchester, M13 9PL,UK}\n}\n\\date{\\today}\n\\maketitle\n\n\\begin{abstract}\nHere we show and deduce the T-matrix and a general multiple scattering formulation which can be adapted to acoustics, electromagnetism, and elasticity. For details on each specific physical medium see the other documents.\n\\end{abstract}\n\n\\noindent\n{\\textit{Keywords:} Multiple scattering, T-matrix, Scattering matrix}\n\n\\section{Using a T-matrix}\nA T-matrix denotes how one single particle scatters waves~\\parencite{ganesh_far-field_2010,ganesh_algorithm_2017}.\n\nFor convenience and generality we denote:\n\\begin{equation}\n\\begin{aligned}\n    & \\mathrm u_{n}(k\\rv) = \\text{outgoing spherical waves},\n    \\label{eqn:outgoing_waves_and_regular_waves}\n    \\\\\n    & \\mathrm v_{n}(k\\rv)= \\text{regular spherical waves},\n \\end{aligned}\n\\end{equation}\nwhere $n$ denotes a multi index which depends on the dimension and if the waves are scalar or vector fields.\n\nAny incident wave and scattered wave\\footnote{For the scattered wave we need only use outgoing spherical waves when measuring the field outside of a sphere which completely encompasses the particle.}, centred at the same coordinate axis, can be written as\n\\begin{align}\n  & \\ui = \\sum_{n} g_n \\mathrm v_{n}(k\\rv),\n  \\\\\n  & \\us = \\sum_{n} f_n \\mathrm u_{n}(k\\rv).\n\\end{align}\nThe T-matrix is an infinite matrix such that\n\\begin{equation}\n  f_n = \\sum_{n'} T_{nn'} g_{n'}.\n\\end{equation}\nSuch a matrix $T$ exists when scattering is a linear operation (elastic scattering).\n\nWe can also estimate the field inside the particle by assuming that the field is smooth and continuous. This approximation is exact for homogeneous spheres and cylinders, but not for a \\href{acoustics.pdf}{Circular cylindrical capsule}.\n\nAssume the field inside the particle can be described by a regular spherical series:\n\\begin{equation}\n  \\vi = \\sum_n b_n \\mathrm v_n(k_o \\rv),\n\\end{equation}\nwhere $k_o$ if the particles wavenumber. Now if we assume that the total field is continuous everywhere so that $\\ui + \\us = \\vi$ on the boundary of the particle. If the field was smooth enough, we could analytically extend the field $\\vi$ to a spherical boundary, with radius $a$, which contains the particle. Let's take this as an assumption and equate $\\ui + \\us = \\vi$ for $r=a$. Due to orthogonality of the angular components of the basis functions this will result in\n\\begin{equation}\n   g_n \\mathrm v_{n}(k\\rv) + f_n \\mathrm u_{n}(k\\rv) = b_n \\mathrm v_n(k_o \\rv), \\quad \\text{for} \\;\\; |\\rv| = a\n\\end{equation}\nusing the T-matrix we can then write $g_n = T_{nm}^{-1} f_m$, which substituted above leads to\n\\begin{equation}\n    b_n = \\frac{1}{\\mathrm v_n(k_o \\rv)}[ \\mathrm v_{n}(k\\rv) T_{nm}^{-1} f_m + \\mathrm u_{n}(k\\rv) f_n], \\quad \\text{for} \\;\\; |\\rv| = a.\n\\end{equation}\n\n\\section{Multiple scattering in general}\n\nFor multiple scattering in higher dimensions and for vector wave equations we use the notation given in \\cite{gower2020effective}.\n\nFor a point $\\rv$, outside of the circumscribed spheres of all particles, we can write the total field $u(\\rv)$ as a sum of the incident wave $\\ui(\\rv)$ and all scattered waves in the form~\\cite{Kristensson2015a,Kristensson2016,Linton+Martin2006}\n\\begin{equation}\n    u(\\rv) = \\ui(\\rv) + \\us(\\rv), \\quad \\us(\\rv) =  \\sum_{i=1}^N \\sum_n f_n^i \\mathrm u_n (k \\rv - k \\rv_i),\n    \\label{eqn:total_discrete_wave}\n\\end{equation}\nwhere we assumed $ |\\rv - \\rv_i| > a_i $ for $i=1,2,\\ldots N$, the $f_n^i$ are coefficients we need to determine, where again:\n\\begin{equation}\n\\left\\{\\begin{aligned}\n    & \\mathrm u_{n}(k\\rv) = \\text{outgoing spherical waves},\n    \\label{eqn:outgoing_waves_and_regular_waves}\n    \\\\\n    & \\mathrm v_{n}(k\\rv)= \\text{regular spherical waves},\n \\end{aligned}\\right.\n\\end{equation}\nwhere $n$ denotes a multi index which depends on the dimension and if the waves are scalar or vector fields.\n\nIn general, we can write the multiple scattering system in the form:\n\\begin{equation}\\label{eqn:multiple-scattering-general}\n   \\alpha_n^i=g_{n}^i\n    +\\sum_{\\substack{j=1\\\\j\\neq i}}^N \\sum_{n' n''}\\mathcal{U}_{n''n}(k\\rv_i - k\\rv_j)T_{n''n'}^j \\alpha_{n'}^j,\n\\end{equation}\nfor $i=1,2,\\ldots,N$, where $f_n^i = \\sum_{n'} T^i_{nn'}\\alpha_{n'}^i$ and $\\mathcal{U}_{nn'}$ is a translation matrix \\cite{Bostrom+Kristensson+Strom1991,Friedman+Russek1954}. Let $\\rv'=\\rv+\\dv$, then\nthe translation matrices for a translation $\\dv$ can be defined by the property~\\cite{Bostrom+Kristensson+Strom1991}\n  \\begin{equation}\\label{eq:translation_spherical_waves}\n \\left\\{\\begin{aligned}\n   &\\mathrm{v}_n(k\\rv')=\\sum_{n'}\\mathcal{V}_{nn'}(k\\dv)\\mathrm{v}_{n'}(k\\rv),\\quad \\text{ for all }\\dv\n   \\\\\n &\\mathrm{u}_n(k\\rv')=\\sum_{n'}\\mathcal{V}_{nn'}(k\\dv)\\mathrm{u}_{n'}(k\\rv),\\quad |\\rv|>|\\dv|\n \\\\\n   &\\mathrm{u}_n(k\\rv')=\\sum_{n'}\\mathcal{U}_{nn'}(k\\dv)\\mathrm{v}_{n'}(k\\rv),\\quad |\\rv|<|\\dv|\n   \\\\\n \\end{aligned}\\right.\n \\end{equation}\n\n\\subsection{Turing equations into code}\nFor easy implementation we need the functions:\n\\[\n\\psi_\\inc \\mapsto g^m_j \\quad \\text{and} \\quad \\text{particle} \\mapsto T^{nm}_j.\n\\]\n\nFor efficient implementation we rewrite~\\eqref{eqn:multiple-scattering-general} as a matrix equation. Let\n\\begin{align}\n  &(\\vec \\alpha_j)_n =  \\alpha_n^j, \\quad (\\vec g_j)_n =  g_n^j,\n  \\\\\n  &(\\vec T_j)_{nn'} = T_{nn'}^j, \\quad (\\vec {\\mathcal U}_{j \\ell})_{n'n} = \\mathcal U_{n'n}(k \\rv_j - k\\rv_\\ell),\n  % H_{n'-n}(k R_{\\ell j})\\ee^{\\ii(n'-n)\\Theta_{\\ell j}},\n\\end{align}\n\n Then\n\\begin{equation}\n \\sum_{\\ell}(\\delta_{j \\ell} +  (\\delta_{j \\ell}-1) \\vec {\\mathcal U}_{j \\ell}^{\\mathrm T} \\vec T_\\ell) \\vec \\alpha_\\ell  =  \\vec g_j,\n\\end{equation}\nwhere $\\cdot ^{\\mathrm T}$ is the transpose operation. The above then leads to a block matrix equation:\n\\begin{equation}\n  \\begin{bmatrix}\n    \\vec I & - \\vec {\\mathcal U}_{1 2}^{\\mathrm T}\\vec T_2 & \\cdots & - \\vec {\\mathcal U}_{1 (N-1)}^{\\mathrm T} \\vec T_{N-1} & - \\vec {\\mathcal U}_{1 N}^{\\mathrm T} \\vec T_N \\\\\n    - \\vec {\\mathcal U}_{2 1}^{\\mathrm T} \\vec T_1 & \\vec I &  - \\vec {\\mathcal U}_{2 3}^{\\mathrm T} \\vec T_3 & \\cdots & - \\vec {\\mathcal U}_{2 N}^{\\mathrm T} \\vec T_N \\\\\n     & \\vdots & & & \\vdots \\\\\n     - \\vec {\\mathcal U}_{N 1}^{\\mathrm T} \\vec T_1  & \\cdots & \\cdots & -  \\vec {\\mathcal U}_{N (N-1)}^{\\mathrm T} \\vec T_{N-1} & \\vec I\n  \\end{bmatrix}\n  \\begin{bmatrix}\n    \\vec \\alpha_1 \\\\\n    \\vec \\alpha_2 \\\\\n    \\vdots \\\\\n    \\vec \\alpha_N\n  \\end{bmatrix}\n   = \\begin{bmatrix}\n     \\vec g_1 \\\\\n     \\vdots \\\\\n     \\vec g_N\n   \\end{bmatrix}\n\\end{equation}\n\n\n\\printbibliography\n\n\\end{document}\n", "meta": {"hexsha": "8a1ff0759049670adbdf5e427a40b65ad1961953", "size": 7576, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/maths/multiplescattering.tex", "max_stars_repo_name": "andyDoucette/MultipleScattering.jl", "max_stars_repo_head_hexsha": "5f076c1049dddaa7c1c7d73ab8f18b4090eab350", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2020-03-26T17:23:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-30T21:53:10.000Z", "max_issues_repo_path": "docs/src/maths/multiplescattering.tex", "max_issues_repo_name": "andyDoucette/MultipleScattering.jl", "max_issues_repo_head_hexsha": "5f076c1049dddaa7c1c7d73ab8f18b4090eab350", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 28, "max_issues_repo_issues_event_min_datetime": "2017-11-10T09:10:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-05T15:14:27.000Z", "max_forks_repo_path": "docs/src/maths/multiplescattering.tex", "max_forks_repo_name": "andyDoucette/MultipleScattering.jl", "max_forks_repo_head_hexsha": "5f076c1049dddaa7c1c7d73ab8f18b4090eab350", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2018-02-19T11:17:09.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-25T10:51:53.000Z", "avg_line_length": 44.5647058824, "max_line_length": 473, "alphanum_fraction": 0.6964097149, "num_tokens": 2543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4366132477125873}}
{"text": "\\chapter{Introduction}  %Title of the First Chapter\n\nUsing past experience to update ones behaviour is what differentiates intelligent beings from other creatures in our world. To artificially create said systems, that can learn from data acquired through experience, is the crowning goal of the field of Artificial Intelligence (AI) and Machine Learning (ML) \\citep{turing}.\nRealising this goal will have a large impact on the world and society we live in, as it will liberate humans from tasks that require cognition, like driving cars, booking appointments, and interpreting and acting on medical records, to give a few examples. Though, arguably, the field has still a long way to go before fulfilling its full potential \\citep{grace2018will}.\n\nAn elegant approach to formalise the concept of learning through acquired experience is that of \\emph{Bayesian learning} \\citep{murphy}. In this framework, one specifies beliefs about quantities of interest, and updates them after observing data. The beliefs are represented using probability distributions: the \\emph{prior} describes what is known about the quantity before any data is observed, and the so-called \\emph{likelihood} describes the relation between the observed data and the quantity of interest. The framework provides a recipe for obtaining an updated belief over the quantity of interest after data has been observed. This distribution is known as the \\emph{posterior}. Bayesian learning makes decisions atop these beliefs, and uses the posterior to reason about the optimality of a decision or the cost associated to a certain action.\n\nThe performance of a decision-making system will depend on the speed at which it can learn and the optimality of the decisions made---quantified by the \\emph{regret}. It can be shown that, under certain assumptions, Bayesian learning gives rise to the optimal regret \\citep{Lattimore}. However, such excellence comes at a high computational cost, which in many scenarios renders Bayesian learning---in its purest form---impractical. Fortunately, the literature has proposed many approximate methods which have lightened the computational complexity of the Bayesian paradigm \\citep{Neal1993Probabilistic,jordan1999introduction,minka2001expectation}.\n\nUnquestionably, models for decision-making systems need to deal with \\emph{uncertainty}. They need to be able to quantify what is known, and what is not known. The importance of quantifying uncertainty for decision-making systems becomes clear from the many sources it can stem from. For example, there can be multiple different settings of a model that explain the data, so one needs to be uncertain about the setting that actually generated it. One also needs to be uncertain about the model itself, as most probably the model at hand is a simplification of the real-world process. Moreover, the environment in which the system operates may also be inherently uncertain, in which case even an infinite amount of data (i.e. experience) would not make the system any smarter (e.g., trying to predict the outcome of rolling a fair dice).\n\nGaussian Processes (GPs) \\citep{rasmussen2006} can be argued to provide the perfect compromise between computational complexity and Bayesian rigour. Their non-parametric nature makes them complex enough to model a wide range of problems, while their kernel formulation makes them applicable to many different domains: graphs, vectors, images, etc. Instead of representing probability distributions on weights, Gaussian processes can be used to represent uncertainty directly on the function that the weights represents. The \\emph{function-space} view of Gaussian processes makes them more amenable to mathematical analysis, which in turn leads to strong guarantees on the future performance of the system and overall robustness. This may be necessary for deploying these systems in critical applications. For these reasons studying Gaussian processes is very worthwhile.\n\nThis reports presents two pieces of research in the domain of approximate Bayesian inference for GP models conducted during the first year of my PhD degree. Namely, \\cref{chapter:vish} introduces an interdomain inducing variable approach that speeds up inference and prediction in GPs by two orders of magnitude by making use of the spectral properties of the kernel. In \\cref{chapter:dnn-as-point-estimate-for-dgps} we marry the strengths of deep neural networks and deep GPs by establishing an equivalence between the forward passes of both models. This results in models that can either be seen as neural networks with improved uncertainty prediction or deep GPs with increased prediction accuracy. The final part of this report, \\cref{chapter:future-research}, elaborates on a future research agenda. Prior to all of this, we start with covering the theoretical background in \\cref{chapter:theoretical-framework}.\n\nThe material presented in \\cref{chapter:vish,chapter:dnn-as-point-estimate-for-dgps} is either published or is currently under review:\n\\begin{enumerate}\n    \\item \\fullcite{Dutordoir2020spherical}\n    \\item \\fullcite{dutordoir2021deep}\n    \\item \\fullcite{dutordoir2021gpflux}\n\\end{enumerate}\n", "meta": {"hexsha": "6d6bb3a52c06fa69c6e1dc8c69c72f4d50a67a07", "size": 5176, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter1/chapter1.tex", "max_stars_repo_name": "vdutor/FYR", "max_stars_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/chapter1.tex", "max_issues_repo_name": "vdutor/FYR", "max_issues_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/chapter1.tex", "max_forks_repo_name": "vdutor/FYR", "max_forks_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 235.2727272727, "max_line_length": 917, "alphanum_fraction": 0.8172333849, "num_tokens": 1056, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.43661324698527193}}
{"text": "% !TEX root = ../main.tex\n% chktex-file 21\n\\section{Introduction}%\n\\label{sec:intro}\n\n\\pagenumbering{arabic}\t\t\t% arabic page numbering\n\\setcounter{page}{1}\t\t\t% set page counter\n\nOver the last few years Big Data processing has become increasingly important in many domains.\nThis increase in the data volume also poses new challenges for machine learning applications.\nThe training time of learners is usually polynomially dependent on the size of the training dataset \\(\\Dtrain\\), i.~e. \\(\\mathcal{O}(|\\Dtrain|^\\alpha), \\alpha \\geq 1\\).\nSince training has to be repeated for every iteration of cross-validation and hyperparameter search, always using the entire dataset quickly becomes infeasible.\nThis paper gives an overview of approaches to tackle this problem with a focus on the domain of classification problems.\n\nThe process of finding a hypothesis can in general be split into three phases:\n\\begin{enumerate}\n\t\\item \\textbf{Model selection:}\n\t\tAt first a model has to be selected that determines the class of hypothesis spaces out of which the final hypothesis will be selected.\n\t\tThe choice of model is often implicitly encoded in the class of hypothesis spaces of a learner \\(L\\).\n\t\tAutomating this step is non-trivial.\n\t\tIn practice the model is typically selected by experts with domain specific knowledge about the problem at hand.\n\t\\item \\textbf{Hyperparameter search:}\n\t\tOptimizing a vector \\(\\lambda\\) in the hyperparameter space \\(\\Lambda_L\\) of the learner \\(L\\) representing a hypothesis space \\(\\mathcal{H}_{\\lambda}\\).\n\t\tA na{\\\"\\i}ve approach to do this is to systematically try configurations using a grid search or a random search over \\(\\Lambda_L\\).\n\t\tTo evaluate the quality of a given \\(\\lambda\\), \\(L\\) is usually trained on a training dataset \\(\\Dtrain\\) using \\(\\lambda\\). This yields a hypothesis \\(\\hat{h}_\\lambda \\in \\mathcal{H}_{\\lambda}\\) that is evaluated using a validation dataset \\(\\Dvalid\\).\n\t\tThe goal of hyperparameter optimization is to minimize the loss \\(l(\\lambda)\\) of \\(\\hat{h}_\\lambda\\) on \\(\\Dvalid\\), i.~e.\\@ to find an approximation \\(\\hat{\\lambda}\\) of \\(\\lambda^* := \\arg\\min_{\\lambda}{l(\\lambda)}\\).\n\t\\item \\textbf{Training or parameter search:}\n\t\tLet \\(w\\) be a vector in the parameter space \\(W_{\\mathcal{H}_\\lambda}\\), describing a hypothesis \\(h_{\\lambda, w} \\in \\mathcal{H}_\\lambda\\) given a hyperparameter configuration \\(\\lambda\\).\n\t\tThe goal of parameter search is to find an approximation \\(\\hat{h}_\\lambda\\) of the hypothesis \\(h^*_\\lambda := \\arg\\min_{h_{\\lambda, w}}{\\ell(\\Dtrain | h_{\\lambda, w})}\\), with \\(\\ell(\\Dtrain | h_{\\lambda, w})\\) being the empirical loss of \\(h_{\\lambda, w}\\) on a given training dataset \\(\\Dtrain\\) according to some loss function \\(\\ell\\).\n\t\tDepending on the learner \\(L\\), various kinds of optimization methods are used to find this minimum, e.~g.\\@ Bayesian optimization, quadratic programming or, if \\(\\nabla_w e(\\Dtrain | h_{\\lambda, w})\\) is computable, gradient descent.\n\t\tThe quality \\(l\\) of \\(\\hat{h}_\\lambda\\) is measured by the loss on a validation or test dataset, i.~e.\\@ \\(l(\\lambda) := \\ell(\\Dvalid | \\hat{h}_\\lambda)\\).\n\\end{enumerate}\nThis paper is structured according to the last two phases, i.~e.\\@ we will assume that the learner \\(L\\) is given.\nSection~\\ref{sec:hyperparams} describes ways to speed up the hyperparameter search.\nSection~\\ref{sec:params} then describes how to improve the training methods of existing learners.\nMost of the techniques described in this paper improve upon independent components of the hypothesis finding process, allowing them to be combined.\n", "meta": {"hexsha": "c76005d4703c100a02db49892674fe91610a2b10", "size": 3593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/content/chapter-introduction.tex", "max_stars_repo_name": "Cortys/aml-seminar", "max_stars_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/content/chapter-introduction.tex", "max_issues_repo_name": "Cortys/aml-seminar", "max_issues_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/content/chapter-introduction.tex", "max_forks_repo_name": "Cortys/aml-seminar", "max_forks_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.1081081081, "max_line_length": 343, "alphanum_fraction": 0.7392151406, "num_tokens": 928, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.43661323485692327}}
{"text": "\\newcommand\\lbxmonad{\\texttt{xmonad}\\xspace}\n\n\\NV{(R3)\n Regarding your XMonad experience, you might want to compare your approach to the work of Wouter Swierstra: \"Xmonad in Coq (Experience Report)\n}\n\\section{XMonad: From Testing to Static Verification}\\label{sec:xmonad}\n\nIn this section we discuss our experience in the on-going endeavour of \nstatic verification of \\lbxmonad.\n%\nWe start by summarizing the data structures used in \\lbxmonad, as described in the documentation.\n%\nWe continue by specifying and proving \\lbxmonad's invariant, \\ie, that\nvirtual workspaces are unique\n%\nFinally, we comment on proving \\lbxmonad properties to conclude \nthat static verification can be not much harder than testing.\n\n\\subsection{The structure}\n\n\\lbxmonad is a dynamically tiling \\texttt{X11} \nwindow manager that is written and configured in Haskell.\n\nThe window (@a@) is a set of virtual workspaces. \nOn each workspace is a stack of windows. \nA given workspace is always current, and a given\nwindow on each workspace has focus. \nThe focused window on the current\nworkspace is the one which will take user input. \n%\n\\lbxmonad uses a Zipper~\\citep{zipper} data structure \nto directly track focus on the virtual workspaces, \nand calls this structure @Stack a@.\n\nA workspace is just a @Stack@ of virtual workspaces \ntagged with a tag @i@ and its layout @l@\n@Workspace i l a@.\n\nTo view a workspace on a physical screen one needs to \nassociate the workspace with physical screen's id @sid@\nand details @sd@, \nforming the new data structure @Screen i l a sid sd@.\n\nXinerama in X11 allows viewing multiple virtual workspaces\nsimultaneously. \n%\nWhile only one the current one will ever be in focus (i.e. will\nreceive keyboard events), other workspaces may be passively\nviewable.  \n%\nWe thus need to track which virtual workspaces are\nassociated (viewed) on which physical screens.  \n%\nTo keep track of\nthis, \\lbxmonad's main data structure  @StackSet i l a sid sd@ \nkeeps, apart from the current screen,\nseparate lists of visible but non-focused\nworkspaces (@Screen@) , and non-visible workspaces (@Workspace@).\n\n\\subsection{Uniqueness of windows}\nWe proved that each window @a@ appears once in the @StackSet i l a sid sd@\nbottom-up: \nWe proved that each @Stack@ has unique elements\nand that all the stacks that appear in @StackSet@ are disjoint.\n\n\\mypara{Unique Stack} \nAssume the existence of a predicate \n@ULNeq (X::a) (XS::[a])@ that ensures that \n(1)~the list @XS@ has no duplicates and\n(2)~@X@ is not an element of @XS@.\n%\nWith that magical predicate we define an \\emph{almost unique}\nstack: \n\\begin{code}\ndata Stack a = Stack { focus :: a   \n                     , up    :: ULNEq a focus\n                     , down  :: ULNEq a focus }\n\\end{code}\nThe stack has a @focus@ element @a@ and \nand two unique lists of @a@'s @up@ and @down@ of the focus.\n\nThe above Stack is almost unique, as an element \nmay appear both in the @up@ and the @down@ lists.\n%\nWe define a type alias for @U@nique@Stack@\nthat rejects with possibility:\n\n\\begin{code}\ntype UStack a = {v:(Stack a) | \n  (LDisjoint (up v) (down v))}\n\npredicate LDisjoint X Y = \n  (Set_emp (Set_cap (listElts X) (listElts Y)))\n\\end{code}\n\nwhere @listElts@ is a recursively defined measure that \nreturns the Set of elements of the input list, \nthat is build in \\toolname.\n\\begin{code}\nmeasure listElts  :: [a] -> (Set a) \n   listElts([])   = {v | (Set_emp v) }\n   listElts(x:xs) = {v | v = \n     (Set_cup (Set_sng x) (listElts xs))} \n\\end{code}\n\nNote that the above definitions crucially depend on set theoretic properties.\nThus, verification of \\lbxmonad is achieved using an SMT back-end \nthat supports set theory (like Z3~\\citep{z3}).\n\nWe slightly modify the above measure definition\nto define @listDup@, a measure that returns the duplicate\nelements of a list.\n%\n\\begin{code}\nmeasure listDup :: [a] -> (Set a)\n listDup([])   = {v | (Set_emp v)}\n listDup(x:xs) = {v | v = \n   if (Set_mem x (listElts xs)) \n    then (Set_cup (Set_sng x) (listDup xs))\n    else (listDup xs))                      }\n\\end{code}\n\nUsing @listDup@ we define the magical list type @ULNEq a N@ \nas a list @v@ that has no duplicates, \\ie the set @listDup v@\nis empty, and @N@ does not belong to the set @listElts v@.\n\n\\begin{code}\ntype ULNEq a N = {v:[a] | ( (UL v) && (not (LElt N v))}\n\npredicate LElt N LS  = (Set_mem N (listElts LS)) \npredicate UL     LS  = (Set_emp (listDup LS)   )\n\\end{code}\n\nThroughout verification\nwe need to establish and use the invariant \nthat each Stack is Unique.\n%\nThis is achieved by the following annotation\n\\begin{code}\nusing (Stack a) as (UStack a)\n\\end{code}\nthat allows \\toolname to \n(1)~ use the invariant:\neach time a Stack value is retrieved from the environment\n\\toolname strengthens its type with the disjointness information;\n(2)~ prove the invariant:\neach time @Stack@ data constructor is used,\nan disjoint constraint should be proved.\nFailure to prove this constraint will raise an \n``Invariant Check'' error.\n\n\\mypara{Unique StackSet} \nEstablishing Uniqueness on StackSets is a generalization of the above procedure.\n\nThe definition of a @StackSet@ includes \nthe @current@ Screen, \nthe list of @visible@ screens,\nand the list of @hidden@ workspaces.\n\\begin{code}\ndata StackSet i l a sid sd = StackSet \n   { lcurrent  ::  Screen i l a sid sd   \n   , lvisible  :: [Screen i l a sid sd]\n   , lhidden   :: [Workspace i l a]\n   , lfloating :: M.Map a RationalRect     \n   }\n\\end{code}\n%\n\\toolname automatically turns the record selectors of refined data types\nto measures that return the appropriate fields.\n%\nThus we infix the refined selectors with an @l@\nto distinguish between the haskell (\\eg, @current@)\nand the logical (\\eg, @lcurrent@) selectors. \n\nTo prove absence of duplicates we need to @use@\nonly @StackSet@s that have no duplicates:  \n\\begin{code}\nusing (StackSet i l a sid sd) \n as  {v:StackSet i l a sid sd|(NoDuplicates v)}\n\\end{code}\n\n@NoDuplicates@ ensures that the elements of\n@hidden@, @current@, and @visible@ \nworkspaces are mutually disjoint\nand that the @visible@ and @hidden@ workspaces\nhave no duplicates.\n%\n\\begin{code}\npredicate NoDuplicates SS = \n    (Disjoint3  (workspacesElts (lhidden  SS)) \n                (screenElts     (lcurrent SS)) \n                (screensElts    (lvisible SS))) \n  &&\n    (Set_emp (screensDups    (lvisible SS))) \n  &&\n    (Set_emp (workspacesDups (lhidden  SS)))\n\\end{code}\n%\nAgain we used recursively defined measures to grap \nthe elements and the duplicates of the structures.\nFor example, @screenElts@ returns \nthe elements of the stack of the workspace of the screen, \nand is used by @screensDup@ to grap the duplicates of \na list of Screens.\n\n\\mypara{Verification Procedure}\nUsing the above unique types make \\toolname verify the absence of duplicates.\n%\nIt was not surprising that when we first run \\toolname \nagainst these stronger types many type errors where created.\n%\nThe \ncan be summarized as follows:\n\\begin{itemize}\n\t\\item\\emph{Strengthening library functions.}\n      \\lbxmonad repeatedly concatenates the list fields of a Stack.\n      %\n      To prove that for some `s::UStack a`, `(up s ++ down s)` is a unique list, \n      the type of `(++)`\n      needs to capture that concatenation of two unique and disjoint lists is a unique list.\n      %\n      For verification, we assumed that Prelude's `(++)` satisfies this property.\n      %\n      But, not all arguments of `(++)` are unique disjoint lists:\n      @\"StackSet\" ++ \"error\"@ is a trivial example that does not satisfy\n      the assumed preconditions of `(++)` thus creating a type error.\n      % \n      Sadly, \\toolname does not currently support sum types, \n      thus we used an unrefined `(++.)` variant of `(++)` for such cases.\n%%\n%%\tThus function @mapLayout@ seemed en auto-provable one, \n%%\tas it only modify the layout elements @l@ \n%%\twhich cannot affect the uniqueness of @a@ elements.\n%%\t%\n%%\\begin{code}\n%%mapLayout :: (l -> l') \n%%          -> StackSet i l a s sd \n%%          -> StackSet i l' a s sd\n%%\\end{code}\n     \n\t\\item\\emph{Restrict the functions' domain.}\n\t@modify@ is a @maybe@ like function\n\tthat given a default value @x@,\n\ta function @f@ and a StackSet @s@,\n\tapplies @f@ on the @Maybe (Stack a)@ values inside @s@. \n\t%\n\\begin{code}\nmodify :: \n    x:{v:Maybe (UStack a) | (isNothing v)}\n -> f:(y:(UStack a) \n     -> Maybe {v:UStack a) | (SubElts v y)})\n -> s:StackSet i l a s sd \n -> StackSet i l a s sd\n\\end{code}\n\t%\n\tSince inside the StackSet each @y:Maybe (Stack a)@\n\tcould be replaced with either the default value @x@\n\tor @f y@ we need to ensure that both there alternatives\n\twill not insert duplicates.\n\t%\n\tThis imposes the interesting precondition that the default\n\tvalue should be @Nothing@, which dramatically restricts \n\t@modify@'s domain.\n\t%\n\tGiven this restriction, \\toolname should verify \n\tthat all user functions satisfy it.\n\t\t\t\n\t\\item\\emph{Code inlining}\n    %\n    Given a tag @i@ and a StackSet @s@, \n    @view i s@ will set the current Screen \n    to the screen with tag @i@, \n    if such screen exists in @s@.\n    %\n    Below is the original definition for @view@\n    in case when a screen with tag @i@ exists in \n    visible screens\n    %\n\\begin{code}\nview :: (Eq s, Eq i) => i \n    -> StackSet i l a s sd -> StackSet i l a s sd\nview i s    \n  | Just x <- L.find ((i==).tag.workspace) \n                     (visible s)\n  = s { current = x\n      , visible = current s : \n          L.deleteBy (equating screen) x \n                     (visible s)} \n\\end{code}\n    %\n    Verification of this code is difficult\n    as the properties of all intermediate values \n    are too complicated to be expressed.\n    %\n    Instead we replaces this code with a call to a \n    recursive function @raiseIfVisible i s@\n    that in-place replaces @x@ with the current screen.  \n  \n\\end{itemize}\n\n\\subsection{QuickCheck Properties}\n\n\\lbxmonad is tested against $113$ \\texttt{quickcheck} properties.\n%\nOf those $15$ check the uniqueness invariant \nand the rest $113$ check various functional properties.\n%\nWe started the endeavour of verifying these properties with \\toolname.\n%\nWe looked at a sample of $15$ properties to conclude that\nwhich we categorized as follows:\n\\begin{itemize}\n\\item\\emph{Easy to be proved.}\nConsider the \\texttt{quickcheck} property that checks that @view@ing \na @StackSet a@ is idempotent:\n\\begin{code}\nprop_view_idem (x :: T) (i :: NonNegative Int) \n  = i `tagMember` x ==> view i (view i x) == (view i x)\n\\end{code}\n%\nThe above property directly translated to a haskell function\n\\begin{code}\ntype Valid     = {v:Bool | (Prop v) }\n\nprop_view_idem :: StackSet i l a sid sd -> i -> Valid\nprop_view_idem x i \n  | i `tagMember` x = view i (view i) == v\n  | otherwise       = True\n\\end{code}\n%\nBy the above type signature,\n\\ie by the result type @Valid@, \nwe specify that the function should always returns True.\n%\nWhen typechecking the above function,\n\\toolname proves that the property holds.\n%\n\\toolname is able to verify this property as the result type of @view@\nis strengthens with a refinement \n(in this case @EqTag x i => x = v@) \nthat directly implies this property.\n\nThe above is generalizing to (10/17) properties that we checked:\nstrengthening the function types by refinements that \\toolname can prove\nis sufficient to verify these properties.\n\n\\item\\emph{Can be estimated.}\nIn some other properties (like checking that @view@ing is reversible),\ntwo StackSets (@s1@ and @s2@) were normalized before being compared,\nthat is their elements were first sorted.\n%\nIn our logic we do not support any operation that can normalize structures in such a way.\n%\nThus we cannot prove this exact property.\n%\nInstead we approximated it, by proving that proving that @s1@ and @s2@\nhave the same sets of elements.\n%\nWe approximated (3/17) of the properties.\n\n\\item\\emph{Their proof cannot be supported, currently.} [1]\nOne \\texttt{quickcheck} property checks \nthat @i@ cannot belong to an empty stackset.\n%\nWe used abstract refinements to encode empty stacksets.\n%\nProving the above property would be easy \nif we could mix abstract and concrete refinements in logical formulas\nor if \\toolname supported sum types.\n%\nBoth the alternatives constitutes features that\nwe would like to extend \\toolname with in the near future.\n%\nStill, currently we are not able to prove such kind of properties.\n\\item\\emph{Cannot be expressed}\nOther properties %, like @prop_focus_left_master@ \ncheck that the order of the windows is not affected by certain operations.\n%\nThough not infeasible we acknowledge that \\toolname \nis not appropriate for reasoning about order preserving\nand verification of such properties \nwould require many code modifications.\n%\n(3/17) are order preserving properties.\n\\end{itemize}\n", "meta": {"hexsha": "1f0e805771411b50aed5bdf6a187385ac83ba7e7", "size": 12727, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/realworldhaskell/xmonad.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/realworldhaskell/xmonad.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/realworldhaskell/xmonad.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 32.9715025907, "max_line_length": 142, "alphanum_fraction": 0.7100652157, "num_tokens": 3429, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.43661323485692327}}
{"text": "% arara: pdflatex\n% arara: bibtex\n% arara: pdflatex\n\\documentclass[letterpaper]{article}\n\\usepackage{graphicx}\n\\usepackage{amsfonts,amsmath,amssymb}\n\\usepackage{natbib}\n\\usepackage{url}\n\\usepackage{hyperref}\n\\hypersetup{colorlinks=false,pdfborder={0 0 0}}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\n%\\frenchspacing\n\\setlength{\\pdfpagewidth}{8.5in}\n\\setlength{\\pdfpageheight}{11in}\n\n%\\setcounter{secnumdepth}{0}\n\n\\newcommand{\\VT}{\\ensuremath{V_\\mathrm{T}}}\n\\newcommand{\\VTO}{\\ensuremath{V_\\mathrm{T0}}}\n\\newcommand{\\VTm}{\\ensuremath{V_\\mathrm{T}^-}}\n\\newcommand{\\VTp}{\\ensuremath{V_\\mathrm{T}^+}}\n\\newcommand{\\VDD}{\\ensuremath{V_\\mathrm{DD}}}\n\\newcommand{\\Vth}{\\ensuremath{V_\\mathrm{th}}}\n\\newcommand{\\VGS}{\\ensuremath{V_\\mathrm{GS}}}\n\\newcommand{\\VGSi}{\\ensuremath{V_\\mathrm{GSi}}}\n\\newcommand{\\VDS}{\\ensuremath{V_\\mathrm{DS}}}\n\\newcommand{\\VDSi}{\\ensuremath{V_\\mathrm{DSi}}}\n\\newcommand{\\VMIT}{\\ensuremath{V_\\mathrm{MIT}}}\n\\newcommand{\\VIMT}{\\ensuremath{V_\\mathrm{IMT}}}\n\\newcommand{\\Vmet}{\\ensuremath{V_\\mathrm{met}}}\n\\newcommand{\\vmet}{\\ensuremath{v_\\mathrm{met}}}\n\n\\newcommand{\\Cinv}{\\ensuremath{C_\\mathrm{inv}}}\n\n\\newcommand{\\ID}{\\ensuremath{I_\\mathrm{D}}}\n\\newcommand{\\IOFF }{\\ensuremath{I_\\mathrm{OFF}}}\n\\newcommand{\\ION}{\\ensuremath{I_\\mathrm{ON}}}\n\\newcommand{\\IMIT}{\\ensuremath{I_\\mathrm{MIT}}}\n\\newcommand{\\IIMT}{\\ensuremath{I_\\mathrm{IMT}}}\n\n\\newcommand{\\Rins}{\\ensuremath{R_\\mathrm{ins}}}\n\\newcommand{\\Rmet}{\\ensuremath{R_\\mathrm{met}}}\n\\newcommand{\\Rinsp}{\\ensuremath{R_\\mathrm{ins}'}}\n\\newcommand{\\Rmetp}{\\ensuremath{R_\\mathrm{met}'}}\n\n\\newcommand{\\pins}{\\ensuremath{\\rho_\\mathrm{ins}}}\n\\newcommand{\\pmet}{\\ensuremath{\\rho_\\mathrm{met}}}\n\\newcommand{\\pinsp}{\\ensuremath{\\rho_\\mathrm{ins}'}}\n\\newcommand{\\pmetp}{\\ensuremath{\\rho_\\mathrm{met}'}}\n\n\n\n\\begin{document}\n\n\\title{The Design of HyperFETs}\n\\author{Sam Bader, Debdeep Jena}\n\\author{Sam Bader$^1$, Debdeep Jena$^{2,3}$\\\\ $^1$Cornell University, Applied and Engineering Physics\\\\$^2$Cornell University, Electrical and Computer Engineering\\\\$^3$Cornell University, Materials Science and Engineering }\n\n\n\\maketitle\n\n\n\\section{Model}\n\\subsection{Transistor}\nThe transistor is modeled generically by a heavily simplified virtual-source (short-channel) MOSFET model \\cite{Khakifirooz_2009}.  Although this model was first defined for Silicon transistors, it has been successfully adapted to numerous other contexts, including Graphene \\cite{Han_Wang_2011} and Gallium Nitride devices, both HEMTs \\cite{RadhakrishnaThesis} and MOSHEMT+VO$_2$ HyperFETs \\cite{Verma_2017}.  Following Khakifirooz \\cite{Khakifirooz_2009}, the drain current $\\ID$ is expressed\n\\begin{equation}\n\\frac{\\ID}{W}=Q_{ix_0}v_{x_0}F_s\n\\end{equation}\nwhere $Q_{iz_0}$ is the charge at the virtual source point, $v_{x_0}$ is the virtual source saturation velocity, and $F_s$ is an empirically fitted ``saturation function'' which smoothly transitions between linear ($F_s\\propto V_{DS}/V_{DSSAT}$) and saturation ($F_s\\approx 1$) regimes.  The charge in the channel is described via the following semi-empirical form first proposed for CMOS-VLSI modeling \\cite{Wright_1985} and employed frequently since (often with modifications, eg \\cite{Khakifirooz_2009, RadhakrishnaThesis}):\n\\begin{equation}\nQ_{ix_0}=C_\\mathrm{inv}nV_\\mathrm{th}\\ln\\left[1+\\exp\\left\\{\\frac{\\VGSi-\\VT}{nV_\\mathrm{th}}\\right\\}\\right]\n\\end{equation}\nwhere $C_\\mathrm{inv}$ is an effective inversion capacitance for the gate, $n\\Vth \\ln10$ is the subthreshold swing of the transistor, $\\VGS$ is the transistor gate-to-source voltage, $\\VT$ is the threshold voltage, and $V_\\mathrm{th}$ is the thermal voltage $kT/q$.\n\nFor precise modeling, Khakifirooz includes further adjustments of $\\VT$ due to the drain voltage (DIBL parameter $\\delta$) and the gate voltage (strong vs weak inversion shift), \n\\begin{equation}\n  \\VT=\\VTO-\\delta \\VDSi-\\alpha \\Vth F_f(\\VGSi)\n  \\label{eq:DIBL}\n\\end{equation}\nwhere $\\delta$ is the DIBL parameter, and $F_f$ is a smoothing function which goes from 1 below \\VT\\ to 0 above \\VT.  We will not employ any specific form of $F_f$ for analytic work.  Futher, we will  assume the supply voltage is maintained above the gate overdrive such that $F_s\\approx 1$. However, we will add on a leakage floor with conductance $G_\\mathrm{leak}$.  Altogether, the final current expression (for the analytical part of this analysis) is\n\\begin{equation}\n\\frac{\\ID}{W}=nv_{x_0}C_\\mathrm{inv}\\Vth \\ln\\left[1+\\exp\\left\\{\\frac{\\VGSi-\\VT}{n\\Vth }\\right\\}\\right]+\\frac{G_\\mathrm{leak}}{W}V_\\mathrm{DSi}\\label{eq:transistor_iv}\n\\end{equation}\nAnd we will often use the shorthands\n\\begin{equation}\n  \\VTm=\\VTO-\\delta\\VDS-\\alpha\\Vth, \\quad\n  \\VTp=\\VTO-\\delta\\VDS, \\quad\n  k=v_{x_0}C_\\mathrm{inv}W\n  \\label{eq:short}\n\\end{equation}\nfor the deep-subthreshold threshold voltage at $\\VDSi=\\VDD$, the inversion threshold voltage at $\\VDSi=\\VDD$, and the inversion transconductivity respectively.\n\\subsection{Phase-change resistor}\n\\label{ss:PCR}\nThe phase-change material is included by a similarly generic and brutally simple model.  As done with the transistor, the goal is to capture only the most relevant feature: here, an abrupt change in resistance.  However, for a concrete example, the material most frequently used in HyperFET research \\cite{Pergament_2013,Shukla_2015} is Vanadium Dioxide (VO$_2$), which features an S-style (ie current-controlled) and hysteretic negative differential resistance (NDR) region \\cite{Pergament_arxiv2016,Zimmers_2013} due to an insulator-metal transition (IMT), the underlying mechanism of which has been a source of long-running controversy \\cite{Pergament_2013}.  Though the literature contains numerous examples of voltage-swept I-V curves \\cite{Shukla_2015,Zimmers_2013,Radu_2015,Yoon_2014}, proper modeling of a current-controlled NDR device in a circuit requires a current-swept I-V, examples of which can be found in \\cite{Zimmers_2013,Kumar_2013,Pergament_arxiv2016} and schematically in the supplementary materials of \\cite{Shukla_2015}.  The cleanest of these is Figure 1(b) of Kumar \\cite{Kumar_2013}, which is suggested to the reader as a concrete realization of the model used herein.\n\nThe phase-change resistor (PCR) will be described by a piecewise-linear model:\n\\begin{equation}\nV_R=\\left\\{\\begin{array}{llr}\nI_R\\Rins &, & I_R < \\IIMT \\\\\nV_\\mathrm{met}+I_R\\Rmet &, & I_R > \\IMIT \\\\\n\\end{array}\\right\\}\n\\label{eq:PCR_iv}\n\\end{equation}\nNote that $\\IMIT <\\IIMT $ (as in \\cite{Kumar_2013}) implies hysteresis in the PCR itself, while $\\IMIT >\\IIMT $ implies a disallowed current range and can lead to oscillation as discussed in the supplementary materials of \\cite{Shukla_2015}.  For convenience, we define voltage thresholds, $V_\\mathrm{IMT}=\\IIMT \\Rins $ and $V_\\mathrm{MIT}=\\IMIT \\Rmet +V_\\mathrm{met}$.  Finally, we require $V_\\mathrm{met}+\\IIMT \\Rmet <V_\\mathrm{IMT}$ and $\\IMIT \\Rins >V_\\mathrm{MIT}$ to ensure that the absolute resistance of the metallic state is lower than that of the insulating state wherever they are both defined.\n\n\\section{HyperFET Regimes}\nWhen the PCR is attached in series with the source of the transistor, the total device satisfies the above equations with the additional matching $I=\\ID=I_R$ and $\\VGS=V_{GS}-V_R$ where $I$ is the current through the device and $V_{GS}$ is the voltage between HyperFET gate (the transistor gate) and the HyperFET source (the exterior node of the resistor).  We can immediately solve for several regions of the HyperFET model.  For this section, it is assumed that the transistor and PCR are scaled such that the left end of the hysteretic region and the lower branch are entirely contained within subthreshold, and above the leakage floor; these choices will be discussed in the next section.\n\n\\subsection{Leakage floor}\nWhen the transistor is completely off, only the leakage term of \\eqref{eq:transistor_iv} remains, and combines with the PCR off-state resistance, leading to\n\\begin{equation}\nI=G_\\mathrm{off}V_{DS},\\quad G_\\mathrm{off}^{-1}=\\Rins +1/G_\\mathrm{leak}\n\\end{equation}\n\\subsection{Insulating (lower) branch of hysteretic region}\nFor the lower branch (in the region above the leakage floor), we plug $\\VGSi=V_\\mathrm{GS}-I\\Rins $ and $V_\\mathrm{DSi}=V_\\mathrm{DS}-I\\Rins $ into the transistor I-V \\eqref{eq:transistor_iv}, and take the subthreshold limit: $\\ln(1+e^x)\\approx e^x$ for $-x \\gg 1$.\n\\begin{equation}\n  \\frac{I}{W}=nC_\\mathrm{inv}v_{x_0}\\Vth\\exp\\left\\{\\frac{V_\\mathrm{GS}-I\\Rinsp -\\VTm}{n\\Vth }\\right\\} + \\frac{G_\\mathrm{leak}}{W}(V_\\mathrm{DS}-I\\Rins )\n\\label{eq:insbranch_preW}\n\\end{equation}\nwhere $\\Rinsp=(1+\\delta)\\Rins$.\nThis can be rearranged and solved in terms of the Lambert $\\mathcal{W}$ function\n\\begin{equation}\n  I=\\frac{n\\Vth }{\\Rinsp }\\mathcal{W}\\left[\\frac{k\\Rins' }{1+G_\\mathrm{leak}\\Rins }\\exp\\left\\{\\frac{V_\\mathrm{GS}-\\VTm-\\frac{G_\\mathrm{leak} V_\\mathrm{DS}\\Rins }{(1+G_\\mathrm{leak}\\Rins )W}}{n\\Vth}\\right\\}\\right]+\\frac{G_\\mathrm{leak}V_\\mathrm{DS}}{1+G_\\mathrm{leak}\\Rins }\n\\label{eq:insbranch_wleak}\n\\end{equation}\nIf $I$ is well above the leakage floor, this reduces to\n\\begin{equation}\nI=\\frac{n\\Vth }{\\Rins'}\\mathcal{W}\\left[k\\Rins'\\exp\\left\\{\\frac{V_\\mathrm{GS}-\\VTm}{n\\Vth}\\right\\}\\right]\n\\label{eq:insbranch}\n\\end{equation}\n\\subsection{Metallic (upper) branch of the hysteretic region}\nFor the upper branch (in deep subthreshold), we follow the same procedure to find\n\\begin{equation}\n  I=\\frac{n\\Vth }{\\Rmetp}\\mathcal{W}\\left[k\\Rmetp \\exp\\left\\{\\frac{V_\\mathrm{GS}-\\VTm-\\Vmet}{n\\Vth }\\right\\}\\right]\n\\label{eq:metbranch}\n\\end{equation}\nwhere $\\Rmetp=(1+\\delta)\\Rmet$.\n%Note that if the metal-state resistance is small and we are in subthreshold $I\\Rmet \\ll n\\Vth $, we approximate\n%\\begin{equation}\n%\\frac{I}{W}\\approx n\\Vth C_\\mathrm{inv}v_{x_0}\\exp\\left\\{\\frac{V_\\mathrm{GS}-V_\\mathrm{met}-\\VT}{n\\Vth }\\right\\}\n%\\label{eq:met_smallR}\n%\\end{equation}\n\\subsection{Strong inversion}\nAgain we plug $\\VGSi=V_\\mathrm{GS}-V_\\mathrm{met}-I\\Rmet $ into the transistor I-V \\eqref{eq:transistor_iv}, but this time, we take the strong inversion limit $\\ln(1+e^x)\\approx x$ for $x\\gg 1$.\n\\begin{equation}\n  \\frac{I}{W}=v_{x_0}C_\\mathrm{inv}(V_\\mathrm{GS}-V_\\mathrm{met}-I\\Rmetp -\\VTp)\n  \\label{eq:Isat_pre}\n\\end{equation}\nwhich gives\n\\begin{equation}\n  I=\\frac{k}{1+k\\Rmetp}(V_\\mathrm{GS}-V_\\mathrm{met}-\\VTp)\n  \\label{eq:Isat}\n\\end{equation}\n\n\\subsection{Voltage boundaries of the hysteretic region}\nThe leftmost point of the upper branch is defined by the minimum current below which no metallic-state solution can exist: $I=\\IMIT $.  By \\eqref{eq:PCR_iv}, $V_\\mathrm{R}=V_\\mathrm{MIT}$.  Plugging this point into \\eqref{eq:transistor_iv} and solving yields\n\\begin{equation}\nV_\\mathrm{left}-\\VT=V_\\mathrm{MIT}+n\\Vth \\ln\\left[\\exp\\left\\{\\frac{\\IMIT }{nk\\Vth }\\right\\}-1\\right]\n\\end{equation}\nWe have not yet made an assumption of subthreshold in the above equation, but if we do, we arrive at\n\\begin{equation}\nV_\\mathrm{left}-\\VTm\\approx (1+\\delta)V_\\mathrm{MIT}-n\\Vth \\ln\\left[\\frac{nk\\Vth }{\\IMIT }\\right]\n\\label{eq:Vleft_sub}\n\\end{equation}\nSince $V_\\mathrm{left}$ may or may not be near $\\VT$ depending on the parameters of the devices in question, we will take one self-consistent adjustment to account for strong/weak inversion shift\n\\begin{equation}\n  V_\\mathrm{left}\\rightarrow V_\\mathrm{left}+\\alpha\\Vth \\left[1-F_f\\right]_{\\VDSi=\\VDD-\\VMIT, \\VGSi=V_\\mathrm{left}-\\VMIT}\n\\label{eq:Vleft_sub2}\n\\end{equation}\nIf $V_\\mathrm{left}$ is far below $\\VT$, then this does nothing, but as $V_\\mathrm{left}$ approaches threshold, this shifts the left side rightward on the order of $\\alpha\\Vth$.\n\nThe rightmost point of the upper branch is defined by the maximum current beyond which no insulating state solution can exist: $I=\\IIMT $.  By definition then, $V_\\mathrm{R}=V_\\mathrm{IMT}$.  Plugging this point in\n\\begin{equation}\nV_\\mathrm{right}-\\VT=V_\\mathrm{IMT}+n\\Vth \\ln\\left[\\exp\\left\\{\\frac{\\IIMT }{nk\\Vth }\\right\\}-1\\right]\n\\end{equation}\nwhere again, we have delayed the assumption of subthreshold until this point:\n\\begin{equation}\nV_\\mathrm{right}-\\VTm\\approx (1+\\delta)V_\\mathrm{IMT}-n\\Vth \\ln\\left[\\frac{nk\\Vth }{\\IIMT }\\right]\n\\label{eq:Vright_sub}\n\\end{equation}\nNote that $V_\\mathrm{right}$ depends only on the properties of the insulating branch, so even if the top right corner of the hysteresis loop is in strong inversion, this expression may still be entirely valid because the lower branch is likely in subthreshold.\nEquations \\ref{eq:Vleft_sub} and \\eqref{eq:Vright_sub} can be combined into a simple form (ignoring the $\\alpha$ shift):\n\\begin{equation}\n  V_\\mathrm{hyst}=V_\\mathrm{right}-V_\\mathrm{left}=(1+\\delta)(V_\\mathrm{IMT}-V_\\mathrm{MIT})+n\\Vth \\log\\frac{\\IIMT }{\\IMIT }\n  \\label{eq:Vhyst_sub}\n\\end{equation}\nAssuming the voltage scale of the PCR is sufficiently larger than thermal voltage, this reduces to\n\\begin{equation}\n  V_\\mathrm{hyst}\\approx (1+\\delta)(V_\\mathrm{IMT}-V_\\mathrm{MIT})\n  \\label{eq:Vhyst_simple}\n\\end{equation}\nNote that it is formally possible for \\eqref{eq:Vhyst_sub} to become negative, ie $V_\\mathrm{left}>V_\\mathrm{right}$. Examining the definitions of $V_\\mathrm{left}$ and $V_\\mathrm{right}$, this implies that, in such circumstances, the range between the two will contain no valid solution, ie it will be unstable (oscillatory) rather than bistable (hysteretic).  See the supplementary materials of \\cite{Shukla_2015} for a discussion of this behavior in the context of resistors only.\n\n\\subsection{Current boundaries of the hysteresis}\nThe current at the left boundary of the metallic branch is at $I_\\mathrm{left, met}=\\IMIT $.  Now plugging  the subthreshold expression for the left boundary \\eqref{eq:Vleft_sub} into the expression for the insulating branch \\eqref{eq:insbranch}, we can get an expression for the current at the same point on the insulating branch:\n\\begin{equation}\nI_\\mathrm{left,ins}=\\frac{n\\Vth }{\\Rinsp}\\mathcal{W}\\left[\\frac{\\IMIT \\Rinsp}{n\\Vth }\\exp\\left\\{\\frac{V_\\mathrm{MIT}}{n\\Vth }\\right\\}\\right]\n\\label{eq:Ileftins}\n\\end{equation}\nAnd note that the inequality $\\IMIT \\Rins >V_\\mathrm{MIT}$ we demanded in Sec \\ref{ss:PCR} ensures that the current on the insulating branch at the boundary is strictly lower, so there will be a discontinuous jump:\n\\begin{equation}\nI_\\mathrm{left, ins}<\\frac{n\\Vth }{\\Rinsp}\\mathcal{W}\\left[\\frac{\\IMIT \\Rinsp}{n\\Vth }\\exp\\left\\{\\frac{\\IMIT \\Rinsp }{n\\Vth }\\right\\}\\right]=\\IMIT \n  \\label{eq:leftjump}\n\\end{equation}\nThe current at the right boundary of the insulating branch is $I_\\mathrm{right, ins}=\\IIMT $.  Now plugging the the subthreshold expression for the right boundary \\eqref{eq:Vright_sub} into the expression of the metallic branch \\eqref{eq:metbranch}, we can get an expression for the current at the same point on the metallic branch:\n\\begin{equation}\n  I_\\mathrm{right,met}=\\frac{n\\Vth }{\\Rmetp}\\mathcal{W}\\left[\\frac{\\IIMT \\Rmetp}{n\\Vth }\\exp\\left\\{\\frac{V_\\mathrm{IMT}-V_\\mathrm{met}}{n\\Vth }\\right\\}\\right]\n\\label{eq:Irightmet}\n\\end{equation}\nAnd note that the inequality $V_\\mathrm{met}+\\IIMT\\Rmet <V_\\mathrm{IMT}$ we demanded in Sec \\ref{ss:PCR} ensures that the current on the metallic branch at the boundary is strictly higher, so there will be a discontinuous jump:\n  (NOTE this paragraph is technically not true any more; once I include DIBL, the requirements are slightly higher\\dots I need that to hold for $\\Rmetp$, not just $\\Rmet$, but small difference\\dots)\n\\begin{equation}\n  I_\\mathrm{right,met}>\\frac{n\\Vth }{\\Rmet }\\mathcal{W}\\left[\\frac{\\IIMT \\Rmet }{n\\Vth }\\exp\\left\\{\\frac{\\IIMT \\Rmet }{n\\Vth }\\right\\}\\right]=\\IIMT \n  \\label{eq:rightjump}\n\\end{equation}\n%\\section{Super-Boltzmann behavior}\n%As evidenced by \\eqref{eq:leftjump} and \\eqref{eq:rightjump}, there are two points of discontinuity.  A $V_\\mathrm{GS}$ sweep from OFF to ON may then move continuously along the insulating branch, but then will have to jump up to the metallic branch at the right end of the hysteresis.  Conversely, a $V_\\mathrm{GS}$ sweep from ON to OFF may move continuously along the metallic branch, but then will have to jump down to the insulating branch at the left end of the hysteresis.  At these two localized points, the current changes a finite amount over an infinitesimally small voltage difference, surpassing the drift-diffusion (``Boltzmann'') limit of $\\frac{dV}{d \\log I} >\\frac{kT}{q}$\n%How do these local violations of the Boltzmann limit at the hysteretic boundaries connect to the useful, global steepness of the I-V curve, as measured outside hysteresis?\n%\n%\\subsection{Immediate steepness}\n%Immediately to the left of the hysteresis, the current is $I_\\mathrm{left,ins}$, and immediately to the right, the current is $I_\\mathrm{right, met}$, which, from expressions \\eqref{eq:Ileftins}, \\eqref{eq:Irightmet} gives a log-ratio of currents\n%\n%\n%\\begin{equation}\n%  \\log{\\frac{I_\\mathrm{right}}{I_\\mathrm{left}}}=\\log\\frac{\\Rins }{\\Rmet }+\\log\\frac{\\mathcal{W}\\left[\\frac{\\IIMT \\Rmet }{n\\Vth }\\exp\\left\\{\\frac{V_\\mathrm{IMT}-V_\\mathrm{met}}{n\\Vth }\\right\\}\\right]}{\\mathcal{W}\\left[\\frac{\\IMIT \\Rins }{n\\Vth }\\exp\\left\\{\\frac{V_\\mathrm{MIT}}{n\\Vth }\\right\\}\\right]}\n%\\label{eq:logI_sub}\n%\\end{equation}\n%\n%Inverting the $\\mathcal{W}$'s in \\eqref{eq:Ileftins}, \\eqref{eq:Irightmet} allows us to rewrite this in a suggestive form:\n%\\begin{align}\n%  V_\\mathrm{hyst}&=n\\Vth \\ln\\left[ \\frac{I_\\mathrm{right}}{I_\\mathrm{left}} \\right]-I_\\mathrm{left}\\Rins +I_\\mathrm{right}\\Rmet +V_\\mathrm{met}\\\\\n%  &=n\\Vth \\ln\\left[ \\frac{I_\\mathrm{right}}{I_\\mathrm{left}} \\right]-V_\\mathrm{PCR, left}+V_\\mathrm{PCR, right}\n%  \\label{}\n%\\end{align}\n%where $V_\\mathrm{PCR}$ indicates the voltage across the PCR at the left or right hysteresis boundary.  The first term is the intrinsic swing of the transistor.  So the condition for the PCR improving the transistor swing is that more voltage is dropped on the PCR in the insulating state at the left of the hysteresis than dropped there in the metallic state at the right side.\n%\n%Put another way, we can define a unitless ``loaded subthreshold steepness''\n%\\begin{equation}\n%  \\Sigma_n=\\Vth \\frac{\\log{\\frac{I_\\mathrm{right}}{I_\\mathrm{left}}}}{V_\\mathrm{hyst}}\n%  \\label{eq:sigman}\n%\\end{equation}\n%The PCR improves the subthreshold swing of the transistor (in the immediate vicinity of the hysteresis) if $\\Sigma_n> 1/n$, and enables super-Boltzmann switching if $\\Sigma_n>1$.  \n%\n%Furthermore, we note that \\eqref{eq:logI_sub} and \\eqref{eq:Vhyst_sub} are independent of all the transistor properties except $n$ (because we've assumed the hysteresis occurs within subthreshold).  So setting $n=1$, we can consider $\\Sigma_1$, the ``unloaded steepness'', as a transistor-independent figure of merit for a PCR which expresses its ability to enable super-Boltzmann switching in a HyperFET configuration.\n%\\subsection{Adjacent steepness}\n%Taking the log and differentiating both sides of Eq \\eqref{eq:insbranch_preW}, we find the slope of the insulating branch:\n%\\begin{equation}\n%  \\left.\\frac{d\\log I}{dV_\\mathrm{GS}}\\right|_\\mathrm{ins}=\\frac{1}{nV_\\mathrm{th}}\\frac{1}{1+(I\\Rins /n\\Vth )}\n%  \\label{eq:steep_ins}\n%\\end{equation}\n%Similarly, the slope of the metallic branch is\n%\\begin{equation}\n%  \\left.\\frac{d\\log I}{dV_\\mathrm{GS}}\\right|_\\mathrm{met}=\\frac{1}{nV_\\mathrm{th}}\\frac{1}{1+(I\\Rmet /n\\Vth )}\n%  \\label{eq:steep_met}\n%\\end{equation}\n%Note that the quantity in parentheses in \\eqref{eq:steep_ins} is $V_\\mathrm{PCR}$ and the same in \\eqref{eq:steep_met} is $V_\\mathrm{PCR}-V_\\mathrm{met}$.  As discussed in the previous section, for a useful PCR, $V_\\mathrm{PCR, right}<V_\\mathrm{PCR, left}$, so it's reasonable to expect, for an optimal PCR design, that the region immediately to the right of the hysteresis will be steeper than that to the left.\n%\n%\n\\section{Shifted comparison}\nThe addition of a PCR reduces both the on- and off- current of a transistor, so in demonstrating the premise of the HyperFET, Shukla et al \\cite{Shukla_2015} use a procedure of shifting the threshold voltage of a HyperFET to re-equalize the off-currents.  Since the off-current will be exponentially suppresed by a shift while the on-current (in inversion) will change linearly, this can, under reasonable circumstances, result in a large increase in the on-current at constant off-current.  The entire procedure can be performed analytically within this model, shedding light on precisely when a PCR is able to improve a transistor.  \n\n\\subsection{The shift}\nTo this end, we imagine a transistor $\\mathcal{T}$ with threshold voltage $\\VTO$ is reengineered to an identical transistor $\\mathcal{T'}$ with threshold $\\VTO'=\\VTO-\\Delta \\VTO$, and then combined with a PCR to form a HyperFET with the same off-current $\\IOFF $ as the original transistor.  This condition is expressed by\n\\begin{align}\n  \\IOFF &=\\frac{n V_\\mathrm{th}}{\\Rinsp}\\mathcal{W}\\left[ k\\Rinsp\\exp\\left\\{ \\frac{-V_\\mathrm{T}'^{-}}{n\\Vth} \\right\\} \\right]\\\\\n  &=\\frac{n V_\\mathrm{th}}{\\Rinsp}\\mathcal{W}\\left[ \\frac{\\IOFF \\Rinsp}{n\\Vth}\\exp\\left\\{ \\frac{\\Delta \\VTO}{n\\Vth} \\right\\} \\right]\n  \\label{}\n\\end{align}\nwhere the first equality follows from the HyperFET current equations \\eqref{eq:insbranch} and the second follows from plugging in the normal transistor current equation \\eqref{eq:transistor_iv} in the subthreshold limit.  This is easily inverted to yield\n\\begin{equation}\n  \\Delta \\VTO=\\IOFF \\Rinsp \n  \\label{eq:shift}\n\\end{equation}\n\\subsection{Shifting gain}\nThis shift increases the on-current at constant $V_\\mathrm{DD}$.  Plugging \\eqref{eq:shift} into the strong inversion expression, we find the new HyperFET on-current \n\\begin{equation}\n  \\ION'=\\frac{k}{1+k\\Rmetp }\\left( V_\\mathrm{DD}-\\VTp+\\IOFF \\Rinsp -V_\\mathrm{met} \\right)\n  \\label{eq:shiftedon}\n\\end{equation}\nThe ratio of the HyperFET on-current to the original transistor on-current, ie the ``shifting gain'', is then\n\\begin{equation}\n  \\frac{\\ION'}{\\ION}=\\frac{1+\\left( \\IOFF \\Rinsp -V_\\mathrm{met}\\right)/(V_\\mathrm{DD}-\\VTp )}{1+k\\Rmetp }\n  \\label{eq:Ion_rat}\n\\end{equation}\nSo we find that the PCR enables an increased on-current if\n\\begin{equation}\n  \\IOFF \\Rinsp -V_\\mathrm{met} >\\ION\\Rmetp\n  \\label{eq:inconcond}\n\\end{equation}\nNamely, the voltage across the PCR in ON-state is smaller than that in the OFF state.  Setting \\Vmet\\ to zero for a moment, this condition becomes the simple statement that the insulator/metal resitance ratio of the PCR must be larger than the desired HyperFET \\ION/\\IOFF ratio in order to be useful.  For example, HyperFETs have been demonstrated in conjunction with GaN HEMTs, but despite that GaN HEMTs can easily achieve a dozen orders of ON-OFF ratio, making a HyperFET from one will necessarily involve limiting the ON-OFF to the PCR resistivity ratio (at most five orders).\n\n(Note: The above discussion does assume that $\\IOFF <I_\\mathrm{left}$.)\n\\subsection{Shifting supply reduction}\nWhereas the above subsection held $\\IOFF $ and $V_\\mathrm{DD}$ constant and noted the increase in $\\ION$, one could alternatively hold $\\IOFF $ and $\\ION$ constant, and allow $V_\\mathrm{DD}$ to change.  Comparing \\eqref{eq:shiftedon} to to the strong inversion expression, we find that holding $\\ION$ constant requires the supply voltage to change to\n\\begin{equation}\n  V_\\mathrm{DD}'-\\VTp=(V_\\mathrm{DD}-\\VTp)(1+k\\Rmetp)+V_\\mathrm{met}-\\IOFF \\Rinsp \n  \\label{eq:shiftedVDD}\n\\end{equation}\nie\n\\begin{equation}\n  \\Delta V_\\mathrm{DD}'=(V_\\mathrm{DD}-\\VTp)(k\\Rmetp)+V_\\mathrm{met}-\\IOFF \\Rinsp \n  \\label{eq:VDDshift}\n\\end{equation}\nThe conditions for this shift to be useful (ie negative) are the same as in the previous subsection.\n\n\n\n\\section{Optimization}\nTaking the expression for the shifting gain \\eqref{eq:Ion_rat}, we can refine the region in the PCR parameter space best suited to a HyperFET.  We will assume that the various current parameters scale proportional to the PCR cross-sectional area $wt$ (ie $I_\\mathrm{IMT, MIT}= w t J_\\mathrm{IMT, MIT})$, and the various voltages scale proportional to the PCR length $l$ (ie $V_\\mathrm{IMT}=lJ_\\mathrm{IMT}\\pins$, $V_\\mathrm{met}=lv_\\mathrm{met}$, $V_\\mathrm{MIT}=lJ_\\mathrm{MIT}\\pmet+l\\vmet$).\n\nWith these definitions, we now consider the shifted gain as a function of $l$; it takes the form $(A_1+B_1l)/(C_1+D_1l)$.  Similarly, we could consider the shifted gain as a function of $\\frac{1}{wt}$, and we find it takes the form $(A_2+\\frac{B_2}{wt})/(C_2+\\frac{D_2}{wt})$.  The derivative $\\frac{d}{dx}\\left[(A+Bx)/(C+Dx)\\right]=(BC-DA)/(C+Dx)^2$ is monotonic with sign given by $BC-DA$.  In the cases of $l$ and $wt$, these signs are\n\\begin{equation}\n  \\frac{\\partial \\ION'}{\\partial l}\\propto\\IOFF\\Rinsp-\\ION\\Rmetp-\\Vmet\n  \\label{eq:lderiv}\n\\end{equation}\n\\begin{equation}\n  \\frac{\\partial \\ION'}{\\partial \\frac{1}{wt}}\\propto\\IOFF\\Rinsp-\\ION\\Rmetp-\\Vmet+(1+k\\Rmetp)\\Vmet\n  \\label{eq:1wtderiv}\n\\end{equation}\nBy \\eqref{eq:inconcond} and \\eqref{eq:lderiv}, we know that, if we are in a regime where the HyperFET is useful, then we can always improve it \\ION\\ further by increasing $l$.  By \\eqref{eq:inconcond} and \\eqref{eq:1wtderiv}, we see that shrinking $wt$ will always improve \\ION, unless \\vmet\\ is signficantly large and negative, in which case increasing $wt$ will always improve \\ION.\n\nSince $l$ should always be larger and $wt$ should always be smaller, it's clear that the optimal parameters will always lie along a problem boundary set by some other constraint.  The most obvious constraint is that the boundaries of the HyperFET transfer curve at $\\VGS=0$ and $\\VGS=\\VDD$ should be hysteresis-free for a practical logic device.  In this regard, increasing $l$ increases the right voltage boundary of the hysteresis, and decreasing $wt$ lowers the left current of the hysteresis.  So the trade-off is, broadly, larger hysteresis for the larger \\ION.  Given this, it is reasonable to estimate the scale of the optimal $l$ and $wt$ by the extremizing until the hysteresis nears the left and right limits of device operation.\n\nThe left current boundary \\eqref{eq:Ileftins} can be reexpressed\n\\begin{equation}\n  I_\\mathrm{left, ins}=\\frac{wtn\\Vth}{l\\pinsp}\\mathcal{W}\\left[ \\frac{lJ_\\mathrm{MIT}\\pinsp}{n\\Vth}\\exp\\left\\{ \\frac{lJ_\\mathrm{MIT}\\pmet+l\\vmet}{n\\Vth} \\right\\} \\right]\n  \\label{eq:Ill_geom}\n\\end{equation}\nso the condition of maximal hysteresis gives\n\\begin{equation}\n  \\frac{1}{wt}=\\frac{n\\Vth}{l\\pinsp\\IOFF}\\mathcal{W}\\left[ \\frac{lJ_\\mathrm{MIT}\\pinsp}{n\\Vth}\\exp\\left\\{ \\frac{lJ_\\mathrm{MIT}\\pmet+l\\vmet}{n\\Vth} \\right\\} \\right]\n  \\label{eq:Ill_geom_ext}\n\\end{equation}\nand the right boundary (after being shifted) can be expressed\n\\begin{equation}\n  V_\\mathrm{right}-\\VTm=J_\\mathrm{IMT}\\pinsp l-n\\Vth \\ln\\left[ \\frac{nk\\Vth}{wtJ_\\mathrm{IMT}} \\right]-\\IOFF \\frac{l\\pinsp }{wt}\n  \\label{eq:Vright_geom}\n\\end{equation}\nso the condition of maximal hysteresis gives\n\\begin{equation}\n  V_\\mathrm{DD}-\\VTm=J_\\mathrm{IMT}\\pinsp l-n\\Vth \\ln\\left[ \\frac{nk\\Vth}{wtJ_\\mathrm{IMT}} \\right]-\\IOFF \\frac{l\\pinsp }{wt}\n  \\label{eq:Vright_geom_ext}\n\\end{equation}\nPlugging in \\eqref{eq:Ill_geom} and making use of the identity $\\ln\\mathcal{W}(z)=\\ln z- \\mathcal{W}(z)$ results in a cancelation of both the Lambert terms\n\\begin{multline*}\n  V_\\mathrm{DD}-\\VTm=J_\\mathrm{IMT}\\pinsp l-n\\Vth \\ln\\left[ \\frac{k(n\\Vth)^2}{l\\pinsp \\IOFF J_\\mathrm{IMT}} \\right]\\\\\n  -n\\Vth\\ln\\left[ \\frac{lJ_\\mathrm{MIT}\\pinsp}{n\\Vth}\\exp\\left\\{ \\frac{lJ_\\mathrm{MIT}\\pmet+l\\vmet}{n\\Vth} \\right\\} \\right]\n\\end{multline*}\nwhich becomes\n\\begin{multline*}\n  V_\\mathrm{DD}-\\VTm=J_\\mathrm{IMT}\\pinsp l-n\\Vth \\ln\\left[ \\frac{kn\\Vth J_\\mathrm{MIT}}{ \\IOFF J_\\mathrm{IMT}} \\right]\n  -\\left( lJ_\\mathrm{MIT}\\pmet+l\\vmet \\right)\n\\end{multline*}\nand can be solved for $l$\n\\begin{equation}\n  l=\\frac{V_\\mathrm{DD}-\\VTm+n\\Vth \\ln\\left[ \\frac{kn\\Vth J_\\mathrm{MIT}}{ \\IOFF J_\\mathrm{IMT}} \\right]}{J_\\mathrm{IMT}\\pinsp - J_\\mathrm{MIT}\\pmet-\\vmet}\n  \\label{eq:lopt}\n\\end{equation}\nand this result can be plugged back into \\eqref{eq:Ill_geom_ext} so that the optimal geometry is obtained.\n\nThis derivation does have one (correctable) caveat: as $V_\\mathrm{right}$ pushes toward \\VDD, \\VIMT\\ is also moving toward \\VDD, and when \\VIMT\\ is within \\Vth\\ of \\VDD\\ or larger, the voltage across the transistor drain-source in the near-\\VDD\\ insulating branch reaches \\Vth\\ or lower and it becomes impossible to saturate the transistor, so the entire model, with its assumption of saturation (neglect of the $F_s$ factor) breaks down.  In fact, it should be clear that, once $\\VIMT>\\VDD$, there can be no $I\\rightarrow M$ jump (even though the formulas for $V_\\mathrm{right}$ continue to provide a finite location).  While this is a region unsatisfactorally handled by the model, it is also a terrible region in which to design the device: over a short range of variation in material geometry, the right boundary of hysteresis rapidly moves from some reasonable location potentially well below $\\VDD$ to entirely inaccessible.  So it makes sense to set a further constraint that $\\VIMT$ stays well below $\\VDD$ (numerical examination suggests $\\VIMT < \\VDD - \\Vth/2$ actually suffices).  This constraint is simple to express as\n\\begin{equation}\n  l=\\frac{\\VDD-\\Vth/2}{J_\\mathrm{IMT}\\pins}\n  \\label{eq:lmax}\n\\end{equation}\nThe proper $l$ to use is the minimum of those suggested by \\eqref{eq:lopt} and \\eqref{eq:lmax}.  Experience thus far suggests that \\eqref{eq:lmax} typically sets the minimum unless a very large safety margin $M_r$ (see below) is chosen.\n\nAs a practical concern of course, one may not wish to set the boundary of the hysteresis right at \\VDD\\ and 0, since these are the operating points.  It's easy to plug a safety margin into these formulas by replacing $\\VDD$ with $\\VDD-M_r\\Vth$ in \\eqref{eq:lopt}, where $M_r$ is a quantity of order unity chosen by the reliability engineer.  This does not change the exactness of the solution.  One could also, to reasonable approximation, multiply $wt$ by a safety factor $M_l+1$ (which increases $I_\\mathrm{left}$ by the same factor and $M_l$ is of order unity) and then plug back into \\eqref{eq:Vright_geom_ext} to resolve for $l$.  (In principle, this should process should be iterated to solve $l$ and $wt$ simultaneously, but at the precision of this discussion, one iteration is generally sufficient.)\n\n%\\section{Device considerations}\n%Given the above expressions, we now analyze the effect of the PCR on $V_\\mathrm{on}$ and $I_\\mathrm{on}/I_\\mathrm{off}$.  We begin with some basic observations of the HyperFET I-V and how they shape the design space for a steep-switching device.\n%\\begin{enumerate}\n%\\item In all of the above, $V_\\mathrm{GS}$ only ever appears in the combination $V_\\mathrm{GS}-\\VT$, so a device engineer can shift the entire I-V curve horizontally by threshold-engineering, just as in a conventional transistor.  Thus, we will assume, without loss of generality, that the HyperFET operates between 0V and $V_\\mathrm{ON}$, and this range (of width $V_\\mathrm{ON}$) can be shifted to any desired location on the HyperFET I-V curve.\n%\\item If the HyperFET is to operate as a conventional logic device (with enhanced steepness), then the $V_\\mathrm{OFF}=0\\mathrm{V}$ must be to the left of the hysteresis, and $V_\\mathrm{ON}$ must be to the right of the hysteresis.  For a given PCR, this requires a minimum $V_\\mathrm{ON}>V_\\mathrm{hyst}$.  From that minimum, $V_\\mathrm{ON}$ will be expanded to ensure sufficient $\\ION/\\IOFF $ ratio (unless this ratio is already satisfied at the boundaries of the hysteretic region).\n%\\item If it is necessary to expand $V_\\mathrm{ON}$ beyond $V_\\mathrm{hyst}$, it is preferable (if the devices can be scaled properly) to expand to the right.  The insulating branch to the left of hysteresis, with its swing $>nkT/q$ will either rejoin the original transistor IV or hit the leakage floor (and then continue at essentially a constant ratio versus the original transistor IV).  If $V_\\mathrm{OFF}$ is place\\ldots\n%  \n%  \n%%\n%%If the OFF point (0V) is too far from the \n%\\end{enumerate}\n%\n%\n%The procedure is essentially to choose a desired $I_\\mathrm{on}/I_\\mathrm{off}$, then find the minimum $V_\\mathrm{on}$ compatible with this choice, given a fixed PCR.  We will assume that the device engineer is free to manipulate the  $\\VT$ of the transistor, so that, effectively, the OFF point can be placed anywhere on the HyperFET I-V, and then the component devices are scaled.\n%\n%\n%sliding it left and right to choose where on the HyperFET I-V the OFF current ($V_\\mathrm{GS}=0$) on the as necessary to optimize the design.  Second, the device engineer may scale the transistor \n%\n%\n%We assume the component devices have been scaled with the optimization of these parameters in mind.\n%\n%Thoughts for the morning:\n%\n%(1) Defend why want hysteresis in subthreshold\n%    (a) To be able to climb toward right\n%    (b) Does shape of hysteresis change at lower values?\n%(2) Derive Von at fixed Ion/Ioff.  (width of hyst provided min Von, then grow at nVth*(Ion/Ioff- [Ion/Ioff]\\_hyst)\n%    (a) could probably get a better expression for [Von versus (Ion/Ioff)] or at least (Ion/Ioff)hyst by dividing Eq 6 and [the skipped equation leading to Eq 8].  That seems more likely to yield a good result than messing with W functions.\n%(3) Mention in intro: Boltzmann only violated at one VGS per branch.  This paper gives the connection between local violation and global properties of Ion/Ioff vs Von.\n%\n%(4) Compute with right-end in sat. Near-Threshold Computing: Reclaiming Moore's Law Through Energy Efficient Integrated Circuits\n%\n\\bibliography{biblio}{}\n\\bibliographystyle{plain}\n\n\n\\end{document}\n", "meta": {"hexsha": "251e87f0c18d4a9f4642c6349e4d0ab06ab57c99", "size": 33580, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "RawMathReference/The_Design_of_HyperFETs.tex", "max_stars_repo_name": "samueljamesbader/HyperFET_Project", "max_stars_repo_head_hexsha": "c9b7a870aa9c63f0bac76d3b9370ef4814acda0b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "RawMathReference/The_Design_of_HyperFETs.tex", "max_issues_repo_name": "samueljamesbader/HyperFET_Project", "max_issues_repo_head_hexsha": "c9b7a870aa9c63f0bac76d3b9370ef4814acda0b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RawMathReference/The_Design_of_HyperFETs.tex", "max_forks_repo_name": "samueljamesbader/HyperFET_Project", "max_forks_repo_head_hexsha": "c9b7a870aa9c63f0bac76d3b9370ef4814acda0b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.9024390244, "max_line_length": 1194, "alphanum_fraction": 0.7469029184, "num_tokens": 10437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.43656679262414994}}
{"text": "% Generated by GrindEQ Word-to-LaTeX 2008 \n% ========== UNREGISTERED! ========== Please register! ==========\n% LaTeX/AMS-LaTeX\n\n\\documentclass[a4paper]{article}\n\\usepackage{anysize}\n\\marginsize{1cm}{1cm}{1cm}{1cm}\n\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage[dvips]{graphicx}\n\\usepackage{listings}\n\\lstset{language=haskell}\n\\lstset{commentstyle=\\textit}\n\\lstset{mathescape=true}\n%\\lstset{labelstep=1}\n%\\lstset{backgroundcolor=,framerulecolor=}\n\\lstset{backgroundcolor=,rulecolor=}\n\\linespread{2.0}\n\n\\begin{document}\n\n\\noindent \n\\section{Subtyping Heaps and References}\n\n\\noindent Let us consider the types of the references of the example above, given $Heap\\ h_0\\ ref$ for some initial heap $h_0$ and some reference type$\\ ref$:\n\n\\begin{lstlisting}\ni : ref (New $h_0$ Int) Int\ns : ref (New (New $h_0$ Int) String) String\n\\end{lstlisting}\n\nThe heap $h_0$ is the starting heap at the beginning of the program. If the program is used as a ``main'', that is it is just launched, then $h_0$ will be an empty heap; in other cases, like using our computation inside another, larger computation, will mean that  $h_0$ will be the current heap that is available where the example is launched.\n\n\\noindent Now let us consider the two statements:\n\n\\begin{lstlisting}\nv $\\leftarrow$ s\nx $\\leftarrow$ i\n\\end{lstlisting}\n\nThese two are incompatible, since the first statement forces our monad to be of type $ref\\ \\left(New\\ \\left(New\\ h_0\\ Int\\right)\\ String\\right)$ and thus this type will have to be in all subsequent statements of the same monadic program, but the second statement expects our monad to be of type $ref\\ \\left(New\\ h_0\\ Int\\right)$. This is absolutely reasonable on the part of the type system, but it is quite unacceptable given our circumstances: why cannot we use a reference that refers to a smaller heap where we have a larger heap available? Indeed, all the values that reference $i$ requires are available (plus some more that are irrelevant to $i$) in the heap that we have when the reference $s$ is in scope. It would be interesting to make it possible to use a reference that requires a smaller (less defined) heap when a larger (more specified) heap is available. This kind of notion is clearly a notion of subtyping between heaps and references.\n\n\\noindent To define a subtyping relationship between heaps, let us start by giving a subtyping predicate:\n\n\\begin{lstlisting}\nSubtype $\\alpha$ $\\beta$\n\\end{lstlisting}\n\nWhich for brevity we will also write\n\n\\begin{lstlisting}\n$\\alpha$ $\\le$ $\\beta$\n\\end{lstlisting}\nThe fact that $\\alpha $ is a subtype of $\\beta $ implies that $\\alpha $ is more specified than $\\beta $, and as such it may be used in any context where a $\\beta $ is expected. For this reason we also give a casting (or coercion) function that converts from a value of type $\\alpha $ to a value of its supertype $\\beta $:\n\n\\begin{lstlisting}\ndowncast :$\\alpha$ $\\to$ $\\beta$\n\\end{lstlisting}\nWe also know that the subtyping relation is reflexive and transitive, so we will add these rules as instances of the subtyping predicate:\n\n\\begin{lstlisting}\nSubtype $\\alpha$ $\\alpha$ downcast=$\\lambda$ x.x\n\\end{lstlisting}\n\n\\begin{lstlisting}\nSubtype $\\alpha$ $\\beta$ $\\wedge$ Subtype $\\beta$ $\\gamma$ $\\Rightarrow$ Subtype $\\alpha$ $\\gamma$ downcast=downcast $\\circ$ downcast\n\\end{lstlisting}\n\nSince we are mostly interested in subtyping between references, when is it safe to downcast them? As already discussed, a first criterion for downcasting a reference is that the heap $h$ that the reference manipulates is actually smaller than the current heap; this means that:\n\n\\begin{lstlisting}\nHeap h ref $\\wedge$ Heap $h'$ ref $\\wedge$ $h'$ $\\le$ h $\\Rightarrow$ ref h $\\alpha$ $\\le$ ref $h'$ $\\alpha$\n\\end{lstlisting}\n\nThis means that references are contravariant with respect to their heap. Also, the second argument of references allows for the intuitive kind of conversion:\n\n\\begin{lstlisting}\n$\\alpha$ $\\le$ $\\alpha'$ $\\Rightarrow$ ref h $\\alpha$ $\\le$ ref h $\\alpha'$\n\\end{lstlisting}\n\nThis second rule shows that a reference to a value $\\alpha $ behaves exactly like that value, thereby allowing conversions that mirror the behavior of the value that our reference is standing for.\n\nThese rules are quite hard to concretely instance. This is why we will not be able to instance these rules once and for all in a highly parametric fashion, but instead we will just give some specific instances that are of particular use to us when we are dealing with concrete heaps and references. Also, we will mostly deal with subtyping between values and not subtyping between functions.\n\nAt this point we can rewrite the ``incriminated'' example above so that it compiles:\n\n\\begin{lstlisting}[frame=tb,mathescape]{somecode}\n$ex_2'$ =\n\tdo 10 $>>=$ ($\\lambda$i.\n\tdo \"hello \" $>>=$ ($\\lambda$s.\n\tdo s *= ($\\lambda$x.x++\"world\")\n\t   let $i'$ = downcast i\n\t   v$\\leftarrow$eval s\n\t   x$\\leftarrow$eval $i'$\n\t   return v ++ show x))\n\\end{lstlisting}\n\nNow the type of $ex_2'$ will not only reflect the type of the result of the computation, but also the requirement of subtyping between heaps built with the $New$ type operator:\n\n\\begin{lstlisting}\nHeap $h_0$ ref $\\wedge$ ref (New $h_0$ Int) Int $\\le$ ref (New (New $h_0$ Int) String) Int $\\Rightarrow$ $ex_2'$ : ref $h_0$ String\n\\end{lstlisting}\n\n\\end{document}\n\n% == UNREGISTERED! == GrindEQ Word-to-LaTeX 2008 ==\n\n", "meta": {"hexsha": "832f33dcde264a5437d49f8799f94662cd20331a", "size": 5388, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex/2.tex", "max_stars_repo_name": "vs-team/Papers", "max_stars_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-04-06T08:46:02.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-19T07:16:23.000Z", "max_issues_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex/2.tex", "max_issues_repo_name": "vs-team/Papers", "max_issues_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex/2.tex", "max_forks_repo_name": "vs-team/Papers", "max_forks_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.4311926606, "max_line_length": 954, "alphanum_fraction": 0.7416481069, "num_tokens": 1442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208002, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4365667926241499}}
{"text": "\\documentclass[3p, authoryear, square]{elsarticle}\n\\bibliographystyle{elsarticle-harv}\n\n\\usepackage{amsthm,amssymb,amsmath}\n%% https://tex.stackexchange.com/a/396829/32270\n\\allowdisplaybreaks\n%% H/T: https://tex.stackexchange.com/a/202168/32270\n\\usepackage{textcomp}\n%% H/T: https://tex.stackexchange.com/a/56877/32270\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n%% H/T: https://tex.stackexchange.com/a/244805\n\\usepackage{booktabs,siunitx}\n%% H/T: https://tex.stackexchange.com/a/4217/32270\n\\usepackage{mathtools}\n%% H/T: https://tex.stackexchange.com/a/33869/32270\n\\makeatletter\n\\newenvironment{breakablealgorithm}\n  {% \\begin{breakablealgorithm}\n   \\begin{center}\n     \\refstepcounter{algorithm}% New algorithm\n     \\hrule height.8pt depth0pt \\kern2pt% \\@fs@pre for \\@fs@ruled\n     \\renewcommand{\\caption}[2][\\relax]{% Make a new \\caption\n       {\\raggedright\\textbf{\\ALG@name~\\thealgorithm} ##2\\par}%\n       \\ifx\\relax##1\\relax % #1 is \\relax\n         \\addcontentsline{loa}{algorithm}{\\protect\\numberline{\\thealgorithm}##2}%\n       \\else % #1 is not \\relax\n         \\addcontentsline{loa}{algorithm}{\\protect\\numberline{\\thealgorithm}##1}%\n       \\fi\n       \\kern2pt\\hrule\\kern2pt\n     }\n  }{% \\end{breakablealgorithm}\n     \\kern2pt\\hrule\\relax% \\@fs@post for \\@fs@ruled\n   \\end{center}\n  }\n\\makeatother\n%% H/T: https://tex.stackexchange.com/a/28334/32270\n\\usepackage{chngcntr}\n\\counterwithin{figure}{section}\n\\counterwithin{table}{section}\n\\counterwithin{equation}{section}\n\\counterwithin{algorithm}{section}\n%% H/T: https://tex.stackexchange.com/a/202047/32270\n%%      https://tex.stackexchange.com/a/32463/32270\n\\usepackage[labelfont=bf]{caption}\n%% H/T: https://tex.stackexchange.com/a/163250/32270\n\\usepackage{adjustbox}\n%% H/T: https://tex.stackexchange.com/a/26348/32270\n\\renewcommand*{\\appendixname}{}\n%% Initial Submission: May 16, 2018\n%% First Revision: August 29, 2018\n%% Second Revision: March 11, 2019\n%% Accepted: March 19, 2019\n%% Published: April 5, 2019\n\n\\theoremstyle{definition}\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}{Lemma}[section]\n\n\\usepackage[usenames, dvipsnames]{color}\n\\usepackage{hyperref}\n\\hypersetup{\n  colorlinks=true,\n  pdfinfo={\n    CreationDate={D:20180516090844},\n    ModDate={D:20180516090844},\n  },\n}\n\n\\renewcommand{\\qed}{\\(\\blacksquare\\)}\n\\newcommand{\\cond}[1]{\\operatorname{cond}\\left(#1\\right)}\n\\newcommand{\\fl}[1]{\\operatorname{fl}\\left(#1\\right)}\n\\newcommand{\\bigO}[1]{\\mathcal{O}\\left(#1\\right)}\n\\newcommand{\\mach}{\\mathbf{u}}\n%% db == ``delta'' b\n\\newcommand{\\db}[1]{\n  \\ifthenelse{\\equal{#1}{1}}\n             {\\partial b}\n             {\\partial^{#1} b}\n}\n%% cdb == computed ``delta'' b\n\\newcommand{\\cdb}[1]{\n  \\ifthenelse{\\equal{#1}{1}}\n             {\\widehat{\\partial b}}\n             {\\widehat{\\partial^{#1} b}}\n}\n\n%% \\journal{Applied Mathematics and Computation}\n\\makeatletter\n\\def\\ps@pprintTitle{%\n  \\let\\@oddhead\\@empty\n  \\let\\@evenhead\\@empty\n  \\def\\@oddfoot{\\footnotesize\\itshape\n    Published in Applied Mathematics and Computation (\\cite{Hermes2019})\n      \\hfill April 5, 2019}%\n  \\let\\@evenfoot\\@oddfoot}\n\\makeatother\n\n\\begin{document}\n%% H/T: https://tex.stackexchange.com/a/263503/32270\n\\hypersetup{\n  urlcolor=MidnightBlue,\n  linkcolor=MidnightBlue,\n  citecolor=ForestGreen,\n}\n\n\\begin{frontmatter}\n\n\\title{Compensated de Casteljau algorithm in \\(K\\) times the working precision}\n\\author[djh]{Danny Hermes}\\ead{dhermes@berkeley.edu}\n\\address[djh]{UC Berkeley, 970 Evans Hall \\#3840, Berkeley, CA 94720-3840 USA}\n\n\\begin{abstract}\nIn computer aided geometric design a polynomial is usually represented in\nBernstein form. This paper presents a family of compensated algorithms to\naccurately evaluate a polynomial in Bernstein form with floating point\ncoefficients. The principle is to apply error-free transformations to\nimprove the traditional de Casteljau algorithm. At each stage of computation,\nround-off error is passed on to first order errors, then to second order\nerrors, and so on. After the computation has been ``filtered'' \\((K - 1)\\)\ntimes via this process, the resulting output is as accurate as the de Casteljau\nalgorithm performed in \\(K\\) times the working precision. Forward error\nanalysis and numerical experiments illustrate the accuracy of this family\nof algorithms.\n\\end{abstract}\n\n\\begin{keyword}\nPolynomial evaluation \\sep Compensated algorithm \\sep\nFloating-point arithmetic \\sep Bernstein polynomial \\sep\nError-free transformation \\sep Round-off error\n\\end{keyword}\n\n\\end{frontmatter}\n\n\\section{Introduction}\n\nIn computer aided geometric design, polynomials are usually expressed in\nBernstein form. Polynomials in this form are usually evaluated by the\nde Casteljau algorithm. This algorithm has a round-off error bound\nwhich grows only linearly with degree, even though the number of\narithmetic operations grows quadratically. The Bernstein basis is\noptimally suited (\\cite{Farouki1987, Delgado2015, Mainar2005})\nfor polynomial evaluation; it is\ntypically more accurate than the monomial basis, for example in\nFigure~\\ref{fig:horner-inferior} evaluation via Horner's method produces\na jagged curve for points near a triple root, but the de Casteljau algorithm\nproduces a smooth curve. Nevertheless the de Casteljau\nalgorithm returns results arbitrarily less accurate than the working\nprecision \\(\\mach\\) when evaluating \\(p(s)\\) is ill-conditioned.\nThe relative accuracy of the computed\nevaluation with the de Casteljau algorithm (\\texttt{DeCasteljau}) satisfies\n(\\cite{Mainar1999}) the following a priori bound:\n\\begin{equation}\\label{de-casteljau-error}\n  \\frac{\\left|p(s) - \\mathtt{DeCasteljau}(p, s)\\right|}{\\left|p(s)\\right|} \\leq\n  \\cond{p, s} \\times \\bigO{\\mach}.\n\\end{equation}\nIn the right-hand side of this inequality, \\(\\mach\\) is the computing\nprecision and the condition number \\(\\cond{p, s} \\geq 1\\) only depends\non \\(s\\) and the Bernstein coefficients of \\(p\\) --- its expression will\nbe given further.\n\n\\begin{figure}\n  \\includegraphics[width=0.9375\\textwidth]{horner_inferior.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Comparing Horner's method to the de Casteljau method for\n    evaluating \\(p(s) = (2s - 1)^3\\) in the neighborhood of its\n    multiple root \\(1/2\\).}\n  \\label{fig:horner-inferior}\n\\end{figure}\n\nFor ill-conditioned problems, such as evaluating \\(p(s)\\) near a\nmultiple root, the condition number may be arbitrarily large, i.e.\n\\(\\cond{p, s} > 1 / \\mach\\), in\nwhich case most or all of the computed digits will be incorrect.\nIn some cases, even the order of magnitude of the computed value\nof \\(p(s)\\) can be incorrect.\n\nTo address ill-conditioned problems, error-free transformations (EFT) can\nbe applied in \\textit{compensated algorithms} to account for round-off.\nError-free transformations were studied in great detail in \\cite{Ogita2005}\nand open a large number of applications.\nIn \\cite{langlois_et_al:DSP:2006:442}, a compensated Horner's algorithm was\ndescribed to evaluate a polynomial in the monomial basis. In \\cite{Jiang2010},\na similar method was described to perform a compensated version of the de\nCasteljau algorithm. In both cases, the \\(\\cond{p, s}\\) factor is moved\nfrom \\(\\mach\\) to \\(\\mach^2\\) and the computed value is as accurate\nas if the computations were done in twice the working precision. For example,\nthe compensated de Casteljau algorithm (\\texttt{CompDeCasteljau}) satisfies\n\\begin{equation}\\label{de-casteljau-2-error}\n  \\frac{\\left|p(s) - \\mathtt{CompDeCasteljau}(p, s)\\right|}{\n    \\left|p(s)\\right|} \\leq \\mach + \\cond{p, s} \\times\n    \\bigO{\\mach^2}.\n\\end{equation}\nFor problems with \\(\\cond{p, s} < 1 / \\mach^2\\), the relative error\nis \\(\\mach\\), i.e. accurate to full precision, aside from rounding to the\nnearest floating point number. Figure~\\ref{fig:jlcs-10} shows this shift\nin relative error from \\texttt{DeCasteljau} to \\texttt{CompDeCasteljau}.\n\n\\begin{figure}\n  \\includegraphics[width=0.8125\\textwidth]{jlcs10_plot.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Evaluation of \\(p(s) = (s - 1)\\left(s - 3/4\\right)^7\\)\n    represented in Bernstein form.}\n  \\label{fig:jlcs-10}\n\\end{figure}\n\nIn \\cite{Graillat2009}, the authors generalized the compensated Horner's\nalgorithm to produce a method for evaluating a polynomial as if\nthe computations were done in \\(K\\) times the working precision for\nany \\(K \\geq 2\\). This result motivates this paper, though the\napproach there is somewhat different than ours. They perform each computation\nwith error-free transformations and interpret the errors as coefficients of new\npolynomials. They then evaluate the error polynomials, which (recursively)\ngenerate second order error polynomials and so on. This recursive property\ncauses the number of operations to grow exponentially in \\(K\\). Here, we\ninstead have a fixed number of error groups, each corresponding to round-off\nfrom the group above it. For example, when\n\\((1 - s) b_j^{(n)} + s b_{j + 1}^{(n)}\\) is computed in floating point, any\nerror is filtered down to the error group below it.\n\nAs in~\\eqref{de-casteljau-error}, the accuracy of the compensated\nresult~\\eqref{de-casteljau-2-error} may be arbitrarily bad for ill-conditioned\npolynomial evaluations. For example, as the condition number grows in\nFigure~\\ref{fig:jlcs-10}, some points have relative error exactly equal to\n\\(1\\); this indicates that \\(\\mathtt{CompDeCasteljau}(p, s) = 0\\), which is\na complete failure to evaluate the order of magnitude of \\(p(s)\\). For\nroot-finding problems \\(\\mathtt{CompDeCasteljau}(p, s) = 0\\) when\n\\(p(s) \\neq 0\\) can cause premature convergence and incorrect results.\nWe describe how to defer rounding into progressively\nsmaller error groups and improve the accuracy of the computed result by a\nfactor of \\(\\mach\\) for every error group added. So we derive\n\\texttt{CompDeCasteljauK}, a \\(K\\)-fold compensated de Casteljau algorithm\nthat satisfies the following a priori bound for any arbitrary integer \\(K\\):\n\\begin{equation}\n  \\frac{\\left|p(s) - \\mathtt{CompDeCasteljauK}(p, s, K)\\right|}{\n    \\left|p(s)\\right|} \\leq \\mach + \\cond{p, s} \\times\n    \\bigO{\\mach^K}.\n\\end{equation}\nThis means that the computed value with \\texttt{CompDeCasteljauK} is now\nas accurate as the result of the de Casteljau algorithm performed in\n\\(K\\) times the working precision with a final rounding back to the\nworking precision.\n\nThe paper is organized as follows. Section~\\ref{sec:notation} establishes\nnotation for error analysis with floating point operations, reviews\nresults about error-free transformations and reviews the\nde Casteljau algorithm. In Section~\\ref{sec:compensated-2},\nthe compensated algorithm for polynomial evaluation from \\cite{Jiang2010} is\nreviewed and notation is established for the expansion. In\nSection~\\ref{sec:compensated-k}, the \\(K\\)-compensated algorithm is provided\nand a forward error analysis is performed. Finally, in\nSection~\\ref{sec:numerical} we perform two numerical experiments to\ngive practical examples of the theoretical error bounds.\n\n\\section{Basic notation and results}\\label{sec:notation}\n\n\\subsection{Floating Point and Forward Error Analysis}\n\nWe assume all floating point operations obey\n\\begin{equation}\n  a \\star b = \\fl{a \\circ b} = (a \\circ b)(1 + \\delta_1) =\n  (a \\circ b) / (1 + \\delta_2)\n\\end{equation}\nwhere \\(\\star \\in \\left\\{\\oplus, \\ominus, \\otimes, \\oslash\\right\\}\\), \\(\\circ\n\\in \\left\\{+, -, \\times, \\div\\right\\}\\) and \\(\\left|\\delta_1\\right|,\n\\left|\\delta_2\\right| \\leq \\mach\\). The symbol \\(\\mach\\) is the unit round-off\nand \\(\\star\\) is a floating point operation, e.g.\n\\(a \\oplus b = \\fl{a + b}\\). (For IEEE-754 floating point double precision,\n\\(\\mach = 2^{-53}\\).) We denote the computed result of\n\\(\\alpha \\in \\mathbf{R}\\) in floating point arithmetic by\n\\(\\widehat{\\alpha}\\) or \\(\\fl{\\alpha}\\) and use \\(\\mathbf{F}\\) as the set of\nall floating point numbers (see \\cite{Higham2002} for more details).\nFollowing \\cite{Higham2002}, we will use the following classic properties in\nerror analysis.\n\n\\begin{enumerate}\n  \\item If \\(\\delta_i \\leq \\mach\\), \\(\\rho_i = \\pm 1\\), then\n      \\(\\prod_{i = 1}^n (1 + \\delta_i)^{\\rho_i} = 1 + \\theta_n\\),\n  \\item \\(\\left|\\theta_n\\right| \\leq \\gamma_n \\coloneqq\n      n \\mach / (1 - n \\mach)\\),\n  \\item \\((1 + \\theta_k)(1 + \\theta_j) = 1 + \\theta_{k + j}\\),\n  \\item \\(\\gamma_k + \\gamma_j + \\gamma_k \\gamma_j \\leq \\gamma_{k + j}\n    \\Longleftrightarrow (1 + \\gamma_k)(1 + \\gamma_j) \\leq 1 + \\gamma_{k + j}\\),\n  \\item \\((1 + \\mach)^j \\leq 1 / (1 - j \\mach) \\Longleftrightarrow\n  (1 + \\mach)^j - 1 \\leq \\gamma_j\\).\n\\end{enumerate}\n\n\\subsection{Error-Free Transformation}\n\nAn error-free transformation is a computational method where both\nthe computed result and the round-off error are returned. It\nis considered ``free'' of error if the round-off can be represented\nexactly as an element or elements of \\(\\mathbf{F}\\).\nThe error-free transformations used in this paper are\nthe \\texttt{TwoSum} algorithm by Knuth (\\cite{Knuth1969}) and\n\\texttt{TwoProd} algorithm by Dekker (\\cite{Dekker1971}, Section 5),\nrespectively.\n\n\\begin{theorem}[\\cite{Ogita2005}, Theorem 3.4]\\label{thm:eft}\nFor \\(a, b \\in \\mathbf{F}\\) and \\(P, \\pi, S, \\sigma \\in \\mathbf{F}\\),\n\\texttt{TwoSum} and \\texttt{TwoProd} satisfy\n\\begin{alignat}{4}\n\\left[S, \\sigma\\right] &= \\mathtt{TwoSum}(a, b), & \\, S &= \\fl{a + b},\n  S + \\sigma &= a + b, \\sigma &\\leq \\mach \\left|S\\right|,\n  & \\, \\sigma &\\leq \\mach \\left|a + b\\right| \\\\\n\\left[P, \\pi\\right] &= \\mathtt{TwoProd}(a, b),\n  & \\, P &= \\fl{a \\times b}, P + \\pi &= a \\times b,\n  \\pi &\\leq \\mach \\left|P\\right|,\n  & \\, \\pi &\\leq \\mach \\left|a \\times b\\right|.\n\\end{alignat}\nThe letters \\(\\sigma\\) and \\(\\pi\\) are used to indicate that the\nerrors came from sum and product, respectively. See\nAppendix~\\ref{sec:appendix-algo} for implementation details.\n\\end{theorem}\n\n\\subsection{de Casteljau Algorithm}\n\nNext, we recall\\footnote{We have used slightly non-standard notation for the\nterms produced by the de Casteljau algorithm: we start the superscript at\n\\(n\\) and count down to \\(0\\) as is typically done when describing Horner's\nalgorithm. For example, we use \\(b_j^{(n - 2)}\\) instead of\n\\(b_j^{(2)}\\).} the de Casteljau algorithm:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{de Casteljau algorithm for polynomial evaluation.}}\n  \\label{alg:de-casteljau}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\mathtt{result} = \\mathtt{DeCasteljau}\\)}{$b, s$}\n      \\State \\(n = \\texttt{length}(b) - 1\\)\n      \\State \\(\\widehat{r} = 1 \\ominus s\\)\n      \\\\\n      \\For{\\(j = 0, \\ldots, n\\)}\n        \\State \\(\\widehat{b}_j^{(n)} = b_j\\)\n      \\EndFor\n      \\\\\n      \\For{\\(k = n - 1, \\ldots, 0\\)}\n        \\For{\\(j = 0, \\ldots, k\\)}\n          \\State \\(\\widehat{b}_j^{(k)} = \\left(\n              \\widehat{r} \\otimes \\widehat{b}_j^{(k + 1)}\\right) \\oplus\n              \\left(s \\otimes \\widehat{b}_{j + 1}^{(k + 1)}\\right)\\)\n        \\EndFor\n      \\EndFor\n      \\\\\n      \\State \\(\\mathtt{result} = \\widehat{b}_0^{(0)}\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\begin{theorem}[\\cite{Mainar1999}, Corollary 3.2]\nIf \\(p(s) = \\sum_{j = 0}^n b_j B_{j, n}(s)\\) and \\(\\mathtt{DeCasteljau}(p, s)\\)\nis the value computed by the de Casteljau algorithm then\\footnote{In the\noriginal paper the factor on \\(\\widetilde{p}(s)\\) is \\(\\gamma_{2n}\\),\nbut the authors did not consider round-off when computing\n\\(1 \\ominus s\\).}\n\\begin{equation}\n\\left|p(s) - \\mathtt{DeCasteljau}(p, s)\\right| \\leq \\gamma_{3n}\n\\sum_{j = 0}^n \\left|b_j\\right| B_{j, n}(s).\n\\end{equation}\n\\end{theorem}\n\nThe relative condition number of the evaluation of \\(p(s) = \\sum_{j = 0}^n\nb_j B_{j, n}(s)\\) in Bernstein form used in this paper is (see\n\\cite{Mainar1999}, \\cite{Farouki1987}):\n\\begin{equation}\n\\cond{p, s} = \\frac{\\widetilde{p}(s)}{\\left|p(s)\\right|},\n\\end{equation}\nwhere \\(B_{j, n}(s) = \\binom{n}{j} (1 - s)^{n - j} s^j \\geq 0\\) and\n\\(\\widetilde{p}(s) \\coloneqq \\sum_{j = 0}^n \\left|b_j\\right| B_{j, n}(s)\\).\n\nTo be able to express the algorithm in matrix form, we define\nthe vectors\n\\begin{equation}\nb^{(k)} = \\left[\\begin{array}{c c c} b_0^{(k)} & \\cdots &\nb_k^{(k)}\\end{array}\\right]^T, \\quad\n\\widehat{b}^{(k)} = \\left[\\begin{array}{c c c} \\widehat{b}_0^{(k)} & \\cdots &\n    \\widehat{b}_k^{(k)}\\end{array}\\right]^T\n\\end{equation}\nand the reduction matrices:\n\\begin{equation}\nU_k = U_k(s) = \\left[\\begin{array}{c c c c c c}\n    1 - s  & s      & 0      & \\cdots & \\cdots & 0      \\\\\n    0      & 1 - s  & s      & \\ddots &        & \\vdots \\\\\n    \\vdots & \\ddots & \\ddots & \\ddots & \\ddots & \\vdots \\\\\n    \\vdots &        & \\ddots & \\ddots & \\ddots & 0 \\\\\n    0      & \\cdots & \\cdots & 0      & 1 - s  & s\n\\end{array}\\right] \\in \\mathbf{R}^{k \\times (k + 1)}.\n\\end{equation}\nWith this, we can express (\\cite{Mainar1999}) the de Casteljau algorithm as\n\\begin{equation}\\label{matrix-de-casteljau}\nb^{(k)} = U_{k + 1} b^{(k + 1)}\n\\Longrightarrow b^{(0)} = U_1 \\cdots U_n b^{(n)}.\n\\end{equation}\n\nIn general, for a sequence \\(v_0, \\ldots, v_n\\) we'll refer to \\(v\\)\nas the vector containing all of the values:\n\\(v = \\left[\\begin{array}{c c c} v_0 & \\cdots &\n    v_n\\end{array}\\right]^T.\\)\n\n\\section{Compensated de Casteljau}\\label{sec:compensated-2}\n\nIn this section we review the compensated de Casteljau algorithm\nfrom \\cite{Jiang2010}. In order to track the local errors at\neach update step, we use four EFTs:\n\\begin{align}\n\\left[\\widehat{r}, \\rho\\right] &= \\mathtt{TwoSum}(1, -s) \\\\\n\\left[P_1, \\pi_1\\right] &= \\mathtt{TwoProd}\\left(\n    \\widehat{r}, \\widehat{b}_j^{(k + 1)}\\right) \\\\\n\\left[P_2, \\pi_2\\right] &= \\mathtt{TwoProd}\\left(\n    s, \\widehat{b}_{j + 1}^{(k + 1)}\\right) \\\\\n\\left[\\widehat{b}_j^{(k)}, \\sigma_3\\right] &= \\mathtt{TwoSum}(P_1, P_2)\n\\end{align}\nWith these, we can exactly describe the local error between the exact\nupdate and computed update:\n\\begin{gather}\n\\ell_{1, j}^{(k)} = \\pi_1 + \\pi_2 + \\sigma_3 + \\rho \\cdot\n  \\widehat{b}_j^{(k + 1)} \\label{ell-j} \\\\\n(1 - s) \\cdot \\widehat{b}_j^{(k + 1)} +\n  s \\cdot \\widehat{b}_{j + 1}^{(k + 1)} =\n\\widehat{b}_j^{(k)} + \\ell_{1, j}^{(k)}.\n\\end{gather}\n\n\\begin{figure}\n  \\includegraphics[width=0.375\\textwidth]{tikz_local_err.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Local round-off errors}\n  \\label{fig:loc-err-accumulate}\n\\end{figure}\n\n\\noindent By defining the global errors at each step\n\\begin{equation}\n  \\db{1}_j^{(k)} = b_j^{(k)} - \\widehat{b}_j^{(k)}\n\\end{equation}\nwe can see (Figure~\\ref{fig:loc-err-accumulate}) that the local errors\naccumulate in\n\\(\\db{1}^{(k)}\\):\n\\begin{equation}\\label{err-update}\n  \\db{1}_j^{(k)} = (1 - s) \\cdot \\db{1}_j^{(k + 1)} + s \\cdot\n  \\db{1}_{j + 1}^{(k + 1)} + \\ell_{1, j}^{(k)}.\n\\end{equation}\nWhen computed in exact arithmetic\n\\begin{equation}\n  p(s) = \\widehat{b}_0^{(0)} + \\db{1}_0^{(0)}\n\\end{equation}\nand by using \\eqref{err-update}, we can continue to compute\napproximations of \\(\\db{1}_j^{(k)}\\). The idea behind the compensated\nde Casteljau algorithm is to compute both the local error and the updates\nof the global error with floating point operations:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{Compensated de Casteljau algorithm for polynomial evaluation.}}\n  \\label{alg:comp-de-casteljau}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\mathtt{result} = \\mathtt{CompDeCasteljau}\\)}{$b, s$}\n      \\State \\(n = \\texttt{length}(b) - 1\\)\n      \\State \\(\\left[\\widehat{r}, \\rho\\right] = \\mathtt{TwoSum}(1, -s)\\)\n      \\\\\n      \\For{\\(j = 0, \\ldots, n\\)}\n        \\State \\(\\widehat{b}_j^{(n)} = b_j\\)\n        \\State \\(\\cdb{1}_j^{(n)} = 0\\)\n      \\EndFor\n      \\\\\n      \\For{\\(k = n - 1, \\ldots, 0\\)}\n        \\For{\\(j = 0, \\ldots, k\\)}\n          \\State \\(\\left[P_1, \\pi_1\\right] = \\mathtt{TwoProd}\\left(\n              \\widehat{r}, \\widehat{b}_j^{(k + 1)}\\right)\\)\n          \\State \\(\\left[P_2, \\pi_2\\right] = \\mathtt{TwoProd}\\left(\n              s, \\widehat{b}_{j + 1}^{(k + 1)}\\right)\\)\n          \\State \\(\\left[\\widehat{b}_j^{(k)}, \\sigma_3\\right] =\n              \\mathtt{TwoSum}(P_1, P_2)\\)\n          \\State \\(\\widehat{\\ell}_{1, j}^{(k)} = \\pi_1 \\oplus \\pi_2 \\oplus\n              \\sigma_3 \\oplus \\left(\\rho \\otimes\n              \\widehat{b}_j^{(k + 1)}\\right)\\)\n          \\State \\(\\cdb{1}_j^{(k)} =\n              \\widehat{\\ell}_{1, j}^{(k)} \\oplus\n              \\left(s \\otimes \\cdb{1}_{j + 1}^{(k + 1)}\n              \\right) \\oplus\n              \\left(\\widehat{r} \\otimes\n              \\cdb{1}_j^{(k + 1)}\\right)\\)\n        \\EndFor\n      \\EndFor\n      \\\\\n      \\State \\(\\mathtt{result} = \\widehat{b}_0^{(0)} \\oplus\n          \\cdb{1}_0^{(0)}\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent  When comparing this computed error to the exact error, the\ndifference depends only on \\(s\\) and the Bernstein\ncoefficients of \\(p\\). Using a bound (Lemma~\\ref{lemma:db-lemma}) on the\nround-off error when computing \\(\\db{1}^{(0)}\\), the algorithm can\nbe shown to be as accurate as if the computations were done in twice\nthe working precision:\n\n\\begin{theorem}[\\cite{Jiang2010}, Theorem 5]\n  If no underflow occurs, \\(n \\geq 2\\) and \\(s \\in \\left[0, 1\\right]\\)\n  \\begin{equation}\n    \\frac{\\left|p(s) - \\mathtt{CompDeCasteljau}(p, s)\\right|}{\n      \\left|p(s)\\right|} \\leq \\mach + 2 \\gamma_{3n}^2 \\cond{p, s}.\n  \\end{equation}\n\\end{theorem}\n\n\\begin{figure}\n  \\includegraphics[width=0.9375\\textwidth]{compensated_insufficient.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{The compensated de Casteljau method starts to lose accuracy\n    for \\(p(s) = (2s - 1)^3 (s - 1)\\) in the neighborhood of its\n    multiple root \\(1/2\\).}\n  \\label{fig:compensated-insufficient}\n\\end{figure}\n\nUnfortunately, Figure~\\ref{fig:compensated-insufficient} shows how\n\\texttt{CompDeCasteljau} starts to break down in a region of\nhigh condition number (caused by a multiple root with multiplicity\nhigher than two). For example, the point\n\\(s = \\frac{1}{2} + 1001\\mach\\)\n--- which is in the plotted region \\(\\left|s - \\frac{1}{2}\\right|\n\\leq \\frac{3}{2} \\cdot 10^{-11}\\) --- evaluates to exactly \\(0\\) when\nit should be \\(\\bigO{\\mach^3}\\). As shown in\nTable~\\ref{tab:exact-computation}, the breakdown occurs because\n\\(\\widehat{b}_0^{(0)} = -\\cdb{1}_0^{(0)} = \\mach / 16\\).\n\n\\begin{table}\n  %% See: ``scripts/verify_table.py``.\n  \\centering\n  \\begin{adjustbox}{max width=\\textwidth}\n  \\begin{tabular}{>{$}c<{$} >{$}c<{$} >{$}c<{$} >{$}c<{$} >{$}c<{$} >{$}c<{$}}\n    \\toprule\n    k & j & \\widehat{b}_j^{(k)} & \\cdb{1}_j^{(k)} & \\db{1}_j^{(k)} - \\cdb{1}_j^{(k)} \\\\\n    \\midrule\n    3 & 0 & 0.125 - 1.75 (1001 \\mach) - 0.25 \\mach & 0.25\\mach & 0 \\\\\n    3 & 1 & -0.125 + 1.25(1001 \\mach) + 0.25 \\mach & -0.25\\mach & 0 \\\\\n    3 & 2 & 0.125 - 0.75 (1001 \\mach) & 0 & 0 \\\\\n    3 & 3 & -0.125 + 0.25 (1001 \\mach) & 0 & 0 \\\\\n    \\midrule\n    2 & 0 & -0.5 (1001 \\mach) & 3 (1001 \\mach)^2 & 0 \\\\\n    2 & 1 & 0.5(1001 \\mach) + 0.125 \\mach & -0.125\\mach - 2 (1001 \\mach)^2 & 0 \\\\\n    2 & 2 & -0.5 (1001 \\mach) & (1001 \\mach)^2 & 0 \\\\\n    \\midrule\n    1 & 0 & 0.0625\\mach + (1001 \\mach)^2 + 239\\mach^2 & -0.0625\\mach + 0.5  (1001 \\mach)^2 - 239 \\mach^2 & -5 (1001\\mach)^3 \\\\\n    1 & 1 & 0.0625\\mach - (1001 \\mach)^2 - 239\\mach^2 & -0.0625\\mach - 0.5  (1001 \\mach)^2 + 239 \\mach^2 & 3 (1001\\mach)^3 \\\\\n    \\midrule\n    0 & 0 & 0.0625 \\mach & -0.0625 \\mach & -4 (1001 \\mach)^3 + 8 (1001 \\mach)^4 \\\\\n    \\bottomrule\n  \\end{tabular}\n  \\end{adjustbox}\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Terms computed by \\texttt{CompDeCasteljau} when evaluating \\\\\n    \\(p(s) = (2s - 1)^3 (s - 1)\\) at the point\n    \\(s = \\frac{1}{2} + 1001 \\mach\\)}\n  \\label{tab:exact-computation}\n\\end{table}\n\n\\section{\\texorpdfstring{\\(K\\)}{K}-Compensated de Casteljau}\\label{sec:compensated-k}\n\n\\subsection{Algorithm Specified}\n\nIn order to raise from twice the working precision to \\(K\\) times the\nworking precision, we continue using EFTs when computing\n\\(\\cdb{1}^{(k)}\\). By tracking the round-off from each\nfloating point evaluation via an EFT, we can form a cascade of global errors:\n\\begin{align}\n  b_j^{(k)} &= \\widehat{b}_j^{(k)} + \\db{1}_j^{(k)} \\\\\n  \\db{1}_j^{(k)} &= \\cdb{1}_j^{(k)} + \\db{2}_j^{(k)} \\\\\n  \\db{2}_j^{(k)} &= \\cdb{2}_j^{(k)} +\n  \\db{3}_j^{(k)} \\\\\n  %% H/T: https://tex.stackexchange.com/a/7651/32270\n  &\\mathrel{\\makebox[\\widthof{=}]{\\vdots}} \\nonumber\n\\end{align}\nIn the same way local error can be tracked when updating\n\\(\\widehat{b}_j^{(k)}\\), it can be tracked for updates that happen down\nthe cascade:\n\\begin{alignat}{4}\n  (1 - s) \\cdot \\widehat{b}_j^{(k + 1)} &+\n  s \\cdot \\widehat{b}_{j + 1}^{(k + 1)} &&  &&=\n  \\widehat{b}_j^{(k)} &&+ \\ell_{1, j}^{(k)} \\\\\n  (1 - s) \\cdot \\cdb{1}_j^{(k + 1)} &+\n  s \\cdot \\cdb{1}_{j + 1}^{(k + 1)} &&+ \\ell_{1, j}^{(k)} &&=\n  \\cdb{1}_j^{(k)} &&+ \\ell_{2, j}^{(k)} \\\\\n  (1 - s) \\cdot \\cdb{2}_j^{(k + 1)} &+\n  s \\cdot \\cdb{2}_{j + 1}^{(k + 1)} &&+ \\ell_{2, j}^{(k)} &&=\n  \\cdb{2}_j^{(k)} &&+ \\ell_{3, j}^{(k)} \\\\\n  &  &&  &&\\mathrel{\\makebox[\\widthof{=}]{\\vdots}} && \\nonumber\n\\end{alignat}\n\n\\begin{figure}\n  \\includegraphics[width=0.875\\textwidth]{tikz_filtration.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Filtering errors}\n  \\label{fig:error-filtration}\n\\end{figure}\n\nIn \\texttt{CompDeCasteljau} (Algorithm~\\ref{alg:comp-de-casteljau}), after\na single stage of error filtering we\n``give up'' and use \\(\\cdb{1}\\) instead of\n\\(\\db{1}\\) (without keeping around any information about the\nround-off error). In order to obtain results that are as accurate as if\ncomputed in \\(K\\) times the working precision, we must continue filtering\n(see Figure~\\ref{fig:error-filtration})\nerrors down \\((K - 1)\\) times, and only at the final level do we accept\nthe rounded\n\\(\\cdb{K - 1}\\) in place of the exact\n\\(\\db{K - 1}\\).\n\nWhen computing \\(\\cdb{F}\\) (i.e. the error after\n\\(F\\) stages of filtering)\nthere will be several sources of round-off. In particular, there will be\n\\begin{itemize}\n\\item errors when computing \\(\\widehat{\\ell}_{F, j}^{(k)}\\) from the\n  terms in \\(\\ell_{F, j}^{(k)}\\)\n\\item an error\nfor the ``missing'' \\(\\rho \\cdot \\cdb{F}_j^{(k + 1)}\\) in\n\\((1 - s) \\cdot \\cdb{F}_j^{(k + 1)}\\)\n\\item an error from the product\n  \\(\\widehat{r} \\otimes \\cdb{F}_j^{(k + 1)}\\)\n\\item an error from the product\n  \\(s \\otimes \\cdb{F}_{j + 1}^{(k + 1)}\\)\n\\item two errors from the two \\(\\oplus\\) when combining the three\n  terms in\n  \\(\\widehat{\\ell}_{F, j}^{(k)} \\oplus\n  \\left(s \\otimes \\cdb{F}_{j + 1}^{(k + 1)}\\right) \\oplus\n  \\left(\\widehat{r} \\otimes \\cdb{F}_j^{(k + 1)}\\right)\\)\n\\end{itemize}\nFor example, in~\\eqref{ell-j}:\n%% H/T: https://tex.stackexchange.com/a/154333/32270\n\\begin{equation}\n\\ell_{1, j}^{(k)} =\n    \\underbrace{\\vphantom{\\rho \\cdot \\widehat{b}_j^{(k + 1)}} \\pi_1}_{\n        \\vphantom{(1 - s) \\widehat{b}_j^{(k + 1)}}\n        P_1 = \\widehat{r} \\otimes \\widehat{b}_j^{(k + 1)}} +\n    \\underbrace{\\vphantom{\\rho \\cdot \\widehat{b}_j^{(k + 1)}} \\pi_2}_{\n        \\vphantom{(1 - s) \\widehat{b}_j^{(k + 1)}}\n        P_2 = s \\otimes \\widehat{b}_{j + 1}^{(k + 1)}} +\n    \\underbrace{\\vphantom{\\rho \\cdot \\widehat{b}_j^{(k + 1)}} \\sigma_3}_{\n        \\vphantom{(1 - s) \\widehat{b}_j^{(k + 1)}}\n        P_1 \\oplus P_2} +\n    \\underbrace{\\rho \\cdot \\widehat{b}_j^{(k + 1)}}_{\n        (1 - s) \\widehat{b}_j^{(k + 1)}}\n\\end{equation}\nAfter each stage, we'll always have\n\\begin{equation}\n\\ell_{F, j}^{(k)} = e_1 + \\cdots + e_{5F - 2} + \\rho \\cdot\n\\cdb{F - 1}_j^{(k + 1)}\n\\end{equation}\nwhere the terms \\(e_1, \\ldots, e_{5F - 2}\\) come from using \\texttt{TwoSum}\nand \\texttt{TwoProd} when computing \\(\\cdb{F - 1}_j^{(k)}\\)\nand the \\(\\rho\\) term comes from the round-off\nin \\(1 \\ominus s\\) when multiplying \\((1 - s)\\) by\n\\(\\cdb{F - 1}_j^{(k + 1)}\\). With this in mind, we\ncan define an EFT (\\texttt{LocalErrorEFT}) that computes\n\\(\\widehat{\\ell}\\) and tracks all round-off errors generated in\nthe process:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{EFT for computing the local error.}}\n  \\label{alg:local-error-eft}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\left[\\eta, \\widehat{\\ell}\\right] =\n        \\mathtt{LocalErrorEFT}\\)}{$e, \\rho, \\delta b$}\n      \\State \\(L = \\texttt{length}(e)\\)\n      \\\\\n      \\State \\(\\left[\\widehat{\\ell}, \\eta_1\\right] =\n          \\mathtt{TwoSum}(e_1, e_2)\\)\n      \\For{\\(j = 3, \\ldots, L\\)}\n        \\State \\(\\left[\\widehat{\\ell}, \\eta_{j - 1}\\right] =\n            \\mathtt{TwoSum}\\left(\\widehat{\\ell}, e_j\\right)\\)\n      \\EndFor\n      \\\\\n      \\State \\(\\left[P, \\eta_L\\right] =\n          \\mathtt{TwoProd}\\left(\\rho, \\delta b\\right)\\)\n      \\State \\(\\left[\\widehat{\\ell}, \\eta_{L + 1}\\right] =\n          \\mathtt{TwoSum}\\left(\\widehat{\\ell}, P\\right)\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent With this EFT in place\\footnote{And the related\n\\texttt{LocalError} in Algorithm~\\ref{alg:local-error}}, we can\nperform \\((K - 1)\\) error filtrations. Once we've computed the \\(K\\) stages\nof global errors, they can be combined with\n\\texttt{SumK} (Algorithm~\\ref{alg:sum-k}) to produce a sum that is as\naccurate as if computed in \\(K\\) times the working precision.\n\n\\begin{breakablealgorithm}\n  \\caption{\\(K\\)-\\textit{compensated de Casteljau algorithm.}}\n  \\label{alg:k-comp-de-casteljau}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\mathtt{result} = \\mathtt{CompDeCasteljauK}\\)}{$b, s, K$}\n      \\State \\(n = \\texttt{length}(b) - 1\\)\n      \\State \\(\\left[\\widehat{r}, \\rho\\right] = \\mathtt{TwoSum}(1, -s)\\)\n      \\\\\n      \\For{\\(j = 0, \\ldots, n\\)}\n        \\State \\(\\widehat{b}_j^{(n)} = b_j\\)\n        \\For{\\(F = 1, \\ldots, K - 1\\)}\n          \\State \\(\\cdb{F}_j^{(n)} = 0\\)\n        \\EndFor\n      \\EndFor\n      \\\\\n      \\For{\\(k = n - 1, \\ldots, 0\\)}\n        \\For{\\(j = 0, \\ldots, k\\)}\n          \\State \\(\\left[P_1, \\pi_1\\right] = \\mathtt{TwoProd}\\left(\n              \\widehat{r}, \\widehat{b}_j^{(k + 1)}\\right)\\)\n          \\State \\(\\left[P_2, \\pi_2\\right] = \\mathtt{TwoProd}\\left(\n              s, \\widehat{b}_{j + 1}^{(k + 1)}\\right)\\)\n          \\State \\(\\left[\\widehat{b}_j^{(k)}, \\sigma_3\\right] =\n              \\mathtt{TwoSum}(P_1, P_2)\\)\n          \\\\\n          \\State \\(e = \\left[\\pi_1, \\pi_2, \\sigma_3\\right]\\)\n          \\State \\(\\delta b = \\widehat{b}_j^{(k + 1)}\\)\n          \\\\\n          \\For{\\(F = 1, \\ldots, K - 2\\)}\n            \\State \\(\\left[\\eta, \\widehat{\\ell}\\right] =\n                \\mathtt{LocalErrorEFT}(e, \\rho, \\delta b)\\)\n            \\State \\(L = \\texttt{length}(\\eta)\\)\n            \\\\\n            \\State \\(\\left[P_1, \\eta_{L + 1}\\right] = \\mathtt{TwoProd}\\left(\n                s, \\cdb{F}_{j + 1}^{(k + 1)}\\right)\\)\n            \\State \\(\\left[S_2, \\eta_{L + 2}\\right] =\n                \\mathtt{TwoSum}\\left(\\widehat{\\ell}, P_1\\right)\\)\n            \\State \\(\\left[P_3, \\eta_{L + 3}\\right] = \\mathtt{TwoProd}\\left(\n                \\widehat{r}, \\cdb{F}_j^{(k + 1)}\\right)\\)\n            \\State \\(\\left[\\cdb{F}_j^{(k)}, \\eta_{L + 4}\\right]\n                = \\mathtt{TwoSum}\\left(S_2, P_3\\right)\\)\n            \\\\\n            \\State \\(e = \\eta\\)\n            \\State \\(\\delta b = \\cdb{F}_j^{(k + 1)}\\)\n          \\EndFor\n          \\\\\n          \\State \\(\\widehat{\\ell} =\n                \\mathtt{LocalError}(e, \\rho, \\delta b)\\)\n          \\State \\(\\cdb{K - 1}_j^{(k)} =\n              \\widehat{\\ell} \\oplus\n              \\left(s \\otimes \\cdb{K - 1}_{j + 1}^{(k + 1)}\n              \\right) \\oplus\n              \\left(\\widehat{r} \\otimes\n              \\cdb{K - 1}_j^{(k + 1)}\\right)\\)\n        \\EndFor\n      \\EndFor\n      \\\\\n      \\State \\(\\mathtt{result} = \\mathtt{SumK}\\left(\\left[\n        \\widehat{b}_0^{(0)}, \\ldots, \\cdb{K - 1}_0^{(0)}\\right], K\\right)\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent Noting that \\(\\ell_{F, j}\\) contains \\(5F - 1\\) terms, one can\nshow that \\texttt{CompDeCasteljauK} (Algorithm~\\ref{alg:k-comp-de-casteljau})\nrequires\n\\begin{equation}\n(15K^2 + 11K - 34)T_n + 6K^2 - 11K + 11 =\n\\bigO{n^2 K^2}\n\\end{equation}\nflops to evaluate a degree \\(n\\) polynomial, where \\(T_n\\) is the\n\\(n\\)th triangular number. As a comparison, the non-compensated form of\nde Casteljau requires \\(3 T_n + 1\\) flops. In total this will require\n\\((3K - 4)T_n\\) uses of \\texttt{TwoProd}. On hardware that supports\nFMA, \\texttt{TwoProdFMA} (Algorithm~\\ref{alg:two-prod-fma}) can be used\ninstead, lowering the flop count by \\(15(3K - 4)T_n\\). Another way\nto lower the total flop count is to just use\n\\(\\widehat{b}_0^{(0)} \\oplus \\cdots \\oplus \\cdb{K - 1}_0^{(0)}\\)\ninstead of \\texttt{SumK}; this will reduce the total by\n\\(6(K - 1)^2\\) flops. When using a standard sum, the results produced\nare (empirically) identical to those with \\texttt{SumK}. This makes\nsense: the whole point of \\texttt{SumK}\nis to filter errors in a summation so that the final operation produces\na sum of the form \\(v_1 \\oplus \\cdots \\oplus v_K\\) where each\nterm is smaller than the previous by a factor of \\(\\mach\\). This\nproperty is already satisfied for the \\(\\cdb{F}_0^{(0)}\\) so in\npractice the \\(K\\)-compensated summation is likely not needed.\n\n\\subsection{Error bound for polynomial evaluation}\n\n\\begin{theorem}[\\cite{Ogita2005}, Proposition 4.10]\\label{thm:sum-k}\nA summation can be computed (\\texttt{SumK}, Algorithm~\\ref{alg:sum-k})\nwith results that are as accurate as if computed in \\(K\\) times the\nworking precision. When computed this way, the result satisfies:\n\\begin{equation}\n\\left|\\mathtt{SumK}(v, K) - \\sum_{j = 1}^n v_j\\right| \\leq\n\\left(\\mach + 3 \\gamma_{n - 1}^2\\right) \\left|\\sum_{j = 1}^n v_j\\right| +\n\\gamma_{2n - 2}^K \\sum_{j = 1}^n \\left|v_j\\right|.\n\\end{equation}\n\\end{theorem}\n\n\\begin{lemma}[\\cite{Jiang2010}, Theorem 4]\\label{lemma:db-lemma}\nThe second order error \\(\\db{2}^{(0)}_0\\) satisfies\\footnote{The authors\n  missed one round-off error so used \\(\\gamma_{3n + 1}\\) where\n  \\(\\gamma_{3n + 2}\\) would have followed from their arguments.}\n\\begin{equation}\n  \\left|\\db{1}^{(0)}_0 - \\cdb{1}^{(0)}_0\\right| =\n  \\left|\\db{2}^{(0)}_0\\right| \\leq 2 \\gamma_{3n + 2} \\gamma_{3(n - 1)}\n  \\widetilde{p}(s).\n\\end{equation}\n\\end{lemma}\n\nTo enable a bound on the \\(K\\) order error \\(\\db{K}^{(0)}_0\\), it's necessary\nto understand the difference between the exact local errors \\(\\ell_{F, j}\\)\nand the computed equivalents \\(\\widehat{\\ell}_{F, j}\\). To do this, we define\n\\begin{equation}\n\\widetilde{\\ell}_{F, j} \\coloneqq \\left|e_1\\right| +\n\\cdots + \\left|e_{5F - 2}\\right| + \\left|\\rho \\cdot\n\\cdb{F - 1}_j^{(k + 1)}\\right|.\n\\end{equation}\n\n\\begin{lemma}\\label{lemma:ell-tilde}\nThe local error bounds \\(\\widetilde{\\ell}_{F, j}\\) satisfy:\n\\begin{align}\n\\widetilde{\\ell}_{1, j}^{(k)} &\\leq\n  \\gamma_3 \\left(\n  (1 - s) \\left|\\widehat{b}_j^{(k + 1)}\\right| +\n  s \\left|\\widehat{b}_{j + 1}^{(k + 1)}\\right|\\right)\n  \\label{ell-tilde-1} \\\\\n\\widetilde{\\ell}_{F + 1, j}^{(k)} &\\leq\n  \\gamma_3 \\left(\n  (1 - s) \\left|\\cdb{F}_j^{(k + 1)}\\right| +\n  s \\left|\\cdb{F}_{j + 1}^{(k + 1)}\\right|\\right) +\n  \\gamma_{5F} \\cdot \\widetilde{\\ell}_{F, j}^{(k)}\n  \\text{ for } F \\geq 1.\n\\end{align}\n\\end{lemma}\n\nAs we'll see soon (Lemma~\\ref{lemma:k-order}), putting a bound on\nsums of the form \\(\\sum_{j = 0}^k \\widetilde{\\ell}_{F, j}^{(k)} B_{j, k}(s)\\) will\nbe useful to get an overall bound on the relative error for\n\\texttt{CompDeCasteljauK}, so we define\n\\(L_{F, k} \\coloneqq \\sum_{j = 0}^k \\widetilde{\\ell}_{F, j}^{(k)} B_{j, k}(s)\\).\n\n\\begin{lemma}\\label{lemma:L-and-D-bounds}\nFor \\(s \\in \\left[0, 1\\right]\\), the Bernstein-type error sum defined above\nsatisfies the following bounds:\n\\begin{align}\nL_{F, n - k} &\\leq \\left[\\left(3^F \\binom{k}{F - 1} + \\bigO{k^{F - 1}}\\right)\n  \\mach^F + \\bigO{\\mach^{F + 1}}\\right] \\cdot \\widetilde{p}(s) \\\\\n\\sum_{k = 0}^{n - 1} \\gamma_{3k + 5F} L_{F, k} &\\leq\n  \\left[\\left(3^{F + 1} \\binom{n}{F + 1} + \\bigO{n^F}\\right)\n  \\mach^{F + 1} + \\bigO{\\mach^{F + 2}}\\right] \\cdot \\widetilde{p}(s).\n  \\label{L-sum-bound}\n\\end{align}\nIn particular, this means that\n\\(\\sum_{k = 0}^{n - 1} \\gamma_{3k + 5F} L_{F, k} =\n\\bigO{(3 n \\mach)^{F + 1}} \\cdot \\widetilde{p}(s)\\).\n\\end{lemma}\n\nSee Appendix~\\ref{sec:appendix-proof-details} for details on\nproving Lemma~\\ref{lemma:ell-tilde} and Lemma~\\ref{lemma:L-and-D-bounds}.\n\n\\begin{lemma}\\label{lemma:k-order}\nThe \\(K\\) order error \\(\\db{K}^{(0)}_0\\) satisfies\n\\begin{equation}\n  \\left|\\db{K - 1}^{(0)}_0 - \\cdb{K - 1}^{(0)}_0\\right| =\n  \\left|\\db{K}^{(0)}_0\\right| \\leq\n  \\left[\\left(3^{K} \\binom{n}{K} + \\bigO{n^{K - 1}}\\right)\n  \\mach^{K} + \\bigO{\\mach^{K + 1}}\\right] \\cdot \\widetilde{p}(s).\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}\nAs in \\eqref{matrix-de-casteljau}, we can express the compensated\nde Casteljau algorithm as\n\\begin{equation}\n\\db{F}^{(k)} = U_{k + 1} \\db{F}^{(k + 1)} + \\ell_{F}^{(k)}\n\\Longrightarrow \\db{F}^{(0)} = \\sum_{k = 0}^{n - 1}\nU_1 \\cdots U_k \\ell_F^{(k)} = \\sum_{k = 0}^{n - 1}\n\\left[\\sum_{j = 0}^k \\ell_{F, j}^{(k)} B_{j, k}(s)\\right].\n\\end{equation}\nFor the inexact equivalent of these things, first note that\n\\(\\widehat{r} = (1 - s)(1 + \\delta)\\). Due to this,\nwe put the \\(\\widehat{r}\\) term at the end of each update step to reduce\nthe amount of round-off:\n\\begin{align}\n  \\cdb{F}_j^{(k)} &=\n  \\widehat{\\ell}_{F, j}^{(k)} \\oplus\n  \\left(s \\otimes \\cdb{F}_{j + 1}^{(k + 1)}\\right) \\oplus\n  \\left(\\widehat{r} \\otimes \\cdb{F}_j^{(k + 1)}\\right) \\\\\n&= (1 - s) \\cdot \\cdb{F}_j^{(k + 1)}(1 + \\theta_3) +\n  s \\cdot \\cdb{F}_{j + 1}^{(k + 1)}(1 + \\theta_3) +\n  \\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_2) \\\\\n\\Longrightarrow \\cdb{F}^{(k)} &=\n  U_{k + 1} \\cdb{F}^{(k + 1)}(1 + \\theta_3) +\n  \\widehat{\\ell}_{F}^{(k)} (1 + \\theta_2) \\\\\n\\Longrightarrow \\cdb{F}^{(0)} &=\n  \\sum_{k = 0}^{n - 1}\n  U_1 \\cdots U_k \\widehat{\\ell}_F^{(k)} (1 + \\theta_{3k + 2})\n  = \\sum_{k = 0}^{n - 1}\n  \\left[\\sum_{j = 0}^k \\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_{3k + 2})\n    B_{j, k}(s)\\right].\n\\end{align}\nSince\n\\begin{equation}\n\\db{F + 1}_0^{(0)} = \\db{F}_0^{(0)} - \\cdb{F}_0^{(0)} = \\sum_{k = 0}^{n - 1}\n\\sum_{j = 0}^k \\left(\\ell_{F, j}^{(k)} -\n\\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_{3k + 2})\\right) B_{j, k}(s)\n\\end{equation}\nit's useful to put a bound on \\(\\ell_{F, j}^{(k)} -\n\\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_{3k + 2})\\). Via\n\\begin{align}\n\\widehat{\\ell}_{F, j}^{(k)} &= e_1 \\oplus \\cdots \\oplus e_{5F - 2} \\oplus\n\\left(\\rho \\otimes \\cdb{F - 1}_j^{(k + 1)}\\right) \\\\\n&= e_1\\left(1 + \\theta_{5F - 2}\\right) + \\cdots +\ne_{5F - 2}\\left(1 + \\theta_2\\right) +\n\\rho \\cdot \\cdb{F - 1}_j^{(k + 1)} \\left(1 + \\theta_2\\right)\n\\end{align}\nwe see that\n\\begin{equation}\n\\left|\\ell_{F, j}^{(k)} -\n\\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_{3k + 2})\\right| \\leq\n\\gamma_{3k + 5F} \\cdot \\widetilde{\\ell}_{F, j}^{(k)}\n\\Longrightarrow\n\\left|\\db{F + 1}_0^{(0)}\\right| \\leq \\sum_{k = 0}^{n - 1}\n\\gamma_{3k + 5F} \\sum_{j = 0}^k \\widetilde{\\ell}_{F, j}^{(k)} B_{j, k}(s).\n\\end{equation}\nApplying \\eqref{L-sum-bound} directly gives\n\\begin{equation}\n\\left|\\db{F + 1}_0^{(0)}\\right| \\leq\n  \\left[\\left(3^{F + 1} \\binom{n}{F + 1} + \\bigO{n^F}\\right)\n  \\mach^{F + 1} + \\bigO{\\mach^{F + 2}}\\right] \\cdot \\widetilde{p}(s).\n\\end{equation}\nLetting \\(K = F + 1\\) we have our result.\n\\end{proof}\n\n\\begin{theorem}\nIf no underflow occurs, \\(n \\geq 2\\) and \\(s \\in \\left[0, 1\\right]\\)\n\\begin{multline}\n  \\frac{\\left|p(s) - \\mathtt{CompDeCasteljau}(p, s, K)\\right|}{\n    \\left|p(s)\\right|} \\leq \\left[\\mach + \\bigO{\\mach^2}\n    \\right] + \\\\\n    \\left[\\left(3^{K} \\binom{n}{K} + \\bigO{n^{K - 1}}\\right) \\mach^K +\n    \\bigO{\\mach^{K + 1}}\\right] \\cond{p, s}.\n\\end{multline}\n\\end{theorem}\n\n\\begin{proof}\nSince\n\\begin{equation}\n\\mathtt{CompDeCasteljau}(p, s, K) = \\mathtt{SumK}\\left(\\left[\n  \\widehat{b}_0^{(0)}, \\ldots, \\cdb{K - 1}_0^{(0)}\\right], K\\right),\n\\end{equation}\napplying Theorem~\\ref{thm:sum-k} tells us that\n\\begin{equation}\\label{sum-k-applied}\n\\left|\\mathtt{CompDeCasteljau}(p, s, K) - \\sum_{F = 0}^{K - 1}\n\\cdb{F}_0^{(0)}\\right| \\leq\n\\left(\\mach + 3 \\gamma_{n - 1}^2\\right) \\left|\\sum_{F = 0}^{K - 1}\n\\cdb{F}_0^{(0)}\\right| +\n\\gamma_{2n - 2}^K \\sum_{F = 0}^{K - 1} \\left|\\cdb{F}_0^{(0)}\\right|.\n\\end{equation}\nSince\n\\begin{equation}\np(s) = b_0^{(0)} = \\widehat{b}_0^{(0)} + \\db{1}_0^{(0)}\n= \\cdots\n= \\widehat{b}_0^{(0)} + \\cdb{1}_0^{(0)} + \\cdots\n+ \\cdb{K - 1}_0^{(0)} + \\db{K}_0^{(0)}\n\\end{equation}\nwe have\n\\begin{gather}\n\\left|\\sum_{F = 0}^{K - 1} \\cdb{F}_0^{(0)}\\right|\n\\leq \\left|p(s)\\right| + \\left|\\db{K}_0^{(0)}\\right| \\quad \\text{and} \\\\\n\\left|\\mathtt{CompDeCasteljau}(p, s, K) - p(s)\\right| \\leq\n\\left|\\mathtt{CompDeCasteljau}(p, s, K) - \\sum_{F = 0}^{K - 1}\n\\cdb{F}_0^{(0)}\\right| +\n\\left|\\db{K}_0^{(0)}\\right| \\label{triangle-ps}.\n\\end{gather}\nDue to Lemma~\\ref{lemma:k-order}, \\(\\db{F}_0^{(0)} =\n\\bigO{\\mach^F} \\widetilde{p}(s)\\), hence\n\\begin{align}\n\\left(\\mach + 3 \\gamma_{n - 1}^2\\right) \\left|\\sum_{F = 0}^{K - 1}\n\\cdb{F}_0^{(0)}\\right| &\\leq\n\\left[\\mach + \\bigO{\\mach^2}\\right] \\left|p(s)\\right| +\n\\bigO{\\mach^{K + 1}} \\widetilde{p}(s) \\\\\n\\gamma_{2n - 2}^K \\sum_{F = 0}^{K - 1} \\left|\\cdb{F}_0^{(0)}\\right| &\\leq\n\\gamma_{2n - 2}^K \\left|\\widehat{b}_0^{(0)}\\right| +\n\\bigO{\\mach^{K + 1}} \\widetilde{p}(s) \\\\\n&\\leq\n\\gamma_{2n - 2}^K \\left[\\left|p(s)\\right| +\n  \\bigO{\\mach} \\widetilde{p}(s)\\right] +\n\\bigO{\\mach^{K + 1}} \\widetilde{p}(s).\n\\end{align}\nCombining this with \\eqref{sum-k-applied} and \\eqref{triangle-ps}, we\nsee\n\\begin{align}\n& \\left|\\mathtt{CompDeCasteljau}(p, s, K) - p(s)\\right| \\\\\n\\leq &\n\\left[\\mach + \\bigO{\\mach^2}\\right] \\left|p(s)\\right| +\n\\left|\\db{K}_0^{(0)}\\right| +\n\\bigO{\\mach^{K + 1}} \\widetilde{p}(s) \\\\\n\\leq &\n\\left[\\mach + \\bigO{\\mach^2}\\right] \\left|p(s)\\right| +\n\\left[\\left(3^{K} \\binom{n}{K} + \\bigO{n^{K - 1}}\\right) \\mach^K +\n\\bigO{\\mach^{K + 1}} \\right]\n\\widetilde{p}(s).\n\\end{align}\nDividing this by \\(\\left|p(s)\\right|\\), we have our result.\n\\end{proof}\n\nFor the first few values of \\(K\\) the coefficient of\n\\(\\cond{p, s}\\) in the bound is\n\\begin{center}\n  \\begin{tabular}{>{$}c<{$} c >{$}c<{$}}\n    K & Method & \\text{Multiplier} \\\\\n    \\midrule\n    1 & \\texttt{DeCasteljau} & 3 \\binom{n}{1} \\mach =\n      3n \\mach \\approx \\gamma_{3n} \\\\[0.125cm]\n    2 & \\texttt{CompDeCasteljau} & \\left[9 \\binom{n}{2} +\n      15 \\binom{n}{1}\\right]\\mach^2 = \\frac{3n(3n + 7)}{2} \\mach^2\n      \\approx \\frac{1}{4} \\cdot 2 \\gamma_{3n}^2 \\\\[0.125cm]\n    3 & \\texttt{CompDeCasteljau3} & \\left[27 \\binom{n}{3} +\n      135 \\binom{n}{2} + 150 \\binom{n}{1}\\right] \\mach^3 =\n      \\frac{3n(3n^2 + 36n + 61)}{2} \\mach^3 \\\\[0.125cm]\n    4 & \\texttt{CompDeCasteljau4} & \\left[81 \\binom{n}{4} + 810 \\binom{n}{3} +\n      2475 \\binom{n}{2} + 2250 \\binom{n}{1}\\right] \\mach^4 \\\\[0.125cm]\n  \\end{tabular}\n\\end{center}\nSee the \\hyperref[proof:L-and-D-bounds]{proof} of\nLemma~\\ref{lemma:L-and-D-bounds} for more details on where these\npolynomials come from.\n\n\\section{Numerical experiments}\\label{sec:numerical}\n\n\\begin{figure}\n  \\includegraphics[width=0.9375\\textwidth]{de_casteljau_smooth_drawing.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Evaluation of \\(p(s) = (s - 1)\\left(s - 3/4\\right)^7\\)\n    in the neighborhood of its multiple root \\(3/4\\).}\n  \\label{fig:smooth-drawing}\n\\end{figure}\n\nAll experiments were performed in IEEE-754 double precision.\nAs in \\cite{Jiang2010}, we consider the evaluation in the neighborhood\nof the multiple root of \\(p(s) = (s - 1)\\left(s - 3/4\\right)^7\\),\nwritten in Bernstein form.\nFigure~\\ref{fig:smooth-drawing} shows the evaluation of \\(p(s)\\) at\nthe 401 equally spaced\\footnote{It's worth noting that \\(0.1\\) cannot\nbe represented exactly in IEEE-754 double precision (or any binary\narithmetic for that matter). Hence (most of) the points of the form\n\\(a + b \\cdot 10^{-c}\\) can only be approximately represented.} points\n\\(\\left\\{\\frac{3}{4} + j \\frac{10^{-7}}{2}\\right\\}_{j=-200}^{200}\\)\nwith \\texttt{DeCasteljau} (Algorithm~\\ref{alg:de-casteljau}),\n\\texttt{CompDeCasteljau} (Algorithm~\\ref{alg:comp-de-casteljau})\nand \\texttt{CompDeCasteljau3} (Algorithm~\\ref{alg:k-comp-de-casteljau}\nwith \\(K = 3\\)). We see that \\texttt{DeCasteljau} fails to get the\nmagnitude correct, \\texttt{CompDeCasteljau} has the right shape but\nlots of noise and \\texttt{CompDeCasteljau3} is able to smoothly evaluate\nthe function. This is in contrast to a similar figure in \\cite{Jiang2010},\nwhere the plot was smooth for the 400 equally spaced points\n\\(\\left\\{\\frac{3}{4} + \\frac{10^{-4}}{2} \\frac{2j - 399}{399}\n\\right\\}_{j=0}^{399}\\). The primary difference is that as the interval\nshrinks by a factor of \\(\\approx \\frac{10^{-4}}{10^{-7}} = 10^3\\), the\ncondition number goes up by \\(\\approx 10^{21}\\) and \\texttt{CompDeCasteljau}\nis no longer accurate.\n\n\\begin{figure}\n  \\includegraphics[width=0.8125\\textwidth]{de_casteljau_rel_error.pdf}\n  \\centering\n  \\captionsetup{width=.75\\linewidth}\n  \\caption{Accuracy of evaluation of \\(p(s) = (s - 1)\\left(s - 3/4\\right)^7\\)\n    represented in Bernstein form.}\n  \\label{fig:compensated-k}\n\\end{figure}\n\nFigure~\\ref{fig:compensated-k} shows the relative forward errors compared\nagainst the condition number. To compute relative errors, each input and\ncoefficient is converted to a fraction (i.e. infinite precision) and\n\\(p(s)\\) is computed exactly as a fraction, then\ncompared to the corresponding computed values. Similar tools are used to\n\\textbf{exactly} compute the condition number, though here we can rely\non the fact that \\(\\widetilde{p}(s) = (s - 1)\n\\left(s/2 - 3/4\\right)^7\\). Once the relative errors and\ncondition numbers are computed as fractions, they are rounded to the\nnearest IEEE-754 double precision value. As in \\cite{Jiang2010}, we use\nvalues \\(\\left\\{\\frac{3}{4} - (1.3)^j\\right\\}_{j=-5}^{-90}\\)\\footnote{As with\n\\(0.1\\), it's worth noting that \\((1.3)^j\\) can't be represented exactly in\nIEEE-754 double precision. However, this geometric series still serves a\nuseful purpose since it continues to raise \\(\\cond{p, s}\\) as \\(j\\) decreases\naway from \\(0\\) and because it results in ``random'' changes in the bits of\n\\(0.75\\) that are impacted by subtracting \\((1.3)^j\\).}. The curves for\n\\texttt{DeCasteljau} and \\texttt{CompDeCasteljau} trace the same paths seen\nin \\cite{Jiang2010}. In particular, \\texttt{CompDeCasteljau} has a relative\nerror that is \\(\\bigO{\\mach}\\) until \\(\\cond{p, s}\\) reaches\n\\(1 / \\mach\\), at which point the relative error increases linearly with\nthe condition number until it becomes \\(\\bigO{1}\\) when\n\\(\\cond{p, s}\\) reaches \\(1 / \\mach^2\\).\nSimilarly, the relative error in \\texttt{CompDeCasteljau3}\n(Algorithm~\\ref{alg:k-comp-de-casteljau} with \\(K = 3\\))\nis \\(\\bigO{\\mach}\\) until \\(\\cond{p, s}\\) reaches\n\\(1 / \\mach^2\\) at which point the relative error increases linearly\nto \\(\\bigO{1}\\) when \\(\\cond{p, s}\\) reaches \\(1 / \\mach^3\\)\nand the relative error in \\texttt{CompDeCasteljau4}\n(Algorithm~\\ref{alg:k-comp-de-casteljau} with \\(K = 4\\))\nis \\(\\bigO{\\mach}\\) until \\(\\cond{p, s}\\) reaches\n\\(1 / \\mach^3\\) at which point the relative error increases linearly\nto \\(\\bigO{1}\\) when \\(\\cond{p, s}\\) reaches \\(1 / \\mach^4\\).\n\n\\section{Future Work}\n\nThe family of algorithms described in this paper have been implemented in\nC, C++ and Python by the author (\\cite{KCompensatedGitHub}). A more complete\ncompensated algorithms library (similar to \\cite{Barrio2018}) could be quite\nuseful. For example, such a library could include the algorithms in the\nexisting literature such as the \\(K\\)-compensated algorithm for Horner's method\nfrom \\cite{Graillat2009}.\n\n\\section{Acknowledgements}\n\nThe author would like to thank \\cite{Ogita2005}, \\cite{Graillat2009} and\n\\cite{Jiang2010} for their papers that motivated this work. In particular,\nthe work of \\cite{Ogita2005} reignited the path to compensated algorithms set\nforth in \\cite{Babuska1968}, \\cite{Knuth1969} and \\cite{Dekker1971}.\n\n%% H/T: https://tex.stackexchange.com/a/137379/32270\n\\section*{\\refname}\n\\bibliography{paper}\n\n\\appendix\n\n\\section{Algorithms}\\label{sec:appendix-algo}\n\nFind here concrete implementation details on the EFTs described\nin Theorem~\\ref{thm:eft}. They do not use branches, nor access to the\nmantissa that can be time-consuming.\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{EFT of the sum of two floating point numbers.}}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\left[S, \\sigma\\right] = \\mathtt{TwoSum}\\)}{$a, b$}\n      \\State \\(S = a \\oplus b\\)\n      \\State \\(z = S \\ominus a\\)\n      \\State \\(\\sigma = (a \\ominus (S \\ominus z)) \\oplus (b \\ominus z)\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent In order to avoid branching to check which among\n\\(\\left|a\\right|, \\left|b\\right|\\) is largest, \\texttt{TwoSum} uses 6 flops\nrather than 3.\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{Splitting of a floating point number into two parts.}}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\left[h, \\ell\\right] = \\mathtt{Split}\\)}{$a$}\n      \\State \\(z = a \\otimes (2^r + 1)\\)\n      \\State \\(h = z \\ominus (z \\ominus a)\\)\n      \\State \\(\\ell = a \\ominus h\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent For IEEE-754 double precision floating point number, \\(r = 27\\)\nso \\(2^r + 1\\) will be known before \\texttt{Split} is called. In all,\n\\texttt{Split} uses 4 flops.\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{EFT of the product of two floating point numbers.}}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\left[P, \\pi\\right] = \\mathtt{TwoProd}\\)}{$a, b$}\n      \\State \\(P = a \\otimes b\\)\n      \\State \\(\\left[a_h, a_{\\ell}\\right] = \\mathtt{Split}(a)\\)\n      \\State \\(\\left[b_h, b_{\\ell}\\right] = \\mathtt{Split}(b)\\)\n      \\State \\(\\pi = a_{\\ell} \\otimes b_{\\ell} \\ominus (((P \\ominus\n          a_h \\otimes b_h)\n          \\ominus a_{\\ell} \\otimes b_h) \\ominus a_h \\otimes b_{\\ell})\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent This implementation of \\texttt{TwoProd} requires 17 flops.\nFor processors that provide a fused-multipy-add operator (\\texttt{FMA}),\n\\texttt{TwoProd} can be rewritten to use only 2 flops:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{EFT of the sum of two floating point numbers with a FMA.}}\n  \\label{alg:two-prod-fma}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\left[P, \\pi\\right] = \\mathtt{TwoProdFMA}\\)}{$a, b$}\n      \\State \\(P = a \\otimes b\\)\n      \\State \\(\\pi = \\mathtt{FMA}(a, b, -P)\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent The following algorithms from \\cite{Ogita2005} can be used as a\ncompensated method for computing a sum of numbers. The first is a vector\ntransformation that is used as a helper:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{Error-free vector transformation for summation.}}\n  \\label{alg:vec-sum}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\mathtt{VecSum}\\)}{$p$}\n      \\State \\(n = \\texttt{length}(p)\\)\n      \\For{\\(j = 2, \\ldots, n\\)}\n        \\State \\(\\left[p_j, p_{j - 1}\\right] = \\mathtt{TwoSum}\\left(\n            p_j, p_{j - 1}\\right)\\)\n      \\EndFor\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent The second (\\texttt{SumK}) computes a sum with results that are as\naccurate as if computed in \\(K\\) times the working precision. It requires\n\\((6K - 5)(n - 1)\\) floating point operations.\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{Summation as in K-fold precision by \\((K - 1)\\)-fold error-free vector transformation.}}\n  \\label{alg:sum-k}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\mathtt{result} = \\mathtt{SumK}\\)}{$p, K$}\n      \\For{\\(j = 1, \\ldots, K - 1\\)}\n        \\State \\(p = \\mathtt{VecSum}(p)\\)\n      \\EndFor\n      \\State \\(\\mathtt{result} = p_1 \\oplus p_2 \\oplus \\cdots \\oplus p_n\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\noindent Since the final error \\(\\cdb{K - 1}\\) will not track the errors\nduring computation, we have a non-EFT version of\nAlgorithm~\\ref{alg:local-error-eft}:\n\n\\begin{breakablealgorithm}\n  \\caption{\\textit{Compute the local error (non-EFT).}}\n  \\label{alg:local-error}\n\n  \\begin{algorithmic}\n    \\Function{\\(\\widehat{\\ell} =\n        \\mathtt{LocalError}\\)}{$e, \\rho, \\delta b$}\n      \\State \\(L = \\texttt{length}(e)\\)\n      \\\\\n      \\State \\(\\widehat{\\ell} = e_1 \\oplus e_2\\)\n      \\For{\\(j = 3, \\ldots, L\\)}\n        \\State \\(\\widehat{\\ell} = \\widehat{\\ell} \\oplus e_j\\)\n      \\EndFor\n      \\\\\n      \\State \\(\\widehat{\\ell} = \\widehat{\\ell} \\oplus \\left(\n          \\rho \\otimes \\delta b\\right)\\)\n    \\EndFunction\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\n\\section{Proof Details}\\label{sec:appendix-proof-details}\n\n\\begin{proof}[Proof of Lemma~\\ref{lemma:ell-tilde}]\nWe'll start with the \\(F = 1\\) case. Recall where the terms originate:\n\\begin{align}\n\\left[P_1, e_1\\right] &= \\mathtt{TwoProd}\\left(\\widehat{r},\n  \\widehat{b}_j^{(k + 1)}\\right) \\\\\n\\left[P_2, e_2\\right] &= \\mathtt{TwoProd}\\left(s,\n  \\widehat{b}_{j + 1}^{(k + 1)}\\right) \\\\\n\\left[\\widehat{b}_j^{(k)}, e_3\\right] &= \\mathtt{TwoSum}\\left(P_1, P_2\\right).\n\\end{align}\nHence Theorem~\\ref{thm:eft} tells us that\n\\begin{align}\n\\left|P_1\\right| &\\leq (1 + \\mach)\\left|\\widehat{r} \\cdot\n  \\widehat{b}_j^{(k + 1)}\\right| \\leq (1 + \\mach)^2 (1 - s)\n  \\left|\\widehat{b}_j^{(k + 1)}\\right| \\\\\n\\left|e_1\\right| &\\leq \\mach \\left|\\widehat{r} \\cdot\n  \\widehat{b}_j^{(k + 1)}\\right| \\leq \\mach(1 + \\mach)(1 - s) \\left|\n  \\widehat{b}_j^{(k + 1)}\\right| \\\\\n\\left|P_2\\right| &\\leq (1 + \\mach) s \\left|\\widehat{b}_{j + 1}^{(k + 1)}\\right| \\\\\n\\left|e_2\\right| &\\leq \\mach s \\left|\\widehat{b}_{j + 1}^{(k + 1)}\\right| \\\\\n\\left|e_3\\right| &\\leq \\mach \\left|P_1\\right| + \\mach\\left|P_2\\right| \\\\\n\\left|\\rho \\cdot \\widehat{b}_j^{(k + 1)}\\right| &\\leq\n(1 + \\mach)(1 - s) \\left|\\widehat{b}_j^{(k + 1)}\\right|.\n\\end{align}\nIn general, we can swap \\(\\mach\\left|P_j\\right|\\) for\n\\((1 + \\mach)\\left|e_j\\right|\\) based on how closely related the bound\non the result and the bound on the error are. Thus\n\\begin{align}\n\\widetilde{\\ell}_{1, j}^{(k)} &= \\left|e_1\\right| + \\left|e_2\\right| +\n  \\left|e_3\\right| + \\left|\\rho \\cdot \\widehat{b}_j^{(k + 1)}\\right| \\\\\n&\\leq (2 + \\mach)\\left(\\left|e_1\\right| + \\left|e_2\\right|\\right) +\n  (1 + \\mach)(1 - s) \\left|\\widehat{b}_j^{(k + 1)}\\right| \\\\\n&\\leq \\left[(1 + \\mach)^3 - 1\\right] (1 - s) \\left|\n  \\widehat{b}_j^{(k + 1)}\\right| + \\left[(1 + \\mach)^2 - 1\\right] s \\left|\n  \\widehat{b}_{j + 1}^{(k + 1)}\\right| \\\\\n&\\leq \\gamma_3 \\left((1 - s) \\left|\\widehat{b}_j^{(k + 1)}\\right| +\n  s \\left|\\widehat{b}_{j + 1}^{(k + 1)}\\right|\\right).\n\\end{align}\nFor \\(\\widetilde{\\ell}_{F + 1}\\), we want to relate the ``current'' errors\n\\(e_1, \\ldots, e_{5F + 3}\\) to the ``previous'' errors \\(e_1',\n\\ldots, e_{5F - 2}'\\) that show up in \\(\\widetilde{\\ell}_F\\). In the same\nfashion as above, we track where the current errors come from:\n\\begin{align}\n\\left[S_1, e_1\\right] &= \\mathtt{TwoSum}\\left(e_1', e_2'\\right) \\\\\n\\left[S_2, e_2\\right] &= \\mathtt{TwoSum}\\left(S_1, e_3'\\right) \\\\\n&\\mathrel{\\makebox[\\widthof{=}]{\\vdots}} \\nonumber \\\\\n\\left[S_{5F - 3}, e_{5F - 3}\\right] &=\n  \\mathtt{TwoSum}\\left(S_{5F - 4}, e_{5F - 2}'\\right) \\\\\n\\left[P_{5F - 2}, e_{5F - 2}\\right] &= \\mathtt{TwoProd}\\left(\\rho,\n  \\cdb{F - 1}_j^{(k + 1)}\\right) \\\\\n\\left[\\widehat{\\ell}_{F, j}^{(k)}, e_{5F - 1}\\right] &=\n  \\mathtt{TwoSum}\\left(S_{5F - 3}, P_{5F - 2}\\right) \\\\\n\\left[P_{5F}, e_{5F}\\right] &= \\mathtt{TwoProd}\\left(s,\n  \\cdb{F}_{j + 1}^{(k + 1)}\\right) \\\\\n\\left[S_{5F + 1}, e_{5F + 1}\\right] &=\n  \\mathtt{TwoSum}\\left(\\widehat{\\ell}_{F, j}^{(k)}, P_{5F}\\right) \\\\\n\\left[P_{5F + 2}, e_{5F + 2}\\right] &= \\mathtt{TwoProd}\\left(\\rho,\n  \\cdb{F}_j^{(k + 1)}\\right) \\\\\n\\left[\\cdb{F}_j^{(k)}, e_{5F + 3}\\right] &= \\mathtt{TwoSum}\\left(\n  S_{5F + 1}, P_{5F + 2}\\right).\n\\end{align}\nArguing as we did above, we start with\n\\(\\left|e_1\\right| \\leq \\mach \\left|e_1'\\right| + \\mach \\left|e_2'\\right|\\)\nand build each bound recursively based on the previous, e.g.\n\\(\\left|e_2\\right| \\leq \\mach \\left|S_1\\right| + \\mach \\left|e_3'\\right| \\leq\n(1 + \\mach) \\mach \\left|e_1'\\right| + (1 + \\mach) \\mach \\left|e_2'\\right| +\n\\mach \\left|e_3'\\right|\\). Proceeding in this fashion, we find\n\\begin{align}\n\\widetilde{\\ell}_{F + 1, j}^{(k)} &= \\left|e_1\\right| + \\cdots +\n  \\left|e_{5F + 3}\\right| + \\left|\\rho \\cdot \\cdb{F}_j^{(k + 1)}\\right| \\\\\n&\\leq \\gamma_{5F} \\left|e_1'\\right| + \\gamma_{5F} \\left|e_2'\\right| +\n  \\gamma_{5F - 1} \\left|e_3'\\right| + \\cdots +\n  \\gamma_4 \\left|e_{5F - 2}'\\right| +\n  \\gamma_4 \\left|\\rho \\cdot \\cdb{F - 1}_j^{(k + 1)}\\right| \\\\\n&\\qquad + \\gamma_3 (1 - s) \\left|\n  \\cdb{F}_j^{(k + 1)}\\right| + \\gamma_3 s \\left|\n  \\cdb{F}_{j + 1}^{(k + 1)}\\right| \\\\\n&\\leq \\gamma_3 \\left(\n  (1 - s) \\left|\\cdb{F}_j^{(k + 1)}\\right| +\n  s \\left|\\cdb{F}_{j + 1}^{(k + 1)}\\right|\\right) +\n  \\gamma_{5F} \\cdot \\widetilde{\\ell}_{F, j}^{(k)}\n\\end{align}\nas desired.\n\\end{proof}\n\n\\begin{proof}[Proof of Lemma~\\ref{lemma:L-and-D-bounds}]\\label{proof:L-and-D-bounds}\nFirst, note that for \\textbf{any} sequence \\(v_0, \\ldots, v_{k + 1}\\) we\nmust have\n\\begin{equation}\n\\sum_{j = 0}^k \\left[(1 - s) v_j + s v_{j + 1}\\right] B_{j, k}(s) =\n\\sum_{j = 0}^{k + 1} v_j B_{j, k + 1}(s).\n\\end{equation}\nFor example of this in use, via \\eqref{ell-tilde-1}, we have\n\\begin{equation}\n  L_{1, k} \\leq \\gamma_3 \\sum_{j = 0}^{k + 1} \\left|\n  \\widehat{b}_j^{(k + 1)}\\right| B_{j, k + 1}(s).\n\\end{equation}\nIn order to work with sums of this form, we define Bernstein-type\nsums related to \\(L_{F, k}\\):\n\\begin{align}\nD_{0, k} &\\coloneqq \\sum_{j = 0}^k \\left|\\widehat{b}_j^{(k)}\\right|\nB_{j, k}(s) \\\\\nD_{F, k} &\\coloneqq \\sum_{j = 0}^k \\left|\\cdb{F}_j^{(k)}\\right| B_{j, k}(s).\n\\end{align}\nHence Lemma~\\ref{lemma:ell-tilde} gives\n\\begin{align}\nL_{1, k} &\\leq \\gamma_3 D_{0, k + 1} \\label{ell-1-k} \\\\\nL_{F + 1, k} &\\leq \\gamma_3 D_{F, k + 1} + \\gamma_{5F} L_{F, k}\n\\label{ell-F-k}\n\\end{align}\nIn addition, for \\(F \\geq 1\\) since\n\\begin{align}\n\\cdb{F}_j^{(k)} &= \\widehat{\\ell}_{F, j}^{(k)} \\oplus \\left(\n  s \\otimes \\cdb{F}_{j + 1}^{(k + 1)}\\right) \\oplus \\left((1 \\ominus s) \\otimes\n  \\cdb{F}_{j}^{(k + 1)}\\right) \\\\\n&= (1 - s) \\cdot \\cdb{F}_j^{(k + 1)}(1 + \\theta_3) +\n  s \\cdot \\cdb{F}_{j + 1}^{(k + 1)}(1 + \\theta_3) +\n  \\widehat{\\ell}_{F, j}^{(k)} (1 + \\theta_2)\n\\end{align}\nwe have\n\\begin{equation}\\label{df-first}\nD_{F, k} \\leq (1 + \\gamma_3) D_{F, k + 1} + (1 + \\gamma_2) \\sum_{j = 0}^k\n\\left|\\widehat{\\ell}_{F, j}^{(k)}\\right| B_{j, k}(s).\n\\end{equation}\nSince \\(\\ell_{F, j}^{(k)}\\) has \\(5F - 1\\) terms (only the last of which\ninvolves a product), the terms in the computed value will be involved in\nat most \\(5F - 2\\) flops, hence\n\\(\\left|\\widehat{\\ell}_{F, j}^{(k)}\\right| \\leq\n\\left(1 + \\gamma_{5F - 2}\\right) \\widetilde{\\ell}_{F, j}^{(k)}.\\)\nCombined with \\eqref{df-first} and the fact that there is no local error\nwhen \\(F = 0\\), this means\n\\begin{align}\nD_{0, k} &\\leq (1 + \\gamma_3) D_{0, k + 1} \\label{d-0-k} \\\\\nD_{F, k} &\\leq (1 + \\gamma_3) D_{F, k + 1} + (1 + \\gamma_{5F}) L_{F, k}.\n\\label{d-F-k}\n\\end{align}\nThe four inequalities \\eqref{ell-1-k}, \\eqref{ell-F-k}, \\eqref{d-0-k}\nand \\eqref{d-F-k} allow us to write all bounds in terms of\n\\(D_{0, n} = \\widetilde{p}(s)\\) and \\(D_{F, n} = 0\\). From \\eqref{d-0-k}\nwe can conclude that \\(D_{0, n - k} \\leq \\left(1 + \\gamma_{3k}\\right) \\cdot\n\\widetilde{p}(s)\\) and from \\eqref{ell-1-k} that \\(L_{1, n - k} \\leq\n\\gamma_3 \\left(1 + \\gamma_{3(k - 1)}\\right) \\cdot \\widetilde{p}(s)\\).\n\nTo show the bounds for higher values of \\(F\\), we'll assume we have\nbounds of the form\n\\(D_{F, n - k} \\leq \\left(q_F(k) \\mach^F + \\bigO{\\mach^{F + 1}}\\right) \\cdot\n\\widetilde{p}(s)\\) and\n\\(L_{F, n - k} \\leq \\left(r_F(k) \\mach^F + \\bigO{\\mach^{F + 1}}\\right) \\cdot\n\\widetilde{p}(s)\\) for two families of polynomials \\(q_F(k), r_F(k)\\). We\nhave \\(q_0(k) = 1\\) and \\(r_1(k) = 3\\) as our base cases and can build from\nthere. To satisfy \\eqref{d-F-k}, we'd like\n\\(q_F(k) = q_F(k - 1) + r_F(k)\\)\nand for \\eqref{ell-F-k}\n\\(r_{F + 1}(k) = 3 q_F(k - 1) + 5 F r_F(k)\\).\nSince the forward difference \\(\\Delta q_F(k) = r_F(k + 1)\\) is known,\nwe can inductively solve for \\(q_F\\) in terms of \\(q_F(0)\\). But\n\\(D_{F, n} = 0\\) gives \\(q_F(0) = 0\\).\n\nFor example, since we have \\(r_1(k) = 3 \\binom{k}{0}\\) we'll have\n\\(q_1(k) = 3 \\binom{k}{1}\\). Once this is known\n\\begin{equation}\nr_2(k) = 3 q_1(k - 1) + 5 r_1(k) = 3 \\cdot 3 \\binom{k - 1}{1} +\n5 \\cdot 3 \\binom{k}{0} = 9 \\binom{k}{1} + 6 \\binom{k}{0}.\n\\end{equation}\nIf we write these polynomials in the ``falling factorial'' basis of\nforward differences, then we can show that\n\\begin{equation}\nr_F(k) = 3^F \\binom{k}{F} + \\cdots\n\\end{equation}\nwhich will complete the proof of the first inequality. To see this, first\nnote that for a polynomial in this basis\n\\(f(k) = A \\binom{k}{d} + B \\binom{k}{d - 1} + C \\binom{k}{d - 2} +\nD \\binom{k}{d - 3} + \\cdots\\) we have\n\\begin{align}\nf(k + 1) &= A \\binom{k}{d} + (A + B) \\binom{k}{d - 1} +\n  (B + C) \\binom{k}{d - 2} + (C + D) \\binom{k}{d - 3} + \\cdots \\\\\nf(k - 1) &= A \\binom{k}{d} + (B - A) \\binom{k}{d - 1} +\n  (C - B + A) \\binom{k}{d - 2} + (D - C + B - A) \\binom{k}{d - 3} + \\cdots\n\\end{align}\nUsing these, we can show that if\n\\(r_F(k) = \\sum_{j = 0}^{F - 1} c_j \\binom{k}{j}\\) then\n\\begin{align}\nq_F(k) &= c_{F - 1} \\binom{k}{F} + \\sum_{j = 1}^{F - 1}\n  (c_j + c_{j - 1}) \\binom{k}{j} \\\\\nr_{F + 1}(k) &= 3 \\left[-c_0 \\binom{k}{0} +\n  \\sum_{j = 1}^F c_{j - 1} \\binom{k}{j}\\right] +\n5F \\left[\\sum_{j = 0}^{F - 1} c_j \\binom{k}{j}\\right] =\n3 c_{F - 1} \\binom{k}{F} + \\cdots\n\\end{align}\nUnder the inductive hypothesis \\(c_{F - 1} = 3^F\\) so that\nthe lead term in \\(r_{F + 1}(k)\\) is \\(3 c_{F - 1} \\binom{k}{F}\n= 3^{F + 1} \\binom{k}{F}\\).\n\nFor the second inequality, we'll show that\n\\begin{equation}\n\\sum_{k = 0}^{n - 1} \\gamma_{3k + 5F} L_{F, k} \\leq\n  \\left[q_{F + 1}(n) \\mach^{F + 1} +\n  \\bigO{\\mach^{F + 2}}\\right] \\cdot \\widetilde{p}(s)\n\\end{equation}\nand then we'll have our result since we showed above that\n\\(q_{F + 1}(n) = 3^{F + 1} \\binom{n}{F + 1} + \\bigO{n^F}\\). Since\n\\(\\gamma_{3k + 5F} L_{F, k} \\leq (3k + 5F) L_{F, k} \\mach +\n\\bigO{\\mach^{F + 2}} \\widetilde{p}(s)\\) it's enough to consider\n\\begin{equation}\n\\sum_{k = 0}^{n - 1} (3k + 5F) r_F(n - k) =\n\\sum_{k = 1}^n (3(n - k) + 5F) r_F(k).\n\\end{equation}\nSince \\(q_F(k) = q_F(k - 1) + r_F(k)\\) and \\(q_F(0) = 0\\) we have\n\\(q_{F}(n) = \\sum_{k = 1}^n r_{F}(k)\\) thus\n\\begin{equation}\nq_{F + 1}(n) = \\sum_{k = 1}^n r_{F + 1}(k)\n= \\sum_{k = 1}^n 3 q_F(k - 1) + 5 F r_F(k)\n= \\sum_{k = 1}^n 3 \\left[\\sum_{j = 1}^{k - 1} r_F(j)\\right] + 5 F r_F(k).\n\\end{equation}\nSwapping the order of summation and grouping like terms, we have our\nresult.\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "978aa4dffd4508f92cdfbf8d33301ec5d1af39b9", "size": 61979, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/paper.tex", "max_stars_repo_name": "dhermes/k-compensated-de-casteljau", "max_stars_repo_head_hexsha": "8511f0c2c525ac24215f6307e80032329f97301d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-22T15:45:20.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-03T07:56:01.000Z", "max_issues_repo_path": "doc/paper.tex", "max_issues_repo_name": "dhermes/k-compensated-de-casteljau", "max_issues_repo_head_hexsha": "8511f0c2c525ac24215f6307e80032329f97301d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/paper.tex", "max_forks_repo_name": "dhermes/k-compensated-de-casteljau", "max_forks_repo_head_hexsha": "8511f0c2c525ac24215f6307e80032329f97301d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.0767141887, "max_line_length": 126, "alphanum_fraction": 0.6302457284, "num_tokens": 23841, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.43656678601832916}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n      \\subsection{lossHinge.m}\n\n\\begin{par}\n\\textbf{Summary:} Function to compute the moments and derivatives of the loss of a Gaussian distributed point under a double hinge loss function. The loss function has slope -/+a and corners b1 and b2. The function also calculates derivatives of the loss w.r.t. the state distribution.\n\\end{par} \\vspace{1em}\n\\begin{par}\nGraph:          \\ensuremath{\\backslash}                   /           \\ensuremath{\\backslash}                 /            \\ensuremath{\\backslash}               /             \\ensuremath{\\backslash}\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_/             b1           b2\n\\end{par} \\vspace{1em}\n\\begin{par}\nTo use a single hinge b1 or b2 can be set to -Inf or +Inf respectively.\n\\end{par} \\vspace{1em}\n\\begin{par}\nNote, this function is only analytic for 1D inputs. To apply this loss function to multiple variables, use the lossAdd function.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}function [L dLdm dLds S dSdm dSds C dCdm dCds dLdb] = lossHinge(cost, m, s)\\end{verbatim}\n\\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}cost\n  .fcn      @lossHinge - called to get here\n  .a        slope of loss function\n  .b        corner points of loss function                     [1   x    2 ]\nm             input mean                                       [D   x    1 ]\nS             input covariance matrix                          [D   x    D ]\\end{verbatim}\n\\begin{par}\n\\textbf{Output arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}L               expected loss                                  [1   x    1 ]\ndLdm            derivative of L wrt input mean                 [1   x    D ]\ndLds            derivative of L wrt input covariance           [1   x   D^2]\nS               variance of loss                               [1   x    1 ]\ndSdm            derivative of S wrt input mean                 [1   x    D ]\ndSds            derivative of S wrt input covariance           [1   x   D^2]\nC               inv(S) times input-output covariance           [D   x    1 ]\ndCdm            derivative of C wrt input mean                 [D   x    D ]\ndCds            derivative of C wrt input covariance           [D   x   D^2]\\end{verbatim}\n\\begin{par}\nCopyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.\n\\end{par} \\vspace{1em}\n\\begin{par}\nLast modified: 2013-03-06\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{High-Level Steps} \n\n\\begin{enumerate}\n\\setlength{\\itemsep}{-1ex}\n   \\item Expected cost\n   \\item Variance of cost\n   \\item inv(s)* cov(x,L)\n\\end{enumerate}\n\n\\begin{lstlisting}\nfunction [L dLdm dLds S dSdm dSds C dCdm dCds dLdb] = lossHinge(cost, m, s)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\nD = length(m);\nif D > 1;\n    error(['lossHinge only defined for 1D inputs, use lossAdd to '...\n                                     'concatenate multiple 1D loss functions']);\nend\n\na = cost.a;\nb = cost.b(:)' - m(:)'; I = ~isinf(b); % centralize\neb = exp(-b.^2/2/s); erfb = erf(b/sqrt(2*s));\nc = sqrt(s/pi/2);\n\n% 1. Expected Loss\n% int_{-inf}^{b1-m} -a*(x-b1+m)*N(0,S)  +  int_{b2-m}^inf a*(x-b2+m)*N(0,S)\nL = a*(b/2.*erfb + c*eb + b.*[1,-1]/2);\nL = sum(L(I));\n\nif nargout > 1\n    % Derivative w.r.t. m\n    dLdb = a/2*(erfb + [1,-1]);\n    dLdm = sum(dLdb(I)*-1);\n\n    % Derivative w.r.t. S\n    dc = 1/(2*sqrt(2*pi*s));\n    dLds = a*sum(eb)*dc;\nend\n\n% 2. Variance of Loss\nif nargout > 3\n    S = a^2*((b.^2+s).*(1+[1,-1].*erfb)/2 + [1,-1].*b*c.*eb);\n    S = sum(S(I)) - L^2;\n\n    erfbdm = -sqrt(2/pi/s)*eb; erfbds = -b.*eb/sqrt(2*pi*s^3);\n    dSdm = a^2*(-b.*(1+[1,-1].*erfb) + (b.^2+s).*[1,-1].*erfbdm/2 + ...\n                                                    [1,-1]*c.*eb.*(-1+b.^2/s));\n    dSdm = sum(dSdm(I)) - 2*L*dLdm;\n    dSds = a^2/2*((1+[1,-1].*erfb) + (b.^2+s).*[1,-1].*erfbds + ...\n                                   [2,-2].*b*dc.*eb + [1,-1].*b.^3/s^2*c.*eb);\n    dSds = sum(dSds(I)) - 2*L*dLds;\nend\n\n% 3. inv(s)* covariance between input and cost\nif nargout > 6\n   C = a*([-1 1] - erfb)/2;\n   C = sum(C);\n\n   dCdm = -a/2*sum(erfbdm);\n   dCds = -a/2*sum(erfbds(I));\nend\n\\end{lstlisting}\n", "meta": {"hexsha": "8d84e30b3e97f5a04aa9db810f11aff9d33b1711", "size": 4268, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/lossHinge.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/lossHinge.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/lossHinge.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 35.5666666667, "max_line_length": 285, "alphanum_fraction": 0.5388940956, "num_tokens": 1436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4365667860183291}}
{"text": "%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[english]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage{amsmath}\n\n\\makeatletter\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{babel}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\n\\title{Solving REXI}\n\n\n\\author{Martin Schreiber <M.Schreiber@exeter.ac.uk>, ADD YOURSELF IF YOU\nADD THINGS<cool@things.hell> et al.}\n\n\\maketitle\nThis document serves as the basis to understand and discuss various\nways how to solve the REXI approximation given by\n\\[\ne^{L}U_{0}\\approx\\sum_{i}\\beta_{i}(\\alpha_{i}+L)^{-1}U_{0}.\n\\]\n\n\n\n\\section{Problem formulation}\n\nExponential integrators provide a form to directly express the solution\nof a linear operator (non-linear operators are not considered in this\nwork). For a linear PDE given by\n\n\\[\nU_{t}=L(U)\n\\]\nwe can write \n\\[\nU(t)=e^{Lt}U(0).\n\\]\nFurthermore, assuming that the $L$ operator is skew-Hermitian - hence\nhas imaginary Eigenvalues only - we can write this as a Rational approximation\nof the EXponential Integrator (REXI)\n\n\\[\ne^{L}U_{0}\\approx\\sum_{n=-N}^{N}Re\\left(\\beta_{n}(\\alpha_{n}+L)^{-1}U_{0}\\right),\n\\]\nsee \\cite{Terry:High-order time-parallel approximation of evolution operators}.\nThis is the already simplified equation where the time step size $\\tau$\nis merged with $L$ which doesn't make a big difference here.\n\n\n\\section{Properties}\n\nWe will discuss properties and potential misunderstandings in the\nREXI approximation.\n\n\n\\subsection{REXI Coefficient properties}\n\nWith overbar denoting the complex conjugate, the coefficients in the\nREXI terms have the following properties:\n\n\\begin{equation}\n\\alpha_{-n}=\\bar{\\alpha}_{n}\\label{eq:alpha_conjugate_symmetry-1}\n\\end{equation}\n\n\n\\begin{equation}\n\\beta_{-n}=\\bar{\\beta}_{n}\\label{eq:beta_conjugate_symmetry}\n\\end{equation}\n\n\n\\begin{equation}\nIm(\\alpha_{0})=Im(\\beta_{0})=0\\label{eq:imaginary_a_b_zero}\n\\end{equation}\n\n\n\n\\subsection{Reduction of REXI terms}\n\nUsing the REXI coefficient properties we can almost half the terms\nof the sum to\n\n\\begin{equation}\ne^{L}U_{0}\\approx\\sum_{n=0}^{N}Re\\left(\\gamma_{n}(\\alpha_{n}+L)^{-1}U_{0}\\right)\\label{eq:rexi_formulation}\n\\end{equation}\nwith\n\\[\n\\gamma_{n}:=\\begin{cases}\n\\begin{array}{c}\n\\beta_{0}\\\\\n2\\beta_{n}\n\\end{array} & \\begin{array}{c}\nfor\\,n=0\\\\\nelse\n\\end{array}\\end{cases}\n\\]\nhence\n\n\\begin{equation}\n\\gamma_{-n}=\\bar{\\gamma}_{n}\\label{eq:gamma_conjugate_symmetry}\n\\end{equation}\n\n\n\n\\subsection{Reutilization of REXI terms for several coarse time steps}\n\n{[}Based on idea of Mike Ashworth{]}. Assuming that we're interested\nin all the solutions at coarse time stamps $T_{n}:=n\\Delta T$, is\nit possible to directly compute them by reutilizing the REXI terms\nof $T_{n<N}$ for $T_{N}$? Reusing REXI terms requires computing\nREXI terms with the same $\\alpha_{i}$ coefficients. Those alpha coefficients\nare computed with\n\n\\[\n\\alpha_{n}:=h(\\mu+i(m+k)).\n\\]\nHere, $h$ specifies the sampling accuracy, $m$ is related to the\nnumber of REXI terms and $k$ can be assumed constant and is related\nto the number of poles for the approximation of the Gaussian function.\nThis shows, that REXI terms can be indeed reused! However, we shall\nalso take the $\\beta$ terms into account to see if we can reuse the\nfirst partial sum. These $\\beta_{n}$ coefficients are given by \n\n\\[\n\\beta_{n}^{Re}:=h\\sum_{k=L_{1}}^{L_{2}}Re(b_{n-k})a_{k}\n\\]\nand\n\\[\nb_{m}=e^{-imh}e^{h^{2}}.\n\\]\nAll of these coefficients are constant for given $h$, but $L_{1/2}$\ndepend on all $a_{k}$ and hence the number of total REXI terms. Therefore,\nwe \\textbf{cannot directly reuse the result of the REXI sum }of the\nfirst coarse time step, \\textbf{but the results of solving the inverse\nproblem} - each one depending on different $\\alpha_{i}$.\n\nFuture work: Maybe a reformulation to reuse the previous sum reduction\nis possible.\n\n\n\\subsection{Real values of exponential integrators}\n\nObviously, only real values should be computed by the exponential\nintegrator $e^{L}.$ There could be the assumption that \\emph{REXI\nalso creates only real values with negligible imaginary values}. However,\nthis is not true! It holds that\n\\[\nIm\\left(\\lim_{N\\rightarrow\\infty}\\sum_{n=-N}^{N}\\left(\\beta_{n}(\\alpha_{n}+L)^{-1}U_{0}\\right)\\right)\\neq0.\n\\]\nNote, that here we didn't restrict the solution to real values as\nin \\eqref{eq:rexi_formulation}.\n\n\\textbf{@TERRY: TODO: The way how I derived $\\beta$ and $\\alpha$\nmight be different to your way but I think it's the same. Do you agree\nin the statement above?}\n\n\n\\section{Computing inverse of $(\\alpha+L)^{-1}$}\n\nIt was suggested \\cite{Terry:High-order time-parallel approximation of evolution operators}\nto use a reformulation of this linear operator which is based on an\nadvective shallow-water formulation to compute $\\eta(t+\\Delta t)$\nvia a Helmholtz problem and then solve for both velocity components\ndirecctly. However, this reformulation in an ODE-oriented way was\nonly possible with a constant Coriolis term. Here, we will also discuss\nMatrix formulations.\n\n\n\\subsection{Deriving Helmholtz problem for constant f SWE with matrix partitioning}\n\nWe can reformulate the SWE (see \\cite{Schreiber:Understanding REXI})\ninto the following formulation\n\\[\n((\\alpha^{2}+f^{2})-g\\bar{\\eta}\\Delta)\\eta=\\frac{f^{2}+\\alpha^{2}}{\\alpha}\\eta_{0}-\\bar{\\eta}\\delta_{0}-\\frac{f\\bar{\\eta}}{\\alpha}\\zeta_{0}.\n\\]\n\n\n\n\\subsubsection{Spectral elements:}\n\nFor spectral element methods, Gunnar's method was successfully applied\nto solve this.\n\n\n\\subsubsection{Spectral method:}\n\nFor spectral methods, we used a so-called fast Helmholtz solver to\ndirectly solve this very efficiently.\n\n\n\\subsection{Deriving Helmholtz problem for f-varying SWE with matrix partitioning}\n\nWe have to find a matrix-formulation of this reformulation. Following\nthe derivation in \\cite{Schreiber:Understanding REXI} we get the\nsystem of equations\n\n\\[\n((\\alpha^{2}+f^{2})-g\\bar{\\eta}\\Delta)\\eta=\\frac{f^{2}+\\alpha^{2}}{\\alpha}\\eta_{0}-\\bar{\\eta}\\delta_{0}-\\frac{f\\bar{\\eta}}{\\alpha}\\zeta_{0}\n\\]\nto solve for. Instead of treating every term in the linear operator\nas being scalar-like, we can a partitioning of the matrix making the\nlinear operator a diagonal matrix L\n\\begin{equation}\nL(U):=\\left(\\begin{array}{ccc}\n0 & -\\eta_{0}\\partial_{x} & -\\eta_{0}\\partial_{y}\\\\\n-g\\partial_{x} & 0 & F\\\\\n-g\\partial_{y} & -F & 0\n\\end{array}\\right)U\n\\end{equation}\nand all other operators itself also representing a matrix formulation.\nThe term $F$ is then the matrix with varying Coriolis effect\n\\[\nF:=\\left[\\begin{array}{ccccc}\ncos(\\theta_{0})\\\\\n & cos(\\theta_{1})\\\\\n &  & \\ldots\\\\\n &  &  & cos(\\theta_{N-1})\\\\\n &  &  &  & cos(\\theta_{N})\n\\end{array}\\right]\n\\]\nwith $N$ the size of the matrix. Then we write the system to solve\nfor as\n\n\\[\n((\\alpha^{2}+F^{2})-g\\bar{\\eta}\\Delta)\\eta=\\frac{F^{2}+\\alpha^{2}}{\\alpha}\\eta_{0}-\\bar{\\eta}\\delta_{0}-\\frac{F\\bar{\\eta}}{\\alpha}\\zeta_{0}.\n\\]\nNow the challenge is to solve for this system of equations with the\nvarying terms in the $F$ matrix. The $F^{2}$ terms lead to longitude-constant\n$\\cos^{2}(\\theta)$ terms.\n\n\n\\subsubsection{Spectral elements method:}\n\nFor spectral element methods, Gunnar's method could be applied to\nsolve this.\n\n\n\\subsubsection{Spectral methods:}\n\nUsing spectral space, applying this term could basically mean to shift\na solution to a different spectrum. This could allow developing a\ndirect solver for it in spectral space. The real-to-real Fourier transformations\nresults in $\\cos$-only eigenfunctions and could be appropriate for\nthis. \\textbf{{[}TODO: Just a sketch. Seems to be good to be true,\nhence probably wrong{]}.}\n\n\n\\subsection{Hybridization for SWE}\n\nThis is related to Colin's idea and is based on writing down the entire\nformulation in its discretized way, hence before applying solver reformulations\nas done in the previous section.\n\nBefore doing any analytical reformulations it discretizes the equations\nfirst (e.g. on a C-grid) and then works on this reformulation.\n\nThis focuses on maintaining the conservative properties (e.g. avoiding\ncomputational modes) first and then to solve it.\n\n{[}TODO: Awesome formulation of hybridization on C-grid{]}\n\n\n\\subsection{Iterative solver with complex values}\n\nA straight-forward approach is to use an iterative solver which supports\ncomplex values. This means that $(\\alpha+L)U=U_{0}$ is solved directly\nand that's it if we could use already existing solvers.\n\n\n\\subsection{Reformulation to real-valued solver}\n\nThe complex-valued iterative system for $(\\alpha+L)U=U_{0}$ can be\nreformulated to a real valued system by treating real and imaginary\nparts separately. This is based on splitting up $U=Re(U)+i\\,Im(U)=U^{R}+i\\,U^{I}$\n(see also notes from Terry and Pedro). Similarly, we use $\\alpha=Re(\\alpha)+i\\,Im(\\alpha)=\\alpha^{R}+i\\alpha^{I}$.\nThen the complex system of equations $(\\alpha+L)\\,U=U_{0}$ can be\nwritten as\n\\[\n\\left[\\begin{array}{c|c}\nA^{R}+L & -A^{I}\\\\\n\\hline A^{I} & A^{R}+L\n\\end{array}\\right]\\left[\\begin{array}{c}\nU^{R}\\\\\nU^{I}\n\\end{array}\\right]=\\left[\\begin{array}{c}\nU_{0}^{R}\\\\\n0\n\\end{array}\\right]\n\\]\nwith $A$ a Matrix with $\\alpha$ values on the diagonal. Obviously,\nthe off-diagonal values in partitions given by $A^{I}$ are a pain\nin the neck for iterative solvers: they are varying depending on the\nnumber of REXI term. We again get a skew Hermitian matrix\\textbf{\n{[}TODO: Check the signs{]}}.\n\n\n\\subsection{Solving real and imaginary parts}\n\nWe can go one step further and generate a system of equations to solve\nby eliminating $U^{I}$. We first solve the 2nd line for $U^{I}$:\n\\[\nU^{I}=-(A^{R}+L)^{-1}A^{I}U^{R}.\n\\]\nPutting this in the 1st line\n\\[\n(A^{R}+L)U^{R}+A^{I}U^{I}=U_{0}^{R}\n\\]\nwe get\n\\[\n(A^{R}+L)U^{R}+A^{I}(A^{R}+L)^{-1}A^{I}U^{R}=U_{0}^{R}.\n\\]\nSolving this for $U^{R}$, we get\n\\[\n\\left((A^{R}+L)+A^{I}(A^{R}+L)^{-1}A^{I}\\right)U^{R}=U_{0}^{R}.\n\\]\nInverting stuff is not nice and we multiply both sides from left side\nwith $(A^{R}+L)$ yielding the following equation:\n\n\\[\nU^{R}:\\,\\,\\left((A^{R}+L)^{2}-A^{I}A^{I}\\right)U^{R}=(A^{R}+L)U_{0}^{R}\n\\]\nWe are not finished yet, since we also need the imaginary components\nof $U$. The reason for this is that these components, once multiplied\nwith the imaginary component of $\\beta$, create real values. Solving\nthe 1st line for $U^{R}$ gives us\n\\[\nU^{R}=(A^{R}+L)^{-1}\\left(A^{I}U^{I}+U_{0}^{R}\\right)\n\\]\nPutting this in the 2nd line, we get\n\\begin{eqnarray*}\nA^{I}(A^{R}+L)^{-1}\\left(A^{I}U^{I}+U_{0}^{R}\\right)+(A^{R}+L)U^{I} & = & 0\\\\\nA^{I}(A^{R}+L)^{-1}\\left(A^{I}U^{I}\\right)+(A^{R}+L)U^{I} & = & -A^{I}(A^{R}+L)^{-1}U_{0}^{R}\\\\\nA^{I}A^{I}U^{I}+(A^{R}+L)^{2}U^{I} & = & -A^{I}U_{0}^{R}\\\\\n\\end{eqnarray*}\n\n\n\\[\nU^{I}:\\,\\,\\,\\left(A^{I}A^{I}+(A^{R}+L)^{2}\\right)U^{I}=-A^{I}U_{0}^{R}\n\\]\n\n\nBoths things look quite ugly. However, this leads to another important\nproperty of PinTing. This allows sovling both contributions independent\nof each other. Hence, this would give us an additional degree of parallelization.\n\n\n\\subsection{Including $\\beta$ and solving for real values only}\n\nSo far we totally ignored the $\\beta$ coefficient in REXI. This forced\nus to also care about the imaginary-values solution $U^{I}$. If we\nwould be able to put it into the inverse computation, we might be\nable to compute only the real values. With $(AB)^{-1}=B^{-1}A^{-1}$\nwe can write \n\\[\n\\sum_{i}(\\beta_{i}^{-1})^{-1}(\\alpha_{i}+L)^{-1}U_{0}=\\sum_{i}(\\alpha_{i}\\beta_{i}^{-1}+L\\beta_{i}^{-1})^{-1}U_{0}.\n\\]\nWe formulate this term to\n\\[\n\\sum_{i}(\\alpha_{i}\\beta_{i}^{-1}+L\\beta_{i}^{-1})^{-1}U_{0}\n\\]\nwith $\\beta_{i}^{-1}\\alpha_{i}$ again complex valued and $L\\beta_{i}^{-1}$\nthe linear operator scaled by $\\beta_{i}^{-1}$, hence also containing\nreal and complex values. We can now apply the same strategy as before\nby eliminating $U^{I}$ and solve for $U^{R}$. Let \n\\[\nM^{R}=Re(\\alpha_{i}\\beta_{i}^{-1}+L\\beta_{i}^{-1})\n\\]\nand\n\n\\[\nM^{I}=Im(\\alpha_{i}\\beta_{i}^{-1}+L\\beta_{i}^{-1}).\n\\]\nThis yields the SoE\n\\[\n\\left[\\begin{array}{c|c}\nM^{R} & -M^{I}\\\\\n\\hline M^{I} & M^{R}\n\\end{array}\\right]\\left[\\begin{array}{c}\nU^{R}\\\\\nU^{I}\n\\end{array}\\right]=\\left[\\begin{array}{c}\nU_{0}^{R}\\\\\n0\n\\end{array}\\right]\n\\]\nand further \n\\[\nU^{I}=\\left(M^{R}\\right)^{-1}\\left(-M^{I}U^{R}\\right).\n\\]\nPutting this in 1st line yields\n\\[\nM^{R}U^{R}+M^{I}\\left(M^{R}\\right)^{-1}M^{I}U^{R}=U_{0}^{R}\n\\]\n\\[\n\\left(M^{R}+M^{I}\\left(M^{R}\\right)^{-1}M^{I}\\right)U^{R}=U_{0}^{R}\n\\]\nWe can also write\n\n\\[\n\\left(I+\\left(\\left(M^{R}\\right)^{-1}M^{I}\\right)^{2}\\right)U^{R}=\\left(M^{R}\\right)^{-1}U_{0}^{R}\n\\]\nNow the big question arises what $\\left(\\left(M^{R}\\right)^{-1}M^{I}\\right)$\nis. Seems like computing the time step tendencies $L(U)$ with different\nconstant contributions given by the shifted poles.\n\n\n\\section{Interpreting $M^{R/I}$ and $(\\alpha+L)^{-1}$ terms}\n\n\\textbf{{[}TODO: Here we assuming that the previous reformulations\nare really possible and there are probably a lot of bugs in it{]}.}\n\nWe like to get insight in the meaning of the terms \n\\[\n\\left(M^{R}\\right)^{-1}M^{I}\n\\]\n\n\nBoth terms only consist out of a real formulation and should be summarized\nhere as\n\\[\n(a+bL)\n\\]\nwith $a$ a real-valued constant which is e.g. given by $Re(\\alpha_{i}\\beta_{i}^{-1})$\nand $bL$ the linear operator $L$ scaled by a real-valued scalar\n$b$.\n\n{[}10 minute brainstorming with John T.{]}\n\n$(a+bL)U$ can be interpreted as an explicit time stepping method.\n\n$(a+bL)^{-1}U$ can be interpreted as an implicit time stepping method.\n\nThe factors $a$ and $b$ can then be interpreted as scaling factors\nand time step sizes.\n\n\n\\section{Final notes}\n\nHave fun in reading this. Don't miss out all the errors! ;-)\n\\begin{thebibliography}{4}\n\\bibitem[4]{Schreiber:Understanding REXI}Understanding REXI\n\n\\bibitem{Schreiber:Formulations of the shallow-water equations}Formulations\nof the shallow-water equations, M. Schreiber, P. Peixoto et al.\n\n\\bibitem{Terry:High-order time-parallel approximation of evolution operators}High-order\ntime-parallel approximation of evolution operators, T. Haut et al.\n\n\\bibitem{Moler:Nineteen Dubious Ways to Compute the Exponential of a Matrix}Nineteen\nDubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years\nLater, Cleve Moler and Charles Van Loan, SIAM review\n\n\\bibitem{Damle:Near optimal rational approximations of large data sets}Near\noptimal rational approximations of large data sets, Damle, A., Beylkin,\nG., Haut, T. S. \\& Monzon\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "d544553615270d0ff6363cef3d2bcd3f63c8ffdf", "size": 14458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/rexi/strategies_for_solving_rexi_terms/solving_rexi_terms.tex", "max_stars_repo_name": "valentinaschueller/sweet", "max_stars_repo_head_hexsha": "27e99c7a110c99deeadee70688c186d82b39ac90", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2017-11-20T08:12:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-11T15:32:36.000Z", "max_issues_repo_path": "doc/rexi/strategies_for_solving_rexi_terms/solving_rexi_terms.tex", "max_issues_repo_name": "valentinaschueller/sweet", "max_issues_repo_head_hexsha": "27e99c7a110c99deeadee70688c186d82b39ac90", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-02-02T21:46:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-11T11:10:27.000Z", "max_forks_repo_path": "doc/rexi/strategies_for_solving_rexi_terms/solving_rexi_terms.tex", "max_forks_repo_name": "valentinaschueller/sweet", "max_forks_repo_head_hexsha": "27e99c7a110c99deeadee70688c186d82b39ac90", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-03-01T18:33:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T22:20:31.000Z", "avg_line_length": 31.1594827586, "max_line_length": 140, "alphanum_fraction": 0.7044542814, "num_tokens": 4654, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.4365667794125081}}
{"text": "\\def\\pathToRoot{../../}\n\\def\\DLbook{https://www.deeplearningbook.org/}\n\\def\\LAchapter{https://www.deeplearningbook.org/contents/linear_algebra.html}\n\\def\\post{https://towardsdatascience.com/linear-algebra-for-deep-learning-f21d7e7d7f23}\n\\input{HW1/mainheader}\n\\input{HW1/uebungsheader}\n\\def\\issolution{}\n\n\n\\begin{document}\n\n% {Sheet number}{headline}{deadline}\n\\exercisehead{1}{Linear Algebra Basics}{17.11.2020, 23:59}\n\n\\section*{Instructions}\n\nA good understanding of linear algebra is essential for understanding and working with many machine learning algorithms, especially deep learning algorithms.\nThe purpose of the following exercises is to create the base for understanding concepts and algorithms introduced in the following lectures.\n\nThe exercises are based on the \\href{\\post}{\\textit{Basic Linear Algebra for Deep Learning} post} by Niklas Donges and the \\href{\\LAchapter}{\\textit{Linear Algebra} chapter} in the \\href{\\DLbook}{\\textit{Deep Learning} book} by Ian Goodfellow, Yoshua Bengio and Aaron Courville.\n\n\\section*{Exercises}\n\n\\begin{exercise}[Mathematical objects][1]\n Consulting \\href{\\post}{Niklas's post} or \\href{\\LAchapter}{Deep Learning book}, give short definitions and your own examples.\n \n Note the conventional way to define different mathematical objects (you can find them in the \\href{\\LAchapter}{DL book}), e.g. we write scalars in italics and usually give them lowercase variable names.\n Throughout all the assignments (and of course outside of this course) stick to the conventional way of writing scalars, vectors etc\\footnote{See how to make letters bold in LaTex math mode  \\href{https://tex.stackexchange.com/questions/14395/bold-italic-vectors}{here}.}.\n \n \\begin{enumerate}\n     \\item scalar\n     \\item vector\n     \\item matrix\n     \\item tensor\n \\end{enumerate}\n\n\\end{exercise}\n\n\n\\begin{solution}\n   % write the solution here\n   \\color{blue}\n   \\begin{enumerate}\n       \\item A \\textbf{scalar} is just a single number. We write scalars in italics and usually give them lowercase variable names.\n        \\math\n        s \\in R , s = 0.2\n        \\endmath\n\n        \\item A \\textbf{vector} is an ordered array of numbers. Typically we give vectors lowercase names in bold typeface. The elements of the vector are identified by writing its name in italic typeface.\n        \\math\n            \\textbf{x} = \\begin{bmatrix}\n            x_1 & x_2 & x_3\n            \\end{bmatrix}\n        \\endmath\n\n        \\item A \\textbf{matrix} is a 2-D array of numbers, where each element is identiﬁed by indices instead of just one. We usually give matrices uppercase variable names with bold typeface, such as \\textbf{A}. The elements of the matrix are identified by writing its name in italic typeface.\n\n        \\math\n            \\textbf{A} = \\begin{bmatrix}\n            x_1 & x_2 & x_3 \\\\\n            x_4 & x_5 & x_6 \\\\\n            x_7 & x_8 & x_9\n            \\end{bmatrix}\n        \\endmath\n\n\n        \\item A \\textbf{tensor} is an array of numbers, arranged on a regular grid, with a variable number of axes. A tensor has three indices, where the first one points to the row, the second to the column and the third one to the axis. We denote a tensor named “A” with this typeface: A.\n        \n        We identify the element of A at coordinates $ (i,j,k)$  by writing  $ \\textbf{A}_{i,j,k}$.\n\n \\end{enumerate}\n\\end{solution}\n\n\\begin{exercise}[Vectors in machine learning][2]\n\nIn machine learning we deal with data in multidimensional space.\nEach data point is characterised by a number of features: for example, a lecture can be characterised by the number of CoLi students, CS students and students from other departments (i.e. 3 features).\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{figures/vectors.png}\n    \\caption{Different vector representations. Note: those are not representations of the same vector}\n    \\label{fig:vector_representations}\n\\end{figure}\n\n\\begin{enumerate}\n\\item Create your own data set of \\textbf{three} data points where each data point is described by \\textbf{two} features.\nReport:\n    \\begin{enumerate}\n        \\item what are the data points in your data set (e.g. lectures);\n        \\item what are the features of the data points (e.g. number of CoLi students).\n    \\end{enumerate}\n\n\\item Represent the data set in physical space (as in Figure \\ref{fig:vector_representations}).\nLabel the axes according to the features you defined.\n\n\\item Represent the data in form of vectors $\\vect{x_1}, \\vect{x_2}, \\vect{x_3}$.\n\n\\item Represent the data in form of a matrix $\\vect{X} \\in \\mathbb{R}^{n\\times m}$, where $n$ is the number of data points and $m$ is the number of features.\n\n\\end{enumerate}\n\n\\end{exercise}\n\n\\begin{solution}\n   % write the solution here\n   \\color{blue}\n   \n   \\begin{enumerate}\n       \\item This dataset comprises number of letters in the alphabet vs. number of phonemes in three languages: Arabic, Hindi and Lithuanian.\n       \n       \\begin{enumerate}\n            \\item Data points - Arabic, Hindi, Lithuanian.\n           \\item Features of the data points - number of letters in alphabet, number of phonemes.\n       \\end{enumerate}\n       \n       \\item \n    \\begin{tikzpicture}\n  \\draw[<->] (0,0)--(6.1,0) node[right]{$x, letters$};\n  \\draw[<->] (0,0)--(0,6.1) node[above]{$y, phonemes$};\n  \\draw[line width=2pt,blue,-stealth](0,0)--(2.8,3.6) node[anchor=south west]{$\\boldsymbol{Arabic(28,36)}$};\n  \\draw[line width=2pt,red,-stealth](0,0)--(4.7,6.1) node[anchor=south west]{$\\boldsymbol{Hindi(47,61)}$};\n  \\draw[line width=2pt,green,-stealth](0,0)--(3.2,5.6) node[anchor=north east]{$\\boldsymbol{Lithuanian(32,56)}$};\n\\end{tikzpicture}\n\n       \\item\n       Arabic:\\\\\n     $$\\vect{x1} = \\begin{bmatrix} \\texttt{28} \\\\  \\texttt{36} \\end{bmatrix} $$ \\\\\n     Hindi:\\\\\n     $$\\vect{x2} = \\begin{bmatrix} \\texttt{47} \\\\  \\texttt{61} \\end{bmatrix} $$ \\\\\n     Lithuanian:\\\\\n     $$\\vect{x3} = \\begin{bmatrix} \\texttt{32} \\\\  \\texttt{56} \\end{bmatrix} $$\n     \n       \\item\n    $\\vect{X} \\in \\mathbb{R}^{n\\times m}$\\\\\n    $\\vect{X} = \\begin{bmatrix} 28 & 47 & 32 \\\\ 36 & 61 & 56 \\end{bmatrix}$\n   \\end{enumerate}\n\\end{solution}\n\n\\begin{exercise}[Operations on vectors and matrices][2.5]\n\nWe can perform mathematical operations such as addition, subtraction, multiplication on vectors, matrices and scalars.\nCarefully read the \\textit{Computational rules} part of the \\href{\\post}{post\\footnote{Pay attention to the dimensions and use the cheat sheets provided by Niklas.}} and perform the following exercises.\nIf the computation is impossible, write \\textit{impossible} and argue why.\n\n\\begin{enumerate}\n    \\item $\\begin{bmatrix} 3 & 4 & 1 \\\\ 0 & 2 & 3 \\end{bmatrix} \\div 2 = $\n    \\item $\\begin{bmatrix} 3 & 4 & 1 \\\\ 0 & 2 & 3 \\end{bmatrix} \\ast \\begin{bmatrix} 2 \\\\ 1 \\\\ 5  \\end{bmatrix} = $\n    \\item $\\begin{bmatrix} 3 & 4 & 1 \\\\ 0 & 2 & 3 \\end{bmatrix} - \\begin{bmatrix} -1 & 2 & 10 \\\\ 3 & -6 & 3 \\end{bmatrix} = $\n    \\item $\\begin{bmatrix} 3 & 4 & 1 \\\\ 0 & 2 & 3 \\end{bmatrix} \\ast \\begin{bmatrix} 0 & 2 \\\\ 1 & -2 \\\\ 4 & 0 \\end{bmatrix} = $\n    \\item $\\begin{bmatrix} 3 & 4 & 1 \\\\ 0 & 2 & 3 \\end{bmatrix} \\ast \\begin{bmatrix} 10 & 5 \\\\ 0 & 2 \\end{bmatrix} = $\n\\end{enumerate}\n\nIf you are interested in the physical meaning of vectors, matrices and operations on them, watch videos from the \\href{https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab}{Linear Algebra} series by \\href{https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw}{3Blue1Brown}.\n\n\\end{exercise}\n\n\\begin{solution}\n   % write the solution here\n   \\color{blue}\n    \\begin{enumerate}\n    \\item   \\math\n                \\begin{bmatrix}\n                    1.5 & 2 & 0.5 \\\\\n                    0 & 1 & 1.5\n                \\end{bmatrix}\n            \\endmath\n        \n    \\item   \\math\n                \\begin{bmatrix}\n                    15\\\\\n                    17\n                \\end{bmatrix}\n            \\endmath\n        \n        \n    \\item   \\math\n                \\begin{bmatrix}\n                    4 & 2 & -9 \\\\\n                    -3 & 8 & 0\n                \\end{bmatrix}\n         \\endmath\n        \n    \\item   \\math\n                \\begin{bmatrix}\n                    8 & -2 \\\\\n                    14 & -4\n                \\end{bmatrix}\n            \\endmath\n\n        \n        \\item Impossible. As number of columns in first matrix doesn't match number of rows in the second one.\n                 \n    \\end{enumerate}\n   \n\\end{solution}\n\n\\begin{exercise}[Multiplication properties and types of matrices][3.5]\n\nRead chapters \\textit{2.2 Multiplying Matrices and Vectors} and \\textit{2.3 Identity and Inverse Matrices} of the \\href{https://www.deeplearningbook.org/contents/linear_algebra.html}{DL book} or corresponding parts of the \\href{https://towardsdatascience.com/linear-algebra-for-deep-learning-f21d7e7d7f23}{Niklas's post}\n\nOn the internet, find the following definitions and write them down:\n\\begin{enumerate}\n    \\item symmetric matrix\n    \\item orthogonal matrix\n    \\item unit vector\n    \\item orthogonal vectors\n\\end{enumerate}\n\nLet $\\vect{A}^{n \\times n}$ be an orthogonal matrix, $\\vect{B}^{m \\times m}$ -- a symmetric matrix and $\\vect{C}^{m \\times n}$ -- a regular matrix, $\\vect{I}$ -- identity matrix, and $\\lambda$ - a scalar. \\\\\n    For each expression choose its equivalent, show the intermediate steps, give the dimensions of the result. \\vspace*{0.5em} \\\\\n    $(\\vect{B} \\lambda \\vect{I})^T\\vect{C} = $ \\\\\n    \\begin{enumerate*}\n        \\item $\\lambda \\vect{CB}$ \\hspace*{3em}\n        \\item $\\vect{CB}^T  \\lambda$ \\hspace*{3em}\n        \\item $\\lambda \\vect{BCI}$\n    \\end{enumerate*}\n    \\vspace*{0.5em} \\\\\n    $\\vect{A}^{-1}(\\vect{CA}^{-1})^T \\lambda = $ \\\\\n    \\begin{enumerate*}\n        \\item $\\lambda \\vect{C}^T$ \\hspace*{3em}\n        \\item $\\lambda \\vect{C}$ \\hspace*{4.5em}\n        \\item $\\vect{A}^T\\vect{C}^T \\lambda$\n    \\end{enumerate*}\n    \\vspace*{0.5em} \\\\\n    $\\vect{AA}^T\\vect{B}^T\\vect{C} = $ \\\\\n    \\begin{enumerate*}\n        \\item $\\vect{CB}$ \\hspace*{3.2em}\n        \\item $\\vect{B}^{-1}\\vect{C}$ \\hspace*{3.8em}\n        \\item $\\vect{BC}$\n    \\end{enumerate*}\n    \n\n\\end{exercise}\n\n\\begin{solution}\n   \\color{blue}\n   \\begin{enumerate}\n       \\item A \\textbf{symmetric matrix} is a square matrix that satisfies $ A^T = A$. The entries of a symmetric matrix are symmetric with respect to the main diagonal. If $A$ is a symmetric matrix, then for every $i$,$j$ $$ a_{ij} = a_{ji}$$\n\n        \\item An \\textbf{orthogonal matrix} is a real square matrix whose columns and rows are orthogonal unit vectors. When matrix $Q$ is orthogonal, the given is true:\n        $$\n        Q\\mathord{\\cdot}Q^T = Q^T\\mathord{\\cdot}Q = I\n        $$\n\n        \\item A \\textbf{unit vector} is a vector of length 1 , and is denoted by circumflex or “hat”: $\\hat{u}$ \n        \\item \\textbf{Orthogonal vectors} are two vectors $u$ and $v$ whose dot product- $$u\\mathord{\\cdot}v = 0$$\n   \\end{enumerate}\n\n   \\begin{enumerate}\n       \\item The answer is \\textbf{c}.\\\\\n        $ (B_{m \\times m}\\lambda I_{m \\times m})^{T}C_{m \\times n}$\\\\\n        $= \\lambda B_{m \\times m}^{T}C_{m \\times n}$ (Property used- $B^T=B$)\\\\\n        $= \\lambda B_{m \\times m}C_{m \\times n}I_{n \\times n} $\\\\\n        Matrix dimension - $m \\times n$\n\n        \\item The answer is \\textbf{a}.\\\\\n        $ A^{-1}(CA^{-1})^{T}\\lambda$\\\\\n        $= A^{-1}\\mathord{\\cdot}(A^{-1})^{T}\\mathord{\\cdot}C^{T}\\lambda$  (Property used- $AA^T=I$)\\\\\n        $= IC^{T}\\lambda$ \\\\\n        $= \\lambda C^{T}$ \\\\\n        Matrix dimension - $n \\times m$\n\n        \\item\n        $ (A_{n \\times n}A^{T}_{n \\times n})B^{T}_{m \\times m}C_{m \\times n}\\\\$\n        $= I_{n \\times n}B_{m \\times m}C_{m \\times n}$\\\\\n        There is an ambiguity in the expression above as $ AA^{T}$ results an identity matrix $\\vect{I}$ of size $n \\times n$. However, proceeding further we get $\\vect{I}\\vect{B}\\vect{C}$ which is an undefined expression as size of $\\vect{B}$ is $m \\times m$ while the size of identity matrix $\\vect{I}$ is $n \\times n$.  \\\\\n        Matrix dimension - undefined.\n   \\end{enumerate}\n\n\\end{solution}\n\n\\begin{exercise}[Vector norms][1]\n\nRead the chapter \\textit{2.5 Norms} of the \\href{https://www.deeplearningbook.org/contents/linear_algebra.html}{DL book}. \n\nCalculate $L^2$ and $L^1$ norms of the following vector: $\\vect{a} = \\begin{bmatrix} 2 \\\\ -3 \\\\ 1 \\end{bmatrix}$.\n\n\\vspace{3em}\n\n\\textit{Bonus exercise (2 points)}: Draw all the vectors $\\vect{x} \\in \\mathbb{R}^2$ for which \n\\begin{enumerate}\n    \\item $||\\vect{x}||_1 = 1$;\n    \\item $||\\vect{x}||_2 = 1$.\n\\end{enumerate}\n\n\\end{exercise}\n\n\\begin{solution}\n   \\color{blue}\n    \\begin{flalign*}\n        L^{2}   & = {\\left \\| x \\right \\|}_{2} = (\\sum_{i} \\left | x_{i} \\right |^{2})^{\\frac{1}{2}}\\\\\n                & = \\sqrt{4+9+1} = \\sqrt{14} = 3.741\n    \\end{flalign*}\n    \n    \\begin{flalign*}\n        L^{1}   & = {\\left \\| x \\right \\|}_{1} = \\sum_{i} \\left | x_{i} \\right |\\\\\n                & = 2+3+1 = 6\n    \\end{flalign*}\n    \\textbf{Bonus exercise}\\\\\n    \\\\\n    Let $\\vect{x} = \\begin{bmatrix} x_1 \\\\ x_2 \\end{bmatrix}$ represent a 2-dimensional vector. Given that,\n    \\begin{flalign}\n        ||\\vect{x}||_1 = x_1 + x_2 = 1 \\\\\n        ||\\vect{x}||_2 = \\sqrt{x_1 + x_2} = 1\n    \\end{flalign}\n    Squaring equation 1 both sides-\n    \\begin{flalign*}\n        &\\implies (x_1 + x_2)^2 = 1 \\\\\n        &\\implies x_1^2 + x_2^2 + 2x_1x_2 = 1\n    \\end{flalign*}\n    Squaring equation 2 both sides and replacing it in the above equation-\n    \\begin{flalign*}\n    &\\implies x_1^2 + x_2^2 = 1\\\\\n    &\\implies 1 + 2x_1x_2 = 1\\\\\n    &\\implies x_1x_2 = 0\n    \\end{flalign*}\n    Therefore, all possible vectors are-\n    $$\\vect{x} = \\begin{bmatrix} x_1 \\\\ 0 \\end{bmatrix}, \\vect{x} = \\begin{bmatrix} 0 \\\\ x_2 \\end{bmatrix}$$\n    $$\\vect{x} = \\begin{bmatrix} x_1 & 0 \\end{bmatrix}, \\vect{x} = \\begin{bmatrix} 0 & x_2 \\end{bmatrix}$$\n    \n\\end{solution}\n\n\\section*{Submission instructions}\n\n\\framebox{\n\t\\begin{minipage}{\\linewidth}\n\t\tThe following instructions are mandatory. If you are not following them, tutors can\n\t\tdecide to not correct your exercise.\n\t\\end{minipage}\n}\n\n\\begin{itemize}\n    \\item You have to submit the solutions of this assignment sheet as a team of 2-3 students.\n    \\item  Hand in a \\textbf{single} PDF file with your solutions.\n    \\item Therefore Make sure to write the student ID and the name of each\n    member of your team on your submission.\n    \\item Your assignment solution must be uploaded by only \\textbf{one} of your team members to the course website.\n    \\item If you have any trouble with the submission, contact your tutor \\textbf{before} the deadline.\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "9663465f22404a638dbc0c3e137e83cb4fbe7323", "size": 14640, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "neural-networks/assignment1/assignment-1.tex", "max_stars_repo_name": "sangeet2020/ws-20-21", "max_stars_repo_head_hexsha": "316d2c1495cd540ce390eced52d41c57efed1f64", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "neural-networks/assignment1/assignment-1.tex", "max_issues_repo_name": "sangeet2020/ws-20-21", "max_issues_repo_head_hexsha": "316d2c1495cd540ce390eced52d41c57efed1f64", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-12-03T00:05:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-03T00:05:20.000Z", "max_forks_repo_path": "neural-networks/assignment1/assignment-1.tex", "max_forks_repo_name": "sangeet2020/WS-20-21", "max_forks_repo_head_hexsha": "316d2c1495cd540ce390eced52d41c57efed1f64", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-01-05T06:55:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-17T00:19:30.000Z", "avg_line_length": 42.6822157434, "max_line_length": 325, "alphanum_fraction": 0.6338797814, "num_tokens": 4614, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7981867825403177, "lm_q1q2_score": 0.43639916642463816}}
{"text": "\\documentclass[12pt, letterpaper]{article}\n\\usepackage{amsmath, amssymb, mathtools, graphicx, listings, color, xcolor, bold-extra, tikz, tikz-qtree, colortbl, hyperref}\n\\usepackage[margin = 1.5in]{geometry}\n\\graphicspath{ {/} }\n\n\\topmargin 0in\n\\headheight 0in\n\n\\setlength{\\parindent}{0pt}\n\n\\definecolor{codegreencomment}{HTML}{629755}\n\\definecolor{codegreen}{HTML}{6A8759}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.92}\n \n\\lstdefinestyle{mystyle}{\n    backgroundcolor=\\color{backcolour},   \n    commentstyle=\\color{codegreencomment},\n    keywordstyle=\\color{orange}\\bfseries,\n    numberstyle=\\tiny\\color{codegray},\n    stringstyle=\\color{codegreen},\n    basicstyle=\\footnotesize\\ttfamily,\n    breakatwhitespace=false,         \n    breaklines=true,                 \n    captionpos=b,                    \n    keepspaces=true,                 \n    numbers=left,                    \n    numbersep=5pt,                  \n    showspaces=false,                \n    showstringspaces=false,\n    showtabs=false,                  \n    tabsize=2,\n    language=Scala\n}\n \n\\lstset{style=mystyle}\n\n\\hypersetup{\n    colorlinks,\n    citecolor=black,\n    filecolor=black,\n    linkcolor=black,\n    urlcolor=black\n}\n\n\\usetikzlibrary{automata, positioning, calc, shapes.multipart, chains,arrows}\n\n\\begin{document}\n\\title{CS 241E: Foundations of Sequential Programs (Enriched)}\n\\author{Muhammad Talha, taught by Ondrej Lhotak }\n\\date{Fall 2017}\n\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Machine Language}\nEvery instruction that the computer executes is a 32 or 64 bit binary number. An instruction that is represented by a sequence of bits is called a machine language instruction.\n\n\\subsection{Binary numbers}\nIn a binary number each bit is a power of 2. A binary number can be unsigned or signed.\n\n\\subsubsection{Unsigned Binary numbers}\nUnsigned binary numbers are used to represent non-negative numbers. \\\\\n\nE.g. Consider the following binary number:\n\n\\[\n\\underbrace{\n\\begin{tabular}{c c c c c c c}\n\t1 & 0 & 0 & 0 & 0 & 1 & 1 \\\\\n\t$2^6$ & $2^5$ & $2^4$ & $2^3$ & $2^2$ & $2^1$ & $2^0$\n\\end{tabular}\n}_\\text{1 + 2 + 64 = 67}\n\\]\\\\\n\nIn order to encode a number \\(n\\) as a binary number we need to continually find a power of 2 that is \\(\\leq n\\).\\\\\n\nE.g. Convert 42 to binary.\n\nThe highest power of 2 that is at most 42 is \\(2^5 = 32\\).\nThe highest power of 2 that is at most \\(42 - 32 = 10\\) is \\(2^3 = 8\\).\nThe highest power of 2 that is at most \\(10 - 8 = 2\\) is \\(2^1 = 2\\).\nSo the answer is \\(1 0 1 0 1 0\\).\\\\\n\nSuppose we have 32 bits. What is the range of unsigned binary numbers? \\(0\\) to \\(2^{32} - 1\\).\nIn general, if we had n bits, the maximum number we can store is \\(2^n - 1\\).\n\n\\subsubsection{Signed binary numbers}\nSigned binary numbers are used to represent negative numbers. A common format for encoding signed numbers is using 2's complement. To interpret a binary number as a 2's complement number, make the most significant bit negative.\\\\\n\nE.g. \\(100111 = 1 + 2 + 4 - 32 = -25\\)\n\nE.g. \\(010101 = 1 + 4 + 16 = 21\\)\\\\\n\nSuppose we have 32 bits. What is the range of signed binary numbers?\n\nWhat is the lowest number that we can store in 32 bits using 2's complement?\n\n\\[\n\\underbrace{\n\\begin{tabular}{c c c c c}\n\t1 & 0 & 0 & ... & 0\n\\end{tabular}\n}_\\text{$-2^{31}$}\n\\]\\\\\n\nWhat is the largest number that we can store in 32 bits using 2's complement?\n\n\\[\n\\underbrace{\n\\begin{tabular}{c c c c c}\n\t0 & 1 & 1 & ... & 1\n\\end{tabular}\n}_\\text{$2^{31} - 1$}\n\\]\\\\\n\nSo the range of signed 2's complement numbers is: \\(-2^{31}\\) to \\(2^{31} - 1\\).\\\\\n\nHow do we encode a negative number using 2's complement? It turns out there is an algorithm to do this. To encode -n:\n\n\\begin{enumerate}\n\\item Encode n (making sure the most significant bit is 0, to indicate a non-negative number).\n\\item Flip all bits.\n\\item Add 1.\n\\end{enumerate}\n\nWhy does this algorithm work? Lets take a look and see what is happening step by step.\n\n\\begin{enumerate}\n\\item n\n\\item \\(1 1 1 ... 1 - n = 2^{32} - 1 - n\\) \n\\item \\(2^{32} - n \\equiv -n\\) mod \\(2^{32}\\) \n\\end{enumerate}\n\nSo we see that the resulting number is congruent to \\(-n\\) mod \\(2^{32}\\). Therefore the resulting number has the same bit representation as \\(-n\\) in 32 bits. In general, if \\(x \\equiv y\\) mod \\(2^{32}\\), then \\(x\\) and \\(y\\) have the same bit representation in 32 bits.\\\\\n\nE.g. Encode -72.\n\\[-72 \\xrightarrow{\\text{encode 72}} 01001000 \\xrightarrow{\\text{flip all bits}} 10110111 \\xrightarrow{\\text{add 1}} 10111000 = -72\\]\n\n\\section{Computers and Assembly Language}\nA computer consists of registers and memory. Operations involving registers are efficient because they are close to the arithmetic and logic unit. Operations involving memory are slower because we first need to fetch the data from memory to registers and then do the operation.\n\n\\subsubsection{MIPS}\nIn MIPS there are 32 general purpose registers. Register 0 is always hard coded to store 0. Program Counter (PC) holds the address of the next instruction to execute. LO holds the quotient of a division and the first 32 bit result of a multiplication. HI holds the remainder of a division and the last 32 bits of a multiplication.\\\\\n\nIn MIPS, memory is indexed by multiples of 4. The first memory location is 0, the next memory location is 4 and so on.\n\n\\subsubsection{Control Unit and Step function}\nThe control unit of a computer is a bunch of hardware that implements a step function. A step function goes from one state of a program to the next. A state of a program is a \"snapshot\" that is used to represent all the bits in the computer.\\\\\n\nSuppose we wanted to design a step function. We could make it specific to the task were trying to solve (make step function integrate or do algebra). The problem with that is if we make the step function too specific, it will not be able to do a wide variety of tasks. We want the step function to be as general as possible.\\\\\n\nThe step function that people ended up using is the following:\n\\begin{enumerate}\n\\item Fetch next instruction to execute by looking at PC.\n\\item Increment PC by 4.\n\\item Execute instruction.\n\\end{enumerate}\n\n\\subsubsection{Assembly}\nRecall that computers only execute machine language. The problem is that it's very difficult for humans to understand machine language (i.e. interpret a bunch of bits). That is why we invented assembly language.\\\\\n\nAssembly language is a language for writing machine language programs using op codes instead of sequences of bits. An op code is a word that represents a machine language instruction (e.g. ADD, SUB).\\\\\n\nNote that assembly language is an \\emph{abstraction} of machine language since each op code represents a machine language instruction. It's important to understand that the computer does not \"see\" assembly language. We need to somehow translate assembly language programs to machine language programs so that the computer can successfully execute it. The assembler is a program that translates assembly language to machine language. \n\n\\subsubsection{Labels}\nE.g. Consider the following assembly language code to find the absolute value of Reg 1:\n\\begin{verbatim}\n\tSLT $2, $1, $0\n\tBEQ $2, $0, 1\n\tSUB $1, $0, $1\n\tJR  $31\n\\end{verbatim}\n\nSuppose we add some code between the BEQ and JR instructions. Then the BEQ jump offset would be incorrect. We have to be very careful to get the offset exactly right, otherwise we will jump to some random point in our program. The problem is that it's tedious to always update all the jump offsets in our program whenever we edit the code. Lets instead use labels.\\\\\n\nA label is an abstraction of a memory address, that is, every label represents a memory address. We want to be able to define labels in memory and then jump to them.\\\\\n\nE.g. Previous example with labels:\n\\begin{verbatim}\n\tSLT $2, $1, $0\n\tBEQ $2, $0, label\n\tSUB $1, $0, $1\n\tDefine(label)\n\tJR  $31\n\\end{verbatim}\n\nHow can we compile assembly language programs with labels to just assembly language programs? We will use a symbol table. A symbol table is a map that maps labels to memory addresses they point to. Now, to eliminate labels we need to:\n\n\\begin{enumerate}\n\\item Go through the entire code and store each label's respective memory address in the symbol table.\n\\item Go through the entire code again and convert each label to an address/offset.\n\\end{enumerate}\n\nQuestion: How do we branch to a procedure? What we can do is define a label in the beginning of the procedure. Then we can load the address of that label into a register and branch to it.\\\\\n\nE.g. Calling a procedure:\n\\begin{verbatim}\n\tLIS $1\n\tUse(label)\n\tJALR(label)\n\t..\n\tDefine(label)\n\t..procedure..\n\tJR  $31\n\\end{verbatim}\n\nNote that instructions like Define only exist in our \"intermediate language\". The compiler uses them to determine addresses/offsets and removes them from the program. The compiler also does this to other instructions like comments.\n\n\\subsubsection{Relocation}\nSuppose we have a block of code located at some memory address. We want this block of code to be relocatable. That is, we want to be able to take that code and place it somewhere else in memory and still be able to run exactly the same.\\\\\n\nIs this possible with machine language? Suppose our code has a BEQ jumping to another part of the program (for example, BEQ \\$0 \\$0 104). When we relocate our code to another memory location, the address is incorrect. Therefore, it is simply not possible to relocate machine code.\\\\\n\nAs a result, the assembler translates assembly language files to object files. An object file is a file that contains the compiled machine language code + extra meta data. This meta data includes information regarding where the labels in the assembly file used to be and which memory locations contain addresses to other memory locations (to differentiate between a memory address and a constant). The assembler translates all assembly language files to object files and then the linker links them into a single object file.\\\\\n\nHowever, the linker needs to relocate all the code and still make it work in the combined object file. The linker performs relocation when it links all object files. Note that the job of the linker can be done in a much easier way. Instead of linking object files, we could simply link assembly files together and make the assembler turn that into a single object file. The result would be exactly the same. So why don't we do this?\\\\\n\nThe reason why is modular code. Suppose we have a large project and we need to edit parts of our code. If we linked assembly files, we would have to edit the specific assembly file and compile it all again.\\\\\n\nIf we linked object files, all we would have to do is translate the edited assembly file to an object file and link it with the rest of the object files, thus saving time from recompiling the whole program. \\\\\n\nE.g. Consider the following code snippets. The assembler will turn both files into object files and then the linker will link both files.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{1.asm}\n\\begin{verbatim}\nLIS  $1\nUse(a)\nJALR $1\nJR   $31\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{1.o}\n\\begin{verbatim}\n0  LIS  $1\n4  ??\n8  JALR $1\n12 JR   $31\nMetadata:\nUse imported label a @ address 4\n\\end{verbatim}\n\\end{minipage}\n\n\\vspace{5mm}\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{2.asm}\n\\begin{verbatim}\nDefine(a)\nLIS $1\nUse(b)\nJALR $1\nJR $31\nDefine(b)\nJR $31\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{2.o}\n\\begin{verbatim}\n0  LIS  $1\n4  16\n8  JALR $1\n12 JR   $31\n16 JR   $31\nMetadata:\nexport label a = 0 -> 16\nexport label b = 16 -> 36\nAddress at 4 -> 20\n\\end{verbatim}\n\\end{minipage}\\\\\n\n\\vspace{7mm}\n\nIn general, the assembler translates:\n\\begin{itemize}\n\\item Define(a) to \\verb|export label a = ..|\n\\item Use(a) where a is found to \\verb|Address at ..|\n\\item Use(a) where a is not found to \\verb|use imported label a @ address ..|\n\\end{itemize}\n\nNow lets link the two object files together:\n\n\\begin{verbatim}\n0  LIS  $1\n4  ?? -> 16\n8  JALR $1\n12 JR   $31\n16 LIS  $1\n20 16 -> 32\n24 JALR $1\n28 JR   $31\n32 JR   $31\n\\end{verbatim}\n\nThe first to note is that the file \\emph{1.o} and \\emph{2.o} start at memory address 0. However, in the linked program, \\emph{2.o} starts at 16 since the size of \\emph{1.o} is 16.\\\\\n\nThis is a problem because all of the second file's meta data is off by an offset of 16. So we need to perform relocation on the second file's meta data.\\\\\n\nWe read the first file's meta data and see at address 4 we need to use imported label a. So lets set address 4 to be a. We read the second file's meta data and see there is an address at 20. The problem is that any address value is also going to be off by an offset of 16. So lets add 16 to the address value. Thus we get the resulting correct object file.\n\n\\section{Variables}\nVariables are abstractions of memory addresses that can be used in expressions. Variables are very useful as we can simply store any value we want in them. There are two types of variables: global variables and function local variables.\\\\\n\nGlobal variables are accessible from anywhere and anytime in the program.\n\nFunction local variables are accessible only during function execution.\\\\\n\nThe extent of a variable is the time interval in which its value can be accessed. For global variables, the extent is the entire execution of the program. For function local variables, the extent is only one execution of the function (i.e. every time a function is called a new local variable is created).\n\n\\subsubsection{Stack}\nE.g. Consider the following code:\n\\begin{lstlisting}[mathescape]\ndef fact(x: Int): Int = if (x $\\leq 1$) 1 else x $\\cdot$ fact(x - 1)\n\\end{lstlisting}\n\n\nSuppose we call fact(3). This would be evaluated to \\(3 \\times\\) fact(2), \\(3 \\times 2 \\times\\) fact(1) and finally return \\(3 \\times 2 \\times 1\\). Note that there are actually 3 run time instances of the variable x. That is, x is 3 in fact(3), 2 in fact(2) and 1 in fact(1). After x is 1 in fact(1), the value 1 returns and that run time instance of x is deallocated. Then x is 2 is deallocated followed by x is 3.\\\\\n\nWhat kind of data structure can we use that allows us to easily:\n\nAllocate x = 3, x = 2, x = 1\n\nDeallocate x = 1, x = 2, x = 3\\\\\n\nWe can use a stack. Every time we allocate a variable, we can push it onto the stack. Every time we deallocate a variable, we pop from the stack. We can implement a stack by considering a block of memory to be the stack and have a register (called stack pointer, SP) that always points to the top of stack.\\\\\n\nConvention: Lets put the stack at the end of memory and use register 30 as the SP.\nTo push a word we need to decrement the SP by 4. To pop a word we need to increment the SP by 4.\nLets initialize the SP to point to the address one word after the end of memory. Then, when we push a word, that word will be located right at the end of memory.\\\\\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nCode\\\\\n\\hline\n1010..\\\\\n..\\\\\n..\\\\\n\\hline\nStack\\\\\n\\hline\nx\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nSuppose a function pushes variables a, b and c onto the stack. How can it access those variables again? One idea might be to use a symbol table mapping each variable to its offset from the SP. However, there is a problem with this idea. Suppose that same function wanted to use the stack again. It cannot simply add other things onto the stack because, if it does, the symbol table mapping each variable to its SP offset will be incorrect.\\\\\n\nLets instead use a frame. Whenever we call a function lets allocate its frame onto the stack. This frame will act as a container for all of the function's variables. Since the top of the stack and the top of the frame might not point to the same thing (i.e. function decides to use the stack again), we need another register that points to the top of the frame.\\\\\n\nConvention: Lets use register 29 to point to the top of the frame (called frame pointer, FP).\\\\\n\nNow, instead of the symbol table holding each variable's SP offset, it will hold each variable's FP offset. This allows the function to modify the stack \\emph{and} still have access to its variables via the symbol table.\\\\\n\nConvention: For CS 241E assignments, all memory is organized in chunks. The first two words of the chunk are reserved and always hold the size of the chunk and some data that will be useful for assignment 11.\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nSize of chunk\\\\\n\\hline\nA11\\\\\n\\hline\nVariables..\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nNow that we have figured out how to store variables, how can we use them in an expression?\n\n\\subsubsection{Expressions}\nAn expression is a variable or an operation involving two sub expressions (E.g. a, a + b). In order to compile expressions we need to generate code for its sub expressions.\\\\\n\nE.g. Let a, b, c and d be variables. Consider the expression: \\((a \\cdot b) + (c \\cdot d)\\).\\\\\n\nIn order to generate code for this expression we need to first MUL a and b, store the result, and then MUL c and d, store the result, and finally ADD the two results.\\\\\n\nConvention: Whenever we evaluate an expression, put the result into register 3 (Reg.result).\\\\\n\nIn general, how can we evaluate \\(e_1\\) op \\(e_2\\)? We cannot simply evaluate the first sub expression and then the next sub expression, as the result of the first sub expression will be overwritten. There are 3 techniques that we will study in order to evaluate expressions.\n\n\\paragraph{Technique 1: Using a Stack} \\hfill\n\nThe main idea of technique 1 is saving the result of the first sub expression onto the stack. Note that push and pop correspond to the Stack push and pop.\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef evaluate((*$e_1$*) op (*$e_2$*)): Code = block(\n\tevaluate((*$e_1$*)),\n\tpush $3,\n\tevaluate((*$e_2$*)),\n\tpop $4,\n\t$3 = $4 op $3\n)\n\\end{lstlisting}\n\nE.g. How does this generate code for \\((a \\cdot b) + (c \\cdot d)\\)?\n\n\\begin{verbatim}\nread a\npush $3\nread b\npop $4\n$3 = $4 * $3\npush $3\nread c\npush $3\nread d\npop $4\n$3 = $4 * $3\npop $4\n$3 = $4 + $3\n\\end{verbatim}\n\nWhat are some advantages of this technique? It is general, simple.\n\nWhat are some disadvantages? Inefficient (lots of pushing and popping), difficult to optimize further.\n\n\\paragraph{Technique 2: Using Variables to save result} \\hfill\n\nThe main idea of technique 2 is using variables to store the result of the two sub expressions. We will create one variable to store the result of \\(e_1\\), another variable to store the result of \\(e_2\\) and finally return the result of  \\(e_1\\) op \\(e_2\\) in a variable.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef evaluate((*$e_1$*) op (*$e_2$*)): (Code, Variable) = block(\n\tval ((*$c_1$*), (*$v_1$*)) = evaluate((*$e_1$*))\n\tval ((*$c_2$*), (*$v_2$*)) = evaluate((*$e_2$*))\n\tval (*$v_3$*) = new Variable\n\tval code = block((*$c_1$*), (*$c_2$*), ((*$v_3$*) = (*$v_1$*) op (*$v_2$*)))\n\t(code, (*$v_3$*))\n)\n\\end{lstlisting}\n\nWhat are some advantages of this technique? It is flexible, easy to optimize.\n\nWhat are some disadvantages? Inefficient (lots of variables). Recall that the computer only performs arithmetic operations on registers. That means whenever we perform an operation like (\\(v_3\\) = \\(v_1\\) op \\(v_2\\)), we need to read \\(v_1\\) and \\(v_2\\) to registers, perform the operation and then write the result to \\(v_3\\).\n\n\\paragraph{Technique 3: Using \\emph{a} Variable to save result} \\hfill\n\nThe main idea of technique 3 is combining techniques 1 and 2. All we really need is one temporary variable to store the result of \\(e_1\\).\\\\\n\nConvention: In assignments we have another abstraction called withTempVar. This abstraction is a piece of code that holds a piece of code and a temporary variable that the code uses. In order to create a withTempVar you need to pass a function that accepts a variable and returns a piece of code that uses the variable. Then withTempVar will create the temporary variable and wrap it around the code that the function returns.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef evaluate((*$e_1$*) op (*$e_2$*)): Code = withTempVar{\n\t(*$t$*) => block(\n\t\tevaluate((*$e_1$*)),\n\t\twrite((*$t$*), $3),\n\t\tevaluate((*$e_2$*)),\n\t\tread($4, (*$t$*)),\n\t\t$3 = $4 op $3\n\t)\n}\n\\end{lstlisting}\n\nE.g. How does this generate code for \\((a \\cdot b) + (c \\cdot d)\\)?\n\n\\begin{verbatim}\nread a\nt_1 = $3\nread b\n$4 = t_1\n$3 = $4 * $3\nt_2 = $3\nread c\nt_3 = $3\nread d\n$4 = t_3\n$3 = $4 * $3\n$4 = t_2\n$3 = $4 + $3\n\\end{verbatim}\n\nNote that now all operations are done on registers. This technique has the perfect balance between flexibility and efficiency. We will apply this technique in the assignments.\n\n\\section{Control Structures}\nWe want our language to have control structures like if statements and while loops.\n\n\\subsubsection{If statements}\n\\begin{lstlisting}[mathescape]\nif ($e_1$ op $e_2$) $\\underbrace{T}_\\text{thens}$ else $\\underbrace{F}_\\text{elses}$\n\\end{lstlisting}\n\nWe can implement if statements with a simple BEQ and labels.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef eliminateIfStmts(ifStmt: IfStmt): Code = withTempVar{\n\tt => block(\n\t\tevaluate((*$e_1$*)),\n\t\tt = $3,\n\t\tevaluate((*$e_2$*)),\n\t\t$3 = $4 op $3,\n\t\tbeq($3, $0, elseLabel),\n\t\tifStmt.thens,\n\t\tbeq($0, $0, endIf),\n\t\tDefine(elseLabel),\n\t\tifStmt.elses,\n\t\tDefine(endIf)\n\t)\n}\n\\end{lstlisting}\n\nNote that after executing the thens code, we need to branch to the end, otherwise we will end up executing the elses code as well.\\\\\n\n\\subsubsection{While loops}\n\\begin{lstlisting}[mathescape]\nwhile ($e_1$ op $e_2$) $\\underbrace{B}_\\text{keep executing as long as exp. true}$\n\\end{lstlisting}\n\nWe can implement if statements with a simple BEQ and labels.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef eliminateWhile(whileLoop: WhileLoop): Code = withTempVar{\n\tt => block(\n\t\tDefine(startWhile),\n\t\tevaluate((*$e_1$*)),\n\t\tt = $3,\n\t\tevaluate((*$e_2$*)),\n\t\t$3 = $4 op $3,\n\t\tbeq($3, $0, endWhile),\n\t\twhileLoop.B,\n\t\tbeq($0, $0, startWhile),\n\t\tDefine(endWhile)\n\t)\n}\n\\end{lstlisting}\n\nNote that after executing the while block, we need to branch back to the beginning of the while loop to test if the condition still holds true.\\\\\n\n\\subsubsection{Arrays}\nArrays can be easily implemented, using a similar technique as when were implementing the stack. All we really need to do is store the start of the array. Whenever the user wants to access element i, we need to access address \\(start + 4*i\\). Although arrays are simple to implement, we will not be implementing them in the assignments.\n\n\\section{Register Allocation}\nSuppose you have an expression containing 33 variables. Since there are only 32 registers in MIPS assembly, we cannot read every single variable into a register and perform the designated operation. Register allocation deals with the problem of mapping a large number of variables to a small number of registers.\\\\\n\nE.g. Consider the following code with variables \\(t_1, t_2, t_3, t_4\\):\n\\begin{lstlisting}[mathescape]\n$t_1$ = a + b\n$t_2$ = $t_1$ + c\n$t_3$ = $t_2$ + d\n$t_4$ = $t_3$ + e\n\\end{lstlisting}\n\nHow many registers do we really need? Do we need 4 registers to store \\(t_1, t_2, t_3, t_4\\) independently? No. We know we can deal with this particular code by using just 1 register. We can put \\(a\\) into this register and add \\(b\\), \\(c\\), \\(d\\), and \\(e\\) to it.\\\\\n\nA program point is a point between two pieces of code. It's nice to define a program point between two pieces of code as there's no ambiguity (we know every thing above the program point has already executed and every thing below the program point has not yet executed).\\\\\n\nWe say a variable is live at program point P if its value may be read later in the program. The live range of a variable is the set of all program points where the variable is live.\\\\\n\nNotice that we only need to know variables values at program points in its live range. For example, if a program point P is not in a variables live range, then the variables value will not be read after the program point P. As a result, there's no need to store its value.\\\\\n\nTwo variables can share a memory address if their live ranges are disjoint. To understand this, consider two variables who have at least one program point P where both variables are live. Then, at this program point P, the first variable's value may be read later in the program \\emph{and} the second variable's value may be read later in the program. Therefore, we need two memory locations to store both variable values.\\\\\n\nE.g. Consider the following code in the previous example:\n\\begin{lstlisting}[escapeinside={(*}{*)}]\n(*$t_1$*) = a + b\n(*\\textcolor{codegreen}{Live: $t_1$}*)\n(*$t_2$*) = (*$t_1$*) + c\n(*\\textcolor{codegreen}{Live: $t_2$}*)\n(*$t_3$*) = (*$t_2$*) + d\n(*\\textcolor{codegreen}{Live: $t_3$}*)\n(*$t_4$*) = (*$t_3$*) + e\n(*\\textcolor{codegreen}{Live: $t_4$}*)\n..\nprintln((*$t_4$*))\n\\end{lstlisting}\n\nWe see that the live range of all \\(t_i\\) is disjoint with \\(t_j\\) (\\(i \\neq j\\)). So we can use one register to store \\(t_1, t_2, t_3, t_4\\).\\\\\n\nE.g. Consider the following code:\n\\begin{lstlisting}[escapeinside={(*}{*)}]\n(*$t_1$*) = a * b\n(*\\textcolor{codegreen}{Live: $t_1$}*)\n(*$t_2$*) = c * d\n(*\\textcolor{codegreen}{Live: $t_1, t_2$}*)\n(*$t_3$*) = (*$t_1$*) + (*$t_2$*)\n(*\\textcolor{codegreen}{Live: $t_3$}*)\n(*$t_4$*) = e * f\n(*\\textcolor{codegreen}{Live: $t_3, t_4$}*)\n(*$t_5$*) = (*$t_3$*) - (*$t_4$*)\n(*\\textcolor{codegreen}{Live: $t_3, t_5$}*)\ng = (*$t_3$*) + (*$t_5$*)\n\\end{lstlisting}\n\nNotice that the live range of \\(t_1\\) is \\(\\{P_1, P_2\\}\\), \\(t_2\\) \\(\\{P_2\\}\\), \\(t_3\\) \\(\\{P_3, P_4, P_5\\}\\), \\(t_4\\) \\(\\{P_4\\}\\), \\(t_5\\) \\(\\{P_5\\}\\).\\\\\n\nSince the live range of \\(t_1\\) and \\(t_2\\) are not disjoint, we need at least 2 registers.\\\\\n\nWe say a variable is dead at a program point P if it's never read after P or its value is overwritten before it's read.\\\\\n\nNow that we can tell whether two or more variables can share a memory location, how do we actually map the variables to registers?\\\\\n\nWe will use an inference graph. The basic idea is that the vertices are variables. There exists an edge between two vertices (two variables) if both variables are live at the same time.\\\\\n\nE.g. For the above example, the inference graph is:\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[shape=circle,draw=black] (t1) at (1, 4) {$t_1$};\n\t\\node[shape=circle,draw=black] (t2) at (4, 4) {$t_2$};\n\t\\node[shape=circle,draw=black] (t3) at (0, 1) {$t_3$};\n\t\\node[shape=circle,draw=black] (t5) at (5, 1) {$t_5$};\n\t\\node[shape=circle,draw=black] (t4) at (2.5, 0) {$t_4$};\n\n\t\\path [-] (t1) edge node[] {} (t2); \n\t\\path [-] (t3) edge node[] {} (t5); \n\t\\path [-] (t3) edge node[] {} (t4); \n\\end{tikzpicture}\n\\end{center}\n\nNow that we have an inference graph, we need a graph coloring. A graph is \\(k\\)-colorable if you can color all the vertices of the graph with \\(k\\) colors such that no two adjacent vertices have the same color.\\\\\n\nThe idea is that a color represents a register. We want to minimize the number of colors (registers) used. However, the problem of finding the minimal graph coloring for an arbitrary graph is NP-hard. There do exist simple greedy algorithms that do quite well but, in general, don't find the minimal graph coloring.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\nfor (v <- vertices){\n\t(*color v with the lowest numbered color not yet used by its neighbours*)\n}\n\\end{lstlisting}\n\nE.g. For the example above:\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[shape=circle,draw=black] (t1) at (1, 4) {$t_1,$ \\$1};\n\t\\node[shape=circle,draw=black] (t2) at (4, 4) {$t_2$, \\$2};\n\t\\node[shape=circle,draw=black] (t3) at (0, 1) {$t_3$, \\$1};\n\t\\node[shape=circle,draw=black] (t5) at (5, 1) {$t_5$, \\$2};\n\t\\node[shape=circle,draw=black] (t4) at (2.5, 0) {$t_4$, \\$2};\n\n\t\\path [-] (t1) edge node[] {} (t2); \n\t\\path [-] (t3) edge node[] {} (t5); \n\t\\path [-] (t3) edge node[] {} (t4); \n\\end{tikzpicture}\n\\end{center}\n\nSo \\(t_1, t_3\\) would be mapped to register 1, and \\(t_2, t_4, t_5\\) would be mapped to register 2.\nThe resulting code would now look like:\n\n\\begin{lstlisting}\n$1 = a * b\n$2 = c * d\n$1 = $1 + $2\n$2 = e * f\n$2 = $1 - $2\ng = $1 + $2\n\\end{lstlisting}\n\nIf the graph coloring algorithm requires more colors than number of available registers, then we can allocate some colors to represent memory locations on the stack.\\\\\n\nHowever, in the assignments we will allocate all variables on the stack for simplicity.\n\n\\section{Procedures}\nProcedures are an abstraction of a reusable block of code. How do we implement them? Suppose a procedure, called caller procedure, calls another procedure, called callee procedure.\\\\\n\nThe first thing we have to do is branch to the label of the procedure. We will load the address of the callee procedure into Reg.targetPC, and branch to it.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Caller procedure}\n\\begin{verbatim}\nLIS (Reg.targetPC)\nUse(procedureLabel)\nJALR(Reg.targetPC)\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Callee procedure}\n\\begin{verbatim}\nDefine(procedureLabel)\n\\end{verbatim}\n\\end{minipage}\n\n\\vspace{7mm}\n\nAfter calling the callee procedure, the caller procedure's code needs to continue executing. \nWe will use Reg.savedPC (i.e. the link register) to store the address of the next instruction to execute after calling the callee procedure. The JALR instruction does this automatically, and sets Reg.savedPC to be the value of PC and then jumps to the specified address.\\\\\n\nHowever, there is a problem with this. Suppose the callee procedure has some code that calls another procedure. Then that call will update Reg.savedPC to be the address of the next piece of code after calling that procedure. Now, when the callee procedure returns, it will attempt to jump to the value of Reg.savedPC to return to the caller procedure. However, this will create an infinite loop.\\\\\n\nWe need to \\emph{preserve} the value of Reg.savedPC. To do this, we will save the value of Reg.savedPC in the callee procedure's frame and then set it back to what it was before returning from the procedure. However, we first need to allocate the callee procedure's frame. Since we are allocating a new frame, we should set the FP to be the address of the top of the frame. Note that the old FP points to the caller procedure's frame and the caller procedure uses it to access it's variables. So we need to \\emph{preserve} the value of Reg.FP as well.\\\\\n\nConvention: We will save Reg.savedPC in a variable called savedPC and Reg.FP in a variable called dynamicLink.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Caller procedure}\n\\begin{verbatim}\nLIS (Reg.targetPC)\nUse(procedureLabel)\nJALR(Reg.targetPC)\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Callee procedure}\n\\begin{verbatim}\nDefine(procedureLabel)\nStack.allocate(frame)\ndynamicLink = Reg.FP\nsavedPC = Reg.savedPC\nReg.FP = Reg.allocated\n..\n..\nReg.savedPC = savedPC\nReg.FP = dynamicLink\nStack.pop // Pop frame\nJR(Reg.savedPC)\n\\end{verbatim}\n\\end{minipage}\n\n\\vspace{7mm}\nNote that while we are saving the value of Reg.savedPC and Reg.FP, we need to write to the callee procedure's frame at base offsets of Reg.allocated. The reason why is because Reg.FP currently points to the old FP.\\\\\n\nQuestion: How do we pass parameters to the callee procedure?\\\\\n\nThe caller procedure should allocate a parameter chunk on the stack that will store all the computed parameters. One solution might be to have the caller allocate the parameter chunk and then store the results. However, this might be difficult to do. The solution works fine for normal expressions (E.g. f(1 + 1, 2 + 5)) but what if we call another function as a parameter (E.g. f(g())?\\\\\n\nHere we will allocate a parameter chunk for f() and, while we are evaluating its parameters, we will need to call g(). This will create another parameter chunk and now we need to be careful to write to the correct parameter chunk.\\\\\n\nAn easier solution is to evaluate all parameters to temporary variables and then allocate a parameter chunk and write the results of those temporary variables to the newly created parameter chunk. Now that the caller procedure has created a parameter chunk, it needs to tell the callee procedure of its location.\\\\\n\nConvention: The callee procedure will expect address of its parameter chunk to be stored in Reg.allocated. However, as soon as the callee procedure creates its own frame, it will overwrite the address of its parameter chunk. So we need to \\emph{preserve} the address of the parameter chunk. Lets initially save it to a new register, Reg.savedParamPtr, and then store it in a variable called paramPtr.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Caller procedure}\n\\begin{verbatim}\nevaluate params to temp vars \nStack.allocate(paramChunk)\nparam1 = temp1\nparam2 = temp2\n..\n..\nLIS (Reg.targetPC)\nUse(procedureLabel)\nJALR(Reg.targetPC)\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\emph{Callee procedure}\n\\begin{verbatim}\nDefine(procedureLabel)\nReg.savedParamPtr = Reg.allocated\nStack.allocate(frame)\ndynamicLink = Reg.FP\nsavedPC = Reg.savedPC\nReg.FP = Reg.allocated\nparamPtr = Reg.savedParamPtr\n..\n..\nReg.savedPC = savedPC\nReg.FP = dynamicLink\nStack.pop // Pop frame\nStack.pop // Pop param chunk\nJR(Reg.savedPC)\n\\end{verbatim}\n\\end{minipage}\n\n\\vspace{7mm}\n\nWe call the code at the beginning of the callee procedure the prologue and the code at the end of the epilogue.\\\\\n\nIn general, a register is caller save if its value is not preserved by the procedure call. So if the caller wishes to preserve its value, they will need to save it. A register is callee save if its value is preserved by the procedure call. So if the callee wishes to change its value, they will need to save it and then return it back to normal.\\\\\n\nReg.FP and Reg.SP are callee save. Note that the SP is preserved because we are doing equal number of push and pops. Reg.savedPC, Reg.result and all other registers are caller save.\\\\\n\nWe also need to revisit the variable abstraction. Previously, we implemented the variable abstraction by writing/reading at an offset from the FP. However, now a procedure can also access variables in its parameter chunk.\\\\\n\n\\begin{lstlisting}\ndef eliminateVarAccessesA5(variable: Variable): Code = {\n\tif (variable is not a parameter){\n\t\tread/write at offset from FP using symbol table\n\t} else {\n\t\tread paramPtr from frame to Reg.scratch\n\t\tread/write at offset from Reg.scratch\n\t}\n\n}\n\\end{lstlisting}\n\nNote that we cannot read the paramPtr to Reg.result because it will overwrite the value of an expression during a variable assignment. For a variable assignment, \\(p = exp\\), the value of \\(exp\\) will be evaluated to Reg.result. While we are compiling the variable, if we read paramPtr into Reg.result, it will overwrite the value of the expression.\n\n\\subsubsection{Nested Procedures}\nE.g. Consider the following code:\n\\begin{lstlisting}\ndef f() = {\n\tval w = 5\n\t\n\tdef g(){\n\t\tval w = 7\n\t\th() + 10\t\t\n\t}\n\t\n\tdef h(){\n\t\t20 + w\n\t}\n\t\n\tg()\n}\n\\end{lstlisting}\n\nSuppose we call f(). What does h() evaluate to, 5 or 7?\\\\\n\nIt turns out it can be both. A programming language either has dynamic scope or static scope.\\\\\n\nDynamic scope means when the language is evaluating variables, if a variable cannot be found in the current scope, it looks in the scope of the procedure that called it. Static scope means when a language is evaluating variables, if a variable cannot be found in the current scope, it looks in the enclosing procedure's scope.\\\\\n\nIf the language was dynamic scope, then w would evaluate to 7 since g() called h(). If the language was static scope, then w would evaluate to 5 since f() is h()'s enclosing procedure.\\\\\n\nHow would we implement dynamic scope? \n\nSuppose a procedure attempts to access a variable that is not found in the frame's variables or parameters. Then we need to search for the variable in the scope of the caller procedure. We can easily get access to the caller procedure's frame because it is stored in a variable in our frame, dynamicLink. So, to implement dynamic scope, we need to update the variable abstraction to continually follow the dynamicLink until the variable is found.\\\\\n\nHow would we implement static scope?\n\nWe need a way for every procedure to access its enclosing procedure's frame. We will use a static link. For each procedure, the static link will point to the enclosing procedure's frame. If there is no enclosing procedure (i.e. the procedure is a top level procedure), then the static link will simply point to the current procedure's frame. So, to implement static scope, we need to update the variable abstraction to continually follow the static link until the variable is found. \\\\\n\nHow do we find out the static link for each procedure?\n\nSimilar to passing the parameter pointer to the callee procedure, the caller procedure will pass the static link to the callee procedure during a procedure call.\\\\\n\nConvention: The caller will pass the static link in the callee procedure's parameter chunk.\\\\\n\nThe first case we need to handle is when a procedure calls one of its direct child procedures. In this case, the static link of the callee will be the frame of the caller. For example:\\\\\n\n\\begin{lstlisting}\ndef f() = {\n\tdef g(){}\n\tdef h(){\n\t\tdef k(){}\t\n\t}\n}\n\\end{lstlisting}\n\nSuppose f() calls g(), a direct child of f(). It will pass its frame pointer to g(), which will let g() have access to its enclosing procedure's frame.\\\\\n\nNow suppose a procedure does not call one of its direct child procedures. In the above example, suppose g() calls h(). Then g() has access to h()'s static link, which is just g()'s static link. Now suppose k() calls g()\\footnote{How does k() get access to its own static link? h() must have called k() and passed its frame pointer as the static link. }. Then k() has access to g()'s static link, which is h()'s static link. Note that k() can access h()'s static link because it is a variable stored in h()'s parameter chunk and we updated the variable abstraction to continually follow the static link until a variable is found.\\\\\n\nIn both of the above cases, the caller traverses up 0 or more times to return the callee's static link. If g() calls h(), g() traverses up 0 times to return g()'s static link. If k() calls g(), k() traverses up 1 times to return h()'s static link. In general, let \\(n\\) be the number of times the caller needs to traverse up to return the callee's static link:\n\n\\begin{gather*}\nn = depth(\\text{caller procedure}) - depth(\\text{callee procedure})\n\\end{gather*}\\\\\n\nIn conclusion, to implement static scope we need to do the following things:\n\\begin{itemize}\n\\item Update the variable abstraction to continually follow the static link until a variable is found\n\\item If a procedure is calling one of its direct children, in which case \\(n\\) will be equal to \\(-1\\), just return the caller's frame pointer\n\\item Otherwise, traverse up \\(n\\) times and return the resulting procedure's static link\n\\end{itemize}\n\nIt seems the values that \\(n\\) can take on are \\(\\{-1, 0, 1, 2, ..\\}\\). Can n take on a value \\(\\leq -2\\)? Suppose f() calls k(). In this case, \\(n = 0 - 2 = -2\\). However, this call is invalid because f() should not be able to call k() without calling h() first. So n can only take values in \\(\\{-1, 0, 1, 2, ..\\}\\).\n\n\\newpage\n\n\\section{Closures}\nSo far we have dealt with integers in our language. That is, our language allows creating a variable and assigning a integer value to it. However, now we want to be able to create a variable and assign a \\emph{function} value to it.\\\\\n\nE.g. The variable \"proc\" holds a function value:\n\\begin{lstlisting}\ndef procedure(x: Int): Int = {..}\nvar proc: (Int) => Int = procedure\n..\nproc()\n\\end{lstlisting}\n\nIn the above example, we can use the \"proc\" variable to call the function it is holding.\\\\\n\nA programming language has function values if it treats functions as values and allows assigning them to a variable.\\\\\n\nNote that some languages have anonymous functions (Scala, JavaScript). Anonymous functions are functions without a name. If a language has anonymous functions then it also has function values because the only way to use anonymous functions is to store them in a variable (i.e. treat that anonymous function as a value). Our language will not have anonymous functions.\\\\\n\nWe call variables that hold function values closures. Consider the following code:\\\\\n\nE.g. Example of a closure:\n\\begin{lstlisting}\ndef increaseBy(increment: Int): (Int) => Int = {\n\tdef procedure(x: Int): Int = {\n\t\tx + increment\n\t}\n\t\n\tprocedure\n}\n\nval closure: (Int) => Int = increaseBy(1)\nclosure(5) // Returns 6\n\\end{lstlisting}\n\nThe first thing to note is the variable \"closure\" holds the function \"procedure\". Inside this procedure there are variables that are defined in the procedure (such as \"x\") and variables that are not defined in the procedure (such as \"increment\").\\\\\n\nWe call variables that are not defined in a procedure free variables. Variables that are defined (i.e. defined in parameter chunk or frame) are called bound variables.\\\\\n\nSo a closure needs to somehow hold the code of the function its holding as well as something that gives meaning to the function's free variables.\\\\\n\nA closure is a pair of two things:\n\\begin{itemize}\n\\item The code of a closure's procedure\n\\item An environment that gives meaning to the free variables inside the closure's procedure\n\\end{itemize}\n\nThe environment of a closure is really just the frame of the enclosing closure's procedure, that is, the closure procedure's static link.\\\\\n\nTo implement closures we will use something called a closure chunk. A closure chunk is a chunk that will hold the closure procedure's label and the closure procedure's environment.\\\\\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nClosure procedure's label\\\\\n\\hline\nClosure procedure's environment\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nHow and when can we create the closure chunk? Lets take a look at the previous example:\n\\begin{lstlisting}\ndef increaseBy(increment: Int): (Int) => Int = {\n\tdef procedure(x: Int): Int = {\n\t\tx + increment\n\t}\n\t\n\tprocedure // Closure creation\n}\n\nval closure: (Int) => Int = increaseBy(1)\nclosure(5) // Returns 6\n\\end{lstlisting}\nNote that the increaseBy procedure is \\emph{creating} a closure and then returning it to be stored in the \"closure\" variable. In order to create this closure we can allocate a closure chunk on the stack and set the label to be procedure's label and the environment to be the static link of procedure.\\\\\n\nAfter creating the closure chunk on the stack, the increaseBy procedure needs to return the address of the top of the closure chunk to be stored in the \"closure\" variable. Now, when we attempt to call the closure (i.e. closure(5)), we know the label of the procedure we're calling and we can simply branch to it like a normal call. Furthermore, just like we did with nested proecdures, we can pass the static link of the closure's procedure in its parameter chunk. Setting the static link will allow the closure's procedure to have access to its free variables.\\\\\n\nQuestion: What is the extent of the the \"increment\" variable?\n\nWe know it starts as soon as increaseBy begins executing but does it end after increaseBy returns? No. The problem is that as soon as increaseBy is called, we push its parameter chunk and frame onto the stack. Then when it is done executing, we pop its frame and parameter chunk from the stack. But now if we call the closure it will attempt to access the \"increment\" variable. That is, it will attempt to access popped variables.\\\\\n\nSo we cannot put the parameter chunk and frames of procedures that create closures onto the stack. We need to store them somewhere else where we can continue to access them via closure calls.\\\\\n\nAlso note that we can create copies of the \"closure\" variable and store the closure chunk in a bunch of other variables. Now each one of those variables can access the frame and parameter chunk of increaseBy.\\\\\n\nThe extent of the \"increment\" variable starts at the beginning of increaseBy and ends when all copies of the closure chunk are lost or overwritten. Only then is it impossible to access the parameter chunk and frame of increaseBy.\\\\\n\nWe will store the parameter chunk and frames of procedures that create a closure themselves or have a nested procedure that creates a closure to be on the heap.\\\\\n\nA heap is a data structure that manages memory and allows a user to allocate and free memory. We will implement a proper heap in assignment 11. For now the heap will be a simple heap that never frees memory.\\\\\n\n\\subsubsection{Objects}\nAn object is a structure with data and procedures. We say the object state is the data and the object behavior is the procedures.\\\\\n\nObject state represents the state of an object which can change depending on how that object is used via object behavior.\\\\\n\nE.g. A car object that has data saying how many kilometers its drive. Then, as the car object is driven, the state can change and increase.\\\\\n\nHow can we implement objects using the abstractions we've built so far?\n\nOne thing to note is that closures have access to data that they change change. For example:\n\\begin{lstlisting}\ndef increaseBy(increment: Int): (Int) => Int = {\n\tval value: Int = 0\n\t\n\tdef inc(x: Int): Int = {\n\t\tvalue = value + x + increment\n\t\tvalue\n\t}\n\t\n\tinc\n}\n\\end{lstlisting}\nNow when we call increaseBy, it returns a closure. Every time we call this closure it updates a free variable called \"value\". That is, every time the closure is called it changes its state.\\\\\n\nIn general, closures have state which is the environment of the closure.\\\\\n\nWe can think of an object as a collection of closures. Each of the object procedure's can be represented as closures that all close over a common environment. This allows the object to have state. If one closure (i.e. one procedure) changes the environment, all other closures (i.e. all other procedures) will see that change.\\\\\n\nThis duality of viewing objects as a collection of closures that close over a common environment and closures as objects whose data is the closure's environment allows languages to combine the concept of closures and objects and implement them both (Scala). Our language will not be implementing objects.\n\n\\subsubsection{Tail Call Optimization}\nTail call optimization is applied to optimize procedure and closure calls so that constant stack/heap space is used.\\\\\n\nThe main idea of tail call optimization is deallocating the frame and parameter chunk of a procedure early because it is no longer needed after a call.\\\\\n\nE.g. Consider the following code:\n\\begin{lstlisting}\ndef main() = {\n\tvar i: Int = 0\n\t\n\tdef loop() = {\n\t\tif (i < 10000000){\n\t\t\ti = i + 1\n\t\t\tloop()\n\t\t}\n\t}\n\t\n\tloop()\n}\n\\end{lstlisting}\nThis code recursively calls loop() and ends up generating a very large stack space. If our memory is not enough then we will get a stack overflow error.\\\\\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nloop's frame\\\\\n\\hline\nloop's parameter chunk\\\\\n\\hline\nloop's frame\\\\\n\\hline\nloop's parameter chunk\\\\\n\\hline\n..\\\\\n..\\\\\n\\hline\nloop's frame\\\\\n\\hline\nloop's parameter chunk\\\\\n\\hline\nmain's frame\\\\\n\\hline\nmain's parameter chunk\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nLets take a look at the recursive call in more detail:\n\\begin{lstlisting}\ni = i + 1\nloop()\n// Free loop's parameter chunk and frame\n\\end{lstlisting}\n\nThe problem is that each instance of loop does this and the parameter chunks and frames only get deallocated when the recursive call reaches its base case, which in turn generates a lot of stack space.\\\\\n\nQuestion: Does loop() need its parameter chunk or frame after the recursive call?\n\nNo. It doesn't use any of its parameters or variables after the recursive call. So we can actually deallocate loo()p's parameter chunk and frame early and then do the recursive call:\n\\begin{lstlisting}\ni = i + 1\n// Free loop's parameter chunk and frame\nloop()\n\\end{lstlisting}\nThis uses constant stack space.\\\\\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nloop's parameter chunk\\\\\n\\hline\nmain's frame\\\\\n\\hline\nmain's parameter chunk\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nSo when can we apply the tail call optimization? As mentioned before, we can only free the parameter chunk and frame early if they are not used after the call. That is, tail call optimization can only be applied to a call if its the last thing executed before the epilogue.\n\\begin{lstlisting}\ndef main() = {\n\tdef loop() = {\n\t\t..\n\t\tloop() // Valid tail call\n\t}\n}\n\\end{lstlisting}\nIn this case, loop() is the last thing executed before the epilogue so it is a valid tail call.\\\\\n\nWhat if the last thing we do is enclosed in an if statement?\n\\begin{lstlisting}\ndef main() = {\n\tvar i: Int = 0\n\t\n\tdef loop() = {\n\t\tif (i < 10000000){\n\t\t\ti = i + 1\n\t\t\tloop() // Valid tail call\n\t\t} else {\n\t\t\tloop() // Invalid tail call\n\t\t\tprintln(\"i = \" + i)\n\t\t}\n\t}\n\t\n\tloop()\n}\n\\end{lstlisting}\n\nIf the last thing we do is enclosed in an if statement, we need to check whether or not the call is the last thing we do in the thens or elses block, depending on which block the call is located it. The first loop() call is the last thing we do in the thens block so it is a valid tail call. The second loop() call is not the last thing we do in the elses block so it is not a valid tail call since the code after could use the frame (which it does in this case).\\\\\n\nThere is also a tricky case to handle. Consider the following code:\n\\begin{lstlisting}\ndef f() = {\n\tdef g() = {\n\t\t// g() can access f()'s parameter chunk and frame\n\t\t..\n\t}\n\t\n\tg() // Invalid tail call\n}\n\\end{lstlisting}\nEven though g() is the last thing executed before f()'s epilogue, it is not a valid tail call. The reason why is because the procedure were calling, g(), can access f()'s parameter chunk and frame because it is nested inside of f().\\\\\n\nIn general, when can only apply the tail call optimization when the call is the last thing executed before the epilogue \\emph{and} the procedure were calling is not nested within our procedure.\n\n\\newpage\n\n\\section{Formal Languages and Scanning}\nAn alphabet \\(\\sum\\) is a finite set of symbols. A string is a sequence of symbols made from an alphabet \\(\\sum\\). A formal language is a set of strings made from an alphabet \\(\\sum\\).\\\\\n\nE.g. \\(\\sum = \\{0, 1\\}\\) is called the binary alphabet. \\(\\sum = \\{a, b, c, ..., z\\}\\) is the English alphabet.\\\\\n\nE.g. 10, 10101 are strings of \\(\\sum = \\{0, 1\\}\\). abc, def, ghi are strings of \\(\\sum = \\{a, b, c, ..., z\\}\\).\\\\\n\nE.g. \\(L_1 = \\{abc, def, ghi\\}\\), \\(L_2 = \\{1, 11, 111, 1111, ...\\}\\), \\(L_2 = \\{\\epsilon, 1, 11, 111, 1111, ...\\}\\).\\\\\n\nThe empty string is denoted by \\(\\epsilon\\).\n\n\\subsubsection{Regular Languages}\nA formal language \\(L\\) is a regular language if any of the following are true statements. Let \\(L_1, L_2\\) be regular languages:\n\n\\begin{itemize}\n\\item \\(L\\) is finite\n\\item \\(L = L_1 \\cup L_2\\) (i.e. union of two regular languages)\n\\item \\(L = L_1L_2\\) (i.e. concatenation of two regular languages)\n\\item \\(L = L_1^*\\) (i.e. 0 or more concatenations of a regular language)\n\\end{itemize}\n\nNotice that the definition of regular languages is recursive. A formal language that involves any number of unions, 0 or more concatenations of regular languages is a regular language.\n\n\\subsubsection{Deterministic Finite Automaton (DFA)}\nA DFA is just a finite state machine. They are called deterministic because at each state, when you receive a symbol, there is a predefined state to go to. If there was a choice (E.g. go to A or B on 1), then it would be non-deterministic.\\\\\n\nA DFA is a 5-tuple \\((\\sum, Q, q_o, A, \\delta)\\) where:\n\n\\begin{itemize}\n\\item \\(\\sum\\) is the alphabet\n\\item \\(Q\\) is a finite set of states\n\\item \\(q_o\\) is the starting state\n\\item \\(A\\) is a finite set of accepting states\n\\item \\(\\delta\\) is called the transition function. It maps a state and an input symbol to another state and is defined for all input symbols and states. \\(\\delta: Q \\times \\sum \\rightarrow S, S \\in Q\\)\n\\end{itemize}\n\nOften times it is difficult to interpret a DFA using this definition so we usually draw a bubble diagram. A bubble diagram is a representation of a DFA where the bubbles are states and edges are transitions. A bubble has an extra circle if its an accepting state.\\\\\n\nWe use DFAs to answer the question: is a string in a regular language?\\\\\n\nWe often build DFAs for a regular language and then run that DFA on a string. If the resulting state is an accepting state then the string is in the language. If not then the string is not in the language. Also, while running the DFA on a string, if we ever get to a point where the transition function is not defined for a state and an input symbol, the string is automatically not in the language.\\\\\n\nE.g. Let L be a language that is the set of all binary strings that have an even block of 0's.\\\\\n\\begin{center}\n\\begin{tikzpicture}[node distance=3cm, on grid, auto] \n   \\node[state, initial, accepting] (q0)   {$q_0$}; \n   \\node[state] (q1) [right=of q0] {$q_1$}; \n   \n   \\path[->] \n    (q0) edge [bend left=45] node [above] {0} (q1)\n          edge [loop above] node {1} ()\n\t(q1) edge [bend right=-45] node [below] {0} (q0);\n\\end{tikzpicture}\n\\end{center}\n\nNote that there does not exist unique DFAs for a regular language. For the above example, another valid DFA is the following:\n\\begin{center}\n\\begin{tikzpicture}[node distance=3cm, on grid, auto] \n   \\node[state, initial] (q0)   {$q_0$}; \n   \\node[state] (odd) [above right=of q0] {odd}; \n   \\node[state, accepting] (even) [below right=of q0] {even}; \n   \n   \\path[->] \n    (q0) edge [bend left=45] node [above] {0} (odd)\n\t(q0) edge [bend left=-45] node [below] {1} (even)\n\t(odd) edge [bend left=45] node [right] {0} (even)\n\t(even) edge [bend left=45] node [left] {0} (odd)\n\t\t\tedge [loop below] node [below] {1} ();\n\\end{tikzpicture}\n\\end{center}\n\nLets take a look at the algorithm that decides whether a DFA recognizes a string or not:\n\\begin{lstlisting}\ndef recognize(dfa: DFA, str: List[Char]): Boolean = {\n\tvar stuck: Boolean = false\n\tvar state = dfa.qo\n\t\n\tfor (c <- str){\n\t\tif (!dfa.transition.definedAt(state, c)){\n\t\t\tstuck = true\n\t\t} else {\n\t\t\tstate = dfa.transition(state, c)\n\t\t}\t\t\n\t}\n\t\n\t!stuck && dfa.accepting.contains(state)\n}\n\\end{lstlisting}\n\n\\subsubsection{Intersection of two DFAs}\nSuppose you have two DFAs, DFA1 and DFA2. We want a new DFA that accepts a string if and only if its accepted by DFA1 \\emph{and} DFA2.\\\\\n\nLet \\(Q_1, Q_2\\) be the states of DFA1, DFA2, respectively.\\\\\n\nThen DFA1 \\(\\cap\\) DFA2 is \\((\\sum, Q, q_0, A, \\delta)\\) where:\n\\begin{itemize}\n\\item \\(Q = Q_1 \\times Q_2\\) (i.e. the set of all pairs of states of DFA1 and DFA2)\n\\item \\(q_0 = (q_1, q_2)\\) (where \\(q_1, q_2\\) are the starting states of DFA1 and DFA2)\n\\item \\(A = A_1 \\times A_2\\) (i.e. the set of all pairs of accepting states of DFA1 and DFA2)\n\\item \\(\\delta((q_1, q_2), a) = (q_1', q_2')\\) if and only if \\(\\delta(q_1, a) = q_1', \\delta(q_2, a) = q_2'\\) (i.e. transition to a new state iff the corresponding DFA1 and DFA2 states transition to their new states in DFA1, DFA2 respectively)\n\\end{itemize}\n\nE.g. Find the intersection of the following two DFAs:\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[state, initial] (A) {A};\n\t\\node[state, accepting] (B) [right=of A] {B};\n\t\n\n\t\\path[->] \n\t\t(B) edge [loop above] node {b} (B)\n\t    (A) edge [] node [above] {a} (B);\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[state, initial, accepting] (C) {C};\n\t\\node[state] (D) [right=of C] {D};\n\t\n\t\\path[->] \n\t    (C) edge [bend left=45] node [above] {a} (D)\n\t    (D) edge [bend right=-45] node [below] {b} (C);\n\\end{tikzpicture}\n\\end{center}\n\nThen the intersection of the two DFAs is:\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[state, initial] (AC) {(A,C)};\n\t\\node[state] (AD) [right=of AC] {(A,D)};\n\t\\node[state, accepting] (BC) [below=of AC] {(B,C)};\n\t\\node[state] (BD) [right=of BC] {(B,D)};\n\t\n\t\\path[->] \n\t    (AC) edge [] node [above] {a} (BD)\n\t    (BD) edge [bend right=-45] node [below] {b} (BC);\n\\end{tikzpicture}\n\\end{center}\n\n\n\\subsubsection{Non-deterministic Finite Automaton (NFA)}\nNFAs are finite state machines that are non-deterministic. This means there can be multiple transitions out of a state on the same symbol.\\\\\n\nE.g. A sample NFA:\n\n\\begin{center}\n\\begin{tikzpicture}[node distance=2cm, on grid, auto] \n   \\node[state, initial] (q0)   {$q_0$}; \n   \\node[state] (A) [above right=of q0] {A}; \n   \\node[state] (B) [below right=of q0] {B}; \n   \n   \\path[->] \n    (q0) edge [bend left=45] node [above] {1} (A)\n\t(q0) edge [bend left=-45] node [below] {1} (B);\n\\end{tikzpicture}\n\\end{center}\n\nLike DFAs, NFAs are built for a regular language to answer the question whether a string is inside the language.\\\\\n\nThe recognition algorithm for NFAs is slightly different from DFAs as there can now be multiple transitions out of a state on the same symbol. Consider the above example. There are multiple transitions out of \\(q_0\\) on the symbol 1. We don't know whether following A or B will lead to an accepting state. So the recognition algorithm follows both and checks if at least one of set of resulting end states is an accepting state.\\\\\n\nA NFA is a 5-tuple \\((\\sum, Q, q_0, A, \\delta)\\) where the transition function maps all states and symbols to a set of states you can transition to, \\(\\delta: Q \\times \\sum \\rightarrow \\{S_0, S_1, ..\\}\\).\\\\\n\nLets take a look at the algorithm that decides whether a NFA recognizes a string or not:\n\\begin{lstlisting}\ndef recognize(nfa: NFA, str: List[Char]): Boolean = {\n\tvar stuck: Boolean = false\n\n\tdef recur(state: State, str: List[Char]): List[State] = {\n\t\tif (str.isEmpty()){\n\t\t\tList(state)\n\t\t} else {\n\t\t\tif (!nfa.transition\t.definedAt(state, str.head)){\n\t\t\t\tstuck = true\n\t\t\t} else {\n\t\t\t\tnfa.transition(state, str.head).flatMap(\n\t\t\t\t\t(newState: State) => recur(newState, str.tail))\n\t\t\t}\n\t\t}\n\t}\n\n\t!stuck && recur(nfa.qo, str).exists(nfa.accepting.contains)\n}\n\\end{lstlisting}\n\n\\subsubsection{Epsilon-NFAs}\nAn \\(\\epsilon\\)-NFA is a NFA that has epsilon transitions. An epsilon transition is a transition to another state without consuming a symbol.\\\\\n\nE.g. A sample \\(\\epsilon\\)-NFA\n\n\\begin{center}\n\\begin{tikzpicture}[node distance=2cm, on grid, auto] \n   \\node[state, initial] (q0)   {$q_0$}; \n   \\node[state] (A) [above right=of q0] {A}; \n   \\node[state] (B) [below right=of q0] {B}; \n   \n   \\path[->] \n    (q0) edge [bend left=45] node [above] {$\\epsilon$} (A)\n\t(q0) edge [bend left=-45] node [below] {$\\epsilon$} (B);\n\\end{tikzpicture}\n\\end{center}\n\n\\subsubsection{Regular Expressions}\nRegular expressions are an alternate way of specifying a regular language compared to building a DFA, NFA, or \\(\\epsilon\\)-NFA for it.\\\\\n\nLike DFAs, NFAs and \\(\\epsilon\\)-NFA, regular expressions are built for a regular language to answer the question whether a string is inside the language.\\\\\n\nA regular expression is defined as the following:\n\\begin{enumerate}\n\\item \\(R := \\epsilon\\). A regular expression can be the empty string. The language this regular expression specifies is L = \\(\\{\\epsilon\\}\\). It only accepts the empty string.\n\\item \\(R := a, a \\in \\sum\\). A regular expression can be a symbol from the alphabet. The language this regular expression specifies is \\(L = \\{a\\}\\). It only accepts the symbol a.\n\\item \\(R := R_1|R_2\\). A regular expression can be the OR of two regular expressions. The languages specified is \\(L = L_1 \\cup L_2\\). It will accept any string that is either in \\(L_1\\) or \\(L_2\\), or both.\n\\item \\(R := R_1 R_2\\). A regular expression can be the concatenation of two regular expressions. The language specified is \\(L = \\{uv | u \\in L_1, v \\in L_2\\}\\). It accepts any string such that the first part of the string is inside \\(L_1\\) and the second part is inside \\(L_2\\).\n\\item \\(R := R_1^*\\). A regular expression can be 0 or more concatenations of a regular expression. The language specified is \\(L = \\{\\epsilon\\} \\cup L_1 \\cup L_1L_1 \\cup L_1L_1L_1 \\cup ...\\). It will accept any string that is the result of 0 or more concatenations of strings that are inside \\(L_1\\).\n\\end{enumerate}\n\nE.g. \\(R = \\epsilon\\). \\(L = \\{\\epsilon\\}\\).\\\\\n\nE.g. \\(\\sum = \\{a, b, c, ..., z\\}\\). \\(R = a\\). \\(L = \\{a\\}\\).\\\\\n\nE.g. \\(R = a|b\\). \\(L_1 = \\{a\\}\\), \\(L_2 = \\{b\\}\\), \\(L = \\{a, b\\}\\).\\\\\n\nE.g. \\(R = (a|b)|c\\). \\(L_1 = \\{a, b\\}\\), \\(L_2 = \\{c\\}\\), \\(L = \\{a, b, c\\}\\).\\\\\n\nE.g. \\(R = ab\\). \\(L_1 = \\{a\\}\\), \\(L_2 = \\{b\\}\\), \\(L = \\{ab\\}\\).\\\\\n\nE.g. \\(R = abc\\). \\(L_1 = \\{ab\\}\\), \\(L_2 = \\{c\\}\\), \\(L = \\{abc\\}\\).\\\\\n\nE.g. \\(R = (ab)^*\\). \\(L_1 = \\{ab\\}\\), \\(L = \\{\\epsilon, ab, abab, ababab, abababab, ...\\}\\).\\\\\n\nE.g. \\(R = a(a)^*\\). \\(L = \\{a, aa, aaa, aaaa, ...\\}\\).\\\\\n\nKleenes Theorm: Given a regular language L there exists a DFA specifying L, NFA specifying L, \\(\\epsilon\\)-NFA specifying L and a regular expression specifying L.\\\\\n\nE.g. Give a regular expression for a language of all english words containing the word \"issi\":\n\n\\(R = (A-z)^*(issi)(A-z)^*\\)\\\\\n\nE.g. Give a regular expression for a language of all binary strings with even block of 0's and even block of 1's:\n\n\\(R = ((00)^*(11)^*)^*\\)\n\n\\subsubsection{Scanning}\nScanning deals with the problem of tokenization. That is, given a regular language L and a string, break the string down into a set of tokens that are in the language.\\\\\n\nE.g. Suppose L = C++ and we have the string \"int main()\\{ return 0; \\}\".\n\nWe want to convert this string to a set of tokens that are in the C++ language. \\{int, main, (, ), \\{, return, 0, ;, \\}\\}.\\\\\n\nWe will study one algorithm that makes uses of DFAs to solve the problem of tokenization, called Maximal munch.\\\\\n\nThe basic idea of maximal munch is to use as much of the string to generate tokens.\\\\\n\nE.g. Let L = \\(\\{aa, aaa\\}\\) and w = \"aaaaa\". Maximal munch will use as much of the string as possible to generates tokens and return \\(\\{aaa, aa\\}\\). Note that the tokenization \\(\\{aa, aaa\\}\\) is still valid.\\\\\n\nIn general, scanning output is not unique. There can be many valid of tokenizations of a string. Maximal munch chooses the longest possible token for each tokenization step as a way to ensure unique output.\\\\\n\nE.g. Let L = \\(\\{aa, aaa\\}\\) and w = \"aaaa\". Maximal munch will produce the first largest token as \"aaa\", then attempt to tokenize \"a\". However there exists no valid tokenization of \"a\". So maximal munch will produce an error. Note that there exists a valid tokenization of the string, \\(\\{aa, aa\\}\\).\\\\\n\nIn general, maximal munch will not always find a valid tokenization, even if it exists.\\\\\n\nLets take a look at the algorithm. Given: a regular language L, a DFA of that language, a string w:\n\\begin{enumerate}\n\\item Run the DFA on w.\n\\item If the resulting end state is an accepting state, return w as a token.\n\\item If not, go back to the last accepting state.\n\\item If there is no last accepting state then return an error.\n\\item Otherwise, generate the token of the last accepting state and rerun this algorithm on the rest of the string.\n\\end{enumerate}\n\n\\newpage\n\n\\section{Context Free Languages and Parsing}\nSuppose we now want to scan expressions. We could try doing this using DFAs. \\\\\n\nE.g. Lets write a DFA to recognize the expression \\(a + b * c - d\\):\n\\begin{center}\n\\begin{tikzpicture}\n\t\\node[state, initial] (q0) {$q_0$};\n\t\\node[state, accepting] (exp) [right=of C] {Exp};\n\t\n\t\\path[->] \n\t    (q0) edge [bend left=45] node [above] {ID} (exp)\n\t    (exp) edge [bend right=-45] node [below] {+, -, *, /} (q0);\n\\end{tikzpicture}\n\\end{center}\n\nE.g. Now suppose we add brackets to the expression: \\((a + b) * (c - d)\\). The above DFA does not recognize this expression even though it is valid. Lets instead write a new DFA:\n\\begin{center}\n\\begin{tikzpicture}[node distance=2cm]\n\t\\node[state, initial] (q0) {$q_0$};\n\t\\node[state, accepting] (exp) [right=of C] {Exp};\n\t\\node[state] (left) [below=of q0] {};\n\t\\node[state] (right) [right=of left] {};\t\n\t\n\t\\path[->] \n\t    (q0) edge [bend left=45] node [above] {ID} (exp)\n\t    (q0) edge [bend right=45] node [left] {(} (left)\n\t    (exp) edge [bend right=-45] node [below] {+, -, *, /} (q0)\n   \t    (left) edge [bend left=45] node [above] {ID} (right)\n\t \t(right) edge [bend right=45] node [right] {)} (exp)\n\t    (right) edge [bend right=-45] node [below] {+, -, *, /} (left);\n\\end{tikzpicture}\n\\end{center}\n\nBut now this DFA doesn't work for the expression \\((a + b) * ((c) - d)\\). We would need to add another state to accept double open brackets. But even that DFA would not work for an expression with 3 open brackets.\\\\\n\nIn general, regular languages and ways of specifying regular languages are not sufficient for nested structures like expressions and procedures. The reason why is because DFAs, NFAs, \\(\\epsilon\\)-NFAs all depend on knowing the number of previous symbols that it encountered. For example, we could be in a state called \"(((\" which means we've encountered 3 open brackets. Similarly, there would be states \"((((\", \"(((((\". Each state tells us something about the previous symbols that it encountered.\\\\\n\nNow consider a nested structure like expressions which can have an arbitrary number of open and close brackets. To write a DFA/NFA/\\(\\epsilon\\)-NFA for this structure we would need an arbitrary number of states, which is not possible. We need another concept to represent nested structures, like context free languages.\\\\\n\nThe main idea of context free languages is to replace looping by recursion. As a result, many context free definitions are recursive definitions.\\\\\n\nContext free grammar is a 4-tuple \\((V, \\sum, P, s)\\) where:\n\\begin{itemize}\n\\item V is a finite set of non-terminals\n\\item \\(\\sum\\) is a finite set of terminals (also known as the alphabet)\n\\item P is a finite set of production rules (also known as grammar rules)\n\\item s is the starting non-terminal\n\\end{itemize}\n\nA non-terminal symbol expands to something else. That is, it does not terminate. A terminal symbol does not expand to something else. That is, it terminates.\\\\\n\nE.g. Consider the following context free grammar production rules for an expression:\\\\\n\nexp \\(\\rightarrow\\) ID \\(\\vert\\) exp op exp\\\\\nop \\(\\rightarrow\\) + \\(\\vert\\) - \\(\\vert\\) * \\(\\vert\\) /\\\\\n\nIn this grammar the terminals are \\(\\sum = \\) \\{ID, +, -, *, /\\} because they do not expand to anything else in the production rules. The non-terminals are V = \\{exp, op\\} because they expand to something else in the production rules\\footnote{Note that anything to the left-hand side of the production rules are non-terminals.}. By convention, the starting non-terminal is the first non-terminal, exp.\\\\\n\nWe can use this grammar to generate a parse tree of an expression.\\\\\n\nE.g. Parse tree of a + b * c:\n\\begin{center}\n\\Tree [.exp [.exp [.exp [.ID a ] ] [.op + ] [.exp [.ID b ] ] ] \n\t\t\t[.op * ] \n\t\t\t[.exp [.ID c ] ] ]\n\\end{center}\n\nConventions with context free grammar:\n\\begin{itemize}\n\\item a, b, c, d, \\(\\in \\sum\\) (i.e. The symbols a, b, c, d refer to a terminal)\n\\item A, B, C, D, S \\(\\in V\\). (i.e. The symbols A, B, C, D, S refer to a non-terminal)\n\\item W, X, Y, Z \\(\\in (\\sum \\cup V)\\). (i.e. The symbols W, X, Y, Z refer to a terminal or non-terminal)\n\\item w, x, y, z \\(\\in \\sum^*\\). (i.e. The symbols w, x, y, z refer to sequences of terminals)\n\\item \\(\\alpha, \\beta, \\gamma \\in (\\sum \\cup V)^*\\). (i.e. The symbols \\(\\alpha, \\beta, \\gamma\\) refer to sequences of terminals and non-terminals)\n\\end{itemize}\n\nWe say:\\\\\n\n\\(\\alpha\\) A \\(\\beta \\underbrace{\\Rightarrow}_\\text{directly derives} \\alpha\\) \\(\\gamma\\) \\(\\beta\\) if \\(\\{A \\rightarrow \\gamma\\} \\in P\\).\\\\\n\n\\(\\alpha_1 \\underbrace{\\Rightarrow^*}_\\text{derives} \\alpha_n\\) if there is a chain of directly derives leading from \\(\\alpha_1\\) to \\(\\alpha_n\\) (i.e. \\(\\alpha_1 \\Rightarrow \\alpha_2 \\Rightarrow ... \\Rightarrow \\alpha_n\\)).\\\\\n\nE.g. exp \\(\\Rightarrow\\) exp op exp\\\\\n\nE.g. exp \\(\\Rightarrow^*\\) ID + ID since exp \\(\\Rightarrow\\) exp op exp \\(\\Rightarrow\\) exp + exp \\(\\Rightarrow\\) ID + exp \\(\\Rightarrow\\) ID + ED\\\\\n\nThe language generated by a context free grammar G = \\((V, \\sum, P, s)\\) is L = \\(\\{w \\in \\sum^* \\vert s \\Rightarrow^* w\\}\\). That is, the language generated by G is a set of sequences of terminals that the starting non-terminal derives.\\\\\n\nWe say a context free grammar is ambiguous if there exists multiple valid parse trees for an expression. Otherwise it is unambiguous. \\\\\n\nE.g. The context free grammar introduced in the last example is ambiguous. Consider the two valid parse trees for the expression a + b * c.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{center}\n\\Tree [.exp [.exp [.exp [.ID a ] ] [.op + ] [.exp [.ID b ] ] ] \n\t\t\t[.op * ] \n\t\t\t[.exp [.ID c ] ] ]\n\\end{center}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{center}\n\\Tree [.exp [.exp [.ID a ] ]\n\t\t\t[.op + ] \n\t\t\t[.exp [.exp [.ID b ] ] [.op * ] [.exp [.ID c ] ] ] ]\n\\end{center}\n\\end{minipage}\n\n\\vspace{7mm}\n\nIn the above example, which parse tree is correct? Bedmas tells us its the one on the right but there are expressions where even applying bedmas can result in multiple valid parse trees, such as a - b - c.\\\\\n\nIn general, we want to specify languages precisely and get a unique parse (just like we want a unique scan). That is, we want to work with unambiguous grammar. However, the problem of figuring out whether a grammar is unambiguous is a undecidable by an algorithm. As a result, we often have to come up with a grammar and make sure it is unambiguous through rigorous testing. Fortunately, the grammar for the language we are implementing on the assignments, Lacs, is unambiguous.\\\\\n\nE.g. Example of a unambiguous context free grammar. There exists only one valid parse tree for the expression a - b - c:\\\\\n\nexp \\(\\rightarrow\\) term \\(\\vert\\) exp + term \\(\\vert\\) exp - term\\\\\nterm \\(\\rightarrow\\) ID \\(\\vert\\) term * ID \\(\\vert\\) term / ID\\\\\n\n\\begin{center}\n\\Tree [.exp [.exp [.exp [.term [.ID a ] ] ] [-  ] [.term [.ID b ] ] ]\n\t\t\t[-  ]\n\t\t\t[.term [.ID c ] ] ]\n\\end{center}\n\n\\subsubsection{Parsing}\nParsing deals with the problem of generating a parse tree for a sequence of terminals. The sequence of terminals are the sequence of tokens we got from running the scanner on our input program.\\\\\n\nWe will study one algorithm for generating a parse tree, called the CYK algorithm.\\\\\n\nThe first question we need to answer is whether \\(\\alpha \\Rightarrow^* x\\). After we implement the algorithm to answer that question, we will extend it to generate a parse tree if \\(\\alpha \\Rightarrow^* x\\) is true.\\\\\n\nThere are 4 sub cases to handle:\n\\begin{enumerate}\n\\item \\(\\alpha = \\epsilon\\). When does \\(\\epsilon \\Rightarrow^* x\\)? The only time \\(\\epsilon\\Rightarrow^* x\\) is when \\(x = \\epsilon\\).\n\\item \\(\\alpha = a\\beta\\). Note that \\(a\\) is a terminal symbol. That means anything \\(\\alpha\\) derives has to start with \\(a\\) since \\(a\\) cannot expand to anything else. When does \\(a\\beta \\Rightarrow^* x\\)? The only time this happens is when \\(x = az\\) and \\(\\beta \\Rightarrow^* z\\).\n\\item \\(\\alpha = A\\). In this case we need to expand \\(A\\) and go through all of its production rules. That is, for all \\(\\gamma\\), \\(A \\rightarrow \\gamma \\in P\\), we need to check if \\(\\gamma \\Rightarrow^* x\\). If at least one \\(\\gamma \\Rightarrow^* x\\) then \\(A \\Rightarrow^* x\\). If not, then \\(A \\nRightarrow^* x\\).\n\\item \\(\\alpha = A\\beta\\). When does \\(A\\beta \\Rightarrow^* x\\)? We need to split \\(x\\) into all possible sub-strings, \\(x_1, x_2\\), and check if \\(A \\Rightarrow^* x_1\\) and \\(\\beta \\Rightarrow^* x_2\\). If at least one of these is true for some sub-string \\(x_1, x_2\\), then \\(A\\beta \\Rightarrow^* x\\).\n\\end{enumerate}\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef parse((*$\\alpha, x$*)) = {\n\tif ((*$\\alpha$*).isEmpty()){\n\t\treturn (*$x$*).isEmpty()\n\t} else if ((*$\\alpha = a\\beta$*)){\n\t\treturn (*$x = az$*) && parse((*$\\beta, z$*))\n\t} else if ((*$\\alpha = A$*)){\n\t\tfor each production rule: (*$A \\rightarrow \\gamma \\in P$*) {\n\t\t\tif (parse((*$\\gamma, x$*)){\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false\n\t} else {\n\t\t(*$\\alpha = A\\beta$*)\n\t\tfor each ((*$x = x_1x_2$*)) {\n\t\t\tif (parse((*$A, x_1$*)) && parse((*$\\beta, x_2$*)){\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false\n\t}\n}\n\\end{lstlisting}\n\nLets run the algorithm on an example to see if there are any bugs.\\\\\n\nE.g. Run the CYK parsing algorithm on parse(\\(exp \\Rightarrow^* ID + ID\\)).\n\nRecall the context free grammar:\\\\\n\nexp \\(\\rightarrow\\) ID \\(\\vert\\) exp op exp\\\\\nop \\(\\rightarrow\\) + \\(\\vert\\) - \\(\\vert\\) * \\(\\vert\\) /\n\n\\begin{itemize}\n\t\\item [3.] Notice that \\(exp = A\\). For each production rule:\n\t\\begin{itemize}\n\t\t\\item [-] parse(\\(ID \\Rightarrow^* ID + ID\\))? Notice that \\(ID = a\\beta\\) where \\(a = ID, \t\t\t\\beta = \\epsilon\\).\n\t\t\\begin{itemize}\n\t\t\t\\item [2.] We see that \\(x = az\\) where \\(a = ID, z =\\) + \\(ID\\). Does parse(\\(\\epsilon \t\t\t\\Rightarrow^* + \\) \\(ID\\))?\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item [1.] We see that \\(+\\) \\(ID \\neq \\epsilon\\), return false.\n\t\t\t\\end{itemize}\n\t\tSo parse(\\(ID \\Rightarrow^* ID + ID\\)) is false.\n\t\t\\end{itemize}\n\t\t\\item [-] parse(\\(exp\\) \\(op\\) \\(exp \\Rightarrow^*\\) \\(ID\\) + \\(ID\\))? Notice that \\(exp\\) \\(op\\) \\(exp\\) = \\(A\\beta\\) where \\(A = exp, \\beta =\\) \\(op\\) \\(exp\\).\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item [4.] What are all the different ways to split \\(ID\\) + \\(ID\\)? \\(\\{(\\epsilon, ID + ID), (ID, +\\) \\(ID), (ID\\) \\(+, ID), (ID + ID, \\epsilon)\\}\\). \n\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\\item [-] parse(\\(exp\\) \\(\\Rightarrow^* \\epsilon\\)) and parse(\\(op\\) \\(exp\\) \\(\\Rightarrow^* ID + ID\\)). Lets first focus on parse(exp \\(\\Rightarrow^* \\epsilon\\)). Notice that \\(exp = A\\). parse(\\(ID \\Rightarrow^* \\epsilon\\))? False. parse(\\(exp\\) \\(op\\) \\(exp\\) \\(\\Rightarrow^* \\epsilon\\))? This leads to answering the question parse(\\(exp \\Rightarrow^* \\epsilon\\)) which is an infinite loop.\n\t\t\t\t\t\\item [-] parse(\\(exp \\Rightarrow^* ID\\)) and parse(\\(op\\) \\(exp\\) \\(\\Rightarrow^*\\) \\(+\\) \\(ID\\)). Lets focus on parse(\\(exp \\Rightarrow^* ID\\)). True. And so on...\n\t\t\t\t\\end{itemize}\n\t\t\t\\end{itemize}\n\t\\end{itemize}\n\\end{itemize}\n\nWe see that the algorithm runs fine on the example except there is an infinite loop. We wanted to figure out whether parse(\\(exp \\Rightarrow^* \\epsilon\\)) but, as a process of figuring that out, we asked whether parse(\\(exp \\Rightarrow^* \\epsilon\\)). This is an infinite loop.\\\\\n\nIn order to fix this we can apply memoization to the algorithm. The basic idea of memoization is: if you have to compute the result twice, just use the previous result. Whenever we need to compute \\(\\alpha \\Rightarrow^* x\\), check the memo table. If we've computed it before, return the result from the memo table. Otherwise, compute \\(\\alpha \\Rightarrow^* x\\) and update the memo table.\\\\\n\nFurthermore, we can use memoization to fix the infinite loop in the algorithm. Before the start of the core algorithm of checking whether \\(\\alpha \\Rightarrow^* x\\), set the value in the memo table to be false. So now, if the algorithm attempts to answer the question \\(\\alpha \\Rightarrow^* x\\) again, it will check the memo table and return false.\\\\\n\nWhat is the space complexity of the parsing CYK algorithm? We can figure this out by looking at the memo table.\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\nval memo = Map[((*$\\underbrace{Seq[Symbol]}_\\text{$\\alpha$}$*), (*$\\underbrace{Int}_\\text{from}$*), (*$\\underbrace{Int}_\\text{length}$*)), Option[Seq[Tree]]]\n\\end{lstlisting}\n\nWhat are all the possible values for \\(\\alpha\\)? \n\nWe know \\(\\alpha\\) starts as the starting non-terminal and, after that, is always a prefix or suffix of some right hand side production rule. Since our context free grammar has finite production rules, there are finite many possible values for \\(\\alpha\\). From and length are used to refer to a substring of \\(x\\) in an efficient way and there are \\(O(\\vert x \\vert)\\) many possibilities for each of them. So the space time complexity is \\(O(\\vert 1 \\vert) * O(\\vert x \\vert) * O(\\vert x \\vert) = O(\\vert x^2 \\vert)\\).\\\\\n\nWhat is the running time complexity of the parsing CYK algorithm? \n\nAt worst, the entire memo table is filled. So it is \\(\\Omega(x^2)\\). We also need to account for the time it takes to split a string into all possible sub strings, \\(O(\\vert x \\vert)\\). So the run time complexity is \\(O(\\vert x^3 \\vert)\\).\\\\\n\nHow can we modify the algorithm to generate a parse tree if \\(\\alpha \\Rightarrow^* x\\)? Lets consider all 4 sub cases:\n\n\\begin{enumerate}\n\\item parse(\\(\\epsilon \\Rightarrow^* \\epsilon\\)). Return empty sequence of tree nodes.\n\\item parse(\\(a\\beta \\Rightarrow^* az\\)). Return Tree(a, []) +: parse(\\(\\beta \\Rightarrow^* z\\)).\n\\item parse(\\(A \\Rightarrow^* x\\)) and there exists \\(\\gamma\\), \\(A \\rightarrow \\gamma \\in P\\), such that parse(\\(\\gamma \\Rightarrow^* x\\)). Return Tree(\\(A\\), parse(\\(\\gamma \\Rightarrow^* x\\))).\n\\item parse(\\(A\\beta \\Rightarrow^* x\\)) and there exists \\(x = x_1x_2\\) such that parse(\\(A \\Rightarrow^* x_1\\)) and parse(\\(\\beta \\Rightarrow^* x_2\\)). Return parse(\\(A \\Rightarrow^* x_1\\)) ++ parse(\\(\\beta \\Rightarrow^* x_2\\)).\n\\end{enumerate}\n\n\\subsubsection{Parsing Algorithms Comparison}\n\\begin{itemize}\n\\item [] Parsing CYK. Advantages: General, easy to learn, works for all grammars. Disadvantages: Space complexity is large, \\(O(\\vert x^2 \\vert)\\) and time complexity is large, \\(O(\\vert x^3 \\vert)\\).\n\\item [] LR(1)/LR(k). Advantages: Efficient, \\(O(\\vert x \\vert)\\). Can use LR(1) parsers to test for ambiguity (if it can be parsed by LR(1) then grammar is unambiguous). Disadvantages: Takes 3 weeks to learn. Works for most unambiguous practical grammars but not all.\n\\item [] LL(1)/LL(k). Advantages: Efficient, \\(O(\\vert x \\vert)\\). Disadvantages: Takes 1.5 weeks to learn. Works for few grammars. Always generates a right associative parse tree.\n\\item [] Earley parser. Advantages: Works for all grammars. Moderately efficient. Running time is \\(O(\\vert x^2 \\vert)\\) on unambiguous grammar and \\(O(\\vert x^3 \\vert)\\) on ambiguous grammar. Disadvantages: LR(1)/LR(k) parsers can parse most grammars in \\(O(\\vert x \\vert)\\).\n\\end{itemize}\n\n\\subsubsection{Correct Prefix Property}\nSuppose that you have a program that you spent a long time building and try compiling it. However, there is a syntax error in the program and so the parsing CYK algorithm cannot generate a parse tree for the program. It would be nice to know why the parse tree cannot be generated to help debug the syntax error.\\\\\n\nA parser has the correct prefix property if it halts as soon as it encounters a terminal symbol that cannot possibly make a parse tree.\\\\\n\nSuppose \\(w\\) is a sequence of terminals that represents a program. Let \\(w = xaz\\) where \\(w \\not\\in Language\\). Then \\(w\\) does not have a parse tree.\\\\\n\nSuppose that \\(\\exists y, xy \\in Language\\). That is, its possible for some part of \\(w\\) to be in the language and have a parse tree. Then we know \\(\\forall v, xav \\not\\in Language\\).\\\\\n\nA parser has the correct prefix property if it rejects the program as soon as it encounters \\(a\\) (a terminal that cannot make a parse tree). Most parsers have this property except the parsing CYK algorithm.\n\n\\newpage\n\n\\section{Context Sensitive Analysis}\nContext sensitive analysis deals with rejecting incorrect programs, resolving names and performing type checking.\n\n\\subsubsection{Rejecting incorrect programs}\nWe need to reject programs that have duplicate names and undeclared names. We will do this during type checking.\n\n\\subsubsection{Resolving names}\nEvery ID token in Lacs is used to refer to a variable or a procedure. We need to map all names to either a variable or a procedure.\\\\\n\nE.g. Consider the following code:\n\\begin{lstlisting}\ndef f(): Int = {\n\tvar y: Int = 10;\n\t\n\tdef p(): Int = {\n\t\tvar x: Int = 5;\n\t\tx + y\n\t}\n\t\n\tdef q(): Int = {\n\t\tvar x: Int = 6;\n\t\tx + y\t\n\t}\n\t\n\ty\n}\n\\end{lstlisting}\nThe procedures p() and q() both have a variable \\(x\\). This is valid because a variable can mean different things depending on its scope. Also notice that p() and q() can access \\(y\\), a variable declared in f()'s scope.\\\\\n\nIn general, to resolve names, we need to build a symbol table that maps names to variables or procedures, for \\emph{every} procedure scope. Furthermore, any procedure that is nested within another procedure should inherit the parent procedure's symbol table.\\\\\n\nE.g. Consider the following code:\n\\begin{lstlisting}\ndef f(): Int = {\n\tvar x: Int;\n\t\n\tdef g(): Int = {\n\t\tvar x: Int;\n\t\tx = 5;\n\t\tx\n\t}\n\t\n\tx =  6;\n\tx\n}\n\\end{lstlisting}\nNotice that inside g()'s scope \\(x\\) means 5 not 6.\\\\\n\nIn general, nested procedures need to inherit and shadow their parent procedure's symbol table. Any outer variable that is declared with the same name as an inner variable needs to be overwritten by the inner procedure.\n\n\\subsubsection{Type checking}\nIn Lacs there are two types:\n\\begin{itemize}\n\\item 2's complement integers between \\(-2^{31}\\) to \\(2^{31} - 1\\) with arithmetic module \\(2^{32}\\)\n\\item Function values that represent a function that takes arguments with specified types and returns a return type (E.g. \\((Int, Int) \\Rightarrow Int\\))\n\\end{itemize}\n\nA type system is a set of rules that computes the type of an expression based on the types of its sub-expressions. We can follow these rules to determine the type of any expression.\\\\\n\nA type system is sound if whenever the type system computes a type \\(\\tau\\) for an expression, the expression actually evaluates to a value of type \\(\\tau\\). Essentially it means the type system is not lying. Fortunately, the Lacs type system is sound.\n\n\\subsubsection{Lacs Type System}\nLet \\(E \\in\\) \\{expras, expra, expr, term, factor\\} and \\(\\tau \\in\\) \\{type\\}. Note that \\(\\Gamma \\vdash E:\\) \\textbf{Int} means if we type check \\(E\\), we get an Int. \\(\\Gamma(E)\\) means getting the expression's type from the symbol table. Everything above the overbar are conditions for the rule to be true.\\\\\n\n\\begin{enumerate}\n\\item Literals\\\\\n\n$\\overline{\\Gamma \\vdash \\textbf{NUM}: \\textbf{Int}}$\n\n\\item IDs\\\\\n\n$\\overset{\\displaystyle \\Gamma(\\textbf{ID}) = \\tau}{\\overline{\\Gamma \\vdash \\textbf{ID}: \\tau}}$\n\n\\item Parenthesis\\\\\n\n$\\overset{\\displaystyle \\Gamma \\vdash E: \\tau}{\\overline{\\Gamma \\vdash (E): \\tau}}$\n\n\\item Arithmetic\\\\\n\n$\\overset{\\displaystyle \\Gamma \\vdash E_1: \\textbf{Int}, \\ \\Gamma \\vdash E_2: \\textbf{Int}}{\\overline{\\Gamma \\vdash E_1 \\ \\{+, -, *, /\\} \\ E_2: \\textbf{Int}}}$\n\n\\item Assignment\\\\\n\n$\\overset{\\underline{\\displaystyle \\Gamma(\\textbf{ID}) = \\tau, \\ \\Gamma \\vdash E: \\tau}}{\\Gamma \\vdash \\textbf{ID} = E: \\tau}$\n\n\\item Sequence of expression\\\\\n\n$\\overset{\\underline{\\displaystyle \\Gamma \\vdash E_1: \\tau', \\ \\Gamma \\vdash E_2: \\tau}}{\\Gamma \\vdash E_1; E_2: \\tau}$\n\nNote that we still need to type check \\(E_1\\) to make sure its valid and has a type. Otherwise, \\(E_1\\) could be an invalid expression.\n\n\\item If statements\\\\\n\n$\\overset{\\displaystyle \\Gamma \\vdash E_1: \\textbf{Int}, \\ \\Gamma \\vdash E_2: \\textbf{Int}, \\ \\Gamma \\vdash E_3: \\tau, \\ \\Gamma \\vdash E_4: \\tau}{\\overline{\\Gamma \\vdash \\textbf{if} \\ (E_1 \\ \\{==, !=, >=, <=, >, <\\} \\ E_2)\\ E_3 \\ \\textbf{else} \\ E_4: \\tau}}$\n\nIn an if statement, the thens and elses block must return a value of the same type.\n\n\\item Procedure call\\\\\n\n$\\overset{\\underline{\\displaystyle \\Gamma \\vdash E'(\\overline{\\tau}) \\Rightarrow \\tau', \\ \\forall i. \\ \\Gamma \\vdash E_i: \\tau_i}}{\\Gamma \\vdash E'(\\overline{E}): \\tau'}$\n\nThe parameter and argument types must match.\n\n\\item Procedure Declaration\\\\\n\n$\\overset{\\underline{\\displaystyle \\Gamma + \\overline{\\text{vardef}} + \\overline{\\text{vardef'}} + \\overline{\\text{defedef}} \\vdash \\forall i. \\text{defdef}_i, \\ \\Gamma + \\overline{\\text{vardef}} + \\overline{\\text{vardef'}} + \\overline{\\text{defedef}} \\vdash E: \\tau}}{\\Gamma \\vdash \\textbf{def ID}(\\overline{\\text{vardef}}): \\tau = \\{\\overline{\\text{vardef'}}, \\overline{\\text{defdef}}, E\\}}$\n\nAs mentioned before, we need to make sure there are no duplicate names. So all names in \\(\\overline{\\text{vardef}}\\), \\(\\overline{\\text{vardef'}}\\), \\(\\overline{\\text{defdef}}\\) need to be distinct, that is, all parameter names, variable names and nested procedure names need to be distinct.\\\\\n\nWe need to type check each of the procedure's nested procedures. However, recall that every nested procedure should inherit and shadow their parent procedure's symbol table. Therefore we need to update the symbol table with the newly added parameters, variables and nested procedures names before we type check each nested procedure.\\\\\n\nWe also need to type check \\(E\\) to make sure it is the same as the procedure's return type.\n\n\\item Program\\\\\n\n$\\overset{\\underline{\\displaystyle \\emptyset + \\ \\overline{\\text{defdef}} \\vdash \\forall i. \\ \\text{defdef}_i}}{\\emptyset \\vdash \\overline{\\text{defdef}}}$\n\nIn Lacs a program is just a sequence of top level procedures. In order to type check a program we need to type check all top level procedures. However, recall that top level procedures can call each other. Therefore we need to update the empty symbol table with all the top level procedures names.\n\\end{enumerate}\n\n\\newpage\n\n\\section{Memory Management}\nA heap is a data structure that manages memory so that it can be allocated and freed at any time.\\\\\n\nThere are two key functions of a heap:\n\\begin{itemize}\n\\item Allocate a new chunk of a given size\n\\item Deallocate a  chunk, returning it back into the memory pool so it can be used later\n\\end{itemize}\n\nDeallocation can be explicit (like in C/C++) or explicit (like in Java, Scala). We will study both of these topics, starting with how to implement an early day C heap.\n\n\\subsubsection{Early day C Memory Management}\nMain idea: use a linked list of free chunks. This linked list will contain all chunks that are currently free in the heap.\\\\\n\nEvery chunk needs to store a next pointer that points to the next free chunk in the linked list.\n\n\\[\n\\begin{tabular}{|c|}\n\\hline\nsize of chunk\\\\\n\\hline\nnext pointer\\\\\n\\hline\ndata\\\\\n..\\\\\n\\hline\n\\end{tabular}\n\\]\\\\\n\nConvention: The heapStart register will store the head of the linked list. A chunk's next pointer will point to one word after the end of the heap to indicate that it is the last chunk in the linked list.\\\\\n\nSuppose we want to allocate a chunk of a given size but the only large enough free chunk is the head of the linked list. Then we would need to update the head of the linked list. In order to avoid this case, we will use a dummy head.\\\\\n\nThe initialization code for the heap will need to initialize the dummy head and set the next pointer to a chunk that is almost the size of the entire heap.\\\\\n\n\\begin{lstlisting}\ndef setSize(chunk, size) = assignToAddr(chunk, size)\n\ndef setNext(chunk, next) = assignToAddr(chunk + 4, next)\n\ndef init() = {\n\tsetSize(heapStart, 8)\n\tval newChunk = heapStart + 8\n\tsetSize(newChunk, heapSize - 8)\n\tsetNext(heapStart, newChunk)\n\tsetNext(newChunk, heapStart + heapSize)\n}\n\\end{lstlisting}\nSo now the linked list looks as follows:\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {dummy head};\n  \\node[list,on chain] (B) {almost entire heap};\n  \\node[on chain,draw,inner sep=6pt] (D) {};\n  \\draw (D.north east) -- (D.south west);\n  \\draw (D.north west) -- (D.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) -- (B);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) -- (D);\n\\end{tikzpicture}\n\\end{center}\n\nSuppose we want to allocate a chunk of size: wanted. We need to find a chunk inside the linked list of free chunks that has size at least wanted + 8 and then remove it from the linked list (as it is no longer free).\\\\\n\nIn order to remove a node from a linked list we need to set prev.next = curr.next:\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain] (B) {curr};\n  \\node[list,on chain] (C) {};\n  \\node[list,on chain] (D) {};    \n  \\node[on chain,draw,inner sep=6pt] (E) {};\n  \\draw (E.north east) -- (E.south west);\n  \\draw (E.north west) -- (E.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) -- (B);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) -- (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);  \n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);      \n\\end{tikzpicture}\n\\end{center}\n\nSuppose we find a chunk that is much bigger than wanted + 8. If we just gave that chunk to the user the heap would be full immediately. So we need to detect if a chunk is too big for the size the user wanted and, if so, split it into two chunks: one that has size wanted + 8 and another chunk that is the leftover chunk.\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{center}\nLarge chunk\\\\\n\\begin{tabular}{|c|}\n\\hline\nSize \\(\\geq\\) wanted + 8\\\\\n\\hline\nnext\\\\\n\\hline\n..\\\\\n..\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\n\\begin{center}\nUser's chunk\\\\\n\n\\begin{tabular}{|c|}\n\\hline\nSize = wanted + 8\\\\\n\\hline\nnext\\\\\n\\hline\n..\\\\\n..\\\\\n\\hline\n\\end{tabular}\\\\\n\n\\vspace{7mm}\n\nLeftover chunk\\\\\n\n\\begin{tabular}{|c|}\n\\hline\nSize \\(\\geq\\) 8\\\\\n\\hline\nnext\\\\\n\\hline\n..\\\\\n..\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{minipage}\n\n\\vspace{7mm}\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef size(chunk) = deref(chunk)\n\ndef next(chunk) = deref(chunk + 4)\n\ndef malloc(wanted) = {\n\tdef find(prev) = {\n\t\tval current = next(prev)\n\t\t\n\t\tif (size(current) < wanted + 8){\n\t\t\tfind(current)\n\t\t} else {\n\t\t\tif (size(current) (*$\\geq$*) wanted + 16){\n\t\t\t\tval newChunk = current + (wanted + 8)\n\t\t\t\tsetSize(newChunk, size(current) - (wanted + 8))\n\t\t\t\tsetSize(current, wanted + 8)\n\t\t\t\tsetNext(prev, newChunk)\n\t\t\t\tsetNext(newChunk, next(current))\n\t\t\t} else {\n\t\t\t\tsetNext(prev, next(current))\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfind(heapStart)\n}\n\\end{lstlisting}\nNote that we need to add the leftover chunk into the linked list since it is a free chunk.\\\\\n\nSuppose the user wants to deallocate a chunk, called toFree. We need to add it back into the linked list since it will be a free chunk after deallocation. Suppose we add toFree back into the linked list and it is directly above or below another chunk that is free. We would want to merge these free chunks together into one, otherwise the user may not be able to allocate a large chunk. There are 4 sub cases to deal with:\\\\\n\n\\begin{enumerate}\n\\item Chunks before and after toFree are both non-free:\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain, fill=gray!25] (C) {toFree};\n  \\node[list,on chain, fill=gray!25] (D) {...};    \n  \\node[list,on chain] (E) {curr};\n  \\node[on chain,draw,inner sep=6pt] (F) {};\n  \\draw (F.north east) -- (F.south west);\n  \\draw (F.north west) -- (F.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (E);\n  \\draw[*->] let \\p1 = (E.two), \\p2 = (E.center) in (\\x1,\\y2) -- (F);\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain] (C) {toFree};\n  \\node[list,on chain, fill=gray!25] (D) {...};    \n  \\node[list,on chain] (E) {curr};\n  \\node[on chain,draw,inner sep=6pt] (F) {};\n  \\draw (F.north east) -- (F.south west);\n  \\draw (F.north west) -- (F.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) to[out=-45,in=-135] (E);\n  \\draw[*->] let \\p1 = (E.two), \\p2 = (E.center) in (\\x1,\\y2) -- (F);\n\\end{tikzpicture}\n\\end{center}\n\nWe need to:\n\\begin{lstlisting}\nprev.next = toFree\ntoFree.next = curr\n\\end{lstlisting}\n\n\\item Chunk after toFree is free:\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain, fill=gray!25] (C) {toFree};\n  \\node[list,on chain] (D) {curr};\n  \\node[list,on chain] (E) {};      \n  \\node[on chain,draw,inner sep=6pt] (F) {};\n  \\draw (F.north east) -- (F.south west);\n  \\draw (F.north west) -- (F.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (D);\n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n  \\draw[*->] let \\p1 = (E.two), \\p2 = (E.center) in (\\x1,\\y2) -- (F);  \n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain] (C) {toFree + curr};\n  \\node[list,on chain] (D) {};  \n  \\node[on chain,draw,inner sep=6pt] (E) {};\n  \\draw (E.north east) -- (E.south west);\n  \\draw (E.north west) -- (E.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);  \n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n\\end{tikzpicture}\n\\end{center}\n\nWe need to:\n\\begin{lstlisting}\nMerge toFree + curr\nprev.next = toFree\ntoFree.next = curr.next\n\\end{lstlisting}\n\nAlso, we don't want to merge with current if previous is at the end of the heap.\n\n\\item Chunk before toFree is free:\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {toFree};\n  \\node[list,on chain, fill=gray!25] (C) {...};\n  \\node[list,on chain] (D) {curr};    \n  \\node[on chain,draw,inner sep=6pt] (E) {};\n  \\draw (E.north east) -- (E.south west);\n  \\draw (E.north west) -- (E.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (D);\n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev + toFree};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain] (C) {curr};    \n  \\node[on chain,draw,inner sep=6pt] (D) {};\n  \\draw (D.north east) -- (D.south west);\n  \\draw (D.north west) -- (D.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);  \n\\end{tikzpicture}\n\\end{center}\n\nWe need to:\n\\begin{lstlisting}\nMerge prev + toFree\n\\end{lstlisting}\n\nAlso, we don't want to merge with the dummy head.\n\n\\item Chunks before and after toFree are free:\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {toFree};\n  \\node[list,on chain] (C) {curr};    \n  \\node[list,on chain] (D) {};    \n  \\node[on chain,draw,inner sep=6pt] (E) {};\n  \\draw (E.north east) -- (E.south west);\n  \\draw (E.north west) -- (E.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);  \n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n\\end{tikzpicture}\n\\end{center}\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev + toFree + curr};  \n  \\node[list,on chain] (B) {};    \n  \\node[on chain,draw,inner sep=6pt] (C) {};\n  \\draw (C.north east) -- (C.south west);\n  \\draw (C.north west) -- (C.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) -- (B);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) -- (C);\n\\end{tikzpicture}\n\\end{center}\n\nWe need to:\n\\begin{lstlisting}\nMerge prev + toFree + curr\nprev.next = curr.next\n\\end{lstlisting}\nThis case is just an extension of sub case 2 and 3. However, if we applied sub case 2 and 3 (in that order), the prev chunk will be stuck pointing at toFree + curr chunk.\\\\\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain] (B) {toFree + curr};\n  \\node[list,on chain] (C) {};  \n  \\node[on chain,draw,inner sep=6pt] (D) {};\n  \\draw (D.north east) -- (D.south west);\n  \\draw (D.north west) -- (D.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) -- (B);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) -- (C);  \n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);\n\\end{tikzpicture}\n\\end{center}\n\nTo fix this, we need to update sub case 3 to set: prev.next = toFree.next.\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev + toFree + curr};  \n  \\node[list,on chain] (B) {};    \n  \\node[on chain,draw,inner sep=6pt] (C) {};\n  \\draw (C.north east) -- (C.south west);\n  \\draw (C.north west) -- (C.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) -- (B);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) -- (C);\n\\end{tikzpicture}\n\\end{center}\n\n\\item Sub case 3, Chunk before toFree is free (revised):\n\nThe solution for sub case 4 actually changes sub case 3 and adds a new line of code: prev.next = toFree.next. We need to make sure it still works. What happens if sub case 2 does not occur (i.e. we don't merge with current)? Then we set toFree.next = current, as a part of sub case 1.\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev};\n  \\node[list,on chain, fill=gray!25] (B) {toFree};\n  \\node[list,on chain, fill=gray!25] (C) {...};\n  \\node[list,on chain] (D) {curr};    \n  \\node[on chain,draw,inner sep=6pt] (E) {};\n  \\draw (E.north east) -- (E.south west);\n  \\draw (E.north west) -- (E.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (D);\n  \\draw[*->] let \\p1 = (B.two), \\p2 = (B.center) in (\\x1,\\y2) to[out=-45,in=-135] (D);  \n  \\draw[*->] let \\p1 = (D.two), \\p2 = (D.center) in (\\x1,\\y2) -- (E);\n\\end{tikzpicture}\n\\end{center}\n\nThen, if sub case 3 occurs, we merge prev and toFree and do prev.next = toFree.next which does not change sub case 3.\n\n\\begin{center}\n\\begin{tikzpicture}[list/.style={rectangle split, rectangle split parts=2,\n    draw, rectangle split horizontal}, >=stealth, start chain]\n\n  \\node[list,on chain] (A) {prev + toFree};\n  \\node[list,on chain, fill=gray!25] (B) {...};\n  \\node[list,on chain] (C) {curr};    \n  \\node[on chain,draw,inner sep=6pt] (D) {};\n  \\draw (D.north east) -- (D.south west);\n  \\draw (D.north west) -- (D.south east);\n  \\draw[*->] let \\p1 = (A.two), \\p2 = (A.center) in (\\x1,\\y2) to[out=-45,in=-135] (C);\n  \\draw[*->] let \\p1 = (C.two), \\p2 = (C.center) in (\\x1,\\y2) -- (D);  \n\\end{tikzpicture}\n\\end{center}\n\n\\end{enumerate}\n\n\\begin{lstlisting}\ndef free(toFree) = {\n\tdef find(prev) = {\n\t\tval current = next(prev)\n\t\t\n\t\tif (current < toFree){\n\t\t\tfind(current)\n\t\t} else {\n\t\t\t// Case 2, check if we can merge with current\n\t\t\tif (toFree + size(toFree) == current && \n\t\t\t\t\tcurrent < heapStart + heapSize){\n\t\t\t\tsetSize(toFree, size(toFree) + size(current))\n\t\t\t\tsetNext(prev, toFree)\n\t\t\t\tsetNext(toFree, next(current))\n\t\t\t} else {\n\t\t\t\tsetNext(toFree, current)\n\t\t\t}\n\t\t\t\n\t\t\t// Case 3, check if we can merge with previous\n\t\t\tif (prev + size(prev) == toFree && \n\t\t\t\t\tprev > heapStart){\n\t\t\t\tsetSize(prev, size(prev) + size(toFree)\n\t\t\t\t// Required for case 4 to work\n\t\t\t\tsetNext(prev, next(toFree))\n\t\t\t} else {\n\t\t\t\tsetNext(prev, toFree)\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfind(heapStart)\n}\n\\end{lstlisting}\n\nWhat is the running time of this heap data structure?\n\nAllocation: \\(O(\\vert heap \\vert)\\). Deallocation: \\(O(\\vert heap \\vert)\\).\\\\\n\nNote that we could improve the algorithm for deallocation to \\(O(1)\\) if we had access to more memory and used a doubly linked list.\n\n\\subsubsection{Fragmentation}\nE.g. Consider the following code:\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{lstlisting}\na = malloc(8)\nb = malloc(8)\nc = malloc(8)\nfree(a)\nfree(b)\n\\end{lstlisting}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{center}\n\n\\begin{minipage}[t]{0.25\\textwidth}\nHeap\n\n\\begin{tabular}{|c|}\n\\hline\na\\\\\n\\hline\nb\\\\\n\\hline\nc\\\\\n\\hline\n\\end{tabular}\n\\end{minipage}\n\\begin{minipage}[t]{0.25\\textwidth}\nHeap\n\n\\begin{tabular}{|c|}\n\\hline\n\\\\\n\\\\\n\\hline\nc\\\\\n\\hline\n\\end{tabular}\n\\end{minipage}\n\\end{center}\n\\end{minipage}\\\\\nThen a and b will be merged into one free chunk.\\\\\n\nE.g. Consider the following code:\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{lstlisting}\na = malloc(8)\nb = malloc(8)\nc = malloc(8)\nfree(a)\nfree(c)\n\\end{lstlisting}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{center}\n\n\\begin{minipage}[t]{0.25\\textwidth}\nHeap\n\n\\begin{tabular}{|c|}\n\\hline\na\\\\\n\\hline\nb\\\\\n\\hline\nc\\\\\n\\hline\n\\end{tabular}\n\\end{minipage}\n\\begin{minipage}[t]{0.25\\textwidth}\nHeap\n\n\\begin{tabular}{|c|}\n\\hline\n\\\\\n\\hline\nb\\\\\n\\hline\n\\\\\n\\hline\n\\end{tabular}\n\\end{minipage}\n\\end{center}\n\\end{minipage}\\\\\nNo chunk will be merged.\\\\\n\nNotice that the two examples result in the exact same amount of memory, 8 bytes. However, in the second example, we cannot allocate a chunk of size 8.\\\\\n\nThis problem is called fragmentation. A heap is fragmented when it is split into many small pieces. Fragmentation can cause out of memory errors even when most of the heap is free.\\\\\n\nDefragmentation (also called compacting) is the process of moving all used chunks in memory and putting them at the beginning of the heap. Compaction needs to update all pointers in the program so they point to their new locations.\\\\\n\nHow can we update all pointers in the program?\n\nFirst we need to know where the pointers actually are. The only way can know this is through a sound type system. Recall the Lacs type system is sound and there are two types, Integers and Function values, where the latter is a pointer.\\\\\n\nConvention: A chunk will look like the following:\n\\begin{center}\n\\begin{tabular}{|c|}\n\\hline\nSize\\\\\n\\hline\nNumber of pointers\\\\\n\\hline\nPointers\\\\\n..\\\\\n\\hline\nNon-pointers\\\\\n..\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nA chunk is live if it will be read later in the program. We need to move all lives chunk to the beginning of the heap. How do we determine which chunks are live? We could let the programmer tell us (like in C/C++). However, it would be nice if we could somehow predict which chunks are live, even if it is an approximation. We will apply the concept of reachable chunks to approximate live chunks.\\\\\n\nA chunk is reachable if:\n\\begin{itemize}\n\\item Its address is stored in the stack or register\n\\item Its address is stored in another reachable chunk\n\\end{itemize}\n\nIn general, if a chunk is live then it is reachable. However the converse is not always true. There could be chunks that are reachable but dead. Remember that the concept of reachable chunks is only an approximation to live chunks.\\\\\n\nLets study an algorithm that applies the concept of reachable chunks to a automatic garbage collector.\n\n\\subsubsection{Cheney's Garbage Collector}\nMain idea: split the heap into two halves called semispaces. The first half is called the from-space and the second half is called the to-space. Always allocate in the from-space. When the from-space is full, perform compaction and move all reachable chunks to the to-space. Then switch the from-space and to-space.\\\\\n\nConvention: The from-space and to-space will take 25\\% of heapSize. The from-space will start as the first half. The heapPtr register points to one word after the end of the used heap space. That is, everything about the heapPtr is used space. The variable \"semiSpaceTop\" will point to one word after the end of from-space. \\\\\n\n\\begin{center}\n\\begin{tabular}{|c|}\n\\hline\nCode\\\\\n..\\\\\n\\hline\nFrom-space\\\\\n..\\\\\n\\hline\nTo-space\\\\\n..\\\\\n\\hline\nStack\\\\\n..\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\\begin{lstlisting}\ndef init() = {\n\theapPtr = heapStart\n\tsemiSpaceTop = heapMiddle\n}\n\ndef allocate(wanted) = {\n\tif (heapPtr + wanted > semiSpaceTop){\n\t\tgc()\n\t}\n\t\n\tval ret = heapPtr\n\theapPtr = heapPtr + wanted\n\tret\n}\n\\end{lstlisting}\nNote that if semiSpaceTop is equal to heapPtr + wanted, then the from-space would be exactly full after allocating a chunk of size wanted. The next time we allocate a chunk we'll need to call the garbage collector and perform compaction.\\\\\n\nThe main algorithm is as follows:\n\\begin{enumerate}\n\\item First we need to find all the reachable chunks from the stack. To do this, we go through all chunks in the stack. If any of these chunks have pointer variables, we check to see if they point to chunks in the from-space. If they do, we check to see if the chunk has already been copied. If so, just return the new address. If not, we copy the chunk from the from-space to the to-space and return the new address of the chunk. Then we need to update the pointer so it pointers to the new location of the chunk.\n\n\\item After we are done scanning the stack, the to-space will be filled with a bunch of chunks that are reachable from the stack. Now we need to scan each of those chunks to see if any of them contain pointers to chunks in the from-space. If they do, then that chunk is also reachable since it has a pointer from a reachable chunk. We copy the chunk from the from-space to the to-space and update the pointer so it pointers to the new address.\n\n\\item After we are done scanning all the chunks in the to-space, we will have processed every reachable chunk in memory. Now we update the heapPtr = free and then switch the from-space and to-space.\n\\end{enumerate}\n\nNote that Cheney's algorithm actually uses the to-space as a queue. At first, the to-space holds all the reachable chunks from the stack. Then, as we process each of those reachable chunks, more reachable chunks get pushed onto the to-space for us to process later. We will eventually be done processing all chunks in the to-space because there are finitely many reachable chunks in memory.\\\\\n\n\\begin{lstlisting}[escapeinside={(*}{*)}]\ndef gc() = {\n\tval toSpace = if (semiSpaceTop == heapMiddle) heapMiddle else heapStart\n\tval free = toSpace\n\t\n\t// Start scanning from top of the stack excluding gc's frame\n\tvar scan = gc.dynamicLink\n\twhile (scan < memSize){\n\t\tforwardPtrs(scan)\n\t\tscan = scan + size(scan)\n\t}\n\t\n\tscan = toSpace\n\twhile (scan < free){\n\t\tforwardPtrs(scan)\n\t\tscan = scan + size(scan)\n\t}\n\t\n\tsemiSpaceTop = toSpace + semiSpaceSize\n\theapPtr = free\n}\n\ndef forwardPtrs(chunk){\n\tfor each offset o that holds a pointers {\n\t\tval newAddress = copy(deref(chunk + o))\n\t\tassignToAddress(chunk + o, newAddress)\n\t}\n}\n\ndef copy(chunk){\n\tif (chunk not in from-space){\n\t\tchunk\n\t} else {\n\t\tif (size(chunk) (*$\\geq$*) 0){\n\t\t\tcopyChunk(free, chunk)\n\t\t\tsetSize(chunk, -size(chunk))\n\t\t\tsetNext(chunk, free)\n\t\t\tfree = free + size(free)\n\t\t}\n\t\t\n\t\tnext(chunk)\n\t}\n}\n\\end{lstlisting}\n\nNote: forwardPtrs and copy should be nested procedures of gc. When implementing the algorithm on the assignments, make sure that the procedure that calls gc() has its frame on the stack (and not the heap). When a chunk is copied to the to-space, we negate its size to indicate that it has been copied. We store the address that the chunk has been copied to in the second word of the chunk.\\\\\n\n\\newpage\n\nE.g. Run Cheney's algorithm on the following code:\\\\\n\n\\begin{minipage}[t]{0.5\\textwidth}\n\\begin{lstlisting}\nforwardPtrs(120) // No Ptrs\n\\end{lstlisting}\n\\begin{lstlisting}\nforwardPtrs(132) // Ptrs: 8\n\\end{lstlisting}\n\t\\begin{itemize}\n\t\t\\item copy(deref(132 + 8)) \\(\\rightarrow\\) copy(36)\n\t\t\\begin{itemize}\n\t\t\t\\item 36 is in from-space\n\t\t\t\\item copyChunk(72, 36)\n\t\t\t\\item setSize(36, -12)\n\t\t\t\\item setNext(36, 72)\n\t\t\t\\item Return 72\n\t\t\\end{itemize}\t\t\n\t\t\\item assignToAddr(132 + 8, 72)\n\t\\end{itemize}\n\\begin{lstlisting}\nforwardPtrs(72) // Ptrs: 8\n\\end{lstlisting}\n\t\\begin{itemize}\n\t\t\\item copy(deref(72 + 8)) \\(\\rightarrow\\) copy(48)\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item 48 is in from-space\n\t\t\t\t\\item copyChunk(84, 48)\n\t\t\t\t\\item setSize(48, -12)\n\t\t\t\t\\item setNext(48, 84)\n\t\t\t\t\\item Return 84\n\t\t\t\\end{itemize}\n\t\t\\item assignToAddr(72 + 8, 84)\n\t\\end{itemize}\n\\begin{lstlisting}\nforwardPtrs(84) // Ptrs: 8\n\\end{lstlisting}\n\t\\begin{itemize}\n\t\t\\item copy(deref(84 + 8)) \\(\\rightarrow\\) copy(36)\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item 36 is in from-space\n\t\t\t\t\\item 36 has already been copied\n\t\t\t\t\\item Return 72\n\t\t\t\\end{itemize}\n\t\t\\item assignToAddr(84 + 8, 72)\t\n\t\\end{itemize}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n\t\\begin{center}\n\t\tFrom-space\\\\\n\t\t\\begin{tabular}{|c|c|}\n\t\t\t\\hline\n\t\t\t36 & size = 12 \\(\\rightarrow\\) -12\\\\\n\t\t\t\\hline\n\t\t\t40 & ptrs = 1 \\(\\rightarrow\\) 72\\\\\n\t\t\t\\hline\n\t\t\t44 & 48\\\\\n\t\t\t\\hline\n\t\t\t48 & size = 12 \\(\\rightarrow\\) -12\\\\\n\t\t\t\\hline\n\t\t\t52 & ptrs = 1 \\(\\rightarrow\\) 84\\\\\n\t\t\t\\hline\n\t\t\t56 & 36\\\\\n\t\t\t\\hline\n\t\t\t60 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t64 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t68 & \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\t\n\t\t\\vspace{7mm}\n\t\t\n\t\tTo-space\\\\\n\t\t\\begin{tabular}{|c|c|}\n\t\t\t\\hline\n\t\t\t72 & size = 12 \\\\\n\t\t\t\\hline\n\t\t\t76 & ptrs = 1 \\\\\n\t\t\t\\hline\n\t\t\t80 & 48 \\(\\rightarrow\\) 84 \\\\\n\t\t\t\\hline\n\t\t\t84 & size = 12\\\\\n\t\t\t\\hline\n\t\t\t88 & ptrs = 1 \\\\\n\t\t\t\\hline\n\t\t\t92 & 36 \\(\\rightarrow\\) 72\\\\\n\t\t\t\\hline\n\t\t\t96 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t100 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t104 & \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\t\n\t\t\\vspace{7mm}\n\t\t\n\t\tStack\\\\\n\t\t\\begin{tabular}{|c|c|}\n\t\t\t\\hline\n\t\t\t108 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t112 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t116 & \\\\\n\t\t\t\\hline\t\t\t\n\t\t\t120 & size = 12 \\\\\n\t\t\t\\hline\n\t\t\t124 & ptrs = 0 \\\\\n\t\t\t\\hline\n\t\t\t128 & 60 \\\\\n\t\t\t\\hline\n\t\t\t132 & size = 12 \\\\\n\t\t\t\\hline\n\t\t\t136 & ptrs = 1 \\\\\n\t\t\t\\hline\n\t\t\t140 & 36 \\(\\rightarrow\\) 72 \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\t\t\t\t\n\t\\end{center}\n\\end{minipage}\n\nWhat is the running time of Cheney's garbage collector?\n\nAllocation: Best case: \\(\\Omega(1)\\). Worst case: \\(O(\\vert \\text{reachable chunks} \\vert)\\).\\\\\n\nThe major disadvantage of the algorithm is that it wastes 25\\% of memory. Real life compilers use generational garbage collection. Generational garbage collection observes that most memory either dies young or lives long. Instead of having only 2 semispaces there are multiple semispaces. There are small-sized semispaces for short lived memory where the garbage collector runs frequently. There are large-sized semispaces for long lived memory where the garbage collector runs infrequently.\\\\\n\nHow do they determine short lived memory and long lived memory?\n\nThey approximate. All chunks that still exist after 100 garbage collector runs is probably long lived memory. This can get very complex because all these different semispaces can have pointers between each other and we need another data structure to keep track of that.\n\n\\newpage\n\n\\section{Lambda Calculus}\nLambda calculus is a theoretical mathematical model of programs. All calculations are done through a context free grammar:\\\\\n\ne \\(\\rightarrow\\) v (i.e. An expression is a variable)\\\\\ne \\(\\rightarrow\\) e e (i.e. An expression is a function call. The left e evaluates to a function/closure and the right e are the arguments) \\\\\ne \\(\\rightarrow\\) \\(\\lambda\\) v. e (An expression is a function declaration. The function has parameter v and function body e)\\\\\n\nJust like there is a step function for MIPs assembly, there is a step function for lambda calculus called \\(\\beta\\)-reduction:\\\\\n\n(\\(\\lambda\\) v. \\(e_1\\)) \\(e_2\\) \\(\\rightarrow\\) \\(e_1\\)[\\(e_2\\)/v] (i.e. Evaluates to \\(e_1\\) with \\(e_2\\) replacing v in the function body)\\\\\n\nE.g. (\\(\\lambda\\) v. v v)(a b c) \\(\\rightarrow\\) (a b c)(a b c)\\\\\n\nE.g. (\\(\\lambda\\) v. v v)(\\(\\lambda\\) x. x x) \\(\\rightarrow\\) (\\(\\lambda\\) x. x x)(\\(\\lambda\\) x. x x) \\(\\rightarrow\\) (\\(\\lambda\\) x. x x)(\\(\\lambda\\) x. x x) \\(\\rightarrow\\) (\\(\\lambda\\) x. x x)(\\(\\lambda\\) x. x x)... There can be infinite loops in lambda calculus.\\\\\n\nE.g. \\(\\lambda\\) y. ((\\(\\lambda\\) x. (\\(\\lambda\\) y. x)  y) y)\\\\\n\nNotice that inside the main function body, y evaluates to the global y. But inside the middle function body, y evaluates to a local y. However, we cannot distinguish between the two y. This will cause a name clash so lets rename the inner y to y'.\\\\\n\n=  \\(\\lambda\\) y. ((\\(\\lambda\\) x. (\\(\\lambda\\) y'. x)  y) y) \\(\\rightarrow\\) \n\\(\\lambda\\) y. ((\\(\\lambda\\) y'. y) y)\n\\end{document}", "meta": {"hexsha": "dbd422f91eed5b455eb238b73dc4c7f1b7af42cf", "size": 112882, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cs241e/cs241e.tex", "max_stars_repo_name": "Mo-Talha/Notes", "max_stars_repo_head_hexsha": "31f0554a31920f953bb542e077d76a82dbc6e6bf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-22T14:48:09.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-22T14:48:09.000Z", "max_issues_repo_path": "cs241e/cs241e.tex", "max_issues_repo_name": "Mo-Talha/Notes", "max_issues_repo_head_hexsha": "31f0554a31920f953bb542e077d76a82dbc6e6bf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cs241e/cs241e.tex", "max_forks_repo_name": "Mo-Talha/Notes", "max_forks_repo_head_hexsha": "31f0554a31920f953bb542e077d76a82dbc6e6bf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7527131783, "max_line_length": 630, "alphanum_fraction": 0.6974185433, "num_tokens": 33184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301064, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.43636886303138556}}
{"text": "\\documentclass[10pt,reqno]{amsart}\n\n\\usepackage{accents}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{fullpage}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{multicol}\n\\usepackage{siunitx}\n\\usepackage{verbatim}\n\n\\mathtoolsset{showonlyrefs,showmanualtags}\n\\allowdisplaybreaks[1] % Allow grouped equations to be split across pages\n\n\\newcommand{\\tensor}[1]{\\accentset{\\leftrightarrow}{#1}}\n\\newcommand{\\Mach}[1][]{\\ensuremath{\\mbox{Ma}_{#1}}}\n\\newcommand{\\Reynolds}[1][]{\\ensuremath{\\mbox{Re}_{#1}}}\n\\newcommand{\\Prandtl}[1][]{\\ensuremath{\\mbox{Pr}_{#1}}}\n\n\\lstset{ %\nbasicstyle=\\scriptsize,         % the size of the fonts that are used for the code\nnumbers=left,                   % where to put the line-numbers\nnumberstyle=\\tiny,              % the size of the fonts that are used for the line-numbers\nstepnumber=5,                   % the step between two line-numbers. If it's 1, each line\n                                % will be numbered\nnumbersep=5pt,                  % how far the line-numbers are from the code\nframe=single,                   % adds a frame around the code\nshowstringspaces=false          % underline spaces within strings\n}\n\n\\begin{document}\n\n\\title{\n    A transient manufactured solution for the nondimensional, compressible\n    Navier--Stokes equations with a power law viscosity\n}\n\\author{Rhys Ulerich}\n\n\\begin{abstract}\nA time-varying manufactured solution is presented for the nondimensional,\ncompressible Navier--Stokes equations under the assumption of a constant\nPrandtl number, Newtonian perfect gas obeying a power law viscosity.  The\nchosen nondimensionalization employs a reference density, length, velocity, and\ntemperature.  The solution form includes waveforms with adjustable phase\noffsets and mixed partial derivatives to bolster code coverage.  Temperature,\nrather than pressure, is selected to have a simple analytic form to aid\nverifying codes having temperature-based boundary conditions.  Suggested\nverification tests for isothermal channel and flat plate codes are provided.  A\nC++ implementation of the manufactured solution and the forcing it requires is\nprovided.  Tests are included to ensure the implementation matches the solution\nform to within acceptable floating point loss.\n\\end{abstract}\n\n\\maketitle\n\n\\section{Mathematical model}\n\\label{sec:model}\n\nUnder common assumptions the nondimensional Navier--Stokes equations\nmay take the form\n\\begin{subequations}\n\\label{eq:model}\n\\begin{align}\n  \\frac{\\partial}{\\partial{}t}\\rho\n&=\n  - \\nabla\\cdot\\rho{}\\vec{u}\n  + Q_{\\rho}\n  \\\\\n  \\frac{\\partial{}}{\\partial{}t}\\rho{}\\vec{u}\n&=\n  - \\nabla\\cdot(\\vec{u}\\otimes{}\\rho{}\\vec{u})\n  - \\frac{1}{\\Mach^{2}} \\nabla{} p\n  + \\frac{1}{\\Reynolds} \\nabla\\cdot{} \\tensor{\\tau}\n  + \\vec{Q}_{\\rho{}u}\n  \\\\\n  \\frac{\\partial}{\\partial{}t} \\rho{}e\n&=\n  - \\nabla\\cdot{}\\rho{}e\\vec{u}\n  - \\nabla\\cdot{} p \\vec{u}\n  - \\nabla\\cdot{} \\vec{q}\n  + \\frac{\\Mach^2}{\\Reynolds} \\nabla\\cdot{}\\tensor{\\tau} \\vec{u}\n  + Q_{\\rho{}e}\n\\end{align}\naided by the auxiliary relations\n\\begin{align}\n  p &=   \\left(\\gamma-1\\right)\\left(\\rho{}e\n          - \\Mach^{2} \\rho\\frac{\\vec{u}\\cdot{}\\vec{u}}{2} \\right)\n  &\n  T &= \\gamma\\frac{p}{\\rho}\n  \\\\\n  \\mu &= T^{\\beta}\n  &\n  \\lambda &= \\left(\\alpha-\\frac{2}{3}\\right) \\mu\n  \\\\\n  \\tensor{\\tau}\n       &=   \\mu \\left( \\nabla{}\\vec{u} + {\\nabla{}\\vec{u}}^{\\mathsf{T}} \\right)\n          + \\lambda \\left( \\nabla\\cdot{}\\vec{u} \\right) I\n  &\n  \\vec{q} &= - \\frac{1}{\\Reynolds\\Prandtl\\left(\\gamma-1\\right)} \\mu \\nabla{} T\n\\end{align}\nwhere the nondimensional quantities\n\\begin{align}\n  \\Reynolds &= \\frac{\\rho_{0}u_{0}l_{0}}{\\mu_{0}}\n  &\n  \\Mach &= \\frac{u_{0}}{a_{0}}\n  &\n  \\Prandtl &= \\frac{\\mu_{0}C_{p}}{\\kappa_{0}}\n  &\n  \\gamma &= \\frac{C_{p}}{C_{v}}\n\\end{align}\nare the constant Reynolds number, Mach number, and Prandtl number, and ratio\nof specific heats, respectively.\n\\end{subequations}\nThe fluid's nondimensional dynamic viscosity follows a power law in temperature\nwith exponent $\\beta$.  The fluid's bulk viscosity is a constant multiple\n$\\alpha$ of the dynamic viscosity.  Setting $\\alpha = 0$ is equivalent to\nStokes' hypothesis that the bulk viscosity is zero.  Here $e$ denotes the\nspecific total energy and that later we will refer to the components of\n$\\vec{u}$ as the scalars $u$, $v$, and $w$.  The arbitrary forcing terms\n$Q_{\\rho}$, $\\vec{Q}_{\\rho{}u}$, and $Q_{\\rho{}e}$ will be used to obtain the\ndesired manufactured solution.\n\n\n\\section{Manufactured solution}\n\\label{sec:solution}\n\nFor all $\\phi\\in\\left\\{\\rho, u, v, w, T\\right\\}$ we select analytical solutions\nof the form\n\\begin{alignat}{20}\n\\label{eq:solution}\n  \\phi\\!\\left(x, y, z, t\\right)\n  &= &&a_{\\phi{}0}  &&          &&             &&               &&  &&            &&       &&          &&             &&                &&  &&            &&        &&\\cos\\Bigl(&&f_{\\phi{}0 } &&t &&+ &&g_{\\phi{}0 }&&\\Bigr)       \\\\\n  &+ &&a_{\\phi{}x } &&\\cos\\Bigl(&&b_{\\phi{}x } &&2\\pi x L_x^{-1}&&+ &&c_{\\phi{}x }&&\\Bigr) &&          &&             &&                &&  &&            &&        &&\\cos\\Bigl(&&f_{\\phi{}x } &&t &&+ &&g_{\\phi{}x }&&\\Bigr) \\notag\\\\\n  &+ &&a_{\\phi{}xy} &&\\cos\\Bigl(&&b_{\\phi{}xy} &&2\\pi x L_x^{-1}&&+ &&c_{\\phi{}xy}&&\\Bigr) &&\\cos\\Bigl(&&d_{\\phi{}xy} &&2\\pi y L_y^{-1} &&+ &&e_{\\phi{}xy}&&\\Bigr)  &&\\cos\\Bigl(&&f_{\\phi{}xy} &&t &&+ &&g_{\\phi{}xy}&&\\Bigr) \\notag\\\\\n  &+ &&a_{\\phi{}xz} &&\\cos\\Bigl(&&b_{\\phi{}xz} &&2\\pi x L_x^{-1}&&+ &&c_{\\phi{}xz}&&\\Bigr) &&\\cos\\Bigl(&&d_{\\phi{}xz} &&2\\pi z L_z^{-1} &&+ &&e_{\\phi{}xz}&&\\Bigr)  &&\\cos\\Bigl(&&f_{\\phi{}xz} &&t &&+ &&g_{\\phi{}xz}&&\\Bigr) \\notag\\\\\n  &+ &&a_{\\phi{}y } &&\\cos\\Bigl(&&b_{\\phi{}y } &&2\\pi y L_y^{-1}&&+ &&c_{\\phi{}y }&&\\Bigr) &&          &&             &&                &&  &&            &&        &&\\cos\\Bigl(&&f_{\\phi{}y } &&t &&+ &&g_{\\phi{}y }&&\\Bigr) \\notag\\\\\n  &+ &&a_{\\phi{}yz} &&\\cos\\Bigl(&&b_{\\phi{}yz} &&2\\pi y L_y^{-1}&&+ &&c_{\\phi{}yz}&&\\Bigr) &&\\cos\\Bigl(&&d_{\\phi{}yz} &&2\\pi z L_z^{-1} &&+ &&e_{\\phi{}yz}&&\\Bigr)  &&\\cos\\Bigl(&&f_{\\phi{}yz} &&t &&+ &&g_{\\phi{}yz}&&\\Bigr) \\notag\\\\\n  &+ &&a_{\\phi{}z } &&\\cos\\Bigl(&&b_{\\phi{}z } &&2\\pi z L_z^{-1}&&+ &&c_{\\phi{}z }&&\\Bigr) &&          &&             &&                &&  &&            &&        &&\\cos\\Bigl(&&f_{\\phi{}z } &&t &&+ &&g_{\\phi{}z }&&\\Bigr) \\notag\n\\end{alignat}\nwhere $a$, $b$, $c$, $d$, $e$, $f$, and $g$ are constant coefficient\ncollections indexed by $\\phi$ and one or more directions.  To aid in providing\nreusable, physically realizable coefficients for Cartesian domains of arbitrary\nsize, domain extents $L_x$, $L_y$, $L_z$ have been introduced.  Partial\nderivatives $\\phi_{t }$, $\\phi_{x }$, $\\phi_{y }$, $\\phi_{z }$, $\\phi_{xx}$,\n$\\phi_{xy}$, $\\phi_{xz}$, $\\phi_{yy}$, $\\phi_{yz}$, and $\\phi_{zz}$ may be\ncomputed directly from the chosen solutions.\n\nThough they increase the solution's complexity significantly, mixed partial\nspatial derivatives are included to improve code coverage.  Each term has an\nadjustable amplitude, frequency, and phase for all spatial dimensions.  Cosines\nwere chosen so all terms can be ``turned off'' by employing zero coefficients.\nIt is suggested that users gradually ``turn on'' the more complicated features\nof the solution (i.e. use non-zero coefficients) after ensuring simpler usage\nhas been successful.\n\nThe Python-based computer algebra system SymPy (\\url{http://sympy.org})\ncan both compute the derivatives and output C code for computing these\nvalues at some $x$, $y$, $z$, and $t$:\n\\lstinputlisting[language=Python]{soln.py}\n\n\\section{Forcing terms}\n\\label{sec:forcing}\n\nThe solutions given in \\textsection~\\ref{sec:solution} may be plugged into the\nmodel from \\textsection~\\ref{sec:model} and solved for the forcing terms\n$Q_{\\rho}$, $\\vec{Q}_{\\rho{}u}$, and $Q_{\\rho{}e}$.  However, solving for these\ncomplete terms entirely within the context of a computer algebra system causes\nan unwieldy explosion of terms.  As the fully expanded forcing terms are too\nlarge to be usable in any meaningful way, they are not shown.\n\nInstead, starting from the solution and its the analytic derivatives, we use\nbasic calculus followed by algebraic operations performed in floating point to\nobtain the necessary forcing \\emph{at runtime}.  The errors arising in this\nprocess behave like standard floating point truncation issues.  Many of the\ncomputations are independent of the constitutive relations used and could be\nemployed for other manufactured solutions.\n\nComputing the forcing terms looks as follows:\n\\lstinputlisting[language=python]{forcing.py}\n\n\\section{Suggested coefficients for isothermal channels and flat plates}\n\\label{sec:suggest}\n\nEmploying the manufactured solution requires fixing the more than two hundred\ncoefficients appearing in equations \\eqref{eq:model} and \\eqref{eq:solution}.\nSelecting usable values is not difficult but it can be time consuming.  We\ntherefore present reasonable coefficient choices for testing channel and flat\nplate codes.\n\nIn both geometries the streamwise, wall-normal, and spanwise directions are\nlabeled $x$, $y$, and $z$ respectively.  Both $x$ and $z$ are periodic while\n$y\\in\\left\\{0,L_y\\right\\}$ is not.  Transient tests should likely take place\nwithin the duration $0\\leq{}t\\leq{}1/10$ nondimensional time units as the time\nphase offsets (e.g. $g_{Tyz}$) have been chosen for appreciable transients to\noccur throughout this time window.\n\nFor isothermal channel flow code verification we recommend testing using\n\\begin{equation*}\n  b_{\\rho{}y} =\n  b_{u{}y}    =\n  b_{v{}y}    =\n  b_{w{}y}    =\n  b_{T{}y}    = \\frac{1}{2}\n\\end{equation*}\nand the coefficients given in Table~\\ref{tbl:auxcoeff}.  With these choices\nthe manufactured solution satisfies isothermal, no-slip conditions at $y = 0,\nL_y$.  For isothermal flat plate code verification we recommend testing using\n\\begin{equation*}\n  b_{\\rho{}y} =\n  b_{u{}y}    =\n  b_{v{}y}    =\n  b_{w{}y}    =\n  b_{T{}y}    = \\frac{1}{4}\n\\end{equation*}\nand the coefficients given in Table~\\ref{tbl:auxcoeff}.  With these choices\nthe manufactured solution satisfies an isothermal, no-slip condition at $y =\n0$.\n\n\\section{Reference Implementation}\n\nA templated, precision-agnostic C++ implementation for evaluating the\nmanufactured solution and its associated forcing is included.  Also included is\na high precision test case which ensures the implementation computes exactly\nwhat is described in this documentation.  The test can do so because it\nexecutes the same Python source files used to generate this document.\n\nOne can ensure the implementation files match this documentation by comparing\nagainst the following MD5 checksums:\n\n\\verbatiminput{CHECKSUMS}\n\nMore details on the implementation and tests can be found in the solution's\nREADME:\n\n\\verbatiminput{README}\n\n\\begin{table}[p]\n\\allowdisplaybreaks\n\\begin{multicols}{3}\n\\begin{small}\n\\begin{align*}\n\\alpha    &= 0          \\\\\n\\beta     &= 2/3        \\\\\n\\gamma    &= \\num{1.4}  \\\\\n\\Mach     &= \\num{1.15} \\\\\n\\Prandtl  &= \\num{0.7}  \\\\\n\\Reynolds &= 100 \\\\\nL_x       &= 4 \\pi \\\\\nL_y       &= 2 \\\\\nL_z       &= 4 \\pi / 3 \\\\\n\\intertext{}\na_{\\rho{}0}  &= 1 \\\\\na_{\\rho{}xy} &= 1 / 11 \\\\\nb_{\\rho{}xy} &= 3 \\\\\nd_{\\rho{}xy} &= 3 \\\\\nf_{\\rho{}xy} &= 3 \\\\\ng_{\\rho{}xy} &= \\pi / 4 \\\\\na_{\\rho{}y} &= 1 / 7 \\\\\nb_{\\rho{}y} &= \\text{\\emph{see \\textsection{}~\\ref{sec:suggest}}} \\\\\nf_{\\rho{}y} &= 1 \\\\\ng_{\\rho{}y} &= \\pi / 4 - 1 / 20 \\\\\na_{\\rho{}yz} &= 1 / 31 \\\\\nb_{\\rho{}yz} &= 2 \\\\\nd_{\\rho{}yz} &= 2 \\\\\nf_{\\rho{}yz} &= 2 \\\\\ng_{\\rho{}yz} &= \\pi / 4 + 1 / 20 \\\\\n\\intertext{}\na_{uxy} &= 37 / 251 \\\\\nb_{uxy} &= 3 \\\\\nc_{uxy} &= - \\pi / 2 \\\\\nd_{uxy} &= 3 \\\\\ne_{uxy} &= - \\pi / 2 \\\\\nf_{uxy} &= 3 \\\\\ng_{uxy} &= \\pi / 4 \\\\\na_{uy} &= 1 \\\\\nb_{uy} &= \\text{\\emph{see \\textsection{}~\\ref{sec:suggest}}} \\\\\nc_{uy} &= -\\pi / 2 \\\\\nf_{uy} &= 1 \\\\\ng_{uy} &= \\pi / 4 - 1 / 20 \\\\\na_{uyz} &= 41 / 257 \\\\\nb_{uyz} &= 2 \\\\\nc_{uyz} &= - \\pi / 2 \\\\\nd_{uyz} &= 2 \\\\\ne_{uyz} &= - \\pi / 2 \\\\\nf_{uyz} &= 2 \\\\\ng_{uyz} &= \\pi / 4 + 1 / 20 \\\\\n\\intertext{}\na_{vxy} &= 3 / 337 \\\\\nb_{vxy} &= 3 \\\\\nc_{vxy} & = - \\pi / 2 \\\\\nd_{vxy} & = 3         \\\\\ne_{vxy} & = - \\pi / 2 \\\\\nf_{vxy} &= 3 \\\\\ng_{vxy} &= \\pi / 4 \\\\\na_{vy} &= 2 / 127 \\\\\nb_{vy} &= \\text{\\emph{see \\textsection{}~\\ref{sec:suggest}}} \\\\\nc_{vy} &= - \\pi / 2 \\\\\nf_{vy} &= 1 \\\\\ng_{vy} &= \\pi / 4 - 1 / 20 \\\\\na_{vyz} &= 5 / 347 \\\\\nb_{vyz} &= 2 \\\\\nc_{vyz} &= -\\pi / 2 \\\\\nd_{vyz} &= 2 \\\\\ne_{vyz} &= -\\pi / 2 \\\\\nf_{vyz} &= 2 \\\\\ng_{vyz} &= \\pi / 4 + 1 / 20 \\\\\n\\intertext{}\na_{wxy} &= 11 / 409 \\\\\nb_{wxy} &= 3 \\\\\nc_{wxy} &= -\\pi / 2 \\\\\nd_{wxy} &= 3 \\\\\ne_{wxy} &= -\\pi / 2 \\\\\nf_{wxy} &= 3 \\\\\ng_{wxy} &= \\pi / 4 \\\\\na_{wy} &= 7 / 373 \\\\\nb_{wy} &= \\text{\\emph{see \\textsection{}~\\ref{sec:suggest}}} \\\\\nc_{wy} &= - \\pi / 2 \\\\\nf_{wy} &= 1 \\\\\ng_{wy} &= \\pi / 4 - 1 / 20 \\\\\na_{wyz} &= 13 / 389 \\\\\nb_{wyz} &= 2 \\\\\nc_{wyz} &= - \\pi / 2 \\\\\nd_{wyz} &= 2 \\\\\ne_{wyz} &= - \\pi / 2 \\\\\nf_{wyz} &= 2 \\\\\ng_{wyz} &= \\pi / 4 + 1 / 20 \\\\\n\\intertext{}\na_{T0} &= 1 \\\\\na_{Txy} &= 1 / 17 \\\\\nb_{Txy} &= 3 \\\\\nc_{Txy} &= - \\pi / 2 \\\\\nd_{Txy} &= 3 \\\\\ne_{Txy} &= - \\pi / 2 \\\\\nf_{Txy} &= 3 \\\\\ng_{Txy} &= \\pi / 4 \\\\\na_{Ty} &= 1 / 13 \\\\\nb_{Ty} &= \\text{\\emph{see \\textsection{}~\\ref{sec:suggest}}} \\\\\nc_{Ty} &= - \\pi / 2 \\\\\nf_{Ty} &= 1 \\\\\ng_{Ty} &= \\pi / 4 - 1 / 20 \\\\\na_{Tyz} &= 1 / 37 \\\\\nb_{Tyz} &= 2 \\\\\nc_{Tyz} &= - \\pi / 2 \\\\\nd_{Tyz} &= 2 \\\\\ne_{Tyz} &= - \\pi / 2 \\\\\nf_{Tyz} &= 2 \\\\\ng_{Tyz} &= \\pi / 4 + 1 / 20 \\\\\n\\end{align*}\n\\end{small}\n\\end{multicols}\n\\caption{Coefficient recommendations from section~\\ref{sec:suggest}.\n         Unlisted coefficients should be set to zero.\n         \\label{tbl:auxcoeff}}\n\\end{table}\n\n\\end{document}\n", "meta": {"hexsha": "bc5cf91691cab8bc4bcff6d822ffecb2fac3bddb", "size": 13553, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "disputatio/dissertation/mms/writeup.tex", "max_stars_repo_name": "nicholasmalaya/paleologos", "max_stars_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-04T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T17:49:42.000Z", "max_issues_repo_path": "disputatio/dissertation/mms/writeup.tex", "max_issues_repo_name": "nicholasmalaya/paleologos", "max_issues_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "disputatio/dissertation/mms/writeup.tex", "max_forks_repo_name": "nicholasmalaya/paleologos", "max_forks_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-01-04T16:08:18.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-16T19:34:24.000Z", "avg_line_length": 37.6472222222, "max_line_length": 230, "alphanum_fraction": 0.6169851693, "num_tokens": 4704, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4363688550556188}}
{"text": "\\graphicspath{{Pics/combi/config/}}\n\n\n\\newpage\\section{Exploring Configurations}\n\nProblems where there is some kind of a configuration is given, the question\nusually asks to proof or find some specific properties of the configuration.\n\n\n\\subsection{Problems}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1634977p10278658}{ARO 2018\n    P11.5}{E}{\n    On the table, there're $ 1000 $ cards arranged on a circle. On each\n    card, a positive integer was written so that all $ 1000 $ numbers are\n    distinct. \n\n    First, Vasya selects one of the card, remove it from the circle, and\n    do the following operation: If on the last card taken out was written positive\n    integer $ k $, count the $ k^{th} $ clockwise card not removed, from that\n    position, then remove it and repeat the operation. This continues until only\n    one card left on the table. \n\n    Is it possible that, initially, there's a card $A$ such that, no matter\n    what other card Vasya selects as first card, the one that left is always\n    card $A$?\n}\\label{problem:constructive_algo_7}\n\n\\solu{\n    Consider the numbering, \\[1, 1001!+1, 1002!+1, \\dots 1998!+1,\n    1999!+2\\]It's easy to check that it works.\n}\n\n\\rem{\n    We want to find a configuration, where one card, let's call it $ a $,\n    gets skipped over all the time. Now, controlling the skipping for every move\n    is kinda hard. Instead of doing that, we want to control only one move that\n    skips $ a $, and all other moves will go to the next card in the clockwise\n    rotation. And the card before $ a $ will skip over $ a $, and land of the next\n    card. That being said, the construction is rather trivial.\n}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1446905p8271388}\n{APMO 2017 P1}{M}{\n    We call a $5$-tuple of integers arrangeable if its elements can be\n    labeled $a,b,c,d,e$ in some order so that $a-b+c-d+e=29$. Determine all $ 2017$\n    -tuples of integers $n_1, n_2, n_3\\dots n_{2017}$ such that if we place\n    them in a circle in clockwise order, then any $5$-tuple of numbers in\n    consecutive positions on the circle is arrangeable.\n}\\label{problem:minus_constant_1}\\label{problem:invariant_rules_of_thumb_5}\n\n\\solu{\n    The annoying part is the $a-b+c-d+e = 29$ condition, as $29$ is too random.\n    Can we do something to make this sum equal to a nicer interger, possibly\n    $0$?\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h41116p258304}\n{ISL 2004 C1}{E}{\n    There are $10001$ students at an university. Some students join\n    together to form several clubs (a student may belong to different clubs).\n    Some clubs join together to form several societies (a club may belong to\n    different societies). There are a total of $k$ societies. Find all\n    possible values of $k$ so that the following conditions are satisfied:\n    \\begin{enumerate}\n        \\item  Each pair of students are in exactly one club.\n        \\item  For each student and each society, the student is in exactly\n            one club of the society.\n        \\item  Each club has an odd number of students. In addition, a club\n            with ${2m+1}$ students ($m$ is a positive integer) is in exactly $m$\n            societies.  \n    \\end{enumerate}\n}\\label{problem:double_counting_7}\n\n\\solu{Just Double-Counting.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h17336p118710}{ISL 2002\nC1}{E}{Let $ n $ be a positive integer. Each point $ (x,y) $ in the plane,\nwhere $ x $ and $ y $ are non-negative integers with $ x+y<n $ , is coloured\nred or blue, subject to the following condition: if a point $ (x,y) $ is red,\nthen so are all points $ (x',y') $ with $ x'\\leq x $ and $ y'\\leq y $. Let $ A\n$ be the number of ways to choose $ n $ blue points with distinct $ x $\n-coordinates, and let $ B $ be the number of ways to choose $ n $ blue points\nwith distinct $ y $ -coordinates. Prove that $ A=B\n$.}\\label{problem:induction_type1_5}\\label{problem:recursive_solution_2}\\label{problem:bijection_1}\n\n\n\\prob{https://artofproblemsolving.com/community/c5h476723p2669115}{USAMO 2012\nP2}{M}{A circle is divided into $ 432 $ congruent arcs by $ 432 $ points. The\npoints are colored in four colors such that some $ 108 $ points are colored\nRed, some $ 108 $ points are colored Green, some $ 108 $ points are colored\nBlue, and the remaining $ 108 $ points are colored Yellow. Prove that one can\nchoose three points of each color in such a way that the four triangles formed\nby the chosen points of the same color are\ncongruent.}\\label{problem:double_counting_6}\n\n\\solu{Double counting saves the day :) The trick is to rotate ;)}\n\n\n\n\\prob{http://emc.mnm.hr/wp-content/uploads/2018/12/EMC_2018_Seniors_ENG_Solutions-2.pdf}{European\nMathematics Cup 2018 P1}{E}{Call a partition of $ n $ a set $ a_1, \\dots a_k $\nwith $ a_1 \\le a_2\\dots \\le a_k $ and $ a_1 + a_2 \\dots + a_k =  $. A\npartition of a positive integer is `even' if all of its elements are even\nnumbers. Similarly, a partition is `odd' if all of its elements are odd.\nDetermine all positive integers $ n $ such that the number of even partitions\nof $ n $ is equal to the number of odd partitions of $ n $.}\n\n\\solu{Bijection.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1268873p6622370}{ISL 2015 C1}{E}{In Lineland there are $n\\geq1$ towns, arranged along a road running from left to right. Each town has a left bulldozer (put to the left of the town and facing left) and a right bulldozer (put to the right of the town and facing right). The sizes of the $2n$ bulldozers are distinct. Every time when a left and right bulldozer confront each other, the larger bulldozer pushes the smaller one off the road. On the other hand, bulldozers are quite unprotected at their rears; so, if a bulldozer reaches the rear-end of another one, the first one pushes the second one off the road, regardless of their sizes.\n\n    Let $A$ and $B$ be two towns, with $B$ to the right of $A$. We say that town $A$ can sweep town $B$ away if the right bulldozer of $A$ can move over to $B$ pushing off all bulldozers it meets. Similarly town $B$ can sweep town $A$ away if the left bulldozer of $B$ can move over to $A$ pushing off all bulldozers of all towns on its way.\n\nProve that there is exactly one town that cannot be swept away by any other one.}\n\n\\solu{Focus on the heaviest bulldozer.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h195492p1073989}{APMO 2008\nP2}{EM}{Students in a class form groups each of which contains exactly three\nmembers such that any two distinct groups have at most one member in common.\nProve that, when the class size is $ 46 $ , there is a set of $ 10 $ students\nin which no group is properly\ncontained.}\\label{problem:bijection_8}\\label{problem:extremal_case_whole_5}\n\n\\solu{Taking the maximum set that follows the ``in which no group is properly\ncontained'' rule. Now the elements that are \\emph{not} in this set, we can\nconnect this element to only one of the pairs from the set. Now defining a\nbijection, and counting the elements, we are done.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h364231p2000940}{IMO SL\n1985}{M}{A set of $ 1985 $ points is distributed around the circumference of a\ncircle and each of the points is marked with $ 1 $ or $ -1 $. A point is\ncalled ``good'' if the partial sums that can be formed by starting at that\npoint and proceeding around the circle for any distance in either direction\nare all strictly positive. Show that if the number of points marked with $ -1\n$ is less than $ 662 $ , there must be at least one good\npoint.}\\label{problem:induction_type1_12}\n\n\\solu{First thing to notice, the number $ 3*661 + 2 = 1985 $. And these\nnumbers are completely random. So what if we try to replace $ 1985 $ by $ n $\n? Will the condition still hold?}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h418978p2365036}{IMO 2011\nP4}{E}{Let $ n > 0 $ be an integer. We are given a balance and $ n $ weights\nof weight $ 2^0, 2^1, \\cdots, 2^{n-1} $. We are to place each of the $ n $\nweights on the balance, one after another, in such a way that the right pan is\nnever heavier than the left pan. At each step we choose one of the weights\nthat has not yet been placed on the balance, and place it on either the left\npan or the right pan, until all of the weights have been placed. Determine the\nnumber of ways in which this can be done.}\\label{problem:recursive_solution_5}\n\n\\solu{Writing the whole process as a sum, we see that only $ 2^0 $ is the odd\nterm here, if we remove that we can divide by $ 2 $ to get a recursive\nformula.}\n\n\\solu{Calculating wrt to the last placed weight.}\n\n\\solu{Getting recursive formula considering the position of $ 2^{n-1} $.}\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c5h202936p1116367}{USAMO 2008\nP3}{H}{Let $ n $ be a positive integer. Denote by $ S_n $ the set of points $\n(x, y) $ with integer coordinates such that \\[ \\left\\lvert x\\right\\rvert +\n\\left\\lvert y + \\frac{1}{2} \\right\\rvert < n. \\] A path is a sequence of\ndistinct points $ (x_1 , y_1), (x_2, y_2), \\ldots, (x_\\ell, y_\\ell) $ in $ S_n\n$ such that, for $ i = 2, \\ldots, \\ell $ , the distance between $ (x_i , y_i)\n$ and $ (x_{i-1} , y_{i-1} ) $ is $ 1 $ (in other words, the points $ (x_i,\ny_i) $ and $ (x_{i-1} , y_{i-1} ) $ are neighbors in the lattice of points\nwith integer coordinates). Prove that the points in $ S_n $ cannot be\npartitioned into fewer than $ n $ paths (a partition of $ S_n $ into $ m $\npaths is a set $ \\mathcal{P} $ of $ m $ nonempty paths such that each point in\n$ S_n $ appears in exactly one of the $ m $ paths in $ \\mathcal{P} $\n).}\\label{problem:alternating_chains_2}\\label{problem:coloring_2}\n\n\n\\solu{Graph + Partition, coloring is just natural. Again, the edges join two\nneighbor lattice points, so checkerboard coloring. But checkerboard doesn't do\nmuch good. So the next thing we try is to apply some derivations of it,\npseudo!!! Well, overkill.}\n\n\n\\solu{For all n, induction is very natural. The optimal partition (the most\nbeautiful one) and the longest path in it, say $ P $ , gives us a way to\nperform induction. As always, we suppose a partition with $ n-1 $ paths. As\nthere are a lot of partitions, we need to choose a certain partition, say $\n\\mathbb{M} $. Again as our goal is to include $ P $ in $ \\mathbb{M} $. So\nsuppose that the set with all the points in $ P $ is $ A $. And further more,\nsuppose that in $ \\mathbb{M} $ there is a path $ Q $ with $ \\vert Q\\cap A\\vert\n$ being maximal among all other partitions of the points. Some some easy case\nwork shows that we must have $ P\\in \\mathbb{M} $.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c5h532235p3041823}{USAMO 2013\nP2}{H}{For a positive integer $ n\\geq 3 $ plot $ n $ equally spaced points\naround a circle. Label one of them $ A $ , and place a marker at $ A $. One\nmay move the marker forward in a clockwise direction to either the next point\nor the point after that. Hence there are a total of $ 2n $ distinct moves\navailable; two from each point. Let $ a_n $ count the number of ways to\nadvance around the circle exactly twice, beginning and ending at $ A $ ,\nwithout repeating a move. Prove that $ a_{n-1}+a_n=2^n $ for all $ n\\geq 4\n$.}\\label{problem:recursive_solution_4}\\label{problem:bijection_7}\n\n\n\\solu{Problems where there are multiple possible value of a function\nregardless of the current position, one of dealing with these is to assigning\nlabels of these possible values to each points of the function, and this will\ngive a combinatorial model and a way to deal it with bijection.}\n\n\\solu{First investigate the problem condition, $ a_n + a_{n-1} = 2^n $ , now,\n$ 2^n $ means the number of differently coloring every point black or white,\nand the left side is the number of such paths for $ n $ and $ n-1 $. Which\nmeans we should try to color the points and see what happens.}\n\n\\proof{EChen's solution: In this problem, the main obstacle seems to be the\ncircle condition. And on top of that, on can land on the starting point. So\nthings are pretty messed up here. What we want to do is to make things a\nlittle bit more easy to deal with. So our best option is to change the problem\nso that we get the similar problem with a different explanation. So we change\nthe condition circle with matrix, $ 2 $ round with $ 2 $ rows. $ n $ points\nwith $ n $ entries in each rows. What we get now is the same problem, just a\nbit easier to deal with. We call this \\hl{Tweak The Problem} strategy.}\n\n\n\n\\prob{}{}{E}{ $ 10 $ persons went to a bookstore. It is known that: Every\nperson has bought 3 kinds on books and for every 2 persons, there is at least\none kind of books which they both have bought. Let $ m_i $ be the number of\nthe persons who bought the $ i^{th} $ kind of books and $ M= \\max\\lbrace\nm_i\\rbrace $ Find the smallest possible value of $ M\n$.}\\label{problem:double_counting_4}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h86560p504805}{ARO 2006\n    11.3}{M}{On a $49\\times 69$ rectangle formed by a grid of lattice squares,\n    all $50\\cdot 70$ lattice points are colored blue. Two persons play the\n    following game: In each step, a player colors two blue points red, and\n    draws a segment between these two points. (Different segments can\n    intersect in their interior.) Segments are drawn this way until all\n    formerly blue points are colored red. At this moment, the first player\n    directs all segments drawn - i. e., he takes every segment AB, and\n    replaces it either by the vector $\\overrightarrow{AB}$, or by the vector\n    $\\overrightarrow{BA}$. If the first player succeeds to direct all the\n    segments drawn in such a way that the sum of the resulting vectors is\n    $\\overrightarrow{0}$, then he wins; else, the second player wins.\n\nWhich player has a winning strategy?}\n\n\\proof{The basic idea comes from wishing that the first player might be able\nto copy the second player to ``nullify'' his moves. But since this isn't\nalways possible, because no nice symmetry exists on the board, the idea of\ncoloring the board with dominoes and copying moves wrt the dominoes comes.\n\\index[strat]{copycat!partition!aro 2006 11.3}}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h17338p118714}{ISL 2002\nC3}{EM}{Let $n$ be a positive integer. A sequence of $n$ positive integers\n(not necessarily distinct) is called full if it satisfies the following\ncondition: for each positive integer $k\\geq2$, if the number $k$ appears in\nthe sequence then so does the number $k-1$, and moreover the first occurrence\nof $k-1$ comes before the last occurrence of $k$. For each $n$, how many full\nsequences are\nthere?}\\label{problem:bijection_13}\\label{problem:graph_representation_9}\n\n\\proof{After guessing the ans, the first thing that I did was to draw a level\nbased graph. Suppose that a full sequence has $ k $ different entries. Then\nthe top level contains the positions of $ k $ in the sequence sorted from left\nto right. The next level contains the positions of $ k-1 $ in the sequence\nsorted so, and so on till the last level. What I noticed is that if we draw\narrows pointing from a larger integer to a smaller integer, the only arrows\n(or more like relations between entries of the sequence) we need to worry\nabout are the arrows pointing left to right in each levels, and the arrows\nfrom the last entry of level $ i $ to the first entry of level $ i+1 $. After\nthis, if we try with a smaller case, we see that this leads to a bijection\nfrom the set of sequences of length $ n $ with $ n $ different integers to the\nset of full-sequences of length $ n $.}\n\n\n\\solu{Another bijection approach is as followed, in a full-sequence, on first\nrun, go from right to left, placing integers starting with $ 1 $ onwards on\nthe $ 1 $'s in the sequence. on the second run continue counting and placing\nintegers on the $ 2 $'s and so on.}\n\n\n\\solu{Another idea is to prove $ a_n = n a_{n-1} $. To do this, remove the\nrightmost $ 1 $ and do some casework.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h219938p1219679}{ISL 1994\nC2}{M}{In a certain city, age is reckoned in terms of real numbers rather than\nintegers. Every two citizens $x$ and $x'$ either know each other or do not\nknow each other. Moreover, if they do not, then there exists a chain of\ncitizens $x = x_0, x_1, \\ldots, x_n = x'$ for some integer $n \\geq 2$ such\nthat $ x_{i-1}$ and $x_i$ know each other. In a census, all male citizens\ndeclare their ages, and there is at least one male citizen. Each female\ncitizen provides only the information that her age is the average of the ages\nof all the citizens she knows. Prove that this is enough to determine uniquely\nthe ages of all the female citizens.}\n\n\\solu{Describing the problem using matrix and vector spaces, the problem\nreduces to well known theorems of linear algebra.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h93p261}{ISL 2003 C1}{E}{Let\n$A$ be a $101$-element subset of the set $S=\\{1,2,\\ldots,1000000\\}$. Prove\nthat there exist numbers $t_1$, $t_2, \\ldots, t_{100}$ in $S$ such that the\nsets \\[ A_j=\\{x+t_j\\mid x\\in A\\},\\qquad j=1,2,\\ldots,100 \\] are pairwise\ndisjoint.}\n\n\\solu{just count...}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1425422p8029376}{EGMO 2017\n    P5}{E}{Let $n\\geq2$ be an integer. An $n$-tuple $(a_1,a_2,\\dots,a_n)$ of\n    not necessarily different positive integers is expensive if there exists a\n    positive integer $k$ such that \n\n    \\[(a_1+a_2)(a_2+a_3)\\dots(a_{n-1}+a_n)(a_n+a_1)=2^{2k-1}\\]\n\n    a) Find all integers $n\\geq2$ for which there exists an expensive\n    $n$-tuple.\n\nb) Prove that for every odd positive integer $m$ there exists an integer\n$n\\geq2$ such that $m$ belongs to an expensive $n$-tuple.}\n\n\\rem{gutaguti solution}\n\n\\solu{All odd $ n $ works, you can prove for even $ n $ by $ +1, -1 $\naddition. For the second part, start with the odd number, move on both side,\nyou will eventually reach $ 1 $.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h84550p490581}{USAMO 2006\nP2}{E}{For a given positive integer $k$ find, in terms of $k$, the minimum\nvalue of $N$ for which there is a set of $2k + 1$ distinct positive integers\nthat has sum greater than $N$ but every subset of size $k$ has sum at most\n$\\tfrac{N}{2}.$}\n\n\\solu{Compactness is the optimal decision.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1076949p4710743}{MOP\nProblem}{E}{Prove that for any positive integer $c$, there exists an integer\n$n$ such that $n$ has more 1's in its binary expansion than $n^2+c$ does.}\n\n\\solu{For $ x= 2^a-1 $, $ x $ and $ x^2 $ have the same number of $ 1's $. So\ndoes $ x=2^a-2^b $. But what if increase the number of $ 1's $ in this $ x $\nby substracting $ 1 $? Let $ x=2^a - 2^b -1 $. This might work if we can\nchoose nice $ a, b $'s}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1078552p4732509}{EGMO 2015\nP2}{EM}{A domino is a $2 \\times 1$ or $1 \\times 2$ tile. Determine in how many\nways exactly $n^2$ dominoes can be placed without overlapping on a $2n \\times\n2n$ chessboard so that every $2 \\times 2$ square contains at least two\nuncovered unit squares which lie in the same row or column.}\n\n\\solu{Notice how each of the four kind of dominoes needs to be in a group. So\nif we separated them into blocks, inverstigation shows that there can only be\n$ 4 $ blocks and each strictly attached to the sides. The reason why this is\nhappening is pretty obvious. Now those blocks create two paths between the two\nopposite vertices of the square. This gives our desired bijection.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h148826p841252}{USA TST 2006\nP5}{TE}{Let $n$ be a given integer with $n$ greater than $7$ , and let\n$\\mathcal{P}$ be a convex polygon with $n$ sides. Any set of $n-3$ diagonals\nof $\\mathcal{P}$ that do not intersect in the interior of the polygon\ndetermine a triangulation of $\\mathcal{P}$ into $n-2$ triangles. A triangle in\nthe triangulation of $\\mathcal{P}$ is an interior triangle if all of its sides\nare diagonals of $\\mathcal{P}$. Express, in terms of $n$, the number of\ntriangulations of $\\mathcal{P}$ with exactly two interior triangles, in closed\nform.}\n\n\\solu{Just mindless calculation...}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h418687p2362298}{ISL 2010\n    C3}{E}{2500 chess kings have to be placed on a $100 \\times 100$ chessboard\n    so that\n\n    \\begin{enumerate} \\item  no king can capture any other one (i.e. no two\n    kings are placed in two squares sharing a common vertex); \\item  each row\n    and each column contains exactly 25 kings.  \\end{enumerate}\n\nFind the number of such arrangements. (Two arrangements differing by rotation\nor symmetry are supposed to be different.)}\n\n\n\n\\solu{In a $ 2\\times 2 $ box, one can place only one king. So we divide the\nboard in that way, and explore...}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1558133_a_tasty_dish_of_graph_theory}{USA\n    Winter TST 2018 P3}{M}{\n    At a university dinner, there are $ 2017 $\n    mathematicians who each order two distinct entrées, with no two mathematicians\n    ordering the same pair of entrées. The cost of each entrée is equal to the\n    number of mathematicians who ordered it, and the university pays for each\n    mathematician's less expensive entrée (ties broken arbitrarily). Over all\n    possible sets of orders, what is the maximum total amount the university could\n    have paid?\n}\n\n\\input{dump/USATST_W_2018_P3}\n\n\\rem{Easy to think in grids, but it was quite difficult to formulate the\nsolution rigorously, I still am not 100\\% convinced myself. Next time when I\nfeel like it, I will reconstruct the solution. Roughly it is: take the final 0\nvalue columns, prove that there is only one such, and prove the bounds on the\nsolution before using that instead. Then use general bounding to find the\nmaximum. It's not hard, it's just I don't have time now. GAH!! HSC!!}\n\n\\rem{Didn't read other solutions too, gonna give a todo}\n%todo: read other solutions.\n\n\n\\subsubsection{Conway's Soldiers}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h62194p372309}{ISL 1993\nC5}{MH}{On an infinite chessboard, a solitaire game is played as follows: at\nthe start, we have $n^2$ pieces occupying a square of side $n.$ The only\nallowed move is to jump over an occupied square to an unoccupied one, and the\npiece which has been jumped over is removed. For which $n$ can the game end\nwith only one piece remaining on the board?}\n\n\\solu{We want to find an invariant. So we need to find a weight for each of\nthe cells such that any two consecutive cells' values equals to the values of\nthe two cells on the two sides. Some mind bashing gives the idea of mod $ 3 $.\nAnd a construction for the other $ n $'s can be easily generated after some\ncasework.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h262542p1426437}{ARO 1999\nP4}{M}{A frog is placed on each cell of a $n \\times n$ square inside an\ninfinite chessboard (so initially there are a total of $n \\times n$ frogs).\nEach move consists of a frog $A$ jumping over a frog $B$ adjacent to it with\n$A$ landing in the next cell and $B$ disappearing (adjacent means two cells\nsharing a side). Prove that at least $ \\left[\\frac{n^2}{3}\\right]$ moves are\nneeded to reach a configuration where no more moves are possible.}\t\n\n\\solu{In the final stage, no two neighboring cells are occupied. Could we\ndouble count the number of frogs with this information? What about the number\nof frogs in the original $ n\\times n $ board? Another small information needed\nfor this is that we need $ 2 $ moves to ``empty'' a $ 2\\times 2 $ board.}\n\n\n\n\n\n\n\\subsubsection{Triominos}\n\n\\prob{https://artofproblemsolving.com/community/c6h404324p2254569}{ARO 2011\nP10.8}{M}{A $2010\\times 2010$ board is divided into corner-shaped figures of\nthree cells. Prove that it is possible to mark one cell in each figure such\nthat each row and each column will have the same number of marked cells.}\n\n\\solu{First we will mark the corner pieces of the triominos. Then shift the\nmark to either of the legs. Our objective is to show that we can always do\nthis. First if we only focus on the rows, we can easily show that this can be\ndone using some counting. To show that we can do the same for columns as well,\nwe create a graph from columns and rows to triominos which should be operated\non, and using Hall's Marriage we pove the result.}\n\n\n\n\\prob{}{St. Petersburg 2000}{E}{On an infinite checkerboard are placed $111$\nnon-overlapping corners, L-shaped figures made of $3$ unit squares. Suppose\nthat for any corner, the $2\\times 2$ square containing it is entirely covered\nby the corners. Prove that one can remove some number between $1$ and $110$ of\nthe corners so that the property will be preserved.}\n\n\n\n\\subsubsection{Dominos}\n\n\\prob{}{}{E}{An $m\\times n$ rectangular grid is covered by dominoes. Prove\nthat the vertices of the grid can be coloured using three colours so that any\ntwo vertices a distance $1$ apart are colored with different colours if and\nonly if their segment lies on the boundary of a domino.}\n\n\\solu{Create a graph with the midpoints of the dominos.}\n\n\n\n\n\\subsection{Clearly Bijection}\n\n\\prob{https://artofproblemsolving.com/community/c6h1446909p8271411}\n{APMO 2017 P3}{H}{\n    Let $ A(n) $ denote the number of sequences $ a_1\\geq a_2\\geq \\dots\\geq\n    a_k $ of positive integers for which   $ \\sum_{i=1}^k a_k =n $ and each $\n    a_i+1 $ is a power of two. \n\n    Let $ B(n) $ denote the number of sequences $\n    b_1\\geq b_2\\geq\\dots\\geq b_k $ of positive integers for which $ \\sum_{i=1}^k\n    b_k =n $ and each inequality $ b_j\\geq 2b_{j+1} $ holds $(j=1,2\\dots m-1)$. \n\n    Prove that $ \\vert A(n)\\vert =\\vert B(n)\\vert $ for every\n    positive integer. \n}\\label{problem:add_stuffs_1}\\label{problem:bijection_6}\n\n\\solu{\n    A sequence of the first type can be rewritten as: \\[\n    n=x_1+3x_2+7x_3\\dots +(2^i-1)x_i+\\dots (2^k-1)x_k \\] Where $ x_i $ are\n    non-negative integers. This motivates us to find a way to represent $ b_i $ as\n    sums of $ ( 2^i-1)x_i $. Then since $ b_j\\geq 2b_{j+1} $, we write: $\n    b_i=2b_{i-1}+x_i $ with $ x_i $ being non-negative integers.\n}\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h215429p1191679}\n{ISL 2008 C4}{M}{\n    Let $ n $ and $ k $ be positive integers with $ k\\geq n $ and $k-n$ \n    an even number. Let $ 2n $ lamps labeled $ 1,2\\dots 2n $ be given, each\n    of which can be either on or off. Initially, all the lamps are off. We\n    consider sequences of steps: at each step one of the lamps is switched\n    (from on to off or from off to on).\n\n    Let $ N $ be the number of such sequences consisting of $ k $ steps and\n    resulting in the state where lamps $ 1 $ through $ n $ are all on, and\n    lamps $ n+1 $ through $ 2n $ are all off.\n\n    Let $ M $ be number of such sequences consisting of $ k $ steps, resulting\n    in the state where lamps $ 1 $ through $ n $ are all on, and lamps $ n+1 $\n    through $ 2n $ are all off, but where none of the lamps $ n+1 $ through $\n    2n $ is ever switched on.\n\n    Determine $ \\dfrac{N}{M} $.\n}\\label{problem:bijection_5}\n\n\\solu{\n    These type of problems most of the time have bijection or algo\n    solutions. Think of a way to perform bijection from the set $ S\\{M\\}\n    \\rightarrow S\\{N\\} $. Find an algorithm to get a sequence of the first type\n    from a sequence of the second type.\n}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h57380p353058}\n{USAMO 1996 P4}{E}{\n    An $ n $ -term sequence $ (x_1, x_2, \\ldots, x_n) $ in which each term\n    is either 0 or 1 is called a binary sequence of length $ n $. Let $ a_n $ be\n    the number of binary sequences of length $ n $ containing no three consecutive\n    terms equal to 0, 1, 0 in that order. Let $ b_n $ be the number of binary\n    sequences of length $ n $ that contain no four consecutive terms equal to 0,\n    0, 1, 1 or 1, 1, 0, 0 in that order. Prove that $ b_{n+1} = 2a_n $ for all\n    positive integers $ n $.\n}\\label{problem:bijection_4}\n\n\\solu{\n    These type of problems cries for a nice bijection. That is a way to get\n    from $ a\\rightarrow b $ and vice versa. What if there is no $ 0,0,1,1 $ ? Or\n    what if there is no $ 0,1,0 $ ? What is an one way bijection?\n}\n", "meta": {"hexsha": "c145f0b402f4cca2238e153c42b031ff62204b4a", "size": 28108, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combi/sec9_configs.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "combi/sec9_configs.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combi/sec9_configs.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 48.1301369863, "max_line_length": 689, "alphanum_fraction": 0.7272306817, "num_tokens": 8110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.8152324871074608, "lm_q1q2_score": 0.4362296228165666}}
{"text": "\\section{Binary integers : ZArith}\nThe {\\tt ZArith} library deals with binary integers (those used\nby the {\\tt Omega} decision tactic).\nHere are defined various arithmetical notions and their properties,\nsimilar to those of {\\tt Arith}.\n\n", "meta": {"hexsha": "21e52c19820fcc7f13515bbb48bab7755e75f734", "size": 238, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Resources/coq-8.3pl2/theories/ZArith/intro.tex", "max_stars_repo_name": "mzp/coq-for-ipad", "max_stars_repo_head_hexsha": "4fb3711723e2581a170ffd734e936f210086396e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-01-27T00:11:26.000Z", "max_stars_repo_stars_event_max_datetime": "2015-01-27T00:11:26.000Z", "max_issues_repo_path": "Resources/coq-8.3pl2/theories/ZArith/intro.tex", "max_issues_repo_name": "mzp/coq-for-ipad", "max_issues_repo_head_hexsha": "4fb3711723e2581a170ffd734e936f210086396e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Resources/coq-8.3pl2/theories/ZArith/intro.tex", "max_forks_repo_name": "mzp/coq-for-ipad", "max_forks_repo_head_hexsha": "4fb3711723e2581a170ffd734e936f210086396e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0, "max_line_length": 67, "alphanum_fraction": 0.7731092437, "num_tokens": 58, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4362083426263687}}
{"text": "\\section{Control Panel} \\label{sec:cp}\nBefore we dive in an start modelling the planet, let us first set up a control \npanel that will influence how the model will behave and effectively decides what \ntype of planet we model.\n\n\\subsection{The Beginning}\nIn the beginning there was nothing, and then there was \"Hello World!\" Or at \nleast that is how many projects start. Why? you might ask, which is a perfectly \nvalid question. In Computer Science, \"Hello World!\" is very simple code that we \nuse to test whether all the tools we need to get coding works. This checks \nwhether the computer compiles the code and is able to execute it and whether the \ncode editor (IDE, Integrated Development Environment) starts the right processes \nto get the code compiled and executed. Oh right we were talking about CLAuDE, \nahem.\n\nEvery project must have its beginning. And with CLAuDE I made the decision to \nstart explaining the Control Panel first. This is to get you familiar with \nnotation and to lay down some basics. To do that we start with the fixed part of \nthe Control Panel, the physical constants. Many things vary from planet to \nplanet, how much radiation they receive from their star, how strong their \ngravity is, how fast they spin around their axis and many many more. What does \nnot change are the physical constants, well because they are constant. The \nStefan-Boltzmann constant for instance does not change. Whether you are on \nEarth, in space or on Jupiter, the value of the Stefan-Boltzmann constant will \nremain the same. \n\nThe Stefan-Boltzmann constant is denoted by $\\sigma$ and has a value of \n$5.670373 \\cdot 10^-8$ (\\si{Wm^{-2}K^{-4}}) \\cite{stefan-boltzmann}. The \n$\\sigma$ is a greek letter called sigma. Greek letters are often used in \nmathematics, as well as in physics or any other discipline that relies on maths \n(spoiler alert, quite a lot). Treat it like a normal letter in maths, \nrepresenting a number that you either do not know yet or is too long or \ncumbersome to write down every time. The Stefan-Boltzmann constant is denoted in \nscientific notation, a number followed by the order of magnitude. It is denoted \nas a multiplication, because that is what you have to do to get the real number. \nAn example: $4.3 \\cdot 10^2 = 430$ and $4.3 \\cdot 10^{-2} = 0.043$. The letters \nbehind the numbers are units, how we give meaning to the numbers. If I say that \nI am $1.67$ does not mean anything. Do I mean inches, centimeters, meters, \nmiles? That is why we need units as they give meaning to the number. They tell \nus whether the number is talking about speed, distance, time, energy and many \nother things. In this manual we will use SI units. Behind all the letters you \nwill find the following: [number]. This is a citation, a reference to an \nexternal source where you can check whether I can still read. If I pull a value \nout somewhere I will insert a citation to show that I am not making these \nnumbers up. This is what scientists use to back up their claims if they do not \nwant to redo the work that others have done. I mean what is the point of \nre-inventing the wheel if there is a tyre company next door? That is why \nscientists citate.\n\nSo with that out of the way, let us write down some constants. Why do I do this \nhere? Because a lot of constants are used everywhere and I am too lazy to \nreplicate them every time. If you see a letter or symbol that is not explicitly \nexplained, then it is most likely a constant that we discuss here in the control \npanel. \n\n\\subsection{Physical Constants}\nAs mentioned before, physical constants do not change based on where you are in \nthe universe. Below you will find an overview of all the relevant constants \ntogether with their units. As well as a short explanation where they are used or \nwhat they represent. To see them in action, consult the other sections of this \nmanual, you will find them in equations all throughout this document.\n\n\\subsubsection{The Gas Constant} \\label{sec:gas constant}\nThe Gas constant, $R = 8.3144621$ (\\si{JK^{-1}mol^{-1}}) \\cite{idealGas} is the \nconstant used to relate the temperature of the gas to the pressure and the \nvolume. One would expect this constant to be different per gas, but under high \nenough temperatures and low enough pressure the gas constant is the same for all \ngases. \n\n\\subsubsection{The Specific Heat Capacity}\nThe specific heat capacity $c$ depicts how much energy is required to heat the \nobject by one degree Kelvin per unit mass (\\si{Jkg^{-1}K^{-1}}) \n\\cite{specificHeat}. This varies per material and is usually indicated by a \nsubscript. The specific heat capacity for water for instance is $c_w = 4190$ \n\\si{Jkg^{-1}K^{-1}}. Specific heat capacities also exist in the form of \n\\si{Jkg^{-1}K^{-1}}, \\si{Jmol^{-1}K^{-1}} and \\si{Jcm^{-3}K^{-1}} which you can \nuse in various circumstances, depending on what information you have.\n\n\\subsubsection{Mole}\nMole is the amount of particles ($6.02214076 \\cdot 10^{23}$) in a substance, \nwhere the average weight of one mole of particles in grams is about the same as \nthe weight of one particle in atomic mass units (\\si{u})\\cite{mole}. This is not \na physical constant perse, but more like a unit (\\si{mol}). Though it is still \nimportant enough to be added here for future reference. All other units are \nway more intuitive and are assumed to be known.\n\n\\subsubsection{The Stefan-Boltzmann Constant}\nThe Stefan-Boltzmann constant, $\\sigma = 5.670373 \\cdot 10^-8$ \n\\si{Wm^{-2}K^{-4})} \\cite{stefan-boltzmann} is used in the Stefan-Boltzmann law \n(more on that in \\Cref{sec:first thermolaw}). \n\n\\subsection{Planet Specific Variables}\nThe following set of variables vary per planet, that's why we call them \nvariables since they vary. Makes sense right? We add them here as we will use \nthem throughout the manual. The advantage of that is quite significant. If you \nwant to test things for a different planet, you only need to change the values \nin one place, instead of all places where you use it. If there is one thing \nthat we computer scientists hate is doing work, we like being lazy and defining \nthings in one place means that we can be lazy if we need to change it. So we put \nin the extra work now, so we do not have to do the extra work in the future. \nThat's actually a quite accurate description of computer scientists, doing hard \nwork so that they can be lazy in the future.\n\n\\subsubsection{The Passage of Time}\nOn Earth we have various indications of how much time has passed. While most of \nthem remain the same throughout the universe, like seconds, minutes and hours, \nothers vary throughout the universe, like days, months and years. Here we \nspecify how long the variable quantities of time are for the planet we want to \nconsider as they are used in the code. When using these variables in equations,\nthe variables are (by the compiler/interpreter) substituted with their \nrespective values. So if somewhere in the manual you see an equation with \n\\texttt{day} in it, we actually need the value of \\texttt{day} to take its \nplace, but write \\texttt{day} so that if we need to change the value we only \nneed to change it in one place. We use the equality symbol ($=$) to check if two \nvariables/numbers are equal and the leftarrow $\\leftarrow$ to assign a value \n(right hand side of the arrow) to a variable (left hand side of the arrow). This \nway there can never be any confusion about whether we mean being equal or \nsetting a value (making it equal) when using the equality symbol ($=$). The star \n(*) symbol means multiplication, whereas the dot ($\\cdot$) is used to indicate \nthe inner product (also known as dot product) between two vectors.\n\nThe different quantities of time that we need are shown in \\Cref{cp:time}. \n\\Cref{cp:day} defines the length of one day in seconds (\\si{s}). \n\\Cref{cp:year} assigns the length of one year in seconds (\\si{s}). \n\\Cref{cp:delta t} is how much time is between each calculation run in seconds \n(\\si{s}).\n\n\\begin{equ}[!htb]\n    \\begin{subequations}\n        \\label{cp:time}\n        \\begin{equation}\n            \\label{cp:day}\n            \\texttt{day} \\is 60 * 60 * 24\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:year}\n            \\texttt{year} \\is 365 * \\texttt{day}\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:delta t}\n            \\delta \\texttt{t} \\is 60 * 9\n        \\end{equation}\n    \\end{subequations}\n    \\caption{Variable assignments with regard to time}\n\\end{equ}\n\n\\subsubsection{The Planet Passport}\nEach planet is different, so why should they all have the same gravity? Oh wait, \nthey don't. Just as they are not all the same size, tilted as much and their \natmospheres differ. So here we define all the relevant variables that are unique \nto a planet, or well not necessarily unique but you get the idea. Remember how \nwe discussed specific heat capacities before and talk about them here again? \nYeah, the specific heat capacity for the Earth's atmosphere is set in stone, \nhowever the specific heat capacity of another planet's atmosphere might be \ncompletely different. Therefore I decided to add them here. So they are \nconstants, but differ per planet.\n\nThe values and variables that define a planet can be found in \n\\Cref{cp:planet}. \\Cref{cp:gravity} deals with the magnitude of gravity on \nthe planet in \\si{ms^{-2}}. \\Cref{cp:axial tilt} describes the angle between \nthe orbital axis and the rotational axis \\cite{axialTilt} in degrees. \n\\Cref{cp:top} indicates how high the top of the atmosphere is with respect to \nthe planet surface in meters (\\si{m}). \\Cref{cp:ins} stores the amount of \nenergy from the star that reaches the planet per unit area (\\si{Jm^{-2}}). \n\\Cref{cp:absorp} is the absorbtivity of the atmosphere, the fraction of how \nmuch of the total energy that enters the atmosphere is absorbed (unitless). \n\\Cref{cp:radius} tells us the radius of the planet in meters (\\si{m}). \n\\texttt{R} is a captial as the non-captilised version (\\texttt{r}) is used to \nindicate the radius of any object, whereas the capital is used to indicate the \nradius of celestial bodies, which planets are. \\Cref{cp:pressureLevels} is an \narray that stores the pressure of the different levels in pascals (\\si{Pa}). \n\\Cref{cp:heatCapacityAtmos} states the specific heat capacity of the \natmosphere in \\si{Jkg^{-1}K^{-1}}. \\Cref{cp:heatCapacityPlanet} describes the \nspecific heat capacity of the planet in \\si{Jkg^{-1}K^{-1}}.\n\n\\begin{equ}[!htb]\n    \\begin{subequations}\n        \\label{cp:planet}\n        \\begin{equation}\n            \\label{cp:gravity}\n            \\texttt{g} \\is 9.81\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:axial tilt}\n            \\alpha \\is -23.5\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:top}\n            \\texttt{top} \\is 50 * 10^3\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:ins}\n            \\texttt{insulation} \\is 1370\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:absorp}\n            \\epsilon \\is 0.75\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:radius}\n            \\texttt{R} \\is 6.4 * 10^6\n        \\end{equation}\n        \\begin{multline}\n            \\label{cp:pressureLevels}\n            \\texttt{pressure} \\is [100000, 95000, 90000, 80000, 70000, 60000, \n                                    50000, 40000, 35000, 30000, \\\\\n                                    25000, 20000, 15000, 10000, 7500, 5000, \n                                    2500, 1000, 500, 200, 100]\n        \\end{multline}\n        \\begin{equation}\n            \\label{cp:heatCapacityAtmos}\n            C_a \\is 287\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:heatCapacityPlanet}\n            C_p \\is 1 * 10^6\n        \\end{equation}\n    \\end{subequations}\n    \\caption{Variable assignments for planet specific constants}\n\\end{equ}\n\n\\subsubsection{Model Specific Parameters}\nThese parameters cannot be found in the wild, they only exist within our \nmodel. They control things like the size of a cell on the latitude longitude \ngrid (more on that in later sections), how much time the model gets to spin up. \nWe need the model to spin up in order to avoid numerical instability. Numerical \ninstability occurs when you first run the model. This is due to the nature of \nthe equations. Nearly all equations are continuous, which means that they are \nalways at work. However when you start the model, the equations were not at work \nyet. It is as if you suddenly give a random meteor an atmosphere, place it in \norbit around a star and don't touch it for a bit. You will see that the whole \nsystem oscilates wildly as it adjusts to the sudden changes and eventually it \nwill stabilise. We define the amount of time it needs to stabilise as the spin \nup time. All definitions can be found in \\Cref{cp:model}. \n\\Cref{cp:resolution} defines the number of degrees on the latitude longitude \ngrid that each cell has, with this setting each cell is 3 degrees latitude high \nand 3 degrees longitude wide. \\Cref{cp:atmosLevels} is the amount of layers \nin the atmosphere, determined by the pressure levels array. \n\\Cref{cp:spinupCalctime} describes the time between calculation rounds during \nthe spin up period in seconds (\\si{s}). \\Cref{cp:spinuptime} shows us how \nlong we let the planet spin up in seconds (\\si{s}). \\Cref{cp:smoothEnable} \nis whether we want to enable smoothing using Fast Fourier Transforms (FFTs) or \nnot, see \\Cref{sec:3dsmooth}. \\Cref{cp:smoothT} is the smoothing parameter \nfor the temperature. \\Cref{cp:smoothU} describes the smoothing parameter for \nthe $u$ component of the velocity, see \\Cref{sec:velocity}. \n\\Cref{cp:smoothV} shows us the smoothing parameter for the $v$ component of \nthe velocity, see \\Cref{sec:velocity}. \\Cref{cp:smoothW} talks about the \nsmoothing parameter for the $w$ component of the velocity, see \n\\Cref{sec:velocity}. \\Cref{cp:smoothAdd} is the smoothing parameter for \nthe change in potential temperature, see \\Cref{sec:thermal pot}. \n\\Cref{cp:save} is used to determine whether we want to enable saving the \nmodel state to a file for later use. \\Cref{cp:load} is used to enable loading \nthe model state from a file and to skip the spin up time. \\Cref{cp:saveFreq} \ndetermines how often we save the model state, after how many iterations we save.\n\\Cref{cp:poleLowLatLimit} is the polar plane approximation lower grid limit, \nhow far north the polar plane data is calculated from the south pole. This is \nmirrored to the north pole as well. \\Cref{cp:poleHighLatLimit} defines the \npolar plane approximation upper grid limit, how far south the data from the \nlatitude longitude grid is calculated. This is mirrored to the north pole as \nwell. \\Cref{cp:spongeLayer} is the pressure at which the equations of motion \nstop being applied (to absorb upwelling atmospheric waves) in \\si{Pa}.\n\n\\begin{equ}[!htbp]\n    \\begin{subequations}\n        \\label{cp:model}\n        \\begin{equation}\n            \\label{cp:resolution}\n            \\texttt{resolution} \\is 3\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:atmosLevels}\n            \\texttt{layerCount} \\is \\texttt{pressure}.length\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:spinupCalctime}\n            \\delta \\texttt{t}_{\\texttt{s}} \\leftarrow 60 * 17.2\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:spinuptime}\n            \\texttt{t}_{\\texttt{s}} \\leftarrow 5 * \\texttt{day}\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothEnable}\n            \\texttt{smoothing} \\is \\F\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothT}\n            \\texttt{smooth}_{\\texttt{t}} \\is 1\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothU}\n            \\texttt{smooth}_{\\texttt{u}} \\is 0.9\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothV}\n            \\texttt{smooth}_{\\texttt{v}} \\is 0.9\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothW}\n            \\texttt{smooth}_{\\texttt{w}} \\is 0.3\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:smoothAdd}\n            \\texttt{smooth}_{\\texttt{add}} \\is 0.3\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:save}\n            \\texttt{save} \\is \\F\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:load}\n            \\texttt{load} \\is \\F\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:saveFreq}\n            \\texttt{saveFrequency} \\is 100\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:poleLowLatLimit}\n            \\texttt{poleLowerLatLimit} \\is -75\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:poleHighLatLimit}\n            \\texttt{poleHigherLatLimit} \\is -85\n        \\end{equation}\n        \\begin{equation}\n            \\label{cp:spongeLayer}\n            \\texttt{spongeLayer} \\is 1000\n        \\end{equation}\n    \\end{subequations}\n    \\caption{Variable assignments for model specific parameters}\n\\end{equ}\n\n%Move to initial setup $\\delta y \\leftarrow \\frac{2\\pi r}{nlat}$ \\Comment*[l]{How far apart the gridpoints in the y direction are (degrees latitude)}\n%Move to initial setup $\\alpha_a \\leftarrow 2 \\cdot 10^{-5}$ \\Comment*[l]{The diffusivity constant for the atmosphere}\n%Move to initial setup $\\alpha_p \\leftarrow 1.5 \\cdot 10^{-6}$ \\Comment*[l]{The diffusivity constant for the planet surface}\n\n% \\begin{algorithm}\n%     \\caption{Defining the paramters that only apply to the model}\n%     \\label{alg:model constants}\n%     \\SetKwComment{Comment}{//}{}\n\n%     $count \\leftarrow 0$ \\; %And this is..?\n%     \\For{$j \\in [0, top]$}{\n%         $heights[j] \\leftarrow count$ \\Comment*[l]{The height of a layer (\\si{m})}\n%         $count \\leftarrow count + \\frac{top}{nlevels}$ \\;\n%     }\n\n%     \\For{$i \\in [0, nlat]$}{\n%         $\\delta x[i] \\leftarrow \\delta y\\cos(lat[i]\\frac{\\pi}{180})$ \\Comment*[l]{How far apart the gridpoints in the x direction are (degrees longitude)}\n%     }\n\n%     \\For{$k \\in [0, nlevels - 1]$}{\n%         $\\delta z[k] \\leftarrow p_z[k + 1] - p_z[k]$ \\Comment*[l]{How far apart the gridpoints in the z direction are (\\si{Pa})}\n%     }\n\n%     $\\Pi \\leftarrow$ Array with the same amount of elements as $p_z$ \\Comment*[l]{Dimensionless pressure that is used to easily convert from potential temperature to absolute temperature and \n%     vice versa}\n%     $\\kappa \\leftarrow \\frac{R}{C_p}$ \\;\n%     \\For{$i \\leftarrow 0$ \\KwTo $\\Pi.length$}{\n%         $\\Pi[i] \\leftarrow C_p(\\frac{p_z[i]}{p_z[0]})^{\\kappa}$ \\;\n%     }\n% \\end{algorithm}", "meta": {"hexsha": "bc6594f0352c3359af27b7ec2c53f9b0a8381fe6", "size": 18688, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex-docs/topics/control_panel.tex", "max_stars_repo_name": "TechWizzart/claude", "max_stars_repo_head_hexsha": "68d68f8724477f8ddbc67d5add62a25c7fc439ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex-docs/topics/control_panel.tex", "max_issues_repo_name": "TechWizzart/claude", "max_issues_repo_head_hexsha": "68d68f8724477f8ddbc67d5add62a25c7fc439ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex-docs/topics/control_panel.tex", "max_forks_repo_name": "TechWizzart/claude", "max_forks_repo_head_hexsha": "68d68f8724477f8ddbc67d5add62a25c7fc439ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-11-25T21:14:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-17T00:38:40.000Z", "avg_line_length": 51.4820936639, "max_line_length": 193, "alphanum_fraction": 0.6961151541, "num_tokens": 5025, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4362083369961536}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{geometry}\n\\usepackage{enumerate}\n\\usepackage{natbib}\n\\usepackage{float}%稳定图片位置\n\\usepackage{graphicx,subfig}%画图\n\\usepackage{caption}\n\\usepackage[english]{babel}\n\\usepackage{indentfirst}%缩进\n\\usepackage{enumerate}%加序号\n\\usepackage{multirow}%合并行\n\\usepackage{hyperref}\n\\usepackage{tikz}\n\\hypersetup{hypertex=true, colorlinks=true, linkcolor=black, anchorcolor=black, citecolor=black}\n\\title{\\Large \\textbf{VG441 Problem Set 2}\\\\\n\\author{\\textbf{Pan, Chongdan ID:516370910121}\\\\\n}\n}\n\\begin{document}\n\\maketitle\n\\section{Problem 1}\n\\quad\nLet one day be the unit time, then we get $\\lambda=500,K=2250,h=\\frac{1}{1460}$\n\\\\\\[c=\\begin{cases}\n    1490 & Q<1200\\\\\n    1220 & 1200\\leq Q<2400\\\\\n    1100 & Q\\geq 2400\n\\end{cases}\\]\n\\\\When we apply the all-units discount structure:\n\\\\$Q_0^*=\\sqrt{\\frac{2K\\lambda}{hc_0}}=\\sqrt{\\frac{2\\times2250\\times500\\times1460}{1490}}\\approx1484.8$\n\\\\$Q_1^*=\\sqrt{\\frac{2K\\lambda}{hc_1}}=\\sqrt{\\frac{2\\times2250\\times500\\times1460}{1220}}\\approx1640.9$\n\\\\$Q_2^*=\\sqrt{\\frac{2K\\lambda}{hc_2}}=\\sqrt{\\frac{2\\times2250\\times500\\times1460}{1100}}\\approx1728.1$\n\\\\\\\\Only $Q_0^*$ and $Q_1^*$ are realizable\n\\\\$g_1(Q_1)=500\\times1200+\\sqrt{2\\times2250\\times500\\times\\frac{1}{1460}\\times1200}\\approx611371.2$\n\\\\\\\\For the breakpoints\n\\\\$g_1(1200)=500\\times1220+\\frac{2250\\times500}{1200}+\\frac{1220\\times1200}{2\\times1460}\\approx611438.9$\n\\\\$g_2(2400)=500\\times1100+\\frac{2250\\times500}{2400}+\\frac{1100\\times2400}{2\\times1460}\\approx551372.9$\n\\\\Therefore, it's the optimal order quantity is $Q=2400$ ton, which incurs a purchase cost of 1100\\$ and the daily cost is 551372.9\\$\n\\\\\\\\When we apply the incremental discount structure:\n\\\\$\\bar{c_1}=1490\\times1200-1220\\times1200=324000$\n\\\\$\\bar{c_2}=1490\\times1200+1220\\times1200-1100\\times2400=612000$\n\\\\$Q_0^*=\\sqrt{\\frac{2\\times2250\\times500\\times1460}{1490}}=1484.8$\n\\\\$Q_1^*=\\sqrt{\\frac{2\\times(2250+324000)\\times500\\times1460}{1220}}=19759.3$\n\\\\$Q_2^*=\\sqrt{\\frac{2\\times(2250+612000)\\times500\\times1460}{1100}}=28553.1$\n\\\\\\\\Only $Q_2^*$ are realizable\n\\\\$g_2(28553.1)=500\\times1100+\\frac{612000}{2\\times1460}+\\sqrt{2\\times500\\times(2250+612000)\\times1100\\times\\frac{1}{1460}}=571722.2$\n\\\\Therefore, it's the optimal order quantity is $Q=28553.1$ ton, which incurs the daily cost 571722.2\\$\n\\section{Problem 2}\n$T=52,K=1100,c=2.4$\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.2]{P1.png}\n    \\caption{Plot of Result}\n    \\label{P1}\n\\end{figure}\nAccording to MILP Model computed by guroby package in python, the objective $\\sum_{t=1}^T(Ky_t+hx_t)$ is 42583\\$, \\ref{P1} shows demand, optimal order quantity and corresponding inventory level.\n\\section{Problem 3}\n\\textbf{Task 1}\n\\begin{enumerate}\n    \\item First, we pick the Path:$s\\rightarrow b\\rightarrow t$\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.25]{P2.png}\n        \\caption{Flow Graph of Step 1}\n    \\end{figure}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.25]{P3.png}\n        \\caption{Residual Graph of Step 1}\n    \\end{figure}\n    \\item Second, we pick the Path:$s\\rightarrow a\\rightarrow t$\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.25]{P4.png}\n        \\caption{Flow Graph of Step 2}\n    \\end{figure}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[scale=0.25]{P5.png}\n        \\caption{Residual Graph of Step 2}\n    \\end{figure}\n    Since there is no more path $p\\rightarrow t$, the max flow is 5\n\\end{enumerate}\n\\textbf{Task 2}\nYes, because by looking the original graph intuitively, we can easily find the max flow is 2000, and the algorithm only needs to take two steps if it prefers $s\\rightarrow a\\rightarrow t$ and $s\\rightarrow b\\rightarrow t$\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.25]{P6.png}\n    \\caption{Intuitive Path}\n\\end{figure}\nHowever, if the algorithm prefers $E_{ab}$, the first path will either be $s\\rightarrow a\\rightarrow t$ or $s\\rightarrow b\\rightarrow t$ with flow 1. \n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.25]{P7.png}\n    \\caption{Flow Graph of Step 1}\n\\end{figure}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.25]{P8.png}\n    \\caption{Residual Graph of Step 1}\n\\end{figure}\nThen, according to the perference and residual graph, the next path will be the opposite one, but still with flow 1. Therefore, it takes 2000 steps for the algorithm to find the max flow. So the perference to $E{ab}$ will lead to more steps for the algorithm.\n\\section*{Python Code}\n\\begin{verbatim}\nimport numpy as np\nimport pandas as pd\nfrom gurobipy import *\nimport matplotlib.pyplot as plt\n\ndf = pd.DataFrame(pd.read_csv(r\"D:\\PANDA\\Study\\VG441\\Homework\\Problem Set 2\\demand.csv\"))\nd = df.d_t.T\nT, K, h = 52, 1100, 2.4\nM = 10e5\n# 导入数据\nWW = Model()\nq = WW.addVars(T, lb=np.zeros(T), vtype=GRB.CONTINUOUS, name=\"order_quantity\")\nx = WW.addVars(T, lb=np.zeros(T), vtype=GRB.CONTINUOUS, name=\"inventory_level\")\ny = WW.addVars(T, vtype=GRB.BINARY, name=\"if_order\")\n\nWW.setObjective(quicksum(K*y[t]+h*x[t] for t in range(T)), GRB.MINIMIZE)\n\nc1 = WW.addConstrs(q[t] <= M*y[t] for t in range(T))\nc2 = WW.addConstrs(x[t] == x[t-1] + q[t] - d[t] for t in range(1,T))\nc3 = WW.addConstr(x[0] == q[0] - d[0])\nWW.optimize()\n# WW.printAttr('X')\nprint(WW.getAttr('X',q).values())\n\nt=np.linspace(0,T-1,T)\nX=[234.9999999999999, 122.99999999999835, 0.0, 297.0, 150.0, 0.0, 174.0, 0.0, 197.0, 0.0, 206.99999999999997, 0.0, 240.00000000000006, 0.0, 241.0000000000011, 0.0, 267.0, 0.0, 289.9999999999999, 0.0, 301.0, 1.4203321069368455e-12, 324.9999999999985, 0.0, 343.0000000000001, 0.0, 340.0, 0.0, 323.0, 0.0, 309.0, 0.0, 293.0, 0.0, 272.9999999999999, 0.0, 248.99999999999994, 0.0, 234.99999999999994, 0.0, 204.0, 0.0, 182.99999999999994, 0.0, 163.99999999999994, 0.0, 299.0, 145.0, 0.0, 224.0, 112.0, 0.0]\n\nQ=[342.9999999999999, 0.0, 1.2505552149377763e-12, 426.0000000000004, 0.0, 0.0, 330.0, 0.0, 386.0, 0.0, 409.0, 0.0, 468.00000000000006, 0.0, 483.00000000000216, 0.0, 533.0, 0.0, 559.9999999999999, 0.0, 604.0, 1.4203321069368455e-12, 653.9999999999972, 1.553065288008162e-12, 688.0000000000001, 0.0, 707.0, 0.0, 660.0, 0.0, 634.0, 0.0, 598.0, 0.0, 545.9999999999999, 0.0, 500.99999999999994, 0.0, 477.99999999999994, 0.0, 430.0, 0.0, 386.99999999999994, 0.0, 338.99999999999994, 0.0, 461.0, 0.0, 0.0, 361.0, 0.0, 0.0]\nplt.plot(t,X,color='blue',label='Inventory Level')\nplt.plot(t,Q,color='red',label='Order Quantity')\nplt.plot(t,d,color='green',label='Demand')\nplt.legend(loc='upper left', fontsize=10)\nplt.show()\n\\end{verbatim}\n\\end{document}", "meta": {"hexsha": "2e315695db5519132a9ccfbe8654b988c9ea034b", "size": 6637, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "VG441SupplyChain/HW/Problem Set 2/HW2.tex", "max_stars_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_stars_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "VG441SupplyChain/HW/Problem Set 2/HW2.tex", "max_issues_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_issues_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "VG441SupplyChain/HW/Problem Set 2/HW2.tex", "max_forks_repo_name": "PANDApcd/SJTU-Machine-Learning", "max_forks_repo_head_hexsha": "e38049db368e683c73ec54412603f4e04270bb2c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0709219858, "max_line_length": 516, "alphanum_fraction": 0.7018231129, "num_tokens": 2655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4362083290048319}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{setspace}\n\n\\usepackage{amsmath, amsfonts, amssymb, graphicx, color, fancyhdr, lipsum, scalerel, stackengine, mathrsfs, tikz-cd, mdframed, enumitem, framed, adjustbox, bm, upgreek, xcolor, hyperref}\n\\usepackage[framed,thmmarks]{ntheorem}\n\\usepackage[style=alphabetic]{biblatex}\n%Set the bibliography file\n\\bibliography{sources}\n\n%Replacement for the old geometry package\n\\usepackage{fullpage}\n\n%Input my definitions\n\\input{./mydefs.tex}\n\n%Shade definitions\n\\theoremindent0cm\n\\theoremheaderfont{\\normalfont\\bfseries} \n\\def\\theoremframecommand{\\colorbox[rgb]{0.9,1,.8}}\n\\newshadedtheorem{defn}[thm]{Definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%% Customize Below %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%header stuff\n\\setlength{\\headsep}{24pt}  % space between header and text\n\\pagestyle{fancy}     % set pagestyle for document\n\\lhead{Notes on Local Duality} % put text in header (left side)\n\\rhead{Nico Courts} % put text in header (right side)\n\\cfoot{\\itshape p. \\thepage}\n\\setlength{\\headheight}{15pt}\n\\allowdisplaybreaks\n\n% Document-Specific Macros\n% Primes and Maximals for the lazy person.\n\\newcommand{\\p}{\\frakp}\n\\newcommand{\\m}{\\frakm}\n\n\\begin{document}\n%make the title page\n\\title{Local Duality Theorems \\vspace{-1ex}}\n\\author{Nico Courts}\n\\date{Summer 2019}\n\\maketitle\n\n\\renewcommand{\\abstractname}{Introduction}\n\\begin{abstract}\n\tThese notes are my attempt to understand the current state of the art in ``local duality'' theorems, especially \n\tof the kind investigated by Benson, Iyengar, Krause, and Pevtsova (herein abbreviated BKIP) in \\cite{BIKPgroupschemes} and \\cite{BKIPgorenstein}.\n\n\tFurthermore I will continue my investigation into quantum groups and other Hopf algebras and see if some of the methods developed earlier \n\tcan be applied to this new area.\n\\end{abstract}\n\n\\section{Current State of the Art}\n\\subsection{Ideas to flush out}\nFrom meeting with Julia, the idea that I have gathered is that these two papers constitute two (slightly) different approaches \nto showing that the notion of Serre duality (which by itself is a ``global'' phenomenon) restricts ($\\frakp$)-locally (more on this later)\nto an analogous result.\n\nThe original result in \\cite{BIKPgroupschemes} proves that such a duality exists for finite group schemes, but the objects of study here are \nmuch simpler (for instance the algebras that arise are Frobenius). Furthermore (this part may be sketchy), the results that are proven \nrely on the (relatively simple) monoidal structure of $G$-modules (where $G$ is a finite group scheme). \n\nThe newer result in \\cite{BKIPgorenstein} reconstructs this result in the context of Gorenstein rings, which are decidedly less degenerate than \nthe case of finite group schemes. What is important here is that this is done although the structure theory of these algebras \nis rather poorly understood, so what this represents is the formation of the idea that this duality somehow can be understood at\na higher level, meaning that it may apply to broader classes of algebras.\n\n\\subsection{Background results and definitions}\nI have seen a good deal of these results already, but it will be useful to put everything into one place so I can reference them as needed.\n\nFirst, Serre duality, which comes from \\cite{hartshorneAG}:\n\\begin{thm}[Serre Duality]\\label{thm-serre-duality}\n\tLet $XS$ be a projective Cohen-Macaulay scheme of equidimension $n$ over $k$. Then for any locally free sheaf $\\scrF$ on $X$, \n\tthere are natural isomorphisms\n\t\\[H^i(X,\\scrF)\\cong H^{n-i}(X,\\scrF^\\vee\\otimes \\omega_X^\\circ)'\\]\n\twhere $(-)'$ indicates taking a vector space dual, $(-)^\\vee$ indicates taking the dual of a locally free sheaf via the functor\n\t$\\mathscr Hom(-,\\calO_X)$ (sheaf hom) and $\\omega_X^\\circ$ denotes a dualizing sheaf (\\ref{defn-dualizing-sheaf}) on $X$.\n\\end{thm}\n\n\\begin{defn}\\label{defn-dualizing-sheaf}\n\tLet $X$ be a proper scheme of dimension $n$. Recall that a \\textbf{dualizing sheaf} is a (coherent) sheaf $\\omega_X^\\circ$ such that there is an isomorphism \n\t\\[\\Hom(\\scrF,\\omega_X^\\circ)\\cong H^n(X,\\scrF)'.\\]\n\\end{defn}\n\\begin{rmk}\n\tIn fact, there is something more: that this isomorphism is induced from a natural pairing of $\\Hom$ and $H^n$. I won't worry \n\tabout this too much for now, but it can be found in \\cite[p. 240]{hartshorneAG}\n\\end{rmk}\n\nI will also include the definition and explanation of compact generation that I wrote down for my Brown representability presentation.\n\\begin{defn}[Compact Object]\\label{defn-compact-obj}\n\tLet $X\\in\\calT$ be an object in a triangulated category. Then $X$ is called \\textbf{compact} if for every coproduct of objects in $\\calT$\n\t\\[\\Hom_\\calT\\left(X,\\coprod_{\\lambda\\in\\Lambda}t_\\lambda\\right)=\\coprod_{\\lambda\\in\\Lambda}\\Hom_\\calT(X,t_\\lambda)\\]\n\\end{defn}\n\\begin{rmk}\n\tThe idea here is that when the codomain is a product, this equality always exists. The projections give you \n\ta product of maps into the factors and the universal property of products gives you a (unique!) map into the product if you\n\thave maps into each of the factors.\n\n\tThis does not hold in general for coproducts, however! Recall that in additive categories \n\tone has a canonical isomorphism between finite products and coproducts. Since triangulated \n\tcategories are additive, this is akin to saying that $X$ is well-behaved in that the maps \n\tfrom $X$ still split even when the codomain is an arbitrarily large coproduct.\n\\end{rmk}\n\\begin{defn}[Compactly Generated Triangulated Category]\\label{defn-compact-tricat}\n\tLet $\\calT$ be a triangulated category. Then $\\calT$ is called \\textbf{compactly generated by a set $G$} of its elements \n\tif $\\calT$ is closed under small coproducts and $G$ consists of compact objects of $\\calT$ such that for all $X\\in\\calT$,\n\t\\[\\Hom_\\calT(G,X)=0\\quad\\Rightarrow\\quad X=0.\\]\n\\end{defn}\n\\begin{rmk}\n\tHere the generators of $\\calT$ are elements that have ``sufficient complexity'' to detect all nonzero elements. \n\t\n\tIn the more general context where $\\calT$ is not necessarily additive, we can generalize this definition to a set of objects \n\tsuch that for every generator $E\\in G$ and any $X,Y\\in\\calC$, if for every $f,g\\in\\Hom(X,Y)$ and $h\\in\\Hom(E,X)$ we have \n\t\\[f\\circ e=g\\circ e\\]\n\tthen \n\t\\[f=g\\]\n\tand here we would say that $G$ has ``sufficient complexity'' to differentiate between any two non-identical maps.\n\\end{rmk}\n\n\\begin{defn}\\label{defn-R-linear-cat}\n\tRecall that with such an $R$, an \\textbf{$R$-linear category} $\\calC$ is one such that the graded ring $\\End^\\ast_\\calC(X)$ admits\n\tan $R$ module structure via a graded ring homomorphism $\\varphi_X:R\\to \\End^\\ast_\\calC(X)$.\n\\end{defn}\n\nThe following comes from \\cite{nlab-serre-functor}. \n\\begin{defn}\\label{defn-serre-func}\n\tLet $\\calS$ be an endofunctor $\\calS:\\calA\\to\\calA$ on a $k$-linear category with finite dimensional $\\Hom$ objects,\n\twhere $k$ is any field. Then $\\calS$ is called a \\textbf{Serre functor} if it is an additive equivalence admitting \n\tbi-functorial isomorphisms\n\t\\[\\phi_{A,B}:\\Hom_\\calA(A,B)\\xrightarrow{\\sim}\\Hom_\\calA(B,\\calS(A))^\\ast\\]\n\tfor all $A$ and $B$ in $\\calA$.\n\\end{defn}\n\n\n\n\\subsection{BKIP Paper 1---Finite Group Schemes}\nLet's start off with the primary result. We will need some definitions and other results to get us there, but it will give us a sense of \nwhere we're headed.\n\\subsubsection{Main Results}\n\\begin{thm}[BKIP `18]\\label{thm-BKIP18}\n\tLet $G$ be a finite group scheme over $k$. Fix some homogeneous prime ideal $\\frakp\\lhd H^\\ast(G,k)$ not containing $H^{\\ge 1}(G,k)$. Let $C=\\gamma_\\frakp(\\stmod G)$\n\tand let $d$ be the Krull dimension of $H^\\ast(G,k)/\\frakp$. Then the assignment\n\t\\[M\\mapsto \\Omega^d\\delta_G\\otimes_k M\\]\n\tinduces a Serre functor (defn~\\ref{defn-serre-func}) for $C$. Thus for all $M$ and $N$ in $C$,\n\t\\[\\Hom_{H^\\ast(G,k)}(\\Hom_C^\\ast(M,N),I(\\frakp))\\cong\\Hom_C(N,\\Omega^d\\delta_G\\otimes M)\\]\n\twhere $I(\\frakp)$ is the injective hull of the graded $H^\\ast(G,k)$ module $H^\\ast(G,k)/\\frakp$.\n\\end{thm}\n\n\\noindent This result follows from a more general result:\n\\begin{thm}[BKIP `18]\\label{thm-BKIP18-ext}\n\tFor any $G$ module $M$ and $I\\in\\bbZ$, there is a natural isomorphism\n\t\\[\\widehat{\\Ext}^i_G(M,\\Gamma_\\frakp(\\delta_G))\\cong\\Hom_{H^\\ast(G,k)}(H^{\\ast-d-i}(G,M),I(\\frakp)).\\]\n\\end{thm}\n\\begin{rmk}\n\tNotice that here $\\Gamma_\\frakp(\\delta_G)$ plays the part of the dualizing object in the second theorem, as Serre duality takes \n\ton a similar form when $\\scrF$ is a coherent sheaf on a nonsingular projective variety $X$ of dimension $n$:\n\t\\[\\Ext_X^i(\\scrF,\\omega_X)\\cong \\Hom_k(H^{n-i}(X,\\scrF),k)\\]\n\\end{rmk}\n\n\\subsubsection{Conventions}\n\nThroughout we are fixing $R$, a \\textbf{graded commutative, Noetherian} ring and $\\calT$, a \\textbf{compactly-generated (\\ref{defn-compact-obj}, \\ref{defn-compact-tricat}) \n$R$-linear (\\ref{defn-R-linear-cat}) triangulated category.} Let $\\calT^c$ be the full subcategory of $\\calT$ comprising of compact objects.\n\n\\subsubsection{Torsion and Localization}\nWe should brush up on a bit of how torsion and localization from rings passes to such a $\\calT$: We say that $M\\in \\Rmod$ is \\textbf{$\\fraka$-torsion} if \n$M_\\frakq=0$ whenever $\\fraka\\not\\subseteq\\frakq$. In other words, whenever we invert something in $\\fraka$, we kill everything. Analogously,\nwe say that $X\\in\\calT$ is $\\fraka$-torsion if $\\Hom^\\ast_\\calT(C,X)$ is $\\fraka$-torsion for all $C\\in\\calT^c$.\n\nNow if $\\p$ is a (homogeneous!) prime in $R$,  we say that $M\\in \\Rmod$ is $\\p$-local if the localization map $M\\mapsto M_\\frakp$ is invertible.\nThis means that ``all of the action is at $\\p$'' -- recall that in the case of rings, this would mean that $\\frakp$ is maximal and contains all non-units,\nso $R$ is local. We say that $X\\in\\calT$ is $\\p$-local if $\\Hom^\\ast_\\calT(C,X)$ is $\\p$-local for all $C\\in\\calT^c$.\n\nWe will be devoting significant attention to $\\Gamma_\\p(\\calT)$, the (full, localizing) subcategory of $\\calT$ consisting \nof the $\\p$-local $\\p$-torsion elements. As far as I can tell, we should be thinking of $R/\\p^i$ as an analogy in $\\Rmod$.\n\nOne of the primary functors in question (the one that extracts the ``local'' nature) is $\\Gamma_\\p$, which assigns to $\\calT$ the \nset (actually it's a localizing subcategory in $\\calT$)\n\\[\\Gamma_\\p(\\calT)=\\{X\\in\\calT| X\\text{is $\\p$-local and $\\p$-torsion\\}}.\\]\n\nThe paper points this out as an important result:\n\\begin{lem}\n\t$\\Gamma_\\p(\\StMod G)$ is finitely generated as a triangulated category by the family of objects $(M//\\p)_\\p$.\n\\end{lem}\nHere $M//\\p$ is defined as $M//p_1\\otimes\\cdots\\otimes M//p_k$ where $p_1,\\dots,p_k$ generate $\\p$ and $M//a$ is defined to \nbe the mapping cone of the map $f_a:k\\to \\Omega^{-d}k$ that comes from the element $a\\in H^d(G,k)$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%  Bibliography %%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\medskip\n\n\\printbibliography\n\n\\end{document}", "meta": {"hexsha": "0b810d99497c9892ce32c24a44b5d5533011375a", "size": 11023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Local Duality/local_duality.tex", "max_stars_repo_name": "NicoCourts/Algebra", "max_stars_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-09-27T17:11:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-29T01:14:02.000Z", "max_issues_repo_path": "Local Duality/local_duality.tex", "max_issues_repo_name": "NicoCourts/Algebra", "max_issues_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Local Duality/local_duality.tex", "max_forks_repo_name": "NicoCourts/Algebra", "max_forks_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-10T00:24:49.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T00:24:49.000Z", "avg_line_length": 55.115, "max_line_length": 186, "alphanum_fraction": 0.7163204209, "num_tokens": 3361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.43610907608897975}}
{"text": "%% -*- coding:utf-8 -*-\n\\chapter{Galois correspondence and first examples. Examples continued}\nWe continue to study the examples: cyclotomic extensions (roots of\nunity), cyclic extensions (Kummer and Artin-Schreier extensions). We\nintroduce the notion of the composite extension and make remarks on\nits Galois group (when it is Galois), in the case when the composed\nextensions are in some sense independent and one or both of them is\nGalois. The notion of independence is also given a precise sense\n(\"linearly disjoint extensions\").\n\n\n\\section{Cyclotomic extensions (cont'd). Examples over $\\mathbb{Q}$}\n\nLast time we discussed cyclotomic extensions which are splitting\nfields of $\\Phi_n$ (generated by n-th roots\n(\\mynameref{def:primitiverootsofunity}) of 1). And we got a very precise\ndescription of those extensions in the case when $\\Phi_n$ was\nirreducible, for instance, over $\\mathbb{Q}$.\n\nWe have seen (see theorem \\ref{thm:lec6_3}) that\n$\\mathbb{Q}\\left(\\zeta_n\\right)$ is a \\mynameref{def:galoisextension} of\n\\mynameref{def:galoisgroup} $\\left(\\mathbb{Z}/n\\mathbb{Z}\\right)^\\times$\n(see example \\ref{ex:multiplicativegroup}) \nwhere $\\zeta_n = e^{\\frac{2 \\pi i}{n}}$. So it acts as $g_a: \\zeta_n \\to\n\\zeta_n^a$ where $a \\in \\left(\\mathbb{Z}/n\\mathbb{Z}\\right)^\\times$\nthat can be considered as a number relatively prime to $n$: $\\left(a,\nn\\right) = 1$.\n\\footnote{\n  $\\left(\\mathbb{Z}/n\\mathbb{Z}\\right)^\\times$ consists of elements\n  which are invertible in $\\mathbb{Z}/n\\mathbb{Z}$. The numbers\n  which are prime to $n$ are invertible.\n}\n\nLets consider several examples\n\n\\begin{example}[$n=8$]\n  Lets consider $n = 8$. In the case\n  \\[\n  \\left|\\left(\\mathbb{Z}/8\\mathbb{Z}\\right)^\\times\\right| = 4\n  \\]\n  i.e. the group has 4 elements there are\n  \\[\n  \\left(\\mathbb{Z}/8\\mathbb{Z}\\right)^\\times =\n  \\left\\{\n  1,3,5,7\n  \\right\\}.\n  \\]\n  So our Galois group also has 4 elements\n  \\footnote{\n    There is a well known \\mynameref{def:v4} $V_4$ -\n    the only non-cyclic group of order 4 (really there are 2 groups of\n    order 4: the first one is the Klein four group, the second one is\n    the cyclic group of order 4). We will also see the group when we\n    will investigate the solvability of group $S_4$ at example\n    \\ref{ex:lec8_s4}. \n  }:\n  \\[\n  Gal: \\left\\{\n  id, \\zeta_8 \\to \\zeta_8^3,\n  \\zeta_8 \\to \\zeta_8^5, \\zeta_8 \\to \\zeta_8^7\n  \\right\\} =\n  \\left\\{\n  id, \\sigma_3, \\sigma_5, \\sigma_7\n  \\right\\}.\n  \\]\n  We can note that $\\sigma_7 = \\zeta_8 \\to \\zeta_8^7$ is something\n  very simple - it is complex conjugation:\n  $\\sigma_7 = \\zeta_8 \\to \\bar{\\zeta}_8$. It's\n  \\mynameref{def:fixedfield} $\\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_7}$\n  is determined by the following expression\n  \\footnote{\n    First of all by the \\mynameref{thm:galoiscorrespondence} for\n    any normal subgroup of the \\mynameref{def:galoisgroup} ($V_4$ in our\n    case) there exists a sub-extension that is fixed by the normal\n    sub-group. For our $V_4$ (see \\mynameref{def:v4}) we have 3 normal\n    subgroups: \n    $\\{id, \\sigma_3\\}, \\{id, \\sigma_5\\}, \\{id, \\sigma_7\\}$. Lets\n    consider the last one i.e. lets find the extension that corresponds\n    to $\\{id, \\sigma_7\\}$. The extension has the following form (we\n    are using triviality of $id$: $L^{id} = L$)\n    \\[\n    \\mathbb{Q}\\left(\\zeta_8\\right)^{\\{id, \\sigma_7\\}} =\n    \\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_7}\n    \\]\n\n    To calculate $\\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_7}$ we have\n    to find a \\mynameref{ex:lec5_primitiveelement} $\\nu$ such\n    that $\\nu \\notin \\mathbb{Q}$, $\\nu \\in\n    \\mathbb{Q}\\left(\\zeta_8\\right)$ and $\\sigma_7\\left(\\nu\\right) =\n    \\nu$ (i.e. $\\sigma_7$ fixes $\\mathbb{Q}\\left(\\nu\\right)$).\n    Using the fact that $\\bar{\\zeta}_8 = \\zeta_8^7$, it can\n    be easy to check that\n    \\begin{eqnarray}\n      \\sigma_7\\left(\\zeta_8 + \\bar{\\zeta}_8\\right) =\n      \\sigma_7\\left(\\zeta_8 + \\zeta_8^7\\right) =\n      \\nonumber \\\\\n      =\n      \\zeta_8^7 + \\zeta_8^{49} =\n      \\zeta_8^7 + \\zeta_8^{6 \\cdot 8 + 1} =\n      \\zeta_8^7 + \\zeta_8 = \\bar{\\zeta}_8 + \\zeta_8,\n      \\nonumber\n    \\end{eqnarray}\n    i.e. we can take $\\nu = \\zeta_8 + \\bar{\\zeta}_8$ as an element\n    that generates the required extension.\n  }\n  \\[\n  \\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_7} =\n  \\mathbb{Q}\\left(\\zeta_8\\right) \\cap \\mathbb{R} =\n  \\mathbb{Q}\\left(\\zeta_8 + \\bar{\\zeta}_8\\right) =\n  \\mathbb{Q}\\left(\\sqrt{2}\\right)\n  \\]\n  i.e. there is a quadratic extension.\n  \\footnote{\n    In the expression we used the following fact\n    \\[\n    \\mathbb{Q}\\left(\\zeta_8\\right) \\cap \\mathbb{R} =\n    \\mathbb{Q}\\left(Re\\left(\\zeta_8\\right)\\right) =\n    \\mathbb{Q}\\left(\\zeta_8 + \\bar{\\zeta}_8\\right).\n    \\]\n  }\n\n\n  Our Galois group has 3 subgroups of order 2 so we have 3 quadratic\n  sub-extensions. One o them we have already found\n  ($\\mathbb{Q}\\left(\\sqrt{2}\\right)$) lets find 2 others.\n  \\footnote{\n    The following equations were used\n    \\[\n    \\sigma_3\\left(\\zeta_8 + \\zeta_8^3\\right) =\n    \\zeta_8^3 + \\zeta_8^9 = \\zeta_8^3 + \\zeta_8\n    \\]\n    and\n    \\[\n    \\sigma_5\\left(\\zeta_8 \\cdot \\zeta_8^5\\right) =\n    \\zeta_8^5 \\cdot \\zeta_8^{25} =\n    \\zeta_8^5 \\cdot \\zeta_8^{3 \\cdot 8 + 1} =\n    \\zeta_8^5 \\cdot \\zeta_8.  \n    \\]\n  }\n  \\[\n  \\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_3} =\n  \\mathbb{Q}\\left(\\zeta_8 + \\zeta_8^3\\right) =\n  \\mathbb{Q}\\left(i \\sqrt{2}\\right).\n  \\]\n  and finally (with note $\\zeta_8^5 = - \\zeta_8, \\zeta_8^6 = -i$)\n  \\footnote{\n    we cannot choose $\\zeta_8 + \\zeta_8^5 = 0$ and have chosen\n    $\\zeta_8 \\cdot \\zeta_8^5$ instead of it.\n  }\n  \\[\n  \\mathbb{Q}\\left(\\zeta_8\\right)^{\\sigma_5} =\n  \\mathbb{Q}\\left(\\zeta_8 \\cdot \\zeta_8^5\\right) =\n  \\mathbb{Q}\\left(\\zeta_8^6\\right) =\n  \\mathbb{Q}\\left(i\\right).\n  \\]\n  \\label{ex:lec7_cyclotomic8}\n\\end{example}\n\n\\begin{example}[$n=5$]\n  $\\mathbb{Q}\\left(\\zeta_5\\right)$ where $\\zeta_5 = e^{\\frac{2 \\pi\n      i}{5}}$. The \\mynameref{def:galoisgroup} is the following:\n  \\[\n  Gal \\cong \\left(\\mathbb{Z}/5\\mathbb{Z}\\right)^\\times\n  \\]\n  that is a \\mynameref{def:cyclicgroup} of order 4.\n  \\footnote{\n    As it was mentioned above there are only 2 finite group of order\n    4. The first one $V_4$ (see \\mynameref{def:v4}) was considered at example\n    \\ref{ex:lec7_cyclotomic8}. There is the second one that isomorphic\n    to the cyclic group of order 4:\n    \\[\n    \\left(\\mathbb{Z}/5\\mathbb{Z}\\right)^\\times =\n    \\left\\{ 1,2,3,4\n    \\right\\}\n    \\]\n  }\n  It is generated by\n  $\\zeta_5 \\to \\zeta_5^2$\n  \\footnote{\n    $Gal = \\left<\\zeta_5\\right>$ and the group action on an element is\n    just a multiplication by $\\zeta_5$ i.e.\n    $id \\to \\zeta_5, \\zeta_5 \\to \\zeta_5^2, \\zeta_5^2 \\to \\zeta_5^3,\n    \\zeta_5^3 \\to \\zeta_5^4, \\zeta_5^4 \\to id$\n  }\n  and it has only one\n  \\mynameref{def:propersubgroup} $\\cong \\mathbb{Z}/2\\mathbb{Z}$\n  (see theorem \\ref{thm:subgroupofcyclicgroup})\n  so our\n  field $\\mathbb{Q}\\left(\\zeta_5\\right)$\n  has only one sub-field different from $\\mathbb{Q}$ of course and\n  this going to be a real part all of the complex conjugation which\n  are part of Galois group. Now this is the same as the real part\n  \\(\\mathbb{Q}\\left(\\zeta_5\\right) \\cap \\mathbb{R} =\n  \\mathbb{Q}\\left(\\zeta_5 + \\bar{\\zeta}_5\\right) =\n  \\mathbb{Q}\\left(cos \\frac{2 \\pi}{5}\\right)\\).\n\\end{example}\nSo these were the examples of cyclotomic extensions of $\\mathbb{Q}$\nand of course the picture is exactly the same as long as the\ncyclotomic polynomial is irreducible. If it is not reducible, which\ncan happen as we have seen, the Galois group becomes smaller.\n\n\\section{Kummer extensions}\n\\label{sec:kummerextension}\n\nConsider a field $K$ such that the\n\\mynameref{def:fieldcharacteristic} of $K$ is prime to \na certain number $n$: $\\left(char(K), n\\right) = 1$\n\\footnote{\n  case $char(K) = 0$ is also included because it is used only one time\n  to prove separability (see note\n  \\ref{note:lec7_kummer_extension_char_zero}) \n}\nand such that $X^n\n- 1$ splits in $K$. So $K$ contains all roots of unity. Consider an\nelement $a$ of $K$ : $a \\in K$ and let $\\alpha = \\sqrt[n]{a}$ (i.e. a\nroot of $X^n - a$). Take\n\\begin{equation}\n  d = \\min{\\left\\{ i \\mid \\alpha^i \\in\n    K\\right\\}}.\n  \\label{eq:lec7_d}\n\\end{equation}\n\n\\begin{proposition}\n  $d \\mid n$, minimal polynomial of $\\alpha$ is $X^d - \\alpha^d$ and\n  $K\\left(\\alpha\\right)$ is a \\mynameref{def:galoisextension} with\n  cyclic \\mynameref{def:galoisgroup} of order $d$.\n  \\label{prop:lec7_1}\n  \\begin{proof}\n    It's clear that $K\\left(\\alpha\\right)$ is Galois because all the\n    n-th roots of unity are in $K$. So $K\\left(\\alpha\\right)$\n    contains all roots of $X^n - a$.\n    \\footnote{\n      Consider $\\alpha_k = \\alpha \\zeta^k$ where\n      $k = 0,1, \\dots, n - 1$. All such $\\alpha_k$ are roots of\n      $X^n - a$ because\n      \\[\n      \\alpha_k^n - a = \\alpha^n \\left(\\zeta^n\\right)^k - a = a - a =0.\n      \\]\n      We also have that $\\forall k_1 \\ne k_2: \\alpha_{k_1} \\ne\n      \\alpha_{k_2}$ because $\\zeta^{k_1} \\ne \\zeta^{k_2}$. Therefore\n      we have $n$ distinct roots i.e. all roots are in\n      $K\\left(\\alpha\\right)$\n    }\n    Therefore $K\\left(\\alpha\\right)$\n    is a splitting field of $X^n - a$ thus it's\n    normal. The extension is also separable because\n    $\\left(char(K), n\\right) = 1$.    \n    \\footnote{\n      If $P_n = X^n - a$ then $P_n' = n X^{n-1} \\ne 0$ as soon as\n      $\\left(char(K), n\\right) = 1$ and as result $(P_n, P_n') = 1$\n      and $P_n$ does not have multiple roots and therefore it is\n      separable. As result the extension $K\\left(\\alpha\\right)$ is\n      also separable.\n\n      The case $char(K) = 0$ is obvious because such extensions are\n      always separable (see section\n      \\ref{sec:lec3_separable_elements}).\n      \\label{note:lec7_kummer_extension_char_zero}\n    }\n    Thus $K\\left(\\alpha\\right)$ is \\mynameref{def:galoisextension}.\n\n    Lets define a \\mynameref{def:homomorphism}\n    $f: Gal\\left(K\\left(\\alpha\\right)/K\\right) \\xrightarrow[g \\to\n      \\frac{g\\left(\\alpha\\right)}{\\alpha}]{} \\mu_n$. This is correct\n    because $g$ sends $\\alpha$ to another root of $X^n - a$ thus the\n    quotient $\\frac{g\\left(\\alpha\\right)}{\\alpha}$ is a root of unity:\n    \\footnote{\n      $g^n\\left(\\alpha\\right) - \\alpha^n =\n      g^n\\left(\\alpha\\right) - a = 0$\n    }\n    \\[\n    \\left(\\frac{g\\left(\\alpha\\right)}{\\alpha}\\right)^n = 1.\n    \\]\n    The homomorphism $f$ is \\mynameref{def:injection} because\n    $g\\left(\\alpha\\right)$ determines $g$.\n    \\footnote{\n      If we have $g_1 \\ne g_2$ then\n      $g_1\\left(\\alpha\\right) \\ne g_2\\left(\\alpha\\right)$ because\n      in the case $g_1\\left(\\alpha\\right)$ and\n      $g_2\\left(\\alpha\\right)$ are 2 different roots of $X^n - a$.\n      As result the homomorphism $f$ is \\mynameref{def:injection}.\n    }\n    What's the image? It should\n    be a \\mynameref{def:subgroup} of a \\mynameref{def:cyclicgroup} $\\mu_n$\n    but the subgroup should be also cyclic. \n    \\footnote{\n      see \\mynameref{thm:fundamentaltheoremofcyclicgroup}\n    }\n    Let $\\delta$ is the order of the image and we want to show that\n    $\\delta = d$. Consider\n    $g\\left(\\alpha^\\delta\\right) = f\\left(g\\right)^\\delta \\cdot\n    \\alpha^\\delta = \\alpha^\\delta$ because $f\\left(g\\right)$ is a root\n    of 1 ($f\\left(g\\right) = \\sqrt[\\delta]{1}$).\n    \\footnote{\n      Using $g\\left(\\alpha\\right)g\\left(\\alpha\\right) = g\\left(\\alpha\n      \\cdot \\alpha \\right) = g\\left(\\alpha^2\\right)$:\n      \\begin{eqnarray}\n        f^\\delta\\left(g\\right) =\n        \\frac{g^\\delta\\left(\\alpha\\right)}{\\alpha^\\delta} =\n        \\frac{g\\left(\\alpha^\\delta\\right)}{\\alpha^\\delta}.\n        \\nonumber\n      \\end{eqnarray}      \n    }\n    Thus $\\alpha^\\delta\n    \\in K$ ( see (\\ref{eq:lec5_2})). And $\\alpha^i \\notin K$ for $i < \\delta$ since otherwise\n    $\\deg P_{min}\\left(\\alpha, K\\right) = i < \\delta$. But this is\n    impossible because\n    \\[\n    \\left[K\\left(\\alpha\\right):K\\right] =\n    \\left|Gal\\left(K\\left(\\alpha\\right)/K\\right)\\right| = \\delta.\n    \\]\n    Thus only possible option is $d = \\delta$.\n    \\footnote{\n      $d$ was chosen accordingly (\\ref{eq:lec7_d}) and therefore\n      $\\delta \\ge d$.\n    }\n    Thus\n    $P_{min}\\left(\\alpha, K\\right) = X^d - \\alpha^d$.\n  \\end{proof}\n\\end{proposition}\n\n\\begin{proposition}\n  And conversely (to \\ref{prop:lec7_1}) for all cyclic extension of\n  degree $n$ such that $\\left(char(K), n\\right) = 1$ is generated by\n  $\\sqrt[n]{a}$ for some $a \\in K$.\n  \\begin{proof}\n    Consider $L$ is an extension of $K$.\n    $Gal\\left(L/K\\right) = \\left<\\sigma\\right>$ then we have\n    $\\sigma^n = id$. Linear algebra says that $\\sigma$ is\n    \\mynameref{def:diagonalizable_map}.\n    \\footnote{\n      Apply theorem \\ref{thm:diagonalizable_matrix} to the\n      diagonalizable $\\sigma^n = id$. \n      Really a map is diagonalizable if it has $n$ distinct\n      eigenvalues (see theorem\n      \\ref{thm:diagonalizable_map_eigenvalues}). This fact will be\n      proved below. \n    }\n    Now, let us show that all eigenspaces have dimension 1. Indeed if\n    $x,y$ are in the same \\mynameref{def:eigenspace} then\n    $\\sigma\\left(\\frac{x}{y}\\right) = \\frac{x}{y}$\n    \\footnote{\n      $L^{\\left<\\sigma\\right>} = K$ i.e. $L^{\\sigma} = K$.\n    }\n    because $x$ and $y$\n    are multiplied by the same number.\n    Therefore $\\frac{x}{y} \\in\n    K$. And this is exactly means that dimension of the eigenspace is\n    1, $x,y$ are proportional over $K$.\n    \\footnote{\n      I.e. if $\\mathcal{L}$ is the eigenspace then we have that\n      $\\exists x \\in \\mathcal{L}$ such that $\\forall y \\in\n      \\mathcal{L}: y = k x$, where $k \\in K$. This exactly means that\n      $\\dim \\mathcal{L} = 1$\n    }\n    Thus all roots of 1 are eigenvalues of $\\sigma$.\n    \\footnote{\n      Let $x$ - eigenvector of $\\sigma$ and $\\nu$ is the\n      eigenvalue. We have $\\sigma\\left(x\\right) = \\nu x$, using\n      $\\sigma^n = id$ and $\\sigma \\circ \\sigma(x) = \\sigma(\\nu x) =\n      \\nu^2 x$, one can get $\\sigma^n\\left(x\\right) = \\nu^n x\n      = id(x) = x$. Thus $\\nu^n = 1$ i.e. $\\nu$ is a root of unity.\n    }\n    Then take\n    $\\alpha$ such that $\\sigma\\left(\\alpha\\right) = \\zeta \\alpha$\n    where $\\zeta$ is a \\mynameref{def:primitiverootsofunity}. Then\n    $\\left<\\sigma\\right>$ - orbit of $\\alpha$ has $n$ elements\n    therefore $\\left[K\\left(\\alpha\\right):K\\right] = n$ (see\n    explanation below) and $\\alpha^n\n    \\in K$ since $\\sigma\\left(\\alpha^n\\right) = \\zeta^n \\cdot \\alpha^n\n    = \\alpha^n$. We see that $\\alpha$ is a root of $X^n - a$. This is\n    irreducible by degree reason.\n\n    Maybe I should have said here, why it follows from the formula,\n    $\\left<\\sigma\\right>$ - orbit of $\\alpha$ has $n$ elements\n    that the degree of the extension is exactly $n$. While this is\n    easy because either degree of the extension was less than $n$,\n    then also, $\\alpha$ would have to be fixed by some non-trivial\n    subgroup of Galois group by Galois correspondence. And then its\n    orbit would have less than $n$ elements.\n    \\footnote{\n      If we have $K \\subset K\\left(\\alpha\\right) \\subset L$ and\n      $\\left<\\sigma\\right>$ is a \\mynameref{def:galoisgroup} $L/K$ and\n      $\\left[K\\left(\\alpha\\right):\\right] = d < n$ then by\n      \\mynameref{thm:galoiscorrespondence} there exists a subgroup\n      $H \\subset \\left<\\sigma\\right>$\n      (cyclic as soon as  $\\left<\\sigma\\right>$) that fixes the\n      $K\\left(\\alpha\\right)$ and especially $\\forall h \\in H:\n      h\\left(\\alpha\\right) = \\alpha$\n      therefore\n      $\\left|\\sigma^k\\left(\\alpha\\right)\\right| < n$ i.e. the orbit\n      contains less than $n$ elements.\n\n      Another explanation as follows. If\n      $\\left[K\\left(\\alpha\\right):\\right] = d < n$ then\n      $P_{min}\\left(\\alpha, K\\right)$ has $d$ roots and the orbit\n      $Orb\\left(\\alpha\\right)$ consists of roots of\n      $P_{min}\\left(\\alpha, K\\right)$ and the number of roots is\n      $d < n$.\n    }\n  \\end{proof}\n  \\label{prop:lec7_2}\n\\end{proposition}\n  \n\\section{Artin-Schreier extensions}\n\n\\begin{definition}[Artin-Schreier extension]\n  Let $L$ is an extension of a field $K$ such that $char K = p$, where $p$\n  is a prime number. If degree of the extension $n=\\left[L:K\\right]$\n  is equal to $p$, i.e. $n = char K$ then the extension is called  as\n  Artin-Schreier extension. \n  \\label{def:srtinschreierextension}\n\\end{definition}\n\n\\begin{definition}[Cyclic extension]\n  The Galois extension is called cyclic extension if the corresponding\n  \\mynameref{def:galoisgroup} is cyclic.\n  \\label{def:cyclicextension}\n\\end{definition}\n\n\\begin{theorem}[Artin-Schreier]\n  \\label{thm:lec7_1}\n  Let $p = char(K)$ and let\n  $P = X^p - X - a \\in K\\left[X\\right]$. Then $P$ is irreducible or\n  splits over $K$. Let $\\alpha$ be a root. If $P$ is irreducible then\n  $K\\left(\\alpha\\right)$ is \\mynameref{def:cyclicextension} of $K$ of\n  degree $p$.\n\n  Conversely any cyclic extension of degree $p$ is like this: $L/K,\n  \\exists \\alpha \\in K$ such that $L = K\\left(\\alpha\\right)$, $\\alpha$\n  - root of $X^p - X - a$ for some $a \\in K$.\n  \\begin{proof}\n    First of all notice that roots of $P$ are $\\alpha + k$ where $k\n    \\in \\mathbb{F}_p$ ($k$ is an element of prime field).\n    \\footnote{\n      In $\\mathbb{F}_p$ we have $k^p = k$ and therefore \n      \\begin{eqnarray}\n        \\left(\\alpha + k\\right)^p -\n        \\left(\\alpha + k\\right) -a =\n        \\nonumber \\\\\n        =\\alpha^p + k^p - \\alpha -k - a =\n        \\alpha^p + k - \\alpha -k - a =\n        \\nonumber \\\\\n        =\n        \\alpha^p - \\alpha - a =0,\n        \\nonumber\n      \\end{eqnarray}\n      as soon as $\\alpha$ is a root of $X^p - X - a$.\n    }\n\n    If $P$ is irreducible then \\mynameref{def:galoisgroup} should be\n    transitive\n    \\index{Transitive group action}\n    on the roots (see remark \\ref{rem:lec5_onnormalext})  then\n    $\\exists \\sigma \\in Gal\\left(K\\left(\\alpha\\right)/K\\right)$ such that\n    $\\sigma\\left(\\alpha\\right) = \\alpha + 1$ (because roots of $P$ are\n    $\\alpha + k$). The \\mynameref{def:grouporder} for $\\sigma$ is\n    $p = \\left[K\\left(\\alpha\\right):K\\right]$\n    \\footnote{\n      \\[\n      \\sigma^p = \\sigma(\\sigma(\\sigma( \\dots ( \\sigma(\\alpha) ) \\dots\n      ))) = \\alpha + p = \\alpha\n      \\]\n      i.e. $\\sigma^p = id$ and order of $\\left<\\sigma\\right>$ is $p$.\n    }\n    so the $\\sigma$ must\n    generate the \\mynameref{def:galoisgroup}:\n    $Gal\\left(K\\left(\\alpha\\right)/K\\right) = \\left<\\sigma\\right>$.\n\n    We have to show that if $P$ is not irreducible then $P$ splits\n    i.e. $\\alpha \\in K$. Leave it for an exercise\n    \\footnote{\n      Let $\\alpha$ is a root then we can get $p$ different roots as\n      $\\alpha + k$ where $k \\in \\mathbb{F}_p$. Suppose that $\\alpha\n      \\notin K$ and $Q$ is a\n      factor of $P$ (it should exist as soon as $P$ is reducible). $Q$\n      splits in $K\\left(\\alpha\\right)$ as soon as $P$ splits there and\n      its factors have the form $X - \\left(\\alpha - i\\right)$.\n      Let $d = \\deg Q$, i.e.\n      \\[\n      Q = \\prod_{i}\\left(X - \\left(\\alpha - i\\right)\\right) = X^d +\n      a_1 X^{d-1} + \\dots + a_d.\n      \\]\n      Consider the coefficient $a_1$. It should have the form\n      $a_1 = \\sum_{i} \\left(\\alpha - i\\right) = d \\alpha -j$ (where\n      $i$ is taken \n      from $d$ factors of $Q$ and $\\sum_{i} i = j$ - another\n      integer). $a_1 \\in K$ (and as result $Q \\in K\\left[X\\right]$)\n      only if $d = 0 \\mod p$. Therefore $P$ has no nontrivial\n      factors that is in the contradiction with statement that $P$ is\n      reducible.\n\n      Thanks Ben Petschel for the hint.\n    }\n\n    Now we will prove the converse statement. Let $L$ is a\n    \\mynameref{def:cyclicextension} of $K$ of degree $p$. We want to\n    find $\\alpha$ such that $\\sigma\\left(\\alpha\\right) = \\alpha + 1$\n    where $\\sigma$ is a generator of $Gal\\left(L/K\\right)$ (we know\n    that the Galois group is cyclic i.e. must have the following form\n    $Gal\\left(L/K\\right) = \\left<\\sigma\\right>$).\n\n    Set $f = \\sigma -id$, $K = \\ker f$\n    \\footnote{\n      this is because\n      $\\forall x \\in K: \\sigma\\left(x\\right) = x$ (see\n      (\\ref{eq:lec5_2})).\n    }\n    and the \\mynameref{def:rank} $rg f = p -1$.\n    \\footnote{\n      In lectures we can hear about range (\\mynameref{def:image}) not a\n      \\mynameref{def:rank} but by future content we spoke about the rank\n      but not about range (image). In any way the equation $rg f = p\n      -1$ requires some explanation. As soon as $f^{p-1} \\ne 0$\n      $\\exists x \\in L$ such that $f^{p-1}\\left(x\\right) \\ne\n      0$. Therefore $f^{k}\\left(x\\right) \\ne 0$  for all $k < p - 1$\n      because in other case\n      \\[\n      f^{p-1}\\left(x\\right) = f\\left( \\dots f\\left(\n      f^k\\left(x\\right) \\right) \\dots \\right) =\n      f\\left( \\dots f\\left( 0 \\right) \\dots \\right) =\n      0.\n      \\]\n      Lets show that $\\left(f\\left(x\\right), f^2\\left(x\\right)\\dots,\n      f^{p-1}\\left(x\\right) \\right)$ is linearly independent.\n      For $k \\in K, x \\in L$ we can get\n      \\[\n      f\\left(k \\cdot x\\right) =\n      \\sigma\\left(k \\cdot x\\right) - k \\cdot x =\n      \\sigma\\left(k\\right) \\cdot \\sigma\\left(x\\right) -\n      k \\cdot x = k \\cdot \\sigma\\left(x\\right) - k \\cdot x =\n      k \\cdot f\\left(x\\right).\n      \\]\n      Thus for $k_i \\in K$ such that:\n      \\[\n      \\sum_{i=1}^{p-1} k_i f^i\\left(x\\right) = 0\n      \\]\n      applying $f^{p-1}$ one can get that $k_1 = 0$, applying\n      $f^{p-2}$ gives us $k_2 = 0$. Continue the way we get that all\n      $k_i = 0$. That proves the linear independence. Therefore\n      $rg\\left(f\\right) \\ge p - 1$. The vector\n      $y = \\left(f^{p-1}\\left(x\\right), f^{p-1}\\left(x\\right)\\dots,\n      f^{p-1}\\left(x\\right) \\right)$ is not zero but $f(y) = 0$\n      therefore $y \\in \\ker f$. This means that $\\dim{\\ker f} \\ge\n      1$. Using \\mynameref{thm:ranknullity} one can conclude that only\n      possible choice there is $\\dim{\\ker f} = 1$ and\n      $rg\\left(f\\right) = p - 1$. \n    }\n    We have \n    $\\left(\\sigma - id\\right)^p = 0$\n    \\footnote{\n      In $\\mathbb{F}_p$ we have\n      \\[\n      \\left(\\sigma - id\\right)^p = \\sigma^p - id = 0\n      \\]\n      as soon as $\\left<\\sigma\\right>$ has order $p$.      \n    }\n    so the \\mynameref{def:kernel} must\n    be included into \\mynameref{def:image}:\n    $K = \\ker f \\subset \\Ima f$\n    because otherwise $L = \\ker f \\oplus \\Ima f$ ($L$ is a\n    direct sum\n    \\footnote{\n      see also definition \\ref{def:directsummodules} and example\n      \\ref{ex:directsummodules} \n    }\n    of \n    kernel and image) and $f^k$ is never zero (but we have $f^p = 0$)\n    \\footnote{\n      As soon as $f \\ne 0$ exists $x \\in L$ such that\n      $y = f^{p-1}\\left(x\\right) \\ne 0$ but\n      $f\\left(y\\right) = f^p\\left(x\\right) = 0$,\n      therefore $y \\in \\ker f$. Using the fact that $\\dim{\\ker f} = 1$\n      (follows from $rg(f) = p - 1$ and \\mynameref{thm:ranknullity}) and\n      $y \\in \\Ima f$ ($y = f\\left(f^{p-2}\\left(x\\right)\\right)$) one\n      can conclude that  the \\mynameref{def:kernel} must\n      be included into \\mynameref{def:image}.\n    }.\n\n    So as soon as $K$ is in the image of $f$ then $\\exists \\alpha \\in L$\n    such that $f\\left(\\alpha\\right) = 1$\n    \\footnote{\n      This is because $1 \\in K$ but\n      $K \\subset \\ker\\left(f\\right) \\subset \\Ima\\left(f\\right)$ therefore\n      $1 \\in Im\\left(f\\right)$.\n    }\n    but this means that\n    $\\sigma\\left(\\alpha\\right) = \\alpha + 1$. Now consider\n    $\\sigma\\left(\\alpha^p - \\alpha\\right) =\n    \\left(\\alpha + 1\\right)^p - \\left(\\alpha + 1\\right) = \\alpha^p -\n    \\alpha$ (because we are in the field of\n    \\mynameref{def:fieldcharacteristic} $p$). This \n    means that $\\alpha^p - \\alpha \\in K$ because the field is fixed by\n    Galois group (see (\\ref{eq:lec5_2})). So\n    $\\alpha^p - \\alpha =  a \\in K$ and $\\alpha$ is a root of $X^p - X\n    - a$ and this finished the proof of the theorem.\n  \\end{proof}\n\\end{theorem}\n\n\n\\begin{myremark}\n  Theorem \\ref{thm:lec7_1} shows that\n  \\mynameref{def:srtinschreierextension} is a\n  \\mynameref{def:cyclicextension} as well as\n  \\mynameref{sec:kummerextension}. The different between both is in\n  relation  between $n$ and $p$.  \\mynameref{sec:kummerextension}\n  plays a role in solvability for fields over\n  $\\mathbb{Q}$ (see \\mynameref{def:solvableextension}),\n  \\mynameref{def:srtinschreierextension} plays the same \n  role for finite fields.\n\\end{myremark}\n\n\\section{Composite extensions. Properties}\n\n\\begin{definition}[Composite extension]\n  Let $L_1$ and $L_2$ are extensions of $K$ both contained in some\n  extension $L$ (for instance the \\mynameref{def:algebraicclosure}\n  $\\bar{K}$). The composite extension $L_1 L_2$ is the extension they\n  generate: $L_1 L_2 = L_2 L_1 = K\\left(L_1 \\cup L_2\\right)$. I.e. the\n  composite extension is the smallest extension that contains both\n  $L_1$ and $L_2$.\n  \\label{def:compositeextension}\n\\end{definition}\n\nAnother way to view this: consider the tensor product $L_1 \\otimes_K\nL_2$ - there is a $K$-algebra. By \\mynameref{def:universalproperty}\nthere is a map from the tensor product to $L$:\n\\(\nj: L_1 \\otimes_K L_2 \\to L  \n\\)\nsuch that $j\\left(l_1 \\otimes l_2\\right) = l_1 l_2$\n\\footnote{\n  By the \\mynameref{def:universalproperty} $j$ is a \n  \\mynameref{def:fieldhomomorphism} as soon as\n  $L_1, L_2, L_1 \\otimes_K L_2$ are the fields (see also theorem\n  \\ref{thm:lec7_2}), but by lemma \n  \\mynameref{lem:lec1_homomorphism_is_injection} the homomorphism is\n  injection.\n}\n\n  \\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]\n    \\matrix (m) [matrix of math nodes, row sep=3em,\n      column sep=2.5em, text height=1.5ex, text depth=0.25ex]\n            { L_1 \\times L_2 & & L \\\\\n              & L_1 \\otimes_K L_2 & \\\\ };\n            %\\draw[double,double distance=5pt] (m-1-1) – (m-1-3);\n            \\path[->]\n            (m-1-1) edge node[auto] {$ f: (l_1,l_2) \\to l_1 l_2 $} (m-1-3)\n            edge node[auto] {$ \\phi $} (m-2-2)\n            (m-2-2) edge node[auto] {$ \\tilde{f} = j $} (m-1-3);\n  \\end{tikzpicture}\n\nThe \n\\mynameref{def:image} $\\Ima j$ is a sub-algebra of $L$. If $L$ is\nalgebraic then any sub algebra is a sub field (see proposition\n\\ref{prop:lec1_algebraicsubalgebra}) and this \nis exactly the field generated by $L_1 L_2$. In general we can take\nits fraction field (to obtain a field from a ring (an algebra)) but in\nour case, as it was mentioned above, as soon as $L$ is algebraic then\n$L_{1,2}$ are fields.\n\n\\begin{property}\n  If $L_1$ is separable (pure inseparable, normal, finite of\n  degree $n$) over $K$ then $L_1 L_2$ is also separable (pure\n  inseparable, normal, finite of degree $ \\le n$) over $L_2$\n  \\begin{proof}\n    Let $x \\in L_1$ ($L_1 L_2$ is generated by $L_1$ over $L_2$)\n    \\footnote{\n      We have $K \\subset L_2 \\subset L_1 L_2$ as the case there\n    }\n    then it's minimal polynomial $P_{min}\\left(x, L_2\\right)$ is a\n    divisor of $P_{min}\\left(x, K\\right)$ in\n    $L_2\\left[X\\right]$ (see proposition \\ref{prop:lec1_algebraic}). \n    Therefore $P_{min}\\left(x, L_2\\right)$ has a\n    degree $\\le n$ where $n$ \n    is degree of $P_{min}\\left(x, K\\right)$.\n\n    So if $P_{min}\\left(x, K\\right)$ is separable (pure inseparable)\n    then $P_{min}\\left(x, L_2\\right)$ is separable (pure inseparable).\n    \\footnote{\n      From proposition \\ref{prop:lec1_algebraic}) we know that\n      $P_{min}\\left(x, L_2\\right)$ is a divisor of $P_{min}\\left(x,\n      K\\right)$. Therefore if $P_{min}\\left(x, K\\right)$ does not have\n      multiply roots then $P_{min}\\left(x, L_2\\right)$ (its divisor)\n      will also have only non-multiply roots.\n\n      The inseparability is obvious because if the\n      $P_{min}\\left(x,K\\right)$ has only one root the same will be the\n      truth for $P_{min}\\left(x, L\\right)$.\n    }\n\n    The same is true for splitting so the normality is preserved.\n    \\footnote{\n      i.e. the polynomial splits in $L_2$ if it splits in $K \\supset L_2$\n    }\n\n    About dimensions (``finite extension of degree'' in the property\n    formulation). By the \\mynameref{thm:basechange}\n    \\footnote{\n      From \\mynameref{thm:basechange} one can get\n      \\[\n      \\left|Hom_K\\left(L_1, \\bar{K}\\right)\\right| =\n      \\left|Hom_{L_2}\\left(L_2 \\otimes_K L_1, \\bar{K}\\right)\\right|\n      \\]\n      But proposition \\ref{prop:lec3_2}\n      says that\n      \\[\n      \\left|Hom_K\\left(L_1, \\bar{K}\\right)\\right| =\n      \\deg\\left(P_{min}\\left(x,K\\right)\\right) =\n      \\left[L_1 : K\\right] = \n      \\dim_K\\left(L_1\\right)\n      \\]\n      and\n      \\[\n      \\left|Hom_{L_2}\\left(L_2 \\otimes_K L_1, \\bar{K}\\right)\\right| =\n      \\left[L_2 \\otimes_K L_1 : L_2\\right] = \n      \\dim_{L_2}\\left(L_1 \\otimes_K L_2 \\right)\n      \\]\n    }: \n    \\[\n    \\dim_K L_1 = \\dim_{L_2}\\left(L_1 \\otimes_K L_2\\right)\n    \\]\n    and as soon as $L_1 L_2$ is the $\\Ima j$:\n    \\footnote{\n      Using \\mynameref{thm:ranknullity} one can conclude that for\n      $j: L_1 \\otimes_K L_2 \\to L_1L_2$,\n      $\\dim{\\Ima j} \\le \\dim{L_1\\otimes_K L_2}$\n      (the equal sign is when $\\dim{\\ker{j}} = 0$).\n    }\n    \\[\n    \\dim_{L_2}\\left(L_1 \\otimes_K L_2\\right) \\ge\n    \\dim_{L_2}\\left(L_1 L_2\\right)\n    \\]\n    i.e.\n    \\[\n    \\dim_{L_2}\\left(L_1 L_2\\right) \\le \\dim_K L_1 = n.\n    \\]\n  \\end{proof}\n  \\label{property:lec7_1}\n\\end{property}\n\n\\begin{property}\n  If $L_1, L_2$ are separable (pure inseparable, normal, finite of\n  degree $n$ and $m$) over $K$ then $L_1 L_2$ is also separable (pure\n  inseparable, normal, finite of degree $ \\le n m $) over $K$\n  \\begin{proof}\n    We have the following towers:\n    \\[\n    K \\hookrightarrow L_1 \\hookrightarrow L_1 L_2\n    \\]\n    and all properties except normality are preserved in the towers\n    so\n    follows from property \\ref{property:lec7_1}.\n    \\footnote{\n      From property \\ref{property:lec7_1} follows that if $L_1$ is\n      separable over $K$ then $L_1 L_2$ is separable over \n      $L_2$. If $L_2$ is separable over $K$ then theorem\n      \\ref{thm:lec3_3} about separability says the $L_1 L_2$ is\n      separable over $K$ as soon as $K \\subset L_2 \\subset L_1 L_2$.\n\n      About degrees: if $n = \\left[L_1 : K\\right]$ and\n      $m = \\left[L_2 : K\\right]$ then from property\n      \\ref{property:lec7_1} follows that\n      $\\left[L_1 L_2 : L_2\\right] \\le n$. Using theorem\n      \\ref{thm:mulformuladegrees}\n      $\\left[L_1 L_2 : K\\right]  = \\left[L_1 L_2 : L_2\\right] \\left[\n        L_2 : K\\right]\\le nm$.\n    }\n\n    \n    Normality is obvious because if $L_1$ is a splitting field of the\n    family polynomials $\\left\\{P_i\\right\\}_{i \\in I}$\n    and $L_2$ is a splitting field of the\n    family polynomials $\\left\\{Q_j\\right\\}_{j \\in J}$ then\n    $L_1 L_2$ is a splitting field of the union of those families\n    $\\left\\{P_i, Q_j\\right\\}_{i \\in I, j \\in J}$. So normality is\n    obviously preserved.  \n  \\end{proof}\n  \\label{property:lec7_2}\n\\end{property}\n\n\n\\section{Linearly disjoint extensions. Examples}\n\n\\begin{theorem}\n  \\label{thm:lec7_2}\n  The following statements are equivalent (for algebraic extensions)\n  \\begin{enumerate}\n  \\item $L_1 \\otimes_K L_2$ is a field \\label{thm:lec7_2_a}\n  \\item $j$ is \\mynameref{def:injection} \\label{thm:lec7_2_b}\n  \\item if we have $x_1, x_2, \\dots, x_n \\in L_1$ linearly independent\n    over $K$ then they are linearly independent\n    over $L_2$ \\label{thm:lec7_2_c}\n  \\item if we have two families: $x_1, x_2, \\dots, x_n \\in L_1$ linearly independent\n    over $K$ and  $y_1, y_2, \\dots, y_m \\in L_2$ linearly independent\n    over $K$ then $x_i y_j$ are also linearly independent over $K$\n    \\label{thm:lec7_2_d}\n  \\end{enumerate}\n  When $L_1$ finite over $K$ then all the statements are equivalent to\n  $\\left[L_1 L_2 : L_2\\right] = \\left[L_1 : K\\right]$ or in other\n  words\n  $\\left[L_1 L_2 : K\\right] = \\left[L_1 : K\\right] \\left[L_2 :\n    K\\right]$\n  \\footnote{\n    Using theorem \\ref{thm:mulformuladegrees} we have $\\left[L_1 L_2 :\n      K\\right]  = \\left[L_1 L_2 : L_2\\right] \\left[L_2 : K\\right]$.\n  }\n  \n  \\begin{definition}[Linearly disjoint extensions]\n    In the case $L_1$ and $L_2$ are called linearly disjoint extensions\n    \\label{def:linearlydisjoint}\n  \\end{definition}\n  \\begin{proof}\n    Equivalence \\ref{thm:lec7_2_a} and \\ref{thm:lec7_2_b} is clear\n    because we have that $L_1 L_2 = \\Ima j$.\n    \\footnote{\n      By the \\mynameref{def:universalproperty} $j$ is a \n      \\mynameref{def:homomorphism}, but by lemma\n      \\mynameref{lem:lec1_homomorphism_is_injection} the homomorphism is\n      injection if $L_1 \\otimes_K L_2$ is a field i.e. if the\n      homomorphism is a \\mynameref{def:fieldhomomorphism}.\n\n      If $j$ is injection then from the fact $L_1 L_2 = \\Ima j$ we can\n      conclude that for any $x \\in L_1 \\otimes_K L_2$ such that $x \\ne\n      0$ there exists\n      $y \\in L_1 \\otimes_K L_2$ such that $j(x) j(y) = 1$ as soon as\n      $L_1 L_2 = K\\left(L_1 \\cup L_2\\right)$ is a field\n      (both $L_1$ and $L_2$ are algebraic). Therefore\n      $x y = 1$ and for any non zero element of $L_1 \\otimes_K L_2$ we\n      can the the inverse one. This means that $L_1 \\otimes_K L_2$ is\n      a field.\n    }\n\n    Then \\ref{thm:lec7_2_b} implies \\ref{thm:lec7_2_c}: we have\n    $x_1 \\otimes 1, \\dots, x_n \\otimes 1$ are linearly independent\n    over $L_2$ by base change property\n    (see proposition \\ref{prop:lec4_Addon}).\n    If $j$ is injective then their images $x_1, \\dots, x_n$\n    are also linearly independent over $L_2$. This is because an\n    injective map transforms a linearly independent set of vectors\n    into a linearly independent set.\n    \\footnote{\n      Let $x_1, \\dots, x_n$ are not linearly independent over $L_2$\n      then there exists $\\alpha_1, \\dots, \\alpha_n \\in L_2$ such that\n      $\\exists \\alpha_k \\ne 0$ but $\\sum_{i=1}^n \\alpha_i x_i =\n      0$. From other side $x_i = j\\left(x_i \\otimes 1\\right)$\n      therefore $j\\left(\\sum_{i=1}^n \\alpha_i x_i \\otimes 1 \\right) =\n      0$ but $\\sum_{i=1}^n \\alpha_i x_i \\otimes 1 \\ne 0$ as soon as\n      $x_1 \\otimes 1, \\dots, x_n \\otimes 1$ are linearly independent\n      over $L_2$. Therefore we just got a contradiction: $j$ cannot be\n      injection. \n    }\n\n    \\ref{thm:lec7_2_c} implies \\ref{thm:lec7_2_d}: if we have some\n    relation $\\sum_{i,j} a_{ij} x_i y_j = 0, a_{ij} \\in K$ then since $x_i$\n    linearly independent over $K$ one can get $\\sum_{j} a_{ij} y_j = 0$\n    but as soon as $y_j$ linearly independent we will get $a_{ij} =\n    0$.\n\n    Next \\ref{thm:lec7_2_d} implies \\ref{thm:lec7_2_b} (remember that\n    \\ref{thm:lec7_2_b} is injectivity of $j$). Take\n    $z \\in L_1 \\otimes_K L_2$ such that $j\\left(z\\right) = 0$. We have\n    $z = \\sum a_{ij} x_i \\otimes y_j$ and\n    $j\\left(z\\right) = \\sum a_{ij} x_i y_j = 0$ i.e. $a_{ij} = 0$ and\n    therefore $z = 0$. I.e. $j$ is \\mynameref{def:injection}.\n\n    The part about finite degrees follows from the 4 properties.\n    \\footnote{\n      Let $L_1$ and $L_2$ are linearly disjoint extensions over $K$\n      with finite degree: $\\left[L_1:K\\right] = n, \\left[L_2:K\\right]\n      = m$. From \\ref{thm:lec7_2_c} we can conclude that\n      $\\left[L_1 L_2:L_2\\right] = n$ and using theorem\n      \\ref{thm:mulformuladegrees} we will obtain \n      $\\left[L_1 L_2:K\\right] = \\left[L_1 L_2:L_2\\right]\n      \\left[L_2 : K\\right] = nm$.\n    }\n  \\end{proof}\n\\end{theorem}\n\n\\begin{example}\n  First of all, the extensions which have relatively prime degrees are\n  always linearly disjoint.\n\n  I.e. if $\\left[L_1 : K\\right] = n$, $\\left[L_2 : K\\right] = m$ and\n  $\\left(m, n\\right) = 1$ then $L_1$ and $L_2$ are linearly\n  disjoint. Indeed $m$ and $n$ must divide $\\left[L_1 L_2 : K\\right]\n  \\le m n$. With our conditions $\\left[L_1 L_2 : K\\right] = m n$ but\n  this is one of definition of linearly disjoint extensions\n  (see definition \\ref{def:linearlydisjoint}).\n  \\footnote{\n    The claim is the following: if $\\left(m, n\\right) = 1$ then $L_1$\n    and $L_2$ are linearly disjoint. From\n    property \\ref{property:lec7_2} $\\left[L_1 L_2 : K\\right] \\le m\n    n$. But from theorem \n    \\ref{thm:mulformuladegrees} $n \\mid \\left[L_1 L_2 : K\\right]$, as\n    soon as $K \\subset L_1 \\subset L_1 L_2$, and\n    $m \\mid \\left[L_1 L_2 : K\\right]$, as\n    soon as $K \\subset L_2 \\subset L_1 L_2$ and therefore using\n    $\\left(m, n\\right) = 1$ one can conclude that $\\left[L_1 L_2 :\n      K\\right] = nm$ and thus $L_1$  and $L_2$ are linearly\n    disjoint by last statement of theorem \\ref{thm:lec7_2}. \n  }\n\n  In particular $\\mathbb{Q}\\left(\\sqrt[5]{2}\\right)$ and\n  $\\mathbb{Q}\\left(\\sqrt[5]{1}\\right)$ are linearly disjoint\n  extensions because the degrees are\n  $\\left[\\mathbb{Q}\\left(\\sqrt[5]{2}\\right): \\mathbb{Q}\\right] = 5$\n  and\n  $\\left[\\mathbb{Q}\\left(\\sqrt[5]{1}\\right): \\mathbb{Q}\\right] = 4$.\n  \\footnote{\n    $P_{min}\\left(\\sqrt[5]{2}, \\mathbb{Q}\\right) = X^5 - 2$ and\n    $\\deg\\left(P_{min}\\left(\\sqrt[5]{2}, \\mathbb{Q}\\right)\\right) =\n    5$.\n\n    $P_{min}\\left(\\sqrt[5]{1}, \\mathbb{Q}\\right) = X^4 + X^3 + X^2 + X\n    + 1$ and\n    $\\deg\\left(P_{min}\\left(\\sqrt[5]{1}, \\mathbb{Q}\\right)\\right) =\n    4$.\n  }\n\n  From the other side with $\\sqrt[5]{1} = e^{\\frac{2 \\pi i}{5}}$ the\n  following extensions are not linearly disjoint:\n  $\\mathbb{Q}\\left(\\sqrt[5]{2}\\right)$ and\n  $\\mathbb{Q}\\left(e^{\\frac{2 \\pi i}{5}} \\cdot\n  \\sqrt[5]{2}\\right)$.\n  Indeed in both cases $L_1 L_2$ is a splitting\n  field of $X^5 - 2$ and (for the first case) $\\left[L_1 L_2 :\n    \\mathbb{Q}\\right] = 4 \\cdot 5 = 20$. In the second case both\n  $\\left[L_{1,2}:\\mathbb{Q}\\right] = 5$ and $5 \\cdot 5 \\ne 20$.\n\n   So, you see that the difference is rather subtle. Well, the obvious\n   reason in the second case is that those extensions are generated by\n   rules of the same polynomial, but, still some effort is needed to\n   formalize why this is not linearly disjoint case.\n   In particular we see that $L_1 \\cap L_2 = \\mathbb{Q}$ does not\n   imply that $L_1$ and $L_2$ are linearly disjoint over\n   $\\mathbb{Q}$. It's exactly what's happen in the second case.\n   \\label{ex:lec7_1}\n\\end{example}\n\n\\section{Linearly disjoint extensions in the Galois case}\n\n\\begin{theorem}\n  Let $L_1, L_2 \\subset \\bar{K}$ - extensions of $K$. $L_1$ is\n  \\mynameref{def:galoisextension} \n  over $K$. Let $K' = L_1 \\cap L_2$. Then $L_1 L_2$ is Galois over\n  $L_2$.\n  $Gal\\left(L_1 L_2/ L_2\\right)$ stabilizes $L_1$. $\\phi: g \\to\n  \\left.g\\right|_{L_1}$ is an injective map of\n  $Gal\\left(L_1 L_2/ L_2\\right) \\to Gal\\left(L_1/ K\\right)$ with\n  image $Gal\\left(L_1/K'\\right)$ and $L_1, L_2$ are linearly disjoint\n  over $K'$.\n  \\label{thm:lec7_3}\n  \\begin{proof}\n    The proof that $L_1 L_2$ is Galois over $L_2$ is obvious.\n    \\footnote{\n      We have $L_1$ is \\mynameref{def:galoisextension} and therefore\n      normal and separable over $K$. By property \\ref{property:lec7_1}\n      this means that $L_1 L_2$ is normal and separable over $L_2$ or in\n      other words $L_1 L_2$ is Galois over $L_2$.\n    }\n\n    The next statement is that $Gal\\left(L_1 L_2/ L_2\\right)$\n    stabilizes\n    $L_1$.\n    \\footnote{\n      I.e. $\\forall g \\in Gal\\left(L_1 L_2/ L_2\\right)$  and for\n      any $x \\in L_1$ we have $g(x) \\in L_1$ or in other words $g(L_1)\n      = L_1$ (see also definition \\ref{def:stabilizersubgroup}).\n    }\n    Let $x \\in L_1$ and $g \\in Gal\\left(L_1 L_2/\n    L_2\\right)$ then \n    $g\\left(x\\right)$ is a root of $P_{min}\\left(x, L_2\\right)$.\n    \\footnote{\n      This is because $g$ permutes roots and the image of the\n      permutation is the set of roots of the following polynomial\n      $P_{min}\\left(x, L_2\\right)$. Note that $x$ is also one of the\n      roots.  \n    }\n    It is\n    also a root of $P_{min}\\left(x, K\\right)$.\n    \\footnote{\n      This is because proposition \\ref{prop:lec1_algebraic} i.e. because\n       $P_{min}\\left(x, L_2\\right)$ divides  $P_{min}\\left(x,\n      K\\right)$ i.e. all roots of $P_{min}\\left(x, L_2\\right)$ are\n      also roots of $P_{min}\\left(x, K\\right)$.\n    }\n    But all such roots are\n    in $L_1$ because $L_1$ is a \\mynameref{def:galoisextension}. \n\n    Therefore the map $\\phi$ is well\n    defined. The map is injective because if we have some $\\sigma$ such that\n    $\\left. \\sigma \\right|_{L_1} = \\left. \\sigma \\right|_{L_2} = id$\n    then it should be $\\sigma = id$.\n    This is because our extension is\n    generated by $L_1$ and $L_2$, so if it happened to be in identity\n    on them both, it must be an identity.\n    \\footnote{\n      \\label{note:lec7_injectivity}\n      We have that $\\phi(id) = id$ i.e. $\\phi$ is\n      \\mynameref{def:injection}. Because if $g_1, g_2 \\ne id$ then\n      the equality $\\phi(g_1) = \\phi(g_2)$ holds if $g_1 g_2^{-1} =\n      id$ i.e. if $g_1 = g_2$ that is accordingly with the injectivity\n      definition.\n\n      Another proof is the following. Accordingly the staff comment on\n      last section of lecture 6 (see \n      note \\ref{note:lec6_staff_comment}). We have to take an arbitrary\n      element $g \\in L$ then if its image is identity ($\\phi(g) = id$)\n      then $g = id$. We got the required property if we assume\n      \\[\n      \\begin{cases}\n        \\phi(g)\\left(x\\right) = g\\left(x\\right),& \\text{if } x \\in\n        L_1\\\\\n        \\phi(g)\\left(x\\right) = id\\left(x\\right) = x,& \\text{if } x \\in\n        L_2.\n      \\end{cases}\n      \\]\n      In the case if $\\phi(g) = id$ then $\\left.g\\right|_{L_1} = id$\n      and $\\left.g\\right|_{L_2} = id$ or as it was mentioned in the\n      lectures $g = id$. This finishes the proof that $\\phi$ is\n      injective.\n\n      See also theorem \\ref{thm:grouphomomorphsim}.\n    }\n\n    So now lets find the image of $\\phi$. If $g\\left(x\\right) = x,\n    \\forall g \\in Gal\\left(L_1 L_2/ L_2\\right)$ then $x \\in L_2$ by\n    \\mynameref{thm:galoiscorrespondence}. So if also $x \\in L_1$ then it\n    should be $x \\in K' = L_1 \\cap \\L_2$. So if $L_1$ is finite over\n    $K$ then by   \\mynameref{thm:galoiscorrespondence} we can conclude\n    that $\\Ima \\phi = Gal\\left(L_1/K'\\right)$\n    \\footnote{\n      In the lectures Ekaterina marked it as $\\Ima \\phi =\n      Gal\\left(L/K'\\right)$ but really we should have $L_1$ instead of\n      $L$ there.\n    }\n    because the\n    \\mynameref{def:fixedfield} is $K'$.\n\n    In general\n    \\footnote{\n      not finite $L_1$ over $K$\n    }\n    we have to find finite\n    sub-extension of $L_1$: let denote it as $L_1'$. We also have a\n    finite Galois sub extension of $L_1$ that contains $L_1'$. We\n    denote this Galois sub-extension as $L_1''$.\n    \\footnote{\n      ??? The claim require a proof. Ekaterina provided only initial ideas\n      about how the proof can look like:\n      You can take the union of all images of $L_1'$ by all\n      automorphisms. And this will be a finite union since $L_1'$ was\n      finite, so there are finitely many possible roots of minimal\n      polynomials so there are not really many possibilities for the\n      images of this $L_1'$. So I shall leave it as an exercise , but the\n      solution is more or less what I just have told you.\n    }   \n\n    We have\n    $L_1''$ and $L_2$ are linearly disjoint over $K'$\n    \\footnote{\n      As soon as $j$ is injection, the theorem \\ref{thm:lec7_2} gives\n      us that $L_1''$ and $L_2$ are linearly disjoint over $K'$. \n    }\n    then it follows\n    that $L_1$ and $L_2$ are also linearly disjoint over $K'$\n    (see theorem \\ref{thm:lec7_2} point \\ref{thm:lec7_2_c}).\n\n    Several additional comments about the $\\Ima \\phi$.\n    Let $\\gamma \\in Gal\\left(L_1/K'\\right)$ then exists an element in\n    $Gal\\left(L_1 L_2/L_2\\right)$ which is sent by $\\phi$ to $\\gamma$.\n    \\footnote{\n      The element exists if $\\Ima \\phi = Gal\\left(L_1/K'\\right)$.\n    }\n    We have $j: L_1 \\otimes_K L_2 \\cong L_1 L_2$ and we can take\n    $j \\cdot \\left(\\gamma \\otimes id_{L_2}\\right) \\cdot j^{-1}$ - this will\n    be the element of the required Galois group.\n    \\footnote{\n      I.e. there is an element $g \\in Gal\\left(L_1 L_2/L_2\\right)$\n      such that $\\phi(g) = \\gamma$. Let $x \\in L_1$\n      (but $x \\notin L_2$ i.e. $x \\notin K'$ because for such $x$ and\n      $\\forall g \\in Gal\\left(L_1 L_2/L_2\\right)$ it will be\n      $g(x) = x$ as well as $\\gamma(x) = x$\n      i.e. obviously the required property is satisfied)\n      then, using equality $x = x \\cdot 1_{L_2}$, one can get\n      \\[\n      j^{-1}(x) = x \\otimes 1_{L_2}\n      \\]\n      and therefore\n      \\begin{eqnarray}\n        \\phi(g)(x) = j \\cdot \\left(\\gamma \\otimes id_{L_2}\\right) \\cdot\n        j^{-1} (x) =\n        \\nonumber \\\\\n        = j \\cdot \\left(\\gamma(x) \\otimes id_{L_2}(1)\\right) =\n        \\gamma(x) \\cdot 1 = \\gamma(x).\n        \\nonumber\n      \\end{eqnarray}\n      I.e. $\\phi(g) = \\gamma$.\n    }\n  \\end{proof}\n\\end{theorem}\n\n\\section{On the Galois group of the composite}\n\nFrom the theorem \\ref{thm:lec7_3} follows the following proposition\n\\begin{proposition}\n  \\begin{enumerate}\n  \\item $L_1$ and $L_2$ are both Galois over $K$ and linearly disjoint then\n    the following map $g \\to \\left(\\left. g \\right|_{L_1}, \\left. g\n    \\right|_{L_2}\\right)$ defines the isomorphism\n    \\footnote{\n      $Gal\\left(L_1/K\\right) \\times Gal\\left(L_2/K\\right)$ is a\n      \\mynameref{def:directproduct} of 2 groups\n      $Gal\\left(L_1/K\\right)$ and $Gal\\left(L_2/K\\right)$.\n    }\n    \\[\n    Gal\\left(L_1 L_2/K\\right) \\cong Gal\\left(L_1/K\\right) \\times Gal\\left(L_2/K\\right)\n    \\]\n  \\item conversely to the first part: if\n    $Gal\\left(L/K\\right) = G_1 \\times G_2$ then $L = L^{G_1} L^{G_2}$\n    which are linearly disjoint over the intersection.\n    \\footnote{\n      i.e. $L^{G_1}$ and $L^{G_2}$ are linearly disjoint over $L^{G_1}\n      \\cap L^{G_2}$ \n    }\n    \\begin{proof}\n      The first part is very sure because the injectivity of this\n      map is clear: if something is trivial both on $L_1$ and $L_2$,\n      then  it's trivial on the composite,\n      \\footnote{\n        If we take an arbitrary element\n        $g \\in Gal\\left(L_1 L_2/K\\right)$\n        and the image of the element is:\n        $\\left(\\left. id \\right|_{L_1}, \\left. id\n        \\right|_{L_2}\\right) \\in Gal\\left(L_1/K\\right) \\times Gal\\left(L_2/K\\right)$\n        then the taken element is the identity\n        too: $g = id$. This proves the injectivity i.e. the proof is the same as\n        in the note \\ref{note:lec7_injectivity}.\n        \n        See also theorem \\ref{thm:grouphomomorphsim}.\n      }\n      so I only have to prove the\n      surjectivity.  I will use the same trick as before:\n      $L_1 \\otimes_K L_2 \\cong_j L_1 L_2$ then\n      $j \\cdot \\left(g_1 \\otimes g_2\\right) \\cdot j^{-1}$ goes to\n      $\\left(g_1, g_2\\right)$.\n      \\footnote{\n        Let $x \\in L_1$ then\n        using equality $x = x \\cdot 1_{L_2}$, one can get\n        \\[\n        j^{-1}(x) = x \\otimes 1_{L_2}\n        \\]\n        and therefore\n        \\begin{eqnarray}\n          \\left(j \\cdot\n          \\left(\\left.g\\right|_{L_1} \\otimes \\left.g\\right|_{L_2}\\right) \\cdot\n          j^{-1}\\right)(x) = j \\cdot \\left(\\left.g\\right|_{L_1}(x) \\otimes\n          \\left.g\\right|_{L_2}(1)\\right) =\n          \\nonumber \\\\\n          = \\left.g\\right|_{L_1}(x) \\cdot 1 = g_1(x).\n          \\nonumber\n        \\end{eqnarray}\n        If $x \\in L_2$ then\n        using equality $x = 1_{L_1} \\cdot x$, one can get\n        \\[\n        j^{-1}(x) = 1_{L_1} \\otimes x\n        \\]\n        and therefore\n        \\begin{eqnarray}\n          \\left(j \\cdot\n          \\left(\\left.g\\right|_{L_1} \\otimes \\left.g\\right|_{L_2}\\right) \\cdot\n          j^{-1}\\right)(x) = j \\cdot \\left(\\left.g\\right|_{L_1}(1) \\otimes\n          \\left.g\\right|_{L_2}(x)\\right) =\n          \\nonumber \\\\\n          = 1 \\cdot \\left.g\\right|_{L_2}(x) = g_2(x).\n          \\nonumber\n        \\end{eqnarray}\n        Thus we have the following construction\n        \\[\n        \\begin{cases}\n        j \\cdot \\left(g_1 \\otimes g_2\\right) \\cdot j^{-1} \\to g_1 = g_{L_1},& \\forall x \\in\n        L_1\\\\\n        j \\cdot \\left(g_1 \\otimes g_2\\right) \\cdot j^{-1} \\to g_2 = g_{L_2},& \\forall x \\in\n        L_2\\\\\n      \\end{cases}\n        \\]\n        In the obvious case $x \\in L_1 \\cap L_2$ we have $g_1 = g_2$.\n        Thus we can write $j \\cdot \\left(g_1 \\otimes g_2\\right) \\cdot\n        j^{-1} \\to \\left(g_1, g_2\\right)$.\n      }\n\n      The second part. $L^{G_1}$ and $L^{G_2}$ are both Galois\n      \\footnote{\n        see theorem \\ref{thm:galoiscorrespondence} point\n        \\ref{thm:galoiscorrespondence:item2a} \n      }\n      because\n      $G_1$ and $G_2$ are normal in the product\n      (see property \\ref{property:directproduct}):\n      $G_1, G_2 \\triangleleft G_1 \\times G_2$. What I mean is $G_1$\n      embedded to the product by identifying it with $G_1 \\times e$\n      where $e$ is the neutral element of $G_2$.\n\n      The intersection $L^{G_1} \\cap L^{G_2}$ is fixed by $G$ so\n      $L^{G_1} \\cap L^{G_2} = K$.\n      \\footnote{\n        Lets define the action of $g = (g_1, g_2) \\in G_1 \\times G_2$\n        on $L_1L_2$. By definition \\mynameref{def:compositeextension},\n        any element of $L_1L_2$ can be represented in the form $x =\n        \\sum_{ij} l_i^{(1)}l_j^{(2)}$, where\n        $l_i^{(1)} \\in L_1, l_j^{(2)} \\in L_2$\n        (see also \\autoref{thm:lec7_2} (statement\n        \\ref{thm:lec7_2_d})). Thus\n        \\[\n        g(x) = (g_1, g_2)(x) = \\sum_{ij} \n        g_1\\left(l_i^{(1)}\\right)\n        g_2\\left(l_j^{(2)}\\right).\n        \\]\n        We also have\n        \\[\n        g_1(x) = \\sum_{ij} \n        g_1\\left(l_i^{(1)}\\right)\n        l_j^{(2)}\n        \\]\n        and\n        \\[\n        g_2(x) = \\sum_{ij} \n        l_i^{(1)}\n        g_2\\left(l_j^{(2)}\\right).\n        \\]\n        \n        Let $x \\in L^{G_1} \\cap L^{G_2}$ then $\\forall g_1 \\in\n        G_1, g_2 \\in G_2: g_1(x) = x, g_2(x) = x$.\n        Therefore\n        \\[\n        g_1\\left(l_i^{(1)}\\right) = l_i^{(1)},\n        g_2\\left(l_j^{(2)}\\right) = l_j^{(2)}.\n        \\]\n        I.e. $l_{i,j}^{(1,2)} \\in K$.\n        Or in other words\n        $\\forall g \\in G : g = (g_1, g_2)$ we have\n        \\[\n        g(x) = (g_1, g_2)(x) = \\sum_{ij} \n        g_1\\left(l_i^{(1)}\\right)\n        g_2\\left(l_j^{(2)}\\right) =\n        \\sum_{ij} l_i^{(1)}l_j^{(2)} =\n        x.\n        \\]\n        Therefore $G$ fixes $L^{G_1} \\cap L^{G_2}$, but\n        $G = Gal\\left(L/K\\right)$ thus $L^{G_1} \\cap L^{G_2} = K$.\n      }\n      Linear disjoint follows from\n      $L^{G_1} \\cap L^{G_2} = K$ since we are in the Galois case.\n      \\footnote{\n        We can use theorem \\ref{thm:lec7_3} as soon as\n        $L^{G_1}$ and $L^{G_2}$ are both Galois\n        (see theorem \\ref{thm:galoiscorrespondence} point\n        \\ref{thm:galoiscorrespondence:item2a}).\n      }\n    \\end{proof}\n  \\end{enumerate}\n  \\label{prop:lec7_3}\n\\end{proposition}\n\nLet me give you a small example:\n\\begin{example}\n  We have a \\mynameref{def:compositeextension}\n  $\\mathbb{Q}\\left(\\zeta_n\\right) \\mathbb{Q}\\left(\\zeta_m\\right) =\n  \\mathbb{Q}\\left(\\zeta_n, \\zeta_m\\right)$\n  \\footnote{\n    We can consider $L_1 = \\mathbb{Q}\\left(\\zeta_n\\right)$,\n    $L_2 = \\mathbb{Q}\\left(\\zeta_m\\right)$ and\n    $L_1 L_2 = \\mathbb{Q}\\left(\\zeta_n, \\zeta_m\\right)$.\n  }\n  where\n  $\\zeta_n = e^{\\frac{2 \\pi i}{n}}$.\n  $\\mathbb{Q}\\left(\\zeta_n, \\zeta_m\\right) =\n  \\mathbb{Q}\\left(\\zeta_{LCM\\left(n,m\\right)}\\right)$\n  \\footnote{\n    LCM - least common multiple. For instance multiples for 4 are\n    $4,8,12, \\dots$. Multiples for 6 are $6,12,18, \\dots$. Thus\n    $LCM\\left(4,6\\right) = 12$.\n  } therefore if $\\left(n,m\\right) = 1$ then\n  $\\mathbb{Q}\\left(\\zeta_n\\right)$ and\n  $\\mathbb{Q}\\left(\\zeta_m\\right)$ are linearly disjoint.\n  \\footnote{\n    See example \\ref{ex:lec7_1} where we got if\n    $\\left(\\left[L_1:K\\right], \\left[L_2:K\\right]\\right) =\n    \\left(n, m\\right) = 1$ then $L_1$ and $L_2$ are linearly\n    disjoint. \n  }\n  It can be\n  seen as follows: we can apply proposition \\ref{prop:lec7_3} to our\n  Galois groups then\n  $\\mathbb{Q}\\left(\\zeta_n, \\zeta_m\\right) =\n  \\mathbb{Q}\\left(\\zeta_{nm}\\right)$ but by the\n  \\mynameref{thm:chineseremainder}\n  \\footnote{\n    and also by \\mynameref{thm:fundamentaltheoremofcyclicgroup}\n  }\n  \\[\n  \\left(\\mathbb{Z}/nm\\mathbb{Z}\\right)^\\times \\cong\n  \\left(\\mathbb{Z}/n\\mathbb{Z}\\right)^\\times \\times\n  \\left(\\mathbb{Z}/m\\mathbb{Z}\\right)^\\times. \n  \\]\n  Thus $Gal\\left(\\mathbb{Q}\\left(\\zeta_{nm}\\right)\\right) =\n  Gal\\left(\\mathbb{Q}\\left(\\zeta_{n}\\right)\\right) \\times\n  Gal\\left(\\mathbb{Q}\\left(\\zeta_{m}\\right)\\right)$. So the linear\n  disjoint is just got from the proposition \\ref{prop:lec7_3}.\n\\end{example}\n", "meta": {"hexsha": "5827d31c88bb57d14cecb3cf5622f2f6de94a6e1", "size": 52059, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture7.tex", "max_stars_repo_name": "JiuziLau/courseragalois", "max_stars_repo_head_hexsha": "06423d7609caf8e083fe4c5a442ec01ea27018ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2016-06-21T07:34:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T00:14:44.000Z", "max_issues_repo_path": "lecture7.tex", "max_issues_repo_name": "JiuziLau/courseragalois", "max_issues_repo_head_hexsha": "06423d7609caf8e083fe4c5a442ec01ea27018ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-06-28T21:26:22.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-30T05:36:37.000Z", "max_forks_repo_path": "lecture7.tex", "max_forks_repo_name": "JiuziLau/courseragalois", "max_forks_repo_head_hexsha": "06423d7609caf8e083fe4c5a442ec01ea27018ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-08-08T07:47:20.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-25T06:16:07.000Z", "avg_line_length": 39.6791158537, "max_line_length": 93, "alphanum_fraction": 0.616838587, "num_tokens": 18916, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.43610907230708323}}
{"text": "\\subsubsection{\\stid{3.11} ALExa}\r\n\r\n\r\n\\paragraph{Overview}\r\n\r\nThe ALExa project ({\\sl Accelerated Libraries for Exascale}) focuses on\r\npreparing the DTK and Tasmanian libraries for exascale platforms and\r\nintegrating these libraries into ECP applications.  These libraries deliver\r\ncapabilities identified as needs of ECP applications: (1) the ability to\r\ntransfer computed solutions between grids with differing layouts on parallel\r\naccelerated architectures, enabling multiphysics projects to seamlessly\r\ncombine results from different computational grids to perform their required\r\nsimulations (DTK); and\r\n%\r\n(2) the ability to construct fast and memory efficient surrogates to large\r\nscale engineering models with multiple inputs and large number of outputs,\r\nenabling uncertainty quantification (both forward and inverse) as well as\r\noptimization and efficient multi-physics simulations in projects such as\r\nExaStar (Tasmanian).\r\n\r\nThese capabilities are being developed through ongoing interactions with our\r\nECP application project collaborators to ensure they will satisfy requirements\r\nof these customers.  The libraries in turn take advantage of other ECP/SW\r\ncapabilities currently in development, including Trilinos and ForTrilinos,\r\nKokkos and SLATE.  The final outcome of the ECP project will be a set of\r\nlibraries deployed to facilities and also made broadly available as part of\r\nthe xSDK4ECP project.\r\n\r\n\r\n{\\bf DTK} (Data Transfer Kit)\r\n\r\n{\\it Purpose:} Transfers computed solutions between grids with differing\r\nlayouts on parallel accelerated architectures.\r\n\r\n{\\it Significance:} Coupled applications frequently have different grids with\r\ndifferent parallel distributions; DTK is able to transfer solution values\r\nbetween these grids efficiently and accurately.\r\n\r\n{\\it Mesh and mesh-free interpolation capabilities:} multivariate data\r\ninterpolation between point clouds and grids; compactly supported radial basis\r\nfunctions; nearest-neighbor and moving least square implementations; support\r\nfor standard finite-element shape functions and user-defined interpolants;\r\ncommon applications include conjugate heat transfer, fluid structure\r\ninteraction, and mesh deformation.\r\n\r\n{\\it Performance portable search capabilities:} shared memory and GPU\r\nimplementations of spatial tree construction; shared memory and GPU\r\nimplementations of various spatial tree queries; MPI front-end for\r\ncoordinating distributed spatial searches between sets of geometric objects\r\nwith different decompositions; communication plan generation based on spatial\r\nsearch results.\r\n\r\n{\\it URL:} https://github.com/ORNL-CEES/DataTransferKit\r\n\r\n\r\n{\\bf Tasmanian} (Toolkit for Adaptive Stochastic Modeling and Non-Intrusive\r\nApproximation)\r\n\r\n{\\it Purpose:} Constructs efficient surrogate models for high dimensional\r\nproblems and performs parameter calibration and optimization geared towards\r\napplications in uncertainty quantification (UQ).\r\n\r\n{\\it Significance:} UQ pertains to the statistical properties of the output\r\nfrom a complex model with respect to variability in multiple model inputs;\r\nlarge number of simulations are required to compute reliable statistics which\r\nis prohibitive when dealing with computationally expensive engineering\r\nmodels. A surrogate model is constructed from a moderate set of simulations\r\nusing carefully chosen input values; analysis can then be performed on the\r\nefficient surrogate.\r\n\r\n{\\it Sparse grids capabilities:} surrogate modeling and design of experiments\r\n(adaptive multi-dimensional interpolation); reduced (lossy) representation of\r\ntabulated scientific data; high dimensional numerical quadrature; data mining\r\nand manifold learning.\r\n\r\n{\\it DiffeRential Evolution Adaptive Metropolis (DREAM) capabilities:}\r\nBayesian inference; parameter estimation/calibration; model validation.\r\nglobal optimization and optimization under uncertainty.\r\n\r\n{\\it URL:} http://tasmanian.ornl.gov\r\n\r\n\\paragraph{Key Challenges}\r\n\r\n\\indent\r\n\r\n{\\bf DTK:} General data transfer between grids of unrelated applications\r\nrequires many-to-many communication which is increasingly challenging as\r\ncommunication to computation ratios are decreasing on successive HPC systems.\r\nSearch procedures to locate neighboring points and mesh cells require tree\r\nsearch methods difficult to optimize on modern accelerated architectures due\r\nto vector lane or thread divergence. Maintaining high accuracy for the\r\ntransfer requires careful attention to the mathematical properties of the\r\ninterpolation methods and is highly application-specific.\r\n\r\n{\\bf Tasmanian:} Complex models usually have significant variability in\r\nexecution time for different model inputs, which leads to massive down-time\r\nwhen employing the standard fork-join adaptive sparse grid algorithms.  After\r\nthe surrogate has been constructed, collecting the samples for statistical\r\nanalysis (or multi-physics simulations) requires a massive number of basis\r\nevaluations and many sparse and dense linear operations.\r\n\r\n\\paragraph{Solution Strategy}\r\n\r\n\\nobreak\r\n\r\n\r\n\\indent\r\n\r\n{\\bf DTK:} State-of-the-art, mathematically rigorous methods are used in DTK\r\nto preserve accuracy of interpolated solutions.  Algorithms are implemented in\r\na C++ code base with extensive unit testing on multiple platforms.  Trilinos\r\npackages are used to support interpolation methods.  Kokkos is used to achieve\r\nperformance portability across accelerated platforms.\r\n\r\n{\\bf Tasmanian:} Implement asynchronous DAG-based sparse grids construction\r\nmethods that preserve the convergence properties of the fork-join algorithms\r\nbut are insensitive to fluctuations in model simulation time.  Port the basis\r\nevaluations and linear algebra to the GPU accelerators, and leverage the\r\nSLATE/MAGMA capabilities to ensure performance portability across relevant\r\nplatforms.\r\n\r\n\r\n%----------------------------------------\r\n\r\n\\paragraph{Recent Progress}\r\n\r\n\\indent\r\n\r\n{\\bf DTK:} Extensive optimization work has yielded significant performance\r\nimprovements on accelerated and heterogeneous architectures. Work with partner\r\napplication ExaAM (WBS 2.2.1.05) created a preliminary multiphysics driver\r\ncapability for additive manufacturing simulations.\r\n\r\n\\begin{figure}[htb]\r\n        \\centering\r\n        \\includegraphics[width=3.0in]{projects/2.3.3-MathLibs/2.3.3.11-ALExa/dtk-gpu}\r\n        \\caption{\\label{fig:dtk-gpu}DTK search performance relative to Boost with Intel Xeon E5-2698 and Nvidia P100. 10M points randomly distributed in a unit cube, 1M queries. The time is in seconds. Speedup in bold.}\r\n\\end{figure}\r\n\r\n{\\bf Tasmanian:} The infrastructure of Tasmanian has been upgraded to support\r\nthe broader ECP focus of the work.  GPU acceleration of sparse grid surrogates\r\nhas been implemented.  Tasmanian recently enabled the ExaStar project to\r\nreduce the size of a large-memory table of neutrino opacities by 100X while\r\nstill preserving accuracy.\r\n\r\n\\begin{figure}[htb]\r\n        \\centering\r\n        \\includegraphics[width=1.5in]{projects/2.3.3-MathLibs/2.3.3.11-ALExa/tasmanian-gpu}\r\n        \\caption{\\label{fig:tasmanian-gpu}Tasmanian approximation (right) of neutrino capacities (left).}\r\n\\end{figure}\r\n\r\n%----------------------------------------\r\n\r\n\\paragraph{Next Steps}\r\n\r\n\\indent\r\n\r\n{\\bf DTK:} DTK search and communication capabilities will deployed in a new,\r\nlightweight library, ArborX, to provide these ECP investments to a broader\r\nuser base.\r\n\r\n{\\bf Tasmanian:} Work will continue with the development of the asynchronous\r\nconstruction methods that exploit the native sparse grids DAG hierarchy.\r\n\r\n%----------------------------------------\r\n", "meta": {"hexsha": "973d53a38a9a01adeea549edcef879cfcd0b68ef", "size": 7616, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/2.3.3-MathLibs/2.3.3.11-ALExa/2.3.3.11-ALExa.tex", "max_stars_repo_name": "olivier-snl/ECP-ST-CAR-PUBLIC", "max_stars_repo_head_hexsha": "6e869d56e254e1c6fa74545635d66e7a7ff5e0cd", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/2.3.3-MathLibs/2.3.3.11-ALExa/2.3.3.11-ALExa.tex", "max_issues_repo_name": "olivier-snl/ECP-ST-CAR-PUBLIC", "max_issues_repo_head_hexsha": "6e869d56e254e1c6fa74545635d66e7a7ff5e0cd", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/2.3.3-MathLibs/2.3.3.11-ALExa/2.3.3.11-ALExa.tex", "max_forks_repo_name": "olivier-snl/ECP-ST-CAR-PUBLIC", "max_forks_repo_head_hexsha": "6e869d56e254e1c6fa74545635d66e7a7ff5e0cd", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8795180723, "max_line_length": 220, "alphanum_fraction": 0.7883403361, "num_tokens": 1543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4361090660835251}}
{"text": "% !TEX root = hw2.tex\n\n\\section{Decision-based Cascades: A Local Election [25 points]}\nIt's election season and two candidates, Candidate A and Candidate B, are in a\nhotly contested city council race in sunny New Suburb Town. You are a strategic\nadvisor for Candidate A in charge of election forecasting and voter acquisition\ntactics.\n\nBased on careful modeling, you've created two possible versions of the social\ngraph of voters. Each graph has 10,000 nodes, where nodes are denoted by an\ninteger ID between 0 and 9999.  The edge lists of the graphs are provided in \nthe homework bundle.\nBoth graphs are \\textbf{undirected}.\n\nGiven the hyper-partisan political climate of New Suburb Town, most voters have\nalready made up their minds: 40\\% know they will vote for A, 40\\% know they will\nvote for B, and the remaining 20\\% are undecided. Each voter's support is\ndetermined by the last digit of their node id. If the last digit is 0--3, the\nnode supports A. If the last digit is 4--7, the node supports B. And if the last\ndigit is 8 or 9, the node is undecided.\n\nThe undecided voters will go through a 10-day decision period where they choose\na candidate each day based on the majority of their friends. The \\textbf{decision period}\nworks as follows:\n\\begin{enumerate}\n\\item The graphs are initialized with every voter's initial state ($A$, $B$, or\n  undecided).\n\\item In each iteration, every undecided voter decides on a candidate.\n  Voters are processed in increasing order of node ID.  \n  For every undecided voter, if\n  the majority of their friends support A, they now support A. If the majority of\n  their friends support B, they now support B. ``Majority'' for A means that\n  strictly more of their friends support A than the number of their friends supporting B,\n  and vice versa for B (ignoring undecided friends).\n\\item If a voter has an equal number of friends supporting A and B, we assign support\nfor A or B in alternating fashion, starting with A.  \nIn other words, as the voters\nare being processed in increasing order of node ID, the first tie leads to\nsupport for A, the second tie leads to support for B, the third for A, the fourth for B, and so on.\nThis alternating assignment happens at a \\textit{global level} for the whole network, across all rounds.\n(Keep a single global variable that keeps track of whether the current\n  alternating vote is A or B, and initialize it to A in the first round. Then as\n  you iterate over nodes in order of increasing ID, whenever you assign a vote\n  using this alternating variable, change its value afterwards.)\n\\item When processing the updates, use the values from the current iteration.\n  For example, when updating the votes for node 10, you should use the updated\n  votes for nodes 0--9 from the current iteration, and nodes 11 and onwards from the\n  previous iteration.\n\\item There are 10 iterations of the process described above.\n\\item On the 11th day, it's election day, and the votes are counted.\n\\end{enumerate}\n\n\\emph{Note that only the undecided voters go through the decision process. The decision process does not change the loyalties of those voters who have already made up their minds. Voters who are initially undecided may change their mind on each iteration of this process.}\n\n\\subsection{Basic Setup and Forecasting [4 points]}\nStart your work with the starter code provided.\nRead in the two graphs and assign the initial vote configurations to the\nnetwork.  Then, perform the 10 iterations of the voting process.  Which candidate wins in\nGraph 1, and by how many votes? Which candidate wins in Graph 2, and by how many\nvotes?\n\nFor sanity check, neither of these two numbers (how many votes) is larger than 300.\n\n\\subsection{TV Advertising [8 points]}\nYou have amassed a substantial war chest of \\$9000, and you have decided to\nspend this money by showing ads on the local news. Unfortunately, only 100 New\nSuburb Townians watch the local news---those with ids 3000--3099.  However, your\nads are extremely persuasive, so anyone who sees the ad is immediately swayed to\nvote for candidate A regardless of his/her previous decision.  You may spend\n\\$1000 at a time on ads.  The first \\$1,000 reaches voters 3000--3009, the\nsecond \\$1000 reaches voters 3010--3019, and so on. In other words, the total of \\$$k$ in advertising would reach voters with ids from 3000 to $3000 + \\frac{k}{100} - 1$.  This advertising happens\nbefore the decision period.  \\emph{After voters are persuaded by your ads, they\n  never change their minds again.}\n\nSimulate the effect of advertising spending on the two possible social\ngraphs. First, read in the two graphs again and assign the initial\nconfigurations as before. Now, before the decision process, you purchase \\$$k$\nof ads and go through the decision process of counting votes.\n\nFor each of the two social graphs, plot \\$$k$ (the amount you spend) on the\nx-axis (for values $k = 1000, 2000, \\ldots, 9000$) and the number of votes for A minus the number of votes for B on the y-axis.  Put these on the\nsame plot.  What's the minimum\namount you can spend to win the election in each of the two social graphs?\n\n\\emph{Note that the TV advertising affects all of the voters who see the ads and not just those who\n  are undecided.}\n\n\\subsection{Wining and Dining the High Rollers [8 points]}\n\\label{cascades_3}\nTV advertising is only one way to spend your campaign war chest.  You have\nanother idea to have a very classy \\$1000 per plate event for the high rollers\nof New Suburb Town (the people with the highest degree in the social graph). You\ninvite high rollers in order of how many people they know, and everyone that\ncomes to your dinner is \\emph{instantly persuaded to vote for candidate A\n  regardless of his/her previous decision}.  \nFor each high roller you spend \\$1000 to this persuasion.  \nThis event will happen before the\ndecision period. When there are ties between voters with the same degree, the\nhigh roller with lowest node ID get chosen first.\n\nSimulate the effect of the high roller dinner on the two graphs. First, read in\nthe graphs and assign the initial configuration as before. Now, before the\ndecision process, you spend \\$$k$ on the fancy dinner and then go through the\ndecision process of counting votes.\n\nFor each of the two social graphs, plot \\$$k$ (the amount you spend) on the\nx-axis (for values $k = 1000, 2000, \\ldots, 9000$) and the number of votes you\nwin by on the y-axis (that is, the number of votes for A less the number of votes for B).\nWhat's the minimum amount you can spend to win the election in each of the two social graphs?\n\n\\emph{Note that wining and dining sways all the voters to vote for A and not\n  just those who are undecided.}\n\n\\subsection{Analysis [5 points]}\nPlot the degree distributions on a log-log scale of the two graphs on the same\nplot (as in Question 1.1 on Problem Set 1).  Although both graphs have roughly\nthe same number of edges, degree distributions are actually very different.\nIn 1--2 sentences, briefly\nsummarize how this difference explains the results of \nQuestion \\ref{cascades_3}.\n\n\\subsection*{What to submit}\n\\begin{enumerate}[{Page} 1:]\n\\setcounter{enumi}{8}\n\\item \n\\begin{itemize}\n\\item Which candidate wins and by how many votes in each graph.\n\\end{itemize}\n \n\\item\n\\begin{itemize}\n\\item Plot of winning margin in each graph as a function of \\$k (on the same plot)\n\\item The minimum amount you can spend to win the election in each graph\n\\end{itemize}\n \n\\item\n\\begin{itemize}\n\\item Plot of winning margin in each graph as a function of \\$k (on the same plot)\n\\item The minimum amount you can spend to win the election in each graph\n\\end{itemize}\n \n\\item\n\\begin{itemize}\n\\item Log-log plot of the degree distributions (on the same plot),\n\\item 1--2 sentences on why the plot explains the results of Question \\ref{cascades_3}.\n\\end{itemize}\n\\end{enumerate}\n", "meta": {"hexsha": "4db841307a2bae44b92464f9f3f4823b1c92f4d2", "size": 7851, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw3-bundle/hw3_source/hw3_q3.tex", "max_stars_repo_name": "zlpure/cs224w", "max_stars_repo_head_hexsha": "03fc4d179e430454632e1eeaf457626b3ba18a4e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2020-09-02T15:40:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T05:22:33.000Z", "max_issues_repo_path": "H3/bundle/hw3_source/hw3_q3.tex", "max_issues_repo_name": "Cauchemare/CS224W_2020_Solutions", "max_issues_repo_head_hexsha": "0a37c06e804a0600a505229008e78557a663eabb", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "H3/bundle/hw3_source/hw3_q3.tex", "max_forks_repo_name": "Cauchemare/CS224W_2020_Solutions", "max_forks_repo_head_hexsha": "0a37c06e804a0600a505229008e78557a663eabb", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-07-22T16:37:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-10T16:05:32.000Z", "avg_line_length": 53.0472972973, "max_line_length": 272, "alphanum_fraction": 0.7707298433, "num_tokens": 1933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.4361090609613931}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% PACKAGES %\n\n\\documentclass[11pt]{amsart}\n\\usepackage[main=english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{enumerate, enumitem}\n\\usepackage{colonequals}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% THEOREMS %\n\n\\theoremstyle{plain}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{proposition}{Proposition}\n\\newtheorem{conjecture}{Conjecture}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}\n\\newtheorem{example}{Example}\n\\newtheorem{observation}[theorem]{Observation}\n\n\\theoremstyle{remark}\n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{question}{Question}\n\\newtheorem{problem}{Problem}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% MATH OPERATORS %\n\n\\DeclareMathOperator{\\Z}{\\mathbb{Z}}\n\\DeclareMathOperator{\\N}{\\mathbb{N}}\n\\DeclareMathOperator{\\R}{\\mathbb{R}}\n\\DeclareMathOperator{\\F}{\\mathbb{F}}\n\\DeclareMathOperator{\\Q}{\\mathbb{Q}}\n\\DeclareMathOperator{\\C}{\\mathbb{C}}\n\n\\newcommand{\\mf}[1]{\\mathfrak{#1}}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\n\\setlength\\parindent{0pt}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% COMMENTS %\n\\newcommand{\\sk}[1]{\\textcolor{BurntOrange}{\\textbf{[#1]}}}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% TITLE %\n\n\\begin{document}\n\n\\title{Some Quals Problems}\n\\author{Santiago Arango-Piñeros}\n\\date{\\today}\n\n\\maketitle\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n% BODY %\n\\section{Algebra}\n\\subsection{Groups}\n    \\begin{enumerate}\n        \\item Classify the groups of order $182 = 2 \\cdot 7 \\cdot 13$.\n        \n        \\item  Let $G$ be a finite group of order $p^nm$ where $p$ is a prime and $m$ is not divisible by $p$. Prove that if $H$ is a subgroup of $G$ of order $p^k$ for some $k<n$, then the normalizer of $H$ in $G$ properly contains $H$.\n\n        \n        \\item Let $H$ be a subgroup of $S_n$ of index $n$. Prove:\n        \\begin{enumerate}\n            \\item[a)] There is an isomorphism $f: S_n \\to S_n$ such that $f(H)$ is the subgroup of $S_n$ stabilizing $n$. In particular, $H$ is isomorphic to $S_{n-1}$.\n            \\item[b)] The only subgroups of $S_n$ containing $H$ are $S_n$ and $H$.\n        \\end{enumerate}\n        \n        \\item \\begin{itemize}\n        \\item[a)] Prove that a group of order $351=3^3\\cdot 13$ cannot be simple.\n        \\item[b)] Prove that a group of order $33$ must be cyclic.\n    \\end{itemize}\n        \n        \\item \\begin{enumerate}\n        \\item[a)] Let $G$ be a group, and $Z(G)$ the center of $G$. Prove that if $G/Z(G)$ is cyclic, then $G$ is abelian.\n        \\item[b)] Prove that a group of order $p^n$, where $p$ is a prime and $n \\geq 1$, has non-trivial center.\n        \\item[c)] Prove that a group of order $p^2$ must be abelian.\n    \\end{enumerate}\n    \n    \\item Let $G$ be a finite group.\n    \\begin{enumerate}\n        \\item[a)] Prove that if $H < G$ is a proper subgroup, then $G$ is not the union of conjugates of $H$.\n        \\item[b)] Suppose that $G$ acts transitively on a set $X$ with $|X| > 1$. Prove that there exists an element of $G$ with no fixed points in $X$.\n    \\end{enumerate}\n    \n    \\item Classify all groups of order $15$ and of order $30$.\n        \n    \\item Count the number of $p$-Sylow subgroups of $S_p$.\n    \n    \\item \\begin{enumerate}\n        \\item[a)] Let $G$ be a group of order $n$. Suppose that for every divisor $d$ of $n$, $G$ contains at most one subgroup of order $d$. Show that $G$ is clyclic.\n        \\item[b)] Let $F$ be a field. Show that every finite subgroup of the group of units $F^\\times$ is cyclic.\n    \\end{enumerate}\n    \\end{enumerate}\n\\subsection{Fields and Galois Theory}\n\n    \\begin{enumerate}\n        \\item Let $K$ and $L$ be finite fields. Show that $K$ is contained in $L$ if and only if $\\# K = p^r$ and $\\# L = p^s$ for the same prime $p$, and $r \\leq s$.\n        \n        \\item Let $K$ and $L$ be finite fields with $K \\subseteq L$. Prove that $L$ is Galois over $K$ and that $\\mathrm{Gal}(L/K)$ is cyclic.\n        \n        \\item Fix a field $F$, a separable polynomial $f\\in F[x]$ of degree $n \\geq 3$, and a splitting field $L$ for $f$. Prove that if $[L:F] = n!$ then:\n    \\begin{enumerate}\n        \\item[a)] $f$ is irreducible.\n        \\item[b)] For each root $r$ of $f$, $r$ is the unique root of $f$ in $F(r)$.\n        \\item[c)] For every root $r$ of $f$, there are no proper intermediate fields $F \\subset L \\subset F(r)$.\n    \\end{enumerate}\n    \n    \\item \\begin{enumerate}\n        \\item[a)] Show that $\\sqrt{2+\\sqrt{2}}$ is a root of $p(x) = x^2 - 4x^2 + 2 \\in \\mathbf{Q}[x]$.\n        \\item[b)] Prove that $\\mathbf{Q}(\\sqrt{2 + \\sqrt{2}})$ is a Galois extension of $\\mathbf{Q}$ and find its Galois group. (Hint: note that $\\sqrt{2 - \\sqrt{2}}$ is another root of $p(x)$).\n        \\item[c)] Let $f(x) = x^3 - 5$. Determine the splitting field $K$ of $f(x)$ over $\\mathbf{Q}$ and the Galois group of $f(x)$. Give an example of a proper sub-extension $\\mathbf{Q} \\subset L \\subset K$, such that $L/\\mathbf{Q}$ is Galois.\n    \\end{enumerate}\n    \\end{enumerate}\n\n\\subsection{Rings}\n\n    \\begin{enumerate}\n        \\item An integral domain $R$ is said to be an {\\it Euclidean domain} if there is a function $N: R \\to \\{n\\in\\mathbf{Z} \\mid n\\geq 0\\}$ such that $N(0)=0$ and for each $a,b\\in R$ with $b\\neq 0$, there exist elements $q,r\\in R$ with\n    \\begin{align*}\n        a = qb + r, \\quad \\text{and} \\quad r = 0 \\, \\text{ or } \\, N(r) < N(b).\n    \\end{align*}\n    Prove:\n    \\begin{enumerate}\n        \\item[a)] The ring $F[[x]]$ of power series over a field $F$ is an Euclidean domain.\n        \n        \\item[b)] Every Euclidean domain is a PID. \n    \\end{enumerate}\n    \n    \\item Let $F$ be a field, and let $R$ be the subring of $F[X]$ of polynomials with $X$ coefficient equal to $0$. Prove that $R$ is not a UFD.\n    \n    \\item $R$ is a commutative ring with 1. Prove that if $I$ is a maximal ideal in $R$, then $R/I$ is a field. Prove that if $R$ is a PID, then every nonzero prime ideal in $R$ is maximal. Conclude that if $R$ is a PID and $p\\in R$ is prime, then $R/(p)$ is a field.\n    \n    \\end{enumerate}\n\n\\subsection{Linear Algebra}\n\n    \\begin{enumerate}\n        \\item Prove that any square matrix is conjugate to its transpose matrix. (You may prove it over $\\mathbf{C}$).\n        \n        \\item Determine the number of conjugacy classes of $16 \\times 16$ matrices with entries in $\\mathbf{Q}$ and minimal polynomial $(x^2+1)^2(x^3+2)^2$.\n        \n        \\item Let $V$ be a vector space over a field $F$. The evaluation map $e\\colon V \\to (V^\\vee)^\\vee$ is defined by $e(v)(f) \\colonequals f(v)$ for $v\\in V$ and $f\\in V^\\vee$.\n            \\begin{enumerate}\n                \\item[a)] Prove that $e$ is an injection.\n                \\item[b)] Prove that $e$ is an isomorphism if and only if $V$ is finite dimensional.\n            \\end{enumerate}\n            \n        \\item Let $R$ be a principal ideal domain that is not a field, and write $F$ for its field of fractions. Prove that $F$ is not a finitely generated $R$-module.\n        \n        \\item Carefully state Zorn's lemma and use it to prove that every vector space has a basis.\n    \\end{enumerate}\n\n\\section{Analysis}\n\\subsection{Complex Analysis}\n\\begin{enumerate}\n    \\item Use residues to compute the integral\n    \\begin{align*}\n        \\int_{0}^{\\infty} \\dfrac{\\cos x}{(x^2+1)^2} \\mathrm{d}x \\, .\n    \\end{align*}\n    \n    \\item State and prove the Cauchy integral formula for holomorphic functions.\n    \n    \\item Use the Cauchy integral formula to prove the maximal principle for analytic functions.\n    \n    \\item Let $f$ be an entire function and suppose that $|f(z)| \\leq A|z|^2$ for all $z$ and some constant $A$. Show that $f$ is a polynomial of degree $\\leq 2$.\n    \n    \\item \\begin{enumerate}\n        \\item[a)] State the Schwarz lemma for analytic functions in the unit disc.\n        \n        \\item[b)] Let $f: \\mathbf{D} \\to \\mathbf{D}$ be an analytic map from the unit disc $\\mathbf{D}$ into itself. Use the Schwarz lemma to show that for each $a\\in \\mathbf{D}$ we have\n     \\begin{align*}\n         \\dfrac{|f'(a)|}{1-|f(a)|^2} \\leq \\dfrac{1}{1-|a|^2} \\, .\n     \\end{align*}\n    \\end{enumerate}\n    \n    \\item State the Riemann mapping theorem and prove the uniqueness part.\n    \n    \\item Compute the integrals\n    \\begin{align*}\n        \\int_{|z-2|=1} \\dfrac{e^z}{z(z-1)^2} \\, \n        \\mathrm{d}z, \\quad \\int_0^\\infty \\dfrac{\\cos 2x}{x^2 + 2} \\, \\mathrm{d}x \\, .\n    \\end{align*}\n    \n    \\item Let $(f_n)$ be a sequence of holomorphic functions in a domain $D$. Suppose that $f_n \\to f$ uniformly on each compact subset of $D$. Show that\n    \\begin{itemize}\n        \\item[a)] $f$ is holomorphic on $D$.\n        \n        \\item[b)] $f_n' \\to f'$ uniformly on each compact subset of $D$.\n    \\end{itemize}\n    \n    \\item If $f$ is a non-constant entire function, then $f(\\mathbf{C})$ is dense in the plane.\n    \n    \\item \\begin{enumerate}\n        \\item[a)] State Rouche's theorem.\n        \\item[b)] Let $f$ be analytic in a neighborhood of $0$, and satisfying $f'(0) \\neq 0$. Use Rouche's theorem to show that there exists a neighborhood $U$ of $0$ such that $f$ is a bijection in $U$.\n    \\end{enumerate}\n    \n    \\item Let $f$ be a meromorphic function in the plane such that\n   \\begin{align*}\n       \\lim_{|z|\\to\\infty} |f(z)| = \\infty \\, .\n   \\end{align*}\n   \\begin{enumerate}\n       \\item[a)] Show that $f$ has only finitely many poles.\n       \\item[b)] Show that $f$ is a rational function.\n   \\end{enumerate}\n\\end{enumerate}\n\n\\subsection{Real Analysis}\n\\begin{enumerate}\n    \\item Describe the process that extends a measure on an algebra $\\mathcal{A}$ of subsets of $X$, to a complete measure defined on a $\\sigma$-algebra $\\mathcal{B}$ containing $\\mathcal{A}$. State the corresponding definitions and results (without proofs).\n    \n    \\item State and prove Fatou's Lemma on a general measurable space.\n    \n    \\item \\begin{enumerate}\n        \\item[a)] State the Dominated Convergence Theorem for Lebesgue integrals.\n        \n        \\item[b)] Let $\\{f_n\\}$ be a sequence of measurable functions on a Lebesgue measurable set $E$ which converges {\\it in measure} to a function $f$ on $E$. Suppose that for every $n$, $|f_n| \\leq g$ with $g$ integrable on $E$. Using the above theorem show that \n        \\begin{align*}\n            \\int_E |f_n-f| \\longrightarrow 0 \\, .\n        \\end{align*}\n    \\end{enumerate}\n    \n    \\item Let $f\\in L^1([0,1])$. Show that\n    \\begin{enumerate}\n        \\item[a)] The limit $\\lim_{p\\to 0^+} \\| f \\|_p$ exists.\n        \\item[b)] If $m \\{x : f(x) = 0\\} > 0$, then the above limit is zero.\n    \\end{enumerate}\n    \n    \\item Let $f$ be a continuous function on $[0,1]$. Show that the following statements are equivalent.\n    \\begin{enumerate}\n        \\item[a)] $f$ is absolutely continuous.\n        \\item[b)] For any $\\epsilon > 0$ there exists $\\delta > 0$ such that $m(f(E)) < \\epsilon$ for any set $E\\subseteq [0,1]$ with $m(E) < \\delta$.\n        \\item[c)] $m(f(E)) = 0$ for any set $E \\subseteq [0,1]$ with $m(E)=0$.\n    \\end{enumerate}\n\\end{enumerate}\n\n\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "c8332605549b9553f5973ae93d7c8a26a526dfac", "size": 12040, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Questions/Archive/Emory/main.tex", "max_stars_repo_name": "dzackgarza/MakeMeAQual_UGA", "max_stars_repo_head_hexsha": "beba581e5b32f54ff469ed603a0885d51591e5fc", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-02T02:57:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-11T17:23:01.000Z", "max_issues_repo_path": "Questions/Archive/Emory/main.tex", "max_issues_repo_name": "dzackgarza/MakeMeAQual_UGA", "max_issues_repo_head_hexsha": "beba581e5b32f54ff469ed603a0885d51591e5fc", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Questions/Archive/Emory/main.tex", "max_forks_repo_name": "dzackgarza/MakeMeAQual_UGA", "max_forks_repo_head_hexsha": "beba581e5b32f54ff469ed603a0885d51591e5fc", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T07:12:00.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T07:12:00.000Z", "avg_line_length": 43.4657039711, "max_line_length": 267, "alphanum_fraction": 0.563538206, "num_tokens": 3511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4361090547378354}}
{"text": "%Deep neural networks (DNNs) have been demonstrated effective for approximating complex and high dimensional functions. In the data-driven inverse modeling, we use DNNs to substitute unknown physical relations, such as constitutive relations, in a physical system described by partial differential equations (PDEs). The coupled system of DNNs and PDEs enables describing complex physical relations while satisfying the physics to the largest extent. However, training the DNNs embedded in PDEs is challenging because input-output pairs of DNNs may not be available, and the physical system may be highly nonlinear, leading to an implicit numerical scheme. We propose an approach, physics constrained learning, to train the DNNs from sparse observations data that are not necessarily input-output pairs of DNNs while enforcing the PDE constraints numerically. Particularly, we present an efficient automatic differentiation based technique that differentiates through implicit PDE solvers. We demonstrate the effectiveness of our method on various problems in solid mechanics and fluid dynamics. Our PCL method enables learning a neural-network-based physical relation from any observations that are interlinked with DNNs through PDEs. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Beamer Presentation\n% LaTeX Template\n% Version 1.0 (10/11/12)\n%\n% This template has been downloaded from:\n% http://www.LaTeXTemplates.com\n%\n% License:\n% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%----------------------------------------------------------------------------------------\n%    PACKAGES AND THEMES\n%----------------------------------------------------------------------------------------\n\n\\documentclass[usenames,dvipsnames]{beamer}\n\\usepackage{animate}\n\\usepackage{float}\n\\usepackage{bm}\n\\usepackage{mathtools}\n\\usepackage{extarrows}\n\n\\newcommand{\\ChoL}{\\mathsf{L}}\n\\newcommand{\\bx}{\\mathbf{x}}\n\\newcommand{\\ii}{\\mathrm{i}}\n\\newcommand{\\bxi}{\\bm{\\xi}}\n\\newcommand{\\bmu}{\\bm{\\mu}}\n\\newcommand{\\bb}{\\mathbf{b}}\n\\newcommand{\\bA}{\\mathbf{A}}\n\\newcommand{\\bJ}{\\mathbf{J}}\n\\newcommand{\\bB}{\\mathbf{B}}\n\\newcommand{\\bM}{\\mathbf{M}}\n\n\\newcommand{\\by}{\\mathbf{y}}\n\\newcommand{\\bw}{\\mathbf{w}}\n\n\\newcommand{\\bX}{\\mathbf{X}}\n\\newcommand{\\bY}{\\mathbf{Y}}\n\\newcommand{\\bs}{\\mathbf{s}}\n\\newcommand{\\sign}{\\mathrm{sign}}\n\\newcommand{\\bt}[0]{\\bm{\\theta}}\n\\newcommand{\\bc}{\\mathbf{c}}\n\\newcommand{\\bzero}{\\mathbf{0}}\n\\renewcommand{\\bf}{\\mathbf{f}}\n\\newcommand{\\bu}{\\mathbf{u}}\n\\newcommand{\\bv}[0]{\\mathbf{v}}\n\n\\mode<presentation> {\n\n% The Beamer class comes with a number of default slide themes\n% which change the colors and layouts of slides. Below this is a list\n% of all the themes, uncomment each in turn to see what they look like.\n\n%\\usetheme{default}\n%\\usetheme{AnnArbor}\n%\\usetheme{Antibes}\n%\\usetheme{Bergen}\n%\\usetheme{Berkeley}\n%\\usetheme{Berlin}\n%\\usetheme{Boadilla}\n%\\usetheme{CambridgeUS}\n%\\usetheme{Copenhagen}\n%\\usetheme{Darmstadt}\n%\\usetheme{Dresden}\n%\\usetheme{Frankfurt}\n%\\usetheme{Goettingen}\n%\\usetheme{Hannover}\n%\\usetheme{Ilmenau}\n%\\usetheme{JuanLesPins}\n%\\usetheme{Luebeck}\n\\usetheme{Madrid}\n%\\usetheme{Malmoe}\n%\\usetheme{Marburg}\n%\\usetheme{Montpellier}\n%\\usetheme{PaloAlto}\n%\\usetheme{Pittsburgh}\n%\\usetheme{Rochester}\n%\\usetheme{Singapore}\n%\\usetheme{Szeged}\n%\\usetheme{Warsaw}\n\n\n% As well as themes, the Beamer class has a number of color themes\n% for any slide theme. Uncomment each of these in turn to see how it\n% changes the colors of your current slide theme.\n\n%\\usecolortheme{albatross}\n\\usecolortheme{beaver}\n%\\usecolortheme{beetle}\n%\\usecolortheme{crane}\n%\\usecolortheme{dolphin}\n%\\usecolortheme{dove}\n%\\usecolortheme{fly}\n%\\usecolortheme{lily}\n%\\usecolortheme{orchid}\n%\\usecolortheme{rose}\n%\\usecolortheme{seagull}\n%\\usecolortheme{seahorse}\n%\\usecolortheme{whale}\n%\\usecolortheme{wolverine}\n\n%\\setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line\n%\\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line\n\n%\\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line\n}\n\\usepackage{booktabs}\n\\usepackage{makecell}\n\\usepackage{soul}\n\\newcommand{\\red}[1]{\\textcolor{red}{#1}}\n%\n%\\usepackage{graphicx} % Allows including images\n%\\usepackage{booktabs} % Allows the use of \\toprule, \\midrule and \\bottomrule in tables\n%\n%\n%\\usepackage{amsthm}\n%\n%\\usepackage{todonotes}\n%\\usepackage{floatrow}\n%\n%\\usepackage{pgfplots,algorithmic,algorithm}\n\\usepackage{algorithmicx}\n\\usepackage{algpseudocode}\n%\\usepackage[toc,page]{appendix}\n%\\usepackage{float}\n%\\usepackage{booktabs}\n%\\usepackage{bm}\n%\n%\\theoremstyle{definition}\n%\n\\newcommand{\\RR}[0]{\\mathbb{R}}\n%\n%\\newcommand{\\bx}{\\mathbf{x}}\n%\\newcommand{\\ii}{\\mathrm{i}}\n%\\newcommand{\\bxi}{\\bm{\\xi}}\n%\\newcommand{\\bmu}{\\bm{\\mu}}\n%\\newcommand{\\bb}{\\mathbf{b}}\n%\\newcommand{\\bA}{\\mathbf{A}}\n%\\newcommand{\\bJ}{\\mathbf{J}}\n%\\newcommand{\\bB}{\\mathbf{B}}\n%\\newcommand{\\bM}{\\mathbf{M}}\n%\\newcommand{\\bF}{\\mathbf{F}}\n%\n%\\newcommand{\\by}{\\mathbf{y}}\n%\\newcommand{\\bw}{\\mathbf{w}}\n%\\newcommand{\\bn}{\\mathbf{n}}\n%\n%\\newcommand{\\bX}{\\mathbf{X}}\n%\\newcommand{\\bY}{\\mathbf{Y}}\n%\\newcommand{\\bs}{\\mathbf{s}}\n%\\newcommand{\\sign}{\\mathrm{sign}}\n%\\newcommand{\\bt}[0]{\\bm{\\theta}}\n%\\newcommand{\\bc}{\\mathbf{c}}\n%\\newcommand{\\bzero}{\\mathbf{0}}\n%\\renewcommand{\\bf}{\\mathbf{f}}\n%\\newcommand{\\bu}{\\mathbf{u}}\n%\\newcommand{\\bv}[0]{\\mathbf{v}}\n\n\\AtBeginSection[]\n{\n   \\begin{frame}\n       \\frametitle{Outline}\n       \\tableofcontents[currentsection]\n   \\end{frame}\n}\n\n%----------------------------------------------------------------------------------------\n%    TITLE PAGE\n%----------------------------------------------------------------------------------------\n\\usepackage{bm}\n\\newcommand*{\\TakeFourierOrnament}[1]{{%\n\\fontencoding{U}\\fontfamily{futs}\\selectfont\\char#1}}\n\\newcommand*{\\danger}{\\TakeFourierOrnament{66}}\n\n\\title[Physics Constrained Learning]{Data-driven Inverse Modeling with Sparse Observation} % The short title appears at the bottom of every slide, the full title is only on the title page\n\n\\author[Kailai Xu, et al.]{Kailai Xu and Eric Darve\\\\ { Alexandre M. Tartakovsky, Jeff Burghardt, Dongzhuo Li, Jerry M. Harris, Weiqiang Zhu, Gregory C. Beroza} }% Your name\n%\\institute[] % Your institution as it will appear on the bottom of every slide, may be shorthand to save space\n%{\n%%ICME, Stanford University \\\\ % Your institution for the title page\n%%\\medskip\n%%\\textit{kailaix@stanford.edu}\\quad \\textit{darve@stanford.edu} % Your email address\n%}\n\\date{}% Date, can be changed to a custom date\n% Mathematics of PDEs\n\n\\newcommand\\blfootnote[1]{%\n  \\begingroup\n  \\renewcommand\\thefootnote{}\\footnote{#1}%\n  \\addtocounter{footnote}{-1}%\n  \\endgroup\n}\n\\begin{document}\n\n\\usebackgroundtemplate{%\n\\begin{picture}(0,250)\n\\centering\n\t{{\\includegraphics[width=1.0\\paperwidth]{../background}}}\n\\end{picture}\n  } \n%\\usebackgroundtemplate{%\n%  \\includegraphics[width=\\paperwidth,height=\\paperheight]{figures/back}} \n\\begin{frame}\n\n\\titlepage % Print the title page as the first slide\n\n\n\\blfootnote{\\scriptsize Full version: \\url{https://kailaix.github.io/ADCME.jl/dev/assets/Slide/ADCME.pdf} }\n%dfa\n\\end{frame}\n\\usebackgroundtemplate{}\n\n\\section{Inverse Modeling}\n\n\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling}\n\t\\begin{itemize}\n\t\t\\item \\textbf{Inverse modeling} identifies a certain set of parameters or functions with which the outputs of the forward analysis matches the desired result or measurement.\n\t\t\\item Many real life engineering problems can be formulated as inverse modeling problems: shape optimization for improving the performance of structures, optimal control of fluid dynamic systems, etc.t\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n\t\\centering\n  \\includegraphics[width=0.8\\textwidth]{../inverse2}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling}\n\t\\begin{figure}\n\t\\centering\n  \\includegraphics[width=1.0\\textwidth]{../inverse3}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Inverse Modeling}\n\tWe can formulate inverse modeling as a PDE-constrained optimization problem \n\t\\begin{equation*}\n\t\t\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\theta, u_h) = 0\n\t\\end{equation*}\n\t\\begin{itemize}\n\t\t\\item The \\textcolor{red}{loss function} $L_h$ measures the discrepancy between the prediction $u_h$ and the observation $u_{\\mathrm{obs}}$, e.g., $L_h(u_h) = \\|u_h - u_{\\mathrm{obs}}\\|_2^2$. \n\t\t\\item $\\theta$ is the \\textcolor{red}{model parameter} to be calibrated. \n\t\t\\item The \\textcolor{red}{physics constraints} $F_h(\\theta, u_h)=0$ are described by a system of partial differential equations. Solving for $u_h$ may require solving linear systems or applying an iterative algorithm such as the Newton-Raphson method. \n\t\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Function Inverse Problem}\n\t\n\t\\begin{equation*}\n\t\t\\min_{\\textcolor{red}{f}} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\textcolor{red}{f}, u_h) = 0\n\t\\end{equation*}\n\t\n\tWhat if the unknown is a \\textcolor{red}{function} instead of a set of parameters?\n\\begin{itemize}\n\t\\item Koopman operator in dynamical systems.\n\t\\item Constitutive relations in solid mechanics. \n\t\\item Turbulent closure relations in fluid mechanics.\n\t\\item ...\n\\end{itemize}\n\nThe candidate solution space is \\textcolor{red}{infinite dimensional}.\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Physics Based Machine Learning}\n\t$$\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\;F_h(\\textcolor{red}{NN_\\theta}, u_h) = 0$$\n\t\\vspace{-0.5cm}\n\t\\begin{itemize}\n\t\t\\item Deep neural networks exhibit capability of approximating high dimensional and complicated functions. \n\t\t\\item \\textbf{Physics based machine learning}: \\textcolor{red}{the unknown function is approximated by a deep neural network, and the physical constraints are enforced by numerical schemes}.\n\t\t\\item \\textcolor{red}{Satisfy the physics to the largest extent}.\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.75\\textwidth]{../physics_based_machine_learning.png}\n\\end{figure}\n\\end{frame}\n\n\n\n\\begin{frame}\n\t\\frametitle{Gradient Based Optimization}\n\t\\begin{equation}\\label{equ:opt}\n\t\t\\min_{\\theta} L_h(u_h) \\quad \\mathrm{s.t.}\\; F_h(\\theta, u_h) = 0\n\t\t\\end{equation}\n\t\n\t\\begin{itemize}\n\t\t\\item We can now apply a gradient-based optimization method to (\\ref{equ:opt}).\n\t\t\\item The key is to \\textcolor{red}{calculate the gradient descent direction} $g^k$\n\t\t$$\\theta^{k+1} \\gets \\theta^k - \\alpha g^k$$ \n\t\\end{itemize}\n\t\n\t\\begin{figure}[hbt]\n\t\\centering\n  \\includegraphics[width=0.6\\textwidth]{../im.pdf}\n\\end{figure}\n\n\\end{frame}\n\n\n\n\\section{Automatic Differentiation}\n\n\\begin{frame}\n\t\\frametitle{Automatic Differentiation}\nThe fact that bridges the \\textcolor{red}{technical} gap between machine learning and inverse modeling:\n\t\\begin{itemize}\n\t\t\\item Deep learning (and many other machine learning techniques) and numerical schemes share the same computational model: composition of individual operators. \n\t\\end{itemize}\n\t\n\n\\begin{minipage}[b]{0.4\\textwidth}\n\n\n\n\n\\begin{center}\n\\textcolor{red}{Mathematical Fact}\n\n\\\n\n\tBack-propagation \n\n$||$\n\nReverse-mode\n\n Automatic Differentiation \n\n$||$\n \n Discrete \n \n Adjoint-State Method\n\\end{center}\n\\end{minipage}~\n\\begin{minipage}[b]{0.6\\textwidth}\n\\begin{figure}[hbt]\n\\centering\n  \\includegraphics[width=0.8\\textwidth]{../compare-NN-PDE.png}\n\\end{figure}\n\\end{minipage}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Computational Graph for Numerical Schemes}\n\t\n\t\\begin{itemize}\n\t\t\\item To leverage automatic differentiation for inverse modeling, we need to express the numerical schemes in the ``AD language'': computational graph. \n\t\t\\item No matter how complicated a numerical scheme is, it can be decomposed into a collection of operators that are interlinked via state variable dependencies. \n\t\\end{itemize}\n\t\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../cgnum}\n\\end{figure}\n\n\t\n\t\n\\end{frame}\n\n\n\n\n\n%\\begin{frame}\n%\t\\frametitle{Code Example}\n%\t\\begin{itemize}\n%\t\t\\item  Find $b$ such that $u(0.5)=1.0$ and\n%\t\t$$-bu''(x)+u(x) = 8 + 4x - 4x^2, x\\in[0,1], u(0)=u(1)=0$$\n%\t\\end{itemize}\n%\t\\begin{figure}[hbt]\n%  \\includegraphics[width=0.8\\textwidth]{../code.png}\n%\\end{figure}\n%\\end{frame}\n\n\n\\section{Physics Constrained Learning}\n\\begin{frame}\n\n\n\t\\frametitle{Challenges in AD}\n\t\n\t\n\t\\begin{minipage}[t]{0.49\\textwidth}\n\t\\vspace{-3cm}\n\\begin{itemize}\n\t\\item Most AD frameworks only deal with \\textcolor{red}{explicit operators}, i.e., the functions that has analytical derivatives, or composition of these functions. \n\t\\item Many scientific computing algorithms are \\textcolor{red}{iterative} or \\textcolor{red}{implicit} in nature.\n\\end{itemize}\n\\end{minipage}~\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\includegraphics[width=1.0\\textwidth]{../sim.png}\n\\end{minipage}\n\n\t% Please add the following required packages to your document preamble:\n% \\usepackage{booktabs}\n\\begin{table}[]\n\\begin{tabular}{@{}lll@{}}\n\\toprule\nLinear/Nonlinear & Explicit/Implicit & Expression   \\\\ \\midrule\nLinear           & Explicit          & $y=Ax$       \\\\\nNonlinear        & Explicit          & $y = F(x)$   \\\\\n\\textbf{Linear}           & \\textbf{Implicit}          & $Ay = x$     \\\\\n\\textbf{Nonlinear}        & \\textbf{Implicit}          & $F(x,y) = 0$ \\\\ \\bottomrule\n\\end{tabular}\n\\end{table}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Example}\n\t\n\\begin{itemize}\n\t\\item Consider a function $f:x\\rightarrow y$, which is implicitly defined by \n\t$$F(x,y) = x^3 - (y^3+y) = 0$$\nIf not using the cubic formula for finding the roots, the forward computation consists of iterative algorithms, such as the Newton's method and bisection method\n\\end{itemize}\n\n\n\n\\begin{minipage}[t]{0.48\\textwidth}\n\\centering\n\\begin{algorithmic}\n\\State $y^0 \\gets 0$\n\\State $k \\gets 0$\n\\While {$|F(x, y^k)|>\\epsilon$}\n\\State $\\delta^k \\gets F(x, y^k)/F'_y(x,y^k)$\n\\State $y^{k+1}\\gets y^k - \\delta^k$\n\\State $k \\gets k+1$\n\\EndWhile\n\\State \\textbf{Return} $y^k$\n\\end{algorithmic}\n\\end{minipage}~\n\\begin{minipage}[t]{0.48\\textwidth}\n\\centering\n\\begin{algorithmic}\n\\State $l \\gets -M$, $r\\gets M$, $m\\gets 0$\n\\While {$|F(x, m)|>\\epsilon$}\n\\State $c \\gets \\frac{a+b}{2}$\n\\If{$F(x, m)>0$}\n\\State $a\\gets m$\n\\Else\n\\State $b\\gets m$\n\\EndIf\n\\EndWhile\n\\State \\textbf{Return} $c$\n\\end{algorithmic}\n\n\\end{minipage}\t\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Example}\n\n\t\\begin{itemize}\n\t\t%\t\t\\item A simple approach is to save part or all intermediate steps, and ``back-propagate''. This approach is expensive in both computation and memory\\footnote{Ablin, Pierre, Gabriel Peyr�, and Thomas Moreau. ``Super-efficiency of automatic differentiation for functions defined as a minimum.''}.\n\t\t%\t\t\\item Nevertheless, the simple approach works in some scenarios where accuracy or cost is not an issue, e.g., automatic differetiation of soft-DTW and Sinkhorn distance. \n\t\t\\item An efficient way to do automatic differentiation is to apply the \\textcolor{red}{implicit function theorem}. For our example, $F(x,y)=x^3-(y^3+y)=0$; treat $y$ as a function of $x$ and take the derivative on both sides\n\t\t      $$3x^2 - 3y(x)^2y'(x)-y'(x)=0\\Rightarrow y'(x) = \\frac{3x^2}{3y^2+1}$$\n\t\t      The above gradient is \\textcolor{red}{exact}.\n\t\\end{itemize}\n\t\\begin{center}\n\t\t\\textbf{Can we apply the same idea to inverse modeling?}\n\t\\end{center}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Example}\n\t\n\t\\begin{itemize}\n%\t\t\\item A simple approach is to save part or all intermediate steps, and ``back-propagate''. This approach is expensive in both computation and memory\\footnote{Ablin, Pierre, Gabriel Peyré, and Thomas Moreau. ``Super-efficiency of automatic differentiation for functions defined as a minimum.''}.\n%\t\t\\item Nevertheless, the simple approach works in some scenarios where accuracy or cost is not an issue, e.g., automatic differetiation of soft-DTW and Sinkhorn distance. \n\t\t\\item An efficient way is to apply the \\textcolor{red}{implicit function theorem}. For our example, $F(x,y)=x^3-(y^3+y)=0$, treat $y$ as a function of $x$ and take the derivative on both sides\n\t\t$$3x^2 - 3y(x)^2y'(x)-1=0\\Rightarrow y'(x) = \\frac{3x^2-1}{3y(x)^2}$$\n\tThe above gradient is \\textcolor{red}{exact}.\n\t\\end{itemize}\n\t\\begin{center}\n\t\t\t\\textbf{Can we apply the same idea to inverse modeling?}\n\t\\end{center}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{Physics Constrained Learning}\n\t$${\\small    \\min_{\\theta}\\; L_h(u_h) \\quad \\mathrm{s.t.}\\;\\; F_h(\\theta, u_h) = 0}$$\n\t\\begin{itemize}\n\t\t\\item Assume that we solve for $u_h=G_h(\\theta)$ with $F_h(\\theta, u_h)=0$, and then\n\t\t      $${\\small\\tilde L_h(\\theta)  = L_h(G_h(\\theta))}$$\n\t\t\\item Applying the \\textcolor{red}{implicit function theorem}\n\t\t      {  \\scriptsize\n\t\t\t      \\begin{equation*}\n\t\t\t\t      \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }} + {\\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}}}\n\t\t\t\t      \\textcolor{red}{\\frac{\\partial G_h(\\theta)}{\\partial \\theta}}\n\t\t\t\t      = 0 \\Rightarrow\n\t\t\t\t      \\textcolor{red}{\\frac{\\partial G_h(\\theta)}{\\partial \\theta}} =  -\\Big( \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}} \\Big)^{ - 1} \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }}\n\t\t\t      \\end{equation*}\n\t\t      }\n\t\t\\item Finally we have\n\t\t\t      {\\scriptsize\n\t\t\t\t      \\begin{equation*}\n\t\t\t\t\t      \\boxed{\\frac{{\\partial {{\\tilde L}_h}(\\theta )}}{{\\partial \\theta }}\n\t\t\t\t\t      = \\frac{\\partial {{ L}_h}(u_h )}{\\partial u_h}\\frac{\\partial G_h(\\theta)}{\\partial \\theta}=\n\t\t\t\t\t      - \\textcolor{red}{ \\frac{{\\partial {L_h}({u_h})}}{{\\partial {u_h}}} } \\;\n\t\t\t\t\t      \\textcolor{blue}{ \\Big( {\\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial {u_h}}}\\Big|_{u_h = {G_h}(\\theta )}} \\Big)^{ - 1} } \\;\n\t\t\t\t\t      \\textcolor{ForestGreen}{ \\frac{{\\partial {F_h(\\theta, u_h)}}}{{\\partial \\theta }}\\Big|_{u_h = {G_h}(\\theta )} }\n\t\t\t\t\t      }\n\t\t\t\t      \\end{equation*}\n\t\t\t      }\n\n\t\\end{itemize}\n\n\\end{frame}\n\n\n\n\\section{Applications}\n\n\n%\\begin{frame}\n%\t\\frametitle{ADSeismic.jl: A General Approach to Seismic Inversion}\n%\t\\begin{itemize}\n%\t\t\\item Many seismic inversion problems can be solved within a unified framework. \n%\t\\end{itemize}\n%\t\\begin{figure}[hbt]\n%  \\includegraphics[width=1.0\\textwidth]{../adseimic.jpeg}\n%\\end{figure}\n%\t\n%\\end{frame}\n%\n%\\begin{frame}\n%\t\\frametitle{ADSeismic.jl: Earthquake Location Example}\n%\t\\begin{itemize}\n%\t\t\\item The earthquake source function is parameterized by ($g(t)$ and $x_0$ are unknowns)\n%\t\t$$f(x, t) =  \\frac{g(t)}{2\\pi \\sigma^2} \\exp \\left( -\\frac{||x - x_0||^2}{2 \\sigma^2} \\right)$$\n%\t\\end{itemize}\n%\t\\begin{figure}[hbt]\n%  \\includegraphics[width=1.0\\textwidth]{../source_time}\n%\\end{figure}\n%\\end{frame}\n%\n%\n%\\begin{frame}\n%\t\\frametitle{ADSeismic.jl: Benchmark}\n%\t\\begin{itemize}\n%\t\t\\item ADCME makes the heterogeneous computation capability of TensorFlow available for scientific computing. \n%\t\\end{itemize}\n%\t\\begin{figure}[hbt]\n%  \\includegraphics[width=0.7\\textwidth]{../benchmark}\n%\\end{figure}\n%\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{FwiFlow.jl: Elastic Full Waveform Inversion for Subsurface Flow Problems}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.8\\textwidth]{../geo.png}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{FwiFlow.jl: Fully Nonlinear Implicit Schemes}\n\\begin{itemize}\n\t\\item The governing equation is a nonlinear PDE\n\\begin{minipage}[b]{0.48\\textwidth}\n{\\scriptsize\n\t\\begin{align*}\n\t&\\frac{\\partial }{{\\partial t}}(\\phi {{S_i}}{\\rho _i}) + \\nabla  \\cdot ({\\rho _i}{\\mathbf{v}_i}) = {\\rho _i}{q_i},\\quad \n      i = 1,2\t\\\\\n     & S_{1} + S_{2} = 1\\\\\n      &{\\mathbf{v}_i} = - \\frac{{\\textcolor{blue}{K}{\\textcolor{red}{k_{ri}}}}}{{{\\tilde{\\mu}_i}}}(\\nabla {P_i} - g{\\rho _i}\\nabla Z), \\quad\n      i=1, 2\\\\\n\t&k_{r1}(S_1) = \\frac{k_{r1}^o S_1^{L_1}}{S_1^{L_1} + E_1 S_2^{T_1}}\\\\\n\t&k_{r2}(S_1) = \\frac{ S_2^{L_2}}{S_2^{L_2} + E_2 S_1^{T_2}}\n\t\\end{align*}\n\t}\n\\end{minipage}~\\vline\n\\begin{minipage}[b]{0.48\\textwidth}\n\\flushleft\n\t{\\scriptsize \\begin{eqnarray*}\n && \\rho \\frac{\\partial v_z}{\\partial t} = \\frac{\\partial \\sigma_{zz}}{\\partial z} + \\frac{\\partial \\sigma_{xz}}{\\partial x} \\nonumber \\\\\n && \\rho \\frac{\\partial v_x}{\\partial t} = \\frac{\\partial \\sigma_{xx}}{\\partial x} + \\frac{\\partial \\sigma_{xz}}{\\partial z} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{zz}}{\\partial t} = (\\lambda + 2\\mu)\\frac{\\partial v_z}{\\partial z} + \\lambda\\frac{\\partial v_x}{\\partial x} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{xx}}{\\partial t} = (\\lambda + 2\\mu)\\frac{\\partial v_x}{\\partial x} + \\lambda\\frac{\\partial v_z}{\\partial z} \\nonumber \\\\\n && \\frac{\\partial \\sigma_{xz}}{\\partial t} = \\mu (\\frac{\\partial v_z}{\\partial x} + \\frac{\\partial v_x}{\\partial z}),\n\\end{eqnarray*}}\n\\end{minipage}\n\n\t\\item For stability and efficiency, implicit methods are the industrial standards. \n{\\scriptsize\t$$\\phi (S_2^{n + 1} - S_2^n) - \\nabla \\cdot \\left( {{m_{2}}(S_2^{n + 1})K\\nabla \\Psi _2^n} \\right) \\Delta t = \n\\left(q_2^n + q_1^n \\frac{m_2(S^{n+1}_2)}{m_1(S^{n+1}_2)}\\right) \n\\Delta t\\quad m_i(s) = \\frac{k_{ri}(s)}{\\tilde \\mu_i}\n$$} \n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{FwiFlow.jl: Showcase}\n\t\\begin{itemize}\n\t\t\\item Task 1: Estimating the permeability from seismic data \n\t\t\\begin{center}\n\tB.C. +\t\\textcolor{red}{Two-Phase Flow Equation} + Wave Equation $\\Rightarrow$ Seismic Data\n\t\\end{center}\n\t\t\\begin{figure}[hbt]\n\t\t\\centering\n  \\includegraphics[width=0.6\\textwidth]{../coupled}\n\\end{figure}\n\\item Task 2: Learning the rock physics model from sparse saturation data. The rock physics model is approximated by neural networks  \n{\\scriptsize$$f_1(S_1; \\theta_1) \\approx k_{r1}(S_1)\\qquad f_2(S_1; \\theta_2) \\approx k_{r2}(S_1)$$}\n\\vspace{-0.4cm}\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.3\\textwidth]{../sat}~\n  \\includegraphics[width=0.25\\textwidth]{../rock}\n\\end{figure}\n\t\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{FwiFlow.jl: Showcase}\n\t\\begin{itemize}\n\t\t\\item Task 3: Learning the \\textcolor{red}{nonlocal} (space or time) hidden dynamics from seismic data. This is very challenging using traditional methods (e.g., the adjoint-state method) because the dynamics are history dependent. \n\t\\end{itemize}\n\t\\begin{center}\n\tB.C. +\t\\textcolor{red}{Time-/Space-fractional PDE} + Wave Equation $\\Rightarrow$ Seismic Data\n\t\\end{center}\n\\begin{table}[htpb]\n\\centering\n\\begin{tabular}{@{}lll@{}}\n\\toprule\nGoverning Equation & $\\sigma=0$ & $\\sigma=5$ \\\\ \\midrule\n${}_0^CD_t^{\\textbf{0.8}}m = 10\\Delta m $ & \\makecell{$a/a^*\\ =1.0000$ \\\\  $\\quad\\alpha\\quad =\\mathbf{0.8000}$} & \\makecell{$a/a^*\\ =0.9109$ \\\\  $\\quad\\alpha\\quad =\\mathbf{0.7993}$} \\\\ \\hline\n${}_0^CD_t^{\\textbf{0.2}}m = 10\\Delta m $ & \\makecell{$a/a^*\\ =0.9994$ \\\\  $\\quad\\alpha\\quad =\\mathbf{0.2000}$} & \\makecell{$a/a^*\\ =0.3474$ \\\\  $\\quad\\alpha\\quad =\\mathbf{0.1826}$}  \\\\   \\bottomrule\n$\\frac{\\partial m}{\\partial t} = -10(-\\Delta)^{\\textbf{0.2}} m$ & \\makecell{$a/a^*\\ =1.0000$ \\\\   $\\quad s\\quad =\\mathbf{0.2000}$} & \\makecell{$a/a^*\\ =1.0378$ \\\\   $\\quad s\\quad =\\mathbf{0.2069}$} \\\\  \\hline\n$\\frac{\\partial m}{\\partial t} = -10(-\\Delta)^{\\textbf{0.8}} m$ & \\makecell{$a/a^*\\ =1.0000$ \\\\   $\\quad s\\quad =\\mathbf{0.8000}$} & \\makecell{$a/a^*\\ =1.0365$ \\\\   $\\quad s\\quad =\\mathbf{0.8093}$}\\\\  \\bottomrule\n\\end{tabular}\n\\end{table}\n\n\\end{frame}\n\n\n\\newcommand{\\bsigma}[0]{\\bm{\\sigma}}\n\\newcommand{\\bepsilon}[0]{\\bm{\\epsilon}}\n\n\\begin{frame}\n\t\\frametitle{PoreFlow.jl: Inverse Modeling of Viscoelasticity}\n%\t\n\t\\begin{itemize}\n\t\t\\item Multi-physics Interaction of Coupled Geomechanics and Multi-Phase Flow Equations \n{\\small\n\\begin{align*}\n\\mathrm{div}\\bsigma(\\bu) - b \\nabla p &= 0\\\\\n    \\frac{1}{M} \\frac{\\partial p}{\\partial t} + b\\frac{\\partial \\epsilon_v(\\bu)}{\\partial t} - \\nabla\\cdot\\left(\\frac{k}{B_f\\mu}\\nabla p\\right) &= f(x,t)\t\\\\\n    \t\\bsigma &= \\bsigma(\\bepsilon, \\dot\\bepsilon)\n\\end{align*}\n}\n\\item Approximate the constitutive relation by a neural network\n{\\small\n$$\\bsigma^{n+1} = \\mathcal{NN}_{\\bt} (\\bsigma^n, \\bepsilon^n) + H\\bepsilon^{n+1}$$}\n\t\\end{itemize}\t\t\n\t\\begin{figure}[hbt]\t\n\t\\centering\n  \\includegraphics[width=0.5\\textwidth]{../ip}~\n  \\includegraphics[width=0.3\\textwidth]{../cell}\n\\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n\t\\frametitle{PoreFlow.jl: Inverse Modeling of Viscoelasticity}\n\t\n\t\\begin{itemize}\n\t\t\\item Comparison with space varying linear elasticity approximation\n\t\t\\begin{equation*}\n\t\t\t\\bsigma = H(x, y) \\bepsilon\n\t\t\\end{equation*}\n\t\\end{itemize}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../visco1}\n\\end{figure}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{PoreFlow.jl: Inverse Modeling of Viscoelasticity}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=0.7\\textwidth]{../visco2}\n\\end{figure}\n\n\\end{frame}\n\n\n\n\\section{Some Perspectives}\n\n\\begin{frame}\n\t\\frametitle{Scopes, Challenges, and Future Work}\n\t\\textcolor{red}{\\textbf{Physics based Machine Learning}}: an innovative approach to inverse modeling. \n\t{\\scriptsize\n\t\\begin{enumerate}\n\t\t\\item Deep neural networks provide a novel function approximator that outperforms traditional basis functions in certain scenarios. \n\t\t\\item Numerical PDEs are not on the opposite side of machine learning. By expressing the known physical constraints using numerical schemes and approximating the unknown with machine learning models, we combine the best of the two worlds, leading to efficient and accurate inverse modeling tools. \n\t\\end{enumerate}\n\t}\n\t\t\n\t\t\\textcolor{red}{\\textbf{Automatic Differentiation}}: the core technique of physics based machine learning.\n\t\t{\\scriptsize\n\t\t\\begin{enumerate}\n\t\t\\item The AD technique is not new; it has existed for several decades and many software exists. \n\t\t\\item The advent of deep learning drives the development of robust, scalable and flexible AD software that leverages the high performance computing environment. \n\t\t\\item As deep learning techniques continue to grow, crafting the tool to incorporate machine learning and AD techniques for inverse modeling is beneficial in scientific computing.\n\t\t\\item However, AD is not a panacea. Many scientific computing algorithms cannot be directly translated to the AD language. \n\t\\end{enumerate}\n\t}\n\t\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{ADCME}\n\t\\begin{itemize}\n\t\\item ADCME is the materialization of the physics based machine learning concept. \n\t\t\\item ADCME allows users to use \\textcolor{red}{high performance} and \\textcolor{red}{mathematical friendly} programming language Julia to implement numerical schemes, and obtain the \\textcolor{red}{comprehensive automatic differentiation functionality}, \\textcolor{red}{heterogeneous computing capability}, \\textcolor{red}{parallelism} and \\textcolor{red}{scalability} provided by the TensorFlow backend. \n\t\\end{itemize}\n\t\\begin{center}\n\t\t\\url{https://github.com/kailaix/ADCME.jl}\n\t\\end{center}\n\t\\vspace{-0.3cm}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../Julia.png}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{A General Approach to Inverse Modeling}\n\t\\begin{figure}[hbt]\n  \\includegraphics[width=1.0\\textwidth]{../summary.png}\n\\end{figure}\n%\n\\end{frame}\n\n%}\n%\\usebackgroundtemplate{}\n%----------------------------------------------------------------------------------------\n%    PRESENTATION SLIDES\n%----------------------------------------------------------------------------------------\n\n%------------------------------------------------\n\n\n\n\\end{document} ", "meta": {"hexsha": "1de39775c58ebfe0fe8cae4d4a399341511d6569", "size": 27274, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/assets/Slide/AAAI.tex", "max_stars_repo_name": "z403173402/ADCME.jl", "max_stars_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/src/assets/Slide/AAAI.tex", "max_issues_repo_name": "z403173402/ADCME.jl", "max_issues_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/src/assets/Slide/AAAI.tex", "max_forks_repo_name": "z403173402/ADCME.jl", "max_forks_repo_head_hexsha": "eee87c3aea6ad990bdf80f63e33c7a926f8d5392", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-14T09:14:08.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-14T09:14:08.000Z", "avg_line_length": 35.6522875817, "max_line_length": 1235, "alphanum_fraction": 0.6873945883, "num_tokens": 8744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.43610905229617386}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{amsmath,amsthm,amsfonts,amssymb,xspace,graphicx,url,stmaryrd,parskip}\n\n\\newtheorem{lemma}{Lemma}\n\n\\newcommand\\todo[1]{\\textbf{[[TODO: #1]]}\\xspace}\n\\def\\F{\\ensuremath{\\mathbb{F}}}\n\\def\\G{\\ensuremath{\\mathbb{G}}}\n\\def\\Z{\\ensuremath{\\mathbb{Z}}}\n\\def\\O{\\ensuremath{O}}\n\n\\begin{document}\n\\title{The Ristretto and Cortado elliptic curve groups}\n\\author{Mike Hamburg\\thanks{Rambus Security Division}}\n\\maketitle\n\n\\begin{abstract}\n\\end{abstract}\n\n\\section{Introduction}\n\\section{Definitions and notation}\n\nLet the symbol $\\bot$ denote failure.\n\n\\subsection{Field elements}\nLet \\F\\ be a finite field of prime order $p$.  For an element $x\\in\\F$, let $\\text{res}(x)$ be the integer representative of $x\\in[0,p-1]$.  We call an element $x\\in\\F$ \\textit{negative} if $\\text{res}(x)$ is odd.  Call an element in \\F\\ \\textit{square} if it is a quadratic residue, i.e.\\ if there exists $\\sqrt{x}\\in\\F$ such that $\\sqrt{x}^2=x$.  There will in general be two such square roots; let the notation $\\sqrt{x}$ mean the unique non-negative square root of $x$.  If $p\\equiv1\\pmod 4$, then \\F\\ contains an element $i := \\sqrt{-1}$.\n\nLet $\\ell := \\lceil \\log_{2^8} p\\rceil$.  Each $x\\in\\F$ has a unique \\textit{little-endian byte representation}, namely the sequence\n$$\n\\text{\\F\\_to\\_bytes}(x) := \\llbracket b_i\\rrbracket_{i=0}^{\\l-1} \\ \\text{where}\\ b_i\\in[0,255]\\text{\\ and\\ }\\sum_{i=0}^{\\l-1} 2^{8i} \\cdot b_i = \\text{res}(x)\n$$\n\\todo{bytes to \\F}\n\n\\subsection{Groups}\nFor an abelian group \\G\\ with identity \\O, let $n\\G$ denote the subgroup of $\\G$ which are of the form $n\\cdot g$ for some $g\\in\\G$.  Let $\\G_n$ denote the $n$-torsion group of \\G, namely the subgroup $\\{g\\in\\G : n\\cdot g = O\\}$.\n\n\\subsection{Edwards curves}\nWe will work with twisted Edwards elliptic curves of the form \n%\n$$E_{a,d} : y^2 + a\\cdot x^2 = 1 + d\\cdot x^2\\cdot y^2$$\n%\nwhere $x,y\\in\\F$. Twisted Edwards curves curves have a group law\n$$(x_1,y_1) + (x_2,y_2) := \n\\left(\n\\frac{x_1 y_2 + x_2 y_1}{1+d x_1 x_2 y_1 y_2},\n\\frac{y_1 y_2 - a x_1 x_2}{1-d x_1 x_2 y_1 y_2}\n\\right)\n$$\nwith identity point $\\O := (0,1)$ and group inverse operation $$-(x,y) = (-x,y)$$\nThe group law is called \\textit{complete} if is produces the correct answer (rather than e.g.\\ $0/0$) for all points on the curve.  The above formulas are complete when $d$ and $ad$ are nonsquare in \\F, which implies that $a$ is square.  When these conditions hold, we also say that the curve itself is complete.\n\nLet the number of points on the curve be $$\\#E_{a,d} = h\\cdot q$$ where $q$ is prime and $h\\in\\{4,8\\}$.  We call $h$ the \\textit{cofactor}.\n\nFor $P = (x,y)\\in E$, we can define the \\textit{projective homogeneous form} of $P$ as $(X,Y,Z)$ with $Z\\neq 0$ and $$(x,y) = (X/Z,Y/Z)$$ and the \\textit{extended homogeneous form} as $(X,Y,Z,T)$ where additionally $XY=ZT$.  Extended homogeneous form is popular because it supports simple and efficient complete addition formulas~\\cite{hisil}.\n\n\\subsection{Montgomery curves}\n\nWhen $a-d$ is square in \\F, the twisted Edwards curve $E_{a,d}$ is isomorphic to the Montgomery curve\n$$v^2 = u\\cdot\\left(u^2 + 2\\cdot\\frac{a+d}{a-d}\\cdot u + 1\\right)$$\nby the map\n$$(u,v) = \\left(\\frac{1+y}{1-y},\\ \\ \\frac{1+y}{1-y}\\cdot\\frac1x\\cdot\\frac{2}{\\sqrt{a-d}}\\right)$$\nwith inverse\n$$(x,y) = \\left(\\frac{u}{v}\\cdot\\frac{\\sqrt{a-d}}{2},\\ \\ \\frac{u-1}{u+1}\\right)$$\n\nIf $M = (u,v)$ is a point on the Montgomery curve, then the $u$-coordinate of $2M$ is $(u^2-1)^2 / (4v^2)$ is necessarily square.  It follows that if $(x,y)$ is a point on $E_{a,d}$, and $a-d$ is square, then $(1+y)/(1-y)$ is also square.\n\nLikewhise, when $d-a$ is square in \\F, $E_{a,d}$ is isomorphic to the Montgomery curve\n$$v^2 = u\\cdot\\left(u^2 - 2\\cdot\\frac{a+d}{a-d}\\cdot u + 1\\right)$$\nby the map\n$$(u,v) = \\left(\\frac{y+1}{y-1},\\ \\ \\frac{y+1}{y-1}\\cdot\\frac1x\\cdot\\frac{2}{\\sqrt{d-a}}\\right)$$\nwith inverse\n$$(x,y) = \\left(\\frac{u}{v}\\cdot\\frac{\\sqrt{d-a}}{2},\\ \\ \\frac{1+u}{1-u}\\right)$$\n\n\\section{Lemmas}\nFirst, we characterize the 2-torsion and 4-torsion groups.\\\\\n\\begin{lemma}\\label{lemma:tors}\nLet $E_{a,d}$ be a complete Edwards curve.  Its 2-torsion subgroup is generated by $(0,-1)$.  The 4-torsion subgroup is generated by $(1/\\sqrt{a},0)$.\n\nAdding the 2-torsion generator to $(x,y)$ produces $(-x,-y)$.  Adding the 4-torsion generator $(1/\\sqrt{a},0)$ produces $(y/\\sqrt{a},-x\\cdot\\sqrt{a})$\n\\end{lemma}\n\\begin{proof}\nInspection.\n\\end{proof}\n\n\\begin{lemma}\\label{lemma:line}\nLet $E_{a,d}$ be a complete twisted Edwards curve over \\F, and $P_1 = (x_1,y_1)$ be any point on it.  Then there are exactly two points $P_2 = (x_2,y_2)$ satisfying $x_1 y_2 = x_2 y_1$, namely $P_1$ itself and $(-x_1,-y_1)$.  That is, there are either 0 or 2 points on any line through the origin.\n\\end{lemma}\n\\begin{proof}\nPlugging into the group operation gives\n$$x_1 y_2 = x_2 y_1 \\Longleftrightarrow P_1-P_2 = (0,y_3)$$\nfor some $y_3$.  Plugging $x=0$ into the curve equation gives $y=\\pm1$, the 2-torsion points.  Adding back, we have $P_2 = P_1 + (0,\\pm1) = (\\pm x_1, \\pm y_1)$ as claimed.\n\\end{proof}\n\n\\begin{lemma}\\label{lemma:dma}\nIf $E_{a,d}$ is a complete Edwards curve, then $a^2-ad$ is square in \\F\\ (and thus $a-d$ is square in \\F) if and only if the cofactor of $E_{a,d}$ is divisible by 8.\n\\end{lemma}\n\\begin{proof}\nDoubling an 8-torsion generator $(x,y)$ should produce a 4-torsion generator, i.e.\\ a point with $y=0$.  From the doubling formula, this happens precisely when $y^2=ax^2$, or $2ax^2=1+adx^4$.  This has roots in \\F\\ if and only if its discriminant $4a^2-4ad$ is square, so that $a^2-ad$ is square.\n\\end{proof}\n\n\\begin{lemma}\\label{lemma:sqrt}\nIf $(x_2,y_2) = 2\\cdot(x_1,y_1)$ is an even point in $E_{a,d}$, then $(1-ax_2^2)$ is a quadratic residue in \\F.  \\todo{$(y_2^2-1)$}.\n\\end{lemma}\n\\begin{proof}\nThe doubling formula has $$x_2 = \\frac{2x_1 y_1}{y_1^2+ax_1^2}$$\nso that $$1-ax_2^2 = \\left(\\frac{y_1^2-ax_1^2}{y_1^2+ax_1^2}\\right)^2$$\nis a quadratic residue.  Now for any point $(x,y)\\in E_{a,d}$, we have\n$$(y^2-1)\\cdot(1-ax^2)\n= y^2+ax^2-1-ax^2y^2\n= (d-a)x^2y^2\n$$\nwhich is a quadratic residue by Lemma~\\ref{lemma:dma}.\n\\end{proof}\n\n\\section{The Espresso groups}\nLet $E$ be a complete twisted Edwards curve with $a\\in\\{\\pm1\\}$ and cofactor $4$ or $8$. We describe the \\textit{Espresso} group $\\G(E)$ as\n$$\\text{Espresso}(E) := 2E / E_{h/2}$$\nThis group has prime order $q$.\n\\subsection{Group law}\nThe group law on $\\text{Espresso}(E)$ is the same as that on $E$.\n\\subsection{Equality}\nTwo elements $P_1 := (x_1,y_1)$ and $P_2 := (x_2,y_2)$ in $\\text{Espresso}(E)$ are equal if they differ by an element of $E_{h/2}$.\n\nIf $h=4$, the points are equal if $P_1-P_2\\in E_2$.  By Lemma~\\ref{lemma:line}, this is equivalent to $$x_1 y_2 = x_2 y_1$$\n\nIf $h=8$, the points are equal if $P_1-P_2\\in E_4$.  By Lemmas~\\ref{lemma:tors} and~\\ref{lemma:line}, this is equivalent to $$x_1 y_2 = x_2 y_1\\text{\\ \\ or\\ \\ }x_1 x_2 = -a y_1 y_2$$\n\nThese equations are homogeneous, so they may be evaluated in projective homogeneous form with $X_i$ and $Y_i$ in place of $x_i$ and $y_i$\n\n\\subsection{Encoding}\nWe now describe how to encode a point $P = (x,y)$ to bytes.  The requirements of encoding are that\n\\begin{itemize}\n\\item Any point $P\\in2E$ can be encoded.\n\\item Two points $P,Q$ have the same encoding if and only if $P-Q\\in E_{h/2}$.\n\\end{itemize}\n\nWhen $h=4$, we encode a point as $\\sqrt{a(y-1)/(y+1)}$\n\n\\end{document}", "meta": {"hexsha": "d646506cfe1410b0c2e8e229f75421f3853b6782", "size": 7412, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aux/ristretto/ristretto.tex", "max_stars_repo_name": "otrv4/little-Ed448-Goldilocks-", "max_stars_repo_head_hexsha": "1c9b89ed9cfc0dd180dd230aaa142b731e502b18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-05-18T19:05:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-22T15:43:16.000Z", "max_issues_repo_path": "aux/ristretto/ristretto.tex", "max_issues_repo_name": "otrv4/little-Ed448-Goldilocks-", "max_issues_repo_head_hexsha": "1c9b89ed9cfc0dd180dd230aaa142b731e502b18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2018-03-15T22:10:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-11T16:37:55.000Z", "max_forks_repo_path": "aux/ristretto/ristretto.tex", "max_forks_repo_name": "otrv4/little-Ed448-Goldilocks-", "max_forks_repo_head_hexsha": "1c9b89ed9cfc0dd180dd230aaa142b731e502b18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-03-15T22:20:38.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-02T11:34:31.000Z", "avg_line_length": 52.9428571429, "max_line_length": 543, "alphanum_fraction": 0.670264436, "num_tokens": 2802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879992, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4361090509559388}}
{"text": "\\revise{}{\n\\section{Fabrication}\nIn order to accurately manufacture adaptive width toolpaths using an off-the-shelf 3D printing system,\nwe need a model which relates the required width to process parameters such as movement speed and filament extrusion speed.\nA different approach might be appropriate depending on whether the filament feeder is mounted directly on the print head (a.k.a. \\emph{direct drive}) or the filament fed from the back of the printer to the print head via a \\emph{Bowden tube}.\nBecause Bowden style 3D printing systems have the filament feeder relatively far away from the nozzle, changing the internal pressure in the system requires a large amount of filament movement, which requires a prohibitive amount of time.\n\n\\subsection{Back pressure compensation}\nBecause changing the internal pressure is difficult in our setup,\nwe keep the internal pressure constant, and vary the movement speed instead.\n%In order to accurately realize a varying bead width we vary the movement speed, while keeping the internal pressure in the system constant.\nOne approach would be\\revise{}{ to} keep the filament inflow $f$ (in \\si{\\milli\\meter\\cubed\\per\\second}) constant by varying movement speed accordingly \\cite{Kuipers2018}.\nHowever, that doesn't result in the intended filament outflow variation - see \\cref{zero_back_pressure}.\nWe conjecture that the filament outflow is related to the total pressure in the system,\nwhich depends not only on the amount of filament in between the feeder wheel and the nozzle (which we keep constant), \nbut also depends on the back pressure that the previous layer exerts on the filament protruding from the nozzle.\nThe amount of back pressure is most likely monotonically related to the requested line width.\nWe compensate for the back pressure using a simple linear model:\n\n\\begin{align}\n v(w) &= \\frac{f(w)}{h w} \\\\ \n% f &\\sim p \\\\\n% p &= p_\\text{in} + p_\\text{ext} \\\\\n% p_\\text{in} &= C \\\\\n% p_\\text{ext} &\\sim w \\\\\n% p_\\text{ext} &= w / w^* - 1 \\\\\n% f &= f^* - k p_\\text{ext} \\\\\n f(w) &= f_0 - k \\left( w / w_0 - 1 \\right)\n % f_0 &= v_0 w_0 h \n% v &= \\frac{f^* - k p_\\text{ext}}{h w} \\\\ \n% v &= \\frac{v^* w^* h - k (w / w^* - 1)}{h w}\n\\end{align}\nwhere\n$v(w)$ is the movement speed as a function of requested bead width $w$,\n$f(w)$ is the filament outflow,\n$f_0$ is a constant reference flow,\n$w_0$ is a constant reference bead width\nand\n$k$ is the amount of back pressure compensation.\n\n% adapted from 5.5 Discussion on implications\n% limitations of back pressure compensation\nOur back pressure compensation method effectively changes the speed to realize adaptive width,\nbut this approach is limited, since the movement speed is constrained by acceleration considerations near bends in the toolpath~\\cite{Ertay2018}.\nMoreover, as the layer height is decreased the back pressure becomes larger compared to the internal pressure, which might cause the back pressure compensation method to demand prohibitively slow movement speeds.\nFurthermore, the shape and filling of the previous layer might influence the amount of back pressure.\n%\n% direct drive & pressure advance\nAccurate flow control can be further enhanced by using a direct drive hardware system and by employing \\emph{pressure advance algorithms} which dynamically change the internal pressure \\cite{tronvoll2019investigating}.\nConversely such a setup might benefit from some form of back pressure compensation as well.\n\n\\subsection{Print results}\\label{print_results_section}\nUsing increments of $0.1$ we established that using a factor of $k=1.1$ yields satisfactory bead width variation for our setup where we use\n$f_0 = v_0 w_0 h $\nwith\n$v_0=\\SI{30}{\\milli\\meter\\per\\second}$, \n$w_0=\\SI{0.4}{\\milli\\meter}$\nand\n$h=\\SI{0.1}{\\milli\\meter}$.\nSee \\cref{back_pressure}.\nThe fact that the printed lines are wider than intended is compensated for using a flow reduction to \\SI{90}{\\percent}.\n%\nTest prints were performed on an unmodified Ultimaker S5 system,\nwith a standard  \\SI{0.4}{\\milli\\meter} nozzle\nand PLA filament.\nThe printing order is determined greedily by choosing the closest point of a polygonal extrusion path, or the closest of either end point in case of an open polyline extrusion path.\nBecause the machine instructions file format \\emph{G-code} doesn't natively support adaptive width beads,\nwe discretize adaptive width extrusions into \\SI{0.2}{\\milli\\meter} long segments of the average width.\nThe print results can be viewed in \\cref{prints}.\n\n\n\\begin{figure}\n\\centering\n\\setlength{\\figwidth}{0.32\\columnwidth}\n\\setlength{\\figheight}{0.5\\columnwidth}\n\\begin{subfigure}[t]{\\figwidth}\\centering\n\\includegraphics[angle=90,height=\\figheight]{sources-validation-backpressure_0_0}\n\\caption{$k=0$}\\label{zero_back_pressure}\n\\end{subfigure}\n\\begin{subfigure}[t]{\\figwidth}\\centering\n\\includegraphics[angle=90,height=\\figheight]{sources-validation-backpressure_1_1}\n\\caption{$k=1.1$}\\label{back_pressure}\n\\end{subfigure}\n\\begin{subfigure}[t]{\\figwidth}\\centering\n\\includegraphics[angle=90,height=\\figheight]{sources-validation-backpressure_2_0}\n\\caption{$k=2.0$}\\label{too_much_back_pressure}\n\\end{subfigure}\n\\caption{\nPrint results (black) of the varying width test on top of a dense white raft.\nTarget widths in green.\n\\subref{zero_back_pressure} Simple flow equalization without back pressure compensation results in nearly constant bead widths.\n\\subref{back_pressure} A value of $k=1.1$ seems to produce good results.\n}\n\\label{back_pressure_compensation}\n\\end{figure}\n\n% discussion of print results\nIn \\cref{print_naive} the underfill problem of the naive uniform offset approach is most prevalent for the Ultimaker word mark, which negatively impacts the visual quality and the stiffness of the part.\nMoreover, in the case of the spatially graded honeycomb\\revise{}{,} there are several fully disconnected hexagons, which means the object falls apart when picked up.\nThe honeycomb print is also missing all parts which are slightly more thin than the preferred bead width $w^*$.\n\\Cref{print_center} still shows some underfill, but considerably less than the uniform approach.\nThese prints also exhibit dark regions where the translucency of the layer is less because the bead is higher.\nThis can be explained by inaccuracies in the back pressure compensation method, which arise for bead widths which deviate from the preferred width by a large amount.\n\\Cref{print_inward} diminishes the underfill nearly completely and the visual quality of these prints is more homogenous than those of the other methods.\nMoreover, the absence of dark regions signifies that our proposed method is more robust against inaccuracies in the deposition system.\nHowever, both the centered and inward distributed approach introduce transitions to a different bead count in the word `Delft', which reduces the dimensional accuracy on the outline around those locations.\n\n\\begin{figure}\n\\centering\n\\setlength{\\figwidth}{\\columnwidth}\n\\begin{subfigure}{\\figwidth}\\centering\n\\includegraphics[width=\\figwidth]{sources-applications-result-prints-target}\n\\caption{Outlines}\\label{print_outlines}\n\\end{subfigure}\n\\begin{subfigure}{\\figwidth}\\centering\n\\includegraphics[width=\\figwidth]{sources-applications-result-prints-naive-bw.png}\n\\caption{Uniform}\\label{print_naive}\n\\end{subfigure}\n\\begin{subfigure}{\\figwidth}\\centering\n\\includegraphics[width=\\figwidth]{sources-applications-result-prints-center-bw.png}\n\\caption{Centered}\\label{print_center}\n\\end{subfigure}\n\\begin{subfigure}{\\figwidth}\\centering\n\\includegraphics[width=\\figwidth]{sources-applications-result-prints-inward-bw.png}\n\\caption{Inward distributed}\\label{print_inward}\n\\end{subfigure}\n\\caption{\nTest shapes printed using the uniform scheme, centered scheme and the inward distributed scheme.\nThe uniform technique produces distinct underfill areas.\nThe centered scheme shows some defects due to inaccurate control of extreme deposition widths.\nThe inward distributed scheme produces the least defects.\n}\n\\label{prints}\n\\end{figure}\n\n\n}\n", "meta": {"hexsha": "5b2a13987c475789673990c2f6ac7e560f77a1fd", "size": 8006, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6_2_printing_results.tex", "max_stars_repo_name": "BagelOrb/variable_width_paper", "max_stars_repo_head_hexsha": "8b8b7a2b9b913e56267a578d2a15ed7e97fa3503", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-23T10:22:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-23T10:22:42.000Z", "max_issues_repo_path": "6_2_printing_results.tex", "max_issues_repo_name": "BagelOrb/variable_width_paper", "max_issues_repo_head_hexsha": "8b8b7a2b9b913e56267a578d2a15ed7e97fa3503", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6_2_printing_results.tex", "max_forks_repo_name": "BagelOrb/variable_width_paper", "max_forks_repo_head_hexsha": "8b8b7a2b9b913e56267a578d2a15ed7e97fa3503", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.0144927536, "max_line_length": 242, "alphanum_fraction": 0.7876592556, "num_tokens": 1966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.43610905095593877}}
{"text": "\\documentclass[10pt, letterpaper]{article}\r\n\\usepackage[cm]{fullpage}\r\n\\usepackage{algpseudocode}\r\n\\usepackage{algorithm}\r\n\\usepackage{graphicx}\r\n\\usepackage[section]{placeins}\r\n\\usepackage[table]{xcolor}\r\n\\usepackage{amsmath}\r\n\\usepackage[margin=0.7in]{geometry}\r\n\\usepackage{comment}\r\n\\usepackage{wrapfig}\r\n\\usepackage[demo]{graphicx}\r\n\r\n\\algrenewcommand\\Return{\\State \\algorithmicreturn{} }%\r\n\r\n\\title{Tetanus - A Batch GCD RSA Cracker}\r\n\\author{Daiwei Chen \\and Cole Houston}\r\n\\date{\\today}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\\begin{abstract}\r\nRSA is a widely used system for modern public key cryptography. It can be extremely secure, but there are several ways in which it can be implemented poorly. One such way is through weak generation of keys. This can happen when the seed used in the generation of the keys is not entirely random, which is the weakness that our program exploits. If several keys have the same seed, it is possible to deduce one of the prime numbers contained in the private key from the public key.  From there, it is possible to recreate the entire private key that should never be seen by the public in a strong implementation of RSA.\r\n\\end{abstract}\r\n\r\n\\section{RSA}\r\nLet's quickly go over RSA, how it is possible to break it. RSA is usually cryptographically secure due to the complexity and difficulty to factor very, very large prime numbers. However, within the Public Component of RSA contains $N$, a result of the product between two (usually) large primes $p$ and $q$. However, if one could efficiently calcualte $p$ and $q$ from $N$, then it will be possible to reconstruct a RSA Private key. \\\\\r\n\\\\\r\nThis means it is possible to perform Man In the Middle attacks against the cracked RSA Private Key target. Decrypt TLS encrypted traffic, or even authenticate SSH using the public key as well. Essentially, you become your target.\r\n\r\n\\section{Batch GCD}\r\n\r\n\\begin{wrapfigure}{r}{0.5\\textwidth}\r\n  \\begin{center}\r\n    \\includegraphics[width=0.48\\textwidth]{batch-gcd-tree.png}\r\n  \\end{center}\r\n  \\caption{The Batch GCD Trees, being created and used.}\r\n\\end{wrapfigure}\r\n\r\nBatch GCD is split into 3 main components: creation of the product tree, creation of the remainder tree, and finally, the GCD process.\r\n\r\n\\begin{enumerate}\r\n\\item Creation of the product tree. \\\\\r\n  The base of the product tree is simply the RSA moduli. The product tree is created by multiplying 2 numbers to create a new layer, and keep multiplying every next 2 numbers together till you run out of numbers. On odd layers, simply add the final number to the end. Stop creating more layers until you reach the final number.\r\n\\item Creation of the remainder tree. \\\\\r\n  The remainder tree is created by first using the final number of the product tree. Then, for each new layer, the $i/2$th product number in that layer is modded to with then $i$th number on the next layer of the product tree squared. This is a faster version of Batch-GCD, in the slower version, you simply create the final layer of the remainder tree by modding the final product tree number to each moduli.\r\n\\item Performing the GCD. \\\\\r\n  Finally, for each moduli, find the GCD between each number on the final layer of the remainder tree divide by the modulus and the modulus itself.\r\n\\end{enumerate}\r\n\r\nThe complexity of Batch-GCD is $O(n(\\lg{n})^2 \\lg{\\lg{n}})$ for the entire process.\r\n\r\n\\section{Reconstruction}\r\nAfter vulnerable keys are identified by batch GCD, it is possible to reconstruct the RSA private key. $N$ is publicly available via the public key, and the batch GCD algorithm reveals either $p$ or $q$.  Since $N$ divided by $p$ will give you $q$, at this point all three numbers are available. The rest of the numbers needed for the private key are $e$, $d$, exponent 1, exponent 2, and coefficient.  $e$ can be found within the public key, so it is already available. $d$ can be calculated via an inverse modulus on (p-1)*(q-1). Exponent 1 can be found with d mod (p-1), and the second exponent is calculated the same way but with q rather than p. Lastly, the coefficient is found by (inverse of q) mod p. With those numbers, it is possible to reconstruct the entire RSA private key.\r\n\r\n\\section{Experimental Setup}\r\nWe have collected about 22,000 keys all together from 2 main sources for this project. First, we grabbed a datadump of about 10,000 moduli from a 2016 scan containing vulnerable moduli off the internet. Next, using a in-house tool tScanner, which performs TLS Handshakes with HTTPS servers to extract the certificate. Then, it extracts the public componet $N$ for Tetanus to attempt Batch-GCD cracking. The 12,000 keys were collected from about 2 entire days of scanning on one computer. The moduli are output by tScanner are all uniq, since duplicate moduli could raise a false positive for Tetanus.\\\\\r\n\\\\\r\nAll moduli and gcd are saved and processed in hex. Within Rust, we used the Rug crate for arbitrary large number processing and math operations. The benchmark process is done on a single thread of an Intel i5-7200U (3.1 GHz), and 8 GB of ram with 8 GB of swap on SSD. \r\n\r\n\\section{Results}\r\n\\begin{figure}[htp]\r\n  \\begin{center}\r\n    \\includegraphics[scale=0.8]{batch-gcd-time.png}\r\n    \\caption{Results for n and t (in seconds)}\r\n  \\end{center}\r\n\\end{figure}\r\n\r\n\\section{Conclusions}\r\nBatch-GCD works better with more keys, since there will be a higher chance of finding a GCD. However, network, memory, and storage is an issue; we simply just don't have enough time and resources to do a check of the entire IPv4 range. Once vulnerable keys are found, it is quick and easy to recreate the private key. Since it is not certain whether p or q is returned by Batch-GCD there are two possible private keys to reconstruct for each vulnerable key. Judging from the difference in the number of vulnerable keys found via the 2016 scan versus our 2019 scan there are fewer vulnerable keys in the world today. This is somewhat thanks to other exploits that have forced people to update their systems, but there are still several keys in the world that are vulnerable to the Batch-GCD attack.\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "96695930d2e6e42679330c2df2e2b8a19dc44d9f", "size": 6132, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/tetanus-paper.tex", "max_stars_repo_name": "ForeverAnApple/Tetanus", "max_stars_repo_head_hexsha": "12e30439c247952e7b77f93b640611b85f2c5461", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-04-29T05:50:16.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-10T20:23:18.000Z", "max_issues_repo_path": "paper/tetanus-paper.tex", "max_issues_repo_name": "ForeverAnApple/Tetanus", "max_issues_repo_head_hexsha": "12e30439c247952e7b77f93b640611b85f2c5461", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/tetanus-paper.tex", "max_forks_repo_name": "ForeverAnApple/Tetanus", "max_forks_repo_head_hexsha": "12e30439c247952e7b77f93b640611b85f2c5461", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-26T02:05:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-26T02:05:52.000Z", "avg_line_length": 82.8648648649, "max_line_length": 798, "alphanum_fraction": 0.7656555773, "num_tokens": 1481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.4360275716508343}}
{"text": "\\documentclass{standalone}\n\n\\begin{document}\n\n\\chapter*{Appendix D - Multi-Class Performances}\\addcontentsline{toc}{chapter}{Appendix C - Multi-Class Performances}\n\\markboth{Appendix D}{Scorer}\n\n\\begin{center}\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[width=0.6\\textwidth]{scorer_net.png}\n\\caption{Multi classes score interaction graph.\nEach node identifies a different performance evaluator and the links are given by the interactions between mathematical formulations of each quantity.\nThe graph has more than 100 nodes and more than 200 links.\nThe node colors are given by the classes identified in the work of Sepand et al.~\\cite{PyCM}.\n}\n\\label{fig:scorer_net}\n\\end{figure}\n\\end{center}\n\nThe performances evaluation is a crucial task in any Machine Learning application.\nGiven a set of patterns and its corresponding (true) labels, we can evaluate the efficiency of a given model with a comparison between labels and model outputs, i.e the predicted labels.\nThere are a lot of different score functions that can be computed and each of them evaluates some aspects of the model efficiency.\nAny paper author choses the score that better highlights the advantages of its model and it is difficult to move around this large zoo of indicators.\nMoreover, (it is quite a constant in scientific research) when a paper is send to a peer-review, in many cases the reviewers suggest to check if other performance indicators are good enough for the showed results.\nThis means that a lot of large simulations should be performed again and the appropriate variables recomputed to obtain the required scores.\n\nAt this point the main question is: are these scores totally independent one from each other?\nThe brief answer is simply no.\nIn a very interesting work of Sepand et al.~\\cite{PyCM} the authors show how we can compute a wide range of these scores starting from the evaluation of the simple confusion matrix\\footnote{\n  The confusion matrix is a square matrix of shapes $(N, N)$, with $N$ the total number of classes in the current problem, whose entries are the number of right and false classifications.\n  In particular, each entry of the matrix represents the predicted instances in a given class.\n  If the class is the right one we call it as true positive item.\n  As counterpart we have a false positive item.\n}, providing a full mathematical documentation and references about their numerical evaluations.\n\nDespite the \\textsf{Python} code provided by Sepand et al. explains these links between the mathematical quantities, they stop their analyses on the score evaluations, without any interest on the optimization of these computations.\nStarting from their work we analyzed the inter-connections between these mathematical formulas and we extracted the dependencies between the involved variables.\nIn particular, a score function can be interpreted as a node and its connections could be given by the variables needed to evaluate it.\nThis type of graphs are commonly called \\href{https://en.wikipedia.org/wiki/Factor_graph}{\\emph{factor graphs}}.\nIn a mathematical formulation of \\emph{factor graphs} there are different kinds of nodes (variables and factors, or equations).\nThe focus of our analysis was not on the mathematical formalism of these kinds of graphs, but we aimed to a visualization of function interactions and an analysis of the numerical improvements derived from it.\n\nIn the work of Sepand et al. the authors identify three function classes: common statistics, class statistics and overall statistics.\nIn Fig.~\\ref{fig:scorer_net} the interaction graph of these three classes is shown.\nThe figure shows deep interactions between the three function classes and it highlights the dependencies of the different quantities involved.\nWe can also use this kind of visualization to formulate computational considerations about the order in which these quantities could be evaluated.\nSince the graph is a direct graph by definition, we can start from the root node (the node without links which bring to it) and cross the network up to the leaf nodes (nodes without links which go out from them) like in a tree-graph (or more precisely a DAG, \\emph{Direct Acyclic Graph}).\nAt each step of the percolation, the incoming nodes identify totally independent quantities.\nThis independence means that the node-quantities can be potentially computed in parallel.\nTo clarify this consideration we can reorganize the graph visualization minimizing the link lengths and obtaining a stratified graph in which each level identifies a potential parallel section.\nA graph with these properties was obtained using the \\textsf{dot} visualization and it is shown in Fig.~\\ref{fig:scorer_parallel}.\nAs can be seen in the figure we can identify 7 levels in the graph and thus 7 potential parallel regions for the computation of the full set of functions.\n\n\\begin{center}\n\\begin{figure}[htbp]\n\\hspace{-2cm}\n\\includegraphics[width=1.3\\textwidth]{scorer_parallel.pdf}\n\\caption{Re-organization of the graph in Fig.~\\ref{fig:scorer_net}.\nThe rendering was obtained using the \\textsf{dot} visualization, i.e the minimization of the link lengths.\nThe direct graph identifies the tree of dependencies and each level of the tree represents a set of independent functions that can be potentially computed in parallel.\nThis graph is used as parallel scheme for the \\textsf{Scorer} library.\n}\n\\label{fig:scorer_parallel}\n\\end{figure}\n\\end{center}\n\nThese considerations allow us to create an optimized version of the code of Sepand et al., the \\textsf{Scorer} library~\\cite{Scorer}.\nThe \\textsf{Scorer} library is the \\textsf{C++} porting of the \\textsf{PyCM} library of Sepand et al. with a \\textsf{Cython} wrap for the \\textsf{Python} compatibility.\nFollowing the above told graph, the computation of score quantities are performed in parallel according to the 7 levels found.\nThe parallelization strategy chosen uses the \\textsf{section} keywords of OpenMP library to perform no-wait tasks that are computed by each thread of the parallel region.\n\nThe extracted graph includes more than 100 different quantities so writing the full set of parallel sections becomes an hard (and boring) work in \\textsf{C++}.\nMoreover, update the graph with new quantities brings to a consequential update of the full code and also of the parallelization strategy.\nEach function was written as an anonymous-struct, i.e a functor, with an appropriate operator overloading.\nEach functor has a name given by a pre-determined regex (\\textsf{get\\_\\{function\\}}) and the list of arguments follows the same nomenclature\\footnote{\n  If the functor receives in input the variable $A$ and $B$ we have to ensure that two functors named $get\\_A$ and $get\\_B$ will be provided.\n  The only exception is given by the root functor.\n}.\nWith these expedients we created a fully automated \\textsf{Python} script which parses the list of functors, it computes the dependency graph and the parallelization levels and it gives back a compilable \\textsf{C++} script with the desired characteristics.\nIn this way we can guarantee an easy way to update the library and moreover we overcome the boring writing of a long code.\nThe automatic creation script is provided in the \\textsf{Scorer} library and it should be used at each pull request or version update.\n\nFor a pretty/useful visualization of the computed quantities we rendered the interaction graph in an HTML framework.\nIn this way we can insert with a CSS table the computed values in each node that can be discovered passing the mouse over the figure.\nAn example of this rendering is given in the on-line version of the library~\\cite{Scorer}.\n\nIn conclusion the developed \\textsf{Scorer} library is a very powerful tool for Machine Learning performances evaluation which can be used either in \\textsf{C++} either in \\textsf{Python} codes through its \\textsf{Cython} wrap.\nThe code is automatically generated at each update and automatically tested using continuous integration for any platform using \\href{https://github.com/Nico-Curti/scorer/blob/master/.travis.yml}{Travis CI} and \\href{https://github.com/Nico-Curti/scorer/blob/master/appveyor.yml}{Appveyor CI}\\footnote{\n  We perform tests for Unix and Windows environments.\n  We check more than 15 combinations of environments and compilers.\n}.\nThe code can be compiled using \\href{https://github.com/Nico-Curti/scorer/blob/master/CMakeLists.txt}{\\textsf{CMakefile}} or \\href{https://github.com/Nico-Curti/scorer/blob/master/Makefile}{\\textsf{Makefile}} and a \\href{https://github.com/Nico-Curti/scorer/blob/master/setup.py}{\\textsf{setup.py}} is provided for the \\textsf{Python} version.\nSo when you write a new paper on Machine Learning and you do not know what could be the most appropriate indicator to show in your research or you are afraid that a referee could ask you to compute an other one there is only one solution: compute them all using \\textsf{Scorer}.\n\n\n\\end{document}\n", "meta": {"hexsha": "8c26fea2ad0347540996b6e23bb7afa7d20eb4c7", "size": 8951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Appendix/Scorer/Intro.tex", "max_stars_repo_name": "Nico-Curti/PhDthesis", "max_stars_repo_head_hexsha": "234b38234eb15870056f71c4f33946d8aed05aae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-03-17T14:01:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-04T10:21:41.000Z", "max_issues_repo_path": "tex/Appendix/Scorer/Intro.tex", "max_issues_repo_name": "Nico-Curti/PhDthesis", "max_issues_repo_head_hexsha": "234b38234eb15870056f71c4f33946d8aed05aae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Appendix/Scorer/Intro.tex", "max_forks_repo_name": "Nico-Curti/PhDthesis", "max_forks_repo_head_hexsha": "234b38234eb15870056f71c4f33946d8aed05aae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-05-09T13:17:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-09T15:16:46.000Z", "avg_line_length": 91.3367346939, "max_line_length": 343, "alphanum_fraction": 0.8016981343, "num_tokens": 1955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.731058578630005, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.43602756815603894}}
{"text": "\\documentclass{article}\n\n\\usepackage{xcolor}\n\\usepackage{mathpartir}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{amssymb}\n\\usepackage{latexsym}\n\\usepackage{stmaryrd}\n\\usepackage{fullpage}\n\\usepackage{subcaption}\n\\usepackage{tikz}\n\n\n\\input{macros}\n\\newcommand{\\mypar}[1]{\\vspace{0.2cm}\\paragraph{#1:} \\hfill\\vspace{0.1cm}}\n\n\\newtheorem{theorem}{Theorem}\n\n\\begin{document}\n\\section{Syntax}\n\\mypar{Syntax of source language, $F_{MP}^{+}$}\n\\noindent\\begin{tabular}{l r r l}\n    Types        & $A, B$   & $::=$ & $\\tau~\\mid~A \\to B~\\mid~A \\& B~\\mid~\\textcolor{magenta}{\\Tabs{\\alpha}{A}{B}}~\\mid~\\trecord{l}{A}$\\vspace{0.3cm}\\\\\n    Monotypes    & $\\tau$   & $::=$ & $\\nat~\\mid~\\top~\\mid~\\textcolor{magenta}{\\alpha}~\\mid~\\tau_1\\to\\tau_2~\\mid~\\tau_1\\&\\tau_2~\\mid~\\trecord{l}{\\tau}$ \\vspace{0.3cm}\\\\\n    Expressions  & $E$      & $::=$ & $i~\\mid~()~\\mid~x~\\mid~\\abs{x}{E}~\\mid~E_1\\,E_2~\\mid~E_1,,E_2~\\mid~E : A~\\mid~\\record{l}{E}~\\mid~E.l$\\vspace{0.1cm}\\\\\n                 &          &       & $\\textcolor{magenta}{\\tabs{\\alpha}{A}{E}}~\\mid~\\textcolor{magenta}{E\\,A}$\\vspace{0.3cm}\\\\\n    Type context & $\\Delta$ & $::=$ & $\\bullet~\\mid~\\Delta,\\tentry{\\alpha}{A}$\n  \\end{tabular}\n%% \\klara{Is there a reason to exclude intersection types from monotypes?}\n\n\\mypar{Syntax of target language}\n\\noindent\\begin{tabular}{l r r l}\n    Types        & $\\rho$   & $::=~$ & $\\nat~\\mid~\\top~\\mid~\\alpha~\\mid~\\rho_1 \\to \\rho_2~\\mid~\\rho_1 \\times \\rho_2~\\mid~\\alpha~\\mid~\\forall{\\alpha}.{\\rho}~\\mid~\\trecord{l}{\\rho}$ \\vspace{0.3cm}\\\\\n    Expressions  & $e$      & $::=~$ & $i~\\mid~()~\\mid~x~\\mid~\\abs{x}{e}~\\mid~e_1\\,e_2~\\mid~e_1 , , e_2~\\mid~c\\,e~\\mid~\\Lambda{\\alpha}.{e}~\\mid~e\\,\\rho~\\mid~\\record{l}{e}~\\mid~e.l$ \\vspace{0.3cm}\\\\\n    Coercions    & $c$      & $::=~$ & $\\idC{\\rho}~\\mid~\\topC{\\rho}~\\mid~\\topArrC~\\mid~\\topAllC~\\mid~\\distArrC{\\rho_1}{\\rho_2}{\\rho_3}~\\mid~\\distRecC{l}{\\rho_1}{\\rho_2}~\\mid~\\projlC{\\rho_1}{\\rho_2}~\\mid~\\projrC{\\rho_1}{\\rho_2}~\\mid$\\vspace{0.1cm}\\\\\n                 &          & & $\\mpC{c_1}{c_2}~\\mid~\\compC{c_1}{c_2}~\\mid~\\pairC{c_1}{c_2}~\\mid~\\arrC{c_1}{c_2}~\\mid~\\textcolor{magenta}{\\alllC{c}{\\rho}}~\\mid~\\textcolor{magenta}{\\allrC{\\alpha}{c}}~\\mid~\\trecord{l}{c}$\\vspace{0.3cm}\\\\\n    Type context & $\\Phi$   & $::=~$ & $\\bullet~\\mid~\\Phi,\\alpha$\\vspace{0.1cm}\\\\\n    Term context & $\\Psi$   & $::=~$ & $\\bullet~\\mid~\\Psi,\\eentry{x}{\\rho}$\n  \\end{tabular}\n\n\\vspace{1cm}\n\\paragraph{Helper definitions:}\nDesugaring of new coercion operators into target functions.\n\\begin{align*}\n  \\trecord{l}{c}    &= \\abs{x}{\\record{l}{c\\,x}}\\\\\n  \\alllC{c}{\\rho}   &= \\abs{x}{(c\\,(x\\,\\rho))}\\\\\n  \\allrC{\\alpha}{c} &= \\abs{x}{\\tabst{\\alpha}{c\\, x}}\n\\end{align*}\n\n\\section{Declarative Specification}\n\\subsection{Declarative bidirectional typing}\n%% \\subsubsection{Declarative bidirectional typing}\n\\fbox{\n\\begin{mathpar}\n  \\inferrule*[right=TS-top]{\\wfContext{\\Gamma}}{\\synthmode{\\Gamma}{()}{\\top}{()}} \\and\n  \\inferrule*[right=TS-nat]{\\wfContext{\\Gamma}}{\\synthmode{\\Gamma}{i}{\\nat}{i}} \\and\n  \\inferrule*[right=TS-var]{\\wfContext{\\Gamma}\\\\(\\eentry{x}{A})\\in\\Gamma}{\\synthmode{\\Gamma}{x}{A}{x}} \\and\n  \\inferrule*[right=TS-Rcd]{\\synthmode{\\Gamma}{E}{A}{e}}{\\synthmode{\\Gamma}{\\record{l}{E}}{\\trecord{l}{A}}{\\record{l}{e}}}\\and\n  \\inferrule*[right=TS-Proj]{\\synthmode{\\Gamma}{E}{\\trecord{l}{A}}{e}}{\\synthmode{\\Gamma}{E.l}{A}{e.l}}\\and\n  \\inferrule*[right=TS-app]{\\synthmode{\\Gamma}{E_1}{A\\to B}{e_1}\\\\ \\checkmode{\\Gamma}{E_2}{A}{e_2}}{\\synthmode{\\Gamma}{E_1\\,E_2}{B}{e_1\\,e_2}} \\and\n  \\inferrule*[right=TS-anno]{\\checkmode{\\Gamma}{E}{A}{e}}{\\synthmode{\\Gamma}{E:A}{A}{e}} \\and\n  \\inferrule*[right=TS-merge]{\\synthmode{\\Gamma}{E_1}{A_1}{e_1}\\\\ \\synthmode{\\Gamma}{E_2}{A_2}{e_2}\\\\ \\udisjoint{\\Gamma}{A\\& B}}{\\synthmode{\\Gamma}{E_1,,E_2}{A_1\\& A_2}{\\pairC{e_1}{e_2}}}\\and\n  %% \\nrule{TS-abs}{\\checkmode{\\Gamma,\\tentry{\\hat\\alpha}{\\top},\\tentry{\\hat\\beta}{\\top},\\eentry{x}{\\hat\\alpha}}{E}{\\hat\\beta}{e}{\\Gamma',\\eentry{x}{\\hat\\alpha},\\Theta}\\\\\\fresh{\\hat\\alpha,\\hat\\beta}}{\\synthmode{\\Gamma}{\\abs{x}{E}}{\\hat\\alpha\\to \\hat\\beta}{\\abs{x}{e}}{\\Gamma'}}\\and\n  \\inferrule*[right=TS-Tabs]{\\synthmode{\\Gamma,\\tentry{\\alpha}{A}}{E}{B}{e}}{\\synthmode{\\Gamma}{\\tabs{\\alpha}{A}{E}}{\\Tabs{\\alpha}{A}{B}}{\\Lambda\\alpha.e}}\\and\n  \\inferrule*[right=TS-Tapp]{\\synthmode{\\Gamma}{E}{\\Tabs{\\alpha}{A}{B}}{e}\\\\ \\disjoint{\\Gamma}{A}{A'}}{\\synthmode{\\Gamma}{E\\,A'}{[\\substitution{\\alpha}{A'}]B}{e\\,\\toTarget{A'}}}\n\\end{mathpar}\n}\n\\fbox{\n\\begin{mathpar}\n  \\inferrule*[right=TC-abs]{\\wfT{\\Gamma}{A}\\\\\\checkmode{\\Gamma,\\eentry{x}{A}}{E}{B}{e}}{\\checkmode{\\Gamma}{\\abs{x}{E}}{A\\to B}{\\abs{x}{e}}} \\and\n  \\inferrule*[right=TC-sub]{\\synthmode{\\Gamma}{E}{A}{e}\\\\ \\Subtype{\\Gamma}{A}{B}{c}}{\\checkmode{\\Gamma}{E}{B}{c\\,e}}\\and\n\\end{mathpar}\n}\n%% \\fbox{\n%% \\begin{mathpar}\n%%   \\inferrule*[right=T-..]{\\checkmode{\\Gamma,\\eentry{x}{A_1}}{E}{A_2}{e}{\\Gamma',\\eentry{x}{A_1},\\Theta}}{\\checkmode{\\Gamma}{\\abs{x}{E}}{A_1\\to A_2}{\\abs{x}{e}}{\\Gamma'}} \\and\n%%   \\inferrule*[right=T-sub]{\\synthmode{\\Gamma}{E}{A}{e}{\\Theta}\\\\ \\ldots }{\\checkmode{\\Gamma}{E}{B}{c\\,e}{\\Gamma'}}\n%% \\end{mathpar}\n%% }\n\n\\subsection{Declarative Disjointness}\n%% \\mypar{Disjointness - Declarative}\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule*[right=D-TopL]{ }{\\disjoint{\\Delta}{\\top}{A}} \\and\n%    \\inferrule*[right=D-TopR]{ }{\\disjoint{\\Delta}{A}{\\top}} \\and\n    %% \\inferrule*[right=D-Arr]{\\disjoint{\\Delta}{A_2}{B_2}}{\\disjoint{\\Delta}{A_1\\to A_2}{B_1\\to B_2}} \\and\n    \\inferrule*[right=D-ArrL]{\\disjoint{\\Delta}{A_2}{B}}{\\disjoint{\\Delta}{A_1\\to A_2}{B}} \\and\n%    \\inferrule*[right=D-ArrR]{\\disjoint{\\Delta}{A}{B_2}}{\\disjoint{\\Delta}{A}{B_1\\to B_2}} \\and\n    \\inferrule*[right=D-AndL]{\\disjoint{\\Delta}{A_1}{B} \\\\ \\disjoint{\\Delta}{A_2}{B}}{\\disjoint{\\Delta}{A_1\\& A_2}{B}} \\and\n%    \\inferrule*[right=D-AndR]{\\disjoint{\\Delta}{A}{B_1} \\\\ \\disjoint{\\Delta}{A}{B_2}}{\\disjoint{\\Delta}{A}{B_1\\& B_2}} \\and\n    \\inferrule*[right=D-VarL]{\\tentry{\\alpha}{A}\\in{\\Delta} \\\\ \\subt{A}{B}}{\\disjoint{\\Delta}{\\alpha}{B}} \\and\n%    \\inferrule*[right=D-VarR]{\\tentry{\\beta}{B}\\in{\\Delta} \\\\ \\subt{B}{A}}{\\disjoint{\\Delta}{A}{\\beta}} \\and\n    \\mprset{sep=1em}\n    \\inferrule*[right=D-AllL]{(\\forall \\tau,\\,\\disjoint{\\Delta}{\\tau}{A}\\implies\\disjoint{\\Delta}{[\\alpha\\mapsto\\tau]B_1}{B_2})}{\\disjoint{\\Delta}{\\Tabs{\\alpha}{A}{B_1}}{B_2}}\\and\n%    \\inferrule*[right=D-AllR]{(\\forall \\tau,\\,\\disjoint{\\Delta}{\\tau}{A}\\implies\\disjoint{\\Delta}{B_1}{[\\alpha\\mapsto\\tau]B_2})}{\\disjoint{\\Delta}{B_1}{\\Tabs{\\alpha}{A}{B_2}}}\\and\n    \\inferrule*[right=D-Rec]{\\disjoint{\\Delta}{A}{B}}{\\disjoint{\\Delta}{\\trecord{l}{A}}{\\trecord{l}{B}}} \\and\n    \\inferrule*[right=D-NRec]{l_1\\neq l_2}{\\disjoint{\\Delta}{\\trecord{l_1}{A}}{\\trecord{l_2}{B}}} \\and\n    \\inferrule*[right=D-NatRcd]{ }{\\disjoint{\\Delta}{\\nat}{\\trecord{l}{A}}}\\and\n    \\inferrule*[right=D-Sym]{\\disjoint{\\Delta}{A}{B}}{\\disjoint{\\Delta}{B}{A}}\n    %% \\inferrule*[right=D-ax]{\\starax{A}{B}}{\\disjoint{\\Delta}{A}{B}}\n  \\end{mathpar}\n}\n\\subsubsection{Notes}\n\\mypar{Subsumption of \\textsc{D-Forall} from $F_{i}^{+}$}\nRule \\textsc{D-Forall} of $F_{i}^{+}$ is subsumed by our rules:\n\\[\n\\inferrule*[right=D-forall]\n    {\\disjoint{\\Delta,\\tentry{\\alpha}{A_1\\& B_1}}{A_2}{B_2}}\n    {\\disjoint{\\Delta}{\\Tabs{\\alpha}{A_1}{A_2}}{\\Tabs{\\alpha}{B_1}{B_2}}}\n\\]\nFor any well-formed substitution $\\wfSubst{\\Delta,\\tentry{\\alpha}{A_1\\& B_1}}{\\theta\\circ[{\\alpha}\\mapsto{\\tau_0}]}$,\nit follows by case analysis that $\\wfT{\\Delta}{\\tau_0}$, $\\disjoint{\\Delta}{\\tau_0}{A_1}$ and $\\disjoint{\\Delta}{\\tau_0}{B_1}$.\nApplying $\\theta\\circ[{\\alpha}\\mapsto{\\tau_0}]$ in the premise of \\textsc{D-forall}, yields $\\disjoint{\\theta(\\Delta)}{[{\\alpha}\\mapsto{\\tau_0}]{A_2}}{[{\\alpha}\\mapsto{\\tau_0}]{B_2}}$. In our system,\nthis behaviour is recovered by:\n\\[\n\\inferrule*[right=D-allL($\\tau_0$)]\n           { \\inferrule*{\\text{given}}{\\disjoint{\\Delta}{\\tau_0}{A_1}}\n             \\\\\n             \\inferrule*[right=D-allR($\\tau_0$)]\n                        {\n                          \\inferrule*{\\text{given}}{\\disjoint{\\Delta}{\\tau_0}{B_1}}\n                          \\\\\n                          \\inferrule*\n                              {\\text{given}}\n                              {\\disjoint{\\Delta}{[\\alpha\\mapsto\\tau_0]A_1}{[\\alpha\\mapsto\\tau_0]{B_2}}}\n                        }\n                        {\\disjoint{\\Delta}{[\\alpha\\mapsto\\tau_0]A_1}{\\Tabs{\\alpha}{B_1}{B_2}}}\n           }\n    {\\disjoint{\\Delta}{\\Tabs{\\alpha}{A_1}{A_2}}{\\Tabs{\\alpha}{B_1}{B_2}}}\n\\]\n\n\\subsection{Declarative Subtyping}\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule*[right=S-refl]{ }{\\Subtype{\\Delta}{A}{A}{\\idC{\\toTarget{A}}}} \\and\n    \\inferrule*[right=S-trans]{\\Subtype{\\Delta}{A_1}{A_2}{c} \\\\ \\Subtype{\\Delta}{A_2}{A_3}{c'}}{\\Subtype{\\Delta}{A_1}{A_3}{\\compC{c'}{c}}} \\\\\n    \\inferrule*[right=S-top]{ }{\\Subtype{\\Delta}{A}{\\top}{\\topC{\\toTarget{A}}}} \\and\n    \\inferrule*[right=S-topArr]{ }{\\Subtype{\\Delta}{\\top}{\\top\\to\\top}{\\topArrC}} \\and\n    \\inferrule*[right=S-topAll]{ }{\\Subtype{\\Delta}{\\top}{\\Tabs{\\alpha}{A}{\\top}}{\\topAllC}} \\and\n    \\inferrule*[right=S-and]{\\Subtype{\\Delta}{A}{B_1}{c_1} \\\\ \\Subtype{\\Delta}{A}{B_2}{c_2}}{\\Subtype{\\Delta}{A}{B_1 \\& B_2}{\\pairC{c_1}{c_2}}} \\and\n    \\inferrule*[right=S-andL]{ }{\\Subtype{\\Delta}{A_1\\& A_2}{A_1}{\\projlC{\\toTarget{A_1}}{\\toTarget{A_2}}}} \\and\n    \\inferrule*[right=S-andR]{ }{\\Subtype{\\Delta}{A_1\\& A_2}{A_2}{\\projrC{\\toTarget{A_1}}{\\toTarget{A_2}}}} \\and\n    \\inferrule*[right=S-arr]{\\Subtype{\\Delta}{B_1}{A_1}{c_1}\\\\ \\Subtype{\\Delta}{A_2}{B_2}{c_2}}{\\Subtype{\\Delta}{A_1\\to A_2}{B_1\\to B_2}{\\arrC{c_1}{c_2}}} \\and\n    \\inferrule*[right=S-rcd]{\\Subtype{\\Delta}{A}{B}{c}}{\\Subtype{\\Delta}{\\trecord{l}{A}}{\\trecord{l}{B}}{\\trecord{l}{c}}} \\and\n    \\inferrule*[right=S-mp]{\\Subtype{\\Delta}{A}{B_1\\to B_2}{c_1} \\\\ \\Subtype{\\Delta}{A}{B_1}{c_2}}{\\Subtype{\\Delta}{A}{B_2}{\\mpC{c_1}{c_2}}} \\and\n    \\inferrule*[right=S-distArr]{ }{\\Subtype{\\Delta}{(A\\to B_1)\\&(A\\to B_2)}{A\\to{B_1\\& B_2}}{\\distArrC{\\toTarget{A}}{\\toTarget{B_1}}{\\toTarget{B_2}}}} \\and\n    \\inferrule*[right=S-distRcd]{ }{\\Subtype{\\Delta}{\\trecord{l}{A}\\&\\trecord{l}{B}}{\\trecord{l}{A\\& B}}{\\distRecC{l}{\\toTarget{A}}{\\toTarget{B}}}} \\and\n    \\inferrule*[right=S-allL]{\\disjoint{\\Delta}{\\tau}{A} \\\\ \\Subtype{\\Delta}{[\\alpha\\mapsto\\tau]B}{B'}{c}}{\\Subtype{\\Delta}{\\Tabs{\\alpha}{A}{B}}{B'}{\\alllC{c}{\\tau}}} \\and\n    \\inferrule*[right=S-allR]{\\Subtype{\\Delta,\\tentry{\\alpha}{B_1}}{A}{B_2}{c}}{\\Subtype{\\Delta}{A}{\\Tabs{\\alpha}{B_1}{B_2}}{\\allrC{\\alpha}{c}}}\n  \\end{mathpar}\\hfill\n}\\\\\n\\subsubsection{Notes}\n\\mypar{Predicative instantiation}\nWe use predicative type instantiation (rule \\textsc{S-allL}) to avoid following kind of non-termination, where $\\mathcal{A} :=\\Tabs{\\alpha}{A}{\\alpha\\to\\alpha}$.\nIn the premise of rule \\textsc{S-allL} below, we use substitution $[\\alpha\\mapsto\\mathcal{A}]$.\n\\begin{mathpar}\n  \\inferrule*[right=S-MP]\n             {\n               \\inferrule*[right=S-allL]\n                          {\\disjoint{\\Delta}{\\mathcal{A}}{A}\n                           \\\\\n                           \\inferrule*\n                                      {\\vdots}\n                                      {\\Subtype{\\Delta}{\\mathcal{A}\\to\\mathcal{A}}{\\mathcal{A}\\to\\mathcal{A}}{?}}\n                          }\n                          {\\Subtype{\\Delta}{\\mathcal{A}}{\\mathcal{A}\\to\\mathcal{A}}{\\alllC{?}{\\toTarget{\\mathcal{A}}}}}\n               \\\\\n               \\inferrule*[right=S-refl]\n                          { }\n                          {\\Subtype{\\Delta}{\\mathcal{A}}{\\mathcal{A}}{\\idC{\\toTarget{\\mathcal{A}}}}}\n             }\n             {\\Subtype{\\Delta}{\\mathcal{A}}{\\mathcal{A}}{\\mpC{(\\alllC{?}{\\toTarget{\\mathcal{A}}})}{\\idC{\\toTarget{\\mathcal{A}}}}}}\n\\end{mathpar}\n\n\\mypar{Subsumption of \\textsc{S-DistAll} and \\textsc{S-topAll} from $F_{i}^{+}$}\nRule \\textsc{S-DistAll} of $F_{i}^{+}$ is subsumed by our rules:\n\\begin{mathpar}\n  \\inferrule*\n      {\n        \\inferrule*\n            {\n              \\inferrule*\n                  {\n                    \\inferrule*\n                        {\\disjoint{\\bullet,\\tentry{a}{A}}{a}{A}\n                          \\\\\n                         \\inferrule*{ }{\\Subtype{\\bullet,\\tentry{a}{A}}{[\\alpha\\mapsto\\alpha]B_1}{B_1}{\\idC{\\toTarget{B_1}}}}\n                        }\n                        {\\Subtype{\\bullet,\\tentry{a}{A}}{\\Tabs{\\alpha}{A}{B_1}}{B_1}{\\alllC{\\idC{\\toTarget{B_1}}}{\\alpha}}}\n                    \\\\\n                    \\vdots\n                  }\n                  {\\Subtype{\\bullet,\\tentry{a}{A}}{(\\Tabs{\\alpha}{A}{B_1})\\&(\\Tabs{\\alpha}{A}{B_2})}{B_1}{\\compC{(\\alllC{\\idC{\\toTarget{B_1}}}{\\alpha})}{\\projlC{\\Tabst{\\alpha}{\\toTarget{B_1}}}{\\Tabst{\\alpha}{\\toTarget{B_2}}}}}}\n                  \\\\\n                  \\vdots\n              %% \\inferrule*\n              %%     { }\n              %%     {\\Subtype{\\bullet,\\tentry{a}{A}}{(\\Tabs{\\alpha}{A}{B_1})\\&(\\Tabs{\\alpha}{A}{B_2})}{B_2}{ }}    \n            }\n            {\\Subtype{\\bullet,\\tentry{a}{A}}{(\\Tabs{\\alpha}{A}{B_1})\\&(\\Tabs{\\alpha}{A}{B_2})}{B_1\\&B_2}{\\pairC{\\compC{(\\alllC{\\idC{\\toTarget{B_1}}}{\\alpha})}{\\projlC{\\Tabst{\\alpha}{\\toTarget{B_1}}}{\\Tabst{\\alpha}{\\toTarget{B_2}}}}}{\\compC{(\\alllC{\\idC{\\toTarget{B_2}}}{\\alpha})}{\\projrC{\\Tabst{\\alpha}{\\toTarget{B_1}}}{\\Tabst{\\alpha}{\\toTarget{B_2}}}}}}}\n      }\n      {\\Subtype{\\bullet}{(\\Tabs{\\alpha}{A}{B_1})\\&(\\Tabs{\\alpha}{A}{B_2})}{\\Tabs{\\alpha}{A}{B_1\\&B_2}}{\\allrC{\\alpha}{\\pairC{\\compC{(\\alllC{\\idC{\\toTarget{B_1}}}{\\alpha})}{\\projlC{\\Tabst{\\alpha}{\\toTarget{B_1}}}{\\Tabst{\\alpha}{\\toTarget{B_2}}}}}{\\compC{(\\alllC{\\idC{\\toTarget{B_2}}}{\\alpha})}{\\projrC{\\Tabst{\\alpha}{\\toTarget{B_1}}}{\\Tabst{\\alpha}{\\toTarget{B_2}}}}}}}}\n\\end{mathpar}\n\n\\clearpage\n\\section{Algorithmic Specification}\n\n\\begin{table}[h]\n  \\begin{tabular}{l r r l}\n    Types         & $A, B$   & $::=$ & $\\tau~\\mid~A \\to B~\\mid~A \\& B~\\mid~\\textcolor{magenta}{\\Tabs{\\alpha}{A}{B}}~\\mid~\\trecord{l}{A}$\\vspace{0.1cm}\\\\\n    Monotypes     & $\\tau$   & $::=$ & $\\xi~\\mid~\\tau_1\\to\\tau_2~\\mid~\\tau_1\\&\\tau_2~\\mid~\\trecord{l}{\\tau}$ \\vspace{0.1cm}\\\\\n    Base types    & $\\xi$    & $::=$ & $\\nat~\\mid~\\bool~\\mid~\\top~\\mid~\\textcolor{magenta}{\\alpha}~\\mid~\\textcolor{magenta}{\\hat{\\alpha}}$ \\vspace{0.3cm}\\\\\n    Expressions   & $E$      & $::=$ & $i~\\mid~\\True~\\mid~\\False~\\mid~()~\\mid~x~\\mid~\\abs{x}{E}~\\mid~E_1\\,E_2~\\mid~E_1,,E_2~\\mid$\\vspace{0.1cm}\\\\\n                  &          &       & $E : A~\\mid~\\textcolor{magenta}{\\tabs{\\alpha}{A}{E}}~\\mid~\\textcolor{magenta}{E\\,A}~\\mid\\record{l}{E}~\\mid~E.l$\\vspace{0.3cm}\\\\\n    Type context  & $\\Delta$ & $::=$ & $\\bullet~\\mid~\\Delta,\\tentry{\\alpha}{A}~\\mid~\\Delta,\\tentry{\\hat{\\alpha}}{A}$\\vspace{0.3cm}\\\\\n    Queue         & $\\mathcal{L},\\mathcal{M}$ & $::=$ & $\\bullet~\\mid~\\mathcal{L},A~\\mid~\\mathcal{L},l$\\vspace{0.3cm}\\\\\n    Coercion context & $\\mathcal{C}$ & $::=$ & $\\bullet~\\mid~\\arrCC{\\mathcal{C}}{c}~\\mid~\\projlCC{\\mathcal{C}}{A}{B}~\\mid~\\projrCC{\\mathcal{C}}{A}{B}~\\mid~\\mpCC{\\mathcal{C}}{\\mathcal{M}}{c_1}{A}{B}~\\mid~\\alllCC{\\mathcal{C}}{\\tau}~\\mid~\\recCC{\\mathcal{C}}{l}$\\vspace{0.3cm}\\\\\n    Type variable substitutions & $\\theta$ & $::=$ & $\\bullet~\\mid~\\unification{\\alpha}{A},\\theta~\\mid~\\substitution{\\alpha}{A},\\theta$\\vspace{0.3cm}\n  \\end{tabular}\n  \\caption{The language of the algorithm}\n\\end{table}\n\n\\subsubsection{Coercion context completion}\n\\begin{minipage}[t]{0.7\\textwidth}\n\\begin{align*}\n  \\bullet [c] &= c\\\\\n  (\\arrCC{\\mathcal{C}}{c'})[c] &= \\mathcal{C}[c'\\to c]\\\\\n  \\projlCC{\\mathcal{C}}{A}{B}[c] &= \\mathcal{C}[\\compC{c}{\\projlC{\\toTarget{A}}{\\toTarget{B}}}]\\\\\n  \\projrCC{\\mathcal{C}}{A}{B}[c] &= \\mathcal{C}[\\compC{c}{\\projrC{\\toTarget{A}}{\\toTarget{B}}}]\\\\\n  \\mpCC{\\mathcal{C}}{\\mathcal{M}}{c_1}{A}{B}[c] &= \\compC{\\distarrowqueueC{\\mathcal{M}}{\\left(\\compC{c}{(\\mpC{\\projlC{\\toTarget{A\\to B}}{\\toTarget{A}}}{\\projrC{\\toTarget{A\\to B}}{\\toTarget{A}}})}\\right)}{\\toTarget{A\\to B}}{\\toTarget{A}}}{\\pairC{\\mathcal{C}[\\idC{\\toTarget{A\\to B}}]}{c_1}}\\\\\n  \\alllCC{\\mathcal{C}}{\\tau}[c] &= \\mathcal{C}[\\alllC{c}{\\toTarget{\\tau}}]\\\\\n  \\recCC{\\mathcal{C}}{l}[c] &= \\mathcal{C}[\\trecord{l}{c}]\n\\end{align*}\n\\end{minipage}\n\n\\subsection{Substitutions}\n\\subsubsection{Applying unification variable substitution...}\n\\begin{minipage}[t]{0.5\\textwidth}\n  \\mypar{{...on types}}\n  \\begin{align*}\n    [\\unification{\\alpha}{\\tau}]\\nat                  &= \\nat\\\\\n    [\\unification{\\alpha}{\\tau}]\\top                  &= \\top\\\\\n    [\\unification{\\alpha}{\\tau}]\\alpha                &= \\alpha\\\\\n    [\\unification{\\alpha}{\\tau}]\\hat\\alpha            &= \\tau\\\\\n    [\\unification{\\alpha}{\\tau}]\\hat\\beta             &= \\hat\\beta\\\\\n    [\\unification{\\alpha}{\\tau}](A\\to B)              &= ([\\unification{\\alpha}{\\tau}]A)\\to([\\unification{\\alpha}{\\tau}]B)\\\\\n    [\\unification{\\alpha}{\\tau}](A\\& B)               &= ([\\unification{\\alpha}{\\tau}]A)\\&([\\unification{\\alpha}{\\tau}]B)\\\\\n    [\\unification{\\alpha}{\\tau}](\\Tabs{\\alpha}{A}{B}) &= \\Tabs{\\alpha}{[\\unification{\\alpha}{\\tau}]A}{[\\unification{\\alpha}{\\tau}]B}\\\\\n    [\\unification{\\alpha}{\\tau}]\\trecord{l}{A}        &= \\trecord{l}{[\\unification{\\alpha}{\\tau}]A}\n  \\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n  \\mypar{{...on terms}}\n  \\begin{align*}\n    [\\unification{\\alpha}{\\tau}]i &= i\\\\\n    [\\unification{\\alpha}{\\tau}]() &= ()\\\\\n    [\\unification{\\alpha}{\\tau}]x &= x\\\\\n    [\\unification{\\alpha}{\\tau}]\\abs{x}{E} &= \\abs{x}{[\\unification{\\alpha}{\\tau}]E}\\\\\n    [\\unification{\\alpha}{\\tau}](E_1\\,E_2) &= ([\\unification{\\alpha}{\\tau}]E_1)\\,([\\unification{\\alpha}{\\tau}]E_2)\\\\\n    [\\unification{\\alpha}{\\tau}](E : A) &= [\\unification{\\alpha}{\\tau}]E : [\\unification{\\alpha}{\\tau}]A\\\\\n    [\\unification{\\alpha}{\\tau}]\\tabs{\\alpha}{A}{E} &= \\tabs{\\alpha}{[\\unification{\\alpha}{\\tau}]A}{[\\unification{\\alpha}{\\tau}]E}\\\\\n    [\\unification{\\alpha}{\\tau}](E\\,A) &= ([\\unification{\\alpha}{\\tau}]E)\\, ([\\unification{\\alpha}{\\tau}]A)\\\\\n    [\\unification{\\alpha}{\\tau}]\\record{l}{E} &= \\record{l}{[\\unification{\\alpha}{\\tau}]E}\\\\\n    [\\unification{\\alpha}{\\tau}](E.l) &= ([\\unification{\\alpha}{\\tau}]E).l\n  \\end{align*}\n\\end{minipage}\\\\\n\n\\noindent\n\\begin{minipage}[t]{0.47\\textwidth}\n  \\mypar{{...on type contexts}}\n  \\begin{align*}\n    [\\unification{\\alpha}{\\tau}]\\bullet &= \\bullet\\\\\n    [\\unification{\\alpha}{\\tau}](\\Delta,\\tentry{\\alpha}{A}) &= [\\unification{\\alpha}{\\tau}]\\Delta,\\tentry{\\alpha}{[\\unification{\\alpha}{\\tau}]A}\\\\\n    [\\unification{\\alpha}{\\tau}](\\Delta,\\tentry{\\hat\\alpha}{A}) &= [\\unification{\\alpha}{\\tau}]\\Delta\\\\\n    [\\unification{\\alpha}{\\tau}](\\Delta,\\tentry{\\hat\\beta}{A}) &= [\\unification{\\alpha}{\\tau}]\\Delta,\\tentry{\\hat\\beta}{[\\unification{\\alpha}{\\tau}]A}\n  \\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.47\\textwidth}\n    \\mypar{{...on queues}}\n  \\begin{align*}\n    [\\unification{\\alpha}{\\tau}]\\bullet &= \\bullet\\\\\n    [\\unification{\\alpha}{\\tau}](\\mathcal{M},A) &= [\\unification{\\alpha}{\\tau}]\\mathcal{M},([\\unification{\\alpha}{\\tau}]A)\\\\\n    [\\unification{\\alpha}{\\tau}](\\mathcal{M},l) &= [\\unification{\\alpha}{\\tau}]\\mathcal{M},l\n  \\end{align*}\n\\end{minipage}\\\\\n\n\\noindent\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\mypar{...on coercions}\n\\begin{align*}\n  [\\unification{\\alpha}{\\rho}]\\idC{\\rho'} &= \\idC{[\\unification{\\alpha}{\\rho}]\\rho}\\\\\n  [\\unification{\\alpha}{\\rho}]\\topC{\\rho'} &= \\topC{[\\unification{\\alpha}{\\rho}]\\rho'}\\\\\n  [\\unification{\\alpha}{\\rho}]\\topArrC &= \\topArrC\\\\\n  [\\unification{\\alpha}{\\rho}]\\topAllC &= \\topAllC\\\\\n  [\\unification{\\alpha}{\\rho}]\\distArrC{\\rho_1}{\\rho_2}{\\rho_3} &= \\distArrC{[\\unification{\\alpha}{\\rho}]\\rho_1}{[\\unification{\\alpha}{\\rho}]\\rho_2}{[\\unification{\\alpha}{\\rho}]\\rho_3}\\\\\n  [\\unification{\\alpha}{\\rho}]\\distRecC{l}{\\rho_1}{\\rho_2} &= \\distRecC{l}{[\\unification{\\alpha}{\\rho}]\\rho_1}{[\\unification{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\unification{\\alpha}{\\rho}]\\projlC{\\rho_1}{\\rho_2} &= \\projlC{[\\unification{\\alpha}{\\rho}]\\rho_1}{[\\unification{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\unification{\\alpha}{\\rho}]\\projrC{\\rho_1}{\\rho_2} &= \\projrC{[\\unification{\\alpha}{\\rho}]\\rho_1}{[\\unification{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\unification{\\alpha}{\\rho}](\\mpC{c_1}{c_2}) &= \\mpC{([\\unification{\\alpha}{\\rho}]c_1)}{([\\unification{\\alpha}{\\rho}]c_2)}\\\\\n  [\\unification{\\alpha}{\\rho}](\\compC{c_1}{c_2}) &= \\compC{([\\unification{\\alpha}{\\rho}]c_1)}{([\\unification{\\alpha}{\\rho}]c_2)}\\\\\n  [\\unification{\\alpha}{\\rho}]\\pairC{c_1}{c_2} &= \\pairC{[\\unification{\\alpha}{\\rho}]c_1}{[\\unification{\\alpha}{\\rho}]c_2}\\\\\n  [\\unification{\\alpha}{\\rho}](\\arrC{c_1}{c_2}) &= \\arrC{([\\unification{\\alpha}{\\rho}]c_1)}{([\\unification{\\alpha}{\\rho}]c_2)}\\\\\n  [\\unification{\\alpha}{\\rho}](\\alllC{c}{\\rho'}) &= \\alllC{([\\unification{\\alpha}{\\rho}]c)}{([\\unification{\\alpha}{\\rho}]\\rho')}\\\\\n  [\\unification{\\alpha}{\\rho}](\\allrC{\\alpha}{c}) &= \\allrC{\\alpha}{[\\unification{\\alpha}{\\rho}]c}\\\\\n  [\\unification{\\alpha}{\\rho}]\\trecord{l}{c} &= \\trecord{l}{[\\unification{\\alpha}{\\rho}]c}\n\\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\mypar{...on coercion contexts}\n\\begin{align*}\n  [\\unification{\\alpha}{\\rho}]\\bullet                       &= \\bullet\\\\\n  [\\unification{\\alpha}{\\rho}](\\arrCC{\\mathcal{C}}{c'})     &= \\arrCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{[\\unification{\\alpha}{\\rho}]c'}\\\\\n  [\\unification{\\alpha}{\\rho}](\\projlCC{\\mathcal{C}}{A}{B}) &= \\projlCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{[\\unification{\\alpha}{\\rho}]A}{[\\unification{\\alpha}{\\rho}]B}\\\\\n  [\\unification{\\alpha}{\\rho}](\\projrCC{\\mathcal{C}}{A}{B}) &= \\projrCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{[\\unification{\\alpha}{\\rho}]A}{[\\unification{\\alpha}{\\rho}]B}\\\\\n  [\\unification{\\alpha}{\\rho}](\\mpCC{\\mathcal{C}}{\\mathcal{M}}{c_1}{A}{B}) &= \\mpCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{([\\unification{\\alpha}{\\rho}]\\mathcal{M})}{[\\unification{\\alpha}{\\rho}]c_1}{[\\unification{\\alpha}{\\rho}]A}{[\\unification{\\alpha}{\\rho}]B}\\\\\n  [\\unification{\\alpha}{\\rho}](\\alllCC{\\mathcal{C}}{\\rho'}) &= \\alllCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{[\\unification{\\alpha}{\\rho}]\\rho'}\\\\\n  [\\unification{\\alpha}{\\rho}](\\recCC{\\mathcal{C}}{l})     &= \\recCC{([\\unification{\\alpha}{\\rho}]\\mathcal{C})}{l}\n\\end{align*}\n\\end{minipage}\n\n\\subsubsection{Applying type variable substitution...}\n\\begin{minipage}[t]{0.5\\textwidth}\n  \\mypar{{...on types}}\n  \\begin{align*}\n    [{\\alpha}\\mapsto{\\tau}]\\nat                  &= \\nat\\\\\n    [{\\alpha}\\mapsto{\\tau}]\\top                  &= \\top\\\\\n    [{\\alpha}\\mapsto{\\tau}]\\alpha                &= \\tau\\\\\n    [{\\alpha}\\mapsto{\\tau}]\\beta                 &= \\beta\\\\\n    [{\\alpha}\\mapsto{\\tau}]\\hat\\alpha            &= \\hat\\alpha\\\\\n    [{\\alpha}\\mapsto{\\tau}](A\\to B)              &= ([\\substitution{\\alpha}{\\tau}]A)\\to([\\substitution{\\alpha}{\\tau}]B)\\\\\n    [{\\alpha}\\mapsto{\\tau}](A\\& B)               &= ([\\substitution{\\alpha}{\\tau}]A)\\&([\\substitution{\\alpha}{\\tau}]B)\\\\\n    [{\\alpha}\\mapsto{\\tau}](\\Tabs{\\alpha}{A}{B}) &= \\Tabs{\\alpha}{[\\substitution{\\alpha}{\\tau}]A}{[\\substitution{\\alpha}{\\tau}]B}\\\\\n    [{\\alpha}\\mapsto{\\tau}]\\trecord{l}{A}        &= \\trecord{l}{[\\substitution{\\alpha}{\\tau}]A}\n  \\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.5\\textwidth}\n  \\mypar{{...on terms}}\n  \\begin{align*}\n    [\\substitution{\\alpha}{\\tau}]i &= i\\\\\n    [\\substitution{\\alpha}{\\tau}]() &= ()\\\\\n    [\\substitution{\\alpha}{\\tau}]x &= x\\\\\n    [\\substitution{\\alpha}{\\tau}]\\abs{x}{E} &= \\abs{x}{[\\substitution{\\alpha}{\\tau}]E}\\\\\n    [\\substitution{\\alpha}{\\tau}](E_1\\,E_2) &= ([\\substitution{\\alpha}{\\tau}]E_1)\\,([\\substitution{\\alpha}{\\tau}]E_2)\\\\\n    [\\substitution{\\alpha}{\\tau}](E : A) &= [\\substitution{\\alpha}{\\tau}]E : [\\substitution{\\alpha}{\\tau}]A\\\\\n    [\\substitution{\\alpha}{\\tau}]\\tabs{\\beta}{A}{E} &= \\tabs{\\beta}{[\\substitution{\\alpha}{\\tau}]A}{[\\substitution{\\alpha}{\\tau}]E}\\\\\n    [\\substitution{\\alpha}{\\tau}](E\\,A) &= ([\\substitution{\\alpha}{\\tau}]E)\\, ([\\substitution{\\alpha}{\\tau}]A)\\\\\n    [\\substitution{\\alpha}{\\tau}]\\record{l}{E} &= \\record{l}{[\\substitution{\\alpha}{\\tau}]E}\\\\\n    [\\substitution{\\alpha}{\\tau}](E.l) &= ([\\substitution{\\alpha}{\\tau}]E).l\n  \\end{align*}\n\\end{minipage}\\\\\n\n\\noindent\n\\begin{minipage}[t]{0.47\\textwidth}\n  \\mypar{{...on type contexts}}\n  \\begin{align*}\n    [\\substitution{\\alpha}{\\tau}]\\bullet &= \\bullet\\\\\n    [\\substitution{\\alpha}{\\tau}](\\Delta,\\tentry{\\alpha}{A}) &= [\\substitution{\\alpha}{\\tau}]\\Delta\\\\\n    [\\substitution{\\alpha}{\\tau}](\\Delta,\\tentry{\\beta}{A}) &= [\\substitution{\\alpha}{\\tau}]\\Delta,\\tentry{\\beta}{[\\substitution{\\alpha}{\\tau}]A}\\\\\n    [\\substitution{\\alpha}{\\tau}](\\Delta,\\tentry{\\hat\\alpha}{A}) &= [\\substitution{\\alpha}{\\tau}]\\Delta,\\tentry{\\hat\\alpha}{[\\substitution{\\alpha}{\\tau}]A}\n  \\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.47\\textwidth}\n    \\mypar{{...on queues}}\n  \\begin{align*}\n    [\\substitution{\\alpha}{\\tau}]\\bullet &= \\bullet\\\\\n    [\\substitution{\\alpha}{\\tau}](\\mathcal{M},A) &= [\\substitution{\\alpha}{\\tau}]\\mathcal{M},([\\substitution{\\alpha}{\\tau}]A)\\\\\n    [\\substitution{\\alpha}{\\tau}](\\mathcal{M},l) &= [\\substitution{\\alpha}{\\tau}]\\mathcal{M},l\n  \\end{align*}\n\\end{minipage}\\\\%\\vspace{3pt}\n\n\\noindent\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\mypar{...on coercions}\n\\begin{align*}\n  [\\substitution{\\alpha}{\\rho}]\\idC{\\rho'} &= \\idC{[\\substitution{\\alpha}{\\rho}]\\rho}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\topC{\\rho'} &= \\topC{[\\substitution{\\alpha}{\\rho}]\\rho'}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\topArrC &= \\topArrC\\\\\n  [\\substitution{\\alpha}{\\rho}]\\topAllC &= \\topAllC\\\\\n  [\\substitution{\\alpha}{\\rho}]\\distArrC{\\rho_1}{\\rho_2}{\\rho_3} &= \\distArrC{[\\substitution{\\alpha}{\\rho}]\\rho_1}{[\\substitution{\\alpha}{\\rho}]\\rho_2}{[\\substitution{\\alpha}{\\rho}]\\rho_3}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\distRecC{l}{\\rho_1}{\\rho_2} &= \\distRecC{l}{[\\substitution{\\alpha}{\\rho}]\\rho_1}{[\\substitution{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\projlC{\\rho_1}{\\rho_2} &= \\projlC{[\\substitution{\\alpha}{\\rho}]\\rho_1}{[\\substitution{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\projrC{\\rho_1}{\\rho_2} &= \\projrC{[\\substitution{\\alpha}{\\rho}]\\rho_1}{[\\substitution{\\alpha}{\\rho}]\\rho_2}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\mpC{c_1}{c_2}) &= \\mpC{([\\substitution{\\alpha}{\\rho}]c_1)}{([\\substitution{\\alpha}{\\rho}]c_2)}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\compC{c_1}{c_2}) &= \\compC{([\\substitution{\\alpha}{\\rho}]c_1)}{([\\substitution{\\alpha}{\\rho}]c_2)}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\pairC{c_1}{c_2} &= \\pairC{[\\substitution{\\alpha}{\\rho}]c_1}{[\\substitution{\\alpha}{\\rho}]c_2}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\arrC{c_1}{c_2}) &= \\arrC{([\\substitution{\\alpha}{\\rho}]c_1)}{([\\substitution{\\alpha}{\\rho}]c_2)}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\alllC{c}{\\rho'}) &= \\alllC{([\\substitution{\\alpha}{\\rho}]c)}{([\\substitution{\\alpha}{\\rho}]\\rho')}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\allrC{\\alpha}{c}) &= \\allrC{\\alpha}{[\\substitution{\\alpha}{\\rho}]c}\\\\\n  [\\substitution{\\alpha}{\\rho}]\\trecord{l}{c} &= \\trecord{l}{[\\substitution{\\alpha}{\\rho}]c}\n\\end{align*}\n\\end{minipage}\n\\begin{minipage}[t]{0.49\\textwidth}\n  \\mypar{{...on coecion contexts}}\n\\begin{align*}\n  [\\substitution{\\alpha}{\\rho}]\\bullet                       &= \\bullet\\\\\n  [\\substitution{\\alpha}{\\rho}](\\arrCC{\\mathcal{C}}{c'})     &= \\arrCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{[\\substitution{\\alpha}{\\rho}]c'}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\projlCC{\\mathcal{C}}{A}{B}) &= \\projlCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{[\\substitution{\\alpha}{\\rho}]A}{[\\substitution{\\alpha}{\\rho}]B}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\projrCC{\\mathcal{C}}{A}{B}) &= \\projrCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{[\\substitution{\\alpha}{\\rho}]A}{[\\substitution{\\alpha}{\\rho}]B}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\mpCC{\\mathcal{C}}{\\mathcal{M}}{c_1}{A}{B}) &= \\mpCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{([\\substitution{\\alpha}{\\rho}]\\mathcal{M})}{[\\substitution{\\alpha}{\\rho}]c_1}{[\\substitution{\\alpha}{\\rho}]A}{[\\substitution{\\alpha}{\\rho}]B}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\alllCC{\\mathcal{C}}{\\rho'}) &= \\alllCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{[\\substitution{\\alpha}{\\rho}]\\rho'}\\\\\n  [\\substitution{\\alpha}{\\rho}](\\recCC{\\mathcal{C}}{l})     &= \\recCC{([\\substitution{\\alpha}{\\rho}]\\mathcal{C})}{l}\n\\end{align*}\n\\end{minipage}\n\n\\subsection{Judgments}\n\\mypar{Well-formed substitution (algorithmic)}\n\\fbox{\n\\begin{mathpar}\n  \\inferrule*[right=WFS-nil]{ }{\\wfSubst{\\Delta}{\\bullet}{\\bullet}} \\and\n  \\inferrule*[]{\\wfSubst{\\Delta}{\\theta,\\unification{\\alpha}{A}}{\\theta'}}{\\wfSubst{\\Delta,\\tentry{\\alpha}{B}}{\\theta,\\unification{\\alpha}{A}}{\\theta'}} \\and\n  \\inferrule*{\\wfSubst{\\Delta}{\\theta,\\unification{\\beta}{A}}{\\theta'}}{\\wfSubst{\\Delta,\\tentry{\\hat{\\alpha}}{B}}{\\theta,\\unification{\\beta}{A}}{\\theta'}} \\and\n  \\inferrule*[right=WFS-next]{\\wfSubst{\\Delta}{\\theta}{\\theta_1} \\\\ \\theta_1\\circ\\theta(\\algdisjoint{\\Delta}{A}{B)}{\\theta_2}}{\\wfSubst{\\Delta,\\tentry{\\hat{\\alpha}}{B}}{\\theta,\\unification{\\alpha}{A}}{\\theta_2\\circ\\theta_1}}\n\\end{mathpar}\n}\n\\mypar{Unification algorithm}\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule*[right=U-refl]{ }{\\unifyB{\\Delta}{\\xi}{\\xi}{\\bullet}} \\\\\n    \\inferrule*[right=U-VVL]{\\wfSubst{\\Delta}{[\\unification{\\alpha}{\\hat\\beta}]}{\\theta}}{\\unifyB{\\Delta}{\\hat\\alpha}{\\hat\\beta}{\\theta,{\\hat\\alpha}\\mapsto{\\hat\\beta}}} \\and\n    \\inferrule*[right=U-VVR]{\\wfSubst{\\Delta}{[\\unification{\\beta}{\\hat\\alpha}]}{\\theta}}{\\unifyB{\\Delta}{\\hat\\alpha}{\\hat\\beta}{\\theta,{\\hat\\beta}\\mapsto{\\hat\\alpha}}} \\and\n    \\inferrule*[right=U-NatV]{\\wfSubst{\\Delta}{[\\unification{\\alpha}{\\nat}]}{\\theta}}{\\unifyB{\\Delta}{\\nat}{\\hat{\\alpha}}{\\theta,\\unification{\\alpha}{\\nat}}} \\and\n    \\inferrule*[right=U-VNat]{\\wfSubst{\\Delta}{[\\unification{\\alpha}{\\nat}]}{\\theta}}{\\unifyB{\\Delta}{\\hat{\\alpha}}{\\nat}{\\theta,\\unification{\\alpha}{\\nat}}} \\and\n    \\inferrule*[right=U-CV]{\\wfSubst{\\Delta}{[\\unification{\\alpha}{\\alpha}]}{\\theta}}{\\unifyB{\\Delta}{\\alpha}{\\hat{\\alpha}}{\\theta,\\hat{\\alpha}\\mapsto\\alpha}}\\and\n    \\inferrule*[right=U-VC]{\\wfSubst{\\Delta}{[\\unification{\\alpha}{\\alpha}]}{\\theta}}{\\unifyB{\\Delta}{\\hat{\\alpha}}{\\alpha}{\\theta,\\hat{\\alpha}\\mapsto\\alpha}}\n  \\end{mathpar}\n}\\\\\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule{\\unifyB{\\Delta}{\\xi_1}{\\xi_2}{\\theta}}{\\unifyM{\\Delta}{\\xi_1}{\\xi_2}{\\theta}}\n  \\end{mathpar}\n}\n\\mypar{Algorithmic disjointness}\n\nFormula $\\notarrow{A}$, in the rules below, means that $A$ is not a function type.\\\\\n\\fbox{\n\\begin{mathpar}\n  \\inferrule*[right=AD-TopL]{ }{\\algdisjoint{\\Delta}{\\top}{A}{\\bullet}} \\and\n  \\inferrule*[right=AD-TopR]{ }{\\algdisjoint{\\Delta}{A}{\\top}{\\bullet}} \\\\\n  \\inferrule*[right=AD-VarL]{\\tentry{\\alpha}{A}\\in\\Delta \\\\ \\algSubRight{\\Delta}{\\bullet}{A}{B}{c}{\\theta}}{\\algdisjoint{\\Delta}{\\alpha}{B}{\\theta}} \\and\n  \\inferrule*[right=AD-VarR]{\\tentry{\\beta}{B}\\in{\\Delta} \\\\ \\algSubRight{\\Delta}{\\bullet}{B}{A}{c}{\\theta}}{\\algdisjoint{\\Delta}{A}{\\beta}{\\theta}} \\and\n  \\inferrule*[right=AD-UVarL]{\\tentry{\\hat\\alpha}{A}\\in\\Delta \\\\ \\algSubRight{\\Delta}{\\bullet}{A}{B}{c}{\\theta}}{\\algdisjoint{\\Delta}{\\hat\\alpha}{B}{\\theta}} \\and\n  \\inferrule*[right=AD-UVarR]{\\tentry{\\hat\\beta}{B}\\in{\\Delta} \\\\ \\algSubRight{\\Delta}{\\bullet}{B}{A}{c}{\\theta}}{\\algdisjoint{\\Delta}{A}{\\hat\\beta}{\\theta}} \\and\n  \\inferrule*[right=AD-Rcd]{\\algdisjoint{\\Delta}{A}{B}{\\theta}}{\\algdisjoint{\\Delta}{\\trecord{l}{A}}{\\trecord{l}{B}}{\\theta}} \\and\n  \\inferrule*[right=AD-Nrcd]{l_1 \\neq l_2}{\\algdisjoint{\\Delta}{\\trecord{l_1}{A}}{\\trecord{l_2}{B}}{\\bullet}} \\and\n  \\inferrule*[right=AD-Arr]{\\algdisjoint{\\Delta}{A_2}{B_2}{\\theta}}{\\algdisjoint{\\Delta}{A_1\\to A_2}{B_1\\to B_2}{\\theta}} \\and\n  \\inferrule*[right=AD-ArrL]{\\algdisjoint{\\Delta}{A_2}{B}{\\theta} \\\\ \\notarrow{B}}{\\algdisjoint{\\Delta}{A_1\\to A_2}{B}{\\theta}} \\and\n  \\inferrule*[right=AD-ArrR]{\\algdisjoint{\\Delta}{A}{B_2}{\\theta} \\\\ \\notarrow{A}}{\\algdisjoint{\\Delta}{A}{B_1\\to B_2}{\\theta}} \\and\n  \\inferrule*[right=AD-AndL]{\\algdisjoint{\\Delta}{A_1}{B}{\\theta_1} \\\\ \\theta_1(\\algdisjoint{\\Delta}{A_2}{B)}{\\theta_2} \\\\ \\notarrow{B}}{\\algdisjoint{\\Delta}{A_1\\& A_2}{B}{\\theta_2\\circ\\theta_1}} \\and\n  \\inferrule*[right=AD-AndR]{\\algdisjoint{\\Delta}{A}{B_1}{\\theta_1} \\\\ \\theta_1(\\algdisjoint{\\Delta}{A}{B_2)}{\\theta_2} \\\\ \\notarrow{A}}{\\algdisjoint{\\Delta}{A}{B_1\\& B_2}{\\theta_2\\circ\\theta_1}} \\and\n  \\inferrule*[right=AD-All]{\\algdisjoint{\\Delta,\\tentry{\\hat\\alpha}{A_1\\& B_1}}{[\\alpha\\mapsto\\hat\\alpha]B_1}{[\\alpha\\mapsto\\hat\\alpha]B_2}{\\theta}}{\\algdisjoint{\\Delta}{\\Tabs{\\alpha}{A_1}{A_2}}{\\Tabs{\\alpha}{B_1}{B_2}}{\\theta}}\\and\n  \\inferrule*[right=AD-AllL]{\\algdisjoint{\\Delta,\\tentry{\\hat\\alpha}{A}}{[\\alpha\\mapsto\\hat\\alpha]B_1}{B_2}{\\theta}}{\\algdisjoint{\\Delta}{\\Tabs{\\alpha}{A}{B_1}}{B_2}{\\theta}}\\and\n  \\inferrule*[right=AD-AllR]{\\algdisjoint{\\Delta,\\tentry{\\hat\\alpha}{A}}{B_1}{[\\alpha\\mapsto\\hat\\alpha]B_2}{\\theta}}{\\algdisjoint{\\Delta}{B_1}{\\Tabs{\\alpha}{A}{B_2}}{\\theta}}\\and\n  \\inferrule*[right=AD-AX]{\\starax{A}{B}}{\\algdisjoint{\\Delta}{A}{B}{\\bullet}}\n\\end{mathpar}\n}\\\\\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule*[right=AX-NatBool]{ }{\\starax{\\nat}{\\bool}}\\and\n    \\inferrule*[right=AX-BoolNat]{ }{\\starax{\\bool}{\\nat}}\\and\n    \\inferrule*[right=AX-RcdNat]{ }{\\starax{\\trecord{l}{A}}{\\nat}}\\and\n    \\inferrule*[right=AX-NatRcd]{ }{\\starax{\\nat}{\\trecord{l}{A}}}\\and\n    \\inferrule*[right=AX-RcdBool]{ }{\\starax{\\trecord{l}{A}}{\\bool}}\\and\n    \\inferrule*[right=AX-BoolRcd]{ }{\\starax{\\bool}{\\trecord{l}{A}}}\n    %% \\inferrule*{}\n  \\end{mathpar}\n}\n\n\\mypar{Internal disjointness}\n\\fbox{\n  \\begin{mathpar}\n    \\inferrule*[right=UD-Nat]{ }{\\algUdisjoint{\\Delta}{\\nat}{\\bullet}}\\and\n    \\inferrule*[right=UD-Bool]{ }{\\algUdisjoint{\\Delta}{\\bool}{\\bullet}}\\and\n    \\inferrule*[right=UD-Top]{ }{\\algUdisjoint{\\Delta}{\\top}{\\bullet}}\\and\n    \\inferrule*[right=UD-Var]{\\tentry{\\alpha}{A}\\in\\Delta}{\\algUdisjoint{\\Delta}{\\alpha}{\\bullet}}\\and\n    \\inferrule*[right=UD-UVar]{\\tentry{\\hat\\alpha}{A}\\in\\Delta}{\\algUdisjoint{\\Delta}{\\hat\\alpha}{\\bullet}}\\and\n    \\inferrule*[right=UD-Rcd]{\\algUdisjoint{\\Delta}{A}{\\theta}}{\\algUdisjoint{\\Delta}{\\trecord{l}{A}}{\\theta}}\\and\n    \\inferrule*[right=UD-Arr]{\\algUdisjoint{\\Delta}{B}{\\theta}}{\\algUdisjoint{\\Delta}{A\\to B}{\\theta}}\\and\n    \\inferrule*[right=UD-And]{\\algdisjoint{\\Delta}{A}{B}{\\theta}\\\\\\ \\theta(\\algUdisjoint{\\Delta}{A)}{\\theta_1}\\\\\\theta(\\algUdisjoint{\\Delta}{B)}{\\theta_2}}{\\algUdisjoint{\\Delta}{A\\& B}{\\theta_1\\circ\\theta_2\\circ\\theta}}\\and\n    \\inferrule*[right=UD-All]{\\algUdisjoint{\\Delta,\\tentry{\\alpha}{A}}{B}{\\theta}}{\\algUdisjoint{\\Delta}{\\Tabs{\\alpha}{A}{B}}{\\theta}}\n  \\end{mathpar}\n}\n\n\\begin{figure}[h]\n  \\caption{Algorithmic subtyping}\n  \\begin{subfigure}{\\textwidth}\n    \\begin{mathpar}\n      \\inferrule{\\algSubRight{\\bullet}{\\bullet}{A}{B}{c}{\\theta}}{\\algSubMain{A}{B}{c}{\\theta}}\n    \\end{mathpar}\n    \\caption{Main judgment}\n  \\end{subfigure}\n  \n  \\begin{subfigure}{\\textwidth}\n    \\begin{mathpar}\n      \\inferrule*[right=AR-top]\n          { }\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{\\top}{\\compC{\\toparrowqueue{\\mathcal{L}}}{\\topC{\\toTarget{A}}}}{\\bullet}}\n      \\and\n      \\inferrule*[right=AR-rcd]\n          {\\algSubRight{\\Delta}{\\mathcal{L},l}{A}{B}{c}{\\theta}}\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{\\trecord{l}{B}}{c}{\\theta}}\n      \\and    \n      \\inferrule*[right=AR-and]\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{B_1}{c_1}{\\theta} \\\\ \\algSubRight{\\Delta}{\\mathcal{L}}{A}{B_2}{c_2}{\\theta}}\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{B_1\\& B_2}{\\compC{\\distarrowqueue{\\mathcal{L}}{B_1}{B_2}}{\\pairC{c_1}{c_2}}}{\\theta}}\n      \\and\n      \\inferrule*[right=AR-arr]\n          {\\algSubRight{\\Delta}{\\mathcal{L},B_1}{A}{B_2}{c}{\\theta}}\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{B_1\\to B_2}{c}{\\theta}}\n      \\and\n      \\inferrule*[right=AR-all]\n          {\\algSubRight{\\Delta,\\tentry{\\alpha}{B_1}}{\\mathcal{L}}{A}{B_2}{c}{\\theta}}\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{\\Tabs{\\alpha}{B_1}{B_2}}{\\allrC{\\alpha}{c}}{\\theta}}\n      \\and\n      \\inferrule*[right=AR-base]\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\bullet}{A}{\\bullet}{A}{\\xi}{\\mathcal{C}}{\\theta}}\n          {\\algSubRight{\\Delta}{\\mathcal{L}}{A}{\\xi}{\\mathcal{C}[\\idC{\\toTarget{A}}]}{\\theta}}\n    \\end{mathpar}\n    \\caption{Right focus}\n  \\end{subfigure}\n\n  \\begin{subfigure}{\\textwidth}\n    \\begin{mathpar}\n      \\inferrule*[right=AL-Base]\n          {\\unifyB{\\Delta}{\\xi_1}{\\xi_2}{\\theta}}\n          {\\algSubLeft{\\Delta}{\\bullet}{\\mathcal{M}}{A_0}{\\mathcal{C}}{\\xi_1}{\\xi_2}{\\mathcal{C}}{\\theta}}\n          \\and\n      \\mprset{vskip=2pt}\n      \\inferrule*[right=AL-VarArr]\n                 {\\theta= [\\unification{\\alpha}{(\\hat\\alpha_1\\to\\hat\\alpha_2)}] \\\\ \\fresh{\\hat\\alpha_1, \\hat\\alpha_2}\\\\ \\Delta = \\Delta_1,\\tentry{\\hat\\alpha}{A},\\Delta_2\\\\\\\\ %(\\tentry{\\hat\\alpha}{A})\\in\\Delta\\\\\\\\\n                   \\algSubRight{\\Delta_1,\\tentry{\\hat\\alpha_1}{\\top},\\tentry{\\hat\\alpha_2}{A},\\theta(\\Delta_2)}{\\bullet}{\\theta(B_1)}{\\hat\\alpha_1}{c_1}{\\theta_1}\\\\\n                   \\theta_1\\circ\\theta(\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M},B_1}{A_0}{\\arrCC{\\mathcal{C}}{c_1}}{\\hat\\alpha_2}{\\xi)}{\\mathcal{C'}}{\\theta_2}\n                 }\n          {\\algSubLeft{\\Delta}{B_1,\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{\\hat\\alpha}{\\xi}{\\mathcal{C'}}{\\theta_2\\circ\\theta_1\\circ\\theta}}\n          \\mprset{vskip=}\n      \\and\n      \\inferrule*[right=AL-AndL]\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\projlCC{\\mathcal{C}}{\\toTarget{A_1}}{\\toTarget{A_2}}}{A_1}{\\xi}{\\mathcal{C'}}{\\theta}}\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{A_1\\& A_2}{\\xi}{\\mathcal{C'}}{\\theta}}\n      \\and\n      \\inferrule*[right=AL-AndR]\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\projrCC{\\mathcal{C}}{\\toTarget{A_1}}{\\toTarget{A_2}}}{A_2}{\\xi}{\\mathcal{C'}}{\\theta}}\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{A_1\\& A_2}{\\xi}{\\mathcal{C'}}{\\theta}}\n      \\and\n      \\inferrule*[right=AL-Rcd]\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M},l}{A_0}{\\recCC{\\mathcal{C}}{l}}{A}{\\xi}{\\mathcal{C'}}{\\theta}}\n          {\\algSubLeft{\\Delta}{l,\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{\\trecord{l}{A}}{\\xi}{\\mathcal{C'}}{\\theta}}\n      \\and\n      \\inferrule*[right=AL-Arr]\n          {\\algSubRight{\\Delta}{\\bullet}{B_1}{A_1}{c_1}{\\theta_1}\\\\ \\theta_1(\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M},B_1}{A_0}{\\arrCC{\\mathcal{C}}{c_1}}{A_2}{\\xi)}{\\mathcal{C'}}{\\theta_2}}\n          {\\algSubLeft{\\Delta}{B_1,\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{A_1\\to A_2}{\\xi}{\\mathcal{C'}}{\\theta_2\\circ\\theta_1}}\n      \\and\n      \\inferrule*[right=AL-MP]\n                 {\\algSubRight{\\Delta}{\\bullet}{A_0}{\\arrowqueue{\\mathcal{M}}{A_1}}{c_1}{\\theta_1}\\\\\n                  \\theta_1(\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mpCC{\\mathcal{C}}{\\mathcal{M}}{c_1}{\\toTarget{A_1}}{\\toTarget{A_2}}}{A_2}{\\xi)}{\\mathcal{C'}}{\\theta_2}\n                  %% \\elab{\\mathcal{C'} = \\abs{c}{\\compC{\\distarrowqueueC{\\mathcal{M}}{\\left(\\compC{c}{(\\mpC{\\projlC{\\toTarget{A_1\\to A_2}}{\\toTarget{A_1}}}{\\projrC{\\toTarget{A_1\\to A_2}}{\\toTarget{A_1}}})}\\right)}{(A_1\\to A_2)}{A_1}}{\\pairC{\\mathcal{C}[\\idC{\\toTarget{A_1\\to A_2}}]}{c_1}}}}\n                 }\n          {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{A_1\\to A_2}{\\xi}{\\mathcal{C'}}{\\theta_2\\circ\\theta_1}}\n      \\and\n      \\inferrule*[right=AL-Forall]\n                 {\\algSubLeft{\\Delta,\\tentry{\\hat{\\alpha}}{A}}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\alllCC{\\mathcal{C}}{\\hat\\alpha}}{[\\alpha\\mapsto\\hat{\\alpha}]B}{\\xi}{\\mathcal{C'}}{\\theta}\\\\\n                 \\fresh{\\hat\\alpha}}\n                 {\\algSubLeft{\\Delta}{\\mathcal{L}}{\\mathcal{M}}{A_0}{\\mathcal{C}}{\\Tabs{\\alpha}{A}{B}}{\\xi}{\\mathcal{C'}}{\\theta}}\n    \\end{mathpar}\n    \\caption{Left focus}\n  \\end{subfigure}\n\\end{figure}\n\n\\section{Guide}\n\\begin{theorem}\n  \\newcommand*{\\dom}[1]{\\mathsf{dom}(#1)}\n  If $\\wfSubst{\\Delta}{\\theta}{\\theta'}$, then $\\dom{\\theta}\\cap\\dom{\\theta'}=\\emptyset$.\n\\end{theorem}\n\\begin{proof}\n  \\newcommand*{\\dom}[1]{\\mathsf{dom}(#1)}\n  Easy by induction on the well-formed-substitution judgment. The only interesting case is where\n  \\begin{itemize}\n  \\item \\(\\inferrule{\\wfSubst{\\Delta}{\\theta}{\\theta_1} \\\\ \\theta_1\\circ\\theta(\\algdisjoint{\\Delta}{A}{B)}{\\theta_2}}{\\wfSubst{\\Delta,\\tentry{\\hat{\\alpha}}{B}}{\\theta,\\unification{\\alpha}{A}}{\\theta_1\\circ\\theta_2}}\\)\n  \\end{itemize}\n  From the fact that $\\hat\\alpha\\not\\in\\Delta$ and the two premises of the rule, it follows that $\\hat\\alpha\\not\\in\\dom{\\theta_1}$ and $\\hat\\alpha\\not\\in\\dom{\\theta_2}$.\n  From the definition of substitution, we have $\\forall\\beta,\\,\\beta\\in\\dom{\\theta_1\\circ\\theta}\\implies\\beta\\not\\in\\dom{(\\theta_1\\circ\\theta)(\\Delta)}$.\n  Therefore, from the second premise it follows that $\\beta\\not\\in\\dom{\\theta_2}$. Then, $\\dom{\\theta}\\cap\\dom{\\theta_2}=\\emptyset$.\\\\  \n  Also, from the induction hypothesis and the first premise of the rule, it follows that $\\dom{\\theta}\\cap\\dom{\\theta_1}=\\emptyset$.\\\\\n  Altogether, we get that $(\\dom{\\theta}\\cup\\{\\hat\\alpha\\})\\cap\\dom{\\theta_1\\circ\\theta_2}=\\emptyset$.\n\\end{proof}\n\\subsection{Examples}\nWith\n\\begin{align*}\n  \\mathcal{A} &:= \\Tabs{\\alpha}{\\top}{\\Tabs{\\beta}{\\alpha}{\\Tabs{\\gamma}{\\alpha\\&\\beta}{\\gamma\\to\\alpha\\&\\beta}}}\\\\\n  \\Delta_1    &:= \\tentry{\\alpha}{\\top},\\tentry{\\beta}{\\alpha\\&\\nat}\\\\\n  \\Delta_2    &:= \\tentry{\\hat\\alpha}{\\top},\\tentry{\\hat\\beta}{\\hat\\alpha},\\tentry{\\hat\\gamma}{\\hat{\\alpha}\\&\\hat\\beta}\\\\\n\\end{align*}\nwe have\n\\[\n\\mprset{vskip=0ex}\n\\inferrule*[right=AR-all*]\n {\n   \\inferrule*[Right=AR-arr]\n    {\n      \\inferrule*[Right=AR-and]\n       {\n         \\inferrule*\n          {\\vdots}\n         {\\algSubRight{\\Delta_1}{\\beta}{\\mathcal{A}}{\\alpha}{?_1}{?}}\n         \\\\\n         \\inferrule*[Right=AR-base]\n          {\n            \\inferrule*[Right=AL-all*]\n             {\n               \\inferrule*[Right=AL-arr]\n                {\n                  \\inferrule*[right=AR-base,leftskip=2cm]\n                   {\n                     \\inferrule*[Right=AL-base]\n                      {\n                        \\inferrule*\n                         {\n                           \\inferrule*\n                            {\n                              \\inferrule*[Right=AD-andR]\n                               {\n                                 \\inferrule*[right=AD-varL,leftskip=2cm]\n                                  {\n                                    \\inferrule*[]\n                                     { }\n                                     {\\algSubRight{\\Delta_1,\\Delta_2}{}{}{}{}{}}\n                                  }\n                                  {\\algdisjoint{\\Delta_1,\\Delta_2}{\\beta}{\\hat\\alpha}{?}}\n                                 \\\\\n                                 \\inferrule*[right=AD-varL,rightskip=3cm]\n                                  {\\vdots}\n                                  {\\algdisjoint{\\Delta_1,\\Delta_2}{\\beta}{\\hat{\\beta}}{?}}\n                                 %% \\vdots\n                               }\n                               {\\algdisjoint{\\Delta_1,\\Delta_2}{\\beta}{\\hat{\\alpha}\\&\\hat\\beta}{?}}\n                            }\n                            {\\wfSubst{\\Delta_1,\\Delta_2}{\\unification{\\gamma}{\\beta}}}\n                         }\n                         {\\unifyB{\\Delta_1,\\Delta_2}{\\beta}{\\hat\\gamma}{?}}\n                      }\n                      {\\algSubLeft{\\Delta_1,\\Delta_2}{\\bullet}{\\bullet}{\\beta}{\\abs{c}{c}}{\\beta}{\\hat\\gamma}{?}{?}}\n                   }\n                   {\\algSubRight{\\Delta_1,\\Delta_2}{\\bullet}{\\beta}{\\hat\\gamma}{?}{?}}\n                  \\\\\n                  \\inferrule*[rightskip=2cm]\n                   { }\n                   {\\algSubLeft{}{}{\\beta}{\\mathcal{A}}{}{}{\\nat}{?}{?}}\n                }\n                {\\algSubLeft{\\Delta_1,\\Delta_2}{\\beta}{\\bullet}{\\mathcal{A}}{\\abs{c}{c}}{\\hat\\gamma\\to\\hat{\\alpha}\\&\\hat\\beta}{\\nat}{?}{?}}\n             }\n             {\\algSubLeft{\\Delta_1}{\\beta}{\\bullet}{\\mathcal{A}}{\\abs{c}{c}}{\\mathcal{A}}{\\nat}{?}{?}}\n          }\n          {\\algSubRight{\\Delta_1}{\\beta}{\\mathcal{A}}{\\nat}{?_2}{?}}\n       }\n       {\\algSubRight{\\Delta_1}{\\beta}{\\Tabs{\\alpha}{\\top}{\\Tabs{\\beta}{\\alpha}{\\Tabs{\\gamma}{\\alpha\\&\\beta}{\\gamma\\to\\alpha\\&\\beta}}}}{\\alpha\\&\\nat}{\\pairC{?_1}{?_2}}{?}}\n    }\n    {\\algSubRight{\\Delta_1}{\\bullet}{\\Tabs{\\alpha}{\\top}{\\Tabs{\\beta}{\\alpha}{\\Tabs{\\gamma}{\\alpha\\&\\beta}{\\gamma\\to\\alpha\\&\\beta}}}}{\\beta\\to\\alpha\\&\\nat}{?}{?}}\n }\n {\\algSubRight{\\bullet}{\\bullet}{\\Tabs{\\alpha}{\\top}{\\Tabs{\\beta}{\\alpha}{\\Tabs{\\gamma}{\\alpha\\&\\beta}{\\gamma\\to\\alpha\\&\\beta}}}}{\\Tabs{\\alpha}{\\top}{\\Tabs{\\beta}{\\alpha\\&\\nat}{\\beta\\to\\alpha\\&\\nat}}}{?}{?}}\n\\]\n\\end{document}\n", "meta": {"hexsha": "5587365b28921651eb9d48a155fa316f3f3fdab5", "size": 44340, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/newspecs.tex", "max_stars_repo_name": "martonbognar/modusponens-prototype", "max_stars_repo_head_hexsha": "c44dbb91b647827767af12f5c6e00154c6b26bb7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/newspecs.tex", "max_issues_repo_name": "martonbognar/modusponens-prototype", "max_issues_repo_head_hexsha": "c44dbb91b647827767af12f5c6e00154c6b26bb7", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/newspecs.tex", "max_forks_repo_name": "martonbognar/modusponens-prototype", "max_forks_repo_head_hexsha": "c44dbb91b647827767af12f5c6e00154c6b26bb7", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.8778280543, "max_line_length": 369, "alphanum_fraction": 0.5789129454, "num_tokens": 17572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4360275681560389}}
{"text": "For the moment, assume that we are running in comoving coordinates, \nwith dark matter particles only (no hydro) and that the particles all exist at level 0.   These assumptions are\nencapsulated in the following lines in the inputs file: \\\\\n\n\\noindent {\\bf castro.use\\_comoving = t} \\\\\n\\noindent {\\bf castro.do\\_dm\\_particles = 1} \\\\\n\\noindent {\\bf amr.max\\_level =  0} \\\\\n\\noindent {\\bf castro.do\\_hydro = 0} \\\\\n\\noindent {\\bf castro.do\\_react = 0} \\\\\n\\noindent {\\bf castro.do\\_grav =  1} \n\n\\section{Equations}\n\nIf we define ${\\mathbf x}_i$ and ${\\bf u}_i$ as the location and velocity of particle $i$, respectively, then we wish\nto solve\n\\begin{eqnarray}\n\\frac{d {\\mathbf x}_i}{d t} &=& \\frac{1}{a} {\\mathbf u}_i \\\\\n\\frac{d (a {\\mathbf u}_i) }{d t} &=& {\\mathbf g}_i\n\\end{eqnarray}\nwhere ${\\mathbf g}_i$ is the gravitational force evaluated at the location of particle $i$, i.e., \n${\\mathbf g}_i = {\\mathbf g}({\\mathbf x}_i,t).$\n\n\\section{Initializing the Particles}\n\n\\noindent There are three different ways in which particles can currently be initialized:\n\n\\subsection{Read from an ASCII file}\n\nTo enable this option, set \\\\\n\n\\noindent {\\bf castro.castro.particle\\_init\\_type = AsciiFile} \\\\\n\\noindent {\\bf castro.castro.ascii\\_particle\\_file =}{\\em particle\\_file}\n\nHere {\\em particle\\_file} is the user-specified name of the file.  The first line in this file is\nassumed to contain the number of particles.  Each line after that contains  \\\\\n\nx y z mass xdot ydot zdot \\\\\n\nNote that the variable that we call the particle velocity, ${\\mathbf u} = a {\\bf \\dot{x}}$, \nso we must multiply ${\\bf \\dot{x}}$, by $a$ when we initialize the particles.\n\n\\subsection{Random placement}\n\nTo enable this option, set \\\\\n\n\\noindent {\\bf castro.castro.particle\\_init\\_type = Random} \\\\\n\n\\noindent There are then a number of parameters to set, for example: \\\\\n\n\\noindent {\\bf castro.particle\\_initrandom\\_count = 100000}\n\n\\noindent {\\bf castro.particle\\_initrandom\\_mass  = 1}\n\n\\noindent {\\bf castro.particle\\_initrandom\\_iseed = 15}\n\n\\subsection{Cosmological}\n\nTo enable this option, set \\\\\n\n\\noindent {\\bf castro.castro.particle\\_init\\_type = Cosmological} \\\\\n\n\\noindent This process is still under development.\n\n\\section{Time Stepping}\n\n\\noindent There are currently two different ways in which particles can be moved:\n\n\\subsection{Random}\n\n\\noindent To enable this option, set \\\\\n\n\\noindent {\\bf castro.particle\\_move\\_type = Random} \\\\\n\n\\noindent Update the particle positions at the end of each coarse time step using a \nrandom number between 0 and 1 multiplied by 0.25 dx.\n\n\\subsection{Motion by Self-Gravity}\n\n\\noindent To enable this option, set \\\\\n\n\\noindent {\\bf castro.particle\\_move\\_type = Gravitational} \\\\\n\n\\subsubsection{Move-Kick-Drift Algorithm}\n\nIn each time step:\n\\begin{itemize}\n\\item Solve for ${\\mathbf g}^n$  (only if multilevel, otherwise use ${\\mathbf g}^{n+1}$ from previous step)\n\\item ${\\mathbf u}_i^{\\nph} = \\frac{1}{a^{\\nph}} ( (a^n {\\mathbf u}^n_i) + \\frac{\\dt}{2} \\; {\\mathbf g}^n_i )$\n\\item ${\\mathbf x}_i^{n+1 } = {\\mathbf x}^n_i +  \\frac{\\dt}{a^{\\nph}}  {\\mathbf u}_i^{\\nph}$\n\\item Solve for ${\\mathbf g}^{n+1}$ using ${\\mathbf x}_i^{n+1}$\n\\item ${\\mathbf u}_i^{n+1} = \\frac{1}{a^{n+1}} ( (a^{\\nph} {\\mathbf u}^{\\nph}_i) + \\frac{\\dt}{2} \\; {\\mathbf g}^{n+1}_i )$\n\\end{itemize}\n\nNote that at the end of the timestep ${\\bf x}_i^{n+1}$ is consistent with ${\\bf g}^{n+1}$ becasue\nwe have not advanced the positions after computing the new-time gravity.  This has the benefit that\nwe perform only one gravity solve per timestep (in a single-level calculation with no hydro) because\nthe particles are only moved once.\n\n\\subsubsection{Computing {\\bf g}}\n\nWe solve for the gravitational vector as follows:\n\\begin{itemize}\n\\item Assign the mass of the particles onto the grid in the form of density, $\\rho_{DM}$.  \nThe mass of each particle is assumed to be uniformly distributed over a cube of side $\\Delta x$, \ncentered at what we call the position of the particle.    We distribute the mass of each\nparticle to the cells on the grid in proportion to the volume of the intersection of each cell\nwith the particle's cube.   We then divide these cell values by $\\Delta x^3$ so that the\nright hand side of the Poisson solve will be in units of density rather than mass.  \nNote that this is the {\\it comoving} density.\n\n\\item Solve $\\nabla^2 \\phi = \\frac{4 \\pi G}{a} \\rho_{DM}$.\nWe discretize with the standard 7-point Laplacian (5-point in 2D) \nand use multigrid with Gauss-Seidel red-black relaxation to solve the equation for $\\phi$ at cell centers.\n\n\\item Compute the normal component of ${\\bf g} = -\\nabla \\phi$ at cell faces by differencing the adjacent values of $\\phi,$\ne.g. if $\\gb = (g_x, g_y, g_z),$ then we define $g_x$ on cell faces with a normal in the x-direction by computing\n$g_{x,i-\\myhalf,j,k} = -(\\phi_{i,j,k} - \\phi_{i-1,j,k}) / \\Delta x.$\n\n\\item  Interpolate each component of ${\\bf g}$ from normal cell faces onto each particle position using \nlinear interpolation in the normal direction.\n\n\\end{itemize}\n\n%\\subsection{Predictor-Corrector}\n%\n%An alternative to the above algorithm would be the following predictor-corrector approach:\n%\n%\\begin{itemize}\n%\\item Solve for ${\\bf g}^n$\n%\\item ${\\bf v}_i^{n+1,*} = {\\bf v}^n_i + \\dt \\; {\\bf g}^n$\n%\\item ${\\bf x}_i^{n+1,*} = {\\bf x}^n_i + \\dt \\; {\\bf v}_i^n$\n%\\item Solve for ${\\bf g}^{n+1}$ using ${\\bf x}_i^{n+1,*}$\n%\\item ${\\bf v}_i^{n+1} = {\\bf v}^{n+1,*}_i + \\frac{\\dt}{2} \\; ({\\bf g}^{n+1} - {\\bf g}^n)$\n%\\item ${\\bf x}_i^{n+1} = {\\bf x}^{n+1,*}_i + \\frac{\\dt}{2} \\; ({\\bf v}_i^{n+1} - {\\bf v}_i^n)$\n%\\end{itemize}\n%\n%\\noindent This has two issues:\n%\\begin{itemize}\n%\\item First, the gravity at the end of the timestep is not consistent with the particle positions at the end of the timestep.\n%Thus this will require an additional solve per timestep because we move the particles twice per timestep.\n%\\item Second, this increases the memory required per particle because we would need to keep both ${\\bf v}^n_i$\n%and ${\\bf v}^{n+1,*}_i$ over the course of a timestep.\n%\\end{itemize}\n\n\\section{Output Format}\n\n\\subsection{Checkpoint Files}\n\nThe particle positions and velocities are stored in a binary file in each checkpoint directory.  \nThis format is designed for being read by the code at restart rather than for diagnostics. \\\\\n\nWe note that the value of $a$ is also written in each checkpoint directory, \nin a separate ASCII file called {\\em comoving\\_a}, containing only the single value. \\\\\n\n\\subsection{Plot Files}\n\nIf {\\bf particles.write\\_in\\_plotfile =} 1 in the inputs file \nthen the particle positions and velocities will be written in a binary file in each plotfile directory.  \n\nIn addition, we can also\nvisualize the particle locations as represented on the grid.  There are two ``derived quantities''\nwhich represent the particles.  Setting \\\\\n\n\\noindent {\\bf amr.derive\\_plot\\_vars = particle\\_count particle\\_mass\\_density} \\\\\n\\noindent {\\bf amr.plot\\_vars = NONE} \\\\\n\n\\noindent in the inputs file will generate plotfiles with only two variables.  \n{\\bf particle\\_count} represents the number of particles in a grid cell; \n{\\bf particle\\_mass\\_density} is the density on the grid resulting from the particles.\n\nWe note that the value of $a$ is also written in each plotfile directory, \nin a separate ASCII file called {\\em comoving\\_a}, containing only the single value. \\\\\n\n\\subsection{ASCII Particle Files}\n\nTo generate an ASCII file containing the particle positions and velocities, \none needs to restart from a checkpoint\nfile but doesn't need to run any steps.  For example, if chk00350 exists, then one can set: \\\\\n\n\\noindent {\\bf amr.restart = chk00350} \\\\\n\\noindent {\\bf max\\_step = 350} \\\\\n\\noindent {\\bf particles.particle\\_output\\_file =} {\\em particle\\_output} \\\\\n\n\\noindent which would tell the code to restart from chk00350, not to take any further time steps, and to write an ASCII-format \nfile called {\\em particle\\_output}. \\\\\n\n\\noindent This file has the same format as the ASCII input file: \\\\\n\n\\noindent number of particles \\\\ \nx y z mass xdot ydot zdot \\\\\n\n\\subsection{Run-time Data Logs}\n\nIf you set \\\\\n\n\\noindent {\\bf amr.data\\_log = }{\\em log\\_file}  \\\\\n\n\\noindent in the inputs file, then at run-time the code will write a log file with entries every coarse\ngrid time step, containing \\\\\n\n\\noindent nstep  time   dt   redshift   a\n\n\n\\subsection{Run-time Screen Output}\n\nThere are a number of flags that control the verbosity written to the screen at run-time.  These are:\n\n\\noindent {\\bf amr.v } \\\\\n\\noindent {\\bf castro.v } \\\\\n\\noindent {\\bf gravity.v } \\\\\n\\noindent {\\bf mg.v } \\\\\n\\noindent {\\bf particles.v } \\\\\n\nThese control printing  about the state of the calculation (time, value of $a$, etc) as well as\ntiming information.\n", "meta": {"hexsha": "d8e3b956c88762aafa8cd2d205a1e921eaa06ca1", "size": 8764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/UsersGuide/Particles/Particles.tex", "max_stars_repo_name": "hbrunie/PeleLM", "max_stars_repo_head_hexsha": "8b8c07aa1770c07e087f8976b6e16a71de68f751", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Docs/UsersGuide/Particles/Particles.tex", "max_issues_repo_name": "hbrunie/PeleLM", "max_issues_repo_head_hexsha": "8b8c07aa1770c07e087f8976b6e16a71de68f751", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Docs/UsersGuide/Particles/Particles.tex", "max_forks_repo_name": "hbrunie/PeleLM", "max_forks_repo_head_hexsha": "8b8c07aa1770c07e087f8976b6e16a71de68f751", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5740740741, "max_line_length": 127, "alphanum_fraction": 0.7115472387, "num_tokens": 2562, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.435959912393955}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{Fri Nov 08 2019}\n\nIt can be shown that the equation \n%\n\\begin{align}\n  \\dv[2]{x^{\\mu }}{\\tau } + \\Gamma^{\\mu }_{\\alpha \\beta } \\dv{x^{\\alpha }}{\\tau } \\dv{x^{\\beta }}{\\tau } = 0\n\\,,\n\\end{align}\n%\nin the low-field limit gives the regular acceleration in a gravitational field.\n\nIf we define \\(u^{\\mu }\\) as \\(\\dv*{x^{\\mu }}{\\tau }\\), we get that the equation is equivalent to \n%\n\\begin{align}\n  u^{\\alpha } \\qty(\\pdv{u^{\\mu } }{x^{\\alpha }} + \\Gamma^{\\mu }_{\\alpha \\beta }u^{\\beta }) = u^{\\alpha } \\nabla_{\\alpha } u^{\\mu } = a^{\\mu } = 0\n\\,.\n\\end{align}\n\nThe acceleration we feel corresponds to the difference between our motion and geodesic motion.\n\nThe four-velocity has constant square modulus: either 0, or \\(\\pm 1\\), if we choose an appropriate parametrization. Therefore we can classify geodesics.\n\n\\paragraph{Timelike geodesics} have \\(u^{\\mu } u_{\\mu } = -1\\), and are related to the motion of a particle. They minimize the proper time \\(\\dd{\\tau} = \\sqrt{-\\dd{s^2}}\\), which is real in this case. We parametrize them by \\(\\tau \\).\n\n\\paragraph{Spacelike geodesics} have \\(u^{\\mu } u_{\\mu } = +1\\) and can be seen as the shortest path between two points: for them, the integral of \\(\\dd{s}\\) is stationary. We parametrize them by \\(s\\).\n\n\\paragraph{Null geodesics} have \\(u^{\\mu } u_{\\mu } = 0\\) are characterized by \\(\\dd{s}=0\\). We parametrize them with some parameter of our choosing, \\(\\lambda \\), which must be independent of proper time or space.\n\n\\subsection{Solutions of the geodesic equation}\n\nWe treat the problem in the case of a two-dimensional Euclidean plane, using polar coordinates: we know we should find straight lines, but in these coordinates the problem is nontrivial.\n\nThe metric is \\(\\dd{s^2} = \\dd{r^2} + r^2 \\dd{\\theta^2}\\), and the nonzero Christoffel symbols are (see exercise 3.3): \n%\n\\begin{align}\n  \\Gamma^{r}_{\\theta \\theta } = -r \n  \\qquad \\text{and} \\qquad \n  \\Gamma^{\\theta }_{\\theta r } = \n  \\Gamma^{\\theta }_{r \\theta } = \\frac{1}{r} \n\\,.\n\\end{align}\n\nOur equation for the \\(r\\) coordinate is then: \n%\n\\begin{align}\n  \\dv[2]{r}{s} - r \\qty(\\dv{\\theta }{s})^2 = 0\n\\,,\n\\end{align}\n%\nwhile for the \\(\\theta \\) coordinate by symmetry we can identify the two terms: \n%\n\\begin{align}\n  \\dv[2]{\\theta }{s} + \\frac{2}{r} \\dv{r}{s} \\dv{\\theta }{s} =0\n\\,.\n\\end{align}\n\nIn general, in an \\(n\\) dimensional space, motion is defined by \\(n\\) scalar functions, which can be determined by our \\(n\\) differential equations with \\(2n\\) initial conditions.\n\nIt is in general useful to find \\emph{first integrals}, quantities which are constant along the geodesic.\n\nIt can be shown that the second equation can be written as\n%\n\\begin{align}\n  \\frac{1}{r^2} \\dv[]{}{s} \\qty(r^2 \\dv{\\theta }{s}) =0\n\\,,\n\\end{align}\n%\nwhich gives us the first integral \\(A = r^2 \\dv*{\\theta }{s}\\).\n\n\\begin{bluebox}\nAn easy way to see this: the equation can be written, denoting derivatives with respect to \\(s\\) with a dot, as \n%\n\\begin{align}\n\\ddot{\\theta} + \\frac{2 \\dot{r} \\dot{\\theta}}{r} = 0\n\\,,\n\\end{align}\n%\nwhich we can rearrange as \n%\n\\begin{align}\n\\frac{ \\ddot{\\theta}}{\\dot{\\theta}}\n+ 2 \\frac{\\dot{r}}{r} = 0\n\\,,\n\\end{align}\n%\nor \n%\n\\begin{align}\n\\dv{}{s} \\qty( \\log \\dot{\\theta} + 2 \\log r) =\n\\dv{}{s} \\log(\\dot{\\theta} r^2)\n=0\n\\,,\n\\end{align}\n%\nso we have found our integral: the derivative of the logarithm of something is constant iff the thing is constant.\n\\end{bluebox} \n\nWe can always also use the definition of the differential: \n%\n\\begin{align}\n    \\dd{s^2} = \\dd{r^2} + r^2 \\dd{\\theta^2 } \n    \\,,\n\\end{align}\n%\nso we can insert our integral:\n%\n\\begin{align}\n    \\dd{s^2} = \\dd{r^2} + r^2 \\frac{A^2}{r^{4}} \\dd{s^2}\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{align}\n  \\dd{s^2} \\qty(1- \\frac{A^2}{r^2}) = \\dd{r^2}\n\\,.\n\\end{align}\n\nThis has two solutions, but it can be shown that they give the same result in the end.\n\nWe want the trajectory: the locus of the points the geodesic passes through, \\(r(\\theta )\\) or \\(\\theta (r)\\).\n\nWe do: \n%\n\\begin{align}\n  \\dv[]{\\theta }{r} = \\dv[]{\\theta }{s} \\dv[]{s}{r} = \\frac{A}{r^2} \\frac{1}{\\sqrt{1- \\frac{A^2}{r^2}}}\n\\,,\n\\end{align}\n%\nso we can integrate this: \n%\n\\begin{align}\n  \\theta  = \\int \\dd{\\theta } = \\int\n  \\frac{A}{r^2} \\qty(1 - \\frac{A^2}{r^2})^{-1/2} \\dd{r}\n\\,,\n\\end{align}\n%\nwhich comes out to be \\(\\Delta \\theta  = \\arccos (A/r)\\), which can be inverted to find \\(r\\cos(\\Delta \\theta ) = A \\): using the trigonometric relation \n%\n\\begin{align}\n\\cos(x-y) = \\cos(x) \\cos(y) + \\sin(x) \\sin(y)\n\\,,\n\\end{align}\n%\nwe find that this is equivalent to \n%\n\\begin{align}\n  r \\cos(\\theta ) \\cos(\\theta_0 ) + r \\sin(\\theta ) \\sin(\\theta_0 ) = A\n\\,,\n\\end{align}\n%\ntherefore this can be written as \\(y = \\alpha x + \\beta \\).\n\n\\subsection{Euler-Lagrange equations}\n\nThe time interval can be written as \n%\n\\begin{subequations}\n\\begin{align}\n  \\tau_{AB} &= \\int \\dd{\\tau } = \\int \\sqrt{-\\dd{s^2}}  \\\\\n  &= \\int  \\dd{\\sigma } \\mathscr{L} \\qty(x^{\\alpha }, \\dv{x^{\\alpha }}{\\sigma }) \n\\,,\n\\end{align}\n\\end{subequations}\n%\nso under a perturbation we get: \n%\n\\begin{subequations}\n\\begin{align}\n  0 &= \\delta \\tau \\\\\n  &= \\int  \\dd{\\sigma } \\qty(\n      \\pdv{\\mathscr{L}}{x^{\\alpha }} \\delta x^{\\alpha } \n      + \\pdv{\\mathscr{L}}{\\dv{x^{\\alpha }}{\\sigma }} \n      \\dv{ \\delta x^{\\alpha }}{\\sigma }\n  )  \\\\\n  &= \\int  \\dd{\\sigma } \n  \\qty(\n      \\pdv{\\mathscr{L}}{x^{\\alpha }} - \\dv{}{\\sigma } \\qty(\\pdv[]{\\mathscr{L}}{\\dv{x^{\\alpha }}{\\sigma }})\n  ) \\delta x^{\\alpha } =0\n\\,,\n\\end{align}\n\\end{subequations}\n%\ntherefore the integrand must vanish identically: this gives us the Euler-Lagrange equations \n%\n\\begin{align}\n  \\pdv{\\mathscr{L}}{x^{\\alpha }} \n  - \\dv{}{\\sigma } \n  \\pdv{\\mathscr{L}}{\\dv{x^{\\alpha}}{\\sigma }}=0\n\\end{align}\n\n\\subsection{Killing vectors}\n\nSymmetries of the metric correspond to conserved quantities if our Lagrangian only depends on the metric.\nIf the metric does not depend on a coordinate, then the unit vector in that direction is called a Killing vector field. \n\nIf we have a Killing vector field, then the momentum along the Killing vector is conserved.\n\nIf the Killing coordinate is \\(x^{1}\\), it can be expressed as \n%\n\\begin{align}\n  \\pdv{\\mathscr L}{\\dv{x^{1}}{\\sigma }} = \\frac{1}{2 \\mathscr L} \\qty(-2 g_{1 \\beta } \\dv{x^{\\beta }}{\\sigma }) = - g_{1 \\beta } \\dv{x^{\\beta }}{\\tau }\n\\,,\n\\end{align}\n%\nwhere we performed a change of variable from the derivation with respect to \\(\\sigma \\) to one with respect to \\(\\tau \\).\n\nThis holds because:\n%\n\\begin{align}\n\\mathscr{L} = \\sqrt{- g_{\\alpha \\beta } \\dv{x^{\\alpha }}{\\sigma } \\dv{x^{\\beta }}{\\sigma }} = \\dv{\\tau }{\\sigma }\n\\,.\n\\end{align}\n\nThis is usually written as \\(\\xi^{\\mu } u_{\\mu } = \\const\\), which is actually more general.\nWe can write it with respect to the momentum: \\(p^{\\mu } \\xi_{\\mu }\\) since we are considering a constant-mass particle.\n\nWe can apply this to our 2D example: the metric does not depend on \\(\\theta \\), therefore \\(\\xi = (0,1)\\) is a Killing vector, so \\(g_{\\theta \\mu  } u^{\\mu } = r^2 \\dv*{\\theta }{s} = \\const\\).\n\n\n\n\\end{document}", "meta": {"hexsha": "7ba3df217f8781377e0f05c207bd01e2e90bc333", "size": 7059, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/08nov.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/08nov.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/08nov.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 31.3733333333, "max_line_length": 234, "alphanum_fraction": 0.6294092648, "num_tokens": 2467, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.4359599123939549}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{amsfonts}\n\\usepackage{graphicx}\n\\usepackage{amsmath,textcomp,amssymb,geometry,graphicx,enumerate}\n\\usepackage{amssymb}\n\\usepackage{algorithm} % Boxes/formatting around algorithms\n\\usepackage[noend]{algpseudocode} % Algorithms\n\\usepackage[usenames,dvipsnames]{color}\n\n\n\\begin{document}\n\n\\title{CongressRank: A PageRank Application}\n\\author{Chandler Chen, David Tseng}\n\\date{\\today}\n\\maketitle\n\n\\section*{Introduction}\nWhen a bill is introduced to Congress, the original proponent is usually called the \\textit{sponsor}. Congress members who support the bill can sign onto the bill as a \\textit{cosponsor}. The political community places great emphasis on cosponsorships, as it is believed that a bill with more cosponsorships demonstrates a greater support base. Thus, the number of cosponsorships of a bill is an indicator of the popularity of the bill among Congress members. Since a Congress member will only agree to cosponsor a sponsor's bill if he or she agrees with the bill's contents, a cosponsorship can also symbolize the cosponsor's support for and agreement with the sponsor. We believe that by analyzing the network of cosponsorships, we can have a better understanding of the power dynamics and unity within Congress. \n\nIn this project, we used PageRank to analyze the cosponsorship graph. PageRank is a ranking algorithm developed to find the stationary distribution of a Markov Chain, where a crawler visits other nodes (where neighboring nodes are chosen uniformly at random) for many iterations. As the number of iterations increases, the percentage of visits a node receives converges to the graph's stationary distribution, and nodes are ranked based on the number of visits they receive. We believe that the rankings generated by PageRank on this graph will be able to rank each member's importance/support within Congress. \n\n% probably be more clear about what you are ranking\n\n% include graphic of edge pointing from cosponsor to sponsor. \n\n\n\\section*{Methods}\nIn our project, we represented each Congress member as a node. If member $u$ cosponsors member $v$ on a bill, then a directed edge is placed from $u$ to $v$ on the graph. If $u$ cosponsors $v$ on $x$ different bills, there will be $x$ parallel directed edges from $u$ to $v$. Since outgoing edges are chosen uniformly at random in PageRank, if there are more parallel directed edges from $u$ to $v$, the crawler will have a higher probability of visiting $v$ from $u$. Representatives and Senators are analyzed in separate graphs. \n\nWe decided to use data from the 114th Congress (2015-2017), since this was the most recent Congress that completed its term. Although the 114th Congress had 100 Senators, 435 Representatives, and 6 non-voting members, there were 7 additional members who left Congress before their term ended. Therefore, we included a total of 548 members (nodes) in our graph. To extract the bill and member data, we used ProPublica's Congress API, which presented us the data in a convenient JSON format. \\\\\n\n\n\n%http://tex.stackexchange.com/questions/160540/how-to-number-figures-continuously-in-documentclassarticle\n\n\n\\textbf{Pseudocode}\n\n\\begin{algorithmic}[1]\n\\Procedure{createGraph}{bills}\n\\State graph = dictionary initialized to a mapping between each member to an empty list. This will be a mapping between each member to a list of members that he/she cosponsored, i.e., a dictionary mapping each node to a list of adjacent nodes. \n\\For{bill in bills}\n\t\\For {cosponsor in bill[cosponsors]}\n\t\t\\State graph[cosponsor].append(sponsor) \n\t\\EndFor \n\\EndFor\n\\State \\Return graph\n\\EndProcedure\\\\\n\n\n\\Procedure{PageRank}{bills, numIterations, p} // bills = list of bills that we are analyzing for our graph. numIterations = total number of visits to be made. p = probability of resetting to a random node. \n\\State graph = createGraph(bills) \n\\State membersNumVisits = dictionary initialized to a mapping between each member to 0. This will eventually be a dictionary mapping each member to the number of visits he/she receives during the PageRank algorithm. \n\\State currentMember = randomly chosen member\n\\State membersNumVisits[currentMember] += 1\n\\For {i in range(numIterations)}\n\t\\If {currentMember sponsored no one or Uniform[0,1] $<$ p}\n\t\t\\State currentMember = randomly chosen member\n\t\\Else\n\t\t\\State neighbors = graph[currentMember] // list of adjacent nodes\n\t\t\\State currentMember = randomly chosen member from neighbors, uniformly at random\n\t\\EndIf\n\t\\State membersNumVisits[currentMember] += 1\n\n\\EndFor\n\\State Sort members based on the number of visits, in descending order. \n\\State \\Return membersNumVisits\n\\EndProcedure\n\\end{algorithmic}\n\nAbove is the pseudocode we used to generate our graph and run our PageRank algorithm. We retrieved the list of bills and their sponsors and cosponsors by using calls to ProPublica's Congress API. \n\n\\section*{Experiment 1: Results and Analysis}\nFor Experiment 1, we included cosponsorships of all bills that were introduced by the 114th Congress, and all of their corresponding sponsors and cosponsors. We set $p$=0.15 (probability of resetting to a random node) and ran the PageRank algorithm for 100,000 steps. If we decrease $p$ to 0.05 or increase $p$ to 0.20, the rankings remain relatively the same. If we further increase $p$ to even higher values, the results become more uniformly random, so we believe it is more meaningful to keep  $p$ at around 0.15. \n\n\n\\begin{table}[h!]\n\\centering\n \\begin{tabular}{|c | c |c |c|} \n \\hline\n Rank & Normalized No. Visits & Name & Party \\\\ [0.5ex] \n \\hline\n1  & 1.000000 & Diane Black & R \\\\\n2  & 0.812907 & Erik Paulsen & R \\\\\n3  & 0.758962 & Sam Johnson & R \\\\\n4  & 0.744396 & Charles Boustany Jr. & R \\\\\n5  & 0.739433 & Brett Guthrie & R \\\\\n6  & 0.690203 & Christopher Smith & R \\\\\n7  & 0.664008 & Tom Price & R \\\\\n8  & 0.657639 & Paul Gosar & R \\\\\n9  & 0.638455 & Kevin Brady & R \\\\\n10 &  0.625765 &  Peter Roskam & R \\\\\n \\hline\n \n\\end{tabular}\n\\caption{Top 10 ranking of Representatives, using all bills that were introduced}\n\\label{table:experiment1}\n\\end{table}\n\n\\begin{table}[h!]\n\\centering\n \\begin{tabular}{|c | c |c |c|} \n \\hline\n Rank & Normalized No. Visits & Name & Party \\\\ [0.5ex] \n \\hline\n1  & 1.000000 & Orrin Hatch &R\\\\\n2  & 0.983083 & Charles Grassley &R\\\\\n3  & 0.800678 & John Thune &R\\\\\n4  & 0.696344  & Benjamin Cardin & D\\\\\n5  & 0.693545  & Mark Kirk & R\\\\\n6  & 0.652788  & John Cornyn & R\\\\\n7  & 0.625090  & Marco Rubio & R\\\\\n8  & 0.620461  & Jerry Moran & R\\\\\n9  & 0.614111  & Mike Lee & R\\\\\n10 &  0.608837 &  Rob Portman & R\\\\\n \\hline\n \n\\end{tabular}\n\\caption{Top 10 ranking of Senators, using all bills that were introduced}\n\\label{table:experiment1_2}\n\\end{table}\n\nTables \\ref{table:experiment1} and \\ref{table:experiment1_2} list the resulting top 10 Representatives and Senators from our data. The second column displays the number of visits each member received during the course of the PageRank algorithm, normalized by the maximum number received. From our results, it appears that Diane Black and Orrin Hatch are the most popular in their respective chambers. One interesting thing to note is that almost every top 10 member is a Republican, even though we included members from both parties. Since we analyzed all bills that were introduced, this captures the most interactions possible between members via bills. From this analysis, it seems like Republicans were generally more unified compared to Democrats during the 2015-2017 Congress. This makes sense, because Republicans controlled both the House and the Senate during this period of time. Politicians tend to support other politicians in the same party, so therefore the Republicans' advantage in numbers boosted their rankings. \n\nWe also noted that some members with leadership positions (such as Nancy Pelosi, Paul Ryan, Mitch McConnell) actually had relatively low rankings. For example, Mitch McConnell ranked 91 within the 100 Senators. It seems like ranking members based on a network of cosponsorships of all bills is not necessarily a good indication of actual influence in Congress. This may be because we included every bill that is introduced, so a person who writes many insignificant bills can accumulate more cosponsorships, leading to skewed results.\n\n\\section*{Experiment 2: Results and Analysis}\nFor our next experiment, we decided to only analyze cosponsorships of bills that were actually signed into law. We ran PageRank on this filtered dataset, using the same parameters as before. \n\n\n\\begin{table}[h!]\n\\centering\n \\begin{tabular}{|c | c |c |c|} \n \\hline\n Rank & Normalized No. Visits & Name & Party \\\\ [0.5ex] \n \\hline\n1  & 1.000000 &Sam Johnson & R \\\\  \n2  & 0.801382 &Bill Posey & R \\\\  \n3  & 0.741576 &Carolyn Maloney & D \\\\  \n4  & 0.715829 &Terri Sewell & D \\\\  \n5  & 0.706899 &Jeff Fortenberry & R \\\\  \n6  & 0.590983 &Brett Guthrie & R \\\\  \n7  & 0.567227 &Martha McSally & R \\\\  \n8  & 0.548026 &Seth Moulton & D \\\\  \n9  & 0.507255 &Edward Royce & R \\\\  \n10 &  0.337657 & Christopher Smith & R \\\\  \n \\hline\n \n\\end{tabular}\n\\caption{Top 10 ranking of Representatives, using only bills that were signed into law.}\n\\label{table:experiment2}\n\\end{table}\n\n\\begin{table}[h!]\n\\centering\n \\begin{tabular}{|c | c |c |c|} \n \\hline\n Rank & Normalized No. Visits & Name & Party \\\\ [0.5ex] \n \\hline\n1 & 1.000000 & John Cornyn & R \\\\ \n2 & 0.713656 & Roy Blunt & R \\\\ \n3 & 0.683725 & Orrin Hatch & R \\\\ \n4 & 0.627329 & Dianne Feinstein & D \\\\ \n5 & 0.525480 & Mazie Hirono & D \\\\ \n6 & 0.492836 & Benjamin Cardin & D \\\\ \n7 & 0.421928 & Sheldon Whitehouse & D \\\\ \n8 & 0.320936 & Patrick Leahy & D \\\\ \n9 & 0.280296 & Heidi Heitkamp & D \\\\ \n10& 0.278308 & Rob Portman & R \\\\  \\hline\n \n\\end{tabular}\n\\caption{Top 10 ranking of Representatives, using only bills that were signed into law.}\n\\label{table:experiment2_2}\n\\end{table}\n \nTables \\ref{table:experiment2} and \\ref{table:experiment2_2} show the results of this experiment. It now appears that Sam Johnson and John Cornyn have the highest ranking in their respective chambers. We note that the proportion of Democrats in the top 10 category is now higher than it was in the previous experiment. One possible explanation is that by only considering cosponsorships on bills that were eventually signed into law, the rankings are more representative of the members' level of influence than their popularity.  This idea is also supported by the fact that people in leadership positions (Paul Ryan, Nancy Pelosi, Mitch McConnell) all have higher rankings here compared to the previous experiment. For example, while Mitch McConnell was ranked 91st previously, he now ranks 15th. This shows that indeed, the second experiment shows more about each member's influence in Congress. \nBecause the Democrats make up approximately half of the people in the top 10, it seems like the Democrats have almost equal influence as Republicans. \n \n \n\n% include example of networkx graph. \n\n\n\n%We noted that despite the quantity of bills used in Experiment 1, many of the bills did not even make it past one chamber of Congress. For Experiment 2, we decided that in order to filter out insignificant bills, it might be more meaningful to only look at bills that passed by at least one chamber of Congress. We then ran the experiment the same way. \n\n% results\n\n\n%To take it further, we decided to finally consider only bills that were actually signed into law. We then ran the experiment the same way as Experiment 1 and 2. \n\n\n% talk about which p values you used. \n\n\n\n\\section*{Discussion and Limitations}\nThere are several limitations to our approaches. One limitation is that although we were only aiming to analyze the 114th Congress, many members were already in Congress before 2015, and they had many more contributions before then. So while our rankings may show some general trends in popularity/support from the interactions in 2015-2017, it does not include interactions between members that were already there before 2015.\n\nOur model is also limited by omitting the relative importance of each considered bill. For instance, H.R.6135-114, a bill \\textit{To designate the Federal building and United States courthouse located at 719 Church Street in Nashville, Tennessee, as the \"Fred D. Thompson Federal Building and United States Courthouse\"} may not be as important as a major defense bill. True, this notion of importance is subjective, so objective importance may be better approximated with the quantifiable amount of discretionary spending put forth in each bill. Even this approach is flawed since large trade deals or important foreign policies may be excluded, but it remains a step in the right direction.\n% did not take into account the fact that some bills are more important than others. Weighed each bill the same amount. \n% Dicussion: We can see that cosponsorships does not really have a correlation with leadership in Congress.\n\nOverall, despite these limitations, our PageRank algorithm produced some very interesting results. While Republicans may have enjoyed higher levels of popularity in the 114th Congress, Democrats and Republicans shared somewhat equal levels of influence. \n\n\n\n\n\n\n%It's interesting to note, that strong correlation fails to exist between the ability to pass bills and having a heavy network of cosponsors within each chamber. Congress members do spend a significant portion of their time gathering cosponsors for their bills, perhaps the time should better be spent on more productive tasks. \n\n\n% We only looked at 2 years, which is not the same as their actual contributions over time\n\n% experiment 2 shows more about influence than popularity. \n\n\n\n\n\\end{document}\t", "meta": {"hexsha": "f3c0560164734d4ca07877893eea7b9116c2a8eb", "size": 13687, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report.tex", "max_stars_repo_name": "tsengd/CongressRank", "max_stars_repo_head_hexsha": "d9fb5c734db12ae829c92d61f57ba5d452e8cc74", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report.tex", "max_issues_repo_name": "tsengd/CongressRank", "max_issues_repo_head_hexsha": "d9fb5c734db12ae829c92d61f57ba5d452e8cc74", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report.tex", "max_forks_repo_name": "tsengd/CongressRank", "max_forks_repo_head_hexsha": "d9fb5c734db12ae829c92d61f57ba5d452e8cc74", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.6531531532, "max_line_length": 1030, "alphanum_fraction": 0.7643018923, "num_tokens": 3447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.4359599092096591}}
{"text": "\\subsection{Proposed approach}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nThe main purpose of this work is to investigate the feasibility of deep learning approaches for delamination identification in CFRP materials by only utilizing frames of the full wavefield propagation of the guided waves.\r\nAccordingly, two deep learning models based on time data sequence were developed.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{figure} [!h]\r\n\t\\centering\r\n\t\\begin{subfigure}[b]{0.49\\textwidth}\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=.2\\textheight]{Fully_ConvLSTM2d_MODEL_updated.png}\r\n\t\t\\caption{Convolutional LSTM model}\r\n\t\t\\label{fig:convlstm_model}\r\n\t\\end{subfigure}\r\n\t\\hfill\r\n\t\\begin{subfigure}[b]{0.49\\textwidth}\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=.2\\textheight]{RNN_LSTM_MODEL_updated.png}\r\n\t\t\\caption{Time distributed AE model}\r\n\t\t\\label{fig:AE_convlstm}\r\n\t\\end{subfigure}\r\n\t\\caption{The architecture of the proposed deep learning models.}\r\n\t\\label{fig:proposed_models}\r\n\\end{figure} \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nThe developed models presented in Fig.~\\ref{fig:proposed_models} have a scheme of Many-to-One sequence prediction, in which it takes \\(n\\) number of frames representing the waves propagation through time and their interaction with the damage in order to extract the damage features, and finally predicts the delamination location, shape and size in a single output image.\r\n\r\nThe first proposed model presented in~\\ref{fig:convlstm_model} \r\nconsists of a three ConvLSTM layers with the filter sizes of 10, 5, and 10 respectively.\r\nThe kernel size of the ConvLSTM layers was set to (\\(3\\times3\\)) with a stride of 1 padding was set to \"same\" which makes the output as same as the input in the case of stride 1.\r\nFurthermore, a \\(tanh\\) (the hyperbolic tangent) activation function was used at the ConvLSTM layers, which outputs a values in a range between \\(-1\\) and \\(1\\).\r\nMoreover, batch normalization~\\cite{Santurkar2018} was also applied after each ConvLSTM layer.  \r\nThe final layer is used a simple 2D convolutional layer followed by a sigmoid activation function which outputs values in a range between \\(0\\) and \\(1\\) to indicate the delamination probability.\r\nIn this model, we applied a binary cross-entropy as the objective function.\r\nMoreover,Adadelta~\\cite{zeiler2012adadelta} optimization technique was utilised that performs back-propagation through time (BPTT)~\\cite{goodfellow2016deep}. \r\nSince the sigmoid activation function produces probability values between \\(0\\) and \\(1\\), a threshold value must be chosen to classify the output into a damaged or undamaged classes.\r\nAccordingly, the threshold value was set to (\\(0.5\\)).\r\nThe reason for choosing this value for the sigmoid activation function is explained in our previous research work~\\cite{ijjeh2021full}.\r\n\r\nIn the second model presented in~\\ref{fig:AE_convlstm} we have applied an autoencoder technique (AE) which is well-known technique for features extraction.\r\nThe idea of AE is to compress the input data within the encoding process then learn how to reconstruct it back from the reduced encoded representation (latent space) to a representation that is as close to the original input as possible. \r\nAccordingly, AE reduces data dimensions by learning how to discard the noise in the data.\r\nIn this model, we have investigated the use of AE to process a sequence of input frames in order to perform image segmentation operation.\r\nAccordingly, a Time Distributed layer presented in Fig.~\\ref{fig:TD} was introduced to the model, in which it distributes the input frames into the AE to keep the independently among frames.\r\n\\begin{figure}[!h]\r\n\t\\centering\r\n\t\\includegraphics[width=0.5\\textwidth]{Time_ditributed_layer.png}\r\n\t\\caption{Flow of input frames using Time distributed layer}\r\n\t\\label{fig:TD}\r\n\\end{figure}\r\n\r\nThe AE consists of three parts: the encoder, the bottleneck, and the decoder.\r\nThe encoder is responsible for learning how to reduce the input dimensions and compress the input data into an encoded representation.\r\nIn Fig.~\\ref{fig:AE_convlstm}, the encoder part consists of four levels of downsampling. \r\nThe purpose of having different scale levels is to extract feature maps from the input image at different scales.\r\nEvery level at the encoder consists of two 2D convolution operations followed by a Batch Normalization then a dropout is applied. \r\nFurthermore, at the end of each level a Maxpooling operation is applied to reduce the dimensionality of the inputs. \r\nThe bottleneck presented in Fig.\\ref{fig:AE_convlstm} has the lowest level of dimensions of the input data, further it consists of two 2D convolution operations followed by a Batch Normalization.\r\nThe decoder part presented in Fig.\\ref{fig:AE_convlstm}, is responsible of learning how to restore the original dimensions of the input.\r\nThe decoder part consists of two 2D convolutional operations followed by Batch Normalization and Dropout, and an upsampling operation is applied at the end of each decoder level to retrieve the dimensions of its inputs.\r\nMoreover, to enhance the performance learning of the decoder skip connections linking the encoder with the corresponding decoder levels were added.\r\nThe outputs sequences of the decoder part is fed into the ConvLSTM2D layer that is utilized to learn long-term spatiotemporal features.\r\nFinally, a 2D convolution operations is applied on the output of the ConvLSTM2d layer followed by a sigmoid activation function.", "meta": {"hexsha": "76ebbec34a279c3cb0e29cb3adf06b79f60f49a7", "size": 5542, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/journal_papers/ConvLSTM Paper/Model_architecture.tex", "max_stars_repo_name": "IFFM-PAS-MISD/aidd", "max_stars_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-03T05:36:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:36:07.000Z", "max_issues_repo_path": "reports/journal_papers/ConvLSTM Paper/Model_architecture.tex", "max_issues_repo_name": "IFFM-PAS-MISD/aidd", "max_issues_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/journal_papers/ConvLSTM Paper/Model_architecture.tex", "max_forks_repo_name": "IFFM-PAS-MISD/aidd", "max_forks_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.9682539683, "max_line_length": 372, "alphanum_fraction": 0.7675929267, "num_tokens": 1252, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4359599060253634}}
{"text": "% !TEX program = pdflatex\n\n\\documentclass[11pt]{article}\n\\usepackage{amsmath,amsfonts,amsthm,amssymb,geometry,dsfont}\n\\usepackage[usenames,dvipsnames,svgnamesable]{xcolor}\n\\usepackage[capitalise,noabbrev]{cleveref} %\n%\\usepackage{natbib,url}\n\\crefname{equation}{}{} %\n\\crefname{assumption}{Assumption}{Assumptions}\n\\crefname{property}{Property}{Properties}\n\\geometry{left=1in,right=1in,top=0.6in,bottom=1in}\n\\newcommand{\\set}[1]{\\ensuremath{\\left\\{{#1}\\right\\}}}\n\\newcommand{\\R}{\\ensuremath{\\mathbb{R}}}\n\\newcommand{\\diff}{\\ensuremath{\\mathrm{diff}}}\n\\newcommand{\\band}{\\ensuremath{\\mathrm{band}}}\n\\newcommand{\\toep}{\\ensuremath{\\mathrm{toep}}}\n\\newcommand{\\tridiag}{\\ensuremath{\\mathrm{tridiag}}}\n\\newcommand{\\diag}{\\ensuremath{\\mathrm{diag}}}\n\\newcommand{\\D}[1][]{\\ensuremath{\\partial_{#1}}}\n\\newcommand{\\indicator}[1]{\\ensuremath{\\mathds{1}\\left\\{{#1}\\right\\}}}\n\\newcommand{\\condexpec}[3][]{\\ensuremath{\\mathbb{E}_{#1}\\left[{#2} \\; \\middle| \\; {#3} \\right]}}\n\\newcommand{\\expec}[2][]{\\ensuremath{\\mathbb{E}_{{#1}}\\left[ {#2} \\right]}}\n\\geometry{left=1in,right=1in,top=0.6in,bottom=1in}\n\\newenvironment{psmallmatrix}\n{\\left(\\begin{smallmatrix}}\n\t{\\end{smallmatrix}\\right)}\n\n\\theoremstyle{definition}\n\\newtheorem{example}{Examples}[section]\n\n\\bibliographystyle{ecta}\n\\begin{document}\n\\title{Notes on Discrete Simulations}\n\\author{Jess Benhabib, Jesse Perla, and Christopher Tonetti}\n\\maketitle\n\n\\section{Overview}\nThis package is \n\n\\subsection{Linear Differential Equations}\n\n\nStaley, Luttmer formulation, in log productivity,%\n\\[\n\\partial _{t}G\\left( z,t\\right) =\\frac{\\sigma ^{2}}{2}\\partial\n_{z}^{2}G\\left( z,t\\right) -\\mu \\partial _{z}G\\left( z,t\\right) -\\alpha\nG\\left( z,t\\right) \\left( 1-G\\left( z,t\\right) \\right) \n\\]%\n\\[\nG\\left( t,-\\infty \\right) =0,\\ \\ G\\left( t,+\\infty \\right) =1,\\ \\ \\ G\\left(\n0,z\\right) =G_{0} \n\\]\n\nTransform variables%\n\\[\n\\tilde{t}=\\alpha t,\\ \\ \\tilde{z}=\\frac{\\left( 2\\alpha \\right) ^{.5}}{\\sigma }%\n\\left( z-\\mu t\\right) ,\\ \\ H\\left( t,z\\right) =1-G(t,z)\n\\]%\nwe get KPP:%\n\\begin{equation}\n\\partial _{t}H\\left( t,z\\right) =\\partial _{z}^{2}H\\left( t,z\\right)\n+H\\left( t,z\\right) \\left( 1-H\\left( t,z\\right) \\right)   \\label{H}\n\\end{equation}%\nwith solution that depends on initial conditions given by $H\\left(\n0,z\\right) $, and $v$ is th speed of the travelling wave solution to (\\ref{H}%\n).%\n\\[\nH\\left( t,z\\right) =W_{v}\\left( z-vt\\right) \n\\]%\nFor a solution we get a travelling wave, \n\\[\n\\lim_{x\\rightarrow \\infty }W_{v}\\left( x\\right) \\sim e^{-\\gamma x}\n\\]%\nwhere $\\gamma $ is the smallest $\\gamma $ that solves $v=\\gamma +\\gamma\n^{-1}.$\n\nIf initial $H\\left( 0,z\\right) $ is Dirac or a compact perturbation of a\nstep function, then $v=2$, $\\gamma =1,$ and there is a unique travelling\nwave function.\n\nIf $H\\left( 0,z\\right) \\sim e^{-\\gamma x},\\ 0<\\gamma <1,\\ $\\ then $\\gamma $\nsolves $v=\\gamma +\\gamma ^{-1}$ $>2$ as above. ALSO: From Murray,\nMathematical Biology, 1993, Springer, page 280, eq. (11.19): if $\\gamma \\geq\n1,\\ $for $H\\left( 0,z\\right) \\sim e^{-\\gamma x},$ then $v=2.$\n\nRecovering the untransformed system: \n\nTo reverse the transformation to get back to $G\\left( t,z\\right) $, we have: \n\\begin{eqnarray}\n\\ G\\left( t,z\\right)  &=&1-H(\\alpha t,\\frac{\\left( 2\\alpha \\right) ^{.5}}{%\n\\sigma }\\left( z-\\mu t\\right) )\\sim e^{-\\gamma \\tilde{z}}  \\label{G1} \\\\\n&=&e^{-\\gamma \\left( \\frac{\\left( 2\\alpha \\right) ^{.5}}{\\sigma }\\left(\nz-\\mu t\\right) -v\\alpha t\\right) }=e^{-\\gamma \\frac{2\\alpha }{\\sigma }\\left(\n\\left( z-\\mu t\\right) -v\\frac{\\sigma }{\\left( 2\\alpha \\right) ^{.5}}\\alpha\nt\\right) }=e^{-\\gamma \\frac{2\\alpha }{\\sigma }\\left( z-\\left( \\mu +v\\left( \n\\frac{\\alpha }{2}\\right) ^{.5}\\sigma \\right) t\\right) }  \\label{G2} \\\\\n&=&e^{-\\gamma \\frac{2\\alpha }{\\sigma }\\left( z-\\left( \\mu +\\left( \\gamma +%\n\\frac{1}{\\gamma }\\right) \\left( \\frac{\\alpha }{2}\\right) ^{.5}\\sigma \\right)\nt\\right) }  \\label{G3}\n\\end{eqnarray}%\nfor $z>\\left( \\mu +v\\left( \\frac{\\alpha }{2}\\right) ^{.5}\\sigma \\right) t$ $%\n\\ $\\ along the travelling wave.Thus wave speed  for the original system $%\nG\\left( t,z\\right) $ is $\\left( \\mu +\\left( \\gamma +\\frac{1}{\\gamma }\\right)\n\\left( \\frac{\\alpha }{2}\\right) ^{.5}\\sigma \\right) $ and the exponential\ndecay rate for log productivity is $\\left( \\gamma \\frac{2\\alpha }{\\sigma }%\n\\right) ,$  unless $v=2$ and $\\gamma =1$ because $H\\left( 0,z\\right) \\sim\ne^{-\\gamma x}$ with $\\gamma \\geq 1,$ and then wave speed is $v=2$ so that $%\n\\left( \\mu +2\\left( \\frac{\\alpha }{2}\\right) ^{.5}\\sigma \\right) =\\mu\n+\\left( 2a\\right) ^{.5}\\sigma $ along the travelling wave for $z>\\left( \\mu\n+\\left( 2a\\right) ^{.5}\\sigma \\right) t,$ and the decay rate of log\nproductivity distribution is $e^{-\\frac{2\\alpha }{\\sigma }.}$\n\nNote these cdf's for $G\\left( t,z\\right) $ are in log productivity: $log\\\n\\left( z\\right) \\sim e^{-\\gamma \\frac{2\\alpha }{\\sigma }z},\\ x\\sim e^{\\log\n\\left( z^{-\\gamma \\frac{2\\alpha }{\\sigma }}\\right) }\\sim z^{-\\gamma \\frac{%\n2\\alpha }{\\sigma }}.$ For the pareto to have a mean we need $-\\gamma \\frac{%\n2\\alpha }{\\sigma }.$\n\nMildred, in her SSRN paper had used the relations from above found in\nMcKean, Brunet-Derrida, Bramson, Murray and others, to study whether the\ndrop in recent growth is compatible with decreasing diffusion $\\sigma ,$\nwhich also decreases inequality as given by the tail index  $\\frac{\\gamma\n\\left( 2\\alpha \\right) ^{.5}}{\\sigma },$ an inverse measure of inequality.\nThe tail index  however decreases with $\\alpha $, compatible with decreasing\nimitation  and rising inequality. One can argue therefore that decreasing $%\n\\alpha $ reflects increasing industry concentration, fostering inequality.\nIn Jones and Kim however higher growth  due to more leapfrogging and\ninventions also generates  higher inequality, while we have recently\nobserved decreasing growth and higher inequality. Playing with both $\\alpha $\nand $\\sigma $, Mildred could get both an increase in inequality and lower\ngrowth, as in equation (\\ref{G3}) above.\n\n\n%\\bibliography{simulation_notes}\n\\end{document}\n", "meta": {"hexsha": "fc2d7720bc8c8c3e81609a0b24d857e52c54be42", "size": 5971, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/simulation_notes.tex", "max_stars_repo_name": "PooyaFa/KnowledgeDiffusionSimulations.jl", "max_stars_repo_head_hexsha": "3e923d177e53b757d4bc8828d3fe1ed8b91846ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-09-19T09:14:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T14:39:06.000Z", "max_issues_repo_path": "tex/simulation_notes.tex", "max_issues_repo_name": "PooyaFa/KnowledgeDiffusionSimulations.jl", "max_issues_repo_head_hexsha": "3e923d177e53b757d4bc8828d3fe1ed8b91846ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/simulation_notes.tex", "max_forks_repo_name": "PooyaFa/KnowledgeDiffusionSimulations.jl", "max_forks_repo_head_hexsha": "3e923d177e53b757d4bc8828d3fe1ed8b91846ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2019-09-14T01:27:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T01:24:25.000Z", "avg_line_length": 43.9044117647, "max_line_length": 96, "alphanum_fraction": 0.6709093954, "num_tokens": 2145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.4359598996567715}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tikz, xcolor}\n\\usetikzlibrary{arrows.meta, calc}\n\n\\title{Polar Coordinates}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\titlepage\n\\end{frame}\n\n\\section{Plot polar coordinates.}\n\n\\begin{frame}{Polar Coordinates}\n    \\begin{tabular}{p{0.4\\textwidth}p{0.4\\textwidth}}\n\\begin{tikzpicture}\n    \\coordinate (O) at (0,0);\n    \\draw [->, >=stealth, color=blue, line width = 1.25] (O) -- (2,0) node [above, midway, black] {Polar axis}; \n    \\draw [fill=blue, color=blue] (O) circle (2pt) node [below left, black] {Pole};\n\\end{tikzpicture}\n&\n\\begin{tikzpicture}\n    \\coordinate (O) at (0,0);\n    \\draw [->, >=stealth, color=blue, line width = 1.25] (O) -- (2,0) node [below, midway, black] {Polar axis}; \n    \\draw [fill=blue, color=blue] (O) circle (2pt) node [below left, black] {Pole};\n    \\draw [-, >=stealth, color=blue, line width = 1.25] (O) -- (30:2) node [right, black] {$P=(r,\\theta)$};\n    \\draw [color=red, fill=red] (30:2) circle (2pt);\n    \\draw [->,>=stealth] (0:1) arc (0:30:1) node [midway, right] {$\\theta$};\n    \\node at (30:1) [above left] {$r$};\n\\end{tikzpicture}\n\\end{tabular}\n\\\\[10pt]\n\\pause\nFor polar coordinates:  \\newline\\\\\n\\begin{itemize}\n    \\item Start at the origin (pole)    \\pause\n    \\item Go out $r$ units right ($r > 0$) or left ($r < 0$)    \\pause\n    \\item Rotate by the amount given (\\textbf{**direction**})   \\pause\n\\end{itemize}\n\\vspace{10pt}\n\nThe polar coordinates of a point are $(r, \\theta)$.\n\\end{frame}\n\n\\begin{frame}{Example 1. Plot each of the following}\n\\begin{minipage}{0.56\\textwidth}\n\\begin{tikzpicture}[scale = 0.52, every node/.style={scale=0.6}]\n    % Origin Point\n    \\coordinate (O) (0,0);\n    % Circles\n    \\foreach \\r in {1.5,3,...,6}\n    {\n        \\draw[thick] (O) circle (\\r cm);\n    }\n    \n    % \\foreach \\r in {1.5,3,...7.5}\n    % {\n    %     \\node at (\\r, 0) [anchor=north] {\\r/};\n    % }\n    \n    \\foreach \\r in {0.75, 2.25,...,5.25}\n    {\n        \\draw[dotted] (O) circle (\\r cm);\n    }\n    \n    % \\node at (1.5, 0) [anchor = north west] {1};\n    % \\node at (3, 0) [anchor = north west] {2};\n    % \\node at (4.5, 0) [anchor = north west] {3};\n    % \\node at (6, 0) [anchor = north west] {4};\n    % \\node at (7.5,0) [anchor = north west] {5};\n    % \\foreach \\r in {1.5,3,...,9}\n    % {\n    %     \\node at (\\r, 0) {\\r/1.5};\n    % }\n    % Radial Lines\n    \\foreach \\l in {0,15,...,360}\n    {\n        \\draw (O) -- ++(\\l:6cm);\n    }\n    % Thicker Radial Lines at 90 degree increments\n    \\foreach \\l in {0,90,...,360}\n    {\n        \\draw[very thick] (O) -- ++(\\l:6cm);\n    }\n    % Minor Tick marks on outer circle\n    \\foreach \\t in {0,5,...,360}\n    {\n        \\draw (O) ++ (\\t:5.85cm) -- ++(\\t:0.3cm);\n    }\n    % Now for the fun part, the text\n    % Degrees\n    \\node[draw=none, rotate= -90 ] at ( 0 :6.45cm) {$ 0 ^\\circ$};\n    \\node[draw=none, rotate= -75 ] at ( 15 :6.45cm) {$ 15 ^\\circ$};\n    \\node[draw=none, rotate= -60 ] at ( 30 :6.45cm) {$ 30 ^\\circ$};\n    \\node[draw=none, rotate= -45 ] at ( 45 :6.45cm) {$ 45 ^\\circ$};\n    \\node[draw=none, rotate= -30 ] at ( 60 :6.45cm) {$ 60 ^\\circ$};\n    \\node[draw=none, rotate= -15 ] at ( 75 :6.45cm) {$ 75 ^\\circ$};\n    \\node[draw=none, rotate= 0 ] at ( 90 :6.45cm) {$ 90 ^\\circ$};\n    \\node[draw=none, rotate= 15 ] at ( 105 :6.45cm) {$ 105 ^\\circ$};\n    \\node[draw=none, rotate= 30 ] at ( 120 :6.45cm) {$ 120 ^\\circ$};\n    \\node[draw=none, rotate= 45 ] at ( 135 :6.45cm) {$ 135 ^\\circ$};\n    \\node[draw=none, rotate= 60 ] at ( 150 :6.45cm) {$ 150 ^\\circ$};\n    \\node[draw=none, rotate= 75 ] at ( 165 :6.45cm) {$ 165 ^\\circ$};\n    \\node[draw=none, rotate= 90 ] at ( 180 :6.45cm) {$ 180 ^\\circ$};\n    \\node[draw=none, rotate= 285 ] at ( 195 :6.45cm) {$ 195 ^\\circ$};\n    \\node[draw=none, rotate= 300 ] at ( 210 :6.45cm) {$ 210 ^\\circ$};\n    \\node[draw=none, rotate= 315 ] at ( 225 :6.45cm) {$ 225 ^\\circ$};\n    \\node[draw=none, rotate= 330 ] at ( 240 :6.45cm) {$ 240 ^\\circ$};\n    \\node[draw=none, rotate= 345 ] at ( 255 :6.45cm) {$ 255 ^\\circ$};\n    \\node[draw=none, rotate= 360 ] at ( 270 :6.45cm) {$ 270 ^\\circ$};\n    \\node[draw=none, rotate= 375 ] at ( 285 :6.45cm) {$ 285 ^\\circ$};\n    \\node[draw=none, rotate= 390 ] at ( 300 :6.45cm) {$ 300 ^\\circ$};\n    \\node[draw=none, rotate= 405 ] at ( 315 :6.45cm) {$ 315 ^\\circ$};\n    \\node[draw=none, rotate= 420 ] at ( 330 :6.45cm) {$ 330 ^\\circ$};\n    \\node[draw=none, rotate= 435 ] at ( 345 :6.45cm) {$ 345 ^\\circ$};\n    % Radians\n\n    \\node[draw=none, rotate= -90 ] at ( 0 :7cm) {$  $};\n    \\node[draw=none, rotate= -75 ] at ( 15 :7cm) {\\scriptsize$ \\pi/12 $};\n    \\node[draw=none, rotate= -60 ] at ( 30 :7cm) {\\scriptsize$ \\pi/6 $};\n    \\node[draw=none, rotate= -45 ] at ( 45 :7cm) {\\scriptsize$ \\pi/4 $};\n    \\node[draw=none, rotate= -30 ] at ( 60 :7cm) {\\scriptsize$ \\pi/3 $};\n    \\node[draw=none, rotate= -15 ] at ( 75 :7cm) {\\scriptsize$ 5\\pi/12 $};\n    \\node[draw=none, rotate= 0 ] at ( 90 :7cm) {\\scriptsize$ \\pi/2 $};\n    \\node[draw=none, rotate= 15 ] at ( 105 :7cm) {\\scriptsize$ 7\\pi/12 $};\n    \\node[draw=none, rotate= 30 ] at ( 120 :7cm) {\\scriptsize$ 2\\pi/3 $};\n    \\node[draw=none, rotate= 45 ] at ( 135 :7cm) {\\scriptsize$ 3\\pi/4 $};\n    \\node[draw=none, rotate= 60 ] at ( 150 :7cm) {\\scriptsize$ 5\\pi/6 $};\n    \\node[draw=none, rotate= 75 ] at ( 165 :7cm) {\\scriptsize$ 11\\pi/12 $};\n    \\node[draw=none, rotate= 90 ] at ( 180 :7cm) {\\scriptsize$ \\pi $};\n    \\node[draw=none, rotate= 285 ] at ( 195 :7cm) {\\scriptsize$ 13\\pi/2 $};\n    \\node[draw=none, rotate= 300 ] at ( 210 :7cm) {\\scriptsize$ 7\\pi/6 $};\n    \\node[draw=none, rotate= 315 ] at ( 225 :7cm) {\\scriptsize$ 5\\pi/4 $};\n    \\node[draw=none, rotate= 330 ] at ( 240 :7cm) {\\scriptsize$ 4\\pi/3 $};\n    \\node[draw=none, rotate= 345 ] at ( 255 :7cm) {\\scriptsize$ 17\\pi/12 $};\n    \\node[draw=none, rotate= 360 ] at ( 270 :7cm) {\\scriptsize$ 3\\pi/2 $};\n    \\node[draw=none, rotate= 375 ] at ( 285 :7cm) {\\scriptsize$ 19\\pi/12 $};\n    \\node[draw=none, rotate= 390 ] at ( 300 :7cm) {\\scriptsize$ 5\\pi/3 $};\n    \\node[draw=none, rotate= 405 ] at ( 315 :7cm) {\\scriptsize$ 7\\pi/4 $};\n    \\node[draw=none, rotate= 420 ] at ( 330 :7cm) {\\scriptsize$ 11\\pi/6 $};\n    \\node[draw=none, rotate= 435 ] at ( 345 :7cm) {\\scriptsize$ 23\\pi/12 $};\n    \n    \\onslide<2->{\\draw [color=red,fill=red] (240:3) circle (4pt) node [above] {$A$};}\n    \\onslide<4->{\\draw [color=red,fill=red] (30:6) circle (4pt) node [left, yshift=0.2cm] {$B$};}\n    \\onslide<6->{\\draw[color=red,fill=red] (270:3.75) circle (4pt) node [above right] {$C$};}\n    \\onslide<8->{\\draw[color=red,fill=red] (135:4.5) circle (4pt) node [right] {$D$};}\n\\end{tikzpicture} \n\\end{minipage}\n\\hspace{1.17cm}\n\\begin{minipage}{0.12\\textwidth}\n% (a) $A\\left(2, 240^\\circ\\right)$ \\\\[15pt]\n% \\onslide<3->{(b) $B\\left(-4,\\dfrac{7\\pi}{6}\\right)$} \\\\[15pt]\n% \\onslide<5->{(c) $C\\left(2.5,-\\dfrac{5\\pi}{2}\\right)$} \\\\[15pt]\n% \\onslide<7->{(d) $D\\left(-3, -\\dfrac{\\pi}{4}\\right)$} \\\\\n\\begin{align*}\n    &(a)\\quad A\\left(2, 240^\\circ\\right) \\\\[15pt]\n    \\onslide<3->{&(b)\\quad B\\left(-4,\\dfrac{7\\pi}{6}\\right)} \\\\[15pt]\n    \\onslide<5->{&(c)\\quad C\\left(2.5,-\\dfrac{5\\pi}{2}\\right)}    \\\\[15pt]\n    \\onslide<7->{&(d)\\quad D\\left(-3, -\\dfrac{\\pi}{4}\\right)}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\section{Convert from polar to rectangular coordinates.}\n\n\\begin{frame}{Polar to Rectangular Coordinates}\n\n\\begin{center}\n\\begin{tikzpicture}\n    \\draw [->, >=stealth] (-0.5,0) -- (3.5,0) node [right] {$x$};\n    \\draw [->, >=stealth] (0,-0.5) -- (0,2.5) node [left] {$y$};\n    \\draw (2.5,0) rectangle +(-0.25,0.25);\n    \\draw [color=blue, line width = 1.5] (0,0) -- (2.5,0) node [midway, below, black] {$x$};\n    \\draw [color=blue, line width=1.5] (2.5,0) -- (2.5,2) node [midway, right, black] {$y$};\n    \\draw [color=red, line width=1.5] (0,0) -- (2.5,2) node [above right] {$P(r,\\theta)$};\n    \\draw [color=red, fill=red] (2.5,2) circle (2pt);\n    \\node at (2.5,2) [below right, blue] {$P(x, y)$};\n    \\node at (1.25, 1) [above left] {$r$};\n    \\draw [->, >=stealth] (0:0.75) arc (0:38.5:0.75) node [midway, right] {$\\theta$};\n\\end{tikzpicture}\n\\end{center}\n\\pause\n\n\\begin{align*}\n    \\onslide<2->{\\cos\\theta = \\frac{x}{r} \\qquad & \\qquad \\sin\\theta = \\frac{y}{r}} \\\\[11pt]\n    \\onslide<3->{x = r\\cos \\theta \\qquad & \\qquad y = r\\sin \\theta}   \\\\\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 2}\nConvert each to rectangular coordinates.    \\newline\\\\\n(a) \\quad $\\left(2, 240^\\circ\\right)$\n\\begin{align*}\n    \\onslide<2->{x=2\\cos240^\\circ \\quad & \\quad y = 2\\sin240^\\circ} \\\\[10pt]\n    \\onslide<3->{x=2\\left(-\\frac{1}{2}\\right) \\quad & \\quad y = 2\\left(-\\frac{\\sqrt{3}}{2}\\right)} \\\\[10pt]\n    \\onslide<4->{x=-1 \\quad & y = -\\sqrt{3}} \n\\end{align*}\n\\onslide<5->{\\[(-1,\\, -\\sqrt{3})\\]}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n    \\begin{center}\n    \\begin{tikzpicture}[scale = 0.52, every node/.style={scale=0.6}]\n    % Origin Point\n    \\coordinate (O) (0,0);\n    % Circles\n    \\foreach \\r in {1.5,3,...,6}\n    {\n        \\draw[thick] (O) circle (\\r cm);\n    }\n    \n    % \\foreach \\r in {1.5,3,...7.5}\n    % {\n    %     \\node at (\\r, 0) [anchor=north] {\\r/};\n    % }\n    \n    \\foreach \\r in {0.75, 2.25,...,5.25}\n    {\n        \\draw[dotted] (O) circle (\\r cm);\n    }\n    \n    % \\node at (1.5, 0) [anchor = north west] {1};\n    % \\node at (3, 0) [anchor = north west] {2};\n    % \\node at (4.5, 0) [anchor = north west] {3};\n    % \\node at (6, 0) [anchor = north west] {4};\n    % \\node at (7.5,0) [anchor = north west] {5};\n    % \\foreach \\r in {1.5,3,...,9}\n    % {\n    %     \\node at (\\r, 0) {\\r/1.5};\n    % }\n    % Radial Lines\n    \\foreach \\l in {0,15,...,360}\n    {\n        \\draw (O) -- ++(\\l:6cm);\n    }\n    % Thicker Radial Lines at 90 degree increments\n    \\foreach \\l in {0,90,...,360}\n    {\n        \\draw[very thick] (O) -- ++(\\l:6cm);\n    }\n    % Minor Tick marks on outer circle\n    \\foreach \\t in {0,5,...,360}\n    {\n        \\draw (O) ++ (\\t:5.85cm) -- ++(\\t:0.3cm);\n    }\n    % Now for the fun part, the text\n    % Degrees\n    \\node[draw=none, rotate= -90 ] at ( 0 :6.45cm) {$ 0 ^\\circ$};\n    \\node[draw=none, rotate= -75 ] at ( 15 :6.45cm) {$ 15 ^\\circ$};\n    \\node[draw=none, rotate= -60 ] at ( 30 :6.45cm) {$ 30 ^\\circ$};\n    \\node[draw=none, rotate= -45 ] at ( 45 :6.45cm) {$ 45 ^\\circ$};\n    \\node[draw=none, rotate= -30 ] at ( 60 :6.45cm) {$ 60 ^\\circ$};\n    \\node[draw=none, rotate= -15 ] at ( 75 :6.45cm) {$ 75 ^\\circ$};\n    \\node[draw=none, rotate= 0 ] at ( 90 :6.45cm) {$ 90 ^\\circ$};\n    \\node[draw=none, rotate= 15 ] at ( 105 :6.45cm) {$ 105 ^\\circ$};\n    \\node[draw=none, rotate= 30 ] at ( 120 :6.45cm) {$ 120 ^\\circ$};\n    \\node[draw=none, rotate= 45 ] at ( 135 :6.45cm) {$ 135 ^\\circ$};\n    \\node[draw=none, rotate= 60 ] at ( 150 :6.45cm) {$ 150 ^\\circ$};\n    \\node[draw=none, rotate= 75 ] at ( 165 :6.45cm) {$ 165 ^\\circ$};\n    \\node[draw=none, rotate= 90 ] at ( 180 :6.45cm) {$ 180 ^\\circ$};\n    \\node[draw=none, rotate= 285 ] at ( 195 :6.45cm) {$ 195 ^\\circ$};\n    \\node[draw=none, rotate= 300 ] at ( 210 :6.45cm) {$ 210 ^\\circ$};\n    \\node[draw=none, rotate= 315 ] at ( 225 :6.45cm) {$ 225 ^\\circ$};\n    \\node[draw=none, rotate= 330 ] at ( 240 :6.45cm) {$ 240 ^\\circ$};\n    \\node[draw=none, rotate= 345 ] at ( 255 :6.45cm) {$ 255 ^\\circ$};\n    \\node[draw=none, rotate= 360 ] at ( 270 :6.45cm) {$ 270 ^\\circ$};\n    \\node[draw=none, rotate= 375 ] at ( 285 :6.45cm) {$ 285 ^\\circ$};\n    \\node[draw=none, rotate= 390 ] at ( 300 :6.45cm) {$ 300 ^\\circ$};\n    \\node[draw=none, rotate= 405 ] at ( 315 :6.45cm) {$ 315 ^\\circ$};\n    \\node[draw=none, rotate= 420 ] at ( 330 :6.45cm) {$ 330 ^\\circ$};\n    \\node[draw=none, rotate= 435 ] at ( 345 :6.45cm) {$ 345 ^\\circ$};\n    % Radians\n\n    \\node[draw=none, rotate= -90 ] at ( 0 :7cm) {$  $};\n    \\node[draw=none, rotate= -75 ] at ( 15 :7cm) {\\scriptsize$ \\pi/12 $};\n    \\node[draw=none, rotate= -60 ] at ( 30 :7cm) {\\scriptsize$ \\pi/6 $};\n    \\node[draw=none, rotate= -45 ] at ( 45 :7cm) {\\scriptsize$ \\pi/4 $};\n    \\node[draw=none, rotate= -30 ] at ( 60 :7cm) {\\scriptsize$ \\pi/3 $};\n    \\node[draw=none, rotate= -15 ] at ( 75 :7cm) {\\scriptsize$ 5\\pi/12 $};\n    \\node[draw=none, rotate= 0 ] at ( 90 :7cm) {\\scriptsize$ \\pi/2 $};\n    \\node[draw=none, rotate= 15 ] at ( 105 :7cm) {\\scriptsize$ 7\\pi/12 $};\n    \\node[draw=none, rotate= 30 ] at ( 120 :7cm) {\\scriptsize$ 2\\pi/3 $};\n    \\node[draw=none, rotate= 45 ] at ( 135 :7cm) {\\scriptsize$ 3\\pi/4 $};\n    \\node[draw=none, rotate= 60 ] at ( 150 :7cm) {\\scriptsize$ 5\\pi/6 $};\n    \\node[draw=none, rotate= 75 ] at ( 165 :7cm) {\\scriptsize$ 11\\pi/12 $};\n    \\node[draw=none, rotate= 90 ] at ( 180 :7cm) {\\scriptsize$ \\pi $};\n    \\node[draw=none, rotate= 285 ] at ( 195 :7cm) {\\scriptsize$ 13\\pi/2 $};\n    \\node[draw=none, rotate= 300 ] at ( 210 :7cm) {\\scriptsize$ 7\\pi/6 $};\n    \\node[draw=none, rotate= 315 ] at ( 225 :7cm) {\\scriptsize$ 5\\pi/4 $};\n    \\node[draw=none, rotate= 330 ] at ( 240 :7cm) {\\scriptsize$ 4\\pi/3 $};\n    \\node[draw=none, rotate= 345 ] at ( 255 :7cm) {\\scriptsize$ 17\\pi/12 $};\n    \\node[draw=none, rotate= 360 ] at ( 270 :7cm) {\\scriptsize$ 3\\pi/2 $};\n    \\node[draw=none, rotate= 375 ] at ( 285 :7cm) {\\scriptsize$ 19\\pi/12 $};\n    \\node[draw=none, rotate= 390 ] at ( 300 :7cm) {\\scriptsize$ 5\\pi/3 $};\n    \\node[draw=none, rotate= 405 ] at ( 315 :7cm) {\\scriptsize$ 7\\pi/4 $};\n    \\node[draw=none, rotate= 420 ] at ( 330 :7cm) {\\scriptsize$ 11\\pi/6 $};\n    \\node[draw=none, rotate= 435 ] at ( 345 :7cm) {\\scriptsize$ 23\\pi/12 $};\n    \\draw [color=red,fill=red] (240:3) circle (4pt);\n    \\end{tikzpicture}\n    \\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n\\begin{center}\n\\begin{tikzpicture}[scale=0.52]\n    \\draw [<->,>=stealth,very thick] (-6,0) -- (6,0) node [right] {$x$};\n    \\draw [<->,>=stealth,very thick] (0,-6) -- (0,6) node [right] {$y$};\n    \\foreach \\x in {-4.5,-3,...,4.5}\n    \\draw [thick] (\\x,0.2) -- (\\x,-0.2);\n    \\foreach \\y in {-4.5,-3,...,4.5}\n    \\draw [thick] (0.2,\\y) -- (-0.2,\\y);\n    \\draw [color=red,fill=red] (240:3) circle (4pt);\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(b) \\quad $\\left(-4, \\dfrac{7\\pi}{6}\\right)$\n\\begin{align*}\n    \\onslide<2->{x = -4\\cos\\left(\\frac{7\\pi}{6}\\right) \\quad & \\quad y = -4\\sin\\left(\\frac{7\\pi}{6}\\right)} \\\\[10pt]\n    \\onslide<3->{x = -4\\left(-\\frac{\\sqrt{3}}{2}\\right) \\quad & \\quad y = -4\\left(-\\frac{1}{2}\\right)} \\\\[10pt]\n    \\onslide<4->{x = 2\\sqrt{3} \\quad & \\quad y = 2}\n\\end{align*}\n\\onslide<5->{\\[\\left(2\\sqrt{3}, \\, 2\\right) \\]}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(c) \\quad $\\left(2.5, -\\dfrac{5\\pi}{2}\\right)$\n\\begin{align*}\n    \\onslide<2->{x = 2.5\\cos\\left(-\\frac{5\\pi}{2}\\right) \\quad & \\quad y = 2.5\\sin\\left(-\\frac{5\\pi}{2}\\right)} \\\\[10pt]\n    \\onslide<3->{x = 2.5\\left(0\\right) \\quad & \\quad y = 2.5\\left(-1\\right)} \\\\[10pt]\n    \\onslide<4->{x = 0 \\quad & \\quad y = -2.5}\n\\end{align*}\n\\onslide<5->{\\[\\left(0, \\, -2.5\\right) \\]}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(d) \\quad $\\left(-3, -\\dfrac{\\pi}{4}\\right)$\n\\begin{align*}\n    \\onslide<2->{x = -3\\cos\\left(-\\frac{\\pi}{4}\\right) \\quad & \\quad y = -3\\sin\\left(-\\frac{\\pi}{4}\\right)} \\\\[10pt]\n    \\onslide<3->{x = -3\\left(\\frac{\\sqrt{2}}{2}\\right) \\quad & \\quad y = -3\\left(-\\frac{\\sqrt{2}}{2}\\right)} \\\\[10pt]\n    \\onslide<4->{x = -\\frac{3\\sqrt{2}}{2} \\quad & \\quad y = \\frac{3\\sqrt{2}}{2}}\n\\end{align*}\n\\onslide<5->{\\[\\left(-\\frac{3\\sqrt{2}}{2}, \\, \\frac{3\\sqrt{2}}{2}\\right) \\]}\n\\end{frame}\n\n\\section{Convert from rectangular to polar coordinates.}\n\n\\begin{frame}{Rectangular to Polar}\n\\begin{center}\n\\begin{tikzpicture}\n    \\draw [->, >=stealth] (-0.5,0) -- (3.5,0) node [right] {$x$};\n    \\draw [->, >=stealth] (0,-0.5) -- (0,2.5) node [left] {$y$};\n    \\draw (2.5,0) rectangle +(-0.25,0.25);\n    \\draw [color=blue, line width = 1.5] (0,0) -- (2.5,0) node [midway, below, black] {$x$};\n    \\draw [color=blue, line width=1.5] (2.5,0) -- (2.5,2) node [midway, right, black] {$y$};\n    \\draw [color=red, line width=1.5] (0,0) -- (2.5,2) node [above right] {$P(r,\\theta)$};\n    \\draw [color=red, fill=red] (2.5,2) circle (2pt);\n    \\node at (2.5,2) [below right, blue] {$P(x, y)$};\n    \\node at (1.25, 1) [above left] {$r$};\n    \\draw [->, >=stealth] (0:0.75) arc (0:38.5:0.75) node [midway, right] {$\\theta$};\n\\end{tikzpicture}\n\\end{center}\n\\pause\n\\[\nr = \\sqrt{x^2+y^2} \\qquad \\onslide<3->{\\theta' = \\tan^{-1}\\left| \\frac{y}{x} \\right|}\n\\]\n\\vspace{15pt}\n\\onslide<4->{where $\\theta '$ is the \\underline{reference angle} used to find the total angle rotated, $\\theta$.}\n\\end{frame}\n\n\\begin{frame}{Example 3}\nConvert each of the following to polar coordinates. \\newline\\\\\n(a) \\quad $\\left(2, -2\\sqrt{3}\\right)$   \\newline\\\\\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}[scale=0.9]\n\\draw[<->,>=stealth] (-2.5,0) -- (2.5,0) node [right] {$x$};\n\\draw[<->,>=stealth] (0,-2.5) -- (0,2.5) node [above] {$y$};\n\\coordinate (A) at (1,-1.7);\n\\draw[fill=black] (A) circle (2pt);\n\\onslide<2->{\\draw (0,0) -- (A) -- node [right] {\\scriptsize $-2\\sqrt{3}$} (1,0) -- node [above] {\\scriptsize $2$} cycle;}\n\\onslide<4->{\\node at (0.3,-0.15) {\\scriptsize $\\theta'$};}\n\\onslide<4->{\\node at (300:1) [left] {\\scriptsize 4};}\n\\onslide<6->{\\node at (0.3,-0.15) [color=white,fill=white] {};}\n\\onslide<6->{\\node at (0.35,-0.15) {\\scriptsize $60^\\circ$};}\n\\onslide<7->{\\draw[->,>=stealth,color=red] (0.75,0) arc (0:300:0.75) node [xshift=-1cm, yshift=1.25cm] {\\scriptsize $300^\\circ$};}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{-0.5cm}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<3->{r &= \\sqrt{2^2 + (2\\sqrt{3})^2} = \\sqrt{16} = 4}  \\\\[8pt]\n    \\onslide<5->{\\theta' &= \\tan^{-1}\\left|\\frac{-2\\sqrt{3}}{2}\\right| = 60^\\circ}    \\\\[8pt]\n    \\onslide<7->{\\theta &= 300^\\circ} \\\\[8pt]\n    & \\onslide<8->{\\left(4, \\frac{5\\pi}{3}\\right)} \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(b) \\quad $(-3, -3)$ \\newline\\\\\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.8]\n\\draw[<->,>=stealth] (-2.5,0) -- (2.5,0) node [right] {$x$};\n\\draw[<->,>=stealth] (0,-2.5) -- (0,2.5) node [above] {$y$};\n\\coordinate (A) at (-1.75,-1.75);\n\\draw [fill=black] (A) circle (2pt);\n\\onslide<2->{\\draw (0,0) -- (A) -- node [left] {\\scriptsize $-3$} (-1.75,0) -- node [above] {\\scriptsize $-3$} cycle;}\n\\onslide<4->{\\node at (-0.5,-0.2) {\\scriptsize $\\theta'$};}\n\\onslide<4->{\\node at (225:1) [below, yshift=-0.1cm] {\\scriptsize $3\\sqrt{2}$};}\n\\onslide<6->{\\node at (-0.5,-0.2) [color=white,fill=white] {};}\n\\onslide<6->{\\node at (-0.6,-0.2) {\\scriptsize $45^\\circ$};}\n\\onslide<7->{\\draw[->,>=stealth,color=red] (1.25,0) arc (0:225:1.25) node [midway, above left] {\\scriptsize $225^\\circ$};}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.5cm}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<3->{r &= \\sqrt{3^2 + 3^2} = 3\\sqrt{2}}  \\\\[8pt]\n    \\onslide<5->{\\theta' &= \\tan^{-1}\\left|\\frac{-3}{-3}\\right| = 45^\\circ}    \\\\[8pt]\n    \\onslide<7->{\\theta &= 225^\\circ} \\\\[8pt]\n    & \\onslide<8->{\\left(3\\sqrt{2}, \\frac{5\\pi}{4}\\right)} \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 3}\n(c) \\quad $(0, -3)$ \\newline\\\\\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.8]\n\\draw[<->,>=stealth] (-2.5,0) -- (2.5,0) node [right] {$x$};\n\\draw[<->,>=stealth] (0,-2.5) -- (0,2.5) node [above] {$y$};\n\\draw (-0.15,-1.75) -- (0.15,-1.75) node [right] {\\scriptsize $-3$};\n\\coordinate (A) at (0,-1.75);\n\\draw [fill=black] (A) circle (2pt);\n\\onslide<2->{\\node at (0,-0.75) [right, red] {\\scriptsize $r = 3$};}\n\\onslide<3->{\\draw[->,>=stealth,color=red] (1,0) arc (0:270:1) node [midway, above left] {\\scriptsize $270^\\circ$};}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.5cm}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<2->{r &= 3}  \\\\[12pt]\n    \\onslide<4->{\\theta &= \\frac{3\\pi}{2}} \\\\[12pt]\n    \\onslide<5->{&\\left(3, \\frac{3\\pi}{2}\\right)}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 3}\n(d) \\quad $(-3, 4)$ \\newline\\\\\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.8]\n\\draw[<->,>=stealth] (-2.5,0) -- (2.5,0) node [right] {$x$};\n\\draw[<->,>=stealth] (0,-2.5) -- (0,2.5) node [above] {$y$};\n\\coordinate (A) at (-1.75,2);\n\\draw [fill=black] (A) circle (2pt);\n\\onslide<2->{\\draw (0,0) -- (A) -- node [left] {\\scriptsize $4$} (-1.75,0) -- node [below] {\\scriptsize $-3$} cycle;}\n\\onslide<4->{\\node at (-0.5,0.2) {\\scriptsize $\\theta'$};}\n\\onslide<4->{\\node at (127:1.5) [right] {\\scriptsize $5$};}\n\\onslide<6->{\\node at (-0.5,0.2) [color=white,fill=white] {};}\n\\onslide<6->{\\node at (-0.7,0.2) {\\scriptsize $53.13^\\circ$};}\n\\onslide<7->{\\draw[->,>=stealth,color=red] (1,0) arc (0:127:1) node [midway, above right] {\\scriptsize $126.87^\\circ$};}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.5cm}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\n    \\onslide<3->{r &= \\sqrt{3^2 + 4^2} = 5}  \\\\[8pt]\n    \\onslide<5->{\\theta' &= \\tan^{-1}\\left|\\frac{4}{-3}\\right| \\approx 53.13^\\circ}    \\\\[8pt]\n    \\onslide<7->{\\theta &\\approx 126.87^\\circ} \\\\[8pt]\n    \\onslide<8->{&\\left(5, \\pi - \\tan^{-1}\\left(\\frac{4}{3}\\right)\\right)} \\\\\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\section{Convert rectangular equations to polar equations.}\n\n\\begin{frame}{Rectangular and Polar Equations}\nWe can use the relationship between rectangular and polar coordinates to convert equations of one form to the other.  \\newline\\\\  \\pause\n\n\\begin{tabular}{p{0.4\\textwidth}p{0.4\\textwidth}}\n    \\onslide<2->{$x = r\\cos \\theta$}  & \\onslide<3->{$x^2 + y^2 = r^2$}  \\\\\n    \\onslide<2->{$y = r\\sin\\theta$}   & \\onslide<3->{$\\tan\\theta = \\dfrac{y}{x}$}  \\\\ \n\\end{tabular}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n    Convert each to polar equations.    \\newline\\\\\n(a) \\quad $y=-x$ \n\\begin{align*}\n    \\onslide<2->{{\\color{red}y}&=-{\\color{blue}x}} \\\\[8pt]\n    \\onslide<3->{{\\color{red}r\\sin\\theta} &= - {\\color{blue}r\\cos\\theta}} \\\\[8pt]\n    \\onslide<4->{r\\cos\\theta\\ + r\\sin\\theta &= 0} \\\\[8pt]\n    \\onslide<5->{r(\\cos\\theta + \\sin\\theta) &= 0}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n\\[r(\\cos\\theta + \\sin\\theta) = 0\\]\n\\begin{align*}\n    \\onslide<2->{r &= 0 & \\cos\\theta + \\sin\\theta &= 0} \\\\[8pt]\n    \\onslide<3->{&& \\cos\\theta &= -\\sin\\theta} \\\\[8pt]\n    \\onslide<4->{&&{\\color{red}\\theta} &= {\\color{red}-\\frac{\\pi}{4}}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n(b) \\quad $y=x^2$\n\\begin{align*}\n    \\onslide<2->{{\\color{red}r\\sin\\theta} &= \\left({\\color{blue}r\\cos\\theta}\\right)^2} \\\\[8pt]\n    \\onslide<3->{r\\sin\\theta &= r^2\\cos^2\\theta} \\\\[8pt]\n    \\onslide<4->{r\\sin\\theta - r^2\\cos^2\\theta &= 0} \\\\[8pt]\n    \\onslide<5->{r\\left(\\sin\\theta - r\\cos^2\\theta\\right) &= 0} \n\\end{align*}\n\\begin{align*}\n    \\onslide<6->{r &= 0 & \\sin\\theta - r\\cos^2\\theta &= 0} \n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n\\[ \\sin\\theta - r\\cos^2\\theta = 0\\]\n\\begin{align*}\n    \\onslide<2->{\\sin\\theta &= r\\cos^2\\theta} \\\\[8pt]\n    \\onslide<3->{r &= \\frac{\\sin\\theta}{\\cos^2\\theta}} \\\\[10pt]\n    \\onslide<4->{r &= \\left(\\frac{\\sin\\theta}{\\cos\\theta}\\right)\\left(\\frac{1}{\\cos\\theta}\\right)}    \\\\[10pt]\n    \\onslide<5->{r &= \\tan\\theta \\cdot \\sec\\theta}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n(c) \\quad $(x-3)^2 + y^2 = 9$\n\\begin{align*}\n    \\onslide<2->{(r\\cos\\theta - 3)^2 + (r\\sin\\theta)^2 &= 9} \\\\[6pt]\n    \\onslide<3->{r^2\\cos^2\\theta - 6r\\cos\\theta + 9 + r^2\\sin^2\\theta &= 9} \\\\[6pt]\n    \\onslide<4->{r^2\\cos^2\\theta + r^2\\sin^2\\theta - 6r\\cos\\theta &= 0} \\\\[6pt]\n    \\onslide<5->{r^2\\left(\\cos^2\\theta + \\sin^2\\theta\\right) - 6r\\cos\\theta &= 0} \\\\[6pt]\n    \\onslide<6->{r^2 - 6r\\cos\\theta &= 0} \\\\[6pt]\n    \\onslide<7->{r(r-6\\cos\\theta) &= 0}\n\\end{align*}\n\\begin{align*}\n\\onslide<8->{r &= 0 & r-6\\cos\\theta &= 0}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 4}\n    \\[r-6\\cos\\theta = 0\\]\n\\onslide<2->{\\[r = 6\\cos\\theta \\]}\n\\end{frame}\n\n\\section{Convert polar equations to rectangular equations}\n\n\n\\begin{frame}{Example 5}\nConvert each of the following to rectangular equations. \\newline\\\\\n(a) \\quad $r = -3$\n\\begin{align*}\n    \\onslide<2->{r &= -3} \\\\[8pt]\n    \\onslide<3->{r^2 &= 9} \\\\[8pt]\n    \\onslide<4->{x^2+y^2 &= 9} \n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 5}\n(b) \\quad $\\theta = \\dfrac{4\\pi}{3}$\n\\begin{align*}\n    \\onslide<2->{\\theta &= \\frac{4\\pi}{3}} \\\\[8pt]\n    \\onslide<3->{\\tan \\theta &= \\tan\\left(\\frac{4\\pi}{3}\\right)} \\\\[8pt]\n    \\onslide<4->{\\frac{y}{x} &= \\sqrt{3}} \\\\[8pt]\n    \\onslide<5->{y &= x\\sqrt{3}} \\\\\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 5}\n(c) \\quad $r = 1 - \\cos\\theta$\n\\begin{align*}\n    \\onslide<2->{r &= 1 - \\cos\\theta} \\\\[6pt]\n    \\onslide<3->{r \\cdot {\\color{red}r} &= {\\color{red}r}(1-\\cos\\theta)} \\\\[6pt]\n    \\onslide<4->{r^2 &= r-r\\cos\\theta} \\\\[6pt]\n    \\onslide<5->{x^2 + y^2 &= r - x} \\\\[6pt]\n    \\onslide<6->{x^2 + y^2 + x &= r} \\\\[6pt]\n    \\onslide<7->{\\left(x^2 + y^2 + x\\right)^2 &= x^2 + y^2}\n\\end{align*}\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "b0c58a8753ae9fef90a4b6d4aba2517629eb4da9", "size": 24951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Polar_Coordinates(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Polar_Coordinates(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Polar_Coordinates(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 41.1054365733, "max_line_length": 136, "alphanum_fraction": 0.5552082081, "num_tokens": 10829, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.43588371196333847}}
{"text": "\\documentclass[11pt]{scrartcl} % Font size\n\\input{../structure.tex} % Include the file specifying the document structure and custom commands\n\n%----------------------------------------------------------------------------------------\n%\tTITLE SECTION\n%----------------------------------------------------------------------------------------\n\n\\title{\n\t\\normalfont\\normalsize\n\t\\textsc{Harvard Privacy Tools Project}\\\\ % Your university, school and/or department name(s)\n\t\\vspace{25pt} % Whitespace\n\t\\rule{\\linewidth}{0.5pt}\\\\ % Thin top horizontal rule\n\t\\vspace{20pt} % Whitespace\n\t{\\huge Covariance Sensitivity Proofs}\\\\ % The assignment title\n\t\\vspace{12pt} % Whitespace\n\t\\rule{\\linewidth}{2pt}\\\\ % Thick bottom horizontal rule\n\t\\vspace{12pt} % Whitespace\n}\n\n% \\author{\\LARGE} % Your name\n\n\\date{\\normalsize\\today} % Today's date (\\today) or a custom date\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Preliminaries}\n\n\\begin{definition}\nLet $X$ be a matrix of values and $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Denote the sample mean of column $X_i$ as $\\bar{X}_i$, and let $n$ be the size of $X_i$. Then the covariance matrix of $X$ has $ij^{\\text{th}}$ element \n$$ \\frac{1}{n-1} \\sum_{k=1}^n (x_{ki} - \\bar{X}_i)(x_{kj} - \\bar{X}_j).$$\n\\end{definition}\n\\begin{lemma}\n\\label{lemma:cancel}\nLet $X$ be a matrix of values and $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Denote the sample mean of column $X_i$ as $\\bar{X}_i$, and let $n$ be the size of $X_i$. Then,\n$\\forall i,$\n$$ \\sum_{j=1}^n (x_{ji} - \\bar{X}_i) = 0.$$\n\\end{lemma}\n\n\\begin{proof}\n\\begin{align*}\n\\sum_{j=1}^n (x_{ji} - \\bar{X}_i) &= \\sum_{j=1}^n x_{ji} - n \\bar{X}_i,\\\\\n\t&= \\sum_{j=1}^n x_{ji} - n\\left( \\frac{1}{n}\\sum_{j=1}^n x_{ji}\\right), \\\\\n\t&= 0.\n\\end{align*}\n\\end{proof}\n\n\\begin{lemma}\n\\label{cov:rewrite}\nLet $X$ be a matrix and let\n$$ f_{ij}(X) = \\sum_{k=1}^n (x_{ki} - \\bar{X}_i)(x_{kj} - \\bar{X}_j).$$\nNote that this is equivalent to the $ij^{\\text{th}}$ element of the sample covariance matrix for $X$, without the normalization by $n-1$. Consider the matrix $X'$ equal to $X$ with a single row $Y$ added, so that $X_i' = X_i \\cup \\{y_i\\}$. Say $X_i$ has size $n$. Let  $\\bar{X}_i$, $\\bar{X}_j$, $\\bar{X}_i'$, and $\\bar{X}_j'$ be the sample means of $X_i, X_j, X_i'$ and $X_j'$ respectively. Then,\n$$ f_{ij}(X') = f_{ij}(X) + n(\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') + (y_i - \\bar{X}_i)(y_j - \\bar{X}_j).$$\n\\end{lemma}\n\n\\begin{proof}\nNote that\n\\begin{align*}\nf_{ij}(X') &= \\sum_{k=1}^{n+1} (x_{ki}' - \\bar{X}_i')(x_{kj}' - \\bar{X}_j'),\\\\\n\t&= \\sum_{k=1}^{n} (x_{ki} - \\bar{X}_i')(x_{kj} - \\bar{X}_j') + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j'),\\\\\n\t&= \\sum_{k=1}^{n} \\left( (x_{ki} - \\bar{X}_i )+ (\\bar{X}_i - \\bar{X}_i' )\\right) \\left( (x_{kj} - \\bar{X}_j )+ (\\bar{X}_j - \\bar{X}_j') \\right) + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j'),\\\\\n\t&= \\sum_{k=1}^{n} (x_{ki} - \\bar{X}_i)(x_{kj} - \\bar{X}_j) + (\\bar{X}_j - \\bar{X}_j')\\sum_{k=1}^{n} (x_{ki}-\\bar{X}_i) + (\\bar{X}_i - \\bar{X}_i') \\sum_{k=1}^{n} (x_{kj} - \\bar{X}_j),\\\\\n\t& \\hspace{1cm} + \\sum_{k=1}^{n} (\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j'),\\\\\n\t&= f_{ij}(X) + n(\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j'),\n\\end{align*}\nwhere the cancellation of the second and third terms in the second-to-last line is due to Lemma \\ref{lemma:cancel}.\n\\end{proof}\n\n\\begin{lemma}\n\\label{lemma:term1bound}\nLet $X$ be a matrix of values and $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Let  $X_i$ have size $n$ and consider the matrix $X'$ equal to $X$ with a single row $Y$ added, so that $X_i' = X_i \\cup \\{y_i\\}$. Say that the space of datapoints $\\mathcal{X}_i$ that the elements of $X_i'$ are drawn from is bounded above by $M_i$ and bounded below by $m_i$. Let  $\\bar{X}_i$, $\\bar{X}_j$, $\\bar{X}_i'$, and $\\bar{X}_j'$ be the sample means of $X_i, X_j, X_i'$ and $X_j'$ respectively. Then,\n$$ n \\left\\vert (\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') \\right\\vert \\le \\frac{n}{(n+1)^2}(M_i - m_i)(M_j - m_j).$$\n\\end{lemma}\n\n\\begin{proof}\nNote that\n\\begin{align*}\n n \\left\\vert (\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') \\right\\vert &= n\\left\\vert \\left( \\frac{1}{n} \\sum_{k=1}^n x_{ki} - \\frac{1}{n+1} \\sum_{k=1}^{n+1} x_{ki}' \\right) \\left( \\frac{1}{n} \\sum_{k=1}^n x_{kj} - \\frac{1}{n+1} \\sum_{k=1}^{n+1} x_{kj}' \\right)\\right\\vert, \\\\\n \t&= n \\left\\vert \\left( \\left(\\frac{1}{n} - \\frac{1}{n+1}\\right) \\sum_{k=1}^n x_{ki} - \\frac{y_i}{n+1} \\right)\\left( \\left(\\frac{1}{n} - \\frac{1}{n+1}\\right) \\sum_{k=1}^n x_{kj} - \\frac{y_j}{n+1} \\right) \\right\\vert, \\\\\n\t&= n  \\left\\vert \\left(\\frac{1}{n(n+1)} \\sum_{k=1}^n x_{ki} - \\frac{y_i}{n+1} \\right)\\left( \\frac{1}{n(n+1)} \\sum_{k=1}^n x_{kj} - \\frac{y_j}{n+1} \\right) \\right\\vert, \\\\\n\t&= \\frac{n}{(n+1)^2} \\left\\vert \\left( \\frac{1}{n} \\sum_{k=1}^n x_{ki} - \\frac{y_i}{n+1} \\right)\\left( \\frac{1}{n} \\sum_{k=1}^n x_{kj} - \\frac{y_j}{n+1} \\right) \\right\\vert,\\\\\n\t&\\le \\frac{n}{(n+1)^2} (M_i - m_i)(M_j - m_j).\n \\end{align*}\n\\end{proof}\n\n\\begin{lemma}\n\\label{lemma:term2bound}\nLet $X$ be a matrix of values and $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Let  $X_i$ have size $n$ and consider the matrix $X'$ equal to $X$ with a single row $Y$ added, so that $X_i' = X_i \\cup \\{y_i\\}$. Say that the space of datapoints $\\mathcal{X}_i$ that the elements of $X_i'$ are drawn from is bounded above by $M_i$ and bounded below by $m_i$. Let  $\\bar{X}_i$, $\\bar{X}_j$, $\\bar{X}_i'$, and $\\bar{X}_j'$ be the sample means of $X_i, X_j, X_i'$ and $X_j'$ respectively. Then,\n$$ \\left\\vert (y_i - \\bar{X}_i')(y_j - \\bar{X}_j') \\right\\vert \\le \\frac{n^2}{(n+1)^2}(M_i - m_i)(M_j-m_j).$$\n\\end{lemma}\n\n\\begin{proof}\nNote that\n\\begin{align*}\n \\left\\vert (y_i - \\bar{X}_i')(y_j - \\bar{X}_j') \\right\\vert &= \\left\\vert \\left( y_i - \\frac{y_i + n \\bar{X}_i}{n+1}\\right) \\left( y_j - \\frac{y_j + n \\bar{X}_j}{n+1}\\right) \\right\\vert, \\\\\n \t&= \\frac{1}{(n+1)^2} \\left\\vert \\left((n+1)y_i - y_i - n\\bar{X}_i \\right)\\left((n+1)y_j - y_j - n\\bar{X}_j \\right) \\right\\vert, \\\\\n\t&= \\frac{n^2}{(n+1)^2} \\left\\vert (y_i - \\bar{X}_i)(y_j - \\bar{X}_j)\\right\\vert, \\\\\n\t&\\le \\frac{n^2}{(n+1)^2} (M_i - m_i)(M_j - m_j).\n\\end{align*}\n\\end{proof}\n\n\\section{Neighboring Definition: Add/Drop One}\n\\subsection{$\\ell_1$-sensitivity}\n\n\\begin{theorem}\nLet $X$ be a matrix of values and let $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Let\n$$ f_{ij} (X)= \\sum_{k=1}^n (x_{ki} - \\bar{X}_i)(x_{kj} - \\bar{X}_j).$$\nSay that the space of datapoints $\\mathcal{X}_i$ that $X_i$ is drawn from is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_1$-sensitivity in the add/drop-one model of $f(\\cdot)$ is bounded above by\n $$ \\frac{n}{(n+1)}  (M_i - m_i)(M_j - m_j).$$ \n\\end{theorem}\n\n\\begin{proof}\n\nWe must consider both adding and removing a row from $X$.\n\nAdding a row:\\\\\nLet $X'_i = X_i \\cup \\{y_i\\}$. Then, from Lemma \\ref{cov:rewrite}, \n\\begin{align}\n\\label{eq:addone}\n\\left\\vert f_{ij}(X') - f_{ij}(X) \\right\\vert &= \\left\\vert n(\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') + (y_i - \\bar{X}_i)(y_j - \\bar{X}_j) \\right\\vert \\hspace{1cm} \\nonumber\\\\\n\t&\\le  n \\left\\vert (\\bar{X}_i - \\bar{X}_i')(\\bar{X}_j - \\bar{X}_j') \\right\\vert + \\left\\vert (y_i - \\bar{X}_i)(y_j - \\bar{X}_j) \\right\\vert \\nonumber\\\\\n\t&\\le \\frac{n}{(n+1)^2} (M_i - m_i)(M_j - m_j) + \\frac{n^2}{(n+1)^2} (M_i - m_i)(M_j - m_j) \\nonumber\t\\\\\n\t& \\hspace{8cm} \\text{(By Lemmas \\ref{lemma:term1bound} and \\ref{lemma:term2bound})} \\nonumber\\\\\n\t&= \\frac{n}{n+1}  (M_i - m_i)(M_j - m_j).\n\\end{align}\n\nRemoving a row:\\\\\nLet $Y$ be the last row of $X$, and let $X_i'  = X_i \\setminus \\{y_i\\}$. Note that Lemma \\ref{cov:rewrite} can be rewritten in this setting by parametrizing $n$ as $n-1$ and swapping X and X' in its expression:\n\n$$ f_{ij}(X) = f_{ij}(X') + (n-1)(\\bar{X}_i' - \\bar{X}_i)(\\bar{X}_j' - \\bar{X}_j) + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j'). $$\n\nLemmas \\ref{lemma:term1bound} and \\ref{lemma:term2bound} may be rewritten with the same reparametrization:\n$$ (n-1)\\left\\vert (\\bar{X}_i' - \\bar{X}_i)(\\bar{X}_j' - \\bar{X}_j) \\right\\vert \\le \\frac{n-1}{n^2} (M_i - m_i)(M_j - m_j),$$\nand \n$$ \\left\\vert (y_i - \\bar{X}_i')(y_j - \\bar{X}_j') \\right\\vert \\le \\frac{(n-1)^2}{n^2}(M_i - m_i)(M_j - m_j).$$\nThen,\n\\begin{align}\n\\label{eq:subone}\n\\left\\vert f_{ij}(X) - f_{ij}(X') \\right\\vert &= \\left\\vert (n-1)(\\bar{X}_i' - \\bar{X}_i)(\\bar{X}_j' - \\bar{X}_j) + (y_i - \\bar{X}_i')(y_j - \\bar{X}_j') \\right\\vert, \\nonumber\\\\\n\t&\\le  \\left\\vert (n-1)(\\bar{X}_i' - \\bar{X}_i)(\\bar{X}_j' - \\bar{X}_j) \\right\\vert + \\left\\vert(y_i - \\bar{X}_i')(y_j - \\bar{X}_j') \\right\\vert, \\nonumber\\\\\n\t&\\le \\frac{n-1}{n^2} (M_i - m_i)(M_j - m_j) + \\frac{(n-1)^2}{n^2}(M_i - m_i)(M_j - m_j), \\nonumber\\\\\n\t&= \\frac{n-1}{n} (M_i - m_i)(M_j - m_j).\n\\end{align}\n\nNote that for any $n \\ge 1$,\n\t\\begin{equation}\n\t\\label{ineq}\n\t \\frac{n}{n + 1} > \\frac{n-1}{n}.\n\t\\end{equation}\n\nSo, the worst-case bound always occurs in the ``add-one'' case, and in general the  $\\ell_1$ sensitivity of $f(\\cdot)$ is bounded by\n $$ \\frac{n}{n+1}  (M_i - m_i)(M_j - m_j).$$ \n\\end{proof}\n\n\\begin{corollary}\n\\label{cor:renorm}\nLet $X \\leftarrow \\mathcal{X}$ where $\\mathcal{X}_i$ is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_1$-sensitivity in the add/drop-one model of the $ij^{\\text{th}}$ element of the covariance matrix for $X$ is bounded above by \n$$ \\frac{1}{n+1}(M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nNote that the $ij^{\\text{th}}$ element of the covariance matrix for $X$ is equal to $f(x)/n$.\n\\end{proof}\n\n\\begin{corollary}\n\\label{cor:renorm}\nLet $X \\leftarrow \\mathcal{X}$ where $\\mathcal{X}_i$ is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_1$-sensitivity in the add/drop-one model of the $ij^{\\text{th}}$ element of a sample covariance matrix for $X$ is bounded above by \n$$ \\frac{n}{n^2-1}(M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nNote that the $ij^{\\text{th}}$ element of the sample covariance of $X$ is equal to $f(x)/(n-1)$, and that $(n-1)(n+1) = n^2 -1$.\n\\end{proof}\n\n\\subsection{$\\ell_2$-sensitivity}\n\n\\begin{theorem}\nLet $X \\leftarrow \\mathcal{X}$ where $\\mathcal{X}_i$ is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_2$-sensitivity in the add/drop-one model of the $ij^{\\text{th}}$ element of the covariance matrix for $X$ is bounded above by\n$$ \\frac{1}{n+1}(M_i - m_i)(M_j - m_j).$$\n\\end{theorem}\n\n\\begin{proof}\n% note you can also do this directly by squaring the bounds and bounding the central term. I can add that in but it's just a lot of cluttered arithmetic. \nThis follows from the bounds in Equations \\ref{eq:addone} and \\ref{eq:subone} and the inequality in Equation \\ref{ineq}, and a renormalization by $n$ from the definition of covariance.\n\\end{proof}\n\n\\begin{corollary}\n\\label{thm:l2addsub}\nLet $X \\leftarrow \\mathcal{X}$ where $\\mathcal{X}_i$ is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_2$-sensitivity in the add/drop-one model of the $ij^{\\text{th}}$ element of a sample covariance matrix for $X$ is bounded above by\n$$\\frac{n}{n^2-1}(M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nThe logic here is identical to the proof of Theorem \\ref{thm:l2addsub}, with a renormalization by $n$ rather than by $n-1$.\n\\end{proof}\n\n\\section{Neighboring Definition: Change One}\n\\subsection{$\\ell_1$-sensitivity}\n\n\\begin{theorem}\n\\label{thm:l1change1}\nLet $X$ be a matrix of values and let $X_i$ indicate the $i^{\\text{th}}$ column of the matrix. Let\n$$ f_{ij} (X)= \\sum_{k=1}^n (x_{ki} - \\bar{X}_i)(x_{kj} - \\bar{X}_j).$$\nSay that the space of datapoints $\\mathcal{X}_i$ that $X_i$ is drawn from is bounded above by $M_i$ and bounded below by $m_i$. Then the $\\ell_1$-sensitivity in the change-one model of $f(\\cdot)$ is bounded above by\n$$ \\frac{2(n-1)}{n}  (M_i - m_i)(M_j - m_j).$$\n\\end{theorem}\n\n\\begin{proof}\nRecall from Equation \\ref{eq:addone} that \n$$ \\left\\vert f_{ij}(X) - f_{ij}(X') \\right\\vert \\le \\frac{n}{(n+1)}  (M_i - m_i)(M_j - m_j).$$\nand\n$$ \\left\\vert f_{ij}(X) - f_{ij}(X'') \\right\\vert \\le \\frac{n}{(n+1)}  (M_i - m_i)(M_j - m_j).$$\nReparametrizing these equations so that $n$ is the size of $X'$ and $X''$ gives that \n$$ \\left\\vert f_{ij}(X) - f_{ij}(X') \\right\\vert \\le \\frac{n-1}{n}  (M_i - m_i)(M_j - m_j).$$\nand\n$$ \\left\\vert f_{ij}(X) - f_{ij}(X'') \\right\\vert \\le \\frac{n-1}{n}  (M_i - m_i)(M_j - m_j).$$\nIt then follows from the triangle inequality that \n$$ \\left\\vert f_{ij}(X') - f_{ij}(X'') \\right\\vert \\le \\frac{2(n-1)}{n}  (M_i - m_i)(M_j - m_j).$$\n\\end{proof}\n\n\\begin{corollary}\nThe $\\ell_1$-sensitivity in the change-one model of covariance is bounded above by\n$$\\frac{2(n-1)}{n^2}  (M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nNote that the $ij^{\\text{th}}$ element of the covariance of $X$ is equal to $f(x)/n$.\n\\end{proof}\n\n\\begin{corollary}\n\\label{cor:renorm2}\nThe $\\ell_1$-sensitivity in the change-one model of sample covariance is bounded above by\n$$\\frac{2}{n}  (M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nNote that the $ij^{\\text{th}}$ element of the sample covariance of $X$ is equal to $f(x)/(n-1)$.\n\\end{proof}\n\n\\subsection{$\\ell_2$-sensitivity}\n\n\\begin{theorem}\n\\label{thm:l2change}\nThe $\\ell_2$-sensitivity in the change-one model of covariance is bounded above by \n$$\\frac{2(n-1)}{n^2}  (M_i - m_i)(M_j - m_j).$$\n\\end{theorem}\n\n\\begin{proof}\nThis follows from the bounds in the proof of Theorem \\ref{thm:l1change1} and a renormalization by $n$.\n\\end{proof}\n\n\\begin{corollary}\nThe $\\ell_2$-sensitivity in the change-one model of sample covariance is bounded above by \n$$\\frac{2}{n}  (M_i - m_i)(M_j - m_j).$$\n\\end{corollary}\n\n\\begin{proof}\nThe logic here is identical to the proof of Theorem \\ref{thm:l2change}, with a renormalization by $n-1$ rather than by $n$.\n\\end{proof}\n\n\\bibliographystyle{alpha}\n\\bibliography{mean}\n\n\\end{document}", "meta": {"hexsha": "f7205bab7527d4480a1e2378690404c6570dfcf7", "size": 13881, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "whitepapers/sensitivities/covariance/covariance.tex", "max_stars_repo_name": "amanjeev/whitenoise-core", "max_stars_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2021-02-18T07:02:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:10:13.000Z", "max_issues_repo_path": "whitepapers/sensitivities/covariance/covariance.tex", "max_issues_repo_name": "amanjeev/whitenoise-core", "max_issues_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 34, "max_issues_repo_issues_event_min_datetime": "2020-10-22T13:56:57.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-11T13:44:20.000Z", "max_forks_repo_path": "whitepapers/sensitivities/covariance/covariance.tex", "max_forks_repo_name": "amanjeev/whitenoise-core", "max_forks_repo_head_hexsha": "74f7cc7cce7f22c7f39b455ed7db99e04b328001", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2020-10-22T13:29:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-08T15:57:02.000Z", "avg_line_length": 52.3811320755, "max_line_length": 500, "alphanum_fraction": 0.6193357827, "num_tokens": 5699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.43588370167321305}}
{"text": "\\documentclass[twocolumn]{article}\n\n\\usepackage{graphicx}\n\\usepackage{subfigure}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage[usenames,dvipsnames]{color} % good support for colors\n\\usepackage{pstricks}\n\n\\def\\registered{\\textsuperscript{\\textregistered}}\n\\def\\copyright{\\textsuperscript{\\textcopyright}}\n\\def\\trademark{\\textsuperscript{\\texttrademark}}\n\n\\newrgbcolor{kennycolor}{.1 .1 .7}\n\\newcommand{\\kenny}[1]{  { \\bf \\kennycolor Kenny:  #1}}\n\n\\renewcommand{\\vec}[1]{ \\ensuremath{\\mathbf{#1} } }\n\\newcommand{\\abs}[1]{\\left| {#1} \\right|}\n\\newcommand{\\quat}[1]{ #1 }\n\\newcommand{\\mat}[1]{\\ensuremath{\\mathbf{#1} }}\n\\newcommand{\\norm}[1]{\\parallel {#1} \\parallel}\n\\renewcommand{\\Re}{ \\mathbb{R} }\n\\newcommand{\\set}[1]{\\mathcal{#1}}\n\\newcommand{\\identity}{ \\ensuremath{ \\mat I }}\n\\newcommand{\\bigO}{ \\ensuremath{ \\mathcal{O} }}\n\\newcommand{\\atan }{ \\ensuremath{ \\phantom{\\cdot}\\text{atan}_2 } }\n\\newcommand{\\acos }{ \\ensuremath{ \\cos^{-1} } }\n\\newcommand{\\asin }{ \\ensuremath{ \\sin^{-1} } }\n\\newcommand{\\logand }{ \\ensuremath{ \\wedge } }\n\\newcommand{\\logor }{ \\ensuremath{ \\vee } }\n\\newcommand{\\degree}{\\,^{\\circ}}\n\\renewcommand{\\th}{ \\ensuremath{ ^{\\text{th}}} }\n\\newcommand{\\sgn }[1]{ \\ensuremath{ \\text{sgn}\\left( #1 \\right) } }\n\\newcommand{\\union}{\\ensuremath{ \\cup }}\n\\newcommand{\\intersection}{\\ensuremath{ \\cap }}\n\\newcommand{\\hull }[1]{ \\ensuremath{ \\text{convex hull}\\left( #1 \\right) } }\n\\newcommand{\\proj }[1]{ \\ensuremath{ \\text{proj}\\left( #1 \\right) } }\n\\newcommand{\\trace }[1]{ \\ensuremath{ \\text{tr}\\left( #1 \\right) } }\n\\newcommand{\\inertia}{\\ensuremath{\\mathcal{I} }}\n\\newcommand{\\mass}{\\ensuremath{\\mathcal{M} }}\n\n\\title{Hints for using the MASS Library}\n\\author{Kenny Erleben}\n\\date{December 2010}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n  The MASS library was created to provide a functional toolbox for handling mass\n  properties of rigid bodies. This includes functions for computing the total\n  mass of an object $\\mass$ the center of mass position $\\vec r$ and the inertia\n  tensor $\\inertia$. These values depend on the chosen frame of reference. To\n  achieve a correct physical simulation it is important to apply the correct\n  mass values. In this short paper we will address the issues in computing the\n  values of mass properties of rigid bodies and compounds hereof. Our\n  contribution includes a description of how to deal with initialization and the\n  visualization synchronizations of rigid bodies and the construction of\n  compound bodies.\n\\end{abstract}\n\n\\section*{Creation of a Rigid Body}\nWhen creating content in rigid body simulators several different coordinate\nframes are used. We will work with three different coordinate frames\n\\begin{description}\n\\item[The world frame] is the world coordinate frame wherein everything can be\n  absolutely placed.\n\\item[The body frame ] refers to the coordinate frame with its origin at the\n  center of mass of a given rigid body and the orientation of the frame chosen\n  such that the inertia tensor of the given body is a constant and diagonal\n  tensor.\n\\item[The model frame] is some convenient frame used to describe the geometry\n  in. The frame is fixed in the sense that it always will follow the same motion\n  as the geometry.\n\\end{description}\nThe model frame needs not be physically founded, but can in principle be defined\nanywhere where it make sense from an artistic or modelling viewpoint. From a\nmodelling viewpoint one would define the geometry in some model reference frame\nand then place the model frames in the world frame. However, when connecting to\na rigid body simulator one must account find the body frame as this is the one\nthe simualtor works with. This leads to the following steps of actions\n\\begin{enumerate}\n\\item Compute model frame values $\\mass$, $\\vec r_M$, and $\\inertia_M$\n\\item Transform from model frame values into the body frame values $\\inertia_B$.\n\\item Given model frame placement in the world $\\vec r$ and $\\mat R$ compute the\n  body frame placement in the world $\\vec r_B$ and $\\mat R_B$.\n\\end{enumerate}\nThe MASS library provides routines for the first step. For the second step one\nwould have to first transform the reference point to the center of mass position\nusing the parallel-axis theorem ($\\textbf{p-a-t}$)\\footnote{See\n  $mass::translate_inertia$ function},\n\\begin{equation}\n  \\inertia^\\prime = \\textbf{p-a-t}(\\inertia_M, - \\vec   r_M) .\n\\end{equation}\nNext we can apply eigen-value-decomposition to find the body frame\nvalues\\footnote{See $mass::compute_orientation$ function},\n\\begin{equation}\n  \\inertia_M  = \\mat R_M \\inertia_B \\mat R_M^T.\n\\end{equation}\nNow given the model frame placement in the world frame we compute,\n\\begin{subequations}\n  \\begin{align}\n    \\vec r_B &= \\vec r - \\mat R \\vec r_M, \\\\\n    \\mat R_B &= \\mat R \\mat R_M.\n  \\end{align}\n\\end{subequations}\nThere is one more subtlety in the creation process. The rigid body simulator\nmust know where its geometry is relative to its body frame. Thus, one should\napply the transformation from model frame to body frame onto the geometry. That\nis first translate by $- \\vec r_M$ and then rotation by $\\mat\nR_M^{-1}$\\footnote{Some simultors allow one to specify these transformations\n  directly. Other simulators assume geometry is living in body space in which\n  case one actually has to transform the geometry.}.\n\n\\section*{Visualization Update of a Rigid Body}\\label{sec:visualization-update}\nDuring simulation a rigid body simulator will compute new values of $\\vec r_B$\nand $\\mat R_B$. However, for the visualization one needs to find the new\nplacement of the model frame in the world. Thus one must solve\n\\begin{subequations}\n  \\begin{align}\n    \\vec r  &= \\vec r_B + \\mat R \\vec r_M, \\\\\n    \\mat R &= \\mat R_B \\mat R_M^{-1}.\n  \\end{align}\n\\end{subequations}\nThus, one must always store the body frame to model frame transformation given\nby $\\vec r_M$ and $\\mat R_M$.\n\n\n\\section*{The Curious Parallel Axis Theorem}\\label{sec:curi-parall-axis}\nOne has to be carefull when applying the parallel axis theorem. By its\ndefinition it transforms a body frame inertia tensors $\\inertia$ into a modified\ntensor $\\inertia^\\prime$\nhaving the same orientation but a different reference point given by the\ntranslation $\\vec d$\n\\begin{subequations}\n  \\begin{align}\n    \\inertia_{\\alpha \\alpha}^\\prime \n    &=\n    \\inertia_{\\alpha \\alpha} + \\mass (\\vec d_{\\beta}^2  + \\vec d_{\\gamma}^2)\\\\\n    \\inertia_{\\alpha \\beta}^\\prime &=  \\inertia_{\\alpha \\beta} - \\mass (\\vec\n    d_{\\alpha} \\vec d_{\\beta})\n  \\end{align}\n\\end{subequations}\nHere the primed quantities would be the modified inertia tensor that no longer\nlives in the body space frame. The translation given here is the vector from the\nbody space frame origin to the new origin of the new model frame.\n\nHowever, here comes the tricky part say one which to do another translation to\nget $\\inertia^{\\prime\\prime}$ then one can not just apply the above formula to\n$\\inertia^\\prime$. Instead one must first transform $\\inertia^\\prime$ back to the\nbody space frame using \n\\begin{subequations}\n  \\begin{align}\n    \\inertia_{\\alpha \\alpha} \n    &=\n    \\inertia_{\\alpha \\alpha}^\\prime - \\mass (\\vec d_{\\beta}^2  + \\vec d_{\\gamma}^2)\n    \\\\\n    \\inertia_{\\alpha \\beta} \n    &=\n    \\inertia_{\\alpha \\beta}^\\prime + \\mass (\\vec d_{\\alpha} \\vec d_{\\beta})\n  \\end{align}\n\\end{subequations}\nand first then may one apply the transform taking one from the body space\ninertia tensor into the $\\inertia^{\\prime\\prime}$ tensor.\n\n\\section*{Creating Compounds}\\label{sec:creating-compounds}\nAs mass properties are defined by volume integrals it is easy to see that all we\nneed to do is to make sure all properties are given with respect to the same\nreference frame. When this is the case we can simply sum up all the mass\nproperties.\n\nHere we will give an example of two rigid bodies their body frame inertia\ntensors are given by the constant diagonal tensors $\\inertia_A$ and\n$\\inertia_B$. The center of mass positions are given by $\\vec r_A$ and $\\vec\nr_B$ and the orientatio of the body frames wrt. the world frame is given by\n$\\mat R_A$ and $\\mat R_B$.\n\nIn our first step we will transform inertia tensors into the world frame\n\\begin{subequations}\n\\begin{align}\n  \\inertia^{\\prime}_A &\\leftarrow \\mat R_A \\inertia_A \\mat R_A^T,\\\\\n  \\inertia^{\\prime}_B &\\leftarrow \\mat R_B \\inertia_B \\mat R_B^T,\\\\\n  \\inertia^{\\prime^\\prime}_A &\\leftarrow \\textbf{p-a-t}(\\inertia_A^\\prime,  \\vec   r_A) ,\\\\\n  \\inertia^{\\prime^\\prime}_B &\\leftarrow \\textbf{p-a-t}(\\inertia_B^\\prime, \\vec\n  r_B) .\n\\end{align}  \n\\end{subequations}\nNext we may find the compund inertia tensor with reference to the world frame\n\\begin{equation}\n  \\inertia_C^\\prime = \\inertia^{\\prime^\\prime}_A + \\inertia^{\\prime^\\prime}_B\n\\end{equation}\nThe total mass is simply\n\\begin{equation}\n  \\mass_C = \\mass_A + \\mass_B\n\\end{equation}\nand the center of mass position is\n\\begin{equation}\n  \\vec r_C =  \\frac{\\mass_A \\vec r_A + \\mass_B \\vec r_B}{ \\mass_C}\n\\end{equation}\nWhat remains is to find the body frame inertia tensor\n\\begin{subequations}\n  \\begin{align}\n    \\inertia_C^{\\prime\\prime} &\\leftarrow \\textbf{p-a-t}(\\inertia_C^\\prime, - \\vec   r_C) .\\\\\n    \\mat R_C \\inertia_C \\mat R_C^T  &\\leftarrow \\inertia_C^{\\prime\\prime}\n  \\end{align}\n\\end{subequations}\nThe recipe can be incremental extended straigthforwardly. Observe that there is\none more snag as with the creation of rigid bodies one must ensure that\ngeometries in the rigid body simulator is given writh respect to the new\ncompound bodies body frame.\n\n\n\n\n\\section*{Handling a Deformed Box}\\label{sec:handl-deform-box}\nImagine we are given a deformed box shape. We assume that the deformation can be\nspecified by some linear coordinate transformation and write thie mathematically\nas\n\\begin{equation*}\n  \\begin{bmatrix}\n    x\\\\\n    y\\\\\n    z\n  \\end{bmatrix}\n  =\n  \\mat \\Phi\n  \\begin{bmatrix}\n    X\\\\\n    Y\\\\\n    Z\n  \\end{bmatrix}\n\\end{equation*}\nwhere the linear transformation is given by the matrix $\\mat A$ that maps\ncoordinates the $(X, Y, Z)$ from a regular unit box with its center placed at\nthe origin into the deformed coordinates $(x, y, z)$. Here we assume that the\nmapping is bijective and thus $\\mat  \\Phi$ must be invertible implying we\ncan find the inverse mapping given by $\\mat \\Phi^{-1}$\n\nWe now wish to find closed form solutions for the mass properties of the\ndeformed box. That is we wish to solve the volume integrals\n\\begin{subequations}\n  \\begin{align*}\n    \\mass &= \\int_v  \\rho   dv \\\\\n    \\vec r_x &= \\frac{1}{\\mass}\\int_v  \\rho \\vec x  dv \\\\\n    \\vec r_y &= \\frac{1}{\\mass}\\int_v  \\rho \\vec y  dv \\\\\n    \\vec r_z &= \\frac{1}{\\mass}\\int_v  \\rho \\vec z  dv \\\\\n    \\inertia_{xx} &= \\int_v  \\rho \\left( y^2 + z^2 \\right)  dv \\\\\n    \\inertia_{yy} &= \\int_v  \\rho \\left( x^2 + y^2 \\right)  dv \\\\\n    \\inertia_{zz} &= \\int_v  \\rho \\left( x^2 + y^2 \\right)  dv \\\\\n    \\inertia_{xy} &= - \\int_v  \\rho \\left( x y \\right)  dv \\\\\n    \\inertia_{xz} &= - \\int_v  \\rho \\left( x z\\right)  dv \\\\\n    \\inertia_{yz} &= - \\int_v  \\rho \\left( y z \\right)  dv\n  \\end{align*}\n\\end{subequations}\nOur approach to finding the closed form solutions we seek is to rewrite the\nvolume integrals such that we are integrating over the undeformed volume. The\nmachinery is pretty much the same for all equations so we will here just treat\none term in detail and leave the remaining terms for the reader.\n\nFirst we will make a change of variables using the formula $dv = j dV$ where $j\n= \\det(\\mat  \\Phi)$\n\\begin{subequations}\n  \\begin{align*}\n    \\inertia_{xx} &= \\int_v  \\rho \\left( y^2 + z^2 \\right)  dv \\\\\n    \\inertia_{xx} &= j \\rho \\int_V   \\left( y^2 + z^2 \\right)  dV\n  \\end{align*}  \n\\end{subequations}\nSecondly we observe that the deformed coordinates are a linear mapping of\nundeformed coordinates that means\n\\begin{subequations}\n  \\begin{align*}\n    x  &=  \\Phi_{11} X + \\Phi_{12} Y + \\Phi_{13} Z\\\\\n    y  &=  \\Phi_{21} X + \\Phi_{22} Y + \\Phi_{23} Z\\\\\n    z  &=  \\Phi_{31} X + \\Phi_{32} Y + \\Phi_{33} Z\n  \\end{align*}\n\\end{subequations}\nusing this we have that\n\\begin{equation*}\n  \\begin{split}\n    y^2 + z^2 \n    =\n    \\left(\\Phi_{21} X + \\Phi_{22} Y + \\Phi_{23} Z\\right)^2 \n    \\quad \\quad \\quad \\quad \\quad \n    \\\\\n    +\n    \\left(\\Phi_{31} X + \\Phi_{32} Y    + \\Phi_{33} Z\\right)^2 \n    =\n    P_2(X,Y,Z)    \n  \\end{split}\n\\end{equation*}\nwhere $P_2$ denotes a general second order polynomial in $X$, $Y$ and $Z$. So\nnow the volume integral reads\n\\begin{subequations}\n  \\begin{align*}\n    \\inertia_{xx} \n    &=\n    j \\rho \\int_V   P_2(X,Y,Z)  dV\\\\\n    &= \n    j \\rho \n    \\int_{-\\frac{1}{2}}^{\\frac{1}{2}}  \n    \\int_{-\\frac{1}{2}}^{\\frac{1}{2}}  \n    \\int_{-\\frac{1}{2}}^{\\frac{1}{2}}  \n    P_2(X,Y,Z)\n    dX\n    dY\n    dZ\n  \\end{align*}\n\\end{subequations}\nWhich is straightforward to solve for a closed form solution. All that are\nmissing in order to do this is formulas for the coefficients of $P_2$ in the\ngiven integral these are\n\\begin{subequations}\n  \\begin{align*}\n    P_2(X,Y,Z) \n    &= \\underbrace{ \\left (\\Phi_{21}^2 + \\Phi_{31}^2\\right) }_{a_{XX}} X^2 \\\\\n    &+ \\underbrace{ \\left (\\Phi_{22}^2 + \\Phi_{32}^2\\right) }_{a_{YY}}  Y^2 \\\\\n    &+ \\underbrace{ \\left (\\Phi_{23}^2 + \\Phi_{33}^2\\right) }_{a_{ZZ}}  Z^2\\\\\n    &+ \\underbrace{ 2 \\left ( \\Phi_{21} \\Phi_{22} + \\Phi_{31} \\Phi_{32} \\right)\n    }_{a_{XY}}  X Y \\\\\n    &+ \\underbrace{ 2 \\left ( \\Phi_{21} \\Phi_{23} + \\Phi_{31} \\Phi_{33} \\right)\n    }_{a_{XZ}}  X Z \\\\\n    &+ \\underbrace{ 2 \\left(\\Phi_{22} \\Phi_{23} + \\Phi_{32} \\Phi_{33}\\right) }_{a_{YZ}} Y Z \n  \\end{align*}\n\\end{subequations}\nFrom this we find\n\\begin{subequations}\n  \\begin{align*}\n    \\inertia_{xx}\n    =\n    j \\rho\n    \\begin{bmatrix}\n      \\begin{matrix}\n        \\frac{a_{XX}}{3} X^3 Y Z +\\frac{a_{yy}}{3} X Y^3 Z +\\\\\n        \\quad \\frac{a_{zz}}{3} X Y Z^3 +  \\frac{a_{XY}}{4} X^2 Y^2  Z +\\\\\n        \\quad \\quad         \\frac{a_{XZ}}{4} X^2 Y  Z^2 + \\frac{a_{YZ}}{4} X Y^2  Z^2      \n      \\end{matrix}\n    \\end{bmatrix}_{ (-\\frac{1}{2}, -\\frac{1}{2}, -\\frac{1}{2} ) } ^{ (\n      \\frac{1}{2}, \\frac{1}{2}, \\frac{1}{2})  }\n  \\end{align*}\n\\end{subequations}\nFrom this we can generalize the recipe for deriving a closed form solution for\nall the volume intergrals. The other principal moments of inertia will be\npermutations of the above derivation. The products of moments are all similar\nand will also result in integrals of second order polynomials. The center of\nmass integrals all results in integrals of linear polynomials and the mass\nvolume integral is straightforward.\n\n\n\n\n\\bibliographystyle{plain}\n\\bibliography{references}\n\n\n\\end{document}\n\n%%% Local Variables: \n%%% mode: pdflatex\n%%% TeX-master: t\n%%% End: \n", "meta": {"hexsha": "35ed46a1fb84cb67b52693b4d0c5d6002d069aa7", "size": 14613, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PROX/SIMULATION/MASS/tex/hints.tex", "max_stars_repo_name": "diku-dk/PROX", "max_stars_repo_head_hexsha": "c6be72cc253ff75589a1cac28e4e91e788376900", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-27T09:44:45.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-13T00:24:21.000Z", "max_issues_repo_path": "PROX/SIMULATION/MASS/tex/hints.tex", "max_issues_repo_name": "erleben/matchstick", "max_issues_repo_head_hexsha": "1cfdc32b95437bbb0063ded391c34c9ee9b9583b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PROX/SIMULATION/MASS/tex/hints.tex", "max_forks_repo_name": "erleben/matchstick", "max_forks_repo_head_hexsha": "1cfdc32b95437bbb0063ded391c34c9ee9b9583b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3674033149, "max_line_length": 93, "alphanum_fraction": 0.6944501471, "num_tokens": 4577, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4358836980585609}}
{"text": "\\chapter{Lip Reed}\\label{ch:lipreed}\nThe dynamics of wind instruments can be modelled by acoustic tubes as presented in Chapter 5. Excitation of these instruments happens either by blowing a jet of air across an opening, such as in a flute, or by the buzzing of a \\textit{reed}. In \\cite{Fletcher1998}, the authors state that all wind-instrument reeds fall into one of three categories: the single reed, (clarinet, saxophone), the double reed (oboe, bassoon) and the lip reed (trumpet, trombone). The latter will be the focus of this chapter.\n\n% Brass instruments are excited by the lips of the player. The opening and closing of the lips causes a vibration\nSections \\ref{sec:webstersExcitation} and \\ref{sec:pulseTrain} presented a physically inspired pulse train that attempts to model the opening and closing of the lips using a clipped sinusoidal signal. A more physical approach, which is bidirectional, is to model the lips as a mass-spring-damper system that interacts with the left boundary of the tube. The literature describes lip reed models with varying degrees of freedom (DoF) (see \\cite{Fletcher1998,Harrison2018} for an overview). Recent work includes vortex-induced vibration into the lip reed model that allows for the buzzing of the lips without the need of an acoustic tube [\\hyperref[ch:listOfPublications]{S1}]. \n\nAs the contribution of this project to a brass instrument model was mainly focused on the resonator, the simple `outward striking door model' was chosen, which is a simple single one-DoF mass-spring-damper system. The model is as presented in \\cite{Bilbao2009Reed} excluding the collision. An alternative collision model was added in paper \\citeP[H] and will be elaborated on in Chapter \\ref{ch:trombone}.\\todo{check}\n\nThis chapter starts by introducing the mass-spring-damper system, after which the lip reed model will be given in continuous and discrete time. The lip reed will be coupled to the first-order system of equations presented in \\ref{sec:firstOrderSystem}. Unless denoted otherwise, this chapter follows \\cite{Harrison2018}. \n\n\\section{Mass-spring systems revisited: Damping}\\label{sec:massSpringDamping}\nBefore moving on to the lip reed system, the mass-spring system given in Section \\ref{sec:massSpringSystem} will be extended to contain damping. \n\nRecall the mass spring system presented in Eq. \\eqref{eq:massSpringPDE}, where $u=u(t)$ is the displacement of the mass from its equilibrium position (in m). Damping can be easily be added to yield a mass-spring-damper system as follows:\n\\begin{equation}\\label{eq:massSpringDampingPDE}\n    M\\ddot u = -Ku - R\\dot u,\n\\end{equation}\nwith mass $M$ (in kg), spring constant $K$ (N/m) and damping coefficient $R$ (in kg/s). Figure \\ref{fig:massSpringDamper} shows the behaviour of the system for different values of $R$. \n\n\\def\\figWidth{0.32}\n\\begin{figure}[b]\n    \\centering\n    \\subfloat[$R=0$.\\label{fig:massSpringDamper1}]{\\includegraphics[width=\\figWidth\\textwidth]{figures/exciters/lipreed/massSpringDamper1.eps}}\\hfill\n    \\subfloat[$R=50$.\\label{fig:massSpringDamper2}]{\\includegraphics[width=\\figWidth\\textwidth]{figures/exciters/lipreed/massSpringDamper2.eps}}\\hfill\n    \\subfloat[$R=200$.\\label{fig:massSpringDamper3}]{\\includegraphics[width=\\figWidth\\textwidth]{figures/exciters/lipreed/massSpringDamper3.eps}}\n    \\caption{The mass-spring-damper system in Eq. \\eqref{eq:massSpringDampingPDE} with $f_0=440$ Hz for different values of $R$. \\label{fig:massSpringDamper}}\n\\end{figure}\n\nEquation \\eqref{eq:massSpringDampingPDE} can then be discretised to the following FD scheme:\n\\begin{equation}\\label{eq:massSpringDampingFDS}\n    M\\dtt \\un = -K\\un - R\\dtd \\un.\n\\end{equation}\nExpanding and solving for $u^{n+1}$ yields the following update equation (before division with the term multiplied onto $u^{n+1}$):\n\\begin{equation}\\label{eq:massSpringDampingUpdate}\n    \\left(1+\\frac{Rk}{2M}\\right)u^{n+1} = 2 \\un - u^{n-1} - \\frac{Kk^2}{M}\\un + \\frac{Rk}{2M}u^{n-1}.\n\\end{equation}\n\n\\subsection{Energy analysis}\nFollowing Section \\ref{sec:energyAnalysis} (without explicitly following the steps for brevity), one can obtain the energy of Eq. \\eqref{eq:massSpringDampingFDS} through a multiplication of the scheme by $(\\dtd \\un)$ to get\n\\begin{equation}\\label{eq:massSpringDampingPreEnergyBalance}\n    M(\\dtt \\un)(\\dtd \\un) = -K(\\dtd \\un)\\un - R(\\dtd \\un)^2.\n\\end{equation}\nAs there is damping present in the system, the energy balance will be of the form \n\\begin{equation*}\n    \\dtp \\h = -\\q.\n\\end{equation*}\nUsing identities \\eqref{eq:prodIdentity1} and \\eqref{eq:prodIdentity2}, $\\h$ and $\\q$ can be obtained from Eq. \\eqref{eq:massSpringDampingPreEnergyBalance} \n\\begin{equation}\\label{eq:energyBalanceMassSpringDamper}\n    \\h = \\t + \\v, \\qwiq\n    \\t = \\frac{M}{2}(\\dtm\\un)^2, \\qaq \\v = \\frac{K}{2}\\un e_{t-}\\un.\n\\end{equation} \nand\n\\begin{equation}\\label{eq:massDampingEnergy}\n    \\q = R(\\dtd \\un)^2.\n\\end{equation}\n\nFigure \\ref{fig:massSpringDamperEnergy} shows the energy output of the mass spring damper system with $R = 50$ and $f_0 = 2\\pi\\sqrt{K/M} = 440$ Hz. One can observe that the damping term causes the system to lose energy when the mass is in motion (high kinetic energy).\n\\begin{figure}[h]\n    \\centering\n    \\begin{tikzpicture}[->,node distance=3cm,\n        thick,main node/.style={circle,draw}]\n    \n        \\node[] (image) at (0,0) {\n        \\includegraphics[width=\\textwidth]{figures/exciters/lipreed/massSpringDamperEnergy.eps}\n        };\n    \n        \\node[] (he) at (0.2,0.5) {\\small $\\mathfrak{h}_\\text{e}$};\n\n        \\node[] (h) at (-5.8, 1) {\\small $\\mathfrak{h}$};\n        \\node[] (v) at (-5.8, 0.5) {\\small $\\color{red}\\mathfrak{v}$};\n        \\node[] (t) at (-5.8, 0) {\\small $\\color{blue}\\mathfrak{t}$};\n      \\end{tikzpicture}\n      \\caption{The potential (red), kinetic (blue), and total (black) energy of the mass-spring-damper system. The right panel shows the normalised energy (according to Eq. \\eqref{eq:normalisedEnergyDamping}) and shows that the deviation of the energy is within machine precision. \\label{fig:massSpringDamperEnergy}}\n\\end{figure}\n\n\\section{Continuous time}\\label{sec:lipreedContinuous}\nAs mentioned at the beginning of this chapter, the lip reed will be modelled as a mass-spring-damper system as in Eq. \\eqref{eq:massSpringDampingPDE}. The system will be coupled to an acoustic tube described by the first-order system of PDEs described in Section \\ref{sec:firstOrderSystem}, Eq. \\eqref{eq:firstOrderSystem}.\n% :\n% \\begin{subequations}\\label{eq:firstOrderSystemLipReedCh}\n%     \\begin{align}\n%         \\frac{S}{\\rho_0 c^2}\\partial_t p &= -\\partial_x(Sv),\\label{eq:contPressureLipReedCh}\\\\\n%         \\rho_0\\partial_tv &= -\\partial_xp\\label{eq:discVelocityLipReedCh},\n%     \\end{align}\n% \\end{subequations} %An additional term  due to the pressure difference between the mouth and the tube is added to the equation and t\n\nUsing dots to denote derivatives with respect to time $t$, the PDE of the lip reed connected to an acoustic tube is defined as\n\\begin{equation}\\label{eq:lipReedDimensional}\n    M\\ddot y = -K y - R \\dot y + S_\\text{r}\\Delta p.\n\\end{equation}\nwith displacement of the lip reed from equilibrium $y = y(t)$ (in m), mass of the lip reed $M > 0$ (in kg), lip stiffness $K\\geq 0$ (in N/m), damping coefficient $R\\geq 0$ (in kg/s), and effective surface area of the lip $S_\\text{r}\\geq 0$ (in m$^2$). Furthermore,  \n\\begin{equation}\\label{eq:deltaP}\n    \\Delta p = \\Delta p(t) = P_\\text{m} - p(0,t)\n\\end{equation}\nis the difference between the pressure in the mouth $P_\\text{m} = P_\\text{m}(t)$ and the pressure at the left boundary of the acoustic tube $p(0,t)$ (all in Pa). The acoustic tube can be described by the first-order system presented in Section \\ref{sec:firstOrderSystem}. See Figure \\ref{fig:lipSystem} for a schematic representation of the lip reed.\n\\input{exciters/lipReedSystemFig.tex}\n\nThe pressure difference in Eq. \\eqref{eq:deltaP} causes a volume flow velocity (in  m$^3$/s) and follows the Bernoulli equation\n\\begin{equation}\n    U_\\text{B} = U_\\text{B}(t) = w[y + H_0]_+\\text{sgn}(\\Delta p) \\sqrt{\\frac{2|\\Delta p|}{\\rho_0}},\n\\end{equation}\nwith effective lip-reed width $w$ (in m), density of air $\\rho_0$ (in kg/m$^3$), static equilibrium separation $H_0$ (in m). Moreover, $[\\cdot]_+$ describes the `positive part of' (see Chapter \\ref{ch:collisions}). The negative equilibrium separation $-H_0$ can be seen as the location of the lower lip, and when $y + H_0 \\leq 0$, the lips are closed and $U_\\text{B}$ is 0. Another volume flow (in m$^3$/s) is generated by the lip reed itself according to\n\\begin{equation}\n    U_\\text{r} = U_\\text{r}(t) = S_\\text{r} \\dot y,\n\\end{equation}\nand assuming that the volume flow velocity is conserved, the total air volume entering the acoustic tube at the left boundary is defined as\n\\begin{equation}\n    S(0)v(0,t) = U_\\text{B}(t) + U_\\text{r}(t).\n\\end{equation} \n\n\\subsubsection{Compact PDE}\nTo reduce the number of variables in later derivations in this chapter, one can divide all terms in Eq. \\eqref{eq:lipReedDimensional} by $M$ to obtain\n\\begin{equation}\n    \\ddot y = -\\omega_0^2 y - \\sigma_\\text{r} \\dot y + \\frac{S_\\text{r}}{M}\\Delta p,\n\\end{equation}\nwith angular frequency of the lip reed $\\omega_0 = \\sqrt{K/M}$ (rad/s) and loss parameter $\\sigma_\\text{r} = R / M$ (s$^{-1}$). \n\n\\section{Discrete time}\\label{sec:discreteLipReed}\n\\def\\nph{}\n\\def\\nphSys{n+1/2}\n\nFollowing \\cite{Harrison2018}, $y$, $\\Delta p$, and thereby $U_\\text{B}$ and $U_\\text{r}$ are placed on the interleaved temporal grid\\footnote{The variables are placed on the non-interleaved spatial grid, as the lip reed interacts with the boundary of the tube ($x=0$).}, and the equations presented above can be discretised to the following system:\n\\begin{subequations}\\label{eq:discreteLipSystem}\n    \\begin{align}\n        \\delta_{tt}y^{\\nphSys} &= -\\omega_0^2\\mu_{t\\cdot}y^{\\nphSys}-\\sigma_\\text{r}\\delta_{t\\cdot}y^{\\nphSys} + \\frac{S_\\text{r}}{M}\\Delta p^{\\nphSys},\\label{eq:discReed}\\\\\n        \\Delta p^{\\nphSys} &= P_\\text{m} - \\mu_{t+}p_0^n,\\label{eq:pDiff}\\\\\n        U_\\text{B}^{\\nphSys} &= w[y^{\\nphSys}+H_0]_+\\text{sgn}(\\Delta p^{\\nphSys})\\sqrt{\\frac{2|\\Delta p^{\\nphSys}|}{\\rho_0}},\\label{eq:bernoulli}\\\\\n        U_\\text{r}^{\\nphSys} &= S_\\text{r}\\delta_{t\\cdot}y^{\\nphSys},\\label{eq:Ur}\\\\\n        \\mu_{x-}(S_{1/2}v_{1/2}^{\\nphSys}) &= U_\\text{B}^{\\nphSys} + U_\\text{r}^{\\nphSys}.\\label{eq:UbUr}\n    \\end{align}\n\\end{subequations}\nHere, $p_0^n$ and $S_{1/2}v_{1/2}^{\\nphSys}$ are discrete values at the left boundary of an acoustic tube described by system \\eqref{eq:firstOrderFDS}. Expanding the operators in Eq. \\eqref{eq:discReed} and solving for $y^{n+3/2}$ yields\n\\begin{equation}\\label{eq:updateEqLipreed}\n    % \\left(1 + \\frac{\\omega_0^2 k^2}{2} + \\frac{\\sigma_\\text{r} k}{2}\\right)y^{n+3/2} &= 2 y^{n+1/2} - \\left(1 + \\frac{\\omega_0^2 k^2}{2} - \\frac{\\sigma_\\text{r} k}{2}\\right) y^{n-1/2} + \\frac{S_\\text{r} k^2}{M} \\Delta p^{n+1/2}\\nonumber\\\\\n    \\alpha_\\text{r}y^{n+3/2} = 4y^{n+1/2} + \\beta_\\text{r}y^{n-1/2} + \\xi_\\text{r}\\Delta p^{n+1/2}\n\\end{equation}\nwhere (after a multiplication by 2 to reduce fractions)\n\\begin{equation}\\label{eq:lipreedUpdateTerms}\n    \\alpha_\\text{r} = 2 + \\omega_0^2k^2 + \\sigma_\\text{r} k\\ , \\quad \\beta_\\text{r} =  \\sigma_\\text{r} k - 2 - \\omega_0^2 k^2\\ , \\quad \\text{and} \\quad \\xi_\\text{r} = \\frac{2 S_\\text{r}k^2}{M}.\n\\end{equation}\nAlthough Eq. \\eqref{eq:updateEqLipreed} seems to be implicitly dependent to the pressure difference $\\Delta p^{n+1/2}$ it is possible to explicitly solve it. A derivation is shown below.\n\n\\subsection{Obtaining $\\Delta p$}\\label{sec:obtainingDeltaP}\nIn the following, the superscript $n+1/2$ will be suppressed for $y$, $\\Delta p$, $U_\\text{B}$, $U_\\text{r}$, $S_{1/2}$ and $v_{1/2}$ for brevity. \n\n\\subsubsection{Rewrite Eq. \\eqref{eq:discReed}}\nUsing identities \\eqref{eq:identity1} and \\eqref{eq:identity4}, Eq. \\eqref{eq:discReed} can be rewritten to\n\\begin{equation*}\n    \\frac{2}{k} (\\delta_{t\\cdot} - \\delta_{t-})y^{\\nph} = -\\omega_0^2(k\\delta_{t\\cdot} + e_{t-})y^{\\nph} - \\sigma_\\text{r}\\delta_{t\\cdot} y^{\\nph} + \\frac{S_\\text{r}}{M}\\Delta p^{\\nph},\n\\end{equation*}\nand, after grouping the terms,\n\\begin{equation}\n    a_1\\delta_{t\\cdot}y^{\\nph} - a_2\\Delta p^{\\nph} - a_3^n = 0,\\label{eq:preAEquation}\n\\end{equation}\nwhere\n\\begin{equation}\\label{eq:aCoeffs}\n    a_1 = \\frac{2}{k} + \\omega_0^2k + \\sigma_\\text{r} \\geq 0, \\quad a_2 = \\frac{S_\\text{r}}{M} \\geq 0\\ , \\quad \\text{and} \\quad a_3^n = \\left(\\frac{2}{k} \\delta_{t-} - \\omega_0^2e_{t-}\\right)y^{\\nph}\\ .\n\\end{equation}\nNote that non-negativity property can be applied to $a_1$ and $a_2$ as these are calculated solely from non-negative parameters. %The same will be done for other coefficients below.\nEquation \\eqref{eq:Ur} can then be substituted into Eq. \\eqref{eq:preAEquation}\n\\begin{equation*}\n    \\frac{a_1}{S_\\text{r}}U_\\text{r}^{\\nph} - a_2 \\Delta p^{\\nph} - a_3^n = 0,\n\\end{equation*}\nand consequently Eq. \\eqref{eq:UbUr} to get\n\\begin{equation}\\label{eq:aEquation}\n    \\frac{a_1}{S_\\text{r}}\\left(\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph}) - U_\\text{B}^{\\nph}\\right) - a_2 \\Delta p^{\\nph} - a_3^n = 0.\n\\end{equation}\n%\n\\subsubsection{Obtaining $\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph})$}\nTo obtain a definition for $\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph})$, one can use the FD scheme for the pressure of the first-order system in \\eqref{eq:discPressure} and evaluate this at $l = 0$\n\\begin{equation}\n    \\frac{\\bar S_0}{\\rho_0 c^2}\\delta_{t+}p_0^n = -\\delta_{x-}(S_{1/2}v_{1/2}^{\\nph}).\n\\end{equation}\nUsing identity \\eqref{eq:identityLip} for $\\dxm$ and $\\delta_{t+}$, this can be rewritten to\n% \\begin{equation}\n%     \\frac{\\bar S_0}{\\rho_0 c^2}\\delta_{t+}p_0^n = \\frac{2}{h} \\left(\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph})-S_{1/2}v_{1/2}^{\\nph}\\right),\n% \\end{equation}\n% and, using the same identity for $\\delta_{t+}$, yields\n\\begin{equation}\n    \\frac{2\\bar S_0}{\\rho_0 c^2k}(\\mu_{t+}p_0^n-p_0^n) = \\frac{2}{h} \\left(\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph})-S_{1/2}v_{1/2}^{\\nph}\\right).\n\\end{equation}\nand substituting Eq. \\eqref{eq:pDiff} yields\n\\begin{align}\n    \\frac{2\\bar S_0}{\\rho_0 c^2k}(P_\\text{m} - \\Delta p^{\\nph}-p_0^n) &= \\frac{2}{h} \\left(\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph})-S_{1/2}v_{1/2}^{\\nph}\\right).\\nonumber\\\\\n    \\mu_{x-}(S_{1/2}v_{1/2}^{\\nph}) &= b_1^n - b_2\\Delta p^{\\nph}\\label{eq:bEquation}\n\\end{align}\nwhere\n\\begin{equation}\\label{eq:bCoeffs}\n    b_1^n = S_{1/2}v_{1/2}^{\\nph} + \\frac{\\bar S_0h}{\\rho_0 c^2k} (P_\\text{m} - p_0^n), \\quad \\text{and} \\quad b_2 = \\frac{\\bar S_0h}{\\rho_0 c^2k} \\geq 0\\ .\n\\end{equation}\n\\subsubsection{Final steps}\nEquations \\eqref{eq:bEquation} and \\eqref{eq:bernoulli} can be substituted into Eq. \\eqref{eq:aEquation} to get\n\\begin{gather}\n    \\frac{a_1}{S_\\text{r}}\\left(b_1^n - b_2\\Delta p^{\\nph} - w[y^{\\nph}+H_0]_+\\text{sgn}(\\Delta p^{\\nph})\\sqrt{\\frac{2|\\Delta p^{\\nph}|}{\\rho_0}}\\right) - a_2 \\Delta p^{\\nph} - a_3^n = 0,\\nonumber\\\\\n    - w[y^{\\nph}+H_0]_+\\text{sgn}(\\Delta p^{\\nph})\\sqrt{\\frac{2|\\Delta p^{\\nph}|}{\\rho_0}} - b_2\\Delta p^{\\nph} - \\frac{a_2S_\\text{r}}{a_1} \\Delta p^{\\nph} + b_1^n - \\frac{a_3^nS_\\text{r}}{a_1} = 0,\\nonumber\\\\\n    -c_1^n\\text{sgn}(\\Delta p^{\\nph})\\sqrt{|\\Delta p^{\\nph}|} - c_2\\Delta p^{\\nph} + c_3^n = 0\\label{eq:cEquation}\n\\end{gather}\nwhere\n\\begin{equation}\\label{eq:cCoeffs}\n    c_1^n = w[y^{\\nph} + H_0]_+\\sqrt{\\frac{2}{\\rho_0}} \\geq 0, \\quad c_2 = b_2 + \\frac{a_2S_\\text{r}}{a_1} \\geq 0, \\quad \\text{and}\\quad c_3^n = b_1^n - \\frac{a_3^nS_\\text{r}}{a_1}\\ .\n\\end{equation}\nEquation \\eqref{eq:cEquation} can be divided by $-\\text{sgn}(\\Delta p^{\\nph})$ to get a quadratic equation in $\\sqrt{|\\Delta p^{\\nph}|}$\n\\begin{equation}\n    c_2|\\Delta p^{\\nph}| + c_1^n\\sqrt{|\\Delta p^{\\nph}|} - \\frac{c_3^n}{\\text{sgn}(\\Delta p^{\\nph})} = 0.\n\\end{equation}\nAs $c_1^n, c_2 \\geq 0$, the following must be true for any real solutions to exist\n\\begin{equation}\\label{eq:sgnEquality}\n    \\text{sgn}(c_3^n) = \\text{sgn}(\\Delta p^{\\nph}) \\quad \\Longrightarrow \\quad \\frac{c_3^n}{\\text{sgn}(\\Delta p^{\\nph})} = |c_3^n|.\n\\end{equation}\nand one can solve for $\\sqrt{|\\Delta p^{\\nph}|}$:\n\\begin{equation}\n    \\sqrt{|\\Delta p^{\\nph}|} = \\frac{-c_1^n \\pm \\sqrt{(c^n_1)^2+4c_2|c_3^n|}}{2c_2}\\ .\n\\end{equation}\nFinally, because $\\sqrt{(c_1^n)^2 + 4c_2|c_3^n|} \\geq c_1^n$, one can only guarantee a positive solution if square root term is added. Using Eq. \\eqref{eq:sgnEquality}, the definition for the pressure difference can be found:\n\\begin{equation}\\label{eq:pressureDiff}\n    \\Delta p^{\\nph} = \\text{sgn}(c_3^n)\\left(\\frac{-c_1^n + \\sqrt{(c^n_1)^2+4c_2|c_3^n|}}{2c_2}\\right)^2.\n\\end{equation}\nwhich can be used in the update of the lip reed in Eq. \\eqref{eq:discReed}. \n\n\\subsection{Coupling to the tube}\\label{sec:lipreedTube}\nThe coupling of the lip reed to the acoustic tube is easily done by rewriting Eq. \\eqref{eq:pressureUpdate} evaluated at $l=0$ to\n\\begin{equation}\\label{eq:tubeCoupling}\n    p^{n+1}_0 = p_0^n - \\frac{\\rho_0c\\lambda}{\\bar S_0}\\left(-2\\mu_{x-}(S_{1/2}v_{1/2}^{\\nph}) + 2 S_{1/2}v_{1/2}^{\\nph}\\right).\n\\end{equation}\nEquation \\eqref{eq:UbUr} can then be substituted to get\n\\begin{equation}\\label{eq:pressureCoupled}\n    p^{n+1}_0 = p_0^n - \\frac{\\rho_0c\\lambda}{\\bar S_0}\\left(-2(U_\\text{B}^{\\nph} + U_\\text{r}^{\\nph}) + 2 S_{1/2}v_{1/2}^{\\nph}\\right).\n\\end{equation}\nFigure \\ref{fig:lipreedTube} shows an implementation of the lip reed connected to an acoustic tube. The lip reed is shown on the left and the left boundary of the tube is on the right side of the lip reed. The frequency of the lips is set to $f_0 = 600$ Hz ($\\omega_0 = 1200\\pi$ rad/s), the input pressure $P_\\mtxt = 2000$ Pa and the other parameters are as listed in paper \\citeP[H]. The initial conditions of the lip have been set to $y^{1/2} = y^{3/2} = -H_0$ such that the lips are closed at the start of the simulation and the tube is cylindrical with a circular cross-section of $S(x) = 5\\cdot 10^{-5}$. The figure shows that the lips oscillate, and that when the lips are closed, i.e. when $y \\leq H_0$, no energy enters the acoustic tube.\\footnote{This is similar behaviour to what the pulse train in Section \\ref{sec:pulseTrain} attempts to model.}\n\n% \\subsubsection{Discussion}\n% The oscillation shown in Figure \\ref{fig:lipreedTube} is similar to the pulse train shown in Section \\ref{eq:pulseTrain}, and shows that this type of excitation signal is sufficient as a test case for a lip reed excitation. \n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/exciters/lipreed/lipreedImplementation.eps}\n    \\caption{A lip reed (shown at the left side of the plots) exciting a cylindrical acoustic tube. The y-axis refers to the displacement of the lips and the pressure in the tube $p_l^n$ is shown in red and highlighted with a dashed line (not related to the y-axis).\\label{fig:lipreedTube}}\n\\end{figure}\n\\section{Energy analysis}\nThis section performs an energy analysis on the lip reed system coupled to an acoustic tube using the steps described Section \\ref{sec:energyAnalysis}. As all physical parameters need to be written out to obtain the correct units, Eq. \\eqref{eq:lipReedDimensional} is discretised to get\n\\begin{equation}\\label{eq:discLipreedDimensional}\n    M\\delta_{tt}y^{\\nphSys} = -K\\mu_{t\\cdot}y^{\\nphSys}-R\\delta_{t\\cdot}y^{\\nphSys} + S_\\text{r}\\Delta p^{\\nphSys},\n\\end{equation} \nand will be used in this analysis. Again, the superscript $n+1/2$ will be suppressed for $y$, $\\Delta p$, $U_\\text{B}$, $U_\\text{r}$, $S_{1/2}$ and $v_{1/2}$ for brevity.\n\n\\subsubsection{Step 1: Obtain $\\dtp \\h$} \nMultiplying Eq. \\eqref{eq:discLipreedDimensional} by $(\\delta_{t\\cdot}y)$, and moving all terms to the left-hand side, yields the rate of change of the energy in the lip reed $\\h_\\rtxt$\n\\begin{equation*}\n    \\dtp \\h_\\rtxt = M(\\delta_{t\\cdot}y^{\\nph})(\\delta_{tt}y^{\\nph}) + K(\\delta_{t\\cdot}y^{\\nph})(\\mu_{t\\cdot}y^{\\nph}) + R(\\delta_{t\\cdot}y^{\\nph})^2 - S_\\text{r}(\\delta_{t\\cdot}y^{\\nph})\\Delta p^{\\nph} = 0.\n\\end{equation*}\nOne can substitute Eqs \\eqref{eq:Ur}, and \\eqref{eq:UbUr} thereafter, to get\n\\begin{align*}\n    \\dtp \\h_\\rtxt = M(\\delta_{t\\cdot}y^{\\nph})(\\delta_{tt}y^{\\nph}) &+ K(\\delta_{t\\cdot}y^{\\nph})(\\mu_{t\\cdot}y^{\\nph}) + R(\\delta_{t\\cdot}y^{\\nph})^2 \\\\\n    &\\quad- \\left(\\mu_{x-}(S_{1/2}v_{1/2})-U_\\text{B}\\right)\\Delta p^{\\nph} = 0.\n\\end{align*}\nFinally, substituting Eq. \\eqref{eq:pDiff}, yields\n\\begin{align*}\n    \\dtp \\h_\\rtxt = M(\\delta_{t\\cdot}y^{\\nph})(\\delta_{tt}y^{\\nph}) &+ K(\\delta_{t\\cdot}y^{\\nph})(\\mu_{t\\cdot}y^{\\nph}) + R(\\delta_{t\\cdot}y^{\\nph})^2 \\\\\n    &\\quad+ U_\\text{B}\\Delta p^{\\nph} - \\mu_{x-}(S_{1/2}v_{1/2})(P_\\mtxt-\\mtp p_0^n) = 0.\n\\end{align*}\nOne can then include the tube by recalling that $\\delta_{t+}\\mathfrak{h}_\\text{t} = -\\mathfrak{b}_\\text{r} + \\mathfrak{b}_\\text{l}$, and that the left boundary term is defined as (Eq. \\eqref{eq:firstOrderLeftBoundary})\n\\begin{equation*}\n    \\mathfrak{b}_\\text{l} = (\\mu_{t+}p_0)\\mu_{x-}(S_{1/2}v_{1/2}),\n\\end{equation*} \nand substituting this (ignoring the right boundary term, i.e., $\\b_\\rtxt = 0$) to get\n\\begin{align*}\n    \\dtp (\\h_\\rtxt +\\h_\\ttxt) = M(\\delta_{t\\cdot}y^{\\nph})(\\delta_{tt}y^{\\nph}) &+ K(\\delta_{t\\cdot}y^{\\nph})(\\mu_{t\\cdot}y^{\\nph}) + R(\\delta_{t\\cdot}y^{\\nph})^2 \\\\\n    &\\quad+ U_\\text{B}\\Delta p^{\\nph} - \\mu_{x-}(S_{1/2}v_{1/2})P_\\mtxt = 0.\n\\end{align*}\n\\subsubsection{Step 2: Identify energy types and isolate $\\dtp$}\nUsing identities \\eqref{eq:prodIdentity1} and \\eqref{eq:prodIdentity4}, the energy balance can be shown to be\n\\begin{equation}\n    \\delta_{t+}\\left(\\mathfrak{h}_\\text{t}+\\mathfrak{h}_\\text{r}\\right) = - \\q_\\text{r} - \\mathfrak{p}_\\text{r},\n\\end{equation}\nwhere the energy of the tube $\\h_\\ttxt$ is as defined in Eq. \\eqref{eq:energyBalanceFirstOrder} and the energy of the mass is\n\\begin{equation}\n    \\h_\\rtxt = \\t_\\rtxt + \\v_\\rtxt, \\qwiq \\t_\\rtxt = \\frac{M}{2}(\\delta_{t-}y)^2, \\qaq \\v = \\frac{K}{2}\\mu_{t-}(y^2).\n\\end{equation}\nFurthermore, the damping term is defined as\n\\begin{equation}\n    \\mathfrak{q}_\\text{r} = R(\\dtd y)^2 + U_\\text{B}\\Delta p^{\\nph},\n\\end{equation}\nand the input power as\n\\begin{equation}\n    \\mathfrak{p}_\\text{r} = -(U_\\text{B} + U_\\text{r})P_\\text{m}.\n\\end{equation}\nIt is interesting to note that due to the choice of discretisation of the lip reed, $\\t_\\rtxt$, $\\v_\\rtxt$ and $\\q_\\rtxt$ are non-negative, making the lip reed strictly dissipative and thus inherently stable. \n\n\\subsubsection{Step 3: Check units}\nThe kinetic and potential energy of the lip reed can be written in their units as\n\\begin{align*}\n    \\t_\\rtxt = \\frac{M}{2}(\\delta_{t-}y)^2 &\\ \\overset{\\text{in units}}{\\xrightarrow{\\hspace*{1cm}}} \\quad\\text{kg}\\cdot(\\text{s}^{-1}\\cdot \\text{m})^{2}= \\text{kg}\\cdot\\text{m}^2\\cdot\\text{s}^{-2},\\\\\n    \\v_\\rtxt = \\frac{K}{2}\\mu_{t-}(y^2)&\\ \\overset{\\text{in units}}{\\xrightarrow{\\hspace*{1cm}}} \\quad \\text{N} \\cdot \\text{m}^{-1} \\cdot \\text{m}^2 = \\text{kg}\\cdot\\text{m}^2\\cdot\\text{s}^{-2},\n\\end{align*}\nand have the correct units. Recalling that the damping and input power terms need to have units of kg$\\cdot$ m$^2 \\cdot $s$^{-3}$, writing the individual components of these terms in their respective units yields\n\\begin{align*}\n    R(\\dtd y)^2 &\\ \\overset{\\text{in units}}{\\xrightarrow{\\hspace*{1cm}}} \\quad\\text{kg}\\cdot\\text{s}^{-1}\\cdot(\\text{s}^{-1}\\cdot \\text{m})^{2} = \\text{kg} \\cdot \\text{m}^2 \\cdot \\text{s}^{-3} ,\\\\\n    U_\\text{B}\\Delta p^{\\nph}&\\ \\overset{\\text{in units}}{\\xrightarrow{\\hspace*{1cm}}} \\quad \\text{m}^3 \\cdot \\text{s}^{-1}\\cdot \\text{kg}\\cdot \\text{m}^{-1}\\cdot \\text{s}^{-2}= \\text{kg} \\cdot \\text{m}^2 \\cdot \\text{s}^{-3},\\\\\n    -(U_\\Btxt + U_\\rtxt)P_\\mtxt&\\ \\overset{\\text{in units}}{\\xrightarrow{\\hspace*{1cm}}} \\quad \\text{m}^3 \\cdot \\text{s}^{-1}\\cdot \\text{kg}\\cdot \\text{m}^{-1}\\cdot \\text{s}^{-2}= \\text{kg} \\cdot \\text{m}^2 \\cdot \\text{s}^{-3},\n\\end{align*}\nand shows that the units are indeed correct.\n\\subsubsection{Step 4: Implementation}\nFigure \\ref{fig:lipReedEnergy} shows the energetic output of the lip reed exciting coupled to an acoustic tube corresponding to the behaviour shown in Figure \\ref{fig:lipreedTube}. The total energy of the system increases due to the input pressure and is mainly transferred to the tube. The oscillations of the lip reed can be observed from the oscillations in its kinetic and potential energy. The normalised energy (using Eq. \\eqref{eq:normalisedEnergyDamping}) does not include the first time index as one full iteration of the coupling is necessary to yield a correct energy calculation. Instead, one starts at $n=1$ and uses $\\h^1$ instead of $\\h_0$ in Eq. \\eqref{eq:normalisedEnergyDamping}. \\SWcomment[Check with stefan]\n\n\\begin{figure}[h]\n    \\centering\n    \\begin{tikzpicture}[->,node distance=3cm,\n        thick,main node/.style={circle,draw}]\n    \n        \\node[] (image) at (0,0) {\n        \\includegraphics[width=\\textwidth]{figures/exciters/lipreed/lipreedEnergy.eps}\n        };\n    \n        \\node[] (he) at (0.2,0.5) {\\small $\\mathfrak{h}_\\text{e}$};\n\n        \\node[] (h) at (-5.8, 1) {\\small $\\mathfrak{h}$};\n        \\node[] (v) at (-5.8, 0.5) {\\small $\\color[HTML]{00DB00}\\mathfrak{h}_\\ttxt$};\n        \\node[] (t) at (-5.8, 0) {\\small $\\color{red}\\mathfrak{v}_\\rtxt$};\n        \\node[] (c) at (-5.8, -0.5) {\\small $\\color{blue}\\mathfrak{t}_\\rtxt$};\n\n      \\end{tikzpicture}\n      \\caption{The energy of the acoustic tube (green), the potential energy (red) and the kinetic energy of the lip reed (blue), and the total energy (black) of the system corresponding to Figure \\ref{fig:lipreedTube}. The right panel shows the normalised energy (according to Eq. \\eqref{eq:normalisedEnergyDamping} starting at $n=1$) shows that the deviation of the energy is within machine precision. \\label{fig:lipReedEnergy}}\n\\end{figure}", "meta": {"hexsha": "f6be3d4d6c4f3c795f39437ab28d6583573ca43b", "size": 25750, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aauPhdCollectionThesis/exciters/lipreed.tex", "max_stars_repo_name": "SilvinWillemsen/phdThesis", "max_stars_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aauPhdCollectionThesis/exciters/lipreed.tex", "max_issues_repo_name": "SilvinWillemsen/phdThesis", "max_issues_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aauPhdCollectionThesis/exciters/lipreed.tex", "max_forks_repo_name": "SilvinWillemsen/phdThesis", "max_forks_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.9689440994, "max_line_length": 857, "alphanum_fraction": 0.6886601942, "num_tokens": 9413, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7217432062975978, "lm_q1q2_score": 0.4358836980585608}}
{"text": "\\documentclass[11pt,oneside]{article}    %use\"amsart\"insteadof\"article\"forAMSLaTeXformat\n\\usepackage{geometry}        %Seegeometry.pdftolearnthelayoutoptions.Therearelots.\n\\geometry{letterpaper}        %...ora4paperora5paperor...\n%\\geometry{landscape}        %Activateforforrotatedpagegeometry\n%\\usepackage[parfill]{parskip}        %Activatetobeginparagraphswithanemptylineratherthananindent\n\\usepackage{graphicx}                %Usepdf,png,jpg,orepsßwithpdflatex;useepsinDVImode\n                                %TeXwillautomaticallyconverteps-->pdfinpdflatex        \n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\n%----macros begin---------------------------------------------------------------\n\\usepackage{color}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\newtheorem{theorem}{Theorem}\n\n\\def\\conv{\\mbox{\\textrm{conv}\\,}}\n\\def\\aff{\\mbox{\\textrm{aff}\\,}}\n\\def\\N{\\mathbb{N}}\n\\def\\E{\\mathbb{E}}\n\\def\\R{\\mathbb{R}}\n\\def\\Z{\\mathbb{Z}}\n\\def\\tex{\\TeX}\n\\def\\latex{\\LaTeX}\n\\def\\v#1{{\\bf #1}}\n\\def\\p#1{{\\bf #1}}\n\\def\\T#1{{\\bf #1}}\n\n\\def\\vet#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\\def\\mat#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\n\\def\\lin{\\mbox{\\rm lin}\\,}\n\\def\\aff{\\mbox{\\rm aff}\\,}\n\\def\\pos{\\mbox{\\rm pos}\\,}\n\\def\\cone{\\mbox{\\rm cone}\\,}\n\\def\\conv{\\mbox{\\rm conv}\\,}\n\\newcommand{\\homog}[0]{\\mbox{\\rm homog}\\,}\n\\newcommand{\\relint}[0]{\\mbox{\\rm relint}\\,}\n\n%----macros end-----------------------------------------------------------------\n\n\\title{Boundary operators on LAR\n\\footnote{This document is part of the \\emph{Linear Algebraic Representation with CoChains} (LAR-CC) framework~\\cite{cclar-proj:2013:00}. \\today}\n}\n\\author{Alberto Paoluzzi}\n%\\date{}                            %Activatetodisplayagivendateornodate\n\n\\begin{document}\n\\maketitle\n\\nonstopmode\n\n\\begin{abstract}\nThe various versions of boundary operators on Linear Algebraic Representation of cellular complexes are  developed in this module, in order to maintain under focus their proper development, including the possible special cases.\n\\end{abstract}\n\n\\tableofcontents\n\\newpage\n\n\\section{Introduction}\n\nIn the current \\texttt{LarLib} implementation, we have to distinguish between between dimension-independent, dimension-dependent, oriented and non-oriented operators.\nTherefore a code refactoring of \\texttt{LarLib}---related to boundary/coboundary operators---started here, with the aim of both providing a precise mathematical definition within the LAR framework, and to simplify and generalise the implemented algorithms.\n\n\n\\section{Implementation}\n\nWe start this section by making a distinction between the (matrices of) boundary operators for the linear spaces $C_k$ of chains over the field $\\Z_2 = \\{0,1\\}$ and over the field $\\Z$ of integer numbers.\nWe call either \\emph{non-oriented} or \\emph{oriented} the corresponding boundary operators, respectively, since the matrix elements take values within the sets $\\{-1,0,+1\\}$ or $\\{0,1\\}$, correspondingly.\nOf course, the associated matrices of \\emph{coboundary} operators are their transpose matrices.\n\n\n\\subsection{Non-oriented operators}\n\nFor several computations, the knowledge of the matrices of non-oriented boundary operators is sufficient. \nTherefore we will use such tool wherever possible, since its computation is much faster in term of computing time. \n\nIn the following we provide be binary operator matrices provided by two implementations,\nrespectively named \\texttt{boundary} and \\texttt{larUnsignedBoundary2}. The first one works correctly only with convex cells; the second one works also with non-convex but path-connected cells.\n\n\n\\subsubsection{Dimension-independence}\n\nAs we show in the following, in order to compute the non-oriented boundary operator $\\partial_d$, it it sufficient to have knowledge of the $M_d$ and $M_{d-1}$ characteristic matrices of $d$-cells and their $(d-1)$-facets, at least in the case of cellular complexes with convex cells. Conversely, for more general non-convex but simply-connected cells, also the $M_{d-2}$ matrix is needed.\n\n\\paragraph{Convex-cells}\n\nThe algorithm used is pretty easy to present. The compressed characteristic matrices of $d$-cells and $(d-1)$-cells, denoted as \\texttt{cells} and \\texttt{facets}, respectively, are first put in \\texttt{csr} format as \\texttt{csrCV} and \\texttt{csrFV}. Then the incidence matrix \\texttt{csrFC} in compressed sparse row format is computed by matrix product of the compressed characteristic matrices. \n\nThe element $(i,j)$ of this matrix provides the number of vertices in the intersection of \\emph{facet} $i$ and \\emph{cell} $j$, whereas the number of non-zero elements in each \\texttt{csrFV} \\emph{row} gives the number of vertices of the facet represented by the row, and is stored in \\texttt{facetLengths}. \n\nThe \\texttt{boundary} function---to be used only with dimension-independent LAR convex cells---is written efficiently in the following script, by using only the standard functions and attributes of the \\texttt{scipy.sparse} module.\n\nThe variable \\texttt{facetCoboundary} stores in a list, for every facet (\\texttt{for h in range(m)})\nthe list of cells in its \\emph{coboundary}, to be stored in the output \\texttt{csr\\_matrix} boundary matrix as column indices of elements with non-zero (i.e.~$1$) value.\n\nNotice that both the computation of \\texttt{facetCoboundary} contents, and the output of the compressed boundary matrix, are performed in the most efficient way---according to the internal design of the scipy's \\texttt{csr} sparse data structure.\n\n%-------------------------------------------------------------------------------\n@D convex-cells boundary operator\n@{\"\"\" convex-cells boundary operator --- best implementation \"\"\"\ndef larBoundary(cells,facets):\n    lenV = max(max(CAT(cells)),max(CAT(facets)))+1\n    csrCV = csrCreate(cells,lenV)\n    csrFV = csrCreate(facets,lenV)\n    csrFC = csrFV * csrCV.T\n    facetLengths = [csrFacet.getnnz() for csrFacet in csrFV]\n    m,n = csrFC.shape\n    facetCoboundary = [[csrFC.indices[csrFC.indptr[h]+k] \n        for k,v in enumerate(csrFC.data[csrFC.indptr[h]:csrFC.indptr[h+1]]) \n            if v==facetLengths[h]] for h in range(m)]\n    indptr = [0]+list(cumsum(AA(len)(facetCoboundary)))\n    indices = CAT(facetCoboundary)\n    data = [1]*len(indices)\n    return csr_matrix((data,indices,indptr),shape=(m,n),dtype='b')\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Non-convex LAR cells}\n\nA more general \\texttt{larUnsignedBoundary2} operator is given in the following, aiming at compute the boundary matrix for general non-convex cellular decompositions, including \\emph{multiply connected} LAR models.\nNotice that in this case an input triple made by \\texttt{CV}, \\texttt{FV}, and \\texttt{EV} is needed,\nwhere---more in general embedded in $\\mathbf{E}^d$---they stand for the (binary compressed) characteristic matrices $M_d$, $M_{d-1}$, and $M_{d-2}$.\n\n\\paragraph{Boundary operator from 3-chains to 2-chains}\n\n%-------------------------------------------------------------------------------\n@D path-connected-cells boundary operator\n@{\"\"\" path-connected-cells boundary operator \"\"\"\ndef larUnsignedBoundary2(CV,FV,EV):\n    out = larBoundary(CV,FV)\n    def csrRowSum(h): \n        return sum(out.data[out.indptr[h]:out.indptr[h+1]])    \n    unreliable = [h for h in range(len(FV)) if csrRowSum(h) > 2]\n    if unreliable != []:\n        csrBBMat = larBoundary(FV,EV) * larBoundary(CV,FV)\n        lenV = max(max(CAT(CV)),max(CAT(FV)),max(CAT(EV)))+1\n        FE = larcc.crossRelation0(lenV,FV,EV)\n        out = csrBoundaryFilter2(unreliable,out,csrBBMat,CV,FE)\n    return out\n\ndef boundary3(CV,FV,EV):\n    out = larUnsignedBoundary2(CV,FV,EV)\n    lenV = max(max(CAT(CV)),max(CAT(FV)),max(CAT(EV)))+1\n    VV = AA(LIST)(range(lenV))\n    csrBBMat = scipy.sparse.csc_matrix(larBoundary(FV,EV) * larUnsignedBoundary2(CV,FV,EV))\n    def csrColCheck(h): \n        return any([val for val in csrBBMat.data[csrBBMat.indptr[h]:csrBBMat.indptr[h+1]] if val>2])    \n    unreliable = [h for h in range(len(CV)) if csrColCheck(h)]\n    if unreliable != []:\n        FE = larcc.crossRelation0(lenV,FV,EV)\n        out = csrBoundaryFilter3(unreliable,out,csrBBMat,CV,FE)\n    return out\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Boundary operator from 2-chains to 1-chains}\n\nFirst the \\texttt{boundary} operator for the convex case is computed within the \\texttt{out} variable of \\texttt{csr\\_matrix} type. Then every \\texttt{out} row (i.e.~every $(d-1)$-facet of the $d$-complex) is tested for \\emph{reliability}, since every $(d-1)$-face can be shared by \\emph{at most two} $d$-cells in a $d$-complex . When this condition is not satisfied, deeper tests are needed to understand what row elements must be forced to value 1, since the $(d-1)$-face itself is a subset, but not actually a facet, of the corresponding $d$-cell. \n\nIn presence of some ``unreliable'' facets, the matrix \\texttt{csrBBMat} of the operator $\\partial_{d-1}\\circ\\partial_d$ and the relation \\texttt{FE} between faces of dimensions $d-1$ and $d-2$ are computed. Now, let us notice that the columns of \\texttt{csrBBMat} report the number of incidences of the $d-2$ faces (as belonging to $(d-1)$-facets embedded on the boundary) and $d$-cells (that are associated to such matrix columns). Hence, in a regular (convex) $d$-complex, such numbers are always even, and in $\\Z_2$ arithmetic are reduced to zero, in order to satisfy the fundaments equation $\\partial\\partial=0$. \n\nConversely, with non-convex LAR cells, some incidence numbers may get odd values, due to the non-strict coincidence between cell facets and vertex subsets.\nTherefore, for ``unreliable'' $h$ rows (facets) the \\texttt{csrBBMat} columns tracked by ones in $[\\partial_d]$ are checked, looking for elements of $(h,k)$ indices with value greater that 2.\n\n%-------------------------------------------------------------------------------\n@D path-connected-cells boundary operator\n@{\"\"\" path-connected-cells boundary operator \"\"\"\nimport larlib\nimport larcc\nfrom larcc import *\n\ndef csrBoundaryFilter2(unreliable,out,csrBBMat,cells,FE):\n    for row in unreliable:\n        for j in range(len(cells)):\n            if out[row,j] == 1:\n                cooCE = csrBBMat.T[j].tocoo()\n                flawedCells = [cooCE.col[k] for k,datum in enumerate(cooCE.data)\n                    if datum>2]\n                if all([facet in flawedCells  for facet in FE[row]]):\n                    out[row,j]=0\n    return out\n\ndef csrBoundaryFilter3(unreliable,out,csrBBMat,cells,FE):\n    for col in unreliable:\n        cooCE = csrBBMat.T[col].tocoo()\n        flawedCells = [cooCE.col[k] for k,datum in enumerate(cooCE.data)\n                    if datum>2]\n        for j in range(out.shape[0]):\n            if out[j,col] == 1:\n                if all([facet in flawedCells  for facet in FE[j]]):\n                    out[j,col]=0\n    return out\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-02} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-03} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-04} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-05} \n   \\caption{Non-convex LAR 2-complex with (two) 1-cells that are subsets of 2-cells without being their facets. Correctly disentangled by the \\texttt{larUnsignedBoundary2()} function: (a) Indexing of 0-, 1-, and 2-cells; (b) exploded 2-cells; (c) triangulated and exploded 2-cells; (d) boundary of the 2-chain \\texttt{[1,1,1,1,1,0]}.}\n   \\label{fig:example}\n\\end{figure}\n\n\n%-------------------------------------------------------------------------------\n@D From cells and facets to boundary cells\n@{def totalChain(cells):\n    return csr_matrix(len(cells)*[[1]])\n\ndef boundaryCells(cells,facets):\n    csrBoundaryMat = larBoundary(cells,facets)\n    csrChain = csr_matrix(totalChain(cells))\n    csrBoundaryChain = csrBoundaryMat * csrChain\n    out = [k for k,val in enumerate(csrBoundaryChain.data.tolist()) if val == 1]\n    return out\n\ndef boundary2Cells(cells,facets,faces):\n    csrBoundaryMat = larUnsignedBoundary2(cells,facets,faces)\n    csrChain = csr_matrix(totalChain(cells))\n    csrBoundaryChain = csrBoundaryMat * csrChain\n    out = [k for k,val in enumerate(csrBoundaryChain.data.tolist()) if val == 1]\n    return out\n\ndef boundary3Cells(cells,facets,faces):\n    csrBoundaryMat = boundary3(cells,facets,faces)\n    csrChain = csr_matrix(totalChain(cells))\n    csrBoundaryChain = csrBoundaryMat * csrChain\n    out = [k for k,val in enumerate(csrBoundaryChain.data.tolist()) if val == 1]\n    return out\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Correctness proof}\n\nOur goal is to get a constructive and, of course, correct representation of the matrix $[\\partial_3]$ starting only from $M_1$, $M_2$, and $M_3$.\n\nWe have sufficient evidence here to support the correctness of our identification of the matrices of boundary operators as discussed in the previous section. Remember that $M_1$, $M_2$, and $M_3$ are the characteristic matrices of 1-cells, 2-cells and 3-cells as subsets of vertices, and that $C_0, C_1, C_2, C_3$ are the linear spaces of 0-, 1-, 2-, and 3-chains, with coefficients in the field $\\Z_2=\\{0,1\\}$.\n\nIn the following we give a dimension-independent proof, even our implementation is currently restricted to $d\\in\\{1,2,3\\}$.\n\n\\paragraph{Preamble}\nIt is well known that a linear transformation $T: V\\to W$ between two linear spaces, with fixed bases  of dimension $n$ and $m$ respectively, is represented uniquely by a matrix $A\\in \\R^{m\\times n}$, that by columns contains the coordinate representations in $W$ of the basis vectors of $V$. \n\n\n\\begin{theorem}\nConsider the linear transformation $\\partial_d: C_d \\to C_{d-1}$. Having fixed the bases, made by singleton cells in $C_d$ and $C_{d-1}$, the transformation $\\partial_d$ can be represented as a matrix product ${c} \\mapsto [\\partial_d]\\, {c}$, where ${c}\\in C_d$ is the coordinate representation of a d-chain, and $[\\partial_d]$ is the $m\\times n$ binary matrix having \\emph{by columns} the coordinate representation in $C_{d-1}$ of the boundary $(d-1)$-chains of cells in $C_{d}$.\n\\end{theorem}\n\n\\begin{proof}\nThe computation of the boundary operator matrix $A_d = [\\partial_d] \\in\\Z_2^{m\\times n}$, where $m$ and $n$ are the dimensions of the linear spaces $C_d$ and $C_{d-1}$, respectively, is made in two steps, in the general case.\n\n\\paragraph{First step} \nConsider the characteristic matrices $M_d\\in\\Z_2^{m\\times q}$ and $M_{d-1}\\in\\Z_2^{n\\times q}$ having as rows the images of characteristic functions of bases elements as subsets of vertices, where $q$ is the number of vertices.\n\nThen consider the product matrix $M=M_{d-1}M_{d}^t=(m_{ij})$, with values in the set $\\N$ of non-negative integers. Clearly $m_{ij}$ will coincide with the number of vertices shared by cells $c_i\\in C_{d-1}$ and $c_j\\in C_d$, i.e. with the cardinality of their intersection as discrete sets of vertices. The predicate \n\\begin{equation}\nm_{ij} \\equiv |c_i|\n\\label{eq:intersection}\n\\end{equation}\nis a \\emph{necessary} condition for $c_i$ to be a \\emph{facet} of $c_j$. Using the Iverson bracket notation, where $[P]$ returns either 1 or 0 depending on the truth of predicate $P$, we can  assign (to) the $(i,j)$ element of our (tentative) boundary matrix the corresponding value:\n\\begin{equation}\nA_d(i,j) := [m_{ij} \\equiv |c_i|], \\qquad 1\\leq i\\leq m,\\, 1\\leq j\\leq n.\n\\label{eq:iverson}\n\\end{equation}\nUnfortunately, condition~(\\ref{eq:intersection}) is also \\emph{sufficient} for $c_i$ being a facet of $c_j$ only when both are convex cells. In other words, Equation~(\\ref{eq:iverson}) with $A_d=[\\partial_d]$ holds in full generality if and only if the cellular complex under consideration is made only by convex cells. With more general cells, the column $j$ of the $\\partial_d$ matrix contains the coordinate representation in $C_{d-1}$ of a possibly proper \\emph{superset}  of $\\partial_d(c_j)$.\n\n\\paragraph{Second step} \nIn order to reduce the columns of the approximate boundary matrix $A_d$ to their exact value in $\\Z_2^m$, with $m=\\dim C_{d-1}$, we may compute an (approximate) matrix $B\\in\\N^{p\\times n}$ of the operator $\\partial_{d-1}\\circ\\partial_d: C_d \\to C_{d-2}$, with $p=\\dim C_{d-2}$, by using the approximate representation $A_d$ of the matrix $[\\partial_d]$. Let us remark that the exact value of the latter is yet unknown at this point.\n\nAccording to what asserted in the preamble, every column of this matrix should contain the coordinate representation (in $C_{d-2}$) of the boundary of the boundary of a basis element in $C_d$, i.e.~of a singleton $d$-chain.\n\nTherefore, we will enforce the validity of the constraints $\\partial\\partial=0$, by checking\nthe values of columns in the product matrix $B_d = A_{d-1} A_d \\in \\N^{p\\times n}$. In particular, ~every unit vector $e_j$, \\emph{i.e.},~the coordinate representation of a singleton chain $c_j\\in C_d$, should be mapped by $B_d$ to the zero vector in $\\Z_2^p$:\n\\begin{equation}\ne_j \\mapsto B_d\\, e_j = 0^{p} \\in \\Z_2^p, \\qquad c_j\\in C_d.\n\\label{eq:boundaryofboundary}\n\\end{equation}\n\nNow, let consider the cells of LAR both as subsets of vertices and as cells of a cellular complex.\nActually, in the LAR general case, there may be some $(d-1)$-facets of some $d$-cell that are subsets of other $d$-cells of which they are not faces. It is not difficult to provide some examples of this fact (see Figure~\\ref{fig:}).\n\nWhen considering each column of $B$ as the coordinate representation of the boundary $(d-2)$-chain of a $d$-cell, and noting that every $d$-cell must be \\emph{orientable}, and hence separating an interior space from an exterior space, we conclude that the number of occurrencies of each $(d-2)$-cell in a $B$ column must be necessarily even. In particular, it must be either equal to 2 if the column (the $d$-cell) is locally manifold, or equal to some even number $>2$ if the $d$-cell is locally non-manifold. But \\emph{odd incidencies} of $(d-2)$-cells along the $d$-cell boundary \\emph{are not allowed}. \n\nTherefore, for each column $B_j$ ($1\\leq j\\leq n$) we look for the subset of rows (i.e.~boundary $(d-2)$-faces of $c_j$) of odd value. If there are none, the column $A_j$, associated to $c_j$, is a correct representation of $[\\partial_d]_j$. Otherways, we must look for the subsets of $(d-1)$-cells \\emph{incorrectly} considered facets of $c_j$.\n\nLet us call $R_j$ the subset of row indices corresponding to odd values in column $B_j$, and consider the subset of $A_j$ rows with value $a_{ij}=1$, i.e.~the superset $S_j$ of $(d-1)$-cells including the boundary $(d-1)$-chain of $c_j$. The redundant vertex subsets that are not boundary facets of $c_j$  are easily discovered by looking at the $(d-2)$-boundary of each $s\\in S_j$.\n\nIn particular, the $(d-1)$-cell $s\\in S_j$ is \\emph{redundant} or \\emph{extraneous} with respect to the $c_j$ boundary if and only if $\\partial_{d-1}(s) \\subseteq R_j$, because that property has certainly introduced a spurious increment for each $(d-2)$-facet in the count of incidences of boundary facets.\n\nAt this point, we can finally compute the actual boundary matrix $\\partial_d$ for a \\emph{general} LAR cellular complex, using again the Iverson brackets:\n\\begin{align*}\n[\\partial_d]_{ij} = [(a_{ij}=1) \\wedge ((R_j=\\emptyset) \\vee (R_j \\not\\supseteq \\partial_{d-1}(s_i)))]\\qquad 1\\leq i\\leq m,\\, 1\\leq j\\leq n\n\\end{align*}\nIn words it sounds that \\emph{the element $(i,j)$ of the boundary matrix $[\\partial]_d$ equals that of the ``approximate'' matrix $A_d$ if and only if either the redundant set $R_j$ is empty, or if it does not contain the $(d-1)$-boundary chain of the $i$-th $(d-1)$-cell.}\n\nJust remember that the redundant set $R_j$ contains the $(d-2)$-faces with odd incidencies on $c_j\\in C_d$, computed via the ``approximate'' matrix $B_d = A_{d-1}\\circ A_d$.\n\n\\end{proof}  \n\n\n\\subsection{Oriented operators}\n\n\\subsubsection{Oriented simplicial complexes}\n\n\\subsubsection{Oriented LAR complexes}\n\n\n\n\n\n\n\\section{From relations to operators}\n%===============================================================================\n\nThe LAR approach to topology, implemented in the \\texttt{LarLib} modules, allows the user to consider the topological relations of incidence and adjacency between faces of a cellular complex as \\emph{linear operators} between chains of cells of various dimensions. \n\nThe previous approach was to consider the incidence and adjaceny as set-theoretical relations, to be solved by using typical database tools. Conversely, according to the novel IT evolution towards big data and cloud-based storage, even for geometrical data, \\texttt{LarLib}  takes advantage of a conceptual framework based on linear-algebra and sparse matrices.\n\n\\subsection{Classification of operators} \n\nIn the standard solid modeling approach, mainly based on boundary representations, the standard topological operations concern the answers to queries, by reporting the subsets of boundary elements which are incident (different dimension) or adjacent (equal dimension) to assigned boundary elements. Boundary elements stand there for three type of boundary cells: aka \\emph{faces} $F$, \\emph{edges} $E$, and \\emph{vertices} $V$. Nine binary relations may be considered, that are summarized in Table~\\ref{tab:one}.\n\\begin{table}[htbp]\n\\caption{Binary topological relations between boundary elements in boundary representations of solid models}\n\\begin{center}\n\\begin{tabular}{|c|ccc|}\n\\hline \n  & F & E & V \\\\\n\\hline \nF & FF & FE & FV \\\\\nE & EF & EE & EV \\\\\nV & VF & VE & VV \\\\\n\\hline \n\\end{tabular}\n\\end{center}\n\\label{tab:one}\n\\end{table}%\n\nConversely, LAR  models are normally based on cellular 3-complexes, so using four sets of cells, namely \\emph{3-cells} $C$, \\emph{2-cells} $F$, \\emph{1-cells} $E$, and \\emph{0-cells} $V$. The resulting tables of topological relations, and the associated linear operators, are shown in Tables~\\ref{tab:two}a and \\ref{tab:two}b, respectively.\n\\begin{table}[htbp]\n\\caption{Binary topological relations between cells of LAR decompositions of  solid models and corresponding topological operators on $\\partial_\\circ$ chains.}\n\\vspace{3mm}\n\\begin{minipage}[c]{0.5\\linewidth}\\centering\n\\begin{tabular}{|c|cccc|}\n\\hline \n  & C & F & E & V \\\\\n\\hline \nC & CC & \\fbox{CF} & \\fbox{CE} & CV \\\\\nF & \\fbox{FC} & FF & \\fbox{FE} & FV \\\\\nE & \\fbox{EC} & \\fbox{EF} & EE & EV \\\\\nV & VC & VF & VE & VV \\\\\n\\hline \n\\end{tabular}\n\\end{minipage}\n\\begin{minipage}[c]{0.5\\linewidth}\\centering\n\\begin{tabular}{|c|cccc|}\n\\hline \n  & C & F & E & V \\\\\n\\hline \nC & $\\v{1}_C^\\top\\circ\\v{1}_C$ & {$\\partial_3$} & {$\\partial_2\\circ\\partial_3$} & $\\v{1}_C$ \\\\\nF & {$\\delta_2$} & $\\v{1}_F^\\top\\circ\\v{1}_F$ & {$\\partial_2$} & $\\v{1}_F$ \\\\\nE & {$\\delta_2\\circ\\delta_1$} & {$\\delta_1$} & $\\v{1}_E^\\top\\circ\\v{1}_E$ & $\\v{1}_E$ \\\\\nV & $\\v{1}_C^\\top$ & $\\v{1}_F^\\top$ & $\\v{1}_E^\\top$ & $\\v{1}_V$ \\\\\n\\hline \n\\end{tabular}\n\\end{minipage}\n\\label{tab:two}\n\\end{table}%\n\n\\subsection{Topological relations}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\n\n\\subsubsection{Adjacency relations}\n\n%-------------------------------------------------------------------------------\n@D kfaces-to-kfaces relation\n@{\"\"\" kfaces-to-kfaces relation \"\"\"\neeOp = larEdges2Edges(EV,VV)\nEE = [eeOp([k]) for k in range(len(EV))]\n\nffOp = larFaces2Faces(FV,EV)\nFF = [ffOp([k]) for k in range(len(FV))]\n\nccOp = larCells2Cells(CV,FV,EV)\nCC = [ccOp([k]) for k in range(len(CV))]\n\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Adjacency relations examples}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test09.py\n@{\"\"\" Adjacency relations examples \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/boundary/')\nfrom test07 import *\n\n@< kfaces-to-kfaces relation @>\nprint \"\\nCC =\",CC\nprint \"\\nFF =\",FF\nprint \"\\nEE =\",EE,\"\\n\"\n\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([1,0])\nVIEW(STRUCT(MKTRIANGLES((V,[FV[h] for h in FF[-1]],EV),color=True)))\nVIEW(STRUCT(MKPOLS((V,[EV[h] for h in EE[-1]]))+[COLOR(RED)(MKPOLS((V,[EV[-1]]))[0])]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsubsection{Incidence relations}\n\n%-------------------------------------------------------------------------------\n@D mfaces-to-nfaces relations\n@{\"\"\" mfaces-to-nfaces relations \"\"\"\nfcOp = larCells2Faces(CV,FV,EV)\nCF = [fcOp([k]) for k in range(len(CV))]\nFC = invertRelation(CF)\n\necOp = larCells2Edges(CV,FV,EV)\nCE = [ecOp([k]) for k in range(len(CV))]\nEC = invertRelation(CE)\n    \nefOp = larFaces2Edges(FV,EV)\nFE = [efOp([k]) for k in range(len(FV))]\nEF = invertRelation(FE)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Incidence relations examples}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test10.py\n@{\"\"\" Incidence relations examples \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/boundary/')\nfrom test08 import *\n\n@< mfaces-to-nfaces relations @>\nprint \"\\nFC =\",FC\nprint \"\\nEC =\",EC\nprint \"\\nEF =\",EF,\"\\n\"\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\n\\subsection{Querying}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe more important topological operations in a geometric system concern the answer to queries of the type: ``what is the $h$-chain whose cells are $(k-h)$-incident to a given $h$-chain''?\n\nAn efficient answer is given by the three higher-level functions in this section, respectively denoted as \\texttt{larCells2Faces}, \\texttt{larCells2Edges}, and \\texttt{larFaces2Edges}.\nTheir first application, over the two or three necessary (compressed) characteristic matrices, returns the \\texttt{csr\\_matrix} of the topological operator, that can be so cached by the calling code.\nThe second application, over the list of $h$-chain indices, returns the list of $k$-chain indices of the cells that share with them a $(k-h)$-face.\n\n\n\\subsubsection{Topological incidences}\n\n\n\\paragraph{Query from 3-chain to incident 2-chain}\n%-------------------------------------------------------------------------------\n@D Query from 3-chain to incident 2-chain\n@{\"\"\" Query from 3-chain to incident 2-chain \"\"\"\ndef larCells2Faces(CV,FV,EV):\n    csrFC = boundary3(CV,FV,EV)\n    def larCells2Faces0(chain):\n        chainCoords = csc_matrix((csrFC.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrFC * chainCoords\n        return out.tocoo().row.tolist()\n    return larCells2Faces0\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Query from 3-chain to incident 1-chain}\n%-------------------------------------------------------------------------------\n@D Query from 3-chain to incident 1-chain\n@{\"\"\" Query from 3-chain to incident 1-chain \"\"\"\ndef larCells2Edges(CV,FV,EV):\n    lenV = max(CAT(CV))+1\n    VV = AA(LIST)(range(lenV))\n    csrEC = larUnsignedBoundary2(FV,EV,VV) * boundary3(CV,FV,EV)\n    def larCells2Faces0(chain):\n        chainCoords = csc_matrix((csrEC.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrEC * chainCoords\n        return out.tocoo().row.tolist()\n    return larCells2Faces0\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Compute the signed 2-boundary matrix}\nCompute the signed 2-boundary matrix. The second definition extends the first one by considering LAR faces including holes. For this purpose the signed areas of all loops inside each lar face in FV are taken into account, and only the greates positive area and all the negative areas (exept the most negative one) are considered. \n%-------------------------------------------------------------------------------\n@D Compute the signed 2-boundary matrix\n@{\"\"\" Compute the signed 2-boundary matrix \"\"\"\nimport triangulation,integr\n    \ndef larSignedBoundary2(V,FV,EV):\n    efOp = larFaces2Edges(V,FV,EV)\n    FE = [efOp([k]) for k in range(len(FV))]\n    data,row,col = [],[],[]\n    for f in range(len(FE)):\n            \n        Vcycles,Ecycles = triangulation.makeCycles((V,[EV[e] for e in FE[f]]))\n        Ecycles = [[FE[f][e] for e in cycle] for cycle in Ecycles]\n        #areas = integr.signedSurfIntegration((V,Vcycles,EV),signed=True)\n        areas = integr.signedSurfIntegration((V, Vcycles, EV), False)\n        sortedAreas = sorted((area,k) for k,area in enumerate(areas))\n        innerLoops = [zip(Vcycles[k],Ecycles[k]) for area,k in sortedAreas[1:] if area<0]\n        outerLoop = [zip(Vcycles[sortedAreas[-1][1]],Ecycles[sortedAreas[-1][1]])]\n        orientedFaceLoops = CAT(outerLoop+innerLoops)\n        coefficients = [1 if v==EV[e][0] else -1 for v,e in orientedFaceLoops]\n\t\t\n        ecycle = [e for v,e in orientedFaceLoops]\n        data += coefficients\n        row += ecycle\n        col += [f]*len(ecycle)\n        #print f,len(data),len(row),len(col)\n    signedBoundary2 = coo_matrix((data,(row,col)), shape=(len(EV),len(FV)),dtype='b')\n    return csr_matrix(signedBoundary2)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Compute any signed 1-boundary chain}\nThe script below computes the signed boundary 1-cycle of any 2-chain in a 2-complex. \nThe script returns the pair of arrays \\texttt{orientations,boundaryCells}, providing the signs of 1-cells in the extracted 1-cycle and their edge indices, respectively.\n%-------------------------------------------------------------------------------\n@D Compute any signed 1-boundary chain\n@{\"\"\" Compute any signed 1-boundary chain \"\"\"\ndef larSignedBoundary2Cells(V,FV,EV):\n\tdef larSignedBoundary2Cells0(chain):\n\t\tboundaryMat = larSignedBoundary2(V,FV,EV)\n\t\tchainCoords = csc_matrix((len(FV), 1))\n\t\tfor cell in chain: chainCoords[cell,0] = 1\n\t\tboundaryCells = list((boundaryMat * chainCoords).tocoo().row)\n\t\torientations = list((boundaryMat * chainCoords).tocoo().data)\n\t\treturn orientations,boundaryCells\n\treturn larSignedBoundary2Cells0\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Testing the extraction of a boundary chain}\nAn example for testing the extraction of the boundary 1-cycle of a 2-chain $[f_1,f_2]$ is given below.\nThe images generated by the script are displayed in Figure~\\ref{fig:signedBoundary2}.\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test14.py\n@{\"\"\" Testing the extraction of a boundary chain \"\"\"\nfrom larlib import *\n\nlines = svg2lines(\"test/svg2lines/test.svg\")\nV,FV,EV,polygons = larFromLines(lines,True)\nVIEW(STRUCT(MKTRIANGLES((V,FV,EV),color=True)))\nsubmodel = mkSignedEdges((V,EV))\nVV = AA(LIST)(range(len(V)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.25))\n\norientations,boundaryCells = larSignedBoundary2Cells(V,FV,EV)([1,2])\norientedBoundaryCells = [EV[e] if sign==1 else REVERSE(EV[e]) \n\t\t\t\t\t\tfor sign,e in zip(orientations,boundaryCells)]\n\nVIEW(STRUCT(MKTRIANGLES((V,FV[1:3],EV),color=True)))\nVIEW(mkSignedEdges((V,orientedBoundaryCells)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.27\\linewidth,width=0.495\\linewidth]{images/larSignedBoundary2a} \n   \\includegraphics[height=0.27\\linewidth,width=0.495\\linewidth]{images/larSignedBoundary2b} \n   \n   \\includegraphics[height=0.27\\linewidth,width=0.495\\linewidth]{images/larSignedBoundary2c} \n   \\includegraphics[height=0.27\\linewidth,width=0.495\\linewidth]{images/larSignedBoundary2d} \n   \\caption{Example  of \\emph{signed} boundary operator: (a) 2-complex with non-compressible cells; (b) oriented 1-cells; (c) drawing of the 2-chain $[f_1,f_2]$; (d) oriented boundary 1-chain of 2-chain $[f_1,f_2]$.}\n   \\label{fig:signedBoundary2}\n\\end{figure}\n\n\n\\paragraph{Query from 2-chain to incident 1-chain}\n%-------------------------------------------------------------------------------\n@D Query from 2-chain to incident 1-chain\n@{\"\"\" Query from 2-chain to incident 1-chain \"\"\"\ndef larFaces2Edges(V,FV,EV):\n    VV = AA(LIST)(range(len(V)))\n    csrEF = larUnsignedBoundary2(FV,EV,VV)\n    def larCells2Faces0(chain):\n        chainCoords = csc_matrix((csrEF.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrEF * chainCoords\n        return out.tocoo().row.tolist()\n    return larCells2Faces0\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\subsubsection{Topological adjacencies}\n\n\\paragraph{kfaces-to-kfaces relations}\n%-------------------------------------------------------------------------------\n@D kfaces-to-kfaces relations\n@{\"\"\" kfaces-to-kfaces relations \"\"\"\n\ndef larCells2Cells(CV,FV,EV):\n    csrMat = boundary3(CV,FV,EV)\n    csrCC = csrMat.T * csrMat\n    def larCells2Cells0(chain):\n        chainCoords = csc_matrix((csrCC.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrCC * chainCoords\n        return out.tocoo().row.tolist()\n    return larCells2Cells0\n\ndef larFaces2Faces(FV,EV):\n    lenV = max(CAT(FV)) + 1\n    VV = AA(LIST)(range(lenV))\n    csrMat = larUnsignedBoundary2(FV,EV,VV)\n    csrFF = csrMat.T * csrMat\n    def larFaces2Faces0(chain):\n        chainCoords = csc_matrix((csrFF.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrFF * chainCoords\n        return out.tocoo().row.tolist()\n    return larFaces2Faces0\n\ndef larEdges2Edges(EV,VV):\n    lenV = len(VV)\n    csrMat = larBoundary(EV,VV)\n    csrEE = csrMat.T * csrMat\n    def larFaces2Faces0(chain):\n        chainCoords = csc_matrix((csrEE.shape[1],1),dtype='b')\n        for k in chain: chainCoords[k,0] = 1\n        out = csrEE * chainCoords\n        return out.tocoo().row.tolist()\n    return larFaces2Faces0\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\subsection{Oriented operators}\n\n\\subsubsection{Signed 2-boundary}\n\n\n\n\\paragraph{Testing signed 2-boundary}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test11.py\n@{\"\"\" Testing signed 2-boundary \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/boundary/')\nfrom test10 import *\n\n@< mfaces-to-nfaces relations @>\n\nsignedBoundary2 = larSignedBoundary2(FV,EV)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Testing signed 2-boundary}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test13.py\n@{\"\"\" Testing signed 2-boundary \"\"\"\nfrom larlib import *\n\nlines = svg2lines(\"test/svg2lines/test.svg\")\nV,FV,EV,polygons = larFromLines(lines,True)\nVIEW(STRUCT(MKTRIANGLES((V,FV,EV),color=True)))\nsubmodel = mkSignedEdges((V,EV))\nVV = AA(LIST)(range(len(V)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.25))\n\nB = larSignedBoundary2(V,FV,EV)\nfor k in range(B.shape[0]):\n    print k,B.todense()[k]\n\nVIEW(STRUCT(MKTRIANGLES((V,FV[1:3],EV),color=True)))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Example 2-bondary matrix}\nThe example in file \\texttt{test13.py}, corresponding to Figure~\\ref{fig:signedBoundary2} produces the following two-dimensional LAR model:\n{\\scriptsize\n\\begin{verbatim}\nV = [[0.8627, 0.263], [0.7223, 0.263], [0.7223, 0.1857], [0.8627, 0.1857], [0.5422, 0.0489], [0.3613, \n0.0238], [0.0, 0.2296], [0.6044, 0.4933], [1.0, 0.382], [0.1896, 0.0], [0.5037, 0.1896], [0.9614, \n0.1522], [0.9207, 0.318], [0.7457, 0.3241], [0.7457, 0.3942], [0.6583, 0.3942], [0.6583, 0.3241], \n[0.3718, 0.157], [0.1704, 0.1259], [0.3541, 0.3141], [0.1748, 0.2296]] \nEV = [[0, 1], [2, 1], [3, 2], [0, 3], [4, 5], [6, 7], [7, 8], [9, 10], [4, 10], [11, 12], [6, 9], \n[4, 11], [12, 8], [9, 5], [4, 7], [13, 14], [15, 14], [16, 15], [13, 16], [17, 18], [17, 19], \n[20, 18], [19, 20]]\n\\end{verbatim}}\nand the following boundary operator matrix:\n\\[\n\\partial_2 =\n\\mat{ \n 0 & 0 &-1 & 0 & 1 & 0 \\\\\n 0 & 0 & 1 & 0 &-1 & 0 \\\\\n 0 & 0 & 1 & 0 &-1 & 0 \\\\\n 0 & 0 & 1 & 0 &-1 & 0 \\\\\n-1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 &-1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 &-1 & 0 & 0 & 0 \\\\\n-1 & 1 & 0 & 0 & 0 & 0 \\\\\n 1 &-1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 &-1 & 0 & 0 & 0 \\\\\n 0 & 0 &-1 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 &-1 & 0 & 0 \\\\\n 0 & 0 & 1 &-1 & 0 & 0 \\\\\n 0 & 0 & 1 &-1 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 &-1 \\\\\n 0 &-1 & 0 & 0 & 0 & 1 \\\\\n 0 &-1 & 0 & 0 & 0 & 1 \\\\\n 0 &-1 & 0 & 0 & 0 & 1 \\\\\n }\n\\]\n\n\n\\paragraph{Transformation from chain coordinates to explicit chain data}\n%-------------------------------------------------------------------------------\n@D Transformation from chain coordinates to explicit chain data\n@{\"\"\" Transformation from chain coordinates to explicit chain data \"\"\"\ndef coords2chain(chainCoords):\n    coo = coo_matrix(chainCoords)\n    return [(e,val) for e,val in zip(coo.row,coo.data)]\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Offset of 2-faces of a 2D complex}\nIn some applications it is necessary to compute the offset of faces of a 2D complex. This may happen for example in architectural applications, where the walls of building layout must be computed from its wire-frame design. Another important application aims to make more numerically robust the point-in-polygon containment test. In this case the test is driven against a slightly ``grown'' version of the polygon.\nThe problem solved by the \\texttt{larOffset2D (model)} function given below is to \"enlarge\" each 2-face of a 2-complex in 2D of a (generally small) constant offset.  \nFor this purpose, the \\texttt{larOffset2D} function operates as follows:\n\n\\begin{enumerate}\n\\item translate every 1-face towards its cobounday exterior (see Figure 1);\n\\item compute the parametric line equation for the translated pairs of edge vertices;\n\\item compute the intersection points between of adjacent pairs of such lines:\n    \\begin{enumerate}\n    \\item solving for both parameters;\n    \\item using the computed parameter value to get the intersection point.\n    \\end{enumerate}\n\\end{enumerate}\n\t\n\\paragraph{Offset of 2-faces of a 2D complex}\nThe coding below is using the Cramer's formula for the the solution of the intersection of two 2D lines via their parametric equation, according to page 50-51 of the formulation given in \\href{http://www.ti.inf.ethz.ch/ew/lehre/CG09/materials/v9.pdf}{http://www.ti.inf.ethz.ch/ew/lehre/CG09/materials/v9.pdf}.\nThe implementation is  simple and very general---e.g.˜it does not require conditional constructs---so that it may be useful to avoid, for future GPGPU implementations.\n%-------------------------------------------------------------------------------\n@D Offset of 2-faces of a 2D complex\n@{\"\"\" Offset of 2-faces of a 2D complex \"\"\"\nfrom scipy.linalg.basic import det\n\ndef larOffset2D (model,offset=0.001):\n    V,FV,EV = model\n    newVertices,lines = [],[]\n\n    for f in range(len(FV)):\n        # pair of arrays (signs, edges) of f face\n        orientations,boundaryCells = larSignedBoundary2Cells(V,FV,EV)([f])\n        # array of pairs (sign, edge) of f face\n        edges = zip(orientations,boundaryCells)\n        \n        # array of pairs (begin_vertex, end_vertex) of oriented edges of f face\n        orientedEdges = [tuple(EV[e]) if sign==1 else tuple(REVERSE(EV[e])) \n            for sign,e in edges]\n        # array of unit tangentVectors of  f face\n        tangentVectors = [UNITVECT(VECTDIFF([ V[edge[1]],V[edge[0]] ])) \n            for edge in orientedEdges]\n        # array of unit normalVectors of   f face\n        normalVectors = [ SCALARVECTPROD([ offset,[vect[1],-vect[0]] ]) \n            for vect in tangentVectors]\n        # array of pairs of moved vertices  of oriented edges of f face\n        movedEdgesOffLine = [[VECTSUM([V[v],n]) for v in orientedEdges[k]] \n            for k,n in enumerate(normalVectors)]\n        # successor map ( succ[first] := second ) for verts of oriented edges of $f$ \n        succ = dict(orientedEdges)\n        # dictionary of numerals of oriented edges of $f$ (key = pair of vertices)\n        edgeDict = dict([(edge,k) for k,edge in enumerate(orientedEdges)])\n        # array of pairs of numerals of intersecting edges\n        intersections = [[ edgeDict[(u,v)], edgeDict[(v,succ[v])] ] \n            for k,(u,v) in enumerate(orientedEdges)]\n        # coupling of data points of intersecting pairs\n        linepairs = [[movedEdgesOffLine[l1],movedEdgesOffLine[l2]] \n            for l1,l2 in intersections]\n        # prepare data for line pairs\n        linedata = [[ax,ay,bx,by,cx,cy,dx,dy] \n            for [[(ax,ay),(bx,by)],[(cx,cy),(dx,dy)]] in linepairs]\n        # assemble intersection determinants\n        determinants = [ det(mat([[ax-bx,dx-cx], [ay-by,dy-cy]])) \n            for [ax,ay,bx,by,cx,cy,dx,dy] in linedata]\n        # parameter pairs by Cramer's rule (for oriented edges of f face)\n        alpha = [det(mat([[dx-bx,dx-cx],[dy-by,dy-cy]]))/D  if abs(D)>.00001 else 0 \n            for D,(ax,ay,bx,by,cx,cy,dx,dy) in zip(determinants,linedata)]\n        # intersection points\n        newvert = [ (a*mat(p1)+(1-a)*mat(p2)).tolist()[0] \n            for a,[[p1,p2],[q1,q2]] in zip(alpha,linepairs)]\n        newedges = [[newvert[u],newvert[v]] for u,v in intersections]\n\n        newVertices += [newvert]\n        lines += newedges  \n    return lines\n\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Example of Offset generation for the 2-faces of a 2D complex}\nThe result of execution of the test program below is given in Figure˜\\ref{fig:offset}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test15.py\n@{\"\"\" Example of Offset generation for the 2-faces of a 2D complex \"\"\"\nfrom larlib import *\nlines = svg2lines(\"test/svg2lines/test.svg\")\nV,FV,EV,polygons = larFromLines(lines,True)\nVIEW(STRUCT(MKTRIANGLES((V,FV,EV),color=True)))\n\nsubmodel = mkSignedEdges((V,EV))\nVV = AA(LIST)(range(len(V)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.25))\n\nnewEdges = larOffset2D((V,FV,EV),offset=0.01)\nVIEW(STRUCT(MKPOLS((V,EV)) + AA(COLOR(YELLOW))(AA(POLYLINE)(newEdges))))\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.49\\linewidth]{images/offset1} \n   \\includegraphics[width=0.49\\linewidth]{images/offset2} \n   \\caption{(a) the input 2-complex with general LAR cells; (b) drawing of the offset edges (in yellow) generated by \\texttt{larOffset2D}.}\n   \\label{fig:offset}\n\\end{figure}\n\n\\subsection{Extraction of 3-cells from a 2-skeleton embedded in 3D}\nNeed to characterize the two vertices of zero edge as \"last\" of previous edge in the chain,\nand \"first\" of following edge in the chain. Therefore the zero edge is oriented as from \"last\" to \"first\" and consequently, is \"positive\" iff  \"first\" $>$ \"last\".\n\nIt is sufficient to characterize the \"first\" vertex of the edge following the zero edge. This one is the \"last\" of zero edge. the other vertex of zero edge is its \"first\". Zero edge is \"positive\" iff last(zero) $>$ first(zero).\n\n\n\\paragraph{Choose the next face on ordered coboundary of edge}\nChoose the \"next\" face $g_i$  on \"ordered\" coboundary of edge\n\n\n%-------------------------------------------------------------------------------\n@D Choose the next face on ordered coboundary of edge\n@{\"\"\" Choose the next face on ordered coboundary of edge \"\"\"\ndef adjFace(boundaryOperator,EV,EF_angle,faceChainOrientation):\n    def adjFace0(edge,orientation):\n        if orientation > 0:  edgeLoop = REVERSE(EF_angle[edge])\n        elif orientation < 0:  edgeLoop = EF_angle[edge]\n        edgeLoop = edgeLoop + [edgeLoop[0]]  # all positive indices\n        \n        candidates = set([f for f,_ in faceChainOrientation]).intersection(edgeLoop)\n        if candidates != set([]):\n            pivotFace = candidates.pop()\n            if pivotFace in edgeLoop:\n                pivotIndex = edgeLoop.index(pivotFace)\n            else:\n                pivotIndex = edgeLoop.index(-pivotFace)\n            adjacentFace = edgeLoop[pivotIndex+1]\n        else: return None\n        \n        theSign = boundaryOperator[edge,adjacentFace]\n        return adjacentFace, -(theSign*orientation)\n    return adjFace0\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Choose the start facet in extracting the facet representation of a cell}\n%-------------------------------------------------------------------------------\n@D Choose the start facet in extracting the facet representation of a cell\n@{\"\"\" Choose the start facet in extracting the facet representation of a cell \"\"\"\n\ndef chooseStartFace(FV,faceCounter):\n    if faceCounter[0,0]==0: return (0,1)\n    for f in range(len(FV)):\n        if faceCounter[f,0]==1 and faceCounter[f,1]==0: return (f,-1)\n        elif faceCounter[f,0]==0 and faceCounter[f,1]==1: return (f,1)\n    for f in range(len(FV)):\n        if faceCounter[f,0]==0 and faceCounter[f,1]==0: return (f,1)\n    if sum(array(faceCounter))==2*len(FV): return (-1,999)\n    else: print \"ERROR: chooseStartFace\"\n\ndef chooseStartFace(FV,faceCounter):\n    for f in range(len(FV)):\n        if faceCounter[f,0]==1 and faceCounter[f,1]==0: return (f,-1)\n        elif faceCounter[f,0]==0 and faceCounter[f,1]==1: return (f,1)\n    for f in range(len(FV)):\n        if faceCounter[f,0]==0 and faceCounter[f,1]==0: return (f,1)\n    if sum(array(faceCounter))==2*len(FV): return (-1,999)\n    else: return (0,1)\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Extract the signed representation of a basis element}\n%-------------------------------------------------------------------------------\n@D Extract the signed representation of a basis element\n@{\"\"\" Extract the signed representation of a basis element \"\"\"\ndef signedBasis(boundaryOperator):\n    facesByEdges = csc_matrix(boundaryOperator)\n    m,n = facesByEdges.shape\n    edges,signs = [],[]\n    for i in range(n):\n        edges += [facesByEdges.indices[facesByEdges.indptr[\n                              i]:facesByEdges.indptr[i+1]].tolist()]\n        signs += [facesByEdges.data[facesByEdges.indptr[\n                              i]:facesByEdges.indptr[i+1]].tolist()]\n    return zip(edges,signs)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Algoritm} \nThe algorithm to compute the signed boundary matrix of a 3-complex is given below in pseudocode.\n\n%-------------------------------------------------------------------------------\n\\begin{algorithm}\n\\caption{Compute the signed $\\partial_3$ matrix of a 3-complex, from 2-skeleton}\n\\begin{algorithmic}[1]\n\\Function {larSignedBoundary3}{LarModel}\n    \\State {$V,FV,EV \\leftarrow {}$LarModel}\n    \\State {$[\\partial_2]\\equiv[\\delta_1]^t  \\leftarrow {}$\\textsc{larSignedBoundary2}(LarModel)}\n    \\State {$sort: EV\\to FV\\to \\R^*: e\\mapsto \\delta_1(e)$ (ordered loops of signed 2-faces)}\n    \\State {$[\\partial_3]\\equiv[\\delta_2]^t \\leftarrow []$  (boundary 2-faces of 3-cells by row)}\n    \\State {$S = {}$indices\\ of\\ 2-faces}\n    \\While {$S \\not= \\emptyset$ (set of non-traversed 2-faces) } \n        \\State {$f \\leftarrow \\textsc{choose}(S)$ (first 2-face, reversing previous sign)}\n        \\State $F \\leftarrow \\{f\\}$ (singleton 2-chain)\n        \\While {$\\partial_2(F) \\not= \\emptyset$} ($F$ non closed)\n            \\State $E \\leftarrow \\partial_2(F) $ (1-cycle of signed edges)\n            \\While {$E \\not= \\emptyset$}\n                \\For {each $e \\in E$}\n                    \\State {$f_i \\leftarrow next(f)(sort(\\delta_1(e)))$}\n                    \\State {$F \\leftarrow F \\cup \\{f_i\\}$}\n                    \\State {$S \\leftarrow S - \\{f_i\\}$ (non-traversed 2-faces)}\n                    \\State {$E \\leftarrow E - \\{e\\}$}\n                \\EndFor\n                \\State {$E \\leftarrow \\partial_2(F) $ (new oriented 1-cycle)}\n            \\EndWhile\n        \\EndWhile\n        \\State {$[\\partial_3] \\leftarrow [\\partial_3]+[F]$ (put F in new $[\\partial_3]$ column, i.e.~new $[\\delta_2]$ row)}\n    \\EndWhile \n    \\State \\Return {$[\\partial_3]$ (operator's matrix)}\n    \\EndFunction \n\\end{algorithmic}\n\\end{algorithm}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Return the signed boundary matrix of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Return the signed boundary matrix of a 3-complex\n@{\"\"\" Return the signed boundary matrix of a 3-complex \"\"\"\nimport boolean\ndef larSignedBoundary3((V,FV,EV)):\n    model = V,FV,EV\n    faceCounter = zeros((len(FV),2),dtype='b')\n    CF,m = [],len(FV)\n    efOp = larFaces2Edges(V,FV,EV)\n    FE = [efOp([k]) for k in range(len(FV))]\n    EF_angle, _,_,_ = boolean.faceSlopeOrdering(model,FE)\n    nonWorkedFaces,coboundary_2,cellNumber = set(range(m)),[],0\n    boundaryOperator = larSignedBoundary2(V,FV,EV)\n    FEbasis = signedBasis(boundaryOperator)\n    row,col,data = [],[],[]\n    longestrow,longestcol,longestdata,longestLength = [],[],[],0\n    while True:\n        startFace,orientation = chooseStartFace(FV,faceCounter)\n        if startFace == -1: break\n        nonWorkedFaces = nonWorkedFaces.difference({startFace})\n        faceChainOrientation = {(startFace,orientation)}\n        vect = csc_matrix((m,1),dtype='b')\n        for face,orientation in faceChainOrientation:  \n            vect[face] = orientation\n        edgeCycleCoords = boundaryOperator * vect\n        edgeCycle = coords2chain(edgeCycleCoords)\n        while edgeCycle != []:\n            look4face = adjFace(boundaryOperator,EV,EF_angle,faceChainOrientation)\n            for edge,orientation in edgeCycle:\n                outPair = look4face(edge,orientation)\n                if outPair != None:\n                    adjacentFace,orientation = outPair\n                    faceChainOrientation = faceChainOrientation.union(\n                        [(adjacentFace,orientation)])\n                    nonWorkedFaces = nonWorkedFaces.difference([adjacentFace])\n            vect = csc_matrix((m,1),dtype='b')\n            for face,orientation in faceChainOrientation:  \n                vect[face] = orientation\n            edgeCycleCoords = boundaryOperator * vect\n            edgeCycle = coords2chain(edgeCycleCoords)\n            #if edgeCycle!=[]: VIEW(STRUCT(MKPOLS((V,[EV[e] for e in TRANS(edgeCycle)[0]]))))\n        for face,orientation in faceChainOrientation:\n            if orientation == 1: faceCounter[face,0]+=1\n            elif orientation == -1: faceCounter[face,1]+=1\n        #VIEW(STRUCT(MKPOLS((V,[FV[f] for f in TRANS(faceChainOrientation)[0]]))))\n        \n        lastrow = [face for face,_ in faceChainOrientation]\n        lastcol = [cellNumber for face,orientation in faceChainOrientation]\n        lastdata = [orientation for _,orientation in faceChainOrientation]\n        lastlength = len(lastrow)\n                \n        if lastlength >= longestLength:\n            lastrow,longestrow = longestrow,lastrow\n            lastcol,longestcol = longestcol,lastcol\n            lastdata,longestdata = longestdata,lastdata\n            lastlength,longestLength = longestLength,lastlength\n        if lastlength != 0:\n            row += lastrow\n            col += lastcol\n            data += lastdata\n            CF += [lastrow]\n            cellNumber += 1 \n        print \"\\nfaceCounter =\",faceCounter      \n    outMatrix = coo_matrix((data, (row,col)), shape=(m,cellNumber),dtype='b')\n    signedBoundary = zip(longestrow,longestdata)\n    return csr_matrix(outMatrix),CF,signedBoundary\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Return the signed boundary matrix of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Return the signed boundary matrix of a 3-complex\n@{\"\"\" Return the signed boundary matrix of a 3-complex \"\"\"\nimport boolean\ndef larSignedBoundary3((V,FV,EV)):\n    model = V,FV,EV\n    faceCounter = zeros((len(FV),2),dtype='b')\n    CF,m = [],len(FV)\n    efOp = larFaces2Edges(V,FV,EV)\n    FE = [efOp([k]) for k in range(len(FV))]\n    EF_angle, _,_,_ = boolean.faceSlopeOrdering(model,FE)\n    nonWorkedFaces,coboundary_2,cellNumber = set(range(m)),[],0\n    boundaryOperator = larSignedBoundary2(V,FV,EV)\n    FEbasis = signedBasis(boundaryOperator)\n    row,col,data = [],[],[]\n    while True:\n        startFace,orientation = chooseStartFace(FV,faceCounter)\n        if startFace == -1: break\n        nonWorkedFaces = nonWorkedFaces.difference({startFace})\n        faceChainOrientation = {(startFace,orientation)}\n        vect = csc_matrix((m,1),dtype='b')\n        for face,orientation in faceChainOrientation:  \n            vect[face] = orientation\n        edgeCycleCoords = boundaryOperator * vect\n        edgeCycle = coords2chain(edgeCycleCoords)\n        while edgeCycle != []:\n            look4face = adjFace(boundaryOperator,EV,EF_angle,faceChainOrientation)\n            for edge,orientation in edgeCycle:\n                outPair = look4face(edge,orientation)\n                if outPair != None:\n                    adjacentFace,orientation = outPair\n                    faceChainOrientation = faceChainOrientation.union(\n                        [(adjacentFace,orientation)])\n                    nonWorkedFaces = nonWorkedFaces.difference([adjacentFace])\n            vect = csc_matrix((m,1),dtype='b')\n            for face,orientation in faceChainOrientation:  \n                vect[face] = orientation\n            edgeCycleCoords = boundaryOperator * vect\n            edgeCycle = coords2chain(edgeCycleCoords)\n            #if edgeCycle!=[]: VIEW(STRUCT(MKPOLS((V,[EV[e] for e in TRANS(edgeCycle)[0]]))))\n        row += [face for face,_ in faceChainOrientation]\n        col += [cellNumber for face,orientation in faceChainOrientation]\n        data += [orientation for _,orientation in faceChainOrientation]\n        cellNumber += 1\n        \n        for face,orientation in faceChainOrientation:\n          if orientation == 1: faceCounter[face,0]+=1\n          elif orientation == -1: faceCounter[face,1]+=1\n        print \"faceChainOrientation =\",faceChainOrientation   \n        print \"faceCounter =\",faceCounter   \n          \n        CF += [[face for face,_ in faceChainOrientation]]\n        print \"CF =\",CF\n        print \"\\nfaceCounter =\",faceCounter      \n    outMatrix = coo_matrix((data, (row,col)), shape=(m,cellNumber),dtype='b')\n    return csr_matrix(outMatrix),CF,faceCounter\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.295\\linewidth]{images/signbound-0} \n   %\\includegraphics[width=0.245\\linewidth]{images/signbound-2} \n   \\includegraphics[width=0.385\\linewidth]{images/signbound-3} \n   \\includegraphics[width=0.30\\linewidth]{images/signbound-4} \n   \\caption{Arrangment of 3-complexes: (a) 1-skeleton of the fragmented (union) 3-complex; (b) view from the interior of the boundary 2-complex; (c) view from the exterior of the 3-complex.\n   Notice that the colour patches correspond to the chain of 2-faces of the boundary of 3-complex.\n   }\n   \\label{fig:signbound}\n\\end{figure}\n\n\\paragraph{Test the signed boundary matrix of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Test the signed boundary matrix of a 3-complex\n@{\"\"\" Test the signed boundary matrix of a 3-complex \"\"\"\nif __name__==\"__main__\":\n\n    V,[VV,EV,FV,CV] = larCuboids([2,2,1],True)\n    cubeGrid = Struct([(V,FV,EV)],\"cubeGrid\")\n    cubeGrids = Struct(2*[cubeGrid,t(.5,.5,.5),r(0,0,PI/6)])\n\n    V,FV,EV = struct2Marshal(cubeGrids)\n    VIEW(EXPLODE(1.2,1.2,1.2)(BREP((V,FV,EV),color=False) ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Examples}\n\n\\paragraph{A 3-cell with several holes}\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test12.py\n@{\"\"\" testing boundary operators (correct result) \"\"\"\nfrom larlib import *\n\nV,[VV,EV,FV,CV] = larCuboids([1,1,1],True)\ncell = (V,FV,EV)\ncubeGrid =  Struct([Struct([ s(10,10,1),cell ])] + 3*[t(0,2,0), Struct(3*[ t(1.5,0,0), cell] )] ,\"cubeGrid\")\nVIEW(STRUCT(MKPOLS(struct2lar(cubeGrid))))\n\nV,FV,EV = struct2Marshal(cubeGrid)\ncsrmat,CF,faceCounter = larSignedBoundary3((V,FV,EV))\nprint csrmat.todense()\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\section{Exporting}\n%===============================================================================\n\n\n%-------------------------------------------------------------------------------\n@O larlib/larlib/boundary.py\n@{\"\"\" boundary operators \"\"\"\nfrom larlib import *\n@< convex-cells boundary operator @>\n@< path-connected-cells boundary operator @>\n@< From cells and facets to boundary cells @>\n@< Marshalling a structure to a LAR cellular model @>\n@< Compute the signed 2-boundary matrix @>\n@< Compute any signed 1-boundary chain @>\n@< Offset of 2-faces of a 2D complex @>\n@< Boundary of a 3-complex @>\n@< Query from 3-chain to incident 2-chain @>\n@< Query from 3-chain to incident 1-chain @>\n@< Query from 2-chain to incident 1-chain @>\n@< kfaces-to-kfaces relations @>\n@< Transformation from chain coordinates to explicit chain data @>\n@< Choose the next face on ordered coboundary of edge @>\n@< Choose the start facet in extracting the facet representation of a cell @>\n@< Extract the signed representation of a basis element @>\n@< Return the signed boundary matrix of a 3-complex @>\n@< Test the signed boundary matrix of a 3-complex @>\n@}\n%-------------------------------------------------------------------------------\n\n\n\\section{Testing}\n\n\\subsection{Non-oriented operators}\n\n\\paragraph{Correct boundary extraction example}\n\nThe \\texttt{larBoundary()} operator is applied here to a cellular 2-complex of convex cells, producing correct result. It is worth noting that the operator is dimension-independent, and must be appliad to the \\emph{pair} of compressed characteristic matrices $M_d$ and $M_{d-1}$, that --- in list format --- we call either \\texttt{CV,FV} or  \\texttt{FV,EV}, depending on the dimension (either 3 or 2) of the embedding space.\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test01.py\n@{\"\"\" testing boundary operators (correct result) \"\"\"\nfrom larlib import *\n\nfilename = \"test/svg/inters/boundarytest0.svg\"\nlines = svg2lines(filename)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n    \nV,FV,EV,polygons = larFromLines(lines)\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.2))\nVIEW(EXPLODE(1.2,1.2,1.2)(MKPOLS((V,[EV[e] for e in boundaryCells(FV,EV)],))))\nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,FV,EV))))\n\nboundaryOp = larUnsignedBoundary2(FV,EV,VV)\n\nfor k in range(1,len(FV)+1):\n    faceChain = k*[1]\n    BF = chain2BoundaryChain(boundaryOp)(faceChain)\n    VIEW(STRUCT(MKPOLS((V,[EV[e] for e in BF]))))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Wrong boundary extraction example}\n\nThe \\texttt{larBoundary()} operator, applied  to a cellular 2-complex wih some non-convex cells, produces incorrect results. In such cases a correct result may be produced only by chance (sometimes this happens). So, be careful to use it only when the precondition (of cell convexity) is everywhere verified. In order to get always a correct result, use the \\texttt{larUnsignedBoundary2} operator.\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test02.py\n@{\"\"\" testing boundary operators (wrong result) \"\"\"\nfrom larlib import *\n\nfilename = \"test/svg/inters/boundarytest3.svg\" # KO (MKTRIANGLES) with boundarytest3 !!!\n#filename = \"test/svg/inters/boundarytest4.svg\"\nlines = svg2lines(filename)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n    \nV,FV,EV,polygons = larFromLines(lines)\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.2))\n\nboundaryOp = larUnsignedBoundary2(FV,EV,VV)  # <<======  NB\n#boundaryOp = larBoundary(FV,EV)  # <<======  NB\nBF = chain2BoundaryChain(boundaryOp)([1]*len(FV))\n\nVIEW(EXPLODE(1.2,1.2,1.2)(MKPOLS((V,[EV[e] for e in BF])))) \nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,FV,EV),color=True))) \nVIEW(SKEL_1(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,FV,EV))))) \n\"\"\"\nfor k in range(1,len(FV)+1):\n    faceChain = k*[1]\n    boundaryChain = chain2BoundaryChain(boundaryOp)(faceChain)\n    VIEW(STRUCT(MKPOLS((V,[EV[e] for e in boundaryChain]))))\n\"\"\"\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-2} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-3} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-4} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-5} \n\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-6} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-7} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-8} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test01-9} \n   \\caption{Convex-cell 2-complex. (a) Indexing of 0-,1-,and 2-cells; (b) exploded 2-boundary cells; (c) exploded 2-cells; (d) boundary of a singleton 2-chain; (e--h) boundaries of some 2-chains.}\n   \\label{fig:example}\n\\end{figure}\n\n\\paragraph{Example}\nComparison of two implementations of the $\\partial$ operator. Notice the difference between the penultimate rows. In particular, the penultimate row of the matrix generated by \\texttt{larBoundary(FV,EV)} is plain wrong. It means that the edge $e_{10}$ is shared by all the (three) 2-cells of the complex. Conversely, it is well known that, for a solid complex, i.e.~a $d$-complex embedded in $\\mathbb{E}^d$, every $(d-1)$-facet may be shared by no more than 2 $d$-cells. The resulting boundary of the total chain $[f_0, f_1, f_2]$ codified in coordinates as $[1,1,1]$, and shown in Figure~\\ref{fig:boundary-test02}d, is sonsequently incorrect.\n\\\\[3mm]\n\n%-------------------------------------------------------------------------------\n{\\scriptsize\n\\begin{minipage}[c]{0.5\\linewidth}\n\\centering\n\\begin{verbatim}\nIn [1]: larBoundary(FV,EV).todense()\nOut[1]: \nmatrix([[0, 1, 0],\n        [0, 0, 1],\n        [1, 0, 1],\n        [1, 0, 1],\n        [0, 1, 1],\n        [0, 1, 0],\n        [1, 0, 1],\n        [0, 0, 1],\n        [0, 0, 1],\n        [0, 1, 0],\n        [1, 1, 1],\n        [0, 1, 1]])\n\\end{verbatim}\n\\end{minipage}\n\\begin{minipage}[c]{0.5\\linewidth}\n\\centering\n\\begin{verbatim}\nIn [2]: larUnsignedBoundary2(FV,EV,VV).todense()\nOut[2]: \nmatrix([[0, 1, 0],\n        [0, 0, 1],\n        [1, 0, 1],\n        [1, 0, 1],\n        [0, 1, 1],\n        [0, 1, 0],\n        [1, 0, 1],\n        [0, 0, 1],\n        [0, 0, 1],\n        [0, 1, 0],\n        [1, 1, 0],\n        [0, 1, 1]])\n\\end{verbatim}\n\\end{minipage}}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-1} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-2} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-3} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-4} \n\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-1} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-2} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-3} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test02-5} \n   \\caption{Non-working (i.e.~\\emph{wrong}) example with \\texttt{boundary}. (a) Indexing of 0-,1-,and 2-cells; (b) boundary of a singleton 2-chain; (c) exploded 2-cells; (d) boundary of a singleton 2-chain. Working (i.e.~\\emph{exact}) example using \\texttt{larUnsignedBoundary2}: (e--h) as above.}\n   \\label{fig:boundary-test02}\n\\end{figure}\n\n\n\\paragraph{3D non-convex LAR cells}\nIn this example and in the next one we show the boundary computation of LAR models with non-contractible 3- and 2-cells.\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test03.py\n@{\"\"\" 3D non-convex LAR cells \"\"\"\nfrom larlib import *\n\nV = [[0.25,0.25,0.0],[0.25,0.75,0.0],[0.75,0.75,0.0],[0.75,0.25,0.0],[1.0, 0.0,0.0],\n[0.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0],[0.25,0.25,1.0],[0.25, 0.25,2.0],[0.25,0.75,\n2.0],[0.25,0.75,1.0],[0.25,0.75,-1.0],[0.25,0.25, -1.0],[0.75,0.75,-1.0],[0.75,0.25,\n-1.0],[0.75,0.25,1.0],[0.75,0.75,1.0], [1.0,0.0,1.0],[0.0,0.0,1.0],[1.0,1.0,1.0],\n[0.0,1.0,1.0],[0.75,0.75,2.0],[0.75,0.25,2.0]]\n\nCV = [(0,1,2,3,4,5,6,7,8,11,16,17,18,19,20,21), (0,1,2,3,8,11,16,17),\n(0,1,2,3,12,13,14,15), (8,9,10,11,16,17,22,23)]\n\nFV = [(2,3,16,17),(6,7,20,21),(12,13,14,15),(0,1,8,11),(1,2,11,17),(0,1,12,13),\n(4,6,18,20),(5,7,19,21),(0,3,13,15),(0,3,8,16),(0,1,2,3),\n(10,11,17,22),(2,3,14,15),(8,9,16,23),(8,11,16,17),\n(1,2,12,14),(16,17,22,23),(4,5,18,19),(8,9,10,11),(\n9,10,22,23),(0,1,2,3,4,5,6,7),(8, 11,16,17,18,19,20,21)]\n\nEV =[(3,15),(7,21),(10,11),(4,18),(12,13),(5,19),(8,9),(18,19),(22,23),(0,3),(1,11),\n(16,17),(0,8),(6,7),(20,21),(3,16),(10,22),(18,20),(19,21),(1,2),(12,14),(4,5),(\n8,11),(13,15),(16,23),(14,15),(11,17),(17,22),(2,14),(2,17),(0,1),(9,10),(8,16),\n(4,6),(1,12),(5,7),(0,13),( 9,23),(6,20),(2,3)]\n\nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV,CV],hpc,0.6))\n\nBF = boundary3Cells(CV,FV,EV)\nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,[FV[f] for f in BF],EV),color=True)))\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.495\\linewidth,width=0.495\\linewidth]{images/boundary-test03-1} \n   \\includegraphics[height=0.495\\linewidth,width=0.495\\linewidth]{images/boundary-test03-2} \n   \\caption{Non-convex 3-complex. (a) Indexing of 0-,1-,2- and 3-cells; (b) exploded 2-boundary cells.\n   Notice that two faces are multiply-connected.}\n   \\label{fig:boundary-test03}\n\\end{figure}\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test04-1} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test04-2} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test03-4} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/boundary-test03-5} \n   \\caption{Non-convex 3-complex. (a) Indexing of 0-,1-,2- and 3-cells; (b) exploded 2-boundary cells ---notice a drawing error on the back of the model---conversely, the data structures involved are correct, as shown by the two following pictures;\n   (c) solid drawing of the 2-chain \\texttt{[FV[29],FV[30]]}; (d) triangulation of the same 2-chain.}\n   \\label{fig:boundary-test04}\n\\end{figure}\n\n\\paragraph{3D non-convex LAR cells}\nIn this example the 3D model is constructed partly in automated way, partly by hand.\nIn particular, first we generate a structure of cuboidal complexes, then we transform it is a single complex using part of the computational pipeline being developed for the Boolean arrangments of complexes, so that all the included cells are mutually fragmented. Then the 3-cells are assembed as sets of 2-faces, giving the \\texttt{CF} (cells-by-faces) variable. Finally this one is transformed automatically into \\texttt{CV} (cells-by-vertices).\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test04.py\n@{\"\"\" 3D non-convex LAR cells \"\"\"\nfrom larlib import *\n@< Input of a cellular 3-complex @>\n@< Visualization of a 2-chain of a 3-complex @>\n@< Visualization of a 3-chain of a 3-complex @>\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Input of a cellular 3-complex}\n%-------------------------------------------------------------------------------\n@D Input of a cellular 3-complex\n@{\"\"\" Input of a cellular 3-complex \"\"\"\nV,[VV,EV,FV,CV] = larCuboids([2,1,1],True)\nstruct = Struct([(V,FV,EV),t(.25,.25,0),s(.25,.5,2),(V,FV,EV)])\n\nV,FV,EV = struct2Marshal(struct)\nCF = AA(sorted)([[20,12,21,5,19,6],[27,1,5,28,13,23],[12,14,25,17,10,4],\n[1,7,17,24,11,18],[30,29,26,16,8,22,10,11,4,18,24,25],[2,3,8,9,0,15]])\nCV = [list(set(CAT([FV[f]  for f in faces]))) for faces in CF]\n\nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV,CV],hpc,0.6))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Visualization of a 2-chain of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Visualization of a 2-chain of a 3-complex\n@{\"\"\" Visualization of the boundary 2-chain of a 3-complex \"\"\"\n\n\"\"\"\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)(len(CV)*[1])\nVIEW(STRUCT(MKTRIANGLES((V,BF,EV),color=True)))\nVIEW(SKEL_1(STRUCT(MKTRIANGLES((V,BF,EV)) )))\n\nboundaryEdges = chain2BoundaryChain(larUnsignedBoundary2(FV,EV,VV))\nedgeChain = boundaryEdges(29*[0]+[1]+[1]) \nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,FV[29:31],[EV[e] for e in edgeChain]),color=True)))\nVIEW(SKEL_1(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,FV[29:31],[EV[e] for e in edgeChain])))))\n\"\"\"\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Visualization of a 3-chain of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Visualization of a 3-chain of a 3-complex\n@{\"\"\" Visualization of a 3-chain of a 3-complex \"\"\"\n\nprint \"\\n****** ECCOMI\"\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([0,0,0,0,1,1])\nVIEW(STRUCT(MKTRIANGLES((V,BF,BE))))\nVIEW(SKEL_1(STRUCT(MKTRIANGLES((V,BF,BE)) )))\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test05.py\n@{\"\"\" Boundary of a 3-complex \"\"\"\nfrom larlib import *\n\nV,[VV,EV,FV,CV] = larCuboids([1,1,1],True)\ncube = Struct([ (V,FV,EV) ])\nassembly = Struct([ cube, Struct([t(0,.5,0), r(PI/4,0,0), s(.5,.5,.5),cube]) ])\n\nV,FV,EV = struct2Marshal(assembly)\nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],hpc,0.6))\n\nCF = [[1,2,3,4,6,7],[0,1,2,3,4,5,6,7,8,9,10,11]]\nCV = [list(set(CAT([FV[f]  for f in faces]))) for faces in CF]\n\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([0,1])\nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,BE),color=True))) \n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test06.py\n@{\"\"\" Boundary of a 3-complex \"\"\"\nfrom larlib import *\n\nV,[VV,EV,FV,CV] = larCuboids([1,1,1],True)\ncube = Struct([ (V,FV,EV) ])\nhole = Struct([t(0,.5,0), r(PI/4,0,0), s(.5,.5,.5),cube])\nassembly = Struct([ cube, hole, t(0,0,SQRT(0.5)), hole ])\n\nV,FV,EV = struct2Marshal(assembly) # WRONG:  TODO: check ...\nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[[],[],FV],hpc,0.6))\n\nCF = [[4,5,7,16,17,19,20],[3,8,6,12,11,13],[0,1,10,20],[]]\nCV = [list(set(CAT([FV[f]  for f in faces]))) for faces in CF]\n\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([0,1,1,0])\nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,BE)))) # ERROR in MKTRIANGLES with non-manifold face\nVIEW(EXPLODE(1.2,1.2,1.2)(MKFACES((V,BF,EV))))\nVIEW(SKEL_1(EXPLODE(1.2,1.2,1.2)(MKFACES((V,BF,EV)))))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test07.py\n@{\"\"\" Boundary of a 3-complex \"\"\"\nfrom larlib import *\n\nV,[VV,EV,FV,CV] = larCuboids([1,1,1],True)\ncube = Struct([ (V,FV,EV) ])\nhole = Struct([t(0,.5,0), r(PI/4,0,0), s(1,.5/SQRT(2),.5/SQRT(2)),cube])\nassembly = Struct([ cube, hole ])\n\nV,FV,EV = struct2Marshal(assembly) # WRONG:  TODO: check ...\nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],hpc,0.6))\n\nCF = [[1,3,6,7,12,11],[0,2,4,5,9,8]]\nCV = [list(set(CAT([FV[f]  for f in faces]))) for faces in CF]\n\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([1,0])\nVIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,EV),color=True)))\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O test/py/boundary/test08.py\n@{\"\"\" Boundary of a 3-complex \"\"\"\nfrom larlib import *\n\nV,[VV,EV,FV,CV] = larCuboids([1,1,1],True)\ncube = Struct([ (V,FV,EV) ])\nhole = Struct([t(0,.5,0), r(PI/4,0,0), s(1,.5/SQRT(2),.5/SQRT(2)),cube])\nassembly = Struct([ cube, hole ])\nassembly2 = Struct([ assembly, t(0,0,.5), s(0.5,1,1), hole ])\n\nV,FV,EV = struct2Marshal(assembly2) \nVV = AA(LIST)(range(len(V)))\nhpc = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],hpc,0.7))\n\n#CF = [[1,3,6,14,17,18,19, 0,4,9,11,15,16, 2,5,7,8,10,13],[0,4,9,11,15,16],[2,5,7,8,10,13]]\nCF = [[16,9,11,0,15,4],[10,12,7,2,17,15,9,5,18,8,16,3,6,14,19,4,1],[5,13,7,10,8,2]]\nCV = [list(set(CAT([FV[f]  for f in faces]))) for faces in CF]\n\nn = len(CV)\nfor k in range(n): \n    V,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)(IDNT(n)[k])\n    VIEW(STRUCT(MKTRIANGLES((V,BF,BE),color=True))) \n    VIEW(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,BE),color=True))) \n    VIEW(SKEL_1(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,BE)))))\nV,BF,BE = larUnsignedBoundary3(V,CV,FV,EV)([1,1,1])\nVIEW(SKEL_1(EXPLODE(1.2,1.2,1.2)(MKTRIANGLES((V,BF,BE)))))\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/topos1} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/topos2} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/topos3} \n   \\includegraphics[height=0.245\\linewidth,width=0.245\\linewidth]{images/topos4} \n   \\caption{Decomposition of the unit 3-cube in a cellular 3-complex with three 3-cells. Two 3-cells are homeomorphic to the 3-ball, while the remaining one is homeomorphic to the 3-torus.\nNotice that one of 2-cells (as well one of 3-cells) are non-contractible and non-manifold, as well as non-convex:\n   (a) Indexing of 2-faces of the 3-complex; (b) drawing of the (boundary of) non-convex 3-cell;\n   (c) exploded drawing of the (boundary of) non-convex 3-cell; (d) triangulation of its 2-faces.\n   The triangulation of LAR 2-faces is needed in order to draw them solidly.}\n   \\label{fig:boundary-test04}\n\\end{figure}\n\n\n\n\n\\appendix\n\\section{Utilities}\n\n\n\\paragraph{Marshalling a structure to a LAR cellular model}\nThe function \\texttt{struct2Marshal} transforms a \\texttt{Struct} object, often used to \ndefine some assembly of simpler models, to a correctly defined LAR cellular model, i.e.~to\na cellular partition of the space, in other words a quasi-disjoint partition of the object into well-glued cells of suitable dimensions.\n\n%-------------------------------------------------------------------------------\n@D Marshalling a structure to a LAR cellular model\n@{\"\"\" Marshalling a structure to a LAR cellular model \"\"\"\nimport boolean,inters\n\ndef struct2Marshal(struct):\n    W,FW,EW = struct2lar(struct)\n    quadArray = [[W[v] for v in face] for face in FW]\n    parts = boolean.boxBuckets3d(boolean.containmentBoxes(quadArray))\n    Z,FZ,EZ = boolean.spacePartition(W,FW,EW, parts)\n    V,FV,EV = inters.larSimplify((Z,FZ,EZ),radius=0.001)\n    return V,FV,EV\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Boundary of a 3-complex}\n%-------------------------------------------------------------------------------\n@D Boundary of a 3-complex\n@{\"\"\" Boundary of a 3-complex \"\"\"\nimport larcc\n\"\"\"  WHY wrong ????  TOCHECK !!\ndef larUnsignedBoundary3(V,CV,FV,EV):\n    VV = AA(LIST)(range(len(V)))\n    operator3 = larcc.chain2BoundaryChain(boundary3(CV,FV,EV))\n    operator2 = larcc.chain2BoundaryChain(larUnsignedBoundary2(FV,EV,VV))\n    def larUnsignedBoundary30(chain):\n        BF = operator3(chain)\n        faceCoords = len(FV)*[0]\n        for f in BF: faceCoords[f] = 1\n        BE = operator2(faceCoords)\n        return V,[FV[f] for f in BF],[EV[e] for e in BE]\n    return larUnsignedBoundary30\n\"\"\"\ndef larUnsignedBoundary3(V,CV,FV,EV):\n    VV = AA(LIST)(range(len(V)))\n    operator3 = larcc.chain2BoundaryChain(boundary3(CV,FV,EV))\n    operator2 = larcc.chain2BoundaryChain(larUnsignedBoundary2(FV,EV,VV))\n    def larUnsignedBoundary30(chain):\n        BF = operator3(chain)\n        BE = set()\n        for f in BF: \n            faceCoords = len(FV)*[0]\n            faceCoords[f] = 1\n            BE = BE.union(operator2(faceCoords))\n        return V,[FV[f] for f in BF],[EV[e] for e in BE]\n    return larUnsignedBoundary30\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.5\\linewidth]{images/edgecycle} \n   \\caption{The oriented boundary 1-cycle of a partial 3-cell extraction from a 2-complex in 3D.}\n   \\label{fig:edgecycle}\n\\end{figure}\n\n\n\\bibliographystyle{amsalpha}\n\\bibliography{boundary}\n\n\n\\end{document}\n", "meta": {"hexsha": "23cf8d8d54f54d3fccd3469be533916afd01cfcc", "size": 78951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/tex/boundary.tex", "max_stars_repo_name": "cvdlab/lar-cc", "max_stars_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-20T04:48:12.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-20T04:48:12.000Z", "max_issues_repo_path": "src/tex/boundary.tex", "max_issues_repo_name": "Ahdhn/lar-cc", "max_issues_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-02-20T21:57:07.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T07:18:11.000Z", "max_forks_repo_path": "src/tex/boundary.tex", "max_forks_repo_name": "Ahdhn/lar-cc", "max_forks_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-04T10:47:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-10T17:32:50.000Z", "avg_line_length": 48.0822168088, "max_line_length": 643, "alphanum_fraction": 0.6187382047, "num_tokens": 22924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318194686359, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.43588368415378326}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n%\\usepackage[scientific-notation=true]{siunitx}\n\\usepackage{tabularx}\n\\newcommand{\\D}{\\displaystyle}\n\\begin{document}\n\n\\title{Inferring Characteristics of Interaction Matrices in an Ecological Context{}}\n\\author{Naika Dorilas\\\\\\\\{Santa Fe Institute}}\n\n\\maketitle\n\n\\begin{abstract}\nIn ecology, an interaction matrix describes how species in an ecosystem interact with one another and affect each others growth in a given model of population growth. In an attempt to find a method for inferring species interactions, many ecologists have tried to go from time series data on the populations of species to inferring the entire interaction matrix. In this paper, the objective is to infer parameters of the interaction matrix, given a set of data, so instead of inferring the entire matrix, we just want 3 key statistical properties about how the entries are drawn, the mean $\\mu$, variance $\\sigma$ and average diagonal elements d. So based on a specified ecosystem we are trying to find a method of inferring the statistical properties of the interaction matrix between different species based on a simple model of population fluctuation. We will use maximum likelihood, to predict the probability of observing our data, x given $\\mu, \\sigma, d$. So what we expect from this maximization are the $\\mu,\\sigma,d$ that make the data, or fluctuations in population sizes of the species the most likely. The implications of this are that assuming this method is successful, any randomly generated matrix with the given statistical properties found could be used to describe how species in the data set used interact.\n\\end{abstract}\n\n\\section{Background}\n\n\\subsection{What is random matrix theory?}\n\\hfill\\break\nRandom Matrix Theory is a combination of statistics and traditional matrix theory. In this field, many tools from statitistics are used to describe matrices with random elements instead of relying on those individual elements. It allows us to generalize about certain characteristics of mtrices with similar statistical properties. Many problems in physical systems modeling and biological systems modeling involve matrices with random entries. \\hfill\\break\n\nRandom matrix theory has some great uses for the context of this project. Traditionally in one-dimensional models of population growth, specifically Lotka Volterra there are birth rates $r_b$, death rates $r_d$, and a carrying capacity, K.  \\hfill\\break\n\\hfill\\break \n$$\nN(t+\\Delta t)=N(t)+\\Delta t (r_b-r_d)N(t)(1-\\dfrac{N(t)}{K})\n$$\n\\hfill\\break \\hfill\\break\nAlthough, if we want to include the effects of other species on a single species, in ecological models of population growth across species we need to include something called an interaction matrix. It describes the way that different species interact with each other and effect eachothers survivial whether it be positively, negatively or with no effect at all. If we look at the equilibrium solutions-which tells us about stability of systems-and take them in smal perturbations, we get this linearized model of population dynamics \\hfill\\break\n\\hfill\\break \n\\begin{equation}\ny_i(t+\\Delta t)=y_i(t) + \\Delta t(A_{ij}y_i +\\xi_i)\n\\end{equation}\n\n\\hfill\\break\nwhere $y_i(t)$ is the population of species i at time t, $\\xi_i$ is random noise that might affect a species growth, and $A_{ij}$ is the matrix that describes the interactions between the species.\n\\hfill\\break \nIf we subtract both sides by $y_i(t)$, divide by $\\Delta t$ then allow $\\Delta t \\rightarrow 0$ then we obtain \\hfill\\break\n$$\\dfrac{\\partial y_i}{\\partial t}=A_{ij}y_i$$\nwe also dropped the random noise variable in order to illustrate species interactions simply.\n\\subsection{Examples of Interaction Matrices}\n\nAn example interaction matrix is illustrated below. \n\n$$\n\\begin{bmatrix}\nx_{11}&x_{12} \\\\\nx_{21}&x_{22}\n\\end{bmatrix}\n$$\n\\hfill\\break \\hfill\\break\nHere we have a small ecosystem of just 2 species for simplicity. In this case the model for population size of species i can be expanded to, \n\\hfill\\break\n\\hfill\\break\n\\begin{equation}\n\\begin{cases}\n\\dfrac{dy_1}{dt}=x_{11}y_1+x_{12}y_2\\\\\\\\\n\\dfrac{dy_2}{dt}=x_{21}y_1+x_{22}y_2\\\\\\\\\n\\end{cases}\n\\end{equation}\n\\hfill\\break\n\\hfill\\break\nNow we will explore a couple of different cases of what could happen when two species interact with eachother and what this looks like in terms of the interaction matrix and the model.\n\\hfill\\break\n\\hfill\\break\n\\textbf{Example 1:}\\hfill\\break\n\\hfill\\break\nWe could have a situation where the interaction matrix looks as such \\hfill\\break\n$$\n\\begin{bmatrix}\nx_{11}&0 \\\\\n0&x_{22} \n\\end{bmatrix}\n$$\nIn this case, the off diagonal elements are equal to 0, if we expand model (1) for this interaction matrix we get:\n\\begin{equation}\n\\begin{cases}\n\\dfrac{dy_1}{dt}=x_{11}y_1\\\\\\\\\n\\dfrac{dy_2}{dt}=x_{22}y_2\\\\\\\\\n\\end{cases}\n\\end{equation}\nNow we can see that the population of species 2 does not appear in the dynamics for species one and vice versa meaning the species are not interacting at all.\\hfill\\break\\hfill\\break\\hfill\\break\n\\textbf{Example 2:} \\hfill\\break\\hfill\\break\nWe could also have a case where the interaction matrix looks like this:\n$$\n\\begin{bmatrix}\nx_{11}&0 \\\\\nx_{21}&x_{22} \n\\end{bmatrix}\n$$\nIn this case if we exapand the equations in model (1) we would get something like this:\n\\begin{equation}\n\\begin{cases}\n\\dfrac{dy_1}{dt}=x_{11}y_1\\\\\\\\\n\\dfrac{dy_2}{dt}=x_{21}y1+x_{22}y_2\\\\\\\\\n\\end{cases}\n\\end{equation}\nmeaning that species 2 has no effect on the population dynamics for species 1 but species 1 is postively benifiting the populaiton of species 2. This could happen in a case of commensalism where species 1 is not being harmed or helped by species 2 but species 2 is gaining something from interacting with species 1.\n\\hfill\\break\\hfill\\break\\hfill\\break\n\n\\textbf{Example 3:} \\hfill\\break\\hfill\\break\nIn this case we have an interaction matrix that looks like this\n\n$$\n\\begin{bmatrix}\nx_{11}&-x_{12} \\\\\nx_{21}&x_{22} \n\\end{bmatrix}\n$$\n\\hfill\\break\nand if we expand model (1) we have something that looks like this:\n\\begin{equation}\n\\begin{cases}\n\\dfrac{dy_1}{dt}=x_{11}y_1\\\\\\\\\n\\dfrac{dy_2}{dt}=x_{21}y_1+x_{22}y_2\\\\\\\\\n\\end{cases}\n\\end{equation}\nThis shows us that species 2 is having a negative effect on the dynamics of species one and that species one is having a positive effect on the dynamics of species 2. An instance where this could happen is if there is a parasitic relationship between the two species or predation.\n\\hfill\\break\n\\subsection{The Need For Larger Matrices}\n\\hfill\\break\nNow this is what happens in a two-dimensional case, if we make the interaction matrix larger, the same kinds of patterns for different entries follow.\\hfill\\break\n$$\n\\begin{bmatrix}\n   x_{11} & x_{12} & x_{13} & \\dots &x_{1, 100}&\\dots & x_{1n} \\\\\n    x_{21} & x_{22} & x_{23} & \\dots &x_{2,100}&\\dots & x_{2n} \\\\\n    \\vdots & \\vdots & \\vdots & \\ddots & \\vdots &\\vdots&\\vdots \\\\\nx_{100,1}&x_{100,2}&x_{100,3} &\\dots & x_{100,100}&\\dots& x_{100,n}\\\\ \n\\vdots & \\vdots& \\vdots& \\vdots& \\vdots &\\ddots&\\vdots \\\\\n    x_{n1} & x_{n2} & x_{n3} & \\dots &x_{n,100}&\\dots & x_{nn}\n\\end{bmatrix}\n$$\\hfill\\break\nIn biological systems many aspects of the environment and growth process are random, large and can vary over space and time. For higher dimension interaction cases, the exact entries of the matrix matter less than certain aspects about the distribution of their entries such as the mean $\\mu$, variance $\\sigma$ and diagonal elements d. Random Matrix Theory(RMT) allows us to understand the stability of an ecosystem through looking at large scale properties of the matrix which we often refer to as an interaction matrix A. We can determine when a system will be stable based on these properties because we have results from RMT that for instance tell us about the distribution of eigenvalues for random matrices with similar statistical properties. Eigenvalues, tell us about the stability of our equilibrium solutions: whether or not starting close to that equilibrium will result in staying close to that equlibrium or diverging. In Ecology that tells us about a species survival. It would give researchers alot of insight if they were able to get basic aspects of matrices that allow for a stable ecosystem in a given population.   \\hfill\\break\n\nIn this project we start with a stable symmetrical matrix for which there are many useful properties from Random Matrix Theory. Given a set of data and our simple population model (1), our goal was to infer paramaters:$\\mu,\\sigma,d$ of a random interaction matrix A that would best fit the data. What this means is that based on an arbitrary real world data set of populations of different species across time, we hoped to infer the statistics of how the species in that data set interact with eachother.\n\n\n\n\\section{Methods}\n\\subsection{Maximum Likelihood}\n\\hfill\\break\nSo again, given time series data on poulation fluctuaton for S different species and our simple population model (1), our goal was to infer paramaters:$\\mu,\\sigma,d$ of a random interaction matrix A that would best fit the data. to do that we needed to maximize $P(x|\\mu,\\sigma,d)$ where x represents discrete data points for each species, particularly N of them. Given a statistical model-$f(x)$ and parameters-$p_i:p_1,p_2,...,p_n$,  $P(x|\\mu,\\sigma,d)$ is the likelihood of observing the model input x given the parameters p1:pn. Then we maximize this likelihood so our output from maximum likelihood becomes the parameter values:$p_i$ that make the x, the most probable. In the context of this project, x is the data of population dynamics of S different speices. We also have paramteres $p_i={\\mu,\\sigma,d}$ which describe the statistical properties of a random interaction matrix, and the output from maximum likelihood gives us the $p_i$ which makes the population fluctuations most likely to happen. So it optimizes $p_i$ by finding the parameters $p_i$ of a random interaction matrix which make those interactions the most likely to produce the fluctuations at each time step for S species: $x^a$, where a is the index for the number of data points drawn from each species.\n\\hfill\\break\\hfill\\break\nIn this paper we assume that each discrete data point, $x^a$ from the an arbitrary time series are independent. Therefore the average probability of observing the data points for one species ,$x^a$ given our parameters, $p_i$ for each species 1:S is just the multiplication of these probabilities \\hfill\\break\\hfill\\break $P(x_i^1|p_i)\\times P(x_i^2|p_i) \\times \\dots \\times P(x^a|p_i)\\times \\dots \\times P(x_i^N|p_i)$\n\\begin{equation}\nP(x|\\mu,\\sigma,d)=\\int dA \\prod_{a=1}^N P(x_i^a|A)\\times P(A|\\mu,\\sigma,d)\n\\end{equation}\n\\hfill\\break where N is the number of data points we collect for each species.\n\\hfill\\break\\hfill\\break Then we assume 3 things\n\\hfill\\break\\hfill\\break\n1). $A_{ij}=\\dfrac{\\mu}{S} + B_{ij}, B_{ij}~N(0,\\dfrac{\\sigma^2}{S}\\leftarrow A_{ij}~N(\\dfrac{\\mu}{S},\\dfrac{\\sigma^2}{S})$ \\hfill\\break\n2). $A_{ii}=-d+\\dfrac{\\mu}{S}$ \\hfill\\break\n3). $\\dfrac{1}{S}\\overline{logD}=\\dfrac{1}{S}(log(d+\\mu)+(S-1)\\int d\\lambda \\dfrac{\\sqrt{4\\sigma^2-(\\lambda+d)^2}}{2\\pi\\sigma}\\times log\\lambda$ \\hfill\\break\\hfill\\break\nSo that the parameters $\\mu, \\sigma, d$ can be solved for, we one assume that the off diagonal elements of A are drawn from a normal distribution of mean $\\mu$ and variance $\\sigma^2$, both sized down by S, and two assume that the diagonal elements of A are $-d+\\dfrac{\\mu}{S}$\\hfill\\break\nWe will justify why we do this below, but the determinants for large matrices are very similar, so to simplify our calculation we take the average determinant of A. The determinant of a matrix is given by the multiplication of eigenvalues. So the third assumption comes from the semircular law in Random Matrix Theory by physicicst Eugene Wigner in 1955. The distribution of eigenvalues for a symmetric matrix A whose entries were generated randomly and independently by a given distribution with mean:$ \\mu$, variance: $\\sigma$ and average diagonal elements: d, lie on a semicircle centered at d with diameter $2\\sigma$. The distribution of eigenvalues therefore comes from the formula \\hfill\\break\n$$\n\\dfrac{\\sqrt{4\\sigma^2-(\\lambda+d)^2}}{2\\pi\\sigma}\n$$\n\\hfill\\break\n\\includegraphics[scale=0.5]{Picture2} \\cite{one}\n\n\\hfill\\break\\hfill\\break\n\nNow based on some of these assumptions \n$$\nP(x|A)=\\dfrac{(det(A))^{1/2}}{(2\\pi)^{S/2}} exp(\\dfrac{1}{2}\\sum_{a=1}^N\\sum_{ij}^S x_i^aA_{ij}x_j^a)\n$$\n\nWe can then expand the likelihood equation to be \n$$\nP(x|\\mu,\\sigma,d)=\\int \\prod_{i<j}^N(dA_{ij})\\dfrac{(det(A))^{1/2}}{(2\\pi)^{S/2}} exp(\\dfrac{1}{2}\\sum_{a=1}^N\\sum_{ij}^S x_i^aA_{ij}x_j^a)\\times P(A|\\mu,\\sigma,d)\n$$\nSince A is a symmetric $S\\times S$ matrix for our purposes, then we only need to integrate over the upper right half of A. Then we just needed to multiply the $P(x|\\mu,\\sigma,d)$ for each $a \\in$ [1,N]. \\hfill\\break \\hfill\\break So then after including our assumptions, since we are taking the average determinant of A we replace that term with D \n\\hfill\\break\n\\begin{equation}\n\\dfrac{2}{N}logP=logD-\\dfrac{d}{N}\\sum_{a}\\sum_i (x_i^a)^2 +\\dfrac{1}{SN}\\sum_{a}(\\sum_i x_i^a)^2+\\dfrac{1}{2SN}\\sum_{ab}(\\sum_i x_i^a x_i^b)^2 \n\\end{equation}\ngives us the simplified version of our log likelihood equations.\n\\hfill\\break\nThen we had to maximize this likelihood to obtain parameters $\\mu,\\sigma,d$. So we took the partial derivates with respect to each variable of the log likelihood and set them equal to 0. \n\\hfill\\break\\hfill\\break\n$\\dfrac{\\partial logP}{\\partial \\mu}=0$,\n$\\dfrac{\\partial logP}{\\partial \\sigma}=0$,\n$\\dfrac{\\partial logP}{\\partial d}=0$\n\\hfill\\break\nThese equations based on the log likelihood can be written in the following form:\n\\begin{equation}\n\\begin{cases}\n\\dfrac{\\partial D}{\\partial \\mu} \\dfrac{1}{D}=-\\dfrac{1}{SN}\\sum_{a}(\\sum_i x_i^a)^2 \\\\\\\\\n\\dfrac{\\partial D}{\\partial \\sigma^2} \\dfrac{1}{D}=-\\dfrac{1}{2SN}\\sum_{ab}(\\sum_i x_i^a x_i^b)^2 \\\\\\\\\n\\dfrac{\\partial D}{\\partial d} \\dfrac{1}{D}=\\dfrac{1}{N}\\sum_{a}\\sum_i (x_i^a)^2 \\\\\\\\\n\\end{cases}\n\\end{equation}\nSolving these systems of equations for $\\mu,\\sigma, d$ is the last step in completing this method.\n\\subsection{Simulating Data}\\hfill\\break\nTo ensure that our calculations were correct and that this method was valid we generated data from a multivariate normal distribution, \n$$P(x_i^a| A)=\\dfrac{\\sqrt{det(A)}^{N/2}}{2\\pi^{NS/2}} exp(\\dfrac{1}{2}\\sum_{a=1}^N\\sum_{ij}^S x_i^aA_{ij}x_j^a)$$ \\hfill\\break\nDoing this, we assume X comes from discrete data points from each of S species. To make sure this method for inferring parameters is valid, we wanted to make sure it produces similar predictions for $\\mu,\\sigma,d$, as the $\\mu,\\sigma,d$ we gave to the simulation and used to generate the data. Given that our assumption of X is that it will come from this exact kind of distribution, our predicted values should closely match the actual values given to the simulation. An example of the time series data that we might take from each species is given in Figure 1. Where instead of taking all the data, we look at discrete time steps.\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\begin{figure}\n\\includegraphics[scale=0.6]{Popf}\n\\end{figure}\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\hfill\\break\n\\section{Results}\n\\subsection{Validation of Methods}\nTo make sure his method was valid and can be applied to other uncorrelated data, we graphed the simulated log determinants vs the analytical log determinants , the Rhs vs Lhs of the maximization equations and the output our optimization function for different $\\mu,\\sigma,d$. What we wanted is \\hfill\\break\\hfill\\break 1) That the average log determinants of matrices made from different $\\mu,\\sigma,d$, to be close to the log determinants calculated from the semicircular law for those same $\\mu,\\sigma,d$. \\hfill\\break\\hfill\\break 2). We wanted the Lhs of the optimization equations that depend on $\\mu,\\sigma,d$ and the Rhs that depend on the data X, for different parameters that generate both sides to also be very close so that \n$\\dfrac{\\partial logP}{\\partial \\mu,\\sigma,d}=Lhs-Rhs$=0. This is neccessary to be able to optimize for our parameters. \\hfill\\break\\hfill\\break 3). We wanted to see that the output for $\\dfrac{\\partial logP}{\\partial\\mu,\\sigma,d}$ was equal to 0 at some point or else there would be no root and therefore no optimal $\\mu,\\sigma,d$. \\hfill\\break\\hfill\\break According to the following figures, 1), 2)., 3). were achieved.\n\\hfill\\break\n\\hfill\\break\n1)\\hfill\\break\n\\includegraphics[scale=0.4]{LD}\\hfill\\break\n2)\\hfill\\break\n\\includegraphics[scale=0.4]{rlmu}\n\\includegraphics[scale=0.4]{rld}\n\\includegraphics[scale=0.4]{rlsigma} \\hfill\\break\n3)\\hfill\\break\n\\includegraphics[scale=0.4]{OPmu}\n\\includegraphics[scale=0.4]{OPsigma}\n\\includegraphics[scale=0.4]{OPd}\n\n\\subsection{Predicted output parameters vs actual parameters}\\hfill\\break\n\\hfill\\break\nAs a result of technical difficulties for this project in terms of gaining valus for our estimations, we only plot The predicted values we obtained for d in comparison to the actual values for a number of iterations. \n\\hfill\\break\n\\includegraphics[scale=0.5]{Picture1}\n%\\begin{equation}\n%\\begin{cases}\n%\\dfrac{dT}{dt}=-\\beta V T\\\\\\\\\n%\\dfrac{dI_1}{dt}=\\beta V T- kI_1\\\\\\\\\n%\\dfrac{dI_2}{dt}= kI_1- \\delta I_2\\\\\\\\\n%\\dfrac{dV}{dt}=\\pi I_2- c V\\\\\\\\\n%\\end{cases}\n%\\end{equation}\n%\\hfill\\break\n\\hfill\\break\n%\\hfill\\break\n%\\begin{table}\n%\\caption{Predicted Values of $\\mu,\\sigma,d$ in Comparison to the Actual Values of $\\mu,\\sigma,d$} \n%\\centering \n%\\begin{tabular}{lll}\n%\\hline\n%Variable  & Predicted Value &Actual Value\\\\ [0.5ex]\n%\\hline\n%\\\\\n%&  &  $\\D\\frac{\\mbox{}}{}$ \\\\ [0.5ex]\t\n%&  &  $\\D\\frac{\\mbox{}}{}$ \\\\ [0.5ex]\n%& &$\\D\\frac{\\mbox{}}{}$ \\\\[0.5ex]\n%& &  $\\D\\frac{\\mbox{}}{}$  \\\\ [0.5ex]\n%\n%\\hline\n%\\end{tabular}\n%\\label{table:variables} \n%\\end{table}\n%\\hfill\\break\n\n\n\n\n\n\\section{Discussion}\nThe impact of doing this method successfully is that hopefully we will be able to determine the key aspects of interaction given a specific data set and not have to infer an exact matrix. So we would be able to say that any random interaction matrix with those parameters $\\mu, \\sigma$ and d would be able to describe how the species in that given data set interact. I would soon like to see that this method still holds for $\\mu, \\sigma$ since d was the only estimation that currently works. Also, in the future I would like to use real world data sets of different species, and maybe even try multiple data sets and see how different types of data fare under this method. \n\n\\hfill\\break\n\n\\section{Aknowledgements}\nI would like to thank my mentors Dr. Andy Rominger and Dr. Jacopo Grilli for their support, patience and guidance throughout my project. \n\n\\begin{thebibliography}{999}\n\n\\bibitem{one} Wigner's Semicircle Law. (n.d.). Retrieved from http://mathworld.wolfram.com/WignersSemicircleLaw.html\n\n%On top of that, the stability of a biological system is very pertinent. In an ecological context it determines the survival of species. Generally we look at the \"community matrix\", which for a population of S species is influenced by S equations for population fluctuation. The community matrix looks at equilibrium solutions for these equations in small perturbations around the equilibria. We say the system is stable if when starting close to an equilibrium we stay close to that equilibria. Local stability can be determined by the eigenvalues of the matrix M. \n\n\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "f5e3b28ccda3264eca643b4d8dc516bf7ecf474f", "size": 19672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MS/RMT Project Paper.tex", "max_stars_repo_name": "ndorilas2014/RMTProject", "max_stars_repo_head_hexsha": "67edc50786cf525404e94bca34a2cbdb8f77c3c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-08T23:04:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-08T23:04:46.000Z", "max_issues_repo_path": "MS/RMT Project Paper.tex", "max_issues_repo_name": "ndorilas2014/RMTProject", "max_issues_repo_head_hexsha": "67edc50786cf525404e94bca34a2cbdb8f77c3c0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MS/RMT Project Paper.tex", "max_forks_repo_name": "ndorilas2014/RMTProject", "max_forks_repo_head_hexsha": "67edc50786cf525404e94bca34a2cbdb8f77c3c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.6013745704, "max_line_length": 1328, "alphanum_fraction": 0.7556933713, "num_tokens": 5595, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980404, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.43588064398345966}}
{"text": "\\problemname{Canvas Line}\n\nYour friend Charmion asked you to hang some canvases out to dry on a straight\nwashing line for an art project she has been working on.\nThe canvases are artfully arranged such that none of them overlap, although\nthey may touch along the edges.\nFor stability, each canvas must be held by two pegs, but because the canvases\nare very rigid, they can be held from anywhere.\n\nEach canvas is an integral number of centimetres wide (at least $10$ cm).\nEach peg is slightly less than $1$ cm wide. Canvases and pegs are all placed at\nintegral centimetre positions along the line.\n\nUnnecessary things touching any canvas is a smudge risk, thus every canvas\nshould be held by exactly two pegs, no more and no less. Given all of the pegs\nthat are already attached to the line, place as few as possible additional pegs\nas necessary to hold all of the canvases.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=1.0\\textwidth]{sample}\n  \\caption{Illustration of a solution to Sample Input 2. Pre-existing pegs are marked in white.}\n  \\label{fig:collage}\n\\end{figure}\n\\vspace{-0.4cm}\n\n\\section*{Input}\n\nThe input consists of:\n\\begin{itemize}\n\\item One line with an integer $n$ ($1 \\leq n \\leq 10^3$), the number of\n      canvases on the line.\n\\item $n$ lines, the $i$th of which contains two integers $\\ell_i$ and $r_i$\n      ($0 \\leq \\ell_i < r_i \\leq 10^9$ and $\\ell_i + 10 \\le r_i$), the\n      positions of the left and the right end of the $i$th canvas in centimetres.\n\\item One line with an integer $p$ ($0 \\leq p \\leq 2 \\cdot 10^3$), the number of\n      pegs already used.\n\\item One line with $p$ integers $x_1, \\ldots, x_p$ ($0 \\leq x_i < x_{i+1}\n  \\leq 10^9$ for each $i$), the position of each existing peg in\n    centimetres.\n\\end{itemize}\n\nCanvases are given from left to right and may touch only at edges,\nthat is $r_i \\le \\ell_{i+1}$ for each $i$.\n\n\\section*{Output}\n\nIf the canvases can be secured, output the smallest number of extra pegs needed\nto secure all of the canvases while touching each exactly twice. On the next\nline output the integer positions of all of the new pegs.\n\nOtherwise, output ``\\texttt{impossible}''.\n\nIf there are multiple optimal solutions, you may output any one of them.\n", "meta": {"hexsha": "55fcf449c5e3bd0e2bf8bfce470355ed41fb287b", "size": 2233, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/canvasline/problem_statement/problem.en.tex", "max_stars_repo_name": "Shahraaz/CP_P_S5", "max_stars_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/canvasline/problem_statement/problem.en.tex", "max_issues_repo_name": "Shahraaz/CP_P_S5", "max_issues_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ICPC_Mirrors/Nitc_9.0/nwerc2019all/canvasline/problem_statement/problem.en.tex", "max_forks_repo_name": "Shahraaz/CP_P_S5", "max_forks_repo_head_hexsha": "b068ad02d34338337e549d92a14e3b3d9e8df712", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.6, "max_line_length": 96, "alphanum_fraction": 0.736229288, "num_tokens": 643, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4358806439834596}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lscape}\n\\usepackage{graphicx}\n\\usepackage{stfloats}\n\\usepackage{float}\n\\usepackage{import}\n\\usepackage{adjustbox}\n\\usepackage{hyperref}\n\\usepackage{apacite}\n\\usepackage{fancyhdr}\n\n\n\\pagestyle{fancy}\n\\lhead{Niklas Lundberg}\n\\rhead{inaule-6@student.ltu.se}\n\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{1em}\n\n\\title{Structural Operational Semantics}\n\\author{Niklas Lundberg \\\\ inaule-6@student.ltu.se}\n\\date{\\today}\n\n\\begin{document}\n\n    \\maketitle\n    \\newpage\n    \\section{SOS} \n        \\subsection{i32}\n                \\begin{equation}\n                    \\langle e, \\sigma \\rangle\\Downarrow n\n                \\end{equation}\n                \n            \\subsection{bool}\n                \\begin{equation} \n                    \\langle e, \\sigma \\rangle\\Downarrow b\n                \\end{equation}   \n                \n            \\subsection{Unop}\n                \\subsubsection{Not}\n                    \\begin{equation}  \n                        \\frac{\\langle b, \\sigma \\rangle\\Downarrow false}\n                        {\\langle !b, \\sigma \\rangle\\Downarrow true }\n                    \\end{equation}\n                    \\begin{equation}\n                        \\frac{\\langle b, \\sigma \\rangle\\Downarrow true}\n                        {\\langle !b, \\sigma \\rangle\\Downarrow false }\n                    \\end{equation}\n                    \n                \\subsubsection{Sub}\n                    \\begin{equation}  \n                        \\frac{\\langle e, \\sigma \\rangle\\Downarrow n}\n                        {\\langle -e, \\sigma \\rangle\\Downarrow - n }\n                    \\end{equation}\n                    \n            \\subsection{Binop}\n                \\subsubsection{Add}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 + e2, \\sigma \\rangle\\Downarrow n1 + n2}\n                    \\end{equation}\n                    \n                \\subsubsection{Sub}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 - e2, \\sigma \\rangle\\Downarrow n1 - n2}\n                    \\end{equation}\n                    \n                \\subsubsection{Div}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 / e2, \\sigma \\rangle\\Downarrow n1 / n2}\n                    \\end{equation}\n                    \n                \\subsubsection{Multiplication}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 * e2, \\sigma \\rangle\\Downarrow n1 * n2}\n                    \\end{equation}\n                \n                \\subsubsection{Mod}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 \\% e2, \\sigma \\rangle\\Downarrow n1 \\% n2}\n                    \\end{equation}\n                    \n                \\subsubsection{And}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow false \\: \\langle b2, \\sigma \\rangle\\Downarrow false}\n                        {\\langle e1 \\&\\& e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow true \\: \\langle b2, \\sigma \\rangle\\Downarrow false}\n                        {\\langle e1 \\&\\& e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow false \\: \\langle b2, \\sigma \\rangle\\Downarrow true}\n                        {\\langle e1 \\&\\& e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow true \\: \\langle b2, \\sigma \\rangle\\Downarrow true}\n                        {\\langle e1 \\&\\& e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \n                \\subsubsection{Or}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow false \\: \\langle b2, \\sigma \\rangle\\Downarrow false}\n                        {\\langle e1 || e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow true \\: \\langle b2, \\sigma \\rangle\\Downarrow false}\n                        {\\langle e1 || e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow false \\: \\langle b2, \\sigma \\rangle\\Downarrow true}\n                        {\\langle e1 || e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle b1, \\sigma \\rangle\\Downarrow true \\: \\langle b2, \\sigma \\rangle\\Downarrow true}\n                        {\\langle e1 || e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \n                \\subsubsection{Not equal}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 != e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n \\: \\langle e2, \\sigma \\rangle\\Downarrow n}\n                        {\\langle e1 != e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \n                \\subsubsection{Equal}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 == e2, \\sigma \\rangle\\Downarrow false}\n                    \\end{equation}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n \\: \\langle e2, \\sigma \\rangle\\Downarrow n}\n                        {\\langle e1 == e2, \\sigma \\rangle\\Downarrow true}\n                    \\end{equation}\n                    \n                \\subsubsection{Less or equal then}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 <= e2, \\sigma \\rangle\\Downarrow n1 <= n2}\n                    \\end{equation}\n                    \n                \\subsubsection{Larger or equal then}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 >= e2, \\sigma \\rangle\\Downarrow n1 >= n2}\n                    \\end{equation}\n            \n                \\subsubsection{Less then}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 < e2, \\sigma \\rangle\\Downarrow n1 < n2}\n                    \\end{equation}\n                    \n                \\subsubsection{Larger then}\n                    \\begin{equation}  \n                        \\frac{\\langle e1, \\sigma \\rangle\\Downarrow n1 \\: \\langle e2, \\sigma \\rangle\\Downarrow n2}\n                        {\\langle e1 > e2, \\sigma \\rangle\\Downarrow n1 > n2}\n                    \\end{equation}\n                    \n            \\subsection{Assigment}\n                \\begin{equation}  \n                        \\frac{}\n                        {\\langle x := n, \\sigma \\rangle\\Downarrow \\sigma [ x := n ]}\n                \\end{equation}\n                \n            \\subsection{Variable}\n                \\begin{equation}  \n                        \\sigma [ x := n ] = n\n                \\end{equation}\n                \n            \\subsection{If}\n                \\begin{equation}  \n                    \\frac{\\langle b, \\sigma \\rangle\\Downarrow true \\: \\langle c1, \\sigma \\rangle\\Downarrow \\sigma'}\n                    {\\langle \\textbf{if } b \\textbf{ then } c1 \\textbf{ else } c2, \\sigma \\rangle\\Downarrow \\sigma'}\n                \\end{equation}\n                \\begin{equation}  \n                    \\frac{\\langle b, \\sigma \\rangle\\Downarrow false \\: \\langle c2, \\sigma \\rangle\\Downarrow \\sigma''}\n                    {\\langle \\textbf{if } b \\textbf{ then } c1 \\textbf{ else } c2, \\sigma \\rangle\\Downarrow \\sigma''}\n                \\end{equation}\n                \n            \\subsection{While}\n                \\begin{equation}  \n                    \\frac{\\langle b, \\sigma \\rangle\\Downarrow false }\n                    {\\langle \\textbf{while } b \\textbf{ do } c, \\sigma \\rangle\\Downarrow \\sigma}\n                \\end{equation}\n                \\begin{equation}  \n                    \\frac{\\langle b, \\sigma \\rangle\\Downarrow true \\: \\langle c, \\sigma \\rangle\\Downarrow \\sigma' \\langle \\textbf{while } b \\textbf{ do } c, \\sigma' \\rangle\\Downarrow \\sigma'' }\n                    {\\langle \\textbf{while } b \\textbf{ do } c, \\sigma \\rangle\\Downarrow \\sigma''}\n                \\end{equation}\n                \n            \\subsection{Function call}\n                \\begin{equation}  \n                    \\frac{\\langle c, \\sigma \\rangle\\Downarrow \\sigma' }\n                    {\\langle \\textbf{call } c, \\sigma \\rangle\\Downarrow \\sigma'}\n                \\end{equation}\n                \n            \\subsection{Return}\n                \\begin{equation}  \n                    \\frac{\\langle c, \\sigma \\rangle\\Downarrow \\sigma' }\n                    {\\langle \\textbf{return } c, \\sigma \\rangle\\Downarrow \\sigma'}\n                \\end{equation}\n    \n\\end{document}", "meta": {"hexsha": "38f54d41ebd322851c6b01d82cee7d352273580b", "size": 10307, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "my_compiler/Documents/SOS.tex", "max_stars_repo_name": "Blinningjr/D7050E", "max_stars_repo_head_hexsha": "52c080ccfa102ee98b80b258a67aedb6583d9294", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-09-09T16:04:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-10T07:49:54.000Z", "max_issues_repo_path": "my_compiler/Documents/SOS.tex", "max_issues_repo_name": "Blinningjr/D7050E", "max_issues_repo_head_hexsha": "52c080ccfa102ee98b80b258a67aedb6583d9294", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "my_compiler/Documents/SOS.tex", "max_forks_repo_name": "Blinningjr/D7050E", "max_forks_repo_head_hexsha": "52c080ccfa102ee98b80b258a67aedb6583d9294", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.8483412322, "max_line_length": 193, "alphanum_fraction": 0.4636654701, "num_tokens": 2536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4358806366777909}}
{"text": "\\chapter{Mixed-Integer Linear Modelling and Analysis of Historical Schedules}\n\\label{chapter: 2-Evaluating Royal Mail Historical Data}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nThis chapter concerns the formulation of an initial set of models used to provide a first assessment on the opportunity for optimisation that is available in our problem. The goal of this analysis is to corroborate the quest of this dissertation to investigate the opportunity for efficiency gains and optimisation of the current practices run by Royal Mail. \n\n\\vspace{\\baselineskip}\n\\noindent\nSection \\ref{section: 4.1} starts by defining the playing field within which our models will be developed. It also provides an overview of the actual historical practices implemented by Royal Mail building upon the high-level overview seen in Chapter \\ref{chapter: Problem Definition}. Sections \\ref{section:Makespan Scheduling-content}-\\ref{section: Pre-emptive} each involve the study of a different model, and they all follow a similar organisation. They begin by outlining the motivation behind the use of each of the models, and the goal we wish to achieve with each one. They then present the first set of results of this dissertation, outlining the efficiency gains that can be made for the instances of the supplied dataset.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Modelling Environment}\n\\label{section: 4.1}\nTo develop this first set of model formulations, we assume that the schedule instances contain \\textbf{fixed duties} with a concrete \\texttt{start\\_time}, and \\texttt{end\\_time}. Multiple duties are being run in parallel each day. Our goal is to allocate the trips (i.e. atomic blocks) efficiently to those available duties. We assume carte blanche in regards to our flexibility in allocating a block to a duty by neglecting any restrictions as to whether or not we can move a block. We also render our data points agnostic to any semantics associated with each trip\\footnote{e.g. the distance between locations or the day on which each shift should occurs} and assume that all blocks are equivalent in their significance, and are merely characterised by their parameters. These abstractions will enable us to determine the maximum room for improvement that exists in efficiently allocating blocks to each duty establishing an upper bound in regards to the degree to which we can aim to optimise.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\vspace{\\baselineskip}\n\\noindent\nThe set of assumptions mentioned are succinctly summarised below:\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\t\\begin{table}[ht]\n\t\\renewcommand{\\arraystretch}{1.7} %adds space between cells of a table\n\t\t\\centering\n\t\t\\begin{tabular}{|c |p{0.9\\textwidth}|} \n\t\t\t\\multicolumn{2}{l}{\\textbf{Simplifying Assumptions}} \\\\\n\t\t    \\hline\n\t\t\t\\textbf{(1)}  & The \\textbf{duration} of a \\textbf{block} stays \\textbf{constant}, irrespective of the timing of its occurrence.\\\\\n            \\hline\n            \\textbf{(2)}  & The \\texttt{start}, \\texttt{end} times and \\textbf{durations} of duties remain fixed. \\\\\n            \\hline\n            \\textbf{(3)}  &\\textbf{Atomic blocks} are \\textbf{freely interchangeable}, within the spectrum of a schedule.\\\\\n\t\t\t\\hline\n\t\t\t\\textbf{(4)}  & The \\textbf{routes} are \\textbf{fixed}, and we \\textbf{maintain} the \\textbf{order} with which we visit external locations.\\\\\n\t\t\t\\hline\n\t\t\\end{tabular} \n\t\\end{table}\n\t\n\\vspace{\\baselineskip}\n\\noindent\nThe first two assumptions, capture the fact that our proposed schedules respect the principle of \\textbf{conservation of time}. Our models receive as input an instance that contains blocks inside duties the sum of the durations of which gives us the \\texttt{overall labor time} to be scheduled. The schedules that are generated from our algorithms have the same blocks, covering the same \\texttt{overall labor time} with the only difference being the \\textbf{arrangement}, of those blocks in the duties. The third assumptions, refers to our \\textit{assignment policy} of blocks to duties, and the fact that it is completely open-ended giving the schedule total freedom over which duty, and at what point in time to assign a block. Finally, the last assumption reiterates that we do not focus on the routing aspect of this Vehicle-Routing like problem but only study its scheduling portion.\n\t\n\n\t\n\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\t\n\\subsection*{Evaluation of Historical Schedules}\nTo begin assessing the performance of our optimised schedule we must first look at the schedules currently run by Royal Mail which we refer to as the \\textbf{historical} instance.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|c|c|c|c|c|c|c|}\n        \\hline\n        \\textbf{Instance} & \\multicolumn{3}{|c|}{ \\textbf{Characteristics}} & \\multicolumn{3}{|c|}{ \\textbf{Blocks (HH:mm)}}  \\\\\n        \\hline\n        & \\texttt{Duties} & \\texttt{Blocks} & \\texttt{Activities} & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Maximum} \\\\\n        \\hline\n        Historical & 183 & 462 & 3,285 & 03:05 & 00:40 & 08:25 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n\n\n\\vspace{\\baselineskip}\n\\noindent\nThe historical schedules which our model is given as an input are driven by an instance $I = \\langle{m},B\\rangle{}$ of the problem where 462 blocks are allocated among a set of 183 duties over the period of a week\\footnote{As input we provide the Finalised Dataset (Cleaned) from Section \\ref{section: Data Cleaning} of the previous chapter that we henceforth refer to as the Historical Schedule.}. The minimal processing time $p_{j}$ was that of a round-trip lasting only 40 minutes while the longest trips lasted up to 8 hours and 25 minutes. On average a round-trip is expected to last 3 hours and 5 minutes among the historical schedules. \n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|c|c|c|c|c|}\n        \\hline\n        \\textbf{Schedule} & \\multicolumn{3}{|c|}{ \\textbf{Duties (HH:mm)}} & \\textbf{Total Time (HH:mm)}  \\\\\n        \\hline\n        & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Makespan} & \\\\\n        \\hline\n        Historical & 07:50 & 02:50 & 11:50 & 1,435:22 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n\\vspace{\\baselineskip}\n\\noindent\nWe proceeded to plot a histogram of the duty structure of the historical schedule, seen in Figure \\ref{fig: Historical for Evaluation.}. In that diagram we have fitted the historical workload into class intervals or histogram bins that represent durations of duties according to the duties of the historical schedule. The purpose of this figure is to show us how much each driver works historically. Indeed, there is a \\textbf{noticeable variation}. We see some drivers work for around 2 hours whereas others for close to 12 hours and in general there are some \\textbf{significant fluctuations}, which provokes a waste of labour hours. In general, there are people asked to perform duties in excess of 9 hours, hence requiring \\textbf{overtimes}, which might prove costly for the company. Hence, envisioning a more balanced schedule we wanted to see if it is possible to have a solution that balances the workload more uniformly. This motivated the experiment run in Section \\ref{section:Makespan Scheduling-content}, where since our goal is a balanced schedule we choose a formulation based on the \\textit{Makespan Scheduling} model first seen in Section \\ref{section:Makespan Scheduling}. The motivation behind this choice is that as was explained in Section \\ref{section:Makespan Scheduling}, a schedule with a minimised \\textit{makespan} usually achieves a \\textbf{well-balanced} sequence of the tasks processed \\cite{DUMMY:2}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}[ht]\n\\begin{center}\n\\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/Historical-for-evaluation.png}\n    \n\\end{center}\n   \\caption{The histogram provides an overview of the overall $Duty$ lengths featured in the \\textbf{Historical Schedule}.}\n\\label{fig: Historical for Evaluation.}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBSECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Load Balancing}\n\\label{section:Makespan Scheduling-content}\nWith the goal of finding a more balanced schedule in terms of duty length the \\textit{Makespan Scheduling} formulation attempts to minimise the overall duration of the schedule, the \\textbf{makespan}. The goal is for the resulting optimised schedule to decrease the amount of time for which a driver is generally occupied for, a practical advantage that we hope will be gained by a \\textbf{balanced schedule}.\n\n\\vspace{\\baselineskip}\n\\noindent\nThe two evaluation criteria that we need to examine to determine the success of our model are the degree to which the \\textit{makespan is decreased} and a \\textit{measure of uniformity} of the optimised schedule. Two ways to practically evaluate these two criteria is to look at the \\textbf{(\\%) makespan reduction} and the \\textbf{(\\%) standard deviation reduction ($\\pmb{\\sigma}$)} of the distribution of duties, respectively, compared to the instance that was provided as input to the model. Hence, for the experiments involving the Makespan model, we compare every schedule generated at each stage with respect to those two measures of success. \n\n\\vspace{\\baselineskip}\n\\noindent\nAn instance $I = \\langle{m},B\\rangle{}$ of the problem involves  an environment of $D=\\{1,...,m\\}$ parallel and identical duties, and a set of blocks $B =\\{1,...,n\\}$. Each duty may be assigned at most \\textbf{one block per unit of time}, and once assigned a block it must execute it until its completion with no interruptions. In other words, this is a \\textit{non-preemptive} model. %A duty is described by its start time $s_{i}$, and finish time $f_{i}$. The execution of any blocks for each duty must occur within the time horizon $f_{i}-s_{i}$. \nThe blocks $j \\in B$ are all associated with processing time $p_{j}$ as their one and only attribute. Mathematically the goal for this first stage of optimisation is to evenly allocate the blocks to each duty in a way that minimises the completion time of the last duty to be completed. \n\n\\vspace{\\baselineskip}\n\\noindent\nThe formulation utilised to perform this task is an adapted version %aka a variance\nof the makespan scheduling model seen in Chapter \\ref{chapter: Background}. We parallelise\\footnote{The purpose of this parallelisation is to transform our problem into an equivalent problem to that studied in \\cite{PRAKASH2010}, for which efficient algorithms for solving it have already been studied.} our problem with the problem observed in Section \\ref{section:Makespan Scheduling}. We consider a \\textbf{duty} as the \\textit{machine} from formulation \\ref{section:Makespan Scheduling} and a \\textbf{block} as a \\textit{job}, respectively. Hence, our formulation assigns blocks to duties. Binary variable $x_{i,j}$ dictates the assignment of a block $j$ to a duty $i$. The binary variable $x_{i,j}$ is equal to 1 if the atomic block $j \\in B$ is assigned to duty $i \\in D$, and 0 otherwise. Continuous variable $y$ contains the \\textbf{makespan} of the schedule, which is what we are trying to minimise.  \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Maths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{\\baselineskip}\n\\begin{equation}\n\\label{equation: Makespan Scheduling}\n\\begin{aligned}\n&\\text{minimise}\n%& & y_{i}  \\\\ %\\todo{why y and and not yi}\n& & y  \\\\ \n& \\text{subject to}\n% & & y_{i} = \\sum _{j=1}^n x_{i,j}p_{j}  \\;\\;\\; &\\forall \\; i \\in D\\tag{1}\\\\   \n& & y \\geq \\sum _{j=1}^n x_{i,j}p_{j}  \\;\\;\\; &\\forall \\; i \\in D\\\\   \n& & &\\sum _{i=1}^m x_{i,j} = 1 \\;\\;\\; &\\forall \\; j \\in B\\\\\n% & & &\\sum _{j=1}^n x_{i,j}p_{j} \\leq f_{i}-s_{i} \\;\\;\\; &\\forall \\; i \\in D\\\\ %{\\color{red} we deleted the constraint that involves the length of duty being less than end-start.}\n& & & y\\geq 0  \\\\\n& & & x_{i,j} \\in  \\{ 0,1 \\} \\;\\;\\; &\\forall \\; j \\in B, \\; i \\in D\\\\\n\\end{aligned}\n\\end{equation}\n\n\\vspace{\\baselineskip}\n\\noindent\nThe objective is to get the \\textbf{minimal} possible \\textbf{makespan} that allows a feasible schedule. The first constraint assigns $y$ its definition of the \\textbf{makespan} by making it equal to the completion time of the last atomic block to be executed. With the second constraint we make sure that each block is assigned to at least one but only one duty. The third and the fourth constraints enforce the continuous and integrality nature to the $y,x$ variables respectively, rendering this a \\textit{MILP} problem.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation}\nIn this initial model, we choose to focus on trying to shorten the \\textbf{completion time} of the \\textbf{longer lasting duty}, with the goal of obtaining \\textbf{fairer shifts }that will have a more \\textbf{uniform} allocation of the workload among drivers. In the historical schedule, the shortest shift lasts for 2 hours and 50 minutes while the longest one (i.e. the makespan) takes 11 hours and 50 minutes, as seen before. The historical allocation of blocks has been done heuristically, for the historical schedules, which is why cases of longer and shorter shifts than the average tend to occur. Taking as an example, the extremely short and long cases of shifts described above a closer observation shows that more than seven blocks (i.e. round-trips) were allocated to a driver as part of that longest shift, whereas just a single one was assigned to the shortest shift. Such observations motivate our efforts in striving to improve efficiency by minimising the duration of every duty to ensure a fairer allocation of the work load, since there seems to be a chance to remedy all these oddities of the historical schedule.\n\n\\vspace{\\baselineskip}\n\\noindent\nWith regards to the objective of our model, the makespan, we need to be aware of a practical constraint that places a lower bound regarding the most minimum makespan that can be achieved in a feasible schedule. This constraint stems from the fact the there exist blocks of duration 8 hours and 25 minutes. According to assumption (4) of Section \\ref{section: 4.1}, we cannot split a block into smaller sub-components so as to reduce its duration. Consequently, the \\texttt{absolute theoretical limit} in regards to the most optimal schedule that we can hope to achieve will have a makespan equal to the duration of those maximum-lasting blocks. Such a schedule would contain duties that solely complete these 08:25 block and no other. Proposing a schedule with an 08:25 makespan or one close to it will constitute an efficient optimisation of the current practices. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}%\n    \\centering\n    \\subfloat[The duration of each duty before and after optimisation sorted in increasing duration.]{%\\begin{center}\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D1.png}\n    }%\\end{center}}%picture #1\n    \\qquad\n    %picture #2\n    \\centering\n    \\subfloat[Histogram showing the improvement in the \\textbf{uniformity} of duties.]{%\\begin{center}\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D1M1.png}\n    }%\\end{center}}%end of picture #2\n    \\caption{Figures illustrating the effects of the optimisation model on the historical duties.}%\n    \\label{fig:1-D1M1}%\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection*{Qualitative Results}\nThe application of the Makespan Scheduling model on the Historical dataset has the effect of \\textit{flattening} the historical curve as seen in Figure \\ref{fig:1-D1M1}(a), and hence concentrating the majority of the workload on duties that last as long as the makespan of the schedule, or less. \n\n\\vspace{\\baselineskip}\n\\noindent\nThe effect of our model is most noticeable in Figure \\ref{fig:1-D1M1}(b) which plots the duration of each duty before and after the optimisation. We can observe how this first attempt at optimising the historical schedule results in a fairer distribution of labor time, since the majority of duties are now of similar length. There is also a big improvement in the \\textbf{reduction of extremities} vis-\\`a-vis extremely long and extremely short shifts, allowing us to prevent the occurrence of a large group of very long duties that are not efficient since they require drivers to complete overtimes. In a nutshell a reduction of the order of \\textbf{72\\%} in the \\textbf{standard deviation ($\\pmb{\\sigma}$)} of the optimised schedule compared to the input instance encapsulates the fact that we have achieved our main goal of obtaining a more uniform schedule.\n\n\\subsubsection*{Quantitative Results}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|l|c|c|c|c|}\n        \\hline\n        \\textbf{Schedule} & \\multicolumn{3}{|c|}{ \\textbf{Duties (HH:mm)}} & \\textbf{Total Time (HH:mm)}  \\\\\n        \\hline\n        & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Makespan} & \\\\\n        \\hline\n        Historical & 07:50 & 02:50 & 11:50 & 1,435:22 \\\\\n        \\hline\n        Historical\\_Optimised & 07:50 & 05:15 & 08:25 & 1,435:22 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n\n\n\\vspace{\\baselineskip}\n\\noindent\nWe have also achieved our main objective of minimising the \\textit{maximum duty length} since the historical makespan was 11 hours and 45 minutes whereas in our revised schedule it is exactly 8 hours and 25 minutes hence, achieving the \\texttt{absolute theoretical limit}. This accomplishment amounts to a \\textbf{28\\% reduction of the makespan} compared to the historical instance received as input. In essence, we have redistributed the load\\footnote{The principle of \\textbf{conservation of time} is respected as observed on the \\texttt{Average} and Total Time columns of the table.} so that some people will not need to be working \\textbf{overtimes} hence resulting in efficiency cost cuts for Royal Mail. A side-effect of our scheduling is that some drivers will be working a bit more. As far as Royal Mail is concerned this is a welcome change since it means we will be utilising the drivers' time better.\n\n\\vspace{\\baselineskip}\n\\noindent\nIt is evident in the historical schedule in Figure \\ref{fig:1-D1M1}(b) that duties lasting between 8-11.7 hours take a larger load of the work while the rest of the shifts carry out a smaller portion of the overall workload. By making an effort to redistribute the load in a more uniform fashion we are able to achieve a \\textbf{fairer allocation} of the amount of work required by assigning the load of the long lasting shift to the frequently occurring shifts of up to 8 hours and 25 minutes. We distributed the load from the previously shorter and longer lasting shifts to those frequently occurring ones. The outcome, was an increase in the duration of the shorter lasting shifts resulting in a fairer allocation of the load. However, this also resulted in an increase in the frequency with which the around 8 hour lasting shifts occur. This is an unwanted side-effect of this redistribution of load since even though we reduce the toll taken by the most frequently occurring shift, we distribute a portion of it on the longer-lasting shifts which are already overwhelmed. \n\n\\vspace{\\baselineskip}\n\\noindent\nA synopsis of the statistics that highlight the performance of our model for the Historical schedule as the input instance is found below:\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n\\begin{tabular}{c|c|c}\n        \\textbf{Schedule} & \\textbf{Makespan Reduction (\\%)} & \\textbf{Maximum Difference-Reduction \\cite{maxdif} (\\%)} \\\\\n        \\hline\n         Historical\\_Optimised & 28\\% & 72\\% \\\\\n\\end{tabular}\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation - Optimising Redefined Instance}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|c|c|c|c|c|c|c|}\n        \\hline\n        \\textbf{Instance} & \\multicolumn{3}{|c|}{ \\textbf{Characteristics}} & \\multicolumn{3}{|c|}{ \\textbf{Blocks (HH:mm)}}  \\\\\n        \\hline\n        & \\texttt{Duties} & \\texttt{Blocks} & \\texttt{Activities} & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Maximum} \\\\\n        \\hline\n        Historical & 183 & 462 & 3,285 & 03:05 & 00:40 & 08:25 \\\\\n        \\hline\n        Redefined & 183 & 462 & 2,850 & 02:25 & 00:30 & 06:35 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n\n\\vspace{\\baselineskip}\n\\noindent\nWe now apply model (\\ref{equation: Makespan Scheduling}) to an instance of the Redefined\\footnote{Introduced in Section \\ref{section: Redefined Dataset} of the previous chapter.} blocks and compare the model's performance with the optimal schedule, previously generated. As mentioned in Section \\ref{section: Redefined Dataset}, the Redefined instance is expected to lead us to a better solution, with respect to makespan, since it contains \\textbf{less activities} and consequently \\textbf{less labour hours to be scheduled}, due the deletion of the non-useful activities. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}%\n    \\centering\n    \\subfloat[The duration of each duty before and after optimisation sorted in increasing duration.]{%\\begin{center}\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D2.png}\n    }%\\end{center}}%picture #1\n    \\qquad\n    %picture #2\n    \\centering\n    \\subfloat[Histogram showing the improvement in the uniformity of duties.]{%\\begin{center}\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D2M1.png}\n    }%\\end{center}}%end of picture #2\n    \\caption{Illustrations of curves indicating our results.}%\n    \\label{fig:1-D2M1}%\n\\end{figure}\n \n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|l|c|c|c|c|}\n        \\hline\n        \\textbf{Schedule} & \\multicolumn{3}{|c|}{ \\textbf{Duties (HH:mm)}} & \\textbf{Total Time}  \\\\\n        \\hline\n         & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Makespan} & \\\\\n        \\hline\n        Historical  & 07:50 & 02:50 & 11:50 & 1,435:22 \\\\\n        \\hline\n        Historical\\_Optimised   & 07:50 & 05:15 & 08:25 & 1,435:22 \\\\\n        \\hline\n        Redefined\\_Optimised   & 06:06 & 03:55 & 07:27 & 1,118:58 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n \n\\vspace{\\baselineskip}\n\\noindent\nObserving the Histogram chart in Figure \\ref{fig:1-D2M1}(b), we can see that long lasting shifts have been reduced down to duty lengths which are at the very least, smaller than 7 hours and 27 minutes which is the longest lasting shift (i.e. makespan). The majority of the workload has been assigned to such shifts lasting longer than 6 hours but also generally below the 7 hour mark. With respect to the makespan we see a \\textbf{36\\% reduction} compared to the historical instance.\n\n\\vspace{\\baselineskip}\n\\noindent\nThe duty that pushes the makespan up to the 07:27 mark occurs only once, and the reason behind its increased duration relative to the bulk of shorter-lasting duties is because it holds the longest lasting block of 6 hours and 35 minutes. As a result, we could argue that the effective makespan of the Redefined schedule is slightly lower in reality since the majority of the duties last approximately 6 and a half hours. Hence, practically the whole cohort of drivers would have to work for 6 and a half hours, except for a single driver that would have to perform the 7 hours and 27 minutes lasting duty.\n\n\\vspace{\\baselineskip}\n\\noindent\nIn terms of encapsulating the performance of generated schedule in a more concrete manner we list the following table outlining how the optimised schedule fairs against our two evaluation criteria:\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n\\begin{tabular}{c|c|c}\n        \\textbf{Schedule} & \\textbf{Makespan Reduction (\\%)} & \\textbf{Maximum Difference-Reduction (\\%)} \\\\\n        \\hline\n         Historical\\_Optimised & 28\\% & 72\\% \\\\\n        \\hline\n         Redefined\\_Optimised  & 36\\% & 78\\% \\\\ \n\\end{tabular}\n\\end{table}\n\n\\vspace{\\baselineskip}\n\\noindent\nComparing the optimised schedules that are created from the Historical and Redefined Instances respectively we see that as expected there is a further reduction of 8\\% in the makespan of the Redefined schedule, and also the Redefined schedule has a 6\\% lower standard deviation, capturing the fact that it is even more uniform than the Historical schedule. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation - Optimising Departure Wave Instances}\nAs a final experiment on the Makespan Scheduling model we break our problem into separate instances that are designed to resemble the observation made through analysing the dataset\\footnote{The \\texttt{starting-time} analysis of the dataset mentioned is presented in detail in Appendix \\ref{subsection: Appendix Starting times} for interested readers.} concerning the fact that duties tend to start in \\textbf{wave}-like clusters. This observation is an important, design parameter that needs to be taken into serious consideration, as it automatically renders any results that we are able to obtain more \\textit{practically oriented} and easier to realise from the perspective of Royal Mail. As outlined in Section \\ref{section: Wave Instances - Data} we split our dataset into three autonomous sub-problems and we once more run the Makespan Scheduling model.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n    \\begin{tabular}{|l|c|c|c|c|c|c|c|}\n        \\hline\n        \\textbf{Schedule} & \\multicolumn{2}{|c|}{ \\textbf{Characteristics}} & \\multicolumn{3}{|c|}{ \\textbf{Duties (HH:mm)}} & \\textbf{Total Time}  \\\\\n        \\hline\n        & \\texttt{Duties} & \\texttt{Blocks} & \\texttt{Average} &  \\texttt{Minimum} & \\texttt{Makespan} & \\\\\n        \\hline\n        Historical\\_Optimised & 183 & 462  & 07:50 & 05:15 & 08:25 & 1,435:22 \\\\\n        \\hline\n        Morning\\_Optimised & 59 & 114 & 06:46 & 00:00 & 08:25 & 393:40 \\\\\n        \\hline\n        Afternoon\\_Optimised & 61 & 145 & 07:32 & 03:25 & 07:19 & 444:53 \\\\\n        \\hline\n        Night\\_Optimised & 63 & 203 & 09:27 & 08:40 & 09:30 & 596:34 \\\\\n        \\hline\n    \\end{tabular}%\n    \\medbreak\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}\n\\minipage{0.32\\textwidth}\n\\subfloat[Morning]{%\\begin{center}\n  \\includegraphics[width=\\linewidth]{[2] - chapter/Image Files/morning.png}}\n\\endminipage\\hfill\n\\minipage{0.32\\textwidth}\n\\subfloat[Afternoon]{%\\begin{center}\n  \\includegraphics[width=\\linewidth]{[2] - chapter/Image Files/afternoon.png}}\n  \n\\endminipage\\hfill\n\\minipage{0.32\\textwidth}%\n\\subfloat[Night]{%\\begin{center}\n  \\includegraphics[width=\\linewidth]{[2] - chapter/Image Files/night.png}}\n \n\\endminipage\n\n\\caption{The effects of Makespan Scheduling when considering our problem in Wave Instances.}\n\\label{fig: Wave Makespan Scheduling}\n\\end{figure}\n\n\\vspace{\\baselineskip}\n\\noindent\nThe effects of re-organising our problem in such a fashion can be observed in Figure \\ref{fig: Wave Makespan Scheduling}. Upon splitting our data into the three wave instances (\\texttt{morning, afternoon, night})\\footnote{The instances are listed in detail in Appendix \\ref{subsection: redefine appexnix}} one can see that overall, the wave sub-instances do not consistently behave either better or worse than the schedule of the whole dataset seen previously in Figure \\ref{fig:1-D1M1}(b). More specifically, in the \\texttt{morning, afternoon} waves we can create schedules with a \\textit{makespan} of around or below the makespan of the whole instance at the \\textbf{08:25} mark, hence corroborating the fact that in an ideal schedule for the whole instance, the majority of duties should be of length below the 8 and a half hours mark obtained previously.\n\n\\vspace{\\baselineskip}\n\\noindent\nIt is only in the \\texttt{night} wave that we observe a sub-optimal makespan, relative to the other two. The \\texttt{night} wave's makespan is beyond the 08:25 hour mark at 9 and a half hours. A sound argument behind this sub-optimal performance is to observe that the \\texttt{night} wave has considerably more overall labor time to allocate than the other two instances. Moreover, it only has at most four more duties to allocate that time to, compared to the other two instances. Hence, the combination of more time to be scheduled and the limit amount of flexibility provided by the small amount of extra duties that the model has at its disposal to allocate that additional time to, lead to this sub-par performance with respect to the makespan.\n\n\\vspace{\\baselineskip}\n\\noindent\nOn the other hand, the reason behind the great performance of our model in the \\texttt{afternoon} instance could be zeroed down to the fact that the \\texttt{afternoon} wave has the largest timespan out of the three waves (09:00-16:00), as can be seen in Table \\ref{table:Starting Waves}, of Appendix \\ref{subsection: Appendix Starting times}. Given, that it has a drastically bigger timespan, in fact equal to the sum of the other two instances, it might prove slightly easier to assign very late and very early starting duties since there will be more flexibility due this increased timespan.\n\n\\vspace{\\baselineskip}\n\\noindent\nFinally, we can see in Figure \\ref{fig: Wave Makespan Scheduling}(a) that although the \\texttt{morning} wave performs respectably with respect to its makespan, it lacks in its uniformity of the schedule compared to the other two wave instances, which enjoy a much tighter bandwidth. The non-optimised historical morning wave instance that our model receives as input could be identified as the cause for this lack of uniformity. More specifically, \\ref{fig: Wave Makespan Scheduling}(a)-(c) we can see that the historical input instance for the \\texttt{morning} is the least uniform out of the three. More importantly, it is \\textit{right-skewed} when compared to the other two, hinting at the existence of numerous shorter-lasting shifts. As a result, our model is largely struggling to allocate the redistributed load from the longer lasting shifts to these shorter-lasting due to their small durations.  \n\n\\vspace{\\baselineskip}\n\\noindent\nThese individual findings for each wave sub-instance justify the fact that the most frequently occurring duties in the whole dataset tend to have a duration between 6-8 hours. In addition, it is the shifts of the \\texttt{night} wave, which contain the biggest portion of schedulable time, that end up contributing to pushing the makespan beyond 6 hours up to the 08:25 mark. \n\n\\vspace{\\baselineskip}\n\\noindent\nAll in all, by approximating the real-world through adding such constraints to our problem that make it more realistic in terms of its ease of implementation, for our Industrial Liaison, we have determined that the efficiency of our schedules is \\textbf{not} significantly \\textbf{compromised}. The \\textit{makespan}, of the optimal schedule compared to that of the historical one is \\textbf{equal or smaller} for two of the three waves. In addition, the optimised schedules are much more \\textbf{uniform} than their historical equivalent, as seen in the table below\\footnote{Each wave-optimised schedule is compared with its wave sub-instance for the table's evaluation criteria. Effectively, for each chart of Figure \\ref{fig: Wave Makespan Scheduling} we compare the optimised schedule with the input wave instance.}:\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{table}[h]\n\\small\n    \\centering \n\\begin{tabular}{l|c|c}\n        \\textbf{Schedule} & \\textbf{Makespan Reduction (\\%)} & \\textbf{Maximum Difference-Reduction (\\%)} \\\\\n        \\hline\n         Historical\\_Optimised & 28\\% & 72\\% \\\\\n        \\hline\n         Morning\\_Optimised  & 28\\% & 14\\% \\\\ \n         \\hline\n         Afternoon\\_Optimised  & 29\\% & 76\\% \\\\ \n         \\hline\n         Night\\_Optimised  & 19\\% & 80\\% \\\\ \n\\end{tabular}\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SECTION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Trade-off between Number of Completed Duties and Maximum Duty Length}\n\\label{section:minimise duties}\nUpon proving that there exists significant room for improvement with respect to the historical schedule's makespan we re-examined the historical schedule to see if there are other aspects of it that could be improved. After a careful observation of the dataset we noticed that there are potentially too many duties in the historical schedule. Consequently, people have to work a lot to carry out all those duties. To remedy this, we attempt to minimise the number of duties that are required to complete the same amount of workload (i.e. same amount of blocks). \n\n\\vspace{\\baselineskip}\n\\noindent\nProvided we are able to decrease the number of duties for the same amount of blocks, this would translate to people working less, since there would be less duties requiring completion. In practical terms this amounts to a transformation of our problem to a Bi-Objective Generalised Assignment Problem \\cite{PRAKASH2010} since it aims to \\textbf{minimise} the \\textbf{maximum duty length}, while also \\textbf{minimising} the \\textbf{number of duties}. \n\n\\vspace{\\baselineskip}\n\\noindent\nTo solve this problem we need to develop an algorithm that will provide us with the Pareto Optimal points of the problem. Those points will represent Pareto Optimal schedules, and our Industrial Partners can evaluate each of those schedules to select the one that best fits their company policy requirements. We rely upon the formulation of the previous section but shift the focus of the minimisation problem onto minimising the number of duties that need to be operational to carry out the required tasks. We hypothesise that we can fix an upper threshold for the duty length ($L$). We hence assume that people have to work $L$ hours, and not any more than that. \n\n\\vspace{\\baselineskip}\n\\noindent\nFor the purposes of our solver that means that it can schedule duties that are only as long as that threshold. The solver hence, has at its disposal duties that are subject to this upper bound to and has to attempt to fit all the blocks inside of them. In practice this is enforced by creating a constraint that applies this upper bound restriction to the duties' lengths. We hence, take the minimisation of the duration out of the objective function of this problem but it remains in spirit as the secondary objective that we will attempt to minimise through our sensitivity analysis.\n\n\\vspace{\\baselineskip}\n\\noindent\nThe variable $y_{i}$ contains a value that specifies the number of duties $i$ that are \\textbf{required}. Similarly to the previous formulation binary variable $x_{i,j}$ dictates the assignment of a block $j$ to a duty $i$ and is equal to 1 if the atomic block $j \\in B$ is assigned to duty $i \\in D$, and 0 otherwise.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Maths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{\\baselineskip}\n\\begin{equation}\n\\label{equation: Minimise Duties}\n\\begin{aligned}\n&\\text{minimise}\n& & \\sum _{i=1}^m y_{i}  \\\\\n& \\text{subject to}\n& & y_{i} \\geq x_{i,j}  \\;\\;\\; &\\forall \\; i \\in D,\\; j \\in B\\\\   \n& & &\\sum _{i=1}^m x_{i,j} = 1 \\;\\;\\; &\\forall \\; j \\in B\\\\\n%& & &\\sum _{j=1}^n x_{i,j}p_{j} \\leq f_{i}-s_{i} \\;\\;\\; &\\forall \\; i \\in D\\\\\n& & &\\sum _{j=1}^n x_{i,j}p_{j} \\leq L \\;\\;\\; &\\forall \\; i \\in D\\\\\n& & & y\\geq 0  \\\\\n& & & x_{i,j} \\in  \\{ 0,1 \\} \\;\\;\\; &\\forall \\; j \\in B, \\; i \\in D\\\\\n\\end{aligned}\n\\end{equation}\n\n\\vspace{\\baselineskip}\n\\noindent\nThe model minimises the number of active duties. The first constraint makes sure that a duty $i$ is counted as active if at least one of the $x_{i,j}$ is equal to 1. The second constraint makes sure that each atomic block is executed by one and only one duty. Finally, the third constraint makes sure that the contents of a duty do not exceed the maximum duty length threshold $L$. This maximum duty length is determined by the hyper-parameter $L$ that we supply as input to the model 36 times to complete the sensitivity analysis. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation}\n\\vspace{\\baselineskip}\n\\noindent\nUsing this formulation we investigate the number of active duties that can be reduced for various levels of the maximum duty length. This investigation is carried out by conducting a sensitivity analysis, where we vary the hyper-parameter $L$ and measure the number of duties required. A particularly important threshold that we choose to focus on is that of setting \\textit{L} equal to the maximum duty length observed in the historical schedule. This will allow us to determine the optimal number of duties that could have been used instead of the historically used 183 duties utilised by Royal Mail. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}%\n    \\centering\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D1M2.png}\n    \\caption{Depicts the number of duties required as a function of the Maximum Duty Length varied in 30 minute intervals, up to an \\textit{upper threshold} of \\textbf{24 hours} per duty.}\n    \\label{fig:1-D1M2}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection*{Qualitative Results}\nIn Figure \\ref{fig:1-D1M2} we plot the result of the sensitivity analysis. In more detail, through utilising the principle of the Pareto front we computed the efficient frontier seen in Figure \\ref{fig:1-D1M2} by applying algorithm (\\ref{alg: Pareto}) 36 times\\footnote{\\label{Pareto}Seen in Section \\ref{section: Pareto} of Chapter \\ref{chapter: Background}} between a minimum and maximum \\textit{L}. Hence, the trade-off curve shows the sensitivity analysis in its entirety applying the Pareto algorithm from a maximum \\textit{L} of 24 hours down to a minimum \\textit{L} of around 8 and half hours, that still provides a feasible schedule. Obviously, we cannot expect an individual to complete duty lasting 24 hours, however, we present the Pareto front to allow the flexibility for our industrial partner. Figure \\ref{fig:1-D1M2} shows that if the maximum duty length increases the number of duties required decreases significantly. \n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection*{Quantitative Results}\nAs mentioned before although it might not be directly reflected in equation (\\ref{equation: Minimise Duties}) this is principally a Bi-Objective problem where the two objectives minimised are the maximum duty length (\\textit{L}) and the number of duties. As result, on the left end of the curve one can see the value of \\textit{L} for which the objective regarding the minimisation of \\textit{L} is best satisfied. As observed in Figure \\ref{fig:1-D1M2} that minimal value of \\textit{L} is equal to 8.417 hours\\footnote{Which amounts to 8 hours and 25 minutes.} and this allows us to complete all blocks in the original 183 duties. Hence, we have identified an optimisation opportunity since it is possible to allocate the same workload into a schedule with \\textbf{shorter maximum lasting duty} compared to the historical practices. A careful observer will recognise that this exact finding was been seen in an earlier stage of this report. Namely, this value for the maximum duty length, coincides exactly with the value found for the Makespan of the optimal schedule in Section \\ref{section:Makespan Scheduling-content}. Consequently, we can be sure that the schedule with $L=8.417 \\text{ hours}$ is a Pareto optimal schedule that satisfies the minimisation of the maximum duty length objective of this problem.\n\n\\vspace{\\baselineskip}\n\\noindent\nMoreover, looking at the rest of the curve we can see that we have determined that we are able to reduce the amount of duties required significantly, as we increase hyper-parameter $L$. Using the \\textit{L}-\\textbf{threshold} of around 12 hours currently utilised by Royal Mail allows us to use a mere 128 duties compared to the 183 required by Royal Mail. This translates to a \\textbf{30\\%} reduction in the duties that need to be fulfilled for the same maximum duty length (\\textit{L)}. Practically this means that if a small portion of the drivers is able to complete overtime duties (up to that 12 hours threshold) the remaining cohort of drivers would be able to work less since there would be less duties to be completed. \n\n\n\\vspace{\\baselineskip}\n\\noindent\nThe realisation that Royal Mail's current operating scenario is not on the Pareto frontier, is another indication that there is a substantial need for optimisation that will most likely lead to opportunities for cost cuts once Royal Mail places itself on the frontier. Taking into account the reality-based constraints that would constrict the provision of more efficient scheduling, we proceed to propose the most optimal but realistic schedule that Royal Mail can aim towards. That practical limit is founded in the fact that the maximum number of labor hours per day for an individual is a total of 13 hours as determined by EU rules\\footnote{Seen in Appendix \\ref{section: EU rules}}. If we proceed to utilise a maximum duty length $(L)$ of 13 hours the Pareto optimal schedule that we can achieve requires merely 115 duties to be completed. This would be a significant decrease over the 183 duties of the historical solution.\n\n\\vspace{\\baselineskip}\n\\noindent\nFinally, looking at the \\textbf{theoretical optimal schedule} with respect to the other objective of this problem (i.e. minimal \\textit{L}) we claim in theory we can do even better than a schedule with $L=8.417 \\text{ hours}$. The most optimal schedule that we can hope to achieve is a schedule with a maximum duty length equal to that of the average duty duration of the input instance. That is because such a schedule would be equivalent to spreading the total schedulable hours equally to all 183 available duties. The historical schedules contained 183 duties with an average duty length 7 hours and 50 minutes, equivalent to 1435 hours and 22 minutes of total workload. We can see that the lowest feasible threshold for our maximum duty length in Figure \\ref{fig:1-D1M2} is that of 8 hours and 25 minutes. This indicates that there an optimality gap between the ideal maximum duty length and the practical one. This is to be expected, due to the fact that the theoretical optimum could only be achieved if we neglect assumption (1) from Section \\ref{section: 4.1}. In reality the atomic blocks in the input instance have an arbitrary size and hence we cannot obtain an exact fit of the blocks to all duties that sums to 7 hours and 50 minutes.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}%\n    \\centering\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D2M2.png}\n    \\caption{Compares the number of duties required as a function of the Maximum Duty Length for the Redefined and Historical instances.}\n    \\label{fig:1-D2M2}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\subsection*{Evaluation - Optimising Redefined Instance}\nWe proceed to apply the Redefined instance, to model (\\ref{equation: Minimise Duties}) in order to determine whether applying this more realistic instance will further improve the two objectives of our problem. For the historical instance, our optimisation was able to minimise the number of duties by around 30\\% for an \\textit{L} equal to Royal Mail's historical threshold. When applying the Redefined instance we expect an additional decrease in the number of required duties for the same \\textit{L}. The expectation is founded in the fact that, in this new instance there is less overall schedulable time. Hence, that means that for the same maximum duty length, we can fit more blocks per duty which will directly result in less duties being used overall. \n\n\\vspace{\\baselineskip}\n\\noindent\nIndeed, were able to carry out the same amount of block with \\textbf{47\\%} less duties, namely merely 96 duties as seen in Figure \\ref{fig:1-D2M2}. This result justifies our quest for optimisation, since it identifies that Royal Mail's current practices are once again outside the \\textit{efficient frontier} line. \n\n\\vspace{\\baselineskip}\n\\noindent\nObserving the Figure \\ref{fig:1-D2M2}, we can see that this additional reduction in required duties, is mostly due to the step change in \\textit{idle time} that we are able to achieve from deleting the \\textit{non-useful} activities within the blocks. However, as is shown in Section \\ref{section: Redefined Dataset} the idle time that we gain is on average 1 hour and 44 minutes per duty. Moreover, we saw in Section \\ref{section:Makespan Scheduling-content} that the average size of a block is on average 2 hours and 25 minutes for the Redefined instance. As a result of those two facts we can determine why the application of the model on the Redefined yields only an additional small improvement of 17\\% in the number of duties deleted compared to the 30\\% improvement obtained in the Historical instance. The explanation is found in the fact despite the increase in idle time there is still not enough space to re-allocate the deleted duties' blocks to other duties, since the average idle time gain (of 01:44) per duty, is significantly smaller than the average size of the block (02:25), hence there are generally not too many blocks that can be relocated to other duties so that we can delete their original duty.\n\n\n\\vspace{\\baselineskip}\n\\noindent\nOnce again, if we attempt to determine the \\textbf{theoretical optimal schedule} for the Redefined instance we would expect to obtain a schedule with maximum duty length (\\textit{L}) of 6 hours and 06 minutes\\footnote{Such that \\textit{L} coincides with the Redefined schedule's average duty length seen in Section \\ref{section: Redefined Dataset}}. Given that as we saw in Figure \\ref{fig:1-D2M2} we can only go as low as an  $L=6.4 \\text{ hours}$\\footnote{Which amounts to 6 hours and 24 minutes.}  we can see there exist an optimality gap between the schedule with the ideal maximum duty length and the one we can practically obtain. This is once again due to the fact that atomic blocks have an arbitrary size and hence the solver more often than cannot find a duty length that fits all blocks exactly. \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Maximising the Number of Completed Duties with Limited Driver Time}\n\\label{section: maximise blocks}\nHaving created the sensitivity analysis that identified the minimum number of required duties for each value of \\textit{L} we proceeded to solve the directly symmetric problem. More specifically, in Figure \\ref{fig:1-D1M1} of Section \\ref{section:minimise duties} the left end of the curve informed us that the most tight feasible schedule we can possible create is one where the maximum duty length (\\textit{L}) is equal to 8.417 hours. Being aware aware of that we would like to move towards infeasibility and discover the schedules that are to the left of that Pareto optimal schedule with $L=8.417 \\text{ hours}$.\n\n\\vspace{\\baselineskip}\n\\noindent\nThe reasoning behind conducting this experiment is to determine the effect the decrease of \\textit{L} and the transition towards infeasibility will have on the processing capacity of the MC. More specifically, given that we are moving towards infeasibility, we are aware that we will no longer be able to create a feasible schedule, i.e. a schedule that manages to fit in all blocks, since we have determined that an $L=8.417 \\text{ hours}$ is the least maximum duty length that can fit all the 183 blocks. Hence, further decreasing \\textit{L} will certainly result in not enough schedulable time to fit all the blocks inside the schedule. \n\n\\vspace{\\baselineskip}\n\\noindent\nThe practical purpose of this experiment is to investigate the degree to which we see a degradation in the processing capacity of the MC as we decrease \\textit{L}. In practice to perform this experiment we maximise the number of blocks that can be completed for each value of \\textit{L}, by creating another sensitivity analysis. By decreasing $L$ we obviously will no longer be able to complete everything, so the question posed is what is the maximum amount of work (i.e. number of blocks) that we can manage to accomplish for each \\textit{L}. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Maths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{\\baselineskip}\n\\begin{equation}\n\\label{equation: M3}\n\\begin{aligned}\n&\\text{maximise}\n& & \\sum _{i=1}^m x_{i,j}  \\\\\n& \\text{subject to}\n& &\\sum _{i=1}^m x_{i,j} \\leq 1 \\;\\;\\; &\\forall \\; j \\in B\\\\\n& & &\\sum _{j=1}^n x_{i,j}p_{j} \\leq L \\;\\;\\; &\\forall \\; i \\in D\\\\\n& & & y\\geq 0  \\\\\n& & & x_{i,j} \\in  \\{ 0,1 \\} \\;\\;\\; &\\forall \\; j \\in B, \\; i \\in D\\\\\n\\end{aligned}\n\\end{equation}\n\n\\vspace{\\baselineskip}\n\\noindent\nThe model maximises the number of blocks processed, for the given constraints. The first constraint applies the allowance of non-feasible schedules. It allows for a block to not be processed by a duty. The third constraint makes sure that the contents of a duty do not exceed the maximum duty length threshold $L$ as seen in the previous formulation. This maximum duty length is varied to then complete the sensitivity analysis. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D1M3.png}\n    \\caption{Depicts the number of blocks that can be processed as a function of the Maximum Duty Length varied in 30 minute intervals, up to an \\textit{upper threshold} that provides the first schedule that is feasible.}\n    \\label{fig:1-D1M3}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation}\nApplying equation (\\ref{equation: M3}) to the \\textbf{historical} instance and by repeating this process in conjunction with the Pareto algorithm (\\ref{alg: Pareto}) 18 times we receive the curve \\ref{fig:1-D1M3} depicting the results of the sensitivity analysis. In the study of this problem we keep the amount of duties fixed to 183 available, and are only concerned with the effects on the processing capacity of the schedule (i.e. the amount of blocks that can fit in those duties).\n\n\\subsubsection*{Qualitative Results}\nThe trade-off curve shows the efficient frontier that we have created in its entirety. The frontier, shows us that as expected while we decrease the value of \\textit{L} the schedules that we are able to create have an ever-decreasing processing capacity since as we can see they are able to process a continuously decreasing amount of blocks. The right end of the curve shows the only feasible schedule featured on this curve. That point with $L=8.417 \\text{ hours}$ is the meeting point between the problem that we are currently solving and its symmetric that was studied in Section \\ref{section:minimise duties}. The symmetry of the two problems is confirmed through this function since the schedule rightmost schedule of Figure \\ref{fig:1-D1M3} coincides with the leftmost schedule of Figure \\ref{fig:1-D1M2} since they both refer to schedules with 183 duties, 462 blocks processed and an $L=8.417 \\text{ hours}$.\n\n\\subsubsection*{Quantitative Results}\nAnother interesting finding concerns the relationship between the degradation of the processing capacity as a function of \\textit{L}. As we can see in Figure \\ref{fig:1-D1M3} if we reduce the duty length by 2 hours, (\\textbf{25\\% reduction}), the decrease in duties that can be performed is only of the order of magnitude of \\textbf{10\\%}. This finding is in the direction of obtaining the trade-off relationship between finding the maximum duty length and the effect it has on the processing capacity of the MC. A practical understanding provided by this finding is that if we decrease \\textit{L} by this 2 hour interval i.e. down to around 6 and a half hours, we will not have a proportional decrease in the processing capacity. From the perspective of Royal Mail, this insight could mean that we could allow a small portion of people to work part-time if they so wish. This insight is explained by the fact that this group of part-time employees could carry out that \\textbf{10\\%} of blocks that are left unscheduled. Moreover, since they would only work part-time they would work considerably less hours, hence allowing for the decrease seen in \\textit{L} of the order of textbf{25\\%}. These insights are not concrete proof that this would work for Royal Mail, but they show that significantly reducing drivers' work time results in a not so significant reduction in the number of blocks that can be processed.\n\n\\subsection*{Evaluation - Optimising Redefined Instance}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{figure}%\n    \\centering\n    \\includegraphics[width=0.46\\linewidth]{[1] - chapter/Image Files/1-D2M3.png}\n    \\caption{Compares the number of blocks that can be processed as a function of the Maximum Duty Length for the Redefined and Historical instances.}\n    \\label{fig:1-D2M3}\n\\end{figure}\n\n\\vspace{\\baselineskip}\n\\noindent\nIn a similar fashion to the case of the results from the Redefined instances in Section \\ref{section:minimise duties}, the application of the Redefined instances provides marginally better results. In more detail, as seen in Figure \\ref{fig:1-D2M3}, the processing capacity of the schedules generated based on the Redefined instances is hindered ever so slightly less, in comparison to the Historical instance's. That is an expected phenomenon, since as we mentioned before the blocks of the Redefined instances, contain naturally smaller blocks, since they do not consider the redundant activities. As a result, more of them can generally fit in the same 183 duties, which explains the smaller degradation in the processing capacity for the same level of \\textit{L} compared to the Historical instance's schedules. \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Load Balancing with Pre-emptions}\n\\label{section: Pre-emptive}\nThe final experiment run in this chapter involves the further investigation of the \\textbf{theoretical optimal schedule} discussed in the final parts of the evaluations of the prior sections. In all three prior sections, we saw that there exists an absolute theoretical limit that would give us the corresponding \\textbf{theoretical optimal schedule} with respect to the makespan objective. However, we also saw that the most optimal schedules that our solver was able to come up with would always have a certain optimality gap to that theoretical schedule. That theoretical schedule has been obtained through theoretically hypothesising that we can split the total schedulable labor hours equally in duties of equal length. Unlike, the other schedules discussed in this chapter it has not been obtain as an output from our solver. The purpose of exploring this topic is to investigate how close we can get to that theoretical limit with a schedule generated by our solver if we relax some of the design principles of our makespan formulation. \n\n\\vspace{\\baselineskip}\n\\noindent\nIt is normal to expect that completely achieving the theoretical limit is not a possibility. That is because as explained in the previous sections to obtain that theoretically optimal schedule we would have to completely disregard the structure of our components. Namely, we would have to discretise our activities and blocks with a very high frequency, effectively rendering them a collection of time instants that can exactly fit in duties of any length. However, that experiment is of little utility to us. In investigating how close we can get to approaching the theoretical limit, we choose to only breakdown the size of the blocks, but maintain the structure and processing times of the activities intact. Hence, we still expect not to be able to completely approach the theoretical limit, because cases where activities lengths' do not exactly fit in duties are expected to occur.  \n\n\n\\vspace{\\baselineskip}\n\\noindent\nTo develop a schedule that approaches the theoretical limit we ran the MIP seen in Section \\ref{section:Makespan Scheduling-content}, but by allowing the model to act \\textbf{preemptively}. Non-pre-emptive formulations were used in all previous three models. By disregarding this design parameter we grant the model complete freedom in terms of the policy with which it can process each block. Effectively, we provide it with an additional degree of freedom that allows it to switch between blocks while processing one already. Effectively, it is allowed to process activities from different blocks even after having begun the processing of an activity from a different block. \n\n\\vspace{\\baselineskip}\n\\noindent\nIn practice, we carry this out by supplying instances of $I = \\langle{m},\\langle{B},A\\rangle{}$ of the problem in an environment of $D=\\{1,...,m\\}$ parallel duties. However, in addition to a set of blocks we provide a set of activities $A =\\{1,...,n\\}$. The Historical instance utilised contained 3,285 activities that were allocated once again among a set of 183 duties. \n\n\\vspace{\\baselineskip}\n\\noindent\nThrough supplying activities as the component to be scheduled, the model is now \\textbf{pre-emptive} with respect to blocks, since the solver is allowed to move activities around within each duty hence, breaking the original structure of the blocks. Consequently, we have allowed the model to switch between blocks by allowing it to start processing an activity from one block and then switch to processing an activity from a different block. The activities $j \\in A$ all have their processing time $p_{j}$ as before. \n\n\\vspace{\\baselineskip}\n\\noindent\nThe \\textit{MILP} is marginally changed. The biggest change is seen in the constraint: $\\sum _{i=1}^m x_{i,j} = 1$ which is converted to $\\sum _{i=1}^m x_{i,j} = p_j$ \\cite{DUMMY:2}. Moreover $x_{i,j}$ are no longer binary variables. Variables $x_{i,j}$ now represent the time each block spends on each machine compared to whether machine \\textit{i} executes job \\textit{j} as before.\n\n\\vspace{\\baselineskip}\n\\noindent\nAs a result formulation (\\ref{equation: Makespan Scheduling}) from Section \\ref{section:Makespan Scheduling-content} becomes:\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Maths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\vspace{\\baselineskip}\n\\begin{equation}\n\\label{equation: Makespan preemptive}\n\\begin{aligned}\n&\\text{minimise}\n%& & y_{i}  \\\\ %\\todo{why y and and not yi}\n& & y  \\\\ \n& \\text{subject to}\n% & & y_{i} = \\sum _{j=1}^n x_{i,j}p_{j}  \\;\\;\\; &\\forall \\; i \\in D\\tag{1}\\\\   \n& & y\\geq \\sum _{j=1}^n x_{i,j}  \\;\\;\\; &\\forall \\; i \\in D\\\\   \n& & &\\sum _{i=1}^m x_{i,j} = p_j \\;\\;\\; &\\forall \\; j \\in B\\\\\n& & &y \\geq \\sum _{i=1}^m x_{i,j}  \\;\\;\\; &\\forall \\; j \\in B\\\\\n% & & &\\sum _{j=1}^n x_{i,j}p_{j} \\leq f_{i}-s_{i} \\;\\;\\; &\\forall \\; i \\in D\\\\ %{\\color{red} we deleted the constraint that involves the length of duty being less than end-start.}\n& & & y,x_{i,j}\\geq 0  \\\\\n\\end{aligned}\n\\end{equation}\n\n\\vspace{\\baselineskip}\n\\noindent\nThe problems objective is once again to minimise the \\textbf{makespan} while obtaining a feasible schedule. The first constraint assigns $y$ its definition of the \\textbf{makespan}, since the makespan must be greater or equal to the completion time of the longest lasting machine. With the second constraint we ensure that each job is performed to completion on the various machines that process it. The final constraint ensures that no block is processed for more total time than the makespan itself.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation}\nTo investigate how close we can approach to the theoretical limit of the maximum duty length, we attempt through this experiment to establish a practical lower-bound solution. As mentioned in the beginning of this section, we do not expect to achieve the \\texttt{absolute theoretical limit}. But by investigating the effects a preemptive model would have on our results, we can obtain a realisable best possible solution that we can hope to achieve. The \\texttt{absolute theoretical limit} is that of a maximum duty length equal to the average duty length of the instance, which in the case of the Historical instance is equal to 7 hours and 50 minutes.\n\n\\vspace{\\baselineskip}\n\\noindent\nThe results of the preemptive model hints to a lower-bound for the maximum duty length of 8 hours and 5 minutes. Compared to the makespan of 8 hours and 25 minutes this is a significant improvement in the maximum duty length. In fact this is a \\textbf{7\\%} improvement in the optimality gap with the \\texttt{absolute theoretical limit}. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sub-SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection*{Evaluation - Optimising Redefined Instance}\nWe repeat the process outlined above to calculate the effect of pre-emption on the Redefined instance. We ran the MILP (\\ref{equation: Makespan preemptive}) but with an instance containing 2,850 activities that were once again allocated among a set of 183 duties. The \\texttt{absolute theoretical limit} in this case would be to obtain a schedule where \\textit{L} would be equal to the average duty length of the instance (i.e. 06:06). \n\n\\vspace{\\baselineskip}\n\\noindent\nUpon running the pre-emptive model on the instance we obtain a practical lower-bound of 6 hours and 32 minutes. Similar to the prior case of the Historical instance this is a significant improvement over the previously obtained makespan of 7 hours and 27 minutes. In quantitative terms this is a bigger improvement compared to the Historical instance's case, of magnitude \\textbf{23\\%}.", "meta": {"hexsha": "fc2257a67c54b9f56e1ae6ed8987f3cfdf4f02a5", "size": 66380, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/.tex files/[2] - chapter/Mathematical Formulations.tex", "max_stars_repo_name": "liaskast/Final-Year-Project", "max_stars_repo_head_hexsha": "6943f5fc406891ae1635e42dff6e7fba28a2bffc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-06-21T21:22:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-26T14:12:36.000Z", "max_issues_repo_path": "Report/.tex files/[2] - chapter/Mathematical Formulations.tex", "max_issues_repo_name": "liaskast/Final-Year-Project", "max_issues_repo_head_hexsha": "6943f5fc406891ae1635e42dff6e7fba28a2bffc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/.tex files/[2] - chapter/Mathematical Formulations.tex", "max_forks_repo_name": "liaskast/Final-Year-Project", "max_forks_repo_head_hexsha": "6943f5fc406891ae1635e42dff6e7fba28a2bffc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 98.9269746647, "max_line_length": 1431, "alphanum_fraction": 0.6902078939, "num_tokens": 15431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4358806366777909}}
{"text": "\\documentclass[letterpaper,11pt]{article}\n\n\\input{macros}\n\\newcommand{\\loris}{\\textcolor[rgb]{0.00,0.00,1.00}}\n\n\\begin{document}\n\n\\title{Symbolic counter machines}\n\n\\author{...}\n\\maketitle\n\n\\section{Definition}\n\n\\begin{definition}\nA (nondeterministic) symbolic counter machine is a tuple $A=(Q,q_0,F,C,\\delta)$,\nwhere\n\\begin{itemize}\n\\item $Q$ is a finite set of states,\n\\item $q_0\\in Q$ is an initial state,\n\\item $F\\subseteq Q$ is a set of accepting states,\n\\item $C$ is a finite set of counters,\n\\item $\\delta$ is a transition relation containing tuples of the form\n\\begin{description}\n\\item[Test and set:] $(q,C_t,\\varphi,\\rho,q')$ such that:\n\\begin{itemize}\n\\item $q,q'\\in Q$ are the source and target states respectively;\n\\item $C_t\\subseteq$ is the subset of counters being tested;\n\\item $\\varphi \\subseteq lin(C_t)$ is a linear guard over the counters $C_t$; and\n\\item $\\rho\\subseteq lin(C_t)$ is a linear counter update that nondeterministically maps the counters $C_t$ to a value satisfying $\\rho$.\n\\end{itemize}\n\n\\item[Decrement:] $(q,c,q')$ such that $q,q'\\in Q$ are the source and target states respectively, and $c\\in C$ is a counter being decremented;\n\n\\end{description}\n\\end{itemize}\n\\end{definition}\n\n\nIntuitively the machine $A$ starts in state $q_0$ with all the counters set to $0$.\nEach test and set transition $(q,C_t,\\varphi,\\rho,q')$ checks whether the set of counters $C_t$ have\nvalues satisfying\n$\\varphi$ and, if this is the case, it updates the values of the \ncounters in $C_t$ to a value satisfying $\\rho$.\nEach decrement transition $(q,c,q')$ subtracts $1$ from the value of the counter $c$.\nA run reaching the final state is a successful run.\n\n\\loris{TODO: define semantics formally}\n\n\\section{Reachability algorithm}\nThe reachability problem is to find whether, given two states $q_1$ and $q_2$ in $Q$ there exists a path from $q_1$ to $q_2$.\nWe solve this problem via a Kleene-style reachability algorithm.\n\nLet $S(q_1,q_2,R,V)$ be the set of counter values we can obtain when starting in state $q_1$ (with counter values 0) and reaching state $q_2$ such that:\n\\begin{itemize}\n\\item a path can use ONLY the test-and-set transitions in $R$ but all decrement transitions;\n\\item each counter $c\\in V$ must be reset at least once (in some sense $V\\subseteq V(R)$), and no other counter can be reset.\n\\end{itemize}\nWe can define this quantity as follows.\n\\[\n\\begin{array}{rcl}\nS(q_1,q_2,R, \\emptyset) & = &P\\text{ the semilinear set induced by all}\\\\\n&& \\text{decrement transitions from }q_1\\text{ to  }q_2\\\\\nS(q_1,q_2,R,V) & = &\\emptyset\\text{ if } \\neg V\\subseteq V(R)\\\\\n&&\\\\\nS(q_1,q_2,R,V) & = & \\bigcup\\limits_{r=(q_3,V_r, \\varphi, \\rho, q_4)\\in R} S(q_1,q_2, R\\setminus\\{r\\},V)\\\\\n&&\\\\\n& \\cup & \\bigcup\\limits_{V_1\\cup V_2 \\cup V_r=V} S(q_1,q_3, R\\setminus \\{r\\}, V_1) \\proj \\overline{V_2\\cup V_r}\\\\\n&         &  \\quad\\quad\\quad \\quad\\quad\\quad + S(q_4,q_2,R\\setminus\\{r\\}, V_2)\\\\\n&&\\\\\n & \\cup  & \\bigcup\\limits_{V_1\\cup V_2\\cup V_3 \\cup V_r=V} S(q_1,q_3, R\\setminus\\{r\\},V_1)\\proj \\overline{V_2\\cup V_3\\cup V_r}+\\\\\n&         &  \\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad + \\gamma(R\\setminus \\{r\\},r,V_2)\\proj \\overline{V_3\\cup V_r} \\\\\n&         &  \\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad  + S(q_4,q_2, R\\setminus \\{r\\},V_3)\\\\\n\\end{array}\n\\]\nThe interesting case is the third rule. \nFor each $r\\in R$ we take into account three possibilities:\n\\begin{itemize}\n\\item the paths that do not use $r$ but still reset all the variables in $V$;\n\\item the paths that use $r$ exactly once. In this case we iterate over all possible sets $V_1$ and $V_2$ for which the union is $V$ and assume that\n\t\tall the  that th\n\\item the paths that use $r$ multiple times. This is the most interesting case in which we need to use the star operation. This is done via the function $\\gamma$\n\t\tthat takes the star of all the possible combinations of $R$.\n\\end{itemize}\n\\section{Complement}\n\n\\cite{jurg14}\n\n\\bibliographystyle{alpha}\n\\bibliography{dmatheory}\n\n\\end{document}\n\n", "meta": {"hexsha": "b9621e15098376f1b9c768bd85b0fc0136567e0b", "size": 4030, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "theory/dmatheory.tex", "max_stars_repo_name": "termite2/dma_synthesis", "max_stars_repo_head_hexsha": "421b2c734c346bb6fa5cd5f035261b3da8bc3736", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theory/dmatheory.tex", "max_issues_repo_name": "termite2/dma_synthesis", "max_issues_repo_head_hexsha": "421b2c734c346bb6fa5cd5f035261b3da8bc3736", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theory/dmatheory.tex", "max_forks_repo_name": "termite2/dma_synthesis", "max_forks_repo_head_hexsha": "421b2c734c346bb6fa5cd5f035261b3da8bc3736", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8723404255, "max_line_length": 161, "alphanum_fraction": 0.7101736973, "num_tokens": 1348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.435821618700624}}
{"text": "\\section[Asymptotic normality]{Theoretical results supporting the asymptotically normal \\oos\\ statistic}\n\\label{sec:1}\n\nThis section presents the new \\oos\\ statistic; first we give an\ninformal motivation of the statistic, then present the paper's key\nassumptions in Section~\\ref{sec:1a} and present our formal theoretical\nresults in Section~\\ref{sec:1b}.\n\nSuppose for now that a researcher is interested in\npredicting the target variable $y_{t+1}$ with a vector of regressors\n$x_t$, that $v_t$ is another random process that is believed to\npotentially contain information about $y_{t+1}$, and that\n$(y_t, x_t, v_t)$ is stationary and weakly dependent.\nIn addition,\nlet $\\btrue = (\\E x_t x_t')^{-1} \\E x_t y_{t+1}$ be the pseudotrue\ncoefficient for the regression of $y_{t+1}$ on $x_t$ and define\n$\\ep_{t+1} = y_{t+1} - x_t'\\btrue$.  If this linear model is\ncorrectly specified, then $\\ep_{t+1}$ is an \\mds\\ with respect\nto $\\sigma((x_t, v_t, y_t), (x_{t-1}, v_{t-1}, y_{t-1}),\\dots)$\nand we can see immediately that\n\\begin{equation}\n  \\label{eq:1}\n  \\oclt{t} \\ep_{t+1} (v_t - x_t'\\btrue)\n\\end{equation}\nobeys an \\mds\\ \\clt\\ and is asymptotically normal as $P \\to \\infty$,%\n\\footnote{This claim assumes that the asymptotic variance of the\n  sample average is uniformly positive, a requirement that we will\n  address in Section~\\ref{sec:1b}.} %\nwith $R$ an arbitrary starting value\nand $P = T - R$.\n\nStraightforward algebra \\citep{ClW:07} shows that\n\\begin{equation}\n  \\label{eq:2}\n  \\tfrac{1}{\\sqrt{P}} \\osum{t} \\ep_{t+1} (v_t -\n  x_t'\\btrue) = \\tfrac{1}{2 \\sqrt{P}} \\osum{t} \\Big[(y_{t+1} -\n  x_t\\btrue)^2 - (y_{t+1} - v_t)^2 + (x_t'\\btrue - v_t)^2 \\Big]\n\\end{equation}\nalmost surely.\n\\citet{ClW:06,ClW:07} base their \\oos\\ statistics on the \\allcaps{RHS} of\nEquation~\\eqref{eq:2}, but use a second forecast of $y_{t+1}$ as\n$v_t$. (Call it $\\yh_{t+1}$.) They use a rolling window of length\n$R$ to estimate $\\yh_{t+1}$,%\n\\footnote{Making $\\yh_{t+1}$ a function of $y_t, x_{t-1}, z_{t-1}\n\\dots, y_{t-R+1}, x_{t-R}$ and $z_{t-R}$, where $z_t$ is another weakly\ndependent random process} %\nand $R$ is kept finite as $T \\to \\infty$ so that\n$\\yh_{t+1}$ inherits the weak dependence properties of the\nvariables used to estimate it. Using a finite window prevents\nthe degeneracy that can arise when comparing nested models out-of-sample (see\n\\citealp{ClM:01}, and \\citealp{Mcc:07}), so the conditional variance\nof the \\oos\\ average remains positive and the average obeys a \\clt.%\n\\footnote{This approach was first introduced by \\citet{GiW:06}.} %\n\n\\citet{ClW:06,ClW:07} propose using this as a test of whether the benchmark is correctly specified.\nIn their 2006 paper, Clark and West assume that the\ncoefficients on the benchmark model, $\\btrue$, are zero under the null, making\n$\\ep_{t+1}$ observed directly. This restriction is relaxed in\ntheir 2007 paper, where $\\btrue$ is unknown and estimated with the same length-$R$\nrolling window as $\\yh_{t+1}$. Now the estimated linear model's prediction errors,\n$\\eph_{t+1}$, replace $\\ep_{t+1}$ in the \\oos\\\ntest statistic. Unfortunately, $\\eph_{t+1}$ is not an\n\\mds\\ even when $\\ep_{t+1}$ is, so the statistic is no longer\nasymptotically mean-zero normal, even though this approximation\nperforms well in simulations. Since the window length is finite,\nthe estimator of $\\btrue$ does not converge to $\\btrue$.\n\nThis paper proposes using the same basic \\oos\\ statistic,\nbut using a recursive window to estimate $\\btrue$ and produce\n$\\eph_{t+1}$:\n\\begin{align}\n  \\label{eq:3}\n  \\bh_t &= \\Big(\\sum_{s=1}^{t-1} x_{s} x_{s}'\\Big)^{-1}\n  \\sum_{s=1}^{t-1} x_{s} y_{s+1}\n  && \\text{and}\n  &\n  \\eph_{t+1} &= y_{t+1} - x_t'\\bh_t\n\\end{align}\nfor each $t$.%\n\\footnote{The matrix inversion in $\\bh_t$ can be replaced with a\n  pseudo-inverse if necessary for some values of $t$ without changing\n  the forecast.} %\n\\citepos{Wes:96} Theorem 4.1 implies that\n\\begin{equation*}\n  \\oclt{t} \\Big[(y_{t+1} -\n  x_t\\bh_t)^2 - (y_{t+1} - v_t)^2 + (x_t'\\bh_t - v_t)^2 \\Big]\n\\end{equation*}\nis asymptotically normal with mean zero under Clark and West's\n\\mds\\ null for fairly\narbitrary processes $v_t$, as long as $v_t$ is weakly dependent and\nthe \\oos\\ statistic has uniformly positive variance.  Just as in\n\\citet{ClW:06,ClW:07}, these conditions are ensured if $v_t$ is\nanother forecast of $y_{t+1}$ based on a fixed-length rolling window.\n\nSo far, we have presented an especially simple version of the result\nto make the intuition as clear as possible. The next section lists the\nspecific assumptions for the more general case and defines additional notation.\n\n\\subsection{Theoretical assumptions}\n\\label{sec:1a}\n\nConsider the following environment. There is a single linear\nbenchmark model of the target variable, $y_{t+1}$:\n\\begin{equation}\\label{eq:4}\n  y_{t+1} = x_t'\\beta + \\ep_{t+1}, \\quad t = 1,\\dots,T-1\n\\end{equation}\nwhere $\\beta$ is an unknown vector of parameters and $x_t$ is an\nobserved vector of predictors. The parameter $\\beta$ is estimated with\n\\ols\\ using a recursive window as described by Equation~\\eqref{eq:3}.\nThe alternative model is denoted $\\yh_{t+1}$ and is estimated with a\nrolling window of length $R$.\n\nThe main conditions on the \\dgp\\ are summarized in the first\nassumption.  The weak dependence and moment conditions are\nstandard. The assumption of strict stationarity is stronger than\nnecessary in practice --- once the alternative forecasting method is\nknown, it is only necessary that the \\oos\\ adjusted loss difference be\nweak stationary, and even that can be relaxed further --- but this\nstronger assumption ensures that the results hold generally.\n\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Assumption \\ref{a1}}\n\\begin{asmp}\\label{a1}%\n  The data are generated by the relationship\n  \\begin{equation}\n    y_{t+1} = x_t'\\btrue + \\ep_{t+1}\n  \\end{equation}\n  for $t=1,2,\\dots$, for some value $\\btrue$, with $\\E x_t \\ep_{t+1} =\n  0$, $\\E \\ep_{t+1}^2 > 0$, and $\\E x_t x_t'$ positive definite for\n  all $t$. Also assume that there is an additional sequence of random\n  vectors $z_t$ and the process $(\\ep_{t+1}, x_t, z_t)$ is stationary\n  and strong mixing of size $-r/(r-2)$ or uniform mixing of size\n  $-r/(2r-2)$, for $r > 2$.\n\\end{asmp}\n\nThe next assumption defines the forecasting models and adds additional\nconstraints to the \\dgp.\n\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Assumption \\ref{a3}}\n\\begin{asmp}\\label{a3}%\n  The benchmark forecast is $x_t'\\bh_t$, where $\\bh_t$ is constructed\n  with a recursive window according to~\\eqref{eq:3}. The alternative\n  forecast satisfies\n  \\begin{equation}\n    \\yh_{t+1} = \\psi(y_t,z_t,\\dots,y_{t-R+1}, z_{t-R+1})\n  \\end{equation}\n  where $\\psi$ is a known measurable function and the window length,\n  $R$, remains finite as $T \\to \\infty$. Moreover, the vector\n  $(\\ep_{t+1}, x_t, \\yh_{t+1})$ has uniformly bounded $2 r$ moments\n  where $r$ is first defined in Assumption~\\ref{a1}.\n\\end{asmp}\n\nThe requirement that the alternative forecast satisfies moment\nconditions, rather than the underlying predictors $z_t$, is somewhat\nunappealing but necessary. The function $\\psi$ that generates these\nforecasts is otherwise nearly unrestricted, so even well-behaved predictors\ncould produce arbitrarily badly-behaved forecasts. For example, if\n\\begin{equation*}\n  z_t \\sim \\iid~\\bernoulli(1/2),\n\\end{equation*}\nsetting $\\psi(y_t, z_t) = 1/z_t$ would prevent a \\clt\\ from holding\nsince the forecast equals positive infinity with probability $1/2$. It\nis easy to construct less obvious examples of problematic functions as\nwell. Assumption~\\ref{a3} implicitly rules out these functional forms\nby imposing moment conditions on the alternative models' forecasts.\n\nOur next assumption ensures that the asymptotic variance of the \\oos\\\naverage is positive.\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Assumption \\ref{a4}}\n\\begin{asmp}\\label{a4}%\n  The asymptotic variance-covariance matrix\n  \\begin{equation}\n    \\var \\Bigg(\n      \\oclt{t} \\begin{pmatrix} x_t \\\\ \\yh_{t+1} \\end{pmatrix} \\ep_{t+1}\n      \\Bigg)\n  \\end{equation}\n  is uniformly positive definite (in $T$).\n\\end{asmp}\nThis assumption is much less restrictive than in \\cite{Wes:96}.  As in\n\\cite{GiW:06} and \\citet{ClW:06,ClW:07}, the assumption only serves to\nrule out pathological cases --- for example, letting the alternative\nmodel consist of only the first regressor of the benchmark. In \\citet{Wes:96}, this\nassumption is a restriction on the \\dgp\\ as well as the forecasting\nmodels, but in this paper it is a restriction only on the models.\n\nThe final assumption restricts the class of \\hac\\ variance estimators\nwe will consider. We use the same class of estimators studied by\n\\citet{JoD:00} (their class $\\mathcal{K}$); see their paper for\nfurther discussion.\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Assumption \\ref{a5}}\n\\begin{asmp}\\label{a5}%\n  The kernel $K$ is a function from $\\Re$ to $[-1,1]$ such that $K(0) = 1$, $K(x)\n  = K(-x)$ for all $x$, $K(\\cdot)$ is continuous at zero and all but a\n  finite number of points, and\n  \\begin{gather*}\n    \\int_{-\\infty}^{\\infty} \\lvert K(x) \\rvert\\, dx < \\infty,\n    \\intertext{and}\n    \\int_{-\\infty}^{\\infty} \\Bigg\\lvert\n    \\int_{-\\infty}^{\\infty} K(z) e^{ixz}\\,dz \\Bigg\\rvert\\, dx < \\infty.\n  \\end{gather*}\n\\end{asmp}\n\nLast, we define some notation that will be used to derive the\ntheoretical properties of our \\oos\\ statistics.  The information set\nthat contains the information available for forecasting $y_{t+1}$ is\n\\begin{equation*}\n  \\Fs_t = \\sigma(y_t, x_t, z_t, y_{t-1}, x_{t-1}, z_{t-1},\\dots).\n\\end{equation*}\nThe adjusted \\oos\\ loss difference using a hypothetical value of\n$\\beta$ to produce the benchmark forecast is denoted by\n\\begin{equation*}\n  f_t(\\beta) = (y_{t+1} - x_t'\\beta)^2 - (y_{t+1} - \\yh_{t+1})^2 + (x_t'\\beta - \\yh_{t+1})^2.\n\\end{equation*}\nDefine the additional terms $\\fh_t = f_t(\\bh_t)$, $f_t = f_t(\\btrue)$,\n\\begin{gather*}\n  \\gh_t = 2 \\Bigg[\\oavg{s} (x_s'\\bh_s - \\yh_{s+1}) x_s'\\Bigg]\\,\n          \\Bigg[\\tfrac{1}{T-1} \\sum_{s=1}^{T-1} x_s x_s'\\Bigg]^{-1} x_t \\eph_{t+1}\n  \\intertext{and}\n  g_t = 2 \\E\\Big[(x_t'\\btrue - \\yh_{t+1}) x_t'\\Big] \\, (\\E x_t x_t')^{-1} x_t \\ep_{t+1}\n\\end{gather*}\nand the \\oos\\ averages $\\fb = \\osum{t} \\fh_t/P$, $\\fb^* = \\osum{t}\nf_t/P$, $\\gb = \\osum{t} \\gh_t/P$, and $\\gb^* = \\osum{t} g_t/P$.\n\n\\subsection{Theoretical results}\n\\label{sec:1b}\n\nAsymptotic normality of the \\oos\\ average now follows directly from the\nfirst three assumptions without other conditions. The proof is\npresented in the Appendix and follows \\citet{Wes:96} closely.\n\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Theorem \\ref{res:1}}\n\\begin{thm}\\label{res:1}\n  If Assumptions~\\ref{a1}--\\ref{a4} hold then\n  \\begin{equation*}\n    \\sqrt{P} (\\fb - \\E \\fb^*) \\to^d N(0, \\sigma^2),\n  \\end{equation*}\n  with $\\sigma^2 = s_1 + 2(s_2 + s_3)$ and\n  \\begin{align*}\n    s_1  &= \\lim \\var(\\sqrt{P}\\, \\fb^*), &\n    s_2  &= \\lim \\cov(\\sqrt{P}\\, \\fb^*, \\sqrt{P}\\, \\gb^*), &\n    s_3  &= \\lim \\var(\\sqrt{P}\\, \\gb^*).\n  \\end{align*}\n\\end{thm}\n\nTo use this result, we need a consistent estimator of\n$\\sigma^2$. Define the \\hac\\ covariance estimator $\\sigmah^2_1 =\n\\sh_{11} + 2 (\\sh_{12} + \\sh_{13})$ and the \\mds\\ covariance estimator\n$\\sigmah^2_2 = \\sh_{21} + 2(\\sh_{22} + \\sh_{23})$ with\n\\begin{align*}\n  \\sh_{11} &= \\oavg{s,t} (\\fh_s - \\fb) (\\fh_t - \\fb) K(\\tfrac{t-s}{P}), &\n  \\sh_{21} &= \\oavg{t} (\\fh_t - \\fb)^2, \\\\\n  \\sh_{12} &= \\oavg{s,t} (\\fh_s - \\fb)(\\gh_t - \\gb) K(\\tfrac{t-s}{P}), &\n  \\sh_{22} &= \\oavg{t} (\\fh_t - \\fb)(\\gh_t - \\gb),\n\\intertext{and}\n  \\sh_{13} &= \\oavg{s,t} (\\gh_s - \\gb) (\\gh_t - \\gb), &\n  \\sh_{23} &= \\oavg{t} (\\gh_t - \\gb)^2.\n\\end{align*}\n\nThese estimators are consistent under similar assumptions to\nTheorem~\\ref{res:1}.\n\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Lemma \\ref{lem:2}}\n\\begin{lem}\\label{lem:2}\n  If Assumptions~\\ref{a1}--\\ref{a5} hold then\n  \\begin{equation*}\n    \\sigmah_1^2 \\to^p \\sigma^2.\n  \\end{equation*}\n  If Assumptions~\\ref{a1}--\\ref{a4} hold and $\\{\\varepsilon_{t},\n  \\Fs_t\\}$ is an \\mds\\ then\n  \\begin{equation*}\n    \\sigmah_2^2 \\to^p \\sigma^2.\n  \\end{equation*}\n\\end{lem}\n\nNote that these results allow misspecification; asymptotic normality\nfollows from the weak dependence of the underlying series and from the\ndesign of the test statistic. These statistics have typically been\nused to test the null hypothesis that the benchmark model is correctly\nspecified --- that $\\{\\ep_t, \\Fs_t\\}$ is an \\mds\\ --- which\nimplies that $f_t$ is an \\mds\\ as discussed\nat the beginning of this section. This is especially appealing in our\nframework, since the benchmark can be theoretically motivated so the\n\\mds\\ null would be a test of rationality. For example, \\citet{GoW:08}\ntest whether excess returns for the S\\&P 500 are predictable\nout-of-sample, and any deviation of $\\ep_{t+1}$ from an \\mds\\ is potentially\ninteresting. But the \\mds\\ null hypothesis only affects the estimator\nof $\\sigma^2$ (see Lemma~\\ref{lem:2}); Theorem~\\ref{res:1} continues\nto hold under any \\dgp\\ that satisfies Assumptions~\\ref{a1}~--~\\ref{a4}.\n\nIn other settings, a researcher may want to test the weaker hypothesis\nthat $\\E \\fb^* = 0$ but the benchmark may be misspecified. Our\nstatistic can then be interpreted as an encompassing test as in\n\\citet{HLN:98}, and would test whether the alternative model contains\nadditional information that could make the benchmark model more\naccurate. This interpretation can be motivated by the combination forecasting\nmodel\n\\begin{equation*}\n  \\yh_{\\mathit{avg},t+1} = (1 - w) x_t'\\btrue + w \\yh_{t+1}\n\\end{equation*}\nwhich can be rewritten in terms of forecast errors as\n\\[\ny_{t+1} - \\yh_{\\mathit{avg},t+1} = \\ep_{t+1} + w (x_t'\\btrue - \\yh_{t+1}).\n\\]\nThe value\n\\[\nw = \\frac{\\E \\ep_{t+1} (\\yh_{t+1} - x_t'\\btrue)}{\\E (x_t'\\btrue - \\yh_{t+1})^2}\n\\]\nminimizes the \\mse\\ of the combination forecast, so the combination\nmodel will have smaller \\mse\\ than the benchmark model, implying that\nthe alternative uses information not in the benchmark, unless\n$\\ep_{t+1}$ and $\\yh_{t+1} - x_t'\\btrue$ are uncorrelated. This\ncorrelation is exactly the quantity measured by our statistic.\n\nThe final result puts together Theorem~\\ref{res:1} and\nLemma~\\ref{lem:2} to produce our test statistics. The null hypothesis\nunder misspecification is written in terms of $\\E \\ep_{t+1} \\yh_{t+1}$\nand not $\\E \\ep_{t+1} (\\yh_{t+1} - x_t'\\btrue)$, since $\\E \\ep_{t+1}\nx_t = 0$ by construction. This result is an immediate consequence of\nthe previous two results and its proof is omitted.\n\n\\phantomsection\n\\addcontentsline{toc}{subsubsection}{Theorem \\ref{thm:3}}\n\\begin{thm}\\label{thm:3}\n  If Assumptions~\\ref{a1}--\\ref{a5} hold, then\n  \\begin{equation*}\n    \\sqrt{P} \\fb / \\sigmah_1 \\to^d N(0, 1)\n  \\end{equation*}\n  under the null hypothesis $\\E(\\varepsilon_{t+1} \\yh_{t+1}) = 0$ for\n  all $t = R,\\dots,T-1$.  If, instead, Assumptions~\\ref{a1}--\\ref{a4}\n  hold, then\n  \\begin{equation*}\n    \\sqrt{P} \\fb / \\sigmah_2 \\to^d N(0, 1)\n  \\end{equation*}\n  under the null hypothesis that $\\{\\varepsilon_t, \\Fs_t\\}$ is an \\mds.\n\\end{thm}\n\nThe test statistic proposed in Theorem~\\ref{thm:3} can be easily\nextended in several ways. For longer-horizon forecasts (two or more\nperiods ahead), $\\sigmah_1$ will remain consistent but $\\sigmah_2$\nwill not --- the forecast errors for a correctly specified\n$h$-step-ahead forecast have an MA($h-1$) dependence structure --- but\nusing a generalized $\\sigmah_2$ that reflects this covariance\nstructure restores consistency. To test optimality under loss\nfunctions other than squared-error, one can replace the forecast error\nwith the generalized forecast error \\citep[see, for\nexample][]{PaT:07,PaT:07b} and replace the \\ols\\ estimator of $\\beta$ with the\ncorresponding $M$-estimator. And the benchmark model can be replaced\nin general with a nonlinear model that satisfies the assumptions of\n\\citet{Wes:96} or \\citet{Mcc:00} by making the appropriate changes to\n$f_t$ and $g_t$. (See \\citealp{Wes:96}, and \\citealp{Mcc:00},\nfor details.) The general approach of using a recursive window to\nestimate the benchmark and a fixed-length rolling window to estimate\nthe alternative applies quite broadly.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"mixedwindow\"\n%%% TeX-command-extra-options: \"-shell-escape\"\n%%% End:\n", "meta": {"hexsha": "ff51e9d17743d98924ed24f332bc344ddab562c4", "size": 16279, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "S2-normality.tex", "max_stars_repo_name": "grayclhn-econ/mixedwindow", "max_stars_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "S2-normality.tex", "max_issues_repo_name": "grayclhn-econ/mixedwindow", "max_issues_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2015-01-07T16:44:10.000Z", "max_issues_repo_issues_event_max_datetime": "2016-02-08T21:21:38.000Z", "max_forks_repo_path": "S2-normality.tex", "max_forks_repo_name": "grayclhn-econ/mixedwindow", "max_forks_repo_head_hexsha": "3b25a5acad1da570bcd72806e6c32fbf9c54845d", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6, "max_line_length": 104, "alphanum_fraction": 0.7065544567, "num_tokens": 5423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.43582161435504013}}
{"text": "% This file contains the content for a main section\n\\regularsectionformat\n%% Modify below this line %%\n\\chapter{Discussion}\n\\label{chap:discussion}\n\n\\section{Comparison of the ACES white point and CIE \\texorpdfstring{D\\textsubscript{60}}{D60}}\n\\label{sec:comp}\nFrequently, the white point associated with various ACES encodings is said to be `D\\textsubscript{60}' \\cite{autodesk,bmforum,acescentralD60}. This shorthand notation has sometimes led to confusion for those familiar with the details of how the chromaticity coordinates of the CIE D series illuminants are calculated \\cite{notD60}.  The chromaticity coordinates of any CIE D series illuminant can be calculated using the equations found in Section 3 of CIE 15:2004 and reproduced in Equation~\\ref{eq:xyeq} \\cite{CIE152004}.\n\n\\begin{floatequ}[!ht]\n    \\begin{alignat*}{2}\n    & y_{D} && = -3.000x_{D}^{2}+2.870x_{D}-0.275 \\\\\n    & x_{D} && =\n        \\begin{dcases}\n            0.244063+0.09911{\\frac {10^{3}}{T}}+2.9678{\\frac {10^{6}}{T^{2}}}-4.6070{\\frac {10^{9}}{T^{3}}} \\qquad & 4,000\\ \\mathrm {K} \\leq T\\leq 7,000\\ \\mathrm {K} \\\\\n            0.237040+0.24748{\\frac {10^{3}}{T}}+1.9018{\\frac {10^{6}}{T^{2}}}-2.0064{\\frac {10^{9}}{T^{3}}} \\qquad & 7,000\\ \\mathrm {K} < T\\leq 25,000\\ \\mathrm {K}\n        \\end{dcases}\n    \\end{alignat*}\n    \n    \\captionsetup{width=.75\\textwidth}\n    \\caption{Calculation of CIE xy from CCT for CIE Daylight}\n    \\label{eq:xyeq}\n\\end{floatequ}\n\nThe CIE has specified four canonical daylight illuminants (D\\textsubscript{50}, D\\textsubscript{55}, D\\textsubscript{65} and D\\textsubscript{75}) \\cite{CIE152004}.  Contrary to what the names might imply, the correlated color temperature (CCT) values of these four canonical illuminants are not the nominal CCT values of \\SI[mode=text]{5000}{\\kelvin}, \\SI[mode=text]{5500}{\\kelvin}, \\SI[mode=text]{6500}{\\kelvin}, and \\SI[mode=text]{7500}{\\kelvin}.  For instance, CIE D\\textsubscript{65} does not have a CCT of \\SI[mode=text]{6500}{\\kelvin} but rather a CCT temperature of approximately \\SI[mode=text]{6504}{\\kelvin} \\cite{wyszecki1982color}.  \nThe exact CCT values differ from the nominal CCT values due to a 1968 revision to $c_2$, the second radiation constant in Planck's blackbody radiation formula \\cite{Durieux1970}.  When the value of $c_2$ was changed from 0.014380 to 0.014388, it altered the CIE xy location of the Planckian locus for a blackbody. This small change to the Planckian locus' position relative to the chromaticity coordinates of the established CIE daylight locus had the effect of changing the correlated color temperature of the CIE D series illuminants ever so slightly.  The precise CCT values for the established canonical CIE D series illuminants can be determined by applying the equation in Equation~\\ref{eq:ccteq} to the nominal CCT values implied by the illuminant name.  The exact CCT values of the canonical daylight illuminants are not whole numbers after the correction factor is applied, but it is common to round their values to the nearest Kelvin.  The CCT values of the CIE canonical daylight illuminants before the 1968 change to $c_2$, after the 1968 change, and rounded to the nearest Kelvin can be found in Table~\\ref{tab:d_cct}. \n\n\\begin{floatequ}[!ht]\n\\begin{equation}\n    CCT_{new} = CCT\\times \\frac{1.4388}{1.4380}\n\\end{equation}\n    \\captionsetup{width=.75\\textwidth}\n    \\caption{Conversion of nominal pre-1968 CCT to post-1968 CCT}\n    \\label{eq:ccteq}\n\\end{floatequ}\n\n\\begin{table}[!ht]\n    \\centering\n    \\begin{tabularx}{.97\\linewidth}{|Y|Y|Y|Y|}\n    \\hline\n    \\textbf{CIE D} & \\textbf{CCT} & \\textbf{CCT current} & \\textbf{CCT current} \\\\ [-1.3ex]\n    \\textbf{Illuminant} & \\textbf{before 1968} & \\footnotesize{\\textbf{(round to 3 decimal places)}} & \\footnotesize{\\textbf{(round to 0 decimal places)}} \\\\ \\hline\n    D\\textsubscript{50} & \\SI[mode=text]{5000}{\\kelvin} & \\SI[mode=text]{5002.782}{\\kelvin} & \\SI[mode=text]{5003}{\\kelvin} \\\\ \\hline\n    D\\textsubscript{55} & \\SI[mode=text]{5500}{\\kelvin} & \\SI[mode=text]{5503.060}{\\kelvin} & \\SI[mode=text]{5503}{\\kelvin} \\\\ \\hline\n    D\\textsubscript{65} & \\SI[mode=text]{6500}{\\kelvin} & \\SI[mode=text]{6503.616}{\\kelvin} & \\SI[mode=text]{6504}{\\kelvin} \\\\ \\hline\n\tD\\textsubscript{75} & \\SI[mode=text]{7500}{\\kelvin} & \\SI[mode=text]{7504.172}{\\kelvin} & \\SI[mode=text]{7504}{\\kelvin} \\\\ \\hline\n    \\end{tabularx}\n    \\captionsetup{width=.75\\textwidth}\n    \\caption{CCT of canonical CIE daylight illuminants \\cite{tableValsPython}}\n    \\label{tab:d_cct}\n\\end{table}\n\nD\\textsubscript{60} is not one of the four CIE canonical daylight illuminants so the exact CCT of such a daylight illuminant could be interpreted to be either approximately \\SI[mode=text]{6003}{\\kelvin} ($6000 \\times \\frac{1.4388}{1.4380}$) or \\SI[mode=text]{6000}{\\kelvin}.  Regardless, the ACES white point chromaticity coordinates derived using the method specified in Section~\\ref{chap:dervation} differs from both the chromaticity coordinates of CIE daylight with a CCT of \\SI[mode=text]{6003}{\\kelvin} and CIE daylight with a CCT of \\SI[mode=text]{6000}{\\kelvin}.  The chromaticity coordinates of each, rounded to 5 decimal places, can be found in Table~\\ref{tab:ciexy}.  As illustrated in Figure~\\ref{fig:cieuv}, the chromaticity coordinates of the ACES white point do not fall on the daylight locus nor do they match those of any CIE daylight spectral power distribution.  The positions of the chromaticity coordinates in CIE Uniform Color Space (u$^\\prime$v$^\\prime$) and the differences from the ACES chromaticity coordinates in $\\Delta$u$^\\prime$v$^\\prime$ can be found in Table~\\ref{tab:cieuv}.\n\n\\begin{table}[!ht]\n    \\centering\n    \\begin{tabularx}{.75\\linewidth}{|l|Y|Y|}\n    \\hline\n     & \\textbf{CIE $\\boldsymbol{x}$} & \\textbf{CIE $\\boldsymbol{y}$} \\\\ \\hline\n    ACES White Point & 0.32168 & 0.33767 \\\\ \\hline\n    CIE Daylight 6000K & 0.32169  & 0.33780 \\\\ \\hline\n\tCIE Daylight 6003K & 0.32163  & 0.33774 \\\\ \\hline\n    \\end{tabularx}\n    \\captionsetup{width=.75\\textwidth}\n    \\caption{CIE xy chromaticity coordinates rounded to 5 decimal places \\cite{tableValsPython}}\n    \\label{tab:ciexy}\n\\end{table}\n\n\\begin{table}[!ht]\n    \\centering\n    \\begin{tabularx}{.75\\linewidth}{|l|Y|Y|Y|}\n    \\hline\n     & \\textbf{CIE $\\boldsymbol{u^\\prime}$} & \\textbf{CIE $\\boldsymbol{v^\\prime}$} & $\\boldsymbol{\\Delta u^\\prime v^\\prime}$ \\\\ \\hline\n    ACES White Point & 0.20078 & 0.47421 & 0\\\\ \\hline\n    CIE Daylight 6000K & 0.20074 & 0.47427 & 0.00008 \\\\ \\hline\n\tCIE Daylight 6003K & 0.20072 & 0.47423 & 0.00007 \\\\ \\hline\n    \\end{tabularx}\n    \\captionsetup{width=.75\\textwidth}\n    \\caption{CIE u$^\\prime$v$^\\prime$ chromaticity coordinates and $\\Delta$u$^\\prime$v$^\\prime$ from the ACES white point rounded to 5 decimal places \\cite{tableValsPython}}\n    \\label{tab:cieuv}\n\\end{table}\n\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{cieuv.png}\n    \\caption{CIE UCS diagram with chromaticity coordinates}\n    \\label{fig:cieuv}\n\\end{figure}\n\nAlthough the ACES white point chromaticity is not on either the Planckian locus or the daylight locus, the CCT of its chromaticity can still be estimated.  There are a number of methods for estimating the CCT of any particular set of chromaticity coordinates \\cite{robertson1968computation,mccamy1992correlated,hernandez1999calculating,Ohno2014}.  The results of four popular methods can be found in Table~\\ref{tab:aceswpcct}.  Each of the methods estimates the CCT of the ACES white point to be very close to \\SI[mode=text]{6000}{\\kelvin}.\n\n\\begin{table}[!ht]\n    \\centering\n    \\begin{tabularx}{.9\\linewidth}{|Y|Y|}\n    \\hline\n    \\textbf{CCT Estimation Method} & \\textbf{ACES white point CCT} \\\\ \\hline\n    Robertson & \\SI[mode=text]{5998.98}{\\kelvin} \\\\ \\hline\n    Hernandez-Andres & \\SI[mode=text]{5997.26}{\\kelvin} \\\\ \\hline\n    Ohno & \\SI[mode=text]{6000.04}{\\kelvin} \\\\ \\hline\n\tMcCamy & \\SI[mode=text]{6000.41}{\\kelvin} \\\\ \\hline\n    \\end{tabularx}\n    \\captionsetup{width=.9\\textwidth}\n    \\caption{Estimation of the CCT of the ACES white point rounded to 2 decimal places \\cite{tableValsPython}}\n    \\label{tab:aceswpcct}\n\\end{table}\n\n\\section{Reasons for the ``\\texorpdfstring{D\\textsubscript{60}}{D60}-like'' white point}\n\\label{sec:reasonForD60}\nThe ACES white point was first specified by the Academy's ACES Project Committee in 2008 in Academy Specification S-2008-001.  The details in S-2008-001 were later standardized in SMPTE ST 2065-1:2012.  Prior to the release of the Academy specification the Project Committee debated various aspects of the ACES2065-1 encoding, including the exact white point, for many months.  The choice of the ``D\\textsubscript{60}-like'' white point was influenced heavily by discussions centered around viewer adaptation, dark surround viewing conditions, ``cinematic look'', and preference.  In the end, the Committee decided to go with a white point that was close to that of a daylight illuminant but also familiar to those with a film heritage. The white point would later be adopted for use in other encodings used in the ACES system. It is important to note that the ACES white point does not dictate the chromaticity of the reproduction neutral axis.  Using various techniques beyond the scope of this document the chromaticity of the equal red, green and blue (ACES2065-1 \\rgbequal) may match the ACES white point, the display calibration white point, or any other white point preferred for technical or aesthetic reasons.\n\nThe Committee felt that a white point with a chromaticity similar to that of daylight was appropriate for ACES2065-1.  However, the exact CCT of the daylight was in question.  Some felt D\\textsubscript{55} was a reasonable choice given its historical use as the design illuminant for daylight color negative films.  Others felt D\\textsubscript{65} would be good choice given its use in television and computer graphics as a display calibration white point.  Because the exact white point chromaticity would not prohibit users from achieving any reproduction white point, the Committee ultimately decided to use the less common CCT of \\SI[mode=text]{6000}{\\kelvin}.  This choice was based on an experiment to determine the reproduction chromaticity of projected color print film, the relative location of the white point compared to other white points commonly used in digital systems, and the general belief that imagery reproduced with the white point felt aesthetically ``cinematic''.\n\nThe projected color print film experiment involved simulating the exposure of a spectrally non-selective (neutral) gray scale onto color negative film, printing that negative onto a color print film, then projecting the color film onto a motion picture screen with a xenon-based film projector and measuring the colorimetry off the screen. The result of the experiment found that the CIE xy chromaticity coordinates of a projected LAD patch \\cite{pytlak1976simplified,kodakLad} through a film system were approximately $x=0.32170$ $y=0.33568$. Figure~\\ref{fig:filmprintthrough} shows a plot of the CIE $u^\\prime v^\\prime$ chromaticity coordinates of a scene neutral as reproduced by a film system compared to the CIE daylight locus and the ACES white point.  The chromaticity of the film system LAD reproduction was determined to be closest to CIE daylight with the CCT of \\SI[mode=text]{6000}{\\kelvin} when the differences were calculated in CIE $u^\\prime v^\\prime$.  A summary of the CIE $u^\\prime v^\\prime$ differences between CIE daylight at various CCTs and the LAD patch chromaticity are summarized in Table~\\ref{tab:lad}.\n\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.85\\textwidth]{images/PrintThroughChromaticities.png}\n    \\caption{Film system print-through color reproduction of original scene neutral scale}\n    \\label{fig:filmprintthrough}\n\\end{figure}\n\n\\begin{table}[!ht]\n    \\centering\n    \\begin{tabularx}{.75\\linewidth}{|Y|Y|}\n    \\hline\n    \\textbf{Daylight CCT} & $\\boldsymbol{\\Delta u^\\prime v^\\prime}$ \\textbf{from LAD chromaticity}\\\\ \\hline\n\t\t\\SI[mode=text]{5500}{\\kelvin} & 0.008183 \\\\ \\hline\n\t\t\\SI[mode=text]{5600}{\\kelvin} & 0.006619 \\\\ \\hline\n\t\t\\SI[mode=text]{5700}{\\kelvin} & 0.005112 \\\\ \\hline\n\t\t\\SI[mode=text]{5800}{\\kelvin} & 0.003676 \\\\ \\hline\n\t\t\\SI[mode=text]{5900}{\\kelvin} & 0.002354 \\\\ \\hline\n\t\t\\SI[mode=text]{6000}{\\kelvin} & 0.001360 \\\\ \\hline\n\t\t\\SI[mode=text]{6100}{\\kelvin} & 0.001448 \\\\ \\hline\n\t\t\\SI[mode=text]{6200}{\\kelvin} & 0.002442 \\\\ \\hline\n\t\t\\SI[mode=text]{6300}{\\kelvin} & 0.003627 \\\\ \\hline\n\t\t\\SI[mode=text]{6400}{\\kelvin} & 0.004836 \\\\ \\hline\n\t\t\\SI[mode=text]{6500}{\\kelvin} & 0.006035 \\\\ \\hline\n    \\end{tabularx}\n    \\captionsetup{width=.75\\textwidth}\n    \\caption{CIE $\\Delta$u$^\\prime$v$^\\prime$ difference between projected LAD patch and CIE Daylight CCT chromaticity coordinates round to 6 decimal places \\cite{tableValsPython}}\n    \\label{tab:lad}\n\\end{table}\n\n\n\\section{Reasons why the ACES white point doesn't match the CIE \\texorpdfstring{D\\textsubscript{60}}{D60} chromaticity coordinates}\n\\label{sec:reasonsForDifference}\nAs discussed in Section~\\ref{sec:reasonForD60}, the ACES white point was chosen to be very close to that of CIE Daylight with a CCT of \\SI[mode=text]{6000}{\\kelvin}.  This raises the question why the CIE chromaticity coordinates of $x=0.32169$ $y=0.33780$ were not used.  The reasoning is somewhat precautionary; at the time, the exact chromaticity coordinates for the ACES white point were being debated, the ACES Project Committee was concerned about the implications the choice of any particular set of chromaticity coordinates could suggest.  \n\nThose new to ACES can often misinterpret the specification of a set of ACES encoding white point chromaticity coordinates as a requirement that the final reproduction neutral axis chromaticity is limited to only that white point chromaticity.  However, as pointed out in Section~\\ref{sec:reasonForD60}, the ACES encoding white point does not dictate the chromaticity of the reproduction neutral axis, and regardless of the ACES white point chromaticity, the reproduction neutral axis may match the ACES white point, the display calibration white point, or any other white point preferred for technical or aesthetic reasons.  The ACES white point chromaticity coordinates serve to aid in the understanding and, if desired, conversion of the colorimetry of ACES encoded images to any other encoding including those with a different white point.\n\nJust as the implication of the ACES encoding white point on reproduction can be misunderstood, the ACES Project Committee was also concerned that the ACES encoding white point might have unintended implications for image creators. Specifically, the Committee was concerned that the choice of a set of chromaticity coordinates that corresponded to a source with a defined spectral power distribution might be misunderstood to suggest that only that source could be used to illuminate the scene.  For example, the Committee was concerned if the ACES white point chromaticity was chosen to match that of CIE Daylight with a CCT of \\SI[mode=text]{6000}{\\kelvin} then \\textit{only} scenes photographed under CIE Daylight with a CCT of \\SI[mode=text]{6000}{\\kelvin} would be compatible with the ACES system.  In reality, ACES does not dictate the source under which movies or television shows can be photographed.  ACES Input Transforms handle the re-encoding of camera images to ACES2065-1 and preserve all the technical and artistic intent behind on-set lighting choices.  \n\nFor these reasons as well as an abundance of caution, the ACES Project Committee decided it would be best to use a set of chromaticity coordinates very near those of CIE Daylight with a CCT of \\SI[mode=text]{6000}{\\kelvin} but not exactly those of any easily calculated spectral power distribution.", "meta": {"hexsha": "1d4daf84cebf1837fc5920cf89ed4e37a470a37c", "size": 15826, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/LaTeX/TB-2018-001/sec-discussion.tex", "max_stars_repo_name": "KelSolaar/aces-dev", "max_stars_repo_head_hexsha": "76ea982a988d278dd12b563602771f46a5da3b83", "max_stars_repo_licenses": ["AMPAS"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-01-04T18:12:13.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-27T06:46:50.000Z", "max_issues_repo_path": "documents/LaTeX/TB-2018-001/sec-discussion.tex", "max_issues_repo_name": "colour-science/aces-dev", "max_issues_repo_head_hexsha": "86284e2f145a89e3612f05ec7ea5a3e9d92cc779", "max_issues_repo_licenses": ["AMPAS"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/LaTeX/TB-2018-001/sec-discussion.tex", "max_forks_repo_name": "colour-science/aces-dev", "max_forks_repo_head_hexsha": "86284e2f145a89e3612f05ec7ea5a3e9d92cc779", "max_forks_repo_licenses": ["AMPAS"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 102.7662337662, "max_line_length": 1218, "alphanum_fraction": 0.7488942247, "num_tokens": 4627, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.43582161426398097}}
{"text": "\n\\chapter{Design of a Multi-Trajectory Simulation Algorithm} \n\\label{ch:Multi-Trajectory Simulation Algorithm}\nThis chapter introduces a design for a multi-trajectory simulation algorithm and provides explanations and examples of its main steps. The strength of this algorithm lies in its ability to run simulations within complex models, either with or without the presence of rare-events, and its adaptability to reach a wide coverage of the state space with efficiency in different types of models...\n\n\\section{Introduction to Multi-Trajectory}\n\\label{sec:Introduction to Multi-Trajectory}\nMulti-trajectory simulation algorithm is based on particles, where a particle represents one possible trajectory of the simulation, and carries a weight that indicates the probability of that trajectory to happen. At any given time there is a collection of particles ready to be executed. Each particle is associated with one state of the model, and the execution of it implies a change in that state by following one or more of its possible transitions. \n\nThe core idea of the algorithm can be described as a loop of three steps:\n\\begin{enumerate}\n  \\item Selection of the next particle...\n  \\item Execution of the particle, which consists in choosing between:\n  \\begin{enumerate}\n    \\item Move: Randomly select...\n    \\item Split: Create one new...\n  \\end{enumerate}\n  \\item Insertion of the particle...\n\\end{enumerate}\n\n\n\\begin{figure}[htb]\n\\begin{multicols}{3}\n\\centering\n\\includegraphics[width=.33\\textwidth]{Model_Markov_Chain_Init.pdf}\\\\\nInitial\\\\\n\\includegraphics[width=.33\\textwidth]{Model_Markov_Chain_Move.pdf}\\\\\nMove, with probability $\\alpha/(\\alpha+\\beta+\\gamma)$\\\\\n\\includegraphics[width=.33\\textwidth]{Model_Markov_Chain_Split.pdf}\\\\\nSplit\\\\\n\\end{multicols}\n\\caption{Move or Split Example}\n\\label{fig:Move or Split Example}\n\\end{figure}\n\n\nAgainst expectations, after the implementation of these strategies the results obtained by the executions were incorrect. Different attempts were made to overcome this error without success. An analysis of it with a numerical example is presented in Section~\\ref{sub:Markov Chain}. Due to this limitation a solution with a fair execution over the particles is chosen, using the definition of a cycle as the execution of all particles in the pool and the restriction of not execute a particle twice in a cycle.\n\n\n\\subsection*{Only Exponential Transitions Enabled}\nIf there are only exponential transitions enabled, ...  and the average time spent in the state is equal to the inverse of the sum of all those weighting factors.\n\n\\begin{flalign*}\n\\begin{array}{ccl}\nTime\\ Spent &=&\\displaystyle\\frac{\\displaystyle 1}{\\displaystyle\\sum\\limits_{i=0}^n (\\frac{enabled_i}{delay_i})}\\\\\n\\\\\nWeighting\\ Factor[i] &=&\\left\\lbrace \n\t\\begin{array}{ccl}\n\tImmediate\\ Transition &=&0\\\\\n\tExponential\\ Transition &=&\\displaystyle\\frac{enabled_i}{delay_i}\\\\\n\tDeterministic\\ Transition &=&0\n\t\\end{array} \n\\right.\n\\end{array}\n\\end{flalign*}\n\n", "meta": {"hexsha": "5cd0b75efbe204e0a5854fc38ee86df5e924b713", "size": 2969, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/Thesis_3_Desing.tex", "max_stars_repo_name": "tuiSSE/sse-thesis-template", "max_stars_repo_head_hexsha": "5a081682cd2ea4176effc47d263f47de5d5b3f79", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-04-13T17:01:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T21:05:30.000Z", "max_issues_repo_path": "content/Thesis_3_Desing.tex", "max_issues_repo_name": "tuiSSE/sse-thesis-template", "max_issues_repo_head_hexsha": "5a081682cd2ea4176effc47d263f47de5d5b3f79", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-12-08T10:32:15.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-26T13:19:47.000Z", "max_forks_repo_path": "content/Thesis_3_Desing.tex", "max_forks_repo_name": "tuiSSE/sse-template-deu", "max_forks_repo_head_hexsha": "5a081682cd2ea4176effc47d263f47de5d5b3f79", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-07-29T16:24:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-28T15:49:24.000Z", "avg_line_length": 52.0877192982, "max_line_length": 509, "alphanum_fraction": 0.7824183227, "num_tokens": 705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.4358215966995275}}
{"text": "\\documentclass[11pt,oneside]{article}\t%use\"amsart\"insteadof\"article\"forAMSLaTeXformat\n\\usepackage{geometry}\t\t%Seegeometry.pdftolearnthelayoutoptions.Therearelots.\n\\geometry{letterpaper}\t\t%...ora4paperora5paperor...\n%\\geometry{landscape}\t\t%Activateforforrotatedpagegeometry\n%\\usepackage[parfill]{parskip}\t\t%Activatetobeginparagraphswithanemptylineratherthananindent\n\\usepackage{graphicx}\t\t\t\t%Usepdf,png,jpg,orepswithpdflatex;useepsinDVImode\n\t\t\t\t\t\t\t\t%TeXwillautomaticallyconverteps-->pdfinpdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\n%----macros begin---------------------------------------------------------------\n\\usepackage{color}\n\\usepackage{amsthm}\n\n\\def\\conv{\\mbox{\\textrm{conv}\\,}}\n\\def\\aff{\\mbox{\\textrm{aff}\\,}}\n\\def\\E{\\mathbb{E}}\n\\def\\R{\\mathbb{R}}\n\\def\\Z{\\mathbb{Z}}\n\\def\\tex{\\TeX}\n\\def\\latex{\\LaTeX}\n\\def\\v#1{{\\bf #1}}\n\\def\\p#1{{\\bf #1}}\n\\def\\T#1{{\\bf #1}}\n\n\\def\\vet#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\\def\\mat#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\n\\def\\lin{\\mbox{\\rm lin}\\,}\n\\def\\aff{\\mbox{\\rm aff}\\,}\n\\def\\pos{\\mbox{\\rm pos}\\,}\n\\def\\cone{\\mbox{\\rm cone}\\,}\n\\def\\conv{\\mbox{\\rm conv}\\,}\n\\newcommand{\\homog}[0]{\\mbox{\\rm homog}\\,}\n\\newcommand{\\relint}[0]{\\mbox{\\rm relint}\\,}\n\n%----macros end-----------------------------------------------------------------\n\n\\title{Curves, surfaces and splines with LAR\n\\footnote{This document is part of the \\emph{Linear Algebraic Representation with CoChains} (LAR-CC) framework~\\cite{cclar-proj:2013:00}. \\today}\n}\n\\author{Alberto Paoluzzi}\n%\\date{}\t\t\t\t\t\t\t%Activatetodisplayagivendateornodate\n\n\\begin{document}\n\\maketitle\n\\nonstopmode\n\n\\begin{abstract}\nIn this module we implement above LAR most of the parametric methods for polynomial and rational curves, surfaces and splines discussed in the book~\\cite{Paoluzzi2003a}, and implemented in the PLaSM language and in the python package pyplasm. \n\\end{abstract}\n\n\\tableofcontents\n\n%===============================================================================\n\\section{Introduction}\n%===============================================================================\n\n\n\n%===============================================================================\n\\section{Tensor product surfaces}\n%===============================================================================\n\nThe tensor product form of surfaces will be primarily used, in the remainder of this module, to support the LAR implementation of polynomial (rational) surfaces. For this purpose, we start by defining some basic operators on function tensors.\nIn particular, a toolbox of basic tensor operations is given in Script 12.3.1. The ConstFunTensor operator produces a tensor of constant functions starting from a tensor of numbers; the recursive FlatTensor may be used to ?flatten? a tensor with any number of indices by producing a corresponding one index tensor; the InnerProd and TensorProd are used to compute the inner product and the tensor product of conforming tensors of functions, respectively.\n\n\n\\paragraph{Toolbox of tensor operations}\n\n%-------------------------------------------------------------------------------\n@D Multidimensional transfinite Bernstein-Bezier Basis\n@{\"\"\" Toolbox of tensor operations \"\"\"\ndef larBernsteinBasis (U):\n\tdef BERNSTEIN0 (N):\n\t\tdef BERNSTEIN1 (I):\n\t\t\tdef map_fn(point):\n\t\t\t\tt = U(point)\n\t\t\t\tout = CHOOSE([N,I])*math.pow(1-t,N-I)*math.pow(t,I)\n\t\t\t\treturn out\n\t\t\treturn map_fn\n\t\treturn [BERNSTEIN1(I) for I in range(0,N+1)]\n\treturn BERNSTEIN0\n@}\n%-------------------------------------------------------------------------------\n\n\\subsection{Tensor product surface patch}\n\n%-------------------------------------------------------------------------------\n@D Tensor product surface patch\n@{\"\"\" Tensor product surface patch \"\"\"\ndef larTensorProdSurface (args):\n\tubasis , vbasis = args\n\tdef TENSORPRODSURFACE0 (controlpoints_fn):\n\t\tdef map_fn(point):\n\t\t\tu,v=point\n\t\t\tU=[f([u]) for f in ubasis]\n\t\t\tV=[f([v]) for f in vbasis]\n\t\t\tcontrolpoints=[f(point) if callable(f) else f \n\t\t\t\tfor f in controlpoints_fn]\n\t\t\ttarget_dim = len(controlpoints[0][0])\n\t\t\tret=[0 for x in range(target_dim)]\n\t\t\tfor i in range(len(ubasis)):\n\t\t\t\tfor j in range(len(vbasis)):\n\t\t\t\t\tfor M in range(len(ret)):\n\t\t\t\t\t\tfor M in range(target_dim): \n\t\t\t\t\t\t\tret[M] += U[i]*V[j] * controlpoints[i][j][M]\n\t\t\treturn ret\n\t\treturn map_fn\n\treturn TENSORPRODSURFACE0\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Bilinear tensor product surface patch}\n\n%-------------------------------------------------------------------------------\n@D Bilinear surface patch\n@{\"\"\" Bilinear tensor product surface patch \"\"\"\ndef larBilinearSurface(controlpoints):\n\tbasis = larBernsteinBasis(S1)(1)\n\treturn larTensorProdSurface([basis,basis])(controlpoints)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Biquadratic tensor product surface patch}\n\n%-------------------------------------------------------------------------------\n@D Biquadratic surface patch\n@{\"\"\" Biquadratic tensor product surface patch \"\"\"\ndef larBiquadraticSurface(controlpoints):\n\tbasis1 = larBernsteinBasis(S1)(2)\n\tbasis2 = larBernsteinBasis(S1)(2)\n\treturn larTensorProdSurface([basis1,basis2])(controlpoints)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Bicubic tensor product surface patch}\n\n%-------------------------------------------------------------------------------\n@D Bicubic surface patch\n@{\"\"\" Bicubic tensor product surface patch \"\"\"\ndef larBicubicSurface(controlpoints):\n\tbasis1 = larBernsteinBasis(S1)(3)\n\tbasis2 = larBernsteinBasis(S1)(3)\n\treturn larTensorProdSurface([basis1,basis2])(controlpoints)\n@}\n%-------------------------------------------------------------------------------\n\n\n%===============================================================================\n\\section{Transfinite B\\'ezier}\n%===============================================================================\n%-------------------------------------------------------------------------------\n@D Multidimensional transfinite B\\'ezier\n@{\"\"\" Multidimensional transfinite Bezier \"\"\"\ndef larBezier(U):\n\tdef BEZIER0(controldata_fn):\n\t\tN = len(controldata_fn)-1\n\t\tdef map_fn(point):\n\t\t\tt = U(point)\n\t\t\tcontroldata = [fun(point) if callable(fun) else fun \n\t\t\t\tfor fun in controldata_fn]\n\t\t\tout = [0.0 for i in range(len(controldata[0]))]\t\t\n\t\t\tfor I in range(N+1):\n\t\t\t\tweight = CHOOSE([N,I])*math.pow(1-t,N-I)*math.pow(t,I)\n\t\t\t\tfor K in range(len(out)):  out[K] += weight*(controldata[I][K])\n\t\t\treturn out\n\t\treturn map_fn\n\treturn BEZIER0\n\ndef larBezierCurve(controlpoints):\n\treturn larBezier(S1)(controlpoints)\n@}\n%-------------------------------------------------------------------------------\n\n%===============================================================================\n\\section{Coons patches}\n%===============================================================================\n\n%-------------------------------------------------------------------------------\n@D Transfinite Coons patches\n@{\"\"\" Transfinite Coons patches \"\"\"\ndef larCoonsPatch (args):\n\tsu0_fn , su1_fn , s0v_fn , s1v_fn = args\n\tdef map_fn(point):\n\t\tu,v=point\n\t\tsu0 = su0_fn(point) if callable(su0_fn) else su0_fn\n\t\tsu1 = su1_fn(point) if callable(su1_fn) else su1_fn\n\t\ts0v = s0v_fn(point) if callable(s0v_fn) else s0v_fn\n\t\ts1v = s1v_fn(point) if callable(s1v_fn) else s1v_fn\n\t\tret=[0.0 for i in range(len(su0))]\t\n\t\tfor K in range(len(ret)):\n\t\t\tret[K] = ((1-u)*s0v[K] + u*s1v[K]+(1-v)*su0[K] + v*su1[K] + \n\t\t\t(1-u)*(1-v)*s0v[K] + (1-u)*v*s0v[K] + u*(1-v)*s1v[K] + u*v*s1v[K])\n\t\treturn ret\n\treturn map_fn\n@}\n%-------------------------------------------------------------------------------\n\n\n%===============================================================================\n\\section{Bsplines}\n%===============================================================================\nThe B-splines discussed in this section are called \\emph{non-uniform}\nbecause different spline segments may correspond to different\nintervals in parameter space, unlike uniform B-splines. \nThe basis polynomials, and consequently the spline shape and the other\nproperties, are defined by a non-decreasing sequence of real\nnumbers\n\\[\nt_0 \\leq t_1 \\leq\\cdots\\leq t_n,\n\\]\ncalled the {\\it knot sequence}.  Splines of this kind are also named\n\\emph{NUB-splines} in the remainder of this book,\\footnote{Some authors\ncall them non-uniform non-rational B-splines.  We prefer to emphasize\nthat they are polynomial splines.} where the name stands for\nNon-Uniform B-splines. \n\nThe knot sequence is used to define the basis polynomials which blend\nthe control points.  In particular, each subset of $k+2$ adjacent knot\nvalues is used to compute a basis polynomial of degree $k$.  Notice\nthat some subsequent knots may coincide.  In this case we speak of \n\\emph{multiplicity} of the knots.\n\n\n\\paragraph{Note}\\index{Splines!number of points and joints}\n\nIn non-uniform B-splines the number $n+1$ of {\\em knot values} is\ngreater than the number $m+1$ of control points $\\p{p}_0, \\ldots,\n\\p{p}_m$.  In particular, the relation\n\\begin{equation}\n\tn = m+k+1,\n\t\\label{eq:knotsNumber}\n\\end{equation}\nwhere $k$ is the \\emph{degree} of spline segments, must hold between\nthe number of knots and the number of control points.  The quantity $h\n= k+1$ is called the \\emph{order} of the spline.  It will be useful\nwhen giving recursive formulas to compute the B-basis polynomials. \nLet us remember, e.g., that a spline of order four is made of cubic\nsegments.\n\n\n\\paragraph{Non-uniform B-spline flexibility}\n\\index{Non-uniform B-splines!flexibility}\n\nSuch splines have a much greater flexibility than the uniform ones. \nThe basis polynomial associated with each control point may vary\ndepending on the subset of knots it depends on.  Spline segments may\nbe parametrized over intervals of different size, and even reduced to\na single point.  Therefore, the continuity at a joint may be reduced, \ne.g.~from $C^{2}$ to $C^{1}$ to $C^{0}$ and even to none by suitably increasing the multiplicity\nof a knot.\n\n%-------------------------------------------------------------------------------\n\\subsection{Definitions}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Geometric entities}\n\nIn order to fully understand the construction of a non-uniform B-spline, it may\nbe useful to recall the main inter-relationships among the 5 geometric\nentities that enter the definition.\n\n\\paragraph{Control points} \\hspace{-2mm}are denoted as $\\p{p}_{i}$, \nwith $0\\leq i\\leq m$.  A non-uniform B-spline usually approximates the control \npoints. \n\n\\paragraph{Knot values} \\hspace{-2mm}are denoted as $t_{i}$, with $0\\leq i\\leq \nn$.  It must be $n = m+k+1$, where $k$ is the spline degree.\nKnot values are used to define the B-spline polynomials. They also \ndefine the join points (or joints) between adjacent spline segments. \nWhen two consecutive knots coincide, the spline segment associated with \ntheir interval reduces to a point.\n\n\\paragraph{Spline degree} \\hspace{-2mm}is defined as the degree of the\nB-basis functions which are combined with the control points.  The\ndegree is denoted as $k$.  It is connected to the spline order $h =\nk+1$.  The most used non-uniform B-splines are either cubic or quadratic.  The\nimage of a linear non-uniform B-spline is a polygonal line.  The image of a\nnon-uniform B-spline of degree $0$ coincides with the sequence of control\npoints.\n\n\\paragraph{B-basis polynomials} \\hspace{-2mm}are denoted as $B_{i,h}(t)$.  They are\nunivariate polynomials in the $t$ indeterminate, computed by using the\nrecursive formulas of Cox and de Boor.  The $i$ index is associated with\nthe first one of values in the knot subsequence\n$(t_{i},t_{i+1},\\ldots,t_{i+h})$ used to compute $B_{i,h}(t)$.  The\nsecond index is called \\emph{order} of the polynomial.\n\n\\paragraph{Spline segments} \\hspace{-2mm}are defined as polynomial vector functions\nof a single parameter.  Such functions are denoted as $\\p{Q}_{i}(t)$,\nwith $k\\leq i\\leq m$.  A $\\p{Q}_{i}(t)$ spline segment is obtained by a\ncombination of the $i$-th control point and the $k$ previous points\nwith the basis polynomials of order $h$ associated to the same\nindices.  It is easy to see that the number of spline segments is\n$m-K+1$.\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Computation of a B-spline mapping}\n%-------------------------------------------------------------------------------\n\nThe B-spline mapping, i.e. the vector-valued polynomial to be mapped over a 1D domain\ndiscretisation by the \\texttt{larMap} operator, is computed by making reference to the \n\\texttt{pyplasm} implementation given by the \\texttt{BSPLINE} contained in the \n\\texttt{fenvs.py} library in the \\texttt{pyplasm} package.\n\n\\texttt{BSPLINE} is a third-order function, that must be ordinately applied to \n\\texttt{degree}, \\texttt{knots}, and \\texttt{controlpoints}.\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Domain computation}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@D Domain decomposition for 1D bspline maps\n@{\"\"\" Domain decomposition for 1D bspline maps \"\"\"\ndef larDom(knots,tics=32): \n\tdomain = knots[-1]-knots[0]\n\treturn larIntervals([tics*int(domain)])([domain])\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Examples}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Two examples of B-spline curves using lar-cc}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test08.py\n@{\"\"\" Two examples of B-spline curves using lar-cc \"\"\"\nfrom larlib import *\n\ncontrols = [[0,0],[-1,2],[1,4],[2,3],[1,1],[1,2],[2.5,1],[2.5,3],[4,4],[5,0]];\nknots = [0,0,0,0,1,2,3,4,5,6,7,7,7,7]\nbspline = BSPLINE(3)(knots)(controls)\nobj = larMap(bspline)(larDom(knots))\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n\ncontrols = [[0,1],[1,1],[2,0],[3,0],[4,0],[5,-1],[6,-1]]\nknots = [0,0,0,1,2,3,4,5,5,5]\nbspline = BSPLINE(2)(knots)(controls)\nobj = larMap(bspline)(larDom(knots))\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Bezier curve as a B-spline curve}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test09.py\n@{\"\"\" Bezier curve as a B-spline curve \"\"\"\nfrom larlib import *\n\ncontrols = [[0,1],[0,0],[1,1],[1,0]]\nbezier = larBezierCurve(controls)\ndom = larIntervals([32])([1])\nobj = larMap(bezier)(dom)\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n\nknots = [0,0,0,0,1,1,1,1]\nbspline = BSPLINE(3)(knots)(controls)\ndom = larIntervals([100])([knots[-1]-knots[0]])\nobj = larMap(bspline)(dom)\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{B-spline curve: effect of double or triple control points}\n\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test10.py\n@{\"\"\" B-spline curve: effect of double or triple control points \"\"\"\nfrom larlib import *\n\ncontrols1 = [[0,0],[2.5,5],[6,1],[9,3]]\ncontrols2 = [[0,0],[2.5,5],[2.5,5],[6,1],[9,3]]\ncontrols3 = [[0,0],[2.5,5],[2.5,5],[2.5,5],[6,1],[9,3]]\nknots = [0,0,0,0,1,1,1,1]\nbspline1 = larMap( BSPLINE(3)(knots)(controls1) )(larDom(knots))\nknots = [0,0,0,0,1,2,2,2,2]\nbspline2 = larMap( BSPLINE(3)(knots)(controls2) )(larDom(knots))\nknots = [0,0,0,0,1,2,3,3,3,3]\nbspline3 = larMap( BSPLINE(3)(knots)(controls3) )(larDom(knots))\n\nVIEW(STRUCT( CAT(AA(MKPOLS)([bspline1,bspline2,bspline3])) + \n\t[POLYLINE(controls1)]) )\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Periodic B-spline curve}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test11.py\n@{\"\"\" Periodic B-spline curve \"\"\"\nfrom larlib import *\n\ncontrols = [[0,1],[0,0],[1,0],[1,1],[0,1]]\nknots = [0,0,0,1,2,3,3,3]\t\t\t\t# non-periodic B-spline\nbspline = BSPLINE(2)(knots)(controls)\nobj = larMap(bspline)(larDom(knots))  \nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n\nknots = [0,1,2,3,4,5,6,7]\t\t\t\t# periodic B-spline\nbspline = BSPLINE(2)(knots)(controls) \t\nobj = larMap(bspline)(larDom(knots))\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Effect of knot multiplicity on B-spline curve}\n\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test12.py\n@{\"\"\" Effect of knot multiplicity on B-spline curve \"\"\"\nfrom larlib import *\n\npoints = [[0,0],[-1,2],[1,4],[2,3],[1,1],[1,2],[2.5,1]]\nb1 = BSPLINE(2)([0,0,0,1,2,3,4,5,5,5])(points)\nVIEW(STRUCT(MKPOLS( larMap(b1)(larDom([0,5])) ) + [POLYLINE(points)]))\nb2 = BSPLINE(2)([0,0,0,1,1,2,3,4,4,4])(points)\nVIEW(STRUCT(MKPOLS( larMap(b2)(larDom([0,5])) ) + [POLYLINE(points)]))\nb3 = BSPLINE(2)([0,0,0,1,1,1,2,3,3,3])(points)\nVIEW(STRUCT(MKPOLS( larMap(b3)(larDom([0,5])) ) + [POLYLINE(points)]))\nb4 = BSPLINE(2)([0,0,0,1,1,1,1,2,2,2])(points)\nVIEW(STRUCT(MKPOLS( larMap(b4)(larDom([0,5])) ) + [POLYLINE(points)]))\n@}\n%-------------------------------------------------------------------------------\n\n\nTODO: extend biplane mapping to unconnected domain ... (remove BUG above)\n\n\n\n%-------------------------------------------------------------------------------\n\\subsection{B-spline basis functions}\n%-------------------------------------------------------------------------------\n\nIn mathematics, the support of a function is the set of points where the function is not zero-valued.\nA spline is a sufficiently smooth polynomial function that is piecewise-defined, and possesses a high degree of smoothness at the places where the polynomial pieces connect (which are known as knots).\n\nA B-spline, or Basis spline, is a spline function that has minimal support with respect to a given degree, smoothness, and domain partition. Any spline function of given degree can be expressed as a linear combination of B-splines of that degree. Cardinal B-splines have knots that are equidistant from each other. B-splines can be used for curve-fitting and numerical differentiation of experimental data.\n\nIn CAD and computer graphics, spline functions are constructed as linear combinations of B-splines with a set of control points.\n\n\\paragraph{Sampling of a set of B-splines}\nHere we provide the code  for  the sampling of a set of B-splines of given degree, knot vector and number of control points.\n\n%-------------------------------------------------------------------------------\n@D Sampling of a set of B-splines\n@{\"\"\" Sampling of a set of B-splines of given degree, knots and controls \"\"\"\ndef BSPLINEBASIS(degree):\n\tdef BSPLINE0(knots):\n\t\tdef BSPLINE1(ncontrols):\n\t\t\tn = ncontrols-1\n\t\t\tm=len(knots)-1\n\t\t\tk=degree+1\n\t\t\tT=knots\n\t\t\ttmin,tmax=T[k-1],T[n+1]\t\t\t\n\t\t\tif len(knots)!=(n+k+1):\n\t\t\t\traise Exception(\"Invalid point/knots/degree for bspline!\")\t\t\t\n\n\t\t\t# de Boor coefficients\n\t\t\tdef N(i,k,t):\t\t\t\t\n\t\t\t\t# Ni1(t)\n\t\t\t\tif k==1:\n\t\t\t\t\tif(t>=T[i] and t<T[i+1]) or(t==tmax and t>=T[i] and t<=T[i+1]):\n\t\t\t\t\t\t# i use strict inclusion for the max value\n\t\t\t\t\t\treturn 1\n\t\t\t\t\telse:\n\t\t\t\t\t\treturn 0\t\t\t\t\n\t\t\t\t# Nik(t)\n\t\t\t\tret=0\n\t\t\t\t\n\t\t\t\tnum1,div1= t-T[i], T[i+k-1]-T[i]\n\t\t\t\tif div1!=0: ret+=(num1/div1) * N(i,k-1,t)\t\t\t\t\n\t\t\t\tnum2,div2=T[i+k]-t, T[i+k]-T[i+1]\n\t\t\t\tif div2!=0:  ret+=(num2/div2) * N(i+1,k-1,t)\n\t\t\t\t\n\t\t\t\treturn ret\n\t\t\t\n\t\t\t# map function\n\t\t\tdef map_fn(point):\n\t\t\t\tt=point[0]\n\t\t\t\treturn [N(i,k,t) for i in range(n+1)]\n\t\t\t\t\t\t\t\n\t\t\treturn map_fn\n\t\treturn BSPLINE1\n\treturn BSPLINE0\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Example}\n\nThe script below is used to display the graph of the whole set of basis splines \nfor a given degree, knot vector and number of control points. It may be interesting to note that\nthe value stored in \\texttt{obj} is the LAR 2-model of a curve (look at \\texttt{obj[1]}) embedded in \n$n$-dimensional space, with $n=9$ (the number of contral points), where every coordinate provides the \ndiscretised values of one of the blending functions, i.e.~the values of one B-spline basis function. \n\n%-------------------------------------------------------------------------------\n@D Drawing the graph of a set of B-splines\n@{\"\"\" Drawing the graph of a set of B-splines \"\"\"\nif __name__==\"__main__\":\n\n\tknots = [0,0,0,1,1,2,2,3,3,4,4,4]\n\tncontrols = 9\n\tdegree = 2\n\tobj = larMap(BSPLINEBASIS(degree)(knots)(ncontrols))(larDom(knots))\n\t\n\tfuns = TRANS(obj[0])\n\tvar = AA(CAT)(larDom(knots)[0])\n\tcells = larDom(knots)[1]\n\t\n\tgraphs =  [[TRANS([var,fun]),cells] for fun in funs]\n\tgraph = STRUCT(CAT(AA(MKPOLS)(graphs)))\n\tVIEW(graph)\n\tVIEW(STRUCT(MKPOLS(graphs[0]) + MKPOLS(graphs[-1])))\n@}\n%-------------------------------------------------------------------------------\n\n\n%===============================================================================\n\\section{Transfinite B-splines}\n%===============================================================================\n\n\n\n%-------------------------------------------------------------------------------\n@D Transfinite B-splines\n@{\ndef TBSPLINE(U):\n\tdef TBSPLINE0(degree):\n\t\tdef TBSPLINE1(knots):\n\t\t\tdef TBSPLINE2(points_fn):\n\t\n\t\t\t\tn=len(points_fn)-1\n\t\t\t\tm=len(knots)-1\n\t\t\t\tk=degree+1\n\t\t\t\tT=knots\n\t\t\t\ttmin,tmax=T[k-1],T[n+1]\n\t\n\t\t\t\t# see http://www.na.iac.cnr.it/~bdv/cagd/spline/B-spline/bspline-curve.html\n\t\t\t\tif len(knots)!=(n+k+1):\n\t\t\t\t\traise Exception(\"Invalid point/knots/degree for bspline!\")\n\t\n\t\t\t\t# de boord coefficients\n\t\t\t\tdef N(i,k,t):\n\t\n\t\t\t\t\t# Ni1(t)\n\t\t\t\t\tif k==1: \n\t\t\t\t\t\tif(t>=T[i] and t<T[i+1]) or (t==tmax and t>=T[i] and t<=T[i+1]): \n\t\t\t\t\t\t\t# i use strict inclusion for the max value\n\t\t\t\t\t\t\treturn 1\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\treturn 0\n\t\n\t\t\t\t\t# Nik(t)\n\t\t\t\t\tret=0\n\t\n\t\t\t\t\tnum1,div1= t-T[i], T[i+k-1]-T[i]  \n\t\t\t\t\tif div1!=0: ret+=(num1/div1) * N(i,k-1,t)\n\t\t\t\t\t# elif num1!=0: ret+=N(i,k-1,t)\n\t\n\t\t\t\t\tnum2,div2=T[i+k]-t, T[i+k]-T[i+1]\n\t\t\t\t\tif div2!=0:  ret+=(num2/div2) * N(i+1,k-1,t)\n\t\t\t\t\t# elif num2!=0: ret+=N(i,k-1,t)\n\t\n\t\t\t\t\treturn ret\n\t\n\t\t\t\t# map function\n\t\t\t\tdef map_fn(point):\n\t\t\t\t\tt=U(point)\n\t\n\t\t\t\t\t# if control points are functions\n\t\t\t\t\tpoints=[f(point) if callable(f) else f for f in points_fn]\n\t\n\t\t\t\t\ttarget_dim=len(points[0])\n\t\t\t\t\tret=[0 for i in range(target_dim)];\n\t\t\t\t\tfor i in range(n+1):\n\t\t\t\t\t\tcoeff=N(i,k,t) \n\t\t\t\t\t\tfor M in range(target_dim):\n\t\t\t\t\t\t\tret[M]+=points[i][M]*coeff\n\t\t\t\t\treturn ret\n\t\n\t\t\t\treturn map_fn\n\t\n\t\t\treturn TBSPLINE2\n\t\treturn TBSPLINE1\n\treturn TBSPLINE0\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test13.py\n@{\"\"\" Periodic B-spline curve \"\"\"\nfrom larlib import *\n\ncontrols = [[0,1],[0,0],[1,0],[1,1],[0,1]]\nknots = [0,0,0,1,2,3,3,3]\t\t\t\t# non-periodic B-spline\ntbspline = TBSPLINE(S1)(2)(knots)(controls)\nobj = larMap(tbspline)(larDom(knots))  \nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n\nknots = [0,1,2,3,4,5,6,7]\t\t\t\t# periodic B-spline\ntbspline = TBSPLINE(S1)(2)(knots)(controls) \t\nobj = larMap(tbspline)(larDom(knots))\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Transfinite surface from Bezier control curves and periodic B-spline curve}\n\nIn the script below a simple example of Transfinite surface is generated, using 5\nBezier control curves and a periodic B-spline curve.\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test14.py\n@{\"\"\" Transfinite surface from Bezier control curves and periodic B-spline curve \"\"\"\nfrom larlib import *\n\nb1 = BEZIER(S1)([[0,1,0],[0,1,5]])\nb2 = BEZIER(S1)([[0,0,0],[0,0,5]])\nb3 = BEZIER(S1)([[1,0,0],[2,-1,2.5],[1,0,5]])\nb4 = BEZIER(S1)([[1,1,0],[1,1,5]])\nb5 = BEZIER(S1)([[0,1,0],[0,1,5]])\ncontrols = [b1,b2,b3,b4,b5]\nknots = [0,1,2,3,4,5,6,7]\t\t\t\t# periodic B-spline\nknots = [0,0,0,1,2,3,3,3]\t\t\t\t# non-periodic B-spline\ntbspline = TBSPLINE(S2)(2)(knots)(controls) \t\ndom = larModelProduct([larDomain([10]),larDom(knots)])\ndom = larIntervals([32,48],'simplex')([1,3])\nobj = larMap(tbspline)(dom)\nVIEW(STRUCT( MKPOLS(obj) ))\nVIEW(SKEL_1(STRUCT( MKPOLS(dom) )))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n%===============================================================================\n\\section{NURBS}\n%===============================================================================\n\n\nRational non-uniform B-splines are normally denoted as NURB splines or\nsimply as NURBS. These splines are very important for both graphics\nand CAD applications. In particular:\n\n\n\\begin{enumerate}\n\n\\item \nRational curves and splines are invariant with respect to affine and\nprojective transformations.  Consequently, to transform or\nproject a NURBS it is sufficient to transform or project its\ncontrol points, leaving to the graphics hardware the task of sampling\nor rasterizing the transformed curve.\n\n\\item \nNURBS represent exactly the conic sections, i.e.~circles, ellipses, \nparabol\\ae, iperbol\\ae. Such curves are very frequent in mechanical \nCAD, where several shapes and geometric constructions are based on \nsuch geometric primitives.\n\n\\item\nRational B-splines are very flexible, since (a) the available degrees\nof freedom concern both degree, control points, knot values and\nweights; (b) can be locally interpolant or approximant; (c) can\nalternate spline segments with different degree; and (d)\ndifferent continuity at join points.\n\n\\item\nThey also allow for local variation of ``parametrization velocity\", or\nbetter, allow for modification of the norm of velocity vector along\nthe spline, defined as the derivative of the curve with respect to the\narc length.  For this purpose it is sufficient to properly modify the\nknot sequence.  This fact allows easy modification of the sampling density\nof spline points along segments with higher or lower curvature, while\nmaintaining the desired appearance of smoothness.\n\n\\end{enumerate}\n\nAs a consequence of their usefulness for applications, NURBS are\nlargely available when using geometric libraries or CAD kernels.\n\n%-------------------------------------------------------------------------------\n\\subsection{Rational B-splines of arbitrary degree}\n%-------------------------------------------------------------------------------\n\nA rational B-spline segment $\\v{R}_{i}(t)$ is defined as the\nprojection from the origin on the hyperplane $x_{d+1}=1$ of a\npolynomial B-spline segment $\\v{P}_{i}(u)$ in $\\E^{d+1}$ homogeneous\nspace.  \n\nUsing the same approach adopted when discussing rational B\\'ezier\ncurves, where $\\p{q}_{i} = (w_{i}\\p{p}_{i}, w_{i})\\in\\E^{d+1}$ are the\n$m+1$ homogeneous control points, the equation of the rational\nB-spline segment of degree $k$ with $n+1$ knots, may be therefore\nwritten as\n\\begin{equation}\n    \\p{R}_i(t) = \n    \\sum_{\\ell=0}^k \n    w_{i-\\ell}\\,\\p{p}_{i-\\ell} \n    {B_{i-\\ell,k+1}(t) \\over w(t)}\n = \n    \\sum_{\\ell=0}^k \n    \\p{p}_{i-\\ell} \n    N_{i-\\ell,k+1}(t)\n    \\label{eq:NUBgeneriche1}\n\\end{equation}\nwith $ k\\leq i\\leq m$,  $t\\in [t_{i}, t_{i+1})$, and\n\\[\nw(t) = \\sum_{\\ell=0}^k\nw_{i-\\ell} B_{i-\\ell,k+1}(t),\n\\]\nwhere $N_{i,h}(t)$ is the non-uniform rational\nB-basis function of initial value $t_{i}$ and order $h$.\nA global representation of the NURB spline can be given, due to the \nlocal support of the $N_{i,h}(t)$ functions, i.e.~to the fact that \nthey are zero outside the interval $[t_{i},t_{i+h})$. So:\n\\[\n\\p{R}(t) =  \\bigcup_{i=k}^{m} \\p{R}_i(t) = \n\\sum_{i=0}^{m}\\p{p}_{i}\\,N_{i,h}(t), \\qquad t\\in [t_{k},t_{m+1}).\n\\]\n\nNURB splines can be computed as non-uniform B-splines by using homogeneous\ncontrol points, and finally by dividing the Cartesian coordinate\nmaps times the homogeneous one.  This approach will be used in\nthe NURBS implementation given later in this chapter.  A more\nefficient and numerically stable variation of the Cox and de Boor\nformula for the rational case is given by\nFarin~\\cite{Farin:88}, p.~196.\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Computation of a NURBS mapping}\n%-------------------------------------------------------------------------------\n\nThe NURBS mapping, i.e. the vector-valued polynomial to be mapped over a 1D domain\ndiscretisation by the \\texttt{larMap} operator, is computed by making reference to the \n\\texttt{pyplasm} implementation given by the \\texttt{RATIONALBSPLINE} contained in the \n\\texttt{fenvs.py} library in the \\texttt{pyplasm} package.\n\n\\texttt{RATIONALBSPLINE} is a third-order function, that must be ordinately applied to \n\\texttt{degree}, \\texttt{knots}, and \\texttt{controlpoints}.\n\n%-------------------------------------------------------------------------------\n@D NURBS and TNURBS mapping definition\n@{\"\"\" Alias for the pyplasm definition (too long :o) \"\"\"\nNURBS = RATIONALBSPLINE     # in pyplasm\nTNURBS = TRATIONALBSPLINE\t # in lar-cc (only)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Transfinite NURBS interface}\n\nThe \\texttt{TNURBS} function, that is by definite an alias to \\texttt{TRATIONALBSPLINE},\nis used to define a NURBS surface by blending 1D curves, or a NURBS solid by blending 2D surfaces, \nand so on. For an example of use, just look at the test example \\texttt{test05.py},\nwhere a cylinder surface with unit radius and height is generated by blending 9 vertical unit segments\nvia the unit 1D circle as NURBS curve. \n\n%-------------------------------------------------------------------------------\n@D Transfinite NURBS interface\n@{\"\"\" Transfinite NURBS \"\"\"\ndef TRATIONALBSPLINE(U):\n\tdef TRATIONALBSPLINE0(degree):\n\t\tdef TRATIONALBSPLINE1(knots):\n\t\t\tdef TRATIONALBSPLINE2(points):\n\t\t\t\tbspline=TBSPLINE(U)(degree)(knots)(points)\n\t\t\t\tdef map_fn(point):\t\t\t\n\t\t\t\t\tret=bspline(point)\n\t\t\t\t\tlast=ret[-1]\n\t\t\t\t\tif last!=0: ret=[value/last for value in ret]\n\t\t\t\t\tret=ret[:-1]\n\t\t\t\t\treturn ret\n\t\t\t\treturn map_fn\n\t\t\treturn TRATIONALBSPLINE2\n\t\treturn TRATIONALBSPLINE1\n\treturn TRATIONALBSPLINE0\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Examples}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.33\\linewidth]{images/nurbs-circle} \n   \\caption{Circle 2D \\emph{exactly} implemented as a 9-point NURBS curve.}\n   \\label{fig:example}\n\\end{figure}\n\n\n\\paragraph{Circle implemented as 9-point NURBS curve}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test13.py\n@{\"\"\" Circle implemented as 9-point NURBS curve \"\"\"\nfrom larlib import *\n\nknots = [0,0,0,1,1,2,2,3,3,4,4,4]\n_p=math.sqrt(2)/2.0\ncontrols = [[-1,0,1], [-_p,_p,_p], [0,1,1], [_p,_p,_p],[1,0,1], [_p,-_p,_p], \n\t\t\t[0,-1,1], [-_p,-_p,_p], [-1,0,1]]\nnurbs = NURBS(2)(knots)(controls)\nobj = larMap(nurbs)(larDom(knots))\nVIEW(STRUCT( MKPOLS(obj) + [POLYLINE(controls)] ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Cylinder implemented as transfinite NURBS surface (with Bezier control curves)}\n\nThe transfinite cylinder surface generated below has both radius and height equal to 1.\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test15.py\n@{\"\"\" Cylinder implemented as 9-point NURBS curve \"\"\"\nfrom larlib import *\n\nknots = [0,0,0,1,1,2,2,3,3,4,4,4]\n_p=math.sqrt(2)/2.0\ncontrols = [[-1,0,1], [-_p,_p,_p], [0,1,1], [_p,_p,_p],[1,0,1], [_p,-_p,_p], \n\t\t\t[0,-1,1], [-_p,-_p,_p], [-1,0,1]]\nc1 = BEZIER(S1)([[-1,0,0,1],[-1,0,1,1]])\nc2 = BEZIER(S1)([[-_p,_p,0,_p],[-_p,_p,_p,_p]])\nc3 = BEZIER(S1)([[0,1,0,1],[0,1,1,1]])\nc4 = BEZIER(S1)([[_p,_p,0,_p],[_p,_p,_p,_p]])\nc5 = BEZIER(S1)([[1,0,0,1],[1,0,1,1]])\nc6 = BEZIER(S1)([[_p,-_p,0,_p],[_p,-_p,_p,_p]])\nc7 = BEZIER(S1)([[0,-1,0,1],[0,-1,1,1]])\nc8 = BEZIER(S1)([[-_p,-_p,0,_p],[-_p,-_p,_p,_p]])\nc9 = BEZIER(S1)([[-1,0,0,1],[-1,0,1,1]])\ncontrols = [c1,c2,c3,c4,c5,c6,c7,c8,c9]\n\t\t\t\ntnurbs = TNURBS(S2)(2)(knots)(controls)\ndom = larModelProduct([larDomain([10]),larDom(knots)])\ndom = larIntervals([10,36],'simplex')([1,4])\nobj = larMap(tnurbs)(dom)\nVIEW(STRUCT( MKPOLS(obj) ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\n%===============================================================================\n\\section{Computational framework}\n%===============================================================================\n\\subsection{Exporting the library}\n%-------------------------------------------------------------------------------\n@O larlib/larlib/splines.py\n@{\"\"\" Mapping functions and primitive objects \"\"\"\nfrom larlib import *\n\n@< Tensor product surface patch @>\n@< Bilinear surface patch @>\n@< Biquadratic surface patch @>\n@< Bicubic surface patch @>\n@< Multidimensional transfinite Bernstein-Bezier Basis @>\n@< Multidimensional transfinite B\\'ezier @>\n@< Transfinite Coons patches @>\n@< Domain decomposition for 1D bspline maps @>\n@< Sampling of a set of B-splines @>\n@< Drawing the graph of a set of B-splines @>\n@< Transfinite B-splines @>\n@< Transfinite NURBS interface @>\n@< NURBS and TNURBS mapping definition @>\n@}\n\n\n%===============================================================================\n\\section{Examples}\n%===============================================================================\n\n\\paragraph{Examples of larBernsteinBasis generation}\n\n%-------------------------------------------------------------------------------\n@d Examples of larBernsteinBasis\n@{larBernsteinBasis(S1)(3) \n\"\"\" [<function __main__.map_fn>,\n\t<function __main__.map_fn>,\n\t<function __main__.map_fn>,\n\t<function __main__.map_fn>] \"\"\"\nlarBernsteinBasis(S1)(3)[0]\n\"\"\" <function __main__.map_fn> \"\"\"\nlarBernsteinBasis(S1)(3)[0]([0.0])\n\"\"\" 1.0 \"\"\"\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Graph of Bernstein-Bezier basis}\n\n%-------------------------------------------------------------------------------\n@O  test/py/splines/test04.py\n@{\"\"\" Graph of Bernstein-Bezier basis \"\"\"\nfrom larlib import *\n\ndef larBezierBasisGraph(degree):\n\tbasis = larBernsteinBasis(S1)(degree)\n\tdom = larDomain([32])\n\tgraphs = CONS(AA(larMap)(DISTL([S1, basis])))(dom)\n\treturn graphs\n\ngraphs = larBezierBasisGraph(4)\nVIEW(STRUCT( CAT(AA(MKPOLS)( graphs )) ))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Some examples of curves}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test01.py \n@{\"\"\" Example of Bezier curve \"\"\"\nfrom larlib import *\n\ncontrolpoints = [[-0,0],[1,0],[1,1],[2,1],[3,1]]\ndom = larDomain([32])\nobj = larMap(larBezierCurve(controlpoints))(dom)\nVIEW(STRUCT(MKPOLS(obj)))\n\nobj = larMap(larBezier(S1)(controlpoints))(dom)\nVIEW(STRUCT(MKPOLS(obj)))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Transfinite cubic surface}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test02.py  \n@{\"\"\" Example of transfinite surface \"\"\"\nfrom larlib import *\n\ndom = larDomain([20],'simplex')\nC0 = larBezier(S1)([[0,0,0],[10,0,0]])\nC1 = larBezier(S1)([[0,2,0],[8,3,0],[9,2,0]])\nC2 = larBezier(S1)([[0,4,1],[7,5,-1],[8,5,1],[12,4,0]])\nC3 = larBezier(S1)([[0,6,0],[9,6,3],[10,6,-1]])\ndom2D = larExtrude1(dom,20*[1./20])\nobj = larMap(larBezier(S2)([C0,C1,C2,C3]))(dom2D)\nVIEW(STRUCT(MKPOLS(obj)))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Coons patch interpolating 4 boundary curves}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test03.py  \n@{\"\"\" Example of transfinite Coons surface \"\"\"\nfrom larlib import *\n\nSu0 = larBezier(S1)([[0,0,0],[10,0,0]])\nSu1 = larBezier(S1)([[0,10,0],[2.5,10,3],[5,10,-3],[7.5,10,3],[10,10,0]])\nSv0 = larBezier(S2)([[0,0,0],[0,0,3],[0,10,3],[0,10,0]])\nSv1 = larBezier(S2)([[10,0,0],[10,5,3],[10,10,0]])\ndom = larDomain([20])\ndom2D = larExtrude1(dom, 20*[1./20])\nout = larMap(larCoonsPatch([Su0,Su1,Sv0,Sv1]))(dom2D)\nVIEW(STRUCT(MKPOLS(out)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Bilinear tensor product patch}\n\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test05.py\n@{\"\"\" Example of bilinear tensor product surface patch \"\"\"\nfrom larlib import *\n\ncontrolpoints = [\n\t[[0,0,0],[2,-4,2]],\n\t[[0,3,1],[4,0,0]]]\ndom = larDomain([20])\ndom2D = larExtrude1(dom, 20*[1./20])\nmapping = larBilinearSurface(controlpoints)\npatch = larMap(mapping)(dom2D)\nVIEW(STRUCT(MKPOLS(patch)))\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Biquadratic tensor product patch}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test06.py\n@{\"\"\" Example of bilinear tensor product surface patch \"\"\"\nfrom larlib import *\n\ncontrolpoints=[\n\t[[0,0,0],[2,0,1],[3,1,1]],\n\t[[1,3,-1],[2,2,0],[3,2,0]],\n\t[[-2,4,0],[2,5,1],[1,3,2]]]\ndom = larDomain([20])\ndom2D = larExtrude1(dom, 20*[1./20])\nmapping = larBiquadraticSurface(controlpoints)\npatch = larMap(mapping)(dom2D)\nVIEW(STRUCT(MKPOLS(patch)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Bicubic tensor product patch}\n\n%-------------------------------------------------------------------------------\n@O test/py/splines/test07.py\n@{\"\"\" Example of bilinear tensor product surface patch \"\"\"\nfrom larlib import *\n\ncontrolpoints=[\n\t[[ 0,0,0],[0 ,3  ,4],[0,6,3],[0,10,0]],\n\t[[ 3,0,2],[2 ,2.5,5],[3,6,5],[4,8,2]],\n\t[[ 6,0,2],[8 ,3 , 5],[7,6,4.5],[6,10,2.5]],\n\t[[10,0,0],[11,3  ,4],[11,6,3],[10,9,0]]]\ndom = larDomain([20])\ndom2D = larExtrude1(dom, 20*[1./20])\nmapping = larBicubicSurface(controlpoints)\npatch = larMap(mapping)(dom2D)\nVIEW(STRUCT(MKPOLS(patch)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n%===============================================================================\n\\appendix\n\\section{Utility functions}\n%===============================================================================\n\n\n\n\\bibliographystyle{amsalpha}\n\\bibliography{splines}\n\n\\end{document}\n", "meta": {"hexsha": "e7748e541794a3aaf7d3bc8fb52fe8debb25873a", "size": 38993, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/tex/splines.tex", "max_stars_repo_name": "Ahdhn/lar-cc", "max_stars_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-10T02:06:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-10T02:06:27.000Z", "max_issues_repo_path": "src/tex/splines.tex", "max_issues_repo_name": "Ahdhn/lar-cc", "max_issues_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-02-20T21:57:07.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T07:18:11.000Z", "max_forks_repo_path": "src/tex/splines.tex", "max_forks_repo_name": "Ahdhn/lar-cc", "max_forks_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-04T10:47:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-10T17:32:50.000Z", "avg_line_length": 37.0655893536, "max_line_length": 454, "alphanum_fraction": 0.5538942887, "num_tokens": 10792, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.4357738808814179}}
{"text": "\\subsection{Nonlinear Invariant Cryptanalysis}\n\n\\renewcommand{\\TITLE}{\\it Nonlinear Invariant Cryptanalysis}\n\n\\begin{frame}[t]\n\\vspace{1.25cm}\n\\CurTitle{}\n\n\\Center{\n    \\textcolor{blue}{Properties} of messages that are \\textcolor{green!70!black}{preserved} through encryption\n}\n\n\\vspace{-0.5cm}\n\n\\only<2>{\\Center{\\includegraphics[height=3cm]{invariant1.pdf}}}\n\\only<3>{\\Center{\\includegraphics[height=3cm]{invariant2.pdf}}}\n\\only<4>{\\Center{\\includegraphics[height=3cm]{invariant3.pdf}}}\n\\only<5>{\\Center{\\includegraphics[height=3cm]{invariant4.pdf}}}\n\\only<6>{\\Center{\\includegraphics[height=3cm]{invariant5.pdf}}}\n\\end{frame}\n\n\n\\begin{frame}[t]\n\\CreditsTikz{}\n\\CurTitle{}\n\n\\Center{\n\\hspace*{1.75cm}\\includegraphics[width=0.85\\linewidth]{norx_sponge_serial_v3.pdf}\n}\n\n\\Block{4cm,4cm}{5cm}{\n    \\includegraphics[width=2.5cm]{norx_G_col.pdf}\n}\n\\Block{8cm,4cm}{5cm}{\n    \\includegraphics[width=4.5cm]{norx_G_diag.pdf}\n}\n\n\\vspace{3.75cm}\n\n\\Center{\n    \\Large Analysis of the NORX Authenticated Encryption\n}\n\\end{frame}\n\n\n\\begin{frame}[t]\n\\CurTitle{}\n\n\\vspace{1cm}\n\n$$\n\\begin{bmatrix}\n0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\\\\n0 & 1 & 1 & 1 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\\\\n1 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \\\\\n1 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 \\\\\n1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1 \\\\\n\\end{bmatrix}\n$$\n\n\\vspace{0.5cm}\n\n\\Center{\n    \\Large Theoretical study of linear layers \\\\\n    preserving degree-$d$ invariants\n}\n\\end{frame}\n\n\n\\begin{frame}[t]\n    \\CurTitle{}\n    \n    \\nocitepartii{mybibNORX}\n    \\nocitepartii{mybibNLI}\n    \\bibliographystylepartii{unsrt}\n    \\Block{3cm,2.5cm}{10cm}{\n        \\bibliographypartii{mybiblio.bib}\n    }\n\\end{frame}", "meta": {"hexsha": "2620d0600c1919eca8da144b2b23c4814d979888", "size": 1670, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides-source/tex/12nonlininv.tex", "max_stars_repo_name": "hellman/thesis", "max_stars_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2019-05-16T19:55:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T15:36:12.000Z", "max_issues_repo_path": "slides-source/tex/12nonlininv.tex", "max_issues_repo_name": "hellman/thesis", "max_issues_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-09T11:26:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-09T11:26:45.000Z", "max_forks_repo_path": "slides-source/tex/12nonlininv.tex", "max_forks_repo_name": "hellman/thesis", "max_forks_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-05T19:40:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T19:40:16.000Z", "avg_line_length": 21.1392405063, "max_line_length": 110, "alphanum_fraction": 0.6467065868, "num_tokens": 658, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4357738765360803}}
{"text": "% $RCSfile: timestepping.tex,v $\n% $Revision: 1.5 $\n% $Author: langer $\n% $Date: 2008-06-17 15:26:24 $\n\n\\documentclass[onecolumn,prl,floatfix,12pt]{revtex4}\n\n\\newcommand{\\M}{\\textbf{M}}\n\\newcommand{\\C}{\\textbf{C}}\n\\newcommand{\\K}{\\textbf{K}}\n\\newcommand{\\D}{\\textbf{D}}\n\\newcommand{\\f}{\\textbf{f}}\n\\newcommand{\\fbarstar}{\\textbf{$\\bar{\\textbf{f}}$*}}\n\\newcommand{\\half}{{1\\over2}}\n\n\\begin{document}\n\n\\title{Notes on Time Stepping for OOF2}\n\n\\author{OOF Team}\n\n\\maketitle\n\n\\section{Zienkiewicz \\& Taylor's SS22 Algorithm}\n\nThe equation to be solved is\n\\begin{equation}\n  \\label{eq:ode}\n  \\M \\ddot a + \\C \\dot a + \\K a + \\f = 0\n\\end{equation}\nwhere $a$ is a vector of values and \\M, \\C, and \\K\\ are constants.\n\nAssume we know $a$ and $\\dot a$ at $t=t_n$ and we want to find them at\n$t=t_{n+1} = t_n + \\Delta t$.  Expand in a Taylor series in $\\tau =\nt-t_n$:\n\\begin{equation}\n  \\label{eq:taylor}\n  a = a_n + \\tau\\dot a_n + \\half\\tau^2\\alpha_n\n\\end{equation}\n$\\alpha_n$ is a vector of unknown values.\nMultiply (\\ref{eq:ode}) by a weighting function $W(\\tau)$ and integrate\nover the interval:\n\\begin{equation}\n  \\label{eq:weighted}\n  0=\\int_0^{\\Delta t}d\\tau\\, \\left[\\M \\ddot a + \\C \\dot a + \\K a + \\f\\right]\n\\end{equation}\nInsert (\\ref{eq:taylor})\n\\begin{equation}\n  \\label{eq:w1}\n0 = \\left[\\int W(\\tau)d\\tau\\right]^{-1}\\int W(\\tau)\\left(\\M \\alpha_n + \\C\n  (\\dot a_n + \\tau \\alpha_n) + \\K(a_n + \\tau\\dot a_n + \\half\n  \\tau^2\\alpha_n)+ \\f\n \\right) d\\tau\n\\end{equation}\n\nSince the matrices are constant, we can pull them out of the\nintegral, so if we define\n\\begin{equation}\n  \\label{eq:theta}\n  \\Delta t^k \\theta_k = {\\int_0^{\\Delta t}W(\\tau)\\tau^k\\,d\\tau\\over\n    \\int_0^{\\Delta t}W(\\tau)\\,d\\tau}\n\\end{equation}\nthen (\\ref{eq:w1}) becomes\n\\begin{eqnarray}\n  0 &=& \\M\\alpha_n + \\C(\\dot a_n + \\theta_1\\Delta t\\alpha_n) + \\K (a_n +\n  \\theta_1 \\Delta t\\dot a_n + \\half\\Delta t^2 \\theta_2\\alpha_n) +\n  \\bar \\f \\label{eq:w2} \\\\\n&=& \\left(\\M + \\theta_1\\Delta t\\C + \\half\\theta_2\\Delta t^2\\K\\right) \\alpha_n\n + \\left(\\C + \\theta_1\\Delta t\\K\\right)\\dot a_n + \\K a_n  + \\bar \\f \\label{eq:w3}\n\\end{eqnarray}\nwhere\n\\begin{equation}\n  \\label{eq:fbar}\n  \\bar \\f = {\\int_0^{\\Delta t} W(\\tau)f(t_n+\\tau)\\,d\\tau \\over\n    \\int_0^{\\Delta t}W(\\tau)\\,d\\tau}\n\\end{equation}\n(\\ref{eq:w3}) is a matrix equation which can be solved for $\\alpha_n$.\nThen\n\\begin{eqnarray}\n  \\label{eq:anp1}\n  a_{n+1} &=& a_n + \\Delta t\\dot a_n + \\half\\Delta t^2\\alpha_n \\\\\n  \\label{eq:adnp1}\n  \\dot a_{n+1} &=& \\dot a_n + \\Delta t\\alpha_n\n\\end{eqnarray}\n\nZ\\&T give no guidance on how to compute $\\bar\\f$ in (\\ref{eq:w3})\nexcept to mention that if we assume $\\f(t)$ to be linear in $t$ over\nthe (short) interval $\\Delta t$ (see below) then\n\\begin{equation}\n  \\label{eq:fbar2}\n  \\bar \\f = (1-\\theta_1)\\f(t_n) + \\theta_1\\f(t_{n+1})\n\\end{equation}\nwhich is probably a reasonable approximation.\n\nIf $\\M=0$, the equation is a first order ODE in disguise.  The method\nstill works as long as we choose the right initial value for $\\dot\na_0$.  Just set $\\Delta t=0$ and $\\M=0$ in (\\ref{eq:w3}) to get\n\\begin{equation}\n  \\label{eq:a0}\n  \\dot a_0 = -\\C^{-1}(\\K a_0 + \\bar\\f).\n\\end{equation}\n\n\\section{Nonlinear generalization of SS22}\n\nIf \\M, \\C, or \\K\\ are functions of the variables $a$ or $t$, we can\nmake progress by assuming that they vary linearly over the interval\n$\\Delta t$, like this:\n\\begin{equation}\n  \\label{eq:Mexp}\n  \\M(\\tau) = \\M_n + {\\tau\\over\\Delta t}(\\M_{n+1} - \\M_n)\n\\end{equation}\nwhere $\\M_n$ means $\\M(t_n, a_n)$.  The \\M\\ terms in (\\ref{eq:w1})\nbecome\n\\begin{equation}\n  \\label{eq:m1}\n  \\left[\\int W(\\tau)d\\tau\\right]^{-1}\\int W(\\tau)\\M\\alpha_n\\,d\\tau =\n  (1-\\theta_1)\\M_n\\alpha_n + \\theta_1\\M_{n+1}\\alpha_n\n\\end{equation}\nIn the linear system, where $\\M_n = \\M_{n+1} = \\M$, this reduces to\n$\\M\\alpha_n$, in agreement with (\\ref{eq:w3}).\n\nThe numerator of the \\C\\ terms in (\\ref{eq:w1}) becomes\n\\begin{eqnarray}\n  \\lefteqn{\\int W(\\tau)\\C(\\dot a_n + \\tau\\alpha_n)\\,d\\tau}\\nonumber \\\\\n  &&= \\int W(\\tau)\\left(\\C_n + {\\tau\\over\\Delta t}(\\C_{n+1} - \\C_n)\\right)\n  (\\dot a_n + \\tau\\alpha_n)\\,dt \\\\\n&&= \\int W(\\tau)\\left[\\C_n\\dot a_n + \n  {\\tau\\over\\Delta t}(\\C_{n+1}-\\C_n)\\dot a_n\n  + \\C_n\\tau\\alpha_n + {\\tau^2\\over\\Delta t}(\\C_{n+1}-\\C_n)\\alpha_n\\right]\\, dt\n\\end{eqnarray}\nUse (\\ref{eq:theta}) and restore the denominator to get\n\\begin{eqnarray}\n  &=& \\C_n\\dot a_n + \\theta_1(\\C_{n+1}-\\C_n)\\dot a_n +\n  \\Delta t\\theta_1\\C_n\\alpha_n + \\Delta t\\theta_2(\\C_{n+1}-\\C_n)\\alpha_n \\\\\n  &=& \n  \\label{eq:Cexp}\n  \\Delta t\\left[(\\theta_1-\\theta_2)\\C_n + \\theta_2\\C_{n+1}\\right]\\alpha_n\n  + \\left[(1-\\theta_1)\\C_n+ \\theta_1\\C_{n+1}\\right]\\dot a_n\n\\end{eqnarray}\nIn the linear case where $\\C_{n+1} = \\C_n = \\C$, this reduces to\n$\\Delta t\\theta_1\\C\\alpha_n + \\C\\dot a_n$, also in agreement with\n(\\ref{eq:w3}).\n\nThe numerator of the \\K\\ terms in (\\ref{eq:w1}) becomes\n\\begin{eqnarray}\n  \\lefteqn{\\int W(\\tau)\\K(a_n + \\tau\\dot a_n + \\half\\tau^2\\alpha_n)}\\nonumber \\\\\n  &&= \\int W(\\tau)\n  \\left[\\K_n + {\\tau\\over\\Delta t} (\\K_{n+1} - \\K_n)\\right]\n    (a_n + \\tau\\dot a_n + \\half\\tau^2\\alpha_n)\n\\end{eqnarray}\nIncluding the denominator gives\n\\begin{eqnarray}\n  \\label{eq:Kexp}\n  &=& \\left[(1-\\theta_1)\\K_n + \\theta_1\\K_{n+1}\\right]a_n\n  + \\left[(\\theta_1-\\theta_2)\\K_n + \\theta_2\\K_{n+1}\\right]\\Delta t\\dot a_n\\\\\n  &&\\qquad +\\half \\left[(\\theta_2-\\theta_3)\\K_n + \\theta_3\\K_{n+1}\\right]\n  \\Delta t^2\\alpha_n \\nonumber\n\\end{eqnarray}\nWhen $\\K_n = \\K_{n+1}=\\K$, this reduces to $\\K a_n + \\theta_1\\Delta\nt\\K\\dot a_n + \\half\\theta_2\\Delta t^2\\K\\alpha_n$, in agreement with\n(\\ref{eq:w3}).\n\nCombining (\\ref{eq:Kexp}), (\\ref{eq:Cexp}), and (\\ref{eq:Mexp}), we\nget\n\\begin{equation}\n  \\label{eq:nlsummary}\n  0 = \\textbf{M*}\\alpha_n + \\textbf{C*}\\dot a_n + \\textbf{K*}a_n + \\fbarstar\n\\end{equation}\nwhere\n\\begin{eqnarray}\n  \\textbf{M*} &=& \n    (1-\\theta_1)\\M_n + \\theta_1\\M_{n+1} \n    + \\Delta t\\left[(\\theta_1-\\theta_2)\\C_n + \\theta_2\\C_{n+1}\\right]\n    \\label{eq:Mstar} \\\\\n    && \\nonumber\\qquad + \\half\\Delta t^2 \\left[\n      (\\theta_2-\\theta_3)\\K_n + \\theta_3\\K_{n+1} \\right]\\\\\n    \\textbf{C*} &=& (1-\\theta_1)\\C_n + \\theta_1\\C_{n+1}\n    + \\Delta t\\left[(\\theta_1-\\theta_2)\\K_n + \\theta_2\\K_{n+1}\\right] \n    \\label{eq:Cstar}\\\\\n    \\textbf{K*} &=& (1-\\theta_1)\\K_n + \\theta_1\\K_{n+1}\n    \\label{eq:Kstar} \\\\\n    \\fbarstar &=& (1-\\theta_1)\\f_n + \\theta_1\\f_{n+1} \\label{eq:fstar}\n\\end{eqnarray}\n(\\ref{eq:nlsummary}) is a matrix equation which may be solved for\n$\\alpha_n$, which then determines $a_{n+1}$ and $\\dot a_{n+1}$ via\n(\\ref{eq:anp1}) and (\\ref{eq:adnp1}).  Since $\\M_{n+1}$, $\\C_{n+1}$,\n$\\K_{n+1}$, and $\\f_{n+1}$ may depend on $a_{n+1}$,\n(\\ref{eq:nlsummary}) is non-linear and must be solved iteratively,\nprobably with Picard iteration.\n\nIt's likely that stability requires that $\\theta_i\\ge\\half$ for\n$i=1,2,3$.\n\n\\section{The Numerical Recipes Method}\n\nI'm calling this the Numerical Recipes Method because it's basically\nthe only way that NR suggests handling second order time derivatives.\nIt's not meant to imply that NR invented it.  Surprisingly, Z\\&T\n\\textit{don't} mention this method.\n\nIn (\\ref{eq:ode}), let\n\\begin{equation}\n  \\label{eq:y}\n  y \\equiv \\D^{-1} \\dot a\n\\end{equation}\nwhere $\\D$ is an arbitrary nonsingular matrix.  Then we have two\n\\textit{first} order ODEs:\n\\begin{eqnarray}\n  \\label{eq:ode2a}\n  \\M\\D\\dot y + \\C\\D y + \\K a + \\f &=& 0 \\\\\n  \\label{eq:ode2b}\n  \\dot a - \\D y &=& 0 \n\\end{eqnarray}\nIf we define a new vector that includes the degrees of freedom ($a$)\nand their derivatives ($y$)\n\\begin{equation}\n  \\label{eq:u}\n  u = \\left[\\begin{array}{c} a\\\\y \\end{array} \\right]\n\\end{equation}\nthen the equations can be written as\n\\begin{equation}\n  \\label{eq:ode3}\n  \\tilde\\M \\dot u + \\tilde\\K u + \\tilde f = 0\n\\end{equation}\nwhere\n\\begin{equation}\n  \\label{eq:tildeM}\n  \\tilde\\M = \\left[\\begin{array}{cc}\n      0 & \\M\\D \\\\\n      \\mathcal{I} & 0\n \\end{array}\\right],\n\\end{equation}\n\\begin{equation}\n  \\label{eq:tildeK}\n  \\tilde\\K = \\left[\\begin{array}{cc}\n      \\K & \\C\\D \\\\\n      0 & -\\D \n    \\end{array}\\right],\n\\end{equation}\nand\n\\begin{equation}\n  \\label{eq:tildef}\n  \\tilde f =  \\left[\\begin{array}{c} \\f \\\\ 0 \\end{array}\\right]\n\\end{equation}\nIf we choose $\\D\\approx\\M^{-1}$, then $\\tilde\\M$ should be well\nbehaved. (\\ref{eq:ode3}) can be solved with a number of different\nmethods, such as forward and backward Euler, Runge-Kutta,\n\\textit{etc.}\n\n\n\\end{document}", "meta": {"hexsha": "05d6f9bcd63cadc2413ea6a3569a3ce57014c4df", "size": 8343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "NOTES/timestepping.tex", "max_stars_repo_name": "usnistgov/OOF3D", "max_stars_repo_head_hexsha": "4fd423a48aea9c5dc207520f02de53ae184be74c", "max_stars_repo_licenses": ["X11"], "max_stars_count": 31, "max_stars_repo_stars_event_min_datetime": "2015-04-01T15:59:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T20:21:47.000Z", "max_issues_repo_path": "NOTES/timestepping.tex", "max_issues_repo_name": "usnistgov/OOF3D", "max_issues_repo_head_hexsha": "4fd423a48aea9c5dc207520f02de53ae184be74c", "max_issues_repo_licenses": ["X11"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-02-06T19:30:24.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-25T14:14:31.000Z", "max_forks_repo_path": "NOTES/timestepping.tex", "max_forks_repo_name": "usnistgov/OOF3D", "max_forks_repo_head_hexsha": "4fd423a48aea9c5dc207520f02de53ae184be74c", "max_forks_repo_licenses": ["X11"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-01-23T15:19:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-09T09:03:59.000Z", "avg_line_length": 33.2390438247, "max_line_length": 81, "alphanum_fraction": 0.6398178113, "num_tokens": 3390, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6261241772283035, "lm_q1q2_score": 0.4357563415436638}}
{"text": "\n\\documentclass[preprint, 11pt]{sigplanconf}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\newcommand{\\cL}{{\\cal L}}\n\\newcommand{\\concat}{\\ensuremath{+\\!\\!\\!\\!+\\,}}\n\\begin{document}\n\n\\special{papersize=8.5in,11in}\n\\setlength{\\pdfpageheight}{\\paperheight}\n\\setlength{\\pdfpagewidth}{\\paperwidth}\n\n\n\\titlebanner{McGill University COMP527 Winter2016 final project}\n\\preprintfooter{Review and Test Cases for \\textsc{Myth} by \\citet{osera2015type}}\n\n\\title{Example-directed Program Synthesis}\n\\subtitle{Review and Test Cases}\n\n\\authorinfo{Qi Nan Jin - 260531346}\n           {McGill University}\n           {qi.jin@mail.mcgill.ca}\n\n\\maketitle\n\n\\begin{abstract}\nThis project closely reviews the concept of example-directed program synthesis with a main focus on the new synthesis language $\\lambda_{syn}$ developed by \\citet{osera2015type}, as well as the associated artifact: \\textsc{Myth}. It provides a theoretical review of the underlying concepts, a reproducibility test to the results and a sensitivity test of the synthesis language with respect to example specifications. It also proposes some improvements and additions to the existing \\textsc{Myth} artifact.\\end{abstract}\\\\\n\n\\terms\n$\\lambda_{syn}$, \\textsc{Myth}\\\\\n\n\\keywords\nProgram synthesis, Example-directed\\\\\n\n\\section{Introduction}\\label{sec-intr}\n\nFor decades, program synthesis has been an active and interesting area of research for its promising potential applications \\cite{Basin2004}. Since the early works of \\citet{green1969application}, as well as \\citet{manna1971toward}, a close link has been established between program synthesis and formal deduction systems with heuristics. The underlying relationship between logical frameworks and programs makes program synthesis a particularly interesting topic in both computer science and logics. \\\\\n\nIn the recent years, more attentions have been attributed to the development of example-directed program synthesis. The ideal of example specifications can be related back to early works include \\citet{freeman1991refinement}, which introduces the concept of refinement types. A recent paper by \\citet{osera2015type} introduces a new method for type-and-example-directed program synthesis that claims to match or outperform existing “gold-standard” methods. \\\\\n\nIn this project, a theoretical review of the concept of program synthesis will be provided, leading to a detailed examination of the new method by \\citet{osera2015type}, as well as the emerging artifact, \\textsc{Myth}. \\\\\n\n\\section{Theory}\\label{sec-theo}\n\n\\subsection{Program Synthesis in General}\\label{sec-prog}\n\nWorks in constructive mathematics from as early as the 1930s \\cite{kolmogorov1932theory}\\cite{kreitz1998program} laid foundation in the field of program synthesis, by suggesting the parallel between programs as proofs. With the appearance of automatic theorem provers, program synthesizers emerged shortly thereafter\\cite{kreitz1998program}. \\\\\n\nIn its early stage, program synthesis focuses mainly on proof search, based on early works of \\citet{green1969application}, as well as \\citet{manna1971toward}. The method builds upon the idea that corresponding proof of the specification statement is constructive, for which the steps can be directly associated to methods to construct the program. This method mainly relies on the construction of an extended $\\lambda$-calculus, following the Curry-Howard Isomorphism between proofs and terms \\cite{curry1972combinatory} \\cite{tait1967intensional}.\\\\\n\nA second branch of program synthesis quickly emerged in the late 1970s based on program transformation \\cite{burstall1977transformation}, which usually proceeds by translating the output-condition step-by-step, into logically equivalent or stronger formula \\cite{kreitz1998program}. Different branches of possible optimizations methods for transformational synthesis include Partial evaluation \\cite{bjorner1988partial}, Finite differencing \\cite{paige1982finite}, etc.\\\\\n\n\\subsection{Example-directed program synthesis}\\label{sec-exam}\n\nExample-directed program synthesis aims to provide concrete input-output examples as extra information in the specification in a proof-search based program synthesis. Based on recent work from \\citet{frankle2016example}, examples can be interpreted as refinement types, first studies by Freeman and Pfenning \\cite{freeman1991refinement}\\cite{pfenning1993refinement}. A parallel can be drown between the three fundamental types in the refinement-type system and the input-output specifications. More specifically, the input/output pairs can be identified as singleton types. The functions mapping the input type to the output type can be identified as function/arrow types. Finally, multiple input-output examples used in conjunction can, obviously, identified as the conjunction type in the refinement-type system.\\\\\n\nThe work of \\citet{osera2015type}, builds on this idea and formalizes a synthesis languague: $\\lambda_{syn}$, as shown in Figure \\ref{fig-lambdasyn}. \\\\\n\n\\begin{figure}[!ht]\n  \\begin{center}\n    \\begin{tabular}{lrl}\n            $\\tau$    & ::=    & $\\tau$ $\\mid$ $\\tau_{1} \\rightarrow \\tau_{2}$ \\\\\n            $e$       & ::=    & $x$ $\\mid$ $C(e_{1},..,e_{k})$ $\\mid$ $e_{1}$ $e_{2}$ \\\\\n                      & $\\mid$ & $\\mathrm{fix} \\, f(x:\\tau_{1}):\\tau_{2}=e$ $\\mid$ $pf$ \\\\\n                      & $\\mid$ & $\\mathrm{match}\\, e \\, \\mathrm{ with } \\, p_{1} \\rightarrow e_{1}$ $\\mid$ .. $\\mid$ $p_{m} \\rightarrow e_{m}$ \\\\\n            $p$       & ::=    & $C(x_{1},..,x_{k})$ \\\\\n            $u,v$     & ::=    & $C(v_{1},..,v_{k})$ $\\mid$ $\\mathrm{fix} \\, f(x:\\tau_{1}):\\tau_{2}=e$ $\\mid$ $pf$ \\\\\n            $ex$      & ::=    & $C(ex_{1},..,ex_{k})$ $\\mid$ $pf$ \\\\\n            $pf$      & ::=    & $v_{1} \\Rightarrow ex_{1}$ $\\mid$ .. $\\mid$ $v_{m} \\Rightarrow ex_{m}$ \\\\\n            $E$       & ::=    & $x$ $\\mid$ $E\\,I$ \\\\\n            $I$       & ::=    & $E$ $\\mid$ $C(I_{1},..,I_{k})$ $\\mid$ $\\mathrm{fix} \\, f(x:\\tau_{1}):\\tau_{2}=I$ \\\\\n                      & $\\mid$ & $\\mathrm{match}\\, E \\, \\mathrm{ with } \\, p_{1} \\rightarrow I_{1}$ $\\mid$ .. $\\mid$ $p_{m} \\rightarrow I_{m}$ \\\\\n            $\\Gamma$  & ::= & $\\cdot$ $\\mid$ $x$ : $\\tau,\\Gamma$ \\\\\n            $\\Sigma$  & ::= & $\\cdot$ $\\mid$ $C$ : $\\tau_{1} * .. * \\tau_{n} \\rightarrow T,\\Sigma$ \\\\\n\n            $\\sigma$  & ::= & $\\cdot$ $\\mid$ $[v/x]\\sigma$ \\\\\n            $X$       & ::= & $\\cdot$ $\\mid$ $\\sigma \\mapsto ex \\concat X$\n    \\end{tabular} \\\\\n  \\end{center}\n  \\caption{$\\lambda_{syn}$ syntax as formalized by \\citet{osera2015type}.}\n  \\label{fig-lambdasyn}\n\\end{figure}\n\nThis language also includes full sets of typechecking rules, synthesis rules, auxiliary synthesis functions as well as evaluation and compatibility rules to form a complete framework. The details are exhaustively presented in the original paper \\cite{osera2015type}.\\\\\n\nThe formalized synthesis language $\\lambda_{syn}$ operates in two modes: generating type in elimiation form ($E$-guessing) and checking type in introduction form ($I$-refinement). This is achieved with the help of an new data structure named \\em{refinement tree}. A \\em{refinement tree} includes both goal nodes at which $E$-guessing happen, and refinement nodes at which the type-checking of $I$-refinement is performed. An iterative-deepening search is then applied to this structure to find a matching function that satisfies the input-output specifications \\cite{osera2015type}.\\\\\n\n\\section{Implementation}\\label{sec-impl}\n\nThe authors implemented a prototype synthesizer \\textsc{Myth} under the \\textsc{Ocaml} environment. The artifact uses a relatively naive but balanced search strategy to alternate between $E$-guessing and increasing the number of nodes in the refinement tree. The startegy is described in Figure \\ref{fig-stra}.\\\\\n\n\\begin{figure}[!ht]\n  \\begin{center}\n    \\begin{verbatim}\n        SynthSaturate 0.25\n      ; SynthGrowMatches\n      ; SynthSaturate 0.25\n      ; SynthGrowMatches\n      ; SynthSaturate 0.25\n      ; SynthGrowScrutinees 5\n      ; SynthSaturate 0.25\n      ; SynthGrowMatches\n      ; SynthSaturate 0.25\n      ; SynthGrowScrutinees 5\n      ; SynthSaturate 0.25\n    \\end{verbatim}\n  \\end{center}\n  \\caption{Synthesis strategy of \\textsc{Myth} by \\citet{osera2015type}.}\n  \\label{fig-stra}\n\\end{figure}\n\n\\noindent where \\texttt{SynthSaturate} performs a round of $E$-guessing with the given time constraint, \\texttt{SynthGrowMatches} increases the depth of  the search tree by one, and finally \\texttt{SynthGrowScrutinees} increases the search scrutinee by a specified size. Here the scrutinee growth size is fixed at five (which corresponds to the size of a binary function application \\texttt{f e1 e2}) \\cite{osera2015type}. \\\\\n\nUsing a benchmark testing suite, \\citet{osera2015type} state that \\textsc{Myth} matches or outperforms previous methods by synthesizing more programs as well as achieving it in shorter time on average.\\\\\n\n\\section{Testing}\\label{sec-test}\n\nIn the context of this review project, a straightforward reproducibility test is first performed, using the method and benchmark test set from the paper, to confirm the results published by the authors. A smaller test set is then applied with minor modifications in the input-output example specifications, in order to assess the artifact's sensitivity to example specifications. Finally, a few new test cases are constructed to test the limits of \\textsc{Myth}.\\\\\n\n\\section{Results}\\label{sec-resu}\n\n\\subsection{Reproducibility test}\\label{sec-repr}\n\nIn order to confirm the results published from the paper, a straightforward reproducibility test is first performed using the benchmark test suite and the standard method discribed in the artifact \\citet{osera2015type}. The simulation is run on a Linux laptop machine with an Intel i5-4210H @ 2.90GHz and 8Gb of ram. The result of this reproducibility test is presented in Figure \\ref{fig-repr}. Synthesis times using minimal context in the reproducibility test are generally longer than, but comparable to the ones published in the paper. The longer synthesis time can be explained by the mismatch in the specs of the equipments.\\\\\n\nOne interesting finding is that for several tests, such as \\texttt{list\\_append} and \\texttt{list\\_nth}, the numbers of examples used is significantly lower than the ones reported in the paper. This is likely caused by the fact that the example set of these tests are further optimized since the paper was submitted.\\\\\n\n\\begin{figure}[!ht]\n  \\begin{center}\n  \\footnotesize\n  \\begin{tabular}{ccccc}\n  \\hline\n  \\textbf{Test} & \\textbf{ \\#Ex } & \\textbf{ \\#N } & \\multicolumn{2}{c}{\\textbf{Time-Min (s)}} \\\\\n   &  &  & test & paper \\\\\n  \\hline\n\\multicolumn{5}{c}{\\textbf{Booleans}} \\\\\nbool\\_band & 4 & 6 & 0.0032 & 0.002 \\\\\nbool\\_bor & 4 & 6 & 0.0034 & 0.001 \\\\\nbool\\_impl & 4 & 6 & 0.0036 & 0.002 \\\\\nbool\\_neg & 2 & 5 & 0.001 & 0 \\\\\nbool\\_xor & 4 & 9 & 0.0036 & 0.002 \\\\\n  \\hline\n\\multicolumn{5}{c}{\\textbf{Lists}} \\\\\nlist\\_append & 6 & 12 & 0.007 & 0.003 \\\\\nlist\\_compress & 13 & 28 & 0.116 & 0.073 \\\\\nlist\\_concat & 6 & 11 & 0.011 & 0.006 \\\\\nlist\\_drop & 11 & 13 & 0.023 & 0.013 \\\\\nlist\\_even\\_parity & 7 & 13 & 0.0086 & 0.004 \\\\\nlist\\_filter & 8 & 15 & 0.0282 & 0.067 \\\\\nlist\\_fold & 9 & 13 & 0.1986 & 0.139 \\\\\nlist\\_hd & 3 & 5 & 0.002 & 0.001 \\\\\nlist\\_inc & 4 & 8 & 0.0016 & 0 \\\\\nlist\\_last & 6 & 11 & 0.005 & 0 \\\\\nlist\\_length & 3 & 8 & 0.002 & 0.001 \\\\\nlist\\_map & 8 & 12 & 0.0184 & 0.008 \\\\\nlist\\_nth & 13 & 16 & 0.025 & 0.013 \\\\\nlist\\_pairwise\\_swap & 7 & 19 & 0.0146 & 0.007 \\\\\nlist\\_rev\\_append & 5 & 13 & 0.017 & 0.011 \\\\\nlist\\_rev\\_fold & 5 & 12 & 0.013 & 0.007 \\\\\nlist\\_rev\\_snoc & 5 & 11 & 0.01 & 0.006 \\\\\nlist\\_rev\\_tailcall & 8 & 12 & 0.0098 & 0.004 \\\\\nlist\\_snoc & 8 & 14 & 0.007 & 0.003 \\\\\nlist\\_sort\\_sorted\\_insert & 7 & 11 & 0.013 & 0.008 \\\\\nlist\\_sorted\\_insert & 12 & 24 & 0.1908 & 0.122 \\\\\nlist\\_stutter & 3 & 11 & 0.0018 & 0.001 \\\\\nlist\\_sum & 3 & 8 & 0.004 & 0.002 \\\\\nlist\\_take & 12 & 15 & 0.1406 & 0.112 \\\\\nlist\\_tl & 3 & 5 & 0.0016 & 0.001 \\\\\n  \\hline\n\\multicolumn{5}{c}{\\textbf{Natural Numbers}} \\\\\nnat\\_add & 9 & 11 & 0.004 & 0.002 \\\\\nnat\\_iseven & 4 & 10 & 0.0016 & 0.001 \\\\\nnat\\_max & 9 & 14 & 0.0196 & 0.011 \\\\\nnat\\_pred & 3 & 5 & 0.001 & 0.001 \\\\\n  \\hline\n\\multicolumn{5}{c}{\\textbf{Trees}} \\\\\ntree\\_binsert & 20 & 31 & 0.4856 & 0.374 \\\\\ntree\\_collect\\_leaves & 6 & 15 & 0.0266 & 0.016 \\\\\ntree\\_count\\_leaves & 7 & 14 & 0.0162 & 0.008 \\\\\ntree\\_count\\_nodes & 6 & 14 & 0.016 & 0.009 \\\\\ntree\\_inorder & 5 & 15 & 0.026 & 0.012 \\\\\ntree\\_map & 7 & 15 & 0.029 & 0.014 \\\\\ntree\\_nodes\\_at\\_level & 11 & 22 & 1.0388 & 1.093 \\\\\ntree\\_postorder & 9 & 32 & 1.4258 & 1.136 \\\\\ntree\\_preorder & 5 & 15 & 0.0188 & 0.009 \\\\\n  \\hline\n  \\end{tabular}\n  \\end{center}\n  \\caption{\\textsc{Myth} benchmark suite reproducibility test results using minimal context, where \\#Ex is the number of examples used, \\#N is the size of the result}\n  \\label{fig-repr}\n\\end{figure}\n\n\\begin{figure}[!ht]\n  \\noindent \\small Test case for \\texttt{list\\_nth}:\n  \\scriptsize\n  \\begin{verbatim}\ntype nat =\n  | O | S of nat\n\ntype list =\n  | Nil | Cons of nat * list\n\nlet list_nth : list -> nat -> nat |>\n  { [] => ( 0 => 0\n          | 1 => 0 )\n  | [2] => ( 0 => 2\n           | 1 => 0 )\n  | [1; 2] => ( 0 => 1\n              | 1 => 2 )\n  | [1] => ( 0 => 1\n           | 1 => 0 )\n  | [2; 1] => ( 0 => 2\n              | 1 => 1 )\n  | [3; 2; 1] => ( 0 => 3\n                 | 1 => 2\n                 | 2 => 1 )\n  } = ?\n  \\end{verbatim}\n\n  \\noindent \\small Output with original input:\n  \\scriptsize\n  \\begin{verbatim}\nlet list_nth : list -> nat -> nat =\n  let rec f1 (l1:list) : nat -> nat =\n    fun (n1:nat) ->\n      match n1 with\n        | O -> (match l1 with\n                  | Nil -> 0\n                  | Cons (n2, l2) -> n2)\n        | S (n2) -> (match l1 with\n                       | Nil -> 0\n                       | Cons (n3, l2) -> f1 l2 n2)\n  in\n    f1\n;;\n  \\end{verbatim}\n\n  \\noindent \\small Output with modified input, by changing the order of the last example to \\texttt{[1; 2; 3]}:\n  \\scriptsize\n  \\begin{verbatim}\nlet list_nth : list -> nat -> nat =\n  let rec f1 (l1:list) : nat -> nat =\n    fun (n1:nat) ->\n      match l1 with\n        | Nil -> O\n        | Cons (n2, l2) -> ( match f1 l2 O with\n                           | O -> ( match n1 with\n                                  | O -> n2\n                                  | S (n3) -> O)\n                           | S (n3) -> ( match n1 with\n                                       | O -> n2\n                                       | S (n4) -> S (n3)))\n  in\n    f1\n;;\n  \\end{verbatim}\n  \\caption{Difference in synthesized program given slightly modified example.}\n  \\label{fig-sensitivity}\n\\end{figure}\n\n\\subsection{Sensitivity test}\\label{sec-sens}\n\n\nSeveral test cases are slightly modified by changing the order in which the examples are presented, in order to test \\textsc{Myth}'s sensitivity to example specifications. While programs dealing with simply data types such as \\texttt{bool} or \\texttt{nat} are synthesized identically to the original cases, \\textsc{Myth} fails to synthesize the same program for more complex data types such as \\texttt{list}. An example is shown in Figure \\ref{fig-sensitivity}. This finding will be further discuss in Section \\ref{sec-disc-sens}.\\\\\n\n\\subsection{New test cases}\\label{sec-newc}\n\nFive new test cases, as listed below, are successfully synthesized:\n\n\\begin{itemize}\n  \\item \\texttt{bool\\_iff : bool -> bool -> bool}, which checks the \\emph{if and only if} condition of two \\texttt{bool}.\n  \\item \\texttt{nat\\_eq : nat -> nat -> bool}, which checks if two \\texttt{nat} numbers are equal.\n  \\item \\texttt{list\\_has : nat -> list -> bool}, which checks if a \\texttt{list} contains a specific \\texttt{nat} number.\n  \\item \\texttt{list\\_index : nat -> list -> nat}, which returns the index of the first instance of a specific \\texttt{nat} number in a \\texttt{list}, returns the index of the last element if specified element not found in list.\n  \\item \\texttt{list\\_eq : list -> list -> bool}, which checks whether two lists contain the exact same elements (in same order).\n\\end{itemize}\n\n\\texttt{bool\\_iff} and \\texttt{nat\\_eq} are quite trivial, whereas the three test cases of \\texttt{list} type require more careful tuning of the example specification and definition of helper functions. The synthesis data is listed in Figure \\ref{fig-newc}. The detailed findings will again be further discussed in Section \\ref{sec-disc-cont}.\\\\\n\n\\begin{figure}[!ht]\n  \\begin{center}\n  \\begin{tabular}{cccc}\n  \\hline\n  \\textbf{Test} & \\textbf{ \\#Ex } & \\textbf{ \\#N } & \\textbf{Time (s)} \\\\\n  \\hline\n  nat\\_eq & 5 & 16 & 0.0104 \\\\\n  list\\_eq & 16 & 23 & 13.6328 \\\\\n  list\\_index & 10 & 19 & 1.751 \\\\\n  list\\_has & 7 & 19 & 0.638 \\\\\n  bool\\_band & 4 & 9 & 0.0038 \\\\\n  \\hline\n  \\end{tabular}\n  \\end{center}\n  \\caption{\\textsc{Myth} test results using new test cases, where \\#Ex is the number of examples used, \\#N is the size of the result}\n  \\label{fig-newc}\n\\end{figure}\n\n\\section{Discussion}\\label{sec-disc}\n\n\\subsection{Sensitivity to example specifications}\\label{sec-disc-sens}\nThe most important finding from the tests is that, although not an issue with more premitive data types (\\texttt{bool}, \\texttt{nat}), \\textsc{Myth} is extremely sensitive to example specifications for programs with more complex types. Sometimes, a very slight change in the example specification could result in vastely different results or even failure in synthsis. In some extreme cases, the synthesis changes significantly even by simply adding an extra redundant example. \\citet{osera2015type} did make a note of this issue in their discussion, stating that the examples should be specified in such way that they imitate each recursive call of the target function, which is usually not case in real-life input-output examples available to be used for program synthesis. This is likely going to be the most important challenge to overcome in order for this method to have real-life applications.\\\\\n\n\\subsection{Context size and helper functions}\\label{sec-disc-cont}\nSome of the new test cases require a larger context, \\emph{i.e.}, predefined helper functions. This allows the program to be synthesized correctly but significantly increased the synthsis time. This finding is in agreement of some cases presented by \\citet{osera2015type} in the original publication. The authors attributed this issue to the significantly larger set of possible matches for $E$-guessing given by the helper function. They also proposed possible ways of mitigate this problem, such as optimizing search heuristic.\\\\\n\nIt was pointed out by \\citet{osera2015type} that the synthesis tend to be driven into a counter-intuitive pattern: \\emph{inside-out recursion}, where the synthesized function tends to match for output types from recursive calls itself, rather than input types. Although there are successful cases where a synthesized function with an \\emph{inside-out recursion} does perform the correct task, it is observed during the testing that most of these functions are too specific to satisfying the given set of examples and generally correct. It is also observed, however, that extra context and helper functions tend to decrease the chance of getting an \\emph{inside-out recursion}, at the cost of synthsis time.\\\\\n\n\\subsection{Other findings}\\label{sec-disc-othe}\nAs already pointed out in Section \\ref{sec-disc-cont}, one possible immediate improvement to this synthesis method is to further optimize the search strategy and/or heuristic. The current setting of \\textsc{Myth} has a rather naive, but balanced alternation between term generation and refinement, with a generation timeout of 2.5ms. Based on the description by \\citet{osera2015type} as well as the traces in the source code, it appears that the authors have tested several different possibilities and found the current setting to be the most stable one. During the testing, a few other search strategies, such as a longer timeout for term generation and increasing the size of scrutinee growth, have been attempted. They all prove to be less optimal than the existing stable strategy. Due to time and resource constraint, the different possible search strategies cannot be exhaustively tested, but this should definitely be the main concentration of future works on this topic.\\\\\n\nAnother minor finding of the \\textsc{Myth} prototype is an issue in output formatting. Although \\textsc{Myth} is not compatible with premitive data types in OCaml, such as \\texttt{int} or \\texttt{string}, the authors added an extra layer of parser to translate normal repersentation of a natural number or a list (\\emph{e.g.}, \\texttt{0, 1, [0,1]} etc) into algebraic types \\texttt{nat} and \\texttt{list} recognizable by \\textsc{Myth}. This is certainly done for convenience in specifying input-output examples. During the output step of the synthesized program, the authors reformat the \\texttt{nat} and \\texttt{list} types back into a normal reprsentation. Althought this is more advantageous from an aesthetics point of view, it prevents the synthesized code from being run directly in the context of OCaml. This may potentially cause issues for future wrapper methods for test/application purposes. An adapted implementaion of \\textsc{Myth} is created to resolve this issue by keeping the data types as they are during the output formatting step. \\\\\n\n\\section{Conclusion}\\label{sec-conl}\nThis project provides an overview of the underlying theories of program synthesis with a concentrated attention on the new synthesis language $\\lambda_{syn}$ - a proof-theory-based, example-and-type-directed synthesis algorithm - developped by \\citet{osera2015type}. Reproducibility as well as sensitivity tests are performed on the prototype of $\\lambda_{syn}$'s artifact: \\textsc{Myth}, revealing strengths and weakenesses of this method. Five additional test cases are also successfully synthesized using the \\textsc{Myth} artifact. Interesting results are discovered during the testing and discussed in this report. Optimization of the search strategy has been identified during this project to be the key component that needs to be improved in future works, if time and resources permit. An optimal search strategy will allow this method to accomodate for more formats of example-specification while keeping the synthesis search space reasonably small. Once achieved, this synthesis method has great potential of becoming a usable tool with broader applications.\\\\\n\n\n\\appendix\n\\section{Electronic Appendix}\nAll work done for this project, including an copy of the \\textsc{Myth} artifact with customized implementation (output format fix and new test cases), as well as a copy of this report and its source code, can be found in a repository dedicated to this project at https://github.com/Hachiko99/Project-527.\n\n\\begin{thebibliography}{14}\n\\softraggedright\n\n\\bibitem[Basin et~al.(2004)Basin, Deville, Flener, Hamfelt, and\n  Fischer~Nilsson]{Basin2004}\nD.~Basin, Y.~Deville, P.~Flener, A.~Hamfelt, and J.~Fischer~Nilsson.\n\\newblock \\emph{Program Development in Computational Logic: A Decade of\n  Research Advances in Logic-Based Program Development}, chapter Synthesis of\n  Programs in Computational Logic, pages 30--65.\n\\newblock Springer Berlin Heidelberg, Berlin, Heidelberg, 2004.\n\\newblock ISBN 978-3-540-25951-0.\n\n\\bibitem[Bjorner et~al.(1988)Bjorner, Jones, and Ershov]{bjorner1988partial}\nD.~Bjorner, N.~D. Jones, and A.~Ershov.\n\\newblock \\emph{Partial Evaluation and Mixed Computation: Proceedings of the\n  IFIP TC2 Workshop, Gammel Avernaes, Denmark, 18-24 Oct., 1987}.\n\\newblock Elsevier Science Inc., 1988.\n\n\\bibitem[Burstall and Darlington(1977)]{burstall1977transformation}\nR.~M. Burstall and J.~Darlington.\n\\newblock A transformation system for developing recursive programs.\n\\newblock \\emph{Journal of the ACM (JACM)}, 24\\penalty0 (1):\\penalty0 44--67,\n  1977.\n\n\\bibitem[Curry et~al.(1972)Curry, Feys, Craig, Hindley, and\n  Seldin]{curry1972combinatory}\nH.~B. Curry, R.~Feys, W.~Craig, J.~R. Hindley, and J.~P. Seldin.\n\\newblock Combinatory logic.\n\\newblock 1972.\n\n\\bibitem[Frankle et~al.(2016)Frankle, Osera, Walker, and\n  Zdancewic]{frankle2016example}\nJ.~Frankle, P.-M. Osera, D.~Walker, and S.~Zdancewic.\n\\newblock Example-directed synthesis: a type-theoretic interpretation.\n\\newblock In \\emph{Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium\n  on Principles of Programming Languages}, pages 802--815. ACM, 2016.\n\n\\bibitem[Freeman and Pfenning(1991)]{freeman1991refinement}\nT.~Freeman and F.~Pfenning.\n\\newblock \\emph{Refinement types for ML}, volume~26.\n\\newblock ACM, 1991.\n\n\\bibitem[Green(1969)]{green1969application}\nC.~Green.\n\\newblock Application of theorem proving to problem solving.\n\\newblock Technical report, DTIC Document, 1969.\n\n\\bibitem[Kolmogorov(1932)]{kolmogorov1932theory}\nA.~Kolmogorov.\n\\newblock The theory of functions of a real variable.\n\\newblock \\emph{Science in the USSR during fifteen years: Mathematics}, 1932.\n\n\\bibitem[Kreitz(1998)]{kreitz1998program}\nC.~Kreitz.\n\\newblock Program synthesis.\n\\newblock In \\emph{Automated Deduction—A Basis for Applications}, pages\n  105--134. Springer, 1998.\n\n\\bibitem[Manna and Waldinger(1971)]{manna1971toward}\nZ.~Manna and R.~J. Waldinger.\n\\newblock Toward automatic program synthesis.\n\\newblock \\emph{Communications of the ACM}, 14:\\penalty0 151--165, 1971.\n\n\\bibitem[Osera and Zdancewic(2015)]{osera2015type}\nP.-M. Osera and S.~Zdancewic.\n\\newblock Type-and-example-directed program synthesis.\n\\newblock In \\emph{Proceedings of the 36th ACM SIGPLAN Conference on\n  Programming Language Design and Implementation}, pages 619--630. ACM, 2015.\n\n\\bibitem[Paige and Koenig(1982)]{paige1982finite}\nR.~Paige and S.~Koenig.\n\\newblock Finite differencing of computable expressions.\n\\newblock \\emph{ACM Transactions on Programming Languages and Systems\n  (TOPLAS)}, 4\\penalty0 (3):\\penalty0 402--454, 1982.\n\n\\bibitem[Pfenning(1993)]{pfenning1993refinement}\nF.~Pfenning.\n\\newblock Refinement types for logical frameworks.\n\\newblock In \\emph{Informal Proceedings of the Workshop on Types for Proofs and\n  Programs}, pages 285--299, 1993.\n\n\\bibitem[Tait(1967)]{tait1967intensional}\nW.~W. Tait.\n\\newblock Intensional interpretations of functionals of finite type i.\n\\newblock \\emph{The journal of symbolic logic}, 32\\penalty0 (02):\\penalty0\n  198--212, 1967.\n\n\\end{thebibliography}\n\n\\bibliographystyle{abbrvnat}\n\n\\end{document}\n", "meta": {"hexsha": "b896c9829ea2ff9923c23f048b4b0818b2099f0f", "size": 26492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/Report.tex", "max_stars_repo_name": "awendland/myth-extended", "max_stars_repo_head_hexsha": "3b5a51c905355813654dc185511257364a809929", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/Report.tex", "max_issues_repo_name": "awendland/myth-extended", "max_issues_repo_head_hexsha": "3b5a51c905355813654dc185511257364a809929", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/Report.tex", "max_forks_repo_name": "awendland/myth-extended", "max_forks_repo_head_hexsha": "3b5a51c905355813654dc185511257364a809929", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-12-01T20:38:39.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-15T11:43:21.000Z", "avg_line_length": 63.8361445783, "max_line_length": 1069, "alphanum_fraction": 0.7168956666, "num_tokens": 7594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.43575633364675864}}
{"text": "\\subsection{Fuel salt reprocessing system}\n\n\\begin{frame}\n  \\frametitle{Fuel salt reprocessing system overview: gas separation}\n  Gaseous fission products (e.g., Xe, Kr) must be removed from the fuel salt \n  to avoid reactor poisoning ($\\sigma_{a,^{135}Xe}=10^6\\dots10^7$b). \n  \n      \\begin{columns}\n      \t\\column[t]{4.0cm}\n    \\begin{block}{Noble gas removal}\n      \\begin{enumerate}\n      \t\\item[\\textcolor{blue}{\\textbullet}] bubble generator injects He \n      \tbubbles in the salt stream\n      \t\\item[\\textcolor{green}{\\textbullet}] noble gases migrate to the He \n      \tbubbles \n      \t\\item[\\textcolor{red}{\\textbullet}] gas separator discharges the \n      \tpoison-rich bubbles\n      \\end{enumerate}\n    \\end{block}    \t\n      \t\n     \t\\column[t]{8cm}\n  \\begin{figure}[t]\n\t  \\centering\n\t  \t\t\\vspace{-4mm}\n\t\t\\includegraphics[width=1.03\\textwidth]{./images/msbr_gas_separation.pdf}\n\t\\caption{Schematic flow diagram of the \\gls{MSBR} gas separation system \n\t(figure reproduced from Robertson \\emph{et al.}  \n\t\\cite{robertson_conceptual_1971}).} \n    \\end{figure}\n\n\t\\end{columns}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Mathematical model for gas separation efficiency}\n  \t\t\\vspace{-1mm}\nXenon removal efficiency ($\\epsilon_{Xe}$) in a gas separation system is \n\\cite{peebles_removal_1968, sada_gas-liquid_1987}:\n\\begin{align}\n& \\qquad\\qquad \\epsilon_{Xe} = \\frac{1-e^{-\\beta}}{1+\\alpha} \\nonumber \\\\\n\\alpha &= \\frac{RTQ_{L}}{HQ_{G}} \\nonumber \\\\\n\\beta &= K_L \\frac{6}{d_b} \\frac{Q_G}{Q_G+G_L} \\frac{A_C L (1+\\alpha)}{Q_{L}} \n\\nonumber \\\\\nQ_{L}&= \\mbox{volumetric salt flow rate [$m^3/s$]} \\nonumber \\\\\nQ_{G}&= \\mbox{volumetric helium flow rate [$m^3/s$]} \\nonumber \\\\\nH &= \\mbox{Henry's law constant [$Pa\\cdot mol^{-1}\\cdot L$]} \\nonumber \\\\\nd_b &= \\mbox{helium bubble diameter [m]} \\nonumber \\\\\nK_L &= \\mbox{liquid phase mass transfer coefficient [m/s].} \\nonumber\n\\end{align}\n\t\t\\vspace{-5mm}\n  \\begin{figure}[t]\n\t\\includegraphics[width=0.77\\textwidth]{./images/pipeline_contactor.png}\n\t\\vspace{-2mm}\n\t\\caption{Flow diagram for gas separator (figure reproduced from Peebles \n\t\t\\emph{et al.} \\cite{peebles_removal_1968}).}\n\\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Fuel processing system overview: TAP concept}\n\\begin{textblock*}{12.4cm}(0.25cm,1.7cm) % {block width} (coords)\n\\begin{figure}[htp!] % replace 't' with 'b' to \n\t\\begin{columns}\n\t\t\\column{0.65\\linewidth}\n\t\t\t\\hspace{+3mm}\n\t\t\\includegraphics[height=0.88\\textheight]{../dissertation/figures/ch4/tap_primary_loop.png}\n\t\t\n\t\t\\column{0.3\\linewidth}\n\t\t\\caption{Simplified \\gls{TAP} primary loop design including off-gas \n\t\tsystem \n\t\t(blue), nickel filter (orange) and liquid metal extraction system \n\t\t(green) \\cite{transatomic_power_transatomic_2019}.}\n\t\\end{columns}\n\\end{figure}\n\\end{textblock*}\n\\end{frame}\n\n\n\\subsection{SaltProc tool design}\n\n\n\\begin{frame}\n\\frametitle{SaltProc class architecture}\n\t\\begin{itemize}\n\t\t\\item \\textit{Simulation} class\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Manages simulation process\n\t\t\t\t\\item Stores data into the HDF5 database\n\t\t\t\t\\item Tracks time, power level\n\t\t\t\\end{itemize}\n\t\t\\item \\textit{Depcode} class\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Contains attributes and methods for reading user's input\n\t\t\t\t\\item Creates input files for depletion code\n\t\t\t\t\\item Parses depletion code output \n\t\t\t\\end{itemize}\n\t\t\\item \\textit{Process} class\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Represents fuel processing system component\n\t\t\t\t\\item Contains attributes of the component ($\\vec{\\epsilon}$, \n\t\t\t\tthroughput rate)\n\t\t\t\t\\item Tracks waste stream\n\t\t\t\\end{itemize}\n\t\t\\item \\textit{MaterialFlow} class\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Instances of that class represents the material flowing between processes\n\t\t\t\\end{itemize}\n\t\\end{itemize}\n\t\t\\vspace{1mm}\n\t\\begin{figure}[ht!] % replace 't' with 'b' to \n\t\t\\centering\n\t\t\\begin{overprint}\n\t\t\\onslide<1>\\centerline{\\includegraphics[width=0.6\\textwidth]{../dissertation/figures/ch2/materialflow.pdf}}\n\t\t\\onslide<2>\\centerline{\\includegraphics[width=0.6\\textwidth]{../dissertation/figures/ch2/tap_materialflow.pdf}}\n\t\t\\end{overprint}\n\t\t\\vspace{-2mm}\n\t\t\\caption{Schematic for passing material data between fuel processing \n\t\tsystem components.}\n\t\\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{SaltProc flowchart}\n\\begin{textblock*}{12.4cm}(0.07cm,1.7cm) % {block width} (coords)\n\\begin{figure}[ht!] % replace 't' with 'b' to \\centering\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{../dissertation/figures/ch2/saltproc_flowchart.pdf}\n\t\t\\vspace{-4mm}\n\t\\caption{SaltProc v1.0 Python package flowchart with example of object \n\tinstances.}\n\\end{figure}\n\\end{textblock*}\n\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Multi-component fuel reprocessing system model in SaltProc}       \n\n\\begin{figure}[htp!] % replace 't' with 'b' to \n\t\\centering\n\t\\vspace{-2mm}\n\t\\begin{overprint}\n\t\\onslide<1>\\includegraphics[height=0.85\\textheight]{./images/tap_saltproc_var_eps.png}\n\t\t\\vspace{-2mm}\n    \\caption{\\textcolor{cyan}{\\gls{TAP}} reprocessing scheme for \n\tSaltProc demonstration.}\n\t\\onslide<2>\\includegraphics[height=0.85\\textheight]{./images/msbr_saltproc_var_eps.png}\n\t\t\\vspace{-2mm}\n\t\\caption{\\textcolor{red}{\\gls{MSBR}} reprocessing scheme for \n\tSaltProc demonstration.}\n\t\\end{overprint}\n\\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n\\frametitle{DOT-code describing reprocessing system as a directed graph}\n\\small\n\\begin{verbatim}\ndigraph fuel {\n==============================================================================\ncore_outlet -> sparger [label=\"100%\"]\nsparger -> waste_sparger [label=\"60% of Xe, Kr, H\"]\nsparger -> entrainment_separator [label=\"100%\"]\nentrainment_separator -> nickel_filter [label=\"100%\"]\nentrainment_separator -> waste_entrainment_separator [label=\"97% of Xe, Kr, H\"]\nnickel_filter -> bypass [label=\"90%\"]\nbypass -> heat_exchanger [label=\"90%\"]\nnickel_filter -> waste_nickel_filter [label=\"100% of noble metals\"]\nnickel_filter -> liquid_metal [label=\"10%\"]\nliquid_metal -> heat_exchanger [label=\"10%\"]\nliquid_metal -> waste_liquid_metal [label=\"57% of seminoble metals & RE\"]\nheat_exchanger -> core_inlet [label=\"100%\"]\nLEU_feed -> core_inlet\n==============================================================================\n# Optional parameters to prettify plots\n\\end{verbatim}\n\\end{frame}", "meta": {"hexsha": "25b909affc191dd8ca325c3571684510f404ddbc", "size": 6236, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pres/method.tex", "max_stars_repo_name": "arfc/2020-rykhl-dissertation", "max_stars_repo_head_hexsha": "5c942f25fed851a38d8055a73a23c35a3de5b80d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-15T19:07:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-15T19:07:22.000Z", "max_issues_repo_path": "pres/method.tex", "max_issues_repo_name": "arfc/2020-rykhl-dissertation", "max_issues_repo_head_hexsha": "5c942f25fed851a38d8055a73a23c35a3de5b80d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pres/method.tex", "max_forks_repo_name": "arfc/2020-rykhl-dissertation", "max_forks_repo_head_hexsha": "5c942f25fed851a38d8055a73a23c35a3de5b80d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-10-03T01:05:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-03T01:05:23.000Z", "avg_line_length": 33.8913043478, "max_line_length": 113, "alphanum_fraction": 0.6961193072, "num_tokens": 1966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.43575632574985323}}
{"text": "% Created 2022-02-16 Wed 14:39\n% Intended LaTeX compiler: pdflatex\n\\documentclass[12pt, reqno, oneside]{amsbook}\n              \\usepackage[letterpaper, width=6.5in, height=9in]{geometry}\n\\usepackage[framemethod=TikZ, skipabove=10pt, skipbelow=10pt, backgroundcolor=black!3, roundcorner=4pt, linewidth=1pt]{mdframed}\n\\BeforeBeginEnvironment{minted}{\\begin{mdframed}}\n\\AfterEndEnvironment{minted}{\\end{mdframed}}\n\\numberwithin{equation}{chapter}\n\\usepackage{appendix}\n\\usepackage{url}\n\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage[newfloat]{minted}\n\\usepackage{caption}\n\\author{Yi Zhang}\n\\date{\\today}\n\\title{\\texttt{Fazang}: A Reverse-mode Automatic differentiation tool in Fortran\\\\\\medskip\n\\large User's Guide \\\\  (Version 0.1.0)}\n\\hypersetup{\n pdfauthor={Yi Zhang},\n pdftitle={\\texttt{Fazang}: A Reverse-mode Automatic differentiation tool in Fortran},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 27.2 (Org mode 9.4.4)}, \n pdflang={English}}\n\\begin{document}\n\n\\begin{titlepage}\n\\maketitle\nCopyright 2022, Yi Zhang\n\\newline\n\\newline\n\\newline\n\n\\today\n\\tableofcontents\n\\end{titlepage}\n\n\\chapter{Introduction}\n\\label{sec:orgb4421eb}\n\\texttt{Fazang} is a reverse-mode automatic differentiation (AD) tool. The\nproject is heavily influenced by \\texttt{Stan/Math} \\cite{Carpenter:2015}, a project the author\nis also involved in. \\texttt{Fazang} is intended to support general scientific\ncomputing in Fortran beyond Bayesian inference and Markov Chain\nMonte Carlo that \\texttt{Stan/Math} is designed for. \n\nUser should be aware that the project is at early stage and still\nunder development. For any questions, suggestions, and\ncontributions, please visit the project at \\url{https://github.com/yizhang-yiz/fazang}.\n\\chapter{Quick Start}\n\\label{sec:orgcc6cf98}\nCurrently \\texttt{Fazang} has been tested on Linux and MacOS platform, with\nFortran compiler Intel Fortran 19.0.1+ and GNU Fortran 11.2.0+.\n\nAfter downloading \\texttt{Fazang}, user can use \\texttt{meson} to build the library.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{bash}\ngit clone git@github.com:yizhang-yiz/fazang.git\ncd fazang && mkdir build && cd build\nmeson compile\n\\end{minted}\nThis generates a shared library at \\texttt{build/src/}. User needs to link\nthis library when building an application. This can be done in\n\\texttt{meson} by setting\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{python}\nexecutable('app_name', files('path/to/app_file.F90'), dependencies : fazang_dep)\n\\end{minted}\n\n\\texttt{Fazang} provides a user-facing derived type \\texttt{var}. This is the\ntype for the dependent and independent variables of which the\nadjoint (derivative) will be calculated.\n\nFor example, consider the log of\nthe Gaussian distribution density with mean \\(\\mu\\) and\nstandard deviation \\(\\sigma\\)\n\\begin{equation}\\label{eq:lnormal_example}\n  f(\\mu, \\sigma) = \\log{\\left(\n      \\frac{1}{\\sigma\\sqrt{2\\pi}} \\exp\\left(\n        -\\frac{1}{2}\\left(\\frac{y-\\mu}{\\sigma}\\right)^2\n      \\right)\n    \\right)}\n\\end{equation}\nThe following programe calculates \\(\\frac{df}{d\\mu}\\) and\n      \\(\\frac{df}{d\\sigma}\\) at \\(y=1.3\\), \\(\\mu=0.5\\), and \\(\\sigma=1.2\\).\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nprogram log_demo\n  use fazang ! load Fazang library\n\n  implicit none\n\n  real(rk) :: y\n  type(var) :: f, sigma, mu\n\n  ! data\n  y = 1.3d0\n\n  ! independent variables\n  mu = var(0.5d0)\n  sigma = var(1.2d0)\n\n  ! dependent\n  f = var(-0.5d0 * log(2 * pi))\n  f = f - log(sigma)\n  f = f - 0.5d0 * ((y - mu) / sigma) ** 2.d0;\n\n  ! use grad() to calculate df/d(mu) and df/d(sigma). Each var's\n  ! derivative (also called adjoint) can be access through var%adj().\n\n  call f%grad()\n  write(*, *) \"df/d(mu): \", mu%adj()\n  write(*, *) \"df/d(sigma): \", sigma%adj()\nend program log_demo\n\\end{minted}\n\n\\chapter{Use \\texttt{Fazang}}\n\\label{sec:org446bb05}\n\\texttt{Fazang} uses \\texttt{var} type to record numerical and gradient\noperations. The type supports three functions\n\\begin{itemize}\n\\item \\mintinline[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}{var%val()} : returns value\n\\item \\mintinline[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}{var%adj()} : returns derivative, henceforth referred as \\emph{adjoint}.\n\\item \\mintinline[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}{var%grad()} : takes gradient operation with respect to the current \\mintinline[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}{var} variable.\n\\end{itemize}\n\\section{Constructors}\n\\label{sec:orgbe12852}\n\\texttt{var} can be constructed using overloaded \\texttt{var} interface.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nreal(real64) :: a, b(3), c(2, 3)\nreal(real64) :: new_a, new_b(3), new_c(2, 3)\ntype(var) :: x, y(3), z(2, 3)\n! ...\nx = var()                 ! x%val() == 0.d0\nx = var(a)                ! x%val() == a\ny = var(b)                ! y%val() == b\nz = var(c)                ! z%val() == c\n\\end{minted}\n\\section{Assignment}\n\\label{sec:org8058780}\n\\texttt{var} can be assigned from consistent \\texttt{var} and \\texttt{real(real64)}.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\n! ....\nx = new_a                 ! x%val() == new_a\ny = new_b                 ! y%val() == new_b\nz = new_c                 ! z%val() == new_c\n\\end{minted}\n\n\\section{Gradient}\n\\label{sec:orgfd6291a}\n   \\label{sec:gradient}\nConsider a variable \\(z\\) calculated by the composition of a series of operations\n\\begin{equation*}\nz = f_1(z_1), \\quad z_1 = f_2(z_2), \\quad \\dots, \\quad z_{n-1} = f_n(z_n).\n\\end{equation*}\nFor \\(z_i, i = 1, \\dots, n\\) we refer \\(dz/d{z_i}\\) as the \\emph{adjoint} of \\(z_i\\),\ndenoted by \\(z_i^{\\text{adj}}\\).\nThe chain rule says the adjoints can be calculated recursively \\cite{griewank_evaluating_2008},\n\\begin{equation*}\nz^{\\text{adj}} = 1, \\quad\nz_1^{\\text{adj}} = z^{\\text{adj}} \\frac{df_1}{dz_1}, \\quad\n\\dots, \\quad\nz_i^{\\text{adj}} = z_{i-1}^{\\text{adj}} \\frac{df_i}{dz_i}.\n\\end{equation*}\n\nWe often refer each \\((f_i, z_i)\\) pair as a\n\\emph{node}, and \\(z_i\\) the \\emph{operand} of operation \\(f_i\\). The above recursion through the nodes requires a way to store\nand visit the \\emph{callstack} of nodes.  It is embodied in \\texttt{Fazang} by the \\texttt{var\\%grad()}\nfunction. When \\texttt{z\\%grad()} is called, \\texttt{z}'s adjoint is set to 1, and\nevery other \\texttt{var} variable is transversed with its adjoint updated. In\norder to calculate the adjoint with respect to another variable, user\nmust \\texttt{call set\\_zero\\_all\\_adj()} first to reset all adjoints to zero.\n\nAn alternative to invoke gradient calculation is to define the\ndependent as a function and feed it to \\texttt{Fazang}'s \\texttt{gradient}\nfunction. Take Eq.\\eqref{eq:lnormal_example} for example, we can first\ndefine the function for \\(f(\\mu, \\sigma)\\).\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nmodule func\n  use fazang ! load Fazang library\n  implicit none\n\n  real(rk), parameter :: y = 1.3d0\n\ncontains\n  type(var) function f(x)\n    type(var), intent(in) :: x(:)\n    type(var) :: mu, sigma\n    mu = x(1)\n    sigma = x(2)\n    f = -0.5d0 * log(2 * pi) - log(sigma) - 0.5d0 * ((y - mu) / sigma) ** 2.d0;\n  end function f\n\nend module func\n\\end{minted}\nThen we can supply function \\texttt{f} as a procedure argument.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nprogram log_demo2\n  use iso_c_binding\n  use fazang\n  use func\n\n  implicit none\n\n  real(real64) :: fx(3), x(2)\n  x = [0.5d0, 1.2d0]\n\n  fx = gradient(f, x)\n  write(*, *) \"f(x): \", fx(1)\n  write(*, *) \"df/d(x(1)): \", fx(2)\n  write(*, *) \"df/d(x(2)): \", fx(3)\nend program log_demo2\n\\end{minted}\nThe output of \\texttt{gradient(f, x)} is an array of size \\texttt{1 + size(x)}, with\nfirst component being the function value, and the rest the partial\nderivatives.\n\nNote that the above approach of using \\texttt{gradient} function does not\ninvolve explicitly setting up \\texttt{var} variables. \\texttt{Fazang} achieves this\nby using a \\emph{nested} AD envionment.\n\n\\section{Nested AD envionment}\n\\label{sec:orgf79e864}\n   \\label{sec:nested}\nLet us take a look of the internals of \\texttt{Fazang}'s \\texttt{gradient} function.\nThe \\texttt{dependent\\_function} interface requires \\(f\\) to follow the above\nexample's signature, and \\texttt{x} is the \\texttt{real64} array of independent variables.\nWe then create the \\texttt{var} version of \\texttt{x} and introduct it to \\texttt{f}. The\nevaluation result is saved in \\texttt{f\\_var} variable. The adjoints are\nobtained by calling \\texttt{f\\_var\\%grad()}. Unlike what we have seen, the\nabove process happens within a pairing \\texttt{begin\\_nested()} and\n\\texttt{end\\_nested()} calls.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nfunction gradient(f, x) result (f_df)\n  procedure(dependent_function) :: f\n  real(real64), intent(in) :: x(:)\n  real(real64) :: f_df(1 + size(x))\n  type(var) :: x_var(size(x)), f_var\n\n  call begin_nested()\n\n  x_var = var(x)\n  f_var = f(x_var)\n  f_df(1) = f_var%val()\n  call f_var%grad()\n  f_df(2:(1+size(x))) = x_var%adj()\n\n  call end_nested()\nend function gradient\n\\end{minted}\nWhen we use these two functions, all the \\texttt{var} variables created\nin between are \"temporary\", in the sense that the values and adjoints\nof these variables are no longer available after \\texttt{call\nend\\_nested()}. User can use this function pair to construct a local\ngradient evaluation procedure.\n\n\\section{Jacobian}\n\\label{sec:orgdde6fc2}\n   \\label{sec:jacobian}\nSimilar to \\texttt{gradient}, using the same nested technique \\texttt{Fazang}\nprovides a \\texttt{jacobian} function that calculates the Jacobian matrix of\n\\texttt{f}, a multivariate function \\(f: \\mathbb{R}^m \\rightarrow \\mathbb{R}^n\\) for\nan input array \\texttt{x} of dimension \\texttt{m}.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nfunction jacobian(f, n, x) result (f_df)\n\\end{minted}\nThe input function must follow the interface\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nabstract interface\n   function jac_dependent_function (x, n) result (fx)\n     import :: var\n     integer, intent(in) :: n\n     type(var), intent(in) :: x(:)\n     type(var) :: fx(n)\n   end function jac_dependent_function\nend interface\n\\end{minted}\nwhere \\texttt{n} is the output dimension. Like \\texttt{gradient}, the output \\texttt{f\\_df}\nhas dimension \\(n\\times(m+1)\\), with the first column being the function\nresults and the rest columns the adjoints.\n\n\\section{Functions}\n\\label{sec:org2b87706}\nNumeric functions supported by \\texttt{Fazang} are listed in Appendix \\ref{appendix:func}. All unary and\nbinary functions are \\texttt{elemental}. The binary functions allow mixed\nargument types, namely, either argument can be \\texttt{real64} type while the\nother the \\texttt{var} type.\n\nProbability distributions supported by \\texttt{Fazang} are list in Appendix \\ref{appendix:likelihood}.\n\n\\section{Ordinary differential equations}\n\\label{sec:orge24bbe8}\n\\texttt{Fazang} supports ODE solutions through CVODES from SUNDIALS library\n\\cite{hindmarsh2005sundials}. One can solve ODE like this.\n\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\n! user defined ODE\nmodule ode_mod\n  use fazang\n  use, intrinsic :: iso_c_binding\n  implicit none\n\n  real(rk), parameter :: params(2) = [0.2d0, 0.1d0]\n\ncontains\n  ! user defined right-hand-side\n  subroutine eval_rhs(t, y, fy)\n    real(c_double), intent(in) :: t, y(:)\n    real(c_double), intent(inout) :: fy(size(y))\n    fy(1) = y(2)\n    fy(2) = t * y(1) * sum(params%val())\n  end subroutine eval_rhs\nend module ode_mod\n\nprogram cvodes_solve_data\n  use ode_mod                   ! import ODE\n  use fazang                    ! import Fazang\n\n  implicit none\n\n  real(rk) :: yt(2, 3)          ! output array\n  real(rk) :: y0(2)             ! initial condition\n  type(cvodes_tol) :: tol       ! basic solver control\n\n  ! use BDF method with given relative tolerance, absolute tolerance,\n  ! and max number of steps between outputs\n  tol = cvodes_tol(CV_BDF, 1.d-10, 1.d-10, 1000_8)\n\n  ! initial condition\n  y0 = [1.2d0, 1.8d0]\n\n  ! solve the ODE with initial time 0.d0 and\n  ! output time 1.d0, 2.d0, 3.d0\n  yt = cvodes_sol(0.d0, y0, [1.d0, 2.d0, 3.d0], eval_rhs, tol)\n\nend program cvodes_solve_data\n\\end{minted}\nIn the above example, we first define an ODE following \\texttt{Fazang}'s\ninterface on the RHS. The defined RHS function \\texttt{eval\\_rhs} will be later used as an\nargument to \\texttt{cvodes\\_sol}. In addition to initial condition, one must\nalso define an object for solver control. Such an object must be of a\ntype that \\texttt{extend} the \\texttt{cvodes\\_options} abstract type. Here we use \\texttt{Fazang}'s\nbasic type \\texttt{cvodes\\_tol}, which gives: the integration scheme (\\texttt{CV\\_BDF}\nfor BDF method or \\texttt{CV\\_ADAMS} for Adams-Moulton method), relative\ntolerance, absolution tolerance, and the maximum number of steps\nallowed between output.\n\nThen to the solver interface \\texttt{cvodes\\_sol} we give the initial time,\ninitial condition, array for output time, the RHS subroutine, and the\nsolver control. It returns a 2D array with each column at a requested\noutput time.\n\n\\subsection{Forward sensitivity}\n\\label{sec:org5755bfa}\nCombining the sensitivity capability of \\texttt{CVODES} and AD from \\texttt{Fazang},\nwe can solve for ODE sensitivity with respect to given parameters\nwithout explicitly supplying Jacobian. For that the user-defined ODE\nmust include an additional RHS definition with \\texttt{var} parameters,\nfollowing \\texttt{Fazang}'s RHS interface.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nmodule ode_mod\n  use fazang\n  use, intrinsic :: iso_c_binding\n  implicit none\n\n  real(rk), parameter :: omega = 0.5d0\n  real(rk), parameter :: d1 = 1.0d0\n  real(rk), parameter :: d2 = 1.0d0\n\ncontains\n  ! right-hand-side for data input\n  subroutine eval_rhs(t, y, fy)\n    implicit none\n    real(c_double), intent(in) :: t, y(:)\n    real(c_double), intent(inout) :: fy(size(y))\n    fy(1) = y(2)\n    fy(2) = sin(omega * d1 * d2 * t)\n  end subroutine eval_rhs\n\n  ! right-hand-side for var input with parameters\n  ! y, p, and output fy must all be of var type\n  subroutine eval_rhs_pvar(t, y, fy, p)\n    implicit none\n    real(c_double), intent(in) :: t\n    type(var), intent(in) :: y(:), p(:)\n    type(var), intent(inout) :: fy(size(y))\n    fy(1) = y(2)\n    fy(2) = sin(p(1) * p(2) * p(3) * t)\n  end subroutine eval_rhs_pvar\nend module ode_mod\n\\end{minted}\nNow we can solve the defined ODE in a similar way.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nprogram cvodes_demo\n  use ode_mod\n  use fazang\n  implicit none\n\n  type(var) :: yt(2, 3)\n  type(cvodes_tol) :: tol\n  real(rk), parameter :: ts(3) = [1.2d0, 2.4d0, 4.8d0]\n  real(rk), parameter :: y00(2) = [0.2d0, 0.8d0]\n  type(var) :: param(3)\n  real(rk) :: y0(2), ga(2)\n  integer :: i, j\n\n  y0 = y00                      ! init condition\n  param = var([omega, d1, d2])  ! parameters\n  tol = cvodes_tol(CV_BDF, 1.d-10, 1.d-10, 1000_8)\n\n  yt = cvodes_sol(0.d0, y0, ts, param, eval_rhs,&\n       & eval_rhs_pvar, tol)\n! ...\nend program cvodes_demo\n\\end{minted}\nNote that now the call to \\texttt{cvodes\\_sol} includes additional argument\n\\texttt{param} as the sensitivity parameters, as well as the RHS function for\n\\texttt{var} inputs. The sensitivities are obtained the same way by calling\n\\texttt{grad} and \\texttt{adj} functions.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\ncall yt(1, 1) % grad()\nwrite(*, *) \"dy_1/ d_omega at time ts(1):\", param(1)%adj()\n\\end{minted}\n\n\\subsection{Functions}\n\\label{sec:orgf1d1100}\n\\begin{enumerate}\n\\item Data solution\n\\label{sec:org271df10}\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nfunction cvodes_sol(t, y, ts, rhs, cvs_options) result(yt)\n    real(real64), intent(in) :: t          ! initial time\n    real(real64), intent(inout) :: y(:)    ! initial condition\n    real(real64), intent(in) :: ts(:)      ! output time\n    procedure(cvs_rhs_func) :: rhs         ! RHS definition (see below)\n    class(cvodes_options), intent(in) :: cvs_options ! solver control\n    real(real64) :: yt(size(y), size(ts))  ! solution\n\\end{minted}\n\n\\item Sensitivity solution  with respect to the initial condition\n\\label{sec:orgf19dcad}\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nfunction cvodes_sol(t, y, ts, rhs, rhs_yvar, cvs_options) result(yt)\n    real(real64), intent(in) :: t          ! initial time\n    type(var), intent(inout) :: y(:)       ! initial condition\n    real(real64), intent(in) :: ts(:)      ! output time\n    procedure(cvs_rhs_func) :: rhs         ! data-only RHS (see below)\n    procedure(cvs_rhs_func_yvar) :: rhs_yvar ! var-type RHS (see below)\n    class(cvodes_options), intent(in) :: cvs_options  ! solver control\n    type(var) :: yt(size(y), size(ts))     ! solution\n\\end{minted}\n\n\\item Sensitivity solution  with respect to the parameters\n\\label{sec:org64f810b}\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nfunction cvodes_sol(t, y, ts, param, rhs, rhs_pvar, cvs_options) result(yt)\n    real(real64), intent(in) :: t          ! initial time\n    real(real64), intent(inout) :: y(:)    ! initial condition\n    real(real64), intent(in) :: ts(:)      ! output time\n    type(var), target, intent(in) :: param(:) ! parameters\n    procedure(cvs_rhs_func) :: rhs         ! data-only RHS (see below)\n    procedure(cvs_rhs_func_pvar) :: rhs_pvar ! var-type RHS (see below)\n    class(cvodes_options), intent(in) :: cvs_options  ! solver control\n    type(var) :: yt(size(y), size(ts))     ! solution\n\\end{minted}\n\n\\item Interfaces for different solvers\n\\label{sec:org58311fb}\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nabstract interface\n   subroutine cvs_rhs_func(t, y, fy)\n     import c_double\n     real(c_double), intent(in) :: t, y(:)\n     real(c_double), intent(inout) :: fy(size(y))\n   end subroutine cvs_rhs_func\n\n   subroutine cvs_rhs_func_yvar(t, y, f)\n     import c_double, var\n     real(c_double), intent(in) :: t\n     type(var), intent(in) :: y(:)\n     type(var), intent(inout) :: f(size(y))\n   end subroutine cvs_rhs_func_yvar\n\n   subroutine cvs_rhs_func_pvar(t, y, f, p)\n     import c_double, var\n     real(c_double), intent(in) :: t\n     type(var), intent(in) :: y(:), p(:)\n     type(var), intent(inout) :: f(size(y))\n   end subroutine cvs_rhs_func_pvar\nend interface\n\\end{minted}\n\n\\item Solver controls\n\\label{sec:org06a915d}\nThe last argument of the solver call is a solver control\nobject. User-defined type must be able to follow \\texttt{CVODES} user guide\nto modify \\texttt{CVODES} memory object, by extending the abstract type \\texttt{cvodes\\_options}.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\ntype, abstract :: cvodes_options\n   integer :: cv_method = -1\n contains\n   procedure(set_cvodes), deferred :: set\nend type cvodes_options\n\nabstract interface\n   subroutine set_cvodes(this, mem)\n     import c_ptr, cvodes_options\n     class(cvodes_options), intent(in) :: this\n     type(c_ptr), intent(inout) :: mem ! CVODES memory\n   end subroutine set_cvodes\nend interface\n\\end{minted}\nOne can follow \\texttt{Fazang} 's tolerance control type as an example.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\n  type, extends(cvodes_options) :: cvodes_tol\n     real(c_double) :: rtol, atol\n     integer(c_long) :: max_nstep\n  contains\n    procedure :: set\n end type cvodes_tol\n\ncontains\n\n  subroutine set(this, mem)\n    class(cvodes_tol), intent(in) :: this\n    type(c_ptr), intent(inout) :: mem ! CVODES memory\n    integer :: ierr\n! call cvodes functions\n    ierr = FCVodeSStolerances(mem, this % rtol, this % atol)\n    ierr = FCVodeSetMaxNumSteps(mem, this % max_nstep)\n  end subroutine set\n\\end{minted}\n\\end{enumerate}\n\n\\chapter{Design}\n\\label{sec:org85ae2ef}\nThe core of any reverse-mode automatic differentiation is the data\nstructure to store and visit the callstack. \\texttt{Fazang} achieves this\nthrough two derived types, \\texttt{tape} and \\texttt{vari}.\n\n\\section{\\texttt{tape} data structure}\n\\label{sec:org2bb7ef1}\nA \\texttt{tape} is an \\texttt{int32} array emulating a stack, with an integer marker \\texttt{head} pointing to the\nhead to the current stack top.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\ntype :: tape\n     integer(ik) :: head = 1\n     integer(ik), allocatable :: storage(:)\n!...\n\\end{minted}\nEach time a new AD node is created,\nspace in \\texttt{storage} is allotted to store the node's\n\\begin{itemize}\n\\item value \\(f_i(z_i)\\),\n\\item adjoint \\(z_{i-1}^{\\text{adj}}\\),\n\\item number of \\texttt{var} operands of \\(f_i\\),\n\\item The \\texttt{var} operands' index in the same \\texttt{tape} array,\n\\item number of \\texttt{real64} operands of \\(f_i\\),\n\\item The \\texttt{real64} operands' value.\n\\end{itemize}\n\nSince a node's value, adjoint, and data\noperands are \\texttt{real64}, they are first converted to \\texttt{int32} using\n\\texttt{transfer} function before stored in the \\texttt{tape} array, so that each such\na value occupies two \\texttt{storage} entries. After each\nallotation, the \\texttt{head} is moved to point to the next empty slot in\nthe array after saving its current value to a \\texttt{vari} type variable\nfor future retrieval.\n\n\\section{\\texttt{vari} type}\n\\label{sec:org611a41b}\nThe \\texttt{vari} type is simply a proxy of a node's storage location in the tape\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\ntype :: vari\n  integer(ik) :: i = 0\n  procedure(chain_op), pass, pointer :: chain\ncontains\n   !....\n\\end{minted}\nwhere \\texttt{i} is the index to the beginning of a node's storage, and the\n\\texttt{chain} procedure encodes the node's operation\n\\(f_i\\). \\texttt{chain} follows an interface that describes the chain rule\noperation\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nabstract interface\n   subroutine chain_op(this)\n     import :: vari\n     class(vari), intent(in) :: this\n   end subroutine chain_op\nend interface\n\\end{minted}\nAn alternative to integer index is to a \\texttt{pointer} to the according\nenry in the \\texttt{tape} array. However, we will need to expand the\n\\texttt{storage} when it is filled up, and \\texttt{Fazang} does this by doubling the\n\\texttt{storage} size and use \\texttt{move\\_alloc} to\nrestore the original values. Since there is no guarantee that \\texttt{move\\_alloc}\nwill keep the original memory, a pointer to the original address would\nbe corrupted.\n\nAs a \\texttt{Fazang} program steps forward, a series of \\texttt{vari} variables are\ngenerated, with their \\emph{values} calculated and stored. This is called\na \\emph{forward pass}. The generated \\texttt{vari} variables in the forward pass are\nstored in array \\texttt{varis}. Each entry in \\texttt{varis} is a dependent\n(operation output) of one or more previous entries.\n\n\\section{\\texttt{var} type}\n\\label{sec:orgf8b9d4f}\nThe user-facing \\texttt{var} type serves as proxy to \\texttt{vari}. Each \\texttt{var}\nstores the index of a \\texttt{vari} in the \\texttt{varis} array.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\ntype :: var\n   integer(int32) :: vi\n contains\n   procedure :: val\n   procedure :: adj\n   procedure :: grad\n   procedure :: set_chain\nend type var\n\\end{minted}\nAfter the forward pass, when adjoints are desired, we call \\texttt{grad} or\n\\texttt{gradient} procedure. This initiates a \\emph{backward pass}, in which  the\n\\texttt{varis} array is traversed backward\nso that each \\texttt{vari}'s \\texttt{chain} procedure is called to update the\noperand adjoints.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nsubroutine grad(this)\n  class(var), intent(in) :: this\n  integer i\n  call callstack % varis (this%vi) % init_dependent()\n  do i = callstack % head - 1, 1, -1\n     call callstack % varis(i) % chain()\n  end do\nend subroutine grad\n\\end{minted}\nHere \\texttt{callstack} is the module variable that encapsulate \\texttt{tape} and\n\\texttt{varis} arrays.\n\n\\section{Nested tape}\n\\label{sec:orgde2db32}\n\\texttt{Fazang} use \\texttt{begin\\_nested()} and \\texttt{end\\_nested()} to record and\nterminate a nested tape. With \\texttt{call begin\\_nested()} \\texttt{Fazang} records\nthe current \\texttt{tape} and \\texttt{varis} array head. When \\texttt{end\\_nested()} is\ncalled, the storage between the recorded head and current head are\nwiped, and the head is moved back to the recorded location. Multiple\nlevels of nested envionment are supported this way.\n\n\\chapter{Add operation functions}\n\\label{sec:org0c57838}\nAdding an operation \\(f_i\\) involves creating functions for forward\npass and backward pass. Let us first use \\texttt{log} function as a simple\nexample.\n\nFirst, we create a \\texttt{log\\_v} function for the forward pass.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nimpure elemental function log_v(v) result(s)\n  type(var), intent(in) :: v\n  type(var) :: s\n  s = var(log(v%val()), [v])\n  call s%set_chain(chain_log)\nend function log_v\n\\end{minted}\nThe function generates a new \\texttt{var} variable \\texttt{s} using a special\nconstructor \\texttt{var(value, array of operands)} which stores the value as\nwell as the single operand \\texttt{v}'s index (in the \\texttt{tape} \\texttt{storage}\narray). It also points \\texttt{s}'s chain to a dedicated procedure \\texttt{chain\\_log}.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nsubroutine chain_log(this)\n  class(vari), intent(in) :: this\n  real(rk) :: adj(1), val(1)\n  val = this%operand_val()\n  adj(1) = this%adj() / val(1)\n  call this%set_operand_adj(adj)\nend subroutine chain_log\n\\end{minted}\nTo understand this function, recall the recursion in Section \\ref{sec:gradient},\nassume the \\texttt{log} operation is node \\(i\\), then \\(f_i=\\log(\\dot)\\) and\n\\(z_i\\) is the operand \\texttt{v}, and the new \\texttt{var} \\texttt{s} would be\n\\(z_{i-1}\\). During the backward pass when the node is visited, \\texttt{chain\\_log} \nfirst retrieves current \\((z_i, z_i^{\\text{adj}})\\)\nusing \\texttt{operand\\_val()} and \\texttt{operand\\_adj()}, then updates\n\\(z_i^{\\text{adj}}\\) with an additional\n\\begin{equation*}\nz_{i-1}^{\\text{adj}} \\frac{df_i}{dz_i} = z_{i-1}^{\\text{adj}}\\frac{d\\log(z_i)}{dz_i}=\\frac{z_{i-1}^{\\text{adj}}}{z_i}.\n\\end{equation*}\n\nAdding a binary operation \\(f_i(z_i^{(1)}, z_i^{2})\\) is slightly more complex, as we will need to\naddress possibly different scenarios when \\(z_i^{(1)}\\) and \\(z_i^{(2)}\\)\nare either \\texttt{var} or \\texttt{real64}. Let us use overloaded division \\texttt{operator(/)} as an example.\n\nWith\n\\begin{equation*}\nf_i(z_i^{(1)}, z_i^{2}) = z_i^{(1)} / z_i^{(2)}\n\\end{equation*}\nwe need to account for\n\\begin{itemize}\n\\item both \\(z_i^{(1)}\\) and \\(z_i^{2}\\) are \\texttt{var}'s\n\\item \\(z_i^{(1)}\\) is \\texttt{var}, \\(z_i^{2}\\) is \\texttt{real64},\n\\item \\(z_i^{(1)}\\) is \\texttt{real64}, \\(z_i^{2}\\) is \\texttt{var},\n\\end{itemize}\n\n\nFor the first scenario, we create\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nimpure elemental function div_vv(v1, v2) result(s)\n  type(var), intent(in) :: v1, v2\n  type(var) :: s\n  s = var(v1%val() / v2%val(), [v1, v2])\n  call s%set_chain(chain_div_vv)\nend function div_vv\n\\end{minted}\nSimilar to the \\texttt{log} example, we create a new \\texttt{s} with both operands\nstored. In the corresponding \\texttt{chain} procedure, we need update\nthe adjoints of both \\texttt{v1} and \\texttt{v2}.\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nsubroutine chain_div_vv(this)\n  class(vari), intent(in) :: this\n  real(rk) :: adj(2), val(2)\n  val = this%operand_val()\n  adj(1) = this%adj()/val(2)\n  adj(2) = - this%val() * this%adj()/val(2)\n  call this%set_operand_adj(adj)\nend subroutine chain_div_vv\n\\end{minted}\n\nFor the second scenario, we create\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nimpure elemental function div_vd(v, d) result(s)\n  type(var), intent(in) :: v\n  real(rk), intent(in) :: d\n  type(var) :: s\n  s = var(v%val() / d, [v], [d])\n  call s%set_chain(chain_div_vd)\nend function div_vd\n\\end{minted}\nAgain we create a new \\texttt{var} \\texttt{s}. But this time\nwe use another constructor \\texttt{var(value, var operands, data\noperands)} to store value, \\texttt{var} operand \\texttt{v}, and \\texttt{real64}\noperand \\texttt{d}. In the corresponding backward pass \\texttt{chain} procedure, not\n      only we need retrieve \\texttt{var} operand \\texttt{v} but also data operand\n      \\texttt{d}, as the new adjoint of \\(z_i^{(1)}\\) is\n\\begin{equation*}\nz_i^{(1)\\text{new adj}} = z_i^{(1)\\text{old adj}} + z_{i-1}^{\\text{adj}}\\frac{df_i}{dz_i^{(1)}}\n= z_i^{(1)\\text{old adj}} + z_{i-1}^{\\text{adj}}\\frac{1}{dz_i^{(2)}}\n\\end{equation*}      \nSo with \\texttt{v} as \\(z_i^{(1)}\\) and \\texttt{d} as \\(z_i^{(2)}\\) we have\n\\begin{minted}[breaklines=true,fontsize=\\footnotesize,breakanywhere=true]{fortran}\nsubroutine chain_div_vd(this)\n  class(vari), intent(in) :: this\n  real(rk) d(1), adj(1)\n  d = this%data_operand()\n  adj(1) = this%adj() / d(1)\n  call this%set_operand_adj(adj)\nend subroutine chain_div_vd\n\\end{minted}\n\nThe third scenario is treated similarly.\n\n\\appendix\n\\chapter{\\texttt{Fazang} Functions \\label{sec:func_list}}\n\\label{sec:org3f9b4b7}\n\\label{appendix:func}  \n\\begin{center}\n\\begin{tabular}{lll}\nFunction & Argument(s) & Operation\\\\\n\\hline\n\\texttt{sin} & scalar or array & same as intrinsic\\\\\n\\texttt{cos} & scalar or array & same as intrinsic\\\\\n\\texttt{tan} & scalar or array & same as intrinsic\\\\\n\\texttt{asin} & scalar or array & same as intrinsic\\\\\n\\texttt{acos} & scalar or array & same as intrinsic\\\\\n\\texttt{atan} & scalar or array & same as intrinsic\\\\\n\\texttt{log} & scalar or array & same as intrinsic\\\\\n\\texttt{exp} & scalar or array & same as intrinsic\\\\\n\\texttt{sqrt} & scalar or array & same as intrinsic\\\\\n\\texttt{erf} & scalar or array & same as intrinsic\\\\\n\\texttt{erfc} & scalar or array & same as intrinsic\\\\\n\\texttt{abs} & scalar or array & same as intrinsic\\\\\n\\texttt{norm2} & 1D array & same as intrinsic\\\\\n\\texttt{hypot} & scalars or arrays & same as intrinsic\\\\\n\\texttt{sinh} & scalar of array & same as intrinsic\\\\\n\\texttt{cosh} & scalar of array & same as intrinsic\\\\\n\\texttt{tanh} & scalar of array & same as intrinsic\\\\\n\\texttt{asinh} & scalar of array & same as intrinsic\\\\\n\\texttt{acosh} & scalar of array & same as intrinsic\\\\\n\\texttt{atanh} & scalar of array & same as intrinsic\\\\\n\\texttt{log\\_gamma} & scalar or array & same as intrinsic\\\\\n\\texttt{square} & scalar or array & For input \\texttt{x}, calculate \\texttt{x**2}\\\\\n\\texttt{inv} & scalar or array & For input \\texttt{x}, calculate \\texttt{1/x}\\\\\n\\texttt{inv\\_square} & scalar or array & For input \\texttt{x}, calculate \\texttt{1/x**2}\\\\\n\\texttt{inv\\_sqrt} & scalar or array & For input \\texttt{x}, calculate \\texttt{1/sqrt(x)}\\\\\n\\texttt{logit} & scalar or array & For input \\texttt{x}, calculate \\texttt{log(x/(1-x))}\\\\\n\\texttt{inv\\_logit} & scalar or array & For input \\texttt{x}, calculate \\texttt{1/(1+exp(-x))}\\\\\noperator (\\texttt{+}) & scalars or arrays & same as intrinsic\\\\\noperator (\\texttt{-}) & scalars or arrays & same as intrinsic\\\\\noperator (\\texttt{*}) & scalars or arrays & same as intrinsic\\\\\noperator (\\texttt{/}) & scalars or arrays & same as intrinsic\\\\\noperator (\\texttt{**}) & scalars & same as intrinsic\\\\\n\\texttt{sum} & 1D array & same as intrinsic\\\\\n\\texttt{dot\\_product} & 1D arrays & same as intrinsic\\\\\n\\texttt{log\\_sum\\_exp} & 1D array & For input \\texttt{x}, calculate \\texttt{log(sum(exp((x))))}\\\\\n\\texttt{matmul} & 2D arrays & same as intrinsic\\\\\n\\end{tabular}\n\\end{center}\n\n\\chapter{\\texttt{Fazang} Probability distributions \\label{sec:likelihood_list}}\n\\label{sec:org558cd1e}\n\\label{appendix:likelihood}  \n\\section{Normal distribution}\n\\label{sec:org1a8138a}\n\\begin{equation}\n\\text{Normal}(y, \\mu, \\sigma) = \\prod_{i=1}^n\\frac{1}{\\sqrt{2\\pi}\\sigma}\\exp{\n  \\left(\n    -\\frac{1}{2}\n    \\left(\n      \\frac{y_i-\\mu}{\\sigma}\n    \\right)^2\n  \\right)\n},\\qquad\n\\forall y\\in \\mathbb{R}^n, \\mu\\in \\mathbb{R}, \\sigma\\in \\mathbb{R}^+.\n\\end{equation}\n\n\\begin{itemize}\n\\item \\texttt{normal\\_lpdf(y, mu, sigma)}\n\\begin{itemize}\n\\item \\texttt{y}: \\texttt{real64} array.\n\\item \\texttt{mu}: \\texttt{real64} or \\texttt{var}.\n\\item \\texttt{sigma}: \\texttt{real64} or \\texttt{var}.\n\\item Return: the \\texttt{log} of \\(\\text{Normal}(y, \\mu, \\sigma)\\).\n\\end{itemize}\n\\end{itemize}\n\n\\section{LogNormal distribution}\n\\label{sec:org8579ae6}\n\\begin{equation}\n\\text{LogNormal}(y, \\mu, \\sigma) = \\prod_{i=1}^n\\frac{1}{\\sqrt{2\\pi}\\sigma}\\frac{1}{y_i}\\exp{\n  \\left(\n    -\\frac{1}{2}\n    \\left(\n      \\frac{\\log{y_i}-\\mu}{\\sigma}\n    \\right)^2\n  \\right)\n},\\quad\n\\forall y\\in (\\mathbb{R}^+)^n, \\mu\\in \\mathbb{R}, \\sigma\\in \\mathbb{R}^+.\n\\end{equation}\n\n\\begin{itemize}\n\\item \\texttt{lognormal\\_lpdf(y, mu, sigma)}\n\\begin{itemize}\n\\item \\texttt{y}: \\texttt{real64} array.\n\\item \\texttt{mu}: \\texttt{real64} or \\texttt{var}.\n\\item \\texttt{sigma}: \\texttt{real64} or \\texttt{var}.\n\\item Return: the \\texttt{log} of \\(\\text{LogNormal}(y, \\mu, \\sigma)\\).\n\\end{itemize}\n\\end{itemize}\n\\section{{\\bfseries\\sffamily TODO} additional distributions}\n\\label{sec:orgfacca40}\n\n\n\\bibliographystyle{plain}\n\\bibliography{ref}\n\\end{document}\n", "meta": {"hexsha": "67546536ab090b5d330341e69735e12388f2b0e9", "size": 33998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/fazang_user_guide.tex", "max_stars_repo_name": "zoziha/fazang", "max_stars_repo_head_hexsha": "ce2449cdcebed067473d7e4ad9c51da15d805cc0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2022-02-02T00:26:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-13T06:20:47.000Z", "max_issues_repo_path": "doc/fazang_user_guide.tex", "max_issues_repo_name": "zoziha/fazang", "max_issues_repo_head_hexsha": "ce2449cdcebed067473d7e4ad9c51da15d805cc0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2022-02-02T01:41:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-09T17:06:14.000Z", "max_forks_repo_path": "doc/fazang_user_guide.tex", "max_forks_repo_name": "zoziha/fazang", "max_forks_repo_head_hexsha": "ce2449cdcebed067473d7e4ad9c51da15d805cc0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2022-02-03T12:41:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-13T06:21:01.000Z", "avg_line_length": 38.9885321101, "max_line_length": 247, "alphanum_fraction": 0.710806518, "num_tokens": 10794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.43575632393604385}}
{"text": "% This is part of the TFTB Reference Manual.\n% Copyright (C) 1996 CNRS (France) and Rice University (US).\n% See the file refguide.tex for copying conditions.\n\n\n\n\\markright{anafsk}\n\\section*{\\hspace*{-1.6cm} anafsk}\n\n\\vspace*{-.4cm}\n\\hspace*{-1.6cm}\\rule[0in]{16.5cm}{.02cm}\n\\vspace*{.2cm}\n\n\n\n{\\bf \\large \\sf Purpose}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\nFrequency Shift Keyed (FSK) signal.\n\\end{minipage}\n\\vspace*{.5cm}\n\n\n{\\bf \\large \\sf Synopsis}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n\\begin{verbatim}\n[y,iflaw] = anafsk(N)\n[y,iflaw] = anafsk(N,ncomp)\n[y,iflaw] = anafsk(N,ncomp,nbf)\n\\end{verbatim}\n\\end{minipage}\n\\vspace*{.5cm}\n\n\n{\\bf \\large \\sf Description}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n        {\\ty anafsk} simulates a phase coherent Frequency Shift Keyed (FSK)\n        signal. This signal is a succession of complex sinusoids of {\\ty ncomp}\n        points each and with a normalized frequency uniformly chosen\n        between {\\ty nbf} distinct values between 0.0 and 0.5.  Such signal is\n        only 'quasi'-analytic.\\\\\n\n\\hspace*{-.5cm}\\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}\nName & Description & Default value\\\\\n\\hline\n        {\\ty N }    & number of points\\\\\n        {\\ty ncomp} & number of points of each component & {\\ty N/5}\\\\\n        {\\ty nbf}   & number of distinct frequencies     & {\\ty 4}  \\\\\n \\hline {\\ty y }    & signal\\\\\n        {\\ty iflaw} & instantaneous frequency law  \\\\\n\\hline\n\\end{tabular*}\n\n\\end{minipage}\n\\vspace*{1cm}\n\n\n{\\bf \\large \\sf Example}\n\\begin{verbatim}\n         [signal,ifl]=anafsk(512,64,5); \n         subplot(211); plot(real(signal)); \n         subplot(212); plot(ifl);\n\\end{verbatim}\n\\vspace*{.5cm}\n\n\n{\\bf \\large \\sf See Also}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n\\begin{verbatim}\nanabpsk, anaqpsk, anaask.\n\\end{verbatim}\n\\end{minipage}\n\\vspace*{.5cm}\n\n\n{\\bf \\large \\sf Reference}\\\\\n\\hspace*{1.5cm}\n\\begin{minipage}[t]{13.5cm}\n[1] W. Gardner {\\it Introduction to Random Processes, with Applications to\nSignals and Systems}, 2nd Edition, McGraw-Hill, New-York, p. 357 ,1990.  \n\\end{minipage}\n", "meta": {"hexsha": "bbee5c79c0b8f521e7a7932079a87d62ec35e54e", "size": 2079, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tftb/refguide/anafsk.tex", "max_stars_repo_name": "sangyoonHan/extern", "max_stars_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2018-03-28T01:50:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T07:24:14.000Z", "max_issues_repo_path": "tftb/refguide/anafsk.tex", "max_issues_repo_name": "sangyoonHan/extern", "max_issues_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tftb/refguide/anafsk.tex", "max_forks_repo_name": "sangyoonHan/extern", "max_forks_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2018-03-28T01:50:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T09:09:40.000Z", "avg_line_length": 24.4588235294, "max_line_length": 79, "alphanum_fraction": 0.645983646, "num_tokens": 747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4356784205255295}}
{"text": "\\chapter{Specific Implementation}\n\\label{chap-spec-impl}\n\n\\begin{minted}{haskell}\ndata Tree a = Leaf a\n            | Node (Leaf a) a (Leaf a)\n\\end{minted}\n\n\\begin{minted}{haskell}\nsumTree :: Tree Int -> Int\nsumTree (Leaf x)     = x\nsumTree (Node l x r) = x + (sumTree l) + (sumTree r)\n\\end{minted}\n\nComputing a value of a data structure can easily be defined in Haskell, but every time there is a small change in the \\texttt{Tree}, the entire \\texttt{Tree} needs to be recomputed. This is inefficient, because most of the computations have already been performed in the previous computation. \n\nTo prevent recomputation of already computed values, the technique memoization is introduced. Memoization is a technique where the results of computational intensive tasks are stored and when the same input occurs, the result is reused. \n\nThe comparison of two values in Haskell is done with the \\texttt{Eq} typeclass, which implements the equality operator \\inlinehaskell{(==) :: a -> a -> Bool}. So, an example implementation of the \\texttt{Eq} typeclass for the \\texttt{Tree} datatype would be:\n\n\\begin{minted}{haskell}\ninstance Eq a => Eq (Tree a) where\n  Leaf x1       == Leaf x2       = x1 == x2\n  Node l1 x1 r1 == Node l2 x2 r2 = x1 == x2 && l1 == l2 && r1 == r2\n  _             == _             = False\n\\end{minted}\n\nThe problem with using this implementation of the \\texttt{Eq} typeclass for Memoization is that for every comparison of the \\texttt{Tree} datatype the equality is computed. This is inefficient because the equality implementation has to traverse the complete \\texttt{Tree} data structure to know if the \\texttt{Tree}'s are equal. \n\nTo efficiently compare the \\texttt{Tree} datatypes, we need to represent the structure in a manner which does not lead to traversing to the complete \\texttt{Tree} data structure. This can be accomplished using a \\texttt{hash} function. A hash function is a process of transforming a data structure into an arbitrary fixed-size value, where the same input always generates the same output. \n\nOne of the disadvantages of using hashes is \\textit{hash collisions}. Hash collisions happen when two different pieces of data have the same hash. This is because a hash function has a limited amount of bits to represent every possible combination of data. Using the formula $p = \\epsilon^{\\frac{-k(k-1)}{2N}}$ from \\citetitle{hashcoll2011}\\cite{hashcoll2011}, we can calculate a $50\\%$ chance of getting a hash collision with a collection of $k$. The hash function CRC-32 needs a collection of 77163 hash values. The hash function MD5 needs a collection of $\\num{5.06e9}$ hash values. And, the hash function SHA-1 needs a collection of $\\num{1.42e24}$ hash values. As a result of, we can say that for most popular hash functions, hash collisions are negligible.\n\n\\begin{minted}{haskell}\nclass Hashable a where\n  hash :: a -> Hash\n\ninstance Hashable a => Hashable (Tree a) where\n  hash (Leaf x)     = concatHash [hash \"Leaf\", hash x]\n  hash (Node l x r) = concatHash [hash \"Node\", hash x, hash l, hash r]\n\\end{minted}\n\nThe hashes can then be used to efficiently compare two \\texttt{Tree} data structures, without having to traverse the entire \\texttt{Tree} data structure. To keep track of the intermediate results of the computation, we store the results in a \\texttt{Map}. A \\texttt{Map}, also known as a dictionary, is an implementation of mapping a key to a value. In our next example the \\texttt{Hash} is the key and the value is the intermediate result.\n\n\\begin{minted}{haskell}\nsumTreeInc :: Tree Int -> (Int, Map Hash Int)\nsumTreeInc l@(Leaf x)     = (x, insert (hash l) x empty)\nsumTreeInc n@(Node l x r) = (y, insert (hash n) y (ml <> mr))\n  where\n    y = x + xl + xr\n    (xl, ml) = sumTreeInc l\n    (xr, mr) = sumTreeInc r\n\\end{minted}\n\nThen after the first computation over the entire \\texttt{Tree}, we can recompute the \\texttt{Tree} using the previously created \\texttt{Map}. Thus, when we recompute the \\texttt{Tree}, we first look in the \\texttt{Map} if the computation has already been performed then return the result. Otherwise, compute the result and store it in the \\texttt{Map}.\n\n\\question{Maybe add the more efficient implementation of merging maps?}\n\\begin{minted}{haskell}\nsumTreeIncMap :: Map Hash Int -> Tree Int -> (Int, Map Hash Int)\nsumTreeIncMap m l@(Leaf x) = case lookup (hash l) m of\n  Just x  -> (x, m) \n  Nothing -> (x, insert (hash l) x empty)\nsumTreeIncMap m n@(Node l x r) = case lookup (hash n) m of\n  Just x  -> (x, m)\n  Nothing -> (y, insert (hash n) y (ml <> mr))\n    where\n      y = x + xl + xr\n      (xl, ml) = sumTreeIncMap m l\n      (xr, mr) = sumTreeIncMap m r\n\\end{minted}\n\nGenerating a hash for every computation over the data structure is time-consuming and unnecessary, because most of the \\texttt{Tree} data structure stays the same. The work of \\citeauthor{miraldo2019efficient}\\cite{miraldo2019efficient} inspired the use of the Merkle Tree. A Merkle Tree is a data structure which integrates the hashes within the data structure.\n\n\\section{Merkle Tree (\\texttt{TreeH})}\nFirst we introduce a new datatype \\texttt{TreeH}, which contains a \\texttt{Hash} for every constructor in \\texttt{Tree}. Then to convert the \\texttt{Tree} datatype into the \\texttt{TreeH} datatype, the structure of the Tree is hashed and stored into the datatype using the \\texttt{merkle} function.\n\n\\begin{minted}{haskell}\ndata TreeH a = LeafH Hash a\n             | NodeH Hash (Leaf a) a (Leaf a)\n\\end{minted}\n\n\\begin{minted}{haskell}\nmerkle :: Tree Int -> TreeH Int\nmerkle l@(Leaf x) = LeafH (hash l) x\nmerkle (Node l x r) = NodeH h l' x r'\n  where\n    h = hash [\"Node\", x, getHash l', getHash r']\n    l' = merkle l\n    r' = merkle r\n\\end{minted}\n\nThe precomputed hashes can then be used to easily create a \\texttt{Map}, without computing the hashes every time the \\texttt{sumTreeIncH} function is called.\n\n\\begin{minted}{haskell}\nsumTreeIncH :: TreeH Int -> (Int, Map Hash Int)\nsumTreeIncH (LeafH h x)     = (x, insert h x empty)\nsumTreeIncH (NodeH h l x r) = (y, insert h y (ml <> mr))\n  where\n    y = x + xl + xr\n    (xl, ml) = sumTreeInc l\n    (xr, mr) = sumTreeInc r\n\\end{minted}\n\nThe problem with this implementation is, that when the \\texttt{Tree} datatype is updated, the entire \\texttt{Tree} needs to be converted into a \\texttt{TreeH}, which is linear in time. This can be done more efficiently, by only updating the hashes which are impacted by the changes. Which means that only the hashes of the change and the parents need to be updated. \n\nThe first intuition to fixing this would be using a pointer to the value that needs to be changed. But because Haskell is a functional programming language, there are no pointers. Luckily, there is a data structure which can be used to efficiently update the data structure, namely the Zipper\\cite{huet1997zipper}.\n\n\\input{sections/specific_implementation/zipper.tex}", "meta": {"hexsha": "9605041d096fd7cf6324fc4ce09f723d18a2458d", "size": 6890, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/specific_implementation/main.tex", "max_stars_repo_name": "jortvangorkum/thesis-paper", "max_stars_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/specific_implementation/main.tex", "max_issues_repo_name": "jortvangorkum/thesis-paper", "max_issues_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/specific_implementation/main.tex", "max_forks_repo_name": "jortvangorkum/thesis-paper", "max_forks_repo_head_hexsha": "897946211f14901b656a89b2f56c624c84b4e810", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.7962962963, "max_line_length": 762, "alphanum_fraction": 0.7281567489, "num_tokens": 1896, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4356784205255295}}
{"text": "\\section{Varieties of Hypergraphs}\n\\p{Any notion of hypergraphs contrasts with an \nunderlying graph model, such that some element treated as \nsingular or unstructured in regular graphs becomes a multiplicity \nor compound structure in the hypergraph.  So for example, an \nedge generalizes to a hyperedge with more than two incident \nnodes (which means, for directed graphs, more than \none source and/or target node).  Likewise, nodes might generalize \nto complex structures containing other nodes (including, \npotentially, nested graphs).  The \\q{elements} of a graph \nare nodes and edges, but also (for labeled/weighted \nand/or directed graphs) things like labels, weights \n(such as probability metrics associated with edges), and directions \n(in the distinction between incoming and outgoing edges incident to any node).  \nPotentially, any of these elements can be transformed \nfrom a unit to a plural structure, a process \nI will call \\i{diversification}.  That is, \na hypergraph emerges from a graph by \\q{diversifying} \nsome elements, rendering as multiplicities what \nhad previously been a single entity \\mdash{} nodes become node-sets, edges \nbecome grouped into larger aggregates, labels generalize to \ncomplex structures (which I will call \\q{annotations}), \netc.  Different avenues of diversification give \nrise to different varieties of hypergraphs, as \nI will review in the next several paragraphs.\n}\n\\p{\\begin{description}\\item[Hyperedges]  Arguably the most common model of \nhypergraphs involves generalizing edges to hyperedges, \neach of which (potentially) connect more than two nodes.  \nFor directed graphs,  \ndirected hyperedges have a \\q{source} node-set and a \\q{target} node-set, \neither of which can (potentially) have more than one node.  \nNote that this is actually a form of node-diversification \n\\mdash{} there is still (in this genre of hypergraph) just one \nedge at a time, but its incident node set (or source and \ntarget node-sets) are sets and not single nodes.  Another way \nof looking at directed hyperedges is to see source and target \nnode-sets as integral complex parts, or \\q{hypernodes}.  \nSo a (directed) hypergraph with hyperedges can also \nbe seen as generalizing ordinary graphs by replacing \nnodes with hypernodes (such that one hypernode \nspans a \\i{set} of \\q{normal} nodes).\n \n\\item[Recursive Graphs]  Whereas hyperedges embody a relatively \nsimple node-diversification \\mdash{} nodes replaced by node-sets \n\\mdash{} so-called \\q{recursive} graphs allow compound nodes (hypernodes) \nto contain entire nested graphs.  Edges in this case can still \nconnect two hypernodes as in ordinary graphs, but the \nhypernodes internally contain other graphs, \nwith their own (on another \\q{level}) nodes and edges.\n \n\\item[Link Grammar]   Since \\i{labeled} \ngraphs are an important model for computational models, \nwe can also consider generalizations of labels to be \ncompound structures rather than numeric or string labels \n(or, as in the Semantic Web, \\q{predicate} terms,  \ndrawn from an Ontology, in \\q{Subject-Predicate-Object} \ntriples).  Compound labels (which I will generically call \ndouble- or multiple-annotations) are encountered \nin several different branches of mathematics and other fields.  \n\\vspace*{.3em}\\\\\\hspace*{3em}\nIn particular, compound annotations can represent the \nrules, justifications, or \\q{compatibility} which allows \ntwo nodes to be connected.   In this case the annotation \nmay contain information about both incident nodes.  \nThis general phenomenon (I will mention further examples \nbelow) can be called a \\q{diversification} \non \\i{labels}, transforming from labels as single units \nto labels as multi-part records.\n\\item[Hypergraph Categories]  Directed hyperedges have source- \nand target-\\i{sets} of nodes (possibly ordered).  Allowing \nthese sets to be \\i{empty} yields structures similar to \nhypergraph categories in recent mathematical treatments, such \nas \\cite{BrendanFong}, \\cite{AleksKissinger}.  Hypergraphs \nin this characterization might be used to study software applications \nand real-time monitoring systems.  Hyperedges would then \nmark information flows between different sites \\i{inside} the \nsystem.  A directed hyperedge \\i{without} a source node-sets then \nmodels information \\i{entering} the system \\i{ab initio}.  \nLikewise hyperedges without target node-sets could model \nempirical effects produced by the system, which from one \nperspective embodies information \\q{leaving} the system.\n\\vspace*{.3em}\\\\\\hspace*{3em}\nAnalogous models can be realized by, in lieu of \nhyperedges \\i{without} source or target node-sets at all, \ndesignating special hypernodes representing empty \nnode-sets; or hypernodes providing greater detail about \norigin- or destination-points for paths modeling \ninformation flows.  In software and some CyberPhysical \nsystems, information \\q{enters} the system via \n\\q{events} \\mdash{} that is, \\i{events} are introduced as a \nprimitive concept alongside \\i{procedures}, though \nevents themselves are not \\q{implemented} (they have no \n\\q{body}).  While procedures call other procedures, \nevents \\i{trigger} calls via event-to-procedure \n\\i{connections}.   \nEvents which are not generated by components \\i{in} the \nsystem then correspond to hyperedges without source-nodes, \nbut the situation can be more precisely modeled via a \nspecial class of event hypernodes (analogous to \nevents, as a distinct signature-bearing element from \nprocedures, in event-driven programming; \ncf. \\cite{JenniferPaykin}, \n\\cite{PaykinKrishnaswami}, \\cite{WolfgangJeltsch}). \n\\item[Edges Incident to Edges]  A further generalization \npermits edges to \\q{point at} other edges\n\\cite[p. 10]{BalintMolnar}; \\cite[p. 13]{BenGoertzel}.\nThe rationale for corresponding constructions is that\nan edge \\mdash{} qua relation between two or more \ncomponents \\mdash{} is itself a fact, datapoint, or \nassertion, and as such can be on some perspectives a \nsingular element in a space of information.  \nThe Semantic Web, for example, includes \\q{reified} \nedges (Subject/Predicate/Object triples).  \nReification permits properties to be stated about edges, \nsuch as provenance data (who asserts the edge and on \nwhat evidence) and context (the assertion is believed true \nat a specific time or in a given context).  \nIt is plausible then to allow reified edges \nto be treated as nodes incident to other edges.  As \nwith hyperedges possessing empty source or target \nsets, the associated paradigm can be interpreted through \na special class of hypernode: we can certainly \nconsider nodes which refer to edges (perhaps via the \nlatter's label or annotation).  Such \\q{referring} \nis not necessarily an explicit further edge in graphs \nbut could instea be \\q{semantic} \\mdash{} that is, an edge being the \n\\q{value} associated with a node (or likewise  \none value in a multi-element hypernode).\n\\item[Channels]   Hyperedges, which connect multiple \nnodes, are still generally seen as single edges \n(in contrast to multigraphs which allow multiple \nedges between two nodes).  Analogous to the grouping \nof nodes into hypernodes, we can also consider structures \nwhere several different edges are unified into a larger \ntotality, which I will call a \\i{channel}.  \nIn the canonical case, a directed graph can group \nedges into composites (according to more fine-grained criteria \nthan just distinguishing incoming and outgoing edges) which share a \nsource or target node.  The set of incoming and/or outgoing  edges \nto each node may be partitioned into distinct \n\\q{channels}, so that at one scale of consideration the network \nstructure can be analyzed via channels rather than via \nsingle edges (this shows why channels mark edge \\i{diversification} \nas well as edge \\i{aggregation}, because the conceptual role \nof edges is potentially replaced by channels, which are composed \nof numerous edges).\n\\vspace*{.3em}\\\\\\hspace*{3em}\nAs a concrete case, \nconsider graphs used to model Object-Oriented programming \nlanguages, where a single node can represent a \nsingle function call.  The incoming edges are then \n\\q{input parameters}, and outgoing edges are procedural \nresults or \\q{outputs}.  In the Object-Oriented paradigm, however, \ninput parameters are organized into two groups: in addition \nto any number of \\q{conventional} arguments, there is \na single \\this{} or \\self{} object which has a distinct  semantic \nstatus (\\visavis{} name resolution, function visibility, and \npolymorphism).  This calls, under the graph model, for splitting \nincoming edges into two \\q{channels}, one representing regular \nparameters and a separate channel for the distinguished or \n\\q{receiver} object-value.\n\\end{description}\n}\n\\p{In each of these formulations, what makes a graph \\q{hyper} is the presence of \nsupplemental information \\q{attached} to parts of an underlying (potentially \nlabeled, directed) \ngraph.  For a concrete example, consider a case from linguistics \\mdash{} specifically, \nmorphosyntactic agreement \nbetween grammatically linked words, which involves details \nmatched between both \\q{ends} of a word-to-word \\q{link} \n(part-of-speech, plural/singular, gender, case/declension, \netc.).  According to the theory of Link Grammar, \nwords are associated with \\q{connectors} (a related useful terminology, \nderived more in a Cognitive-Linguistic context, holds that \nwords carry \\q{expectations} which must be matched by other words they \ncould connect to).\\footnote{Link Grammar proper was developed by Davy Temperley and Daniel Sleator \n\\cite{TemperleySleator}, \\cite{GoertzelPLN}, and computer \nscientists such as Kenneth Holmqvist and Matt Selway have adopted \nconcepts from Link Grammar as part of projects formalizing \nCognitive Linguistics in the tradition associated (notably) with \nRonald Langacker \\cite{HolmqvistDiss}, \\cite{MattSelway}  \nThe OpenCog system is an example of Link Grammar integrated with \nhypergraphs concerned with data models and procedural \nexecution, embodied in the AtomSpace data management component \n\\cite{GoertzelEtAl}, \\cite{RuitingLian}, \\cite[pp. 55ff]{GoertzelP2}.  \n}  The word \\i{many}, for instance, as in \\i{many dogs}, \ncarries an implicit expectation to be paired with a plural noun.  The actual \nsyntactic connection \\mdash{} as would be embodied by a graph-edge when a graph \nformation is employed to model parse structures \\mdash{} therefore depends on \nboth the expectations on one word in a pair (whichever acts as a modifier, \nlike \\i{many}) and the \\q{lexicomorphic} details of its \\q{partner} \n(\\q{dog}, as a lexical item, being a noun, and \\i{dogs} being \nin plural form).\n}\n\\p{In Link Grammar terminology, both the expectations on \none word and the lexical and morphological state of a second are called \n\\q{connectors}; a proper linkage between two words is then a \\i{connection}.  \nFor each connection there is accordingly two sets of relevant information, \nwhich might be regarded as a generalization on edge-labeling wherein edges \ncould have two or more labels.  Furthermore, the assertion of multi-part annotations \non edges permits edges themselves to be grouped and categorized: aside from several \ndozen recognized link varieties between words (which can be treated as conventional \nedge-labels drawn from a taxonomy, consistent with ordinary labeled graphs), \nedge-annotations in this framework mark patterns of semantic and syntactic agreement \nin force between word pairs (not just foundational grammatic matching, like \ngender and number \\mdash{} singular/plural \\mdash{} but more nuanced compatibility at the \nboundary between syntax and semantics, such as the stipulation that a noun in a \nlocative position must have some semantic interpretation as a place or \ndestination).  Insofar as these agreement-patterns carry over to other word-pairs, \nannotations mark linguistic criteria that tie together multiple edges \nin the guise of signals that a specific parse-graph (out of the space \nof possible graphs that could be formed from a sentence's word set) is correct.\n}\n\\p{Ordinary directed graphs \n(not necessarily hypergraphs) already have some sense of grouping edges together, \ngiven that incoming and outgoing edges are distinguished; \nbut this indirect association between edges does not \ninternally yield a concordant grouping of the nodes \nat the sources of edges all pointing to one target node \n(or analogously the targets of one source node).  \nIn the theory of \nhypergraph \\i{categories}, hypernodes come into play insofar as representation \ncalls for the nodes \\q{across} (i.e., at the other end of) \nincoming/outgoing edges to be pulled together.   \nWe distinguish an \\i{incoming node-set} from an \\i{outgoing node-set}; \nthen we might treat these sets as integral \\q{bodies} of inputs \n(respectively, outputs):   \n\\begin{cquote}The term hypergraph category was introduced recently ... in reference\nto the fact that these special commutative Frobenius monoids provide precisely the\nstructure required for their string diagrams to be directed graphs with \\sq{hyperedges}:\nedges connecting any number of inputs to any number of outputs. ... \nWe then think of morphisms in a hypergraph category as hyperedges \n\\cite[p. 13]{BrendanFongThesis}.\n\\end{cquote}  \nFor a general mapping of  \ncategories to graphs where edges represent morphisms, this represents a \ngeneralization on the notion of \\i{edges} themselves.  Suppose morphisms are \nintended to model computational procedures in a general sense (say, as \nmorphisms in an ambient program state).  Because procedures can have any \nnumber (even zero) of both inputs and outputs, this implies a generalization \nwherein directed edges can have zero, one, or multiple source (and respectively \ntarget) nodes.  A corresponding hypergraph form is one where hyperedges have \nsource- and target- hypernodes, but each hypernode models variant-sized sets \nof further \\q{inner} nodes (or \\q{hyponodes}); here the empty set can be \na hypernode with no hyponodes.  Elsewhere, apparently an equivalent \nstructure is called a \\q{trivial system}:\n\\begin{cquote}Monoidal categories admit an elegant and powerful graphical notation \n[wherein] an object $A$ is denoted by a wire [and] [a] \nmorphism \\fAB{} is represented by a box.  The trivial system \n$I$ is the empty diagram.  Morphisms \\uIA{} and \\vAI{} \n... are referred to as \\textbf{states} and \\textbf{effects} \n\\cite[p. 4]{InteractingConceptualSpaces}.\n\\end{cquote}\nThe system $I$ \\mdash{} which we can also see as a hypernode with an empty \n(hypo-)node set \\mdash{} may embody a procedure which has no internal \nalgorithmic or calculational structure (at least relative to the \ndomain of analysis where we might represent computer code).  In \nCyberPhysical Systems, a function which just produces a \nvalue (with no input and no intermediate computations) can also \nbe called an \\i{observation}, perhaps a direct reading from a \nphysical \\i{sensor} (accordingly, as in the above excerpt, a \\i{state}).  \nDually, a procedure which performs no evident calculation and produces \nno output value, but has a CyberPhysical \\i{effect}, can be called an \n\\q{actuation}, potentially connected to a CyberPhysical \\i{actuator} \n(an example of a sensor would be a thermostat, and an example of an \nactuator would be a device which can activate/deactivate a furnace \nand/or cooling system).\n}\n\\p{In these examples I have cited hypergraphs in a linguistic (Link Grammar) \nand a mathematical (hypergraph categories) context.  These \nshare some parallels insofar as a core motivation is to generalize and add \nstructure to edges, either freeing edges from limts on \nnode-arity (even allowing edges to be \\q{unattached}), \nor supplying edges with structured (potentially multi-part) annotations.\n}\n\\p{A somewhat different conception of hypergraphs is found in database \nsystems such as HypergraphDB.  Graphs in that context express what have \nbeen called \\i{recursive} graphs, wherein a hypernode \\q{contains} or \n\\q{designates} its own graph.  The basic idea is that for each (hyper-)node we \ncan associate a separate (sub-)graph.  This can actually work two \nways, yielding a distinction between (I'll say) \\i{nested} \nand \\i{cross-referencing} graphs.  In a \\i{cross-referencing} graph, \nsubgraphs or other collections of graph elements (nodes, edges, and/or \nannotations) can be given unique identifiers or designations and, as \na data point, associated with a separate node.  Consider a case where \nnodes refer to typed values from a general-purpose type system; insofar \nas subgraphs themselves may be represented as typed values, a node could \nreference a subgraph by analogy to any other value (textual, numeric, \nnominal/enumerative data, etc.).  Here the (hyper)node does not \n\\q{contain} but \\i{references} a subgraph; the added structure involves \nsubgraphs themselves being incorporated into the universe of values \nwhich nodes may quantify over.  Conversely, \\i{nested} hypergraphs \nmodel hypernodes which have other graphs \\q{inside} them, thereby creating \nan ordering among nodes (we can talk of nodes at one level belonging \nto graphs which are contained in nodes at a higher level).  Such constructions \nmay or may not allow edges across nodes at different levels. \n}\n\\p{Note that nested hypergraphs can be seen as a special case of cross-referencing \ngraphs, where each hypernode \\nodeN{} is given an index \\ix{}, \nwith the restriction that when  \\nodeN{} designates (e.g., via \nits corresponding typed value) a subgraph \\sg{}, all of \n\\sg{}'s hypernodes have index \\ixminusone{}.  Cross-referencing \ngraphs, in turn, can be seen as special cases of an overall \nspace of hypergraphs wherein hypernodes are paired with \ntyped values from some suitably expressive type system \\tys{}.  \nIf \\tys{} includes higher-order types \\mdash{} especially, lists and \nother \\q{collections} types which become concrete types in \nconjunction with another type (as in \\i{list} qua generic \nbecomes the concrete type \\i{list of integers}), then \nhypernodes acquire aggregate structure in part by \nacquiring values whose types encompass multiple \nother values.  I will use the term \\i{procedural} hypergraphs \nto discuss structures that model node diversification \nvia mapping hypernodes to collections-types \n(with the possibility for hypernodes \nto \\q{expand} or \\q{contract} as values are inserted into or \nremoved from the collection).\n}\n\\p{Cross-referencing also potentially introduces a variant derivation of \nhypergraphs which proceeds by accumulating graph elements (nodes, \nedges, and labels or annotations) into higher-scale posits, rather \nthan defining inner structures on elements.  Specifically, as a \ncomplimentary operation to diversification, consider \\q{aggregation} \nof graph elements: the option to take a set of (hyper)nodes, \n(hyper)edges, and/or annotations as a typed value which can then \nbe assigned to a (hyper)node.  In such a manner, higher-level \nstructures can be notated with respect to graphs, which is one \nway to model phenomena such as \\i{contexts} \\mdash{} the kind of multi-scale \npatterns that are considered endemic to practical domains \nlike the Semantic Web.  While it is informally acknowledged that \na single-level interpretation of the Semantic Web is misleading \n\\mdash{} the Semantic Web is not an undifferentiated mesh of connections, but \nrather an aggregation of data from many sources, which implies the existence of \nlocalization, contextualization, and other \\q{emergent} structure \\mdash{} \nthere is no definitive protocol for actually representing this emergent \nstructure.  This issue, in turn, is one of arguments \nfor hypergraphs in lieu of ordinary graphs as general-purpose \ndata representations. \n}\n\\p{The multi-scale, contextualized nature of the Semantic Web also points toward \na conceptual duality in \\i{how} graphs represent data.  On the one hand, graph \nstructures \\mdash{} especially in the case of the Semantic Web, which builds off of \ninternet technology in general \\mdash{} represent \\i{relationships} between points \nor structures of data in some sense; in familiar web terms, the relata linked \nby graph edges are often \\q{resources}, designated by unique web addresses.   \nA more theoretical model might take the information \\q{residing} at \ngraph nodes as typed values.  But in either case a given node may stand in \nfor an aggregate of information \\mdash{} a single web resources may contain a \ntheoretically unlimited supply of data, and a typed value can be of a list \nor tuple type internally containing its own body of information.  \nConsequently, the full stock of data embodied in a graph may not lie \nprimarily in the graph structure itself, but rather distributed among \nits nodes (that is, among nodes' associated data). \n}  \n\\p{Conversely, graph structures (with suitable semantic specifications) are  \nalso considered to be media for serializing arbitrary data structures, which \nimplies representing all details, at all levels of hierarchical organization, \nvia graph structures.  Insofar as nodes embody their own information spaces, \nsuch internal structuration must then be mapped to their own graphs, \nas part of a workflow to project arbitrary structured data onto a canonical \nformat.  The theoretical corollary to this idea would be that node data \n(via associated typed values) has its own internal representation; \nthat it is, every typed value has a corresponding graph structure \nthat may be \\q{contained} within a higher-scale node.  \n}\n\\p{Different varieties of hypergraph forms complicate this picture \nbecause the structuring elements of hypergraphs include \naggregate data within nodes as well as the space of \nedges and incidence relations.  Given the structures I have referred to \nas \\q{procedural} hypergraphs, nodes can encompass multiple\ninternal values so long as they have a suitably well-defined \ninternal structure.  We can analyze these possibilities \nby defining, for each hypernode, an \\q{interface} or list of \noperations available for updating hypernodes' associated values.  \nWhich operations are proper depends on a hypernode's type: \nhypernodes associated with a single unstructured value \nshould have one basic update operation, while nodes with \nlist-like types would have operations to insert (and remove) \nvalues at different positions.  In general, procedural \nhypergraphs should differentiate between \\i{atomic} hypernodes \nwith one associated value; \\i{tuple} hypernodes with a \nfixed array of values (potentially of multiple types); \nand \\i{collections} hypernodes encompassing lists of \nvalues subject to append/insert/remove actions \n(in which case inserted values' types should \nhave a predictable pattern; \nconsider key- and value-type alternation in \nassociative arrays).\n} \n   \n\\p{Separate and apart from operations modifying hypernodes' values, there \nare also conventional graph operations \\mdash{} adding and removing \nnodes and edges.  In combination, the graph-oriented and node-oriented \noperations present a variegated interface for manipulating \nprocedural hypergraphs.  Such an interface then serves as a rigorous \ncharacterization of the overall hypergraph model \\mdash{} the structuring \nelements expressed by enumerating graphs' transformation operations \nrepresent the particular features of each specific hypergraph \nvariety.\n}\n\\p{In the case of procedural hypergraphs, many of these transformations \nare not graph-related, per se, but derive from hypernodes' collections or tuple \ntypes.  I contend that this is a useful property of procedural hypergraphs \nfor reasons I alluded to in the introduction \\mdash{} hypergraphs (or at least the \ndata represented with them) need to work in a variety of computational contexts.  \nThe relatively unstructured form of graph data is not always appropriate \nfrom one context to another; the list-of-values or value-tuple structures \nembodied as hypernode data may be more consistent with internal representations \nin database or language-runtime engines, for example.  Procedural hypergraphs \nare appropriately flexible in that some data is modeled at the graph level \nproper while other data is modeled as lists, tuples, and similar data structures \nwithin individual nodes.  \n}\n\\p{In many practical contexts graph structures are not implicitly used at all; \nthe importance of Semantic Web-style representation is for intermediary \nstructures, where information is routed among different environments \n(database, applications, serialization, and so forth).  Transformations \nbetween hypergraphs can be a central process in generic transformations \nbetween data structures proper to different contexts.  In effect, where \nthere is a general need for data transforms in routing between \ncontexts \\mdash{} e.g., database to application runtime \\mdash{} the relevant \ntransform logic is specifically  \nmappings between hypergraphs, with each hypergraph possessing a structure \noptimized for being initialized from one context (or for generating data \nused in another context).  This progression may involve restructuring \nwherein information modeled at the \\q{inter-hypernode} level \\mdash{} \nwhich we can call \\i{hypernode} data \\mdash{} tends to be migrated \nto the level \\i{inside} hypernodes, which we can call \\i{hyponode} data.\n}\n\\p{In broad outline, then, hypergraph transforms will in many scenarios \nprogress from relatively \ncasual structures \\mdash{} with a preponderance of information expressed as \n\\i{hypernode} data \\mdash{} to more constrained structures.  The underlying  \npattern in such instances is mapping \n\\i{hypernode} to \\i{hyponode} data \\mdash{} i.e., mapping data from structures \n\\i{between} hypernodes to those \\i{within} hypernodes \\mdash{} where \nthe hyponode data is regulated by hypernodes' types.\n}\n\\thindecoline{}\n\\p{In this section I identified different additions through which graph \nstructures generalize to hypergraphs; a general-purpose hypergraph \nengine would need to support each of these variations, which entails \nenabling the complete repository of transform-operations applicable to \ndifferent hypergraph varieties.  This includes generalizing \nedges to hyperedges by \\q{diversifying} nodes to encompass mutiple values; \nrepresenting nodes' internal structure in terms of data structures \nsuch as lists, tuples, and nested graphs; and generalizing edge-labels \nto annotations which may have multiple parts.  I have not yet discussed \nthe possibility of grouping hyperedges into higher-level structures \n(what I called \\q{channels}), but I will return to \nthose details in a later section.  \n}\n\\p{For the remainder of this paper, I will attend especially to \nhypergraphs modeling (and subsequently executing) computer code, \nbecause constructing a working runtime engine which runs source \ncode, via hypergraph intermediaries, demonstrates a variety of concepts \napplicable to hypergraphs in general.  I will discuss a workflow \nconnecting parsers, a runtime \\q{virtual machine}, intermediate representations \nfor hypergraphs, and inter-graph transforms.  Collectively \nthis workflow implicates many of the capabilities which would be \nrequisite for a general-purpose hypergraph software ecosystem.  \n}\n\\p{Interested readers who would like to observe a concrete \nunfolding of this workflow are invited to download the \ncode base accompanying this paper, where readers can examine \nthe operations of parsers and code generators working with \na built-in, general-purpose hypergraph library.  The demo  \nis fully integrated with \\Qt{} Creator, a \\Cpp{} Integrated Development\nEnvironment, and has no further dependencies (assuming users \nhave a working \\Qt{} and \\Cpp{} compiler; \\Qt{} is a popular \\Cpp{} application-development\nframework).  The dataset includes instructions for \nexperimenting with the hypergraph library via \\Qt{} Creator and examining\nruntime structures by executing demonstration scripts in Debug mode. \n}\n", "meta": {"hexsha": "ae236cc529705b9871be634e72e75d605cf7106a", "size": 27907, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/section1.ngml.tex", "max_stars_repo_name": "ScignScape-RZ/phcg", "max_stars_repo_head_hexsha": "8fd304d7df709d32367e49a98fb99f16162c5477", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/section1.ngml.tex", "max_issues_repo_name": "ScignScape-RZ/phcg", "max_issues_repo_head_hexsha": "8fd304d7df709d32367e49a98fb99f16162c5477", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/section1.ngml.tex", "max_forks_repo_name": "ScignScape-RZ/phcg", "max_forks_repo_head_hexsha": "8fd304d7df709d32367e49a98fb99f16162c5477", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.6281512605, "max_line_length": 99, "alphanum_fraction": 0.7899810083, "num_tokens": 6373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4356784205255295}}
{"text": "\\section{Method}\n\n\\subsection{Dataset}\nThe datasets originate from a study on the mechanism behind head direction sense \\cite{projectdata}.\nFive adult male and two female mice were implanted with recording electrodes under anesthesia \\cite{projectdata}.\nSilicon probes were mounted on movable drives for recording of neural activity in the anteriour thalamus in all mice, while in additional three of the mice probes were also mounted in the post-subiculum (PoS) \\cite{projectdata}. For the remaning four mice with probes only mounted in the anteriour thalamus, additional probes were mounted in the hippocampal CA1 pyramidal layer for accurate sleep scoring \\cite{projectdata}.\nThe head directions (HD) were tracked using two light-emitting-diodes (LEDs) mounted to the back of the head and recored using a videocamera with a frame rate of 30fps. The data was then resampled to 39Hz by the aquisition system \\cite{projectdata}.\nData from two mice were explored, mouse 12 with probes only in the anteriour thalamus and mouse 28 with additional probes in the PoS. Only the awake dataset where used.\n\\subsection{Tuning curves}\nThe electrode spikes can be encoded as timestamps synchronized with the tracked head direction. The timestamps are binned into timebins with a time resolution of \n$$\\Delta t = \\frac{1}{39Hz} \\approx 25.64ms$$ \ncorresponding to the sampling frequency of $39$Hz set by the aquisition system.\nEach bin corresponds to the number of cell firings over a period of $\\Delta t$ time, and each sample has a corresponding head angle.\nDividing by the sampling time yields the number of spikes per unit time in each timebin.\n\nThe continious range of possible head directions, \n$\\theta \\in [0, 2\\pi)$\n, can be discretized into a desired number of edges $N_{HD}$ with fixed spacing such that\n\\begin{equation}\n\\theta_k \\in \\{\\frac{2 \\pi k}{N_{HD}}| k \\in \\mathbb{N}, 0 \\leq k \\leq N_{HD} \\}\n\\end{equation}\nand each tracked head direction sample is binned using the rule\n\\begin{equation}\n    f_{\\theta}(\\theta) =  \\begin{cases}\n        \\theta_0, & \\text{if } \\theta_0 \\leq \\theta < \\theta_{1} \\\\\n        \\theta_1, & \\text{if } \\theta_1 \\leq \\theta < \\theta_{2} \\\\\n         & \\vdots \\\\\n        \\theta_k, & \\text{if } \\theta_k \\leq \\theta < \\theta_{k+1}\n    \\end{cases} \\quad \\text{for} \\quad 0 \\leq k < N_{HD}\n\\end{equation}\nThe number of cell firings were binned accordingly to create an overview of number of spikes per head angle.\nThe firing rate can be found by dividing the sum of spikes for each head direction bin by the number of head direction samples in the same bin.\n\\begin{equation} \\label{eq:firing_rate}\n    \\lambda_k = \\frac{\\sum_i S_i}{\\sum_i 1} \\quad i \\in \\{t | t \\in \\mathbb{N}, 0 \\leq t \\leq N, f_\\theta(\\theta_t) = \\theta_k\\}\n\\end{equation}\nwhere $S_i$ is the number of spikes in timestep $i$, $\\theta_t$ is the head angle in timestep $t$ and $N$ is the number of timesteps. Tuning curves are created by plotting the firing rate $\\lambda_k$ against the head direction $\\theta_k$ in MATLAB or other similar tools.\n\n\\subsection{Mutual information}\nMutual information can be used to quantify how much knowing the state of one variable can tell us about another, i.e. how much information is shared between the variables.\nThe amount of information is quantified as bits (or Shannons), and originates from information theory. A bit can be thought of as the answer to a yes/no question. \nThe mutual information can be calculated using \n\\begin{equation}\\label{eq:mutual_info}\n    I(X;Y) = \\sum_{i, j} Pr(y_i,x_j) \\log_2(\\frac{Pr(y_i, x_j)}{Pr(y_i)Pr(x_j)}) = \\sum_{i,j}Pr(y_i|x_j)Pr(x_j) \\log_2(\\frac{Pr(y_i | x_j)Pr(x_j)}{Pr(y_i)Pr(x_j)})\n\\end{equation}\nDuring a sufficiently short period of time $\\Delta t$ the cell spikes can be thought of as a binary (bernouilly) variable, either spiking once or not at all. \\cite{mutualinfo} The probability of a cell spiking can be then be calculated using\n\\begin{align} \\label{eq:probs}\n    Pr(S=1 | X = k) &= \\lambda_k \\Delta t & Pr(S=1) = \\lambda \\Delta t = \\Delta t \\sum_k \\lambda_k\n\\end{align}\nwhere $\\lambda_k$ is the mean fire rate in bin $k$ and $\\lambda$ is the mean firing rate over all bins.\nBy inserting \\cref{eq:probs} into \\cref{eq:mutual_info} it can be shown that the mutal information can be calculated using a discrete approximation \\cite{mutualinfo}.\n\\begin{equation} \\label{eq:mutinfo_disc}\n    I \\approx \\Delta t \\sum_k \\lambda_k \\log_2(\\frac{\\lambda_k}{\\lambda})Pr(X = k)\n\\end{equation}\nIt can be rewritted to compute the mutual information per unit time, which may be easier to interpret.\n\\begin{equation} \\label{eq:mutinfo_disc_per_time}\n    \\frac{I}{\\Delta t} \\approx \\sum_k \\lambda_k \\log_2(\\frac{\\lambda_k}{\\lambda})Pr(X = k)\n\\end{equation}\nThe prior distribution of head angles can be estimated by\n\\begin{equation}\n    \\hat{Pr}(X = k) = \\frac{\\sum_i 1}{N}  \\quad i \\in \\{t | t \\in \\mathbb{N}, 0 \\leq t \\leq N, f_\\theta(\\theta_t) = \\theta_k\\}\n\\end{equation}\ni.e. the proportion of samples corresponding to bin $k$.\n\nDue to the approximations, \\cref{eq:mutinfo_disc_per_time} may lead to slight negative values. Negative information does not contain any meaning and any values below zero is therefore considered to be approximation errors, and is manually forced to zero.\n\n\\subsection{Principal Component Analysis}\nTo reduce the feature space from many potentially unimportant variables to only a few important ones, principal analysis can be used.\nThe goal of PCA is to create new variables using linear transformations of the original variables, creating a new basis for the vector space. More specifically the goal is to create new variables which describe as much of the variance in the original data as possible.\nThe amount of variance explained by each variable is sorted descendingly with the first principal component explaining the most, and where each new variables are orthogonal to the rest. MATLAB can be used to perform PCA analysis using the \\texttt{pca} command by providing a $NxP$ matrix where $N$ is the number of samples and $P$ is the number of features. The output PCA \\texttt{scores} contains the original samples represented by the new basis.  \nA color coded scatter plot can be generated from the first few principal components. \n\n\\subsection{Polar coordinates}\nPolar coordinates can be used to represent cartesian datapoints as a rotation and a distance. If the samples are  distributed around a circle, this can help visualize the samples in a linear space of rotations. The MATLAB function \\texttt{cart2pol} can be used to transform from cartesian to polar coordinates.\n\n\n", "meta": {"hexsha": "fa540e94e9e118828d9ff0a15daf4e3d12a28ba6", "size": 6587, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/project1/methods.tex", "max_stars_repo_name": "HaavardM/nevr3004-neural-networks", "max_stars_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/project1/methods.tex", "max_issues_repo_name": "HaavardM/nevr3004-neural-networks", "max_issues_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/project1/methods.tex", "max_forks_repo_name": "HaavardM/nevr3004-neural-networks", "max_forks_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.6710526316, "max_line_length": 450, "alphanum_fraction": 0.7574009412, "num_tokens": 1760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.43567842007042207}}
{"text": "%\n% finished at Aug. 5th, 2009\n%\n%\n\\chapter{Position representation and momentum representation}\n\\label{position_momentum representation}\n% introduce the coordinates\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Introduction}\n%\n% why we have this chapter?\n%\n%\nIn the previous sections, we have brought into the concept of\nHilbert space and operator, and have discussed their features in\ngeneral. However, all the discussions have been made are abstract.\nFor example, the wave functions are only considered as some\n``vectors'' in the Hilbert space and the discussion are mainly on\nthe ``vector'' property. Samely, in the discussion about the\noperators, no analysis has bee made on the concrete expression of\nthe operators; for instance; does the Hamiltonian operator commute\nwith the momentum operator? such subjects has been put down so far.\n\nWell, since this chapter we will go into such discussions. We will\nderive the concrete expression for both wave functions and operators\nfrom the above general discussion. Here we will focus on the subject\nthat how to associate the concrete wave function of $\\Psi(\\bm{r},\nt)$ with the corresponding vector of $\\Psi$ in the Hilbert\nspace?\\footnote{Here the analysis within in this chapter is taken\nfrom the Xinlin Ke's book\\cite{XingLinKe}.}\n\nThe general thread for derivation within this chapter has been given\nin section \\ref{vector_schalar_in_operator}. Here we only follow the\nclues there.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Eigen states and eigen values for position\nand momentum operator}\n\\label{eigen_states_in_position_momentum}\n%\n% the changing of eigen states are continuous for x and p\n%\n%\nNow let's concentrate on one dimension motion of a single particle for\nsimplicity. Suggest that $\\ket{x}$ and $\\ket{p}$ are some normalized\neigen states for position operator $\\hat{x}$ and momentum operator\n$\\hat{p}$, the corresponding eigen values are $x$ and $p$. hence we\nhave:\n\\begin{align}\n\\label{PRAMReq:1}\n\\hat{x}\\ket{x} &= x\\ket{x} \\nonumber \\\\\n\\hat{p}\\ket{p} &= p\\ket{p}\n\\end{align}\nHere the $\\ket{x}$ and $\\ket{p}$ are just some generalization for\nthe wave functions we have shown in the (\\ref{sec:PWF_in_Hilbert}).\nThere the $\\nu_{p}(x)$ is just some concrete function to stand for\nthe $\\ket{p}$ in the position representation.\n\nNow let's go to see what kind of value can be achieved by $x$ and\n$p$.\n\nFrom the commutation relation of $[\\hat{x}, \\hat{p}] = i\\hbar$, we can\nuse $\\hat{p}$ to construct some unitary operator of $\\hat{q}$:\n\\begin{align}\n  \\label{PRAMReq:2}\n\\hat{q}(\\xi) &= e^{\\frac{i}{\\hbar}\\xi\\hat{p}} \\Rightarrow \\nonumber \\\\\n\\hat{q}^{+}(\\xi) &= e^{-\\frac{i}{\\hbar}\\xi\\hat{p}} \\Rightarrow\n\\nonumber \\\\\n\\hat{q}(\\xi)\\hat{q}^{+}(\\xi) &= I\n\\end{align}\nHere $\\xi$ is some arbitrary real number. From the mathematical\nanalysis, it's known that we can expand the $\\hat{q}(\\xi)$ into series\nexpansion (it holds true for all $\\xi$ value):\n\\begin{equation}\n  \\label{PRAMReq:3}\n  \\hat{q}(\\xi) = 1 + \\left(\\frac{i}{\\hbar}\\xi\\hat{p}\\right) +\n \\frac{\\left(\\frac{i}{\\hbar}\\xi\\hat{p}\\right)^{2}}{2!} +\n\\frac{\\left(\\frac{i}{\\hbar}\\xi\\hat{p}\\right)^{3}}{3!} + \\cdots\n\\end{equation}\n\nNow we have to resort to an equation which will be introduced in the\nfollowing content (\\ref{OPERATORMOREeq:11}):\n\\begin{equation}\n  \\label{PRAMReq:4}\n[\\hei{r}, f(\\hei{p})] = i\\hbar \\frac{\\partial f(\\hei{p})}{\\partial\n\\hei{p}}\n\\end{equation}\n\nHere the operation is for the vector operator, but it can be directly\napplied to the scalar operator; so by the (\\ref{PRAMReq:4}) we can\nget:\n\\begin{align}\n  \\label{PRAMReq:5}\n    [\\hat{x}, \\hat{q}(\\xi)] &=\ni\\hbar \\frac{\\partial\\hat{q}(\\xi)}{\\partial \\hat{p}} \\nonumber \\\\\n&=i\\hbar \\frac{i}{\\hbar}\\xi\\hat{q}(\\xi) \\nonumber \\\\\n&=-\\xi\\hat{q}(\\xi)\n\\end{align}\n\nSo we have:\n\\begin{align}\n  \\label{PRAMReq:6}\n\\hat{x}\\hat{q}(\\xi) - \\hat{q}(\\xi)\\hat{x} &= -\\xi\\hat{q}(\\xi)\n\\Rightarrow \\nonumber \\\\\n\\hat{x}\\hat{q}(\\xi) &= \\hat{q}(\\xi)\\hat{x} - \\xi\\hat{q}(\\xi)\n\\end{align}\n\nHence for the $\\ket{x}$, we have:\n\\begin{align}\n  \\label{PRAMReq:7}\n\\hat{x}\\hat{q}(\\xi)\\ket{x} &= (\\hat{q}(\\xi)\\hat{x} -\n\\xi\\hat{q}(\\xi))\\ket{x} \\nonumber \\\\\n&=\\hat{q}(\\xi) (x - \\xi)\\ket{x} \\nonumber \\\\\n&=(x - \\xi)\\hat{q}(\\xi)\\ket{x}\n\\end{align}\n\nFrom (\\ref{PRAMReq:7}) it turns out that if $\\ket{x}$ is the eigen\nstate for the $\\hat{x}$, then $\\hat{q}(\\xi)\\ket{x}$ is also the\n$\\hat{x}$ eigen state which gives the eigen value of $x - \\xi$. This\nholds true for any real value of $\\xi$. Hence, this conclusion implies\nthat the position can adopt any real value for the wave functions.\n\nWhat's more, the (\\ref{PRAMReq:7}) indicates that through\n$\\hat{q}(\\xi)$ the eigen state of $\\ket{x}$ is transformed into the\neigen state of $\\ket{x - \\xi}$, that is:\n\\begin{equation}\n  \\label{PRAMReq:8}\n  \\hat{q}(\\xi)\\ket{x} = \\ket{x - \\xi}\n\\end{equation}\nThus the $\\hat{q}(\\xi)$ is also called ``down operator'' for the\n$\\ket{x}$.\n\nSimilarly, by the same procedure we can construct the ``up operator''\nfor the $\\ket{x}$, which is $\\hat{q}^{+}(\\xi) =\ne^{-\\frac{i}{\\hbar}\\xi\\hat{p}}$. It transforms the $\\ket{x}$ into the\n$\\ket{x + \\xi}$:\n\\begin{equation}\n  \\label{PRAMReq:9}\n    \\hat{q}^{+}(\\xi)\\ket{x} = \\ket{x + \\xi}\n\\end{equation}\n\nHence, from the $\\ket{x}$, and the corresponding up and down operators\nwe can get all the eigen states for the $\\ket{x}$.\n\nAs for the momentum, we can build the similar up and down operators of\n$\\hat{t}(\\xi)$ and $\\hat{t}^{+}(\\xi)$:\n\\begin{align}\n  \\label{PRAMReq:10}\n  \\hat{t}(\\xi) = e^{\\frac{i}{\\hbar}\\xi\\hat{x}} &\\quad \\hat{t}^{+}(\\xi) =\n  e^{-\\frac{i}{\\hbar}\\xi\\hat{x}} \\nonumber \\\\\n \\hat{t}(\\xi)\\ket{p} = \\ket{p + \\xi} &\\quad \\hat{t}^{+}(\\xi)\\ket{p} =\n \\ket{p - \\xi}\n\\end{align}\nthrough same procedure, we can know that $\\ket{p}$ also adopts all the\nreal values.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Position representation and momentum representation}\n\\label{sec:PRAMR_in_position_representation}\n%\n% 1 how to express the \\ket{x} and \\ket{p} in matrix form\n% 2 the physical meaning of matrix element\n% 3 obtain the expression of \\hat{x} for \\ket{x}\n%\nFrom the above section, we have generally set up some important\nfeature for the $\\ket{x}$ and $\\ket{p}$, that both of their eigen\nvalues are continuously changed. Here in this section, we will further\ninvestigate their details by concentrating on one question: how to\nassociate the abstract Hilbert vector of $\\ket{x}$ with the concrete\nwave function of $\\Psi(x)$?\n\nNow let's consider the complete sets of $\\ket{x}$ and $\\ket{p}$. Since\nthe $\\ket{x}$ is the eigen states for the $\\hat{x}$, then it's the\nrepresentation for the $\\hat{x}$, we can call it ``position\nrepresentation''; on the other hand, the $\\ket{p}$ is the\nrepresentation for the $\\hat{p}$ so that we can call it as ``momentum\nrepresentation''.\n\nAccording to the discussion in the above paragraph, the eigen states\nand eigen values for the $\\ket{x}$ and $\\ket{p}$ are continuously\nchanged. So we can express the closure relation as:\n\\begin{align}\n\\label{PRAMReq:11}\n  \\int^{+\\infty}_{-\\infty}\\ket{x}\\bra{x}dx &= 1 \\nonumber \\\\\n  \\int^{+\\infty}_{-\\infty}\\ket{p}\\bra{p}dp &= 1\n\\end{align}\n\nFirstly let's consider the position representation. Let's multiply\n$\\ket{x^{'}}$ to the (\\ref{PRAMReq:11}), it leads to:\n\\begin{equation}\n  \\label{PRAMReq:12}\n    \\int^{+\\infty}_{-\\infty}\\ket{x}\\bra{x} x^{'}\\rangle dx =\n    \\ket{x^{'}}\n\\end{equation}\n\nHowever, since the position is continuously changed, we can use the\ndelta function to express it:\n\\begin{equation}\n  \\label{PRAMReq:13}\n  \\ket{x^{'}}  = \\int^{+\\infty}_{-\\infty}\n  \\ket{x}\\delta(x - x^{'}) dx\n\\end{equation}\n\nHence we have:\n\\begin{equation}\n  \\label{PRAMReq:14}\n \\langle x|x^{'} \\rangle = \\delta(x - x^{'})\n\\end{equation}\n\nFrom (\\ref{PRAMReq:14}) we have gotten the expression for the inner\nproduct. Now let's express some arbitrary quantum state of\n$\\ket{\\Psi}$ via $\\ket{x}$:\n\\begin{align}\n  \\label{PRAMReq:15}\n\\ket{\\Psi} &= \\left\\{\\int^{+\\infty}_{-\\infty}  \\ket{x}\\bra{x}\\,\ndx\\right\\}\\ket{\\Psi}\\nonumber \\\\\n&=\\int^{+\\infty}_{-\\infty}  \\langle x|\\Psi \\rangle\n\\ket{x} dx \\nonumber \\\\\n&= \\int^{+\\infty}_{-\\infty} \\Psi_{x}\\ket{x} dx\n\\end{align}\n\nAccording to the discussion in the section of \\ref{REPRESENTATION:2},\nthe $\\Psi_{x}$ is just the representation for the $\\ket{\\Psi}$; so the\n$\\ket{\\Psi}$ can be expressed as:\n\\begin{equation}\n  \\label{PRAMReq:16}\n  \\ket{\\Psi} \\Leftrightarrow \\begin{pmatrix}\n                               \\vdots \\\\\n                               \\Psi_{x} \\\\\n                               \\vdots \\\\\n                               \\Psi_{x^{'}} \\\\\n                               \\vdots \\\\\n                             \\end{pmatrix}\n\\end{equation}\nHere an important feature is, because the index of $x$ is continuously\nchanged so the the matrix element of the $\\Psi_{x}$ is also continuously\nchanged.\n\nThe $\\bra{\\Psi}$ can be similarly expressed as:\n\\begin{equation}\n  \\label{PRAMReq:17}\n  \\bra{\\Psi} \\Leftrightarrow\n  \\begin{pmatrix}\n  \\cdots & \\Psi^{*}_{x} & \\cdots & \\Psi^{*}_{x^{'}} & \\cdots \\\\\n  \\end{pmatrix}\n\\end{equation}\nThe inner product of $\\langle\\Psi|\\Psi\\rangle$ is:\n\\begin{equation}\n  \\label{PRAMReq:18}\n  \\langle\\Psi|\\Psi\\rangle \\Leftrightarrow\n  \\begin{pmatrix}\n  \\cdots & \\Psi^{*}_{x} & \\cdots & \\Psi^{*}_{x^{'}} & \\cdots \\\\\n  \\end{pmatrix}\n  \\begin{pmatrix}\n  \\vdots \\\\\n  \\Psi_{x} \\\\\n  \\vdots \\\\\n  \\Psi_{x^{'}} \\\\\n  \\vdots \\\\\n  \\end{pmatrix}\n\\end{equation}\nFor some arbitrary operator of $\\hat{A}$, we have:\n\\begin{equation}\n  \\label{PRAMReq:19}\n  \\begin{split}\n    \\langle\\Psi|\\hat{A}|\\Psi\\rangle &=\n\\int^{+\\infty}_{-\\infty}dx \\int^{+\\infty}_{-\\infty}dx^{'}\n   \\Psi^{*}_{x}\\Psi_{x^{'}} \\langle x|\\hat{A}|x^{'}\\rangle\n\\quad\n\\underrightarrow{A_{xx^{'}} = \\langle x|\\hat{A}|x^{'}\\rangle} \\\\\n&\\Leftrightarrow\n\\int^{+\\infty}_{-\\infty}dx \\int^{+\\infty}_{-\\infty}dx^{'}\n  \\begin{pmatrix}\n  \\cdots & \\Psi^{*}_{x} & \\cdots & \\Psi^{*}_{x^{'}} & \\cdots \\\\\n  \\end{pmatrix} \\\\\n&  \\begin{pmatrix}\n    \\cdots & \\cdots & \\cdots & \\cdots & \\cdots \\\\\n    \\cdots & \\cdots & \\cdots & \\cdots & \\cdots \\\\\n    \\cdots & \\cdots & A_{xx^{'}} & \\cdots & \\cdots \\\\\n    \\cdots & \\cdots & \\cdots & \\cdots & \\cdots \\\\\n    \\cdots & \\cdots & \\cdots & \\cdots & \\cdots \\\\\n  \\end{pmatrix}\n  \\begin{pmatrix}\n  \\vdots \\\\\n  \\Psi_{x} \\\\\n  \\vdots \\\\\n  \\Psi_{x^{'}} \\\\\n  \\vdots \\\\\n  \\end{pmatrix}\n  \\end{split}\n\\end{equation}\n\nSuggest that the $\\hat{A}$ in the (\\ref{PRAMReq:19}) is $\\hat{x}$,\nthen we can have:\n\\begin{align}\n  \\label{PRAMReq:26}\n\\langle x^{'}|\\hat{x}|x \\rangle &= x \\langle x^{'}|x \\rangle \\nonumber\n\\\\\n&= x \\delta(x - x^{'})\n\\end{align}\nHence the matrix for $\\hat{x}$ is some continuous diagonal matrix with\nthe its elements all equal to infinity.\n\nNow let's try to associate the $\\ket{x}$ with the wave function form\nof $\\Psi(x)$. Firstly, let's give some physical interpretation for the\n$\\Psi_{x}$.  Since the $x$ inside the $\\Psi_{x}$ are continuously\nvaried, and $\\Psi_{x}$ physically characterizes the weight the\n$\\ket{x}$ in the $\\ket{\\Psi}$; so it turns out that we can set up such\none to one correspondence:\n\\begin{equation}\n\\label{PRAMReq:20} \\Psi_{x} \\Leftrightarrow \\Psi(x)\n\\end{equation}\nThis means, the abstract vector of $\\ket{\\Psi}$ in Hilbert space can\nbe considered as some function based on the variable of $x$. The two\nexpressions are identical to each other. Such one to one\ncorrespondence generally holds true for an arbitrary vector of\n$\\ket{\\Psi}$ in any Hilbert space.\n\nThis final conclusion also give an explanation that why in the\n(\\ref{sec:WPDAOYE_in_basic}) and (\\ref{sec:PWC_in_basic}) we express\nthe wave function in terms of $\\bm{r}$. This can be naturally\nderived from the the more strict framework of quantum mechanics.\n\nGenerally such conclusion can be extended to three dimensional\nspace, that is:\n\\begin{equation}\n\\label{PRAMReq:21} \\Psi_{\\bm{r}} \\Leftrightarrow \\Psi(\\bm{r})\n\\end{equation}\nFor multi-particles system, we can also get:\n\\begin{equation}\\label{PRAMReq:22}\n\\Psi_{\\bm{r_{1}}, \\bm{r_{2}}, \\cdots, \\bm{r_{n}}} \\Leftrightarrow\n\\Psi(\\bm{r_{1}}, \\bm{r_{2}}, \\cdots, \\bm{r_{n}})\n\\end{equation}\n\nFrom now on we can just write the $\\Psi_{x}$ as $\\Psi(x)$. However,\nhere there's one thing still needed to be solved, that is how to\nexpress the operator of $\\hat{x}$ and $\\hat{p}$ in the $\\Psi_{x}$? Now\nlet's go to see how to express the $\\hat{x}$.\n\nSuggest that $\\hat{A}\\ket{\\Psi} = \\ket{\\Phi}$, hence we have:\n\\begin{equation}\\label{PRAMReq:25}\n\\begin{split}\n  \\ket{\\Phi} &= \\hat{A}\\ket{\\Psi} \\quad\n  \\underrightarrow{\\text{From closure relation}} \\\\\n  \\langle x|\\Phi \\rangle &= \\int^{+\\infty}_{-\\infty} \\langle\n  x|\\hat{A}|x^{'} \\rangle \\langle x^{'}|\\Psi\n  \\rangle dx^{'}\\\\\n  \\Phi_{x} &= \\int^{+\\infty}_{-\\infty} A_{xx^{'}}\\Psi_{x^{'}}dx^{'}\n\\end{split}\n\\end{equation}\nNow suggest the $\\hat{A}$ is just the $\\hat{x}$, then according to the\n(\\ref{PRAMReq:26}) we can have:\n\\begin{equation}\\label{PRAMReq:23}\n  \\begin{split}\n      \\Phi_{x} &= \\int^{+\\infty}_{-\\infty} x \\delta(x -\n      x^{'})\\Psi_{x^{'}}dx^{'} \\\\\n&= x \\Psi_{x}\n  \\end{split}\n\\end{equation}\nTherefore, if we have $\\hat{x}\\ket{\\Psi} = \\ket{\\Phi}$, then in the\nposition representation we can conveniently express the position\noperator as $\\hat{x}\\Psi(x) = x\\Phi(x)$. Generally, for the position\noperator of $\\hei{r}\\ket{\\Psi} = \\ket{\\Phi}$, we have\n$\\hei{r}\\Psi(\\bm{r}) = \\bm{r}\\Phi(\\bm{r})$ to correspond to it.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{How to express momentum operator in the position\n  representation}\n\\label{sec:momentum_operator_in_position_momentum}\n%\n%\n% how to express the momentum operator in position representation?\n%\n%\n%\nNow in this section, we are going to seek the concrete expression for\nthe $\\hat{p}$ in the representation of $\\ket{x}$. Firstly, let's\nconcentrate how to express $\\langle x|p \\rangle$.\n\nBy using the up and down operators in the\n(\\ref{eigen_states_in_position_momentum}), we can have:\n\\begin{equation}\n  \\label{PRAMReq:24}\n  \\langle x|p \\rangle = \\langle x|e^{\\frac{i}{\\hbar}p\\hat{x}}|0_{p}\n  \\rangle\n\\end{equation}\nHere $\\ket{0_{p}}$ is just to express the eigen state gives the $0$\neigen value: $\\hat{p}\\ket{0_{p}} = 0\\ket{0_{p}}$.\n\nOn the other hand, the operator of $e^{\\frac{i}{\\hbar}p\\hat{x}}$ is\nalso some operator for the $\\bra{x}$, and by using that\n$\\bra{x}\\hat{x} = \\bra{x}x$, we can have:\n\\begin{equation}\n  \\label{PRAMReq:27}\n  \\langle x|p \\rangle = \\langle x|e^{\\frac{i}{\\hbar}p\\hat{x}}|0_{p}\n  \\rangle  = e^{\\frac{i}{\\hbar}px}\\langle x|0_{p} \\rangle\n\\end{equation}\n\nFor the $\\langle x|0_{p} \\rangle$, by using the up operator for\n$\\bra{x}$, we can have:\n\\begin{equation}\n  \\label{PRAMReq:28}\n  \\langle x|0_{p} \\rangle = \\langle 0_{x}|e^{\\frac{i}{\\hbar}x\\hat{p}}|0_{p}\n  \\rangle\n\\end{equation}\nSimilarly the $e^{\\frac{i}{\\hbar}x\\hat{p}}$ is also the operator on\nthe $\\ket{p}$, so we have $e^{\\frac{i}{\\hbar}x\\hat{p}}\\ket{0_{p}} =\ne^{\\frac{i}{\\hbar}x\\times 0}\\ket{0_{p}} = \\ket{0_{p}}$; therefore we have:\n\\begin{equation}\n  \\label{PRAMReq:29}\n  \\langle x|p \\rangle = e^{\\frac{i}{\\hbar}px}\\langle 0_{x}|0_{p} \\rangle\n\\end{equation}\n\nNow let's go to see how to express the $\\langle 0_{x}|0_{p} \\rangle$:\n\\begin{equation}\n  \\label{PRAMReq:30}\n  \\begin{split}\n    \\langle p^{'}|p \\rangle = \\delta (p^{'} - p) &=\n    \\int^{+\\infty}_{-\\infty} \\langle p^{'}|x \\rangle \\langle x|p\n    \\rangle dx \\\\\n    &= \\int^{+\\infty}_{-\\infty}\n    e^{-\\frac{i}{\\hbar}p^{'}x}e^{\\frac{i}{\\hbar}px} |\\langle\n    0_{x}|0_{p}\n    \\rangle|^{2} dx \\\\\n    &= \\int^{+\\infty}_{-\\infty} e^{\\frac{i}{\\hbar}(p-p^{'})x}|\\langle\n    0_{x}|0_{p}\n    \\rangle|^{2} dx \\quad\n    \\underrightarrow{\\text{From delta function}} \\\\\n    &= |\\langle 0_{x}|0_{p} \\rangle|^{2} 2\\pi\\hbar\\delta(p^{'} - p)\n    \\quad \\Rightarrow \\\\\n    \\langle 0_{x}|0_{p} \\rangle &= \\frac{1}{\\sqrt[2]{2\\pi\\hbar}}\n  \\end{split}\n\\end{equation}\n\nBased on the (\\ref{PRAMReq:30}), let's go to see how to express the\n$\\langle x|\\hat{p}|x^{'}\\rangle$:\n\\begin{equation}\n  \\label{PRAMReq:31}\n  \\begin{split}\n    \\langle x|\\hat{p}|x^{'}\\rangle &= \\int^{+\\infty}_{-\\infty}dp\n    \\int^{+\\infty}_{-\\infty}dp^{'} \\langle x|p\\rangle \\langle\n    p|\\hat{p}|p^{'}\\rangle \\langle p^{'}|x^{'}\\rangle \\quad\n    \\text{by closure relation in \\ref{PRAMReq:1}}  \\\\\n    &= \\frac{1}{2\\pi\\hbar}\\int^{+\\infty}_{-\\infty}dp\n    \\int^{+\\infty}_{-\\infty}dp^{'}\n    e^{\\frac{i}{\\hbar}px}e^{-\\frac{i}{\\hbar}p^{'}x^{'}}\n    p^{'}\\delta(p-p^{'}) \\\\\n    &= \\frac{1}{2\\pi\\hbar}\\int^{+\\infty}_{-\\infty}pdp\n    e^{\\frac{i}{\\hbar}p(x-x^{'})}  \\\\\n    &= \\frac{1}{2\\pi\\hbar}\\int^{+\\infty}_{-\\infty}dp\n    \\frac{\\hbar}{i}\\frac{\\partial e^{\\frac{i}{\\hbar}p(x-x^{'})} }\n    {\\partial x} \\\\\n    &= \\left(\\frac{\\hbar}{i}\\frac{\\partial}{\\partial x}\\right)\n    \\frac{1}{2\\pi\\hbar}\\int^{+\\infty}_{-\\infty}dp\n    e^{\\frac{i}{\\hbar}p(x-x^{'})}  \\\\\n    &=\\frac{1}{2\\pi\\hbar}\\left(-i\\hbar \\frac{\\partial}{\\partial\n        x}\\right)\n    2\\pi\\hbar \\delta(x - x^{'}) \\\\\n    &=-i\\hbar \\frac{\\partial}{\\partial x}\\delta(x - x^{'})\n  \\end{split}\n\\end{equation}\n\nNow let's use the (\\ref{PRAMReq:31}) to get the concrete expression\nfor the momentum operator. Similar to the (\\ref{PRAMReq:25}), we\nsuggest that we have $\\hat{p}\\ket{\\Psi} = \\ket{\\Phi}$, so we have:\n\\begin{equation}\\label{PRAMReq:32}\n\\begin{split}\n  \\ket{\\Phi} &= \\hat{p}\\ket{\\Psi} \\quad\n  \\underrightarrow{\\text{From closure relation}} \\\\\n  \\langle x|\\Phi \\rangle &= \\int^{+\\infty}_{-\\infty} \\langle\n  x|\\hat{p}|x^{'} \\rangle \\langle x^{'}|\\Psi\n  \\rangle dx^{'}\\\\\n  \\Phi_{x} &= \\int^{+\\infty}_{-\\infty} p_{xx^{'}}\\Psi_{x^{'}}dx^{'}\n  \\quad\n  \\underrightarrow{\\text{From \\ref{PRAMReq:31}}} \\\\\n  &= \\int^{+\\infty}_{-\\infty} \\left(-i\\hbar \\frac{\\partial}{\\partial\n      x}\\delta(x - x^{'})\\right) \\Psi_{x^{'}}dx^{'} \\\\\n  &=  -i\\hbar \\frac{\\partial}{\\partial x}\\Psi_{x}\n\\end{split}\n\\end{equation}\nHence we get the expression of momentum operator for wave function\nof $\\Psi(x)$:\n\\begin{equation}\\label{PRAMReq:33}\n\\hat{p}\\Psi(x) = -i\\hbar \\frac{\\partial}{\\partial x}\\Psi(x)\n\\end{equation}\n\nFor three-dimensional space, such conclusion can be generally\nextended as:\n\\begin{equation}\n  \\label{PRAMReq:34}\n  \\hei{p} =  -i\\hbar \\nabla\n\\end{equation}\n\nIn quantum mechanics, since all the other operators are constructed\nby the position operator and the momentum operator, then from the\n$\\hei{r}$ and $\\hei{p}$ we are able to construct the expression for\nall the other operators in the position representation.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{How to express the wave function and operators\nin momentum expression}\n\\label{sec:momentum_operator_in_position_momentum}\n%\n%\n% How to express the wave function and operators\n% in momentum expression\n%\n%\n%\nIn the above content, we have fully solved the question that how to\nassociate the $\\ket{\\Psi}$ with wave function of $\\Psi(\\bm{r})$, and\nhow to express the $\\hei{r}$ and $\\hei{p}$ in terms of the position\nrepresentation.\n\nHowever, according to the axiom \\ref{axiom5}, the position and\nmomentum in quantum mechanics are ``paired'' together. That means,\nif we can express the $\\hei{r}$ and $\\hei{p}$ in terms of $\\bm{r}$,\nthen all the other operators will be some function of $\\bm{r}$; and\nthe corresponding wave functions will be in the form of\n$\\Psi(\\bm{r})$; which is one to one correspondent to the\n$\\ket{\\Psi}$. To be contrary, the judgment holds true for the\nmomentum $\\bm{p}$. We can express the relation as:\n\\begin{align}\\label{PRAMReq:35}\n \\Psi(\\bm{r}) \\Leftrightarrow &\\ket{\\Psi}\n \\Leftrightarrow \\Psi(\\bm{p}) \\nonumber \\\\\n\\hei{r} = \\hei{r}(\\bm{r}), \\hei{p} = \\hei{p}(\\bm{r})\n&\\Leftrightarrow \\hei{r} = \\hei{r}(\\bm{p}), \\hei{p} =\n\\hei{p}(\\bm{p})\n\\end{align}\n\nThe derivation process for getting the expression for the $\\hei{r}$\nand $\\hei{p}$ in terms of the momentum representation is nearly the\nsame with the above derivation for position representation. By\nstarting from the (\\ref{PRAMReq:11}), and each step we exchange the\nposition representation $\\ket{x}$ with the momentum representation\n$\\ket{p}$, we are indeed getting the conclusions shown in\n(\\ref{PRAMReq:35}). More specifically, we point out that in the\nmomentum representation, the operator of $\\hei{r}$ and $\\hei{p}$ are\nexpressed as:\n\\begin{align}\\label{PRAMReq:36}\n\\hei{p} &= p \\nonumber \\\\\n\\hei{r} &= -i\\hbar \\frac{\\partial}{\\partial \\bm{p}}\n\\end{align}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../../main\"\n%%% End:\n", "meta": {"hexsha": "01d28345855071ca6cc58e3ba80bb626018c8032", "size": 20490, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "theory/physics/coordinate_momentum.tex", "max_stars_repo_name": "murfreesboro/fenglai-note", "max_stars_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-16T07:23:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T07:23:48.000Z", "max_issues_repo_path": "theory/physics/coordinate_momentum.tex", "max_issues_repo_name": "murfreesboro/fenglai-note", "max_issues_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theory/physics/coordinate_momentum.tex", "max_forks_repo_name": "murfreesboro/fenglai-note", "max_forks_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.9189189189, "max_line_length": 75, "alphanum_fraction": 0.6387018058, "num_tokens": 6882, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4356784119268605}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% ICML 2013 EXAMPLE LATEX SUBMISSION FILE %%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Use the following line _only_ if you're still using LaTeX 2.09.\n%\\documentstyle[icml2013,epsf,natbib]{article}\n% If you rely on Latex2e packages, like most moden people use this:\n\\documentclass{article}\n\n% For figures\n\\usepackage{graphicx} % more modern\n%\\usepackage{epsfig} % less modern\n\\usepackage{subfigure} \n\n% For citations\n\\usepackage{natbib}\n\n% For algorithms\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\n% As of 2011, we use the hyperref package to produce hyperlinks in the\n% resulting PDF.  If this breaks your system, please commend out the\n% following usepackage line and replace \\usepackage{icml2013} with\n% \\usepackage[nohyperref]{icml2013} above.\n\\usepackage{hyperref}\n\n% Packages hyperref and algorithmic misbehave sometimes.  We can fix\n% this with the following command.\n\\newcommand{\\theHalgorithm}{\\arabic{algorithm}}\n\n% Employ the following version of the ``usepackage'' statement for\n% submitting the draft version of the paper for review.  This will set\n% the note in the first column to ``Under review.  Do not distribute.''\n\\usepackage{icml2013} \n% Employ this version of the ``usepackage'' statement after the paper has\n% been accepted, when creating the final version.  This will set the\n% note in the first column to ``Proceedings of the...''\n% \\usepackage[accepted]{icml2013}\n\n\n% The \\icmltitle you define below is probably too long as a header.\n% Therefore, a short form for the running title is supplied here:\n\\icmltitlerunning{Submission and Formatting Instructions for ICML 2013}\n\n\\begin{document} \n\n\\twocolumn[\n\\icmltitle{Analysis of Self Implemented Logistic Regression}\n\n% It is OKAY to include author information, even for blind\n% submissions: the style file will automatically remove it for you\n% unless you've provided the [accepted] option to the icml2013\n% package.\n\\icmlauthor{Carl Cortright}{carl.cortright@colorado.edu}\n\n% You may provide any keywords that you \n% find helpful for describing your paper; these are used to populate \n% the \"keywords\" metadata in the PDF but will not be shown in the document\n\\icmlkeywords{boring formatting information, machine learning, ICML}\n\n\\vskip 0.3in\n]\n\n\\section{Introduction}\nLogistic regression is a common machine learning technique used for both binary and multiclass classification problems. In this paper, I demonstrate how logistic regression can be used to identify the topic of a document. Specifically, I use a technique called stochastic gradient decent to build a fast and accurate model for classification. Analysis of the forulas used will show how large beta values are used heavily in predicting a class.\n\n\\section{Formulas}\n\n\\subsection{The Sigmoid Fuction}\nThe sigmoid function is used heavily in logistic regression because it sqeezes any real value into a number between 0 and 1 (like a probability) and is easily differentiable. To calculate the probability of a given feature vector, we feed the dot product of beta values and the training examples into the sigmoid function.\n\n\\subsection{The Delta}\nOn each beta update, we change each beta value by some amount delta. We know that delta needs to move beta in the right direction, so we take the actual label and subtract the calculated probability and then we multiply by the number of times that feature appears in the feature vector. After multiplying this value by the step function, we add it to the beta vector, allowing us to shift the beta vector is the right direection based on the training example.\n\n\\subsection{Regularization}\nIn order to ensure that our model generalizes well to unseen data, we need to prevent overfitting. The most common way to prevent overfitting in logistic regression is by using regularization, or penalizing large beta values. The way we do this is by shrinking large beta values. We define a shrinkage value that gets larger based on the iteration. We then take all of the features that we just updated and multiply them by our shrinkage number raised to the gap power (how long it has been since we last updated). This will effectively scale the beta value down if it is very large. \n\n\\section{Questions}\n\n\\subsection{What is the learning rate?}\nThe learning rate determines how quickly our model will converge. In this program, the learning rate is determined in our lambda function step and is set to 0.05.\n\n\\subsection{How many passes over the data did we need?}\nIn this program, we are able to converge to a reasonable answer fairly quickly, using 1 or 2 passes over the data. Heuristically, I would guess the sweetspot is somewhere between 5-10 passes with mu being less than 0.1. Any more and we would risk overfitting.\n\n\\subsection{What are the best predictors?}\nThe best predictors of each class, are the highest weighted beta values for that class. Hockey was denoted by negative beta values and when we sorted them we found that the highest predictors were:\n\n\\begin{tabular}{|c|c|}\n  Feature & Beta \\\\\n  \\hline\n  hockey & -2.39701629657 \\\\\n  playoffs & -1.44564218453 \\\\\n  golchowy & -1.17516769744 \\\\\n  ice & -1.03574704859 \\\\\n  next & -1.02160900872 \\\\\n  goals & -1.01665832771 \\\\\n  pick & -1.01647140833 \\\\\n  playoff & -0.976664795926 \\\\\n  points & -0.954740265196 \\\\\n  biggest & -0.934753162921 \\\\\n  \n\\end{tabular}\n\nAnd for baseball, the beta values were positive:\n\n\\begin{tabular}{|c|c|}\n  Feature & Beta \\\\\n  \\hline\n  runs & 1.43294142746 \\\\\n  hit & 1.10998401766 \\\\\n  pitching & 1.03061549829 \\\\\n  baseball & 1.02607170122 \\\\\n  catcher & 0.854081642361 \\\\\n  ball & 0.793975224712 \\\\\n  anyone & 0.784188784459 \\\\\n  saves & 0.764849612496 \\\\\n  run & 0.697562386451 \\\\\n  book & 0.684478585989 \\\\\n  \n\\end{tabular}\n\nInterestingly, the words that best predicted baseball were verbs associated with the activity, with the actual word baseball coming in at number 4.\n\n\\subsection{What are the worst predictors?}\nThe worst predictors for a given class are the best predictors for the other class. In this case the worst predictors for hockey are the best predictors for baseball and vice versa.\n\n\\subsection{What happens if mu is 0?}\nIf mu is zero, our regularization will have no effect. This means a lot of things including that we might risk overfitting. It also means it takes less passes for our model to converge.\n\n\\section{Conclusion}\nIn this lab, we used a logistic regression model to predict whether a document was talking about hockey or baseball. We used this model to predict which unigram features were most predictive of each class, and created a highly accurate classifier to go along with our testing and training data. We learned about regularization and stochastic gradient decent. I was most supprised at how accurate the model became even on a small dataset. \n\n\n\\end{document} \n\n\n% This document was modified from the file originally made available by\n% Pat Langley and Andrea Danyluk for ICML-2K. This version was\n% created by Lise Getoor and Tobias Scheffer, it was slightly modified  \n% from the 2010 version by Thorsten Joachims & Johannes Fuernkranz, \n% slightly modified from the 2009 version by Kiri Wagstaff and \n% Sam Roweis's 2008 version, which is slightly modified from \n% Prasad Tadepalli's 2007 version which is a lightly \n% changed version of the previous year's version by Andrew Moore, \n% which was in turn edited from those of Kristian Kersting and \n% Codrina Lauth. Alex Smola contributed to the algorithmic style files.  \n", "meta": {"hexsha": "745aa1b901a1ed5eb39a8285697bf8c3ca75c762", "size": 7574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProgrammingAssignments/LogisticRegression/Analysis/logreg.tex", "max_stars_repo_name": "ckcortright/CSCI4830MachineLearning", "max_stars_repo_head_hexsha": "5d1c6c7bfb05b54f7c000c940b1f6410054f10f0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ProgrammingAssignments/LogisticRegression/Analysis/logreg.tex", "max_issues_repo_name": "ckcortright/CSCI4830MachineLearning", "max_issues_repo_head_hexsha": "5d1c6c7bfb05b54f7c000c940b1f6410054f10f0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProgrammingAssignments/LogisticRegression/Analysis/logreg.tex", "max_forks_repo_name": "ckcortright/CSCI4830MachineLearning", "max_forks_repo_head_hexsha": "5d1c6c7bfb05b54f7c000c940b1f6410054f10f0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-11-30T07:28:47.000Z", "max_forks_repo_forks_event_max_datetime": "2017-01-28T05:52:45.000Z", "avg_line_length": 50.8322147651, "max_line_length": 584, "alphanum_fraction": 0.7602323739, "num_tokens": 1816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.43553528117262175}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{cmap}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[english]{babel}\n\n\\usepackage{microtype}\n\\usepackage{csquotes}\n\\usepackage{enumitem}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{mathtools}\n\n\\setlength{\\parindent}{0cm}\n\n\\newtheorem{definition}{Definition}\n\\newtheorem{example}{Example}\n\n\\begin{document}\n\n\\section{Adverse Selection}\n\nIn reality, information is often asymmetrically held by market participants. Examples of such situations are\n\n\\begin{itemize}\n\t\\item Firms do not know the abilities of workers to be hired\n\t\\item Investors / creditors cannot observe the abilities / projects of firms' managers\n\t\\item Automobile insurance companies do not know the individual driving skills of their customers\n\t\\item Buyers of used car can rarely check the cars' qualities perfectly\n\\end{itemize}\n\nSuch hidden information can lead to adverse selection, signalling and screening. Following, we will examine the case of adverse selection.\n\n\\subsection{Basic Labour Market Model}\n\nAssume that in a market, there are many workers of different types $\\theta$, e.g. with different productivity, such that\n\n\t$$ \\theta \\in [\\underline{\\theta}, \\overline{\\theta}] \\text{ with }0 \\leq \\underline{\\theta} < \\overline{\\theta} < \\infty.  $$\n\t\nThe proportion of workers with productivity of $\\theta$ or less is given by the cumulative distribution function $F(\\theta)$. Additionally, we assume there to be many identical potential firms that can hire workers seeking to maximise their expected profits. A worker can choose to work either at a firm or at home, and the utility of worker $\\theta$ is thereby given by\n\n\t$$ u(w, \\theta) = \\begin{cases} \\omega & \\text{ if he accepts wage } \\omega \\\\ r(\\theta) & \\text{ if he does not accept } \\omega \\end{cases} $$\n\t\nFirms produce with labour only and have constant production technologies\n\n\t$$ \\theta = \\text{ output (=revenue) of worker } \\theta $$\n\t\nPareto-optimum: Set of workers employed is $\\theta = \\left\\{ \\theta \\colon \\theta \\geq r(\\theta) \\right\\}$.\n\n\\subsubsection{Case 1: $\\theta$ is publicly observable}\n\nThe resulting wage will depend on each type, i.e. $\\omega(\\theta)$. Because the labour of each different type of worker is a distinct, publicly known good, there is a distinct equilibrium wage. As the profit of a firm ($\\pi$) from a type $\\theta$ worker:\n\n\t$$ \\pi = \\theta - \\omega(\\theta) $$\n\nThey will only seek employment if $\\theta > \\omega(\\theta)$. The resulting demand for labour ($z$) of type $\\theta$ is hence:\n\n\t$$ z(\\theta) = \\begin{cases} 0 & \\text{ if } \\theta < \\omega(\\theta) \\\\ [0, \\infty) & \\text{ if } \\theta = w(\\theta) \\\\ \\infty & \\text{ if } \\theta > \\omega(\\theta) \\end{cases} $$\n\nTherefore, given the competitive, constant returns nature of the firm, in a \\textit{competitive} equilibrium the different wage offers (i.e. $\\pi = 0$) are\n \n\t$$ \\omega(\\theta) = \\theta, $$\n\t\nand the set of workers accepting employment in a firm is\n\n\t$$ \\Theta = \\left\\{ \\theta \\colon r(\\theta) \\leq \\theta \\right\\} $$\n\t\nAs expected from the first fundamental welfare theorem, the outcome is, due to the competitive nature of the market, a Pareto optimal equilibrium. Note: For this result firms need not know $r(\\theta)$, and thus, the market can successfully aggregate and process information!\n\n\\subsubsection{Case 2: $\\theta$ is ex ante observable only to the worker}\n\nWe have to begin by noting that the resulting equilibrium in this competitive environment is of asymmetric information. A firm will learn about $\\theta$ only \\textit{ex post}, therefore  this is not useful for \\textit{ex ante} contracting. This means the wage cannot depend on $\\theta$, and hence, there must be a single wage $\\omega$ offered to all workers. Again, a worker of type $\\theta$ is willing to work for a firm if and only if $r(\\theta) \\leq \\omega$. Hence, the set of worker types who are willing to accept employment at wage rate $\\omega$ is\n\n\t$$ \\Theta(\\omega) = \\left\\{ \\theta \\colon r(\\theta) \\leq \\omega \\right\\} $$\n\t\nand gives us the labour supply. Let $\\mu$ be the expected average productivity of employed workers (to be determined). If a firm assumes $\\mu$, its demand for labour is given by\n\n\t$$ z(\\omega)= \\begin{cases} 0 & \\text{ if } \\mu < \\omega \\\\ [0, \\infty) & \\text{ if } \\mu = \\omega \\\\ \\infty & \\text{ if } \\mu > \\omega \\end{cases} $$ \n\t\nNow, if worker types in set $\\Theta^*$ are accepting employment offers in a competitive equilibrium, and if firms' beliefs about the productivity of potential employees correctly reflect the actual average productivity of the workers hired in this equilibrium, then we must have \n\n\t$$ \\mu = \\mathbb{E} \\left[\\theta ~|~\\theta \\in \\Theta^* \\right] $$\n\t\n\tHence, the labour demand implies that the demand can equal its supply in an equilibrium with a positiv level of employment if and only if \n\t\n\t$$ w = \\mathbb{E} \\left[ \\theta ~|~ \\theta \\in \\Theta^* \\right] $$\n\t\n\tThis leads to the notion of a competitive equilibria\n\t\n\t\\begin{definition}\n\t\tA \\textbf{competitive equilibrium} is a wage $\\omega^*$, an employment set $\\Theta^*$, and a belief $\\mu^*$ such that\n\t\t\n\t\t\\begin{align*}\n\t\t\t\\Theta^* & = \\left\\{ \\theta \\colon r(\\theta) \\leq \\omega^* \\right\\} \\\\\n\t\t\t\\omega^* & = \\mu^* \\\\\n\t\t\t\\mu^* & = \\begin{cases} \\mathbb{E} \\left[ \\theta ~|~\\theta \\in \\Theta^* \\right] & \\text{ if } \\Theta^* \\neq \\emptyset \\\\ \\mathbb{E} \\left[ \\theta \\right] & \\text{ if } \\Theta^* = \\emptyset \\end{cases}\n\t\t\\end{align*}\n\t\\end{definition}\n\nNote, that the expectation in the definition above seems not to be well defined when no workers are accepting employment in an equilibrium, i.e. when $\\Theta^* = \\emptyset$. In the following discussions however, we can assume for simplicity that in this circumstance each firm's expectation of potential employees' average productivity is simply the unconditional expectation $\\mathbb{E} \\left[ \\theta \\right]$, and we take \n\n\t$$ \\omega^* = \\mathbb{E} \\left[ \\theta \\right] $$\n\t\nin any such equilibrium. Typically a competitive equilibrium as defined above will fail to be Pareto optimal which is seen in the following example.\n\n\\begin{example}\n\tAssume $r(\\theta) = r$ for all $\\theta$, with $\\underline{\\theta} < r < \\overline{\\theta}$, i.e. every worker is equally productive at home. The Pareto optimal allocation of labour in this setting has workers with $\\theta \\geq r$ accepting employment at a firm and those with $\\theta < r$ not doing so. In the competitive equilibrium, a worker is willing to accept employment if $\\omega \\geq r$. This means at a given wage, $\\Theta(\\omega)$, is either:\n\t\n\t$$ \\Theta = \\left[ \\underline{\\theta}, \\overline{\\theta} \\right] \\text{ if } \\omega \\geq r ~\\text{ or }~ \\Theta = \\emptyset \\text{ if } \\omega < r $$\n\t\n\tThus, in either case, $\\mu = \\mathbb{E}\\left[ \\theta ~|~\\theta \\in \\Theta^*(\\omega) \\right] = \\mathbb{E} \\left[ \\theta \\right]$, i.e. for all $\\omega$ and unconditional. By the definition of competitive equilibria  the equilibrium wage rate must be\n\t\n\t\t$$ \\omega^* = \\mathbb{E} \\left[ \\theta \\right] $$\n\t\t\n\tIf $\\mathbb{E}[\\theta] \\geq r$, then all workers accept employment at a firm; if $\\mathbb{E}[\\theta] < r$, then none do. Which type of equilibrium arises depends on the relative fraction of good and bad workers. For example, if there is a high fraction of low-productivity workers then, because firms cannot distinguish good workers from bad, they will be unwilling to hire any workers at a wage that is sufficient to have them accept employment, i.e.\n\t\n\t\t$$ \\mathbb{E} \\left[ \\theta \\right] < r $$\n\t\t\n\tOn the other hand, if there are very few low-productivity workers, then the average productivity of the workforce will be avoce $r$, and so the firms will be willing to hire workers at a wage that they are willing to accept, i.e.\n\t\t\n\t$$ \\mathbb{E} \\left[ \\theta \\right] \\geq r $$\n\t\n\tIn one case, too many workers are employed relative to the Pareto optimal allocation, and in the other too few, and therefore,  neither case is Pareto-optimal since \n\t\n\t$$\\Theta^* \\neq \\left\\{ \\theta \\colon \\theta \\geq r \\right\\}. $$\n\t\n\tThe cause of this failure of the competitive allocation to be Pareto optimal is simple to see: because firms are unable to distinguish among workers of differing productivities, the market is unable to allocate workers efficiently between firms and home production. ~\\bigskip\n\t\n\tNote: If workers could not observe their own type $\\theta$ the same allocation would result. Thus, knowledge does not do harm in this example, but cannot be optimally processed by the market.\n\\end{example}\n\n\\section{Signalling}\n\nIn the model with adverse selection, good workers were underpaid because they were unable to credibly inform firms about their productivity. Hence, they should have an incentive to \\enquote{signal} their productivity, if this is possible. This will now be investigated in a simple setting.\n\n\\subsection{Simple Signalling}\n\n\\subsubsection{Model}\n\nIn this section we assume that there are two firms competing for hiring workers. Furthermore, there are only two types of workers, $L$ and $H$, with $0 < \\theta_L < \\theta_H$ and $\\lambda = \\mathbb{P}(\\theta = \\theta_H)$ where $0 < \\lambda < 1$. We assume \n\n\t$$ 0 \\leq r(\\theta_L) \\leq r(\\theta_H) < \\mathbb{E}[\\theta]. $$\n\nThe important extension of our previous model is that before entering the job market a worker can signal, this can have the form of getting some education and the amount of education that a worker receives is observable. Regardless of the type, signalling does nothing for a worker's productivity. Type $\\theta_H$  can produce such a signal at cost $c$, and we assume that type $\\theta_L$ cannot produce a signal, where\n\n\t$$ 0 \\leq c < \\theta_H - \\mathbb{E}[\\theta] $$\n\n\\subsubsection{Timing}\n\nIn this setting, we can identify four stages developing from setup to possible employment:\n\n\\begin{enumerate}\n\t\\item Nature chooses workers' types, observed only by them\n\t\\item Workers may produce a signal\n\t\\item Firms observe signals and simultaneously announce wage offers\n\t\\item Workers decide whether to join a firm or not. If they are indifferent, they choose either option with probability $p = 0.5$.\n\\end{enumerate}\n\n\\textbf{Stage 3}: ~\\smallskip\n\nAt the fourth stage the decision is merely where a worker maximises his profit, we will therefore start with stage three. Here, we notice that wages cannot depend on the type $\\theta$ as those aren't observable. However, the wages can depend on the signal:\n\n\\begin{itemize}\n\t\\item Let $\\omega_s$ be the wage offered to a worker who has signalled\n\t\\item Let $\\omega_{nonS}$ be the wage offered to a worker who has not signalled.\n\\end{itemize}\n\nThe competitive equilibrium that emerges is hence\n$$ \\omega_s = \\theta_H ~\\text{ and }~ \\omega_{nonS} \\in \\left[\\theta_L, \\mathbb{E}[\\theta] \\right] $$\n\n\\textbf{Stage 2}: ~\\smallskip\n\nAs by assumption $0 \\leq c < \\theta_H - \\mathbb{E}[\\theta]$ holds, all workers of type $H$ will now signal.\n\n\\subsubsection{Consider two sub-cases}\n\n\\begin{itemize}\n\t\\item $r(\\theta_L) \\leq r(\\theta_H) \\leq \\theta_L$: Signalling is wasteful\n\t\\item $\\theta_L < r(\\theta_L) < r(\\theta_H) < \\mathbb{E} \\left[ \\theta \\right]$: Signalling may be useful\n\\end{itemize}\n\nHint: In both cases, the equilibrium in the pure adverse selection model (without signalling) is \n\n\t$$ \\omega^* = \\mathbb{E}[\\theta] $$\n\n\\end{document}", "meta": {"hexsha": "9f514ee36fb6bc0e4015b460c12c3c9559e8814f", "size": 11358, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Skript.tex", "max_stars_repo_name": "MBelica/Advanced-Topics-in-Economic-Theory", "max_stars_repo_head_hexsha": "36a08012f40acb999b63c127f3710b5abba519ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Skript.tex", "max_issues_repo_name": "MBelica/Advanced-Topics-in-Economic-Theory", "max_issues_repo_head_hexsha": "36a08012f40acb999b63c127f3710b5abba519ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Skript.tex", "max_forks_repo_name": "MBelica/Advanced-Topics-in-Economic-Theory", "max_forks_repo_head_hexsha": "36a08012f40acb999b63c127f3710b5abba519ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.0952380952, "max_line_length": 554, "alphanum_fraction": 0.7248635323, "num_tokens": 3058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.43553527660105584}}
{"text": "\\subsection{Boltzmann Machine}\n\n%Lucas.\n\n\\begin{figure}[htbp]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.5\\textwidth]{inc/Restricted_Boltzmann_machine.png}\n\t\t\\caption{Illustration of a Restricted Boltzmann Machine.\\protect\\footnotemark}\n\t\t\\label{fig:restricted_boltzmann_machine}\n\t\\end{center}\n\\end{figure}\n\\footnotetext{Original image (CC BY-SA): \\url{https://en.wikipedia.org/wiki/File:Restricted_Boltzmann_machine.svg}}\n\nUnfortunately, the Boltzmann Machine is very slow to train and is thus only practical for simpler problem domains. If the BM is scaled beyond any trivial domain it becomes too slow and almost stops learning. This is due to the fact that all units of the BM are fully connected to each other which does not scale well.\n\nIn order to use the BM for bigger tasks a restriction has to be made. Namely, connections between units in the same layer can not be allowed. This is called the Restricted Boltzmann Machine (or ``Harmonium'' as the original author referred to it) \\cite{smolensky1986information}.\n\nVersions of the Restricted Boltzmann Machine (RBM) have been successfully used in many applications such as deep learning \\cite{hinton2012better} and speech recognition \\cite{dahl2010phone}.\n\nThe general idea when using RBM's in deep learning is to ``stack'' several RBM's on top of each other. The activities of the units in the hidden layer of one RBM can be used as input vector for the next RBM. This way the overall system does not have the problem with scalability that the ordinary Boltzmann Machine suffered as well as the added bonus that the generative model is improved each time a new layer is added on top of the existing ones.\n\nA variant of the Deep Boltzmann Machine \\cite{salakhutdinov2009deep} (which is used for deep learning) called the Shape Boltzmann Machine (SBM) has been shown to be able to ``restore'' parts of an image when shown only a part of it \\cite{eslami2014shape}. It does not ``restore'' the image to its original form, but fill in the blanks with its interpretation of the data it has been given. This can bee seen as a form of auto-associative memory.\n", "meta": {"hexsha": "f115a9418c03b49c104376999174c0f66b64d3f3", "size": 2112, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/3_current_capabilities/2_boltzmann_machine.tex", "max_stars_repo_name": "mewmew/associative_memories", "max_stars_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-30T12:08:22.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-30T12:08:22.000Z", "max_issues_repo_path": "report/sections/3_current_capabilities/2_boltzmann_machine.tex", "max_issues_repo_name": "mewmew/associative_memory", "max_issues_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-04-04T00:06:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-02T13:32:52.000Z", "max_forks_repo_path": "report/sections/3_current_capabilities/2_boltzmann_machine.tex", "max_forks_repo_name": "mewmew/associative_memory", "max_forks_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.8260869565, "max_line_length": 448, "alphanum_fraction": 0.7940340909, "num_tokens": 518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.4355352674579238}}
{"text": "\\subsection{Intel Lab Data}\n\\label{sec:intel-lab-data-evaluation}\n\nWe also evaluated our outlier detection framework on sensor data from the publicly available Intel Lab Data set\\footnote{\\url{http://db.csail.mit.edu/labdata/labdata.html}}. The Intel Lab Data contains data collected from 54 sensors spread throughout the Intel Berkeley Research Lab. Each data entry contains information including temperature, humidity, light and voltage taken from a Mica2Dot sensor and weatherboard. The dataset contains a total of approximately 2.3 million measurements.\n\nThe Intel lab dataset has known outliers from faulty sensor readings due to periods of critically low voltage. During these periods, the sensors go haywire and produce faulty measurements. For example, the temperature may be registered as over $120$ degrees Celsius, which is obviously abnormal behavior in a human environment such as where the sensors were deployed.\n \nWe analyzed a sample of 1000 data points selected at random from the sensor data; due to the numerical nature of this data, the Simple Gaussian and Mixture models are better-suited to analyzing it than the Histogram model.\n\nWe also compare the results of our models to Local Outlier Factors, a common outlier detection methodology, in this section.\n \n\\subsubsection{Simple Gaussian Model}\n\nThe results from running the sensor data set through the Simple Gaussian model are shown in Figure~\\ref{fig:gauss15}. The data is plotted in light green, and the outliers are marked by dark red crosses. \n\nIn this experiment we flag the entries with column values that fall outside $1.5$ standard deviations of the mean of that particular column as outliers. This model runs relatively fast, as no correlations are computed (\\timing{.03}{0}{.12}).\n%As we observe in Figure~\\ref{fig:gauss15}, this leads to the extreme values on the temperature spectrum as well as the humidity spectrum to be identified as outliers.\n%However, many points in the normal range of operation are flagged as outliers.\n%The cause of the noise can be seen in Figure~\\ref{fig:sensors_gaus_1-5b}.\n%In this plot we see that the values of both voltage and light are relatively evenly distributed within their respective ranges.\n%Therefore many values lie outside $1.5$ standard deviations from the mean, despite having reasonable values in other dimensions such as temperature.\n%Using information from correlations is one way in which we improve on this, which we describe in the next section.\n\n\n\\subsubsection{Mixture Model}\nWe set the statistical threshold to $0.7$, which produces two correlations between temperature and humidity and between temperature and voltage. \nFigure~\\ref{fig:gmm1t1} shows the results when using a single Gaussian component. Points flagged as outliers have a likelihood of less than $7.5\\%$ of being produced by the Gaussian generated by the model (\\timing {.03}{.34}{.73}).\n\nThis model is able to detect values with high temperature and low voltage as outliers.\n \n%We show in Figure~\\ref{fig:sensors_nocorr} the benefits of pruning the data via correlations before feeding it into the Gaussian model.\n%In this experiment, we allow the statistical analyzer to mark all columns as correlated.\n%The model produces a Gaussian with so much noise from the light data that it detects many points even within the normal operating range as outliers, even when the threshold is reduced to $0.5\\%$. \n%Thus, using some mechanism to find correlations is useful in narrowing the search space for outliers.\n \nFigure~\\ref{fig:gmm2t05} shows the results obtained using the Mixture model with two components, using the same 1000 randomly selected data points. Flagged values have a likelihood of less than $7.5\\%$ under their dominant Gaussian (\\timing {.03}{.35}{0.78}).\nWhen using two Gaussians, the points clustered around the temperature $120$ degrees Celsius are no longer detected as outliers: they are modeled by their own Gaussian (although this Gaussian's weight is smaller than its counterpart). This model highlights the points within normal sensor operation that have outlying results.\n\n\n\\subsubsection{Local Outlier Factors}\n\\label{sec:lof-evaluation}\n\nIn this section we compare the results of our Gaussian and Mixture models to Local Outlier Factors (LOF)~\\cite{Breunig2000}, a frequently used method for outlier detection.\nLOF measures the degree to which a data point is an outlier by comparing each data point's reachability to those of its $k$ nearest neighbors.\nThe higher the LOF, the more isolated the data point relative to its local neighborhood and therefore the more likely the point is to be an outlier.\n\nOne downside of LOF compared to \\dBoost/ is that it can only evaluate two-dimensional data.\nThe original algorithm also has significant computation complexity in order to calculate the distance to the nearest neighbors of each data point.\nOne benefit of LOF, however, is that the algorithm returns a continuous value that indicates the degree to which a point is an outlier, as opposed to a binary value.\n\nFigure~\\ref{fig:lofk2} shows the outliers detected by LOF when $k=2$.\nWe observe that contrary to the Gaussian and Mixture models, the outliers detected by LOF are scattered throughout the data.\nThe outliers are not necessarily the points one would intuitively assume are outliers.\nThis is because points that are within the normal range of the data will be selected as outliers if they are far enough away from the other points nearest to them.\n%When the number of nearest neighbors evaluated is increased to $10$ in Figure~\\ref{fig:lof_10}, the outliers detected are further outside the main cluster of points.\nWe find that LOF is not as useful at pointing out the tagged outliers in the sensor data set.\n\n\n", "meta": {"hexsha": "3879ea732a47373ea1b309fb1e81a43809cd9f3f", "size": 5749, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "raha/tools/dBoost/paper/icde/intel-lab-data-evaluation.tex", "max_stars_repo_name": "adrianlut/raha", "max_stars_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2019-07-05T12:03:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T07:44:58.000Z", "max_issues_repo_path": "raha/tools/dBoost/paper/icde/intel-lab-data-evaluation.tex", "max_issues_repo_name": "adrianlut/raha", "max_issues_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-01-10T12:59:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-10T12:59:43.000Z", "max_forks_repo_path": "raha/tools/dBoost/paper/icde/intel-lab-data-evaluation.tex", "max_forks_repo_name": "adrianlut/raha", "max_forks_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2019-04-21T12:28:33.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T06:42:36.000Z", "avg_line_length": 97.4406779661, "max_line_length": 490, "alphanum_fraction": 0.8018785876, "num_tokens": 1221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4355352589516791}}
{"text": "\\documentclass{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\n\\usepackage[shortlabels]{enumitem}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{mathtools}\n\\usepackage{lmodern}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\\setlength{\\parskip}{0.5em}\n\n\\usepackage{clrscode3e}\n\n\\title{Binary Search: Find it Quickly} \n\\author{Competitive Programming UTEC}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\n\\subsection{Motivation}\n\nLets say you are given an integer array $A$ of size $n$, and you have to answer the following query: Given an integer $x$ find, $i$ such that $A_i = x$, or determine that such position doesn't exist. \n\nThere is one obvious trivial solution for this problem, we iterate through all elements in the array and find an index that satisfies the condition. It is simple to see that this approach would have a complexity of $O(n)$, so if we have multiple queries this might be too slow.\n\nAnother sensible approach would be to keep an index \\textit{map}, in which we store for every value in the array it's position. With this apporach we can have a time of $O(1)$ per query, but will also need an auxiliary space of $O(n)$.\n\nFor most arrays, this are our only options. However, if the array is \\textit{sorted}, we can use binary seach to solve this problem in logarithmic time and $O(1)$ of memory.\n\n\\subsection{Binary Search}\n\nBinary search is a \\textit{divide and conquer} search algorithm that allows us to look for values in sorted lists in logarithmic time. Thanks to it versatility, binary search is used in thousands of algorithms in order to boost up performance. Most importantly, its uses go \\textbf{way beyond looking for values in an array}, as we will learn later.\n\nIn order to be able to apply binary search the following conditions must be satisfied:\n\n\\begin{itemize}\n\t\\item \\textbf{Random Access:} We must be able to jump to any element in the sequence with an $O(1)$ complexity.\n\t\\item \\textbf{Order:} Elements in the sequence must follow some kind of order.\n\\end{itemize}\n\n\\subsection{The Algorithm}\n\nThe binary search algorithm is very simple. Lets say I want to find element $x$ in array $A$. I could begin by guessing at which position $x$ will be, for example I could guess that $A[i] = x$. There are three possibilities:\n\n\\begin{enumerate}\n\t\\item If am very lucky then $A[i] = x$.\n\t\\item $A[i] < x$\n\t\\item $A[i] > x$\n\\end{enumerate}\n\nIt is obvious that in the first case I just need to return $i$ as my answer, but what about cases 2 and 3. Lets say that $A[i] < x$, then as the array is sorted, we know that it is impossible that $x$ is to the left of $A[i]$ as they will be all smaller than $A[i]$, and therefore, smaller than $x$. This means that if I were to guess again, I could ignore all indexes that are smaller or equal to $i$. Symmetrically, if $A[i] > x$, than I now that it is impossible that $x$ is anywhere to the right of $A[i]$.\n\nNow what if instead of guessing, we picked an index systematically, so that after every comparison we can discard a large number of the elements in the array of our candidates. The best way to do this is to pick the middle element of the array, as regardless of how $A[i]$ compares with it, we will get rid of half of the array in one move. Then we can repeatedly apply binary search until we find the value we are looking for.\n\nAs after each iteration we are halving the array, it is simple to see than in the worst case we will have to split the array until a single element remains. This is what yields a complexity of $O(lgn)$ for the search.\n\nJust as it is the case with most divide and conquer algorithms, the most intuitive approach for the implementation of binary search is recursive. In the implementation $l$ and $r$ represent that range in which we can still find value $x$. The algorithm stops when we find $x$ of when $l > r$, which means that $x$ wasn't in the array.\n\n\\begin{codebox}\n\\Procname{$\\proc{binarySearch}(A, l, r, x)$}\n\t\\li \\If $l > r$ \\li \\Then\n\t\t\\Return -1\n\t\\End\n\n\t\\li $m = \\floor{\\frac{l + r}{2}}$\n\t\\li \\If $A[m] < x$ \\li \\Then \n\t\t\\Return $\\proc{binarySearch}(A, l, m - 1, x)$\n\t\\End\n\t\\li \\If $A[m] > x$ \\li \\Then \n\t\t\\Return $\\proc{binarySearch}(A, m + 1, r, x)$\n\t\\End\n\t\n\t\\li \\Return $m$\n\\end{codebox}\n\nThis solution occupies $O(lgn)$ memory because of the extra space that needs to be allocated in the stack, unless we use the \\textit{tail recursion optimization}, case in which it will just consume $O(1)$ memory. A simple iterative implementation of binary search also exists. The idea for this is the same, but instead of calling the binary search method recursively, we use an while loop to update the values of $l$ and $r$.\n\n\\begin{codebox}\n\\Procname{$\\proc{binarySearch}(A, l, r, x)$}\n\t\\li $l \\gets 1$\n\t\\li $r \\gets \\attrib{A}{size}$\n\t\\li \\While $l \\leq r$ \\li \\Do \n\t\t$m \\gets \\floor{\\frac{l + r}{2}}$\n\t\t\\li \\If $A[m] = x$ \\li \\Then\n\t\t\t\\Return m\n\t\t\\End\n\t\t\\li \\If $A[m] < x$ \\li \\Then\n\t\t\t$r \\gets m - 1$\n\t\t\\li \\Else\n\t\t\t\\li $l \\gets m + 1$\n\t\t\\End\n\t\\End\n\n\t\\li \\Return $-1$\n\\end{codebox}\n\nBoth of this implementation have the same asymptotic complexity of $O(lgn)$, however the iterative implementation is usually faster.\n\n\\section{Orderings}\n\nIn \\textit{order} to better understand binary search we need to first understand what \\textit{sorted} means. We say thing are sorted when they follow an \\textit{order}, but this inevitably arises the question, what is order?\n\nIn mathematics order is a binary relationship that exists in a set of elements. We will usually refer to this relationship with the symbol $\\leq$. In order for a relationship to be considered an order it must follow some conditions, the most important being:\n\n\\begin{itemize}\n\t\\item \\textbf{Antisymmetry:} $a \\leq b \\land b \\leq a \\rightarrow a = b$\n\t\\item \\textbf{Transitivity:} $a \\leq b \\land b \\leq c \\rightarrow a \\leq c$\n\\end{itemize}\n\nUnder this definition of $order$ we can define as array as sorted if:\n\n$$\\forall i, j \\leq n (i < j \\rightarrow A_i \\leq A_j)$$\n\nThe most important thing of this is to remember that $\\leq$ can represent any relationship that satisfies the condition described above. For example, $a \\leq b$ can mean $a$ is smaller than $b$, $a$ is greater than $b$, $|a|$ is grater than $|b|$, etc...\n\n\\subsection{Types of order}\n\nThere are two types of order: total order and partial order. The only difference between this is that total order maintains \\textit{connexity}, that is to say that the given a pair of elements $a$ and $b$, there must exist a relationship between them (either $a \\leq b$ or $b \\leq a$). In practice, this means that in a partial order, some pairs of elements don't have a defined order between them. \n\nFor example, lets say that we define $a \\leq b$ as $a$ is an ancestor of $b$. How would I compare with my cousin? We can't either say that I am my cousins ancestor or that my cousin is my ancestor, so how we should compare is not defined. \n\nWhen we define an order, it is really important that we make sure this order is total, as partial ordering might lead to undefined behaviour. From here forward when we talk about order we will be referring to total orders, as with partial ordering some complications arise in the algorithms and theory we are going to explore.\n\n\\subsection{Order in a Computer}\n\nIn the context of computer science, we can think of the relationship $a \\leq b$, as a 2-parameter boolean function $\\proc{comp}(a, b)$, that returns \\texttt{true} if the relation $a \\leq b$ exists and \\texttt{false} otherwise. This function is called the \\textit{comparator} and it fully defines the order of the array. In order to ensure the correctness of our algorithms, we must be sure that our comparator obeys the same restrictions the order relationship $\\leq$ did.\n\n\n\\end{document}\n", "meta": {"hexsha": "15f163b2a5b9212c132596a1daf7f07689585433", "size": 7903, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2020-I/Lessons/9/binary-search.tex", "max_stars_repo_name": "CP-UTEC/theory", "max_stars_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-04-15T05:34:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-03T03:51:55.000Z", "max_issues_repo_path": "2020-I/Lessons/9/binary-search.tex", "max_issues_repo_name": "CP-UTEC/theory", "max_issues_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2020-I/Lessons/9/binary-search.tex", "max_forks_repo_name": "CP-UTEC/theory", "max_forks_repo_head_hexsha": "bd24c10d074ae7c25104460ba164d96d66efa502", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.268115942, "max_line_length": 510, "alphanum_fraction": 0.7361761356, "num_tokens": 2168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.8198933425148214, "lm_q1q2_score": 0.4355350287106128}}
{"text": "%!TEX root = /Users/stevenmartell/Documents/CURRENT PROJECTS/iSCAM-trunk/fba/BC-herring-2011/WRITEUP/BCHerring2011.tex\n\\section{Technical description of \\iscam}\\label{appiSCAM}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\n%%      Move to appendix  \n\t\\subsection{Analytic methods}\n\tThe section contains the documentation in mathematical form of the underlying age structured model, and its steady state version that is used to calculate MSY-based reference points, the observation models used in predicting observations, and the components of the objective function that formulate the statistical criterion that is used to estimate model parameters. All of the model equations are laid out in tables and are intended to represent the order of operations, or pseudocode, in which to implement the model. \\iscam was implemented in AD Model Builder version 10.1 \\citep{ADMB2009}.  This appendix also describes some of the optional features in \\iscam\\ for estimating nonparametric selectivities.  \n\t\n\tIt should be noted here that MSY-based reference points assume steady-state conditions, and the model structure that is implemented for the BC herring stocks is non-stationary due to time-varying changes in natural mortality rates ($M_t$) and selectivity.  Estimates of MSY are conditional on the estimates of $M$, selectivity and mean weight-at-age; all of which change over time in the herring assessments.  In the calculations of reference points, we use the average natural mortality between 1951-2010 and estimated selectivities and the empirical weight-at-age data in 2011.\n\n\\subsection{Equilibrium considerations}\n\nSteady-state conditions are presented in Table \\ref{Table2}, in here we assume the parameter vector $\\Theta$ in \\eqref{T2.1} is unknown (with the exception of $F_e$) and would eventually be estimated by fitting \\iscam\\ to time series data. The definition of $F_e$ is the steady-state fishing mortality rate, and the value of $F_e$ that maximizes equilibrium yield corresponds to \\fmsy\\ (see section \\ref{sec:Finding_MSY}).   For a given set of growth parameters (or if available empirical weight-at-age data) and maturity-at-age parameters defined by \\eqref{T2.3}, growth is assumed to follow the von Bertalanffy model \\eqref{T2.4}, mean weight-at-age is given by the allometric relationship in \\eqref{T2.5}, and the age-specific vulnerability is given by a logistic function \\eqref{T2.6}.  Note, however, there are alternative selectivity functions implemented in \\iscam, the logistic function used here is simply for demonstration purposes.  Mean fecundity-at-age is assumed to be proportional to the mean weight-at-age of mature fish, where maturity at age is specified by the parameters $\\dot{a}$ and $\\dot{\\gamma}$ for the logistic function.\n\n \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{table}[!tbp]\n  %\\centering\n\\caption{Steady-state age-structured model assuming unequal\nvulnerability-at-age, age-specific natural mortality, age-specific\nfecundity and Beverton-Holt type recruitment.  Note that $M$ is the average natural mortality rate between 1951-2011.}\\label{Table2} \n\\tableEq\n    \\begin{gather}\n           \\hline\n        \\mbox{Parameters} \\nonumber \\\\\n            \\Theta = (B_o,\\kappa,M,\\hat{a},\\hat{\\gamma},F_e) \\label{T2.1}\\\\\n            B_o>0; \\kappa > 1; M > 0; F_e \\ge 0 \\nonumber\\\\\n            \\Phi = (l_\\infty, k, t_o,a,b,\\dot{a},\\dot{\\gamma}) \\label{T2.3}\\\\[1ex]\n        %%\n        %%\n        \\mbox{Age-schedule information} \\nonumber\\\\\n            l_a=l_\\infty(1-\\exp(-k(a-t_o)))\\label{T2.4}\\\\\n            w_a=a(l_a)^b \\label{T2.5}\\\\\n            v_a=(1+\\exp(-(\\hat{a}-a)/\\gamma))^{-1} \\label{T2.6}\\\\\n            f_a=w_a(1+\\exp(-(\\dot{a}-a)/\\dot{\\gamma}))^{-1} \\label{T2.7}\\\\[1ex]\n        %%\n        %%\n        \\mbox{Survivorship} \\nonumber\\\\\n            \\iota_a=\\begin{cases} 1, \\quad a=1      \\label{T2.8} \\\\\n            \\iota_{a-1}e^{-M},\\quad a>1\\\\\n            \\iota_{a-1}/(1-e^{-M}),\\quad a=A \\end{cases}\\\\\n            \\hat{\\iota}_a=\\begin{cases} 1, \\quad a=1\\\\\n            \\hat{\\iota}_{a-1}e^{-M-F_e v_{a-1}},\\quad a>1\\\\\n            \\hat{\\iota}_{a-1}e^{-M-F_e v_{a-1}}/(1-e^{-M-F_e v_{a}}),\\quad a=A\n            \\end{cases} \\label{T2.9}\\\\[1ex]\n        %%\n        %%\n        \\mbox{Incidence functions} \\nonumber \\\\\n            \\phi_E=\\sum_{a=1}^\\infty \\iota_a f_a, \\quad\n            \\phi_e=\\sum_{a=1}^\\infty \\hat{\\iota}_a f_a \\label{T2.10}\\\\\n            \\phi_B=\\sum_{a=1}^\\infty \\iota_a w_a v_a, \\quad\n            \\phi_b=\\sum_{a=1}^\\infty \\hat{\\iota}_a w_a v_a \\label{T2.11}\\\\\n            \\phi_q=\\sum_{a=1}^\\infty\n                \\frac{ \\hat{\\iota}_a w_a v_a}{M+F_ev_a}\n                \\left(1-e^{(-M-F_ev_a)}\\right) \\label{T2.11b} \\\\[1ex]\n        %%\n        %%\n        \\mbox{Steady-state conditions} \\nonumber \\\\\n        R_o=B_o/ \\phi_B \\label{T2.12}\\\\\n        R_e=R_o\\frac{\\kappa-\\phi_E/\\phi_e}{\\kappa-1} \\label{T2.13}\\\\\n        %%C_e=R_e \\phi_b \\frac{F_e}{Z_e}(1-\\exp(-Z_e))\\label{T2.14} \\B \\\\\n        C_e=F_e R_e \\phi_q\\label{T2.14} \\\\[1ex]\n        \\hline \\hline \\nonumber\n    \\end{gather}\n    \\normalEq\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nSurvivorship for unfished and fished populations is defined by \\eqref{T2.8} and \\eqref{T2.9}, respectively.  It is assumed that all individuals ages $A$ and older (i.e., the plus group) have the same total mortality rate.  The incidence functions refer to the life-time or per-recruit quantities such as spawning biomass per recruit ($\\phi_E$) or vulnerable biomass per recruit ($\\phi_b$).  Note that upper and lower case subscripts denote unfished and fished conditions, respectively.  Spawning biomass per recruit is given by \\eqref{T2.10}, the vulnerable biomass per recruit is given by \\eqref{T2.11} and the per recruit yield to the fishery is given by \\eqref{T2.11b}.  Unfished recruitment is given by \\eqref{T2.12} and the steady-state equilibrium recruitment  for a given fishing mortality rate $F_e$ is given by \\eqref{T2.13}.  Note that in \\eqref{T2.13} we assume that recruitment follows a Beverton-Holt model of the form:\n\\[\nR_e=\\frac{s_o R_e \\phi_e}{1+\\beta R_e \\phi_e}\n\\]\nwhere\n\\[\ns_o = \\kappa/\\phi_E,\n\\]\n\\[\n\\beta = \\frac{(\\kappa-1)}{R_o\\phi_E},\n\\]\nwhich simplifies to \\eqref{T2.13}.\nThe equilibrium yield for a given fishing mortality rate is \\eqref{T2.14}.  These steady-state conditions are critical for determining various reference points such as \\fmsy\\ and \\bmsy. The description of calculating steady-state yield for a given value of $F_e$ in Table \\ref{Table2} is written assuming that only one fishing fleet exists.  The actual calculations are slightly more complicated for the BC herring fishery, as there are three distinct fishing fleets that each have different selectivities.  The actual selectivities and calculations of survivorship involve a matrix of age-specific fishing mortalities, where each row of this matrix corresponds to one fishing fleet.  In this case $F_e$ is the total fishing mortality rate for fully selected fish summed over all fleets.  In order to calculate the fleet specific fishing mortality rate, a fixed allocation of the total yield must be specified \\textit{a priori}.\n\t\n\\subsection{MSY based reference points}\\label{sec:Finding_MSY}\n\\iscam\\ calculates MSY-based reference points by finding the value of $F_e$ that results in the zero derivative of the steady-state catch equation \\eqref{T2.14}.  This is accomplished numerically using a Newton-Raphson method where an initial guess for \\fmsy\\ is set equal to 1.5$M$, then use \\eqref{eq1.1} to iteratively find \\fmsy.  Note that the partial derivatives in \\eqref{eq1.1} can be found in Table \\ref{Table3}.\n\n\\begin{align}\\label{eq1.1}\n    F_{e+1}&=F_e - \n    \\dfrac{ \\dfrac{\\partial C_e}{\\partial F_e}}\n    { \\dfrac{\\partial^2 C_e}{\\partial F_e}}\\\\\n    \\mbox{where}\\nonumber\\\\\n     \\frac{\\partial C_e}{\\partial F_e} &=\n    R_e \\phi_q\n    + F_e \\phi_q \\dfrac{\\partial R_e}{\\partial F_e}\n    + F_e R_e \\dfrac{\\partial \\phi_q}{\\partial F_e} \\nonumber\\\\\n    \\frac{\\partial^2 C_e}{\\partial F_e} &=\n    \\phi_q \\dfrac{\\partial R_e}{\\partial F_e}\n   +  R_e \\dfrac{\\partial \\phi_q}{\\partial F_e}\\nonumber\n%    \\frac{R_e \\phi_q\n%    + F_e \\phi_q \\dfrac{\\partial R_e}{\\partial F_e}\n%    + F_e R_e \\dfrac{\\partial \\phi_q}{\\partial F_e}}\n%    {\\phi_q \\dfrac{\\partial R_e}{\\partial F_e}\n%    +  R_e \\dfrac{\\partial \\phi_q}{\\partial F_e}}.\n\\end{align}\n\nThe algorithm usually converges in less than 10 iterations depending on how close the initial guess of \\fmsy\\ is to the true value.  A maximum of 20 iterations are allowed in \\iscam, however, if $\\frac{\\partial C_e}{\\partial F_e}<10^{-5}$ the algorithm stops.  Note also, that this is only performed on data type variables and not differentiable variables within AD Model Builder.\n\nGiven an estimate of \\fmsy, other reference points such as MSY are calculated use the equations in Table \\ref{Table2} where each of the expressions is evaluated at \\fmsy.  A graphical representation of MSY based reference points for two alternative values of the recruitment compensation parameter $\\kappa$ is show in Figure \\ref{FigMSY}.\n\n\\begin{figure}[!tbp]\n  % Requires \\usepackage{graphicx}\n  \\centering\n  \\includegraphics[width=0.5\\columnwidth]{../Figs/Fig1Quadplot.pdf}\\\\\n  \\caption{Equilibrium yield (a), recruits (b), biomass (c) and\nspawner per recruit ($\\phi_e/\\phi_E$) (d) versus instantaneous\nfishing mortality $F_e$ for two different values of the recruitment\ncompensation ratio ($\\kappa=12$ solid lines, $\\kappa=4$ dashed\nlines). Vertical lines in each panel correspond to \\fmsy\\ and\nhorizontal lines correspond to various reference points that would\nachieve MSY.}\\label{FigMSY}\n\\end{figure}\n\n%% Add bit here about how reference points are calculated when there\n%% are multiple gears with different selectivities.  Also how this is\n%% done when using empirical body weight data.\n\nThere are some additional technical details about calculating MSY based reference points when considering multiple fishing gears with different selectivities.  The maximum sustainable yield summed over all fishing gears is a function of the selectivities of each gear type and what fraction of the total catch is allocated to each gear.  In the Pacific herring fishery, there are three distinct fleets that all have different selectivities; the purse-seine gears tend to catch smaller younger fish, while the gill net fishery tends to target larger mature females.  The optimum fishing mortality rate for each gear that would maximize the yield depends on what the other gears are removing; this in itself is another optimization problem that fisheries management must contend with.  For the purposes of this assessment, \\iscam\\ requires an allocation of the total catch (summed across gear type) to each gear before it proceeds with calculating reference points.\n\nFor this herring assessment, the average catch over the past 20 years used to determine the allocation scheme for each of the stock assessment regions.  For the Strait of Georgia this corresponds to 6.9\\% for the winter seine fishery, 41.4\\% for the seine roe fishery, and 51.8\\% for the gill net fishery.  We further assume that 100\\% of the total mortality takes place prior to spawning, and the start of each biological year is the month of April.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{table}\n  \\centering\n\\caption{Partial derivatives, based on components in Table\n\\ref{Table2}, required for the numerical calculation of \\fmsy\\ using \\eqref{eq1.1}.}\\label{Table3} \\tableEq\n    \\begin{gather}\n        \\hline\n        \\mbox{Mortality \\& Survival} \\nonumber \\\\\n        Z_{a}=M+F_ev_a \\label{T3.1} \\\\\n        S_{a}=1-e^{-Z_a}\\label{T3.2}\\\\[1ex]\n        %%\n        %%\n        \\mbox{Partial for survivorship} \\nonumber \\\\\n        \\frac{\\partial \\hat{\\iota}_a}{\\partial F_e} =\n        \\begin{cases}\n          0,& a=1 \\label{T3.3}\\\\\n          e^{-Z_{a-1}}\\left(\\dfrac{\\partial \\hat{\\iota}_{a-1}}{\\partial F_e}\n           -\\hat{\\iota}_{a-1}v_{a-1}\\right),& 1<a<A\\\\\n           \\dfrac{\\dfrac{\\partial \\hat{\\iota}_{a-1}}{\\partial F_e}}\n           {(1-e^{-Z_a})} -\n           \\dfrac{\\hat{\\iota}_{a-1} e^{-Z_{a-1}} v_a e^{-Z_a}}\n           {(1-e^{-Z_a})^2}, &a=A\n        \\end{cases} \\\\[1ex]\n        %%\n        %%\n        \\mbox{Partials for incidence functions} \\nonumber \\\\\n        \\frac{\\partial \\phi_e}{\\partial F_e}=\n            \\sum_{a=1}^\\infty f_a \\frac{\\partial \\hat{\\iota}_a}{\\partial F_e} \\label{T3.4}\\\\\n        %%\n        %%\n        \\frac{\\partial \\phi_q}{\\partial F_e}=\n            \\sum_{a=1}^\\infty \\frac{w_av_a S_a}{Z_a}\n             \\frac{\\partial \\hat{\\iota}_a}{\\partial F_e}\n             +\\frac{\\hat{\\iota}_a w_av_a^2}{Z_a}\\left(e^{-Z_a}-\\frac{S_a}{Z_a} \\right) \\label{T3.5}\\\\[1ex]\n        %%\n        %%\n        \\mbox{Partial for recruitment} \\nonumber\\\\\n        \\frac{\\partial R_e}{\\partial F_e}=\\frac{R_o}{\\kappa-1}\n        \\frac{\\phi_E}{\\phi_e^2} \\frac{\\partial \\phi_e}{\\partial\n        F_e} \\label{T3.6}\\\\[1ex]\n        \\hline \\hline \\nonumber\n    \\end{gather}\n\n    \\normalEq\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\t\n\t\t\n\t\t\\subsection{Dynamic age-structured model}\n\nThe estimated parameter vector in \\iscam\\ is defined in \\eqref{T4.1}, where $R_0, \\kappa$ and $M$ are the leading unknown population parameters that define the overall population scale in the form of unfished recruitment and productivity in the form of recruitment compensation and natural mortality.  The total variance $\\vartheta^2$ and the proportion of the total variance that is associated with observation errors $\\rho$ are also estimated, then the variance is partitioned into observation errors ($\\sigma^2$) and process errors ($\\tau^2$) using \\eqref{T4.2}.\n\nThe unobserved state variables \\eqref{T4.3} include the numbers-at-age year year $t$ ($N_{t,a}$), the spawning stock biomass ($B_t$) and the total age-specific total mortality rate ($Z_{t,a}$).\n\nThe initial numbers-at-age in the first year \\eqref{T4.4} and the annual recruits \\eqref{T4.5} are treated as estimated parameters and used to initialize the numbers-at-age matrix.  Age-specific selectivity for gear type $k$ is a function of the selectivity parameters $\\gamma_k$ \\eqref{T4.6}, and the annual fishing mortality for each gear $k$ in year $t$ ($\\digamma_{k,t}$).  The vector of log fishing mortality rate parameters $\\digamma_{k,t}$ is a bounded vector with a minimum value of -30 and an upper bound of 3.0.  In arithmetic space this corresponds to a minimum value of 9.36e-14 and a maximum value of 20.01 for annual fishing mortality rates.  In years where there are 0 reported catches for a given fleet, no corresponding fishing mortality rate parameter is estimated and the implicit assumption is there was no fishery in that year.\n\nThere is an option to treat natural mortality as a random walk process \\eqref{T4.6b}, where the natural mortality rate in the first year is the estimated leading parameter \\eqref{T4.1} and in subsequent years the mortality rate deviates from the previous year based on the estimated deviation parameter $\\varphi_t$.  If the mortality deviation parameters are not estimated, then $M$ is assumed to be time invariant. \n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{table}[!tpb]\n  \\centering\n\\caption{Statistical catch-age model using the Baranov catch\nequation, where $R_0$ and $\\kappa$ are the leading parameters that define population scale and productivity, respectively.}\\label{Table4}\n\\tableEq\n    \\begin{align}\n        \\hline \\nonumber \\\\\n        &\\mbox{Estimated parameters} \\nonumber\\\\\n        \\begin{split}\n        \\Theta&= \n        \t\t\\left(R_0,\\kappa,M,\\bar{R},\\ddot{R},\\rho,\\vartheta,\n\t\t\\vec{\\gamma}_{k}\n\t\t\t\t,\\digamma_{k,t}, %\\delta_{k,t},\n\t\t \\{\\ddot{\\omega}_a\\}_{a=\\acute{a}+1}^{a=A},\n\t\t \\{\\omega_t\\}_{t=1}^{t=T},\n        \t\t\\{\\varphi_t \\}_{t=2}^T\\right)\n\t\\end{split} \\label{T4.1}\\\\\n        \\sigma&=\\rho /\\vartheta, \\quad\n        \\tau=(1-\\rho)/\\vartheta\\label{T4.2}\\\\[1ex]\n        %\\vartheta^2=\\sigma^2+\\tau^2, \\quad\n        %\\rho=\\frac{\\sigma^2}{\\sigma^2+\\tau^2}\\label{T4.3}\\\\[1ex]\n        %%\n        %%\n        &\\mbox{Unobserved states} \\nonumber\\\\\n        &N_{t,a},B_t,Z_{t,a}\t\\label{T4.3}\\\\\n\t%%\n\t%%\t        \n        &\\mbox{Initial states ($t=\\acute{t}$)} \\nonumber\\\\\n        %v_a=\\left[1+e^{-(\\hat{a}-a)/\\hat{\\gamma}}\\right]^{-1}\\label{T4.7}\\\\\n        N_{t,a}&=\\ddot{R}e^{\\ddot{\\omega}_{a}} \\exp(-M_t)^{(a-\\acute{a})};\n        \t\\quad t=\\acute{t};  \\acute{a}\\leq a\\leq A \\label{T4.4}\\\\\n        N_{t,a}&=\\bar{R}e^{\\omega_{t}} ;\\quad \\acute{t}\\leq t\\leq T;  \n        \ta=\\acute{a} \\label{T4.5}\\\\\n        v_{k,a}&=f(\\vec{\\gamma}_k) \\label{T4.6}\\\\\n        M_t &= M_{t-1} \\exp(\\varphi_t), \\quad t>1, \\varphi_t \\sim N(0,\\sigma_M) \\label{T4.6b}\\\\\n        F_{k,t}&= \\exp(\\digamma_{k,t}) \\label{T4.7}\\\\[1ex]\n        %%F_{k,t}&=\\bar{F}_k \\exp(\\delta_{k,t}) \\label{T4.7}\\\\[1ex]\n        %%\n        %%\n        &\\mbox{State dynamics ($t>\\acute{t}$)} \\nonumber\\\\\n        B_t&=\\sum_a N_{t,a}f_a \\label{T4.8}\\\\\n        Z_{t,a}&=M_t+\\sum_k F_{k,t} v_{k,t,a}\\label{T4.9}\\\\\n        \\hat{C}_{k,t}&=\\sum _ a\\frac {N_{{t,a}}w_{{a}}F_{k,t} v_{{k,t,a}}\n        \\left( 1-{e^{-Z_{t,a}}} \\right) }{Z_{t,a}} e^{\\eta_t} \\label{T4.10}\\\\\n        %F_{t_{i+1}}= \\ F_{t_{i}} -\\frac{\\hat{C}_t-C_t}{\\hat{C}_t'} \\label{T4.12}\\\\\n        N_{t,a}&=\\begin{cases}\n            %\\dfrac{s_oE_{t-1}}{1+\\beta E_{t-1}} \\exp(\\omega_t-0.5\\tau^2) &a=1\\\\ \\\\\n            N_{t-1,a-1} \\exp(-Z_{t-1,a-1}) &a>\\acute{a}\\\\\n            N_{t-1,a} \\exp(-Z_{t-1,a}) & a=A\n        \\end{cases}\\label{T4.11}\\\\[1ex]\n        %%\n        %%\n        &\\mbox{Recruitment models} \\nonumber\\\\\n        R_t &= \\frac{s_oB_{t-k}}{1+\\beta B_{t-k}}e^{\\delta_{t}-0.5\\tau^2}\\label{T4.12}\n        \t\\quad \\mbox{Beverton-Holt}  \\\\\n        R_t &= s_oB_{t-k}e^{-\\beta B_{t-k}+\\delta_t-0.5\\tau^2}\\label{T4.13}\n        \t\\quad \\mbox{Ricker} \\\\\n\t%%        \\mbox{Residuals \\& predicted observations} \\nonumber\\\\\n\t%%        \\epsilon_t=\\ln\\left(\\frac{I_t}{B_t}\\right)-\\frac{1}{n}\\sum_{t \\in I_t}\\ln\\left(\\frac{I_t}{B_t}\\right)\\label{T4.15}\\\\\n\t%%        \\hat{A}_{t,a}=\\dfrac{N_{t,a}\\dfrac{F_tv_a}{Z_{t,a}}\\left(1-e^{-Z_{t,a}}\\right)}\n\t%%        {\\sum_a N_{t,a}\\dfrac{F_tv_a}{Z_{t,a}}\\left(1-e^{-Z_{t,a}}\\right)}\\label{T4.16}\\\\\n        \\hline \\hline \\nonumber\n    \\end{align}\n\n    \\normalEq\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%% Make into a longtable.\n\\begin{table}[htdp]\n\\caption{An incomplete list of symbols, constants and description for variables used in \\iscam.}\\label{TableSymbols}\n\\begin{center}\n\\begin{tabular}{lcl}\n\\hline\nSymbol & Constant value & Description\\\\\n\\hline\n\\multicolumn{3}{l}{\\underline{Indexes}}\\\\\na & & index for age\\\\\nt & & index for year\\\\\nk & & index for gear\\\\\n\\multicolumn{3}{l}{\\underline{Model dimensions}}\\\\\n$\\acute{a}, A$ & 2, 10& youngest and oldest age class ($A$ is a plus group)\\\\\n$\\acute{t}, T$ & 1951, 2010 & first and last year of catch data\\\\\n$K$ & 5 & Number of gears including survey gears\\\\\n\\multicolumn{3}{l}{\\underline{Observations (data)}}\\\\\n$C_{k,t}$ & & catch in weight by gear $k$ in year $t$\\\\\n$I_{k,t}$ & & relative abundance index for gear $k$ in year $t$\\\\\n$p_{k,t,a}$& & observed proportion-at-age $a$ in year $t$ for gear $k$\\\\\n\\multicolumn{3}{l}{\\underline{Estimated parameters}}\\\\\n$R_o$ & & Age-$\\acute{a}$ recruits in unfished conditions\\\\\n$\\kappa$ & & recruitment compensation\\\\\n$M$ & & instantaneous natural mortality rate \\\\\n$\\bar{R}$ & & average age-$\\acute{a}$ recruitment from year $\\acute{t}$ to $T$\\\\\n$\\ddot{R}$ & & average age-$\\acute{a}$ recruitment in year $\\acute{t}-1$\\\\\n$\\rho$ & & fraction of the total variance associated with observation error\\\\\n$\\vartheta$ & & total precision (inverse of variance) of the total error\\\\\n$\\vec{\\gamma}_k$ & & vector of selectivity parameters for gear $k$\\\\\n$\\digamma_{k,t}$ & & logarithm of the instantaneous fishing mortality for gear $k$ in year $t$\\\\\n$\\ddot{\\omega}_a$&& age-$\\acute{a}$ deviates from $\\ddot{R}$ for year $\\acute{t}$\\\\\n$\\omega_t$&& age-$\\acute{a}$ deviates from $\\bar{R}$ for years $\\acute{t}$ to $T$\\\\\n$\\varphi_t$&& logarithm of annual change in natural mortality rate\\\\\n\\multicolumn{3}{l}{\\underline{Standard deviations}}\\\\\n$\\sigma_M$ &0.1& standard deviation in random walk for natural mortality\\\\\n$\\sigma$ && standard deviation for observation errors in survey index\\\\\n$\\tau$ && standard deviation in process errors (recruitment deviations)\\\\\n$\\sigma_C$& 0.0707 & standard deviation in observed catch by gear\\\\\n\\multicolumn{3}{l}{\\underline{Residuals}}\\\\\n$\\delta_t$ && annual recruitment residual\\\\\n$\\eta_t$ && residual error in predicted catch\\\\\n\\hline \\hline\n\\end{tabular}\n\\end{center}\n\\end{table}%\n\n\nState variables in each year are updated using equations \\ref{T4.8}--\\ref{T4.11}, where the spawning biomass is the product of the numbers-at-age and the mature biomass-at-age \\eqref{T4.8}.  The total mortality rate is given by \\eqref{T4.9}, and the total catch (in weight) for each gear is given by \\eqref{T4.10} assuming that both natural and fishing mortality occur simultaneously throughout the year.  The numbers-at-age are propagated over time using \\eqref{T4.11}, where members of the plus group (age $A$) are all assumed to have the same total mortality rate.  \n\nRecruitment to age $k$ can follow either a Beverton-Holt model \\eqref{T4.12} or a Ricker model \\eqref{T4.13} where the maximum juvenile survival rate ($s_o$) in either case is defined by $s_o=\\kappa/\\phi_E$.  For the Beverton-Holt model, $\\beta$ is derived by solving \\eqref{T4.12} for $\\beta$ conditional on estimates of $\\kappa$ and $R_o$:\n\\[\n\\beta = \\frac{\\kappa-1}{R_o \\phi_E},\n\\]\nand for the Ricker model this is given by:\n\\[\n\\beta = \\frac{\\ln(\\kappa)}{R_o \\phi_E}\n\\]\n\n\n\t\t\n\\subsection{Options for selectivity}\\label{Appendix:SelectivityOptions}\n\t\t\nAt present, there are eight alternative age-specific selectivity options in \\iscam.  The simplest of the selectivity options is a simple logistic function with two parameters where it is assumed that selectivity is time-invariant.  The more complex selectivity options assume that selectivity may vary over time a may have as many as (A-1)$\\cdot$T parameters.  For time-varying selectivity, cubic and bicubic splines are used to reduce the number of estimated parameters. The last two options consider how selectivity may vary over time based on changes in mean weight-at-age. Prior to parameter estimation, \\iscam\\ will determine the exact number of selectivity parameters that need to be estimated based on which selectivity option was chosen for each gear type.  It is not necessary for all gear types to have the same selectivity option.  For example it is possible to have a simple two parameter selectivity curve for say a survey gear, and a much more complicated selectivity option for a commercial fishery.\n\n\\paragraph{Logistic selectivity} \nThe logistic selectivity option is a two parameter model of the form\n\\[\nv_a = \\frac{1}{1+ \\exp{(-(a-\\mu_{a})/\\sigma_a)}}\n\\]\nwhere $\\mu_a$ and $\\sigma_a$ are the two estimated parameters representing the age-at-50\\% vulnerability and the standard deviation, respectively.\n\n\\paragraph{Age-specific selectivity coefficients}\nThe second option also assumes that selectivity is time-invariant and estimates at total of $A$-1 selectivity coefficients, where the plus group age-class is assumed to have the same selectivity as the previous age-class.  For example, if the ages in the model range from 1 to 15 years, then a total of 14 selectivity parameters are estimated, and age-15+ animals will have the same selectivity as age-14 animals.\n\nWhen estimating age-specific selectivity coefficients, there are two additional penalties that are added to the objective function that control how much curvature there is and limit how much dome-shaped can occur.  To penalize the curvature, the square of the second differences of the vulnerabilities-at-age are added to the objective function: \n\\begin{equation}\\label{eq2ndDiff}\n\\lambda_k^{(1)} \\sum_{a=2}^{A-1}(v_{k,a} - 2v_{k,a-1} + v_{k,a-2})^2\n\\end{equation}\nThe dome-shaped term penalty as:\n\\begin{equation}\\label{eqDomePenalty}\n\\begin{cases}\n\\lambda_k^{(2)} \\sum_{a=1}^{A-1}(v_{k,a} - v_{k,a+1})^2& \\mbox(if) v_{k,a+1}< v_{k,a}\\\\\n0 & \\mbox(if) v_{k,a+1}\\geq v_{k,a}\n\\end{cases}\n\\end{equation}\nFor this selectivity option the user must specify the relative weights ($\\lambda_k^{(1)},\\lambda_k^{(2)}$) to add to these two penalties.\n\n\\paragraph{Cubic spline interpolation}\nThe third option also assumes time-invariant selectivity and estimates a selectivity coefficients for a series age-nodes (or spline points) and uses a natural cubic spline to interpolate between these nodes (Figure \\ref{Fig2}). Given $n+1$ distinct knots $x_i$, selectivity can be interpolated in the intervals defined by\n\\[\nS(x) = \\begin{cases}\n\tS_0(x) & x \\in [x_0,x_1]\\\\\n\tS_1(x) & x \\in [x_1,x_2]\\\\\n\t...\\\\\n\tS_{n-1}(x) & x \\in [x_{n-1},x_n]\n\\end{cases}\n\\]\nwhere  $S''(x_0) = S''(x_n)=0$  is the condition that defines a natural cubic spline.\n\\begin{figure}\n\t\\centering\n\t% Requires \\usepackage{graphicx}\n\t\\includegraphics[width=0.4\\columnwidth]{../Figs/SplineEg.pdf}\\\\\n\t\\caption{Example of a natural cubic spline interpolation for 15-selectivity coefficients based on estimating 6 nodes (true selectivity was based on a logistic function).  In \\iscam\\ the user specifies the number of nodes (e.g., 6 circles) to estimate; then the 15 age-specific selectivity coefficients are interpolated using a natural cubic spline.}\\label{Fig2}\n\\end{figure}\n\nThe same penalty functions for curvature and dome-shaped selectivity are also invoked for the cubic spline interpolation of selectivity.\n\n\\paragraph{Time-varying selectivity with cubic spline interpolation} A fourth option allows for cubic spline interpolation for age-specific selectivity  in each year.  This option adds a considerable number of estimated parameters but the most extreme flexibility.  For example, given 40 years of data and estimated 5 age nodes, this amounts 200 (40 years times 5 ages) estimated selectivity parameters.  Note that the only constraints at this time are the dome-shaped penalty and the curvature penalty; there is no constraint implemented for say a random walk (first difference) in age-specific selectivity).  As such this option should only be used in cases where age-composition data is available for every year of the assessment.\n\n\\paragraph{Bicubic spline to interpolate over time and ages}  The fifth option allows for a two-dimensional interpolation using a bicubic spline (Figure \\ref{Fig3}).  In this case the user must specify the number of age and year nodes.  Again the same curvature and dome shaped constraints are implemented.  It is not necessary to have age-composition data each and every year as in the previous case, as the bicubic spline will interpolate between years.  However, it is not advisable to extrapolate selectivity back in time or forward in time where there are no age-composition data unless some additional constraint, such as a random-walk in age-specific selectivity coefficients is implemented (as of \\today, this has not been implemented).\n\n\\begin{figure}[!tbp]\n\t% Requires \\usepackage{graphicx}\n\t\\centering\n\t\\includegraphics[width=0.9\\textwidth]{../Figs/BicubicEg.pdf}\\\\\n\t\\caption{Example of a time-varying cubic spline (left) and bicubic spline (right) interpolation for selectivity based on data from the Pacific hake. The panel on the left contains 165 estimated selectivity parameters and the bicubic interpolation estimates 85 selectivity parameters, or 5 age nodes and 17 year nodes. There are 495 actual nodes (selectivity parameters) being interpolated.}\\label{Fig3}\n\\end{figure}\n\n\n\\paragraph{Selectivity as a logistic function of weight-at-age}\n\nThe seventh option for selectivity is to parameterize a logistic function in terms of the weight-at-age in year $t$ ($w_{a,t}$). In this case changes in weight-at-age over time allow for changes in selectivity. Such a weight-based function may be appropriate for size selective gears such as gill nets. \n\\[\nv_{a,t} = \\frac{1}{1+ \\exp{(-(w_{a,t}-\\mu_{a})/\\sigma_a)}}\n\\]\n\n\\paragraph{Using weight as a covariate}\nThe eighth option for selectivity is to use a logistic function based on age, but allow selectivity to vary based on deviations in the mean weight-at-age over time.  In this case:\n\\[\nv_{a,t} = \\frac{1}{1+ \\exp{(-(a-\\mu_{a})/\\sigma_a)}}\\exp(\\lambda^{(a)} \\delta_{a,t})\n\\]\nwhere $\\lambda^{(a)}$ is a latent variable that describes the residual variation in the age-composition data that is due to changes  in selectivity, and $\\delta_{a,t}$ is a standardized ($\\mu=0, \\sigma=1$) annual age-specific deviation in mean weight-at-age.  In this case, estimates of $\\lambda^{(a)}=0$ imply that variation in the empirical weight-at-age data explain none of the residual variation in the age-composition data.  Values  of $\\lambda^{(a)}\\neq0$ imply a positive or negative affect of variation in growth on selectivity.\n\n\n\t\t\\subsection{Options for natural mortality}\n\t\t\nThere is an option in \\iscam\\ to estimate a time series of annual changes in natural mortality rates ($\\varphi_t$).  If not estimated, natural mortality $M$ is assumed to be invariant over time and age.  If, however, $M$ is thought to vary over time, then \\iscam\\ models natural mortality as a random walk process \\eqref{T4.6b}.  In such cases where $M$ is allowed to freely vary over time, the user must specify two additional components in the control file. First, the phase in which the vector of deviations $\\varphi_t$ is estimated must be specified (use a -ve phase to turn off the estimation), and the user must also specify a standard deviation in the rate of change $\\sigma_M$.  If estimated, then an additional component is added to the objective function to constrain the first differences in the deviation parameters.  This first difference constraint only limits how quickly $M$ may increase or decrease over time and does not penalize deviations from an underlying mean.  Thus it is possible for $M$ to drift (increase or decrease) away from some central tendency. This drifting can have profound effects on reference point calculations as it also allows for non-stationarity in the underlying production function.\n\n\n\t\t\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\n\t\t\\subsection{Residuals, likelihoods \\& objective function value components}\\label{secLikelihoods}\n\nThere are 3 major components to the overall objective function that are minimized.  These components consist of the likelihood of the data, prior distributions and penalty functions that are invoked to regularize the solution during intermediate phases of the non-linear parameter estimation.  This section discusses each of these in turn, starting first with the residuals between observed and predicted states followed by the negative loglikelihood that is minimized for the catch data, relative abundance data, age-composition, and stock-recruitment relationships.\n\n\\subsection{Catch data}\nIt is assumed that the measurement errors in the non-zero catch observations are log-normally distributed, and the residuals is given by:\n\\begin{equation}\\label{eq2}\n\\eta_{k,t}=\\ln(C_{k,t}) -  \\ln(\\hat{C}_{k,t}),\n\\end{equation}\nThe residuals are assumed to be normally distributed with a user specified standard deviation $\\sigma_{C}$.  At present, it is assumed that observed catches for each gear $k$ is assumed to have the same standard deviation.  To aid in parameter estimation, two separate standard deviations are specified in the control file: the first is the assumed standard deviation used in the first, second, to N-1 phases, and the second is the assumed standard deviation in the last phase.  The negative loglikelihood (ignoring the scaling constant) for the catch data is given by:\n\\begin{equation}\\label{eq3}\n\\ell_C = \\sum_k\\left[  T_k\\ln(\\sigma_C)+\\dfrac{\\sum_{t \\in \\hat{C}_{k,t}\\neq 0}(\\eta_{k,t})^2}{2\\sigma_C^2}\\right],\n\\end{equation}\nwhere $T_k$ is the total number of non-zero catch observations for gear type $k$.\n\n\n\\subsection{Relative abundance data}\nThe relative abundance data are assumed to be proportional to biomass that is vulnerable to the sampling gear:\n\\begin{equation}\\label{eq4}\n V_{k,t} = \\sum_a N_{t,a} e^{-\\lambda_{k,t} Z_{t,a}} v_{k,a} w_{a,t},\n\\end{equation}\nwhere $v_{k,a}$ is the age-specific selectivity of gear $k$, and $w_a$ is the mean-weight-at-age. A user specified fraction of the total mortality $\\lambda_{k,t}$ adjusts the numbers-at-age to correct for survey timing.  In the case of Pacific herring spawn surveys, the vulnerability is fixed to the assumed maturity ogive and the empirical weight-at-age data are used to construct the predicted relative abundance.  Also, it was assumed that all the mortality (post-fishing) had occurred during the time the survey took place (i.e., $\\lambda_{k,t}=1$).  The residuals between the observed and predicted relative abundance index is given by:\n\\begin{equation}\\label{eq5}\n\\epsilon_{k,t} = \\ln(I_{k,t}) - \\ln(q_k) - \\ln(V_{k,t}),\n\\end{equation}\nwhere $I_{k,t}$ is the observed relative abundance index, $q_k$ is the catchability coefficient for index $k$, and $V_{k,t}$ is the predicted vulnerable biomass at the time of sampling.  The catchability coefficient $q_k$ is evaluated at its conditional maximum likelihood estimate:\n\\[\n  q_k =\\frac{1}{N_k} \\sum_{t \\in I_{k,t}} \\ln(I_{k,t}) - \\ln(V_{k,t}),\n\\]\nwhere $N_k$ is the number of relative abundance observations for index $k$ \\citep[see][for more information]{walters1994calculation}. The negative loglikelihood for relative abundance data is given by:\n\\begin{align}\n\\ell_I &= \\sum_k \\sum_{t \\in I_{k,t}}  \\ln(\\sigma_{k,t})+\\frac{\\epsilon_{k,t}^2}{2\\sigma_{k,t}^2} \\label{eq6}\\\\\n&\\mbox{where}\\nonumber\\\\\n\\sigma_{k,t} &= \\frac{\\rho \\vartheta}{ \\omega_{k,t}},  \\nonumber\n\\end{align}\nwhere $\\rho \\vartheta$ is the proportion of the total error that is associated with observation errors, and $\\omega_{k,t}$ is a user specified relative weight for observation $t$ from gear $k$.  The $ \\omega_{k,t}$ terms allow each observation to be weighted relative to the total error $\\rho \\vartheta$; for example, to omit a particular observation, set $\\omega_{k,t}=0$, or to give 2 times the weight, then set  $\\omega_{k,t}=2.0$. To assume all observations have the same variance then simply set  $\\omega_{k,t}=1$.  Note that if  $\\omega_{k,t}=0$ then equation \\eqref{eq6} is undefined; therefore, \\iscam\\ adds a small constant to  $\\omega_{k,t}$ (1.e-10, which is equivalent to assuming an extremely large variance)  to ensure the likelihood can be evaluated.\n\nIn the case of the Pacific herring assessment, the spawn survey data post-1988 were assumed to be twice as precise as the pre-dive survey data (1951-1987).  To implement this, weights for the 1951-1987 data were set equal to $\\omega_{k,t}=1.0$ and the contemporary data was assigned $\\omega_{k,t}=2.0$.  The standard deviation in the observation errors is conditional on estimated values of $\\rho$ and $\\varphi^2$.\n\n\n%% AGE COMPOSITION\n\\subsection{Age composition data}\\label{agecomps}\nSampling theory suggest that age composition data are derived from a multinomial distribution \\citep{fournier1982general}; however, \\iscam\\ assumes that age-proportions are obtained from a multivariate logistic distribution \\citep{schnute1995influence,richards1997visualizing}.  The main reason \\iscam\\ departs from the traditional multinomial model has to do with how the age-composition data are weighted in the objective function.  First, the multinomial distribution requires the specification of an effective sample size; this may be done arbitrarily or through iterative re-weighting \\citep{MCALLISTER1997,gavaris2002sif}, and in the case of multiple and potentially conflicting age-proportions this procedure may fail to converge properly.  The assumed effective sample size can have a large impact on the overall model results.  \n\nA nice feature of the multivariate logistic distribution is that the age-proportion data can be weighted based on the conditional maximum likelihood estimate of the variance in the age-proportions.  Therefore, the contribution of the age-composition data to the overall objective function is ``self-weighting'' and is conditional on other components in the model.\n\nIgnoring the subscript for gear type for clarity, the observed and predicted proportions-at-age must satisfy the constraint \n\\[\n \\sum_{a=1}^A p_{t,a} = 1\n\\]\nfor each year. The multivariate logistic residuals between the observed ($p_{t,a}$) and predicted proportions ($\\widehat{p_{t,a}}$) is given by:\n\\begin{equation}\\label{eq7}\n\\eta_{t,a}=\\ln(p_{t,a})-\\ln(\\widehat{p_{t,a}})-\\frac{1}{A}\\sum_{a=1}^A\\left[\\ln(p_{t,a})-\\ln(\\widehat{p_{t,a}}) \\right].\n\\end{equation}\nThe conditional maximum likelihood estimate of the variance is given by\n\\[\n\\widehat{\\tau}^2=\\frac{1}{(A-1)T}\\sum_{t=1}^T\\sum_{a=1}^A \\eta_{t,a}^2,\n\\]\nand the negative loglikelihood evaluated at the conditional maximum likelihood estimate of the variance is given by:\n\\begin{equation}\\label{eq8}\n\t\\ell_A = (A-1)T \\ln(\\widehat{\\tau}^2).\n\\end{equation}\nIn short, the multivariate logistic likelihood for age-composition data is just the log of the residual variance weighted by the number observations over years and ages.\n\n%Add technical details about requiring the minimum p_{t,a} to be greater than 2% \"Grouping\".\nThere is also a technical detail in \\eqref{eq7}, where observed and predicted proportions-at-age must be greater than 0.  It is not uncommon in catch-age data sets to observe 0 proportions for older, or young, age classes or weak year classes. In \\iscam\\ the same approach described by \\cite{richards1997visualizing} is adopted where the definition of age-classes is altered to require that $p_{t,a}\\geq \\dot{p}$ for every age in each year, where $\\dot{p}$ is the minimum percentage specified by the user (e.g., $\\dot{p}=0.02$ corresponds to 2\\%).  This is accomplished by grouping consecutive ages, where $p_{t,a} <\\dot{p}$, into a single age-class and reducing the effective number of age-classes in the variance calculation ($\\widehat{\\tau}^2$) by the number of groups created.  The minimum proportion (including 0) is set by the user and can influence the results, especially in cases where there is sparse aging information.  In the case of $\\dot{p}=0$, the pooling of the adjacent age-class still occurs, this ensures that \\eqref{eq7} is defined.\n\nIn the Strait of Georgia herring example, we set the minimum proportion to 2\\% to reduce the influence of the large numbers of 0 proportions in the purse-seine fleets, especially prior to 1970 during the reduction fishery.\n\n\n\\subsection{Stock-recruitment}\nThere are two alternative stock-recruitment models available in \\iscam: the Beverton-Holt model and the Ricker model.  Annual recruitment and the initial age-composition are treated as latent variables in \\iscam, and residuals between estimated recruits and the deterministic stock-recruitment models are used to estimate unfished spawning stock biomass and recruitment compensation.  The residuals between the estimated and predicted recruits is given by\n\\begin{equation}\\label{eq9}\n\t\\delta_t = \\ln(\\bar{R}e^{w_t}) - \\ln(f(B_{t-\\acute{a}}))\n\\end{equation}\nwhere $f(B_{t-k})$ is given by either \\eqref{T4.12} or \\eqref{T4.13}, and $\\acute{a}$ is the age at recruitment.  Note that a bias correction term for the lognormal process  errors is included in  \\eqref{T4.12} and \\eqref{T4.13}.\n\nThe negative log likelihood for the recruitment deviations is given by the normal density (ignoring the scaling constant):\n\\begin{equation}\\label{eq10}\n \\ell_\\delta = n\\ln(\\tau) + \\frac{\\sum_{t=1+k}^T \\delta^2_t}{2\\tau^2}\n\\end{equation}\nEquations \\eqref{eq9} and \\eqref{eq10} are key for estimating unfished spawning stock biomass and recruitment compensation via the recruitment models.  The relationship between ($s_o,\\beta$) and ($B_o,\\kappa$) is defined as:\n\\begin{align}\ns_o &= \\kappa/\\phi_E\\\\\n\\beta&=\\begin{cases}\n\\frac{\\kappa-1}{B_o} \\quad \\mbox{Beverton-Holt}\\\\[1ex]\n\\frac{\\ln(\\kappa)}{B_o} \\quad \\mbox{Ricker}\n\\end{cases}\n\\end{align}\nwhere $s_o$ is the maximum juvenile survival rate, $\\beta$ is the density effect on recruitment, and $B_o$ is the unfished spawning stock biomass. Unfished steady-state spawning stock biomass per recruit is given by $\\phi_E$, which is the sum of products between age-specific survivorship and relative fecundity.  In cases where the natural mortality rate is allowed to vary over time, the calculation of $\\phi_E$, and the corresponding unfished spawning stock biomass ($B_o$) is based on the average natural mortality rate over the entire time period.  This subtle calculation has implications for reference point calculations in cases where there are increasing or decreasing trends in natural mortality rates over time; as estimates of natural mortality rates trend upwards, estimates of $B_o$ decrease. \n\nFor the Strait of Georgia Pacific herring example, only the Beverton-Holt recruitment model was considered.  The description of the Ricker model is included here for the sake of completely documenting the features in the \\iscam\\ platform.\n\n\t\t\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\n\t\\subsection{Parameter Estimation and Uncertainty}\n\t\nParameter estimation and quantifying uncertainty was carried out using the tools available in AD Model Builder \\citep{ADMB2009}.  AD Model Builder (ADMB) is a software for creating computer programs to estimate the parameters and associated probability distributions for nonlinear statistical models.  The software is freely available from \\url{http://admb-project.org/}.  This software was used to develop \\iscam, and the source code and documentation for \\iscam\\ is freely available from \\url{https://sites.google.com/site/iscamproject/}, or from a subversion repository at \\url{http://code.google.com/p/iscam-project/}.  \n\nSuffice it to say that there is a lot more going on in the \\iscam\\ software than just minimizing the sum of the four negative loglikelihood functions defined in the previous section.  There are actually five distinct components that make up the objective function that ADMB is minimizing:\n\\[\nf = \\mbox{negative loglikelihoods}+\\mbox{constraints}+\\mbox{priors for parameters}+\\mbox{survey priors}+\\mbox{convergence penalties}.\n\\]\nThe purpose of this section is to completely document all of the components that make up the objective function.  Such transparency is absolutely necessary to better understand estimation performance, as well as, to ensure the results are repeatable.\n\n\\subsection{Negative loglikelihoods}\n\tThe negative loglikelihoods pertain specifically elements that deal with the data and variance partitioning and have already been described in detail in section \\ref{secLikelihoods}.  There are four specific elements that make up the vector of negative loglikelihoods:\n\\begin{equation}\\label{eq11}\n\t\\vec{\\ell}=\\ell_C, \\ell_I, \\ell_A, \\ell_\\delta.\n\\end{equation}\nTo reiterate, these are the likelihood of the catch data $\\ell_C$, likelihood of the survey data $\\ell_I$, the likelihood of the age-composition data $\\ell_A$ and the likelihood of the stock-recruitment residuals $\\ell_\\delta$.  Each of these elements are expressed in negative log-space, and ADMB attempts to estimate model parameters by minimizing the sum of these elements.\n\n\\subsection{Constraints}\nThere are two specific constraints that are described here: 1) parameter bounds, and 2) constraints to ensure that a parameter vector sums to 0.  In \\iscam\\ the user must specify the lower and upper bounds for the leading parameters defined in the control file ($\\ln(R_o),h,\\ln(M),\\ln(\\bar{R}),\\rho,\\vartheta$).  All estimated selectivity parameters $\\vec{\\gamma}_k$ are estimated in log space and have a minimum and maximum values of -5.0 and 5.0, respectively.  These values are hard-wired into the code, but should be sufficiently large/small enough to capture a wide range of selectivities.  Estimated fishing mortality rates are also constrained (in log space) to have a minimum value of -30, and a maximum value of 3.0. Log annual recruitment deviations are also constrained to have minimum and maximum values of -15.0 and 15.0 and there is an additional constraint to ensure the vector of deviations sums to 0. This is necessary in order to be able to estimate the average recruitment $\\bar{R}$. Finally, the annual log deviations in natural mortality rates are constrained to lie between -2.0 and 2.0.\n\nAn array of selectivity parameters (i.e., \\verb\"init_bounded_matrix_vector\") is estimated within \\iscam\\, where each matrix corresponds to a specific gear type, and the number of rows and columns of each depends on the type of selectivity function assumed for the gear and if that selectivity changes over time.  In cases where the nodes of a spline are estimated these nodes also have an additional constraint to sum to 0.  This is effectively implemented by adding to the objective function: \\[ 1000 \\left(\\frac{1}{N_{\\vec{\\lambda_k}}}\\sum \\vec{\\lambda}_k \\right)^2.\\]  This additional constraint is necessary to ensure the model remains separable and the annual fishing mortality rates are less confounded with selectivity parameters.\n\n\\subsection{Priors for parameters}\n\tEach of the six leading parameters specified in the control file ($\\ln(R_o),h,\\ln(M),\\ln(\\bar{R}),\\rho,\\vartheta$) are declared as bounded parameters and in addition the user can also specify an informative prior distribution for each of these parameters.  Five distinct prior distributions can be implemented: uniform, normal, lognormal, beta and a gamma distribution.  For the Strait of Georgia herring, a bounded uniform prior was specified for  the log of unfished recruitment U(-5.0,15), a vague beta prior was assumed for steepness Beta(1.01,1.01), a normal prior was specified for the log of natural mortality rate \\emph{N}(-1.0966,0.05), a bounded uniform prior for the log of average recruitment U(-5.0,15.0), a beta prior for the variance partitioning parameter $\\rho$ Beta(15,60), and a gamma prior for the precision parameter $\\vartheta$, Gamma(156.25,125.0). These prior distributions based on the parameter specified above are shown in Figure \\ref{FigPriorExample}. \n\t\n\\begin{figure}[!tbp]\n\t\\centering\n\t% Requires \\usepackage{graphicx}\n\t\\includegraphics[width=0.7\\textwidth]{../Figs/priorexample.pdf}\\\\\n\t\\caption{Prior distributions used for $\\ln(R_o),h,\\ln(M),\\ln(\\bar{R}),\\rho,\\vartheta$ in the herring assessment models.}\\label{FigPriorExample}\n\\end{figure}\n\nIn addition to the priors specified for the six leading parameter, there are several other informative distributions that are invoked for the non-parametric selectivity parameters.  In cases were age-specific selectivity coefficients are estimated, or nodes of a spline function are estimated, two additional penalties are added to the objective function to control how smooth the selectivity changes \\eqref{eq2ndDiff} and how much dome-shape is allowed in the nonparametric selectivities \\eqref{eqDomePenalty}.  \n\n\\subsection{Survey priors}\n\nThe scaling parameter $q$ for each of the surveys is not treated as an unknown parameter within the code; rather, the maximum likelihood estimate for $q$ conditional on all other parameters is used to scale the predicted spawning biomass to the observed spawn survey index.  In the case of Pacific herring, the relationship between fecundity and mature female biomass is relatively invariant at about 200 eggs per gram \\citep{hay1985reproductive,hardwick1973biomass}.  This relationship has been used to convert total egg deposition from the spawn survey to total female spawning biomass, and assuming all spawning was accounted for, then a reasonable estimate for $q$ should be 1.0.\n\nIn the Strait of Georgia herring assessment, we specified an informative normal prior on $\\ln(q)$ with a mean of 0, and a a standard deviation of 0.05 for the contemporary data.  For the pre-1988 spawn survey data, we explored three alternative priors including a non-informative prior, and a normal prior with a mean 0 and standard deviations of 0.05, or 0.1.  The informative prior for the contemporary data implies a 95\\% confidence interval of 0.82 to 1.22 for $q$.\n\n\\subsection{Convergence penalties}\n\nFor the Strait of Georgia herring assessment, there are well over 200 estimated parameters, the exact number depends on the model configuration.  Needless to say, non-linear parameter estimation is often very sensitive to the initial starting conditions, and the end results may differ depending on the initial values of the model parameters or even the phase at which parameters are included into the estimation problem.  There is no guarantee that the algorithm will converge to the global minimum every time.  AD Model Builder is unique in that the estimation process can be conducted in a series of phases where more and more parameters are `freed up' as the model progress through each phase.  Furthermore, the actual objective function can change between phases such that during the initial phases large penalties can be used to, as Dave Fournier would say, ``regularize the solution''.  For example, in the initial phases of parameter estimation \\iscam\\ uses fairly steep quadratic penalties for the annual recruitment deviations and average fishing mortality rates to initially aid in finding reasonable values of the average recruitment, natural mortality and selectivity parameters.  In the final phase, these quadratic penalties are relaxed.\n\nIn the case of the annual recruitment deviations, the quadratic penalty term is:\\[ 100 \\sum_{t=1-A}^T \\omega_t^2,\\] which is approximately a normal density with a standard deviation equal to 0.07.  In the last phase this constraint is relaxed with a large standard deviation of 5.0.\n\nA similar penalty (a normal distribution for the log mean fishing rate) is also invoked for the mean fishing mortality rate, but in this case the user specifies the mean fishing mortality rate and the standard deviations in the initial phases and the last phase.  Normally, a rather small standard deviation is used in the initial phases (e.g., 0.01) and this is then relaxed to a much larger value (e.g., 5.0) in the last phase.  These standard deviations are specified by the user in the control file.\n%% ^^^^^ Move to appendix  ^^^^^^^^^\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\n\n\\clearpage\n", "meta": {"hexsha": "d5977a25680b1ebe7607ee3fc8b876fe6559a6fe", "size": 51434, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fba/BC-herring-2011/WRITEUP/APPENDIX_A/Appendix_iSCAMdescription.tex", "max_stars_repo_name": "krHolt/iSCAM", "max_stars_repo_head_hexsha": "b6e1f1b5c3f81e1860a983cbafd18221d365fdb6", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "fba/BC-herring-2011/WRITEUP/APPENDIX_A/Appendix_iSCAMdescription.tex", "max_issues_repo_name": "krHolt/iSCAM", "max_issues_repo_head_hexsha": "b6e1f1b5c3f81e1860a983cbafd18221d365fdb6", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fba/BC-herring-2011/WRITEUP/APPENDIX_A/Appendix_iSCAMdescription.tex", "max_forks_repo_name": "krHolt/iSCAM", "max_forks_repo_head_hexsha": "b6e1f1b5c3f81e1860a983cbafd18221d365fdb6", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 92.1756272401, "max_line_length": 1252, "alphanum_fraction": 0.7123886923, "num_tokens": 13569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833893685269, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.43545257947946014}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\section*{NYU Physics I---spacetime diagrams}\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nDraw a spacetime diagram for your own rest-frame.  On the spacetime\ndiagram, show your own world-line.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nImagine there is a galaxy flying away from you with a velocity $v =\n0.5\\,c$. When the galaxy is moving away, it sends back to you a light\nsignal every $T'=3.3\\,\\ns$ (as recorded in the galaxy's rest frame).\nDraw the world-line of this galaxy on your spacetime diagram and mark\nthe events corresponding to the departures of the signals from the\ngalaxy.  Draw at least five such events.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nDraw all the world-lines for all the the signals.  Mark the events of\nthe signals reaching you.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nCalculate the time intervals between the arrival events (arrivals of\nthe signals from the galaxy) according to you (that is, in your\nframe).  Give your answer in terms of $T'$, $\\beta$, and $\\gamma$.\n\\textsl{Hint:} It should be longer than what is suggested by the\nsimple time-dilation formula.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nWhy do the time intervals in the previous problem \\emph{not} agree\nwith the time-dilation formula?  What, on the spacetime diagram,\n\\emph{does} agree with the time-dilation formula?\n\n\\end{document}\n", "meta": {"hexsha": "b8c55ed95a4c64146455703e1cd2ccd926409187", "size": 1438, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/worksheet_spacetime.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/worksheet_spacetime.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/worksheet_spacetime.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9444444444, "max_line_length": 69, "alphanum_fraction": 0.7726008345, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.4354467088895501}}
{"text": "\\documentclass[a4paper,11pt]{article}%,twocolumn\n\\input{settings/packages}\n\\input{settings/page}\n\\input{settings/jupyter}\n\n\n\n\n\\begin{document}\n\t\\begin{center}\n\t\t{\\large \\textbf{Assignment A02: Alignment}}\\\\\n\t\tThalagala B.P.\\hspace{0.5cm} 180631J \n\t\\end{center}\n\t\\hrule\n\\section{2-D transformations}\nAs shown in the figures (a),(b) and (c) Translation and Rotation  preserves angles, area and the lengths of the 2D object subjected to the transformation. They also known as \\textit{2D Euclidean transformation} due to the preservation of the Euclidean distances under the transformation. The similarity transform(\\textit{Scaled rotation}) only preserves the angles between lines and the Affine transformation only preserves the parallelism of the lines while the Projective transformation distort all the mentioned properties and preserves only the straightness of the lines of the object.\n\n\\begin{figure}[!h]\n\t\\centering\n\t\\subfigure[Translation]\n\t{ \\includegraphics[scale=0.4]{figures/Translation}\n\t\t\n\t}\n\t\\subfigure[Rotation]\n\t{ \\includegraphics[scale=0.4]{figures/Rotation}\n\t\t\n\t}\n\t\\subfigure[Rotation + Translation]\n\t{ \\includegraphics[scale=0.38]{figures/2DEuclidean}\n\t\t\n\t}\n\t\\subfigure[Similarity Transform]\n\t{ \\includegraphics[scale=0.35]{figures/similarity}\n\t\t\n\t}\n\t\\subfigure[Affine]\n\t{ \\includegraphics[scale=0.35]{figures/Affine}\n\t\t\n\t}\n\t\\subfigure[Projective]\n\t{ \\includegraphics[scale=0.35]{figures/Projective}\n\t\t\n\t}\n\t\\caption{2-D transformations \\textit{Note that: Figures are not in the same scale.}}\n\\end{figure}  \nFollowing code snippet consists of all the transformation matrices used to generate the above figures in the given order.\\\\ \t\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{1}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{c+c1}{\\PYZsh{} Translation}\n\\PY{n}{t} \\PY{o}{=} \\PY{l+m+mi}{1} \\PY{c+c1}{\\PYZsh{} translation along each axis}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{,}\\PY{l+m+mi}{0}\\PY{p}{,}\\PY{n}{t}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{,}\\PY{l+m+mi}{1}\\PY{p}{,}\\PY{n}{t}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{,}\\PY{l+m+mi}{0}\\PY{p}{,}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]}\n\\PY{c+c1}{\\PYZsh{} Rotation }\n\\PY{n}{theta} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{pi}\\PY{o}{/}\\PY{l+m+mi}{4} \\PY{c+c1}{\\PYZsh{} Anti clockwise pi/4 rad rotation}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{o}{\\PYZhy{}}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{l+m+mf}{0.}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{l+m+mf}{0.}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{1.}\\PY{p}{]}\\PY{p}{]}\n\\PY{c+c1}{\\PYZsh{} Rotation + translation.(2D Euclidean transformation)}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{o}{\\PYZhy{}}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{t}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{t}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{1.}\\PY{p}{]}\\PY{p}{]}\n\\PY{c+c1}{\\PYZsh{} Scaled rotation (similarity transform)}\n\\PY{n}{s} \\PY{o}{=} \\PY{l+m+mf}{0.5}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n}{s}\\PY{o}{*}\\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{o}{\\PYZhy{}}\\PY{n}{s}\\PY{o}{*}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{t}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{n}{s}\\PY{o}{*}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sin}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{s}\\PY{o}{*}\\PY{n}{np}\\PY{o}{.}\\PY{n}{cos}\\PY{p}{(}\\PY{n}{theta}\\PY{p}{)}\\PY{p}{,} \\PY{n}{t}\\PY{p}{]}\\PY{p}{,} \\PY{p}{[}\\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{0.}\\PY{p}{,} \\PY{l+m+mf}{1.}\\PY{p}{]}\\PY{p}{]}\n\\PY{c+c1}{\\PYZsh{} Affine Transformation: An arbitrary 2 by 3 Matrix}\n\\PY{n}{a00} \\PY{o}{=} \\PY{l+m+mi}{3} \\PY{p}{;} \\PY{n}{a01} \\PY{o}{=} \\PY{l+m+mi}{2} \\PY{p}{;} \\PY{n}{a02} \\PY{o}{=} \\PY{l+m+mi}{3}\n\\PY{n}{a10} \\PY{o}{=} \\PY{l+m+mi}{1} \\PY{p}{;} \\PY{n}{a11} \\PY{o}{=} \\PY{l+m+mi}{3} \\PY{p}{;} \\PY{n}{a12} \\PY{o}{=} \\PY{l+m+mi}{3}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n}{a00}\\PY{p}{,} \\PY{n}{a01}\\PY{p}{,} \\PY{n}{a02}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{n}{a10}\\PY{p}{,} \\PY{n}{a11}\\PY{p}{,} \\PY{n}{a12}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]}\n\\PY{c+c1}{\\PYZsh{} Projective(Perspective transform or Homography): An arbitrary 3 by 3 Matrix}\n\\PY{n}{a20} \\PY{o}{=} \\PY{l+m+mf}{1.5} \\PY{p}{;} \\PY{n}{a21} \\PY{o}{=} \\PY{l+m+mi}{2}\\PY{p}{;} \\PY{n}{a22} \\PY{o}{=} \\PY{l+m+mi}{1}\n\\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n}{a00}\\PY{p}{,} \\PY{n}{a01}\\PY{p}{,} \\PY{n}{a02}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{n}{a10}\\PY{p}{,} \\PY{n}{a11}\\PY{p}{,} \\PY{n}{a12}\\PY{p}{]}\\PY{p}{,}\\PY{p}{[}\\PY{n}{a20}\\PY{p}{,}\\PY{n}{a21}\\PY{p}{,}\\PY{n}{a22}\\PY{p}{]}\\PY{p}{]}\n\\end{Verbatim}\n\\end{tcolorbox}\n%---------------------------------------------------------------\n\\section{Warping Using a Given Homography}  \n\nFollowing figure shows the transformation of the  \\href{https://www.robots.ox.ac.uk/~vgg/data/affine/}{Graffiti} {\\tt img1.ppm} onto {\\tt img5.ppm} using the provided homography matrix. Consider the area enclosed using the yellow colored bounding box in the figure(d). The transition between two images is almost unnoticeable and it will be completely seamless if  intensities of the pixels around the transition area are perfectly matched.\\\\\n\n\\begin{figure}[!h]\n\t\\centering\n\t\\subfigure[Image 1]\n\t{ \\includegraphics[scale=0.2]{figures/im1}\n\t\t\n\t}\n\t\\subfigure[Image 5]\n\t{ \\includegraphics[scale=0.2]{figures/im5}\n\t\t\n\t}\\\\\n\t\\subfigure[Warped Image 5]\n\t{ \\includegraphics[scale=0.175]{figures/im5warped}\n\t\t\n\t}\n\t\\subfigure[Stitched Images]\n\t{ \\includegraphics[scale=0.29]{figures/im5warped2}\t\t\n\t}\n\t\\caption{Warping Using a Given Homography}\n\t\\label{fig:givenhomo}\n\\end{figure}  \n{\\scriptsize\n\n\\[\nH1to5p = \n\\begin{bmatrix}\n   6.2544644e-01&   5.7759174e-02&   2.2201217e+02\\\\\n2.2240536e-01   &1.1652147e+00  &-2.5605611e+01\\\\\n4.9212545e-04 & -3.6542424e-05 &  1.0000000e+00\\\\\n\\end{bmatrix}\n\\]}\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{2}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{c+c1}{\\PYZsh{} Loading im1.ppm and im5.ppm}\n\\PY{n}{im1} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{imread}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{../images/graf/img1.ppm}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{IMREAD\\PYZus{}ANYCOLOR}\\PY{p}{)}\n\\PY{n}{im5} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{imread}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{../images/graf/img5.ppm}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{,} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{IMREAD\\PYZus{}ANYCOLOR}\\PY{p}{)}\n\\PY{c+c1}{\\PYZsh{} Loading the given Homography H1to5p}\n\\PY{k}{with} \\PY{n+nb}{open}\\PY{p}{(}\\PY{l+s+s1}{\\PYZsq{}}\\PY{l+s+s1}{../images/graf/H1to5p}\\PY{l+s+s1}{\\PYZsq{}}\\PY{p}{)} \\PY{k}{as} \\PY{n}{f}\\PY{p}{:}\n    \\PY{n}{H} \\PY{o}{=} \\PY{p}{[}\\PY{p}{[}\\PY{n+nb}{float}\\PY{p}{(}\\PY{n}{x}\\PY{p}{)} \\PY{k}{for} \\PY{n}{x} \\PY{o+ow}{in} \\PY{n}{line}\\PY{o}{.}\\PY{n}{split}\\PY{p}{(}\\PY{p}{)}\\PY{p}{]} \\PY{k}{for} \\PY{n}{line} \\PY{o+ow}{in} \\PY{n}{f}\\PY{p}{]}\n\\PY{n}{H} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\n\\PY{n}{im5\\PYZus{}warped} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{warpPerspective}\\PY{p}{(}\\PY{n}{im5}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{linalg}\\PY{o}{.}\\PY{n}{inv}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\\PY{p}{,} \\PY{p}{(}\\PY{l+m+mi}{900}\\PY{p}{,}\\PY{l+m+mi}{900}\\PY{p}{)}\\PY{p}{)}\n\\PY{n}{im5\\PYZus{}warped}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]} \\PY{o}{=} \\PY{n}{im1}\n\\end{Verbatim}\n\\end{tcolorbox}\n\\vspace{0.5cm}\n\\hrule\n\\section{Computing the Homography Using Mouse-Clicked Points and Warping}\n\nTo calculate the homography at least 4 corresponding points are required. Following figures show the points used to calculate the homography matrix given below. There, 5 points marked in the light blue circles on each image were selected. Note that the same sets of points were used to calculate the homography using the custom function defined in the next section since it enables better comparison between the sections of this report. \\\\\n \n\\begin{figure}[!h]\n\t\\centering\n\t\\subfigure[Image 1]\n\t{ \\includegraphics[scale=0.25]{figures/im1points}\n\t\t\n\t}\n\t\\subfigure[Image 4]\n\t{ \\includegraphics[scale=0.25]{figures/im4points}\n\t}\n\t\\caption{Corresponding Points used to Calculate the Homography}\n\t\n\\end{figure}\n \nConsider the area enclosed using the yellow colored bounding box in the sub figure(b) of Fig.\\ref{findhomo}. Transition between two images is visible than that in the Fig.\\ref{fig:givenhomo}. Human made error at the selection of corresponding points and low quality of the chosen points can be reasons for this imperfection as it was done through manual mouse clicking. However some of the values obtained for the elements of homography matrix is nearly closer to that of the original homography given in the aforementioned website.\\\\% and they are also included in the below table.\n%\\begin{table}[!h]\n%\t\\centering\n%\t\\begin{tabular}{|l|| c| c|}\n%\t\t\\hline\n%\t\t\\textbf{Point} & \\textbf{Image 1} & \\textbf{Image 4}\\\\\\hline\n%\t\t&&\\\\\n%\t\tPoint 1&[157. 560.]&[434. 631.]\\\\\n%\t\tPoint 2&[141. 130.]&[143. 243.]\\\\\n%\t\tPoint 3&[544. 542.]&[576. 486.]\\\\\n%\t\tPoint 4&[405. 209.]&[325. 250.]\\\\\n%\t\tPoint 5&[682.  056.]&[358.  081.]\\\\\\hline\n%\t\\end{tabular}\n%\t\\caption{Corresponding Points in the two Images}\n%\\end{table}\n\n\n\\begin{figure}[!h]\n\t\\centering\n\t\\subfigure[Warped Image 4]\n\t{ \\includegraphics[scale=0.175]{figures/im4warped}\n\t\t\n\t}\n\t\\subfigure[Stitched Images]\n\t{ \\includegraphics[scale=0.29]{figures/im4warped2}\t\t\n\t}\n\t\\caption{Warping Using the Homography calculated using {\\tt cv.findHomography()} in OpenCV }\n\t\\label{findhomo}\n\\end{figure}  \n\n\n\nThe homography matrix calculated using the above points and the OpenCV's {\\tt cv.findHomography()} function is given below. \n{\\scriptsize\n\\[\nH = \n\\begin{bmatrix}\n 6.59894211e-01 &  6.86220378e-01& -3.13000247e+01\\\\\n-1.50977725e-01  &9.56863356e-01  &1.52906596e+02\\\\\n 4.12755346e-04& -1.98886486e-05  &1.00000000e+00\\\\\n\\end{bmatrix}\n\\]\n}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{3}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{H}\\PY{p}{,} \\PY{n}{status} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{findHomography}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{,}\\PY{n}{p2}\\PY{p}{)}\n\\PY{n}{H} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\n\\PY{n}{im4\\PYZus{}warped} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{warpPerspective}\\PY{p}{(}\\PY{n}{im4}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{linalg}\\PY{o}{.}\\PY{n}{inv}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\\PY{p}{,} \\PY{p}{(}\\PY{l+m+mi}{900}\\PY{p}{,}\\PY{l+m+mi}{900}\\PY{p}{)}\\PY{p}{)}\n\\PY{n}{im4\\PYZus{}warped}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]} \\PY{o}{=} \\PY{n}{im1}\n\\end{Verbatim}\n\\end{tcolorbox}\n\\vspace{0.5cm}\n\\hrule\n\n\\section{Computing the Homogrpahy Using Mouse-Clicked Points and without OpenCV}\n\nFollowing algorithm implements the \\textbf{\\textit{Normalized Direct Linear Transformation (DLT)}} method (described in the \\textit{Multiple View Geometry in Computer Vision}(Second Edition), by \\textit{Richard Hartley} and   \\textit{Andrew Zisserman}), to find the homography matrix {\\tt M}$_{3 \\times 3}$ using 5 pairs of corresponding points. Let $x_i = [x , y, 1]$ and $x_i^\\prime = [x\\prime , y\\prime, w\\prime ] $  be two corresponding points in the given two images. Then the transformation is given by $x_i^\\prime = Hx_i$. This equation can be represented by using the vector cross product as  $x_i^\\prime \\times Hx_i = 0$ sine both the components have the same direction even though they differ in magnitude. This equation can be further simplified  to obtain the following linearly independent  system of two equations corresponding to each pair of points. Where $h^j$ indicates the $j^{th}$ row of the Homography matrix and $j = {1,2,3}$.\n\n{\\footnotesize\n\\begin{equation*}\n\t\\begin{bmatrix}\n\t\t0^\\top & -w\\prime x_i^\\top & y\\prime x_i^\\top\\\\\n\t\tw\\prime x_i^\\top\t& 0^\\top & -x\\prime x_i^\\top\\\\\n\t\\end{bmatrix}\n\t\\begin{bmatrix}\n\t\th^1\\\\\n\t\th^2\\\\\n\t\th^3\n\t\\end{bmatrix} =\n\t\\begin{bmatrix}\n\t\t0& 0 &0 & -w\\prime.x&-w\\prime.y&-w\\prime.1& y\\prime.x & y\\prime.y& y\\prime.1\\\\\n\t\tw\\prime.x&w\\prime.y&w\\prime.1& 0& 0 &0 & -x\\prime.x& -x\\prime.y& -x\\prime.1\\\\\n\t\\end{bmatrix}\n\t\\begin{bmatrix}\n\t\th^1\\\\\n\t\th^2\\\\\n\t\th^3\n\t\\end{bmatrix}\n\\end{equation*}\n}\n\nWe can obtain 5 pairs of such equations and they can be put into a single matrix to solve for the unknown  $h^j$s through \\textbf{\\textit{Singular Value Decomposition}} as described in the {\\tt Algorithm 4.1, 4.2 } in the above mentioned reference book. When Considering the area enclosed using the yellow colored bounding box in the sub figure(b) of Fig.\\ref{clachomo}, discontinuous transition between two images is clearly visible than both the Fig.\\ref{fig:givenhomo} and the Fig.\\ref{findhomo}. In addition to the aforementioned reasons for this imperfection, low quality of the used algorithm may also be a reason since it is a very basic algorithm for homography calculation. \n\n\\begin{figure}[!h]\n\t\\centering\n%\t\\subfigure[Image 1]\n%\t{ \\includegraphics[scale=0.2]{figures/myim1points}\n%\t\t\n%\t}\n%\t\\subfigure[Image 4]\n%\t{ \\includegraphics[scale=0.2]{figures/myim4points}\n%\t}\\\\\n\t\\subfigure[Warped Image 4]\n\t{ \\includegraphics[scale=0.175]{figures/myim4warped}\n\t\t\n\t}\n\t\\subfigure[Stitched Images]\n\t{ \\includegraphics[scale=0.29]{figures/myim4warped2}\t\t\n\t}\n\t\\caption{Warping Using the Calculated Homography}\n\t\\label{clachomo}\n\\end{figure} \n\nThe homography calculated using the same points mentioned earlier and the {\\tt calcHomography()} custom function defined below is given below. Even though some values of its elements are nearly closer to the ideal values it has unable to provide good results due to the previously mentioned reasons.  \n{ \\scriptsize\n\\[\nH = \n\\begin{bmatrix}\n 6.60355290e-01&  6.85735356e-01 &-3.13168167e+01\\\\\n-1.50699933e-01 & 9.56965356e-01 & 1.52763838e+02\\\\\n 4.13108386e-04 &-2.02092511e-05 & 1.00000000e+00\\\\\n\\end{bmatrix}\n\\]\n}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{4}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{c+c1}{\\PYZsh{}============================ Normalization ======================}\n\\PY{k}{def} \\PY{n+nf}{normalizePoints}\\PY{p}{(}\\PY{n}{points}\\PY{p}{)}\\PY{p}{:}\n    \\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{       Normalizing the point cloud(pre\\PYZhy{}conditioning) }\n\\PY{l+s+sd}{    \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n    \\PY{c+c1}{\\PYZsh{} Calculating the centroid of the points.}\n    \\PY{n}{centroid} \\PY{o}{=} \\PY{n+nb}{sum}\\PY{p}{(}\\PY{n}{points}\\PY{p}{)}\\PY{o}{/}\\PY{n+nb}{len}\\PY{p}{(}\\PY{n}{points}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} Calculating the scaling factor.}\n    \\PY{n}{total\\PYZus{}dist} \\PY{o}{=} \\PY{n+nb}{sum}\\PY{p}{(}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sqrt}\\PY{p}{(}\\PY{n}{np}\\PY{o}{.}\\PY{n}{sum}\\PY{p}{(}\\PY{p}{(}\\PY{p}{(}\\PY{n}{points} \\PY{o}{\\PYZhy{}} \\PY{n}{centroid}\\PY{p}{)}\\PY{o}{*}\\PY{o}{*}\\PY{l+m+mi}{2}\\PY{p}{)}\\PY{p}{,}\\PY{n}{axis} \\PY{o}{=} \\PY{l+m+mi}{1}\\PY{p}{)}\\PY{p}{)}\\PY{p}{)}\n    \\PY{n}{avg\\PYZus{}dist}  \\PY{o}{=} \\PY{n}{total\\PYZus{}dist}\\PY{o}{/}\\PY{n+nb}{len}\\PY{p}{(}\\PY{n}{points}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} For average distance from the origin to be sqrt(2) after scaling}\n    \\PY{n}{scale} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{sqrt}\\PY{p}{(}\\PY{l+m+mi}{2}\\PY{p}{)}\\PY{o}{/}\\PY{n}{avg\\PYZus{}dist}    \n    \\PY{c+c1}{\\PYZsh{} Defining Similarity transformation: translation and scaling}\n    \\PY{n}{xt}\\PY{p}{,} \\PY{n}{yt} \\PY{o}{=} \\PY{n}{centroid}\n    \\PY{n}{transform} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{p}{[}\\PY{p}{[}\\PY{n}{scale}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{,} \\PY{o}{\\PYZhy{}}\\PY{n}{xt}\\PY{o}{*}\\PY{n}{scale}\\PY{p}{]}\\PY{p}{,}\n                          \\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{n}{scale}\\PY{p}{,} \\PY{o}{\\PYZhy{}}\\PY{n}{yt}\\PY{o}{*}\\PY{n}{scale}\\PY{p}{]}\\PY{p}{,}\n                          \\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{,}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} Making the points homogeneous by adding 1 at the end}\n    \\PY{n}{points} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{concatenate}\\PY{p}{(}\\PY{p}{(}\\PY{n}{points}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{ones}\\PY{p}{(}\\PY{p}{(}\\PY{n+nb}{len}\\PY{p}{(}\\PY{n}{points}\\PY{p}{)}\\PY{p}{,}\\PY{l+m+mi}{1}\\PY{p}{)}\\PY{p}{)}\\PY{p}{)}\\PY{p}{,} \\PY{n}{axis} \\PY{o}{=}\\PY{l+m+mi}{1}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} Similarity transformation through matrix multiplication}\n    \\PY{n}{normalized\\PYZus{}points} \\PY{o}{=} \\PY{n}{transform}\\PY{o}{.}\\PY{n}{dot}\\PY{p}{(}\\PY{n}{points}\\PY{o}{.}\\PY{n}{T}\\PY{p}{)}\\PY{o}{.}\\PY{n}{T}\n    \\PY{k}{return} \\PY{n}{transform}\\PY{p}{,} \\PY{n}{normalized\\PYZus{}points}\n\\end{Verbatim}\n\\end{tcolorbox}\n\nNormalization of data points was also done using the above function in order to improve the performance of the algorithm defined below and to obtain a  better homography.\\\\ \n\n\n   \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\t\\prompt{In}{incolor}{4}{\\boxspacing}\n\t\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{c+c1}{\\PYZsh{}===================== Calculating homography ====================}\n\\PY{k}{def} \\PY{n+nf}{calcHomography}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{,}\\PY{n}{p2}\\PY{p}{)}\\PY{p}{:}\n    \\PY{l+s+sd}{\\PYZdq{}\\PYZdq{}\\PYZdq{}}\n\\PY{l+s+sd}{        The normalized DLT for 2D homographies.Given in the }\n\\PY{l+s+sd}{        \"Multiple View Geometry in Computer Vision\" Second Edition }\n\\PY{l+s+sd}{        by Richard Hartley \\PYZam{} Andrew Zisserman. Algorithm 4.2 }\n\\PY{l+s+sd}{    \\PYZdq{}\\PYZdq{}\\PYZdq{}}\n    \\PY{c+c1}{\\PYZsh{} Normalizing the points using predefined function}\n    \\PY{n}{T1}\\PY{p}{,}\\PY{n}{p1} \\PY{o}{=} \\PY{n}{normalizePoints}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{)}\n    \\PY{n}{T2}\\PY{p}{,}\\PY{n}{p2} \\PY{o}{=} \\PY{n}{normalizePoints}\\PY{p}{(}\\PY{n}{p2}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{}Initialising an array to keep the coefficint matrix}\n    \\PY{n}{A} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{zeros}\\PY{p}{(}\\PY{p}{(}\\PY{l+m+mi}{2}\\PY{o}{*}\\PY{n+nb}{len}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{)}\\PY{p}{,} \\PY{l+m+mi}{9}\\PY{p}{)}\\PY{p}{)}\n    \\PY{n}{row} \\PY{o}{=} \\PY{l+m+mi}{0}\n    \\PY{c+c1}{\\PYZsh{} Filling rows of the matrix according to the expressions}\n    \\PY{k}{for} \\PY{n}{point1}\\PY{p}{,} \\PY{n}{point2} \\PY{o+ow}{in} \\PY{n+nb}{zip}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{,}\\PY{n}{p2}\\PY{p}{)}\\PY{p}{:}\n        \\PY{c+c1}{\\PYZsh{} Coefficients of the current row }\n        \\PY{n}{A}\\PY{p}{[}\\PY{n}{row}\\PY{p}{,} \\PY{l+m+mi}{3}\\PY{p}{:}\\PY{l+m+mi}{6}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{n}{point2}\\PY{p}{[}\\PY{l+m+mi}{2}\\PY{p}{]}\\PY{o}{*}\\PY{n}{point1}\n        \\PY{n}{A}\\PY{p}{[}\\PY{n}{row}\\PY{p}{,} \\PY{l+m+mi}{6}\\PY{p}{:}\\PY{l+m+mi}{9}\\PY{p}{]} \\PY{o}{=}  \\PY{n}{point2}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{o}{*}\\PY{n}{point1}\n        \\PY{c+c1}{\\PYZsh{} Coefficients of the next row }\n        \\PY{n}{A}\\PY{p}{[}\\PY{n}{row}\\PY{o}{+}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{:}\\PY{l+m+mi}{3}\\PY{p}{]} \\PY{o}{=}  \\PY{n}{point2}\\PY{p}{[}\\PY{l+m+mi}{2}\\PY{p}{]}\\PY{o}{*}\\PY{n}{point1}\n        \\PY{n}{A}\\PY{p}{[}\\PY{n}{row}\\PY{o}{+}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+m+mi}{6}\\PY{p}{:}\\PY{l+m+mi}{9}\\PY{p}{]} \\PY{o}{=} \\PY{o}{\\PYZhy{}}\\PY{n}{point2}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{o}{*}\\PY{n}{point1}    \n        \\PY{n}{row}\\PY{o}{+}\\PY{o}{=}\\PY{l+m+mi}{2}    \n    \\PY{c+c1}{\\PYZsh{} Singular Value decomposition of A}\n    \\PY{n}{U}\\PY{p}{,} \\PY{n}{D}\\PY{p}{,} \\PY{n}{VT} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{linalg}\\PY{o}{.}\\PY{n}{svd}\\PY{p}{(}\\PY{n}{A}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} unit singular vector corresponding to the smallest }\n    \\PY{c+c1}{\\PYZsh{} singular value, is the solution h. That is last column of V.}\n    \\PY{c+c1}{\\PYZsh{} i.e. Last row of the V\\PYZca{}T}\n    \\PY{n}{h} \\PY{o}{=}   \\PY{n}{VT}\\PY{p}{[}\\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\\PY{p}{]}\n    \\PY{c+c1}{\\PYZsh{} Reshaping to get 3x3 homography}\n    \\PY{n}{H} \\PY{o}{=} \\PY{n}{h}\\PY{o}{.}\\PY{n}{reshape}\\PY{p}{(}\\PY{p}{(}\\PY{l+m+mi}{3}\\PY{p}{,}\\PY{l+m+mi}{3}\\PY{p}{)}\\PY{p}{)}\n    \\PY{c+c1}{\\PYZsh{} Denormalization}\n    \\PY{n}{H} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{linalg}\\PY{o}{.}\\PY{n}{inv}\\PY{p}{(}\\PY{n}{T2}\\PY{p}{)}\\PY{o}{.}\\PY{n}{dot}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\\PY{o}{.}\\PY{n}{dot}\\PY{p}{(}\\PY{n}{T1}\\PY{p}{)}\n    \\PY{n}{H} \\PY{o}{=} \\PY{n}{H}\\PY{o}{/}\\PY{n}{H}\\PY{p}{[}\\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\\PY{p}{,}\\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\\PY{p}{]}\n    \\PY{k}{return} \\PY{n}{H}\n    \n\\PY{c+c1}{\\PYZsh{} Calculating Homography using the above function }    \n\\PY{n}{myH} \\PY{o}{=} \\PY{n}{calcHomography}\\PY{p}{(}\\PY{n}{p1}\\PY{p}{,}\\PY{n}{p2}\\PY{p}{)}\n\\PY{n}{myH} \\PY{o}{=} \\PY{n}{np}\\PY{o}{.}\\PY{n}{array}\\PY{p}{(}\\PY{n}{H}\\PY{p}{)}\n\\PY{c+c1}{\\PYZsh{} Warping } \n\\PY{n}{im4\\PYZus{}warped} \\PY{o}{=} \\PY{n}{cv}\\PY{o}{.}\\PY{n}{warpPerspective}\\PY{p}{(}\\PY{n}{im4}\\PY{p}{,} \\PY{n}{np}\\PY{o}{.}\\PY{n}{linalg}\\PY{o}{.}\\PY{n}{inv}\\PY{p}{(}\\PY{n}{myH}\\PY{p}{)}\\PY{p}{,} \\PY{p}{(}\\PY{l+m+mi}{900}\\PY{p}{,}\\PY{l+m+mi}{900}\\PY{p}{)}\\PY{p}{)}\n\\PY{c+c1}{\\PYZsh{} Stiching two images } \n\\PY{n}{im4\\PYZus{}warped}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{p}{,} \\PY{l+m+mi}{0}\\PY{p}{:}\\PY{n}{im1}\\PY{o}{.}\\PY{n}{shape}\\PY{p}{[}\\PY{l+m+mi}{1}\\PY{p}{]}\\PY{p}{]} \\PY{o}{=} \\PY{n}{im1}\n\\end{Verbatim}\n\\end{tcolorbox}\n\\vfill\n\\hrule\n\\begin{center}\n\tExecutable code for this assignment can be found  \\href{https://github.com/bimalka98/Computer-Vision-and-Image-Processing/blob/main/EN2550Assignments/A2/180631J_a02.ipynb}{here}.\n\\end{center}\n  \n\\end{document}\n", "meta": {"hexsha": "c1065c6e9bc7fd83f03b9556eca6894c3a53ac0d", "size": 22481, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "EN2550Assignments/A2/LaTeX Report/180631J_a02.tex", "max_stars_repo_name": "bimalka98/Com.VISION-Img.PROCESSING", "max_stars_repo_head_hexsha": "785bfdd4204d6e672600f8e0fae6b006310982c7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2021-01-07T00:35:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T15:13:16.000Z", "max_issues_repo_path": "EN2550Assignments/A2/LaTeX Report/180631J_a02.tex", "max_issues_repo_name": "bimalka98/Com.VISION-Img.PROCESSING", "max_issues_repo_head_hexsha": "785bfdd4204d6e672600f8e0fae6b006310982c7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-03-10T04:02:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-16T20:46:57.000Z", "max_forks_repo_path": "EN2550Assignments/A2/LaTeX Report/180631J_a02.tex", "max_forks_repo_name": "bimalka98/Com.VISION-Img.PROCESSING", "max_forks_repo_head_hexsha": "785bfdd4204d6e672600f8e0fae6b006310982c7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-08-07T15:13:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T13:16:11.000Z", "avg_line_length": 66.1205882353, "max_line_length": 948, "alphanum_fraction": 0.594813398, "num_tokens": 9499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.43544670888955006}}
{"text": "\\chapter{Introduction}\n\\setcounter{page}{1}\n\nThis is an overview of the topics developed in the rest of the book.\n\n\\section{Rewrite systems}\n\n\\paragraph{String-rewriting}\n\nLet us assume that we own a string of white and black beads, like\n\\(\\circ \\bullet \\bullet \\bullet \\circ \\circ \\bullet\\), and the\ngame \\citep{VanLeeuwen_1990a,Dershowitz_1993} consists in removing two\nadjacent beads and replace them with only one according to some rules,\nfor example\n\\begin{equation*}\n\\bullet \\; \\circ   \\xrightarrow{\\smash{\\alpha}} \\bullet\\qquad\\qquad\n\\circ   \\; \\bullet \\xrightarrow{\\smash{\\beta}} \\bullet\\qquad\\qquad\n\\bullet \\; \\bullet \\xrightarrow{\\smash{\\gamma}} \\circ\n\\end{equation*}\nThe rules~\\(\\alpha\\), \\(\\beta\\)~and~\\(\\gamma\\) make up a simple\n\\emph{string\\hyp{}rewriting system}\\index{rewrite system}. Rules\n\\(\\alpha\\)~and~\\(\\beta\\) can be conceived as ``A black bead absorbs\na white bead next to it.'' The goal of this game is to end up with\nas few beads as possible, so our example may lead to the\n\\emph{rewrites}\n\\begin{equation*}\n\\circ \\bullet \\bullet \\, \\fbox{\\(\\bullet\\; \\circ\\)} \\circ \\bullet\n\\xrightarrow{\\smash{\\alpha}} \\circ \\bullet \\bullet \\,\n\\fbox{\\(\\bullet\\; \\circ\\)} \\; \\bullet \\xrightarrow{\\smash{\\alpha}}\n\\fbox{\\(\\circ \\; \\bullet\\)} \\; \\bullet \\bullet \\,\\bullet\n\\xrightarrow{\\smash{\\beta}} \\bullet \\bullet \\, \\fbox{\\(\\bullet \\;\n  \\bullet\\)} \\xrightarrow{\\smash{\\gamma}} \\bullet \\, \\fbox{\\(\\bullet\n  \\; \\circ\\)} \\xrightarrow{\\smash{\\alpha}} \\fbox{\\(\\bullet \\;\n  \\bullet\\)} \\xrightarrow{\\smash{\\gamma}} \\circ\n\\end{equation*}\nwhere the part of the string to be rewritten next is framed.\n\nOther compositions of the rules lead to the same result~\\(\\circ\\) as\nwell. Some others bring all\\hyp{}white strings, the simplest being\n\\(\\circ \\, \\circ\\). Some others lead to~\\(\\bullet\\). Strings that can\nnot be further rewritten, or \\emph{reduced}, are called \\emph{normal\n  forms}\\index{rewrite system!normal form}. These observations induce\nus to wonder whether all strings have a normal form; if so, if it is\nunique and, furthermore, if it is either all\\hyp{}white or\nblack\\hyp{}only.\n\nFirst, let us note that the system is\n\\emph{terminating}\\index{termination}, that is, there is no infinite\nchain of rewrites, because the number of beads strictly decreases in\nall the rules, although this is not a necessary condition in general,\nfor instance, \\(\\circ \\; \\bullet \\xrightarrow{\\smash{\\beta}} \\bullet\n\\circ \\circ\\) would preserve termination because the composition\n\\(\\beta\\alpha\\alpha\\) would be equivalent to the original\nrule~\\(\\beta\\). In particular, this means that any string has a normal\nform. Furthermore, notice how the parity of the number of black beads\nis invariant through each rule and how there is no rewrite rule for\ntwo adjacent white beads. Therefore, if there are \\(2p\\) initial black\nbeads, then composing rules \\(\\alpha\\)~and~\\(\\beta\\) lead to an\nall\\hyp{}black string, like \\(\\bullet \\bullet \\bullet \\, \\bullet\\),\nwhich can be reduced by applying rule~\\(\\gamma\\) to contiguous pairs\nof beads into an all\\hyp{}white string made of \\(p\\)~beads. Otherwise,\nthe same all\\hyp{}black string can be reduced by applying\nalternatively \\(\\gamma\\)~and~\\(\\beta\\) on the left end or\n\\(\\gamma\\)~and~\\(\\alpha\\) on the right end,\nyielding~\\(\\circ\\). Similarly, if there is an initial odd number of\nblack beads, we always end up with one black bead. It suffices to\nconsider the rewrites \\(\\circ \\circ \\xleftarrow{\\smash{\\gamma}}\n\\bullet \\bullet \\circ \\xrightarrow{\\smash{\\alpha}} \\bullet \\bullet\n\\xrightarrow{\\smash{\\gamma}} \\circ\\) to see that normal forms are not\nunique. Systems where normal forms are unique are called\n\\emph{confluent}\\index{rewrite system!confluence}.\n\nIf we add the rule \\(\\circ\\; \\circ \\xrightarrow{\\smash{\\delta}}\n\\circ\\), the result of the game is always one bead, whose colour\ndepends on the original parity of the black beads as before, and any\nstrategy is successful. To see why, let us consider first that two\nnon\\hyp{}overlapping parts of a string can be rewritten in parallel,\nthat is to say, the order in which they are applied is irrelevant.\nThe interesting cases occur when two applications of rules (maybe of\nthe same rule) lead to different strings because they overlap. For\ninstance, \\(\\circ \\, \\circ \\xleftarrow{\\smash{\\gamma}} \\bullet \\bullet\n\\circ \\xrightarrow{\\smash{\\alpha}} \\bullet \\, \\bullet\\). The important\npoint is that \\(\\circ \\, \\circ\\) and \\(\\bullet \\, \\bullet\\) can be\nrewritten into~\\(\\circ\\) at the next step by\n\\(\\delta\\)~and~\\(\\gamma\\), respectively.\n\nIn general, what matters is that all pairs of strings resulting from\nthe application of overlapping rules, called \\emph{critical\npairs}\\index{rewrite system!critical pair}, can be rewritten to the\nsame string, to wit, they are \\emph{joinable}. In our example, all\ninteractions occur on substrings consisting of three beads (because\nthe left\\hyp{}hand sides of the rules are made of exactly two beads),\nso we must examine in \\fig~\\vref{fig:bullets}\n\\begin{figure}[b]\n\\centering\n\\includegraphics{bullets}\n\\caption{The critical pairs are all joinable\\label{fig:bullets}}\n\\end{figure}\neight cases, which we can order as if counting in binary from\n\\(0\\)~to~\\(7\\), (\\(\\circ\\))~being interpreted as~\\(0\\) and\n(\\(\\bullet\\))~as~\\(1\\). In all the cases, the divergences are joinable\nin one step at most.\n\nIn general, it is not necessary for critical pairs to be joinable in\none rewrite just after the divergence, but to be joinable after any\nnumber of rewrites. This property is called \\emph{local\nconfluence}\\index{rewrite system!confluence!local $\\sim$}. Together\nwith termination, it implies that \\emph{every} string has exactly one\nnormal form, which is a strong property entailing confluence.\n\nThe system we defined is \\emph{ground}\\index{rewrite system!ground\n  $\\sim$}, that is, it involves no variables. Variables allow a finite\nsystem to denote an infinite number of ground rules if the elements\nmaking up the strings are infinite, but also to reduce the size of a\nfinite ground system. For instance, the previous example is equivalent\nto\n\\begin{equation*}\n\\bullet \\; \\circ \\xrightarrow{\\smash{\\alpha}} \\bullet\n\\qquad\\qquad\n\\circ \\; x \\xrightarrow{\\smash{\\beta+\\delta}} x\n\\qquad\\qquad\n\\bullet \\; \\bullet \\xrightarrow{\\smash{\\gamma}} \\circ\n\\end{equation*}\nwhere \\(x \\in \\{\\circ, \\bullet\\}\\).If we accept multiple occurrences\nof a variable on the left\\hyp{}hand side of a rule, a so\\hyp{}called\n\\emph{non left\\hyp{}linear rule}\\index{rewrite system!linear $\\sim$},\nwe can further decrease the size of the system as follows:\n\\begin{equation*}\nx  \\; x \\xrightarrow{\\smash{\\gamma+\\delta}} \\circ\\qquad\\qquad\nx  \\; y \\xrightarrow{\\smash{\\alpha+\\beta}} \\bullet\n\\end{equation*}\nThere is now an \\emph{implicit order over the rules}, which is the\norder of writing (from left to right, top to bottom): the\nrule \\(\\gamma+\\delta\\) must be examined first for a match with a part\nof the current string, because it is included in the second (set\n\\(x=y\\) in \\(\\alpha+\\beta\\) and we obtain the same left\\hyp{}hand side\nas~\\(\\gamma+\\delta\\)).\n\n\\paragraph{Term-rewriting}\n\nUp to now, only string\\hyp{}rewriting systems have been played\nwith. More general are the \\emph{term\\hyp{}rewriting\n  systems} \\citep{BaaderNipkow_1998}\\index{rewrite system}, where a\n\\emph{term}\\index{term} is a mathematical object possibly featuring\ntuples, integers and variables. Let us consider the following totally\nordered system\n\\begin{equation}\n(0,m) \\rightarrow m;\\qquad\\qquad\n(n,m) \\rightarrow (n-1,n \\cdot m);\\qquad\\qquad\nn     \\rightarrow (n,1).\n\\label{eq:fact_tf}\n\\end{equation}\nwhere rules are separated by a semi\\hyp{}colon and the last one is\nended by a period. Arithmetic operators \\((-)\\)~and~\\((\\cdot)\\) are\ndefined outside the system, and \\(m\\)~and~\\(n\\) are variables denoting\nnatural numbers. Would the rules not be ordered as they are laid out,\nthe second rule would match any pair. Instead, it can be assumed that\n\\(n \\neq 0\\) in the second rule. We can easily see that all\ncompositions of rewrites starting with a natural number~\\(n\\) end with\nthe \\emph{factorial}\\index{factorial} of~\\(n\\), that is, \\(1 \\cdot 2\n\\cdot 3 \\dots \\cdot n\\), or simply~\\(n!\\):\n\\begin{equation*}\nn \\rightarrow (n,1) \\rightarrow \\dots \\rightarrow (0,n!) \\rightarrow\nn!, \\quad \\text{for \\(n \\in \\mathbb{N}\\)}.\n\\end{equation*}\nLet us note \\((\\xrightarrow{\\smash{n}})\\) the composition of\n\\((\\rightarrow)\\) repeated \\(n\\)~times:\n\\begin{equation*}\n  (\\xrightarrow{\\smash{1}})   := (\\rightarrow);\\qquad\n  (\\xrightarrow{\\smash{n+1}}) :=\n     (\\rightarrow) \\circ (\\xrightarrow{\\smash{n}}),\n\\quad \\text{with \\(n > 0\\)}.\n\\end{equation*}\nThe symbol ``\\(:=\\)'' is the definitional equality, meaning: ``is, by\ndefinition,''. The \\emph{transitive closure}\\index{transitive\n  closure} \\label{transitive_closure} of \\((\\rightarrow)\\) is defined\nas \\((\\twoheadrightarrow) := \\bigcup_{i >\n  0}{(\\xrightarrow{\\smash{i}})}\\). In the present case, the\nfactorial\\index{factorial} coincides with the transitive closure of\n\\((\\rightarrow)\\), namely, \\(n \\twoheadrightarrow n!\\). Let\n\\((\\xrightarrow{\\smash{*}})\\) be the reflexive\\hyp{}transitive closure\nof \\((\\rightarrow)\\), that is, \\((\\xrightarrow{\\smash{*}}) := (=) \\cup\n(\\twoheadrightarrow)\\).\n\nA confluent system defines a \\emph{partial function}, and it is then\nconvenient to name it; for example, \\(\\fun{c}(1, \\fun{d}(n))\\)~is a\nterm constructed with \\emph{function names} \\fun{c}~and~\\fun{d}, as\nwell as variable~\\(n\\). A tuple tagged with a function name, like\n\\(\\fun{f}(x,y)\\), is called a \\emph{function call}. The components of\nthe tuples are then called \\emph{arguments}, for example\n\\(\\fun{d}(n)\\) is the second argument of the call \\(\\fun{c}(1,\n\\fun{d}(n))\\). It is possible for a function call to hold no\narguments, like \\(\\fun{d}()\\). For a given system, we restrict the\nleft\\hyp{}hand sides of rules to be calls to the same function being\ndefined.\n\n\\section{Trees for depicting terms}\\index{term|see{tree}}\n\\label{def:tree}\n\n% Wrapping figure better declared before a paragraph\n%\n\\begin{wrapfigure}[9]{r}[0pt]{0pt}\n% [9] vertical lines\n% {r} mandatory right placement\n% [0pt] of margin overhang\n\\centering\n\\includegraphics[bb=65 645 192 710]{tree_for_term}% [...720]\n\\caption{Shape of a tree\\label{fig:tree_for_term}}\n\\end{wrapfigure}\nThe topological understanding of a function call or a tuple is the\nfinite \\emph{tree}\\index{tree}. A tree is a hierarchical layout of\ninformation and \\fig~\\vref{fig:tree_for_term} shows the shape of\none. The disks are called \\emph{nodes}\\index{tree!node} and the\nsegments which connect two nodes are called\n\\emph{edges}\\index{tree!edge}. The topmost node (with a diameter) is\ncalled the \\emph{root}\\index{tree!node!root} and the bottommost ones\n(\\(\\bullet\\)) are called the \\emph{leaves}\\index{tree!node!leaf}. All\nnodes except the leaves are seen to downwardly connect to some other\nnodes, called \\emph{children}\\index{tree!node!child}. Upwardly, each\nnode but the root is connected to another node, called its\n\\emph{parent}\\index{tree!node!parent}. Depending on the context, a\nnode can also denote the whole tree of which it is the root. Any node\nexcept the root is the root of a \\emph{proper\n  subtree}\\index{tree!subtree!proper $\\sim$}. A tree is its own\nsubtree. The children of a node~\\(x\\) are the roots of \\emph{immediate\n  subtrees}\\index{tree!subtree!immediate $\\sim$} with respect to the\ntree rooted at~\\(x\\). Any two different immediate subtrees are\ndisjoint, that is, no node from one connects to a node in the other. A\ngroup of trees is a \\emph{forest}\\index{tree!forest}.\n\n% Wrapping figure better declared before a paragraph\n%\n\\begin{wrapfigure}[8]{r}[0pt]{0pt}\n% [8] vertical lines\n% {r} mandatory right placement\n% [0pt] of margin overhang\n\\centering\n\\includegraphics[bb=71 652 123 710]{tree}% normal is [.. .. .. 715]\n\\caption{\\label{fig:tree}}\n\\end{wrapfigure}\nTrees can be used to depict terms as follows. A function call is a\ntree whose root is the function name and the children are the trees\ndenoting the arguments. A tuple can be considered as having an\ninvisible function name represented by a node with a period\n(\\texttt{.}) in the tree, in which case the components of the tuple\nare its children. For example, the tree in \\fig~\\vref{fig:tree} has\nroot~\\fun{f} and leaves~\\(0\\), \\(x\\), \\(1\\) and~\\(y\\). Note how\nvariables \\(x\\)~and~\\(y\\) are set in italics to differentiate them\nfrom function names \\fun{x}~and~\\fun{y}, set in\n\\textsf{sans\\hyp{}serif}. For example \\(\\fun{d}((), \\fun{e}([1]))\\)\ncan be interpreted as a tree of root~\\fun{d} and whose first immediate\nsubtree is the representation of the empty tuple \\(()\\), and the\nsecond immediate subtree corresponds to\n\\(\\fun{e}([1])\\). \\Fig~\\ref{fig:tree} represents the tree\ncorresponding to \\(\\fun{f}((\\fun{g}(0),(x,1)),(),\\fun{g}(y))\\). The\nnumber of arguments of a function is called\n\\emph{arity}\\index{functional language!arity}. Functions with the same\nname but different arities are permitted; for instance, we could have\nboth \\(\\fun{c}(\\fun{a}())\\) and \\(\\fun{c}(\\fun{a}(x),0)\\). This is\ncalled \\emph{overloading}\\index{functional language!overloading}. To\ndistinguish the different uses, the arity of the function should be\nindicated after a slash, for example \\fun{c/1} and \\fun{c/2}.\n\n\\section{Purely functional languages}\n\\label{sec:functional}\n\nWe only want to consider confluent systems because they define partial\nfunctions. This property can be trivially enforced by setting an order\non the rules, as we did in previous examples. Another restriction we\nimpose is for normal forms to be \\emph{values}\\index{functional\n  language!value}, to wit, they do not contain any function call which\ncan be further reduced. These two constraints define a \\emph{purely\nfunctional language} \\citep{Hughes_1989,Hinsen_2009}\\index{functional\n  language}. Notice that we do not require by construction that a\nsystem terminates. Not doing so enables more expressivity, at the\nexpense of some more work to prove termination case by case.\n\nWe would like to further constrain the computation of function calls\nby imposing that arguments are rewritten before the call is. This\nstrategy is named \\emph{call\\hyp{}by\\hyp{}value}\\index{functional\n  language!call-by-value}.\\label{def:call-by-value} Unfortunately, it\nenables otherwise terminating programs to not terminate. For instance,\nlet us consider\n\\begin{equation*}\n\\fun{f}(x) \\xrightarrow{\\smash{\\alpha}} 0.\\qquad\n\\fun{g}() \\xrightarrow{\\smash{\\beta}} \\fun{g}().\n\\end{equation*}\nWe have \\(\\fun{f}(\\fun{g}()) \\xrightarrow{\\smash{\\alpha}} 0\\) but\n\\(\\fun{f}(\\fun{g}()) \\xrightarrow{\\smash{\\beta}} \\fun{f}(\\fun{g}())\n\\xrightarrow{\\smash{\\beta}} \\dots\\) Despite this inconvenience, we\nshall retain call\\hyp{}by\\hyp{}value because it facilitates some\nanalyses. (As an illustration of a reduction strategy more powerful\nthan call-by-value, see the purely functional language \\Haskell\n\\citep{DoetsVanEijck_2004}.) Also it allows us to restrict the shape\nof the left\\hyp{}hand sides, called \\emph{patterns}\\index{functional\n  language!pattern}, to one, outermost function call. For instance, we\ncan then disallow for being useless a rule like\n\\begin{equation*}\n\\fun{plus}(x,\\fun{plus}(y,z)) \\rightarrow\n\\fun{plus}(\\fun{plus}(x,y),z).\n\\end{equation*}\nIf the system is also terminating, we say that\n\\((\\twoheadrightarrow)\\) defines an \\emph{evaluation}\\index{functional\n  language!evaluation}, or \\emph{interpretation}\\index{functional\n  language!interpretation|see{evaluation}}, of the terms. For example,\nthe factorial\\index{factorial|(}\n\\fun{fact/1}\\index{fact@\\textsf{fact/1}} can be defined by the ordered\nsystem\n\\begin{equation}\n\\fun{fact}(0) \\rightarrow 1;\\qquad\n\\fun{fact}(n) \\rightarrow n \\cdot \\fun{fact}(n-1).\n\\label{def:fact}\n\\end{equation}\nThus \\(\\fun{fact}(n) \\twoheadrightarrow n!\\) and the system details\nhow to reduce step by step \\(\\fun{fact}(n)\\) to its value.\n\nMost functional languages allow \\emph{higher-order\n  function}\\index{functional language!higher-order functions}\ndefinitions, whereas standard term\\hyp{}rewriting systems do not. Such\nan example would be the following higher\\hyp{}order functional\nprogram, where \\(n \\in \\mathbb{N}\\):\n\\begin{equation*}\n\\fun{f}(g,0) \\rightarrow 1;\n\\qquad\n\\fun{f}(g,n) \\rightarrow n \\cdot g(g,n-1).\n\\qquad\n\\fun{fact}_1(n) \\rightarrow \\fun{f}(\\fun{f},n).\n\\end{equation*}\nNote that these two definitions are not recursive, yet\n\\fun{fact\\(_1\\)/1}\\index{fact1@\\textsf{fact$_1$/1}} computes the\nfactorial\\index{factorial}.\\index{factorial|)} An adequate theoretical\nframework to understand higher\\hyp{}order functions is the\n\\emph{\\(\\lambda\\)-calculus}\\hspace*{-2.1pt}\n\\citep{HindleySeldin_2008,VanLeeuwen_1990b}.\n\\index{lambda-calculus@$\\lambda$-calculus} In fact, the\n\\(\\lambda\\)-calculus features prominently in the semantics of\nprogramming languages, whether they are functional or not\n\\citep{Winskel_1993,Reynolds_1998,Pierce_2002,FriedmanWand_2008,TurbakGifford_2008}. Here,\nwe prefer to work with rewrite systems because they offer native\npattern matching, whilst in the\n\\(\\lambda\\)-calculus\\index{lambda-calculus@$\\lambda$-calculus} we\nwould have to encode it as a cascade of conditionals, which have\nthemselves to be encoded by means of more elementary constructs.\n\nIn the following, we show how to express linear data structures in a\npurely functional language and how to run our programs on a computer.\n\n\\paragraph{Stacks}\n\\label{par:stacks}\n\nLet us consider the abstract program\\index{cat@\\fun{cat/2}|(}\n\\index{cons@\\fun{cons/2}|(}\\index{nil@\\fun{nil/0}|(}\n\\begin{equation*}\n\\fun{cat}(\\fun{nil}(),t)     \\xrightarrow{\\smash{\\alpha}} t;\\qquad\n\\fun{cat}(\\fun{cons}(x,s),t) \\xrightarrow{\\smash{\\beta}}\n                                \\fun{cons}(x,\\fun{cat}(s,t)).\n\\end{equation*}\nIt defines the function \\fun{cat/2}\\index{cat@\\fun{cat/2}|)} that\ncatenates \\index{stack!catenation} two \\emph{stacks}. Functions\n\\fun{nil/0} and \\fun{cons/2} are \\emph{data\nconstructors}\\index{functional language!data constructor}, that is,\nfunctions that are \\emph{not} defined by any system: their irreducible\ncalls model data, so they are values and are allowed in patterns as\narguments. The function call \\(\\fun{nil}()\\) denotes the empty stack,\nand \\(\\fun{cons}(x,s)\\) is the stack obtained by putting the\nitem~\\(x\\) on top of the stack~\\(s\\), an action commonly referred as\n\\textsl{pushing~\\(x\\) on~\\(s\\)}. A non\\hyp{}empty stack can be thought\nof as a finite series of items that can only be accessed sequentially\nfrom the top, as suggested by the analogy with a stack of material\nobjects, like cubes or plates.\n\nLet~\\(T\\) be the set of all possible terms and \\(S \\subseteq T\\) be\nthe set of all stacks. Formally, \\(S\\)~can by defined by\n\\emph{induction}\\index{induction!definition by\n  $\\sim$}\\index{stack!inductive definition}\\index{inductive\n  definition|see{induction}} as the smallest set~\\(\\mathcal{S}\\) such\nthat\n\\begin{itemize}\n\n  \\item \\(\\fun{nil}() \\in \\mathcal{S}\\);\\label{def:stack}\n\n  \\item if \\(x \\in T\\) and \\(s \\in \\mathcal{S}\\), then\n    \\(\\fun{cons}(x,s) \\in \\mathcal{S}\\).\n\n\\end{itemize}\n\nNote that, in rule~\\(\\beta\\), if \\(s\\)~is not a stack, the recursion\nimplies that the function \\fun{cat/2} is partial, not because the\nrewrites never end, but because the normal form\\index{rewrite\n  system!normal form} is not a value. In operational terms, the\ninterpreter fails to rewrite the call for some arguments.\n\nLet us set the abbreviations\n\\begin{itemize}\n\n  \\item \\(\\el := \\fun{nil}()\\)\\index{nil@\\fun{nil/0}|)},\n\n  \\item \\(\\cons{x}{s} := \\fun{cons}(x,s)\\)\\index{cons@\\fun{cons/2}|)},\n\n\\end{itemize}\nafter the convention of the programming language \\Prolog\n\\citep{SterlingShapiro_1994,Bratko_2000}. For instance, we may write\n\\([1|[2|[3|\\el]]]\\) in stead of\n\\(\\fun{cons}(1,\\fun{cons}(2,\\fun{cons}(3,\\fun{nil}())))\\).  We can\nfurther abbreviate the notations as follows:\n\\begin{itemize}\n\n  \\item \\(\\cons{x_1,x_2,\\dots,x_n}{s} := \\cons{x_1}{\\cons{x_2}{\\dots\n      \\cons{x_n}{s}}}\\),\n\n  \\item \\([x] := \\cons{x}{\\el}\\).\n\n\\end{itemize}\nFor example, \\([1|[2|[3|\\el]]]\\) is more compactly written as\n\\([1,2,3]\\). Our system for \\fun{cat/2}\\index{cat@\\fun{cat/2}} now\nbecomes a bit more legible:\n\\begin{equation}\n\\fun{cat}(        \\el,t) \\xrightarrow{\\smash{\\alpha}} t;\\qquad\n\\fun{cat}(\\cons{x}{s},t) \\xrightarrow{\\smash{\\beta}}\n\\cons{x}{\\fun{cat}(s,t)}.\n\\label{def:cat}\\index{stack!catenation!definition}\n\\end{equation}\nFinally, let us illustrate it with the following\nevaluation:\\index{stack!catenation!example}\n\\begin{equation*}\n\\fun{cat}([1,2],[3,4])\n\\!\\xrightarrow{\\smash{\\beta}}\\!\n\\cons{1}{\\fun{cat}([2],[3,4])}\n\\!\\xrightarrow{\\smash{\\beta}}\\!\n\\cons{1}{\\cons{2}{\\fun{cat}(\\el,[3,4])}}\n\\!\\xrightarrow{\\smash{\\alpha}}\\!\n[1,2,3,4].\n\\end{equation*}\n\n\\paragraph{Abstract syntax trees}\n\nDepending on the context, we may use the arborescent depiction of\nterms to bring to the fore certain aspects of a computation. For\nexample, it may be interesting to show how parts of the output (the\nright\\hyp{}hand side) are actually \\emph{shared}\\index{sharing} with\nthe input (the left\\hyp{}hand side), or how much of the data remains\ninvariant through a given rule. The former notion supposes that terms\nreside in some sort of space and that they can be referred to from\nother terms. That abstract space serves as a model of a computer\n\\emph{memory}\\index{memory}. Consider for instance in\n\\fig~\\vref{fig:cat_dag} the same definition of~\\fun{cat/2} as given\nin~\\eqref{def:cat}. The arrows on certain edges denote some data\nsharing. When trees are used to visualise terms, they are called\n\\emph{abstract syntax trees}\\index{tree!abstract syntax $\\sim$}. When\nsome trees share subtrees, the whole forest is called a \\emph{directed\nacyclic graph}.\\index{directed acyclic graph} \\index{tree|see{directed\n    acyclic graph}}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[bb=73 654 300 720]{cat_dag}\n\\caption{Definition of \\fun{cat/2} with directed acyclic graphs\n\\label{fig:cat_dag}}\n\\end{figure}\n\n\\section{Analysis of algorithms}\n\nThe branch of theoretical informatics (or \\emph{computer science})\ndevoted to the mathematical study of the efficiency of programs has\nbeen pioneered by Donald Knuth, who named it \\emph{analysis of\n  algorithms} \\citep{SedgewickFlajolet_1996,Knuth_1997}. Given a\nfunction definition, this approach consists basically in three steps:\n\\begin{enumerate}\n\n  \\item defining a measure on the arguments, which represents their\n    size;\n\n  \\item defining a measure on time, which abstracts the\n    wall\\hyp{}clock time;\n\n  \\item expressing the abstract time needed to compute calls to that\n    function in terms of the size of its arguments.\n\n\\end{enumerate}\nThis function models the efficiency and is called the\n\\emph{cost}\\index{cost} (the lower the cost, the higher the\nefficiency). For example, when sorting objects, also called\n\\emph{keys}\\index{key|see{sorting}} in this context, by comparing\nthem, the input size is the number of keys and the abstract unit of\ntime is often one comparison, so the cost is the mathematical function\nwhich associates the number of keys and the number of comparisons to\nsort them.\n\n\n\\mypar{Exact cost}\n\nRewrite systems enable a rather natural notion of cost for functional\nprograms: it is the number of rewrites to reach the value of a\nfunction call, assuming that the arguments are values. In other words,\nit is the number of calls needed to compute the value. To gain some\ngenerality, we need to relate the cost to a measure of the size of the\ninput. In the case of stacks, this is the number of items it\ncontains. For instance, let us recall the catenation of two stacks in\ndefinition~\\eqref{def:cat}\\index{cat@\\fun{cat/2}}:\n\\begin{equation*}\n\\fun{cat}(        \\el,t) \\xrightarrow{\\smash{\\alpha}} t;\\qquad\n\\fun{cat}(\\cons{x}{s},t) \\xrightarrow{\\smash{\\beta}}\n\\cons{x}{\\fun{cat}(s,t)}.\n\\end{equation*}\nWe observe that \\(t\\)~is invariant, so the cost depends only on the\nsize of the first argument. Let\n\\(\\C{\\fun{cat}}{n}\\)\\index{cat@$\\C{\\fun{cat}}{n}$} be the cost of the\ncall \\(\\fun{cat}(s,t)\\)\\index{cat@\\fun{cat/2}}, where \\(n\\)~is the\nsize of~\\(s\\). Rules~\\(\\alpha\\) and~\\(\\beta\\) respectively lead to the\nequations\n\\begin{equation*}\n\\C{\\fun{cat}}{0} \\eqn{\\smash{\\alpha}} 1\\qquad\n\\C{\\fun{cat}}{n+1} \\eqn{\\smash{\\beta}} 1 + \\C{\\fun{cat}}{n}.\n\\end{equation*}\nwhich together yield \\(\\C{\\fun{cat}}{n} = n +\n1\\).\\label{cost:cat}\\index{stack!catenation!cost}\n\n\n\\mypar{Extremal costs}\n\\index{cost!extremal $\\sim$}\n\nWhen considering sorting programs based on comparisons, the cost\nvaries depending on the algorithm and it also often depends on the\noriginal partial ordering of the keys, thus size does not capture all\naspects needed to assess efficiency. This quite naturally leads to\nconsider bounds on the cost: for a given input size, we seek the\nconfigurations of the input that minimise and maximise the cost,\nrespectively called \\emph{best case} and \\emph{worst case}. For\nexample, some sorting algorithms have their worst case when the keys\nare already sorted, others when they are sorted in reverse order, etc.\n\n\n\\mypar{Average cost}\n\\label{par:mean_sort}\n\\index{cost!average $\\sim$}\n\\index{cost!mean $\\sim$|see{cost, average}}\n\nOnce we obtain bounds on a cost, the question about the \\emph{average}\nor \\emph{mean cost} \\citep{VitterFlajolet_1990}\n\\citep[\\S{}1.2.10]{Knuth_1997} arises as well. It is computed by\ntaking the arithmetic mean of the costs for all possible inputs of a\ngiven size. Some care is necessary, as there must be a finite number\nof such inputs. For instance, to assess the mean cost of sorting\nalgorithms based on comparisons, it is usual to assume that the input\nis a series of \\(n\\)~\\emph{distinct\nkeys}\\index{sorting!key!uniqueness} and that the sum of the costs is\ntaken over all its \\emph{permutations}\\index{permutation}, thus\ndivided by~\\(n!\\), the number of permutations of size~\\(n\\). The\nuniqueness constraint actually allows the analysis to equivalently,\nand more simply, consider the permutations of \\((1,2,\\dots,n)\\). Some\nsorting algorithms, like \\emph{merge sort}\n\\cite[\\S{}5.2.4]{Knuth_1998} \\cite[\\S{}2.3]{CLRS_2009} or\n\\emph{insertion sort} \\cite[\\S{}5.2.1]{Knuth_1998}\n\\cite[\\S{}2.1]{CLRS_2009}, have their average cost\n\\emph{asymptotically equivalent} to their maximum cost, that is, for\nincreasingly large numbers of keys, the ratio of the two costs become\narbitrarily close to~\\(1\\)\\index{cost!asymptotic $\\sim$}. Some others,\nlike \\emph{Quicksort} \\cite[\\S{}5.2.2]{Knuth_1998}\n\\cite[\\S{}7]{CLRS_2009}, have the growth rate of their average cost\nbeing of a lower magnitude than the maximum cost, on an asymptotic\nscale \\cite[\\S{}9]{GrahamKnuthPatashnik_1994}.\n\n\\paragraph{Online versus off-line}\n\\label{par:online_vs_offline}\n\nSorting algorithms can be distinguished depending on whether they\noperate on the whole series of keys, or key by key. The former are\nsaid \\emph{off\\hyp{}line}\\index{off-line algorithm}, as keys are not\nsorted while they are coming in, and the latter are called\n\\emph{online}\\index{online algorithm}, as the sorting process can be\ntemporally interleaved with the input process. For example, insertion\nsort is an online algorithm, whereas Quicksort is not because it is\nan instance of the divide\\hyp{}and\\hyp{}conquer strategy that splits\nthe whole data set. This distinction is pertinent in other contexts,\nas with algorithms that are intrinsically \\emph{sequential}, instead\nof enabling some degree of \\emph{parallelism}, e.g., a database is\nupdated by a series of atomic requests, but requests on\nnon\\hyp{}overlapping parts of the data might be performed in parallel.\n\n\\mypar{Amortised cost}\n\\label{par:amortised_cost}\n\nSometimes an update is costly because it is delayed by an imbalance in\nthe data structure that calls for an immediate remediation, but this\nremediation itself may lead to a state such that subsequent operations\nare faster than if the costly update had not happen. Therefore, when\nconsidering a series of updates, it may be overly pessimistic to\ncumulate the maximum costs of all the operations considered in\nisolation. Instead, \\emph{amortised\n  analysis} \\citep{Okasaki_1998a} \\citep[\\S{}17]{CLRS_2009}\\index{cost!amortised\n  $\\sim$}\\index{amortised analysis|see{cost, amortised}} takes into\naccount the interactions between updates, so a lower maximum bound on\nthe cost is derived. Note that this kind of analysis is inherently\ndifferent from the average case analysis, as its object is the\ncomposition of different functions instead of independent calls to the\nsame function on different inputs. Amortised analysis is a worst case\nanalysis of a sequence of updates, not of a single one.\n\n\n\\paragraph{Aggregate analysis}\n\\label{par:aggregate}\n\\index{aggregate cost|see{cost, amortised}}\n\\index{enumerative combinatorics}\n\nAs an example, let us consider a counter enumerating the integers\nfrom~\\(0\\) to~\\(n\\) in binary by updating an array containing bits\n\\cite[\\S{}17.1]{CLRS_2009}. In the worst case, an increment leads to\ninverting all the bits. The number~\\(m\\) of bits of~\\(n\\) can be found\nby setting \\(n := \\sum_{i=0}^{m-1}{b_i2^i}\\), where the~\\(b_i\\) are\nthe bits and \\(b_{m-1}=1\\). Then\n\\begin{equation}\n2^{m-1} \\leqslant n < 2^m \\Rightarrow m - 1 \\leqslant \\lg n\n< m \\Rightarrow m = \\floor{\\lg n} + 1,\n\\label{eq:num_of_bits}\n\\end{equation}\nwhere \\(\\floor{x}\\) (\\textsl{floor\n  of~\\(x\\)})\\index{floor@$\\floor{x}$|see{floor function}}\\index{floor\n  function} is the greatest integer less than or equal to~\\(x\\) and\n\\(\\lg n\\)~is the binary logarithm of~\\(n\\). The cost of the\n\\(n\\)~increments is thus bounded from above by \\(n\\lg n + n \\sim n\\lg\nn\\), as \\(n \\rightarrow \\infty\\).\n\n\\hspace*{-0.25pt} A little observation reveals that this upper bound\nis overly pessimistic, as carry propagation clears a series of\nrightmost bits to~\\(0\\), so the next addition will flip only one bit,\nthe following two etc. as shown in \\fig~\\vref{fig:flips}, where bits\nabout to be flipped at the next increment are set in boldface type.\n\\begin{figure}[t]\n\\centering\n\\subfloat[Bit flips\\label{fig:flips}]{\\includegraphics{flips}}\n\\qquad\n\\subfloat[$F(n) = \\sum_{i \\geqslant 0}\\floor{n/2^i}$, with $n=22$\\label{fig:ruler}]%\n{\\includegraphics{ruler}}\n\\caption{Counting bits vertically and diagonally}\n\\end{figure}\nCounting the flips \\emph{vertically} reveals that the bit\ncorresponding to~\\(2^0\\), that is, the rightmost bit, flips every\ntime. The bit of~\\(2^1\\) flips once every two increments, so, from\n\\(0\\)~to~\\(n\\), it flips \\(\\floor{n/2^1}\\)~times. In general, the bit\nof~\\(2^k\\) flips \\(\\floor{n/2^k}\\)~times. Therefore, the total number\nof flips~\\(F(n)\\) in a sequence of \\(n\\)~increments is\n\\begin{equation}\nF(n) := \\sum_{k \\geqslant 0}{\\left\\lfloor\\frac{n}{2^k}\\right\\rfloor}.\n\\label{eq:F}\n\\end{equation}\nThe sum is actually always finite, as illustrated by the example in\n\\fig~\\vref{fig:ruler}. There, we can see \\emph{diagonally} that\n\\(1\\)-bits at position~\\(j\\) appear in positions~\\(j-1\\) down\nto~\\(0\\), so account for \\(2^j + 2^{j-1} + \\dots + 2^0 = 2^{j+1}-1\\).\nIn all generality, let \\(n := 2^{e_r} + \\dots + 2^{e_1} + 2^{e_0} >\n0\\), with \\(e_r > \\dots > e_1 > e_0 \\geqslant 0\\) and \\(r \\geqslant\n0\\). The naturals \\(e_i\\)~are the positions of the \\(1\\)-bits in the\nbinary notation of~\\(n\\). The power \\(2^{e_r}\\) corresponds to the\nleftmost bit in the binary expansion of~\\(n\\), so \\(e_r+1\\)~is equal\nto the number of bits of~\\(n\\), which is known from\nequation~\\eqref{eq:num_of_bits}:\n\\begin{equation}\ne_r = \\floor{\\lg n}.\\label{eq:e_r}\n\\end{equation}\nWe can now give a closed form for \\(F(n)\\) as follows:\n\\begin{equation}\nF(n) = \\sum_{i=0}^{r}(2^{e_i+1} - 1) = 2n - \\nu_n,\n\\label{eq:ruler_nu}\n\\end{equation}\nwhere \\(\\nu_n := r + 1\\)\\index{bit sum@$\\nu_n$|see{bit sum}} is the\nsum of the bits of~\\(n\\), or, equivalently, the number of\n\\(1\\)-bits. It is called many names, like \\emph{population count},\n\\emph{sideways sum}, \\emph{bit sum}\\index{bit sum} or \\emph{Hamming\n  weight}; for example, in \\fig~\\vref{fig:ruler}, we can read \\(F(22)\n= 41 = 2 \\cdot 22 - 3\\). Furthermore, we have the following intuitive\ntight bounds for any \\(n>0\\):\n\\begin{equation*}\n1 \\leqslant \\nu_{n} \\leqslant \\floor{\\lg n} + 1,\n\\end{equation*}\nbecause equality~\\eqref{eq:e_r} establishes that \\(\\floor{\\lg n} + 1\\)\nis the number of bits of~\\(n\\). Therefore, \\(2n - \\floor{\\lg n} - 1\n\\leqslant F(n) \\leqslant 2n\\). By l'Hospital rule, \\(\\lim_{n \\to\n  +\\infty}{(\\lg n/n)} = \\lim_{n \\to +\\infty}(1/n\\ln 2) = 0\\), where\n\\(\\ln n\\)~is the \\emph{natural logarithm}. Therefore,\n\\begin{equation*}\nF(n) \\sim 2n,\\;\\, \\text{as \\(n \\rightarrow \\infty\\)}.\n\\end{equation*}\nTwo enumerations (counting vertically and diagonally) have shown that\nthe exact total number of flips is of a lower magnitude than expected.\n\nThis example resorts to a particular kind of amortised analysis called\n\\emph{aggregate analysis}, because it relies on enumerative\ncombinatorics \\citep{Stanley_1999a,Stanley_1999b,Martin_2001} to reach\nits result (it aggregates positive partial amounts, often in different\nmanners, to obtain the total cost). A visually appealing variation on\nthe previous example consists in determining the average number of\n\\(1\\)-bits in the binary notation of the integers from~\\(0\\) to~\\(n\\)\n\\citep{Bush_1940}.\n\n\\section{Inductive proofs}\n\nLet us notice that \\(\\fun{cat}([1], [2,3,4]) \\twoheadrightarrow\n[1,2,3,4] \\twoheadleftarrow \\fun{cat}([1,2],\n[3,4])\\)\\index{cat@\\fun{cat/2}|(}. It is enlightening to create\n\\emph{equivalence classes} of terms that are joinable. These classes\nthen define an equivalence relationship~\\((\\equiv)\\)\n\\index{equivalence@$a \\equiv b$|see{equivalence of expressions}}\n\\index{equivalence!$\\sim$ of expressions} as follows:\n\\begin{center}\n  \\(a \\equiv b\\) if there exists a value~\\(v\\) such that \\(a\n  \\xrightarrow{\\smash[t]{*}} v\\) and \\(b \\xrightarrow{\\smash{*}} v\\).\n\\end{center}\nFor instance, \\(\\fun{cat}([1,2], [3,4]) \\equiv \\fun{cat}([1],\n[2,3,4])\\). The relation (\\(\\equiv\\)) is indeed an equivalence\nbecause it is\n\\begin{itemize*}\n\n  \\item \\emph{reflexive}: \\(a \\equiv a\\);\n\n  \\item \\emph{symmetric}: if \\(a \\equiv b\\), then \\(b \\equiv a\\);\n\n  \\item \\emph{transitive}: if \\(a \\equiv b\\) and \\(b \\equiv c\\), then\n    \\(a \\equiv c\\).\n\n\\end{itemize*}\n%% Of some interest are the following facts. If \\(f(x)\\) and~\\(f(y)\\)\n%% have a value, then \\(x \\equiv y\\) implies \\(f(x) \\equiv f(y)\\). If\n%% \\(x_1 \\leftarrow x_2 \\twoheadrightarrow x_3 \\equiv x_4 \\rightarrow x_5\n%% \\twoheadleftarrow x_6\\), then \\(x_1 \\equiv x_2 \\equiv x_3 \\equiv x_4\n%% \\equiv x_5 \\equiv x_6\\). In the case \\(x \\twoheadrightarrow z\n%% \\xrightarrow{\\smash{\\alpha}} t \\twoheadleftarrow y\\), we use the\n%% special notation \\(x \\Rra{\\alpha} y\\) to underline the role played by\n%% rule~\\(\\alpha\\) in the equivalence, instead of simply \\(x \\equiv y\\).\n\nIf we want to prove equivalences with variables ranging over\ninfinite sets, like \\(\\fun{cat}(s,\\fun{cat}(t,u)) \\equiv\n\\fun{cat}(\\fun{cat}(s,t),u)\\)\\index{cat@\\fun{cat/2}|)}, we need some\ninduction principle.\n\n\n\\mypar{Well-founded induction}\n\\label{par:well-founded}\n\\index{induction!well-founded $\\sim$}\n\nWe define a \\emph{well\\hyp{}founded order}\n\\citep{Winskel_1993}\\index{induction!well-founded order} on a\nset~\\(A\\) as being a binary relation \\((\\succ)\\) which does not have\nany \\emph{infinite descending chains}\\index{induction!infinite\n  descending chain}, to wit, no \\(a_0 \\succ a_1 \\succ \\dots\\) The\n\\emph{well\\hyp{}founded induction principle} then states that, for any\npredicate~\\(\\aleph\\),\n\\begin{center}\n  \\(\\forall a \\in A.\\aleph(a)\\) is implied by \\(\\forall a.(\\forall b.a\n  \\succ b \\Rightarrow \\aleph(b)) \\Rightarrow \\aleph(a)\\).\n\\end{center}\nBecause there are no infinite descending chains, any\nsubset \\(B \\subseteq A\\) contains minimal elements \\(M \\subseteq B\\),\nthat is, there is no \\(b \\in B\\) such that \\(a \\succ b\\), if \\(a \\in\nM\\). In this case, proving by well\\hyp{}founded induction degenerates\ninto proving \\(\\aleph(a)\\) for all \\(a \\in M\\). When \\(A=\\mathbb{N}\\),\nthis principle is called \\emph{mathematical (complete) induction}\n\\citep{Buck_1963}\\index{induction!mathematical\n  $\\sim$}. \\emph{Structural induction}\\index{induction!structural\n  $\\sim$} is another particular case where \\(t \\succ s\\) holds if, and\nonly if, \\(s\\)~is a proper\n\\emph{subterm}\\index{term!subterm}\\index{term!proper subterm}\nof~\\(t\\), namely, the abstract syntax tree of~\\(s\\) is included in the\ntree of~\\(t\\) and \\(s \\neq t\\).\n\nSometimes, a restricted form is enough. For instance, we can define\n\\(\\cons{x}{s} \\succ s\\)\\index{cons@\\fun{cons/2}}, for any term~\\(x\\)\nand any stack~\\(s \\in S\\). Both \\(x\\)~and~\\(s\\) are \\emph{immediate\n  subterms}\\index{term!immediate subterm} of\n\\(\\cons{x}{s}\\)\\index{cons@\\fun{cons/2}}. There is no infinite\ndescending chain since \\(\\el\\)~is the unique minimal element of~\\(S\\):\nno~\\(s\\) satisfies \\(\\el \\succ s\\); so the basis is \\(t=\\el\\) and\n\\(\\forall t.(\\forall s.t \\succ s \\Rightarrow \\aleph(s)) \\Rightarrow\n\\aleph(t)\\) degenerates into \\(\\aleph(\\el)\\).\n\n\\mypar{Termination}\n\\label{par:ackermann}\nWhen defining our purely functional language, we allowed programs to\nnot terminate. We could actually have imposed some syntactic\nrestrictions on recursive definitions in order to guarantee the\ntermination of all functions. A well\\hyp{}known class of such\nterminating functions makes exclusively use of a bridled form of\nrecursion called \\emph{primitive recursion}\n\\citep{Robinson_1947,Robinson_1948}\\index{termination!primitive\n  recursion}.\n\nUnfortunately, many useful functions do not fit, easily or at all, in\nthis framework and, as a consequence, most functional languages leave\nto the programmers the responsibility to check the termination of\ntheir programs. For theoretical reasons, it is not possible to provide\na general criterion for termination, but some rules exist that cover\nmany usages.\n\nConsider the following example where \\(m,n \\in \\mathbb{N}\\):\n\\begin{equation*}\n\\begin{array}{@{}r@{\\;}l@{\\;}l@{}}\n\\fun{ack}(0,n)     & \\xrightarrow{\\smash{\\theta}} & n+1;\\\\\n\\fun{ack}(m+1,0)   & \\xrightarrow{\\smash{\\iota}}  & \\fun{ack}(m,1);\\\\\n\\fun{ack}(m+1,n+1) & \\xrightarrow{\\smash{\\kappa}}\n                   & \\fun{ack}(m,\\fun{ack}(m+1,n)).\n\\end{array}\n\\end{equation*}\nThis is a simplified form of Ackermann's\nfunction\\index{termination!Ackermann's\n  function}\\index{ack@\\fun{ack/2}|(}, an early example of a total\ncomputable function which is not primitive recursive. It makes use of\ndouble recursion and two parameters to grow values as towers of\nexponents, for example, \\(\\fun{ack}(4,3) \\twoheadrightarrow\n2^{2^{65536}} - 3\\). It is not obviously terminating, because if the\nfirst argument does decrease, the second largely increases.\n\nLet us define a well\\hyp{}founded ordering on pairs, called\n\\emph{lexicographic order}\\index{induction!lexicographic order}. Let\n\\((\\succ_A)\\) and \\((\\succ_B)\\) be well\\hyp{}founded orders on the\nsets \\(A\\) and~\\(B\\). Then \\((\\succ_{A \\times B})\\) defined as follows\non \\(A \\times B\\) is well\\hyp{}founded:\n\\begin{equation}\n(a_0,b_0) \\succ_{A \\times B} (a_1,b_1) :\\Leftrightarrow \\text{\\(a_0\n    \\succ_A a_1\\) or (\\(a_0 = a_1\\) and \\(b_0 \\succ_B b_1\\)).}\n\\label{def:lexico}\n\\end{equation}\nIf \\(A=B=\\mathbb{N}\\) then \\((\\succ_A) = (\\succ_B) = (>)\\). To prove\nthat \\(\\fun{ack}(m,n)\\) terminates for all \\(m,n \\in \\mathbb{N}\\),\nfirst, we must find a well\\hyp{}founded order on the calls\n\\(\\fun{ack}(m,n)\\), that is, the calls must be totally ordered without\nany infinite descending chain. Here, a lexicographic order on \\((m,n)\n\\in \\mathbb{N}^2\\) extended to \\(\\fun{ack}(m,n)\\) works:\n\\begin{equation*}\n\\fun{ack}(a_0,b_0) \\succ \\fun{ack}(a_1,b_1) :\\Leftrightarrow\n\\text{\\(a_0 > a_1\\) or (\\(a_0 = a_1\\) and \\(b_0 > b_1\\)).}\n\\end{equation*}\nClearly, \\(\\fun{ack}(0,0)\\) is the minimum element. Second, we must\nprove that \\fun{ack/2} rewrites to smaller calls. We are only\nconcerned with rules \\(\\iota\\)~and~\\(\\kappa\\). With the former, we\nhave \\(\\fun{ack}(m+1,0) \\succ \\fun{ack}(m,1)\\). With the latter, we\nhave\n\\begin{equation*}\n  \\begin{array}{@{}r@{\\;}l@{\\;}l@{}}\n    \\fun{ack}(m+1,n+1) & \\succ & \\fun{ack}(m+1,n),\\\\\n    \\fun{ack}(m+1,n+1) & \\succ & \\fun{ack}(m,p),\n  \\end{array}\n\\end{equation*}\nfor all values~\\(p\\), in particular when \\(\\fun{ack}(m+1,n)\n\\twoheadrightarrow p\\)\\index{ack@\\fun{ack/2}|)}.\\hfill\\(\\Box\\)\n\nA series of examples of termination\\index{termination}\\index{rewrite\n  system!termination} proofs for term\\hyp{}rewriting systems has been\npublished by \\cite{Dershowitz_1995,ArtsGiesl_2001}. An accessible\nsurvey is provided by \\cite{Dershowitz_1987}. \\cite{Knuth_2000a}\nanalysed some famously involved recursive functions.\n\n\\paragraph{Associativity}\n\\label{proof:assoc_cat}\n\nLet us recall the definition~\\eqref{def:cat} of the catenation of two\nstacks:\n\\begin{equation*}\n\\fun{cat}(        \\el,t) \\xrightarrow{\\smash{\\alpha}} t;\\qquad\n\\fun{cat}(\\cons{x}{s},t) \\xrightarrow{\\smash{\\beta}}\n\\cons{x}{\\fun{cat}(s,t)}.\n\\index{stack!catenation!definition}\n\\end{equation*}\nand let us prove the\nassociativity\\index{stack!catenation!associativity}\n\\index{induction!example} of \\fun{cat/2}\\index{cat@\\fun{cat/2}}, which\nwe express formally as\n\\begin{equation*}\n  \\pred{CatAssoc}{s,t,u} \\colon\n\\fun{cat}(s,\\fun{cat}(t,u)) \\equiv\n\\fun{cat}(\\fun{cat}(s,t),u)\n\\index{CatAssoc@\\predName{CatAssoc}|(}\n\\end{equation*}\nwhere \\(s\\), \\(t\\) and~\\(u\\) are stack values.\n\nThe goal here is to use the rewrite system as an abstract machine to\nprove a property, with the timely help of the induction\nprinciple. Precisely, we want to rewrite each side of the equivalence\nwe wish to prove until we either find the same term (equality), or we\nuse the induction hypothesis (equivalence). We want to be free to\nchoose a rewrite amongst those possible for a term, and this freedom\nis entailed by the termination and the confluence of the rewrite\nsystem defining the functions, which we assume here.\n\nWe apply the well\\hyp{}founded induction principle to the structure\nof~\\(s\\), so we must establish\n\\begin{itemize}\n\n  \\item the basis \\(\\forall t,u \\in S.\\pred{CatAssoc}{\\el,t,u}\\);\n\n  \\item step \\(\\forall s,t,u \\in S.\\pred{CatAssoc}{s,t,u}\n    \\Rightarrow \\forall x \\in T.\\pred{CatAssoc}{\\cons{x}{s},t,u}\\).\n\n\\end{itemize}\nThe base case is direct:\n\\begin{equation*}\n  \\fun{cat}(\\el,\\fun{cat}(t,u))\n\\xrightarrow{\\smash{\\alpha}} \\fun{cat}(t,u)\n\\xleftarrow{\\smash{\\alpha}}\n\\fun{cat}(\\fun{cat}(\\el,t),u).\n\\index{cat@\\fun{cat/2}}\n\\end{equation*}\nLet us assume now \\(\\pred{CatAssoc}{s,t,u}\\), called the\n\\emph{induction hypothesis}\\index{induction!$\\sim$ hypothesis}, and\nlet us prove\n\\(\\pred{CatAssoc}{\\cons{x}{s},t,u}\\)\\index{CatAssoc@\\predName{CatAssoc}|)},\nfor any term~\\(x\\). We have\n\\begin{equation*}\n\\begin{array}{r@{\\;}l@{\\;}l@{\\qquad}r@{}}\n  \\fun{cat}(\\cons{x}{s},\\fun{cat}(t,u))\n& \\xrightarrow{\\smash\\beta}\n& \\cons{x}{\\fun{cat}(s,\\fun{cat}(t,u))}\\\\\n& \\equiv\n& \\cons{x}{\\fun{cat}(\\fun{cat}(s,t),u)}\n& (\\pred{CatAssoc}{s,t,u})\\\\\n& \\xleftarrow{\\smash\\beta}\n& \\fun{cat}(\\cons{x}{\\fun{cat}(s,t)},u)\\\\\n& \\xleftarrow{\\smash\\beta}\n& \\fun{cat}(\\fun{cat}(\\cons{x}{s},t),u).\\index{cat@\\fun{cat/2}}\n\\end{array}\n\\end{equation*}\nThus\\index{CatAssoc@\\predName{CatAssoc}}\n\\(\\pred{CatAssoc}{\\cons{x}{s},t,u}\\) holds and \\(\\forall s,t,u \\in\nS.\\pred{CatAssoc}{s,t,u}\\)\\index{CatAssoc@\\predName{CatAssoc}}.\\hfill\\(\\Box\\)\n\nNote that we matched here an expression, namely\n\\(\\fun{cat}(\\cons{x}{s},\\fun{cat}(t,u))\\), instead of a value, as is\nnormally done with the call\\hyp{}by\\hyp{}value evaluation strategy,\nbecause we work with equivalences and we assumed that the system is\nterminating and confluent, so any reduction strategy will do.\n\n\n\\section{Implementation}\n\\label{sec:implementation}\n\n\\mypar{Translation to \\Erlang}\n\\index{functional language!Erlang@\\Erlang}\n\nIt is always enjoyable to have computers actually evaluate our\nfunction calls. We briefly introduce here \\Erlang, a functional\nlanguage that contains a pure core \\citep{Armstrong_2007}. A\n\\emph{module} is a collection of function definitions. The syntax of\n\\Erlang is very close to our formalism and our previous rewrite\nsystems become\\index{stack!catenation!$\\sim$ in\n  \\Erlang}\\index{factorial}\n\\begin{verbatim}\n-module(mix).\n-export([cat/2,fact/1]).\n\ncat(   [],T) -> T;\ncat([X|S],T) -> [X|cat(S,T)].\n\nfact(N) -> f(fun f/2,N).\n\nf(_,0) -> 1;\nf(G,N) -> N * G(G,N-1).\n\\end{verbatim}\nThe differences are the headers and the lexical conventions of setting\nvariables in big capitals and to mute unused variables in patterns\nwith an underscore (\\verb|_|). Moreover, the expression \\verb|fun f/2|\ndenotes~\\fun{f/2} when used in stead of a value. From the \\Erlang\nshell, we can compile and run some examples:\n\\begin{verbatim}\n1> c(mix).\n{ok,mix}\n2> mix:cat([1,2,3],[4,5]).\n[1,2,3,4,5]\n3> mix:fact(30).\n265252859812191058636308480000000\n\\end{verbatim}\nNote that \\Erlang features exact integer arithmetic and that the order\nof the definitions is irrelevant.\n\n\\mypar{Translation to \\Java}\n\\label{par:java}\n\\index{Java@\\Java|(}\n\nFunctional programs on stacks can be systematically translated into\n\\Java, following designs similar to those initially published\nby \\cite{FelleisenFriedman_1997}, \\cite{Bloch_2003}\nand \\cite{Sher_2004}. This operation should transfer some interesting\nproperties proved on the source to the target language: the whole\npoint hinges on how the mathematical approach presented earlier, both\nwith structural induction and functional programming, leads to trusted\n\\Java programs and, therefore, constitutes a solid bridge between\nmathematics and computer science.\n\nOf course, the programs discussed in this book are extremely short and\nthe topic at hand thus resorts to ``programming in the small'', but,\nfrom the vantage point of software engineering, these functional\nprograms can then be considered as \\emph{formal specifications} of the\n\\Java programs, and inductive proofs may be thought as instances of\n\\emph{formal methods}, like the ones used to certify telecommunication\nprotocols and critical embedded systems. Therefore, this book may be\nused as a prerequisite to a software engineering course, but also to\nan advanced programming course.\n\n\\paragraph{Design Pattern}\n\nThe design pattern in \\Java which models a stack \\index{stack!$\\sim$\n  in \\Java} relies on polymorphic methods, recursive classes and\ngenerics. A generic and abstract class \\texttt{Stack} captures the\nessence of a stack as follows:\n\\begin{alltt}\n// Stack.java\n\\public \\abstractX \\class Stack<Item> \\{\n  \\public \\final NStack<Item> push(\\final Item item) \\{\n    \\return \\new NStack<Item>(item,\\this); \\}\n\\}\n\\end{alltt}\nA stack is empty or not and the class \\texttt{Stack} is abstract\nbecause it asserts that both are stacks and that they share common\nfunctionalities, like the method \\texttt{push}, which is a wrapper\naround the constructor of non\\hyp{}empty stacks, \\texttt{NStack}, so\nboth empty and non\\hyp{}empty stacks are augmented by the same\nmethod. The argument \\texttt{item} of \\texttt{push} is declared\n\\final{} because we want it to be constant in the body of the method,\nfollowing the functional paradigm. The empty stack~\\(\\el\\) is mapped\nto an extension \\texttt{EStack} of \\texttt{Stack}, capturing the\nrelationship ``An empty stack is a stack.'' The class \\texttt{EStack}\ncontains no data.\n\\begin{alltt}\n// EStack.java\n\\public \\final \\class EStack<Item> \\extends Stack<Item> \\{\\}\n\\end{alltt}\nThe non\\hyp{}empty stack is logically encoded by \\texttt{NStack},\nanother subclass of \\texttt{Stack}:\n\\begin{alltt}\n// NStack.java\n\\public \\final \\class NStack<Item> \\extends Stack<Item> \\{\n  \\private \\final Item head;\n  \\private \\final Stack<Item> tail;\n\n  \\public NStack(\\final Item item, \\final Stack<Item> stack) \\{\n    head = item; tail = stack; \\}\n\\}\n\\end{alltt}\nThe field \\texttt{head} models the first item of a stack and\n\\texttt{tail} corresponds to the rest of the stack (so \\texttt{NStack}\nis a recursive class). The constructor just initialises\nthese. Importantly, both are declared \\texttt{final} to express that\nwe do not expect reassignments after the first instantiation. Just as\nin our functional language, every time a new stack is needed, instead\nof modifying another with a side\\hyp{}effect, a new one is created,\nperhaps reusing others as constant components.\n\n\\paragraph{Catenation of stacks}\n\nAs an illustration\\index{stack!catenation!$\\sim$ in \\Java|(}, let us\nrecall definition~\\eqref{def:cat} \\vpageref{def:cat}\n\\index{cat@\\fun{cat/2}|(} for catenating two stacks:\n\\begin{equation*}\n\\fun{cat}(        \\el,t) \\xrightarrow{\\smash{\\alpha}} t;\\qquad\n\\fun{cat}(\\cons{x}{s},t) \\xrightarrow{\\smash{\\beta}}\n                                          \\cons{x}{\\fun{cat}(s,t)}.\n\\end{equation*}\nThe translation into our \\Java class hierarchy is as follows. The\nfirst argument of \\fun{cat/2} is a stack, corresponding to\n\\texttt{this} inside our classes \\texttt{EStack} and\n\\texttt{NStack}. Therefore, the translation of \\fun{cat/2} is an\nabstract \\Java method in class \\texttt{Stack}, with one parameter (the\nsecond of \\fun{cat/2}):\n\\begin{alltt}\n\\public \\abstractX Stack<Item> cat(\\final Stack<Item> t);\n\\end{alltt}\nRule~\\(\\alpha\\) applies only if the current object represents~\\(\\el\\),\nso the corresponding translation is a method of\n\\texttt{EStack}. Dually, rule~\\(\\beta\\) leads to a method of\n\\texttt{NStack}. The former returns its argument, so the translation\nis\n\\begin{alltt}\n\\public Stack<Item> cat(\\final Stack<Item> t) \\{ \\return t; \\}\n\\end{alltt}\nThe latter returns an object of~\\texttt{NStack} corresponding to\n\\(\\cons{x}{\\fun{cat}(s,t)}\\). It is built by translating this stack\nfrom the bottom up: translate\n\\(\\fun{cat}(s,t)\\)\\index{cat@\\fun{cat/2}|)} and then push~\\(x\\). Let\nus recall that \\(s\\)~is the tail of \\(\\cons{x}{s}\\) on the\nleft\\hyp{}hand side of rule~\\(\\beta\\), hence \\(\\cons{x}{s}\\) is\n\\texttt{this} and \\(s\\)~corresponds to \\texttt{this.tail}, or, simply,\n\\texttt{tail}. Similarly, \\(x\\)~is~\\texttt{head}. Finally,\n\\begin{alltt}\n\\public NStack<Item> cat(\\final Stack<Item> t) \\{\n  \\return tail.cat(t).push(head);\n\\}\n\\end{alltt}\n\\index{stack!catenation!$\\sim$ in \\Java|)}\n\\index{Java@\\Java|)}\n", "meta": {"hexsha": "3e8472ba07b566d19e781bc92981eaaf8ccbda60", "size": 49963, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "introduction.tex", "max_stars_repo_name": "rinderknecht/Book", "max_stars_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "introduction.tex", "max_issues_repo_name": "rinderknecht/Book", "max_issues_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "introduction.tex", "max_forks_repo_name": "rinderknecht/Book", "max_forks_repo_head_hexsha": "6f302ab1319c8ae9b3ea690c45fdb3d2b6fbca16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0064456722, "max_line_length": 90, "alphanum_fraction": 0.7237355643, "num_tokens": 15422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.43544670127859614}}
{"text": "  \\documentclass{mynotes}\n\n%\\geometry{showframe}% for debugging purposes -- displays the margins\n\n\\newcommand{\\E}{\\mbox{E}}\n\n\\usepackage{amsmath}\n%\\usepackage[garamond]{mathdesign}\n\\usepackage{url}\n\n% Set up the images/graphics package\n\\usepackage{graphicx}\n\\setkeys{Gin}{width=\\linewidth,totalheight=\\textheight,keepaspectratio}\n\\graphicspath{{graphics/}}\n\n\\title[Lesson 1 $\\cdot$ SDS 383D]{Exercises 2: Generalized linear models}\n%\\author[ ]{ }\n\\date{}  % if the \\date{} command is left out, the current date will be used\n\n% The following package makes prettier tables.  We're all about the bling!\n\\usepackage{booktabs}\n\n% The units package provides nice, non-stacked fractions and better spacing\n% for units.\n\\usepackage{units}\n\n% The fancyvrb package lets us customize the formatting of verbatim\n% environments.  We use a slightly smaller font.\n\\usepackage{fancyvrb}\n\\fvset{fontsize=\\normalsize}\n\n% Small sections of multiple columns\n\\usepackage{multicol}\n\n% Provides paragraphs of dummy text\n\\usepackage{lipsum}\n\n% These commands are used to pretty-print LaTeX commands\n\\newcommand{\\doccmd}[1]{\\texttt{\\textbackslash#1}}% command name -- adds backslash automatically\n\\newcommand{\\docopt}[1]{\\ensuremath{\\langle}\\textrm{\\textit{#1}}\\ensuremath{\\rangle}}% optional command argument\n\\newcommand{\\docarg}[1]{\\textrm{\\textit{#1}}}% (required) command argument\n\\newenvironment{docspec}{\\begin{quote}\\noindent}{\\end{quote}}% command specification environment\n\\newcommand{\\docenv}[1]{\\textsf{#1}}% environment name\n\\newcommand{\\docpkg}[1]{\\texttt{#1}}% package name\n\\newcommand{\\doccls}[1]{\\texttt{#1}}% document class name\n\\newcommand{\\docclsopt}[1]{\\texttt{#1}}% document class option name\n\n\\newcommand{\\N}{\\mbox{N}}\n\\newcommand{\\thetahat}{\\hat{\\theta}}\n\\newcommand{\\sigmahat}{\\hat{\\sigma}}\n\\newcommand{\\betahat}{\\hat{\\beta}}\n\n\n\\begin{document}\n\n\\maketitle% this prints the handout title, author, and date\n\n\\section{Exponential families}\n\nWe say that a distribution $f(y \\mid \\theta, \\phi)$ is in an exponential family if we can write its PDF or PMF in the form\n$$\nf(y; \\theta, \\phi) = \\exp \\left\\{ \\frac{y \\theta - b(\\theta)}{a(\\phi)} + c(y; \\phi)   \\right \\}\n$$\nfor some known functions $a$, $b$ and $c$.  We refer to $\\theta$ as the canonical parameter of the family, and to $\\phi$ as the dispersion parameter.  \n\n\\begin{enumerate}[(A)]\n\n\\item Starting from the ``standard'' form of each PDF/PMF, show that the following distributions are in an exponential family, and find the corresponding $b$, $c$, $\\theta$, and $a(\\phi)$.  \n\n\\begin{itemize}\n\\item $Y \\sim N(\\mu, \\sigma^2)$ for known $\\sigma^2$.  \n\\item $Y = Z/N$ where $Z \\sim \\mbox{Binom}(N, P)$ for known $N$.   \n\\item $Y \\sim \\mbox{Poisson}(\\lambda)$  \n\\end{itemize}\n\n\\item We want to characterize the mean and variance of an exponential family, but to do this simply, we need a preliminary lemma (that holds for all distributions, not just the exponential family).  Define the \\emph{score} $s(\\theta)$ as the gradient of the log likelihood:\n$$\ns(\\theta) = \\frac{\\partial}{\\partial \\theta} \\log L(\\theta) \\, , \\quad L(\\theta) = \\sum_{i=1}^n f(y_i; \\theta) \\, ;\n$$\nwe've written this in multivariate form for the sake of generality, but of course it just involves an ordinary partial derivative (w.r.t.~$\\theta$) in case where $\\theta$ is one-dimensional.  Let's also define $H(\\theta)$ as the Hessian matrix, i.e.~the matrix of second partial derivatives of the log likelihood:\n$$\nH(\\theta) = \\frac{\\partial}{\\partial \\theta^T} s(\\theta) =   \\frac{\\partial^2}{ \\partial \\theta \\partial \\theta^T} \\log L(\\theta)\n$$\n\nWhile we think of the score as a function of $\\theta$, clearly (like the likelihood) it also depends on the data.  So a natural question is: what can we say about the \\emph{distribution} of the score over different random realizations of the data under the true data-generating process, i.e.~at the true $\\theta$?  It turns out we can say the following, sometimes referred to as the score equations:  \n$$\n\\begin{aligned}\nE\\{ s(\\theta) \\} &= 0 \\\\\n\\mbox{var} \\{ s(\\theta) \\} &= - E \\left\\{ H(\\theta) \\right\\}\n\\end{aligned}\n$$\nwhere the mean and variance are taken under the true $\\theta$.  \\textbf{Prove the score equations.}  Hints: prove the first equation first.  You can assume that it's OK to switch the order of differentiation and integration (i.e.~that any necessary technical conditions are met).  To prove the second equation, differentiate both sides of the first equation with respect to $\\theta^T$ and switch the order of differentiation and integration again.  Expand out and simplify.  \n\n\\item Use the score equations you just proved to show that, if $Y \\sim f(y; \\theta, \\phi)$ is in an exponential family, then\n$$\n\\begin{aligned}\nE\\{ Y \\} &=  b'(\\theta) \\\\\n\\mbox{var} \\{ Y \\} &= a(\\phi) b''(\\theta) \n\\end{aligned}\n$$\n\nThus the variance of $Y$ is a product of two terms.  One of these terms, $b''(\\theta)$, depends only on the canonical parameter $\\theta$, and hence on the mean, since you showed that $E\\{ Y \\} =  b'(\\theta)$.  The other, $a(\\phi)$, is independent of $\\theta$.  Note that the most common form of $a$ is $a(\\phi) = \\phi/w$, where $\\phi$ is called a dispersion parameter and where $w$ is a known prior weight that can vary from one observation to another.  \n\n\\item To convince yourself that your result in $(C)$ is correct, use these results to compute the mean and variance of the $N(\\mu, \\sigma^2)$ distribution.  \n\n\\end{enumerate}\n\n\n\\section{Generalized linear models}  \n\nSuppose we observe data like in the typical regression setting: that is, pairs $\\{y_i, x_i\\}$ where $y_i$ is a scalar response for case $i$, and $x_i$ is a $p$-vector of predictors or features for that same case $i$.  We say that the $y_i$'s follow a \\textit{generalized linear model} (GLM) if two conditions are met.  First, the PDF (or PMF, if discrete) can be written as:  \n$$\nf(y_i; \\theta_i,  \\phi)  = \\exp \\left\\{ \\frac{y_i \\theta_i - b(\\theta_)}{\\phi/w_i} + c(y_i; \\phi/w_i)   \\right \\}\n$$\nwhere the weights $w_i$ are all known.  This is referred to as a the stochastic or random component of the model.  Second, for some known invertible function $g$ we have\n$$\ng(\\mu_i) = x_i^T \\beta\n$$\nwhere $\\mu_i = E(Y_i; \\theta_i, \\phi)$.  This is the systematic component of the model, and $g$ is referred to as a link function, since it links the mean of the response $\\mu_i$ with the \\emph{linear predictor} $\\eta_i = x_i^T \\beta$.  \n\n\n\\begin{enumerate}[(A)]\n\n\\item Deduce from your results above that, in a GLM,\n $$\n\\begin{aligned}\n\\theta_i &= (b')^{-1} \\left\\{g^{-1}(x_i^T \\beta) \\right\\} \\\\\n\\mbox{var} \\{ Y_i \\} &= \\frac{\\phi}{w_i} V(\\mu_i)\n\\end{aligned}\n$$\nfor some function $V$ that you should specify in terms of the building blocks of the exponential family model.  $V$ is often referred to as a the \\emph{variance function}, since it explicitly relates the mean and the variance in a GLM.  \n\n\\item Take two special cases.  \n\\begin{enumerate}[(1)]\n\\item Suppose that $Y$ is a Poisson GLM, i.e. that the stochastic component of the model is a Poisson distribution.  Show that $V(\\mu) = \\mu$.\n\\item Suppose that $Y = Z/N$ is a Binomial GLM, i.e. that the stochastic component of the model is a Binomial distribution $Z \\sim \\mbox{Binom}(N, P)$.  Show that $V(\\mu) = \\mu(1-\\mu)$.  \n\\end{enumerate}\n\n\\item To specify a GLM we must choose the link function $g(\\mu_i)$.  Recall that $g$ links the predictors with the mean of the response: $g(\\mu_i) = x_i^T \\beta$.  Since you've shown that\n$$\n\\theta_i = (b')^{-1} \\left\\{g^{-1}(x_i^T \\beta) \\right\\}\n$$\na particular simple choice of link function is one where $g^{-1} = b'$, or equivalently $g(\\mu) = (b')^{-1}(\\mu)$.  This is known as the \\textit{canonical link}, in which case the canonical parameter simplifies to\n$$\n\\theta_i = (b')^{-1} \\left\\{b'(x_i^T \\beta) \\right\\} = x_i^T \\beta \\, .\n$$\nSo under the canonical link $g(\\mu) = b'^{-1}(\\mu)$, we have the model\n$$\nf(y_i; \\beta, \\phi) \\exp \\left\\{ \\frac{y_i x_i^T \\beta - b(x_i^T \\beta)}{\\phi/w_i} + c(y_i; \\phi/w_i)   \\right \\}\n$$\n\nNow return to the two special cases from the previous problem.\n\\begin{enumerate}[(1)]\n\\item Suppose that $Y$ is a Poisson GLM, i.e. that the stochastic component of the model is a Poisson distribution. Show that the canonical link is $g(\\mu) = \\log \\mu$.  \n\\item Suppose that $Y = Z/N$ is a Binomial GLM, i.e. that the stochastic component of the model is a Binomial distribution $Z \\sim \\mbox{Binom}(N, P)$.   Show that the canonical link is $g(\\mu) = \\log \\left\\{ \\mu/(1-\\mu) \\right\\}$.  \n\\end{enumerate}\n\n\\end{enumerate}\n\n\n%\n%\\section{Fitting GLMs}\n%\n% The regression coefficients $\\beta$ in a GLM are typically fit using some variation on likelihood-based inference.  To this end, define the likelihood function for a given GLM as\n%$$\n%L(\\beta, \\phi) = \\prod_{i=1}^n \\exp \\left\\{ \\frac{y_i \\theta_i - b(\\theta_i)}{\\phi/w_i} + c(y_i; \\phi/w_i)   \\right \\} \\, ,\n%$$\n%where based on results you proved above, we define $\\theta_i = (b')^{-1}(\\mu_i)$ and $\\mu_i = g^{-1}(x_i^T \\beta)$.  \n%\n%This allows us to define the score function $s(\\beta, \\phi)$ as the gradient of the log likelihood with respect to $\\beta$:\n%$$\n%s(\\beta, \\phi) = \\nabla_\\beta \\  \\log L(\\beta, \\phi) = \\frac{\\partial}{\\partial \\beta} \\log L(\\beta, \\phi) \\, .\n%$$\n%Similarly, define the Hessian matrix as the matrix of partial second derivatives of the log likelihood:  \n%$$\n%H(\\beta, \\phi) = \\frac{\\partial^2}{\\partial \\beta \\partial \\beta^T} \\log L(\\beta, \\phi) \n%$$\n%\n%\n%\\begin{enumerate}[(A)]\n%\n%\\item Using the chain rule\n%$$\n%\\frac{\\partial}{\\partial \\beta} = \\frac{\\partial}{\\partial \\theta} \\times \\frac{\\partial \\theta}{\\partial \\mu } \\times \\frac{\\partial \\mu}{\\partial \\beta} \\, ,\n%$$\n%show that \n%\n%\\item Show that under the canonical link, $g'(\\mu) = 1/V(\\mu)$.  Hint: remember from calculus that\n%$$\n%(f^{-1})'(x) = \n%$$\n%\n%\\end{enumerate}\n%\n\n\\end{document}\n\n", "meta": {"hexsha": "cdedff66d750aa85af687ef642991cb2862d4dc0", "size": 9862, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/exercises02-SDS383D.tex", "max_stars_repo_name": "jgscott/SDS383D", "max_stars_repo_head_hexsha": "871bebdd119c4e52e431708377cfdae184e30bb5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-01-18T22:26:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T19:02:29.000Z", "max_issues_repo_path": "exercises/exercises02-SDS383D.tex", "max_issues_repo_name": "jgscott/SDS383D", "max_issues_repo_head_hexsha": "871bebdd119c4e52e431708377cfdae184e30bb5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercises/exercises02-SDS383D.tex", "max_forks_repo_name": "jgscott/SDS383D", "max_forks_repo_head_hexsha": "871bebdd119c4e52e431708377cfdae184e30bb5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-01-18T22:40:06.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T20:17:04.000Z", "avg_line_length": 49.8080808081, "max_line_length": 475, "alphanum_fraction": 0.6905293044, "num_tokens": 3057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.43544592197805987}}
{"text": "% !TEX root =S-PoR.tex\n\n\\subsection{Time-lock Puzzles}\n\nThe idea to send information into the \\emph{future}, i.e.\ntime-lock puzzle/encryption, was first put forth by Timothy C. May. A time-lock puzzle allows a party to encrypt a message such that it cannot be decrypted  until a certain amount of time has passed. In general,  a  time-lock scheme should allow  that generating (and verifying) a puzzle to take less time than solving it. The time-lock puzzle scheme that May proposed lies on a trusted agent. Later on, Rivest \\textit{et al} \\cite{Rivest:1996:TPT:888615} propose a protocol that does not require a trusted agent, and is secure against a receiver\nwho may have access to many  computation resources that can be run in parallel. It is based on Blum-Blum-Shub pseudorandom number generator that relies on modular repeated squaring, believed to be sequential. The scheme in \\cite{Rivest:1996:TPT:888615} allows (only) the puzzle creator to  verify the correctness of the puzzle solution using a secret key and the original secret message.  This scheme has been the core of (almost) all later time-lock puzzles schemes that supports encapsulation of an arbitrary message. Later on, \\cite{BonehN00,DBLP:conf/fc/GarayJ02} proposed timed commitment schemes that offer more security properties, in the sense that they   allow a puzzle generator to prove (in Zero-knowledge) to a puzzle solver that the correct solution (e.g. a signature of a public document) will be recovered after a certain time, before the solver starts solving the puzzle. These schemes are more complex, due to the use of zero-knowledge proofs, and less efficient than \\cite{Rivest:1996:TPT:888615}.    Very recently, \\cite{MalavoltaT19,BrakerskiDGM19}  propose protocols for homomorphic time-lock puzzles, where an arbitrary function can be run over puzzles before they are solved. The schemes mainly use  fully homomorphic encryption and   the RSA puzzle, proposed in \\cite{BrakerskiDGM19}, in the nutshell. The main difference between the two protocols is the security assumption they rely on (i.e. the former uses a non-standard assumption while the latter relies on a standard one). Since both schemes use a generic fully homomorphic encryption, it is not hard to make them publicly verifiable. Both protocols  are only of theoretical interest as in practice they impose  high computation and communication costs, due to the use of fully homomorphic encryptions.\n\n\n%Furthermore, \\cite{KarameC10} proposes a privately verifiable puzzle scheme that has up to $12\\times$  lower cost than \\cite{Rivest:1996:TPT:888615} in puzzle generation and verification phases. However,  it relies on  a new and non-standard assumption (i.e. computationally infeasible to compute a small private exponent when a public exponent is much larger than the RSA modulus).\n\n\n\nWe also cover two related but different notions, pricing puzzles and verifiable delay functions. \n\n\\noindent\\textbf{\\textit{Pricing Puzzles.}} Also known as \\emph{client puzzles}. It was first put forth by Dwork \\textit{et al.} \\cite{DworkN92} who defined it as a function that requires a certain amount of computation resources to solve a puzzle.  In general, the pricing puzzles are based on either hash inversion problems or number theoretic. In the former category, \na puzzle generator  generates a puzzle as: $h= \\mathtt{H}(m||r)$, where $\\mathtt{H}$ is a hash function, $m$ is a public value and $r$ is a random value of a fixed size. Given $h, \\mathtt{H}$ and $m$, the solver must find $r$ such that the above equation holds. The size of $r$ is picked in such a way that the expected time to find the solution is fixed (however it does not rule out finding the solution on the first attempt). The above hash-based scheme allows a solver to find a solution faster if it has more computational power resources  running in parallel. The application area of such puzzle includes  defending against denial-of-service (DoS)  attacks, reaching a consensus in cryptocurrencies, etc. A  variant  of such a puzzle uses iterative hashing; for instance, to generate a set of puzzles  in the case where the solver receives a service proportional to the number of puzzles it solves \\cite{groza2006chained},  or to generate password puzzle to mitigate DoS attacks \\cite{Ma05}. However, the iterative hashing schemes are partially parallelizable, in the sense that each single invocation of the hash function can be run in parallel. Later on,  \\cite{MahmoodyMV11} investigates the possibility of constructing (time-lock) puzzles in the random oracle model.  Their main result was negative, that rules out time-lock puzzles that require more parallel time to solve than the total work required to generate.  Also \\cite{MahmoodyMV11} proposes an iterative hash-based mechanism (very similar to \\cite{Ma05}) that allows a puzzle generator to generate a puzzle with $n$ parallel queries to the random oracle, but the solver needs $n$ rounds of serial queries. Nevertheless, this scheme is also partially parallelizable, as each instance of the puzzle can be solved in parallel. Note that the above hash-based puzzle schemes would have very limited applications if they are used directly to  encapsulate a message: $m'$ of arbitrary size. The reason is that, in these schemes,  the solution  size: $|r|$ plays a vital role in (adjusting) the  time taken to solve the puzzle. If the solution size becomes bigger, as a result of combining $r$ with $m'$, i.e. $r \\odot m'$, then it would take longer to find the solution. This means  the puzzles can be used only in the cases where  the time required to find a solution is long enough, and is a function of $|r \\odot m'|$, which seriously restricts its application. Researchers also propose non-parallelizable pricing puzzles based on number theoretic \\cite{WatersJHF04,KuppusamyRSBN12,KarameC10} whose main application is to resist DoS attacks. These schemes  have a more efficient verification mechanism than the one proposed in \\cite{Rivest:1996:TPT:888615}. But, they are only privately verifiable and not designed to encapsulate an arbitrary message. \n\n\n\n\n\n\\noindent\\textbf{\\textit{Verifiable Delay Function (VDF).}} Allows a prover to provide a publicly verifiable proof stating  it has performed  a pre-determined number of sequential computations. It has many applications, e.g. in decentralised systems to extract  trustworthy public randomness from a blockchain. VDF first formalised by Boneh \\textit{et al} in \\cite{BonehBBF18} that proposed several VDF constructions based on SNARKs along with either  incrementally verifiable computation or injective polynomials, or based on time-lock puzzles, where  the SNARKs based approaches require a trusted setup.  Later on,  \\cite{Wesolowski19} improved the pervious VDFs  from different perspectives and proposed a scheme  based on RSA time-lock encryption, in the random oracle model. To date, this protocol is the most efficient VDF.  It also supports batch verification, such that given a single proof a verifier can efficiently check the validity of multiple outputs of the verifiable delay function. As discussed above, (most of) VDF schemes are built  upon time-lock puzzles, however the converse is not necessarily the case, as VDFs are not designed to encapsulate an  arbitrary private message, and they take a public message as input while time-lock puzzles are designed to conceal a private input message. \n\n\n%BonehBBF18,Wesolowski19\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "f08f4142aed08b73275f7714b7e3f8870cdbe5e0", "size": 7478, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/eprint-version/Puzzle-literature-review-long.tex", "max_stars_repo_name": "AydinAbadi/CR-LP", "max_stars_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/eprint-version/Puzzle-literature-review-long.tex", "max_issues_repo_name": "AydinAbadi/CR-LP", "max_issues_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/eprint-version/Puzzle-literature-review-long.tex", "max_forks_repo_name": "AydinAbadi/CR-LP", "max_forks_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 196.7894736842, "max_line_length": 2818, "alphanum_fraction": 0.79326023, "num_tokens": 1726, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43544591824361073}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\n\n\\title{Chapter 10\\\\Green’s Functions}\n\\author{solutions by Hikari}\n\\date{September 2021}\n\n\\begin{document}\n\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\br}[2]{\\langle#1|#2\\rangle}\n\\newcommand{\\del}{\\boldsymbol{\\nabla}}\n\n\\maketitle\n\n\\section*{10.1 One-Dimensional Problems}\n\n\\paragraph{10.1.1}\nThe solution given by the Green's function is\n\\[\ny(x)=\\int_0^xt\\cdot f(t)\\,dt+x\\int_x^1f(t)\\,dt\n\\]\nthen\n\\begin{align*}\n    & y'(x)=xf(x)+\\int_x^1f(t)\\,dt-xf(x)=\\int_x^1f(t)\\,dt\\\\\n    & y''(x)=-f(x)\\\\\n    & y(0)=\\int_0^0t\\cdot f(t)\\,dt+0\\int_x^1f(t)\\,dt=0\\\\\n    & y'(1)=\\int_1^1f(t)\\,dt=0\n\\end{align*}\nso the equation $\\mathcal{L}y=-y''(x)=f(x)$ is satisfied, and the boundary conditions $y(0)=0$ and $y'(1)=0$ are also satisfied.\n\n\\paragraph{10.1.2}\n(a) $\\sin x$ satisfies the homogeneous equation and $y(0)=0$, and $\\cos(x-1)$ satisfies the homogeneous equation and $y'(1)=0$, so the Green's function has the form\n\\[\nG(x,t)=\n\\begin{cases}\nh_1(t)\\sin x,\\quad & 0\\leq x<t\\\\\nh_2(t)\\cos(x-1),\\quad & t<x\\leq1\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)\\cos(t-1)=h_1(t)\\sin t\\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && -h_2(t)\\sin(t-1)-h_1(t)\\cos t=1\n\\end{alignat*}\nso $h_1(t)=-\\frac{\\cos(t-1)}{\\cos(1)}$, and $h_2(t)=-\\frac{\\sin t}{\\cos(1)}$. Therefore the Green's function is\n\\[\nG(x,t)=\n\\begin{cases}\n-\\frac{\\sin x\\cos(t-1)}{\\cos(1)},\\quad & 0\\leq x<t\\\\[5pt]\n-\\frac{\\cos(x-1)\\sin t}{\\cos(1)},\\quad & t<x\\leq1\n\\end{cases}\n\\]\n\\medskip\n\n(b) $e^x$ satisfies the homogeneous equation and $y(-\\infty)=0$, and $e^{-x}$ satisfies the homogeneous equation and $y(\\infty)=0$, so the Green's function has the form\n\\[\nG(x,t)=\n\\begin{cases}\ne^xh_1(t),\\quad & -\\infty<x<t\\\\\ne^{-x}h_2(t),\\quad & t<x<\\infty\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && e^{-t}h_2(t)=e^th_1(t) \\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && -e^{-t}h_2(t)-e^th_1(t)=1\n\\end{alignat*}\nso $h_1(t)=-\\frac{e^{-t}}{2}$, and $h_2(t)=-\\frac{e^t}{2}$. Therefore the Green's function is\n\\[\nG(x,t)=\n\\begin{cases}\n-\\frac{e^{x-t}}{2},\\quad & -\\infty<x<t\\\\[5pt]\n-\\frac{e^{t-x}}{2},\\quad & t<x<\\infty\n\\end{cases}\n\\]\n\n\\paragraph{10.1.3}\nThe solution is\n\\[\ny(x)=\\int_0^x\\sin(x-t)f(t)dt\n\\]\nBy Leibniz integral rule,\n\\begin{align*}\n    & y'(x)=\\sin(x-x)f(x)+\\int_0^x\\pdv{\\sin(x-t)}{x}f(t)\\,dt=\\int_0^x\\cos(x-t)f(t)\\,dt\\\\\n    & y''(x)=\\cos(x-x)f(x)+\\int_0^x\\pdv{\\cos(x-t)}{x}f(t)\\,dt=f(x)-y(x)\\\\\n    & y(0)=\\int_0^0\\sin(x-t)f(t)\\,dt=0\\\\\n    & y'(0)=\\int_0^0\\cos(x-t)f(t)\\,dt=0\n\\end{align*}\nso the equation $y''+y=f(x)$ is satisfied, and the initial conditions $y(0)=y'(0)=0$ are also satisfied.\n\n\\paragraph{10.1.4}\n$\\sin(\\frac{x}{2})$ satisfies the homogeneous equation and $y(0)=0$, and $\\cos(\\frac{x}{2})$ satisfies the homogeneous equation and $y(\\pi)=0$, so the Green's function has the form\n\\[\nG(x,t)=\n\\begin{cases}\nh_1(t)\\sin(\\frac{x}{2}),\\quad & 0\\leq x<t\\\\\nh_2(t)\\cos(\\frac{x}{2}),\\quad & t<x\\leq\\pi\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)\\cos(\\frac{t}{2})=h_1(t)\\sin(\\frac{t}{2})\\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && -\\frac{1}{2} h_2(t)\\sin(\\frac{t}{2})-\\frac{1}{2} h_1(t)\\cos(\\frac{t}{2})=-1\n\\end{alignat*}\nso $h_1(t)=2\\cos(\\frac{t}{2})$, and $h_2(t)=2\\sin(\\frac{t}{2})$. Therefore the Green's function is\n\\[\nG(x,t)=\n\\begin{cases}\n2\\sin(\\frac{x}{2})\\cos(\\frac{t}{2}),\\quad & 0\\leq x<t\\\\[5pt]\n2\\cos(\\frac{x}{2})\\sin(\\frac{t}{2}),\\quad & t<x\\leq\\pi\n\\end{cases}\n\\]\n\n\\paragraph{10.1.5}\nLet $u=kx$, then the equation becomes Bessel's equation with order $n=1$, so the solution is $J_1(kx)$ and $Y_1(kx)$. \\;$J_1(kx)$ satisfies $y(0)=0$, and $Y_1(k)J_1(kx)-J_1(k)Y_1(kx)$ satisfies $y(1)=0$. To find the Green's function, we must put it into the self-sdjoint form:\n\\[\nx\\frac{d^2y}{dx^2}+\\frac{dy}{dx}+(k^2x-\\frac{1}{x})y=\\frac{f(x)}{x}\n\\]\nThen the Green's function has the form (we use $g$ instead of $G$ to remind that it is the Green's function of the self-adjoint equation, not the original equation)\n\\[\ng(x,t)=\n\\begin{cases}\nh_1(t)J_1(kx),\\quad & 0\\leq x<t\\\\\nh_2(t)\\left[Y_1(k)J_1(kx)-J_1(k)Y_1(kx)\\right],\\quad & t<x\\leq1\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)\\left[Y_1(k)J_(kt)-J_1(k)Y_1(kt) \\right]=h_1(t)J_1(kt) \\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && h_2(t)\\left[Y_1(k)J_1'(kt)-J_1(k)Y_1'(kt) \\right]-h_1(t)J_1'(kt)=\\frac{1}{t}\n\\end{alignat*}\nso $h_1(t)=-\\frac{\\pi}{2J_1(k)}\\left[Y_1(k)J_1(kt)-J_1(k)Y_1(kt) \\right]$, and $h_2(t)=-\\frac{\\pi}{2J_1(k)}J_1(kt)$. Therefore the Green's function is\n\\[\ng(x,t)=\n\\begin{cases}\n-\\frac{\\pi}{2J_1(k)}J_1(kx)\\left[Y_1(k)J_1(kt)-J_1(k)Y_1(kt) \\right] ,\\quad & 0\\leq x<t\\\\\n-\\frac{\\pi}{2J_1(k)}\\left[Y_1(k)J_1(kx)-J_1(k)Y_1(kx)\\right]J_1(kt) ,\\quad & t<x\\leq1\n\\end{cases}\n\\]\nThe solution is given by $y(x)=\\int_0^1g(x,t)\\frac{f(x)}{x}dx$, which means the Green's function of the original equagtion is \n\\[\nG(x,t)=\\frac{g(x,t)}{x}=\n\\begin{cases}\n\\frac{\\pi}{2x}J_1(kx)\\left[Y_1(kt)-\\frac{Y_1(k)}{J_1(k)}J_1(kt) \\right] ,\\quad & 0\\leq x<t\\\\[5pt]\n\\frac{\\pi}{2x}\\left[Y_1(kx)-\\frac{Y_1(k)}{J_1(k)}J_1(kx) \\right]J_1(kt) ,\\quad & t<x\\leq1\n\\end{cases}\n\\]\n\n\\paragraph{10.1.6}\nThe equation is Legendre's differential equation of order $n=0$, so the solution is $P_0(x)=1$ and $Q_0(x)=\\frac{1}{2}\\ln\\frac{1+x}{1-x}$. \\;$Q_0(x)$ is infinite at $x=\\pm1$, so the function for $x<t$ and $x>t$ that satisfies the boundary conditions will both be a multiple of $P_0(x)$, which results in the absence of the discontinuity in $\\frac{dG(x,t)}{dx}\\big|_{x=t}$\\,. So no Green's function can be constructed.\n\n\\paragraph{10.1.7}\nThe solution of the homogeneous equation has the form $c_1e^{-kt}+c_2$. The only solution that satisfies $\\psi(0)=\\psi'(0)=0$ is the trivial solution $\\psi(t)=0$, while there is no other boundary condition. To find the Green's function, we must  put the equation into self-adjoint form:\n\\[\ne^{kt}\\frac{d^2\\psi}{dt^2}+ke^{kt}\\frac{d\\psi}{dt}=e^{kt}f(t)\n\\]\nThen the Green's function has the form\n\\[\ng(t,u)=\n\\begin{cases}\n0,\\quad & 0\\leq t<u\\\\\nh_1(u)e^{-kt}+h_2(u),\\quad & u<t\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(u_+,u)=G(u_-,u)\\quad && \\longrightarrow\\quad && h_1(u)e^{-kt}+h_2(u)=0 \\\\\n    & \\pdv{G}{t}(u_+,u)-\\pdv{G}{t}(u_-,u)=\\frac{1}{p(u)}\\quad && \\longrightarrow\\quad && -kh_1(u)e^{-ku}=e^{-ku}\n\\end{alignat*}\nso $h_1(u)=-\\frac{1}{k}$, and $h_2(u)=\\frac{e^{-ku}}{k}$. Therefore the Green's function of the self-adjoint equation is\n\\[\ng(t,u)=\n\\begin{cases}\n0,\\quad & 0\\leq t<u\\\\\n\\frac{1}{k}\\left(-e^{-kt}+e^{-ku} \\right) ,\\quad & u<t\n\\end{cases}\n\\]\nand the Green's function of the original equation is\n\\[\nG(t,u)=g(t,u)e^{ku}=\n\\begin{cases}\n0,\\quad & 0\\leq t<u\\\\\n\\frac{1}{k}\\left(1-e^{k(u-t)} \\right) ,\\quad & u<t\n\\end{cases}\n\\]\nIf $f(t)=e^{-t}$, then the solution is given by\n\\[\ny(t)=\\int_0^t\\frac{1}{k}\\left(1-e^{k(u-t)} \\right)e^{-u}du=\\frac{(k-1)-ke^{-t}+e^{-kt}}{k(k-1)}\n\\]\n\n\\paragraph{10.1.8}\nFrom the Green's function, the solution is given by \n\\[\n\\psi(x)=\\int_{-\\infty}^x-\\frac{i}{2k}e^{ik(x-x')}g(x')dx'+\\int_x^\\infty-\\frac{i}{2k}e^{ik(x'-x)}g(x')dx'\n\\]\nUsing the Leibniz integral rule:\n\\[\n\\frac{d\\psi(x)}{dx}=-\\frac{i}{2k}e^{ik(x-x)}g(x)+\\int_{-\\infty}^x-\\frac{i}{2k}(ik)e^{ik(x-x')}g(x')dx'+\\frac{i}{2k}e^{ik(x-x)}g(x)+\\int_x^\\infty-\\frac{i}{2k}(-ik)e^{ik(x'-x)}g(x')dx'\n\\]\n\\[\n=\\int_{-\\infty}^x\\frac{1}{2}e^{ik(x-x')}g(x')dx'+\\int_x^\\infty-\n\\frac{1}{2}e^{ik(x'-x)}g(x')dx'\n\\]\n\\[\n\\frac{d^2\\psi(x)}{dx^2}=\\frac{1}{2}e^{ik(x-x)}g(x)+\\int_{-\\infty}^x\\frac{1}{2}(ik)e^{ik(x-x')}g(x')dx'+\\frac{1}{2}e^{ik(x-x)}g(x)+\\int_x^\\infty-\\frac{1}{2}(-ik)e^{ik(x'-x)}g(x')dx'\n\\]\n\\[\n=g(x)-k^2\\psi(x)\n\\]\nso the solution satisfies the equation $\\frac{d^2\\psi}{dx^2}+k^2\\psi=g(x)$\n\n\\paragraph{10.1.9}\n$e^{kx}$ satisfies the homogeneous equation and $y(-\\infty)=0$, and $e^{-kx}$ satisfies the homogeneous equation and $y(\\infty)=0$, so the Green's function has the form\n\\[\nG(x,t)=\n\\begin{cases}\nh_1(t)e^{kx} ,\\quad & -\\infty<x<t\\\\\nh_2(t)e^{-kx} ,\\quad & t<x<\\infty\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)e^{-kt}=h_1(t)e^{kt} \\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && -kh_2(t)e^{-kt}-kh_1(t)e^{kt}=1\n\\end{alignat*}\nso $h_1(t)=-\\frac{1}{2k}e^{-kt}$, and $h_2(t)=-\\frac{1}{2k}e^{kt}$. Therefore the Green's function is\n\\[\nG(x,t)=\n\\begin{cases}\n-\\frac{1}{2k}e^{k(x-t)} ,\\quad & -\\infty<x<t\\\\[5pt]\n-\\frac{1}{2k}e^{k(t-x)} ,\\quad & t<x<\\infty\n\\end{cases}\n=-\\frac{1}{2k}e^{-k|x-t|}\n\\]\n\n\\paragraph{10.1.10}\n(a) From Example 10.1.1,\n\\[\nG(x,t)=\n\\begin{cases}\nx(1-t),\\quad & 0\\leq x<t\\\\\nt(1-x),\\quad & t<x\\leq1\n\\end{cases}\n\\]\nis the Green's function of the equation $-y''=f(x)$, with boundary conditions $y(0)=y(1)=0$. The operator $\\mathcal{L}=-\\frac{d^2}{dx^2}$ and boundary conditions $y(0)=y(1)=0$ have the orthonormal eigenfunctions $\\varphi_n=\\sqrt{2}\\sin n\\pi x$ with eigenvalues $\\lambda_n=n^2\\pi^2$, so by Equation 10.14, the Green's function is given by\n\\[\nG(x,t)=\\sum_n\\frac{\\varphi_n^*(t)\\varphi_n(x)}{\\lambda_n}=\\sum_{n=1}^\\infty\\frac{2\\sin n\\pi x\\,\\sin n\\pi t}{n^2\\pi^2}\n\\]\n\n(b) From Exercise 10.1.1, \n\\[\nG(x,t)=\n\\begin{cases}\nx,\\quad & 0\\leq x<t\\\\\nt,\\quad & t<x\\leq1\n\\end{cases}\n\\]\nis the Green's function of the equation $-y''=f(x)$, with boundary conditions $y(0)=0,\\,y'(1)=0$. The operator $\\mathcal{L}=-\\frac{d^2}{dx^2}$ and boundary conditions $y(0)=0,\\,y'(1)=0$ have the orthonormal eigenfunctions $\\varphi_n=\\sqrt{2}\\sin(n+\\frac{1}{2})\\pi x$ with eigenvalues $\\lambda_n=(n+\\frac{1}{2})^2\\pi^2$, so by Equation 10.14, the Green's function is given by\n\\[\nG(x,t)=\\sum_n\\frac{\\varphi_n^*(t)\\varphi_n(x)}{\\lambda_n}=\\sum_{n=1}^\\infty\\frac{2\\sin(n+\\frac{1}{2})\\pi x\\,\\sin (n+\\frac{1}{2})\\pi t}{(n+\\frac{1}{2})^2\\pi^2}\n\\] \n\n\\paragraph{10.1.11}\n(a) \n\\[\ny''(x)=y(x)\n\\]\n\\[\ny'(x)-y'(-1)=\\int_{-1}^xy(t)dt\n\\]\n\\[\ny'(x)=c+\\int_{-1}^xy(t)dt\n\\]\n\\[\ny(x)-y(-1)=c\\int_{-1}^xdx+\\int_{-1}^xds\\int_{-1}^sy(t)dt\n\\]\n\\[\n=c(x+1)+\\int_{-1}^xy(t)dt\\int_t^xds\n\\]\n\\[\n=c(x+1)+\\int_{-1}^xy(t)(x-t)dt\n\\]\nwhere we change the order of integration in the last three equation (the area to be integrated is an upper triangle in the \\textit{t-s} surface). Substitute $y(1)=1$ and $y(-1)=1$:\n\\[\ny(1)-y(-1)=2c+\\int_{-1}^1y(t)(1-t)dt=0\n\\]\n\\[\nc=-\\frac{1}{2}\\int_{-1}^1y(t)(1-t)dt\n\\]\nso\n\\[\ny(x)=y(-1)+c(x+1)+\\int_{-1}^xy(t)(x-t)dt\n\\]\n\\[\n=1-\\frac{1}{2}\\int_{-1}^1(x+1)y(t)(1-t)dt+\\int_{-1}^xy(t)(x-t)dt\n\\]\n\\[\n=1-\\int_{-1}^x\\frac{1}{2}(1-x)(t+1)y(t)dt-\\int_x^1\\frac{1}{2}(1-t)(x+1)y(t)dt\n\\]\n\\[\n=1-\\int_{-1}^1K(x,t)\\,y(t)\\,dt\n\\]\nwhere\n\\[\nK(x,t)=\n\\begin{cases}\n\\frac{1}{2}(1-x)(t+1),\\quad & x>t\\\\\n\\frac{1}{2}(1-t)(x+1),\\quad & x<t\n\\end{cases}\n\\]\n\\medskip\n\n(b) Let $u(x)=y(x)-1$, then the equation becomes $u''(x)=u(x)+1$, and the boundary conditions becomes $u(1)=u(-1)=0$. \\;$u(x)=x+1$ satisfies the homogeneous equation and $u(-1)=0$, and $u(x)=x-1$ satisfies the homogeneous equation and $u(1)=0$. So the Green's function has the form\n\\[\nG(x,t)=\n\\begin{cases}\nh_1(t)(x+1),\\quad & x<t\\\\\nh_2(t)(x-1),\\quad & x>t\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)(t-1)=h_1(t)(t+1) \\\\\n    & \\pdv{G}{x}(t_+,t)-\\pdv{G}{x}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && h_2(t)-h_1(t)=1\n\\end{alignat*}\nso $h_1(t)=\\frac{1}{2}(t-1)$, and $h_2(t)=\\frac{1}{2}(t+1)$. Therefore the Green's function is\n\\[\nG(x,t)=\n\\begin{cases}\n\\frac{1}{2}(x+1)(t-1),\\quad & x<t\\\\[2pt]\n\\frac{1}{2}(x-1)(t+1),\\quad & x>t\n\\end{cases}\n\\]\nTo match the notation with the book, define\n\\[\nK(x,t)=-G(x,t)=\n\\begin{cases}\n\\frac{1}{2}(1-x)(t+1),\\quad & x>t\\\\[2pt]\n\\frac{1}{2}(1-t)(x+1),\\quad & x<t\n\\end{cases}\n\\]\nthen the solution (integral equation) is given by\n\\[\ny(x)=1+u(x)=1+\\int_{-1}^1G(x,t)\\left[u(t)+1 \\right]dt=1-\\int_{-1}^1K(x,t)\\,y(t)\\,dt\n\\]\n\n\\paragraph{10.1.12}\n\\[\ny'(x)-y'(0)+a_1y(x)-a_1y(0)+a_2\\int_0^xy(t)dt=0\n\\]\n\\[\ny(x)-y(0)-y'(0)(x-0)+a_1\\int_0^xy(t)dt-a_1y(0)(x-0)+a_2\\int_0^xds\\int_0^sy(t)dt=0\n\\]\n\\[\ny(x)-y'_0x+a_1\\int_0^xy(t)dt+a_2\\int_0^xy(t)(x-t)dt=0\n\\]\nSubstitute $y(1)=0$:\n\\[\n-y'_0+a_1\\int_0^1y(t)dt+a_2\\int_0^1y(t)(1-t)dt=0\n\\]\n\\[\ny_0'=a_1\\int_0^1y(t)dt+a_2\\int_0^1y(t)(1-t)dt\n\\]\n\\[\ny(x)=y'_0x-a_1\\int_0^xy(t)dt-a_2\\int_0^xy(t)(x-t)dt\n\\]\n\\[\n=a_1\\int_0^1xy(t)dt+a_2\\int_0^1x(1-t)y(t)dt-a_1\\int_0^xy(t)dt-a_2\\int_0^x(x-t)y(t)dt\n\\]\n\\[\n=\\int_0^x\\big[a_2t(1-x)+a_1(x-1)\\big]y(t)dt+\\int_x^1\\big[a_2x(1-t)+a_1x\\big]y(t)dt\n\\]\n\\[\n=\\int_0^1K(x,t)y(t)dt\n\\]\nwhere\n\\[\nK(x,t)=\n\\begin{cases}\na_2t(1-x)+a_1(x-1),\\quad & t<x\\\\\na_2x(1-t)+a_1x,\\quad & x<t\n\\end{cases}\n\\]\n\nIf $a_1=0$, then the equation is self-adjoint, so $K(x,t)$ is the Green's function of the equation, and therefore has the properties of Green's function (symmetry, continuity, etc.)\n\n\\paragraph{10.1.13}\nRegard $V_0\\frac{e^{-r}}{r}y(r)$ as the inhomogeneous term:\n\\[\n\\frac{d^2y(r)}{dr^2}-k^2y(r)=-V_0\\frac{e^{-r}}{r}y(r)\n\\]\nThe solution of the homogeneous equation has the form $c_1e^{kr}+c_2e^{-kr}$. \\;$\\sinh kr=\\frac{1}{2}(e^{kr}-e^{-kr})$ satisfies the homogeneous equation and y(0)=0, and $e^{-kr}$ satisfies the homogeneous equation and $y(\\infty)=0$. So the Green's function has the form\n\\[\nG(r,t)=\n\\begin{cases}\nh_1(t)\\sinh kr,\\quad & 0\\leq r<t\\\\\nh_2(t)e^{-kr},\\quad & t<r<\\infty\n\\end{cases}\n\\]\nUsing the general properties of Green's function:\n\\begin{alignat*}{3}\n    & G(t_+,t)=G(t_-,t)\\quad && \\longrightarrow\\quad && h_2(t)e^{-kt}=h_1(t)\\sinh ht \\\\\n    & \\pdv{G}{r}(t_+,t)-\\pdv{G}{r}(t_-,t)=\\frac{1}{p(t)}\\quad && \\longrightarrow\\quad && -kh_2(t)e^{-kt}-kh_1(t)\\cosh kt=1\n\\end{alignat*}\nso $h_1(t)=-\\frac{1}{k}e^{-kt}$, and $h_2(t)=-\\frac{1}{k}\\sinh kt$. Therefore the Green's function is\n\\[\nG(r,t)=\n\\begin{cases}\n-\\frac{1}{k}e^{-kt}\\sinh kr,\\quad & 0\\leq r<t\\\\[2pt]\n-\\frac{1}{k}e^{-kr}\\sinh kt,\\quad & t<r<\\infty\n\\end{cases}\n\\]\nand the solution (integral equation) is given by\n\\[\ny(r)=\\int_0^\\infty G(r,t)f(t)dt=-V_0\\int_0^\\infty G(r,t)\\frac{e^{-t}}{t}y(t)\\,dt\n\\]\n\n\\section*{10.2 Problems in Two and Three Dimensions}\n\n\\paragraph{10.2.1}\n\\[\n\\mathcal{L}\\int_a^b\\Big[G(x_1,x_2)+\\varphi(x_1)\\Big]f(x_2)dx_2=\\int_a^b\\Big[\\mathcal{\nL}G(x_1,x_2)+\\mathcal{L}\\varphi(x_1)\\Big]f(x_2)dx_2=\\mathcal{L}\\int_a^bG(x_1,x_2)f(x_2)dx_2\n\\]\nif $\\mathcal{L}\\varphi(x_1)=0$. That means\nthe Green's function will still give the correct solution if added a solution of the homogeneous equation.\n$\\frac{1}{2}|x_1-x_2|$ is the Green's function of Laplace equation, and $-\\frac{1}{2}x_1-\\frac{1}{2}x_2$ is a solution of the homogeneous solution, so \n\\[\n\\frac{1}{2}|x_1-x_2|-\\frac{1}{2}x_1-\\frac{1}{2}x_2=\n\\begin{cases}\n-x_1,\\quad & 0\\leq x_1<x_2\\\\\n-x_2,\\quad & x_2<x_1\\leq1\n\\end{cases}\n\\]\nis also a Green's function of Laplace equation, which is consistent with the one found in Example 10.1.1 (negative signs arise because the operator is defined as $\\mathcal{L}=-\\frac{d^2}{dx^2}$ in Example 10.1.1).\n\n\\paragraph{10.2.2}\n\\[\n\\mathcal{L}\\psi(\\V{r})=\\del\\cdot\\big[p(\\V{r})\\del\\psi(\\V{r}) \\big]+q(\\V{r})\\psi(\\V{r})\n\\]\n\\[\n\\br{\\chi}{\\mathcal{L}\\psi}=\\int\\displaylimits_V\\chi^*\\mathcal{L}\\psi\\,d\\tau=\\int\\displaylimits_V\\chi^*\\del\\cdot\\big[p\\del\\psi\\big]\\,d\\tau+\\int\\displaylimits_V\\chi^*q\\psi\\,d\\tau\n\\]\n\\[\n=\\int\\displaylimits_V\\del\\cdot(\\chi^*p\\del\\psi)\\,d\\tau-\\int\\displaylimits_V(\\del\\chi^*)\\cdot(p\\del\\psi)\\,d\\tau+\\int\\displaylimits_V\\chi^*q\\psi\\,d\\tau\n\\]\n\\[\n=\\oint\\displaylimits_A\\chi^*p(\\del\\psi)\\cdot d\\boldsymbol{\\sigma}-\\int\\displaylimits_V\\del\\cdot(\\psi p\\del\\chi^*)\\,d\\tau+\\int\\displaylimits_V\\psi\\del\\cdot(p\\del\\chi^*)\\,d\\tau+\\int\\displaylimits_V\\chi^*q\\psi\\,d\\tau\n\\]\n\\[\n=\\oint\\displaylimits_A\\chi^*p(\\del\\psi)\\cdot d\\boldsymbol{\\sigma}-\\int\\displaylimits_A\\psi p(\\del\\chi^*)\\cdot d\\boldsymbol{\\sigma} +\\int\\displaylimits_V\\psi\\big[\\del\\cdot(p\\del\\chi^*)+q\\chi^*\\big]\\,d\\tau\n\\]\n\\[\n=\\oint\\displaylimits_A(\\chi^*p\\del\\psi-\\psi p\\del\\chi^*)\\cdot d\\boldsymbol{\\sigma}+\\int\\displaylimits_V\\psi\\mathcal{L}\\chi^*\\,d\\tau\n\\]\n\\[\n=\\br{\\mathcal{L}\\chi}{\\psi}\n\\]\nwhich implies $\\mathcal{L}$ is Hermitian. \\\\(The surface integral vanishes by the Dirichlet boundary conditions.) \\\\($\\del\\cdot(f\\V{V})=(\\del f)\\cdot\\V{V}+f\\del\\cdot\\V{V}$ and $\\int_V\\del\\cdot\\V{V}\\,d\\tau=\\oint_A\\V{V}\\cdot d\\boldsymbol{\\sigma}$ have been used several times.)\n\n\\paragraph{10.2.3}\n(The space to be integrated given in the book is not quite clear, and the result we get is different from the book.)\n\\[\n\\lim_{|\\V{r}_1-\\V{r}_2|\\to0}\\int k^2G(\\V{r}_1,\\V{r}_2)d^3r_2\n\\]\n\\[\n=\\lim_{a\\to0}\\int\\displaylimits_{|\\V{r}_1-\\V{r}_2|<a}-k^2\\,\\frac{e^{ik|\\V{r}_1-\\V{r}_2|}}{4\\pi |\\V{r}_1-\\V{r}_2|}\\,d^3r_2\n\\]\n\\[\n=-\\lim_{a\\to0}\\int_0^a\\int_0^\\pi\\int_0^{2\\pi}k^2\\,\\frac{e^{ikr}}{4\\pi r}\\,r^2\\sin\\theta\\,d\\theta\\,d\\varphi\n\\]\n\\[\n=-\\lim_{a\\to0}k^2\\int_0^a re^{ikr}dr\n=\\lim_{a\\to0}(ika\\,e^{ika}-e^{ika}+1)=0\n\\]\nSubstitute $k$ with $ik$, the case becomes modified Helmholtz operator, and the result is the same.\n\n\\paragraph{10.2.4}\nFor\n\\[\nG(\\V{r}_1,\\V{r}_2)=-\\frac{e^{ik|\\V{r}_1-\\V{r}_2|}}{4\\pi|\\V{r}_1-\\V{r}_2|}=-\\frac{e^{ikr_{12}}}{4\\pi r_{12}}\n\\]\nWe want to show that $(\\del^2+k^2)G(\\V{r_1},\\V{r}_2)=\\delta(\\V{r}_1-\\V{r}_2)$.\n\nFor $\\V{r}_1\\neq\\V{r}_2$, \n\\[\n(\\del^2+k^2)G(\\V{r_1},\\V{r}_2)=-\\del^2\\frac{e^{ikr}}{4\\pi r}-k^2\\frac{e^{ikr}}{4\\pi r}\n\\]\n\\[\n=-\\frac{1}{r^2}\\frac{d}{dr}\\left[r^2\\frac{d}{dr}(\\frac{e^{ikr}}{4\\pi r}) \\right]-\\frac{k^2e^{ikr}}{4\\pi r}\n\\]\n\\[\n=-\\frac{1}{r^2}\\frac{d}{dr}\\left[\\frac{ikr\\,e^{ikr}}{4\\pi}-\\frac{e^{ikr}}{4\\pi} \\right]-\\frac{k^2e^{ikr}}{4\\pi r}\n\\]\n\\[\n=-\\frac{ike^{ikr}}{4\\pi r^2}+\\frac{k^2e^{ikr}}{4\\pi r}+\\frac{ike^{ikr}}{4\\pi r^2}-\\frac{k^2e^{ikr}}{4\\pi r}=0\n\\]\n\nFor $\\V{r}_1=\\V{r}_2$, the function diverges, but for every $a>0$,\n\\[\n\\int\\displaylimits_{r_{12}<a}(\\del^2+k^2)G(\\V{r}_1,\\V{r}_2)d^3r_1\n\\]\n\\[\n=-\\int\\displaylimits_{r_{12}<a}\\del\\cdot\\del\\frac{e^{ikr_{12}}}{4\\pi r_{12}}d^3r_{12}-\\int\\displaylimits_{r_{12}<a}k^2\\frac{e^{ikr_{12}}}{4\\pi r_{12}}d^3r_{12}\n\\]\n\\[\n=-\\oint\\displaylimits_{r_{12}=a}\\del\\frac{e^{ikr_{12}}}{4\\pi r_{12}}\\cdot d\\boldsymbol{\\sigma}_{12}-\\int_0^a\\int_0^\\pi\\int_0^{2\\pi}k^2\\frac{e^{ikr}}{4\\pi r}r^2\\sin\\theta\\,d\\theta\\,d\\varphi\n\\]\n\\[\n=-\\oint\\displaylimits_{r_{12}=a}\\left(\\frac{ike^{ikr_{12}}}{4\\pi r_{12}}-\\frac{e^{ikr_{12}}}{4\\pi r_{12}^2} \\right)\\hat{\\V{r}}\\cdot d\\boldsymbol{\\sigma}_{12}-k^2\\int_0^a re^{ikr}dr\n\\]\n\\[\n=-\\left(\\frac{ike^{ika}}{4\\pi a}-\\frac{e^{ika}}{4\\pi a^2} \\right)4\\pi a^2-k^2\\left(\\frac{ae^{ika}}{ik}+\\frac{e^{ika}-1}{k^2} \\right)\n\\]\n\\[\n=-ika\\,e^{ika}+e^{ika}+ika\\,e^{ika}-e^{ika}+1=1\n\\]\nTherefore, it must be\n\\[\n(\\del^2+k^2)G(\\V{r_1},\\V{r}_2)=\\delta(\\V{r}_1-\\V{r}_2)\n\\]\n\n\\paragraph{10.2.5}\n\\[\n-\\frac{e^{ik|\\V{r}_1-\\V{r}_2|}}{4\\pi|\\V{r}_1-\\V{r}_2|}\n\\]\nis the fundamental Green's function of the Helmholtz equation, and\n\\[\n\\frac{i\\sin k|\\V{r}_1-\\V{r}_2|}{4\\pi|\\V{r}_1-\\V{r}_2|}\\] \nis a solution of the Helmholtz equation, so\n\\[\n-\\frac{e^{ik|\\V{r}_1-\\V{r}_2|}}{4\\pi|\\V{r}_1-\\V{r}_2|}+\\frac{i\\sin k|\\V{r}_1-\\V{r}_2|}{4\\pi|\\V{r}_1-\\V{r}_2|}=\\frac{-\\cos k|\\V{r}_1-\\V{r}_2|}{4\\pi|\\V{r}_1-\\V{r}_2|}\n\\]\nis also a Green's function of the Helmholtz equation, and the asymptotic $r$ dependence is $\\cos kr$, which is a standing wave.\n\n\\paragraph{10.2.6}\nIn Exercise 10.2.4, substitute $k$ with $ik$, then the Helmholtz equation $(\\del^2+k^2)\\psi=0$ becomes $(\\del^2-k^2)\\psi=0$, which is the modified Helmholtz equation, and the Green's function becomes \n\\[\nG(\\V{r}_1,\\V{r}_2)=-\\frac{e^{-k|\\V{r}_1-\\V{r}_2|}}{4\\pi|\\V{r}_1-\\V{r}_2|}\n\\]\nwhich is the fundamental Green's function of the modified Helmholtz equation, and \n\\[\n\\lim_{|\\V{r}_1-\\V{r}_2|\\to\\infty}-\\frac{e^{-k|\\V{r}_1-\\V{r}_2|}}{4\\pi|\\V{r}_1-\\V{r}_2|}=0\n\\]\n\n\\paragraph{10.2.7}\nUsing the Poisson's equation for electrostatics:\n\\[\n\\del^2\\varphi=-\\frac{\\rho}{\\varepsilon_0}\n\\]\nFor $\\V{r}\\neq0$, \n\\[\n\\rho(\\V{r})=-\\varepsilon_0\\del^2\\varphi(\\V{r})\n\\]\n\\[=-\\varepsilon_0\\frac{Z}{4\\pi\\varepsilon_0}\\frac{1}{r^2}\\frac{d}{dr}\\left[r^2\\frac{d}{dr}(\\frac{e^{-ar}}{r}) \\right]\n\\]\n\\[\n=-\\frac{Z}{4\\pi}\\frac{1}{r^2}\\frac{d}{dr}\\left[-ar\\,e^{-ar}-e^{-ar} \\right]\n\\]\n\\[\n=-\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}\n\\]\nFor $\\V{r}=0$, the function diverges, but for every $R>0$,\n\\[\n\\int\\displaylimits_{r<R}\\rho(\\V{r})d^3r=\\int\\displaylimits_{r<R}-\\varepsilon_0\\del^2\\varphi(\\V{r})d^3r\n\\]\n\\[=-\\frac{Z}{4\\pi}\\int\\displaylimits_{r<R}\\del^2(\\frac{e^{-ar}}{r})d^3r\n\\]\n\\[\n=-\\frac{Z}{4\\pi}\\oint\\displaylimits_{r=R}\\del(\\frac{e^{-ar}}{r})\\cdot d\\boldsymbol{\\sigma}\n\\]\n\\[\n=ZaR\\,e^{-aR}+Ze^{-aR}\n\\]\nNote that \n\\[\n\\int\\displaylimits_{r<R}\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}d^3r=\\int_0^R\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}4\\pi r^2\\,dr=Za^2\\int_0^R re^{-ar}dr=-ZaR\\,e^{-aR}-Ze^{-aR}+Z\n\\]\nso for every $R$,\n\\[\n\\int\\displaylimits_{r<R}\\left[\\rho(\\V{r})+\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r} \\right]d^3r=Z\n\\]\nbut \n\\[\n\\rho(\\V{r})+\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}=0, \\quad \\textit{for $\\V{r}\\neq0$}\n\\]\nwhich means\n\\[\n\\rho(\\V{r})+\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}=Z\\delta(r)\n\\]\nTherefore,\n\\[\n\\rho(\\V{r})=Z\\delta(r)-\\frac{Za^2}{4\\pi}\\frac{e^{-ar}}{r}\n\\]\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "ea2b3c7a2ac6054ce978a0e4769ebc55c84e4b35", "size": 21543, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 10/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 10/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 10/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3163934426, "max_line_length": 417, "alphanum_fraction": 0.6075291278, "num_tokens": 10087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.43544590442273634}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\setcounter{section}{-2}\n\n\\begin{document}\n\n\\title{Number Fields}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Miscellaneous}\n\nBook: Number Fields, Marcus\n\nCourse notes: www.dpmms.ac.uk/~jat58/nfl2018\n\n\\newpage\n\n\\section{Motivation}\n\\begin{thm}\nIf $p$ is an odd prime, then $p=a^2+b^2$ for $a,b \\in \\Z \\iff p \\equiv 1 \\pmod 4$.\n\\begin{proof}\nIf $p=a^2+b^2$, then $p\\equiv 0,1,2 \\pmod 4$. So this condition on $p$ is necessary.\\\\\nSuppose instead $p \\equiv 1 \\pmod 4$. Then $\\left(\\frac{-1}{p}\\right) = 1$. Thus $\\exists a \\in \\Z$ such that $a^2 \\equiv -1 \\pmod p$, or $p|a^2+1$. We can factor $a^2+1=(a+i)(a-i)$ in the ring $\\Z[i]$. Here we introduce a notation: if $R \\subseteq S$ are rings and $\\alpha \\in S$, then $$R[\\alpha] = \\{\\sum_{i=0}^n a_i \\alpha^i \\in S | a_i \\in R\\}$$, the smallest subring of $S$ containing both $R$ and $\\alpha$.\n\nWe know from IB GRM that $\\Z[i]$ is a UFD. Now $p|(a+i)(a-i)$. If $p$ is irreducible in $\\Z[i]$ then $p|a+i$ or $p|a-i$, contradiction. Thus $p$ is reducible in $\\Z[i]$, hence $p=z_1z_2$ with $z_1,z_2 \\in \\Z[i]$. If $z_1 = A+Bi$, $A,B\\in \\Z$, then $A^2+B^2 = p$.\n\\end{proof}\n\\end{thm}\n\nAnother example is when $p$ is an odd prime. Does the equation $$x^p+y^p=z^p$$ have solutions with $x,y,z\\in \\Z$ and $xyz \\neq 0$?\n\n\\begin{thm} (Kummer, 1850)\\\\\nIf $\\Z[e^{2\\pi i/p}]$ is a UFD, then there are no solutions.\\\\\nStrategy: factor $x^p+y^p = \\prod_{j=0}^{p-1} (x+e^{2\\pi ij/p}y)$ in $\\Z[e^{2\\pi i/p}]$.\n\\end{thm}\n\nHowever, we now know $\\Z[e^{2\\pi i/p}]$ is a UFD $\\iff$ $p \\leq 19$.\n\n\\begin{thm} (Kummer, 1850)\\\\\nIf $p$ is a \\emph{regular} prime, then there are no solutions.\\\\\nIf $p<100$, then $p$ is regular $\\iff$ $p \\neq 37,59,67$.\n\\end{thm}\n\nWe have seen various examples such as $\\Z \\subseteq \\Q$, $\\Z[i] \\subseteq \\Q[i]$, $\\Z[e^{2\\pi i/p}] \\subseteq \\Q[e^{2\\pi i/p}]$, or in general, $\\mathcal{O}_L\\subseteq L$, where a ring of \"integers\" lies in a number field.\n\n\\newpage\n\n\\section{Ring of integers}\nRecall: A field extension $L/K$ is an inclusion $K \\leq L$ of fields. The degree of $L/K$ is $[L:K] = \\dim_K L$. We say $L/K$ is finite if $[L:K]<\\infty$.\n\n\\begin{defi} (1.1)\\\\\nA number field is a finite extension $L/\\Q$. Here are two ways to construct number fields:\\\\\n(1) Let $\\alpha \\in \\C$ be an algebraic number. Then $L=\\Q(\\alpha)$ is a number field;\\\\\n(2) Let $K$ be a number field, and let $f(X) \\in K[X]$ be an irreducible polynomial. Then $L=K[X]/(f(X))$ is a number field.\\\\\n(Recall Tower Law: $[L:Q] = [L:K][K:Q] < \\infty$).\n\\end{defi}\n\n\\begin{defi} (1.2)\\\\\n(1) Let $L/K$ be a field extension. Then we say $\\alpha \\in L$ is algebraic over $K$ if there exists a monic $f(X) \\in K[X]$ such that $f(\\alpha) = 0$;\\\\\n(2) Let $L/\\Q$ be a field extension. Then we say $\\alpha \\in L$ is an algebraic integer if there exists a monic $f(X) \\in Z[X]$ such that $f(\\alpha) = 0$.\n\\end{defi}\n\n\\begin{defi} (1.3)\\\\\nLet $L/K$ be a field extension, and let $\\alpha \\in L$ be algebraic over $K$. We call the minimal polynomial of $\\alpha$ over $K$ the monic polynomial $f_\\alpha(X) \\in K[X]$ of least degree such that $f_\\alpha(\\alpha)=0$.\n\\end{defi}\n\nWe recall why $f_\\alpha(X)$ is well-defined: there exists some monic $f(X) \\in K[X]$ with $f(\\alpha)=0$ as $\\alpha$ is algebraic. If $f_\\alpha(\\alpha),f'_\\alpha(\\alpha) \\in K[X]$ both satisfy the definition of minimal polynomial, then we apply the polynomial division algorithm to write $$f_\\alpha(X) = p(X) f'_\\alpha(X) + r(X)$$ where $p(X),r(X) \\in K[X]$, and $\\deg r < \\deg f'_\\alpha$. Evaluate at $X=\\alpha$, we have $0=f_\\alpha(\\alpha) = p(\\alpha)f'_\\alpha(\\alpha)+r(\\alpha)=r(\\alpha)$. By minimality of $\\deg f'_\\alpha$, we must have $r=0$. Then $\\deg f_\\alpha = \\deg f'_\\alpha$, and $f_\\alpha(X),f'(\\alpha)$ are both monic, i.e. $p(X) = 1$ and $f_\\alpha(X) = f'_\\alpha(X)$.\n\n\\begin{lemma}(1.4)\\\\\nLet $L/\\Q$ be a field extension, and let $\\alpha \\in L$ be an algebraic integer. Then:\\\\\n(1) The minimal polynomial $f_\\alpha(X)$ of $\\alpha$ over $\\Q$ lies in $\\Z[X]$;\\\\\n(2) If $g(X) \\in \\Z[X]$ satisfies $g(\\alpha) = 0$, then there exists $q(X) \\in \\Z[X]$ such that $g(X) = f_\\alpha(X) q(X)$;\\\\\n(3) The kernel of the ring homomorphism $\\Z[X] \\to L$ by $f(X) \\to f(\\alpha)$ equals $(f_\\alpha(X))$, the ideal generated by $f_\\alpha(X)$.\n\\begin{proof}\n(1) Recall that if $f(X) = a_n X^n + ... + a_0 \\in \\Z[X]$, then we define from GRM, the content $c(f) = \\gcd(a_n,...,a_0)$. Recall Gauss' Lemma: If $f(X), g(X) \\in \\Z[X]$, then $c(fg) = c(f)c(g)$. Since $\\alpha \\in L$ is an algebraic integer, there exists monic $f(X) \\in \\Z[X]$ such that $f(\\alpha) = 0$, i.e. $c(f) = 1$. Apply polynomial division in $\\Q[X]$ to get $f(X) = p(X) f_\\alpha(X) +r(X)$, where $p(X),r(X) \\in \\Q[X]$, $\\deg r < \\deg f_\\alpha$. The definition of $f_\\alpha(X)$ implies that $r(X) = 0$, hence $f(X) = p(X) f_\\alpha(X)$. Now choose integers $n,m \\geq 1$ such that $np(X) \\in \\Z[X]$, $c(np) = 1$, and $mf_\\alpha(X) \\in \\Z[x]$, $c(mf_\\alpha) = 1$. Then $nmf(x) = (np(x))(mf_\\alpha(x)) \\implies c(nmf(x)) = nm = 1$. So $n=m=1$, hence $f_\\alpha(x) \\in \\Z[X]$.\\\\\n(2) Let $g(X) \\in \\Z[X]$ be such that $g(\\alpha) =0 $. WLOG $g(x) \\neq 0$ and $c(g) = 1$. Now apply polynomial division to write $g(x) = q(x) f_\\alpha(x) + s(x)$ where $q(x),s(x) \\in \\Q[x]$, $\\deg s < \\deg f_\\alpha$. Again by definition we have $s(x) = 0$. Choose an integer $k \\geq 1$ such that $kq(x) \\in Z[x]$ and $c(kq) =1$. Then $kg(x) = kq(x) f_\\alpha(x) \\implies k=c(kg) = c(kq) c(f_\\alpha) = 1$. So $k=1$, hence $q(x) \\in \\Z[x]$.\\\\\n(3) is a reformulation of (2).\n\\end{proof}\n\\end{lemma}\n\nLet $L/\\Q$ be a field extension. Last time we said $\\alpha \\in L$ is an algebraic integer if $\\exists$ monic polynomial $f(x) \\in \\Z[x]$ such that $f(\\alpha) = 0$. We proved that if $\\alpha \\in L$ is an algebraic integer and $f_\\alpha(x) \\in \\Q[x]$ is the minimal polynomial of $\\alpha$ over $\\Q$, then $f_\\alpha(x) \\in \\Z[x]$. However there is a small problem, so we'll prove again.\n\\begin{proof}\nChoose $f(x) \\in \\Z[x]$ monic with $f(\\alpha) = 0$, and write $$f(x) = q(x) f_\\alpha(x) + r(x)$$ where $q(x),r(x) \\in \\Q[x]$, $\\deg r < \\deg f_\\alpha$. Then $r(\\alpha) = 0 \\implies r(x) = 0$, by minimality of $\\deg f_\\alpha$. I said that we can find integer $n,m \\geq 1$ s.t. $nf\\alpha(x) \\in \\Z[x]$, $c(nf\\alpha) = 1$, $mq(x) \\in \\Z[x]$, $c(mq) = 1$. However we need to explain why do they exist. Note $f_\\alpha(x)$ and $q(x)$ are both monic. Choose integers $N,M \\geq 1$ such that $Nf_\\alpha(x) \\in \\Z[x]$, $Mq(x) \\in \\Z[x]$. Then $c(Nf_\\alpha) | N$, $c(Mq)|M$ as those are the leading term of the polynomial. Now let $N/c(Nf\\alpha) = n \\in \\Z$, $M/c(Mq) = m \\in \\Z$. Now $nmf(x) = (nf\\alpha(x)) (mq(x))$, so $c(nmf(x)) = nm = 1 \\implies n=m=1$.\n\\end{proof}\n\n\\begin{coro} (1.5)\\\\\nIf $\\alpha \\in \\Q$, then $\\alpha$ is an algebraic integer $\\iff$ $\\alpha \\in \\Z$.\n\\begin{proof}\nBy lemma 1.4, $\\alpha$ is an algebraic integer $\\iff f_\\alpha(x) \\in \\Z[x]$. But if $\\alpha \\in \\Q$, then $f_\\alpha(x) = x-\\alpha$, and the first needs to divide the second polynomial.\n\\end{proof}\n\\end{coro}\n\n\\begin{notation}\nIf $L/\\Q$ is any field extension, we write $\\mathcal{O}_L =\\{\\alpha \\in L | \\alpha$ is an algebraic integer$\\}$.\n\\end{notation}\n\nNow we proceed to the first non-trivial result of the course:\n\n\\begin{prop} (1.6)\\\\\nIf $L/\\Q$ is a field extension, $\\mathcal{O}_L$ is a ring.\n\\begin{proof}\nClearly $0,1 \\in \\mathcal{O}_L$. Now if $\\alpha \\in \\mathcal{O}_L$, then $f_{-\\alpha}(x) = (-1)^{\\deg f_\\alpha} f_\\alpha (-x) \\implies -\\alpha \\in \\mathcal{O}_L$.\\\\\nThe hard part is to show that if $\\alpha,\\beta \\in \\mathcal{O}_L$, then $\\alpha+\\beta \\in \\mathcal{O}_L$ and $\\alpha\\beta \\in \\mathcal{O}_L$.\\\\\nObserve that if $\\alpha \\in \\mathcal{O}_L$, then $\\Z[\\alpha] \\subseteq L$ is a finitely generated $\\Z$-module. By definition, $\\Z[\\alpha]$ is generated by $1,\\alpha,\\alpha^2,\\alpha^3,...$. Let $f_\\alpha(x) = x^d + a_1 x^{d-1} + ... + ad$, $a_i \\in \\Z$. Then $\\alpha^d = -(a_1 \\alpha^{d-1} + ... + ad)$, so $\\alpha^d \\in \\sum_{i=0}^{d-1} \\Z \\alpha^i$. By induction, we see that $\\alpha^n \\in \\sum_{i=0}^{d-1} \\Z \\alpha^i$ for all $n \\geq d$. Hence $\\Z[\\alpha] = \\sum_{i=0}^{d-1} \\Z \\alpha^i$. Now take $\\alpha,\\beta \\in \\mathcal{O}_L$ and let $d = \\deg f_\\alpha$, $e = \\deg f_\\beta$.\\\\\nBy definition, $\\Z[\\alpha,\\beta] =\\Z[\\alpha][\\beta]$ is generated as a $\\Z$-module by $\\{\\alpha^i\\beta^j\\}_{i,j \\in \\N}$. The same argument show that in fact this ring is generated as a $\\Z$-module by $\\{\\alpha^i \\beta^j\\}$ for $0\\leq i\\leq d-1, 0 \\leq j \\leq e-1$. So $\\Z[\\alpha,\\beta]$ is finitely generated. From GRM we know the classification of finitely generated $\\Z$-modules implies that there's an isomorphism $\\Z[\\alpha,\\beta] \\cong \\Z^r \\oplus T$ for some $r \\geq 1$ and finite abelian group $T$. In fact, $T=0$: if $\\gamma \\in T$, then $|T|\\gamma = 0$, by Lagrange's theorem. But $\\Z[\\alpha,\\beta] \\subseteq L$, a $\\Q$-vector space, so this forces $\\gamma = 0$. Now we can therefore fix an isomorphism $\\Z[\\alpha,\\beta] \\cong \\Z^r$ ($r \\geq 1$. There's an endomorphism $m_{\\alpha\\beta}: \\Z[\\alpha,\\beta] \\to \\Z[\\alpha,\\beta]$ by $\\gamma \\to \\alpha\\beta\\gamma$ (as a $\\Z$-module). $m_{\\alpha\\beta}$ corredponds to an $r \\times r$ matrx $A_{\\alpha\\beta} \\in M_{r \\times r} (\\Z)$.\\\\\nLet $F_{\\alpha\\beta}(x) = \\det (x\\cdot 1_r -A_{\\alpha\\beta}) \\in \\Z[x]$, a monic polynomial. By the Cayley-Hamilton theorem, $F_{\\alpha\\beta}(m_{\\alpha\\beta}) = 0$ as endomorphisms of $\\Z[\\alpha,\\beta]$. Write $F_{\\alpha\\beta}(x) = x^r + b_1x^{r-1} + ... + b_r$ for $b_i \\in \\Z$. Thus $m^r_{\\alpha\\beta} + b_1 m^{r-1}_{\\alpha\\beta} + ... + b_r \\cdot 1_r = 0$ as endomorphisms of $\\Z[\\alpha,\\beta]$.\\\\\nNow the image of $1$ is $(\\alpha\\beta)^r+b_1(\\alpha\\beta)^{r-1} + ... + b_r = F_{\\alpha\\beta}(\\alpha\\beta) = 0$. So $\\alpha\\beta \\in \\mathcal{O}_L$.\\\\\nThe argument to show $\\alpha+\\beta \\in \\mathcal{O}_L$ is identical, replacing $m_{\\alpha\\beta}$ by $m_{\\alpha+\\beta}: \\Z[\\alpha,\\beta] \\to \\Z[\\alpha,\\beta]$ by $\\gamma \\to (\\alpha+\\beta)\\gamma$. The detail is omitted here.\n\\end{proof}\n\\end{prop}\n\nWe call $\\mathcal{O}_L$ the ring of algebraic integers of $L$.\n\n\\begin{lemma} (1.7)\\\\\nLet $L/\\Q$ be a number field, and let $\\alpha \\in L$. Then $\\exists n \\geq 1$ an integer such that $n\\alpha \\in \\mathcal{O}_L$.\n\\begin{proof}\nLet $f(x) \\in \\Q[x]$ be a monic polynomial such that $f(\\alpha) = 0$. Then $\\exists n\\in \\Z, n \\geq 1$ such that $g(x) = n^{\\deg f} f(x/n) \\in \\Z[x]$ is monic. But then $g(n\\alpha) = n^{\\deg f} f(\\alpha) = 0$. So $n\\alpha \\in \\mathcal{O}_L$.\n\\end{proof}\n\\end{lemma}\n\n\\newpage\n\n\\section{Complex embeddings}\nLet $L$ be a number field.\n\\begin{defi} (2.1)\\\\\nA \\emph{complex embedding} of $L$ is a field homomorphism $\\sigma: L \\to \\C$. Note: in this case, $\\sigma$ is injective, and $\\sigma|_\\Q$ is the usual embedding $\\Q \\to \\C$.\n\\end{defi}\n\n\\begin{prop} (2.2)\\\\\nLet $L/K$ be an extension of number fields, and let $\\sigma_0:K \\to \\C$ be a complex embedding. Then there exist exactly $[L:K]$ embeddings $\\sigma:L \\to \\C$ which extends $\\sigma_0$ ($\\sigma|_K = \\sigma_0$).\n\\begin{proof}\nInduction on $[L:K]$. If $[L:K] = 1$, then $L=K$, so $\\sigma_0$ determines $\\sigma$.\\\\\nIn general, choose $\\alpha \\in L-K$ and consider $L/K(\\alpha)/K$. By the Tower law, $[L:K] = [L:K(\\alpha)][K(\\alpha):K]$ and $[K(\\alpha):K]>1$. By induction, it's enough to show there are exactly $[K(\\alpha):K]$ embeddings $\\sigma:K(\\alpha) \\to \\C$ extending $\\sigma_0$.\\\\\nLet $f_\\alpha(x) \\in K[x]$ be the minimal polynomial of $\\alpha$ over $K$. Observe there's an isomorphism $K[x] / (f_\\alpha(x)) \\to K(\\alpha)$ by sending $x \\to \\alpha$. To give a complex embedding $\\sigma:K(\\alpha) \\to \\C$ extending $\\sigma_0$, it's equivalent to give a root $\\beta$ of $(\\sigma_0 f)(x)$ in $\\C$ ($\\sigma_0 f(x) \\in \\C[x]$ means apply $\\sigma_0$ to the coefficients of $f(x)$). Dictionary: $\\sigma \\to \\beta = \\sigma (\\alpha)$. We have $[K(\\alpha):K] = \\deg f_\\alpha = \\deg \\sigma_0 f_\\alpha$. It's enough to show $\\sigma_0 f_\\alpha$ has distinct roots in $\\C$. The polynomial $f_\\alpha(x) \\in K[x]$ is irreducible, so is prime to its derivative $f'_\\alpha(x)$ ($char\\ K =0$). So $\\alpha$ is separable over $K$.\n\\end{proof}\n\\end{prop}\n\nRecall from last lecture, let $L$ be a number field, a complex embedding is a field homomorphism $\\sigma:L \\to \\C$. The number of such embeddings is $[L:\\Q$]. If $L = \\Q(\\alpha)$, and $f_\\alpha(x) \\in \\Q[x]$ is the minimal polynomial, then there is a bijection $\\{\\sigma:L \\to \\C \\} \\leftrightarrow \\{$ roots $\\beta \\in \\C$ of $f_\\alpha(x)\\}$ by sending $\\sigma \\to \\beta = \\sigma(alpha)$.\n\nNotation: if $\\sigma:L \\to \\C$ is a complex embedding, then $\\bar{\\sigma} : L \\to \\C$ is also a complex embedding, where $\\bar{\\sigma}(\\alpha) = \\overline{\\sigma(\\alpha)}$ (complex conjugation). If $\\sigma = \\bar{\\sigma}$, then $\\sigma(L) \\subseteq \\R$. Otherwise $\\sigma \\neq \\bar{\\sigma}$ and $\\sigma(L) \\not\\subseteq \\R$.\n\nWe write $r$ for the number of complex embedding $\\sigma$ such that $\\sigma = \\bar{\\sigma}$, $s$ for the number of pairs of embeddings $\\{\\sigma,\\bar{\\sigma}\\}$ where $\\sigma \\neq \\bar{\\sigma}$. Then $r+2s = [L:\\Q]$.\n\n\\begin{eg}\nLet $d \\in \\Z$ be square-free, $d \\neq 0,1$. Let $\\Q(\\sqrt{d}) = \\Q[x] / (x^2-d)$. If $d>0$, then $r=2,s=0$ (real quadratic field).\\\\\nIf $d<0$, then $r=0,s=1$ (imaginary quadratic field).\n\\end{eg}\n\n\\begin{eg}\nLet $m \\in \\Z$ cube-free, $m \\neq 0,1,-1$. Let $\\Q(\\sqrt[3]{m}) =\\Q[x]/(x^3-m)$. Then $r=1,s=1$, since $x^3-m$ has one real and two complex roots.\n\\end{eg}\n\n\\begin{defi} (2.3)\\\\\nLet $L/K$ be an extension of number fields, and let $\\alpha \\in L$. Let $m_\\alpha:L\\to L$ be the $K$-linear map defined by $m_\\alpha(\\beta) = \\alpha\\beta$. Then we define\n\\begin{equation*}\n\\begin{aligned}\n\\tr_{L/K}(\\alpha) = \\tr m_\\alpha \\in K\\\\\nN_{L/K}(\\alpha) = \\det m_\\alpha \\in K\n\\end{aligned}\n\\end{equation*}\nthe trace and norm of $\\alpha$ respectively.\n\\end{defi}\n\n\\begin{lemma} (2.4)\\\\\nIf $L/K$ is an extension of number fields and $\\alpha \\in L$, then \n\\begin{equation*}\n\\begin{aligned}\n\\tr_{L/K}(\\alpha) = [L:K(\\alpha)] \\tr_{K(\\alpha)/K}(\\alpha)\\\\\nN_{L/K}(\\alpha) = N_{K(\\alpha)/K} (\\alpha)^{[L:K(\\alpha)]}\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nThere's an isomorphism $L \\cong K(\\alpha)^{[L:K(\\alpha)]}$ of $K(\\alpha)$-vector spaces(?).\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (2.5)\\\\\nLet $L/K$ be an extension of number fields and let $\\alpha \\in L$. Let $\\sigma_0:K \\to \\C$ be a complex embedding, and let $\\sigma_1,...,\\sigma_n:L \\to \\C$ be the embeddings of $L$ extending $\\sigma_0$.\\\\\nThen \n\\begin{equation*}\n\\begin{aligned}\n\\sigma_0(\\tr_{L/K} (\\alpha)) = \\sigma_1(\\alpha) + ... + \\sigma_n(\\alpha)\\\\\n\\sigma_0(N_{L/K}(\\alpha)) = \\sigma_1(\\alpha)...\\sigma_n(\\alpha).\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nWLOG let $L=K(\\alpha)$. Let $f_\\alpha(x) \\in K[x]$ be the minimal polynomial of $\\alpha$ over $K$. Then $$(\\sigma_0 f_\\alpha)(x) = (x-\\sigma_1(\\alpha))(x-\\sigma_2(\\alpha))...(x-\\sigma_n(\\alpha))$$\nIf $f(\\alpha) = x^n+a_1x^{n-1}+...+a_n$, then $\\sigma_0(a_1) = -(\\sigma_1(\\alpha)+...+\\sigma_n(\\alpha))$, $\\sigma_0(a_n) = (-1)^n \\sigma_1(\\alpha)...\\sigma_n(\\alpha)$.\\\\\nLet $g(x) \\in K[x]$ be the characteristic polynomial of $m_\\alpha$. If $g(x) = x^n+b_1x^{n-1}+...+b_n$, then $b_1 = -\\tr m_\\alpha = -\\tr_{L/K}(\\alpha)$, $b_n = (-1)^n \\det m_\\alpha = (-1)^n N_{L/K}(\\alpha)$.By Cayley-Hamilton, $g(m_\\alpha) = 0 \\implies g(\\alpha) = 0 \\implies f_\\alpha(x) = g(x)$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro} (2.6)\\\\\nIf $\\alpha \\in \\mathcal{O}_L$, then $\\tr_{L/K}(\\alpha)$, $N_{L/K}(\\alpha) \\in \\mathcal{O}_K$.\n\\begin{proof}\nIf $\\beta \\in K$ then $\\beta \\in \\mathcal{O}_K$ $\\iff$ $\\sigma_0(\\beta) \\in \\mathcal{O}_\\C$ (as $\\forall f(x) \\in \\Z[x], f(\\beta) = 0 \\iff f(\\sigma_0(\\beta)) = 0$).\\\\\nBy the lemma, $\\sigma_0 \\tr_{L/K} (\\alpha) = \\sigma_1(\\alpha)+...+\\sigma_n(\\alpha)$. If $\\alpha \\in \\mathcal{O}_L$, then $\\sigma_1(\\alpha),...,\\sigma_n(\\alpha) \\in \\mathcal{O}_\\C \\implies \\sigma_1(\\alpha)+...+\\sigma_n(\\alpha) \\in \\mathcal{O}_\\C$ $\\implies \\sigma_0 \\tr_{L/K}(\\alpha) \\in \\mathcal{O}_\\C$ $\\implies \\tr_{L/K}(\\alpha) \\in \\mathcal{O}_K$.\n\nThe same argument works for the norm.\n\\end{proof}\n\\end{coro}\n\n\\begin{prop} (2.7)\\\\\nLet $d \\in \\Z$ be squarefree, $d \\neq 0,1$, and let $L = \\Q(\\sqrt{d})$. Then \n\\begin{equation*}\n\\begin{aligned}\n\\mathcal{O}_L = \\left\\{\\begin{array}{ll}\n\\Z[\\sqrt{d}] & d \\equiv 2,3 \\pmod 4\\\\\n\\Z[\\frac{1+\\sqrt{d}}{2}] & d \\equiv 1 \\pmod 4\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nIf $\\alpha \\in L$, then $\\alpha \\in \\mathcal{O}_L$ if and only if both trace and norm (over $L/\\Q$) of $\\alpha$ is in $\\Z$. Why? Forward direction is the previous corollary; if $\\alpha \\in L$, then $f(\\alpha) = 0$, where $f(x) = (x-\\sigma_1(\\alpha))(x-\\sigma_2(\\alpha)) = x^2 - \\tr_{L/\\Q}(\\alpha)x+N_{L/\\Q}(\\alpha) \\in \\Q[x]$, where $\\sigma_1,\\sigma_2$ are complex embeddings of $L$. So backward holds too.\n\nLet $\\alpha \\in L$. Write $\\alpha = \\frac{u}{2} + \\frac{v}{2}\\sqrt{d}$ where $u,v \\in \\Q$. If $\\alpha \\in \\mathcal{O}_L$, then $\\tr_{L/\\Q}(\\alpha) = u \\in \\Z$, and $N_{L/\\Q}(\\alpha) = \\frac{1}{4} (u+\\sqrt{d} v) (u-\\sqrt{d} v) = \\frac{1}{4} (u^2-dv^2) \\in \\Z$ $\\implies u^2-dv^2 \\in 4\\Z$ $\\implies dv^2\\in\\Z$.\\\\\nWrite $v=\\frac{r}{s}$ where $r,s \\in \\Z, s \\neq 0, (r,s) = 1$. Then we get $dr^2 \\in s^2\\Z$ $\\implies s^2 | dr^2$.\\\\\nIf $p$ is a prime and $p|s$ then $p^2|d$. But we assumed $d$ is square-free. So $s=1$, so $v \\in \\Z$.\n\nWe've shown if $\\alpha \\in \\mathcal{O}_L$, then $\\alpha = \\frac{u}{2} + \\frac{v}{2}\\sqrt{d}$ where $u,v \\in \\Z$ and $u^2 \\equiv d^2 \\pmod 4$.\\\\\n\nCase 1: $d \\equiv 2,3 \\pmod 4$. Then $u^2,v^2 \\equiv 0,1 \\pmod 4$. Considering the congruence $u^2\\equiv dv^2 \\pmod 4$ shows that both $u,v \\in 2\\Z$. Hence $\\alpha \\in \\Z[\\sqrt{d}] = \\{a+b\\sqrt{d} | a,b \\in \\Z\\}$, and $\\mathcal{O}_L = \\Z[\\sqrt{d}]$.\n\nCase 2: $d \\equiv 1 \\pmod 4$. Hence $u^2\\equiv v^2 \\pmod 4$, so $u \\equiv v \\pmod 2$. Hence $\\mathcal{O}_L \\subseteq \\{\\frac{u}{2}+\\frac{v}{2}\\sqrt{d} | u,v \\in \\Z, u \\equiv 1 \\pmod 2\\} =\\Z \\oplus \\Z(\\frac{1+\\sqrt{d}}{2})$. It remains to show that $\\frac{1+\\sqrt{d}}{2}$ is an algebraic integer.\\\\\nWe have $\\tr_{L/\\Q}(\\frac{1+\\sqrt{d}}{2}) = 1$, $N_{L/\\Q}(\\frac{1+\\sqrt{d}}{2}) = \\frac{1-d}{4} \\in \\Z$.\n\\end{proof}\n\\end{prop}\n\nRecall that if $R$ is a ring, then a unit in $R$ is an element $u \\in R$ such that there exists $v \\in R$ such that $uv = 1$.\n\nThe set $\\R^* = \\{u \\in R | u $ is a unit$\\}$ forms a group under multiplication.\n\n\\begin{lemma} (2.8)\\\\\nIf $L$ is a number field, then the units in $\\mathcal{O}_L$ are $\\mathcal{O}_L^* = \\{\\alpha \\in \\mathcal{O}_L| N_{L/\\Q}(\\alpha) = \\pm 1\\}$.\n\\begin{proof}\nnext time.\n\nIt's next time now! Let's prove this lemma.\\\\\n$N_{L/\\Q}(\\alpha\\beta)=N_{L/\\Q}(\\alpha)N_{L/\\Q}(\\beta)$ for any $\\alpha,\\beta \\in L$.\\\\\nIf $\\alpha \\in \\mathcal{O}_L^*$, then $\\exists \\beta \\in \\mathcal{O}_L$ such that $\\alpha\\beta = 1 \\implies N_{L/\\Q}(\\alpha) N_{L/\\Q}(\\beta) = 1$. Since $N_{L/\\Q}(\\alpha),N_{L/\\Q}(\\beta) \\in \\Z$, we get $N_{L/\\Q}(\\alpha) \\in \\{\\pm 1\\}$.\\\\\nConversely, suppose $\\alpha \\in \\mathcal{O}_L$ and $N_{L/\\Q} (\\alpha) = \\pm 1$. Then $\\alpha^{-1} \\in L$. Let $\\sigma_1,...,\\sigma_n:L \\to \\C$ be the distinct complex embeddings of $L$. Then \n\\begin{equation*}\n\\begin{aligned}\nN_{L/\\Q}(\\alpha) = \\sigma_1(\\alpha)...\\sigma_n(\\alpha) = \\pm 1\\\\\n\\implies \\sigma_1(\\alpha^{-1}) = \\pm \\sigma_2(\\alpha)...\\sigma_n(\\alpha) \\in \\mathcal{O}_\\C\\\\\n\\implies \\alpha^{-1} \\in \\mathcal{O}_L\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{lemma}\n\n\\begin{rem}\nWe'll prove later in the course that $\\mathcal{O}_L^*$ is a finite group $\\iff$ either $L=\\Q$ or $L$ is an imaginary quadratic field.\n\\end{rem}\n\n\\newpage\n\n\\section{Discriminants and integral bases}\nLet $L$ be a number field, $n=[L:\\Q]$, $\\sigma_1,...,\\sigma_n:L \\to \\C$ be distinct complex embeddings.\n\n\\begin{defi} (3.1)\\\\\nLet $\\alpha_1,...,\\alpha_n \\in L$. Then their discriminant is $disc(\\alpha_1,...,\\alpha_n) = \\det(D)^2$, where $D=M_{n\\times n}(F)$ is $D_{ij} = \\sigma_i (\\alpha_j)$. Note: this is independent of the choice of ordering of $\\sigma_1,...,\\sigma_n$ and $\\alpha_1,...,\\alpha_n$, as that's just permuting the rows or columns, hence changing only possibly signs; but we took a square in the definition.\n\\end{defi}\n\n\\begin{lemma} (3.2)\\\\\nLet $\\alpha_1,...,\\alpha_n \\in L$. Then $disc(\\alpha_1,...,\\alpha_n) = \\det(T)$, where $T \\in M_{n \\times n}(\\Q)$ is $T_{ij} = \\tr_{L/\\Q}(\\alpha_i\\alpha_j)$.\n\\begin{proof}\n$T_{ij} = \\sum_{k=1}^n \\sigma_k (\\alpha_i\\alpha_j) = \\sum_{k=1}^n D_{ki} D_{kj} = (D^T D)_{ij}$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro} (3.3)\\\\\n$disc(\\alpha_1,...,\\alpha_n) \\in \\Q$. If $\\alpha_1,...,\\alpha_n \\in \\mathcal{O}_L$, then $disc(\\alpha_1,...,\\alpha_n) \\in \\Z$.\n\\begin{proof}\n$disc(\\alpha_1,...,\\alpha_n) = \\det(T)$, and entries of $T$ is trace of some elements of $L$ (over $\\Q$) so is in the base field $\\Q$ (think a bit). So this must be rational. If $\\alpha_1,...,\\alpha_n \\in \\mathcal{O}_L$, then $\\forall i,j$, $D_{ij} \\in \\mathcal{O}_\\C \\implies disc(\\alpha_1,...,\\alpha_n) \\in \\mathcal{O}_\\C \\cap \\Q =\\Z$.\n\\end{proof}\n\\end{coro}\n\n\\begin{prop} (3.4)\\\\\nLet $\\alpha_1,...,\\alpha_n \\in L$. Then $disc(\\alpha_1,...,\\alpha_n) \\neq 0 \\iff \\alpha_1,...,\\alpha_n$ form a basis of $L$ as $\\Q$-vector space.\\\\\n\\begin{proof}\nFirst suppose $\\alpha_1,...,\\alpha_n$ are linearly dependent. Then the columns of the matrix $D_{ij} = \\sigma_i(\\alpha_j)$ are linearly depnedent $\\implies disc(\\alpha_1,...,\\alpha_n) = 0$ (determinant is 0).\\\\\nNow suppose $\\alpha_1,...,\\alpha_n$ are linearly independent. Then $disc(\\alpha_1,...,\\alpha_n) \\neq 0$ $\\iff \\det (T) \\neq 0$ $\\iff$ the symmetric bilinear form $\\phi:L \\times L \\to \\Q$ by $\\phi(\\alpha,\\beta) = \\tr_{L/\\Q}(\\alpha\\beta)$ is non-degenerate, i.e. $\\forall \\alpha \\in L^*, \\exists \\beta \\in L$ such that $\\phi(\\alpha,\\beta) \\neq 0$.\\\\\nIf $\\alpha \\in L^*$, then $\\phi(\\alpha,\\alpha^{-1}) = \\tr_{L/\\Q}(1) = n \\neq 0$.\n\\end{proof}\n\\end{prop}\n\n\\begin{defi} (3.5)\\\\\nWe say elements $\\alpha_1,...,\\alpha_n \\in L$ form an \\emph{integral basis for $\\mathcal{O}_L$}, if:\\\\\n(i) $\\alpha_1,...,\\alpha_n \\in \\mathcal{O}_L$;\\\\\n(ii) $\\alpha_1,...,\\alpha_n$ generate $\\mathcal{O}_L$ as a $\\Z$-module.\n\\end{defi}\n\n\\begin{lemma} (3.6)\\\\\nIf $\\alpha_1,...,\\alpha_n$ form an integral basis for $\\mathcal{O}_L$, then the function\n\\begin{equation*}\n\\begin{aligned}\nf: \\Z^n &\\to \\mathcal{O}_L\\\\\n(m_1,...,m_n) &\\to \\sum_{i=1}^n m_i\\alpha_i\n\\end{aligned}\n\\end{equation*}\nis an isomorphism of $\\Z$-module.\n\\begin{proof}\n$f$ is a homomorphism, we must show it's bijective. Observe that $\\alpha_1,...,\\alpha_n$ form a basis of $L$ as $\\Q$-vector space. We know that if $\\beta \\in L$, then $\\exists N \\in \\Z^+$ such that $N\\beta \\in \\mathcal{O}_L$ (I think (1.7)). So we can write $N\\beta = \\sum_{i=1}^n m_i \\alpha_i$ for some $m_1 \\in \\Z$ $\\implies \\beta = \\sum_{i=1}^n \\frac{m_i}{N}\\alpha_i$. Hence $\\alpha_1,...,\\alpha_n$ span $L$, so they form a basis of $L$.\\\\\nIf $f(m_1,...,m_n) = 0$, then $\\sum_{i=1}^n m_i \\alpha_i = 0 \\implies (m_1,...,m_n) = (0,...,0)$, as $\\alpha_1,...,\\alpha_n$ are independent over $\\Q$. This shows $f$ is injective. It's surjecitve by definition.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (3.7, sandwich lemma)\\\\\n(i) If $H \\leq G$ are groups and $G \\cong \\Z^a$ for some $a \\geq 0$, then $H \\cong \\Z^b$ for some $b \\leq a$.\\\\\n(ii) If $K \\leq H \\leq G$ are groups and $K \\cong \\Z^a$, $G \\cong \\Z^a$ for some $a \\geq 0$, then $H \\cong \\Z^a$.\\\\\n(iii) If $H \\leq G$ are groups and $H \\cong \\Z^a$, $G \\cong \\Z^a$ for some $a \\geq 0$, then $G/H$ is finite.\n\\begin{proof}\n(i) $H \\leq G$, $G \\cong \\Z^a$. Then $G/H$ is f.g abelian group. By the classification, there's an isomorphism $G/H \\cong \\Z^N \\oplus A$, $A$ finite abelian group. Choose $p$ prime, $p \\not\\mid |A|$. Then the map $f:G/H \\to G/H$ by $x+H \\to px + H$ is injective, so $f':H/pH \\to G/pG$ by $x+pH \\to x+pG$ is injecitve -- why? If $x \\in H, x \\in pG$, then $x = py$ for some $y \\in G$; then $y+H \\in \\ker(f) =H$. Hence $x \\in pH$. So indeed $f'$ is injective. By the classification, $H \\cong \\Z^b$. $f'$ injective $\\implies |H/pH| \\leq |G/pG|$, i.e. $p^b \\leq p^a$ so $b\\leq a$.\\\\\n(ii) Apply (i) to $K \\leq H$ and $H \\leq G$ to get $H \\cong \\Z^b$ where $a\\leq b\\leq a$.\\\\\n(iii) $H \\leq G$, $H \\cong \\Z^a, G \\cong \\Z^a$. Again $G/H$ is finitely generated, so by the classification $G/H \\cong \\Z^N \\oplus A$ where $A$ is a finite abelian group.\\\\\nLet $p$ be a prime, $p \\not\\mid |A|$. same proof as in (i) shows that $f':H/pH \\to G/pG$ is injecitve. Since $|H/pH| = |G/pG| = p^a$, $f'$ is a group isomorphism $G/H + pG \\cong (\\Z/p\\Z)^N$. There's a surjective homomorphism $G/pG \\to G/H+pG$ which has kernel containing the image of $f'$. Hence $G/pG \\to G/H + pG$ is surjective with kernel $G/pG$. This forces $N=0$.\n\\end{proof}\n\\end{lemma}\n\nLet $L$ be a number field, $n = [L:\\Q]$, $\\sigma_1,...,\\sigma_n:L \\to \\C$ be distinct complex embeddings; $\\alpha_1,...,\\alpha_n \\in L$, we defined $disc(\\alpha_1,...,\\alpha_n) = \\det(\\sigma_i(\\alpha_j))^2$. An alternative notation is $\\Delta(\\alpha_1,...,\\alpha_n)$. We also said $\\alpha_1,...,\\alpha_n$ form an integral basis for $\\mathcal{O}_L$ if they generate $\\mathcal{O}_L$ as a $\\Z$-module.\n\n\\begin{prop} (3.8)\\\\\nThere exists an integral basis for $\\mathcal{O}_L$.\n\\begin{proof}\nLet $\\beta_1,...,\\beta_n \\in L$ be a basis for $L$ as $\\Q$-vector space. WLOG, $\\beta_1,...,\\beta_n \\in \\mathcal{O}_L$. Then $\\mathcal{O}_L \\supset \\oplus_{i=1}^n \\Z \\beta_i$.\\\\\nRecall $\\phi:L \\times L \\to \\Q$ by sending $(\\alpha,\\beta) \\to \\tr_{L/\\Q} (\\alpha\\beta)$ is a non-degenerate symmetric bilinear form (we showed that last time). Let $\\beta_1^*,...,\\beta_n^*$ be the dual basis. Then $\\tr_{L/\\Q(\\beta_i \\beta_j^*)} = \\delta_{ij}$ (why?).\\\\\nIf $\\alpha \\in \\mathcal{O}_L$, then we can write $\\alpha = \\sum_{i=1}^n a_i \\beta_i^*$ where $a_i \\in \\Q$. We know $\\alpha\\beta_i \\in \\mathcal{O}_L$, hence $\\tr_{L/\\Q} (\\alpha\\beta) \\in \\Z$. However LHS = $\\sum_{j=1}^n \\tr_{L/\\Q} (a_j \\beta_j^* \\beta_i) = \\sum_{j=1}^n a_j \\tr_{L/\\Q} (\\beta_j^* \\beta_i) = a_j$. So $\\mathcal{O}_L \\subseteq \\oplus_{i=1}^n \\Z \\beta_i^*$. By sandwich lemma there is an isomorphism between $\\Z^n$ and $\\mathcal{O}_L$.\n\\end{proof}\n\\end{prop}\n\nIf $\\alpha_1,...,\\alpha_n$, $\\beta_1,...,\\beta_n$ are both integral bases for $\\mathcal{O}_L$, then there exists $A \\in M_{n \\times n} (\\Z)$ such that $\\beta_j = \\sum_{i=1}^n A_{ij}\\alpha_i$ for each $j=1,...,n$. Moreover, we must have $\\det(A) \\in \\{\\pm 1\\}$, and $A \\in GL_n(\\Z)$. Then $disc(\\beta_1,...,\\beta_n) = \\det(D')^2$, where $D'_{ij} = \\sigma_i(\\beta_j), D_{ij} = \\sigma_i(\\alpha_j)$. We have $D'_{ij} = \\sum_{k=1}^n \\sigma_i (A_{kj} \\alpha_k) = \\sum_{k=1}^n \\sigma_i (\\alpha_k) A_{kj} = (DA)_{ij}$.\n\nWe find $disc(\\beta_1,...,\\beta_n) = \\det(D')^2 = \\det(DA)^2 = \\det(D)^2 = disc(\\alpha_1,...,\\alpha_n)$. Therefore we could define:\n\n\\begin{defi} (3.9)\\\\\nThe discriminant $D_L$ of the number field $L$ is $disc(\\alpha_1,...,\\alpha_n)$, where $\\alpha_1,...,\\alpha_n$ is any integral basis for $\\mathcal{O}_L$.\n\\end{defi}\n\n\\begin{prop} (3.10)\\\\\nLet $L=\\Q(\\alpha)$, and let $f(x) \\in \\Q[x]$ be the minimal polynomial of $\\alpha$ over $\\Q$. Then \n\\begin{equation*}\n\\begin{aligned}\ndisc (1,\\alpha,\\alpha^2,...,\\alpha^{n-1}) = \\prod_{i<j} (\\sigma_i(\\alpha)-\\sigma_j(\\alpha))^2 = (-1)^{n(n-1)/2} N_{L/\\Q}(f'(\\alpha))\n\\end{aligned}\n\\end{equation*}\nIn part II Galois theory, we defined the discrimant of a polynomial, $disc f = \\prod_{i<j} (\\sigma_i(\\alpha) - \\sigma_j(\\alpha))^2$ where $\\alpha_i$'s are the roots of $f$.\n\\begin{proof}\nIf $D_{ij} = \\sigma_i(\\alpha^{j-1})$, $D \\in M_{n\\times n} (\\C)$, then $disc(1,\\alpha,...,\\alpha^{n-1}) = \\det(D)^2$. $D$ is a Vandermonde matrix, so we know $\\det(D) = \\prod_{i<j} (\\sigma_j(\\alpha) - \\sigma_i(\\alpha))$.\\\\\nOn the other hand, $N_{L/\\Q} (f'(\\alpha)) = \\prod_{i=1}^n \\sigma_i (f'(\\alpha)) = \\prod_{i=1}^n f'(\\sigma_i(\\alpha))$.\\\\\nUsing $f(x) = \\prod_{j=1}^n (x-\\sigma_j(\\alpha))$, we get RHS = $\\prod_{i=1}^n \\prod_{j \\neq i} (\\sigma_i(\\alpha) - \\sigma_j(\\alpha)) = (-1)^{n \\choose 2} \\prod_{i < j} (\\sigma_i(\\alpha) - \\sigma_j(\\alpha))^2$.\n\\end{proof}\n\\end{prop}\n\nNote: if $\\alpha \\in \\mathcal{O}_L$ and $\\Z[\\alpha] = \\mathcal{O}_L$, then $1,\\alpha,...,\\alpha^{n-1}$ is an integral basi for $\\mathcal{O}_L$. We can then use proposition to calculate $D_L$.\n\n\\begin{eg}\nLet $d\\in \\Z$ square-free, $d \\neq 0,1$, $L = \\Q(\\sqrt{d})$. Then \n\\begin{equation*}\n\\begin{aligned}\nD_L = \\left\\{\\begin{array}{ll}\n4d & d \\equiv 2,3 \\pmod 4\\\\\nd & d \\equiv 1 \\pmod 4\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\nTo see this, if $d \\equiv 2,3 \\pmod 4$, then $\\mathcal{O}_L = \\Z[\\sqrt{d}]$ (shown previously). Apply proposition to $x^2-d = f(x)$, we get $D_L = disc(1,\\sqrt{d}) = -N_{L/\\Q}(2\\sqrt{d}) = 4d$.\\\\\nOn the other hand, if $d \\equiv 1 \\pmod 4$, then $\\mathcal{O}_L = \\Z[\\frac{1+\\sqrt{d}}{2}]$. Apply proposition to the minimal polynomial of this element, $f(x) = x^2-x+\\frac{1-d}{4}$, so $f'(x) = 2x-1$, so $f'(\\alpha) = \\sqrt{d}$. Therefore $D_L = -N_{L/\\Q}(\\sqrt{d}) = \\sqrt{d}$.\n\\end{eg}\n\n\\begin{prop}\nIf $\\alpha_1,...,\\alpha_n \\in \\mathcal{O}_L$ are such that $disc(\\alpha_1,...,\\alpha_n)$ is a non-zero square-free integer, then $\\alpha_1,...,\\alpha_n$ form an integral basis for $\\mathcal{O}_L$.\\\\\nNote: this is a sufficient condition, but is not necessary (the previous example).\\\\\n\\begin{proof}\nLet $\\beta_1,...,\\beta_n$ be an integral basis for $\\mathcal{O}_L$. There exists $A \\in M_{n \\times n} (\\Z)$ such that $\\alpha_j = \\sum_{i=1}^n A_{ij} \\beta_i$ $\\forall j = 1,...,n$. Then $disc(\\alpha_1,...,\\alpha_n) = \\det(A)^2 disc(\\beta_1,...,\\beta_n)$ (we proved this in the beginning of lecture: $D'=DA$). In particular, if this is square-free and non-zero, then $\\det(A)$ must be $\\{\\pm 1\\}$. So $A \\in GL_n(\\Z)$. Hence $\\alpha_1,...,\\alpha_n$ generate $\\mathcal{O}_L$ (as they can generate $\\beta_i$) and form an integral basis.\n\\end{proof}\n\\end{prop}\n\nThis could save a lot of calculation if we are lucky.\n\\begin{eg}\nLet $f(x) = x^3-x-1$. Then $disc f = -4a^3 - 27b^2 = -23$. This is square-free! If $L=\\Q(\\alpha)$, $\\alpha$ a root of $f(x)$, then $\\mathcal{O}_L = \\Z[\\alpha]$.\n\\end{eg}\n\n\\begin{defi} (3.12)\\\\\nLet $I \\subseteq \\mathcal{O}_L$ be a no-zero ideal. Then elements $\\alpha_1,...,\\alpha_n \\in L$ form an integral basis for $I$ if:\\\\\n(i) $\\alpha_1,...,\\alpha_n \\in I$;\\\\\n(ii) $\\alpha_1,...,\\alpha_n$ generate $I$ as a $\\Z$-module.\n\\end{defi}\n\n\\begin{prop} (3.13)\\\\\nLet $I \\subseteq \\mathcal{O}_L$ be a non-zero ideal. Then there exists an integral basis for $I$.\n\\begin{defi}\nBy definition, $I \\subseteq \\mathcal{O}_L \\cong \\Z^n$. Let $\\alpha_1,...,\\alpha_n \\in \\mathcal{O}_L$ be an integral basis for $\\mathcal{O}_L$. Let $\\alpha \\in I$ be non-zero. Then $(\\alpha)\\subseteq I$, hence $\\oplus_{i=1}^n \\Z \\alpha \\alpha_i \\subseteq I \\subseteq \\mathcal{O}_L$. So by sandwich lemma, there is an isomorphism between $I$ and $\\Z^n$ as $\\Z$-module. Hence there exists an integral basis for $I$.\n\\end{defi}\n\\end{prop}\n\nAn interesting consequence of the proof:\n\\begin{defi} (3.14)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then we define its norm\n\\begin{equation*}\n\\begin{aligned}\nN(I) = [\\mathcal{O}_L:I]\n\\end{aligned}\n\\end{equation*}\nwhich is finite by the sandwich lemma.\n\\end{defi}\n\n\\begin{defi} (3.15)\\\\\nIf $I \\subset \\mathcal{O}_L$ is a non-zero ideal then we define $disc(I) = disc(\\alpha_1,...,\\alpha_n)$ where $\\alpha_1,...,\\alpha_n$ is an integral basis for $I$. (same argument shows $disc(I)$ depends only on $I$).\n\\end{defi}\n\n\\begin{lemma} (3.16)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then $disc(I) = disc(\\mathcal{O}_L) N(I)^2$.\n\\begin{proof}\nLet $\\alpha_1,...,\\alpha_n$, $\\beta_1,...,\\beta_n$ be integral bases for $\\mathcal{O}_L$ and $I$ respectively. Then $\\exists A \\in M_{n \\times n} (\\Z)$ such that $\\beta_j = \\sum_{i=1}^n A_{ij} \\alpha_i$ $\\forall j = 1,...n$, and $disc (\\alpha_1,...,\\alpha_n) \\det(A)^2 = disc(\\beta_1,...,\\beta_n)$. We must show $\\det(A)^2 = [\\mathcal{O}_L:I]^2$.\n\nIn fact, we'll show if $B \\in M_{n \\times n} (\\Z)$ and $\\det(B) \\neq 0$, then $|\\Z^n / B\\Z^n| = |\\det(B)|$. This suffices after identify $\\mathcal{O}_L \\cong \\Z^n$.\n\nRecall: $\\exists P,Q \\in GL_n(\\Z)$ such that $PBQ = D = Diag(d_1,...,d_n)$, $d_i \\in \\Z$ (Smith normal form). Hence we have $\\Z^n/B\\Z^n \\cong \\Z^n/D\\Z^n \\cong \\oplus_{i=1}^n \\Z/d_i \\Z \\implies |\\Z^n / B\\Z^n| = |\\Z^n / D\\Z^n| = \\prod_{i=1}^n |d_i|$.\\\\\nOn the other hand, $|\\det(B)| = |\\det(D)| = \\prod_{i=1}^n |d_i|$.\n\\end{proof}\n\\end{lemma}\n\nRemember we have $L$ a number field, $n=[L:\\Q]$, $\\sigma_1,...,\\sigma_n:L \\to \\C$ are distinct complex embeddings of $L$.\n\n\\begin{lemma} (3.17)\\\\\nLet $\\alpha \\in \\mathcal{O}_L \\setminus\\{0\\}$. Then $N((\\alpha)) = |N_{L/\\Q}(\\alpha)|$ (Note that's an ideal).\n\\begin{proof}\nLet $\\alpha_1,...,\\alpha_n$ be an integral basis for $\\mathcal{O}_L$. Then $\\alpha\\alpha_1,...,\\alpha\\alpha_n$ is an integral basis for $I=(\\alpha)$. So\n\\begin{equation*}\n\\begin{aligned}\ndisc(I) &= disc(\\alpha\\alpha_1,...,\\alpha\\alpha_n)\\\\\n&= \\det(\\sigma_i(\\alpha\\alpha_j))^2\\\\\n&= \\det(\\sigma_i(\\alpha)\\sigma_i(\\alpha_j))^2\\\\\n&= (\\prod_{i=1}^n \\sigma_i(\\alpha))^2 \\det(\\sigma_i(\\alpha_j))^2\\\\\n&= N_{L/\\Q}(\\alpha)^2 disc(\\mathcal{O}_L)\n\\end{aligned}\n\\end{equation*}\nAnd we showed last time that for any non-zero ideal $J \\subseteq \\mathcal{O}_L$, $disc(J) = N(J)^2 disc(\\mathcal{O}_L)$.\n\\end{proof}\n\\end{lemma}\n\nNotation: If $\\alpha \\in \\mathcal{L}-\\{0\\}$, we let $N(\\alpha) = N((\\alpha)) N(0) = 0$.\\\\\nThen $\\forall \\alpha,\\beta \\in \\mathcal{O}_L$, $N(\\alpha\\beta) = N(\\alpha)N(\\beta)$.\n\n\\newpage\n\\section{Unique factorisation in $\\mathcal{O}_L$}\nRecall: we say a ring $R$ is a unique factorisation domain (UFD) if\\\\\n(i) $R$ is an integral domain;\\\\\n(ii) if $x \\in R$ is non-zero and not a unit, then there exists an expression $x=p_1...p_r$ where $p_i \\in R$ are irreducible elements. This expression is unique in the sense that if $x = q_1...q_s$ is another such expression, then $r=s$ and after re-ordering, each $q_i$ is an associate of $p_i$ (i.e. $q_i \\in R^* p_i$, where $R^*$ is the field of units).\n\nAfter 2 years of Cambridge Maths we certainly know $\\Z$ is a UFD. However, if $L$ is a number field, $\\mathcal{O}_L$ need not be a UFD.\n\nIn fact, any non-zero $x \\in \\mathcal{O}_L$ which is not a unit can be expressed as a product of irreducible elements.\n\nIf $x \\in \\mathcal{O}_L$, then $x$ is a no-zero non-unit $\\iff N(x)>1$. Suppose $x \\in \\mathcal{O}_L$ is a non-zero non-unit which cannot be written as a product of irreducible elements, and with $N(x)$ minimal among elements with this property. Then $x=yz$ with $N(y) >1$, $N(z)>1$, hence $N(y)<N(x)$, $N(z)<N(x)$. By minimality of $N(x)$, both $y,z$ can be written as products of irreducible; contradiction.\n\n\\begin{eg}\nConsider $L=\\Q(\\sqrt{-5}$, $\\mathcal{O}_L = \\Z[\\sqrt{-5}]$, and $\\mathcal{O}_L^* = \\{\\pm 1\\}$. In $\\mathcal{O}_L$ we have $6 = 2 \\times 3 = (1+\\sqrt{-5})(1-\\sqrt{-5})$, and all of the four are irreducibles, and no two are associates (norms). So $\\mathcal{O}_L$ is not a UFD (famous example).\n\\end{eg}\n\nIdea: introduce ideal multiplication in order to reduce elements further.\n\nRecall that if $R$ is a ring and $I,J$ are ideals of $R$, then we define\n\\begin{equation*}\n\\begin{aligned}\nIJ = \\{\\sum_{i=1}^k a_ib_i | a_i \\in I, b_i \\in J\\},\\\\\nI+J = \\{a+b|a\\in I, b \\in J\\}\n\\end{aligned}\n\\end{equation*}\nWe can define an ideal $I \\subsetneq R$ to be irreducible if it does not admit an expression $I=JK$ where $J,K$ are proper ideals of $R$.\n\nKey point: even if $\\alpha \\in \\mathcal{O}_L$ is irreducible, the ideal $(\\alpha)$ need not be irreducible. For example in $\\Z[\\sqrt{-5}]$, we have $(2) = (2,1+\\sqrt{-5})^2$, $(3) = (3,1+\\sqrt{-5})(3,1-\\sqrt{-5})$.\n\n\\begin{defi} (4.1)\\\\\nIf $R$ is a ring, we say that an ideal $P \\subsetneq R$ is prime if $\\forall x,y \\in R$, $xy \\in P$ $\\implies x \\in P$ or $y \\in P$.\n\\end{defi}\n\n\\begin{lemma} (4.2)\\\\\nLet $R$ be a ring, and let $I,J,P \\subseteq R$ be ideals, and suppose $P$ is prime and $IJ \\subseteq P$. Then $I \\subseteq P$ or $J \\subseteq P$.\n\\begin{proof}\nWLOG $I \\not\\subseteq P$. Choose some $x \\in I \\setminus P$. If $y \\in J$, is any element, then $xy \\in IJ \\subseteq P$. So $y \\in P$. So $J \\subseteq P$.\n\\end{proof}\n\\end{lemma}\n\nFrom now on, $L$ is a number field.\n\n\\begin{lemma} (4.3)\\\\\nAny non-zero prime ideal $P \\subseteq \\mathcal{O}_L$ is a maximal ideal.\n\\begin{proof}\nRecall: if $R$ is a ring and $I \\subsetneq R$ is an ideal, then $I$ is prime $\\iff R/I$ is an integral domain, and $I$ is maximal $\\iff R/I$ is a field. If you don't remember these statements then I strongly encourage you to review GRM. If $p \\subseteq \\mathcal{O}_L$ is a non-zero prime ideal, then $\\mathcal{O}_L/P$ is a finite integral domain (of cardinality $N(P)$); any such ring is a field, so $P$ is also maximal.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (4.4)\\\\\nIf $I \\subsetneq \\mathcal{O}_L$ is a non-zero ideal, then there exist non-zero prime ideals $P_1,...,P_r \\subseteq \\mathcal{O}_L$ such that $P_1...P_r \\subseteq I$.\n\\begin{proof}\nFor contradiction, let $I \\subsetneq \\mathcal{O}_L$ be an ideal whicih does not have this property, and such that $N(I)$ is minimal among ideals not having this property. Then $I$ is not prime, so there exist elements $x,y \\in \\mathcal{O}_L$ such that $xy \\in I$ but $x \\not\\in I$, $y \\not\\in I$. But then it follows that $I \\subsetneq I+(x)$ and $I \\subsetneq I+(y)$. So $N(I+(x)), N(I+(y)) < N(I)$. By minimality of $N(I)$, we can find non-zero prime ideals $P_1...P_r \\subseteq I+(x)$ and $Q_1...Q_r \\subseteq I+(y)$. Then $P_1 ... P_rQ_1...Q_r \\subseteq (I+(x))(I+(y)) \\subseteq I^2 +xI+yI+(xy) \\subseteq I$. Contradiction.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (4.5)\\\\\nIf $I \\subsetneq \\mathcal{O}_L$ is a non-zero ideal, then there exists $\\gamma \\in L\\setminus \\mathcal{O}_L$ such that $\\gamma I \\subseteq \\mathcal{O}_L$.\n\\begin{proof}\nLet $\\alpha \\in I \\setminus \\{0\\}$. Let $P_1,...,P_r \\subseteq \\mathcal{O}_L$ be non-zero prime ideals such that $P_1...P_r \\subseteq (\\alpha)$. WLOG $r$ is minimal with this property. Let $P$ be a minimal ideal containing $I$. Then $P \\supseteq I \\supseteq (\\alpha) \\supseteq P_1...P_r$, hence $P \\supset P_i$ for some $i$. After relabelling assume $P \\supset P_1$. Since non-zero prime ideals are maximla, we have $P=P_1$. Since $r$ is minimal, we have $P_2...P_r \\not\\subseteq(\\alpha)$. Choose $\\beta \\in P_2...P_r \\setminus (\\alpha)$.\\\\\nClaim: the element $\\gamma = \\beta/\\alpha$ has the desired property.\\\\\nIf $\\gamma \\in \\mathcal{O}_L$, then $\\beta = \\alpha\\gamma \\in (\\alpha)$, contradiction;\\\\\n$\\gamma I = \\frac{\\beta}{\\alpha} I \\subseteq \\frac{1}{\\alpha} P_2...P_r \\cdot I \\subseteq \\frac{1}{\\alpha} P_1P_2...P_r \\subseteq \\mathcal{O}_L$.\n\\end{proof}\n\\end{lemma}\n\nLet $L$ be a number field. Last lecture we proved that if $I \\subsetneq \\mathcal{O}_L$ is a non-zero ideal, then there exist $\\gamma \\in L\\setminus \\mathcal{O}_L$ such that $\\gamma I \\subseteq \\mathcal{O}_L$.\n\n\\begin{prop} (4.6)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, there exists a non-zero ideal $J \\subseteq \\mathcal{O}_L$, such that $IJ$ is principal.\n\\begin{proof}\nChoose $\\alpha \\in I \\setminus \\{0\\}$. Define $J = \\{\\beta \\in \\mathcal{O}_L | \\beta I \\subseteq (\\alpha)\\}$. $J$ is a non-zero ideal, as $\\alpha \\in J$. We have $IJ \\subseteq (\\alpha)$. We will show $IJ = (\\alpha$.\\\\\nLet $K = \\frac{1}{\\alpha}IJ \\subseteq \\mathcal{O}_L$. We will show in fact that $K=\\mathcal{O}_L$. Suppose otherwise, that $K \\neq \\mathcal{O}_L$, then $\\exists \\gamma \\in L \\setminus \\mathcal{O}_L$ such that $\\gamma K \\subseteq \\mathcal{O}_L$.\\\\\nWe have $(\\alpha) \\subseteq I$, hence $\\frac{1}{\\alpha} I \\supseteq \\mathcal{O}_L$, hence $underbrace{\\frac{1}{\\alpha} IJ}_{K} \\supset J$. Hence $\\gamma J \\subseteq \\gamma K \\subseteq \\mathcal{O}_L$.\\\\\nAnother observation is that, we also have $\\gamma IJ = \\gamma \\alpha K \\subseteq (\\alpha)$.\\\\\nIf we have $\\beta \\in \\gamma J$, on one hand $\\beta \\in \\mathcal{O}_L$; on the other hand, $\\beta I \\subseteq (\\alpha)$. So $\\beta \\in J$, hence $\\gamma J \\subseteq J$.\\\\\nRecall that $J$ admits an integral basis, so ther's an isomorphism $J \\cong \\Z^n$. If $A \\in M_{n \\times n} (\\Z)$ is the matrix representing multiplication by $\\gamma$, and if $f(x) \\in \\Z[x]$ is the characteristic polynomial of $A$, then $f(\\gamma) = 0$.\\\\\nHence $\\gamma \\in \\mathcal{O}_L$. Contradiction. So $K = \\mathcal{O}_L$.\n\\end{proof}\n\\end{prop}\n\n\\begin{coro} (4.7)\\\\\nIf $I,J,K \\subseteq \\mathcal{O}_L$ are non-zero ideals and $IJ = IK$, then $J=K$.\n\\begin{proof}\nChoose a non-zero ideal $A \\subseteq \\mathcal{O}_L$ such that $AI = (\\alpha)$ is principal. Then $AIJ = \\alpha J = AIK = \\alpha K \\implies J=K$.\n\\end{proof}\n\\end{coro}\n\nIf $I,J \\subseteq \\mathcal{O}_L$ are non-zero ideals, say $I$ divides $J$ (or $I | J$) if there exists an ideal $K \\subseteq \\mathcal{O}_L$ such that $IK = J$.\n\n\\begin{coro} (4.8)\\\\\nIf $I,J \\subseteq \\mathcal{O}_L$ are non-zero ideals, then $I|J \\iff I \\supseteq J$.\n\\begin{proof}\nIf $IK=J$, then $J \\subseteq I$.\\\\\nSuppose instead that $I \\supseteq J$. Choose a non-zero ideal $A \\mathcal{O}_L$ such that $AI = (\\alpha)$ is principal (by 4.6). Then $AI =(\\alpha) \\supseteq AJ$, hence $\\mathcal{O}_L \\supseteq \\frac{1}{\\alpha} AJ$. So $K=\\frac{1}{\\alpha} AJ$ is a non-zero ideal of $\\mathcal{O}_L$, and $IK = \\frac{1}{\\alpha} AIJ = J$.\n\\end{proof}\n\\end{coro}\n\n\\begin{thm} (4.9)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then there exist prime ideals $P_1,...,P_r \\subseteq \\mathcal{O}_L$ such that $I = P_1P_2...P_r$. Moreover, this expression is unique up to re-ordering of terms.\n\\begin{proof}\nWe show existence by contradiction. Suppose $I$ is an ideal which cannot be written as product of primes, and with $N(I)$ minimal subject to this condition. We can find a maximal ideal $P \\supset I$. $P$ is also prime. Then $P|I$, so we can write $I=PJ$ for some ideal $J\\subseteq \\mathcal{O}_L$. Then $J|I$, hence $J \\supset I$. If $J=I$, then we get $I=IP$, hence $\\mathcal{O}_L = P$ as we can cancel, but that's a contradiction as prime ideals by definition cannot be $\\mathcal{O}_L$.\\\\\nTherefore $J \\supsetneq I$, hence $N(J) < N(I)$. By minimality, we can write $J$ as $J=P_2...P_r$ where each $P_i\\subseteq \\mathcal{O}_L$ are prime ideals. Then we have $I=PJ$. Contradiction. This shows existence.\n\nFor uniqueness, suppose $P_1,...,P_r$, $Q_1,...,Q_s$ are non-zero prime ideals in $\\mathcal{O}_L$ such that $P_1...P_r = Q_1...Q_s$. Then $P_1 | Q_1...Q_r$, so $P_1 \\supseteq Q_i$ for some $i=1,...,s$. WLOG $P_1 \\supset Q_1$. Since both $P_1,Q_1$ are maximal, $P_1 = Q_1$. Then we cancel to obtain $P_2...P_r = Q_2...Q_s$; continue this to get $r=s$ and $P_i = Q_i$ after re-ordering.\n\\end{proof}\n\\end{thm}\n\n\\begin{defi} (4.10)\\\\\nThe ideal class group $Cl(\\mathcal{O}_L) = \\{I\\subseteq \\mathcal{O}_L$ non-zero ideal$\\}$. $I \\sim J$ if $\\exists \\alpha \\in L^*$ such that $\\alpha I = J$.\\\\\nWe write $[I]$ for the equivalence class containing $I$.\n\\end{defi}\n\n\\begin{lemma} (4.11)\\\\\n$Cl(\\mathcal{O}_L$ is a group under the operation\n\\begin{equation*}\n\\begin{aligned}\n[I][J] = [IJ]\n\\end{aligned}\n\\end{equation*}\nwith identity $[\\mathcal{O}_L]$.\n\\begin{proof}\nIf $I,J \\subseteq \\mathcal{O}_L$ are non-zero ideals and $\\alpha,\\beta \\in L^*$ are such that $\\alpha I \\subseteq \\mathcal{O}_L$ and $\\beta J \\subseteq \\mathcal{O}_L$. Then\n\\begin{equation*}\n\\begin{aligned}\n(\\alpha I)(\\beta J) = \\alpha\\beta IJ\n\\end{aligned}\n\\end{equation*}\nso ideal multiplication is well-defined on equivalent classes.\\\\\nFor any $I \\subseteq \\mathcal{O}_L$, $\\mathcal{O}_L I = I$, so $[\\mathcal{O}_L]$ is an identity.\\\\\nWe showed that if $I \\subseteq \\mathcal{O}_L$ is any non-zero ideal, then there exists a non-zero ideal $J \\subseteq \\mathcal{O}_L$ such that $IJ = (\\alpha)$ is principal. Then $[I][J] = [IJ] = [(\\alpha)] = [\\mathcal{O}_L]$. Hence $[I]^{-1} = [J]$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{prop} (4.12)\\\\\nThe following are equivalent:\\\\\n(i) $\\mathcal{O}_L$ is a PID;\\\\\n(ii) $\\mathcal{O}_L$ is a UFD;\\\\\n(iii) The ideal class group, $Cl(\\mathcal{O}_L)$, is trivial.\n\\begin{proof}\n(i) implies (ii): In IB GRM.\\\\\n(ii) implies (iii): We must show any ideal $I \\subseteq \\mathcal{O}_L$ is principal. We know that we can write $I=P_1...P_r$ as a product of prime ideals.\\\\\nIt's therefore enough to show that every prime ideal of $\\mathcal{O}_L$ is principal. Let $P \\subseteq \\mathcal{O}_L$ be a non-zero prime ideal, let $\\alpha \\in P$ be non-zero, and let $\\alpha=\\alpha_1...\\alpha_r$ be an expression of $\\alpha$ as a product of irreducibles.\\\\\nRecall: if $R$ is a ring, then we say $x \\in R$ is prime if $\\forall y,z \\in R, x|yz \\implies x|y$ or $x|z$. Also we learned from GRM that if $R$ is a UFD then irreducible elements of $R$ are prime.\\\\\nWe find $P \\supset \\alpha = (\\alpha_1)...(\\alpha_r) \\implies P | P_1...P_r$ where $P_i = (\\alpha_i)$. Since $\\alpha_i$ is prime, $P_i$ is a prime ideal. Hence we must have $P=P_i = (\\alpha_i)$ for some $i$, and hence $P$ is principal.\\\\\n(iii) implies (i): Let $I \\subseteq \\mathcal{O}_L$ be a non-zero ideal. Since $Cl(\\mathcal{O}_L$ is trivial, we have $[I] = [\\mathcal{O}_L]$, so there exists $\\alpha \\in L^*$ such that $\\alpha \\mathcal{O}_L = I$. We have $\\alpha \\cdot 1 = \\alpha \\in I \\subseteq \\mathcal{O}_L$, so $\\alpha \\in \\mathcal{O}_L$, hence $I=(\\alpha)$ is principal.\n\\end{proof}\n\\end{prop}\n\n\\begin{lemma} (4.13)\\\\\nIf $I,J \\subseteq \\mathcal{O}_L$ are non-zero ideals, then $N(IJ) = N(I)N(J)$.\n\\begin{proof}\nExample sheet 2.\n\\end{proof}\n\\end{lemma}\n\nExample sheet 2 now available!\n\nLast time we learned that, if $L$ is a number field, then we know any non-zero ideal $I \\subseteq \\mathcal{O}_L$ canbe written uniquely as $I = \\prod_{i=1}^r P_i^{e_i}$, wher the $p_i$ are distinct prime ideals, and $e_i \\geq 1$. We also defined $Cl(\\mathcal{O}_L)$ as the obstruction to $\\mathcal{O}_L$ being a UFD.\n\n\\newpage\n\\section{Dedekind's criteion}\nIf $P\\subseteq \\mathcal{O}_L$ is a non-zero prime ideal, then there's a unique prime number $p \\in \\Z_{\\geq 0}$ such that $p \\in P$. $(p) = \\ker(\\Z \\to \\mathcal{O}_L/P)$. Then $P | p \\mathcal{O}_L$, and $N(P) = p^f$ for some $f \\geq 1$.\n\n\\begin{lemma} (5.1)\\\\\nLet $p$ be a prime number, and factor $p\\mathcal{O}_L = \\prod_{i=1}^r P_i^{e_i}$ where $P_1,...,P_r$ are distinct prime ideals of $\\mathcal{O}_L$, $e_i \\geq 1$. Define $f_i \\geq 1$ by $N(P_i) = p^{f_i}$. Then $\\sum_{i=1}^r e_i f_i = [L:\\Q]$. In particular, $r \\leq [L:\\Q]$.\n\\begin{proof}\nApply norm to get $N(p\\mathcal{O}_L) (=p^{[L:\\Q]}) = \\prod_{i=1}^r N(P_i)^{e_i} (=p^{\\prod_{i=1}^r e_if_i})$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi} (5.2)\\\\\nLet $p$ be a prime number, and let $p\\mathcal{O}_L = \\prod_{i=1}^r P_i^{e_i}$ be the factorization as above.\\\\\n(i) We say $p$ \\emph{ramifies} in $L$ if $e_i > 1$ for some $i$. We say $p$ is totally \\emph{ramified} if $r=1$ and $e_1 = [L:\\Q]$. In other words, $p\\mathcal{O}_L = P_i^{[L:\\Q]}$.\\\\\n(ii) We say $p$ is \\emph{inert} in $L$ if $r=1$ and $e_1 = 1$, i.e. $p\\mathcal{O}_L$ is prime.\\\\\n(iii) We say $p$ \\emph{splits completely} in $L$ if $r=[L:\\Q]$ and $e_i=f_i=1$ for all $i$.\n\nNote that these don't cover all the possible cases.\n\\end{defi}\n\n\\begin{thm} (5.3, Dedekind's criterion)\\\\\nLet $\\alpha \\in \\mathcal{O}_L$ be such that $L=\\Q(\\alpha)$. Let $f(x) \\in \\Z[x]$ be its minimal polynomial and let $p$ be a prime such that $p \\nmid [\\mathcal{O}_L:\\Z[\\alpha]]$.\\\\\nLet $\\bar{f}(x) = f(x) \\pmod p$, and factor $\\bar{f}(x) = \\prod_{i=1}^r \\bar{g}_i(x)^{e_i}$ in $F_p[x]$, where $\\bar{g}_1(x),...,\\bar{g}_r(x) \\in F_p[x]$ are distinct monic irreducible polynomials. Let $g_i(x) \\in \\Z[x]$ be any polynomial with $g_i(x) \\pmod p = \\bar{g}_i(x)$, and define $Q_i = (p,g_i(\\alpha)) \\subseteq \\mathcal{O}_L$, an ideal of $\\mathcal{O}_L$. Let $f_i = \\deg \\bar{g}_i(x)$.\\\\\nThen $Q_1,...,Q_r$ are distinct prime ideals of $\\mathcal{O}_L$, and $p\\mathcal{O}_L = \\prod_{i=1}^r Q-i^{e_i}$, and $N(Q_i) = p^{f_i}$.\n\\end{thm}\n\nFor example, let's take $L=\\Q(\\sqrt{-11})$, $p=5$. We see $-11 \\equiv 1 \\pmod 4$, so $\\mathcal{O}_L = \\Z [ \\frac{1+\\sqrt{-11}}{2}]$. Thus $\\Z[\\sqrt{-11}] \\subseteq \\mathcal{O}_L$ has index 2 as an additive subgroup. Therefore we can apply Dedekind's criterion to $\\alpha = \\sqrt{-11}$, with $f(x) = x^2+11$ in order to factorize $5\\mathcal{O}_L$. We see $\\bar{f}(x) = f(x) \\pmod 5 = x^2+1 = (x+2)(x+3)$ in $F_5[x]$. So $t\\mathcal{O}_L = PQ$ where $P = (5,\\sqrt{-11}+2), Q = (5,\\sqrt{-11},3)$, and hence $P,Q$ are the same prime ideals (of $\\mathcal{O}_L$). Thus $5\\mathcal{O}_L$ splits completely in $\\mathcal{Q}\\sqrt{-11}$.\n\n\\begin{proof} (of 5.3)\\\\\nRecall: if $R$ is a ring and $I \\subseteq R$ is an ideal, then there's a bijection between ideals containing $I$ and idealks of $R/I$. 3rd isomorphism theorem gives $R/J \\cong (R/I)/(J/I)$. We have $\\Z[\\alpha] \\subseteq \\mathcal{O}_L$ of finite index. Let $A = \\Z[\\alpha]$, $\\phi:A \\to \\mathcal{O}_L$. By reduction mod $p$, we get another ring homomorphism $\\bar{\\phi}: A/pA \\to \\mathcal{O}_L / p\\mathcal{O}_L$ by $\\bar{\\phi}(\\beta+pA) = \\beta + p\\mathcal{O}_L$.\\\\\nWe claim that this is actually an isomorphism. Both source and targe have cardinality $p^{[L:\\Q]}$, so it's enough to show $\\bar{\\phi}$ is surjective. Let $N=[\\mathcal{O}_L:\\Z[\\alpha]]$. We can find $a,b \\in \\Z$ such that $aN+bp = 1$. If $\\beta \\in \\mathcal{O}_L$, then $N\\beta \\in \\Z[\\alpha]$ (by Lagrance), and $\\beta = aN\\beta + bp\\beta \\implies \\bar{\\phi} (aN\\beta + pA) = \\beta + p\\mathcal{O}_L$. Therefore there is a bijection between ideals in $\\mathcal{O}_L$ containing $p$ and ideals of $A/pA$.\\\\\nWe have $A=\\Z[\\alpha] \\cong \\Z[x] / (f(x))$ by sending $\\alpha$ to $x$. Reduction mod $p$ gives an isomorphism $A/pA \\cong \\Z[x] / (p,f(x)) \\cong F_p[x]/ (\\bar{f}(x))$. We have $\\bar{f}(x) = \\prod_{i=1}^r \\bar{g}_i(x)^{e_i}$, so there are homomorphisms $F_p[x] / (\\bar{f}(x)) \\to \\F_p[x]/(\\bar{g}_i(x))$, given by quotient by the ideal $(\\bar{g}_i (x)) \\supseteq (\\bar{f}(x))$. Define $\\Q_i \\subseteq \\mathcal{O}_L$ to be the ideal containing $p$ such that $\\Q_i/(p)$ is the kernel of the ring homomorphism $\\mathcal{O}_L/p\\mathcal{O}_L \\xrightarrow{\\bar{\\phi}^{-1}} A/pA \\xrightarrow{\\cong} F_p[x]/(\\bar{f}(x)) \\to F_p[x]/(\\bar{g}_i(x))$. This ring homomorphism is surjective, and its image is a field of cardinality $p^{f_i}$. Hence $\\mathcal{O}_L/\\Q_i$ is a finite field of cardinality $p^{f_i}$, hence $\\Q_i$ is a prime ideal of norm $N(\\Q_i) = p^{f_i}$.\\\\\nAlso, the $\\Q_i$ are distinct, because their images in $\\mathcal{O}_L/p\\mathcal{O}_L$ are distinct, as if $i \\neq j$ then $(\\bar{g}_i(x),\\bar{g}_j(x))$ is the unit ideal of $F_p[x]$. To show $\\Q_i = (p,g_i(\\alpha))$, it's enough to show $\\Q_i/(p) \\subseteq \\mathcal{O}_L/p\\mathcal{O}_L$ is generated by $\\bar{g}_i(\\alpha)$. This is equivalent to showing that $\\ker(F_p[x] / (\\bar{f}(x)) \\to F_p[x]/(\\bar{g}_i(x)))$ is generated by $\\bar{g}_i(x)$. This is true by definition.\\\\\nIt remains to show $Q_1^{e_1}...Q_r^{e_r} = p\\mathcal{O}_L$. We have\n\\begin{equation*}\n\\begin{aligned}\nQ_1^{e_1}...Q_r^{e_r} &= (p_1g_1(\\alpha))^{e_1}...(p_rg_r(\\alpha))^{e_r}\\\\\n&=(p_1g_1(\\alpha)^{e_1}) ... (p_1g_r(\\alpha)^{e_r})\\\\\n&\\leq (p,g_1(\\alpha)^{e_1})...(g_r(\\alpha)^{e_r}) = (p,f(\\alpha))=(p)\n\\end{aligned}\n\\end{equation*}\nTake norms, $N(LHS) = \\prod_{i=1}^r N(Q_i)^{e_i} = p^{\\sum_{i=1}^r e_i f_i} =p^{\\deg f} = p^{[L:\\Q]} = N(p) = N(RHS)$. This forces $Q_1^{e_1}...Q_r^{e_r} = p\\mathcal{O}_L$.\n\\end{proof}\n\nLet $L$ be a number field. Last time we had that if $\\alpha \\in \\mathcal{O}_L$, $\\Q(\\alpha) = L$, $p \\nmid [\\mathcal{O}_L:\\Z[\\alpha]]$. Dedekind's criterion: can factor $p\\mathcal{O}_L$ by factoring $f_\\alpha(x) \\pmod p$.\n\n\\begin{prop} (5.4)\\\\\nLet $d$ be a square-free integer, $d \\neq 0,1$, $L = \\Q(\\sqrt{d})$, and let $p$ be a prime number. Then\\\\\n(1) If $p$ is odd, then:\\\\\n$\\bullet$ if $p|d$, then $(p) = P^2$, so $p$ ramifies in $L$;\\\\\n$\\bullet$ if $p \\nmid d$ and $(\\frac{d}{p}) = 1$, then $(p) = PQ$, so $p$ splits completely in $L$;\\\\\n$\\bullet$ if $p \\nmid d$ and $(\\frac{d}{p} = -1$, then $(p)$ is prime and $p$ is inert in $L$.\\\\\n(2) If $p=2$, then:\\\\\n$\\bullet$ if $d \\equiv 2,3 \\pmod 4$, then 2 ramifies in $L$;\\\\\n$\\bullet$ if $d \\equiv 1 \\pmod 8$, then 2 splits completely in $L$;\\\\\n$\\bullet$ if $d \\equiv 5 \\pmod 8$, then $2$ is inert in $L$.\n\\begin{proof}\nWe just do the case where $p=2$. If $d \\equiv 2,3 \\pmod 4$, then $\\mathcal{O}_L = \\Z[\\sqrt{d}]$, so by Dedekind's criterion, we must factor $x^2 - d \\pmod 2$. But $x^2-d \\equiv (x-d)^2 \\pmod 2$. If $d \\equiv 1 \\pmod 4,$ then $\\mathcal{O}_L = \\Z[\\frac{1+\\sqrt{d}}{2}]$, so we must factor $x^2+x+\\frac{1-d}{4} \\pmod 2$. If $d \\equiv 1 \\pmod 8$, this is $x^2+x = x(x+1) \\pmod 2$. If $d \\equiv 5 \\pmod 8$, this is $x^2+x+1 \\pmod 2$ which is irreducible.\n\\end{proof}\n\\end{prop}\n\n\\newpage\n\\section{Geometry of numbers}\n\n\\begin{defi} (6.1)\\\\\nIf $V$ is a finite dimensional $\\R$-vector space, then a lattice in $V$ is a subgroup of the form $\\Lambda = \\oplus_{i=1}^m \\Z v_i$, where $v_1,...,v_n$ is a basis of $V$ as $\\R$-vector space (for example, $\\Z^n \\subseteq \\R^n$).\n\\end{defi}\n\n\\begin{defi} (6.2)\\\\\nIf $V$ is a finite-dimensional inner product space over $\\R$, and $\\Lambda \\subseteq V$ is a lattice, then the covolume of $\\Lambda$ is \n\\begin{equation*}\n\\begin{aligned}\nA(\\Lambda) = vol(\\{\\sum_{i=1}^n t_i v_i | t_i \\in [0,1)\\})\n\\end{aligned}\n\\end{equation*}\nwhere $\\Lambda = \\oplus_{i=1}^n \\Z v_i$.\\\\\nCheck: this is independent of the choice of basis $v_1,...,v_n$.\n\\end{defi}\n\nFor today, let's consider only a fixed imaginary quadratic field $L = \\Q(\\sqrt{d})$ where $d<0$ is a square-free integer. Let's take $\\sigma:L \\to \\Q$ be a complex embedding. Then $\\sigma(\\mathcal{O}_L)$ is a lattice in $\\phi$. If $d \\equiv 2,3 \\pmod 4$, then $\\sigma(\\mathcal{O}_L) = \\Z \\oplus \\Z [\\sqrt{d}]$; if $d \\equiv 1 \\pmod 4$ then $\\sigma(\\mathcal{O}_L) = \\Z \\oplus \\Z (\\frac{1+\\sqrt{d}}{2})$\\\\\nIf $I \\leq \\mathcal{O}_L$ is a non-zero ideal, then $\\sigma(I)$ is a lattice in $\\C$.\n\n\\begin{lemma} (6.3)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then $A(I) = \\frac{1}{2} \\sqrt{|disc(I)|} = \\frac{N(I)}{2} \\sqrt{|D_L|}$.\n\\begin{proof}\nLet $\\alpha_1,\\alpha_2$ be an integral basis for $I$. Then $\\sigma(I) = \\Z \\sigma(\\alpha_1) \\oplus \\Z \\sigma (\\alpha_2)$. Write $\\alpha_1 = x_1+iy_1,\\alpha_2=x_2+iy_2$, then $A(\\sigma(I)) = |\\det{{x_1 \\ x_2} \\choose {y_1 \\ y_2}}|$ (area of a parallelogram).\\\\\nThen \n\\begin{equation*}\n\\begin{aligned}\ndisc(I) = \\det \n\\begin{pmatrix}\nx_1+iy_1 & x_2 + iy_2\\\\\nx_1 - iy_1 & x_2 - iy^2\n\\end{pmatrix} \n= \n(2i)^2 \\det \n\\begin{pmatrix}\ny_1 & y_2\\\\\nx_1 & x_2\n\\end{pmatrix}\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{lemma}\n\n\\begin{thm} (6.4, special case of Minkovski's theorem)\\\\\nLet $\\Lambda \\subseteq \\R^2$ be a lattice, and let $S=D(0,r) \\subseteq \\R^2$ be the closed disk of radius $r$. Then if $area(S) \\geq 4A(\\Lambda)$, then $\\exists \\lambda \\in \\Lambda - \\{0\\}$ such that $\\lambda \\in S$.\\\\\nIn particular, there exists $\\lambda \\in \\Lambda - \\{0\\}$ such that $|\\lambda|^2 \\leq \\frac{4}{\\pi} A(\\Lambda)$.\n\\end{thm}\n\n\\begin{coro} (6.5)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then there exists $\\alpha \\in I-\\{0\\}$ s.t. $N(\\alpha) \\leq c_LN(I)$, where $c_L := \\frac{2}{\\pi} \\sqrt{|D_L|}$.\n\\begin{proof}\nWe apply the theorem to $\\sigma(I) \\subseteq \\C$ to get $\\lambda \\in \\sigma(I) - \\{0\\}$, such that $|\\lambda|^2 \\leq \\frac{4}{\\pi} \\cdot \\frac{N(I)}{2} \\sqrt{|D_L|} = c_l N(I)$. If $\\alpha \\in I$ is such that $\\sigma(\\alpha) = \\lambda$, then $N(\\alpha) = \\sigma(\\alpha) \\overline{\\sigma(\\alpha)} = |\\sigma(\\alpha)|^2 = |\\lambda|^2$.\n\\end{proof}\n\\end{coro}\n\n\\begin{coro} (6.6)\\\\\nIf $[I] \\in Cl(\\mathcal{O}_L)$, then there exists $J \\in [I]$ such that $N(J) \\leq c_L$.\n\\begin{proof}\nChoose $k \\in [I]^{-1}$ so that $IK$ is principal. Apply the corollary to find $\\alpha \\in K-\\{0\\}$, such that $N(\\alpha) \\leq c_L N(K)$. Then $(\\alpha) \\subseteq K \\implies K | (\\alpha) \\implies \\exists J \\subseteq \\mathcal{O}_L$ non-zero ideal such that $JK = (\\alpha)$. We have $[J] = [K]^{-1} = [I]$, so $J \\in [I]$. Also, $N(J) = N(\\alpha) / N(K) \\leq c_L$.\n\\end{proof}\n\\end{coro}\n\n\\begin{thm} (6.7)\\\\\nThe group $Cl(\\mathcal{O}_L)$ is finite. (we'll prove this for any $L$ next time).\n\\begin{proof}\nWe've shown every class $[I] \\in Cl(\\mathcal{O}_L)$ has a representative of norm $\\leq c_L$. It therefore suffices to show that $\\forall m \\in \\Z, m \\geq 1$, the number of ideals $I \\subseteq \\mathcal{O}_L$ of norm $N(I) = m$ is finite. If $N(I) = m$, then $[\\mathcal{O}_L:I] = m$, so by Lagrance, $m \\in I$. Thus $I$ comes from an ideal of the finite ring $\\mathcal{O}_L / m\\mathcal{O}_L$.\n\\end{proof}\n\\end{thm}\n\nNote: we see $CL(\\mathcal{O}_L)$ is generated by ideal classes $[P]$, where $P \\subseteq \\mathcal{O}_L$ is a non-zerp prime ideal of norm $N(P) \\leq c_L$. Why? Any class has the form $[I]$, where $N(I) \\leq c_L$. If $I = \\prod_{i=1}^r p_i^{e_i}$, then $[I] = \\pod_{i=1}^r [P_i]^{e_i}$ and $N(I) = \\prod_{i=1}^r N(P_i)^{e_i}$, so $N(P_i) \\leq N(I) \\leq c_L$ for each $i=1,...,r$.\n\n\\begin{eg}\nConsider $d=-7$. $d \\equiv 1\\pmod 4$, so $D_L = -d$, $c_l = \\frac{2}{\\pi} \\sqrt{7} < \\frac{2}{3} \\sqrt{7} < 2$.\\\\\n$Cl(\\mathcal{O}_L)$ is generated by ideals of norm $<2$. There are none except $\\mathcal{O}_L$, so $Cl(\\mathcal{O}_L)$ is the trivial group. Hence $\\mathcal{O}_L = \\Z[\\frac{1+\\sqrt{-7}}{2}]$ is a UFD.\\\\\n$d=-5$: $D_L = -4d$, $c_L = \\frac{2}{\\pi} \\sqrt{70} = \\frac{4}{\\pi} \\sqrt{5} < \\frac{4}{3}\\sqrt{5} < 3$. Hence $Cl(\\mathcal{O}_L)$ is generated by prime ideals $P \\subseteq \\mathcal{O}_L$ of norm $N(P) = 2$. We know by Dedekind's criterion that $2\\mathcal{O}_L = P^2$. Hence $Cl(\\mathcal{O}_L)$ is generated by $[P]$, and $[P]^2 = [2\\mathcal{O}_L]$ is the trivial class.\\\\\nHence there are two possibilities: if $P$ is principal, then $Cl(\\mathcal{O}_L)$ is trivial; if $P$ is not principal, then $Cl(\\mathcal{O}_L) \\cong \\Z/2\\Z$. We know $\\mathcal{O}_L$ is not a UFD, so we must have $Cl(\\mathcal{O}_L) \\cong \\Z/2\\Z$.\n\\end{eg}\n\nLast time we see that if $L$ is an imaginary quadratic field, then $Cl(\\mathcal{O}_L)$ is finite, generated by $[P]$ where $P$ is a prime ideal of norm $N(P) \\leq C_L$, where $C_L = \\frac{2}{\\pi} \\sqrt{|D_L|}$.\n\nThis time we will show the case of a general number field $L$.\n\n\\begin{thm} (6.8, Minkowski's theorem)\\\\\nLet $\\Lambda \\subseteq \\R^n$ be a lattice, and let $E \\subseteq \\R^n$ be a measurable subset which is conve, and centrally symmetric ($E=-E = \\{x \\in \\R^n | -x \\in E\\}$). Then:\\\\\n(i) If $vol(E) > 2^n A(\\Lambda)$, then $\\exists \\lambda \\in \\Lambda \\setminus \\{0\\}$ such that $\\lambda \\in E$;\\\\\n(i) If $vol(E) \\geq 2^n A(\\Lambda)$ and $E$ is compact, then $\\exists \\lambda \\in \\Lambda \\setminus \\{0\\}$ such that $\\lambda \\in E$.\\\\\n(we used this last time in the special case $n=2$, $E$=closed disk).\n\\begin{proof}\nLet $\\Lambda = \\oplus_{i=1}^n \\Z v_i$, $P = \\{\\sum_{i=1}^n t_i v_i | t_i \\in [0,1)\\}$. Then $vol(P) = A(\\Lambda)$, and $\\R^n = \\sqcup_{\\lambda \\in \\Lambda} (P+\\lambda)$.\\\\\n(i) $vol(P) < \\frac{1}{2^n} vol(E) = vol(\\frac{1}{2} E) = \\sum_{\\lambda \\in \\Lambda} vol([\\frac{1}{2} E] \\cap [\\lambda+P]) = \\sum_{\\lambda \\in \\Lambda} vol ([\\frac{1}{2} E - \\lambda] \\cap P)$.\\\\\nWe claim that there exists $\\lambda\\neq\\mu \\in \\Lambda$ such that $(\\frac{1}{2} E - \\lambda) \\cap (\\frac{1}{2} E - \\mu)$ is non-empty. Why? If not, sets $\\frac{1}{2} E - \\lambda$ are pairwise disjoint, so $vol(P) < \\sum_{\\lambda \\in \\Lambda} vol([\\frac{1}{2} E-\\lambda]\\cap P) \\leq vol(P)$, contradiction.\\\\\nHence $\\exists z,w \\in E$ such that $\\frac{z}{2} - \\lambda = \\frac{w}{2} - \\mu$, where $\\lambda \\neq \\mu \\in \\Lambda$, so $\\lambda-\\mu = \\frac{z}{2} - \\frac{w}{2} = \\frac{z}{2} + \\frac{(-w)}{2}$. Since $E$ is centrally symmetric, $-w \\in E$, and $E$ is convex implies that $\\frac{z}{2} + \\frac{(-w)}{2} \\in E$, so $\\lambda -\\ mu \\in (\\Lambda \\setminus \\{0\\}) \\cap E$.\\\\\n(ii) $E$ compact implies that $E$ is closed and bounded. $vol(E) \\geq 2^n A(\\Lambda)$ so $\\forall m \\geq 1$, $vol((1+\\frac{1}{m}) E) > 2^n A(\\Lambda)$. By (i), $\\forall m \\in \\N \\exists s\\lambda_m \\in (\\Lambda \\setminus \\{0\\})\\cap((1+\\frac{1}{m})E)$, and $(1+\\frac{1}{m})E \\subseteq 2E$, and $2E \\cap \\Lambda$ is finite as $2E$ is bounde. By pigeonhole principle we can assume $\\exists \\lambda \\in \\Lambda \\setminus \\{0\\}$ such that $\\lambda_m = \\lambda \\forall m \\geq 1$. $E$ closed and $\\lambda \\in (1+\\frac{1}{m})E \\forall m \\geq 1$ $\\implies \\lambda \\in E$. Now let $L$ be a number field. Let $n = [L:\\Q]$, let $\\tau_1,...,\\tau_r:L \\to \\R$ be the real embeddings of $L$, and let $\\sigma_1,\\bar{\\sigma}_1,...,\\sigma_s,\\bar{\\sigma}_s:L \\to \\C$ be the remaining distinct complex embeddings of $L$. Then $r+2s = n$.\n\nDefine a map $S:l \\to \\R^r \\times \\C^s$ by $\\alpha \\to (\\tau_1(\\alpha),...,\\tau_r(\\alpha),\\sigma_1(\\alpha),...,\\sigma_s(\\alpha))$. This is a homomorphism of additive groups.\n\\end{proof}\n\\end{thm}\n\n\\begin{lemma}\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then $S(I)$ is a lattice.\n\\begin{proof}\nLet $\\alpha_1,...,\\alpha_n$ be an integral basis of $I$. Then $S(I) = \\oplus_{i=1}^n \\Z s(\\alpha_i)$ and $\\R^r \\times \\C^3$ has dimension $n$ as $\\R$-vector space. So we must show that $S(\\alpha_1),...,S(\\alpha_n)$ are independent or equivalently that\n\\begin{equation*}\n\\begin{aligned}\n\\det \\begin{pmatrix}\n\\tau_1 (\\alpha)1) ... \\tau_1(\\alpha_n)\\\\\n...\\\\\n\\tau_r(\\alpha_1) ... \\tau_r(\\alpha_n)\\\\\nRe \\sigma_1 (\\alpha_1)...Re \\sigma_1(\\alpha_n)\\\\\nIm \\sigma_1 (\\alpha_1)...Im \\sigma_1(\\alpha_n)\\\\\n...\\\\\nIm \\sigma_n (\\alpha_1)...Im \\sigma_s(\\alpha_n)\n\\end{pmatrix} \\neq 0\n\\end{aligned}\n\\end{equation*}\nNote: for $z \\in \\C$,\n\\begin{equation*}\n\\begin{aligned}\n\\begin{pmatrix}\nz\\\\\nz\n\\end{pmatrix} = \n\\begin{pmatrix}\n1 & i\\\\\n1 & -i\n\\end{pmatrix}\n\\begin{pmatrix}\nRe z\\\\\nIm z\n\\end{pmatrix}\n\\end{aligned}\n\\end{equation*}\nSo this determinant equals\n\\begin{equation*}\n\\begin{aligned}\n(\\frac{1}{-2i})^s  \\det \\begin{pmatrix}\n\\tau_1 (\\alpha)1) ... \\tau_1(\\alpha_n)\\\\\n...\\\\\n\\tau_r(\\alpha_1) ... \\tau_r(\\alpha_n)\\\\\n\\sigma_1 (\\alpha_1)...\\sigma_1(\\alpha_n)\\\\\n...\\\\\nsigma_n (\\alpha_1)...\\sigma_s(\\alpha_n)\n\\end{pmatrix} \\neq 0\n\\end{aligned}\n\\end{equation*}\nas $disc(I) \\neq 0$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (6.10)\\\\\nIf $I \\subseteq \\mathcal{O}_L$ is a non-zero ideal, then\n\\begin{equation*}\n\\begin{aligned}\nA(S(I)) = \\frac{1}{2^s} \\sqrt{|disc(I)|} = \\frac{N(I)}{2^s} \\sqrt{|D_L|}\n\\end{aligned}\n\\end{equation*}\n\\end{lemma}\n\n\\begin{prop} (6.11)\\\\\nIf $I\\subseteq \\mathcal{O}_L$ is a non-zero ideal, then there exists $\\alpha \\in I \\setminus \\{0\\}$ such that $N(\\alpha) \\leq C_L N(I)$, where $C_L = (\\frac{4}{\\pi})^s \\frac{n!}{n^n} \\sqrt{|D_L|}$.\\\\\nHere $C_L$ is called the Minkowski constant of $L$.\n\\begin{proof}\nWe apply Minkowski's theorem to the lattice $S(I)$, and region $B_{r,s}(t) = \\{(\\mathbf{x},\\mathbf{z}) \\in \\R^r \\times \\C^s | \\sum_{i=1}^r |X_i| + 2\\sum_{i=1}^s |z_i| \\leq t\\}$.\\\\\nNote: $B_{r,s} (t)$ is convex, centrally symmetric and compact.\\\\\nIf $vol(B_{r,s}(t)) \\geq 2^n A(S(I))$, then there exists $\\alpha \\in I \\setminus \\{0\\}$ such that $S(\\alpha) \\in B_{r,s}(t)$.\\\\\nWe use a tuck with the AM-GM inequality to bound $N(\\alpha)$:\n\\begin{equation*}\n\\begin{aligned}\nN(\\alpha)^{1/n} = (\\prod_{i=1}^r |\\tau_i(\\alpha)) \\prod_{i=1}^s |\\sigma_i(\\alpha)|^2)^{1/n} \\leq \\frac{(\\sum_{i=1}^r |\\tau_1(\\alpha)| + 2\\sum_{i=1}^s |\\sigma_i(\\alpha)|)}{n}\n\\end{aligned}\n\\end{equation*}\nHence $N(\\alpha) \\leq t^n/n^n$. To get optimal bound, choose $t$ so that $vol(B_{r,s}(t)) = 2^n A(S(I))$.\\\\\nExercise: $vol(B_{r,s}(t)) = 2^r (\\frac{\\pi}{2})^s t^n/n!$ (Induction on $r$ and $s$).\\\\\nWe have\n\\begin{equation*}\n\\begin{aligned}\n2^r (\\pi/2)^s t^n / n! &= 2^n A(S(I)) = 2^{r+s} N(I) \\sqrt{|D_L|}\\\\\n\\implies t^n &= (4/\\pi)^s n! N(I) \\sqrt{|D_L|}\\\\\n\\implies N(\\alpha) &\\leq t^n/n^n = C_L N(I)\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{prop}\n\n\\begin{coro} (6.12)\\\\\nFor any class $[I] \\in Cl(\\mathcal{O}_L)$, there exists $J \\in [I]$ such that $N(J) \\leq C_L$.\n\\end{coro}\n\n\\begin{coro} (6.13)\\\\\nThe group $Cl(\\mathcal{O}_L)$ is finite, generated by $[P]$ where $P$ is a prime ideal of norm $N(P) \\leq C_L$.\n\\end{coro}\n\nThese corollaries are deduced from the proposition exactly as in the case $L=\\Q(\\sqrt{d})$, $d<0$.\n\n\\begin{rem}\nIn practice this bound is very effective. For example consider $f(x) = x^5 -x+1$, this is irreducible mod 5, so over $\\Q$. Let $L=\\Q(\\alpha)$ where $\\alpha$ is a root of $f(x)$. In this case $r=1,s=2$, the discriminant $disc f = 2869 = 19 \\cdot 151$ is square-free, so $\\mathcal{O}_L = \\Z[\\alpha]$, and $D_L = disc f$, so $c_L =(4/\\pi)^2 (5^!/5^5) \\sqrt{2869} < 4$. Hence $Cl)\\mathcal{O}_L$ is generated by $P$ of norm $N(P) = 2$ or $3$. By Dedekind's criterion, such primes exist iff $f(x)$ has a root in $F_2$ or $F_3$. But there are no such roots. Hence $Cl(\\mathcal{O}_L)$ is trivial, hence $\\Z[\\alpha]$ is a UFD.\n\\end{rem}\n\nLast time we showed $CL(\\mathcal{O}_L)$ is generated by $[P]$ where $[P]$ is a prime ideal of norm $N(P) \\leq C_L = (4/\\pi)^3 n!/n^n \\sqrt{|D_L|}$. For example, if $L=\\Q(\\sqrt{10})$, $C_L = \\frac{1}{2} \\sqrt{4 \\cdot 10} = \\sqrt{10} < 4$. $Cl(\\mathcal{O}_L$ is generated by $[P]$ where $N(P) = 2$ or $3$. \\\\\nDedekind's criterion: $2\\mathcal{O}_L = P_2^2$, where $P_2 = (2,\\sqrt{10})$. $x^2 -10 \\equiv x^2-1 \\pmod 3$ so $3\\mathcal{O}_L = P_3 P_3'$, where $P_3 = (3,1+\\sqrt{10})$. To find relatoins in $Cl(\\mathcal{O}_L)$, we can calculate norms, e.g. $N(2+\\sqrt{10}) = |4-10| = 6$, so $(2+\\sqrt{10}) = P_2 P_3$ or $P_2 P_3'$. In either case we see that $[P_2]$ generates $Cl(\\mathcal{O}_L$. So either $Cl(\\mathcal{O}_L)$ is trivail, or $Cl(\\mathcal{O}_L \\cong \\Z/2\\Z$ with the second case occuring iff So $P_2$ is not principal. $P_2$ is principal $\\iff \\exists a+b\\sqrt{10} \\in \\mathcal{O}_L$ such that $(a+b\\sqrt{10}) = P_2$ $\\iff \\exists a,b \\in \\Z$ s.t. $a^2 - 10b^2 = \\pm 2$.\\\\\nIf $a^2-10b^2 = \\pm 2$, then either $2$ or $-2$ is a quadratic residue $\\pmod 5$. So in fact $P_2$ is not principal. So $Cl(\\mathcal{O}_L) \\cong \\Z/2\\Z$.\n\nNow take $L = \\Q(\\sqrt{-17})$. $C_l = \\frac{4}{\\pi}\\cdot \\frac{1}{2} \\sqrt{4\\cdot 17} = 4/\\pi \\sqrt{17} < \\frac{4}{3} \\sqrt{17} < 6$. So $Cl(\\mathcal{O}_L)$ is generated by primes of norm $2,3$ or $5$. Dedekind's criterion: $x^2 + 17 \\equiv x^2 + 2 \\pmod 5$, so $5 \\mathcal{O}_L$ is prime of norm 25. $x^2+17 \\equiv x^2-1 \\pmod 3$, so $3 \\mathcal{O}_L = Q_3 Q'_3$ where $Q_3 = (3,1+\\sqrt{-17})$, $Q_3' = (3,1-\\sqrt{-17})$. $x^2+17 = (x+1)^2 \\pmod 2$, so $2 \\mathcal{O}_L = Q_2^2$ where $Q_2 = (2,1+\\sqrt{-17})$.\\\\\nNow $N(1+\\sqrt{-17}) = 18 = 2 \\times 3^2$. Note $1+\\sqrt{-17} \\in Q_3 \\implies Q_3 | (1+\\sqrt{-17})$. So we must have either $(1+\\sqrt{-17}) = Q_2Q_3Q'_3$, or $(1+\\sqrt{-17}) = Q_2 Q_3^2$. To decide between these, we compute\n\\begin{equation*}\n\\begin{aligned}\nQ_3^2 &= (0,3+3\\sqrt{-17},(1+\\sqrt{-17})^2)\\\\\n&= (9,3+3\\sqrt{-17},-16+2\\sqrt{-17})\\\\\n&= (9,3+3\\sqrt{-17},2+2\\sqrt{-17})\\\\\n&= (9,1+\\sqrt{-17})\n\\end{aligned}\n\\end{equation*}\n\nWe see $1+\\sqrt{-17} \\in Q_3^2$ so $Q_3^2 | (1+\\sqrt{-17})$, hence $(1+\\sqrt{-17}) = Q_2Q_3^2$. We see $[Q_3]$ generates $Cl(\\mathcal{O}_L)$ and if $Q_2$ is not principal then $Cl(\\mathcal{O}_L) \\cong \\Z/4\\Z$. But $Q_2$ is principal iff we can solve $a^2+17b^2 = 2$ with $a,b \\in \\Z$. This is impossible, so $Cl(\\mathcal{O}_L) \\cong \\Z/4\\Z$.\n\n\\begin{rem}\nTher are many open questions about ideal class groups even for quadratic fields.\\\\\nThings we know: Number of $Cl(\\mathcal{O}_{\\Q(\\sqrt{d})} \\to \\infty$ as $d \\to -\\infty$ through squaree-free integers. There are exactly 9 imaginary quadratic fields with trivial ideal class group (hard).\\\\\nThings we don't know: are there infinitely many real quadratic fields of trivial ideal class group?\n\\end{rem}\n\nCohen-Lenstra heuristics: let $p$ be an odd prime, and let $A$ be a finite abelian group of $p$-power order. Then for $d<0$ square-free, $\\P(Cl(\\mathcal{O}_{\\Q(\\sqrt{d})}) \\cong A) = \\frac{\\prod_{i=1}^\\infty (1-1/p^i)}{\\text{Number of }Aut(A)}$.\n\nFor $M$ a finite abelian group, $M_p$ is the (unique) $p$-sylow subgroup.\n\nBy definition, The above probablity is the ratio between the number of $d<0$ square-free, $Cl(\\mathcal{O}_{\\Q(\\sqrt{d})})_p \\cong A$, $|d| < X$ and the number of $d<0$ square-free, $|d|<x$.\n\n\\newpage\n\n\\section{Dirichlet's unit theorem}\nLet $L$ be a number field of degree $n = [L:\\Q]$, $\\tau_1,...,\\tau_r:L \\to \\R$ are real embeddings, $\\sigma_1,...,\\sigma_s,\\bar{\\sigma}_1,...,\\bar{\\sigma}_s: L \\to \\C$ are distinct complex embeddings.\n\n\\begin{thm} (7.1)\\\\\nThere is an isomorphism $\\mathcal{O}_L^* \\cong \\mu_L \\times \\Z^{r+s-1}$, where $\\mu_L \\subseteq \\mathcal{O}_L^*$ is the finite cyclic group of roots of unity in $\\mathcal{O}_L^*$.\\\\\nIn fact the proof shows omre: define a map $l:\\mathcal{O}_L^* \\to \\R^{r+s}$: $l(\\alpha) = (\\log |\\tau_1(\\alpha)|,...,\\log|\\tau_r(\\alpha)|,2\\log |\\sigma_1(\\alpha)|,...,2\\log|\\sigma_s(\\alpha)|)$, then this is a homomorphism of abelian groups, and $l(\\mathcal{O}_L^*)$ is contained in the hyperplane $H =\\{\\mathbf{x} \\in \\R^{r+s} | \\sum_{i=1}^{r+s} x_i = 0\\}\\subseteq \\R^{r+s}$. This expresses the condition $\\alpha \\in \\mathcal{O}_L^* \\implies \\log N(\\alpha) = \\sum_{i=1}^r \\log |\\tau_i(\\alpha)|+2\\sum_{i=1}^s |\\sigma_i(\\alpha)|$.\n\nThe proof of the theorem will show $l(\\mathcal{O}_L^*)$ is a lattice in $H$.\n\nExample: $\\mathcal{O}_L^*$ is finite $\\iff r+s = 1$, i.e. $r=1,s=0$ ($L=\\Q$), or $r=0,s=1$ ($L=\\Q(\\sqrt{d})$,$d<0$ square-free). The first case where $\\mathcal{O}_L^*$ is infinite is $L=\\Q\\sqrt{d}), d>0$, square-free. Then $+s-1=1$, so $l(\\mathcal{O}_L^*)$ is infinite cyclic. Let's fix $\\sigma:\\Q(sqrt{d}) \\to \\R$ to be the real embedding with $\\sigma(\\sqrt{d}) \\geq 0$. $\\sigma(\\mu_L) \\subseteq \\R^*$, so $\\mu_L = \\{\\pm 1\\}$ in this case. In this case, we can consider the map $l':\\mathcal{O}_L^* \\to \\R$ by $\\alpha \\to \\log |\\sigma(\\alpha)|$. We know that $l'(\\mathcal{O}_L^*) \\subseteq \\R$ is a lattice, in particular there is a uniquely characterised unit $\\alpha \\in \\mathcal{O}_L^*$ satisfying $\\sigma(\\alpha)>0$, $\\log |\\sigma(\\alpha)| > 0$ and as small as possible. In other words, $\\alpha \\in \\mathcal{O}_L^*$ is the unit for which $\\sigma(\\alpha)>1$ and $\\sigma(\\alpha)$ is minimal with respect to this property. We call $\\alpha$ the fundamental unit of $L=\\Q(\\sqrt{d})$. Then we have $\\mathcal{O}_L^* = \\{\\pm \\alpha^n | n \\in \\Z\\}$.\n\\end{thm}\n\nExample sheet 3 is now online!\n\nLast time we have: if $L$ is a number field, then $\\mathcal{O}_L^* \\cong \\mu_L \\times \\Z^{r+s-1}$, where $\\mu_L$ are roots of unity.\n\nNow suppose $L = \\Q(\\sqrt{d})$ where $d \\in \\Z$ is a square free integer, $d>1$. We identify $L$ with a subfield of $\\R$, where $\\sqrt{d}$ is the positive square root.\n\nWe saw that the Dirichlet's unit theorem implies $\\exists u \\in \\mathcal{O}_L^*$ such that $u = \\min \\{v \\in \\mathcal{O}_L^* | v>1\\}$. $u$ is called the fundamental unit, and $\\mathcal{O}_L^* = \\{\\pm u^n | n \\in \\Z\\}$.\n\n\\begin{lemma} (7.2)\\\\\n(1) If $d \\equiv 2,3 \\pmod 4$ and $v \\in \\mathcal{O}_L^*$ satisfies $v > 1$, then $v = a+b\\sqrt{d}$ where $a \\geq b \\geq 1$;\\\\\n(2) If $d \\equiv 1 \\pmod 4$, and $v \\in \\mathcal{O}_L^*$ satisfies $v>1$, then $v = \\frac{1}{2} (a+b\\sqrt{d})$ wher $a \\geq b \\geq 1$.\n\\begin{proof}\n(1) Let $v' = a-b\\sqrt{d}$. Then $vv' = a^2 - db^2 = N_{L/\\Q}(v) = \\pm 1$. So $v>1 \\implies |v'| < 1$. Hence $v+v' = 2a > 0$, $v-v' = sb\\sqrt{d} > 0$. As $a,b$ are integers, we must have $a \\geq 1, b \\geq 1$.\\\\\nAlso, $(a/b)^2 = d \\pm 1/b^2 \\geq 1$ as $d \\geq 2$.\\\\\n(2) Let $v' = \\frac{1}{2} (a-b\\sqrt{d}$). Then $vv' = \\pm 1$ and $a^2-db^2 = \\pm 4$. Then $v+v' = a > 0$, and $v-v' = b\\sqrt{d} > 0$. Hence $a \\geq 1, b \\geq 1$. Also, $(a/b)^2 = d \\pm 4/b^2$ as $d \\geq 5$ as $d \\equiv 1 \\pmod 4$.\n\\end{proof}\n\\end{lemma}\n\nWe can use this to find the fundamental unit $u \\in \\mathcal{O}_L^*$. First suppose $d \\equiv 2,3 \\pmod 4$ and let $u = a+b\\sqrt{d}$. Let $u^k = a_k + b_k \\sqrt{d}$. Then $u^{k+1} = (a_1 + b_1 \\sqrt{d})(a_k + b_k \\sqrt{d}) = (a_1a_k + db_1b_k) + (b_1a_k + a_1b_k) \\sqrt{d}$. Hence $b_{k+1} = b_1a_k + a_1b_k > b_k$.\\\\\nHence the sequence $b_1,b_2,b_3$ is strictly increasing.\n\nWe can therefore characterise $u$ as follows: let $b \\in \\N$ be the least positive integer such that $db^2+1$ or $db^2-1$ is of the form $a^2$ for some $a \\in \\N$. Then $u = a+b\\sqrt{d}$.\\\\\nNow suppose $d \\equiv 1 \\pmod 4$, and let $u = \\frac{1}{2} (a+b\\sqrt{d})$, $a,b \\in \\Z$. Let $u^k = \\frac{1}{2} (a_k + b_k \\sqrt{d})$. Then $b_{k+1} = \\frac{1}{2} (a_1b_k + b_1 a_k$). Using lemma 7.2, we see $b_{k+1} \\geq b_k$. If (??)\\\\\nThis is wrong. Let's correct this next time. Sorry!\n\n\\begin{eg}\n$d=2$.$L = \\Q(\\sqrt{2})$. $b=1$ works: $2-1=1^2$. So $1+\\sqrt{2}$ is a fundamental unit.\\\\\n$d=7$. Try $b=1$: $7 \\pm 1$ is not a square; $b=2,$ doesn't work either; $b=3$: $9 \\cdot 7 \\pm 1 = 8^2$. So $8+3\\sqrt{7}$ is a fundamental unit.\n\\end{eg}\n\nNote: This procedure is not always efficient. For example, the fundamental unit in $\\Q(\\sqrt{22})$ is $197+42\\sqrt{22}$.\n\nThere is a more efficient algorithm which uses continued fractions, but it is not discussed in this course (see number theory).\n\nWe now prove the unit theorem (this is non-examinable).\n\nWe recall the setup: $L$ is a number field, $\\tau_1,...,\\tau_r: L \\to \\R$, $\\sigma_1,\\bar{\\sigma}_1,...,\\sigma_s,\\bar{\\sigma}_s:L \\to \\C$ are real and complex embeddings of $L$ respectively.\\\\\nLast time we defined a map: $l: \\mathcal{O}_L^* \\to \\R^{r+s}$ by $\\alpha \\to (\\log (\\tau_1(\\alpha)),...,\\log(\\tau_r (\\alpha)),2\\log (\\sigma_1(\\alpha)),...,2\\log(\\sigma_s(\\alpha)))$.\\\\\nThe image is contained inside the subspace $H = \\{\\mathbf{x} \\in \\R^{r+s}| \\sum_{i=1}^{r+s} x_i = 0\\}$.\n\n\\begin{lemma} (7.3)\\\\\nLet $\\alpha \\in \\mathcal{O}_L \\setminus \\{0\\}$ be such that the above image vector is $(a_1,...,a_{r+s}) \\in \\R^{r+s}$. Fix an integer $1 \\leq k \\leq r+s$. Then ther exists $\\beta \\in \\mathcal{O}_L \\setminus\\{0\\}$ such that if $l(\\beta) = (b_1,...,b_{r+s}) \\in \\R^{r+s}$, then $b_i < a_i$ if $i \\neq k$. Moreover, $N(\\beta) \\leq (\\frac{2}{\\pi})^s \\sqrt{|D_L|}$.\n\\begin{proof}\nLet $c_1,...,c_{r+s} \\in \\R_{>0}$, and let\n\\begin{equation*}\n\\begin{aligned}\nE=\\{(\\mathbf{x},\\mathbf{z})\\in \\R^r \\times \\C^s | |x_1| \\leq c_1,...,|x_r| \\leq c_r,|z_1|^2 \\leq c_{r+1},...,|z_r|^2 \\leq c_{r+s}\\}\n\\end{aligned}\n\\end{equation*}\nThen if $vol(E) \\geq 2^{r+2s} A(S(\\mathcal{O}_L)) = 2^{r+s} \\sqrt{|D_L|}$, then $(S:\\mathcal{O}_L \\to \\R^r \\times \\C^s)$.\n\nThere exists $\\beta \\in \\mathcal{O}_L \\setminus \\{0\\}$ such that $S(\\beta) \\in E$ (by Minkovski's theorem). In particular, $N(\\beta) = \\prod_{i=1}^r |\\tau_1(\\beta)| \\prod_{i=1}^s |\\sigma_i(\\beta)|^2 \\leq c_1...c_{r+s}$ (by defiintion of $E$).\n\nWe choose $c_i$ so that $0 < c_i < e^{a_i}$ if $i \\neq k$, and $vol(E) = \\pi^s 2^r c_1...c_{r+s} = 2^{r+s} \\sqrt{|D_L|}$.\n\nThe first property gives $b_i < a_i$ if $i \\neq k$, and the second property gives $N(\\beta) \\geq c_1...c_{r+s} = (\\frac{2}{\\pi})^s \\sqrt{|D_L|}$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro} (7.4)\\\\\nFix an integer $1 \\leq k \\leq r+s$. Then there exists $\\varepsilon \\in \\mathcal{O}_L^*$ such that if $l(\\varepsilon) = (a_1,...,a_{r+s})$ then $a_i < 0$ if $i \\neq k$, and $a_k > 0$.\n\\begin{proof}\nBy the lemma, we can find elements $\\alpha_1,\\alpha_2,...$ of $\\mathcal{O}_L\\setminus \\{0\\}$ such that $N(\\alpha_1) \\leq (\\frac{2}{\\pi})^s \\sqrt{|D_L|}$ $\\forall i \\in \\N$, and if $l(\\alpha_i) = (b_{i_1},...,b_{i,r+s})$, then $b_{ij} < b_{i-1,j}$ if $j \\neq k$ $\\forall i = 2,3,...$. The ideals $(\\alpha_i)$ have bounded norm, so are finite in number, so there exist elements $\\alpha_N, \\alpha_M$ with $(\\alpha_N) = (\\alpha_M)$. Then the element $\\varepsilon = \\alpha_N/\\alpha_M \\in \\mathcal{O}_L^*$ has the desired property.\n\\end{proof}\n\\end{coro}\n\nWe continue with the non-examinable proof of Dirichlet's unit theorem.\n\nWe proved propoition: let $\\alpha \\in \\mathcal{O}_L \\setminus \\{0\\}$ be such that $l(\\alpha)$ fix $1 \\leq k \\leq r+s$. Then $\\exists \\beta \\in \\mathcal{O}_L \\setminus \\{0\\}$ such that $N(\\beta) \\leq (\\frac{2}{\\pi})^s \\sqrt{|D_L|}$, and if $l(\\beta) = (b_1,...,b_{r+s})$ then $b_i < a_i$ if $i \\neq k$.\n\nWe deduced Corllary 7.4: fix $1 \\leq k \\leq r+s$. Then there exists $\\varepsilon \\in \\mathcal{O}_L^*$ such that if $l(\\varepsilon) = (a_1,...,a_{r+s})$, then $a_i < 0$ if $i \\neq k$.\n\\begin{proof}\nChoose $\\alpha \\in \\mathcal{O}_L \\setminus \\{0\\}$. By the proposition, we can find elements $\\alpha_1,...$ such that $N(\\alpha_i) \\leq (2/\\pi)^s \\sqrt{|D_L|}$, and if $l(i) = (b_{i1,...,ir+s})$ then $b_{ij} > b_{i+1j}$ if $j \\neq k$ for all $i \\geq 1$.\n\nWe now look at the ideals $(\\alpha_1),(\\alpha_2),...$. These have norm at most $(2/\\pi)\\sqrt{|D_L|}$. We know there are only finitely many ideals of $\\mathcal{O}_L$ of norm at monst that, so there must exist $N<M$ such that $(\\alpha_N) = (\\alpha_M)$. Hence $\\exists u \\in \\mathcal{O}_L^*$ such that $\\alpha_M = u \\alpha_N$. Also, $u = \\alpha_M / \\alpha_N \\implies l(u) = (b_{m1}-b_{N1},...,b_{mr+s}-b_{Nr+s})$. But $N<M$, so $b_{Nj} > b_{Mj}$ if $j \\neq k$. So $B_{Mj} - b_{Nj} < 0$ if $j \\neq k$.\n\\end{proof}\n\n\\begin{lemma} (7.5)\\\\\nLet $N \\geq 1$, and let $A \\in M_{N \\times N} (\\R)$ be such that:\\\\\n$\\bullet$ $\\sum_{i=1}^N A_{ij} = 0$ for all $j=1,...,N$;\\\\\n$\\bullet$ $A_{ij} > 0$ if $i = j$, and $<0$ if $i \\neq j$.\\\\\nThen $A$ has rank $N-1$.\n\\begin{proof}\nThe rank is at most $N-1$. We show the first $N-1$ rows of $A$ are LI.\\\\\nSuppose there exist $t_i \\in \\R,i = 1,...,N-1$ not all zero s.t. $\\sum_{i=1}^{N-1} t_i A_{ij} = 0$ for each $j = 1,...,N$. WLOG after rescaling ther exists $k$ that $t_k=1$ and $t_i \\leq 1$ if $i \\neq k$. Then $0 = \\sum_{i=1}^{N-1} t_i A_{ik} \\geq \\sum_{i=1}^{N-1} A_{ik} > \\sum_{i=1}^N A_{ik} = 0$, contradiction.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (7.6)\\\\\nFix $B>0$. Let $X_B = \\{\\alpha \\in \\mathcal{O}_L | \\forall \\sigma: L \\to \\C, |\\sigma(\\alpha)| \\leq B\\}$. THen $X_B$ is finite.\n\\begin{proof}\nRecall the map $S:\\mathcal{O}_L \\to \\R^r \\times \\C^s$. $S(\\mathcal{O}_L)$ is a lattice in $\\R^r \\times \\C^s$. $S(X_B)$ is the intersection of the lattice $S(\\mathcal{O}_L)$ with a compact subset of $\\R^r \\times \\C^s$. Therefore it must be finite.\n\\end{proof}\n\\end{lemma}\n\n\\begin{prop} (7.7)\\\\\n$l(\\mathcal{O}_L^*)$ is a lattice in $H \\leq \\R^{r+s}$.\n\\begin{proof}\nWe must show there exist units $v_1,...,v_{r+s-1} \\in \\mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ span $H$ as an $\\R$-vector space and generate $l(\\mathcal{O}_L^*)$ as an abelian group.\\\\\nBy corollary 7.4, we can find $\\varepsilon_1,...,\\varepsilon_{r+s} \\in \\mathcal{O}_L^*$ such htat if $l(\\varepsilon_j) = (A_{ij},...,A_{r+sj})$, then $A_{ij} < 0$ if $i \\neq j$ and $A_{ij} > 0$ if $i = j$. By lemma 7.5, the matrix $A$ has rank $r+s-1$, so we can find $v_1,...,v_{r+s-1} \\in \\mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ span $\\mathcal{O}_L^*$ as an $\\R$-vector space.\\\\\nLet $\\Lambda = \\oplus_{i=1}^{r+s-1} \\Z l(v_i) \\leq H$. This is a lattice in $H$. Then $\\Lambda \\leq l(\\mathcal{O}_L^*)$ and if $u \\in \\mathcal{O}_L^*$, then $\\exists \\lambda \\in \\Lambda$ such that $l(u) - \\lambda \\in \\{\\sum_{i=1}^{r+s-1} t_i l(v_i) | t_1,...,t_{r+s-1} \\in [0,1]\\}=P$. But the set of units $l(P)$ is finite by Lemma 7.6. Hence the quotien $l(\\mathcal{O}_L^*) / \\Lambda$ is finite. By Lagrange's theorem, $\\exists N \\in \\Z, N > 1$ such that $N l(\\mathcal{O}_L^*) \\leq \\Lambda$. Hence $\\Lambda \\leq l(\\mathcal{O}_L^*) \\leq \\frac{1}{N}\\Lambda$. By the sandwich lemma, $l(\\mathcal{O}_L^*)$ is a free abelian group of rank $r+s-1$. In particular, it is a lattice in $H$.\n\\end{proof}\n\\end{prop}\n\nLet's now finish the proof of the unit theorem, i.e. show there's an isomorphism $\\mathcal{O}_L^* \\cong \\mu_L \\times \\Z^{r+s-1}$, where $\\mu_L$ is the (finite) group of roots of unity in $\\mathcal{O}_L$.\n\n\\begin{proof}\nWe have $\\mu_L = \\ker l$. If $\\xi \\in \\mu_L$, then $\\xi^N = 1$ for some $N\\geq 1$, hence $l(\\xi^N) = 0 = N l(\\xi) \\implies l(\\xi) = 0$ as $l(\\xi \\in \\R^{r+s}$. If $\\alpha \\in \\mathcal{O}_L^*$ and $l(\\alpha) = 0$ then $\\forall \\sigma: L \\to \\C$, $|\\sigma(\\alpha)| = 1$. By lemma 7.6, $\\ker l$ is finite. By Lagrange's theorem, it consists of roots of unity.\n\nChoose $v_1,...,v_{r=s-1} \\in \\mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ is a $\\Z$-basis of $l(\\mathcal{O}_L^*)$. Define a map $f:\\mu_L \\times \\Z^{r+s-1} \\to \\mathcal{O}_L^*$ by $(\\xi,n_1,...,n_{r+s-1}) \\to \\xi v_1^{n_1} ... v_{r+s-1}^{n_{r+s-1}}$.\n\\end{proof}\n\nExercise: this is an isomorphism.\n\nReturn to the examinable parts:\n\nWe now show how to find the fundamental unit in $\\Q(\\sqrt{d})$, where $\\sqrt{d} \\in \\R_{>0}$ and $d \\in \\Z$ is a positive square-free integer.\n\n$d>1,d \\equiv 1 \\pmod 4$:\n\nRecall: the fundamental unit $u \\in \\mathcal{O}_L^*$ is the least unit $u>1$. We saw last time that if $v=\\frac{1}{2}(a+b\\sqrt{d}) \\in \\mathcal{O}_L^*$ is any unit with $v>1$, then $a \\geq b \\geq 1$.\n\nLet $u^k = \\frac{1}{2} (a_k+b_k\\sqrt{d})$. Then $b_{k+1} = \\frac{1}{2} (a_1 b_k + b_1a_k) \\geq \\frac{1}{2} (a_1+b_1)b_k \\geq b_k$. We see $b_{k+1} \\geq b_k$, with equality iff $a_k = b_k$ and $a_1=b_1=1$. Note: if $a_1=b_1 =1$, then $N(u) = |\\frac{1-d}{4}| = 1 \\implies d=5$. Assume first that $d>5$. Then the sequence $b_1<b_2<b_3<...$ is strictly increasing. The fundamental unit $u$ can therefore be found as following: let $b \\in \\N$ be the least positive integer such that $db^2 + 4 = a^2$ or $db^2 - 4 = a^2$, where $a \\in \\N$. Then $\\frac{1}{2} (a+b\\sqrt{d})$ is the fundamental unit.\n\nNow suppose $d=5$. Then at least $b_1 \\leq b_2 \\leq ...$ is non-decreasing, and each value $b_i$ can appear at most twice: this is because occurrences correspond to solutions to $b_i^2 d \\pm 4 = a_i^2$. We can therefore characterize the fundamental unit $u$ as follows: let $b\\ in \\N$ be the least positive integer for which $db^2+4 = a^2$ or $db^2-4 = a^2$ for $a,a' \\in \\N$ (units $\\frac{1}{2}(a+b\\sqrt{d}) and \\frac{1}{2} (a'+b\\sqrt{d})$). Recall that the fundamental unit is the least unit with $u>1$. Of these two possibilities, choose the unit with the smaller value of $a$ or $a'$. In this case, $b=1$ gives $d+4=3^2,d-4=1$. So $\\frac{1}{2} (1+\\sqrt{5})$ is the fundamental unit in this case.\n\n\\iffalse\n\\begin{equation*}\n\\begin{aligned}\n\n\\end{aligned}\n\\end{equation*}\n\\fi\n\n\\end{document}\n", "meta": {"hexsha": "4577085d593846f5d57cf2f7ffb1d0383e15756c", "size": 82074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Number Fields.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Number Fields.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Number Fields.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.8690702087, "max_line_length": 1044, "alphanum_fraction": 0.6201964081, "num_tokens": 33029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.4354304111962328}}
{"text": "\\documentclass{beamer}\n\\usepackage{csquotes}\n\\usepackage{tikz}\n\\usetikzlibrary{arrows,positioning,shapes.geometric, calc}\n\\usepackage{amsmath}\n\\usepackage{listings, xcolor}\n\\usepackage{lmodern}\n\\usepackage{adjustbox}\n\\usepackage{booktabs}\n\\usepackage{colortbl}\n\\usepackage{caption}\n\\usepackage{icomma}\n\\usepackage{bigstrut}\n\\usepackage{geometry}\n\\usepackage{subfigure}\n\n\\DeclareMathOperator*{\\argmin}{argmin}\n\n\\usetheme{metropolis}           % Use metropolis theme\n\\title{Penalized Regression for predicting trait from genotypes}\n\\date{\\today}\n\\author{Robert M. Porsch}\n\\institute{Center of Genomic Science}\n\\begin{document}\n\\maketitle\n\n\\begin{frame}[t]{Introduction}\n  Our goal is to use raw genotypes to predict traits and compare it to PGS\\@.\n  \\begin{enumerate}[(i)]\n    \\item Application of penalized regressions (linear models)\n      \\begin{itemize}\n        \\item $L_1$, $L_2$, and $L_0$ norm\n      \\end{itemize}\n    \\item Application of non-linear frameworks\n      \\begin{itemize}\n        \\item Neural Networks, SVM\n      \\end{itemize}\n  \\end{enumerate}\n  Identify and estimate epistatic effects.\n\\end{frame}\n\n\\section{Simple Simulation}\n\\label{sec:simulation}\n\n\\begin{frame}[t]{Some simple simulation}\n  I simulated some toy data with $n = 10,000$ with $p = 10,000$. \n  Effect sizes of 1\\% of variables were drawn from a $\\mathcal{N}(0, 0.01)$, the rest are set to 0.\n\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.99\\linewidth]{./performance.png}\n  \\end{figure}\n  \\begin{columns}\n    \\begin{column}{0.35\\textwidth}\n      \\includegraphics[width=0.99\\linewidth]{./joyplot_l0.png}\n    \\end{column}\n    \\begin{column}{0.35\\textwidth}\n      \\includegraphics[width=0.99\\linewidth]{./joyplot_l1.png}\n    \\end{column}\n    \\begin{column}{0.35\\textwidth}\n      \\includegraphics[width=0.99\\linewidth]{./percentage_0_l0l1.png}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}[t]{}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.999\\linewidth]{./performance_epochs_l1l0.png} \\\\\n  \\end{figure}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.999\\linewidth]{./loss_l1l0.png} \\\\\n  \\end{figure}\n\\end{frame}\n\n\\section{Combing $L_0$ and $L0_1$}\n\\label{sec:combing_l_0_and_l0_1_}\n\n\\begin{frame}[t]{Connection between the $L_2$-norm and Gaussian prior}\n  \\small\n  Let $\\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\\{(x_1, y_1), \\ldots, (x_N, y_N)\\}$.\n\n  Lets also assume that the output is linear related via $\\theta$ and that the data is corrupted by some noise $\\epsilon\\sim N(0, \\sigma^2)$.\n  Then the Gaussian likelihood is:\n  \\begin{equation}\n    \\prod^N_{i=1} \\mathcal{N}(y_i|\\theta x_i, \\sigma^2)\n  \\end{equation}\n  We can then impose a Gaussian prior $\\mathcal{N}(\\theta|0, \\lambda^{-1})$, in which $\\lambda$ is a positive scalar.\n  Then we have for the likelihood:\n  \\begin{equation}\n    \\prod^N_{i=1} \\mathcal{N}(y_i|\\theta x_i, \\sigma^2)\\mathcal{N}(\\theta|0, \\lambda^{-1})\n  \\end{equation}\n  Taking the logarithm of the above and removing unecessary constants we get:\n  \\begin{equation}\n    \\sum^N_{i=1} - \\frac{1}{\\sigma^2} (y_i - \\theta x_i)^2 - \\lambda \\theta^2 + const.\n  \\end{equation}\n\\end{frame}\n\n\\begin{frame}[t]{Combining $L_0$ and $L_2$}\n  \\small\n  Often it is desirable to shrink paramenters, hence on should combine $L_0$ and other norms.\n  Using the $L_2$-norm and under a bernulli gating mechanism:\n  \\begin{equation}\n    \\mathbb{E}_{q(z|\\pi)} [||\\theta||^2_2] = \\sum^P_{j=1} \\mathbb{E}_{q(z_j|\\pi_j)} [z_j^2\\tilde{\\theta}^2_j] = \\sum^P_{j=1} \\pi_j \\tilde{\\theta}^2_j\n  \\end{equation}\n  in which $\\pi_j$ is the probability of the gate being open.\n\n  Since the $L_2$ norm is proportional to the negative log density of $\\mathcal{N}(0, \\sigma^2)$ we can assume that the $\\sigma$ for each $\\theta$ is controlled by $z$.\n  That is if $z=0 \\rightarrow \\sigma=1$, while if $z > 0 \\rightarrow \\sigma = z$\n  Hence the $L_2$ norm is then (where $\\hat{\\theta} = \\frac{\\theta}{\\sigma}$)\n  \\begin{equation}\n    \\begin{split}\n      \\mathbb{E}_{q(z|\\pi)} [||\\hat{\\theta}||^2_2] =  & \\sum^P_{j=1} (1 - Q_{\\hat{s}_j}(0 | \\phi_j)) \\mathbb{E}_{q(z_j|\\pi_j, \\hat{s}_j > 0)} [\\frac{\\tilde{\\theta}^2_j z^2_j}{z^2_j}] \\\\\n                                                & \\sum^P_{j=1} (1 - Q_{\\hat{s}_j}(0 | \\phi_j)) \\tilde{\\theta}^2_j\n      \\end{split}\n  \\end{equation}\n\\end{frame}\n\n\\begin{frame}[t]{Results of $L_{0,2}$}\n  \n\\end{frame}\n\n\\begin{frame}[t]{Simulation Framework}\n  \\begin{center}\n  \\textbf{Completely blind. You need to ask Tim.}\n  \\end{center}\n  \\\\\n  But here is what I know:\n  \\begin{itemize}\n    \\item Linear and non-linear effects present\n    \\item Currently only using chromosome 10\n    \\item $R^2$ between $0.04$ and $0.01$\n    \\item Performance of Lassosum is a correlation of $0.05$\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[t]{Task processing}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{Dask_processing.png}\n  \\end{figure} \n\\end{frame}\n\n\\begin{frame}[t]{Some Results}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.99\\linewidth]{performance.png}\n    \\caption{Performance}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}[t]{Parameter Space}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.99\\linewidth]{null_proportion.png}\n    \\caption{Proportion of parameters equal or close to 0}\n  \\end{figure}\n  \\begin{itemize}\n    \\item $L_0$ comes very quickly to sparse solution (parameters are not accurate, small effects)\n    \\item $L_1$ and $L_2$ seem to take a bit longer\n  \\end{itemize}\n\\end{frame}\n\n\\section{Suplementary for $L_0$-norm}\n\\label{sec:suplementary}\n\n\\begin{frame}[t]{Penalized Regression}\n  Let $\\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\\{(x_1, y_1), \\ldots, (x_N, y_N)\\}$ and consider the following regularized minimization procedure\n\n  \\begin{equation} \n    \\mathcal{R}(\\theta) = \\frac{1}{N} ( \\sum^N_{i=1} \\mathcal{L}(h(x_i; \\theta), y_i)) + \\lambda\\mathcal{P}(\\theta)\n  \\end{equation}\n\n  With $\\theta^* = \\underset{\\theta}{\\argmin}\\{\\mathcal{R}(\\theta)\\}$.\n\n  $\\mathcal{P}(\\theta)$ is a penalization function for the parameters $\\theta$.\n\\end{frame}\n\n\\begin{frame}[t]{The General Recipe}\n  The first step is to reformulate the $L_0$ norm under the parameters $\\theta$.\n  Hence let,\n  \\begin{equation}\n    \\begin{matrix}\n      \\theta_j = \\tilde{\\theta_j}z_j, & z_j \\in \\{0, 1\\}, & \\tilde{\\theta}_j \\neq 0\n    \\end{matrix}\n  \\end{equation}\n  Therefore $z_j$ can be considered as binary gates (parameter has an effect).\n\n  Then we can reformulate the minimization from Eq. 1 by letting $q(z_j|\\pi_j) = Bern(\\pi_j)$\n  \\begin{equation}\n    \\mathcal{R}(\\tilde{\\theta}, \\pi) = \\mathbb{E}_{q(z|\\pi)} [\\frac{1}{N} ( \\sum^N_{i=1} \\mathcal{L}(h(x_i; \\tilde{\\theta} \\otimes z), y_i)] + \\lambda \\sum^{p}_{j=1} \\pi_j\n  \\end{equation}\n  with  $\\tilde{\\theta}^*, \\pi^* = \\underset{{\\tilde{\\theta}, \\pi}}{\\argmin} \\{\\mathcal{R}(\\tilde{\\theta}, \\pi)\\}$\n\n  However, the discrete nature of $z$ makes it still difficult to minimize $\\pi$.\n\\end{frame}\n\n\\begin{frame}[t]{Hard-sigmoid function}\n  \\small\n  Let s be a continuous random variable with a distribution $q(s)$ with parameter $\\phi$.\n  Then we can give the gates $z$ a hard sigmoid function with:\n  \\begin{equation}\n    \\begin{align*}\n      s \\sim& q(s|\\phi) \\\\\n      z =& \\min(1, \\max(0, s))\n    \\end{align*}\n  \\end{equation}\n  Then the probability of the gates being non-zero is\n  \\begin{equation}\n    q(z \\neq 0 | \\delata) =  1 - Q(s\\leq 0 | \\phi)\n  \\end{equation}\n  in which $Q(\\cdot)$ is the cumulative distribution function of s\n  \\begin{equation}\n    \\begin{split}\n      \\mathcal{R}(\\tilde{\\theta}, \\phi) = \\mathbb{E}_{q(s|\\phi)} [\\frac{1}{N} ( \\sum^N_{i=1} \\mathcal{L}(h(x_i; \\tilde{\\theta} \\otimes g(s)), y_i)] + \\\\ \n      \\lambda \\sum^{|\\theta|}_{j=1} (1 - Q(s_j \\leq 0 | \\phi_j))\n    \\end{split}\n  \\end{equation}\n  with $\\theta^*, \\phi^* = \\underset{{\\tilde{\\theta}, \\phi}}{\\argmin} \\{\\mathcal{R}(\\tilde{\\theta}, \\phi)\\}$ and $g(\\cdot) = \\min(1, \\max(0, \\cdot))$\n\\end{frame}\n\n\n\\begin{frame}[t]{The Hard Concrete Distribution}\n  The literature suggests to use a hard concrete distribution as a smoothing function $q(s)$. \n  The parameters of the distribution are $\\phi = (\\log \\alpha, \\beta)$ and can be stretched to $(\\gamma, \\zeta)$ intervals.\n  \\begin{equation}\n    \\begin{align*}\n      u \\sim \\mathcal{U}(0,1) \\\\\n      s = Sigmoid((\\log u - \\log(1-u) + \\log\\alpha)/\\beta) \\\\\n      \\bar{s} = s(\\zeta - \\gamma) + \\gamma \n    \\end{align*}\n  \\end{equation}\n  \\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.5\\linewidth]{hard_concrete.png}\n    \\caption{Sample from the Hard Concrete Distribution}\\label{fig:hard_concrete}\n  \\end{figure} \n\\end{frame}\n\n\\begin{frame}[t]{Connection between the $L_2$-norm and Gaussian prior}\n  \\small\n  Let $\\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\\{(x_1, y_1), \\ldots, (x_N, y_N)\\}$.\n\n  Lets also assume that the output is linear related via $\\theta$ and that the data is corrupted by some noise $\\epsilon\\sim N(0, \\sigma^2)$.\n  Then the Gaussian likelihood is:\n  \\begin{equation}\n    \\prod^N_{i=1} \\mathcal{N}(y_i|\\theta x_i, \\sigma^2)\n  \\end{equation}\n  We can then impose a Gaussian prior $\\mathcal{N}(\\theta|0, \\lambda^{-1})$, in which $\\lambda$ is a positive scalar.\n  Then we have for the likelihood:\n  \\begin{equation}\n    \\prod^N_{i=1} \\mathcal{N}(y_i|\\theta x_i, \\sigma^2)\\mathcal{N}(\\theta|0, \\lambda^{-1})\n  \\end{equation}\n  Taking the logarithm of the above and removing unecessary constants we get:\n  \\begin{equation}\n    \\sum^N_{i=1} - \\frac{1}{\\sigma^2} (y_i - \\theta x_i)^2 - \\lambda \\theta^2 + const.\n  \\end{equation}\n\\end{frame}\n\n\\begin{frame}[t]{Combining $L_0$ and $L_2$}\n  \\small\n  Often it is desirable to shrink paramenters, hence on should combine $L_0$ and other norms.\n  \n  Using the $L_2$-norm and under a bernulli gating mechanism:\n  \\begin{equation}\n    \\mathbb{E}_{q(z|\\pi)} [||\\theta||^2_2] = \\sum^P_{j=1} \\mathbb{E}_{q(z_j|\\pi_j)} [z_j^2\\tilde{\\theta}^2_j] = \\sum^P_{j=1} \\pi_j \\tilde{\\theta}^2_j\n  \\end{equation}\n  in which $\\pi_j$ is the probability of the gate being open.\n\n  Since the $L_2$ norm is proportional to the negative log density of $\\mathcal{N}(0, \\sigma^2)$ we can assume that the $\\sigma$ for each $\\theta$ is controlled by $z$.\n  That is if $z=0 \\rightarrow \\sigma=1$, while if $z > 0 \\rightarrow \\sigma = z$\n  Hence the $L_2$ norm is then (where $\\hat{\\theta} = \\frac{\\theta}{\\sigma}$)\n  \\begin{equation}\n    \\begin{split}\n      \\mathbb{E}_{q(z|\\pi)} [||\\hat{\\theta}||^2_2] =  & \\sum^P_{j=1} (1 - Q_{\\hat{s}_j}(0 | \\phi_j)) \\mathbb{E}_{q(z_j|\\pi_j, \\hat{s}_j > 0)} [\\frac{\\tilde{\\theta}^2_j z^2_j}{z^2_j}] \\\\\n                                                & \\sum^P_{j=1} (1 - Q_{\\hat{s}_j}(0 | \\phi_j)) \\tilde{\\theta}^2_j\n      \\end{split}\n  \\end{equation}\n  \n\\end{frame}\n\n\\begin{frame}[t]{Challenges}\n  \\textbf{Challenge:} \\\\\n  The plumbing (data engineering)\n  \\\\\n  \\begin{itemize}\n    \\item Process of the UKB in parallel efficiently\n    \\item Large Memory requirements for the UKB (scaling)\n    \\item Currently using Dask on our cluster\n  \\end{itemize}\n  The optimization/implementation:\n  \\begin{itemize}\n    \\item Works fine on test data (1k Genome Project)\n    \\item Issues with larger data\n    \\item size of mini-batch size\n    \\item choosing appropriate learning rates\n  \\end{itemize}\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "df38ec8446d116f6894b80d31922deac86d4fce5", "size": 11400, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/presentation/l0_results/sim_results.tex", "max_stars_repo_name": "rmporsch/ML_genetic_risk", "max_stars_repo_head_hexsha": "4e1a0510c94260e69f93639ff4104c5f85080d9f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/presentation/l0_results/sim_results.tex", "max_issues_repo_name": "rmporsch/ML_genetic_risk", "max_issues_repo_head_hexsha": "4e1a0510c94260e69f93639ff4104c5f85080d9f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-11-13T18:04:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-10T19:40:45.000Z", "max_forks_repo_path": "doc/presentation/l0_results/sim_results.tex", "max_forks_repo_name": "rmporsch/ML_genetic_risk", "max_forks_repo_head_hexsha": "4e1a0510c94260e69f93639ff4104c5f85080d9f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-23T05:57:04.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-23T05:57:04.000Z", "avg_line_length": 37.6237623762, "max_line_length": 185, "alphanum_fraction": 0.6580701754, "num_tokens": 3960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.43534452205121504}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\setcounter{section}{-1}\n\n\\begin{document}\n\n\\title{Galois Theory}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{History}\n\nThe primary motivation is to stury the solutions in $\\C$ of polynomial equations in one variable and to wonder whether there is a formula involving roots, i.e. solution by radicals. Quadratics was solved at school. Cubics and quartics ware solved in 1770 by Lagrange. In 1799 Ruffini claimed to have proven that Quntics were not solvable by radicals but the proof was flawed. Abel gave the first accepted proof in 1824 using existing ideas about permutation of roots. Galois gave the first explanation as to why some polynomials are soluble by radicals and others are not. He made use of a group of permutation of the roots and he realized in particular, the importance of \\emph{normal} subgroups.\n\nFrom GRM, if $f(t)$ is an irreducible polynomian in $\\mathcal{K}[t]$ where $\\mathcal{K}$ is a field, then $\\mathcal{K}[t]/(f(t))$ is a field.\n\n\\newpage\n\n\\section{Field Extensions}\n\n\\subsection{Field extensions}\n\n\\begin{defi}\nA \\emph{field extension} $K \\leq L$ is the inclusion of a field $K$ into another field $L$, with the same $0,1$, and restriction of $+$ and $\\cdot$ in $L$ to $K$ gives the $+$ and $\\cdot$ in $K$.\n\\end{defi}\n\n\\begin{eg}\n$\\Q\\leq\\R$, $\\R\\leq\\C$, $\\Q \\leq \\Q(\\sqrt{2}) = \\{\\lambda + \\mu \\sqrt{2}, \\lambda,\\mu \\in \\Q\\}$, $\\{\\lambda+\\mu i,\\lambda,\\mu \\in \\Q\\} = \\Q(i) \\leq \\C$ are all field extensions.\n\\end{eg}\n\nSuppose $K \\leq L$ is a field extension. Then $L$ is a $K$-vector space using the addition from the field structure and the scalar multiplication given by the multiplication within the field $L$.\n\n\\begin{defi}\nThe \\emph{degree of $L$ over $K$} is $\\dim_K L$ is the dimension of the $K$-vector space $L$. This may not be finite, and we denote it as $|L:K|$.\\\\\nIf $|L:K|<\\infty$, we say the extension is \\emph{finite}. Otherwise it's infinite.\n\\end{defi}\n\n\\begin{eg}\n$|\\C:\\R| = 2$ because ${1,i}$ is a basis. Similarly $|\\Q(i):\\Q| = 2$.\\\\\nIn contrast, $\\Q\\leq\\R$ is an infinite extension.\n\\end{eg}\n\n\\begin{thm} (Tower Law)\\\\\nSuppose $K\\leq L\\leq M$ are field extensions. Then\n\\begin{equation*}\n\\begin{aligned}\n|M:K| = |M:L| |L:K|\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nAssume $|M:L|<\\infty$, $|L:K|<\\infty$. Then we take $L$-basis $\\{f_1,...,f_b\\}$ and $K$-basis $\\{e-1,...,e_a\\}$.\n\nNow take $m \\in M$. Then $m= \\sum_{i=1}^b \\mu_i f_i$ for some $\\mu_i \\in L$. However, for each $\\mu_i$ we have $\\mu_i = \\sum_{j=1}^a \\lambda_{ij} e_j$ for some $\\lambda_{ij} \\in K$. As a result,\n\\begin{equation*}\n\\begin{aligned}\nm=\\sum_{i=1}^b \\sum_{j=1}^a \\lambda_{ij} e_j f_i\n\\end{aligned}\n\\end{equation*}\nso $\\{e_jf_i | 1\\leq j\\leq a, 1 \\leq i \\leq a\\}$ span $M$.\n\nTo prove linear independence, it's enough to show that if $m=0$, then each of the $\\lambda_{ij}$ must be 0. When $m=0$, the linear independence of $f_i$ forces each $\\mu_i$ to be 0. But then by the linear independence of $e_i$, each $\\lambda_{ij}$ must be 0 as required.\n\nThe proof for infinite extensions is omitted. Observe (not very rigorously) that if $M$ is an infinite extension of $L$, then it is an infinite extension of $K$; and if $L$ is an infinite extension of $K$, then the larger field $M$ must also be an infinite extension of $K$.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\nConsider $\\Q \\leq \\Q(\\sqrt{2}) \\leq \\Q(\\sqrt{2},i)$. $\\Q(\\sqrt{2})$ has basis $1,\\sqrt{2}$ over $\\Q$, $\\Q(\\sqrt{2},i)$ has basis $1,i$ as a $\\Q(\\sqrt{2})$-vector space. Now $\\Q(\\sqrt{2},i)$ has basis $1,\\sqrt{2},i,i\\sqrt{2}$ over $\\Q$. So $|\\Q(i,\\sqrt{2}):\\Q| = 4 = 2\\cdot 2$.\n\\end{eg}\n\nNote that any intermediate field strictly between $\\Q(i,\\sqrt{2})$ and $\\Q$ is going to be of degree 2 over $\\Q$ by Tower Law. But what are they? We have $\\Q(\\sqrt{2},\\Q(i)$ and $\\Q(i\\sqrt{2})$ and we believe that's all, though that is not trivial.\n\nThe Galois correspondence arising in the \\emph{Fundamental Theorem of Galois Theory} gives an order-reversing bijection between the lattice of intermediate subfields and the subgroups of a group of ring automorphisms of the big field ($\\Q(i,\\sqrt{2})$ here) that fix the smaller field element-wise.\n\nLet's consider the ring automorphisms of $\\Q(i,\\sqrt{2})$ that fix $\\Q$. Certainly we have the identity map. Another thing we have is complex conjugation $g$: $\\sqrt{2} \\to \\sqrt{2}$, $i \\to -i$. Also we have $h: \\sqrt{2} \\to -\\sqrt{2}$ and $i \\to i$ as another automorphism. The last one is $gh$ sending $\\sqrt{2} \\to -\\sqrt{2}$ and $i \\to -i$. We shall note that $\\pm \\sqrt{2}$ and $\\pm i$ are really the same thing here, as they are both roots of $t^2-2=0$ and $t^2+1=0$ respectively.\n\nThese four maps form the group of order $4=|\\Q(\\sqrt{2},i):\\Q|$. Now note that there is a correspondence:\n\n\\includegraphics[scale=0.4]{image/GT_01.png}\n\nThe recipe for producing an intermediate subfield from a subgroup is to take the elements of $\\Q(i,\\sqrt{2})$ which are fixed by all elements of the subgroup, e.g. $\\Q(i\\sqrt{2})$ is the field of elements fixed by both $e$ and $gh$.\n\nThis correspondence doesn't always work for all finite field extensions. It works for \\emph{Galois extensions}.\n\nIn the correspondence, normal extensions correspond to normal subgroups. In the above example, all subgroups are normal and the extensions are normal.\n\nWe'll also prove the Primitive Element Theorem, which in the context of finite extensions of $\\Q$, tells us that they are necessarily of the form $\\Q(\\alpha)$ for some $\\alpha$, e.g. $\\Q(i,\\sqrt{2})$ (or $\\Q(i+\\sqrt{2})$).\n\nNow let's review some material from GRM:\n\n\\begin{defi}\nSuppose $K \\leq L$ is a field extension. Take $\\alpha \\in L$. We define $I_\\alpha = \\{f \\in K[t] : f(\\alpha) = 0\\}$, i.e. all the polynomials on $K$ with $\\alpha$ a root. $\\alpha$ is \\emph{algebraic} over $K$ if $I_\\alpha \\neq \\{0\\}$. Otherwise, $\\alpha$ is \\emph{transcendental}.\n\nWe say $L$ is algebraic over $K$ if $\\alpha$ is algebraic over $K$ for all $\\alpha \\in L$.\n\\end{defi}\n\n\\begin{rem}\n\\begin{equation*}\n\\begin{aligned}\nI_\\alpha = \\ker\\ \\left(\n\\begin{array}{ll}\nK[t] &\\to L\\\\\nf(t) &\\to f(\\alpha)\\\\\n\\end{array}\n\\right)\n\\end{aligned}\n\\end{equation*}\ni.e. the set of polynomials in $K[t]$ that have $\\alpha$ as a root, is an ideal of $K[t]$.\n\\end{rem}\n\n\\begin{eg}\n$\\sqrt{2}$ is algebraic over $\\Q$. $\\pi$ is transcendental over $\\Q$.\n\\end{eg}\n\n\\begin{lemma}(1.5)\\\\\nLet $K \\leq L$ be a finite field extension. Then $L$ is algebraic over $K$.\n\\begin{proof}\nLet $|L:K| = n$. Take $\\alpha \\in L$. Consider $1,\\alpha,\\alpha^2,...,\\alpha^n$. These must be linearly dependent in the $n$-dimensional $K$-vector space $L$. Therefore $\\sum_0^n \\lambda_i \\alpha^i=0$ for some $\\lambda_i \\in K$ not all zero. Then $\\alpha$ is a root of $f(t) = \\sum_0^n \\lambda_i t^i$, i.e. algebraic over $K$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi}(1.6)\\\\\nThe non-zero ideal $I_\\alpha$ (where $\\alpha$ is algebraic over $K$) is principal, since $K[t]$ is a principal ideal domain ($K$ is a field, so $K[t]$ is in fact a ED). So let $I_\\alpha = (f_\\alpha(t))$ and $f_\\alpha(t)$ can be assumed to be monic. Such a monic $f_\\alpha(t)$ is the \\emph{minimal polynomial of $\\alpha$ over $K$}.\n\\end{defi}\n\n\\begin{rem}\nMultiplication by $\\alpha$ within the field $L$ gives a $K$-linear map $L \\to L$, an automorphism (if $\\alpha \\neq 0$). In GRM we proved that the minimal polynomial of a linear map is unique.\n\\end{rem}\n\n\\begin{eg}\nThe minimal polynomial of $\\sqrt{2}$ over $\\Q$ is $t^2-2$, and is $t-\\sqrt{2}$ over $\\R$.\n\\end{eg}\n\n\\begin{lemma}(1.7)\\\\\nSuppose $K \\leq L$ is a field extension, and $\\alpha \\in L$ is algebraic over $K$. Then the minimal polynomial $f_\\alpha(t)$ of $\\alpha$ over $K$ is irreducible in $K[t]$. As a result, $I_\\alpha$ is a prime ideal.\n\\begin{proof}\nSuppose $f_\\alpha(t) = p(t) q(t)$. We must show that either $p(t)$ or $q(t)$ is a unit in $K[t]$. Note that \n\\begin{equation*}\n\\begin{aligned}\n0 = f_\\alpha(\\alpha) = p(\\alpha)q(\\alpha)\n\\end{aligned}\n\\end{equation*}\nWLOG assume $p(\\alpha)=0$. Then $p(t) \\in I_\\alpha$, i.e. $p(t) = f_\\alpha(t) \\cdot r(t)$ since $I_\\alpha = (f_\\alpha(t))$. So $f_\\alpha(t) = f_\\alpha(t) r(t) q(t)$, i.e. $r(t) q(t) = 1$, hence $q(t)$ is a unit of $K[t]$. So $f_\\alpha(t)$ is irreducible.\n\nRecall from GRM that irreducible elements of $K[t]$ are prime ($K[t]$ is PID), and generate prime ideals of $K[t]$. So $I_\\alpha$ is a prime ideal.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi} (1.8)\\\\\nSuppose $K \\leq L$ is a field extension, and $\\alpha \\in L$. $K(\\alpha)$ is the smallest subfield of $L$ that contains both $K$ and $\\alpha$, called the field generated by $K$ and $\\alpha$. We say that $L$ is a \\emph{simple extension} if $L=K(\\beta)$ for some $\\beta \\in L$.\n\\end{defi}\n\nNote that the previous Primitive Element Theorem can be restated as: any finite extension of $Q$ is a simple extension over $\\Q$.\n\nAlso, given $\\alpha_1,...,\\alpha_n \\in L$, $K \\leq L$, we call $K(\\alpha_1,...,\\alpha_n)$ the smallest intermediate field containing $\\alpha_1,...,\\alpha_n$. It is the field generated by $K$ and $\\alpha_1,...,\\alpha_n$. \n\nOn the other hand we'll prove that $K[\\alpha]$, the image of the map $K[t] \\to L$ by $f(t) \\to f(\\alpha)$, is the \\emph{ring} generated by $K$ and $\\alpha$ (for $\\alpha \\in L$).\n\n\\begin{thm} (1.9)\\\\\nSuppose $K \\leq L$ is a field extension, $\\alpha \\in L$ is algebraic over $K$. Then\\\\\n(i) $K(\\alpha) = K[\\alpha]$;\\\\\n(ii) $|K(\\alpha):K| = \\deg f_\\alpha (t)$ where $f_\\alpha(t)$ is the minimal polynomial of $\\alpha$ over $K$.\n\\begin{proof}\n(i) Clearly $K[\\alpha] \\leq K(\\alpha)$. We need to show that if $0 \\neq \\beta \\in K[\\alpha]$, then it is a unit in $K[\\alpha]$, so $K[\\alpha] $  is a field.\\\\\nFor every $\\beta$ we have $\\beta=g(\\alpha)$ for some $g(t) \\in K[t]$. Since $\\beta = g(\\alpha) \\neq 0$, $g(t) \\not\\in I_\\alpha = (f_\\alpha(t))$. Thus $f_\\alpha(t) \\nmid g(t)$. From theorem 1.7, $f_\\alpha(t)$ is irreducible. From GRM, since $K[t]$ is a PID, we know there exist $r(t),s(t) \\in K[t]$ with $r(t) f_\\alpha(t) + s(t) g(t) = 1$ in $K[t]$. Hence $s(\\alpha) g(\\alpha) = 1$ in $K[\\alpha]$. So $\\beta = g(\\alpha)$ is a unit as required.\n\n(ii) Let $n = \\deg f_\\alpha(t)$. We'll show that $\\{1,\\alpha,...,\\alpha^{n-1}\\}$ is a $K$-vector space basis of $K[\\alpha]$.\\\\\nIf $f_\\alpha(t) = t^n + a_{n-1}t^{n-1}+...+a_0$ with $a_i \\in K$, then $\\alpha^n = -a_{n-1}\\alpha^{n-1} -...-a_0$. This implies that $\\alpha^n$ is a linear combination of $\\{1,...,\\alpha^{n-1}\\}$.\\\\\nAn easy induction shows that $\\alpha^m$ for $m \\geq n$ is likewise a linear combination of $\\{1,\\alpha,...,\\alpha^{n-1}\\}$. Thus the above set spans $K[\\alpha]$.\\\\\nSuppose $\\lambda_{n-1}\\alpha^{n-1}+...+\\lambda_0=0$. Let $g(t) = \\lambda_{n-1}t^{n-1}+...+\\lambda_0$. Since $g(\\alpha)=0$, we have $g(t) \\in I_\\alpha = (f_\\alpha(t))$. So $g(t) = 0$ or $f_\\alpha(t) \\mid g(t)$. The latter is not possible because $\\deg f_\\alpha(t) > \\deg g(t) = n-1$. So $g(t)=0 \\in K[t]$, and all the $\\lambda_i$ must then be zero.\n\\end{proof}\n\\end{thm}\n\n\\begin{coro} (1.10)\\\\\nIf $K \\leq L$ is a field extension and $\\alpha \\in L$, then $\\alpha$ is algebraic over $K$ $\\iff$ $K \\leq K(\\alpha)$ is finite.\n\\begin{proof}\nThe forward direction is given by (1.9), $|K(\\alpha):K| = \\deg f_\\alpha(t) < \\infty$. The backward is given by (1.5).\n\\end{proof}\n\\end{coro}\n\n\\begin{coro} (1.11)\\\\\nLet $K \\leq L$ be a field extension with $|L:K|=n$. Let $\\alpha \\in L$. Then $\\deg f_\\alpha(t) | n$.\n\\begin{proof}\nUse the Tower Law (1.3) on $K \\leq K(\\alpha) \\leq L$, we deduce that $|K(\\alpha) : K| $ divdes $|L:K|$. (1.9) says that $\\deg f_\\alpha(t) = |K(\\alpha):K|$.\n\\end{proof}\n\\end{coro}\n\n\\subsection{Constructibility problems}\nNow let's digress on some constructibility problems. Assume we're given a set $P_0$ of points in $\\R^2$. A ruler operation is to draw a straight line through any two points in $P_0$, and a compass operation is to draw a circle with a centre being a point in $P_0$ and radius equal to tidtance between a pair of points in $P_0$.\n\n\\begin{defi} (1.12)\\\\\nThe points of intersection of any two distinct lines or circles drawn using those operations are constructible in one step from $P_0$.\n\nA point $\\mathbf{r} \\in \\R^2$ is constructible from $P_0$ if there is a finite sequence $\\mathbf{r}_1,...,\\mathbf{r}_n = \\mathbf{r}$ Such that $r_i$ is constructible in one step from $P \\cup \\{r_1,...,r_{i-1}\\}$.\n\\end{defi}\n\nAn easy exercise is to construct the midpoint of a line between two points.\n\nNow let $K_0$ be the subfield of $\\R$ generated by $\\Q$ and the coordinates of the points in $P_0$. Let $\\mathbf{r}_i = (x_i,y_i)$. Set $K_i = K_{i-1} (x_i,y_i)$. Thus $K_0 \\leq K_1 \\leq ... \\leq K_m \\leq \\R$.\n\n\\begin{lemma} (1.13)\\\\\n$x_i$, $y_i$ are both roots in $K_i$ of quadratic polynomials in $K_{i-1}[t]$.\n\\begin{proof}\nWe have 3 cases of intersections: line meets line, line meets circle, circle meets circle. We can just consider the equations of lines/circles and solve a system of equation for each case of intersection, which in all three cases are at most quadratic equations.\n\\end{proof}\n\\end{lemma}\n\n\\begin{thm} (1.14)\\\\\nIf $\\mathbf{r} = (x,y)$ is a constructible point from set $P_0$ of points in $\\R^2$, and if $K_0$ is the subfield of $\\R$ generated by $\\Q$ and the coordinates of the points in $P_0$, then the degrees $|K_0(x):K_0|$ and $|K_0(y):K_0|$ are both powers of $2$.\n\\begin{proof}\nWe continue with the previous notation, $K_i = K_{i-1} (x_i,y_i)$. By tower law,\n\\begin{equation*}\n\\begin{aligned}\n|K_i:K_{i-1}| = |K_{i-1}(x,y):K_{i-1}(x)| |K_{i-1}(x) : K_{i-1}|\n\\end{aligned}\n\\end{equation*}\nBut (1.13) tells us that $|K_{i-1}(x):K_{i-1}|$ is $1$ or $2$ using degree of extension $=$ degree of minimal polynomial of $x$ over $K_{i-1}$. Similarly $y$ satisfies a quadratic polynomial over $K_{i-1}$ and hence over $K_{i-1}(x)$. So $|K_{i-1}(x,y):K_{i-1}(x)|$ is $1$ or $2$.\n\nSo $|K_i:K_{i-1}|$ is 1,2 or 4 (but $4$ doesn't happen -- that doesn't matter anyway in this proof). Then we just use tower law recursively. Now if $\\mathbf{r}=(x,y)$ is constructible from $P_0$ then we can write $x,y \\in K_n$ and $K_0 \\leq K_0(x) \\leq K_n$ and $K_0 \\leq K_0(y) \\leq K_n$. Then again by tower law we know the two indexes must be some powers of $2$.\n\\end{proof}\n\\end{thm}\n\nThat is a nice theorem to determine constructibility, but to actually use it we need to be reasonable expert at working out minimal polynomials. Recall from GRM that\n\n\\begin{thm} (1.15, Gauss' lemma)\\\\\nLet $f(t)$ be a primitive integral polynomial. Then $f(t)$ is irreducible in $\\Q[t]$ iff $f(t)$ is irreducible in $\\Z[t]$.\n\\end{thm}\nAnother useful tool is\n\\begin{thm} (1.16, Eisenstein's criterion)\\\\\nLet $f(t) = a_n t^n + a_{n-1} t^{n-1} + ... + a_0 \\in \\Z[t]$. Suppose there is a prime $p$ such that\\\\\n(1) $p \\nmid a_n$;\\\\\n(2) $p \\mid a_i$ for $i=0,...,n-1$;\\\\\n(3) $p^2 \\nmid a_0$.\nThen $f(t)$ is irreducible in $\\Z[t]$.\n\\end{thm}\n\nAnother method is to consider an integral polynomial $f(t) \\pmod p$. If $f(t)$ is reducible in $\\Z[t]$ then it is reducible in $\\Z/p\\Z$. So if we find a prime $p$ such that $f(t) \\pmod p$ is irreducible, then $f(t)$ must be irreducible in $\\Z[t]$.\n\nTo see how this work, we prove that $t^3+t+1$ is irreducible. Consider $\\Z/2\\Z$, if it were irreducible it would have a linear factor and the polynomial would have a root; but neither $0$ nor $1$ is a root. So $t^3+t+1$ is not reducible mod $2$, so not reducible in $\\Z[t]$ (and $\\Q[t]$) either.\n\nHowever, on later example we'll see an example that is irreducible in $\\Z[t]$ but is reducible mod $p$ for all primes $p$. So this method is not sufficient in all cases.\n\n\\begin{thm} (1.17)\\\\\nThe cube cannot be duplicated by ruler and compasses.\n\\begin{proof}\nThe problem amounts to whether given a unit distance, one can construct points distanced $\\alpha=\\sqrt[3]{2}$ apart, i.e. starting with $P_0=\\{(0,0),(1,0)\\}$, can we produce $(\\alpha,0)$? The answer is NO -- if we could then we need $|\\Q(\\alpha):\\Q|$ to be a power of $2$, but $|\\Q(\\alpha):\\Q|=\\deg f_\\alpha(t) = 3$ as $f_\\alpha(t) = t^3-2$ and we know that that is not reducible (using Eisenstein's with $p=2$).\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (1.18)\\\\\nThe circle cannot be squared using ruler and compasses.\n\\begin{proof}\nSimilarly, the problem becomes starting with $(0,0)$ and $(1,0)$, can we construct $(\\sqrt{\\pi},0)$. But we know $\\pi$ is transcendental over $\\Q$ (by Lindermann -- not proved here).\n\\end{proof}\n\\end{thm}\n\n\\subsection{Field extensions}\nNow we return to our theory development.\n\n\\begin{lemma} (1.19)\\\\\nLet $K \\leq L$ be a field extension. Then\\\\\n(i) $\\alpha_1,...,\\alpha_n \\in L$ are algebraic over $K$ if and only if $K \\leq K(\\alpha_1,...,\\alpha_n)$ is a finite extension.\\\\\n(ii) If $K \\leq M \\leq L$ such that $K \\leq M$ is finite, then there exists $\\alpha_1,...,\\alpha_n \\in L$ such that $K(\\alpha_1,...,\\alpha_n) = M$.\\\\\nNote that $L$ isn't really relevant in the second part.\n\\begin{proof}\n(i) By (1.10), $\\alpha$ is algebraic over $K$ if and only if $K \\leq K(\\alpha)$ is a finite field extension. $\\alpha_i$ is algebraic over $K$, hence algebraic over $K(\\alpha_1,...,\\alpha_{i-1})$. So $|K(\\alpha_1,...,\\alpha_i):K(\\alpha_1,...,\\alpha_{i-1})|$ is finite. By tower law applied to $K \\leq K(\\alpha_1) \\leq K(\\alpha_1,\\alpha_2) \\leq ... \\leq K(\\alpha_1,...,\\alpha_n)$, we get $|K(\\alpha_1,...,\\alpha_n):K|$ is finite.\n\nConversely, consider $K \\leq K(\\alpha_1)\\leq K(\\alpha_1,...,\\alpha_n)$. Then the tower law says that if $|K(\\alpha_1,...,\\alpha_n) :K|$ is finite then $|K(\\alpha_i):K|$ is also finite for any $i$, i.e. $\\alpha_i$ is algebraic.\n\n(ii) If $|M:K|=n$, then $M$ is an $n$-dimensional $K$-vector space by definition. So there exists a $K$-basis $\\alpha_1,...,\\alpha_n$ of $M$. Then $K(\\alpha_1,...,\\alpha_n) \\leq M$. However, element of $M$ is a $K$-linear combination of $\\alpha_1,...,\\alpha_n$, so we also have $M \\leq K(\\alpha_1,...,\\alpha_n)$. So they are equal.\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi} (1.20)\\\\\nSuppose $K \\leq L$, $K \\leq L'$ are fields extensions. A $K$-homomorphism: $\\phi: L \\to L'$ is a ring homomorphism such that $\\phi|_K = id$.\n\\end{defi}\n\nWe'll occasionally use the notation $Hom_K(L,L') = \\{K$-homomorphisms $L \\to L'\\}$.\n\nA $K$-homomorphism $\\phi:L \\to L'$ is a $K$-isomorphism if it is a ring isomorphism.\n\nWe have another notation, $\\Aut_K(L) = \\{K-$isomorphisms $L \\to L\\}$ which is a group.\n\n\\begin{lemma} (1.21)\\\\\nSuppose $K \\leq L$, $K \\leq L'$ are field extensions. Then \\\\\n(i) Any $K$-homomorphism $\\phi:L \\to L'$ is injective, and $K \\leq \\phi(L)$ is a field extension;\\\\\n(ii) If $|L:K| = |L':K|$ is finite, then any $K$-homomorphism is actually a $K$-isomorphism.\n\\begin{proof}\n(i) $L$ is a field, so $\\ker(\\phi)$ is an ideal of $L$. Note that $1 \\to 1$ by $\\phi$, so $\\ker \\phi$ can't be the whole of $L$. So $\\ker\\phi = \\{0\\}$, i.e. $\\phi(L)$ is a field and $K \\leq \\phi(L)$ is a field extension.\n\n(ii) $\\phi$ is an injective $K$-linear map, and so $|\\phi(L):K| = |L:K|$ considering dimensions of $K$-vector spaces. As a result, $\\phi(L) = L'$, i.e. $\\phi$ is an isomorphism.\\\\\nIn particular, if $L=L'$, then $\\phi$ is an $K$-automorphism of $L$.\n\\end{proof}\n\\end{lemma}\n\nWe introduce another notation: If $K \\leq L$ is a field extension, and if $f(t) \\in K[t]$, we denote the set of roots of $f$ in $L$ by $Root_f (L)$.\n\n\\begin{defi} (1.22)\\\\\nLet $K \\leq L$ be a field extension, and $f(t) \\in K[t]$. We say $f$ \\emph{splits over $L$} if $f(t) = a(t-\\alpha_1)...(t-\\alpha_n)$, where $a \\in K$, $\\alpha_1,...,\\alpha_n \\in L$. We say $L$ is a \\emph{spltting field} for $f$ over $K$ if $L = K(\\alpha_1,...,\\alpha_n)$.\n\\end{defi}\n\n\\begin{rem}\nThis is equivalent to saying that $L$ is a splitting field for $f$ over $K$ if and only if:\\\\\n(i) $f$ splits over $K$;\\\\\n(ii) if $K \\leq M \\leq L$ and $f$ splits over $M$ then $M = L$ (minimality).\n\\end{rem}\n\n\\begin{eg}\n(1) $f(t) = t^3-2$ over $\\Q$. $\\Q(\\sqrt[3]{2})$ is not a splitting field for $f$ over $\\Q$, but $\\Q(\\sqrt[3]{2},\\omega \\sqrt[3]{2},\\omega^2 \\sqrt[3]{2})$ is a splitting field over $Q$, where $\\omega$ is the primitive cube root of unity. Note that the above field is equal to $\\Q(\\sqrt[3]{2},\\omega)$.\\\\\nNote that $\\Q(\\sqrt[3]{2})$ is degree $3$ over $\\Q$, but $\\Q(\\omega)$ is only degree 2. Also $|\\Q(\\sqrt[3]{2},\\omega):\\Q(\\omega)|\\leq 3$ and $|\\Q(\\sqrt[3]{2},\\omega) : \\Q(\\sqrt[3]{2})| \\leq 2$. Then use the tower law and we get $2 \\mid |\\Q(\\sqrt[3]{2},\\omega):\\Q|$, and $3$ also divides it. So $\\Q(\\sqrt[3]{2},\\omega)$ must be at least degree 6. So the two previous inequalities actually have their equal signs hold.\n\n(2) $f(t) = (t^2-3)(t^3-1)$. Splitting field for $f$ over $\\Q$ is $\\Q(\\sqrt{3},-\\sqrt{3},\\omega,\\omega^2,1) = \\Q(\\sqrt{3},\\omega) = \\Q(\\sqrt{3},i)$ since we know $\\omega = \\frac{-1+\\sqrt{3}i}{2}$.\n\n(3) $t^2-3$ and $t^2-2t-2$ both have the same splitting field $\\Q(\\sqrt{3})$ over $\\Q$.\n\n(4) $f(t) = t^2+t+1$ in $\\F_2[t]$ (where $\\F_2 =$ field of $2$ elements $0,1 = \\Z / 2\\Z$). $f(t)$ is irreducible over $\\F_2$ since it has no roots in $\\F_2$ and hence no linear factors $\\F_2[t]$. So $\\F_2[t] / (t^2+t+1)$ is a field.\n\nNow set $\\alpha = t+(t^2+t+1) \\in \\F_2[t] / (t^2+t+1)$. Then $\\F_2[t] / (t^2+t+1) = \\F_2(\\alpha)$. The elements are $0,1,\\alpha,\\alpha+1$. $f(t) =t^2+t+1$ splits over $\\F_2(\\alpha)$  noting that $\\alpha^2 = \\alpha+1$. Now $f(t) = (t-\\alpha)(t-1-\\alpha)$. Thus $\\F_2(\\alpha)$ is splitting field for $f$ over $\\F_2$.\n\\end{eg}\n\nWe use this construction to produce splitting field in general.\n\n\\begin{thm} (1.23, Existence of splitting fields)\\\\\nLet $K$ be a field, and $f(t) \\in K[t]$. Then there exists a splitting field for $f$ over $K$.\n\\begin{proof}\nIf $\\deg f = 0$, then $K$ itself is the splitting field.\\\\\nNow let $\\deg f >0$ and pick an irreducible factor $g(t)$ of $f(t)$ in $K[t]$. Note $K \\leq K[t] / (g(t))$ is a field extension.\\\\\nNow take $\\alpha_1 = t+(g(t)) \\in K[t] / (g(t))$. Then $K[t] / (g(t)) = K(\\alpha_1)$ and $g(\\alpha_1) = 0$ in $K(\\alpha_1)$; therefore $f(\\alpha_1) = 0$ in $K(\\alpha_1)$, and we can write $f(t) = (t-\\alpha_1) h(t)$ in $K(\\alpha_1)[t]$. Repeat, noting that $\\deg h(t) < \\deg f(t)$, and we get $f(t) = a(t-\\alpha_1) (t-\\alpha_2) ... (t-\\alpha_n)$ where $a$ is a constant, which is in $K$ (consider top coefficient).\\\\\nThus we have a factorization of $f(t)$ in $K(\\alpha_1,...,\\alpha_n)[t]$, i.e. $K(\\alpha_1,...,\\alpha_n)$ is a splitting field for $f$ over $K$.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (1.24, Uniqueness of splitting fields)\\\\\nIf $K$ is a field and $f(t) \\in K[t]$, then the splitting field for $f$ over $K$ is unique up to $K$-isomorphisms.\n\\begin{proof}\nSuppose $L$ and $L'$ are both splitting fields for polynomial $f(t) \\in K[t]$ over $K$. We need to show that there is a $K$-isomorphism $L \\to L'$. Suppose $K \\leq M \\leq L$ and $\\exists K \\leq M' \\leq L'$ and a $K$-isomorphism $\\psi: M \\to M'$; clearly we can always take $M=K$, so such $M$ always exists. Now we pick $M$ so that $|M:K|$ is maximal among all such $M,M',\\psi$. We must show $M=L$ and $M'=L'$. Note that if $M=L$, then $f(t)$ splits over $L$ then $f(t)$ splits over $M$, i.e. $f(t) = a(t-\\alpha_1)...(t-\\alpha_m)$ in $M[t]$. Now apply $\\psi$, we got an induced map $M[t] \\to M'[t]$, and $f(t) \\to \\psi f(t) = \\psi(a)(t-\\psi(\\alpha_1))...(t-\\psi(\\alpha_m))$, thus $f(t)$ splits over $\\psi(M) = M'$. But $L'$ is a splitting field, and $M' \\leq L'$; but a splitting field is the minimal field extension that $f$ splits; so $M'=L'$.\n\nOtherwise, if $M \\neq L$, we want to get a contradiction of maximality of $M$. Since $M < L$, there is a root $\\alpha$ of $f(t) \\in L$ that is not in $M$. Now factorize $f(t) = g(t) h(t)$ in $M[t]$ so that $g(t)$ is irreducible in $M[t]$ and $g(\\alpha)=0$ in $L$. Then there exists a $K$-homomorphism $M[t]/(g(t)) \\to L$ by $t+(g(t)) \\to \\alpha$. The image of this is $M(\\alpha)$, the $K$-isomorphism $M[t] \\to M'[t]$ induced by $\\psi$ maps $g(t)\\in M[t]$ to some $\\gamma(t) \\in M'[t]$. Now $f(t) = g(t)h(t)$ in $M[t]$ is mapped to $f(t) = \\gamma(t) \\delta(t)$ in $M'[t]$. We now have a field extension $M' \\leq M'[t] / (\\gamma(t))$, and there exists a $M'$-homomorphism $M'[t]/(\\gamma(t)) \\in L'$ by picking a root $\\alpha'$ of $\\gamma(t)$ in $L'$, sending $t+(\\gamma(t)) \\to \\alpha'$. However $\\gamma(t) |f(t)$ in $M'[t]$, hence in $L'[t]$. As a result, this root $\\alpha'$ is also a root of $f(t)$ in $L'$. The $M'$-homomorphism gives a $K$-isomorphism $M'[t] / (\\gamma(t)) \\to M'(\\alpha')$, and so we have a $K$-isomorphism $M(\\alpha) \\to M'(\\alpha')$. This contradicts the maximality of $M$ and $M'$.\n\\end{proof}\n\\end{thm}\n\n\\begin{defi} (1.25)\\\\\nAn algebraic field extension $K \\leq L$ is \\emph{normal} if for every $\\alpha \\in L$, the minimal polynomial $f_\\alpha(t)$ of $\\alpha$ over $K$ splits over $L$.\n\\end{defi}\n\n\\begin{thm} (1.26)\\\\\nLet $K \\leq L$ be a finite field extension. Then $K \\leq L$ is normal $\\iff$ $L$ is the splitting field for some $f(t) \\in K[t]$.\n\\begin{proof}\nThis proof will be presented later.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg} (1.27)\\\\\nLet $\\F$ be a finite field, with $|\\F| = m$. We know $\\F$ has characteristic $p$ for some prime $p$, and $\\F_p \\leq \\F$. Therefore $m=p^r$ for some $r$. The non-zero elements from the multiplicative group, of order $m-1=n$, say. Also they satisfy $t^n-1$, i.e. they are roots of $t^n-1$. So $t^n-1 = (t-\\alpha_1)...(t-\\alpha_n)$ where $\\alpha_1,...,\\alpha_n$ are the non-zero elements of $\\F$. Thus $\\F$ is the splitting field for $t^n-1$ over $\\F_p$. By (1.24) we have uniqueness of splitting fields, so any other field with $m$ elements is $\\F_p$-isomorphic to $\\F$. (Note that we haven't shown that there exists such a $\\F$).\n\\end{eg}\n\n\\begin{thm} (1.28)\\\\\nLet $G$ be a finite subgroup of the multiplicative group of a field $K$. Then $G$ is cyclic. In particular, the multiplicative group of a finite field is cyclic.\n\\begin{proof}\nLet $|G|=n$. By structure theorem of finite abelian groups, we have\n\\begin{equation*}\n\\begin{aligned}\nG \\cong C_{q_1^{m_1}} \\times C_{q_2^{m_2}} \\times ... \\times C_{q_r^{m_r}}\n\\end{aligned}\n\\end{equation*}\nwith $q_i$ prime, but not necessarily distinct. However, if we have $q=q_i = q_j$ for some $i \\neq j$, there are at least $q^2$ distinct solutions of $t^q-1=0$ in $K$, since $C_q \\times C_q$ is isomorphic to a subgroup of $G$. However in a field (even in an integral domain), we know a polynomial of degree $q$ has at most $q$ roots. So the $q_i$ must be distinct and hence $G$ is actually cyclic, generated by $(g_1,...,g_r)$ where $g_i$ generates $C_{q_i^{m_i}}$.\n\\end{proof}\n\\end{thm}\n\n\\newpage\n\n\\section{Separable, Normal and Galois Extensions}\n\n\\subsection{Separable extensions}\n\n\\begin{defi} (2.1)\\\\\nLet $K$ be a field and $f(t) \\in K[t]$. Suppose $f(t)$ is irreducible in $K[t]$, and $L$ is a splitting field of $f(t)$ over $K$. Then $f(t)$ is \\emph{separable over $K$} if $f(t)$ has no repeated roots in $L$. For general $f(t)$, we say $f(t)$ is \\emph{separable over $K$} if every irreducible factor in $K[t]$ is separable over $K$. All constant polynomials are deemed to be separable.\n\\end{defi}\n\n\\begin{defi} (2.2)\\\\\nIf $K$ is a field, then formal differentiation $D:K[t] \\to K[t]$ is a $K$-linear map with $D(t^n) = nt^{n-1}$. We denote $D(f(t))$ by $f'(t)$.\n\\end{defi}\n\n\\begin{lemma} (2.3)\\\\\nLet $K$ be a field, $f(t),g(t) \\in K[t]$. Then\n\\begin{equation*}\n\\begin{aligned}\nD(f(t)g(t)) = f'(t)g(t)+f(t)g'(t)\n\\end{aligned}\n\\end{equation*}\nand if $f(t) \\neq 0$, then $f(t)$ has a repeated root in a splitting field if and only if $f(t)$ and $f'(t)$ have a common irreducible factor in $K[t]$.\n\\begin{proof}\n(a) $D$ is a $K$-linear map and so we only need to check for $f(t) = t^n$ and $g(t) = t^m$. (check)\n\n(b) Let $\\alpha$ be a repeated root in a splitting field $L$. Then $f(t) = (t-\\alpha)^2g(t)$ in $L[t]$, hence $f'(t) = (t-\\alpha)^2 g'(t) + 2(t-\\alpha)g(t)$ and so $f'(\\alpha) = 0$. Therefore the minimal polynomial $f_\\alpha(t)$ of $\\alpha$ in $K[t]$ divides both $f(t)$ and $f'(t)$, and thus $f_\\alpha(t)$ is a common irreducible factor of $f(t)$ and $f'(t)$. Conversely, let $h(t)$ be a common irreducible factor of $f(t)$ and $f'(t)$ in $K[t]$. Pick a root $\\alpha$ in $L$ of $h(t)$, so $f(\\alpha) = 0 = f'(\\alpha)$. Thus $f(t) = (t-\\alpha) g(t)$ in $L[t]$, and $f'(t) = (t-\\alpha) g'(t) + g(t)$. Since $f'(\\alpha) =0 $, we have $(t-\\alpha) | f'(t)$, so $(t-\\alpha)|g(t)$. Hence we have $(t-\\alpha)^2 | f(t)$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro} (2.4)\\\\\nIf $K$ is a field and $f(t) \\in K[t]$ is irreducible,\\\\\n(i) If $char(K) = 0$ then $f(t)$ is separable over $K$;\\\\\n(ii) If $char(K)=p>0$ then $f(t)$ is not separable if and only if $f(t) \\in K[t^p]$.\n\\begin{proof}\nBy (2.3), $f(t)$ is not separable if and only if $f(t)$ and $f'(t)$ has a common irreducible factor. But $f(t)$ is not irreducible, the only possible factor is $f(t)$ itself, i.e. $f(t) | f'(t)$, i.e. $f'(t) =0$ since it has a smaller degree. But then if $f(t) = a_n t^n + ... + a_0$, then $f'(t) = na_n t^{n-1}+...+a_1$, thus $f'(t) = 0 \\iff ia_i=0 \\forall i \\geq 1$. So \\\\\n(i) $char(K) = 0$, so $f'(t) \\neq 0$ for non-constant polynomial $f(t)$. So $f(t)$ is separable over $K$.\\\\\n(ii) If $char(K) = p > 0$, then if $f'(t) = 0$ we have $ia_i = 0 \\forall i>0$, i.e. $f(t)$ is not separable $\\iff$ $f(t) \\in K[t^p]$.\n\\end{proof}\n\\end{coro}\n\n\\begin{defi}(2.5)\\\\\nIf $K \\leq L$ is a field extension, we say $\\alpha \\in L$ is separable over $K$ if its minimal polynomial is separable over $K$. $L$ is separable over $K$ if all elements of $L$ are separable over $K$. If the minimal polynomial of $\\alpha$ is $f_\\alpha(t) = (t-\\alpha)^n = t^n - \\alpha^n$ where $n$ is a power of $p$ ($=char(K)$), we say $\\alpha$ is \\emph{purely inseparable} over $K$.\n\\end{defi}\n\n\\begin{eg} (2.6)\\\\\n(1) Let $\\Q \\subseteq L$ be an algebraic field extension. Then $L$ is separable over $\\Q$.\\\\\n(2) Let $L = \\F_p(X)$, the rational functions in $X$ over $\\F_p$, and $K = \\F_p (X^p)$ be a subfield. Then $K \\leq L$ is not separable: observe that if $f(t) = t^p - X^p \\in K[t]$. Then $f'(t) = 0$. But $t^p-X^p = (t-X)^p$ in $L[t]$. However, $f(t)$ is irreducible in $K[t]$: suppose we have a factorization $f(t) = g(t)h(t)$ in $K[t]$ and hence in $L[t]$, so we get $g(t) = (t-X)^r$ for some $0 \\leq r < p$ if the factorisation is non-trivial. But this would mean $X^r$ was in $K$. However (again), $\\exists$ integers $a,b$ s.t. $ar+bp=1$, so $(X^r)^a (X^p)^b \\in K$, i.e. $X \\in K$. Thus we'd have $X = u(X^p)/v(X^p)$, contradiction.\\\\\nThus $f(t) = t^p -X^p$ is the minimal polynomial of $X$ over $K$. Thus $X$ is purely inseparable over $K$, and $K \\leq l$ is not separable.\\\\\n(3) Let $\\F$ be a finite field with $|\\F| = m$, a power of $p = char(\\F)$, and $f(t) = t^n - 1$ where $n=m-1$. We know this is separable over $\\F_p$ since we saw that $f(t)$ has distinct linear factors in $F[t]$.\n\\end{eg}\n\n\\begin{rem}\nIt's useful to have an alternative approach to separability of field extensions without having to check separability of minimal polynomials for all elements of the larger field. This is where we start thinking about $K$-homomorphisms.\n\\end{rem}\n\n\\begin{lemma} (2.6)\\\\\nLet $M = K(\\alpha)$ for $\\alpha$ algebraic over $K$, and let $f_\\alpha(t)$ be the minimal polynomial of $\\alpha$ over $K$. For any field extension $K \\leq L$, the number of $K$-homomorphisms of $M$ to $L$ is equal to the number of distinct roots of $f_\\alpha(t)$ in $L$. Thus this number $\\leq \\deg f_\\alpha(t) = |K(\\alpha):K| = |M:K|$.\n\\begin{proof}\nWe saw in (1.21) that any $K$-homomorphism $M$ to $L$ is injective, $K(\\alpha) \\cong K[t]/(f_\\alpha(t))$. For any root $\\beta$ of $f_\\alpha(t)$ in $L$, we can define a $K$-homomorphism $K[t]/(f_\\alpha(t)) \\to L$ that sends $t+(f_\\alpha(t)) \\to \\beta$. Thus we get a $K$-homomorphism $M \\to L$. Conversely, for any $K$-homomorphism $\\phi:M \\to L$, the image $\\phi(\\alpha)$ must satisfy $f_\\alpha(\\phi(\\alpha)) = 0$. These processes are inverse to each other,\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}(2.7)\\\\\nIn (2.6), the number of $K$-homomorphisms $K(\\alpha) \\to L$ $= \\deg f_\\alpha(t)$ if and only if $L$ is large enough, i.e. $L$ contains a splitting field for $f_\\alpha(t)$ and $\\alpha$ is separable over $K$.\n\\end{coro}\n\n\\begin{lemma}(2.8)\\\\\nLet $K \\leq M$ be a field extension and $M_1 = M(\\alpha_1)$ where $\\alpha_1$ is algebraic over $M$. Let $f(t)$ be the minimal polynomial of $\\alpha$ over $M$ and let $K \\leq L$. Let $\\phi:M \\to L$ be a $K$-homomorphism. Then there is a 1-1 correspondence between the extensions $\\phi_1:M_1 \\to L$ of $\\phi$ and the roots of $\\phi(f(t))$ in $L$.\n\nNote that (2.6) is a special case $M=K$ and $\\phi$=inclusion of $K$ in $L$.\n\\begin{proof}\n$f(t)$ is irreducible in $M[t]$ implies that $\\phi(f(t))$ is irreducible in $\\phi(M)[t]$. Any extension $\\phi_1:M_1 \\to L$ of $\\phi$ produces a root $\\phi_1(\\alpha_1)$ of $\\phi(f(t))$. Conevrsely, given a root $\\gamma$ of $\\phi(f(t))$ in $L$, we have $M_1 = M(\\alpha_1) \\cong M[t] / (f(t)) \\cong \\phi(M)[t]/\\phi(f(t)) \\cong \\phi(M)(\\gamma) \\leq L$ Thus we get an extension $\\phi_1$ of $\\phi$ as required.\n\\end{proof}\n\\end{lemma}\n\n\\begin{coro}(2.9)\\\\\nIf $L$ is large enough, the number of $\\phi_1$ which extend $\\phi$ is equal to the number of distinct roots of $f(t)$ in $L$. This is equal to $|M_1:M|$ if and only if $\\alpha$ is separable over $M$.\n\\end{coro}\n\n\\begin{coro}(2.10)\\\\\nLet $K \\leq M \\leq N$ be finite field extensions, $K \\leq L$. Let $\\phi:M \\to L$ be a $K$-homomorphism. Then the number of extensions of $\\phi$ to maps $\\theta:N \\to L$ $\\leq |N:M|$. Moreover, such a $\\theta$ exists if $L$ is large enough.\n\\begin{proof}\nPick $\\alpha_1,...,\\alpha_n$ so that $N=M(\\alpha_1,...,\\alpha_r)$ and set $M_i = M(\\alpha_1,...,\\alpha_i)$. Thus we've got $M \\leq M_1 \\leq M_2 \\leq ... \\leq M_n = N$. Consider extension to each $M_i$ and by tower law we get the required inequality. The last bit comes from the proof of (2.8), i.e. we need $L$ to contain the roots.\n\\end{proof}\n\\end{coro}\n\n\\begin{rem}(2.11)\\\\\nThe profo and (2.9) shows that number of extensions $\\theta$ of $\\phi$ is $|N:M|$ if and only if $L$ is large enough and $\\alpha_i$ is separable over $M(\\alpha,...,\\alpha_{i-1})$ for each $i$.\n\\end{rem}\n\n\\begin{thm}(2.12)\\\\\nLet $K \\leq N$ be a field extension with $|N:K| = n$ and $N=K(\\alpha_1,...,\\alpha_n)$, say. Then the following are equivalent:\\\\\n(1) $N$ is separable over $K$;\\\\\n(2) each $\\alpha_i$ is separable over $K(\\alpha_1,...,\\alpha_{i-1})$;\\\\\n(3) if $K\\leq L$ is large enough, there are exactly $n$ distinct $K$-homomorphisms $N \\to L$.\n\\begin{proof}\n(1) $\\to$ (2): $N$ separable over $K$ $\\implies$ $\\alpha_i$ is separable over $K$. The minimal polynomial of $\\alpha_i$ over $K(\\alpha_1,...,\\alpha_{i-1})$ divides minimal polynomial of $\\alpha_i$ over $K$ (in $K(\\alpha_1,...,\\alpha_{i-1})[t]$). So if the latter has distinct roots in a splitting field then the former does. So $\\alpha_i$ separable over $K$ $\\implies$ $\\alpha_i$ separable over $K(\\alpha_1,...,\\alpha_{i-1})$.\n\n(2) $\\to$ (3) is (2.11).\n\n(3) $\\to$ (1): Assume (3) is true but (1) is false. So $\\exists \\beta \\in N$ that is not separable over $K$. So there are strictly less than $|K(\\beta):K|$ $K$-homomorphisms $\\phi:K(\\beta) \\to L$ by (2.7). By (2.10), $\\phi$ extends to at most that number of extensions $\\theta:N \\to L$. So there are strictly less than $|:K(\\beta)||K(\\beta):K|$ $K-$homomorphisms $N \\to L$. Contradiction.\n\\end{proof}\n\\end{thm}\n\n\\begin{defi}(2.13)\\\\\nWe say $M=K(\\alpha_1,...,\\alpha_r)$ is \\emph{separably generated} by $\\alpha_1,...,\\alpha_r$ over $K$ if each $\\alpha_i$ is separable over $K$.\n\\end{defi}\n\n\\begin{coro}(2.14)\\\\\nA finite extension is separable if and only if it is separably generated.\n\\end{coro}\n\n\\begin{lemma}(2.15)\\\\\nIf $K \\leq M \\leq L$ are finite extensions. Then $M \\leq L$, $K \\leq M$ are both separable if and only if $K \\leq L$ is separable. See example sheet.\n\\end{lemma}\n\n\\begin{eg}(2.16)\\\\\nLet $F$ be a finite field, $|F| = m$. The multiplicative group of order $n=m-1$ is cyclic. Take a generator $\\alpha$, then $F = F_p(\\alpha)$. The minimal polynomial of $\\alpha$ divides $t^n-1$ since $\\alpha^n=1$. We saw that this polynomial has distinct roots (all non-zero elements in $F$), so the minimal polynomial of $\\alpha$ is separable. Hence $F=F_p(\\alpha)$ is separable over $F_p$.\n\\end{eg}\n\n\\begin{thm} (2.17, Theorem of the primitive element)\\\\\nAny finite separable extension $K \\leq M$ is a simple extension, i.e. $M = K(\\alpha)$ for some $\\alpha$, called the \\emph{primitive element}.\n\n\\begin{proof}\nIf $K$ is a finite field, then $M$ is also finite. So we can take $K$ to be a generator of the multiplicative group of $M$ (which is cyclic).\n\nNow assume $K$ is an infinite field. Since $K \\leq M$ is a finite extension, $M = K(\\alpha_1,...,\\alpha_n)$ for some $\\alpha_i$. It's enough to show that any field $M=K(\\alpha,\\beta)$ with $\\beta$ separable over $K$ is of the form $K(\\gamma)$. Take $f(t)$ and $g(t)$ to be the minimal polynomials of $\\alpha$ and $\\beta$ over $K$. Let $L$ be the splitting field for $f(t) g(t)$ over $K(\\alpha,beta)$. The distinct zeros of $f(t)$ in $L$ are $\\alpha = \\alpha_1,...,\\alpha_a$, and of $g(t)$ are $\\beta = \\beta_1,...,\\beta_b$. By separability we know $b = \\deg g(t)$. Choose $\\lambda \\in K$ such that all $\\alpha_i + \\lambda \\beta_j$ are distinct (this is possible since $K$ is infinite). Now we set $\\gamma = \\alpha_\\lambda\\beta$ (remember $\\alpha$ is $\\alpha_1$ and $\\beta$ is $\\beta_1$). Let $F(t) = f (\\gamma -\\lambda t) \\in K(\\gamma)[t]$. We have $g(\\beta) = 0$. We have $g(\\beta) =0 $ and $F(\\beta) = f(\\alpha)=0$. Thus $F(t)$ and $g(t)$ have a common zero. Any other common zero would have to be $\\beta_j$ for some $j>1$. Bu then $F(\\beta_j) = f(\\alpha+\\lambda(\\beta-\\beta_j))$. By assumption, $\\alpha+\\lambda(\\beta-\\beta_j)$ is never an $\\alpha_i$, and so $F(\\beta_j) \\neq 0$.\n\nNow separability of $g(t)$ says that the linear factors are all distinct. So $(t-\\beta)$ is a highest common factor of $F(t)$ and $g(t)$ in $L[t]$. However, the minimal polynomial $h(t)$ of $\\beta$ over $K(\\gamma)$ then divides $F(t)$ and $g(t)$ in $K(\\gamma)[t]$, and hence in $L[t]$. This implies $h(t) = t-\\beta$, and so $\\beta \\in K(\\gamma)$. Therefore $\\alpha = \\gamma - \\lambda \\beta$ is also in $K(\\gamma)$. So $K(\\alpha,\\beta) \\leq K(\\gamma)$. The other direction is trivial.\n\\end{proof}\n\\end{thm}\n\n\\begin{eg}\nIn our example in Chapter 1 we have $\\Q \\leq \\Q(\\sqrt{2},i)$. We had intermediate subfields $\\Q(\\sqrt{2})$, $\\Q(i)$ and $\\Q(i\\sqrt{2})$. If we follow the procedure of the proof of $(2.17)$, $\\alpha = \\sqrt{2},\\beta = i$, $f(t) = t^2-2$, and $g(t) = t^2+1$, we consider some $\\sqrt{2}+\\lambda i$ where $\\pm \\sqrt{2} \\pm \\lambda i$ are all distinct, e.g. $\\lambda=1$. The proof shows that $\\Q(\\sqrt{2},i) =\\Q(\\sqrt{2}+i)$.\n\n\\end{eg}\n\n\\subsection{Trace and Norm}\nThis will also be used in number fields next term.\n\n\\begin{defi} (2.18)\\\\\nLet $K \\leq M$ be a finite field extension, and $\\alpha \\in M$. Multiplication by $\\alpha$ gives a $K$-linear map $\\theta_\\alpha: M \\to M$. The trace of $\\alpha$ over $K$, denoted $\\tr_{M/K} (\\alpha)$ is the trace of $\\theta_\\alpha$. The norm of $\\alpha$ over $K$, denoted $N_{M/K}(\\alpha)$ is the determinant of $\\theta_\\alpha$.\n\nNote; these are dependent on the field extension.\n\\end{defi}\n\n\\begin{thm} (2.19)\\\\\nWith the above notation, suppose $f_\\alpha(t) = t^s+a_{s-1}t^{s-1}+...+a_0$ is the minimal polynomial for $\\alpha$ over $K$. Let $r = |M:K(\\alpha)|$. Then the characteristic polynomial of $\\theta_\\alpha$ is $(f_\\alpha(t))^r$. (Note: $|M:K| = |M:K(\\alpha)| |K(\\alpha):K| = rs$), and $\\tr_{M/K} (\\alpha) = -ra_{s-1}$, $N_{M/K} (\\alpha) = ((-1)^s a_0)^r$.\n\\begin{proof}\nRegard $M$ as $K(\\alpha)$-vector space with basis $1=\\beta_1,...,\\beta_r$. Now take the $K$-vector space basis $1,\\alpha,\\alpha^2,...,\\alpha^{s-1}$ of $K(\\alpha)$. So $1,\\alpha,\\alpha^2,...,\\alpha^{s-1},\\beta_2,\\beta_2\\alpha,...,\\beta_2\\alpha^{s-1},...$ is $K$-vector space basis for $M$. Multiplication by $\\alpha$ in $K(\\alpha)$ is represented by matrix\n\\begin{equation*}\n\\begin{aligned}\nA = \\begin{bmatrix}\n0 & & & ... & -a_0\\\\\n1 &0& & ... & -a_1\\\\\n0 &1& & ... & -a_2\\\\\n..&.&1& ... & ....\\\\\n..&.&.& 1   & -a_{s-1}\n\\end{bmatrix}\n\\end{aligned}\n\\end{equation*}\nMultiplication by $\\alpha$ in $M$ is represented by the $rs\\times rs$ matrix with blocks of $A$ on its diagonal and $0$ elsewhere, whose characteristic polynomial is $(f_\\alpha(t))^r$. Look at terms of this characteristic polynomial to get trace and norm.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (2.20)\\\\\nLet $K \\leq M$ be a finite separable field extension, and $|M:K| =n$, $\\alpha \\in M$. Let $K \\leq L$ be large enough so that there are $n$ distinct $K$-homomorphisms (why?) $\\sigma_1,...,\\sigma_n: M \\to L$, then the characteristic polynomial of $\\theta_\\alpha :M \\to M$ (multiplication by $\\alpha$) is\n\\begin{equation*}\n\\begin{aligned}\n\\prod_{i=1}^n (t-\\sigma_i(\\alpha))\n\\end{aligned}\n\\end{equation*}\nso $\\tr_{M/K} (\\alpha) = \\sum_{i=1}^n \\sigma_i (\\alpha)$ and $N_{M/K} = \\prod_{i=1}^n \\sigma_i(\\alpha)$.\n\\begin{proof}\n\\begin{equation*}\n\\begin{aligned}\nf_\\alpha(t) &= (t-\\alpha_1)...(t-\\alpha_s)\\\\\n&= t^s + a_{s-1}t^{s-1}+...+a_0\n\\end{aligned}\n\\end{equation*}\nis the minimal polynomial of $\\alpha$ over $K$ in $L[t]$, where $L$ is large enough that $f_\\alpha(t)$ splits in $L$ (???). There are $s$ $K$-homomorphisms $K[\\alpha] \\to L$, corresponding to maps sending $\\alpha$ to $\\alpha_i$. Each of those extends in $|M:K(\\alpha)|$ ways to give $K$-homomorphisms $M \\to L$ (separability and (2.9)). However, each such extension of a map sending $\\alpha \\to \\alpha_i$ still sends $\\alpha \\to \\alpha_i$. Set $r = |L:K(\\alpha)|$. Thus there are $r$ maps sending $\\alpha \\to \\alpha_i$ for each $i$. Thus if the $n(=rs)$ distinct $K$-homomorphisms $M \\to L$ are $\\sigma_1,...,\\sigma_n$, then\n\\begin{equation*}\n\\begin{aligned}\n\\sum_{i=1}^n \\sigma_i(\\alpha) = r(\\alpha_1+...+\\alpha_s) =-ra_{s-1} = \\tr_{M/K}(\\alpha)\n\\end{aligned}\n\\end{equation*}\nsince the sum of roots of $f_\\alpha(t)$ is $-a_{s-1}$, and\n\\begin{equation*}\n\\begin{aligned}\n\\prod_{i=1}^n \\sigma_i(\\alpha) = ((-1)^s a_0)^r = N_{M/K}(\\alpha)\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{thm}\n\n--- lecture 10---\n\nFrom (2.19), the characteristic polynomial of $\\theta_\\alpha$ is $(f_\\alpha(t))^r$. $f_\\alpha(t)$ is the minimal polynomial of $\\alpha$ over $K$, $r=|M:K(\\alpha)|$. Characteristic polynomial is $(t-\\alpha_1)^r ... (t-\\alpha_s)^r$ where $\\alpha_1,...,\\alpha_s$ are the roots of $f_\\alpha(t)$ in $L$ if $L$ is large enough. And we saw that those roots are $\\sigma_1(\\alpha),...,\\sigma_n(\\alpha)$, so characteristic polynomial is\n\\begin{equation*}\n\\begin{aligned}\n\\prod_{i=1}^n (t-\\sigma_i(\\alpha))\n\\end{aligned}\n\\end{equation*}\n\n\\begin{thm} (2.21)\\\\\nLet $K \\leq M$ be a finite separable extension. Then we define a $K$-bilinear form $T:M \\times M \\to K$ by $(x,y) \\to \\tr_{M/K} (xy)$, where $xy$ is the product in $M$. Then this is non-degenerate. In particular, the $K$-linear map $\\tr_{M/K}: M \\to K$ is non-zero. So it's surjective.\n\\end{thm}\n\n\\begin{rem}\nIf $K \\leq M$ is a finite extension which is not separable, then $\\tr_{M/K}:M \\to K$ is always zero. And so $T:M \\times M \\to K$ is degenerate (see example sheet).\n\\end{rem}\n\n\\begin{proof}\nBy theorem (2.17), separability implies that $M=K(\\alpha)$ for some $\\alpha$. We have a $K$-basis $1,\\alpha,\\alpha^2,...,\\alpha^{n-1}$ of $K(\\alpha)$ wher $n=|M:K|$. The $K$-bilinear form $T$ is represented by matrix\n\\begin{equation*}\n\\begin{aligned}\nA = \\begin{bmatrix}\n\\tr_{M/K}(1) & \\tr_{M/K}(\\alpha) & ...\\\\\n\\tr_{M/K}(\\alpha) & \\tr_{M/K}(\\alpha^2) & ...\\\\\n... & ... & ...\n\\end{bmatrix}\n\\end{aligned}\n\\end{equation*}\nLet $L$ be a splitting field of the minimal polynomial $f(t)$ of $\\alpha$ over $K$. Then $f_\\alpha(t) = (t-\\alpha_1) ... (t-\\alpha_n)$, with $\\alpha_1,...,\\alpha_n \\in L$. The entries in $A$ are of the form $\\tr_{M/K} (\\alpha^l)$ which is $\\alpha_1^l+...+\\alpha_n^l$ by (2.20).\n\nNow consider $\\triangle = \\prod_{i < j} (\\alpha_i - \\alpha_j)$, the Van der Monde determinant, is \n\\begin{equation*}\n\\begin{aligned}\n\\begin{vmatrix}\n1 & 1 & 1 & ... & 1\\\\\n\\alpha_1 & \\alpha_2 & ... & ... & ...\\\\\n\\alpha_1^2 & \\alpha_2^2 & ... & ... & ...\\\\\n... & ... & ... & ... & ...\\\\\n\\alpha_1^{n-1} & \\alpha_2^{n-1} & ... & ... & ...\n\\end{vmatrix}\n\\end{aligned}\n\\end{equation*}\nNow consider $VV^T$ and observe that it is $A$. Thus $0 \\neq D = \\triangle^2 = |VV^T| = |A|$. Thus $A$ is non-singular, and therefore the bilinear form $T$ is non-degenerate.\n\\end{proof}\n\n\\begin{rem}\nWe'll meet $D$ again shortly. It is the \\emph{discriminant} of the polynomial $f_\\alpha(t)$.\n\\end{rem}\n\n\\subsection{Normal extensions}\nWe met the definition in chapter 1: recall\n\n\\begin{defi} (1.25)\\\\\nAn extension $K \\leq L$ is \\emph{normal} if for every $\\alpha \\in L$, the minimal polynomial $f_n(t)$ of $\\alpha$ over $K$ splits over $L$.\n\\end{defi}\n\nAlso, we stated a theorem, which we'll now prove:\n\\begin{thm} (1.26)\\\\\nLet $K \\leq M$ be a field extension. Then $K\\leq M$ is normal iff $M$ is the splitting field for some $f(t) \\in K[t]$, not necessarily irreducible.\n\\begin{proof}\nAssume $K \\leq M$ is normal. Pick $\\alpha_1,...,\\alpha_r \\in M$ so that $M = K(\\alpha_1,...,\\alpha_r)$. Let $f_{\\alpha_i} (t)$  be the minimal polynomial for $\\alpha_i$ over $K$. Let $f(t) = \\prod_{i=1}^r f_{\\alpha_i}(t)$. By normality, each $f_{\\alpha_i}(t)$ splits over $M$. Therefore their product does. Now $M$ is the splitting field of $f(t)$ over $K$, since if $\\beta_,...,\\beta_m$ are the roots of $f(t)$ Then $M=K(\\beta_1,...,\\beta_m)$.\n\nConversely, suppose $M$ is a splitting field for $f(t)$ over $K$. Thus $M = K(\\beta_1,...,\\beta_m)$ where $\\beta_j$ are the roots of $f(t)$ in $M$. Take $\\alpha \\in M$. Let $f_\\alpha (t)$ be the minimal polynomial of $\\alpha$ over $K$. Now take $M \\leq L$ be large enough so that $f_\\alpha(t)$ splits in $L$, and consider $K$-homomorphisms $\\phi:M \\to L$ with $\\phi(\\beta_j)$ is also a root of $f(t)$, and is therefore one of the $\\beta_j$. Injectivity of $K$-homomorphisms ((1.21)) implies that $\\phi$ permutes the $\\beta_j$'s. However, $M = K(\\beta_1,...,\\beta_m)$ and so $\\phi$ is determined by the images of the $\\beta_j$'s. Thus $\\phi(M) = M$. However if $\\alpha_i$ is a root of $f_\\alpha(t)$ in $L$, there is a $K$-homomorphism $K(\\alpha) \\to K(\\alpha_i) \\leq L$ by sending $\\alpha \\to \\alpha_i$. This extends (eg (2.10)) to a $K$-homomorphism $\\phi:M \\to L$ with $\\phi(\\alpha) = \\alpha_i$. But $\\phi(M) = M$. So $\\alpha_i \\in M$. Thus $M$ is normal over $K$.\n\\end{proof}\n\\end{thm}\n\n\\begin{rem}\nAs for separability, the property of 'normality' is equivalent to 'normally generated', i.e. we have $f \\leq L$ a finite extension is normal iff $L=K(\\alpha_1,...,\\alpha_r)$ with $f_{\\alpha_i}(t)$ splitting over $L$  (see example sheet).\n\\end{rem}\n\n\\begin{defi} (2.22)\\\\\nLet $K \\leq M$ be a finite field extension. Its $K-$automorphism group $\\Aut_K(M)$ is $\\{\\phi: \\phi \\text{ K-homomorphism } M \\to M\\}$.\n\\end{defi}\n\nFrom (1.22), we know that such $K$-homomorphisms are isomorphisms, of thus have inverses. Composition gives a group operation as a result.\n\n\\begin{lemma} (2.23)\\\\\n$\\Aut_K(M) \\leq |M:K|$. The proof is in (2.10).\n\\end{lemma}\n\n\\begin{thm} (2.24)\\\\\nLet $K \\leq M$ be a finite field extension. $|\\Aut_K(M)| = |M:K|$ iff the extension is both normal and separable.\n\\end{thm}\n\n\\begin{defi}(2.25)\\\\\nA finite field extension that is normal and separable is a \\emph{Galois extension}.\n\\end{defi}\n\n\\begin{defi}(2.26)\\\\\nLet $K \\leq M$ be a Galois extension. Then the $K$-automorphism group of $M$ is the \\emph{Galois group of $M$ over $K$}, denoted by $\\Gal(M/K)$.\n\\end{defi}\n\n\\begin{rem}\nSome authors use 'Galois group' for the automorphism group even when the field extension is not Galois.\n\\end{rem}\n\n\\begin{proof} (of 2.24)\\\\\nSuppose $|\\Aut_K(M)| = |M:K| = n$. Let $L$ be large enough, containing $M$. Then $n$ distinct $K$-homomorphisms $\\phi: M \\to M \\leq L$ give us $n$ $K-$homomorphisms $\\phi:M \\to L$. And (2.12) says that $M$ is separable over $K$. For normality, pick $\\alpha \\in M$ with minimal polynomial $f_\\alpha(t)$ over $K$. Take $M=K(\\alpha_1,...,\\alpha_m)$ as in the proof of (2.10), with $\\alpha = \\alpha_1$ and $L=M$. We only get $|M:K|$ extensions of the inclusion $K \\to M$ if each inequality is an equality.\n\nIn particular, we need the number of $K$-homomorphisms $K(\\alpha_1) \\to M$ to be $|K(\\alpha_1):K|$. But then (2.6) says we have $|K(\\alpha):K|$ distinct roots of $f_\\alpha(t)$ in $M$. Thus $f_\\alpha(t)$ splits over $M$.\n\nConversely, suppose $K \\leq m$ is separable and normal. Then for $K \\leq M \\leq L$, with $L$ large enough, separability implies there are $|M:K|$ $K-$homomorphisms $\\phi: M \\to L$ by (2.12). However, $K \\leq M$ is normal implies it is the splitting field for some polynomial $f(t) \\in K[t]$ by (1.26), and thus $M = K(\\alpha_1,...,\\alpha_n)$, where $f(t) = (t-\\alpha_1)...(t-\\alpha_n)$. Note that $\\phi(\\alpha_j)$ is also a root of $\\phi(f(t)) = f(t)$, and is therefore one of the $\\alpha_j$ (this also explains a similar deduction for 2.23 I think). Thus $\\phi(M) = M$. Thus we have $|M:K|$ $K$-homomorphisms $\\phi:M \\to M$.\n\\end{proof}\n\n\\begin{rem} (2.27)\\\\\nIn the previous proof we have shown that if $K \\leq M \\leq L$, and $\\phi: M \\to L$ is a $K$-homomorphism, and $K \\leq M$ is normal, then $\\phi(M) = M$.\n\\end{rem}\n\n\\begin{eg}\n$\\bullet$ Consider $\\Q \\leq \\Q(\\sqrt{2},i)$, which is Galois. $\\Gal(\\Q(\\sqrt{2},i/\\Q)$ has $4$ elements : $\\sigma : \\sqrt{2} to \\pm \\sqrt{2}$, $i \\to \\pm i$ $\\cong C_2 \\times C_2$. All non-identity elements have order 2.\n\n$\\bullet$ $f(t) = t^3-2$. The splitting field over $\\Q$ is $\\Q(\\sqrt[3]{2},\\omega$, where $\\omega$ is primitive cube roof of $1$. Thus $\\Q \\leq \\Q(\\sqrt[3]{2} \\omega$ is Galois, and $|\\Q(\\sqrt[3]{2},\\omega):\\Q| = 6$. The Galois group contains $\\sigma_1:\\sqrt[3]{2} \\to \\sqrt[3]{2}, \\omega \\to \\omega$, the identity,  and $\\sqrt[3]{2} \\to \\omega \\sqrt[3]{2}, \\omega \\to \\omega$ of order $3$, $\\sqrt[3]{2} \\to \\sqrt[3]{2}, \\omega \\to \\omega^2$ (complex conjugation, order 2), and some composition of those. We check that this is actually the Dihedral group $D_6 \\cong S_3$.\n\\end{eg}\n\n\\newpage\n\n\\section{Fundamental Theorem of Galois Theory, Artin's Theorem, and Galois Theory of Polynomials and of Finite Fields}\n\n\\begin{defi} (3.1)\\\\\nLet $K \\leq L$ be a field extension, $H \\leq \\Aut_K(L)$. The fixed field of $H$ \n\\begin{equation*}\n\\begin{aligned}\nL^H = \\{\\alpha \\in L, \\sigma(\\alpha) = \\alpha \\text{ for all } \\sigma \\in H\\}\n\\end{aligned}\n\\end{equation*}\nCheck: it is a field, and $K \\leq L^H \\leq L$.\n\\end{defi}\n\n\\begin{defi} (3.2, Fundamental Theorem of Galois Theory)\\\\\nLet $K \\leq L$ be a finite Galois extension. Then\\\\\n$\\bullet$ There is a 1-1 correspondence between intermediate subfields $K \\leq M \\leq L$ and subgroups $H$ of the Galois group $\\Gal(L/K)$, by sending $M$ to $\\Aut_M(L)$, or sending $H$ to $L^H$ backwards. This is known as the \\emph{Galois correspondence}.\\\\\n$\\bullet$ $H$ is a normal subgroup of $\\Gal(L / K)$ iff $K \\leq L^H$ is normal iff $K \\leq L^H$ is Galois.\\\\\n$\\bullet$ If $H \\triangleleft \\Gal(L/K)$ then the map $\\theta:\\Gal(L/K) \\to Gal(L^H /K)$ given by restriction to $L^H$ is a surjective group homomorphism with kernel $H$.\n\\end{defi}\n\n\\begin{rem}\nObserve that $M \\leq L$ is Galois and so we could have written $\\Gal(L/M)$ instead of $\\Aut_M(L)$ in the first part of the theorem. To see this, separability follows from (2.15); for normality, if $\\alpha \\in L$, the minimal polynomial of $\\alpha$ over $M$ divides the minimal polynomial of $\\alpha$ over $K$. But the latter splits over $L$.\n\nIf $K \\leq M$ is normal, then remark (2.27) says that if $\\sigma:L \\to L$ then $\\sigma(M) = M$ and so we can talk about the restriction of $\\alpha$ to $M$, giving an automorphism of $M$.\n\\end{rem}\n\n\\begin{eg}\n$\\Q \\leq \\Q(\\sqrt{2},i)$. We saw in chapter 1 that the lattices of intermediate fields and subgroups $\\Gal(\\Q(\\sqrt{2},i) / \\Q) \\cong C_2 \\times C_2$ are abelian. All subgroups are normal and intermediate subfields are also normal extensions of $\\Q$.\n\\end{eg}\n\n\\begin{eg}\n$\\Q \\leq \\Q(\\sqrt[3]{2},\\omega)$. The intermediate subfields are $\\Q(\\omega),\\Q(\\sqrt[3]{2})$, $\\Q(\\omega\\sqrt[3]{2})$, $\\Q(\\omega^2\\sqrt[3]{2})$. Consider their corresponding subgroups of $\\Gal(\\Q(\\sqrt[3]{2},\\omega)/\\Q) \\cong D_6$ which is not abelian, and has a non-abelian subgroup. The subgroup $H$ of order 3 is normal, but those of order $2$ are not. So we get $\\Q \\leq \\Q(\\omega)$ is normal $\\leftrightarrow$ $H$ of order 3, and we get a homomorphism $\\Gal(\\Q(\\sqrt[3]{2},\\omega)/\\Q) \\to \\Gal(\\Q(\\omega)/\\Q)$, i.e. $D_6 \\to C_2$, generated by conjugation, which has kernel $H$.\n\\end{eg}\n\n\\begin{thm} (3.3, Artin's Theorem)\\\\\nLet $K \\leq l$ be a field extension and $H$ is a finite subgroup of $\\Aut_K(L)$. Let $M = L^H$. Then $M \\leq L$ is a finite Galois extension, and $H = \\Gal(L/M)$.\n\nThis is a more general theorem, and implies some of the Galois correspondence: by $H \\to L^H \\to G\\Gal(L/L^H)$ we get back to $H$.\n\\begin{proof}\nTake $\\alpha \\in L$. The first step is to show that $|M(\\alpha) :M | \\leq |H|$.\n\nLet $\\{\\alpha_1,...,\\alpha_n\\} = \\{\\phi(\\alpha):\\phi \\in H\\}$ all distinct. Define $g(t) = \\prod_{i=1}^n (t-\\alpha_i)$. Each $\\phi$ induces a homomorphism $L[t] \\to L[t]$ that sends $g(t)$ to itself, since $\\phi$ is permuting the $\\alpha_i$. So the coefficients of $g(t)$ are fixed by all $\\phi \\in H$, and thus they lie in $L^H = M$. Thus $g(t) \\in M[t]$. By definition, $g(\\alpha)=0$ since $\\alpha$ is one of the roots $\\alpha_i$. Hence the minimal polynomial $f_\\alpha(t)$ of $\\alpha$ over $M$ divides $g(t)$. Thus $|M(\\alpha):M| = \\deg f_\\alpha(t) \\leq \\deg g(t) \\leq |H|$. We've shown that $\\alpha$ is algebraic over $M$, and $f_\\alpha(t)$ is separable since $g(t)$ is. Hence $M \\leq L$ is a separable extension.\n\nThe next step is to show that $M\\leq L$ is a simple extension.\n\nPick $\\alpha \\in L$ with $|M(\\alpha):M|$ maximal. We'll show that $L = M(\\alpha)$. Suppose $\\beta \\in L$ is another element. Then $M \\leq M(\\alpha,\\beta)$ is finite and is generated separabaly, and hence is a finite separable extension. (2.12). By the primitive element theorem (2.17), $M(\\alpha,\\beta) = M(\\gamma)$ for some $\\gamma$. But $M \\leq M(\\alpha) \\leq M(\\gamma)$. By maximality we know $|M(\\alpha):M| \\geq |M(\\gamma):M|$, i.e. $M(\\alpha) = M(\\gamma)$. Thus $\\beta \\in M(\\gamma) = M(\\alpha)$, i.e. $L = M(\\alpha)$. \n\nFinally, $|L:M| = |M(\\alpha):M| \\leq |H|| \\leq |\\Aut_M(L)| \\leq |L:M|$ by (2.23). We must have equality throughout, and hence $|L:M| = |\\Aut_M(L)| = |H|$. Hence by (2.24) we have $M \\leq L$ is a finite Galois extension, and $H = \\Gal(L/M)$.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (3.4)\\\\\nLet $K \\leq L$ be a finite field extension. Then the following are equivalent:\\\\\n(i) $K \\leq L$ is Galois;\\\\\n(ii) $L^H = K$ when $H = \\Aut_K(L)$.\n\\begin{rem}\nThe theorem allows some authors yet another alternative for the definition of a Galois extension.\n\\end{rem}\n\n\\begin{proof}\n(i) $\\implies$ (ii): Let $M = L^H$ where $H = \\Aut_K(L)$. By (3.3) (Artin), $M \\leq L$ is a Galois extension, and $|L:M| = |\\Gal(L/M)|$ and $H=\\Gal(L/M)$. However if $K \\leq L$ is Galois then $|H| = |\\Aut_K(L)| = |L:K|$ by (2.24). Thus $|L:M| = |L:K|$ and so $M=K$.\n\nFor the other direction just apply (3.3).\n\\end{proof}\n\\end{thm}\n\n\\begin{proof} (of 3.2, the fundamental theorem)\\\\\n(i) Composing the maps $H \\to L^H$ and $M \\to \\Gal(L/M)$ gives $H \\to H$ by (3.3), $M \\to \\Gal(L/M) \\to L^H$ where $H = \\Gal(L/M)$ yields $M$ since $M \\leq L^H$ here $H = \\Gal(L/M)$ and $|L:L^H| = |H| = |\\Gal(L/M)| = |L:M|$ by (3.3) and (2.24). So $M=L^H$.\n\n(ii) Take $H \\leq \\Gal(L/K)$. Then $L^{\\phi H \\phi^{-1}} = \\phi(L^H)$ (think about this) when $\\phi \\in \\Gal(L/K)$. So by (i), $H$ is normal if and only if $\\phi(L^H) = L^H$. Set $M = L^H$. We'll show that $K \\leq M$ is normal iff $\\phi(M) = M$ for all $\\phi \\in \\Gal(L/K)$. $K \\leq M$ is normal $\\implies \\phi(M) = M$ is Remark 2 after the statement of (3.2).\n\nConversely, if $\\phi(M) = M$ for all $\\phi \\in \\Gal(L/K)$, we pick $\\alpha \\in M$ and $f_\\alpha(t)$ be its minimal polynomial over $K$. We take $\\beta$ as a root for $f_\\alpha(t)$ in $L$ (which is possible by normality). Then there is a $K$-homomorphism $K(\\alpha) \\cong K[t] / (f_\\alpha(t)) \\to K(\\beta) \\cong K[t] / (f_\\alpha(t)) \\leq L$, by sending $\\alpha \\to \\beta$. This extends to a $K$-homomorphism $\\phi:L \\to L$. However we are assuming $\\phi(M) = M$, and so $\\phi(\\alpha) = \\beta \\in M$. Thus $K \\leq M$ is normal.\n\nNote that $K\\leq L^H$ is separable since $K \\leq L^H \\leq L$ and $K \\leq L$ is separable.\n\n(iii) By remark 2 after the statement of (3.2), the restriction map $\\theta: \\Gal(L/K) \\to \\Gal(L^H/K)$ is defined. Surjectivity follows from being able to extend a $K$-homomorphism $L^H \\to L^H \\leq L$ to a $K$-homomorphism $L \\to L$. Clearly $H \\leq \\ker \\theta$. However $|L:K|/|\\ker \\theta| = |\\Gal(L/K)| / |\\ker \\theta| = |\\Gal(L^H/K)|$ by surjectivity of $\\theta$, which is then equal to $|L^H : K|$ since $K \\leq L^H$ is Galois, and is then equal to $|L:K| / |L:L^H|$ by tower law. So $|\\ker \\theta| = |L:L^H| = |\\Gal(L/L^H)| = |H|$ by (3.3). So $H = \\ker \\theta$.\n\n\\end{proof}\n\n\\subsection{Galois Groups of polynomials}\n\n\\begin{defi}\nLet $f(t)$ be a separable polynomial $\\in K[t]$, and let $K \\leq L$ with $L$ a splitting field for $f(t)$. Then the Galois group of $f(t)$ over $K$ $\\Gal(f) := \\Gal(L/K)$.\n\\end{defi}\n\nSince $L$ is a splitting field for $f(t)$, $L = K(\\alpha_1,...,\\alpha_n)$, where $\\alpha_1,...,\\alpha_n$ are the roots of $f(t)$ in $L$. Observe that if $\\phi \\in \\Gal(L/K)$ then it maps the set of roots of $f(t)$ to itself, i.e. $\\phi$ permutes the $\\alpha_i$. If $\\phi$ fixes each $\\alpha_i$, then it fixes $K$, therefore fixes every element in $L$. Thus $\\Gal(f)$ may be regarded as a permutation group of the roots, or as a subgroup of $S_n$.\n\n\\begin{lemma} (3.6)\\\\\nSuppose separable $f(t) = g_1(t) ... g_s(t)$ with $g_i(t)$ irreducible in $K[t]$ is a factorisation in $K[t$]. Then the orbits of $\\Gal(f)$ on the roots of $f(t)$ correspond to the factors $g_j(t)$: two roots are in the same orbit iff they are roots of the same $g_j(t)$.\n\nIn particular, if $f$ is irreducible in $K[t]$, there is only one orbit, i.e. $\\Gal(f)$ acts transitively on the roots of $f(t)$.\n\\begin{proof}\nLet $\\alpha_k,\\alpha_l$ be in the same orbit under $\\Gal(f)$. Then there is $\\phi \\in \\Gal(f)$ with $\\alpha_l = \\phi(\\alpha_k)$. But if $\\alpha_k$ is a root of $g_j(t)$, then $\\alpha_l=\\phi(\\alpha(k))$ is also a root of $g_j(t)$ (coefficients are in $K$, so are fixed by $\\phi$ -- this argument has been used many times before). Conversely, if $\\alpha_k,\\alpha_l$ are roots of $g_j(t)$, then $K(\\alpha_k) \\cong K[t] / g_j(t) \\cong K(\\alpha_l) \\leq L$. Let $\\phi_0$ takes $K(\\alpha_k)$ to $K(\\alpha_l)$. Then $\\phi_0$ extends to a $\\phi:L \\to L \\in \\Gal(L/K)$, whereas $\\phi_0(\\alpha_k) = \\alpha_l$. Thus $\\alpha_k,\\alpha_l$ are in the same orbit.\n\\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (3.7)\\\\\nThe transitive subgroups of $X_n$ for $n \\leq 5$ are\\\\\n$n=2$: $S_2 \\cong C_2$;\\\\\n$n=3$: $A_3 \\cong C_3$, $S_3$;\\\\\n$n=4$: $C_4,V_4,D_8,A_4,S_4$;\\\\\n$n=5$: $C_5,D_{10},H_{20},A_5,S_5$ where $H_{20}$ is the group generated by a 5-cycle and a 4-cycle.\n\nThe proof is an exercise.\n\\end{lemma}\n\n\\begin{lemma} (3.8)\\\\\nLet $p$ be a prime, and $f(t)$ irreducible in $\\Q[t]$ of degree $p$. Suppose $f(t)$ has exactly 2 non-real roots (one conjugate pair) in $\\C$. Then $\\Gal(f)$ over $\\Q$ $\\cong S_p$.\n\\begin{proof}\n$\\Gal(f)$ acts on the $p$ distinct roots of $f(t)$ in a splitting field $L$ of $f(t)$ (in $\\C$). By (3.6), the irreducibility of $f(t)$ tells us that $\\Gal(f)$ acts transitively on the $p$ roots. By Orbit-Stabilizer theorem, $p\\mid |\\Gal(f)|$. But $|\\Gal(f)| \\leq |S_p| = p!$. So $\\Gal(f)$ has a Sylow $p$-subgroup of order $p$ (by Lagrance $|\\Gal(f)| \\mid p!$, so $p^2 \\nmid |\\Gal(f)|$), necessarily cyclic, i.e .$\\Gal(f)$ contains a $p$-cycle. We've got exactly 2 non-real roots, so complex conjugation yields a transposition in $\\Gal(f)$. But from GRM we know the $p$-cycle and transposition generate the whole of $S_p$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{eg} (3.9)\\\\\nLet $f(t) = t^5 - 6t+3 \\in \\Q[t]$. Then we claim that $\\Gal(f) \\cong S_5$.\n\\begin{proof}\nFirst $f$ is irreducible by Eisenstein with $p=3$. We want to show that $f(t)$ has 3 real roots and 2 non-real roots, then we can apply (3.8).\n\nWe check $f(-2) = -17$, $f(-1) = 8$, $f(1) = -2$, $f(2) = 23$. So we have at least 3 real roots. Also, $f'(t) = 5t^4-6$ which has two real roots. So by Rolle's theorem $f(t)$ has at most 3 real roots. So $f(t)$ has exactly 3 real roots.\n\\end{proof}\n\\end{eg}\n\n\\begin{defi} (3.10)\\\\\nLet $f(t) \\in K[t]$ with distinct roots $\\alpha_1,...,\\alpha_n$ (in a spitting field (note that $f(t)$ is not necessarily irreducible). We set\n\\begin{equation*}\n\\begin{aligned}\n\\Delta = \\prod_{i \\leq j} (\\alpha_i - \\alpha_j)\n\\end{aligned}\n\\end{equation*}\nThen the discriminant $D =D(f)$ of $f$ is $\\Delta^2 = \\prod_{i<j} (\\alpha_i-\\alpha_j)^2 = (-1)^{n(n-1)/2} \\prod_{i \\neq j} (\\alpha_i - \\alpha_j)$.\n\\end{defi}\n\nNote that we've already met the above in the proof of (2.21).\n\n\\begin{lemma} (3.11)\\\\\nLet $f(t)$ be separable in $K[t]$ of degree $n$ with $char K \\neq 2$. Then $\\Gal(f) \\leq A_n$ if and only if $D(f)$ is a square in $K$.\n\\begin{proof}\nLet $L$ be a splitting field of $f(t)$ over $K$. Then $D(f) \\neq 0$ and is fixed by all elements of $G =\\Gal(L/K)$ as the latter permutes the roots.\n\nThus $D \\in K$, since $L^G = K$ (by Galois correspondence).\n\nOn the other hand, if $\\sigma \\in G$ then $\\sigma(\\Delta) = (sgn \\sigma) \\Delta$, where we regard $G$ as a subgroup of $S_n$, and the signature of $\\sigma = \\pm 1$ if $\\sigma$ is even/odd (this is where we need $char K \\neq 2$). If $G \\leq A_n$ we get that $\\Delta$ is fixed by all $\\sigma \\in G$. Thus $\\Delta \\in K = L^G$. Otherwise, we get $\\sigma(\\Delta) = -\\Delta$ if $\\sigma$ is odd. So $\\Delta \\not \\in K = L^G$.\n\nNote that if $D$ does have square roots, they must be $\\pm \\Delta$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{eg} (3.12)\\\\\n$n=2$: $f(t) = t^2 + bt + c = (t-\\alpha_1)(t-\\alpha_2)$, and $D(f) = (\\alpha_1-\\alpha_2)^2 = (\\alpha_1+\\alpha_2)^2-4\\alpha_1\\alpha_2 = b^2-4c$.\\\\\n$n=3$: $f(t) = t^3 + ct +d$, $D(f) = -4c^3-27d^2$ (without proof here).\n\nNote that any general monic cubic $g(t)$ can be put into this form by a suitable subtitution $f(t) = g(t_1+\\lambda)$. Note that $D(f) = D(g)$.\n\nNow consider $f(t) = t^3 - t - 1 \\in \\Q[t]$, which is irreducible in $\\Z[t]$ (as it's not reducible mod 2). Now $D(f) = -23$ is not a square in $\\Q$, so $\\Gal(f) \\cong S_3$.\n\nNow let $f(t) = t^3 - 3t - 1 \\in \\Q[t]$, which is also irreducible by the same reason. Now $D(f) = 81$ is a square. So $\\Gal(f) \\cong A_3 \\cong C_3$.\n\\end{eg}\n\nIrreducible quartics: we saw that the possible Galois groups are $C_4,V_4,D_8,A_4$ or $S_4$. Those that are subgroups of $A_4$ are $V_4$ and $A_4$. From looking at the discriminant one gets information as to whether the group is one of  those two or the other three.\n\nWe need further methods to pin down which group we are dealing with.\n\n\\begin{thm} (3.13, mod $p$ reduction)\\\\\nLet $f(t) \\in \\Z[t]$ be monic of degree $n$ with $n$ distinct roots in a splitting field. Let $p$ be a prime such that $\\bar{f}(t)$, the reduction of $f(t)$ mod $p$, also has $n$ distinct roots in a splitting field (of char $p$).\\\\\nLet $\\bar{f}(t) = \\bar{g}_1(t) ... \\bar{g}_s(t)$ be the factorisation into irreducible in $\\F_p[t]$, with $n_j = \\deg \\bar{g}_j(t)$. Then $\\Gal(\\bar{f}) \\hookrightarrow \\Gal(f)$ (embeds into), and has an element of cycle type $(n_1,...,n_s)$.\n\n\\begin{rem}\n\\begin{proof}\nI'll talk about last line once we've thought about Galois groups of finite fields. The foil that $\\Gal(\\bar{f}) \\hookrightarrow \\Gal(f)$ is from Number Fields (Look at Tony Scholl's teaching page on Galois).\n\\end{proof}\n\\end{rem}\n\\end{thm}\n\n\\begin{eg}\nLet $f(t) = t^4 + dt + e$. Now $D(f) = -27d^4+256e^3$ (not proved here). If $f(t) = t^4-t-1$ irreducible (since it's irreducible mod 2), then $D(f)=-283$ is not a square in $\\Q$. Now if we consider mod $7$, $\\bar{f}(t) = t^4 - t - 1 = (t+4)(t^3+3t^2+2t+5) \\pmod 7$, and the second factor is irreducible mod 7 (no roots). By (3.13), $\\Gal(f)$ contains an element of cycle type $(1,3)$, i.e. a $3$-cycle. We deduce that $\\Gal(f) \\cong S_4$ as the other 2 possibilities that contain an odd permutation do not contain $3$-cycles.\n\\end{eg}\n\n\\subsection{Galois Theory of Finite Fields}\nRecall what we already know from chapter 1.\n\nFrom (1.27), a finite field $\\F$ is of characteristic $p>0$, $p$ necessarily prime, and $|\\F| = p^r$ for some $r$. Also, the multiplicative group of $\\F$ is cyclic (1.28). It is a splitting field for $t^n-1$ over $\\F_p$ where $n = p^r-1$. By the uniqueness of splitting fields (1.24), this is unique up to isomorphism. Note that we could also describe $\\F$ as the splitting field of $t^{p^r}-1$ over $\\F_p$.\n\nWhat we haven't shown yet is that for any $p^r$ there is a field $\\F$ with $|\\F| = p^r$.\n\n\\begin{defi} (3.15)\\\\\nLet $\\F$ be a finite field of characteristic $p$. Then the Frobenius automorphism of $\\F$ is $\\phi:\\F \\to \\F$ by $\\alpha \\to \\alpha^p$ (some authors use $\\Phi$).\n\\end{defi}\n\n\\begin{rem}\n$(\\alpha+\\beta)^p = \\alpha^p + \\beta^p$ since all other terms in binomial expansion is divisible by $p$. $\\F_p$ is fixed under this, and this is a $\\F_p$ automorphism.\n\nSince $t^{p^r}-t$ splits as a product of distinct linear factors $(t-x)$ in $F$ we have that $\\F_p \\leq \\F$ is a Galois extension. And so we consider $\\Gal(\\F/\\F_p) = G$. It is of order $r$ since $|\\F:\\F_p| = r$.\n\\end{rem}\n\n\\begin{thm} (3.16, Galois groups of finite fields)\\\\\nLet $\\F$ be a finite field with $|\\F| = p^r$. Then $\\F_p \\leq \\F$ is a Galois extension, with $\\Gal(\\F/\\F_p) = C_r$ cyclic group with the Frobenius automorphism $\\phi$ as generator.\n\\begin{proof}\nIt remains to show that the order of Frobenius automorphism is $r$. Suppose $\\phi^s = e$ the identity. Then $\\alpha^{p^s} = \\alpha$ for all $\\alpha \\in \\F$. But $t^{p^s}-t$ has at most $p^s$ roots in $\\F$, so we deduce that $s \\geq r$. Also note that $\\phi^r$ is the identity, since $\\alpha^{p^r} = \\alpha$ for all $\\alpha \\in \\F$. So $s=r$.\n\\end{proof}\n\\end{thm}\n\nNow apply the fundamental theorem (3.2), we have correspondence between intermediate fields $\\F_p \\leq M \\leq F$ and subgroups $H \\leq G$, where $G = \\Gal(\\F/\\F_p)$ is cyclic. But we know all about subgroups of a cyclic group with generator $\\phi$ and order $r$: there is exactly one subgroup of order $s$ for each factor $s$ of $r$, and is generated by $\\phi^{r/s}$. The corresponding intermediate fields are the fixed fields $\\F^{<\\phi^{r/s}>}$ and $|\\F:\\F^{<\\phi^{r/s}>}| = s$. By Tower law, $|\\F^{<\\phi^{r/s}>}:\\F_p| = r/s$.\n\nObserve that all subgroups of cyclic groups are normal, and therefore all intermediate fields are normal extensions of $\\F_p$ (3.2(ii)).\n\n(3.2)(iii) then shows that $\\Gal(\\F^{<\\phi^{r/s}>}/\\F_p) \\cong \\Gal(\\F/\\F_p) / H$ where $H = <\\phi^{r/s}>$.\n\n\\begin{coro} (3.17)\\\\\nLet $\\F_p \\leq M \\leq \\F$ be finite fields. Then $\\Gal(\\F/M)$ is cyclic, generated by $\\phi^u$ where $\\phi$ is Frobenius map, and $|M| = p^u$ and $M$ is the fixed field of $<\\phi^u>$.\n\\begin{proof}\nSet $u=r/s$.\n\\end{proof}\n\\end{coro}\n\n\\begin{thm} (3.18,Existence of finite fields)\\\\\nLet $p$ be a prime, $u \\geq 1$. Then there is a field of order $p^i$, unique up to isomorphism.\n\\begin{proof}\nConsider the splitting field of $L$ of $f(t) = t^{p^u}-t$ over $\\F_p$. It is a finite Galois extension $\\F_p \\leq L$, however the roots of $f(t)$ form a field, and is the fixed field of $\\phi^u$. Thus set $L=\\F$, and $|\\F:\\F_p| = u$.\n\\end{proof}\n\\end{thm}\n\nRemark about mod $p$ reduction (3.13): You'll discover in number fields that $\\Gal(\\bar{f}) \\hookrightarrow \\Gal(f)$ if $f(t) \\in \\Z[t]$. We factorised $\\bar{f}(t) = \\bar{g}_1(t)...\\bar{g}_s(t)$ as product of irreducibles. We know from (3.6) that the orbits of $\\Gal(\\bar{f})$ correspond to the factorisation. We know $\\Gal(\\bar{f})$ is cyclic generated by the Frobenius map, which must have cyclic type $(n_1,...,n_s)$ where $n_j = \\deg \\bar{g}_j(t)$.\n\n\\newpage\n\n\\section{Cyclotomic and Kummer extensions, cubis and quartics, solution by radicals}\n\\subsection{Cyclotomic extensions}\n\\begin{defi} (4.1)\\\\\nSuppose $Char k = 0$ or $p$ prime where $p \\nmid m$. The $m$th cyclotomic extension of $K$ is the splitting field $L$ of $t^m-1$.\n\\end{defi}\n\n\\begin{rem}\nIf we take $f'(t)$ we'll find that $f'(t) = mt^{m-1}$ so they do not have common zeros, so $f(t)$ is separable. So $f(t)$ has distinct roots, the $m$th roots of unity, which form a finite subgroup $\\mu_m$ of $L^*$. Hence by  (1.28) a cyclic group $<\\xi>$. Thus $L = K(\\xi)$ is a simple extension.\n\\end{rem}\n\n\\begin{defi} (4.2)\\\\\nAn element $\\xi \\in \\mu_mM$ is a primitive $m$th root of unity if $\\mu_m = <\\xi>$. Choosing a positive $m$th root of unity determines $\\mu_m \\to \\Z/m\\Z$ an isomorphism.\n\\end{defi}\n\nNote that $\\xi$ is a generator of $\\mu_m$ iff $(i,m) = 1$, and so the primitive $m$th roots of unity correspond to elements of $(\\Z/m\\Z)^*$, the unit group of $\\Z/m\\Z$.\n\nNow consider Galois groups of cyclotomic extensions. We'll see they must be abelian. Observe $f(t) = t^{m}-1$ is separable and so the extension $K \\leq L$ is Galois. Let $G=\\Gal(L/K)$. An element $\\sigma \\in G$ sends a primitive $m$th root of unity $\\xi$ to a primitive with root of unity where $(i,m) = 1$. Then $\\xi \\to \\xi^i$ determines a $K$-homomoprhism $K(\\xi) \\to K(\\xi)$, or $L \\to L$, by $\\xi \\to \\xi^i$. Thus we've got an injective map.\n\n\\begin{defi} (4.3)\\\\\nLet $\\theta:G \\to (\\Z/m\\Z)^*$. This is a group homomorphism: if $\\sigma(\\xi) = \\xi^i$, $\\phi(\\xi) = \\xi^j$, then $(\\sigma\\phi)(\\xi) = \\sigma(\\xi^j) = \\xi^{ij}$. Thus $G$ is abelian. Thus we may regard $G$ as a subgroup of $(\\Z/m\\Z)^*$ by this embedding. \n\\end{defi}\n\n\\begin{defi} (4.4)\\\\\nThe $m$th cyclotomic polynomial is\n\\begin{equation*}\n\\begin{aligned}\n\\Phi_m(t) = \\prod_{i \\in (\\Z/m\\Z)^*} (t-\\xi^i)\n\\end{aligned}\n\\end{equation*}\nthe polynomial of the linear factors of $t^m-1$ corresponding to the primitive $m$th roots of unity.\n\\end{defi}\n\n\\begin{rem}\n$f(t) = t^m-1 = \\prod_{i \\in \\Z/m\\Z} (t-\\xi^i) = \\prod_{d| m} \\Phi_d(t)$.\n\\end{rem}\n\nFor example, take $K=\\Q$, we have $\\Phi_1(t) = t-1$, $\\Phi_2(t) = t+1$, $\\Phi_3(t) = t^2+t+1$, $\\Phi_4(t) = t^2+1$, $\\Phi_8(t) = t^4+1$. since $t^8-1 = (t-1)(t+1)(t^2+1)(t^4+1)$.\n\n\\begin{lemma}(4.5)\\\\\n$\\Phi_m(t) \\in \\Z[t]$ if $Char K = 0$ (with $Q \\hookrightarrow K$ a prime subfield), $\\Phi_m(t) \\in \\F_p[t]$ if $Char K = p$ (with $\\F_p \\hookrightarrow K$ a prime subfield).\\\\\nIf $CharK = p>0$ we deduce by division that $\\Phi_m(t) \\in \\F_p[t]$.\n\\end{lemma}\n\n\\begin{lemma} (4.6)\\\\\nThe homomorphism, $\\theta: G \\to (\\Z/m\\Z)^*$ defined in (4.3) is an isomorphism if and only if $\\Phi_m(t)$ is irreducible.\n\\begin{proof}\nWe know from (3.6), that the orbit of $G = \\Gal(L/K)$ correspond to the factorisation of $f(t)$ in $K[t]$. In particular, the primitive $m$th root of unity form one orbit if and only if $\\Phi_n(t)$ is irreducible. In particular, the primitive $m$th roots of unity form one orbit iff $\\Phi_m(t)$ is irreducible. Then $\\theta$ is surjective iff $\\Phi_m(t)$ is irreducible.\n\\end{proof}\n\\end{lemma}\n\n\\begin{thm} (4.7)\\\\\nLet $L$ be the $m$th cyclotomic extension of finite field $\\F =\\F_q$, where $q = p^u$.\\\\\nThen the Galois group $G = \\Gal(L/\\F)$ is isomorphic to the cyclic subgroup of $(\\Z/m\\Z)^*$ genrated by $q$.\n\\begin{proof}\nWe now from (3.17) that $G$ is generated by $\\alpha \\to \\alpha^{p^u} = \\alpha^q$. So $\\theta(G) = <q> \\leq (\\Z/m\\Z)^*$.\n\\end{proof}\n\\end{thm}\n\n\\begin{rem}\nThus if $(\\Z/m\\Z)^*$ is not cyclic then $\\theta$ is not surjective for any finite field $\\F$ and $\\Phi_m(t)$ is reducible over $\\F$.\n\\end{rem}\n\n\\begin{eg}\nConsider $\\F=\\F_3$, $\\Phi_8(t) = t^4+1 = (t^2+t-1)(t^2-t-1)$. So $t^8-1$ factorises as a product of linear and quadratic polynomials mod $3$. So the splitting field $L=\\F_9$ is the unique field of order $9$ whose multiplicative group is cyclic $C_8$.\\\\\nNote $(\\Z/8\\Z)^* = \\{1,3,5,7\\} \\cong C_2 \\times C_2$.\n\nNote that $\\Gal(L/\\F_3)$ is cyclic of order 2, so the map $\\theta:\\Gal(L/K) \\hookrightarrow (\\Z/m\\Z)^*$ is definitely not surjective, and we saw that $\\Phi_8(t)$ is reducible.\n\\end{eg}\n\n\\begin{thm} (4.8)\\\\\nFor all $m>0$, $\\Phi_m(t)$ is irreducible in $\\Z[t]$ and hence in $\\Q[t]$. Thus $\\theta$ in (4.2) is an isomorphism and thus $\\Gal(\\Q(\\xi)/\\Q) \\cong (\\Z/m\\Z)^*$ where $\\xi$ is the primitive $m$th root of unity.\n\\begin{rem}\nWe already know this when $m=p$ by substitution and Eisenstein.\n\\end{rem}\n\\begin{proof}\n(4.5) implies irreducibility corresponds to surjectivity of $\\theta$. So it's left to show that $\\Phi_m(t)$ is irreducible in $\\Z[t]$. Suppose otherwise, that $\\Phi_m(t) = g(t) h(t)$ in $\\Z[t]$, with $g(t)$ irreducible, monic and $\\deg g(t) \\lneq \\deg \\Phi_m(t)$. Let $\\Q \\leq L$ be the $m$th cyclotomic extension, and $\\xi$ be a root of $g(t)$, $\\xi$ primitive $m$th root of $1$.\n\nWe claim that if $p \\nmid m$, $p$ is prime, then $\\xi^p$ is also a root of $g(t)$ in $L$.\\\\\n$\\bullet$ Proof of claim: suppose not. Then $\\xi^p$ is also a primitive $m$th root of 1, since $p \\nmid m$, is a root of $\\Phi_m(t)$. Our supposition implies that $\\xi^p$ is actually a root of $h(t)$. Define $r(t) = h(t^p)$. Then $r(\\xi) = 0$. But $g(t)$ is the minimal polynomial of $\\xi$ over $\\Q$, and so $g(t) \\mid r(t)$ in $\\Q[t]$. By Gauss' lemma, $r(t) = g(t)s(t)$ with $s(t) \\in \\Z[t]$. Now reduce mod $p$: $F(t) = \\bar{g}(t) \\bar{s}(t)$. But then $F(t) = \\bar{h}(t^p) = (\\bar{h}(t))^p$. If $\\bar{a}(t)$ is any irreducible factor of $\\bar{g}(t)$ in $\\F_p[t]$ then $\\bar{a}(t) | (\\bar{h}(t))^p$. As a result $\\bar{a}(t) | \\bar{h}(t)$. But then $(\\bar{a}(t))^2 | \\bar{g}(t) \\bar{h}(t) = \\bar{\\Phi}_m(t)$. Hence $\\bar{\\Phi}_m(t)$ has a repeated root and thus $t^m-1$ has repeated root mod $p$, contradiction since $p \\nmid m$. So our claim is true.\n\nNow consider a root $\\gamma$ of $h(t)$. Then it is also a primitive roof of $1$ and so $\\gamma =\\xi^i$ for some $i$ with $(i,m) =1$. Write $i = p_1...p_k$ factorization with $p_j$ prime, not necessarily distinct. Apply the claim repeatedly, we get that $\\gamma$ is a root of $g(t)$, and so $\\Phi_m(t)$ has a repeated root which is impossible. Hence $\\Phi_m(t)$ is irreducible over $\\Q$.\n\\end{proof}\n\\end{thm}\n\n\\begin{defi} (4.9)\\\\\nAn extension $K \\leq L$ is \\emph{cyclic} if the extension is Galois and $\\Gal(L/K)$ is cyclic. Note that this is not the same as a primitive/simple extension. Say the extension is abelian if it is Galois and $\\Gal(L/K)$ is abelian.\n\\end{defi}\n\n\\begin{eg}\nIn (3.17) we say that for finite fields, $\\F \\leq L$ is cyclic. And fomr (4.3) cyclotomic extensions are abelian. However, (4.8) says $\\Gal(\\Q(\\xi)/\\Q) \\cong (\\Z/m\\Z)^*$ and so if $m=8$, $\\Q \\leq \\Q(\\xi)$ is abelian, non-cyclic extension, where $\\xi$ primitive $8$th root of unity.\n\\end{eg}\n\n\\subsection{Kummer Theory}\nWe consider Galois extensions $K \\leq L$ wher $L$ is splitting field of a polynomial of the form $t^m-\\lambda$ with $\\lambda \\in K$.\n\n\\begin{thm} (4.10)\\\\\nLet $f(t) = t^m-\\lambda \\in K[t]$ and $char K \\nmid m$. Then the splitting field $L$ of $f(t)$ over $K$ contains a primitive $m$th root of unity $\\xi$, and $\\Gal(L/K(\\xi))$ is cyclic of order dividing $m$.\\\\\nMoreover, $f(t)$ is irreducible over $K(\\xi)$ if and only if $|L:K(\\xi)| = m$.\n\\begin{rem}\nWe consider the correspondence between $L -- K(\\xi) -- K$ and $\\{e\\} -- \\Gal(L/K(\\xi)) -- \\Gal(L/K)$ ,where the first is cyclic and the second is abelian: we know for cyclic $\\Gal(L/K(\\xi)) \\triangleleft \\Gal(L/K)$, by (3.2)(iii) $\\Gal(L/K)/\\Gal(L/K(\\xi)) \\cong \\Gal(K(\\xi) / K)$ is abelian.\n\\begin{proof}\nSince $t^m-\\lambda$ and $mt^{m-1}$ are coprime, we know that $t^m-\\lambda$ has distinct roots $\\alpha_1,...,\\alpha_m$ in the splitting field $L$. Thus $K \\leq L$ is Galois. Since $(\\alpha_i\\alpha_j^{-1})^m = \\lambda \\lambda^{-1} = 1$, the elements $1 = \\alpha_1\\alpha_1^{-1},\\alpha_2\\alpha_1^{-1},...,\\alpha_m\\alpha_1^{-1}$ are $m$ distinct $m$th roots of unity in $L$, and so \n\\begin{equation*}\n\\begin{aligned}\nt^m-\\lambda = (t-\\beta)(t-\\xi\\beta)(t-\\xi^2\\beta)...(t-\\xi^{m-1}\\beta)\n\\end{aligned}\n\\end{equation*}\nin $L[t]$, where $\\beta = \\alpha_1$, and $\\xi$ is a primitive $m$th root of unity. So $L = K(\\xi,\\beta)$. Let $\\sigma \\in \\Gal(L/K(\\xi))$. It's determined by its action on $\\beta$. Note that $\\sigma(\\beta)$ is another root of $t^m-\\lambda$ and so $\\sigma(\\beta) = \\xi^{j(\\sigma)}\\beta$, where $0 \\leq j(\\sigma) < m$. Also if $\\sigma,\\tau \\in \\Gal(L/K(\\xi))$ then \n\\begin{equation*}\n\\begin{aligned}\n\\tau\\sigma(\\beta) = \\tau(\\xi^{j(\\sigma)}\\beta) = \\xi^{j(\\sigma)} \\tau(\\beta) = \\xi^{j(\\sigma)} \\xi^{j(\\tau)} \\beta\n\\end{aligned}\n\\end{equation*}\nas $\\xi$ is fixed by $\\tau$. Thus $\\sigma \\to j(\\sigma)$ gives a group homomorphism\n\\begin{equation*}\n\\begin{aligned}\n\\theta: \\Gal(L/K(\\xi)) \\to \\Z/m\\Z\n\\end{aligned}\n\\end{equation*}\nwhere $\\Z/m\\Z$ is referring to the additive group. Note that $j(\\sigma) = 1$ if and only if $\\sigma$ is the identity and so $\\theta$ is injective.  $\\Gal(L/K(\\xi)) \\cong $subgroup of $\\Z/m\\Z$, is therefore cyclic since it's a subgroup of a cyclic group, and its order will divide $m$.\n\nFinally, since we are in a Galois extension, $|L:K(\\xi)| = |\\Gal(L/K(\\xi)| \\leq m$, with equality hold precisely when the action of $\\Gal(L/K(\\xi))$ is transitive on the roots, and that is when the polynomial $t^n-\\lambda$ is irreducible over $K(\\xi)$ by (3.6).\n\\end{proof}\n\\end{rem}\n\\end{thm}\n\n\\begin{eg}\nConsider $f(t) = t^6+3$, $\\xi$ the primitive $6$th root of unity. Note that $\\xi = -\\omega$ where $\\omega$ is the primitive cube root of 1. Now $\\Q(\\xi) = \\Q(\\omega) = \\Q(\\sqrt{-3})$. Note that $f(t)$ is irreducible over $\\Q$ by Eisenstein with $p=3$. However over $\\Q(\\xi) = \\Q(\\sqrt{-3})$, $f(t)$ factorizes as $f(t) = (t^3 - \\sqrt{-3})(t^3 + \\sqrt{-3})$. Let $L$ be the splitting field of $f(t)$. Now $\\Gal(L/\\Q(\\xi)) \\lneq \\Z/6\\Z$. Consider the correspondence $L \\xrightarrow{3} \\Q(\\xi) \\xrightarrow{2} \\Q$ with $\\{e\\} \\xrightarrow{3} \\Gal(L/\\Q(\\xi)) \\xrightarrow{2} \\Gal(L/\\Q)$. $\\Gal(L/\\Q)$ is dihedral of order $6$. So we have $\\Gal(L/\\Q(\\xi)) \\hookrightarrow \\Z/6\\Z$ and is cyclic of order 3. Complex conjugation is an element of order 2. Let $\\beta$ be a root of $f(t)$. Then the roots are $\\beta, \\xi \\beta =-\\omega \\beta, \\xi^2 \\beta = \\omega^2 \\beta, \\xi^3 \\beta = -\\beta, \\xi^4 \\beta = \\omega \\beta,\\xi^5\\beta = -\\omega^2 \\beta$. We have a 3-cycle generated by permuting $\\beta, \\omega^2\\beta,\\omega \\beta$. There's a dihedral relation -- conjugating the 3-cycle by complex conjugation yields the inverse of 3-cycle.\n\\end{eg}\n\n\\begin{eg}\nLet $f(t) = t^5-2$ over $\\Q$. Let $L$ be the splitting field of $f(t)$ over $\\Q$, and $\\xi$ be the 5th root of unity. $f$ is similar irreducible over $\\Q$. Now we have correspondence $L \\xrightarrow{5} \\Q(\\xi) \\xrightarrow{4} \\Q$ with $\\{e\\} \\xrightarrow{5} \\Gal(L/\\Q(\\xi)) \\xrightarrow{4} \\Gal(L/\\Q)$, as from our theorem $\\Gal(L/\\Q(\\xi))$ is embedded in the additive group $\\Z/5\\Z$. The extension degree 5 is because, is we adjoint any root $\\beta$ of $f(t)$ to $\\Q$, then $\\Q(\\beta) -- \\Q$ is a degree 5 extension, while $\\Q(\\beta)$ is also an intermediate field between $\\Q$ and $L$. So we actually get $\\Gal(L/\\Q(\\xi)) \\cong \\Z/5\\Z$. Note that we've deduced that $f(t)$ remains irreducible over $\\Q(\\xi)$. So $|\\Gal(L/\\Q(\\xi))| = 5$. So $|\\Gal(L/\\Q)| = 20$. Irreducibility of $f(t)$ over $\\Q$ implies that $\\Gal(L/\\Q)$ is a transitive subgroup of $S_5$. By the list of transitive subgroups of $S_5$ in (3.7), we know $H_{20}$ is of order 20, generated by a 5-cycle and a 4-cycle. We've already got 5-cycles. $\\Gal(L/\\Q) / \\Gal(L/\\Q(\\xi)) \\cong \\Gal(\\Q(\\xi)/\\Q)$ by fundamental theorem (3.2) (iii). However RHS $\\cong (\\Z/5\\Z)^*$ which is the multiplicative group of a finite field, therefore cyclic. So we deduce that our subgroups of $S_5$ contains a 4-cycle.\n\\end{eg}\n\nNow we look at the converse of (4.10).\n\n\\begin{thm} (4.11)\\\\\nSuppose $K\\leq L$ is a cyclic extension with $|L:K| = m$ where $char K \\nmid m$ and that $K$ contains a primitive $m$th root of unity. Then there exists $\\lambda \\in K$ such that $t^m - \\lambda$ is irreducible over $K$, and $L$ is the splitting field of $t^m-\\lambda$ over $K$.\n\nIf $\\beta$ is a root of $t^m-\\lambda$ in $L$, then $L=K(\\beta)$.\n\\end{thm}\n\n\\begin{defi} (4.12)\\\\\nA cyclic extension $K \\leq L$ with $|L:K| = m$ where $char K \\nmid m$ and $K$ contains a primitive $m$th root of unity is a \\emph{Kummer extension}.\n\\end{defi}\n\nTo prove (4.11), we need a lemma, which is in the previous example sheet (Sheet2 Q10):\n\\begin{lemma} (4.13)\\\\\nLet $\\phi_1,...,\\phi_n$ be embeddings of a field $K$ into a field $L$. Then there do not exist $\\lambda_1,...,\\lambda_m$, not all zero, such that $\\lambda_1\\phi_1(x) + ...+\\lambda_n\\phi_n(x) = 0$ for all $x \\in K$.\n\\end{lemma}\n\n\\begin{proof} (proof of theorem)\\\\\nLet $\\Gal(L/K) = <\\sigma>$ of order $m$. Observe that $1,\\sigma,\\sigma^2,...,\\sigma^{m-1}$ are distinct and map $L \\to L$. We can apply (4.13), there exists $\\alpha \\in L$ s.t. $\\beta = \\alpha+\\xi \\sigma(\\alpha) + ... + \\xi^{m-1} \\sigma^{m-1}(\\alpha) \\neq 0$, where $\\xi$ is a primitive $m$th root of unity. Observe that $\\sigma(\\beta) = \\xi^{-1} \\beta \\neq \\beta$, and so $\\beta \\not \\in K$, the fixed field of $\\Gal(L/K)$. Then $\\sigma(\\beta^n) = (\\sigma(\\beta))^m = \\beta^m$. Let $\\lambda = \\beta^m \\in K$. But $t^m-\\lambda = (t-\\beta(t-\\xi\\beta)...(t-\\xi^{m-1}\\beta)$ in $L[t]$, ans do $K(\\beta)$ is the splitting field of $t^m-\\lambda$ over $K$ (recall $\\xi \\in K$). Observe that $1,\\sigma,...,\\sigma^{m-1}$ are distinct $K$-automorphisms of $K(\\beta)$, and so $|K(\\beta):K| \\geq m$. So by size $L=K(\\beta) = K(\\xi\\beta)$ since $\\xi \\in K$. However, $t^m-\\lambda$ is the minimal polynomial of $\\beta$ over $K$, and hence is irreducible.\n\\end{proof}\n\n\\begin{defi} (4.14)\\\\\nA field extension $K \\leq L$ is an \\emph{extension by radicals} if there exists $K=L_0 \\leq L_1 \\leq ... \\leq L_n = L$, such that each extension $L_i \\leq L_{i+1}$ is either cyclotmic, or Kummer. A polynomial $f(t) \\in K[t]$ is \\emph{soluble by radicals} if its splitting field lies in an extension by radicals.\n\\end{defi}\n\n\\subsection{Cubics}\nWe've already seen that if $f(t)$ is a monic irreducible cubic in $K[t]$ with $L$ its splitting field over $K$, then $\\Gal(f) = \\Gal(L/K) = G$ is $A_3$ or $S_3$, since irreducibility implies action on roots is transitive, and transitive subgroups of $S_3$ are $A_3$ and $S_3$. Consider the correspondence $L -- K(\\Delta) \\xrightarrow{1 or 2} K$ with $\\{e\\} -- G \\cup A_3 \\xrightarrow{1 or 2} G$, where $\\Delta^2 = D(f)$ the discriminant of $f$. But to see that we can solve $f$ by radicals we want to make use of (4.11), and so we need to adjoin the approximate roots of unity.\n\nNow we get a bigger picture, where $\\omega$ is the primitive cube root of 1:\n\n\\includegraphics[scale=0.5]{image/GT_02.png}\n\nFrom the tower law, $L(\\omega):K(\\Delta,\\omega)| = 3$. Hence $\\Gal(L(\\omega)/K(\\Delta,\\omega)) \\cong C_3$. We can apply (4.11) to see that $L(\\omega) = K(\\Delta,\\omega) (\\beta)$, where $\\beta$ is a root of an irreducible polynomial $t^3-\\lambda \\in K(\\Delta,\\omega)[t]$. In fact, from the proof of (4.11) we see that $\\beta = \\alpha_1 + \\omega\\alpha_2+\\omega^2\\alpha_3$ where $\\alpha_1,\\alpha_2,\\alpha_3$ are roots of $f(t)$. Now all the extensions $K \\leq K(\\Delta) \\leq K(\\Delta,\\omega) \\leq L(\\omega)$ are cyclotomic or Kummer. So $f(t)$ is soluble by radicals.\n\nIn practice, Given irreducible cubic $f(t) = t^3+at^2+bt+c = (t-\\alpha_1)(t-\\alpha_2)(t-\\alpha_3)$, we have $\\alpha_1+\\alpha_2+\\alpha_3 = -a$. Replace $\\alpha_i$'s by $\\alpha_i' = \\alpha_i + a/3$, so that $\\alpha'_1+\\alpha'_2+\\alpha'_3 = 0$ and they are roots of a polynomial $g(t) = t^3+pt+q$, and $K(\\alpha_1,\\alpha_2,\\alpha_3) = K(\\alpha'_1,\\alpha'_2,\\alpha'_3$. Recall that the discriminant is $D(g) = -4p^3 - 27q^2$.\n\nSet $\\beta = \\alpha'_1+\\omega\\alpha'_2+\\omega^2\\alpha'_3$, $\\gamma = \\alpha'_1+\\omega^2\\alpha'_2+\\omega\\alpha'_3$. Then \n\\begin{equation*}\n\\begin{aligned}\n\\beta\\gamma &= {\\alpha'}_1^2+{\\alpha'}_2^2+{\\alpha'}_3^2 + (\\omega+\\omega^2)(\\alpha'_1\\alpha'_2+\\alpha'_1\\alpha'_3+\\alpha'_2\\alpha'_3)\\\\\n&= (\\alpha'_1+\\alpha'_2+\\alpha'_3)^2-3(\\alpha'_1\\alpha'_2+\\alpha'_1\\alpha'_3+\\alpha'_2\\alpha'_3)\\\\\n&= -3p\n\\end{aligned}\n\\end{equation*}\nand so $\\beta^3\\gamma^3 = -27p^3$. Now\n\\begin{equation*}\n\\begin{aligned}\n\\beta^3+\\gamma^3 &=(\\alpha_1+\\omega\\alpha'_2+\\omega^2\\alpha'_3)^3 + (\\alpha'_1+\\omega^2\\alpha'_2+\\omega\\alpha'_3)^3 + (\\alpha'_1+\\alpha'_2+\\alpha'_3)\\\\\n&=3({\\alpha'}_1^3+{\\alpha'}_2^3+{\\alpha'}_3^3) + 18\\alpha'_1\\alpha'_2\\alpha'_3\\\\\n&= -27q\n\\end{aligned}\n\\end{equation*}\nsince ${\\alpha'}_1^3 = -p\\alpha'_1-q$, and so ${\\alpha'}_1^3+{\\alpha'}_2^3+{\\alpha'}_3^3 = -3q$. So $\\beta^3$ and $\\gamma^3$ are roots of a quadratic $t^2+27qt-27p^3$ and so are \n\\begin{equation*}\n\\begin{aligned}\n-\\frac{27}{2}q \\pm \\frac{3\\sqrt{-3}}{2} \\sqrt{-27q^2-4p^3} = -\\frac{27}{2}q \\pm \\frac{3\\sqrt{-3}}{2} \\sqrt{D}\n\\end{aligned}\n\\end{equation*}\nWe can solve for $\\beta^3+\\gamma^3$ in $K(\\sqrt{-3},\\sqrt{D}) = K(\\omega,\\Delta)$. We can get $\\beta$ by adjoining a cube root of $\\beta^3$, and then set $\\gamma = -\\frac{3p}{\\beta}$. Finally we solve in $L(\\omega)$ for $\\alpha'_i$ to get\n\\begin{equation*}\n\\begin{aligned}\n\\alpha'_1 = \\frac{1}{3}(\\beta+\\gamma),\\\\\n\\alpha'_2 = \\frac{1}{3}(\\omega^2\\beta+\\omega\\gamma),\\\\\n\\alpha'_3 = \\frac{1}{3}(\\omega\\beta+\\omega^2\\gamma)\n\\end{aligned}\n\\end{equation*}\n(remember that $\\alpha'_1+\\alpha'_2+\\alpha'_3 = 0$.)\n\n\\subsection{Quartics}\nAs with the cubics case, by making a substitution of the form $\\alpha'_i = \\alpha_i + a/4$, we may assume that the sum of the roots is zero, and so the $t^3$ term is zero. Then we have\n\\begin{equation*}\n\\begin{aligned}\nf(t) = t^4+bt^2+ct+d = (t-\\alpha_1)(t-\\alpha_2)(t-\\alpha_3)(t-\\alpha_4)\n\\end{aligned}\n\\end{equation*}\nmonic irreducible. Let $L = K(\\alpha_1,...,\\alpha_4)$ be the splitting field for $f(t)$ over $K$. We have correspondence $L -- M =L^{G \\cap V_4}$, normal extension of $K -- K(\\Delta) -- K$ and $\\{e\\} -- G \\cap V_4 \\triangleleft G -- G\\cap A_4 -- G = \\Gal(L/K) \\leq S_4$. By fundamental theorem $\\Gal(M/K) \\cong G/G\\cap V_4$ by $\\theta :S_4 \\to S_3$, $\\ker \\theta = V_4$, $S_4/ V_4 \\cong S_3$. $\\theta|_G : G \\to S_3$ satisfies $\\ker \\theta|_G = G\\cap V_4$, $G/G\\cap V_4 \\cong im \\theta|_G \\leq S_3$. We therefore go looking for a cubic for which $M$ is the splitting field, called the resolvent cubic.\n\nNow set $x = \\alpha_1+\\alpha_2$, $y=\\alpha_1+\\alpha_3$, $z=\\alpha_1+\\alpha_4$. We see that $\\alpha_1 = \\frac{1}{2}(x+y+z)$, $\\alpha_2 = \\frac{1}{2}(x-y-z)$, $\\alpha_3 =\\frac{1}{2}(-x+y-z)$, $\\alpha_4 = \\frac{1}{2}(-x-y+z)$. Thus $K(\\alpha_1,...,\\alpha_4) = K(x,y,z)$,\n\\begin{equation*}\n\\begin{aligned}\nx^2 = (\\alpha_1+\\alpha_2)^2 = -(\\alpha_1+\\alpha_2)(\\alpha_3+\\alpha_4)\\\\\ny^2 = (\\alpha_1+\\alpha_3)^2 = -(\\alpha_1+\\alpha_3)(\\alpha_2+\\alpha_4)\\\\\nz^2 = (\\alpha_1+\\alpha_4)^2 = -(\\alpha_1+\\alpha_4)(\\alpha_2+\\alpha_3)\n\\end{aligned}\n\\end{equation*}\nThese are distinct e.g. if $y^2=z^2$ then $y = \\pm z$, and so either $\\alpha_3 = \\alpha_4$ or $\\alpha_1 = \\alpha_2$. The $x^2,y^2,z^2$ are permuted by $G$ and are fixed by $G \\cap V_4$. So $K(x^2,y^2,z^2) \\leq M = L^{G \\cap V_4}$. We claim that we have equality here, $M = K(x^2,y^2,z^2)$. Now consider the resolvent cubic $g(t) = (t-x^2)(t-y^2)(t-z^2) \\in K[t]$. Note that its coefficients are fixed by $G$ and so lie in $K$.\n\nTo prove the claim, Observe that $D(f) = D(g)$ (example sheet), so $K(\\Delta) \\leq K(x^2,y^2,z^2)$. Now observe that $\\Gal(L/K(x^2,y^2,z^2)) = \\Gal(K(x,y,z)/K(x^2,y^2,z^2))$, $K(x^2,y^2,z^2) \\leq K(x,y^2,z^2) \\leq K(x,y,z^2) \\leq K(x,y,z)$, where each extension is of degree 1 or 2. So $|K(x,y,z):K(x^2,y^2,z^2)|$ divides 8. So elements of $\\Gal(L/K(x^2,y^2,z^2))$ have order dividing 8. But $\\Gal(L/K(x^2,y^2,z^2)) \\leq G \\cap A_4$, so $\\Gal(L/K(x^2,y^2,z^2)) \\leq G \\cap V_4$. Then by fundamental theorem we get $M = K(x^2,y^2,z^2)$.\n\nNow consider the coefficients of $g(t)$: $x^2,y^2,z^2$ are permuted by $G$ and so the $g(t)$ are fixed by $G$ and therefore in $K$. $x^2+y^2+z^2 = -2b$, $x^2y^2+x^2z^2+y^2z^2 = b^2-4d$, $xyz = -c$ i.e. $x^2y^2z^2 = c^2$. So\n\\begin{equation*}\n\\begin{aligned}\ng(t) = t^3 + 2bt^2 + (b^2-4d)t - c^2\n\\end{aligned}\n\\end{equation*}\n\nWe know how to solve cubics, so we can solve for $x^2,y^2,z^2$. Therefore we can solve for $x,y,z$. Then use our formulae from last time $\\alpha_1 = \\frac{1}{2}(x+y+z)$ etc.\n\n\\begin{rem}\nConsider the map $\\theta:S_4 \\to S_3$, we have $\\ker \\theta = V_4$, $\\theta|_{A_4}:A_4 \\to A_3 \\cong C_3$, $\\theta|_{G \\cap A_4} : G\\cap A_4 \\to A_3$, this has kernel $G \\cap V_4$, so $G \\cap A_4 / G \\cap V_4 \\cong $ subgroup of $A_3$. So we know $G\\cap A_4$ has index 1 or 3 in $G \\cap V_4$. So by correspondence, $L^{G \\cap V_4}$ is an extension of order 1 or 3 over $K(\\Delta)$. It is 3 if the resolvent cubic is irreducible, and is 1 if the cubic is reducible.\n\\end{rem}\n\nFor example, let $f(t) = t^4+4t^2+2$. We have $g(t) = t^3+8t^2+8t$ is reducible.\n\nWe are assuming $char K \\neq 2$ from discussion about discriminants, and $char K \\neq 3$ for cubic Kummer extensions.\n\n\\subsection{Solubility by radicals}\nNow suppose we have a Galois extension $K \\leq L$, with $K = L_0 \\leq L_1 \\leq ... \\leq L_m = L$, such that $L_i \\leq L_{i+1}$ is either cyclotomic or Kummer extension. Let $G = \\Gal(L/K)$. There is a corresponding chain of subgroups of $G$, $G = G_0 \\geq G_1 \\geq ... \\geq G_m = \\{e\\}$, with $G_i = \\Gal(L/K_i)$, $L_i = L^{G_i}$ from Fundamental theorem. However, each extension $L_i \\leq L_{i+1}$ is Galois, and we know $G_{i+1} = \\Gal(L_i / L_{i+1}) \\triangleleft \\Gal(L/L_i) =  G_i$, and we know that the factor $G_i / G_{i+1} \\cong \\Gal(L_{i+1} / L_i)$, and RHS is abelian if $L_i \\leq L_{i+1}$ is cyclotomic, and is cyclic if it's Kummer.\n\n\\begin{defi} (4.15)\\\\\nA group is \\emph{soluble} if there is a chain of subgroups $\\{e\\} = G_m \\triangleleft G_{m-1} \\triangleleft ... \\triangleleft G_1 \\triangleleft G_0 = G$ (*), with $G_i / G_{i+1}$ abelian.\n\\end{defi}\n\n\\begin{eg}\n$S_3$ is soluble as $\\{e\\} \\triangleleft <(123)> \\triangleleft S_3$;\\\\\n$S_4$ is soluble as $\\{e\\} \\triangleleft V_4 \\triangleleft A_4 \\triangleleft S_4$, and $A_4/V_4 \\cong C_3$, $S_4 / A_4 \\cong C_2$.\n\nAlso, we know that $A_5$ is simple, and therefore any normal subgroup is either $\\{e\\}$ or $A_5$. As a result, any chain as in (*) in definition (4.15) would have non-abelian quotients. So $A_5$ is not soluble.\n\\end{eg}\n\n\\begin{lemma} (4.16)\\\\\nA finite group $G$ is soluble if and only if we have $\\{e\\} = G_m \\triangleleft G_{m-1} \\triangleleft ... \\triangleleft G_1 \\triangleleft G_0 = G$ (**), with $G_i/G_{i+1}$ cyclic.\n\\begin{proof}\nBackwards is definition. To show forward, we know about the structure of finite abelian groups. If $A$ abelian then there is a chain $\\{e\\} = A_4 \\triangleleft A_{r-1} \\triangleleft ... \\triangleleft A_0 = A$ with $A_r /A_{r+1}$ cyclic. Thus we have a chain (*) with abelian factors $G_i / G_{i+1}$. But we can refine it (adding terms in between), to one of the form (**).\n\\end{proof}\n\\end{lemma}\n\n\\begin{defi} (4.17)\\\\\nThe \\emph{derived subgroup} $G'$ of a group $G$ is the subgroup generated by all the commutators $g_1g_2g_1^{-1}g_2^{-1}$ for $g_1,g_2 \\in G$.\n\nNote that this is not necessarily a subgroup, so we'll have to check that.\n\\end{defi}\n\n\\begin{lemma} (4.18)\\\\\nLet $K \\triangleleft G$. Then $G/K$ abelian $\\iff$ $G' \\leq K$.\n\\begin{proof}\n$G/K$ abelian $\\iff$ $Kg_1 Kg_2 Kg_1^{-1} Kg_2^{-1} = K$ for all $g_1,g_2 \\in G$ $\\iff$ $g_1g_2g_1^{-1} g_2^{-1} \\in K$ $\\iff G' \\leq K$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{rem}\n$\\bullet$ Next etrm in representation theory we'll prove Burnside's theorem: If $|G| = p^a q^b$, $p,q$ distinct primes, then $G$ is soluble.\\\\\n$\\bullet$ Also Feit-Thompson theorem: if $|G|$ is odd, then $G$ is soluble.\\\\\n$\\bullet$ There's an analogue of Sylow's theorems due to Philip Hall: for all $|G| = mn$, with $(m,n)$ coprime, there is a subgroup of order $m$ if and only if $G$ is soluble.\n\\end{rem}\n\n\\begin{defi} (4.19)\\\\\nThe derived series $\\{G^{(m)}\\}$ of $G$ is defined inductively: $G^{(0)} =G, G^{(1)} = G',G^{(2)} = (G')'$,...\n\nThus we have\n\n\\begin{equation*}\n\\begin{aligned}\nG = G^{(0)} \\triangleright G^{(1)} \\triangleright ...\n\\end{aligned}\n\\end{equation*}\nwith $G^{(j)} / G^{(j+1)}$ abelian.\n\\end{defi}\n\n\\begin{lemma} (4.20, for $G$ finite)\\\\\n$G$ is soluble iff $G^{(m)} = \\{e\\}$ for some $m$.\n\\begin{proof}\nIf $G^{(m)} = \\{e\\}$, then the derived series gives a chain of the form (*) (in 4.15) in the definition of solubility.\n\nConversely, if there is a chain of the form (*), $G \\triangleright G_1 \\triangleright G_2 \\triangleright ... \\triangleright G_m = \\{e\\}$, with $G_i / G_{i+1}$ abelian, then an easy induction shows that $G^{(j)} \\leq G_j$, and so $G^{(m)} = \\{e\\}$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{rem}\nThe derived series is the fastest descending chain with abelian factors.\n\\end{rem}\n\n\\begin{lemma} (4.21)\\\\\n(i) Let $H \\leq G$, $G$ soluble, then $H$ is soluble.\\\\\n(ii) Let $H \\triangleleft G$, then $G$ soluble $\\iff$ $H$ and $G/H$ are both soluble.\n\\begin{proof}\n(i) $G$ soluble $\\implies$ $G^{(m)} = \\{e\\}$ by (4.20). But $H^{(m)} \\leq G^{(m)}$, so $H$ is soluble by 4.20.\\\\\n(ii) Let $H \\triangleleft G$. Then $G$ soluble $\\implies$ $H$ soluble by (i).\\\\\n$G$ soluble $\\implies$ $G^{(m)} = \\{e\\}$ say. Observer that $(G/H)' = G'H/H \\leq GH$, similarly $(G/H)^{(j)} = G^{(j)} H/H \\leq G/H$, thus $(G/H)^{(m)} = H/H$ trivial subgroup of $G/H$, and so $G/H$ is soluble.\n\nNow consider the converse. Suppose that $H$ and $G/H$ are soluble. Then $H^{(r)} = \\{e\\}$ and $(G/H)^{(s)} = H/H$ for some $r,s$. But then $(G/H)^{(s)} = G^{(s)} H/H$, so $G^{(s)} H \\cong H$ and thus $G^{(s)} \\leq H$. Hence $G^{(r+s)} \\leq H^{(r)} = \\{e\\}$. Thus $G$ is soluble.\n\\end{proof}\n\\end{lemma}\n\n\\begin{eg}\n$S_5$ is not soluble, since its subgroup $A_5$ is not soluble.\n\\end{eg}\n\n\\begin{thm} (4.22)\\\\\nLet $K$ be a field, and $f(t) \\in K[t]$. Assume $char K = 0$. Then $f(t)$ is soluble by radicals over $K$ $\\iff$ $\\Gal(f)$ over $K$ is soluble.\n\\begin{rem}\nWe don't need to restrict to $charK = 0$. What we need to do for a particular $f(t)$ is to avoid a finite number of bad characteristics (avoid characteristics $\\leq \\deg f(t)$).\n\\end{rem}\n\\end{thm}\n\n\\begin{coro} (4.23)\\\\\nIf $f(t)$ is a monic irreducible polynomial in $K[t]$ with $\\Gal(f) \\cong A_5$ or $S_5$, then $f(t)$ is not soluble by radicals (with $char K = 0$).\n\\end{coro}\n\n\\begin{eg}\nIn example 3.9(i), we had $f(t) = t^t-6t+3 \\in \\Q[t]$, and we've seen that $\\Gal(f)$ over $\\Q$ is $S_5$ (recall we had 3 real roots and complex conjugation gives a transposition, $f(t)$ is irreducible and so $5|\\Gal(f)$, so we've also got a 5-cycle and these generate $S_5$). So $f(t)$ is not soluble by radicals.\n\\end{eg}\n\n\\begin{proof} (of 4.22)\\\\\nSuppose $f(t)$ is soluble by radicals. Thus if $L$ is the splitting field of $f(t)$ over $K$, then $L$ lies in an extension of $K$ by radicals $K = L_0 \\leq L_1 \\leq ... \\leq L_m$ with each $L_i \\leq L_{i+1}$ is cyclotomic or Kummer. At this stage we don't know that $L_m$ is Galois over $K$. At this stage, we don't know that $L_m$ is Galois over $K$. So we'll need something else first:\n\n\\begin{lemma} (4.24)\\\\\nIf $K \\leq N$ is an extension by radicals, then $\\exists N'$ with $N \\leq N'$, $K \\leq N'$ is an extension of radicals, and $K \\leq N'$ being a Galois extension.\n\\end{lemma}\n\nAssuming this lemma, and so we may assume that $L_m$ is Galois over $K$. Then by Fundamental theorem of Galois Theory (3.2), there is a corresponding chain of subgroups of $\\Gal(L_m/K)$. Our previous discussion at the beginning of this section (before (4.13)) we know that $\\Gal(L_m / K)$ is soluble, because our chain has abelian factors. But $K \\leq L \\leq L_m$ with $K \\leq L$ Galois, by the Fundamental theorem (3.2(iii)), the Galois group $\\Gal(L/K) \\cong \\Gal(L_m/K)/\\Gal(L_m/L)$. But quotients of soluble groups are soluble. So $\\Gal(L/K)$ is soluble.\n\\end{proof}\n\n\\begin{proof} (of 4.24)\\\\\nWe have $K=L_0 \\leq L_1 \\leq ... \\leq L_m$, with each $L_i \\leq L_{i+1}$ cyclotomic or Kummer, and we want to embed this into a Galois extension of the same form. Assume $char K = 0$. By the primitive elemnt theorem, $L_m = K(\\alpha_1)$ for some $\\alpha_1$.\\\\\nLet $g(t)$ be the minimal polynomial of $\\alpha_1$ over $K$, with splitting field $M$. Thus $M = K(\\alpha_1,...,\\alpha_n)$ where $\\alpha_i$ are roots of $g(t)$. There are $K$-homomorphisms $\\phi_1:M \\to M$ by $\\alpha_1 \\to \\alpha_i$, extending the $K$-homomorphisms $K(\\alpha_1) \\to K(\\alpha_i) \\leq M$. The tower $K \\leq \\phi_i(K) \\leq \\phi_i(L_1) \\leq ... \\leq \\phi_i(L_m) = K(\\alpha_i)$, with cyclotomic or Kummer extensions as before.\\\\\nConsider $$L_m = K(\\alpha_1) \\leq \\phi_2(L_1)(\\alpha_1) \\leq \\phi_2(L_2)(\\alpha_1) \\leq ... \\leq \\phi_2(L_m)(\\alpha_1) = K(\\alpha_1,\\alpha_2)$$\\\\\nConsider the extension $\\phi_2(L_j)(\\alpha_1) \\leq \\phi_2(L_{j+1})(\\alpha_1)$: if $L_j \\leq L_{j+1}$ cyclotomic, then all the roots of unity adjoined are now in $L_m = K(\\alpha_1)$ and so $\\phi_2(L_j)(\\alpha_1) = \\phi_2(L_{j+1})(\\alpha_1)$. If $L_j \\leq L_{j+1}$ then we obtain $L_{j+1}$ by adjoining roots of an element of $L_j$, and so we obtain $\\phi_2(L_{j+1})$ by adjoining roots of an element in $\\phi_2(L_j)$. Hence we get from $\\phi_2(L_j)(\\alpha_1)$ to $\\phi_2(L_{j+1})(\\alpha_1)$ by adjoining roots of an element of $\\phi_2(L_j)$. So it's a Kummer extension.\\\\\nNow continue to get a suitable chain $K(\\alpha_1,\\alpha_2) \\leq ... \\leq K(\\alpha_1,\\alpha_2,\\alpha_3)$ etc. Thus we get a suitable chain from $K$ to $K(\\alpha_1,...,\\alpha_n) = M$. Observe that $K \\leq M$ is Galois.\n\\end{proof}\n\nConverse of (4.22): Suppose $G = \\Gal(f)$ over $K$ is soluble. Let $L$ be the splitting field of $f(t)$ over $K$ and so $|G| = |L:k| =n$. Set $m=n!$, and let $\\xi$ be a primitive $m$th root of unity and consider $L(\\xi)$. Our proof is similar to that used for cubics.\\\\\nObserve that $|L(\\xi):K(\\xi)| \\leq n$: by primitive element theorem $L=K(\\alpha)$ for some $\\alpha$ with minimal polynomial $g(t)$ say of degree $n$. Then $L(\\xi) = K(\\xi)(\\alpha)$, and the minimal polynomial of $\\alpha$ over $K(\\xi)$ divides $g(t)$, so is of degree $\\leq n$. Note that $\\Gal(L(\\xi)/L)$ is abelian, since the extension is cyclotomic. Then $\\Gal(L(\\xi)/K)$ is soluble since $\\Gal(L(\\xi) / L)$ soluble and $\\Gal(L/K) \\cong \\Gal(L(\\xi)/K) / \\Gal(L(\\xi)/L)$ soluble by Fundamental theorem and (4.21). Then the subgroup $\\Gal(L(\\xi)/K(\\xi)) \\leq \\Gal(L(\\xi)/K)$ is soluble by (4.21). Thus there is a chain of subgroups $\\Gal(L(\\xi)/K(\\xi)) = G_0 \\triangleright G_1 \\triangleright ... \\triangleright G_m = \\{e\\}$, with $G_i/G_{i+1}$ cyclic (using (4.16)). Now use the Fundamental theorem to get a corresponding chain of fields $K(\\xi) \\leq K_1 \\leq ... \\leq K_m = L(\\xi)$ with each $K_i \\leq K_{i+1}$ Galois, with cyclic Galois group.\\\\\nTheorem (4.11) now says that all those extensions are Kummer (note all the extensions are of degree $\\leq n$, and so we have the appropriate roots of unity). Thus we've embedded $L$ in an extension of $K$ by radicals.\n\n\\begin{eg}\n$f(t) = t^4+4t^2+2$. This is irreducible over $\\Q$ by Eisenstein. Resolvent cubic $g(t) = t^3+8t^2+8t$, its roots are 0 and $-4 \\pm 2\\sqrt{2}$, so its splitting field $L$ has degree 8 over $K=\\Q$, and is degree 4 over $K(\\sqrt{2})$. The Galois group is transitive of degree 8 in $S_4$, so must be $D_8$.\n\\end{eg}\n\n\\begin{eg}\n$f(t) = t^4+2t+2$ over $\\Q$, which is irreducible by Eisenstein. Its discriminant is $101 \\cdot 4^2$ which is not a square. The resolvent cubic $g(t) = t^3-8t-4$ is irreducible (as it's irreducible mod 5). So $\\Gal(f)$ is transitive, but not in $A_4$, and has a 3-cycle. So $\\Gal(f) = S_4$.\n\\end{eg}\n\n\\begin{eg}\n$f(t) = t^5-t-1$ is also irreducible over $\\Q$ since it's irreducible mod 5. So its Galois group contains a 5-cycle and is transitive. Consider mod 2, $f$ factorises as a product of irreducible cubic and irreducible quadratic $(t^3+t^2+1)(t^2+t+1)$. So $\\Gal(\\bar{f})$ generated by an element of cycle type 3,2. So $\\Gal(f)$ also contains an element of cycle type 3,2. Then $g^3$ is a transposition. Therefore $\\Gal(f) = S_5$ Then $g^3$ is a transposition. Therefore $\\Gal(f) = S_5$ over $\\Q$.\n\\end{eg}\n\n\\newpage\n\n\\section{Final Thoguhts}\n\\subsection{Algebraic Closure}\n\\begin{defi}(5.1)\\\\\nA field $L$ is \\emph{algebraically closed} if any $f(t) \\in L[t]$ splits into a product of linear factors in $L[t]$.\n\\end{defi}\n\n\\begin{rem}\nThis is equivalent to saying that any $f(t) \\in L[t]$ has a root in $L$ \\emph{or} that any algebraic extension of $L$ is $L$ itself.\n\\end{rem}\n\n\\begin{defi}(5.2)\\\\\nAn extension $K \\leq L$ is an \\emph{algebraic closure} of $K$ if $K \\leq L$ is algebraic and $L$ is algebraically closed.\n\\end{defi}\n\n\\begin{lemma}(5.3)\\\\\nIf $K \\leq L$ is algebraic and every polynomial in $K[t]$ splits completely over $L$ then $L$ is an algebraic closure of $K$.\n\\begin{proof}\nWe need to show $L$ is algebraically closed. Suppose $L \\leq L(x)$ is a finite extension, and $f_\\alpha(t) = t^n+a_{n-1}t^{n-1}+...+a_0$ is the minimal polynomial of $\\alpha$ over $L$. Let $M = K(\\alpha_0,...,\\alpha_{n-1}$. Then $M \\leq M(\\alpha)$ is a finite extension. But each $a_i$ is algebraic over $K$ and so $|M:K|<\\infty$. Hence $|M(\\alpha):K|<\\infty$ by Tower Law, and so $\\alpha$ is algebraic over $K$.\n\nThe minimal polynomial of $\\alpha$ over $K$ must split over $L$, and so $\\alpha \\in L$. Thus any algebraic extension of $L$ is $L$ itself.\n\\end{proof}\n\n\\begin{eg}\n$\\mathbb{A} = \\{\\alpha \\in \\C:\\alpha$ algebraic over $\\Q\\}$. It is a subfield of $\\C$: if $\\alpha,\\beta$ are algebraic over $\\Q$, then $|\\Q(\\alpha,\\beta):\\Q|<\\infty$, so if $\\gamma = \\alpha+\\beta,\\alpha-\\beta,\\alpha\\beta$ or $\\alpha/\\beta \\neq 0$, we get $\\Q(\\gamma) \\leq \\Q(\\alpha,\\beta)$ and so $|\\Q(\\gamma):\\Q| < \\infty$. So $\\gamma$ is algebraic over $\\Q$, and so $\\gamma \\in \\mathbb{A}$. Therefore $\\mathbb{A} = \\bar{\\Q}$ is an algebraic closure of $\\Q$.\n\\end{eg}\n\\end{lemma}\n\nHowever, if we want to prove existence and uniqueness of algebraic closures in general, then we need to appeal to Zorn's lemma (see Logic and Set Theory), and it's equivalent to the Axiom of Choice and the Well-Ordering Principle.\n\n\\begin{defi}\n$(\\mathcal{S},\\leq)$ is a partial order on $\\mathcal{S}$ if:\\\\\n(i) $x \\leq x$ $\\forall x \\in \\mathcal{S}$;\\\\\n(ii) $x \\leq y$ and $y \\leq z$ $\\implies x \\leq z$;\\\\\n(iii) if $x \\leq y$ and $y \\leq x$ then $x = y$.\n\\end{defi}\n\n$\\mathcal{S}$ is \\emph{totally ordered} if for any $x,y \\in \\mathcal{S}$, either $x \\leq y$ or $y \\leq x$.\n\nA \\emph{chain} in a partially ordered set $(\\mathcal{S},\\leq)$ is a totally ordered subset.\n\n\\begin{lemma} (5.5, Zorn's Lemma (actually an axiom))\\\\\nIf $(\\mathcal{S},\\leq)$ be a non-empty partially ordered set. Suppose that any chain has an upper bound in $\\mathcal{S}$(?). Then $\\mathcal{S}$ has a maximal element.\n\\end{lemma}\n\n\\begin{lemma} (5.6)\\\\\nLet $R$ be a non-trivial ring with multiplicative unity. Then $R$ has a maximal ideal.\n\\begin{proof}\nLet $\\mathcal{S}$ be the set of proper ideals of $R$, so this is non-empty since $(0)$ is proper as $R$ is non-trivial. We partially order $\\mathcal{S}$ by inclusion. We know any ideal $I$ is proper $\\iff$ $1 \\not\\in I$. Any chain of proper ideals has an upper bound in $\\mathcal{S}$, namely the union of chain. Then apply Zorn's lemma we know $\\mathcal{S}$ has a maximal element, i.e. a maximal ideal of $\\R$.\n\\end{proof}\n\\end{lemma}\n\n\\begin{thm} (5.7, existence of algebraic closures)\\\\\nFor any field $K$, there is an algebraic closure.\n\\begin{proof}\nLet $\\mathcal{S} = \\{(f(t),j)$ $f(t)$ irreducible monic in $K[t]$, $1 \\leq j \\leq \\deg f\\}$. For each pair $s=(f(t),j)$, we introduce an indeterminate $X_s = X_{f,j}$. Consider the polynomial ring $K[X_s, s \\in \\mathcal{S}]$, and set $\\tilde{f}(t) = f(t) - \\prod_{i=1}^{\\deg f} (t-X_{f,j}) \\in K[X_s, s \\in \\mathcal{S}][t]$. Let $I \\triangleleft K[X_s, s \\in \\mathcal{S}]$ generated by all the coefficients of all the $\\tilde{f} (t)$. Denote the coefficients of $\\tilde{f}(t)$ by $a_{f,l}$ for $0 \\leq l \\leq \\deg{f}$. We claim that $I \\neq K[X_s, s \\in \\mathcal{S}]$.\\\\\nTo prove that, suppose $1 \\in I$ and we try to get a contradiction. We have $b_1 a_{f_1,l_1}+...+b_n a_{f_N,l_N} = 1$ in $K[X_s, s \\in \\mathcal{S}]$ (+). Let $L$ be a splitting field for $f_1(t)...f_N(t)$ (product). For each $i$, $f_i$ splits over $L$. So $f_i(t) = \\prod_{j=1}^{\\deg f_i} (t-\\alpha_{ij}$. Define a $K$-linear ring homomorphism, which is identity on $K$: $\\theta$: $K[X_s, s \\in \\mathcal{S}] \\to L$ by $X_{f_i,j} \\to \\alpha_{i,j}$, $X_s \\to 0$ otherwise. This induces a map $K[X_s,s \\in \\mathcal{S}] \\to L[t]$. Then $\\theta(\\tilde{f}_i(t)) =\\theta(f_i(t)) - \\prod_{j=1}^{\\deg f_i} \\theta(t-X_{f_i,j}) = f_i(t) - \\prod_{j=1}^{\\deg f_i} (t-\\alpha_{i,j}) = 0$. But then $\\theta(a_{f_i,j}) = 0$ since $a_{f_i,j}$ are the coefficients of $\\tilde{f}_i(t)$. But applying $\\theta$ to (+) we get $0=1$. Contradiction.\nThen $I$ is a proper ideal of $K[X_s,s \\in \\mathcal{S}]$. By Zorn's lemma there is a maximal ideal $P$ of $K[X_s,s \\in \\mathcal{S}]$ containing $I$. set $L_1 = K[X_s,s \\in \\mathcal{S}] / P$ a field. Thus we have a field extension $K \\leq L_1$. We claim that $L_1$ is an algebraic closure of $K$.\\\\\nWe now prove that $K \\leq L_1$ is algebraic. $L_1$ is generated by the images $x_{f,j}$ of the $X_{f,j}$. However $\\tilde{f}(j)$ has coefficients in $I$ and so its image in $L_1[t]$ is the zero polynomial. Thus in $L_1[t]$, $f(t) = \\prod (t-x_{f,j})$ (*), and so $f(x_{f,j}) = 0$. Thus the $x_{f,j}$ are algebraic. Any element of $L_1$ involves only finitely many of the $x_{f,j}$, and so is algebraic over $K$. Moreover, from (*), any $f(t) \\in K[t]$ splits completely over $L_1$. The theorem follows from (5.3).\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (5.8)\\\\\nSuppose $\\theta:K \\to L$ is a ring homomorphism and $L$ is algebraically closed. Suppose $K \\leq M$ is an algebraic extension. Then $\\theta$ can be extended to a homomorphism $\\phi:M \\to L$ (i.e. $\\phi|_K = \\theta$).\n\\begin{proof}\nLet $\\mathcal{S} = \\{(N,\\phi):K \\leq N \\leq M, \\phi$ homomorphism $N \\to L$ extending $\\theta\\}$. Partially order $\\mathcal{S}$ by $(N_1,\\phi_1) \\leq (N_2,\\phi_2)$ if $N_1 \\leq N_2$ and $\\phi_2|_{N_1} = \\phi_1$. $\\mathcal{S}$ is non-empty since $(K,\\theta) \\in \\mathcal{S}$. Now if there is a chain $(N_1,\\phi_1) \\leq ...$ then set $N = \\bigcap N_\\lambda$. This is a subfield of $M$, and we can define $\\chi:N \\to L$ as follows: if $\\alpha \\in N$ then $\\alpha \\in N_\\lambda$ for some $\\lambda$ and we set $\\psi(\\alpha) = \\phi_\\lambda(\\alpha)$. This is well defined. Thus $(N,\\psi)$ is an upper bound for our chain in $\\mathcal{S}$. Zorn applies to give a maximal element of $\\mathcal{S}$ $(N,\\phi)$. We now show $N = M$. Given $\\alpha \\in M$, it's algebraic over $K$, and hence over $N$. Let $F_\\alpha(t)$ be its minimal polynomial over $N$. But $\\phi f(t)$ is in $L[t]$ and so splits completely over $L$, since $L$ algebraically closed. So $\\phi f(t) = (t-\\beta_1)...(t-\\beta_r)$ say. Since $\\phi f(\\beta_j) = 0$, there is a map $N(\\alpha) \\cong N[t] / (f_\\alpha(t)) \\to L$ by $\\alpha \\to \\beta_1$ extending $\\phi$. Maximality of $(N,\\phi)$ implies that $N(\\alpha) = N$. So $\\alpha \\in N$. Thus $N=M$.\n\\end{proof}\n\\end{thm}\n\n\\begin{thm} (5.9, uniqueness of algebraic closure)\\\\\nIf $K \\leq L_1$, $K \\leq L_2$ are two algebraic closures of $K$, then there exists an isomorphism $\\phi$:$L_1 \\to L_2$.\n\\begin{proof}\nBy (5.8) there is a homomorphism $\\phi:L_1 \\to L_2$ extending the embedding $K$ in $L_2$. Since $K \\leq L_2$ is algebraic, so also is $K \\leq \\phi(L_1)$. But $L_1$ is algebraically closed and so $\\phi(L_1)$ is algebraicaly closed. So $L_2 = \\phi(L_1)$ and $\\phi$ is an isomorphism.\n\\end{proof}\n\\end{thm}\n\n\\subsection{Symmetric polynomials and invariant theory}\nIn the build up of the Fundamental Theorem we met Artin's Theorem (3.3). Let $K \\leq L$ and $H$ finite subgroup of $\\Aut_K(L)$. Let $M = L^H$. Then $M \\leq L$ is a Galois extension and $H = \\Gal(L/M)$.\n\n\\begin{eg}\n$L = K(X_1,...,X_n)$. Let $S_n$ permute the variables. These permutations induce $K$-automorphisms of $L$. By Artin's theorem, if $M = L^{S_n} \\leq L$ then it is Galois and $\\Gal(L/M) = S_n$. Thus $S_n$ is aGalois group of some field extension. We know that we can regard any finite group $G$ as a subgroup of some $S_n$ and so we see that any finite group is a Galois group of some field extension (using Fundamental Theorem).\n\nNow consider $f(t) = (t-X_1)...(t-X_n) \\in M[t] = t^n - s_1 t^{n-1} + ... + (-1)^n s_n$. Thus $s_1 = X_1 + ... +X_n,...,s_n = X_1...X_n$.\n\\end{eg}\n\n\\begin{defi} (5.10)\\\\\nThese $s_i$ are the \\emph{elementary symmetric polynomials}.\n\\end{defi}\n\n\\begin{thm} (5.11)\\\\\nThe fixed field $M=L^{S_n} = K(s_1,...,s_n)$ and the $s_1,...,s_n$ are algebraically indepndent over $K$ (in $L$).\n\\end{thm}\n\n\\begin{defi} (5.12)\\\\\n$\\alpha_1,...,\\alpha_n$ are algebraically independent over $K$ if the ring homomorphism $K[Y_1,...,Y_n] \\to K[\\alpha_1,...,\\alpha_n] \\leq L$ is an isomorphism, where $K[Y_1,...,Y_n]$ is the polynomial ring in $Y_1,...,Y_n$.\n\\end{defi}\n\nRecall $S_n$ acts on $K(X_1,...,X_n)$ by permuting the variables, and we defined elementary symmetric polynomials last time.\n\n\\begin{proof} (of (5.11))\\\\\nCertainly the $s_i$ are fixed under $S_n$. So $M_1 = K(s_1,...,s_n) \\leq M = K(X_1,...,X_n)^{S_n}$. Observe that $L=K(X_1,...,X_n)$ is the splitting field for $f(t)$ over $M_1$, $f(t) = (t-X_1)...(t-X_n)$, but $f(t)$ has degree $n$ and so the degree of the splitting field over $M_1 \\leq n!$ (extension by adjoining one root is of degree $\\leq n$, the second is $\\leq n(n-1)$, etc). However, Artin's theorem gives $|L:M|=n!=|S_n|$ and so $M_1 = M$. For the algebraic independence of $s_1,...,s_n$ we make use of the idea of transcendence bases and transcendence degree: we may consider the algebraically independent subsets of $L$ and partially order them by inclusion. Note that the union of a chain is algebraically independent and so an upper bound Zorn applies to give a maximal algebraically independent subset -- \\emph{transcendence basis}. A version of the Exchange lemma implies that these all have the same cardinality, which is called the \\emph{transcendence degree}, $trdeg_K(L)$ of $L$ over $K$. Note that in our example $X_1,...,X_n$ is a transcendence basis for $L$ over $K$, $trdeg_K(L) = n$. However $L$ is algebraic over a fixed field $M$ and so $trdeg_K(L) = trdeg_K(M)$. If $s_1,...,s_n$ were algebraically independent then $trdeg_K(M) < n$, as $M$ would be algebraic over a subfield generated by fewer elemnts (using a general lemma $trdeg_K(K(\\alpha_1,...,\\alpha_n) \\leq n$). Therefore $s_1,...,s_n$ are algebraically independent.\n\\end{proof}\n\n\\subsection{Polynomial invariant theory}\nWe study $K[X_1,...,X_N]^H$ for a finite group and rather than confining ourselves to permutations of the variables, we also consider $H \\leq GL(V)$ where $V = span(X_1,...,X_n)$. \n\nQuestions: (1) Is $K[X_1,...,X_n]^H$ finitely generated?\\\\\n(2) Is $K[X_1,...,X_n]^H \\cong$ a polynomial algebra(?)?\n\n\\begin{thm} (5.13)\\\\\n$K[X_1,...,X_n]^{S_n} = K[s_1,...,s_n]$ (we've already seen that RHS is $\\cong$ to a polynomial algebra.\n\\end{thm}\n\n\\begin{defi} (5.14)\\\\\nThe elements of $K[s_1,...,s_n]$ are the \\emph{symmetric polynomials}.\n\\end{defi}\n\n\\begin{proof} (of (5.13))\\\\\nLet $f(X_1,...,X_n) \\in K[X_1,...,X_n]^{S_n}$. The proof is by induction on the total degree of $f$. If total degree is $0$, then $f$ is a constant polynomial, hence in $K$, and in $K[s_1,...,s_n]$. Suppose now the total degree $>0$. Let $\\theta:K[X_1,...,X_n] \\to K[X_1,...,X_{n-1}]$ by $g(X_1,...,X_n) \\to g(X_1,...,X_{n-1},0$, so $\\ker \\theta$ = ideal generated by $X_n$. Since $f(X_1,...,X_n)$ is fixed by $S_n$, $\\theta(f(X_1,...,X_n)) = f(X_1,...,X_{n-1},0)$ is fixed under the subgroup $S_{n-1}$ that fixes $n$. Note that $\\theta(s_j(X_1,...,X_n)) = s_j(X_1,...,X_{n-1})$(elementaray symmetric polynomials) for $j \\leq n-1$. Application induction, $\\theta(f(X_1,...,X_n)) = P(S_1(X_1,...,X_{n-1}),...,s_{n-1}(X_1,...,X_{n-1}))$ where $P$ denotes the polynomial. So $\\theta(f(X_1,...,X_n)-P(s_1(X_1,...,X_n),...,s_{n-1}(X_1,...,X_n)) = 0$, so $X_n$ divides $f(X_1,...,X_n) - P(s_1(X_1,...,X_n),...,s_{n-1}(X_1,...,X_n))$ (+). But (+) is a symmetric polynomial so it's fixed by $S_n$. Then $X_l$ divides (+) for lal $l$. But $K[X_l,...,X_n]$ has unique factorisation and the $X_l$ are coprime. So $X_1...X_n$ (product) divides (+). So $f(X_1,...,X_n) = g(X_1,...,X_n)X_1...X_n + P(s_1(X_1,...,X_n),...,s_{n-1}(X_1,...,X_n))$. Observe that the total degree of $g <$ total degree of $f(X_1,...,X_n)$, and that $g(X_1,...,X_n)$ is fixed under $S_n$. Apply induction to $g(X_1,...,X_n)$ and so it's a polynomial in the $s_i$'s. Thus $f(X_1,...,X_n) \\in K[s_1,...,s_n]$.\n\\end{proof}\n\n\\begin{eg}\n$K[X_1,...,X_n]^{A_n}$ is generated by $s_1,...,s_n$ and $$\\Delta(X_1,...,X_n) = \\prod_{i < j} (X_i-X_j)$$ Emmy Noether(1920s) considered other subgroups of $S_n$ and showed the invariant rings were Noetherian.\\\\\nChevalley-Shepherd-Todd (1954/5): $\\C[X_1,...,X_n]^H$, $H \\leq GL(V)$ finite, is isomorphic to a polynomial algebrad $\\iff$ $H$ is generated by pseudoreflections (1-eigenspace has codimension 1).\n\\end{eg}\n\n---end of course---\n\n\\end{document}\n", "meta": {"hexsha": "f1f8609bb8e1e8747728597125dfee5a40af3f6f", "size": 113335, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Galois Theory.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Galois Theory.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Galois Theory.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 80.1520509194, "max_line_length": 1470, "alphanum_fraction": 0.6412052764, "num_tokens": 41975, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7690802370707281, "lm_q1q2_score": 0.435313680495438}}
{"text": "\\documentclass[11pt, a4]{article}\n\\usepackage{qtree}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{mathtools}\n\\usepackage{tikz}\n\\usepackage{forest}\n\n\\usetikzlibrary{positioning}\n\\newcommand\\tab[1][0.5cm]{\\hspace*{#1}}\n\n%% define left/right/full outer join symbols\n\\def\\ojoin{\\setbox0=\\hbox{$\\bowtie$}%\n  \\rule[-.02ex]{.25em}{.4pt}\\llap{\\rule[\\ht0]{.25em}{.4pt}}}\n\\def\\leftouterjoin{\\mathbin{\\ojoin\\mkern-5.8mu\\bowtie}}\n\\def\\rightouterjoin{\\mathbin{\\bowtie\\mkern-5.8mu\\ojoin}}\n\\def\\fullouterjoin{\\mathbin{\\ojoin\\mkern-5.8mu\\bowtie\\mkern-5.8mu\\ojoin}}\n\\newcommand*{\\QEDB}{\\null\\nobreak\\hfill\\ensuremath{\\square}}%\n\\newcommand{\\car}[1]{\\tiny\\textcolor{red}{#1}}\n\\setcounter{section}{5}\n\\begin{document}\n\\title{Exercise Sheet 6}\n\n\\section{Exercise Sheet 6}\n\\subsection{Exercise 1}\n$|R_0| = 20, |R_1| = 10, |R_2| = 50, |R_3| = 40, |R_4| = 50, |R_5| = 55, |R_6| = 50, |R_7| = 60$\\\\\n$f_{0,1} = 0.1, f_{0,2} = 0.2, f_{0,6} = 0.2, f_{6,7} = 0.2, f_{2,5} = 0.2, f_{2,3} = 0.2, f_{3,4} = 0.3$\n\n\\subsubsection{Give the precedence graph rooted in $R_0$}\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=-> ]\n    [$R_2$,edge=-> \n        [$R_3$,edge=->\n            [$R_4$,edge=-> ]\n        ]\n        [$R_5$,edge=-> ]\n    ] \n    [$R_6$,edge=->\n        [$R_7$,edge=-> ]\n    ]\n]\n\\end{forest}\n\n\\subsubsection{Perform the IKKBZ algorithm Root at $R_0$}\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=-> ]\n    [$R_2$,edge=-> \n        [$R_3$,edge=->\n            [$R_4$,edge=-> ]\n        ]\n        [$R_5$,edge=-> ]\n    ] \n    [$R_6$,edge=->\n        [$R_7$,edge=-> ]\n    ]\n]\n\\end{forest}\n\\vspace{.2cm}\\\\\n\\begin{tabular}{|c|c|c|c|c|c|}\n\\hline\nRelation & n & s & C & T & rank\\\\\n\\hline\n$R_1$ & 10 & $0.1$ & 1 & 1 & $0$\\\\\n$R_2$ & 50 & $0.2$ & 10 & 10 & $\\frac{9}{10} = 0.9$\\\\\n$R_3$ & 40 & $0.2$ & 8 & 8 & $\\frac{7}{8} = 0.875$\\\\\n$R_4$ & 50 & $0.3$ & 15 & 15 & $\\frac{14}{15} = 0.933$\\\\\n$R_5$ & 55 & $0.2$ & 11 & 11 & $\\frac{10}{11} = 0.909$\\\\\n$R_6$ & 50 & $0.2$ & 10 & 10 & $\\frac{9}{10} = 0.9$\\\\\n$R_7$ & 60 & $0.2$ & 12 & 12 & $\\frac{11}{12} = 0.917$\\\\\n\\hline\n\\end{tabular}\n\\vspace{.2cm}\\\\\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=-> ]\n    [$R_2$,edge=-> \n        [$R_3$,edge=->\n            [$R_5$,edge=->\n                [$R_4$,edge=-> ]\n            ]\n        ]\n    ] \n    [$R_6$,edge=->\n        [$R_7$,edge=-> ]\n    ]\n]\n\\end{forest}\n\\tab $\\longrightarrow$ Merge $R_2$ and $R_3$ $\\longrightarrow$ \\tab\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=-> ]\n    [$R_{2,3}$,edge=-> \n        [$R_5$,edge=->\n            [$R_4$,edge=-> ]\n        ]\n    ] \n    [$R_6$,edge=->\n        [$R_7$,edge=-> ]\n    ]\n]\n\\end{forest}\n\\vspace{.2cm}\\\\\n\\begin{tabular}{|c|c|c|c|c|c|}\n\\hline\nRelation & n & s & C & T & rank\\\\\n\\hline\n$R_1$ & 10 & $0.1$ & 1 & 1 & $0$\\\\\n$R_4$ & 50 & $0.3$ & 15 & 15 & $\\frac{14}{15} = 0.933 $\\\\\n$R_5$ & 55 & $0.2$ & 11 & 11 & $\\frac{10}{11} = 0.909 $\\\\\n$R_6$ & 50 & $0.2$ & 10 & 10 & $\\frac{9}{10} = 0.9 $\\\\\n$R_7$ & 60 & $0.2$ & 12 & 12 & $\\frac{11}{12} = 0.917 $\\\\\n$R_{2,3}$ &  &  & 90 & 80 & $\\frac{79}{90} = 0.878 $\\\\\n\\hline\n$R_2$ & 50 & $0.2$ & 10 & 10 & $\\frac{9}{10} = 0.9 $\\\\\n$R_3$ & 40 & $0.2$ & 8 & 8 & $\\frac{7}{8} = 0.875 $\\\\\n\\hline\n\\end{tabular}\n\\vspace{.2cm}\\\\\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=->\n        [$R_{2,3}$,edge=-> \n            [$R_6$,edge=->\n                [$R_5$,edge=->\n                    [$R_7$,edge=-> \n                        [$R_4$,edge=-> ]\n                    ]\n                ]\n            ] \n        ]\n    ]\n]\n\\end{forest}\n\\tab $\\longrightarrow$ denormalizing $\\longrightarrow$ \\tab\n\\begin{forest}\n[$R_0$\n    [$R_1$,edge=->\n        [$R_2$,edge=-> \n            [$R_3$,edge=-> \n                [$R_6$,edge=->\n                    [$R_5$,edge=->\n                        [$R_7$,edge=-> \n                            [$R_4$,edge=-> ]\n                        ]\n                    ]\n                ] \n            ]\n        ]\n    ]\n]\n\\end{forest}\n\\vspace{1cm}\\\\\nResulting Join Tree =\\\\\n\\tab$((((((R_0 \\bowtie R_1) \\bowtie R_2) \\bowtie R_3) \\bowtie R_6) \\bowtie R_5) \\bowtie R_7) \\bowtie R_4 = RJT$\n\\vspace{1cm}\\\\\n$M = R_0 \\bowtie R_1 $\\\\\n$C_{out}(M) = |R_0| * |R_1| * s_1 = 20 $\\\\\n\\\\\n%%20\n$P = (R_0 \\bowtie R_1) \\bowtie R_2 $\\\\\n$C_{out}(P) = |M| * |R_2| * s_2 + C_{out}(M) = 220 $\\\\\n%%200\n\\\\\n$Q = ((R_0 \\bowtie R_1) \\bowtie R_2) \\bowtie R_3 $\\\\\n$C_{out}(Q) = |P| * |R_3| * s_3 + C_{out}(P) = 1'820 $\\\\\n%%1'600\n\\\\\n$S = (((R_0 \\bowtie R_1) \\bowtie R_2) \\bowtie R_3) \\bowtie R_6 $\\\\\n$C_{out}(S) = |Q| * |R_6| * s_6 + C_{out}(Q) = 17'820 $\\\\\n%%16'000\n\\\\\n$T = ((((R_0 \\bowtie R_1) \\bowtie R_2) \\bowtie R_3) \\bowtie R_6) \\bowtie R_5 $\\\\\n$C_{out}(T) = |S| * |R_5| * s_5 + C_{out}(S) = 193'820 $\\\\\n%%176'000\n\\\\\n$U = (((((R_0 \\bowtie R_1) \\bowtie R_2) \\bowtie R_3) \\bowtie R_6) \\bowtie R_5) \\bowtie R_7 $\\\\\n$C_{out}(U) = |T| * |R_7| * s_7 + C_{out}(T) = 2'305'820 $\\\\\n%%2'112'000\n\\\\\n$C_{out}(RJT) = |U| * |R_4| * s_4 + C_{out}(U) \\mathbf{= 33'985'820} $\n%%31'680'000\n\n\\subsubsection{Perform the MVP algorithm}\nThere are no edges with weights $< 1$, so we start with phase 2:\\\\\nWeighted-Join-Graph $G$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{20}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{200}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{550}};\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{400}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n  \\draw [->,thick] (v67) to [out=30,in=150] node[above] {12} (v06);\n  \\draw [->,thick] (v06) to [out=210,in=330] node[below] {4} (v67);\n\n  \\draw [->,thick] (v06) to [out=30,in=150] node[above] {10} (v01);\n  \\draw [->,thick] (v01) to [out=210,in=330] node[below] {1} (v06);\n\n  \\draw [->,thick] (v01) to [out=270,in=45] node[right] {1} (v02);\n  \\draw [->,thick] (v02) to [out=360,in=0] node[right] {10} (v01);\n\n  \\draw [->,thick] (v06) to [out=280,in=135] node[left] {10} (v02);\n  \\draw [->,thick] (v02) to [out=180,in=240] node[left] {10} (v06);\n\n  \\draw [->,thick] (v02) to [out=190,in=90] node[left] {4} (v25);\n  \\draw [->,thick] (v25) to [out=20,in=240] node[right] {11} (v02);\n\n  \\draw [->,thick] (v25) to [out=0,in=180] node[above] {27.5} (v23);\n  \\draw [->,thick] (v23) to [out=200,in=340] node[below] {20} (v25);\n\n  \\draw [->,thick] (v02) to [out=350,in=120] node[right] {4} (v23);\n  \\draw [->,thick] (v23) to [out=160,in=300] node[left] {8} (v02);\n  \n  \\draw [->,thick] (v23) to [out=30,in=150] node[above] {10} (v34);\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 1\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{0,1}, v_{0,6}, v_{0,2}, v_{2,3}, v_{2,5}, v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{0,1} \\rightarrow v_{0,2}$.\\\\\nNew cost: $\\text{cost}(v_{0,1}') = 10 \\cdot \\frac{1}{10} \\cdot 20 \\cdot \\frac{1}{5} \\cdot 50 + 20 + 200 = 420$\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{200}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{550}};\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{400}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n  \\draw [->,thick] (v67) to [out=30,in=150] node[above] {12} (v06);\n  \\draw [->,thick] (v06) to [out=210,in=330] node[below] {4} (v67);\n\n  \\draw [->,thick] (v06) to [out=30,in=150] node[above] {10} (v01);\n\n\n  \\draw [->,thick] (v06) to [out=280,in=135] node[left] {10} (v02);\n  \\draw [->,thick] (v02) to [out=180,in=240] node[left] {10} (v06);\n\n  \\draw [->,thick] (v02) to [out=190,in=45] node[left] {4} (v25);\n  \\draw [->,thick] (v25) to [out=360,in=240] node[right] {11} (v02);\n\n  \\draw [->,thick] (v25) to [out=0,in=180] node[above] {27.5} (v23);  \n  \\draw [->,thick] (v23) to [out=200,in=340] node[below] {20} (v25);    \n\n  \\draw [->,thick] (v02) to [out=350,in=120] node[right] {4} (v23);\n  \\draw [->,thick] (v23) to [out=160,in=300] node[left] {8} (v02);\n  \n  \\draw [->,thick] (v23) to [out=30,in=150] node[above] {10} (v34);\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to [out=270,in=45] (v02);\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 2\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{0,6}, v_{0,2}, v_{2,3}, v_{2,5}, v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{0,6} \\rightarrow v_{6,7}$.\\\\\nNew cost: $\\text{cost}(v_{0,6}') = 60 \\cdot \\frac{1}{5} \\cdot 50 \\cdot \\frac{1}{5} \\cdot 20 + 600 + 200 = 3200$\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{3200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{200}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{550}};\n\n  \\draw [->,thick] (v25) to [out=0,in=180] node[above] {27.5} (v23);\n  \\draw [->,thick] (v23) to [out=200,in=340] node[below] {20} (v25);\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{400}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n  \\draw [->,thick] (v02) to [out=180,in=240] node[left] {10} (v06);\n\n  \\draw [->,thick] (v02) to [out=190,in=45] node[left] {4} (v25);\n  \\draw [->,thick] (v25) to [out=360,in=240] node[right] {11} (v02);\n\n  \\draw [->,thick] (v02) to [out=350,in=120] node[right] {4} (v23);\n  \\draw [->,thick] (v23) to [out=160,in=300] node[left] {8} (v02);\n  \n  \\draw [->,thick] (v23) to [out=30,in=150] node[above] {10} (v34);\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n\n  \\draw [dashed, ->,thick] (v67) to [out=280,in=190] node[left] {1} (v02);\n  \\draw [dashed, ->,thick] (v67) to [out=30,in=150] node[above] {1} (v01);\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to [out=270,in=45] (v02);\n  \\draw [->,thick] (v06) to  (v67);\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 3\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{0,2}, v_{2,3}, v_{2,5}, v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{0,2} \\rightarrow v_{2,5}$.\\\\\nNew cost: $\\text{cost}(v_{0,2}') = 20 \\cdot \\frac{1}{5} \\cdot 50 \\cdot \\frac{1}{5} \\cdot 55 + 200 + 550= 2950 $\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{3200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{2950}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{550}};\n\n  \\draw [->,thick] (v25) to [out=0,in=180] node[above] {27.5} (v23);\n  \\draw [->,thick] (v23) to [out=200,in=340] node[below] {20} (v25);\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{400}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n  \n  \\draw [->,thick] (v23) to [out=160,in=300] node[left] {8} (v02);\n  \n  \\draw [->,thick] (v23) to [out=30,in=150] node[above] {10} (v34);\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n\n  \\draw [dashed, ->,thick] (v67) to [out=280,in=190] node[left] {1} (v02);\n  \\draw [dashed, ->,thick] (v67) to [out=30,in=150] node[above] {1} (v01);\n\n  \\draw [dashed, ->,thick] (v25) to [out=90,in=270] node[right] {1} (v06);\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to (v02);\n  \\draw [->,thick] (v06) to (v67);\n  \\draw [->,thick] (v02) to (v25);\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 4\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{2,3}, v_{2,5}, v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{2,3} \\rightarrow v_{0,2}$.\\\\\nNew cost: $\\text{cost}(v_{2,3}') = 20 \\cdot \\frac{1}{5} \\cdot 50 \\cdot \\frac{1}{5} \\cdot 40 + 2950 + 400 = 4950 $\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{3200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{2950}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{550}};\n\n  \\draw [->,thick] (v25) to [out=0,in=180] node[above] {27.5} (v23);\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{4950}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n\n\n  \\draw [dashed, ->,thick] (v67) to [out=30,in=150] node[above] {1} (v01);\n\n  \\draw [dashed, ->,thick] (v25) to [out=90,in=270] node[right] {1} (v06);\n\n  \\draw [dashed, ->,thick] (v02) to [out=350,in=90] node[above] {1} (v34);\n\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to (v02);\n  \\draw [->,thick] (v06) to (v67);\n  \\draw [->,thick] (v02) to (v25);\n  \\draw [->,thick] (v23) to (v02);\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 5\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{2,5}, v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{2,5} \\rightarrow v_{0,6}$.\\\\\nNew cost: $\\text{cost}(v_{2,5}') = 50 \\cdot \\frac{1}{5} \\cdot 55 \\cdot 20 \\cdot \\frac{1}{5} \\cdot 50 + 550 + 3200 = 113750$\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{3200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{2950}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{113750}};\n\n\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{4950}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{600}};\n\n  \\draw [->,thick] (v34) to [out=210,in=330] node[below] {15} (v23);\n  \\draw [dashed, ->,thick] (v67) to [out=30,in=150] node[above] {1} (v01);\n  \\draw [dashed, ->,thick] (v02) to [out=350,in=90] node[above] {1} (v34);\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to (v02);\n  \\draw [->,thick] (v06) to (v67);\n  \\draw [->,thick] (v02) to (v25);\n  \\draw [->,thick] (v23) to (v02);\n  \\draw [->,thick] (v25) to (v06);\n\\end{tikzpicture}\\\\\n%% ###########\n%% STEP 6\n%% ###########\n\\rule{\\textwidth}{0.4pt}\n$Q_1 = \\emptyset$\\\\\n$Q_2 = \\{v_{3,4}, v_{6,7}\\}$\\\\\nConsider edge $v_{3,4} \\rightarrow v_{2,3}$.\\\\\nNew cost: $\\text{cost}(v_{3,4}') = 50 \\cdot \\frac{3}{10} \\cdot 40 \\cdot \\frac{1}{5} \\cdot 50 + 600 + 4950 = 11550$\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v67car) [above = 0cm of v67] {\\car{600}};\n\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v06car) [above = 0cm of v06] {\\car{3200}};\n\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v01car) [above = 0cm of v01] {\\car{420}};\n\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v02car) [above = 0cm of v02] {\\car{2950}};\n\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v25car) [above = 0cm of v25] {\\car{113750}};\n\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v23car) [above = 0cm of v23] {\\car{4950}};\n\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n  \\node (v34car) [above = 0cm of v34] {\\car{11550}};\n\n  \\draw [dashed, ->,thick] (v67) to [out=30,in=150] node[above] {1} (v01);\n  \\draw [dashed, ->,thick] (v02) to [out=350,in=90] node[above] {1} (v34);\n\n\\end{tikzpicture}\\\\\nSpanning Tree $S$:\\\\\n\\begin{tikzpicture}[node distance=3cm]\n  \\node (v67) at (0,0) {$v_{6,7}$};\n  \\node (v06) [right of=v67] {$v_{0,6}$};\n  \\node (v01) [right of=v06] {$v_{0,1}$};\n  \\node (v02) [below right of=v06] {$v_{0,2}$};\n  \\node (v25) [below left of=v02] {$v_{2,5}$};\n  \\node (v23) [below right of=v02] {$v_{2,3}$};\n  \\node (v34) [right of=v23] {$v_{3,4}$};\n\n  \\draw [->,thick] (v01) to (v02);\n  \\draw [->,thick] (v06) to (v67);\n  \\draw [->,thick] (v02) to (v25);\n  \\draw [->,thick] (v23) to (v02);\n  \\draw [->,thick] (v25) to (v06);\n  \\draw [->,thick] (v34) to (v23);\n\\end{tikzpicture}\\\\\nspanning tree is complete $\\Rightarrow$ stop.\\\\\nResulting join tree:\\\\\n\n%% tree\n\\Tree[.$\\bowtie$\n        [.$\\bowtie$\n            [.$\\bowtie$ \n                [.$\\bowtie$\n                    [.$\\bowtie$ \n                      [.$\\bowtie$\n                        $R_3$\n                        $R_4$\n                      ]\n                      $R_2$\n                    ]\n                    [.$\\bowtie$ \n                      $R_0$\n                      $R_1$\n                    ]\n                ]\n                $R_5$\n            ]\n            $R_6$\n        ]\n        $R_7$\n]\n\n\\end{document}\n", "meta": {"hexsha": "4de0f8d71f79c6b8777bec0caab89e4981a3d700", "size": 20064, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Query Optimization/assignments/Assignment 6.tex", "max_stars_repo_name": "mrahtapot/TUM", "max_stars_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 225, "max_stars_repo_stars_event_min_datetime": "2019-10-02T10:49:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:25:38.000Z", "max_issues_repo_path": "Query Optimization/assignments/Assignment 6.tex", "max_issues_repo_name": "mrahtapot/TUM", "max_issues_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-02-16T12:22:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-31T19:35:57.000Z", "max_forks_repo_path": "Query Optimization/assignments/Assignment 6.tex", "max_forks_repo_name": "mrahtapot/TUM", "max_forks_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 69, "max_forks_repo_forks_event_min_datetime": "2019-10-02T21:46:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T19:27:50.000Z", "avg_line_length": 32.4135702746, "max_line_length": 125, "alphanum_fraction": 0.5159489633, "num_tokens": 9383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961016, "lm_q2_score": 0.7690802264851919, "lm_q1q2_score": 0.43531366324343435}}
{"text": "% !TeX root = ./apxthy.tex\n\n\\section{Nonlinear Approximation}\n%\n\\label{sec:nonlin}\n%\n\n\\subsection{Best polynomial approximation}\n%\n\\label{sec:poly:bestapprox}\n%\nBest approximation in Hilbert spaces is a linear operation, indeed an orthogonal\nprojection. By contrast best approximation max-norms is far less trivial. This\nsection concerns the best approximation of continuous functions with polynomials\nin the $L^\\infty$-norm. Although this norm is not strictly convex, it turns out\nthat the best-approximant is still unique. Moreover, its characterisation leads\nto an algorithm (the Remez algorithm). The high cost of the Remez algorithm an\ntogether with the fact that Chebyshev interpolation (or projection) typically\ngives accuracy very close to best-approximation means this is rarely used in\npractise, however the mathematics is still interesting and worth studying.\nMoreover, this is our first non-trivial example of a {\\em non-linear\napproximation algorithm}.\n\n\\begin{theorem} \\label{th:poly:bestapprox}\n   Let $f \\in C([-1,1])$, then there exists a unique best approximation\n   $p \\in \\Poly_N$ such that $\\|f - p \\|_\\infty \\leq \\|f-q\\|_\\infty$ for\n   all $q \\in \\Poly_N$.\n\n   A polynomial $p \\in \\Poly_N$ is the best approximation if and only if\n   it equioscillates at (at least) $N+2$ points $y_0 < \\dots < y_{N+1}$;\n   that is,\n   \\[\n      (f-p)(y_j) = \\pm (-1)^j \\|f-p\\|_\\infty.\n   \\]\n\\end{theorem}\n\\begin{proof}\n   test\n   {\\it 1. Existence: } This is covered in\n   Exercise~\\ref{exr:prelims:bestapprox}. Let $E := \\inf_{p \\in \\Poly_N}\n   \\|f-p\\|_\\infty$.\n\n   {\\it 2. Equi-oscillation implies optimality: } Suppose $p$ satisfies\n   the equi-oscillation property and $q \\in \\Poly_N$ such that\n   $\\|f-q\\|_\\infty < \\|f-p\\|_\\infty$. Without loss of generality, we then have\n   \\begin{align*}\n      (f-q)(y_j) &< (f-p)(x_j), \\qquad j \\text{ even},  \\\\\n      (f-q)(y_j) &> (f-p)(x_j), \\qquad j \\text{ odd}, \\\\\n   \\end{align*}\n   and hence\n   \\begin{align*}\n      (p-q)(y_j) &> 0, \\qquad j \\text{ odd}, \\\\\n      (p-q)(y_j) &< 0, \\qquad j \\text{ even}.  \\\\\n   \\end{align*}\n   Consequently $p-q$ has at least $N+1$ roots, which means that $p - q = 0$.\n\n   {\\it 3. Optimality implies equi-oscillation: } Let $p \\in \\Poly_N$ and\n   suppose there exist {\\em at most} $M < N+2$ points $y_1 < \\dots y_M$ at which\n   $f-p$ equi-oscillates. Without loss of generality, assume that $(f-p)(y_1) =\n   -E$, then we can find points\n   \\[\n      z_1 \\in (-1, y_1), z_2 \\in (y_1, y_2), \\dots,\n      z_M \\in (y_{M-1}, y_M), z_{M+1} \\in (y_M, 1)\n   \\]\n   such that\n   \\begin{align*}\n      (f-p) &< E, \\qquad \\text{in } [-1, z_1], [z_2, z_3], \\dots\n      (f-p) &> E, \\qquad \\text{in } [z_1, z_2], [z_3, z_4], \\dots\n   \\end{align*}\n   Now, let\n   \\[\n      \\delta p(x) := (z_1 - x)(z_2-x)\\cdots(z_{M+1}-1),\n   \\]\n   then we readily see that\n   \\[\n      \\|f - (p + \\eps \\delta p)\\|_\\infty < \\|f - p\\|_\\infty\n      \\qquad \\text{for $\\eps$ sufficiently small.}\n   \\]\n   Thus, $p$ was not optimal.\n\n   {\\it 4. Uniqueness: } Suppose that $p, q$ are both best approximations, then\n   $r := (p+q)/2$ is a best approximation as well. Let $y_j$ be the\n   equi-oscillation points. $|r(y_j)| = E$ is only possible if $p(y_j) = q(y_j)\n   = \\pm E$. Thus $q, p$ agree at $N+2$ points and are therefore equal.\n\\end{proof}\n\nInterestingly, then proof is semi-constructive and with a bit of immagination\ngives rise to the following (not quite an) algorithm:\n\n{\\bf Remez Algorithm:} Input: $f, N$\n\\begin{enumerate}\n\\item Choose initial interpolation nodes $x_0 < \\dots < x_N$. E.g., Chebyshev\nnodes are a canonical choice.\n\\item Solve the system\n\\[\n      b_0 + b_1 x_j + \\dots + b_{N} x_{j}^{N} + (-1)^j E = f(x_j),\n      \\qquad j = 0, \\dots, N+1\n\\]\nfor the $n+2$ unknowns $b_i, E$.\n\\item\n\\end{enumerate}\n\n% A complete analysis of the Remez algorithm is a little involved\n\n\n\\subsection{Rational Approximation by Example}\n\n\n\n% \\subsection{Adaptive Grid Selection}\n% %\n% \\alert{we did not cover this in 2019, but see \\S~\\ref{sec:splines:sing}\n% for a similar topic}\n\n\n\\subsection{Rational Approximation by Iteratively Reweighted Least Squares}\n\n\n\\subsection{The AAA Algorithm}\n", "meta": {"hexsha": "d12bd8e755bc790cf97f98a18c0e4dfe6cfb4bc6", "size": 4140, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/nonlin.tex", "max_stars_repo_name": "cortner/MA3J8ApxThyApp", "max_stars_repo_head_hexsha": "9400c557187dbd82468df2dbd0a7da99d7f08f8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-05-22T05:11:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-03T02:47:25.000Z", "max_issues_repo_path": "tex/nonlin.tex", "max_issues_repo_name": "cortner/MA3J8ApxThyApp", "max_issues_repo_head_hexsha": "9400c557187dbd82468df2dbd0a7da99d7f08f8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-03T22:23:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-21T01:58:58.000Z", "max_forks_repo_path": "tex/nonlin.tex", "max_forks_repo_name": "cortner/ApxThyApp", "max_forks_repo_head_hexsha": "0b28c5c4370eb4d9c5a9063c2c5c1b938aa54a3d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-02T02:44:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-02T02:44:56.000Z", "avg_line_length": 34.7899159664, "max_line_length": 80, "alphanum_fraction": 0.6504830918, "num_tokens": 1430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7690802264851919, "lm_q1q2_score": 0.4353136632434343}}
{"text": "\n%\n% Chapter Six\n%\n\n\\chapter{REACTION RATES AND IMPLICATIONS}\n\\section{Reaction Rates Calculation}\nAs discussed in Chapter 1, the reaction rate for the narrow resonances is given by\n \\begin{equation}\n \\label{eq:rate_1}\n    \\begin{aligned}\n         N_A<\\sigma v> =( \\frac{2 \\pi}{\\mu k T_9 })^{3/2}h_2 \\sum_i(\\omega \\gamma)_i exp(\\frac{-E_{R,i}}{kT_9})\n        \\end{aligned}\n\\end{equation}\nin units of cm$^3$ s$^{-1}$ mole$^{-1}$, and\n \\begin{equation}\n \\label{eq:rate_2}\n    \\begin{aligned}\n         N_A<\\sigma v> = 1.54 \\times 10^{5} (\\mu T_9)^{-3/2} \\sum_i (\\omega \\gamma)_i \\frac{-11.605E_{R,i}}{T_9}\n        \\end{aligned}\n\\end{equation}\nin units of cm$^3$ s$^{-1}$ mole$^{-1}$ if applying the numerical values to the equation above, where $\\mu$ refers to the reduced mass, $T_9$ the astrophysical temperature in in units of GK, $ (\\omega \\gamma)_i$ the resonance strength in the i$^{th}$ resonance in eV, $E_{R,i}$ the resonance energy of the  i$^{th}$ resonance in the center of mass system in MeV, respectively.\n\nTo calculate the reaction rate from Eq.\\ref{eq:rate_2}, $T_9$ is associated with the effective temperature that  enables the stellar  burning, $E_{R,i}$  is determined by\n \\begin{equation}\n \\label{eq:Er}\n    \\begin{aligned}\n    E_{R,i} = E_{x,i} - Q\n        \\end{aligned}\n\\end{equation}\nwhere E$_{x,i}$ is the excitation energy of the i$_{th}$ excited states of the compound nuclei and Q is the Q-value of the reaction, i.e. Q = 10.615 MeV in the $^{22}$Ne($\\alpha,\\gamma$)$^{26}$Mg reaction in this work.\nThe resonance strength  $(\\omega \\gamma)_i$ is given by\n \\begin{equation}\n    \\label{eq:strength}\n    \\begin{aligned}\n    \\omega \\gamma_{i} = \\frac{2J_{res} + 1}{(2J_1 + 1)(2J_2 + 1)} \\frac{\\Gamma_{in} \\Gamma_{out}}{\\Gamma_{tot}}\n        \\end{aligned}\n\\end{equation}\nwhere $J_{res}$, $J_1$, $J_2$ refer to the spins of the resonance, the target nuclei $^{22}$Ne (J = 0) and the incoming $\\alpha$ particle (J = 0), respectively. The particle widths  $\\Gamma$ can be written as $\\Gamma_{tot} = \\Gamma_\\alpha + \\Gamma_\\gamma$ for neutron bound states and  $\\Gamma_{tot} = \\Gamma_\\alpha + \\Gamma_\\gamma + \\Gamma_n$ for neutron unbound states.\n\nAs a result, Eq.\\ref{eq:strength} becomes\n \\begin{equation}\n    \\label{eq:width_n_bound}\n    \\begin{aligned}\n \\omega \\gamma_{(\\alpha,\\gamma)} &= (2J_{res} + 1) \\frac{\\Gamma_\\alpha \\Gamma_\\gamma }{\\Gamma_\\alpha + \\Gamma_\\gamma } \\\\\n                                & \\sim (2J_{res} + 1)\\Gamma_\\alpha\n        \\end{aligned}\n\\end{equation}\nfor neutron bound states. Because of the large Coulomb barrier for $\\alpha$ particles that the approximation $\\Gamma_\\alpha \\ll \\Gamma_\\gamma , \\Gamma_n$ has been made for low energy resonances.\n\n\nSimilarly, we obtain neutron unbound states,\n\\begin{equation}\n    \\label{eq:width_n_unbound1}\n    \\begin{aligned}\n \\omega \\gamma_{(\\alpha,\\gamma)} = (2J_{res} + 1) \\frac{\\Gamma_\\alpha }{1+ \\Gamma_n/\\Gamma_\\gamma }\n        \\end{aligned}\n\\end{equation}\nand\n\\begin{equation}\n    \\label{eq:width_n_unbound2}\n    \\begin{aligned}\n \\omega \\gamma_{(\\alpha,n)} = (2J_{res} + 1) \\frac{\\Gamma_\\alpha }{1+ \\Gamma_\\gamma/\\Gamma_n }\n        \\end{aligned}\n\\end{equation}\n\n\n\nTypically spectroscopic factors  are very sensitive to the choice of optical potentials. However, it has been  shown~\\citep{Fortune2003} that the width $\\Gamma_{exp}$ does not critically depend on the selected potential, owing to  the fact that $\\Gamma_{sp}$ also depends on the potential thus canceling most of the potential dependence, as long as both values are extracted with the same potential. In addition, DWBA calculations for transfer reactions to neutron unbound states use the Vincent-Fortune Method~\\citep{Vincent1970}. In this method the width of the resonance, instead of the spectroscopic factor, is measured by the absolute magnitude of the cross section. Thus the particle width can be determined in the same theoretical framework where the spectroscopic factor is determined.\n\n\n\n\nThe reaction rates of $^{22}$Ne($\\alpha$,n)$^{25}$Mg reaction are calculated by Eq.~\\ref{eq:rate_2} with the parameters taken from the calculation in Talwar $et\\ al.$\\citep{Rashi2016} ,as listed in Table.~\\ref{tb:rate_para}. The lowest-lying known resonance in the direct measurement has been observed at a c.m. energy of E$_\\alpha$ = 702 keV corresponding to an excitation energy in $^{26}$Mg of 11.317 MeV~\\citep{Wolke1989}~\\citep{Jaeger2001}. The reaction rates corresponding to each individual resonances observed in this work has been normalized to this resonance.   Figure~\\ref{fg:rate1} represents the behaviour of the $^{22}$Ne($\\alpha,\\gamma$)$^{25}$Mg reaction rates as a function of the temperature $T_9$ using the individual resonances 533 keV and 702 keV with several possible spin assignments and $\\alpha$-spectroscopic factors obtained in \\citep{Rashi2016}. Each resonance shows  similar behaviour in regards of the contribution to the ($\\alpha$, $\\gamma$) reaction rate.  For $T_9 < $ 0.31, the  four possible 553 keV resonances with different spin-parity assignments listed in Table.~\\ref{tb:rate_para} make the similar  amount of contribution to the reaction rate. With higher temperatures, the contribution of 553 keV with $2^+$ and S = 0.44 drops, along with  553 keV ($2^+$, S=0.21) and 553 keV ($2^+$, S=0.99) resonances. Up until   $T_9 < $ 0.34, 553 keV($1^-$, S=0.36) is still the dominant with respect to the 702 keV resonance.\n\n\\begin{table}[tpb]\n    \\setlength{\\capwidth}{0.7\\textwidth}\n    \\begin{centering}\n       \\caption{Resonance parameters taken from Talwar $et\\ al.$\\citep{Rashi2016} used in the present work for the reaction rate calculation. }\n       \\label{tb:rate_para}\n       \\begin{tabular}{c c c c c c c c}\n       \\toprule\n       \\toprule\n              $E_x$        &    $E_R^{c.m.}$ &  $J^{\\pi}$  &  $S_{\\alpha}$   &    $\\Gamma_{sp}$     &   (2J+1)$\\Gamma_\\alpha$     &    $\\omega\\gamma_{(\\alpha,\\gamma)}$  & $\\omega\\gamma_{(\\alpha,n)}$           \\\\\n              (keV)        &    (keV)       &     &    &  (eV)   &   (eV)  &  (eV)  &   (eV)   \\\\\n             \\hline\n            11167(11)       &    553         &   1$^-$  &  0.36   & 5.00 $\\times$ 10$^{-07}$   & 5.4(7) $\\times$ 10$^{-07}$  & 5.4(7) $\\times$ 10$^{-07}$ & $\\leq$6 $\\times$ 10$^{-08}$   \\\\\n                           &                &   2$^+$  &  0.99   & 8.78 $\\times$ 10$^{-08}$   & 4.4(5) $\\times$ 10$^{-07}$  & 4.4(5) $\\times$ 10$^{-07}$ & $\\leq$ 6 $\\times$ 10$^{-08}$   \\\\\n                            &                 &   1$^-$  &  0.44   & 5.00 $\\times$ 10$^{-07}$   & 6.6(7) $\\times$ 10$^{-07}$  & 6.6(7) $\\times$ 10$^{-07}$ &$\\leq$ 6 $\\times$ 10$^{-08}$   \\\\\n                            &                &   2$^+$  &  0.21   & 8.78 $\\times$ 10$^{-08}$   & 5.3(7) $\\times$ 10$^{-07}$  & 5.3(7) $\\times$ 10$^{-07}$ & $\\leq$6 $\\times$ 10$^{-08}$   \\\\\n               11317(11)       &    702        &   1$^-$  &  0.43   & 1.18 $\\times$ 10$^{-04}$   & 1.5(2) $\\times$ 10$^{-04}$  & 3.7(4) $\\times$ 10$^{-05}$ & 1.2(1)$\\times$ 10$^{-04}$   \\\\\n                            &                  &   2$^+$  &  1.44   & 2.15 $\\times$ 10$^{-05}$   & 1.5(2) $\\times$ 10$^{-04}$  & 3.7(4) $\\times$ 10$^{-05}$ & 1.2(1)$\\times$ 10$^{-04}$   \\\\\n\n             \\hline\n         \\hline\n       \\end{tabular}\n     \\end{centering}\n\\end{table}\n\nDespite of the resonance parameters, the errors of the variables in Eq.~\\ref{eq:rate_2} also affect the magnitude of the values of the calculated reaction rates. According to  Mao~\\cite{Mao1996}, there is a model dependence uncertainty of about 30\\%  in $\\Gamma_\\alpha$ between  different $r_0$ values that are used to calculate the single particle widths in the DWBA model. As shown in Figure.~\\ref{fg:ag_1}, adding the model dependence error of 30\\% to the reaction rates gives the magnitude of the reaction rate of the individual resonance 553 keV with respect to the 702 keV resonance.\n\nAnother uncertainty that may affect the upper limits of the reaction rates comes from the uncertainty of the resonance energies. Talwar\\citep{Rashi2016} measured the ($\\alpha$, n) and ($\\alpha$, $\\gamma$) reaction rates with large error in the resonance energy with respect to the (d,p) measurements (error of 18 keV for the 703 keV resonance, compared to the error of 11 keV in this work). In this work the energy error of the resonance is 11 keV and the best error measured so far is about 3 keV~\\citep{26mgaa2017}. To see how the uncertainty of the resonance energies affect the reaction rates, 3 keV and 18 keV are applied to the calculation, respectively.  As  shown in Fig.~\\ref{fg:ag_2}, the left panel gives the result for the resonance with the error of 18 keV and the right panel shows the error of 3 keV. It is clearly seen that there are   dramatic differences between the larger  and the smaller uncertainties in the resonance energy. This is because   E$_{R}$ is in the exponential term in Eq.~\\ref{eq:rate_2}, which also leads to the fact that the lower reaction rate ratio on the left plot drops to negative at about T$_9$ = 0.25.\n\nIn addition to the 553 keV resonance, in this work 13 resonances are observed between the $\\alpha$ threshold and the lowest observed resonance by the $^{22}$Ne + $\\alpha$ system. Amongst these resonances, contributions from the resonances at 374 keV ($E_x=$ 10.988(11) MeV), 455 keV ($E_x=$ 11.069(10) MeV) and 553  keV ($E_x=$ 11.165(11) MeV)  are not negligible because they are possibly associated with $E_x=$ 10.095(21) MeV, 11.085(8) MeV and 11.167 MeV with $S_{\\alpha}$s obtained in ~\\citep{Rashi}. Their reaction rates to the 702 keV are plotted in Fig.~\\ref{fg:ag_a}. It is shown at For T$_9 <$ 0.3, the 553 keV is the dominant resonance to the ($\\alpha, \\gamma$) rate. When stellar temperature  drops down to about T$_9 <$ 0.23, the 347 keV resonance begins to contribute significantly  to the rate. When T$_9$ keeps going down to about T$_9 <$ 0.18, the 455 keV resonance starts to contribute significantly to the ($\\alpha, \\gamma$) reaction rate, and  the 374 keV resonance gradually replaces the 553 keV and becomes to the dominant resonance in the $^{22}$Ne($\\alpha, \\gamma$)$^{26}$Mg reaction.\n\n\n\n\n\n\n\n%Table~\\ref{tb:res} listed the resonances above the $\\alpha$ threshold and the corresponding parameters observed in this work that contribute to the reaction rates up to E$_\\alpha$ = 703 keV.\n\n\n\n\n\n\n\\begin{figure}[tpb]\n  \\begin{center}\n    \\centerline{\\includegraphics[scale=0.8]{graph/ch6/an_rate}}\n    \\caption{The reaction rate ratio of ($\\alpha$, $\\gamma$) calculated from several possible spin parity assignments of 553 keV resonance ($1^-$, S=0.36), normalized to the 702 keV resonance, the lowest observed resonance from the direct measurement.}\n    \\label{fg:rate1}\n  \\end{center}\n\\end{figure}\n\n\n\n\n\\begin{figure}[tpb]\n  \\begin{center}\n    \\centerline{\\includegraphics[scale=0.8]{graph/ch6/ag_1}}\n    \\caption{The uncertainty band  of the reaction rate ratio of ($\\alpha$, $\\gamma$)   calculated for the 552 keV resonance ($1^-$, S=0.36), normalized to the 702 keV resonance. The colored band represents is the error band of from the model dependent error of  30\\%.}\n    \\label{fg:ag_1}\n  \\end{center}\n\\end{figure}\n\n\n\\begin{figure}[tpb]\n  \\begin{center}\n    \\centerline{\\includegraphics[scale=1.5]{graph/ch6/ag_2}}\n    \\caption{The uncertainty band  of the reaction rate ratio of ($\\alpha$, $\\gamma$)   calculated from the 552 keV resonance ($1^-$, S=0.36), normalized to the 702 keV resonance.  The left panel (a) shows the light blue error band of 18 keV on the 702 keV resonance and the right panel (b) shows the light blue error band of 3 keV. }\n    \\label{fg:ag_2}\n  \\end{center}\n\\end{figure}\n\n\\begin{figure}[tpb]\n  \\begin{center}\n    \\centerline{\\includegraphics[scale=0.8]{graph/ch6/ag_a}}\n    \\caption{The reaction rate ratios of  ($\\alpha$, $\\gamma$) ), calculated from the  374 keV (red line), 455 keV (yellow line) and 553 keV (blue line)  resonances, respectively, normalized to the 702 keV resonance.}\n    \\label{fg:ag_a}\n  \\end{center}\n\\end{figure}\n%\\section{Astrophysical Implication}\n\n\n% % uncomment the following lines,\n% if using chapter-wise bibliography\n%\n% \\bibliographystyle{ndnatbib}\n% \\bibliography{example}\n", "meta": {"hexsha": "c8b6b089b6b5cbdbdefa076d39189f0f87a2005f", "size": 12183, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter6.tex", "max_stars_repo_name": "silverashashash/ND_thesis", "max_stars_repo_head_hexsha": "77e1b9ccf672450958be40c8d01d112cc46747f4", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter6.tex", "max_issues_repo_name": "silverashashash/ND_thesis", "max_issues_repo_head_hexsha": "77e1b9ccf672450958be40c8d01d112cc46747f4", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter6.tex", "max_forks_repo_name": "silverashashash/ND_thesis", "max_forks_repo_head_hexsha": "77e1b9ccf672450958be40c8d01d112cc46747f4", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.2037037037, "max_line_length": 1453, "alphanum_fraction": 0.6673233194, "num_tokens": 3830, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4352718161384436}}
{"text": "\\documentclass[../thesis.tex]{subfiles}\n\n%!TeX spellcheck = en-GB\n\n\\theoremstyle{definition}\n\\newtheorem*{def*}{Definition}\n\n\\begin{document}\n\n\\chapter{Quantum Chaos}\n\\label{chap:quantum-chaos}\n\n\\section{Fundamental notions}\n\nIn this section will briefly present the basic principles of quantum mechanics\nand introduce the concepts which are required for the characterisation of\nenergy spectra.\nWe begin with the concept of the physical state.\nA \\emph{physical state} contains all the information that can be learned\nabout the system.\nWe associate to our physical system a \\emph{Hilbert space}, denoted with\n\\(\\mathbb{H}\\), which will contain all the possible states of the system.\nA vector in the Hilbert space will describe the state of the system\n(more rigorously only the direction of the vector will describe the state\nsince by convention any two vectors that differ only by a constant describe\nthe same physical state). In the Dirac formalism~\\cite{Dirac1967} the vectors in the Hilbert\nspace corresponding to physical states are represented by \\emph{ket vectors},\ndenoted with \\(\\ket{\\Psi}\\). The elements of the dual of the Hilbert space\nare called \\emph{bra vectors} and are denoted with \\(\\bra{\\Psi}\\). Due to the\nisomorphism between the Hilbert space and its dual, the bra vectors equally\ndescribe the physical state and the correspondence between the ket vectors and\nthe bra vectors is given by dual conjugation.\n\n\\subsubsection{The observables postulate}\n\nIn quantum mechanics the properties of the physical system, called \\emph{observables}\nare described by linear hermitian operators.\nAs a result of a measurement, the obtained values of the observable are among\nthe eigenvalues of the associated hermitian operator.\n\n\\subsubsection{The measurement postulate}\n\nLet us consider a physical system in a state described by the state vector\n\\(\\ket{\\Psi} \\in \\mathbb{H}\\) and an observable described by the linear hermitian\noperator \\(A\\). If a measurement of the observable is performed, then following\nthe measurement the system will jump in an uncontrollable manner in one of the\neigenstates of the operator associated with the measured observable and the result\nof the measurement will be given by the corresponding eigenvalue. The probability\nof obtaining a given eigenvalue is given by the square of the absolute value of\nthe scalar product between the final state associated with the given eigenvalue\nand the initial state.\n\n% {\\color{red}discrete / continuous discussion?}\n\n\\subsubsection{Fundamental commutation relations}\n\nIn analogy with classical mechanics, a quantum version of the Poisson\nbrackets can be defined, postulating that they have the same properties\nas the classical Poisson brackets, namely anti-symmetry, linearity, the product\nrule and the Jacobi identity. These properties uniquely define the form\nof the quantum Poisson brackets the commutator of two observables,\n\\(\\comm{A}{B} = AB - BA\\), as being proportional to the quantum Poisson brackets\n\\[\n  \\comm{A}{B} = \\ii \\hbar {\\{A,B\\}}_{QM}.\n\\]\nThus we obtain the fundamental commutation relations in quantum mechanics\n\\begin{align*}\n  \\comm{Q_i}{Q_j} &= 0 \\\\\n  \\comm{P_i}{P_j} &= 0 \\\\\n  \\comm{Q_i}{P_j} &= \\ii \\hbar \\,\\delta_{i,j}.\n\\end{align*}\n\n\\subsubsection{Time evolution postulate}\n\nIn quantum mechanics time is just a parameter and not an observable.\nThe time evolution can be postulated in different ways.\nIf we consider the states as time dependent entities and observables as time\nindependent ones, we can view the time\nevolution as a temporal displacement, similar to a spatial displacement.\nThen we can use the time evolution operator identity\n\\[\n  \\ii \\hbar \\pdv{t} U(t,t_0) = H U(t,t_0)\n\\]\nto derive the Schrödinger equation:\n\\[\n  \\ii \\hbar \\pdv{t} \\ket{\\Psi} = H \\ket{\\Psi}.\n\\]\nIf we consider the states as time independent and the observables as time dependent,\nthen the time evolution of the observables will be given by\n\\[\n  \\ii \\hbar \\dv{t} A(t) = [A(t), H].\n\\]\n\nWe can observe the link between this equation and Hamilton's equations is given\nby the correspondence between the commutator in quantum mechanics and the Poisson\nbracket in classical mechanics, as mentioned in the previous chapter.\n\nThe first approach is called the Schrödinger picture of quantum mechanics, while\nthe second is called the Heisenberg picture. There is also another formulation,\nnamely the interaction picture also named the Dirac picture.\nIn the following we will only consider the Schrödinger picture.\n\nIn the particular case when the Hamiltonian is time-independent, Schrödinger's equation\nreduces to\n\\[\n  H \\ket{\\Psi} = E \\ket{\\Psi},\n\\]\nalso called the time-independent Schrödinger equation and the time evolution of\nthe state is given by\n\\[\n  \\ket{E(t)} = \\ee^{-\\frac{\\ii}{\\hbar} (t-t_0) H} \\ket{E(t_0)}\n             = \\ee^{-\\frac{\\ii}{\\hbar} (t-t_0) E} \\ket{E}.\n\\]\n\nThus if the system is initially in an energy eigenstate, it will remain in the\nsame state, having at most a phase modulation. Such states are called\n\\emph{stationary states}.\n\n\\section{From symmetry to degeneracy}\n\nLet us consider the above mentioned time-independent case. If we suppose that\nthe energy spectrum is discrete,\n\\[\n  H \\ket{\\Psi_i} = E_i \\ket{\\Psi_i}.\n\\]\nIf for an eigenvalue \\(E_i\\) repeats itself for different eigenstates\n\\(\\ket{\\Psi_i}\\) we have what is called a \\emph{degeneracy}. In order to emphasise\nthis, we can use a second index for the eigenvectors, \\(j=1,\\dotsc,m\\), where\n\\(m\\) is the number of times the eigenvalue repeats.\n\nThus for the \\(i\\)-th eigenvalue,\n\\[\n  H \\ket{\\Psi_{i,j}} = E_i \\ket{\\Psi_{i,j}}.\n\\]\n\nIf the Hamiltonian is invariant to a set of unitary transformations,\n\\(T^\\dagger H T = H\\), then this set forms a group since the transformation\ngiven by \\(T T'\\), with \\(T'\\) an arbitrary transformation from the set,\nwill also leave the Hamiltonian invariant.\nSince symmetry operations form a group, the unitary operators which correspond to the\nsymmetries of the Hamiltonian will form a group to which the Hamiltonian is invariant.\nThus,\n\\[\n  T H = T T^\\dagger H T = T T^{-1} H T = H T,\n\\]\nor \\(\\comm{T}{H} = 0\\). We can once again observe how classical mechanics and\nquantum mechanics are linked through the Poisson bracket-commutator structure.\nIn classical mechanics Noether's theorem asserts that to any symmetry of the action\nwill correspond a constant of the motion. This will have a vanishing Poisson bracket\nwith the Hamiltonian. For example, the invariance to rotations around a given\naxis will lead to angular momentum conservation.\n\nSince the operators commute, they share a common set of eigenvectors\n\\[\n  H (T \\ket{\\Psi_i}) = H T \\ket{\\Psi_i} = T H \\ket{\\Psi_i} = T E_i \\ket{\\Psi_i}\n  = E_i (T \\ket{\\Psi_i}).\n\\]\nThus if the Hamiltonian is invariant to the set of unitary transformations\n\\( \\{T_j\\} \\), with \\(j=1,\\dotsc,m\\)\n\\[\n  T_j H \\ket{\\Psi_i} = T E_i \\ket{\\Psi_i} = E_i (T \\ket{\\Psi_i}) = E_i \\ket{\\Psi_{i,j}}\n\\]\nand we will not change the value of the eigenvalue \\(E_i\\) by applying \\(T_j\\),\nwe only transform the eigenstates \\(\\ket{\\Psi_i}\\) to a linear combination\n\\(\\ket{\\Psi_{i,j}}\\).\n\n\n\\section{Level repulsion}\n\nAs is the case with classical mechanics there are few situations in which the\nanalytic solution is known. In order to find approximate solutions we can use\nperturbation theory if we can assume that the Hamiltonian can be viewed as to\nhave a part for which the solutions are known and another part that can\nbe considered a small perturbation. The following concepts are mainly following\nthe notations from~\\cite{Sakurai2011} and the lecture notes~\\cite{Baran,Zus}.\n\nIn the framework of time-independent perturbation theory, we want to obtain\nan approximate solution to the problem\n\\begin{equation}\n  H \\ket{\\Psi^{[j]}} = E_j \\ket{\\Psi^{[j]}}\n\\label{eq:q-pert-th-ex-pr}\n\\end{equation}\nand we consider that the Hamiltonian can be written as \\(H = H_0 + \\lambda V\\),\nwhere the solution to the unperturbed problem\n\\[\n  H_0 \\ket{\\Psi^0_{n\\alpha}} = E_n^0 \\ket{\\Psi^0_{n\\alpha}}\n\\]\nis known and \\( \\alpha \\) gives the degeneracy of the \\(n\\)-th level.\n\nSince the unperturbed eigenvectors form a basis in the Hilbert space, we can\nexpand the perturbed eigenvectors in that basis.\n\\[\n  \\ket{\\Psi^{[j]}} = \\sum_{m,\\beta} c_{m,\\beta}^{[j]} \\ket{\\Psi_{m,\\beta}^0}.\n\\]\nInserting into eq.~\\eqref{eq:q-pert-th-ex-pr} we obtain\n\\[\n  (H_0 + \\lambda V) \\sum_{m,\\beta} c_{m,\\beta}^{[j]} \\ket{\\Psi_{m,\\beta}^0}\n  = \\sum_{m,\\beta} E_j\\, c_{m,\\beta}^{[j]} \\ket{\\Psi_{m,\\beta}^0}.\n\\]\nUsing the solution to the unperturbed problem the above equation becomes\n\\[\n\\sum_{m,\\beta} (E_m^0 + \\lambda V)  c_{m,\\beta}^{[j]} \\ket{\\Psi_{m,\\beta}^0}\n= \\sum_{m,\\beta} E_j\\, c_{m,\\beta}^{[j]} \\ket{\\Psi_{m,\\beta}^0}.\n\\]\n\nTo simplify the discussion we will now consider what happens with two unperturbed\nstates \\(\\ket{\\Psi_1^0}\\) with the energy \\(E_1^0\\) and \\(\\ket{\\Psi_2^0}\\) with\nthe energy \\(E_2^0\\) when \\(\\lambda=1\\).\n\n\\[\n\\sum_{m,\\beta} (E_m^0 + V)  c_{m}^{[j]} \\ket{\\Psi_{m}^0}\n= \\sum_{m=1,2} E_j\\, c_{m}^{[j]} \\ket{\\Psi_{m}^0}\n.\\]\n\nBy taking the scalar product with the state \\(\\bra{\\Psi_{k}^0}\\) and using the\northogonality relation\n\\(\\braket{\\Psi_{k}^0}{\\Psi_{m}^0} = \\delta_{k,m}\\)\nwe obtain\n\\[\nE_k^0\\, c_{k}^{[j]} + \\sum_{m=1,2} \\bra{\\Psi_{k}^0} V \\ket{\\Psi_{m}^0} c_{m}^{[j]}\n= E_j\\, c_{k}^{[j]},\n\\]\nor\n\\[\n  c_{k}^{[j]} \\left( E_k^0 - E_j + V_{k,k} \\right) + \\sum_{m \\neq k} V_{k,m}\\, c_{m}^{[j]} = 0,\n\\]\nwhere \\(\\bra{\\Psi_{k}^0} V \\ket{\\Psi_{m}^0} \\equiv V_{k,m}\\).\n\nThe above equation becomes\n\\begin{align*}\n  (E_1^0 - E_j + V_{1,1})\\, c_1^{[j]} + V_{1,2}\\, c_2^{[j]} = 0, \\text{ for } k=1 \\\\\n  V_{2,1}\\, c_1^{[j]} + (E_2 - E_j + V_{2,2})\\, c_2^{[j]} = 0, \\text{ for } k=2.\n\\end{align*}\nWe use the following notations:\n\\[\n  H_{1,1} \\equiv E_1^0 + V_{1,1}, H_{2,2} \\equiv E_2^0 + V_{2,2}, H_{1,2} \\equiv V_{1,2},\n  H_{2,1} \\equiv V_{2,1}, \\delta \\equiv H_{1,1} - H_{2,2}, \\tan{\\beta} \\equiv \\frac{2\\abs{H_{1,2}}}{\\delta}.\n\\]\n\nThe above system of equations has non-trivial solutions if the determinant vanishes.\n\\[\n  (H_{1,1} - E_j)(H_{2,2} - E_j) - H_{1,2} H_{2,1} = 0\n\\]\nor\n\\[\n  E_j^2 - (H_{1,1} + H_{2,2}) E_j + H_{1,1} H_{2,2} - H_{1,2} H_{2,1} = 0.\n\\]\nThis equation has the solutions\n\\begin{align}\n  E_j &= \\frac{(H_{1,1} + H_{2,2}) \\pm\n         \\sqrt{ {(H_{1,1} + H_{2,2})}^2 - 4(H_{1,1} H_{2,2} - H_{1,2} H_{2,1})}}{2} \\\\\n      &= \\frac{H_{1,1} + H_{2,2}}{2} \\pm \\frac{1}{2} \\sqrt{\\delta^2 + 4 \\abs{H_{1,2}}^2}.\n\\label{eq:lvl-repulsion-e}\n\\end{align}\n\nSince \\((H_{1,1} - E_j)\\, c_1^{[j]} + H_{1,2}\\, c_2^{[j]} = 0\\),\n\\[\n  \\frac{c_1^{[j]}}{c_2^{[j]}} = \\frac{H_{1,2}}{E_j - H_{1,1}}.\n\\]\nIf we rewrite eq.~\\eqref{eq:lvl-repulsion-e} as\n\\[\n  E_j = \\frac{1}{2} \\left[ H_{1,1} + H_{2,2} \\mp (H_{2,2} - H_{1,1})\n        \\sqrt{1 + \\frac{4\\abs{H_{1,2}}^2}{\\delta^2}}\\right]\n\\]\nwe obtain\n\\[\n  \\frac{c_1^{[j]}}{c_2^{[j]}} = \\frac{2 H_{1,2}}{H_{2,2} - H_{1,1}}\n  \\left[ 1 \\mp \\sqrt{1 + \\frac{4\\abs{H_{1,2}}^2}{\\delta^2}} \\right]^{-1}\n  = -\\tan{\\beta}\\left(1 \\mp \\sqrt{1+\\tan^2\\beta}\\right).\n\\]\nThis ratio can be also expressed as\n\\begin{align*}\n  \\frac{c_1^{[j]}}{c_2^{[j]}} &= \\frac{-\\tan{\\beta}}{1 \\mp \\frac{1}{\\cos{\\beta}}}\n  = \\frac{-\\sin{\\beta}}{\\cos{\\beta} \\mp 1} \\\\\n  &= \\frac{-2\\sin{\\frac{\\beta}{2}} \\cos{\\frac{\\beta}{2}}}\n      {\\cos^2{\\frac{\\beta}{2}} - \\sin^2{\\frac{\\beta}{2}} \\mp\n        \\left(\\cos^2{\\frac{\\beta}{2}} + \\sin^2{\\frac{\\beta}{2}}\\right)}\n  =\n  \\begin{cases}\n    \\cot{\\frac{\\beta}{2}} \\\\\n    -\\tan{\\frac{\\beta}{2}}\n  \\end{cases}.\n\\end{align*}\nThus,\n\\begin{align*}\n  \\ket{\\Psi^{[1]}} &= \\cos{\\frac{\\beta}{2}} \\ket{\\Psi_1^0} + \\sin{\\frac{\\beta}{2}} \\ket{\\Psi_2^0} \\\\\n  \\ket{\\Psi^{[2]}} &= -\\sin{\\frac{\\beta}{2}} \\ket{\\Psi_1^0} + \\cos{\\frac{\\beta}{2}} \\ket{\\Psi_2^0}.\n\\end{align*}\n\nIf the matrix elements of the interaction which mix distinct states are relatively small,\nthat is \\(\\abs{H_{1,2}} \\ll \\delta \\), \\(\\beta \\simeq 0\\)\n\\[\n  E_{1,2} = \\frac{H_{1,1} + H_{2,2}}{2} \\pm\n            \\frac{\\delta}{2} \\sqrt{1 + \\frac{4 \\abs{H_{1,2}}^2}{\\delta^2}}\n\\]\nThus\n\\[\n  E_1 \\simeq H_{1,1} + \\frac{\\abs{H_{1,2}}^2}{\\delta}\n\\]\nand\n\\[\n  E_2 \\simeq H_{2,2} - \\frac{\\abs{H_{1,2}}^2}{\\delta}.\n\\]\nand the perturbed energy levels are close to the unperturbed ones.\nThe states will also be approximatively the unperturbed ones\n\\begin{align*}\n  \\ket{\\Psi^{[1]}} &\\simeq \\ket{\\Psi_1^0} \\\\\n  \\ket{\\Psi^{[2]}} &\\simeq \\ket{\\Psi_2^0}.\n\\end{align*}\n\nIf on the other hand, the matrix elements levels which mix distinct states are\nrelatively strong, that is \\(\\abs{H_{1,2}} \\gg \\delta \\), \\(\\beta \\simeq \\frac{\\pi}{2}\\)\n\\[\n  E_{1,2} = \\frac{H_{1,1} + H_{2,2}}{2} \\pm\n            \\sqrt{\\frac{\\delta^2}{4} + \\abs{H_{1,2}}^2}\n          \\simeq \\frac{H_{1,1} + H_{2,2}}{2} \\pm\n          \\left(\\abs{H_{1,2}} + \\frac{\\delta^2}{8\\abs{H_{1,2}}}\\right)\n\\]\nand\n\\begin{align*}\n  \\ket{\\Psi^{[1]}} &\\simeq \\frac{\\sqrt{2}}{2} \\ket{\\Psi_1^0} + \\frac{\\sqrt{2}}{2} \\ket{\\Psi_2^0} \\\\\n  \\ket{\\Psi^{[2]}} &\\simeq -\\frac{\\sqrt{2}}{2} \\ket{\\Psi_1^0} + \\frac{\\sqrt{2}}{2} \\ket{\\Psi_2^0}.\n\\end{align*}\nIn this case we observe that if \\(\\delta \\simeq 0\\),\nthen \\(E_1 - E_2 \\simeq 2\\abs{H_{1,2}}\\). If the unperturbed energy levels were\ndegenerated, then the perturbed energy levels will not remain so. The removal\nof the degeneracy is called \\emph{level repulsion}.\n\nWe can illustrate this phenomena by considering an arbitrary \\(2 \\cross 2\\)\nhermitian matrix and computing its eigenvalues.\n\\[\n  H = \\begin{pmatrix}\n  H_{1,1}   & H_{1,2} \\\\\n  H_{1,2}^* & H_{2,2}\n  \\end{pmatrix}\n\\]\nThe eigenvalues will be given by eq.~\\eqref{eq:lvl-repulsion-e}.\n\nThe first case, \\(\\abs{H_{1,2}} \\ll \\delta \\), can be viewed as the case when\nthe off-diagonal elements are small and the matrix can be approximated with\na diagonal matrix. In this case we expect that the energy levels will be close\nto the diagonal levels or the unperturbed levels. The perturbed eigenstates\nwill also be approximatively equal with the unperturbed eigenstates.\n\nThe level repulsion emphasised by the second case, \\(\\abs{H_{1,2}} \\gg \\delta \\),\ncorresponds to the case when the off-diagonal elements are significant. When we\nexpand the perturbed eigenstates in the basis given by the unperturbed eigenstates\nwe will have significant components from each element in the basis and the new\nstates will be a mixture of the unperturbed states. We can say that the energy levels\nare no longer independent. In the case when the unperturbed energy\nlevels are degenerated, the difference between the perturbed energy levels\nis given by \\(2 \\abs{H_{1,2}}\\), which is a measure of the mixing of the\nunperturbed states.\n\n\n\\section{Probability notions}\n\n\\begin{def*}[Joint probability]\n  Given two events $A$ and $B$, their joint probability, \\(P(A \\cap B)\\), is\n  the probability of the two events to occur simultaneously.\n\\end{def*}\n\n\\begin{def*}[Conditional probability]\n  The conditional probability of an event $A$ given an event $B$ with \\(P(B)>0\\),\n  denoted \\(P(A\\,|\\,B)\\) is given by\n  \\[\n    P(A\\,|\\,B) = \\frac{P(A \\cap B)}{P(B)}.\n  \\]\n\\end{def*}\n\nThe joint probability of $A$ and $B$ can be expressed as\n\\(P(A \\cap B) = P(A\\,|\\,B) P(B)\\).\n\n\\begin{def*}[Continuous random variable]\n  A continuous random variable is a function from the set of all outcomes to the\n  set of real numbers \\(X:\\Omega \\to \\mathbb(R)\\) such that\n  \\[\n    P(a \\leq X(\\omega) \\leq b) = \\int_a^b f(x) \\dd{x},\n  \\]\n  where \\(f(x) \\geq 0\\) and \\(\\int_{-\\infty}^{+\\infty}f(x)\\dd{x}=1\\).\n\\end{def*}\nThe above function \\(f\\) is called the \\emph{probability density function}.\nThe probability for a continuous random variable $X$ to take a value in the\ninfinitesimal interval of length \\(\\dd{x}\\) is given by\n\\begin{equation}\n  \\label{eq:prob-rv-in-int}\n  P(x \\in [x, x + \\dd{x}]) = \\int_x^{x+\\dd{x}} f(z) \\dd{z} \\approx f(x)\\dd{x}\n\\end{equation}\n\n\n\\section{Nearest neighbour distributions}\n\n% \\emph{Random matrices} are matrices which have random variables as elements,\n% with their randomness is restricted by the symmetries of the whole matrix.\n\nNearest neighbour spacing distributions show how the differences\nbetween consecutive energy levels fluctuate around the average.\nIn order to better understand this concept we shall begin with the simpler\ncase of real random numbers as presented in~\\cite{Timberlake2006} and then\ncontinue with a general case as in~\\cite{Brody1981}.\n\n\\subsection{The nearest neighbour spacing distribution of random numbers}\n\nWe consider a sequence of uniformly distributed, ordered, real, random numbers.\nWe define the \\emph{spacing} of an ordered sequence as the sequence of\ndifferences between consecutive elements.\nFor an interval of length \\(s, s>0\\), we will denote with \\( P(n \\in s) \\) the probability\nfor the interval to contain $n$ numbers and with \\( P(n \\in \\dd{s} |\\; m \\in s) \\)\nthe conditional probability for the interval of length \\( \\dd{s} \\) to contain\n$n$ numbers given that the interval of length $s$ contains $m$ numbers.\n\nIf $E$ is a given number in the sequence, we are interested in the probability\n\\( P(s)\\dd{s} \\) to have the next number between \\( E+s \\) and \\( E+s+\\dd{s} \\).\nSince we are interested in the next number after $E$, we know that in the\ninterval of length $s$ there is no other number and the next number is somewhere\nin the infinitesimal interval \\(\\dd{s}\\). Thus the joint probability of\nthe events \\(1 \\in \\dd{s}\\) and \\(0 \\in s\\) is given by:\n\\begin{equation}\n  \\label{eq:jpr-next}\n  P(s)\\dd{s} = P(1 \\in \\dd{s} |\\; 0 \\in s) P(0 \\in s).\n\\end{equation}\n\nSince random numbers are not correlated, the probability of a random number to be found\nin the interval \\( \\dd{s} \\) does not depend on the number of random numbers in $s$, so\n\\[\n  P(1 \\in \\dd{s} |\\; 0 \\in s) = P(1 \\in \\dd{s}).\n\\]\n\nThe random numbers are uniformly distributed, so their probability density function\n\\(f\\) is a constant. Hence, according to eq.~\\eqref{eq:prob-rv-in-int}, the probability\nof finding a number in the interval of length \\( \\dd{s} \\) is given by\n\\[\n  P(1 \\in \\dd{s}) \\equiv P(1 \\in [0, 0+\\dd{s}]) \\approx f(s) \\dd{s} \\sim \\dd{s}.\n\\]\nIf we denote the constant probability density function with $a$\n\\[\n  P(s)\\dd{s} = a \\dd{s} P(0 \\in s).\n\\]\n\\( P(0 \\in s) \\) can be expressed using the complementary probability as\n\\( {1 - \\int_0^s P(s') \\dd{s'}} \\). Now we can express \\( P(s)\\dd{s} \\) as follows:\n\\[\n  P(s)\\dd{s} = a \\dd{s} \\left( 1 - \\int_0^s P(s') \\dd{s'} \\right).\n\\]\n\nIn order to differentiate with respect to $s$, we will use the Leibniz rule\nfor differentiating integrals, namely\n\\begin{equation}\n  \\label{eq:leibnitz}\n  \\dv{x} \\int\\limits_{G(x)}^{H(x)} F(x, t) \\dd{t} = \\int\\limits_{G(x)}^{H(x)} \\pdv{F}{x} \\dd{t}\n  + F(x, H(x))\\, \\dv{H}{x} - F(x, G(x))\\, \\dv{G}{x}\n\\end{equation}\n\nUsing this rule, we obtain\n\\[\n  \\dv{s}P(s) = -aP(s).\n\\]\nThis differential equation can be solved by separation of variables, yielding\n\\[\n  P(s) = \\mathcal{C} \\ee^{-as}\n\\]\nIn order to determine the constant \\(\\mathcal{C}\\), we use the normalisation condition\nfor the probability density function\n\\[\n  \\int_{-\\infty}^{\\infty} P(s) \\dd{s} = 1\n\\]\nSince \\(s>0\\), this reduces to\n\\[\n  \\int_{0}^{\\infty} P(s) \\dd{s} = \\int_{0}^{\\infty} \\mathcal{C} \\ee^{-as} \\dd{s}\n  = -\\frac{\\mathcal{C}}{a} \\eval{\\ee^{-as}}_0^{\\infty} = \\frac{\\mathcal{C}}{a}\n\\]\nThus \\(\\mathcal{C} = a\\) and \\(P(s) = a \\ee^{-as}\\).\nWe can further simplify the formula if we set that the average spacing to unity.\nThe average spacing is given by\n\\[\n  \\mean{s} = \\int_{0}^{\\infty} s P(s) \\dd{s}\n  = -\\int_{0}^{\\infty} s \\dv{s} \\left( \\ee^{-as} \\right) \\dd{s}\n  = \\int_{0}^{\\infty} \\ee^{-as} \\dd{s} = \\frac{1}{a},\n\\]\nso setting it to unity results in \\(a=1\\).\nThus the probability density function becomes\n\\begin{equation}\n  \\label{eq:poisson-dist}\n  P(s) = \\ee^{-s}.\n\\end{equation}\nThis function is known as the \\emph{Poisson distribution}.\n\n\\subsection{The Wigner distribution}\n\nWe will now consider a more complicated situation, by considering the\nprobability density function for the sequence of random numbers to be arbitrary.\n\nWe can start from eq.~\\eqref{eq:jpr-next} since the discussion up to that point\ndid not include any details related to the distribution of the random numbers.\n\nIn this case \\(P(1 \\in \\dd{s} |\\; 0 \\in s) = f_{1,0}(s) \\dd{s}\\), where\n\\(f_{n,m}(s)\\) is function which describes how the probability of having $n$\nnumbers in \\(\\dd{s}\\) is influenced by the $m$ numbers in $s$.\nThus\n\\[\n  P(s)\\dd{s}=f_{1,0}(s)\\dd{s} \\left( 1 - \\int_0^s P(s') \\dd{s'} \\right)\n\\]\nBy solving\n% {\\color{red}\\large????}\nthis integral equation, we obtain the solution\n\\[\n  P(s) = \\mathcal{C} f_{1,0}(s) \\exp(-\\int_0^s f_{1,0}(x) \\dd{x})\n\\]\nWe observe that if we take the probability density function constant,\n\\(f_{1,0}(s) = \\frac{1}{a}\\), we obtain the above case of the Poisson distribution.\nFor a\n% {\\color{red}linear (why?)}\nprobability density function,\n\\(f_{1,0}(s) = \\alpha s\\) we obtain\n\\[\n  P(s) = \\mathcal{C} \\alpha s \\exp(-\\alpha \\frac{s^2}{2})\n\\]\nFrom the normalisation condition we obtain\n\\[\n  \\int_{0}^{\\infty} P(s) \\dd{s} = \\mathcal{C} = 1\n\\]\nThe average spacing is given by\n\\[\n  \\mean{s} = \\int_{0}^{\\infty} s P(s) \\dd{s}\n  = \\alpha \\int_{0}^{\\infty} s^2 \\exp(-\\alpha \\frac{s^2}{2}) \\dd{s}\n  = \\frac{1}{\\sqrt{\\alpha}} \\sqrt{\\frac{\\pi}{2}}.\n\\]\nIf we set the average spacing to unity, we obtain \\(\\alpha = \\frac{\\pi}{2}\\)\nand\n\\[\n  P(s) = \\frac{\\pi}{2} s \\exp(-\\frac{\\pi}{4} s^2)\n\\]\nThis function is known as the \\emph{Wigner distribution}.\n\n\\section{From Classical Chaos to Quantum Chaos}\n\nThe classical concept of sensitivity to initial conditions loses its meaning\nin the quantum realm since the trajectory cannot be defined due to\nHeisenberg's uncertainty principle. However, there are some other\nways in which we can link classically chaotic dynamics to quantum features.\nThese bridges between classical mechanics and quantum\nmechanics allows us to give a meaning to quantum chaos~\\cite{Berry1989}.\n\n% In the terms of classical mechanics, such as the sensitivity to initial conditions\n% quantum chaos does not exist~\\cite{Berry1989} because of the Heisenberg's uncertainty principle,\n% the absence of trajectories and many other reasons. In turn, there are some other\n% ways in which we can link classically chaotic systems to their\n% quantum counterparts. These bridges between classical mechanics and quantum\n% mechanics allows us to give a meaning to quantum chaos.\n% {\\color{red} (Berry $\\to$ quantum chaology)}\n\nSpecifically, there are two important conjectures that allow us to connect\nclassical systems and quantum systems as mentioned above.\n\n\\subsubsection{The Berry-Tabor conjecture}% {\\color{red}(or theorem?)}}\n\nThis conjecture states that the quantum counterpart of a classically integrable\nsystem has a Poissonian nearest neighbour distribution.\n\n\\subsubsection{The Bohigas-Gianoni-Schmit conjecture}\n\nThis conjecture states that the nearest neighbour distribution of a quantum system\nwith a classically chaotic counterpart is given by the Wigner distribution.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "57d287b2e1f50199911df9366bf694e11994d115", "size": 22928, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/Quantum_Chaos/q_chaos.tex", "max_stars_repo_name": "SebastianM-C/Bachelor-Thesis", "max_stars_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-19T23:15:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T23:15:42.000Z", "max_issues_repo_path": "Manuscript/Quantum_Chaos/q_chaos.tex", "max_issues_repo_name": "SebastianM-C/Bachelor-Thesis", "max_issues_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manuscript/Quantum_Chaos/q_chaos.tex", "max_forks_repo_name": "SebastianM-C/Bachelor-Thesis", "max_forks_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-19T23:15:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-19T23:15:46.000Z", "avg_line_length": 40.4373897707, "max_line_length": 108, "alphanum_fraction": 0.6855809491, "num_tokens": 7520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934765, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.4352574519718648}}
{"text": "\\problemname{H-Index}\n\n%% Image URL: https://www.pexels.com/photo/black-pen-on-white-book-page-159621/ \n%% Image License: https://www.pexels.com/photo-license/\n\n\\illustration{0.33}{books.jpg}{~}\n\nIn research, it is tough to determine how good of a researcher you are. One way that people determine how good you are is by looking at your \\textit{$H$-Index}.\n\nEach paper has a certain number of citations. Your $H$-Index is the largest number $H$ such that you have $H$ papers with at least $H$ citations. Given the number of citations on each paper you have written, what is your $H$-Index?\n\n\\section*{Input}\n\nThe first line of input contains a single integer $n$~($1 \\leq n \\leq 100\\,000$), which is the number of papers you have written.\n\nThe next $n$ lines describe the papers. Each of these lines contains a single integer $c$~($0 \\leq c \\leq 1\\,000\\,000\\,000$), which is the number of citations that this paper has.\n\n\\section*{Output}\n\nDisplay your $H$-Index.\n", "meta": {"hexsha": "b205b8a2bd9e9eb5cb6b833694a2b5009521f06c", "size": 964, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problems/hindex/problem_statement/problem.tex", "max_stars_repo_name": "icpc/na-rocky-mountain-2018-public", "max_stars_repo_head_hexsha": "416a94258f99ab68ff7d9777faca55c94cdaf5f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-22T16:34:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T16:34:26.000Z", "max_issues_repo_path": "problems/hindex/problem_statement/problem.tex", "max_issues_repo_name": "icpc/na-rocky-mountain-2018-public", "max_issues_repo_head_hexsha": "416a94258f99ab68ff7d9777faca55c94cdaf5f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problems/hindex/problem_statement/problem.tex", "max_forks_repo_name": "icpc/na-rocky-mountain-2018-public", "max_forks_repo_head_hexsha": "416a94258f99ab68ff7d9777faca55c94cdaf5f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.9047619048, "max_line_length": 231, "alphanum_fraction": 0.7302904564, "num_tokens": 270, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.43525744906685016}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\n\\onlyinsubfile{\n\\title{NeuroData SIMPLEX Report: Subfile}\n}\n\n\\begin{document}\n\\onlyinsubfile{\n\\maketitle\n\\thispagestyle{empty}\n\nThe following report documents the progress made by the labs of Randal~Burns and Joshua~T.~Vogelstein at Johns Hopkins University towards goals set by the DARPA SIMPLEX grant.\n\n%%%% Table of Contents\n\\tableofcontents\n\n%%%% Publications\n\\bibliographystyle{IEEEtran}\n\\begin{spacing}{0.5}\n\\section*{Publications, Presentations, and Talks}\n%\\vspace{-20pt}\n\\nocite{*}\n{\\footnotesize\t\\bibliography{simplex}}\n\\end{spacing}\n%%%% End Publications\n}\n\n\\subsection{Robust Law of Large Graphs}\n\nTo estimate the mean of a collection of weighted graphs under a\nlow rank random graph model (e.g. Stochastic Blockmodel) when\nobserving contaminated graphs, we propose an estimator which not\nonly inherits robustness from element-wise robust estimators but\nalso has small variance due to application of a rank-reduction\nprocedure. Under appropriate conditions, we prove that our\nestimator outperforms standard estimators via asymptotic relative\nefficiency.  Previously we illustrated our theory and methods by Monte\nCarlo simulation. And now we focus on the real data experiment.\n\n\nThe real data we consider is a structural connectomic data.\nThe graphs are based on diffusion tensor MR\nimages. It contains 114 different brain scans, each of\nwhich was processed to yield an undirected, weighted graph with no\nself-loops, using the m2g/ndmg pipelines.  The vertices of the graphs\nrepresent different regions in the brain defined according to an atlas.\nWe used the  desikan atlas with 70 vertices. The weight of an edge\nbetween two vertices represents the number of white-matter tract\nconnecting the corresponding two regions of the brain.\nAs we know, ndmg is a better pipeline compared to m2g, which means that the mean graph derived from ndmg should be a more accurate estimate to actual population mean graph.\nIn order to evaluate the performance of the four estimators, we build estimates based on the samples from m2g, while using the sample mean graph from ndmg as an estimate of the probability matrix $P$.\nSpecifically, each Monte Carlo replicate corresponds to sampling $m$ graphs out\nof the 114 from the m2g dataset and computing the four estimates based on the $m$ sampled graphs.\nWe then compared these estimates to the sample mean for the 114 graphs from the ndmg dataset.\nWe ran 100 simulations for the sample sizes $m=2, 5, 10$.\nWe also considered all possible dimensions for adjacency spectral embedding by ranging d from 1 to 70 in\norder to investigate the impact of the dimension selection procedures.\nWe plot the result in figure~\\ref{fig:robDim}\n\n\n\n\\begin{figure}[h!]\n\\begin{cframed}\n\\centering\n\\includegraphics[width=\\textwidth]{../../figs/CCI_m2g_ndmg_Weighted_q_0.9_EIG.png}\n\\caption{\n{\\bf Comparison of MSE of the four estimators for the desikan atlases at three sample sizes based on m2g and ndmg pipelines.}  \n{\\bf 1. MLE (horizontal solid line) vs MLqE (horizontal dotted line):} \nML$q$E outperforms MLE since robust estimators are always preferred in practice;\n{\\bf 2. MLE (horizontal solid line) vs MLE\\_ASE (dashed line):} MLE\\_ASE wins the bias-variance tradeoff when embedded into a proper dimension; \n{\\bf 3. MLqE (horizontal dotted line) vs ML$q$E\\_ASE (dashed dotted line):}\nML$q$E\\_ASE wins the bias-variance tradeoff when embedded into a proper dimension; \n{\\bf 4.  ML$q$E\\_ASE (dashed dotted line) vs MLE\\_ASE (dashed\nline):}\nMLqE\\_ASE is better, since it inherits the robustness from \nML$q$E. And the square and circle represent the dimensions selected by the Zhu and Ghodsi method. We can see it does a pretty good job. But more importantly, a wide range of dimensions could lead to an improvement.\n}\n\\label{fig:robDim}\n\\end{cframed}\n\\end{figure}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "fc72407f4f9ad5d0df92654a768a7c916268aa0b", "size": 3942, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2017-01/robustLOLG.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2017-01/robustLOLG.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2017-01/robustLOLG.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3103448276, "max_line_length": 214, "alphanum_fraction": 0.7889396246, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.43525744906685016}}
{"text": "\\providecommand{\\main}{..}\n\\documentclass[\\main/thesis.tex]{subfiles}\n\\begin{document}\n\\chapter{Constructions}\\label{constructions}\n\nThe representation for positional numeral systems will be constructed and\nformalized with Agda in this section,\nalong with the generalizations introduced in section~\\ref{generalizations}.\n\n\\begin{itemize}\n    \\item \\textbf{base}: the base of a numeral system, denoted {\\lstinline|b|}.\n    \\item \\textbf{\\#digit}: the number of digits, denoted {\\lstinline|d|}.\n    \\item \\textbf{offset}: the number where the digits starts from, denoted {\\lstinline|o|}.\n\\end{itemize}\n\n\\subfile{\\main/tex/constructions/digit.tex}\n\\subfile{\\main/tex/constructions/num.tex}\n\\subfile{\\main/tex/constructions/maximum.tex}\n\\subfile{\\main/tex/constructions/bounded.tex}\n\n\\subfile{\\main/tex/constructions/next.tex}\n\\subfile{\\main/tex/constructions/increment.tex}\n\\subfile{\\main/tex/constructions/continuous.tex}\n\\subfile{\\main/tex/constructions/fromnat.tex}\n\\subfile{\\main/tex/constructions/addition.tex}\n\n\n% \\subsection{Maximum}\n%\n%\n%\n% \\section{Conclusions}\\label{conclusions}\n\n\\end{document}\n", "meta": {"hexsha": "b0a484b03a4635fa9637d3f0f37420bb6387f311", "size": 1103, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/tex/constructions.tex", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Thesis/tex/constructions.tex", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/tex/constructions.tex", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 31.5142857143, "max_line_length": 92, "alphanum_fraction": 0.7660924751, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.4352574392721748}}
{"text": "% NB: use pdflatex to compile NOT pdftex.  Also make sure youngtab is\n% there...\n\n% converting eps graphics to pdf with ps2pdf generates way too much\n% whitespace in the resulting pdf, so crop with pdfcrop\n% cf. http://www.cora.nwra.com/~stockwel/rgspages/pdftips/pdftips.shtml\n\n\n\n\n\\documentclass[10pt,aspectratio=169,dvipsnames]{beamer}\n\n\\usetheme[color/block=transparent]{metropolis}\n\n\\usepackage[absolute,overlay]{textpos}\n\\usepackage{booktabs}\n\\usepackage[utf8]{inputenc}\n\n\n\\usepackage[scale=2]{ccicons}\n\n\\usepackage[official]{eurosym}\n\n%use this to add space between rows\n\\newcommand{\\ra}[1]{\\renewcommand{\\arraystretch}{#1}}\n\n\n\\setbeamerfont{alerted text}{series=\\bfseries}\n\\setbeamercolor{alerted text}{fg=Mahogany}\n\\setbeamercolor{background canvas}{bg=white}\n\n\n\\newcommand{\\R}{\\mathbb{R}}\n\n\\def\\l{\\lambda}\n\\def\\m{\\mu}\n\\def\\d{\\partial}\n\\def\\cL{\\mathcal{L}}\n\\def\\co2{CO${}_2$}\n\n\n\\def\\bra#1{\\left\\langle #1\\right|}\n\\def\\ket#1{\\left| #1\\right\\rangle}\n\\newcommand{\\braket}[2]{\\langle #1 | #2 \\rangle}\n\\newcommand{\\norm}[1]{\\left\\| #1 \\right\\|}\n\\def\\corr#1{\\Big\\langle #1 \\Big\\rangle}\n\\def\\corrs#1{\\langle #1 \\rangle}\n\n\n\n% for sources http://tex.stackexchange.com/questions/48473/best-way-to-give-sources-of-images-used-in-a-beamer-presentation\n\n\\setbeamercolor{framesource}{fg=gray}\n\\setbeamerfont{framesource}{size=\\tiny}\n\n\n\\newcommand{\\source}[1]{\\begin{textblock*}{5cm}(10.5cm,8.35cm)\n    \\begin{beamercolorbox}[ht=0.5cm,right]{framesource}\n        \\usebeamerfont{framesource}\\usebeamercolor[fg]{framesource} Source: {#1}\n    \\end{beamercolorbox}\n\\end{textblock*}}\n\n\\usepackage{hyperref}\n\n\n\\usepackage{tikz}\n\\usetikzlibrary{arrows.meta}\n\n\n\\usepackage[europeanresistors,americaninductors]{circuitikz}\n\n\n%\\usepackage[pdftex]{graphicx}\n\n\n\\graphicspath{{graphics/}}\n\n\\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg,.gif}\n\n\n\n\\def\\goat#1{{\\scriptsize\\color{green}{[#1]}}}\n\n\n\n\\let\\olditem\\item\n\\renewcommand{\\item}{%\n\\olditem\\vspace{5pt}}\n\n\\title{Energy System Modelling\\\\ Summer Semester 2020, Lecture 4}\n%\\subtitle{---}\n\\author{\n  {\\bf Dr. Tom Brown}, \\href{mailto:tom.brown@kit.edu}{tom.brown@kit.edu}, \\url{https://nworbmot.org/}\\\\\n  \\emph{Karlsruhe Institute of Technology (KIT), Institute for Automation and Applied Informatics (IAI)}\n}\n\n\\date{}\n\n\\titlegraphic{\n  \\vspace{0cm}\n  \\hspace{10cm}\n    \\includegraphics[trim=0 0cm 0 0cm,height=1.8cm,clip=true]{kit.png}\n\n\\vspace{5.1cm}\n\n  {\\footnotesize\n\n  Unless otherwise stated, graphics and text are Copyright \\copyright Tom Brown, 2020.\n  Graphics and text for which no other attribution are given are licensed under a\n  \\href{https://creativecommons.org/licenses/by/4.0/}{Creative Commons\n  Attribution 4.0 International Licence}. \\ccby}\n}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\begin{frame}\n\n  \\frametitle{Table of Contents}\n  \\setbeamertemplate{section in toc}[sections numbered]\n  \\tableofcontents[hideallsubsections]\n\\end{frame}\n\n\n\n\\section{3-node example from last time}\n\n\n\\begin{frame}\n  \\frametitle{Solving 3-node example}\n\n  Last time we looked at an example where energy conservation at each\n  vertex (Kirchhoff's Current Law, KCL) was not enough information to\n  solve the power flow, since there are multiple paths in the network.\n  Assume equal reactances $x_\\ell = x$ on each edge.\n\n  \\vspace{.3cm}\n\n  \\begin{columns}\n    \\column[c]{.5\\textwidth}\n\n\n    \\centering\n\n  %https://tex.stackexchange.com/questions/270543/draw-a-graph-in-latex-with-tikz\n  \\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=yellow}]\n      \\node (1) at (0,3) {$+6$};\n      \\node (2) at (3,3) {$0$};\n      \\node (3) at (1.5,0) {$-6$};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=red,very thick}]\n      \\path [->] (1) edge node {$?$} (2);\n      \\path [->] (2) edge node {$?$} (3);\n      \\path [->] (3) edge node {$?$} (1);\n    \\end{scope}\n  \\end{tikzpicture}\n\n\n      \\column[c]{.5\\textwidth}\n\n      Formalise by labelling the nodes and edges:\n\n      \\vspace{.5cm}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (1) at (0,2.5) {1};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {3} (1);\n    \\end{scope}\n  \\end{tikzpicture}\n\n      \\vspace{.5cm}\n\nWe have $p_i = (6,0,-6)$. (Check $\\sum_i p_i = 0$.)\n\nGoal is to find $f_\\ell$ for $\\ell = 1,2,3$.\n\n  \\end{columns}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Solving 3-node example: Kirchhoff's Current Law (KCL)}\n  \\begin{columns}\n\n      \\column[c]{.5\\textwidth}\n\n      \\vspace{.2cm}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (1) at (0,2.5) {1};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {3} (1);\n    \\end{scope}\n  \\end{tikzpicture}\n\n      \\vspace{.3cm}\n\n      Kirchhoff's Current Law gives us:\n  \\begin{equation*}\n    p_i = \\sum_\\ell K_{i\\ell} f_\\ell \\hspace{2cm} \\forall i\n  \\end{equation*}\n\n  The incidence matrix $K$ is given by:\n        \\begin{equation*}\n\\mathbf{K}_{i \\ell}=\\left(\\begin{matrix}\n 1 & 0 & -1\\\\\n -1 & 1 & 0\\\\\n 0 & -1 & 1\n\\end{matrix}\\right)\n\\end{equation*}\n      \\column[c]{.5\\textwidth}\n        So we get:\n        \\begin{align*}\n          p_1 & = 6 = f_1 - f_3 \\\\\n          p_2 & = 0 = f_2 - f_1 \\\\\n          p_3 & = -6 = f_3 - f_2\n        \\end{align*}\n        Sum of KCL equations is always zero, so\n        reduce to $N-1 = 2$ independent equations:\n        \\begin{align*}\n          6 & = f_1 - f_3 \\\\\n          0 & = f_2 - f_1\n        \\end{align*}\n        Not enough information to solve!\n\n        Need more information from KVL and reactances.\n\n  \\end{columns}\n\\end{frame}\n\n\n\n\n\n\n\\begin{frame}\n  \\frametitle{Solving 3-node example: Kirchhoff's Voltage Law (KVL)}\n  \\begin{columns}\n\n      \\column[c]{.5\\textwidth}\n\n      \\vspace{.2cm}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (1) at (0,2.5) {1};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {3} (1);\n    \\end{scope}\n  \\end{tikzpicture}\n\n      \\vspace{.1cm}\n\n      One formulation of Kirchhoff's Voltage Law gives us $L-N+1$ equations for cycles:\n  \\begin{equation*}\n    \\sum_\\ell C_{\\ell c} x_\\ell f_\\ell = 0 \\hspace{2cm} \\forall c\n  \\end{equation*}\n  The cycle matrix $C$ is given by:\n        \\begin{equation*}\n\\mathbf{C}_{\\ell c}=\\left(\\begin{matrix}\n 1 \\\\\n 1\\\\\n 1\n\\end{matrix}\\right)\n\\end{equation*}\n      \\column[c]{.5\\textwidth}\n        For equal reactances $x_\\ell = x$ we get:\n        \\begin{align*}\n          \\sum_\\ell C_{\\ell 1} x_\\ell f_\\ell = x(f_1 + f_2 + f_3) = 0\n        \\end{align*}\n        Together with KCL equations we now have 3 independent equations for 3 unknowns. Solve:\n        \\begin{align*}\n          f_1 & = 2 \\\\\n          f_2 & = 2 \\\\\n          f_3 & = -4\n        \\end{align*}\n\n  \\end{columns}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Solving 3-node example: Solution}\n\n  \\vspace{.3cm}\n\n  \\begin{columns}\n\n      \\column[c]{.5\\textwidth}\n\n  Solution:\n  \\vspace{.3cm}\n\n    \\centering\n  %https://tex.stackexchange.com/questions/270543/draw-a-graph-in-latex-with-tikz\n  \\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=yellow}]\n      \\node (1) at (0,3) {$+6$};\n      \\node (2) at (3,3) {$0$};\n      \\node (3) at (1.5,0) {$-6$};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=red,very thick}]\n      \\path [->] (1) edge node {$2$} (2);\n      \\path [->] (2) edge node {$2$} (3);\n      \\path [->] (3) edge node {$-4$} (1);\n    \\end{scope}\n  \\end{tikzpicture}\n\n  \\raggedright\n\n      \\column[c]{.5\\textwidth}\n\n      Along 2-edge path reactance is double the 1-edge path, so half as much power flows along the 2-edge path as the 1-edge path.\n\n      \\vspace{.5cm}\n  NB: For directed graph, sign determines direction of flow.\n\n  \\end{columns}\n\\end{frame}\n\n\n\n\n\\section{Full power flow equations}\n\n\n\\begin{frame}\n  \\frametitle{Goal: Understand the physical origin of these equations}\n\n  Last time we said we can (in the linear approximation) express the\n  flow $f_\\ell$ on each line in terms of the voltage angles $\\theta_i$\n  at the nodes for a line $\\ell$ with\n  reactance $x_\\ell$ as\n  \\begin{equation*}\n    f_\\ell = \\frac{\\theta_i - \\theta_j}{x_\\ell} = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell} \\theta_i\n  \\end{equation*}\n   This is a relative of Ohm's Law in DC circuits, $I = \\frac{V_1 - V_2}{R}$.\n\n\n  Now we explain the physics of where this comes from, and the linear approximation\n  that leads to it.\n\n  This is also useful when we consider the synchronisation of\n  oscillators later.\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Alternating Current}\n\n  The majority of electrical power, including what you get out of a\n  wall plug, is transmitted as \\alert{Alternating Current (AC)},\n  i.e. both the voltage and current are sinusoidal waves.\n\n  \\begin{center}\n  \\includegraphics[width=8cm]{738px-Types_of_current}\n  \\end{center}\n\n  [Some power is transmitted as \\alert{Direct Current (DC)} under bodies of water and\n    indeed many electronic devices require DC (must convert AC to DC).]\n  \\source{Wikipedia}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Why alternating current?}\n\n  Battle of currents! Edison versus Westinghouse/Tesla in late 1880s, early 1890s, etc.\n\n  \\url{https://en.wikipedia.org/wiki/War_of_Currents}\n\n  AC won, because it's easy to transform AC to a higher voltage, so\n  you can transmit a given power $P = VI$ with a lower current and thus avoid\n  the $I^2R$ resistive losses in power lines.\n\n  Reason: $\\frac{d}{dt}$ in $\\mathcal{E} = \\frac{d\\Phi}{dt}$; use a\n  solenoid to induce a \\alert{fluctuating} magnetic field in another\n  solenoid with a different number of turns, giving different\n  potential difference.\n\n  Frequency of 50~Hz is uniform across Europe (except for\n  train-electricity, e.g. in Germany 16.7~Hz). 60~Hz in USA, western half of\n  Japan, etc.\n\\end{frame}\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Frankfurt: Home of Long-Distance AC Transmission}\n\n  First long-distance high-voltage alternating-current transmission in 1891 from hydroelectric\n  plant in Lauffen to Frankfurt for the Elektrotechnische Ausstellung (176~km, 15~kV).\n\n  \\begin{columns}[T]\n\\begin{column}{3.5cm}\n  \\includegraphics[trim=0 0cm 0 0cm,width=3.7cm,clip=true]{IEAFrankfurt1891c.jpg}\n\\end{column}\n\\begin{column}{2.5cm}\n  \\includegraphics[trim=0 0cm 0 0cm,width=2.8cm,clip=true]{Drehstromuebertragung_Lauffen-Frankfurt.png}\n\\end{column}\n\\begin{column}{5cm}\n  \\vspace{1cm}\n        \\includegraphics[trim=0 0cm 0 0cm,width=5cm,clip=true]{Lauffen-Frankfurt1891-1991.jpg}\n\\end{column}\n  \\end{columns}\n\n  \\source{Wikipedia}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Sinuisoidal waves}\n\n  The voltage is usually written in terms of the \\alert{angular frequency} $\\omega =\n  2\\pi f$ (radians per second) rather than frequency $f$ (Hertz) and the \\alert{Root-Mean-Squared (RMS)} voltage magnitude $V_{\\textrm{rms}}$\n  \\begin{equation*}\n    V(t) = V_{\\textrm{peak}} \\sin(\\omega t) = \\sqrt{2} V_{\\textrm{rms}} \\sin(\\omega t)\n  \\end{equation*}\n  Similarly for the current we have\n  \\begin{equation*}\n    I(t) = I_{\\textrm{peak}} \\sin(\\omega t - \\varphi) = \\sqrt{2} I_{\\textrm{rms}} \\sin(\\omega t - \\varphi)\n  \\end{equation*}\n  Note that they are not necessarily in phase, $\\varphi \\neq 0$.\n\n  The RMS values are useful because then for the \\alert{average power} with $\\varphi = 0$ we can forget factors of 2\n  \\begin{equation*}\n    \\langle P(t) \\rangle = \\langle V(t)I(t) \\rangle = 2 V_{\\textrm{rms}} I_{\\textrm{rms}} \\langle\\sin^2(\\omega t)\\rangle = V_{\\textrm{rms}} I_{\\textrm{rms}}\n  \\end{equation*}\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Resistive loads}\n\n  For purely \\alert{resistive loads}, e.g. a kettle or an electric heater, we have\n  \\begin{equation*}\n    V(t) = R I(t)\n  \\end{equation*}\n  and thus for a voltage of $V(t) = \\sqrt{2} V_{\\textrm{rms}}\n  e^{j\\omega t}$ (NB: for engineers $j = \\sqrt{-1}$ to avoid confusion\n  with the current $i$) we have\n  \\begin{equation*}\n    I(t) = \\sqrt{2} \\frac{V_{\\textrm{rms}}}{R} e^{j\\omega t} = \\frac{1}{R} V(t)\n  \\end{equation*}\n  or in terms of the RMS value and phase shift\n  \\begin{align*}\n    I_{\\textrm{rms}} & = \\frac{1}{R} V_{\\textrm{rms}} \\\\\n    \\varphi & = 0\n  \\end{align*}\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Resistive loads}\n\n  In terms of the waveforms, the current has no phase shift from the voltage.\n\n  \\centering\n  \\includegraphics[width=11cm]{vi-r.pdf}\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Capacitive loads}\n\n  For purely \\alert{capacitive loads} we have\n  \\begin{equation*}\n       I(t) = C  \\frac{dV(t)}{dt}\n  \\end{equation*}\n  and thus for a voltage of $V(t) = \\sqrt{2} V_{\\textrm{rms}}\n  e^{j\\omega t}$ we get\n  \\begin{equation*}\n    I(t) = \\sqrt{2} j\\omega C V_{\\textrm{rms}} e^{j\\omega t} = j\\omega C V(t)\n  \\end{equation*}\n  or in terms of the RMS value and phase shift\n  \\begin{align*}\n    I_{\\textrm{rms}} & = \\omega C V_{\\textrm{rms}} \\\\\n    \\varphi & = -\\frac{\\pi}{2}\n  \\end{align*}\n  We write $X_{C} = \\frac{1}{\\omega C}$ for the \\alert{capacitive reactance}.\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Capacitive loads}\n\n  Current peaks before the voltage (it \\alert{leads} the voltage),\n  since first charge must accumulate on the plates; once the charge is\n  on the plates, the current drops to zero and the voltage peaks.\n\n  \\begin{columns}\n    \\column[c]{.7\\textwidth}\n  \\includegraphics[width=10cm]{vi-c.pdf}\n    \\column[c]{.3\\textwidth}\n  \\includegraphics[width=4cm]{capacitor.png}\n  \\end{columns}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Inductive loads}\n\n  For purely \\alert{inductive loads}, e.g. a motor during start-up\n  \\begin{equation*}\n    V(t) = L \\frac{d I(t)}{dt}\n  \\end{equation*}\n  and thus for a voltage of $V(t) = \\sqrt{2} V_{\\textrm{rms}}\n  e^{j\\omega t}$ we get\n  \\begin{equation*}\n    I(t) = \\sqrt{2} \\frac{V_{\\textrm{rms}}}{j\\omega L} e^{j\\omega t} = \\frac{1}{j\\omega L}V(t)\n  \\end{equation*}\n  or in terms of the RMS value and phase shift\n  \\begin{align*}\n    I_{\\textrm{rms}} & = \\frac{1}{\\omega L} V_{\\textrm{rms}} \\\\\n    \\varphi & = \\frac{\\pi}{2}\n  \\end{align*}\n  We write $X_{L} = \\omega L$ for the \\alert{inductive reactance}, in analogy to the resistance.\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Inductive loads}\n\n  Now current peaks after the voltage (it \\alert{lags} the voltage),\n  since the flow of current in the solenoid resists the changing voltage.\n\n  \\begin{columns}\n    \\column[c]{.7\\textwidth}\n  \\includegraphics[width=10cm]{vi-l.pdf}\n    \\column[c]{.3\\textwidth}\n  \\includegraphics[width=4cm]{600px-Solenoid_and_Ampere_Law_-_2.png}\n  \\end{columns}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{General loads}\n\n  General loads will have a combination of resistive, capacitive and\n  inductive parts. For an RLC circuit in series the voltage across the\n  components is additive\n  \\begin{equation*}\n    V(t) = R I(t) + L\\frac{dI(t)}{dt} + \\frac{1}{C} \\int_{-infty}^t I(\\tau) d\\tau\n  \\end{equation*}\n  and therefore for a sinuisoidal voltage with angular frequency $\\omega$ we get\n  \\begin{equation*}\n    V(t) = \\left[ R + j\\omega L + \\frac{1}{j\\omega C} \\right] I(t)\n  \\end{equation*}\n  which leads us to define a general complex notion of resistance called \\alert{impedance}\n  \\begin{equation*}\n    Z =  R + j\\omega L + \\frac{1}{j\\omega C} = R + j(X_L - X_C) = R + jX\n  \\end{equation*}\n  where $X$ is the reactance $X = X_L - X_C$.\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Impedances and admittances}\n\n  Thus for a regular sinuisodal setup we have\n  \\begin{equation*}\n    V(t) = ZI(t)\n  \\end{equation*}\n  where the complex \\alert{impedance} takes care both of the relation\n  of the RMS values of the current and the voltage, and their phase\n  difference. We can decompose $Z$ into real resistance $R$ and real reactance $X$\n  \\begin{equation*}\n    Z = R + jX\n  \\end{equation*}\n\n  The inverse impedance, called the \\alert{admittance} is given by\n  \\begin{equation*}\n    Y = \\frac{1}{Z}\n  \\end{equation*}\n  so that\n  \\begin{equation*}\n    I(t) = Y V(t)\n  \\end{equation*}\n  We can also decompose this into real conductance $G$ and real susceptance $B$\n  \\begin{equation*}\n    Y = G + jB\n  \\end{equation*}\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Simple transmission line}\n\n  A simple model for a transmission line $\\ell$ between nodes $i$ and\n  $j$ is a resistance $R$ in series with an (inductive) reactance $X$.\n\n  [Typical values are for a 380~kV overhead transmission line e.g. $R = 0.03$~Ohm/km and $X = 0.3$~Ohm/km.]\n\n  The voltage at each node (compared to ground) is given by $V_i(t) = \\sqrt{2}\n  V_ie^{j(\\omega t + \\theta_i)}$ where $\\theta_i$ is the phase offset\n  for each node and $V_i$ is the RMS voltage magnitude.\n\n  Now the current in the transmission line is given by\n  \\begin{equation*}\n    I(t) = \\frac{1}{R + jX} \\left[ V_j(t) - V_i(t) \\right] =  \\frac{1}{R + jX}\\sqrt{2} V_i e^{j(\\omega t + \\theta_i)} \\left[\\frac{V_j}{V_i} e^{j(\\theta_j - \\theta_i)} - 1\\right]\n  \\end{equation*}\n\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Active versus reactive power}\n\n  Now let's consider the power injection at the first node. This is\n  simply the voltage there multiplied by the current in the\n  transmission line.\n\n  It's convenient to eliminate the time-dependent part $e^{j\\omega t}$\n  by multiplying the voltage with the complex conjugate of the current\n  \\begin{equation*}\n    S = P + jQ = \\frac{1}{2} V(t)I^*(t)\n  \\end{equation*}\n\n  For a resistive load with $V(t) = R I(t)$ this reproduces the\n  \\alert{active power} $P$.\n\n  For loads where the $I(t)$ is not in phase with the voltage, we get\n  a flow of \\alert{reactive power} $Q$.\n\n  $S = P + j Q$ is called the \\alert{apparent power}.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Linearisation: Assumption 1/3}\n\n  Now if we consider the power injected at the first node we get\n  \\begin{equation*}\n    P_i + jQ_i =  \\frac{1}{R + jX} V_i^2\\left[\\frac{V_j}{V_i} e^{j(\\theta_i - \\theta_j)} - 1\\right]\n  \\end{equation*}\n\n  This is the full non-linear equation for the power flow. Now let's\n  linearise by making some simplifying assumptions.\n\n  1. Assume the voltage magnitudes are the same everywhere in the network $V_i = V_j$\n  \\begin{equation*}\n    P_i + jQ_i =  \\frac{1}{R + jX} V_i^2\\left[e^{j(\\theta_i - \\theta_j)} - 1\\right]\n  \\end{equation*}\n  This means \\alert{power flows primarily according to angle differences} in this approximation.\n\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Linearisation: Assumption 2/3}\n\n\n  2. Now assume that the voltage angle differences across the transmission line are small enough that $\\sin(\\theta_i - \\theta_j) \\sim (\\theta_i - \\theta_j)$\n  \\begin{align*}\n    P_i + jQ_i & =  \\frac{1}{R + jX} V_i^2\\left[e^{j(\\theta_i - \\theta_j)} - 1\\right] \\\\\n    & \\sim  \\frac{1}{R + jX} V_i^2\\left[j(\\theta_i - \\theta_j)\\right]\n  \\end{align*}\n\n  This assumption is usually valid, since for stability reasons, we usually have in the transmission network\n  $(\\theta_i - \\theta_j) \\leq \\frac{\\pi}{6}$ (30 degrees).\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Linearisation: Assumption 3/3}\n\n\n  3. Finally we assume $R << X$ so that we can ignore the resistance $R$\n  \\begin{align*}\n    P_i + jQ_i\n    & =  \\frac{1}{R + jX} V_i^2\\left[j(\\theta_i - \\theta_j)\\right] \\\\\n    & \\sim  \\frac{1}{jX} V_i^2\\left[j(\\theta_i - \\theta_j)\\right]\\\\\n    & =  \\frac{V_i^2}{X}(\\theta_i - \\theta_j)\n  \\end{align*}\n\n  Note that ignoring $R$ means that we ignore resistive losses in the transmission lines and also since $Q_i \\sim 0$, we ignore the flow of reactive power. Finally we absorb the voltage into the definition of the \\alert{per unit} reactance $x_\\ell = \\frac{X}{V_i^2}$ to get\n  \\begin{equation*}\n    f_\\ell = P_i = -P_j = \\frac{\\theta_i - \\theta_j}{x_\\ell}\n  \\end{equation*}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Three-phase power}\n\n  Electricity is generally generated simultaneously in\n    3 separate circuits separate by 120 degrees or $\\frac{2\\pi}{3}$\n  \\begin{center}\n  \\includegraphics[width=7cm]{3_phase_AC_waveform}\n  \\end{center}\n\n  In your plug, you only see one phase, but your oven may use all\n  three phases.\n\n  \\source{Wikipedia}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Three-phase power}\n\n  Why three phases? This was settled in the late 1880s.\n\n\n  1. The total power delivery is constant\n  \\begin{equation*}\n    \\frac{d}{dt} P(t) =     \\frac{d}{dt} \\left[P_a(t) + P_b(t) + P_c(t) \\right] = 0\n  \\end{equation*}\n  This reduces mechanical stress on generators and motors.\n\n  2. The sum of voltages and currents is zero, so no return path\n  required! Saving on materials.\n\n  Both facts follow from\n  \\begin{equation*}\n    \\sum_{k=0}^{N-1} e^{j\\frac{2\\pi k}{N}} = 0\n  \\end{equation*}\n  for $N > 1$.\n\n  3. Why $N=3$ rather than $N=2$? Allows directional rotating fields for induction motors (thanks Tesla!).\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Roots of unity for $N=3$}\n\n  For $N=3$, check they add up to zero:\n\n  \\centering\n  \\includegraphics[width=8cm]{f8UGvjRAqV-3rd-roots-of-unity.png}\n\n  \\source{\\href{https://brilliant.org/wiki/roots-of-unity/}{brilliant.org}}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Rotating field in a three-phase induction motor}\n\n  A brilliant insight (credited to Tesla, but the history is\n  \\href{https://en.wikipedia.org/wiki/Induction\\_motor\\#History}{complicated})\n  was that with three-phase power, you can place your wires spaced at\n  $2\\pi/3$ to create a \\alert{rotating} magnetic field\n\n  \\url{https://www.youtube.com/watch?v=LtJoJBUSe28}\n\n  which can then induce a current in a rotor cage, which then\n  experiences a torque thanks to the magnetic field: this is the\n  principle of the \\alert{induction motor}.\n\n  It would not be possible to create such a rotating field with a\n  single-phase or two-phase system.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Three-phase power}\n  \\begin{center}\n  \\includegraphics[width=9cm]{circuit}\n  \\end{center}\n\n  \\source{\\href{https://en.wikipedia.org/wiki/Three-phase_electric_power}{Wikipedia}}\n\n\\end{frame}\n\n\n\n\n\\section{Computing the Linear Power Flow}\n\n\n\\begin{frame}\n  \\frametitle{The goal of power flow analysis}\n\n  \\begin{columns}\n    \\column[c]{.55\\textwidth}\n\n  The goal of a power/load flow analysis is to find the flows in the\n  lines of a network given a power injection pattern at the nodes.\n\n\n    I.e. given power injection at the nodes\n\\begin{equation*}\n\\mathbf{P}_{i}=\\left(\\begin{matrix}\n50 \\\\\n50 \\\\\n0 \\\\\n-100\n\\end{matrix}\\right)\n\\end{equation*}\nwhat are the flows in lines 1-4?\n\n\\vspace{.1cm}\n\nTo find the flows, it is sufficient to know the \\alert{reactances} of\nthe lines $x_\\ell$ and the \\alert{voltages angles} $\\theta_i$ at each node.\n\n\\column[c]{.45\\textwidth}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (4) at (0,2.5) {4};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n      \\node (1) at (4.2,4.2) {1};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {4} (4);\n      \\path [->] (2) edge node {3} (4);\n    \\end{scope}\n  \\end{tikzpicture}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Framing the load flow problem}\n\n  Suppose we have $N$ nodes labelled by $i$, and $L$ edges labelled by\n  $\\ell$ forming a directed graph $G$.\n\n  Suppose at each node we have a \\alert{power imbalance} $p_i$ ($p_i >\n  0$ means its generating more than it consumes and $p_i < 0$ means it\n  is consuming more than it).\n\n  Since we cannot create or destroy energy (and we're ignoring losses):\n  \\begin{equation*}\n    \\sum_i p_i = 0\n  \\end{equation*}\n\n  \\alert{Question}: How do the flows $f_\\ell$ in the network relate to the nodal power\n  imbalances?\n\n  \\alert{Answer}: According to the reactances (generalisation of\n  resistance for oscillating voltage/current) and the corresponding\n  voltages.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Kirchhoff's Current Law (KCL)}\n\n  KCL says (in this linear setting) that the nodal power imbalance at\n  node $i$ is equal to the sum of direct flows arriving at the\n  node. This can be expressed compactly with the incidence matrix\n\n  \\begin{equation*}\n    p_i = \\sum_\\ell K_{i\\ell} f_\\ell \\hspace{2cm} \\forall i\n  \\end{equation*}\n\n\n  Only $N-1$ of these equations are independent for a connected network, since $\\sum_i K_{i\\ell} = 0$.\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Kirchhoff's Voltage Law (KVL)}\n\n  KVL says that the sum of voltage differences across edges for any\n  closed cycle must add up to zero.\n\n  If the voltage angle at any node is given by $\\theta_i$ then the voltage difference across edge $\\ell$ is\n  \\begin{equation*}\n    \\sum_i K_{i\\ell} \\theta_i\n  \\end{equation*}\n\n  And Kirchhoff's law can be expressed using the cycle matrix encoding of independent cycles\n  \\begin{equation*}\n    \\sum_\\ell C_{\\ell c} \\sum_i K_{i\\ell} \\theta_i = 0 \\hspace{2cm} \\forall c\n  \\end{equation*}\n\n  [Automatic, since we already said KC = 0.]\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Kirchhoff's Voltage Law (KVL)}\n\n  Physics gives us the expression of the flow $f_\\ell$ on each line $\\ell$ with reactance $x_\\ell$ in terms of the voltage angles at the nodes $\\theta_i$  (a\n  relative of $V = IR$)\n  \\begin{equation}\n    f_\\ell = \\frac{\\theta_i - \\theta_j}{x_\\ell} = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell} \\theta_i \\label{eq:1}\n  \\end{equation}\n      [NB: This restricts the $L$ variables $f_\\ell$ to depend only on the $N$ voltage angles $\\theta_i$. Since the flow doesn't change under a constant shift $\\theta_i \\to \\theta_i + c$, we can choose   a \\alert{slack} or \\alert{reference node} such that  $\\theta_1 = 0$, so there are only $N-1$ independent variables.]\n\n      \\vspace{.5cm}\n\n\n  KVL now becomes $L-N+1$ binding constraints on the line flows $f_\\ell$\n  \\begin{equation}\n    \\sum_\\ell C_{\\ell c} x_\\ell f_\\ell = 0 \\hspace{2cm} \\forall c  \\label{eq:2}\n  \\end{equation}\n  [NB: Equations \\eqref{eq:1} and  \\eqref{eq:2} are equivalent and both restrict our $L$ variables $f_\\ell$ to an $N-1$ dimensional subspace.]\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Solving the equations via the line flows}\n\n  Now we have $N-1$ equations for the flows $f_\\ell$ from KCL:\n  \\begin{equation*}\n    p_i = \\sum_\\ell K_{i\\ell} f_\\ell \\hspace{2cm}\\forall i \\in \\{ 1, \\dots N-1 \\}\n  \\end{equation*}\n  and $L-N+1$ equations from KVL:\n  \\begin{equation*}\n    \\sum_\\ell C_{\\ell c} x_\\ell f_\\ell = 0 \\hspace{2cm}\\forall c \\in \\{ 1, \\dots L-N+1 \\}\n  \\end{equation*}\n\n  So $L$ independent linear equations for $L$ variables $f_\\ell$.\n\n  Can solve with e.g. LU decomposition using specialised sparse solvers, with polynomial complexity in $L$. (For dense matrices complexity $O(L^a)$ where $2 < a < 3$.)\n\n  This formulation is useful for the optimisation later, but we can solve a smaller dimensional linear system with $N-1$ variables using the voltage angles.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Solving the equations via the voltage angles}\n\n  If we combine\n    \\begin{equation}\n    f_\\ell  = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell} \\theta_i \\label{eq:3}\n  \\end{equation}\n    with Kirchhoff's Current Law we get\n    \\begin{equation*}\n    p_i = \\sum_{\\ell} K_{i\\ell}f_\\ell =   \\sum_{\\ell} K_{i\\ell} \\frac{1}{x_\\ell}\\sum_{j} K_{j\\ell} \\theta_j\n    \\end{equation*}\n    This is a \\alert{weighted Laplacian}. If we write $B_{k\\ell}$ for the diagonal matrix with $B_{\\ell\\ell} = \\frac{1}{x_\\ell}$ then\n    \\begin{equation*}\n      L = KBK^t\n    \\end{equation*}\n    and we get a \\alert{discrete Poisson equation} for the $\\theta_i$ sourced by the $p_i$\n    \\begin{equation*}\n      p_i = \\sum_{j} L_{ij} \\theta_j\n    \\end{equation*}\n    This is a set of $N-1$ sparse linear equations for the $\\theta_j$ ($N-1$ since $\\sum_i L_{ij} = 0$).\n    We can solve this for the $\\theta_i$ and then find the flows using equation \\eqref{eq:3}. Polynomial complexity in $N$.\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Solving the equations via the PTDF}\n\n  If we are repeating the calculation for a fixed network multiple times with different power injections, it can make sense to do the full matrix inversion.\n\n  Given $p_i$ at every node, we want to find the flows $f_\\ell$. We\n  have the equations\n    \\begin{align*}\n      p_i & = \\sum_{j} L_{ij} \\theta_j \\\\\n     f_\\ell  & = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell} \\theta_i\n    \\end{align*}\n\n    Basic idea: invert $L$ to get $\\theta_i$ in terms of $p_i$\n    \\begin{equation*}\n      \\theta_i  = \\sum_{k} (L^{-1})_{ik} p_k\n    \\end{equation*}\n    then insert to get the flows as a linear function of the power injections $p_i$\n    \\begin{equation*}\n    f_\\ell   = \\frac{1}{x_\\ell}\\sum_{i,k} K_{i\\ell}  (L^{-1})_{ik} p_k = \\sum_k \\textrm{PTDF}_{\\ell k} p_k\n    \\end{equation*}\n    called the \\alert{Power Transfer Distribution Factors} (PTDF).\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Inverting Laplacian $L$}\n\n  There is one small catch: $L$ is \\alert{not invertible} since we saw last\n  time it has (for a connected network) one zero eigenvalue, with\n  eigenvector $(1,1, \\dots 1)$, since by construction $\\sum_j L_{ij} =\n  0$.\n\n  This is related to a gauge freedom to add a constant to all voltage angles\n  \\begin{equation*}\n    \\theta_i \\to \\theta_i + c\n  \\end{equation*}\n  which does not affect physical quantities:\n    \\begin{align*}\n      p_i & = \\sum_{j} L_{ij} (\\theta_j+ c) = \\sum_{j} L_{ij} (\\theta_j)  \\\\\n     f_\\ell  & = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell}( \\theta_i  + c) = \\frac{1}{x_\\ell}\\sum_{i} K_{i\\ell}( \\theta_i )\n    \\end{align*}\n\n    Typically choose a \\alert{slack} or \\alert{reference node} such that  $\\theta_1 = 0$.\n\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Inverting Laplacian $L$}\n\n  Two solutions:\n\n  1. Since $\\theta_1 = 0$ and $p_1$ is not independent of the other\n  power injections ($\\sum_{i=1}^N p_i = 0$ implies $p_1 = -\n  \\sum_{i=2}^N p_i$), we can ignore these elements and invert\n  the lower-right $(N-1) \\times (N-1)$ part of $L$ (which doesn't have zero eigenvalues) to find the\n  remaining $\\{\\theta_i\\}_{i=2,\\dots N}$ in terms of the\n  $\\{p_i\\}_{i=2,\\dots N}$.\n\n  2. Use the Moore-Penrose pseudo-inverse.\n\n  Write $L$ in terms of its basis of orthonormal eigenvectors $e^n_i$ ($\\sum_j L_{ij} e^n_j = \\l_n e^n_i$, $\\sum_i e^n_i e^n_i = 1$ and  $\\sum_i e^n_i e^m_i = 0$ if $n \\neq m$):\n  \\begin{equation*}\n    L_{ij} = \\sum_n \\l_n e^n_i e^n_j\n  \\end{equation*}\n  then the Moore-Penrose pseudo-inverse is:\n  \\begin{equation*}\n    L^\\dagger_{ij} = \\sum_{n | \\l_n \\neq 0} \\frac{1}{\\l_n} e^n_i e^n_j\n  \\end{equation*}\n\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Check the Moore-Penrose pseudo-inverse}\n\n  Let's check the Moore-Penrose pseudo-inverse really gives us an inverse:\n  \\begin{align*}\n    \\sum_{j} L_{ij}L^\\dagger_{jk} &= \\sum_j \\sum_n \\l_n e^n_i e^n_j  \\sum_{m | \\l_m \\neq 0} \\frac{1}{\\l_m} e^m_j e^m_k \\\\\n&= \\sum_n \\l_n e^n_i  \\sum_{m | \\l_m \\neq 0} \\frac{1}{\\l_m} e^m_k \\sum_j   e^n_j e^m_j \\\\\n    & =   \\sum_{m | \\l_m \\neq 0} \\frac{\\l_m}{\\l_m} e^m_i e^m_k\\\\\n    & =   \\sum_{m | \\l_m \\neq 0}  e^m_i e^m_k\n  \\end{align*}\n  From line 2 to 3 we use the orthogonality of the eigenvectors.\n\n  This is almost the identity. It has eigenvalues 1 for each eigenvector $e^n_k$ except for zero eigenvectors of $L$ with $\\l_n = 0$, which it annihilates.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{4-node example}\n\n  \\begin{columns}\n\\column[c]{.5\\textwidth}\n\\begin{equation*}\n\\mathbf{K}_{i \\ell}=\\left(\\begin{matrix}\n1 & 0 & 0 & 0\\\\\n-1 & 1 & 1 & 0\\\\\n0 & -1 & 0 & 1\\\\\n0 & 0 & -1 & -1\n\\end{matrix}\\right)\n\\end{equation*}\n\\begin{equation*}\n\\mathbf{L}_{ij}=\\left(\\begin{matrix}\n1 & -1 & 0 & 0\\\\\n-1 & 3 & -1 & -1\\\\\n0 & -1 & 2 & -1\\\\\n0 & -1 & -1 & 2\n\\end{matrix}\\right)\n\\end{equation*}\n\\begin{equation*}\n\\mathbf{PTDF}_{\\ell i}=\\left(\\begin{matrix}\n0 & -1 & -1 & -1\\\\\n0 & 0 & -2/3 & -1/3\\\\\n0 & 0 & -1/3 & -2/3\\\\\n0 & 0 & 1/3 & -1/3\n\\end{matrix}\\right)\n\\end{equation*}\n\n\\column[c]{.5\\textwidth}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (4) at (0,2.5) {4};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n      \\node (1) at (4.2,4.2) {1};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {4} (4);\n      \\path [->] (2) edge node {3} (4);\n    \\end{scope}\n  \\end{tikzpicture}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{4-node example}\n\n  \\begin{columns}\n\\column[c]{.65\\textwidth}\n\\begin{align*}\n\\sum_i \\mathbf{PTDF}_{\\ell i}p_i & =\\left(\\begin{matrix}\n0 & -1 & -1 & -1\\\\\n0 & 0 & -2/3 & -1/3\\\\\n0 & 0 & -1/3 & -2/3\\\\\n0 & 0 & 1/3 & -1/3\n\\end{matrix}\\right)\\left(\\begin{matrix}\n50\\\\\n50 \\\\\n0\\\\\n-100\n\\end{matrix}\\right) \\\\\n& =\\left(\\begin{matrix}\n50\\\\\n33.3 \\\\\n66.7 \\\\\n33.3\n\\end{matrix}\\right)\n\\end{align*}\n\n\\column[c]{.35\\textwidth}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=yellow}]\n      \\node (4) at (0,2.5) {-100};\n      \\node (2) at (2.5,2.5) {+50};\n      \\node (3) at (1.25,.3) {0};\n      \\node (1) at (4.2,4.2) {+50};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n                every node/.style={fill=white,circle},\n        every edge/.style={draw=red,very thick}]\n      \\path [->] (1) edge node {50} (2);\n      \\path [->] (2) edge node {33.3} (3);\n      \\path [->] (3) edge node {33.3} (4);\n      \\path [->] (2) edge node {66.7} (4);\n    \\end{scope}\n  \\end{tikzpicture}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{PTDF as sensitivity}\n\n  Can also `experimentally' determine the Power Transfer Distribution\n  Factors (PTDF) by choosing a slack node (in this case node 1).\n\n  Each column (labelled by $i$) is then the resulting line flows if we have\n  a simple power transfer from node $i$ to the slack $p_i = 1$ and $p_1\n  = -1$.\n\n  \\begin{columns}\n\\column[c]{.5\\textwidth}\n\\begin{equation*}\n\\mathbf{PTDF}_{\\ell i}=\\left(\\begin{matrix}\n0 & -1 & -1 & -1\\\\\n0 & 0 & -2/3 & -1/3\\\\\n0 & 0 & -1/3 & -2/3\\\\\n0 & 0 & 1/3 & -1/3\n\\end{matrix}\\right)\n\\end{equation*}\n\n\\column[c]{.5\\textwidth}\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=cyan}]%text=white}]\n      \\node (4) at (0,2.5) {4};\n      \\node (2) at (2.5,2.5) {2};\n      \\node (3) at (1.25,.3) {3};\n      \\node (1) at (4.2,4.2) {1};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n        every node/.style={fill=white,circle},\n        every edge/.style={draw=black,very thick}]\n      \\path [->] (1) edge node {1} (2);\n      \\path [->] (2) edge node {2} (3);\n      \\path [->] (3) edge node {4} (4);\n      \\path [->] (2) edge node {3} (4);\n    \\end{scope}\n  \\end{tikzpicture}\n\n\\end{columns}\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{PTDF as sensitivity: example of 3rd column for node 3}\n  \\begin{columns}\n    \\column[c]{.5\\textwidth}\n    Focus on 3rd column of PTDF and look at power flow with $p_3 = +1$ and slack $p_1 = -1$. Coefficients determined by resulting flow:\n\\begin{equation*}\n\\mathbf{PTDF}_{\\ell 3}=\\left(\\begin{matrix}\n &  & -1 &\\\\\n &  & -2/3 & \\\\\n &  & -1/3 & \\\\\n &  & 1/3 &\n\\end{matrix}\\right)\n\\end{equation*}\n\n\\column[c]{.5\\textwidth}\n\n\\begin{tikzpicture}\n    \\begin{scope}[every node/.style={circle,thick,draw,fill=yellow}]\n      \\node (4) at (0,2.5) {0};\n      \\node (2) at (2.5,2.5) {0};\n      \\node (3) at (1.25,.3) {+1};\n      \\node (1) at (4.2,4.2) {-1};\n    \\end{scope}\n\n    \\begin{scope}[>={Stealth[black]},\n                every node/.style={fill=white,circle},\n        every edge/.style={draw=red,very thick}]\n      \\path [->] (1) edge node {-1} (2);\n      \\path [->] (2) edge node {-2/3} (3);\n      \\path [->] (3) edge node {1/3} (4);\n      \\path [->] (2) edge node {-1/3} (4);\n    \\end{scope}\n  \\end{tikzpicture}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\\section{Consequences of limiting power transfers}\n\n\n\\begin{frame}\n  \\frametitle{Line loading limits}\n\n  You cannot pass infinite current through a transmission line.\n\n  As it warms, it sags, then it will become damaged and/or hit a\n  building/tree and cause a short-circuit. For this reasons there are\n  always \\alert{thermal limits} on current transfer. There may also be\n  limits on the amount of power or current based on concerns about\n  \\alert{voltage stability} or \\alert{general stability}.\n\n  Typically each line has a well-defined \\alert{line loading limit} on the\n  amount of current or power that can flow through it:\n  \\begin{equation*}\n    | f_{\\ell } | \\leq F_\\ell\n  \\end{equation*}\n  where here $F_\\ell$ is the maximum power capacity of the transmission line.\n\n  These limits prevent the transfer of renewable energy or other power sources.\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{Adjusting generator dispatch to avoid overloading}\n\n  To avoid overloading the power lines, we must adjust our generator\n  output (or the demand) so that the power imbalances do not overload\n  the network.\n\n  We will now generalise and adjust our notation.\n\n  From lecture 3 we had for a single node:\n  \\begin{equation*}\n    - p_t = m_t -b_t + c_t = d_t - Ww_t - Ss_t -b_t + c_t = 0\n  \\end{equation*}\n  where $p_t$ was the nodal power balance, $m_t$ was the mismatch\n  (load $d_t$ minus wind $Ww_t$ and solar $Ss_t$), $b_t$ was the\n  backup power and $c_t$ was curtailment.\n\n  We generalised this to multiple nodes labelled by $i$\n  \\begin{equation*}\n    - p_{i,t} = m_{i,t} -b_{i,t} + c_{i,t} = d_{i,t} - W_iw_{i,t} - S_is_{i,t} -b_{i,t} + c_{i,t}\n  \\end{equation*}\n  where now we don't enforce $p_{i,t} = 0$ but $\\sum_{i} p_{i,t} = 0$ for\n  all $t$.\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Adjusting generator dispatch to avoid overloading} Now\n  we write the dispatch of all generators at node $i$ (wind, solar,\n  backup) labelled by technology $s$ as $g_{i,s,t}$ ($i$ labels node, $s$ technology and $t$ time) so that we have a relation between load $d_{i,t}$, generation $g_{i,s,t}$ and network flows $f_{\\ell,t}$\n  \\begin{equation*}\n    p_{i,t} = \\sum_{s} g_{i,s,t} - d_{i,t} = \\sum_{\\ell} K_{i\\ell} f_{\\ell,t}\n  \\end{equation*}\n  Where $s$ runs over the wind, solar and backup capacity generators\n  (e.g. hydro or natural gas) at the node.\n\n  A dispatchable generator's $g_{i,s,t}$ output can be controlled\n  within the limits of its power capacity $G_{i,s}$\n  \\begin{equation*}\n      0 \\leq g_{i,s,t} \\leq  G_{i,s}\n  \\end{equation*}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Variable generation constraints}\n\n  For a renewable generator we have time series of availability $0\\leq G_{i,s,t}\\leq 1$ (the $s_t$ and $w_t$ before; $W$ and $S$ are the capacity $G_{i,s}$):\n    \\begin{equation*}\n      0 \\leq g_{i,s,t} \\leq G_{i,s,t} G_{i,s} \\leq  G_{i,s}\n    \\end{equation*}\n    Curtailment corresponds to the case where $g_{i,s,t} < G_{i,s,t} G_{i,s}$:\n\n     \\centering\n  \\begin{tikzpicture}\n\\node[anchor=south west,inner sep=0] (image) at (0,0) {\\includegraphics[width=10cm]{scigrid-curtailment}};\n\\draw (3,2.75) node{$g_{i,s,t}$};\n\\draw (3,3.4) node{$G_{i,s,t}G_{i,s}$};\n\\draw (3,4.7) node{$G_{i,s}$};\n  \\end{tikzpicture}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Germany curtailment example}\n\n  See \\url{https://pypsa.org/examples/scigrid-lopf-then-pf.html}.\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{European transmission versus backup energy}\n\n  Consider backup energy in a simplified European grid:\n\n  \\centering\n  \\includegraphics[trim=0 4cm 0 4cm,width=9cm,clip=true]{europe_map}\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{DE versus EU backup energy from last time}\n\n  Germany needed backup generation for 31\\% of total load:\n\n  \\centering\n  \\includegraphics[width=6.3cm]{mismatch-duration-DE}\n\n  \\raggedright\n  Europe needed Backup generation for only 24\\% of the total load:\n\n  \\centering\n  \\includegraphics[width=6.3cm]{mismatch-duration-EU}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{European transmission versus backup energy}\n\n  \\href{http://www.sciencedirect.com/science/article/pii/S0960148113005351}{Transmission needs across a fully renewable European power system} by Rodriguez, Becker, Andresen, Heide, Greiner, Renewable Energy, 2014\n\n  \\centering\n  \\includegraphics[width=6cm]{sarah_balancing.png}\n\n\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "bf4310ba7b91755623aaebf4250878c00eec9260", "size": 41145, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "esm-lecture-4.tex", "max_stars_repo_name": "nworbmot/esm-lectures", "max_stars_repo_head_hexsha": "780320fa6755596cd1578f1c035f66208e496215", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2020-05-26T19:02:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T17:54:02.000Z", "max_issues_repo_path": "esm-lecture-4.tex", "max_issues_repo_name": "pitmonticone/esm-lectures", "max_issues_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "esm-lecture-4.tex", "max_forks_repo_name": "pitmonticone/esm-lectures", "max_forks_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-06-25T16:25:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-15T08:25:36.000Z", "avg_line_length": 28.2589285714, "max_line_length": 320, "alphanum_fraction": 0.6495078381, "num_tokens": 14350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4352574255763233}}
{"text": "\\chapter{Introduction to Time Series Analysis}\nA {\\sl time series} is a collection of observations made\nsequentially in time. Examples are daily mortality counts,\nparticulate air pollution measurements, and temperature data.\nFigure 1 shows these for the city of Chicago from 1987 to 1994.\nThe public health question is whether daily mortality is\nassociated with particle levels, controlling for temperature.\n\n\\centerline{\\epsfig{figure=Plots/plot-10-01.ps,angle=270,width=\\textwidth}}\n\nWe represent time series measurements with $Y_1, \\dots, Y_T$\nwhere $T$ is the total number of measurements. In order to analyze\na time series, it is useful to set down a statistical model in the\nform of a {\\sl stochastic process}. A stochastic process can be\ndescribed as a statistical phenomenon\nthat evolves in time. While most statistical problems are\nconcerned with estimating properties of a population from a\nsample, in time series analysis there is a different situation.\nAlthough it might be possible to vary the length of the observed\nsample, it is usually impossible to make multiple observations at\nany single time (for example, one can't observe today's mortality\ncount more than once). This makes the conventional statistical\nprocedures, based on large sample estimates, inappropriate.\nStationarity is a convenient assumption that permits us to\ndescribe the statistical properties of a time series.\n\n\n\\input{section-10-01}\n\\input{section-10-02}", "meta": {"hexsha": "ab29dc4d8082f449d5e7f0f1f53d080ef94c2e37", "size": 1443, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pages/754/section-10.tex", "max_stars_repo_name": "igrabski/rafalab.github.io", "max_stars_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2016-08-17T23:04:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T19:21:02.000Z", "max_issues_repo_path": "pages/754/section-10.tex", "max_issues_repo_name": "igrabski/rafalab.github.io", "max_issues_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2016-08-18T00:41:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-21T22:35:40.000Z", "max_forks_repo_path": "pages/754/section-10.tex", "max_forks_repo_name": "igrabski/rafalab.github.io", "max_forks_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 38, "max_forks_repo_forks_event_min_datetime": "2016-08-17T22:17:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-20T12:17:08.000Z", "avg_line_length": 49.7586206897, "max_line_length": 75, "alphanum_fraction": 0.8094248094, "num_tokens": 314, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.435106235855154}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 05-10-21\n\n\\section{Techniques in Characteristic p > 0}\n\\label{sec:techniques_in_characteristic_p_0}\n\n\\begin{prop}\n\tLet \\(F\\) be a field of characteristic \\(p>0\\). Then for all \\(a,b \\in F\\), we get that\n\t\\begin{align*}\n\t\t(a+b)^{p} = a^{p} + b^{p}\\\\\n\t\t(ab)^{p} = a^{p}b^{p}\n\t\\end{align*}\n\\end{prop}\nThis is the \"Freshman's Dream\".\n\n\\begin{defn}[Frobenius Endomorphism]\n\tFor a field \\(F\\) of characteristic \\(p>0\\), the function\n\t\\begin{align*}\n\t\t\\varphi :F\\to F\\\\\n\t\ta\\mapsto a^{p}\n\t\\end{align*}\n\tis the \\textbf{Frobenius endomorphism} of \\(F\\).\n\\end{defn}\n\\begin{cor}\n\tThe Frobenius endomorphism of \\(F\\) is an injective field homomorphism. When \\(F\\) is finite, it is also surjective.\n\\end{cor}\n\nNow we will go back to some propositions about finite fields using these ideas.\n\\begin{prop}\n\tEvery irreducible polynomial over a finite field \\(F\\) is separable. Moreover, \\(f(x) \\in F[x]\\) is separable if and only if it is the product of distinct irreducible polynomials in \\(F[x]\\).\n\\end{prop}\nThis follows by contradiction. One can express the irreducible polynomial as a polynomial of the form \\(g(x^{p})\\), but this polynomial can be shown to be reducible, and so cannot occur.\n\n\\begin{defn}[Perfect]\n\tA field \\(K\\) of characteristic \\(p>0\\) is called \\textbf{perfect} if every element of \\(K\\) is a \\(p\\)-th power in \\(K\\)-- that is, \\(K = K^{p}\\).\n\\end{defn}\nBy convention any field of characteristic zero is also called perfect.\\\\\n\nWe have just shown that every irreducible polynomial over a perfect field is separable, and hence finite extensions of perfect fields are separable.\n\n\\begin{hw}\n\tProve that there exists a non-perfect infinite field \\(F\\), i.e. find \\(f(x) \\in F[x]\\) so that \\(f\\) is irreducible and not separable.\n\\end{hw}\n\nThese concepts can be used to prove that the \\(n\\)-th cyclotomic polynomial \\(\\Phi_n(x) \\in \\Z[x]\\) is irreducible.\n\n\\end{document}\n", "meta": {"hexsha": "4a85fbec2054ce18295c44982fd2e3c8a53b0866", "size": 2334, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture23 - Polynomial_Fields_Over_Fp.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture23 - Polynomial_Fields_Over_Fp.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture23 - Polynomial_Fields_Over_Fp.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9076923077, "max_line_length": 192, "alphanum_fraction": 0.7077977721, "num_tokens": 718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.43510623069542415}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\nThis code verifies that successive $\\ny{n}^{a}$ introduce a new leading power of $\\eps$ while leaving the lower\norder terms unchanged. That is\n\\begin{align}\n   \\ny{n+1}^a - \\ny{n}^a = \\BigO{\\eps^{n+1}}\n\\end{align}\n\n\\clearpage\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   \\nabla{#}::Derivative.\n\n   g_{a b}::Metric.\n   g^{a b}::InverseMetric.\n   g_{a}^{b}::KroneckerDelta.\n   g^{a}_{b}::KroneckerDelta.\n   \\delta^{a}_{b}::KroneckerDelta.\n   \\delta_{a}^{b}::KroneckerDelta.\n\n   R_{a b c d}::RiemannTensor.\n   R^{a}_{b c d}::RiemannTensor.\n\n   R_{a b c d}::Depends(\\nabla{#}).\n   R^{a}_{b c d}::Depends(\\nabla{#}).\n\n   # Dx{#}::LaTeXForm{\"{\\Dx}\"}.  # LCB: currently causes a bug, it kills ::KeepWeight for Dx\n\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{cadabra}\n   # note: keeping numbering as is (out of order) to ensure R appears before \\nabla R etc.\n   def product_sort (obj):\n       substitute (obj,$ A^{a}                            -> A001^{a}               $)\n       substitute (obj,$ x^{a}                            -> A002^{a}               $)\n       substitute (obj,$ g^{a b}                          -> A003^{a b}             $)\n       substitute (obj,$ \\nabla_{e f g h}{R_{a b c d}}    -> A008_{a b c d e f g h} $)\n       substitute (obj,$ \\nabla_{e f g}{R_{a b c d}}      -> A007_{a b c d e f g}   $)\n       substitute (obj,$ \\nabla_{e f}{R_{a b c d}}        -> A006_{a b c d e f}     $)\n       substitute (obj,$ \\nabla_{e}{R_{a b c d}}          -> A005_{a b c d e}       $)\n       substitute (obj,$ R_{a b c d}                      -> A004_{a b c d}         $)\n       sort_product   (obj)\n       rename_dummies (obj)\n       substitute (obj,$ A001^{a}                  -> A^{a}                         $)\n       substitute (obj,$ A002^{a}                  -> x^{a}                         $)\n       substitute (obj,$ A003^{a b}                -> g^{a b}                       $)\n       substitute (obj,$ A004_{a b c d}            -> R_{a b c d}                   $)\n       substitute (obj,$ A005_{a b c d e}          -> \\nabla_{e}{R_{a b c d}}       $)\n       substitute (obj,$ A006_{a b c d e f}        -> \\nabla_{e f}{R_{a b c d}}     $)\n       substitute (obj,$ A007_{a b c d e f g}      -> \\nabla_{e f g}{R_{a b c d}}   $)\n       substitute (obj,$ A008_{a b c d e f g h}    -> \\nabla_{e f g h}{R_{a b c d}} $)\n\n       return obj\n\n   # now check that y(n+1) - y(n) = Order \\eps^{n+1}\n\n   import cdblib\n\n   y2 = cdblib.get ('y2','../geodesic-bvp.json')\n   y3 = cdblib.get ('y3','../geodesic-bvp.json')\n   y4 = cdblib.get ('y4','../geodesic-bvp.json')\n   y5 = cdblib.get ('y5','../geodesic-bvp.json')\n\n   diff32 := @(y3) - @(y2).\n   diff43 := @(y4) - @(y3).\n   diff54 := @(y5) - @(y4).\n\n   diff32 = product_sort (diff32)\n   rename_dummies        (diff32)\n   canonicalise          (diff32)         # cdb (diff32.001,diff32)\n\n   diff43 = product_sort (diff43)\n   rename_dummies        (diff43)\n   canonicalise          (diff43)         # cdb (diff43.001,diff43)\n\n   diff54 = product_sort (diff54)\n   rename_dummies        (diff54)\n   canonicalise          (diff54)         # cdb (diff54.001,diff54)\n\n   def truncateR (obj,n):\n\n   # I would like to assign different weights to \\nabla_{a}, \\nabla_{a b}, \\nabla_{a b c} etc. but no matter\n   # what I do it appears that Cadabra assigns the same weight to all of these regardless of the number of subscripts.\n   # It seems that the weight is assigned to the symbol \\nabla alone. So I'm forced to use the following substitution trick.\n\n       Q_{a b c d}::Weight(label=numR,value=2).\n       Q_{a b c d e}::Weight(label=numR,value=3).\n       Q_{a b c d e f}::Weight(label=numR,value=4).\n       Q_{a b c d e f g}::Weight(label=numR,value=5).\n\n       tmp := @(obj).\n\n       substitute (tmp, $\\nabla_{e f g}{R_{a b c d}} -> Q_{a b c d e f g}$)\n       substitute (tmp, $\\nabla_{e f}{R_{a b c d}} -> Q_{a b c d e f}$)\n       substitute (tmp, $\\nabla_{e}{R_{a b c d}} -> Q_{a b c d e}$)\n       substitute (tmp, $R_{a b c d} -> Q_{a b c d}$)\n\n       ans = Ex(0)\n\n       for i in range (0,n+1):\n          foo := @(tmp).\n          bah = Ex(\"numR = \" + str(i))\n          keep_weight (foo, bah)\n          ans = ans + foo\n\n       substitute (ans, $Q_{a b c d e f g} -> \\nabla_{e f g}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d e f} -> \\nabla_{e f}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d e} -> \\nabla_{e}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d} -> R_{a b c d}$)\n\n       return ans\n\n   diff32 = truncateR (diff32,2)        # cdb (diff32.002,diff32)\n   diff43 = truncateR (diff43,3)        # cdb (diff43.002,diff43)\n   diff54 = truncateR (diff54,4)        # cdb (diff54.002,diff54)\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Verify order of $\\ny{n}^{a}$}\n\nIf things have gone to plan then we should see that $\\ny{n+1}^a - \\ny{n}^a = \\BigO{\\eps^{n+1}}$. And we do. Good show.\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{3}^{a} - \\ny{2}^{a} = \\cdb{diff32.001} \\end{dmath*}\n   \\begin{dmath*} \\ny{4}^{a} - \\ny{3}^{a} = \\cdb{diff43.001} \\end{dmath*}\n   % \\begin{dmath*} \\ny{5}^{a} - \\ny{4}^{a} = \\cdb{diff54.001} \\end{dmath*}  % too long\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\nT{2}\\left(\\ny{3}^{a} - \\ny{2}^{a}\\right) = \\cdb{diff32.002} \\end{dmath*}\n   \\begin{dmath*} \\nT{3}\\left(\\ny{4}^{a} - \\ny{3}^{a}\\right) = \\cdb{diff43.002} \\end{dmath*}\n   \\begin{dmath*} \\nT{4}\\left(\\ny{5}^{a} - \\ny{4}^{a}\\right) = \\cdb{diff54.002} \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "c47768cce2f60b244feff6202e68f4a5fd2de8b1", "size": 5677, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/checks/check-bvp.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/checks/check-bvp.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/checks/check-bvp.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.619047619, "max_line_length": 124, "alphanum_fraction": 0.5103047384, "num_tokens": 2055, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43510622653527786}}
{"text": "\n\n\n\n\\section{BL test case I}\n\nIn this section test case 1 is solved (1D incompressible \nBL equations with gas injection along a bore hole). \nThe gas is injected at a velocity of $u_g \\phi =1$ and \na saturation of one $S_g=1$. On the outlet boundary the \npressure level is set to zero. All boundary conditions are \napplied naturally. \n\nA converged time step of $1\\times 10^{-3}$ is used for all simulations \nand applications with the continuous and discontinuous between \nelement formulations are presented. All simulations \nuse the overlapping mixed finite element method with a \npiecewise linear variation of the velocity within each \nelement and quadatric pressure. Saturation is collocated at \nthe pressure nodes. Although saturation is cacluated using \na control volume formulation a FEM interpolation is \nused to form the high order fluxes and these are also \nused in this section for most of the graphs. \n\n\n\\subsubsection{Continuous formulation}\n\n{\\it Upwind solution} \n\nIn figure \\ref{bl-exact-meth-upwind}  the \ncontrol volume (CV) saturation of gas (with horizontal and vertical lines) and \nthe quadratic finite element interpolation of these are \npresented. \nAs can be seen the solution converges with increased resolution. \nNotice that the corners of the control volumes pass \nvery closely \nto the converged solution. This is because upwinding of \nthe velocities is used (or equivalently the relative permeabilities) \nand it is at these corners that the equations reach the \nbalance necessary to match closely the analytical solution. \n\n{\\it Optimal upwinding} \n\nIf one uses 80$\\%$ upwinding and 20$\\%$ downwinding then \none gets a closer match with the converged solution, \nsee figure \\ref{bl-exact-meth-cv-0-8-ele50} where we see the \ncontrol volume solution and figure \\ref{bl-optimal-upwind} \nand where these solutions with upwinding as well as \nthe optimal quantity of upwinding (as described in section \\ref{opt-up}) \nare compared. \nOne should note that 80$\\%$ upwinding matches quite closely with the \noptimal upwind parameter results and these results converge rapidly \nwith increase resolution. When applying optimal upwinding \nthe quantity of upwinding (upwind fraction) varies from \n1 (full upwinding) which is typically applied near shocks \nand $\\frac{1}{2}$ which is central differencing. See \nthe upwind fractions in figure \\ref{bl-upwind-frac} for the \ndifferent grid resolutions and each of the two phases. \nThe upwind fraction is chosen so as to increase the accuracy \nof the formulation. However, even though downwinding of the \nvelocity may increase this accuracy we limit ourselves to \ncentral difference. If however, one chooses to use \nupwinding and downwinding then one obtains the solution \nshown in figure \\ref{bl-upwind-v-up-and-down}. Including \nthe downwind components may not be consistent with the characteristics \nof the differential equation and thus may detract from \nits accurate solution. The optimal solution for a number \nof different resolutions ranging from 3 elements to 50 elements \nis shown in figure \\ref{bl-3-10-20-50}. Notice that \nthe solution converges rapidly. There are no oscillations in \nthe corresponding control volume solutions, but here we are \nlooking at the finite element interpolation (using a Galerkin \nproject) of the control volume solution which does oscillate \nnear the shock. \n\n \n\n\n% cty:\n\n\n%fig1: bl-exact-meth-upwind.xmgr\n\n%fig2: bl-exact-meth-cv-0-8-ele50.xmgr\n\n%fig3: bl-optimal-upwind.xmgr\n\n%fig4: bl-upwind-frac.xmgr\n\n%fig5: bl-upwind-v-up-and-down.xmgr\n\n%fig6: bl-3-10-20-50.xmgr\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-exact-meth-upwind}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{The continuous upwind method applied to the BL test \ncase 1 for different mesh resolutions.}\n\\label{bl-exact-meth-upwind}\n\\end{figure}\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-exact-meth-cv-0-8-ele50}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Comparison of the control volume solutions using 80$\\%$ upwinding \nand with optimal upwinding and using 50 continuous quadatric elements. }\n\\label{bl-exact-meth-cv-0-8-ele50}\n\\end{figure}\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-optimal-upwind}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Comparison of upwind, 80$\\%$ upwind and optimal upwind solutions \nat various resolutions.  }\n\\label{bl-optimal-upwind}\n\\end{figure}\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-upwind-v-up-and-down}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{A comparison of the optimal upwind formulation when using \ndownwind as well as upwinding and upwinding only. The finite element interpolation \nof the gas saturation is shown at different mesh resolutions. \nDownwinding seems to detract from the accuracy of the solution. }\n\\label{bl-upwind-v-up-and-down}\n\\end{figure}\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-upwind-frac}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{The fraction of upwinding used in the optimal upwinding approach at the control volume boundaries at the final time step and for three different mesh resolutions. Notice that the upwind fraction is at its largest near the shocks and is relatively small \nwhere the solution is smooth. The magnitude of the upwind fraction also reduces \nwith increased mesh resolution. Also shown is the finite element interpolation \nof the gas saturation at the 3 mesh resolutions.  }\n\\label{bl-upwind-frac}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-3-10-20-50}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{The finite element interpolation of the gas volume fraction, for the optimal upwind scheme and for different mesh resolutions. }\n\\label{bl-3-10-20-50}\n\\end{figure}\n\n\n\n\n\\subsubsection{Discontinuous formulation}\n\nHere results for the discontinuous between elements \nof saturation and pressure are presented. \nHaving the discontinuity between elements potentially allows one \nto use a course mesh to represent abruptly changing fields. \nFor example, using two discontinuous elements only one \nobtains a result, for the BL test case, which is qualatively \nsimilar to the converged solution, see \\ref{bl-dg-2eles}. \nThis solution was obtained with upwinding within and \nbetween the elements, as described in section \\ref{opt-up}. \nThis upwind scheme issued in all results presented here \nwith the acception of solutions obtained using a central scheme \nas shown in figure \\ref{bl-dg-cent-4-10-20} for different \nresolutions. The corresponding upwind solutions at the \nsame mesh resolutions are shown in figure \\ref{bl-dg-4-10-20}. \nIn order to get a feel for how the discontinuous solutions \ncompare, in terms of accuracy, with the continuous \nsolutions of the previous subsection they are compared \nin figure \\ref{bl-dg-4-10-vers-cty}. At the courser resolution \nthey do seem more accurate despite the outstanding accuracy \nof the continuous formulation. We also show \nthe accuracy of the formulation for linear fem-saturation/pressure and various mesh resolutions in figure \\ref{bl-dg-p1-2-4-5-10-20-40}. \nNear the shock front there is little benefit in using high order elements \nso linear elements perform well here compared to quadratic elements. \n\n% dg:\n\n%fig7: bl-dg-2eles.xmgr\n\n%fig8: bl-dg-cent-4-10-20.xmgr\n\n%fig9: bl-dg-4-10-20.xmgr\n\n%fig10: bl-dg-4-10-vers-cty.xmgr\n\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-dg-2eles}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Two element solution using the discontinuous formulation. Both the \ncontrol volume gas saturation and the finite element interpolation \nof this saturation are shown.  }\n\\label{bl-dg-2eles}\n\\end{figure}\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-dg-cent-4-10-20}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations from the discontinuous formulation with no upwinding and for \ndifferent mesh resolutions. Notice that there are substantial oscillations.  }\n\\label{bl-dg-cent-4-10-20}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-dg-4-10-20}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations from the discontinuous formulation with upwinding and for \ndifferent mesh resolutions.  \nNotice that oscillations are suppressed compared to the central scheme.  }\n\\label{bl-dg-4-10-20}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-dg-4-10-vers-cty}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations shown comparing the accuracy of the discontinuous between elements and continuous \nformulation. The 50 element continuous solution may be viewed as a converged \nresult.     }\n\\label{bl-dg-4-10-vers-cty}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-dg-p1-2-4-5-10-20-40}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations for p1(linear) pressure/(fem-interpolation of saturation) \nfor changing mesh resolution.   }\n\\label{bl-dg-p1-2-4-5-10-20-40}\n\\end{figure}\n\n\n%\\pagebreak\n\n\n\\subsubsection{BL test case with positive and negative gravity} \n\nIn this section we apply the the formulations to the test \ncase of the previous section but with gravity defined \nin both the negative (figure \\ref{bl-sou-neg}) and \npositive (figure \\ref{bl-sou-pos}) x-directions. \nThese solutions converge to the analytical solutions \nshown in the appendix. \nNotice that for the negative gravity source the less dense gas region \nis compressed (compared to the case without gravity shown in \nthe previous section) by the weight of the more dense liquid and \nthe opposite happens for the positive gravity result. \n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-sou-pos}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations for p2(quadratic) pressure/(fem-interpolation of saturation) \nfor changing mesh resolution and for the test case with gravity acting in \nthe +ve x-direction. }\n\\label{bl-sou-pos}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/bl-sou-neg}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Gas saturations for p2(quadratic) pressure/(fem-interpolation of saturation) \nfor changing mesh resolution and for the test case with gravity acting in \nthe -ve x-direction. }\n\\label{bl-sou-neg}\n\\end{figure}\n\n\n\\subsubsection{Pressure/density wave propogation} \n\nIn this section we solve a single phase flow problem \nwith an compressible with a simple EoS given by \n$\\rho=1+0.01 p_{CV}$ and the fluid initially as rest. \nThe inlet velocity is accelerated within \none time step (the time step sizes are $\\Delta t=1\\times 10^{-4}$) \nto a unit velocity and is sustained for 0.005 seconds. \nThe inlet velocity is then decreased to zero. \nThe rest is a density/pressure wave which \npropagates across the domain with a characteristic \nvelocity of $c=10$. The results at $t=0.25$ seconds \ninto the simulation are shown. The outlet pressure is zero \nand initial density unity. \n\nAn intermediate density using a quadratic DG pressure \nand cubic DG velocity are shown in figure \\ref{compres-imp-nonlin}. \nThe final solution is shown for this scheme as well \nas a quadratic continuous pressure and quadratic DG velocity \nscheme. In addition, we use the same two scheme's but \nswitching off the non-linear terms in the momentum \nequations (retaining the time term only) to \nproduce the results shown in figure \\ref{compres-imp-no-nonlin}. We have \nalso shown the results using the overlapping finite \nelement method. For the continuous scheme this results \nin an exact representation of the momentum equation.  \nFor the DG pressure formulation this is no longer \ntrue but is close in some sense. \n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/compres-imp-nonlin}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Density wave propogation from left to right across the domain \nwith DG and continuous pressure formulations. The fem-interpolation of \ndensity is shown. }\n\\label{compres-imp-nonlin}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\vbox{\n\\begin{center}\n\\includegraphics[width=17.5cm,height=12.5cm]{./doc_figures/compres-imp-no-nonlin}\n\\end{center}\n\\vspace{0.cm}}\n\\caption{Density wave propogation from left to right across the domain \nwith DG, continuous pressure and overlapping velocity formulations. \nThe non-linear terms in the momentum equations are switched off \nin these simulations. The fem-interpolation of \ndensity is shown.  }\n\\label{compres-imp-no-nonlin}\n\\end{figure}\n\n", "meta": {"hexsha": "36c13d8282e351cb6ab45d2006f7c981221a13ea", "size": 12890, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "software/multifluids_icferst/legacy_reservoir_prototype/doc/flow_applications.tex", "max_stars_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_stars_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-11T02:39:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-11T03:08:38.000Z", "max_issues_repo_path": "software/multifluids_icferst/legacy_reservoir_prototype/doc/flow_applications.tex", "max_issues_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_issues_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "software/multifluids_icferst/legacy_reservoir_prototype/doc/flow_applications.tex", "max_forks_repo_name": "msc-acse/acse-9-independent-research-project-Wade003", "max_forks_repo_head_hexsha": "cfcba990d52ccf535171cf54c0a91b184db6f276", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-05-21T22:50:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-28T17:16:31.000Z", "avg_line_length": 35.027173913, "max_line_length": 262, "alphanum_fraction": 0.7747866563, "num_tokens": 3444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43510622653527786}}
{"text": "\\chapter{CONCLUSIONS AND FUTURE WORK} \\label{ch:conclusion}% Must have a blank line after every section label\n\n\nThis work analyzes a method of detecting hierarchical and communities in complex networks. This method is capable of detecting the absence of significant community structure as an early stopping criterion, and it performs competitively against other community detection methods. It has been shown to be stable to perturbations in the graph structure, unlike competing methods. Additionally, it can detect ties.\n\nWe have shown that the leximin method (and the related MCF cut algorithm) can identify ties, while eight popular methods cannot. These ties are a superposition of two dendrogram behaviors, and perturbing edge capacities gives a smooth transition away from the tie behavior.\n\nGridlock is a fragmentation of the network structure that occurs when the network lacks any clear mesoscopic, community structure. All edges are saturated with flow at the same time, without any bottlenecks. For a given expected density of edges, larger graphs produce gridlock more frequently. Every gridlock graph with rational capacities is related to a multigraph with unit capacities. On these multigraphs, flow is passed between all pairs along edge-disjoint paths.\n\nThe leximin method is competitive with other methods for low mixing parameter. It tends to break off singletons and small structures between or at fringes of communities. Breaking off singletons suggests worthiness for evaluations involving overlapping communities. Additionally, in graphs with real-world properties but lacking strong community structure, gridlock is extremely likely to occur.\n\nNormalized mutual information (NMI) is deficient for evaluating community detection as a ground truth because it exaggerates accuracy of a random assignment to clusters. Argued in favor of adjusted mutual information (AMI), which addresses this deficiency. Most algorithms' scores do not change significantly under AMI; the trends are the same. It does, however, assess the leximin method in a way that agrees with intuition.\n\nDue to the complexity of the leximin method, other methods for identifying community structure may be more desirable when the ability to recognize ties is not important or concerns about stability are not paramount. Additionally, in networks with weak community structure, other methods demonstrably outperform the AMI of the leximin method, so they should be preferred.\n\n\\section{Future Work}\n\nOften, the disagreement between LFR-given clusters and those identified by the leximin method is \\emph{not} because nodes are assigned to the \\emph{wrong} communities. Instead, nodes are splintered off into \\emph{their own} communities. This especially happens when equally strong connections tie the node to two different communities. This suggests an overlapping structure with some nodes serving as hubs or middlemen. Consequently, it would be beneficial to test the method on Lancichinetti and Fortunato's benchmark for overlapping communities~\\cite{lancichinetti2009benchmarks}.\n\nAdditionally, the leading eigenvector method is another that displays early stopping behavior. Work to contrast their criteria for lack of mesoscopic structure in random graphs is warranted.\n\nFurther, because the leximin method operates in such a high-order polynomial time, it would be beneficial to compare the accuracy of community detection performed by approximation methods that exist~\\cite{shahrokhi1989approximation}~\\cite{madry2010faster}.\n\nFinally, work to tighten the bound of the conjecture from \\autoref{ch:random} would be beneficial to the traffic theory problems which surround the MCFP.\n", "meta": {"hexsha": "8873bf7a506ab435638dafe9a4c03ef5b02e8576", "size": 3680, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/conclusion.tex", "max_stars_repo_name": "aryamccarthy/thesis", "max_stars_repo_head_hexsha": "ef0e45e24e1cde26d3014d8da8cede559bbff5df", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/conclusion.tex", "max_issues_repo_name": "aryamccarthy/thesis", "max_issues_repo_head_hexsha": "ef0e45e24e1cde26d3014d8da8cede559bbff5df", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/conclusion.tex", "max_forks_repo_name": "aryamccarthy/thesis", "max_forks_repo_head_hexsha": "ef0e45e24e1cde26d3014d8da8cede559bbff5df", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 147.2, "max_line_length": 583, "alphanum_fraction": 0.8274456522, "num_tokens": 717, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.679178686187839, "lm_q1q2_score": 0.43510621821498513}}
{"text": "% Document Type: LaTeX\n\n\\chapter{The \\resquan\\ Library}\n\nThe \\resquan\\ library provides some basic facilities for working with\nrestricted quantifications. It consists of a single theory \\verb|res_quan.th|,\nwhich contains a number of theorems about the properties of some\nrestricted quantifiers, and a set of ML functions for dealing with\nthese quantifiers. It also contains some conditional\nrewriting tools which can be loaded as a separate library part.\n\nThe description in this chapter begins with a brief introduction to\nthe syntax for restricted quantification. This is followed by an\noverview of the ML functions available in the library and a\ndescription of the theory \\verb|res_quan.th|. A complete reference\nmanual for all ML functions appears in Chapter~2. The last chapter\nlists all theorems in the \\verb|res_quan.th|.\n\n\\section{Syntax for restricted quantification}\n\nSince Version 2.0, \\HOL\\ provides parser and pretty printer support\nfor restricted quantification. This notation allows terms of the form\n\\[\n\\con{Q}\\,x ::P.\\, t[x],\n\\]\nwhere \\con{Q} is a quantifier and\nif $x:\\alpha$ then $P$ can be any term of type $\\alpha\\fun\\bool$; this\ndenotes the quantification of $x$ over those values satisfying $P$.\nThe qualifier {\\small\\verb|::|} can be used with {\\small\\verb|\\|} and any\nbinder, including user defined ones. The appropriate meanings are\npredefined for {\\small\\verb|\\|} and the built-in binders \n{\\small\\verb|!|}, {\\small\\verb|?|} and {\\small\\verb|@|}. \nThis syntax automatically translates as follows:\n\n\\begin{hol}\n{\\small\\verb%   \\%}$v${\\small\\verb%::%}$P${\\small\\verb%.%}$tm${\\small\\verb%    <---->   %}\\con{RES\\_ABSTRACT}\\ $P${\\small\\verb% (\\%}$v${\\small\\verb%.%}$tm${\\small\\verb%)%}\\\\\n{\\small\\verb%   !%}$v${\\small\\verb%::%}$P${\\small\\verb%.%}$tm${\\small\\verb%    <---->   %}\\con{RES\\_FORALL}\\ \\ \\ $P${\\small\\verb% (\\%}$v${\\small\\verb%.%}$tm${\\small\\verb%)%}\\\\\n{\\small\\verb%   ?%}$v${\\small\\verb%::%}$P${\\small\\verb%.%}$tm${\\small\\verb%    <---->   %}\\con{RES\\_EXISTS}\\ \\ \\ $P${\\small\\verb% (\\%}$v${\\small\\verb%.%}$tm${\\small\\verb%)%}\\\\\n{\\small\\verb%   @%}$v${\\small\\verb%::%}$P${\\small\\verb%.%}$tm${\\small\\verb%    <---->   %}\\con{RES\\_SELECT}\\ \\ \\ $P${\\small\\verb% (\\%}$v${\\small\\verb%.%}$tm${\\small\\verb%)%}\n\\end{hol}\n\nThe constants \\con{RES\\_ABSTRACT}, \\con{RES\\_FORALL}, \\con{RES\\_EXISTS} and \n\\con{RES\\_SELECT} are defined in the theory \\ml{bool} to provide\nsemantics for these restricted quantifiers as follows:\n\n\\begin{hol}\\begin{verbatim}\n   RES_ABSTRACT P tm  =  \\x:*. (P x => tm x | ARB:**)\n\n   RES_FORALL   P tm  =  !x:*. P x ==> tm x\n\n   RES_EXISTS   P tm  =  ?x:*. P x /\\ tm x\n\n   RES_SELECT   P tm  =  @x:*. P x /\\ tm x\n\\end{verbatim}\\end{hol}\n\n\\noindent where the constant \\con{ARB} is defined in the theory \\ml{bool} by:\n\n\\begin{hol}\\begin{verbatim}\n   ARB  =  @x:*. T\n\\end{verbatim}\\end{hol}\n\nUser-defined binders can also have restricted forms, which are set up\nwith the function:\n\n\\begin{holboxed}\\index{associate_restriction@\\ml{associate\\_restriction}}\n\\begin{verbatim}\n   associate_restriction : (string # string) -> *\n\\end{verbatim}\\end{holboxed}\n\n\n\\noindent If \\m{B} is the name\nof a binder and \\ml{RES\\_}$B$ is the name of a suitable constant (which\nmust be explicitly defined), then executing:\n\n\\begin{hol}\n{\\small\\verb%   associate_restriction(`%}\\m{B}{\\small\\verb%`, `RES_%}\\m{B}{\\small\\verb%`)%}\n\\end{hol}\n\n\\noindent will cause the parser and pretty-printer to support:\n\n\\begin{hol}\n{\\small\\verb%   %}$B$ $v${\\small\\verb%::%}$P${\\small\\verb%. %}$tm${\\small\\verb%    <---->   RES_%}$B$ $P${\\small\\verb% (\\%}$v${\\small\\verb%. %}$tm${\\small\\verb%)%}\n\\end{hol}\n\n\\noindent Note that associations between user defined binders and their\nrestrictions are not stored in theory files, so they have to be set up\nfor each \\HOL\\ session (e.g. with a {\\small\\verb%hol-init.ml%} initialization file).\n\nThe flag \\ml{print\\_restrict} has default \\ml{true}, but if set to \n\\ml{false} will\ndisable the pretty printing. This is useful for seeing what the\nsemantics of particular restricted abstractions are.\nHere is an example session:\n\n\\setcounter{sessioncount}{1}\n\\begin{session}\\begin{verbatim}\n#\"!x y::P. x<y\";;\n\"!x y :: P. x < y\" : term\n\n#set_flag(`print_restrict`, false);;\ntrue : bool\n\n#\"!x y::P. x<y\";;\n\"RES_FORALL P(\\x. RES_FORALL P(\\y. x < y))\" : term\n\n#\"?(x,y) p::(\\(m,n).m<n). p=(x,y)\";;\n\"RES_EXISTS\n (\\(m,n). m < n)\n (\\(x,y). RES_EXISTS(\\(m,n). m < n)(\\p. p = x,y))\"\n: term\n\n#\"\\x y z::P.[0;x;y;z]\";;\n\"RES_ABSTRACT P(\\x. RES_ABSTRACT P(\\y. RES_ABSTRACT P(\\z. [0;x;y;z])))\"\n: term\n\\end{verbatim}\\end{session}\n\nThe syntax for restricted quantification provides a method of\nsimulating subtypes and dependent types; the qualifying predicate $P$ can be\nan arbitrary term containing parameters. For example:\n{\\small\\verb|!|}$w${\\small\\verb|::|}$\\con{Word}(n)${\\small\\verb|. |}$t[w]$,\nfor a suitable constant \\con{Word}, simulates a quantification over the\n`type' of $n$-bit words.\\footnote{This approach is used in the library\n{\\tt word} to model bit vectors.}\n\n\\section{The theory {\\tt res\\_quan.{}th}}\n\nThis theory contains a small number of theorems about the restricted\nuniversal quantifier and restricted existential quantifier.\nThe following four theorems state the distributivity property of these\nquantifiers across conjunction and disjunction.\n\\begin{verbatim}\n RESQ_FORALL_CONJ_DIST\n  |- !P Q R. \n     (!(i:*) :: P. (Q i /\\ R i)) = (!i :: P. Q i) /\\ (!i :: P. R i)\n\n RESQ_FORALL_DISJ_DIST\n  |- !P Q R.\n     (!(i:*) :: \\i. P i \\/ Q i. R i) = (!i :: P. R i) /\\ (!i :: Q. R i)\n\n RESQ_EXISTS_DISJ_DIST\n  |- !P Q R.\n     (?(i:*) :: P. (Q i \\/ R i)) = (?i :: P. Q i) \\/ (?i :: P. R i)\n\n RESQ_DISJ_EXISTS_DIST\n  |- !P Q R.\n     (?(i:*) :: \\i. P i \\/ Q i. R i) = (?i :: P. R i) \\/ (?i :: Q. R i)\n\\end{verbatim}\n\nThe theorems \\ml{RESQ\\_FORALL\\_REORDER} and \\ml{RESQ\\_EXISTS\\_REORDER}\nstate the reordering property of these quantifiers.\n\\begin{verbatim}\n RESQ_FORALL_REORDER\n  |- !(P:*->bool) (Q:**->bool) (R:*->**->bool).\n      (!i :: P. !j :: Q. R i j) = (!j :: Q. !i :: P. R i j)\n\n RESQ_EXISTS_REORDER\n  |- !(P:*->bool) (Q:**->bool) (R:*->**->bool).\n      (?i :: P. ?j :: Q. R i j) = (?j :: Q. ?i :: P. R i j)\n\\end{verbatim}\nThe theorem \\ml{RESQ\\_FORALL\\_FORALL} states the reordering property of\nthe restricted universal quantifier and the ordinary universal\nquantifier.\n\\begin{verbatim}\n RESQ_FORALL_FORALL\n  |- !(P:*->bool) (R:*->**->bool) x.\n      (!x. !i :: P. R i x) = (!i :: P. !x. R i x)\n\\end{verbatim}\n\n\\section{ML functions}\n\nThe ML functions available when this library is loaded can be divided\ninto six groups: conditional rewriting tools, syntax functions,\nderived rules, conversions, tactics, and constant definitions. They\nwill be described in separate subsections. \n\n\\subsection{Conditional rewriting tools}\n\nThe conditional rewriting tools are not specific for restricted\nquantifiers. They are available as a separate part of the library\nwhich can be loaded into \\HOL\\ without loading other functions in this\nlibrary. This is done by the command \n\\begin{verbatim}\n load_library `res_quan:cond_rewrite`;;\n\\end{verbatim}\n\nThe conditional rewriting tools consists of a simple tactic which is\nfor use in goal-directed proof and a simple conversion which is\nusually used in forward proof.\n\n\\subsubsection{Conditional theorems}\n\nBoth the conditional rewriting tactic and conversion require a theorem\nto do the rewriting. This theorem should be an implication whose\nconsequence is an equation, i.e., it should be of the following form:\n\\begin{equation}\n   A \\vdash \\forall\\,x_1 \\ldots x_n\\DOT P_1 \\IMP \\ldots P_m \\IMP\n (Q[x_1,\\ldots,x_n] = R[x_1,\\ldots,x_n]) \\label{eq-cond-thm}\n\\end{equation}\nwhere $x_1, \\ldots, x_n$ are the only variables that occur free in the\nleft-hand side of the conclusion of the theorem but do not occur free\nin the assumptions. Futhermore, none of the antecedents\n$P_1,\\ldots,P_n$ should be \nconjunctions. The idea of  conditional rewriting is that the \nantecedents of this input theorem are treated as conditions which have\nto be satisfied before the equation $Q[x_1,\\ldots,x_n] = R[x_1,\\ldots,x_n]$\ncan be used to rewrite a term.\n\nThe ML function \\ml{COND\\_REWR\\_CANON} transforms a theorem\ninto the canonical form in~\\ref{eq-cond-thm}. The antecedents of the\ninput theorem to \\ml{COND\\_REWR\\_CANON} may contain conjunctions and\nquantification. For example, suppose that {\\tt th} is the theorem\n\\begin{equation}\n   A \\vdash \\forall\\,x\\DOT P_1\\,x \\IMP  \\forall y\\,z.(P_2\\,y \\AND P_3\\,z) \\IMP\n (\\forall t. Q[x,y,z,t] = R[x,y,z,t]) \\label{eq-cond-thm2}\n\\end{equation}\nthen \\verb|COND_REWR_CANON th| returns the theorem\n\\[\n   A \\vdash \\forall\\,x\\,y\\,z\\,t\\DOT P_1\\,x \\IMP P_2\\,y \\IMP P_3\\,z \\IMP\n (Q[x,y,z,t] = R[x,y,z,t])\n\\]\nThat is all universal quantifications are moved to the outer most level\nand conjunctions in the antecedents are converted to implication.\n\n\\subsubsection{Conditional rewriting tactic}\n\nThe basic conditional rewriting tactic is\n\\begin{holboxed}\n\\begin{verbatim}\n   COND_REWRITE1_TAC : thm_tactic\n\\end{verbatim}\n\\end{holboxed}\nSuppose {\\tt th} is the theorem in~\\ref{eq-cond-thm2},\nthe effects of applying the tactic $\\ml{COND\\_REWRITE1\\_TAC}\\;th$ to the\ngoal $(asm,gl)$ is that\n\\begin{itemize}\n\\item  all instances of $Q$ in the goal $gl$ are\n\treplaced by corresponding instances of $R$, and\n\\item the instances of the antecedents $P_i$ which do not appear in\n\tthe assumption $asm$ become new subgoals.\n\\end{itemize}\n\nThis tactic is implemented using a lower level tactic \\ml{COND\\_REWR\\_TAC}.\nThe theorem $th$ supplied to \\ml{COND\\_REWRITE1\\_TAC} is processed by\n\\ml{COND\\_REWR\\_CANON} first. The resulting theorem is passed to the low\nlevel conditional rewriting tactic \\ml{COND\\_REWR\\_TAC} together with a\nsearch function \\ml{search\\_top\\_down}. This function determines how to\nfind the instantiations. By calling \\ml{COND\\_REWR\\_TAC} with different\nsearch function, other conditional rewriting strategy can be\nimplemented. The details of the tactics and search functions can be\nfound in the reference entries in Chapter~2.\nNote that the {\\tt 1} in the name of the tactic indicates that it\ntakes only a single theorem as its argument.\n\n\\subsubsection{Conditional rewriting conversion}\n\nThe basic conditional rewriting conversion is\n\\begin{holboxed}\n\\begin{verbatim}\n   COND_REWRITE1_CONV : (thm list -> thm -> conv)\n\\end{verbatim}\n\\end{holboxed}\nwhich performs conversion in a way similar to the conditional\nrewriting tactics. The difference is that the instances of the\nantecedents are added to the list of assumptions of the resulting theorem. The\nextra argument to this conversion is a list of theorems which are\nused to eliminate instances of the antecedents from the assumptions.\n\n\\subsection{Syntax functions}\n\nThere are term constructors, term destructors and term testers for the\nfour built-in restricted quantifiers. There are also iterative\nconstructors and destructors for the restricted universal and\nexistential quantifiers. Their names and types are:\n\\begin{holboxed}\n\\begin{verbatim}\nmk_resq_forall = - : ((term # term # term) -> term)\nmk_resq_exists = - : ((term # term # term) -> term)\nmk_resq_select = - : ((term # term # term) -> term)\nmk_resq_abstract = - : ((term # term # term) -> term)\nlist_mk_resq_forall = - : (((term # term) list # term) -> term)\nlist_mk_resq_exists = - : (((term # term) list # term) -> term)\n\ndest_resq_forall = - : (term -> (term # term # term))\ndest_resq_exists = - : (term -> (term # term # term))\ndest_resq_select = - : (term -> (term # term # term))\ndest_resq_abstract = - : (term -> (term # term # term))\nstrip_resq_forall = - : (term -> ((term # term) list # term))\nstrip_resq_exists = - : (term -> ((term # term) list # term))\n\nis_resq_forall = - : (term -> bool)\nis_resq_exists = - : (term -> bool)\nis_resq_select = - : (term -> bool)\nis_resq_abstract = - : (term -> bool)\n\\end{verbatim}\n\\end{holboxed}\n\n\\subsection{Derived rules}\n\nThe introduction and elimination rules for the restricted universal\nquantifier are \\ml{RESQ\\_SPEC} and \\ml{RESQ\\_GEN} which are in analogy\nto the rules for the universal quantifier. The specification of these\nrules are:\n\\[\n\\frac{\\Gamma \\THM \\forall x :: P. t[x]}{\\Gamma,P\\,x'\\THM t[x'/x]}\n\\quad\\mbox{{\\tt RESQ\\_SPEC \"x'\"}}\n\\]\n\\[\n\\frac{\\Gamma,P\\,x\\THM t[x]}{\\Gamma \\THM \\forall x :: P. t[x]}\n\\quad\\mbox{{\\tt RESQ\\_GEN \"x\" \"P\"}}\n\\]\nThere is an extra rule \\ml{RESQ\\_HALF\\_SPEC} which transform a\nrestricted universal quantification into its underlying semantic\nrepresentation, namely an implication.\n\\[\n\\frac{\\Gamma \\THM \\forall x :: P. t[x]}{\\Gamma \\THM\\forall x. P\\,x\\IMP t[x]}\n\\quad\\mbox{{\\tt RESQ\\_HALF\\_SPEC}}\n\\]\n\nThere are iterative versions of the introduction and elimination rules:\n\\begin{holboxed}\n\\begin{verbatim}\nRESQ_SPECL = - : (term list -> thm -> thm)\nRESQ_SPEC_ALL = - : (thm -> thm)\n\nRESQ_GENL = - : (term list -> thm -> thm)\nRESQ_GEN_ALL = - : (thm -> thm)\n\\end{verbatim}\n\\end{holboxed}\n\nSince instantiation of a theorem is a very common operation, for\nconvenience, the following ML functions are provided to instantiate a\ntheorem with a mixture of ordinary and restricted universal quantifiers:\n\\begin{holboxed}\n\\begin{verbatim}\nGQSPEC = - : tm -> thm -> thm\nGQSPECL : term list -> thm -> thm\nGQSPEC_ALL : thm -> thm\n\\end{verbatim}\n\\end{holboxed}\n\nThe rule for eliminating restricted existential quantification is\n\\ml{RESQ\\_HALF\\_EXISTS} whose specification is:\n\\[\n\\frac{\\Gamma \\THM \\exists x:: P. t[x]}{\\Gamma \\THM \\exists x. P\\,x\n\\AND t[x]}\\quad\\mbox{{\\tt RESQ\\_HALF\\_EXISTS}}\n\\]\nThis function only transforms the restricted existential quantifier to\nan ordinary existential quantifier.\n\nThe function \\ml{RESQ\\_MATCH\\_MP} eliminates a restricted universal\nquantifier using an instance of the condition. Its specification is:\n\\[\n\\frac{\\Gamma_1 \\THM \\forall x::P. t[x]\\qquad\\Gamma_2\\THM P\\,x'}\n{\\Gamma_1 \\cup \\Gamma_2 \\THM t[x'/x]}\\quad\\mbox{{\\tt RESQ\\_MATCH\\_MP}}\n\\]\n\n\\subsection{Conversions}\n\nThere are a number of conversions for manipulating restricted\nuniversal quantification. The conversion \\ml{RESQ\\_FORALL\\_CONV}\nconverts a restricted universal quantification to its underlying\nsemantic representation, namely an implication. For example,\nevaluating the ML expression\n\\verb|RESQ_FORALL_CONV \"!x :: P. t[x]\"| returns the following theorem:\n\\[\n\\THM \\forall x :: P. t[x] = \\forall x. P x \\IMP t[x]\n\\]\nThe ML function\n\\ml{IMP\\_RESQ\\_FORALL\\_CONV} performs the reverse conversion. The ML\nfunction \\ml{LIST\\_RESQ\\_FORALL\\_CONV} is an iterative version of\n\\ml{RESQ\\_FORALL\\_CONV} which converts a term having multiple\nrestricted universal quantifiers at the outer level.\n\nThe conversions \\ml{RESQ\\_FORALL\\_AND\\_CONV} and\n\\ml{AND\\_RESQ\\_FORALL\\_CONV} move the restricted universal\nquantification in and out of a conjunction, respectively.\nThe conversion \\linebreak\\ml{RESQ\\_FORALL\\_SWAP\\_CONV} changes the order of two\nrestricted universal quantifications. For instance, evaluating the\nfollowing ML expression\n\\begin{verbatim}\n   RESQ_FORALL_SWAP_CONV \"!i :: P. !j :: Q. R\"\n\\end{verbatim}\nreturns the theorem:\n\\[\n\\THM (\\forall i :: P. \\forall j :: Q. R) = (\\forall j :: Q. \\forall i :: P. R)\n\\]\nproviding that $i$ does not occur free in $Q$ and $j$ does not occur\nfree in $P$.\n\nThe conversion \\ml{RESQ\\_EXISTS\\_CONV} transforms a restricted\nexistential quantification to its underlying semantic representation.\nFor instance, \\verb|RESQ_EXISTS_CONV \"?x::P. t\"| returns the theorem\n\\[\n\\THM \\exists x::P. t = \\exists x. P x \\AND t[x]\n\\]\n\nA rewriting conversion \\ml{RESQ\\_REWRITE1\\_CONV} uses a restricted\nuniversal quantified equation to rewrite a term. For instance, if {\\tt\nth} is a theorem of the following form:\n\\[\n\\THM \\forall x::P. u[x] = v[x]\n\\]\nand {\\tt tm} is a term containing some instances of $u$,\nthen \\verb|RESQ_REWRITE1_CONV ths th tm| will return the theorem\n\\[\n\\Gamma \\THM tm = tm'\n\\]\nwhere $tm'$ is obtained by replacing all instances of $u$ by\ncorresponding instances of $v$ and $\\Gamma$ contains instances of $P$\nwhich cannot be eliminated by the theorems in the list {\\tt ths}. This\nconversion is implemented using the conditional rewriting conversion\n\\ml{COND\\_REWRITE1\\_CONV}. \n\n\\subsection{Tactics}\n\nThe simple tactics \\ml{RESQ\\_GEN\\_TAC} and \\ml{RESQ\\_EXISTS\\_TAC} are\nprovided for stripping of a restricted universal or existential\nquantifier, respectively. They reduce a restricted quantified goal to\na goal in the underlying semantic representation. They are in analogy\nto \\ml{GEN\\_TAC} and \\ml{EXISTS\\_TAC}.\n\nThe resolution tactics and tactical listed below are in analogy to\n\\ml{RES\\_TAC}, \\ml{IMP\\_RES\\_TAC}, \\ml{RES\\_THEN} and\n\\ml{IMP\\_RES\\_THEN}. \n\\begin{holboxed}\n\\begin{verbatim}\nRESQ_RES_THEN : (thm_tactic -> tactic)\nRESQ_IMP_RES_THEN : thm_tactical\nRESQ_RES_TAC : tactic\nRESQ_IMP_RES_TAC : thm_tactic\n\\end{verbatim}\n\\end{holboxed}\nThe theorem-tactic \\ml{RESQ\\_IMP\\_RES\\_TAC} uses a restricted universally\nquantified theorem as if it is an implication to perform resolution.\nSimilarly, the tactic \\ml{RESQ\\_RES\\_TAC} uses a restricted universally\nquantified assumption as if it is an implication to\nperform resolution against other assumptions.\n\nThe theorem-tactic \\ml{RESQ\\_REWRITE1\\_TAC} uses a restricted universally\nquantified theorem to perform conditional rewriting.\nFor instance, if {\\tt th} is the following theorem\n\\[\n\\THM \\forall x::P. u[x] = v[x]\n\\]\nthen applying the tactic \\verb|RESQ_REWRITE1_TAC th| to a goal {\\tt\ngl} will reduce it to one or more subgoals {\\tt gl0}, \\ldots, {\\tt\ngln}. The main subgoal {\\tt gl0} is obtained by replacing instances of\n$u$ in {\\tt gl} with corresponding instances of $v$. The new subgoals\nare the instances of $P$ which do not occur in the assumption of $gl$.\n\n\n\\subsection{Constant definitions}\n\n\nThis library provides support for defining constants whose arguments\ncan be restricted quantified variables. For example, one can defined a constant\n\\con{C} by the following equation:\n\\begin{eqnarray*}\n\\lefteqn{\\forall x_1::P_1. \\ldots \\forall x_n::P_n.} \\\\\n & &  \\mbox{{\\sf C}}\\, y\\, x_1 \\ldots x_n\\, z = t[y,x_1,\\ldots,x_n,z]\n\\end{eqnarray*}\nThe constant \\con{C} may be an ordinary constant, or it may have\neither `infix' or `binder' status. The ML functions for defining\nrestricted quantified constants are:\n\\begin{holboxed}\n\\begin{verbatim}\nnew_resq_definition        : (string # term) -> thm\nnew_infix_resq_definition  : (string # term) -> thm\nnew_binder_resq_definition : (string # term) -> thm\n\\end{verbatim}\n\\end{holboxed}\nSuppose {\\tt tm} is the term shown above, evaluating the ML expression\n\\begin{verbatim}\n   new_resq_definition(`C_DEF`,tm)\n\\end{verbatim}\nwill store the definition under\nthe name \\verb|C_DEF| in the current theory. The definition is\nreturned as the value of the expression.\n\n\n", "meta": {"hexsha": "c5f9b08cf899ec03d1097c8c5c96f35e6bb96f30", "size": 18698, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/res_quan/Manual/description.tex", "max_stars_repo_name": "LiLiming/HOL", "max_stars_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-27T07:51:47.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-27T07:51:47.000Z", "max_issues_repo_path": "src/res_quan/Manual/description.tex", "max_issues_repo_name": "LiLiming/HOL", "max_issues_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/res_quan/Manual/description.tex", "max_forks_repo_name": "LiLiming/HOL", "max_forks_repo_head_hexsha": "8de43bf3176993a37fb2f917fe978964c9d0591c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8731808732, "max_line_length": 175, "alphanum_fraction": 0.7140870681, "num_tokens": 5680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4350881274153972}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{url}\n\\usepackage[margin=0.75in]{geometry}\n\n\\setlength{\\parskip}{0.7em}\n\\setlength{\\parindent}{0em}\n\n\\begin{document}\n\t\\begin{center}\n\t\t\n\t\t% MAKE SURE YOU TAKE OUT THE SQUARE BRACKETS\n\t\t\\LARGE{\\textbf{CSE 6730, Group Proposal}} \\\\\n\t\t\\vspace{1em}\n\t\t\\Large{Project 2: Complex Simulation} \\\\\n\t\t\n\t\\end{center}\n\t\\begin{normalsize}\n\t\t\n\t\t\\section{Project Title}\n\t\t\n\t\tSimulation of Predator-Prey Population Dynamics\n\t\t\n\t\t\\section{Team Members}\n\t\t\n\t\t\\begin{enumerate}\n\t\t\t\\item D. Aaron Hillegass (GTID 901988533)\n\t\t\t\\item Siawpeng Er (GTID 903413430)\n\t\t\t\\item Xiaotong Mu (GTID 903529807)\n\t\t\\end{enumerate}\n\t\t\n\t\t\\section{Problem Description and Purpose}\n\t\tThe predator and prey relationship is an important ecological system. Their populations rise and fall over time as they interact and impact one another. These interactions are the prime movers of energy through food chains. Both prey and predators are affecting each other. In simplest interaction, predators depend on the prey as the food source. However, any abuse of the food source may result in decease in population of the prey, and subsequently decrease the number of the predators due to lack of food. Because of such interaction, the population of the predators and the prey may oscillate, and inversely proportional to each others.  \\\\\n\t\t\n\t\tPredator prey releationship is important for us to understand the impact of the relationship on the ecological system in one area. Such relationship is always complicated. Without predators, prey (normally herbivors) will cause detrimental impact on the plants in that area. However, overkill by the predators may also impact the balance of the nature. Besides, there are effects from human intervention on such relationship (eg: hunting and destroy of the habitat). Furthermore, predator-prey model can be used to describe many fundamental characteristics of ecological systems and can even be extended to other ideas like military response \\cite{derrik}.\\\\\n\t\t\n\t\tOne of the mathematical models that simulates predator and prey interactions is the Lotka-Volterra model proposed by Alfred Lotka and Vito Volterra. Lotka helped develop the logistic equation to explain autocatalytic chemical reactions. Volterra interconnected the logistic equation to two separate populations in competition to explain predator and prey relationships. We hope to use this intuitive model in our complex system simulation,  so that we could gain more understanding on the relationship, as well as the impact of our activities on such relationship.\n\t\t\n\t\t\\section{Data Source}\n\t\tFor this project, we plan to obtain some data from the National Park. However, it is also possible from literature review we could obtained some of the data source used by the their simulation and use it as our data source.\n\t\n\t\t\\section{Methodology}\n\t\tOur simulation will first simulate predators and prey entering and exiting a predefined area. Then through interactions, their population may affecting each others.\n\t\t\n\t\tTraditionally, there is the nonlinear Lotka-Volterra Model of the predator-prey dynamic system \\cite{inproceedings, 1102729}. LVM approach is a simplified model and suitable for detailed stability analysis. However, it is also very limited model and lack of flexibility for complex interaction. Hence, we also hope to incorporate the Agent-Based Model \\cite{Hodzic} in this project to increase the completeness of our analysis. \n\t\t\n\t\tIn our project, some of the ideas that we wish to investigate include:\n\t\t\\begin{enumerate}\n\t\t\t\\item Long-term population interaction among predators and prey.\n\t\t\t\\item Introduction of the uncertainties like diseases.\n\t\t\t\\item Introduction of the third parties interaction: human activity, natural disasters etc.\n\t\t\\end{enumerate}\n\t\t\n\t\t\\section{Development Platform}\n\t\tThe programming language is Python 3. We will provide a Jupyter notebook for user interaction.\n\t\tIn the Jupyter notebook, we will allow the user to change some of the probability and the simulation parameters to see different result of the simulation.\n\t\t\n\t\t\\section{Division of Labor}\n\t\tAs we move forward on our project, we plan to work concurrently. The timeline is as below:\n\t\t\n\t\t\\begin{center}\n\t\t\t\\begin{tabular}{ |c|c|c| } \n\t\t\t\t\\hline\n\t\t\t\tTask & Duration  \\\\ \n\t\t\t\t\\hline\n\t\t\t\tData collection & 2 weeks \\\\ \n\t\t\t\tModeling design and implementaion & 4 weeks \\\\ \n\t\t\t\tModeling revised & 4 weeks \\\\ \n\t\t\t\t\\hline\n\t\t\t\\end{tabular}\n\t\t\\end{center}\n\t\t\n\n\t\t\n\t\t\\bibliographystyle{plain}\n\t\t\\bibliography{reference}\n\t\\end{normalsize}\n\t\n\\end{document}\n", "meta": {"hexsha": "ad958ab856b1f615f396a19eaebd8752a483d4a6", "size": 4580, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/proposal/proposal.tex", "max_stars_repo_name": "hillegass/complex-sim", "max_stars_repo_head_hexsha": "acfd3849c19fa3361788a6e8f96ce76ca64be613", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-05T20:57:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-17T00:45:54.000Z", "max_issues_repo_path": "documentation/proposal/proposal.tex", "max_issues_repo_name": "hillegass/complex-sim", "max_issues_repo_head_hexsha": "acfd3849c19fa3361788a6e8f96ce76ca64be613", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/proposal/proposal.tex", "max_forks_repo_name": "hillegass/complex-sim", "max_forks_repo_head_hexsha": "acfd3849c19fa3361788a6e8f96ce76ca64be613", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.25, "max_line_length": 660, "alphanum_fraction": 0.7744541485, "num_tokens": 1081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.4350732500397881}}
{"text": "\\section{Deep Learning}\n\\label{sec:deep_learning}\n\n\n\\subsection{Why Machine Learning}\n\nMachine learning methods try to model either the joint or the marginal distribution of some covariates and some target. In statistics a model is usually explicitly formulated. A typical example could be linear regression. The covariates is decided on, and transformed such that they fit the desired model. The linear regression will yield a parameter vector which can then be interpreted. This interpretation is usually the focus; parameter inference. Example: Does an increase in the minimum salary have a negative effect on BNP per capita. Machine Learning focuses on prediction. That is, the objective is to predict some target conditional on some covariates. The specific model is not necessarily important, instead the focus is on Out-Of-Sample error. These predictive methods lend themselves well where causal inference is not needed. Example: What is the expected consumption on a monthly basis by person with a given set of characteristics. When formulating a traditional econometric method, e.g., OLS, there are standard ways to infer if the model is well specified. In general machine learning does not have the same asymptotic results regarding regularization of a model. Usually sample splitting will be used instead. Take a data set, split the data into two partitions a test set and a training set. First the hyper parameters of the machine learning algorithm is tuned, usually by finding which set of hyper parameters that yield the best performance on the training data. Cross validation is the go-to procedure to optimize the hyper parameters. The final algorithm is only used on the test data set once yielding the out-of-sample performance. Machine learning methods, as mentioned before usually has associated hyper parameters. These are parameters of the model, which is not fitted by training on the data, rather these are specifications of the algorithm before training the model. Much of machine learning is about finding the right hyper parameters and regularizing the model in an intelligent way \\parencite{friedman_elements_2001}. Now why is this paper concerned with ML methods? This is due to the fact, that when estimating the value function, or the policy function, one cannot be sure that this follows a linear function. In fact value functions and policy functions might be highly non-linear, which is where machine learning methods shine. Considering that the value function is a conditional expectation: $ \\E[Y \\mid X=x]$, where $Y$ is the expected cumulative discounted rewards and $X$ is the state implies, that machine learning methods is the appropriate choice for value function approximation. Also, in this case, causal interpretation of the influence of a specific state on the value function is not of interest, rather it's the accuracy of the expected value function\\footnote{Obviously, intelligent agents usually do causal inference on their actions. They might not do a certain action exactly because they have some causal notion of how the environment will evolve conditional on their action.}. Deep neural networks has been the standard way to implement reinforcement algorithms, however other machine learning methods can also be used. The reason for deep Learning methods being the standard implementation is the convenient property of online updating of the networks weights. In other words, as more data comes in, the neural network can be incrementally fitted to the new data.\n\n\\subsection{Deep Neural Networks}\n\nDeep learning (feed forward networks), which is used in this paper, is in fact just layered non-linear functions. Figure \\ref{fig:feedforwardnetwork} illustrates the architecture of a deep neural network\\footnote{Figure found at \\url{https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/MultiLayerNeuralNetworkBigger_english.png/381px-MultiLayerNeuralNetworkBigger_english.png}}.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[scale=0.6]{figures/feedforwardnetworkillustration.png}\n    \\caption{Illustration of Feed Forward Neural Network}\n    \\label{fig:feedforwardnetwork}\n\\end{figure}\n\nThe network can be described as having an \\textit{input layer}, that takes the covariates, $\\textbf{x}$. The \\textit{hidden layer} makes a transformation of the previous layer. This also implies that a hidden layer, can be followed by an arbitrary number of other hidden layers. Lastly an \\textit{output layer} maps the representation of the last hidden layer into the desired output. For classification that could be a one-hot encoding of the classes, and for regression a single real valued scalar.\n\nAs illustrated in figure \\ref{fig:feedforwardnetwork}, each layer is broken down into smaller cells. The number of cells in each layer corresponds to the width of the layer. The wider the layer the more flexible representation the given layer is capable of doing. The hidden cells work as mentioned by creating a non-linear transformation of the input from last layer:\n\n\\begin{equation}\n    z_i^{+} = g(\\textbf{z}; \\theta) = g(\\textbf{w}^T \\cdot \\textbf{z} + b)\n\\end{equation}\n\nThe output of cell \\textit{i} is the real valued scalar $z_i^+$. $g$ is the activation function that maps the input into the output. $\\textbf{w}$ is the weights of dot product, $\\textbf{z}$ is a vector of the outputs from the last layer, and $b$ is bias or the constant in the activation. In that sense the activation looks like a linear regression squashed through an activation function $g$. Multiple different activation functions has been proposed. Originally the logistic function was preferred, but in later years the rectified linear unit activation function has been popular \\parencite{goodfellow_deep_2016}:\n\n\\begin{equation}\n    \\textbf{Rectified Linear Unit: }  \\max \\lcp 0, \\textbf{w}^T \\cdot \\textbf{z} + b \\rcp\n\\end{equation}\n\nThe neural network can in other words be considered a function $f$, that takes an input $\\textbf{x}$ and maps it to some output $y$, parameterized by $\\theta$, which is a collection of all the weights and biases associated with each individual cell.\n\n\\subsection{Stochastic Gradient Descent and Optimization}\n\nThe neural network is estimated (or trained) by using stochastic gradient descent. This is possible due to the fact, that a neural network can be represented as a set of nested functions, such that the chain rule can be applied. The loss function can in other words be differentiated with respect to the parameter vector $\\theta$ as shown below:\n\n\\begin{equation}\\label{eq:loss_function}\n    \\frac{\\partial}{\\partial\\theta} \\Loss (\\textbf{X}, \\textbf{Y}, \\theta) = \\frac{\\partial}{\\partial\\theta} \\lp \\sum \\ell_i \\rp = \\frac{\\partial}{\\partial\\theta} \\lp \\sum \\lp \\hat{Y}_i  - Y_i \\rp^2 \\rp = \\frac{\\partial}{\\partial\\theta} \\lp \\sum \\lp f^{\\theta}(X_i)  - Y_i \\rp^2 \\rp\n\\end{equation}\n\nIn equation \\eqref{eq:loss_function} the loss function $\\Loss$ is assumed be a mean squared error loss function, in other words a regression problem. The optimization works by minimizing the loss with respect to the parameters $\\theta$. In modern neural network architectures it is not unusual to see neural networks have in the excess of a million parameters. The objective function of the optimization cannot be assumed to be convex due to the non-linearity of the activation functions. For this reason deep neural networks is not solved analytically. Instead, gradient descent is used for estimating the parameters of the network. The update rule of the parameters can be described as \\parencite{goodfellow_deep_2016}:\n\n\\begin{equation}\n    \\theta \\la \\theta - \\alpha \\nabla_{\\theta} \\Loss(\\textbf{X}, \\textbf{Y}, \\theta)\n\\end{equation}\n\nSo for each step in the algorithm the derivative of the loss function with respect to the parameters can be calculated, and the parameters can be updated by taking a small step in parameter space of size $\\alpha$ in the direction that reduces the loss. Stochastic gradient is a response to the fact that it can be computationally expensive to calculate the gradient for the entire data set in each update step. This is important for deep neural networks, since the training period of a large network, even on optimized hardware, can take a very long time, so any speed up for the training is important. In practice this implies that the training data is split into mini batches usually of size 32 to 128. The optimization is then performed on each of the small batches, taking a small step of size $\\alpha$ for each step.\n\n\n", "meta": {"hexsha": "9ff0769169c530e2a649fe8be07b41e855b4a1da", "size": 8538, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/deeplearning.tex", "max_stars_repo_name": "JakartaLaw/speciale", "max_stars_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/deeplearning.tex", "max_issues_repo_name": "JakartaLaw/speciale", "max_issues_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/deeplearning.tex", "max_forks_repo_name": "JakartaLaw/speciale", "max_forks_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 161.0943396226, "max_line_length": 3428, "alphanum_fraction": 0.7936284844, "num_tokens": 1869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.435073246973073}}
{"text": "\n\\subsubsection{\\lst{GroupElement.getEncoded} method (Code 7.2)}\n\\label{sec:type:GroupElement:getEncoded}\n\\noindent\n\\begin{tabularx}{\\textwidth}{| l | X |}\n   \\hline\n   \\bf{Description} & Get an encoding of the point value. \\\\\n  \n  \\hline\n  \\bf{Parameters} &\n      \\(\\begin{array}{l l l}\n         \n      \\end{array}\\) \\\\\n       \n  \\hline\n  \\bf{Result} & \\lst{Coll[Byte]} \\\\\n  \\hline\n  \n  \\bf{Serialized as} & \\hyperref[sec:serialization:operation:PropertyCall]{\\lst{PropertyCall}} \\\\\n  \\hline\n       \n\\end{tabularx}\n\n\n\n\\subsubsection{\\lst{GroupElement.exp} method (Code 7.3)}\n\\label{sec:type:GroupElement:exp}\n\\noindent\n\\begin{tabularx}{\\textwidth}{| l | X |}\n   \\hline\n   \\bf{Description} & Exponentiate this \\lst{GroupElement} to the given number. Returns this to the power of k \\\\\n  \n  \\hline\n  \\bf{Parameters} &\n      \\(\\begin{array}{l l l}\n         \\lst{k} & \\lst{: BigInt} & \\text{// The power} \\\\\n      \\end{array}\\) \\\\\n       \n  \\hline\n  \\bf{Result} & \\lst{GroupElement} \\\\\n  \\hline\n  \n  \\bf{Serialized as} & \\hyperref[sec:serialization:operation:Exponentiate]{\\lst{Exponentiate}} \\\\\n  \\hline\n       \n\\end{tabularx}\n\n\n\n\\subsubsection{\\lst{GroupElement.multiply} method (Code 7.4)}\n\\label{sec:type:GroupElement:multiply}\n\\noindent\n\\begin{tabularx}{\\textwidth}{| l | X |}\n   \\hline\n   \\bf{Description} & Group operation. \\\\\n  \n  \\hline\n  \\bf{Parameters} &\n      \\(\\begin{array}{l l l}\n         \\lst{other} & \\lst{: GroupElement} & \\text{// other element of the group} \\\\\n      \\end{array}\\) \\\\\n       \n  \\hline\n  \\bf{Result} & \\lst{GroupElement} \\\\\n  \\hline\n  \n  \\bf{Serialized as} & \\hyperref[sec:serialization:operation:MultiplyGroup]{\\lst{MultiplyGroup}} \\\\\n  \\hline\n       \n\\end{tabularx}\n\n\n\n\\subsubsection{\\lst{GroupElement.negate} method (Code 7.5)}\n\\label{sec:type:GroupElement:negate}\n\\noindent\n\\begin{tabularx}{\\textwidth}{| l | X |}\n   \\hline\n   \\bf{Description} & Inverse element of the group. \\\\\n  \n  \\hline\n  \\bf{Parameters} &\n      \\(\\begin{array}{l l l}\n         \n      \\end{array}\\) \\\\\n       \n  \\hline\n  \\bf{Result} & \\lst{GroupElement} \\\\\n  \\hline\n  \n  \\bf{Serialized as} & \\hyperref[sec:serialization:operation:PropertyCall]{\\lst{PropertyCall}} \\\\\n  \\hline\n       \n\\end{tabularx}\n", "meta": {"hexsha": "dc9922b3dc387b39d06dd5e44c7d1eb5370f0460", "size": 2205, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/spec/generated/GroupElement_methods.tex", "max_stars_repo_name": "jozanek/sigmastate-interpreter", "max_stars_repo_head_hexsha": "251784a9f7c1b325c4859fe256c9fe3862fffe4e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 41, "max_stars_repo_stars_event_min_datetime": "2017-04-21T13:18:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-23T19:27:50.000Z", "max_issues_repo_path": "docs/spec/generated/GroupElement_methods.tex", "max_issues_repo_name": "jozanek/sigmastate-interpreter", "max_issues_repo_head_hexsha": "251784a9f7c1b325c4859fe256c9fe3862fffe4e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 486, "max_issues_repo_issues_event_min_datetime": "2017-12-08T13:07:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T11:02:28.000Z", "max_forks_repo_path": "docs/spec/generated/GroupElement_methods.tex", "max_forks_repo_name": "jozanek/sigmastate-interpreter", "max_forks_repo_head_hexsha": "251784a9f7c1b325c4859fe256c9fe3862fffe4e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-12-28T11:19:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:12:08.000Z", "avg_line_length": 23.2105263158, "max_line_length": 113, "alphanum_fraction": 0.6181405896, "num_tokens": 735, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911056, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4350732408396424}}
{"text": "\\documentclass[10pt]{beamer}\n\n\\usetheme[progressbar=frametitle]{metropolis}\n\\usepackage{mathtools}\n\\usepackage{booktabs}\n\\usepackage{setspace}\n\\usepackage{listings}\n\n%\\usepackage{pgfplots}\n%\\usepgfplotslibrary{dateplot}\n\n\\usepackage{xspace}\n\\newcommand{\\order}[1]{\\mathcal{O}(#1)}\n\n%color definitions\t\n\\definecolor{ourgreen}{rgb}{0,0.6,0}\n\\definecolor{ourgray}{rgb}{0.5,0.5,0.5}\n\\definecolor{ourmauve}{rgb}{0.58,0,0.82}\n\n%code style\n\\lstset{ \nfirstnumber=1,\nlanguage=python, % choose the language of the code\nnumbers=left,\nstepnumber=1,% the step between two line-numbers. If it is 1 each line will be numbered\nnumbersep=5pt, % how far the line-numbers are from the code\nframe=single,% adds a frame around the code\ncommentstyle=\\color{ourgreen},    % comment style\nkeywordstyle=\\color{blue},       % keyword style\nstringstyle=\\color{ourmauve},     % string literal style\nbreaklines=true, % sets automatic line breaking \nbasicstyle=\\tiny,\n}\n\n\n\n\\title{Generating Trapdoor Primes}\n\\subtitle{A short take on generating SNFS primes}\n% \\date{\\today}\n\\date{}\n\\author{Nikolai Rozanov}\n\\institute{UCL - Computer Science}\n% \\titlegraphic{\\hfill\\includegraphics[height=1.5cm]{logo.pdf}}\n\n\\begin{document}\n\n\\maketitle\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% TOC and Introduction\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}{Table of contents - Introduction}\n  \\setbeamertemplate{section in toc}[sections numbered]\n  \\tableofcontents[hideallsubsections]\n\\end{frame}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Importance\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Importance}\n\\begin{frame}[fragile]{Importance}\n\n\\begin{itemize}\n\\item Look Up\n\\item Benchmarking\n\\item Deliberate Weakening\n\\end{itemize}\n\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Method and Code\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Method and Code}\n\n\\begin{frame}[fragile]{Algorithm}\n\\begin{enumerate}[\\textbf{Step} 1.]\n\\item Generating the prime q of the corresponding size.\n\\item Generating the coefficients for polynomials f and g, according to the size suggestions in \\cite{Paper} \n\\item Setting up a new polynomial G, which is the resultant of f and g and the variable is the leading coefficient of g.\n\\item Finding roots of G-1 modulo q, if there are no roots then going back to Step 1. \n\\item Then letting p=$|G|$, and checking if p is prime, (an addition is to check whether q divides p-1).\n\\end{enumerate}\n\\end{frame}\n\\begin{frame}[fragile]{Main Script}\n\\textbf{Main Script}\n\\begin{lstlisting}\n# Generating required Rings\nX.<x>     = ZZ['x']\nG.<x,g1>  = ZZ['x,g1']\n# Main Loop\n    #generating prime and Associated Field\n    q = get_prime(bits_q)\n    T.<g2>    = Integers(q)['g2']\n\t##while loop\n        f_poly,norm_f = get_f(X,degree_f,bits_q)\n        g_poly,g0 = get_g(g1,x,bits_p,degree_f, norm_f)\n        G_poly = get_G(f_poly,g_poly)\n        temp = list(G_poly.coefficients())\n        temp.reverse()\n        T2 = T(temp)\n    r    = T2.roots()\n    root = r[0][0]\n    rt   = int(root)\n#    while(rt<int(2^(bits_p/degree_f)/norm_f)):\n#        rt+=q\n    p    = X([G_poly(1,rt)+1])\n\\end{lstlisting}\n\\end{frame}\n\n\n\n\n\\begin{frame}[fragile]{Helper Functions}\n\\begin{alertblock}{Helper Functions}\\end{alertblock}\n\\textbf{Prime Generation}\n\\begin{lstlisting}\ndef get_prime(bits_q):\n    q = random_prime(2^bits_q-1,False,2^(bits_q-1))\n    while(not is_prime(q)):\n        q = random_prime(2^bits_q-1,False,2^(bits_q-1))\n    return q\n \\end{lstlisting}\n \\textbf{Poly f}\n \\begin{lstlisting}\ndef get_f(X,degree_f, bits_q):\n    flag_irreducible = False\n    while (not flag_irreducible):\n        #f_vec = [ZZ.random_element(-int(2^(10)-1),int(2^(10)-1)) for _ in range(degree_f+1)]\n        f_vec = [ZZ.random_element(-int(2^(bits_q/(2*(degree_f+1)))),int(2^(bits_q/(2*(degree_f+1))))) for _ in range(degree_f+1)]\n        #f_vec = [ZZ.random_element(1,int(2^(bits_q/(2*(degree_f+1))))) for _ in range(degree_f+1)]\n\n        norm_f = max(map(abs,f_vec))\n        f_poly = X(list(f_vec))\n        if f_poly.is_irreducible():\n            flag_irreducible = True\n    return f_poly,norm_f\n        \\end{lstlisting}\n\\end{frame}\n\n\n\\begin{frame}[fragile]{Helper Functions}\n\\textbf{Poly g}\n \\begin{lstlisting}\ndef get_g(g1,x,bits_p,degree_f,norm_f):\n    g0 = ZZ.random_element(-int(2^(bits_p/degree_f)/norm_f),int(2^(bits_p/degree_f)/norm_f))\n    #g0 = ZZ.random_element(1,int(2^(bits_p/degree_f)/norm_f))\n    g_poly = g1*x+g0\n    return g_poly,g0\n        \\end{lstlisting}\n\\textbf{Poly G}\n\\begin{lstlisting}\ndef get_G(f_poly,g_poly):\n    G_temp = f_poly.sylvester_matrix(g_poly,variable=x)\n    G_poly = G_temp.determinant()-1\n    return G_poly   \n\\end{lstlisting}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Main Results\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Some Analysis}\n\n\\begin{frame}[fragile]{Plots}\n\\textbf{Running Time Data}\n\\begin{figure}[H]\n\\minipage{0.9\\textwidth}\n  \\includegraphics[width=\\linewidth]{Data.png}\n\\endminipage\n\\end{figure}\n\\end{frame}\n\n\n\\begin{frame}[fragile]{Plots}\n\\textbf{Running Time Plot}\n\\begin{figure}[H]\n\\minipage{0.9\\textwidth}\n  \\includegraphics[width=\\linewidth]{together.png}\n\\endminipage\n\\end{figure}\n\\end{frame}\n\n\n\n\n\\begin{frame}[allowframebreaks]{References}\n\n  \\bibliography{bibliography}\n  \\bibliographystyle{abbrv}\n\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "88ea99a61b4374c2037c30fe379802071b50e57e", "size": 5425, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Presentation/presentation.tex", "max_stars_repo_name": "Kolyan-1/SNFS-Primes", "max_stars_repo_head_hexsha": "06756ec38f66b334ebbe8f1e81d9b7c260e8c858", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Presentation/presentation.tex", "max_issues_repo_name": "Kolyan-1/SNFS-Primes", "max_issues_repo_head_hexsha": "06756ec38f66b334ebbe8f1e81d9b7c260e8c858", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Presentation/presentation.tex", "max_forks_repo_name": "Kolyan-1/SNFS-Primes", "max_forks_repo_head_hexsha": "06756ec38f66b334ebbe8f1e81d9b7c260e8c858", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0817307692, "max_line_length": 130, "alphanum_fraction": 0.6431336406, "num_tokens": 1613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639792, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.43505870886959186}}
{"text": "% !TeX spellcheck = en_GB\n% !TeX root = memoco-report.tex\n\n\\section{Introduction}\n\\label{chap:introduction}\n\n\\subsection{Description of the problem}\nThe task of the exercise was to develop two algorithms capable of solving the Travelling Salesman Problem (TSP), specialized to the domain of drilling holes in electric panels. Given a sequence of holes to be drilled in an electric panel, the algorithms should be used to find a sequence of holes that minimizes the cost of drilling the whole panel, where the costs are given by the euclidean distances between holes. For simplicity it is assumed that the cost of drilling every hole can be ignored.\\\\ \nThe first algorithm implements an exact methods using the IBM CPLEX optimization suite. The second algorithm is an approximated heuristic, inspired by the Lin-Kernighan algorithm \\cite{LinK73}. Some implementation details has been taken from \\cite{ImplemLK}. \\\\\nBoth algorithms have been tested on synthetic instances produced taking into account the applicative domain. The two algorithms are described in the following pages, and tests and results are reported in the last sections.\n\n\\subsection{Description of provided material}\n%\\minitoc\nThe delivered material includes all the produced code and everything necessary to run the program.\nThe provided archive comes with the following structure:\n\\renewcommand*\\DTstylecomment{\\rmfamily\\color{blue}\\textit}\n\\dirtree{%\n\t.1 /.\n\t.2 bin/\\DTcomment{Binary files folder (after compiling)}.\n\t.2 build/\\DTcomment{Build files folder (after compiling)}.\n\t.2 files/\\DTcomment{Logs folder (after running)}.\n\t.2 instances/\\DTcomment{Contains csv files to load}.\n\t.2 plots/.\n\t.2 src/.\n\t.3 utils/.\n\t.4 cpxmacro.hpp.\n\t.4 params.hpp.\n\t.4 python\\_adapter.hpp\\DTcomment{Wrapper class for Python embedding}.\n\t.4 variadic\\_table.hpp\\DTcomment{Library to print tables}.\n\t.4 yaml\\_parser.hpp\\DTcomment{Parser for the configuration file}.\n\t.3 calibrate.cpp\\DTcomment{Calibration script}.\n\t.3 config.yml.\n\t.3 CPLEX.cpp.\n\t.3 CPLEX.hpp.\n\t.3 LK.cpp.\n\t.3 LK.hpp.\n\t.3 main.cpp\\DTcomment{Program main}.\n\t.3 Pair.cpp.\n\t.3 Pair.hpp.\n\t.3 plot\\_script.py\\DTcomment{Script to plot with Python}.\n\t.3 test.cpp\\DTcomment{Test script}.\n\t.3 Tour.cpp.\n\t.3 Tour.hpp.\n\t.3 TSPinstance.cpp.\n\t.3 TSPinstance.hpp.\n\t.3 TSPsolution.cpp.\n\t.3 TSPsolution.hpp.\n\t.3 utilities.cpp.\n\t.3 utilities.hpp.\n}\n\n\\subsubsection{How to run}\nThe program has the following dependencies:\n\\begin{itemize}\n\t\\setlength\\itemsep{0.03em}\n\t\\item \\texttt{g++ 7} or higher;\n\t\\item \\texttt{IBM ILOG CPLEX Optimization Studio 12.8} or higher;\n\t\\item \\texttt{Python 2.7}.\n\\end{itemize}\n\nTo test the program, some instances should be generated or imported by placing them in the \\texttt{instances/} folder. Some files are already provided in this folder to launch some tests. To generate new instances set \\texttt{generate\\_instances: true} in the \\texttt{config.yml} file, and the other parameters as desired. If \\texttt{N\\_min = 20, N\\_incr = 5, N\\_max = 30}, three \\texttt{csv} files containing the coordinates of every point will be generated, with size 20, 25 and 30 respectively, and will be placed in the instances folder. After that it is possible to run the exact method or the heuristic on these instances. To do that, add to the list in \\texttt{instances\\_to\\_read} the filename (without extension) of the files that should be read and set \\texttt{solve\\_heur} and \\texttt{solve\\_cplex} as desired. Some reasonable parameters for the heuristic are already set, but it is possible to change them if necessary. A description of these specific parameters is provided in \\cref{ssec:hyperpar}.\nThe script can then be run from a Linux environment with \\texttt{make \\&\\& ./bin/main}. The algorithm writes its output in file \\texttt{solLK.txt} and \\texttt{solCPLEX.txt} under the \\texttt{files/} folder. When solving more than one problem, these files can also be checked while the program is running to monitor its execution. Additionally running the heuristic also produces an image of the final solution and places it in folder \\texttt{plots/}. Furthermore, running both CPLEX and the heuristic together will produce plots with a comparison of the execution times and error values in the same folder. \\\\\n\n\\subsection{Development environment}\nThe specifics of the machine used for development, calibration and test of the program are listed in \\cref{tab:maspecs}.\n\\begin{table}[H]\n\t\\caption{Hardware and software specifics}\n\t\\label{tab:maspecs}\n\t\\centering\n\t\\begin{tabular}[t]{ll}\n\t\t\\rowcolor[HTML]{EFEFEF}\n\t\t\\textbf{Specific} & \\textbf{Value} \\\\\n\t\tOS       & Ubuntu 18.04.4 LTS 64 bit\t   \\\\\n\t\tProcessor & Intel Core i7-7500U 2.70GHz $\\times$ 4     \\\\\n\t\tMain memory  & 16 GB  \n\t\\end{tabular}\n\\end{table}\n\n\\section{Dataset generation}\n\\label{sec:datasetgen}\nIn order to test the two algorithms, a procedure to build a synthetic dataset of different sizes has been provided.\\\\ \nThe procedure to generate the TSP instances receives as an input a number $N$ of points (which symbolises holes) and generates $N$ pairs representing the coordinates in space of the points on a $N\\times N$ square canvas. These points are distributed in a way to resemble the regularity usually found in the disposition of holes in electric panels.\\\\ \nTo do this the procedure draws some regular polygons with up to $10$ sides. Each polygon is generated independently and may overlap with the others, creating not perfectly regular shapes, but neither a completely random point distribution. An example of such an instance is shown in \\cref{fig:dataexample}. All this operations, as well as the function to load already generated instances from \\texttt{csv} files, are implemented in \\texttt{TSPinstance.cpp}.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=13cm]{path_100}\n\t\\caption{A generated instance of with size N = 100}\n\t\\label{fig:dataexample}\n\\end{figure}\n\n\n", "meta": {"hexsha": "64d8134d4ac47303c8caff064bb181b6cbe06fb3", "size": 5876, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/01-introduction.tex", "max_stars_repo_name": "alek9z/LK-heuristic", "max_stars_repo_head_hexsha": "aa04dcbc9dca3ed434cf4ecf38e4cda9df65d448", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-06T10:20:26.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-06T10:20:26.000Z", "max_issues_repo_path": "report/01-introduction.tex", "max_issues_repo_name": "ALIENK9/MeMoCo", "max_issues_repo_head_hexsha": "aa04dcbc9dca3ed434cf4ecf38e4cda9df65d448", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/01-introduction.tex", "max_forks_repo_name": "ALIENK9/MeMoCo", "max_forks_repo_head_hexsha": "aa04dcbc9dca3ed434cf4ecf38e4cda9df65d448", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.1827956989, "max_line_length": 1011, "alphanum_fraction": 0.771102791, "num_tokens": 1504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.4350587017350601}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[pdftex]{graphicx}\n\\newcommand{\\kg}{\\mathrm{kg}}\n\\newcommand{\\m}{\\mathrm{m}}\n\\newcommand{\\cm}{\\mathrm{cm}}\n\\newcommand{\\s}{\\mathrm{s}}\n\\newcommand{\\ms}{\\mathrm{ms}}\n\\newcommand{\\N}{\\mathrm{N}}\n\\newcommand{\\vs}{\\emph{vs}}\n\\newcounter{problem}\n\\stepcounter{problem}\n\\newcounter{answer}[problem]\n\\newenvironment{problem}{\\noindent\\begin{minipage}{\\textwidth}\\sloppy\\sloppypar\\raggedright\\textbf{\\theproblem.}\\refstepcounter{problem}\\stepcounter{answer}---}{\\end{minipage}\\vspace{2ex}}\n\\newcommand{\\source}[1]{[{#1}]}\n\\newenvironment{answers}{\\\\}{}\n\\newcommand{\\answer}[1]{\\textbf{\\Alph{answer}:}\\refstepcounter{answer}~\\mbox{#1}\\hspace{3ex}}\n\\begin{document}\n\n\\section*{NYU General Physics 1---Term Exam 1}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-06} Roughly what is the mass of a cube\n  of rock of side length $10\\,\\m$?\n  \\begin{answers}\n    \\answer{$600\\,\\kg$}\n    \\answer{$60,000\\,\\kg$}\n    \\answer{$6,000,000\\,\\kg$}\n    \\answer{$600,000,000\\,\\kg$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-08} How long does it take a heavy\n  object to fall (from rest) about $5\\,\\m$?\n  \\begin{answers}\n    \\answer{much less than $0.01\\,\\s$}\n    \\answer{about $0.01\\,\\s$}\n    \\answer{about $0.1\\,\\s$}\n    \\answer{about $1\\,\\s$}\n    \\answer{much more than $1\\,\\s$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-13} We spoke of a girl throwing a\n  stone.  When the stone is precisely at the \\emph{highest} point on\n  its trajectory (at the apex), and ignoring air resistance, the\n  acceleration of the stone:\n  \\begin{answers}\n    \\answer{is zero}\n    \\answer{is downwards at $9.8\\,\\m\\,\\s^{-2}$}\n    \\answer{depends on the velocity}\n    \\answer{is none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-15} Which of the following position\n  \\vs\\ time graphs is a possible path for a car undergoing normal\n  kinds of acceleration and deceleration?\n  \\\\\\includegraphics{../py/x_vs_t_options.pdf}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-20} What is the magnitude $|\\vec{N}|$\n  of the normal force for a block on a frictionless plane inclined at\n  an angle $\\theta$ to the horizontal?\n  \\begin{answers}\n    \\answer{$|\\vec{N}| = m\\,|\\vec{g}|\\,\\cos\\theta$}\n    \\answer{$|\\vec{N}| = m\\,|\\vec{g}|\\,\\sin\\theta$}\n    \\answer{$|\\vec{N}| = |\\vec{g}|\\,\\cos\\theta$}\n    \\answer{$|\\vec{N}| = |\\vec{g}|\\,\\sin\\theta$}\n    \\answer{$|\\vec{N}| = m\\,|\\vec{g}|$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-20} For the block on the inclined\n  plane, by what method did we figure out the \\emph{direction} of the\n  acceleration?\n  \\begin{answers}\n    \\answer{Acceleration is always perpendicular to gravity.}\n    \\answer{Acceleration is always perpendicular to a normal force.}\n    \\answer{We used $\\vec{F}=m\\,\\vec{a}$.}\n    \\answer{We used common sense and/or physical intuition.}\n    \\answer{We used none of the above.}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-22} We considered a machine that had\n  two blocks, one $2\\,\\kg$, one $4\\,\\kg$, attached by a light string\n  with tension $T_4$ in the string.  The $T_4$ string was draped over\n  a light, fixed, frictionless pulley.  What is true of this tension\n  $T_4$ (if we set $g=10\\,\\m\\,\\s^{-2}$)?\n  \\begin{answers}\n    \\answer{$T_4 = 20\\,\\N$}\n    \\answer{$20 < T_4 < 30\\,\\N$}\n    \\answer{$30 \\leq T_4 < 40\\,\\N$}\n    \\answer{$T_4 = 40\\,\\N$}\n    \\answer{$T_4 > 40\\,\\N$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-27} A plane is flying in a circular\n  path at speed $v$.  The circle has radius $R$.  If the plane flies\n  for a short time $t$, by what angle $\\theta$ does its direction\n  change during that time?\n  \\begin{answers}\n    \\answer{$\\displaystyle\\theta = \\frac{R\\,t}{v}$}\n    \\answer{$\\displaystyle\\theta = \\frac{v}{R\\,t}$}\n    \\answer{$\\displaystyle\\theta = \\frac{R}{v\\,t}$}\n    \\answer{$\\displaystyle\\theta = \\frac{v\\,t}{R}$}\n    \\answer{none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from lecture 2011-09-29} A textbook of mass $m$ slams into a\n  hard surface.  Before the collision, the textbook is moving at speed\n  $v$.  The textbook stops in a time $\\Delta t$.  After the collision,\n  the textbook is at rest.  The magnitude of the force of impact is\n  roughly\n  \\begin{answers}\n    \\answer{$\\displaystyle m\\,\\frac{v}{\\Delta t}$}\n    \\answer{$\\displaystyle \\frac{v}{\\Delta t}$}\n    \\answer{$\\displaystyle m\\,\\frac{\\Delta t}{v}$}\n    \\answer{$\\displaystyle \\frac{\\Delta t}{v}$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 1, problem 1} At 1500 dollars per ounce\n  (29\\,g), roughly what is the mass of $100$ million dollars worth of\n  gold?\n  \\begin{answers}\n    \\answer{much less than $20\\,\\kg$}\n    \\answer{$20\\,\\kg$}\n    \\answer{$2,000\\,\\kg$}\n    \\answer{$200,000\\,\\kg$}\n    \\answer{much more than $200,000\\,\\kg$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 1, problem 2} What combination of length $L$,\n  density $\\rho$, and speed $v$ have dimensions of force?\n  \\begin{answers}\n    \\answer{$\\rho\\,L\\,v$}\n    \\answer{$\\rho\\,L\\,v^2$}\n    \\answer{$\\rho\\,L^2\\,v$}\n    \\answer{$\\rho\\,L^2\\,v^2$}\n    \\answer{none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 1, problem 3} The dynamic viscosity $\\mu$\n  has dimensions of mass per length per time (units of\n  $\\kg\\,\\m^{-1}\\,\\s^{-1}$).  What combination of dynamic viscosity\n  $\\mu$, length $L$, and speed $v$ have units of force?\n  \\begin{answers}\n    \\answer{$\\mu\\,L\\,v$}\n    \\answer{$\\mu\\,L\\,v^2$}\n    \\answer{$\\mu\\,L^2\\,v$}\n    \\answer{$\\mu\\,L^2\\,v^2$}\n    \\answer{none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 2, problem 1} A dragster travels 0.25\\,mi\n  in 5.5\\,s, starting from rest.  Under the assumption of constant\n  acceleration, what is the time it takes the dragster to go half-way;\n  that is, how many seconds does it take to go the first 0.125\\,mi?\n  \\begin{answers}\n    \\answer{substantially less than $1.38\\,\\s$}\n    \\answer{$1.38\\,\\s$}\n    \\answer{$2.75\\,\\s$}\n    \\answer{$3.9\\,\\s$}\n    \\answer{substantially more than $3.9\\,\\s$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 2, problem 1} Again, the dragster: Two cars\n  start from rest and accelerate at constant acceleration over a\n  distance $X$.  If car $F$ goes at twice the acceleration of car $S$,\n  by what factor is car $S$ slower?  That is, what is the ratio of the\n  time $t_S$ taken by car $S$ to the time taken by car $F$?\n  \\begin{answers}\n    \\answer{$1$}\n    \\answer{$\\sqrt{2}$}\n    \\answer{$2$}\n    \\answer{$4$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 2, problem 2} Which of the following graphs\n  is a possible graph of the velocity as a function of time for an\n  object thrown upwards at $3\\,\\m\\,\\s^{-1}$ at $t=0$ and then falling\n  freely?\n  \\\\\\includegraphics{../py/vy_vs_t_options.pdf}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 2, problem 3} Below is a graph of velocity\n  $v_x$ in the $x$ direction as a function of time for an automobile.\n  \\\\\\includegraphics{../py/vx_vs_t.pdf}\\\\\n  How far does the automobile travel between $t=0$ and $t=35\\,\\s$?\n  \\begin{answers}\n    \\answer{$5\\,\\m$}\n    \\answer{$175\\,\\m$}\n    \\answer{$425\\,\\m$}\n    \\answer{$525\\,\\m$}\n    \\answer{much more than $525\\,\\m$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 3, problem 1} If $g$ is the acceleration\n  due to gravity and $R$ is the radius of the Earth, what, roughly, is\n  the orbital period of the Space Station?\n  \\begin{answers}\n    \\answer{$\\displaystyle 2\\pi\\,\\sqrt{\\frac{R}{g}}$}\n    \\answer{$\\displaystyle 2\\pi\\,\\sqrt{\\frac{g}{R}}$}\n    \\answer{$\\displaystyle 2\\pi\\,\\sqrt{R\\,g}$}\n    \\answer{$\\displaystyle 2\\pi\\,\\sqrt{\\frac{1}{R\\,g}}$}\n    \\answer{none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 3, problem 2} What is the tension T in this\n  problem?\\\\\\includegraphics{../py/stringblocks.pdf}\n  \\begin{answers}\n    \\answer{$\\displaystyle F\\,\\frac{m_1}{m_1+m_2}$}\n    \\answer{$\\displaystyle F\\,\\frac{m_2}{m_1+m_2}$}\n    \\answer{$\\displaystyle F$}\n    \\answer{$\\displaystyle m_1\\,g$}\n    \\answer{$\\displaystyle m_2\\,g$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 3, problem 3} A block of mass $m=9\\,\\kg$\n  lies on a horizontal table.  It is stationary relative to the table.\n  Now imagine that the table is accelerating upwards with an\n  acceleration of magnitude $0.5\\,\\m\\,\\s^{-2}$.  What is the magnitude\n  of the force on the block from the table?  For ease of calculation,\n  take $g=10\\,\\m\\,\\s^{-2}$.\n  \\begin{answers}\n    \\answer{$4.5\\,\\N$}\n    \\answer{$85.5\\,\\N$}\n    \\answer{$90.0\\,\\N$}\n    \\answer{$94.5\\,\\N$}\n    \\answer{much more than $94.5\\,\\N$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 4, problem 1} A block of mass $m$ sits on a\n  plane inclined at an angle of $\\theta=20\\,\\deg$ to the horizontal.\n  There is a coefficient of friction $\\mu=0.9$ between the block and\n  the plane.  What is the magnitude of the frictional force?\n  \\begin{answers}\n    \\answer{$m\\,g\\,\\cos\\theta$}\n    \\answer{$m\\,g\\,\\sin\\theta$}\n    \\answer{$\\mu\\,m\\,g\\,\\cos\\theta$}\n    \\answer{$\\mu\\,m\\,g\\,\\sin\\theta$}\n    \\answer{$\\mu\\,m\\,g\\,\\tan\\theta$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 4, problem 2} At the lowest point in its\n  swing, a mass swinging like a pendulum at the end of a light,\n  inextensible string is\n  \\begin{answers}\n    \\answer{not accelerating}\n    \\answer{accelerating upwards}\n    \\answer{accelerating downwards}\n    \\answer{accelerating in the direction of the velocity}\n    \\answer{accelerating in the direction opposite to the velocity}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from problem set 4, problem 3} A ball of mass $m$ and radius\n  $R$ drops from a height $h$ onto a flat surface.  It bounces.  In\n  which of these situations will the contact force (during the bounce)\n  be largest?\n  \\begin{answers}\n    \\answer{rubber ball on rubber surface}\n    \\answer{rubber ball on marble surface}\n    \\answer{steel ball on rubber surface}\n    \\answer{steel ball on marble surface}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from \\textit{Motion 1} lab} The motion sensor measured the\n  position of your notebook by making use of\n  \\begin{answers}\n    \\answer{the volume of reflected sound pulses}\n    \\answer{the brightness of reflected light pulses}\n    \\answer{the arrival times of reflected sound pulses}\n    \\answer{the arrival times of reflected light pulses}\n    \\answer{none of the above}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  \\source{from \\textit{Motion 2} lab} Take the second derivative with respect\n  to time $t$ of the expression $$x_0 + v_0\\,t +\n  \\frac{1}{2}\\,a\\,t^2$$.  What do you get?\n  \\begin{answers}\n    \\answer{$\\displaystyle x_0 + v_0\\,t + \\frac{1}{2}\\,a\\,t^2$}\n    \\answer{$\\displaystyle x_0 + v_0\\,t$}\n    \\answer{$\\displaystyle x_0$}\n    \\answer{$\\displaystyle v_0 + a\\,t$}\n    \\answer{$\\displaystyle a$}\n  \\end{answers}\n\\end{problem}\n\n\\begin{problem}\n  WRONG ANSWERS \\source{from \\textit{Equilibrium of a Particle} lab} Imagine that\n  there are three forces $\\vec{A}$, $\\vec{B}$ and $\\vec{C}$ acting on\n  a particle such that the particle is in equilibrium.  Now imagine\n  that forces $\\vec{B}$ and $\\vec{C}$ point in opposite directions from one another.\n  What is true of the force magnitudes?\n  \\begin{answers}\n    \\answer{$|\\vec{A}|^2 = |\\vec{B}|^2 + |\\vec{C}|^2$}\n    \\answer{$|\\vec{A}|^2 = |\\vec{B}|^2 + |\\vec{C}|^2 - |\\vec{B}|\\,|\\vec{C}|\\,\\cos{\\theta}$}\n    \\answer{$|\\vec{A}| = 0$ and $|\\vec{B}| = |\\vec{C}|$}\n    \\answer{All forces must have zero magnitude.}\n    \\answer{None of the above.}\n  \\end{answers}\n\\end{problem}\n\n\\end{document}\n", "meta": {"hexsha": "23de408bbe90f795dbcf3475a0c397bee4a2dfa3", "size": 11985, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/old/gp1_exam1_2011.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/old/gp1_exam1_2011.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/old/gp1_exam1_2011.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8401162791, "max_line_length": 188, "alphanum_fraction": 0.657571965, "num_tokens": 4105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.4350586981677942}}
{"text": "\\documentclass{classrep}\n\\usepackage[utf8]{inputenc}\n\\frenchspacing\n\n\\usepackage{graphicx}\n\\usepackage[usenames,dvipsnames]{color}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{lmodern}\n\\usepackage{placeins}\n\\usepackage{url}\n\\usepackage{amsmath, amssymb, mathtools}\n\\usepackage{listings}\n\\usepackage{fancyhdr, lastpage}\n\\usepackage{subfiles}\n\\usepackage{ifthen}\n\n\\pagestyle{fancyplain}\n\\fancyhf{}\n\\renewcommand{\\headrulewidth}{0pt}\n\\cfoot{\\thepage\\ / \\pageref*{LastPage}}\n\n% In order to change person, change value of variable\n\\newboolean{is_karwowski}\n\\setboolean{is_karwowski}{true}\n\n%--------------------------------------------------------------------------------------%\n\\studycycle{Applied Information Technology, 2 cycle}\n\\coursesemester{II}\n\n\\coursename{Soft Computing Laboratory}\n\\courseyear{2021/2022}\n\n\\courseteacher{dr inż. Kamil Stokfiszewski}\n\\coursegroup{Wednesday, 8:30}\n\n\\author{%\n    \\ifthenelse{\\boolean{is_karwowski}}\n    {\\studentinfo[239671@edu.p.lodz.pl]{Jan Karwowski}{239671}\\\\}\n    {\\studentinfo[239676@edu.p.lodz.pl]{Kamil Kowalewski}{239676}\\\\}\n}\n\n\\title{Assignment 5.: Kohonen Network for image compression}\n\n\\begin{document}\n    \\maketitle\n    \\thispagestyle{fancyplain}\n\n    \\tableofcontents\n    \\newpage\n\n    \\section{Main goal} \\label{main_goal} {\n        The main goal of this task is to prepare implementation of Kohonen network for\n        image compression. The images themselves should use 8-bit grayscale.\n    }\n\n    \\section{Theoretical background} \\label{theory} {\n        Kohonen Network is a kind of self organizing map, where neurons and input values represent\n        points (vectors) in N-dimensional space. The purpose of this model is to represent or\n        reproduce shape and distribution of input values using much more lower number of points. I.e\n        this algorithm groups input values into clusters (clusterize).\n\n        Kohonen Network consists of a single layer of neurons. It is trained in unsupervised manner\n        (without labels), and the training is based on simple rule \\emph{winner takes all}.  This\n        means, that for each input pattern only the most activated neuron's weights are modified.\n        Purpose of this weights change is to make the winner neuron closer (in some sens, e.g.\n        euclidean) to the input pattern.\n\n        Getting down to the possible implementation details, neuron's activation should depends on\n        \\emph{distance} to input pattern. If input patterns and weights are normalized, this\n        distance (or rather similarity) could be calculated as a simple dot product. If there is no\n        normalization then euclidean distance could be used. After finding the nearest neuron\n        (winner) for the particular pattern, neuron's weights are modified according to the\n        following equation:\n        \\begin{equation}\n            w_{i} = w_{i} + \\eta (x_{i} - w_{i})\n        \\end{equation}\n        where $w_{i}$ and $x_{i}$ are the i-th element of weight and input vectors respectively,\n        $\\eta$ is a learning rate.\n\n        To compress an image using described algorithm, it should be divided to a sequence of\n        random, relatively small crops (e.g. 4x4 or 16x16). Such a sequence constructs training set,\n        and as a result of training Kohonen Network these crops are grouped into clusters.  To\n        compress an image it should be divided to chunks and these chunks should be treated as input\n        patterns and replaced by weights of the most activated neuron. When the network was trained\n        without normalization this substitution is enough. When weights and input\n        patterns are normalized, then pixel intensity information is lost and should be\n        remembered for each chunk during compression.\n    }\n\n    \\section{Implementation} \\label{implementation} {\n        Created program consists of two main modules. The first one is a pure Kohonen Network\n        implementation, the second one is responsible for an image compression. Ours Kohonen Network\n        can work in two modes - with and without normalization, which implies small differences in\n        implementation. When the network is created its weights are initialized and all the input\n        patterns are remembered for further training. If in \\emph{normalize} mode, these two\n        matrices are normalized. To train a network its \\emph{train\\_step} method should be called\n        iteratively. Within this function single training step is proceed - for each input pattern\n        winner neuron is found and its weights are updated. Winner selection depends on the running\n        mode. If in \\emph{normalize} mode, then dot product is calculated and the most activated\n        neuron is a winner. If not in \\emph{normalize} mode, then euclidean distance to each neuron\n        is calculated and the nearest one is a winner. After that, dead neurons, which are not\n        modified for all the input patterns in a single training step, are randomly initialized.\n        Number of dead neurons and max winner weight's modification are remembered to defined stop\n        constraint. Our algorithm stops if there is no dead neurons and maximum winner weight's\n        modification is lower then $0.00001$ part of input patterns' min-max values range.\n        Optionally, if in \\emph{normalize} mode, after each training step neurons' weights are\n        normalized.\n\n        To compress an image it is read into memory in a grayscale mode. Then given number of\n        random crops in given shape are extracted from the image. These random crops build dataset,\n        which Kohonen Network is trained on. After training process, given number of neurons is\n        available to use. Image is splitted into crops and each crop is replaced by weights of\n        neuron, which is the most activated in response to the image crop. This is how decompressed\n        image view is simulated. Additionally PSNR value and compression ratio are calculated.\n    }\n\n    \\section{Experiments and results} \\label{results} {\n        \\ifthenelse{\\boolean{is_karwowski}}\n        {\\subfile{section/karwowski_results.tex}}\n        {\\subfile{section/kowalewski_results.tex}}\n    }\n\n    \\section{Summary and conclusions} \\label{summary} {\n        \\ifthenelse{\\boolean{is_karwowski}}\n        {\\subfile{section/karwowski_summary.tex}}\n        {\\subfile{section/kowalewski_summary.tex}}\n    }\n\n    \\begin{thebibliography}{0}\n        % @formatter:off\n        \\bibitem{instruction}{Labolatory instruction, URL: https://ftims.edu.p.lodz.pl/pluginfile.php/75444/\\\\mod\\_resource/content/1/soft\\_comp\\_lab\\_05\\_KOHONEN.pdf}\n        % @formatter:on\n    \\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "9f5a23354209b5619e3b439e5ac9e4cfca918753", "size": 6682, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "IDP/Task5/src/IDP_Task5_Karwowski_Kowalewski.tex", "max_stars_repo_name": "KKowalewski24/Reports", "max_stars_repo_head_hexsha": "4702f29a2626f19ffb11801acf2ccd5764793482", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "IDP/Task5/src/IDP_Task5_Karwowski_Kowalewski.tex", "max_issues_repo_name": "KKowalewski24/Reports", "max_issues_repo_head_hexsha": "4702f29a2626f19ffb11801acf2ccd5764793482", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "IDP/Task5/src/IDP_Task5_Karwowski_Kowalewski.tex", "max_forks_repo_name": "KKowalewski24/Reports", "max_forks_repo_head_hexsha": "4702f29a2626f19ffb11801acf2ccd5764793482", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.1323529412, "max_line_length": 167, "alphanum_fraction": 0.7171505537, "num_tokens": 1566, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.4350586981677942}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\title{Specialization Store Working}\n\\author{Mark Cox}\n\n\\newcommand{\\true}{\\textrm{true}}\n\\newcommand{\\false}{\\textrm{false}}\n\n\\begin{document}\n\\maketitle\n\nTODO\n\\begin{enumerate}\n\\item Improve the terminology. Precedence, applicability, most\n  applicable.\n\\item Add proofs.\n\\end{enumerate}\n\n\\section{Introduction}\n\nThe specialization store system defines a new style of generic\nfunction which can i) dispatch according to optional, keyword or rest\narguments and ii) the operation is determined using argument types\nrather than classes.\n\nThis document outlines an ordering of specializations for a given set\nof input types and that there exists a set of projections which\npartition a set of specializations in to disjoint regions.\n\nThe operators used in this document are defined as follows\n\\begin{itemize}\n\\item $ x \\preceq y $ denotes that the set $x$ is a subset of the set $y$.\n\\item $ x \\prec y$ denotes that the set $x$ is a strict subset of the set $y$.\n\\item $\\lnot x $ is logical negation operator.\n\\item $x \\lor y$ is an operator performing the \\emph{or} operation.\n\\item $x \\land y$ is an operator performing the \\emph{and} operation.\n\\item $\\Pi_{i=1}^n x_i $ is equivalent to $ x_i \\land \\dots \\land x_n $.\n\\end{itemize}\nThe standard numerical operators $=$, $<$, $>$, $\\leq$ and $\\geq$ are\nalso used.\n\nA symbol $x$ may refer to a tuple containing an arbitrary number of\nvalues, written $x = (x_1, \\dots, x_n)$, or may represent a type. The\ncontext of the symbol should make it clear what it represents. Note\nthat \\emph{none} of the above operators are defined for tuples.\n\nThe operators defined for tuples are\n\\begin{itemize}\n\\item $|x|$ is the number of elements in the typle. e.g. $|x| = n$\n  when $ x = ( x_i, \\dots, x_n ) $ .\n\\end{itemize}\n\n\\section{Specializations}\nThere are two different types of specializations defined in\nspecialization store.\n\\begin{description}\n\\item[Fixed arity] These are specializations which can be added to\n  store functions which accept a fixed number of required arguments\n  and possibly optional arguments and/or keyword\n  arguments. Specializations belonging to these functions are\n  represented by $ t \\equiv (t_1, \\dots, t_n) $.\n\\item[Variable arity] These specialization belong to store functions\n  which define a \\texttt{\\&rest} argument without using\n  \\texttt{\\&key}. These specializations are represented by\n  $ x \\equiv (t_{1}, \\dots, t_{n_x}, \\sigma_x, \\mu_x) $ where $n_x$\n  represents the number of required arguments for the specialization,\n  $\\sigma_x$ is a non negative integer indicating how many other\n  arguments the specialization accepts and $\\mu_x$ is the type of each\n  of the other $\\sigma_x$ arguments. In the context of argument types\n  $t$, the value $\\sigma_t = |t| - n_x$ is the number of non required\n  arguments in the tuple $t$ and $\\mu_t$ is the most specific type for\n  which each non required argument.\n\\end{description}\n\n\\section{Ordering}\n\\label{sec:ordering}\n\\subsection{Fixed arity}\nIn this section we show how a specialization is selected for an\ninvocation with the argument types $t \\equiv (t_1, \\dots, t_n)$.\n\nA specialization is selected by sorting the specializations using a\npredicate $h(x,y;t)$ where $x$ and $y$ denote a specialization tuple\nand $t$ is the tuple containing the argument types. The function $h$\nis true if $x$ is applicable to the argument types $t$ and is a more\nsuitable specialization than $y$. Its definition is as follows\n\\begin{align}\n  h(x,y;t) &\\equiv g(x;t) \\land (\\lnot g(y;t) \\lor f(x,y) )\n\\end{align}\nwhere $g$ is the applicability function\n\\begin{align}\n  g(x;t) &\\equiv \\Pi_{i=1}^n (t_i \\preceq x_i)\n\\end{align}\nand $f$ is the precedence function\n\\begin{align}\n  f(x,y) &\\equiv \\Pi_{i=1}^n (x_i \\preceq y_i)\n\\end{align}\n\n\\subsection{Variable arity}\nThe functions $g$, $f$ and $h$ for specializations with variable arity\nare\n\\begin{align}\n  g(x;t) &\\equiv (n_x \\leq |t| \\leq n_x + \\sigma_x)\n                 \\land \\Pi_{i=1}^{n_x} (t_i \\preceq x_i)\n                 \\land ( \\mu_t \\preceq \\mu_x ) \\\\\n  f(x,y) &\\equiv (n_x \\geq n_y)\n                 \\land \\Pi_{i=1}^{n_y}(x_i \\preceq y_i)\n                 \\land ( \\mu_x \\preceq \\mu_y )\\\\\n  h(x,y;t) &\\equiv g(x;t) \\land (\\lnot g(y;t) \\lor f(x,y) )\n\\end{align}\n\n\\section{Dispatch Tree}\nAn applicability function $g$ and a discrimination function $f$\nprovide a method of selecting a specialization from a set $Z$ which\nhas the highest precedence for a set of arguments. This method of\nselection is not very efficient as it requires sorting the set of\nspecializations.\n\nIn this section we seek to find a function $d : t \\rightarrow x$ which\ncomputes a specialization $x \\in Z$ which has the highest precedence\nfor input arguments of type $t$.\n\nThe key property of the function $d$ is that its computational\ncomplexity is no greater than the $\\max_i |x_i|$ where $x_i \\in Z$.\n\n\\subsection{Criteria}\nThe following cases need to proven in order to show that the function\n$d$ is equivalent to the sorting method.\n\\begin{align}\n  \\begin{cases}\n    g(d(t); t) \\equiv \\true & h(d(t),y;t) \\equiv \\true \\;\\; \\forall y \\in Z \\\\\n    g(d(t); t) \\equiv \\false & g(y;t) \\equiv \\false \\;\\; \\forall y \\in Z\n  \\end{cases}\n\\end{align}\n\n\\noindent The sorting function $h(x,y;t)$ is defined as\n\\begin{align}\n  h(x,y;t) &\\equiv g(x;t) \\land (\\lnot g(y;t) \\lor f(x,y) )\n\\end{align}\nwhich has the following truth table\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|c|c|c||c|}\n\\hline\n$g(x;t)$ & $g(y;t)$ & $f(x,y)$ & $h(x,y;t)$ \\\\\n\\hline\nF & F & F & F \\\\\nF & F & T & F \\\\\nF & T & F & F \\\\\nF & T & T & F \\\\\nT & F & F & T \\\\\nT & F & T & T \\\\\nT & T & F & F \\\\\nT & T & T & T \\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\nThe precedence function for the fixed arity and variable arity case\nboth share the term\n\\begin{align}\n  \\Pi_{i=1}^{\\min(n_x,n_y)} x_i \\preceq y_i\n\\end{align}\nwhich, according to the function $h$, requires an input argument type\n$t_i$ to satisfy\n\\begin{align}\n  (t_i \\preceq x_i) \\land [\\lnot (t_i \\preceq y_i) \\lor (x_i \\preceq y_i)].\n\\end{align}\n\n\\subsection{Fixed Arity}\nAssume that we have a set of specializations $Z$ for an arity $n$\nstore function which are partially applicable.\n\\begin{align}\n  x_1 & \\equiv (x_{11}, \\dots, x_{1n}) \\nonumber \\\\\n  x_2 & \\equiv (x_{21}, \\dots, x_{2n}) \\nonumber \\\\\n  \\vdots & \\vdots                     \\nonumber \\\\\n  x_k & \\equiv (x_{k1}, \\dots, x_{kn}) \\nonumber\n\\end{align}\nIt is assumed that no two specializations are the same.\n\nPartial applicability is defined by the set $P$ which represents\nknowledge about any of the input argument types $t_j$. Specifically\n\\begin{align}\n  (p_j \\in P) \\rightarrow (t_j \\preceq p_j)\n.\n\\end{align}\n\nA specialization $x_i$ is said to be partially applicable if\n\\begin{align}\n  \\exists_j \\left[(p_j \\preceq x_{ij}) \\land (p_j \\in P) \\right]\n.\n\\end{align}\n\nA specialization $x_i$ is said to be applicable if\n\\begin{align}\n  \\forall_j \\left[(p_j \\preceq x_{ij}) \\land (p_j \\in P) \\right]\n\\end{align}\n\nThe function $d$ created for the fixed arity case is a decision tree\nwhich involves selecting a type $p_j$ to use as a test for a specific\ninput argument type $t_j$.\n\nThe type $p_j$ is selected from the $x_{ij}$ such that\n\\begin{enumerate}\n\\item $\\exists_i (p_j \\equiv x_{ij})$\n\\item $\\{ x_{ij} | x_{ij} \\prec p_j \\} \\equiv \\emptyset$\n\\item $p_j \\notin P$\n\\end{enumerate}\n\nThe type $p_j$ is then used to partition the specializations $Z$ in to\na set $X$ and $Y$ such that\n\\begin{align}\n  X & \\equiv \\{ x_i | p_j \\preceq x_{ij} \\} & Y & \\equiv (Z - X) \\cup \\{ x_i | p_j \\prec x_{ij} \\}\n\\end{align}\n\nThis process continues by splitting the set $X$ with\n$P = P \\cup \\{ p_j \\}$ and splitting the set $Y$ with $P =\nP$. Splitting stops when no $p_j$ can be obtained.\n\nThere may be more than one specialization in $X$ when $P$ is full\ne.g. the tuples $x_1 = (\\alpha)$ and $x_2 = (\\alpha \\lor \\beta)$. This\ncan be resolved by sorting the specializations using $h()$.\n\n\\subsection{Variable Arity}\nThe tree building process for the variable arity case proceeds by\npartitioning the specializations using the first $\\min_i n_{x_i}$\narguments as if it were a fixed arity problem.\n\nA leaf in the resulting tree will contain a set of specializations\n$Z$. These specializations can be split in to two categories, those\nwhich can be invoked with $c$ arguments and those that can be invoked\nwith more than $c$\n\\begin{align}\n  X & = \\{ x_i | n_{x_i} \\leq c \\leq n_{x_i} + \\sigma_{x_i} \\} & Y &= \\{ x_i | c < n_{x_i} + \\sigma_{x_i} \\}\n\\end{align}\nwhere $c$ is defined as\n\\begin{align}\n  c = \\min_i n_{x_i} \\textrm{ s.t. } x_i \\in Z\n\\end{align}\n\nThe set $X$ represents a fixed arity problem and thus can be\npartitioned using the strategy outlined in the previous section. The\nabove process is recursively applied to set $Y$.\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: LaTeX\n%%% mode: TeX-PDF\n%%% End:\n", "meta": {"hexsha": "54e46d23cda9bbf6ece13a1f30135d4fd8490677", "size": 8879, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/dispatch-working.tex", "max_stars_repo_name": "markcox80/specialization-store", "max_stars_repo_head_hexsha": "8d39a866a6f24986aad3cc52349e9cb2653496f3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 31, "max_stars_repo_stars_event_min_datetime": "2015-12-19T17:38:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T17:32:28.000Z", "max_issues_repo_path": "doc/dispatch-working.tex", "max_issues_repo_name": "markcox80/specialization-store", "max_issues_repo_head_hexsha": "8d39a866a6f24986aad3cc52349e9cb2653496f3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2017-08-11T22:22:49.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-10T11:36:17.000Z", "max_forks_repo_path": "doc/dispatch-working.tex", "max_forks_repo_name": "markcox80/specialization-store", "max_forks_repo_head_hexsha": "8d39a866a6f24986aad3cc52349e9cb2653496f3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2341269841, "max_line_length": 108, "alphanum_fraction": 0.69715058, "num_tokens": 2735, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.43496402930839256}}
{"text": "\\documentclass[jou]{apa6}\n\n\\usepackage[american]{babel}\n\n\\usepackage{csquotes}\n\\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}\n\\DeclareLanguageMapping{american}{american-apa}\n\\addbibresource{bibliography.bib}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Discrete Structures\n%% The start of RBS stuff\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Working internal and external links in PDF\n\\usepackage{hyperref}\n% Extra math symbols in LaTeX\n\\usepackage{amsmath}\n\\usepackage{gensymb}\n\\usepackage{amssymb}\n% Enumerations with (a), (b), etc.\n\\usepackage{enumerate}\n\\usepackage{xcolor}\n\n\\let\\OLDitemize\\itemize\n\\renewcommand\\itemize{\\OLDitemize\\addtolength{\\itemsep}{-6pt}}\n\n\\usepackage{etoolbox}\n\\makeatletter\n\\preto{\\@verbatim}{\\topsep=3pt \\partopsep=3pt }\n\\makeatother\n\n% These sizes redefine APA for A4 paper size\n\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.27in\n\\headheight 1.0in\n\\topmargin -24pt\n\\headheight 12pt\n\\headsep 12pt\n\\textheight 9.19in\n\n\n\n\\title{Sample Quiz 8}\n\\author{Discrete Structures, Spring 2020}\n\\affiliation{RBS}\n\n\\leftheader{Discrete Sample Quiz 8}\n\n\\abstract{%\n}\n\n%\\keywords{}\n\n\\setlength\\parindent{0pt}\n\n\\begin{document}\n\n%\\thispagestyle{empty}\n\n\\twocolumn\n\\section{Quiz 11: Graphs}\n\n\\vspace{4pt}\n{\\bf Question 1.}\nLet $G = (V,E)$ be a graph, where $V$ is the set of all positive divisors of $144$ (including \n$1$ and $144$ itself). Two different vertices $d_1,d_2$ are connected by an edge iff one of the\nnumbers divides another ($d_1\\,\\mid\\,d_2$ or $d_2\\,\\mid\\,d_1$). \nFind the number of vertices $|V|$ and the number of edges $|E|$ in this graph.\n\nWrite two comma-separated integers.\n\n\n\\vspace{10pt}\n{\\bf Question 2.}\nHow long is the longest simple circuit in $W_{20}$? \n(A simple circuit is a circular path that may visit vertices multiple times, \nbut does not contain any edge more than once.)\n\nWrite a positive integer. \n\n\n\n\n\\vspace{10pt}\n{\\bf Question 3.}\nLet $G$ be a planar connected graph with $60$ vertices, each vertex has degree $3$. \nHow many regions are there in $G$?\n\nWrite a positive integer.\n\n\n\n\\vspace{10pt}\n{\\bf Question 4.} This is an adjacency matrix for some graph:\n{\\footnotesize\n$$M_G = \\left( \n\\begin{array}{ccccccccc}\n0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 \\\\\n1 & 0 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 \\\\\n1 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 \\\\\n0 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 0 \\\\\n0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 \\\\\n0 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 0 & 1 & 1 & 1 & 0 & 1 \\\\\n1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 \\\\\n\\end{array} \\right).$$\n}\n\nIt is known that $G$ is a planar graph. Find the number of vertices $|V|$, \nnumber of edges $|E|$ and the number of regions $|R|$ for this graph. \n\nWrite $3$ comma-separated integers.\n\n\n\n\\vspace{10pt}\n{\\bf Question 5 (Dudeney2016, Prob.434), ``536 Puzzles''.}\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-11/prison-cells.png}}\n\\caption{\\label{fig:prison-cells} A weighted graph.}\n\\end{figure}\n\nA prisoner currently is in the cell ``$A$'' (Figure~\\ref{fig:prison-cells}). He has to visit each \nprison cell no more than once and return \nback to the cell ``$A$''. What is the largest number of prison cells that\ncan be visited in this way?\\\\\n{\\em (Visiting each cell once does not contradict with the requirement to return back \nto ``$A$'' \\textendash{} the prisoner uses a circular path between the rooms: \nevery room on the path, including ``$A$'', is entered once and left once. We want\nto know the maximum length of this path.)}\n\nWrite a positive integer.\n\n{\\em Note.} You may also want to prove to yourself that the number is the largest possible.\n\n\n\\vspace{10pt}\n{\\bf Question 6}\nThere is a bipartite graph $G=(V,E)$ with exactly $|V| = 17$ vertices. (A graph is {\\em bipartite}, if \nthe set of vertices $V$ can be split into two parts $X$, $Y$ so that all edges are between a vertex in $X$ and a vertex in $Y$.)\nFind the largest possible number of edges in such a graph. \n\nWrite a positive integer.\n \n\n\\vspace{10pt}\n{\\bf Question 7} Verify, if these statements are true. \nA simple undirected graph is called a {\\em cubic} graph, \nif every vertex has degree $3$.\\\\\n{\\bf (A)} There exists a cubic graph with $7$ vertices.\\\\\n{\\bf (B)} There exists a cubic graph with $6$ vertices that is not isomorphic to $K_{3,3}$.\\\\\n{\\bf (C)} There exists a cubic graph with $8$ edges.\n\nWrite a sequence of 3 comma-separated letters (e.g.\\ {\\tt T,T,T} or {\\tt F,F,F}).\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 8.} Verify, if these statements are true:\\\\\n{\\bf (A)} There exists a simple directed graph with indegrees $0,1,2,4,5$ and outdegrees $0,3,3,3,3$. (A graph is {\\em simple}, if\nit is not a {\\em multigraph} \\textendash{} there is no more than one edge $(u,v)$ for any vertices $u,v$.)\\\\\n{\\bf (B)} There exists a connected undirected simple planar graph with $5$ regions and $8$ vertices, each vertex has degree $3$.\\\\\n{\\bf (C)} There exists a connected undirected simple planar graph with $8$ regions and $6$ vertices, each region is surrounded \nwith $3$ edges.\n\nWrite a sequence of 3 comma-separated letters (e.g.\\ {\\tt T,T,T} or {\\tt F,F,F}).\n\n\n\n\\vspace{10pt}\n{\\bf Question 9.}\nUse Dijkstra’s Algorithm to find the shortest paths from the source vertex $s$ \nto all other vertices $t,x,y,z$ (Figure~\\ref{fig:dijkstra}). The length of a path is obtained by adding the \nweights of the directed edges.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.8in]{quiz-11/dijkstra.png}}\n\\caption{\\label{fig:dijkstra} A weighted graph.}\n\\end{figure}\n\n\nWrite $4$ comma-separated numbers \\textendash{} the shortest paths \nto the vertices $t,x,y,z$ respectively.\n\n{\\em Note.} Dijkstra's algorithm (Rosen2019, p.747) initializes the set of vertices $S$ that we \nknow the shortest paths to (initially it only contains the \nsource vertex $S = \\{ s \\}$; \nthe distance from $s$ to itself is $0$; initialize the distances to \nall the other vertices to $\\infty$). At every step consider all the edges that \ngo from the set $S$ to $\\overline{S}$, i.e. to the vertices where we still \ndo not know the shortest paths. Update all the shortest paths (if crossing from \nthe set $S$ to $\\overline{S}$ finds a shorter path than $\\infty$ or the currently \nknown minimum length, then decrease the estimate for this vertex). \nFinally, add the minimum vertex from $\\overline{S}$ to $S$. Repeat the steps\nuntil all vertices are added to $S$ and all the shortest path estimates have \nreached their smallest values.\n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 10 (Dudeney2016, Prob.423), ``536 Puzzles''.}\nA man starting from the town $A$, has to inspect all the roads\nshown from town to town (Figure~\\ref{fig:path-with-repetitions}). \nTheir respective lengths, $13$, $12$, and $5$\nmiles are all shown. What is the shortest possible route he can adopt, \nending his journey wherever he likes?\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=2in]{quiz-11/path-with-repetitions.png}}\n\\caption{\\label{fig:path-with-repetitions} Path with repetitions}\n\\end{figure}\n\nWrite an integer \\textendash{} the length of the shortest route.\n\n{\\em Note.} This graph obviously has no Euler path (since there\nare more than $2$ vertices with odd degrees). The problem is to \nfind a path that is likely {\\bf not} simple \n(uses the same edge several times), \nbut that includes every edge shown and the total of weights is minimal. \n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 11}\\\\\nSomebody placed $24$ chess rooks on a $8 \\times 8$ chessboard as shown in Figure~\\ref{fig:rooks}\n(each horizontal and each vertical has exactly $3$ rooks). \n\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-11/rooks.png}}\n\\caption{\\label{fig:rooks} Path with repetitions}\n\\end{figure}\n\nWe imagine that this chess-board defines a bipartite graph between the  \nset of all verticals $X= \\{ A,B,C,D,E,F,G,H \\}$ and the set of all \nhorizontals $Y= \\{ 1,2,3,4,5,6,7,8 \\}$. Any rook defines an edge between these two sets. \nFor example, the rook $C8$ defines an edge $(C,8)$. \n\nFind a subset of verticals $V \\subseteq X$ such that $|V|=3$, but\nthe neighbor set has size $|N(V)| = 5$.\n\nWrite $3$ comma-separated letters in your answer (the vertices from $V$). It is \nsufficient to write just one possible answer, if there are many.\n\n\\vspace{10pt}\n{\\em Note 1.} For example, the answer $\\textcolor{blue}{\\mathtt{F,G,H}}$ does not work, \nsince the set of vertices $\\{ \\mathtt{F},\\mathtt{G},\\mathtt{H} \\} \\subseteq X$ \nis neighboring with a set of six vertices\n$\\{ 1,3,5,6,7,8 \\} \\subseteq Y$, i.e. the rooks on these three verticals\nattack six horizontals, but not five.\n\n{\\em Note 2.} For the condition of the Hall's marriage theorem we need the inequality $|V| \\leq |N(V)|$ \nfor {\\bf every} $V \\subseteq X$. You could prove to yourself that it is always satisfied\n(also for all the other placements of $24$ rooks where each horizontal and each \nvertical has $3$ rooks).\\\\\n{\\em Note 3.} Interpret for yourself what does a ``perfect matching'' between the sets\n$X$ and $Y$ mean in this subject-area with a chessboard and rooks.\n\n\n\n\n\\newpage\n\n\\subsection{Answers}\n\n\n\\vspace{4pt}\n{\\bf Question 1} Answer: $15,75$\\\\\nSince $144 = 2^4 \\cdot 3^2$, number $144$ has $(4+1)(2+1) = 15$ divisors\n(the number of ways to pick powers $2^a \\cdot 3^b$). \nTheir Hasse diagram is shown in Figure~\\ref{fig:divisibility-144-graph}\n(transitive closure has many more arrows that are not shown). \n\nFor each vertex $d_1$ we calculate the number of other vertices that\nare divisible by $d_1$ (i.e. can be reached by following one or more arrows in the\nHasse diagram). Adding all those numbers gives the number of edges.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=3in]{quiz-11/divisibility-144-graph.png}}\n\\caption{\\label{fig:divisibility-144-graph} Divisibility Hasse diagram.}\n\\end{figure}\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 2} Answer: $30$\\\\\nAll the vertices on the regular $20$-gon have degree equal to $3$. \nThis means that we have to drop at least $10$ edges before we \nget a simple path (because any simple path adds only even number to the degree\nof any vertex in a graph). Initially $W_{20}$ has $20 + 20 = 40$ edges. \nAfter deleting $10$ edges (every other edge on the perimeter of the $20$-gon), \nwe are left with $30$ edges.\n\n\n\\vspace{10pt}\n{\\bf Question 3} Answer: $32$\\\\\n$60$ vertices (having degree $3$ each would create the sum of all degrees equal to $60 \\cdot 3 = 180$. \nThe number of edges equals one half of that; so $|E| = 90$. The number of regions\ncan be computed using Euler's formula: $|V| - |E| + |R| = 2$ (in our case \n$60 - 90 + |R| = 2$; therefore $|R| = 32$. \n\nOne example of such graph is {\\em truncated icosahedron}, see \\url{https://bit.ly/2WaSW6I}, \nbut there may be many others that are not isomorphic to it. Still, all of them \nwould have the same number of regions due to Euler's formula.\n\n\\vspace{10pt}\n{\\bf Question 4} Answer: {\\tt 9,17,10}\\\\\nNumber of vertices equals the size of the matrix $9 \\times 9$, \nso $|V| = 9$. The number of edges is one half of all the $1$s written \nin the adjacency matrix; therefore $|E| = 17$. Since we can assume\nthat the graph $G$ is planar, it satisfies Euler's formula:\n$$|V| - |E| + |R| = 2.$$\nTherefore the number of regions $|R| = 10$. \n\nGraph (shown without edge intersections as a planar graph) is visible \non Figure~\\ref{fig:question4-graph}. In this picture we can simply count \nvertices, edges and regions. But it is usually time-consuming to \ncreate such pictures (and to verify that they match the adjacency matrix).\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-11/question4-graph.png}}\n\\caption{\\label{fig:question4-graph} A planar graph}\n\\end{figure}\n\n\n\\vspace{10pt}\n{\\bf Question 5} Answer: $34$\\\\\nIt is easy to build a path that visits all rooms except one. \nThere cannot be a circular path with exactly $35$ steps \\textendash{}\none can use checkerboard pattern (color all cells in black and white). \nEvery step switches the color to the opposite; after exactly $35$ color switches\nthe color would be opposite \\textendash{} the path cannot return back to cell $A$.\n\n\n\\vspace{10pt}\n{\\bf Question 6} Answer: $72$\\\\\nWe know that the sum of two sizes $|X| + |Y| = 17$, \nand the maximum number of edges is $|X| \\cdot |Y|$. \nThe greatest possible product of two numbers is\nwhen they are closest to each other: \n$8 \\cdot 9 = 72$. (We can try out all combinations of two numbers\nthat add up to $17$ to see that this is the largest one.)\n\nWe can write the following algebraic inequalities: \n$$|X| \\cdot |Y| \\leq \\left( \\frac{|X| + |Y|}{2} \\right)^2,$$\n$$4 |X| \\cdot |Y| \\leq \\left( |X| + |Y| \\right)^2,$$\n$$4 |X| \\cdot |Y| \\leq |X|^2 + |Y|^2 + 2 |X| \\cdot |Y|,$$\n$$0 \\leq |X|^2 + |Y|^2 = 2 |X| \\cdot |Y| = (|X| + |Y|)^2.$$\n\nFrom the first inequality we imply that $|X| \\cdot |Y| \\leq (17/2)^2 = 72.25$. \nSince the number of edges cannot be fractional, $72$ is indeed the largest number.\n\n\n\n\\vspace{10pt}\n{\\bf Question 7} Answer: {\\tt FTT}\\\\\n{\\bf (A)} False. No cubic graph can have odd number of vertices \n(the sum of all degrees of all vertices should be even \\textendash{} twice the number of edges).\\\\\n{\\bf (B)} True. $K_{3,3}$ is bipartite graph (it does not contain any ``triangles'': three vertices\nthat are all mutually connected). But the graph on Figure~\\ref{fig:cubic-graph-6}\nis not bipartite (so it is not isomorphic\nto $K_{3,3}$.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1in]{quiz-11/cubic-graph-6.png}}\n\\caption{\\label{fig:cubic-graph-6} Cubic graph with 6 vertices.}\n\\end{figure}\n\n{\\bf (C)} True. You can draw a regular octagon and add all the long diagonals. \nNow every vertex is adjacent with three vertices (both neighbors and the opposite one). \n\n\n\\vspace{10pt}\n{\\bf Question 8} Answer: {\\tt FFT}\\\\\n{\\bf (A)} False. In a simple directed graph with $5$ vertices, an indegree \n$5$ means that all vertices should point arrows to the given vertex (including the vertex itself). \nBut in this case there cannot be any vertices with outdegree $0$.\\\\\n{\\bf (B)} False. A graph with $8$ vertices of degree $3$ means that it has $\\frac{8 \\cdot 3}{2} = 12$ edges. \nAccording to Euler's formula, the number of regions should be $R = 2 + E - V = 6$. Therefore \nsuch a graph should have $6$ (not $5$) regions.\\\\\n{\\bf (C)} True. Such graph exists. For example Octahedron - see \\url{https://bit.ly/3f1gnrG}.\n\n\n\n\\vspace{10pt}\n{\\bf Question 9} Answer: {\\tt 8,9,5,7}\n\n{\\footnotesize\n\\begin{tabular}{|l|l|l|} \\hline\nSet $S$ & Weights of $\\overline{S}$ & Added to $S$ \\\\ \\hline\n$\\{ s \\}$ & $w(t,x,y,z) = (10,\\infty,5,\\infty)$ & $y$ (min path $5$) \\\\  \\hline\n$\\{ s,y \\}$ & $w(t,x,z) = (8,\\infty,7)$ & $z$ (min path $7$) \\\\ \\hline\n$\\{ s,y,z \\}$ & $w(t,x) = (8,9)$ & $t$ (min path $8$) \\\\ \\hline\n$\\{ s,t,y,z \\}$ & $w(x) = 9$ & $x$ (min path $9$) \\\\ \\hline\n\\end{tabular}\n}\n\n\n\\vspace{10pt}\n{\\bf Question 10} Answer: {\\tt 211}\\\\\nThere are altogether $6$ vertices with odd degrees (one of them is $A$). If we start our travel in $A$\nand end it in any other vertex with odd degree (say, in $G$), then there are \nfour more vertices with odd degrees. By adding edges $(C,H)$ and $(I,E)$ two times, we can \nbuild the required path (each of these edges has weight $5$). Therefore the full length of the \npath is the sum of all weights: \n$$3 \\cdot (12 + 12 + 12) + 3 \\cdot (13 + 13 + 5) + (5 + 5).$$\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-11/path-with-repetitions2.png}}\n\\caption{\\label{fig:path-with-repetitions2} Path with Repetitions (Solved).}\n\\end{figure}\n\n\n\\vspace{10pt}\n{\\bf Question 11} Answer: {\\tt \"A,B,D\"}, {\\tt \"A,B,F\"}, \n{\\tt \"C,E,H\"}, {\\tt \"C,G,H\"}, {\\tt \"D,E,G\"}\\\\\nThere are five ways to select the verticals (any one of them is correct). \nSince the rooks (as edges linking horizontals with verticals) satisfy the Hall's Marriage theorem, \nthere exists a perfect matching: One can select $8$ rooks (out of the $24$) so that\neach rook has its own horizontal and its own vertical. In other words, they do not attack each other. \n\nWe can start searching this perfect matching using ``backtracking'' \\textendash{} first \ntry to pick the minimum possible horizontal in each vertical (avoiding any attacking position). \nIf this leads in a dead end, then start moving the rooks that have been placed last. \nThis very quickly leads to a solution (Figure~\\ref{fig:rooks2}). There are also many other \nperfect matchings.\n\n\\begin{figure}[!htb]\n\\center{\\includegraphics[width=1.5in]{quiz-11/rooks2.png}}\n\\caption{\\label{fig:rooks2} 8 selected rooks shown red}\n\\end{figure}\n\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "22db562eb7886b062b208abbdd8464be7f4e75cd", "size": 16488, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/site/discrete-spring2020/questionbase/quiz-11.tex", "max_stars_repo_name": "kapsitis/math", "max_stars_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/site/discrete-spring2020/questionbase/quiz-11.tex", "max_issues_repo_name": "kapsitis/math", "max_issues_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-20T03:40:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T21:50:18.000Z", "max_forks_repo_path": "src/site/discrete-spring2020/questionbase/quiz-11.tex", "max_forks_repo_name": "kapsitis/math", "max_forks_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7216035635, "max_line_length": 130, "alphanum_fraction": 0.6928068899, "num_tokens": 5196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166195971441, "lm_q2_score": 0.84997116805678, "lm_q1q2_score": 0.4349443728730515}}
{"text": "\n\\chapter{Inference for categorical data}\n\\label{inferenceForCategoricalData}\n\nChapter~\\ref{inferenceForCategoricalData} provides a more complete framework for statistical techniques suitable for categorical data. We'll continue working with the normal model in the context of inference for proportions, and we'll also encounter a new technique and distribution suitable for working with frequency and contingency tables in Sections~\\ref{oneWayChiSquare} and~\\ref{twoWayTablesAndChiSquare}.\n\n\n%__________________\n\\section{Inference for a single proportion}\n\\label{singleProportion}\n\n%\\Comment{The next two paragraphs and the term box are new.}\n\nBefore we get started, we'll introduce a little terminology and notation.\n\nIn the tappers-listeners study, one person tapped a tune on the table and the listener tried to guess the game. In this study, each game can be thought of as a \\textbf{trial}. We could label each trial a \\textbf{success} if the listener successfully guessed the tune, and we could label a trial a \\textbf{failure} if the listener was unsuccessful.\n\n\\begin{termBox}{\\tBoxTitle{Trial, success, and failure}\nA single event that leads to an outcome can be called a \\emph{trial}. If the trial has two possible outcomes, e.g. heads or tails when flipping a coin, we typically label one of those outcome a \\emph{success} and the other a \\emph{failure}. The choice of which outcome is labeled a success and which a failure is arbitrary, and it will not impact the results of our analyses.}\n\\end{termBox}\n\nWhen a proportion is recorded, it is common to use a 1 to represent a ``success'' and a 0 to represent a ``failure'' and then write down a \\textbf{key} to communicate what each value represents. This notation is also convenient for calculations. For example, if we have 10 trials with 6 success (1's) and 4 failures (0's), the sample proportion can be computed using the mean of the zeros and ones:\n\\begin{eqnarray*}\n\\hat{p} = \\frac{\\ 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0\\ }{10} = 0.6\n\\end{eqnarray*}\nNext we'll take a look at when we can apply our normal distribution framework to the distribution of the sample proportion, $\\hat{p}$.\n%\\begin{eqnarray*}\n%\\hat{p} = \\frac{\\ 0 + 1 + 1 + \\cdots + 0\\ }{976} = 0.44\n%\\end{eqnarray*}\n%The distribution of $\\hat{p}$ is nearly normal when the distribution of 0's and 1's is not too strongly skewed for the sample size. The most common guideline for sample size and skew when working with proportions is to ensure that we expect to observe a minimum number of successes and failures, typically at least 10 of each.}\n\n\\subsection{When the sample proportion is nearly normal}\n\n\\begin{termBox}{\\tBoxTitle{Conditions for when the sampling distribution of $\\hat{p}$ is nearly normal}\nThe sampling distribution for $\\hat{p}$, taken from a sample of size $n$ from a population with a true proportion $p$, is nearly normal when\n\\begin{enumerate}\n\\item the sample observations are independent and\n\\item we expected to see at least 10 successes and 10 failures in our sample, i.e. $np\\geq10$ and $n(1-p)\\geq10$. This is called the \\textbf{success-failure condition}.\n\\end{enumerate}\nIf these conditions are met, then the sampling distribution of $\\hat{p}$ is nearly normal with mean $p$ and standard error\n\\index{standard error!single proportion}\n\\begin{eqnarray}\nSE_{\\hat{p}} = \\sqrt{\\frac{\\ p(1-p)\\ }{n}}\n\\label{seOfPHat}\n\\end{eqnarray}}\n\\end{termBox}\\marginpar[\\raggedright\\vspace{-53mm}\n\n$\\hat{p}$\\vspace{0mm}\\\\\\footnotesize sample\\\\proportion\\vspace{3mm}\\\\\\normalsize$p$\\vspace{0mm}\\\\\\footnotesize population\\\\proportion]{\\raggedright\\vspace{-53mm}\n\n$\\hat{p}$\\vspace{0mm}\\\\\\footnotesize sample\\\\proportion\\vspace{3mm}\\\\\\normalsize$p$\\vspace{0mm}\\\\\\footnotesize population\\\\proportion}\n\nTypically we do not know the true proportion, $p$, so we substitute some value to check conditions and to estimate the standard error. For confidence intervals, usually $\\hat{p}$ is used to check the success-failure condition and compute the standard error. For hypothesis tests, typically the null value $p_0$ is used in place of $p$. Examples are presented for each of these cases in Sections~\\ref{confIntForPropSection} and~\\ref{htForPropSection}.\n\n\\begin{tipBox}{\\tipBoxTitle{Reminder on checking independence of observations}\nIf data come from a simple random sample and consist of less than 10\\% of the population, then the independence assumption is reasonable. Or, for example, if the data come from an experiment where each user was randomly assigned to the treatment or control group and users do not interact, then the observations in each group are typically independent.}\n\\end{tipBox}\n\n\n\\subsection{Confidence intervals for a proportion}\n\\label{confIntForPropSection}\n\n\\index{point estimate!single proportion}\n\n\\index{data!supreme court|(}\n\nAccording to a New York Times / CBS News poll in June 2012, only about 44\\% of the American public approves of the job the Supreme Court is doing.\\footnote{\\href{http://www.nytimes.com/2012/06/08/us/politics/44-percent-of-americans-approve-of-supreme-court-in-new-poll.html}{\\scriptsize nytimes.com/2012/06/08/us/politics/44-percent-of-americans-approve-of-supreme-court-in-new-poll.html}} This poll included responses of 976 randomly sampled adults.\n\nWe want a confidence interval for the proportion of Americans who approve of the job the Supreme Court is doing. Our point estimate, based on a simple random sample of size $n = 976$ from the NYTimes/CBS poll, is $\\hat{p} = 0.44$. To use our confidence interval formula from Section~\\ref{ConfidenceIntervals}, we must first check whether the sampling distribution of $\\hat{p}$ is nearly normal and calculate the standard error of the estimate.\n\nThe data are based on a simple random sample and consist of far fewer than 10\\% of the U.S. population, so independence is confirmed. The sample size must also be sufficiently large, which is checked via the success-failure condition: there were approximately $976\\times \\hat{p}=429$ ``successes'' and $976\\times (1-\\hat{p})=547$ ``failures'' in the sample, both easily greater than~10.\n\nWith the conditions met, we are assured that the sampling distribution of $\\hat{p}$ is nearly normal. Next, a standard error for $\\hat{p}$ is needed, and then we can employ the usual method to construct a confidence interval.\n\n\\begin{exercise} \\label{seOfPropOfAmericansJobApprovalOfSupremeCourt}\nEstimate the standard error of $\\hat{p}=0.44$ using Equation~\\eqref{seOfPHat}. Because $p$ is unknown and the standard error is for a confidence interval, use $\\hat{p}$ in place of $p$.~\\footnote{$SE = \\sqrt{\\frac{p(1-p)}{n}} \\approx \\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n}} = \\sqrt{\\frac{0.44(1-0.44)}{976}} = 0.016$}\n\\end{exercise}\n\n\\begin{example}{Construct a 95\\% confidence interval for $p$, the proportion of Americans who approve of the job the Supreme Court is doing.}\nUsing the standard error estimate from Guided Practice~\\ref{seOfPropOfAmericansJobApprovalOfSupremeCourt}, the point estimate 0.44, and $z^{\\star} = 1.96$ for a 95\\% confidence interval, the confidence interval can be computed as\n\\begin{eqnarray*}\n\\text{point estimate } \\ \\pm\\ z^{\\star}SE \\quad\\to\\quad 0.44 \\ \\pm\\ 1.96\\times 0.016 \\quad\\to\\quad (0.409, 0.471)\n\\end{eqnarray*}\nWe are 95\\% confident that the true proportion of Americans who approve of the job of the Supreme Court (in June 2012) is between 0.409 and 0.471. At the time this poll was taken, we can say with high confidence that the job approval of the Supreme Court was below 50\\%.\n\n\\index{data!supreme court|)}\n\n\\end{example}\n\n\\begin{termBox}{\\tBoxTitle[]{Constructing a confidence interval for a proportion}\\vspace{-1mm}\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item Verify the observations are independent and also verify the success-failure condition using $\\hat{p}$ and $n$.\n\\item If the conditions are met, then the Central Limit Theorem applies, and the sampling distribution of $\\hat{p}$ is well-approximated by the normal model.\n\\item Construct the standard error using $\\hat{p}$ in place of $p$ and apply the general confidence interval formula.\\vspace{1mm}\n\\end{itemize}}\n\\end{termBox}\n\n\n\\subsection{Hypothesis testing for a proportion}\n\\label{htForPropSection}\n\nTo apply the same normal distribution framework in the context of a hypothesis test for a proportion, the independence and success-failure conditions must also be satisfied. However, in a hypothesis test, the success-failure condition is checked using the null proportion: we verify $np_0$ and $n(1-p_0)$ are at least 10, where $p_0$ is the null value.\n\n\\begin{exercise}\nDeborah Toohey is running for Congress, and her campaign manager claims she has more than 50\\% support from the district's electorate. Ms. Toohey's opponent claimed that Ms. Toohey has \\emph{less} than 50\\%. Set up a hypothesis test to evaluate who is right.\\footnote{We should run a two-sided.$H_0$: Ms. Toohey's support is 50\\%. $p = 0.50$. $H_A$: Ms. Toohey's support is either above or below 50\\%. $p \\neq 0.50$.}\n\\end{exercise}\n\n\\textA{\\pagebreak}\n\n\\begin{example}{A newspaper collects a simple random sample of 500 likely voters in the district and estimates Toohey's support to be 52\\%. Does this provide convincing evidence for the claim of Toohey's manager at the 5\\% significance level?} \\label{TooheyInferenceExample}\n\nBecause this is a simple random sample that includes fewer than 10\\% of the population, the observations are independent. In a one-proportion hypothesis test, the success-failure condition is checked using the null proportion, $p_0=0.5$: $np_0 = n(1-p_0) = 500\\times 0.5 = 250 > 10$. With these conditions verified, the normal model may be applied to $\\hat{p}$.\n\nNext the standard error can be computed. The null value is used again here, because this is a hypothesis test for a single proportion.\n$$SE = \\sqrt{\\frac{p_0\\times (1-p_0)}{n}} = \\sqrt{\\frac{0.5\\times (1-0.5)}{500}} = 0.022$$\nA picture of the normal model is shown in Figure~\\ref{pValueForCampaignManagerClaimOfMoreThan50PercentSupport} with the p-value represented by both shaded tails. Based on the normal model, we can compute a test statistic as the Z score of the point estimate:\n$$Z = \\frac{\\text{point estimate} - \\text{null value}}{SE} = \\frac{0.52 - 0.50}{0.022} = 0.89$$\nThe right tail area is 0.1867, and the p-value is $2 \\times 0.1867 = 0.3734$. Because the p-value is larger than 0.05, we do not reject the null hypothesis, and we do not find convincing evidence to support the campaign manager's claim.\n\\end{example}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{03/figures/pValueForCampaignManagerClaimOfMoreThan50PercentSupport/pValueForCampaignManagerClaimOfMoreThan50PercentSupport}\n\\caption{Sampling distribution of the sample proportion if the null hypothesis is true for Example~\\ref{TooheyInferenceExample}. The p-value for the test is shaded.}\n\\label{pValueForCampaignManagerClaimOfMoreThan50PercentSupport}\n\\end{figure}\n\n\\begin{termBox}{\\tBoxTitle{Hypothesis test for a proportion}\nSet up hypotheses and verify the conditions using the null value, $p_0$, to ensure $\\hat{p}$ is nearly normal under $H_0$. If the conditions hold, construct the standard error, again using $p_0$, and show the p-value in a drawing. Lastly, compute the p-value and evaluate the hypotheses.}\n\\end{termBox}\n\n\n\\subsection{Choosing a sample size when estimating a proportion}\n\n\\index{margin of error|(}\n\nFrequently statisticians find themselves in a position to not only analyze data, but to help others determine how to most effectively collect data and also how much data should be collected. We can perform sample size calculations that are helpful in planning a study. Our task will be to identify an appropriate sample size that ensures the margin of error $ME = z^{\\star} SE$ will be no larger than some value $m$. For example, we might be asked to find a sample size so the margin of error is no larger than $m = 0.04$, in which case, we write\n\\begin{align*}\nz^{\\star} SE \\leq 0.04\n\\end{align*}\nGenerally, we plug in a suitable value for $z^{\\star}$ for the confidence level we plan to use, write in the formula for the standard error, and then solve for the sample size $n$. In the case of a single proportion, we use $\\sqrt{p(1-p) / n\\ }$ for the standard error ($SE$).\n\n\\begin{example}{If we are conducting a university survey to determine whether students support a \\$200 per year increase in fees to pay for a new football stadium, how big of a sample is needed to ensure the margin of error is less than 0.04 using a 95\\% confidence level?}\nFor a 95\\% confidence level, the value $z^{\\star}$ corresponds to 1.96, and we can write the margin of error expression as follows:\n\\begin{align*}\nME = z^{\\star}SE = 1.96\\times \\sqrt{\\frac{p(1-p)}{n}} \\leq 0.04\n\\end{align*}\nThere are two unknowns in the equation: $p$ and $n$. If we have an estimate of $p$, perhaps from a similar survey, we could use that value. If we have no such estimate, we must use some other value for $p$. The margin of error for a proportion is largest when $p$ is 0.5, so we typically use this \\emph{worst case estimate} if no other estimate is available:\n\\begin{align*}\n\t1.96\\times \\sqrt{\\frac{0.5(1-0.5)}{n}} &\\leq 0.04 \\\\\n\t1.96^2\\times \\frac{0.5(1-0.5)}{n} &\\leq 0.04^2 \\\\\n\t1.96^2\\times \\frac{0.5(1-0.5)}{0.04^2} &\\leq n \\\\\n\t600.25 &\\leq n\n\\end{align*}\nWe would need at least 600.25 participants, which means we need 601 participants or more, to ensure the sample proportion is within 0.04 of the true proportion with 95\\% confidence. Notice that in such calculations, we always round up for the sample size!\n\\end{example}\n\nAs noted in the example, if we have an estimate of the proportion, we should use it in place of the worst case estimate of the proportion,~0.5.\n\n\\textA{\\pagebreak}\n\n\\begin{exercise}\nA manager is about to oversee the mass production of a new tire model in her factory, and she would like to estimate what proportion of these tires will be rejected through quality control. The quality control team has monitored the last three tire models produced by the factory, failing 1.7\\% of tires in the first model, 6.2\\% of the second model, and 1.3\\% of the third model. The manager would like to examine enough tires to estimate the failure rate of the new tire model to within about 2\\% with a 90\\% confidence level.\\footnote{(a) For the 1.7\\% estimate of $p$, we estimate the appropriate sample size as follows:\n\\begin{align*}\n1.65\\times \\sqrt{\\frac{p(1-p)}{n}} \\approx\n1.65\\times \\sqrt{\\frac{0.017(1-0.017)}{n}} &\\leq 0.02 \\qquad\\to\\qquad n \\geq 113.7\n\\end{align*}\nUsing the estimate from the first model, we would suggest examining 114 tires (round up!). A similar computation can be accomplished using 0.062 and 0.013 for $p$: 396 and 88. \\par\n(b) We could examine which of the old models is most like the new model, then choose the corresponding sample size. Or if two of the previous estimates are based on small samples while the other is based on a larger sample, we should consider the value corresponding to the larger sample. (Answers will vary.)}\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item[(a)] There are three different failure rates to choose from. Perform the sample size computation for each separately, and identify three sample sizes to consider.\n\\item[(b)] The sample sizes vary widely. Which of the three would you suggest using? What would influence your choice?\n\\index{margin of error|)}\n\\end{itemize}\n\\end{exercise}\n\n\\index{data!Congress approval rating|(}\n\n\\begin{exercise}\nA recent estimate of Congress' approval rating was 17\\%.\\footnote{\\href{http://www.gallup.com/poll/155144/Congress-Approval-June.aspx}{www.gallup.com/poll/155144/Congress-Approval-June.aspx}} If we were to conduct a new poll and wanted an estimate with a margin of error smaller than about 0.04 with 95\\% confidence, how big of a sample should we use?\\footnote{We complete the same computations as before, except now we use $0.17$ instead of $0.5$ for $p$:\n\\begin{align*}\n1.96\\times \\sqrt{\\frac{p(1-p)}{n}} \\approx\n1.96\\times \\sqrt{\\frac{0.17(1-0.17)}{n}} &\\leq 0.04 \\qquad\\to\\qquad n \\geq 338.8\n\\end{align*}\nA sample size of 339 or more would be reasonable.}\n\n\\index{data!Congress approval rating|)}\n\n\\end{exercise}\n\n\n%__________________\n\\section{Difference of two proportions}\n\\label{differenceOfTwoProportions}\n\nWe would like to make conclusions about the difference in two population proportions ($p_1 - p_2$) using the normal model. In this section we consider three such examples. In the first, we compare the approval of the 2010 healthcare law under two different question phrasings. In the second application, a company weighs whether they should switch to a higher quality parts manufacturer. In the last example, we examine the cancer risk to dogs from the use of yard herbicides.\n\nIn our investigations, we first identify a reasonable point estimate of $p_1 - p_2$ based on the sample. You may have already guessed its form: $\\hat{p}_1 - \\hat{p}_2$\\index{point estimate!difference of proportions}. Next, in each example we verify that the point estimate follows the normal model by checking certain conditions; as before, these conditions relate to independence of observations and checking for sufficiently large sample size. Finally, we compute the estimate's standard error and apply our inferential framework.\n\n\n\\textA{\\pagebreak}\n\n\\subsection{Sample distribution of the difference of two proportions}\n\\label{SampleDistributionOfTheDiffOfTwoProportions}\n\nWe must check two conditions before applying the normal model to $\\hat{p}_1 - \\hat{p}_2$. First, the sampling distribution for each sample proportion must be nearly normal, and secondly, the samples must be independent. Under these two conditions, the sampling distribution of $\\hat{p}_1 - \\hat{p}_2$ may be well approximated using the normal model.\n\n\\begin{termBox}{\\tBoxTitle{Conditions for the sampling distribution of $\\hat{p}_1 - \\hat{p}_2$ to be normal}\nThe difference $\\hat{p}_1 - \\hat{p}_2$ tends to follow a normal model when\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item each proportion separately follows a normal model, and\n\\item the two samples are independent of each other.\n\\end{itemize}\nThe standard error of the difference in sample proportions is\n\\index{standard error!difference in proportions}\n\\begin{eqnarray}\nSE_{\\hat{p}_1 - \\hat{p}_2}\n\t= \\sqrt{SE_{\\hat{p}_1}^2 + SE_{\\hat{p}_2}^2}\n\t= \\sqrt{\\frac{p_1(1-p_1)}{n_1} + \\frac{p_2(1-p_2)}{n_2}}\n\\label{seForDiffOfProp}\n\\end{eqnarray}\nwhere $p_1$ and $p_2$ represent the population proportions, and $n_1$ and $n_2$ represent the sample sizes.}\n\\end{termBox}\n\n\n\\subsection{Intervals and tests for $p_1 -p_2$}\n\nIn the setting of confidence intervals, the sample proportions are used to verify the success-failure condition and also compute standard error, just as was the case with a single proportion.\n\n\\begin{example}{The way a question is phrased can influence a person's response. For example, Pew Research Center conducted a survey with the following question:\\footnote{\\href{http://www.people-press.org/2012/03/26/public-remains-split-on-health-care-bill-opposed-to-mandate/}{www.people-press.org/2012/03/26/public-remains-split-on-health-care-bill-opposed-to-mandate/}. Sample sizes for each polling group are approximate.}\n\\begin{quote}\nAs you may know, by 2014 nearly all Americans will be required to have health insurance. [People who do not buy insurance will pay a penalty] while [People who cannot afford it will receive financial help from the government]. Do you approve or disapprove of this policy?\n\\end{quote}\n\\index{data!health care|(}For each randomly sampled respondent, the statements in brackets were randomized: either they were kept in the order given above, or the two statements were reversed. Table~\\ref{pewPollResultsForRandomizedStatementOrdering} shows the results of this experiment. Create and interpret a 90\\% confidence interval of the difference in approval.}\n\n\\begin{table}[t]\n\\centering\n\\begin{tabular}{p{50mm}c p{13mm}p{14mm}p{16.5mm}c}\n\t&\\ & Sample size ($n_i$) & Approve law (\\%)\t& Disapprove law (\\%)\t& Other \\\\\n\\hline\n``people who cannot afford it will receive financial help from the government'' is given second \\vspace{2.5mm}\n\t& & 771\t& 47\t& 49\t& 3 \\\\\n``people who do not buy it will pay a penalty'' is given second\n\t& & 732\t& 34\t& 63\t& 3 \\\\\n\\hline\n\\end{tabular}\n\\caption{Results for a Pew Research Center poll where the ordering of two statements in a question regarding healthcare were randomized.\\vspaceB{-2mm}}\n\\label{pewPollResultsForRandomizedStatementOrdering}\n\\end{table}\n\nFirst the conditions must be verified. Because each group is a simple random sample from less than 10\\% of the population, the observations are independent, both within the samples and between the samples. The success-failure condition also holds for each sample. Because all conditions are met, the normal model can be used for the point estimate of the difference in support, where $p_1$ corresponds to the original ordering and $p_2$ to the reversed ordering:\n$$\\hat{p}_{1} - \\hat{p}_{2} = 0.47 - 0.34 = 0.13$$\nThe standard error may be computed from Equation~\\eqref{seForDiffOfProp} using the sample proportions:\n$$SE \\approx \\sqrt{\\frac{0.47(1-0.47)}{771} + \\frac{0.34(1-0.34)}{732}} = 0.025$$\nFor a 90\\% confidence interval, we use $z^{\\star} = 1.65$:\n$$\\text{point estimate} \\ \\pm\\ z^{\\star}SE \\quad \\to \\quad 0.13 \\ \\pm\\ 1.65 \\times  0.025 \\quad \\to \\quad (0.09, 0.17)$$\nWe are 90\\% confident that the approval rating for the 2010 healthcare law changes between 9\\% and 17\\% due to the ordering of the two statements in the survey question. The Pew Research Center reported that this modestly large difference suggests that the opinions of much of the public are still fluid on the health insurance mandate.\n\\index{data!health care|)}\n\\end{example}\n\n\\begin{exercise}\\label{carWheelGearManufacturer}\nA remote control car company is considering a new manufacturer for wheel gears. The new manufacturer would be more expensive but their higher quality gears are more reliable, resulting in happier customers and fewer warranty claims. However, management must be convinced that the more expensive gears are worth the conversion before they approve the switch. If there is strong evidence of a more than 3\\% improvement in the percent of gears that pass inspection, management says they will switch suppliers, otherwise they will maintain the current supplier. Set up appropriate hypotheses for the test.\\footnote{$H_0$: The higher quality gears will pass inspection no more than 3\\% more frequently than the standard quality gears. $p_{highQ} - p_{standard} = 0.03$. $H_A$: The higher quality gears will pass inspection more than 3\\% more often than the standard quality gears. $p_{highQ} - p_{standard} > 0.03$.}\n\\end{exercise}\n\n\\begin{example}{The quality control engineer from Guided Practice~\\ref{carWheelGearManufacturer} collects a sample of gears, examining 1000 gears from each company and finds that 899 gears pass inspection from the current supplier and 958 pass inspection from the prospective supplier. Using these data, evaluate the hypothesis setup of Guided Practice~\\ref{carWheelGearManufacturer} using a significance level of 5\\%.}\nFirst, we check the conditions. The sample is not necessarily random, so to proceed we must assume the gears are all independent; for this sample we will suppose this assumption is reasonable, but the engineer would be more knowledgeable as to whether this assumption is appropriate. The success-failure condition also holds for each sample. Thus, the difference in sample proportions, $0.958-0.899=0.059$, can be said to come from a nearly normal distribution.\n\nThe standard error can be found using Equation~\\eqref{seForDiffOfProp}:\n$$SE = \\sqrt{\\frac{0.958(1-0.958)}{1000} + \\frac{0.899(1-0.899)}{1000}} = 0.0114$$\nIn this hypothesis test, the sample proportions were used. We will discuss this choice more in Section~\\ref{pooledHTForProportionsSection}.\n\nNext, we compute the test statistic and use it to find the p-value, which is depicted in Figure~\\ref{gearsTwoSampleHTPValueQC}.\n$$Z = \\frac{\\text{point estimate} - \\text{null value}}{SE} = \\frac{0.059 - 0.03}{0.0114} = 2.54$$\nUsing the normal model for this test statistic, we identify the right tail area as 0.006. Since this is a one-sided test, this single tail area is also the p-value, and we reject the null hypothesis because 0.006 is less than 0.05. That is, we have statistically significant evidence that the higher quality gears actually do pass inspection more than 3\\% as often as the currently used gears. Based on these results, management will approve the switch to the new supplier.\n\\end{example}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.5\\textwidth]{03/figures/gearsTwoSampleHTPValueQC/gearsTwoSampleHTPValueQC}\n\\caption{Distribution of the test statistic if the null hypothesis was true. The p-value is represented by the shaded area.}\n\\label{gearsTwoSampleHTPValueQC}\n\\end{figure}\n\n\\subsection{Hypothesis testing when $H_0: p_1=p_2$}\n\\label{pooledHTForProportionsSection}\n\n\\index{data!cancer in dogs, herbicide|(}\n\nHere we use a new example to examine a special estimate of standard error when $H_0: p_1 = p_2$. We investigate whether there is an increased risk of cancer in dogs that are exposed to the herbicide 2,4-dichlorophenoxyacetic acid (2,4-D). A study in 1994 examined 491 dogs that had developed cancer and 945 dogs as a control group.\\footnote{Hayes HM, Tarone RE, Cantor KP, Jessen CR, McCurnin DM, and Richardson RC. 1991. Case-Control Study of Canine Malignant Lymphoma: Positive Association With Dog Owner's Use of 2, 4-Dichlorophenoxyacetic Acid Herbicides. Journal of the National Cancer Institute 83(17):1226-1231.} Of these two groups, researchers identified which dogs had been exposed to 2,4-D in their owner's yard. The results are shown in Table~\\ref{24DAndCancerInDogs}.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{rrr}\n  \\hline\n & cancer & no cancer \\\\\n  \\hline\n2,4-D & 191 & 304 \\\\\nno 2,4-D & 300 & 641 \\\\\n   \\hline\n\\end{tabular}\n\\caption{Summary results for cancer in dogs and the use of 2,4-D by the dog's owner.}\n\\label{24DAndCancerInDogs}\n\\end{table}\n\n\\textA{\\pagebreak}\n\n\\begin{exercise}\nIs this study an experiment or an observational study?\\footnote{The owners were not instructed to apply or not apply the herbicide, so this is an observational study. This question was especially tricky because one group was called the \\emph{control group}, which is a term usually seen in experiments.}\n\\end{exercise}\n\n\\begin{exercise} \\label{htFor24DAndCancerInDogs}\nSet up hypotheses to test whether 2,4-D and the occurrence of cancer in dogs are related. Use a one-sided test and compare across the cancer and no cancer groups.\\footnote{Using the proportions within the cancer and no cancer groups may seem odd. We intuitively may desire to compare the fraction of dogs with cancer in the 2,4-D and no 2,4-D groups, since the herbicide is an explanatory variable. However, the cancer rates in each group do not necessarily reflect the cancer rates in reality due to the way the data were collected. For this reason, computing cancer rates may greatly alarm dog owners. \\\\ $H_0$: the proportion of dogs with exposure to 2,4-D is the same in ``cancer'' and ``no cancer'' dogs, $p_c - p_n = 0$. \\\\ $H_A$: dogs with cancer are more likely to have been exposed to 2,4-D than dogs without cancer, $p_c - p_n > 0$.}\n\\end{exercise}\n\n\\begin{example}{Are the conditions met to use the normal model and make inference on the results?}\\label{condFor24DAndCancerInDogsNormalInference}\n(1) It is unclear whether this is a random sample. However, if we believe the dogs in both the cancer and no cancer groups are representative of each respective population and that the dogs in the study do not interact in any way, then we may find it reasonable to assume independence between observations. (2) The success-failure condition holds for each sample.\n\nUnder the assumption of independence, we can use the normal model and make statements regarding the canine population based on the data.\n\\end{example}\n\nIn your hypotheses for Guided Practice~\\ref{htFor24DAndCancerInDogs}, the null is that the proportion of dogs with exposure to 2,4-D is the same in each group. The point estimate of the difference in sample proportions is $\\hat{p}_c - \\hat{p}_n = 0.067$. To identify the p-value for this test, we first check conditions (Example~\\ref{condFor24DAndCancerInDogsNormalInference}) and compute the standard error of the difference:\n$$SE = \\sqrt{\\frac{p_c(1-p_c)}{n_c} + \\frac{p_n(1-p_n)}{n_n}}$$\nIn a hypothesis test, the distribution of the test statistic is always examined as though the null hypothesis is true, i.e. in this case, $p_c = p_n$. The standard error formula should reflect this equality in the null hypothesis. We will use $p$ to represent the common rate of dogs that are exposed to 2,4-D in the two groups:\n$$SE = \\sqrt{\\frac{p(1-p)}{n_c} + \\frac{p(1-p)}{n_n}}$$\nWe don't know the exposure rate, $p$, but we can obtain a good estimate of it by \\emph{pooling} the results of both samples:\n$$\\hat{p} = \\frac{\\text{\\# of ``successes''}}{\\text{\\# of cases}} = \\frac{191 + 304}{191+300+304+641} = 0.345$$\nThis is called the \\textbf{pooled estimate} of the sample proportion, and we use it to compute the standard error when the null hypothesis is that $p_1 = p_2$ (e.g. $p_c = p_n$ or $p_c - p_n = 0$). We also typically use it to verify the success-failure condition.\n\n\\begin{termBox}{\\tBoxTitle{Pooled estimate of a proportion}\nWhen the null hypothesis is $p_1 = p_2$, it is useful to find the pooled estimate of the shared proportion:\n\\begin{eqnarray*}\n\\hat{p} = \\frac{\\text{number of ``successes''}}{\\text{number of cases}} = \\frac{\\hat{p}_1n_1 + \\hat{p}_2n_2}{n_1 + n_2}\n\\end{eqnarray*}\nHere $\\hat{p}_1n_1$ represents the number of successes in sample 1 since\n\\begin{eqnarray*}\n\\hat{p}_1 = \\frac{\\text{number of successes in sample 1}}{n_1}\n\\end{eqnarray*}\nSimilarly, $\\hat{p}_2n_2$ represents the number of successes in sample 2.}\n\\end{termBox}\n\n\\begin{tipBox}{\\tipBoxTitle{Use the pooled proportion estimate when $\\mathbf{H_0: p_1 = p_2}$}\nWhen the null hypothesis suggests the proportions are equal, we use the pooled proportion estimate ($\\hat{p}$) to verify the success-failure condition and also to estimate the standard error:\n\\begin{eqnarray}\nSE = \\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n_1} + \\frac{\\hat{p}(1-\\hat{p})}{n_2}} \n\\label{seOfDiffInPropUsingPooledEstimate}\n\\end{eqnarray}}\n\\index{data!cancer in dogs, herbicide|)}\n\\end{tipBox}\n\n\\begin{exercise}\\label{verifySEOfPooledEstimateOf24DWithCancerNoCancerDogs}\nUsing Equation~\\eqref{seOfDiffInPropUsingPooledEstimate}, $\\hat{p}=0.345$, $n_1 = 491$, and $n_2=945$, verify the estimate for the standard error is $SE = 0.026$. Next, complete the hypothesis test using a significance level of 0.05. Be certain to draw a picture, compute the p-value, and state your conclusion in both statistical language and plain language.\\footnote{Compute the test statistic:\n\\begin{eqnarray*}\nZ = \\frac{\\text{point estimate} - \\text{null value}}{SE} = \\frac{0.067 - 0}{0.026} = 2.58\n\\end{eqnarray*}\nWe leave the picture to you. Looking up $Z=2.58$ in the normal probability table: 0.9951. However this is the lower tail, and the upper tail represents the p-value: $1-0.9951 = 0.0049$. We reject the null hypothesis and conclude that dogs getting cancer and owners using 2,4-D are associated.}\n\\end{exercise}\n\n\n%__________________\n\\textA{\\pagebreak}\n\\section[Testing for goodness of fit using chi-square (special topic)]{Testing for goodness of fit using chi-square\\\\(special topic)}\n\\label{oneWayChiSquare}\n\nIn this section, we develop a method for assessing a null model when the data are binned.\nThis technique is commonly used in two circumstances:\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item Given a sample of cases that can be classified into several groups, determine if the sample is representative of the general population.\n\\item Evaluate whether data resemble a particular distribution, such as a normal distribution or a geometric distribution. (Background on the geometric distribution is not necessary.)\n\\end{itemize}\nEach of these scenarios can be addressed using the same statistical test: a chi-square test.\n\n\\index{data!racial make-up of jury|(}\n\nIn the first case, we consider data from a random sample of 275 jurors in a small county. Jurors identified their racial group, as shown in Table~\\ref{juryRepresentationAndCityRepresentationForRace}, and we would like to determine if these jurors are racially representative of the population.  If the jury is representative of the population, then the proportions in the sample should roughly reflect the population of eligible jurors, i.e. registered voters.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{ll ccc c ll}\n\\hline\nRace\t & \\hspace{2mm} & White & Black & Hispanic & Other & \\hspace{2mm} & Total \\\\\n\\hline\nRepresentation in juries &\t& 205 & 26 & 25 & 19 & & 275 \\\\\nRegistered voters\t & \t\t& 0.72 & 0.07 & 0.12 & 0.09 & & 1.00 \\\\\n\\hline\n\\end{tabular}\n\\caption{Representation by race in a city's juries and population.}\n\\label{juryRepresentationAndCityRepresentationForRace}\n\\end{table}\n\nWhile the proportions in the juries do not precisely represent the population proportions, it is unclear whether these data provide convincing evidence that the sample is not representative. If the jurors really were randomly sampled from the registered voters, we might expect small differences due to chance. However, unusually large differences may provide convincing evidence that the juries were not representative.\n\nA second application, assessing the fit of a distribution, is presented at the end of this section. Daily stock returns from the S\\&P500 for the years 1990-2011 are used to assess whether stock activity each day is independent of the stock's behavior on previous days.\n\nIn these problems, we would like to examine all bins simultaneously, not simply compare one or two bins at a time, which will require us to develop a new test statistic.\n\n\n\\subsection{Creating a test statistic for one-way tables}\n\n\\begin{example}{Of the people in the city, 275 served on a jury. If the individuals are randomly selected to serve on a jury, about how many of the 275 people would we expect to be white? How many would we expect to be black?}\nAbout 72\\% of the population is white, so we would expect about 72\\% of the jurors to be white: $0.72\\times 275 = 198$.\n\nSimilarly, we would expect about 7\\% of the jurors to be black, which would correspond to about $0.07\\times 275 = 19.25$ black jurors.\n\\end{example}\n\n\\begin{exercise}\nTwelve percent of the population is Hispanic and 9\\% represent other races. How many of the 275 jurors would we expect to be Hispanic or from another race? Answers can be found in Table~\\ref{expectedJuryRepresentationIfNoBias}.\n\\end{exercise}\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{ll ccc c ll}\n\\hline\nRace\t & \\hspace{2mm} & White & Black & Hispanic & Other & \\hspace{2mm} & Total \\\\\n\\hline\nObserved data\t\t\t&\t& 205 & 26\t& 25 & 19\t&\t& 275 \\\\\nExpected counts\t &\t& 198 & 19.25 & 33 & 24.75 & & 275 \\\\\n\\hline\n\\end{tabular}\n\\caption{Actual and expected make-up of the jurors.}\n\\label{expectedJuryRepresentationIfNoBias}\n\\end{table}\n\nThe sample proportion represented from each race among the 275 jurors was not a precise match for any ethnic group. While some sampling variation is expected, we would expect the sample proportions to be fairly similar to the population proportions if there is no bias on juries. We need to test whether the differences are strong enough to provide convincing evidence that the jurors are not a random sample. These ideas can be organized into hypotheses:\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item[$H_0$:] The jurors are a random sample, i.e. there is no racial bias in who serves on a jury, and the observed counts reflect natural sampling fluctuation.\n\\item[$H_A$:] The jurors are not randomly sampled, i.e. there is racial bias in juror selection.\n\\end{itemize}\nTo evaluate these hypotheses, we quantify how different the observed counts are from the expected counts. Strong evidence for the alternative hypothesis would come in the form of unusually large deviations in the groups from what would be expected based on sampling variation alone.\n\n\n\\subsection{The chi-square test statistic}\n\\label{chiSquareTestStatistic}\n\nIn previous hypothesis tests, we constructed a test statistic of the following form:\n$$ \\frac{\\text{point estimate} - \\text{null value}}{\\text{SE of point estimate}} $$\nThis construction was based on (1) identifying the difference between a point estimate and an expected value if the null hypothesis was true, and (2) standardizing that difference using the standard error of the point estimate. These two ideas will help in the construction of an appropriate test statistic for count data.\n\nOur strategy will be to first compute the difference between the observed counts and the counts we would expect if the null hypothesis was true, then we will standardize the difference:\n\\begin{align*}\nZ_{1} = \\frac{\\text{observed white count} - \\text{null white count}}\n\t\t\t\t{\\text{SE of observed white count}}\n\\end{align*}\nThe standard error for the point estimate of the count in binned data is the square root of the count under the null.\\footnote{Using some of the rules learned in earlier chapters, we might think that the standard error would be $np(1-p)$, where $n$ is the sample size and $p$ is the proportion in the population. This would be correct if we were looking only at one count. However, we are computing many standardized differences and adding them together. It can be shown -- though not here -- that the square root of the count is a better way to standardize the count differences.} Therefore:\n\\begin{align*}\nZ_1 = \\frac{205 - 198}{\\sqrt{198}} = 0.50\n\\end{align*}\nThe fraction is very similar to previous test statistics: first compute a difference, then standardize it. These computations should also be completed for the black, Hispanic, and other groups:\n\\begin{align*}\n&Black && Hispanic\t&&Other \\\\\n& Z_2 = \\frac{26-19.25}{\\sqrt{19.25}}=1.54\\ \\ \\ \\ \n\t&& Z_3 = \\frac{25-33}{\\sqrt{33}}=-1.39\\ \\ \\ \\ \n\t&& Z_4 = \\frac{19-24.75}{\\sqrt{24.75}}=-1.16 \\\\\n\\end{align*}\nWe would like to use a single test statistic to determine if these four standardized differences are irregularly far from zero. That is, $Z_1$, $Z_2$, $Z_3$, and $Z_4$ must be combined somehow to help determine if they -- as a group -- tend to be unusually far from zero. A first thought might be to take the absolute value of these four standardized differences and add them~up:\n\\begin{align*}\n|Z_1| + |Z_2| + |Z_3| + |Z_4| = 4.58\n\\end{align*}\nIndeed, this does give one number summarizing how far the actual counts are from what was expected. However, it is more common to add the squared values:\n\\begin{align*}\nZ_1^2 + Z_2^2 + Z_3^2 + Z_4^2 = 5.89\n\\end{align*}\nSquaring each standardized difference before adding them together does two things:\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item Any standardized difference that is squared will now be positive.\n\\item Differences that already look unusual -- e.g. a standardized difference of 2.5 -- will become much larger after being squared.\n\\end{itemize}\nThe test statistic $X^2$\\marginpar[\\raggedright\\vspace{9mm}\n\n$X^2$\\vspace{0.5mm}\\\\\\footnotesize chi-square\\\\test statistic]{\\raggedright\\vspace{9mm}\n\n$X^2$\\vspace{0.5mm}\\\\\\footnotesize chi-square\\\\test statistic}, which is the sum of the $Z^2$ values, is generally used for these reasons. We can also write an equation for $X^2$ using the observed counts and null counts:\n\\index{data!racial make-up of jury|)}\n{\\begin{align*}\nX^2 &=\n\t\\frac\n\t{\\text{\\footnotesize$(\\text{observed count}_1 - \\text{null count}_1)^2$}}\n\t{\\text{\\footnotesize$\\text{null count}_1$}}\n\t+ \\dots + \\frac\n\t{\\text{\\footnotesize$(\\text{observed count}_4 - \\text{null count}_4)^2$}}\n\t{\\text{\\footnotesize$\\text{null count}_4$}}\n\\end{align*}\n}The final number $X^2$ summarizes how strongly the observed counts tend to deviate from the null counts. In Section~\\ref{pValueForAChiSquareTest}, we will see that if the null hypothesis is true, then $X^2$ follows a new distribution called a \\emph{chi-square distribution}. Using this distribution, we will be able to obtain a p-value to evaluate the hypotheses.\n\n\n\\subsection{The chi-square distribution and finding areas}\n\nThe \\textbf{chi-square distribution} is sometimes used to characterize data sets and statistics that are always positive and typically right skewed. Recall the normal distribution had two parameters -- mean and standard deviation -- that could be used to describe its exact characteristics. The chi-square distribution has just one parameter called \\termsub{degrees of freedom (df)}{degrees of freedom (df)!chi-square}, which influences the shape, center, and spread of the distribution.\n\n\\textA{\\pagebreak}\n\n\\begin{exercise}\\label{exerChiSquareDistributionDescriptionWithMoreDOF}\nFigure~\\ref{chiSquareDistributionWithInceasingDF} shows three chi-square distributions. (a) How does the center of the distribution change when the degrees of freedom is larger? (b) What about the variability (spread)? (c) How does the shape change?\\footnote{(a)~The center becomes larger. If we look carefully, we can see that the center of each distribution is equal to the distribution's degrees of freedom. (b)~The variability increases as the degrees of freedom increases. (c)~The distribution is very strongly skewed for $df=2$, and then the distributions become more symmetric for the larger degrees of freedom $df=4$ and $df=9$. We would see this trend continue if we examined distributions with even more larger degrees of freedom.}\n\\end{exercise}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{03/figures/chiSquareDistributionWithInceasingDF/chiSquareDistributionWithInceasingDF}\n\\caption{Three chi-square distributions with varying degrees of freedom.}\n\\label{chiSquareDistributionWithInceasingDF}\n\\end{figure}\n\nFigure~\\ref{chiSquareDistributionWithInceasingDF} and Guided Practice~\\ref{exerChiSquareDistributionDescriptionWithMoreDOF} demonstrate three general properties of chi-square distributions as the degrees of freedom increases: the distribution becomes more symmetric, the center moves to the right, and the variability inflates.\n\nOur principal interest in the chi-square distribution is the calculation of p-values, which (as we have seen before) is related to finding the relevant area in the tail of a distribution. To do so, a new table is needed: the \\textbf{chi-square table}, partially shown in Table~\\ref{chiSquareProbabilityTableShort}. A more complete table is presented in Appendix~\\vref{chiSquareProbabilityTable}. Using this table, we identify a range for the area, and we examine a particular row for distributions with different degrees of freedom. One important quality of this table: the chi-square table only provides upper tail values.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{r | rrrr | rrrr |}\n  \\hline\nUpper tail & 0.3 & 0.2 & 0.1 & 0.05 & 0.02 & 0.01 & 0.005 & 0.001 \\\\ \n  \\hline\n%df \\hfill 1 & \\footnotesize 1.07 & \\footnotesize 1.64 & \\footnotesize 2.71 & \\footnotesize 3.84 & \\footnotesize 5.41 & \\footnotesize 6.63 & \\footnotesize 7.88 & \\footnotesize 10.83 \\\\ \ndf \\hfill 2 & \\footnotesize 2.41 & \\footnotesize \\highlightO{3.22} & \\footnotesize \\highlightO{4.61} & \\footnotesize 5.99 & \\footnotesize 7.82 & \\footnotesize 9.21 & \\footnotesize 10.60 & \\footnotesize 13.82 \\\\ \n  \\em3 & \\em\\footnotesize 3.66 & \\em\\footnotesize 4.64 & \\em\\footnotesize \\highlightT{6.25} & \\em\\footnotesize 7.81 & \\em\\footnotesize 9.84 & \\em\\footnotesize 11.34 & \\em\\footnotesize 12.84 & \\em\\footnotesize 16.27 \\\\ \n  4 & \\footnotesize 4.88 & \\footnotesize 5.99 & \\footnotesize 7.78 & \\footnotesize 9.49 & \\footnotesize 11.67 & \\footnotesize 13.28 & \\footnotesize 14.86 & \\footnotesize 18.47 \\\\ \n  5 & \\footnotesize 6.06 & \\footnotesize 7.29 & \\footnotesize 9.24 & \\footnotesize 11.07 & \\footnotesize 13.39 & \\footnotesize 15.09 & \\footnotesize 16.75 & \\footnotesize 20.52 \\\\ \n  \\hline\n  6 & \\footnotesize 7.23 & \\footnotesize 8.56 & \\footnotesize 10.64 & \\footnotesize 12.59 & \\footnotesize 15.03 & \\footnotesize 16.81 & \\footnotesize 18.55 & \\footnotesize 22.46 \\\\ \n  7 & \\footnotesize 8.38 & \\footnotesize 9.80 & \\footnotesize 12.02 & \\footnotesize 14.07 & \\footnotesize 16.62 & \\footnotesize 18.48 & \\footnotesize 20.28 & \\footnotesize 24.32 \\\\ \n  \\hline\n\\end{tabular}\n\\caption{A section of the chi-square table. A complete table is listed in Appendix~\\vref{chiSquareProbabilityTable}.}\n\\label{chiSquareProbabilityTableShort}\n\\end{table}\n\n\\textA{\\pagebreak}\n\n\\begin{example}{Figure~\\ref{chiSquareAreaAbove6Point25WithDF3} shows a chi-square distribution with 3 degrees of freedom and an upper shaded tail starting at 6.25. Use Table~\\ref{chiSquareProbabilityTableShort} to estimate the shaded area.}\\label{chisquaredistexample01}\nThis distribution has three degrees of freedom, so only the row with 3 degrees of freedom (df) is relevant. This row has been italicized in the table. Next, we see that the value -- 6.25 -- falls in the column with upper tail area 0.1. That is, the shaded upper tail of Figure~\\ref{chiSquareAreaAbove6Point25WithDF3} has area 0.1.\n\\end{example}\n\n\\begin{figure}\n\\centering\n\\subfigure[Example~\\ref{chisquaredistexample01}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove6Point25WithDF3/chiSquareAreaAbove6Point25WithDF3}\n\\label{chiSquareAreaAbove6Point25WithDF3}\n}\n\\subfigure[Example~\\ref{chisquaredistexample02}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove4Point3WithDF2/chiSquareAreaAbove4Point3WithDF2}\n\\label{chiSquareAreaAbove4Point3WithDF2}\n}\n\\subfigure[Example~\\ref{chisquaredistexample03}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove5Point1WithDF5/chiSquareAreaAbove5Point1WithDF5}\n\\label{chiSquareAreaAbove5Point1WithDF5}\n}\n\\subfigure[Guided Practice~\\ref{ChiSquareDistGuidedPractice01}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove11Point7WithDF7/chiSquareAreaAbove11Point7WithDF7}\n\\label{chiSquareAreaAbove11Point7WithDF7}\n}\n\\subfigure[Guided Practice~\\ref{ChiSquareDistGuidedPractice02}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove10WithDF4/chiSquareAreaAbove10WithDF4}\n\\label{chiSquareAreaAbove10WithDF4}\n}\n\\subfigure[Guided Practice~\\ref{ChiSquareDistGuidedPractice03}.]{\n\\includegraphics[width=0.475\\textwidth]{03/figures/arrayOfFigureAreasForChiSquareDistribution/chiSquareAreaAbove9Point21WithDF3/chiSquareAreaAbove9Point21WithDF3}\n\\label{chiSquareAreaAbove9Point21WithDF3}\n}\n\\caption{\\textbf{\\subref{chiSquareAreaAbove6Point25WithDF3}} Chi-square distribution with 3 degrees of freedom, area above 6.25 shaded. \\textbf{\\subref{chiSquareAreaAbove4Point3WithDF2}} 2 degrees of freedom, area above 4.3 shaded. \\textbf{\\subref{chiSquareAreaAbove5Point1WithDF5}} 5 degrees of freedom, area above 5.1 shaded. \\textbf{\\subref{chiSquareAreaAbove11Point7WithDF7}} 7 degrees of freedom, area above 11.7 shaded. \\textbf{\\subref{chiSquareAreaAbove10WithDF4}} 4 degrees of freedom, area above 10 shaded. \\textbf{\\subref{chiSquareAreaAbove9Point21WithDF3}} 3 degrees of freedom, area above 9.21 shaded.}\n\\label{arrayOfFigureAreasForChiSquareDistribution}\n\\end{figure}\n\n\\begin{example}{We rarely observe the \\emph{exact} value in the table. For instance, Figure~\\ref{chiSquareAreaAbove4Point3WithDF2} shows the upper tail of a chi-square distribution with 2 degrees of freedom. The bound for this upper tail is at 4.3, which does not fall in Table~\\ref{chiSquareProbabilityTableShort}. Find the approximate tail area.}\\label{chisquaredistexample02}\nThe cutoff 4.3 falls between the second and third columns in the 2 degrees of freedom row. Because these columns correspond to tail areas of 0.2 and 0.1, we can be certain that the area shaded in Figure~\\ref{chiSquareAreaAbove4Point3WithDF2} is between 0.1 and 0.2.\n\\end{example}\n\n\\begin{example}{Figure~\\ref{chiSquareAreaAbove5Point1WithDF5} shows an upper tail for a chi-square distribution with 5 degrees of freedom and a cutoff of 5.1. Find the tail area.}\\label{chisquaredistexample03}\nLooking in the row with 5 df, 5.1 falls below the smallest cutoff for this row (6.06). That means we can only say that the area is \\emph{greater than 0.3}.\n\\end{example}\n\n\\begin{exercise}\\label{ChiSquareDistGuidedPractice01}\nFigure~\\ref{chiSquareAreaAbove11Point7WithDF7} shows a cutoff of 11.7 on a chi-square distribution with 7 degrees of freedom. Find the area of the upper tail.\\footnote{The value 11.7 falls between 9.80 and 12.02 in the 7 df row. Thus, the area is between 0.1 and 0.2.}\n\\end{exercise}\n\n\\begin{exercise}\\label{ChiSquareDistGuidedPractice02}\nFigure~\\ref{chiSquareAreaAbove10WithDF4} shows a cutoff of 10 on a chi-square distribution with 4 degrees of freedom. Find the area of the upper tail.\\footnote{The area is between 0.02 and 0.05.}\n\\end{exercise}\n\n\\begin{exercise}\\label{ChiSquareDistGuidedPractice03}\nFigure~\\ref{chiSquareAreaAbove9Point21WithDF3} shows a cutoff of 9.21 with a chi-square distribution with 3 df. Find the area of the upper tail.\\footnote{Between 0.02 and 0.05.}\n\\end{exercise}\n\n\n\\subsection{Finding a p-value for a chi-square distribution}\n\\label{pValueForAChiSquareTest}\n\n\\index{data!racial make-up of jury|(}\nIn Section~\\ref{chiSquareTestStatistic}, we identified a new test statistic ($X^2$) within the context of assessing whether there was evidence of racial bias in how jurors were sampled. The null hypothesis represented the claim that jurors were randomly sampled and there was no racial bias. The alternative hypothesis was that there was racial bias in how the jurors were sampled.\n\nWe determined that a large $X^2$ value would suggest strong evidence favoring the alternative hypothesis: that there was racial bias. However, we could not quantify what the chance was of observing such a large test statistic ($X^2=5.89$) if the null hypothesis actually was true. This is where the chi-square distribution becomes useful. If the null hypothesis was true and there was no racial bias, then $X^2$ would follow a chi-square distribution, with three degrees of freedom in this case. Under certain conditions, the statistic $X^2$ follows a chi-square distribution with $k-1$ degrees of freedom, where $k$ is the number of bins.\n\n\\begin{example}{How many categories were there in the juror example? How many degrees of freedom should be associated with the chi-square distribution used for $X^2$?}\nIn the jurors example, there were $k=4$ categories: white, black, Hispanic, and other. According to the rule above, the test statistic $X^2$ should then follow a chi-square distribution with $k-1 = 3$ degrees of freedom if $H_0$ is true.\n\\end{example}\n\nJust like we checked sample size conditions to use the normal model in earlier sections, we must also check a sample size condition to safely apply the chi-square distribution for $X^2$. Each expected count must be at least 5. In the juror example, the expected counts were 198, 19.25, 33, and 24.75, all easily above~5, so we can apply the chi-square model to the test statistic, $X^2=5.89$.\n\n\\begin{example}{If the null hypothesis is true, the test statistic $X^2=5.89$ would be closely associated with a chi-square distribution with three degrees of freedom. Using this distribution and test statistic, identify the p-value.}\nThe chi-square distribution and p-value are shown in Figure~\\ref{jurorHTPValueShown}. Because larger chi-square values correspond to stronger evidence against the null hypothesis, we shade the upper tail to represent the p-value. Using the chi-square table in Appendix~\\ref{chiSquareProbabilityTable} or the short table on page~\\pageref{chiSquareProbabilityTableShort}, we can determine that the area is between 0.1 and 0.2. That is, the p-value is larger than 0.1 but smaller than 0.2. Generally we do not reject the null hypothesis with such a large p-value. In other words, the data do not provide convincing evidence of racial bias in the juror selection.\n\\index{data!racial make-up of jury|)}\n\\end{example}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{03/figures/jurorHTPValueShown/jurorHTPValueShown}\n\\caption{The p-value for the juror hypothesis test is shaded in the chi-square distribution with $df=3$.}\n\\label{jurorHTPValueShown}\n\\end{figure}\n\n\\begin{termBox}{\\tBoxTitle{Chi-square test for one-way table}\nSuppose we are to evaluate whether there is convincing evidence that a set of observed counts $O_1$, $O_2$, ..., $O_k$ in $k$ categories are unusually different from what might be expected under a null hypothesis. Call the \\emph{expected counts} that are based on the null hypothesis $E_1$, $E_2$, ..., $E_k$. If each expected count is at least 5 and the null hypothesis is true, then the test statistic below follows a chi-square distribution with $k-1$ degrees of freedom:\n\\begin{align*}\nX^2 = \\frac{(O_1 - E_1)^2}{E_1} + \\frac{(O_2 - E_2)^2}{E_2} + \\cdots + \\frac{(O_k - E_k)^2}{E_k}\n\\end{align*}\nThe p-value for this test statistic is found by looking at the upper tail of this chi-square distribution. We consider the upper tail because larger values of $X^2$ would provide greater evidence against the null hypothesis.}\n\\end{termBox}\n\n\\begin{tipBox}{\\tipBoxTitle{Conditions for the chi-square test}\nThere are three conditions that must be checked before performing a chi-square test:\\vspace{-1mm}\n\\begin{description}\n\\setlength{\\itemsep}{0mm}\n\\item[Independence.] Each case that contributes a count to the table must be independent of all the other cases in the table.\n\\item[Sample size / distribution.] Each particular scenario (i.e. cell count) must have at least 5~expected cases.\n\\item[Degrees of freedom] We only apply the chi-square technique when the table is associated with a chi-square distribution with 2 or more degrees of freedom. \\vspace{-1mm}\n\\end{description}\nFailing to check conditions may affect the test's error rates.}\n\\end{tipBox}\n\nWhen examining a table with just two bins, pick a single bin and use the one-proportion methods introduced in Section~\\ref{singleProportion}.\n\n\n\\subsection{Evaluating goodness of fit for a distribution}\n\n%Section~\\ref{geomDist} would be useful background reading for this example, but it is not a prerequisite.\n\n\\index{data!S\\&P500 stock data|(}\n\nWe can apply our new chi-square testing framework to the second problem in this section: evaluating whether a certain statistical model fits a data set. Daily stock returns from the S\\&P500 for 1990-2011 can be used to assess whether stock activity each day is independent of the stock's behavior on previous days. This sounds like a very complex question, and it is, but a chi-square test can be used to study the problem. We will label each day as \\resp{Up} or \\resp{Down} (\\resp{D}) depending on whether the market was up or down that day. For example, consider the following changes in price, their new labels of up and down, and then the number of days that must be observed before each \\resp{Up} day:\n\\begin{center}\\footnotesize\n\\begin{tabular}{lc ccc ccc ccc cc}\nChange in price\t\t&\\hspace{-1mm}\t& \\footnotesize2.52 &\n\t\\footnotesize-1.46 & \\footnotesize 0.51 &\n\t\\footnotesize-4.07 & \\footnotesize3.36 &\n\t\\footnotesize1.10 &\n\t\\footnotesize-5.46 & \\footnotesize-1.03 & \\footnotesize-2.99 & \\footnotesize1.71 \\\\\nOutcome\t & \\hspace{-1mm} &\n\tUp &\n\tD & Up &\n\tD & Up &\n\tUp &\n\tD & D & D & Up \\\\\n\\footnotesize Days to Up & \\hspace{-1mm} & 1 & - & 2 & - & 2 & 1 & - & - & - & 4 \\\\\n\\end{tabular}\n\\end{center}\nIf the days really are independent, then the number of days until a positive trading day should follow a geometric distribution. The geometric distribution describes the probability of waiting for the $k^{th}$ trial to observe the first success. Here each up day (Up) represents a success, and down (D) days represent failures. In the data above, it took only one day until the market was up, so the first wait time was 1 day. It took two more days before we observed our next \\resp{Up} trading day, and two more for the third \\resp{Up} day. We would like to determine if these counts (1, 2, 2, 1, 4, and so on) follow the geometric distribution. Table~\\ref{sAndP500For1990To2011TimeToPosTrade} shows the number of waiting days for a positive trading day during 1990-2011 for the S\\&P500.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{ll ccc ccc c ll}\n\\hline\nDays\t & \\hspace{2mm} & 1 & 2 & 3 & 4 & 5 & 6 & 7+ & \\hspace{2mm} & Total \\\\\nObserved &\t\t& 1532 & 760 & 338 & 194 & 74 & 33 & 17 & & 2948 \\\\\n\\hline\n\\end{tabular}\n\\caption{Observed distribution of the waiting time until a positive trading day for the S\\&P500, 1990-2011.}\n\\label{sAndP500For1990To2011TimeToPosTrade}\n\\end{table}\n\nWe consider how many days one must wait until observing an \\resp{Up} day on the S\\&P500 stock exchange. If the stock activity was independent from one day to the next and the probability of a positive trading day was constant, then we would expect this waiting time to follow a \\emph{geometric distribution}. We can organize this into a hypothesis framework:\n\\begin{itemize}\n\\item[$H_0$:] The stock market being up or down on a given day is independent from all other days. We will consider the number of days that pass until an \\resp{Up} day is observed. Under this hypothesis, the number of days until an \\resp{Up} day should follow a geometric distribution.\n\\item[$H_A$:] The stock market being up or down on a given day is not independent from all other days. Since we know the number of days until an \\resp{Up} day would follow a geometric distribution under the null, we look for deviations from the geometric distribution, which would support the alternative hypothesis.\n\\end{itemize}\nThere are important implications in our result for stock traders: if information from past trading days is useful in telling what will happen today, that information may provide an advantage over other traders.\n\nWe consider data for the S\\&P500 from 1990 to 2011 and summarize the waiting times in Table~\\ref{sAndP500For1990To2011TimeToPosTrade2} and Figure~\\ref{geomFitEvaluationForSP500For1990To2011}. The S\\&P500 was positive on 53.2\\% of those days.\n\n\\begin{table}\n\\centering\n\\begin{tabular}{ll ccc ccc c ll}\n\\hline\nDays\t & \\hspace{1mm} & 1 & 2 & 3 & 4 & 5 & 6 & 7+ & \\hspace{1mm} & Total \\\\\n\\hline\nObserved &\t\t& 1532 & 760 & 338 & 194 & 74 & 33 & 17 & & 2948 \\\\\nGeometric Model &\t\t& 1569 & 734 & 343 & 161 & 75 & 35 & 31 & & 2948 \\\\\n\\hline\n\\end{tabular}\n\\caption{Distribution of the waiting time until a positive trading day. The expected counts based on the geometric model are shown in the last row. To find each expected count, we identify the probability of waiting $D$ days based on the geometric model ($P(D) = (1-0.532)^{D-1}(0.532)$) and multiply by the total number of streaks, 2948. For example, waiting for three days occurs under the geometric model about $0.468^2\\times 0.532 = 11.65\\%$ of the time, which corresponds to $0.1165\\times 2948 = 343$ streaks.}\n\\label{sAndP500For1990To2011TimeToPosTrade2}\n\\end{table}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.94\\textwidth]{03/figures/geomFitEvaluationForSP500For1990To2011/geomFitEvaluationForSP500For1990To2011}\n\\caption{Side-by-side bar plot of the observed and expected counts for each waiting time.}\n\\label{geomFitEvaluationForSP500For1990To2011}\n\\end{figure}\n\nBecause applying the chi-square framework requires expected counts to be at least~5, we have \\emph{binned} together all the cases where the waiting time was at least 7 days to ensure each expected count is well above this minimum. The actual data, shown in the \\emph{Observed} row in Table~\\ref{sAndP500For1990To2011TimeToPosTrade2}, can be compared to the expected counts from the \\emph{Geometric Model} row. The method for computing expected counts is discussed in Table~\\ref{sAndP500For1990To2011TimeToPosTrade2}. In general, the expected counts are determined by (1) identifying the null proportion associated with each bin, then (2) multiplying each null proportion by the total count to obtain the expected counts. That is, this strategy identifies what proportion of the total count we would expect to be in each bin.\n\n\\begin{example}{Do you notice any unusually large deviations in the graph? Can you tell if these deviations are due to chance just by looking?}\nIt is not obvious whether differences in the observed counts and the expected counts from the geometric distribution are significantly different. That is, it is not clear whether these deviations might be due to chance or whether they are so strong that the data provide convincing evidence against the null hypothesis. However, we can perform a chi-square test using the counts in Table~\\ref{sAndP500For1990To2011TimeToPosTrade2}.\n\\end{example}\n\n\\begin{exercise}\nTable~\\ref{sAndP500For1990To2011TimeToPosTrade2} provides a set of count data for waiting times ($O_1=1532$, $O_2=760$, ...) and expected counts under the geometric distribution ($E_1=1569$, $E_2=734$, ...). Compute the chi-square test statistic, $X^2$.\\footnote{$X^2=\\frac{(1532-1569)^2}{1569} + \\frac{(760-734)^2}{734} + \\cdots + \\frac{(17-31)^2}{31} = 15.08$}\n\\end{exercise}\n\n\\begin{exercise}\nBecause the expected counts are all at least~5, we can safely apply the chi-square distribution to $X^2$. However, how many degrees of freedom should we~use?\\footnote{There are $k=7$ groups, so we use $df=k-1=6$.}\n\\end{exercise}\n\n\\begin{example}{If the observed counts follow the geometric model, then the chi-square test statistic $X^2=15.08$ would closely follow a chi-square distribution with $df=6$. Using this information, compute a p-value.} \\label{RejectGeomModelForSP500StockDataFor1990To2011}\nFigure~\\ref{geomFitPValueForSP500For1990To2011} shows the chi-square distribution, cutoff, and the shaded p-value. If we look up the statistic $X^2=15.08$ in Appendix~\\ref{chiSquareProbabilityTable}, we find that the p-value is between 0.01 and 0.02. In other words, we have sufficient evidence to reject the notion that the wait times follow a geometric distribution, i.e. trading days are not independent and past days may help predict what the stock market will do today.\n\\end{example}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.93\\textwidth]{03/figures/geomFitPValueForSP500For1990To2011/geomFitPValueForSP500For1990To2011}\n\\caption{Chi-square distribution with 6 degrees of freedom. The p-value for the stock analysis is shaded.}\n\\label{geomFitPValueForSP500For1990To2011}\n\\end{figure}\n\n\\begin{example}{In Example~\\ref{RejectGeomModelForSP500StockDataFor1990To2011}, we rejected the null hypothesis that the trading days are independent. Why is this so important?}\nBecause the data provided strong evidence that the geometric distribution is not appropriate, we reject the claim that trading days are independent. While it is not obvious how to exploit this information, it suggests there are some hidden patterns in the data that could be interesting and possibly useful to a stock trader.\n\\index{data!S\\&P500 stock data|)}\n\\end{example}\n\n\n%__________________\n\\section[Testing for independence in two-way tables (special topic)]{Testing for independence in two-way tables\\\\(special topic)}\n\\label{twoWayTablesAndChiSquare}\n\n\\index{data!search algorithm|(}\n\nGoogle is constantly running experiments to test new search algorithms. For example, Google might test three algorithms using a sample of 10,000 google.com search queries. Table~\\ref{googleSearchAlgorithmByAlgorithmOnly} shows an example of 10,000 queries split into three algorithm groups.\\footnote{Google regularly runs experiments in this manner to help improve their search engine. It is entirely possible that if you perform a search and so does your friend, that you will have different search results. While the data presented in this section resemble what might be encountered in a real experiment, these data are simulated.} The group sizes were specified before the start of the experiment to be 5000 for the current algorithm and 2500 for each test algorithm.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{ll ccc ll}\n\\hline\nSearch algorithm\t & \\hspace{1mm} & current & test 1 & test 2 & \\hspace{1mm} & Total \\\\\nCounts &\t\t& 5000 & 2500 & 2500 & & 10000 \\\\\n\\hline\n\\end{tabular}\n\\caption{Google experiment breakdown of test subjects into three search groups.}\n\\label{googleSearchAlgorithmByAlgorithmOnly}\n\\end{table}\n\n\\begin{example}{What is the ultimate goal of the Google experiment? What are the null and alternative hypotheses, in regular words?}\nThe ultimate goal is to see whether there is a difference in the performance of the algorithms. The hypotheses can be described as the following:\\vspace{-1mm}\n\\begin{itemize}\n\\setlength{\\itemsep}{0mm}\n\\item[$H_0$:] The algorithms each perform equally well.\n\\item[$H_A$:] The algorithms do not perform equally well.\n\\end{itemize}\n\\end{example}\n\nIn this experiment, the explanatory variable is the search algorithm. However, an outcome variable is also needed. This outcome variable should somehow reflect whether the search results align with the user's interests. One possible way to quantify this is to determine whether (1)~the user clicked one of the links provided and did not try a new search, or (2)~the user performed a related search. Under scenario~(1), we might think that the user was satisfied with the search results. Under scenario~(2), the search results probably were not relevant, so the user tried a second search.\n\nTable~\\ref{googleSearchAlgorithmByAlgorithmAndPerformanceWithTotals} provides the results from the experiment. These data are very similar to the count data in Section~\\ref{oneWayChiSquare}. However, now the different combinations of two variables are binned in a \\emph{two-way} table. In examining these data, we want to evaluate whether there is strong evidence that at least one algorithm is performing better than the others. To do so, we apply a chi-square test to this two-way table. The ideas of this test are similar to those ideas in the one-way table case. However, degrees of freedom and expected counts are computed a little differently than before.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{ll ccc ll}\n\\hline\nSearch algorithm & \\hspace{1mm} & current & test 1 & test 2 & \\hspace{1mm} & Total \\\\\n\\hline\nNo new search\t\t\t\t   & & 3511    & 1749 & 1818 & \t\t\t\t& 7078 \\\\\nNew search\t\t\t\t   & & 1489    & 751\t& 682    &\t\t\t\t& 2922 \\\\\n\\hline\nTotal\t\t\t\t\t\t   & & 5000    & 2500 & 2500 & \t\t\t\t& 10000 \\\\\n\\hline\n\\end{tabular}\n\\caption{Results of the Google search algorithm experiment.}\n\\label{googleSearchAlgorithmByAlgorithmAndPerformanceWithTotals}\n\\end{table}\n\n\\begin{tipBox}{\\tipBoxTitle[]{What is so different about one-way tables and two-way tables?}\nA one-way table describes counts for each outcome in a single variable. A two-way table describes counts for \\emph{combinations} of outcomes for two variables. When we consider a two-way table, we often would like to know, are these variables related in any way? That is, are they dependent (versus independent)?}\n\\end{tipBox}\n\nThe hypothesis test for this Google experiment is really about assessing whether there is statistically significant evidence that the choice of the algorithm affects whether a user performs a second search. In other words, the goal is to check whether the \\textbf{search} variable is independent of the \\textbf{algorithm} variable.\n\n\n\\subsection{Expected counts in two-way tables}\n\n\\begin{example}{From the experiment, we estimate the proportion of users who were satisfied with their initial search (no new search) as $7078/10000 = 0.7078$. If there really is no difference among the algorithms and 70.78\\% of people are satisfied with the search results, how many of the 5000 people in the ``current algorithm'' group would be expected to not perform a new search?} \\label{googleExampleComputingTheExpectedNumberOfCurrentGroupWithNoNewSearch}\nAbout 70.78\\% of the 5000 would be satisfied with the initial search:\n$$ 0.7078\\times 5000 = 3539\\text{ users} $$\nThat is, if there was no difference between the three groups, then we would expect 3539 of the current algorithm users not to perform a new search.\n\\end{example}\n\n\\begin{exercise}\\label{googleExampleComputingTheExpectedNumberOfNewAlgGroupWithNoNewSearch}\nUsing the same rationale described in Example~\\ref{googleExampleComputingTheExpectedNumberOfCurrentGroupWithNoNewSearch}, about how many users in each test group would not perform a new search if the algorithms were equally helpful?\\footnote{We would expect $0.7078*2500 = 1769.5$. It is okay that this is a fraction.}\n\\end{exercise}\n\nWe can compute the expected number of users who would perform a new search for each group using the same strategy employed in Example~\\ref{googleExampleComputingTheExpectedNumberOfCurrentGroupWithNoNewSearch} and Guided Practice~\\ref{googleExampleComputingTheExpectedNumberOfNewAlgGroupWithNoNewSearch}. These expected counts were used to construct Table~\\ref{googleSearchAlgorithmByAlgorithmAndPerformanceWithExpectedCounts}, which is the same as Table~\\ref{googleSearchAlgorithmByAlgorithmAndPerformanceWithTotals}, except now the expected counts have been added in parentheses.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{l lll lll lll l}\n\\hline\nSearch algorithm\\hspace{2mm} & \\multicolumn{2}{l}{current} &&\n\t\t\t\t\t\\multicolumn{2}{l}{test 1} &&\n\t\t\t\t\t\\multicolumn{2}{l}{test 2} & \\hspace{0mm} & Total \\\\\n\\hline\nNo new search\t\t   & 3511 &\\highlightO{\\footnotesize(3539)}    &&\n\t\t\t\t\t1749 &\\highlightO{\\footnotesize(1769.5)}\t&&\n\t\t\t\t\t1818 &\\highlightO{\\footnotesize(1769.5)} &\t& 7078 \\\\\nNew search\t\t   & 1489 &\\highlightO{\\footnotesize(1461)}    && \n\t\t\t\t\t751 &\\highlightO{\\footnotesize(730.5)}\t&& \n\t\t\t\t\t682 &\\highlightO{\\footnotesize(730.5)}    &\t\t& 2922 \\\\\n\\hline\nTotal\t\t\t\t   & 5000 &&& \t2500 &&& \t2500 &&& \t10000 \\\\\n\\hline\n\\end{tabular}\n\\caption{The observed counts and the \\highlightO{(expected counts)}.}\n\\label{googleSearchAlgorithmByAlgorithmAndPerformanceWithExpectedCounts}\n\\end{table}\n\nThe examples and guided practice above provided some help in computing expected counts. In general, expected counts for a two-way table may be computed using the row totals, column totals, and the table total. For instance, if there was no difference between the groups, then about 70.78\\% of each column should be in the first row:\n\\begin{align*}\n0.7078\\times (\\text{column 1 total}) &= 3539 \\\\\n0.7078\\times (\\text{column 2 total}) &= 1769.5 \\\\\n0.7078\\times (\\text{column 3 total}) &= 1769.5\n\\end{align*}\nLooking back to how the fraction 0.7078 was computed -- as the fraction of users who did not perform a new search ($7078/10000$) -- these three expected counts could have been computed as\n\\begin{align*}\n\\left(\\frac{\\text{row 1 total}}{\\text{table total}}\\right)\\text{(column 1 total)} &= 3539 \\\\\n\\left(\\frac{\\text{row 1 total}}{\\text{table total}}\\right)\\text{(column 2 total)} &= 1769.5 \\\\\n\\left(\\frac{\\text{row 1 total}}{\\text{table total}}\\right)\\text{(column 3 total)} &= 1769.5\n\\end{align*}\nThis leads us to a general formula for computing expected counts in a two-way table when we would like to test whether there is strong evidence of an association between the column variable and row variable.\n\n\\begin{termBox}{\\tBoxTitle{Computing expected counts in a two-way table}\nTo identify the expected count for the $i^{th}$ row and $j^{th}$ column, compute\n$$\\text{Expected Count}_{\\text{row }i,\\text{ col }j} = \\frac{(\\text{row $i$ total}) \\times  (\\text{column $j$ total})}{\\text{table total}}\\vspace{2mm}$$}\n\\end{termBox}\n\n\n\\subsection{The chi-square test for two-way tables}\n\nThe chi-square test statistic for a two-way table is found the same way it is found for a one-way table. For each table count, compute\n\\begin{align*}\n&\\text{General formula}& &\\frac{(\\text{observed count } - \\text{ expected count})^2}{\\text{expected count}} \\\\\n&\\text{Row 1, Col 1}& &\\frac{(3511 - 3539)^2}{3539} = 0.222 \\\\\n&\\text{Row 1, Col 2}& &\\frac{(1749 - 1769.5)^2}{1769.5} = 0.237 \\\\\n& \\hspace{9mm}\\vdots & &\\hspace{13mm}\\vdots \\\\\n&\\text{Row 2, Col 3}& &\\frac{(682 - 730.5)^2}{730.5} = 3.220\n\\end{align*}\nAdding the computed value for each cell gives the chi-square test statistic $X^2$:\n$$X^2 = 0.222 + 0.237 + \\dots + 3.220 = 6.120$$\nJust like before, this test statistic follows a chi-square distribution. However, the degrees of freedom are computed a little differently for a two-way table.\\footnote{Recall: in the one-way table, the degrees of freedom was the number of cells minus 1.} For two way tables, the degrees of freedom is equal to\n\\begin{align*}\ndf = \\text{(number of rows minus 1)}\\times \\text{(number of columns minus 1)}\n\\end{align*}\nIn our example, the degrees of freedom parameter is\n\\begin{align*}\ndf = (2-1)\\times (3-1) = 2\n\\end{align*}\nIf the null hypothesis is true (i.e. the algorithms are equally useful), then the test statistic $X^2 = 6.12$ closely follows a chi-square distribution with 2 degrees of freedom. Using this information, we can compute the p-value for the test, which is depicted in Figure~\\ref{googleHTForDiffAlgPerformancePValue}.\n\n\\begin{termBox}{\\tBoxTitle{Computing degrees of freedom for a two-way table}\nWhen applying the chi-square test to a two-way table, we use\n$$ df = (R-1)\\times (C-1) $$\nwhere $R$ is the number of rows in the table and $C$ is the number of columns.}\n\\end{termBox}\n\n\\begin{tipBox}{\\tipBoxTitle{Use two-proportion methods for 2-by-2 contingency tables}\nWhen analyzing 2-by-2 contingency tables, use the two-proportion methods introduced in Section~\\ref{differenceOfTwoProportions}.}\n\\end{tipBox}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=\\textwidth]{03/figures/googleHTForDiffAlgPerformancePValue/googleHTForDiffAlgPerformancePValue}\n\\caption{Computing the p-value for the Google hypothesis test.}\n\\label{googleHTForDiffAlgPerformancePValue}\n\\end{figure}\n\n\\textA{\\pagebreak}\n\n\\begin{example}{Compute the p-value and draw a conclusion about whether the search algorithms have different performances.}\nLooking in Appendix~\\ref{chiSquareProbabilityTable} on page~\\pageref{chiSquareProbabilityTable}, we examine the row corresponding to 2 degrees of freedom. The test statistic, $X^2=6.120$, falls between the fourth and fifth columns, which means the p-value is between 0.02 and 0.05. Because we typically test at a significance level of $\\alpha=0.05$ and the p-value is less than 0.05, the null hypothesis is rejected. That is, the data provide convincing evidence that there is some difference in performance among the algorithms.\n\\index{data!search algorithm|)}\n\\end{example}\n\n%\tApprove\tDisapprove\n%Obama\t56\t41\n%Dem\t49\t43\n%Rep\t36\t56\n%http://www.people-press.org/2012/03/14/romney-leads-gop-contest-trails-in-matchup-with-obama/\n%March 7-11, 2012\n%1503 adults\n\n\\begin{example}{\\index{data!approval ratings|(}Table~\\ref{pewResearchPollOnApprovalRatingsForChiSquareSectionExampleAndExercises} summarizes the results of a Pew Research poll.\\footnote{See the Pew Research website: {\\scriptsize\\href{http://www.people-press.org/2012/03/14/romney-leads-gop-contest-trails-in-matchup-with-obama/}{www.people-press.org/2012/03/14/romney-leads-gop-contest-trails-in-matchup-with-obama}}. The counts in Table~\\ref{pewResearchPollOnApprovalRatingsForChiSquareSectionExampleAndExercises} are approximate.} We would like to determine if there are actually differences in the approval ratings of Barack Obama, Democrats in Congress, and Republicans in Congress. What are appropriate hypotheses for such a test?}\\label{hypothesisTestSetupForPewResearchPollOnApprovalRatingsForChiSquareSection}\n\\begin{itemize}\n\\item[$H_0$:] There is no difference in approval ratings between the three groups.\n\\item[$H_A$:] There is some difference in approval ratings between the three groups, e.g. perhaps Obama's approval differs from Democrats in Congress.\n\\end{itemize}\n\\end{example}\n\n\\begin{table}\n\\centering\n\\begin{tabular}{ll ccc ll}\n& & & \\multicolumn{2}{c}{Congress} & \\\\\n\\cline{4-5}\n & \\hspace{1mm} & Obama & Democrats & Republicans & \\hspace{1mm} & Total \\\\\n\\hline\nApprove\t\t\t\t   & & 842    & 736 & 541   & \t\t\t\t& 2119 \\\\\nDisapprove\t\t\t   & & 616    & 646 & 842   &\t\t\t\t& 2104 \\\\\n\\hline\nTotal\t\t\t\t\t   & & 1458    & 1382 & 1383 & \t\t\t\t& 4223 \\\\\n\\hline\n\\end{tabular}\n\\caption{Pew Research poll results of a March 2012 poll.}\n\\label{pewResearchPollOnApprovalRatingsForChiSquareSectionExampleAndExercises}\n\\end{table}\n\n\\textA{\\pagebreak}\n\n\\begin{exercise}\nA chi-square test for a two-way table may be used to test the hypotheses in Example~\\ref{hypothesisTestSetupForPewResearchPollOnApprovalRatingsForChiSquareSection}. As a first step, compute the expected values for each of the six table cells.\\footnote{The expected count for row one / column one is found by multiplying the row one total (2119) and column one total (1458), then dividing by the table total (4223): $\\frac{2119\\times 1458}{3902} = 731.6$. Similarly for the first column and the second row: $\\frac{2104\\times 1458}{4223} = 726.4$. Column 2: 693.5 and 688.5. Column 3: 694.0 and 689.0}\n% R <- c(2119, 2104); C <- c(1458, 1382, 1383); R*C[1]/sum(C); R*C[2]/sum(C); R*C[3]/sum(C)\n\\end{exercise}\n\n\\begin{exercise}\nCompute the chi-square test statistic.\\footnote{For each cell, compute $\\frac{(\\text{obs} - \\text{exp})^2}{exp}$. For instance, the first row and first column: $\\frac{(842-731.6)^2}{731.6} = 16.7$. Adding the results of each cell gives the chi-square test statistic: {\\scriptsize$X^2 = 16.7 + \\cdots + 34.0 = 106.4$}.}\n%R <- c(2119, 2104); C <- c(1458, 1382, 1383); CC <- c(842, 616, 736, 646, 541, 842); EE <- round(c(R*C[1]/sum(C), R*C[2]/sum(C), R*C[3]/sum(C)), 1); (CC-EE)^2/EE; sum((CC-EE)^2/EE)\n\\end{exercise}\n\n\\begin{exercise}\nBecause there are 2 rows and 3 columns, the degrees of freedom for the test is $df=(2-1)\\times (3-1) = 2$. Use $X^2=106.4$, $df=2$, and the chi-square table on page~\\pageref{chiSquareProbabilityTable} to evaluate whether to reject the null hypothesis.\\footnote{The test statistic is larger than the right-most column of the $df=2$ row of the chi-square table, meaning the p-value is less than 0.001. That is, we reject the null hypothesis because the p-value is less than 0.05, and we conclude that Americans' approval has differences among Democrats in Congress, Republicans in Congress, and the president.}\n\\index{data!approval ratings|)}\n\\end{exercise}\n\n\n", "meta": {"hexsha": "24353bc541dd46e63a6b7963c4a7df876fb5cab7", "size": 78643, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ISRS1/Tex/03-V01.tex", "max_stars_repo_name": "amthapar/Crump_Stat", "max_stars_repo_head_hexsha": "8baa0a79d4e996c10b30d41af4d331e887bbaf1c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-09T23:52:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-09T23:52:33.000Z", "max_issues_repo_path": "ISRS1/Tex/03-V01.tex", "max_issues_repo_name": "amthapar/Crump_Stat", "max_issues_repo_head_hexsha": "8baa0a79d4e996c10b30d41af4d331e887bbaf1c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ISRS1/Tex/03-V01.tex", "max_forks_repo_name": "amthapar/Crump_Stat", "max_forks_repo_head_hexsha": "8baa0a79d4e996c10b30d41af4d331e887bbaf1c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.4851380042, "max_line_length": 911, "alphanum_fraction": 0.7677352085, "num_tokens": 21662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.7431680029241322, "lm_q1q2_score": 0.43482844552455646}}
{"text": "\\documentclass{article}\n\\usepackage[margin = 1in, footskip = 0.25in]{geometry}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage[ruled,vlined]{algorithm2e}\n\\usepackage{xcolor}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\n\\usepackage{xparse}\n\n\\NewDocumentCommand{\\codeword}{v}{%\n\\texttt{\\textcolor{teal}{#1}}%\n}\n\\lstset{language=C,keywordstyle={\\bfseries \\color{blue}}}\n\n\\renewcommand{\\familydefault}{\\sfdefault}\n\\newcommand{\\bc}{\\text{\\sc bc}}\n\\newcommand{\\HH}{\\smash{\\widetilde{H}}}\n\n\\title{Code details}\n\\date{}\n\n\\begin{document}\n\\maketitle\nThis document provides an overview of main functions and their outputs. Those interested in contributing to the project may find this document useful.\n\n\\section{The persistent extension method}\n\\subsection{Implementation}\n\\begin{itemize}\n\\item The persistent extension method is implemented in 6 different functions:\t\n\t\\begin{itemize}\n\t\\item \\codeword{run_extension_VR_to_VR()}\n\t\\item \\codeword{run_extension_VR_to_VR_bar()}\n\t\\item \\codeword{run_extension_VR_to_W()}\n\t\\item \\codeword{run_extension_VR_to_W_bar()}\n\t\\item \\codeword{run_extension_W_to_VR()}\n\t\\item \\codeword{run_extension_W_to_VR_bar()}\n\t\\end{itemize}\n\\item The functions implement a variation of the cycle-to-bars extension (Algorithm 5 from paper) or a bar-to-bars extension (Algorithm 3 from paper). The ones implementing bar-to-bars extension has the string \\codeword{_bar} at the end of its function name.\n\\item All implementations are component-wise extensions with $\\mathbb{F}_2$ coefficients.\n\\item Due to computation speed issues, the functions do not return the full collection of cycle extensions and bar extensions as described in the paper. Instead, the functions return the baseline and offset cycle extensions and bar extensions. The output of the above functions can then be processed to return the full collection of cycle extensions $E(\\tau, Y^{\\bullet})$ and bar extensions $S(\\tau, Y^{\\bullet})$.  \n\\item The algorithm below summarizes the bar-to-bars extension method variation implemented by our functions. The cycle-to-bars extension functions implement a similar variation. \n\\end{itemize}\n%------------------------------------------------------------------------------------------------------------------------------\n\\begin{algorithm}[H]\n\\caption{Bar-to-bars extension method variation}\n\\label{alg_variation}\n\\textbf{Input}:\n\\begin{itemize}\n    \\item filtered simplicial complexes $Z^{\\bullet}$, $Y^{\\bullet}$ on vertex set $P$, \n    \\item a bar $\\tau \\in \\bc_k(Z^{\\bullet})$\n    \\end{itemize}\n\n\\textbf{Steps:}\n\\begin{enumerate}\n\\item Fix interval decompositions $\\mathcal{B}$ of $P\\HH_k(Z^{\\bullet})$ and $\\mathcal{D}$ of $P\\HH_k(Y^{\\bullet}).$\n\\item Find parameter $\\delta(\\tau)-1$ and cycle $[\\tau_*^{\\mathcal{B}}]$.\n\\item Let $p_Y$ be the collection of parameters from Algorithm 1 of paper run with inputs $\\delta(\\tau)-1$ and $[\\tau_*^{\\mathcal{B}}]$. \n\\item Let $\\text{\\sc{bars}}_{\\tau}^{\\mathcal{F}} = \\{ \\rho_1, \\dots, \\rho_m \\}$ be the set of bars in the $\\mathcal{F}$-bar representation.\n\\item For each $\\ell \\in p_Y$:\n\t\\begin{enumerate}\n\t\\item Find the baseline cycle extension $\\mathfrak{E}_{\\ell}^{\\text{baseline}} = \\Upsilon_{\\ell}(\\sum_{i=1}^m [\\rho_i^{\\mathcal{F}, \\ell}])$\n\t\\item Find the offset cycle extension $\\mathfrak{E}_{\\ell}^{\\text{offset}} = \\{ \\Upsilon_{\\ell}[\\rho^{\\mathcal{F}, \\ell}] \\; | \\; \\rho \\in \\text{\\sc{bars}}_{\\text{short}}^{\\ell}\\} $\n\t\\item Find the baseline bar extension  $B^{\\ell} = \\{ S^{\\mathcal{D}}_{[t]} \\; | \\; [t] \\in \\mathfrak{E}_{\\ell}^{\\text{baseline}} \\}$ .\n\t\\item Find the offset bar extension $O^{\\ell} = \\{ S^{\\mathcal{D}}_{[t]} \\; | \\; [t] \\in \\mathfrak{E}_{\\ell}^{\\text{offset}} \\}$.\n\t\\end{enumerate}\n\n\\item Return $\\mathfrak{E}_{\\ell}^{\\text{baseline}}, \\mathfrak{E}_{\\ell}^{\\text{offset}}, B^{\\ell}$, and $O^{\\ell}$ for $\\ell \\in p_Y$.\n\\end{enumerate}\n\\end{algorithm}\n\n\n\\begin{itemize}\n\\item The following flow chart summarizes the key functions implemented in each step. The left-most column describes the general flow. The remaining columns show the explicit functions called to execute the specific task. Depending on the filtration types, the component functions require slight modifications.\n\\end{itemize}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width = \\textwidth]{code_components.png}\n\\end{figure}\n\n\\begin{itemize}\n\\item If you choose to take a closer look at the code, you will notice that there are many functions and variables that keeps track of the various ways in which we describe a simplex (and therefore, a chain). Here are some things to keep in mind:\n\\begin{itemize}\n\\item A simplex can either be expressed using some index (the ``i\"-th simplex) or it can be expressed using its 0-simplices ($ s = [v_0, v_1]$). We'll refer to the former as the ``index notation\" and the latter as the ``simplex notation\". Any functions and variables with the t erm \\codeword{simplex2index} or \\codeword{index2simplex} will convert one notation to another.\n\\item The vertex ordering used in various functions may differ from the vertex ordering provided by the input. That is, let's say we provide a distance matrix $D$. We would intuitively think that the 1st row of $D$ corresponds to vertex $v_1$, 2nd row of $D$ corresponds to vertex $v_2$, and so on. However, the vertex ordering used in the computations may differ from the order of the rows of $D$. This is because Eirene permutes the vertices during its computations. We often use specific permutations to go back and forth between Eirene's vertex ordering and the default vertex ordering. \n\\item When building the Witness complex from a cross-distance matrix $D_{P,Q}$, it's possible to provide the maximum parameter at which to build the Witness complex. In such cases, one may end up using only a sub-collection of the vertices provided by the rows of $D_{P,Q}$. In such cases we end up with two distinct ordering of the vertices: The ordering provided by the distance matrix $D_{P,Q}$ and the ordering among the sub-collection of vertices used to build the Witness complex. The former is called the \\codeword{default_vertex} and the latter is called the \\codeword{Wepsilon_vertex} in the code.\n\\end{itemize}\n\n\\end{itemize}\n\n%========================================================================\n\\subsection{Finding the full collection of cycle extensions and bar extensions}\n\\begin{itemize}\n\\item As noted in the previous section, the 6 extension method function returns the \\textbf{component-wise} cycle and bar extensions. We provide several functions that help the user to find the full collection of cycle extensions ($E(\\tau, Y^{\\bullet})$ from paper) and bar extensions ( $S(\\tau, Y^{\\bullet})$ from paper) .\n\\item We first discuss methods for finding the collection of cycle extensions $E(\\tau, Y^{\\bullet})$ and the bar extensions under a \\textbf{fixed interval decomposition} of $P\\HH_k(Y^{\\bullet})$. We'll then discuss methods for finding the full bar extensions under any interval decomposition of $P\\HH_k(Y^{\\bullet})$. \n\\item In each section, we present multiple functions that achieve the same goal. The appropriate use of the functions depend on the size of the data -- In particular, the number of bars in $\\bc_k(Z^{\\psi} \\cap Y^{\\bullet})$ and $\\bc_k(Y^{\\bullet})$. \n\\end{itemize}\n\n\\subsubsection{Finding all cycle extensions and bar extensions under fixed target interval decomposition}\n\\begin{itemize}\n\\item Use the function \\codeword{return_extension_results_at_parameter()} for an interactive exploration of baseline and offset bar extensions. For each parameter, user can select which offset bar extensions to include in their final view. \n\\item To find all cycle extensions and bar extensions at a specific parameter, run the function \\codeword{find_CE_BE_at_param()}. \n\\item To find all cycle extensions and bar extensions at all parameters, run \\codeword{find_CE_BE()}.\n\t\\begin{itemize}\n\t\\item Let \\codeword{CE}, \\codeword{BE} be the outputs of the function.\n\t\\item Given a parameter \\codeword{param}, and some index \\codeword{i}, \\codeword{CE[param][i]} is the i-th cycle extension at given parameter\n\t\\item Given a parameter \\codeword{param}, and some index \\codeword{i}, \\codeword{BE[param][i]} is the i-th bar extension at given parameter\n\t\\end{itemize}\n\\end{itemize}\n\n\\subsubsection{Finding all alternative bar extensions} \n\\begin{itemize}\n\\item We now discuss methods for finding all alternative bar extensions under possible interval decompositions of $P\\HH_k(Y^{\\bullet})$.\n\\item To find the full collection of alternative bar extensions $S(\\tau, Y^{\\bullet}) = \\{ S^{\\mathcal{D} \\circ L^{-1}}_{[y]} | \\ell \\in p_Y, [y] \\in \\mathfrak{E}_{\\ell}, L \\in L_Y \\}$, run the function \\codeword{find_alt_BE()}. Note that this is appropriate for data with small barcodes sizes.\n\\item To find the alternative bar extensions at \\textbf{specific parameters}, run the function \\codeword{find_alt_BE_at_param()}. Given a parameter $\\ell$, this method finds $S(\\tau, Y^{\\bullet}; \\ell) = \\{ S^{\\mathcal{D} \\circ L^{-1}}_{[y]} | [y] \\in \\mathfrak{E}_{\\ell}, L \\in L_Y \\} $.\n\\item To find alternative bar extensions of a specific bar extension, use the function \\codeword{find_alternative_bar_extension()}. Given a parameter $\\ell$ and a cycle extension $[y] \\in \\mathfrak{E}_{\\ell}$, this method returns $\\{S^{\\mathcal{D} \\circ L^{-1}}_{[y]} | L \\in L_Y \\}$. \n\\end{itemize}\n\n\n%========================================================================\n\\subsection{Understanding the output of the functions}\nThe output of the 6 extension method functions is a dictionary with the following key-value pairs.\n\n\\begin{itemize}\n\\item \\codeword{comparison} : Indicates the types of the filtrations under comparison. Values can be ``VR to VR\" or ``VR to W\" or ``W to VR\".\n\\item \\codeword{C_Z}: Eirene's dictionary output on the ``from\" filtration $Z^{\\bullet}$.\n\t\\begin{itemize}\n\t\\item If \\codeword{comparison} is ``VR to VR\" then \\codeword{C_Z} refers to the ``from\" filtration in which a cycle or bar was selected.\n\t\\item If \\codeword{comparison} is ``VR to W\", then the dictionary output will have key \\codeword{C_VR} to refer to the \"from\" filtration.\n\t\\item If \\codeword{comparison} is ``W to VR\", then the dictionary output will have key \\codeword{C_W} to refer to the ``from\" filtration.\n\t\\end{itemize}\n\\item \\codeword{C_Y}: Eirene's dictionary output on the ``target\" filtration $Y^{\\bullet}$.\n\t\\begin{itemize}\n\t\\item If \\codeword{comparison} is ``VR to VR\" then \\codeword{C_Y} refers to the ``target\" filtration in which a cycle or bar was selected.\n\t\\item If \\codeword{comparison} is ``VR to W\", then the dictionary output will have key \\codeword{C_W} to refer to the ``target\" filtration.\n\t\\item If \\codeword{comparison} is ``W to VR\", then the dictionary output will have key \\codeword{C_VR} to refer to the ``target\" filtration.\n\n\t\\end{itemize}\n\\item \\codeword{dim}: Dimension of interest.\n\\item \\codeword{selected_cycle}: Input cycle.\n\t\\begin{itemize}\n\t\\item If the output is obtained from a bar-to-bars extension, then \\codeword{extension[\"selected_cycle\"]} is a simply a copy of the input cycle. \n\t\\item If the output is obtained from a cycle-to-bars extension, then \\codeword{extension[\"selected_cycle\"]} is the cycle representative of the input bar. \n\t\\item In the code, this cycle is often referred to as \\codeword{tau}.\n\t\\end{itemize}\n \\item \\codeword{C_auxiliary_filtration}: Eirene's dictionary output on filtration $Z^{\\psi} \\cap Y^{\\bullet}$\n \\item \\codeword{aux_filt_cycle_rep}: Cycle representatives of bars in \\codeword{C_auxiliary_filtration}\n\\item \\codeword{p_Y}: Collection of parameters $p_Y$\n\\item \\codeword{epsilon_0}: Minimum parameter value in $p_Y$\n\\item \\codeword{nontrivial_pY}: A sub-collection of parameters in $p_Y$. \n\\[\\{\\varepsilon \\in p_Y  \\; | \\; \\text{ there exists a cycle in } Z^{\\psi} \\cap Y^{\\bullet} \\text{ that is born at  } \\varepsilon \\text{ withx a non-trivial cycle extension} \\}\\]\nTo find all cycle extensions and bar extensions, it suffices to consider only the parameters in \\codeword{nontrivial_pY} (instead of \\codeword{p_Y}, which is quite large).\n\\item \\codeword{nontrivial_pY_dict}: A dictionary of parameter index and values.\n\\item \\codeword{Ybar_rep_tau}: Given the \\codeword{selected_cycle} $[\\tau]$, let $\\{\\rho_1, \\dots, \\rho_m \\}$ be the $\\mathcal{F}$-bar representations of $[\\tau]$ (Algorithm 1 step (2)(a)). Let $[y] = \\Upsilon_{\\varepsilon_0}([\\rho_1^{\\mathcal{F}, \\varepsilon_0}] + \\cdots + [\\rho_m^{\\mathcal{F}, \\varepsilon_0}]) \\in \\mathfrak{E}_{\\varepsilon_0}$. \\codeword{Ybar_rep_tau} is the $\\mathcal{D}$-bar representation of $[y]$ ($S^{\\mathcal{D}}_{[y]}$).\n\\item \\codeword{Ybar_rep_short_epsilon0}: A dictionary of the short bars $\\rho \\in \\text{BARS}_{\\text{short}}^{\\varepsilon_0}$ and their $\\mathcal{D}$-bar representations. Given a short bar \\codeword{rho} representing $\\rho \\in \\text{BARS}_{\\text{short}}^{\\varepsilon_0}$, let $[y] = \\Upsilon_{\\varepsilon_0}([\\rho_1^{\\mathcal{F}, \\varepsilon_0}]) $. \n\nThen, \\codeword{extension[\"Ybar_rep_short_epsilon0\"][rho]} is the $\\mathcal{D}$-bar representation $S^{\\mathcal{D}}_{[y]}$.\n\\item \\codeword{Ybar_rep_short}: Dictionary of the short bars $\\rho \\in \\text{BARS}_{\\text{short}} \\setminus \\text{BARS}_{\\text{short}}^{\\varepsilon_0}$ and their $\\mathcal{D}$-bar representations.\n\\item \\codeword{cycle_extensions}: Dictionary summarizing cycle extensions of given input at various parameters.  Given a parameter \\codeword{l} ( or $\\ell$) in \\codeword{extension[\"nontrivial_pY\"]}, \n\n\t\\begin{itemize}\n\t\\item \\codeword{extension[\"cycle_extensions\"][l][\"baseline\"]} is the baseline cycle extension at parameter \\codeword{l}. (See section 4.4 of paper). Given the \\codeword{selected_cycle} $[\\tau]$, let $\\{ \\rho_1, \\dots, \\rho_m \\}$ be the $\\mathcal{F}$-bar representations of $[\\tau]$. Let $[y] = \\Upsilon_{\\ell}([\\rho_1^{\\mathcal{F}, \\ell}] + \\cdots + [\\rho_m^{\\mathcal{F}, \\ell}]) \\in \\mathfrak{E}_{\\ell}$. \\codeword{extension[\"cycle_extensions\"][l][\"baseline\"]} returns $[y]$ if $[y]$ is nontrivial at parameter $l$. Otherwise returns empty array.\n\t\\item \\codeword{extension[\"cycle_extensions\"][l][\"offset\"]} is a dictionary whose keys are $\\text{BARS}_{\\text{short}}^{l}$ (Algorithm 1, step 3(b)(i)) and whose values are the corresponding offset cycle extensions.\n\t\\begin{itemize}\n\t\\item Let \\codeword{j}  be a bar in $\\text{BARS}_{\\text{short}}^{\\ell}$. (That is, $\\rho_j \\in \\text{BARS}_{\\text{short}}^{\\ell}$) % In the paper, we refer to the collection of all such offset cycle extensiosn as the official offset cycle extension.\n\t\\item \\codeword{extension[\"cycle_extensions\"][l][\"offset\"][j]} is  $\\Upsilon_{\\ell} [\\mathcal{F}^{\\ell} (\\vec{e}^{\\; \\ell}_{\\rho_j})]$.\n\t\\item See section 4.4 of paper for notations.\n\t\\end{itemize}\n\t\\end{itemize}\n\t\n\\item \\codeword{bar_extensions}: Dictionary summarizing bar extensions of given input at various parameters.  Given a parameter \\codeword{l} (or $\\ell$) in \\codeword{extension[\"nontrivial_pY\"]}, \n\t\\begin{itemize}\n\t\\item \\codeword{extension[\"bar_extensions\"][l][\"baseline\"]} is the baseline bar extension at parameter \\codeword{l}. (See section 4.4 of paper).  Given the \\codeword{selected_cycle} $[\\tau]$, let $\\{ \\rho_1, \\dots, \\rho_m \\}$ be the $\\mathcal{F}$-bar representations of $[\\tau]$. Let $[y] = \\Upsilon_{\\ell}([\\rho_1^{\\mathcal{F}, \\ell}] + \\cdots + [\\rho_m^{\\mathcal{F}, \\ell}]) \\in \\mathfrak{E}_{\\ell}$. \\codeword{extension[\"bar_extensions\"][l][\"baseline\"]} returns the $\\mathcal{D}$-bar representation of $[y]$: $S^{\\mathcal{D}}_{[y]}$.\n\t\\item \\codeword{extension[\"bar_extensions\"][l][\"offset\"]} is a dictionary whose keys are $\\text{BARS}_{\\text{short}}^{\\ell}$ (Algorithm 1, step 3(b)(i)) and whose values are the corresponding offset bar extensions.\t\n\t\\begin{itemize}\n\t\\item Let \\codeword{j}  be a bar in $\\text{BARS}_{\\text{short}}^{\\ell}$. (That is, $\\rho_j \\in \\text{BARS}_{\\text{short}}^{\\ell}$) % In the paper, we refer to the collection of all such offset cycle extensiosn as the official offset cycle extension.\n\t\\item Recall the cycle extension: \\codeword{extension[\"cycle_extensions\"][l][\"offset\"][j]} is  $\\Upsilon_{\\ell} [\\mathcal{F}^{\\ell} (\\vec{e}^{\\; \\ell}_{\\rho_j})]$. We'll call this cycle $[y]$.\n\t\\item \t\\codeword{extension[\"bar_extensions\"][l][\"offset\"][j]} is the offset bar extension for bar \\codeword{j}. \n\t\\item That is, it returns the $\\mathcal{D}$-bar representation of $[y]$: $S^{\\mathcal{D}}_{[y]}$. \n\t% In the paper, we refer to the collection of all such offset cycle extensiosn as the official offset cycle extension.\n\t\\end{itemize}\n\t\\item Example:\n\t\t\\begin{itemize}\n\t\t\\item \\codeword{extension[\"bar_extensions\"][0.123][\"baseline\"]} = [1,2,3] : At parameter 0.123, the baseline bar extension is [1,2,3].\n\t\t\\item \\codeword{extension[\"bar_extensions\"][0.123][\"offset\"][5]} = [4,5]: At parameter 0.123, the offset bar extension corresponding to bar 5 of $\\text{BAR}_{\\text{short}}$ is [4,5]\n\t\t\\end{itemize}\n\t\\end{itemize}\n\n\\end{itemize}\n\n%========================================================================\n\\section{The analogous bars method}\n\n\\subsection{Implementation}\n\\begin{itemize}\n\\item As discussed in the paper, there are two types of analogous bars method: the similarity-centric analogous bars method and the feature-centric analogous bars method\n\\item \\textbf{similarity-centric analogous bars}\n\t\\begin{itemize}\n\t\\item Given two point clouds \\codeword{P} and \\codeword{Q}, user selects a bar of interest in \\codeword{barcode(W(P,Q))}. (The Witness barcode with \\codeword{P} as landmark and \\codeword{Q} as witness) \n\t\\item The function returns the output of implementing bar-to-bars extension to \\codeword{barcode(VR(P))} and \\codeword{barcode(VR(Q))}.\n\t\\end{itemize}\n\\item \\textbf{feature-centric analogous bars}\n\t\\begin{itemize}\n\t\\item There is no one function that implements this method because it requires user interaction.\n\t\\item One should first run the bar-to-cycle extension method from \\codeword{VR(P)} to \\codeword{W(P,Q)}. We run the function \\codeword{run_extension_VR_to_W_bar()}. \n\t\\item User then selects a particular cycle extension of interest, say \\codeword{cycle_W_PQ}.\n\t\\item % SUPPLY FUNCTION HERE -- APPLY DOWKER\"S THEOREM TO FIND CORRESPONDING CYCLE IN cycle_W_QP\n\t\\item One should then run a cycle-to-bar extension method from \\codeword{W(Q,P)} to \\codeword{VR(Q)} by calling the function \\codeword{run_extension_W_to_VR()}.\t\n\t\\end{itemize}\n\\end{itemize}\n\n\\subsection{Understanding the output}\nBoth the similarity-centric analogous bars and feature-centric analogous bars method return the dictionary outputs that result from running the appropriate extension methods. We thus direct the reader to sections 1.2 and 1.3 of this documentation. \n\n%========================================================================\n\\section{To-do list for future versions}\n\\begin{itemize}\n\\item Generalize the persistent extension and analogous bars method from dimension 1 to higher dimensions. In particular, for the feature-centric analogous bars method, we'll have to implement Dowker's Theorem in higher dimensions. \n\\item Address speed and memory issues: \n\t\\begin{itemize}\n\t\\item Creating the Witness complex and running the extension method can take a long time. Is there a way to speed up this process? Maybe via distributed computation?\n\t\\item When creating the Witness complex, we create a dictionary to keep track of all simplices and their indices. Is there a way to avoid creating dictionaries while keeping track of the simplices and their indices?\n\t\\item Current implementation for exploring alternative bar extensions runs into memory issues if the auxiliary barcode or the target barcode has too many bars. Can we resolve this issue?\t\n\t\\end{itemize}\n\\item Implement ``lazy\" extension. Before running any of the persistent extension or analogous bars method, assume that the user selects bars of ``significant\" length as bars that can participate in the bar extension. The resulting bar extensions must be a subset of the pre-selected bars. Implement the lazy extension and analogous bars method.\n\\end{itemize}\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "e64f5fd15a23db87ed248d9051fd30ffe5216e95", "size": 20127, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "code_details/code_details.tex", "max_stars_repo_name": "UDATG/analogous_bars", "max_stars_repo_head_hexsha": "40b7bfcc2cbec3babe1de16b4bd291b3c228539c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-23T01:47:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T01:47:08.000Z", "max_issues_repo_path": "code_details/code_details.tex", "max_issues_repo_name": "UDATG/analogous_bars", "max_issues_repo_head_hexsha": "40b7bfcc2cbec3babe1de16b4bd291b3c228539c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code_details/code_details.tex", "max_forks_repo_name": "UDATG/analogous_bars", "max_forks_repo_head_hexsha": "40b7bfcc2cbec3babe1de16b4bd291b3c228539c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 82.8271604938, "max_line_length": 606, "alphanum_fraction": 0.722362995, "num_tokens": 5717, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4348205012545579}}
{"text": "\\documentclass{amsart}\n\\usepackage{style/preamble}\n\\usepackage{parskip}\n\\begin{document}\n\\section*{Classification of surfaces}\n\n\\begin{theorem}\n  Every compact Riemann surface is homeomorphic(=topologically isomorphic) to a surface of genus $g$.\n  \\begin{figure}[H]\n    \\centering \\includegraphics[width=0.85\\linewidth]{images/GegusGSurfaces}\n    \\caption{Torus, genus 2 surface, higher genus surfaces}\n  \\end{figure}\n  Upto isomorphism, there is exactly one Riemann surface of genus 0, namely the Riemann sphere $\\bbp^1$.\n\\end{theorem}\n\nThe genus can be thought of as the number of ``handles'' in the surface.\n\n\\textbf{Word of caution:} Two Riemann surfaces being homeomorphic does not mean that they are isomorphic as Riemann surfaces.\nWe will show that every elliptic curve is homeomorphic to the genus 1 surface (=torus) but not all elliptic curves are isomorphic to each other as Riemann surfaces.\n\n\n\n\n\n\n\n\n\\section*{Euler characteristic}\n  It is possible to compute the genus using triangulations of surfaces.\n  For any triangulation of a genus $g$ surface $M$ with $V$ vertices, $E$ edges, and $F$ faces, we have the following identity:\n  \\begin{align*}\n    2 - 2g = V - E + F.\n  \\end{align*}\n  The important point here is that the right-hand side depends on the triangulation but the left-hand side does not. The right-hand is called the Euler characteristic of $M$, denoted $\\chi(M)$.\n\n  \\begin{figure}[H]\n  \\centering\n    % \\includegraphics[width=0.5\\textwidth]{example-image}\n    \\includegraphics[width=0.45\\textwidth]{images/SphereTriangulation.jpg}\n    \\caption{Triangulation of $S^2$ (genus=0) with $V = 4$, $E=6$, and $F = 4$ so that $V - E + F = 2 = 2 - 2 \\cdot 0$.}\n  \\end{figure}\n\n\n\n\n\n\n  \\section*{Coverings of simply-connected spaces}\n\n  A topological space $Y$ is said to be \\emph{simply-connected} if it is connected and every loop in $Y$ can be continuously contracted to a point.\n\n  \\begin{figure}[H]\n  \\centering\n    % \\includegraphics[width=0.5\\textwidth]{example-image}\n    \\includegraphics[width=0.9\\textwidth]{images/S2isSimplyConnected.jpg}\n  \\end{figure}\n\n\n  For example, the Riemann sphere $\\bbp^1$ is simply-connected. If we remove a single point or a single path-connected set from $\\bbp^1$, the resulting space is still simply-connected.\n\n  But if $Y$ is the space obtained by removing two or more points from the Riemann sphere, then $Y$ is not simply-connected.\n\n  This is the only example that concerns us.\n\n  \\begin{theorem}\n    If $f: X \\rightarrow Y$ is a continuous $n:1$ (covering) map and $Y$ is simply-connected then $X$ is topologically isomorphic to $n$ disjoint copies of $Y$.\n  \\end{theorem}\n  For this theorem we do not allow any ramification points, so $f$ needs to a genuine $n:1$ (covering) map.\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "18554218c7291a873c5937e67bbfb40c55d076e8", "size": 2769, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TopologyTheorems.tex", "max_stars_repo_name": "apurvnakade/mc2019-Riemann-surfaces", "max_stars_repo_head_hexsha": "edebdd1c81027b9cedb264eba1eeaa09dd4e311f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TopologyTheorems.tex", "max_issues_repo_name": "apurvnakade/mc2019-Riemann-surfaces", "max_issues_repo_head_hexsha": "edebdd1c81027b9cedb264eba1eeaa09dd4e311f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TopologyTheorems.tex", "max_forks_repo_name": "apurvnakade/mc2019-Riemann-surfaces", "max_forks_repo_head_hexsha": "edebdd1c81027b9cedb264eba1eeaa09dd4e311f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.961038961, "max_line_length": 193, "alphanum_fraction": 0.7284218129, "num_tokens": 792, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.434820492437544}}
{"text": "\\title{Generative Adversarial Networks}\n\n\\subsection{Generative Adversarial Networks}\n\nGenerative adversarial networks (GANs) are a powerful approach for\nprobabilistic modeling \\citep{goodfellow2014generative,goodfellow2016nips}.\nThey posit a deep generative model and they enable fast and accurate\ninferences.\n\nWe demonstrate with an example in Edward.\nAn interactive version with Jupyter notebook is available\n\\href{http://nbviewer.jupyter.org/github/blei-lab/edward/blob/master/notebooks/gan.ipynb}{here}.\n\n\\begin{lstlisting}[language=Python]\nM = 128  # batch size during training\nd = 100  # latent dimension\n\nDATA_DIR = \"data/mnist\"\nIMG_DIR = \"img\"\n\\end{lstlisting}\n\n\\subsubsection{Data}\n\nWe use training data from MNIST, which consists of 55,000 $28\\times\n28$ pixel images \\citep{lecun1998gradient}. Each image is represented\nas a flattened vector of 784 elements, and each element is a pixel\nintensity between 0 and 1.\n\n\\includegraphics[width=450px]{/images/gan-fig0.png}\n\nThe goal is to build and infer a model that can generate high quality\nimages of handwritten digits.\n\nDuring training we will feed batches of MNIST digits. We instantiate a\nTensorFlow placeholder with a fixed batch size of $M$ images.\n\n\\begin{lstlisting}[language=Python]\nfrom tensorflow.examples.tutorials.mnist import input_data\n\nmnist = input_data.read_data_sets(DATA_DIR)\nx_ph = tf.placeholder(tf.float32, [M, 784])\n\\end{lstlisting}\n\n\n\\subsubsection{Model}\n\nGANs posit generative models using an implicit mechanism. Given some\nrandom noise, the data is assumed to be generated by a deterministic\nfunction of that noise.\n\nFormally, the generative process is\n\\begin{align*}\n\\mathbf{\\epsilon} &\\sim p(\\mathbf{\\epsilon}), \\\\\n\\mathbf{x} &= G(\\mathbf{\\epsilon}; \\theta),\n\\end{align*}\nwhere $G(\\cdot; \\theta)$ is a neural network that takes the samples\n$\\mathbf{\\epsilon}$ as input. The distribution\n$p(\\mathbf{\\epsilon})$ is interpreted as random noise injected to\nproduce stochasticity in a physical system; it is typically a fixed\nuniform or normal distribution with some latent dimensionality.\n\nIn Edward, we build the model as follows, using TensorFlow Slim to\nspecify the neural network. It defines a 2-layer fully connected neural\nnetwork and outputs a vector of length $28\\times28$ with values in\n$[0,1]$.\n\n\\begin{lstlisting}[language=Python]\nfrom edward.models import Uniform\nfrom tensorflow.contrib import slim\n\ndef generative_network(eps):\n  h1 = slim.fully_connected(eps, 128, activation_fn=tf.nn.relu)\n  x = slim.fully_connected(h1, 784, activation_fn=tf.sigmoid)\n  return x\n\nwith tf.variable_scope(\"Gen\"):\n  eps = Uniform(tf.zeros([M, d]) - 1.0, tf.ones([M, d]))\n  x = generative_network(eps)\n\\end{lstlisting}\n\nWe aim to estimate parameters of the generative network such\nthat the model best captures the data. (Note in GANs, we are\ninterested only in parameter estimation and not inference about any\nlatent variables.)\n\nUnfortunately, probability models described above do not admit a tractable\nlikelihood. This poses a problem for most inference algorithms, as\nthey usually require taking the model's density.  Thus we are\nmotivated to use ``likelihood-free'' algorithms\n\\citep{marin2012approximate}, a class of methods which assume one\ncan only sample from the model.\n\n\\subsubsection{Inference}\n\nA key idea in likelihood-free methods is to learn by\ncomparison (e.g., \\citet{rubin1984bayesianly,gretton2012kernel}): by\nanalyzing the discrepancy between samples from the model and samples\nfrom the true data distribution, we have information on where the\nmodel can be improved in order to generate better samples.\n\nIn GANs, a neural network $D(\\cdot;\\phi)$ makes this comparison,\nknown as the discriminator.\n$D(\\cdot;\\phi)$ takes data $\\mathbf{x}$ as input (either\ngenerations from the model or data points from the data set), and it\ncalculates the probability that $\\mathbf{x}$ came from the true data.\n\nIn Edward, we use the following discriminative network. It is simply a\nfeedforward network with one ReLU hidden layer. It returns the\nprobability in the logit (unconstrained) scale.\n\n\\begin{lstlisting}[language=Python]\ndef discriminative_network(x):\n  h1 = slim.fully_connected(x, 128, activation_fn=tf.nn.relu)\n  logit = slim.fully_connected(h1, 1, activation_fn=None)\n  return logit\n\\end{lstlisting}\n\nLet $p^*(\\mathbf{x})$ represent the true data distribution.\nThe optimization problem used in GANs is\n\n\\begin{equation*}\n\\min_\\theta \\max_\\phi~\n\\mathbb{E}_{p^*(\\mathbf{x})} [ \\log D(\\mathbf{x}; \\phi) ]\n+ \\mathbb{E}_{p(\\mathbf{x}; \\theta)} [ \\log (1 - D(\\mathbf{x}; \\phi)) ].\n\\end{equation*}\n\nThis optimization problem is bilevel: it requires a minima solution\nwith respect to generative parameters and a maxima solution with\nrespect to discriminative parameters.\nIn practice, the algorithm proceeds by iterating gradient updates on\neach. An additional heuristic also modifies the objective function for the\ngenerative model in order to avoid saturation of gradients\n\\citep{goodfellow2014on}.\n\nMany sources of intuition exist behind GAN-style training. One, which\nis the original motivation, is based on idea that the two neural\nnetworks are playing a game. The discriminator tries to best\ndistinguish samples away from the generator. The generator tries\nto produce samples that are indistinguishable by the discriminator.\nThe goal of training is to reach a Nash equilibrium.\n\nAnother source is the idea of casting unsupervised learning as\nsupervised learning\n\\citep{gutmann2010noise,gutmann2014statistical}.\nThis allows one to leverage the power of classification—a problem that\nin recent years is (relatively speaking) very easy.\n\nA third comes from classical statistics, where the discriminator is\ninterpreted as a proxy of the density ratio between the true data\ndistribution and the model\n\\citep{sugiyama2012density,mohamed2016learning}. By augmenting an\noriginal problem that may require the model's density with a\ndiscriminator (such as maximum likelihood), one can recover the\noriginal problem when the discriminator is optimal. Furthermore, this\napproximation is very fast, and it justifies GANs from the perspective\nof approximate inference.\n\nIn Edward, the GAN algorithm (\\texttt{GANInference}) simply takes the\nimplicit density model on \\texttt{x} as input, binded to its\nrealizations \\texttt{x_ph}. In addition, a parameterized function\n\\texttt{discriminator} is provided to distinguish their\nsamples.\n\n\\begin{lstlisting}[language=Python]\ninference = ed.GANInference(\n    data={x: x_ph}, discriminator=discriminative_network)\n\\end{lstlisting}\n\nWe'll use ADAM as optimizers for both the generator and discriminator.\nWe'll run the algorithm for 15,000 iterations and print progress every\n1,000 iterations.\n\n\\begin{lstlisting}[language=Python]\noptimizer = tf.train.AdamOptimizer()\noptimizer_d = tf.train.AdamOptimizer()\n\ninference.initialize(\n    optimizer=optimizer, optimizer_d=optimizer_d,\n    n_iter=15000, n_print=1000)\n\\end{lstlisting}\n\nWe now form the main loop which trains the GAN. At each iteration, it\ntakes a minibatch and updates the parameters according to the\nalgorithm. At every 1000 iterations, it will print progress and also\nsaves a figure of generated samples from the model.\n\n\\begin{lstlisting}[language=Python]\nsess = ed.get_session()\ntf.global_variables_initializer().run()\n\nidx = np.random.randint(M, size=16)\ni = 0\nfor t in range(inference.n_iter):\n  if t % inference.n_print == 0:\n    samples = sess.run(x)\n    samples = samples[idx, ]\n\n    fig = plot(samples)\n    plt.savefig(os.path.join(IMG_DIR, '{}.png').format(\n        str(i).zfill(3)), bbox_inches='tight')\n    plt.close(fig)\n    i += 1\n\n  x_batch, _ = mnist.train.next_batch(M)\n  info_dict = inference.update(feed_dict={x_ph: x_batch})\n  inference.print_progress(info_dict)\n\\end{lstlisting}\n\nExamining convergence of the GAN objective can be meaningless in\npractice. The algorithm is usually run until some other criterion is\nsatisfied, such as if the samples look visually okay, or if the GAN\ncan capture meaningful parts of the data.\n\n\\subsubsection{Criticism}\n\nEvaluation of GANs remains an open problem---both in criticizing their\nfit to data and in assessing convergence.\nRecent advances have considered alternative objectives and\nheuristics to stabilize training (see also Soumith Chintala's\n\\href{https://github.com/soumith/ganhacks}{GAN hacks repo}).\n\nAs one approach to criticize the model, we simply look at generated\nimages during training. Below we show generations after 14,000\niterations (that is, 14,000 gradient updates of both the generator and\nthe discriminator).\n\n\\includegraphics[width=500px]{/images/gan-fig1.png}\n\nThe images are meaningful albeit a little blurry. Suggestions for\nfurther improvements would be to tune the hyperparameters in the\noptimization, to improve the capacity of the discriminative and\ngenerative networks, and to leverage more prior information (such as\nconvolutional architectures).\n\n\\subsubsection{References}\\label{references}\n", "meta": {"hexsha": "518d08b260cc9f76ee713b36806bb284604eab9f", "size": 8966, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/tex/tutorials/gan.tex", "max_stars_repo_name": "NunoEdgarGFlowHub/edward", "max_stars_repo_head_hexsha": "298fb539261c71e34d5e7aa5a37ed8a029df0820", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-11T03:33:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-11T03:33:36.000Z", "max_issues_repo_path": "docs/tex/tutorials/gan.tex", "max_issues_repo_name": "NunoEdgarGFlowHub/edward", "max_issues_repo_head_hexsha": "298fb539261c71e34d5e7aa5a37ed8a029df0820", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/tex/tutorials/gan.tex", "max_forks_repo_name": "NunoEdgarGFlowHub/edward", "max_forks_repo_head_hexsha": "298fb539261c71e34d5e7aa5a37ed8a029df0820", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-13T06:58:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-13T06:58:00.000Z", "avg_line_length": 37.9915254237, "max_line_length": 96, "alphanum_fraction": 0.7855230872, "num_tokens": 2201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266734, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4348204918473684}}
{"text": "\\documentclass{article}\n\n\\usepackage{defaults}\n\\usepackage[exp]{macros}\n\\usepackage[caption, title, reference]{document_style}\n\n\\usepackage{txfonts}\n\n\\begin{document}\n\n\\section{Section}%\n\\label{sec:section}\n\n1\\supscr{st} 2\\subscr{eme}\n\n\\raggedright{}\n\\textit{i.e.}  \\textit{e.g.} \\textit{etc.} \\textit{viz.} \\textit{et al.}\n\\textit{vice versa}\\par\n\\textit{i.e.}\\  \\textit{e.g.}\\ \\textit{etc.}\\ \\textit{viz.}\\ \\textit{et al.}\\\n\\textit{vice versa}\\par\n\\ie{}\\ \\eg{}\\ \\etc{}\\ \\viz{}\\ \\etal{}\\ \\vive{}\n\n$\\dif{x}$ $\\diff{y}{x}$ $\\pdif{x}$ $\\pdiff{y}{x}$\n\n$\\vec{a}$ $\\unit{b}$ $\\norm{\\vec{c}}$\n\n$\\trans{\\vec{M}}$\n\n\\begin{equation}\n  \\e{- \\beta k_{\\mathrm{B}} T}\n  \\label{eq:boltzmann}\n\\end{equation}\n\nA famous statistical mechanics expression \\cref{eq:boltzmann}\n\n$\\epsilon$ $\\varepsilon$\n\n$\\phi$ $\\varphi$\n\n\\cref{sec:section}\n\n\\section{Another Section}\n\n\\end{document}\n", "meta": {"hexsha": "78f3d4c7ede29003397f67a96fbfd5248a5929b3", "size": 863, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples/document/example.tex", "max_stars_repo_name": "JimMadge/TeX_style", "max_stars_repo_head_hexsha": "c3f05d87e40ef07ca9a8f1ffd17e9eb515cfc16b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/document/example.tex", "max_issues_repo_name": "JimMadge/TeX_style", "max_issues_repo_head_hexsha": "c3f05d87e40ef07ca9a8f1ffd17e9eb515cfc16b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/document/example.tex", "max_forks_repo_name": "JimMadge/TeX_style", "max_forks_repo_head_hexsha": "c3f05d87e40ef07ca9a8f1ffd17e9eb515cfc16b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.1777777778, "max_line_length": 77, "alphanum_fraction": 0.6488991889, "num_tokens": 329, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.43482047891693554}}
{"text": "\\mainsection{Advanced Protocols}\nThis section details the protocols needed to perform complex\nfunctionalities on LSSS style secret shared values in MAMBA.\nAs well as the documentation here further, details can be\nfound at \n\\begin{center}\n   \\verb+$(HOME)/Documentation/Compiler_Documentation/index.html+\n\\end{center}\nunder the heading \\verb+Files+.\n\nThe protocols break the ``arithmetic circuit'' model of computation,\nas they make heavy use of pre-processed data and the ability\nto $\\Open$ shared values.\nIn particular we assume three lists of pre-processed data:\n\\[ \\MList, \\quad \\SList, \\quad \\BList. \\]\nAn entry on the $\\MList$ is of the form \n$(\\sshare{a}, \\sshare{b}, \\sshare{c})$ where $c=a \\cdot b \\pmod{p}$,\nan entry on the $\\SList$ is of the form\n$(\\sshare{a}, \\sshare{b})$ where $b=a^2 \\pmod{p}$,\nwhilst an entry on the $\\BList$ is of the form\n$\\sshare{b}$ where $b \\in \\{0,1\\}$.\nWe also assume a function $\\Random()$ which can generate\na random secret sharing (this can be implemented by just taking\nthe first element from a multiplication triple).\nWe add and multiply secret shared elements in what follows\nusing the notation \n\\[ \\sshare{a+b} \\asn \\sshare{a}+\\sshare{b}, \\quad\n   \\sshare{a\\cdot b} \\asn \\sshare{a} \\cdot \\sshare{b}.\n\\]\n\nThe protocols in this chapter allow us to do more advanced operations,\nwithout resorting to using full blown arithmetic circuits.\nWe describe here what we have implemented as a form of\ndocumentation, both for us and for others. \nMany of the protocol ideas can be found in the five\ndocuments\n\\begin{itemize}\n\\item Unconditionally Secure Constant-Rounds\nMulti-party Computation for Equality, Comparison, Bits and Exponentiation.\n{\\em TCC 2006}, \\cite{DFKNT06}.\n\\item Improved Primitives for Secure Multiparty Integer Computation.\n{\\em SCN 2010}, \\cite{CH10}.\n\\item D9.2 of the EU project {\\em secureSCM}, \\cite{SSCM}.\n\\item Secure Computation with Fixed-Point Numbers {\\em FC 2010} \\cite{CS10}.\n\\item Secure Computation on Floating Point Numbers {\\em NDSS 2013} \\cite{ABZS13}.\n\\end{itemize}\nMany of the protocols operating on integers make use of a statistical security \nparameter $\\kappa$.\nIf the integer being operated on is $k$ bits long, then we often require $(k+\\kappa)<\\log_2 p$.\nFor ease of implementation of the protocols we recommend $k$ is\nalways a power of two, and we assume this in the write up below.\nIf this is not the case, obvious tweaks can be made to the protocols.\n\nDue to experience with the SPDZ system we prefer logarithmic\nround protocols over constant round protocols, it appears that in\npractice the logarithmic round protocols outperform the constant\nround ones.\nThe MAMBA compiler can execute non-constant round protocols, by \nflicking a compile time switch. But here we only document\nlogarithmic round protocols.\n\n\\msubsection{Basic Protocols}\n\n\\msubsubsection{$\\mathsf{Inv}(\\sshare{x})$:}\nThis produces a share $\\sshare{z}$ of $1/x \\pmod{p}$, with an\n$\\abort$ if $x=0$.\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn \\Random()$.\n\\item $\\sshare{y} \\asn \\sshare{a} \\cdot \\sshare{x}$.\n\\item $y \\asn \\Open(\\sshare{y})$.\n\\item If $y=0$ then $\\abort$.\n\\item $t \\asn 1/y \\pmod{p}$.\n\\item $\\sshare{z} \\asn t \\cdot \\sshare{a}$.\n\\item Return $\\sshare{z}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the inverse of a \\verb|sint| or a \\verb|cint| can be done as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\nd = sint(5)\nd_inv =  floatingpoint.Inv(d)\nprint_ln(\"inverse is correct if 1: %s\", (d*d_inv).reveal())\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{Ran}_p^*()$:}\nThis produces a random sharing of a value $x$ and its inverse $1/x$.\nThis is faster than generating $x$, and then performing the above operaton.\n\\begin{enumerate}\n\\item Take a triple $(\\sshare{a},\\sshare{b},\\sshare{c})$ from $\\MList$.\n\\item $c \\asn \\Open(\\sshare{c})$.\n\\item If $c=0$ then return to the first step.\n\\item $\\sshare{a^{-1}} \\asn c^{-1} \\cdot \\sshare{b}$.\n\\item Output $(\\sshare{a},\\sshare{a^{-1}})$.\n\\end{enumerate}\nThis function does not exist ``as is'' in the MAMBA language, as it\nis used in place within the python compiler. Thus it is only here\nfor documentation reasons.\n\n\\msubsubsection{$\\mathsf{PreMult}(\\sshare{a_1},\\ldots,\\sshare{a_t},T)$:}\nThis computes the prefix multiplication, i.e. the values \n\\[ \\sshare{a_{i_0,i_1}} = \\bsshare{\\prod_{i=i_0}^{i_1} a_i} \\]\nwhere $(i_0,i_1) \\in T$ and $1 \\le i_0 \\le i_1 \\le t$.\n\\begin{enumerate}\n\\item For $i \\in [0,\\ldots,t]$ do.\n\\begin{enumerate}\n  \\item $(\\sshare{b_i},\\sshare{b_i^{-1}}) \\asn \\mathsf{Ran}_p^*()$.\n\\end{enumerate}\n\\item For $i \\in [0,\\ldots,t]$ do.\n\\begin{enumerate}\n  \\item $\\sshare{t} \\asn \\sshare{b_{i-1}} \\cdot \\sshare{a_i}$.\n  \\item $\\sshare{d_i} \\asn \\sshare{t} \\cdot \\sshare{b_i^{-1}}$.\n  \\item $d_i \\asn \\Open(\\sshare{d_i})$.\n\\end{enumerate}\n\\item For $(i_0,i_1) \\in T$ \n\\begin{enumerate}\n   \\item $d_{i_0,i_1} \\asn \\prod_{i=i_0}^{i_1} d_i$.\n   \\item $\\sshare{a_{i_0,i_1}} \\asn d_{i_0,i_1} \\cdot\n\t   \t\\sshare{b_{i_0-1}^{-1}} \\cdot \\sshare{b_{i_1}}$.\n\\end{enumerate}\n\\end{enumerate}\nAgain, this function does not exist ``as is'' in the MAMBA language, as it\nis used in place within the python compiler. Thus it is only here\nfor documentation reasons.\n\n\n\n\\msubsection{Bit Oriented Operations}\nThese operations refer exclusively to how to perform bit oriented operations on top of \n$\\modp$ data-types. It is not related to the \\verb|sbit| type.\n\n\\msubsubsection{$\\mathsf{OR}(\\sshare{a},\\sshare{b})$:}\nThis computes the logical OR of two input shared bits:\n\\begin{enumerate}\n\\item Return $\\sshare{a}+\\sshare{b}-\\sshare{a} \\cdot \\sshare{b}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the \\verb|or| of two \\verb|sint| or \\verb|cint| numbers you can: \n\\begin{lstlisting}[language={python}]\na= sint(1)\nb= sint(0)\nprint_ln(\"or is correct if 1: %s\", (a or b).reveal())\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{XOR}(\\sshare{a},\\sshare{b})$:}\nThis computes the logical XOR of two input shared bits:\n\\begin{enumerate}\n\\item Return $\\sshare{a}+\\sshare{b}-2 \\cdot \\sshare{a} \\cdot \\sshare{b}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the \\verb|xor| of two \\verb|sint| or \\verb|cint| numbers you can: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na= sint(1)\nb= sint(0)\nprint_ln(\"or is correct if 1: %s\", floatingpoint.xor_op(a, b).reveal())\n\\end{lstlisting}\n\n\\iffalse\n\\note{Nigel}{Does not seem to be used anywhere}\n\\msubsubsection{$\\mathsf{Symm}(f,\\sshare{a_1},\\ldots,\\sshare{a_t})$:}\nThis takes a symmetric boolean function $f$ on $t$ binary inputs\nand evaluates it at the points $\\sshare{a_1},\\ldots,\\sshare{a_t}$,\nwhere we assume $a_i \\in \\{0,1\\}$.\nWe first pre-process the function $f$ so that we can write\n\\[ f(x_1,\\ldots,x_t) = \\phi(1+\\sum_{i=1}^t x_i), \\]\nwhere the inner sum is over the integers and\n$\\phi:{1,2,\\ldots,t+1} \\longrightarrow \\{0,1\\}$.\nWe then write\n\\[ \\phi(X) = \\sum_{i=0}^t \\alpha_i \\cdot X^i \\pmod{p} \\]\nusing Lagrange interpolation.\nSo for example if we have $f(X_1,X_2)=X_1^2+X_1 \\cdot X_2+X_2^2+1$\nthen $\\phi$ is the function which maps \n$1 \\longrightarrow 1$, $2 \\longrightarrow 0$, $3 \\longrightarrow 0$.\nIn which case $\\phi(X)=X^2/2-5 \\cdot X/2+3$.\n\nTo compute this function we have the algorithm\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn 1+ \\sum_{i=1}^t \\sshare{a_i}$.\n\\item $(\\sshare{a},\\sshare{a^2},\\ldots,\\sshare{a^t})\n\t\\asn \\mathsf{PreMult}(\\sshare{a},\\ldots,\\sshare{a},\n\t\t\t\\{(1,1),\\ldots,(1,t)\\})$.\n\\item $\\sshare{f(a_1,\\ldots,a_t)}\n\t\\asn \\sum_{i=0}^t \\alpha_i \\cdot \\sshare{a^i}$.\n\\end{enumerate}\n\\fi\n\n\\msubsubsection{$\\mathsf{KOp}(\\odot,\\sshare{a_1},\\ldots,\\sshare{a_k},k)$:}\nThis computes the operation $\\sshare{p}= \\bigodot_{i=1}^k \\sshare{a_i}$\ngiven a binary operator $\\odot$.\n\\begin{enumerate}\n\\item If $k>1$ then\n\\begin{enumerate}\n  \\item For $i \\in [1,\\ldots,k/2]$ do\n  \\begin{enumerate}\n     \\item $\\sshare{u_i} \\asn \\sshare{a_{2\\cdot i}} \\odot \\sshare{a_{2 \\cdot i-1}}$.\n  \\end{enumerate}\n  \\item $\\sshare{p} \\asn \\mathsf{KOp}(\\odot, \\sshare{u_{k/2}},\\ldots,\\sshare{u_1},k/2)$.\n\\end{enumerate}\n\\item Else\n\\begin{enumerate}\n   \\item $\\sshare{p} \\asn \\sshare{a_1}$.\n\\end{enumerate}\n\\item Return $\\sshare{p}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} Note that we basically want to achieve a construction capable to call any function in an iterative fashion reducing computation time. In this sense a call to the function could be perform in the following way: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\n\n# addition\ndef addition(a, b):\n    return a + b\n    \nar=[1]*16\n# (k is exctracted from ar directly on the implementation)\nprint_ln(\"KOpL is correct if 32: %s\", (floatingpoint.KOpL(func,ar)).reveal())\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{PreOp}(\\odot,\\sshare{a_1},\\ldots,\\sshare{a_k},k)$:}\nThis computes the prefix operator $\\sshare{p_j} = \\odot_{i=1}^j \\sshare{a_i}$,\nfor $1 \\le j \\le k$.\n\\begin{enumerate}\n\\item For $i \\in [1,\\ldots, \\log_2 k]$ do\n\\begin{enumerate}\n  \\item For $j \\in [1,\\ldots,k/2^i]$ do\n  \\begin{enumerate}\n     \\item $y \\asn 2^{i-1}+j\\cdot 2^i$.\n     \\item For $z \\in [1,\\ldots,2^{i-1}]$ do\n     \\begin{enumerate}\n\t\\item $\\sshare{a_{y+z}} \\asn \\sshare{a_y} \\odot \\sshare{a_{y+z}}$.\n     \\end{enumerate}\n  \\end{enumerate}\n\\end{enumerate}\n\\item Return $(\\sshare{a_1},\\ldots,\\sshare{a_k})$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} Similarly, we basically want to achieve a construction capable to call any function in an iterative fashion reducing computation time. In this case, however, we return all the list of intermediate values. The function call could be performed in the following way: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\n\ndef addition(a, b):\n    return a + b\n\ndef addition_triple(a, b, c):\n\t# c is a boolean parameter\n    return a + b\n    \ne = sint(2)\n\nar = [e]*16\n# k is stracted from ar.\nprint_ln(\"PreOpL is correct if 32: %s\", (floatingpoint.PreOpL(addition_triple,ar))[15].reveal())\nprint_ln(\"PreOpN is correct if 32: %s\", (floatingpoint.PreOpN(addition,ar))[15].reveal())\n\\end{lstlisting}\nNote that both methods are implementations of the functionality with slightly different  communication and round complexity.\nWith the \\verb+PreOpL+ function corresponding to the pseudo-code above.\n\n\\msubsubsection{$\\mathsf{Solved\\mhyphen Bits}(BitsList, k)$:}\nThis outputs a shared integer $x$ in the range\n$[0,\\ldots,2^k)$ with $2^k<p$ and the shared bits\nmaking up its binary representation.\n\\begin{enumerate}\n\\item Take $k$ shares $\\{\\sshare{x_i}\\}_{i=0}^{k-1}$ from $\\BList$.\n\\item $\\sshare{x} \\asn \\sum_{i=0}^{k-1} 2^i \\cdot \\sshare{x_i}$.\n\\item Output $(\\sshare{x}, \\{\\sshare{x_i}\\}_{i=0}^{k-1})$.\n\\end{enumerate}\nTo ease notation in what follows we write\n$\\sshare{x}_B = \\{\\sshare{x_i}\\}_{i=0}^{k-1}$.\n\n\\paragraph{MAMBA Example:}  We can reconstruct a number from its bits as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = [sint(0)]*program.bit_length\n# k is taken from a\nprint_ln(\"solved_bits is correct if 0: %s\", floatingpoint.SolvedBits(a, program.bit_length).reveal())\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{PRandM}(k,m,\\kappa)$:}\nThis generates two random shares $r' \\in [0,\\ldots,2^{k+\\kappa-m}-1]$\nand $r \\in [0,\\ldots,2^m-1]$, along with the shares the bits of $r$.\n\\begin{enumerate}\n\\item $\\sshare{r}, \\sshare{r}_B \\asn \\mathsf{Solved\\mhyphen Bits}(m)$.\n\\item $\\sshare{r'}, \\sshare{r'}_B \\asn \\mathsf{Solved\\mhyphen Bits}(k+\\kappa-m)$.\n\\item Return $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:}  We obtain the randomness and its bits as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n\n# x, y,z are returned values\nx = sint()\ny = sint()\nz = [sint() for i in range(3)]\n\n# k, m, kappa are parameters\nk = 5\nm = 3\nkappa = 7\ncomparison.PRandM(x, y, z, k, m, kappa)\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{CarryOut}(\\sshare{a}_B,\\sshare{b}_B,k)$:}\nThis protocol computes the carry-out of a binary addition of\ntwo $k$ bit shared values, when presented via shared bits.\nThe protocol can easily be adapted to the case when either\nthe bits of $a$, or the bits of $b$, are given in the clear.\nWe give a logarithmic round version, which requires $\\log k$\nrounds of interaction.\nIt requires a sub-routine $\\mathsf{CarryOutAux}$ which we\ngive below.\n\\begin{enumerate}\n\\item For $i \\in [0,\\ldots,k-1]$ do\n\\begin{enumerate}\n\\item $\\sshare{d_i}_B \\asn (\\mathsf{XOR}(\\sshare{a_i},\\sshare{b_i}),\n\t                    \\sshare{a_i}\\cdot \\sshare{b_i})$.\n      [Note, $\\sshare{d_i}_B$ is a set of two shared bits, one being the XOR\n      of $a_i$ and $b_i$, whilst the other the AND].\n\\end{enumerate}\n\\item $\\sshare{d}_B \\asn \\mathsf{CarryOutAux}(\\sshare{d_{k-1}}_B,\\ldots,\\sshare{d_0}_B,k)$.\n\\item $(\\sshare{p},\\sshare{g}) \\asn \\sshare{d}_B$.\n\\item Return $\\sshare{g}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:}  The carry out operation is executed as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n\nres = sint() # last carry bit in addition of a and b\na = [cint(i) for i in [1,0]] # array of clear bits\nb = [sint(i) for i in [0,1]] # array of secret bits (same length as a)\nc = 0 # initial carry-in bit\nkappa = 16\ncomparison.CarryOut(res, a, b, c, 16)\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{CarryOutAux}(\\sshare{d_k}_B,\\ldots,\\sshare{d_1}_B,k, \\kappa)$:}\nThis function uses the $\\circ$ operator for carry propagation on two\nbit inputs which is defined as\n\\[  \\circ:  \\left\\{ \\begin{array}{ccc}\n\t\t\t\\{0,1\\}^2 \\times \\{0,1\\}^2 & \\longrightarrow & \\{0,1\\} \\\\\n\t\t\t(p_2,g_2) \\circ (p_1,g_1) & \\longmapsto &\n\t\t\t (p_1 \\wedge p_2, g_2 \\vee (p_2 \\wedge g_1))\n\t\t     \\end{array} \\right.\n\\]\nThis is computed using arithmetic operations (i.e. where the values are\nheld as bits modulo $p$) as $(p,g) = (p_2,g_2) \\circ (p_1,g_1)$ via\n\\begin{align*}\n\tp &= p_1 \\cdot p_2, \\\\\n\tg &= g_2 + p_2 \\cdot g_1.\n\\end{align*}\nGiven this operation the function $\\mathsf{CarryOutAux}$ is defined by,\nwhich is just a specialisation of the protocol $\\mathsf{KOp}$ above,\n\\begin{enumerate}\n\\item If $k>1$ then\n\\begin{enumerate}\n  \\item For $i \\in [1,\\ldots,k/2]$ do\n  \\begin{enumerate}\n     \\item $\\sshare{u_i}_B \\asn \\sshare{d_{2\\cdot i}}_B \\circ \\sshare{d_{2 \\cdot i-1}}_B$.\n  \\end{enumerate}\n  \\item $\\sshare{d}_B \\asn \\mathsf{CarryOutAux}(\\sshare{u_{k/2}}_B,\\ldots,\\sshare{u_1}_B,k/2)$.\n\\end{enumerate}\n\\item Else\n\\begin{enumerate}\n   \\item $\\sshare{d}_B \\asn \\sshare{d_1}_B$.\n\\end{enumerate}\n\\item Return $\\sshare{d}_B$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} This method is thought as a subroutine for \\verb|CarryOut| and should not be used outside that context. the code is invoked in the following way: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n# this is how it is invoked, where res, is the return, and 16 is the kappa\n# k can be extracted from the array size\ncomparison.CarryOutAux(res, [::d -1], 16)\n# it could be interpreted as follows when called:\nkappa = 16\nx = [cint(i) for i in [1,0]]\nres = sint()\ncomparison.CarryOut(z, x, 16)\n\\end{lstlisting}\n\n\\iffalse\n\\note{Nigel}{Does not seem to be used anywhere}\n\\msubsubsection{$\\mathsf{CarryOutCIn}(\\sshare{a}_B,\\sshare{b}_B,c,k)$:}\nA minor tweak allows us to also input a {\\em clear} carry-in\nbit into the $\\mathsf{CarryOut}$ function.\n\\begin{enumerate}\n\\item For $i \\in [0,\\ldots,k-1]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{d_i}_B \\asn (\\mathsf{XOR}(\\sshare{a_i}, \\sshare{b_i}),\n\t                    \\sshare{a_i}\\cdot \\sshare{b_i})$.\n\\end{enumerate}\n\\item $\\sshare{g_0} \\asn \\sshare{g_0}+c \\cdot\\sshare{p_0}$ [Where $\\sshare{d_0}_B=(\\sshare{p_0},\\sshare{g_0})$].\n\\item $\\sshare{d}_B \\asn \\mathsf{CarryOutAux}(\\sshare{d_{k-1}}_B,\\ldots,\\sshare{d_0}_B,k)$.\n\\item $(\\sshare{p},\\sshare{g}) \\asn \\sshare{d}_B$.\n\\item Return $\\sshare{g}$.\n\\end{enumerate}\n\\fi\n\n\\msubsubsection{$\\mathsf{BitAdd}((\\sshare{a_{k-1}},\\ldots,\\sshare{a_0}), (\\sshare{b_{k-1}},\\ldots,\\sshare{b_0}),k)$:}\nThis function also makes use of the operator $\\circ$.\nThe inputs are shared bits. The case where one set of inputs is in the clear\nis obviously more simple, and we do not detail this here.\n\\begin{enumerate}\n\\item For $i \\in [0,\\ldots,k-1]$ do\n\\begin{enumerate}\n\\item $\\sshare{d_i}_B \\asn (\\mathsf{XOR}(\\sshare{a_i}, \\sshare{b_i}),\n\t                    \\sshare{a_i}\\cdot \\sshare{b_i})$.\n\\end{enumerate}\n\\item $\\sshare{c_{k-1},t_{k-1}},\\ldots,\\sshare{c_0,t_0}  \\asn \\mathsf{PreOp}(\\circ,\\sshare{d_{k-1}}_B,\\ldots,\\sshare{d_0}_B,k)$.\n\\item $\\sshare{s_0} \\asn \\mathsf{XOR}(\\sshare{a_0}, \\sshare{a_1})$.\n\\item For $i \\in [1,\\ldots,k-1]$ do\n\\begin{enumerate}\n  \\item $\\sshare{s_i} \\asn \\sshare{a_i}+\\sshare{b_i}+\\sshare{c_{i-1}}-2\\cdot \\sshare{c_i}$.\n\\end{enumerate}\n\\item $\\sshare{s_k} \\asn \\sshare{c_{k-1}}$.\n\\item Return $(\\sshare{s_k},\\ldots,\\sshare{s_0})$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} The addition of two numbers expressed in bits, can be performed as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na_bits = [sint(i) for i in [0,1,0,1,1]]\nb_bits = [sint(i) for i in [0,1,0,1,1]]\n# k can be extracted from the array size\nb = floatingpoint.BitAdd(a_bits, b_bits)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{BitLT}(a,\\sshare{b}_B,k)$:}\nThis computes the sharing of the bit $a<b$, where $a$ is a public value.\nBoth $a$ and $b$ are assumed to be $k$ bit values, with\n$a=\\sum_{i=0}^{k-1} a_i \\cdot 2^i$ and \n$b=\\sum_{i=0}^{k-1} b_i \\cdot 2^i$.\n\\begin{enumerate}\n\\item For $i \\in [0,\\ldots,k-1]$\n\\begin{enumerate}\n   \\item $\\sshare{b_i'}\\asn 1-\\sshare{b_i}$.\n\\end{enumerate}\n\\item $\\sshare{s} \\asn 1- \n\t\\mathsf{CarryOut}((a_{k-1},\\ldots,a_0),\\sshare{b}_B)$.\n\\item Return $\\sshare{s}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} Comparing an open register with a secret shared number decomposed in bits can be achieved as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\nx = cint(5)\ny = [sint(i) for i in [1,0,1]]\nz = sint()\nkappa = 16\n# k can be extracted from the array size\n# in this case the bit that is the answer is contained in z\ncomparison.BitLTL(z, x, y, kappa)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{BitDec}(\\sshare{a},k,m)$:}\nThis outputs the $m$ least significant bits in the $2$'s complement\nrepresentation of $a \\in \\Zk$.\n\\begin{enumerate}\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,m,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^k+2^{k+\\kappa}-\\sshare{r}-2^m \\cdot \\sshare{r'})$.\n\\item $(\\sshare{a_{m-1}},\\ldots,\\sshare{a_0}) \\asn \n\t\\mathsf{BitAdd}(c,(\\sshare{r_{m-1}},\\ldots,\\sshare{r_0}))$.\n\\item Return $(\\sshare{a_{m-1}},\\ldots,\\sshare{a_0})$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} A secret shared value can be decomposed into bits as shown in the following snippet: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\na = sint(23)\nk = 5\nm = 5\nkappa = 20\n# where b is bit array of type sint\nb = floatingpoint.BitDec(a, k, m, kappa)\n\\end{lstlisting}\n\n\\msubsection{Arithmetic with Signed Integers}\nIn this section we define basic arithmetic on signed integers.\nWe define $\\Zk$ as the set of integers $\\{x \\in \\Z: -2^{k-1} \\le x \\le 2^{k-1}-1\\}$,\nwhich we embed into $\\F_p$ via the map $x \\mapsto x \\pmod{p}$.\n\n\\msubsubsection{$\\mathsf{TruncPR}(\\sshare{a},k,m, \\kappa)$:}\nAn approximate truncation algorithm which is faster than \na fully accurate Trunc. \nGiven $a \\in \\Zk$, $m \\in [1,\\ldots,k-1]$\nthis outputs $\\floor{a/2^m}+u$ where $u$ is a random\n(and unknown) bit.\nIt gives the actual correct nearest integer with\nprobability $1-\\alpha$, where $\\alpha$ is the distance\nbetween $a/2^m$ and that integer.\n\\begin{enumerate}\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,m,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^{k-1}+\\sshare{r}+2^m \\cdot \\sshare{r'})$.\n\\item $c'\\asn c \\pmod{2^m}$.\n\\item $t \\asn 1/2^m \\pmod{p}$.\n\\item $\\sshare{d} \\asn t \\cdot (\\sshare{a}-c'+\\sshare{r})$.\n\\item Return $\\sshare{d}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} A secret shared fractional register can be approximately truncated as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = sint(23)\nk = 5\nm = 3\nkappa = 20\n# where b is a register of type sint\nb=floatingpoint.TruncPr(a, k, m, kappa)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{Mod2m}(\\sshare{a_{prime}}, \\sshare{a},k,m, \\kappa, signed)$:}\nGiven $a \\in \\Zk$, $m \\in [1,\\ldots,k-1]$ this outputs $a \\pmod{2^m}$.\nUse this protocol when $m>1$, for $m=1$ use $\\mathsf{Mod2}$ below.\n\\begin{enumerate}\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,m,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^{k-1}+\\sshare{r}+2^m \\cdot \\sshare{r'})$.\n\\item $c'\\asn c \\pmod{2^m}$.\n\\item $\\sshare{u} \\asn \\mathsf{BitLT}(c',(\\sshare{r_{m-1}},\\ldots,\\sshare{r_0}),m)$.\n\\item $\\sshare{a'} \\asn c'-\\sshare{r}+2^m \\cdot \\sshare{u}$.\n\\item Return $\\sshare{a'}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} The \\verb|mod| to a power of $2$ of a secret shared integer register can be obtain as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n\na_prime = sint(0) # a % 2 ^ m\na = sint(100)\nk = 16 # bit length of a\nm = 2 # modulo of 2^m\nkappa = 8 \nsigned = True # True/False\n\n# where a is a register of type sint\nr_dprime, r_prime, c, c_prime, u, t, c2k1 = \\\n    comparison.Mod2m(a_prime, a, k, m, kappa, signed)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{Trunc}(\\sshare{a},k,m, kappa)$:}\nAn exact version of $\\mathsf{Trunc}$ above\n\\begin{enumerate}\n\\item $\\sshare{a'} \\asn \\mathsf{Mod2m}(\\sshare{a},k,m, \\kappa)$.\n\\item $t \\asn 1/2^m \\pmod{p}$.\n\\item $\\sshare{d} \\asn t \\cdot (\\sshare{a}-\\sshare{a'})$.\n\\item Return $\\sshare{d}$.\n\\end{enumerate}\nBelow we will give a version of $\\mathsf{Trunc}$ in which $m$ is kept secret shared.\n\\paragraph{MAMBA Example:} You truncate a number as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\n# a = sint(23)\n# k = 5\n# m = 3 \n# kappa = 20\n# where a is a register of type sint\na= floatingpoint.Trunc(a, k, m, kappa)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{Mod2}(\\sshare{a},k, \\kappa, signed)$:}\n\\begin{enumerate}\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r_0} \\asn \\mathsf{PRandM}(k,1,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^{k-1}+\\sshare{r}+2 \\cdot \\sshare{r'})$.\n\\item $\\sshare{a_0} \\asn c_0+\\sshare{r_0}-2 \\cdot c_0 \\cdot \\sshare{r_0}$.\n\\item Return $\\sshare{a_0}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} You obtain the modulo two of a number as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n\na = sint(1)\na_0 = sint()\nk = 1\nkappa = 8\nsigned = False \n# y stores the result of X % 2\ncomparison.Mod2(a_0, A, k, kappa, signed)\n\\end{lstlisting}\n\n\\iffalse\n\\note{Nigel}{Does not seem to be used anywhere}\n\\msubsubsection{$\\mathsf{Mod}(\\sshare{a},k,x)$:}\nGiven $a \\in \\Zk$ and public $x \\in [1,\\ldots,2^{k-1}-1]$\nthis computes $\\sshare{a \\pmod{x}}$.\n\\begin{enumerate}\n\\item $m \\asn \\ceil{\\log_2 x }$.\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,m,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^{k-1}+\\sshare{r}+x \\cdot \\sshare{r'})$.\n\\item $c' \\asn c \\pmod{x}$.\n\\item $\\sshare{v} \\asn 1 -\\mathsf{BitLT}(\\sshare{r}_B,x)$.\n\\item $\\sshare{u} \\asn \\mathsf{LTZ}(c' - \\sshare{r} + x \\cdot \\sshare{v},m)$.\n\\item $\\sshare{a'} \\asn c' - \\sshare{r} + x \\cdot ( \\sshare{v}+\\sshare{u})$.\n\\item Return $\\sshare{a'}$.\n\\end{enumerate}\n\\fi\n\n\\msubsubsection{$\\mathsf{LTZ}(\\sshare{a},k, \\kappa)$:}\nGiven $a \\in \\Zk$ this tests whether $a<0$ or not,\nresulting in a shared bit.\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn - \\mathsf{Trunc}(\\sshare{a},k,k-1)$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} You determine whether a number is less than zero as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\na = sint(1)\nb = sint()\nk=80\nkappa=40\n# b stores the result of x < 0\ncomparison.LTZ(b, a, k, kappa)\n\\end{lstlisting}\nLike many commands in this section this can be abbreviated to\n\\begin{lstlisting}[language={python}]\nb=a<0\n\\end{lstlisting}\nIn which case the default value of $\\kappa=40$ is chosen\n(when using a $128$-bit prime modulus), this default value can be \naltered by using the command\n\\begin{lstlisting}[language={python}]\nprogram.security = 100\n\\end{lstlisting}\nThe default value of $k=64$ is used in this setting, and\nthis can be altered by executing\n\\begin{lstlisting}[language={python}]\nprogram.bit_length = 40\n\\end{lstlisting}\nThe requirement is that $k+\\kappa$ must be less than the bit length\nof the prime $p$.\n\n\n\\msubsubsection{$\\mathsf{EQZ}(\\sshare{a},k, \\kappa)$:}\nGiven $a \\in \\Zk$ this tests whether $a=0$ or not,\nresulting in a shared bit.\n\\begin{enumerate}\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,k,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{a}+2^{k-1}+2^k \\cdot \\sshare{r'}+\\sshare{r})$.\n\\item Let $c_{k-1},\\ldots,c_0$ be the bits of $c$.\n\\item For $i \\in [0,\\ldots,k-1]$ do\n\\begin{enumerate}\n   \\item $\\sshare{d_i} \\asn c_i+\\sshare{r_i}-2 \\cdot c_i \\cdot \\sshare{r_i}$.\n\\end{enumerate}\n\\item $\\sshare{z} \\asn 1- \\mathsf{KOp}(\\mathsf{OR},\\sshare{d_{k-1}},\\ldots,\\sshare{d_0},k)$.\n\\item Return $\\sshare{z}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} You determine whether a number is equal to zero as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = sint(1)\nb = sint()\nk = 80\nkappa = 40\n# b stores the result of x == 0\nfloatingpoint.EQZ(b, a, k, kappa)\n\\end{lstlisting}\n\n\n\\msubsubsection{Comparison Operators:}\nWe can now define the basic comparison operators on shared\nrepresentations from $\\Zk$.\n\\begin{center}\n\\begin{tabular}{|lll|}\n\\hline\nOperator & Protocol Name & Construction \\\\\n\\hline\n$a>0$    & $\\mathsf{GTZ(\\sshare{a})}$           & $\\mathsf{LTZ}(-\\sshare{a})$ \\\\\n$a\\le0$  & $\\mathsf{LEZ(\\sshare{a})}$           & $1-\\mathsf{LTZ}(-\\sshare{a})$ \\\\\n$a\\ge0$  & $\\mathsf{GEZ(\\sshare{a})}$           & $1-\\mathsf{LTZ}(\\sshare{a})$ \\\\\n$a=b$    & $\\mathsf{EQ(\\sshare{a},\\sshare{b})}$ & $\\mathsf{EQZ}(\\sshare{a}-\\sshare{b})$ \\\\\n$a<b$    & $\\mathsf{LT(\\sshare{a,\\sshare{b}})}$ & $\\mathsf{LTZ}(\\sshare{a}-\\sshare{b})$ \\\\\n$a>b$    & $\\mathsf{GT(\\sshare{a,\\sshare{b}})}$ & $\\mathsf{LTZ}(\\sshare{b}-\\sshare{a})$ \\\\\n$a\\le b$ & $\\mathsf{LE(\\sshare{a,\\sshare{b}})}$ & $1-\\mathsf{LTZ}(\\sshare{b}-\\sshare{a})$ \\\\\n$a\\ge b$ & $\\mathsf{GE(\\sshare{a,\\sshare{b}})}$ & $1-\\mathsf{LTZ}(\\sshare{a}-\\sshare{b})$ \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\\msubsubsection{Addition, Multiplication in $\\Zk$}\nAddition and multiplication $\\odot$ of two elements $\\sshare{a}, \\sshare{b}$\nto obtain $\\sshare{c}$, where $a,b,c \\in \\Zk$ is then easy to define \nby performing \n\\begin{enumerate}\n\\item $\\sshare{d} \\asn \\sshare{a} \\odot \\sshare{b}$.\n\\item $\\sshare{c} \\asn \\mathsf{Mod2m}(\\sshare{d},k',k)$,\n\twhere $k'=k+1$ is $\\odot=+$ and $k'=2\\cdot k$ if $\\odot=\\cdot$.\n\\item Return $\\sshare{c}$.\n\\end{enumerate}\nThese functions are not directly callable from MAMBA, they are\nincluded here purely for documentation reasons.\n\n\\msubsubsection{$\\mathsf{Pow2}(\\sshare{a},k, \\kappa)$:}\nThis computes $\\sshare{2^a}$ where $a \\in [0,\\ldots,k)$\n\\begin{enumerate}\n\\item $m \\asn \\ceil{\\log_2 k}$.\n\\item $\\sshare{a_{m-1}},\\ldots,\\sshare{a_0} \\asn \\mathsf{BitDec}(\\sshare{a},m,m)$.\n\\item For $i\\in [0,\\ldots,m-1]$ do \n\\begin{enumerate}\n  \\item $\\sshare{v_i} \\asn 2^{2^i} \\cdot \\sshare{a_i}+1-\\sshare{a_i}$.\n\\end{enumerate}\n\\item $\\sshare{x_0},\\ldots,\\sshare{x_{m-1}}\n\t\\asn \\ \\mathsf{PreMult}(\\sshare{v_0},\\ldots,\\sshare{v_{m-1}}, \\{(1,1),\\ldots,(1,m)\\})$\n\\item Return $\\sshare{x_{m-1}}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} You can obtain the value of two raised to a secret shared number as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = sint(23)\nl = 32\nkappa = 20\n# y stores the result of 2^23\ny =floatingpoint.Pow2(a, l, kappa)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{B2U}(\\sshare{a},k, \\kappa)$:}\nThis converts the integer $a \\in [0,\\ldots,k)$ into unary form.\nIt outputs $k$ bits, of which the last $a$ bits are zero to one,\nwith the others set to zero.\n\\begin{enumerate}\n\\item $\\sshare{2^a} \\asn \\mathsf{Pow2}(\\sshare{a},k)$.\n\\item $\\sshare{r'}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,k,\\kappa)$.\n\\item $c \\asn \\Open(\\sshare{2^a}+\\sshare{r}+2^k \\cdot \\sshare{r'})$.\n\\item Let $c_{k-1},\\ldots,c_0$ be the bits of $c$.\n\\item For $i \\in [0,\\ldots,k=1]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{x_i} \\asn c_i+\\sshare{r_i}-2 \\cdot c_i \\cdot \\sshare{r_i}$.\n\\end{enumerate}\n\\item $\\sshare{y_{k-1}},\\ldots,\\sshare{y_0} \\asn \\mathsf{PreOp}(\\mathsf{OR},\\sshare{x_{k-1}},\\ldots,\\sshare{x_0},k)$.\n\\item For $i \\in [0,\\ldots,k=1]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{a_i} \\asn 1-\\sshare{y_i}$.\n\\end{enumerate}\n\\item Return $\\sshare{a_0},\\ldots,\\sshare{a_{k-1}}$.\n\\end{enumerate}\nNote, in the function $\\mathsf{Trunc}$ below we also require the\nvalue $\\sshare{2^a}$ to be returned so as to avoid recomputing it.\n\n\\paragraph{MAMBA Example:} You can transform a number into its unary form as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = sint(3)\nl=5\nkappa=20\nb,c = floatingpoint.B2U(a, l, kappa)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{Trunc}(\\sshare{a},k,\\sshare{m}, \\kappa)$:}\nThis does the same operation as $\\mathsf{Trunc}$ above, but $m$ is now secret shared.\n\\begin{enumerate}\n\\item $\\sshare{x_0},\\ldots,\\sshare{x_{k-1}}, \\sshare{2^m} \\asn \\mathsf{B2U}(\\sshare{m},k)$.\n\\item $\\sshare{2^{-m}} \\asn \\mathsf{Inv}(\\sshare{2^m})$.\n\\item $\\sshare{r''}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,k,\\kappa)$.\n\\item $\\sshare{r'} \\asn \\sum_{i=0}^{k-1} 2^i \\cdot \\sshare{x_i} \\cdot \\sshare{r_i}$\n\\item $c \\asn \\Open(\\sshare{a}+\\sshare{r''}+\\sshare{r})$.\n\\item For $i \\in [1,\\ldots,k=1]$ do $c_i' \\asn c \\pmod{2^i}$.\n\\item $\\sshare{c''} \\asn \\sum_{i=1}^{k-1} c_i' \\cdot (\\sshare{x_{i-1}}-\\sshare{x_i})$.\n\\item $\\sshare{d} \\asn \\mathsf{LT}(\\sshare{c''},\\sshare{r'},k)$.\n\\item $\\sshare{b} \\asn (\\sshare{a}-\\sshare{c''}+\\sshare{r'}) \\cdot \\sshare{2^{-m}} - \\sshare{d}$.\n\\item Return $\\sshare{b}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} You truncate a number as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\na = sint(23)\nk = 5\nm = sint(3)\nkappa = 20\n# where a is a register of type sint\nb= floatingpoint.Trunc(a, k, m, kappa)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{Mod2m}(a_{prime}, \\sshare{a},k,\\sshare{m}, \\kappa)$:}\nThis does the same operation as $\\mathsf{Mod2m}$ above, but $m$ is now secret shared.\n\\begin{enumerate}\n\\item $\\sshare{x_0},\\ldots,\\sshare{x_{k-1}}, \\sshare{2^m} \\asn \\mathsf{B2U}(\\sshare{m},k)$.\n\\item $\\sshare{2^{-m}} \\asn \\mathsf{Inv}(\\sshare{2^m})$.\n\\item $\\sshare{r''}, \\sshare{r}, \\sshare{r}_B \\asn \\mathsf{PRandM}(k,k,\\kappa)$.\n\\item $\\sshare{r'} \\asn \\sum_{i=0}^{k-1} 2^i \\cdot \\sshare{x_i} \\cdot \\sshare{r_i}$\n\\item $c \\asn \\Open(\\sshare{a}+\\sshare{r''}+\\sshare{r})$.\n\\item For $i \\in [1,\\ldots,k=1]$ do $c_i' \\asn c \\pmod{2^i}$.\n\\item $\\sshare{c''} \\asn \\sum_{i=1}^{k-1} c_i' \\cdot (\\sshare{x_{i-1}}-\\sshare{x_i})$.\n\\item $\\sshare{d} \\asn \\mathsf{LT}(\\sshare{c''},\\sshare{r'},k)$.\n\\item $\\sshare{b} \\asn \\sshare{c''}-\\sshare{r'}+\\sshare{2^m} \\cdot \\sshare{d}$.\n\\item Return $\\sshare{b}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} The \\verb|mod| to a secret shared power of $2$ of a secret shared integer register can be obtain as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import comparison\n\na_prime = param_a_prime # a % 2^m\na sint(2137)\nk = 16\nm = sint(2)\nkappa = 8  \nsigned = True # True/False, describes a\n\n# where sb is a register of type sint\nr_dprime, r_prime, c, c_prime, u, t, c2k1 = \\\n    comparison.Mod2m(a_prime, a, k, m, kappa, signed)\n\\end{lstlisting}\n\n\n\\msubsection{Arithmetic with Fixed Point Numbers}\nIn this section we define basic arithmetic on fixed\npoint numbers.\nWe mainly follow the algorithms given in \n\\begin{itemize}\n\\item Secure Computation with Fixed-Point Numbers {\\em FC 2010} \\cite{CS10}.\n\\end{itemize}\nWe define $\\Qk{f}$ as the set of rational numbers\n$\\{x \\in \\Q: x = \\overline{x} \\cdot 2^{-f}, \\overline{x} \\in \\Zk\\}$.\nWe represent $x \\in \\Q$ as the integer $x \\cdot 2^f = \\overline{x} \\in \\Zk$,\nwhich is then represented in $\\F_p$ via the mapping used above.\nThus $x \\in \\Q$ is in the range $[-2^e,2^e-2^{-f}]$\nwhere $e=k-f$.\nAs we are working with fixed point numbers we assume that the\nparameters $f$ and $k$ are public.\nFor our following algorithms to work (in particular fixed point\nmultiplication and division) we require that $q>2^{2 \\cdot k}$.\nBy abuse of notation we write $\\sshare{a}$ to mean $\\sshare{\\overline{a}}$,\ni.e. the secret sharing of the fixed point number $a$,\nis actually the secret sharing of the integer representative\n$\\overline{a}$.\n\n\\msubsubsection{$\\mathsf{Scale}(\\sshare{a},k,f_1,f_2)$:}\nSometimes we want to scale the input fixed point number $a$\nfrom $\\Qk{f_1}$ to $\\Qk{f_2}$.\n\\begin{enumerate}\n\\item $m \\asn f_2-f_1$.\n\\item If $m\\ge 0$ then $\\sshare{a'} \\asn 2^m \\cdot \\sshare{a}$.\n\\item Else $\\sshare{a'} \\asn \\mathsf{TruncPR}(\\sshare{a},k,-m)$.\n\\item Return $\\sshare{a'}$.\n\\end{enumerate}\nThis is not directly callable from MAMBA it is here purely\nfor documentation reasons.\n\n\\msubsubsection{$\\mathsf{FxEQZ}, \\mathsf{FxLTZ}, \\mathsf{FxEQ}, \\mathsf{FxLT}$, etc:}\nAll of the comparison operators for integers given above carry\nover to fixed point numbers (if the inputs have the same $f$-values).\n\n\\msubsubsection{$\\mathsf{FxAbs}(\\sshare{a},k,f)$}\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn \\mathsf{LTZ}(\\sshare{a})$.\n\\item $\\sshare{a} \\asn (1-2\\cdot \\sshare{s}) \\cdot \\sshare{a}$.\n\\item Return $\\sshare{a}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the absolute value of a number as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nb = -1.5\nsb = sfix(b)\n\n# k and f are extracted from b\n# returns unsigned b and receives signed b\nub = mpc_math.abs_fx(sb)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{FxNeg}(\\sshare{a},k,f)$}\n\\begin{enumerate}\n\\item Return $-\\sshare{a}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the original value times $-1$ as follows: \n\\begin{lstlisting}[language={python}]\nb = -1.5\nsb = sfix(b)\n# k and f are extracted from b\n# returns the value of signed b times -1.\nnb = -sb\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{FxAdd}(\\sshare{a},\\sshare{b},k,f)$:}\nGiven $a, b \\in \\Qk{f}$ this is just the integer addition algorithm for elements\nin $\\Zk$ given above\n\\begin{enumerate}\n\\item $\\sshare{c} \\asn \\sshare{a} + \\sshare{b}$.\n\\item Return $\\sshare{c}$.\n\\end{enumerate}\nObviously from $\\mathsf{FxNeg}$ and $\\mathsf{FxAdd}$ we can define $\\mathsf{FxSub}$.\nNote that, if the sum overflows then the resulting value will be\ninvalid.\n\\paragraph{MAMBA Example:} To obtain the addition of two fixed point secret shared values you can do as follows:\n\\begin{lstlisting}[language={python}]\na = sfix(3.5)\nb = sfix(1.5)\n# k and f are extracted from b or a\n#returns secret shared 5\na_plus_b = a+b\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{FxMult}(\\sshare{a},\\sshare{b},k,f)$:}\nGiven $a, b \\in \\Qk{f}$ this requires integer multiplication followed\nby a suitable truncation.\n\\begin{enumerate}\n\\item $\\sshare{d} \\asn \\sshare{a} \\cdot \\sshare{b}$.\n\\item $\\sshare{c} \\asn \\mathsf{TrunkPR}(\\sshare{d},2 \\cdot k,f)$.\n\\item Return $\\sshare{c}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the multiplication of two fixed point secret shared values you can do as follows:\n\\begin{lstlisting}[language={python}]\na = sfix(3.5)\nb = sfix(1.5)\n# k and f are extracted from b or a\n#returns secret shared 5.25\na_mult_b = a*b\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{FxDiv}(\\sshare{a},b,k,f)$:}\nWe first give division for when $a, b \\in \\Qk{f}$ and $b$ is in the clear.\n\\begin{enumerate}\n\\item Compute $x \\in \\Qk{f}$ such that $x \\approx 1/b$.\n\\item $\\sshare{y} \\asn \\mathsf{TruncPR}(\\overline{x} \\cdot \\sshare{a},k,f)$.\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To divide two fixed point values (where only one is secret shared) you can do as follows:\n\\begin{lstlisting}[language={python}]\na = sfix(3.5)\nb = 1.5\n# k and f are extracted from b\n#returns secret shared 2.333333\na_div_b = a/b\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{FxDiv}(\\sshare{a},\\sshare{b},k,f)$:}\nThis operation is more complex and we use method of Goldschmidt, which\nis recommended by Catrina et. al.\nThe following routine makes use of the two subroutines which follow\n\\begin{enumerate}\n\\item $\\theta \\asn \\ceil{\\log_2 (k/3.5)}$. \n\\item $\\overline{\\alpha} \\asn 2^{2 \\cdot f}$. \n\tNote that $\\overline{\\alpha}$ is the integer representative of $1.0$ in $\\Qk{2\\cdot f}$.\n\\item $\\sshare{w} \\asn \\mathsf{AppRcr}(\\sshare{b},k,f)$.\n\\item $\\sshare{x} \\asn \\overline{\\alpha} - \\sshare{b}\\cdot \\sshare{w}$.\n\\item $\\sshare{y} \\asn \\sshare{a}\\cdot \\sshare{w}$.\n\\item $\\sshare{y} \\asn \\mathsf{TruncPr}(\\sshare{y},2\\cdot k,f)$.\n\\item For $i \\in [1,\\ldots,\\theta-1]$ do\n\\begin{enumerate}\n  \\item $\\sshare{y} \\asn \\sshare{y} \\cdot (\\overline{\\alpha}+\\sshare{x})$.\n  \\item $\\sshare{x} \\asn \\sshare{x}^2$.\n  \\item $\\sshare{y} \\asn \\mathsf{TruncPr}(\\sshare{y},2\\cdot k,2 \\cdot f)$.\n  \\item $\\sshare{x} \\asn \\mathsf{TruncPr}(\\sshare{x},2\\cdot k,2 \\cdot f)$.\n\\end{enumerate}\n\\item $\\sshare{y} \\asn \\sshare{y} \\cdot (\\overline{\\alpha}+\\sshare{x})$.\n\\item $\\sshare{y} \\asn \\mathsf{TruncPr}(\\sshare{y},2\\cdot k,2 \\cdot f)$.\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the division of two fixed point values that are secret shared, you can do as follows:\n\\begin{lstlisting}[language={python}]\na = sfix(3.5)\nb = 1.5\n# k and f are extracted from b\n#returns secret shared 2.333333\na_div_b = a/b\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{AppRcr}(\\sshare{b},k,f)$:}\n\\begin{enumerate}\n\\item $\\overline{\\alpha} \\asn 2.9142 \\cdot 2^k$.\n\tNote that $\\overline{\\alpha}$ is the integer representative of $2.9142$ in $\\Qk{f}$.\n\\item $(\\sshare{c},\\sshare{v}) \\asn \\mathsf{Norm}(\\sshare{b},k,f)$.\n\\item $\\sshare{d} \\asn \\overline{\\alpha} - 2 \\cdot \\sshare{c}$.\n\\item $\\sshare{w} \\asn \\sshare{d} \\cdot \\sshare{v}$.\n\\item $\\sshare{w} \\asn \\mathsf{TruncPR}(\\sshare{w},2 \\cdot k,2 \\cdot (k-f))$.\n\\item Return $\\sshare{w}$.\n\\end{enumerate}\nThis is not callable from MAMBA, it is here purely for documentation reasons.\n\n\\msubsubsection{$\\mathsf{MSB}(\\sshare{b},k):$}\nReturns index array $\\sshare{z}$ of size $k$, such that it holds a $1$ in the position of the most significative bit of $\\sshare{b}$ and $\\sshare{0}$ otherwise. This function is used internally on \\verb|NormSQ| and \\verb|SimplifiedNormSQ|.\n\\begin{enumerate}\n\n\\item $\\sshare{s} \\asn 1-2 \\cdot \\mathsf{LTZ}(\\sshare{b},k)$.\n\\item $\\sshare{x} \\asn \\sshare{s} \\cdot \\sshare{b}$.\n\\item $\\sshare{x_{k-1}},\\ldots,\\sshare{x_0} \\asn \\mathsf{BitDec}(\\sshare{x},k,k)$.\n\\item $\\sshare{y_{k-1}},\\ldots,\\sshare{y_0} \\asn \\mathsf{PreOp}(\\mathsf{OR},\\sshare{x_{k-1}},\\ldots,\\sshare{x_0},k)$.\n\\item For $i \\in [0,\\ldots,k-1]$ do \n\\item $z \\asn (\\sshare(0_{1}),...,\\sshare(0_{k + 1 - k \\quad \\% \\quad 2}))$\n\\begin{enumerate}\n  \\item $\\sshare{z_i} \\asn \\sshare{y_i}-\\sshare{y_{i+1}}$.\n\\end{enumerate}\n\\item $\\sshare{z_{k-1}} \\asn \\sshare{y_{k-1}}$.\n\\item Return $\\sshare{z}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{Norm}(\\sshare{b},k,f):$}\nThis returns the value $c$ such that $2^{k-1} \\le c <2^k$\nand $v'$ such that $b \\cdot v' = c$,\nand if $2^{m-1} \\le |b| <2^m$ then $v'= \\pm 2^{k-m}$.\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn 1-2 \\cdot \\mathsf{LTZ}(\\sshare{b},k)$.\n\\item $\\sshare{x} \\asn \\sshare{s} \\cdot \\sshare{b}$.\n\\item $\\sshare{x_{k-1}},\\ldots,\\sshare{x_0} \\asn \\mathsf{BitDec}(\\sshare{x},k,k)$.\n\\item $\\sshare{y_{k-1}},\\ldots,\\sshare{y_0} \\asn \\mathsf{PreOp}(\\mathsf{OR},\\sshare{x_{k-1}},\\ldots,\\sshare{x_0},k)$.\n\\item For $i \\in [0,\\ldots,k-2]$ do \n\\begin{enumerate}\n  \\item $\\sshare{z_i} \\asn \\sshare{y_i}-\\sshare{y_{i+1}}$.\n\\end{enumerate}\n\\item $\\sshare{z_{k-1}} \\asn \\sshare{y_{k-1}}$.\n\\item $\\sshare{v} \\asn \\sum_{i=0}^{k-1} 2^{k-i-1} \\cdot \\sshare{z_i}$.\n\\item $\\sshare{c} \\asn \\sshare{x} \\cdot \\sshare{v}$.\n\\item $\\sshare{v'} \\asn \\sshare{s} \\cdot \\sshare{v}$.\n\\item Return $(\\sshare{c}, \\sshare{v'})$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To obtain the norm of a secret shared fix point register you can do as follows:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import library\nkappa = 40 \nb = sfix(1.5)\n#returns the norm\n c, v = library.Norm(b, b.k, b.f, kappa, True)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{NormSQ}(\\sshare{b},k):$}\nAs above, but now we assume $b \\ge 0$, and we also\noutput shares of $m$ and $w$ such that $w=2^{m/2}$\nif $m$ is even and $2^{(m-1)/2}$ if $m$ is odd. Furthermore $v = 2^{k-m}$. Note that we have introduced some adaptations from the original paper:\n\\begin{enumerate}\n\\item $z \\asn \\mathsf{MSB}(\\sshare{b},k,f)$.\n\\item $\\sshare{v} \\asn \\sum_{i=0}^{k-1} 2^{k-i-1} \\cdot \\sshare{z_i}$.\n\\item $\\sshare{c} \\asn \\sshare{b} \\cdot \\sshare{v}$.\n\\item $\\sshare{m} \\asn \\sum_{i=0}^{k-1} (i+1) \\cdot \\sshare{z_i}$. \n%z[2 * i - 1-(1 -k%2)] + z[2 * i- (1 -k%2)]\n\\item For $i \\in [1,\\ldots,k/2]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{w_i}=\\sshare{z_{2\\cdot i-1}}+\\sshare{z_{2\\cdot i}}$.\n\\end{enumerate}\n\\item $\\sshare{w_0} \\asn 0$. \n\\item $\\sshare{w} \\asn \\sum_{i=0}^{k/2} 2^i \\cdot \\sshare{w_i}$.\n\\item Return $\\sshare{c}, \\sshare{v}, \\sshare{m}, \\sshare{w}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{SimplifiedNormSQ}(\\sshare{b},k):$}\nSame as above, but in this case we only return $m$, and $w$, together with a $\\{0,1\\}$ bit signaling whether m is odd. \n\n\\begin{enumerate}\n\\item $z \\asn \\mathsf{MSB}(\\sshare{b},k,f)$.\n\n\\item $\\sshare{m} \\asn \\sum_{i=0}^{k-1} (i+1) \\cdot \\sshare{z_i}$. \n\\item For $i \\in [0,\\ldots,k-1]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{m}=\\sshare{m}+ (i+1) +\\sshare{z_{i}}$.\n\t\\item If $(i \\quad \\% \\quad 2 == 0)$:\n\t\\begin{enumerate}\n\t    \\item $\\sshare{m_{odd}} \\asn m_{odd} + \\sshare{z_{i}}$\n\t\\end{enumerate}\n\\end{enumerate}\n%z[2 * i - 1-(1 -k%2)] + z[2 * i- (1 -k%2)]\n\\item For $i \\in [1,\\ldots,k/2]$ do\n\\begin{enumerate}\n\t\\item $\\sshare{w_i}=\\sshare{z_{2\\cdot i-1}}+\\sshare{z_{2\\cdot i}}$.\n\\end{enumerate}\n\\item $\\sshare{w_0} \\asn 0$. \n\\item $\\sshare{w} \\asn \\sum_{i=0}^{k/2} 2^i \\cdot \\sshare{w_i}$.\n\n\\item Return $\\sshare{m_{odd}}, \\sshare{m}, \\sshare{w}$.\n\\end{enumerate}\n\n\n\\msubsection{Arithmetic with Floating Point Numbers}\n\nFor floating point numbers we utilize the methods described in\n\\begin{itemize}\n\\item Secure Computation on Floating Point Numbers {\\em NDSS 2013} \\cite{ABZS13}.\n\\end{itemize}\nHowever we make explicit use of an error flag which we carry throughout\na computation, as detailed in previous sections.\nThe processing of overflow and underflow detection is expensive,\nand thus we enable the user to turn this off via\nmeans of a compile time flag \\verb+fdflag+ by passing the option \n\\verb+-f+ or \\verb+--fdflag+ when using \\verb|compile.py|.\nThis can also be turned on/off within a program by assigning\nto the variable \\verb+program.fdflag+.\nThe error flag is still needed however to catch other forms of errors\nin computations (such as division by zero, taking square roots of\nnegative numbers etc). \nThus setting \\verb+fdflag+ equal to $\\false$\ndoes not necessarily result in $\\err$ always equaling zero.\n\nFloating point numbers are defined by two global, public integer parameters\n$(\\ell,k)$ which define the size of the mantissa and the exponent respectively.\nEach floating point number is represented as a five tuple $(v,p,z,s,\\err)$, where\n\\begin{itemize}\n\\item $v \\in [2^{\\ell-1},2^\\ell)$ is an $\\ell$-bit significand with it's most\nmost bit always set to one.\n\\item $p \\in \\Zk$ is the signed exponent.\n\\item $z$ is a bit to define whether the number is zero or not.\n\\item $s$ is a sign bit (equal to zero if non-negative).\n\\item $\\err$ is the error flag (equal to zero if no error has occurred, it holds a non-zero value otherwise).\n\\end{itemize}\nThus assuming $\\err=0$ this tuple represents the value\n\\[ u=(1- 2 \\cdot s) \\cdot (1-z) \\cdot v \\cdot 2^p. \\]\nWe adopt the conventions that when $u=0$ we also have $z=1, v=0$ and $p=0$,\nand when $\\err=1$ then the values of $v,p,z$ and $s$ are meaningless.\n\nThe standard arithmetic operations of addition, multiplication and\ncomparison are then implemented in MAMBA for this datetype using\noperator overloading. The precise algorithms which are executed\nare detailed below.\n\n\\msubsubsection{$\\mathsf{FlowDetect}(\\sshare{p})$:}\n\\begin{enumerate}\n\\item If $\\mathsf{fdflag}$ then\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn -2 \\cdot (\\sshare {p} < 0) + 1$.\n%\\item $\\sshare{of} \\asn \\mathsf{GT}(\\sshare{p},2^{k-1}-1,k+1)$.\n%\\item $\\sshare{uf} \\asn \\mathsf{LT}(\\sshare{p},-2^{k-1}-1,k+1)$.\n\\item $\\sshare{\\err} \\asn \\mathsf{GT}(\\sshare{p} \\cdot \\sshare{s},2^{k-1}-1,k+1)$. \n%\\sshare{of} + \\sshare{uf}.\n\\end{enumerate}\n\\item Return $\\sshare{\\err}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLNeg}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn 1-\\sshare{s}$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLAbs}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn 0$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$\n\\end{enumerate}\nObviously from $\\mathsf{FLNeg}$ and $\\mathsf{FLAdd}$ we can define $\\mathsf{FLSub}$.\n\n\\msubsubsection{$\\mathsf{FLMult}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\nFor floating point operations multiplication is much easier than addition, so we deal with \nthis first.\n\\begin{enumerate}\n\\item $\\sshare{v} \\asn \\sshare{v_1} \\cdot \\sshare{v_2}$.\n\\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{v},2 \\cdot \\ell, \\ell-1)$.\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\sshare{v},2^\\ell,\\ell+1)$.\n\\item $\\sshare{v'} \\asn \\sshare{v}+\\sshare{b} \\cdot \\sshare{v}$.\n\\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{v'}, \\ell+1, 1)$.\n\\item $\\sshare{z} \\asn \\mathsf{OR}(\\sshare{z_1},\\sshare{z_2})$.\n\\item $\\sshare{s} \\asn \\mathsf{XOR}(\\sshare{s_1},\\sshare{s_2})$.\n\\item $\\sshare{p} \\asn (\\sshare{p_1}+\\sshare{p_2}+\\ell-\\sshare{b}) \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err_1} + \\sshare{\\err_2} + \\mathsf{FlowDetect}(\\sshare{p})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\n\n\\msubsubsection{$\\mathsf{FLAdd}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn \\mathsf{LT}(\\sshare{p_1},\\sshare{p_2},k$.\n\\item $\\sshare{b} \\asn \\mathsf{EQ}(\\sshare{p_1},\\sshare{p_2},k$. \n\\item $\\sshare{c} \\asn \\mathsf{LT}(\\sshare{v_1},\\sshare{v_2},k$.\n\\item $\\sshare{p_{\\max}} \\asn \\sshare{a} \\cdot \\sshare{p_2} + (1-\\sshare{a}) \\cdot \\sshare{p_1}$.\n\\item $\\sshare{p_{\\min}} \\asn (1-\\sshare{a}) \\cdot  \\sshare{p_2} + \\sshare{a} \\cdot \\sshare{p_1}$.\n\\item $\\sshare{a \\cdot b} \\asn \\sshare{a} \\cdot \\sshare{b}$.\n\\item $\\sshare{b \\cdot c} \\asn \\sshare{b} \\cdot \\sshare{c}$.\n\\item $\\sshare{v_{\\max}} \\asn \n\t(\\sshare{a \\cdot b}-\\sshare{a}-\\sshare{b \\cdot c}) \\cdot (\\sshare{v_1}-\\sshare{v_2})\n\t\t\t   + \\sshare{v_1}$.\n\\item $\\sshare{v_{\\min}} \\asn \n\t(\\sshare{a \\cdot b}-\\sshare{a}-\\sshare{b \\cdot c}) \\cdot (\\sshare{v_2}-\\sshare{v_1})\n\t\t\t   + \\sshare{v_2}$.\n\\item $\\sshare{s_3} \\asn \\mathsf{XOR}(\\sshare{s_1},\\sshare{s_2})$.\n\\item $\\sshare{d} \\asn \\mathsf{LT}(\\ell, \\sshare{p_{\\max}}-\\sshare{p_{\\min}}, k)$.\n\\item $\\sshare{2^\\Delta} \\asn \\mathsf{Pow2}((1-\\sshare{d}) \\cdot (\\sshare{p_{\\max}}-\\sshare{p_{\\min}),\\ell+1)$.\n\\item $\\sshare{v_3} \\asn 2 \\cdot (\\sshare{v_{\\max}}-\\sshare{s_3})+1$.\n\\item $\\sshare{v_4} \\asn \\sshare{v_{\\max}} \\cdot \\sshare{2^\\Delta}+(1-2 \\cdot \\sshare{s_3}) \\cdot \\sshare{v_{\\min}}$.\n\\item $\\sshare{v} \\asn (\\sshare{d} \\cdot \\sshare{v_3}+(1-\\sshare{d}) \\cdot \\sshare{v_4})\n\t\t\\cdot 2^\\ell \\cdot \\mathsf{Inv}(\\sshare{2^\\Delta}})$.\n\\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{v},2 \\cdot \\ell+1,\\ell-1)$.\n\\item $\\sshare{u_{\\ell+1}},\\ldots,\\sshare{u_0} \\asn \\mathsf{BitDec}(\\sshare{v},\\ell+2,\\ell+2)$.\n\\item $\\sshare{h_0},\\ldots,\\sshare{h_{\\ell+1}} \\asn \\mathsf{PreOp}(\\mathsf{OR},\\sshare{u_{\\ell+1}},\\ldots,\\sshare{u_0},k)$.\n\\item $\\sshare{p_0} \\asn \\ell+2-\\sum_{i=0}^{\\ell+1} \\sshare{h_i}$.\n\\item $\\sshare{2^{p_0}} \\asn 1+ \\sum_{i=0}^{\\ell+1} 2^i \\cdot (1-\\sshare{h_i})$.\n\\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{2^{p_0}} \\cdot \\sshare{v},\\ell+2,2)$.\n\\item $\\sshare{p} \\asn \\sshare{p_{\\max}}-\\sshare{p_0}+1-\\sshare{d}$.\n\\item $\\sshare{z_1 \\cdot z_2} \\asn \\sshare{z_1} \\cdot \\sshare{z_2}$.\n\\item $\\sshare{v} \\asn (1-\\sshare{z_1}-\\sshare{z_2} +\\sshare{z_1 \\cdot z_2}) \\cdot \\sshare{v}\n\t\t    + \\sshare{z_1} \\cdot \\sshare{v_2} + \\sshare{z_2} \\cdot \\sshare{v_1}$.\n\\item $\\sshare{z} \\asn \\mathsf{EQZ}(\\sshare{v},\\ell)$.\n\\item $\\sshare{p} \\asn (1-\\sshare{z_1}-\\sshare{z_2}+\\sshare{z_1 \\cdot z_2}) \\cdot \\sshare{p}\n\t+ \\sshare{z_1} \\cdot \\sshare{p_2} \n\t+ \\sshare{z_2} \\cdot \\sshare{p_1}) \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{s} \\asn (\\sshare{a}-\\sshare{a \\cdot b}) \\cdot \\sshare{s_2}\n\t             + (1-\\sshare{a}-\\sshare{b}+\\sshare{a \\cdot b}) \\cdot \\sshare{s_1})\n\t\t     + \\sshare{b \\cdot c} \\cdot \\sshare{s_2}\n\t\t     + (\\sshare{b}-\\sshare{b \\cdot c}) \\cdot \\sshare{s_1})$.\n\\item $\\sshare{s} \\asn (1-\\sshare{z_1}-\\sshare{z_2}+\\sshare{z_1 \\cdot z_2}) \\cdot \\sshare{s}\n\t             + (\\sshare{z_2}-\\sshare{z_1 \\cdot z_2}) \\cdot \\sshare{s_1}\n\t\t     + (\\sshare{z_1}-\\sshare{z_1 \\cdot z_2}) \\cdot \\sshare{s_2}$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err_1} + \\sshare{\\err_2} + \\mathsf{FlowDetect}(\\sshare{p})$.\n\\item $\\sshare{\\err} \\asn \\mathsf{FlowDetect}(\\sshare{p},\\sshare{\\err})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{SDiv}(\\sshare{a},\\sshare{b},\\ell)$:}\n\\begin{enumerate}\n\\item $\\theta \\asn \\ceil{\\log_{2} \\ell}$. \n\\item $\\sshare{x} \\asn \\sshare{b}$.\n\\item $\\sshare{y} \\asn \\sshare{a}$.\n\\item For $i \\in [1,\\ldots,\\theta-1]$ do\n\\begin{enumerate}\n  \\item $\\sshare{y} \\asn \\sshare{y} \\cdot (2^{\\ell+1}-\\sshare{x})$.\n  \\item $\\sshare{y} \\asn \\mathsf{TruncPr}(\\sshare{y},2\\cdot \\ell+1,\\ell)$.\n  \\item $\\sshare{x} \\asn \\sshare{x} \\cdot (2^{\\ell+1}-\\sshare{x})$.\n  \\item $\\sshare{x} \\asn \\mathsf{TruncPr}(\\sshare{x},2\\cdot \\ell+1,\\ell)$.\n\\end{enumerate}\n\\item $\\sshare{y} \\asn \\sshare{y} \\cdot (2^{\\ell+1}-\\sshare{x})$.\n\\item $\\sshare{y} \\asn \\mathsf{TruncPr}(\\sshare{y},2\\cdot \\ell+1,\\ell)$.\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLDiv}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{v} \\asn \\mathsf{SDiv}(\\sshare{v_1},\\sshare{v_2}+\\sshare{z_2},\\ell)$.\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\sshare{v},2^\\ell,\\ell+1)$.\n\\item $\\sshare{v'} \\asn \\sshare{v}+\\sshare{b} \\cdot \\sshare{v}$.\n\\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{v'}, \\ell+1, 1)$.\n\\item $\\sshare{z} \\asn \\sshare{z_1}$.\n\\item $\\sshare{s} \\mathsf{XOR}(\\sshare{s_1},\\sshare{s_2})$.\n\\item $\\sshare{p} \\asn (\\sshare{p_1}-\\sshare{p_2}-\\ell+1-\\sshare{b}) \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err_1} + \\sshare{\\err_2}$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err} + \\sshare{z_2}$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err} + \\mathsf{FlowDetect}(\\sshare{p})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\n\n\\msubsubsection{$\\mathsf{FLLTZ}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item Return $\\sshare{s} \\cdot (1-\\sshare{z}) \\cdot \\mathsf{EQZ}(\\sshare{\\err}, k)$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLEQZ}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item Return $\\sshare{z} \\cdot \\mathsf{EQZ}(\\sshare{\\err}, k)$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLGTZ}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item Return $(1-\\sshare{s}) \\cdot (1-\\sshare{z}) \\mathsf{EQZ}(\\sshare{\\err}, k)$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLLEZ}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item Return $\\sshare{s} \\cdot (1 - \\mathsf{EQZ}(\\sshare{\\err}, k))$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLGEZ}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}))$:}\n\\begin{enumerate}\n\\item Return $(1-\\sshare{s}) \\cdot \\mathsf{EQZ}(\\sshare{\\err}, k)$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLEQ}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{b_1} \\asn \\mathsf{EQ}(\\sshare{v_1},\\sshare{v_2},\\ell)$.\n\\item $\\sshare{b_2} \\asn \\mathsf{EQ}(\\sshare{p_1},\\sshare{p_2},k)$.\n\\item $\\sshare{b_3} \\asn \\sshare{z_1} \\cdot \\sshare{z_2}$.\n\\item $\\sshare{b_4} \\asn \\sshare{s_1} \\cdot \\sshare{s_2}$.\n\\item $\\sshare{t} \\asn \\sshare{err_1} + \\sshare{err_2}$.\n\\item $\\sshare{t} \\asn (\\mathsf{EQZ}(\\sshare{t}, k)$.\n\\item Return $(\\sshare{b_1} \\cdot \\sshare{b_2} \\cdot \\sshare{b_3} \\cdot (1 - \\sshare{b_4}) + \\sshare{b_4}) \\cdot \\sshare{t}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLLT}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn \\mathsf{LT}(\\sshare{p_1},\\sshare{p_2},k)$.\n\\item $\\sshare{c} \\asn \\mathsf{EQ}(\\sshare{p_1},\\sshare{p_2},k)$.\n\\item $\\sshare{d} \\asn \\mathsf{LT}((1-2\\cdot \\sshare{s_1}) \\cdot \\sshare{v_1},\n\t                           (1-2\\cdot \\sshare{s_2}) \\cdot \\sshare{v_2},\\ell+1)$.\n\\item $\\sshare{a \\cdot c} \\asn \\sshare{a}\\cdot \\sshare{c}$.\n\\item $\\sshare{c \\cdot d} \\asn \\sshare{c}\\cdot \\sshare{d}$.\n\\item $\\sshare{b^+} \\asn \\sshare{c \\cdot d}+(\\sshare{a}-\\sshare{a \\cdot c})$.\n\\item $\\sshare{b^-} \\asn \\sshare{c \\cdot d}+(1-\\sshare{c}-\\sshare{a}+\\sshare{a \\cdot c})$.\n\\item $\\sshare{z_1 \\cdot z_2} \\asn \\sshare{z_1}\\cdot \\sshare{z_2}$.\n\\item $\\sshare{s_1 \\cdot s_2} \\asn \\sshare{s_1}\\cdot \\sshare{s_2}$.\n\\item $\\sshare{b} \\asn \\sshare{z_1 \\cdot z_2} \\cdot (\\sshare{s_2}-1-\\sshare{s_1 \\cdot s_2})\n\t             + \\sshare{s_1 \\cdot s_2} \\cdot (\\sshare{z_1}+\\sshare{z_2}-1)\n\t\t     + \\sshare{z_1}\\cdot (1-\\sshare{s1}-\\sshare{s_2})\n\t\t     + \\sshare{s_1}$.\n\\item $\\sshare{t} \\asn \\sshare{err_1} + \\sshare{err_2}$.\n\\item $\\sshare{t} \\asn \\mathsf{EQZ}(\\sshare{t}, k)$.\n\\item $\\sshare{b} \\asn \\sshare{b}+\n\t(1-\\sshare{z_1}-\\sshare{z_2}+\\sshare{z_1 \\cdot z_2} \\cdot \n\t((1-\\sshare{s_1}-\\sshare{s_2}+\\sshare{s_1 \\cdot s_2}) \\cdot \\sshare{b^+}\n\t+\\sshare{s_1 \\cdot s_2} \\cdot \\sshare{b^-}) \\cdot \\sshare{t}$.\n\\item Return $\\sshare{b}$.\n\\end{enumerate}\n\n\n\\msubsubsection{$\\mathsf{FLGT}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{v_r}, \\sshare{p_r}, \\sshare{z_r}, \\sshare{s_r}, \\sshare{err_r} \\asn\n\\mathsf{FLAdd}(\n\t(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},1 -\\sshare{s_2},\\sshare{\\err_2}),\n    (\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}))$.\n \\item Return $\\mathsf{FLLTZ}(\\sshare{v_r}, \\sshare{p_r}, \\sshare{z_r}, \\sshare{s_r}, \\sshare{err_r})$.   \n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLLET}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{b} \\asn \\mathsf{FLGT}(\n        (\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$.\n%\\item $\\sshare{b_2} \\asn \\mathsf{FLEQ}(\n%        (\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n%        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$.\n\\item Return $1 - \\sshare{b}$%$\\mathsf{OR}(\\sshare{b_1},\\sshare{b_2})$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FLGET}(\n\t(\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$:}\n\\begin{enumerate}\n\\item $\\sshare{b} \\asn \\mathsf{FLLT}(\n        (\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$.\n%\\item $\\sshare{b_2} \\asn \\mathsf{FLEQ}(\n%        (\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}),\n%        (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}))$.\n\\item Return $1 - \\sshare{b}$%$\\mathsf{OR}(\\sshare{b_1},\\sshare{b_2})$.\n\\end{enumerate}\n\n\\msubsection{Conversion Routines}\n\n\\msubsubsection{$\\mathsf{FLRound}((\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1},\\mathsf{mode})$:}\nThis, depending on $\\mathsf{mode}$, computes either the floating point\nrepresentation of the floor (if $\\mathsf{mode}=0$) or the ceiling (if $\\mathsf{mode}=1$)\nof the input floating point number.\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn \\mathsf{LTZ}(\\sshare{p_1},k)$.\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\sshare{p_1},-\\ell+1,k)$.\n\\item $\\sshare{a \\cdot b} \\asn \\sshare{a} \\cdot \\sshare{b}$.\n\\item $\\sshare{v_2},\\sshare{2^{-p_1}} \\asn \\mathsf{Mod2m}(\\sshare{v_1},\\ell,(\\sshare{a \\cdot b}-\\sshare{a}) \\cdot \\sshare{p_1})$. \n\t[Note, we save the computation of $\\sshare{2^{-p_1}}$ which this routine computes when $0 \\le p_1 < -\\ell$, otherwise the returned share is of $2^0$.]\n\\item $\\sshare{c} \\asn \\mathsf{EQZ}(\\sshare{v_2},\\ell)$.\n\\item $\\sshare{v} \\asn \\sshare{v_1}-\\sshare{v_2}+(1-\\sshare{c}) \\cdot \\sshare{2^{-p_1}} \n\t\\cdot \\mathsf{XOR}(\\mathsf{mode},\\sshare{s_1})$.\n\\item $\\sshare{d} \\asn \\mathsf{EQ}(\\sshare{v},2^\\ell,\\ell+1)$.\n\\item $\\sshare{v} \\asn 2^{\\ell-1} \\cdot \\sshare{d} + (1-\\sshare{d}) \\cdot \\sshare{v}$.\n\\item $\\sshare{v} \\asn (\\sshare{a}-\\sshare{a \\cdot b}) \\cdot \\sshare{v}\n\t\t\t+ \\sshare{a \\cdot b} \\cdot (\\mathsf{mode}-\\sshare{s_1})\n\t\t\t\t\t+ (1-\\sshare{a}) \\cdot \\sshare{v_1}$.\n\\item $\\sshare{s} \\asn (1-\\sshare{b} \\cdot \\mathsf{mode}) \\cdot \\sshare{s_1}$.\n\\item $\\sshare{z} \\asn \\mathsf{OR}(\\mathsf{EQZ}(\\sshare{v},\\ell),\\sshare{z_1})$.\n\\item $\\sshare{v} \\asn \\sshare{v} \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{p} \\asn (\\sshare{p_1}+\\sshare{d} \\cdot (\\sshare{a}-\\sshare{a \\cdot b})) \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{\\err} \\asn \\sshare{\\err_1}$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To round a \\verb|sfloat| value we could invoke the function as follows: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\nx = sfloat(5.5)\nmode = 0 \n# v, p, z, s, err are extracted from x\n# retunrs the floor of x\ny = floatingpoint.FLRound(x,mode)\n\\end{lstlisting}\nWhen \\verb+mode=2+ then we get the ceil operation.\n\n\n\\msubsubsection{$\\mathsf{Int2Fx}(\\sshare{a},k,f)$:}\nGiven an integer $a \\in \\Zk$ this gives the equivalent integer $b$\nin $\\Qk{f}$, namely $\\overline{b}=a \\cdot 2^f$.\nNote this means, to ensure correctness, that $|a|\\le 2^{k-f}$.\n\\begin{enumerate}\n\\item Return $2^f \\cdot \\sshare{a}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To cast an \\verb|int| or \\verb|sint| register into a \\verb|sfix| one, you could execute the following: \n\\begin{lstlisting}[language={python}]\nx = sfix(5.5)\n# k, f are extracted from x\ny = sfix.load_sint(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{Int2FL}(\\sshare{a},\\gamma,\\ell)$:}\nWe assume $a \\in \\Zgam$, this could loose precision if $\\gamma-1>\\ell$.\n\\begin{enumerate}\n\\item $\\lambda \\asn \\gamma-1$.\n\\item $\\sshare{s} \\asn \\mathsf{LTZ}(\\sshare{a},\\gamma)$.\n\\item $\\sshare{z} \\asn \\mathsf{EQZ}(\\sshare{a},\\gamma)$.\n\\item $\\sshare{a} \\asn (1- 2 \\cdot \\sshare{s}) \\cdot \\sshare{a}$.\n\\item $\\sshare{a_{\\lambda-1}},\\ldots,\\sshare{a_0}\n\t\t\\asn \\mathsf{BitDec}(\\sshare{a},\\lambda,\\lambda)$.\n\\item $\\sshare{b_0},\\ldots,\\sshare{b_{\\lambda-1}} \\asn\n \\mathsf{PreOp}(\\mathsf{OR},\\sshare{a_{\\lambda-1}},\\ldots,\\sshare{a_0},\\gamma)$.\n\\item $\\sshare{v} \\asn \\sshare{a} \\cdot\n\t( 1+\\sum_{i=0}^{\\lambda-1} 2^i \\cdot (1-\\sshare{b_i}))$.\n\\item $\\sshare{p} \\asn - (\\lambda-\\sum_{i=0}^{\\lambda-1} \\sshare{b_i})$.\n\\item If $(\\gamma-1)>\\ell$ then\n\\begin{enumerate}\n  \\item $\\sshare{v} \\asn \\mathsf{Trunc}(\\sshare{v},\\gamma-1,\\gamma-\\ell-1)$.\n\\end{enumerate}\n\\item Else\n\\begin{enumerate}\n  \\item $\\sshare{v} \\asn 2^{\\ell-\\gamma+1} \\cdot \\sshare{v}$.\n\\end{enumerate}\n\\item $\\sshare{p} \\asn (\\sshare{p}+\\gamma-1-\\ell) \\cdot (1-\\sshare{z})$.\n\\item $\\sshare{\\err} \\asn 0$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To cast an \\verb|int| or \\verb|sint| register into a \\verb|sfloat| one, you could execute the following: \n\\begin{lstlisting}[language={python}]\nx = sfloat(5.5)\n# gamma and l are extracted from the system\ny = sfloat(x)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{Fx2Int}(\\sshare{a},k,f)$:}\nGiven a value $a \\in \\Qk{f}$ this gives the integer\n$\\floor{\\overline{a}/2^f}$.\n\\begin{enumerate}\n\\item Return $\\mathsf{Trunc}(\\sshare{a},k,f)$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To extract the integral component of a \\verb|sfix| register, which is then encapsulated on a \\verb|sint| register, \nand taking into account what is currently implemented, you could execute the following: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\nx = sifx(5.5)\n# y stores 5 in a sint register\ny = floatingpoint.Trunc(x.v, x.k - x.f, x.f, x.kappa)\n\\end{lstlisting}\n\\msubsubsection{$\\mathsf{FxFloor}(\\sshare{a},k,f)$:}\nGiven a value $a \\in \\Qk{f}$ this does the same, but\ngives the result as a fixed point value.\n\\begin{enumerate}\n\\item Return $2^f \\cdot \\mathsf{Trunc}(\\sshare{a},k,f)$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To floor an \\verb|sfix| register, you could execute the following: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx = sifx(5.5)\n# k and f are extracted from x\n# y stores 5 in a sfix register\ny = mpc_math.floor_fx(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{Fx2FL}(\\sshare{g},\\gamma,f,\\ell,k)$:}\nConverts $g \\in \\Qk{f}$ into a floating point number\n\\begin{enumerate}\n\\item ($\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})\n\t\\asn \\mathsf{Int2FL}(\\sshare{g},\\gamma,\\ell)$.\n\\item $\\sshare{p} \\asn (\\sshare{p}-f) \\cdot (1-\\sshare{z})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To cast from \\verb|sfix| to \\verb|sfloat|, you could execute the following: \n\\begin{lstlisting}[language={python}]\n# stores 5.5 on a sfloat register\nx = sfloat(sfix(5.5))\n\\end{lstlisting}\n\n\\iffalse\n% this seems not to be used elsewhere\n\\msubsubsection{$\\mathsf{FL2Int}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}),\\ell,k,\\gamma)$:}\nNote the two calls to $\\mathsf{Mod2m}$ below can be combined into\none, as can the two calls to $\\mathsf{Pow2}$.\nThe output here is in $\\Zgam$.\n\\begin{enumerate}\n\\item $\\sshare{v'},\\sshare{p'},\\sshare{z'},\\sshare{s'},\\sshare{\\err'}\n\t\\asn \\mathsf{FLRound}(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err},\\mathsf{2})$. \n\\item $\\sshare{a} \\asn \\mathsf{LT}(\\sshare{p'},\\gamma-1,k)$.\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\gamma-\\ell-1,\\sshare{p'},k)$.\n\\item $\\sshare{c} \\asn \\mathsf{LTZ}(\\sshare{p'},k)$.\n\\item $\\sshare{b \\cdot c} \\asn \\sshare{b} \\cdot \\sshare{c}$.\n\\item $\\sshare{m} \\asn \\sshare{a}\\cdot (\\sshare{b} -\\sshare{b \\cdot c})\n\t\t\\cdot (\\gamma-1-\\sshare{p'})$.\n\\item $\\sshare{u} \\asn \\mathsf{Mod2m}(\\sshare{v'},\\ell,\\sshare{m})$.\n\\item $\\sshare{v'} \\asn (\\sshare{b} -\\sshare{b \\cdot c}) \\cdot ( \\sshare{u}-\\sshare{v'}) +\\sshare{v'}$\n\\item $\\sshare{2^{-p'}} \\asn \\mathsf{Pow2}(-\\sshare{c} \\cdot \\sshare{p'},\\ell)$.\n\\item $\\sshare{2^{p'}} \\asn \\mathsf{Inv}(\\sshare{2^{-p'}})$.\n\\item $\\sshare{v'} \\asn (\\sshare{c} \\cdot \\sshare{2^{p'}}+1-\\sshare{c})\n\t\t\t\\cdot \\sshare{v'}$.\n\\item $\\sshare{w} \\asn \\mathsf{Mod2m}(\\sshare{v'},\\ell,\n\t\t\\sshare{b \\cdot c}\\cdot(\\gamma-1))$.\n\\item $\\sshare{v'} \\asn \\sshare{b \\cdot c} \\cdot (\\sshare{w}-\\sshare{v'}) +\\sshare{v'}$.\n\\item $\\sshare{2^{p'}} \\asn \\mathsf{Pow2}(\\sshare{a} \\cdot (1-\\sshare{c})\n\t\t\t\t\\cdot \\sshare{p'},\\gamma-1)$.\n\\item $\\sshare{g} \\asn (1-\\sshare{z'}) \\cdot (1-2 \\cdot \\sshare{s'})\n\t\t\t\\cdot \\sshare{2^{p'}} \\cdot \\sshare{a}\n\t\t\t\\cdot \\sshare{v'}$.\n\\item Return $\\sshare{g}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To extract the integral component of a \\verb|sfloat| input,  \ngiven the current implementation, you could execute the following: \n\\begin{lstlisting}[language={python}]\nfrom Compiler import floatingpoint\n# v, p, z, s, err are extracted from x and l, k, gamma are system parameters \nx = sfloat(5.5)\n# retunrs the floor of x\ny = floatingpoint.FLRound(x,0)\n\\end{lstlisting}\n\\fi\n\n\\msubsubsection{$\\mathsf{FL2Fx}((\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}),\\ell,k,\\gamma,f)$:}\n\\begin{enumerate}\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\sshare{p},2^{k-1}-f,k)$.\n\\item $\\sshare{g} \\asn \\mathsf{FL2Int}((\\sshare{v},\\sshare{p}+f,\\sshare{z},\n\t\\sshare{s},\\sshare{\\err}),\\ell,k,\\gamma)$.\n\\item Return $\\sshare{g} \\cdot \\sshare{b}$.\n\\end{enumerate}\n\\paragraph{MAMBA Example:} To cast an \\verb|sfloat| register into a \\verb|sfix| one, you could execute the following: \n\\begin{lstlisting}[language={python}]\n# stores 5.5 on a sfix register\n# v, p, z, s, err are extracted from x and l, k, gamma are system parameters \nx = sfix(sfloat(5.5))\n\\end{lstlisting}\n\n\\msubsection{SQRT Functions}\n\\todo{These functions are only currently supported in their fixed point versions.}\nThe original description of the protocols for the fixed point square root algorithm are included in:\n\\begin{itemize}\n\\item Secure Distributed Computation of the Square Root and Applications, {\\em ISPEC 2012}\n\\cite{Liedel12}.\n\\end{itemize}\nThe floating point variant is in\n\\begin{itemize}\n\\item Secure Computation on Floating Point Numbers {\\em NDSS 2013} \\cite{ABZS13}.\\todo{This is not currently implemented}\n\\end{itemize}\nAdditionally, we provide a simplified implementation for the Square Root on fixed point variables, that is appropriate for inputs of any size. We make use Liedel's protocol, when the input's size makes it possible, as we explain later in this section.\nBoth algorithms makes use of two constants\n\\[ \\alpha = -0.8099868542, \\quad \\beta  =  1.787727479.  \\]\nThese are the solutions of the system of equations\n\\begin{align*}\n   E(x)&= \\frac{\\alpha \\cdot x+\\beta-\\frac{1}{\\sqrt{x}}}{\\frac{1}{\\sqrt{x}}}, \\\\\n\tM &= \\frac{\\sqrt{3}}{3} \\cdot \\sqrt{\\frac{-\\beta}{\\alpha}}\n\t    \\cdot \\left(\\frac{2}{3} \\cdot\\beta\n\t\t    -\\frac{\\sqrt{3}}{\\sqrt{\\frac{-\\beta}{\\alpha}}} \n\t    \\right), \\\\\n   E\\left( \\frac{1}{2}\\right) &= E(1) = -M.\n\\end{align*}\n\n\\msubsubsection{$\\mathsf{ParamFxSqrt}(\\sshare{x},k,f)$:}\nThis algorithm uses the sub-algorithm $\\mathsf{LinAppSQ}$ defined below, note that \\verb|LinAppSQ| returns an scaled $1/\\sqrt{x} \\cdot 2^{f}$.\nThe algorithm only works when $3 \\cdot k -2 \\cdot f$ is less than the system precision, which is by default equal to $20$.\nIn a future release we will extend the sqrt function to cope with other input ranges.\n\\begin{enumerate}\n\\item $\\theta \\asn \\ceil{\\log_2 (k/5.4)}$.\n\\item $\\sshare{y_0} \\asn \\mathsf{LinAppSQ}(\\sshare{x},k,f)$.\n\\item $\\sshare{y_0} \\asn \\sshare{y_0} \\cdot 1/2^{f}$.\n\\item $\\sshare{g_0} \\asn \\sshare{y_0} \\cdot \\sshare{x}$.\n\\item $\\sshare{g_0} \\asn \\sshare{y_0} \\cdot 1/2^{f}$.\n%\\item $\\sshare{g_0} \\asn \\mathsf{TruncPr}(\\sshare{g_0},k,f)$.\n%\\item $\\sshare{h_0} \\asn \\mathsf{FxDiv}(\\sshare{g_0},2,k,f)$.\n\\item $\\sshare{g_0} \\asn \\sshare{y_0} \\cdot 1/2$.\n\\item $\\sshare{gh_0} \\asn \\sshare{g_0} \\cdot \\sshare{h_0}$.\n%\\item $\\sshare{gh} \\asn \\mathsf{TruncPr}(\\sshare{gh},k,f)$.\n\\item $\\sshare{g} \\asn \\sshare{g_0}$.\n\\item $\\sshare{h} \\asn \\sshare{h_0}$.\n\\item $\\sshare{gh} \\asn \\sshare{gh_0}$.\n\\item For $i \\in[1,\\ldots,\\theta-2]$ do\n\\begin{enumerate}\n  \\item $\\sshare{r} \\asn 3/2-\\sshare{gh}$.\n  \\item $\\sshare{g} \\asn \\sshare{g} \\cdot \\sshare{r}$.\n  \\item $\\sshare{h} \\asn \\sshare{h} \\cdot \\sshare{r}$.\n  %\\item $\\sshare{g} \\asn \\mathsf{TruncPr}(\\sshare{g},k,f)$.\n  %\\item $\\sshare{h} \\asn sf{TruncPr}(\\sshare{h},k,f)$.\n  \\item $\\sshare{gh} \\asn \\sshare{g} \\cdot \\sshare{h}$.\n  %\\item $\\sshare{gh} \\asn \\mathsf{TruncPr}(\\sshare{gh},k,f)$.\n\\end{enumerate}\n\\item $\\sshare{r} \\asn 3/2-\\sshare{gh}$.\n\\item $\\sshare{h} \\asn \\sshare{h} \\cdot \\sshare{r}$.\n%\\item $\\sshare{h} \\asn \\mathsf{TruncPr}(\\sshare{h},k,f)$.\n\\item $\\sshare{H} \\asn 4 \\cdot (\\sshare{h}^2)$.\n\\item $\\sshare{H} \\asn \\sshare{H}\\cdot \\sshare{x}$.\n\\item $\\sshare{H} \\asn (3) - \\sshare{H}$.\n\\item $\\sshare{H} \\asn \\sshare{h} \\cdot \\sshare{H}$.\n\\item $\\sshare{g} \\asn \\sshare{H} \\cdot \\sshare{x}$.\n%\\item $\\sshare{g} \\asn \\mathsf{FxDiv}(\\sshare{g},2,k,f)$.\n%\\item $\\sshare{g} \\asn \\mathsf{TruncPr}(\\sshare{g},4 \\cdot k,4 \\cdot f)$.\n\\item Return $\\sshare{g}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{SimplifiedFxSqrt}(\\sshare{x}, k, f)$:}\nThis algorithm uses the sub-algorithm $\\mathsf{NormSQ}$ defined above. Among the values it returns, we base our approximation by directly using $w =2^{m/2}$. From that point it approximates the  value of $\\sqrt{x}$ by calculating $\\frac{x}{2^{m/2}}$. To avoid any loss of precision, we reuse \\verb|sfix| instantiation process.\nThe algorithm work on the precision of the system and can solve values on any range. Its behaviour is still experimental. The function is designed in such a way that there is no restriction on the size $f$.\n\\begin{enumerate}\n\\item $\\theta \\asn \\max{(\\ceil{\\log_2(k)},6)}$.\n\\item $\\sshare{m_{odd}}, \\sshare{w} \\asn \\mathsf{SimplifiedNormSQ}(\\sshare{x},k)$.\n\\item $\\sshare{m_{odd}} \\asn (1 - 2 \\cdot \\sshare{m_{odd}}) \\cdot f$.   \n \\item $\\sshare{w} \\asn (2 \\cdot \\sshare{w} -\\sshare{w}) \\cdot (1 - \\sshare{m_{odd}}) \\cdot (f \\quad \\% \\quad 2) + \\sshare{w}$.\n\\item $\\sshare{w} \\asn sfix( \\sshare{w} \\cdot 2 ^{\\frac{f - f \\quad \\% \\quad 2}{2}})$.\n\\item $\\sshare{w} \\asn (\\sqrt{2}\\cdot \\sshare{w} - \\sshare{w})\\cdot \\sshare{m_{odd}} + \\sshare{w}$.\n\\item $\\sshare{y_0} \\asn \\frac{1}{\\sshare{w}} $.\n\\item $\\sshare{g_0} \\asn \\sshare{y_0} \\cdot \\sshare{x}$.\n\\item $\\sshare{g_0} \\asn \\sshare{y_0} \\cdot 1/2$.\n\\item $\\sshare{gh_0} \\asn \\sshare{g_0} \\cdot \\sshare{h_0}$.\n\\item $\\sshare{g} \\asn \\sshare{g_0}$.\n\\item $\\sshare{h} \\asn \\sshare{h_0}$.\n\\item $\\sshare{gh} \\asn \\sshare{gh_0}$.\n\\item For $i \\in[1,\\ldots,\\theta-2]$ do\n\\begin{enumerate}\n  \\item $\\sshare{r} \\asn 3/2-\\sshare{gh}$.\n  \\item $\\sshare{g} \\asn \\sshare{g} \\cdot \\sshare{r}$.\n  \\item $\\sshare{h} \\asn \\sshare{h} \\cdot \\sshare{r}$.\n  %\\item $\\sshare{g} \\asn \\mathsf{TruncPr}(\\sshare{g},k,f)$.\n  %\\item $\\sshare{h} \\asn sf{TruncPr}(\\sshare{h},k,f)$.\n  \\item $\\sshare{gh} \\asn \\sshare{g} \\cdot \\sshare{h}$.\n  %\\item $\\sshare{gh} \\asn \\mathsf{TruncPr}(\\sshare{gh},k,f)$.\n\\end{enumerate}\n\\item $\\sshare{r} \\asn 3/2-\\sshare{gh}$.\n\\item $\\sshare{h} \\asn \\sshare{h} \\cdot \\sshare{r}$.\n%\\item $\\sshare{h} \\asn \\mathsf{TruncPr}(\\sshare{h},k,f)$.\n\\item $\\sshare{H} \\asn 4 \\cdot (\\sshare{h}^2)$.\n\\item $\\sshare{H} \\asn \\sshare{H}\\cdot \\sshare{x}$.\n\\item $\\sshare{H} \\asn (3) - \\sshare{H}$.\n\\item $\\sshare{H} \\asn \\sshare{h} \\cdot \\sshare{H}$.\n\\item $\\sshare{g} \\asn \\sshare{H} \\cdot \\sshare{x}$.\n%\\item $\\sshare{g} \\asn \\mathsf{FxDiv}(\\sshare{g},2,k,f)$.\n%\\item $\\sshare{g} \\asn \\mathsf{TruncPr}(\\sshare{g},4 \\cdot k,4 \\cdot f)$.\n\\item Return $\\sshare{g}$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FxSqrt}(\\sshare{x}, k \\asn \\mathtt{sfix.k}, f \\asn \\mathtt{sfix.f})$:}\nOur \\verb|FxSqrt| functionality returns the square root of any fixed point input. It receives an input value $\\sshare{x}$, from which it calculates the square root, and optional parameters regarding its bit-length and bit-wise precision. The functionality is going to make use of our \\verb|SimplifiedFxSqrt| process by default, and the somewhat more efficient Liedel's method instead when the $3 \\cdot k - 2 \\cdot f < \\mathtt{sfix.f}$ bound, provided by his paper, is met. \n\n\\begin{enumerate}\n\\item if $(3 \\cdot k - 2 \\cdot f >= \\mathtt{sfix.f})$:\n\\begin{enumerate}\n\t\\item Return $\\mathsf{SimplifiedFxSqrt}(\\sshare{x}, k, f)$.\n\\end{enumerate}\n\\item else:\n\\begin{enumerate}\n    \\item $\\sshare{x} \\asn Trunc(\\sshare{x} \\cdot 2^{f}, sfix.k, sfix.k-sfix.f)$\n\t\\item Return $\\mathsf{ParamFxSqrt}(\\sshare{x}, k, f)$.\n\\end{enumerate}\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|sqrt| of any value, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nk = 5\nf = 2\n \nx = sfix(6.25)\ny = sfix(144)\nz = sfix (257.5)\n \n# returns the sqrt of the number, i.e. 2.5\n# inputs have to be expressed such that:\n# x * 2^f \\in Z_q\n# and 3*k -2*f < sfix.f (system precision)\n# by default system precision is 20 bits. \na = mpc_math.sqrt(x, k, f)\n\n# when you don't specify k and f, the system uses\n# the default sfix values, and hence the simplified\n# version for any value range, at the cost of an\n# additional division call.\n\nb = mpc_math.sqrt(y)\nc = mpc_math.sqrt(z)\n\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{LinAppSQ}(\\sshare{b},k,f)$:}\nWe based this section on the contents of the original paper, \\cite{Liedel12}.\nHowever we corrected the typos from the original work, the result is as follows:\n\\begin{enumerate}\n\\item $\\alpha \\asn (-0.8099868542) \\cdot 2^k$.  \n\\item $\\beta \\asn (1.787727479) \\cdot 2^{2\\cdot k}$.\n\\item $(\\sshare{c},\\sshare{v},\\sshare{m},\\sshare{W}) \\asn \\mathsf{NormSQ}(\\sshare{b},k,f)$.\n\\item $\\sshare{w} \\asn \\alpha \\cdot \\sshare{c}+\\beta$.\n\\item $\\sshare{m} \\asn \\mathsf{Mod2}(\\sshare{m},\\ceil{\\log_2 k})$.\n\\item $\\sshare{w} \\asn \\sshare{w} \\cdot \\sshare{W} \\cdot \\sshare{v}$.\n\\item $\\sshare{w} \\asn \\mathsf{FxDiv}(\\sshare{w},2^{f/2},w.k,w.f)$.\n\\item $\\sshare{w} \\asn \\mathsf{FxDiv}(\\sshare{w},3 \\cdot k - 2 \\cdot f,w.k,w.f)$.\n%\\item $\\sshare{w} \\asn \\mathsf{TruncPr}(\\sshare{w},3\\cdot k, 3 \\cdot k - 2 \\cdot f)$.\n\\item $\\sshare{w} \\asn (1-\\sshare{m}) \\cdot \\sshare{w} \\cdot 2^f\n\t\t\t+(\\sqrt{2} \\cdot 2^f) \\cdot \\sshare{m}\\cdot \\sshare{w}$.\n\\item Return $\\sshare{w}$ % \\asn \\mathsf{TruncPr}(\\sshare{w},k,f)$.\n\\end{enumerate}\n\n\n\\msubsubsection{$\\mathsf{FLSqrt}((\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}))$:}\nBelow we let $\\ell_0$ denote the lsb of $\\ell$,\n$(v_\\alpha,p_\\alpha,z_\\alpha,s_\\alpha)$\n(resp.  $(v_\\beta,p_\\beta,z_\\beta,s_\\beta)$)\ndenote the floating point representation of the constant $\\alpha$ (resp. $\\beta$)\ngiven above,\nand $v_{\\sqrt{2}}$ and $p_{\\sqrt{2}}$ represent the $\\ell$-bit significand and exponent of\n$\\sqrt{2}$ in floating point representation.\n\\begin{enumerate}\n\\item $\\sshare{b} \\asn \\mathsf{BitDec}(\\sshare{p_1},\\ell,1)$.\n\\item $\\sshare{c} \\asn \\mathsf{XOR}(\\sshare{b},\\ell_0)$. \n\\item $\\sshare{p} \\asn 2^{-1} \\cdot (\\sshare{p_1}-\\sshare{b})\n\t\t+\\floor{\\ell/2}+\\mathsf{OR}(\\sshare{b},\\ell_0)$.\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\\asn \\mathsf{FLMult}((\\sshare{v_1},-\\ell,0,0,0),(v_\\alpha,p_\\alpha,z_\\alpha,s_\\alpha,0))$.\n\\item $(\\sshare{v_0},\\sshare{p_0},\\sshare{z_0},\\sshare{s_0},\\sshare{\\err_0})\n\t\\asn \\mathsf{FLAdd}((\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}),(v_\\beta,p_\\beta,z_\\beta,s_\\beta,0))$.\n\\item $(\\sshare{v_g},\\sshare{p_g},\\sshare{z_g},\\sshare{s_g},\\sshare{\\err_g})\n\t\\asn \\mathsf{FLMult}((\\sshare{v_1},-\\ell,0,0,0),(\\sshare{v_0},\\sshare{p_0},\\sshare{z_0},\\sshare{s_0},\\sshare{\\err_0}))$.\n\\item  $(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t\\asn   (\\sshare{v_0},\\sshare{p_0}-1,\\sshare{z_0},\\sshare{s_0},\\sshare{\\err_0})$.\n\\item For $i \\in [1,\\ldots,\\ceil{\\ell/5.4}-1]$ do\n\\begin{enumerate}\n   \\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_g},\\sshare{p_g},\\sshare{z_g},\\sshare{s_g},\\sshare{\\err_g}),\n                (\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t\t)$.\n   \\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLSub}(\n\t\t(3 \\cdot 2^{\\ell-2},-(\\ell-1),0,0,0),\n                (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t)$.\n   \\item $(\\sshare{v_g},\\sshare{p_g},\\sshare{z_g},\\sshare{s_g},\\sshare{\\err_g})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_g},\\sshare{p_g},\\sshare{z_g},\\sshare{s_g},\\sshare{\\err_g}),\n                (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t)$.\n   \\item $(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h}),\n                (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t)$.\n\\end{enumerate}\n\\item $(\\sshare{v_{h^2}},\\sshare{p_{h^2}},\\sshare{z_{h^2}},\\sshare{s_{h^2}},\\sshare{\\err_{h^2}})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h}),\n                (\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t\t)$.\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLMult}(\n                (\\sshare{v_1},-\\ell,0,0,0),\n                (\\sshare{v_{h^2}},\\sshare{p_{h^2}},\\sshare{z_{h^2}},\\sshare{s_{h^2}},\\sshare{\\err_{h^2}})$.\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLSub}(\n\t\t(3 \\cdot 2^{\\ell-2},-(\\ell-1),0,0,0),\n                (\\sshare{v_2},\\sshare{p_2}+1,\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t)$.\n\\item $(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_h},\\sshare{p_h},\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h}),\n                (\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t)$.\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_1},-\\ell,0,0,0),\n                (\\sshare{v_h},\\sshare{p_h}+1,\\sshare{z_h},\\sshare{s_h},\\sshare{\\err_h})\n\t\t)$.\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t   \t\\asn \\mathsf{FLMult}(\n\t\t(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2})\n\t\t(2^{\\ell-1} \\cdot (1-\\sshare{c}) + v_{\\sqrt{2}} \\cdot \\sshare{c},\n\t\t-(1-\\sshare{c}) \\cdot (\\ell-1)+p_{\\sqrt{2}} \\cdot \\sshare{c},0,0,0)$.\n\\item $\\sshare{p} \\asn (\\sshare{p_2}+\\sshare{p}) \\cdot (1-\\sshare{z_1})$.\n\\item $\\sshare{v} \\asn \\sshare{v_2} \\cdot (1-\\sshare{z_1})$.\n\\item $\\sshare{\\err} \\asn \\mathsf{OR}(\\sshare{\\err_2},\\sshare{s_1})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err})$.\n\\end{enumerate}\n\\todo{Have we picked up $\\err$ correctly here?}\n\n\\msubsection{EXP and LOG Functions}\n\\todo{These functions are only currently supported in their fixed point versions.}\n\nA secure fixed point exponentiation and logarithm algorithm is not found anywhere, so\nthis is our own one derived from the identities in the book.\n\\begin{itemize}\n\\item {\\em Computer Approximations} by Hart from 1968 \\cite{Hart:1978:CA:540084}.\n\\end{itemize}\nThe floating point variants are in\n\\begin{itemize}\n\\item Secure Computation on Floating Point Numbers {\\em NDSS 2013} \\cite{ABZS13}.\n\\end{itemize}\nOnce we have defined $\\mathsf{FxExp2}$ and $\\mathsf{FxLog2}$\n(resp. $\\mathsf{FLExp2}$ and $\\mathsf{FLLog2}$) we can\ndefine the following functions from the usual identities\nfor non-secret values of the base $b$:\n\\begin{align*}\n\t\\log_b x &= (\\log_b 2) \\cdot \\mathsf{Log2}(x), \\\\\n\tx^y      &= \\mathsf{Exp2}(y \\cdot \\mathsf{Log2}(x)), \\\\\n\t\\exp   x &= \\mathsf{Exp2}(x \\cdot \\log_2 e), \\\\\n\\end{align*}\nNote, that the functions on these section require specific \\verb|sfloat| parametrization, in accordance to the algorithms in this section. They support secret shared \\verb|sfix| $x$ ad $y$, as well as public floating point or integer inputs.  We can define these operations as follows:\n\n\\msubsubsection{$\\mathsf{FxExp2}(\\sshare{a},k,f)$:}\nThis algorithm computes $2^a$ as a fixed point calculation.\nFirst takes the integer and fractional part of the input\n$|a/2^f|$, which we denote by $b$ and $c$.\nWe then compute $d=2^b$, which will clearly overflow\nif $b>k-f$, but we ignore this error (if the user is stupid\nenough to put in garbage, they get garbage out).\nWe then compute $e=2^c$, as $0 \\le c \\le 1$ via the \npolynomial $P_{1045}(X)$ from Hart \\cite{Hart:1978:CA:540084} with coefficients\n\\begin{center}\n\\begin{tabular}{|c|c|l|}\n\\hline\n0 & 1  & +.10000 00077 44302 1686 \\\\\n1 & 0  & +.69314 71804 26163 82779 5756 \\\\\n2 & 0  & +.24022 65107 10170 64605 384 \\\\\n3 & -1 & +.55504 06862 04663 79157 744 \\\\\n4 & -2 & +.96183 41225 88046 23749 77 \\\\\n5 & -2 & +.13327 30359 28143 78193 29 \\\\\n6 & -3 & +.15510 74605 90052 57397 8 \\\\\n7 & -4 & +.14197 84739 97656 06711 \\\\\n8 & -5 & +.18633 47724 13796 7076 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\nwhich gives a relative error of at most $10^{-12.11}$\nif computed exactly.\nThe table should be read as line $(i,a,b)$ giving \nthe $i$th coefficient of the polynomial being\n$b \\cdot 10^a$.\nGiven $d$ and $e$ one can now compute\n$2^{|a|}=2^{b+c}=2^b \\cdot 2^c=d \\cdot e$,\nand the final dealing with the sign of $a$ can\nbe done by an inversion.\nWe denote by $\\mathsf{FxPol}(P_{1045},\\sshare{x},k,f)$ the evaluation\nof the polynomial $P_{1045}$ on the fixed point input $\\sshare{x}$\nwhere $x \\in \\Qk{f}$. This is done by Horner's rule.\n\\begin{enumerate}\n\\item $\\sshare{s}=\\mathsf{FxLTZ}(\\sshare{a})$.\n\\item $\\sshare{a} \\asn (1-2 \\cdot \\sshare{s}) \\cdot \\sshare{a}$.\n\\item $\\sshare{b} \\asn \\mathsf{Fx2Int}(\\sshare{a},k,f)$.\n\\item $\\sshare{c} \\asn \\sshare{a}-\\mathsf{Int2Fx}(\\sshare{b},k,f)$.\n\\item $\\sshare{d} \\asn \\mathsf{Int2Fx}(\\mathsf{Pow2}(\\sshare{b},k),k,f)$. [This will produce an invalid result if $b$ is too big, in which case the result cannot be held in an Fx in any case]\n\\item $\\sshare{e} \\asn \\mathsf{FxPol}(P_{1045},\\sshare{c},k,f)$.\n\\item $\\sshare{g} \\asn \\mathsf{FxMult}(\\sshare{d},\\sshare{e},k,f)$.\n\\item $\\sshare{g^{-1}} \\asn \\mathsf{FxDiv}(2^f,\\sshare{g},k,f)$.\n\\item $\\sshare{a} \\asn (1-\\sshare{s}) \\cdot g+ \\sshare{s} \\cdot \\sshare{g^{-1}}$.\n\\item Return $\\sshare{a}$.\n\\end{enumerate}\nThe above works, but we have found a little numerical\ninstability due to the division operation. \n\\paragraph{MAMBA Example:} To obtain $2^y$ where $y$ is secret shared you could run the following: \n\\begin{lstlisting}[language={python}]\n\nfrom Compiler import mpc_math\n# import comparison\nsfloat.vlen = 15   # Length of mantissa in bits\nsfloat.plen = 10   # Length of exponent in bits\nsfloat.kappa = 4  # Statistical security parameter for floats\n\ny =sfix(4)\n\n# returns 2^4 \n# extracts k and f from y\nexp2_y=mpc_math.exp2_fx(sfix(y))\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{FLExp2}((\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}))$:}\nThis method assumes that $k \\le \\ell$.\nWe do not support a method if $k > \\ell$, and so if this happens\nwe will signal an error.\n\\begin{enumerate}\n\\item If $k>\\ell$ then $\\err_1 \\asn 1$.\n\\item $\\max \\asn \\ceil{\\log_2(2^{k-1}-1+\\ell)-\\ell+1}$.\n\\item $\\sshare{a} \\asn \\mathsf{LT}(\\sshare{p_1},\\max,k)$.\n\\item $\\sshare{b} \\asn \\mathsf{LT}(\\sshare{p_1},-\\ell+1,k)$.\n\\item $\\sshare{c} \\asn \\mathsf{LT}(\\sshare{p_1},-2 \\cdot \\ell+1,k)$.\n\\item $\\sshare{(1-c) \\cdot a} \\asn (1-\\sshare{c}) \\cdot \\sshare{a}$.\n\\item $\\sshare{p_2} \\asn -\\sshare{(1-c) \\cdot a} \\cdot (\\sshare{b} \\cdot \\ell +\\sshare{p_1})$.\n\\item $\\sshare{x},\\sshare{2^{p_2}} \\asn \\mathsf{Trunc}(\\sshare{v_1},\\ell,\\sshare{p_2})$.\n\\item $\\sshare{y} \\asn \\sshare{v_1}-\\sshare{x} \\cdot \\sshare{2^{p_2}}$.\n\\item $\\sshare{d} \\asn \\mathsf{EQZ}(\\sshare{y},\\ell)$.\n\\item $\\sshare{b \\cdot s_1} \\asn \\sshare{b} \\cdot \\sshare{s_1}$.\n\\item $\\sshare{(1-d) \\cdot s_1} \\asn (1-\\sshare{d}) \\cdot \\sshare{s_1}$.\n\\item $\\sshare{x} \\asn (1-\\sshare{b \\cdot s_1})\n\t                 \\cdot (\\sshare{x}-\\sshare{(1-d)\\cdot s_1})\n\t\t+\\sshare{b \\cdot s_1} \\cdot(2^\\ell-1+\\sshare{d}-\\sshare{x})$.\n\\item $\\sshare{y} \\asn \\sshare{(1-d) \\cdot s_1} \\cdot (\\sshare{2^{p_2}}-\\sshare{y})\n\t\t\t+ (1-\\sshare{s_1})\\cdot \\sshare{y}$.\n\\item $\\sshare{w} \\asn \\sshare{(1-c) \\cdot a} \\cdot\n\t\t\t((1-\\sshare{b}) \\cdot\\sshare{x}+\\sshare{b \\cdot s_1})\n\t\t\t\\cdot (1-2\\cdot \\sshare{s_1})-\\sshare{c} \\cdot \\sshare{s_1}$.\n\\item $\\sshare{u} \\asn \\sshare{(1-c) \\cdot a}\n\t\t\t\\cdot (\\sshare{b} \\cdot \\sshare{x}\n\t\t\t+(1-\\sshare{b}) \\cdot 2^\\ell \\cdot \\mathsf{Inv}(\\sshare{2^{p_2}})\n\t\t\t\t\t\t\t\\cdot \\sshare{y})\n\t\t\t+(2^\\ell-1)\\cdot \\sshare{c} \\sshare{s_1}$.\n\\item $\\sshare{u_\\ell},\\ldots,\\sshare{u_1} \\asn \\mathsf{BitDec}(\\sshare{u},\\ell,\\ell)$.\n\\item For $i \\in [1,\\ldots,\\ell]$ do\n\\begin{enumerate}\n  \\item~ [In this loop $(cv_i,cp_i,0,0)$ represents the floating point number $2^{2^{-i}}$].\n  \\item $\\sshare{a_i} \\asn 2^{\\ell-1} \\cdot (1-\\sshare{u_i})+cv_i \\cdot \\sshare{u_i}$.\n  \\item $\\sshare{b_i} \\asn -(\\ell-1) \\cdot (1-\\sshare{u_i})+cp_i \\cdot \\sshare{u_i}$.\n\\end{enumerate}\n\\item $(\\sshare{v_u},\\sshare{p_i},0,0)\n\t\\asn \\mathsf{FLProd}((\\sshare{a_1},\\sshare{b_1},0,0), \\ldots,\n\t                     (\\sshare{a_\\ell},\\sshare{b_\\ell},0,0))$. \n\t\t\t     [This implements a product of $\\ell$ floating point values, which is\n\t\t\t      performed via a binary tree style method.]\n\\item $\\sshare{p} \\asn \\sshare{a} \\cdot (\\sshare{w}+\\sshare{p_u})\n\t\t\t+2^{k-1}\\cdot (1-\\sshare{a}) \\cdot (1-2 \\sshare{s_1})$.\n\\item $\\sshare{v} \\asn 2^{\\ell-1} \\cdot \\sshare{z_1}+(1-\\sshare{z_1}) \\cdot \\sshare{v_u}$.\n\\item $\\sshare{p} \\asn -\\sshare{z_1} \\cdot (\\ell-1)\n\t\t\t+(1-\\sshare{z_1}) \\cdot \\sshare{p}$.\n\\item $\\sshare{\\err} \\asn \\mathsf{FlowDetect}(\\sshare{p},\\sshare{\\err_1})$\n\\item Return $(\\sshare{v},\\sshare{p},0,0,\\sshare{\\err})$.\n\\end{enumerate}\n\n\\msubsubsection{$\\mathsf{FxLog2}(\\sshare{a},k,f)$:}\nWe first map $a$ to a value $v$ in the interval $[1/2,1]$ by essentially\nconverting to a floating point number.\nSo we a have $a=(v/2^k) \\cdot 2^p$ where $v, p \\in \\Zk$,\nand $v/2^k \\in [1/2,1]$.\nThus we have \n$\\log_2 a = p+\\log_2 (v/2^k)$, and we then treat $v$ as a fixed\npoint number and apply the Pade approximation $P_{2524}/Q_{2524}$\nfrom Hart's book \\cite{Hart:1978:CA:540084},\nwhich produces an {\\em absolute} error of $10^{-8.32}$.\nWe denote by $\\mathsf{FxPade}(P_{2524},Q_{2524},\\sshare{x},k,f)$ the evaluation\nof the rational function $P_{2524}/Q_{2524}$ on the fixed point input $\\sshare{x}$\nwhere $x \\in \\Qk{f}$.\nThe Pade approximation is given be the rational function defined\nby the following table\n\\begin{center}\n\\begin{tabular}{|c|c|c|l|}\n\\hline\nP & 0 & 1  & -.20546 66719 51 \\\\\nP & 1 & 1  & -.88626 59939 1 \\\\\nP & 2 & 1  & +.61058 51990 15 \\\\\nP & 3 & 1  & +.48114 74609 89 \\\\ \nQ & 0 & 0  & +.35355 34252 77 \\\\ \nQ & 1 & 1  & +.45451 70876 29  \\\\\nQ & 2 & 1  & +.64278 42090 29 \\\\ \nQ & 3 & 1  & +.1 \\\\ \n\\hline\n\\end{tabular}\n\\end{center}\n\n\\begin{enumerate}\n\\item $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err})\n\t\\asn \\mathsf{Fx2FL}(\\mathsf{a},k,f,k,k)$.\n\\item $\\sshare{a} \\asn \\mathsf{FxPade}(P_{2524},Q_{2524},\\sshare{v},k,k)$.\n\\item $\\sshare{a} \\asn \\sshare{a}+\\sshare{p}$.\n\\item $\\sshare{a} \\asn \\sshare{a} \\cdot (1-\\sshare{z}) \\cdot (1-\\sshare{s}) \\cdot (1-\\cdot \\sshare{\\err})$.\n\\item Return $\\sshare{a}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain \\verb|log2|$(x)$ where $y$ is secret shared you could run the following: \n\\begin{lstlisting}[language={python}]\n\nfrom Compiler import mpc_math\n# import comparison\nsfloat.vlen = 15   # Length of mantissa in bits\nsfloat.plen = 10   # Length of exponent in bits\nsfloat.kappa = 4  # Statistical security parameter for floats\n\nx =sfix(4)\n# extracts k and f from y\n# returns log_2(4) \nlog2_x=mpc_math.log2_fx(sfix(x))\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{FLLog2}((\\sshare{v_1},\\sshare{p_1},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err_1}))$:}\nIn the following algorithm $(cv_i,cp_i,0,0)$ represents the floating point\nconstant $(2 \\cdot \\log_2 e)/(2 \\cdot i+1)$.\n\\begin{enumerate}\n\\item $M \\asn \\ceil{ \\ell/(2 \\cdot \\log_2 3)-1/2}$.\n\\item $(\\sshare{v_2},\\sshare{p_2},0,0,0) \\asn \\mathsf{FLSub}((2^{\\ell-1},-(\\ell-1),0,0,0),(\\sshare{v_1},-\\ell,0,0,0))$.\n\\item $(\\sshare{v_3},\\sshare{p_3},0,0,0) \\asn \\mathsf{FLAdd}((2^{\\ell-1},-(\\ell-1),0,0,0),(\\sshare{v_1},-\\ell,0,0,0))$.\n\\item $(\\sshare{v_y},\\sshare{p_y},0,0,0) \\asn \\mathsf{FLDiv}((\\sshare{v_2},\\sshare{p_2},0,0,0),(\\sshare{v_3},\\sshare{p_3},0,0,0))$.\n\\item $(\\sshare{v_{y^2}},\\sshare{p_{y^2}},0,0,0) \\asn \\mathsf{FLMult}((\\sshare{v_y},\\sshare{p_y},0,0,0),(\\sshare{v_y},\\sshare{p_y},0,0,0))$.\n\\item $(\\sshare{v},\\sshare{p},0,0,0) \\asn  \\mathsf{FLMult}((\\sshare{v_y},\\sshare{p_y},0,0),(cv_0,cp_0,0,0))$.\n\\item For $i \\in[1,\\ldots,M]$ do\n\\begin{enumerate}\n  \\item $(\\sshare{v_y},\\sshare{p_y},0,0,0) \\asn \\mathsf{FLMult}((\\sshare{v_y},\\sshare{p_y},0,0,0),(\\sshare{v_{y^2}},\\sshare{p_{y^2}},0,0,0))$.\n  \\item $(\\sshare{v_2},\\sshare{p_2},0,0,0) \\asn \\mathsf{FLMult}((\\sshare{v_y},\\sshare{p_y},0,0,0),(cv_i,cp_i,0,0,0))$.\n  \\item $(\\sshare{v},\\sshare{p},0,0,0) \\asn \\mathsf{FLAdd}((\\sshare{v},\\sshare{p},0,0,0),(\\sshare{v_2},\\sshare{p_2},0,0,0))$.\n\\end{enumerate}\n\\item $(\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}) \\asn \\mathsf{Int2FL}(\\ell,-\\sshare{p},\\ell,\\ell)$.\n\\item $(\\sshare{v},\\sshare{p},\\sshare{z},\\sshare{s},\\sshare{\\err}) \\asn \\mathsf{FLSub}((\\sshare{v_2},\\sshare{p_2},\\sshare{z_2},\\sshare{s_2},\\sshare{\\err_2}),(\\sshare{v},\\sshare{p},0,0,0))$.\n\\item $\\sshare{a} \\asn \\mathsf{EQ}(\\sshare{p_1},-(\\ell-1),k)$.\n\\item $\\sshare{b} \\asn \\mathsf{EQ}(\\sshare{v_1},2^{\\ell-1},\\ell)$.\n\\item $\\sshare{z} \\asn \\sshare{a} \\cdot \\sshare{b}$.\n\\item $\\sshare{v} \\asn \\sshare{v} \\cdot(1-\\sshare{z})$.\n\\item $\\sshare{\\err} \\asn \\mathsf{OR}(\\sshare{\\err},\\sshare{\\err_1})$.\n\\item $\\sshare{\\err} \\asn \\mathsf{OR}(\\mathsf{OR}(\\sshare{z_1},\\sshare{s_1}),\\err)$.\n\\item $\\sshare{p} \\asn \\sshare{p} \\cdot(1-\\sshare{z})$.\n\\item Return $(\\sshare{v},\\sshare{p},\\sshare{z_1},\\sshare{s_1},\\sshare{\\err})$.\n\\end{enumerate}\n\n\n\\msubsection{Trigonometic Functions}\nAll three basic trigonometric functions support inputs of either \nfixed point or floating point precision. \nWith the output type being equal to the input type.\nThe computation of $\\sin(x)$ and $\\cos(x)$ are performed\nusing polnoymial approximations, with the computation of $\\tan(x)$ \ndone via $\\sin(x)/\\cos(x)$.\nThe basic idea for $\\sin(x)$ and $\\cos(x)$ is to first reduce\nthe argument $x$ into the range $[0,\\ldots,2 \\pi)$, so\nas to obtain a new argument (which we call $y$)\nWe then compute a bit $b_1$ to test as to whether\n$y \\in [0,\\pi)$ or $[\\pi,2 \\pi)$ (with $0$ being\nthe former).\nWe then reduce $y$ to $z$ by reducing it into the range\n$[0,\\pi)$, and compute a bit $b_2$ which says whether\n$z$ is in the range $[0,\\pi/2)$ or $[\\pi/2,\\pi)$.\nWe finally reduce $z$ into the range $[0,\\pi/2)$ resulting \nin $w$.\nThen a polynomial is used to compute\n$\\sin(w)$ or $\\cos(w)$, which means\nwe need to now {\\em scale} $w$ into the range $[0,1)$\nto obtain $v$.\n%We then derive the final result using the following \n%identities:\n%\\begin{align*}\n%\t\\sin(x) &= \\sin(y) = (1-2 \\cdot b_1) \\cdot \\sin(z), %\\\\\n%\t\\cos(x) &= \\cos(y) = (1-2 \\cdot b_1) \\cdot \\cos(z), %\\\\\n%\t\\sin(z) &= (1-b_2) \\cdot \\sin(w) + b_2\\cdot \\cos(w), %\\\\\n%\t\\cos(z) &= (1-b_2) \\cdot \\cos(w) - b_2\\cdot \\sin(w).\n%\\end{align*}\nFor the polynomial approximations to the basic functions in\nthe range $[0,\\pi/2)$, where the argument is given as $w = v \\cdot \\pi/2$\nwe use the following approximations from Hart's book \\cite{Hart:1978:CA:540084}\n\\begin{align*} \n\t\\sin(w) &= v \\cdot P_{3307}(v^2), \\\\\n\t\\cos(w) &= P_{3508}(v^2).\n\\end{align*}\nWhere we have\n\\begin{center}\n\\begin{tabular}{|c||c|l||c|l|}\n\\hline\n& \\multicolumn{2}{c||}{$P_{3307}$} & \\multicolumn{2}{c|}{$P_{3508}$}  \\\\\n\\hline\n0  &   1  & +.15707 96326 79489 66192 31314 989 &   0 & +.99999 99999 99999 99999 99914 771 \\\\\n1  &   0  & -.64596 40975 06246 25365 51665 255 &   0 & -.49999 99999 99999 99999 91637 437 \\\\\n2  &  -1  & +.79692 62624 61670 45105 15876 375\t&  -1 & +.41666 66666 66666 66653 10411 988 \\\\\n3  &  -2  & -.46817 54135 31868 79164 48035 89  &  -2 & -.13888 88888 88888 88031 01864 15 \\\\\n4  &  -3  & +.16044 11847 87358 59304 30385 5\t&  -4 & +.24801 58730 15870 23300 45157 \\\\\n5  &  -5  & -.35988 43235 20707 78156 5727\t&  -6 & -.27557 31922 39332 25642 1489 \\\\\n6  &  -7  & +.56921 72920 65732 73962 4\t\t&  -8 & +.20876 75698 16541 25915 59 \\\\\n7  &  -9  & -.66880 34884 92042 33722\t\t& -10 & -.11470 74512 67755 43239 4 \\\\\n8  & -11  & +.60669 10560 85201 792\t\t& -13 & +.47794 54394 06649 917 \\\\\n9  & -13  & -.43752 95071 18174 8\t\t& -15 & -.15612 26342 88277 81 \\\\\n10 & -15  & +.25002 85418 9303\t\t\t& -18 & +.39912 65450 7924 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\nNOTE: Polynomial tables are described by the monomial number, the degree of the approximation $p$ and its significand $s$. The coefficient of the $i$th monomial can be obtained by multiplying the significand by $10^{p_{i}}$ as follows: $s_{i} \\cdot 10^{p_{i}}$.\n\n\\msubsubsection{$\\mathsf{F\\star TrigSub}(\\sshare{x})$:}\n\\begin{enumerate}\n\n\\item $\\sshare{f} \\asn \\mathsf{F\\star Mult}(\\sshare{x},(1 /(2 \\cdot \\pi))$\n\\item $\\sshare{f} \\asn \\mathsf{F\\star Floor}(\\sshare{f})$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star Mult}(\\sshare{f},(2 \\cdot \\pi ))$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star Add}(\\sshare{x},-\\sshare{y})$.\n\\item $\\sshare{b_1} \\asn \\mathsf{F\\star GE}(\\sshare{y},(\\pi))$.\n\\item $\\sshare{f} \\asn \\mathsf{F\\star Add}(2 \\cdot \\pi,-\\sshare{y})$\n\\item $w \\asn \\mathsf{F\\star Choose}(\\sshare{f},\\sshare{y}, \\sshare{b_1})$.\n\\item $\\sshare{b_2} \\asn \\mathsf{F\\star GE}(\\sshare{2},(\\pi / 2))$.\n\\item $\\sshare{f} \\asn \\mathsf{F\\star Add}( \\pi,-\\sshare{w})$\n\\item $w \\asn \\mathsf{F\\star Choose}(\\sshare{f},\\sshare{w}, \\sshare{b_2})$.\n\\item Return $(\\sshare{w},\\sshare{b_1},\\sshare{b_2})$.\n\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To reduce the angle you could execute the following (note that this function call is meant to be used internally):\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx = sfix(4) # sfloat(4)\n# returns an angle in the [0,pi/2) interval in w and flags b1 and b2. \nw, b1, b2 = mpc_math.sTrigSub_fx(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{F\\star Sin}(\\sshare{x})$}\nWe present these routines as generic routines given the specific helper subroutine above;\nwe assume an obvious overloading/translation of arguments.\nWe let $\\mathsf{F\\star Choose}(\\sshare{x},\\sshare{y},\\sshare{b})$, for a \nshared bit $b$, denote an operation which produces $\\sshare{x}$ if $\\sshare{b}=1$ \nand $\\sshare{y}$ otherwise\nThis is easily obtained by securely multiplying each component share\nof the data representing $\\sshare{x}$ etc by $\\sshare{b}$.\nSo for fixed point representations this becomes, irrespective of the\nvalues $k$ and $f$,\n\\begin{enumerate}\n\\item $\\sshare{a} \\asn \\sshare{b}\\cdot \\sshare{x}+(1-\\sshare{b}) \\cdot \\sshare{y}$\n\\end{enumerate}\nFor floating point representations this becomes\n\\begin{enumerate}\n\\item $\\sshare{w}, \\sshare{b_1}, \\sshare{b_2} \\asn \\mathsf{F\\star TrigSub}(\\sshare{x})$\n\\item $\\sshare{v} \\asn \\sshare{w} \\cdot (1/(\\pi/2))$.\n\\item $\\sshare{b} \\asn \\mathsf{F\\star Choose}(\\sshare{-1},\\sshare{1}, \\sshare{b_1})$.\n\\item $\\sshare{\\sin(v)} \\asn \\sshare{v} \\cdot \\mathsf{F\\star Pol}(P_{3307},\\sshare{v^2})$.\n\\item Return $(\\sshare{b} \\cdot \\sshare{\\sin(v)})$.\n\\end{enumerate}\n%\n%Given this we can now compute $\\sin(x)$ in the following lines:\n%\\begin{enumerate} \n%\\item $(\\sshare{\\sin(w)},\\sshare{\\cos(w)},\\sshare{b_1},\\sshare{b_2}) \\asn \\mathsf{F\\star TrigSub}(\\sshare{x})$.\n%\\item $\\sshare{\\sin(z)} \\asn \\mathsf{F\\star Choose}(\\sshare{\\sin(w)},\\sshare{\\cos(w)},1-\\sshare{b_2})$.\n%\\item $\\sshare{-\\sin(z)} \\asn \\mathsf{F\\star Neg}(\\sshare{\\sin(z)}$.\n%\\item $\\sshare{\\sin(x)} \\asn \\mathsf{F\\star Choose}(\\sshare{\\sin(z)},\\sshare{-\\sin(z)},1-\\sshare{b_1})$.\n%\\item Return $\\sshare{\\sin(x)}$.\n%\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|sin| of any value, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx = sfix(4) # sfloat(4)\n# returns the sin of a number of any interval\ny = mpc_math.sin(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{F\\star Cos}(\\sshare{x})$}\nLikewise this becomes\n\\begin{enumerate}\n\n\\item $\\sshare{w}, \\sshare{b_1}, \\sshare{b_2} \\asn \\mathsf{F\\star TrigSub}(\\sshare{x})$\n\\item $\\sshare{v} \\asn \\sshare{w}$.\n\\item $\\sshare{b} \\asn \\mathsf{F\\star Choose}(\\sshare{-1},\\sshare{1}, \\sshare{b_2})$.\n\\item $\\sshare{\\cos(v)} \\asn  \\mathsf{F\\star Pol}(P_{3308},\\sshare{v^2})$.\n\\item Return $(\\sshare{b} \\cdot \\sshare{\\cos(v)})$.\n\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|sin| of any value, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx = sfix(4) # sfloat(4)\n# returns the cos of an angle on any interval\ny = mpc_math.cos(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{F\\star Tan}(\\sshare{x})$}\nLikewise this becomes\n\\begin{enumerate} \n\n\\item $(\\sshare{w},\\sshare{b_1},\\sshare{b_2}) \\asn \\mathsf{F\\star TrigSub}(\\sshare{x})$.\n\\item $\\sshare{v} \\asn \\sshare{w} \\cdot (1/(\\pi/2))$.\n\\item $\\sshare{b} \\asn \\mathsf{F\\star Choose}(\\sshare{-1},\\sshare{1}, \\sshare{b_1})$.\n\\item $\\sshare{\\sin(v)} \\asn \\sshare{v} \\cdot \\mathsf{F\\star Pol}(P_{3307},\\sshare{v^2})$.\n\\item $\\sshare{\\sin(x)} \\asn (\\sshare{b} \\cdot \\sshare{\\sin(v)})$.\n\\item $\\sshare{v} \\asn \\sshare{w}$.\n\\item $\\sshare{b} \\asn \\mathsf{F\\star Choose}(\\sshare{-1},\\sshare{1}, \\sshare{b_2})$.\n\\item $\\sshare{\\cos(v)} \\asn  \\mathsf{F\\star Pol}(P_{3308},\\sshare{v^2})$.\n\\item $\\sshare{\\sin(x)} \\asn (\\sshare{b} \\cdot \\sshare{\\cos(v)})$.\n\\item $\\sshare{\\tan(x)} \\asn \\mathsf{F\\star Div}(\\sshare{\\sin(x)},\\sshare{\\cos(x)})$.\n\\item Return $\\sshare{\\tan(x)}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|tan| of any value, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx = sfix(4) # sfloat(4)\n# returns the tan of an angle on any interval\ny = mpc_math.tan(x)\n\\end{lstlisting}\n\n\\msubsection{Inverse Trigonometric Functions}\n\\todo{Given that SCALE-MAMBA currently only supports square root operations for sfix inputs, \ninverse trigonometric functions are restricted to sfix inputs.}\nTo obtain  $\\arcsin$ and $\\arccos$ one makes use of the formula:\n\\begin{align*}\n \\arcsin (x) &= \\arctan \\left( \\frac{x}{\\sqrt{1-x^2}} \\right), \\\\\n \\arccos (x) &= \\frac{\\pi}{2} - \\arcsin (x). \n\\end{align*}\nNote, that $\\arcsin$ and $\\arccos$ are only defined when \n$|x|\\le 1$.\nThe value of $\\arctan(x)$ is however defined for all real $x$.\nFor $\\arctan(x)$ we first reduce to positive values of $x$ by using the formula\n\\[ \\arctan(-x) = - \\arctan(x). \\]\nWe then reduce to the interval $[0,1)$ using the formula\n\\[ \\arctan(x) = \\frac{\\pi}{2} - \\arctan\\left(\\frac{1}{x} \\right). \\]\nThe final approximation to $\\arctan(x)$ for $x \\in [0,1)$\nis obtained using the Pade approximation $P_{5102}/Q_{5102}$\nfrom Hart's book \\cite{Hart:1978:CA:540084}.\nWhere the polynomials are represented as in our earlier \ndescriptions.\n\\begin{center}\n\\begin{tabular}{|c||c|l||c|l|}\n\\hline\n& \\multicolumn{2}{c||}{$P_{5102}$} & \\multicolumn{2}{c|}{$Q_{5102}$}  \\\\\n\\hline\n0  &  5  & +.21514 05962 60244 19331 93254 468 & 5 & +.21514 05962 60244 19331 93298 234 \\\\\n1  &  5  & +.73597 43380 28844 42408 14980 706 & 5 & +.80768 78701 15592 48851 76713 209 \\\\\n2  &  6  & +.10027 25618 30630 27849 70511 863 & 6 & +.12289 26789 09278 47762 98743 322 \\\\ \n3  &  5  & +.69439 29750 03225 23370 59765 503 & 5 & +.97323 20349 05355 56802 60434 387 \\\\\n4  &  5  & +.25858 09739 71909 90257 16567 793 & 5 & +.42868 57652 04640 80931 84006 664 \\\\ \n5  &  4  & +.50386 39185 50126 65579 37791 19  & 5 & +.10401 13491 56689 00570 05103 878 \\\\ \n6  &  3  & +.46015 88804 63535 14711 61727 227 & 4 & +.12897 50569 11611 09714 11459 55  \\\\ \n7  &  2  & +.15087 67735 87003 09877 17455 528 & 2 & +.68519 37831 01896 80131 14024 294 \\\\\n8  & -1  & +.75230 52818 75762 84445 10729 539 & 1 & +.1 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nThe following protocol for \\verb|arcsin| implements the formulas from before. \nThe protocol and its implementation, make use of our secure implementation of Square Root. \nThis method is implemented, and it is used to derive \\verb|arccos|.\n\n\\msubsubsection{$\\mathsf{F\\star ArcSin}(\\sshare{x})$}\n\\begin{enumerate}\n\\item $\\sshare{x^2} \\asn \\mathsf{F\\star Mult}(\\sshare{x},\\sshare{x})$.\n\\item $\\sshare{-x^2} \\asn \\mathsf{F\\star Neg}(\\sshare{x^2})$.\n\\item $\\sshare{1-x^2} \\asn \\mathsf{F\\star Add}(1,\\sshare{-x^2})$.\n\\item $\\sshare{\\sqrt{1-x^2}} \\asn \\mathsf{F\\star Sqrt}(1,\\sshare{1-x^2})$.\n\\item $\\sshare{v} \\asn \\mathsf{F\\star Div}(\\sshare{x},\\sshare{\\sqrt{1-x^2}})$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star ArcTan}(\\sshare{v})$.\n\\item If $\\star=\\mathsf{L}$\n\\begin{enumerate}\n  \\item $\\sshare{|x|} \\asn \\mathsf{FLAbs}(\\sshare{x})$.\n  \\item $\\sshare{y_\\err} \\asn \\mathsf{FLGT}(\\sshare{|x|},1.0)$.\n\\end{enumerate}\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|arcSin| on the  (-1,1) interval, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx =sfix(0.5)\n# returns the tan of an angle on any interval\ny = mpc_math.asin(x)\n\\end{lstlisting}\n\n\n\\msubsubsection{$\\mathsf{F\\star ArcCos}(\\sshare{x})$}\n\\begin{enumerate}\n\\item $\\sshare{y} \\asn \\mathsf{F\\star ArcSin}(\\sshare{x})$.\n\\item $\\sshare{-y} \\asn \\mathsf{F\\star Neg}(\\sshare{y})$.\n\\item $\\sshare{\\pi/2-y} \\asn \\mathsf{F\\star Add}(\\pi/2,\\sshare{-y})$.\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|arcCos| of any value on the (-1,1) interval, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx =sfix(0.5)\n# returns the tan of an angle on any interval\ny = mpc_math.acos(x)\n\\end{lstlisting}\n\n\\msubsubsection{$\\mathsf{F\\star ArcTan}(\\sshare{x})$}\n\\begin{enumerate}\n\\item $\\sshare{s} \\asn \\mathsf{F\\star LTZ}(\\sshare{z})$.\n\\item $\\sshare{|x|} \\asn \\mathsf{F\\star Abs}(\\sshare{x})$.\n\\item $\\sshare{b} \\asn \\mathsf{F\\star GT}(\\sshare{|x|},1.0)$.\n\\item $\\sshare{v} \\asn \\mathsf{F\\star Div}(1,\\sshare{|x|})$.\n\\item $\\sshare{v} \\asn \\mathsf{F\\star Choose}(\\sshare{|x|},\\sshare{v},1-\\sshare{b})$.\n\\item $\\sshare{v^2} \\asn \\mathsf{F\\star Mul}(\\sshare{v},\\sshare{v})$.\n\\item $\\sshare{y} \\asn \\mathsf{FxPade}(P_{5102},Q_{5102},\\sshare{v^2})$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star Mul}(\\sshare{v},\\sshare{y})$.\n\\item $\\sshare{\\pi/2-y} \\asn \\mathsf{F\\star Sub}(\\pi/2,\\sshare{y})$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star Choose}(\\sshare{y},\\sshare{\\pi/2-y},1-\\sshare{b})$.\n\\item $\\sshare{-y} \\asn \\mathsf{F\\star Neg}(\\sshare{y})$.\n\\item $\\sshare{y} \\asn \\mathsf{F\\star Choose}(\\sshare{y},\\sshare{-y},1-\\sshare{s})$.\n\\item Return $\\sshare{y}$.\n\\end{enumerate}\n\n\\paragraph{MAMBA Example:} To obtain the \\verb|arcTan| of any value, you could execute the following:\n\\begin{lstlisting}[language={python}]\nfrom Compiler import mpc_math\nx =sfix(0.5)\n# returns the tan of an angle on any interval\ny = mpc_math.atan(x)\n\\end{lstlisting}\n", "meta": {"hexsha": "e09feae02756543d2a97c22f1a07207b09cbd0b6", "size": 102905, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Advanced.tex", "max_stars_repo_name": "ggessner/SCALE-MAMBA", "max_stars_repo_head_hexsha": "d8bc74e910f531d9514ea267c29bb35a769a9de5", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documentation/Advanced.tex", "max_issues_repo_name": "ggessner/SCALE-MAMBA", "max_issues_repo_head_hexsha": "d8bc74e910f531d9514ea267c29bb35a769a9de5", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2019-11-11T04:54:12.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-07T04:55:19.000Z", "max_forks_repo_path": "Documentation/Advanced.tex", "max_forks_repo_name": "ggessner/SCALE-MAMBA", "max_forks_repo_head_hexsha": "d8bc74e910f531d9514ea267c29bb35a769a9de5", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-08-14T08:26:28.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T20:22:17.000Z", "avg_line_length": 45.4326710817, "max_line_length": 473, "alphanum_fraction": 0.6600553909, "num_tokens": 41377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.43475240577324176}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{geometry}\n\\usepackage[utf8]{inputenc}\n\\usepackage{enumitem}\n\\usepackage{physics}\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1em}\n\\relpenalty=10000\n\\binoppenalty=10000\n\n\\begin{document}\n\\section*{Combinatorial geometry}\n\t\\begin{enumerate}\n\t\t\\item % PKV 10 2017\n\t\tThere are $5$ points on the plane, no three of them lie on the same line. Prove that there exists $4$ of them which form a convex quadrilateral\n\t\t\\item % LVS V 2017\n\t\tA finite number of points is chosen on the plane, no three of them lie on the same line. It is known that there exists a non-convex polygons with its vertices at given points. Prove that there exists a non-convex quadrilateral with its vertices at given points.\n\t\t\\item % BT 2017\n\t\tLet $n \\geq 3$ be an integer. Find the largest number of angles which can be greater than $180^\\circ$ in an $n$-gon whose sides are all equal.\n\t\t\\item % LPV 11 2016\n\t\tEvery point on the sides of an equilateral triangle is coloured either red or blue. Is it always possible to find a right angle triangle with all its vertices having the same colour.\n\t\t\\item % PKV 11 2016\n\t\tProve that there are more than $30000$ points with integral coordinates which lie within a circle of radius $100$.\n\t\t\\item % VV 2013\n\t\tThere are $n$ points on the plane. Starting from one of those points, in each step we move to the second closest point. After $n$ steps we have visited all the points and returned to the original point. Find all possible values for $n$.\n\t\t\\item % http://www.math.olympiaadid.ut.ee/arhiiv/valik/vv2018/tvv2018.pdf ül5\n\t\tLet $k$ be a positive integer. Find all positive integers $n$ for which it is possible to choose $n$ points on the sides of a triangle (different from its vertices) and connect some of them with a line such that\n\t\t\\begin{enumerate}\n\t\t\t\\item There is at least $1$ point on each side\n\t\t\t\\item For each pair of points $X$ and $Y$ which are on different sides of the triangle, there exists exactly $k$ points on the third side which are all connected to both $X$ and $Y$, and exactly $k$ points which are all connected to neither of $X$ or $Y$.\n\t\t\\end{enumerate}\n\n  \\end{enumerate}\n\\end{document}\n", "meta": {"hexsha": "6680b6272d4ca7ee17fb701b987bb24cdaf8e3b8", "size": 2217, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "16_combinatorial-geometry.tex", "max_stars_repo_name": "ZhaoWanLong/maths-olympiad", "max_stars_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-21T21:57:43.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-21T21:57:43.000Z", "max_issues_repo_path": "16_combinatorial-geometry.tex", "max_issues_repo_name": "ZhaoWanLong/maths-olympiad", "max_issues_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "16_combinatorial-geometry.tex", "max_forks_repo_name": "ZhaoWanLong/maths-olympiad", "max_forks_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-08T07:04:43.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-08T07:04:43.000Z", "avg_line_length": 59.9189189189, "max_line_length": 263, "alphanum_fraction": 0.751014885, "num_tokens": 645, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.434736819531647}}
{"text": "\\subsection{Attention}\n\\label{text:approach/runtime/filtering}\nFor a trajectory optimization to be feasible for online applications, it must be efficient to solve. As empirically shown by experiments in Section \\ref{text:experiments/unit}, the computational bottleneck of solving Problem \\ref{problem:general} is evaluating and, particularly, differentiating the components, which depend on the interaction between robot and pedestrians. By design, the computational cost of the safety constraint has already been reduced. However, the interactive cost presented in Section \\ref{text:approach/objective/interactive} cannot be further runtime optimized or occluded, being one of the core parts of the underlying algorithm. Therefore there are mostly two ways to increase overall runtime efficiency of the trajectory optimization: Firstly, reducing the number of solver iterations for convergence and secondly lowering the runtime cost of evaluating the optimization components itself.\n\\newline\nWhile the number of solver iterations has already largely been reduced by warm-starting the optimization, the attention focusses on merely taking into account essential factors into the evaluation, with improves runtime without having a significant impact on the resulting behavior of the algorithm. Accurately, the attention filter decides which pedestrians are taken into account for a specific (interactive objective) function evaluation. Importantly to note here, that attention merely effects the evaluation of the interactive objective function (including its gradient computation). Especially, it is not applied to the safety-relevant constraints, to guarantee safety regarding all pedestrians at every time.    \n\\newline\nUsing the distance between the robot as each pedestrian is a natural choice for filtering out the agents to consider for the trajectory optimization; the larger the distance is, the smaller the impact of the robot probably is. In fact, the Trajectron model uses a similar distance-based metric for building and evaluating edges in their graph network \\cite{Salzmann2020}.\n\n\\begin{equation}\n\\attention(\\x, \\xped[k]) = \\left( ||\\x - \\xped[k]||_2 > D_{Attention} \\right)\n\\end{equation}\n\nAlthough euclidean distance-based filtering is a quite naive way of distributing attention to pedestrians in the scene, it shows to be quite effective in reducing the runtime of the interactive objective and gradient evaluations, and therefore of the whole algorithm. A comparison to more sophisticated approaches such as using (forward) reachability to conservatively estimate the pedestrians that eventually could impinge on the robot trajectory, or focussing on only a specific pedestrian instead of a set of pedestrians, as used by game-theoretic crowd navigation works (as presented in Chapter \\ref{text:related/crowd_navigation}, e.g.\\,  \\cite{Bouzat2014}\\cite{Nikolaidis2017}), is given in Section \\ref{text:experiments/unit}.\n", "meta": {"hexsha": "0a5f96e71d4930cbd38c2fbf84e3cafa49fb032c", "size": 2940, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/runtime_attention.tex", "max_stars_repo_name": "simon-schaefer/mantrap", "max_stars_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-05-11T18:13:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:52:48.000Z", "max_issues_repo_path": "report/thesis/runtime_attention.tex", "max_issues_repo_name": "StanfordASL/mantrap", "max_issues_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/runtime_attention.tex", "max_forks_repo_name": "StanfordASL/mantrap", "max_forks_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-12-09T00:03:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T10:39:03.000Z", "avg_line_length": 210.0, "max_line_length": 920, "alphanum_fraction": 0.8207482993, "num_tokens": 576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.43473027436533}}
{"text": "\n\\documentclass[12pt]{amsart}\n\\usepackage[margin=0.5in]{geometry} \n  % see geometry.pdf on how to lay out the page. There's lots.\n\\usepackage{bsymb}\n\\usepackage{calculation}\n\\usepackage{ulem}\n\\usepackage{hyperref}\n\\usepackage{unitb}\n\n\\newcommand{\\REQ}{\\text{REQ}}\n\\newcommand{\\OBJ}{\\mathcal{O}bj}\n\\newcommand{\\Node}{\\mathcal{N}ode}\n\\newcommand{\\Addr}{\\mathcal{P}tr}\n\\newcommand{\\link}{\\textit{LINK}}\n\\newcommand{\\trash}{\\textit{TRASH}}\n\\newcommand{\\shared}{\\textit{SHARED}}\n\\newcommand{\\State}{\\mathcal{S}tate}\n\\newcommand{\\cEmpty}{\\text{``empty''}}\n\\newcommand{\\cNonEmpty}{\\text{``non-empty''}}\n\\newcommand{\\cInit}{\\text{``init''}}\n\\newcommand{\\cPopped}{\\text{``popped''}}\n\\newcommand{\\cBot}{\\text{``idle''}}\n\n\\begin{document}\n\n\\tableofcontents\n\n\\section{m0}\n\\input{pop-left/machine_m0}\n\\begin{machine}{m0}\n    \\with{functions}\n    \\with{sets}\n    \\[ \\newset{\\Addr_0} \\]\n    \\[ \\constant{ dummy : \\Addr_0} \\]\n    \\[ \\constant{ \\bot : \\OBJ_0} \\]\n    \\[ \\definition\n        {\\Addr}{ \\Addr_0 \\setminus \\{ dummy \\} } \\]\n    \\[ \\definition\n        {\\OBJ}{ \\OBJ_0 \\setminus \\{ \\bot \\} } \\]\n    \\[ \\definition\n        {\\Node}{ [ 'item : \\OBJ_0 \\setminus \\{ \\bot \\} ] } \\]\n    \\[\\newset{\\OBJ_0}\\]\n\nshared:\n    \\[ \\variable{ LH, RH : \\Addr_0 } \\]\n    \\[ \\variable{ free : \\set [\\Addr_0] } \\]\n    \\[ \\variable{ ver : \\Int } \\]\n    \\[ \\variable{ result : \\OBJ_0 } \\]\n    \\[ \\variable{ \\link, \\trash : \\Addr_0 \\pfun \n        \\{ 'item : \\OBJ_0 \n         , 'left : \\Addr_0\n         , 'right : \\Addr_0  \\} } \\]\n\nprivate:\n    \\[ \\variable{ popL,remL : \\Bool } \\]\n    \\[ \\variable{ resL : \\OBJ_0 } \\]\n\n\\begin{align*}\n  \\initialization{m0:init0}{ LH = dummy } \\\\\n  \\initialization{m0:init1}{ RH = dummy } \\\\\n  \\initialization{m0:init2}{ free = \\Addr } \\\\\n  \\initialization{m0:init3}{ ver = 0 } \\\\\n  \\initialization{m0:init4}{ result = \\bot } \\\\\n  \\initialization{m0:init5}{ \\link = \\emptyfun } \\\\\n  \\initialization{m0:init6}{ \\trash = \\emptyfun } \\\\\n  \\initialization{m0:init7}{ popL = \\false } \\\\\n  \\initialization{m0:init8}{ remL = \\false } \\\\\n  \\initialization{m0:init9}{ resL = \\bot } \\\\\n\\end{align*}\n\ninternal:\n\\newevent{add:popL}{req\\_popL}\n\\newevent{hdl:popL:empty}{hdl\\_popL\\_empty}\n\\newevent{hdl:popL:one}{hdl\\_popL\\_one}\n\\newevent{hdl:popL:more}{hdl\\_popL\\_more}\n\\newevent{returnL}{returnL}\n\n\\begin{align*}\n    \\evguard{add:popL}{m0:grd0}{\\neg popL} \\\\\n    \\evbcmeq{add:popL}{m0:act0}{popL}{\\true} \\\\\n    \\cschedule{returnL}{m0:sch0}{remL} \\\\\n    \\evbcmeq{returnL}{m0:act0}{result}{resL} \\\\\n    \\evbcmeq{returnL}{m0:act1}{remL}{\\false} \\\\    \n\\end{align*}\n\n\\begin{align*}\n  \\theorem{m0:thm0:ASM}{ LH \\in \\dom.\\link \\bunion \\{ dummy \\} } \\\\\n  \\theorem{m0:thm1:ASM}{ RH \\in \\dom.\\link \\bunion \\{ dummy \\} } \\\\\n  \\theorem{m0:thm2:ASM}{ \\neg LH \\in \\dom.\\trash  } \\\\\n  \\theorem{m0:thm3:ASM}{ \\neg RH \\in \\dom.\\trash  } \\\\\n  \\invariant{m0:inv0}{ free \\subseteq \\Addr }\n\\end{align*}\n\n\\[ \\indices{hdl:popL:empty}{ v : \\Int } \\]\n\\[ \\indices{hdl:popL:one}{ v : \\Int } \\]\n\\[ \\indices{hdl:popL:more}{ v : \\Int } \\]\n\n\\begin{align*}\n  \\cschedule{hdl:popL:empty}{m0:sch0}{v = ver} \\\\\n  \\cschedule{hdl:popL:one}{m0:sch0}{v = ver} \\\\\n  \\cschedule{hdl:popL:more}{m0:sch0}{v = ver} \\\\\n  \\cschedule{hdl:popL:empty}{m0:sch1}{popL} \\\\\n  \\cschedule{hdl:popL:one}{m0:sch1}{popL} \\\\\n  \\cschedule{hdl:popL:more}{m0:sch1}{popL} \\\\\n  \\cschedule{hdl:popL:empty}{m0:sch2}{LH = dummy} \\\\\n  \\cschedule{hdl:popL:one}{m0:sch2}{\\neg LH = dummy} \\\\\n  \\cschedule{hdl:popL:more}{m0:sch2}{\\neg LH = dummy} \\\\\n  \\cschedule{hdl:popL:one}{m0:sch3}{LH = RH} \\\\\n  \\cschedule{hdl:popL:more}{m0:sch3}{\\neg LH = RH} \\\\\n  \\evbcmeq{hdl:popL:empty}{m0:act0}\n    {ver}{ver + 1} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act0}\n    {ver}{ver + 1} \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act0}\n    {ver}{ver + 1} \\\\\n  \\evbcmeq{hdl:popL:empty}{m0:act1}\n    {popL}{\\false} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act1}\n    {popL}{\\false} \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act1}\n    {popL}{\\false} \\\\\n  \\evbcmeq{hdl:popL:empty}{m0:act2}\n    {remL}{\\true} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act2}\n    {remL}{\\true} \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act2}\n    {remL}{\\true} \\\\\n  \\evbcmeq{hdl:popL:empty}{m0:act3}\n    {resL}{\\bot} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act3}\n    {resL}{\\link.LH.'item} \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act3}\n    {resL}{\\link.LH.'item} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act4}\n    {\\trash}{\\trash \\1| LH \\fun \\link.LH} \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act4}\n    {\\trash}{\\trash \\1| LH \\fun \\link.LH} \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act5}\n    {\\link}{ \\{LH\\} \\domsub \\link } \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act5}\n    {\\link}{ \\{LH\\} \\domsub \\link } \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act6}\n    {LH}{ dummy } \\\\\n  \\evbcmeq{hdl:popL:one}{m0:act7}\n    {RH}{ dummy } \\\\\n  \\evbcmeq{hdl:popL:more}{m0:act6}\n    {LH}{ \\link.LH.'right } \\\\\n\\end{align*}\n\nexternal:\n\\newevent{ext:pushL:empty}{EXT\\_pushL\\_empty}\n\\newevent{ext:pushL:non:empty}{EXT\\_pushL\\_non\\_empty}\n\\newevent{ext:pushR:empty}{EXT\\_pushR\\_empty}\n\\newevent{ext:pushR:non:empty}{EXT\\_pushR\\_non\\_empty}\n\\newevent{ext:popL:empty}{EXT\\_popL\\_empty}\n\\newevent{ext:popL:one}{EXT\\_popL\\_one}\n\\newevent{ext:popL:more}{EXT\\_popL\\_more}\n\\newevent{ext:popR:empty}{EXT\\_popR\\_empty}\n\\newevent{ext:popR:one}{EXT\\_popR\\_one}\n\\newevent{ext:popR:more}{EXT\\_popR\\_more}\n\\newevent{ext:return}{EXT\\_return}\n\n\\paragraph{pushL --- empty}\n\n\\begin{align*}\n  \\param{ext:pushL:empty}{x : \\OBJ_0 } \\\\\n  \\param{ext:pushL:empty}{n : \\Addr_0 } \\\\\n\\end{align*}\n\n\\begin{align*}\n  \\evguard{ext:pushL:empty}{m0:grd0}{LH = dummy } \\\\\n  \\evguard{ext:pushL:empty}{m0:grd1}{x \\in \\OBJ } \\\\\n  \\evguard{ext:pushL:empty}{m0:grd2}{n \\in free } \\\\\n  \\evbcmeq{ext:pushL:empty}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:pushL:empty}{m0:act1}\n      {free}{free \\setminus \\{ n \\} } \\\\\n  \\evbcmeq{ext:pushL:empty}{m0:act2}\n      {\\link}{\\link \\1| n \\fun \n          \\left[ \\begin{array}{l}\n            'item := x, \\\\\n            'left := dummy, \\\\\n            'right := dummy\n          \\end{array} \\right] } \\\\\n  \\evbcmeq{ext:pushL:empty}{m0:act3}\n      {LH}{n} \\\\\n  \\evbcmeq{ext:pushL:empty}{m0:act4}\n      {RH}{n} \\\\\n\\end{align*}\n\n\\paragraph{pushL --- non-empty}\n\n\n\\begin{align*}\n  \\param{ext:pushL:non:empty}{x : \\OBJ_0 } \\\\\n  \\param{ext:pushL:non:empty}{n : \\Addr_0 } \\\\\n\\end{align*}\n\n\\begin{align*}\n  \\evguard{ext:pushL:non:empty}\n    {m0:grd0}{ \\neg LH = dummy } \\\\\n  \\evguard{ext:pushL:non:empty}\n    {m0:grd1}{x \\in \\OBJ } \\\\\n  \\evguard{ext:pushL:non:empty}\n    {m0:grd2}{n \\in free } \\\\\n  \\evbcmeq{ext:pushL:non:empty}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:pushL:non:empty}{m0:act1}\n      {free}{free \\setminus \\{ n \\} } \\\\\n  \\evbcmeq{ext:pushL:non:empty}{m0:act2}\n      {\\link}{\\link \\1| n \\fun \n          \\left[ \\begin{array}{l}\n            'item := x, \\\\\n            'left := dummy, \\\\\n            'right := LH\n          \\end{array} \\right] } \\\\\n  \\evbcmeq{ext:pushL:non:empty}{m0:act3}\n      {LH}{n} \\\\\n  \\evbcmeq{ext:pushL:non:empty}{m0:act4}\n      {\\link}{ \\link \\1| LH \\fun \n        (\\link.LH) [ 'left := n ] } \\\\\n\\end{align*}\n\n\\paragraph{pushR --- empty}\n\n\n\\begin{align*}\n  \\param{ext:pushR:empty}{x : \\OBJ_0 } \\\\\n  \\param{ext:pushR:empty}{n : \\Addr_0 } \\\\\n\\end{align*}\n\n\\begin{align*}\n  \\evguard{ext:pushR:empty}\n      {m0:grd0}{RH = dummy } \\\\\n  \\evguard{ext:pushR:empty}\n      {m0:grd1}{x \\in \\OBJ } \\\\\n  \\evguard{ext:pushR:empty}\n      {m0:grd2}{n \\in free } \\\\\n  \\evbcmeq{ext:pushR:empty}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:pushR:empty}{m0:act1}\n      {free}{free \\setminus \\{ n \\} } \\\\\n  \\evbcmeq{ext:pushR:empty}{m0:act2}\n      {\\link}{\\link \\1| n \\fun \n          \\left[ \\begin{array}{l}\n            'item := x, \\\\\n            'left := dummy,\n            'right := dummy\n          \\end{array} \\right] } \\\\\n  \\evbcmeq{ext:pushR:empty}{m0:act3}\n      {LH}{n} \\\\\n  \\evbcmeq{ext:pushR:empty}{m0:act4}\n      {RH}{n} \\\\\n\\end{align*}\n\n\\paragraph{pushR --- non-empty}\n\n\\begin{align*}\n  \\param{ext:pushR:non:empty}{x : \\OBJ_0 } \\\\\n  \\param{ext:pushR:non:empty}{n : \\Addr_0 } \\\\\n\\end{align*}\n\n\\begin{align*}\n  \\evguard{ext:pushR:non:empty}\n    {m0:grd0}{ \\neg RH = dummy } \\\\\n  \\evguard{ext:pushR:non:empty}\n    {m0:grd1}{x \\in \\OBJ } \\\\\n  \\evguard{ext:pushR:non:empty}\n    {m0:grd2}{n \\in free } \\\\\n  \\evbcmeq{ext:pushR:non:empty}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:pushR:non:empty}{m0:act1}\n      {free}{free \\setminus \\{ n \\} } \\\\\n  \\evbcmeq{ext:pushR:non:empty}{m0:act2}\n      {\\link}{\\link \\1| n \\fun \n          \\left[ \\begin{array}{l}\n            'item := x, \\\\\n            'left := RH,\n            'right := dummy\n          \\end{array} \\right] } \\\\\n  \\evbcmeq{ext:pushR:non:empty}{m0:act3}\n      {RH}{n} \\\\\n  \\evbcmeq{ext:pushR:non:empty}{m0:act4}\n      {\\link}{ \\link \\1| RH \\fun \n        (\\link.RH) [ 'right := n ] } \\\\\n\\end{align*}\n\n\\paragraph{popL --- empty}\n\n\\begin{align*}\n  \\evguard{ext:popL:empty}\n      {m0:grd0}{LH = dummy} \\\\\n  \\evbcmeq{ext:popL:empty}{m0:act0}\n      {ver}{ver + 1}\n\\end{align*}\n\n\\paragraph{popL --- one}\n\n\\begin{align*}\n  \\evguard{ext:popL:one}\n      {m0:grd0}{\\neg LH = dummy} \\\\\n  \\evguard{ext:popL:one}\n      {m0:grd1}{LH = RH} \\\\\n  \\evbcmeq{ext:popL:one}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:popL:one}{m0:act1}\n      {\\link}{ \\{LH\\} \\domsub \\link } \\\\\n  \\evbcmeq{ext:popL:one}{m0:act2}\n      {LH}{ dummy } \\\\\n  \\evbcmeq{ext:popL:one}{m0:act3}\n      {RH}{ dummy } \\\\\n  \\evbcmeq{ext:popL:one}{m0:act4}\n      {\\trash}{ \\trash \\1| LH \\fun \\link.LH } \\\\\n\\end{align*}\n\n\\paragraph{popL --- more}\n\n\\begin{align*}\n  \\evguard{ext:popL:more}\n      {m0:grd0}{\\neg LH = dummy} \\\\\n  \\evguard{ext:popL:more}\n      {m0:grd1}{\\neg LH = RH} \\\\\n  \\evbcmeq{ext:popL:more}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:popL:more}{m0:act1}\n      {\\link}{ \\{LH\\} \\domsub \\link } \\\\\n  \\evbcmeq{ext:popL:more}{m0:act2}\n      {LH}{ \\link.LH.'right } \\\\\n  \\evbcmeq{ext:popL:more}{m0:act3}\n      {\\trash}{ \\trash \\1| LH \\fun \\link.LH } \\\\\n\\end{align*}\n\n\\paragraph{popR --- empty}\n\n\\begin{align*}\n  \\evguard{ext:popR:empty}\n      {m0:grd0}{RH = dummy} \\\\\n  \\evbcmeq{ext:popR:empty}{m0:act0}\n      {ver}{ver + 1}\n\\end{align*}\n\n\\paragraph{popR --- one}\n\n\\begin{align*}\n  \\evguard{ext:popR:one}\n      {m0:grd0}{\\neg RH = dummy} \\\\\n  \\evguard{ext:popR:one}\n      {m0:grd1}{LH = RH} \\\\\n  \\evbcmeq{ext:popR:one}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:popR:one}{m0:act1}\n      {\\link}{ \\{RH\\} \\domsub \\link } \\\\\n  \\evbcmeq{ext:popR:one}{m0:act2}\n      {LH}{ dummy } \\\\\n  \\evbcmeq{ext:popR:one}{m0:act3}\n      {RH}{ dummy } \\\\\n  \\evbcmeq{ext:popR:one}{m0:act4}\n      {\\trash}{ \\trash \\1| RH \\fun \\link.RH } \\\\\n\\end{align*}\n\n\\paragraph{popR --- more}\n\n\\begin{align*}\n  \\evguard{ext:popR:more}\n      {m0:grd0}{\\neg RH = dummy} \\\\\n  \\evguard{ext:popR:more}\n      {m0:grd1}{\\neg LH = RH} \\\\\n  \\evbcmeq{ext:popR:more}{m0:act0}\n      {ver}{ver + 1} \\\\\n  \\evbcmeq{ext:popR:more}{m0:act1}\n      {\\link}{ \\{RH\\} \\domsub \\link } \\\\\n  \\evbcmeq{ext:popR:more}{m0:act2}\n      {RH}{ \\link.RH.'left } \\\\\n  \\evbcmeq{ext:popR:more}{m0:act3}\n      {\\trash}{ \\trash \\1| RH \\fun \\link.RH } \\\\\n\\end{align*}\n\n\\paragraph{return}\n\n\\end{machine}\n\\section{m1}\n\n\\input{pop-left/machine_m1}\n\n\\begin{machine}{m1}\n  \\refines{m0}\n  \\[ \\newset{\\State} \\]\n  \\[ \\constant{\\cInit : \\State} \\]\n  \\[ \\constant{\\cBot : \\State} \\]\n  \\[ \\constant{\\cPopped : \\State} \\]\n  \\[ \\constant{\\cEmpty : \\State} \\]\n  \\[ \\constant{\\cNonEmpty : \\State} \\]\n  \\[ \\assumption{m0:asm0}{ \\neg \\cInit = \\cBot } \\]\n  \\[ \\assumption{m0:asm1}{ \\neg \\cInit = \\cEmpty } \\]\n  \\[ \\assumption{m0:asm2}{ \\neg \\cInit = \\cNonEmpty } \\]\n  \\[ \\assumption{m0:asm3}{ \\neg \\cInit = \\cPopped } \\]\n  \\[ \\assumption{m0:asm4}{ \\neg \\cBot = \\cEmpty } \\]\n  \\[ \\assumption{m0:asm5}{ \\neg \\cBot = \\cNonEmpty } \\]\n  \\[ \\assumption{m0:asm6}{ \\neg \\cBot = \\cPopped } \\]\n  \\[ \\assumption{m0:asm7}{ \\neg \\cEmpty = \\cNonEmpty } \\]\n  \\[ \\assumption{m0:asm8}{ \\neg \\cEmpty = \\cPopped } \\]\n  \\[ \\assumption{m0:asm9}{ \\neg \\cNonEmpty = \\cPopped } \\]\n  \\[ \\variable{lh : \\Addr_0} \\]\n  \\[ \\variable{state : \\State} \\]\n  \\begin{align*}\n    \\initialization{m1:init0}\n      { lh = dummy } \\\\\n    \\initialization{m1:init2}\n      { state = \\cBot } \\\\\n  \\end{align*}\n\n\\newevent{read:LH}{read\\_LH}\n\n\\begin{align*}\n  \\cschedule{read:LH}{m1:sch0}\n    {state \\in \\{ \\cInit, \\cNonEmpty \\} } \\\\\n  \\cschedule{read:LH}{m1:sch1}\n    { \\neg LH = dummy } \\\\\n  \\evbcmeq{read:LH}{m1:act0}\n    {lh}{LH} \\\\\n  \\evbcmeq{read:LH}{m1:act1}\n    {state}{ \\ifelse{LH = dummy}{\\cEmpty}{\\cNonEmpty} } \\\\\n  \\evbcmeq{read:LH}{m1:act2}\n    {ver}{ \\ifelse{LH = dummy}{ver + 1}{ver} } \\\\\n\\end{align*}\n\n\\subsection{Invariants}\n\n\\begin{align*}\n  \\invariant{m1:inv0}\n    {state = \\cBot & \\3\\equiv \\neg popL \\land \\neg remL} \\\\\n  % \\invariant{m1:inv1}\n  %   {state = \\cInit & \\3\\implies popL} \\\\\n  % \\invariant{m1:inv2}\n  %   {state = \\cNonEmpty & \\3\\implies popL \\land \\neg lh = dummy} \\\\\n  \\invariant{m1:inv3}\n    {popL & \\3\\equiv state \\in \\{\\cInit,\\cNonEmpty\\}} \\\\\n  \\invariant{m1:inv4}\n    { state = \\cPopped & \\3\\implies \\left( \n      \\begin{array}{ll}\n         & remL \\\\\n         \\land & lh \\in \\dom.\\trash \\\\\n         \\land & \\trash.lh.'item = resL\n       \\end{array} \\right) } \\\\\n  \\invariant{m1:inv5}\n    { remL &\\3\\equiv state \\in \\{ \\cPopped, \\cEmpty \\} } \\\\\n  \\invariant{m1:inv7}\n    { \\qforall{p}{p \\in \\dom.\\link}{\\link.p.'item \\in \\OBJ} } \\\\\n  \\invariant{m1:inv6}\n    { state = \\cEmpty & \\3\\equiv remL \\land resL = \\bot } \\\\\n\\end{align*}\n\n\\subsection{State}\n\n\\removevar{popL,remL,resL}\n\n\\removeguard{add:popL}{m0:grd0}\n\\removeact{add:popL}{m0:act0}\n\\begin{align*}\n  \\evguard{add:popL}{m1:grd0}\n    { state = \\cBot } \\\\\n  \\evbcmeq{add:popL}{m1:act0}\n    {state}{ \\cInit } \\\\\n\\end{align*}\n\n\\removeact{hdl:popL:empty}{m0:act0}\n\\removeact{hdl:popL:empty}{m0:act1}\n\\removeact{hdl:popL:empty}{m0:act2}\n\\removeact{hdl:popL:empty}{m0:act3}\n\\removecoarse{hdl:popL:empty}{m0:sch1}\n\\begin{align*}\n  &\\cschedule{hdl:popL:empty}{m1:sch0}\n    { state \\in \\{ \\cInit, \\cNonEmpty \\} } \\\\\n  &\\evbcmeq{hdl:popL:empty}{m1:act0}\n    {lh}{LH} \\\\\n  &\\evbcmeq{hdl:popL:empty}{m1:act1}\n    { state }{ \\ifelse{ LH = dummy }{\\cEmpty}{\\cNonEmpty} } \\\\\n  & \\evbcmeq{hdl:popL:empty}{m1:act2}\n    {ver}{ \\ifelse{LH = dummy}{ver + 1}{ver} } \\\\\n\\end{align*}\n\n\\removeact{hdl:popL:more}{m0:act1}\n\\removeact{hdl:popL:more}{m0:act2}\n\\removeact{hdl:popL:more}{m0:act3}\n% \\removecoarse{hdl:popL:more}{m0:sch0}{popL}\n\\removecoarse{hdl:popL:more}{m0:sch1}{popL}\n\\removecoarse{hdl:popL:more}{m0:sch2}{popL}\n\\removecoarse{hdl:popL:more}{m0:sch3}{popL}\n% \\removeind{hdl:popL:more}{v}\n\\begin{align*}\n  % &\\witness{hdl:popL:more}{v}{v = ver} \\\\\n  &\\cschedule{hdl:popL:more}{m1:sch0}\n    { state = \\cNonEmpty } \\\\\n  &\\cschedule{hdl:popL:more}{m1:sch1}\n    { lh = LH } \\\\\n  &\\cschedule{hdl:popL:more}{m1:sch2}\n    { \\neg lh = RH } \\\\\n  &\\cschedule{hdl:popL:more}{m1:sch3}\n    { \\neg lh = dummy } \\\\\n  &\\evbcmeq{hdl:popL:more}{m1:act0}\n    { state }{ \\cPopped } \\\\\n  % &\\evbcmeq{hdl:popL:more}{m1:act0}\n  %   { remL }{ \\true } \\\\\n\\end{align*}\n\n\\replace{hdl:popL:more}{m1:sch0,m1:sch1}{m1:prog0}\n\\replace{hdl:popL:one}{m1:sch0,m1:sch1}{m1:prog0}\n\\begin{align*}\n  \\progress{m1:prog0}\n    {v = ver \\1\\land \\neg LH = dummy \n        \\1\\land state \\in \\{ \\cInit, \\cNonEmpty \\} }\n    { (LH = lh \\1\\land \\neg LH = dummy \\1\\land state = \\cNonEmpty)\n      \\1\\lor \\neg v = ver}\n  \\refine{m1:prog0}{ensure}{read:LH}{}\n  % \\progress{m1:prog0}\n  %   {v = ver \\1\\land \\neg LH = dummy \n  %       \\1\\land state \\in \\{ \\cInit, \\cNonEmpty \\} }\n  %   { (LH = lh \\1\\land \\neg LH = dummy \\1\\land state = \\cNonEmpty)\n  %     \\1\\lor \\neg v = ver}\n  % \\refine{m1:prog1}{ensure}{read:LH}{}\n\\end{align*}\n\\[ \\dummy{v : \\Int} \\]\n\n\\removeact{hdl:popL:one}{m0:act1}\n\\removeact{hdl:popL:one}{m0:act2}\n\\removeact{hdl:popL:one}{m0:act3}\n% \\removecoarse{hdl:popL:one}{m0:sch0}\n\\removecoarse{hdl:popL:one}{m0:sch1}\n\\removecoarse{hdl:popL:one}{m0:sch2}\n\\removecoarse{hdl:popL:one}{m0:sch3}\n% \\removeind{hdl:popL:one}{v}\n\\begin{align*}\n  % &\\witness{hdl:popL:one}{v}{v = ver} \\\\\n  &\\cschedule{hdl:popL:one}{m1:sch0}\n    { state = \\cNonEmpty } \\\\\n  &\\cschedule{hdl:popL:one}{m1:sch1}\n    { lh = LH } \\\\\n  &\\cschedule{hdl:popL:one}{m1:sch3}\n    { \\neg lh = dummy } \\\\\n  &\\evbcmeq{hdl:popL:one}{m1:act0}\n    { state }{ \\cPopped } \\\\\n\\end{align*}\n\n\\[ \\splitevent{returnL}{returnL:empty,returnL:non:empty} \\]\n% \\begin{align*}\n    \\refiningevent{returnL}{returnL:empty}{returnL\\_empty} \\\\\n    \\refiningevent{returnL}{returnL:non:empty}{returnL\\_non\\_empty}  \\\\\n% \\end{align*}\n\\hide{\n\\removeact{returnL:empty}{m0:act0}\n\\removeact{returnL:empty}{m0:act1}\n\\removecoarse{returnL:empty}{m0:sch0}\n\\removeact{returnL:non:empty}{m0:act0}\n\\removeact{returnL:non:empty}{m0:act1}\n\\removecoarse{returnL:non:empty}{m0:sch0}}\n% \\replace{returnL}{m0:sch0}{m1:sch}{}{}\n\\begin{align*}\n  \\cschedule{returnL:empty}{m1:sch0}{state = \\cEmpty} \\\\\n  \\evbcmeq{returnL:empty}{m1:act0}{state}{\\cBot} \\\\\n  \\evbcmeq{returnL:empty}{m1:act1}{result}{\\bot} \\\\\n  \\cschedule{returnL:non:empty}{m1:sch0}{state = \\cPopped} \\\\\n  \\evbcmeq{returnL:non:empty}{m1:act0}{state}{\\cBot} \\\\\n  \\evbcmeq{returnL:non:empty}{m1:act1}{result}{\\trash.lh.'item} \\\\\n\\end{align*}\n\n\\removeinit{m0:init7}\n\\removeinit{m0:init8}\n\\removeinit{m0:init9}\n\\begin{align*}\n  \\initwitness{resL}{resL = \\bot} \\\\\n  \\initwitness{remL}{remL = \\false}\\\\\n  \\initwitness{popL}{popL = \\false}\n\\end{align*}\n\n\\end{machine}\n\n\\section{m2}\n\\input{pop-left/machine_m2}\n\n\\begin{machine}{m2}\n  \\refines{m1}\n    \\removevar{ver} \n    \\removeact{ext:popL:empty}{m0:act0} \n    \\removeact{ext:popL:more}{m0:act0} \n    \\removeact{ext:popL:one}{m0:act0} \n    \\removeact{ext:popR:empty}{m0:act0} \n    \\removeact{ext:popR:more}{m0:act0} \n    \\removeact{ext:popR:one}{m0:act0} \n    \\removeact{ext:pushL:empty}{m0:act0} \n    \\removeact{ext:pushL:non:empty}{m0:act0} \n    \\removeact{ext:pushR:empty}{m0:act0} \n    \\removeact{ext:pushR:non:empty}{m0:act0} \n\n    % \\removeact{read:LH}{m0:act0} \n    \\removeact{hdl:popL:more}{m0:act0} \n    \\removeact{hdl:popL:one}{m0:act0} \n    \\removeact{read:LH}{m1:act2} \n    \\removecoarse{read:LH}{m1:sch1}\n    \\removecoarse{read:LH}{m0:sch2}\n    \\removeinit{m0:init3} \n    \\hide{\n        \\mergeevents{read:LH,hdl:popL:empty}{read:LH}}\n    \\begin{align*}\n      \\initwitness{ver}{ ver = 0 }\n    \\end{align*}\n    % \\removeact{hdl:popL:more}{m1:act2} \n    % \\removeact{hdl:popL:one}{m1:act2} \n    \\removecoarse{read:LH}{m0:sch0} \n\n  \\removecoarse{hdl:popL:one}{m0:sch0}{popL}\n  \\removecoarse{hdl:popL:more}{m0:sch0}{popL}\n  \\removeind{read:LH}{v}\n  \\removeind{hdl:popL:one}{v}\n  \\removeind{hdl:popL:more}{v}\n  \\begin{align*}\n  &\\witness{read:LH}{v}{v = ver} \\\\\n  &\\witness{hdl:popL:one}{v}{v = ver} \\\\\n  &\\witness{hdl:popL:more}{v}{v = ver} \\\\\n  \\end{align*}\n\n\\subsection{read RH}\n\n\\newevent{read:RH}{read\\_RH}\n  \\[ \\variable{rh : \\Addr_0} \\]\n\n\\begin{align*}\n  \\initialization{m1:init1}\n    { rh = dummy } \\\\\n\\end{align*}\n\n\\replace{hdl:popL:one}{m2:sch0}{m2:prog0}\n\\refine{m1:prog2}{ensure}{read:RH}{}\n\\begin{align*}\n  \\cschedule{read:RH}{m1:sch0}{ state = \\cNonEmpty } \\\\\n  \\evbcmeq{read:RH}{m1:act0}{rh}{RH} \\\\\n  \\cschedule{hdl:popL:one}{m2:sch0}\n    { rh = RH } \\\\\n  \\cschedule{hdl:popL:one}{m2:sch1}\n    { lh = rh } \\\\\n\\end{align*}\n\n\\begin{align*}\n  \\progress{m2:prog0}\n    {v = ver \\land state \\in \\{ \\cNonEmpty, \\cInit \\} }\n    {(rh = RH \\land state = \\cNonEmpty) \\lor \\neg v = ver}\n\\end{align*}\n\n    % \\removecoarse{hdl:popL:more}{m0:sch0} \n    % \\removecoarse{hdl:popL:one}{m0:sch0} \n  % \\mergeevents{foo}{bar}\n\\end{machine}\n\n\\end{document}\n", "meta": {"hexsha": "f36948c235d97c13083cfd96c749c2a032ae83cd", "size": 19379, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Tests/pop-left-t12.tex", "max_stars_repo_name": "literate-unitb/literate-unitb", "max_stars_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-07-27T11:05:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-20T14:53:33.000Z", "max_issues_repo_path": "Tests/pop-left-t12.tex", "max_issues_repo_name": "unitb/literate-unitb", "max_issues_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 32, "max_issues_repo_issues_event_min_datetime": "2017-06-25T03:53:02.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-25T04:28:38.000Z", "max_forks_repo_path": "Tests/pop-left-t12.tex", "max_forks_repo_name": "literate-unitb/literate-unitb", "max_forks_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.586259542, "max_line_length": 71, "alphanum_fraction": 0.5883688529, "num_tokens": 8431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4347302680893116}}
{"text": "\\section{Scalable Inference}\\label{sec:inf}\n\n%n the single user case, the goal is to infer the posterior distribution over the utilities of test items, $\\bs f^*$, \n%given a set of pairwise training labels, $\\bs y$. In the multi-user case, w\nGiven a set of pairwise training labels, $\\bs y$,\nwe aim to find the posterior over the matrix\n$\\bs F^*=\\bs V^{*T} \\bs W^*$ of utilities for test items and test users,\nand the posterior over consensus utilities for test items, $\\bs t^*$.\nThe non-Gaussian likelihood (Equation \\ref{eq:plphi})\nmakes exact inference intractable, hence previous work uses\n the Laplace approximation for GPPL~\\citep{chu2005preference}\nor combines expectation propagation (EP) with variational Bayes for a \nmulti-user model~\\citep{houlsby2012collaborative}.\nThe Laplace approximation is a maximum a-posteriori solution that\ntakes the most probable values of parameters rather than integrating over their distributions,\nand has been shown to perform poorly for classification compared to EP~\\citep{nickisch2008approximations}. \nHowever, \n%for a latent factor model, the \n%EP and VB approximate the true posterior with a simpler, factorised distribution.\n%%that can be learned using an iterative algorithm.\n%For crowdGPPL, the true posterior is multi-modal, \n%In a latent factor model, the latent factors can be re-ordered arbitrarily without\n%affecting $\\bs F$, causing a \\emph{non-identifiability problem}.\n%Since using EP would average these modes and produce uninformative predictions over $\\bs F$, so\n%\\citet{houlsby2012collaborative} incorporate a VB step that approximates a single mode.\na drawback of EP is that convergence is not guaranteed\n%, even when distributions are conjugate \n~\\citep{minka2001expectation}.\n%do they also linearise in the same way? -- both linearise. But EP uses a joint over y and f as its approximation to p(y|f), then optimises the parameters iteratively. It's not guaranteed to converge. Variational EGP instead approximates\n% p(y|f) directly with the best fit Gaussian. It's not clear whether this could be updated iteratively but it doesn't\n% seem to work if done simultaneously with the other variables we need to learn (the linearisation), \n% perhaps because the algorithm for learning the weights breaks if the variance of q(y|f), Q, keeps changing. \n% Possibly because Q does not change incrementally. So it's\n% possible that an outer loop could be used.\n%TODO: remove redundancy with the related work section. Consider whether this should actually be in a background section. NM^2 is limiting, not just the other costs. The other costs NP etc come into play in this pairwise model only.\nMore importantly, inference for a GP using either method\nhas computational complexity $\\mathcal{O}(N^3)$ \nand memory complexity $\\mathcal{O}(N^2)$, where $N$ is the number of data points.\n\nThe cost of inference can be reduced using a \\emph{sparse} approximation based on a set of \n\\emph{inducing points}, which act as substitutes for the points in the training dataset.\nBy choosing a fixed number of inducing points, $M \\ll N$, the computational cost is cut to $\\mathcal{O}(NM^2)$,\nand the memory complexity to $\\mathcal{O}(NM)$.\nInducing points must be selected %to give a good approximation\nusing either heuristics or by optimising their positions to maximise an estimate of the \nmarginal likelihood. \nOne such sparse approximation is the \\emph{generalized fully independent training conditional} (GFITC)~\\citep{NIPS2007_3351,snelson2006sparse}, \nused by \\citet{houlsby2012collaborative} for collabGP.\n%which generalizes the fully independent training conditional \n%(FITC)~\\citep{snelson2006sparse} method to non-Gaussian likelihoods.\n%GFITC assumes that each training and test point is independent of all other points\n%given the function values at the inducing points.\n%This may be inappropriate for the pairwise likelihood (Equation \\ref{eq:plphi})\n%because it ignores the covariance between the utilities of the items.\nHowever, time and memory costs that grow linearly with $\\mathcal{O}(N)$\nstart to become a problem with thousands of data points,\nas all data must be processed in every iterative update,\nbefore any other parameters such as $s$ are updated,\nmaking GFITC unsuitable for very large datasets~\\citep{hensman2015scalable}.\n%and distributed computation cannot be applied to GFITC to tackle the growing\n%computational costs as the objective function does not contain a sum over observations~\n\nWe derive a more scalable approach for GPPL and crowdGPPL using\nstochastic variational inference (SVI)~\\citep{hoffman2013stochastic}.\n%an iterative scheme that \n%limits the computational and memory costs at\n%each iteration.\n%and allows training data to be split into mini-batches for parallel processing.\n%As we explain below,\n%this allows us to reduce \nFor GPPL, this reduces the time complexity of each iteration %of the algorithm \n%from $\\mathcal{O}(NM^2)$ \nto $\\mathcal{O}(P_i M^2 + P_i^2 M + M^3)$,\nand memory complexity %from $\\mathcal{O}(NM)$ \nto $\\mathcal{O}(P_i M + M^2  + P_i^2)$,\nwhere $P_i$ is a mini-batch size that we choose in advance.\nNeither $P_i$ nor $M$ are dependent on the size of the dataset, meaning that SVI \ncan be run with arbitrarily large datasets, \nand other model parameters such as $s$ can be updated before processing all data\nto encourage faster convergence.\nFirst, we define a suitable likelihood approximation to enable the use of SVI.\n\n\\subsection{Approximating the Posterior with a Pairwise Likelihood}\n\nThe preference likelihood in Equation \\ref{eq:plphi} \nis not conjugate with the Gaussian process, which means there is no analytic expression for\nthe exact posterior.\nFor single-user GPPL, we therefore\napproximate the preference likelihood with a Gaussian:\n%This avoids the need for quadrature methods, as in \\cite{hensman2015scalable} or ...\n\\begin{flalign}\np(\\bs f | \\bs y, s) & \\propto \\prod_{p=1}^P p\\left(y_p | z_p\\right) p\\left(\\bs f | \\bs K, s\\right)\n= \\prod_{p=1}^P \\Phi\\left(z_p\\right) \\mathcal{N}\\left(\\bs f; \\bs 0, \\bs K/s\\right)\n%= \\mathbb{E}\\left[\\prod_{p=1}^P \\Phi(z_p)\\right] = \\prod_{p=1}^P \\Phi(\\hat{z}_p) \n%\\approx \\mathcal{N}(\\bs y; \\Phi(\\hat{\\bs z}), \\bs Q),\n& \\\\\n& \\approx \\prod_{p=1}^P \\mathcal{N}\\left(y_p; \\Phi(z_p), Q_{p,p}\\right) \n\\mathcal{N}\\left(\\bs f; \\bs 0, \\bs K/s\\right)\n = \\mathcal{N}\\left(\\bs y; \\Phi(\\bs z), \\bs Q\\right) \\mathcal{N}\\left(\\bs f; \\bs 0, \\bs K/s\\right), &\\nonumber \n\\end{flalign}\nwhere $\\bs Q$ is a diagonal noise covariance matrix\nand we omit the kernel hyperparameters, $\\theta$, to simplify notation.\nFor crowdGPPL, we use the same approximation to the likelihood, but\nreplace $\\bs f$ with $\\bs F$.\n% and the priors over $\\bs v$, $\\bs t$ and $\\bs w$\n%throughout this section.\n%There are two problems with this approximation so far:\n%firstly, $\\Phi(\\bs z)$ is a nonlinear function of $\\bs f$,\n%which makes the posterior intractable:\n%\\begin{flalign}\n%p(\\bs f | \\bs y) %\\propto p(\\bs y | \\bs f)\\mathcal{N}(\\bs f; \\bs 0, \\bs K/s)\n%\\approx \\frac{ \\mathcal{N}(\\bs y; \\Phi(\\bs z), \\bs Q)\\mathcal{N}(\\bs f; \\bs 0, \\bs K/s) }{\n%\\int \\mathcal{N}(\\bs y; \\Phi(\\bs z), \\bs Q)\\mathcal{N}(\\bs f'; \\bs 0, \\bs K/s) df'}\n%\\end{flalign}\n%Secondly, we need to estimate the diagonal variance terms in $\\bs Q$.\nWe estimate the diagonals of $\\bs Q$ \nby moment matching our approximate likelihood with $\\Phi(z_p)$,\nwhich defines a Bernoulli distribution with variance $Q_{p,p} = \\Phi(z_p)(1 - \\Phi(z_p))$.\nHowever, this means that $\\bs Q$ % the variance of the approximate likelihood\ndepends on $\\bs z$ and therefore on $\\bs f$,\nso the approximate posterior over $\\bs f$ cannot be computed in closed form.\nTo resolve this, we approximate $Q_{p,p}$ \nusing an estimated posterior over $\\Phi(z_p)$ computed\nindependently for each pairwise label, $p$.\n%thereby replacing intractable expectations with respect to $p(\\bs f|\\bs y)$\n%with simple \nWe obtain this estimate\n by updating the parameters of the conjugate prior for the Bernoulli likelihood,\n which is\na beta distribution with parameters $\\gamma$ and $\\lambda$.\nWe find $\\gamma$ and $\\lambda$ by \nmatching the moments of the beta prior to the prior mean and variance of $\\Phi(z_p)$,\nestimated using numerical integration.\nThe prior over $\\Phi(z_p)$ is defined by a GP for single-user GPPL, $p(\\Phi(z_p) | \\bs K, \\alpha_0, \\beta_0)$,\nand a non-standard distribution for crowdGPPL. \n%Assuming a beta prior over $\\Phi(z_p)$ means that $y_p$ has a beta-Bernoulli\n%distribution. \nGiven the observed label $y_p$, we estimate the diagonals in $\\bs Q$\nas the variance of the posterior beta-Bernoulli:\n\\begin{flalign}\nQ_{p,p} & \\approx \\frac{ (\\gamma + y_p)(\\lambda + 1 - y_p) }{(\\gamma + \\lambda + 1)^2}. &\n\\end{flalign}\nThe covariance $\\bs Q$ therefore approximates the expected noise in the observations, \nhence captures variance due to $\\sigma$ in Equation \\ref{eq:plphi}.\nThis approximation performs well empirically\nfor Gaussian process classification~\\citep{reece2011determining,simpson2017bayesian} and \nclassification using extended Kalman filters~\\citep{lee2010sequential,lowne2010sequential}. \n\nUnfortunately, the nonlinear term $\\Phi(\\bs z)$ means that the posterior is still intractable, \nso we replace $\\Phi(\\bs z)$ with a linear function of $\\bs f$ by taking\nthe first-order Taylor series expansion of $\\Phi(\\bs z)$ \nabout the expectation $\\mathbb{E}[\\bs f] = \\hat{\\bs f}$:\n\\begin{flalign}\n\\Phi(\\bs z) &\\approx \\tilde{\\Phi}(\\bs z) = \\bs G \\left(\\bs f-\\hat{\\bs f}\\right) \n+ \\Phi(\\hat{\\bs z}), & \\\\\nG_{p,i} &= \\frac{\\partial \\Phi(\\hat{z}_p)} {\\partial f_i}\n= \\Phi(\\hat{z}_p)\\left(1 - \\Phi(\\hat{z}_p)\\right) \\left(2y_p - 1\\right)\\left( [i = a_p] - [i = b_p]\\right), &\n\\end{flalign}\n%where $\\bs G$ is a matrix whose elements \n%$G_{p,i}= \\Phi(\\hat{z}_p)(1 - \\Phi(\\hat{z}_p)) (2y_p - 1)( [i = a_p] - [i = b_p])$ \n%are the partial derivatives of $\\Phi(\\hat{z_p})$ %the pairwise likelihood \n%with respect to $f_i$.\n%of the latent function values, $\\bs f$.\nwhere $\\hat{\\bs z}$ is the expectation of $\\bs z$ computed using Equation \\ref{eq:predict_z},\nand $[i=a]=1$ if $i=a$ and is $0$ otherwise. \nThere is a circular dependency between $\\hat{\\bs f}$,\nwhich is needed to compute $\\hat{\\bs z}$, and $\\bs G$. %the linearization terms in the likelihood,\nWe estimate these terms using a variational inference procedure\nthat iterates between updating $\\bs f$ and $\\bs G$~\\citep{steinberg2014extended}\nas part of Algorithm \\ref{al:singleuser}.\n%and is described in more detail below.\nThe complete approximate posterior for GPPL is now as follows:\n\\begin{flalign}\np(\\bs f | \\bs y, s) \n\\approx %\\frac{1}{Z}\n\\mathcal{N}(\\bs y; \\bs G (\\bs f-\\mathbb{E}[\\bs f]) + \\Phi(\\hat{\\bs z}), \\bs Q) \\mathcal{N}(\\bs f; \\bs 0, \\bs K/s) / Z = \\mathcal{N}(\\bs f; \\hat{\\bs f}, \\bs C), &&\n\\label{eq:likelihood_approx} \n\\end{flalign}\nwhere $Z$ is a normalisation constant.\nLinearisation means that our approximate likelihood is conjugate to the prior,\nso the approximate posterior is also Gaussian. \n%TODO any other variant in Nickish that uses linearization? Can we cite nickisch to say that linearization is good, m'kay?\n%TODO show the posterior without further SVI approximations?\nGaussian approximations to the posterior have shown strong empirical results for \nclassification~\\citep{nickisch2008approximations} and\npreference learning~\\citep{houlsby2012collaborative},\n%including the \n%expectation propagation method~\\citep{rasmussen_gaussian_2006}.\nand linearisation using a Taylor expansion has been widely tested\nin the extended Kalman filter~\\citep{haykin2001kalman}\nas well as Gaussian processes~\\citep{steinberg2014extended,bonilla2016extended}.\n%\\todo{generate a synthetic plot showing the \n%difference between a true posterior over f and our\n%approximation on synthetic data. Do what Nickisch did?}\n%Given our approximate posterior, we now derive an efficient inference scheme using SVI.\n\n\\subsection{SVI for Single User GPPL}\n\n%TODO what's going on here? First, we need to learn s. Second, we need a more efficient way to learn\n% f without inverting K and without using all observations at once.\nUsing the linear approximation in the previous section, \nposterior inference requires inverting\n$\\bs K$ with computational cost $\\mathcal{O}(N^3)$\nand taking an expectation with respect to $s$, which remains intractable. \nWe address these problems using stochastic variational inference (SVI)\nwith a sparse approximation to the GP that limits\nthe size of the covariance matrices we need to invert.\nWe introduce $M \\ll N$ inducing items with inputs \n$\\bs X_m$,\nutilities $\\bs f_m$, and covariance $\\bs K_{mm}$. The\ncovariance between the observed and inducing items is $\\bs K_{nm}$.\n% The inducing points act as proxies for the observed points during inference,\n% and thereby reduce the number of data points we have to perform costly operations % over.\n%We modify the variational approximation in Equation \\ref{eq:vb_approx} to introduce the inducing points \nFor clarity, we omit $\\theta$ from this point on.\nWe assume a \\emph{mean-field} approximation to the joint posterior over \ninducing and training items\nthat factorises between different sets of latent variables:\n\\begin{flalign}\np\\left(\\bs f, \\bs f_m, s | \\bs y, \\bs X, \\bs X_m, k_{\\theta}, \\alpha_0, \\beta_0 \\right) \n&\\approx q\\left(\\bs f, \\bs f_m, s\\right) = q(s)q\\left(\\bs f\\right)q\\left(\\bs f_m\\right), \\label{eq:svi_approx} &&\n\\end{flalign}\nwhere $q(.)$ are \\emph{variational factors} defined below. \nEach factor corresponds to a subset of latent variables, $\\bs \\zeta_i$, and\ntakes the form $\\ln q(\\bs \\zeta_i) = \\mathbb{E}_{j \\neq i}[\\ln p(\\bs \\zeta_i, \\bs x, \\bs y)]$.\nThat is, the expectation with respect\nto all other latent variables, $\\bs\\zeta_j,\\forall j \\neq i$, of the log joint distribution\nof the observations and latent variables, $\\bs \\zeta_i$.\nTo obtain the factor for $\\bs f_m$, we marginalise $\\bs f$ and take expectations with respect to $q(s)$:\n\\begin{flalign}\n\\ln q\\left(\\bs f_m\\right) &= \\ln \\mathcal{N}\\!\\left(\\bs y; \\tilde{\\Phi}(\\bs z), \\bs Q\\right)\n+ \\ln\\mathcal{N}\\left(\\bs f_m; \\bs 0, \\frac{\\bs K_{mm}}{\\mathbb{E}\\left[s\\right]}\\right) \\!  + \\textrm{const} %& \\nonumber \\\\\n = \\ln \\mathcal{N}\\left(\\bs f_m; \\hat{\\bs f}_m, \\bs S \\right), &\n \\label{eq:fhat_m}\n\\end{flalign}\nwhere the variational parameters $\\hat{\\bs f}_m$ and $\\bs S$ are computed using \nan iterative SVI procedure described below.\nWe choose an approximation of $q(\\bs f)$ that depends only on the inducing point utilities, $\\bs f_m$, and is independent of the observations:\n \\begin{flalign}\n\\ln q\\left(\\bs f\\right) & = \\ln \\mathcal{N}\\left(\\bs f; \\bs A \\hat{\\bs f}_m, \n\\bs K + \\bs A (\\bs S - \\bs K_{mm}/\\mathbb{E}[s]) \\bs A^T \\right), &\n\\end{flalign}\nwhere $\\bs A=\\bs K_{nm} \\bs K^{-1}_{mm}$.\nTherefore, we no longer need to invert an $N \\times N$ covariance matrix to compute $q(\\bs f)$.\nThe factor $q(s)$ also depends only the inducing points:\n\\begin{flalign}\n& \\ln q(s) = \\mathbb{E}_{q(\\bs f_m)}[\\ln\\mathcal{N}(\\bs f_m| \\bs 0, \\bs K_{mm}/s)] + \\ln \\mathcal{G}(s; \\alpha_0, \\beta_0) + \\mathrm{const}\n= \\ln \\mathcal{G}(s; \\alpha, \\beta), & \\label{eq:qs}\n\\end{flalign}\nwhere $\\alpha= \\alpha_0 + \\frac{M}{2}$ and $\\beta = \\beta_0 + \\frac{1}{2}\n\\textrm{tr}\\left(\\bs K^{-1}_{mm}\\left(S + \\hat{\\bs f}_m \\hat{\\bs f}_m^T\\right)\\right)$.\nThe expected value is  \n$\\mathbb{E}[s] = \\frac{\\alpha}{\\beta}$.\n\nWe apply variational inference to iteratively reduce the KL-divergence between our approximate posterior\n%$q(s)q(\\bs f)q(\\bs f_m)$\nand the true posterior (Equation \\ref{eq:svi_approx}) %, $p(s, \\bs f, \\bs f_m | \\bs K, \\alpha_0, \\beta_0, \\bs y)$,\nby maximising a lower bound, $\\mathcal{L}$, on the log marginal likelihood (detailed equations in Appendix \\ref{sec:vb_eqns}), which is given by:\n%(see also Equation \\ref{eq:full_L_singleuser} in the Appendix):%, $\\ln p(\\bs y | \\bs K, \\alpha_0, \\beta_0)$ :\n\\begin{flalign}\n&\\ln p(\\bs y | \\bs K, \\alpha_0, \\beta_0) = \\textrm{KL}\\left(q\\left(\\bs f, \\bs f_m, s\\right)  || p\\left(\\bs f, \\bs f_m, s | \\bs y, \\bs K, \\alpha_0, \\beta_0\\right)\\right) \n+ \\mathcal{L} & \\label{eq:lowerbound}\n\\\\\n%\\end{flalign}\n%Taking expectations with respect to the variational $q$ distributions, $\\mathcal{L}$ is:\n%\\begin{flalign}\n&\\mathcal{L} = \\mathbb{E}_{q(\\bs f)}\\left[\\ln p(\\bs y | \\bs f)\\right]\n+ \\mathbb{E}_{q\\left(\\bs f_m, s\\right)}\\left[\\ln p\\left(\\bs f_m, s | \\bs K, \n\\alpha_0, \\beta_0 \\right) -\\ln q\\left(\\bs f_m\\right) - \\ln q(s)\\right]. & \\nonumber\n\\end{flalign}\n%         invK_mm_expecFF = self.invK_mm.dot(self.uS + self.um_minus_mu0.dot(self.um_minus_mu0.T))\n%         self.rate_s = self.rate_s0 + 0.5 * np.trace(invK_mm_expecFF)\nTo optimise $\\mathcal{L}$,\nwe initialise the $q$ factors randomly, then\nupdate each one in turn, taking expectations with respect to the other factors. \n\nThe only term in $\\mathcal{L}$ that refers to the observations, $\\bs y$, \nis a sum of $P$ terms, each of which refers to one observation only.\nThis means that $\\mathcal{L}$ can be maximised by considering a random subset of \nobservations at each iteration~\\citep{hensman2013gaussian}.\n%Therefore, the SVI solution replaces Equations \\ref{eq:fhat_m} and \\ref{eq:S} for computing\n%$\\hat{\\bs f}_m$ and $\\bs S$ over all observations with a sequence of stochastic updates.\nFor the $i$th update of $q(\\bs f_m)$, we randomly select $P_i$ \nobservations $\\bs y_i = \\{ y_p \\forall p \\in \\bs P_i \\}$, \nwhere $\\bs P_i$ is a random subset of indexes of observations,\nand $P_i$ is a mini-batch size.\nThe items referred to by the pairs in the subset are \n$\\bs N_i = \\{a_p \\forall p \\in \\bs P_i \\} \\cup \\{ b_p \\forall p \\in \\bs P_i\\}$.\nWe  perform updates using $\\bs Q_i$ (rows and columns of $\\bs Q$ for pairs in $\\bs P_i$),\n$\\bs K_{im}$ and $\\bs A_i$ (rows of $\\bs K_{nm}$ and $\\bs A$ in $\\bs N_i$),\n$\\bs G_i$ (rows of $\\bs G$ in $\\bs P_i$ and columns in $\\bs N_i$), and\n$\\hat{\\bs z}_i = \\left\\{ \\hat{\\bs z}_p \\forall p \\in P_i \\right\\}$.\n%All matrices with subscript $_i$ contain only the subset of elements relating to \n%observations in $\\bs P_i$.\n% The linearization matrix $\\bs G_i$ is the subset of elements in $\\bs G$ relating to observations in $\\bs P_i$, \n%  is the corresponding subset of elements in $\\bs Q$,\n%  is the covariance between the items referred to by pairs in $\\bs P_i$ \n% and the inducing points,\n% and  contains the corresponding rows of $\\bs A$.\nThe updates optimise the natural parameters of the Gaussian distribution by following the\nnatural gradient~\\citep{hensman2015scalable}:\n\\begin{flalign}\n\\bs S^{-1}_i  & = (1 - \\rho_i) \\bs S^{-1}_{i-1} + \\rho_i\\left( \\mathbb{E}[s]\\bs K_{mm}^{-1} + \\pi_i\\bs A_i^T \\bs G^T_{i} \\bs Q^{-1}_i \\bs G_{i} \\bs A_{i} \\right)& \n\\label{eq:S_stochastic} \\\\\n\\hat{\\bs f}_{m,i}  & = \\bs S_i \\left( \\! (1 - \\rho_i) \\bs S^{-1}_{i-1} \\hat{\\bs f}_{m,i-1}  + \n%\\right. \\nonumber \\\\\n%& \\left.\\hspace{1.5cm} \n\\rho_i \\pi_i  \n\\bs A_{i}^{T} \\bs G_{i}^T \\bs Q_i^{-1}\\! \\left( \\bs y_i  - \\Phi(\\hat{\\bs z}_i) + \\bs G_{i} \\bs A_i \\hat{\\bs f}_{m,i-1} \\! \\right) \\! \\right) & \n\\label{eq:fhat_stochastic}\n\\end{flalign}\nwhere\n$\\rho_i=(i + \\epsilon)^{-r}$ is a mixing coefficient that controls the update rate,\n$\\pi_i = \\frac{P}{P_i}$ weights each update according to sample size,\n $\\epsilon$ is a delay hyperparameter and $r$ is a forgetting rate~\\citep{hoffman2013stochastic}.\n\nBy performing updates in terms of mini-batches, \nthe time complexity of Equations \\ref{eq:S_stochastic} and\n\\ref{eq:fhat_stochastic} is\n%has order $\\mathcal{O}(M^3)$, and the second term has order \n$\\mathcal{O}(P_i M^2 + P_i^2 M + M^3)$ and\n%The $P_i^2$ term arises due to $\\bs G_i$, which is an $N_i \\times P_i$ matrix, where $N_i \\leq 2P_i$ is the number of \n%items referred to by the pairwise labels in the mini-batch.\nmemory complexity is  $\\mathcal{O}(M^2 + P_i^2 + M P_i)$.\n%, where each complexity term is due\n%to the sizes of $K_{mm}$, $G_i$ and $K_{im}$.\nThe only parameters that must be stored between iterations relate to the \ninducing points, hence the memory consumption does not grow with the dataset size \nas in the GFITC approximation used by \\citet{houlsby2012collaborative}.\nA further advantage of stochastic updating is that the $s$ parameter (and any other global\nparameters not immediately depending on the data) can be learned\nbefore the entire dataset has been processed,\nwhich means that poor initial estimates of $s$ are rapidly improved\nand the algorithm can converge faster.\n\n\\begin{algorithm}\n \\KwIn{ Pairwise labels, $\\bs y$, training item features, $\\bs x$, \n test item features $\\bs x^*$}\n \\nl Select inducing point locations $\\bs x_{mm}$ and compute kernel matrices $\\bs K$, $\\bs K_{mm}$ and $\\bs K_{nm}$ given $\\bs x$ \\;\n \\nl Initialise $\\mathbb{E}[s]$ and $\\hat{\\bs f}_m$ to prior means\n and $\\bs S$ to prior covariance $\\bs K_{mm}$\\;\n \\While{$\\mathcal{L}$ not converged}\n {\n \\nl Select random sample, $\\bs P_i$, of $P$ observations\\;\n \\While{$\\bs G_i$ not converged}\n  {\n  \\nl Compute $\\mathbb{E}[\\bs f_i]$ \\;\n  \\nl Compute $\\bs G_i$ given $\\mathbb{E}[\\bs f_i]$ \\;\n  \\nl Compute $\\hat{\\bs f}_{m,i}$ and $\\bs S_{i}$ \\;\n  }\n \\nl Update $q(s)$ and compute $\\mathbb{E}[s]$ and $\\mathbb{E}[\\ln s]$\\;\n }\n\\nl Compute kernel matrices for test items, $\\bs K_{**}$ and $\\bs K_{*m}$, given $\\bs x^*$ \\;\n\\nl Use converged values of $\\mathbb{E}[\\bs f]$and $\\hat{\\bs f}_m$ to estimate\nposterior over $\\bs f^*$ at test points \\;\n\\KwOut{ Posterior mean of the test values, $\\mathbb{E}[\\bs f^*]$ and covariance, $\\bs C^*$ }\n\\vspace{0.2cm}\n\\caption{The SVI algorithm for GPPL: preference learning with a single user.}\n\\label{al:singleuser}\n\\end{algorithm}\nThe complete SVI algorithm is summarised in Algorithm \\ref{al:singleuser}.\nIt uses a nested loop to learn $\\bs G_i$, which avoids storing the complete matrix, \n$\\bs G$.\nIt is possible to distribute computation in lines 3-6 by selecting multiple random samples\nto process in parallel. A global estimate of $\\hat{\\bs f}_m$ and $\\bs S$\nis passed to each compute node, which runs the loop over lines 4 to 6.\nThe resulting updated $\\hat{\\bs f}_m$ and $\\bs S$ values are then passed back to a \ncentral node that combines them by taking a mean weighted by $\\pi_i$ to account for \nthe size of each batch. \n%This does not require modifying Equations \\ref{eq:S_stochastic} and \\ref{eq:fhat_stochastic}, since they already contain a sum weighted by $\\pi_i$.\n\nInducing point locations can be learned\nas part of the variational inference procedure, which\n%or by optimising a bound on the log marginal likelihood.\nbreaks convergence guarantees, or by an expensive optimisation process~\\citep{hensman2015scalable}. \nWe obtain good performance by choosing inducing points up-front \nusing K-means++~\\citep{arthur2007k} with $M$ clusters to cluster\nthe feature vectors, \nthen taking the cluster centres as inducing points that represent the distribution of observations.\n\nThe inferred distribution over the inducing points can be used \nto estimate the posteriors of test items, $f(\\bs x^*)$, according to:\n\\begin{flalign}\n\\bs f^* \\! \\! &= \\bs K_{*m} \\bs K_{mm}^{-1} \\hat{\\bs f}_m, &\n\\bs C^* \\! \\! = \\bs K_{**} + \\bs K_{*m} \\bs K_{mm}^{-1} (\\bs S - \\bs K_{mm} / \\mathbb{E}[s] ) \\bs K_{mm}^{-1}\\bs K_{*m}^T ,\n\\end{flalign}\nwhere $\\bs C^*$ is the posterior covariance of the test items, $\\bs K_{**}$ is their prior covariance, and\n$\\bs K_{*m}$ is the covariance between test and inducing items.\n%It is possible to recover the lower bound proposed by \n%\\citet{hensman2015scalable} for classification by generalizing the\n%likelihood to arbitrary nonlinear functions, and omitting terms relating to $p(s|\\alpha_0,\\beta_0)$ and $q(s)$.\n% However, our approach avoids expensive quadrature methods by linearizing the likelihood to enable analytical updates. We also infer $s$ in a Bayesian manner, \n% rather than treating as a hyper-parameter, which is important for preference learning where $s$ controls the noise level of the observations relative to  $f$. \n\n\\subsection{SVI for CrowdGPPL}\n\nWe now provide the variational posterior for the crowdGPPL model defined in Equation \\ref{eq:joint_crowd}:\n\\begin{flalign}\n& p\\left( \\bs V, \\bs V_m, \\bs W, \\bs W_m, \\bs t, \\bs t_m, s^{(v)}_1, .., s^{(v)}_C,\ns^{(w)}_1, .., s^{(w)}_C, s^{(t)} | \\bs y, \\bs X, \\bs X_m, \\bs U, \\bs U_m, k, \\alpha_0, \\beta_0 \\right) \n& \\nonumber \\\\\n& \\approx q(\\bs t) q(\\bs t_m)q\\left(s^{(t)}\\right)\\prod_{c=1}^{C} q(\\bs v_{c})q(\\bs w_c)q(\\bs v_{c,m})q(\\bs w_{c,m})\nq\\left(s^{(v)}_c\\right)q\\left(s^{(w)}_c\\right), & %\\nonumber \\\\\n%& = q(\\bs F) q(s^{(t)}) \\prod_{c=1}^C q(s^{(v)}_c), &\n\\end{flalign}\nwhere $\\bs U_m$ are the feature vectors of inducing users and the variational $q$ factors are defined below.\nWe use SVI to optimise the lower bound on the log marginal likelihood \n(detailed in Appendix \\ref{sec:crowdL}), which is given by:\n\\begin{flalign}\n& \\mathcal{L}_{cr} = \n\\mathbb{E}_{q(\\bs F)}%(\\bs t, \\bs t_m, \\bs V, \\bs V_m, \\bs W, \\bs W_m, s_1,...,s^{(v)}_c,s^{(t)})\n[\\ln p(\\bs y | \\bs F)] \n+ \\mathbb{E}_{q\\left(\\bs t_m, s^{(t)}\\right)} \\left[\\ln p\\left(\\bs t_m, s^{(t)} | \\bs K_{mm}, \\alpha_0^{(t)}, \\beta_0^{(t)}\\right)\n- \\ln q(\\bs t_m)  - \\ln q\\left(s^{(t)}\\right) \\right]  & \\nonumber \\\\\n&\n+ \\sum_{c=1}^C \\!\\! \\bigg\\{  \\mathbb{E}_{q\\left(\\bs v_{m,c},s^{(v)}_c\\right)}\\left[\\ln p\\left(\\bs v_{m,c}, s^{(v)}_c | \\bs K_{mm}, \\alpha_0^{(v)}, \\beta_0^{(v)}\\right) - \\ln q(\\bs v_{m,c}) - \\ln q\\left(s_c^{(v)}\\right) \\right]\n&  \\nonumber \\\\ \n& \n+  \\mathbb{E}_{q\\left(\\bs w_{m,c}, s_c^{(w)}\\right)}\\left[\\ln p\\left(\\bs w_{m,c},s^{(w)}_c | \\bs L_{mm}, \\alpha_0^{(w)}, \\beta_0^{(w)} \\right)\n  - \\ln q(\\bs w_{m,c} )  - \\ln q\\left(s_c^{(w)} \\right) \\right] \\bigg\\} . & \n  \\label{eq:lowerbound_crowd}\n\\end{flalign}\nThe SVI algorithm \nfollows the same pattern as Algorithm \\ref{al:singleuser}, \nupdating each $q$ factor in turn by computing means and covariances\nfor  $\\bs V_m$, $\\bs W_m$ and $\\bs t_m$ instead of $\\bs f_m$ (see Algorithm \\ref{al:crowdgppl}).\nThe time and memory complexity of each update are\n%the same as for single-user GPPL, \n%except that we now have $C$ updates, and the number of inducing points for items and users \n%may be different:\n$\\mathcal{O}(CM_{\\mathrm{items}}^3 + CM_{\\mathrm{items}}^2 P_i + CM_{\\mathrm{items}} P_i^2$\n$ + CM_{\\mathrm{users}}^3 + CM_{\\mathrm{users}}^2 P_i + CM_{\\mathrm{users}} P_i^2 )$ \n%Memory complexity for crowdGPPL is\nand \n$\\mathcal{O}(CM_{\\mathrm{items}}^2 + P_i^2 + M_{\\mathrm{items}} P_i + CM_{\\mathrm{users}}^2 + M_{\\mathrm{users}} P_i)$, respectively.\n%\nThe variational factor for the $c$th inducing item component is:\n\\begin{flalign}\n\\ln q(\\bs v_{m,c})  & =  \n\\mathbb{E}_{q(\\bs t, \\bs w_{m,c'}\\forall c', \\bs v_{m,c'}\\forall c'\\backslash c) }\\left[\n\\ln \\mathcal{N}\\left( \\bs y; \\tilde{\\Phi}(\\bs z), Q \\right) \\right] \n+ \\ln\\mathcal{N}\\left(\\bs v_{\\!m,c}; \\bs 0, \\frac{\\bs K_{mm}}{\\mathbb{E}[s^{(v)}_c]}\\right) \n +  \\textrm{const} & \\nonumber \\\\\n% are the dimensions collapsed to a single MVN?\n& = \\ln \\mathcal{N}\\left(\\bs v_{m,c}; \\hat{\\bs v}_{m,c}, \\bs S_c^{(v)} \\right), &\n\\end{flalign}\nwhere posterior mean $\\hat{\\bs v}_{m,c}$ and covariance $\\bs S_c^{(v)}$ are computed using \nequations of the same form as % those of the single user GPPL in \nEquations \\ref{eq:S_stochastic} and \\ref{eq:fhat_stochastic}, except $\\bs Q^{-1}$\n is scaled by expectations over $\\bs w_{m,c}$,\nand $\\hat{\\bs f}_{m,i}$ is replaced by $\\hat{\\bs v}_{m,c,i}$.\nThe factor for the inducing points of $\\bs t$ follows a similar pattern to $\\bs v_{m,c}$:\n\\begin{flalign}\n\\ln q(\\bs t_m) & = \n\\mathbb{E}_{q(\\bs w_{m,c'}\\forall c', \\bs v_{m,c'}\\forall c')}\\left[\n\\ln \\mathcal{N}\\left( \\bs y; \\tilde{\\Phi}(\\bs z), Q \\right) \n\\right]\n+ \\ln\\mathcal{N}\\left( \\bs t_m; \\bs 0, \\frac{\\bs K_{mm}}{\\mathbb{E}[s^{(t)}]} \\right)\n+ \\textrm{const} & \\nonumber \\\\\n& = \\ln \\mathcal{N}\\left( \\bs t_m; \\hat{\\bs t}_{m}, \\bs S^{(t)} \\right), & \n\\end{flalign}\nwhere the equations for $\\hat{\\bs t}$ and $\\bs S^{(t)}$ \nare the same as Equations \\ref{eq:S_stochastic} and \\ref{eq:fhat_stochastic}, \nexcept $\\hat{\\bs f}_{m,i}$ is replaced by $\\hat{\\bs t}_{m,i}$. \n%(see also Equations \\ref{eq:St} and \\ref{eq:hatt}).\nFinally, %require a different linearization matrix, $\\bs J \\in P \\times U$, containing partial derivatives \n%of the pairwise likelihood with respect to $\\hat{w}_c$. Its elements are given by:\n%\\begin{flalign}\n%J_{p,j} = \\Phi(\\mathbb{E}[z_p])(1 - \\Phi(\\mathbb{E}[z_p]) (2y_p - 1) [u_p = j] % needs to be added or subtracted depending on a or b\n%\\end{flalign} \n%now multiply by V. What about covariances between v?\nthe variational distribution for each inducing user's component is:% then as follows:\n\\begin{flalign}\n\\ln q(\\bs w_{\\! m,c} )  = & \n\\mathbb{E}_{q(\\bs t,\\bs w_{m,c'}\\forall c'\\backslash c, \\bs v_{m,c'}\\forall c')}\\left[\n\\ln \\mathcal{N}\\! \\left( \\bs y; \\tilde{\\Phi}(\\bs z), Q \\right) \\right] \n+ \\ln\\mathcal{N}\\!\\left(\\bs w_{\\! m,c}; \\bs 0, \\frac{\\bs L_{mm}}{\\mathbb{E}[s^{(w)}_c]} \\right)\n+ \\textrm{const} & \\nonumber \\\\\n& = \\ln \\mathcal{N}\\left( \\bs w_{m,c}; \\hat{\\bs w}_{\\!m,c}, \\bs \\Sigma_c \\right), & \n\\end{flalign}\nwhere $\\hat{\\bs w}_c$ and $\\bs \\Sigma_{c}$ also follow the pattern of\nEquations \\ref{eq:S_stochastic} and \\ref{eq:fhat_stochastic},\nwith $\\bs Q^{-1}$ scaled by expectations of\n$\\bs w_{c,m}$,\n and $\\hat{\\bs f}_{m,i}$ replaced by $\\hat{\\bs w}_{m,c,i}$.\n%(see also Appendix \\ref{sec:post_params}, Equations \\ref{eq:Sigma} and \\ref{eq:what}).\nWe provide the complete equations for the variational means \nand covariances for $\\bs v_{m,c}$, $\\bs t_m$ and $\\bs w_{m,c}$ in \nAppendix \\ref{sec:post_params}.\nThe expectations for inverse scales, $s^{(v)}_1,..,s^{(v)}_c$, $s^{(w)}_1,..,s^{(w)}_c$\n and $s^{(t)}$ can be computed using Equation \\ref{eq:qs} by\nsubstituting the corresponding terms for $\\bs v_c$, $\\bs w_c$ or $\\bs t$ instead of $\\bs f$. \n\n% The equations for the means and covariances \n% can be adapted for stochastic updating by applying weighted sums over\n% the stochastic update and the previous values in the \n% same way as  Equation \\ref{eq:S_stochastic} and \\ref{eq:fhat_stochastic}.\n% The stochastic updates for the inducing points of the latent factors depend \n% on expectations with respect to the observed points. \n% As with the single user case, the variational factors at the observed items are independent of the observations given the variational factors of the inducing points\n% (likewise for the observed users):\n% \\begin{flalign}\n% \\ln q(\\bs V) & = \\sum_{c=1}^C \\ln \\mathcal{N}\\left( \\bs v_c; \\bs A_v\\hat{\\bs v}_{m,c}, \n% \\frac{\\bs K_{v}}{\\mathbb{E}[s^{(v)}_c]} + \\bs A_v (\\bs S_{m,c} - \\frac{\\bs K_{mm}}{\\mathbb{E}[s^{(v)}_c]})\\bs A_v \\right) & \\label{eq:qv} \\\\\n% \\ln q(\\bs t) & = \\ln \\mathcal{N}\\left( \\bs t; \\bs A_t \\hat{\\bs t}_m, \n% \\frac{\\bs K_{t}}{\\mathbb{E}[s^{(t)}]} + \\bs A_t (\\bs s^{(t)} - \\frac{\\bs K_{mm}}{\\mathbb{E}[s^{(t)}]})\\bs A_t \\right)  & \\label{eq:qt}\\\\\n% \\ln q(\\bs W) & = \\sum_{c=1}^C \\ln \\mathcal{N}\\left( \\bs w_c; \\bs A_w \\hat{\\bs w}_{m,c}, \\bs L_{} + \\bs A_w (\\bs\\Sigma - \\bs L_{mm}/s^{(w)}_c) \\bs A_w \\right). &\n% \\label{eq:qw}\n% \\end{flalign}\n%As with GPPL, the stochastic updates are amenable to parallel computation within one iteration \n%of the variational inference algorithm,\n% by performing computations for mini-batches of training data in parallel. \n\nPredictions for crowdGPPL can be made by computing the posterior mean utilities, $\\bs F^*$, \nand the covariance $\\bs \\Lambda_u^*$ for each user, $u$, in the test set:\n\\begin{flalign} \\label{eq:predict_crowd}\n&\\bs F^* = \\hat{\\bs t}^* + \\sum_{c=1}^C \\hat{\\bs v}_{c}^{*T} \\hat{\\bs w}_{c}^*, \\hspace{1cm} \\bs \\Lambda_u^* = \\bs C_{t}^* + \\sum_{c=1}^C \\omega_{c,u}^* \\bs C_{v,c}^* + \\hat{w}_{c,u}^2  \\bs C_{v,c}^*  +\\omega_{c,u}^* \\hat{\\bs v}_{c}\\hat{\\bs v}_{c}^T, &\n\\end{flalign}\nwhere $\\hat{\\bs t}^*$, $\\hat{\\bs v}_{c}^*$ and $\\hat{\\bs w}_{c}^*$ are posterior test means,\n$\\bs C_{t}^*$ and $\\bs C_{v,c}^*$ are posterior covariances of the test items,\nand $\\omega_{c,u}^*$ is the posterior variance of the user components for $u$. \n(see Appendix \\ref{sec:predictions}, Equations \\ref{eq:tstar} to \\ref{eq:omegastar}).\nThe mean $\\bs F^*$ and covariances $\\Lambda^*_u$ can be inserted into Equation \\ref{eq:plphi} to predict pairwise labels.\nIn practice, the full covariance terms are needed only for Equation \\ref{eq:plphi}, so need only be computed\nbetween items for which we wish to predict pairwise labels. ", "meta": {"hexsha": "9448b914ce24951257b90309faaa4e6893201efc", "size": 32204, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/scalable_bayesian_preference_learning_from_crowds/inference.tex", "max_stars_repo_name": "UKPLab/tacl2018-preference-convincing", "max_stars_repo_head_hexsha": "65eb1cd3bf76f8068889880e0f80178e790350ce", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2019-03-01T19:40:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-10T05:53:47.000Z", "max_issues_repo_path": "documents/scalable_bayesian_preference_learning_from_crowds/inference.tex", "max_issues_repo_name": "UKPLab/tacl2018-preference-convincing", "max_issues_repo_head_hexsha": "65eb1cd3bf76f8068889880e0f80178e790350ce", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-13T17:54:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-09T23:39:11.000Z", "max_forks_repo_path": "documents/scalable_bayesian_preference_learning_from_crowds/inference.tex", "max_forks_repo_name": "UKPLab/tacl2018-preference-convincing", "max_forks_repo_head_hexsha": "65eb1cd3bf76f8068889880e0f80178e790350ce", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-02-06T12:08:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-10T20:40:22.000Z", "avg_line_length": 61.340952381, "max_line_length": 252, "alphanum_fraction": 0.6995714818, "num_tokens": 10388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4347302680893116}}
{"text": "\\chapter{Half Wave Rectification}\n\t\\section{Aim}\n\t\t\\begin{itemize}\n\t\t\t\\tightlist\n\t\t\t\\item Explain Rectification\n\t\t\t\\item Explain Half Wave Rectification\n\t\t\t\\item Explain Half Wave Rectification:For Positive Half Cycle\n\t\t\t\\item Explain Half Wave Rectification:For Negative Half Cycle\n\t\t\\end{itemize}\n\n\t\\section{Apparatus}\n\t\t\\begin{itemize}\n\t\t\t\\tightlist\n\t\t\t\\item Silicon/Germanium Diode\n\t\t\t\\item Resistor\n\t\t\t\\item AC Power Source\n\t\t\t\\item Oscilloscope\n\t\t\\end{itemize}\n\t\n\t\\section{Theory}\n\t\t\\subsection{Rectification}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\linewidth]{img/exp6/1}\n\t\t\t\t\\caption{Function of a Rectifier}\n\t\t\t\t\\label{fig:rffxn}\n\t\t\t\\end{figure}\n\t\t\tA rectifier is a device that converts alternating current (AC) to direct current (DC), a process known as rectification. Rectifiers are essentially of two types – a half wave rectifier and a full wave rectifier.\n\t\t\t\n\t\t\\subsection{Half Wave Rectification}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\linewidth]{img/exp6/2}\n\t\t\t\t\\caption{Half Wave Rectification}\n\t\t\t\t\\label{fig:rfhw}\n\t\t\t\\end{figure}\n\t\t\tOn the positive cycle the diode is forward biased and on the negative cycle the diode is reverse biased. By using a diode we have converted an AC source into a pulsating DC source. In summary we have ‘rectified’ the AC signal.\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.3\\linewidth]{img/exp6/3}\n\t\t\t\t\\caption{Half Wave Rectification Circuit}\n\t\t\t\t\\label{fig:rfhwc}\n\t\t\t\\end{figure}\n\t\t\tThe simplest kind of rectifier circuit is the half-wave rectifier.The half-wave rectifier is a circuit that allows only part of an input signal to pass. The circuit is simply the combination of a single diode in series with a resistor, where the resistor is acting as a load.\n\t\t\n\t\t\\subsection{Half Wave Rectifiers – Waveforms}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.7\\linewidth]{img/exp6/6}\n\t\t\t\t\\includegraphics[width=0.7\\linewidth]{img/exp6/4}\n\t\t\t\t\\caption{Half Wave Rectification Wave Form}\n\t\t\t\t\\label{fig:rfhwwf}\n\t\t\t\\end{figure}\n\t\t\tThe output DC voltage of a half wave rectifier can be calculated with the following two ideal equations.\t\t\t\n\t\t\t$$V_{peak}=V_{rms} \\times \\sqrt{2}$$\n\t\t\t$$V_{dc}=\\frac{V_{peak}}{\\pi}$$\n\t\t\n\t\t\\subsection{Half Wave Rectification: For Positive Half Cycle}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\linewidth]{img/exp6/5}\n\t\t\t\t\\caption{Half Wave Rectification - Positive Half Cycle}\n\t\t\t\t\\label{fig:rfhwphc}\n\t\t\t\\end{figure}\t\t\t\n\t\t\tDiode is forward biased, acts as a short circuit, passes the waveform through.\n\t\t\t\n\t\t\tFor positive half cycle: $$V_I - V_b - I \\times r_d - I \\times R=0$$ where,\n\t\t\t$V_I$ is the input voltage,\\\\\n\t\t\t$V_b$ is barrier potential,\\\\\n\t\t\t$r_d$ is diode resistance,\\\\\n\t\t\t$I$ is total current,\\\\\n\t\t\t$R$ is resistance\\\\\n\t\t\t$$I=\\frac{V_I - V_b}{r_d + R}$$\n\t\t\t$$V_O = I \\times R$$\n\t\t\t$$V_O =\\frac{V_I - V_b}{r_d + R} \\times R$$\n\t\t\tFor $r_d << R$,\n\t\t\t$$V_O = V_I- V_b$$\n\t\t\t$V_b$ is 0.3 for Germanium ,\n\t\t\t$V_b$ is 0.7 for Silicon\n\t\t\t\n\t\t\tFor $V_I<V_b$,\n\t\t\t\n\t\t\tThe diode will remain OFF.The Output voltage will be,\n\t\t\t$$V_O =0$$\n\t\t\tFor $V_I>V_b$,\n\t\t\t\n\t\t\tThe diode will be ON.The Output voltage will be,\n\t\t\t$$V_O = V_I- V_b$$\n\t\t\n\t\t\\subsection{Half Wave Rectification: For Negative Half Cycle}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\linewidth]{img/exp6/7}\n\t\t\t\t\\caption{Half Wave Rectification - Negative Half Cycle}\n\t\t\t\t\\label{fig:rfhwnhc}\n\t\t\t\\end{figure}\n\t\t\tDiode is reverse biased, acts as a open circuit, does not pass the waveform through.\n\t\t\t\n\t\t\tFor negative half cycle:\n\t\t\t$$V_O=0 \\quad Since, \\quad I =0$$\n\t\t\n\t\t\\subsection{Half wave Rectification: For an Ideal Diode}\n\t\t\tFor Ideal Diode,\n\t\t\t$$V_b = 0$$\n\t\t\tFor positive half cycle,\n\t\t\t$$V_O = V_I$$\n\t\t\tFor negative half cycle,\n\t\t\t$$V_O = 0$$\n\t\t\t\n\t\t\\subsection{Average output voltage}\t\n\t\t\t\\begin{align*}\n\t\t\t\tV_O &= \\begin{cases} \n\t\t\t\t\tV_m \\sin wt, \\quad\\quad 0 \\leq wt \\leq \\pi\\\\\n\t\t\t\t\t0, \\quad\\quad\\quad\\quad\\quad \\pi \\leq wt \\leq 2 \\pi\n\t\t\t\t\\end{cases}\\\\\n\t\t\t\tV_{av} &= \\frac{V_m}{\\pi} =0.318V_m\n\t\t\t\\end{align*}\n\t\t\n\t\t\\subsection{RMS load voltage}\t\t\t\n\t\t\t$$V_{rms}=I_{rms} \\times R = \\frac {V_m}{2}$$\n\t\t\n\t\t\\subsection{Average load current}\n\t\t\t\\begin{align*}\n\t\t\t\tI_{av} &= \\frac{V_{av}}{R} =\\frac{\\frac{V_m}{\\pi}}{R}\\\\\n\t\t\t\tI_{av} &= \\frac{V_{m}}{\\pi \\times R}=\\frac{I_m}{\\pi}\n\t\t\t\\end{align*}\n\t\t\n\t\t\\subsection{RMS load current}\t\t\t\n\t\t\t$$I_{rms}=\\frac {I_m}{2}$$\n\t\t\t\n\t\t\\subsection{Form factor}\n\t\t\tIt is defined as the ratio of rms load voltage and average load voltage.\n\t\t\t\\begin{align*}\t\t\t\t\t\n\t\t\t\tF.F &= \\frac{V_{rms}}{V_{av}}\\\\\n\t\t\t\t&= \\frac{\\frac{V_{m}}{2}}{\\frac{V_{av}}{2}}=\\frac{\\pi}{2}=1.57\n\t\t\t\\end{align*}\n\t\t\t$$F.F \\geq 1$$\n\t\t\t$$rms \\geq av$$\n\t\t\n\t\t\\subsection{Ripple Factor}\t\t\t\n\t\t\t\\begin{align*}\n\t\t\t\t\\gamma &= \\sqrt{{F.F}^2-1} \\times 100\\%\\\\\n\t\t\t\t&= \\sqrt{{1.57}^2-1} \\times 100\\%\\\\\n\t\t\t\t&= 1.21\\%\n\t\t\t\\end{align*}\t\t\n\t\t\\subsection{Efficiency}\n\t\t\tIt is defined as ratio of dc power available at the load to the input ac power.\n\t\t\t\\begin{align*}\n\t\t\t\tn\\% &= \\frac{P_{load}}{P_{in}} \\times 100\\%\\\\\n\t\t\t\t&= \\frac {{I_{dc}^2} \\times R}{{I_{rms}^2} \\times R}\\times 100\\%\\\\\n\t\t\t\t&= \\frac{\\frac {I_{m}^2}{\\pi^2}}{\\frac{I_{m}^2}{4}}\\times 100\\%\\\\\n\t\t\t\t&= \\frac{4}{\\pi^2}\\times 100\\%\\\\\n\t\t\t\t&= 40.56 \\%\n\t\t\t\\end{align*}\n\t\n\t\t\\subsection{Peak Inverse Volatge}\n\t\t\tFor rectifier applications, peak inverse voltage (PIV) or peak reverse voltage (PRV) is the maximum value of reverse voltage which occurs at the peak of the input cycle when the diode is reverse-biased.The portion of the sinusoidal waveform which repeats or duplicates itself is known as the cycle. The part of the cycle above the horizontal axis is called the positive half-cycle, the part of the cycle below the horizontal axis is called the negative half cycle. With reference to the amplitude of the cycle, the peak inverse voltage is specified as the maximum negative value of the sine-wave within a cycle's negative half cycle.\n\t\t\t\t\t\t\t\n\t\t\t\n\t\t\t$$ V_{PIV}=V$$\n\t\t\t$$ -V_m +V=0 \\Rightarrow V=V_m$$\n\t\t\t$$ V_{PIV} \\geq V_m$$\n\t\n\t\\section{Procedure}\n\t\t\\begin{enumerate}\n\t\t\t\\tightlist\n\t\t\t\\item Set the resistor $R_L$.\n\t\t\t\\item Click on 'ON' button to start the experiment.\n\t\t\t\\item Click on 'Sine Wave' button to generate input waveform\n\t\t\t\\item Click on 'Oscilloscope' button to get the rectified output.\n\t\t\t\\item Vary the Amplitude, Frequency, volt/div using the controllers.\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.7\\linewidth]{img/exp6/8}\n\t\t\t\t\\caption{}\n\t\t\t\t\\label{fig:rfhwp}\n\t\t\t\\end{figure}\n\t\t\t\\item Click on \"Dual\" button to observe both the waveform.\n\t\t\t\\item Channel 1 shows the input sine waveform, Channel 2 shows the output rectified waveform.\n\t\t\t\\item Calculate the Ripple Factor.Theoretical Ripple Factor= 1.21.\n\t\t\\end{enumerate}\n\t\n\t\\section{Calculations}\t\n\t\tMeasure the $V_m$\n\t\t\n\t\t$$V_{rms}= \\frac{V_m}{2}$$\n\t\t$$V_{dc}= \\frac{V_m} {\\pi}$$\n\t\tRipple Factor($RP$)$$RP = \\frac{V_{ac}}{V_{dc}}$$\n\t\tSince, $$V_{ac}=\\sqrt{(V^2_{rms}-V^2_{dc})}$$\t\t\n\t\tPeak Current: $0.74999999 mA$\n\t\t\n\t\\section{Observations}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tdomain=0:3*360,\n\t\t\t\t\tsamples=4*360,\n\t\t\t\t\txtick=\\empty,\n\t\t\t\t\twidth=15cm, height=6cm,\n\t\t\t\t\tymin=-1,\n\t\t\t\t\tenlarge x limits=false\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot [red, very thick] {sin(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Un-Rectified AC Waveform}\n\t\t\\end{figure}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tdomain=0:3*360,\n\t\t\t\t\tsamples=4*360,\n\t\t\t\t\txtick=\\empty,\n\t\t\t\t\twidth=15cm, height=6cm,\n\t\t\t\t\tymin=0,\n\t\t\t\t\tenlarge x limits=false\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot [blue, very thick] {sin(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Half Wave Rectified Waveform}\n\t\t\\end{figure}\n\t\n\t\\section{Result}\n\t\tA rectifier is a device that converts alternating current (AC) to direct current (DC). It is done by using a diode or a group of diodes. Half wave rectifiers use one diode, while a full wave rectifier uses multiple diodes.\n\t\t\n\t\tThe working of a half wave rectifier takes advantage of the fact that diodes only allow current to flow in one direction.\n\t\t\t", "meta": {"hexsha": "d933b15e002d7edf856e9acc9ac1a165e3229948", "size": 8129, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Semester 2/Sem2_ECL_File/sections/6-exp6.tex", "max_stars_repo_name": "anhatsingh/Anhat_LATEX", "max_stars_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Semester 2/Sem2_ECL_File/sections/6-exp6.tex", "max_issues_repo_name": "anhatsingh/Anhat_LATEX", "max_issues_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Semester 2/Sem2_ECL_File/sections/6-exp6.tex", "max_forks_repo_name": "anhatsingh/Anhat_LATEX", "max_forks_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3434782609, "max_line_length": 636, "alphanum_fraction": 0.6598597613, "num_tokens": 2805, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.4347302680893116}}
{"text": "% Created 2020-10-06 mar 18:24\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=169, usenames, dvipsnames]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\usepgfplotslibrary{groupplots}\n\\usepackage{pgfplotstable}\n\\newcommand*{\\shift}{\\operatorname{q}}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.6,0.1}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{2020-10-06}\n\\title{Process Automation Laboratory  - Anti-windup assignment}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Process Automation Laboratory  - Anti-windup assignment},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.3.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\n\\section{Context}\n\\label{sec:org7348bef}\n\\begin{frame}[label={sec:orgccface9}]{The two-tank system}\n\\begin{center}\n\\includegraphics[width=0.8\\linewidth]{../../figures/two-tanks-shutoff-valve.png}\n\\end{center}\n\\end{frame}\n\n\n\\section{Anti-windup}\n\\label{sec:orge5ed4e3}\n\n\\begin{frame}[label={sec:org755088d}]{Anti-windup using back-calculation - Spot the mistake}\n\\begin{center}\n\\includegraphics[height=0.38\\textheight]{../../figures/astrom-back-tracking.png}\n\\includegraphics[height=0.42\\textheight]{../../figures/back-tracking-review.png}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:orgede0024}]{Anti-windup using back-calculation}\n\\begin{center}\n\\includegraphics[width=.82\\linewidth]{../../figures/antiwindup-review.png}\n\\end{center}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "67a5d8ffc65a0c9b5728cddbb83783dce628a3b2", "size": 1829, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pid/slides/lecture-anti-windup-review.tex", "max_stars_repo_name": "kjartan-at-tec/mr2015", "max_stars_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pid/slides/lecture-anti-windup-review.tex", "max_issues_repo_name": "kjartan-at-tec/mr2015", "max_issues_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pid/slides/lecture-anti-windup-review.tex", "max_forks_repo_name": "kjartan-at-tec/mr2015", "max_forks_repo_head_hexsha": "1134f3a99ef72e4a17d44edb4d288daad84f3e70", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7121212121, "max_line_length": 92, "alphanum_fraction": 0.760524877, "num_tokens": 621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.7577943658046608, "lm_q1q2_score": 0.4347302649513024}}
{"text": "% !Mode:: \"TeX:UTF-8\"\n% !TEX program  = xelatex\n\\title{What Angle Should We Throw a Football for Maximum Range}\n\\author[Iydon]{Iydon at DataHub}\n\\date{\\today}\n\\institute[SUSTech]{\n    Department of Mathematics \\\\\n    Southern University of Science and Technology\n}\n\n\\begin{frame}\n\t\\maketitle\n\\end{frame}\n\n\n\n\\section{Introduction}\n\\begin{frame}[t]{Projectile Motion}\n    \\begin{block}{Projectile motion}\n        Projectile motion is a form of motion experienced by an object or particle (a projectile) that is thrown near the Earth’s surface and moves along a curved path under the action of gravity only\\footnote{In particular, the effects of air resistance are assumed to be negligible.}.\n    \\end{block}\n\\end{frame}\n\n\\begin{frame}{Projectile Motion}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=.7\\textwidth]{../figures/quadratic_equation-1.png}\n        \\caption{Parabolic trajectories at different angles}\n    \\end{figure}\n\\end{frame}\n\n\n\n\\section{Quadratic Equation}\n\\begin{frame}[t]{Definition}\n    \\begin{block}{Quadratic equation}\n        In algebra, a quadratic equation (from the Latin \\emph{quadratus} for ``square'') is any equation having the form\n        \\begin{equation}\\label{E:1}\n            c_2 x^2 + c_1 x + c_0 = 0,\n        \\end{equation}\n        where $x$ represents an unknown, and $c_n$ ($n=0,1,2$) represent known numbers, with $a\\neq 0$. If $a=0$, then the equation is linear, not quadratic, as there is no $c_2 x^2$ term. Then we can divide both sides of the equation by $c_2$, and replace $c_1/c_2$ with $b$, $c_0/c_2$ with $c$.\n        \\begin{equation}\\label{E:quadratic-equation}\n            x^2 + bx + c = 0.\n        \\end{equation}\n        That is, every quadratic equation can be transformed into the form of Equation~\\eqref{E:quadratic-equation}.\n    \\end{block}\n\\end{frame}\n\n\\begin{frame}[t]{Quadratic Formula and Its Derivation}\n    \\begin{equation}\\label{E:quadratic-formula-1}\n        \\begin{aligned}\n            x^2 + bx + c &= 0 \\\\\n            x^2 + 2\\frac{b}{2}x &= -c \\\\\n            \\left(x+\\frac{b}{2}\\right)^2 &= \\frac{b^2-4c}{4}.\n        \\end{aligned}\n    \\end{equation}\n    \n    The left side of the Equation~\\eqref{E:quadratic-formula-1} is a squared form, which means that it may have multiple solutions. That is, if $b^2-4c\\geq 0$,\n    \\begin{equation}\\label{E:quadratic-formula-2}\n        \\begin{aligned}\n            x + \\frac{b}{2} &= \\pm \\frac{\\sqrt{b^2-4c}}{2} \\\\\n            x &= \\frac{-b\\pm\\sqrt{b^2-4c}}{2}.\n        \\end{aligned}\n    \\end{equation}\n\\end{frame}\n\n\n\n\\section{Applications}\n\\begin{frame}[t]{Solution to Article Title}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=.5\\textwidth]{../figures/quadratic_equation-3.png}\n        \\caption{Parabolic trajectories at different angles}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}[t]{Solution to Article Title}\n    we have both horizontal and vertical distance at time $t$,\n    \\begin{equation}\\label{E:solution-2}\n        \\begin{cases}\n            S_x &= V\\cos(\\theta)t \\\\\n            S_y &= V\\sin(\\theta)t - \\frac{1}{2} gt^2\n        \\end{cases}\n    \\end{equation}\n\n    We can find all of the coordinate $(S_x, S_y)$ with angle $\\theta$. From Equation~\\eqref{E:solution-2}, we have $t=\\tfrac{2V\\sin(\\theta)}{g}$, then we substitute the expression of $t$ back to the $S_y$, we have the quadratic equation\n    \\begin{equation}\\label{E:solution-3}\n        S_y = \\tan(\\theta)S_x - \\frac{g}{2V^2\\cos^2(\\theta)}S_x^2.\n    \\end{equation}\n\n    From quadratic formula, we can solve this quadratic equation, the solutions are $0$ and $\\tfrac{2V^2}{g}\\sin(\\theta)$. Obviously, $0$ is the initial position, then the football will land at $\\tfrac{2V^2}{g}\\sin(\\theta)$, that is, $\\tfrac{V^2}{g}\\sin(2\\theta)$.\n\\end{frame}\n\n\\begin{frame}[t]{Simulation of Projectile Motion}\n    \\begin{block}{}\n        You can use quadratic equation to simulate projectile motion, which can solve free fall problems. If you are familiar with Python, you can use Python to draw the pictures of trajectories, and you will find it easy to use Python to solve quadratic equations, especially in symbolic calculations. And the code is in appendix of article.\n    \\end{block}\n\\end{frame}\n\n\n\n\\section{Conclusions}\n\\begin{frame}[t]{Conclusions}\n    \\begin{block}{}\n        From this article, we introduce projectile motion and quadratic equation through a real world problem --- \\emph{what angle should we throw a football for maximum range}, then we give a proper and accurate definition of quadratic equation, from which we derive quadratic formula for solving quadratic equations. Furthermore, we list some useful applications of the quadratic equation and implement them in \\texttt{Python}.\n    \\end{block}\n\\end{frame}\n\n\n\n\\section*{Acknowledgments}\n\\begin{frame}[t]{Acknowledgments}\n    \\begin{itemize}\n        \\item The author would like to thank the Associate Editor and one referee for their valuable comments which have greatly improved the paper.\n        \\item The author’s research is fully supported by the DataHub Organization of China (No. 1000001).\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Acknowledgments}\n    \\centering\\Huge Thank you!\n\\end{frame}\n\n\n\n\\section*{References}\n\\begin{frame}[t]{References}\n\t\\begin{thebibliography}{9}\\large\n        \\bibitem{C:1} Wikipedia contributors. Projectile motion — Wikipedia, the free encyclopedia[EB/OL]. 2019. \\url{https://en.wikipedia.org/w/index.php?title=Projectile_motion&oldid=928426750}.\n        \\bibitem{C:2} Wikipedia contributors. Trajectory — Wikipedia, the free encyclopedia[EB/OL]. 2019. \\url{https://en.wikipedia.org/w/index.php?title=Trajectory&oldid=929280103}.\n        \\bibitem{C:3} Wikipedia contributors. Quadratic equation — Wikipedia, the free encyclopedia [EB/OL]. 2019. \\url{https://en.wikipedia.org/w/index.php?title=Quadratic_equation&oldid=929716375}.\n    \\end{thebibliography}\n\\end{frame}\n", "meta": {"hexsha": "67b2d86db7fa6374625752ac7ff600dedd885578", "size": 5887, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MA320/slides/sections/quadratic_equation.tex", "max_stars_repo_name": "iydon/homework", "max_stars_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2019-10-20T08:18:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-11T12:14:56.000Z", "max_issues_repo_path": "MA320/slides/sections/quadratic_equation.tex", "max_issues_repo_name": "iydon/homework", "max_issues_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2022-01-13T03:04:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T00:49:10.000Z", "max_forks_repo_path": "MA320/slides/sections/quadratic_equation.tex", "max_forks_repo_name": "iydon/homework", "max_forks_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-11-02T05:46:01.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-12T23:11:28.000Z", "avg_line_length": 43.9328358209, "max_line_length": 429, "alphanum_fraction": 0.6862578563, "num_tokens": 1687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.43471187121851607}}
{"text": "\\graphicspath{{Ch2_background/}}\n\n\\chapter{Background\\label{sec:bg}}\n\nWe consider prediction problems where we are given inputs and need to make some decision about them. In the context of image recognition, let us consider images of natural objects (\\eg dogs) as input. The task is to predict semantic content in the image. We will consider the image classification task where a single label per image (\\eg `dog' or `person') must be predicted, and more complex tasks where rich description (\\eg `dog on surfboard') must be predicted (\\fig{\\ref{fig:problem}}).%\\looseness-1\n\n\\begin{figure}[htbp]\n    \\centering\n     \\includegraphics[width=0.9\\textwidth, align=c]{figs/problem_form.pdf} \n    \\caption{Prediction of object categories and their relationships given an image.}\n    \\label{fig:problem}\n\\end{figure}\n\n\n\\section{Neural networks\\label{sec:bg_nn}}\nIn image recognition tasks,\n%, such as image classification, \nthe input is high dimensional\\footnote{Image resolution varies drastically between image tasks, but generally represent high-dimensional cases. For example, in MNIST~\\citep{lecun1998gradient}, the images are 28$\\times$28 pixels, \\ie 784 dimensional. In more realistic tasks, such as PASCAL~\\citep{everingham2010pascal}, images can be 500$\\times$300 pixels, \\ie 150,000 dimensional.} and the decision process is hard to formally describe using simple expert rules and raw inputs.\nTherefore, the currently dominant strategy to solve such a task is to formulate it as an optimization problem:\n%\n\\begin{equation}\n    \\w^* = \\underset{\\w}{\\text{arg\\,min }} \\ \\mathcal{L}(f_\\w, \\mathcal{D}),\n\\end{equation} \n%\n%$\\in \\mathcal{D}$\n\\noindent where $f_\\w$ is some function parameterized by $\\w$, $\\mathcal{D}$ is the dataset associated with the task and $\\mathcal{L}$ is the objective to minimize for this dataset. The goal of solving this problem is to find optimal parameters $\\w^*$ for $f_\\w$.\nFor large and complex datasets, the state-of-the-art solutions to this optimization problem are often based on using deep neural networks (DNNs) as $f_\\w$. Finding globally optimal $\\w^*$ of DNNs is generally intractable due to the highly non-convex nature of $\\mathcal{L}(f_\\w, \\mathcal{D})$~\\citep{choromanska2015loss}. Nevertheless, local optima can be found using methods based on gradient descent~\\citep{ruder2016overview,kingma2014adam}.\\looseness-1\n\n%The design of DNNs varies drastically depending on the task. \nDNNs can have drastically different designs depending on the task. This thesis concerns three different designs of DNNs. The first is one of the earliest types of DNNs, colloquially referred to as a multilayer perceptron (MLP). Next, we consider convolutional neural networks (\\cnns) -- DNNs designed specifically for perceptual tasks, such as image recognition. Lastly, we consider graph neural networks (\\gnns) that are designed for graph-structured data. MLPs, \\cnns and \\gnns are the core building blocks of this thesis.\n%\\footnote{Some portions of \\S~\\ref{sec:bg_nn} are based on my blog posts: \\url{https://medium.com/@BorisAKnyazev}}.\n\n\\subsection{Multilayer perceptrons\\label{sec:bg_mlp}}\nMLPs or, more precisely, multilayer feedforward fully-connected neural networks, consist of $L$ layers of trainable parameters (weights) $\\w = [\\W^{(1)}, \\W^{(2)}, ..., \\W^{(L)}]$. Given $N$ input data points $\\X \\in \\R^{N \\times d} $ of dimensionality $d$ from the dataset $\\mathcal{D}$, the MLP sequentially transforms the input $\\X$ as\\footnote{For simplicity, in \\eqref{eq:mlp} we ignore the bias term $\\mathbf{b}$ that in practice is added to the output of $\\X^{(l)}\\W^{(l)}$. The bias is essential when a single layer is used, however it has limited practical value in the case of $L > 1$.}:\n%\n\\begin{equation}\n    \\label{eq:mlp}\n    \\X^{(l+1)} = \\sigma(\\X^{(l)}\\W^{(l)}),\n\\end{equation}\n%\n\\noindent where $l \\in [1,L]$ and an input to the first layer $\\X^{(1)}$ is equal to $\\X$. Function $\\sigma$ is some nonlinearity such as the Rectified Linear Unit (ReLU) applied element-wise to $\\X^{(l)}\\W^{(l)}$: $\\sigma (\\X^{(l)}\\W^{(l)})=\\max(0, \\X^{(l)}\\W^{(l)})$. More advanced nonlinearities can lead to better training and generalization properties, e.g. leaky ReLU~\\citep{maas2013rectifier} or the Exponential Linear Unit (ELU)~\\citep{clevert2015fast}. Applying $\\sigma$ is essential to learn nonlinear transformations. One of the simplest nonlinear transformations is the XOR logic operation that was famous in diminishing the interest in AI (``AI winter'') in the 1970s\\footnote{More about that period can be read at \\url{https://dev.to/jbahire/demystifying-the-xor-problem-1blk} or \\url{https://towardsdatascience.com/history-of-the-first-ai-winter-6f8c2186f80b}.}. For the final layer ($l=L$), it is common to use a nonlinearity specific for the task. For example, in the case of predicting binary labels $\\mathbf{y} \\in [0,1]^N$ for data points $\\X$, a sigmoid function can be applied. In the case of regression tasks, $\\mathbf{y} \\in \\R^N$, \\ie, the final nonlinearity is removed.\nAll $N$ data points in $\\X$ can be processed by MLPs independently, so parallel computing enables very efficient usage of MLPs. $N$ data points processed in parallel are often called a mini-batch, or batch\\footnote{When ``batch'' and ``mini-batch'' are used to describe the operation of learning, batch means updates based on the entire dataset and mini-batch means updates based on a subset.}.\\looseness-1\n%Multiple layers with interleaved nonlinearities are required to learn such and more complex transformations.\n%For example an MLP with a single layer of parameters $\\W \\in \\R^{d_1 \\times d_2}$: $f(\\X, \\W) = \\X\\W$. \n%The MLP layers can be stacked to form a deep network: $f(\\X, \\W) = (\\sigma(\\X\\W^{1}))\\W^{2}$, where $\\sigma$ is some nonlinearity such as ReLU to learn a nonlinear transformations. \n%Without $\\sigma$ multiple layers will be equivalent to a single layer thus preventing learning complex transformations.\n\\paragraph{Applications of MLPs.} MLPs can be in principle applied to any tabular data $\\X$ where rows are data points and columns are features or dimensions. While images can be represented as tabular data by flattening spatial dimensions~\\citep{ciregan2012multi}, MLPs are more common in cases when the dimensions in $\\X$ are not ordered in any meaningful way (\\ie there is no benefit of leveraging the order).\n%(\\ie the order can be changed without affecting the training procedure).\nMLPs are often used as building blocks of many other types of DNNs, including recently developed Transformers~\\citep{vaswani2017attention,dosovitskiy2020image} and Graph Neural Networks~\\citep{kipf2016semi} (\\S~\\ref{sec:bg_gnn}). Oftentimes, the last few layers of Convolutional Neural Networks (\\S~\\ref{sec:bg_cnn}) are modeled as MLPs~\\citep{simonyan2014very}.\nRecently, models based on MLPs were revisited in large-scale image tasks, where they showed competitive results~\\citep{touvron2021resmlp}.\\looseness-1\n\n\\subsection{Convolutional neural networks\\label{sec:bg_cnn}}\n\nThe main building blocks of \\cnns, convolution and downsampling, were introduced in~\\citep{fukushima1982neocognitron}.\n%Convolution and downsampling are the main building blocks of CNNs~\\citep{fukushima1982neocognitron}. \nSubsequently, in \\citep{lecun1998gradient}, \\cnns were combined with a gradient descent-based training algorithm to effectively learn the parameters of \\cnns from raw inputs (images) without manually engineering features.\nFollowing~\\eqref{eq:mlp} for the MLP layer, the convolutional layer for $N$ images ${\\cal X} \\in \\R^{N \\times C \\times H \\times W}$ and $K$ filters (kernels, weights) $\\mathcal{W} \\in \\R^{K \\times C \\times h \\times w}$ can be defined as~\\citep{vedaldi2015matconvnet}:\n%\n\\begin{equation}\n    \\label{eq:conv}\n    {\\cal X}_{n,k,i,j}^{(l+1)} = \\sigma(\\sum_c \\sum_h \\sum_w {\\cal X}_{n,c,i-h,j-w}^{(l)} {\\cal W}_{k,c,h,w}^{(l)}),\n\\end{equation}\n%\n\\noindent where $C$ is the number of channels (\\eg $C=3$ for RGB images); $H,W$ are the height and width of images respectively; $K$ is the number of filters and $h,w$ are their height and width respectively. Each $k$-th filter of $\\mathcal{W}$ slides over the input along the spatial dimensions and for each spatial location $i \\in [1,H], j \\in [1,W]$ of $\\mathcal{X}$ computes the dot product between the local region and the kernel (\\fig{\\ref{fig:conv}}).\\looseness-1\n\n\n\\begin{figure}[htbp]\n    \\centering\n    \\footnotesize\n    \\begin{tabular}{cccc}\n    \\includegraphics[width=0.22\\textwidth]{figs/mnist_digit.pdf} & \n    \\includegraphics[width=0.22\\textwidth]{figs/conv_kernel.pdf} & \n    \\includegraphics[width=0.22\\textwidth]{figs/conv_output.pdf} & \n    \\includegraphics[width=0.22\\textwidth]{figs/relu_output.pdf} \\\\\n    Input image & Convolutional filter & Output of convolution & Output after ReLU \\\\\n    \\end{tabular}\n    \\caption{Example of the convolution operation for a single image and single filter.}\n    \\label{fig:conv}\n\\end{figure}\n\nThe convolution operation exploits a 2D local structure in images, formally described in~\\citep{bronstein2017geometric}:\n\\vspace{-3pt}\n\\begin{itemize}\n    \\setlength{\\itemsep}{1pt}\n    \\item Shift-invariance -- if we spatially translate an object on the image to the left/right/up/down, we still should be able to recognize it. This is exploited by sharing filters across all locations.\n    \\item Locality -- nearby pixels are closely related and often represent some semantic concepts, such as object parts. This is exploited by using filters with spatial dimensions $h > 1$ and $w > 1$, which can capture image features in a local spatial neighborhood.\n    \\item Compositionality (or hierarchy) -- a larger region in the image is often a semantic parent of smaller regions it contains. For example, a dog is a parent of a head, body, legs, etc. \n    %Likewise, the head is a parent of ears, nose, eyes, etc. \n    This implicitly is exploited by stacking convolutional layers.\n\\end{itemize}\n\nAnother important component of \\cnns is the downsampling operation. Downsampling reduces the spatial size of inputs, which is important for computational efficiency, particularly for large inputs. Downsampling is usually based on spatial pooling applied to a local region similar to convolution. Typically, average or max poolings are used that do not have trainable parameters. In practice, pooling can be replaced with modified (strided) convolution to simplify the overall network~\\citep{springenberg2014striving}.\\looseness-1\n\nAs compared to MLPs, \\cnns applied to images have another strength besides those listed above. In particular, the number of trainable parameters in convolutional filters $\\mathcal{W}$ does not depend on the input spatial dimensions $H,W$. In principle, the same \\cnn can be trained on images with $H=W=28$ as well as $H=W=500$. In addition, \\cnns are highly efficient due to their ability to apply filters $\\mathcal{W}$ independently and in parallel for each spatial location, each filter and each image. As a result, \\cnns have been adapted to a broad range of tasks beyond image classification.\n%In other words, the model is parametric.\n\n\\vspace{-3pt}\n\\paragraph{Applications of \\cnns.} \\cnns initially were proposed for simple image classification tasks, such as handwritten digit recognition (MNIST)~\\citep{lecun1998gradient}. Subsequently, a larger and deeper network proposed in \\citep{krizhevsky2012imagenet} led to the top-1 result on the ImageNet 2012 challenge of large-scale image classification~\\citep{russakovsky2015imagenet} outperforming hand-designed visual features such as SIFT~\\citep{lowe2004distinctive}.\nCompared to~\\citep{lecun1998gradient}, the main changes made in \\citep{krizhevsky2012imagenet} to \\cnns were: i) dramatically increased size of a \\cnn possible due to larger and cheaper computational resources available, ii) a large annotated dataset (\\ie ImageNet), iii) applying nonlinearities and regularization methods such as ReLU and Dropout~\\citep{hinton2012improving}.\nSince then, \\cnns have dominated visual tasks~\\citep{gu2018recent} and grown significantly in size showing superior results in image and video object\n%(\\eg a dog, a surfboard in \\fig{\\ref{fig:problem}})\ndetection~\\citep{ren2015faster,wang2017video,he2016deep,he2015delving}, image and video semantic segmentation~\\citep{long2015fully,shelhamer2016clockwork}, video recognition~\\citep{simonyan2014two}, image and video generation~\\citep{goodfellow2014generative,vondrick2016generating}, learning to estimate the optical flow between a pair of images~\\citep{dosovitskiy2015flownet}, and many other tasks.\nIn these and more complex tasks, such as visual question answering (VQA)~\\citep{antol2015vqa}, \\cnns are typically used as a ``backbone'' to extract visual features from images. The same backbone and its trained parameters can be used across different tasks. The procedure of reusing the backbone parameters from one task to improve on another task is called ``transfer learning''. Typically, backbones trained on large image tasks such as ImageNet show the best transfer learning abilities~\\citep{huh2016makes,kornblith2019better}.\n%``Transfer learning'' is a common practice in/for X that transfer \\cnns pretrained on large image datasets such as ImageNet. \nFinally, \\cnns' computational efficiency has been significantly improved. In particular, architectural enhancements~\\citep{howard2017mobilenets,cai2019onceforall}, as well as compression and distillation techniques~\\citep{cheng2017survey} together with very efficient implementations~\\citep{chetlur2014cudnn} enabled the deployment of \\cnns on low-resource mobile devices further extending \\cnns' application reach.\\looseness-1\n% to a downstream task\n%For example, object detectors predict a set of bounding boxes (x,y,width,height) for each object and their category. In \\fig{\\ref{fig:problem}} the object detector should detect a dog, surfboard, wave and, ideally, fine-grained details such as vest and dog's body parts.\n%The widespread utility of \\cnns is reinforced by their efficiency, which is due to the parallelization of the convolution operation. \\looseness-1\n\n%\\cnns are the main backbone of computer vision models, such as object detectors~\\citep{ren2015faster}. \n\n\\subsection{Graph neural networks\\label{sec:bg_gnn}}\n\nThe wide success of \\cnns have motivated their application to more tasks.\n%methods in other tasks where \n%One of such tasks is learning from graph-structured data. \nIn tasks such as chemistry, physics and social networks,\n% Graph-structured data are ubiquitous in\n%, transportation, 3D geometry, visual reasoning, and others\nthe data are represented as graphs. \n%However, applying \\cnns to graphs is not straightforward as there is no notion of spatial translation in graphs. \nHowever, convolution \\eqref{eq:conv} requires data to reside on a ``regular grid'', a Euclidean coordinate system where all the data points are located at the discrete and equally spaced coordinates consistent among all samples~\\citep{bronstein2017geometric}. For example, all MNIST images reside on the same 28$\\times$28 regular grid. In contrast, graphs generally reside on ``irregular grids'' that do not have a notion of spatial translation, preventing the application of convolution as per \\eqref{eq:conv}.\\looseness-1\n\nFormally, a graph $\\G$ consists of an unordered set of $N$ nodes, $\\V$, connected by edges, $\\E$. \nThe edges are often encoded by an adjacency matrix $\\A \\in \\R^{N \\times N}$. The number of neighbors for each node can be then defined as a diagonal matrix $\\D$, where $\\D_{ii} = \\sum_j \\A_{ij}$. %, which is binary if the graph is unweighted.\nDefining convolution on graphs is non-trivial because the nodes are generally unordered, and not attached to a particular coordinate system, and the node degree $\\D_{ii}$ can vary for each $i$-th node.\n\nTo define convolution on graphs, a spectral graph theory has been applied~\\citep{bruna2013spectral}. This theory is based on extending the spectral definition of convolution in signal processing. For signals, we can define spectral convolution equivalent to the spatial definition in~\\eqref{eq:conv} using the Discrete Fourier Transform. Similarly, spectral convolution on graphs can be computed~\\citep{belkin2001laplacian,chung1997spectral,bruna2013spectral}\\footnote{An extended description of defining spectral convolution on graphs can be found in my blog post: \\url{https://towardsdatascience.com/spectral-graph-convolution-explained-and-implemented-step-by-step-2e495b57f801}.} based on the eigendecomposition of the graph Laplacian $\\Lapl = \\mathbf{I}_N - \\D^{-1/2}\\A\\D^{-1/2}$, where $\\mathbf{I}_N$ is an $N \\times N$ identity matrix. In particular, the eigendecomposition of $\\Lapl$ is defined as $\\Lapl=\\mathbf{V}\\mathbf{\\Lambda}\\mathbf{V}^T$, where $\\mathbf{V}$ are eigenvectors and $\\mathbf{\\Lambda}$ are eigenvalues.\nGiven node features $\\X^{(l)} \\in \\R^{N \\times d}$, the spectral graph convolution layer with filters $\\W^{(l)}$ can be then defined as:\n%\n\\begin{equation}\n \\label{eq:graph_spectral_conv}    \n \\X^{(l+1)} = \\sigma \\Big( \\mathbf{V} (\\mathbf{V}^T\\X^{(l)} \\odot \\mathbf{V}^T\\W^{(l)}) \\Big),\n\\end{equation}\n%\n\\noindent where $\\odot$ is element-wise multiplication. Similarly to the spectral convolution in signal processing, in \\eqref{eq:graph_spectral_conv} the features and filters are first projected into the spectral domain where they are multiplied. The result is then reconstructed back to the original domain.\n\nA major disadvantage of spectral graph convolution defined in \\eqref{eq:graph_spectral_conv} is the necessity to compute the eigendecomposition for each graph. In many graph tasks, graphs have very different structures (and different eigenvectors $\\mathbf{V}$) and it is unclear if the same $\\W^{(l)}$ can adapt to different $\\mathbf{V}$~\\citep{nilsson2020experimental}. \n%For example, at test time, for a new graph and a new set of eigenvectors, these filters might be inappropriate.\nMoreover, computing eigendecomposition for large graphs is a computationally intensive process.\nTo eliminate the need of eigendecomposition, %\\citet{defferrard2016convolutional} proposed to approximate \\eqref{eq:graph_spectral_conv} with Chebyshev polynomials of order $K \\in [1, N]$. Chebyshev convolution aggregates node features within the $K$-hop neighborhood. \nspectral graph convolution \\eqref{eq:graph_spectral_conv} can be approximated using recursive Chebyshev polynomials $T_k$ and the property of eigendecomposition that $\\Lapl^k=(\\mathbf{V} \\mathbf{\\Lambda} \\mathbf{V}^T)^k = \\mathbf{V} \\mathbf{\\Lambda}^k \\mathbf{V}^T$.\nTo derive approximate Chebyshev graph convolution, \nthe polynomials $T_k$ are first applied to the rescaled graph Laplacian $\\tilde{\\Lapl}=2\\Lapl/\\lambda_{\\max} - \\mathbf{I}_N$~\\citep{hammond2011wavelets, defferrard2016convolutional}:\\looseness-1\n%\n\\begin{equation}\n\\label{eq:cheb_lapl}\nT_k(\\tilde{\\Lapl}) = 2 \\tilde{\\Lapl} T_{k-1}(\\tilde{\\Lapl}) - T_{k-2}(\\tilde{\\Lapl}), \n\\end{equation}\n%\n\\noindent where $k \\in [1, N]$, $T_0(\\tilde{\\Lapl}) = \\mathbf{I}_N$ and $T_1(\\tilde{\\Lapl}) = \\tilde{\\Lapl}$; $\\lambda_{\\max}$ is the largest eigenvalue of $\\Lapl$.\nUsing \\eqref{eq:cheb_lapl} and the aforementioned property of eigendecomposition that $\\Lapl^k= \\mathbf{V} \\mathbf{\\Lambda}^k \\mathbf{V}^T$, \\citet{hammond2011wavelets, defferrard2016convolutional} derived that spectral graph convolution can be approximated as a sum of the $T_k(\\tilde{\\Lapl})$ terms weighted by trainable parameters $\\W^{(l)}_k$. Hence, the Chebyshev graph convolution layer can be defined as:\n%\n\\begin{equation}\n\\label{eq:cheb_graph_conv}\n\\X^{(l+1)} = \\sigma \\Big(\\sum^{K-1}_{k=0} T_k(\\tilde{\\Lapl}) \\X^{(l)} \\W^{(l)}_k \\Big),\n\\end{equation}\n%\n\\noindent where $K \\in [1, N]$ is a hyperparameter controlling how global is the receptive field of the convolution. In particular, the terms $T_k(\\tilde{\\Lapl})$ include powers $\\tilde{\\Lapl}^k$ enabling a $(k-1)$-hop receptive field and allowing to approximate spectral convolution. For example, for $K=N$ the convolution \\eqref{eq:cheb_graph_conv} is performed globally based on the entire graph structure making it approximately equal to spectral convolution \\eqref{eq:graph_spectral_conv}. For $K=1$ we have $T_0(\\tilde{\\Lapl}) = \\mathbf{I}_N$, so the convolution is performed ignoring the graph structure, while for $K=2$ the convolution is performed based on the 1-hop neighborhood of nodes, and so forth.\nStacking Chebyshev graph convolution layers \\eqref{eq:cheb_graph_conv} form a graph neural network called a ChebyNet studied in our works~\\citep{knyazev2018spectral,knyazev2019image,knyazev2019understanding}.\n\n\\citet{kipf2016semi} studied the 1-hop Chebyshev graph convolution (with $K=2$) and proposed its highly-effective and efficient simplification:\\looseness-1\n%\n\\begin{equation}\n    \\label{eq:graph_conv_kipf}\n    \\X^{(l+1)} = \\sigma(\\hat{\\A}\\X^{(l)}\\W^{(l)}),\n\\end{equation}\n%\n\\noindent where $\\hat{\\A}$ is a normalized adjacency matrix similar to the rescaled graph Laplacian $\\tilde{\\Lapl}$: $\\hat{\\A} = \\tilde{\\D}^{-1/2}\\tilde{\\A}\\tilde{\\D}^{-1/2}$, and $\\tilde{\\D}_{ii} = \\sum_j \\tilde{\\A}_{ij}$; $\\tilde{\\A} = \\A + I_N$ to include self-loops into convolution. Essentially, \\eqref{eq:graph_conv_kipf} combines the first two terms of \\eqref{eq:cheb_graph_conv} for $k=[1,2]$ into a single operation. The model based on multiple convolutions \\eqref{eq:graph_conv_kipf} is commonly referred to as a graph convolutional network (GCN). In this thesis, we will use a more general term ``graph neural network'' (\\gnn) to refer to this and other graph models.\\looseness-1\n\nThe graph layer defined in~\\eqref{eq:graph_conv_kipf} is remarkably similar to the one of the MLP layer~\\eqref{eq:mlp}. The only difference is the normalized adjacency matrix $\\hat{A}$ used in~\\eqref{eq:graph_conv_kipf}. Therefore, a \\gnn can be viewed as an MLP exploiting the relational information between data points (or node features). \n\nFollowing the example in \\fig{\\ref{fig:conv}} (\\S~\\ref{sec:bg_cnn}), graph convolution \\eqref{eq:graph_conv_kipf} can be illustrated based on an MNIST image. To represent an image as a graph, nodes correspond to pixel coordinates and edges connect only four spatially adjacent pixels (\\fig{\\ref{fig:graph_conv}}). In the graphs, pixel intensities are inverted for better visualization with black nodes corresponding to white pixels. The image is resized to 14$\\times$14 and a small amount of Gaussian noise is added to illustrate the effect of graph convolution. To compute the output, only $\\hat{\\A}\\X^{(l)}$ is used while $\\W^{(l)}$ is ignored. Such graph convolution is equivalent to a low-pass mean filter commonly used in signal processing to denoise the signal. The low-pass effect helps \\gnns to excel in tasks where aggregating 1-hop node features is sufficient for high performance. However, 1-hop low-pass filtering also limits the expressive power of \\gnns in tasks where complex long-range interactions between nodes are important~\\citep{nt2019revisiting,knyazev2019image}.~\\looseness-1\n\n\n\\begin{figure}[htbp]\n    \\centering\n    \\newcommand{\\figwidth}{0.16\\textwidth}\n    \\begin{tabular}{ccc}\n        {\\includegraphics[width=\\figwidth,height=\\figwidth,clip,trim={1.65cm 0 1.65cm 0}]{figs/graph_conv_in.pdf}} &  \n        \\includegraphics[width=\\figwidth,height=\\figwidth,clip,trim={1.65cm 0 1.65cm 0}]{figs/graph_conv_kernel.pdf} &\n        \\includegraphics[width=\\figwidth,height=\\figwidth,clip,trim={1.65cm 0 1.65cm 0}]{figs/graph_conv_out.pdf} \\\\\n        \\includegraphics[width=0.27\\textwidth]{figs/graph_conv_in_im.pdf} &  \n        \\includegraphics[width=0.27\\textwidth]{figs/graph_conv_kernel_im.pdf}\n        &\n        \\includegraphics[width=0.27\\textwidth]{figs/graph_conv_out_im.pdf} \\\\\n        Input graph/image & Convolutional filter & Output graph/image \\\\\n    \\end{tabular}\n    \\caption{Example of the graph convolution operation for a single graph and single filter.}\n    \\label{fig:graph_conv}\n\\end{figure}\n\n\n\\vspace{-3pt}\n\\paragraph{Extensions of \\gnns.}\n\\gnns were first proposed as early as in 1997 by~\\citet{sperduti1997supervised} and subsequently integrated with recurrent neural networks in~\\citep{gori2005new,scarselli2008graph}.\nThe works of~\\citet{defferrard2016convolutional} and~\\citet{kipf2016semi} synergized with deep learning and the \\gnns field has grown considerably.\nNotable extensions include Graph Attention Networks~\\citep{velickovic2017graph} that learn pairwise attention between nodes to better capture regularities in graphs. Graph Isomorphism Networks~\\citep{xu2018how} and Principal Neighbourhood Aggregation~\\citep{corso2020principal} use novel more expressive feature aggregation strategies to better differentiate graphs and showed one of the best results in a large-scale graph benchmark~\\citep{hu2020open}. Simple GCNs~\\citep{wu2019simplifying} propose a single layer \\gnn that is computationally efficient yet performant in many tasks. \nMessage Passing Networks~\\citep{gilmer2017neural,battaglia2018relational} generalize \\gnns to support edge features in addition to node features. \nGated \\gnns~\\citep{li2015gated} extended earlier \\gnns~\\citep{gori2005new,scarselli2008graph} based on recurrent networks and recently showed top results among other \\gnns in different tasks~\\citep{dwivedi2020benchmarking}.\n\n\\vspace{-3pt}\n\\paragraph{Applications of \\gnns.} \\gnns primarily focus on solving node and graph classification tasks and link prediction~\\citep{hamilton2017representation,wu2020comprehensive,battaglia2018relational}. Graph generation~\\citep{you2018graphrnn,liao2019efficient} and analysis of dynamic graphs~\\citep{kazemi2019relational,trivedi2019dyrep} are also becoming common tasks. Graphs can be used to model virtually any kind of data, so besides solving classic graph tasks such as molecule classification~\\citep{xu2018how,knyazev2018spectral}, \\gnns have been recently applied to more diverse tasks: image classification~\\citep{knyazev2019image,meyer2020large}, semantic segmentation~\\citep{li2018beyond,zhang2019dual}, visual relationship detection~\\citep{xu2017scene,yang2018graph}, modelling neural network architectures~\\citep{zhang2018graph,wen2020neural}, program synthesis~\\citep{zhang2018neural}, learning interactions between elements of complex systems~\\citep{kipf2018neural,bapst2019structured} and many other tasks. Such a wide range of tasks shows a great potential of \\gnns and, therefore, \\gnns are a central focuses of this thesis.\\looseness-1\n\n\\paragraph{Alternatives to \\gnns.} Recently, Transformers~\\citep{vaswani2017attention,dosovitskiy2020image} have become competitive in diverse tasks. In principle, these models are capable of capturing graph-structured data if the relational information is properly modelled. For example, if relative positional encoding is used~\\citep{shaw2018self}, Transformers can learn a graph representation similar to such \\gnns as GATs~\\citep{velickovic2017graph}. The relation between Transformers and \\gnns has been more formally confirmed in~\\citep{dwivedi2020generalization,yun2019graph}.\n\n\n\\paragraph{Graph pooling.} Like \\cnns, \\gnns can exploit the local structure of data to perform some type of downsampling or pooling of the input graph.\nIn \\gnns, pooling methods generally follow the same idea as in \\cnns. However, in \\gnns the pooling regions (sets of nodes) are often found based on clustering, since there is no regular grid as in images~\\citep{defferrard2016convolutional,shaham2018spectralnet,ying2018hierarchical}.\nDifferently from clustering-based graph pooling, top-k pooling was proposed~\\citep{graphunet2018}. Instead of clustering ``similar'' nodes, top-k propagates only part of the input disregarding the rest.\n%Top-k pooling can thus select some part of the input graph disregarding the rest. \n%For this reason at first glance it does not appear to be logical.\nFormally, given node features $\\X^{(l)}$ for layer $l$, the output node features $\\mathbf{Z}^{(l)}$ of top-k pooling can be defined as:\\looseness-1\n%However, we can notice that pooled feature maps in~\\cite[Eq.~2]{graphunet2018} are computed in the same way as attention outputs $\\mathbf{Z}$ in Eq.~\\ref{eq:attn} above, if we rewrite their Eq.~2 in the following way:\n%\n\\begin{equation}\n%\\label{eq:top-k}\n%\tZ_i = \\alpha_i X_i, \\forall i \\in P, Z_i = \\emptyset, \\forall i \\notin P\n%\\[\n\\mathbf{Z}^{(l)}_i =\n\\begin{cases}\n\\mathbf{a}_i \\X^{(l)}_i,& \\forall i \\in P\\\\\n\\emptyset, & \\text{otherwise} ,\n\\end{cases}\n%\\]\n\\end{equation}\n%\nwhere $P$ is a set of indices of pooled nodes, $|P| \\leq N$, and $\\emptyset$ denotes the unit is absent in the output. $\\mathbf{a} \\in \\R^N$ is predicted by some auxiliary subnetwork: $\\mathbf{a}=f(\\X^{(l)}, \\A)$, where for $f$ a \\gnn can be used as in~\\citep{lee2019self} or an MLP ignoring the graph structure (adjacency matrix $\\A$) can be used as in~\\citep{graphunet2018}.\nThe indices $P$ are the indices of the $|P|$ largest (top) values in $\\mathbf{a}$.\n\nBoth \\gnns and \\cnns are built by stacking convolutional and pooling layers to form a deep network. Sometimes, \\cnns are augmented with \\gnns to improve learning in visual tasks~\\citep{li2018beyond,liu2020non}.\\looseness-1\n\n\\section{Compositional and graph reasoning\\label{sec:bg_comp}}\n\nWith the basic building blocks, MLPs, \\cnns and \\gnns, we can build systems that solve complex \\textit{compositional reasoning} tasks. In this thesis, by compositional reasoning we assume the process of making a decision by analyzing the collection, or \\textit{composition}, of entities where the entities can refer to graph nodes and edges; objects, object parts and relations; or abstract concepts or patterns (\\eg subgraphs, strokes, stripes).\nIn this section, we will describe compositional reasoning methods that mainly concern vision tasks, since these tasks are well studied and easy to understand with simple examples. But similar tasks and methods solving them exist in different domains of compositional reasoning, such as graph reasoning~\\citep{hamilton2018embedding} or natural language processing~\\citep{lake2018generalization}.\\looseness-1\n\nA classic example of compositional visual reasoning is visual question answering (VQA)~\\citep{antol2015vqa}. In VQA, the decision is the answer obtained by visually reasoning over a set of objects and relationships between them given a question, \\eg \\textit{how many chairs are on the left of the table in this image?}. Simpler tasks such as classifying images can also be considered as visual reasoning tasks. Visual reasoning methods may be grouped into low-level and high-level ones and different methods are used in each case. \n%The methods proposed in \\S~\\ref{sec:completed} and \\S~\\ref{sec:proposal} will concern both of these groups and, in fact, will be aimed to bridge the gap between them in the context of a specific problem -- compositional generalization.\\looseness-1\n\n\\subsection{Low-level compositional reasoning\\label{sec:bg_low}}\n% Explain image classification as a low-level reasoning\nWe can view image classification as a low-level visual reasoning task, since the model needs to recognize low-level components and relate them to each other in order to make an accurate prediction.\n%the category of the object in an image\nThe low-level components can be object attributes and parts, parts of parts, or even individual pixels.\n%in case of tasks such as MNIST~\\citep{lecun1998gradient} . \nReasoning over object parts and attributes rather than making a direct decision about an image enables more explainable decisions~\\citep{ul2019explaining} and zero-shot object classification~\\citep{lampert2013attribute,demirel2017attributes2classname,naeem2021learning,tokmakov2019learning}. \nFor example, a relatively complex zebra image can be recognized if the model detects stripes, a tail, a head, long legs (\\fig{\\ref{fig:attrib}}a). A simple MNIST image can be recognized based on the composition of strokes and other patterns (\\fig{\\ref{fig:attrib}}b).\nRegardless of image complexity, the lowest level of reasoning is individual pixels. In complex images, the compositions of individual pixels are less likely to directly lead to a particular semantic decision. However, individual pixels can still affect the prediction of object parts and attributes, which in turn can affect the final prediction. Therefore, it is important to consider low-level reasoning both in simple and complex images to develop more robust and explainable models.\\looseness-1\n%compared to simple images. \n%So in complex images, low-this form of reasoning is rather abstract. \n%Since this reasoning still affects the final decision, it can be called ``hidden'' reasoning. Low-level reasoning includes all these different forms of reasoning.\n%\\paragraph{Hidden reasoning}\n%By low-level reasoning we will also assume pixel level reasoning that does not directly lead to a particular decision. Maybe call this hidden reasoning?\n\n\n\\begin{figure}[htbp]\n    \\centering\n    \\setlength{\\tabcolsep}{10pt}\n    \\begin{tabular}{cc}\n         \\includegraphics[width=0.3\\textwidth,align=c]{figs/zebra_atrib.png}\n         & \\includegraphics[width=0.3\\textwidth,align=c]{figs/mnist_atrib.pdf} \\\\\n         (a) & (b)\n    \\end{tabular}\n    \\vspace{-5pt}\n    \\caption{ (a) A zebra can be described as a collection of object parts, patterns and attributes (figure from~\\citep{demirel2017attributes2classname}); (b) A digit can be described as a collection of primitive strokes and patterns.}\n    \\label{fig:attrib}\n    \\vspace{-10pt}\n\\end{figure}\n\n\\subsection{High-level compositional reasoning\\label{sec:bg_high}}\n\\vspace{-3pt}\n\nHigh-level visual reasoning has been more extensively  studied in different tasks than low-level reasoning. The most common, and perhaps, comprehensive high-level reasoning task is Visual Question Answering (VQA)~\\citep{antol2015vqa,johnson2017clevr}. One of the ways to effectively solve VQA is to first extract a semantic image description -- a scene graph~\\citep{NSM2019,yi2018neural,zhang2019empirical}. \nFormally, a scene graph~\\citep{johnson2015image} ${\\cal G}=(O,R)$ consists of a set of subjects and objects ($O$) as nodes and a set of relationships or predicates ($R$) between them as edges. The nodes and edges form visual relationship \\textit{triplets}: $\\langle$\\textit{subject}, \\textit{predicate}, \\textit{object}$\\rangle$, \\eg\n% $\\langle$person, on, surfboard$\\rangle$, \n$\\langle$cup, on, table$\\rangle$. %Each node in the graph corresponds to a subject or object (with a specific image location) and edges correspond to predicates. \n%Besides bridging the gap, SGs can be used to verify how well the model has understood the visual world, as opposed to just exploiting one of the biases in a dataset~\\citep{jabri2016revisiting,anand2018blindfold,bahdanau2018systematic}.\n% Thus, scene graphs are semantic descriptions of images. \nSolving VQA becomes much easier when the input to the question-answering module is semantic, such as a scene graph, rather than raw pixels or abstract features. Similar to VQA, in image captioning~\\citep{yang2019auto, gu2019unpaired} and retrieval~\\citep{johnson2015image,belilovsky2017joint,tang2020unbiased}, extracting a scene graph from images also simplifies the task improving the downstream performance. Inferring a scene graph is also beneficial for explainable visual reasoning~\\citep{shi2019explainable} within the explainable AI (XAI) paradigm~\\citep{gunning2019darpa}, since the final predictions can be traced back to semantic concepts of scene graphs.\nExtracting a scene graph generally requires a predefined vocabulary of concepts, which is a time-consuming process that must be done for each new task. Therefore, a more flexible strategy is to describe images using abstract entities~\\citep{norcliffe2018learning,vedantam2019probabilistic,locatello2020object,burgess2019monet,greff2020binding} that, if necessary, can be tied to semantic concepts (see \\S~\\ref{sec:bg_methods}).\\looseness-1\n% -- a semantic collection of objects and relationships between them. \n%As reasoning over abstract entities is not necessary high-level, so the corresponding methods are reviewed separately in § 3.2.4.\n% \\begin{figure}[thbp]\n% \t\\centering\n% \t\\begin{scriptsize}\n% \t\t\\setlength{\\tabcolsep}{1pt}\n% \t\t\\begin{tabular}{c} \\includegraphics[width=0.99\\textwidth,align=c,trim={0 0.2cm 0 0.2cm},clip]{2020_bmvc/figs/cup_on_surfboard_overview1.pdf} \\\\\n% \t\t\\end{tabular}\n% \t\\end{scriptsize}\n% \t\\vspace{-5pt}\n% \t\\caption{\\small Typical scene graph generation pipeline used in high-level visual reasoning tasks (figure from~\\citep{knyazev2020graph}). Foreground (FG) edges denote annotated relations, while background (BG) ones denote the absence of relations as deemed by the annotator or annotation system.} %In many downstream tasks, such as VQA, the result directly depends on the accuracy of predicted scene graphs.}\n% \t\\label{fig:overview_sg}\n% \\end{figure}\n\n\\begin{figure}[thbp]\n\t\\centering\n\t\\includegraphics[width=0.99\\textwidth,align=c,trim={0 2.1cm 0cm 0.2cm},clip]{figs/stanford_network.pdf}\n\t%\\vspace{-5pt}\n\t\\caption{\\small A scene graph generation model from~\\citep{xu2017scene} used in high-level visual reasoning tasks. This and other SGG models~\\citep{yang2018graph} are often based on message passing networks that resemble graph neural networks~\\citep{gilmer2017neural,battaglia2018relational}.}\n\t\\label{fig:overview_sg}\n\\end{figure}\n\n%In scene graph generation} (SGG) the task is to predict a scene graph (SG) given an input image. %The inferred SG can be used directly for downstream tasks such as VQA~\\citep{zhang2019empirical,NSM2019}, image captioning~\\citep{yang2019auto, gu2019unpaired} or retrieval~\\citep{johnson2015image,belilovsky2017joint,tang2020unbiased}.\n%A model which performs well on SGG should demonstrate the ability to ground visual concepts to images and generalize to compositions of objects and predicates in new contexts.\n% \\paragraph{Overview of Scene Graph Generation}\n% \t\\label{sec:baseline}\nExtracting a scene graph $\\cal G$ from an image $I$ is a standard high-level visual reasoning task and is called scene graph generation (SGG)~\\citep{xu2017scene}. In general, SGG models first extract a complete graph from an image, where nodes correspond to detected objects~\\citep{zellers2018neural,yang2018graph}. Then several message passing rounds update node and edge features. The goal of the SGG model is to predict a sparse scene graph $\\cal G$ given the dense graph of node and edge features (\\fig{\\ref{fig:overview_sg}}).\nTypically, many different $\\cal G$ can be valid for a single image $I$, so obtaining $\\cal G$ resembles a generative process. However, in practice there is typically only one ground-truth $\\cal G$ annotated for each image and the SGG models are typically deterministic, so the task is rather ``scene graph prediction''. Nevertheless, we will use the term SGG to be consistent with the scene graph literature.\n\n\n\\subsection{Compositional generalization\\label{sec:bg_comp_gen}}\n\nIn real world images, some compositions, \\eg~$\\langle$cup, on, table$\\rangle$ or $\\langle$person, on, surfboard$\\rangle$, appear more frequently than other unusual ones, \\eg~$\\langle$cup, on, \\textit{surfboard}$\\rangle$, $\\langle$cup, \\textit{under}, table$\\rangle$ or $\\langle$\\textit{dog}, on, surfboard$\\rangle$. %, which creates a strong frequency bias. \nSuch a difference in frequencies -- the \\textit{frequency bias} -- is often present in commonly-used visual relationship datasets, such as Visual Genome~\\citep{krishna2017visual}.\n% (\\fig{\\ref{fig:motivation_gan}}). \nThe frequency bias is purely statistical and poorly reflects the physical plausibility of object interactions. For example, according to the statistics of Visual Genome the probability of $\\langle$cup, on, {surfboard}$\\rangle$ is exactly zero because such a composition has never occurred. However, from the physical point of view (in the real world), such a composition would have a greater than zero probability. In fact, $\\langle$cup, on, {surfboard}$\\rangle$ appears in the test set of Visual Genome.\n%of  and are often called the frequency bias.\nThe ability of models to recognize such novel (\\textit{zero-shot} or ZS) and rare (\\textit{few-shot} or FS) compositions accurately, despite the frequency bias, is called \\textit{\\cg} (\\cgshort). \nCompositional generalization has been widely studied in the language~\\citep{atzmon2016learning, keysers2019measuring, lake2019compositional} and reinforcement learning domains~\\citep{jiang2019language,cogswell2019emergence,kipf2019compile}, as well as multi-domain tasks~\\citep{johnson2017clevr,bahdanau2018systematic,bahdanau2019closure,agrawal2017c,agrawal2018don}.\nIn the visual domain, compositional reasoning has been addressed in the scene graph generation (SGG) task and image classification from attributes~\\citep{lampert2013attribute,demirel2017attributes2classname,naeem2021learning} (\\fig{\\ref{fig:zeroshots}}).\n\n\\begin{figure}[thbp]\n\t\\centering\n\t\\includegraphics[width=0.99\\textwidth,align=c,trim={0 0cm 0cm 0cm},clip]{figs/zeroshots.pdf}\n\t\\vspace{-15pt}\n\t\\caption{\\small An example of a ground truth scene graph with a zero-shot composition (ZS triplet) that must be predicted by an SGG model for an input image. The figure is adapted from~\\citep{knyazev2020graph}. Dashed red arrows denote the relationships that have not been annotated by a human.}\n\t\\label{fig:zeroshots}\n\\end{figure}\n\n%So, unless the models have a strong inductive prior , they will tend to predict `person' rather than `dog' on a surfboard. \nWhile compositional reasoning about concepts is easy for humans, for machines this task has remained extremely challenging. \nThe reasons for the challenging nature of \\cgshort are not well understood.\nThe challenge may relate to the fact that learning-based models tend to capture spurious statistical correlations and biases of datasets during training~\\citep{arjovsky2019invariant,niu2020counterfactual,tang2020unbiased}. \n%The frequency bias of visual relationship datasets is particularly pronounced making it hard for the models to recognize relationships without relying on the bias.\nThe frequency bias of visual relationship datasets is particular pronounced, so for the learning-based models it is hard to not rely on this bias.\n%The presence of the strong frequency bias in data and the tendency of models to rely on this bias make the \\cgshort problem extremely challenging.\nThe \\cgshort challenge has been largely overlooked, since the test sets often have the same frequency bias and the evaluation metrics do not penalize models for blindly relying on the bias. However, when the evaluation is explicitly focused on \\cgshort, the models have been found to fail remarkably~\\citep{atzmon2016learning, lu2016visual, tang2020unbiased, knyazev2020graph}.\n\nIn the SGG task, recall-based metrics are typically used for evaluation. So, on frequent compositions these metrics can reach $\\sim$41\\%, while on zero-shot compositions the state-of-the-art result is only 4.5\\% -- a nearly 10 fold drop in performance~\\citep{tang2020unbiased}.\nPrevious SGG works often assume \\cgshort is similar to few-shot predicate generalization and so attempt to improve mean (or predicate-normalized) recall metrics that are not directly related to \\cgshort~\\citep{chen2019knowledge, dornadula2019visual,tang2019learning,zhang2019graphical,tang2020unbiased,chen2019scene,zareian2020bridging,yan2020pcpl}.  \nPredicate imbalance can be treated by simple resampling-based methods, while \\cgshort is more challenging~\\citep{tang2020unbiased}. Therefore, \\cgshort rather than predicate imbalance has to be a focus of visual reasoning tasks.\n\n\n\\subsection{Methods to improve compositional generalization\\label{sec:bg_methods}}\n\nThe methods to improve visual \\cg (\\cgshort) can be grouped into two categories. These are: methods that explicitly impose some compositional inductive prior on the models, and those where \\cgshort comes, or can potentially come, as a side-effect. The side-effect can be, for example, a result of a regularization method applied to neural networks.\\looseness-1\n\n\\paragraph{Explicit Compositionality.}\nMethods to introduce explicit compositionality can be grouped into high-level and lower-level reasoning tasks. The works on other forms of generalization related to high-level \\cg are also discussed.\n\n\\begin{itemize}[leftmargin=5mm]\n    \\item \\textbf{High-level visual reasoning}: High-level visual \\cgshort was first evaluated in~\\citep{lu2016visual} on the VRD dataset using a joint vision-language model.\n    Several follow-up works attempted to improve upon it: by learning a translation operator in the embedding space~\\citep{zhang2017visual}, clustering in a weakly-supervised fashion~\\citep{peyre2017weakly}, using conditional random fields~\\citep{cong2018scene} or optimizing a cycle-consistency loss to learn object-agnostic features~\\citep{yang2018shuffle}. Augmentation using generative models to synthesize more examples of rare compositions is another promising approach~\\citep{wang2019generating}, because we can generate many instances of rare compositions mitigating the frequency bias. \n    But, in \\citep{wang2019generating} this approach was only evaluated on a simple predicate classification task.\n    %In our work, we also consider subject/object classification to enable the classification of the whole triplets, making the ``image to scene graph'' pipeline complete. \n    Most recently,~\\citet{tang2020unbiased} proposed to mitigate the bias by inferring causal rather than correlated relationships and, consequently, showed strong performance on zero-shot visual compositions. In a subsequent work, \\citet{suhail2021energy} improved the SGG loss function \\eqref{eq:scene_graph_prob_simple} to reduce the bias and better handle \\cgshort.\n    %In the visual domain, compositionality has been introduced in the form of translation operators~\\citep{zhang2017visual}, decoupling object and predicate features~\\citep{yang2018shuffle} and constructing causal graphs~\\citep{tang2020unbiased}.\n    In the VQA task, compositionality has been improved by predefining neural modules~\\citep{andreas2016neural} and their more flexible end-to-end extensions \\citep{hu2017learning,johnson2017inferring}.\n    However, since the VQA task often relies on accurately extracting scene graphs, the methods that impose a compositional prior on scene graph prediction improve \\cgshort in VQA~\\citep{yi2018neural,mascharka2018transparency,shi2019explainable}.\n    \n    \\item %Explicit compositionality has been introduced in lower-level reasoning tasks such as image and attribute classification. \n    \\textbf{Lower-level visual reasoning}: The area of low-level visual reasoning is less organized and there is no standard evaluation benchmark. So different works have focused on different aspects of compositionality at the level of simple objects, object parts and attributes. In particular, to improve compositionality of simple objects, a mask-based loss term was added to image classification networks in~\\citep{stone2017teaching}. However, this loss requires expensive pixel-wise mask annotations for training images. \n    %However, the loss was shown to improve compositionality.\n    In another work~\\citep{sylvain2019locality}, to improve generalization to unseen object categories, a more local representation using self-supervised objectives based on Deep InfoMax~\\citep{hjelm2018learning} was learned. \n    %To recognize novel object categories, compositional understanding at the level of object parts and attributes is essential.\n    Zero-shot object classification was also studied in~\\citep{tokmakov2019learning}. The model in \\citep{tokmakov2019learning} is based on decomposing the image representation into a set of attribute representations in the visual space. However, the model does not require to annotate attributes for novel classes to predict their labels.\n    Generalization to zero-shot objects and object-attribute compositions may be approached by learning an image extraction \\cnn together with a \\gnn that learns a knowledge graph from existing object categories and their attributes~\\citep{naeem2021learning}. \n    Another approach to this task is based on a prototypical model that learns object representations disentangled from attribute representations to enable strong generalization to unseen compositions of objects and attributes~\\citep{ruis2021independent}. To further progress in the lower-level \\cgshort, more standardized benchmarks are needed. Integration of the lower-level and higher-level \\cgshort methods and evaluation protocols can also enable faster progress towards better generalization in visual reasoning.\n    \n    \\item \\textbf{Other tasks}: Several general methods exist that can be potentially useful for \\cgshort. One such method is unsupervised domain adaptation (UDA) by backpropagation~\\citep{ganin2015unsupervised} closely connected to domain-adversarial neural networks\\citep{ajakan2014domain,JMLR:v17:15-239}. UDA achieved strong results by learning features invariant to the domain. Such a model allows to recognize objects in novel domains and contexts.\n    Another general method is meta-learning~\\citep{hospedales2020meta} that typically targets few-shot generalization in classification tasks. \n    The idea of commonly-used meta-learning methods, such as MAML~\\citep{finn2017model}, is to take the original training dataset and split it into a sequence of training and validation subsets (episodes). The critical part is to make the validation set largely composed of few-shot data. This way, the meta-learning algorithm aims to update the parameters of a model on the validation loss thereby improving it by learning to generalize to a few examples. In compositional language reasoning, such a meta-learning based objective was proposed in~\\citep{lake2019compositional}, where the validation set is largely composed of zero and few shot compositions. This method yielded improvement \\cgshort on language tasks, and potentially, can be applied to visual tasks.\n\\end{itemize}\n\n\n\\paragraph{Implicit Compositionality via Object-centric Learning.}\n\nUnsupervised learning has recently received more attention in different visual tasks~\\citep{radford2015unsupervised,hjelm2018learning,chen2020simple,verma2021towards}, and is potentially useful for \\cgshort as well.\nIn particular, one of the reasons for poor \\cgshort of models might be the biased annotations in the datasets on which models are trained. Therefore, a logical way to mitigate such bias is to rely less on the annotations. In an extreme case, we can train a model without any labels, in a purely unsupervised fashion.\nIn the context of compositional visual reasoning, a growing body of unsupervised learning works focus on object-centric learning~\\citep{greff2020binding}, usually by employing an encoder-decoder model~\\citep{engelcke2019genesis,burgess2019monet,greff2019multi,locatello2020object}.\nObject-centric learning methods generally decompose an image representation into a set of object representations without accessing the labels of the objects. Some methods also allow to disentangle physical attributes of objects, such as color, shape and material~\\citep{greff2019multi}. The decomposition of an image into objects is typically done by iteratively running encoder-decoder inference until the image is fully reconstructed~\\citep{greff2019multi}. \n%The method in~\\citep{greff2019multi} allows to not only separate objects from each other, but also to disentangle objects from their physical attributes. \nDue to its iterative nature, the inference procedure is computationally inefficient.\nAnother method, slot attention~\\citep{locatello2020object}, is more efficient, since it only requires a single encoder iteration to extract all object representations. Yet, it is unclear if this model disentangles object attributes as in~\\citep{greff2019multi}. Slot attention is reminiscent to the k-means clustering method. Unlike k-means, slot attention is fully-differentiable and employs self-attention~\\citep{vaswani2017attention} with the softmax function to enforce more sparse representation. Object-centric learning methods are typically evaluated using pixel-wise segmentation metrics similar to earlier unsupervised semantic segmentation works~\\citep{arbelaez2010contour}.\nIn addition, in \\citep{locatello2020object,greff2019multi} the evaluation includes how well the representation encodes visual object properties.\nOverall, object-centric learning is a promising direction for \\cgshort as it enables an unbiased (w.r.t. human annotations) decomposition of images into entities that often have a semantic meaning. Such unbiased decomposition recently allowed object-centric learning methods to improve results on several out-of-distribution generalization tasks~\\citep{dittadi2021generalization}.\\looseness-1\n\n\\paragraph{Implicit Compositionality via Regularized Training.}\n\nRegularization methods are often aimed at reducing overfitting and improving different generalization abilities. An open question remains whether or not these methods can also improve \\cgshort.\n% Among the regularization methods to reduce overfitting and improve overall generalization, \nIn the following, the methods that can be more directly leveraged for compositional generalization are considered.\n\nLet us consider the feature activations after some layer $l$: $\\X^{(l)} \\in \\R^{N \\times d_l}$, where \n$N$ is the number of data points (in a batch) and\n%$n \\in [1, N]$ is an index of a sample in the batch of $N$ sample and \n$d_l$ is dimensionality\\footnote{$\\X^{(l)}$ can be outputs of a fully-connected, convolutional, graph layer, etc. In the case of 2D or 3D dimensions in $\\X^{(l)}$, such as after convolutions, it can be flattened to a 1D tensor.\\looseness-1}. \nTo index the $i$-th individual feature (scalar) of the $n$-th sample, the notation $\\X_{n,i}$ will be used.\nIn the visual domain, when a \\cnn is used to extract $\\X$, these activations tend to be highly-correlated due to the regularities in the input data and co-adaptation of weights to capture those regularities~\\citep{hinton2012improving}, \\ie the probability $p(\\X_{n,i} | \\X_{n,j})$ tends to be high. For example, if the $i$-th feature is activated when the input image contains `surfboard', then the $j$-th feature associated with the entity `person' is likely to be activated regardless if the image actually contains the `person' or another object such as `dog'. On the one hand, relying on co-adaptation allows neural networks to fit data more easily. %similarly as relying on (spurious) context in %high-level visual reasoning. \nOn the other hand, heavy reliance on co-adaptation can hurt generalization, so some regularization strategies are needed to mitigate that.\\looseness-1\n\nMany regularization strategies to alleviate overfitting have been proposed. One common strategy is Dropout~\\citep{hinton2012improving}: $\\text{dropout}(\\X, r)$. Dropout stochastically sets to zero the values of $\\X$ with probability $r$ during training. \\citet{ghiasi2018dropblock} generalized this method to convolutions by setting to zero locally connected activations rather than arbitrary ones.\nIn contrast, \\citet{cogswell2015reducing} proposed a covariance loss penalty to explicitly reduce correlation of features.\nAdding the loss penalty to the task objective helped the networks to obtain better generalization properties compared to using Dropout. \nHowever, due to the expensive procedure of computing covariance, this approach does not scale well to high-dimensional features typically present in visual tasks. \nThis limitation was addressed by introducing a locally connected decorrelation penalty specific for convolutional features~\\citep{rodriguez2016regularizing}.\nInstead of adding a loss penalty~\\citep{cogswell2015reducing,rodriguez2016regularizing}, enforcing orthogonality on weights in \\cnns during initialization may help to better regularize the model and, subsequently, achieve better generalization results~\\citep{bansal2018can,wang2020orthogonal}. However, it is important to maintain the orthogonality regularization during the whole training procedure, because the weights tend to diverge to a poor solution otherwise~\\citep{wang2020orthogonal}. Alternatively, generalization can also be improved using decorrelated batch normalization (BN)~\\citep{huang2018decorrelated}, which can also be viewed as a form of regularization. While decorrelated BN improves generalization compared to original BN~\\citep{ioffe2015batch}, it remains unclear if decorrelated BN is better for generalization than other regularization strategies, such as orthogonal regularization.\\looseness-1\n\nThe discussed regularization methods mainly improve generalization results in a more classic machine learning sense, such as generalization to the in-distribution test images.\n%, they only address the linear independence of features. Nonlinear correlations and, hence redundancy, can be well present in networks. Moreover,\nHowever, except for a few synthetic experiments in~\\citep{cogswell2015reducing}, the effect of these methods on out-of-distribution and, especially, compositional generalization has not been systematically evaluated. Meanwhile, these regularization techniques, in particular the orthogonal one, can facilitate learning a representation where entities are more (linearly) independent, and hence disentangled, from each other. This might directly improve \\cgshort, which needs to be empirically confirmed.\n", "meta": {"hexsha": "8d8a9ed4caa014acb558ce2b672516e569e9c1d2", "size": 57525, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch2_background/background.tex", "max_stars_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_stars_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ch2_background/background.tex", "max_issues_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_issues_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch2_background/background.tex", "max_forks_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_forks_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 139.2857142857, "max_line_length": 1195, "alphanum_fraction": 0.7896392873, "num_tokens": 14644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.43471186627965547}}
{"text": "\\subsection{\\pyhf{}}\\label{subsec:pyhf}\n\nFor measurements in HEP based on binned data (histograms), the \\HiFa{}~\\cite{Cranmer:1456844} family of statistical models has been widely used for likelihood construction in Standard Model measurements (e.g. Refs.~\\cite{HIGG-2013-02,Aaij:2015sqa}) as well as searches for new physics (e.g. Ref.~\\cite{SUSY-2016-10}) and reinterpretation studies (e.g. Ref.~\\cite{Alguero:2020grj}).\n\\pyhf{} is a pure-Python implementation of the \\HiFa{} statistical model for multi-bin histogram-based analysis.\n\\pyhf{}'s interval estimation is computed through either the use of the asymptotic formulas of Ref.~\\cite{Cowan:2010js} or empirically through pseudoexperiments (``toys'' in HEP parlance).\nThrough adoption of open source ``tensor'' computational Python libraries (i.e. NumPy, TensorFlow, PyTorch, and JAX), \\pyhf{} is able to leverage tensor calculations to outperform the traditional C++ implementations of \\HiFa{} on data from real LHC analyses.\n\\pyhf{} can additionally leverage automatic differentiation and hardware acceleration from the tensor libraries that support them to further accelerate fitting.\nThrough use of JSON to provide a declarative plain-text serialisation for describing \\HiFa{}-based likelihoods~\\cite{ATL-PHYS-PUB-2019-029} --- well suited for reinterpretation and long-term preservation in analysis data repositories such as HEPData~\\cite{Maguire:2017ypu} --- \\pyhf{} has also become a widely used tool across experiment and theory.\nGiven its lightweight core dependencies and wide distribution through The Python Package Index (PyPI), Conda-forge, and CernVM File System (CernVM-FS) it is easily installable on a wide variety of platforms, including Linux containers.\nMinimally sized Docker images containing stable releases of \\pyhf{} are also distributed through Docker Hub.\n", "meta": {"hexsha": "18ee92bf649824c67ed6a992ca2ae5e4199a4c52", "size": 1840, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pyhf.tex", "max_stars_repo_name": "matthewfeickert/pyhf-funcX-CHEP-2021-proposal", "max_stars_repo_head_hexsha": "536843fe9a7548c4e2b2e440ff0a7558cd1d4f18", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-23T17:08:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T17:08:06.000Z", "max_issues_repo_path": "src/pyhf.tex", "max_issues_repo_name": "matthewfeickert/pyhf-funcX-CHEP-2021-proposal", "max_issues_repo_head_hexsha": "536843fe9a7548c4e2b2e440ff0a7558cd1d4f18", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/pyhf.tex", "max_forks_repo_name": "matthewfeickert/pyhf-funcX-CHEP-2021-proposal", "max_forks_repo_head_hexsha": "536843fe9a7548c4e2b2e440ff0a7558cd1d4f18", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 167.2727272727, "max_line_length": 381, "alphanum_fraction": 0.7945652174, "num_tokens": 459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.43471185363309706}}
{"text": "\n\\section{Conclusions}\nIn this thesis we have presented our work on the dynamical behaviour of non-equilibrium Bose--Einstein condensates, where we have examined the behaviour of vortex lattices subjected to two distinct perturbations. We began by modelling the condensate using the mean-field Gross--Pitaevskii equation. Using this formalism we then discussed the superfluid properties of the condensate, and concentrated primarily on states with vorticity in two-dimensions. We primarily discussed high rotation rates of the condensate, where the condensate attains a large number of singly charged vortices arranged in a triangular Abrikosov vortex lattice. We restricted ourself to a rotation rate of $\\Omega = 0.995\\omega_\\perp$, and sought a numerical solution of the system with $N\\approx 10^{6}$ atoms of $^{87}$Rb.\n\nWe next introduced the algorithmic framework to numerically solve this system, making use of the Fourier split-operator method. With this we discussed imaginary time evolution to determine the vortex lattice ground state, and real time evolution for all subsequent dynamics. The simulation of this system was computationally challenging due to the finely sampled numerical grid required to resolve all features of the condensate in position and momentum space. To overcome this challenge, we introduced GPU computing methods, which were demonstrated for the problem of coherent atomic transport. For this we investigated a system using SAP methods with magnetic waveguides on atom-chips. These advanced computational techniques allowed for a fully three-dimensional simulation of the Schr\\\"odinger equation to be solved in significantly less time than a standard CPU implmentation. The resulting GPU code was compared with a traditional MPI-enabled code, and showed equivalent performance to an 8-core 8-node cluster for the same system parameters. This led to the development of a software suite for the numerical solution of the Gross--Pitaevskii equation titled ``GPUE''. An independently operated performance test of this suite was found to outperform other numerical softwares for the same class of problems.\n\nUsing the developed numerical suite, we performed a series of simulations for stationary and rotating condensates with a low number of vortices. We mentioned the necessary criteria for ensuring a well-ordered vortex lattice, and examined a condition where these criteria were unfulfilled. Following this, we introduced two distinctive perturbation techniques to disturb the the condensate, and allow non-equilibrium dynamics to be observed. The first method used a kicked optical potential, which modified the condensate phase. By matching the structure and lattice constants of both the optical and vortex lattices, the kick allowed for the generation of transient, time-varying superlattice structures in the density. These superlattice structures were observed during the subsequent dynamical evolution following the kick. By varying the alignment angle of the optical lattice relative to the vortices, we showed that the wavelength of the structures could be changed. The change in the structures were explained using moir\\'e interference theory, and arose from the interference between the reciprocal lattice vectors of both the optical and vortex lattices. This was confirmed by examining the compressible kinetic energy spectrum of the condensate. The kicking perturbation showed how robust the vortex lattice was to density variations, with the phonons generated by the kick having little to no effect on the vortex positions.\n\nAs the vortex lattice proved to be very robust following the kicked potential, we next investigated methods to controllably create disorder in the vortex lattice. By directly phase imprinting topological excitations (phase singularities), we demonstrated that this was possible. From the well ordered vortex lattice ground state we annihilated or flipped the rotation direction of vortices at predefined positions in the lattice. As a vacancy was created in the vortex lattice following an annihilation, the remaining vortices attempted to redistribute and reorder to the most favourable position. Through extensive simulations, this was shown to create localised topological defects in the lattice, with the overall lattice still maintaining a large degree of order. Varying degrees of disorder were then created by removing additional vortices, or by flipping a vortex rotation profile. The use of Delaunay triangulation allowed us to easily identify the defect types, and largely showed the appearance of (5,7) topological lattice defects. By examining the orientational correlations of the lattice we observed that different imprints created varying degrees of lattice disordering. We then made use of Voronoi tessellations to allow local variations in lattice area and orientational correlations respectively to be identified following an annihilation, and demonstrated the effect the phase imprinting had on the vortex lattice on different timescales.\n\n\\section{Outlook}\nGiven the current state-of-the-art experimental control of condensate systems through use of SLMs, the perturbation methods discussed within this thesis are expected to be realisable. These perturbations represent two very useful techniques for quantum state control and engineering. For the kicked optical lattice, the creation of moir\\'e interference patterns with wavelengths much greater than the lattice spacing opens the possibility for detecting vortices without time-of-flight expansion in a lattice. We consider this technique to be a unique method for examining the periodicity of a lattice system, where the evolving pattern can also potentially be observed through the \\textit{in-situ} imaging techniques, as discussed in~\\ref{sec:intro_super}. Further extensions of this work can involve investigating the periodicity of large-scale soliton trains in quasi-1D condensates.\n\nSome preliminary work in small-scale zig-zag and linear vortex crystals was carried out in conjunction with A.~Barahmi and Th.~Busch. This showed that with little periodicity in the system there were negligible peaks in the compressible energy spectrum. As a result, there were no discernible moir\\'e superlattice patterns in the condensate density. It is expected that for these structures to be observed that highly periodic systems with a well defined reciprocal lattice are required. However, given a highly periodic system, any disordering of the system will affect the visibility of the peaks. As a result, this method could potentially allow for an examination of lattice disorder, and can form the basis of a future investigation.\n\nThe vortex annihilation/flipping through phase imprinting appears to be a very good candidate to create varying degrees of disorder in a vortex lattice system. The analysis methods discussed and used for this work can easily be applied to real experimental data. A potential use for this is to create controllable routes towards quantum turbulence from a well-ordered system. While the examination presented focussed primarily on the use of phase profiles opposite to that of the lattice, the imprinting of like-signed vortices also remains an interesting choice. Forcing vortices into different locations in the lattice is potentially an additional method to create lattice dislocations, and hence, topological lattice defects. One might consider erasing and adding vortices at different locations to both create and remove topological lattice defects. This can form the basis for a memory storage technique in a quantum computing system. The applicability of this method can potentially be examined in a future work.\n\nAdditionally, one can also create multi-charged vortices in the condensate. The effect of the surrounding lattice on the resulting multi-charged vortex would be an interesting problem. One might expect the $l$-charge vortex decay to be suppressed if the energy to move the surrounding lattice vortices is greater than the energy to maintain the $l$-charged vortex. This was briefly investigated by examining the Bogoliubov-de Gennes solutions of the imprinted vortex lattice system, with the aim of observing if the resulting excitation modes were complex. These modes were, however, not found due to the numerical complexity of the problem, and it remains an open question if this suppression exists. This will be investigated in a future work.\n\nWhile we briefly mentioned the search for a KTHNY hexatic phase transition in this system, this will require further examination. Future work can include an investigation for the existence of this transition, and examine whether dislocation mediated melting of the vortex lattice can occur as a result of the phase imprinting techniques. Though we consider the framework developed and examined for all the above methods to be valid, the consideration of finite temperature effects would ensure that the investigated methods are truly physically realistic. For such finite temperature condensates, one might consider use of the Zaremba--Nikuni--Griffin (ZNG) formalism~\\cite{ZNG_ref, BK:Proukakis_finitetemp_2013}, or the formalism of Billam \\textit{et al.}~\\cite{BEC:Billam_pra_2013}. An extension of the above works can examine this.\n\nThe use of GPU computing for simulating quantum dynamics is currently an under-utilised paradigm. The potential for a significant performance gain exists, given an effective mapping of a numerical algorithm to the GPU hardware. While the code developed and utilised for all the above simulations offers a clear performance advantage, it should be noted that further development and maintenance of such code can be challenging. Rapid changes to the CUDA programming models have introduced many new features to the standard which could potentially be used for solving more complex problems of both linear and nonlinear Schr\\\"odinger-type problems. However, such changes often require training, software rewrites, or newer hardware to take advantage of these. An extension of the GPUE codebase to cover one and three dimensional Gross--Pitaevskii systems will allow for this suite to be as feature rich as the currently most capable suites available~\\cite{NUM:Wittek_cpc_2013,NUM:GPElab_1}, whilst still holding the current edge in performance. Solutions using arbitrary gauge fields for these problems will also offer a distinctive advantage. Additionally, the inclusion of a numerical BdG solver for the resulting numerical solutions will allow for this software to become a very general suite for BEC problems.\n\nThe methods and works examined in this thesis offer interesting answers, questions and possibilities for the future of controllable quantum systems and technologies.\n", "meta": {"hexsha": "4c5d99df04bb18c922c0af3457cc1e62610ace8b", "size": 10761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MainText/ch7_disclusions/conclusion.tex", "max_stars_repo_name": "mlxd/PhDThesis", "max_stars_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MainText/ch7_disclusions/conclusion.tex", "max_issues_repo_name": "mlxd/PhDThesis", "max_issues_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MainText/ch7_disclusions/conclusion.tex", "max_forks_repo_name": "mlxd/PhDThesis", "max_forks_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 430.44, "max_line_length": 1457, "alphanum_fraction": 0.8299414553, "num_tokens": 2089, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.434711853633097}}
{"text": "\\documentclass[a4paper, 11pt]{article}\n\\usepackage[margin=2cm]{geometry}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\title{\\textbf{COMP90056 Assignment A Report}}\n\\author{Tingsheng (Tinson) Lai (731319)}\n\\date{2019}\n\n\\begin{document}\n    \\maketitle\n    \\section{Introduction}\n    Count-Min Sketch is an introductory technique used in stream computing. Specifically, it is a probabilistic data structure for frequency counting returning a (potentially) accurate estimate. Traditionally, the well-known basic technique used for frequency counting is the hash table. It has comparatively fastest update and query process, and it always produces exact results. The only problem is that it needs to record the identities of all items in the stream of data to resolve problems incurred by collisions of hashes. This is considered to be a waste of space as we are not interested in the actual identities. This report will briefly examine the techniques introduced by the Count-Min Sketch to tackle the issues caused by randomness and how it can minimise the effect of hash collisions.\n    \\section{Theory}\n        To start with, the standard Count-Min Sketch draws multiple hash functions from a hash family uniformly at random, and the number of hash functions is denoted as $d$. Intuitively, this introduces randomness, and it decreases the probability of collisions for pairs of items in the stream. Correspondingly, the item will be hashed to the same number of different positions in a matrix, and the update will be applied to these $d$ cells. Essentially, this matrix can be viewed as multiple counters with a fixed width. By definition, the frequency of an item $x$, defined as the sum of all updates, will always be non-negative. Even if the item collides with another item in the stream, the total frequency will never be less than the original individual frequency. Hence, we claim this data structure will always overestimate the frequency of a given item. \\\\\n\n        \\noindent The conservative variant avoids stacking multiple updates due to collisions. The trade-off is to double the runtime compared to the default version. \\\\\n\n        \\noindent The morris counter variant dramatically reduces the memory usage, but we expect to see a dropdown of accuracy for querying. It may underestimate some of the frequencies due to the randomness introduced in the update. \\\\\n\n        \\noindent We can summarise the theoretical complexity in the following table. $d$ and $w$ are two parameters derived from $\\epsilon$ and $\\delta$ where $d = \\log_{2}{\\frac{1}{\\delta}}$ and $w = \\frac{2}{\\epsilon}$. $n$ is the size of the universe. Another assumption used in the table is that the random generator will yield a random number with time complexity of $O(1)$.\n        \\begin{table}[!h]\n            \\centering\n            \\begin{tabular}{|c|c|c|c|}\n                \\hline\n                                     & \\textbf{Standard} & \\textbf{Conservative Update} & \\textbf{Morris Counter} \\\\\n                \\hline\n                \\textbf{Memory}      & $O(dw\\ln{n})$     & $O(dw\\ln{n})$                & $O(dw\\ln{\\ln{n}})$      \\\\\n                \\hline\n                \\textbf{Update Time} & $O(d)$            & $O(d)$                       & $O(d)$                  \\\\\n                \\hline\n                \\textbf{Query Time}  & $O(d)$            & $O(d)$                       & $O(d)$                  \\\\\n                \\hline\n            \\end{tabular}\n            \\caption{Comparison of different implementations}\n            \\label{table:comparison}\n        \\end{table}\n    \\section{Implementation}\n        The assignment was entirely implemented in C++17 as C++ provides sophisticated memory control, and we can get a more accurate estimate of the measurement of memory usage programmatically. The reason for it to be an accurate estimate instead of the exact result is that there are other negligible factors which may slightly increase the actual memory usage, such as alignment of data types. This is better than measuring the runtime memory directly as other significant factors, such as concurrent executions or memory management techniques, will affect the result severely. The hash functions are simply drawn from the 2-universal hash family. \\\\\n\n        \\noindent One minor issue here is that it may not have the property of strong universality as two random variables share the same random number engine, Mersenne Twister generator, provided in the C++ Standard Template Library. I implemented this deliberately to boost the execution, and also it will be more similar to the random number generator in the provided stdlib.jar file for Java. This issue is almost irresolvable as most of the provided random number generators always use some forms of pseudo-random generation algorithm. Maybe we can consider using the random number generation API from random.org which claims to use the atmospheric noises to generate the random numbers. \\\\\n\n        \\noindent In the actual implementation, I used fixed-width integer type definitions to force the size of the data types to be the same across platforms. I also chose the data type with as smallest size as possible. Some of the data types chosen in the stream are based on the consideration of avoiding unintentional integer overflow. \\\\\n\n        \\noindent The Count-Min Sketch variant with Morris counter is the most interesting implementation amongst all three implementations. The implementation is separately designed leveraging the power of the technique of template partial specialisation, and they can adapt to different models of stream, specifically, the cash-register model and turnstile model. To tackle the negative update in the turnstile stream, I introduced an extra counter for negative updates, whereas the normal counter (inherited from the base class) will only be used for positive updates. The consequence is double the space needed, but it is still far less than the Count-Min Sketch using regular numbers as counters. The query will subtract the negative counter from the positive counter and return the resulting value. It implies $E \\left[ Y_{\\text{result}} \\right] = E \\left[ Y_{\\text{pos}} - Y_{\\text{neg}} \\right] = E \\left[ Y_{\\text{pos}} \\right] - E \\left[ Y_{\\text{neg}} \\right]$, so we can conclude that the resulting value $Y_{\\text{result}}$ is a reasonable estimate based on the fact that $Y_{\\text{pos}}$ and $Y_{\\text{neg}}$ are good estimates.\n    \\section{Experimental Set Up}\n        As the technique of hash table is applied widely in the field of computer science and software engineering, it is well-known that the amortised time complexity of query and update in hash tables is $O(1)$ though some expensive operations such as rehashing and expansions may occur during insertion. I only focus on the memory used by hash table. \\\\\n\n        \\noindent There was a stream generator which can generate item with string type\\footnote{\\url{https://github.com/laitingsheng/COMP90056/blob/2ebab4b1699690457c181989a10755cfe9b7cb28/Assignment/Assignment1/stream.hpp} (This repository is just a mirror of my original repository on GitLab. Only master branch will be synced to this repository.)}. But I deleted this after a reconstruct of the stream runner class since the memory usage will be very intensive when the scale of data stream grows to a very large size. The current encapsulation is flexible to accommodate more distributions and data types. \\\\\n\n        The experiment is done to compare different combinations of $\\epsilon$s, $\\delta$s and the numbers of distinct items in the stream. It will be executed for 16 times to provide more rigorous results.\n    \\section{Results \\& Discussion}\n        One of the weird result is that the accuracy for most of the results are 100\\%. One of the possible reasons is that the first frequency moment $F1$ is comparatively much larger than any individual frequency. We can see this from the extrema of the ratios. \\\\\n\n        \\noindent The morris counter variants, as expected, will sometimes underestimate the frequency. It is also noticeable that the memory for turnstile stream is indeed double the original size.\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{memory_default}\n            \\includegraphics[scale=0.5]{memory_conservative}\n        \\end{center}\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{memory_morris_unsigned}\n            \\includegraphics[scale=0.5]{memory_morris_signed}\n        \\end{center}\n\n        \\noindent Comparatively, the memory used by normal hash map is \\\\\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{memory}\n        \\end{center}\n\n        \\noindent To get smaller values of $\\epsilon$ and $\\delta$, the trade of is the increase of space occupied by the counter. Choose the Count-Min Sketch default version as an example.\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{memory_epsilon.jpg}\n            \\includegraphics[scale=0.5]{memory_delta.jpg}\n        \\end{center}\n\n        \\noindent These two graphs reflect that $\\epsilon$ can affect the size of the counter severely, which is reasonable as $w$ is inverse proportional to $\\epsilon$.\n\n        \\noindent Another interesting property is the update time of different Count-Min Sketch.\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{time_default}\n            \\includegraphics[scale=0.5]{time_conservative}\n        \\end{center}\n\n        \\begin{center}\n            \\includegraphics[scale=0.5]{time_morris_unsigned}\n            \\includegraphics[scale=0.5]{time_morris_signed}\n        \\end{center}\n\n        \\noindent We can see a dramatic increase when the morris counter is used to replace the ordinary counters. From the distribution of the points on the graph, we also can spot that $\\epsilon$ and $\\delta$ also have slight impact on the update.\n    \\section{Future Improvement}\n        Add more stream generators, such as different distributions and data types, based on the current skeleton can test the Count-Min Sketch more thoroughly. The accuracy model should be replaced by a more effective mechanism instead of strictly following $f_x \\leq f_x + \\epsilon F_1$.\n\\end{document}\n", "meta": {"hexsha": "76cb8bff4a58c3e1b66dc9b92db2dd586e7b2b04", "size": 10243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment/A/report.tex", "max_stars_repo_name": "laitingsheng/2019S2-COMP90056", "max_stars_repo_head_hexsha": "adc65917942ce0057cd51602f700c8a7e09cfaea", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment/A/report.tex", "max_issues_repo_name": "laitingsheng/2019S2-COMP90056", "max_issues_repo_head_hexsha": "adc65917942ce0057cd51602f700c8a7e09cfaea", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment/A/report.tex", "max_forks_repo_name": "laitingsheng/2019S2-COMP90056", "max_forks_repo_head_hexsha": "adc65917942ce0057cd51602f700c8a7e09cfaea", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 102.43, "max_line_length": 1142, "alphanum_fraction": 0.7289856487, "num_tokens": 2250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.4347118497792481}}
{"text": "\\documentclass{article}\n\n% for images: png, pdf, etc\n\\usepackage{graphicx}\n\n% for nice table formatting, i.e. /toprule, /midrule, etc\n\\usepackage{booktabs}\n\n% for nice units\n\\usepackage{siunitx}\n\n\\usepackage{amsmath}\n\n\\title{Quiet Standing Controller Parameter Identification: A Comparison of\nMethods}\n\n\\author{Jason K. Moore and Antonie van den Bogert}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\nIt is hypothesized that a human operating during the quiet standing task uses\nfeedback to remain upright in the face of perturbations. For various reasons,\nit is desirable to obtain mathematical models that predict a human's actuation\npatterns given measured estimates of the sensory information available to the\nhuman. Reasonably good models of the human's open loop musculoskeletal system\nexist but models of the human's control system and the system process noises\nare still less than adequate. The control model can possibly be derived from\nfirst principles, but high level understanding of the human's sensory\nneurological feedback patterns are difficult to derive from the low level\nneurological first principles. These high level control descriptions may be\nmore easily arrived at through identification and learning techniques.\n\nHere we present a numerical study comparing three methods of identifying the\ncontroller parameters of a human quiet standing state feedback system. The\nfirst method, direct identification, is by far the least computationally\nintensive but suffers from bias due to the unknown processes in the modeled\nsystem and neglect of the closed loop in the model~\\cite{Kooij2010}. The second\nmethod, single shooting, is a typical method for parameter identification but\nis the most computationally intensive and often suffers from extreme\nsensitivity to initial guesses. Finally, the third method, which has not been\nused for control parameter identification in biological systems, is direct\ncollocation. We aim to show that direct collocation is better suited to control\nparameter identification because it does not suffer from bias because it is\nindirect, computation times are very low, and it is much less sensitive to\ninitial guesses than most single shooting methods.\n\n\\section{Musculoskeletal Model Description}\n%\nWe make use of the widely used planar two link inverted pendulum model of human\nfor quiet standing. In particular, our model matches that described in\n\\cite{Park2004}. Figure~\\ref{fig:free-body-diagram} shows the open loop system.\nThe human is modeled by two rigid bodies: the legs and the torso. These are\nconnected to each other at the hip joint, modeled as an ideal pin. The legs can\nrotate about a pin joint relative to the ``platform'' and the platform/ankle\npoint can be laterally accelerated. The centers of mass of the legs and torso\nare located on a line connecting the respective pin joints. The muscles are\nmodeled as simple joint torque actuators. The orientation of the bodies are\ndescribed by the generalized coordinates $\\theta_a$ and $\\theta_h$. Gravity $g$\nacts on the bodies in the $-y$ direction.\n%\n\\begin{figure}\n  \\centering\n  \\includegraphics{figures/free-body-diagram.pdf}\n  \\caption{Free body diagram of musculoskeletal model used in this study.}\n  \\label{fig:free-body-diagram}\n\\end{figure}\n\nThe equations of motion were formed symbolically using Kane's\nMethod~\\cite{Kane1985} using the \\verb|mechanics| package in\nSymPy~\\cite{Gede2013}. The model derivation is included in the\n\\verb|src/model.py| file and implemented in a class named\n\\verb|QuietStandingModel|. The non-linear equations of motion take this form:\n% TODO : This is too long!\n\\begin{equation}\n  \\input{eoms.tex}\n\\end{equation}\n\nThe numerical values of the open loop model constants were estimated using\nYeadon's method~\\cite{Yeadon1989} and the software package\n\\verb|yeadon|~\\cite{Dembia2014}. The body geometry measurements are included in\n\\verb|raw-data/yeadon-measurements.yml| for a 28 year old male.\nTable~\\ref{tab:model-constants} reports the computed constants for the model.\n%\n\\begin{table}\n  \\centering\n  \\caption{Constant parameters in the plant}\n  \\input{tables/constants-table.tex}\n  \\label{tab:model-constants}\n\\end{table}\n\n\\section{Control Model Description}\n\nTo close the loop, we assume the human can at least continuously sense the full\nstate. There are physiological reasons that back this assumption but we mostly\nchoose it for computational simplicity. Given the state vector\n%\n\\begin{equation}\n  \\mathbf{x} = \\left[ \\theta_a \\quad \\theta_h \\quad \\omega_a \\quad \\omega_h \\right]^T\n\\end{equation}\n%\nwe close the loop with\n%\n\\begin{equation}\n  \\mathbf{T} = \\left[ T_a \\quad T_h \\right]^T = \\mathbf{K} (\\mathbf{x}_{r} - \\mathbf{x})\n\\end{equation}\n%\nwhere $\\mathbf{x}_r$ is the desired reference state and $\\mathbf{K}$ is a\nmatrix of feedback gains\n%\n\\begin{equation}\n  \\mathbf{K} =\n  \\begin{bmatrix}\n    k_{00} & k_{01} & k_{02} & k_{03} \\\\\n    k_{10} & k_{11} & k_{12} & k_{13} \\\\\n  \\end{bmatrix}\n  .\n\\end{equation}\n\nWe also consider a process noise, in our case an additive noise to the state\nerror. This primarily represents the human's error in estimating the state and\nchange in the desired state, but can also account for modeling errors. With the\nreference noise $\\mathbf{x}_n$, plant input becomes\n%\n\\begin{equation}\n  \\mathbf{T} = \\mathbf{K} (\\mathbf{x}_{r} + \\mathbf{x}_n - \\mathbf{x}).\n\\end{equation}\n\nWe choose a set of realistic numerical gain values based on those presented in\n\\cite{Park2004} that stabilize the non-linear model around the vertical\nequilibrium point:\n%\n\\begin{equation}\n  \\mathbf{K} =\n  \\begin{bmatrix}\n    950.0 & 175.0 & 185.0 & 50.0 \\\\\n    45.0 & 290.0 & 60.0 & 26.0\n  \\end{bmatrix}\n\\end{equation}\n\nWith the system closed the only inputs are then the acceleration of the\nplatform $a$ and the reference noise $\\mathbf{x}_n$ and both of which are\ntreated as specified exogenous inputs.\n\n\\section{Data Measurement}\n%\nThere are many likely measurements one can use for identification purposes and\nthe different identification methods we propose each require a minimal set of\nmeasurements. To generate artificial measurements we simulate the closed loop\nsystem by integrating the explicit first order form of the equations of motion\nforward in time with the variable step integration routine available in\nodepack's \\verb|lsoda| routine and accessed through SciPy's integration\nwrappers. We choose the following measurements with optionally additive\nGaussian measurement noise $v(t, 0, \\sigma)$.\n%\n\\begin{align}\n  \\mathbf{x}_m = \\left[ \\mathbf{\\theta} \\quad \\mathbf{\\omega} \\right]^T +\n    \\left[\\mathbf{v}_{\\theta}(0, \\sigma_\\theta) \\quad \\mathbf{v}_{\\omega}(0,\n    \\sigma_\\omega)\\right]^T \\\\\n  \\mathbf{T}_m = \\mathbf{T} + \\mathbf{v}_T(0, \\sigma_T) \\\\\n  a_m = a + v_a(0, \\sigma_a)\n\\end{align}\n\nWe use a sum of sinusoids with a bandwidth designed to fall within the human's\noperating bandwidth for the specified platform acceleration. It is made up of\ntwelve sinusoids with fixed frequencies, a fixed amplitude, and randomly\ngenerated phase shifts between $0$ and $2\\pi$. The 12 frequencies are\nlogarithmically spaced between 0.03~\\si{\\hertz} and 2.18~\\si{\\hertz}.\n\n\n\\section{Direct Identification}\n\nThe direct approach can be used to identify the gains in the controller. The\naccuracy of this approach relies heavily on the ratio of the system's process\nnoise and the applied pertrubations \\cite{Kooij2005}. To implement the inputs\nto the controller (-x) and the outputs of the controller (T) are assumed to be\nmeasured. A linear identifcation model is constructed and linear least squares\ncan be used to compute the optimal gains for a set of measurments.\n\nFor the identification we assume that the controller model is:\n\n\\begin{equation}\n  u = -K * x\n\\end{equation}\n\ni.e. not affected by reference noise or deviating reference\n\nMeasuered states and joint torques\n$\\mathbf{X}$ : N x n\n$\\mathbf{T}$ : N x m\n\nUnknown gains\n$\\tilde{\\mathbf{K}}$: n x m\n\n\\begin{equation}\n  -x \\tilde{K} = \\mathbf{T}\n\\end{equation}\n\nThe least squares estimation\n\n\n\\section{Indirect Identification: Shooting}\n\nIndirect identification is based on minimizing the following cost function:\n\n\\begin{align}\n  J(p) = \\int_{t_0}^{t_f} [x_m(t) - x(t, p)]^2 dt\n\\end{align}\n\nthe state at any time is determined by integrating the eqations of motion\n\n\\begin{equation}\n  x = \\int_{t_0}^{t_f} f(x, t, r_m, p_m, p) dt\n\\end{equation}\n\n$r_m$ : measured exongenous input\n$p_m$ : measured constant parameters\np : unknown constant parameters\n\ngiven the initial state $x_0$ \\footnote{Here we assume that the initial state is\nzero and do not include it in the objective's unknowns}.\n\nTo test shooting we make use both a gradient based sovler and a gradient free\nevolutionary algorithm.\n\nThe quasi-Newton method of Broyden, Fletcher, Goldfarb, and Shanno is a common\ngeneral purpose minimizer for unconstrained problems. And we use the CMAES\nalgorithm which is has been successfully used for control identification\npurposes \\cite{Wang2010}.\n\n\\begin{equation}\n  J(\\tilde{K}) = h \\sum_1^N (\\bar{x}_i - x_i)^2\n\\end{equation}\n\n\\section{Indirect Identification: Direct Collocation}\n\nWe make use of direct collocation to transform the parameter identifaction\nproblem into a large scale non-linear programming problem. Do do so we first\nassume that the discrete integral can be described by backward Euler\nintegration, giving an approximation of the state derivative as\n\n\\begin{align}\n  x_{i} = x_{i-1} + h f(x_{i}, t_{i}) \\\\\n  \\dot{x} \\approx \\frac{x_i - x_{i-1}}{h} =  f(t_i, x_i)\n\\end{align}\n\nFor $t_i$ where $i=2 \\dots N$ and the above assumption, we form $N-1$ algebraic\nequations which must be satisfied.\n\n\\begin{align}\n  0 = \\mathbf{c}(\\mathbf{\\theta}) \\\\\n  0 = f_i(x_{i}, x_{i-1}, u_i, p, h)\n\\end{align}\n\nThe objective function is the linear least squares norm which minimizes the\nerror in the measured data with respect to the model's trajectory.\n\n\\begin{equation}\n  J(\\theta) = h \\sum_{i=1}^N \\left[y_{mi} - y_i(\\theta)\\right]^2\n\\end{equation}\n\nThe NLP problem can be formed\n\n\\begin{align}\n  \\min_{\\theta \\in \\Re^{n}}  J(\\theta) \\\\\n  c(\\theta) = 0 \\\\\n  \\theta^L \\leq \\theta \\leq \\theta^U\n\\end{align}\n\nThe goal is to estimate the uknown parameters $p$, the controller gains in our\ncase, given noisy measurements, $y_{m_i}$.\n\n\\bibliographystyle{unsrt}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "400397cc90e4b87b8639a9f0c6e9a7133d8a9897", "size": 10343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper.tex", "max_stars_repo_name": "csu-hmc/inverted-pendulum-sys-id-paper", "max_stars_repo_head_hexsha": "c41d9f7db16a05bc2e6194b62d303908ff45c2ec", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-08T13:07:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-08T13:07:01.000Z", "max_issues_repo_path": "paper.tex", "max_issues_repo_name": "csu-hmc/inverted-pendulum-sys-id-paper", "max_issues_repo_head_hexsha": "c41d9f7db16a05bc2e6194b62d303908ff45c2ec", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-05T18:11:28.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-20T19:02:29.000Z", "max_forks_repo_path": "paper.tex", "max_forks_repo_name": "csu-hmc/inverted-pendulum-sys-id-paper", "max_forks_repo_head_hexsha": "c41d9f7db16a05bc2e6194b62d303908ff45c2ec", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.9392857143, "max_line_length": 88, "alphanum_fraction": 0.761481195, "num_tokens": 2779, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.43471184760922443}}
{"text": "% part: intuitionistic-logic\n% chapter: introduction\n% section: constructive-reasoning\n\n\\documentclass[../../../include/open-logic-chapter]{subfiles}\n\n\\begin{document}\n\n\\olfileid{int}{int}{cr}\n\n\\section{Constructive Reasoning}\n\nIn constrast to extensions of classical logic by modal operators or\nsecond-order quantifiers, intuitionistic logic is ``non-classical'' in\nthat it restricts classical logic.  Classical logic is\n\\emph{non-constructive} in various ways. Intuitionistic logic is\nintended to capture a more ``constructive'' kind of reasoning\ncharacteristic of a kind of constructive mathematics. The following\nexamples may serve to illustrate some of the underlying motivations.\n\nSuppose someone claimed that they had determined a natural number~$n$\nwith the property that if $n$ is even, the Riemann hypothesis is\ntrue, and if $n$ is odd, the Riemann hypothesis is false. Great\nnews!{} Whether the Riemann hypothesis is true or not is one of the\nbig open questions of mathematics, and they seem to have reduced the\nproblem to one of calculation, that is, to the determination of\nwhether a specific number is prime or not.\n\nWhat is the magic value of~$n$? They describe it as follows: $n$ is\nthe natural number that is equal to $2$ if the Riemann hypothesis is\ntrue, and $3$ otherwise.\n\nAngrily, you demand your money back. From a classical point of view,\nthe description above does in fact determine a unique value of $n$;\nbut what you really want is a value of $n$ that is given\n\\emph{explicitly}.\n\nTo take another, perhaps less contrived example, consider the\nfollowing question. We know that it is possible to raise an irrational\nnumber to a rational power, and get a rational result. For example,\n$\\sqrt{2}^2 = 2$. What is less clear is whether or not it is possible\nto raise an irrational number to an \\emph{irrational} power, and get a\nrational result. The following theorem answers this in the\naffirmative:\n\n\\begin{thm}\nThere are irrational numbers $a$ and $b$ such that $a^b$ is rational.\n\\end{thm}\n\n\\begin{proof}\nConsider $\\sqrt{2}^{\\sqrt{2}}$. If this is rational, we are done:\nwe can let $a = b = \\sqrt{2}$. Otherwise, it is irrational. Then we\nhave\n\\[\n(\\sqrt{2}^{\\sqrt{2}})^{\\sqrt{2}} = \\sqrt{2}^{\\sqrt{2} \\cdot\n  \\sqrt{2}} = \\sqrt{2}^2 = 2,\n\\]\nwhich is rational. So, in this case, let $a$ be\n$\\sqrt{2}^{\\sqrt{2}}$, and let $b$ be~$\\sqrt 2$.\n\\end{proof}\n\nDoes this constitute a valid proof? Most mathematicians feel that it\ndoes. But again, there is something a little bit unsatisfying here: we\nhave proved the existence of a pair of real numbers with a certain\nproperty, without being able to say \\emph{which} pair of numbers it\nis.  It is possible to prove the same result, but in such a way that\nthe pair $a$, $b$ \\emph{is} given in the proof: take $a = \\sqrt{3}$\nand $b = \\log_3 4$. Then\n\\[\na^b = \\sqrt{3}^{\\log_3 4} = 3^{1/2 \\cdot \\log_3 4} = (3^{\\log_3\n  4})^{1/2} = 4^{1/2}= 2,\n\\]\nsince $3^{\\log_3 x} = x$.\n\nIntuitionistic logic is designed to capture a kind of reasoning where\nmoves like the one in the first proof are disallowed. Proving the\nexistence of an $x$ satisfying~$!A(x)$ means that you have to give a\nspecific~$x$, and a proof that it satisfies $!A$, like in the second\nproof. Proving that $!A$ or $!B$ holds requires that you can prove one\nor the other.\n\nFormally speaking, intuitionistic logic is what you get if\nyou restrict a proof system for classical logic in a certain\nway. From the mathematical point of view, these are\njust formal deductive systems, but, as already noted, they are\nintended to capture a kind of mathematical reasoning. One can take this\nto be the kind of reasoning that is justified on a certain\nphilosophical view of mathematics (such as Brouwer's intuitionism);\none can take it to be a kind of mathematical reasoning which is more\n``concrete'' and satisfying (along the lines of Bishop's\nconstructivism); and one can argue about whether or not the formal\ndescription captures the informal motivation. But whatever\nphilosophical positions we may hold, we can study intuitionistic logic\nas a formally presented logic; and for whatever reasons, many\nmathematical logicians find it interesting to do so.\n\n\\end{document}\n", "meta": {"hexsha": "31c031c044591639df6825af623c60f81ffdc5ca", "size": 4183, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/intuitionistic-logic/introduction/constructive-reasoning.tex", "max_stars_repo_name": "thechristokeller/OpenLogic", "max_stars_repo_head_hexsha": "89a60cf5c3079ab9f70a4920459bed82d59e0f9c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/intuitionistic-logic/introduction/constructive-reasoning.tex", "max_issues_repo_name": "thechristokeller/OpenLogic", "max_issues_repo_head_hexsha": "89a60cf5c3079ab9f70a4920459bed82d59e0f9c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/intuitionistic-logic/introduction/constructive-reasoning.tex", "max_forks_repo_name": "thechristokeller/OpenLogic", "max_forks_repo_head_hexsha": "89a60cf5c3079ab9f70a4920459bed82d59e0f9c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6836734694, "max_line_length": 71, "alphanum_fraction": 0.7508964858, "num_tokens": 1150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.8006919949619792, "lm_q1q2_score": 0.434666285195003}}
{"text": "% !TEX root = ../root.tex\n\\section{Theoretical principles}\\label{sec:theory}\nThis section will present the theoretical aspects of the technologies employed in the project, and provides a knowledge base for better understanding the problem and the employed solution.\n\n\n\\subsection{Ultra-wideband}\nUltra-wideband (UWB in short) is a radio technology that use a very low energy level for short-range, high-bandwidth communications over a large portion of the radio spectrum.\n\nConventional narrowband systems employs the modulation of a continuous-waveform signal with a specific carrier frequency to transmit and receive information.\nThis continuous waveform has a well-defined signal energy in a narrow frequency band that exposes it to detection and interception.\nOn the other hand, UWB transmitters generate extremely thin pulse (duty cycle of 0.5\\%) whose average energy content is very low, in fact barely above the background noise level.\n\nShort pulses like the ones described above can yield a very wide bandwidth, often in the order of several \\si{\\giga\\hertz}.\nOn a theoretical standpoint, this means that UWB may allow for high channel capacities \\emph{C}, as predicted by Shannon–Hartley, shown below (where \\emph{B} is the channel bandwidth and \\emph{SNR} is the signal-to-noise ratio of the signal):\n\\begin{equation}\n    \\textit{C} = \\textit{B}\\log_2(1 + \\textit{SNR})\n\\end{equation}\n\nThe UWB technology finds easy applications in \\emph{ToF}-based positioning systems, due to its ability of avoiding reflection overlapping (an inherited benefit of the brevity of the pulses).\nMoreover, the wide spectrum ensures that at least a portion of the signal follows a line-of-sight path.\n\nOther applications may include short-range, high-speed communication systems capable of replacing current wireless technologies while having a smaller footprint on the overall level of emission.\n\n\n\\subsection{Ranging algorithm}\nAn overview of different ranging techniques is hereby presented and discussed.\nThe techniques analyzed here mainly strive to calculate the most accurate possible \\emph{time of flight} (TOF), which can then be converted into distance with the following trivial equation:\n\\begin{equation}\n    \\textit{distance} = \\textit{ToF} \\times c\n\\end{equation}\nThe devices involved in the process will be referred to as initiator (\\(\\mathbf{I}\\)) and responder (\\(\\mathbf{R}\\)).\nFurthermore, only solutions that can cope with unsynchronized (i.e. not sharing the same base clock) devices are taken into consideration.\n\n\\fig{5cm}{twr.png}{Two-way ranging: different approaches}{twr}\n\n\\subsubsection{Single-sided 2WR}\nThis is the most straightforward approach:\n\\begin{enumerate}\n    \\item \\(\\mathbf{I}\\) sends poll message and notes time \\(T_{poll_{TX}}\\)\n    \\item \\(\\mathbf{R}\\) receives poll message and notes time \\(T_{poll_{RX}}\\)\n    \\item After an arbitrary time, \\(\\mathbf{R}\\) sends response message and notes time \\(T_{resp_{TX}}\\)\n    \\item \\(\\mathbf{I}\\) receives response message and notes time \\(T_{resp_{RX}}\\)\n\\end{enumerate}\nAssuming that \\(\\mathbf{R}\\) includes all its recorded data into the response message, \\(\\mathbf{I}\\) can assume that:\n\\begin{equation}\n    \\textit{ToF} = \\frac{(T_{resp_{RX}} - T_{poll_{TX}}) - (T_{resp_{TX}} - T_{poll_{RX}})}{2}\n\\end{equation}\nOne of the major shortcomings of this scheme is that clock frequency differences between the two devices will cause vast drifts over the tiniest delay.\n\n\\subsubsection{Double-sided 2WR}\nThis method improves upon the previous ones by trying to compensate for the introduced drift:\n\\begin{enumerate}\n    \\item \\(\\mathbf{I}\\) sends poll message and notes time \\(T_{poll_{TX}}\\)\n    \\item \\(\\mathbf{R}\\) receives poll message and notes time \\(T_{poll_{RX}}\\)\n    \\item After an arbitrary time, \\(\\mathbf{R}\\) sends response message and notes time \\(T_{resp_{TX}}\\) as well as \\(T_{reply1} = T_{resp_{TX}} - T_{poll_{RX}}\\)\n    \\item \\(\\mathbf{I}\\) receives response message and notes time \\(T_{resp_{RX}}\\) as well as \\(T_{round1} = T_{resp_{RX}} - T_{poll_{TX}}\\)\n    \\item After an arbitrary time, \\(\\mathbf{I}\\) sends final message and notes time \\(T_{final_{TX}}\\) as well as \\(T_{reply2} = T_{final_{TX}} - T_{resp_{RX}}\\)\n    \\item \\(\\mathbf{R}\\) receives response message and notes time \\(T_{final_{RX}}\\) as well as \\(T_{round2} = T_{final_{RX}} - T_{resp_{TX}}\\)\n\\end{enumerate}\nAssuming that \\(\\mathbf{R}\\) includes the calculated time intervals in the response message, \\(\\mathbf{I}\\) can assume that:\n\\begin{equation}\n    \\textit{ToF} = \\frac{T_{round1} \\times T_{round2} - T_{reply1} \\times T_{reply2}}{T_{round1} + T_{round2} + T_{reply1} + T_{reply2}}\n\\end{equation}\nAlthough this method is known to be more reliable than the previous, it requires that ranging measurements are transmitted through the radio, which depending on the application may not be desirable.\n\n\\subsubsection{Single-sided 2WR with drift compensation}\nThis method provides drift correction whilst maintaining the range computation on the initializer:\n\\begin{enumerate}\n    \\item \\(\\mathbf{I}\\) sends poll message and notes time \\(T_{poll_{TX}}\\)\n    \\item \\(\\mathbf{R}\\) receives poll message\n    \\item After an arbitrary time, \\(\\mathbf{R}\\) sends response message\n    \\item \\(\\mathbf{I}\\) receives response message and notes time \\(T_{resp1_{RX}}\\)\n    \\item After the same amount of time, \\(\\mathbf{R}\\) sends another response message\n    \\item \\(\\mathbf{I}\\) receives response message and notes time \\(T_{resp2_{RX}}\\)\n\\end{enumerate}\n\nIn this way \\(\\mathbf{I}\\) need not use any data based on other clocks.\nThe equation becomes:\n\\begin{equation}\n    \\textit{ToF} = \\frac{(T_{resp2_{RX}} - T_{poll_{TX}}) - 2 \\times (T_{resp2_{RX}} - T_{resp1_{TX}})}{2}\n\\end{equation}\n\n\n\\subsection{Trilateration}\n\\emph{Trilateration} consists in determining the location of an object by measuring its distance from reference points.\nWith the advent of electronic means of measuring distances, this technique found widespread usage in the fields of geolocalization, navigation, and surveying.\nIn particular, GPS technology leverages on trilateration for providing its services.\n\nThe process of trilateration can be easily visualized in two dimensions by considering the circle projected by the set of points equidistant from a given reference.\nThe radius of such circle is the distance between an anchor whose location is known (the center of the circle) and a tag whose location is to be found.\n\n\\fig{5cm}{trilat.png}{Trilateration: example case in two dimensions}{trilat}\n\nAdding another anchor and projecting its distance from the tag brings down the possible location to two points.\nIn the ideal case, a third anchor would project a circle intercepting precisely in one of these points.\nHowever, this is rarely the case and may simply be unfeasible in case of a moving object (as the application of this project implies). \\nameref{fig:trilat} shows however that an educated estimate can still be achieved.\n\n\n\\subsection{CAN Bus}\nA \\emph{Controller Area Network} (CAN) bus is a standard designed to allow microcontrollers, sensors, and other devices to communicate with each other without a host computer.\nIt was designed in 1983 by \\emph{Robert Bosch GmbH} for automotive usage, but eventually found applications in many other contexts.\n\nA CAN network is made up of nodes connected to each other through a two-wire bus.\nThe wires form a differential pair of \\SI{120}{\\ohm} nominal impedance.\nEach node is capable of sending or receiving messages, properly called called frames.\nA frame consists of an ID which can be \\SI{11}{\\bit} or \\SI{29}{\\bit} long, and up to eight data bytes.\n\nCAN uses a lossless arbitration method in case of multiple nodes simultaneously attempting to transmit data.\nTransmitted bit can be recessive or dominant.\nIf two such bits are beind transmitted at the same time, the node transmitting the recessive bits suspends its operation and reattempts the transfer after a given number of clock cycles, effectively implementing a prioritized communication system.\nFor this strategy to work, each node on a CAN network must agree on a bit rate and is required to sample every bit of data at the same time as the others.\n\nDue to the lack of a shared clock signal, a synchronization mechanism is employed.\n\\emph{Hard synchronization} occurs after a recessive-to-dominant bit transition, and simply restart the timing from there.\nEach bit is divided into time intervals called \\emph{quanta}, and the first quantum is assigned to the so-called synchronization segment.\nWhenever a recessive-to-dominant bit transition occurs outside of the synchronization segment, the sampling time is moved accordingly.\nTo ensure enough transitions to perform the above procedure, a bit of opposite polarity is inserted after five consecutive equal bits, through a process called \\emph{bit stuffing}.\n\n\\fig{2cm}{can_smpl.png}{CAN Bus: bit timing example }{can_smpl}\n\nMost CAN interfaces support automatic filtering of undesired frames through acceptance filter.\nThe process consists in performing a bitwise \\emph{and} operation between the incoming frame ID and an acceptance bit-mask, and then comparing the result with the content of a filter register: if these match, the frame is added to the reception queue.\nIn this way, a receiving node can choose to accept frames of a specific type, or sent by a particular other node.\n", "meta": {"hexsha": "571c430cbdc743f94fadf1cc12e334dd738e31fb", "size": 9396, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2.analysis/theory.tex", "max_stars_repo_name": "miccio-dk/beng-report", "max_stars_repo_head_hexsha": "fd7a4575569dbc7c3da6bc7b06abbacb039d4d22", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2.analysis/theory.tex", "max_issues_repo_name": "miccio-dk/beng-report", "max_issues_repo_head_hexsha": "fd7a4575569dbc7c3da6bc7b06abbacb039d4d22", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2.analysis/theory.tex", "max_forks_repo_name": "miccio-dk/beng-report", "max_forks_repo_head_hexsha": "fd7a4575569dbc7c3da6bc7b06abbacb039d4d22", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.7741935484, "max_line_length": 251, "alphanum_fraction": 0.767134951, "num_tokens": 2290, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4344874251664099}}
{"text": "\\section{Qualitative Sensitivity Measures: The Morris Method} \\label{comp_morris}\n\nThis section introduces the Morris method for input screening. After the usefulness of input screening is discussed, the Morris method is applied to the Rust model.\n\n\\subsection{Input Screening} \\label{screening}\n\nScreening methods aim at identifying uninfluential inputs and ranking them according to their importance. These qualitative sensitivity methods, as opposed to quantitative ones, do not allow us to exactly quantify each input's effect on the model outcome. Nevertheless, there are several settings in which screening methods can be successfully applied. These are the FF and the FP settings discussed in \\cref{var_based_sa}.\n\nSince screening methods come at a lower computational cost than other sensitivity measures, they are well adapted to models with a large number of inputs. In such settings, other sensitivity methods may not be tractable anymore. Input screening can then guide research by identifying uninfluential inputs that can be left out of subsequent analyses. Such a subsequent analysis can be a more thorough, expensive sensitivity method which has then come into reach by having to consider only a subset of inputs. Screening can also foster scientific discovery by telling us which inputs are most important for the model output. Future models can then build on these results by particularly focusing on these important inputs \\citep{R21}.\n\nTo illustrate the usefulness of input screening, consider the following examples of their application found in \\citet{GPWMS17} and \\citet{MMA18}. \\citet{GPWMS17} conduct input screening in hydrology. They apply seven different screening methods to a lake model and learn that a certain input has major influence on their model's output. By identifying the main driver of uncertainty in the model, they are able to make an informed recommendation about which inputs should be estimated more accurately. \\citet{MMA18} use input screening to identify uninfluential inputs that could then be ignored in the subsequent development of a meta-model, thus facilitating and guiding modelling.\n\nWhile applying quantitative sensitivity methods, \\citet{HMSW19} use their sensitivity indices for input ranking as well to ease the interpretation of model mechanics.\n\nWith these examples of the usefulness of input screening in mind, the following section discusses the Morris method which is then applied to the Rust model.\n\n\\subsection{Morris Method for Independent Inputs} \\label{classic_morris}\n\nThe Morris method was introduced to identify the uninfluential input variables of a model, especially in cases where there are many inputs and/or the evaluation of a model is time-consuming \\citep{M91}.\n\nConsider the same setup as employed in the preceding sections. Let $x = \\{x_1, \\dots, x_k\\}$ denote a sample of values assigned to the $X_i$'s. $f(x)$ is then the model output obtained for the values in $x$. Now consider a second sample $x_{\\Delta_i} = \\{x_1, \\dots, x_{i-1}, x_i + \\Delta, x_{i+1}, \\dots, x_k\\}$ that is identical to $x$ up to input $x_i$ which is varied by $\\Delta$. Then, one elementary effect for input $i$ is derived by\n\\begin{equation*}\nEE_i = \\frac{f(x_{\\Delta_i}) - f(x)}{\\Delta}.\n\\end{equation*}\n\nThe above elementary effect is computed $N$ times, each for a varying $\\Delta$ \\citep{GM17}. The actual sensitivity measures resulting from the Morris method are the mean, denoted by $\\mu^\\ast_i$, and the standard deviation, denoted by $\\sigma_i$, taken from all $N$ different elementary effects per input $i$.\n\\begin{align}\n\\mu_i^\\ast& = \\frac{1}{N} \\sum_{r=1}^N \\vert EE_{i, r} \\vert, \\label{mu}\\\\\n\\sigma_i& = \\sqrt{\\frac{1}{N-1} \\sum_{r=1}^N (EE_{i, r} - \\mu_i)^2}, \\label{sigma}\n\\end{align}\n\n\\noindent with $EE_{i, r}$ denoting the $r$-th elementary effect of input $i$, $r = 1,\\ \\dots, N$, and $\\vert \\cdot \\vert$ the absolute value. Note that in \\citet{M91} the absolute value was absent and elementary effects could potentially cancel each other out \\citep{CCS07}. Therefore, \\citet{CCS07} proposed the version presented above, thus making the screening method more robust. A total of $2 k N$ model evaluations is needed to compute the full set of sensitivity measures using the Morris method.\n\n$\\mu_i^\\ast$ and $\\sigma_i$ can now be used to identify non-influential model inputs. Uninfluential inputs exhibit a $\\mu_i^\\ast$ close to zero. If $\\mu_i^\\ast$ is large, it depends on $\\sigma_i$ whether there exist substantial non-linear or interaction effects. A low $\\sigma_i$ indicates that non-linear effects are non-existent, whereas a high $\\sigma_i$ suggests large interaction or non-linear effects \\citep{GM17}.\n\nThe Morris method exhibits some drawbacks, though. Firstly, as they stand, the sensitivity indices derived by the Morris method are not suited for screening inputs under dependence. To see why consider two inputs $X_i$ and $X_j$ which are dependent, i.e. $G(x_i, x_j) \\neq G(x_i)G(x_j)$, where $G(\\cdot)$ again denotes the cumulative distribution function. If $x_i$ changes, $x_j$ should change as well due to the dependence between the two inputs. The sensitivity indices presented above are derived using a one-at-a-time approach that does not allow for the screening of dependent inputs \\citep{GM17}.\n\nSecondly, similar to the Sobol' indices, the researcher or practitioner conducting sensitivity analysis has to take two indices per input into account. Compare to the arguments made in \\cref{var_based_sa}.\n\nThirdly, there exists no clear interpretation of the absolute values of the sensitivity indices. They only provide a ranking of inputs and give a hint of which inputs are the least influential ones \\citep{GM17}.\n\nOn the advantages, Morris indices are easily computed, with a much lower computational burden than the Shapley effects as presented in \\cref{comp_shap}. Recall that Shapley effects as computed by using the algorithm in \\citet{SNS16} came at a cost of $N_V+m \\cdot N_I \\cdot N_O \\cdot (k-1)$ model evaluations. Even the more efficient approach by \\citet{PRB20} needed $2^k$ model runs. See \\cref{comparison} for a discussion of the respective computational costs.\n\n\\citet{M91} points out that his method does not rely on simplifying assumptions, e.g. monotonicity of the model or input sparsity. He argues that if those assumptions hold, one could apply other, more effective and economical procedures, e.g. based on Latin hypercube designs. However, the Morris method does not rely on such assumptions and will work well if these assumptions are justifiable or not \\citep{M91}.\n\nConsidering the interpretation of Morris indices, $\\mu_i^\\ast$ and $\\sigma_i$, it is apparent that not only input ranking is feasible but we can also learn something about the underlying model structure, i.e. whether interaction or non-linear effects are present.\n\n\\citet{BP16} group the Morris method to the family of local sensitivity measures, but they acknowledge that screening methods like the Morris sensitivity measures stand apart from other local sensitivity measures. While the elementary effects themselves consider only local changes, the actual measures for input importance, $\\mu_i^\\ast$ and $\\sigma_i$, average over these $N$ elementary effects. Thus, they take $N$ local changes per input $i$ into account \\citep{M91}. Indeed, \\citet{CCS11} make a case for the Morris method to be seen a global sensitivity method.\n\n\\subsection{Algorithm for Extended Morris Method}\n\n\\begin{figure}[t]\n\t\\caption{Uncertainty in Morris Indices - 100 Replicates}\n    \\label{morris_replicates}\n    \\begin{centering}\n\t\\vspace*{-4mm}\n\t\\begin{centering}\n\t\\includegraphics[scale=0.9]{../figures/boxplot_morris_replicates_100_replicates_27_draws.png}\n    \\end{centering}\n    \\end{centering}\n\n    \\small\n    \\textit{Notes:} Boxplots of the four Morris indices for the model inputs $RC$ and $\\theta_{11}$. 100 Morris indices were estimated with $N=27$. The left panel shows \\textit{independent}, the right one \\textit{full} Morris indices.\n\\end{figure}\n\n\\begin{figure}[t]\n\t\\caption{Convergence of Morris Indices}\n    \\label{morris_convergence}\n    \\begin{centering}\n\t\\vspace*{-4mm}\n\t\\begin{centering}\n\t\\includegraphics[scale=0.9]{../figures/morris_convergence.png}\n    \\end{centering}\n    \\end{centering}\n\n    \\small\n    \\textit{Notes:} Estimated Morris indices for different sample sizes $N$. The left panel shows \\textit{independent} Morris indices, the right one \\textit{full} Morris indices.\n\\end{figure}\n\nIn this section I introduce the extended Morris method for dependent samples as proposed by \\citet{GM17}.\n\nTo grasp the computational procedure of the extended elementary effects, some more notation is needed. Following \\citet{GM17}, let $X' = \\{X_1',\\ X_2',\\ \\dots,\\ X_k'\\}$ be $k$ dependent random inputs, following the joint probability density function $g(X)$. Thus, $X'$ is just a set of inputs independently drawn from the set $X$. Input subsets denoted by $\\bar{X}$ are conditionally drawn inputs. Hence, let $\\bar{X_{-i}'}$ follow the conditional probability density function $g(\\bar{X_{-i}'} \\mid X_{-i})$. That is $\\bar{X_{-i}'}$ is drawn conditionally on the inputs in the first set $X_{-i}$. The input denoted by $\\bar{X_{-i}}$ is conditionally drawn following the probability density function $g(\\bar{X_{-i}} \\mid X_i')$. % Hence, $\\bar{X_{-i}'}$ and $\\bar{X_{-i}}$ differ by [].\n\nAnalogously to the independent and full Sobol' indices \\citep{MTA15}, \\citet{GM17} developed the following elementary effects for dependent inputs.\n\\begin{align}\nEE_i^{ind} = \\frac{f(\\bar{x_i}',\\ x_{-i}) - f(x_i,\\ x_{-i})}{\\Delta},\\\\\nEE_i^{full} = \\frac{f(x_i',\\ \\bar{x_{-i}}) - f(x_i,\\ x_{-i})}{\\Delta},\n\\end{align}\n\n\\noindent where\n\\begin{itemize}\n\\item $EE_i^{ind}$ denotes \\textit{independent} elementary effects for input $i$, effects that exclude the contributions attributable to the dependence between input $X_i$ and $X_j$ for $i \\neq j$, and\n\\item $EE_i^{full}$ denotes \\textit{full} elementary effects for input $i$, that include the effects due to correlation with other inputs.\n\\end{itemize}\n\nAs in the case of the classic Morris method, the sensitivity measures for input $i$ are derived by considering $N$ random samples yielding $2 N$ elementary effects, once for the independent and once for the full elementary effects. \\citet{GM17} compute the corresponding sensitivity measures as shown in \\cref{mu,sigma}. Since two sets of elementary effects are computed, they end up with a set of four sensitivity measures, $(\\mu^{\\ast ind}_i,\\ \\sigma_i^{ind})$ and $(\\mu^{\\ast full}_i,\\ \\sigma_i^{full})$.\n\nInterpretation-wise, $X_i$ is an unimportant input if all sensitivity measures are essentially zero. If $\\mu^{\\ast ind}_i$ is strongly larger than zero and $\\sigma_i^{ind}$ is close to zero, input $X_i$ is an important input due to its own, isolated contribution. When all sensitivity measures except $\\mu^{\\ast full}_i$ are close to zero, $X_i$'s contribution is due to the dependence with other important inputs. Strong interaction effects are present if either or both of the two $\\sigma$'s are larger than zero \\citep{GM17}.\n\nThe computation of the extended Morris indices requires the generation of dependent samples. According to \\citet{GM17}, the computation involves the following steps:\n\n\\begin{enumerate}\n    \\item Create independent, uniformly distributed samples.\n    \\item Transform these uniformly distributed samples into dependent samples of a target distribution.\n    \\item Use the above methods for the computation of the extended elementary effects.\n    \\item As in the case of the classic Morris method, average over all $N$ elementary effects per input $i$ and compute their standard deviation. Do so for the \\textit{independent} and \\textit{full} elementary effects.\n\\end{enumerate}\n\nIn what follows I stick to the version of the algorithm as implemented in the \\textit{econsa} Python-package \\citep{OSE21}. There, the radial design is used for obtaining independent samples. To derive dependent samples, the inverse Nataf transformation is applied. The total computational cost amounts to $3kN$ model runs.\n\n\\subsection{Morris Indices for the Rust Model} \\label{morris_rust_model}\n\n\\begin{table}[t]\n    \\caption{Relative Difference Morris Indices}\n    \\label{rel_diff_morris}\n    \\centering\n\n    \\begin{threeparttable}\n        \\begin{centering}\n            \\input{../figures/morris_convergence_relative_difference.tex}\n            \\begin{tablenotes}\n                \\small\n                \\item \\textit{Notes:} The percentage difference between Morris indices for different values of $N$. For example, for $\\mu^{\\ast,\\ full}$ Percentage changes are calculated by $\\frac{\\mu^{\\ast,\\ full,\\ n-1}_i - \\mu^{\\ast,\\ full,\\ n}_i}{\\mu^{\\ast,\\ full,\\ n}_i}$, for $i \\in \\{RC,\\ \\theta_{11}\\}$ and $n$ denoting the different values of $N$.\n            \\end{tablenotes}\n        \\end{centering}\n\n        \\end{threeparttable}\n\\end{table}\n\nSimilar to the procedure described in \\cref{comp_shap}, I estimate Morris indices in two different ways: Firstly, I estimate 100 replicates for a relatively low sample size to get a sense of the variability in estimates, Then, I consecutively increase the sample size to investigate\nthe estimation procedure further. Uniformly distributed samples are drawn from a Sobol'\nsequence \\citep{S76}.\\footnote{The Sobol' sequence is a quasi-random sequence used for Quasi-Monte Carlo methods. \\citet{KTA12} argue that Quasi-Monte Carlo estimators converge faster than estimators based on pseudo-random numbers.}\n\nFirstly, I estimate 100 sets of Morris indices. In order to ensure comparability to the Shapley effects, I use the same total computational cost as for the data used for \\cref{boxplot_shapley}. I set $N = 27$, which amounts\nto a total cost of 162 model evaluations, which differs slightly from the computational\ncost of the Shapley effects (160) because of rounding.\\footnote{The same computational cost as for Shapley effects is achieved by solving $6 \\cdot N = 160 \\Leftrightarrow N = \\frac{160}{6} \\approx 26.67$.} As stated above, there are four different\nsensitivity indices estimated: $(\\mu^{\\ast ind}_i,\\ \\sigma_i^{ind})$ and $(\\mu^{\\ast full}_i,\\ \\sigma_i^{full})$. The distribution of the\nestimated Morris indices is given in \\cref{morris_replicates}.\n\nAnalysing \\cref{morris_replicates}, we can get a sense of the uncertainty inherent in the estimation procedure,\ngiven the admittedly small sample size. For the independent Morris indices, there exists a\nvery clear ranking: both values indicate that $RC$ is uninfluential. For $\\theta_{11}$ the situation is\ndifferent: both independent indices, $(\\mu^{\\ast ind}_{\\theta_{11}},\\ \\sigma_{\\theta_{11}}^{ind})$, are nonzero. Surprisingly, for the full Morris indices,\nwe fail to observe a clear input ranking. Estimates of $(\\mu^{\\ast full}_i,\\ \\sigma_i^{full})$ are very volatile, but\nclearly different from zero. Seemingly, no\nclear input ranking is achieved. However, Morris indices were primarily developed to\nidentify non-influential inputs. Both inputs are important if the full Morris indices are\nconsidered.\n\nTo investigate whether the individual pairs of full Morris indices, $(\\mu^{\\ast full}_i,\\ \\sigma_i^{full})$, for the\ntwo inputs $i \\in \\{RC,\\ \\theta_{11}\\}$ yield the correct input ranking, I simply compare their values\nper replicate. Details are given in \\cref{accuracy}. Surprisingly, only about 60 of the 100 replicates yield the correct importance ranking\nfor $\\mu^{\\ast full}_i$. I conclude that ranking based on full Morris indices in the case of the Rust model can be misleading given the small sample size.\nThe influence of dependence seems to be so large that indices cannot be ranked according to their full variance contribution.\n\n\\begin{table}\n\t\\centering\n\t\\caption{Accuracy of Morris Indices}\n\t\\label{accuracy}\n\t\\begin{threeparttable}\n\t\\centering\n\t\\input{../figures/correct_rankings.tex}\n\t\\begin{tablenotes}\n\t\\small\n\t\\item \\textit{Notes:} Share of the correct input rankings for $100$ Morris indices based on $\\mu^{\\ast,\\ full}$ and $\\mu^{\\ast,\\ ind}$. As a benchmark, the accuracy of Shapley effects is presented. For Morris indices the accuracy for different sample sizes is reported.\n\t\\end{tablenotes}\n\t\\end{threeparttable}\n\\end{table}\n\nSecondly, I compute Morris indices for a set of number of draws. I consider $N \\in \\{100,\\ 500,\\ 1000,\\ 1500,\\ 2000,\\ 2500,\\ 3000\\}$. The corresponding results are shown in \\cref{morris_convergence}. The obtained Morris indices clearly confirm the input ranking implied by the Shapley effects for both, $\\mu^{\\ast ind}_i$ and $\\mu^{\\ast full}_i$. Further, Morris indices\nseem to converge as $N$ increases. In \\Cref{rel_diff_morris} specific information on the convergence behaviour is provided. \\citet{ASAV19} show for the classical (independent) Morris indices that they do indeed converge with increasing sample size. Since in the end, the full Morris indices are estimated in a similar fashion, similar behaviour for full indices is expected. However, \\textit{full} Morris indices do not converge for all replicates as seen in \\cref{morris_replicates} and supported further by the results in \\cref{accuracy}. In fact, the share of correct rankings steadily declines as $N$ increases. Intrigued by this result, I investigate whether this behaviour can be observed for a larger sample size as well. To that end, I consider the replicate of Morris indices with $N=500$ which shows the largest difference $\\mu^{\\ast,\\ full}_{RC} - \\mu^{\\ast,\\ full}_{\\theta_{11}}$ and re-estimate the full indices for larger sample sizes, i.e. for $N \\in \\{3\\,000,\\ 4\\,000,\\ 6\\,000,\\ 8\\,000\\}$. Details are shown in \\cref{appendix_morris_seed_67} in Appendix A. There, Morris indices seem to converge, but still yield the wrong input ranking. Unfortunately, due to the computational limitations I face, I cannot investigate this further.\n% Although Morris indices are volatile, \\citet{GM17} point out that a high estimation precision is not necessarily needed as long as the identification of uninfluential inputs is achieved.\n\nLet us inspect the Morris indices for $N = 3\\,000$ in more detail. Consult \\cref{morris_3000} for the\nresulting sensitivity indices. The computational cost for this value of $N$ amounts to $18\\,000$\nmodel evaluations. As in the other trials, \\cref{morris_3000} shows $(\\mu^{\\ast ind}_{RC},\\ \\sigma_{RC}^{ind})$ equal to zero.\nIf only the independent Morris indices are considered, we erroneously\nconclude that input $RC$ is a non-influential input by neglecting the variance contribution due to dependence. Since none of the inputs exhibits $(\\mu^{\\ast ind}_i,\\ \\sigma_i^{ind})$ and $(\\mu^{\\ast full}_i,\\ \\sigma_i^{full})$ close to zero at the same time, both inputs have to be considered as influential ones and thus cannot be fixed without influencing the output.\nSince both independent indices for $\\theta_{11}$, $(\\mu^{\\ast ind}_{\\theta_{11}},\\ \\sigma_{\\theta_{11}}^{ind})$, are high, there are either strong interaction and/or non-linear effects present.\n% Since independent sensitivity indices for $RC$ are both zero, the reason for the high $\\sigma_{\\theta_{11}}^{ind}$ must be driven by the presence of non-linear effects in $\\theta_{11}$. Regarding the model structure we can conclude that there are no interaction effects between $RC$ and $\\theta_{11}$.\n\n\\begin{table}[t]\n    \\centering\n    \\caption{Morris Indices for $N=3\\,000$}\n    \\label{morris_3000}\n    \\begin{threeparttable}\n    \\begin{centering}\n        \\input{../figures/table_morris_conv_3000}\n        \\begin{tablenotes}\n            \\small\n            \\item \\textit{Notes:} \\textit{Independent} and \\textit{full} Morris indices for $RC$ and $\\theta_{11}$ using $N=3\\,000$.\n        \\end{tablenotes}\n    \\end{centering}\n\n    \\end{threeparttable}\n\n\\end{table}", "meta": {"hexsha": "802d4571e1013abcc3f7f93900ad8bba30dc1009", "size": 19819, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/morris_method.tex", "max_stars_repo_name": "bhmueller/thesis", "max_stars_repo_head_hexsha": "3bb9a55b356eee4aee65d0e035731809db57acc6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/morris_method.tex", "max_issues_repo_name": "bhmueller/thesis", "max_issues_repo_head_hexsha": "3bb9a55b356eee4aee65d0e035731809db57acc6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/morris_method.tex", "max_forks_repo_name": "bhmueller/thesis", "max_forks_repo_head_hexsha": "3bb9a55b356eee4aee65d0e035731809db57acc6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 100.6040609137, "max_line_length": 1248, "alphanum_fraction": 0.7606841919, "num_tokens": 5010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43448742109985294}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{physics}\n%\\usepackage[round]{natbib}\n%\\usepackage{bibtex}\n\\usepackage{fancyvrb}\n\\usepackage{hyperref}\n\\usepackage[linesnumbered,boxed]{algorithm2e}\n\\usepackage{subfigure}\n\n\\numberwithin{equation}{section} % Remove this line for global equation numbering\n\n\\title{Stefano's awesome MATH1058 coursework report}\n\\author{Stefano Coniglio}\n\\date{\\today}\n\n\\begin{document}\n\n% This produces the title: to modify contents, change the \\title, \\author, and\n% \\date in the preamble\n\\maketitle\n\n\\begin{abstract}\n  This document reports on something really interesting, hopefully.\n\\end{abstract}\n\n\\section{Introduction}\n\\label{sec:intro}\n\nWe consider, in this work, a definitely relevant problem which, in formal terms, can be expressed as follows:\n%\n\\begin{quote}\n  {\\bf Very Interesting Problem (VIP):} Given a quite relevant set of givens $A \\in \\mathbb{R}^{m \\times n}, b \\in \\mathbb{R}^n, c \\in \\mathbb{R}^n$, the VIP problem calls for a very, very relevant solution $x \\in \\mathbb{R}^n$ which satisfies the following very, very, very (!) relevant property:\n  \\begin{equation}\\label{equation:theRelevantOne}\n    z = \\max_{x \\in \\mathbb{R}^n_+} \\{cx: Ax \\leq b\\}\n  \\end{equation}\n\\end{quote}\n\nRelying on Equation~\\eqref{equation:theRelevantOne}, the algorithm computes $x$ proceeding according to the following pseudocode:\n\n\\begin{algorithm}[H]\\label{alg:theGoodOne}\n \\KwData{this text}\n \\KwResult{how to write algorithm with \\LaTeX2e }\n initialization\\;\n \\While{not at end of this document}{\n  read current\\;\n  \\eIf{understand}{\n   go to next section\\;\n   current section becomes this one\\;\n   }{\n   go back to the beginning of current section\\;\n  }\n }\n \\caption{How to write algorithms.}\n\\end{algorithm}\n\nThe pseudocode reported in Algorithm~\\ref{alg:theGoodOne} was taken from~\\cite{coniglio}.\\footnote{Actually, it was not, but I thought that citing myself was a good idea.}\n\n\\section{Solution approach and implementation}\n\nWe had a great solution idea, which we implemented in the following beautiful piece of Python code:\n\n\n\\begin{Verbatim}[numbers=left]\ndef beautiful_function(myUnusedInput, mySecondUnusedInput):\n    if do_something_awesome() == True:\n        return youWillNeverBugOutOnMe\n    else:\n        return myVeryUndefinedOutput\n\\end{Verbatim}\n\n\n\\section{Experimental results and analysis}\n\nWe have run a set of experiments on this very costly piece of hardware: {\\em xxx}. Our findings are summarized in the quite colorful Figure~\\ref{fig:whatANiceFigure}.\n\n\n\\begin{figure}[h]\n  \\subfigure[]{\\includegraphics[scale=0.4]{./template_placeholder.png}}\n  \\subfigure[]{\\includegraphics[scale=0.4]{./template_placeholder.png}}\n  \\caption{One very nice chart entirely unrelated to this coursework (a) and an apparently very similar chart stil unrelated to this coursework (b).}\n  \\label{fig:whatANiceFigure}\n\\end{figure}\n\nWe should not forget to explain what conclusions the figure allows us to draw, nor why.\n\nAlso, including a table may be a good idea. Take a look at Table~\\ref{tab:1}:\n\n\\begin{table}[htbp]\n  \\caption{A nice table. Notice that captions preceed tables, whereas they follow figures.}\n  \\begin{center}\n\\begin{tabular}{l|lll}\n  header    & header2 & header3 \\\\\n  \\hline\n  name1     & 12      & 12\\\\\n  $s = |S|$ & 5       & 42\n\\end{tabular}\n  \\end{center}\n\\label{tab:1}\n\\end{table}\n\n\n\\section{Conclusions}\n\nWe have reported on a set of quite interesting findings.\n\n% At the end of the document, include the bibliography.\n% You can use any citation style: this one is simple.\n\\bibliographystyle{plain}\n% This assumes you have a single BibTeX file called references.bib: change to\n% match your file name.\n\\bibliography{template_references}\n\n\\end{document}\n", "meta": {"hexsha": "67cf099fd1ece58eaf20c6ebacfcc4f64ff0ead7", "size": 3779, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "handedout-assignment/template.tex", "max_stars_repo_name": "IsaacW4/Operational-Research", "max_stars_repo_head_hexsha": "2f172a14e9302ea56a4beb8b0e334b84df7b406b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "handedout-assignment/template.tex", "max_issues_repo_name": "IsaacW4/Operational-Research", "max_issues_repo_head_hexsha": "2f172a14e9302ea56a4beb8b0e334b84df7b406b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "handedout-assignment/template.tex", "max_forks_repo_name": "IsaacW4/Operational-Research", "max_forks_repo_head_hexsha": "2f172a14e9302ea56a4beb8b0e334b84df7b406b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0254237288, "max_line_length": 297, "alphanum_fraction": 0.7443768193, "num_tokens": 1058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43448742109985294}}
{"text": "\\documentclass[oneside]{memoir}\n\n\\usepackage{notestemplate}\n\\usepackage{import}\n\\usepackage{standalone}\n\\usepackage{fancyhdr} % Required for custom headers\n\\usepackage{lastpage} % Required to determine the last page for the footer\n\\usepackage{extramarks} % Required for headers and footers\n\\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template\n\\usepackage{hyperref}\n\\hypersetup{pdftex,colorlinks=true,allcolors=blue}\n\\usepackage{hypcap}\n\\usetikzlibrary{matrix,arrows.meta}\n\n\\logo{~/LibreMath/Auxiliary Resources/resources/png/logo.png}\n\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n\\department{Department of Mathematics}\n\\title{Introduction to Groups, Rings, and Fields}\n\\subtitle{A first exposure to core concepts in abstract algebra}\n\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n\\date{\\today}\n\n%\\makeindex\n\n\\begin{document}\n% \\section{}\t\n\n\\maketitle\n\n\\tableofcontents\n\\input{2020-02-04-NumThryPrelim}\n\\input{2020-03-24-IntroGroups}\n\\input{2020-03-25-Subgroups}\n\\input{2020-03-31-NormalSubgroups}\n\\input{2020-04-01-QuotientGroup+Homo}\n\\input{2020-04-07-GroupProd}\n\\input{2020-03-26-CyclicGroups}\n\\input{2020-04-08-PermGroup}\n%\\input{GroupRepresentations}\n%\\input{AlternatingGroup}\n\\input{2020-04-28-GroupAction}\n%\\input{Automorphisms}\n%\\input{GroupRepresentations2}\n%\\input{Sylow}\n\\input{2020-04-09-ClassificationThms}\n%\\input{NilpotentSolvableGroups}\n%\\input{ProofFundThmFinAbelGrps}\n\n\\chapter{Rings}\n\\label{cha:rings}\n\n\\input{2020-02-05-IntroRings}\n\\input{2020-02-12-Subrings}\n\n\\section{Ring Homomorphisms and Quotient Rings}\n\n\\input{2020-02-18-QuotientRing}\n\\input{2020-02-19-RingHomo}\n\\input{2020-02-25-RingProd}\n\\input{2020-02-26-DivisioninRings}\n\\input{2020-03-03-GaussianInt}\n\\input{2020-03-04-GaussianInt2}\n\\input{2020-03-10-GaussInt3}\n\\input{2020-03-11-FiniteFields}\n%\\input{ModuleTheory}\n\n%\\printindex\n\n\\end{document}\n\n", "meta": {"hexsha": "64b2594b530f2f4c4b41c76bf496c21c1920e9fc", "size": 1956, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/AlgebraI.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/AlgebraI.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra I/Notes/source/AlgebraI.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.4324324324, "max_line_length": 83, "alphanum_fraction": 0.7837423313, "num_tokens": 659, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.8175744739711883, "lm_q1q2_score": 0.43430322400461335}}
{"text": "\\documentclass[12pt, letterpaper]{article}\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage[margin=0.7in]{geometry}\n\n  %%%%%%%%%%%%\n  % PREAMBLE %\n  %%%%%%%%%%%%\n\\begin{document}\n\\selectlanguage{english}\n\n\\section{The crystal state and associated parameter gradients}\n  The purpose of this document is to discuss the code in \\texttt{g\\_gradients.py} and \\texttt{a\\_g\\_conversion.h}, which is presumably used for parameter refinement in \\textit{DIALS}, per the Waterman (2016) paper, section B3.  Code such as this has been in the package at least since 2006.  Unfortunately, the following notes predate the current code, and I notice that slightly different conventions are used, \\textit{e.g.}, the notes give the fractionalization matrix as upper triangular, but the comments in the code indicate lower triangular.  Therefore at some point these notes will have to be reconciled with the actual code.\n\nLet's begin by defining notation.  All formulae will be given here in terms of the reciprocal lattice, therefore the vectors $\\mathbf{a}$, $\\mathbf{b}$, and $\\mathbf{c}$ will be understood to refer to the reciprocal cell basis vectors, even though these vectors may be denoted with superscript asterisks in most literature.  In addition we have the reciprocal space $\\mathbf{A}$ matrix,\n\n  \\begin{equation}\n    \\mathbf{A} = \n    \\left[\n    \\begin{array}{c c c}\n       a_{x}  & b_{x} & c_{x} \\\\\n       a_{y}  & b_{y} & c_{y} \\\\\n       a_{z}  & b_{z} & c_{z} \\\\\n    \\end{array}\n    \\right]\n    \\text{,}\n    \\label{eqn:expansion}\n  \\end{equation}\n\nrepresenting the state variables of the crystal (cell parameters and orientation), in terms of column vectors denoting the basis vectors expressed as laboratory $x,y,z$ components.\n\nIn practice we express $\\mathbf{A}$ as\n\n  \\begin{equation}\n      \\mathbf{A} = \\mathbf{UF} \n    \\text{,}\n    \\label{eqn:sabbrev}\n  \\end{equation}\n\n\nwith unitary matrix $\\mathbf{U}$ expressing the crystal rotation ($e.g.$, as a composite resulting from Euler rotations $\\phi$, $\\theta$ and $\\psi$), and a fractionalization matrix $\\mathbf{F}$ given by  \n\n  \\begin{equation}\n    \\mathbf{F} = \n    \\left[\n    \\begin{array}{c c c}\n       a_{x}  & b_{x} & c_{x} \\\\\n       0  & b_{y} & c_{y} \\\\\n       0  & 0 & c_{z} \\\\\n    \\end{array}\n    \\right]\n    \\text{.}\n    \\label{eqn:expansionF}\n  \\end{equation}\n\nHere it is understood that $\\mathbf{F}$ represents the standard orientation of the crystal, which by convention is taken to mean that the reciprocal $\\mathbf{a}$ vector lies along laboratory $x$, with $\\mathbf{b}$ in the $xy$ plane.  \n  \nIn contrast to the state variables, the parameters most useful for model fitting turn out to be the elements of the reciprocal space symmetric metric tensor, \n\n  \\begin{equation}\n    \\mathbf{G} = \n    \\left[\n    \\begin{array}{c}\n       g_{11}  \\\\ g_{22} \\\\ g_{33} \\\\\n       g_{12}  \\\\ g_{13} \\\\ g_{23} \n       \\\\\n    \\end{array}\n    \\right] = \n    \\left[\n    \\begin{array}{c}\n       g_{0}  \\\\ g_{1} \\\\ g_{2} \\\\\n       g_{3}  \\\\ g_{4} \\\\ g_{5} \n       \\\\\n    \\end{array}\n    \\right] = \n     \\left[\n    \\begin{array}{c}\n       \\mathbf{a}\\cdot\\mathbf{a}  \\\\ \\mathbf{b}\\cdot\\mathbf{b} \\\\ \\mathbf{c}\\cdot\\mathbf{c} \\\\\n       \\mathbf{a}\\cdot\\mathbf{b}  \\\\ \\mathbf{a}\\cdot\\mathbf{c} \\\\ \\mathbf{b}\\cdot\\mathbf{c}\n       \\\\\n    \\end{array}\n    \\right]\n   \\text{.}\n    \\label{eqn:expansionG}\n  \\end{equation}\n\n The reason for prefering the metrical tensor components is that high-symmetry Bravais cells will only refine a subset of the six components, with monoclinic refining four, orthorhombic three, tetragonal and hexagonal two, and cubic only one.\n \n A key strategy in parameter refinement is to use the chain rule.  Suppose we are performing iterative non-linear least-squares parameter refinement with a refinement target $\\chi$ that is a function of $\\mathbf{A}$.  Suppose that at an intermediate step of the calculation we have the gradient of the target with respect to each element $a_{ij}$, \n \n   \\begin{equation}\n    \\frac {\\partial \\chi} {\\partial a_{ij}}\n       \\text{,}\n    \\label{eqn:frac}\n  \\end{equation}\n\n where $i$ denotes the row and $j$ the column of the matrix $\\mathbf{A}$.\n\nThen in order to calculate the gradient of the target with respect to the free parameters $g_{ij}$, one would employ the chain rule.  For the specfic example of $g_{11}$ this would be performed as follows over a total of nine terms:\n\n   \\begin{equation}\n    \\frac {\\partial \\chi} {\\partial g_{11}} =\n    \\frac {\\partial \\chi} {\\partial a_{11}} \\frac {\\partial a_{11}}{\\partial g_{11}}+\n    \\frac {\\partial \\chi} {\\partial a_{12}} \\frac {\\partial a_{12}}{\\partial g_{11}}+\n    \\frac {\\partial \\chi} {\\partial a_{13}} \\frac {\\partial a_{13}}{\\partial g_{11}}+\n    \\ldots+\n    \\frac {\\partial \\chi} {\\partial a_{31}} \\frac {\\partial a_{31}}{\\partial g_{11}}+\n    \\frac {\\partial \\chi} {\\partial a_{32}} \\frac {\\partial a_{32}}{\\partial g_{11}}+\n    \\frac {\\partial \\chi} {\\partial a_{33}} \\frac {\\partial a_{33}}{\\partial g_{11}}\n       \\text{.}\n    \\label{eqn:fracC}\n  \\end{equation}\n\nIt is important to note that \\textit{DIALS} employs a related chain rule formula applicable to the special case where we start with the derivatives of the target with respect to the six non-zero elements of the fractionalization matrix,\n\n     \\begin{equation}\n    \\frac {\\partial \\chi} {\\partial f_{ij}}\n       \\text{.}\n    \\label{eqn:fracF}\n  \\end{equation}\n\n  However, I do not have the specific formulae documented here apart from the code itself.  \n  \n  In any case, the critical piece will then be the relationship between $\\mathbf{F}$ and $\\mathbf{G}$.  Here are the full equations to convert between the two, $\\mathbf{F}$ to $\\mathbf{G}$:  \n      \\begin{flalign*}\n    &g_{0} = a_{x}^{2} &\\\\\n    &g_{1} = b_{x}^{2} + b_{y}^{2} &\\\\\n    &g_{2} = c_{x}^{2} + c_{y}^{2} + c_{z}^{2} &\\\\\n    &g_{3} = a_{x} b_{x} &\\\\\n    &g_{4} = a_{x} c_{x} &\\\\\n    &g_{5} = b_{x} c_{x} + b_{y} c_{y} &\\\\\n    \\end{flalign*}\n  Note the use of two differing nomenclatures for the subscript of $g$, which are nevertheless equivalent.  In the $\\mathbf{G}$ to $\\mathbf{F}$ direction:\n      \\begin{flalign*}\n    &a_{x} = g_{0}^{1/2} &\\\\\n    &b_{x} = g_{3} / a_{x} &\\\\\n    &c_{x} = g_{4} / a_{x} &\\\\\n    &b_{y} = (g_{1} - b_{x}^2)^{1/2} &\\\\\n    &c_{y} = \\dfrac{g_{5} - b_{x}c_{x}}{b_{y}} &\\\\\n    &c_{z} = (g_{2} - c_{x}^2 - c_y^2)^{1/2} &\\\\\n    \\end{flalign*}\nNotice the presence of the square root in three of the $\\mathbf{G}$ to $\\mathbf{F}$ formulae.  A negative value inside the radical should never occur, and if it did would represent an illegal trial value for a free parameter.\n  \n  \n      \\end{document}\n", "meta": {"hexsha": "2a4924c3ff013d9301eb5a5e14498f506aae1b75", "size": 6642, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "rstbx/symmetry/constraints/conversion_and_gradients.tex", "max_stars_repo_name": "rimmartin/cctbx_project", "max_stars_repo_head_hexsha": "644090f9432d9afc22cfb542fc3ab78ca8e15e5d", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 155, "max_stars_repo_stars_event_min_datetime": "2016-11-23T12:52:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T15:35:44.000Z", "max_issues_repo_path": "rstbx/symmetry/constraints/conversion_and_gradients.tex", "max_issues_repo_name": "rimmartin/cctbx_project", "max_issues_repo_head_hexsha": "644090f9432d9afc22cfb542fc3ab78ca8e15e5d", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 590, "max_issues_repo_issues_event_min_datetime": "2016-12-10T11:31:18.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T23:10:09.000Z", "max_forks_repo_path": "rstbx/symmetry/constraints/conversion_and_gradients.tex", "max_forks_repo_name": "rimmartin/cctbx_project", "max_forks_repo_head_hexsha": "644090f9432d9afc22cfb542fc3ab78ca8e15e5d", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 115, "max_forks_repo_forks_event_min_datetime": "2016-11-15T08:17:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T15:30:14.000Z", "avg_line_length": 45.4931506849, "max_line_length": 633, "alphanum_fraction": 0.6449864499, "num_tokens": 2103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.43428376948849984}}
{"text": "\\section{Lecture 4 - The Lazy Approach}\n\n\\begin{frame}\n  \\frametitle{The Lazy Approach}\n\n  \\scriptsize\n\n  Notice that\n  \\begin{itemize}\n    \\item Assignments $\\mu$ of $\\varphi$ are many (potentially $\\infty$),\n          infeasible to check if any of them is a model {\\bf systematically}\n    \\item Models $\\babst{\\mu}$ of $\\babst{\\varphi}$ are finite in number,\n          and easy to enumerate with a SAT-solver\n    \\item A model $\\babst{\\mu}$ is nothing but a {\\bf conjunction of \\tatoms},\n          can be checked efficiently with a \\tsolver\n  \\end{itemize}\n  \\vfill\n  These observations suggest us a methodology\n  to tackle the SMT(\\T) problem\n  \\begin{itemize}\n    \\item Enumerate a Boolean model $\\babst{\\mu}$ of $\\babst{\\varphi}$ (abstraction). If no model \n\t  exist we are done ($\\varphi$ is unsatisfiable) \n    \\item Check if $\\babst{\\mu}$ is satisfiable using the \\tsolver. If so $\\babst{\\mu}$ can be extended \n          to a model $\\mu$ of $\\varphi$, and so we are done ! ($\\varphi$ is satisfiable) \n    \\item It not, we tell the SAT-solver not to enumerate $\\babst{\\mu}$ again,\n          thus {\\bf cutting away systematically an infinite number} \n\t  of assignments for $\\varphi$ (refinement) \n    \\item It can be blocked by adding a clause $\\neg \\babst{\\mu}$. Go up\n    \\item It terminates because there are finite Boolean models\n  \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{The Lazy Approach}\n\n  \\scriptsize\n  \n  The lazy approach falls into the so-called {\\bf abstraction-refinement} \n  paradigm\n  \\vfill\n  \\begin{center}\n  \\scalebox{.5}{\\input{ar.pdf_t}}\n  \\end{center}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{The Lazy Approach}\n\n  \\scriptsize\n\n  The interaction described naturally falls within the\n  CDCL style, enriched with a \\tsolver\n      $$\\varphi \\equiv \n      (x=3 \\vee \\neg (x<3))\\ \\swedge\\\n      (x=3 \\vee \\neg (x>3))\\ \\swedge\\\n      (x>3 \\vee \\neg (x<3))\\ \\swedge\\\n      (x>3 \\vee \\neg (x=3))$$ \n  \\vfill\n  \\begin{columns}\n\n    \\begin{column}{.5cm}\n      \\vspace{-165pt}\n      $\\babst{\\varphi} \\equiv$\n    \\end{column}\n\n    \\begin{column}{5cm}\n      $(\\coltwoat{\\coloneat{a_1}{8-13}}{2-6} \\vee \\coltwoat{\\neg a_2}{9-13})$ \\\\\n      $(\\coltwoat{\\coloneat{a_1}{8-13}}{2-6} \\vee \\coltwoat{\\coloneat{\\neg a_3}{3-6}}{10-13})$ \\\\\n      $(\\coloneat{\\coltwoat{a_3}{3-6}}{10-13} \\vee \\coltwoat{\\neg a_2}{9-13})$ \\\\\n      $(\\coloneat{\\coltwoat{a_3}{3-6}}{10-13} \\vee \\coloneat{\\coltwoat{\\neg a_1}{8-13}}{2-6})$ \\\\\n      \\onslide<6->{$(\\coloneat{\\coltwoat{\\neg a_1}{10-13}}{6} \\vee \\coltwoat{\\coloneat{\\neg a_3}{6}}{10-13})$ \\\\}\n      \\onslide<7->{$(\\coltwoat{\\neg a_1}{8-13})$ \\\\}\n      \\onslide<13->{$(\\coloneat{a_1}{13} \\vee \\coloneat{a_2}{13} \\vee \\coloneat{a_3}{13})$ \\\\}\n      \\onslide<14->{$(\\ )$ \\\\}\n      \\bigskip\n      $a_1 \\equiv x=3$ \\\\\n      $a_2 \\equiv x<3$ \\\\\n      $a_3 \\equiv x>3$ \\\\\n      \\bigskip\n      $\\babst{\\mu}$: $\\{\\ \\only<2-6|handout:0>{a_1}\\only<3-6|handout:0>{, a_3}\\only<8-13|handout:0>{\\neg a_1}\\only<9-13|handout:0>{, \\neg a_2}\\only<10-13|handout:0>{, \\neg a_3}\\ \\}$ \\\\\n      \\bigskip\n      \\begin{tabular}{rl}\n      SAT-solver: & \\only<1,4-5,11-12|handout:0>{Idle}\\only<2|handout:0>{Decision}\\only<3,8-10|handout:0>{BCP}\\only<6,13|handout:0>{Learn}\\only<7,14|handout:0>{Conf. Analysis, Backtrack}\\only<15>{UNS} \\\\\n        \\tsolver: & \\only<1,2,3,6-10,13->{Idle}\\only<4,5,11,12|handout:0>{Is $\\babst{\\mu}$ \\T-satisfiable ?}\\only<5,12|handout:0>{ NO}\n      \\end{tabular}\n    \\end{column}\n\n    \\begin{column}{5cm}\n      \\begin{overlayarea}{5cm}{5cm}\n\t\\only<1|handout:0>{\\scalebox{.6}{\\input{search_0.pdf_t}}}\n\t\\only<2|handout:0>{\\scalebox{.6}{\\input{search_1.pdf_t}}}\n\t\\only<3,4,5|handout:0>{\\scalebox{.6}{\\input{search_2.pdf_t}}}\n\t\\only<6,7|handout:0>{\\scalebox{.6}{\\input{search_3.pdf_t}}}\n\t\\only<8|handout:0>{\\scalebox{.6}{\\input{search_4.pdf_t}}}\n\t\\only<9|handout:0>{\\scalebox{.6}{\\input{search_5.pdf_t}}}\n\t\\only<10-12|handout:0>{\\scalebox{.6}{\\input{search_6.pdf_t}}}\n\t\\only<13->{\\scalebox{.6}{\\input{search_7.pdf_t}}}\n      \\end{overlayarea}\n    \\end{column}\n\n  \\end{columns}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Lecture 4 - Exercize 1}\n\n  \\scriptsize\n\n  \\begin{tabular}{ccc}\n    \\begin{minipage}{.4\\textwidth}\n     $$\n     \\begin{array}{l}\n     (a_1 \\vee \\neg a_2) \\\\\n     (a_1 \\vee \\neg a_3) \\\\\n     (a_3 \\vee \\neg a_2) \\\\\n     (a_3 \\vee \\neg a_1) \\\\\n     (\\neg a_1 \\vee \\neg a_3)\n     \\end{array}\n     $$\n    \\end{minipage}\n    & ~~~~~~ &\n    \\begin{minipage}{.4\\textwidth}\n      \\begin{tabular}{ccl}\n\t\\hline\n\tTrail & dl & Reason \\\\\n\t\\hline\n\t$a_1$ & 1 & Decision \\\\\n\t$a_3$ & 1 & $(a_3 \\vee \\neg a_1)$ \\\\\n\t\\hline\n      \\end{tabular}\n      \\bigskip \\\\\n      $\\{ \\dec{a_1}{1}, \\dec{a_3}{1} \\}$\n    \\end{minipage}\n  \\end{tabular}\n\n  \\vfill\n  \\pause\n\n  \\begin{minipage}{\\textwidth}\n    \\begin{prooftree}\n    \\AxiomC{$(\\neg a_1 \\vee \\neg a_3)$}\n    \\AxiomC{$( a_3 \\vee \\neg a_1 )$}\n    \\BinaryInfC{$(\\neg a_1)$}\n    \\end{prooftree}\n  \\end{minipage}\n\n  \\vfill\n  \\pause\n  Conflict clause: $(\\neg a_1)$ \\pause \\\\\n  Backtracking level: 0\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Lecture 4 - Exercize 1}\n\n  \\scriptsize\n\n  \\begin{tabular}{ccc}\n    \\begin{minipage}{.4\\textwidth}\n     $$\n     \\begin{array}{l}\n     (a_1 \\vee \\neg a_2) \\\\\n     (a_1 \\vee \\neg a_3) \\\\\n     (a_3 \\vee \\neg a_2) \\\\\n     (a_3 \\vee \\neg a_1) \\\\\n     (\\neg a_1 \\vee \\neg a_3) \\\\\n     (\\neg a_1) \\\\\n     (a_1 \\vee a_2 \\vee a_3)\n     \\end{array}\n     $$\n    \\end{minipage}\n    & ~~~~~~ &\n    \\begin{minipage}{.4\\textwidth}\n      \\begin{tabular}{ccl}\n\t\\hline\n\tTrail & dl & Reason \\\\\n\t\\hline\n\t$\\neg a_1$ & 0 & $(\\neg a_1)$ \\\\\n\t$\\neg a_2$ & 0 & $(a_1 \\vee \\neg a_2)$ \\\\\n\t$\\neg a_3$ & 0 & $(a_1 \\vee \\neg a_3)$ \\\\\n\t\\hline\n      \\end{tabular}\n      \\bigskip \\\\\n      $\\{ \\neg \\dec{a_1}{0}, \\neg \\dec{a_2}{0}, \\neg \\dec{a_3}{0} \\}$\n    \\end{minipage}\n  \\end{tabular}\n\n  \\vfill\n  \\pause\n\n  \\begin{minipage}{\\textwidth}\n    \\begin{prooftree}\n    \\AxiomC{$(a_1 \\vee a_2 \\vee a_3)$}\n    \\AxiomC{$(a_3 \\vee \\neg a_1)$}\n    \\BinaryInfC{$(a_1 \\vee a_2)$}\n    \\AxiomC{$(a_1 \\vee \\neg a_2)$}\n    \\BinaryInfC{$(a_1)$}\n    \\AxiomC{$(\\neg a_1)$}\n    \\BinaryInfC{$\\bot$}\n    \\end{prooftree}\n  \\end{minipage}\n\n  \\vfill\n  \\pause\n  Conflict clause: $\\bot$ \\pause \\\\\n  Backtracking level: 0\n\\end{frame}\n", "meta": {"hexsha": "0329da9f1f7c7e5baf1794f0a85ca3bd39b2af47", "size": 6212, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture10/lazy.tex", "max_stars_repo_name": "formalmethods/smtlectures", "max_stars_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-11-07T19:34:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-24T08:05:50.000Z", "max_issues_repo_path": "lecture10/lazy.tex", "max_issues_repo_name": "formalmethods/smtlectures", "max_issues_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lecture10/lazy.tex", "max_forks_repo_name": "formalmethods/smtlectures", "max_forks_repo_head_hexsha": "d4ec5f7eb377d26427ecc34c72906c85eafe8631", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-06T00:40:41.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-06T00:40:41.000Z", "avg_line_length": 29.4407582938, "max_line_length": 203, "alphanum_fraction": 0.5859626529, "num_tokens": 2570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.43418868739439526}}
{"text": "\\documentclass[aspectratio=149]{beamer}\n\n\\input{../../shared_slides.tex}\n\n% reference: https://yuxinchen2020.github.io/ele522_optimization/lectures/variance_reduction.pdf\n% or\n% https://ieeexplore-ieee-org.uaccess.univie.ac.at/stamp/stamp.jsp?tp=&arnumber=9226504\n\n\\usepackage{booktabs}\n\n\\title{Variance reduction for stochastic gradient methods}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\\frame{\\tableofcontents}\n\n\n\\section{Introduction}%\n\n\\begin{frame}\n  \\frametitle{The finite sum problem}\n  A common Task in (supervised) machine learning:\n  \\begin{equation}\n    \\min_{x\\in \\R^d} f(x) := \\frac{1}{n} \\sum_{i=1}^{n} \\underbrace{f_i(x)}_{\\textcolor{blue}{\\text{loss for $i$-th sample}}} + \\underbrace{\\psi(x)}_{\\textcolor{blue}{\\text{regularizer}}}\n  \\end{equation}\n  where the $i$-th sample is $(a_i, y_i)$.\n\n  \\textbf{Examples:}\n  \\begin{itemize}\n    \\item linear regression: $f_i(x) = {(a_i^T x -y_i)}^2$, and $\\psi=0$\n    \\item logistic regression: $f_i(x) = \\log(1+e^{-y_i a_i^T x})$, and $\\psi=0$\n          ``sigmoid function'' and logistic loss.\n    \\item Lasso: $f_i$ as for linear regression but $\\psi(x) = \\Vert x \\Vert_1$\n    \\item SVM: $f_i(x) = \\max \\{0 , 1 - y_i a_i^T x\\}$ and $\\psi(x)= \\Vert x \\Vert^2$\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Gradient descent}\n  \\begin{algorithm}[H]\n    \\caption{(batch) GD}\n    \\begin{algorithmic}[1]\n      \\For{$k = 1,2, \\dots$}\n      \\State{ $x_{k+1} = x_k  - \\alpha_k \\nabla f(x_k) $}\n      \\EndFor{}\n    \\end{algorithmic}\n  \\end{algorithm}\n\n  \\begin{itemize}\n    \\item gradient can be computed via\n          \\begin{equation}\n            \\nabla f(x) = \\nabla \\left(\\sum_{i=1}^{n}f_i(x)\\right) = \\sum_{i=1}^{n} \\nabla f_i(x_k)\n          \\end{equation}\n    \\item good convergence properties\n    \\item can be \\textbf{expensive} if $n$ is large!\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Stochastic gradient descent}\n  \\begin{algorithm}[H]\n    \\caption{SGD}\\label{sgd}\n    \\begin{algorithmic}[1]\n      \\For{$k = 1,2, \\dots$}\n      \\State{pick $i_k$ uniform at random in $[n]$}\n      \\State{$x_{k+1} = x_k  - \\alpha_k \\nabla f_{i_k}(x_k)$}\n      \\EndFor{}\n    \\end{algorithmic}\n  \\end{algorithm}\n\n  We already noticed that:\n  \\begin{itemize}\n    \\item unbiased: $\\E[\\nabla f_{i_k}(x)] = \\sum_{i=1}^{n} \\P[i=i_k] \\nabla f_i(x) = \\sum_{i=1}^{n} \\frac{1}{n} \\nabla f_i(x)$\n    \\item large stepsizes fail to suppress noise in the stoch.\\ gradients \\\\\n          $\\rightarrow$ leads to oscillations\n    \\item decreasing stepsizes mitigate this problem but \\textbf{slows down} convergence (too \\emph{conservative})\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Recall SGD}\n  \\begin{block}{template}\n    \\begin{equation}\n      x_{k+1} = x_k - \\alpha_k g_k\n    \\end{equation}\n  \\end{block}\n  \\begin{itemize}\n    \\item $g_k$ is an unbiased estimator of the true gradient $\\nabla F(x_k)$\n    \\item convergence depends on \\textbf{variance} $\\E [ \\Vert g_k - \\nabla F(x_k) \\Vert ] \\le \\sigma_g$ \\\\\n          (not strictly necessary)\n    \\item vanilla SGD uses $g_k = \\nabla f_{i_k}(x_k)$ \\\\\n          \\textbf{issue:} $\\sigma_g$ is non-negligible even close to the solution\n    \\item \\textbf{Q:} can we choose $g_k$ in a different way to reduce variability?\n  \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Minibatching}\n  \\begin{algorithm}[H]\n    \\caption{minibatch SGD}\n    \\begin{algorithmic}[1]\n      \\For{$k = 1,2, \\dots$}\n      \\State{pick $I_k$ random subset of $[n]$ with $\\vert I_k \\vert = b $}\n      \\State{$x_{k+1} = x_k  - \\alpha_k \\sum_{i \\in I_k} \\nabla f_{i}(x_k)$}\n      \\EndFor{}\n    \\end{algorithmic}\n  \\end{algorithm}\n  \\begin{itemize}\n    \\item typically we make a (uniform) \\emph{random} choice $i_k \\in [n] = \\{1, \\dots, n\\}$\\\\\n          (or random reshuffling)\n    \\item by increasing the size to a \\textbf{random subset} $I_k \\subset [n]$ of size $b \\ll n$ we can\n          \\begin{itemize}\n            \\item decrease variance\n            \\item increase cost only moderately,\n            \\item no improvement in the rate\n          \\end{itemize}\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{A simple idea}\n  Consider\n  \\begin{itemize}\n    \\item estimator $X$ for parameter $\\mu$ ($\\E[X]=\\mu$ and $\\Var[X]=\\sigma^2$)\n    \\item want to \\textcolor{blue}{keep unbiased} but \\textbf{\\textcolor{blue}{reduce variance}}\n    \\item find $Y$ such that $\\E[Y] = 0$ but $\\Cov (X,Y)$ \\textbf{is large} and define\n          \\begin{equation}\n            \\tilde{X} := X-Y\n          \\end{equation}\n    \\item remains unbiased\n    \\item $\\Var[\\tilde{X}]$ can be much smaller than $\\Var[X]$ if $X,Y$ are highly correlated\n          \\begin{equation}\n            \\Var[\\tilde{X}] = \\Var[X]+\\Var[Y]-2\\Cov[X,Y]\n          \\end{equation}\n  \\end{itemize}\n\\end{frame}\n\n\\section{SAG}%\n\\label{sec:}\n\n\\begin{frame}\n  \\frametitle{Stochastic average gradient (SAG), 2013}\n  \\begin{itemize}\n    \\item \\textbf{maintain table} containing gradients $g_i$ of $f_i$\n    \\item pick random $i_k \\in [n]$ and\n          \\begin{equation}\n            g_{i_k}^k := \\nabla f_{i_k}(x^{k})\n          \\end{equation}\n          set $g_{i}^k = g_i^{k-1}$ for all $i\\neq i_k$ (remain the same)\n    \\item Update\n          \\begin{equation}\n            x^{k+1} = x^k - \\alpha_k \\frac{1}{n} \\sum_{i=1}^{n} g_i^k.\n          \\end{equation}\n    % \\item assuming gradients do not change too much along trajectory\n    \\item gradient estimator \\textcolor{red}{no longer unbiased}\n    \\item Isn't it expensive to average these gradients?\n          \\begin{equation}\n            x^{k+1} = x^k - \\alpha_k  \\Big( \\frac{g_{i_k}^k}{n} - \\frac{g_{i_k}^{k-1}}{n} + \\underbrace{\\frac{1}{n}\\sum_{i=1}^{n} g_i^{k-1}}_{\\text{old table average}} \\Big)\n          \\end{equation}\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{SAG variance reduction}\n  Gradient estimator in SAG:\n  \\begin{equation}\n    x^{k+1} = x^k - \\alpha_k \\frac{1}{n} \\Big( \\underbrace{g_{i_k}^k}_X - \\underbrace{g_{i_k}^{k-1} - \\sum_{i=1}^{n} g_i^{k-1}}_{Y} \\Big)\n  \\end{equation}\n  \\begin{itemize}\n    \\item Indeed $\\E[X] = \\nabla f(x^k)$, but $\\E[Y]\\neq 0$ $\\rightarrow $ is \\textbf{biased estimator}\n    \\item $X$ and $Y$ are correlated as $X-Y \\to 0$:\n          \\begin{itemize}\n            \\item $x^k$ and $x^{k-1}$ both converge to $x^*$ $\\Rightarrow$ $ \\nabla f_i(x^k) - \\nabla f_i(x^{k-1}) \\to 0$\n            \\item the last term converges to $\\nabla f(x^*)= 0$\n          \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Convergence}\n  As always, initialization plays a role: $D^2 := \\Vert x^0 -x^* \\Vert^2$.\n\n  \\begin{equation}\n    \\begin{aligned}\n      \\text{SAG:}& \\quad \\frac{n}{k}(f(x^0)-f^*) + \\frac{L}{k}D^2 \\\\\n      \\text{GD:}& \\quad \\frac{L}{k}D^2 \\\\\n      \\text{SGD:}& \\quad \\frac{L}{\\sqrt{k}}D^2 \\\\\n    \\end{aligned}\n  \\end{equation}\n  \\begin{itemize}\n    \\item Achieves \\textcolor{blue}{linear convergence} in the \\textbf{strongly} convex setting.\n    \\item proofs are difficult (and computer-aided)\n  \\end{itemize}\n\n\n  \\begin{center}\n    Same gradient oracle cost as SGD, but same converge rate as GD.\n  \\end{center}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Experiments from the original paper}\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{SAG-experiments}\n    \\caption{ Solving $\\ell_2$-regularized logistic regression.}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{More ``naive'' implementation}\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=\\textwidth,height=0.9\\textheight,keepaspectratio]{SAG}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{SAG experiments}\n  \\begin{itemize}\n    \\item does not work well out of the box\n    \\item needs a \\textcolor{blue}{warm up} to get good $(g_1^0, g_2^0, \\dots, g_m^0)$\n          \\begin{itemize}\n            \\item achieved by running one full epoch of SGD\n          \\end{itemize}\n    \\item reguires hand tuned stepsize or line search\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\section{SAGA}%\n\\label{sec:}\n\n\\begin{frame}\n  \\frametitle{SAGA, 2014}\n  Very similar to SAG:\n  \\begin{itemize}\n    \\item maintain table containing gradients $g_i$ of $f_i$\n    \\item pick random $i_k \\in [n]$ and\n          \\begin{equation}\n            g_{i_k}^k := \\nabla f_{i_k}(x^{k})\n          \\end{equation}\n          set $g_{i}^k = g_i^{k-1}$ for all $i\\neq i_k$ (remain the same)\n    \\item Update\n          \\begin{equation}\n            x^{k+1} = x^k - \\alpha_k  \\Big( g_{i_k}^k - g_{i_k}^{k-1} + \\frac{1}{n}\\sum_{i=1}^{n} g_i^k \\Big)\n          \\end{equation}\n    \\item estimator now \\textbf{unbiased}!\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{For Comparison}\n  SAGA gradient estimate:\n  \\begin{equation}\n    g_{i_k}^k - g_{i_k}^{k-1} + \\frac{1}{n}\\sum_{i=1}^{n} g_i^k.\n  \\end{equation}\n\n  SAG gradient estimate:\n  \\begin{equation}\n    \\frac{1}{n}g_{i_k}^k - \\frac{1}{n}g_{i_k}^{k-1} + \\frac{1}{n}\\sum_{i=1}^{n} g_i^k.\n  \\end{equation}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Experiments from the original paper}\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{SAGA-experiments}\n    \\caption{Solving regularized logistic regression. First row is $\\ell_2$-regularized; second row is $\\ell_1$.}\n  \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{More ``naive'' implementation}\n\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=\\textwidth,height=0.9\\textheight,keepaspectratio]{SAGA.png}\n    \\caption{Highlights the low variance of SAG.}\n  \\end{figure}\n\\end{frame}\n\n\n\\section{SVRG}%\n\n\\begin{frame}\n  \\frametitle{Stochastic Variance Reduced Gradient (SVRG), 2013}\n\n  \\begin{algorithm}[H]\n    \\caption{SVRG}\\label{}\n    \\begin{algorithmic}[1]\n      \\For{$k=1,2, \\dots$}\n      \\State{Set $x^1 = \\tilde{x} = \\tilde{x}^{k}$}\n      \\State{Compute $\\tilde{\\mu} := \\nabla f(\\tilde{x})$ \\hfill \\textcolor{blue}{//update snapshot}}\n      \\For{$l=1,2, \\dots, m$ }\\hfill \\textcolor{blue}{//$m$ iterations per epoch}\n      \\State{pick $i_l$ uniform at random in $[n]$}\n      \\State{Set $x^{l+1} = x^l - \\alpha (\\nabla f_{i_l}(x^l) - \\nabla f_{i_l}(\\tilde{x}) + \\tilde{\\mu})$}\n      \\EndFor{}\n      \\State{$\\tilde{x}^{k+1}= x^{m+1}$}\n      \\EndFor{}\n    \\end{algorithmic}\n  \\end{algorithm}\n  \\begin{itemize}\n    \\item Does \\textbf{\\textcolor{blue}{not need to store}} full table of gradients.\n    \\item requires \\emph{batch} gradient computation every \\emph{epoch}\n    \\item per iteration cost is comparable to that of SGD if $m \\ge n$\n    \\item convergence rates similar to SAGA, but simpler analysis.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{SVRG}\n  \\textbf{key idea:} by storing old point we can\n  \\begin{equation}\n    \\underbrace{\\nabla f_{i_k}(x^k) - \\nabla f_{i_k}(x^{\\text{old}})}_{\\text{$\\to 0$ if $x\\approx x^{\\text{old}}$}} + \\underbrace{\\nabla f(x^{\\text{old}})}_{\\text{$\\to 0$ if $x^{\\text{old}}\\approx x^*$}}\n  \\end{equation}\n  \\begin{itemize}\n    \\item is an unbiased estimate of $\\nabla f(x^k)$\n    \\item converges to $0$ (meaning reduced variability) if $x^k\\approx x^{\\text{old}} \\approx x^*$\n  \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{SVRG: Theorem}\n\n  \\textcolor{gray}{Each $f_i$ is convex and $L$-smooth, and sum is $\\mu$-strongly convex.}\n\n  \\begin{theorem}\n    Choose $m$ large enough s.t. $\\rho = \\frac{1}{\\mu \\alpha (1-2L \\alpha)m} + \\frac{2L \\alpha}{1-2L \\alpha}< 1$, then\n    \\begin{equation}\n      \\E[F(x_s^{old})- F(x^*)] \\le \\rho^s [F(x_0^{old})-F(x^*)]\n    \\end{equation}\n  \\end{theorem}\n  Computational cost:\n  \\begin{itemize}\n    \\item per epoch: $(m+n)$\n    % \\item complexity: $(n+ \\kappa) \\log(1/\\epsilon)$\n    \\item inner loop is annoying (has to choose $m$) $\\rightarrow$ loopless variant\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{SVRG: Convergence Proof}\n  Denote $g_s^k = \\nabla f_{i_l}(x_s^k) - \\nabla f_{i_l}(x_s^{old}) + \\nabla F(x_s^{old})$. Conditioning on everything prior to $x_s^{k+1}$ we get\n  \\begin{equation}\n    \\begin{aligned}\n      \\MoveEqLeft \\E [\\Vert x_s^{k+1} - x^* \\Vert^2] = \\E [\\Vert x_s^{k}- \\alpha g_s^k - x^* \\Vert^2] \\\\\n      &= \\Vert x_s^k-x^* \\Vert^2 - 2 \\alpha {(x_s^k-x^* )}^T \\E[g_s^t] + \\alpha^2 \\E[\\Vert g_s^k \\Vert^2] \\\\\n      &= \\Vert x_s^k-x^* \\Vert^2 - 2 \\alpha {(x_s^k-x^* )}^T \\textcolor{blue}{\\nabla F(x_s^t)} + \\alpha^2 \\E[\\Vert g_s^k \\Vert^2] \\\\\n      &\\le \\Vert x_s^k-x^* \\Vert^2 - 2 \\alpha (F(x_s^k) - F(x^*))+ \\alpha^2 \\E[\\Vert g_s^k \\Vert^2]\n    \\end{aligned}\n  \\end{equation}\n\n  \\begin{itemize}\n     \\item \\textbf{key step:} control $\\E[\\Vert g_s^k \\Vert^2]$\n   \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{SVRG: convergence Proof}\n  \\begin{lemma}%\n    \\begin{equation}\n      \\E[\\Vert g_s^k \\Vert^2] \\le 4L [ F(x_s^k)- F(x^*) + F(x_s^{old}-F(x^*)) ]\n    \\end{equation}\n\n  \\end{lemma}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Comparison}\n\n  % \\begin{tabular}{l | c}\n  %   SVRG & $(n + \\kappa) \\log(1/\\epsilon)$\\\\\n  %   GD   & $n \\kappa \\log(1/\\epsilon)$ \\\\\n  %   SGD  & $\\kappa^2 / \\epsilon$\n  % \\end{tabular}\n\n  % \\textbf{\\textcolor{blue}{Strongly convex}} problems: number gradient calls to compute:\n  % \\begin{equation}\n  %   \\E [f(x_k)] - f^* \\le \\epsilon\n  % \\end{equation}\n  % is given by\n\n  \\textcolor{gray}{$f$ is $L$-smooth and $\\mu$-strongly convex. Condition number: $\\kappa = L/\\mu$.}\\\\\n  \\textbf{\\textcolor{blue}{Strongly convex}} problems: number gradient calls to compute $\\E [f(x_k)] - f^* \\le \\epsilon$ is given by\n  \\begin{center}\n    \\begin{tabular}{c c c}\n      SVRG / SAGA  & GD & SGD \\\\\n      \\midrule\n      $(n + \\kappa) \\log \\frac{1}{\\epsilon}$ & $n \\kappa \\log \\frac{1}{\\epsilon}$ & $\\kappa^2 / \\epsilon$\n    \\end{tabular}\n  \\end{center}\n  \\vspace{1cm}\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{SAGA-table-comparison}\n    \\caption{Summary of other relevant properties.}\n  \\end{figure}\n\n  % \\begin{itemize}\n  %   \\item SVRG:\\ $(n + \\kappa) \\log(1/\\epsilon)$\n  %   \\item GD:\\ $n \\kappa \\log(1/\\epsilon)$\n  %   \\item SGD:\\ $\\kappa^2 / \\epsilon$\n  % \\end{itemize}\n\n\\end{frame}\n\n\\section{Katyusha}%\n\\label{sec:}\n\n\\begin{frame}\n  \\frametitle{Variance reduction + momentum/acceleration}\n  \\begin{block}{}\n    \\centering\n    \\textbf{Katyusha}\n  \\end{block}\n\n  \\textbf{\\textcolor{blue}{Strongly convex}} problems: number gradient calls to compute $\\E [f(x_k)] - f^* \\le \\epsilon$ is given by\n  \\begin{center}\n  \\begin{tabular}{c c c c c}\n    Katyusha & SVRG / SAGA  & GD & NAG & SGD \\\\\n    \\midrule\n    $(n + \\sqrt{n \\kappa}) \\log \\frac{1}{\\epsilon}$ &$(n + \\kappa) \\log \\frac{1}{\\epsilon}$ & $n \\kappa \\log \\frac{1}{\\epsilon}$ & $n \\sqrt{\\kappa} \\log \\frac{1}{\\epsilon}$ & $\\kappa^2 / \\epsilon$\n  \\end{tabular}\n  \\end{center}\n  \\vspace{1cm}\n  \\begin{itemize}\n    \\item Improvement critical for \\textbf{\\textcolor{blue}{ill conditioned}} ($\\kappa \\gg n$) problems.\n  \\end{itemize}\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Katyusha in the non-strongly convex setting}\n  \\textbf{\\textcolor{blue}{just convex}} problems: number gradient calls to compute $\\E [f(x_k)] - f^* \\le \\epsilon$ is given by\n  \\begin{center}\n  \\begin{tabular}{c c c c c c}\n    lower bound & Katyusha & SVRG & GD & NAG & SGD \\\\\n    \\midrule\n    $n + \\sqrt{\\frac{n L}{\\epsilon}}$ & $n \\log \\frac{1}{\\epsilon} + \\sqrt{\\frac{n L}{\\epsilon}}$ &$n + \\sqrt{n}\\frac{L}{\\epsilon}$ & $n \\frac{L}{\\epsilon}$ & $n \\sqrt{\\frac{L}{\\epsilon}}$ & $ \\frac{1}{\\epsilon^2}$\n  \\end{tabular}\n  \\end{center}\n  \\vspace{1cm}\n  \\textcolor{gray}{Almost matches lower bound.}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Summary}\n\n  \\begin{itemize}\n    \\item Variance reduction recovers the rates of batch (deterministic methods)\n    \\item but (more or less) keeps number of gradient calls of SGD\n    \\item still require batch gradient computations sometimes\n    \\item requires offline setting (multiple passes through data)\n    \\item requires knowledge of (multiple) parameters to get good stepsize\n  \\end{itemize}\n\n  \\textcolor{gray}{\n  Check out this fantastic review paper:\n  https://ieeexplore-ieee-org.uaccess.univie.ac.at/stamp/stamp.jsp?tp=&arnumber=9226504}\n\n\\end{frame}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "496fce9a53e703fed1cafac668169891c38b1a2e", "size": 16139, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/12_Variance-reduction/Variance_reduction.tex", "max_stars_repo_name": "LukasKarner/optimization-for-DS-lecture", "max_stars_repo_head_hexsha": "19b9dca8c6256bedfb7ef85cb56992fcb7b43598", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/12_Variance-reduction/Variance_reduction.tex", "max_issues_repo_name": "LukasKarner/optimization-for-DS-lecture", "max_issues_repo_head_hexsha": "19b9dca8c6256bedfb7ef85cb56992fcb7b43598", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/12_Variance-reduction/Variance_reduction.tex", "max_forks_repo_name": "LukasKarner/optimization-for-DS-lecture", "max_forks_repo_head_hexsha": "19b9dca8c6256bedfb7ef85cb56992fcb7b43598", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0040899796, "max_line_length": 214, "alphanum_fraction": 0.6199888469, "num_tokens": 5870, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.43418868399012445}}
{"text": "% !TEX root = main.tex\n% !TEX spellcheck = en-US\n\n\\section{Non-malleability of $\\sonicprotfs$}\n\\label{sec:sonic}\n\n\\markulfdone{22.04}{I prefer the notation $Pr[\\chi \\gets \\FF_q; \\chi' \\gets \\adv( ...): \\chi=\\chi']$ as one can start reading at the left. But I will let that one go and will admit that it's a question of taste and it might be an aquired taste. }\n\n\\subsection{Preliminaries}\n\\begin{definition}[$(q_1, q_2)\\mhyph\\ldlog$ assumption]\\label{def:ldlog}\n  Let $\\adv$ be a $\\ppt$ adversary that gets as input\n  $\\gone{\\chi^{-q_1}, \\ldots, 1, \\ldots, \\chi^{q_1}}, \\gtwo{\\chi^{-q_2},\n    \\ldots, 1, \\ldots, \\chi^{q_2}}$, for some randomly picked\n  $\\chi \\in \\FF_p$, the assumption requires that $\\adv$ cannot compute $\\chi$. That is\n\t\\[\n    \\condprob{\\chi = \\adv(\\gone{\\chi^{-q_1}, \\ldots, 1, \\ldots,\n        \\chi^{q_1}}, \\gtwo{\\chi^{-q_2}, \\ldots, 1, \\ldots, \\chi^{q_2}\n      })}{\\chi \\sample \\FF_p} \\leq \\negl.\n\t\\]\n\\end{definition}\n\n\\begin{definition}[$(q_1, q_2)\\mhyph\\uldlog$ assumption]\\label{def:uldlog}\n\tLet $\\adv$ be a $\\ppt$ adversary that gets oracle access to $\\initU$ with internal algorithms $(\\kgen_{\\ldlog}, \\upd_{\\ldlog}, \\verifyCRS)$, where $\\kgen_{\\ldlog}$ and $\\upd_{\\ldlog}$ are defined as follows:\n\t\\begin{itemize}\n\t\t\\item $\\kgen_\\ldlog(\\secpar)$ samples $\\chi \\sample \\FF_p$ and defines \n\t\t$\\Ch:=(\\gone{\\chi^{-q_1}, \\ldots, 1, \\chi, \\ldots,\n\t\t\t\\chi^{q_1}}, \\gtwo{\\chi^{-q_2}, \\ldots, 1, \\chi, \\ldots, \\chi^{q_2}\n\t\t})$.\n\t\t\\item $\\upd_\\ldlog(\\Ch, \\{\\rho_j \\}_{j=1}^n)$ \n\t\tparses $\\Ch$ as $\\left( \\gone{\\smallset{A_i}_{i = -q_1}^{q_1}},\n\t\t\\gtwo{\\smallset{B_i}_{i = -q_2}^{q_2}} \\right)$, samples\n\t\t$\\widetilde{\\chi} \\sample \\FF_p$, and defines\n\t\t$\\widetilde{\\Ch} := \n\t\t\\left( \\gone{\\smallset{\\widetilde{\\chi}^i A_i}_{i = -q_1}^{q_1}},\n\t\t\\gtwo{\\smallset{\\widetilde{\\chi}^i B_i}_{i = -q_2}^{q_2}} \\right)$.\n\t\\end{itemize}\n\tThen\n\t\\[\n\t\\prob{\\bar{\\chi} \\gets \\adv^{\\initU}(\\secpar)} \\leq \\negl,\n\t\\]\n\twhere $\\left( \\gone{\\smallset{\\bar{\\chi}^i}_{i = -q_1}^{q_1}},\n\t\\gtwo{\\smallset{\\bar{\\chi}^i}_{i = -q_2}^{q_2}} \\right)$ is the finalized challenge.\n\\end{definition}\n\n\\subsection{\\sonic{} Protocol Rolled-out}\nIn this section we present $\\sonic$'s constraint system and algorithms. Reader\nfamiliar with them may jump directly to the next section.\n\n \\begin{figure}[h!]\n \\centering\n \t\\begin{pcvstack}[center,boxed]\n \t\t\\begin{pchstack}\n \t\t\t\\procedure{$\\kgen(\\secparam, \\maxdeg)$} {\n \t\t\t\t\\alpha, \\chi \\sample \\FF^2_p \\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{\\smallset{\\chi^i}_{i = -\\multconstr}^{\\multconstr},\n           \\smallset{\\alpha \\chi^i}_{i = -\\multconstr, i \\neq\n             0}^{\\multconstr}},\\\\\n         \\pcind \\gtwo{\\smallset{\\chi^i, \\alpha \\chi^i}_{i =\n             -\\multconstr}^{\\multconstr}}, \\gtar{\\alpha}\\\\\n \t\t\t\t\\hphantom{\\hspace*{5.5cm}}\n \t\t}\n\n \t\t\t\\pchspace\n\n \t\t\t\\procedure{$\\com(\\srs, \\maxconst, \\p{f}(X))$} {\n \t\t\t\t\\p{c}(X) \\gets \\alpha \\cdot X^{\\dconst - \\maxconst} \\p{f}(X) \\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{c} = \\gone{\\p{c}(\\chi)}\\\\ [\\myskip]\n \t\t\t\t\\hphantom{\\pcind \\pcif \\sum_{i = 1}^{\\abs{\\vec{z}}} r_i \\cdot\n           \\gone{\\sum_{j = 1}^{t_j} \\gamma_i^{j - 1} c_{i, j} - \\sum_{j = 1}^{t_j}\n             s_{i, j}} \\bullet \\gtwo{1} + } }\n \t\t\\end{pchstack}\n \t\t% \\pcvspace\n\n \t\t\\begin{pchstack}\n \t\t\t\\procedure{$\\open(\\srs, z, s, f(X))$}\n \t\t\t{\n \t\t\t\t\\p{o}(X) \\gets \\frac{\\p{f}(X) - \\p{f}(z)}{X - z}\\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{\\p{o}(\\chi)}\\\\ [\\myskip]\n \t\t\t\t\\hphantom{\\hspace*{5.5cm}}\n \t\t\t}\n\n \t\t\t\\pchspace\n\n \t\t\t\\procedure{$\\verify(\\srs, \\maxconst, \\gone{c}, z, s, \\gone{\\p{o}(\\chi)})$}\n       {\n         \\pcif \\gone{\\p{o}(\\chi)} \\bullet \\gtwo{\\alpha \\chi} + \\gone{s - z\n         \\p{o}(\\chi)} \\bullet \\gtwo{\\alpha} = \\\\ [\\myskip] \\pcind \\gone{c}\n         \\bullet \\gtwo{\\chi^{- \\dconst + \\maxconst}} \\pcthen  \\pcreturn 1\\\\\n         [\\myskip]\n         \\rlap{\\pcelse \\pcreturn 0.} \\hphantom{\\pcind \\pcif \\sum_{i =\n             1}^{\\abs{\\vec{z}}} r_i \\cdot \\gone{\\sum_{j = 1}^{t_j} \\gamma_i^{j -\n               1} c_{i, j} - \\sum{j = 1}^{t_j} s_{i, j}} \\bullet \\gtwo{1} + } }\n \t\t\\end{pchstack}\n \t\\end{pcvstack}\n\n \t\\caption{$\\PCOMs$ polynomial commitment scheme.}\n \t\\label{fig:pcoms}\n \\end{figure}\n\n\n\n\\oursubsub{The Constraint System}\n\\label{sec:sonic_constraint_system}\n\\cref{fig:pcoms} presents a variant of KZG~\\cite{AC:KatZavGol10} polynomial commitment schemes used in \\sonic{}. \\sonic's system of constraints composes of three $\\multconstr$-long vectors\n$\\va, \\vb, \\vc$ which corresponds to left and right inputs to multiplication\ngates and their outputs. It hence holds $\\va \\cdot \\vb = \\vc$.\n\nThere is also $\\linconstr$ linear constraints of the form\n\\[\n  \\va \\vec{u_q} + \\vb \\vec{v_q} + \\vc \\vec{w_q} = k_q,\n\\]\nwhere $\\vec{u_q}, \\vec{v_q}, \\vec{w_q}$ are vectors for the $q$-th linear\nconstraint with instance value $k_q \\in \\FF_p$. Furthermore define polynomials\n\\begin{equation}\n  \\begin{split}\n    \\p{u_i}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} u_{q, i}\\,,\\\\\n    \\p{v_i}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} v_{q, i}\\,,\\\\\n  \\end{split}\n  \\qquad\n  \\begin{split}\n    \\p{w_i}(Y) & = -Y^i - Y^{-i} + \\sum_{q = 1}^\\linconstr Y^{q +\n      \\multconstr} w_{q, i}\\,,\\\\\n    \\p{k}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} k_{q}.\n  \\end{split}\n\\end{equation}\n\n$\\sonic$ constraint system requires that\n\\begin{align}\n  \\label{eq:sonic_constraint}\n  \\vec{a}^\\top \\cdot \\vec{\\p{u}} (Y) + \\vec{b}^\\top \\cdot \\vec{\\p{v}} (Y) +\n  \\vec{c}^\\top \\cdot \\vec{\\p{w}} (Y) + \\sum_{i = 1}^{\\multconstr} a_i b_i (Y^i +\n  Y^{-i}) - \\p{k} (Y) = 0.\n\\end{align}\n\nIn \\sonic{} we will use commitments to the following polynomials.\n\\begin{align*}\n  \\pr(X, Y) & = \\sum_{i = 1}^{\\multconstr} \\left(a_i X^i Y^i + b_i X^{-i} Y^{-i}\n              + c_i X^{-i - \\multconstr} Y^{-i - \\multconstr}\\right) \\\\\n  \\p{s}(X, Y) & = \\sum_{i = 1}^{\\multconstr} \\left( u_i (Y) X^{-i} +\n                v_i(Y) X^i + w_i(Y) X^{i + \\multconstr}\\right)\\\\\n  \\pt(X, Y) & = \\pr(X, 1) (\\pr(X, Y) + \\p{s}(X, Y)) - \\p{k}(Y)\\,.\n\\end{align*}\n\nPolynomials $\\p{r} (X, Y), \\p{s} (X, Y), \\p{t} (X, Y)$ are designed such that\n$\\p{t} (0, Y) = \\vec{a}^\\top \\cdot \\vec{\\p{u}} (Y) + \\vec{b}^\\top \\cdot\n\\vec{\\p{v}} (Y) + \\vec{c}^\\top \\cdot \\vec{\\p{w}} (Y) + \\sum_{i =\n  1}^{\\multconstr} a_i b_i (Y^i + Y^{-i}) - \\p{k} (Y) $. That is, the prover is\nasked to show that $\\p{t} (0, Y) = 0$, cf.~\\cref{eq:sonic_constraint}.\n\nFurthermore, the commitment system in $\\sonic$ is designed such that it is\ninfeasible for a $\\ppt$ algorithm to commit to a polynomial with non-zero\nconstant term.\n\n\\oursubsub{Algorithms Rolled out}\n\\ourpar{$\\sonic$ SRS generation $\\kgen(\\REL)$.} The SRS generating algorithm picks\nrandomly $\\alpha, \\chi \\sample \\FF_p$ and outputs\n\t\\[\n      \\srs = \\left( \\gone{\\smallset{\\chi^i}_{i = -\\dconst}^{\\dconst},\n          \\smallset{\\alpha \\chi^i}_{i = -\\dconst, i \\neq 0}^{\\dconst}},\n        \\gtwo{\\smallset{\\chi^i, \\alpha \\chi^i}_{i = - \\dconst}^{\\dconst}},\n        \\gtar{\\alpha} \\right)\n\t\\]\n\\ourpar{$\\sonic$ prover $\\prover(\\srs, \\inp, \\wit=\\va, \\vb, \\vc)$.}\n\\begin{description}\n\\item[Message 1] The prover picks randomly randomizers\n  $c_{\\multconstr + 1}, c_{\\multconstr + 2}, c_{\\multconstr + 3}, c_{\\multconstr\n    + 4} \\sample \\FF_p$. Sets\n  $\\pr(X, Y) \\gets \\pr(X, Y) + \\sum_{i = 1}^4 c_{\\multconstr + i} X^{- 2\n    \\multconstr - i}$. Commits to $\\pr(X, 1)$ and outputs\n  $\\gone{r} \\gets \\com(\\srs, \\multconstr, \\pr(X, 1))$.  Then it computes challenge $y = \\ro(\\tzkproof[0..1])$.\n\\item[Message 2] $\\prover$ commits to $\\pt(X, y)$ and outputs\n  $\\gone{t} \\gets \\com(\\srs, \\dconst, \\pt(X, y))$. Then it gets a challenge $z = \\ro(\\tzkproof[0..2])$.\n\\item[Message 3] The prover computes commitment openings. That is, it outputs\n  \\begin{align*}\n    \\gone{o_a} & = \\open(\\srs, z, \\pr(z, 1), \\pr(X, 1)) \\\\\n    \\gone{o_b} & = \\open(\\srs, y z, \\pr(y z, 1), \\pr(X, 1)) \\\\\n    \\gone{o_t} & = \\open(\\srs, z, \\pt(z, y), \\pt(X, y)) \n  \\end{align*}\n  along with evaluations $a' = \\pr(z, 1), b' = \\pr(y, z), t' = \\pt(z, y)$.  Then it\n  engages in the signature of correct computation playing the role of the\n  helper, i.e.~it commits to $\\p{s}(X, y)$ and sends the commitment $\\gone{s}$, commitment opening\n  \\begin{align*}\n    \\gone{o_s} & = \\open(\\srs, z, \\p{s}(z, y), \\p{s}(X, y)), \\\\\n  \\end{align*} and $s'=\\p{s}(z, y)$. \n%\n  Then\n  it obtains a challenge $u = \\ro(\\tzkproof[0..3])$.\n\\item[Message 4] For the next message the prover computes\n  $\\gone{c} \\gets \\com(\\srs, \\dconst, \\p{s}(u, Y))$ and\n  computes commitments' openings\n  \\begin{align*}\n    \\gone{w} & = \\open(\\srs, u, \\p{s}(u, y), \\p{s}(X, y)), \\\\\n    \\gone{q_y} & = \\open(\\srs, y,\\p{s}(u, y), \\p{s}(u, Y)),\n  \\end{align*}\n  and returns $\\gone{w}, \\gone{q_y}, s = \\p{s}(u, y)$. Eventually the prover gets the last challenge\n  $z' = \\ro(\\tzkproof[0..4])$.\n\\item[Message 5] For the final message, $\\prover$ computes opening\n  $\\gone{q_{z'}} = \\open(\\srs, z', \\p{s}(u, z'), \\p{s}(u, X))$ and outputs $\\gone{q_{z'}}$.\n\\end{description}\n\n\\ourpar{$\\sonic$ verifier $\\verifier(\\srs, \\inp, \\zkproof)$.} The verifier\nin \\sonic{} runs as subroutines the verifier for the polynomial commitment. That\nis it sets $t' = a'(b' + s') - \\p{k}(y)$ and checks the following:\n\\begin{equation*}\n  \\begin{split}\n    &\\PCOMs.\\verifier(\\srs, \\multconstr, \\gone{r}, z, a', \\gone{o_a}), \\\\\n    &\\PCOMs.\\verifier(\\srs, \\multconstr, \\gone{r}, y z, b', \\gone{o_b}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{t}, z, t', \\gone{o_t}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{s}, z, s', \\gone{o_s}),\\\\\n  \\end{split}\n  \\qquad\n  \\begin{split}\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{s}, u, s, \\gone{w}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{c}, y, s, \\gone{q_y}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{c}, z', \\p{s}(u, z'), \\gone{q_{z'}}),\n  \\end{split}\n\\end{equation*}\nand accepts the proof iff all the checks holds. Note that the value\n$\\p{s}(u, z')$ that is recomputed by the verifier uses separate challenges $u$\nand $z'$. This enables the batching of many proof and outsourcing of this\npart of the proof to an untrusted helper.\n\n\\subsection{Unique Opening Property of $\\PCOMs$}\n\\begin{lemma}\n\\label{lem:pcoms_unique_op}\n$\\PCOMs$ has the unique opening property in the AGM. \n\\end{lemma}\n\\begin{proof}\nLet \n$z \\in \\FF_p$ be the attribute the polynomial is evaluated at,\n$\\gone{c} \\in \\GRP$ be the commitment,  \n$s \\in \\FF_p$ the evaluation value, and \n$o \\in \\GRP$ be the commitment opening. \nWe need to show that for every $\\ppt$ adversary $\\adv$ probability\n\\[\n  \\Pr \\left[\n    \\begin{aligned}\n      & \\verify(\\srs, \\gone{c}, z, s, \\gone{o}) = 1, \\\\\n      & \\verify(\\srs, \\gone{c}, z, \\tilde{s}, \\gone{\\tilde{o}}) = 1\n    \\end{aligned}\n    \\,\\left|\\, \\vphantom{\\begin{aligned}\n          & \\verify(\\srs, \\gone{c}, z, s, \\gone{o}),\\\\\n          & \\verify(\\srs, \\gone{c}, z, s, \\gone{\\tilde{o}}) \\\\\n          &o \\neq \\tilde{o})\n\t\t\\end{aligned}}\n      \\begin{aligned}\n        %& \\srs \\gets \\kgen(\\secparam, \\maxdeg), \\\\\n        & (\\gone{c}, z, s, \\gone{o}, \\gone{\\tilde{o}}) \\gets \\adv^{\\initU}(1^\\secpar, \\maxdeg)\n      \\end{aligned}\n    \\right.\\right]\n  % \\leq \\negl.\n\\]\nis at most negligible.\n\nAs noted in \\cite[Lemma 2.2]{EPRINT:GabWilCio19} it is enough to upper bound the\nprobability of the adversary succeeding against the ideal verifier, who verifies equality between polynomials.\n\nFor a polynomial $f$, its degree upper bound $\\maxconst$, evaluation point $z$,\nevaluation result $s$, and opening $\\gone{o(X)}$ the ideal verifier checks that\n\\begin{equation}\n  \\alpha (X^{\\dconst - \\maxconst}f(X) \\cdot X^{-\\dconst + \\maxconst} -  s) \\equiv \\alpha \\cdot o(X) (X - z)\\,,\n\\end{equation}\nwhat is equivalent to \n\\begin{equation}\n\tf(X) -  s \\equiv o(X) (X - z)\\,.\n\t\\label{eq:pcoms_idealised_check}\n\\end{equation}\nSince $o(X)(X - z) \\in \\FF_p[X]$ then from the uniqueness of polynomial\ncomposition, there is only one $o(X)$ that fulfills the equation above.\n\\qed\n\\end{proof}\n\n\\subsection{Unique Response Property}\nThe unique response property of $\\sonicprotfs$ follows from the unique opening\nproperty of the polynomial commitment scheme $\\PCOMs$.\n\\begin{lemma}\n\\label{lem:sonicprot_ur}\nIf a polynomial commitment scheme $\\PCOMs$ is evaluation binding with security loss $\\epsbind (\\secpar)$ and has unique openings property with security loss $\\epsop(\\secpar)$,\\COMMENT{ and $(\\dconst, \\dconst)$-$\\uldlog$ problem is $\\epsuldlog (\\secpar)$-hard,} then $\\sonicprotfs$ is $\\ur{2}$ against algebraic adversaries with security loss\n  \\[\n    2 \\cdot \\epsbinding (\\secpar) + \\epsop (\\secpar).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let $\\adv$ be an algebraic adversary tasked to break the $\\ur{2}$-ness of\n  $\\sonicprotfs$. We note that to show $\\ur{2}$-ness is is enough to show that the first prover's message determines, along with the verifiers challenges, the rest of it. \n  % This is done by game hops. In the games, the adversary outputs two proofs \n  We denote by $\\zkproof^0$ and $\\zkproof^1$ the two proofs for the same statement the adversary outputs.\n  To distinguish polynomials and commitments which an honest prover sends in the\n  proof from the polynomials and commitments computed by the adversary we write the latter using indices $0$ and $1$ (two indices as we have two transcripts), e.g.~to describe the quotient polynomial provided by the adversary we write $\\p{t}^0$ and   $\\p{t}^1$ instead of $\\p{t}$ as in the description of the protocol.\n\n  We note that since the unique response property requires from $\\zkproof^{0}$ and $\\zkproof^{1}$ that the first place they possibly differ is the $3$-th prover's message, then the challenge $z$, that is picked by the adversary after the $2$-rd message is the same in both transcripts. This challenge determines the evaluation point of polynomials $\\p{r}(X, 1), \\p{t}(X, y)$ which commitments are already sent.\n\n  In its third message, the prover provides evaluations of these polynomials along with their openings at $z$ or $yz$. Note that the adversary can output two accepting proofs that differ on their third message only if it  manages to break evaluation binding of one of the opening. Since the commitment scheme is evaluation binding with security loss $\\epsbinding (\\secpar)$, the adversary can make $\\zkproof^{0}$ and $\\zkproof^{1}$ differ on the third message with probability at most $\\epsbinding (\\secpar) $. \n\n  Similarly, in its fourth message, the prover provides an evaluation at $u$ of polynomial $\\p{s}(X, y)$, an evaluation at $y$ of $\\p{s} (u, Y)$, and the corresponding openings. Note that the adversary can output two accepting proofs that differ on their fourth message only if it manages to break evaluation binding of one of the opening. Since the commitment scheme is evaluation binding with security loss $\\epsbinding (\\secpar)$, the adversary can make $\\zkproof^{0}$ and $\\zkproof^{1}$ differ on the fourth message with probability at most $\\epsbinding (\\secpar) $. \n\n  Next, assume that the transcripts are the same up to the fourth message, but differ at the fifth. In that message, the adversary provides openings of the evaluations. Since the unique opening property, the adversary can open the valid evaluation of a polynomial to two different values with probability at most $\\epsop (\\secpar)$.%, which is upper-bounded by $\\epsuldlog (\\secpar)$.\n\n  By the union bound, the adversary is able to break the unique response property with probability upper bounded by $2 \\epsbinding (\\secpar) + \\epsop (\\secpar)$.\n\\iffalse\n  \\michals{30.4}{Old proof starts here}\n\n  \\ncase{Game 0} \n  \\ngame{0} In this game, the adversary additionally wins if it provides two transcripts that match on all $5$ messages sent by the prover.\n  In this game the adversary cannot win.\n\n  \\ngame{1} This game is identical to Game $\\game{0}$ except that now the\n  adversary additionally wins if it provides two transcripts that matches on the first four\n  messages of the proof.\n\n  \\ncase{Game 0 to Game 1} We show that the probability that $\\adv$\n  wins in one game but does not in the other is negligible.  Observe that in\n  after its $4$-th message, the adversary is given a challenge $z'$ and has to open\n  commitment to $\\p{s} (u, z')$. Hence, to be able to give two different\n  openings in its $5$-th message, $\\adv$ has to break the unique opening property of the\n  KZG commitment scheme which happens with probability $\\epsop (\\secpar)$ tops.\n\n  \\ngame{2} This game is identical to Game $\\game{1}$ except that now the\n  adversary additionally wins if it provides two transcripts that matches on the\n  first three messages of the proof.\n\n  \\ncase{Game 2 to Game 3} In its $4$-th message the adversary computes evaluation\n  $s = \\p{s} (u, y)$ and the corresponding openings $\\gone{w}, \\gone{q_y}$. The adversary\n  cannot provide two different evaluations for the committed polynomials, since that would\n  require breaking the evaluation binding property, which happens (by the union bound)\n  with probability at most $2 \\cdot \\epsbind (\\secpar)$. Also, the adversary cannot provide two\n  different yet valid opening except probability $2 \\cdot \\epsop (\\secpar)$\n\n  Hence, the probability that adversary wins in one game but does not in the\n  other is upper-bounded by $2 \\cdot (\\epsbind (\\secpar) + \\epsop (\\secpar))$\n\n  \\ngame{4} This game is identical to Game $\\game{3}$ except that now the\n  adversary additionally wins if it provides two transcripts that match on the\n  first two messages of the proof.\n\n  \\ncase{Game 3 to Game 4} In its $3$-rd message the adversary computes $4$ polynomial\n  evaluations and their openings. It also sends commitment to $\\p{s} (X, y)$ which is a\n  signature of correct computation.\n\n  Probability that the adversary provides different evaluations or polynomial openings is\n  upper bounded by $4 \\cdot (\\epsop (\\secpar) + \\epsbind (\\secpar))$. Since the polynomial\n  commitment scheme is deterministic, if commitment to $\\p{s^0} (X, y)$ does not equal\n  commitment to $\\p{s^1} (X, y)$, then at least one of these values has been computed\n  incorrectly. Probability that the adversary outputs an accepting proof, where signature\n  of correct computation has been computed incorrectly is upper-bounded by $\\epss\n  (\\secpar) + \\epsdlog (\\secpar)$, cf.~\\cref{lem:plonkprot_ur}.\n\n  \\ncase{Game 5}  This game is identical to Game $\\game{4}$ except that now the\n  adversary additionally wins if it provides two transcripts that match on the\n  first messages of the proof.\n\n  \\ncase{Game 4 to Game 5} In its second message the adversary commits to polynomial\n  $\\p{t} (X, y)$. Since the commitment scheme is deterministic, probability that adversary\n  outputs accepting proofs where commitment to $\\p{t^0} (X, y)$ does not equal commitment\n  to $\\p{t^1} (X)$ is upper-bounded by $\\epss (\\secpar) + \\epsdlog (\\secpar)$, cf.~\\cref{lem:plonkprot_ur}.\n\n  \\ncase{Conclusion} Taking all the games together, the probability that $\\adv$ wins\n  in Game 5 is upper-bounded by\n  \\[\n    3 \\cdot \\epsop (\\secpar) + 2 \\cdot (\\epsbind (\\secpar) + \\epss (\\secpar) +\n    \\epsdlog (\\secpar)).\n  \\]\n  \\fi\n  \\qed\n\\end{proof}\n\n\\subsection{Rewinding-Based Knowledge Soundness}\n\\begin{lemma}\n\t\\label{lem:sonicprot_ss}\n  $\\sonicprotfs$ is $(2, \\noofc + 1)$-rewinding-based knowledge sound against algebraic adversaries who make up to $q$ random oracle queries with security loss \n  \\[\n    \\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left( \\frac{\\noofc}{p}\\right)}{1 - \\frac{\\noofc}{p}}\\right) + (\\noofc + 1) \\cdot \\epsuldlog (\\secpar)\\,,\n  \\]\n\tHere $\\accProb$ is a probability that the adversary outputs an accepting proof, and $\\epsuldlog(\\secpar)$ is the security of $(\\maxdeg, \\maxdeg)$-$\\uldlog$ assumption.\n\\end{lemma}\n\n% \t$\\sonicprot$ is $(2, \\noofc + 1)$-computational special sound with security loss $(\\epst (\\accProb, \\secpar), \\epss(\\secpar))$ against\n% \talgebraic adversaries, where\n%   \\[\n%     \\epst(\\accProb, \\secpar) \\leq \\frac{\\accProb - (q + 1) \\epsid (\\secpar)}{1 - \\epsid (\\secpar)}\\,,\n%   \\]\n%   and\n% \t\\[\n% \t  \\epss(\\secpar) \\leq \\epsid(\\secpar) + \\epsldlog(\\secpar) \\,.\n% \t\\]\n% \tHere $\\accProb$ is a probability that the adversary outputs an accepting proof, $q$ is the upper bound for a number of random oracle queries the adversary makes, $\\epsid(\\secpar)$ is a soundness error of the idealized verifier, and $\\epsldlog(\\secpar)$ is security of $(\\dconst, \\dconst)$-$\\ldlog$ assumption.\n% \\end{lemma}\n\n\nLet $\\adv^{\\ro, \\initU}(\\secparam; r)$ be the adversary who outputs $(\\inp, \\zkproof)$ such that $\\sonicprotfs.\\verifier$ accepts the proof. Let $\\tdv$ be the tree-building algorithm of \\cref{lem:attema} that outputs a tree $\\tree$, and let $\\extcss$ be an extractor that given the tree output by $\\tdv$ reveals the witness for $\\inp$. The main idea of the proof is to show that an adversary who breaks rewinding-based knowledge soundness can be used to break a $\\uldlog$-problem instance. The proof goes by game hops. Note that since the tree branches after $\\adv$'s $2$-nd message, the instance $\\inp$, commitments $\\gone{\\p{r} (\\chi, 1), \\p{t} (\\chi, y)}$, and challenge $y$ are the same in all the transcripts. Also, the tree branches after the second adversary's message where the challenge $z$ is presented, thus tree $\\tree$ is built using different values of $z$.\tWe consider the following games.\n\n  \\ncase{Game 0} %\n  In this game, the adversary wins if it outputs a valid instance--proof pair $(\\inp, \\zkproof)$, and the extractor $\\extcss$ does not manage to output a witness $\\wit$ such that $\\REL (\\inp, \\wit)$ holds.\n\n  \\ncase{Game 1} %\n  In this game, the environment aborts the game if the tree building algorithm $\\tdv$ fails in building a tree of accepting transcripts $\\tree$. \n\n  \\ncase{Game 0 to Game 1} %\n  By \\cref{lem:attema} probability that Game 1 is aborted, while Game 0 is not, is, at most\n  \\[\n    1 - \\frac{\\accProb - (q + 1) \\left( \\frac{\\noofc}{p} \\right)} {1 - \\frac{\\noofc }{p}} \\,.\n\\]\n\n  \\ncase{Game 2} %\n  In this game the environment additionally aborts if at least one of its proofs in $\\tree$ is not accepting by an ideal verifier.\n\n  \\ncase{Game 1 to Game 2} % \n  As usual, we show a reduction that breaks an instance of a $\\uldlog$ assumption when Game 2 is aborted, while Game 1 is not.\n\n  Let $\\rdvuldlog$ be a reduction that gets as input an $(\\maxdeg, \\maxdeg)$-$\\uldlog$ instance $\\gone{\\chi^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi^{\\maxdeg}}, \\gtwo{\\chi^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi^{\\maxdeg}}$. Then it can update the instance to another one $\\gone{\\chi'^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi'^{\\maxdeg}}, \\gtwo{\\chi'^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi'^{\\maxdeg}}$. Eventually, the reduction outputs $\\chi'$.\n\t%\n\tThe reduction $\\rdvuldlog$ proceeds as follows.\n\tFirst, it builds $\\adv$'s SRS $\\srs$ using the input $\\uldlog$ instance. Then it processes the adversary's update query by adding it to the list $\\Qsrs$ and passing it to its own update oracle getting instance $\\gone{\\chi'^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi'^{\\maxdeg}}, \\gtwo{\\chi'^{-\\maxdeg}, \\ldots, 1, \\ldots, \\chi'^{\\maxdeg}}$. The updated SRS $\\srs'$ is then computed and given to $\\adv$. $\\rdvuldlog$ also takes care of the random oracle queries made by $\\adv$. It picks their answers honestly and writes them in $\\Qro$. The reduction then starts $\\tdv(\\srs, \\adv, r, \\Qro, \\Qsrs)$.\n\t\n  Let $(1, \\tree)$ be the output returned by $\\tdv$. Let $\\inp$ be a relation proven in $\\tree$.  Consider a transcript $\\zkproof \\in \\tree$ such that $\\vereq_{\\inp, \\zkproof}(X) \\neq 0$, but $\\vereq_{\\inp, \\zkproof}(\\chi') = 0$. Since $\\adv$ is algebraic, all group elements included in $\\tree$ are extended by their representation as a combination of the input $\\GRP_1$-elements. Hence, all coefficients of the verification equation polynomial $\\vereq_{\\inp, \\zkproof}(X)$ are known. \n  Eventually, the reduction finds $\\vereq_{\\inp, \\zkproof}(X)$ zero points and returns $\\chi'$ which is one of them.\n    \n  Hence, the probability that the adversary wins in Game 2 but does not win in Game 1 is upper-bounded by $(\\noofc + 1) \\cdot \\epsuldlog (\\secpar)$.\n\n  \\ncase{Conclusion}\n  Note that the adversary can win in Game 2 only if $\\tdv$ manages to produce a tree of accepting transcript $\\tree$, such that each of the transcripts in $\\tree$ is accepting by an ideal verifier. Note that since $\\tdv$ produces $(\\noofc + 1)$ accepting transcripts for different challenges $z$, it obtains the same number of different evaluations of polynomial $\\p{t} (z, y)$ what allows to extract the witness, cf.~\\cite{CCS:MBKM19}.\n\n  Hence, the probability that the adversary wins in Game 0 is upper-bounded by \n  \\[\n    \\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left( \\frac{\\noofc}{p} \\right)}{1 - \\frac{\\noofc}{p}}\\right) + (\\noofc + 1) \\cdot\\epsuldlog (\\secpar)\\,. \n  \\]\n\n\\subsection{Trapdoor-Less Zero-Knowledge of Sonic}\n\\begin{lemma}\n\\label{lem:sonic_hvzk}\n$\\sonicprotfs$ is 2-programmable trapdoor-less zero-knowledge.\n\\end{lemma}\n\\begin{proof}\n  The simulator proceeds as follows.\n  \\begin{enumerate}\n  \\item Pick randomly vectors $\\vec{a}$, $\\vec{b}$ and set\n    \\begin{equation}\n      \\label{eq:ab_eq_c}\n      \\vec{c} = \\vec{a} \\cdot \\vec{b}. \n    \\end{equation}\n  \\item Pick randomizers $c_{\\multconstr + 1}, \\ldots, c_{\\multconstr + 4}$,\n    honestly compute polynomials $\\p{r}(X, Y), \\p{r'}(X, Y), \\p{s}(X, Y)$ and\n    pick randomly challenges $y$, $z$.\n  \\item Output commitment $\\gone{r} \\gets \\com(\\srs, \\multconstr, \\p{r} (X,\n    1))$ and challenge $y$. \n  \\item Compute\n    \\begin{align*}\n      & a' = \\p{r}(z, 1),\\\\\n      & b' = \\p{r}(z, y),\\\\\n      & s' = \\p{s}(z, y).\n    \\end{align*} \n  \\item Pick polynomial $\\p{t}(X, Y)$ such that\n    \\begin{align*}\n      & \\p{t} (X, y) = \\p{r} (X, 1) (\\p{r}(X, y) + \\p{s} (X, y)) - \\p{k} (Y)\\\\\n      & \\p{t} (0, y) = 0\n    \\end{align*}\n  \\item Output commitment $\\gone{t} = \\com (\\srs, \\dconst, \\p{t} (X, y))$ and\n    challenge $z$.\n  \\item Continue following the protocol.\n  \\end{enumerate}\n\n  We note that the simulation is perfect. This comes since, except polynomial\n  $\\p{t} (X, Y)$ all polynomials are computed following the protocol. For\n  polynomial $\\p{t} (X, Y)$ we observe that in a case of both real and simulated\n  proof the verifier only learns commitment $\\gone{t} = \\p{t} (\\chi, y)$ and\n  evaluation $t' = \\p{t} (z, y)$. Since the simulator picks $\\p{t} (X, Y)$ such\n  that \n  \\begin{align*}\n      \\p{t} (X, y) = \\p{r} (X, 1) (\\p{r}(X, y) + \\p{s} (X, y)) - \\p{k} (Y)\n  \\end{align*}\n  Values of $\\gone{t}$ are equal in both proofs.\n  Furthermore, the simulator picks its polynomial such that $\\p{t}(0, y) = 0$,\n  hence it does not need the trapdoor to commit to it. (Note that the proof\n  system's SRS does not allow to commit to polynomials which have non-zero\n  constant term). \\qed\n\\end{proof}\n\\begin{remark} \n  As noted in \\cite{CCS:MBKM19}, $\\sonic$ is statistically subversion zero-knowledge (Sub-ZK). As noted in \\cite{AC:ABLZ17short}, one way to achieve\n  subversion zero-knowledge is to utilize an extractor that extracts a SRS\n  trapdoor from a SRS-generator. Unfortunately, a NIZK made subversion\n  zero-knowledge by this approach cannot achieve perfect Sub-ZK as one has to\n  count in the probability of extraction failure. However, with the simulation\n  presented in \\cref{lem:sonic_hvzk}, the trapdoor is not required for the\n  simulator as it is able to simulate the execution of the protocol just by\n  picking appropriate (honest) verifier's challenges. This result transfers to\n  $\\sonicprotfs$, where the simulator can program the random oracle to provide\n  challenges that fits it.\n\\end{remark}\n\n\n\\subsection{Simulation Extractability of $\\sonicprotfs$}\nSince \\cref{lem:sonicprot_ur,lem:sonicprot_ss,lem:sonic_hvzk} hold, $\\sonicprotfs$ is $\\ur{2}$, rewinding-based knowledge sound and trapdoor-less zero-knowledge. We now make use\nof \\cref{thm:se} and show that $\\sonicprotfs$ is simulation-extractable as defined in \\cref{def:simext}.\n\n\\begin{corollary}[Simulation extractability of $\\sonicprotfs$]\n  \\label{thm:sonicprotfs_se}\n  $\\sonicprotfs$ is \\emph{updatable simulation-extractable} against any $\\ppt$ adversary $\\advse$ who makes up to $q$ random oracle queries and returns an accepting proof with probability at least $\\accProb$ with extraction failure probability \n\\[\n  \\epsse(\\secpar, \\accProb, q) \\leq \\left(1 - \\frac{\\accProb - \\epsur (\\secpar) - (q + 1) \\epserr (\\secpar)} {1 - \\epserr (\\secpar)}\\right) + (\\noofc + 1) \\cdot \\epsuldlog (\\secpar) ,\n\\]\nwhere $\\epserr (\\secpar) = \\frac{\\noofc}{p}$, $p$ is the size of the field, and $\\noofc$ is the number of constrains in the circuit. \n\\end{corollary}\n\n%%% Local Variables:\n%%% mode: latex \n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "14bd00b33dd7d03bec8236f2593731f34c2f6fac", "size": 28590, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SCN2022/non-malleability-of-sfs.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SCN2022/non-malleability-of-sfs.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SCN2022/non-malleability-of-sfs.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.1689587426, "max_line_length": 904, "alphanum_fraction": 0.6589017139, "num_tokens": 9672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4341197992276145}}
{"text": "\\chapter{Introduction}\n\\label{cha:introduction}\n\nFor a machine to interact in an intelligent manner with its outside world, it needs to be\nequipped with suitable knowledge.  The very same is true for humans, and acquiring this\nknowledge is a highly complex task which up to today is not completely understood.  To\nhelp within this process, previously acquired knowledge is \\emph{represented} in different\nways, \\eg as books or films, to help others learning it.\n\nHowever, the way knowledge is represented for human consumption is almost always not\nsuitable for machines.  While humans can extract knowledge from natural language, which\nmay be full of ambiguity, machines require precise formulations of knowledge.  The\nrepresentation of knowledge in a machine-understandable way is the main focus of the area\nof \\emph{knowledge representation}~\\cite{KRhandbook}.\n\nOne of the most successful approaches to knowledge representations are description\nlogics~\\cite{DLhandbook}, a family of logic-based knowledge representation formalisms\nwith varying expressivity and reasoning complexity.  Description logics allow to represent\nknowledge as \\emph{knowledge bases}, or \\emph{ontologies}.  Essentially, these are\ncollections of axioms, which may be either \\emph{assertional} or \\emph{terminological}.\nFor example, to represent the fact (the \\emph{assertion}) that an individual \\textsf{tom}\nis a cat, one can use the assertional axiom\n\\begin{equation}\n  \\label{eq:14}\n  \\mathsf{Cat}(\\mathsf{tom}).\n\\end{equation}\nOn the other hand, to state the terminological knowledge that every cat hunts mice, one\ncan use so-called \\emph{general concept inclusions} (GCIs) and write\n\\begin{equation}\n  \\label{eq:15}\n  \\mathsf{Cat} \\sqsubseteq \\exists \\mathsf{hunts}. \\mathsf{Mouse}.\n\\end{equation}\nAs soon as a knowledge base is available, it is possible to \\emph{reason} with it, \\ie to\nextract knowledge from it that is implicitly contained.  For example, from the two axioms\nstated above, we can infer that the individual \\textsf{tom} hunts mice, although this has\nnever been stated explicitly.\n\nKnowledge bases can be used to represent knowledge in a machine-consumable way.  However,\nthe question arises how such knowledge bases can be obtained.  One way or the other,\nknowledge which is available to humans has to be translated into the form of a description\nlogic knowledge base.  Of course, this could be done by humans, but this approach would\nnot only be very time-consuming, but also prone to errors.  An automatic translation would\nthus be highly welcomed.  On the other hand, a completely automatic translation would just\nmean that machines can consume knowledge in the way humans represent it, an assumption\nwhich is not reasonable.\n\nHowever, one can still think about approaches which are \\emph{semi-automatic} in the sense\nthat the results obtained from such a translation are preliminary, requiring further\nrefinement, or that the translation procedure requires additional \\emph{assistance} by\nmeans of human experts.\n\nAn approach to achieve such a semi-automatic translation procedure, or \\emph{learning\n  procedure}, has been made in~\\cite{Diss-Felix}.  There, the focus lies on extracting\nterminological knowledge of the form as shown in \\Cref{eq:15} from some given \\emph{finite\n  interpretation} $\\mathcal{I}$.  More precisely, the procedures described\nin~\\cite{Diss-Felix} would automatically learn all GCIs which are \\emph{valid} in the data\nset $\\mathcal{I}$.  This approach makes use of the mathematical theory of \\emph{formal\n  concept analysis}, a subfield of mathematical order theory, which has very close\nconnections to description logics.\n\nOf course, the GCIs learned this way may not be correct, in the sense that the GCI may\nhold in $\\mathcal{I}$, but this data missed to contain some relevant counterexamples.  In\nthis case, we say that $\\mathcal{I}$ is \\emph{incomplete}.  One way to remedy this is to\nuse an algorithm from formal concept analysis called \\emph{attribute exploration}, and\ngeneralize it to the setting of GCIs.  Such a generalization, called \\emph{model\n  exploration}, has been discussed in~\\cite{Diss-Felix}.  Within this algorithm, an expert\n(possibly human) is asked for the correctness of extracted GCIs, and if such a GCI is not\ncorrect, the expert has to provide \\emph{counterexamples} for it.  This way, the problem\nof $\\mathcal{I}$ being incomplete can be solved.\n\nHowever, there are still problems with the original approach of~\\cite{Diss-Felix}, in\nparticular concerning the \\emph{quality} of the data $\\mathcal{I}$ from which GCIs are\nlearned.  The main problem here is that the data may contain \\emph{errors}.  These errors\nmay either cause otherwise valid GCIs not to be found, because these errors act as\n\\emph{false counterexamples}, or GCIs to be found which are not correct, because errors\ncause positive counterexamples to vanish.  While the latter approach can in theory be\nhandled by the attribute exploration approach sketched above, the former cannot, because\nthe approach discussed in~\\cite{Diss-Felix} will not even extract GCIs for which there may\nbe false counterexamples in $\\mathcal{I}$.\n\nIn this work, we want to extent the results obtained in~\\cite{Diss-Felix} to this new\nsetting of where the data $\\mathcal{I}$ may contain errors.  The main approach for this is\nto transfer the notion of \\emph{confidence}~\\cite{arules:agrawal:association-rules} from\nthe area of data-mining to GCIs.  Intuitively, this means that GCIs may have \\emph{few}\nerrors in the data, as opposed to having none in the original approach\nof~\\cite{Diss-Felix}.  The notion of \\enquote{few} is quantified by means of the\nconfidence of the GCIs in the data.\n\nIn the following, we shall give a more in-depth discussion of what we want to do in this\nwork.  To this end, we first shall introduce description logics and formal concept\nanalysis, in an exemplary and historic manner.  Thereafter, we shall discuss the main\nresults of~\\cite{Diss-Felix} in more detail, and also briefly mention some other related\nwork.  Finally, we present the main contributions of this work.\n\n\\section{Description Logics}\n\\label{sec:repr-knowl-using}\n\nDescription logics~\\cite{DLhandbook} are a family of logic-based knowledge representation\nformalisms, with a strong emphasis on well-defined semantics and practical reasoning\nprocedures.  The family of description logics contains various kinds of logical\nformalisms, varying in expressiveness and reasoning complexity, allowing users to choose\nthe expressiveness they need, or the complexity they can afford in their respective\napplications.\n\nThe development of description logics~\\cite{journals/sLogica/BaaderS01} was motivated by\nearlier knowledge representation formalisms like \\emph{semantic\n  networks}~\\cite{SemanticNetworks} or \\emph{frame}~\\cite{Minsky-Frames}, whose semantics\nwere highly ambiguous, and mostly depended on human interpretation or implementation\ndetails.  The need for well-defined and predictable knowledge representation formalisms\nthen led to the first logic-based systems~\\cite{journals/cogsci/BrachmanS85}, which\nhowever were incomplete~\\cite{conf/kr/Schmidt-Schauss89}.\n\nThe first description logics considered were relatively small fragments of first order\nlogic, and already for them it could be shown that reasoning is\nintractable~\\cite{conf/aaai/BrachmanL84,journals/ai/Nebel88}.  One approach to remedy this\nwas to investigate highly optimized reasoning algorithms, which behave well in practice.\nThe most prominent class of such algorithms are \\emph{tableau algorithms}.  These\nalgorithms were first invented for the description logic\n$\\ALC$~\\cite{journals/ai/Schmidt-SchaussS91,conf/ecai/HollunderNS90} for the subsumption\nproblem, and were thereafter extended to other, even more expressive logics.  After a\nconnection of $\\ALC$ to multimodal logic $\\mathsf{K}_{(\\mathsf{m})}$ was\ndiscovered~\\cite{DBLP:conf/ijcai/Schild91}, it was seen that this tableau algorithm is\nactually a re-invention of the tableau algorithms used in modal logics.  The development\nof description logics continued to investigate highly expressive description logics, whose\nexpressiveness exceeds that of $\\ALC$, but which still behave well in\npractice~\\cite{journals/igpl/HorrocksST00}, and for which highly-optimized implementations\nexist~\\cite{sirin_pellet:practical_2007,Haarslev:2001,DBLP:conf/cade/TsarkovH06}.  This\nfinally led to the adoption of the \\emph{Web Ontology Language OWL} by the W3C, which is\nbased on the highly expressive description logic\n$\\mathcal{S}\\mathcal{H}\\mathcal{O}\\mathcal{I}\\mathcal{N}$~\\cite{horrocks03fromshiqrdftoowl}.\n\nThe focus of description logics research departed from the sole focus on expressive\ndescription logics when, at the beginning of this millennium, it was discovered that for\nthe inexpressive description logic $\\EL$ reasoning is\ntractable~\\cite{DBLP:conf/ijcai/Baader03a,DBLP:conf/ecai/Brandt04}, and stays so when the\nexpressiveness of $\\EL$ is extended\nslightly~\\cite{DBLP:conf/ijcai/BaaderBL05,BaaderEtAl-OWLED08DC}.  A practical relevance of\nthese results is given by the fact that large biomedical ontologies can be reformulated as\n\\emph{description logic knowledge bases} (or \\emph{description logic ontologies}) using\n$\\EL$ or such slight extensions of it.  Examples for this are the \\emph{Systematized\n  Nomenclature of Medicine--Clinical Terms}, the Gene Ontology~\\cite{gene-ontology}, and\nlarge parts of the GALEN ontology~\\cite{Rector199475}.\n\nThe term \\enquote{description} in \\enquote{description logics} is motivated by the\nintention to use description logics to express knowledge about \\emph{concept\n  descriptions}.  For this, description logics provide a number of constructors, which can\nthen be used to build concept descriptions from atomic \\emph{concept names} and binary\n\\emph{role names}.  For example, the description logic $\\EL$ provides the constructors\n\\emph{conjunction} ($\\sqcap$) and \\emph{existential restriction} ($\\exists$).  Examples of\n$\\EL$ concept descriptions are\n\\begin{equation*}\n  \\mathsf{Cat},\\, \\mathsf{Cat} \\sqcap \\mathsf{Mouse},\\, \\exists \\mathsf{hunts}. \\mathsf{Mouse},\n\\end{equation*}\nwhere \\textsf{Cat}, \\textsf{Mouse} are concept names, and \\textsf{hunts} is a role name.\n\nA description logic knowledge base formulated in $\\EL$ consists, like most description\nlogic knowledge bases, of two parts, namely an \\emph{ABox}, holding assertional knowledge,\nand a \\emph{TBox}, containing terminological knowledge.  An example knowledge base is\n\\begin{equation*}\n  \\mathcal{K} = (\\set{ \\mathsf{Cat} \\sqsubseteq \\exists \\mathsf{hunts}. \\mathsf{Mouse} },\n  \\set{ \\mathsf{Cat}(\\mathsf{tom}) }),\n\\end{equation*}\nwhere the first entry denotes the TBox, and the second denotes the ABox.  The semantics of\nknowledge bases is defined using \\emph{interpretations} $\\mathcal{I}$, which can be\nthought of as directed edge- and vertex-labeled graphs.  The labels of the vertices, which\nwe shall call \\emph{elements} or \\emph{individuals}, are concept names, and the labels of\nthe edges are role names.  An interpretation is a model of a knowledge base if all\nelements \\emph{satisfy} the axioms contained in this knowledge base.  For example, the\ninterpretation\n\\begin{center}\n  \\begin{tikzpicture}\n    \\begin{scope}[\n      every node/.style = { draw, circle },\n      every label/.style = { draw = none, rectangle }\n      ]\n      \\node[label=above:{\\textsf{Cat}}] (Tom) {\\textsf{tom}};\n      \\node[label=above:{\\textsf{Mouse}}, right=2cm of Tom, inner sep = .1cm] (Jerry)\n      {\\textsf{jerry}};\n    \\end{scope}\n    \\path (Tom) edge[->, bend left=30] node[midway, above] {\\textsf{hunts}} (Jerry);\n    \\path (Jerry) edge[->, bend left=30] node[midway, below] {\\textsf{hunts}} (Tom);\n  \\end{tikzpicture}\n\\end{center}\nis a model of the knowledge base $\\mathcal{K}$, since the element \\textsf{tom} is labeled\n\\textsf{Cat}, and every element which is labeled with \\textsf{Cat} is connected to some\nelement labeled \\textsf{Mouse} via an edge labeled with \\textsf{hunts}.\n\nAs soon as one has a description logic knowledge base, one can conduct \\emph{reasoning}\nwith it, \\ie one can extract knowledge from the knowledge base that may be only contained\nin it implicitly.  Two classical reasoning problems are \\emph{instance checking} and\n\\emph{subsumption}: given an \\emph{individual name} $a$ and a concept description $C$, the\ninstance checking problem is to ask whether $a$ is an \\emph{instance} of $C$, \\ie whether\n$a$ satisfies the concept description $C$ in every interpretation.  The subsumption\nproblem is to ask, given two concept descriptions $C$ and $D$, whether it is true that $C$\nis a \\emph{subconcept} of $D$, \\ie whether it is true in every interpretation that every\nelement that satisfies $C$ also satisfies $D$.  Other reasoning problems are\n\\emph{knowledge base consistency} and \\emph{concept satisfiability}: a knowledge base is\nconsistent if it has a model, and a concept description $C$ is satisfiable with respect to\na given knowledge base $\\mathcal{K}$ if there exists a model of $\\mathcal{K}$ containing\nelements that satisfy $C$.  Deciding knowledge base consistency and concept satisfiability\ncan help to ensure the correctness of the given knowledge base.\n\n\\section{Formal Concept Analysis}\n\\label{sec:learn-impl-using}\n\nFormal concept analysis~\\cite{fca-book} is a subfield of mathematical order theory,\noriginally concerned with the study of properties of ordered structures called\n\\emph{complete lattices} by representing them in terms of so-called \\emph{formal\n  contexts}.  Since then, formal concept analysis has considerably broadened its scope,\nwith connections to previously unrelated subjects such as\nlogics~\\cite{books/math/Prediger00,conf/iccs/FerreR00}, data\nmining~\\cite{arules:Zaki:1998}, machine learning~\\cite{conf/icfca/Kuznetsov04}, and\nartificial intelligence~\\cite{phd/de/Rudolph2006,Diss-Felix}.  Because of this, formal\nconcept analysis today can be considered as a part of theoretical computer science, and\nthus it provides another link between computer science and mathematics.\n\nThe origin of formal concept analysis as it is used in this work can clearly be marked by\nthe work of Wille~\\cite{fca:Wille:1982}, which introduced formal concept analysis as an\napproach to impose meaning on complete lattices by considering them as \\emph{hierarchies\n  of concepts}.  This work was motivated by previous results from\nBirkhoff~\\cite{books/math/Birkhoff67}, but also has a strong philosophical\nbackground~\\cite{books/phil/Hentig72,Wille:Begriffsdenken}.  Another early work that\nincluded some of the ideas of formal concept analysis is~\\cite{OrdreEtClassification}.\n\n\\begin{figure}[tp]\n  \\centering\n  \\begin{math}\n    \\begin{array}[c]{c|*{7}{c}}\n      \\toprule\n      ~       & \\mathsf{small} & \\mathsf{medium} & \\mathsf{large} & \\mathsf{inner} &\n      \\mathsf{outer} & \\mathsf{moon} & \\mathsf{no moon} \\\\\n      \\midrule\n      \\mathsf{Mercury} & \\times &   &   & \\times &   &   & \\times  \\\\\n      \\mathsf{Venus}   & \\times &   &   & \\times &   &   & \\times  \\\\\n      \\mathsf{Earth}   & \\times &   &   & \\times &   & \\times &    \\\\\n      \\mathsf{Mars}    & \\times &   &   & \\times &   & \\times &    \\\\\n      \\mathsf{Jupiter} &   &   & \\times &   & \\times & \\times &    \\\\\n      \\mathsf{Saturn}  &   &   & \\times &   & \\times & \\times &    \\\\\n      \\mathsf{Uranus}  &   & \\times &   &   & \\times & \\times &    \\\\\n      \\mathsf{Neptune} &   & \\times &   &   & \\times & \\times &    \\\\\n      \\mathsf{Pluto}   & \\times &   &   &   & \\times & \\times &    \\\\\n      \\bottomrule\n    \\end{array}\n  \\end{math}\n  \\caption{Example Formal Context (taken from~\\cite{fca:Wille:1982})}\n  \\label{fig:example-formal-context}\n\\end{figure}\n\nThe fundamental idea of formal concept analysis is to represent complete lattices by an\n\\emph{object-attribute-relationship}, which is expressed using \\emph{formal contexts}.\nThese structures can be thought of as \\emph{tables of crosses}.  An example of a formal\ncontext is depicted in \\Cref{fig:example-formal-context}.  This example formal context\nexpresses an object-attribute-relationship between the \\emph{objects} being the known\nplanets of the solar system (including Pluto), and the \\emph{attributes} being certain\nproperties of these planets, like their size (\\textsf{small}, \\textsf{medium}, or\n\\textsf{large}), their distance from the sun (being an \\textsf{inner} or \\textsf{outer}\nplanet, \\ie having an orbit which is closer to the sun than the asteroid belt or not), and\nif they do or do not have a \\textsf{moon}.  A cross in this table then means that the\nobject on the corresponding row \\emph{has} the attribute on the corresponding column.\nThus, for example, \\textsf{Mercury} is a \\textsf{small} planet, and \\textsf{Pluto} is an\n\\textsf{outer} planet.  The set of all pairs of objects $g$ and attributes $m$ where $g$\nhas the attribute $m$ is called the \\emph{incidence relation} of the formal context.\n\nFormally, a \\emph{formal context} $\\con K$ can be defined as a triple $\\con K = (G, M,\nI)$, where $G$ and $M$ are sets and $I \\subseteq G \\times M$.  $G$ is then called the set\nof \\emph{objects}, $M$ is called the set of \\emph{attributes}, and the set $I$ is called\nthe \\emph{incidence}.  An object $g \\in G$ \\emph{has} an attribute $m \\in M$ in $\\con K$\nif and only if $(g, m) \\in I$.\n\nFrom such a formal context one can then extract \\emph{formal concepts}, which can be\nordered in a natural way to yield the \\emph{concept lattice} of the formal context.  In\nour example above, a formal concept which corresponds to the concept of a\n\\emph{medium-sized planet in our known solar system} would be the tuple\n\\begin{equation}\n  \\label{eq:60}\n  ( \\set{ \\mathsf{Uranus}, \\mathsf{Neptune} }, \\set{ \\mathsf{medium}, \\mathsf{moon},\n    \\mathsf{outer} } ),\n\\end{equation}\nwhere the first set is called the \\emph{extent}, and the second set is called the\n\\emph{intent} of the formal concept.\n\nFormal concepts can then be ordered by set-inclusion of their extents, and it can be shown\nthat the thus-obtained ordered set is a complete lattice, the \\emph{concept lattice} of\nthe formal context.  The concept lattice that corresponds to our small example above is\nshown in \\Cref{fig:example-concept-lattice}.  This diagram also uses the usual, abridged\nannotation of concept lattices: a node $v$ in the lattice diagram represents the formal\nconcept whose extent consists of all objects which can be reached by an \\emph{descending\n  path} in the diagram, starting from $v$.  Likewise, the intent of $v$ is the set of all\nattributes that can be reached by an \\emph{ascending path} in the diagram, starting from\n$v$.  Thus, the gray-shaded node in \\Cref{fig:example-concept-lattice} is the formal\nconcept of \\Cref{eq:60}.\n\n\\begin{figure}[tp]\n  \\tikzset{vertexbase/.style={semithick, shape=circle, inner sep=2pt, outer sep=0pt, draw},%\n    vertex/.style={vertexbase},%\n    mivertex/.style={vertexbase},%\n    jivertex/.style={vertexbase},%\n    divertex/.style={vertexbase},%\n    conn/.style={-, thick}%\n  }\n  \\begin{center}\n    \\begin{tikzpicture}\n      \\begin{scope}[xscale=.7] %for scaling and the like\n        \\begin{scope} %draw vertices\n          \\foreach \\nodename/\\nodetype/\\xpos/\\ypos in {%\n            0/vertex/2/4,\n            1/divertex/-4/7,\n            2/jivertex/0/7,\n            3/divertex/8/7,\n            5/jivertex/4/7,\n            6/mivertex/-2/8,\n            7/vertex/2/8,\n            8/mivertex/6/8,\n            9/mivertex/0/9,\n            10/mivertex/4/9,\n            11/vertex/2/10\n          } \\node[\\nodetype] (\\nodename) at (\\xpos, \\ypos) {};\n          \\node[divertex,fill=black!30] (4) at (6,7) {};\n        \\end{scope}\n        \\begin{scope} %draw connections\n          \\path (7) edge[conn] (10);\n          \\path (9) edge[conn] (11);\n          \\path (5) edge[conn] (8);\n          \\path (1) edge[conn] (6);\n          \\path (0) edge[conn] (4);\n          \\path (0) edge[conn] (3);\n          \\path (8) edge[conn] (10);\n          \\path (5) edge[conn] (7);\n          \\path (6) edge[conn] (9);\n          \\path (2) edge[conn] (7);\n          \\path (0) edge[conn] (1);\n          \\path (3) edge[conn] (8);\n          \\path (2) edge[conn] (6);\n          \\path (10) edge[conn] (11);\n          \\path (7) edge[conn] (9);\n          \\path (4) edge[conn] (8);\n          \\path (0) edge[conn] (2);\n          \\path (0) edge[conn] (5);\n        \\end{scope}\n        \\begin{scope}[every label/.style={font=\\sffamily, inner sep=1pt, fill opacity=.9,\n            text opacity=1, fill=white, label distance=4pt}] %add labels\n          \\foreach \\nodename/\\labelpos/\\labelopts/\\labelcontent in {%\n            1/below left//{\\parbox{1.4cm}{Mercury\\\\ Venus}},\n            1/above left//{no-moon},\n            2/below//{\\parbox{2cm}{\\centering Mars\\\\ Earth}},\n            3/below right//{\\parbox{2cm}{Jupiter\\\\ Saturn}},\n            3/above right//{large},\n            4/below//{\\parbox{1.4cm}{\\centering Uranus\\\\ Neptune}},\n            5/below//{Pluto},\n            6/above left//{inner},\n            8/above right//{outer},\n            9/above left//{small},\n            10/above right//{moon}\n          } \\node[draw=none,label={[\\labelopts]\\labelpos:{\\labelcontent}}] at (\\nodename) {};\n          \\node[draw=none,label={[label distance=1pt]above:medium}] at (4) {};\n        \\end{scope}\n      \\end{scope}\n    \\end{tikzpicture}\n  \\end{center}\n  \\caption{Example Concept Lattice}\n  \\label{fig:example-concept-lattice}\n\\end{figure}\n\nOne of the key results of formal concept analysis is that every complete lattice can be\nrepresented as a concept lattice of a suitably chosen formal context (this is the\nso-called \\emph{fundamental theorem of formal concept analysis}).  A major direction of\nformal concept analysis research is to consider properties and operations of lattices,\nsuch as \\emph{distributivity}, \\emph{modularity}, \\emph{direct} and \\emph{semi-direct\n  products}, and transfer them to corresponding properties and operations on the level of\nformal contexts.  See~\\cite{fca-book} for more details on this.\n\nAnother very prominent research direction in formal concept analysis is the study of\n\\emph{implications} in formal contexts, which has been discussed as early\nas~\\cite{fca:Wille:1982}.  Observe that in our example formal context above, all outer\nplanets have a moon.  We can express this fact as saying that the implication\n\\begin{equation*}\n  \\set{ \\mathsf{outer} } \\to \\set{ \\mathsf{moon} }\n\\end{equation*}\n\\emph{holds} in our formal context.  Implications are similar to \\emph{functional\n  dependencies} from the theory of databases~\\cite{DBLP:books/cs/Maier83}, and also play a\ncertain role in classical order theory~\\cite{Wild1994118}.\n\nOne task is to compute the set of all valid implications of a given formal context.  Since\nthis set can be quite large, one usually wants to compute \\enquote{small} sets of\nimplications which are sufficient, called \\emph{bases}.  One very prominent base is the\nso-called \\emph{canonical base}~\\cite{fca:DuquenneGuigues:1986} (also \\emph{stem base},\n\\emph{Duquenne-Guigues base}), which is a \\emph{minimal} base, \\ie a base with minimal\ncardinality.  This base can be computed\neffectively~\\cite{DBLP:conf/icfca/Ganter10,DBLP:journals/amai/ObiedkovD07}, however these\nalgorithms are not efficient~\\cite{DBLP:conf/icfca/Distel10} with respect to the size of\nthe input and the output.  Certain complexity results suggest that efficiently computing\nthe canonical base is not possible in general~\\cite{DBLP:journals/dam/BabinK13}.  However,\nif this is really the case is an open research question.  Therefore, other bases have been\ninvestigated, whose computation is algorithmically easier.  An example is the base of\n\\emph{proper premises}~\\cite{fca-book}, for which fast algorithms\nexist~\\cite{RyDiBo-AMAI13}.\n\nAn algorithm that is related to the study of valid implications of formal contexts is\n\\emph{attribute exploration}~\\cite{fca-book,GORS-book}, which is an interactive process\nwhich extracts valid implications from \\emph{incomplete} data utilizing \\emph{expert\n  interaction} to obtain missing facts.  Within this process, an external expert is asked\nquestions of the form\n\\begin{equation*}\n  \\text{Is the implication } A \\to B \\text{ valid?}\n\\end{equation*}\nThe expert then can either accept this implication, or decline it by providing a\n\\emph{counterexample}.  In this way, the expert enriches the currently known formal\ncontext by missing objects and their attributes.  As soon as the process finishes, the set\nof confirmed implications represents the whole implicational knowledge represented by the\nexpert.  Moreover, it can be shown that the set of confirmed implications is the canonical\nbase of the formal context which consists of the initially known objects together with all\ncounterexamples provided by the expert.  In this way, attribute exploration can be seen as\na semi-automatic knowledge acquisition algorithm.\n\nAttribute exploration has been a major focus of formal concept analysis research, and many\nextensions of this algorithm have been developed and discussed.  Examples for this are the\ninclusion of \\emph{background\n  knowledge}~\\cite{stumme96attribute,DBLP:journals/tcs/Ganter99}, \\emph{concept\n  exploration}~\\cite{conf/iccs/Stumme97}, \\emph{rule\n  exploration}~\\cite{phd/de/Zickwolff1991}, \\emph{relational\n  exploration}~\\cite{phd/de/Rudolph2006}, exploration in the presence of \\emph{partial\n  knowledge}~\\cite{book/fca/BurmeisterH05,conf/ijcai/BaaderGSS07}, and \\emph{model\n  exploration}~\\cite{Diss-Felix}.\n\n\\section{Extracting Terminological Knowledge from Relational Data}\n\\label{sec:extr-term-knowl}\n\nThe main purpose of this work is to discuss a way to extract general concept inclusions\nfrom interpretations which are allowed to contain errors.  The basis for our\nconsiderations are the results obtained by Baader and\nDistel~\\cite{Diss-Felix,BaDi09,BaaderDistel08} on computing \\emph{finite bases} of\n\\emph{valid} GCIs from finite interpretations.  In the following, we shall briefly\nsummarize the main results of this approach.\n\nThe goal of the work by Baader and Distel is to learn terminological knowledge about a\ncertain \\emph{domain} of interest.  For this we assume that we can represent this domain\nas a finite interpretation $\\mathcal{I}$, \\ie our domain is representable as relational\ndata.  The terminological knowledge we are then interested in is the set\n$\\Th(\\mathcal{I})$ of valid GCIs of $\\mathcal{I}$, using the description logic $\\ELbot$.\n\nA first problem here is that the set $\\Th(\\mathcal{I})$ is infinite in general: if $C\n\\sqsubseteq D$ is valid in $\\mathcal{I}$, and if $r$ is a role name, then the GCI $\\exists\nr. C \\sqsubseteq \\exists r. D$ is also valid in $\\mathcal{I}$.  To remedy this, Baader and\nDistel compute \\emph{finite bases} of $\\Th(\\mathcal{I})$, \\ie finite subsets $\\mathcal{B}$\nof $\\Th(\\mathcal{I})$ which are already \\emph{complete} for $\\mathcal{I}$.  In other\nwords, finite bases $\\mathcal{B}$ are finite sets of valid GCIs of $\\mathcal{I}$, such\nthat every GCI valid in $\\mathcal{I}$ is already entailed by $\\mathcal{B}$.  One of the\nmain results of their approach is that such finite bases always exist, and that they can\nbe computed effectively.\n\nTo provide these results, Baader and Distel exploit the tight connection between the\ndescription logic $\\ELbot$ and formal concept analysis, established by \\emph{model based\n  most specific concept descriptions} and \\emph{induced formal contexts} of finite\ninterpretations and sets of concept descriptions.  More precisely, it can be shown that if\n$\\con K_{\\mathcal{I}}$ denotes the induced formal context of $\\mathcal{I}$, then every\nbase of $\\con K_{\\mathcal{I}}$ gives rise to a finite base of $\\mathcal{I}$.  A technical\nproblem that arises here is that model-based most-specific concept descriptions are not\nnecessarily expressible in the description logic \\ELbot.  Because of this, Baader and\nDistel consider the description logic \\ELgfpbot, an extension of \\ELbot by \\emph{cyclic\n  concept descriptions} using \\emph{greatest fixpoint semantics}.\n\nThe resulting algorithms for computing bases of finite interpretations are all effective.\nA preliminary implementation with applications to linked data has been presented\nin~\\cite{DBLP:conf/icdm/BorchmannD11}.\n\nAn additional issue addressed by Baader and Distel is the fact that the interpretation\n$\\mathcal{I}$ may be \\emph{incomplete}, \\ie certain facts from the domain of interest may\nnot be represented in it.  The GCIs which are valid in $\\mathcal{I}$ may not necessarily\nbe valid in the domain of interest.  This problem is very similar to the problem solved by\nattribute exploration, and indeed it can be shown that attribute exploration applied to\nthe context $\\con K_{\\mathcal{I}}$ can be transferred into an algorithm for \\emph{model\n  exploration} of $\\mathcal{I}$.  This algorithm then allows to interactively compute\nbases of $\\mathcal{I}$, allowing an expert to provide missing facts when required.  In\nthis way, learning GCIs which are invalid in the domain of interest can be avoided.\n\n\\section{Other Related Work}\n\\label{sec:related-work}\n\nThe work of Baader and Distel is not the first attempt to bring together the worlds of\ndescription logics and formal concept analysis.  Indeed, there have been several previous\nattempts to utilize formal concept analysis for description logic applications, and to add\nideas from description logics to notions of formal concepts analysis.\n\nOne of the first results in description logics that utilizes formal concept analysis is\nthe work of Baader~\\cite{Baader-KRUSE-95}.  In this work, Baader uses the attribute\nexploration algorithm on a special formal context to compute a minimal representation of\nthe subsumption hierarchy between all conjunctions of the defined concept names of a given\nacyclic TBox $\\mathcal{T}$ formulated in the logic $\\ALC$.  To this end, Baader extends\nthe classical tableau algorithm for \\ALC to decide subsumption between \\emph{single}\ndefined concept names~\\cite{journals/ai/Schmidt-SchaussS91}, and extends it in such a way\nthat it provides counterexamples to instances of the subsumption problem.  These\ncounterexamples are then collected into a suitable formal context, and from this context\nthe attribute exploration algorithm eventually computes the canonical base.  These\nimplications give rise to a set of GCIs, which can then be used to decide subsumption\nbetween conjunctions of defined concept names of $\\mathcal{T}$.\n\nThe results obtained by Baader have been further generalized by\nStumme~\\cite{stumme96concept} to also include disjunction.  For this, a generalization of\nattribute exploration called \\emph{distributive concept\n  exploration}~\\cite{conf/ki/Stumme98} has been used.\n\nAnother use of formal concept analysis for description logic applications is in\n\\emph{knowledge base completion}~\\cite{Sert07,conf/ijcai/BaaderGSS07}, for which again\nattribute exploration was used.  For this, the expert is asked GCIs of the form\n\\begin{equation*}\n  \\bigsqcap U \\sqsubseteq \\bigsqcap V,\n\\end{equation*}\nwhere $U, V \\subseteq M$ for some previously chosen set $M$ of \\emph{interesting\n  concepts}.  The goal is then to ensure the given knowledge base is complete with respect\nto all these GCIs, \\ie the knowledge base should entail all such GCIs which are confirmed\nby the expert, and should contain counterexamples for all other GCIs of the above type.\nThe greatest challenge for transferring attribute exploration to this setting is to deal\nwith the \\emph{open world semantics} of description logic knowledge bases: if a fact is\nnot entailed by the knowledge base, then this does not mean that the negated fact holds.\nFor this, attribute exploration is generalized to work on \\emph{partial contexts}, \\ie\nformal contexts in which certain crosses are unknown.  The resulting algorithm has been\nimplemented as a plugin named \\emph{OntoComp} for the ontology editor\n\\emph{Protégé}~\\cite{conf/esws/Sertkaya09}.\n\nA third prominent application of ideas of formal concept analysis in description logics is\nthe work of Rudolph on \\emph{relational\n  exploration}~\\cite{phd/de/Rudolph2006,conf/iccs/Rudolph04}.  In this approach the target\ndescription logic is \\FLE, the extension of \\EL by value restriction ($\\forall$).  The\ndomain of interest is not represented as an interpretation, but by means of \\emph{binary\n  power context families}~\\cite{DBLP:conf/iccs/PredigerW99}, which however can easily be\nconsidered as an interpretation.  Then the exploration process is conducted in several\nphases: in phase $k$, concept descriptions with \\emph{role depth} at most $k$ are\nconsidered as attributes of the current formal context, and on this formal context\nattribute exploration is performed.  Rudolph then shows that this process has to be\nconsidered only up to a certain maximal role depth, and that the resulting set of\nimplications can be used to decide whether an arbitrary GCI $C \\sqsubseteq D$ is valid or\nnot in the domain represented by the expert.  However, it is not shown whether and how\nthis set of implications can be transferred into a base of the domain.  Indeed, the\ndecision procedure for checking whether $C \\sqsubseteq D$ holds in the domain or not is\nrather complicated.  Thus, no GCIs are learned from this approach, and thus it cannot be\nused to obtain terminological knowledge from relational data.\n\nThe aforementioned approach of \\emph{power context families} is an attempt to add\ndescription logic expressibility to the world of formal concept analysis.  In its easiest\nform a formal context is equipped with a family of relations $\\mathcal{R}$ on the object\nset to obtain a \\emph{relational context}.  Based on this notion, \\emph{terminological\n  attribute logic}~\\cite{books/math/Prediger00} has been introduced that allows to define\nnew attributes in terms of old ones, using the relational context to extend the incidence\nrelation to the newly defined attributes.  With this semantics, terminological attribute\nlogic can be seen as a syntactic variant of \\ALC extended by inverse roles, negated roles\nand the identity role.  Terminological attribute logic can also be defined for\n\\emph{many-valued contexts} to provide a method for \\emph{logical\n  scaling}~\\cite{conf/krdb/PredigerS99}, which transforms many-valued contexts into the\nusual (two-valued) formal contexts in another way as the usual scaling approach of formal\nconcept analysis.\n\nAnother approach to bring a flavor of description logics to formal concept analysis is\n\\emph{relational concept analysis}~\\cite{conf/icfca/RouaneHNV07,\n  journals/amai/HaceneHNV13}.  The basic structure in this approach is a \\emph{relational\n  context family}, which consists of a family of formal contexts and a set of relations\nbetween objects of possibly different contexts of this family.  Using a method called\n\\emph{relational scaling} new attributes $r : C$ are added to the formal contexts, which\nroughly correspond to concept descriptions of the form $\\forall r. C$ or $\\exists r. C$,\nwhere however $C$ is now a formal concept of a formal context of the family.  In an\niterative process, relational scaling is used to construct lattices from all formal\ncontexts of the relational context family.  These lattices can then be used to derive\nassertional and terminological knowledge formulated in the description logic \\FLE.\n\nOther research that is related to this work are approaches in formal concept analysis and\ndescription logics to tackle the problem of \\emph{uncertainty} and \\emph{vagueness}.  In\nthe area of formal concept analysis, the most notable and relevant work is the one by\nLuxenburger~\\cite{diss:Luxenburger,Luxenburger91}, who considers implications in formal\ncontexts together with an \\emph{accuracy} (confidence).  Luxenburger then studies the\nproblem of \\emph{realizations} of partial implications, which in terms of logic is just\nthe question whether a set of partial implications is satisfiable.  The results obtained\nhere give a characterization in terms of \\emph{linear programs}.  Furthermore, he studies\nthe problem of finding \\emph{bases} of partial implications, and we shall use the main\nideas in our later considerations.  Luxenburger's ideas have been used in the area of data\nmining, for instance to obtain smaller representations of \\emph{association\n  rules}~\\cite{DBLP:conf/ki/StummeTBPL01}.\n\nAnother prominent approach to handle knowledge that may not be completely correct is to\nconsider fuzzy extensions of the respective formalisms.  Those exist for both description\nlogics~\\cite{journals/fss/BobilloS09,journals/ws/LukasiewiczS08} and formal concept\nanalysis~\\cite{Pollandt97b,conf/cla/BelohlavekV05}, and are either based on Zadeh's\noriginal approach to fuzzy logics~\\cite{journals/iandc/Zadeh65}, or on the approach by\nHájek~\\cite{hajek1998metamathematics}, in which the semantics is defined using\n\\emph{t-norms} on lattices.  In both cases, logical facts (implications, assertional\nknowledge, terminological knowledge) are annotated with \\emph{truth values} from an\nunderlying lattice, and the semantics then allows to infer truth values for previously\nunknown facts, or at least bounds thereof.\n\nFinally, a completely different approach to learning terminological knowledge has been\ndeveloped recently~\\cite{conf/dlog/KonevLW13}, based on a general framework of \\emph{query\n  learning} proposed by~\\cite{journals/ml/Angluin87}.  In contrast to the work by Baader\nand Distel, this approach tries to learn TBoxes $\\mathcal{T}$ by posing queries to an\n\\emph{oracle}.  These queries are either \\emph{entailment queries}, in which the oracle\nhas to decide whether a proposed GCI is entailed by the TBox $\\mathcal{T}$ to be learned,\nor \\emph{equivalence queries}, where the oracle has to decide whether a given TBox is\nequivalent to $\\mathcal{T}$.  The work~\\cite{conf/dlog/KonevLW13} then considers\nthe question for which description logic the TBox $\\mathcal{T}$ can be learned in\npolynomial time.  In particular, it is shown that if $\\mathcal{T}$ is an \\emph{acyclic\n  \\EL-TBox}, then it cannot be learned in polynomial time.\n\nNote that entailment queries are similar to the questions proposed to an expert during\nattribute exploration.  In fact, it is possible to show that a certain special case of\nquery learning~\\cite{journals/ml/AngluinFP92} can be used to obtain an alternative\ncomputation of the canonical base~\\cite{journals/ml/AriasB11}.\n\n\\section{Contributions}\n\\label{sec:contributions}\n\nThe main contributions of this thesis are the following.\n\n\\subsection{Experiments with Extracting Valid GCIs}\n\\label{sec:exper-with-extr}\n\nAll results obtained by Baader and Distel are \\emph{effective}, meaning that the resulting\nalgorithms can be implemented and applied to relational data.  As a first contribution of\nthis work, we shall present an implementation of these algorithms in\n\\Cref{sec:computing-bases-from}.  We then apply this implementation to relational data\nfrom the \\emph{DBpedia project}~\\cite{DBpedia}, which obtains its data by crawling\n\\emph{infoboxes} of Wikipedia articles.  We shall see that the approach by Baader and\nDistel indeed is able to extract terminological knowledge from this data, and we shall\ndiscuss the corresponding outcome in detail.\n\nThe main observation of these experiments however is that the errors in the DBpedia data\nset inhibit GCIs from being found which otherwise would be relevant for the domain of the\nchosen data.  The main example is that the GCI\n\\begin{equation*}\n  \\exists \\mathsf{child}. \\top \\sqsubseteq \\mathsf{Person}\n\\end{equation*}\nstating the fact that every individual which has a child is a person, was not found during\nour experiments.  The reason for this is that input data contained four counterexamples\nfor this GCI, which however were all erroneous.  On the other hand, the input data\ncontained 2547 \\emph{positive examples} for this GCI.  This shows that the original\napproach of Baader and Distel is very sensitive to errors in the input data, even if they\nare comparably rare.\n\n\\subsection{Extracting GCIs with High Confidence from Erroneous Data}\n\\label{sec:extracting-gcis-from}\n\nA main result from our experiments is that errors in the input data can inhibit otherwise\nvalid GCIs from being extracted.  On the other hand, we can assume that the input data\nmust be of sufficient \\emph{quality} to reasonably extract terminological knowledge from\nit, \\ie must not contain too many errors which are relevant for our computations.  Based\non this assumption we generalize the approach by Baader and Distel from computing bases of\nvalid GCIs to computing bases of GCIs which are \\emph{almost valid} in the input data.  To\nformalize the notion of being \\emph{almost valid}, we make use of the notion of\n\\emph{confidence} as it is used in data-mining, and transfer it to the setting of GCIs.\nInstead of computing bases of valid GCIs, we then want to compute bases of GCIs whose\nconfidence is above a certain threshold $c$, for some chosen value $c \\in [0,1]$.  Those\nGCIs we shall call GCIs \\emph{with high confidence}.  We shall see that we can generalize\nmost of the results of Baader and Distel accordingly, using Luxenburger's ideas on his\ninvestigation of partial implications in formal contexts.  An example for such a result is\nthe fact that bases of the induced context of a finite interpretation give rise to a base\nof the finite interpretation itself.  We shall see that we can generalize this result to\nobtain that bases of implications with high confidence in the induced context give rise to\nbases of GCIs with high confidence in the finite interpretation.  Finally, we shall apply\nour results to the data sets we used for our experiments, to show that our approach is\nable to handle certain errors in the input data.\n\n\\subsection{Exploration by Confidence}\n\\label{sec:expl-conf-2}\n\nThe approach of considering GCIs with high confidence is a purely heuristic one: by\nconsidering GCIs with high confidence, we can ignore rare errors in the input data.\nHowever, our approach ignores \\emph{rare counterexamples} as well, \\ie counterexamples\nwhich are actually valid, but occur so infrequently that the confidence measures ignores\nthem.  In this case, an external source of information is needed that can distinguish\nbetween errors and rare counterexamples in the data.  An example for such an external\nsource of information could be a human expert, who then considers all such counterexamples\nmanually, and decides whether they are valid or not.\n\nExpert interaction can also be used to tackle another problem with data, namely its\n\\emph{incompleteness}: for certain GCIs relevant counterexamples may exist in the domain\nof interest, but may not be present in the given data set.  In other words, we still\nassume that our domain is represented by an interpretation, the so-called \\emph{background\n  interpretation}, but we only have access to some part of it.  In this case, both the\noriginal approach by Baader and Distel, as well as our extension to GCIs with high\nconfidence would extract those GCIs for which relevant counterexamples are missing.  We\ncould use the external expert to avoid this issue, by querying this expert for possible\ncounterexamples from the background interpretation for all GCIs we would extract.\n\nThis expert interaction may be expensive, however, and an algorithm that keeps this\ninteraction to a minimum would be highly desirable.  In the case of valid implications of\na formal context, the attribute exploration algorithm would be such an algorithm, as it\nasks the expert a minimal number of different questions.  Therefore, we want to generalize\nattribute exploration to the setting of GCIs with high confidence to obtain an algorithm\nthat allows the use of an expert to distinguish between errors and rare counterexamples.\n\nAs a first step, we shall consider the easier problem of exploring \\emph{implications with\n  high confidence} instead of GCIs.  In this step, we shall generalize attribute\nexploration to \\emph{exploration by confidence}, where the algorithm not only asks the\nexpert after implications which are valid in the current context, but also after those\nwhich only have high confidence.  For this, we first investigate generalizations of\nattribute exploration which allow us to explore \\emph{sets of implications}.  In these\ngeneralizations, a set $\\mathcal{L}$ of implications can be specified for which the expert\nshould decide which elements of $\\mathcal{L}$ are valid.  In attribute exploration, the\nset $\\mathcal{L}$ is just the set of all valid implications of a given formal context.\nFor the case of implications with high confidence, the set $\\mathcal{L}$ is then just the\nset of all implications whose confidence is above a certain threshold $c$.\n\n\\subsection{Model-Exploration by Confidence}\n\\label{sec:model-expl-conf}\n\nThe problem of incomplete data already arises in the case of valid GCIs, and to approach\nthis problem Baader and Distel propose extensions of attribute exploration which also work\nwith valid GCIs.  One of these extensions, called \\emph{model exploration}, works mostly\nin the same way as attribute exploration does, with the difference that the expert now\ngets asked GCIs for confirmation instead of implications.  Model exploration is\nessentially attribute exploration of the induced context of the given interpretation,\nalthough several technical problems have to be dealt with.\n\nOne of these problems it that the attribute set of the induced context depends on the\nbackground interpretation.  Clearly, the background interpretation is not available during\nthe exploration process.  Model exploration solves this problem by computing the set of\nattributes of the induced context incrementally during the computation.  Another problem\nis the way counterexamples have to be specified: because of the \\emph{closed world\n  semantics} of interpretations, every counterexample provided by the expert has to be\n\\emph{complete}.  This means that as soon as the expert wants to provide an element as a\ncounterexample, all element which can be reached via directed edges from this elements in\nthe background interpretation have to be provided as well.  In other words, the\ncounterexamples provided by the expert have to be \\emph{connected subinterpretations} of\nthe background interpretation.\n\nTo generalize model exploration to GCIs with high confidence, we essentially follow the\nargumentation of model exploration.  More precisely, we shall consider exploration by\nconfidence of the induced context of the given interpretation, and transform it to\n\\emph{model exploration by confidence}, in a very similar way as model exploration arises\nfrom attribute exploration of the induced context.\n\nA notable difference to the argumentation of Baader and Distel is that we first have to\ngeneralize our results about computing bases of GCIs with high confidence to include the\npossibility that certain elements of the interpretation are \\emph{trusted}, in the sense\nthat as soon as a trusted element is a counterexample for some GCI, this GCI is not\nconsidered any further, even if its confidence is high enough.  The motivation for this\ngeneralization stems from the fact that we consider all counterexamples provided by the\nexpert as valid.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../main\"\n%%% End: \n\n%  LocalWords:  Protégé OntoComp\n", "meta": {"hexsha": "627b1864110d813fbd4ce6ff31bdfd84a6b72b03", "size": 47360, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/introduction.tex", "max_stars_repo_name": "exot/thesis", "max_stars_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/introduction.tex", "max_issues_repo_name": "exot/thesis", "max_issues_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/introduction.tex", "max_forks_repo_name": "exot/thesis", "max_forks_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.8274932615, "max_line_length": 95, "alphanum_fraction": 0.7684543919, "num_tokens": 12143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4341071837722207}}
{"text": "\\subsection{Random Two Peasants}\n\\subsubsection{Description of the Algorithm}\nThe main idea for the random two peasants algorithm is to sort the points along\na axis. The algorithm start from a random 2d point cloud \\fref{rtp:base}\n\n\\begin{enumerate}\n  \\item sort all points along the x-axis.\n  \\item use the line \\fref{rtp:line} from lowest point to greatest point\n    on x-axis to divide the points in a upper \\fref{rtp:upper} and a lower\n    \\fref{rtp:lower} point cloud.\n  \\item add sequential all points from the upper list to the polygon\n    \\fref{rtp:polygon-upper}\n  \\item add in reverse order all points from the lower list to the\n    polygon \\fref{rtp:polygon}\n\\end{enumerate}\n\n\\subsubsection{Implementation description}\n\n\\begin{enumerate}\n  \\item the function std::sort from the std lib does the sorting\n  \\item iterate over all points and perform the CGAL::orientation function to\n    get the orientation of all points aligned at the line between the lowest\n    point and the highest point.\n  \\item iterate over all points from the upper list and add it to the polygon\n  \\item iterate over all points from the lower list in reverse direction and add\n    it to the polygon.\n\\end{enumerate}\n\n\\subsubsection{Complexitiy}\n\n\\begin{enumerate}\n  \\item sort all points along the x-axis. $\\bigO(nlogn)$\n  \\item use the line from lowest point to greatest point on x-axis to divide the\n    points in a upper and a lower point cloud. $\\bigO(n)$\n  \\item add sequential all points from the upper list to the polygon $\\bigO(n)$\n  \\item add in reverse order all points from the lower list to the polygon $\\bigO(n)$\n\\end{enumerate}\n\nThis leads to $max(\\bigO(nlogn) + \\bigO(n) + \\bigO(n) + \\bigO(n) \\Rightarrow \\bigO(nlogn))$.\n\n\\subsubsection{Parameters}\n\\begin{description}\n  \\item [--nodes] how many nodes the polygon has to have. [default: 100]\n  \\item [--sampling-grid] the area within the polygon could grow. [default: 1500x800]\n\\end{description}\n\n\\subsubsection{Examples}\n\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n    \\end{tikzpicture}\n    \\caption{Base random point cloud}\n    \\label{fig:rtp:base}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[blue] (1) -- (12);\n    \\end{tikzpicture}\n    \\caption{Dividing Line}\n    \\label{fig:rtp:line}\n  \\end{minipage}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(5,40),(10,20),(20,18),(20,41),(33,15),(39,22),(60,50),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\foreach \\p in {(21,10),(48,9),(55,17)} {\n        \\node[point, fill=red] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[blue] (1) -- (9);\n    \\end{tikzpicture}\n    \\caption{Lower List}\n    \\label{fig:rtp:lower}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(21,10),(48,9),(55,17),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\foreach \\p in {(5,40),(10,20),(20,18),(20,41),(33,15),(39,22),(60,50)} {\n        \\node[point, fill=red] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw[blue] (1) -- (5);\n    \\end{tikzpicture}\n    \\caption{Upper list}\n    \\label{fig:rtp:upper}\n  \\end{minipage}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n      \\draw (1) -- (2) -- (3) -- (5) -- (6) -- (7) -- (8) -- (11) -- (12);\n    \\end{tikzpicture}\n    \\caption{The Upper polygon}\n    \\label{fig:rtp:polygon-upper}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.4\\textwidth}\n    \\begin{tikzpicture}[yscale=0.05,xscale=0.05]\n      \\setcounter{i}{1}\n\n      \\draw[->] (0,0) -- (80,0) node[below] {$x$};\n      \\draw[->] (0,0) -- (0,70) node[left] {$y$};\n\n      \\foreach \\p in {(1,11),(5,40),(10,20),(21,10),(20,18),(20,41),(33,15),(39,22),(48,9),(55,17),(60,50),(68,19)} {\n        \\node[point] (\\arabic{i}) at \\p {};\n        \\stepcounter{i}\n      }\n\n      \\draw (1) -- (2) -- (3) -- (5) -- (6) -- (7) -- (8) -- (11) -- (12) -- (10) -- (9) -- (4) -- (1);\n    \\end{tikzpicture}\n    \\caption{Final polygon}\n    \\label{fig:rtp:polygon}\n  \\end{minipage}\n\\end{figure}\n\n\\FloatBarrier\n", "meta": {"hexsha": "7f35c0749842094f2ab771608e5770c7ff09c565", "size": 5659, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/random_two_peasants.tex", "max_stars_repo_name": "utnapischtim/polygon", "max_stars_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/random_two_peasants.tex", "max_issues_repo_name": "utnapischtim/polygon", "max_issues_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/random_two_peasants.tex", "max_forks_repo_name": "utnapischtim/polygon", "max_forks_repo_head_hexsha": "4c926553f436199d643f43a0129610d8d67d72da", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.5229885057, "max_line_length": 117, "alphanum_fraction": 0.5806679625, "num_tokens": 2044, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.4341071757330641}}
{"text": "\\newpage\n\\section{Proposed solution} \\label{solution}\n\nIn this section we propose the approaches with centralized coordination.\nIn a warehouse the connection between robots is efficient and has no big limitations.\n\\begin{enumerate}\n  \\item The first strategy, mentioned above, is the \\srst which consider only \n  one task allocated for one robot.\n\n  \\item The second strategy \\sps using an optimal approach\n  to compose tasks. Precisely resolve the set partition problem of set tasks $\\mathcal{T}$ . \n  \n  \\item The last strategy (\\gsp) extends the first algorithm,\n  the main concept of this strategy is composing the tasks in a single travel with greedy coalition formation approach. \n  \n\\end{enumerate}\n\nIn section \\ref{chap:conclusions} as a future development we want to explore a distributed \nmethod because in this thesis we  only focused in centralized method.  \n\n\\subsection{Single robot : Single task (\\srst)}\n\nThis method is a baseline for our logistic scenario.\nThe important constraint of this approach is to consider only one task allocated for \none robot at time.\n\\\\\nThe set of tasks is ordered by the function mentioned below.\n\\begin{algorithm}\n  \\caption{Pop minimum element} \\label{SP}\n  \\begin{algorithmic}[1]\n    \n    \\Procedure{PME}{$T_i, T_j \\in \\mathcal{T}$}\n    \\If{$(demand(T_i) < demand(T_j)) \\wedge (dst(T_i) < dst(T_j))$}\n    \\State {\\bf return} true\n    \\Else\n    \\If{$dst(T_i) = dst(T_j)$}\n    \\State {\\bf return} true\n    \\EndIf\n    \\State {\\bf return} false\n    \\EndIf\n    \\EndProcedure\n  \\end{algorithmic}\n\\end{algorithm}\n\\newpage\nSuch function sorts the tasks based on the distance of the unloading bays and the demand of a specific task.\nFor distance we consider the euclidean distance between loading bay $L$ and unloading bays $U_j$.\nInstead for demand is the weight of the item.\n\nAfter the choose of the task to allocate by using the function $f(P)$ return the path distance, precisely the cost of the trail.\n\nFor this method we do not use the function $p(\\cdot)$ because we have only one task for robot\nthen the task already has the path. As mentioned above, we do not combine routes.\n\nFor completeness in this method we do not consider the heuristic function $v(\\cdot)$ because the demand for all\ntask is always 1. Because we allocate only one task for one robot at time.\n\nThis algorithm take linear time or $O(n)$ time, its time complexity is $O(n)$.\nThis means that the running time increases at most linearly with the size of the input.\nMore precisely, this means that there is a constant $c$ such that the running time is \nat most $cn$ for every input of size $n$.\n\n\n\n\\begin{figure} [hbt]\n  \\centering\n  \\includegraphics[width=\\textwidth]{img/cycle1.png}\n  \\caption{Example of execution \\srst with 4 agents with capacity 4 and 9 tasks.}\n  \\label{fig:srst}\n\\end{figure}\n\n\n\n\\subsection{Set Partition Strategy - Single robot : Multiple task (\\sps)}\n\nThis method consists to compute all possible patitions of the task set \nusing Set Partition algorithm \\cite{partition} and use only \nthe best partition which is based on the previously mentioned heuristic $v(\\cdot)$.\n\nAfter initialzation phase which all agents send their capacity and identifier,\nstart the partition algorithm \\cite{partition} that return all possible patitions of subsets combination \nof tasks $P^N$.\n\nThen foreach partitions the heuristic $v(\\cdot)$ has been used to calculate the loss.\nFor calculate the loss $L$ of a partition we have to calculate the $v(\\cdot)$ for all elements in\nthe subsets partition and finally sum all values for all subsets. \nFurthermore the combination with the lowest loss has been choose.\nSo a subset of combination as been sort in a increasing order. \nThen the first subset of combination has the lowest value of heuristic function \nis the first task assigned at the first request from a robot.\n\n\\begin{algorithm}\n  \\caption{Set Partition Strategy} \\label{SP}\n  \\begin{algorithmic}[1]\n  \\Procedure{SPS}{$P^N$}\\Comment{$P^N$= \\texttt{partition(}$\\mathcal{T}$\\texttt{)}}\n  \\State \\Comment{define $C$ the maximum capacity of the robots}\n  \\For{$P_i \\in P^N$}\n  \\If{$demand(P_i) > C$}\n  $P^N \\setminus P_i$\n  \\EndIf\n    \\For{$S_j \\in P_i$}\n      $v(S_j)$ \n    \\EndFor\n  \\EndFor\n  \\Comment{sort all $P_i$ for lowest $v(\\cdot)$} \n  \\State {\\bf return} the first $P_i$\n  \\EndProcedure\n  \\end{algorithmic}\n\\end{algorithm}\n\nThe function \\texttt{partition($\\cdot$)} take exponential time. \n\nMore formally, this algorithm is exponential time because $T(n)$ is bounded by $O(2^{n^{k}})$ \nfor some constant $k$.\n\n\\newpage\n\nAn example of solution with set $|\\mathcal{T}| = 4$:\n\\begin{center}\n  \\begin{tabular}{|c|r|c|} \\hline\n  \\textbf{iteration} & \\textbf{partition size} & \\textbf{partition} \\\\ \\hline\n  1    & 1    & \\{\\{a, b, c, d\\}\\}   \\\\\n  2    & 2    & \\{\\{a, b, c\\}, \\{d\\}\\}   \\\\\n  3    & 2    & \\{\\{a, b, d\\}, \\{c\\}\\}   \\\\\n  4    & 2    & \\{\\{a, b\\}, \\{c, d\\}\\}   \\\\\n  5    & 3    & \\{\\{a, b\\}, \\{c\\}, \\{d\\}\\}   \\\\\n  6    & 2    & \\{\\{a, c, d\\}, \\{b\\}\\}   \\\\\n  7    & 2    & \\{\\{a, c\\}, \\{b, d\\}\\}   \\\\\n  8    & 3    & \\{\\{a, c\\}, \\{b\\},\\{d\\}\\}   \\\\\n  9    & 2    & \\{\\{a, d\\}, \\{b, c\\}\\}   \\\\\n  10   & 2    & \\{\\{a\\}, \\{b, c, d\\}\\}   \\\\\n  11   & 3    & \\{\\{a\\}, \\{b, c\\}, \\{d\\}\\}   \\\\\n  12   & 3    & \\{\\{a, d\\}, \\{b\\}, \\{c\\}\\}   \\\\\n  13   & 3    & \\{\\{a\\}, \\{b, d\\}, \\{c\\}\\}   \\\\\n  14   & 3    & \\{\\{a\\}, \\{b\\}, \\{c, d\\}\\}   \\\\\n  15   & 4    & \\{\\{a\\}, \\{b\\}, \\{c\\},\\{d\\}\\}   \\\\ \\hline       \n  \\end{tabular}\n\\end{center}\n\n\n\nFor $|\\mathcal{T}| = 4$ takes 0.000043 seconds. If we increase the set, time increases exponentially.\nAn example of $|\\mathcal{T}| = 12$ takes 2.8 seconds and $|\\mathcal{T}| = 13$ takes 21.2 seconds.\n\nFor this reason in our experiment we limited the size of the task set at most 9 tasks.\n\n\\begin{figure} [hbt]\n  \\centering\n  \\includegraphics[width=\\textwidth]{img/opt.png}\n  \\caption{Example of execution \\sps with 4 agents with capacity 4 and 9 tasks. See example \\ref{example}}\n  \\label{fig:srst}\n\\end{figure}\n\n\\subsection{Greedy Set Partition Strategy - Single robot : Multiple task (\\gsp)}\nThe main concept of this approach is composing tasks using Greedy Coalition Formation\nbased on \\cite{cf_greedy} and \\cite{cf_farinelli}. Where one wants to minimize the \nteam cost subject to the constraint that each task must be executed by a given \nnumber of cooperative agents simultaneosly. Each task requires a number of different \ndemands, and each coalition for the task needs to provide the requered capabilities.\n\nLater initialzation phase which all agents send their capacity and identifier,\nstart the Coalition Formation algorithm \\cite{cf_greedy}.\nWhen compute new one possible coalition the heuristic  $v(\\cdot)$ has been used to calculate \nthe loss $L(T_{i,j})$ and if is negative that coalition is insered into the formation and the \n$T_i$ , $T_j$ are deleted from the task set $\\mathcal{T}$.\n\n\\begin{algorithm}\n\\caption{Greedy Coalition Formation} \\label{GCF}\n\\begin{algorithmic}[1]\n  \\Procedure{GCF}{$\\mathcal{T}$}\\Comment{$\\mathcal{T}$ = set of tasks}\n  \\State \\Comment{define $C$ the maximum capacity of the robots}\n  \\For{$T_i \\in \\mathcal{T}$}\n  \\For{$T_j \\in \\mathcal{T}$}\n\\Comment{define $T_{i,j} = T_i \\cup T_j$}\n\\If{$(T_i \\neq T_j) \\wedge (demand(T_{i,j}) \\leq C)$}\n\\If{$v(T_{i,j})-v(T_i)-v(T_j) < 0$}\n       \\State $\\mathcal{T} \\setminus \\{ T_i\\} \\setminus \\{T_j\\}$ $\\mathcal{T} \\cup \\{T_{i,j}\\}$\n  \\EndIf\n  \\EndIf\n\\EndFor\n\\EndFor\n\\State {\\bf return} $\\mathcal{T}$\n\\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n\nThis algorithm take polynomial time, its running time is upper bounded by a polynomial expression\nin the size of the input for the algorithm.\n\nMore precisely, this algorithm take $O(n^k)$ for some positive constant $k$. \n\n\\begin{figure} [hbt]\n  \\centering\n  \\includegraphics[width=\\textwidth]{img/cf.png}\n  \\caption{Example of execution \\gsp with 4 agents with capacity 4 and 9 tasks. See example \\ref{example}}\n  \\label{fig:srst}\n\\end{figure}\n\n\n\\newpage\n\\subsection*{Example with 9 tasks and 4 robots} \\label{example}\nGiven a set of tasks $\\mathcal{T}= \\{  \\{T_0\\}, \\{T_1\\}, \\cdots, \\{T_8\\} \\}$ defined like:\n\n${T_i=(item, demand, unloading\\_bay)}$.\n\nThe agents have the same capacity $C_{0,1,2,3} = 4$.\n\\begin{table}[hbt]\n\\begin{center}\n  % \\centering\n  \\begin{tabular}{|c|c|c|c|} \\hline\n    \\textbf{task} & \\textbf{item} & \\textbf{demand} & \\textbf{unloading bay} \\\\ \\hline\n    0    & A    & 1      & 0             \\\\\n    1    & B    & 2      & 1             \\\\\n    2    & C    & 3      & 2             \\\\\n    3    & A    & 1      & 0             \\\\\n    4    & B    & 2      & 1             \\\\\n    5    & C    & 3      & 2             \\\\\n    6    & A    & 1      & 0             \\\\\n    7    & B    & 2      & 1             \\\\\n    8    & C    & 3      & 2             \\\\ \\hline       \n  \\end{tabular}\n  \\caption{The task set $\\mathcal{T}$ for 9 tasks}\n  \\label{tab:t4} \n\\end{center}\n\\end{table}\n\nGiven a finite task set $\\mathcal{T}$ we can see how our strategies works.\nFor this example we have created a video of the simulations execution, in ROS and stage, which are available on YouTube \\footnote{YouTube site https://youtu.be/XbdBklu98HE}.\n\\newpage\nThe \\sps created 5 orders to perform all elements in the tasks set.\n\nIn the table \\ref{tab:sps} we can see the partition composed by subsets of tasks.\n\\begin{table}[hbt]\n  \\begin{center}\n    \\begin{tabular}{|c|c|c|c|} \\hline\n    \\textbf{task} & \\textbf{item} & \\textbf{demand} & \\textbf{unloading bay} \\\\ \\hline\n    \\{4,7\\}    & B    & 4     & \\{1\\}             \\\\\n    \\{0,1,3\\}  & \\{A,B\\}& 4    & \\{0,1\\}             \\\\\n    \\{2,6\\}    & \\{C,A\\}    & 4  & \\{0,2\\}             \\\\\n    5    & C    & 3      & 2             \\\\\n    8    & C    & 3      & 2             \\\\ \\hline       \n    \\end{tabular}\n    \\caption{The result of the Set Partition Strategy (\\sps)}\n    \\label{tab:sps}\n  \\end{center}\n\\end{table}\n\nThe \\gsp creted 6 orders, one more than \\sps, to perform all elements in the tasks set.\n\nIn table \\ref{tab:gsp} we can see the partition composed by subsets of tasks.\n\\begin{table}[hbt]\n\\begin{center}\n  \\begin{tabular}{|c|c|c|c|} \\hline\n  \\textbf{task} & \\textbf{item} & \\textbf{demand} & \\textbf{unloading bay} \\\\ \\hline\n  \\{3,2\\}    & \\{A,C\\}    & 4     & \\{0,2\\}             \\\\\n  \\{0,1\\}    & \\{A,B\\}    & 3     & \\{0,1\\}             \\\\\n  \\{6,4\\}    & \\{A,B\\}    & 3     & \\{0,1\\}             \\\\\n  5    & C    & 3      & 2             \\\\\n  8    & C    & 3      & 2             \\\\        \n  7    & B    & 2      & 1             \\\\\\hline\n  \\end{tabular}\n  \\caption{The result of the Greedy Set Partition (\\gsp)}\n  \\label{tab:gsp}\n\\end{center}\n\\end{table}\n\n\\newpage\nIn this Figure \\ref{fig:CF_graph} we can see because the Greedy approach is less\ncomplex than \\sps. On the execution before to create a coalition is checked if its can \nbe allocated. This check is the value of the loss of the coalition, if is less than zero\nthe colaition is insered in the solution else break the cycle for and pass another coalition.  \n\n\\begin{figure} [hbt]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/CF.png}\n    \\caption{The horizontal line represents a cut on executin defines the coalition structure.}\n    \\label{fig:CF_graph}\n\\end{figure}\n\n", "meta": {"hexsha": "6153b1d00f399e3f9c9d21709fcbb9ddd53bfee0", "size": 11203, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTex/Tesi/chapter/solution.tex", "max_stars_repo_name": "Davidemb/LogisticAgent_ws", "max_stars_repo_head_hexsha": "d1dab6ff32485b3af26ef8be58e624d059282c8a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTex/Tesi/chapter/solution.tex", "max_issues_repo_name": "Davidemb/LogisticAgent_ws", "max_issues_repo_head_hexsha": "d1dab6ff32485b3af26ef8be58e624d059282c8a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTex/Tesi/chapter/solution.tex", "max_forks_repo_name": "Davidemb/LogisticAgent_ws", "max_forks_repo_head_hexsha": "d1dab6ff32485b3af26ef8be58e624d059282c8a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1541218638, "max_line_length": 173, "alphanum_fraction": 0.6360796215, "num_tokens": 3563, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.43410717419271133}}
{"text": "% !TeX root = ../../main.tex\n\n\\chapter{Background}\n\n\\lipsum[1]\n\n\\begin{equation}\n    E = mc^2\n\\end{equation}\n\n\\lipsum[2]\n\n\\section{Celestial Bodies in the Solar System}\n\n\\lipsum[3]\n\n\\begin{figure}[ht]\n\t% Figures and tables are centred by default\n\t\\includegraphics[width=0.6\\textwidth]{pale-blue-dot}\n\t\\caption[Pale Blue Dot]{{\\bf Pale Blue Dot.} The \\emph{Voyager 1} spacecraft took this photograph of planet Earth on February 14, 1990 when she was more than six billion kilometers away from our home.}\n\\end{figure}\n\n\\subsection{Inner Planets}\n\n\\lipsum[4]\n\n\\begin{table}[ht]\n    \\begin{tabular}{lcccc}\n        \\toprule\n                & \\textbf{Mass} & \\textbf{Diameter} & \\textbf{Density}  & \\textbf{Gravity} \\\\\n                & $10^{24}$ kg  & km                & kg/m$^3$          & m/s$^2$ \\\\\n        \\midrule\n        Mercury & 0.33          & 4,879             & 5,427             & 3.7 \\\\\n        Venus   & 4.87          & 12,104            & 5,243             & 8.9 \\\\\n        Earth   & 5.97          & 12,756            & 5,514             & 9.8 \\\\\n        Mars    & 0.64          & 6,792             & 3,933             & 3.7 \\\\\n        \\bottomrule\n    \\end{tabular}\n    \\caption[Comparison of Inner Planets of the Solar System]{{\\bf Comparison of Inner Planets of the Solar System.} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pellentesque dictum neque, sollicitudin accumsan purus porttitor vitae. Phasellus faucibus enim.}\n\\end{table}\n\n\\lipsum[5]\n\n\\begin{figure}[p]\n    \\caption[Inner Planets of the Solar System]{{\\bf Inner Planets of the Solar System}}\n    \\begin{subfigure}[b]{0.5\\textwidth}\n        % While figures and tables are centred by default, subfigures and subtables are not\n        \\centering\n        \\includegraphics[height=2in]{mercury}\n        \\caption{Mercury}\n    \\end{subfigure}%\n    \\begin{subfigure}[b]{0.5\\textwidth}\n        \\centering\n        \\includegraphics[height=2in]{venus}\n        \\caption{Venus}\n    \\end{subfigure}\n    % Add space between rows\n    \\subfigurerow\n    \\begin{subfigure}[b]{0.5\\textwidth}\n        \\centering\n        \\includegraphics[height=2in]{earth}\n        \\caption{Earth}\n    \\end{subfigure}%\n    \\begin{subfigure}[b]{0.5\\textwidth}\n        \\centering\n        \\includegraphics[height=2in]{mars}\n        \\caption{Mars}\n    \\end{subfigure}\n\\end{figure}\n\n\\subsection{Asteroid Belt}\n\n\\lipsum[6]\n\n\\subsection{Outer Planets}\n\n\\lipsum[7]\n\n\\subsection{Kuiper Belt}\n\n\\lipsum[8]\n\n\\section{Artificial Objects in Heliocentric Orbits}\n\n\\lipsum[9]\n\n\\subsection{Tesla Roadster and Starman}\n\n\\lipsum[10]\n\n\\begin{figure}[ht]\n    \\includegraphics[width=0.8\\textwidth]{starman}\n    \\caption[Don't Panic]{{\\bf Don't Panic.} During the maiden flight of SpaceX's Falcon Heavy launch vehicle on February 6, 2018, a Tesla Roadster electric car with the ``Starman'' mannequin in spacesuit is launched into a heliocentric orbit.}\n\\end{figure}\n\n\\lipsum[11]\n\n\\begin{equation}\n    \\Delta v = v_\\text{e} \\ln \\frac{m_0}{m_f}\n\\end{equation}\n\n\\lipsum[12]\n", "meta": {"hexsha": "d2ec8ed3c410d87bfb669d83935f09a27bd86fad", "size": 3004, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "contents/chapters/background.tex", "max_stars_repo_name": "wnagchenghku/HKU-Thesis-LaTeX-Template", "max_stars_repo_head_hexsha": "24f1b63417412d89479e050bdf4af2f9c6a7ca6b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 33, "max_stars_repo_stars_event_min_datetime": "2018-08-21T03:59:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T13:51:11.000Z", "max_issues_repo_path": "contents/chapters/background.tex", "max_issues_repo_name": "wnagchenghku/HKU-Thesis-LaTeX-Template", "max_issues_repo_head_hexsha": "24f1b63417412d89479e050bdf4af2f9c6a7ca6b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-05-15T12:47:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-27T13:36:24.000Z", "max_forks_repo_path": "contents/chapters/background.tex", "max_forks_repo_name": "wnagchenghku/HKU-Thesis-LaTeX-Template", "max_forks_repo_head_hexsha": "24f1b63417412d89479e050bdf4af2f9c6a7ca6b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2018-08-21T03:58:23.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-10T01:17:05.000Z", "avg_line_length": 29.1650485437, "max_line_length": 279, "alphanum_fraction": 0.6238348868, "num_tokens": 939, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4341071701731331}}
{"text": "\\section{Histogram}\n\\label{sec:histogram}\n\n\\subsection{Purpose}\nThis program performs a multi-dimensional histogram of photon correlation events. These are defined by the program \\program{correlate}, though it is also possible to histogram T3 photons directly. The output is a set of histogram bins and the number of events which fall into each. This output is \\textit{not} normalized by bin width or any other factor, and represents the raw number of counts falling into each bin.\n\nFor T3 photons, \\program{histogram} can be used to build a histogram of events as would be done in interactive mode. To do this, set the mode to T3, and order to 1.\n\nFor \\gn{n>2}, all time dimensions are defined identically, and all pulse dimensions are defined identically. If distinct time dimensions are required, the modification can be achieved at the stage where bins are defined, without any modification later in the code.\n\n\\subsection{Command-line syntax}\n%\\input{programs/histogram.usage}\n\n\\subsubsection{Input}\n\\paragraph{\\gn{1} of T3 data}\nThe expected input is a stream of T3 photons.\n\n\\paragraph{\\gn{n\\ge 2}}\nThe expected input is the output of \\program{correlate}.\n\n\\paragraph{General options}\nThe main options specified for \\program{histogram} define the axes for pulse and time. These are treated equivalently, so we will focus on the time axes.\n\nFor \\texttt{--time}, the parameters specify the lower and upper bounds of the time axis, as well as the number of bins $n$ to create along that axis. For a linear spacing, the bin width $\\Delta t$ is $(t_{\\max}-t_{\\min})/n$, such that the bins are defined by the ranges\n\\begin{equation}\n\\begin{aligned}\n&[\\time_{\\min},\\time_{\\min}+\\Delta\\time),\\\\\n&[\\time_{\\min}+\\Delta\\time,\\time_{\\min}+2\\Delta\\time),\\\\\n&\\ldots\\\\\n&[\\time_{\\min}+(n-1)\\Delta\\time,\\time_{\\min}+n\\Delta\\time)\n\\end{aligned}\n\\end{equation}\nThis linear spacing is the default behavior, but the flag \\texttt{--time-scale} can produce two other scales: log, and log-zero. The log scale creates bins with fixed width over the span of $[\\log(\\time_{\\min}),\\log(\\time_{\\max}))$, as if often desired for measurements requiring long and short time correlations. The log-zero scale has identical behavior, except that any zero-time correlations ($\\timedelay=0$) are placed into the first bin. Note that the log scale cannot handle zero-time correlations, and neither log not log-zero can handle negative-time correlations. These values will be dropped from the histogram, with an error message indicating this has happened.\n\n\\subsubsection{Output}\nAfter the input stream terminates, \\program{histogram} outputs the bin definitions and the number of counts associated with that bin. Generically, this format is:\n\\begin{verbatim}\nchannel 0, channel 1, bin (1,1) lower, bin (1,1) upper, ...,\n    channel 2, ... , \n    counts \\n\n\\end{verbatim}\nwhere the channels are integers, bin edges are floats, and the counts are integers. For every bin in the histogram, one line will be output. For T2 mode, the bin definition has only one dimension (time), so the format is:\n\\begin{verbatim}\nchannel 0, channel 1, time 1 lower, time 1 upper, \n           channel 2, time 2 lower, ...,\n           counts \\n\n\\end{verbatim}\nT3 data have an additional dimension (pulse):\n\\begin{verbatim}\nchannel 0, channel 1, pulse 1 lower, pulse 1 upper,\n                      time 1 lower, time 1 uppper,\n           channel 2, ...\n           counts \\n\n\\end{verbatim}\nSee section~\\ref{sec:histogram_examples} for specific examples of output in these formats.\n\n\n\\subsection{Examples of usage}\n\\label{sec:histogram_examples}\n\\subsubsection{Time-averaged photoluminescence lifetime from T3 data}\nIn T3 mode, a correlation order \\gn{1} is code for interactive-like behavior. Formally this is a correlation of the laser pulse and the system response, but this language is not often used.\n\\begin{verbatim}\n> picoquant --file-in data.pt3 |  \\\n  histogram --mode t3 --order 1 --channels 2 \\\n            --time 0,10,500000\n0,0.00,50000.00,0\n0,50000.00,100000.00,0\n...\n1,0.00,50000.00,11267838\n1,50000.00,100000.00,14947845\n1,100000.00,150000.00,1512803\n1,150000.00,200000.00,1152498\n1,200000.00,250000.00,1037717\n1,250000.00,300000.00,973572\n1,300000.00,350000.00,932802\n1,350000.00,400000.00,899615\n1,400000.00,450000.00,12278\n1,450000.00,500000.00,0\n\\end{verbatim}\nNote that \\texttt{histogram} will operate on channel 0 as well, even though channel 1 is the only channel with any signal. This costs extra memory and some computational overhead at startup, but ultimately the cost is insignificant compared to the cost of processing the data stream.\n\n\\subsubsection{\\gn{2} from T2 data}\nThis data represents an electronic sync source (channel 4) and the detection of the laser itself.\n\\begin{verbatim}\n> picoquant --file-in data.ht2 | \\\n  correlate --mode t2 --order 2 \\\n            --channels 5 \\\n            --max-time-distance 1000 | \\\n  histogram --mode t2 --order 2 \\\n            --channels 5 \\\n            --time 0,10,1000\n0,0,0.00,100.00,0\n...\n0,4,0.00,100.00,43\n0,4,100.00,200.00,24\n0,4,200.00,300.00,38\n0,4,300.00,400.00,43\n0,4,400.00,500.00,44\n...\n4,4,900.00,1000.00,0\n\\end{verbatim}\n\n\\subsubsection{\\gn{2} from T3 data}\n\\begin{verbatim}\n> picoquant --file-in data.pt3 | \\\n  correlate --mode t3 --channels 2 \\\n            --order 2 \\\n            --max-pulse-distance 3 \\\n  histogram --mode t3 --channels 2 \\\n            --order 2 --pulse 0,3,3 \\\n            --time -500000,2,500000\n0,0,0.00,1.00,-500000.00,0.00,0\n...\n1,1,0.00,1.00,-500000.00,0.00,0\n1,1,0.00,1.00,0.00,500000.00,104640\n1,1,1.00,2.00,-500000.00,0.00,123289\n1,1,1.00,2.00,0.00,500000.00,124676\n1,1,2.00,3.00,-500000.00,0.00,231962\n1,1,2.00,3.00,0.00,500000.00,231694\n\\end{verbatim}\nAs a rough benchmark, on a computer with a dual-core 3\\giga\\hertz{} processor running 32-bit Linux, this command required 25\\second{} of wall time, for \\texttt{data.ht3} containing 32.7 million photon records (18.1\\kilo\\cps) for a total of 0.8 million correlation events.\n\n\\subsubsection{\\gn{3} from T2 data}\nThis T2 data is the same as the laser data from before:\n\\begin{verbatim}\n> picoquant --file-in data.ht2 | \\\n  correlate --mode t2 --order 2 \\\n            --channels 5 \\\n            --max-time-distance 1000000 | \\\n  histogram --mode t2 --order 2 \\\n            --channels 5 \\\n            --time 0,1,1000000\n0,0,0.00,1000000.00,0,0.00,1000000.00,31\n0,0,0.00,1000000.00,1,0.00,1000000.00,55\n0,0,0.00,1000000.00,2,0.00,1000000.00,57\n...\n4,0,0.00,1000000.00,2,0.00,1000000.00,2710\n4,0,0.00,1000000.00,3,0.00,1000000.00,2235\n4,0,0.00,1000000.00,4,0.00,1000000.00,0\n...\n\\end{verbatim}\nNote how much larger the time window must be to catch significant numbers of higher-order events.\n\n\\subsection{Implementation details}\nThe problem of populating and returning histograms for all possible correlations can be broken into a few distinct steps:\n\\begin{enumerate}\n\\item Construct a histogram for every permutation of channels.\n\\item For each correlation event:\n  \\begin{enumerate}\n  \\item Identify the histogram corresponding to the permutation of channels.\n  \\item Identify the bin associated with the parameters of the correlation.\n  \\item Increment that bin in that histogram.\n  \\end{enumerate}\n\\item For every bin of every histogram, print the bin definition and associated counts\n\\end{enumerate}\nAs such, each of these will be discussed separately. The discussion will focus on T2 data, but T3 data are handled identically for twice the order of equivalent T2 data.\n\n\\subsubsection{The cross-correlations can be enumerated as base-$\\abs{\\channels}$ numbers}\nEach histogram corresponds to a single cross-correlation, as identified by the tuple $\\vec{\\channel}\\in\\channels^{n}$, for $\\channels$ the set of all channels and correlation order $n$. As such, if we enumerate the channels as whole numbers ($0, 1, \\ldots$), it is evident that each element of the tuple can be treated as the coefficient of an $n$-digit number in base $\\abs{\\channels}$. Mapping these tuples onto the set of whole numbers can thus be achieved by the following formula:\n\\begin{equation}\n\\Index(\\vec{\\channel}) = \\sum_{j=0}^{n-1}{\\channel_{j}\\abs{\\channels}^{n-1-j}}\n\\end{equation}\nwhere the elements $\\channel$ refer implicitly to the index of that channel in our enumeration.\nIf $\\abs{\\channels}=2$, this is identical to the expression of an $n$-digit binary number.\n\nIn the software, all possible cross-correlations are enumerated and the corresponding histograms allocated before beginning the calculation. This requires some computational overhead at instantiation, and if an application requires the calculation of large numbers of histograms it may be more efficient to modify the code to output and reset upon receiving particular signals.\n\nThe implementation of these methods can be found in \\texttt{histogram\\_gn.c} and \\texttt{combinations.c}.\n\n\\subsubsection{A histogram is function of $n$-dimensional vectors mapping mapping onto integers}\nOnce the particular cross-correlation has been identified, the task falls to that of incrementing a counter corresponding to the appropriate histogram bin. The purpose of a histogram is to divide some phase space into well-defined smaller blocks, and then to count the number of events which fall into those blocks. We will restrict ourselves to rectangular volumes, so the task of identifying the correct volume of phase space can be reduced to determining the correct index along all axes, and thus each indexing step is identical to that for a single-dimensional histogram. \n\nIn one dimension, we first define a range of values into which the events can fall, for example $\\timewindow=\\left[\\timewindow\\upminus,\\timewindow\\upplus\\right)\\subset\\integers$. Next, we define some number $N$ of ranges $\\resolution$ whose members collectively span $\\timewindow$. These $\\resolution$ can be enumerated $0,1,\\ldots N-1$, so assign these indices in order to the sorted $\\resolution$. Now this one dimension is represented by an $N$-dimensional vector whose dimensions represent some $\\resolution$. The task then turns to mapping any value $z\\in\\integers$ to the appropriate $\\resolution$.\n\nFor linearly-spaced sub-ranges, this identification can be achieved in O(1) time by:\n\\begin{equation}\n\\Index(x) = \\timewindow\\upminus + x\\parens{\\frac{\\timewindow\\upplus-\\timewindow\\upminus}{N}}\n\\end{equation}\nHowever, in the code this is not used, and instead a more general binary search algorithm (costing O($\\log(N)$)) is implemented to permit arbitrary spacings of these ranges. The binary algorithm determines the placement of an element into a sorted list by iterative division of the list into upper and lower halves, until the appropriate element is define. This is implemented as:\n\\lstset{language=Python}\n\\begin{lstlisting}\ndef binary_search(value, bins):\n    upper = len(bins)\n    lower = 0\n    \n    if value < bins[0] or values > bins[-1]:\n        # Not in the bounds\n        return(False)\n     \n    while True:\n        middle = (upper - lower)/2\n        if value in bins[middle]:\n            # Just right\n            return(middle)\n        elif value < bins[middle]:\n            # Too high\n            upper = middle\n        else:\n            # Too low\n            lower = middle\n\\end{lstlisting}\nBecause this must be performed for each dimension of the correlation, the search costs O($n\\log{(N)}$) time, compared to the O($n$) for the complete linear search. \n\nTo see how this is implemented in \\program{histogram}, see \\texttt{histogram\\_gn.c} and \\texttt{histogram\\_t*.c}. \n\n\\subsubsection{Printing the histogram}\nHaving exhausted the stream of correlation events, the final task is to print all of the histogram bins in a readable format. This is done by iterating over the histograms, then iterating over the bins, printing the counts associated with each bin. How this process is performed should be evident from the preceding discussion, and for the details refer to the routine \\texttt{print\\_gn\\_histogram} in \\texttt{histogram\\_gn.c}.\n\nNote that the output of $\\program{histogram}$ is not normalized in any way: only the number of counts is reported for each bin.\n\n", "meta": {"hexsha": "342e26d54679eea3d13882e542f98de64093d561", "size": 12119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/programs/histogram.tex", "max_stars_repo_name": "mktt2897/photon_correlation", "max_stars_repo_head_hexsha": "b5cb9376f883ff25f81521d4270d8dd7f750efb1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-10-24T11:43:34.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-25T06:02:21.000Z", "max_issues_repo_path": "doc/tex/programs/histogram.tex", "max_issues_repo_name": "mktt2897/photon_correlation", "max_issues_repo_head_hexsha": "b5cb9376f883ff25f81521d4270d8dd7f750efb1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2017-08-15T14:42:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T07:35:13.000Z", "max_forks_repo_path": "doc/tex/programs/histogram.tex", "max_forks_repo_name": "mktt2897/photon_correlation", "max_forks_repo_head_hexsha": "b5cb9376f883ff25f81521d4270d8dd7f750efb1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-04-14T16:27:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-15T05:32:12.000Z", "avg_line_length": 57.4360189573, "max_line_length": 674, "alphanum_fraction": 0.7379321726, "num_tokens": 3337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.737158174177441, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4341044364297553}}
{"text": "\\documentclass{article}\n\n%----------------------------------------------------------------------------------------\n\n\\usepackage{listings} % Required for inserting code snippets\n\\usepackage{geometry}\n\\geometry{margin=0.7in}\n\\usepackage[usenames,dvipsnames]{color} % Required for specifying custom colors and referring to colors by name\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{tikz}\n\\usepackage{enumerate}\n\n\\delimitershortfall-1sp\n\\newcommand\\abs[1]{\\left|#1\\right|}\n\n\\definecolor{DarkGreen}{rgb}{0.0,0.4,0.0} % Comment color\n\\definecolor{highlight}{RGB}{255,251,204} % Code highlight color\n\n%----------------------------------------------------------------------------------------\n\n\\begin{document}\n\n%----------------------------------------------------------------------------------------\n\n\\begin{flushleft}\n\\begin{center}\n$\\displaystyle \\lim_{x \\to 2} (x^2 - x) = 2$\n\\end{center}\n\nWe know that $c=2$, $L=2$, $f(x) = x^2 - x$. \\\\\n\n\\vspace{.4cm}\n\\begin{center}\n$\\abs{f(x) - L} = \\abs{x^2-x-2} < \\epsilon \\implies \\abs{\\abs{x-2} \\abs{x+1}} < \\epsilon$ \\\\\n\\end{center}\n\\vspace{.4cm}\n\nWe cannot define $\\delta_\\epsilon$ in terms of $x$, but $\\abs{x-2} = \\frac{\\epsilon}{\\abs{x+1}}$ leaves $\\delta_\\epsilon$ in terms of $x$. We need to find a fixed $M$ such that $\\frac{\\epsilon}{M} < \\frac{\\epsilon}{\\abs{x+1}}$. We only care about $x$ \\textit{around} $2$, so we can restrict $x$ to the open interval $(1,3)$. \n\n\\begin{center}\n\\begin{tabular}{c c}\n$1<x<3$ & $1<x<3$ \\\\\n$-1<x-2<1$ & $2<x+1<4$ \\\\\n$\\abs{x-2}<1$ & $\\frac{1}{2}<\\frac{1}{\\abs{x+1}}<\\frac{1}{4}$ \\\\\n\\end{tabular}\n\\end{center}\n\n\n\\subsection*{Proof}\nLet $\\epsilon > 0$ be given. Let $\\delta_\\epsilon=min\\{1, \\frac{\\epsilon}{4}\\}$. Then $0<\\abs{x-2}<\\delta_\\epsilon$ implies\n\\begin{center}\n\\begin{tabular}{l}\n(1) $\\abs{x-2} < 1 \\implies 2<\\abs{x+1}<4$ \\\\\n(2) $\\abs{f(x) - L} =\\abs{x^2-x-2} = \\abs{x-2}\\abs{x+1} < \\frac{\\epsilon}{4}\\cdot4 = \\epsilon$ \\\\\n\\end{tabular}\n\\end{center}\n\nThis completes the proof.\n\\end{flushleft}\n\n\\vspace{.75cm}\n\n\\begin{flushleft}\n\\begin{center}\n$\\displaystyle \\lim_{x \\to 0} x^2(sin(x) + cos(x)) = 0$\n\\end{center}\n\\vspace{.4cm}\nWe know that $c=0$, $L=0$, $f(x) = x^2(sin(x) + cos(x))$. \\\\\n\\vspace{.4cm}\nFrom the combination of the transcendental functions $\\abs{sin(x) + cos(x)}$, we know the maximum value that the functions can reach is $\\sqrt{2}$. Therefore, we can modify $f(x)$ to be $\\sqrt{2} x^2$ since we know that the $\\abs{sin(x) + cos(x)}$ part of the function is bounded above. Thus, we have\n\\begin{center}\n\\begin{tabular}{r}\n$\\abs{\\sqrt{2} x^2 - 0} < \\epsilon$ \\\\\n$\\abs{\\sqrt{2} x^2} < \\epsilon$ \\\\\n$\\sqrt{2} x^2 < \\epsilon$ \\\\\n$x < \\frac{\\sqrt{\\epsilon}}{\\sqrt[4]{2}}$ \\\\\n\\end{tabular}\n\\end{center}\n\n\\subsection*{Proof}\n\nLet $\\epsilon > 0$ and $\\delta_\\epsilon=\\frac{\\sqrt{\\epsilon}}{\\sqrt[4]{2}}$. Then, $0 < x < \\frac{\\sqrt{\\epsilon}}{\\sqrt[4]{2}}$ implies\n\\begin{center}\n$-\\frac{\\sqrt{\\epsilon}}{\\sqrt[4]{2}} < x < \\frac{\\sqrt{\\epsilon}}{\\sqrt[4]{2}}$ \\\\\n$x^2 < \\frac{\\epsilon}{\\sqrt{2}}$ \\\\\n$\\sqrt{2}x^2 < \\epsilon$ \\\\\n\\end{center}\nThus, $\\abs{\\sqrt{2}x^2} < \\epsilon$. This satisfies the proof because we stated that $sin(x) + cos(x)$ is bounded above by $\\sqrt{2}$. By definition of an upper bound, there can never exist a value that exceeds $\\abs{sin(x) + cos(x)x^2}$. Then, $\\abs{sin(x) + cos(x)x^2} < \\abs{x^2\\sqrt{2}} < \\epsilon$.  \n\\end{flushleft}\n\n%----------------------------------------------------------------------------------------\n\n\\end{document}\n", "meta": {"hexsha": "a10fbe6b65a72560cdf3455c3a1d94f94865451f", "size": 3499, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "elementary-analysis/homework-4/homework_4_group_problem.tex", "max_stars_repo_name": "jShiohaha/math-classes", "max_stars_repo_head_hexsha": "72711363cf0b58863ffb193ee79ff40244e517eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "elementary-analysis/homework-4/homework_4_group_problem.tex", "max_issues_repo_name": "jShiohaha/math-classes", "max_issues_repo_head_hexsha": "72711363cf0b58863ffb193ee79ff40244e517eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "elementary-analysis/homework-4/homework_4_group_problem.tex", "max_forks_repo_name": "jShiohaha/math-classes", "max_forks_repo_head_hexsha": "72711363cf0b58863ffb193ee79ff40244e517eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4479166667, "max_line_length": 325, "alphanum_fraction": 0.5681623321, "num_tokens": 1199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.43410442282787937}}
{"text": "\\documentclass{article}\n\\begin{document}\n  \\section{Block}\n\n  \\begin{equation}\n    e^{i\\pi}=-1\n    \\label{eq:euler}\n  \\end{equation}\n  Equation~\\ref{eq:euler} is some good math.\n\n  \\section{Inline}\n\n  some lovely maths \\(x^2 + y^2 = z^2\\)\n\\end{document}\n", "meta": {"hexsha": "281ab98c1c8631dc496d636dab8cfd9c7cf8896f", "size": 254, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tests/integration/basic/math.tex", "max_stars_repo_name": "kenjikun/engrafo", "max_stars_repo_head_hexsha": "2ac87e215daea32699aa7f888f0405936d2ef452", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 836, "max_stars_repo_stars_event_min_datetime": "2017-10-23T10:16:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T00:31:05.000Z", "max_issues_repo_path": "tests/integration/basic/math.tex", "max_issues_repo_name": "kenjikun/engrafo", "max_issues_repo_head_hexsha": "2ac87e215daea32699aa7f888f0405936d2ef452", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 894, "max_issues_repo_issues_event_min_datetime": "2017-10-23T09:27:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T19:06:07.000Z", "max_forks_repo_path": "tests/integration/basic/math.tex", "max_forks_repo_name": "kenjikun/engrafo", "max_forks_repo_head_hexsha": "2ac87e215daea32699aa7f888f0405936d2ef452", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 62, "max_forks_repo_forks_event_min_datetime": "2017-10-23T19:29:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T12:19:08.000Z", "avg_line_length": 16.9333333333, "max_line_length": 44, "alphanum_fraction": 0.6417322835, "num_tokens": 93, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.43410442282787937}}
{"text": "\n\\subsection{The EXAFS Equation}\n\\begin{frame}\n  \\frametitle{The EXAFS Equation} %% Analysis with {\\feff} \\&  {\\arch} or {\\ifeffit} }\n\n  The XAFS Equation used with {\\feff} and {\\larch}:\n\n  \\[\n  \\chi(k) = \\sum_j {{ S_0^2 {\\Blue{N_j}} {\\Red{f_j(k)}}  e^{-2R_j/\\lambda(k)}\n      e^{-2k^2{\\Blue{\\sigma_j^2}}}}\\over{k{\\Blue{R_j}}^2}}\n  {\\sin[{2k{\\Blue{R_j}} + {\\Red{\\delta_j(k)}}} ]}\n   \\]\n\n\\begin{itemize}\n   \\pause\n     \\item  The sum is over  {\\RedEmph{Scattering Paths}} of the\n       photo-electron.   Both:\n\n       \\begin{description}\n\n       \\item[Single Scattering] {\\tiny{ absorbing atom $\\Rightarrow$ neighbor atom\n             $\\Rightarrow$ absorbing atom}}\n\n\n       \\item[Multiple Scattering] {\\tiny{absorbing atom $\\Rightarrow$ neighbor\n             atom  $\\Rightarrow$ neighbor atom $\\Rightarrow$ \\ldots  $\\Rightarrow$\n             absorbing atom}}\n\n       \\end{description}\n\n       \\pause\\item $\\Red{f(k)}$ and $\\Red{\\delta(k)}$ are\n       {{photo-electron scattering amplitude and phases}}:\n\n   \\begin{itemize}\n   \\item Energy ($k$) dependent.\n   \\item $Z$ dependent -- $Z$ of the scattering atoms(s).\n   \\item non-trivial: must be calculated (or extracted from measured spectra).\n\n   \\end{itemize}\n \\end{itemize}\n\n   \\vmm \\hrule \\vmm\n\n   \\onslide+<4->\n\n   Knowing  $\\Red{f(k)}$ and $\\Red{\\delta(k)}$, we can determine structural information:\n\n     \\begin{itemize}\n     \\item ${\\Blue{R}}$ --  near neighbor distance.\n     \\item ${\\Blue{N}}$ -- coordination number.\n     \\item ${\\Blue{\\sigma^2}}$ -- mean-square  disorder in ${\\Blue{R}}$.\n     \\end{itemize}\n\n   \\vmm\n\n\\end{frame}\n", "meta": {"hexsha": "11a3915507dd0af20839121b25de9b8c974d2988", "size": 1591, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/analysis_xafs_eq.tex", "max_stars_repo_name": "newville/xafsfun", "max_stars_repo_head_hexsha": "525b0b8fb6ec61396dc7dd2950a3e2a3ab6c17d1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/analysis_xafs_eq.tex", "max_issues_repo_name": "newville/xafsfun", "max_issues_repo_head_hexsha": "525b0b8fb6ec61396dc7dd2950a3e2a3ab6c17d1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/analysis_xafs_eq.tex", "max_forks_repo_name": "newville/xafsfun", "max_forks_repo_head_hexsha": "525b0b8fb6ec61396dc7dd2950a3e2a3ab6c17d1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9122807018, "max_line_length": 88, "alphanum_fraction": 0.5977372722, "num_tokens": 500, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.43410442282787937}}
{"text": "\\documentclass{article}\n\n\n%%%%%%%%%%%%%%%% 2020 - 11 - 28 %%%%%%%%%%%%%%%%%%\n\\usepackage{tikz}\n\\usetikzlibrary{calc}\n\\usepackage{pgfplots}\n\\usepackage{graphicx}\n\\usepackage{url}\n\n\\usepackage{amsmath}\n\\usepackage{algorithm, algpseudocode}\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}}\n\\algnewcommand{\\LeftComment}[1]{\\Statex \\(\\triangleright\\) #1}\n\\usepackage{amsfonts}  % \\mathbb{R}\n\\makeatletter\n\\newlength{\\trianglerightwidth}\n\\settowidth{\\trianglerightwidth}{$\\triangleright$~}\n\\algnewcommand{\\LineComment}[1]{\\Statex \\hskip\\ALG@thistlm $\\triangleright$ #1}\n\\algnewcommand{\\LineCommentCont}[1]{\\Statex \\hskip\\ALG@thistlm%\n  \\parbox[t]{\\dimexpr\\linewidth-\\ALG@thistlm}{\\hangindent=\\trianglerightwidth \\hangafter=1 \\strut$\\triangleright$ #1\\strut}}\n  \n\\algnewcommand{\\LeftLineCommentCont}[1]{\\Statex \\hskip\\ALG@thistlm%\n  \\parbox[t]{\\dimexpr\\linewidth-\\ALG@thistlm}{\\leftskip=\\algorithmicindent \\hangindent=\\trianglerightwidth \\hangafter=1 \\strut$\\triangleright$ #1\\strut}}\n  \n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{amsthm}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\usepackage{minted}\n\n\n\\usepackage{subfig}\n\\usepackage[export]{adjustbox}% in preamble\n%\\subfloat[hlof entryi][hsub-captioni]{%\n%hfigurei}\n%\\subfloat[hlot entryi][hsub-captioni]{%\n%htablei}\n\n\\usepackage{hhline}\n\\usepackage{makecell, caption, booktabs}\n\\usepackage{siunitx}\n\n%%The second way (hacky, and depends on an implementation detail of els-cas)\n\\makeatletter\n\\def\\redefparbox{\\def\\@parboxrestore{\\@arrayparboxrestore\\let\\\\\\@normalcr\n  \\if@minipage\\expandafter\\@gobbletwo\\fi\n  \\@firstofone{\\centering\\casscparboxtest}}}\n\\def\\casscparboxtest#1{%\n  \\ifx\\rightskip#1\\relax\\expandafter\\dimen@\\else\n    \\expandafter\\@secondoftwo\n  \\fi\\@gobble{#1}}\n\\makeatother\n%%The second way (hacky, and depends on an implementation detail of els-cas)\n\n%%%%%%%%%%%%%%%% 2020 - 11 - 28 %%%%%%%%%%%%%%%%%%\n\n\n\n\\usepackage{PRIMEarxiv}\n\n\\usepackage[utf8]{inputenc} % allow utf-8 input\n\\usepackage[T1]{fontenc}    % use 8-bit T1 fonts\n\\usepackage{hyperref}       % hyperlinks\n\\usepackage{url}            % simple URL typesetting\n\\usepackage{booktabs}       % professional-quality tables\n\\usepackage{amsfonts}       % blackboard math symbols\n\\usepackage{nicefrac}       % compact symbols for 1/2, etc.\n\\usepackage{microtype}      % microtypography\n\\usepackage{lipsum}\n\\usepackage{graphicx}\n\\graphicspath{{media/}}     % organize your images and other figures under media/ folder\n\n  \n%% Title\n\\title{ on Polynomial Approximation of Activation Function\n%%%% Cite as\n%%%% Update your official citation here when published \n%\\thanks{\\textit{\\underline{Citation}}: \n%\\textbf{Authors. Title. Pages.... DOI:000000/11111.}} \n}\n\n\n\\author{ \\href{https://orcid.org/0000-0003-0378-0607}{\\includegraphics[scale=0.06]{orcid.pdf}\\hspace{1mm}John Chiang} \\\\\n\t\\texttt{liyue.sun@mail.nankai.edu.cn, john.chiang.smith@gmail.com} \\\\\n}\t\n\n\n\n\\begin{document}\n\\maketitle\n\n\n\\section{Introduction}\nWhen it comes to applying homomoiphic encryption techqiue to machine learning such as neural network, there is a techquice problem that non-polynomial of activation function  could not be calculated directly in the HE domain. The common way to deal with it is to approximate the activation function using the least-square method, to a polynomial that can be calculated in a HE-based environmental\\cite{hadash2018estimate}. Being widely adapted in recent work related to HE\\cite{kour2014real}, however, the least-square method maight not be ideal for this task. In this essay, we propose an neat method to approximate the activation function based on the the least squared method. \n\nNote that the idea of this essay did come to the present author, but we can not garnteen that other researches haven't found it (we should give some time to read the book carefully before trying to develope some own method). In conclude, this is a simple idea that can propaply work for approximating activation function of HE. // %比最小二次乘更容易符合同态加密下的要求    \n\n\n\\section{Least Square Method}\n\\label{sec:headings}\nFor a continuous real-value function $f(x)$, a simple version of least square method to approximate $f(x)$ over range $[a, b]$ by a polynomial of a given degree $n$ is to find a polynomial of at most degree $n$, $p_n(x)$, such that  minimise the $$\\int_{a}^{b} (f(x) - p_n(x))^2 dx. $$\n\nFor approximating a continuous real-value function $f(x)$ over the range $[a, b]$ by a polynomial of a given degree $n$, a simple version of least square method  is to find a polynomial of at most degree $n$, $p_n(x)$, such that  maximise the $$\\int_{a}^{b} (f(x) - p_n(x))^2 dx, $$ which has a unique solution (the best approximation). Least square method is such a common method that many softwares implement this method, such as the function  $polyfit( \\cdot )$ in Python, Matlab or Octave. For example, only 3 lines of Octave codes is all it needs to fit the activation function $ReLU(x) = max(0, x) $ over the range $[-8, +8]$ by a polynomial of degree 2, resulting in the figure 1:\n\\begin{minted}\n{octave}\nx = [-8:0.000001:+8]; \ny = max(0,x);\npolyfit(x,y,2) \n\\end{minted} \nand we get the polynomial approximation $p_2^{ls}(x) = 0.058594 +  0.500000 \\cdot x +  0.750000 \\cdot x^2 $\n\n\nEven through least square method has many advantages, it maight not be the best choice in the sense of a HE-based environment. In the sense of a HE-based environment, we would like to choice a low-degree polynomial due to the expensive HE operations, and also perfer the similiar curve shape between the apprximation polynomial and the function to approximate, even at the cost of losing best appxiromation. Thus, we propose a simple method to conside the gradient(the slope) into the optimal function.  \n\nand its limition in the polynomial approximation of activation function\nTo minimise the gray area of the is not enough, we perhaps would like a polynomial approximation that has a similiar shape to the activation function, even at the cost of some larger gray area. \n\n\\section{Our Method}\n\\label{sec:others}\n\nIn this section, we present  a simple method based on the least-square method, which  includes  the graduals (shape) of the Polynomial and the activation into  the least-square method, in order to get the desired polynomial approximation that we describled above.\nsuch that  minimise the \n$$\\int_{a}^{b} (f(x) - p_n(x))^2 + (f'(x) - p_n'(x))^2 dx. $$\n\nFor a toy example, we use this method for the same task above, that is to fit the activation function $ReLU$ over the range $[-8, +8]$ by a polynomial of degree 2 denoted by $p_2^{lg}(x) = c +  b \\cdot x +  a \\cdot x^2 . $ The question is to minimise the observation loss function \n\\begin{equation*}\n  \\begin{aligned}\nF(a, b, c)  = & \\int_{-8}^{0} (f(x) - p_2^{lg}(x))^2  dx \n                +\\int_{0}^{+8} (f(x) - p_2^{lg}(x))^2  dx\n                +\\int_{-8}^{0} (f'(x) - p_2^{lg}{'}(x))^2 dx\n                +\\int_{0}^{+8} (f'(x) - p_2^{lg}{'}(x))^2 dx   \\\\\n            = & [\\frac{4}{3}a^2x^3 + (b^2 + 1 - 2b)x + 2a(b - 1)x^2  ]|_{0}^{+8}  + \\\\\n            &[\\frac{1}{5}a^2x^5 + \\frac{1}{3}b^2x^3 + bcx^2 - \\frac{2}{3}bx^3 + c^2x + \\frac{1}{3}x^3 - cx^2 + \\frac{1}{2}abx^4 - \\frac{1}{2}ax^4 + \\frac{2}{3}acx^3 ]|_{0}^{+8} + \\\\\n            & [\\frac{4}{3}a^2x^3 + b^2x + 2abx^2  ]|_{-8}^0 + \\\\\n            &[\\frac{1}{5}a^2x^5 + \\frac{1}{3}b^2x^3 + c^2x + bcx^2  + \\frac{1}{2}abx^4 + \\frac{2}{3}acx^3 ]|_{-8}^{0} + \\\\\n            = & 14472.5\\dot{3}a^2 + 357.\\dot{3}b^2 + 16c^2  + 682.\\dot{6}ac - 357.\\dot{3}b + 178.\\dot{6} - 64c - 2176a\n \\end{aligned}\n\\end{equation*}\nMinimising $F(a,b,c)$ is a problem of unconstrained optimization. To do that, we need to calcuate  the first-order partial derivatives of $F(a,b,c)$ and have them equal to $0$ : \n\\begin{equation*}\n  \\begin{aligned}\nF_a(a, b, c) & = 28945.0\\dot{6}a +  682.\\dot{6}c - 2176 &= 0  \\\\\nF_b(a, b, c) & =  714.\\dot{6}b  - 357.\\dot{3}  &= 0  \\\\\nF_c(a, b, c) & = 32c  + 682.\\dot{6}a - 64 &= 0\n \\end{aligned}\n\\end{equation*}\nSolving these equations, we obtain the unique solution and the polynomial approximation, respectly:\n\\begin{equation*}\n  \\begin{aligned}\na = 0.0563686709, b = 0.5, c = 0.7974683544, \\\\\np_n^{lg}(x) = 0.797468 +  0.500000 \\cdot x +  0.056369 \\cdot x^2 \n \\end{aligned}\n\\end{equation*}\nWe compare the polynomial generated by least square,  $p_n^{ls}(x)$, with that of our method $p_n^{lg}(x)$. \n\\begin{figure}[ht]\n\\centering\n\n\\begin{tikzpicture}[remember picture]\n\\begin{axis}[ \n%legend pos=south east,\n%legend style={at={(0.5,-0.17)},anchor=north,legend cell align=left},\nlegend style={at={(0.5,+0.9)},anchor=north,},\nwidth=0.45\\linewidth, \nxtick={-8, -6, -4, -2, 0, 2,  4, 6, 8 },\nyticklabels={}, \nat={(0.66\\linewidth,0)},\n]\n%Below the red parabola is defined\n\\addplot [\n    domain=-8:8, \n    samples=100, \n    color=red,\n]\n{0.797468 +  0.500000*x +  0.056369*x^2 };\n\\addlegendentry{$p_2^{lg}(x)$}\n%Here the blue parabola is defined\n\\addplot [\n    domain=-8:8, \n    samples=100, \n    color=blue,\n    ]\n    {0.058594 +  0.500000*x +  0.750000*x^2 };\n\\addlegendentry{$p_2^{ls}(x)$};\n%ReLU\n\\addplot [\n    domain=-8:8, \n    samples=100, \n    color=gray,\n    ]\n    {max(0, x) };\n\\addlegendentry{$\\texttt{ReLU}$};\n\\end{axis}\n\\end{tikzpicture}\n\n\\iffalse\n\\begin{tikzpicture}[overlay, remember picture, scale=.5]\n\\begin{axis}[ \nhide axis,\n%xtick=\\empty, ytick=\\empty,\nwidth=0.45\\linewidth,\n%width=3cm,\n%height=2.1cm,\n%scale only axis,\n%xmin=-0.6235,\n%xmax=-0.6186,\n%xtick={-0.623, -0.621, -0.619},\n%ymin=0.1651,\n%ymax=0.1655,\n%ytick={0.1651, 0.1653, 0.1655},\nxshift=2.25cm,yshift=5.75cm,\n]\n%Below the red parabola is defined\n\\addplot [\n    domain=-2:2, \n    samples=20, \n    color=red,\n]\n{0.797468 +  0.500000*x +  0.056369*x^2 };\n%Here the blue parabola is defined\n\\addplot [\n    domain=-2:2, \n    samples=20, \n    color=blue,\n    ]\n    {0.058594 +  0.500000*x +  0.750000*x^2 };\n%ReLU\n\\addplot [\n    domain=-2:2, \n    samples=20, \n    color=black,\n    ]\n    {max(0, x) };\n\\end{axis}\n\\end{tikzpicture}\n\\fi\n\n\\caption{ Results in the }\n\\label{fig1}\n\\end{figure}\n\n\\begin{figure}[ht]\n\\centering\n\n\\begin{tikzpicture}[remember picture]\n\\begin{axis}[ \n%legend pos=south east,\n%legend style={at={(0.5,-0.17)},anchor=north,legend cell align=left},\nlegend style={at={(0.5,+0.9)},anchor=north,},\nwidth=0.45\\linewidth, \nxtick={ -6, -4, -2, 0, 2,  4, 6 },\nyticklabels={}, \nat={(0.66\\linewidth,0)},\n]\n%Below the red parabola is defined\n\\addplot [\n    domain=-6:6, \n    samples=100, \n    color=red,\n]\n{1.1110537229 + 0.5*x + 0.054235537*x^2 };\n\\addlegendentry{$p_2^{lg}(x)$}\n%ReLU\n\\addplot [\n    domain=-6:6, \n    samples=100, \n    color=gray,\n    ]\n    { max(0, x) };\n\\addlegendentry{$\\texttt{ReLU}$};\n\\end{axis}\n\\end{tikzpicture}\n\n\\caption{ Results in the }\n\\label{fig2}\n\\end{figure}\nFrom the figure \\ref{fig1}, we can see that our polynomial are much the same as ReLU in the term of shape(slope), and that the least square polynomial doesn't even look like the ReLU funtion.\n\nA more flexiable way to generate teh polynomial approximation is to set add more  parameters to control the weight or propotion of the least square to slope gradial resulting polynomial. To take the $ReLU$  within the domain $[-L, +L]$ as a example, we could optimise the following function:\n\\begin{equation*}\n  \\begin{aligned}\nF(a, b, c)  =  \\lambda_0 \\cdot \\int_{-L}^{0} (0 - p_2^{lg}(x))^2  dx \n             + \\lambda_1 \\cdot \\int_{0}^{+L} (x - p_2^{lg}(x))^2  dx  \\\\\n             + \\lambda_2 \\cdot \\int_{-L}^{0} (0 - p_2^{lg}{'}(x))^2 dx \n             + \\lambda_3 \\cdot \\int_{0}^{+L} (1 - p_2^{lg}{'}(x))^2 dx , \n \\end{aligned}\n\\end{equation*}\nwhere $\\lambda_0$, $\\lambda_1$, $\\lambda_2$ and $\\lambda_3$ are four real number greater than zero to control the various weight propotion.\n\nAnother example is, supposing that we want to find a polynomial to approximate the relu over the domain $[-6, +6]$ such that it fit the ReLU very well at the both ends at the expense of losing some precsion round the center. In this case, we need to minimise the function (we just set $\\lambda_0 = \\lambda_1 = \\lambda_2 = \\lambda_3 = 1$ ): \n\\begin{equation*}\n  \\begin{aligned}\nF(a, b, c)  =&   \\int_{-6}^{-3} (0 - p_2^{lg}(x))^2  dx \n             +  \\int_{+3}^{+6} (x - p_2^{lg}(x))^2  dx  \n             +  \\int_{-6}^{-3} (0 - p_2^{lg}{'}(x))^2 dx \n             +  \\int_{+3}^{+6} (1 - p_2^{lg}{'}(x))^2 dx   \\\\\n            =& 3517.2a^2 + 132b^2 + 6c^2  + 54bc + 1917ab + 252ac - 607.5a - 78b - 27c + 12.\n \\end{aligned}\n\\end{equation*}\nSolving this  unconstrained optimization, we get the polynomial $p_2^{(1)} = 1.1110537229 + 0.5 \\cdot x + 0.054235537 \\cdot x^2 $. Figure \\ref{fig2} shows that $p_2^{(1)}$ is exactly what polynomial we want. \n\n\n\\section{Conclusion}\nYour conclusion here\nOur method to approximate activation function is much flexiable compared to least square method in the sense of ml.\nVouriac setting of parmpaters should result in polynomials of different shapes. \n%Bibliography\n\\bibliographystyle{unsrt}  \n\\bibliography{references}  \n\n\n\\end{document}\n", "meta": {"hexsha": "28c8efc7e96d8a3a1e1884954e491263726f610e", "size": 13272, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "on Polynomial Approximation of Activation Function/templatePRIME.tex", "max_stars_repo_name": "petitioner/PolynomialApproximation", "max_stars_repo_head_hexsha": "c0bebf057341b08f9409c50e4e5e9a6763a5d03e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "on Polynomial Approximation of Activation Function/templatePRIME.tex", "max_issues_repo_name": "petitioner/PolynomialApproximation", "max_issues_repo_head_hexsha": "c0bebf057341b08f9409c50e4e5e9a6763a5d03e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "on Polynomial Approximation of Activation Function/templatePRIME.tex", "max_forks_repo_name": "petitioner/PolynomialApproximation", "max_forks_repo_head_hexsha": "c0bebf057341b08f9409c50e4e5e9a6763a5d03e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.475, "max_line_length": 687, "alphanum_fraction": 0.6709614225, "num_tokens": 4532, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.43410442239194047}}
{"text": "\\chapter{The Cubic Nonlinear Schr\\\"{o}dinger Equation}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Background}\n\nThe cubic nonlinear Schr\\\"{o}dinger equation occurs in a variety of areas, including, quantum mechanics, nonlinear optics and surface water waves. A general introduction can be found at \\url{http://en.wikipedia.org/wiki/Schrodinger_equation} and \\url{http://en.wikipedia.org/wiki/Nonlinear_Schrodinger_equation}. A mathematical introduction to Schr\\\"{o}dinger equations can be found in Sulem and Sulem~\\cite{SulSul99} and Yang~\\cite{Yan10}. In this section we will introduce the idea of operator splitting and then go on to explain how this can be applied to the nonlinear Schr\\\"{o}dinger equation in one, two and three dimensions. In one dimension, one can show that the cubic nonlinear Schr\\\"{o}dinger equation is subcritical, and hence one has solutions which exist for all time. In two dimensions, it is $H^1$ critical, and so solutions may exhibit blow-up of the $H^1$ norm, that is the integral of the square of the gradient of the solution can become infinite in finite time.  Finally, in three dimensions, the nonlinear Schr\\\"{o}dinger equation is $L^2$ supercritical, and so the integral of the square of the solution can also become infinite in finite time. For an introduction to norms and Hilbert spaces, see a textbook on partial differential equations or analysis, such as Evans~\\cite{Eva10}, Linares and Ponce~\\cite{LinPon09}, Lieb and Loss~\\cite{LieLos03} or Renardy and Rogers~\\cite{RenRog04}. A question of interest is how this blow-up occurs and numerical simulations are often used to understand this; see Sulem and Sulem~\\cite{SulSul99} for examples of this. The cubic nonlinear Schr\\\"{o}dinger equation\\footnote{To simplify the presentation, we primarily consider the focusing cubic nonlinear Schr\\\"{o}dinger equation.} is given by\n\\begin{equation}\ni\\psi_t + \\Delta \\psi \\pm\\lvert \\psi \\rvert^2\\psi =0,\n\\end{equation}\nwhere $\\psi$ is the wave function and $\\Delta$ is the Laplacian operator, so in one dimension it is $\\partial_{xx}$, in two dimensions, $\\partial_{xx}+\\partial_{yy}$ and in three dimensions it is $\\partial_{xx}+\\partial_{yy}+\\partial_{zz}$. The $+$ corresponds to the focusing cubic nonlinear Schr\\\"{o}dinger equation and the $-$ corresponds to the defocusing cubic nonlinear Schr\\\"{o}dinger equation. This equation has many conserved quantities, including the ``mass'',\n\\begin{equation}\n\\int_{\\Omega}\\lvert\\psi\\rvert^2\\mathrm{d}^n\\bm x\n\\end{equation}\nand the ``energy'',\n\\begin{equation}\n\\int_{\\Omega}\\frac{1}{2}\\lvert\\nabla \\psi\\rvert^2\\mp\\frac{1}{4}\\lvert\\psi\\rvert^4\\mathrm{d}^n\\bm x\n\\end{equation}\nwhere $n$ is the dimension and $\\Omega$ is the domain of the solution. As explained by Klein~\\cite{Kle08}, these two quantities can provide useful checks on the accuracy of numerically generated solutions.\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Splitting}\n\nWe will consider a numerical method to solve this equation known as splitting. This method occurs in several applications, and is a useful numerical method when the equation can be split into two separate equations, each of which can either be solved exactly, or each part is best solved by a different numerical method. Introductions to splitting can be found in Holden et al.~\\cite{HolKarLieRis10}, McLachlan and Quispel~\\cite{McLQui02}, Thalhammer~\\cite{Tha08}, Shen, Tang and Wang~\\cite{SheTanWan11}, Weideman and Herbst~\\cite{WeiHer86} and Yang~\\cite{Yan10}, and also at \\url{http://en.wikipedia.org/wiki/Split-step_method}. For those interested in a comparison of time stepping methods for the nonlinear Schr\\\"{o}dinger equation, see Klein~\\cite{Kle08}. To describe the basic idea of the method, we consider an example given in Holden et al.~\\cite{HolKarRisTao11}, which is the ordinary differential equation,\n\\begin{equation}\\label{eq:SplitOde}\nu_t=u(u-1),\\quad u(t=0)=0.8.\n\\end{equation}\nWe can solve this equation relatively simply by separation of variables to find that\n\\begin{equation}\nu(t)=\\frac{4}{4+\\exp(t)}.\n\\end{equation}\nNow, an interesting observation is that we can also solve the equations $u_t=u^2$ and $u_t=-u$ individually. For the first we get that $u(t)=\\frac{u(0)}{1-tu(0)}$ and for the second we get that $u(t)=u(0)\\exp(-t)$. The principle behind splitting is to solve these two separate equations alternately for short periods of time. We will describe Strang splitting, although there are other forms of splitting, such as Godunov splitting and also additive splittings.  We will not describe these here, but refer you to the previously mentioned references, in particular Holden et al.~\\cite{HolKarLieRis10}. To understand how we can solve the differential equation using splitting, consider the linear ordinary differential equation\n\\begin{equation}\nu_t=u+2u,\\quad u(0)=1.\n\\end{equation}\nWe can first solve $p_t=p$ for a time $\\delta t/2$ and then using $q(0)=p(\\delta t/2)$, we solve $q_t=2q$ also for a time $\\delta t$ to get $q(\\delta t)$ and finally solve $r_t=r$ for a time $\\delta t/2$ with initial data $r(0)=q(\\delta t)$. Thus in this case $p(\\delta t)=\\exp(\\delta t/2)$, $q(\\delta t)=p(\\delta t/2)\\exp(2\\delta t)=\\exp(5\\delta t/2)$ and $u(\\delta t)\\approx r(\\delta t/2)=q(\\delta t)\\exp(\\delta t/2)=\\exp(3\\delta t)$, which in this case is the exact solution. One can perform a similar splitting for matrix differential equations. Consider solving $\\bm u_t = (\\bm A + \\bm B)\\bm u$, where $\\bm A$ and $\\bm B$ are $n\\times n$ matrices, the exact solution is $\\bm u=\\exp\\left((\\bm A + \\bm B) t\\right)\\bm u(t=0)$, and an approximate solution produced after one time step of splitting is $u(\\delta t)\\approx u(0)\\exp(\\bm A \\delta t)\\exp(\\bm B \\delta t)$, which is not in general equal to $u(t=0)\\exp\\left((\\bm A + \\bm B) \\delta t\\right)$ unless the matrices $\\bm A$ and $\\bm B$ commute\\footnote{That is$\\bm A\\bm B=\\bm B\\bm A$.}, and so the error in doing splitting in this case is of the form $(\\bm A \\bm B - \\bm B \\bm A)\\delta t$\\footnote{One can derive this by using the series expansion of the exponential function, $\\exp(\\bm A t)=\\sum_{n=0}^{\\infty}\\frac{(\\bm A t)^n}{n!}$, and subtracting $\\exp((\\bm A+\\bm B)\\delta t)$ from $\\exp(\\bm A \\delta t)\\exp(\\bm B \\delta t).$}. Listing \\ref{lst:OdeStrangMatlab} uses Matlab to demonstrate how to do splitting for eq.\\ \\eqref{eq:SplitOde}.\n\n\\lstinputlisting[style=matlab_style,label=lst:OdeStrangMatlab,caption={A Matlab program which uses Strang splitting to solve an ODE.}]{./CubicNonlinearSchrodinger/Programs/ODEsplittingStrang.m}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Exercises}\n\n\\begin{enumerate}\n\\item[1)] Modify the Matlab code to calculate the error at time 1 for several different choices of timestep. Numerically verify that Strang splitting is second order accurate.\n\\item[2)] Modify the Matlab code to use Godunov splitting where one solves $u1_t=u1$ for a time $\\delta t$ and then using $u1(\\delta t)$ as initial data solves $u2_t=2u2$ also for a time $\\delta t$ to get the approximation to $u(\\delta t)$. Calculate the error at time 1 for several different choices of timestep. Numerically verify that Godunov splitting is first order accurate.\n\\end{enumerate}\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Serial}\n\nFor the nonlinear Schr\\\"{o}dinger equation\n\\begin{equation}\ni\\psi_t\\pm\\lvert\\psi\\rvert^2\\psi+\\Delta\\psi=0, \\label{eq:NLS}\n\\end{equation}\nwe first solve\n\\begin{equation}\ni\\psi_t+\\Delta\\psi=0 \\label{eq:NLSsplit1}\n\\end{equation}\nexactly using the Fourier transform to get $\\psi(\\delta{t}/2,\\cdot)$. We then solve\n\\begin{equation}\ni\\psi_t\\pm\\lvert\\psi\\rvert^2\\psi=0  \\label{eq:NLSsplit2}\n\\end{equation}\nwith $\\psi(\\delta{t}/2,\\cdot)$ as initial data for a time step of $\\delta t$. As explained by Klein~\\cite{Kle08} and Thalhammer~\\cite{Tha08}, this can be solved exactly in real space because in eq.\\ \\eqref{eq:NLSsplit2}, $\\lvert \\psi \\rvert^2$ is a conserved quantity at every point in space and time. To show this, let $\\psi^*$ denote the complex conjugate of $\\psi$, so that\n\\begin{align}\n\\frac{\\mathrm{d}\\lvert \\psi \\rvert^2}{\\mathrm{d}t} &{} = \\psi^*\\frac{\\mathrm{d}\\psi}{\\mathrm{d}t} +\\frac{\\mathrm{d}\\psi^*}{\\mathrm{d}t}\\psi = \\psi^*\\left(\\pm i\\lvert\\psi\\rvert^2\\psi\\right)+\\left(\\pm i\\lvert\\psi\\rvert^2\\psi\\right)^*\\psi = 0.\n\\end{align}\nAnother half step using eq.\\ \\eqref{eq:NLSsplit1} is then computed using the solution produced by solving eq.\\ \\eqref{eq:NLSsplit2} to obtain the approximate solution at time $\\delta t$.  Example Matlab codes demonstrating splitting follow.\n\n\\subsection{Example Matlab Programs for the Nonlinear Schr\\\"{o}dinger Equation}\n\nThe program in listing \\ref{lst:NlsSplit1DMatlab} computes an approximation to an explicitly known exact solution to the focusing nonlinear Schr\\\"{o}dinger equation.   \n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit1DMatlab,caption={A Matlab program which uses Strang splitting to solve the one dimensional nonlinear Schr\\\"{o}dinger equation.}]{./CubicNonlinearSchrodinger/Programs/NLSsplitting1D.m}\n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit2DMatlab,caption={A Matlab program which uses Strang splitting to solve the two dimensional nonlinear Schr\\\"{o}dinger equation.}]{./CubicNonlinearSchrodinger/Programs/NLSsplitting2D.m}\n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit3DMatlab,caption={A Matlab program which uses Strang splitting to solve the three dimensional nonlinear Schr\\\"{o}dinger equation.}]{./CubicNonlinearSchrodinger/Programs/NLSsplitting3D.m}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Example One-Dimensional Fortran Program for the Nonlinear Schr\\\"{o}dinger Equation}\n\nBefore considering parallel programs, we need to understand how to write a Fortran code for the one-dimensional nonlinear Schr\\\"{o}dinger equation. Below is an example Fortran program followed by a Matlab plotting script to visualize the results. In compiling the Fortran program a standard Fortran compiler and the FFTW library are required. Since the commands required for this are similar to those in the makefile for the heat equation, we do not include them here.\n\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:For1dNLS,caption={A Fortran program to solve the 1D nonlinear Schr\\\"{o}dinger equation using splitting.}]{./CubicNonlinearSchrodinger/Programs/NLS1dFortran/NLSsplitting.f90}\n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit1DMatlabPlot,caption={A Matlab program which plots a numerical solution to a 1D nonlinear Schr\\\"{o}dinger equation generated by listing \\ref{lst:For1dNLS}.}]{./CubicNonlinearSchrodinger/Programs/NLS1dFortran/plotcreate.m}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Shared Memory Parallel: OpenMP}\n\nWe recall that OpenMP is a set of compiler directives that can allow one to easily make a Fortran, C or C++ program run on a shared memory machine -- that is a computer for which all compute processes can access the same globally addressed memory space. It allows for easy parallelization of serial programs which have already been written in one of the aforementioned languages.\n\nWe will demonstrate one form of parallelizm for the two dimensional nonlinear Schr\\\"{o}dinger equation in which we will parallelize the loops using OpenMP commands, but will use the threaded FFTW library to parallelize the transforms for us. The example programs are in listing \\ref{lst:For2dNlsOmp1},   A second method to parallelize the loops and Fast Fourier transforms explicitly using OpenMP commands is outlined in the exercises.\n\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:For2dNlsOmp1,caption={An OpenMP Fortran program to solve the 2D nonlinear Schr\\\"{o}dinger equation using splitting and threaded FFTW.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortranThreadFFT/NLSsplitting.f90}\n\n\\lstinputlisting[style=make_style,language=make,label=lst:Makefile2dNLSomp2,caption={An example makefile for compiling the OpenMP program in listing \\ref{lst:For2dNlsOmp1}. The example assumes one is using Flux and has loaded environments for the GCC compiler as well as the GCC compiled version of FFTW.  To use the Intel compiler to with this code, the OMP stack size needs to be explicitly set to be large enough.  If one is using the the PGI compilers instead of the GCC compilers, change the flag $-fopenmp$ to $-mp$.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortranThreadFFT/makefile}\n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit2DMatlabPlot,caption={A Matlab program which plots a numerical solution to a 2D nonlinear Schr\\\"{o}dinger equation generated by listing \\ref{lst:For2dNlsOmp1} or \\ref{lst:For2dNlsOmp2}.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortran/plotcreate.m}\n\n\\lstinputlisting[style=bash_style,language=bash,label=lst:Fluxsub2dNLSomp,caption={An example submission script for use on Flux. Change \\texttt{your\\_username} appropriately.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortran/fluxsubscript}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Exercises}\n\\begin{enumerate}\n\\item[1)] Download the example Matlab programs which accompany the pre-print by Klein, Muite and Roidot~\\cite{KleMuiRoi11}. Examine how the mass and energy for these Schr\\\"{o}dinger like equations are computed. Add code to check conservation of mass and energy to the Matlab programs for the nonlinear Schr\\\"{o}dinger equation.\n\\item[2)] The Gross-Pitaevskii equation\\footnote{\\url{http://en.wikipedia.org/wiki/Gross\\%E2\\%80\\%93Pitaevskii\\_equation}}  is given by\n\\begin{equation}\ni\\psi_t+\\lvert\\psi\\rvert^2\\psi +V(\\bm x)\\psi=0\n\\end{equation}\nwhere we will take\n\\begin{equation}\nV(\\bm x)=\\lVert \\bm x \\rVert^2_{l^2}=\\sum_{k=1}^Nx_k^2\n\\end{equation}\nin which $N$ is the space dimension. Show that this equation can be solved by splitting it into\n\\begin{equation}\ni\\psi_t+\\Delta\\psi=0 \\label{eq:GPsplit1}\n\\end{equation}\nand\n\\begin{equation}\ni\\psi_t+\\lvert\\psi\\rvert^2\\psi+V(\\bm x)\\psi=0.  \\label{eq:GPsplit2}\n\\end{equation}\nBe sure to explain how eqs.\\ \\eqref{eq:GPsplit1},\\eqref{eq:GPsplit2} are solved. \n\\item[3)] Modify the Matlab codes to solve the Gross-Pitaevskii equation in one, two and three dimensions.\n\\item[4)] Modify the serial Fortran codes to solve the Gross-Pitaevskii equation in one, two and three dimensions.\n\\item[5)] Listings \\ref{lst:For2dNlsOmp2} and \\ref{lst:Makefile2dNLSomp2} give an alternate method of parallelizing an OpenMP program. Make the program in listing \\ref{lst:For2dNlsOmp1} as efficient as possible and as similar to that in \\ref{lst:For2dNlsOmp2}, but without changing the parallelization strategy. Compare the speed of the two different programs. Try to vary the number of grid points and cores used. Which code is faster on your system? Why do you think this is?\n\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:For2dNlsOmp2,caption={An OpenMP Fortran program to solve the 2D nonlinear Schr\\\"{o}dinger equation using splitting.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortran/NLSsplitting.f90}\n\n\\lstinputlisting[style=make_style,language=make,label=lst:Makefile2dNLSomp2,caption={An example makefile for compiling the OpenMP program in listing \\ref{lst:For2dNlsOmp2}.  The example assumes one is using Flux and has loaded environments for the intel compiler as well as the Intel compiled version of FFTW.  If one is using the freely available GCC compilers instead of the Intel compilers, change the flag $-openmp$ to $-fopenmp$.}]{./CubicNonlinearSchrodinger/Programs/NLS2dFortran/makefile}\n\n\\item[6)] Modify the OpenMP Fortran codes to solve the Gross-Pitaevskii equation in two and three dimensions.\n\\item[7)] \\footnote{This question is due to a project by Joshua Kirschenheiter.} Some quantum hydrodynamic models for plasmas are very similar to the nonlinear Schr\\\"{o}dinger equation and can also be numerically approximated using splitting methods.  A model for a plasma used by Eliasson and Shukla~\\cite{EliShu09} is\n$$i\\Psi_t+\\Delta \\Psi + \\phi\\Psi - \\lvert \\Psi \\rvert^{4/D}\\Psi=0$$\nand \n$$ \\Delta \\phi =\\lvert \\Psi \\rvert^2-1,$$\nwhere $\\Psi$ is the, $\\phi$ the and $D$ the dimension, typically 1,2 or 3. This equation can be solved in a similar manner to the Davey-Stewartson equations in Klein, Muite and Roidot~\\cite{KleMuiRoi11}. Specifically, first solve\n$$i\\Psi_t+\\Delta \\Psi=0$$\nusing the Fourier transform so that\n$$\\Psi(\\delta t)=\\exp\\left(-i\\Delta^2 \\delta t\\right)\\Psi(0)$$\nThen solve\n$$\\phi=\\Delta^{-1}\\left(\\lvert \\Psi \\rvert^2-1\\right)$$\nusing the Fourier transform.  Finally, solve\n$$i\\Psi_t+ \\phi\\Psi - \\lvert \\Psi \\rvert^{4/D}\\Psi=0$$\nusing the fact that at each grid point $\\phi\\Psi - \\lvert \\Psi \\rvert^{4/D}$ is a constant, so the solution is\n$$\\Psi=\\exp\\left[ i\\left(\\phi-\\lvert \\Phi \\rvert^{4/D}\\right)\\delta t\\right].$$\n\\item[8)] \\footnote{This question is due to a project by Kohei Harada and Matt Warnez.}The operator splitting method can be used for equations other than the nonlinear Schr\\\"{o}dinger equation. Another equation for which operator splitting can be used is the complex Ginzburg-Landau equation\n$$\\frac{\\partial A}{\\partial t}=A+(1+i\\alpha)\\Delta A- (1+i\\beta)|A|^2A,$$\nwhere $A$ is a complex function, typically of one, two or three variables. An example one dimensional code is provided in listing \\ref{lst:Nls16thOrderMatlab}, based on an earlier finite difference code by Blanes, Casa, Chartier and Miura, using the methods described in Blanes et al.~\\cite{BlaCasChaMur12}. By using complex coefficients,  Blanes et al.~\\cite{BlaCasChaMur12} can create high order splitting methods for parabolic equations. Previous attempts to do this have failed since if only real coefficients are used, a backward step which is required for methods higher than second order leads to numerical instability. Modify the example code to solve the complex Ginzburg-Landau equation in one, two and then in three spatial dimensions. The linear part\n$$\\frac{\\partial A}{\\partial t}=A+(1+i\\alpha)\\Delta A$$\ncan be solved explicitly using the Fourier transform. To solve the nonlinear part, \n$$\\frac{\\partial A}{\\partial t}=- (1+i\\beta)|A|^2A$$\nconsider\n$$\\frac{\\partial |A|^2}{\\partial t}=\\frac{\\partial A}{\\partial t}A^*+\\frac{\\partial A^*}{\\partial t}A=2|A|^4$$\nand solve this exactly for $|A|^2$. To recover the phase, observe that\n$$\\frac{\\partial \\log(A)}{\\partial t}=- (1+i\\beta)|A|^2$$\nwhich can also be integrated explicitly since $|A|^2(t)$ is known.\n\n\\lstinputlisting[style=matlab_style,label=lst:Nls16thOrderMatlab,caption={A Matlab program which uses 16th order splitting to solve the cubic nonlinear Schr\\\"{o}dinger equation.}]{./CubicNonlinearSchrodinger/Programs/NLSsplitting1d16Order.m}\n\\end{enumerate}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Distributed Memory Parallel: MPI}\n\nFor this section, we will use the library 2DECOMP{\\&}FFT available from \\url{http://www.2decomp.org/index.html}. The website includes some examples which indicate how this library should be used, in particular the sample code at \\url{http://www.2decomp.org/case_study1.html} is a very helpful indication of how one converts a code that uses FFTW to one that uses MPI and the aforementioned library.  \n\nBefore creating a parallel MPI code using 2DECOMP{\\&}FFT, we will generate  a serial Fortran code that uses splitting to solve the 3D nonlinear Schr\\\"{o}dinger equation. Rather than using loop-based parallelization to do a sequence of one dimensional fast Fourier transforms, we will use FFTW's three dimensional FFT, so that the serial version and MPI parallel version have the same structure. The serial version is in listing \\ref{lst:For3dNls}. This file can be compiled in a similar manner to that in \\ref{lst:MakefileHeat}.\n\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:For3dNls,caption={A Fortran program to solve the 3D nonlinear Schr\\\"{o}dinger equation using splitting and FFTW.}]{./CubicNonlinearSchrodinger/Programs/NLS3dFortran/NLSsplitting.f90}\n\nIn comparison to the previous programs, the program in listing \\ref{lst:For3dNls} writes out its final data as a binary file. This is often significantly faster than writing out a text file, and the resulting file is usually much smaller in size. This is important when many such files are written and/or if individual files are large. Due to the formatting change, the binary file also needs to be read in slightly differently. The Matlab script in listing \\ref{lst:NlsSplit3DMatlabPlot} shows how to do this.\n\n\\lstinputlisting[style=matlab_style,label=lst:NlsSplit3DMatlabPlot,caption={A Matlab program which plots a numerical solution to a 3D nonlinear Schr\\\"{o}dinger equation generated by listings \\ref{lst:For3dNls} or \\ref{lst:For3dNlsMPI}.}]{./CubicNonlinearSchrodinger/Programs/NLS3dFortran/plotcreate.m}\n\nWe now modify the above code to use MPI and the library 2DECOMP{\\&}FFT.  The library 2DECOMP{\\&}FFT hides most of the details of MPI although there are a few commands which it is useful for the user to understand. These commands are:\n\\begin{itemize}\n\\item \\texttt{USE mpi} or \\texttt{INCLUDE 'mpif.h'} \n\\item \\texttt{MPI\\_INIT}\n\\item \\texttt{MPI\\_COMM\\_SIZE}\n\\item \\texttt{MPI\\_COMM\\_RANK}\n\\item \\texttt{MPI\\_FINALIZE}\n\\end{itemize}\n\nThe program is listed in listing \\ref{lst:For3dNlsMPI}, please compare this to the serial code in \\ref{lst:For3dNls}. The library 2DECOMP{\\&}FFT does a domain decomposition of the arrays so that separate parts of the arrays are on separate processors.  The library can also perform a Fourier transform on the arrays even though they are stored on different processors -- the library does all the necessary message passing and transpositions required to perform the Fourier transform. It should be noted that the order of the entries in the arrays after the Fourier transform is not necessarily the same as the order used by FFTW. However, the correct ordering of the entries is returned by the structure \\texttt{decomp} and so this structure is used to obtain starting and stopping entries for the loops. We assume that the library 2DECOMP{\\&}FFT has been installed in an appropriate location. \n\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:For3dNlsMPI,caption={A Fortran program to solve the 3D nonlinear Schr\\\"{o}dinger equation using splitting and 2DECOMP{\\&}FFT.}]{./CubicNonlinearSchrodinger/Programs/NLS3dFortranMPI/NLSsplitting.f90}\n\n%%%%%%%\n%Section\n%%%%%%%\n\\section{Exercises}\n\n\\begin{enumerate}\n\\item[1)] Write an MPI  code using 2DECOMP{\\&}FFT to solve the Gross-Pitaevskii equation in three dimensions.\n\\item[2)] Learn to use either VisIt (\\url{https://wci.llnl.gov/codes/visit/}) or Paraview (\\url{http://www.paraview.org/}) and write a script to visualize two and three dimensional output in a manner that is similar to the Matlab codes.\n\\end{enumerate}\n\n", "meta": {"hexsha": "3672e935482709a1a3b7bcf6b1ae50f26f81db70", "size": 22626, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CubicNonlinearSchrodinger/CubicNonlinearSchrodinger.tex", "max_stars_repo_name": "bcloutier/PSNM", "max_stars_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_stars_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2015-01-05T14:22:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T23:51:25.000Z", "max_issues_repo_path": "CubicNonlinearSchrodinger/CubicNonlinearSchrodinger.tex", "max_issues_repo_name": "bcloutier/PSNM", "max_issues_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_issues_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-12-29T12:35:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-01T07:31:32.000Z", "max_forks_repo_path": "CubicNonlinearSchrodinger/CubicNonlinearSchrodinger.tex", "max_forks_repo_name": "bcloutier/PSNM", "max_forks_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_forks_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_forks_count": 34, "max_forks_repo_forks_event_min_datetime": "2015-01-05T14:23:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T06:55:01.000Z", "avg_line_length": 106.7264150943, "max_line_length": 1753, "alphanum_fraction": 0.7703968885, "num_tokens": 6491, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583270090337583, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.4339875066120209}}
{"text": "\\section{Computational routines}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%      DENSE MATRIX SUM\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\clearpage\\subsection{psb\\_geaxpby --- General Dense Matrix Sum}\n\nThis subroutine is an interface to the computational kernel for\ndense matrix sum:\n\\[ y \\leftarrow  \\alpha\\> x+ \\beta y \\]\n%% where:\n%% \\begin{description}\n%% \\item[$x$] represents the global dense submatrix $x_{:, :1}$\n%% \\item[$y$] represents the global dense submatrix $y_{:, :}$\n%% \\end{description}\n\n\\fortinline| call psb_geaxpby(alpha, x, beta, y, desc_a, info)|\n%% \\syntax*{call psb\\_geaxpby}{alpha, x, beta, y, desc\\_a, info, n, jx, jy}\n\n%( calculating y <- alpha*x+beta*y )\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$x$, $y$, $\\alpha$, $\\beta$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real & psb\\_geaxpby \\\\\nLong Precision Real & psb\\_geaxpby \\\\\nShort Precision Complex & psb\\_geaxpby \\\\\nLong Precision Complex & psb\\_geaxpby \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90axpby}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[alpha] the scalar $\\alpha$.\\\\ Scope: {\\bf global} \\\\ Type: {\\bf\nrequired} \\\\ Intent: {\\bf in}.\\\\ Specified as: a number of the data\ntype indicated in Table~\\ref{tab:f90axpby}.\n\\item[x] the local portion of global dense matrix\n$x$.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type\nspecified in Table~\\ref{tab:f90axpby}.  The rank of $x$ must be the same of $y$.\n\\item[beta] the scalar $\\beta$.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a number of the data type indicated in Table~\\ref{tab:f90axpby}.\n\\item[y] the local portion of the global dense matrix\n$y$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\  containing numbers of the type\nindicated in Table~\\ref{tab:f90axpby}.  The rank of $y$ must be the same of $x$.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n%% \\item[n] number of columns in dense submatrices $x$ and $y$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ and $y$ are of rank 2.\\\\\n%% Default: \\fortinline|min(size(x,2),size(y,2))|.\\\\\n%% Specified as: an integer variable $n\\ge 0$.\n%% \\item[jx]  the column index of the global dense matrix $x$,\n%% identifying the first column of the submatrix $x$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ and $y$ are of rank 2.\\\\\n%% Default: $jx = 1$.\\\\\n%% Specified as: an integer variable $jx\\ge 1$.\n%% \\item[jy]  the column index of the global dense matrix $y$,\n%% identifying the first column of the submatrix $y$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ and $y$ are of rank 2.\\\\\n%% Default: $jy = 1$.\\\\\n%% Specified as: an integer variable $jy\\ge 1$.\n\n\\end{description}\n\n\\begin{description}\n\\item[\\bf On Return]\n\\item[y] the local portion of result submatrix $y$.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\ containing numbers of the type\nindicated in Table~\\ref{tab:f90axpby}.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       F90DOT PRODUCT\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\clearpage\\subsection{psb\\_gedot --- Dot Product}\n\nThis function computes dot product between two vectors $x$ and\n$y$.\\\\\nIf $x$ and $y$ are real vectors\nit computes dot-product as:\n\\[dot \\leftarrow x^T y\\]\nElse if $x$ and $y$ are complex vectors then it computes dot-product as:\n\\[dot \\leftarrow x^H y\\]\n%% where:\n%% \\begin{description}\n%% \\item[$x$] represents the global vector $x_{:,jx}$\n%% \\item[$y$] represents the global vector $y_{:,jy}$\n%% \\end{description}\n\n\\fortinline|psb_gedot(x, y, desc_a, info [,global])|\n%% \\syntax*{psb\\_gedot}{x, y, desc\\_a, info, jx, jy}\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$dot$, $x$, $y$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real & psb\\_gedot \\\\\nLong Precision Real & psb\\_gedot \\\\\nShort Precision Complex & psb\\_gedot \\\\\nLong Precision Complex & psb\\_gedot \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90dot}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$.\\\\\n%%  This function computes the location of the first element of\n%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90dot}. The rank of $x$ must be the same of $y$.\n\\item[y] the local portion of global dense matrix\n$y$. \\\\\n%% This function computes the location of the first element of\n%% local subarray used, based on $iy, jy$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90dot}. The rank of $y$ must be the same of $x$.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[global]  Specifies whether the computation should include the\n  global reduction across all processes.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf optional}.\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a logical scalar.\nDefault: \\fortinline|global=.true.|\\\\\n%% \\item[jx]  the column index of global dense matrix $x$,\n%% identifying the column of vector $x$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ and $y$ are of rank 2.\\\\\n%% Default: $jx = 1$.\\\\\n\n%% \\item[jy]  the column index of global dense matrix $y$,\n%% identifying the column of vector $y$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ and $y$ are of rank 2.\\\\\n%% Default: $jy = 1$.\\\\\n%% Specified as: an integer variable $jy\\ge 1$.\n\\item[\\bf On Return]\n\\item[Function value] is the dot product of vectors $x$ and $y$.\\\\\nScope: {\\bf global}  unless the optional variable\n\\fortinline|global=.false.| has been specified\\\\\nSpecified as: a number of the data type indicated in Table~\\ref{tab:f90dot}.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n{\\par\\noindent\\large\\bfseries Notes}\n\\begin{enumerate}\n\\item The computation of a global result requires a global\n  communication, which entails a significant overhead. It may be\n  necessary and/or advisable to compute multiple dot products at the same\n  time; in this case, it is possible to improve the runtime efficiency\n  by using the following scheme:\n  \\ifpdf\n  \\begin{minted}{fortran}\n  \tvres(1) = psb_gedot(x1,y1,desc_a,info,global=.false.)\n  \tvres(2) = psb_gedot(x2,y2,desc_a,info,global=.false.)\n  \tvres(3) = psb_gedot(x3,y3,desc_a,info,global=.false.)\n  \tcall psb_sum(ctxt,vres(1:3))\n  \\end{minted}\n  \\else\n  \\begin{lstlisting}\n    vres(1) = psb_gedot(x1,y1,desc_a,info,global=.false.)\n    vres(2) = psb_gedot(x2,y2,desc_a,info,global=.false.)\n    vres(3) = psb_gedot(x3,y3,desc_a,info,global=.false.)\n    call psb_sum(ctxt,vres(1:3))\n  \\end{lstlisting}\n  \\fi\n  In this way the global communication, which for small sizes is a\n  latency-bound operation, is invoked only once.\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       F90DOT PRODUCT\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\clearpage\\subsection{psb\\_gedots --- Generalized Dot Product}\n\nThis subroutine computes a series of  dot products among the columns of\ntwo dense matrices  $x$ and $y$:\n\\[ res(i) \\leftarrow x(:,i)^T y(:,i)\\]\nIf the matrices are complex, then the\nusual convention applies, i.e. the conjugate transpose of $x$ is\nused. If $x$ and $y$ are of rank one, then $res$ is a scalar, else it\nis a rank one array.\n\n\\fortinline| call psb_gedots(res, x, y, desc_a, info)|\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$res$, $x$, $y$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real & psb\\_gedots \\\\\nLong Precision Real & psb\\_gedots \\\\\nShort Precision Complex & psb\\_gedots \\\\\nLong Precision Complex & psb\\_gedots \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90mdot}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90mdot}. The rank of $x$ must be the same of $y$.\n\\item[y] the local portion of global dense matrix\n$y$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90mdot}. The rank of $y$ must be the same of $x$.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[\\bf On Return]\n\\item[res] is the dot product of vectors $x$ and $y$.\\\\\nScope: {\\bf global} \\\\\nIntent: {\\bf out}.\\\\\nSpecified as: a number or a rank-one array  of the data type indicated\nin Table~\\ref{tab:f90dot}.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       VECTOR INFINITY-NORM\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_normi --- Infinity-Norm of Vector}\n\nThis function computes\n the infinity-norm of a vector $x$.\\\\\nIf $x$ is a real  vector\nit computes infinity norm as:\n\\[ amax \\leftarrow \\max_i |x_i|\\]\nelse if $x$ is a complex vector then it computes the infinity-norm  as:\n\\[ amax \\leftarrow \\max_i {(|re(x_i)| + |im(x_i)|)}\\]\n%% where:\n%% \\begin{description}\n%% \\item[$x$] represents the global vector $x_{:,jx}$\n%% \\end{description}\n\n\\fortinline|psb_geamax(x, desc_a, info [,global])|\\\\\n\\fortinline|psb_normi(x, desc_a, info [,global])|\n%% \\syntax*{psb\\_geamax}{x, desc\\_a, info, jx}\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$amax$ & $x$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real& Short Precision Real & psb\\_geamax \\\\\nLong Precision Real&Long Precision Real & psb\\_geamax \\\\\nShort Precision Real&Short Precision Complex & psb\\_geamax \\\\\nLong Precision Real&Long Precision Complex & psb\\_geamax \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90amax}}\n\\end{table}\n\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. %% This function computes the location of the first element of\n%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90amax}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[global]  Specifies whether the computation should include the\n  global reduction across all processes.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf optional}.\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a logical scalar.\nDefault: \\fortinline|global=.true.|\\\\%% \\item[jx]  the column index of global dense matrix $x$,\n%% identifying the column of vector $x$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ is of rank 2.\\\\\n%% Default: $jx = 1$\\\\\n%% Specified as: an integer variable $jx\\ge 1$.\n\n\\item[\\bf On Return]\n\\item[Function value] is the infinity norm of vector $x$.\\\\\nScope: {\\bf global} unless the optional variable\n\\fortinline|global=.false.| has been specified\\\\\nSpecified as: a long precision real number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n{\\par\\noindent\\large\\bfseries Notes}\n\\begin{enumerate}\n\\item The computation of a global result requires a global\n  communication, which entails a significant overhead. It may be\n  necessary and/or advisable to compute multiple norms at the same\n  time; in this case, it is possible to improve the runtime efficiency\n  by using the following scheme:\n  \\ifpdf\n  \\begin{minted}{fortran}\n  \tvres(1) = psb_geamax(x1,desc_a,info,global=.false.)\n  \tvres(2) = psb_geamax(x2,desc_a,info,global=.false.)\n  \tvres(3) = psb_geamax(x3,desc_a,info,global=.false.)\n  \tcall psb_amx(ctxt,vres(1:3))\n  \\end{minted}\n  \\else\n  \\begin{lstlisting}\n    vres(1) = psb_geamax(x1,desc_a,info,global=.false.)\n    vres(2) = psb_geamax(x2,desc_a,info,global=.false.)\n    vres(3) = psb_geamax(x3,desc_a,info,global=.false.)\n    call psb_amx(ctxt,vres(1:3))\n  \\end{lstlisting}\n  \\fi\n  In this way the global communication, which for small sizes is a\n  latency-bound operation, is invoked only once.\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       Infinity norm\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\clearpage\\subsection{psb\\_geamaxs --- Generalized Infinity Norm}\n\nThis subroutine computes a series of  infinity norms on the columns of\na  dense matrix  $x$:\n\\[ res(i) \\leftarrow \\max_k |x(k,i)| \\]\n\n\\fortinline| call psb_geamaxs(res, x, desc_a, info)|\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$res$&  $x$& {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real    &Short Precision Real    & psb\\_geamaxs\\\\\nLong Precision Real    &Long Precision Real    & psb\\_geamaxs\\\\\nShort Precision Real &Short Precision Complex & psb\\_geamaxs\\\\\nLong Precision Real &Long Precision Complex & psb\\_geamaxs\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90mamax}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90mamax}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[\\bf On Return]\n\\item[res] is the infinity norm of the columns of $x$.\\\\\nScope: {\\bf global} \\\\\nIntent: {\\bf out}.\\\\\nSpecified as: a number or a rank-one array  of long precision real numbers.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       1-NORM OF A VECTOR\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_norm1 --- 1-Norm of Vector}\n\nThis function computes the 1-norm of a vector $x$.\\\\\nIf $x$ is a real vector\nit computes 1-norm as:\n\\[ asum \\leftarrow  \\|x_i\\|\\]\nelse if $x$ is a complex vector then it computes 1-norm  as:\n\\[ asum \\leftarrow \\|re(x)\\|_1 + \\|im(x)\\|_1\\]\n\n\n\\fortinline|psb_geasum(x, desc_a, info [,global])|\n\\fortinline|psb_norm1(x, desc_a, info [,global])|\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$asum$ & $x$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real&Short Precision Real & psb\\_geasum \\\\\nLong Precision Real&Long Precision Real & psb\\_geasum \\\\\nShort Precision Real&Short Precision Complex & psb\\_geasum \\\\\nLong Precision Real&Long Precision Complex & psb\\_geasum \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90asum}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. %% This function computes the location of the first element of\n%% local subarray used, based on the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90asum}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[global]  Specifies whether the computation should include the\n  global reduction across all processes.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf optional}.\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a logical scalar.\nDefault: \\fortinline|global=.true.|\\\\\n\n\\item[\\bf On Return]\n\\item[Function value] is the 1-norm of vector $x$.\\\\\nScope: {\\bf global} unless the optional variable\n\\fortinline|global=.false.| has been specified\\\\\nSpecified as: a long precision real  number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n{\\par\\noindent\\large\\bfseries Notes}\n\\begin{enumerate}\n\\item The computation of a global result requires a global\n  communication, which entails a significant overhead. It may be\n  necessary and/or advisable to compute multiple norms at the same\n  time; in this case, it is possible to improve the runtime efficiency\n  by using the following scheme:\n  \\ifpdf\n  \\begin{minted}{fortran}\n    vres(1) = psb_geasum(x1,desc_a,info,global=.false.)\n  \tvres(2) = psb_geasum(x2,desc_a,info,global=.false.)\n  \tvres(3) = psb_geasum(x3,desc_a,info,global=.false.)\n  \tcall psb_sum(ctxt,vres(1:3))\n  \\end{minted}\n  \\else\n  \\begin{lstlisting}\n    vres(1) = psb_geasum(x1,desc_a,info,global=.false.)\n    vres(2) = psb_geasum(x2,desc_a,info,global=.false.)\n    vres(3) = psb_geasum(x3,desc_a,info,global=.false.)\n    call psb_sum(ctxt,vres(1:3))\n  \\end{lstlisting}\n  \\fi\n  In this way the global communication, which for small sizes is a\n  latency-bound operation, is invoked only once.\n\\end{enumerate}\n\n\n\\clearpage\\subsection{psb\\_geasums --- Generalized 1-Norm of Vector}\n\nThis subroutine computes a series of  1-norms on the columns of\na  dense matrix  $x$:\n\\[ res(i) \\leftarrow \\max_k |x(k,i)| \\]\nThis function computes the 1-norm of a vector $x$.\\\\\nIf $x$ is a real vector\nit computes 1-norm as:\n\\[ res(i) \\leftarrow  \\|x_i\\|\\]\nelse if $x$ is a complex vector then it computes 1-norm  as:\n\\[ res(i) \\leftarrow \\|re(x)\\|_1 + \\|im(x)\\|_1\\]\n\n\n\\fortinline| call psb_geasums(res, x, desc_a, info)|\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$res$ & $x$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real&Short Precision Real & psb\\_geasums \\\\\nLong Precision Real&Long Precision Real & psb\\_geasums \\\\\nShort Precision Real&Short Precision Complex & psb\\_geasums \\\\\nLong Precision Real&Long Precision Complex & psb\\_geasums \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90asums}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. %% This function computes the location of the first element of\n%% local subarray used, based on the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90asums}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\n\\item[\\bf On Return]\n\\item[res] contains the 1-norm of (the columns of) $x$.\\\\\nScope: {\\bf global} \\\\\nIntent: {\\bf out}.\\\\\nShort as: a long precision real  number.\nSpecified as: a long precision real  number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       2-NORM OF A VECTOR\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_norm2 --- 2-Norm of Vector}\n\nThis function computes the 2-norm of a vector $x$.\\\\\nIf $x$ is a  real  vector\nit computes 2-norm as:\n\\[ nrm2 \\leftarrow \\sqrt{x^T x}\\]\nelse if $x$ is a complex vector then it computes 2-norm  as:\n\\[ nrm2 \\leftarrow \\sqrt{x^H x}\\]\n%% where:\n%% \\begin{description}\n%% \\item[$x$] represents the global vector $x_{:,jx}$\n%% \\end{description}\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$nrm2$ & $x$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real&Short Precision Real & psb\\_genrm2 \\\\\nLong Precision Real&Long Precision Real & psb\\_genrm2 \\\\\nShort Precision Real&Short Precision Complex & psb\\_genrm2 \\\\\nLong Precision Real&Long Precision Complex & psb\\_genrm2 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90nrm2}}\n\\end{table}\n\n\\fortinline|psb_genrm2(x, desc_a, info [,global])|\\\\\n\\fortinline|psb_norm2(x, desc_a, info [,global])|\\\\\n%% \\syntax*{psb\\_genrm2}{x, desc\\_a, info, jx}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$.%%  This function computes the location of the first element of\n%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90nrm2}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[global]  Specifies whether the computation should include the\n  global reduction across all processes.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf optional}.\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a logical scalar.\nDefault: \\fortinline|global=.true.|\\\\%% \\item[jx]  the column index of global dense matrix $x$,\n%% identifying the column of vector $x$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ is of rank 2.\\\\\n%% Default: $jx = 1$\\\\\n%% Specified as: an integer variable $jx\\ge 1$.\n\n\\item[\\bf On Return]\n\\item[Function Value] is the 2-norm of vector $x$.\\\\\nScope: {\\bf global} unless the optional variable\n\\fortinline|global=.false.| has been specified\\\\\nType: {\\bf required} \\\\\nSpecified as: a long precision real number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n{\\par\\noindent\\large\\bfseries Notes}\n\\begin{enumerate}\n\\item The computation of a global result requires a global\n  communication, which entails a significant overhead. It may be\n  necessary and/or advisable to compute multiple norms at the same\n  time; in this case, it is possible to improve the runtime efficiency\n  by using the following scheme:\n  \\begin{lstlisting}\n    vres(1) = psb_genrm2(x1,desc_a,info,global=.false.)\n    vres(2) = psb_genrm2(x2,desc_a,info,global=.false.)\n    vres(3) = psb_genrm2(x3,desc_a,info,global=.false.)\n    call psb_nrm2(ctxt,vres(1:3))\n  \\end{lstlisting}\n  In this way the global communication, which for small sizes is a\n  latency-bound operation, is invoked only once.\n\\end{enumerate}\n\n\n\n\\clearpage\\subsection{psb\\_genrm2s --- Generalized 2-Norm of Vector}\n\nThis subroutine computes a series of  2-norms on the columns of\na  dense matrix  $x$:\n\\[ res(i) \\leftarrow \\|x(:,i)\\|_2 \\]\n\n\n\\fortinline| call psb_genrm2s(res, x, desc_a, info)|\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\n$res$ & $x$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real&Short Precision Real & psb\\_genrm2s \\\\\nLong Precision Real&Long Precision Real & psb\\_genrm2s \\\\\nShort Precision Real&Short Precision Complex & psb\\_genrm2s \\\\\nLong Precision Real&Long Precision Complex & psb\\_genrm2s \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90nrm2s}}\n\\end{table}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[x] the local portion of global dense matrix\n$x$. %% This function computes the location of the first element of\n%% local subarray used, based on the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90nrm2s}.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\n\\item[\\bf On Return]\n\\item[res] contains the 1-norm of (the columns of) $x$.\\\\\nScope: {\\bf global} \\\\\nIntent: {\\bf out}.\\\\\nSpecified as: a long precision real  number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       1-NORM OF A MATRIX\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_norm1 --- 1-Norm of Sparse Matrix}\n\nThis function computes the 1-norm of a matrix $A$:\\\\\n\n\\[ nrm1 \\leftarrow \\|A\\|_1 \\]\nwhere:\n\\begin{description}\n\\item[$A$] represents the global matrix $A$\n\\end{description}\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$A$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real & psb\\_spnrm1 \\\\\nLong Precision Real & psb\\_spnrm1 \\\\\nShort Precision Complex & psb\\_spnrm1 \\\\\nLong Precision Complex & psb\\_spnrm1 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90nrm1}}\n\\end{table}\n\n\\begin{verbatim}\npsb_spnrm1(A, desc_a, info)\npsb_norm1(A, desc_a, info)\n\\end{verbatim}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[a] the local  portion of the global sparse matrix\n$A$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\spdata.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[\\bf On Return]\n\\item[Function value] is the 1-norm of sparse submatrix $A$.\\\\\nScope: {\\bf global} \\\\\nSpecified as: a long precision real number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       INFINITY-NORM OF A MATRIX\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_normi --- Infinity Norm of Sparse Matrix}\n\nThis function computes the infinity-norm of a matrix $A$:\\\\\n\n\\[ nrmi \\leftarrow \\|A\\|_\\infty \\]\nwhere:\n\\begin{description}\n\\item[$A$] represents the global matrix $A$\n\\end{description}\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$A$ & {\\bf Function}\\\\\n\\hline\nShort Precision Real & psb\\_spnrmi \\\\\nLong Precision Real & psb\\_spnrmi \\\\\nShort Precision Complex & psb\\_spnrmi \\\\\nLong Precision Complex & psb\\_spnrmi \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90nrmi}}\n\\end{table}\n\n\\begin{verbatim}\npsb_spnrmi(A, desc_a, info)\npsb_normi(A, desc_a, info)\n\\end{verbatim}\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[a] the local  portion of the global sparse matrix\n$A$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\spdata.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[\\bf On Return]\n\\item[Function value] is the infinity-norm of sparse submatrix $A$.\\\\\nScope: {\\bf global} \\\\\nSpecified as: a long precision real number.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       SPARSE MATRIX by DENSE MATRIX PRODUCT\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_spmm --- Sparse Matrix by Dense Matrix\n  Product}\n\nThis subroutine computes the Sparse Matrix by Dense Matrix Product:\n\n\\begin{equation}\ny \\leftarrow \\alpha  A  x + \\beta y\n\\label{eq:f90spmm_no_tra}\n\\end{equation}\n\\begin{equation}\ny \\leftarrow \\alpha  A^T x + \\beta y\n\\label{eq:f90spmm_tra}\n\\end{equation}\n\\begin{equation}\ny \\leftarrow \\alpha  A^H  x + \\beta y\n\\label{eq:f90spmm_con}\n\\end{equation}\n\nwhere:\n\\begin{description}\n\\item[$x$] is the global dense matrix $x_{:, :}$\n\\item[$y$] is the global dense matrix $y_{:, :}$\n\\item[$A$] is the global sparse matrix $A$\n\\end{description}\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$A$, $x$, $y$, $\\alpha$, $\\beta$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real & psb\\_spmm \\\\\nLong Precision Real & psb\\_spmm \\\\\nShort Precision Complex & psb\\_spmm \\\\\nLong Precision Complex & psb\\_spmm \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90spmm}}\n\\end{table}\n\n\\fortinline| call psb_spmm(alpha, a, x, beta, y, desc_a, info)|\\\\\n\\fortinline| call psb_spmm(alpha, a, x, beta, y,desc_a, info, trans, work)|\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[alpha] the scalar $\\alpha$.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a number of the data type indicated in\nTable~\\ref{tab:f90spmm}.\n\\item[a] the local portion of the sparse matrix\n$A$. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\spdata.\n\\item[x] the local portion of global dense matrix\n$x$. %% This subroutine computes the location of the first element of\n%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spmm}.  The rank of $x$ must be the same of $y$.\n\\item[beta] the scalar $\\beta$.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a number of the data type indicated in Table~\\ref{tab:f90spmm}.\n\\item[y] the local portion of global dense matrix\n$y$. %% This subroutine computes the location of the first element of\n%% local subarray used, based on $jy$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spmm}. The rank of $y$ must be the same of $x$.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[trans] indicates what kind of operation to perform.\n\\begin{description}\n\\item[trans = N] the operation is specified by equation \\ref{eq:f90spmm_no_tra}\n\\item[trans = T] the operation is specified by equation\n\\ref{eq:f90spmm_tra}\n\\item[trans = C] the operation is specified by equation\n\\ref{eq:f90spmm_con}\n\\end{description}\nScope: {\\bf global} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf in}.\\\\\nDefault: $trans = N$\\\\\nSpecified as: a character variable.\n%% \\item[k] number of columns in dense submatrices $x$ and $y$. \\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}\\\\\n%% Default: \\fortinline|min(size(x,2)-jx+1,size(y,2)-jy+1)|\\\\\n%% Specified as: an integer variable $ k \\ge 1$.\n%% \\item[jx]  the column index of global dense matrix $x$,\n%% identifying the column of vector $x$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $x$ is of rank 2.\\\\\n%% Default: $iy = 1$\\\\\n%% Specified as: an integer variable $jx\\ge 1$.\n%% \\item[jy]  the column index of global dense matrix $y$,\n%% identifying the column of vector $y$.\\\\\n%% Scope: {\\bf global} \\\\\n%% Type: {\\bf optional}; can only be present if $y$ is of rank 2.\\\\\n%% Default: $jy = 1$\\\\\n%% Specified as: an integer variable $jy\\ge 1$.\n\n\\item[work]  work array.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf inout}.\\\\\nSpecified as: a rank one array of the same type of $x$ and $y$ with\nthe TARGET attribute.\n\n\\item[\\bf On Return]\n\\item[y] the local portion of result matrix $y$.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as: an array of rank one or two\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spmm}.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       TRIANGULAR SYSTEM SOLVE\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_spsm --- Triangular System Solve}\n\nThis subroutine computes the Triangular System Solve:\n\n\\begin{eqnarray*}\ny &\\leftarrow& \\alpha  T^{-1}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha D  T^{-1}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha  T^{-1}  D x + \\beta y\\\\\ny &\\leftarrow& \\alpha  T^{-T}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha D  T^{-T}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha  T^{-T}  D x + \\beta y\\\\\ny &\\leftarrow& \\alpha  T^{-H}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha D  T^{-H}  x + \\beta y\\\\\ny &\\leftarrow& \\alpha  T^{-H}  D x + \\beta y\\\\\n\\end{eqnarray*}\n\n\nwhere:\n\\begin{description}\n\\item[$x$] is the global dense matrix $x_{:, :}$\n\\item[$y$] is the global dense matrix $y_{:, :}$\n\\item[$T$] is the global sparse block triangular submatrix $T$\n\\item[$D$] is the scaling diagonal matrix.\n\\end{description}\n\n\\fortinline| call psb_spsm(alpha, t, x, beta, y, desc_a, info)|\\\\\n\\fortinline| call psb_spsm(alpha, t, x, beta, y, desc_a, info, trans, unit, choice, diag, work)|\\\\\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{ll}\n\\hline\n$T$, $x$, $y$, $D$, $\\alpha$, $\\beta$ & {\\bf Subroutine}\\\\\n\\hline\nShort Precision Real & psb\\_spsm \\\\\nLong Precision Real & psb\\_spsm \\\\\nShort Precision Complex & psb\\_spsm \\\\\nLong Precision Complex & psb\\_spsm \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Data types\\label{tab:f90spsm}}\n\\end{table}\n\n\n\n\\begin{description}\n\\item[Type:] Synchronous.\n\\item[\\bf On Entry]\n\\item[alpha] the scalar $\\alpha$.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a number of the data type indicated in\nTable~\\ref{tab:f90spsm}.\n\\item[t] the global portion of the sparse matrix\n$T$.  \\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object type specified in\n\\S~\\ref{sec:datastruct}.\n\\item[x] the local portion of global dense matrix\n$x$. %% This subroutine computes the location of the first element of\n%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spsm}.  The rank of $x$ must be the same of $y$.\n\\item[beta] the scalar $\\beta$.\\\\\nScope: {\\bf global} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf in}.\\\\\nSpecified as: a number of the data type indicated in Table~\\ref{tab:f90spsm}.\n\\item[y] the local portion of global dense matrix\n$y$. %% This subroutine computes the location of the first element of\n%% local subarray used, based on $jy$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as:  a rank one or two array or an object of type \\vdata\\\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spsm}. The rank of $y$ must be the same of $x$.\n\\item[desc\\_a] contains data structures for communications.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required}\\\\\nIntent: {\\bf in}.\\\\\nSpecified as: an object of type \\descdata.\n\\item[trans] specify with {\\em unitd} the operation to perform.\n\\begin{description}\n\\item[trans = 'N'] the operation is with no transposed matrix\n\\item[trans = 'T'] the operation is with transposed matrix.\n\\item[trans = 'C'] the operation is with conjugate transposed matrix.\n\\end{description}\nScope: {\\bf global} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf in}.\\\\\nDefault: $trans = N$\\\\\nSpecified as: a character variable.\n\\item[unitd] specify with {\\em trans} the operation to perform.\n\\begin{description}\n\\item[unitd = 'U'] the operation is with no scaling\n\\item[unitd = 'L'] the operation is with left scaling\n\\item[unitd = 'R'] the operation is with right scaling.\n\\end{description}\nScope: {\\bf global} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf in}.\\\\\nDefault: $unitd = U$\\\\\nSpecified as: a character variable.\n\\item[choice] specifies the update of overlap elements to be performed\n  on exit:\n\\begin{description}\n\\item \\fortinline|psb_none_|\n\\item \\fortinline|psb_sum_|\n\\item \\fortinline|psb_avg_|\n\\item \\fortinline|psb_square_root_|\n\\end{description}\nScope: {\\bf global} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf in}.\\\\\nDefault: \\fortinline|psb_avg_|\\\\\nSpecified as: an integer variable.\n\\item[diag] the diagonal scaling matrix.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf in}.\\\\\nDefault: $diag(1) = 1 (no scaling)$\\\\\nSpecified as: a rank one  array containing numbers of the type\nindicated in Table~\\ref{tab:f90spsm}.\n\\item[work] a work array. \\\\\nScope: {\\bf local} \\\\\nType: {\\bf optional}\\\\\nIntent: {\\bf inout}.\\\\\nSpecified as: a rank one array of the same type of $x$ with the\nTARGET attribute.\n\n\\item[\\bf On Return]\n\\item[y] the local portion of global dense matrix\n$y$. %% This subroutine computes the location of the first element of\n%% local subarray used, based on $jy$ and the field $matrix\\_data$ of $desc\\_a$ .\n\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf inout}.\\\\\nSpecified as: an array of rank one or two\ncontaining numbers of type specified in\nTable~\\ref{tab:f90spsm}.\n\\item[info] Error code.\\\\\nScope: {\\bf local} \\\\\nType: {\\bf required} \\\\\nIntent: {\\bf out}.\\\\\nAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%       VECTOR VECTOR OPERATIONS\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\clearpage\\subsection{psb\\_gemlt --- Entrywise Product}\n\nThis function computes the entrywise product between two vectors $x$ and\n$y$\n\\[dot \\leftarrow x(i) y(i).\\]\n\n\\fortinline|psb_gemlt(x, y, desc_a, info)|\n\n%% \\syntax*{psb\\_gedot}{x, y, desc\\_a, info, jx, jy}\n\\begin{table}[h]\n\t\\begin{center}\n\t\t\\begin{tabular}{ll}\n\t\t\t\\hline\n\t\t\t$dot$, $x$, $y$ & {\\bf Function}\\\\\n\t\t\t\\hline\n\t\t\tShort Precision Real & psb\\_gemlt \\\\\n\t\t\tLong Precision Real & psb\\_gemlt \\\\\n\t\t\tShort Precision Complex & psb\\_gemlt \\\\\n\t\t\tLong Precision Complex & psb\\_gemlt \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{Data types\\label{tab:f90mlt}}\n\\end{table}\n\n\\begin{description}\n\t\\item[Type:] Synchronous.\n\t\\item[\\bf On Entry]\n\t\\item[x] the local portion of global dense vector\n\t$x$.\\\\\n\t%%  This function computes the location of the first element of\n\t%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as:  an object of type \\vdata\\\n\tcontaining numbers of type specified in\n\tTable~\\ref{tab:f90dot}.\n\t\\item[y] the local portion of global dense vector\n\t$y$. \\\\\n\t%% This function computes the location of the first element of\n\t%% local subarray used, based on $iy, jy$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as:  an object of type \\vdata\\\n\tcontaining numbers of type specified in\n\tTable~\\ref{tab:f90dot}.\n\t\\item[desc\\_a] contains data structures for communications.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required}\\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as: an object of type \\descdata.\n\t\\item[\\bf On Return]\n\t\\item[y] the local portion of result submatrix $y$.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf inout}.\\\\\n\tSpecified as: an object of type \\vdata\\ containing numbers of the type\n\tindicated in Table~\\ref{tab:f90mlt}.\n\t\\item[info] Error code.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf out}.\\\\\n\tAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\\clearpage\\subsection{psb\\_gediv --- Entrywise Division}\n\nThis function computes the entrywise division between two vectors $x$ and\n$y$\n\\[/ \\leftarrow x(i)/y(i).\\]\n\n\\fortinline|psb_gediv(x, y, desc_a, info, [flag)|\n\n%% \\syntax*{psb\\_gedot}{x, y, desc\\_a, info, jx, jy}\n\\begin{table}[h]\n\t\\begin{center}\n\t\t\\begin{tabular}{ll}\n\t\t\t\\hline\n\t\t\t$/$, $x$, $y$ & {\\bf Function}\\\\\n\t\t\t\\hline\n\t\t\tShort Precision Real & psb\\_gediv \\\\\n\t\t\tLong Precision Real & psb\\_gediv \\\\\n\t\t\tShort Precision Complex & psb\\_gediv \\\\\n\t\t\tLong Precision Complex & psb\\_gediv \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{Data types\\label{tab:f90div}}\n\\end{table}\n\n\\begin{description}\n\t\\item[Type:] Synchronous.\n\t\\item[\\bf On Entry]\n\t\\item[x] the local portion of global dense vector\n\t$x$.\\\\\n\t%%  This function computes the location of the first element of\n\t%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as:  an object of type \\vdata\\\n\tcontaining numbers of type specified in\n\tTable~\\ref{tab:f90dot}.\n\t\\item[y] the local portion of global dense vector\n\t$y$. \\\\\n\t%% This function computes the location of the first element of\n\t%% local subarray used, based on $iy, jy$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as:  an object of type \\vdata\\\n\tcontaining numbers of type specified in\n\tTable~\\ref{tab:f90dot}.\n\t\\item[desc\\_a] contains data structures for communications.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required}\\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as: an object of type \\descdata.\n\t\\item[flag] check if any of the $y(i) = 0$, and in case returns error halting the computation.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf optional}\n\tIntent: {\\bf in}.\\\\\n\tSpecified as: the logical value \\fortinline|flag=.true.|\n\t\\item[\\bf On Return]\n\t\\item[x] the local portion of result submatrix $x$.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf inout}.\\\\\n\tSpecified as: an object of type \\vdata\\ containing numbers of the type\n\tindicated in Table~\\ref{tab:f90mlt}.\n\t\\item[info] Error code.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf out}.\\\\\n\tAn integer value; 0 means no error has been detected.\n\\end{description}\n\n\\clearpage\\subsection{psb\\_geinv --- Entrywise Inversion}\n\nThis function computes the entrywise inverse of a vector $x$ and puts it into\n$y$\n\\[/ \\leftarrow 1/x(i).\\]\n\n\\fortinline|psb_geinv(x, y, desc_a, info, [flag)|\n\n%% \\syntax*{psb\\_gedot}{x, y, desc\\_a, info, jx, jy}\n\\begin{table}[h]\n\t\\begin{center}\n\t\t\\begin{tabular}{ll}\n\t\t\t\\hline\n\t\t\t$/$, $x$, $y$ & {\\bf Function}\\\\\n\t\t\t\\hline\n\t\t\tShort Precision Real & psb\\_geinv \\\\\n\t\t\tLong Precision Real & psb\\_geinv \\\\\n\t\t\tShort Precision Complex & psb\\_geinv \\\\\n\t\t\tLong Precision Complex & psb\\_geinv \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{Data types\\label{tab:f90inv}}\n\\end{table}\n\n\\begin{description}\n\t\\item[Type:] Synchronous.\n\t\\item[\\bf On Entry]\n\t\\item[x] the local portion of global dense vector\n\t$x$.\\\\\n\t%%  This function computes the location of the first element of\n\t%% local subarray used, based on $jx$ and the field $matrix\\_data$ of $desc\\_a$ . \\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as:  an object of type \\vdata\\\n\tcontaining numbers of type specified in\n\tTable~\\ref{tab:f90dot}.\n\t\\item[desc\\_a] contains data structures for communications.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required}\\\\\n\tIntent: {\\bf in}.\\\\\n\tSpecified as: an object of type \\descdata.\n\t\\item[flag] check if any of the $x(i) = 0$, and in case returns error halting the computation.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf optional}\n\tIntent: {\\bf in}.\\\\\n\tSpecified as: the logical value \\fortinline|flag=.true.|\n\t\\item[\\bf On Return]\n\t\\item[y] the local portion of result submatrix $x$.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf out}.\\\\\n\tSpecified as: an object of type \\vdata\\ containing numbers of the type\n\tindicated in Table~\\ref{tab:f90inv}.\n\t\\item[info] Error code.\\\\\n\tScope: {\\bf local} \\\\\n\tType: {\\bf required} \\\\\n\tIntent: {\\bf out}.\\\\\n\tAn integer value; 0 means no error has been detected.\n\\end{description}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"userguide\"\n%%% End:\n", "meta": {"hexsha": "7877f6890d1ca2a113fad899b5d645dbd390459e", "size": 45358, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/psbrout.tex", "max_stars_repo_name": "sfilippone/psblas3", "max_stars_repo_head_hexsha": "7c3852109f86880f609a34415c4d04c8d059a50e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2017-07-12T13:12:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T01:05:39.000Z", "max_issues_repo_path": "docs/src/psbrout.tex", "max_issues_repo_name": "sfilippone/psblas3", "max_issues_repo_head_hexsha": "7c3852109f86880f609a34415c4d04c8d059a50e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2017-10-26T07:13:30.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T11:44:12.000Z", "max_forks_repo_path": "docs/src/psbrout.tex", "max_forks_repo_name": "sfilippone/psblas3", "max_forks_repo_head_hexsha": "7c3852109f86880f609a34415c4d04c8d059a50e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2017-08-18T18:41:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-06T21:12:32.000Z", "avg_line_length": 31.2813793103, "max_line_length": 99, "alphanum_fraction": 0.6694739627, "num_tokens": 14022, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4339875009477028}}
{"text": "         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n         % Information sheet for the Matlab lab - Maths 6111 %\n         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[10pt]{article} \n\\input ma_no_html_header\n\n\\usepackage{color}\n\\usepackage{hyperref}\n\\hypersetup{breaklinks=true,colorlinks=true}\n%\\input ma_header\n\\setlength{\\parindent}{0pt}\n\\pagestyle{myheadings}\n% \\markright{\n% \\protect {\\protect \\epsfxsize=0.2 true cm \\protect \\epsffile {dolph.line.eps}}\n% \\it Maths 3018/6111 - Numerical methods \\hfill}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{document}\n\n\\thispagestyle{empty}\n\\begin{center}\n\\textbf{\\Large Maths 3018/6111 - Numerical Methods \\\\*[8mm]\nWorksheet 4 - Solutions}\\\\*[.8cm]\n\\end{center}\n\n\\section*{Theory}\n\n\\begin{enumerate}\n\\item Convert the ODE\n  \\begin{equation*}\n    y''' + x y'' + 3 y' + y = e^{-x}\n  \\end{equation*}\n  into a first order system of ODEs.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  Step by step we introduce\n  \\begin{align*}\n    u & = y' \\\\\n    v & = u' \\\\\n      & = y''.\n  \\end{align*}\n  We can therefore write the ODE into a system of ODEs. The first\n  order ODEs for $y$ and $u$ are given by the definitions above. The\n  ODE for $v$ is given from the original equation, substituting in the\n  definition of $u$ where appropriate, to get\n  \\begin{align*}\n    \\begin{pmatrix}\n      y \\\\ u \\\\ v\n    \\end{pmatrix}' & =\n    \\begin{pmatrix}\n      u \\\\ v \\\\ e^{-x} - x y'' - 3 y' - y\n    \\end{pmatrix} \\\\\n    & =\n    \\begin{pmatrix}\n      u \\\\ v \\\\ e^{-x} - x v - 3 u - y\n    \\end{pmatrix}.\n  \\end{align*}\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item Show by Taylor expansion that the backwards differencing\n  estimate of $f'(x)$,\n  \\begin{equation*}\n    f'(x) \\simeq \\frac{f(x) - f(x-h)}{h}\n  \\end{equation*}\n  is first order accurate.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  We have the Taylor series expansion of $f(x-h)$ about $x$ is\n  \\begin{equation*}\n    f(x-h) = f(x) - h f'(x) + \\frac{h^2}{2!} f''(x) + {\\cal O}(h^3).\n  \\end{equation*}\n  Substituting this in to the backwards difference formula we find\n  \\begin{align*}\n    \\frac{f(x) - f(x-h)}{h} & = \\frac{f(x) - f(x) + h f'(x) -\n      \\frac{h^2}{2!} f''(x) + {\\cal O}(h^3)}{h} \\\\\n    & = f'(x) - \\frac{h}{2!} f''(x) + {\\cal O}(h^2).\n  \\end{align*}\n  Therefore the difference between the exact derivative $f'$ and the\n  backwards difference estimate is $\\propto h$ and hence the finite\n  difference estimate is first order accurate.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item Use Taylor expansion to derive a symmetric or central difference\n  estimate of $f^{(4)}(x)$ on a grid with spacing $h$.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  For this we need the Taylor expansions\n  \\begin{align*}\n    f(x + h) & = f(x) + h f^{(1)}(x) + \\frac{h^2}{2!} f^{(2)}(x) +\n    \\frac{h^3}{3!} f^{(3)}(x) + \\frac{h^4}{4!} f^{(4)}(x) +\n    \\frac{h^5}{5!} f^{(5)}(x) + \\dots \\\\\n    f(x - h) & = f(x) - h f^{(1)}(x) + \\frac{h^2}{2!} f^{(2)}(x) -\n    \\frac{h^3}{3!} f^{(3)}(x) + \\frac{h^4}{4!} f^{(4)}(x) -\n    \\frac{h^5}{5!} f^{(5)}(x) + \\dots \\\\\n    f(x + 2 h) & = f(x) + 2 h f^{(1)}(x) + \\frac{4 h^2}{2!} f^{(2)}(x) +\n    \\frac{8 h^3}{3!} f^{(3)}(x) + \\frac{16 h^4}{4!} f^{(4)}(x) +\n    \\frac{32 h^5}{5!} f^{(5)}(x) + \\dots \\\\\n    f(x - 2 h) & = f(x) - 2 h f^{(1)}(x) + \\frac{4 h^2}{2!} f^{(2)}(x) -\n    \\frac{8 h^3}{3!} f^{(3)}(x) + \\frac{16 h^4}{4!} f^{(4)}(x) -\n    \\frac{32 h^5}{5!} f^{(5)}(x) + \\dots \n  \\end{align*}\n  By a central or symmetric difference estimate we mean that the\n  coefficient of $f(x \\pm n h)$ should have the same magnitude. By\n  comparison with central difference estimates for first and second\n  derivatives we see that for odd order derivatives the coefficients\n  should have opposite signs and for even order the same sign.\n\n  So we write our estimate as\n  \\begin{equation*}\n    f^{(4)}(x) \\simeq A f(x) + B \\left( f(x + h) + f(x - h) \\right)\n    + C \\left( f(x + 2 h) +  f(x - 2 h) \\right)\n  \\end{equation*}\n  and we then need to constrain the coefficients $A, B, C$. By looking\n  at terms proportional to $h^s$ we see\n  \\begin{align*}\n    h^0: && 0 & = A + 2 B + 2 C \\\\\n    h^1: && 0 & = 0 \\\\\n    h^2: && 0 & = B + 4 C \\\\\n    h^3: && 0 & = 0 \\\\\n    h^4: && \\frac{1}{h^4} & = \\frac{B}{12} + \\frac{16 C}{12}. \n  \\end{align*}\n  This gives three constraints on our three unknowns so we cannot go\n  to higher order. Solving the equations gives\n  \\begin{equation*}\n    A = \\frac{6}{h^4}, \\qquad B = -\\frac{4}{h^4}, \\qquad C =\n    \\frac{1}{h^4}.\n  \\end{equation*}\n  Writing it out in obvious notation we have\n  \\begin{equation*}\n    f_1^{(4)} = \\frac{1}{h^4} \\left( 6 f_i - 4 (f_{i+1} + f_{i-1}) +\n      (f_{i+2} + f_{i-2}) \\right).\n  \\end{equation*}\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item State the convergence rate of Euler's method and the\n  Euler predictor-corrector method.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  Euler's method converges as $h$ and the predictor-corrector method\n  as $h^2$.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item Explain when multistage methods such as Runge-Kutta methods are useful.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  Multistage methods require only one vector of initial data, which\n  must be provided to completely specify the IVP; that is, the method\n  is self-starting. It is also easy to adapt a multistage method to\n  use variable step sizes; that is, to make the algorithm adaptive\n  depending on local error estimates in order to keep the global error\n  within some tolerance. Finally, it is relatively easy to\n  theoretically show convergence. Combining this we see that\n  multistage methods are useful as generic workhorse algorithms and in\n  cases where the function defining the IVP may vary widely in\n  behaviour, so that adaptive algorithms are required.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n\\item{} [3018 only] Explain the power method for finding the largest\n  eigenvalue of a matrix. In particular, explain why it is simpler to\n  find the absolute value, and how to find the phase information.\n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  % \n  The idea behind the power method is that most easily seen by writing\n  out a generic vector ${\\bf x}$ in terms of the eigenvectors of the\n  matrix $A$ whose eigenvalues we wish to find,\n  \\begin{equation*}\n    {\\bf x} = \\sum_{i=1}^N a_i {\\bf e}_i,\n  \\end{equation*}\n  where we assume that the eigenvectors are ordered such that the\n  associated eigenvalues have the order $|\\lambda_1| > |\\lambda_2| \\ge\n  |\\lambda_3| \\ge \\dots \\ge |\\lambda_N|$. Note that we always assume\n  that there is a unique eigenvalue $\\lambda_1$ with largest\n  magnitude. \n\n  We then note that multiplying this generic vector by the matrix $A$\n  a number of times gives\n  \\begin{equation*}\n    A^k {\\bf x} = \\lambda_1^k \\sum_{i=1}^n a_i \\left(\n      \\frac{\\lambda_i}{\\lambda_1} \\right)^k {\\bf e}_i.\n  \\end{equation*}\n  We then note that, for $i \\ne 1$, the ratio of the eigenvalues\n  $(\\lambda_i/\\lambda_1)^k$ must tend to zero as $k \\rightarrow\n  \\infty$. Therefore in the limit we will ``pick out'' $\\lambda_1$. \n\n  Of course, to actually get the eigenvalue itself we have to\n  essentially divide two vectors. That is, we define a sequence ${\\bf\n    x}^{(k)}$ where the initial value ${\\bf x}^{(0)}$ is arbitrary and\n  at each step we multiply by $A$, so that\n  \\begin{equation*}\n    {\\bf x}^{(k)} = A^k {\\bf x}^{(0)}.\n  \\end{equation*}\n  It follows that we can straightforwardly get $\\lambda_1$ by looking\n  at ``the ratio of successive iterations''. E.g.,\n  \\begin{equation*}\n    \\lim_{k \\rightarrow \\infty} \\frac{\\| {\\bf x}^{(k+1)} \\|}{\\| {\\bf\n        x}^{(k)} \\|} = | \\lambda_1 |.\n  \\end{equation*}\n\n  This only gives information about the magnitude as we have used the\n  simplest way of getting from a vector to a real number, the absolute\n  value. To retain information about the phase we need to replace the\n  absolute value of the vectors with some linear functional such as\n  the sum of the coefficients. \n  % \n  \\begin{center}\n    \\rule{0.9\\textwidth}{.1pt}\n  \\end{center}\n  %\n\\end{enumerate}\n\n\\end{document}\n\n", "meta": {"hexsha": "355c0e62969fc5eb5a2ac528c71085f767dea42c", "size": 8518, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Worksheets/Worksheet4_Solutions.tex", "max_stars_repo_name": "alistairwalsh/NumericalMethods", "max_stars_repo_head_hexsha": "fa10f9dfc4512ea3a8b54287be82f9511858bd22", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-01T09:15:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T09:15:04.000Z", "max_issues_repo_path": "Worksheets/Worksheet4_Solutions.tex", "max_issues_repo_name": "indranilsinharoy/NumericalMethods", "max_issues_repo_head_hexsha": "989e0205565131057c9807ed9d55b6c1a5a38d42", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Worksheets/Worksheet4_Solutions.tex", "max_forks_repo_name": "indranilsinharoy/NumericalMethods", "max_forks_repo_head_hexsha": "989e0205565131057c9807ed9d55b6c1a5a38d42", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-13T02:58:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-13T02:58:54.000Z", "avg_line_length": 34.4858299595, "max_line_length": 80, "alphanum_fraction": 0.599319089, "num_tokens": 2989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7772998560157665, "lm_q1q2_score": 0.4339874923066022}}
{"text": "\\chapter{Scientific Background}\n\nThis chapter can be used as your literature reveiw chapter and to include any\ninformation on scientific theories that are particularly relevant to your\nresearch. Here is an example of and equation.\n%\n\\begin{equation}\n    F_{es} = -\\frac{1}{2} \\int \\epsilon(\\mathbf{r}) \\mathbf{E}^2(\\mathbf{r}) dr\n    \\label{esfnrg}\n\\end{equation}\n%\nwhere $\\epsilon(\\mathbf{r})$ is the dielectric constant at position\n$\\mathbf{r}$ and $\\mathbf{E}(\\mathbf{r})$ is the electric field at the same\nposition. The equation can be referenced like this \\ref{esfnrg}.\n", "meta": {"hexsha": "b1dd985466ab5c5a46678fbe2e9052f5fc8cc7f2", "size": 575, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "body/manuscript-style/chapter2.tex", "max_stars_repo_name": "TJLW/UARK-Thesis-Disertation-LaTex-Template", "max_stars_repo_head_hexsha": "547fec9d24f9d81d31c8628ceabe499acb022443", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "body/manuscript-style/chapter2.tex", "max_issues_repo_name": "TJLW/UARK-Thesis-Disertation-LaTex-Template", "max_issues_repo_head_hexsha": "547fec9d24f9d81d31c8628ceabe499acb022443", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "body/manuscript-style/chapter2.tex", "max_forks_repo_name": "TJLW/UARK-Thesis-Disertation-LaTex-Template", "max_forks_repo_head_hexsha": "547fec9d24f9d81d31c8628ceabe499acb022443", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3333333333, "max_line_length": 79, "alphanum_fraction": 0.7373913043, "num_tokens": 168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.43398748942623516}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{makeidx}\n\\usepackage{graphicx}\n\\usepackage{lmodern}\n\\usepackage{url}\n\\usepackage{bm}\n\\usepackage{booktabs}\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\\author{Mudathir Mahgoub}\n\\title{Project proposal}\n\\begin{document}\n\n\\maketitle\n\n\\section{Solver for propositional dynamic logic formulas}\nThe idea of the project is to implement a solver for formulas in propositional dynamic logic (PDL). The input would be a formula in PDL and optionally a kripke frame for that formula. The output result is either \\textit{unsat}, \\textit{sat} or \\textit{unknown}. To check the validity of a formula, the input would be its negation, and it is valid if the result is \\textit{unsat}. If a kripke frame is given, the result scope would be restricted to this kripke frame. Otherwise, the result scope would be all kripke frames. \n\n\nThe project is primarily code and would use the SMT solver CVC4 as a back end and apply the relation theory to implement the semantics of PDL. The project would import CVC4 abstract syntax tree (AST) for relations from another project that I am working on (Alloy2SMT translator\\footnote{\\url{https://github.com/CVC4/org.alloytools.alloy/tree/cvc4/alloy2smt}}) which supports type checking and SMT models parsing, albeit it needs some refactoring to be more generic.  For this project I would write a translator from PDL AST to CVC4 AST and display back the SMT models returned from CVC4 as Kripke frames and dot files for visualization using software like graphvis.\n\n\\section{Progress so far}\n\nSince CVC4 AST is written in Java, I am using Java for this project along with  gradle\\footnote{\\url{https://github.com/mudathirmahgoub/pdl}}. I have written an ANTLR4 grammar for PDL following the syntax in chapter 5 in \\cite{dynamic}. The grammar also handles a kripke frame written using the set notation in chapter 5 with one difference ($m_{\\mathfrak{K}}(a)$ would be written as $m(a)$). Lastly I  prepared classes for PDL AST for Kripke frames, formulas and programs. Next tasks would be parsing PDL input into PDL AST and translating this AST into CVC4 AST. \n\n\\section{Preferences for presentation day}\n\n April 30 is the most preferred date. May 2  is least preferred date because I have a project presentation for another class on this date.\n\n\n\n\\bibliographystyle{plain}\n\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "bbd14307a01b2fd86bbea0a378da4ba5c1fc1911", "size": 2491, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "proposal/proposal.tex", "max_stars_repo_name": "mudathirmahgoub/pdl", "max_stars_repo_head_hexsha": "8dfaeb438e2fbc9de18fa0299e492adac0f269ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proposal/proposal.tex", "max_issues_repo_name": "mudathirmahgoub/pdl", "max_issues_repo_head_hexsha": "8dfaeb438e2fbc9de18fa0299e492adac0f269ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "proposal/proposal.tex", "max_forks_repo_name": "mudathirmahgoub/pdl", "max_forks_repo_head_hexsha": "8dfaeb438e2fbc9de18fa0299e492adac0f269ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.275, "max_line_length": 665, "alphanum_fraction": 0.7904456042, "num_tokens": 654, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.4339820292105084}}
{"text": "\\section{Output}\n\nThe simulation program gives the coefficients \\gls{frrcfa} and \\gls{frrcfb} of the Fourier transform of \\gls{difint}.\nIt is then possible to calculate the latter for each harmonic \\gls{hmc} and value of \\gls{frrvar} by averaging the coefficients over all the simulation outputs from the same set of starting parameters.\n\n\\begin{equation}\\label{eq:fourier-amplitude}\n  \\gls{frrtrf}(\\gls{frrvar}) =\n    \\hat{\\gls{expval}} \\left( \\gls{frrcfa}(\\gls{frrvar}) \\right) + i \\times \\hat{\\gls{expval}} \\left( \\gls{frrcfb}(\\gls{frrvar}) \\right)\n\\end{equation}\n\n\\medskip\n\n\\gls{frrtrf} is complex.\nIt is either its module or its real part that will be used.\nThe functions can be represented according to two methods as shown in \\figref{fig:rdd-output}.\nIn \\gls{r1} the functions are represented in logarithmic scale as a function of \\gls{frrvar}.\nIn \\gls{r2} the functions are represented through the transformation \\( \\ln\\left( \\cdot \\right) / \\gls{frrvar}^2 \\) as a function of \\gls{frrvar} in logarithmic scale.\nWith \\gls{r2} a linear behavior can be observed for the asymptotic values of \\gls{frrvar}.\n\n\\bigfig{fig:rdd-output}{insert/output}{100_rho5e13m-2_square_3200nm_RDD_d5e-5nm-2_edge_S0_PBC1_output}{Results of an X-ray diffraction simulation conducted on a sample of \\gls{rdd}}\n\nThe example shown in \\figref{fig:rdd-output} can be exported with the following script.\n\n\\pyscript{insert/output}{plot.py}\n\n\\bigskip\n\nFor the rest it is defined the orthonormal basis \\( \\left( \\ux, \\uy, \\uz \\right) \\) as follow.\n\\uz \\ gives the direction of the dislocation line vectors \\gls{vecl}.\n\\ux \\ gives the direction of the vector associated with the Fourier variable \\gls{frrvar}.\nAnd \\( \\uy = \\uz \\times \\ux \\).\n\n\\subsection{Fit models}\n\nTo determine the density \\gls{dst} and the outer cut-off radius \\gls{cutrad}, the theoretical models at our disposal are fitted to the simulation results.\nThese models are presented here.\nIt is first defined some quantities that will be common to the models.\n\\( k \\) can be compared to the directing coefficient of the linear part in \\gls{r2} in \\figref{fig:rdd-output}.\n\\( \\psi \\) is the angle between \\gls{vecg} and \\gls{vecl}.\n\\gls{pssrat} is the \\glsdesc{pssrat}.\n\\( \\gamma \\) is the angle between the projections of \\gls{vecg} and \\gls{vecb} in the plane orthogonal to \\gls{vecl}.\nFinally \\gls{confac} is the contrast factor defined for edge and screw dislocations in elastically isotropic crystals.\n\n\\begin{equation}\n  k =\n    \\frac{\\pi}{2} | \\gls{hmc} \\gls{vecg} |^2 | \\gls{vecb} |^2 \\gls{confac} \\gls{dst}\n\\end{equation}\n\n\\begin{equation}\n  \\psi =\n    \\angle \\left( \\gls{vecg}, \\gls{vecl} \\right)\n\\end{equation}\n\n\\begin{equation}\n  \\gamma = \\angle \\left(\n    \\gls{vecg} - \\left( \\gls{vecg} \\cdot \\uz \\right) \\uz,\n    \\gls{vecb} - \\left( \\gls{vecb} \\cdot \\uz \\right) \\uz\n    \\right)\n\\end{equation}\n\n\\begin{equation}\\label{eq:contrast-factor}\n  \\gls{confac}_\\mathrm{edge} =\n    \\begin{cases}\n      \\sin^4 \\psi \\frac{1}{8(1-\\nu)^2} \\left( 1 - 4 \\nu + 8 \\nu^2 + 4 (1 - 2 \\nu) \\cos^2 \\gamma \\right)\n      & \\text{for edge dislocations} \\\\[3mm]\n      \\sin^2 \\psi \\cos^2 \\psi\n      & \\text{for screw dislocations}\n    \\end{cases}\n\\end{equation}\n\n\\subsubsection{\\glsentrytext{guw1}}\n\nEquation \\eqref{eq:guw1} gives be the Fourier transform of diffraction vector harmonic \\gls{hmc} as predicted in the \\gls{guw1} \\cite{GUW1988} \\cite{SGL2001}.\nCompared to the original proposal, \\( \\langle \\gls{dst}^2 \\rangle - \\langle \\gls{dst} \\rangle^2 \\) has been simplified to \\( \\delta \\langle \\gls{dst} \\rangle^2 \\) with \\( \\delta \\) a coefficient quantifying the density fluctuation and \\( \\ln(\\gls{frrvar}/R_1) \\ln(\\gls{frrvar}/R_2) \\) has been simplified to \\( (\\ln(\\gls{frrvar}/R_0))^2 \\).\n\n\\begin{equation}\n  \\define{\n    \\gls{guw1}_{\\gls{hmc}}\n  }{\n    \\gls{setR}^*\n  }{\n    \\gls{setR}\n  }{\n    \\gls{frrvar}\n  }{\n    \\exp\\left( \\gls{frrvar}^2 D_{\\gls{hmc}}(\\gls{frrvar}) \\right)\n  }\n  \\label{eq:guw1}\n\\end{equation}\n\n\\begin{equation}\n  D_{\\gls{hmc}}(\\gls{frrvar}) =\n    k \\left( \\ln \\left( \\frac{\\gls{frrvar}}{\\gls{cutrad}} \\right) + \\frac{\\delta}{2} k \\gls{frrvar}^2 \\left( \\ln\\left( \\frac{\\gls{frrvar}}{R_0} \\right) \\right)^2 \\right)\n\\end{equation}\n\n\\subsubsection{\\glsentrytext{guw2}}\n\nEquation \\eqref{eq:guw2} gives be the Fourier transform of diffraction vector harmonic \\gls{hmc} as predicted in the \\gls{guw2} \\cite{GUW1988}.\n\n\\begin{equation}\n  \\define{\n    \\gls{guw2}_{\\gls{hmc}}\n  }{\n    \\gls{setR}^*\n  }{\n    \\gls{setR}\n  }{\n    \\gls{frrvar}\n  }{\n    \\exp\\left( \\gls{frrvar}^2 D_{\\gls{hmc}}(\\gls{frrvar}) \\right)\n  }\n  \\label{eq:guw2}\n\\end{equation}\n\n\\begin{equation}\n  D_{\\gls{hmc}}(\\gls{frrvar}) =\n    k \\left( \\ln \\left( \\gls{frrvar} \\right) - \\ln\\left( \\left( \\gls{hmc} \\gls{vecg} \\cdot \\gls{vecb} \\right) \\gls{cutrad} \\right) \\right)\n\\end{equation}\n\n\\subsubsection{\\glsentrytext{w1}}\n\nEquation \\eqref{eq:w1} gives be the Fourier transform of diffraction vector harmonic \\gls{hmc} as predicted in the \\gls{w1} \\cite{W1970}.\n\n\\begin{equation}\n  \\define{\n    \\gls{w1}_{\\gls{hmc}}\n  }{\n    \\gls{setR}^*\n  }{\n    \\gls{setR}\n  }{\n    \\gls{frrvar}\n  }{\n    W_{\\gls{hmc}}^S(\\gls{frrvar}) W_{\\gls{hmc}}^D(\\gls{frrvar})\n  }\n  \\label{eq:w1}\n\\end{equation}\n\n\\begin{align}\n  W_{\\gls{hmc}}^S(\\gls{frrvar}) &= 1 \\\\\n  W_{\\gls{hmc}}^D(\\gls{frrvar}) &= \\exp\\left( \\gls{frrvar}^2 D_{\\gls{hmc}}(\\gls{frrvar}) \\right)\n\\end{align}\n\n\\begin{equation}\n  D_{\\gls{hmc}}(\\gls{frrvar}) =\n    - k f \\left( \\frac{1}{2e^\\frac{1}{4}} \\frac{\\gls{frrvar}}{\\gls{cutrad}} \\right)\n\\end{equation}\n\n\\medskip\n\n\\begin{equation}\n  f(\\eta) =\n    \\begin{cases}\n      - \\ln(\\eta) + \\frac{7}{4} - \\ln(2) + \\frac{512}{90 \\pi} \\eta^{-1} \\\\[5mm]\n      + \\frac{2}{\\pi} \\left( 1 - \\frac{1}{4}\\eta^{-2} \\right) \\int_0^\\eta \\frac{\\arcsin(V)}{V} dV \\\\[5mm]\n      - \\frac{1}{\\pi} \\left( \\frac{769}{180} \\eta^{-1} + \\frac{41}{90} \\eta + \\frac{2}{90}\\eta^3 \\right) \\sqrt{ 1 - \\eta^2 }\n      & \\forall \\eta \\leq 1 \\\\[1cm]\n      \\frac{512}{90 \\pi} \\eta^{-1} - \\left( \\frac{11}{24} + \\frac{1}{4} \\ln(2) \\eta \\right) \\eta^{-2}\n      & \\forall \\eta > 1\n    \\end{cases}\n\\end{equation}\n\n\\subsubsection{\\glsentrytext{w2}}\n\nEquation \\eqref{eq:w2} gives be the Fourier transform of diffraction vector harmonic \\gls{hmc} as predicted in the \\gls{w2} proposed by \\textcite{KD2001}.\n\n\\begin{equation}\n  \\define{\n    \\gls{w2}_{\\gls{hmc}}\n  }{\n    \\gls{setR}^*\n  }{\n    \\gls{setR}\n  }{\n    \\gls{frrvar}\n  }{\n    \\exp\\left( \\gls{frrvar}^2 D_{\\gls{hmc}}(\\gls{frrvar}) \\right)\n  }\n  \\label{eq:w2}\n\\end{equation}\n\n\\begin{equation}\n  D_{\\gls{hmc}}(\\gls{frrvar}) =\n    k \\left( \\ln \\left( \\gls{frrvar} \\right) - \\ln\\left( \\left( \\gls{hmc} \\gls{vecg} \\cdot \\gls{vecb} \\right) \\gls{cutrad} \\right) - 2 \\ln(2) +\\frac{1}{3} + \\ln\\left(|\\sin(\\psi) \\gls{vecg} \\cdot \\gls{vecb}| \\right) \\right)\n\\end{equation}\n\n\\subsection{Fits}\n\nFor each model, the fits are performed for each harmonic \\gls{hmc} and for several maximum values of \\gls{frrvar}.\nThe Nelder–Mead method is used to find the minimum of the objective function.\n\\figref{fig:fit:example:rdd} show a fit for a given \\gls{hmc} and a given maximum value of \\gls{frrvar}.\n\n\\bigfig{fig:fit:example:rdd}{insert/fits/100_rho5e13m-2_square_3200nm_RDD_d5e-5nm-2_edge_S0_PBC1_output_analysis/fits_plot_GUW2}{j1_118nm}{Fit of \\gls{guw2} over the harmonic 1 of the computed Fourier Transform of \\gls{rdd}}\n\n\\subsubsection{Filters}\n\nIt has been developed two ways of choosing the maximum value of the maximum values of \\gls{frrvar}.\nThe first one, named \\gls{f1}, aims at keeping only the relevant results and locates the point where \\gls{frrtrf} becomes noise (i.e. when it is no longer decreasing).\nThe second filter, named \\gls{f2}, marks the end of the linearity zone of \\( \\ln \\left( \\gls{frrtrf}(\\gls{frrvar}) \\right) / \\gls{frrvar}^2 \\) as a function of \\( \\ln(\\gls{frrvar}) \\).\nGiven the application assumptions of the models, the filter \\gls{f1} is applied with \\gls{w1} and \\gls{f2} is applied with \\gls{guw2} and \\gls{w2}.\nIndeed \\gls{guw2} and \\gls{w2} are asymptotic models and \\gls{w1} is supposed to describe the complete line profile for \\gls{rrdd}.\nThe purpose of these filters is therefore to apply the models to the intervals for which they are intended.\n\n\\medfig{fig:filter-1}{insert/filters}{f1}{Example of filtering with \\gls{f1}}%\n\\medfig{fig:filter-2}{insert/filters}{f2}{Example of filtering with \\gls{f2}}%\n\n\\bigskip\n\n\\gls{f1} stops at index \\( i \\) when equation \\eqref{eq:filter-1} is not verified.\nIn the same way \\gls{f2} stops at index \\( i \\) when equation \\eqref{eq:filter-2} is not verified.\n\n\\begin{equation}\\label{eq:filter-1}\ny_{i+1} < y_i\n\\end{equation}\n\n\\begin{equation}\\label{eq:filter-2}\n\\left| \\frac{\\hat{\\gls{stddev}}_{\\text{Linear regression of } \\{ y_i \\}_{j<i}}}{\\max \\left( \\{ y_i \\}_{j<i} \\right) - \\min \\left( \\{ y_i \\}_{j<i} \\right)} \\right| < 0.01\n\\end{equation}\n\n\\subsubsection{Residuals}\n\nThe models \\gls{guw2} and \\gls{w2} are fitted within the representation \\( \\ln \\left( \\gls{frrtrf}(\\gls{frrvar}) \\right)/L^2 \\) as a function of \\gls{frrvar} and the model \\gls{w1} is fitted within the representation \\( \\gls{frrtrf}(\\gls{frrvar}) \\) as a function of \\( \\ln(\\gls{frrvar}) \\). Thus the residuals are defined in \\eqref{eq:fit-residual-1} for \\gls{w1} and in \\eqref{eq:fit-residual-2} for \\gls{guw2} and \\gls{w2}.\n\n\\begin{align}\n\\hat{\\epsilon}_i &=\n\\gls{frrtrf}(\\gls{frrvar}_i) - \\gls{frrtrf}^{M}(\\gls{frrvar}_i) \\label{eq:fit-residual-1} \\\\\n\\hat{\\epsilon}_i &=\n\\frac{\\ln\\left(\\gls{frrtrf}(\\gls{frrvar}_i)\\right)}{\\gls{frrvar}^2} -\n\\frac{\\ln\\left(\\gls{frrtrf}^{MOD}(\\gls{frrvar}_i)\\right)}{\\gls{frrvar}^2} \\label{eq:fit-residual-2}\n\\end{align}\n\n\\subsubsection{Weighting}\nThe application of the logarithmic scale to the abscissa axis in the representation of \\( \\ln \\left( \\gls{frrtrf}(\\gls{frrvar}) \\right) / \\gls{frrvar}^2 \\) as a function of \\( \\ln(\\gls{frrvar}) \\) induces a rapprochement of the measurement points with \\gls{frrvar} increasing.\nHere is proposed a weighting of each point according to the distance between it and its neighbors.\nWith this weighting, the fits fit better to the linear parts in the latter representation.\n\n\\begin{align}\nw^{\\gls{w1}}_i &= 1 \\\\\nw^{\\gls{guw2}}_i = w^{\\gls{w2}}_i &=\nn\n\\frac{\n\\ln \\left(\\gls{frrvar}_{i + 1} \\right) - \\ln \\left(\\gls{frrvar}_i\\right)\n}{\n\\ln \\left(\\gls{frrvar}_{n + 1} \\right) - \\ln \\left(\\gls{frrvar}_1\\right)\n} =\n\\frac{n}{\\ln \\left( n + 1 \\right)} \\ln \\left( \\frac{i+1}{i} \\right)\n\\end{align}\n\n\\subsubsection{Standard fit error}\nThe objective function to be minimized for a given model \\( M \\), a harmonic \\gls{hmc} and a maximum value \\( \\gls{frrvar}_n \\) of \\gls{frrvar} is the standard error of the fit defined in equation \\eqref{eq:fit-standard-error}.\n\n\\begin{equation}\\label{eq:fit-standard-error}\n\\hat{\\gls{stddev}} \\left( \\gls{frrtrf}^M \\right) = \\sqrt{\\sum_{i=1}^n \\frac{w^M_i\\hat{\\epsilon}_i^2}{n-2}}\n\\end{equation}\n\n\\subsection{Synthesis}\\label{sec:synthesis}\n\nBelow is an overview of the parameters used for the generation of the samples of distributions.\n\n\\begin{tcolorbox}\n\\begin{verbatim}\n5e13m-2:\n5.000e-05m-2 square 3200nm RDD (d=5e-5nm-2) S=0\n5.000e-05m-2 square 3200nm RRDD-E (d=5e-5nm-2 s= 200nm) S=0\n5.000e-05m-2 square 3200nm RRDD-E (d=5e-5nm-2 s= 400nm) S=0\n5.000e-05m-2 square 3200nm RRDD-R (d=5e-5nm-2 s= 200nm) S=0\n5.000e-05m-2 square 3200nm RRDD-R (d=5e-5nm-2 s= 400nm) S=0\n5.000e-05m-2 square 3200nm RCDD-E (d=5e-5nm-2 s= 800nm t= 84nm) S=0\n5.000e-05m-2 square 3200nm RCDD-R (d=5e-5nm-2 s= 800nm t= 84nm) S=0\n5.000e-05m-2 square 3200nm RCDD-D (d=5e-5nm-2 s= 800nm t= 84nm l= 71nm) S=0\n5.000e-05m-2 square 3200nm RCDD-D (d=5e-5nm-2 s= 800nm t= 84nm l=141nm) S=0\n5.000e-05m-2 square 3200nm RCDD-D (d=5e-5nm-2 s= 800nm t= 84nm l=283nm) S=0\n\n5e14m-2:\n5.000e-04m-2 square 3200nm RDD (d=5e-4nm-2) S=0\n5.000e-04m-2 square 3200nm RRDD-E (d=5e-4nm-2 s= 200nm) S=0\n5.000e-04m-2 square 3200nm RRDD-E (d=5e-4nm-2 s= 400nm) S=0\n5.000e-04m-2 square 3200nm RRDD-R (d=5e-4nm-2 s= 200nm) S=0\n5.000e-04m-2 square 3200nm RRDD-R (d=5e-4nm-2 s= 400nm) S=0\n5.000e-04m-2 square 3200nm RCDD-E (d=5e-4nm-2 s= 800nm t= 84nm) S=0\n5.000e-04m-2 square 3200nm RCDD-R (d=5e-4nm-2 s= 800nm t= 84nm) S=0\n5.000e-04m-2 square 3200nm RCDD-D (d=5e-4nm-2 s= 800nm t= 84nm l= 22nm) S=0\n5.000e-04m-2 square 3200nm RCDD-D (d=5e-4nm-2 s= 800nm t= 84nm l= 45nm) S=0\n5.000e-04m-2 square 3200nm RCDD-D (d=5e-4nm-2 s= 800nm t= 84nm l= 89nm) S=0\n\n5e15m-2:\n5.000e-03m-2 square 3200nm RDD (d=5e-3nm-2) S=0\n5.000e-03m-2 square 3200nm RRDD-E (d=5e-3nm-2 s= 200nm) S=0\n5.000e-03m-2 square 3200nm RRDD-E (d=5e-3nm-2 s= 400nm) S=0\n5.000e-03m-2 square 3200nm RRDD-R (d=5e-3nm-2 s= 200nm) S=0\n5.000e-03m-2 square 3200nm RRDD-R (d=5e-3nm-2 s= 400nm) S=0\n5.000e-03m-2 square 3200nm RCDD-E (d=5e-3nm-2 s= 800nm t= 84nm) S=0\n5.000e-03m-2 square 3200nm RCDD-R (d=5e-3nm-2 s= 800nm t= 84nm) S=0\n5.000e-03m-2 square 3200nm RCDD-D (d=5e-3nm-2 s= 800nm t= 84nm l=  7nm) S=0\n5.000e-03m-2 square 3200nm RCDD-D (d=5e-3nm-2 s= 800nm t= 84nm l= 14nm) S=0\n5.000e-03m-2 square 3200nm RCDD-D (d=5e-3nm-2 s= 800nm t= 84nm l= 28nm) S=0\n\\end{verbatim}\n\\end{tcolorbox}\n\n\\bigskip\n\nThese distribution models are illustrated in section \\ref{sec:data}.\nHere is proposed a synthesis of the results of the fits performed on the simulation outputs of the latter.\nThe objective was to gather in a single data the fits performed for several maximum values of \\gls{frrvar} for a given distribution, model and harmonic.\nTo simplify the reading of the tables, the density values closest to the real densities have been colored.\nNot all decimal places are displayed.\n\n\\bigskip\n\n\\newpage\n\n{\\renewcommand{\\arraystretch}{1.6}\n\n\\subsubsection{Mean effective cut-off radius and relative mean density deviation}\n\n\\input{load/tex/avg-tables}\n\n\\input{load/tex/avg-plots}\n\n\\newpage\n\n\\subsubsection{Effective cut-off radius sandard deviation and relative density standard deviation}\n\n\\input{load/tex/std-tables}\n\n\\input{load/tex/std-plots}\n\n\\newpage\n\n\\subsubsection{Validity domain of \\glsentrytext{guw1}}\n\n\\input{load/tex/guw1-plots}\n\n\\newpage\n\n\\figref{fig:guw1-RRDD-E-A} to \\figref{fig:guw1-RCDD-R} allow to observe the relevance of applying the model \\gls{guw1} on the complete profile.\nWhen the abscissa is equal to 1, we obtain the accuracy that would be offered by \\gls{guw1} if it was applied on the same range as the asymptotic model \\gls{guw2} (delimited by \\gls{f2}).\nThe point on the curve with the greatest abscissa corresponds the accuracy that is offered by \\gls{guw1} in its current application conditions (i.e. applied on the complete profile delimited by \\gls{f1}).\n\n\\subsection{Program}\n\nThe third and last program is used to process the post-simulation data.\nIt allows to average the coefficients from the Fourier analysis, to plot the simulation results, and to export the data and figures of the fits performed for each model.\n\n\\subsubsection{Repository}\n\nUseful information can be found on the project page: \\github{lpa-output}\n\n\\subsubsection{Installation}\n\nThe program can be installed or updated with the following command:\n\n\\pipinstall{lpa-output}\n\n\\subsubsection{Fits data}\n\nFor each harmonic and each maximum value of \\gls{frrvar}, the optimal density and outer cut-off radius in terms of fit are saved in a file like the one below. These files are produced for each fit model applied to each distribution model.\n\n\\txtlst{insert/fits}{fits\\_data\\_structure.dat}\n", "meta": {"hexsha": "008721bf3af9d1baf13b2a6701858495e9f9d56e", "size": 15351, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/include/parts/output.tex", "max_stars_repo_name": "DunstanBecht/lpa-workspace", "max_stars_repo_head_hexsha": "316db41fed08f856c376e7f8e2ff92f2af5ecf7d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/include/parts/output.tex", "max_issues_repo_name": "DunstanBecht/lpa-workspace", "max_issues_repo_head_hexsha": "316db41fed08f856c376e7f8e2ff92f2af5ecf7d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/include/parts/output.tex", "max_forks_repo_name": "DunstanBecht/lpa-workspace", "max_forks_repo_head_hexsha": "316db41fed08f856c376e7f8e2ff92f2af5ecf7d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6416666667, "max_line_length": 426, "alphanum_fraction": 0.6920721777, "num_tokens": 6083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4339820292105083}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath,mathtools,amssymb}\n\\usepackage{graphicx}\n\\usepackage{booktabs}\n\\usepackage{blkarray}\n\\usepackage{gensymb}\n\\usepackage{verbatim}\n\\usepackage{mathrsfs}\n\\usepackage{bbm}\n\\usepackage{braket}\n\\usepackage{hyperref}\n\\usepackage{verbatim}\n\\usepackage{cancel}\n\\usepackage[margin=1.0in]{geometry}\n\\newcommand{\\ol}{\\overline}\n\\newcommand{\\lp}{\\left(}\n\\newcommand{\\rp}{\\right)}\n\\newcommand{\\eps}{\\varepsilon}\n\\newcommand{\\lam}{\\lambda}\n\\newcommand{\\h}{\\circ}\n\\newcommand{\\p}{\\bullet}\n\n\\newcommand{\\Ezero}{E^{(0)}}\n\\newcommand{\\Rz}{\\mathcal{R}_{0}}\n\n\\newcommand{\\Phizero}{\\Phi^{(0)}}\n\\newcommand{\\Eone}{E^{(1)}}\n\\newcommand{\\En}{E^{(n)}}\n\\newcommand{\\Phione}{\\Phi^{(1)}}\n\\newcommand{\\Phin}{\\Phi^{(n)}}\n\n\\newcommand{\\Ecorr}{E_{\\mathrm{corr}}}\n\\newcommand{\\Hc}{H_{\\mathrm{c}}}\n\\newcommand{\\dg}{\\ensuremath{^\\dagger} }\n\\def\\*#1{\\mathbf{#1}}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\title{Lecture 5: Perturbation Theory II}\n\\date{April 6, 2020}\n\\begin{document}\n\\maketitle\n\\noindent\n\nIn perturbation theory, we split our Hamiltonian into parts $H = H_0 + V$, and our ground \nstate wavefunction $\\ket{\\Psi_0}$ and energy $E_0$ are expressed as an infinite series, where the first term is the unperturbed\nquantity of some simpler model system described by $H_0$, and the rest of the terms\nare corrections at various ``orders'' $n$:\n\\[\\ket{\\Psi_0} = \\ket{\\Phi_0} + \\sum_{n=1}^{\\infty} \\ket{\\Phin_0} \\]\n\\[E_0 = \\Ezero_0 + \\sum_{n=1}^{\\infty} \\En_0\\]\n\nAs we saw in the previous set of notes, the expression for each wavefunction and energy correction \n    needs to be derived from a system of equations.\nThis way of doing things is very inefficient at high orders, so in this set of notes \n    we will use a new scheme, which was primarily popularized and championed by Per-Olav L{\\\"o}wdin\n    in his highly influential series of papers \\textit{Studies in Perturbation Theory} in the 1960s.\nThe majority of the content in these notes can be found in the 9th (IX) paper in the series.\nThis new methodology will allow you to derive each order of PT using the same exact procedure. \nThough the higher order wavefunctions and energy expressions get more and more complex,\nthe procedure for deriving them does not change at higher orders.\nThis methodology also beautifully translates into clean diagrams, which we will see later on.\n\n%\\section{L{\\\"o}wdin and his Resolvents}\n\\section{The Wave Operator}\nSuppose there was some magical operator $\\Omega$ which\nacts on the unperturbed state $\\ket{\\Phi_0}$ (an eigenstate of $H_0$)\nand transforms it into the exact state $\\ket{\\Psi_0}$ described by $H_0 + V$\n\\[\\ket{\\Psi_0} = \\Omega \\ket{\\Phi_0} \\]\nWe will call $\\Omega$ the \\textit{wave operator}.\nFor now, we have no idea what it is, but we do know what it does.\nSuppose further that we are using an intermediate normalized $\\Psi_0$ and normalized $\\Phi_0$ such that\n\\[ \\braket{\\Phi_0|\\Phi_0} = 1 \\]\n\\[ \\braket{\\Phi_0 | \\Psi_0} = \\braket{\\Phi_0 | \\Omega | \\Phi_0} = 1 \\]\nUnder the above conditions, we will now see what happens to the Schr{\\\"o}dinger equation,\n\\[(H_0 + V) \\ket{\\Psi_0} = E_0 \\ket{\\Psi_0} \\]\nProjecting both sides of this equation by $\\bra{\\Phi_0}$ gives\n\\[\\braket{\\Phi_0 | H_0 | \\Psi_0} + \\braket{\\Phi_0 | V | \\Psi_0} = E_0 \\braket{\\Phi_0|\\Psi_0} \\]\nThe first term reduces to $\\Ezero_0$ by acting $H_0$ to the left. The second term \ncan be re-expressed in terms of $\\Omega$, and we obtain an expression for the \nperturbed eigenvalue $E_0$ in terms of a \\textit{shift} from the unperturbed eigenvalue $\\Ezero_0$.  \n\\[ E_0 = \\Ezero_0 + \\braket{\\Phi_0 | V \\Omega | \\Phi_0}  \\]\nIf we were to know what $\\Omega$ is, at this point the eigenstates and eigenvalues would be completely\ndetermined.\nL{\\\"o}wdin derived that such an $\\Omega$ can be constructed from an operator called a \\textit{resolvent},\nand under this definition, $\\Omega$ yields the same perturbation expansion for $E_0$ and $\\ket{\\Psi_0}$.\n\n\\section{Resolvents}\nA resolvent is a mathematical structure which is used to study the eigenspectrum\nof operators, among other things.\nThe concept of a \\textit{reduced resolvent} arises when one considers an eigenvalue problem \\[A \\phi = a \\phi \\]\n\nSuppose the eigenfunctions $\\phi$ can be expanded in an orthonormal basis ($f_1$, $f_2$, $f_3$,...) such that $\\sum_i c_i f_i $\nand let $\\mathbf{A}_{ij} = \\braket{f_i | A | f_j}$ be the matrix representation of the operator $A$ in this basis. \nSuppose we divide the basis $f$ into two partitions $p$ and $q$. \nIf the $p$ partition is just a single basis function ($p: {f_1}$) (which we will just denote by the number 1) and the $q$ partition \n    is all other basis functions ($q: {f_2, f_3,...}$),\n    one finds with some manipulation that the eigenvalues are defined by the relation \n\\[ a =  A_{11} + \\mathbf{A}_{1q}( a \\cdot \\mathbf{1}_{qq} - \\mathbf{A}_{qq})^{-1} \\mathbf{A}_{q1} \\]\nThe above is the ``reduced'' characteristic equation, and it can be used for finding the eigenvalues.\nIt arises in the particular case of our partitioning of our basis in this manner.\nThe above equation can be thought of as an alternative to the standard characteristic equation $\\mathrm{det}(\\mathbf{A} - a\\mathbf{1}) = 0$.\n\nIf we replace the eigenvalues $a$ in the expression above with some continuous, variable parameter $\\kappa$, we obtain the following: \n\\[f(\\kappa) =  A_{11} + \\mathbf{A}_{1q}( \\kappa \\cdot \\mathbf{1}_{qq} - \\mathbf{A}_{qq})^{-1} \\mathbf{A}_{q1} \\]\n\nNow, whenever this function is such that $f(\\kappa) = \\kappa $, we have found an eigenvalue $a = \\kappa$.\nIf we vary this $\\kappa$ until $f(\\kappa) - \\kappa = 0$, we pull out a discrete eigenvalue which is a solution to the eigenvalue problem. \n\nThe key quantity above \n\\[\\mathcal{R}_{\\kappa}(A) = ( \\kappa \\cdot \\mathbf{1}_{qq} - \\mathbf{A}_{qq})^{-1}\\]\nis the \\textbf{reduced resolvent} operator of $\\mathbf{A}$ for a particular $\\kappa$.\n\\footnote{Here, $\\mathbf{1}_{qq}$ is the identity matrix of size $q \\times q$ and $\\mathbf{A}_{qq}$ is \n the matrix representation of the operator in just the $q$-space, (over just $q$ basis functions)}\nIn words, the reduced resolvent is an operator that is assigned to another operator $\\mathbf{A}$.\nIt is only defined in $q$-space part of the operator, and different values of $\\kappa$ give different reduced resolvents.\nAs abstract as that is, it is tremendously useful, as we will see later.\n\nNotice how the resolvent is dependent on just the matrix elements of the operator $\\mathbf{A}$\nwhich correspond to the $q$ partition; it lives in the $q$-space partition of our basis.\nExpressed pictorially as a matrix representation divided into $pp$, $pq$, $qp$, $qq$ blocks,\n\\[\\mathcal{R}_{\\kappa}(A) =\n\\left( \\begin{array}{c|c}\n   0 & \\mathbf{0} \\\\\n   \\midrule\n   \\mathbf{0} & (\\kappa \\mathbf{1}_{qq} - A_{qq})^{-1} \\\\\n\\end{array}\\right)\n  \\]\n\n\\section{L{\\\"o}wdin's big idea: using reduced resolvents to define perturbation theory and solve the Schr{\\\"o}dinger equation}\nBack to the world of quantum chemistry and the Schr{\\\"o}dinger equation, \nwe can define two projection operators $P$ and $Q$ which partition our $n$-electron Hilbert space into two parts (note: if that sounds like gobbledygook to you, see the Appendix for details).\nIt is this partitioning which birthed the idea of a reduced resolvent above.\n\n$P$ is the ``model space projection operator'', which can act on a state \n    and project it onto some reference determinant $\\Phi_0$.\n\\[P = \\ket{\\Phi_0}\\bra{\\Phi_0}  \\]\n$Q$ is the \\textit{orthogonal complement} of $P$, which projects out every determinant other than the reference $\\Phi_0$\n\\[Q = 1 - P = \\sum_{n \\neq 0}  \\ket{\\Phi_n}\\bra{\\Phi_n}\\]\n$P$ and $Q$ basically just split our basis into two parts, and the sum of $P$ and $Q$ yield the resolution of the identity, $P + Q = 1$.\nIn terms of operators, the definition of the reduced resolvent for some operator $H$ is\n\\[\\mathcal{R}_{\\kappa} = (\\kappa - H)^{-1} Q  \\]\nThis is the operator analogue of the matrix representation form of $\\mathcal{R}_{\\kappa}(A)$\nwe defined earlier. Instead of only explicitly including matrix elements in the $q$ space, \nwe use our newly defined operator $Q$ to project the negative inverse of $H$ into the $Q$ space.\n%TODO\n\n\nL{\\\"o}wdin's idea, in short, was to generalize the Schr{\\\"o}dinger equation\nto a continous spectrum in $\\kappa$, and use the $\\kappa$-dependent reduced resolvent in the definition of \na trial wavefunction to solve for the eigenvalues. Read that last sentence a few more times. \nHopefully, it will soon become clear what I mean by this.\nStarting from the re-arranged Schr{\\\"o}dinger equation,\n\\[(E_0 - H) \\ket{\\Psi_0} = 0 \\]\nsuppose we choose a form for the wavefunction which has a continuous dependence on some parameter\n$\\kappa$: \n\\[(\\kappa - H) \\ket{\\Psi_{\\kappa}} = ... \\]\nThe above equation \\textit{becomes} the Schrodinger equation whenever the right side is 0.\nIf this is the case, $\\kappa$ happens to be equal to a true eigenvalue $E_0$.\nFor this reason, we refer to it as a \\textit{generalization} of the Schr{\\\"o}dinger equation.\n\nL{\\\"o}wdin derived that a \\textbf{trial wavefunction} $\\ket{\\Psi_{\\kappa}}$ \n    which is of the form $\\ket{\\Psi_\\kappa} = \\Omega_\\kappa \\ket{\\Phi_0}$\n    can be expressed in terms of the reduced resolvent. \n\\[\\ket{\\Psi_\\kappa} = \\Omega_\\kappa \\ket{\\Phi_0}\\]\n\\[\\Omega_{\\kappa} = P + \\mathcal{R}_{\\kappa} H P \\]\n\\[\\ket{\\Psi_{\\kappa}} = \\ket{\\Phi_0} + \\mathcal{R}_{\\kappa} H \\ket{\\Phi_0} \\]\n\nWhat happens when we apply $(\\kappa - H)$ to our trial wavefunction $\\ket{\\Psi_{\\kappa}}$? \nas in the above expression $(\\kappa - H) \\ket{\\Psi_{\\kappa}} = ... $?\nApplying the resolution of the identity $P + Q = 1$, we find\n\\[ (\\kappa - H) \\ket{\\Psi_{\\kappa}} =  P (\\kappa - H) \\ket{\\Psi_{\\kappa}} + Q (\\kappa - H) \\ket{\\Psi_{\\kappa}}  \\]\nLooking at just the $Q$ term, we find that\n\\begin{align*}\nQ (\\kappa - H) \\ket{\\Psi_{\\kappa}} &= Q (\\kappa - H) \\ket{\\Phi_0} + Q (\\kappa - H) \\mathcal{R}_{\\kappa} H \\ket{\\Phi_0}  \\\\\n&= \\kappa Q \\ket{\\Phi_0} - Q H \\ket{\\Phi_0} + Q H \\ket{\\Phi_0}  \\\\\n&= \\kappa Q \\ket{\\Phi_0}  \\\\\n&= 0\n\\end{align*}\nAbove we have used the fact that $ Q (\\kappa - H) \\mathcal{R}_{\\kappa}  = Q$ , which follows\nclearly from the definition of the reduced resolvent, and that $Q$ acting on $\\ket{\\Phi_0}$ is 0, since \n$\\ket{\\Phi_0}$ lives in the $P$ space. \nWe conclude the $Q$ term is 0, so we are left with:\n\\[ (\\kappa - H) \\ket{\\Psi_{\\kappa}} =  P (\\kappa - H) \\ket{\\Psi_{\\kappa}} \\]\nUsing the definition of $P = \\ket{\\Phi_0}\\bra{\\Phi_0}$, and noting that we can always ensure $\\ket{\\Psi_\\kappa}$ is intermediately normalized, we obtain\n\\begin{align*}\n (\\kappa - H) \\ket{\\Psi_{\\kappa}} &=  \\ket{\\Phi_0}\\bra{\\Phi_0} (\\kappa - H) \\ket{\\Psi_{\\kappa}} \\\\\n &=  \\kappa \\ket{\\Phi_0} \\braket{\\Phi_0|\\Psi_\\kappa} - \\ket{\\Phi_0} \\braket{\\Phi_0| H | \\Psi_\\kappa} \\\\\n &= (\\kappa - \\braket{\\Phi_0 | H | \\Psi_\\kappa}) \\ket{\\Phi_0} \\\\\n &= (\\kappa - \\braket{\\Phi_0 | H \\Omega_\\kappa | \\Phi_0}) \\ket{\\Phi_0} \\\\\n &= (\\kappa - \\braket{\\Phi_0 | H + H \\mathcal{R}_\\kappa H  | \\Phi_0} ) \\ket{\\Phi_0} \\\\\n &= (\\kappa - f(\\kappa)) \\ket{\\Phi_0}\n\\end{align*}\n\nwhere we have defined the function of $\\kappa$, denoted  $f(\\kappa)$ as\n\\[ f(\\kappa) =  \\braket{\\Phi_0 | H | \\Psi_\\kappa} = \\braket{\\Phi_0 | H + H \\mathcal{R}_\\kappa H  | \\Phi_0}\\]\nL{\\\"o}wdin calls this the \\textit{bracketing function}, since it enables one to obtain both lower and upper bounds to true eigenvalues.\nRestating the above in one compact expression, we have \n\\[ (\\kappa - H) \\ket{\\Psi_{\\kappa}} = (\\kappa - f(\\kappa)) \\ket{\\Phi_0} \\]\n\\[ (\\kappa - H) \\Omega_\\kappa \\ket{\\Phi_0} = (\\kappa - f(\\kappa)) \\ket{\\Phi_0} \\]\nThis is a monumental result.\n\\textbf{When $\\kappa$ is equal to $f(\\kappa)$, the right side above goes to zero. If this occurs,\nwe conclude that our trial function $\\ket{\\Psi_{\\kappa}}$\nis a solution to the Schr{\\\"o}dinger equation, and the eigenvalue $\\kappa$ is the corresponding \nenergy eigenvalue.}  \nThus, our chosen trial function (derived by L{\\\"o}wdin) gives us access to the solutions of \nthe Schrodinger equation, by looking for zeros of $F(\\kappa) = f(\\kappa) - \\kappa$.\n\n\\textbf{\nTo summarize, our discrete eigenvalue problem (the Schr{\\\"o}dinger equation) \nwas modified into a continuous form, which was enabled by the $\\kappa$ dependence of the\nreduced resolvent $\\mathcal{R}_\\kappa$, which Lowdin realized can be used to construct our magical wave operator $\\Omega_\\kappa$, which\ntransforms our reference determinant into some function $\\Psi_\\kappa$ by $ \\ket{\\Psi_\\kappa} = \\Omega_\\kappa \\ket{\\Phi_0}$.\nWhen $\\kappa$ happens to be equal to an eigenvalue of the Schr{\\\"o}dinger equation,\nwe will know it, since $\\kappa - f(\\kappa) = 0$, and we will have found an eigenstate and eigenvalue (solved the Schr{\\\"o}dinger equation).\n}\n\n\\subsection{L{\\\"o}wdin's Rayleigh-Schr{\\\"o}dinger Perturbation Theory}\nWe can now take our generalized Schr{\\\"o}dinger equation from above \n\\[ (\\kappa - H) \\Omega_\\kappa \\ket{\\Phi_0} = (\\kappa - f(\\kappa)) \\ket{\\Phi_0} \\]\nand consider how it behaves when our Hamiltonian is split into two parts $H = H_0 + V$. \n\n\\paragraph{\\textbf{The Wave Operator}}\nOur wave operator becomes\n\\[\\Omega_\\kappa = P + \\mathcal{R}_{\\kappa} H_0 P + \\mathcal{R}_{\\kappa} V P \\]\n\\[\\Omega_\\kappa = P + \\mathcal{R}_{\\kappa} H_0 \\ket{\\Phi_0}\\bra{\\Phi_0} + \\mathcal{R}_{\\kappa} V P \\]\n\\[\\Omega_\\kappa = P + E_0 \\mathcal{R}_{\\kappa} P + \\mathcal{R}_{\\kappa} V P \\]\n\\[\\Omega_\\kappa = P + \\mathcal{R}_{\\kappa} V P \\]\nwhere the reduced resolvent acting on $P$ is zero, since the resolvent entirely resides in the $Q$ space, which is orthogonal to $P$.\n\n\\paragraph{\\textbf{The Bracketing Function}}\nAfter a few manipulations which are left as an exercise, \nthe bracketing function $f(\\kappa) = \\braket{\\Phi_0 | H \\Omega_\\kappa | \\Phi_0}$ becomes \n\\[f(\\kappa) = \\Ezero_0 + \\braket{\\Phi_0 | V \\Omega_\\kappa | \\Phi_0 } \\]\n\n\\paragraph{\\textbf{The Reduced Resolvent}}\nWe have one last quantity to fully define: the reduced resolvent. \nHow does the resolvent behave for our Hamiltonian $H = H_0 + V$? \n\\[\\mathcal{R}_{\\kappa} = (\\kappa - H)^{-1}Q \\]\nWe are about to do a lot of tricky manipulations, but in doing so,\nwe will arrive at perhaps the most important result in this set of notes. \nLet's do it.\nFirst we will expand $H$ and add $0 = \\Ezero_0 - \\Ezero_0$\n\\[\\mathcal{R}_{\\kappa} = (\\kappa - \\Ezero_0 + \\Ezero_0 - H_0 - V)^{-1}Q \\]\nRearranging and letting $V' = V - (\\kappa - \\Ezero_0)$:\n\\[\\mathcal{R}_{\\kappa} = (\\Ezero_0 - H_0 - V')^{-1}Q \\]\nTo move further, we use of the following identity for two operators $A$ and $B$,\n\\[ (A- B)^{-1} = A^{-1} + A^{-1} B (A - B)^{-1} \\]\nIf we let  $A = (\\Ezero_0 - H_0)$ and $B = V'$, we have\n\\[\\mathcal{R}_{\\kappa} = \\left[ (\\Ezero_0 - H_0)^{-1} +  (\\Ezero_0 - H_0)^{-1} V' (\\Ezero_0 - H_0 - V')^{-1} \\right] Q\\]\n\\[\\mathcal{R}_{\\kappa} = (\\Ezero_0 - H_0)^{-1}Q +  (\\Ezero_0 - H_0)^{-1} V' (\\Ezero_0 - H_0 - V')^{-1}Q\\]\nSince $Q^2 = Q$ and Q is Hermitian we can insert a $Q$ in the second term:\n\\[\\mathcal{R}_{\\kappa} = (\\Ezero_0 - H_0)^{-1}Q +  (\\Ezero_0 - H_0)^{-1}Q V' (\\Ezero_0 - H_0 - V')^{-1}Q\\]\nExpanding the definition of $V'$ in the parentheses we obtain\n\\[\\mathcal{R}_{\\kappa} = (\\Ezero_0 - H_0)^{-1}Q +  (\\Ezero_0 - H_0)^{-1}Q V' (\\kappa - H)^{-1}Q\\]\nNow, we define the quantity $\\Rz =  (\\Ezero_0 - H_0)^{-1} Q$, the \\textbf{unperturbed reduced resolvent}, \nwhich is the resolvent defined for $\\kappa = \\Ezero_0 $ and unperturbed Hamiltonian $H_0$.\n\\[\\mathcal{R}_{\\kappa} = \\Rz +  \\Rz V' (\\kappa - H)^{-1}Q\\]\nNoting the last part of the second term is just our original reduced resolvent $\\mathcal{R}_{\\kappa} = (\\kappa - H)^{-1}Q $,\nwe finally arrive at our result:\n\\[\\mathcal{R}_{\\kappa} = \\Rz +  \\Rz V' \\mathcal{R}_{\\kappa} \\]\n\\textbf{The resolvent is dependent on itself. \nBecause of this, we can iteratively construct an expansion of the resolvent. \nThis will ultimately be the source of our perturbation expansion.}\nIn an exercise, you will explicitly iterate the resolvent, and show that it generalizes to the following\n\\[\\mathcal{R}_{\\kappa} = \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz \\]\n\nUp to this point, we have defined everything with the subscript $\\kappa$.\nFrom here on, we will focus on just finding solutions for which $\\kappa$ is our ground \nstate energy $\\kappa = E_0$, so we will drop the $\\kappa$ subscripts.\nSince the only part of the resolvent above which depends on $\\kappa$ is \n$V' = V - (\\kappa - \\Ezero_0)$, we will now have \n\\[V' = V - (E_0 - \\Ezero_0)\\]\n\\[\\mathcal{R} = \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz \\]\nWe will likewise drop the $\\kappa$ from our definition of the wave operator \nand the wave function\n\\[\\Omega = P + \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz V P \\]\n\\[\\ket{\\Psi_0} = \\Omega \\ket{\\Phi_0}\\]\n\\[\\ket{\\Psi_0} =  \\ket{\\Phi_0} + \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz V \\ket{\\Phi_0} \\]\n\\textbf{This is our perturbation expansion for the wavefunction.}\nFrom section 1, ``The Wave Operator'', we derived our energy expression to be, \n\\[ E_0 = \\Ezero_0 + \\braket{\\Phi_0 | V \\Omega | \\Phi_0}  \\]\nOur energy expansion is therefore,\n\\[E_0 = \\Ezero_0 + \\braket{\\Phi_0|V|\\Phi_0} + \\sum_{n=0}^{\\infty} \\braket{\\Phi_0|V (\\Rz V')^n \\Rz V | \\Phi_0}\\]\n\\textbf{This is our perturbation expansion for the energy.}\n\nThe operator $V'$ introduces some complexity that is worth discussing. \nIt contains $E_0$, which is the exact energy, \n    so it involves a sum over all orders of energy corrections.\n\\[V' = V - (E_0 - \\Ezero_0) \\]\n\\[V' = V - \\sum_{m=1} E_0^{(m)} \\]\n\\[V' = V - E_0^{(1)} - E_0^{(2)} - E_0^{(3)} - \\cdots \\]\n\nTo conclude, we have obtained expressions for the $n^{th}$ order wavefunction \nand energy corrections in perturbation theory.\nLooking at the expression for $\\ket{\\Psi_0}$, each order wavefunction correction\nat higher orders is just a string of operators $(\\Rz, V, V')$ acting on our reference determinant.\nEach energy is just an expectation value of a string of operators $(\\Rz, V, V')$.\nUsing these expansions in practice can be a bit tricky, as we will see in the next section.\n\n\\section{Deriving Perturbation Theory Orders}\nBefore we get started, we need to know how to identify the ``order'' of a term in our\nwavefunction expansion. The reason is that if we want the \n$m$th order wavefunction correction, we need to pull out all $m$th order\nterms in $\\ket{\\Psi_0} =  \\ket{\\Phi_0} + \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz V \\ket{\\Phi_0}$.\n\n\\paragraph{\\textbf{How to identify the order of a term?}}\nSome tips for finding the order of a given term:\n\\begin{itemize} \n\\item Each $V$ contributes an order of 1\n\\item Each $E_0^{(m)}$ contributes an order of $m$\n\\item Instead of counting orders from $V$ and $E_0^{(m)}$, you can instead count\nthe number of resolvents $\\Rz$. Before doing so, you must convert all $E_0^{(m)}$ to the \ncorresponding analytic expression.\n\\end{itemize}\nAs an example of the above rules, when determining the order of the term \n\\[ \\Rz E_0^{(2)} \\Rz V \\ket{\\Phi_0} \\]\nwhich appears in the third-order wavefunction, \nwe could reason that $V$ and $E_0^{(2)}$ is $1 + 2 = 3 \\implies$ third order.\nAlternatively, we could recognize that $E_0^{(2)} = \\braket{\\Phi_0 |V \\Rz V|\\Phi_0}$ (for now,\njust accept that this is true, we will derive it later),\nso therefore our expression is \n\\[ \\Rz \\braket{\\Phi_0 |V \\Rz V|\\Phi_0} \\Rz V \\ket{\\Phi_0} \\]\nThe above expression has 3 resolvents, so we conclude it is third order.\nOR, we could count that the above expression has 3 $V$'s, and conclude it is third order.\nEverything checks out.\nLet's derive some perturbation theory orders.\n\n\\paragraph{\\textbf{Zero order}}\nThe 0th order wavefunction correction is just the first term of the respective pertubation expansion\nfro above, which is of course just our reference determinant $\\ket{\\Phi_0}$. \nThe 0th order energy is just $\\Ezero_0$.\n\n\\paragraph{\\textbf{First order}}\n\\[ \\ket{\\Phi_0^{(1)}} = \\Rz V \\ket{\\Phi_0}\\]\n\\[ E_0^{(1)} = \\braket{ \\Phi_0 | V | \\Phi_0} \\]\n\n\\paragraph{\\textbf{Second order}}\nWe read off from the expansion for $n=1$,\n\\[ \\ket{\\Phi_0^{(2)}} = \\Rz V' \\Rz V \\ket{\\Phi_0}\\]\nHere is the only tricky thing with this formalism: $V'$ contains \nhigher order contributions to the energy \n\\[V' = V - E_0^{(1)} - E_0^{(2)} - E_0^{(3)} - \\cdots\\]\n\\textbf{Since we are building the second order wavefunction, it must be composed of only \nsecond order pieces. The prefactor $\\Rz V' \\Rz V$ above should therefore only be second order. \nThe V is first order, so multiplying by V' should only increase the order by 1. \nThis means only terms in the V' expansion which are first order contribute \nto the second order wavefunction.}\nThis means our $V'$ in this case is truncated to just $V + E_0^{(1)}$,\nso we have,\n\\[\\ket{\\Phi_0^{(2)}} = \\Rz (V - \\Eone_0) \\Rz V \\ket{\\Phi_0}\\]\n\\[\\ket{\\Phi_0^{(2)}} = \\Rz V \\Rz V \\ket{\\Phi_0} - \\Rz \\Eone_0 \\Rz V \\ket{\\Phi_0}\\]\nThat's it! \nThe energy correction is,\n\\[ E_0^{(2)} = \\braket{ \\Phi_0 | V \\Rz V | \\Phi_0} \\]\n\n\\paragraph{\\textbf{Third order}}\nHere we have track of the orders of various terms\nmore carefully. \nTo remind you, our wavefunction perturbation expansion is \n\\[\\ket{\\Psi_0} =  \\ket{\\Phi_0} + \\sum_{n=0}^{\\infty} (\\Rz V')^n \\Rz V \\ket{\\Phi_0} \\]\nAt $n=2$, we have a $V$ and two $V'$ in our term.\nTo make the term third order overall (this is our target for constructing $\\ket{\\Phi_0^{(3)}}$),\nwe require that each $V'$ is 1st order, so we only take out the first order\nenergy and $V$ in our $V'$ expansion $V' = V - E_0^{(1)}$.\nLet's now write this $n=2$ term down before moving on, \n\\[\\ket{\\Phi_0^{(3)}} = (\\Rz (V - \\Eone_0))^2 \\Rz V \\ket{\\Phi_0} + (... \\mathrm{more})\\]\n\nThere is also a third-order term which appears when $n=1$,\n$(\\Rz V')^1 \\Rz V \\ket{\\Phi_0}$. That $V'$ has a second order contribution from $E_0^{(2)}$,\ntherefore we set $V' = -E_0^{(2)}$ and \npick up an additional term $ \\Rz E_0^{(2)} \\Rz V \\ket{\\Phi_0}$ for $\\ket{\\Phi_0^{(3)}}$\n\\[\\ket{\\Phi_0^{(3)}} = (\\Rz (V - \\Eone_0))^2 \\Rz V \\ket{\\Phi_0} - \\Rz E_0^{(2)} \\Rz V \\ket{\\Phi_0} \\]\nExpanding this and simplifying yields\n\\[\\ket{\\Phi_0^{(3)}} = \\Rz V \\Rz V \\Rz V \\ket{\\Phi_0} - \\Rz \\Eone_0 \\Rz V \\Rz V \\ket{\\Phi_0} \n  - \\Rz V \\Rz \\Eone_0 \\Rz V \\ket{\\Phi_0} + \\Rz E_0^{(1)} \\Rz E_0^{(1)} \\Rz V \\ket{\\Phi_0} \n - \\Rz E_0^{(2)} \\Rz V \\ket{\\Phi_0} \\]\n\nOur energy expansion is \n\\[E_0 = \\Ezero_0 + \\braket{\\Phi_0|V|\\Phi_0} + \\sum_{n=0}^{\\infty} \\braket{\\Phi_0|V (\\Rz V')^n \\Rz V | \\Phi_0}\\]\n\nThe third order contribution to the energy expression occurs for $n=1$ and is \n\\[ E_0^{(3)} = \\braket{\\Phi_0 | V ( \\Rz (V - E_0^{(1)})) \\Rz V | \\Phi_0} \\]\nAlternatively, we could have also found the above by noting that generally the $(m+1)$ order energy is found\nby the $m$th order wavefunction,\n\\[ E_0^{(m+1)} = \\braket{\\Phi_0 | V | \\Phi_0^{(m)}} \\]\n\\[ E_0^{(3)} = \\braket{\\Phi_0 | V | \\Phi_0^{(2)}} \\]\nand just plug in our derived $\\ket{\\Phi_0^{(2)}}$.\n\n\\section{The Energy Substitution Theorem}\nThere is a pattern for finding equations for $\\Phi_0^{(m)}$, so you don't have to\ngo through the tedious process of analyzing where to get terms of a certain order for different\nvalues of $n$ in the expansion, or plucking out the proper terms from $V'$\n(but you should know how to do this anyway).\n\n\\paragraph{\\textbf{Energy Substitution Theorem}}\n $\\ket{\\Phi_0^{(m)}}$ is equal to the sum of a ``principal term'' \n $(\\Rz V)^m \\ket{\\Phi_0} $ plus all unique substitutions of \nadjacent factors $(\\Rz V)^r$ with $(\\Rz E_0^{(r)})$. Each term\nin the sum is waited by a sign factor $(-1)^k$ where $k$ is the number of substitutions.\nThe pair of operators $\\Rz V$ closest to the ket $\\ket{\\Phi_0}$ is not considered for substitutions. \\\\\n\nWe will not prove this, but hopefully by looking at the expressions for  $\\ket{\\Phi_0^{(2)}}$ and $\\ket{\\Phi_0^{(3)}}$ that we just derived will convince you:\n\n\\[\\ket{\\Phi_0^{(2)}} = \\Rz V \\Rz V \\ket{\\Phi_0} - \\Rz \\Eone_0 \\Rz V \\ket{\\Phi_0}\\]\n\n\\[\\ket{\\Phi_0^{(3)}} = \\Rz V \\Rz V \\Rz V \\ket{\\Phi_0} - \\Rz \\Eone_0 \\Rz V \\Rz V \\ket{\\Phi_0} \n  - \\Rz V \\Rz \\Eone_0 \\Rz V \\ket{\\Phi_0} + \\Rz E_0^{(1)} \\Rz E_0^{(1)} \\Rz V \\ket{\\Phi_0} \n - \\Rz E_0^{(2)} \\Rz V \\ket{\\Phi_0} \\]\n\n\nNow we barely even need to think when we write down our perturbative wavefunction corrections.\nKeeping in mind the energy corrections follow form\n\\[ E^{(m+1)} = \\braket{\\Phi_0 | V | \\Phi_0^{(m)}} \\]\nour wavefunction correction expressions determine our energy expression corrections.\n\n\\section{Concluding Remarks}\nI should note that we have not actually translated the energy corrections into \nprogrammable expressions. \nTo do this, we would have to actually evaluate the expectation values, and it would \nbe a lot of work.\nLater on in the course, after learning diagrams, we will revisit PT and learn \nhow to diagrammatically derive programmable expressions for the various energy orders.\nWhen we do this, we will cleverly choose $H_0$ and $V$ such that $E_0^{(0)} = E_0^{(1)} = 0$,\nwhich simplifies things a good bit, and also makes it so that each energy\ncorrection is purely a correlation energy contribution. \nFor a sneak peak, you can look at handout 6 from the 2017 edition of this course.\n\n\nThat was a long and arduous mathematical climb. But we have finally reached the summit,\nand now hopefully you can see that all of perturbation theory is obtainable by just \nsmacking your reference state $\\ket{\\Phi_0}$ with operator strings consisting \nof resolvents $\\Rz$ and the perturbed part of the Hamiltonian $V$. \nCompare this to how we derived MP2 in the previous set of notes; we had to do a bunch of \nalgebraic manipulations to get to the end result. \nAs you can imagine, deriving MP3 and MP4 under that framework only gets worse. \nIn L{\\\"o}wdin's resolvent formalism, we can just read off the result, \n    and then evaluate it to an algebraic expression using diagrams. \n\n\\section{Appendix}\n\\subsection{Hilbert Space}\nRecall that many of the objects we have been talking about (spin orbitals, Slater determinants, wavefunctions)\n``live'' in some Hilbert space. This means many things, but for our purposes, we just need to know\nthere is some ``space'' of \\textit{abstract vectors} which have a defined inner product with a certain set of properties.\nEvery abstract vector in the space can be described in terms of the orthonormal basis which makes up the space. \n\n\\begin{itemize}\n\\item The set of all spin orbitals form a basis for what you might call the one-electron Hilbert space $\\mathcal{H}$\n\\item $n$ tensor products of $\\mathcal{H}$ with itself forms an $n$-electron Hilbert space $\\mathcal{H}^n$. \n        A member of the basis of such a space is a product of spin orbitals (Hartree products)\n\\item Denote the \\textit{antisymmetric subspace} of $\\mathcal{H}^n$ as $\\mathscr{H}^n$. The basis of this space\n    is the set of $n$-electron Slater determinants. All possible Slater determinants for an $n$-electron system live in $\\mathscr{H}^n$ \n    The full CI wavefunction for an $n$-electron system can be constructed from a linear combination of basis vectors in $\\mathscr{H}^n$\n\\end{itemize}\n\n\\subsection{Partitioning}\nConsider the following \\textit{partition} of this $n$-electron antisymmetric Hilbert space $\\mathscr{H}^n$ into\na ``$P$'' space and a ``$Q$'' space.\n\\[ \\mathscr{H}^n = \\mathscr{H}^n_P \\oplus  \\mathscr{H}^n_Q \\]\nwhere $P$ is the \\textit{projection operator} onto some reference determinant \n\\[P = \\ket{\\Phi_0}\\bra{\\Phi_0}  \\]\nand $Q$ is the \\textit{orthogonal complement} of $P$, which projects onto every determinant other than the reference $\\Phi_0$\n\\[Q = 1 - P = \\sum_{n \\neq 0}  \\ket{\\Phi_n}\\bra{\\Phi_n} \\]\nYou can think of this as just dividing your Slater determinant basis into two parts, $P$ and $Q$.\nThe sum $P + Q$ is equal to unity. This can be most easily seen by thinking of $P$ and $Q$ as two distinct chunks of the resolution of the identity. \n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "ffcfc3164726eb6a4cdd13531ca00efa49e97aff", "size": 27763, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2020/lecture_notes/tex/5_PT_2.tex", "max_stars_repo_name": "GQCG-edu/chem-8950", "max_stars_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2020/lecture_notes/tex/5_PT_2.tex", "max_issues_repo_name": "GQCG-edu/chem-8950", "max_issues_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-07-13T12:11:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-13T15:31:47.000Z", "max_forks_repo_path": "2020/lecture_notes/tex/5_PT_2.tex", "max_forks_repo_name": "GQCG-edu/chem-8950", "max_forks_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.070212766, "max_line_length": 191, "alphanum_fraction": 0.6898750135, "num_tokens": 9279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.43398202921050827}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on ??\n\n\n\\section{Character Theory}\n\\label{sec:character_theory}\n\nCharacter theory will serve as a very convenient bookkeeping tool for representations of \\(G\\) when \\(G\\) is finite. We still keep \\(K = \\C\\).\n\n\\begin{defn}\n\tLet \\((V,\\rho)\\) be a \\(\\C\\)-representation of \\(G\\) of finite degree \\(n\\). Choose any basis of \\(V\\) and express \\(\\rho_g\\) as a matrix in \\(GL_n(\\C)\\), for all \\(g \\in G\\). The \\textbf{character of \\((V,\\rho)\\)}, denoted \\(X_V\\) is the function\n\t\\begin{align*}\n\t\tX_V:G\\to \\C\\\\\n\t\tg\\mapsto \\textrm{Tr}(\\rho g)\n\t\\end{align*}\n\tWe say that \\(X_V\\) is \\textbf{irreducible} if \\((V,\\rho)\\) is irreducible.\n\\end{defn}\nIt turns out that characters detect irreducibility. Let \\(X_V,\\psi_W\\) be given. We define a scalar by\n\\begin{align*}\n\t\\langle X_V,\\psi_W \\rangle := \\frac{1}{\\left| G \\right| }\\sum_{g \\in G} \\overline{X_V(g)}\\psi_W(g).\n\\end{align*}\n\\begin{prop}\n\tLet \\(V\\) be a representation of \\(G\\). Then\n\t\\begin{align*}\n\t\tV \\text{ is irreducible }\\iff\\langle X_V,X_V \\rangle =1.\n\t\\end{align*}\n\\end{prop}\n\nOf course, we need to be sure that our construction of characters is well-defined. It turns out that they capture the properties of our representation well and are unique.\n\n\\begin{prop}\n\t\\begin{enumerate}\n\t\t\\item The definition of \\(X_V\\) is independent of choice of basis of \\(V\\)\n\t\t\\item If \\(V \\cong W\\), then \\(X_V = X_W\\) \n\t\t\\item If \\(g,h \\in G\\) are conjugate, then \\(X_V(g) = X_V(h)\\)\n\t\\end{enumerate}\n\\end{prop}\n\n\\begin{defn}\n\tThe \\textbf{character table} of \\(G\\) is defined as\n\t\\begin{align*}\n\t\t\\begin{bmatrix} X_{V_1}(g_1) & X_{V_1}(g_2) & \\ldots & X_{V_1}(g_k)\\\\\n\t\t\\vdots & & & \\vdots \\\\\n\tX_{V_\\ell}(g_1) & X_{V_\\ell}(g_2) & \\ldots & X_{V_\\ell}(g_k)\\end{bmatrix} \n\t\\end{align*}\n\\end{defn}\nThe number of irreducible characters of \\(G\\) is the same as the number of conjugacy classes of elements of \\(G\\). Furthermore, the character table is a square matrix with entries in \\(\\C\\) when the rows are indexed by irreducible representations of \\(G\\) and the columns are indexed by conjugacy classes representations of elements of \\(G\\).\\\\\n\nIn this case, \\((X_{V_i}(g_j))\\) is an invertible matrix.\n\n% Examples\n\n\\begin{prop}\n\tLet \\((V,\\rho )\\) be a representation of \\(G\\), and take \\(g \\in G\\). Then\n\t\\begin{enumerate}\n\t\t\\item \\(X_V(e) = \\textrm{dim}(V)\\) \n\t\t\\item \\(X_V(g)\\) is a sum of roots of unity\n\t\t\\item \\(X_{V\\oplus W}(g) = X_{V}(g) + X_{W}(g)\\)\n\t\t\\item \\(X_V(g^{-1}) = \\overline{X_V(g)}\\) \n\t\t\\item \\(\\overline{X_V}\\) is a character of \\(G\\)\n\t\\end{enumerate}\n\\end{prop}\n\nLet \\(X_1,\\ldots,X_r\\) be irreducible characters of a finite group \\(G\\). Define\n\\begin{align*}\n\t\\langle X_i, X_j \\rangle := \\frac{1}{\\left| G \\right| } \\sum_{g \\in G} \\overline{X_i(g)}X_j(g)\n\\end{align*}\n\n\\begin{thm}\n\t\\begin{enumerate}\n\t\t\\item \\(\\langle X_i, X_j \\rangle = \\delta _{ij}\\) \n\t\t\\item \n\t\t\t\\begin{align*}\n\t\t\t\t\\sum_{i=1}^{r} \\overline{X_i(x)}X_i(y) = \\begin{cases}\n\t\t\t\t\t\\left| C_G(x) \\right| & x,y \\text{ conjugate in }G\\\\\n\t\t\t\t\t0 & \\text{otherwise}\n\t\t\t\t\\end{cases}\n\t\t\t\\end{align*}\n\t\\end{enumerate}\n\\end{thm}\n\t\t\tHere, \\(C_G(x)\\) is the centralizer of \\(x \\in G\\), that is, \\(C_G(x) = \\textrm{Stab}_x(G) = \\left\\{g \\in G \\mid g x g^{-1} = x \\right\\} \\).\n\n% Example\n\n\\begin{thm}\n\tIf \\(V,W\\) are irreducible representations of \\(G\\), then\n\t\\begin{align*}\n\t\t\\langle X_V,X_V \\rangle = 1\\\\\n\t\t\\langle X_V,X_W \\rangle = 0 \\text{ when }V\\not\\cong W\n\t\\end{align*}\n\\end{thm}\nThis shows us that characters completely determine representations, and forthermore characters completely determine irreducibility.\n\\end{document}\n", "meta": {"hexsha": "52edb18acddfbebd02982e892c281ec6d7ad172a", "size": 3990, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture13 - CharacterThry.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture13 - CharacterThry.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture13 - CharacterThry.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9459459459, "max_line_length": 344, "alphanum_fraction": 0.6581453634, "num_tokens": 1419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.43398202921050827}}
{"text": "\\section{PolyPasswordHasher: A New Technique for Password Verification}\n\\label{SEC:design}\n\n\nThe goal of PolyPasswordHasher is to make cracking individual passwords\ninfeasible.  It provides a way of preventing an attacker from validating a\npassword hash.  At its core, PolyPasswordHasher aims to protect password hashes\nby combining a share (derived using a threshold cryptosystem) with a salted\npassword hash and then storing this combined value in the password database.\nNeither the share nor the password hash is stored on disk and, as we discuss in\nmore detail below, an attacker cannot recover either piece with only the\npassword database.  Cracking a password that is stored by PolyPasswordHasher\nrequires that the attacker know a threshold of passwords; this effectively\nmakes the passwords in a database interdependent.  Our goal is to ensure that\nso long as an attacker does not know a threshold of passwords, no password in a\ndatabase can be cracked.\n\nTo make passwords interrelate, \\PPH functions differently from a salted hash.  A\ntypical salted hash database stores a Username, Salt, and a Salted Hash.  A \\PPH\ndatabase, rather than storing a salted hash, stores the secure hash XORed with\nthe share (\\sxh).  The resulting \\PPH database also holds an extra field called the\nshare number.  This field indicates which share was XORed with which salted\nhash.   \n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/Verify_account.pdf}\n    \\caption{Account verification. }\n    \\label{FIGURE:account-verification}\n\\end{figure}\n\n\nWhen prompted to validate a password, the server XORs the salted hash with the\nstored data and determines whether the result is a valid share of the threshold\n%cryptosystem.  For example, in Figure~\\ref{FIGURE:basic-pph-algorithm}, Bob\ncryptosystem.  For example, in Figure~\\ref{FIGURE:account-verification}, Alice\nhas provided her password (`fsh\\$t!kz') and the username `Alice'.  \nThe server and computes the salted hash of her password (`4298f44d...') and\nreconstructs Alice's share (`3e773b6f...') using her share number\n(2).  The server XORs the share and Alice's salted password hash together\nand compares them to the value stored in the \\sxh field in the password\ndatabase (`7cefcf22...').  If they match, then the password\nprovided was correct.\n\nAccount creation involves creating a share and XORing it with\nthe salted hash of the password before storing it on disk \nFor example, in Figure~\\ref{FIGURE:basic-pph-algorithm}, Bob registers an\naccount with his password (`Tr4mP0l1ne') and username (`Bob').  The \nserver computes a salt (`0x5a17') and the salted hash of Bob's\npassword (`4153f0aa...').  The server knows the secret and knows Bob's\nshare number, 4. It computes Bob's share (`66ef2279...') and this value is XORed\nwith Bob's password’s salted hash; that value is compared to the value\nstored in the database (`27bcd2d3...'). If these match, then the password\nprovided was correct.\n%cryptosystem.  For example, in Figure~\\ref{FIGURE:basic-pph-algorithm}, Bob\n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/basic-pph-algorithm.pdf}\n    \\caption{The basic PolyPasswordHasher algorithm showing how an entry is created}\n    \\label{FIGURE:basic-pph-algorithm}\n\\end{figure}\n\nIn PolyPasswordHasher, each share protects a salted hash and each salted hash\nprotects a share, unless a threshold of shares is known (as is shown in\nFigure~\\ref{FIGURE:pph-interdependency-2}).  Suppose that an attacker has\nobtained the password database and knows some set of account passwords (x,y,z).\nFor each known password, (illustrated in Figure~\\ref{FIGURE:pph-interdependency-new}) \nthe hacker can compute the salted hash and XOR this with the database entry to \nobtain the corresponding share.  If the attacker does not have a threshold of shares, \nthe attacker cannot generate a share for another account (e.g., `share a').  As a \nresult, the attacker cannot access share a's password's salted hash and cannot crack \na's password.  Or, suppose that a server has a threshold of correct passwords.  \nThe server now has enough information to validate a threshold of shares and can use those to\nrecover the secret. The server could then reconstruct any share and thus,\nrecover the salted hash for any account's password -- an important step in\nvalidating passwords.  Because shares protect passwords, an attacker who does\nnot have an adequate number of correct passwords (and thus shares) cannot\nfeasibly crack passwords individually. \n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/pph-interdependency-2.pdf}\n    \\caption{An attacker: (1) Cannot obtain salted hashes (needed to crack\n    passwords) without a threshold  of shares AND (2) Cannot obtain a share without\n    knowing the salted hash (password) for a \\thresholdaccount.}\n    \\label{FIGURE:pph-interdependency-2}\n\\end{figure}\n\n\\begin{figure*}\n    \\includegraphics[width=1\\linewidth]{./images/pph-interdependency-new.pdf}\n    \\caption{If an attacker knows some number of shares he can get the\n    corresponding salted hashes; if he knows the salted hashes, he can get the\n    corresponding shares; and, if he has a threshold of these, he can get the\n    secret.}\n    \\label{FIGURE:pph-interdependency-new}\n\\end{figure*}\n    \nThe basic scheme, as outlined so far, covers PolyPasswordHasher’s core \nfunctions.  In the remaining subsections we address how \\PPH checks passwords \nwithout having a threshold of correct passwords (such as after a restart) and \nhow it ensures that all\naccounts, even those that could be created by an attacker, are protected.  To\nmore fully describe the full \\PPH algorithm, we begin, in\nSection~\\ref{SUBSEC:normal-operation}, with how PolyPasswordHasher functions in\nsituations where the server has already validated a threshold of correct\npasswords and how, after reaching this threshold, the server proceeds to login\nnormal users, in a phase we call normal operation.  Following this,\nSection~\\ref{SUBSEC:bootstrapping} discusses how \\PPH performs differently when\na threshold of correct passwords have not yet been provided and needs to\nacquire that threshold (e.g. after a reboot).\nSection~\\ref{SUBSEC:bootstrap-transitioning} discusses how the system\ntransitions between bootstrapping and normal operation and in\nSection~\\ref{SUBSEC:handling-rare-events}, we describe how unlikely situations,\nsuch as the loss of a large number of account passwords, are handled.\n\n\\subsection{Normal operation of PolyPasswordHasher}\n\\label{SUBSEC:normal-operation}\n\nGiven that a server with a threshold of shares can effectively recover any\nsalted hash, if every account protected a share, every password would play an\nimportant role in protecting the security of the database.  However, not all\naccounts should necessarily be trusted to protect shares.  For example, a forum\nmay allow any user to register an account and any party, including an attacker,\nto register any number of user accounts.  If these accounts each protected a\nshare, an attacker could easily crack the password database.\n\nPolyPasswordHasher enables one group of passwords, which we call protector\naccounts, to protect the remaining passwords in the password database; these we\ncall \\thresholdlessaccounts.  Bob's account (who we started following in the\nprevious example) is an example of a \\thresholdaccount\n(Figure~\\ref{FIGURE:protected-protector}).  An administrator will define a\nthreshold value of \\thresholdaccounts so that if an attacker does not know a\nthreshold of protector passwords, Bob's salted hash cannot be recovered.  Bob's\npassword hash protects his share and in turn, Bob's share helps to protect the\nother shares (such as shares 1,2), which in turn protect their corresponding\npassword hashes (for root and Alice). These shares serves to protect the full\npassword database, including \\thresholdlessaccounts (Trudy and Luke). \n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/pph-store.pdf}\n    \\caption{A PolyPasswordHasher store with protector and \\thresholdlessaccounts. \\Thresholdlessaccounts are displayed with a share number of SH. }\n    \\label{FIGURE:protected-protector}\n\\end{figure}\n\nSince a \\thresholdlessaccount  does not protect a share, it is not XORed with one.\nNonetheless, these accounts are still protected by shares, or more precisely,\nthe secret.  \\PPH uses the secret as an encryption key and with it, encrypts the\npassword's salted hash.  For these accounts, the resulting value (but not the\nsecret or salted hash) is stored in the password database.  For example, in\nFigure~\\ref{FIGURE:protected-protector}, Trudy's password hash (a9e32543...) is\nencrypted using the secret (9d380eb6...); the result (8198a5fd...) is stored in the\ndatabase.  There are two important points to note.  First, if an attacker knows\nanother \\thresholdlessaccount's password (e.g., Luke's), this does not\nsubstantially help with cracking Trudy's password.  The attacker would need to\nbreak the symmetric encryption algorithm.  Also, knowing Luke's\npassword would not substantially help the attacker crack the secret or other\nshares in the password.  Once again, the attacker would need to break the\nsymmetric encryption algorithm.  Thus, \\thresholdlessaccounts cannot be\neffectively cracked unless an attacker knows a threshold of \\thresholdaccount \npasswords.\n\n\\subsubsection{PolyPasswordHasher's algorithm}\n\\label{SUBSUBSEC:pph-algorithm}\n\nAlgorithm~\\ref{ALG:acc-creation} details the processes of creating a user \naccounts.  The relevant operations for normal operation (lines 2-13)\nare discussed in this section.  Bootstrapping operations (lines 14-23) are\ndeferred to the next section.\n\n\\begin{algorithm}\n\\footnotesize\n\\begin{algorithmic}[1]\\Function{createAccount}{username, salt, saltedPasswordHash, isProtectorAccount}\n    \\vspace{.1cm}\n    \\State \\codecomment{\\footnotesize// check whether we are under normal operation}\n\n    \\If{normalOperation} \\codecomment{\\footnotesize// Section \\ref{SEC:design} and \n    \\ref{SUBSEC:normal-operation}}\n\n        \\If{isProtectorAccount} \n\n            \\State \\codecomment{\\footnotesize// Obtain a share from the share cryptosystem}\n            \\State shareNumber, share = SecretShares.getShare()\n            \n            \\State \\codecomment{\\footnotesize// Combine the share with the hash}\n            \\State passwordEntry = share $\\oplus$ saltedHash\n            \\State shareID = shareNumber\n\n        \\vspace{.11cm}\n        \\Else~\\codecomment{\\footnotesize// Shielded Account \n        (Section~\\ref{SUBSEC:normal-operation})}\n            \\State Key = SecretShares.getSecret() \n            \\State passwordEntry = AES.encrypt(saltedPasswordHash, Key)\n            \\State shareID = \\THRESHOLDLESS\n        \\EndIf\n\n    \\vspace{.1cm}\n    \\Else~\\codecomment{\\footnotesize// Bootstrapping (Section~\\ref{SUBSEC:bootstrapping})}\n\n        \\If{isProtectorAccount}\n            \\State raise AccountCreationError\n        \\Else\n            \\State shareID = BOOTSTRAP\n        \\EndIf \n        \\State passwordEntry = saltedPasswordHash\n    \\EndIf\n\n    \\State \\codecomment{\\footnotesize// Isolated Validation (Section~\\ref{SUBSEC:bootstrapping})}\n    \\State isolatedCheckBits = saltedPasswordHash.getSuffix(IC\\_BITS)\n    \\State passwordEntry += isolatedCheckBits \n\n    \\State store (username, salt, shareID, passwordEntry)\n    \\EndFunction\n\n\\end{algorithmic}\n\\caption{\\small Account creation pseudocode.\n\\label{ALG:acc-creation}}\n\\end{algorithm}\n\n{\\bf Creating Accounts}.  Adding an account works as is shown in\nAlgorithm~\\ref{ALG:acc-creation}.  As the algorithm describes, the username,\nsalt, the password’s salted hash, and a boolean are used to indicate whether or\nnot the account should be a \\thresholdaccount. If the account is a\n\\thresholdaccount, an unused share is found (line 6) and the salted hash is\nXORed with it (line 8) before the share number and resulting value are stored\n(line 23).  \n\nSince a \\thresholdlessaccount does not protect a share, those accounts are\ninstead encrypted with the secret (lines 11-12).  The share field is set to a\nspecial value that indicates a \\thresholdlessaccount (line 13).  As before,\nthis information is then stored in the database (line 23).\n \nIt is important to prevent users, particularly \\thresholdaccounts, from using bad\npasswords.  Similar to many deployed systems, PolyPasswordHasher employs simple\ntechniques to weed out extremely bad passwords.  When creating an account,\nusers input a password they want to use, but \\PPH checks this password to ensure\nthat it is not too weak (e.g., ``letmein'' or ``password'').  This is done by\nchecking the requested password against a list of commonly used passwords (the\n64K most popular). The proposed password will be rejected if it is on\nthat list.  PolyPasswordHasher also enforces constraints on the password length\nand composition (number of lowercase and uppercase letters, numbers, and\nsymbols).  The purpose is not to ensure that passwords are immensely strong,\nbut to prevent the use of \\thresholdaccount  passwords that are trivial to\nguess.  These constraints are already common in many systems, such as those\nthat aim to prevent passwords from being cracked by brute force over the\nnetwork.  \n\n\n{\\bf Process for Verifying Passwords}. Assuming that the server holds the\nright number of valid passwords (and thus shares), it will be able to recover\nthe remaining shares, as shown in Algorithm~\\ref{ALG:acc-verification}.\nTo verify a \\thresholdaccount  (lines 4-5), the server first computes the salted\nhash of the user’s password and XORs it with the passwordEntry. If the\npasswordEntry XORed with the salted hash is the share, then the password is\ncorrect.  \n\nFor a \\thresholdlessaccount, password verification differs because the salted hash\nis encrypted instead of being XORed with a share.  Lines 8-10 of\nAlgorithm~\\ref{ALG:acc-verification} describe how to compare the provided password\nhash.  The password hash is encrypted with the secret and, if the encrypted\nvalue matches the \\sxh field, the correct password was provided.  \n\n\n\n\n\\begin{algorithm}\n\\footnotesize\n\\begin{algorithmic}[1]\\Function{verifyAccount}{username, saltedPasswordHash, shareID, passwordEntry}\n\n    \\If{normalOperation}\n        \\If{isProtector(shareID)}\\codecomment{\\footnotesize // Section~\\ref{SEC:design}}\n            \\State share = passwordHash $\\oplus$ passwordEntry \n            \\State return SecretShares.computeShare(shareID) == share\n        \\Else \\codecomment{\\footnotesize// \\thresholdlessaccount , \n    Section~\\ref{SUBSEC:normal-operation}}\n\n            \\State \\codecomment{\\footnotesize// Encrypt the obtained hash and compare}\n            \\State Key = SecretShares.getSecret()\n            \\State encryptedHash = AES.encrypt(passwordHash, Key)\n            \\State return passwordEntry == encryptedHash\n\n        \\EndIf\n        \\vspace{.1cm}\n\n    \\Else \\codecomment{\\footnotesize// Bootstrapping, Section~\\ref{SUBSEC:bootstrapping}}\n\n        \\State \\codecomment{\\footnotesize// verify account created during bootstrap}\n        \\If{shareID == BOOTSTRAP}\n            \\State return passwordHash == passwordEntry\n        \\EndIf \n\n        \\If{not passwordHash.endsWith(isolatedCheckBits)}\n            \\State return False\n        \\EndIf \n        \\If{isProtector(shareID)}\n            \\State share = passwordHash $\\oplus$ passwordEntry\n            \\State SecretShares.cacheShare(share)\n        \\EndIf\n        \\State return True\n\n    \\EndIf\n\n    \\EndFunction\n\\end{algorithmic}\n\\caption{\\small Account verification pseudocode.\\label{ALG:acc-verification}}\n\\end{algorithm}\n\n{\\bf Changing a user's password / password recovery} Changing a password\nis a similar process to that used in a salted hash system, for both \\thresholdaccounts\nand \\thresholdlessaccounts. Similar to existing systems, the procedure for\nchanging a password may require validating the existing password before\nallowing a replacement to be generated. Changing the password involves creating\na new entry with the same username and share number. (This is nearly identical\nto account creation.)  A new salt is generated and hashed along with the new\npassword.  Since the hash has changed, the fourth field will also change. Once\nthe new password entry is computed, it replaces the original stored data.  The\nuser may then log in normally with their new account.\n\n\\subsection{Bootstrapping After a Reboot}\n\\label{SUBSEC:bootstrapping}\n\nWhen a system restarts, \\PPH cannot validate or create accounts as it normally\nwould, because a threshold of valid accounts has not been reached. Because \\PPH\nstores shares in memory, not on disk, these are lost during reboot.  This means\nthat a server does not know the secret and cannot compute arbitrary shares.  As\na result, when bootstrapping, neither \\thresholdaccount nor \\thresholdlessaccounts \nmay be verified or created using the methods described above; account creation and verification\nprocedures are different when the system is bootstrapping.  \n\n%\\begin{figure}\n%    \\includegraphics[width=1\\linewidth]{./images/bootstrap}\n%    \\caption{Bootstrapping is similar to verifying an account except that we\n%    use the obtained shares to restore the secret and interpolate the rest of the\n%    shares.}\n%    \\label{FIGURE:bootstrap}\n%\\end{figure}\n\n\\subsubsection{Bootstrap account creation}\n\\label{SUBSUBSEC:bootstrap-account}\n\nNew accounts may also be created during bootstrapping. To do this, the new\naccount is added to the database along with the salted hash.  While the system\nis bootstrapping, the new account is available to use.  In the interim, these\npasswords will be created (line 19 of Algorithm~\\ref{ALG:acc-creation}) and\nvalidated (lines 18-19 of Algorithm~\\ref{ALG:acc-verification}) in the same\nmanner as passwords stored in a system that uses salted hashes.\n\nAlthough it would be easy to support \\thresholdaccount creation during\nbootstrap, PolyPasswordHasher does not do so (line 16 of\nAlgorithm~\\ref{ALG:acc-creation}).  The reason is that an attacker who can\nread the password database would also be able to read the salted password hash.\nIf the attacker can later read the password database during normal operation,\nthe attacker could use that salted password hash to recover the share. \n\n\\subsubsection{Isolated Validation}\n\\label{SUBSUBSEC:isolated-validation}\n\nWhen started, a \\PPH system does not have enough protector passwords (and thus,\nshares) to recover the secret.  At this point it is not possible to validate\naccounts following the same process as \\PPH's normal operation\n(\\ref{SUBSEC:normal-operation}).  Here we describe how \\partialverification  can\nbe used to check logins even without the secret.  \\Partialverification is a\nprocess that leaks a configurable number of bits of the salted hash by using a\nslow hash algorithm.  It implements a mechanism wherein it is possible, but\nextremely unlikely, that an attacker could access an account using an incorrect\npassword.  In the next section we discuss the \\partialverification mechanism,\nbut defer discussion of its algorithm until\nSection~\\ref{SUBSEC:security-properties}.\n\nAs it bootstraps, \\PPH collects shares from protector logins. The number of\nlogins required to recover the secret will have been configured by the system\nadministrator, with the threshold normally set to a low number (e.g., three). \nOnce the threshold has been reached, \\PPH will finish bootstrapping\n(Section~\\ref{SUBSEC:bootstrapping}). Meanwhile, before this threshold is\nreached, \\partialverification makes use of an isolated-check bits field to authenticate\nuser passwords. \n\nIn this scheme, illustrated in the upper right corner of\nFigure~\\ref{FIGURE:isolated-verification}, the password database contains\nisolated-check bits.  These bits are used to verify logins before a threshold\nis reached and the same process is used for both protector and shielded\naccounts.  The user's password is hashed using the \\partialverification hash\nfunction.  This function returns a small number of bits of the hash (such as 24\nbits of a SHA256 hash) and typically involves many iterations of a secure hash\nfunction.  If the isolated-check bits field of the password database match the\n\\partialverification  hash function’s output (line 12 of\nAlgorithm~\\ref{ALG:acc-verification}), the user is allowed to log in.\n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/pph-with-partial-bytes.pdf}\n    \\caption{This figure shows validation using \\partialverification. The\n    isolated-check bits are stored on disk. This allows verification of accounts\n    before a threshold of correct passwords is provided.  } \n    \\label{FIGURE:isolated-verification}\n\\end{figure}\n\n\\begin{figure}\n    \\includegraphics[width=1\\linewidth]{./images/bootstrap.pdf}\n    \\caption{Wilson's account was created during bootstrap, so a regular\n    salted hash is stored instead.} \n        \\label{FIGURE:bootstrap-verification}\n\\end{figure}\n\nFor example, Figure~\\ref{FIGURE:bootstrap-verification} illustrates \nverification while the system is bootstrapping.  Bootstrap accounts, such\nas Wilson's account are validated in an identical way to a salted hash\nsystem.  Wilson's password is salted and hashed and this is compared\nwith the value stored in the database.  If it matches, Wilson is logged in.\n\n\\Thresholdaccounts and \\thresholdlessaccounts, like those of Trudy or Alice may\nalso log in while the system is bootstrapping\n(Figure~\\ref{FIGURE:bootstrap-verification}) using \\partialverification.  The\n\\partialverification hash function is computed over the provided password and\nthe \\partialbytes field is checked.  If these values match, the user is allowed\nto log in. Bootstrap accounts, such as Wilson's account are validated in an\nidentical way to a salted hash system.  Wilson's password is salted and hashed\nand this is compared with the value stored in the database.  If it matches,\nWilson is logged in.\n\n\\Partialverification represents a tradeoff for administrators.  Using \n\\partialverification makes the system available immediately after a reboot.  \nHowever, when using a small number of \\partialbytes, there is the potential\nfor an incorrect authentication during the bootstrapping phase.  Alternatively\na large number of \\partialbytes impacts the confidentiality of the password\ndatabase in the event of a theft, by making the passwords easier to crack.\nThus in some scenarios different settings are appropriate, possibly\neven for \\thresholdaccounts and \\thresholdlessaccounts in the same database.\nWe explore this tradeoff more in Section~\\ref{SUBSEC:security-properties}\n\n\\subsection{Transitioning From Bootstraping to Normal Operation}\n\\label{SUBSEC:bootstrap-transitioning}\n\nAs the system bootstraps, the server batches shares from \\thresholdaccounts\n(line 14 of Algorithm~\\ref{ALG:acc-verification}).   After the system has a\nthreshold of shares, it is possible to recover the secret. The server performs\nLagrange interpolation, which allows the server to not only recover the secret\nbut also, to generate arbitrary shares (both are needed to check \\thresholdlessaccounts).  \n\nRecall that accounts created during the bootstrap phase contain BOOTSTRAP for\ntheir share number and have a salted hash stored in the database.  When the\nsystem recovers the secret and transitions to normal operation, these accounts\nwill have their password hashes encrypted with the secret and their share\nnumber field set to \\THRESHOLDLESS.  This transforms these accounts to the same\nstate as \\thresholdlessaccounts that are created in normal operation.\n\nAlso, all account logins that were processed during bootstrapping are now\nchecked to be certain that the correct passwords were provided.  This step is\nneeded because it is possible that an attacker could find a password that is\ninvalid and yet, matches the \\partialbytes.  (We examine the feasibility and\ncomputational cost of this in Section~\\ref{SEC:evaluation})  The salted\npassword hash for \\thresholdlessaccount logins are cached in memory and the\npasswords are verified once a threshold is reached.\n\nFor a \\thresholdaccount , if a provided password hash matches the \\partialbytes,\nbut the password is not correct, the recovered share is not invalid.  The\nincorrect share will be detected when a threshold of shares are obtained\nbecause the integrity check on the secret will fail.  If this integrity check\nfails, the administrator is notified.  The system can still enter normal\noperation once a threshold of valid shares are obtained.  \n\n\\subsection{Handling Rare Events}\n\\label{SUBSEC:handling-rare-events}\n\nAt an administrator's behest, accounts may be switched between shielded\nand protector without user intervention. To do this, the server must be in\nnormal operation.  The server can then recover the salted secure hash. This\nsalted secure hash can then be re-encoded (using a share for an account that\nbecomes a \\thresholdaccount; or encrypted, for an account that becomes\nshielded) and the new entry can be stored. This transitions the account\nfrom a protector to shielded (or vice versa).\n\n{\\bf Recovering data if all \\thresholdaccounts are lost}.  If not enough\nknown threshold users can be verified, the salted hashes are lost forever and\naccounts cannot be validated using the technique we described in\nSection~\\ref{SUBSUBSEC:isolated-validation}.  However, this does not mean that\nthe system is unusable because \\partialverification allows users to log in.\nFurthermore, mechanisms like root password recovery that are done through the console\nwill still work, and will allow any data on the system to be accessed.\n\n{\\bf Trusting a \\thresholdaccount with multiple shares}.  A single\naccount may optionally provide access to multiple shares. \nTo do this, a single user can have multiple rows in the table.  Each \nrow will have a different \\sxh entry and thus protect a different share.\nEach entry must also have a different salt to ensure that a different\nhash value is XORed with each share.  When the user provides their password,\nthe value can be used to recover the share in each row by XORing the salted\npassword hash with each share.\n\n{\\bf Detecting an \\partialbytes match of an incorrect password}.  If the\nsystem is in normal operation, it will detect that the password does not match.\nHowever, PolyPasswordHasher will always check the \\partialbytes for an entered\npassword (for clarity, not depicted in Algorithm~\\ref{ALG:acc-verification}).\nIf the password is incorrect, but the \\partialbytes match, this indicates that\nan attacker has almost certainly stolen the password database but has not (yet)\ncracked the password.  This generates an alert to the administrator to notify\nher of the likely breach.\n\n\n", "meta": {"hexsha": "5ef5628b206f4f890659eae86bf82971f6cfc7d2", "size": 26617, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "academic-writeup/design.tex", "max_stars_repo_name": "PolyPasswordHasher/PolyPasswordHasher", "max_stars_repo_head_hexsha": "7953d182b90e04b5b10945e169afa6e593f84428", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 286, "max_stars_repo_stars_event_min_datetime": "2015-01-13T14:18:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T02:07:03.000Z", "max_issues_repo_path": "academic-writeup/design.tex", "max_issues_repo_name": "PolyPasswordHasher/PolyPasswordHasher", "max_issues_repo_head_hexsha": "7953d182b90e04b5b10945e169afa6e593f84428", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-05-25T04:01:35.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-27T21:41:20.000Z", "max_forks_repo_path": "academic-writeup/design.tex", "max_forks_repo_name": "PolyPasswordHasher/PolyPasswordHasher", "max_forks_repo_head_hexsha": "7953d182b90e04b5b10945e169afa6e593f84428", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 25, "max_forks_repo_forks_event_min_datetime": "2015-01-01T08:38:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-19T11:56:44.000Z", "avg_line_length": 53.6633064516, "max_line_length": 148, "alphanum_fraction": 0.7802156517, "num_tokens": 6206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4339820219312924}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{xcolor}\n\n\\author{Salvador Castagnino \\\\ scastagnino@itba.edu.ar}\n\\date{}\n\\title{Chapter 4 - Elementary Hilbert Space Theory}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Exercise Solutions}\n\n\\begin{exercise}\\textbf{Exercise 4.4.}\n    We start by assuming that $\\{u_n\\}_{n \\in \\mathbb{N}}$ is a countable maximal orthonormal system in $H$, we want to see that $H$ is separable. Observe that it sufices to find a countable set $A$ such that $P \\subset \\overline{A}$, with $P$ the set of all finite linear combinations of elements in $\\{u_n\\}_{n \\in \\mathbb{N}}$. Define the set $A$ to be,\n    \\[\n        A = \\Bigg\\{ \\sum_{n=1}^{N} \\left( q_n + i p_n \\right)  u_n : q_n,p_n \\in \\mathbb{Q},\\ N \\ge 1\\Bigg\\} \n    \\]\n    which is clearly countable. Take $x \\in P$, we have $x = \\sum_{n=1}^{N} c_n u_n $ for some $c_n$ complex numbers and some $N \\ge 1$ . Observe that for every $1 \\le n \\le N$ there exist $\\{q_{nk}\\}_{k \\in \\mathbb{N}}$ and $\\{p_{nk}\\}_{k \\in \\mathbb{N}}$ sequences of rational numbers such that $ \\left( q_{nk} + i p_{nk} \\right) \\rightarrow c_n$ as $k$ goes to infinity. Then let $\\epsilon > 0$ we can ask for a $k$ large enough such that $|\\left( q_{nk} + i p_{nk} \\right) - c_n| < \\frac{\\epsilon}{N}$ for all $1 \\le n \\le N$, we in turn have\n    \\[\n        \\|\\sum_{n=1}^{N} \\left( q_{nk} + i p_{nk} \\right)u_n - \\sum_{n=1}^{N} c_n u_n \\| \\le \\sum_{n=1}^{N} |\\left( q_{nk} + i p_{nk} \\right) - c_n| < \\sum_{n=1}^{N} \\frac{\\epsilon}{N} < \\epsilon \n    \\]\n    Given that every element in $P$ can be aproximated by elements in $A$ we have that, $P \\subset \\overline{A}$, which concludes the proof.\n\n\\bigbreak\n\nNow suppose that $\\{x_n\\}_{n \\in \\mathbb{N}}$ is countable and dense in $H$, we are going to build a countable maximal orthonormal system. Let $A$ be the set such that\n\\[\n   \\begin{cases}\n      x_1 \\in A \\\\\n      x_{n+1} \\in A \\text{ iff } x_{n+1} \\notin [ x_1, ..., x_n ]\n   \\end{cases} \n\\]\nwhere $[x_1, ..., x_n]$ denotes the span of $\\{x_1, ..., x_n\\}$, let's see that $A$ is linearly independent. Suppose that for some $v_1, ..., v_{m+1}$ in $A$ and $\\alpha_1, ..., \\alpha_m$ nonzero complex numbers we have that\n\\[\n    \\sum_{j=1}^{m} \\alpha_j v_j = v_{m+1}\n\\]\nEvery $v_j$ can be expressed as $x_{n_j}$, so let $v_k$ be such that $n_k$ is the greates index between all $n_j$, we then have\n\\[\n    v_k = \\frac{v_{m+1}}{\\alpha_k} - \\sum_{1 \\le n \\neq k \\le m} \\frac{\\alpha_n v_n}{\\alpha_k}\n\\]\nwhich clashes with the construction of A, thus A is linearly independent. By \\textbf{Ex4.3} we can build from A a countable orthnormal set $\\{u_n\\}$ such that $[v_1, ..., v_n] = [u_1, ..., u_n]$ for all $n \\ge 1$. Given that every $x_n$ can be expressed as a linear combination of elements in $A$, one can see that every $x_n$ will be in $[u_1, ..., u_m]$ for some $m$. Then we can see that every $x_n$ is an element of $\\overline{P}$, with P the set of finite linear combinations of elements in $\\{u_n\\}$, which in turn imples that $P$ is dense in $H$ and concludes the proof. \n\\end{exercise}\n\n\\bigbreak\n\n\\begin{exercise}\\textbf{Exercise 4.6.}\n    Let $U = \\{u_n\\}_{n \\in \\mathbb{N}}$ be an orthonormal set in $H$, let's prove the assertion \\textbf{(a)}. Boundedness of $U$ is more than clear and closedness and non-compacntess can be easily derived from that fact that $\\|u_n - u_m\\| = \\sqrt{2}$ for all $1 \\le  n < m$. \n\n\\bigbreak\n\nTo prove assertion \\textbf{(b)} (we go directly with the general case), we start by supposing that $\\sum_{n=1}^{\\infty} \\delta_n^2 < \\infty$ and proving that $S$ is compact. In ordert to do this, let $\\{x_n\\}_{n \\in \\mathbb{N}}$ be a sequence in $S$, we will construct a convergent subsequence.\n\\begin{itemize}\n    \\item Let $y_{n1} = \\hat{x}_n \\left( 1 \\right)$, notation as in the book. Given that the closed disk $\\overline{B} \\left( 0,\\delta_1 \\right)$ is compact and $y_{n1} \\in \\overline{B} \\left( 0, \\delta_1 \\right) $, we can find $y_{n_k1}$ a convergent subsequence of $y_{n1}$ which converges to a $y_1$ in that disk. We replace our original sequence $x_n$ for the new subsequence $x_{n_k}$, define $z_1 = x_{n_1}$  and proceed be repeating what we just did but for the second terms (we also rename the new sequence $x_{n_k}$ as $x_n$ for the sake of simplicity).\n    \\item Notation as above we can find a convergent subsequence $y_{n_k2}$ of the sequence of second terms which converges in $\\overline{B} \\left( 0,\\delta_2 \\right) $ to a $y_2$ in that disk. We again define $z_2 = x_{n_1}$ and replace $x_n$ by it's subsequence $x_{n_k}$. Observe that the sequence of first terms still converges as it's a subsequence of a convergent sequence.  \n\\end{itemize}\nRepeating this process an arbirary number of times we build a sequence $z_n$ in S and a sequence of numbers $y_n$ in $\\overline{B} \\left( 0,\\delta_n \\right) $ for each $n$. Given that $0 \\le |y_n| \\le \\delta_n$ for all $n \\ge 1$ we have that $\\sum_{n=1}^{\\infty} |y_n|^2 < \\infty $ and thus there exists a $y \\in S$ such that $\\hat{y} \\left( n \\right) = y_n$ for all $n \\ge 1$. By the definition of the sequences $z_n$ and $y_n$, given $\\epsilon > 0$ we can find $N, M \\in \\mathbb{N}$ large enough such that,\n\\begin{equation}\n    \\sum_{n=N}^{\\infty} |\\hat{z}_m \\left( n \\right)  - y_n|^2 \\le \\sum_{n=N}^{\\infty} 4\\delta_n^2   < \\frac{\\epsilon}{2}\n\\end{equation}\n\\begin{equation}\n    |\\hat{z}_m \\left( n \\right)  - y_n|^2 < \\frac{\\epsilon}{2^{n+1}} \\quad \\forall\\ 1 \\le n < N\n\\end{equation}\nfor all $m \\ge M$. With this in mind we can see that $\\sum_{n=1}^{\\infty} |\\hat{z}_m \\left( n \\right) - y_n|^2 =  \\|z_m-y\\|^2 < \\epsilon$ for all $m \\ge M$ which shows that $z_n$ converges to $y$ in $S$ and concludes the proof. \n\n\\bigbreak\n\nNow suppose that $S$ is compact and that $\\sum_{n=1}^{\\infty} \\delta_n^2 = \\infty $, we will get to a contradiction. Define $x_k = \\sum_{n=1}^{\\infty} c_{kn}u_n $ with\n\\[\n    c_{kn} = \n    \\begin{cases}\n        \\delta_n & \\text{if } n \\le k \\\\\n        0 & \\text{else}\n    \\end{cases}\n\\]\nClearly $x_k \\in S$ for all $k \\ge 1$  and $\\|x_k\\|^2 \\rightarrow \\sum_{n=1}^{\\infty} \\delta_n^2 = \\infty$ but given that $\\|x_k\\| \\le \\|x_k-x\\| + \\|x\\|$ for every $x \\in S$ no subsequence of $x_k$ can converge in $S$ which implies that $S$ is not compact, contradicting our assumption and concluding the proof.  \n\n\\bigbreak\n\nFinally to prove assertion \\textbf{(c)} we observe that $\\frac{r}{2}u_n \\in B \\left( 0,r \\right)$ for all $r > 0$ and all $n \\ge 1$. With this in mind, and the fact that $\\|u_n\\|$ has no covergent subsequence, the sequences $\\|\\frac{r}{2}u_n\\| $ have no convergent subsequence in $\\overline{B} \\left( 0,r \\right) $ which in turn shows that $0$ has no neighbourhood with compact closure in $H$ which concludes the proof. \n\\end{exercise}\n\n\\bigbreak\n\n\\begin{exercise}\\textbf{Exercise 11.}\nWe claim that the set $ E = \\{ f_n \\}_{n \\in \\mathbb{N}}$  with $f_n \\left( x \\right) = \\sin \\left( nx \\right) I_{[0, \\pi+\\frac{\\pi}{n}]}$ (where $I_A$ stands for the indicator function of $A$) is closed in $L^2 \\left( T \\right) $ and has no element of smallest norm. It can be easily verified that $E$ is a subset of $L^2 \\left( T \\right) $, we proceed to prove the other assertions.\n\n\\bigbreak\n\nWe start by proving that E is closed, to do this we will prove that the sequence $\\{f_n\\}_{n \\in \\mathbb{N}}$ has no convergent subsequence in $L^2 \\left( T \\right) $ and thus $E$ equals it's closure. Before starting the proof, observe that most properties of $L^2 \\left( \\mu \\right) $ spaces hold for $L^2 \\left( T \\right) $ as their norms are just a scalar multiplication appart, we won't give the proofs for them here. Suppose that there exists a subsequence $\\{f_{n_j}\\}_{j \\in \\mathbb{N}}$ convergent in $L^2 \\left( T \\right) $, by \\textcolor{blue}{Th3.12} this subsequence has a subsequence $\\{f_{n_k}\\}_{ k \\in \\mathbb{N}$ which converges pointwise a.e in $[0, 2\\pi]$. Given that $f_n \\left( x \\right) = \\sin \\left( nx \\right) $ for all $x \\in [0,\\pi]$, this conclusion contradicts the result obtained in Ex4.10 saying that the set in which $\\sin \\left( n_k x \\right) $ converges has null measure and proves our assertion.\n\n\\bigbreak\n\nNow, to prove that $E$ has no element of smallest norm let's prove that $\\inf_{n \\ge 1}\\|f_n\\|_2 = \\frac{1}{2}$ and that this infimum is not attained in $E$. To do this we start by observing that\n\\begin{equation}\n    \\bigg\\{ \\frac{1}{2\\pi} \\int_0^\\pi \\sin^2 \\left( nx \\right) \\: dx \\bigg\\}^\\frac{1}{2} = \\frac{1}{2}\n\\end{equation}\nfor all $n \\in \\mathbb{N}$ and that $f_n \\left( x \\right) = \\sin \\left( nx \\right) I_{[0,\\pi]} + \\sin \\left( nx \\right) I_{(\\pi, \\pi + \\frac{\\pi}{n}]}$. Now using (3) we can write\n\\[\n    \\|f_n\\|_2 = \\bigg\\{ \\frac{1}{2\\pi} \\int_0^\\pi \\sin^2 \\left( nx \\right) \\: dx + \\frac{1}{2\\pi} \\int_\\pi^{\\pi + \\frac{\\pi}{n}} \\sin^2 \\left( nx \\right) \\: dx \\bigg\\}^\\frac{1}{2} > \\frac{1}{2}\n\\]\nwhich shows that $\\frac{1}{2}$ is smaller than the norm of every element in $E$. With this in mind and the fact that $\\sin \\left( x \\right) $ is a bounded function using Minkowski's inequality we get,\n\\[\n    0 < \\|f_n\\|_2 - \\frac{1}{2}\\le  \\|\\sin \\left( nx \\right) I_{(\\pi, \\pi + \\frac{\\pi}{n}]}\\|_2 \\rightarrow 0 \n\\]\nThis final assertion shows that $E$ has no element of smallest norm which concludes the proof.\n    \n\\end{exercise}\n\n\\section*{Useful Properties}\n\n\\end{document}\n", "meta": {"hexsha": "112341335bc92f085c29e94873b4dce987ddcdf6", "size": 9355, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch4-Elementary-Hilbert-Space-Theory/Elementary-Hilbert-Spaces-Theory.tex", "max_stars_repo_name": "salCas276/Rudin-RnCAnalysis-Solutions", "max_stars_repo_head_hexsha": "48c1608d45388ec0260ae5d47dee23bdd4d5275a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ch4-Elementary-Hilbert-Space-Theory/Elementary-Hilbert-Spaces-Theory.tex", "max_issues_repo_name": "salCas276/Rudin-RnCAnalysis-Solutions", "max_issues_repo_head_hexsha": "48c1608d45388ec0260ae5d47dee23bdd4d5275a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch4-Elementary-Hilbert-Space-Theory/Elementary-Hilbert-Spaces-Theory.tex", "max_forks_repo_name": "salCas276/Rudin-RnCAnalysis-Solutions", "max_forks_repo_head_hexsha": "48c1608d45388ec0260ae5d47dee23bdd4d5275a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.347826087, "max_line_length": 929, "alphanum_fraction": 0.6541956173, "num_tokens": 3347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.43398202193129237}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{latexsym,amsfonts,amssymb,amsthm,amsmath}\n\\usepackage[makeroom]{cancel}\n\\usepackage {tikz}\n\\usetikzlibrary {positioning}\n\n\\setlength{\\parindent}{0in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\textheight}{8.8in}\n\\setlength{\\topmargin}{0in}\n\\setlength{\\headheight}{18pt}\n\n\n\\title{Complexity Theory - Assignment 1}\n\\author{Kishlaya Jaiswal, Satya Prakash Nayak}\n\n\\begin{document}\n\n\\maketitle\n\n\\vspace{0.5in}\n\n\n\\subsection*{Exercise 1}\n\\begin{proof}\nWe shall prove the contrapositive that $P = NP \\implies EXP = NEXP$. So assume $P=NP$ then it suffices to show $NEXP \\subseteq EXP$.\n\nLet $L \\in NEXP$, then there exist a non-deterministic turing machine $M$ with running time $T(x) = O(2^{|x|^c})$ that decides $L$.\nDefine $L_p = \\{x10^{T(x)} \\mid x \\in L\\}$.\\\\\n\nWe claim that $L_p \\in NP$. For any $y \\in L_p$, we have $|y| = |x| + T(x) + 1$. Define NTM $M'$ that does the following: on input $y$ it throws out the last $10^{T(x)}$ parts and run $M$ on $x$ (remaining part) and does whatever $M$ does. Since $M$ runs in $T(x)$ time, $M'$ is a NP machine. Therefore, $L_p \\in NP \\implies L_p \\in P$, so there exists a deterministic poly-time machine $D$ which decides $L_p$. Now we can construct a deterministic machine $D'$ which on input $x$, will pad it with $10^{T(x)}$ and check whether $x10^{T(x)} \\in L_p$ using the machine $D$ on input $x$. Hence, $L \\in EXP$.\n\\end{proof}\n\n\\subsection*{Exercise 2}\n\\begin{proof}\nWe shall show $SAT \\leq_p HALT$.\n\nLet $N$ be the poly-time $NTM$ that decides $SAT$. Consider the modified $NTM$ $M$ which on input $x$, accepts if $N$ accepts $x$ and otherwise if $N$ rejects then $M$ goes into a loop, and hence never halts. Let $\\alpha$ be the encoding for this machine $M$.\n\nGiven a SAT-instance $\\phi$ encoded as $x$, consider the string $(\\alpha, x)$ as an instance of $HALT$ problem. (Note that: $M_\\alpha = M$)\n\nSuppose $\\phi \\in SAT$, then there exists a satisfying assignment and so $N$ accepts $x$ $\\implies$ $M = M_\\alpha$ halts and accepts $x$ and therefore $(\\alpha, x) \\in HALT$. Conversely, $\\phi \\not \\in SAT$, then $N$ rejects $x$ $\\implies$ $M = M_\\alpha$ doesn't halt on $x$ and therefore $(\\alpha, x) \\not \\in HALT$.\n\nThus, $HALT$ is $NP$-hard.\n\\newline\n\nFurthermore, $HALT \\not \\in NP$ because otherwise, if there exists a $NTM$ which decides $HALT$, then given a machine $M_\\alpha$ and an input $x$, we could decide if $M_\\alpha$ halts on input $x$, hence solving the HALTING problem. So $HALT$ is not $NP$-complete.\n\\end{proof}\n\n\\subsection*{Exercise 3}\n\\begin{proof}\n$L_1 \\in NP \\implies \\exists$ a polynomial $p_1$ and a poly-time predicate $B_1$ such that $x \\in L_1 \\iff \\exists w, |w| \\leq p_1(|x|) \\wedge B_1(w,x) = 1$\n\n$L_2 \\in NP \\implies \\exists$ a polynomial $p_2$ and a poly-time predicate $B_2$ such that $x \\in L_2 \\iff \\exists w, |w| \\leq p_2(|x|) \\wedge B_2(w,x) = 1$\n\\newline\n\nTo show $L_1 \\cup L_2 \\in NP$, consider the polynomial $p = p_1 + p_2$ and the poly-time predicate $B = B_1 \\vee B_2$, then: $x \\in L_1 \\cup L_2 \\iff (x \\in L_1) \\vee (x \\in L_2) \\iff (\\exists w, |w| \\leq p_1(|x|) \\wedge B_1(w,x) = 1) \\vee (\\exists w, |w| \\leq p_2(|x|) \\wedge B_2(w,x) = 1) \\iff \\exists w, |w| \\leq p(|x|) \\wedge B(w,x) = 1$\n\\newline\n\nTo show $L_1 \\cap L_2 \\in NP$, consider the polynomial $p = p_1 + p_2$ and the poly-time predicate $B(w_1 \\# w_2) = B_1(w_1) \\wedge B_2(w_2)$, then: $x \\in L_1 \\cap L_2 \\iff (x \\in L_1) \\wedge (x \\in L_2) \\iff (\\exists w_1, |w_1| \\leq p_1(|x|) \\wedge B_1(w_1,x) = 1) \\wedge (\\exists w_2, |w_2| \\leq p_2(|x|) \\wedge B_2(w_2,x) = 1) \\iff \\exists w, w = w_1 \\# w_2, |w| \\leq p(|x|) \\wedge B(w,x) = 1$\n\\end{proof}\n\n\n\\subsection*{Exercise 4}\n\\begin{proof}.\nIt is clear that $TAUT \\in coNP$ because given any NO instance $\\phi(x)$ of $TAUT$, a short certificate for verification is an assignment of variables $x$ such that $\\phi(x) = 0$. Clearly such an assignment can be expressed in $O(n\\lg n)$ size (where $n$ = number of variables).\n\nTo show that $TAUT$ is $coNP-complete$, we note that, for any two $NP$ languages $A$ and $B$, $A \\leq_p B \\iff \\overline{A} \\leq_p \\overline{B}$.\n\nThus, if $L$ is $NP-complete$, then $\\overline{L}$ is $coNP-complete$ because firstly, $\\overline{L} \\in coNP$ by definition and for any $L' \\in coNP$, $\\overline{L'} \\leq_p L \\implies L' \\leq_p \\overline{L}$. So, we conclude that $\\overline{3SAT}$ is $coNP-complete$.\n\nTo show that $TAUT$ is $coNP-complete$, we show that $\\overline{3SAT} \\leq_p TAUT$. Given any formula $\\varphi$, consider the formula $\\overline{\\varphi}$. This formula can be constructed in $O(|\\varphi|)$ time. Now, $\\varphi$ doesn't have a satisfying assignment iff $\\overline{\\varphi}$ is a tautology.\n\\newline\n\nSuppose $NP=coNP$. Since $3SAT$ is $NP-complete$, for every $NP$ language $L$, $L \\leq_p 3SAT$. But $TAUT \\in coNP = NP \\implies TAUT \\leq_p 3SAT$. Similarly, since $TAUT$ is $coNP-complete$, for every $coNP$ language $L$, $L \\leq_p TAUT$. But $3SAT \\in NP = coNP \\implies 3SAT \\leq_p TAUT$.\n\nConversely, let $L \\in NP$, then $L \\leq_p 3SAT \\leq_p TAUT$. So given a NO instance of the problem $L$, we reduce it to a NO instance of $TAUT$ problem and hence we have a short certificate for the NO instances of $L$ as well implying that $L \\in coNP$. Similarly, let $L \\in coNP$, then $L \\leq_p TAUT \\leq_p 3SAT$. So given a YES instance of the problem $L$, we reduce it to a YES instance of $3SAT$ problem and hence we have a short certificate for the YES instances of $L$ as well implying that $L \\in NP$. Thus, $NP=coNP$.\n\\end{proof}\n\n\\subsection*{Exercise 5}\n\\begin{proof}\nSuppose unary $NP \\subseteq P$.\n\nLet $L \\in NEXP$, then there exist a non-deterministic turing machine $M$ with running time $T(x) = 2^{|x|^c}$ that decides $L$. \n\nDefine $L_u = \\{Unary(x) \\mid x \\in L\\}$.\\\\\n\nObserve that if $x \\in L$, then $x$ is a binary string of length $|x|$ and so the unary representation of $x$ will have size atmost $2^{|x|}$.\n\nWe claim that $L_u \\in NP$. For that we construct a machine $M'$ which on input $1^y$, converts $y$ into it's binary $x$ and then simulate $M$ on $x$. $M'$ accepts $1^y$ iff $M$ accepts $x$. Since $|1^y| = y < 2^{|x|}$, $M$ requires $2^{|x|} + 2^{|x|^c} = O(2^{|x|^c}) = O(y^c)$ time and hence $L(M') = L_u \\in NP$.\n\nTherefore, $L_u \\in P$, so there exists a deterministic poly-time machine $D$ which decides $L_u$. Now we can construct a deterministic machine $D'$ which on input $x$, will construct $Unary(x)$ and check if it is in $L_u$ using the machine $D$. Hence, $L \\in EXP$.\n\\end{proof}\n\n\\subsection*{Exercise 6}\n\\begin{proof}\nSince $P=NP$, we claim that $P = coNP$: $L \\in coNP \\implies \\overline{L} \\in NP \\implies \\overline{L} \\in P \\implies L \\in coP = P$.\n\nThus $TAUT \\in P$ and so there exists a poly-time algorithm $A$ such that $A(\\varphi(y)) = 1$ iff $\\varphi(y)$ is a tautology.\n\nWe shall show that $\\Sigma_2 SAT \\in NP$. Consider a YES instance of $\\Sigma_2 SAT$, that is a formula $\\psi = \\exists x \\forall y (\\phi(x,y) = 1)$ which admits a $x_0$ such that $\\phi(x_0,y)$ is a tautology.\n\nThen a short certificate for $\\psi \\in \\Sigma_2 SAT$ is $x_0$; because clearly $|x_0| \\leq |\\psi|$ and in poly-time we can check if $\\phi(x_0,y)$ is a tautology by calling $A(\\phi(x_0, y))$.\n\nIn other words, $\\psi \\in \\Sigma_2 SAT \\iff \\exists x_0$ such that $|x_0| \\leq |\\psi|$ and $A(\\phi(x_0,y))=1$.\n\nHence $\\Sigma_2 SAT \\in P$.\n\\end{proof}\n\n\\vspace{2in} %Leave more space for comments!\n\n\n\n\\end{document}\n", "meta": {"hexsha": "0071306801e31c9c7db19cb6cdf7df61f93362f5", "size": 7512, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "complexity_theory/assign1_soln.tex", "max_stars_repo_name": "kishlaya/assignments", "max_stars_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-17T09:28:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-14T17:40:34.000Z", "max_issues_repo_path": "complexity_theory/assign1_soln.tex", "max_issues_repo_name": "kishlaya/assignments", "max_issues_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "complexity_theory/assign1_soln.tex", "max_forks_repo_name": "kishlaya/assignments", "max_forks_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.6610169492, "max_line_length": 605, "alphanum_fraction": 0.6691959531, "num_tokens": 2724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.4339122911205643}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage{geometry}\n \\geometry{\n a4paper,\n total={170mm,257mm},\n left=20mm,\n top=20mm,\n }\n\n\n \\usepackage{amsmath}\n \\usepackage{siunitx}\n \\usepackage{multirow}\n\\usepackage{colortbl}\n \\usepackage{hhline}\n\n \\usepackage{lipsum}  %%% Lorem ipsum\n\n\\setlength{\\headheight}{30.0pt}\n\\setlength{\\footskip}{20pt}\n\n\n\\usepackage{hyperref}\n\\hypersetup{\n    colorlinks=True,\n    linkcolor={blue!20!black},\n    filecolor=magenta,      \n    urlcolor=cyan,\n}\n\n\n\n \\usepackage[export]{adjustbox}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{fancyhdr}\n\\usepackage{multicol}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{\\textit{Pul074BEX004}}\n\\lhead{\\textit{Amrit Prasad Phuyal}}\n\\rfoot{\\thepage}\n\n\n\\usepackage{mathpazo} % Palatino font\n\\usepackage{graphicx}\n\\usepackage{float}\n\n\n\\input{./CoverPage.tex} %%% cover page\n\\input{./Matlab.tex} %%% Matlab code\n\n\\newcommand\\ddfrac[2]{\\frac{\\displaystyle #1}{\\displaystyle #2}} \n\n\n\n%%%%%%%%%%%%%%%%%%%%%for matlab observation #1 fig name #2 Caption\n\\newcommand{\\mobs}[2]{\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=1.07\\linewidth]{./FIG/#1.eps}\n        \\caption{#2}\n    \\end{figure}\n   \n}\n\n\n\n\n\\begin{document}\n\n\n%%%%  COver page \n\\CP{Digital Signal Processing}{Lab \\#2}{Familiarization with basic CT/DT functions}\n{Anila  Kansakar}\n%%%%%%%%%%%%%%%%%%%%\n\n\\pagenumbering{gobble}\n\\renewcommand{\\contentsname}{Table of Contents}\n\\tableofcontents\n\n\\pagebreak\n%\\listoffigures\n% \\pagebreak\n% \\vspace{5em}\n\\lstlistoflistings\n\\vspace{10em}\n% \\pagebreak\n\\listoffigures\n\\pagebreak\n\\pagenumbering{arabic}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Title} {\\large Familiarization with basic CT/DT functions }\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Objective}\nFamiliarization with basic CT/DT functions\n\n%%%%%%%%%%%%%%%%%%%%%\n\n\n%Theory\n\\section{Theory}\n\n\n\n\\begin{verbatim}\n    who         >> List variables in workspace\n    whos        >> List variables in workspace, with sizes and types\n    input()     >> Read input from user\n    disp()      >> Display value of variable\n    subplot()   >> Plot multiple graphs in one figure\n    figure()    >> Create new figure window\n    clear all   >> Clear all variables from workspace, freeing up system memory\n    close all   >> Close all figures\n    home        >> Send cursor to home position\n    hold on     >> Retain plot data for multiple plots in one figure\n    grid on     >> Turn on grid lines\n    grid off    >> Turn off grid lines \n    grid        >> Turn on and off grid lines and set grid spacing\n    demo        >> Access product examples in Help browser\n    ver         >> Display version of Matlab and operating system information \n    lookfor     >> Search for keyword in all help files\n    length()    >> Length of largest dimension of array\n    pause       >> Stop MATLAB execution temporarily \n    plot()      >> 2-D line  plotting \n    stem()      >> Plot discrete data as stems\n    real()      >> Return real part of complex number\n    imag()      >> Return imaginary part of complex number\n    zeros()     >> Create array of all zeros \n    ones()      >> Create array of  all ones \n    exp()       >> Return exponential of complex number\n    for         >> Loop to repeat specified numbers of times\n    end         >> End  For loop \n    if-else     >> If-else statement execute if statement is true\n\\end{verbatim}\n\n\\section {Lab Problems}\n%%%%%%%%%%%%Problem 1\n\n\\subsection{Problem 1}\n\\subsection*{Plot the basic signal using Matlab}\n\n%%%%%%%%%%%%% Problem 1aaaaaaaaaaaaaa\n\\subsubsection{Impulse response}\nCodes:\n\\MAT{./CODES/p1a.m}{Matlab code for plotting Impulse function }\n\\mobs{impulse}{Plot for Impulse function }\n\n\n%%%%%%%%%%%%% Problem 1bbbbbbbbbbbb\n\\subsubsection{Unit step response}\n\\MAT{./CODES/p1b.m}{Matlab code for plotting Unit Step function }\n\\mobs{unit}{Plot for Unit Step function }\n\n\n%%%%%%%%%%%%% Problem 1ccccccccccccccc\n\\subsubsection{Ramp response}\n\\MAT{./CODES/p1c.m}{Matlab code for plotting Ramp function }\n\\mobs{ramp}{Plot for Ramp function}\n\n\n%%%%%%%%%%%% Problem 1dddddddddddddd\n\\subsubsection{ Rectangular pulse response}\n\\MAT{./CODES/p1d.m}{Matlab code for plotting  Rectangular pulse function }\n\\mobs{rect}{Plot for Rectangular pulse function}\n\n%%%%%%%%%%%%Problem 2\n\\subsection{Problem 2}\n\\subsection*{Plot the following continuous-time signals}\n\n\n%%%%%%%%%%%%% Problem 2aaaa\n\\subsubsection*{$x(t)=Ce^{at}$ where $C$ and $a$ are real numbers and choose $C$ and $a$ both positive and negative.}\n\\MAT{./CODES/p2a.m}{Matlab code for C and a  Both real }\n\\mobs{ca_real}{Plot for for C and a  Both real}\n\n%%%%%%%%%%%%% Problem 2bbbbbb\n\\subsubsection*{Plot the same signal taking $a$ as pure imaginary number}\n\\MAT{./CODES/p2b.m}{Matlab code for C real a Imaginary }\n\\mobs{a_imag}{Plot for C real a Imaginary}\n\n\n%%%%%%%%%%%%% Problem 2ccccc\n\\subsubsection*{Consider complex exponential signal as specified in b) where $C$ is expressed in polar form i.e., $C=|C|e^{j\\theta}$ and $a$ in rectangular form i.e., $a=r+j\\omega_o$. Then function $x(t)$, on simplification, becomes $$ x(t)= |C|e^{rt}[\\cos(\\omega_o t+\\theta)+j\\sin(\\omega_o t+\\theta)]$$\nNow, plot the signal for different values of r and comment on the results.\\\\\ni. r=0 \\quad \\quad ii. r$<$ 0 \\quad \\quad iii. r$>$0}\n\\MAT{./CODES/p2c.m}{Matlab code for different value of r}\n\n\n\\subsubsection{For r=0}\n\\mobs{r0}{Plot for r=0}\n\n\\subsubsection{For r$<$0}\n\\mobs{rm1}{Plot for r$<$0}\n\n\\subsubsection{For r$>$0}\n\\mobs{r1}{Plot for r$>$0}\n\n\n%%%%%%%%%%%%Problem 3\n\\subsection{Problem 3}\n\\subsection*{Plot the DT exponential function $x[n]=a^n$, $a=|a|e^{j\\theta}$. Choose the suitable value of $|a|$ and $\\theta$.}\n\n\\MAT{./CODES/p3.m}{Matlab code for calculation and plot DT exponential function}\n\n\\mobs{dt}{Plot for DT exponential function}\n\n\n% %%%%%%%%%%%%Problem 4\n\n\\subsection{Problem 4}\n\\subsection*{Synthesize the signal from the FS coefficients as $C_0=1$, $C_1=C_{-1}=\\ddfrac{1}{4}$, $C_2=C_{-2}=\\ddfrac{1}{2}$, $C_3=C_{-3}=\\ddfrac{1}{3}$.}\n\\MAT{./CODES/p4.m}{Matlab code for synthesizing and plotting signal}\n\\mobs{syn}{Plot for synthesized signal}\n\n\n% %%%%%%%%%%%%Problem 5\n\n\\subsection{Problem 5}\n\\subsection*{Plot fundamental sinusoidal signal, its higher harmonics up to 5\\textsuperscript{th} harmonics and add all of them to see the result. Comment on the result.}\n\\MAT{./CODES/p5.m}{Matlab code for calculation and plot of Sinusoidal harmonics and thier sum}\n\\mobs{harmonics}{Plot for Sinusoidal harmonics and thier sum}\n\n\n\n\n%%Discussion and Conclusion\n\\section{Discussion and Conclusion}\nIn this Lab we familiarize ourself with Matlab Programming with basic of Continous time and Discrete time signals. We also learn about their basic operations in Matlab including  plotting and analyzing the signals. We learn to use online help for different commands and use them to calculate different DT and CT functions and plot them.\n\n\n\\end{document}", "meta": {"hexsha": "6126d356389ce310433d17b99918042c23a12b57", "size": 6904, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DSP LABs/LAB 2/DSP LAB 2 Amrit Prasad Phuyal.tex", "max_stars_repo_name": "amritphuyal/LATEX", "max_stars_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-01T08:20:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-01T08:20:34.000Z", "max_issues_repo_path": "DSP LABs/LAB 2/DSP LAB 2 Amrit Prasad Phuyal.tex", "max_issues_repo_name": "amritphuyal/LATEX", "max_issues_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DSP LABs/LAB 2/DSP LAB 2 Amrit Prasad Phuyal.tex", "max_forks_repo_name": "amritphuyal/LATEX", "max_forks_repo_head_hexsha": "7346dc337b8d7aab2dbe81c29611ca2b069e1299", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-19T09:04:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T12:19:26.000Z", "avg_line_length": 29.5042735043, "max_line_length": 336, "alphanum_fraction": 0.6778679027, "num_tokens": 1964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7718434978390747, "lm_q1q2_score": 0.43391227684662603}}
{"text": "\\iffalse\nIt's unfair to say that mathematicians aren't real doctors, we perform surgeries all the time. In this class we'll introduce the notion of a topological manifold via simplicial (delta) complexes. Spend a day or two doing examples and go over several notions like orientation, cobordism and of course surgery.\n\nKeywords: simplicial complex, manifold, orientation, cobordism, surgery\n\nType: Lecture\nHomework: Recommended\nPrereqs: None\n\\fi\n\n\n\n\\input{../preamble}\n\\rhead{\\scshape Mathcamp 2017 : All things Manifoldy}\n\\begin{document}\n\\title{Mapping class groups}\n\\author{Apurva Nakade}\n\\thispagestyle{fancy}\n\\maketitle\n\n\n\n\\section{Automorphisms}\n\n\\begin{definition}\n\tAn \\textbf{automorphism} or a \\textbf{self-homeomorphism} of a manifold $X$ is a map $f:X \\rightarrow X$ which is a homeomorphism. The set of automorphisms forms a group under composition, denoted ${\\mathrm{Homeo}(X)}$.\n\\end{definition}\n\nThis group is usually too big to get a good handle on, so instead we study automorphisms up to deformations i.e. we consider two automorphisms to be the same if one automorphism can be continuously deformed into another.\n\n\\begin{definition}\n\tThe group $\\mathrm{Homeo}(X)/{deformations}$ is called the \\textbf{mapping class group}, denoted $\\mathrm{MCG}(X)$.\n\\end{definition}\n\n\\begin{example}\\label{thm:MCG}\n\tEvery automorphism of $\\R^1$ is a strictly increasing or a strictly decreasing function $f:\\R^1 \\rightarrow \\R^1$. It is possible to deform a strictly increasing function $f_1$ to another strictly increasing function $f_2$ via the path of maps $t.f_1 + (1-t).f_2$ for $t\\in[0,1]$, similarly for decreasing functions. And composition of two decreasing functions is an increasing function. Together these imply that $\\mathrm{MCG}(\\R^1) \\cong \\Z/2$.\n\\end{example}\n\nThe main object of interest for us is the mapping class group of the torus $\\mathrm{MCG}(T)$ i.e. automorphisms of the torus \\emph{up to deformations}. Let us fix two non-parallel circles on the torus and call these the \\textbf{principal circles}. While there are various choices for these all of which work we'll pick the simples ones and call them the \\textbf{red} and the \\textbf{blue} circles. See \\textbf{Fig.1}.\n%\n% The first important observation to make is that \\emph{up to deformations} an automorphism of a torus is completely determined by where the two principal circles are mapped.\n%\n%\n% \\begin{ques}\n% \tAre there automorphisms of the torus which map the red lines as in \\textbf{Fig.2}?\n% \\end{ques}\n\n\n\\section{Dehn Twists}\nOne way to construct non-trivial automorphisms of the torus is via Dehn twists.\n\\begin{definition}\n\tA \\textbf{Dehn twist}, denoted $D$, is a special automorphism of the cylinder which twists the cylinder as in \\textbf{Fig.2}.\n\\end{definition}\n\n% The direction of the rotation is very important. If the cylinder is placed upright then we think of $D$ as fixing the bottom circle and twisting the cylinder by rotating the top circle counterclockwise. To avoid confusion we'll always indicate which way is \\textbf{`up'} in the cylinder.\n\nDehn twist has the nice property that the two boundary circles are unchanged. We can use Dehn twists to create  non-trivial automorphisms of the torus by cutting out a cylinder, performing a Dehn twist, and glueing it back. This is an example of surgery on the torus! Dehn twists look even more interesting on gluing diagrams. See \\textbf{Fig.3}.\n\nWe can perform Dehn twists on other cylinders sitting inside a torus which allows us to create more automorphisms of the torus. A theorem of Dehn-Lickorish  says that for genus $g$ surfaces the mapping class group is generated by a small set of Dehn twists. Dehn twists on punctured discs give rise to Braid groups establishing further connections between topology and group theory.\n\n\n\\section{Exercises}\n\\begin{exercise}\n\tUse the following exercises to show that the mapping class group of $S^1 = \\{ (x,y): x^2 + y^2 = 1\\}$ is $\\Z/2$.\n\t\\begin{enumerate}\n\t\t\\item Show that every automorphism can be continuously deformed to one that fixes the point $(1,0)$.\n\t\t\\item Find two automorphisms of $S^1$ which fix $(1,0)$ which cannot be deformed into each other via automorphisms.\n\t\t\\item Show that $\\mathrm{MCG}(S^1) \\cong \\Z/2$.\n\t\\end{enumerate}\n\\end{exercise}\n\n\\begin{exercise}\n\tFind $\\mathrm{MCG}(X)$ when $X$ is one of the following spaces\n\t\\begin{enumerate}\n\t\t\\item Two parallel lines in $\\R^2$\n\t\t\\item Two intersecting lines in $\\R^2$\n\t\t\\item Union of two intersecting circles\n\t\t\\item The 2 dimensional unit disk $D^2 = \\{ (x,y) \\in \\R^2 : x^2 + y^2 \\le 1\\}$ \\\\ This one is non-trivial. Read the wikipedia page on Alexander's trick.\n\t\\end{enumerate}\n\\end{exercise}\n\n\\begin{exercise}\n\tBased on the above exercise what is the relationship between $\\mathrm{MCG}(X \\sqcup X)$ and $\\mathrm{MCG}(X)$, where $X \\sqcup X$ denotes the disjoint union of two copies of $X$.\n\\end{exercise}\n\n\\begin{exercise}\n\tDescribe the homeomorphisms which are inverses of $D_R$ and $D_B$ in the mapping class group of the torus.\n\\end{exercise}\n\n\\begin{exercise}\n\tPerform a Dehn twist on the cylinder around the equator on $S^2$. What is the corresponding element in $\\mathrm{MCG}(S^2)$?\n\\end{exercise}\n\n\\begin{exercise}\n\t\\begin{enumerate}\n\t\t\\item Verify that $D_B D_R D_B$ and $D_R D_B D_R$ are equal in $\\mathrm{MCG}(T)$ by checking what they do to the principal circles.\n\t\t\\item Consider the $2 \\times 2$ matrices $M_B = \\begin{bmatrix} 1 & 1 \\\\ 0 & 1 \\end{bmatrix}$ and $M_R = \\begin{bmatrix} 1 & 0 \\\\ -1 & 1 \\end{bmatrix}$. Verify that $M_B M_R M_B = M_R M_B M_R$.\n\t\t\\item Assuming that $\\mathrm{MCG}(T)$ is generated by $D_R$ and $D_B$ show that this defines a homomorphism from $\\mathrm{MCG}(T)$ to the group $SL_2(\\Z)$ of $2 \\times 2$ matrices with integer coefficients and determinant 1.\n\t\t\\item Describe the action of the matrices $M_R$ and $M_B$ on the plane and relate it to the Dehn twists $D_R$ and $D_B$.\n\t\\end{enumerate}\n\\end{exercise}\n\n\\begin{exercise}\n\t$D_B D_R D_B$ is NOT a reflection! In \\textbf{Fig. 4} describe what Dehn twists do to the shaded regions and figure out what $D_B D_R D_B$ really is.\n\\end{exercise}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "357f510bb974878c7e38b6d797c4e1d87ba2daf0", "size": 6131, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "01 All things manifoldy/04 - Dehn Twists.tex", "max_stars_repo_name": "apurvnakade/mc2017", "max_stars_repo_head_hexsha": "ebec59bce5ee1979872e0f37208da6abd91dbb75", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "01 All things manifoldy/04 - Dehn Twists.tex", "max_issues_repo_name": "apurvnakade/mc2017", "max_issues_repo_head_hexsha": "ebec59bce5ee1979872e0f37208da6abd91dbb75", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "01 All things manifoldy/04 - Dehn Twists.tex", "max_forks_repo_name": "apurvnakade/mc2017", "max_forks_repo_head_hexsha": "ebec59bce5ee1979872e0f37208da6abd91dbb75", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.7363636364, "max_line_length": 447, "alphanum_fraction": 0.7476757462, "num_tokens": 1756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.43391227389619885}}
{"text": "\\title{FYS-STK4155 \\\\\nProject 1}\n\\author{Lars Johan Brodtkorb}\n\\date{ }\n\n\\subsection*{Abstract}\n\nIn this exercise I have tried to figure out which method is to be preferred of ordinary least squares, Ridge and Lasso regressions. The results show a better prediction error for the ridge regression, but that may be due to a faulty implementation of the Lasso method. \n\n\\section{Introduction}\n\nThe main aim of this project is to study in more detail various\nregression methods, including the Ordinary Least Squares (OLS) method,\nRidge regression and finally Lasso regression.\nThe methods are in turn combined with resampling techniques.\n\nWe will first study how\nto fit polynomials to a specific two-dimensional function called\n\\href{{http://www.dtic.mil/dtic/tr/fulltext/u2/a081688.pdf}}{Franke's\n\tfunction}.  This\nis a function which has been widely used when testing various  interpolation and fitting\nalgorithms. Furthermore, after having etsablished the model and the\nmethod, we will employ resampling techniques such as the  cross-validation and/or\nthe bootstrap methods, in order to perform a proper assessment of our models.\n\n\nThe Franke function, which is a weighted sum of four exponentials  reads as follows\n\\begin{align*}\nf(x,y) &= \\frac{3}{4}\\exp{\\left(-\\frac{(9x-2)^2}{4} - \\frac{(9y-2)^2}{4}\\right)}+\\frac{3}{4}\\exp{\\left(-\\frac{(9x+1)^2}{49}- \\frac{(9y+1)}{10}\\right)} \\\\\n&+\\frac{1}{2}\\exp{\\left(-\\frac{(9x-7)^2}{4} - \\frac{(9y-3)^2}{4}\\right)} -\\frac{1}{5}\\exp{\\left(-(9x-4)^2 - (9y-7)^2\\right) }.\n\\end{align*}\n\nThe function will be defined for $x,y\\in [0,1]$.  Our first step will\nbe to perform an OLS regression analysis of this function, trying out\na polynomial fit with an $x$ and $y$ dependence of the form $[x, y,\nx^2, y^2, xy, \\dots]$. We will also include cross-validation and\nbootstrap as resampling techniques.  As in homeworks 1 and 2, we\ncan use a uniform distribution to set up the arrays of values for $x$\nand $y$, or as in the example below just a fix values for $x$ and $y$ with a given step size.\nIn this case we will have two predictors and need to fit a\nfunction (for example a polynomial) of $x$ and $y$.  Thereafter we will\nrepeat much of the same procedure using the the Ridge and\nLasso regression methods, introducing thus a dependence on the bias\n(penalty) $\\lambda$.\n\nThereafter we are going to use (real) digital terrain data and try to\nreproduce these data using the same methods. We will also try to go\nbeyond the second-order polynomials metioned above and explore \nwhich polynomial fits the data best.\n\n\n\\section{Methods}\n\n\n\\subsection{Measures of prediction accuracy}\n\nFind the confidence intervals of the $\\beta$ parameters by computing their variances, evaluate the Mean Squared error (MSE)\n\\[ MSE(\\hat{y},\\hat{\\tilde{y}}) = \\frac{1}{n}\n\\sum_{i=0}^{n-1}(y_i-\\tilde{y}_i)^2, \n\\] \nand the $R^2$ score function.\nIf $\\tilde{\\hat{y}}_i$ is the predicted value of the $i-th$ sample and $y_i$ is the corresponding true value, then the score $R^2$ is defined as\n\\[\nR^2(\\hat{y}, \\tilde{\\hat{y}}) = 1 - \\frac{\\sum_{i=0}^{n - 1} (y_i - \\tilde{y}_i)^2}{\\sum_{i=0}^{n - 1} (y_i - \\bar{y})^2},\n\\]\nwhere we have defined the mean value  of $\\hat{y}$ as\n\\[\n\\bar{y} =  \\frac{1}{n} \\sum_{i=0}^{n - 1} y_i.\n\\]\n\n\\subsection{Ordinary least square regression}\n\nWe have an input vector $X^T = (X_1,X_2,X_3,...,X_p)$ and want to predict a real-valued output Y. The linear regression model has the form: (\\cite{elementsstat}, chapter 3.2)\n\n\\begin{equation}\nf(X) = \\beta_0 + \\sum_{j=1}^{p}X_j\\beta_j\n\\end{equation}\n\n\nThe linear model either assumes that the regression function $E(Y |X)$ is\nlinear, or that the linear model is a reasonable approximation. The $\\beta_j$ ’s are unknown parameters or coefficients, and the variables $X_j$ can come\nfrom many different sources. One of them is that of basis expansions such as \n\n$X_2 = X_1^2, X_3 = X_1^3$, leading to a polynomial\nrepresentation;\n\nWe can use the basis expansions as a device to achieve more flexible representations for f(X). Polynomials are an example of this. Having great flexibility in approximation allows the basis expansions to work for many occurences, but their variability may increase heavily if they are applied outside their intended scope. The coefficients to achieve a functional form\nin one region can cause the function to flap about madly in remote regions (\\cite{elementsstat}, chapter 5.1, p. 140). \n\nThe polynomial method produces a dictionary $D$ consisting of typically a very large number of basis functions $|D|$, far more than we can afford to fit to our data. Along\nwith the dictionary we require a method for controlling the complexity\nof our model, using basis functions from the dictionary. There are three\ncommon approaches:\nRestriction, selection and regularization methods, which we will revisit in the Ridge and Lasso segment.\n\n\nNo matter the source of the $X_j$, the model is linear in the parameters. Typically we have a set of training data $(x_1, y_1)...(x_N , y_N )$ from which\nto estimate the parameters $\\beta$. Each $x_i = (x_{i1}, x_{i2},...,x_{ip})^T$ is a vector of feature measurements for the i-th case.\n\nUsing linear least squared fittings for $X \\in \\R^2$ we can get the linear function of X that minimizes the sum of the sum of squared residuals of Y.\n\nA unique solution for $\\beta$ has the form:\n\n\\begin{align*}\n\\beta =(\\textbf{X}^T\\textbf{X})^{-1}\\textbf{X}^T\\textbf{y}\n\\end{align*}\n\\medskip\n\nWe have made minimal assumptions about the true distribution\nof the data. In order to pin down the sampling properties of $\\hat{\\beta}$ , we now\nassume that the observations $y_i$ are uncorrelated and have constant variance\n$\\sigma^2$, and that the $x_i$ are fixed (non random). The $\\hyphenation{variance covariance}$\nmatrix of the least squares parameter estimates is then given by:\n\n\\begin{align*}\nVar(\\hat{\\beta}) =(\\textbf{X}^T\\textbf{X})^{-1}\\sigma^2\n\\end{align*}\n\\medskip\n\n\n\\subsection{K-fold cross-validation algorithm}\n\nCross-validation is probably the simplest and most widely used method for estimating prediction\nerror. This method directly estimates the expected\nextra-sample error $Err = E[L(Y, \\hat{f(X)})]$, the average generalization error when the method $\\hat{f(X)}$ is applied to an independent test sample from the joint distribution of X and Y. As mentioned earlier, we might hope that cross-validation estimates the conditional error, with the training set T held fixed. Unfortunately, cross-validation typically estimates well only the expected prediction error (\\cite{elementsstat}, chapter 7.10 - 7.12).\n\n\nK-fold crossvalidation uses part of the available data to fit the model, and a different part to test it. We split the data into K roughly equal-sized parts. For the kth part, we fit the model to the other $K-1$ parts of the data, and calculate the prediction error of the fitted model when predicting the kth part of the data. We do this for k = 1, 2,...,K and\ncombine the K estimates of prediction error.\n\n\nGiven a set of models $f(x,\\alpha)$ indexed by a tuning parameter $\\alpha$, denote \n$\\hat{f}^{-\\kappa(x,\\alpha)}$ by the $\\alpha$-th model fitted with the k-th part of the data removed. Then for this set of models we define:\n\n\\begin{equation}\nCV(\\hat{f},\\alpha) = \\frac{1}{N}\\sum_{i=1}^{N}L(y_i,\\hat{f}^{-\\kappa(i)}(x_i,\\alpha))\n\\end{equation}\n\\medskip\n\nwhere L is the loss function, $\\kappa$ is the removed data.\n\nThe function $CV(\\hat{f},\\alpha)$ provides an estimate of the test error curve, and we\nfind the tuning parameter $\\hat{\\alpha}$ that minimizes it. Our final chosen model is\n$f(x,\\hat{\\alpha})$, which we then fit to all the data.\n\\medskip\n\\medskip\n\nThe steps of the cross-validation method: \\newline\n(a) Find a subset of “good” predictors that show fairly strong (univariate) correlation with the class labels, using all of the samples except those in fold k.\\newline\n(b) Using just this subset of predictors, build a multivariate classifier, using all of the samples except those in fold k.\\newline\n(c) Use the classifier to predict the class labels for the samples in\nfold k.\n\n\\subsection{Bootstrap}\n\nThe bootstrap method has been used in this project to estimate the variance and bias.\nAs with cross-validation, the bootstrap seeks to estimate the conditional error, but typically estimates well only the expected prediction error.\n\nSuppose we have a model fit to a set of training data. We denote the\ntraining set by $Z = (z_1, z_2,...,z_N )$ where $z_i = (x_i, y_i).$ The basic idea is\nto randomly draw datasets with replacement from the training data, each\nsample the same size as the original training set. This is done B times\n(B = 200 in my application), producing B bootstrap datasets.\nThen we refit the model to each of the bootstrap datasets, and examine\nthe behavior of the fits over the B replications (\\cite{elementsstat} p.249)\n\n\n\n\n\\subsection{Ridge and Lasso regression}\n\n\\subsubsection*{Ridge regression}\nRidge regression is a simple example of a regularization approach, while the lasso is both a regularization and selection method. \n\nSelection methods adaptively scan the dictionary and include only those basis functions $h_m$ that contribute significantly to the fit of\nthe model.\n\nRegularization methods use the entire dictionary but restrict the coefficients.  (\\cite{elementsstat}, chapter 5.1 p.141)\n\nThe method used follows \\cite{ridge} quite closely. In chapter 1.4.2 on page 8 in \\cite{ridge} we find an estimator for $\\beta$ and variance in the ridge regression:\n\n\n\\begin{equation*}\n\\beta=(\\textbf{X}^T\\textbf{X}+\\lambda\\textbf{I})^{-1}\\textbf{X}^T\\textbf{y}\n\\end{equation*}\n\n\\medskip\n\\begin{equation*}\nVar(\\hat{\\beta}) =(\\textbf{X}^T\\textbf{X}+\\lambda\\textbf{I})^{-1}\\sigma^2\n\\end{equation*}\n\\medskip\n\nRidge regression shrinks the regression coefficients by imposing a penalty on their size. The ridge coefficients minimize a penalized residual sum of squares.\n\n\n\\begin{equation}\n\\hat{\\beta}_{ridge} =\\argmin_{\\beta}({\\sum_{i=1}^{N}(y_i - \\beta_0 -\\sum_{j=1}^{p}x_{ij}\\beta_j)^2 + \\lambda \\sum_{j=1}^{p}\\beta_j^2})\n\\end{equation}\n\\medskip\n\nHere $\\lambda\\ge 0 $ is a complexity parameter that controls the amount of shrinkage. The idea of penalizing by the sum-of-squares of the parameters is also used in neural networks,\nwhere it is known as weight decay (\\cite{elementsstat} p. 63)\n\n\\subsection*{Lasso regression}\nThe Lasso method is a shrinking method like Ridge. Just as in ridge regression, we can re-parametrize the constant $\\beta_0$ by standardizing the predictors; the solution for $\\hat{\\beta_0}$ is $\\hat{y}$, and thereafter we fit a model without an intercept. In the signal processing literature,\nthe Lasso is also known as basis pursuit (Chen et al., 1998).\nWe can also write the Lasso problem in the equivalent Lagrangian form:\n\n\\begin{equation}\n\\hat{\\beta}_{lasso} =\\argmin_{\\beta}(\\frac{1}{2}{\\sum_{i=1}^{N}(y_i - \\beta_0 -\\sum_{j=1}^{p}x_{ij}\\beta_j)^2 + \\lambda \\sum_{j=1}^{p}\\abs{\\beta_j}})\n\\end{equation}\n\\medskip\n\nThe difference from the ridge method is that the ridge penalty $\\sum_{j=1}^{p}\\beta_j^2$ is replaced with the Lasso penalty $\\sum_{j=1}^{p}\\abs{\\beta_j}$\n\n\\section{Code implementation}\nFor most of the code implementation see github repository: \\href{https://github.com/larsjbro/FYS-STK3155/tree/master/project1}{https://github.com/larsjbro/FYS-STK3155/tree/master/project1}. I will include the bootstrap method with comments in the report.\n\n\\subsection{Bootstrap}\n\nThe bootstrap method was implemented with the following code, which was used to generate the prediction error, bias and variance shown in the figures.\\newline\n\n\n\\lstinputlisting[language=Python]{bootstrap.py}\n\n\\medskip\n\n\n\\section{Analysis}\n\n\n\\subsection{Results}\n\n\n\\subsubsection{OLS}\n\nTable \\ref{Table:1} shows the fitted coefficients for the best ordinary least squares method fitted to the Frankfunkction along with its standard deviation, z-score and 95 percent confidence interval. As we can se from the table, only a few of the coefficients are significantly different from 0. In total table \\ref{Table:1} shows there are only 5 such coefficients. The other coefficients could have possibly been set to zero.\n\n\\FloatBarrier\n\\begin{table}\n\t\n\t\\begin{tabular}{lrrrrr}\n\t\t\\toprule\n\t\t{} &         coef &          std &   z\\_score &        Confidence interval 0.025 &        Confidence interval 0.975 \\\\\n\t\t\\midrule\n\t\t0  &    -1.648196 &     0.532137 & -3.097317 &    -2.691165 &    -0.605227 \\\\\n\t\t1  &    -1.919886 &     1.848958 & -1.038361 &    -5.543776 &     1.704005 \\\\\n\t\t2  &     6.699335 &     3.720084 &  1.800856 &    -0.591897 &    13.990566 \\\\\n\t\t3  &     1.577407 &    10.841403 &  0.145498 &   -19.671353 &    22.826166 \\\\\n\t\t4  &     0.248456 &     0.463744 &  0.535762 &    -0.660466 &     1.157378 \\\\\n\t\t5  &     3.048496 &     2.491046 &  1.223781 &    -1.833865 &     7.930857 \\\\\n\t\t6  &   -20.088662 &    12.870111 & -1.560877 &   -45.313616 &     5.136292 \\\\\n\t\t7  &   -17.914271 &    16.822026 & -1.064929 &   -50.884836 &    15.056294 \\\\\n\t\t8  &    81.253441 &    62.107653 &  1.308268 &   -40.475323 &   202.982204 \\\\\n\t\t9  &     0.006444 &     1.659116 &  0.003884 &    -3.245363 &     3.258252 \\\\\n\t\t10 &   -10.048598 &    13.844107 & -0.725839 &   -37.182548 &    17.085353 \\\\\n\t\t11 &   122.772857 &    58.256501 &  2.107453 &     8.592213 &   236.953501 \\\\\n\t\t12 &    18.202467 &    89.033985 &  0.204444 &  -156.300937 &   192.705871 \\\\\n\t\t13 &  -464.346238 &   295.293981 & -1.572488 & -1043.111806 &   114.419331 \\\\\n\t\t14 &    -5.577415 &     2.836466 & -1.966325 &   -11.136786 &    -0.018044 \\\\\n\t\t15 &   -17.666890 &    15.364312 & -1.149865 &   -47.780388 &    12.446608 \\\\\n\t\t16 &   188.349237 &    79.758452 &  2.361496 &    32.025544 &   344.672930 \\\\\n\t\t17 &   127.373969 &   100.448526 &  1.268052 &   -69.501525 &   324.249463 \\\\\n\t\t18 &  -781.831660 &   379.979896 & -2.057561 & -1526.578570 &   -37.084750 \\\\\n\t\t19 &     0.140168 &     8.835873 &  0.015864 &   -17.177825 &    17.458162 \\\\\n\t\t20 &    72.613196 &    63.561066 &  1.142416 &   -51.964203 &   197.190596 \\\\\n\t\t21 &  -603.170312 &   289.455482 & -2.083810 & -1170.492631 &   -35.847993 \\\\\n\t\t22 &  -176.329738 &   401.060283 & -0.439659 &  -962.393449 &   609.733972 \\\\\n\t\t23 &  2420.894666 &  1422.585633 &  1.701757 &  -367.321940 &  5209.111272 \\\\\n\t\t\\bottomrule\n\t\t\n\t\\end{tabular}\n\t\\caption{Values for the best fit ordinary least squares method for the data from the Frankefunction with m=300 and sigma=0.5}\n\t\\label{Table:1}\n\\end{table}\n\\FloatBarrier\n\n\nBelow are figures from the ordinary least squares method:\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n    \\includegraphics[width=1\\textwidth]{plot_ols_without_r2/olsprediction_error_vs_degrees_m300_l300_s0.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the maximum polynomial degree used in the OLS method, with a sample size of 300.}\n\t\\label{fig:1}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{plot_ols_without_r2/olsprediction_error_vs_degrees_m300_l300_s10.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the maximum polynomial degree used in the OLS method, with a sample size of 300 and a random gaussian noise with standard deviation of 0.1.}\n\t\\label{fig:1}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{plot_ols_without_r2/olsprediction_error_vs_degrees_m300_l300_s50.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the maximum polynomial degree used in the OLS method, with a sample size of 300 and a random gaussian noise with standard deviation of 0.5.}\n\t\\label{fig:1}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\subsubsection{Ridge}\n\nBelow are the figures for varying sample sizes, degree of polynomials and penalty with Ridge.\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{plot_ridge_without_r2/ridgeprediction_error_m300_d5_s0.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda,for Ridge regression with a sample size of 300 and a polynomial degree of 5}\n\t\\label{fig:2}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{plot_ridge_without_r2/ridgeprediction_error_m300_d5_s10.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda,for Ridge regression with a sample size of 300, polynomial degree of 5 and standard deviation of 0.1}\n\t\\label{fig:2}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{plot_ridge_without_r2/ridgeprediction_error_m300_d5_s50.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda,for Ridge regression with a sample size of 300, polynomial degree of 5 and standard deviation of 0.5}\n\t\\label{fig:2}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\n\n\\subsubsection{Lasso}\nBelow are the figures for varying sample sizes, polynomials and penalty with Lasso.\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{lasso_prediction_vs_lambda/lassoprediction_error_m300_d5_s0.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda, for Lasso regression method with a sample size of 300 and a polynomial degree of 5}\n\t\\label{fig:3}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{lasso_prediction_vs_lambda/lassoprediction_error_m300_d5_s10.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda, for Lasso regression method with a sample size of 300, polynomial degree of 5 and standard deviation of 0.1.}\n\t\\label{fig:3}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\FloatBarrier\n\\begin{figure}[!ht]\n\t\\centering\n\t\\FloatBarrier\n\t\\includegraphics[width=1\\textwidth]{lasso_prediction_vs_lambda/lassoprediction_error_m300_d5_s50.png}\n\t\n\t\\caption{This shows the bias-variance tradeoff as function of the regularization parameter, lambda, for Lasso regression method with a sample size of 300, a polynomial degree of 5 and standard deviation of 0.5}\n\t\\label{fig:3}\n\\end{figure}\n\\FloatBarrier\n\n\\medskip\n\n\\subsection{Discussion}\nFrom all the figures I will now consider prediction error, bias and variance for the various methods.\n\n\\subsubsection{OLS}\nFor the OLS I can see that the minimum prediction error is for a polynomial of degree 4 for all standard deviations 0, 0.1 and 0.5. IN all cases the value of the prediction error is about 0.004. The bias is smallest at 5 degrees in all cases. The variance is smallest for a degree 4 polynomial for standard deviations of 0 and 0.1. For standard deviation of 0.5 the smallest variance is at 3. For a degree 1 polynomial, we do have a low variance, but the bias is really high.\n\\medskip\n\nTable \\ref{Table:1} shows that there were only 5 significant coefficients, the other ones could possibly have been set to 0, but that was not implemented. In principle I could have found a best subset model here.\n\n\\subsubsection{Ridge}\nFor the ridge regression I can see a low prediction error for lambda being $10^{-4}$ and $10^{-10}$ for the 0 and 0.1 standard deviation cases, with a value of the prediction error of about 0.0035 and 0.002. The lowest value being for 0.1 standard deviation and lambda $10^{-4}$. For the 0.5 standard deviation case, the prediction error is the smallest at about 0.25 for lambda $10^{-4}$.\n\n\\subsubsection{Lasso}\nFor the lasso regression at standard deviation of 0 I can see a minimum prediction error of about 0.005 for lambda $10^{-7}$. For standard deviation 0.1 the prediction error is up to 0.015 and for standard deviation 0.5 it is all the way up to 0.25. This tells me that something might have gone wrong with the implementation of lasso. \n\n\\section{Conclusion}\n\nThe results show that the Ridge regression gives a better prediction error than the other two methods. That does not agree with the expected, since the Lasso method should have been better. I tried to figure out the reason why that happened, and I came up with the following explanation:\n\nThe formulation of Lasso is the same as for Ridge, but for the extra $\\beta$ term in Ridge. It seems clear from the results that the Ridge method was to be preferred, but on further inspection, it seemed that the Lasso method may have been worse because the standardization method was not done correctly for Lasso. I suspect this was the reason for Lasso being worse than the Ridge regression.\n\nI then implemented this standardization, and still found that the Lasso regression was inferior to the ridge regression, which I can not fully explain.\n\n\n\\section*{Improvements}\nI would have liked to complete the data analysis, and also figured out why Ridge regression showed superior results compared to the Lasso Regression. For the OLS method I could have found a best subset model after having found the significant coefficients.\n\n\n\\section{Bibliography}\n\\begin{thebibliography}{99}\n\t\\bibitem{projecttext}$\\href{https://github.com/CompPhysics/MachineLearning/blob/master/doc/Projects/2018/Project1/pdf/Project1.pdf}{https://github.com/CompPhysics/MachineLearning/blob/master/doc/Projects/2018/Project1/pdf/Project1.pdf}$\n\t\n\t\\bibitem{elementsstat}$\\href{https://github.com/CompPhysics/MachineLearning/blob/master/doc/Textbooks/elementsstat.pdf}{https://github.com/CompPhysics/MachineLearning/blob/master/doc/Textbooks/elementsstat.pdf}$\n\t\n\t\\bibitem{ridge}$\\href{https://arxiv.org/pdf/1509.09169.pdf}{https://arxiv.org/pdf/1509.09169.pdf}$\n\t\n\t\\bibitem{franke}$\\href{http://www.dtic.mil/dtic/tr/fulltext/u2/a081688.pdf}{http://www.dtic.mil/dtic/tr/fulltext/u2/a081688.pdf}$\n\t\n\t\n\\end{thebibliography}\n", "meta": {"hexsha": "a20000ce6b8d0d25b18d51cd15e8098a16a61404", "size": 21975, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "project1/1.tex", "max_stars_repo_name": "larsjbro/FYS-STK3155", "max_stars_repo_head_hexsha": "275dd448533506c25cd5e9904983a24b5cd1e255", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "project1/1.tex", "max_issues_repo_name": "larsjbro/FYS-STK3155", "max_issues_repo_head_hexsha": "275dd448533506c25cd5e9904983a24b5cd1e255", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project1/1.tex", "max_forks_repo_name": "larsjbro/FYS-STK3155", "max_forks_repo_head_hexsha": "275dd448533506c25cd5e9904983a24b5cd1e255", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.2713004484, "max_line_length": 475, "alphanum_fraction": 0.7419340159, "num_tokens": 6402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.8289388125473628, "lm_q1q2_score": 0.43388344251040273}}
{"text": "%%\\documentclass[handout]{beamer}\n%\\documentclass[aspectratio=169,13pt]{beamer}\n\n%\\input{./preamble}\n\n\\subtitle{Fast Fourier Transform}\n\n\\date{}\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\section{Model Problem}\n\n\\begin{frame}{Sparse Linear Systems and Time-independent PDEs}\n\n\\begin{itemize}\n\\item The Poisson equation serves as a model problem for numerical methods:\n\n\\lgcond{\n\\begin{itemize}\n\\sitem the 2D Poisson problem and resulting Kronecker product linear system are a common benchmark,\n\\sitem this system has the form $\\B T \\otimes \\B I + \\B I \\otimes \\B T$ where $\\B T$ is tridiagonal.\n\\end{itemize}\n}\n\n\\item Dense, sparse direct, iterative, FFT, and Multigrid methods provide increasingly good complexity for the problem: \n\n\\lgcond{\n\\begin{itemize}\n\\sitem dense linear system solve costs $O(n^3)$ naively,\n\\sitem nested dissection with Cholesky has $O(n^{3/2})$ complexity and $O(n\\log n)$ memory\n\\sitem Conjugate-Gradient gives $O(n^{3/2})$ complexity with $O(n)$ memory\n\\sitem FFT achieves $O(n \\log n)$ cost and multigrid achieves $O(n)$.\n\\end{itemize}\n}\n\n\\end{itemize}\n\n\\end{frame}\n\n\\section{Multigrid}\n\n\\begin{frame}{Multigrid}\n\n\\begin{itemize}\n\\item Multigrid employs a hierarchy of grids to accelerate iterative methods:\n\n\\lgcond{\n\\begin{itemize}\n\\item the residual equation $\\B A \\B{\\hat{x}} = \\B r$ on each fine grid, is approximately solved on the next coarser grid,\n\\mitem the equation is \\coloremph{restricted} by projection matrix $\\B P$, so that $\\B P \\B A \\B P^T \\B P \\B{\\hat{x}} = \\B P \\B r$\n\\mitem the interpolation operator (often given by $\\B P^T$) is used to obtain an approximate $\\B{\\hat{x}}$ based on the coarse grid approximate solution,\n\\mitem at each level we perform some smoothing operations (e.g. Jacobi or Conjugate Gradient) before restriction and after interpolation, \n\\mitem at the coarsest level we typically solve directly.\n\\end{itemize}\n}\n\\mdcond{}\n\n\\item The multigrid method works by resolving high-frequency error components on finer-grids and low-frequency error components on coarser grids:\n\n\\mdcond{\n\\begin{itemize}\n\\item smoothers are usually effective at reducing local error, but slow at resolving global (low-frequency) components of the error,\n\\mitem on coarser grids, the low frequency error may be resolved more quickly.\n\\end{itemize}\n}\n\n\\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}{Multigrid}\n\n\\begin{itemize}\n\\item Consider the Galerkin approximation with linear finite elements to the Poisson equation $u''=f(t)$ with boundary conditions $u(a)=u(b)=0$:\n\\[%\\forall i \\in \\{1,n\\} , \\quad \n\\phi_i^{(h)}(t) = \\begin{cases} (t-t_{i-1})/h &: t \\in [t_{i-1},t_i] \\\\ (t_{i+1}-t)/h &: t\\in [t_{i},t_{i+1}] \\\\ 0 &: \\text{otherwise} \\end{cases}\\]\nwhere $t_0=t_1=a$ and $t_{n+1}=t_n=b$.\n\\tlgcond{\nThe weak form with grid spacing of $h$ is\n\\begin{align*}\n\\int_a^b f(t) \\phi^{(h)}_i(t) dt &=  - \\sum_{j=1}^n x_j\\int_a^b {\\phi_j^{(h)}}'(t){\\phi_i^{(h)}}'(t) dt.\n\\end{align*}\nin multigrid, we define a coarse grid basis of $(n-1)/2$ functions, which are hat functions of twice the width,\n\\begin{align*}\n\\phi_i^{(2h)}(t) = \\frac 12\\phi_{2i-2}^{(h)}(t) + \\phi_{2i-1}^{(h)}(t) + \\frac 12\\phi_{2i}^{(h)}(t) = \\begin{cases} (t-t_{i-2})/2h &: t \\in [t_{i-2},t_i] \\\\ (t_{i+2}-t)/2h &: t\\in [t_{i},t_{i+2}] \\\\ 0 &: \\text{otherwise} \\end{cases}\n\\end{align*}\n}\n\\lgcond{}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Coarse Grid Matrix}\n\n\\begin{itemize}\n\\item Multigrid restricts the residual equation on the fine grid $\\B A^{(h)}\\B x = \\B r^{(h)}$ to the coarse grid:\n\\tlgcond{\nLet $\\B{\\phi}^{(2h)}=\\begin{bmatrix} \\phi_1^{(2h)} & \\cdots &  \\phi_{(n-1)/2}^{(2h)} \\end{bmatrix}$ and\n$\\B{\\phi}^{(h)}=\\begin{bmatrix} \\phi_1^{(h)} & \\cdots &  \\phi_{n}^{(h)} \\end{bmatrix}$ and define \\coloremph{restriction matrix} $\\B P$ so that $\\B{\\phi}^{(2h)}=\\B P \\B{\\phi}^{(h)}$, i.e., \n\\[\\B P = \\frac 12\\begin{bmatrix} 1 & 2 & 1 & & \\\\ & 1 & 2 & 1 & \\\\ & & \\ddots & \\ddots & \\ddots \\end{bmatrix} = \\begin{bmatrix} {\\B{p}^{(1)}} \\\\ {\\B{p}^{(2)}} \\\\ \\vdots \\end{bmatrix}.\\]\nThe coarse grid stiffness matrix is given by\n\\begin{align*}\na^{(2h)}_{ij} &= - \\int_a^b {\\phi_j^{(2h)}}'(t){\\phi_i^{(2h)}}'(t) dt \\\\\n&= - {\\B{p}^{(i)}}\\underbrace{\\bigg(\\int_a^b  {\\B \\phi^{(h)}}'(t) {{\\B{\\phi}^{(h)}}'}{}^T(t) dt\\bigg)}_{-\\B A^{(h)}}{\\B p^{(j)}}^T, \\\\\n\\B A^{(2h)} &= \\B P \\B A^{(h)} \\B P^T.\n% &=  - \\int_a^b ({\\phi_{2i-2}^{(h)}}'(t) + 2{\\phi_{2i-1}^{(h)}}'(t) + {\\phi_{2i}^{(h)}(t)}'(t))\n% ({\\phi_{2j-2}^{(h)}}'(t) + 2{\\phi_{2j-1}^{(h)}}'(t) + {\\phi_{2j}^{(h)}(t)}'(t))dt\n\\end{align*}\n\n%\\begin{align*}\n%\\int_a^b f(t) \\phi^{(h)}_i(t) dt &=  - \\sum_i x_i\\int_a^b {\\phi_j^{(h)}}'(t){\\phi_i^{(h)}}'(t) dt.\n%\\end{align*}\n%\n%To do so, we need to obtain a suitable basis transformation from $\\{\\phi^{(h)}_i\\}$ to $\\{\\phi^{(2h)}_i\\}$.\n%We would like a correct answer at each $t$ and can obtain a system of equations by integrating w.r.t. test functions $\\phi^{(h)}_j(h)$,\n%\\begin{align*}\n%\\sum_{i=1}^{n/2} x^{(2h)}_i \\int_a^b\\phi_i^{(2h)}(t)  \\phi_j^{(h)}(t)dt = \\sum_{i=1}^n x^{(h)}_i\\int_a^b \\phi_i^{(h)}(t) \\phi_j^{(h)}(t)dt\n%\\end{align*}\n}\n\\lgcond{}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Restricting the Residual Equation}\n\n\\begin{itemize}\n\\item Given the fine-grid residual $\\B r^{(h)}$, we seek to use the coarse grid to approximate $\\B x^{(h)}$ so that $\\B A \\B x^{(h)} \\approx \\B r^{(h)}$\n\n\\lgcond{\n\\begin{itemize}\n\\item\n%Let $\\B t = \\begin{bmatrix} a+h & a+2h & \\cdots & b-h \\end{bmatrix}^T$.\nGiven a function in the coarse grid basis, $u^{(2h)} = {\\B x^{(2h)}}^T\\B{\\phi}^{(2h)}$, we can express it in the fine-grid basis via\n\\begin{align*}\nu^{(2h)} &= {\\B x^{(2h)}}^T \\underbrace{\\B P \\B{\\phi}^{(h)}}_{\\B{\\phi}^{(2h)}} = \\underbrace{{\\B x^{(2h)}}^T \\B P}_{{\\B x^{(h)}}^T} \\B{\\phi}^{(h)}.\n\\end{align*}\n\\item\nConsequently, the solution to the restricted residual equation $\\B A^{(2h)}\\B x^{(2h)} = \\B r^{(2h)}$ will lead to an approximate residual equation solution on the fine grid \nwith $\\B x^{(h)} =\\B P^T\\B x^{(2h)}$.\n\\mitem\nNoting this, we derive the form of the coarse grid residual, %form the coarse grid problem via\n\\begin{align*}\n\\B r^{(2h)} &= \\B A^{(2h)}\\B x^{(2h)} \\\\\n&= \\B P\\B A^{(h)}\\B P^T \\B x^{(2h)}  = \\B P\\B A^{(h)}\\B x^{(h)}  \\\\\n&= \\B P\\B r^{(h)}. \n\\end{align*}\n\\end{itemize}\n%\\[w_i=u^{(2h)}(t_i)={\\B x^{(2h)}}^T\\B{\\phi}^{(2h)}(t_i)={\\B x^{(2h)}}^T\\B P \\underbrace{\\B{\\phi}^{(h)}(t_i)}_{\\B e_i}\\]\n% so $\\B w = \\B P^T{\\B x^{(2h)}}$.\n%Note that for a function in the fine grid basis, $u^{(h)} = {\\B x^{(h)}}^T\\B{\\phi}^{(h)}$, we have $u^{(2h)}(t_i) = x^{(h)}_i$.\n%Consequently, we can express the coarse grid function in the fine grid basis via\n%\\begin{align*}\n%u^{(h)}(t) &= \\underbrace{{\\B x^{(2h)}}^T \\B P}_{\\B x^{(h)}^T} \\B{\\phi}^{(h)}\n%\\end{align*}\n}\n\\lgcond{}\n\\end{itemize}\n\n\\end{frame}\n\n%\\begin{frame}{Multigrid Restriction}\n%\n%\\begin{itemize}\n%\\item Multigrid restricts the residual equation on the fine grid to the coarse grid:\n%\\tlgcond{\n%To do so, we need to obtain a suitable basis transformation from $\\{\\phi^{(h)}_i\\}$ to $\\{\\phi^{(2h)}_i\\}$,\n%\\begin{align*}\n%\\B V(\\{\\phi_{2i-1}^{(2h)}\\}_{i=1}^{(n-1)/2},\\{t_i\\}_{i=1}^n) \\B x^{(2h)} \\cong  \\B V(\\{\\phi_i\\}_{i=1}^n,\\{t_i\\}_{i=1}^n)  \\B x^{(h)}\n%\\end{align*}\n%For linear finite elements $\\B V(\\{\\phi_i^{(h)}\\}_{i=1}^n,\\{t_i\\}_{i=1}^n)= \\B I$ so we obtain,\n%\\begin{align*}\n% \\B V(\\{\\phi_{2i-1}^{(2h)}\\}_{i=1}^{(n-1)/2},\\{t_i\\}_{i=1}^n)\\B x^{(2h)} =  \\B x^{(h)}.\n%\\end{align*}\n%Multigrid requires values of the residual $\\{r(t_{2i-1}\\}_{i=1}^{(n-1)/2}$ on the coarse grid, whose coefficients $\\B x^{(2h)}$ are then given by\n%\\begin{align*}\n%\\B r^{(2h)} = \\underbrace{\\B V(\\{\\phi_{i}^{(h)}\\}_{i=1}^{n},\\{t_{2i-1}\\}_{i=1}^{(n-1)/2})}_{\\B I}\\B x^{(h)} &=  \\B V(\\{\\phi_{2i-1}^{(2h)}\\}_{i=1}^{(n-1)/2},\\{t_i\\}_{i=1}^n)\\B x^{(2h)}.\n%\\end{align*}\n%}\n%\\end{itemize}\n%\\end{frame}\n\n\\section{Fast Fourier Transform}\n\n\\begin{frame}{Discrete Fourier Transform}\n\n\\begin{itemize}\n\\item The solutions to hyperbolic PDEs like Poisson are wave-like and take on simple representations in the frequency basis, both for continuous and discretized equations. We define the \\coloremph{discrete Fourier transform} using\n$$\n\\omega_{(n)} = \\cos(2\\pi/n) - i\\sin(2\\pi/n) = e^{-2\\pi i/n}.\n$$\n\\lgcond{\nThe DFT matrix $\\B F\\in\\mathbb{R}^{n\\times n}$ is given by\n$f_{ij}=\\omega_{(n)}^{ij}$,\n$$\n\\B{F} =\n\\left[ \\begin{matrix}\n1 & 1 & 1 & 1 \\cr\n1 & \\omega_{(4)}^{1} & \\omega_{(4)}^{2} & \\omega_{(4)}^{3} \\cr\n1 & \\omega_{(4)}^{2} & \\omega_{(4)}^{4} & \\omega_{(4)}^{6} \\cr\n1 & \\omega_{(4)}^{3} & \\omega_{(4)}^{6} & \\omega_{(4)}^{9} \\end{matrix}\n\\right]$$\n\n\\begin{itemize}\n\\item it is complex and symmetric (not Hermitian),\n\\item it is unitary modulo scaling $\\B F^{*} = n\\B F^{-1}$.\n\\end{itemize}\nThe discrete Fourier transform of vector $\\B v$ is $\\B F \\B v$.\n}\n\\lgcond{}\n\n\\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}{Fast Fourier Transform (FFT)}\n\n\\begin{itemize}\n\\item Consider $\\B b=\\B{F}\\B a$, we have\n\\[\\forall j\\in[0,n-1] \\quad b_j=\\sum_{k=0}^{n-1}\\omega_{(n)}^{jk}a_k,\\]\nthe FFT computes this recursively via 2 FFTs of dimension $n/2$, using $\\omega_{(n/2)}=\\omega_{(n)}^2$,\n\\lgcond{\n\\begin{align*}\n%\\forall j\\in[0,n-1] \\quad \nb_j&=\\sum_{k=0}^{n/2-1}\\omega_{(n)}^{j(2k)}a_{2k}+\\sum_{k=0}^{n/2-1}\\omega_{(n)}^{j(2k+1)}a_{2k+1} \\\\\n&=\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k}+\\omega_{(n)}^j\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k+1}\n\\end{align*}\n}\n\\lgcond{}\n%, so\n%\\[\\forall j\\in[1,n/2] \\quad b(2j)=\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_k\\]\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Fast Fourier Transform Derivation}\n\n\\begin{itemize}\n\\item The FFT leverages similarity between the first and second half of the output,\n\\begin{align*}\nb_j&=\\underbrace{\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k}}_{u_j}+\\omega_{(n)}^j\\underbrace{\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k+1}}_{v_j}\n\\end{align*}\ncorresponds closely to the entry shifted by $n/2$,\n\\begin{align*}\n b_{j+n/2}&=\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{(j+n/2)k}a_{2k}+\\omega_{(n)}^{j+n/2}\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{(j+n/2)k}a_{2k+1} \n\\end{align*}\n\\lgcond{\nNow $\\omega_{(n/2)}^{(j+n/2)k}=\\omega_{(n/2)}^{jk}$ since $(\\omega_{(n/2)}^{n/2})^k=1^k=1$ and using $\\omega_{(n)}^{n/2}=-1$,\n%$\\forall j\\in[0,n/2-1]$\n\\begin{align*}\nb_{j+n/2}\n&=\\underbrace{\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k}}_{u_j}-\\omega_{(n)}^{j}\\underbrace{\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k+1}}_{v_j} \n\\end{align*}\n}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{FFT Algorithm Summary}\n\n%Each of these two summation can be done recursively with an FFT %of dimension $n/2$\n% which can then be combined to compute the upper and lower halves of $b$\n\\begin{itemize}\n\\item Let vectors $\\B u$ and $\\B v$ be two recursive FFTs, $\\forall j\\in[0,n/2-1]$\n\\begin{align*}\nu_j&=\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k}, \\quad\nv_j=\\sum_{k=0}^{n/2-1}\\omega_{(n/2)}^{jk}a_{2k+1}\n\\end{align*}\n\\lgcond{\n\\begin{itemize}\n%\\item We can make these two recursive calls simultaneously and without any work\n\\item Given $\\B u$ and $\\B v$ scale using \"twiddle factors\" $z_j=\\omega_{(n)}^j\\cdot v_j$\n\\item Then it suffices to combine the vectors as follows\n\\(\\B b=\\begin{bmatrix} \\B u+\\B z \\\\ \\B u-\\B z\\end{bmatrix}\\)\n%\\item This recombination is an FFT of dimension 2\n%\\[\\B b=\\begin{bmatrix} \\B{b}_1 \\\\ \\B{b}_2 \\end{bmatrix} = \\vc{\\begin{bmatrix} \\B b_1 & \\B b_2\\end{bmatrix}} = \n%\\vcop\\bigg(\\begin{bmatrix} \\B u & \\B z \\end{bmatrix} \\underbrace{\\begin{bmatrix} 1 & 1 \\\\ 1 & -1 \\end{bmatrix}}_{\\B{F_4}[0:2,0:2]}\\bigg) %=\n%%\\vc{\\begin{bmatrix} \\B u & \\B z \\end{bmatrix} \\B{F_2}}\n%\\]\n%\\vspace{-.2in}\n%\\item Radix-$r$ algorithm for any $\\B{A}\\in\\mathbb{R}^{n/r\\times r}$ \n%\\[\n%%\\vc{\\B{B}}=\n%\\B{F}_{n}\\vc{\\B{A}} = \\vc{\\big([\\B{F}_{n}[0:r,0:r] \\odot (\\B{F}_r \\B{A})]\\B{F}_{n/r})^T}\\]\n%%\\ \\text{ if and only if } \\ \\B{B} = \\B{F}_{n/r} \\B{A} \\B{F}_r\\]\n\\end{itemize}\n}\n\\item The FFT has $O(n \\log n)$ cost complexity:\n\n\\lgcond{\nThere are two recursive calls of dimension $n/2$ and $O(n)$ work for application to twiddle factors and final summation, thus\n$$T(n)=2T(n)+O(n)=O(n\\log n).$$\n} \n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Applications of the FFT}\n\\begin{itemize}\n\\item We can rapidly multiply degree $n$ polynomials by considering their values $\\omega_{(2n-1)}^i$ for $i\\in\\{0,\\ldots,2n-1\\}$\n\\lgcond{\n\\[p_c(\\omega_{(2n-1)}^i)=p_a(\\omega_{(2n-1)}^i)p_b(\\omega_{(2n-1)}^i)\\]\n\\begin{itemize}\n\\item The product of coefficients of $p_a,p_b$ with Vandermonde matrix $v_{ij}=(\\omega_{(2n-1)}^{i})^{j}$, which is the DFT matrix, gives values of polynomials at $2n-1$ nodes.\n\\mitem Interpolation to compute coefficients of $p_c$ from the products of values of $p_a$ and $p_b$ at those nodes is multiplication by the inverted DFT matrix and is exact since $p_c$ is degree $2n-2$.\n\\end{itemize}\n}\n\n\\item More generally the DFT can be used to solve any Toeplitz linear system (convolution):\n\\lgcond{\n\\begin{itemize}\n\\item\nA standard convolution has the form,\n\\(\\forall k\\in [0,n-1] \\quad c_k = \\sum_{j=0}^k a_jb_{k-j}.\\)\n\\mitem Convolution is equivalent to multiplications of polynomials with degree $n/2-1$ and coefficients  $\\Vec a$ and $\\Vec b$, where\n%\\[p_a(x) = \\sum_{k=0}^{n/2-1} a_kx^k,\\quad\n%p_b(x) = \\sum_{k=0}^{n/2-1} a_kx^k\\]\nthe convolution computes the coefficients $\\Vec c$ of the product of the two polynomials.\n%\\[p_c(x) = p_a(x)p_b(x) = \\sum_{k=0}^{n-1} c_kx^k\\]\n\\end{itemize}\n}\n\\end{itemize}\n\\end{frame}\n\n\n\n\n\\begin{frame}{Convolution via DFT}\n\n\\begin{itemize}\n\\item The Fourier transform method for computing a convolution is given by\n\\begin{align*}\nc_k &= %\\sum_s D^{-1}_{ks} \\Big(\\sum_j D_{sj} a_j\\Big)\\Big(\\sum_t D_{st} b_t\\Big) \n  \\frac 1n \\sum_s \\omega^{-ks}_{(n)} \\Big(\\sum_j \\omega^{sj}_{(n)} a_j\\Big)\\Big(\\sum_t \\omega_{(n)}^{st} b_t\\Big)\n\\end{align*}\n\\lgcond{\n\\begin{itemize}\n\\item Rearrange the order of the summations to see what happens to every product of $a$ and $b$\n\\begin{align*}\nc_k &%= \\frac 1n \\sum_s\\sum_j\\sum_t \\omega^{-ks}_{(n)} \\omega_{(n)}^{sj}\\omega^{st}_{(n)} a_j b_t\n = \\frac 1n \\sum_s\\sum_j\\sum_t \\omega^{(j+t-k)s}_{(n)} a_j b_t \n\\end{align*}\n\\item For any $u=j+t-k\\neq 0$, we observe $\\sum_s(\\omega_{(n)}^u)^s=0$ %, as for $\\Mat F\\Mat F^{-1}$\n\\mitem When $j+t-k=0$ the products $\\omega^{(s+t-j)k}_{(n)}=1$, so there are $n$ nonzero terms $a_jb_{k-j}$ in the summation\n\\end{itemize}\n}\n\\lgcond{}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Solving Numerical PDEs with the FFT}\n\n\n\\urcornerlinkdemo{12-fft}{Fast Fourier Transform}\n\n\\begin{itemize}\n\\item 1D finite-difference schemes on a regular grid correspond to convolutions:\n\n\\mdcond{\n1D model problem is simply convolution with vector $[1, -2, 1]$.\n}\n\n\\item For the 1D Poisson model problem, the eigenvectors of $\\B T$ corresponds to the imaginary part of a minor of a $2(n+1)$-dimensional DFT matrix:\n\n\\mdcond{\n\\begin{itemize}\n\\item\nIn particular, $\\B T =\\B X \\B D \\B X^{-1}$ where $x_{ij}$ is the imaginary part of $f_{i+1,j+1}$ with $\\B X\\in \\mathbb{R}^{n\\times n}$ and $\\B F \\in \\mathbb{R}^{2(n+1)\\times 2(n+1)}$.\n\\mitem\nConsequently, $\\B T$ can be diagonalized and the overall system solved by FFT with $O(n\\log n)$ cost.\n\\end{itemize}\n}\n\n\\item Multidimensional Poisson can be handled with multidimensional FFT:\n\n\\mdcond{\nFor example 2D FFT (1D FFT of each row then 1D FFT of each column) suffices to solve the 2D Poisson problem.\n}\n\n\\end{itemize}\n\n\\end{frame}\n\n%\\end{document}\n\n", "meta": {"hexsha": "e1147b6907a11e928b9f13b533abbdfc46d8e90e", "size": 15249, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "12-body.tex", "max_stars_repo_name": "solomonik/cs450-notes", "max_stars_repo_head_hexsha": "7f4d18705dac5730b7e40e588acf55030c9d823a", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "12-body.tex", "max_issues_repo_name": "solomonik/cs450-notes", "max_issues_repo_head_hexsha": "7f4d18705dac5730b7e40e588acf55030c9d823a", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "12-body.tex", "max_forks_repo_name": "solomonik/cs450-notes", "max_forks_repo_head_hexsha": "7f4d18705dac5730b7e40e588acf55030c9d823a", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.2005141388, "max_line_length": 232, "alphanum_fraction": 0.6281067611, "num_tokens": 6203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.43373641660919354}}
{"text": "% !TEX options=--shell-escape\n\\documentclass [12pt]{article} \n\n\\usepackage {amsmath}\n\\usepackage {amsthm}\n\\usepackage {amssymb}\n\\usepackage {graphicx} \n\\usepackage {float}\n\\usepackage {multirow}\n\\usepackage {xcolor}\n\\usepackage {algorithmic}\n\\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \\usepackage {array} \n\\usepackage {booktabs} \n\\usepackage {url} \n\\usepackage {parskip} \n\\usepackage [margin=1in]{geometry} \n\\usepackage [T1]{fontenc} \n\\usepackage {cmbright} \n\\usepackage [many]{tcolorbox} \n\\usepackage [colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref} \n\\usepackage {enumitem} \n\\usepackage {xparse} \n\\usepackage {verbatim}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{csquotes}\n\\usepackage[cache=false]{minted}\n\\usepackage{mdframed}\n\\newtheorem{theorem}{Theorem}\n\n\\BeforeBeginEnvironment{minted}{\\begin{mdframed}}\n\\AfterEndEnvironment{minted}{\\end{mdframed}}\n\n\\DeclareTColorBox {Solution}{}{breakable, title={Solution}}\n\\DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}}\n\\DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt}\n\\DeclareDocumentCommand {\\Expecting }{+m}{\\textbf {[We are expecting:} #1\\textbf {]}}\n\\DeclareDocumentCommand {\\Points }{m}{\\textbf {(#1 pt.)}} \n\n\\begin {document} \n\n{\\LARGE \\textbf {COMP 285 (NC A\\&T, Spr `22)}\\hfill \\textbf {Homework 3} } \n\\vspace {1em} \n\\begin {Instruction} \n\n\\paragraph {Due.} Tuesday, February 9th, 2022 @ 11:59 PM!\n\\end {Instruction} \n\n\\vspace {1em} \n\\begin {Instruction} \\paragraph {Homework Expectations:} Please see \\href{https://www.comp285.ml/homework/#general-homework-information}{Homework}.\n\\end {Instruction}\n\n\\vspace {1em} \n\\begin {Instruction} \n\n\\paragraph {Exercises} The following questions are exercises. We encourage you to work with a group and discuss solutions to make sure you understand the material.\n\n\\paragraph {Points} This assignment is graded out of 100 points. However, you can get up to 120 points if you complete everything. These are not bonus points, but rather points to help make-up any parts you miss.\n\n\\end {Instruction} \n\n\\begin{centering}\n\\section*{Fun with Divide and Conquer, Sorting, and Medians}\n\\end{centering}\n\n\\begin{Instruction}\n\n\\paragraph{Written Problems} The following questions are to be submitted in written/typed form to gradescope.\n\n\\end{Instruction}\n\n\\section{Getting to Know You \\Points{10}}\n\nAs part of this homework assignment, I'd like to get to know each of you.\n\nDo the following:\n\n\\begin{itemize}\n    \\item \\Points{5} Schedule a 10 minute conversation with me in the available slots \\href{https://calendly.com/comp285-prof/get-to-know-you?month=2022-02}{here}.\n    \\item \\Points{5} When you're done with the homework, complete this \\href{https://forms.gle/KpC8RJ3gvkPgQPYY7}{form}.\n\\end{itemize}\n\n\\Expecting{You should have scheduled a meeting with me for an available slot and submit the form. All of this is tracked and this is how we'll confirm to give you credit for this question.}\n\n\\pagebreak\n\\section{Exercise: A faster MergeSort? \\Points{10}}\nInspired by all of our discussion on recursion and sorting, Miah, Ryan, and Jordan get together to try and figure out a faster\\footnote{We will not cover in class, but it has been proven that there is no deterministic algorithm faster than $\\theta(n \\log n)$ for sorting numbers using comparisons.} way to sort! After many attempts, they write down the following sorting function:\n\n\\vspace{2em}\n\\begin{minted}[linenos=true]{cpp}\n// MergeSort algorithm!\nstd::vector<int> mergeSortN(const std::vector<int>& input) {\n    const std::size_t n = input.size();\n    if (n <= 1) {\n        return input;\n    }\n    std::vector<std::vector<int>> sortedSubvectors = {};\n    for (int i = 0; i < n; i++) {\n        std::vector<int> temp = mergeSortN(\n            {input.begin() + i, input.begin() + i + 1}\n        );\n        sortedSubvectors.push_back(temp);\n    }\n    std::vector<int> sortedA = {};\n    for (const std::vector<int> subVector : sortedSubvectors) {\n        sortedA = merge(sortedA, subVector);\n    }\n    return sortedA;\n}\n\\end{minted}\n\n\\subsection{What is this doing!? \\Points{5} }\nIn your own words, describe that the algorithm above is doing. This should not take more than a few sentences, but should highlight how this is different from the normal implementation of \\texttt{MergeSort}.\n\n\\Expecting{A few sentences describing, in plain English, what the algorithm above does.}\n\n\\subsection{How fast is it?! \\Points{5}}\nJordan claims this version of \\texttt{MergeSort} is much faster than any versions we've seen before. This is his argument:\n\n\\begin{displayquote}\n    This modified \\texttt{MergeSort} splits the array into $n$ subproblems of size $O(1)$ immediately. We therefore don’t waste time with the `$log(n)$ levels’ worth of splitting. Additionally, in this modified sort, we’re calling \\texttt{Merge} on a bunch of subvectors of size $1$. Each merge would therefore take time\n\n    $$\n        O(\\text{size of subvector A}) + O(\\text{size of subvector B}) = O(1) + O(1) = O(1)\n    $$\n    That's contant time per merge! Yay! We therefore have an algorithm that sorts the input array in $O(n)$ time - $n$ merges of $O(1)$ each!\n\\end{displayquote}\n\nSadly, Jordan's analysis is \\textbf{wrong}. It was a valiant try, though. Let's help Miah, Ryan, and Jordan out! What mistake are they making in their analysis above, and what is the true runtime of their modified \\texttt{MergeSort}.\n\n\\Expecting{An explanation (one sentence) that summarizes the mistake in the above reasoning and the correct runtime of \\texttt{mergeSortN} along with an explanation (another sentence).} \n\n\n\\pagebreak\n\\section{Interview Practice: Finding Matching Elements \\Points{10}}\nCaleb is working on a ``search'' algorithm at Foogle. He is given an array \\texttt{input} of $n$ integers that is sorted in ascending order and contains only unique elements. That is to say, if his array is\n$$\na = [a_1, a_2, \\cdots, a_{n-1}, a_n]\n$$\n\nthen $a_1 < a_2 < \\cdots < a_{n-1} < a_n$. \n\nHis project is to search the above array and find the element such that its index is equal to its value, or returns that such $i$ does not exist. That is to say, the algorithm finds $i$ such that $i = a_i$.\n\n\\subsection{A first proposal. \\Points{5}}\n\\label{subsec:first_proposal}\nCaleb proposes the following pseudo-code for an algorithm that solves the problem described above.\n\n\\begin{verbatim}\nAlgorithm:\n    Input: A vector \"input\" sorted in ascending order with no duplicates.\n    Outputs: The index i such that the i-th index contains the value i.\n\n    n = len(input)\n    for i = 0 to i = n - 1\n        if (i == input[i]):\n            return i\n\n    throw \"No such index exists\"\n\\end{verbatim}\n\nDescribe in plain English how Caleb's algorithm works, and provide the big-Oh running time.\n\n\\Expecting{A few sentences describing how the algorithm Caleb wrote works in plain English, as well as $O(\\cdots)$ where $\\cdots$ is filled in with the proper running time.}\n\n\\subsection{Your Proposal. \\Points{5}}\n\\label{subsec:second_proposal}\nAfter looking at Caleb's proposed algorithm, you realize that he's not taking advantage of the fact that the input array is sorted. Give an $O(\\log n)$ algorithm that solves the same problem (eg, it finds the index $i$ such that $i = a_i$ or returns that such $i$ does not exist). If there are multiple such $i$s, your algorithm can return any of them \\footnote{Consider a divide-and-conquer approach, similar to binary search! If you'd like to refresh your memory on binary search, see this \\href{https://www.youtube.com/watch?v=P3YID7liBug}{video}.}.\n\n\\Expecting{Pseudocode for you algorithm, similar to what Caleb wrote in Part \\ref{subsec:first_proposal}, as well as a plain English description of what your algorithm is doing and why it is correct. You \\textbf{do not} need to proof correcness.}\n\n\n\\pagebreak\n\\section{Interview Practice: Finding Medians \\Points{30}}\nYou are given two arrays, each of length $n$. Your goal is to find the median of all elements of the two arrays.\n\n\n\\subsection{Unsorted Arrays \\Points{10}}\nIf the arrays \\textbf{are not sorted}, give a $\\Theta(n \\log n)$ algorithm that returns the median of the combined arrays.\n\n\\Expecting {A short English description of your approach, the pseudocode (similar to Part \\ref{subsec:second_proposal}), and an explanation of your algorithm's runtime.}.\n\n\n\\subsection{Unsorted Arrays But Faster \\Points{10}} \n\nIf the arrays \\textbf{are not sorted}, give an $\\Theta(n)$ algorithm that returns the median of the combined arrays\\footnote{Hint: You can use `Select(A, k)' directly, without explanation, since this was given in lecture}.\n\n\\Expecting {A short English description of your approach, the pseudocode (similar to Part \\ref{subsec:second_proposal}), and an explanation of your algorithm's runtime.}.\n\n\n\\subsection{Sorted Arrays \\Points{10}}\n\nIf the arrays \\textbf{are sorted}, give an $O(\\log n)$ algorithm that returns the median of the combined arrays. Here are a few hints to help you. Try to look at these only after you've given the problem a bit of thought on your own.\n\n\\begin{enumerate}[label=Hint \\arabic*]\n    \\item You probably want to use divide-and-conquer.\n    \\item Calculating the median of a single sorted array can be done in $O(1)$ time (how?).\n    \\item If the biggest element in one array (eg, the last element) is smaller than the smallest element in another array (eg, the first element), you can also compute the median $O(1)$ time (how?).\n    \\item If you look at the medians of the two arrays, how does that help you split the problem into parts? What do you know if the median of the two arrays are equal? What if one is bigger than the other?\n\\end{enumerate}\n\n\\Expecting {A short English description of your approach, the pseudocode (similar to Part \\ref{subsec:second_proposal}), and an explanation of your algorithm's runtime.}.\n\n\\pagebreak\n\\section {Exercise: Randomized Algorithms \\Points {10}} \n\\label{sec:last}\n\nIn this exercise, we'll explore different types of randomized algorithms. We say that a randomized algorithm is a \\textbf {Las Vegas algorithm} if it is always correct (that is, it returns the right answer with probability 1), but the running time is a random variable. We say that a randomized algorithm is a \\textbf {Monte Carlo algorithm} if there is some probability that it is incorrect. For example, QuickSort (with a random pivot) is a Las Vegas algorithm, since it always returns a sorted array, but it might be slow if we get very unlucky. \n\nWe will visit the Majority Element problem to get more insight on randomized algorithms. The Majority Element problem is to find the element in a collection of elements that occurs at least half of the time. See Algorithm \\ref{alg:isMajority} for how we would check if an element is the majority.\n\nWe will assume that such an element always exists.\n\n\\vspace{2em}\n\\begin{minted}[linenos=true]{cpp}\n// Returns 2, because it occurs 4 times which is greater\n// than 6/2 = 3.\nfindMajorityElement({2, 2, 2, 2, 3, 5});\n// Returns 10, because it occurs 3 times which is greater\n// than 5/2 = 2.5\nfindMajorityElement({10, 10, 10, 2, 4});\n// Returns 4 because it occurs 3 times, which is greater\n// than 4/2 = 2.\nfindMajorityElement({4, 4, 2, 4})\n\\end{minted}\n\n\\vspace{2em}\n\\begin{center} \n\\begin{tabular}{|c|p{3cm}|p{2cm}|p{2cm}|p{4cm}|}\n\\hline \nAlgorithm & Monte Carlo or Las Vegas? & Expected running time & Worst-case running time & Probability of returning a majority element \\\\\n\\hline \n\\textbf {Algorithm 1} & & & & \\\\ \n\\hline \n\\textbf {Algorithm 2} & & & & \\\\\n\\hline \n\\textbf {Algorithm 3} & & & & \\\\ \n\\hline \n\\end{tabular}\n\\end{center}\n\n\\Expecting {Your filled in-table. You may use asymptotic notation for the running times.} \\newpage \n\n\\begin{algorithm}[H]\n    \\KwIn {A population $P$ of $n$ elements}\n    \\While {true} { \n        Choose a random $p \\in P$\\;\n        \\If {\\textsc {isMajority}($P$, $p$)}{\n            \\Return { $p$}\\; \n        }\n    } \n    \\caption {\\textsc {findMajorityElement1}}\n\\end{algorithm} \n\n\\begin{algorithm}[H]\n    \\KwIn {A population $P$ of $n$ elements}\n    \\For {100 iterations} { \n        Choose a random $p \\in P$\\;\n        \\If {\\textsc {isMajority}($P$, $p$)}{ \n            \\Return { $p$ }\\;\n        } \n    }\n    \\Return { $P[0]$\\;} \n    \\caption {\\textsc {findMajorityElement2}}\n\\end{algorithm} \n\n\\begin{algorithm}[H]\n    \\KwIn {A population $P$ of $n$ elements}\n    Put the elements in $P$ in a random order.\\; \n    \\tcc{Assume it takes time $\\Theta (n)$ to put the $n$ elements in a random order}\n    \\For { $p \\in P$ } {\n        \\If {\\textsc {isMajority}($P$, $p$)}{\n            \\Return { $p$ }\\; \n        }\n    }\n    \\caption {\\textsc {findMajorityElement3}}\n\\end{algorithm} \n\n\\begin{algorithm}[H]\n    \\KwIn {A population $P$ of $n$ elements and a element $p \\in P$}\n    \\KwOut {True if $p$ is a member of a majority species} \n    count $\\gets $ 0\\;\n    \\For { $q \\in P$ } {\n        \\If { $p = q$ }{\n            count ++\\;\n        }\n    }\n    \\If { count $> n/2$ }{\n        \\Return {True}\\;\n    } \\Else {\n        \\Return {False}\\;\n    }\n    \\caption {\\textsc {isMajority}} \n    \\label{alg:isMajority}\n\\end{algorithm} \n\n\n\n\\pagebreak\n\\begin{Instruction}\n\n\\paragraph{Coding Problems} The following questions are to be submitted as a \".zip\" file on Gradescope. \n\n\\end{Instruction}\n\n\\section{Coding \\Points{50}}\n\\Points{50} After completing the written portion of the assignment, you should submit to \\href{https://www.gradescope.com/courses/350304}{Gradescope}.\n\nYou can get your starter code for the coding portion \\href{https://replit.com/team/COMP285/HW3-Code}{here}.\n\nNote that the starter code also include a few test cases you can run on repl.it. However, the full test suite is the one run on Gradescope.\n\nPlease reference the \\texttt{README.md} included in your starter code for detailed instructions.\n\n\\section*{Submitting the Assignment}\n\nThis assignment is a combination of written and programming questions. Both portions of the assignment should be submitted through \\href{https://www.gradescope.com/courses/350304}{Gradescope}.\n\nThe \"Homework 3: Fun with Divide and Conquer, Sorting, and Medians\" assignment is the written portion, for which you should submit a \\textbf{typed} response to the non-coding questions (questions 1-\\ref{sec:last}). Each response should clearly be marked with its corresponding number. You are free to use the provided templates, print the questions and write your answers, or to simply type your responses on a blank document (whatever works for you).\n\nThe \"Homework 3: Coding\" is the programming portion of the assignment. For this portion, download the \".zip\" file from replit and upload this \".zip\" file as your answer to \\href{https://www.gradescope.com/courses/350304}{Gradescope}. You can upload the assignment as many times as you want.\n\n\n\\end {document} ", "meta": {"hexsha": "395a6ab9b7e9ef504daae6eb5a94e99cab7e098b", "size": 15015, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/homework/hw3/hw3.tex", "max_stars_repo_name": "facebookEIR/algorithms-course", "max_stars_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-16T02:47:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-16T02:47:46.000Z", "max_issues_repo_path": "assets/homework/hw3/hw3.tex", "max_issues_repo_name": "facebookEIR/algorithms-course", "max_issues_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/homework/hw3/hw3.tex", "max_forks_repo_name": "facebookEIR/algorithms-course", "max_forks_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-01-20T21:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T03:00:16.000Z", "avg_line_length": 45.7774390244, "max_line_length": 552, "alphanum_fraction": 0.7181485181, "num_tokens": 4125, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.4337364135882228}}
{"text": "%by Maarten Burger, Alexander Apers, and Jos Zuiderwijk\n\\chapter{Chapter 11. Soundness and Completeness}\n\n\\section*{11.7.1 Part A --- Doing}\n\nIn the following, I give both full, detailed answers to the questions\nand an indication of the expectations I have for a good answer. Note\nthat my way of answering is very detailed and there might be many\ndifferent, equally valid ways of writing up the same result. Note that\nthe correctness of the answer is always a factor but by far not the\nonly one. If, as in 11.7.3, the correctness of the answer is one out\nof 4 elements of a correct answer, just writing down the correct\nanswer can give at most 1/4th of the points.\n\nKeep in mind that since this is your first formal course, I give you a\nlot of leeway when it comes to precise, mathematical formulations, but\nthe elements of a good answer should always be there to get decent\npoints.\n\n\\begin{itemize}\n\n\\item[11.7.1.1] \\emph{Long answer}: In order to determine all variable and\n  quantifier occurrences, we first construct the stripped parsing\n  tree for the formula:\n  \\begin{center}\n    \\Tree [.{$\\forall x$}\n             [.{$\\exists y$}\n                [.{$\\to$}\n                 [.{$R$}\n                   [.{$x$} ]\n                   [.{$y$} ]\n                 ]\n                 [.{$\\forall x$}\n                    [.{$\\land$}\n                         [.{$P$} [.$x$ ] ]\n                         [.{$\\exists y$} [.{$R$} [.$x$ ] [.$y$ ] ] ]\n                    ]\n                 ]\n                ]\n             ]\n             ]\n  \\end{center}\n  The following table contains the information which variable\n  occurrence is bound by which quantifier occurrence:\n    \\begin{longtable}{c | c}\n      Variable occurrence      & Quantifier occurrence that binds it\\\\\\hline\n      $((r,1,1,1,1), x)$       & $(r, \\forall x)$\\\\\n      $((r,1,1,1,2), y)$       & $((r,1), \\exists y)$\\\\\n      $((r,1,1,2,1,1,1), x)$   & $((r,1,1,2), \\forall x)$\\\\\n      $((r,1,1,2,1,2,1,1), x)$ & $((r,1,1,2), \\forall x)$\\\\\n      $((r,1,1,2,1,2,1,2), y)$ & $((r,1,1,2,1,2), \\exists y)$\n    \\end{longtable}\n\n    \\emph{Elements of a good answer}:\n\n    \\begin{itemize}\n    \\item Proper naming of the occurrences.\n    \\item Clear statement which variable occurrence is bound by which\n      quantifier occurrence.\n    \\item Correct answer.\n    \\item Fully formulated sentences. \n    \\end{itemize}\n    \n  \\item[11.7.1.2] \\emph{Full answer}:\n    \\begin{enumerate}\n    \\item $\\forall x(V(x)\\to L(x))$\n    \\item $\\neg \\forall x(L(x)\\to \\forall y(\\neg L(y)\\to I(x,y)))$\n    \\item $L(x)\\land \\neg V(x)\\land \\neg D(x)$\n    \\item $\\exists x(\\neg L(x)\\land \\neg D(x))$\n    \\end{enumerate}\n\n    \\emph{Elements of a good answer}:\n\n    \\begin{itemize}\n    \\item Formalizations are indeed formulas.\n    \\item Adequate formalizations.\n    \\item Recognizes $V(x)\\to L(x)$ as the best formalization of ``only\n      if''\n    \\item Recognizes ``he'' as an indefinite pronoun, i.e. free\n      variable.\n      \\item Recognizes the subordinate clause indicated by the commas\n        in (iv) to indicate an existential quantifier.\n    \\end{itemize}\n\n   \\item[11.7.1.3] \\emph{Long answer}: We are asked to determine the value of $\\llbracket\n     (0+x)\\cdot S(0)\\rrbracket^\\mathcal{M}_\\alpha$ for the given model\n     and assignment. Applying the recursive definition of the\n     denotation of a term in a model under an assignment, we get the\n     following calculation:\n     \\begin{align*}\n       \\llbracket (0+x)\\cdot\n       S(0)\\rrbracket^\\mathcal{M}_\\alpha&=\\llbracket\n                                          0+x\\rrbracket^\\mathcal{M}_\\alpha\\cdot^\\mathcal{M} \n                                          \\llbracket\n                                          S(0)\\rrbracket^\\mathcal{M}_\\alpha\n       \\\\\n       &=(\\llbracket\n         0\\rrbracket^\\mathcal{M}_\\alpha+^\\mathcal{M}\\llbracket\n         x\\rrbracket^\\mathcal{M}_\\alpha)\\cdot^\\mathcal{M}\n         S^\\mathcal{M}(\\llbracket 0\\rrbracket^\\mathcal{M}_\\alpha)\\\\\n                                        &=(0^\\mathcal{M}+^\\mathcal{M}\\alpha(x))\\cdot^\\mathcal{M}S^\\mathcal{M}(0^\\mathcal{M})\\\\\n                                        &=(1 +^\\mathcal{M}3)\\cdot ^\\mathcal{M}S^\\mathcal{M}(1)\\\\\n                                        &= 5\\cdot 3\\\\\n                                        &=15\n     \\end{align*}\n\n     \\emph{Elements of a good answer}:\n\n     \\begin{itemize}\n     \\item Explains what's being done.\n     \\item Applies the recursive clauses in sufficient detail.\n     \\item Applies the functions from the model correctly.\n     \\item Gets the correct result.\n     \\end{itemize}\n\n  \\item[11.7.1.4] \\emph{(Very) Long Answer}: We claim that\n    $\\mathcal{M},\\alpha\\vDash \\forall x\\forall y(R(x,y)\\to R(f(y), f(x)))$.\n    In order to determine what we need to show is, we observe the following\n    \\begin{itemize}\n      \\item[] $\\mathcal{M},\\alpha\\vDash \\forall\n        x\\forall y(R(x,y)\\to R(f(y), f(x)))$\n      \\item[\\emph{iff}] for all $d\\in D^\\mathcal{M}$,\n        $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash \\forall y(R(x,y)\\to\n        R(f(y), f(x)))$\n      \\item[\\emph{iff}] for all $d,d'\\in D^\\mathcal{M}$,\n        $\\mathcal{M},\\alpha[x\\mapsto d, y\\mapsto d']\\vDash R(x,y)\\to\n        R(f(y), f(x))$\n    \\end{itemize}\n    Since there are only 2 elements in $D^\\mathcal{M}=\\{1,2\\}$,\n    there are 4 possible choices for $d$ and $d'$ to consider:\n    \\begin{itemize}\n      \\item $d=1, d'=1$\n      \\item $d=1, d'=2$\n      \\item $d=2, d'=1$\n      \\item $d=2, d'=2$\n    \\end{itemize}\n    Since for all choices of $d$ and $d'$ other than $d=1, d'=2$, we\n    have that $\\mathcal{M},\\alpha[x\\mapsto d, y\\mapsto d']\\nvDash\n    R(x,y)$, so we don't have to check anything else to see that $\\mathcal{M},\\alpha[x\\mapsto d, y\\mapsto d']\\vDash R(x,y)\\to\n    R(f(y), f(x))$.\n\n    For $d=1, d'=2$, we observe that:\\[\\llbracket\n    f(x)\\rrbracket^\\mathcal{M}_{\\alpha[x\\mapsto d, y\\mapsto\n    d']}=f^\\mathcal{M}(1)=2\\]\\[\\llbracket\n    f(y)\\rrbracket^\\mathcal{M}_{\\alpha[x\\mapsto d, y\\mapsto\n    d']}=f^\\mathcal{M}(2)=1.\\]\n    But then, we have\n    $\\mathcal{M}, \\alpha[x\\mapsto d, y\\mapsto d']\\vDash R(f(y), f(x))$\n    and so\n    $\\mathcal{M},\\alpha[x\\mapsto d, y\\mapsto d']\\vDash R(x,y)\\to R(f(y), f(x))$.\n\n      So, for each choice of $d,d'\\in D^\\mathcal{M}$, we have \\[\\mathcal{M},\\alpha[x\\mapsto d, y\\mapsto d']\\vDash R(x,y)\\to\n      R(f(y), f(x))\\] and so \\[\\mathcal{M},\\alpha\\vDash \\forall\n      x\\forall y(R(x,y)\\to R(f(y), f(x)),\\] as desired.\n\n    \\emph{Elements of a good answer}:\n\n    \\begin{itemize}\n    \\item Applies the clause for the universal quantifier.\n    \\item Considers all the values for the variables.\n    \\item Notices that the only interesting case is when the value of\n      $x$ is 1 and the value of $y$ 2.\n    \\item Gives the correct answer.\n    \\item Explains reasoning.\n    \\item Is written in full, comprehensible sentences.\n    \\end{itemize}\n\n  \\item[11.7.1.5]\n\n    \\begin{enumerate}\n\n      \\item%\n        By definition,\n        $\\exists x(P(x)\\land x=c),\\forall x(P(x)\\to Q(x))\\vdash  Q(c)$\n        iff the tableau for\n        $\\{ \\exists x(P(x)\\land x=c),\\forall x(P(x)\\to Q(x)),\\neg Q(c)\\}$\n        is closed.\n        Here is the tableau:\n\n        \\begin{center}\n          \\begin{prooftree}\n            {%\n              line numbering=false,\n              for tree={s sep'=10mm},\n              single branches=true,\n              close with=\\xmark\n            }\n            [{\\exists x(P(x)\\land x=c)}, grouped\n                [{\\forall x(P(x)\\to Q(x))}, grouped\n                    [{\\neg Q(c)}, grouped\n                        [{P(p)\\land p=c}\n                            [{P(p)}\n                                [{p=c}\n                                    [{P(p)\\to Q(p)}\n                                        [{\\neg P(p)}, close ]\n                                        [{Q(p)}\n                                            [{\\neg Q(p)}, close]\n                                        ]\n                                    ]\n                                ]\n                            ]\n                        ]\n                    ]\n                ]\n            ]\n          \\end{prooftree}\n        \\end{center}\n        Since the tableau is closed,\n        we can infer the conclusion from the premises as claimed.\n\n        \\emph{Elements of a good answer}:\n        \\begin{itemize}\n          \\item%\n            Explains why the tableau is done.\n          \\item%\n            Makes a tableau for\n            $\\Gamma\\cup\\{\\neg\\phi\\}$\n            not for $\\Gamma\\cup\\{\\phi\\}$.\n          \\item%\n            Applies all rules correctly.\n          \\item%\n            Recognizes the correct application of the identity rule to close the second branch.\n          \\item%\n            Gets the correct answer.\n        \\end{itemize}\n\n\\item By definition, $P(c)\\lor (P(c)\\land Q(c)), \\forall x(Q(x)\\to\n  \\neg P(c))\\vdash \\neg P(c)$ iff the tableau for $\\{P(c)\\lor (P(c)\\land Q(c)), \\forall x(Q(x)\\to\n  \\neg P(c)), \\neg\\neg P(c)\\}$ is closed. Here is the tableau:\n\n  \\begin{center}\n  \\begin{prooftree}\n{\nline numbering=false,\nfor tree={s sep'=10mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[{P(c)\\lor (P(c)\\land Q(c))}, grouped \n     [{\\forall x(Q(x)\\to \\neg\n  P(x)}, grouped\n          [{\\neg\\neg P(c)}, grouped\n                 [{P(c)}\n                     [{P(c)}\n                          [{Q(c)\\to \\neg P(c)}\n                               [{\\neg Q(c)}]\n                               [{\\neg P(c)}, close]\n                          ]\n                     ]\n                     [{P(c)\\land Q(c)}\n                          [{P(c)}\n                              [{Q(c)}\n                                   [{Q(c)\\to \\neg P(c)}\n                                     [{\\neg Q(c)}, close]\n                                     [{\\neg P(c)}, close]\n                                   ]\n                              ]\n                         ]\n                     ]\n                 ]\n          ]\n     ]\n]\n\\end{prooftree}\n\\end{center}\nSince the tableau is open, we cannot infer the conclusion from the\npremises, as claimed. The associated model of the only open branch is\ngiven by the following specification:\n\\begin{itemize}\n   \\item $D^\\mathcal{M}=\\{c\\}$\n   \\item $c^\\mathcal{M}=c$\n   \\item $P^\\mathcal{M}=\\{c\\}$\n   \\item $Q^\\mathcal{M}=\\emptyset$\n   \\end{itemize}\n\n   \\emph{Elements of a good answer}:\n\n   \\begin{itemize}\n   \\item  Explains why the tableau is done.\n  \\item Makes a tableau for $\\Gamma\\cup\\{\\neg\\phi\\}$ not for\n    $\\Gamma\\cup\\{\\phi\\}$.\n  \\item Applies all rules correctly.\n    \\item Makes a complete tableau (i.e. applies \\emph{all} possible\n      rules).\n  \\item Gets the correct tableau.\n   \\item Specifies the associated model completely (including the\n     interpretation of $c$ and $Q$).\n    \\item Gets the correct model.\n   \\end{itemize}\n   \n    \\end{enumerate}\n\n    \\item[11.7.1.6] \\emph{Long answer}: We're asked to determine whether\n      the following \n      inference is valid:\n      \\begin{itemize}\n      \\item The ball is round, and everything round comes from\n        Mars. So, the ball comes from Mars. \n      \\end{itemize}\n      In order to determine the validity of the argument, we first\n      formalize it. We make use of the following translation key:\n      \\begin{center}\n        \\begin{tabular}[!h]{c c c}\n          $b$   & : & the ball\\\\\n          $R^1$ & : & \\dots is round\\\\\n          $M^1$ & : & \\dots comes from Mars\n        \\end{tabular}\n      \\end{center}\n      We obtain \\[R(b), \\forall x(R(x)\\to M(x))\\therefore M(b)\\]\n\n      I claim that this inference is valid, i.e. \\[R(b), \\forall\n        x(R(x)\\to M(x))\\vDash M(b)\\]\n\n      In order to show that I'm making use of the tableau method. We\n      know that $R(b), \\forall\n        x(R(x)\\to M(x))\\vdash M(b)$ iff the tableau for $\\{R(b), \\forall\n        x(R(x)\\to M(x)),\\neg  M(b)\\}$ is closed. Here is that tableau:\n\n        \\begin{center}\n  \\begin{prooftree}\n{\nline numbering=false,\nfor tree={s sep'=10mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[{R(b)}, grouped\n[{\\forall x(R(x)\\to M(x))}, grouped\n[\\neg M(b), grouped\n[{R(b)\\to M(b)}\n    [{\\neg R(b)}, close]\n    [{M(b)}, close]\n]\n]\n]\n]\n\\end{prooftree}\n\\end{center}\nSince the tableau is closed, we can infer that \\[R(b), \\forall\n        x(R(x)\\to M(x))\\vdash M(b).\\] By the soundness theorem, our\n        claim that \\[R(b), \\forall\n        x(R(x)\\to M(x))\\vDash M(b)\\] follows from this.\n\n        We have now shown that the formal inference \\[R(b), \\forall\n        x(R(x)\\to M(x))\\therefore M(b)\\] is valid. Since this formal\n        inference is a formalization of the natural language inference\n        we started with, we can infer that the natural language\n        inference is valid, too.\n\n        \\emph{Elements of a good answer}:\n\n        \\begin{itemize}\n        \\item Explains what is done.\n        \\item Formalizes the inference.\n        \\item Gets a decent formalization.\n        \\item Checks whether the inferences entail the conclusion with\n          a suitable method (tableau or semantics).\n        \\item Applies that method correctly.\n        \\item Transfers the results back to the natural language\n          inference.\n        \\item Gets the correct result.\n        \\end{itemize}\n    \n\\end{itemize}\n\n\\section*{11.7.2 Part B --- Proving}\n\n      Below, I provide a proof for each of the claimed\n      theorems. Please keep in mind that, as I said in the last\n      lecture, if a mathematical claim is provable, then there is\n      always more than one proof of it. This means, the proofs I\n      provide are not the only possible proofs. The merit of the answers I formulate below is that they might give you a better\n      idea of what I expect a good answer to look like. Also keep in\n      mind that my answer are always as explicit as possible, and I\n      don't necessarily expect the same level of attention to detail\n      from you.\n      \n      The\n      \\emph{elements of a good answer} are the same in every case:\n      \\begin{itemize}\n      \\item Recognizes correctly what needs to be shown.\n      \\item Explains each reasoning step, doesn't have gaps in the\n        argumentation.\n      \\item Uses correct reasoning, doesn't commit fallacies.\n      \\item Applies the definitions correctly.\n      \\item Is written in full, grammatical English/Dutch sentences.\n      \\item Obtains the correct result.\n      \\end{itemize}\n\n      Here is a (non-exhaustive) list of marking categories that we\n      use:\n      \\begin{longtable}{c | l}\n\t\tAbbreviation & Mistake \\\\\n\t\t\\hline\n\t\t\\lightning & Error/mistake (generic)\\\\\n\t\tDf. & Incorrect or imprecise definition \\\\\n\t\tQ\\textbf{?} & Question not read correctly\\\\\n\t\t$\\not\\Rightarrow$ & Non-sequitur, reasoning mistake\\\\\n\t\t$\\neq$ & Calculation mistake \\\\\n\t\t$\\qedsymbol$? & QED missing, reasoning incomplete\\\\\n\t\t\\textbf{x}? & Undeclared variables\\\\\n\t\t$\\Rightarrow$\\textbf{?} & Right-to-left direction missing \\\\\n\t\t$\\Leftarrow$\\textbf{?} & Left-to-right direction missing \\\\\n\t\t$\\underline{\\lor}$ & Distinction by cases not exhaustive\\\\\n\t\t$abc$ & Write complete sentences.\\\\\n\t\t{[squiggles]} & No (unexplained)  paintings!\n\t\t\\end{longtable}\n\n        \\begin{itemize}\n                \\item[11.7.2.1] We're asked to show that if $\\phi$ is an\n                  open formula with $y$ as its only free variable,\n                  then $\\forall x\\phi$ is also an open formula\n                  (i.e. not a sentence). We\n                  show this claim by showing that for every free\n                  occurrence of $y$ in $\\phi$ there will be a\n                  corresponding free occurrence of $y$ in $\\forall\n                  x\\phi$. Since there are free occurrences of $y$ in\n                  $\\phi$, from this the claim follows.\n\n                  So, consider a free occurrence of $y$ in\n                  $\\phi$. Clearly, there is a corresponding occurrence\n                  of $y$ in $\\forall x\\phi$. What remains\n                  to be shown is that the occurrence is free. Suppose,\n                  for indirect proof, that it's not. This would mean\n                  that there's a quantifier occurrence of the form\n                  $Qy$ in $\\forall x\\phi$, which binds the occurrence\n                  of $y$. That quantifier occurrence cannot have a\n                  corresponding occurrence in $\\phi$, because then the\n                  occurrence of $y$ in $\\phi$ would be bound, contrary\n                  to our assumption. But the only quantifier\n                  occurrence that's in $\\forall x\\phi$ without a\n                  corresponding occurrence in $\\phi$ is $(r,\\forall\n                  x)$. But this occurrence cannot bind any occurrence\n                  of $y$ since $x\\neq y$. Hence, $y$ needs to be free\n                  in $\\forall y\\phi$, as desired.%$\n\n                  \\emph{Alternative strategy (way more complicated)}:\n                  Using induction on formulas.\n\n                  \\item[11.7.2.2] We're asked to show that for all $\\Gamma$, we\n                    have $\\Gamma\\vdash P(c)\\lor \\neg P(c)$. We know,\n                    by definition, that this is the case iff the\n                    tableau for $\\Gamma\\cup\\{\\neg (P(c)\\lor \\neg\n                    P(c))\\}$ is closed. But we can infer that this\n                    tableau is closed even without knowing what the\n                    members of $\\Gamma$ are. To see this, note that\n                    the initial list consists in $\\Gamma\\cup\\{\\neg (P(c)\\lor \\neg\n                    P(c))\\}$, so we can always close the tableau as follows:\n                    \\begin{center}\n  \\begin{prooftree}\n{\nline numbering=false,\nfor tree={s sep'=10mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[{\\Gamma}, grouped\n[{\\neg (P(c)\\lor\\neg P(c)}, grouped\n[{\\neg P(c)}\n[{\\neg\\neg P(c)}\n[{P(c)}, close\n]\n]\n]\n]\n]\n\\end{prooftree}\n\\end{center}\nHence the tableau is always closed, which is what we needed to show.\n\n            \\emph{Alternative strategy}: Semantically show that\n                $\\Gamma\\vDash P(c)\\lor\\neg P(c)$ and then use\n                completeness to infer the result.\n\n          \\item[11.7.2.3] We aim to show that\n            $\\forall x(\\phi\\to\\psi)\\vDash\\neg \\exists x(\\phi\\land\n            \\neg\\psi)$.\n            By definition, we know that\n            $\\forall x(\\phi\\to\\psi)\\vDash\\neg \\exists x(\\phi\\land \\neg\\psi)$\n            iff for all models $\\mathcal{M}$,\n            we have that if\n            $\\mathcal{M},\\alpha\\vDash \\forall x(\\phi\\to\\psi)$, then\n            $\\mathcal{M},\\alpha\\vDash\\neg \\exists x(\\phi\\land\\neg\\psi)$\n            (for some arbitrary assignment $\\alpha$).\n            So, let $\\mathcal{M}$ be an\n            arbitrary model and suppose that\n            $\\mathcal{M},\\alpha\\vDash\\forall x(\\phi\\to\\psi)$.\n            This means, by definition, that for all\n            $d\\in D^\\mathcal{M}$ we have\n            $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            \\phi\\to\\psi$.\n            From this, we need to derive that\n            $\\mathcal{M},\\alpha\\vDash\\neg \\exists x\n            (\\phi\\land\\neg\\psi)$.\n            We do this indirectly.\n            Suppose\n            that $\\mathcal{M},\\alpha\\nvDash\\neg \\exists x\n            (\\phi\\land\\neg\\psi)$.\n            It follows that  $\\mathcal{M},\\alpha\\vDash \\exists x\n            (\\phi\\land\\neg\\psi)$.\n            This means, by definition,\n            that there must be a $d\\in D^\\mathcal{M}$ such that\n            $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            \\phi\\land\\neg\\psi$.\n            From this it would follow\n            that $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            \\phi$ and $\\mathcal{M},\\alpha[x\\mapsto\n            d]\\nvDash\\psi$, and so $\\mathcal{M},\\alpha[x\\mapsto d]\\nvDash\n            \\phi\\to\\psi$.\n            But this would contradict our\n            assumption that  $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            \\phi\\to\\psi$ for all $d\\in D^\\mathcal{M}$.\n            So, by\n            indirect proof, we can infer that  $\\mathcal{M},\\alpha\\vDash\\neg\n            \\exists x(\\phi\\land\\neg\\psi)$, as desired.\n                  \n                  \\item[11.7.2.4] We want to find a model\n                    $\\mathcal{M}^+$ that makes\n                    $\\forall x\\exists yR(x,y)$ true and a model\n                    $\\mathcal{M}^-$ that makes the formula\n                    false. There are different ways in which\n                    we can achieve this, for example via tableau. You\n                    know how that works, so I provide an answer that\n                    I found by thinking about what needs to be the\n                    case for the formula to be true/false\n\n                    First, consider the model $\\mathcal{M}^+$ given by:\n                    \\begin{itemize}\n                    \\item $D^{\\mathcal{M}^+}=\\{\\ast\\}$\n                    \\item $R^{\\mathcal{M}^+}=\\{(\\ast,\\ast)\\}$\n                    \\end{itemize}\n                    I claim that we have $\\mathcal{M}^+,\\alpha\\vDash\n                    \\forall x\\exists yR(x,y)$. To see this, remember\n                    that $\\mathcal{M}^+,\\alpha\\vDash\n                    \\forall x\\exists yR(x,y)$ iff for all\n                    $d\\in D^{\\mathcal{M}^+}$, we have\n                    $\\mathcal{M}^+,\\alpha[x\\mapsto d]\\vDash\n                    \\exists yR(x,y)$. And we have $\\mathcal{M}^+,\\alpha[x\\mapsto d]\\vDash\n                    \\exists yR(x,y)$ iff for some $d'\\in\n                    D^{\\mathcal{M}^+}$, we have\n                    $\\mathcal{M}^+,\\alpha[x\\mapsto d, y\\mapsto d']\\vDash\n                    R(x,y)$. So, we have that $\\mathcal{M}^+,\\alpha\\vDash\n                    \\forall x\\exists yR(x,y)$ iff for all $d\\in\n                    D^{\\mathcal{M}^+}$ there exists a $d'\\in\n                    D^{\\mathcal{M}^+}$ such that  $\\mathcal{M}^+,\\alpha[x\\mapsto d, y\\mapsto d']\\vDash\n                    R(x,y)$. But there is only one element in\n                    $D^{\\mathcal{M}^+}$, namely $\\ast$. And for\n                    $d=\\ast$, we can easily find a $d'$ such that $\\mathcal{M}^+,\\alpha[x\\mapsto d, y\\mapsto d']\\vDash\n                    R(x,y)$, namely $d'=\\ast$. To see this, just note\n                    that $\\mathcal{M}^+,\\alpha[x\\mapsto \\ast, y\\mapsto \\ast]\\vDash\n                    R(x,y)$ since\n                    $(\\ast, \\ast)\\in R^\\mathcal{M}$. So, $\\mathcal{M}^+,\\alpha\\vDash\n                    \\forall x\\exists yR(x,y)$, as desired.\n\n                    Now, consider the model $\\mathcal{M}^-$ given by:\n                    \\begin{itemize}\n                    \\item $D^{\\mathcal{M}^+}=\\{\\ast\\}$\n                    \\item $R^{\\mathcal{M}^+}=\\emptyset$\n                    \\end{itemize}\n                   As in the case of $\\mathcal{M}^+$, we can infer\n                   that $\\mathcal{M}^-,\\alpha\\vDash\n                    \\forall x\\exists yR(x,y)$ iff for all $d\\in\n                    D^{\\mathcal{M}^-}$ there exists a $d'\\in\n                    D^{\\mathcal{M}^-}$ such that  $\\mathcal{M}^-,\\alpha[x\\mapsto d, y\\mapsto d']\\vDash\n                    R(x,y)$. Again, there is only one element in\n                    $D^{\\mathcal{M}^-}$, namely $\\ast$. But for\n                    $d=\\ast$, there exists no $d'$ such that $\\mathcal{M}^-,\\alpha[x\\mapsto d, y\\mapsto d']\\vDash\n                    R(x,y)$. For the only possible $d'$ would $\\ast$\n                    itself and we have $\\mathcal{M}^-,\\alpha[x\\mapsto \\ast, y\\mapsto \\ast]\\nvDash\n                    R(x,y)$ since $R^{\\mathcal{M}-}=\\emptyset$. So  $\\mathcal{M}^-,\\alpha\\nvDash\n                    \\forall x\\exists yR(x,y)$, as desired.\n                    \n                    \\item[11.7.2.5]We need to show that if $\\Gamma\\vDash\n                      c\\neq c$, then $\\Gamma$ is unsatisfiable. By\n                      definition $\\Gamma$ is satisfiable iff there is\n                      a model $\\mathcal{M}$ and assignment $\\alpha$\n                      such that $\\mathcal{M},\\alpha\\vDash \\phi$ for\n                      all $\\phi\\in\\Gamma$. So, assume that $\\Gamma\\vDash\n                      c\\neq c$. We derive that $\\Gamma$ is\n                      unsatisfiable using indirect proof. So suppose\n                      that $\\Gamma$ is satisfiable, that is there is\n                      a model $\\mathcal{M}$ and assignment $\\alpha$\n                      such that $\\mathcal{M},\\alpha\\vDash \\phi$ for\n                      all $\\phi\\in\\Gamma$. Since $\\mathcal{M},\\alpha\\vDash \\phi$ for\n                      all $\\phi\\in\\Gamma$ and $\\Gamma\\vDash c\\neq c$,\n                      it follows that $\\mathcal{M},\\alpha\\vDash c\\neq\n                      c$. But that would entail that\n                      $c^\\mathcal{M}\\neq c^\\mathcal{M}$, which is\n                      impossible. So, there is no such $\\mathcal{M}$\n                      and $\\alpha$ and $\\Gamma$ is therefore unsatisfiable.\n\n                  \\item[11.7.2.6] We're asked to prove that for all\n                    terms $s$ and $t$ we have, in the given model\n                    $\\mathcal{M}$ and under the given assignment\n                    $\\alpha$, that $\\llbracket\n                    s\\rrbracket^\\mathcal{M}_\\alpha=\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha$. In order to prove\n                    this fact, we show that for all $t$ we have $\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}$. From\n                    this, the claim follows immediately since then we\n                    have: \\[\\llbracket\n                    s\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}=\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha\\]\n\n                    So, we want to prove by induction that for all $t$ we have $\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}$. We\n                    have two base cases: (i) either $t$ is a constant\n                    or (ii) $t$ a variable. If (i) $t$ is a constant, then\n                    $t=a$, since $a$ is the only constant of\n                    $\\mathcal{S}$. And trivially, if $t=a$,  we have\n                    $\\llbracket t\\rrbracket^\\mathcal{M}=\\llbracket\n                    a\\rrbracket^\\mathcal{M}=a^\\mathcal{M}$. If (ii)\n                    $t$ is a variable $x\\in \\mathcal{V}$, then\n                    $\\llbracket t\\rrbracket^\\mathcal{M}=\\llbracket\n                    x\\rrbracket^\\mathcal{M}=\\alpha(x)=a^\\mathcal{M}$,\n                    as desired.\n\n                    For the induction step, assume the induction\n                    hypothesis that $\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}$. We\n                    need to derive from this that $\\llbracket\n                    f(t)\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}$,\n                    as well. To see this, we can reason as follows:\n                    \\[\\llbracket\n                    f(t)\\rrbracket^\\mathcal{M}_\\alpha=f^\\mathcal{M}(\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha)=f^\\mathcal{M}(a^\\mathcal{M})=a^\\mathcal{M}\\]\n\n                  So, using the principle of induction on terms, we\n                  have seen that  $\\llbracket\n                    t\\rrbracket^\\mathcal{M}_\\alpha=a^\\mathcal{M}$ for\n                    all terms $t$, from which our main claim follows\n                    as explained before.\n\n                  \\item[11.7.2.7] We're asked to prove by induction that\n                    if $\\phi$ is an open formula with $x$ as its only\n                    free variable, then $(\\phi)[x:=c]$ where $c$ is a\n                    constant is a closed formula, i.e. a sentence.\n\n                    For the base case, we need to consider two\n                    situations: (i) $\\phi$ is of the form $R(t_1,\n                    \\mathellipsis, x, \\mathellipsis, t_n)$ where the\n                    $t_i$ are ground terms or (ii)\n                    $\\phi$ is of the form $t=x$ or $x=t$ where $t$ is\n                    a ground term. In case (i),\n                    we simply observe that since each $t_i$ is a\n                    ground term and thus doesn't contain $x$, we have $(R(t_1,\n                    \\mathellipsis, x, \\mathellipsis,\n                    t_n))[x:=c]=R(t_1, \\mathellipsis, c,\\mathellipsis,\n                    t_n)$. Since all of the $t_i$'s are ground-terms\n                    and $c$ is a constant, there is no free variable\n                    in this formula and the claim holds. In case (ii),\n                    we only consider the situation where $\\phi$ is of\n                    the form $t=x$ since $x=t$ is completely\n                    analogous. We simply note that  since $t$ is a\n                    ground term and thus doesn't contain $x$, we have\n                    $(t=x)[x:=c]=t=c$. And since, again, $t$ is a\n                    ground term and $c$ a constant, $t=c$ contains no\n                    variables at all and is thus closed.\n\n                    We go through the induction steps one by one:\n\n                    \\begin{itemize}\n                    \\item Assume the induction hypothesis that if\n                      $\\phi$ has only $x$ free, then $(\\phi)[x:=c]$ is a\n                    sentence. We need to derive that then also if\n                    $\\neg\\phi$ contains only $x$ free, then \n                    $(\\neg\\phi)[x:=c]$ is a sentence. But suppose that\n                    $\\neg\\phi$ contains only $x$ free. We have by\n                    definition that $(\\neg\\phi)[x:=c]=\\neg\n                    (\\phi)[x:=c]$. And since if $\\neg \\phi$ contains\n                    only $x$ free, then also $\\phi$ can only contain\n                    $x$ free. Hence $(\\phi)[x:=c]$ is a sentence by\n                    the induction hypothesis and so $\\neg(\\phi)[x:=c]$\n                    is also sentence.\n\n\n                    \\item Assume the induction hypotheses that (a) if\n                      $\\phi$ has only $x$ free, then $(\\phi)[x:=c]$ is a\n                    sentence and that (b) if\n                      $\\psi$ has only $x$ free, then $(\\psi)[x:=c]$ is a\n                    sentence. Now consider $\\phi\\circ\\psi$ with only\n                    $x$ free for\n                    $\\circ=\\land,\\lor,\\to,\\leftrightarrow$. We know that\n                    $(\\phi\\circ\\psi)[x:=c]=(\\phi)[x:=c]\\circ\n                    (\\psi)[x:=c]$ by definition. Now if\n                    $\\phi\\circ\\psi$ has only $x$ free, each of $\\phi$\n                    and $\\psi$ can only have $x$ free. So, by the\n                    induction hypotheses (a) and (b), we have that\n                    $(\\phi)[x:=c]$ and $(\\psi)[x:=c]$ are both\n                    sentences. But if $(\\phi)[x:=c]$ and\n                    $(\\psi)[x:=c]$, then\n                    $(\\phi)[x:=c]\\circ(\\psi)[x:=c]$ is a sentence,\n                    too, as desired.\n\n                    \\item Assume the induction hypothesis that if\n                      $\\phi$ has only $x$ free, then $(\\phi)[x:=c]$ is a\n                    sentence. Consider $Qy\\phi$ with only $x$ free for\n                    $Q=\\forall,\\exists$. Note that if $Qy\\phi$\n                    contains $x$ free, then we need to have that\n                    $y\\neq x$. For in $Qx\\phi$, every occurrence of\n                    $x$ would be bound by $(r,Qx)$. But if $y\\neq x$,\n                    then we know that\n                    $(Qy\\phi)[x:=c]=Qy(\\phi)[x:=c]$. And since\n                    $(\\phi)[x:=c]$ is a sentence by the induction\n                    hypothesis, so is $Qy(\\phi)[x:=c]$. \n                    \\end{itemize}\n                    This completes our proof, we can now infer by the\n                    principle of induction over formulas that for all\n                    $\\phi$ with only $x$ free, $(\\phi)[x:=c]$ is a\n                    sentence.\n\n          \\item[11.7.2.8] We're essentially asked to show that for all\n            models $\\mathcal{M}$ and assignments $\\alpha$,\n            we have\n            $\\mathcal{M},\\alpha\\vDash \\forall xR(x,x)$ iff\n            $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n            D^\\mathcal{M}$. That is, we need to show two\n            things:\n\n            \\begin{enumerate}[(a)]\n              \\item If  $\\mathcal{M},\\alpha\\vDash \\forall\n                xR(x,x)$, then\n                $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n                D^\\mathcal{M}$\n              \\item If\n                $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n                D^\\mathcal{M}$, then  $\\mathcal{M},\\alpha\\vDash \\forall\n                xR(x,x)$.\n            \\end{enumerate}\n\n            To see that (a) holds, assume that\n            $\\mathcal{M},\\alpha\\vDash \\forall\n            xR(x,x)$. This means, by definition, that\n            $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            R(x,x)$. We derive that  $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n            D^\\mathcal{M}$ by contradiction. Suppose that\n            there exists a $d\\in D^\\mathcal{M}$ such that\n            $(d,d)\\notin R^\\mathcal{M}$. But then, we'd have\n            that $\\mathcal{M},\\alpha[x\\mapsto d]\\nvDash\n            R(x,x)$, contrary to our assumption that for\n            \\emph{all} $d\\in\n            D^\\mathcal{M}$, we have $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            R(x,x)$. Hence $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n            D^\\mathcal{M}$, as desired.\n\n            To see that (b) holds assume that $(d,d)\\in R^\\mathcal{M}$ for all $d\\in\n            D^\\mathcal{M}$. We need to derive that  $\\mathcal{M},\\alpha\\vDash \\forall\n            xR(x,x)$, i.e. for all $d\\in D^\\mathcal{M}$ we have\n            $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            R(x,x)$. But this follows immediately since  $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n            R(x,x)$ iff $(\\llbracket\n            x\\rrbracket^\\mathcal{M}_{\\alpha[x\\mapsto\n            d]},\\llbracket\n            x\\rrbracket^\\mathcal{M}_{\\alpha[x\\mapsto\n            d]})=(d,d)\\in R^\\mathcal{M}$.\n\n                        \\item[11.7.2.9]We're asked to show that in the\n                          given model $\\mathcal{M}$ we have\n                          \\[\\mathcal{M},\\alpha\\vDash \\exists xP(x)\\to\n                          P(a)\\lor P(b)\\lor P(c)\\] for each\n                          $\\alpha$. We know that, by definition, $\\mathcal{M},\\alpha\\vDash \\exists xP(x)\\to\n                          P(a)\\lor P(b)\\lor P(c)$ iff either (i)\n                          $\\mathcal{M},\\alpha\\nvDash \\exists xP(x)$ or (ii)\n                          $\\mathcal{M},\\alpha\\vDash\n                          P(a)\\lor P(b)\\lor P(c)$. Now clearly, we\n                          either have (a) $\\mathcal{M},\\alpha\\vDash\n                          \\exists xP(x)$ or (b)\n                          $\\mathcal{M},\\alpha\\nvDash \\exists xP(x)$ by\n                          bivalence. In case (b), we can immediately\n                          infer that $\\mathcal{M},\\alpha\\vDash \\exists xP(x)\\to\n                          P(a)\\lor P(b)\\lor P(c)$, so we focus on case\n                          (a). Suppose that $\\mathcal{M},\\alpha\\vDash\n                          \\exists xP(x)$. This means, by definition,\n                          that there exists a $d\\in D^\\mathcal{M}$\n                          such that $\\mathcal{M},\\alpha[x\\mapsto d]\\vDash\n                           P(x)$. Now, since\n                           $D^\\mathcal{M}=\\{1,2,3\\}$, we can only have\n                           $d=1,2,3$. If $d=1$, then, since\n                           $a^\\mathcal{M}=1$, we have that\n                           $\\mathcal{M},\\alpha[x\\mapsto \\llbracket\n                           a\\rrbracket^\\mathcal{M}_\\alpha]\\vDash \n                           P(x)$. By the denotation lemma, this gives\n                           us $\\mathcal{M},\\alpha\\vDash \n                           (P(x))[x:=a]$, i.e. $\\mathcal{M},\\alpha\\vDash \n                           P(a)$. But if $\\mathcal{M},\\alpha\\vDash \n                           P(a)$, then $\\mathcal{M},\\alpha\\vDash \n                           P(a)\\lor P(b)\\lor P(c)$ and so $\\mathcal{M},\\alpha\\vDash \\exists xP(x)\\to\n                          P(a)\\lor P(b)\\lor P(c)$ by (ii), as\n                          desired. If $d=2,3$, we can give the same,\n                          analogous argument using the denotation\n                          lemma. So, either way,  $\\mathcal{M},\\alpha\\vDash \\exists xP(x)\\to\n                          P(a)\\lor P(b)\\lor P(c)$, as desired.\n\n                          \\item[11.7.2.10] We're asked to prove that if\n                            $\\phi\\vdash\\psi$ and $\\psi\\vdash\\phi$,\n                            then $\\phi\\vdash\\psi$. There are many\n                            different ways we could do this, but I'll\n                            use soundness and completeness. First,\n                            I'll show my (Lemma) that  if\n                            $\\phi\\vDash\\psi$ and $\\psi\\vDash\\phi$,\n                            then $\\phi\\vDash\\psi$.\\footnote{We\n                              actually proved this in class, so you\n                              could, in principle just use this\n                              without proof.} For suppose that\n                            $\\phi\\vDash\\psi$ and\n                            $\\psi\\vDash\\phi$. By definition, this\n                            means that in every \n                            model $\\mathcal{M}$, (a) if $\\mathcal{M}\\vDash\n                            \\phi$, then $\\mathcal{M}\\vDash \\psi$ and (b)\n                            if $\\mathcal{M}\\vDash \\psi$, then\n                            $\\mathcal{M}\\vDash\\theta$. I want to\n                            derive $\\phi\\vDash\\psi$, i.e. for every\n                            model $\\mathcal{M}$,\n                            such that $\\mathcal{M}\\vDash\\phi$, we also\n                            have $\\mathcal{M}\\vDash\\psi$. But if\n                            $\\mathcal{M}\\vDash\\phi$, then by (a)\n                            $\\mathcal{M}\\vDash\\psi$, and then by (b)\n                            $\\mathcal{M}\\vDash\\psi$, as desired. Now,\n                            to prove our initial claim, suppose that\n                            $\\phi\\vdash\\psi$ and $\\psi\\vdash\\phi$. By\n                            soundness, I have that  $\\phi\\vDash\\psi$\n                            and $\\psi\\vDash\\phi$. So, by my (Lemma), we\n                            have $\\phi\\vDash\\theta$. But then, by\n                            completeness, we have $\\phi\\vdash\\theta$,\n                            as desired.\n\n                            \\item[11.7.2.11] We want to show that if\n                              $\\Gamma\\vDash c\\neq c$, then for all\n                              formulas $\\phi$, either $\\Gamma\\vDash\\phi$ or\n                              $\\Gamma\\vDash\\neg\\phi$ (the either\n                              \\dots or was meant\n                              inclusively, otherwise the claim doesn't\n                              hold). We actually show the stronger\n                              claim that if $\\Gamma\\vDash c\\neq c$,\n                              then $\\Gamma\\vdash\\phi$ for all $\\phi$,\n                              so certainly also for $\\phi$ and\n                              $\\neg\\phi$.\n\n                              Above, we proved that if $\\Gamma\\vDash\n                              c\\neq c$, then $\\Gamma$ is\n                              unsatisfiable. We're going to use this\n                              result. Since $\\Gamma$ is unsatisfiable,\n                              so is $\\Gamma\\cup\\{\\neg\\phi\\}$ for every\n                              $\\phi$ (we proved this in 6.2.5.(c) for\n                              propositional logic, but the proof\n                              clearly goes through for first-order\n                              logic, too). But we know by the ``I\n                              Can't Get No Satisfaction'' Theorem,\n                              that $\\Gamma\\cup\\{\\neg\\phi\\}$ iff\n                              $\\Gamma\\vDash\\phi$. So, we can conclude\n                              that if $\\Gamma\\vDash\n                              c\\neq c$, then $\\Gamma\\vDash\\phi$, as\n                              desired.\n\n                              \\item[11.7.2.12] In order to define the\n                                desired function, we first define the\n                                auxiliary function\n                                $c:\\mathcal{T}\\to\\mathbb{N}$ given by\n                                the following recursion:\n                                \\begin{itemize}\n                                \\item $c(x)=1$ and $c(c)=1$\n                                \\item $c(f(t_1, \\mathellipsis, t_n))=c(t_1)+\\mathellipsis+c(t_n)+1$\n                                \\end{itemize}\n                               We then define the desired function as\n                               follows:\n                               \\begin{itemize}\n                               \\item $c(R(t_1, \\mathellipsis,\n                                 t_n))=c(t_1)+\\mathellipsis+c(t_n)+1$\n\n                               \\item $c(s=t)=c(s)+c(t)+1$\n\n                               \\item $c(\\neg \\phi)=c(\\phi)+1$\n                               \\item\n                                 $c(\\phi\\circ\\psi)=c(\\phi)+c(\\psi)+1$\n                               \\item $c(\\forall x\\phi)=c(\\phi)+1$\n                               \\end{itemize}\n\n                               We now need to prove that the number of\n                               nodes in $T(\\phi)$, $\\#T(\\phi)$, is\n                               $c(\\phi)$ for all \n                               $\\phi$. We do this by induction. Well,\n                               first we prove the lemma that\n                               for all $\\#T(t)=c(t)$.\n\n                               For the induction base, note that the\n                               parsing tree for both $x\\in\\mathcal{V}$\n                               and $c\\in\\mathcal{C}$ contains\n                               precisely one node. So the claim\n                               holds that $\\#T(x)=\\#T(c)=c(x)=c(c)=1$.\n\n                               So, assume the induction hypothesis\n                               that  $\\#T(t_i)=c(t_i)$ for $1\\leq\n                               i\\leq n$ and consider the number of\n                               nodes in $T(f(t_1, \\mathellipsis,\n                               t_n))$. Since $T(f(t_1, \\mathellipsis,\n                               t_n))=$\n\n                               \\begin{center}\n                               \\Tree[.{$f(t_1, \\mathellipsis,\n                                 t_n)$} [.{$T(t_1)$} ] [\n                               .{\\dots} ]\n                             [.{$T(t_n)$} ] ]\n                           \\end{center}\n                           We have that $\\#T(f(t_1, \\mathellipsis,\n                               t_n))=\\#T(t_1)+\\mathellipsis+\\#T(t_n)+1$,\n                               which, by the induction hypothesis is\n                               identical to\n                               $c(t_1)+\\mathellipsis+c(t_n)+1=c(f(t_1,\n                               \\mathellipsis, t_n)$, as\n                               desired.\n\n                               Now, for our main claim, we prove by\n                               induction that $\\#T(\\phi)=c(\\phi)$.\n\n                               For the first base case, we note that\n                               $T(R(t_1, \\mathellipsis, t_n)=$\n                               \\begin{center}\n                               \\Tree[.{$R(t_1, \\mathellipsis,\n                                 t_n)$} [.{$T(t_1)$} ] [\n                               .{\\dots} ]\n                             [.{$T(t_n)$} ] ]\n                           \\end{center}\n                           And so $\\#T(R(t_1, \\mathellipsis,\n                           t_n)=c(t_1)+\\mathellipsis+c(t_n)+1=c(R(t_1,\n                           \\mathellipsis, t_n)$, as\n                           desired. For the second base case, we note\n                           that $T(s=t)=$\n                           \\begin{center}\n                               \\Tree[.{$s=t$} [.{$T(s)$} ]\n                             [.{$T(t)$} ] ]\n                           \\end{center}\n                           And so\n                           $\\#T(s=t)=\\#T(s)+\\#T(t)+1=c(s)+c(t)+1=c(s=t)$, as\n                           desired.\n\n                           For the induction steps,\n                           \\begin{itemize}\n                           \\item Assume that  $\\#T(\\phi)=c(\\phi)$ and\n                             consider $T(\\neg \\phi)=$\n                             \\begin{center}\n                               \\Tree[.{$\\neg \\phi$} [.{$T(\\phi)$} ] ]\n                             \\end{center}\n                             and so\n                             $\\#T(\\neg\\phi)=\\#T(\\phi)+1=c(\\phi)+1$ by\n                             the induction hypothesis, as desired. \n\n                             \\item Assume that  $\\#T(\\phi)=c(\\phi)$\n                               and that  $\\#T(\\psi)=c(\\psi)$ and\n                               consider $T(\\phi\\circ\\psi)=$\n                                \\begin{center}\n                               \\Tree[.{$\\phi\\circ\\psi$} [.{$T(\\phi)$} ]  [.{$T(\\psi)$} ]]\n                             \\end{center}\n                             So,\n                             $\\#T(\\phi\\circ\\psi)=\\#T(\\phi)+\\#T(\\psi)+1=c(\\phi)+c(\\psi)+1$\n                             by the induction hypothesis, as desired.\n                             \n                              \\item Assume that  $\\#T(\\phi)=c(\\phi)$ and\n                             consider $T(Qx \\phi)=$\n                             \\begin{center}\n                               \\Tree[.{$Qx \\phi$} [.{$T(\\phi)$} ] ]\n                             \\end{center}\n                             and so\n                             $\\#T(Qx\\phi)=\\#T(\\phi)+1=c(\\phi)+1$ by\n                             the induction hypothesis, as desired.\n                           \\end{itemize}\n\n                           So, by induction, we indeed have\n                           $\\#T(\\phi)=c(\\phi)$, as desired.\n\n                         \\item[11.7.2.13]\n\n                           We show that Betrand is correct using\n                           logic. First, we formalize the stranger's\n                           claim using the following translation key:\n\n                           \\begin{center}\n                             \\begin{tabular}[!h]{c c c}\n                               $K^1$ & \\dots is a barber\\\\\n                               $S^2$ & \\dots shaves \\underline{\\phantom{\\dots}}\n                             \\end{tabular}\n                           \\end{center}\n\n                           The stranger's claim becomes:\n\n                           \\[ \\exists x(K(x)\\land \\forall y(\\neg\n                             S(y,y)\\leftrightarrow S(x,y)))\\]\n\n                           We now prove that Bertrand is correct, since\n                           the stranger's claim is a logical\n                           falsehood. We show this using\n                           tableaux. More specifically, we show that\n                           $\\vdash \\neg \\exists x(K(x)\\land \\forall y(\\neg\n                             S(y,y)\\leftrightarrow S(x,y)))$. By\n                             definition, what we need to show is that\n                             the tableau for $\\{\\neg\\neg\\exists x(K(x)\\land \\forall y(\\neg\n                             S(y,y)\\leftrightarrow S(x,y)))\\}$\n                             closes. This can be seen as follows:\n\n            \\begin{center}\n              \\begin{prooftree}\n                {%\n                  line numbering=false,\n                  for tree={s sep'=10mm},\n                  single branches=true,\n                  close with=\\xmark\n                }\n                [{\\neg \\neg \\exists x(K(x)\\land \\forall y(\\neg S(y,y)\\leftrightarrow S(x,y)))}\n                    [{\\exists x(K(x)\\land \\forall y(\\neg S(y,y)\\leftrightarrow S(x,y)))}\n                        [{(K(p)\\land \\forall y(\\neg S(y,y)\\leftrightarrow S(p,y)))}\n                            [{K(p)}\n                                [{\\forall y(\\neg S(y,y)\\leftrightarrow S(p,y))}\n                                    [{\\neg S(p,p)\\leftrightarrow S(p,p)}\n                                        [{\\neg S(p,p)}\n                                            [{S(p,p)}, close ]\n                                        ]\n                                    [{S(p,p)}\n                                        [{\\neg S(p,p)}, close ]\n                                        ]\n                                    ]\n                                ]\n                            ]\n                        ]\n                    ]\n                ]\n              \\end{prooftree}\n            \\end{center}\n\n            Now, since\n            $\\vdash \\neg \\exists x(K(x)\\land \\forall y(\\neg S(y,y)\\leftrightarrow S(x,y)))$,\n            by soundness, we have\n            $\\vDash \\neg \\exists x(K(x)\\land \\forall y(\\neg S(y,y)\\leftrightarrow S(x,y)))$.\n            That is the stranger's claim cannot be true in any model, so also not in the actual world.\n            Bertrand is right.\n\n                             \n                \\end{itemize}\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../../logic.tex\"\n%%% End:\n", "meta": {"hexsha": "b452c13757e2ab90a89db44a93f55c65566dad51", "size": 49158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/notes/tex/appendix/ans-fo-completeness.tex", "max_stars_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_stars_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-09-12T17:29:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-05T08:03:21.000Z", "max_issues_repo_path": "lib/notes/tex/appendix/ans-fo-completeness.tex", "max_issues_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_issues_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 69, "max_issues_repo_issues_event_min_datetime": "2020-09-04T16:24:11.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-18T13:54:07.000Z", "max_forks_repo_path": "lib/notes/tex/appendix/ans-fo-completeness.tex", "max_forks_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_forks_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-09-04T08:49:21.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-30T11:24:44.000Z", "avg_line_length": 47.2219020173, "max_line_length": 127, "alphanum_fraction": 0.461166036, "num_tokens": 12665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.43373640841056976}}
{"text": "\\subsection{Computation: $f(I_t)$}\n\n\\begin{frame}{Computation: $f(I_t)$}\n    \\begin{equation*}\n        B: \\alert{f(I_t)} \\rightarrow O_t\n    \\end{equation*}\n    \\begin{columns}[t]\n        \\begin{column}{0.5\\textwidth}\n            Extractor function\n            \\begin{itemize}\n                \\item \\textit{Unbiasing algorithms}\n                \\item Extracts uniformly distributed sequences\n                \\item SHA family\n                \\item Requires known seed\n            \\end{itemize}\n        \\end{column}\n        \\begin{column}{0.5\\textwidth}\n            Delay function\n            \\begin{itemize}\n                \\item Lower bound run time\n                \\item Inherently sequential\n                \\item Adjustable to advances in computation\n                \\item Asymmetrically hard --- slow computation, fast verification\n            \\end{itemize}\n        \\end{column}\n    \\end{columns}\n\\end{frame}\n\\note{\n    Delay functions are often extractors\n}\n", "meta": {"hexsha": "f9614525779411b1b7558288e369950c1ee1de15", "size": 963, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/discussion/computation.tex", "max_stars_repo_name": "randomchain/presentation", "max_stars_repo_head_hexsha": "c9566274e3e76bf73da78d9a1763d23a657e3ca3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/discussion/computation.tex", "max_issues_repo_name": "randomchain/presentation", "max_issues_repo_head_hexsha": "c9566274e3e76bf73da78d9a1763d23a657e3ca3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/discussion/computation.tex", "max_forks_repo_name": "randomchain/presentation", "max_forks_repo_head_hexsha": "c9566274e3e76bf73da78d9a1763d23a657e3ca3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.064516129, "max_line_length": 81, "alphanum_fraction": 0.559709242, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4337328961360707}}
{"text": "% $Id: PropagatorOverview.tex,v 1.1 2008/10/09 16:16:11 dconway Exp $\n\\chapter{\\label{chapter:PropagatorOverview}Propagation in GMAT}\n\\chapauthor{Darrel J. Conway}{Thinking Systems, Inc.}\n\n\\section{Propagator Overview}\n\nGMAT's model contains a subsystem that is used to move a user defined mission through time,\nfollowing the sequence of events defined in the Mission Control Sequence.  That subsystem is\nreferred to as the propagation subsystem.  In its most generic form, GMAT's propagation subsystem\ncan be thought of as taking a mission state $\\textbf{X}_i$ at some time $t_i$ and moving that state\nby some amount $\\delta t$ to some new time $t_f$, resulting in a new state $\\textbf{X}_f$.  The\ncomponents that are used to perform this change of state are the elements of the propagation\nsubsystem.  In other words, GMAT's propagation subsystem performs the actions needed to calculate\nthe new state by performing the operation\n\n\\begin{equation}\\label{eq:abstractProp}\n\\textbf{X}_f(t_f) = F(\\textbf{X}_i(t_i), \\delta t)\n\\end{equation}\n\n\\noindent This chapter provides an overview of the definition of the quantities in this equation:\nthe definition of the mission state vector and all of its components, the evolution operator $F$\nthat moves the state vector, and an overview of the construction and decomposition of these\nquantities in GMAT.\n\nGMAT's propagation subsystem is used to perform all analytic propagation and numerical integration\nneeded by the system.  That includes modeling the time lines for spacecraft and formations, mass\ndepletion modeling during finite duration maneuvers, evolution of the state transition matrix,\nattitude propagation, evolution of physical properties and their variances as needed for orbit and\nattitude determination problems, and evolution of costate variables needed for optimal control\nproblems.  The diversity of propagation issues encountered in the coverage provided by the\npropagation subsystem makes it a potentially quite complicated collection of components.  For that\nreason, the subsystem is broken into a collection of different elements each tailored to specific\naspects of the propagation problem regime.  The propagation problem requires a consistent, complete\ndescription of the evolution operators and the propagation vector, which are discussed briefly below\nand in detail in Chapters~\\ref{chapter:Propagators} and~\\ref{chapter:PropagatorStates},\nrespectively.  This chapter concludes with a description of the scripting elements used to drive\npropagation in GMAT, using the Propagate command as an example of this scripting.\n\n\\section{Propagator Overview}\n\nThe function $F$ in equation~\\ref{eq:abstractProp} defines the process that takes a vector of\nnumbers defining system properties at one time and finds the values of those same properties at a\ndifferent time.  This process of moving the properties through time is performed using one\nor more evolution operators.  The objects in GMAT that perform this evolution are the propagators.\nGMAT's propagators are designed to support evolution either forwards or backwards in time.  The\npropagators can be set to run in a synchronized manner or independently of one another.  The\nselection of the category and type of propagator that is used is selected by the user based on the\ntypes of parameters that need to be propagated.\n\nGMAT Supports three different categories of propagators, defined by the type of data available for\nthe propagation.  The categories are\n\n\\begin{description}\n\\item[Analytic] GMAT's analytic propagators take a known, closed form solution to the evolution\nproblem and apply that solution to the propagation vector specified at some initial time to find its\nvalues at some other time.  GMAT's analytic propagators use embedded evolution equations to\ncalculate the values of parameters at the desired times.\n\\item[Numerical] The numerical propagators find a solution of the differential equations of motion\nfor the parameters using a precision numerical integrator and derivative models.  Propagators in\nthis category consist of a pair of objects: a numerical integrator derived from the Integrator class\nand a derivative model derived from the PhysicalModel class.\n\\item[Precalculated]  Precalculated parameter values are retrieved -- and, if needed, interpolated\n-- from files containing the time history of the parameter values.\n \\end{description}\n\nEach category of propagator supplies implementations of core methods designed to standardize\nthe propagation interface.  The core propagation interfaces are defined in the Propagator base\nclass.  Every GMAT propagator uses these interfaces to perform the following actions:\n\n\\begin{itemize}\n\\item Map the propagation vector to known evolution operators\n\\item Initialize all data structures and object references needed to propagate\n\\item Load the initialized data structure immediately before propagating\n\\item Propagate the propagation vector\n\\item Reset the propagator to use its initial settings\n\\end{itemize}\n\n\\noindent The Propagator class defines these interfaces to perform the actions listed above:\n\n\\begin{description}\n\\item[GetPropagatorOrder]  GMAT includes both first and second order numerical integrators.  This\ninterface is used to determine which is needed for a particular integrator.  The non-numerical\nintegrators all report order 0.\n\\item[SetPhysicalModel]  The SetPhysicalModel method sets the derivative model used for numerical\nintegration, and -- for all propagators -- performs pre-initialization tasks required before\ninitialization can proceed.  This method ensures that all of the elements needed for evolution have\nbeen set for the propagator.\n\\item[Initialize]  All of the reference object pointers and other interconnections necessary for\npropagation are set in the Initialize method.  Propagators that do not allow for dynamic resizing of\nthe propagation vector also use this method to initialize the propagation vector mapping needed for\nthe evolution.  Those that may require dynamic resizing perform a preliminary mapping during\ninitialization.\n\\item[Update]  The Update method is used to reset the propagator when the underlying physical model\nchanges.  This method is used to refresh the propagation vector mapping if the propagation vector\nhas changed -- for instance, when a transient derivative is applied or removed to model mass flow\nduring a finite maneuver.  It also resets some of the propagator's properties if needed, like the\ninitial step size for variable step propagators.\n\\item[ResetInitialData]  The ResetInitialData method sets a flag telling the propagator that at the\nnext call to propagate the propagation vector, the propagator's initial data needs to be updated\nprior to propagation.\n\\item[Step]  State evolution is driven through calls to the Step method.  Different categories and\nsubcategories of propagators implement different versions of this method based on the needs and\ncapabilities of the propagators.\n\\end{description}\n\n\\noindent These methods define the minimum level of interface required for every GMAT propagator.\nThe Propagator subclasses extend this set based on the needs of the category of the propagator\ndefined in the subclass.\n\nThe design details for the propagators are provided in Chapter~\\ref{chapter:Propagators}.\n\n\\section{Propagation Vector Overview}\n\nThe propagators evolve a vector of data from one epoch to another.  The data that evolves is\ncontained in a column vector sized to match the evolving data.  This vector is assembled and\npopulated prior to propagation based on specifications scripted by the user.  The propagation\nvector provides methods that support the following actions:\n\n\\begin{itemize}\n\\item Supply epoch information\n\\item Supply propagation vector information, including all of the following:\n\\begin{itemize}\n\\item Size of the vector\n\\item Element by element types for mapping the vector onto the propagator\n\\end{itemize}\n\\item Supply the propagation vector\n\\end{itemize}\n\n\\noindent GMAT uses a class, PropVector, to model the propagation vector.  The PropVector objects\nsupply the information used to assemble the derivative vector needed for numerical integration, the\nepoch and state data needed for analytic propagation, or the epoch and time step information used\nfor precalculated propagation.\n\nThe PropVector class defines these interfaces to perform the actions listed above:\n\n\\begin{description}\n\\item[GetEpoch and SetEpoch]  A PropVector contains data calculated at a single epoch.  These\nGetEpoch and SetEpoch methods provide access to the epoch data in the PropVector.\n\\item[GetDimension]  Retrieves the current size of the PropVector -- that is, the number of\nelements that evolve over time.  The dimension is used to initialize the propagator, and, in\nconjuction with the vector map, to ensure that the correct operator is used to evolve each element\nof the vector.\n\\item[GetVectorMap]  Retrieves the mapping of the PropVector, element by element, so that the\nevolution components can be set correctly.\n\\item[GetVector]  Retireves a pointer to the Real array of data for the vector.  The retrieved\nvector has the size given by the dimension of the PropVector, mapped as specified in the vector\nmap.  Components that use the PropVector for propagation can both read and write to this retrieved\nvector.  This violation of encapsulation is intentional, in order to make the propagation process\nas fast as possible in GMAT.\n\\end{description}\n\n\\noindent These interfaces define the minimal interfaces necessary for PropVector objects.  They\nare defined as overridable interfaces so that classes can be derived form PropVector in the future\nas needed.\n\nThe PropVector class is managed through a mapping class, the MissionState.  The MissionState class\nis a container class -- it contains references to the objects providing state data that evolves\nusing GMAT's evolution operators, as defined in its Propagator classes.  The MissionState class\nprovides methods accessed by the propagators to construct, retrieve, and update the PropVector.  It\nmanages the data flow between these objects and the propagation vectors manipulated by the\nPropagators.  The MissionState builds the PropVectors used by the propagators, setting up the data\nvector and associated component mappings used by the propagator to assemble the elements needed for\npropagation.\n\nThe MissionState class defines a set of interfaces used to manage the data soureces used to assemble\nthe PropVector.  The interfaces supplied by the MissionState for these tasks are:\n\n\\begin{description}\n\\item[AddObject]  Adds an object that supplied data to one or more PropVectors.\n\\item[Initialize]  Constructs the PropVector or PropVectors used by a propagator.\n\\item[PrepareToPropagate] Completes PropVector initialization needed prior to propagation.\n\\item[GetPropVector]  Retrieves an assembled PropVector designed for propagation.\n\\end{description}\n\n\\noindent Each one of GMAT's propagators uses a MissionState object to manage the data that is\npropagated.\n\nThe PropVector and MissionState classes are described in detail in\nChapter~\\ref{chapter:PropagatorStates}.\n\n\\section{Scripting Propagation}\n\nAs is described above, GMAT provides three approaches to propagation.  The system can model the\nevolution of the state data by numerically integrating the equations of motion, providing a high\nprecision model of the evolution, by reading the data from a pre-calculated file of data points\n(e.g. a SPICE file), or by using an analytical propagator that provides a fast, lower fidelity\nvector of propagated data.  The propagation subsystem can perform these tasks for all of the\nparameters represented in the propagation vector: for the spacecraft orbit and attitude data, mass\nproperties, for the state transition matrix and covariance matrices, and for any other parameters\nplaced in the propagation vector, as long as the underlying propagation model supporting the\nparameter exists.  For the numerical integrators, that means that the  set of ordinary differential\nequations describing the evolution have been coded into the system.  Similarly, analytic\npropagators require encoding of the analytic equations of motion.  The precalculated data\npropagators require an ephemeris or similar time based file of the evolution of the paramteres that\nthey propagate.  GMAT is designed to support mixed mode propagation as well; elements propagated in\na Mission Control Sequence command need not all be propagated using the same approach.  Some can be\npropagated analytically or using a file while others are numerically integrated.  The design\nimplementing this mode is described in Chapter~\\ref{chapter:Propagators} and in the descriptions of\nthe commands that support propagation.\n\nCommands that drive propagation follow the process shown in\nFigure~\\ref{figure:CommandPropagationOverview}.  The command is initialized in the Sandbox along\nwith the rest of the Mission Control Sequence.  During this initialization, specific pieces\nrequired to initialize each propagator driven by that command are performed.  There are portions of\nthe propagation process that cannot be initialized at this point in the mission run because they\ndepend on data that may be changed when commands that precede the one invoking propagation fire.\nThis final piece of initialization is performed in a method named PrepareToPropagate(), which is\ncalled when the command's Execute() method is called, immediately before the actual propagation.\nFinally, the propagation is performed in the body of the Execute() method associated with the\ncommand.\n\n\\begin{figure}[htb]\n\\begin{center}\n\\includegraphics[scale=0.5]{Images/PropagationintheMCS.eps}\n\\caption[Command and Propagation Processes]{\\label{figure:CommandPropagationOverview}Command and\nPropagation Processes}\n\\end{center}\n\\end{figure}\n\n\\subsection{Example: The Propagate Command}\n\nPropagation is scripted in GMAT through the creation of propagator objects and the incorporation of\nthese objects into the Mission Control Sequence through propagator enabled commands.  The\nprototypical propagator enabled command is the Propagate command (described more fully in\nSection~\\ref{section:Propagate}), scripted in its simplest form like this:\n\n\\begin{quote}\n\\begin{verbatim}\nPropagate prop(sat)\n\\end{verbatim}\n\\end{quote}\n\n\\noindent The command shown here consists of three elements: the Propagate keyword, the name of the\npropagator that is used (``prop'' in this case), and the object that is propagated, ``sat'' in\nthis example.  In order for this command to run, the objects used in teh propagation must exist, so\nthere must be matching creation commands.  Assuming that the command exists in the main script\nrather than a function, that means these lines must occur before the Propagate command line:\n\n\\begin{quote}\n\\begin{verbatim}\nCreate Spacecraft sat;\nCreate Propagator prop;\n\\end{verbatim}\n\\end{quote}\n\n\\noindent The propagated object can, of course, be any object that supplies a propagation vector for\npropagation.\n\nThe type of propagator is specified by setting the ``Type'' property on the propagator object, like\nthis:\n\\begin{quote}\n\\begin{verbatim}\nprop.Type = PrinceDormand78;  % Use a Prince-Dormand RK integrator\n\\end{verbatim}\n\\end{quote}\n\n\\noindent The Type setting for the propagator must be made before setting any other propagator\nproperties because the properties for the propagator depend on the type of Propagator object that is\nbeing used.  Every GMAT propagator has default values for each of its properties.  Users override\nthese settings to tailor the behavior of the propagator.\n\nThe following sections describe the scripting for each category of Propagator.\n\n\\subsubsection{Scripting Numerical Integrators}\n\nThe numerical integrators require an additional object defining the forces and other differential\nequations that are used to model the propagation.  These pieces are gathered in a container class,\nthe ODEModel class derived from PhysicalModel.  The ODEModel class plays several roles in the\npropagation subsystem:\n\n\\begin{itemize}\n\\item It works with a MissionState object to create the propagation vector\n\\item It coordinates the data mapping between the objects that are propagated and the propagation\nvector\n\\item It handles the superposition tasks when the differential equations defining propagation\nconsist of multiple components\n\\end{itemize}\n\n\\noindent The ODEModel class is described more fully in Section~\\ref{section:TheODEModel}.\nScripting for ODEModel objects depends on context.  For orbit propagation, the ODEModel is scripted\nas a ForceModel component, using this syntax:\n\n\\begin{quote}\n\\begin{verbatim}\nCreate ForceModel forces;\nforces.CentralBody = Earth;\nforces.PrimaryBodies = {Earth};\nforces.Drag = MSISE90;\nforces.SRP = On;\nforces.ErrorControl = RSSStep;\nforces.GravityField.Earth.Degree = 4;\nforces.GravityField.Earth.Order = 4;\nforces.GravityField.Earth.PotentialFile = 'JGM2.cof';\nforces.PointMasses = {Sun, Luna, Mercury, Venus, Mars};\n\nCreate Propagator prop;\nprop.Type = PrinceDormand78;\nprop.FM = forces;\n\\end{verbatim}\n\\end{quote}\n\n\\noindent The forces that are included in the differential equations of motion are defined by\nspecifying the desired elements and, when needed, properties of those elements.  The resulting\nODEModel is assigned to the integrator by assigning its name to the FM property of the Propagator.\n\n\\subsubsection{Scripting Analytic Propagators}\n\nThis section is TBD, based on requirements and design for analytic propagators when they are added\nto GMAT.\n\n\\subsubsection{Scripting Precalculated Propagators}\n\n\\textit{Detailed information for this section is TBD, based on requirements and design for the SPICE\nfile component and discussions of other ephemeris based propagators planned for GMAT.  However, the\nscripting discussion is underway, and included here, subject to extensive revision.}\n\nPropagation based on precalculated data is used in GMAT to propagate data for spacecraft, celestial\nbodies not modeled elsewhere, and other elements that are described using file-based time-indexed\ndata.\n\nScripting for the precalculated propagators is similar to that for the numerical integrators.  The\nprecalculated propagators identify the propagator type as one of the supported file based propagator\ntypes, and identify a file -- the file containing the ephemeris data -- rather than a force model.\nAn example of the setup for a SPICE file based precalculated propagator for the Clementine mission\nis given here:\n\n\\begin{quote}\n\\begin{verbatim}\nCreate Spacecraft Clementine\nClementine.EphemID = -40      % Clementine's NAIF ID\n\nCreate Asteroid Geographos    % Asteroid support is a future enhancement;\n                              % use a Spacecraft with the current code base\nGeographos.EphemID = 2006513  % No clue about the real NAIF ID for Geographos...\n\nCreate Propagator prop\nprop.type = SPICE\nprop.StepSize = 300    % seconds\nprop.Ephemeris = DSPSE.SPK        % Ephem containing Clementine and Geographos\nprop.Ephemeris = SolarBodies.SPK  % Second ephem used to add vectors together\n\\end{verbatim}\n\\end{quote}\n\n\\noindent Propagation with a SPICE file propagator is handled identically to that performed using\nother propagators.  For the asteroid encounter phase of the mission above, a user could script the\npropagaton like this:\n\n\\begin{quote}\n\\begin{verbatim}\nCreate Variable i\nFor i = 0 : 2000\n   Propagate prop(Clementine, Geographos)\nEndFor\n\\end{verbatim}\n\\end{quote}\n\n\\noindent One constraint imposed in GMAT is that for a single ephemeris based propagator, each\nobject that is propagated must be contained in the same ephemeris file.  That means that in the\nexample above, the ephemeris for both the Clementine spacecraft and the asteroid Geographos must\nexist in the SPICE file DSPSE.SPK.  For this case, the same result could be achieved with separate\nephemerides for the spacecraft and asteroid with this scripting:\n\n\\begin{quote}\n\\begin{verbatim}\nCreate Spacecraft Clementine\nClementine.EphemID = -40   % Clementine's NAIF ID\n\nCreate Asteroid Geographos    % Asteroid support is a future enhancement;\n                              % use a Spacecraft with the current code base\nGeographos.EphemID = 2006513  % No clue about the real NAIF ID for Geographos...\n\nCreate Propagator prop\nprop.type = SPICE\nprop.StepSize = 300    % seconds\nprop.Ephemeris = Clementine.SPK   % Ephem containing Clementine\nprop.Ephemeris = SolarBodies.SPK  % Second ephem used to add vectors together\n\nCreate Propagator geogProp\ngeogProp.type = SPICE\ngeogProp.StepSize = 300    % seconds\ngeogProp.Ephemeris = Asteroids.SPK    % Ephem containing Geographos\ngeogProp.Ephemeris = SolarBodies.SPK  % Second ephem used to add vectors together\n\nCreate Variable i\nFor i = 0 : 2000\n   Propagate Synchronized prop(Clementine) geogProp(Geographos)\nEndFor\n\\end{verbatim}\n\\end{quote}\n\n\\noindent Finally, you may have noted that a second ephemeris source is identified for the SPICE\npropagator.  This option is scripted in these examples to allow conversion of the epheris data for\npropagated objects to other bodies in the model.  For example, the ephemeris for Geographos is\nlikely to be calculated with respect to the Sun.  GMAT may need Earth-centered states, so the SPICE\npropagator needs to load the SPICE kernel that describes the Earth's location with respect to the\nSun in order to add the position vectors together to build the state vector.\n\nThe following chapters provide details of the propagation subsystem components.\nChapter~\\ref{chapter:PropagatorStates} describes the PropVector and MissionState classes, and\nincludes descriptions of the data mapping for vector elements and diagrams describing hte layout of\nthe PropVector data for single and multiple objects.  Chapter~\\ref{chapter:Propagators} describes\nthe design of the propagator classes.  The commands that control the propagation subsystem are\ndescribed in Chapters~\\ref{chapter:Commands} and~\\ref{chapter:SpecificCommands}.\n\n\n% \\subsection{The Equations of Motion}\n%\n% \\subsection{Division of Labor: Integrators and Forces}\n%\n% \\section{Integrators}\n%\n% \\section{\\label{section:ForceModelOverview}The GMAT Force Model}\n%\n% \\subsection{The PhysicalModel Class}\n%\n% \\subsection{The ForceModel Class}\n%\n% \\subsubsection{Adding and Removing Forces}\n%\n% \\subsection{Applying Forces to Spacecraft}\n%\n% \\section{The State Vector}\n%\n% \\section{The PropSetup Container}\n\n", "meta": {"hexsha": "66b5daa1ddf7fce49ba5e9a4b47b091128f6dffa", "size": 22392, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/SystemDocs/ArchitecturalSpecification/PropagatorOverview.tex", "max_stars_repo_name": "Randl/GMAT", "max_stars_repo_head_hexsha": "d6a5b1fed68c33b0c4b1cfbd1e25a71cdfb8f8f5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-01T13:14:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-09T07:05:07.000Z", "max_issues_repo_path": "doc/SystemDocs/ArchitecturalSpecification/PropagatorOverview.tex", "max_issues_repo_name": "ddj116/gmat", "max_issues_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_issues_repo_licenses": ["NASA-1.3"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-03-15T08:58:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-20T20:11:26.000Z", "max_forks_repo_path": "doc/SystemDocs/ArchitecturalSpecification/PropagatorOverview.tex", "max_forks_repo_name": "ddj116/gmat", "max_forks_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_forks_repo_licenses": ["NASA-1.3"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-13T10:26:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-09T07:06:55.000Z", "avg_line_length": 52.5633802817, "max_line_length": 100, "alphanum_fraction": 0.8100214362, "num_tokens": 4953, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703224, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.43368599046450046}}
{"text": "\\subsection{Applying Models to New York City}\r\n\r\nSo what about applying the same models to climate data of a different city? We consider to use the weather data from New York City in 2017 as test data with the models trained by Seattle data. The same data preprocessing approach is followed as what we did on Seattle data. After that, we only apply SVM and random forest here as they have better performance than $k$-NN. The confusion matrices are shown respectively in Table \\ref{ny1} and Table \\ref{ny2}.\r\n\r\nFor random forest, the Type \\uppercase\\expandafter{\\romannumeral1} error is significantly higher. Although the Type \\uppercase\\expandafter{\\romannumeral2} error is lower, it is actually due to the model classified to many days into rain days mistakenly. The model predicted 289 days that rain in 2017 and the average raining day in New York based on historical record is 122. Overall, this model trained with Seattle data is not suitable to predict precipitation in New York. Again, we apply SVM with whole Seattle data as training set and test on New York. As shown in Table \\ref{ny2}, the Type \\uppercase\\expandafter{\\romannumeral1} error is significantly higher as well as the Type \\uppercase\\expandafter{\\romannumeral2} error. Overall those two model performed badly in the New York data.\r\n\r\n\\begin{table}[h]\r\n\\setlength{\\belowcaptionskip}{5pt}\r\n\\caption{Confusion Matrix for New York, Random Forest}\r\n\\label{ny1}\r\n\\centering\r\n\\renewcommand\\arraystretch{1.5}\r\n\\begin{tabular}{rrrrr}\r\n\\hline\r\n\\hline\r\n & & \\multicolumn{2}{c}{True Condition} & \\\\\r\n\\hline\r\n & & Non-Precipitation & Precipitation & \\\\\r\n\\cline{1-4}\r\n\\multirow{2}{*}{Prediction} & {Non-Precipitation} & 62 & 13 & \\\\\r\n\\cline{2-4}\r\n&Precipitation&176&113&\\\\\r\n\\hline\r\n&Error Rate & 0.7394 & 0.1031 & 0.5192\\\\\r\n\\cline{2-5}\r\n& & Type \\uppercase\\expandafter{\\romannumeral1} & Type \\uppercase\\expandafter{\\romannumeral2} & Overall\\\\\r\n\\hline\r\n\\end{tabular}\r\n\\end{table}\r\n\r\n\\begin{table}[h]\r\n\\setlength{\\belowcaptionskip}{5pt}\r\n\\caption{Confusion Matrix for New York, SVM}\r\n\\label{ny2}\r\n\\centering\r\n\\renewcommand\\arraystretch{1.5}\r\n\\begin{tabular}{rrrrr}\r\n\\hline\r\n\\hline\r\n & & \\multicolumn{2}{c}{True Condition} & \\\\\r\n\\hline\r\n & & Non-Precipitation & Precipitation & \\\\\r\n\\cline{1-4}\r\n\\multirow{2}{*}{Prediction} & {Non-Precipitation} & 96 & 45 & \\\\\r\n\\cline{2-4}\r\n&Precipitation&142&81&\\\\\r\n\\hline\r\n&Error Rate & 0.596 & 0.357 & 0.5137\\\\\r\n\\cline{2-5}\r\n& & Type \\uppercase\\expandafter{\\romannumeral1} & Type \\uppercase\\expandafter{\\romannumeral2} & Overall\\\\\r\n\\hline\r\n\\end{tabular}\r\n\\end{table}\r\n\r\nThere are several possible explanations for this. First, New York located on the east coast may have totally different meteorological environment compares to Seattle. So the variables and the threshold of those variables that matter in prediction may change. Second, New York has a rather imbalanced situation which has more days without precipitation (in fact, 126 days with precipitation, and 238 days without).\r\n", "meta": {"hexsha": "71ed651c83e1c8dd666a293983743ef656b4beb4", "size": 2976, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/ny.tex", "max_stars_repo_name": "shengchenHAO/Weather-Forecast-", "max_stars_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/ny.tex", "max_issues_repo_name": "shengchenHAO/Weather-Forecast-", "max_issues_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/ny.tex", "max_forks_repo_name": "shengchenHAO/Weather-Forecast-", "max_forks_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.1428571429, "max_line_length": 793, "alphanum_fraction": 0.7459677419, "num_tokens": 857, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.43367989749595826}}
{"text": "\\section{Substitute Vectors}\n\\label{sec:lm}\n\nIn this study, we predict the part of speech of a word in a given\ncontext based on its substitute vector.  The dimensions of the\nsubstitute vector represent words in the vocabulary, and the entries\nin the substitute vector represent the probability of those words\nbeing used in the given context.  Note that the substitute vector is a\nfunction of the context only and is indifferent to the target word.\nThis section details the choice of the data set, the vocabulary and\nthe estimation of substitute vector probabilities.\n\n% what is the test data\nThe Wall Street Journal Section of the Penn Treebank \\cite{treebank3}\nwas used as the test corpus (1,173,766 tokens, 49,206 types).\n% what is the tag set\nThe treebank uses 45 part-of-speech tags which is the set we used as\nthe gold standard for comparison in our experiments.\n% what is the LM training data\n%Train => 5181717 126019973 690121813\nTo compute substitute probabilities we trained a language model using\napproximately 126 million tokens of Wall Street Journal data\n(1987-1994) extracted from CSR-III Text \\cite{csr3text} (we excluded\nthe test corpus).\n% how is the language model trained\nWe used SRILM \\cite{Stolcke2002} to build a 4-gram language model with\nKneser-Ney discounting.\n% what is the vocabulary\nWords that were observed less than 20 times in the language model\ntraining data were replaced by \\textsc{unk} tags, which gave us a\nvocabulary size of 78,498.\n% perplexity\nThe perplexity of the 4-gram language model on the test corpus is 96.\n\n% how are the substitutes computed\nIt is best to use both left and right context when estimating the\nprobabilities for potential lexical substitutes.  For example, in\n\\emph{``He lived in San Francisco suburbs.''}, the token \\emph{San}\nwould be difficult to guess from the left context but it is almost\ncertain looking at the right context.  We define $c_w$ as the $2n-1$\nword window centered around the target word position: $w_{-n+1} \\ldots\nw_0 \\ldots w_{n-1}$ ($n=4$ is the n-gram order).  The probability of a\nsubstitute word $w$ in a given context $c_w$ can be estimated as:\n\\begin{eqnarray}\n  \\label{eq:lm1}P(w_0 = w | c_w) & \\propto & P(w_{-n+1}\\ldots w_0\\ldots w_{n-1})\\\\\n  \\label{eq:lm2}& = & P(w_{-n+1})P(w_{-n+2}|w_{-n+1})\\nonumber\\\\\n  &&\\ldots P(w_{n-1}|w_{-n+1}^{n-2})\\\\\n  \\label{eq:lm3}& \\approx & P(w_0| w_{-n+1}^{-1})P(w_{1}|w_{-n+2}^0)\\nonumber\\\\\n  &&\\ldots P(w_{n-1}|w_0^{n-2})\n\\end{eqnarray}\nwhere $w_i^j$ represents the sequence of words $w_i w_{i+1} \\ldots\nw_{j}$.  In Equation \\ref{eq:lm1}, $P(w|c_w)$ is proportional to\n$P(w_{-n+1}\\ldots w_0 \\ldots w_{n+1})$ because the words of the\ncontext are fixed.  Terms without $w_0$ are identical for each\nsubstitute in Equation \\ref{eq:lm2} therefore they have been dropped\nin Equation \\ref{eq:lm3}.  Finally, because of the Markov property of\nn-gram language model, only the closest $n-1$ words are used in the\nexperiments.\n\nNear the sentence boundaries the appropriate terms were truncated in\nEquation \\ref{eq:lm3}.  Specifically, at the beginning of the sentence\nshorter n-gram contexts were used and at the end of the sentence terms\nbeyond the end-of-sentence token were dropped.\n\nFor computational efficiency only the top 100 substitutes and their\nunnormalized probabilities were computed for each of the 1,173,766\npositions in the test set\\footnote{The substitutes with unnormalized\n  log probabilities can be downloaded from \\mbox{\\url{http://goo.gl/jzKH0}}.\n  For a description of the {\\sc fastsubs} algorithm used to generate\n  the substitutes please see \\mbox{\\url{http://arxiv.org/abs/1205.5407v1}}.\n  {\\sc fastsubs} accomplishes this task in about 5 hours, a naive\n  algorithm that looks at the whole vocabulary would take more than 6\n  days on a typical 2012 workstation.}.  The probability vectors for\neach position were normalized to add up to 1.0 giving us the final\nsubstitute vectors used in the rest of this study.\n\n\n", "meta": {"hexsha": "1a4578856903f4a369d4fc5e48d390d2ea7de0f2", "size": 3954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/cl2012/emnlp12/substitute.tex", "max_stars_repo_name": "ai-ku/upos", "max_stars_repo_head_hexsha": "27d610318a0c777e2ca88b1ab2de5aa48f5a399f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2015-01-24T11:27:18.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-18T11:35:02.000Z", "max_issues_repo_path": "papers/cl2012/emnlp12/substitute.tex", "max_issues_repo_name": "ai-ku/upos", "max_issues_repo_head_hexsha": "27d610318a0c777e2ca88b1ab2de5aa48f5a399f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/cl2012/emnlp12/substitute.tex", "max_forks_repo_name": "ai-ku/upos", "max_forks_repo_head_hexsha": "27d610318a0c777e2ca88b1ab2de5aa48f5a399f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-04-06T07:56:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-06T07:56:00.000Z", "avg_line_length": 50.6923076923, "max_line_length": 82, "alphanum_fraction": 0.7582195245, "num_tokens": 1147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4336798935234578}}
{"text": "% -*- latex -*-\n\n% This file can be used for troubleshooting problems.\n\n% Adjust this file to your liking and then build using:\n%    make mathics-test.pdf\n\\chapter{Test Chapter}\n\\chapterstart\n\\chaptersections\n\\section*{TestSection}\n\\sectionstart\n\nHere is what we want to test:\n\n\\begin{asy}\nif(!settings.multipleView) settings.batchView=false;\nsettings.tex=\"xelatex\";\ndefaultfilename=\"mathics-test-1\";   % Note that filename line has been altered!\nif(settings.render < 0) settings.render=4;\nsettings.outformat=\"\";\nsettings.inlineimage=true;\nsettings.embed=true;\nsettings.toolbar=false;\nviewportmargin=(2,2);\n\n% Copy stuff here from mathics-xxx.asy\n% The below is from the \"Darker\" section around mathics-114.asy\n\nimport three;\nimport solids;\nsize(6.6667cm, 6.6667cm);\ncurrentprojection=perspective(2.6,-4.8,4.0);\ncurrentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));\n// Sphere3DBox\ndraw(surface(sphere((0, 0, 0), 1)), rgb(0.0,0.6666666666666667,0.0));\ndraw(((-1,-1,-1)--(1,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,-1,1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,-1,-1)--(-1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((1,-1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,-1,1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((1,-1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,-1,-1)--(-1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((1,-1,-1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((-1,1,-1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\ndraw(((1,1,-1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\n\\end{asy}\n\\sectionend\n\\chapterend\n", "meta": {"hexsha": "543d3cf78bd4f57d631394c0166585b2d874d367", "size": 1752, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mathics/doc/tex/testing-sample.tex", "max_stars_repo_name": "tirkarthi/mathics-core", "max_stars_repo_head_hexsha": "6b07500b935f23dc332f4ec3fac1d71ac4c8fc04", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1920, "max_stars_repo_stars_event_min_datetime": "2015-01-06T17:56:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T14:33:29.000Z", "max_issues_repo_path": "mathics/doc/tex/testing-sample.tex", "max_issues_repo_name": "tirkarthi/mathics-core", "max_issues_repo_head_hexsha": "6b07500b935f23dc332f4ec3fac1d71ac4c8fc04", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 868, "max_issues_repo_issues_event_min_datetime": "2015-01-04T06:19:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-14T13:39:38.000Z", "max_forks_repo_path": "mathics/doc/tex/testing-sample.tex", "max_forks_repo_name": "tirkarthi/mathics-core", "max_forks_repo_head_hexsha": "6b07500b935f23dc332f4ec3fac1d71ac4c8fc04", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 240, "max_forks_repo_forks_event_min_datetime": "2015-01-16T13:31:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T12:52:46.000Z", "avg_line_length": 34.3529411765, "max_line_length": 79, "alphanum_fraction": 0.622716895, "num_tokens": 739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4336798918040171}}
{"text": "\\chapter{Limits \\& Continuity}\r\n\r\nLimits are a way of describing what happens to a function $f(x)$ as $x$ gets arbitrarily close to a value from some direction (positive or negative).\r\nThis allows us not only to deal with \"holes\" in some functions but describe some of the building blocks of calculus, namely the derivative.\r\n\r\n\\input{./limits_continuity/limit_definition.tex}\r\n\\input{./limits_continuity/limit_properties.tex}\r\n\\input{./limits_continuity/left_right_hand_limits.tex}\r\n\\input{./limits_continuity/sandwich_theorem.tex}\r\n\\input{./limits_continuity/infinite_limits.tex}\r\n\\input{./limits_continuity/continuity_definition.tex}\r\n\\input{./limits_continuity/discontinuity_types.tex}\r\n\\input{./limits_continuity/continuity_properties.tex}\r\n\\input{./limits_continuity/intermediate_value_theorem.tex}", "meta": {"hexsha": "1d134534b052f22fb0a4d740a9b375dc4e546dfe", "size": 804, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/limits_continuity/limits_continuity.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "calc/limits_continuity/limits_continuity.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "calc/limits_continuity/limits_continuity.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.4285714286, "max_line_length": 150, "alphanum_fraction": 0.8047263682, "num_tokens": 187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.43367989180401706}}
{"text": "\\documentclass[11pt,a4paper]{report}\n\\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}\n\\usepackage{enumitem}\n\\usepackage{changepage}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem*{cor}{Corollary}\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\\newtheorem{conj}{Conjecture}[section]\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{exercise}{Exercise}[section]\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\\newtheorem*{note}{Note}\n\\def\\changemargin#1#2{\\list{}{\\rightmargin#2\\leftmargin#1}\\item[]}\n\\let\\endchangemargin=\\endlist \n\\begin{document}\n\n\n\\section*{Problem}\nThe function graphed below is a polynomial with only real roots. What is the function?\n\\begin{figure}[h!]\n  \\includegraphics[width=4in]{poly.png}\n  {\\caption*{}}\n  \\label{}\n\\end{figure}\n\\section*{Bonus}\nFind all roots of the polynomial $x^3-x^2+x-1$.  Explain why this example illustrates how the ``only real roots'' assumption simplifies the answer to the first part.\n\n\\newpage\n\\section*{Solution}\nFrom the graph, you can see that the polynomial has roots at $x=-1$, $x=0$, and $x=1$.  Since the polynomial has only real roots, its equation must be $p(x) = (x - - 1)(x - 0)(x - 1) = x^3 - x$.\n\n\\section*{Bonus Solution}\n$x^3 - x^2 + x - 1 = (x^2 + 1)(x - 1) = (x - i)(x -- i)(x - 1)$\nThis polynomial has roots at $\\pm i$ in the complex plane and at the real number 1.  Its graph shows only the real root at $x = 1$.  So in general, just multiplying together $(x - r_i)$ where the $r_i$ are the real roots (what you can see in its graph) will not always give you the equation of the polynomial.  If you have all of the complex roots, it will always work (up to a constant). A beautiful fact about the Complex numbers is that they make up what is called an \\textit{algebraically closed field} with the consequence that every polynomial of degree $n$ with real or complex coefficients can be factored into a product like the above, giving $n$ roots.  Some may be ``repeated'' as in $p(x) = x^2 = (x - 0)(x - 0)$.\n\n\\section*{Bonus Bonus Solution}\nThere is actually an error in the solution above. The graph is in fact the graph of the given function, but that can't actually be established from the information given.  If $p(x)$ is a polynomial and $c$ is a non-zero constant, the $r(x) = c \\mathord{\\cdot} p(x)$ is another polynomial with the same roots.  So for example, $2x^3 - 2x$ would also have the same roots as the polynomial above.\n \n\\end{document}\n\n", "meta": {"hexsha": "eec7055cedaf8db7bdc407764b71f3aa408858c3", "size": 2601, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "poly/poly.tex", "max_stars_repo_name": "psteitz/problems", "max_stars_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "poly/poly.tex", "max_issues_repo_name": "psteitz/problems", "max_issues_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-03T21:08:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T21:08:11.000Z", "max_forks_repo_path": "poly/poly.tex", "max_forks_repo_name": "psteitz/problems", "max_forks_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.1875, "max_line_length": 725, "alphanum_fraction": 0.7297193387, "num_tokens": 783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.43367988213957526}}
{"text": "\\documentclass[a4paper]{report}\n\n\\usepackage[margin=3.0cm]{geometry}\n\\usepackage{amsmath}\n\\usepackage[pdftex]{graphicx}\n%\\usepackage{graphics}\n\\usepackage{subfig}\n\\setlength\\parindent{0pt}\n%\\usepackage{natbib}           % required for bibliography\n\n\n\\title{HPIPM reference guide}\n\\author{Gianluca Frison}\n\n\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Introduction}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nHPIPM, which stands for High-Performance Interior Point Method, is a library providing a collection of quadratic programs (QP) and routines to manage them.\nAim of the library is to provide both stand-alone IPM solvers for the QPs and the building blocks for more complex optimization algorithms.\n\nAt the moment, three QPs types are provided: dense QPs, optimal control problem (OCP) QPs, and tree-structured OCP QPs.\nThese QPs are defined using C structures.\nHPIPM provides routines to manage the QPs, and to convert between them.\n\nHPIPM is written entirely in C, and it builds on top of BLASFEO~\\cite{Frison2018}, that provides high-performance implementations of basic linear algebra (LA) routines, optimized for matrices of moderate size (as common in embedded optimization).\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Dense QP}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nThe dense QP is a QP in the form\n\\begin{align*}\n\\min_{v,s} & \\quad \\frac 1 2 \\begin{bmatrix} v \\\\ 1 \\end{bmatrix}^T \\begin{bmatrix} H & g \\\\ g^T & 0 \\end{bmatrix} \\begin{bmatrix} v \\\\ 1 \\end{bmatrix} + \\frac 1 2 \\begin{bmatrix} s^l \\\\ s^u \\\\ 1 \\end{bmatrix}^T \\begin{bmatrix} Z^l & 0 & z^l \\\\ 0 & Z^u & z^u \\\\ (z^l)^T & (z^u)^T & 0 \\end{bmatrix} \\begin{bmatrix} s^l \\\\ s^u \\\\ 1 \\end{bmatrix} \\\\\n\\text{s.t.} & \\quad A v = b, \\\\\n& \\quad \\begin{bmatrix} \\underline v \\\\ \\underline d \\end{bmatrix} \\leq \\begin{bmatrix} J_{b,v} \\\\ C \\end{bmatrix} v + \\begin{bmatrix} J_{s,v} \\\\ J_{s,g} \\end{bmatrix} s^l, \\\\\n& \\quad \\begin{bmatrix} J_{b,v} \\\\ C \\end{bmatrix} v - \\begin{bmatrix} J_{s,v} \\\\ J_{s,g} \\end{bmatrix} s^u \\leq \\begin{bmatrix} \\overline v \\\\ \\overline d \\end{bmatrix}, \\\\\n& \\quad s^l\\geq \\underline s^l, \\\\\n& \\quad s^u\\geq \\underline s^u,\n\\end{align*}\nwhere $v$ are the primal variables, $s^l$ ($s^u$) are the slack variables of the soft lower (upper) constraints.\nThe matrices $J_{\\dots}$ are made of rows from identity matrices.\nFurthermore, note that the constraint matrix with respect to $v$ is the same for the upper and the lower constraints.\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{OCP QP}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nThe OCP QP is a QP in the form\n\\begin{align*}\n\\min_{x,u,s} & \\quad \\sum_{n=0}^N \\frac 1 2 \\begin{bmatrix} u_n \\\\ x_n \\\\ 1 \\end{bmatrix}^T \\begin{bmatrix} R_n & S_n & r_n \\\\ S_n^T & Q_n & q_n \\\\ r_n^T & q_n^T & 0 \\end{bmatrix} \\begin{bmatrix} u_n \\\\ x_n \\\\ 1 \\end{bmatrix} + \\frac 1 2 \\begin{bmatrix} s^l_n \\\\ s^u_n \\\\ 1 \\end{bmatrix}^T \\begin{bmatrix} Z^l_n & 0 & z^l_n \\\\ 0 & Z^u_n & z^u_n \\\\ (z^l_n)^T & (z^u_n)^T & 0 \\end{bmatrix} \\begin{bmatrix} s^l_n \\\\ s^u_n \\\\ 1 \\end{bmatrix} \\\\\n\\text{s.t}  & & \\\\\n     & \\quad x_{n+1} = A_n x_n + B_n u_n + b_n, \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad n=0,\\dots,N-1, &\\\\\n     & \\quad \\begin{bmatrix} \\underline u_n \\\\ \\underline x_n \\\\ \\underline d_n \\end{bmatrix} \\leq \\begin{bmatrix} J_{b,u,n} & 0 \\\\ 0 & J_{b,x,n} \\\\ D_n & C_n \\end{bmatrix} \\begin{bmatrix} u_n \\\\ x_n \\end{bmatrix} + \\begin{bmatrix} J_{s,u,n} \\\\ J_{s,x,n} \\\\ J_{s,g,n} \\end{bmatrix} s^l_n, \\quad \\qquad \\quad \\,n=0,\\dots,N, &\\\\\n& \\quad \\begin{bmatrix} J_{b,u,n} & 0 \\\\ 0 & J_{b,x,n} \\\\ D_n & C_n \\end{bmatrix} \\begin{bmatrix} u_n \\\\ x_n \\end{bmatrix} - \\begin{bmatrix} J_{s,u,n} \\\\ J_{s,x,n} \\\\ J_{s,g,n} \\end{bmatrix} s^u_n \\leq \\begin{bmatrix} \\overline u_n \\\\ \\overline x_n \\\\ \\overline d_n \\end{bmatrix} , \\qquad \\qquad n=0,\\dots,N, & & \\\\\n& \\quad s^l_n\\geq \\underline{s}^l_n, \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\,\\,\\,  n=0,\\dots,N, & &\\\\\n& \\quad s^u_n\\geq \\underline{s}^u_n, \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\,\\,\\,  n=0,\\dots,N, & &\\\\\n\\end{align*}\nwhere $u_n$ are the control inputs, $x_n$ are the states, $s^l_n$ ($s^u_n$) are the slack variables of the soft lower (upper) constraints\nand $\\underline{s}^l_n$ and $\\underline{s}^u_n$ are the lower bounds on lower and upper slacks, respectively.\nThe matrices $J_{\\dots,n}$ are made of rows from identity matrices.\nNote that all quantities can vary stage-wise.\nFurthermore, note that the constraint matrix with respect to $u$ and $x$ is the same for the upper and the lower constraints.\n\n%%%%%%%%%%%%%%%%\n\\section{QP dimensions structure}\n%%%%%%%%%%%%%%%%\n\n%%%%%%%%%%%%%%%%\n\\subsection{Create structure}\n%%%%%%%%%%%%%%%%\n\n\\begin{verbatim}\nint d_ocp_qp_dim_memsize(int N);\n\\end{verbatim}\n\n\\begin{verbatim}\nvoid d_ocp_qp_dim_create(int N, struct d_ocp_qp *qp, void *memory);\n\\end{verbatim}\n\n%%%%%%%%%%%%%%%%\n\\subsection{Populate structure}\n%%%%%%%%%%%%%%%%\n\nOnce created, an OCP QP dimmensions structure can be populated using the global setter routine\n\\begin{verbatim}\nvoid d_ocp_qp_dim_set_all(int *nx, int *nu,\n    int *nbx, int *nbu, int *ng,\n    int *nsbx, int *nsbu, int *nsg,\n    struct d_ocp_qp_dim *dim);\n\\end{verbatim}\nwhich is useful when all structure fields have to be populated at onece.\n\nAlternatively, it is possible to set the individual structure fields with the setter routine\n\\begin{verbatim}\nvoid d_ocp_qp_dim_set(char *field, int *stage, int value,\n    struct d_ocp_qp_dim *dim);\n\\end{verbatim}\nwhere {\\tt field} can be one of {\\tt nx, nu, nbx, nbu, ng, nsbx, nsbu, nsg}.\n\n%%%%%%%%%%%%%%%%\n\\section{QP structure}\n%%%%%%%%%%%%%%%%\n\n%%%%%%%%%%%%%%%%\n\\subsection{Create structure}\n%%%%%%%%%%%%%%%%\n\n\\begin{verbatim}\nint d_ocp_qp_memsize(struct d_ocp_qp_dim *dim);\n\\end{verbatim}\n\n\\begin{verbatim}\nvoid d_ocp_qp_create(struct d_ocp_qp_dim *dim, struct d_ocp_qp *qp, void *memory);\n\\end{verbatim}\n\n%%%%%%%%%%%%%%%%\n\\subsection{Populate structure}\n%%%%%%%%%%%%%%%%\n\nOnce created, an OCP QP structure can be populated using the global conversion routine\n\\begin{verbatim}\nvoid d_ocp_qp_set_all(double **A, double **B, double **b, \n    double **Q, double **S, double **R, double **q, double **r, \n    int **idxbx, double **lbx, double **ubx, \n    int **idxbu, double **lbu, double **ubu, \n    double **C, double **D, double **lg, double **ug, \n    double **Zl, double **Zu, double **zl, double **zu, \n    int **idxs, double **lls, double **lus,\n    struct d_ocp_qp *qp);\n\\end{verbatim}\nwhich is useful when all the structure fileds have to be populated at once.\n\nAlternatively, it is possible to set the individual structure fields with the setter routine\n\\begin{verbatim}\nvoid d_ocp_qp_set(char *field, int *stage, void *value,\n    struct d_ocp_qp *qp);\n\\end{verbatim}\nwhere {\\tt filed} can be one of {\\tt A, B, b, Q, S, R, q, r, idxb, lb, ub, Jbx, idxbx, lbx, ubx, Jbu, idxbu, lbu, ubu, C, D, lg, ug, Zl, Zu, zl, zu, idxs, lls, lus}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \\chapter{Tree OCP QP}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n%\\bibliographystyle{plain}\n%\\bibliography{biblio}             % bib file to produce the bibliography\n\n\\begin{thebibliography}{1}\n\n\\bibitem{Frison2018}\nG.~Frison, D.~Kouzoupis, T.~Sartor, A.~Zanelli, and M.~Diehl.\n\\newblock {BLASFEO}: Basic linear algebra subroutines for embedded\n  optimization.\n\\newblock {\\em ACM Transactions on Mathematical Software (TOMS)}, 2018.\n\\newblock (accepted).\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "6983916b65729998979c3f8b4c7d55377dce78a6", "size": 7468, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/guide.tex", "max_stars_repo_name": "aghezz1/hpipm", "max_stars_repo_head_hexsha": "937c9d7264ac1624ef5539bb4208a8b7c8d3e140", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 235, "max_stars_repo_stars_event_min_datetime": "2017-12-12T03:41:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T08:02:15.000Z", "max_issues_repo_path": "doc/guide.tex", "max_issues_repo_name": "aghezz1/hpipm", "max_issues_repo_head_hexsha": "937c9d7264ac1624ef5539bb4208a8b7c8d3e140", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 92, "max_issues_repo_issues_event_min_datetime": "2017-09-18T09:32:19.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-09T04:27:11.000Z", "max_forks_repo_path": "doc/guide.tex", "max_forks_repo_name": "aghezz1/hpipm", "max_forks_repo_head_hexsha": "937c9d7264ac1624ef5539bb4208a8b7c8d3e140", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 86, "max_forks_repo_forks_event_min_datetime": "2017-09-12T09:12:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T03:41:44.000Z", "avg_line_length": 42.1920903955, "max_line_length": 440, "alphanum_fraction": 0.644884842, "num_tokens": 2486, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.43362128207840067}}
{"text": "\\section{Efficiency Analysis}\n\nHere we try to analyze the speedup of Parareal analytically, and then through\nscalability studies conducted on the supercomputer Prince, here at NYU. \n\n\\subsection{Theoretical Results}\n\nWe try to directly estimate the speedup of the Naive OpenMP implementation. We\ndenote our speedup $S$ by: (\\cite{fieldstalk} slide 17)\n\\begin{equation*}\n  S = \\frac{\\text{Time taken by fine solver}}{\\text{Parareal time}}\n\\end{equation*}\nLet the time taken by the fine and coarse solvers respectively be denoted by\n$T_f$ and $T_g$. Furthermore, suppose we have the optimal amount of processors\n$P$, such that $\\Delta t = T/P$, where $T$ is the time to integrate up to.\n\nConsidering this, each step parareal makes a predictor and corrector\ncomputation. The predictor is just a run of the coarse solver, costing $PT_g$.\nThe corrector has two parts, the fine and coarse portion. The fine portion is\nparallelized optimally, and therefore costs just $T_f$, instead of $PT_f$.  In\naddition, the coarse portion of the corrector takes advantage of the\n\\textit{first same as last} property, and doesn't have to be counted sepreately.\nRecall, also, before the parareal iteration, we make an initial guess using one\ncoarse solve, $PT_g$. Therefore, for a parareal with $k$ iterations it would\nhave speedup:\n\\[\n  S = \\frac{PT_f}{PT_g + k(PT_g + T_f)} \n  = \\frac{1}{\\frac{T_g}{T_f} + k(\\frac{T_g}{T_f} + \\frac{1}{P})} \n  = \\frac{1}{\\frac{T_g}{T_f}(1+k) + \\frac{k}{P}} \n\\]\nNotice, under the limit:\n\\[\n  \\lim_{P \\to \\infty} S = \\frac{1}{\\frac{T_g}{T_f}(1+k)} = \\frac{T_f}{T_g(1+k)}\n\\]\nSupposing we have the idealized case of $k = 1$, then we would find that this\nwould result in speedup $\\frac{T_f}{2T_g}$, which, given that $T_g << T_f$,\ncould be significant. However, in practice, $k$ has to be taken to be large\nenough so that $S$ isn't too great. This is one of the first indicators we have\nof why $T_g << T_f$ must be true. \n\n\\subsection{Scalability}\n\nSince this algorithm is designed to take our numerical ODE techniques to a high\nperformance computing context, we would like to perform the standard scalability\ntests using this algorithm, measuring how it scales to massively parallel\nhardware.\n\nAll tests are performed on a single Prince node, having requested 28 processors.\nWe would be worried about other processes running on this node if this problem\nwas memory bound, however since the fine computation is performed in place and\nthe coarse operator has few points, the computation is compute bound.\n\n\\subsubsection{Strong Scaling Study}\n\nA strong scaling study consists of fixing a total problem size, and increasing\nthe number of processors necessary. See figure \\ref{fig:strong_scaling} for our\nperformed analysis.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=.8\\textwidth]{./resources/strong_scaling}\n  \\caption{This is a strong scaling study performed on the ODE $u' = u, u(0) =\n  1$ integrating on time scale $[0, 4]$. Here we divided our time scale into\n  pieces of size $4/P$, and then ran Parareal restricting the number of\n  processors. Notice how the time taken doesn't improve from $14 \\to\n  28$.}\\label{fig:strong_scaling}\n\\end{figure}\nNote that figure \\ref{fig:strong_scaling} presents a very interesting, and\ndismal, phenomena. Notice how from processors $14 \\to 27$ the speedup recieved\nis negligable from the previous. Why does this occur? Recall that the optimal\nnumber of processors for parareal iteration is the number of coarse steps, so\nthat we can process all of the $\\fine$ integrators in one step. However,\nsupposing we have one less than optimal, the entire compute time is bounded by\nthat one thread that has to process two $\\fine$ integrators. This is\ntroublesome.\nIn fact, suppose we desire to cut our time domain $[0, T]$ into $2N$ pieces.\nThen any computation with number of processors $P$ taking value $N \\to 2N-1$\nwill have the same computation time, theoretically.\n\nNotice, however, that the general speedup does follow the theoretical linear\nspeedup we hope to see with $P$ processors, which is great.\n\n\\subsubsection{Weak Scaling Study}\n\nThe weak scaling study examines how the runtime increases as we increase the\namount of processors, working on a similar sized problem. See figure\n\\ref{fig:weak_scaling} for the results.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=.8\\textwidth]{./resources/weak_scaling}\n  \\caption{}\\label{fig:weak_scaling}\n\\end{figure}\nWe see that the Weak Scaling of parareal is alright, seeming to stay roughly\nconstant, or atleast sublinear as we increase the number of processors doing\nequal amounts of work. Note, this can only be true if $T_g << T_f$, otherwise we\nwill be bounded by Amadahl's law. When we increase the amount of processors\nworking, what happens is that the fine portion is computed in the same amount of\ntime, but the amount of points in general increase. This implies that the serial\nportion of the computation will increase linearly in the number of points, so if\nthe course computation is not very cheap with respect to the fine computation,\nwe will lose the weak scaling performance.\n", "meta": {"hexsha": "a0457050f04b5bc34a4b05096dcfea2bfad8c574", "size": 5112, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/TeXsrc/src/efficiency.tex", "max_stars_repo_name": "abhijit-c/Parareal", "max_stars_repo_head_hexsha": "e64c8ae44577da7e92720aa12b12f28acb3fc473", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-01T19:31:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-08T13:54:15.000Z", "max_issues_repo_path": "Report/TeXsrc/src/efficiency.tex", "max_issues_repo_name": "abhijit-c/Parareal", "max_issues_repo_head_hexsha": "e64c8ae44577da7e92720aa12b12f28acb3fc473", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/TeXsrc/src/efficiency.tex", "max_forks_repo_name": "abhijit-c/Parareal", "max_forks_repo_head_hexsha": "e64c8ae44577da7e92720aa12b12f28acb3fc473", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-25T00:02:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-25T00:02:33.000Z", "avg_line_length": 50.6138613861, "max_line_length": 80, "alphanum_fraction": 0.7642801252, "num_tokens": 1336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7931059487389968, "lm_q1q2_score": 0.433621280741563}}
{"text": "\\documentclass{article}  %Need this.\n\n\\usepackage{amsmath,amsthm,amssymb}\n\n\n\\newtheorem*{thm}{Theorem}\n\\newtheorem*{cnj}{Conjecture}\n\\newtheorem*{lem}{Lemma}\n\\newtheorem*{cor}{Corollary}\n\\newtheorem*{prop}{Proposition}\n\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\R}{\\mathbb{R}}\n\n\n\n\n\n\\title{Proof Portfolio Problem \\#  1--  Example--}\n\\author{--Dr. Keough --}\n\\date{}\n\n\\begin{document}\n\\maketitle  %This will add the title, author, and date located above\n\n\nHere's the problem: You work for a cell phone company which has just invented a new cell phone protector and wants to advertise that it can be dropped from the $n^{th}$ floor without breaking. \nIf you are given 2 phones and a 100 story building, how do you guarantee you know the highest floor it won't break with the smallest number of trial drops?\n\n\nYou might want to try this problem before you read the proof. On the next page I include my scratchwork.\n\n\\newpage\n...\n\n\\newpage\n\n\n\n\\begin{thm}\nIf there are 2 cell phones and a 100 story building available then one can test dropping cell phones from 14 stories and find the maximum number of stories the cell phone can be dropped from without breaking.\n\\end{thm}\n\n\\begin{proof}\nWe will describe an algorithm for needing only to drop from 14 stories. Our first step will be to drop the first phone from the $14^{th}$ floor. If the phone breaks from this floor, we will test floors $1$ through $13$, in order, until the cell phone breaks, giving us up to a total of $14$ drops. If the phone does not break on a drop from the $14^{th}$ floor, we will drop the phone from the $27^{th}$ floor. If the phone breaks from the $27^{th}$ floor, we'll need to test floors $15$ through $26$. This is 12 more floors, in addition to the drop from the $14^{th}$ and the drop from the $27^{th}$ again giving us $14$ drops. \n\nWe'll continue this process by dropping from floors $39, 50, 60, 69, 77, 84, 90, 95,$ and finally $99$. If we make it all the way to the $99^{th}$ floor then we will have done $11$ drops. In any other case, we will do $14$ total drops as seen by the following cases, which consider the first floor the phone breaks on from the list $39, 50, 60, 69, 77, 84, 90, 95$:\n\t\\begin{itemize}\n\t\\item The phone first breaks on the $39^{th}$ floor: In this case we test floors $14, 27, 39$ and floors $28-38$ giving $14$ total drops.\n\t\\item The phone first breaks on the $50^{th}$ floor: In this case we test floors $14, 27, 39, 50$ and floors $40-49$ giving $14$ total drops.\n\t\\item The phone first breaks on the $60^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60$ and floors $51-59$ giving $14$ total drops.\n\t\\item The phone first breaks on the $69^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60, 69$ and floors $60-68$ giving $14$ total drops.\n\t\\item The phone first breaks on the $77^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60, 69, 77$ and floors $70-76$ giving $14$ total drops.\n\t\\item The phone first breaks on the $84^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60, 69, 77, 84$ and floors $78-83$ giving $14$ total drops.\n\t\\item The phone first breaks on the $90^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60, 69, 77, 84,90$ and floors $85-89$ giving $14$ total drops.\n\t\\item The phone first breaks on the $95^{th}$ floor: In this case we test floors $14, 27, 39, 50, 60, 69, 77, 84,90,95$ and floors $91-94$ giving $14$ total drops.\n\t\\end{itemize}\n\nThus we see that we can figure out the maximum floor where the phone breaks in $14$ total drops.\n\\end{proof}\n\n\\newpage\n\n\\section*{A Couple of Notes}\n\n\\begin{enumerate}\n\\item Note the proof does not claim that there isn't a better solution. Don't feel like you need to do every piece of a problem. Figure out something cool, and try to prove it.\n\\item On that note it's best to check your conjectures with me. I can help you if they are too hard, too obvious, too false, and also brainstorm proof ideas.\n\\item Remember that  a proof, at its heart, is just an explanation that other mathematicians believe. Don't feel like you need to adhere to strictly to a specific proof technique. Give a convincing explanation.\n\\item Pick a problem you like and start early so that this can be fun and not something you're worried about in the last week of the semester.\n\\end{enumerate}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "2be80ab56939dce53fe5d0c3ebfaa84d9ec50a75", "size": 4354, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "from LDK/4-ProofPortfolio/PCPExample.tex", "max_stars_repo_name": "mkjanssen/discrete", "max_stars_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "from LDK/4-ProofPortfolio/PCPExample.tex", "max_issues_repo_name": "mkjanssen/discrete", "max_issues_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "from LDK/4-ProofPortfolio/PCPExample.tex", "max_forks_repo_name": "mkjanssen/discrete", "max_forks_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.5454545455, "max_line_length": 629, "alphanum_fraction": 0.7225539734, "num_tokens": 1291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165382362518, "lm_q2_score": 0.8221891392358015, "lm_q1q2_score": 0.4335539306772665}}
{"text": "\\appendix\n\\chapter*{Additional figures}\n\\paragraph{Chapter 4 : Looking into financial data} \\textcolor{white}{Below, the cumulated residuals between }\n\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}[]{ | p{3cm} || m{9cm} ||}\n\t\t\\hline\n\t\tStock & Cumulative residuals between $\\exp(R_t)$ and $1 + R_t$  \\\\ \\hline\n\t\tBNP & 3.22E-15  \\\\ \\hline\n\t\tCarrefour & 1.44E-15  \\\\ \\hline\n\t\tLVMH & 4.75E-15  \\\\ \\hline\n\t\tSanofi & 1.55E-15  \\\\ \\hline\n\t\tTotal & 3.86E-15  \\\\ \\hline\n\t\\end{tabular}\n\t\t\\caption{Cumulative residuals between $\\exp(R_t)$ and $1 + R_t$ for the BNP, Carrefour, LVMH, Sanofi, Total stocks}\n\t\t\\label{tab:cumulativeResidualsStocks}\n\\end{table}", "meta": {"hexsha": "ab4aafdd28d78a0b303998bc74339266ca1288d1", "size": 644, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/tail/additionalFigures.tex", "max_stars_repo_name": "CillianMH/pdmExtremeValueTheory", "max_stars_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/tail/additionalFigures.tex", "max_issues_repo_name": "CillianMH/pdmExtremeValueTheory", "max_issues_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/tail/additionalFigures.tex", "max_forks_repo_name": "CillianMH/pdmExtremeValueTheory", "max_forks_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.8823529412, "max_line_length": 117, "alphanum_fraction": 0.6708074534, "num_tokens": 259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6584175139669998, "lm_q1q2_score": 0.433513613872189}}
{"text": "\n\\chapter{Summary and Discussion}\n\\label{chapter.summary}\n\n\nWe have first discussed entropy for percolation. Note that percolation\nis a probabilistic model and hence Shannon entropy is the only hope if we want to measure entropy \nfor percolation. To measure the Shannon entropy for percolation we \nhave defined the cluster picking probability $\\mu_i$ that a site is picked at random belongs to\nthe labelled cluster $i$. It gives entropy which is consistent with the behaviour \nof the order parameter. Essentially entropy measures \nthe degree of disorder while order parameter measures the extent of order. Thus, entropy and order parameter cannot be minimum or maximum \nat the same state since the system cannot be in most disordered and most ordered state at the same time.\nHowever, by measuring entropy and order parameter using existing definition for site percolation, we find\nthat at $p=0$ both order parameter and entropy equal \nto zero which is absurd. It demands immediate correction to the definition of entropy and we obliged. \nNote that in the bond percolation we occupy bond to connect sites and measure clusters by the\nnumber of sites. In analogy with that we redefine the site percolation as follows. We occupy sites to connect \nbonds which are assumed to exist already in the system and measure clusters in terms of the number of bonds. On the other hand, occupation probability in the bond (site) percolation is the fraction of bonds (sites) occupied\nin the system. With this new definition we have found the entropy behaves exactly in the same way as \nit does in the case of its bond counterpart. Thus the conflict that the system is in ordered and disordered \nat the same state is resolved. \n\n\nThe question that arises then is: Do we recover all the known results? To verify\nthis we obtained all the necessary critical exponents with the new definition for \nsite percolation. Earlier it was well-known that bond and site percolation belong to the\nsame universality class regardless of the nature of lattice but have the same dimension.\nWe have confirmed that bond and redefined site percolation still belong to the same universality class. \nNote that scaling theory predicts that the various critical exponents cannot just assume values \nindependently  rather they are bound by some scaling and hyperscaling relations. One\nof the most interesting relations is the Rushbrooke inequality $\\alpha+2\\beta+\\gamma\\geq 2$.\nSubstituting our values of $\\alpha=0.906$, $\\gamma=0.8543$ and already\nknown value of $\\beta=0.137$ we find $\\alpha+2\\beta+\\gamma=2.0347$. \nWe can thus conclude that the RI holds almost as equality but marginally greater\nthan $2$. \n\n\n\n %%%%%%%%%%%% RSBD summary\n Then we have investigated percolation by random sequential ballistic deposition (RSBD) on a square lattice with interaction range upto second nearest neighbors. The critical points $p_c$ and all the necessary critical exponents $\\alpha$, $\\beta$, $\\gamma$, $\\nu$ etc. are obtained numerically for each range of interactions. Like  in its thermal counterpart, we find that the critical exponents of RSBD depend on the range of interactions and for a given range of interaction they obey the Rushbrooke inequality. We obtain  the fractal dimension $d_f$ that characterizes the spanning cluster at $p_c$. Our results suggest that the RSBD for each range of interaction belong to a new universality class which is in sharp contrast to earlier results of the only work that exhist on RSBD.\n \n\nWe denote $L_0,L_1,L_2$ for expressing direct, first nearest neighbor and second nearest neighbor interaction respectively. Obviously $L_0$ denotes the regular kind of site percolation where we choose a site randomly with uniform probability and occupy it if it is empty else we skip the step. And $L_1$ is the class where we choose one of the four neighbor to occupy whenever we fail to do $L_0$ but only if the neighbor is empty else we skip the step. Finally in $L_2$ we choose the neighbor in the direction of the second neighbor, which was picked but was not empty, to occupy if it is empty else we skip the step. We have found that for $L_1$ and $L_2$ the exponents $\\alpha, \\beta, \\gamma, \\nu$ are consistent and they belong to a universality class respectively. \nNote that  we can use new feature of $L_1$ only if the feature of $L_0$ is unavailable, i.e., the selected site is already occupied. Similarly we can use new feature of $L_2$ only if the feature of $L_0$ and $L_1$ is unavailable. Using this in mind we perform simulation and we obtain the critical exponents which agree with the laws of thermodynamics and the Rushbrooke inequality is satisfied in all cases.\n\n\\clearpage\n\\newpage\n\\section{Results}\nHere we list all the exponents found in our investigation of site percolation after redefining it and the RSBD model. Table (\\ref{tab:exponents-combined}) Lists all the critical values and exponents as we find them in our exponents. Note that we can get the exponent $a$, for example, from exponent $a/\\nu$ simply by dividing them by $1/\\nu$ which is shown in table (\\ref{tab:rushbrooke}) where we also show that the Rushbrooke inequality is satisfied.\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|c|c|c|c|c|c|}\n\t\\hline\n\tInteraction & $p_c$ & $1/\\nu$ & $\\alpha/\\nu$ & $\\beta/\\nu$ & $\\gamma/\\nu$ \\\\ \\hline\n\t$L_0$ & 0.5927 & 0.75  & 0.6799 & 0.103  & 0.64071  \\\\ \\hline\n\t$L_1$ & 0.5782 & 0.736 & 0.6712 & 0.1026 & 0.6287  \\\\ \\hline\n\t$L_2$ & 0.5701 & 0.721 & 0.6631 & 0.0982 & 0.6362  \\\\ \\hline\n\\end{tabular}\n\\caption{List of combined exponents}\n\\label{tab:exponents-combined}\n\\end{table}\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|c|c|c|c|c|}\n\t\\hline\n\tInteraction & $\\alpha$ & $\\beta$ & $\\gamma$ & $\\alpha+2\\beta+\\gamma$ \\\\ \\hline\n\t$L_0$  & 0.906 & 0.137 & 0.8543 & 2.0347   \\\\ \\hline\n\t$L_1$  & 0.911 & 0.139 & 0.8542 & 2.044   \\\\ \\hline\n\t$L_2$  & 0.919 & 0.136 & 0.882  & 2.07    \\\\ \\hline\n\\end{tabular}\n\\caption{Exponents Satisfying Rushbrooke Inequality}\n\\label{tab:rushbrooke}\n\\end{table}\n\nFinally we list all the fractal dimensions, $d_f$, for different interactions in table (\\ref{tab:cluster-info}).\n\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\t\\hline\n\t\tInteraction \t& $d_f$     \\\\ \\hline\n\t\t$L_0$ (standard) \t& 91/48     \\\\ \\hline\n\t\t$L_0$ (obtained)\t& 1.8939   \\\\ \\hline\n\t\t$L_1$\t\t\t\t& 1.8994      \\\\ \\hline\n\t\t$L_2$\t\t\t\t& 1.9081     \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Fractal dimensions for $L_0,L_1,L_2$ respectively.}\n\t\\label{tab:cluster-info}\n\\end{table}\n\t\t\nHere we notice that the critical point decreases as we increase the range of interaction. But the fractal dimension increases. This is reasonable since my occupying nearest and second nearest neighbor we are increasing the change of any individual cluster to grow faster. This is the reason for the $p_c$ value to decrease. But it grows in area not in length average meaning when the spanning cluster appears it will contain more sites and bonds than in regular percolation which is evident from the fractal dimension $d_f$.\nAll other exponents changes a bit but their shape is not different. That's why change is not visible to the naked eye and it requires a thorough investigation.\n\n\\clearpage\n\\section{Further Research}\n\tThe idea of RSBD molde can be applies to many other lattice structures. Notice that in square lattice we only have four neighbor for a site but in other structures of lattice we may have more or less than four neighbors for one site, e.g. honeycomb lattice, triangular lattice. Here we have only considered interaction up to second nearest neighbor which can be extended to an arbitrary range but it will only be effective if we take the lattice size to be large. Instead of single layer formation we can go for multi-layer formation since in real world if we drop particle (for example sand or grain) in a confined space then it will create multiple layer form. Controlling the velocity parameter at which the particle move to a certain direction can also be an interesting thing to do. We can try to involve particles of different sizes and apply the RSBD model which might give some interesting results.", "meta": {"hexsha": "820421a66750de98039172ce5cfdb274e23af3cc", "size": 8113, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter6/chapter6.tex", "max_stars_repo_name": "sha314/MS_thesis_DU_PH", "max_stars_repo_head_hexsha": "c1981167c2503ce5f30fdaf564aa12e824718031", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter6/chapter6.tex", "max_issues_repo_name": "sha314/MS_thesis_DU_PH", "max_issues_repo_head_hexsha": "c1981167c2503ce5f30fdaf564aa12e824718031", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter6/chapter6.tex", "max_forks_repo_name": "sha314/MS_thesis_DU_PH", "max_forks_repo_head_hexsha": "c1981167c2503ce5f30fdaf564aa12e824718031", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.6391752577, "max_line_length": 907, "alphanum_fraction": 0.7653149267, "num_tokens": 2114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.43351360063274624}}
{"text": "\\chapter{Paper Errata}\\label{app:paperErrata}\nThis appendix shows some errors that appeared in the published papers.\n\\\\\n\\subsubsection{Real-Time Implementation of an Elasto-Plastic Friction Model applied to Stiff Strings using Finite Difference Schemes \\citeP[C]}\n\\begin{itemize}\n    \\item The authors in reference [15] are a bit shuffled.\n\\end{itemize}\n\\subsubsection{Real-time Implementation of a Physical Model of the Tromba Marina \\citeP[D]}\n\\begin{itemize}\n    \\item The minus sign in Eq. (28) (and thus Eqs. (31) and (35)) should be a plus sign.\n    \\item $\\sigma_{1,\\text{s}}$ in Eq. (21) should be $\\sigma_{1,\\text{p}}$\n    \\item The unit of the spatial Dirac delta function $\\delta$ should be m$^{-1}$\n\\end{itemize}\n%\n\\subsubsection{DigiDrum: A Haptic-based Virtual Reality Musical Instrument and a Case Study \\citeP[F]}\n\\begin{itemize}\n    \\item $\\sigma_0$ and $\\sigma_1$ should be multiplied by $\\rho H$ in order for the stability condition to hold.\n    \\item stability condition is wrong. Should be: \n    \\begin{equation}\n        h \\geq \\sqrt{c^2k^2 + 4\\sigma_1k + \\sqrt{(c^2k^2+4\\sigma_1k)^2 + 16\\kappa^2k^2}}\n    \\end{equation}\n    \\item Unit for membrane tension is N/m.\n\\end{itemize}\n% %\n% \\subsubsection{Dynamic grids \\citeP[G]}\n% \\begin{itemize}\n%     \\item Reference in intro for `recently gained popularity' should go to \\cite{Bilbao2019CMJa} \\\\\n%     \\textit{Note: not really an error, but should be changed before resubmission}\n% \\end{itemize}", "meta": {"hexsha": "24cbc867aecbf69b3670db7dd9c95ccdb2ca55c1", "size": 1465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aauPhdCollectionThesis/appendices/paperErrata.tex", "max_stars_repo_name": "SilvinWillemsen/phdThesis", "max_stars_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aauPhdCollectionThesis/appendices/paperErrata.tex", "max_issues_repo_name": "SilvinWillemsen/phdThesis", "max_issues_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aauPhdCollectionThesis/appendices/paperErrata.tex", "max_forks_repo_name": "SilvinWillemsen/phdThesis", "max_forks_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.5172413793, "max_line_length": 143, "alphanum_fraction": 0.7146757679, "num_tokens": 444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.43348982007863845}}
{"text": "% !TEX root = ../main.tex\n\\section{Introduction}\nIn statistical physics, building a model corresponding to a physical system is useful: comparing how the model's predictions differ from experiment can be used to understand how a system behaves. For computing properties corresponding to a model's behavior, the normalization constant of the model's Boltzmann distribution in \\Cref{eq:boltzmann} is a central quantity. The partition function can be used to derive properties of physics models that can be measured in experimental realizations, such as specific heat or magnetization. Such properties of models can be compared to experimental values, which can inform how a model might be improved to better mirror reality. But the partition function is intractable for many probabilistic models of interest, as described in \\Cref{ch:background}.\n\nOne workaround to the problem of an intractable partition function is to use an approximate inference algorithm such as \\gls{mcmc}. \\gls{mcmc} relies on sampling likely configurations of a system and does not require calculating the partition function. In theory, these samples will be draws from the probability model of interest~\\citep{metropolis1953equation,andrieu2003an-introduction}. For example, samples from the Boltzmann distribution can be used to approximate physical quantities derived from the probability model, such as specific heat.\n\nHowever, with limited computation \\gls{mcmc} has limitations. This method requires practitioners to use convergence diagnostics~\\citep{brooks1998general} to assess whether samples from the algorithm are independent. Scalable \\gls{mcmc} requires careful consideration. While some scalable versions of \\gls{mcmc} have been developed~\\citep{neal2011mcmc,welling2011bayesian}, they are biased samplers that may not have guaranteed convergence to samples from the probability model of interest. This is similar to how in \\gls{vi} performance must often be assessed empirically. But in comparison to \\gls{vi}, unless a model-specific algorithm has been developed~\\citep{wolff1989comparison}, generic \\gls{mcmc} methods do not readily scale to large numbers of random variables.\n% - describe the contributions of our paper: (1) show that\n% gibbs-bogoliubov-feynman inequality is equivalent to variational inference.\n% (1) show how the reinforcement learning approach of wu (2019) is more\n% naturally expressed in terms of variational inference. (2) show that a modern\n% tool of variational inference, HVMs, is useful and improves on wu (2019) by\n% scaling to larger system sizes.\n\nIn \\Cref{ch:background} we showed that the machine learning framework of \\gls{vi} is equivalent to the \\acrlong{gbf} variational principle. This has allowed practitioners to study statistical physics models using many variational approximations, including \\glspl{van}. As an example of a variational method enabled by \\gls{vi}, we study \\glspl{hvm} as approximations to the Boltzmann distribution of statistical physics models. We find that \\glspl{hvm} scale to larger systems sizes than \\glspl{van} in Sherrington-Kirkpatrick and Ising models. Testing the feasibility of \\gls{vi} methods in statistical physics is a twofold opportunity. Statistical physics problems might serve as benchmarks for \\gls{vi}, and using \\gls{vi} for these problems can lead to improved computational methods in statistical physics. % and where exact solutions ar eknown?\n\\paragraph{Related Work.} The \\gls{gbf} variational principle has been used to study Markov random fields~\\citep{jun-zhang1996the-application} and the connection between variational inference and statistical physics has been well-documented~\\citep{blei2017variational,hoffman2013stochastic,mackay2003information}. But this equivalence between \\gls{vi} and the \\gls{gbf} inequality might serve as an introduction to \\gls{vi} for physicists. \\citet{wu2019solving} implicitly use \\gls{vi}, by developing \\glspl{van} and a reinforcement learning policy gradient algorithm (however, \\gls{vi} is not mentioned). Further, for a system of size $L$, autoregressive neural networks require $\\cO(L^2)$ forward passes to sample a system configuration, making \\glspl{van} intractable in larger systems. The use of \\glspl{hvm} can be advantageous for statistical physics as these models can sample from a system in $\\cO(L)$ time and yield results for larger systems.\n\n\\paragraph{Variational Inference.}\n\\gls{vi} is equivalent to the \\gls{gbf} variational principle and requires similar choices of a practitioner. The variational family $q(\\mbz; \\mbnu)$ to approximate a model must be chosen, in addition to a method to maximize the variational lower bound in \\Cref{eq:llbo}.\n\nThe \\gls{vi} literature provides several choices of variational family, such as a mean field, factorized variational distribution with independent latent variables. Another choice of variational family is the Bethe approximation, which constrains the variational distribution to the polytope of mean parameters that captures correlations between any two latent variables~\\citep{wainwright2008graphical}. Some machine learning research focuses on developing variational approximations that capture correlations between latent variables~\\citep{hoffman2015stochastic,kingma2016improved,maaloe2016auxiliary,wu2019solving}. An example of a variational family that can model correlations between latent variables is the \\gls{van} family~\\citep{wu2019solving}, which uses autoregressive neural networks to parameterize the variational distribution ${q(\\mbz_i \\mid \\mbz_1, \\ldots, \\mbz_{i-1})}$. We explore the \\gls{hvm} class of variational approximations~\\citep{ranganath2018black}.\n\nThe second choice required to employ \\gls{vi} is how to optimize the variational lower bound in \\Cref{eq:llbo}. The choice of variational family can limit the available optimization techniques. For a simple variational family like the mean field approximation, it may be possible to analytically evaluate the expectations in \\Cref{eq:llbo}. Then derivatives of the variational bound with respect to the variational parameters $\\mbnu$ and manual calculation can maximize the lower bound, as derived in \\Cref{sec:ising-mean-field}. If more expressive variational families are used (e.g. \\gls{van}s with thousands or millions of variational parameters), the analytic approach is infeasible. Stochastic optimization and automatic differentiation software have been used to develop several approaches to computing gradients of the variational lower bound, such as \\acrlong{bbvi}~\\citep{ranganath2018black,mohamed2019monte}.\n\\input{ch-hvm/fig/graphical_model}\n\nThe choice of variational family $q(\\mbz; \\mbnu)$ and optimization method for maximizing the variational lower bound leads to a trade-off intrinsic to \\gls{vi}. Simple variational approximations such as the mean field family may be computationally feasible but inaccurate. The cost of increased accuracy, say by using a structured variational approximation, is increased computation. We illustrate the use of \\gls{vi} in statistical physics by comparing two choices of variational approximation, \\glspl{hvm}~\\citep{ranganath2018black} and \\glspl{van}~\\citep{wu2019solving}. Many other variational approximations can be explored in future work.\n", "meta": {"hexsha": "77e85bae0ed27c816944163c16e8425c1e1baa84", "size": 7260, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-hvm/sec_intro.tex", "max_stars_repo_name": "altosaar/thesis", "max_stars_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-21T18:56:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T12:18:53.000Z", "max_issues_repo_path": "ch-hvm/sec_intro.tex", "max_issues_repo_name": "altosaar/thesis", "max_issues_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch-hvm/sec_intro.tex", "max_forks_repo_name": "altosaar/thesis", "max_forks_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 268.8888888889, "max_line_length": 976, "alphanum_fraction": 0.8154269972, "num_tokens": 1701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.43348981116180635}}
{"text": "% Copyright 2017-2019 Burlen Loring, Remi Lehe\n%\n% This file is part of WarpX.\n%\n% License: BSD-3-Clause-LBNL\n\n\\input{newcommands}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Moving window and optimal Lorentz boosted frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nThe simulations of plasma accelerators from first principles are extremely computationally intensive, due to the need to resolve the evolution of a driver (laser or particle beam) and an accelerated particle beam into a plasma structure that is orders of magnitude longer and wider than the accelerated beam. As is customary in the modeling of particle beam dynamics in standard particle accelerators, a moving window is commonly used to follow the driver, the wake and the accelerated beam. This results in huge savings, by avoiding the meshing of the entire plasma that is orders of magnitude longer than the other length scales of interest.\n\n\\begin{figure}\n%\\begin{centering}\n\\includegraphics[scale=0.6]{Boosted_frame.png}\n%\\par\\end{centering}\n\\caption{\\label{fig:PIC} A first principle simulation of a short driver beam (laser or charged particles) propagating through a plasma that is orders of magnitude longer necessitates a very large number of time steps. Recasting the simulation in a frame of reference that is moving close to the speed of light in the direction of the driver beam leads to simulating a driver beam that appears longer propagating through a plasma that appears shorter than in the laboratory. Thus, this relativistic transformation of space and time reduces the disparity of scales, and thereby the number of time steps to complete the simulation, by orders of magnitude.}\n\\end{figure}\n\nEven using a moving window, however, a full PIC simulation of a plasma accelerator can be extraordinarily demanding computationally, as many time steps are needed to resolve the crossing of the short driver beam with the plasma column. As it turns out, choosing an optimal frame of reference that travels close to the speed of light in the direction of the laser or particle beam (as opposed to the usual choice of the laboratory frame) enables speedups by orders of magnitude \\cite{Vayprl07,Vaypop2011}. This is a result of the properties of Lorentz contraction and dilation of space and time. In the frame of the laboratory, a very short driver (laser or particle) beam propagates through a much longer plasma column, necessitating millions to tens of millions of time steps for parameters in the range of the BELLA or FACET-II experiments. As sketched in Fig. \\ref{fig:PIC}, in a frame moving with the driver beam in the plasma at velocity $v=\\beta c$ (where $c$ is the speed of light in vacuum), the beam length is now elongated by $\\approx(1+\\beta)\\gamma$ while the plasma contracts by $\\gamma$ (where $\\gamma=1/\\sqrt{1-\\beta^2}$ is the relativistic factor associated with the frame velocity). The number of time steps that is needed to simulate a ``longer'' beam through a ``shorter'' plasma is now reduced by up to $\\approx(1+\\beta) \\gamma^2$ (a detailed derivation of the speedup is given below).\n\nThe modeling of a plasma acceleration stage in a boosted frame\ninvolves the fully electromagnetic modeling of a plasma propagating at near the speed of light, for which Numerical Cerenkov\n\\cite{Borisjcp73,Habericnsp73} is a potential issue, as explained in more details below.\nIn addition, for a frame of reference moving in the direction of the accelerated beam (or equivalently the wake of the laser),\nwaves emitted by the plasma in the forward direction expand\nwhile the ones emitted in the backward direction contract, following the properties of the Lorentz transformation.\nIf one had to resolve both forward and backward propagating\nwaves emitted from the plasma, there would be no gain in selecting a frame different from the laboratory frame. However,\nthe physics of interest for a laser wakefield is the laser driving the wake, the wake, and the accelerated beam.\nBackscatter is weak in the short-pulse regime, and does not\ninteract as strongly with the beam as do the forward propagating waves\nwhich stay in phase for a long period. It is thus often assumed that the backward propagating waves\ncan be neglected in the modeling of plasma accelerator stages. The accuracy  of this assumption has been demonstrated by\ncomparison between explicit codes which include both forward and backward waves and envelope or quasistatic codes which neglect backward waves\n\\cite{Geddesjp08,Geddespac09,Cowanaac08}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Theoretical speedup dependency with the frame boost}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nThe derivation that is given here reproduces the one given in \\cite{Vaypop2011}, where the obtainable speedup is derived as an extension of the formula that was derived earlier\\cite{Vayprl07}, taking in addition into account the group velocity of the laser as it traverses the plasma.\n\nAssuming that the simulation box is a fixed number of plasma periods long, which implies the use (which is standard) of a moving window following\nthe wake and accelerated beam, the speedup is given by the ratio of the time taken by the laser pulse and the plasma to cross each other, divided by the shortest time scale of interest, that is the laser period. To first order, the wake velocity $v_w$ is set by the 1D group velocity of the laser driver, which in the linear (low intensity) limit, is given by \\cite{Esareyrmp09}:\n\n%\n\\begin{equation}\nv_w/c=\\beta_w=\\left(1-\\frac{\\omega_p^2}{\\omega^2}\\right)^{1/2}\n\\end{equation}\n%\nwhere $\\omega_p=\\sqrt{(n_e e^2)/(\\epsilon_0 m_e)}$ is the plasma frequency, $\\omega=2\\pi c/\\lambda$ is the laser frequency, $n_e$ is the plasma density, $\\lambda$ is the laser wavelength in vacuum, $\\epsilon_0$ is the permittivity of vacuum, $c$ is the speed of light in vacuum, and $e$ and $m_e$ are respectively the charge and mass of the electron.\n\nIn practice, the runs are typically stopped when the last electron beam macro-particle exits the plasma, and a measure of the total time of the simulation is then given by\n%\n\\begin{equation}\nT=\\frac{L+\\eta \\lambda_p}{v_w-v_p}\n\\end{equation}\n%\nwhere $\\lambda_p\\approx 2\\pi c/\\omega_p$ is the wake wavelength, $L$ is the plasma length, $v_w$ and $v_p=\\beta_p c$ are respectively the velocity of the wake and of the plasma relative to the frame of reference, and $\\eta$ is an adjustable parameter for taking into account the fraction of the wake which exited the plasma at the end of the simulation.\nFor a beam injected into the $n^{th}$ bucket, $\\eta$ would be set to $n-1/2$. If positrons were considered, they would be injected half a wake period ahead of the location of the electrons injection position for a given period, and one would have $\\eta=n-1$. The numerical cost $R_t$ scales as the ratio of the total time to the shortest timescale of interest, which is the inverse of the laser frequency, and is thus given by\n%\n\\begin{equation}\nR_t=\\frac{T c}{\\lambda}=\\frac{\\left(L+\\eta \\lambda_p\\right)}{\\left(\\beta_w-\\beta_p\\right) \\lambda}\n\\end{equation}\n%\nIn the laboratory, $v_p=0$ and the expression simplifies to\n%\n\\begin{equation}\nR_{lab}=\\frac{T c}{\\lambda}=\\frac{\\left(L+\\eta \\lambda_p\\right)}{\\beta_w \\lambda}\n\\end{equation}\n%\nIn a frame moving at $\\beta c$, the quantities become\n\\begin{eqnarray}\n\\lambda_p^*&=&\\lambda_p/\\left[\\gamma \\left(1-\\beta_w \\beta\\right)\\right] \\\\\nL^*&=&L/\\gamma \\\\\n\\lambda^*&=& \\gamma\\left(1+\\beta\\right) \\lambda\\\\\n\\beta_w^*&=&\\left(\\beta_w-\\beta\\right)/\\left(1-\\beta_w\\beta\\right) \\\\\nv_p^*&=&-\\beta c \\\\\nT^*&=&\\frac{L^*+\\eta \\lambda_p^*}{v_w^*-v_p^*} \\\\\nR_t^*&=&\\frac{T^* c}{\\lambda^*} = \\frac{\\left(L^*+\\eta \\lambda_p^*\\right)}{\\left(\\beta_w^*+\\beta\\right) \\lambda^*}\n\\end{eqnarray}\nwhere $\\gamma=1/\\sqrt{1-\\beta^2}$.\n\nThe expected speedup from performing the simulation in a boosted frame is given by the ratio of $R_{lab}$ and $R_t^*$\n\n\\begin{equation}\nS=\\frac{R_{lab}}{R_t^*}=\\frac{\\left(1+\\beta\\right)\\left(L+\\eta \\lambda_p\\right)}{\\left(1-\\beta\\beta_w\\right)L+\\eta \\lambda_p}\n\\label{Eq_scaling1d0}\n\\end{equation}\n\nWe note that assuming that $\\beta_w\\approx1$ (which is a valid approximation for most practical cases of interest) and that $\\gamma<<\\gamma_w$, this expression is consistent with the expression derived earlier \\cite{Vayprl07} for the laser-plasma acceleration case, which states that $R_t^*=\\alpha R_t/\\left(1+\\beta\\right)$ with $\\alpha=\\left(1-\\beta+l/L\\right)/\\left(1+l/L\\right)$, where $l$ is the laser length which is generally proportional to $\\eta \\lambda_p$, and $S=R_t/R_T^*$. However, higher values of $\\gamma$ are of interest for maximum speedup, as shown below.\n\nFor intense lasers ($a\\sim 1$) typically used for acceleration, the energy gain is limited by dephasing \\cite{Schroederprl2011}, which occurs over a scale length $L_d \\sim \\lambda_p^3/2\\lambda^2$.\nAcceleration is compromised beyond $L_d$ and in practice, the plasma length is proportional to the dephasing length, i.e. $L= \\xi L_d$. In most cases, $\\gamma_w^2>>1$, which allows the approximations $\\beta_w\\approx1-\\lambda^2/2\\lambda_p^2$, and $L=\\xi \\lambda_p^3/2\\lambda^2\\approx \\xi \\gamma_w^2 \\lambda_p/2>>\\eta \\lambda_p$, so that Eq.(\\ref{Eq_scaling1d0}) becomes\n%\n\\begin{equation}\nS=\\left(1+\\beta\\right)^2\\gamma^2\\frac{\\xi\\gamma_w^2}{\\xi\\gamma_w^2+\\left(1+\\beta\\right)\\gamma^2\\left(\\xi\\beta/2+2\\eta\\right)}\n\\label{Eq_scaling1d}\n\\end{equation}\n%\nFor low values of $\\gamma$, i.e. when $\\gamma<<\\gamma_w$, Eq.(\\ref{Eq_scaling1d}) reduces to\n%\n\\begin{equation}\nS_{\\gamma<<\\gamma_w}=\\left(1+\\beta\\right)^2\\gamma^2\n\\label{Eq_scaling1d_simpl2}\n\\end{equation}\n%\nConversely, if $\\gamma\\rightarrow\\infty$, Eq.(\\ref{Eq_scaling1d}) becomes\n%\n\\begin{equation}\nS_{\\gamma\\rightarrow\\infty}=\\frac{4}{1+4\\eta/\\xi}\\gamma_w^2\n\\label{Eq_scaling_gamma_inf}\n\\end{equation}\n%\nFinally, in the frame of the wake, i.e. when $\\gamma=\\gamma_w$, assuming that $\\beta_w\\approx1$, Eq.(\\ref{Eq_scaling1d}) gives\n%\n\\begin{equation}\nS_{\\gamma=\\gamma_w}\\approx\\frac{2}{1+2\\eta/\\xi}\\gamma_w^2\n\\label{Eq_scaling_gamma_wake}\n\\end{equation}\nSince $\\eta$ and $\\xi$ are of order unity, and the practical regimes of most interest satisfy $\\gamma_w^2>>1$, the speedup that is obtained by using the frame of the wake will be near the maximum obtainable value given by Eq.(\\ref{Eq_scaling_gamma_inf}).\n\nNote that without the use of a moving window, the relativistic effects that are at play in the time domain would also be at play in the spatial domain \\cite{Vayprl07}, and the $\\gamma^2$ scaling would transform to $\\gamma^4$. Hence, it is important to use a moving window even in simulations in a Lorentz boosted frame. For very high values of the boosted frame, the optimal velocity of the moving window may vanish (i.e. no moving window) or even reverse.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Numerical Stability and alternate formulation in a Galilean frame}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nThe numerical Cherenkov instability (NCI) \\cite{Godfreyjcp74}\nis the most serious numerical instability affecting multidimensional\nPIC simulations of relativistic particle beams and streaming plasmas\n\\cite{Martinscpc10,VayAAC2010,Vayjcp2011,Spitkovsky:Icnsp2011,GodfreyJCP2013,XuJCP2013}.\nIt arises from coupling between possibly numerically distorted electromagnetic modes and spurious\nbeam modes, the latter due to the mismatch between the Lagrangian\ntreatment of particles and the Eulerian treatment of fields \\cite{Godfreyjcp75}.\n\nIn recent papers the electromagnetic dispersion\nrelations for the numerical Cherenkov instability were derived and solved for both FDTD \\cite{GodfreyJCP2013,GodfreyJCP2014_FDTD}\nand PSATD \\cite{GodfreyJCP2014_PSATD,GodfreyIEEE2014} algorithms.\n\nSeveral solutions have been proposed to mitigate the NCI \\cite{GodfreyJCP2014,GodfreyIEEE2014,GodfreyJCP2014_PSATD,GodfreyCPC2015,YuCPC2015,YuCPC2015-Circ}. Although\nthese solutions efficiently reduce the numerical instability,\nthey typically introduce either strong smoothing of the currents and\nfields, or arbitrary numerical corrections, which are\ntuned specifically against the NCI and go beyond the\nnatural discretization of the underlying physical equation. Therefore,\nit is sometimes unclear to what extent these added corrections could impact the\nphysics at stake for a given resolution.\n\nFor instance, NCI-specific corrections include periodically smoothing\nthe electromagnetic field components \\cite{Martinscpc10},\nusing a special time step \\cite{VayAAC2010,Vayjcp2011} or\napplying a wide-band smoothing of the current components \\cite{VayAAC2010,Vayjcp2011,VayPOPL2011}. Another set of mitigation methods\ninvolve scaling the deposited\ncurrents by a carefully-designed wavenumber-dependent factor\n\\cite{GodfreyJCP2014_FDTD,GodfreyIEEE2014} or slightly modifying the\nratio of electric and magnetic fields ($E/B$) before gathering their\nvalue onto the macroparticles\n\\cite{GodfreyJCP2014_PSATD,GodfreyCPC2015}.\nYet another set of NCI-specific corrections\n\\cite{YuCPC2015,YuCPC2015-Circ} consists\nin combining a small timestep $\\Delta t$, a sharp low-pass spatial filter,\nand a spectral or high-order scheme that is tuned so as to\ncreate a small, artificial ``bump'' in the dispersion relation\n\\cite{YuCPC2015}. While most mitigation methods have only been applied\nto Cartesian geometry, this last\nset of methods (\\cite{YuCPC2015,YuCPC2015-Circ})\nhas the remarkable property that it can be applied\n\\cite{YuCPC2015-Circ} to both Cartesian geometry and\nquasi-cylindrical geometry (i.e. cylindrical geometry with\nazimuthal Fourier decomposition \\cite{LifschitzJCP2009,DavidsonJCP2015,Lehe2016}). However,\nthe use of a small timestep proportionally slows down the progress of\nthe simulation, and the artificial ``bump'' is again an arbitrary correction\nthat departs from the underlying physics.\n\nA new scheme was recently proposed, in \\cite{KirchenARXIV2016,LeheARXIV2016}, which\ncompletely eliminates the NCI for a plasma drifting at a uniform relativistic velocity\n-- with no arbitrary correction -- by simply integrating\nthe PIC equations in \\emph{Galilean coordinates} (also known as\n\\emph{comoving coordinates}). More precisely, in the new\nmethod, the Maxwell equations \\emph{in Galilean coordinates} are integrated\nanalytically, using only natural hypotheses, within the PSATD\nframework (Pseudo-Spectral-Analytical-Time-Domain \\cite{Habericnsp73,VayJCP2013}).\n\nThe idea of the proposed scheme is to perform a Galilean change of\ncoordinates, and to carry out the simulation in the new coordinates:\n\\begin{equation}\n\\label{eq:change-var}\n\\vec{x}' = \\vec{x} - \\vgal t\n\\end{equation}\nwhere $\\vec{x} = x\\,\\vec{u}_x + y\\,\\vec{u}_y + z\\,\\vec{u}_z$ and\n$\\vec{x}' = x'\\,\\vec{u}_x + y'\\,\\vec{u}_y + z'\\,\\vec{u}_z$ are the\nposition vectors in the standard and Galilean coordinates\nrespectively.\n\nWhen choosing $\\vgal= \\vec{v}_0$, where\n$\\vec{v}_0$ is the speed of the bulk of the relativistic\nplasma, the plasma does not move with respect to the grid in the Galilean\ncoordinates $\\vec{x}'$ -- or, equivalently, in the standard\ncoordinates $\\vec{x}$, the grid moves along with the plasma. The heuristic intuition behind this scheme\nis that these coordinates should prevent the discrepancy between the Lagrangian and\nEulerian point of view, which gives rise to the NCI \\cite{Godfreyjcp75}.\n\nAn important remark is that the Galilean change of\ncoordinates (\\ref{eq:change-var}) is a simple translation. Thus, when used in\nthe context of Lorentz-boosted simulations, it does\nof course preserve the relativistic dilatation of space and time which gives rise to the\ncharacteristic computational speedup of the boosted-frame technique.\n\nAnother important remark is that the Galilean scheme is \\emph{not}\nequivalent to a moving window (and in fact the Galilean scheme can be\nindependently \\emph{combined} with a moving window). Whereas in a\nmoving window, gridpoints are added and removed so as to effectively\ntranslate the boundaries, in the Galilean scheme the gridpoints\n\\emph{themselves} are not only translated but in this case, the physical equations\nare modified accordingly. Most importantly, the assumed time evolution of\nthe current $\\vec{J}$ within one timestep is different in a standard PSATD scheme with moving\nwindow and in a Galilean PSATD scheme \\cite{LeheARXIV2016}.\n\nIn the Galilean coordinates $\\vec{x}'$, the equations of particle\nmotion and the Maxwell equations take the form\n\\begin{subequations}\n\\begin{align}\n\\frac{d\\vec{x}'}{dt} &= \\frac{\\vec{p}}{\\gamma m} - \\vgal \\label{eq:motion1} \\\\\n\\frac{d\\vec{p}}{dt} &= q \\left( \\vec{E} +\n\\frac{\\vec{p}}{\\gamma m} \\times \\vec{B} \\right) \\label{eq:motion2}\\\\\n\\left( \\Dt{\\;} - \\vgal\\cdot\\nab\\right)\\vec{B} &= -\\nab\\times\\vec{E} \\label{eq:maxwell1}\\\\\n\\frac{1}{c^2}\\left( \\Dt{\\;} - \\vgal\\cdot\\nab\\right)\\vec{E} &= \\nab\\times\\vec{B} - \\mu_0\\vec{J} \\label{eq:maxwell2}\n\\end{align}\n\\end{subequations}\nwhere $\\nab$ denotes a spatial derivative with respect to the\nGalilean coordinates $\\vec{x}'$.\n\nIntegrating these equations from $t=n\\Delta\nt$ to $t=(n+1)\\Delta t$ results in the following update equations (see\n\\cite{LeheARXIV2016} for the details of the derivation):\n%\n\\begin{subequations}\n\\begin{align}\n\\fb^{n+1} &= \\theta^2 C \\fb^n\n -\\frac{\\theta^2 S}{ck}i\\vec{k}\\times \\fe^n \\nonumber \\\\\n& + \\;\\frac{\\theta \\chi_1}{\\epsilon_0c^2k^2}\\;i\\vec{k} \\times\n                     \\fj^{n+1/2} \\label{eq:disc-maxwell1}\\\\\n\\fe^{n+1} &=  \\theta^2 C  \\fe^n\n +\\frac{\\theta^2 S}{k} \\,c i\\vec{k}\\times \\fb^n \\nonumber \\\\\n& +\\frac{i\\nu \\theta \\chi_1 - \\theta^2S}{\\epsilon_0 ck} \\; \\fj^{n+1/2}\\nonumber \\\\\n& - \\frac{1}{\\epsilon_0k^2}\\left(\\; \\chi_2\\;\\mc{\\rho}^{n+1} -\n  \\theta^2\\chi_3\\;\\mc{\\rho}^{n} \\;\\right) i\\vec{k} \\label{eq:disc-maxwell2}\n\\end{align}\n\\end{subequations}\n%\nwhere we used the short-hand notations $\\fe^n \\equiv\n%\n\\fe(\\vec{k}, n\\Delta t)$, $\\fb^n \\equiv\n\\fb(\\vec{k}, n\\Delta t)$ as well as:\n\\begin{subequations}\n\\begin{align}\n&C = \\cos(ck\\Delta t) \\quad S = \\sin(ck\\Delta t) \\quad k\n= |\\vec{k}| \\label{eq:def-C-S}\\\\&\n\\nu = \\frac{\\vec{k}\\cdot\\vgal}{ck} \\quad \\theta =\n  e^{i\\vec{k}\\cdot\\vgal\\Delta t/2} \\quad \\theta^* =\n  e^{-i\\vec{k}\\cdot\\vgal\\Delta t/2} \\label{eq:def-nu-theta}\\\\&\n\\chi_1 =  \\frac{1}{1 -\\nu^2} \\left( \\theta^* -  C \\theta + i\n  \\nu \\theta S \\right) \\label{eq:def-chi1}\\\\&\n\\chi_2 = \\frac{\\chi_1 - \\theta(1-C)}{\\theta^*-\\theta} \\quad\n\\chi_3 = \\frac{\\chi_1-\\theta^*(1-C)}{\\theta^*-\\theta} \\label{eq:def-chi23}\n\\end{align}\n\\end{subequations}\nNote that, in the limit $\\vgal=\\vec{0}$,\n(\\ref{eq:disc-maxwell1}) and (\\ref{eq:disc-maxwell2}) reduce to the standard PSATD\nequations \\cite{Habericnsp73}, as expected.\nAs shown in \\cite{KirchenARXIV2016,LeheARXIV2016},\nthe elimination of the NCI with the new Galilean integration is verified empirically via PIC simulations of uniform drifting plasmas and laser-driven plasma acceleration stages, and confirmed by a theoretical analysis of the instability.\n", "meta": {"hexsha": "471863ac3ee50f8688634df4910aeff130a79eab", "size": 18843, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/source/latex_theory/Boosted_frame/Boosted_frame.tex", "max_stars_repo_name": "mrowan137/amrex", "max_stars_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 131, "max_stars_repo_stars_event_min_datetime": "2018-09-29T08:11:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T23:24:22.000Z", "max_issues_repo_path": "Docs/source/latex_theory/Boosted_frame/Boosted_frame.tex", "max_issues_repo_name": "mrowan137/amrex", "max_issues_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 1656, "max_issues_repo_issues_event_min_datetime": "2018-10-02T01:49:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:27:31.000Z", "max_forks_repo_path": "Docs/source/latex_theory/Boosted_frame/Boosted_frame.tex", "max_forks_repo_name": "mrowan137/amrex", "max_forks_repo_head_hexsha": "cafcb6bd5902fc72a4d6fa51b99fe837f5eb5381", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 100, "max_forks_repo_forks_event_min_datetime": "2018-10-01T20:41:14.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T10:30:42.000Z", "avg_line_length": 68.2717391304, "max_line_length": 1404, "alphanum_fraction": 0.7545507616, "num_tokens": 5277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6619228891883799, "lm_q1q2_score": 0.4334898111618063}}
{"text": "\\section{Preliminaries}\n\\label{sect:erssat-preliminaries}\n\nAn E-MAJSAT formula $\\Qf$ has the form $\\exists X,\\random{} Y.\\pf(X,Y)$,\nwhere $X$ and $Y$ are two disjoint sets of Boolean variables,\nand $\\pf(X,Y)$ is a CNF formula.\n\n\\subsection{Solving E-MAJSAT with weighted model counting}\nGiven an E-MAJSAT formula $\\Qf=\\exists X,\\random{} Y.\\pf(X,Y)$ and an assignment $\\as$ over $X$,\ncofactoring the matrix with $\\as$ results in a formula $\\pcf{\\pf}{\\as}$ referring only to variables in $Y$.\nThe prefix $\\random{} Y$ induces a weighting function $\\wt: Y \\mapsto [0,1]$ for each variable $y \\in Y$,\nwhere $\\wt(y)$ equals the probability annotated on the randomized quantifier of $y$.\nAs a result, the conditional satisfying probability $\\spb{\\random{} Y.\\pcf{\\pf}{\\as}}$,\nwhich equals the weight of the formula $\\pcf{\\pf}{\\as}$ under the weighting function $\\wt$,\ncan be obtained by invoking a weighted model counter.\nIn the following,\nthe invocation to a weighted model counter is expressed by $\\texttt{ComputeWeight}(\\random{} Y.\\pcf{\\pf}{\\as})$, which returns the conditional satisfying probability $\\spb{\\random{} Y.\\pcf{\\pf}{\\as}}$.\n\n\\subsection{Clause selection}\n\\label{sect:erssat-clause-select}\n\n\\textit{Clause selection}~\\cite{Janota2015,Rabe2015} is a novel technique for QBF solving.\nGiven a CNF formula $\\pf(X,Y)$ over are two disjoint variable sets $X$ and $Y$,\nwe divide each clause $C\\in\\pf$ into two sub-clauses $\\cx$ and $\\cy$,\nwhere $\\cx$ (resp. $\\cy$) consists of the literals whose variables are from $X$ (resp. $Y$).\nFor example, given a clause $C=(x_1 \\lor x_2 \\lor y_1 \\lor y_2)$,\nwe have $\\cx=(x_1 \\lor x_2)$ and $\\cy=(y_1 \\lor y_2)$.\nClearly, $C=\\cx\\lor\\cy$.\n\nA clause $C$ is said to be \\textit{selected} by an assignment $\\as$ over $X$ if $\\as$ falsifies every literal in $\\cx$;\n$C$ is said to be \\textit{deselected} if $\\as$ assigns some literal in $\\cx$ to $\\top$;\n$C$ is said to be \\textit{undecided} if it is neither selected nor deselected.\nWe also use $\\pcf{\\pf}{\\as}$ to denote the set of clauses selected by an assignment $\\as$ over $X$.\n\nA \\textit{selection variable} $\\sv{C}$ is introduced for each clause $C$ and defined by $\\sv{C}\\equiv\\lnot\\cx$.\nHence, $\\sv{C}$ is an indicator of the selection of clause $C$.\nThat is, $\\sv{C}=\\top$ (resp. $\\sv{C}=\\bot$) indicates $C$ is selected (resp. deselected).\nLet $S$ be the set of selection variables for clauses in $\\pf(X,Y)$.\nThe formula $\\select(X,S)=\\bigwedge\\limits_{C\\in\\pf}(\\sv{C}\\equiv\\lnot\\cx)$ is called a \\textit{selection relation} of $\\pf(X,Y)$.\n\n\\begin{example}\n    \\label{ex:erssat-select}\n    Consider a formula $\\pf(X,Y)$ over two variable sets $X=\\{e_1,e_2,e_3\\}$ and $Y=\\{r_1,r_2,r_3\\}$.\n    $\\pf(X,Y)$ consists of four clauses:\n    \\begin{itemize}\n        \\item[] $C_1: (e_1 \\lor r_1 \\lor r_2)$\n        \\item[] $C_2: (e_1 \\lor e_2 \\lor r_1 \\lor r_2 \\lor \\lnot r_3)$\n        \\item[] $C_3: (\\lnot e_2 \\lor \\lnot e_3 \\lor r_2 \\lor \\lnot r_3)$\n        \\item[] $C_4: (\\lnot e_1 \\lor e_3 \\lor r_3)$\n    \\end{itemize}\n    A set $S$ of selection variables $\\{\\sv{1},\\sv{2},\\sv{3},\\sv{4}\\}$ is introduced for each clause, respectively.\n    The selection relation $\\select(X,S)$ of $\\pf(X,Y)$ equals\n    \\begin{align*}\n        \\select(X,S)=\n        (\\sv{1} \\equiv \\lnot e_1) \\land\n        (\\sv{2} \\equiv \\lnot e_1 \\land \\lnot e_2) \\land\n        (\\sv{3} \\equiv e_2 \\land e_3) \\land\n        (\\sv{4} \\equiv e_1 \\land \\lnot e_3).\n    \\end{align*}\n    Consider a complete assignment $\\as_1=\\lnot e_1 \\lnot e_2 \\lnot e_3$ over $X$.\n    $C_1$ and $C_2$ are selected while $C_3$ and $C_4$ are deselected,\n    as can be seen from the selection relation cofactored with $\\as_1$,\n    which results in $\\pcf{\\select(X,S)}{\\as_1}=s_1s_2\\neg s_3 \\neg s_4$.\n    Consider a partial assignment $\\as_2=\\lnot e_1 e_3$ over $X$.\n    It selects $C_1$, deselects $C_4$, and leaves $C_2$ and $C_3$ undecided.\n    Notice that the two complete assignments $\\lnot e_1 \\lnot e_2 e_3$ and $\\lnot e_1 e_2 e_3$ consistent with $\\as_2$ select $\\{C_1, C_2\\}$ and $\\{C_1, C_3\\}$, respectively.\n    The clause $C_1$ selected by the partial assignment $\\as_2$ lies in the intersection of the sets of clauses selected by the two complete assignments consistent with $\\as_2$.\n\\end{example}", "meta": {"hexsha": "f1cedc957b35acc663b9365d3d431c973ad74bc6", "size": 4242, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/exist-random-ssat/preliminaries.tex", "max_stars_repo_name": "nianzelee/PhD-Dissertation", "max_stars_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-11T19:38:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T19:38:13.000Z", "max_issues_repo_path": "paper/exist-random-ssat/preliminaries.tex", "max_issues_repo_name": "nianzelee/PhD-Dissertation", "max_issues_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/exist-random-ssat/preliminaries.tex", "max_forks_repo_name": "nianzelee/PhD-Dissertation", "max_forks_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.3823529412, "max_line_length": 201, "alphanum_fraction": 0.6706742103, "num_tokens": 1453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.43348980688498373}}
{"text": "\n\\section{The \\findiii algorithm---using a logic function}\n\\Label{sec:findiii}\n\nIn this section we specify linear search yet another way.\nThis requires more preparing work but results in a more concise function contract.\n\n\\subsection{The logic function \\Find}\n\nWe start with a \\emph{recursive} definition of the \\acsl function \\Find.\nDue to the considerable number of associated lemmas of the function\n\\Find we split its definition into several listings.\nNote that \\Find comes as two \\emph{overloaded} functions.\nWhile the first version is defined for \\emph{array sections} the latter is intend\nfor \\emph{complete arrays}.\n\nThe listings start with lemmas which express elementary\nproperties directly related to an incremental increase of the array \\inl{a[0..n-1]}. \nThe latter lemmas are somewhat more higher-level and will\nbe useful for the verification of \\findiii.\nIt will be there that we also reuse the predicates \n\\logicref{SomeEqual}and\n\\logicref{NoneEqual}.\n%\nAt the end of this section we will also discuss in what sense the contracts\nof \\findii and \\findiii are equivalent.\n\n\\begin{logic}[hbt]\n\\begin{minipage}{0.99\\textwidth}\n\\lstinputlisting[linerange={1-60}, style=acsl-block, frame=single]{Source/Find.acsl}\n\\end{minipage}\n\\caption{\\Label{logic:Find-1}The logic function \\Find (1)}\n\\input{Listings/Find.acsl.labels.tex}\n\\input{Listings/Find.acsl.index.tex}\n\\end{logic}\n\n\\FloatBarrier\n\n\\begin{logic}[hbt]\n\\begin{minipage}{0.99\\textwidth}\n\\lstinputlisting[linerange={61-92}, style=acsl-block, frame=single]{Source/Find.acsl}\n\\end{minipage}\n\\caption{\\Label{logic:Find-2}The logic function \\Find (2)}\n\\end{logic}\n\n\\FloatBarrier\n\n\\subsection{Formal specification of \\findiii}\n\nUsing the logic function \\Find we can now give a third specification of linear search.\nThe contract of \\specref{findiii} is considerably shorter than that of \\specref{findii}.\nOf course, we had to put much more effort into the definition of the \\acsl\nfunction \\logicref{Find}.\n\n\\input{Listings/find3.h.tex}\n\n\\clearpage\n\n\\subsection{Implementation of \\findiii}\n\nThe following listing shows the implementation of \\implref{findiii}.\nIn order to achieve a complete verification we had to add the assertion \\inl{found}.\n\n\\input{Listings/find3.c.tex}\n\nA question that remains is in what sense the contract of \\specref{findii} is equivalent to\nthe one of \\specref{findiii}.\nWe will answer this question in the following section.\n\n\\subsection{The equivalence of \\findii and \\findiii}\n\\Label{sec:findiv}\n\\Label{sec:findv}\n\nWe consider the contracts of \\specref{findii} and \\specref{findiii} as \\emph{equivalent} \nif each one is sufficient to verify the other.\nTo this end we introduce yet another two examples \\findiv and \\findv.\n\nThe implementation of \\implref{findiv} consists just of a call to \\findiii.\n\n\\input{Listings/find4.c.tex}\n\n\\clearpage\n\nThe contract of \\specref{findiv}, however, is the same as the one of \\specref{findii}.\n\n\\input{Listings/find4.h.tex}\n\nAnalogously, the implementation of \\implref{findv} is simply a call to \\findii.\n\n\\input{Listings/find5.c.tex}\n\nOn the other hand, the contract of \\specref{findv} is the same as the one of \\specref{findiii}.\n%\nThe verification of the functions \\findiv and \\findv \n(cf.\\ Table~\\ref{tbl:result-nonmutating}) then shows the equivalence\nof the respective contracts of \\specref{findii} and \\specref{findiii}.\n\n\\input{Listings/find5.h.tex}\n\n\\clearpage\n\n", "meta": {"hexsha": "60b9bf1ab3c1610023a6186805c924f2cf2bb63a", "size": 3391, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/nonmutating/find3.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/nonmutating/find3.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/nonmutating/find3.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 33.2450980392, "max_line_length": 95, "alphanum_fraction": 0.7761722206, "num_tokens": 934, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.433489806794187}}
{"text": "\\pagebreak\n\\chapter{Transcranial Temporal Interference Stimulation (tTIS) Theory}\n\nTo better understand the physics behind the simulations, a brief explanation regarding the conduction within the media is presented in \\autoref{sec:e_ohmic_qs}, followed by an analysis regarding the \\gls{tTIS} hypothesis based on Grossman et al.\\cite{Grossman2017} work.\n\n\\section{Electric Field Ohmic Quasi-static Approximation}\n\\label{sec:e_ohmic_qs}\n\nGenerally Maxwell's equations for electromagnetic wave propagation in a medium are as follows:\n% Maxwells equations\n\\begin{center}\n\\begin{minipage}{.35\\linewidth}\n    \\begin{equation}\n        \\nabla\\cdot\\vec{E}=\\dfrac{\\rho}{\\epsilon}\n    \\end{equation}\n\\end{minipage}\n\\begin{minipage}{.35\\linewidth}\n    \\begin{equation}\n        \\nabla\\cdot\\vec{B} = 0\n    \\end{equation}\n\\end{minipage}\\break\n\\begin{minipage}{.35\\linewidth}\n    \\begin{equation}\n        \\label{eq:maxwell_curl_e}\n        \\nabla\\times\\vec{E}=-\\dfrac{\\partial\\vec{B}}{\\partial t}\n    \\end{equation}\n\\end{minipage}\n\\begin{minipage}{.35\\linewidth}\n    \\begin{equation}\n        \\nabla\\times\\vec{B} = \\mu\\Bigg(\\vec{J} + \\epsilon\\dfrac{\\partial\\vec{E}}{\\partial t}\\Bigg)\n    \\end{equation}\n\\end{minipage}\n\\end{center}\n\n\\noindent The problem in question, finding the electrical field distribution in a volume using low frequencies, can be approached by simplifying the general form of Maxwell's equations and deriving the Quasi-static approximation format. The first step is to define the assumptions taken in order for such an approach to be valid.\n\nFor the frequencies used in the studied problem, in \\si{kHz} range, the displacement current can be neglected making the Ohmic currents dominate. Also, since the magnetic field is not time variant, based on \\autoref{eq:maxwell_curl_e} we can write:\n\\begin{equation}\n    \\label{eq:curl_zero_e_field}\n    \\nabla\\times\\vec{E} = \\vec{0}\n\\end{equation}\nand as we know when a field is irrotational then it can be calculated from a scalar potential ($\\phi$) as seen below:\n\\begin{equation}\n    \\label{eq:e_field_from_potential}\n    \\boxed{\\vec{E} = -\\nabla\\phi}\n\\end{equation}\n\n\\noindent Moreover, since the sum of currents entering and exiting the volume is zero \\textit{(Kirchhoff's second law)} we can denote:\n\\begin{equation}\n    \\nabla\\cdot\\vec{J} = 0\n\\end{equation}\nwhere here $\\vec{J}$ is the ohmic current seen below as it is assumed that there are no current sources in the volume:\n\\begin{equation}\n    \\label{eq:sigma_e_0}\n    \\vec{J} = \\sigma\\vec{E}\\Rightarrow\\boxed{\\nabla\\cdot\\big(\\sigma\\vec{E}\\big) = 0}\n\\end{equation}\nwith $\\sigma$ being the electrical conductivity of each medium. Finally, based on \\cref{eq:e_field_from_potential,eq:sigma_e_0} the final relationship describing the problem can be derived:\n\\begin{equation}\n    \\label{eq:laplace_e}\n    \\boxed{\\nabla\\cdot(\\sigma\\nabla\\phi) = 0}\n\\end{equation}\n\n\\autoref{eq:laplace_e} describes the problem of conduction, using bulk conductors, but it is worth noting that the equation is only valid in the frequency domain where the displacement current effects are negligible and only when there is no charge generated \\textit{(charge is conserved)}. Furthermore, care shall be taken with the conductivity values, since depending on the material it may be dependant on the frequency used for the stimulation.\n\n\\pagebreak\n\\section{Temporal Interference}\nThe utilization of \\gls{tTIS} to achieve targeted \\gls{DBS} was first introduced by Grossman et al.\\cite{Grossman2017}. This technique takes advantage of the spatial electromagnetic wave interference, using frequencies at the \\si{kHz} range, having almost no effect on neurons since it is known that they do not respond to higher than 1\\si{kHz} \\draft{(citation needed)} frequencies.\n\\\\\\vspace{1pt}\n\n\\begin{wrapfigure}{r}{0.48\\textwidth}\n    \\vspace{-10pt}\n    \\centering\n    \\includegraphics[width = 0.44\\textwidth]{assets/images/brain_figure_ttis.pdf}\n    \\caption[Depiction of the \\gls{tTIS} pattern and the vector direction of the electric field. The purple area is the \\gls{ROI} where interference happens.]{Depiction of the \\gls{tTIS} pattern and the vector direction of the electric field. The purple area is the \\gls{ROI} where interference happens. Image by \\href{https://pixabay.com/users/openclipart-vectors-30363/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=150935}{OpenClipart-Vectors} from \\href{https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=150935}{Pixabay}}\n    \\label{fig:brain_elec_demo}\n\\end{wrapfigure}\n\nUsing two pairs of electrodes (\\autoref{fig:brain_elec_demo}), with each pair having a slightly different frequency, an interference pattern can be generated in the conducting medium oscillating at the difference of the two frequencies. Depending on the nature of the medium the pattern can vary and as illustrated in Grossman et al.\\cite{Grossman2017} when a uniform medium is used, it is simple and easy to calculate.\n\nSince the modulation happens in the 3D space, there will be different patterns in the $x$, $y$ and $z$ directions. According to Grossman et al.\\cite[page 20]{Grossman2017}, at any location $\\vec{r} = (x,y,z)$ the envelope amplitude of the \\gls{AM} of the electric field produced by the temporal interference, it is calculated as:\n\\begin{equation}\n    \\label{eq:directional_amplitude}\n    \\vec{E}(\\vec{n},\\vec{r}) = \\Big|\\big|(\\vec{E_1} + \\vec{E_2})\\cdot\\vec{n}\\big| - \\big|(\\vec{E_1} - \\vec{E_2})\\cdot\\vec{n}\\big|\\Big|\n\\end{equation}\nwhere $\\vec{E_1} = \\vec{E_1}(\\vec{r})$, $\\vec{E_2} = \\vec{E_2}(\\vec{r})$ are the electric fields coming from the two electrodes and $\\vec{n} = \\vec{n}(\\vec{r})$ is the unit vector at the direction of interest.\n\\\\\\vspace{1pt}\n\nWhat is of interest is the maximum amplitude of modulation at a specific location since the modulation will vary with time between zero and maximum. To calculate that amplitude across all directions, the analysis on Grossman et al.\\cite[page 20]{Grossman2017} can be better supported by the analysis done on Rampersad et al.\\cite[section 2.5]{Rampersad2019} and based on the two aforementioned publications, a complete description will be given here. The formula to calculate the maximum modulation amplitude, along all directions at a specific location, $\\vec{r} = (x,y,z)$, is:\n\\begin{equation}\n    \\label{eq:max_mod_amplitude}\n    \\vec{E}_{AM}^{max}(\\vec{r}) = \\begin{cases}\n        2\\big|\\vec{E_2}\\big| & \\text{if}\\; \\big|\\vec{E_2}\\big| < \\big|\\vec{E_1}\\big|\\cos\\alpha \\\\\n        &\\\\\n      2\\dfrac{\\Big|\\big|\\vec{E_2}\\big|\\times\\big(\\vec{E_1} - \\vec{E_2}\\big)\\Big|}{\\big|\\vec{E_1} - \\vec{E_2}\\big|} & \\text{otherwise}\n    \\end{cases}\n\\end{equation}\nwhere $\\alpha$ is the angle between $\\vec{E_1}$ and $\\vec{E_2}$, while \\autoref{eq:max_mod_amplitude} holds true only if $\\alpha < 90\\si{\\degree}$. Whenever $\\alpha \\geq 90\\si{\\degree}$, the sign of one of the two fields can be flipped \\textit{(it must be done is a consistent fashion)} since reaching peak field strength at different time points across different areas, is what makes the $< 90\\si{\\degree}$ rule to be violated. Such a change is possible considering that \\autoref{eq:max_mod_amplitude} calculates the maximum effect over one oscillation, so the overall effect is the one that we care. The calculation of $\\vec{E}_{AM}^{max}$ can be seen in \\autoref{alg:max_modulation_amplitude} at \\autoref{appndx:algorithms}.\n", "meta": {"hexsha": "a59b82da841fb4c3d0cff48877cdb095a483202d", "size": 7458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Sections/low_frequency_tacs_theory.tex", "max_stars_repo_name": "dimst23/BSc-Thesis", "max_stars_repo_head_hexsha": "9705f8af51d39ea333d84b2b4da35699de2d26d2", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Sections/low_frequency_tacs_theory.tex", "max_issues_repo_name": "dimst23/BSc-Thesis", "max_issues_repo_head_hexsha": "9705f8af51d39ea333d84b2b4da35699de2d26d2", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sections/low_frequency_tacs_theory.tex", "max_forks_repo_name": "dimst23/BSc-Thesis", "max_forks_repo_head_hexsha": "9705f8af51d39ea333d84b2b4da35699de2d26d2", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.1020408163, "max_line_length": 727, "alphanum_fraction": 0.7489943685, "num_tokens": 2150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.43348979369132906}}
{"text": "\\chapter{Method}\n\\label{chap:method}\n\nThe Serpent 2 Monte Carlo code uses a combination of  ray tracing and\ndelta-tracking to simulate the propagation of particles. The \\gls{wdt}\nmethod modifies delta-tracking for an absorbing medium, replacing virtual\ncollisions with a weight reduction. In this chapter, we will discuss\nthe \\gls{wdt} routine for absorption events, and extend the method to\ninclude scattering. We will then define the \\gls{wdt} threshold, a key\nparameter for its implementation in Serpent 2.\n\n\\section{\\Acrlong{wdt}}\n\\label{sec:wdt}\n\nMorgan and Kotlyar~\\cite{morgan2015} introduced a method to improve the\ninefficiencies of Woodcock delta-tracking in the presence of large\nabsorbers. The method, \\gls{wdt}, replaces the\nrejection sampling algorithm of delta-tracking with a weight reduction\nalgorithm. This process is similar to survival biasing, or implicit capture.\n\n\\subsection{Implicit Statistical Events}\n\\label{sec:implicit}\n\nWe consider a process that can result in multiple outcomes, each with\ntheir own probability. One approach is to sample a random variable and\ndetermine which outcome actually occurred. If the event occurs many\ntimes, we can instead replace the\nstatistical process by using the expected value of the random process\n\\cite{lux1991}. The expected value of a random variable $x$ that can\ntake values ${x_1 \\ldots x_n}$ with  probabilities ${p_1 \\ldots p_n}$, respectively,\nis given by:\n\\begin{equation}\n  \\label{eq:expval}\n  E[x] = x_1p_1 + x_2p_2 \\ldots + x_{n}p_n\\:.\n\\end{equation}\nFor example, imagine we have a bag with four coins, three worth \\$0.25 and\none worth \\$0.10. The values and their probabilities are:\n\\begin{align*}\n  x_1 = 0.25, \\quad p_1 = \\frac{3}{4} = 0.75 \\:;\\\\\n  x_2 = 0.10, \\quad p_2 = \\frac{1}{4} = 0.25\\:.\n\\end{align*}\nFor a given draw, we could sample a random value and use the\nprobabilities $p_1$ and $p_2$ to determine the coin drawn. Or, we can\ndescribe the expected value of the drawn coin:\n\\begin{align*}\n  E[x] &= x_1p_1 + x_2p_2 \\\\\n  &= (0.25 \\times 0.75) + (0.10 \\times 0.25) \\\\\n  &= 0.2125\n\\end{align*}\n\\begin{minipage}{1.0\\linewidth}\n  This value represents the average value of a coin drawn, if we\n  perform many draws. The following Matlab code replicates this\n  procedure:\n\\begin{lstlisting}\nv = 0;\nn = 1000;\nfor i = 1:n\n    xi = rand;  \n    v = v + (xi < 0.25)*0.1 + (xi >= 0.25)*0.25;\nend\n\\end{lstlisting}\n\\end{minipage}\n% will the campus get picky about the margins? Can you indent this?\n% Removed the line numbers, they were extraneous anyway -jsr\nAlthough the exact values will vary due to the small sample size, \\verb|v/n|\n$\\approx 0.2125$, as we expected.\n\nThis framework is often applied to neutron propagation in a process\ncalled ``survival biasing'' \\cite{lewis1993}. At each collision location, the type of\ninteraction is sampled and the appropriate action taken. In the case\nof a capture event, the neutron is ``killed'' (removed from the\nsimulation). While this accurately reflects the physical reality, it\ndoes not produce good statistics. Assuming we are using a collision\nestimator, the neutron's contribution to our simulation is the history\nof collisions. Each of these provide a score to that particular\ncollision, contributing to the overall simulation\nstatistics. Capture events that kill neutrons, therefore, are\nremoving the very particles we need to generate better statistics,\nresulting in the need for many more particles. Mitigating this issue\nis the goal of survival biasing.\n\nSurvival biasing avoids killing neutrons by replacing capture\nevents with an expected outcome. As described above, we do not need to\ntrack the outcome of every single event, but can rely on the expected\nvalue. This will give us, on average, the outcome of our many\nevents. To eliminate our explicit consideration of capture events,\nwe therefore have two possible event types: capture events, and\nscattering events. The probabilities $p$ will be given by the\nratios of the cross-sections:\n\\begin{align*}\n  p_{c} = \\frac{\\Sigma_{c}}{\\Sigma_t} \\:,\\\\\n  p_{s} = \\frac{\\Sigma_{s}}{\\Sigma_t}\\:,\n\\end{align*}\nwhere $\\Sigma_{c}$ and $\\Sigma_{s}$ are the macroscopic cross-sections\nfor capture and scattering, respectively.\n\nIn the coin example, each had a different monetary value, giving us an\nexpected value when we drew many times. We must introduce something\nsimilar for neutrons. It is convention to call this intrinsic value\n``weight'', which represents the importance of the neutron. All\nneutrons are born with the same weight, usually unity, and are killed\nwhen they have zero weight. At each point of interaction, the incoming\nneutron has an initial weight based on the neutron's history $w_i$,\nand a final weight $w_f$ that depends on the type of interaction. A\ncapture event that kills a neutron immediately forces the final weight\nof the neutron to zero $w_{f,c} = 0$. We can then\ncalculate the expected value of the interaction of a neutron with\ninitial weight $w_i$:\n% what is w_{f}? is it final and w_{i} is initial, wrt the specific interaction?\n% you can probably shorten scattering to s and capture to c\n\\begin{align*}\n  E[w_f] &= w_{f,s}p_\\mathrm{s} +\n           w_{f,c}p_\\mathrm{c} \\\\\n  &= w_{f,s}p_\\mathrm{s}\n\\end{align*}\nA scattering event merely changes the location of the neutron in\nenergy and angle phase space, leaving its importance\nunchanged. Therefore, $w_{f,s} = w_i$ and:\n\\begin{align*}\n  E[w_f] = w_ip_s\\:.\n\\end{align*}\nWith implicit capture\n% what is the now? with implicit capture? Yes -jsr\nevery collision is considered to be a non-capture event. The\nneutron continues with a lower weight, proportional to the probability\nthat the event was scattering. The weight lost in the collision is\nscored as capture:\n\\begin{align*}\n  S_c &= E[w_i - w_f] \\\\\n  &= E[w_i] - E[w_f] \\\\\n&= w_i - w_ip_{s} \\\\\n&= w_i(1-p_{s})\\:,\n\\end{align*}\nwhere $S_c$ is the score for capture. A similar method will be used\nby weighted delta-tracking.\n%S = socre? Yes -jsr\n\n\\subsection{Russian Rouletting}\n\\label{sec:rouletting}\n\nWhen the survival biasing routine described in Sec.~\\ref{sec:implicit}\nis used, the loss of neutrons is entirely reliant on leakage from the\nproblem or fission events. Neutrons will continue to undergo\ncollisions and subsequent weight reduction until they have a very low\nweight. These particles will only contribute small amounts to our\nstatistics, so tracking them is computationally inefficient.  To\nmitigate this, a lower cutoff for the weight is introduced. Once\nneutrons are below this weight, they have a chance of being killed by\na Russian Rouletting routine. \n\\begin{algorithm}\n\\caption{Rouletting Routine}\\label{alg:roulette}\n\\begin{algorithmic}[1]\n\\If{weight $<$ weight threshold}\n   \\State $\\xi \\gets $ random number $\\in [0,1)$\n   \\If{$\\xi < $ roulette probability}\n     \\State Kill particle\n   \\Else\n     \\State $w_f \\gets w_i$/(roulette probability) \\label{inc}\n   \\EndIf\n\\EndIf\n\\end{algorithmic}\n\\end{algorithm}\n\nThe general algorithm is shown in\nAlgorithm~\\ref{alg:roulette}. Following a collision, if the weight of the colliding particle is\nbelow a defined weight threshold, a random number is sampled. If this\nnumber is below a defined rouletting probability, the particle is\nkilled. If the particle survives rouletting, its weight is increased\nproportionaly to the rouletting probability. By either killing low weight\nparticles or increasing their weight, the inefficiency of tracking\nlow-weight particles can be reduced.\n\n\\subsection{\\Acrlong{wdt}}\n\\label{sec:wdttheory}\n\nMorgan and Kotlyar~\\cite{morgan2015} introduced a method to improve\nthe inefficiencies of Woodcock delta-tracking in the presence of large\nabsorbers. The method, \\gls{wdt}, replaces the rejection sampling of\ndelta-tracking with a weight reduction. This is similar to the process\nof implicit capture discussed in Section~\\ref{sec:implicit}.\n\nThe \\gls{wdt} method samples the particle path length in the same fashion as\nWoodcock delta-tracking. As described in Section~\\ref{sec:delta-tracking},\nafter each path length is sampled, the delta-tracking method accepts the\ncollision as real with the probability shown in\nEq.~\\ref{eq:preal}. The \\gls{wdt} method bypasses this rejection sampling by\naccepting all collisions as real with a subsequent reduction in\nweight. As discussed in Section~\\ref{sec:implicit}, replacing a\nstatistical event requires calculation of the expectated value. In\nthis case, the two events are a real collision and a virtual\ncollision:\n\\begin{equation}\n  \\label{eq:wdtexpected}\n  E[w_f] = w_{f,\\mathrm{real}}P_{\\mathrm{real}} + w_{f,\\mathrm{virt}}P_{\\mathrm{virt}}\\:.\n\\end{equation}\nMorgan and Kotlyar examine a 1D test case with absorption. As an\nabsorption event removes the particle, the resulting final weight of a\nreal collision is zero. A virtual collision is rejected, and therefore\nleaves the weight unchanged. Inserting the appropriate values into\nEq.~\\eqref{eq:wdtexpected} gives the expected value of the final\nweight for an absorption event:\n\\begin{align*}\n  \\label{eq:mkexpected}\n  E[w_f] &= w_{f,\\mathrm{real}}P_{\\mathrm{real}} +\n           w_{f,\\mathrm{virt}}P_{\\mathrm{virt}} \\\\\n  &= 0 + w_iP_{\\mathrm{virt}} \\\\\n  &= w_i(1-P_\\mathrm{real}) \\\\\n  &= w_i\\left(1-\\frac{\\Sigma_t}{\\Sigma_\\mathrm{maj}}\\right)\\:.\n\\end{align*}\nThe particle that is left following the collision continues propagating\nas if it underwent a virtual collision. In this case, the absorption\nis then scored using the expectation value of the score.\n\\begin{align*}\n  S_\\mathrm{absorption} &= E[w_i - w_f] \\\\\n  &= E[w_i] - E[w_f] \\\\\n  &= w_i\\left(\\frac{\\Sigma_t}{\\Sigma_\\mathrm{maj}}\\right)\n\\end{align*}\nThis algorithm is implemented by Kotlyar and Morgan in a 1D problem and the\nresults are verified with an analytical solution. The authors point\nout that a rouletting routine should be implemented when \\gls{wdt} is used,\nto prevent the tracking of low-weight neutrons.\n\n\\section{\\Acrlong{wdt} with scattering}\n\\label{sec:wdt_scattering}\n\n\nIn a scattering event, the weight of the incident particle does not\nchange. Therefore, application of the expectation value as in\nSection~\\ref{sec:wdttheory} results in an expected value of the final\nweight equal to the initial weight:\n\\begin{align*}\n  E[w_f] &= w_{f,\\mathrm{real}}P_{\\mathrm{real}} +\n           w_{f,\\mathrm{virt}}P_{\\mathrm{virt}} \\\\\n  &= w_iP_\\mathrm{real} + w_iP_{\\mathrm{virt}} \\\\\n  &= w_i(P_\\mathrm{real} + 1 -P_\\mathrm{real}) \\\\\n  &= w_i\\:.\n\\end{align*}\n\nThis doesn't model what we expect. We can view \\gls{wdt} as splitting\nthe weighted neutron into two particles. One carries the real portion\nof the weight and experiences the collision. The other carries the\nvirtual portion of the weight and continues propagating as if no\ncollision occurred. This works fine for absorption, where the portion\nthat experiences the collision does not propagate: it is immediately\nkilled and scored. But, when the neutron is split into a scattering\nportion and a virtual portion, no weight is lost because neither of\nthose events change the weight.\n\nTherefore, extension of this methodology to scattering requires duplication of\nthe particle at the point of collsion. The virtual portion of the\nweight is carried away by a particle that propagates as if no\ncollision has occured, and the real portion is carried away by a\nparticle that undergoes scattering. In problems with scattering, this\nresults in a rapid multiplication of neutrons. When implemented into\nSerpent 2, this multiplication very quickly filled any available\nneutron buffer in simulations of a \\gls{bwr}, ending\nthe simulation. We therefore expanded the \\gls{wdt} method with a\nnovel approach to handling scattering. This approach combines the\n\\gls{wdt} methodology with the standard delta-tracking rejection\nsampling in a way that has not been done before.\n\n% Add a sentence or two in here (or a quick additional paragraph) pointing out that this \n% is new: no one has done this before. It's good to explicitly call attention to your \n% contribution so that readers are clear what's new and what was your intellectual contribution.\n\n\\subsection{Scattering Rejection Sampling}\n\\label{sec:scattering}\n\nAs described in the last section, the \\gls{wdt} method may result in\nan intractable simulation when applied to scattering.\nThis occurred because the \\gls{wdt} method splits the incoming weight\nin two: one portion for a real collision, one portion for a virtual\ncollision. We developed a new methodology that avoids splitting the\nneutron when scattering, while keeping the splitting otherwise. To\naccomplish this, the original delta-tracking rejection sampling was\nmoved into the scattering subroutine. The algorithm is shown in\nAlg.~\\ref{alg:scattalg} and a flow chart of the routine is shown in\nFig.~\\ref{fig:wdt}.\n\n\\begin{figure}[p]\n\\begin{algorithm}[H]\n\\caption{\\Acrlong{wdt} with scattering}\\label{alg:scattalg}\n\\begin{algorithmic}[1]\n  \\State \\textbf{Sample} path length\n  \\State \\textbf{Sample} collision type\n  \\If{collision type == (capture or fission)}\n    \\State \\textbf{Score} capture or fission $\\gets\n    w_iP_\\mathrm{real}$\n    \\State \\textbf{Score} collision  $\\gets w_iP_\\mathrm{real}$\n    \\State $w_f \\gets w_i(1-P_\\mathrm{real})$\n    \\State \\textbf{Execute} virtual collision\n  \\Else\n    \\State \\textbf{Sample} random number $\\xi \\in [0,1)$\n    \\If{$\\xi < P_\\mathrm{real}$} \\Comment{Collision is real}\n    \\State \\textbf{Score} scattering $\\gets w_i$\n    \\State \\textbf{Score} collision $\\gets w_i$\n      \\State \\textbf{Execute} scattering collision\n    \\Else \\Comment{Collision is virtual}\n    \\State \\textbf{Execute} virtual collision\n    \\EndIf\n  \\EndIf\n\\end{algorithmic}\n\\end{algorithm}\n  \\centering\n  \\includegraphics[scale=0.5]{images/wdt}\n  \\caption{\\Acrlong{wdt} with scattering rejection sampling.\\label{fig:wdt}}\n\\end{figure}\nNote that there are two separate scoring events in each collision\nsubroutine: scoring of the actual collision type for calculating\nspecific reaction rates, and scoring of collision itself used by the\ncollision flux estimator. In addition, scoring the fission reaction\nalso encompasses generation of fission neutrons.\n\nIn the original delta-tracking routine, the rejection sampling takes\nplace prior to collision type sampling, and collision scoring can\noccur between the two. This is the routine that Serpent 2 used, prior\nto modification for the above scheme. By moving the rejection sampling\nafter the collision type sampling, the collision score is no longer\nagnostic to the type of collision that will occur. Therefore, in the\nimplementation of this routine in Serpent 2, the collision scoring was\nmoved after the collision type sampling.\n\n\\section{Implementation in Serpent 2}\n\\label{sec:method_implementation}\n\nThe \\gls{wdt} algorithm is implemented to work alongside the current\nimplementation of ray tracing and delta-tracking, as described in\nSec.~\\ref{sec:serpent2}. \\gls{wdt} is designed to improve the\neffectiveness of delta-tracking when the change of a virtual collision\nis high. We can hypothesize that the algorithm will benefit in the\nregime where $P_{\\mathrm{real}}$ is low. At high values of\n$P_{\\mathrm{real}}$, a majority of the weight of the incoming particle\nis scored. This leaves the particle that undergoes a virtual collision\nwith a very low weight, relying on the rouletting routine to prevent\ncomputational inefficiency. These two situations imply that\nthere is a region between low and high values of $P_\\mathrm{real}$\nwhere \\gls{wdt} may provide benefit.\n\nThis region is defined by two values, summarized in\nFig.~\\ref{fig:ray_wdt}. On the lower end, the value of $(1-c)$ defines\nthe threshold below which surface tracking is used. On the upper end,\na new parameter $t_{\\mathrm{wdt}}$ defines the threshold below which\n\\gls{wdt} will be used instead of normal delta-tracking. This provides\nthe user with the ability to exactly define the region where \\gls{wdt}\nwill be used.\n\\begin{figure}[hbtp]\n  \\centering\n  \\begin{align*}\n    \\mathrm{Mode} =\n    \\begin{cases}\n      \\mathrm{Ray tracing}, & P_\\mathrm{real} < 1-c \\\\\n      \\mathrm{\\gls{wdt}}, & 1-c \\leq P_\\mathrm{real} < t_{\\mathrm{wdt}}\n      \\\\\n      \\mathrm{Delta-tracking}, & P_\\mathrm{real} \\geq t_{\\mathrm{wdt}}\n    \\end{cases}\n  \\end{align*}\n  \\begin{tikzpicture}[scale=1.5]\n    \\draw[thick] (0,0) -- (10.0,0);\n    \\foreach \\x in {0,1,...,10}\n    {\n      \\draw (\\x, 0.1) -- (\\x, -0.1);\n      \\pgfmathsetmacro\\result{\\x * 0.1}\n      \\node [below] at (\\x, -0.2) {\\small $\\pgfmathprintnumber{\\result}$};\n    }\n    \\node [left] at (0,0) {$P_{\\mathrm{real}}$};\n    \\draw[ thick, <->] (0,0.2) -- (1,0.2);\n    \\draw[ thick, <->] (1,0.2) -- (4,0.2);\n    \\draw[ thick, <->] (4,0.2) -- (10,0.2);\n    \\node [above] at (0.5, 0.2) {Ray tracing};\n    \\node [above] at (2.5, 0.2) {WDT};\n    \\node [above] at (7, 0.2) {Delta-tracking};\n  \\end{tikzpicture}\n  \\caption[Implemented selection scheme for ray-tracing, weighted and normal\n    delta-tracking.]{Implemented selection scheme for ray-tracing, weighted, and normal\n    delta-tracking. Shown using the values of $(1-c)=0.1$ and $t_{\\mathrm{wdt}}=0.4$.}\n  \\label{fig:ray_wdt}\n\\end{figure}\n% this makes sense; I still think you can get rid of the previous figure.\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../masters_report\"\n%%% End:\n", "meta": {"hexsha": "acd249ded935c9bc782d26916111acd6be502515", "size": 17260, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/method.tex", "max_stars_repo_name": "jsrehak/jsr_masters", "max_stars_repo_head_hexsha": "1e7861f4ee2016c770847da496c525e0cc5cf17c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/method.tex", "max_issues_repo_name": "jsrehak/jsr_masters", "max_issues_repo_head_hexsha": "1e7861f4ee2016c770847da496c525e0cc5cf17c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/method.tex", "max_forks_repo_name": "jsrehak/jsr_masters", "max_forks_repo_head_hexsha": "1e7861f4ee2016c770847da496c525e0cc5cf17c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8311688312, "max_line_length": 96, "alphanum_fraction": 0.7492468134, "num_tokens": 4722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4334897891421165}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{graphicx}\n\\usepackage[letterpaper, total={7.5in, 9in}]{geometry}\n\n\\title{Stochastic Processes}\n\\author{Grant Smith }\n\\date{Spring 2022}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Primer on Random Variables and Conditional Random Variables}\n\nIn this section, I want to give two views on conditional probabilities and show how they coincide. The first view is very early in a probability textbook:\n\n$$P(A|B) = \\frac{P(A \\cap  B)}{P(B)}$$\n\nAlso please note that it might appear that $P(A|B)$ is proportional to $P(A)$ perhaps by a proportionality factor such as $1/P(B)$, but that is not true because $P(A)$ is not proportional to $P(A \\cap  B)$.  They are truly different distrubutions.  Thus, $P(A|B)$ is totally different from $P(A)$, because $P(A \\cap  B)$ is totally different from $P(A)$, which is the crutial insight.  The only situation in which they would be similar would be if $A$ and $B$ are independent, at which point the scaling intuition would be true. \n\nNext, I want to explain how if two random variables ($X_1$ and $X_2$) are defined on the same event space, observing one random variable, say $X_1$, filters your event space into a smaller event space, and now there is a new random variable that is $X_2$ restricted to that smaller event space. Let's call the value we observe $x_1$.  The new, restricted, event space is $X_1^{-1}(x_1)$, which means it is the inverse image of $x_1$ under the random variable (aka function) $X_1$.  Our notation for this is $X_2 | X_1 = x_1$. Also note that the probability measure defined on the original event space is now modified to a new measure which depends on the observed value of $X_1$.  This measure (of course) adds up to 1, and those elements in the event space previously added up to less than or equal to 1, so in general they get bigger, but the probability of each element does not necessarily increase.  Also, they are not scaled linearly or anything like that -- we do not know how they change until we know the two random variables.\n\n\\section{Stochastic Process Introduction}\n\nI want to develop a little intuition between how we think about stochastic processes, for example, the stock market, and how they're defined in a probability book.  First of all, here is a picture:\n\n\\includegraphics[width=4in]{stochastic_ image.png}\n\\centering\n\nWe have a sample space, $\\Omega$, and from that sample space, we map to functions of time (or anything else you want).  We call it a stochastic process, but all it is is a function from a sample space to a space of functions.  The notation is $X_t$, but what's under the hood is the following:\n\n$$X_t = x : \\Omega \\rightarrow \\left(\\mathbb{R}^+ \\rightarrow  \\mathbb{R} \\right)$$ \n\nBut we don't really perceive that sample space.  What we perceive (for example when observing the stock market) is that we've observed a process up to a certain time, and we don't know what's going to happen next.  How does that fit into the framework above? Let's start with a picture of a stochastic process.  Here it is, and ignore the 3.5 for now. We'll use it in about two paragraphs.\n\n\\includegraphics[width=4in]{filtration_part_1.png}\n\\centering\n\nLet's say this is a stock price over time, and we'll call it $X_t$.  The picture on the right is all the possible trajectories, and the sample space on the left has a corresponding event for each trajectory (I didn't count, so the dots and the trajectories probably don't align, but that's okay).\n\nAt our initial time, we have no idea which of these trajectories the stock will take.  But then let's wait a little bit (wait until time 3.5) and observe the price.  Let's say the trajectory we observe is the following:\n\n\\includegraphics[width=2.2in]{filtration_part_2.png}\n\\centering\n\nSo now we have information about which of the original trajectories are still possible, and which ones are impossible. This is called a filtration, and in our case, we have the filtration at time 3.5, so we will call it$\\mathcal{F}_{3.5}$, but in general, it would be $\\mathcal{F}_{t}$.\n\nSo now we want to figure out what happens to our stochastic process $X_t$ given the information (aka filtration) we know at time 3.5. What the filtration does is filter out all the trajectories that cannot be the case, and it leaves in all the remaining possible trajectories.  The picture is:\n\n\\includegraphics[width=4in]{filtration_part_3.png}\n\\centering\n\nYou'll notice that the trajectories that don't align with our filtration are gray, and the events in the sample space that correspond to those trajectories are also gray.  And the trajectories that are possible are still black, and their corresponding events are also still black.\n\nThis should feel like a conditional probability, and that's exactly what's happening. We want $Y_t := X_t | \\mathcal{F}_{3.5}$.  Thus, $Y_t$ is given by the following drawing:\n\n\\includegraphics[width=4in]{filtration_part_4.png}\n\\centering\n\nAt this point, we've really explained a lot.  One last part you might be wondering is what would happen if we changed the 3.5.  And you'd be right. So our $Y_t$ is dependent upon our observation duration. So I'll ammend our notation to be $X_t(s) := X_t | \\mathcal{F}_{s}$, which means that the stochastic process we get (a.k.a. remaining trajectories) depends on how long we observe.  So we could say that $Y_t = X_t(3.5)$.  So let's draw another picture for another time, say 4.5. We will start with what we've observed by time = 4.5:\n\n\\includegraphics[width=2.2in]{filtration_4.5.png}\n\\centering\n\nAnd now we can gray out from the picture of $X_t(3.5)$:\n\n\\includegraphics[width=3.2in]{Filtration_grayed_4.5.png}\n\\centering\n\nAnd it is hard to see, but one of the elements in the sample space is also grayed out. Which leaves us with our final image of $X_t(4.5)$:\n\n\\includegraphics[width=3.2in]{final_4.5.png}\n\\centering\n\nAnd this time, it's very clear that I miscounted, and there should only be four elements in the sample space corresponding to the four possible trajectories.\n\nGrant, a note to you, you wanted to write about what $X_t(s)$ looks like???\n\nLastly, I'm working on making a GeoGebra activity to illustrate this. When it's up, I'll update the link, but here is my account for now: https://www.geogebra.org/u/gsmithapples.\n\n\\section{Differentiation and Integration}\nHere is the best way I know to think about stochastic differentiation and integration. We'll redraw our picture, and its equation and notation are given below.\n\n\\includegraphics[width=4in]{stochastic_ image.png}\n\\centering\n\n$$X_t = x : \\Omega \\rightarrow \\left(\\mathbb{R}^+ \\rightarrow  \\mathbb{R} \\right)$$ \n$$x(\\varsigma_1) = f_1(t)$$\n$$x(\\varsigma_2) = f_2(t)$$\n$$x(\\varsigma) = f_\\varsigma(t)$$\n\nAnd note that $x$ is simply a deterministic function.  Also note that we can partially apply and curry however we want, so we also have the following, which will be useful in the following section:\n\n$$X_t = x : \\Omega \\rightarrow \\left(\\mathbb{R}^+ \\rightarrow  \\mathbb{R} \\right) = \\Omega \\rightarrow \\mathbb{R}^+ \\rightarrow  \\mathbb{R} = x :  \\left(\\Omega  , \\mathbb{R}^+\\right)\\rightarrow  \\mathbb{R}$$ \n\n\\subsection{Differentiation}\nWe have that:\n\n$$X_t' = \\frac{\\partial}{\\partial t}x(\\varsigma,t)= \\frac{x\\left(\\varsigma, t + h\\right) - x\\left(\\varsigma, t\\right)}{h} = \\frac{f_\\varsigma\\left(t + h\\right) - f_\\varsigma\\left(t\\right)}{h} = \\frac{df_\\varsigma}{dt} =g\\left(\\varsigma, t\\right)$$\n\nWhich means that $X_t'$ is just the probability weighted derivatives of the trajectories. Which, just like $x$, is just a deterministiic function of $\\varsigma$ and $t$\n\nSide note that this does not work in Brownian Motion because the individual trajectories in Brownian Motion are not differentiable (anywhere).  I think we might be able to do it with some form of a weak derivative, though, just not the regular one.\n\nAlso note that we are using the prime notation for a derivative, but it is a partial derivative. That's okay because $\\Omega$ isn't necessarily a continuous variable like $t$ is, so when we're differentiating, it is understood that we're differentiating with respect to the only reasonable option, $t$.\n\n\\subsection{Integration}\nWe have that:\n$$\\int X_t= \\int_{s = 0}^{s = t} X_s ds = \\int_{s = 0}^{s = t} x\\left(\\varsigma,s\\right) ds = \\int_{s = 0}^{s = t} f_\\varsigma\\left(s\\right) ds  = h\\left(\\varsigma,t\\right)$$\n\nWhich means that $\\int X_t$ is just the probability weighted integrals of the trajectories.  Which, just like $x$ and $g$, is just a deterministic function of $\\varsigma$ and $t$\n\nI think we can do this with Brownian Motion because even though Brownian Motion trajectories are not (in the normal sense) differentiable, they are integrable.\n\n\\subsection{Differentiation and Integration Example}\nSuppose there are only two states of the world, Heads and Tails.  And if Heads is flipped, our world is $x^2 + 2$ and if Tails is flipped, we get $1$.  Our process is:\n\n\\includegraphics[width=3in]{ExampleProcess.png}\n\\centering\n\n\\[X_t = \\begin{cases} \n    t^2 + 2 & H \\\\\n    1 & T \n \\end{cases}\n\\]\n\nThen we also know:\n\n\\[\\int X_t = \\begin{cases} \n    \\frac{1}{3}t^3 + 2t + C_1 & H \\\\\n    t + C_2 & T \n \\end{cases}\n\\]\n\\[X_t = \\begin{cases} \n    t^2 + 2 & H \\\\\n    1 & T \n \\end{cases}\n\\]\n\\[X'_t = \\begin{cases} \n    2t & H \\\\\n    0 & T \n \\end{cases}\n\\]\n\nAnd those integration constants are deterministic (i.e. they are just numbers).\n\n\\section{Ito Processes}\n\n\\subsection{Intro}\n\nIf you have a stochastic process that can be written \\textbf{\\emph{as a function of}} Ito processes, a.k.a. it can be written \\textbf{\\emph{in terms of}} Ito processes, then you can write it \\textbf{\\emph{as}} an Ito Process. And that's what Ito's formula tells us how to do.  This is the equation of an Ito process:\n\n$$Z_t = Z_0 + \\int_{0}^{t} u_s ds + \\int_{0}^{t} \\sigma_s dW_t$$\n\nSo if we have a stochastic process given to us in terms of an Ito process like above, then we can write it as above. Mathematically, that means we have a process $Z_t = f(t,X_t)$ where $X_t$ is an Ito process, and we will show that this new stochastic process is itself an Ito process, and we will be able to explicitly state its formula.  This is done with Ito's formula:\n\n$$Z_t = f(t,X_t) = a + \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) + \\mu_s \\frac{\\partial f}{\\partial x}(s,X_s) + \\frac{1}{2}{\\sigma _s}^2\\frac{\\partial^2 f}{{\\partial x}^2}(s,X_s)  ds + \\int_{s=0}^{s=t}\\sigma_s\\frac{\\partial f}{\\partial x}(s,X_s) dW_s   $$\n\nWhich, you will notice, is in the form of an Ito process, which is the goal.  It helps us transform an arbitrary process written in terms of an Ito process ($Z_t$ or $f(t,X_t)$) into an explicitly stated Ito process.\n\n\\subsection{Derivation}\n\nLet's try to approximate $f$ with a Taylor Series.  The statement is the following (and accompanied with the same thing with explicit dependencies):\n\n$$\\Delta f = \\frac{df}{dt} * \\Delta t$$\n$$\\Delta f(t, \\Delta t) = \\frac{df}{dt}(t) * \\Delta t$$\n\nWhere $\\Delta f$ is the name of a function, and it now depends on two things: $x$ and $\\Delta t$.  What about an approximation with a second order term?  In one dimension, we could have:\n\n$$\\Delta f = \\frac{df}{dt} * \\Delta t + \\frac{1}{2} \\frac{d^2f}{dt^2} \\Delta t ^2$$\n\nAnd in two dimensions, we would have: \n\n$$\\Delta f = \\frac{\\partial f}{\\partial t} \\Delta t + \\frac{\\partial f}{\\partial x} \\Delta x + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2} {\\Delta t}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2} {\\Delta x}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x} \\Delta t\\Delta x$$\n\nAnd with dependencies stated explicitly:\n\n$$\\Delta f(t,x,\\Delta t,\\Delta x) = \\frac{\\partial f}{\\partial t}(t,x) \\Delta t + \\frac{\\partial f}{\\partial x}(t,x) \\Delta x  + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t,x) {\\Delta t}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t,x) {\\Delta x}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t,x) \\Delta t\\Delta x$$\n\nOr if we wanted to write it a little differently, instead of using $\\Delta$ notation on $t, x$, we could write them at times 1 and 2:\n\n$$\\Delta f(t_1,t_2,x_1,x_2) = \\frac{\\partial f}{\\partial t}(t_1,x_1) *[t_2-x_1] + \\frac{\\partial f}{\\partial x}(t_1,x_1) *[x_2-x_1]  + ... $$\n\n$$... +  \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t_1,x_1) * {[t_2-t_1]}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial x}^2}(t_1,x_1) * {[x_2-x_1]}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t_1,x_1) *[t_2-t_1]*[x_2-x_1]$$\n\nWhat is the benefit of this different notation instead of the deltas? The benefit is that now it's obvious that when you replace the $t$s or $x$s, you replace the first and second, i.e. you replace the value and the $d$, rather than just the value. \n\nNow I'm just going to plug in the stochastic $X_t$ for $x$\n\n$$\\Delta f(t_1,t_2,X_1,X_2) = \\frac{\\partial f}{\\partial t}(t_1,X_1) *[t_2-t_1] + \\frac{\\partial f}{\\partial x}(t_1,X_1) *[X_2-X_1]  + ... $$\n\n$$... +  \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t_1,X_1) * {[t_2-t_1]}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial x}^2}(t_1,X_1) * {[X_2-X_1]}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t_1,X_1) *[t_2-t_1]*[X_2-X_1]$$\n\nHere we notice that $X_t$ is also a function of t. So our Taylor series and chain rule can be a little different.  In particular, if we let $\\Delta t$ go very small, there might be some behavior in $X_t$ that could help us. What if $f$ is a function of $t$ and $x$, but $X_t$ is also a function of $t$? I think that's what's going on in our problem.  So we have:\n\n$$\\Delta f(t_1,t_2,X_{t_1},X_{t_2}) = \\frac{\\partial f}{\\partial t}(t_1,X_{t_1}) *[t_2-t_1] + \\frac{\\partial f}{\\partial x}(t_1,X_{t_1}) *[X_{t_2}-X_{t_1}]  + ... $$\n\n$$... +  \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t_1,X_{t_1}) * {[t_2-t_1]}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial x}^2}(t_1,X_{t_1}) * {[X_{t_2}-X_{t_1}]}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t_1,X_{t_1}) *[t_2-t_1]*[X_{t_2}-X_{t_1}]$$\n\nBut now if we know $X_t$, this is a function of only $t_1$ and $t_2$.  And then we can say $t_2 = t_1 + h$. We can also start calling $t_1$ just $t$\n\n$$\\Delta f(t,h) = \\frac{\\partial f}{\\partial t}(t,X_{t}) *h + \\frac{\\partial f}{\\partial x}(t,X_{t}) *[X_{t+h}-X_{t}]  + ... $$\n\n$$... +  \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t,X_{t}) * {h}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial x}^2}(t,X_{t}) * {[X_{t+h}-X_{t}]}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t,X_{t}) *h*[X_{t+h}-X_{t}]$$\n\nNow we use the fact that $X_t$ is an Ito Process given by:\n\n$$X_t = a + \\int_{s=0}^{s=t} \\mu_sds + \\int_{s=0}^{s=t} \\sigma_sdW_s$$\n\nAnd finding the difference between times $t$ and $t+h$:\n\n$$X_{t+h} - X_t = a + \\int_{s=0}^{s=t+h} \\mu_sds + \\int_{s=0}^{s=t+h} \\sigma_sdW_s - \\left(a + \\int_{s=0}^{s=t} \\mu_sds + \\int_{s=0}^{s=t} \\sigma_sdW_s\\right) = $$\n\n$$ =  X_{t+h} - X_t = \\int_{s=0}^{s=t+h} \\mu_sds - \\int_{s=0}^{s=t} \\mu_sds+ \\int_{s=0}^{s=t+h} \\sigma_sdW_s - \\int_{s=0}^{s=t} \\sigma_sdW_s$$\n\nWe now make a temporary notation switch so our work in a few steps will be cleaner, and we will substitute it in:\n\n$$P_t := \\int_{s=0}^{s=t} \\mu_sds$$\n$$Q_t := \\int_{s=0}^{s=t} \\sigma_sdW_s$$\n$$  X_{t+h} - X_t = P_{t+h} -P_t+ Q_{t+h} - Q_t$$\n\nNow plug this in for the step above the Ito Process. \n\n$$\\Delta f(t,h) = \\frac{\\partial f}{\\partial t}(t,X_{t}) *h + \\frac{\\partial f}{\\partial x}(t,X_{t}) *[P_{t+h} -P_t+ Q_{t+h} - Q_t]  + ... $$\n\n$$... +  \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial t}^2}(t,X_{t}) * {h}^2 + \\frac{1}{2}\\frac{\\partial^2 f}{{\\partial x}^2}(t,X_{t}) * {[P_{t+h} -P_t+ Q_{t+h} - Q_t]}^2 +  \\frac{\\partial^2 f}{\\partial t \\partial x}(t,X_{t}) *h*[P_{t+h} -P_t+ Q_{t+h} - Q_t]$$\n\nAt this point, we are ready (in a pretty mathematically justifiable way) to do an integration. We'll start at $t=0$ and go up to an arbitrary $t$.  And during this process, we'll add up very small $\\Delta f$ values until we get the actual change from $t=0$ to $t$, which will just give us the value at $t$ (assuming we know the value at $t=0$, which we'll assume we do).  It is not obvious yet, but if we can do that, we'll be a lot closer to having our function of $t$ that we want, $Z_t$. \n\nSo let's say we have $n$ partitions of our interval $[0,t]$, and we add up $n$ versions of $\\Delta f$ values.  Then our $t$ and $h$ would be:\n\n$$t = \\frac{it}{n}, h = \\frac{t}{n}$$\n\nAnd we could sum the equation and reorder the last two terms:\n\n$$Z_t^n = \\sum_{i=1}^{i = n} \\Delta f\\left(ih,h\\right) = \\sum_{i=1}^{i = n} \\frac{\\partial f}{\\partial t}(ih,X_{ih}) *h + \\sum_{i=1}^{i = n}\\frac{\\partial f}{\\partial x}(ih,X_{ih}) *[\\Delta P_t+ \\Delta Q_t] +  \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial t}^2}(ih,X_{ih}) * {h}^2 + ... $$\n\n\n$$...   + \\sum_{i=1}^{i = n} \\frac{\\partial^2 f}{\\partial t \\partial x}(ih,X_{ih}) *h*[\\Delta P_t+ \\Delta Q_t] + \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}) * {[\\Delta P_t+ \\Delta Q_t]}^2$$\n\nand simplifying and collecting terms:\n\n\n$$Z_t^n = \\sum_{i=1}^{i = n} \\Delta f\\left(ih,h\\right) = \\sum_{i=1}^{i = n} \\frac{\\partial f}{\\partial t}(ih,X_{ih}) *h + \\sum_{i=1}^{i = n}\\frac{\\partial f}{\\partial x}(ih,X_{ih}) *[\\Delta P_t] + \\sum_{i=1}^{i = n}\\frac{\\partial f}{\\partial x}(ih,X_{ih}) *[\\Delta Q_t] +  $$\n\n\n$$ \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial t}^2}(ih,X_{ih}) * {h}^2 + \\sum_{i=1}^{i = n} \\frac{\\partial^2 f}{\\partial t \\partial x}(ih,X_{ih}) *h*[\\Delta P_t] + ... $$\n\n\n\n$$...   + \\sum_{i=1}^{i = n} \\frac{\\partial^2 f}{\\partial t \\partial x}(ih,X_{ih}) *h*[ \\Delta Q_t]+ \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}) * {[\\Delta P_t+ \\Delta Q_t]}^2$$\n\nAnd squaring the $\\Delta P_t$ and $\\Delta Q_t$ terms and splitting across the sum:\n\n\n\n$$Z_t^n = \\sum_{i=1}^{i = n} \\Delta f\\left(ih,h\\right) = \\sum_{i=1}^{i = n} \\frac{\\partial f}{\\partial t}(ih,X_{ih}) *h + \\sum_{i=1}^{i = n}\\frac{\\partial f}{\\partial x}(ih,X_{ih}) *[\\Delta P_t] + \\sum_{i=1}^{i = n}\\frac{\\partial f}{\\partial x}(ih,X_{ih}) *[\\Delta Q_t] +  $$\n\n\n$$ \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial t}^2}(ih,X_{ih}) * {h}^2 + \\sum_{i=1}^{i = n} \\frac{\\partial^2 f}{\\partial t \\partial x}(ih,X_{ih}) *h*[\\Delta P_t]  + \\sum_{i=1}^{i = n} \\frac{\\partial^2 f}{\\partial t \\partial x}(ih,X_{ih}) *h*[ \\Delta Q_t]+ ... $$\n\n\n\n$$...  + \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}) {\\Delta P_t}^2 + \\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}){\\Delta Q_t}^2 + 2\\frac{1}{2}\\sum_{i=1}^{i = n}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih})\\Delta Q_t \\Delta P_t$$\n\nAnd now we take the limit at $n$ approaches $\\infty$, and a bunch of terms cancel. :\n\n\n$$Z_t^\\infty = f(t,X_t) - f(0,X_0) = \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) ds + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) d P_s + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) d Q_s +  $$\n\n\n$$...  +  \\frac{1}{2}\\sum_{i=1}^{i = \\infty}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}){\\Delta Q_t}^2 $$\n\nAnd focusing on the top line, we can substitute back in for $P_s$ and $Q_s$:\n\n\n$$Z_t^\\infty = f(t,X_t) - f(0,X_0) = \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) ds + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) \\mu_s d s + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) \\sigma_sdW_s +  $$\n\n\n$$...  +  \\frac{1}{2}\\sum_{i=1}^{i = \\infty}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}){\\Delta Q_t}^2 $$\n\nAnd again focusing on the top line, we can combine like terms:\n\n$$Z_t^\\infty = f(t,X_t) - f(0,X_0) = \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) + \\mu_s \\frac{\\partial f}{\\partial x}(s,X_s)  ds + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) \\sigma_sdW_s +  $$\n\n\n$$...  +  \\frac{1}{2}\\sum_{i=1}^{i = \\infty}\\frac{\\partial^2 f}{{\\partial x}^2}(ih,X_{ih}){\\Delta Q_t}^2 $$\n\nAnd now we focus on the bottom line and given that ${\\Delta Q_t}^2$ approaches ${\\sigma _t}^2dt$, we get:\n\n\n$$Z_t^\\infty = f(t,X_t) - f(0,X_0) = \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) + \\mu_s \\frac{\\partial f}{\\partial x}(s,X_s)  ds + \\int_{s=0}^{s=t}\\frac{\\partial f}{\\partial x}(s,X_s) \\sigma_sdW_s +  $$\n\n\n$$...  +  \\frac{1}{2}\\int_{s=0}^{s=t}\\frac{\\partial^2 f}{{\\partial x}^2}(s,X_s) {\\sigma _s}^2 ds $$\n\nAnd now we can combine like terms again, and we have Ito's formula:\n\n\n$$Z_t = f(t,X_t) = a + \\int_{s=0}^{s=t} \\frac{\\partial f}{\\partial t}(s,X_s) + \\mu_s \\frac{\\partial f}{\\partial x}(s,X_s) + \\frac{1}{2}{\\sigma _s}^2\\frac{\\partial^2 f}{{\\partial x}^2}(s,X_s)  ds + \\int_{s=0}^{s=t}\\sigma_s\\frac{\\partial f}{\\partial x}(s,X_s) dW_s   $$\n\n\n\\end{document}", "meta": {"hexsha": "c0334305b2f6af79956b6ba2f9a888554684b60b", "size": 20618, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "GSmithApps/StochasticProcesses", "max_stars_repo_head_hexsha": "0fbdf356e5a804fc7c15a003ed37fe1251905063", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "GSmithApps/StochasticProcesses", "max_issues_repo_head_hexsha": "0fbdf356e5a804fc7c15a003ed37fe1251905063", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "GSmithApps/StochasticProcesses", "max_forks_repo_head_hexsha": "0fbdf356e5a804fc7c15a003ed37fe1251905063", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.3790849673, "max_line_length": 1035, "alphanum_fraction": 0.6667960035, "num_tokens": 7203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.43348153091687364}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 27, Section 5.1: 18, 21, 23, 25, 31}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{18.}\nUpper triangular matrix, so the eigenvalues are the values on the diagonal $= 5, 0, 3$\n\\subsection*{21. A)}\nFalse. The equation $Ax = \\lambda x$ must have a nontrivial solution. \n\\subsection*{21. B)}\nTrue. If 0 is an eigenvalue then is equivalent to $Ax = 0$, which has a nontrivial solution if and only if A is not invertible. Thus 0 is an eigenvalue of A if and only if A is not invertible. \n\\subsection*{21. C)}\nTrue. The set of all solutions of $A - \\lambda I)x = 0$ is just the null space of the matrix $Ax = \\lambda I$. \n\\subsection*{21. D)}\nTrue. To check if it is an eigenvector, just multiply it by the matrix in question. \n\\subsection*{21. E)}\nTrue. Although row reduction is used to find eigenvectors, it cannot be used to find eigenvalues. \n\\subsection*{23.}\nIf a 2 x 2 matrix A were to have three distinct eigen values then by theorem 2 there would correspond three linearly independent eigenvectors. This is impossible because the vectors all belong to a two-dimensional vector space, in which any set of three vectors in linearly dependent. \n\\subsection*{25.}\nIf $\\lambda$ is an eigenvalue of A then there is a nonzero vector x such that $Ax - \\lambda x$. Since $x \\neq 0$, $\\lambda$ cannot be zero. This then means that $\\lambda^{-1} Ax = A^{-1}x$, which shows that $\\lambda^{-1}$ is an eigenvalue of $A^{-1}$. \n\\subsection*{31.}\nSuppose T reflects points through a line that passes through the origin of the matrix. The line is multiples of some nonzero vector v, so the points on the line do not move under A. So T(v) = v. If A is the standard matrix of T, then $Av = v$. Thus v is an eigenvector of A corresponding to the eigenvalue 1. This also means another eigenspace is generated by any nonzero vector u that is perpendicular to the given line. This, by the properties of transformation, each vector on the line through the vector u is transformed onto the vector -x, meaning the eigenvalue is -1. \n\\end{document}", "meta": {"hexsha": "8a36f5533c381ecaba18b0d904a15380df78a281", "size": 2431, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LinearAlgebra/Homework27.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LinearAlgebra/Homework27.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LinearAlgebra/Homework27.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.775, "max_line_length": 575, "alphanum_fraction": 0.7338543809, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.43348151711684}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{GW energy}\n\n\\marginpar{Monday\\\\ 2021-5-17, \\\\ compiled \\\\ \\today}\n\nBecause of the equivalence principle, there can be no local definition of energy density or of a stress-energy tensor for \\(g_{\\mu \\nu }\\). \n\nHowever, we can define the Landau-Lifshitz pseudotensor (which is actually a tensor density): from the gothic metric \n%\n\\begin{align}\n\\mathfrak{g}^{\\alpha \\beta } = \\sqrt{-g } g^{\\alpha \\beta }\n\\,\n\\end{align}\n%\nwe define \n%\n\\begin{align}\n\\Lambda^{\\alpha \\mu \\beta \\nu } = \\mathfrak{g}^{\\alpha \\beta } \\mathfrak{g}^{\\mu \\nu } - \\mathfrak{g}^{\\alpha \\nu } \\mathfrak{g}^{\\beta \\mu }\n\\,,\n\\end{align}\n%\na four-tensor density which has the same symmetries as the Riemann tensor. \nAlso, we have the properties that \n%\n\\begin{align}\n\\partial_{\\mu } \\partial_{\\nu } \\Lambda^{\\alpha \\mu \\beta \\nu } = 2 (-g) G^{\\alpha \\beta } + 16 \\pi (-g) \\tau^{\\alpha \\beta }_{LL}\n\\,,\n\\end{align}\n%\nwhere \\(G^{\\alpha \\beta }\\) is the Einstein tensor, while \\(\\tau_{LL}\\) (defined to contain whatever remains) is called the Landau-Lifshitz tensor: this can also be expressed as \n%\n\\begin{align}\n\\partial_{\\mu } \\partial_{\\nu } \\Lambda^{\\alpha \\mu \\beta \\nu } =\n16 \\pi (-g) \\qty(T^{\\alpha \\beta } + \\tau_{LL}^{\\alpha \\beta })\n\\,.\n\\end{align}\n\nIf we take a further derivative with respect to \\(\\alpha \\), in a vacuum, we find \n%\n\\begin{align}\n\\partial_{\\alpha } \\partial_{\\mu } \\partial_{\\nu } \\Lambda^{\\alpha \\mu \\beta \\nu } = \\partial_{\\alpha } \\tau_{LL}^{\\alpha \\beta } = 0\n\\,,\n\\end{align}\n%\nwhere the last equality is due to the symmetries of \\(\\Lambda \\). Therefore, the tensor \\(\\tau_{LL}\\) is conserved, and we can try to interpret it as the ``energy of the gravitational field''.\n\nIn normal coordinates at any given point \\(\\tau_{LL}\\) is identically zero.\n\nA global concept of energy does not exist for certain spacetimes --- see ADM and the Hamiltonian formulation of GR. \n\nHowever, asymptotically flat spacetimes have some nice properties.\n\nIf we foliate a spacetime \\((M, g)\\) into 3D spacelike hypersurfaces \\(\\Sigma \\), we say it is asymptotically flat if the reduced metric \\(\\gamma_{ij} \\to f_{ij}\\) tends towards the Minkowski metric at radial infinity. \n\nIn this case, we can associate an energy to \\(\\Sigma \\).\nUsing these concepts, there is hope to identify some quantity which represents GW energy.\n\nWe explore directions at infinity which are \\textbf{asymptotically null}, and suppose that at \\(\\Sigma_{t_{1, 2}}\\) we have stationary states, with dynamics in between. \n\nThen, if there is a difference of energy \\(\\Delta E = E_2 - E_1 \\), we expect there to be a flux of ``some \\(\\tau_{\\mu \\nu }\\)'' from the surface. \n\nWe can work in linearized theory: \\(g = f + h\\). \nThe characteristics we expect a definition of energy to have are, at the very least\n\\begin{enumerate}\n    \\item quadratic in \\(h\\),\n    \\item generate curvature via a stress-energy tensor \\(\\tau_{\\alpha \\beta }\\),\n    \\item gauge invariant under infinitesimal coordinate transformations.  \n\\end{enumerate}\n\nWe start by specifying the \\(LL\\) tensor to the weak field case. \nThe metric reads \\(g = \\eta + h^{(1)} + h^{(2)} + \\order{3}\\), where by the indices in parentheses we mean orders in some expansion parameter.\n\nThe Ricci reads \n%\n\\begin{align}\nR_{\\mu \\nu } = \nR_{\\mu \\nu }^{(0)} + \nR_{\\mu \\nu }^{(1)} + \nR_{\\mu \\nu }^{(2)} + \n\\order{3}\n\\,.\n\\end{align}\n\nNow, \\(R_{\\mu \\nu }^{(0)} = (\\text{Ric}[\\eta ])_{\\mu \\nu } \\sim \\eta \\partial^2 \\eta  = 0\\), but if we had a non-flat background this would not hold. \nOn the other hand, \n%\n\\begin{align}\nR^{(1)}_{\\mu \\nu } = \\qty(\\text{Ric}^{(1)}[h^{1}])_{\\mu \\nu } \\sim \\eta \\partial^2 h^{(1)}\n\\,,\n\\end{align}\n%\nwhere \\(\\text{Ric}^{(i)}\\) is the Ricci operator expanded up to \\(i\\)-th order. This is relevant in the second-order term: \n%\n\\begin{align}\nR^{(2)}_{\\mu \\nu } = \n\\qty(\\text{Ric}^{(1)} [ h^{(2)}])_{\\mu \\nu }\n\\qty(\\text{Ric}^{(2)} [ h^{(1)}])_{\\mu \\nu }\n\\sim\n\\eta \\partial^2 h^{(2)} + h^{(1)} \\partial^2 h^{(1)}\n\\,.\n\\end{align}\n\nThen, the EFE in vacuo read \n%\n\\begin{align}\n0 = \nR^{(0)}_{\\mu \\nu } + \nR^{(1)}_{\\mu \\nu } + \nR^{(2)}_{\\mu \\nu } +  \\order{3}\n\\,,\n\\end{align}\n%\ntherefore to order 0 we have the \\(\\eta \\) metric; to order \\(1\\) we can calculate \\(h^{(1)}\\), while to order \\(2\\) we can assume the \\(h^{(1)}\\) metric is already calculated and solve \\(R^{(2)}_{\\mu \\nu } = 0\\) for \\(h^{2}\\). \n\nThe second order equation reads \n%\n\\begin{align}\nG^{(1)}_{\\mu \\nu }[h^{(2)}] &= \\qty(\\text{Ric}^{(1)}[h^{2}] - \\frac{1}{2} R^{(1)} [h^{2}]\\eta )_{\\mu \\nu }  \\\\\n&=\\qty(- \\text{Ric}^{(2)} [h^{1}] + \\frac{1}{2} R^{(2)}[h^{1}] \\eta )_{\\mu \\nu }   \\\\\n&\\overset{?}{=} 8 \\pi \\tau_{\\mu \\nu }\n\\,,\n\\end{align}\n%\nbut can this actually be our GW stress-energy tensor? It is symmetric, it is quadratic in \\(h\\), and due to the Bianchi identities it is also conserved. \nHowever, it is not gauge invariant, and it is not unique! \n\nIf \\(h^{(1)}\\) is \\textbf{asymptotically flat}, then \\(h \\sim \\order{1/r}\\), \\(\\partial_{i} h \\sim \\order{1/r^2}\\) and \\(\\partial_{i} \\partial_{j} h \\sim \\order{1/r^3}\\).\n\nIn this case, \\(E = \\int_{\\Sigma } \\dd[3]{x} \\tau_{00} \\) is both \\textbf{gauge invariant} and \\textbf{unique}: \\(E[h_{\\mu \\nu } + 2 \\partial_{(\\mu } \\xi_{\\nu )}] = E[h_{\\mu \\nu }]\\). \n\nWe can then write an energy flux in the form \n%\n\\begin{align}\n\\Delta E = -\\int_{S} \\dd[2]{y} \\tau_{\\mu 0} n^\\mu   \n\\,,\n\\end{align}\n%\nacross a surface \\(S\\) which determines the spatial boundary of \\(\\Sigma \\) over time.  \n\nWeak-field GR can be interpreted as a field theory on \\(\\eta \\) for the field \\(h\\). \n\nPhysically speaking, it is true that we can ``eliminate'' the gravitational field at a point, but here we are more interested in the following question:\ncan the GW in a neighborhood of that point contribute to the curvature via a gauge invariant tensor?  \n\nThe issue comes down to: what is the distinction between ``waves'' and background?\n\nOne can prove that a suitable average of \\(\\text{Ric}^{(2)}[h^{(1)}]\\) is actually gauge-invariant: this is the \\textbf{Isaacson tensor}, \n%\n\\begin{align}\n\\tau_{\\alpha \\beta } = \\frac{c^{4}}{32 \\pi G} \\expval{\\partial_{\\mu } h_{\\alpha \\beta } \\partial_{\\nu } h^{\\alpha \\beta }}\n\\,,\n\\end{align}\n%\ndue to the fact that \\(\\text{Ric}^{(2)}[h] \\sim h \\partial \\partial h + \\partial h \\partial h + \\partial (h \\partial h)\\). \n\nLet us take the derivative \\(\\partial_{\\mu} \\tau^{\\mu \\nu }\\): \n%\n\\begin{align}\n\\int_{V} \\dd[3]{x} \\qty(\\partial_0 \\tau^{00} + \\partial_{i} \\tau^{0i}) \n&= \\dot{E} + \\oint_{S} \\dd[2]{y} \\tau_{0i} n^i  \\\\\n&= \\dot{E} + r^2 \\oint \\dd[2]{y} \\expval{\\partial^{0} h_{ij} \\partial_{r} h^{ij}}\n\\,,\n\\end{align}\n%\nwhich yields the quadrupole formula: \n%\n\\begin{align}\n\\dv{E_{GW}}{t} &= \\frac{c^3}{32 \\pi G} r^2 \\int \\dd{\\Omega } \\expval{\\partial_{t} h_{ij}^{TT} \\partial_{t} h_{ij}^{TT}}  \\\\\n&= \\frac{G}{5 c^{5}}\\expval{ \\dot{\\ddot{Q}}_{ij} \\dot{\\ddot{Q}}^{ij}}\n\\,.\n\\end{align}\n\nLet us look at some dimensional analysis: \n%\n\\begin{align}\n[Q] &= a ML^2  \\\\\n[\\dot{\\ddot{Q}}] &= a ML^2 T^{-3} \\sim a \\Omega^3 M L^2 = E^2 T^{-2}\\\\\n[ \\frac{G}{c^{5}}] &= T E^{-1}\n\\,.\n\\end{align}\n%\nThe factor \\(G / c^{5}\\) is the inverse of a power: \\(c^{5} / G \\approx \\SI{e52}{W}\\), a very large power, and we are dividing by it.  \nThis suggests a potential rewriting of the formula, which was an idea of Weber's: \n%\n\\begin{align}\n\\dot{E} \\sim \\frac{G}{c^{5}} a^2 \\Omega^{6} M^2 R^{4} = \\dots\n= a^2 \\frac{c^{5}}{G} \\qty( \\frac{v}{c})^{6} \\frac{GM}{c^2 R}\n\\,.\n\\end{align}\n\nThe power is therefore huge if \\(v \\sim c\\) and \\(R \\sim R_S\\)! \n\nThe above formula for \\(\\dot{E}\\) is \\emph{correct} for a leading-order description of a binary system, if we take \\(a^2 = 32/5\\), \\(\\Omega \\) to be the orbital frequency, \\(M\\) to be \\(\\mu \\) (the reduced mass), and \\(R\\) the orbital radius. So, \n%\n\\begin{align}\n\\dot{E} = \\frac{32}{5} \\frac{G \\mu^2}{c^{5}} R^{4} \\Omega^3\n\\,.\n\\end{align}\n\nOf course, \\(\\dot{E} _{\\text{orbital energy}} = - \\dot{E} _{\\text{gw}}\\). \n\n\\end{document}\n", "meta": {"hexsha": "431a2e0276a98a3d0de18c91c6138d048f76908f", "size": 7975, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd_courses/gravitational_waves/may17.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "phd_courses/gravitational_waves/may17.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd_courses/gravitational_waves/may17.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 38.9024390244, "max_line_length": 247, "alphanum_fraction": 0.6275862069, "num_tokens": 2847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.43348151711683997}}
{"text": "\\documentclass{article}\n\\usepackage[section]{placeins}\n\\usepackage{graphicx, wrapfig, amsmath, amssymb, physics, hyperref}\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    filecolor=magenta,      \n    urlcolor=cyan,\n    }\n\n\\author{Yaghoub Shahmari}\n\\title{Report - Problem Set No 6}\n\\date{\\today}\n\\graphicspath{ {../Figs/} }\n\n\\begin{document}\n    \\maketitle\n    \\section*{Problem 1}\n    \\textbf{Basic description:}\n\n    In this problem, we're going to find the answer to the integral of a function.\n    So we will follow the instructions introduced by the book.\n    We will deploy both methods of the Monte Carlo algorithm for solving an integration.\n    As the problem told us:\n\n    $$f_{(x)} = \\int e^{-x^2} \\mathop{dx} \\Rightarrow I = \\int_0^2 e^{-x^2} \\mathop{dx} = \\frac{\\sqrt{\\pi}}{2} \\mathrm{erf}_{(2)}$$\n    \n    We solved the integration for different amounts of samples for both methods\n    and showed the benchmark result of each one in the notebook (Q1-1DInt.ipynb).\n    We also showed the distribution of answers for both methods.\n    And finally, we will show the answers, errors, and performance for each amount of samples.\n\n    \\textbf{The results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.25]{/Q1/IMCVilPlot}\n        \\label{fig:1.1}\n        \\includegraphics[scale = 0.25]{/Q1/SMCVilPlot}\n        \\label{fig:1.2}\n        \\caption{Distribution of answers for both methods.}\n    \\end{figure}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.42]{/Q1/MCAnswerPlot}\n        \\label{fig:1.3}\n        \\includegraphics[scale = 0.42]{/Q1/MCErrorPlot}\n        \\label{fig:1.4}\n        \\includegraphics[scale = 0.42]{/Q1/MCPerformPlot}\n        \\label{fig:1.5}\n        \\caption{Plot of answers, errors, and performance for both methods.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 2}\n    \\textbf{Basic description:}\n\n    In this problem, we want to find the center of mass of\n    a sphere whit specific mass distribution.\n    So we have to find the answer to a 2D integration.\n    As we know:\n\n    $$R_{CoM} = \\frac{I}{M} \\Rightarrow R_{CoM} = \\frac{\\int_{Sphere} z \\rho dV}{\\int_{Sphere} \\rho dV},\\ \\rho = \\rho_0 (3 + \\frac{r}{R} \\cos{\\theta}) \\Rightarrow$$\n    $$ R_{CoM} = \\frac{\\int_0^R\\int_0^\\pi (3+\\frac{r}{R}\\cos{\\theta})r^3\\sin{\\theta}\\cos{\\theta} d\\theta dr}{\\int_0^R\\int_0^\\pi (3+\\frac{r}{R}\\cos{\\theta})r^2\\sin{\\theta} d\\theta dr}$$\n\n    That has the exact answer of $R_{CoM} = \\frac{R}{15}$.\n    We drew the distribution of a bunch of answers.\n    Also, we calculated the values of errors.\n    The final answer is $R_{CoM} = 0.0665806190158467$.\n    All steps and values are available in the notebook.\n\n    \\textbf{The results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.25]{/Q2/IHistPlot}\n        \\label{fig:2.1}\n        \\includegraphics[scale = 0.25]{/Q2/MHistPlot}\n        \\label{fig:2.2}\n        \\caption{Distribution of answers of integration of I and M.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 3}\n    \\textbf{Basic description:}\n\n    In this problem, we want to create the Normal distribution\n    by moving samples of the Uniform distribution in a span\n    with various chances of movement and deploying the Metropolis algorithm.\n    As we know the best distribution comes out with $a_r \\approx 0.5$.\n    So we draw a distribution with $a_r \\approx 0.5$.\n    Then, we will show the relation between $\\Delta$ and $a_r$.\n    And finally, we will show the Auto Correlation and Correlation length.\n    The Correlation length will come out by finding the exponent of the Auto Correlation.\n\n    \\textbf{The results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q3/NormalHist}\n        \\label{fig:3.1}\n        \\caption{Metropolis Normal Distribution with $a_r \\approx 0.5$.}\n    \\end{figure}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q3/AcceptanceRatio}\n        \\label{fig:3.2}\n        \\caption{Acceptance Ratio plot.}\n    \\end{figure}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.3]{/Q3/Autocorrelation1}\n        \\label{fig:3.3}\n        \\includegraphics[scale = 0.3]{/Q3/Autocorrelation2}\n        \\label{fig:3.4}\n        \\includegraphics[scale = 0.3]{/Q3/CorrelationLength}\n        \\label{fig:3.5}\n        \\caption{Auto correlation and Correlation Length Plot.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\centering\n    \\textbf{The whole data I gathered is in \\href{https://github.com/shahmari/ComputationalPhysics-Fall2021/tree/main/ProblemSet7/Data}{this link}}\n\n    Thanks for watching :)\n\\end{document}", "meta": {"hexsha": "e077c192217f21737bcc724fc2e12b5f86132551", "size": 4679, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProblemSet7/TEXfiles/report.tex", "max_stars_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_stars_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ProblemSet7/TEXfiles/report.tex", "max_issues_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_issues_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProblemSet7/TEXfiles/report.tex", "max_forks_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_forks_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-21T11:07:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-21T11:07:08.000Z", "avg_line_length": 35.446969697, "max_line_length": 184, "alphanum_fraction": 0.6527035691, "num_tokens": 1450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.611381973294151, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4334815133577291}}
{"text": "\\section{Matching Features}\\label{sec:match-feat}\r\n\r\nIn order to support alphabet-based laws and definitions,\r\nwe introduce the notion of ``list variables'',\r\nthat match against zero or more variables satisfying some property.\r\nThese list-variables encode simple expressions that give\r\nsome flexibility in how they match.\r\nWe further classify as follows:\r\n\\begin{description}\r\n  \\item[Reserved:]  $O$, $M$, $S$\r\n  \\item[Generic:] $\\lst v$, $\\lst e$, \\ldots (lowercase)\r\n\\end{description}\r\nHere are some examples of laws that require this list-matching facility:\r\n\\begin{description}\r\n%\r\n\\item[Sequential Composition]\r\n$$\r\n  P ; Q ~\\defs~ \\exists O_m \\bullet P[O_m/O'] \\land Q[O_m/O]\r\n$$\r\nHere the $O$ list-variable matches all the undecorated\r\nobservation variables., i.e. the alphabet, of the theory.\r\nIn practise we also need a side condition that says all the $O_m$\r\nare fresh --- we don't want to rely on $P$ and $Q$ only having free variables\r\nin that alphabet.\r\nThe idea is that \\texttt{O}, \\texttt{M} and \\texttt{S} are reserved-variable root strings that\r\ncorrespond to $O$, $M$ and $S$, respectively.\r\n%\r\n\\item[Assignment]\r\n$$\r\n  x := e ~\\defs~ ok \\implies ok' \\land x' = e\r\n    \\land S'\\less x = S\\less x\r\n$$\r\nList-variable $S$ refers to all the program or user variables,\r\nthose that appear explicitly in the programming notation (script) under study.\r\nThis are different from the model variables (often referred to as\r\n``auxiliary''), denoted by $M$ that capture observable aspects\r\nof system behaviour beyond what can be expressed with just the $S$\r\nvalues. Examples of variables in $M$ include $ok$, $wait$, $tr$, etc.\r\nThe expression $S'\\less x = S\\less x$\r\ndenotes the conjunction of identities of the form $v'=v$\r\nwhere $v \\in S\\setminus\\setof x$.\r\nIf $x$ is an observation variable\r\nthen the above law only works for that variable,\r\nand in fact could be expanded out (given $S$)\r\nto an explicit law for that variable.\r\nIf $x$ is not an observation variable,\r\nthen it should be a ``variable-variable'',\r\nand typically we cannot complete the match of $S\\less x$\r\nuntil\r\nother context information tells us to which variables $x$ must match.\r\n\\par\r\nWe can have more than one subtracted variable:\r\n$$\r\n  x,y := e,f ~\\defs~ ok \\implies ok' \\land x' = e \\land y'=f\r\n    \\land S'\\less{x,y} = S\\less{x,y}\r\n$$\r\n\\item[Simultaneous Assignment]\r\nWay more than just two subtracted variables!\r\n\\begin{eqnarray*}\r\n  \\lefteqn{x_1,\\ldots,x_n ::= e_1, \\ldots , e_n}\r\n\\\\ &=& \\lst x := \\lst e\r\n\\\\ &\\defs&\r\n     ok \\implies ok'\r\n     \\land x'_1 = e_1 \\land \\ldots \\land x'_n = e_n\r\n     \\land S'\\less{x_1,\\ldots,x_n} = S\\less{x_1,\\ldots,x_n}\r\n\\\\ &=& ok \\implies ok'\r\n    \\land \\lst x' = \\lst e\r\n    \\land S'\\less{\\lst x} = S\\less{\\lst x}\r\n\\end{eqnarray*}\r\nIn the mathematical form, we use indices and ellipsis\r\nto suggest that we have lists of variables and expressions\r\nof the same length.\r\n\\item[Skip]\r\n\\begin{eqnarray*}\r\n  \\Skip &\\defs& ok \\implies ok' \\land S'=S\r\n\\end{eqnarray*}\r\nA simple form of a simple simultaneous assignment!\r\n\\end{description}\r\n\r\nFrom the above examples,\r\na number of general observations can be made:\r\n\\begin{itemize}\r\n  \\item\r\n    All list-variables match against lists of things (zero or more).\r\n    This means they can only occur in certain places:\r\n    \\begin{itemize}\r\n      \\item quantifier binding variable lists\r\n      \\item replacement/target lists in substitutions\r\n       \\item in 2-place (atomic) predicates, provided both places\r\n        are occupied by a single meta-variable.\r\n    \\end{itemize}\r\n  \\item\r\n    A predicate involving two list-variables mandates that both\r\n    match lists of the same size, and the predicate\r\n    is interpreted as the \\emph{conjunction} of instances of that predicate\r\n    over corresponding pairs from the match-list.\r\n    It can also match a single such predicate also using two list-variables.\r\n  \\item\r\n    Some list-variables ($O$, $S$, $M$)\r\n    denote specific sets of variables.\r\n    The matching rules for these differ from those for regular variables,\r\n    in that $O$ and $O'$ can only match themselves or their expansions,\r\n    while $O_a$ and $O_b$ can match with a binding---subscript decorations\r\n    are viewed as general patterns, and are not considered ``known''.\r\n  \\item\r\n    Other list-variables  ($x_1$, $e_1$, \\ldots)\r\n    are local names used as general placeholder.\r\n    These simply match all the variables/ expressions /whatever\r\n    that occur in the relevant position.\r\n  \\item\r\n    These list-variables won't only appear in match patterns,\r\n    but could also appear in test/goal predicates,\r\n    so we could imagine the following predicate fragment:\r\n    $$\r\n       \\exists ok_m,S_m \\bullet \\ldots\r\n    $$\r\n    matching against a similar fragment from the definition of\r\n    sequential composition:\r\n    $$\r\n      \\exists O_n \\bullet \\ldots\r\n    $$\r\n    Here the match binding would include\r\n    $O_n \\mapsto \\setof{ok_m} \\cup S_m$.\r\n  \\item\r\n    The reserved list-variables are \\emph{precise},\r\n    in the sense that on any given matching context,\r\n    they match a known fixed collection of variables\r\n    (so there shouldn't be a need in most cases to defer a match).\r\n    An exception is in a generic theory that has no specific observation\r\n    variables defined, when these list-variables can only match\r\n    themselves, and $O$ being able to match $S,M$.\r\n\\end{itemize}\r\n", "meta": {"hexsha": "98956a8d0324ca986986c0c8e6110d631a07d505", "size": 5380, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/Matching-Features.tex", "max_stars_repo_name": "leomcclean/reasonEq", "max_stars_repo_head_hexsha": "86b4c70c4a2ca1d0f05b6d1384059f13e26abd2b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-10-02T15:29:38.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-23T23:06:56.000Z", "max_issues_repo_path": "doc/Matching-Features.tex", "max_issues_repo_name": "ConchuirORiain/reasonEq", "max_issues_repo_head_hexsha": "79a3513db4444d9ce4cf66cf8c53e614cbad7725", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/Matching-Features.tex", "max_forks_repo_name": "ConchuirORiain/reasonEq", "max_forks_repo_head_hexsha": "79a3513db4444d9ce4cf66cf8c53e614cbad7725", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-02-15T17:08:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-13T09:57:38.000Z", "avg_line_length": 40.4511278195, "max_line_length": 95, "alphanum_fraction": 0.6953531599, "num_tokens": 1418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.43345879122806197}}
{"text": "\\vssub\n\\subsection{~Non-ice source term integration} \\label{sub:source}\n\\vssub\n\nThe source terms not involving ice are accounted for by solving\n\n%---------------------%\n% Step : Source terms %\n%---------------------%\n% eq:step_source\n\n\\begin{equation}\n\\frac{\\p N}{\\p t} = \\cS_{no~ice} \\: . \\label{eq:step_source}\n\\end{equation}\n\n\\noindent \nAs in \\wam, a semi-implicit integration scheme is used. In this scheme the\ndiscrete change of action density $\\Delta N$ becomes \\citep{art:WAM88}\n\n% eq:implicit_st\n\n\\begin{equation}\n\\Delta N(k,\\theta) = \\frac{\\cS(k,\\theta)}{1- \\epsilon D(k,\\theta)\\Delta t}\n\\: , \\label{eq:implicit_st} \\end{equation}\n\n\\noindent \nwhere $D$ represents the diagonal terms of the derivative of $\\cS$ with\nrespect to $N$ \\citep[Eqs. 4.1 through 4.10]{art:WAM88}, and where $\\epsilon$\ndefines the offset of the scheme. Originally, $\\epsilon = 0.5$ was implemented\nto obtain a second-order accurate scheme. Presently, $\\epsilon = 1$ is used because it is more appropriate for the large time steps in the equilibrium range of\nthe spectrum \\citep{pro:HA98,art:HA01} and it results in much smoother\nintegration of the spectrum. The change of $\\epsilon$ has little impact on\nmean wave parameters, but makes the dynamical time stepping as described below\nmore economical.\n\nThe semi-implicit scheme is applied in the framework of a dynamic\ntime-stepping scheme \\citep{tol:JPO92}. In this scheme, integration over the\nglobal time step $\\Delta t_g$ can be performed in several dynamic time steps\n$\\Delta t_d$, depending on the net source term $\\cS$, a maximum change of\naction density $\\Delta N_m$ and the remaining time in the interval $\\Delta\nt_g$. For the $n^{\\rm th}$ dynamic time step in the integration over the\ninterval $\\Delta t_g$, $\\Delta t_d^n$ is calculated in three steps as\n\n% ------ Dynamic s.t. int. scheme ------- %\n% eq:st_d_1\n% eq:st_d_2a\n% eq:st_d_2b\n% eq:st_d_3\n\n\\begin{equation}\n\\Delta t_d^n = \n\\min_{f<f_{hf}} \\left [ \\frac{\\Delta N_m}{|\\cS|}\n\\left ( 1 + \\epsilon D \\frac{\\Delta N_m}{|\\cS|} \\right ) ^{-1}\n\\right ] \\: , \\label{eq:st_d_1}\n\\end{equation} \\begin{equation}\n\\Delta t_d^n = \\max \\: \\left [ \\: \\Delta t_d^n \\: , \\: \n\\Delta t_{d,\\min} \\right ] \\: , \\label{eq:st_d_2a}\n\\end{equation} \\begin{equation}\n\\Delta t_d^n = \\min \\: \\left [ \\: \\Delta t_d^n \\: , \\: \n\\Delta t_g - \\sum_{i=1}^{n-1} \\Delta t_d^i\n \\: \\right ] \\: , \\label{eq:st_d_2b}\n\\end{equation}\n\n\\noindent\nwhere $\\Delta t_{\\min}$ is a user-defined minimum time step, which is added to\navoid excessively small time steps. The corresponding new spectrum $N^n$\nbecomes\n\n\\begin{equation}\nN^n = \\max\\: \\left [ \\: 0 \\: , \\: N^{n-1} + \n\\left ( \\frac{\\cS \\Delta t_d}{1 - \\epsilon D \\Delta t_d} \\right )\n\\: \\right ] \\: . \\label{eq:st_d_3}\n\\end{equation}\n\n\nThe maximum change of action density $\\Delta N_m$ is determined from a\nparametric change of action density $\\Delta N_p$ and a filtered relative\nchange $\\Delta N_r$\n\n% eq:st_d_4\n% eq:st_d_5\n% eq:st_d_6\n% eq:st_d_7\n\n\\begin{equation}\n\\Delta N_m (k,\\theta) = \\min \\: \\left [ \\:\n\\Delta N_p (k,\\theta) \\: , \\: \\Delta N_r (k,\\theta) \n\\: \\right ] \\: , \\label{eq:st_d_4}\n\\end{equation} \\begin{equation}\n\\Delta N_p (k,\\theta) = X_p \\: \\frac{\\alpha}{\\pi} \\:\n\\frac{(2\\pi)^4}{g^2} \\: \\frac{1}{\\sigma k^3}\n\\: , \\label{eq:st_d_5}\n\\end{equation} \\begin{equation}\n\\Delta N_r (k,\\theta) = X_r \\; \\max \\: \\left [ \\: \nN(k,\\theta) \\: , \\: N_f \\: \\right ] \\: , \\label{eq:st_d_6}\n\\end{equation} \\begin{equation}\nN_f = \\max \\: \\left [ \\: \\Delta N_p (k_{\\max},\\theta) \\: , \n\\: X_f \\: \\max_{\\forall k,\\theta} \\left \\{ N(k,\\theta) \\right \\}\n\\: \\right ] \\: , \\label{eq:st_d_7} \\end{equation}\n\n\\noindent \nwhere $X_p$, $X_r$ and $X_f$ are user-defined constants (see\nTable~\\ref{tab:st_d_p}), $\\alpha$ is a {\\sc pm} spectrum energy level (set to $\\alpha =\n0.62\\times 10^{-4}$) and $k_{\\max}$ is the maximum discrete wavenumber. The\nparametric spectral shape in (\\ref{eq:st_d_5}) corresponds in deep water to\nthe well-known high-frequency shape of the one-dimensional frequency spectrum\n$F(f) \\propto f^{-5}$. The link between the filter level and the maximum\nparametric change in (\\ref{eq:st_d_7}) is used to assure that the dynamic time\nstep remains reasonably large in cases with extremely small wave energies. A\nfinal safeguard for stability of integration is provided by limiting the\ndiscrete change of action density to the maximum parametric change\n(\\ref{eq:st_d_5}) in conditions where Eq.~(\\ref{eq:st_d_2a}) dictates $\\Delta\nt_d^n$. In this case Eq.~(\\ref{eq:st_d_2a}) becomes a limiter as in the WAM\nmodel. Impacts of limiters are discussed in detail in for instance\n\\cite{art:HJ99,art:HJ01}, \\cite{art:HA01} and \\cite{tol:GAOS02}.\n\n% tab:st_d_p\n\n\\begin{table} \n\\begin{center} \\begin{tabular}{|l|c|c|c|c|} \\hline \\hline\n                 & $X_p$     & $X_r$             & $X_f$ &\n$\\Delta t_{d,\\min}$      \\\\ \\hline\n\\wam\\ equivalent & $\\frac{\\pi}{24}10^{-3}\\Delta t$\n & $\\infty (\\geq 1)$ & --    & $\\Delta t_g$  \\\\ \n suggested       & 0.1-0.2  & 0.1-0.2 & 0.05 & $\\approx 0.1 \\Delta t_g$ \\\\  \ndefault setting  &  0.15    &   0.10  & 0.05 & -- \\\\ \\hline \\hline\n\\end{tabular} \\end{center}\n\\caption{User-defined parameters in the source term integration\n scheme}\n\\label{tab:st_d_p} \\botline \\end{table}\n\nThe dynamic time step is calculated for each grid point separately, adding\nadditional computational effort only for grid points in which the spectrum is\nsubject to rapid change. The source terms are re-calculated for every dynamic\ntime step.\n\nIt is possible to compile \\ws\\ without using a linear growth term. In such a\ncase, waves can only grow if some energy is present in the spectrum. In\nsmall-scale applications with persistent low wind speeds, wave energy might\ndisappear completely from part of the model. To assure that wave growth can\noccur when the wind increases, a so-called seeding option is available in \\ws\\\n(selected during compilation). If the seeding option is selected, the energy\nlevel at the seeding frequency $\\sigma_{\\rm seed} = \\min(\\sigma_{\\max}, 2\\pi\nf_{hf})$ is required to at least contain a minimum action density\n\n% ------ Spectral seeding ------- %\n% eq:seed\n\n\\begin{eqnarray}\nN_{\\min}(k_{seed},\\theta) & = & \n        6.25 \\times 10^{-4} \\frac{1}{k_{\\rm seed}^3 \\: \\sigma_{\\rm seed}}\n        \\max \\left [ \\: 0. \\: , \\: \\cos^2 ( \\theta - \\theta_w ) \\right ]\n                             \\nonumber \\\\ & & \\hspace{5mm}\n        \\min \\left [ \\: 1 \\: , \\: \\max \\left ( \\: 0 \\: , \\: \n        \\frac{|u_{10}|}{X_{\\rm seed} g \\sigma_{\\rm seed}^{-1}}-1 \n\\: \\right ) \\: \\right ] \\: , \\label{eq:seed} \\end{eqnarray}\n\n\\noindent\nwhere $g \\sigma_{\\rm seed}^{-1}$ approximates the equilibrium wind speed for\nthe highest discrete spectral frequency. This minimum action distribution is\naligned with the wind direction, goes to zero for low wind speeds, and is\nproportional to the integration limiter (\\ref{eq:st_d_5}) for large wind\nspeeds. $X_{\\rm seed} \\geq 1$ is a user-defined parameter to shift seeding to\nhigher frequencies. Seeding starts if the wind speed reaches $X_{\\rm seed}$\ntimes the equilibrium wind speed for the highest discrete frequency, and\nreaches its full strength for twice as high wind speeds. The default model\nsettings include the seeding algorithm, with $X_{\\rm seed} = 1$.\n\nIn model version 3.11, surf-zone physics parameterizations have been\nintroduced. Such physics, particularly depth-induced breaking, operate on much\nsmaller time scales than deep water and limited-depth physics outside the surf\nzone. To assure reasonable behavior for larger time steps, an additional\noptional limiter has been adopted from the SWAN model, which can be used instead of \nmodeling surf-breaking explicitly.  This limiter is similar to the Miche\nstyle maximum wave height in the depth-limited wave breaking source term of\nEq.~(\\ref{eq:BJ78_Miche}). In this limiter, the maximum wave energy $E_m$ is\ncomputed as\n\n% ------ Surf zone limiter ------ %\n% eq:MLIM\n\n\\begin{equation}\nE_m = \\frac{1}{16} [ \\gamma_{lim}  \\tanh ( \\bar{k} d ) / \\bar{k} ] ^2\n\\:\\:\\: , \\label{eq:MLIM} \n\\end{equation}\n\n\\noindent\nwhere $\\gamma_{lim}$ is a factor comparable to $\\gamma_M$ in\nEq.~(\\ref{eq:BJ78_Miche}), with the caveat that $\\gamma_M$ is representative\nfor an individual wave, whereas $\\gamma_{lim}$ is representative for the\nsignificant wave height. For monochromatic waves, the original expression by\n\\cite{art:Miche44} would correspond to $\\gamma_{lim} = 0.94$ and replacing\n$H_s$ by the height $H$ of the waves. Here this idea is applied to random\nwaves.  In shallow water, this limits $H_s$ to be less than $\\gamma_{lim} d$.\nIf the total spectral energy $E$ is larger than the maximum energy $E_m$, the\nlimiter is applied by simply rescaling the spectrum by the factor $E/E_m$,\nloosely following the argumentation from \\cite{art:EB96} and used\nin \\para\\ref{sec:DB1}.  \n\nThis limiter can be switched on or off in the\ncompilation of the model, and $\\gamma_{lim}$ can be adjusted by the user. The\ndefault is set to $\\gamma_{lim} = 1.6$ because $H_{rms}$ values close to $d$\nhave indeed been recorded and thus taking a ratio $H_s/H_{rms}$ of 1.4, using\n1.6 allows this large steepness to be exceeded by some margin.  Note that this\nlimiter should be used as a `safety valve' only, and hence that it should be\nless strict than the breaking criterion in the surf-breaking or whitecapping\nsource terms, if these source terms are modeled explicitly.\n\nAlso, this limiter does not guarantee that all parts of the spectrum are\nrealistic. Indeed, the use of a mean wavenumber, as in the Komen et\nal. dissipation, makes it possible to have unrealistically steep short waves\nin the presence of swell. A future extension of this limiter could be to limit\nthe steepness with a partial spectral integration in frequencies, to make sure\nthat waves of all scales are indeed not too steep.\n\n\\vssub\n\\subsection{~Ice source terms integration} \\label{sub:icesource}\n\\vssub\n\nBecause the attenuation and scattering in the ice can be very strong (although they are linear), it is convenient \nto perform a separate integration of the ice terms $S_{\\mathrm{ice}}=S_{\\mathrm{id}}+S_{\\mathrm{is}}$. This combines \na dissipation term \n\\begin{equation}\nS_{\\mathrm{id}}/\\sigma  = \\beta_{\\mathrm{id}} N ,\n\\end{equation}\n and a scattering term \nwhich is of the form \n\\begin{equation}\n \\frac{S_{\\mathrm{is}}(k,\\theta)}{\\sigma} =  \\int_0^{2\\pi}\\beta_{\\mathrm{is}} [N(k,\\theta')-N(k,\\theta)] d\\theta'  ,\n \\end{equation}\n in which the scattering coefficient $\\beta_{\\mathrm{is}}$ is a priori a function of the difference in direction between \n incident $\\theta'$ and scattered $\\theta$ directions, as well as the shape of ice floes. In general \n  the directional spectrum $N(k,.)$ is a vector with {\\F NTH} (number of directions) components, \nand the source term is a vector of the same size  given by the matrix product $S/\\sigma = M N(k,.)$ where  \n$M$ is a positive symmetric square {\\F NTH} by {\\F NTH} matrix with components given from the $\\beta_{\\mathrm{id}}$ values.\nThe matrix $M$ is easily diagonalized as \n\\begin{equation}\n M  =  V D V^T  ,\n \\end{equation}\n where $D$ is a diagonal matrix containing all eigenvalues and $V$ is the array of eigenvectors, \n and $V^T$ is its transpose. As a result the split wave action equation for ice source terms \n \\begin{equation}\n\\frac{\\p}{\\p t} \\frac{N}{c_g}   = \\frac{S_{\\mathrm{id}}}{\\sigma c_g} ,\n \\end{equation}\n can be rewritten for the action $N_i$ of each eigenvector $V_i$ with eigenvalue $\\lambda_i$ as \n  \\begin{equation}\n\\frac{\\p}{\\p t} \\frac{N_i}{c_g}   = \\frac{\\beta_{\\mathrm{id}} + \\lambda_i}{\\sigma c_g} N_i ,\n \\end{equation}\n which has the following exact solution \n   \\begin{equation}\n {N_i}(t+\\Delta t_g)   = N_i(t) \\exp \\left[ (\\beta_{\\mathrm{id}} + \\lambda_i) +\\Delta t_g\\right].\n \\end{equation}\n \n In all cases the eigenvector corresponding to an isotropic spectrum has an eigenvalue $\\lambda=\\beta_{\\mathrm{id}}$. \n In the case of an isotropic back-scatter, the other eigenvalues are all equal to $(\\beta_{\\mathrm{id}} + \\beta_{\\mathrm{is}})$. \n This decomposition over the two eigenspaces simplifies the solution to \n%---------------------%\n% Step : Source terms %\n%---------------------%\n% eq:exact_st_ice\n\\begin{equation}\n N(t+\\Delta t_g) = \\exp(\\beta_{\\mathrm{id}} \\Delta t_g) \\overline{N}(t)  + \\exp \\left[\\left(\\beta_{\\mathrm{id}} + \\beta_{\\mathrm{is}}\\right) \\Delta t_g\\right] \\left[N(t)-\\overline{N}(t)\\right]\n, \\label{eq:exact_st_ice} \\end{equation}\nwhere $\\overline{N}$ is the average over all directions. As a result, for a spatially homogeneous field, \nthe spectrum exponentially tends to isotropy over a time scale $1/(\\beta_{\\mathrm{id}})$.\n", "meta": {"hexsha": "20dc551f7a18da75c07e76632eedc6e9cca1f4f1", "size": 12621, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/num/source.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/num/source.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/num/source.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 47.4473684211, "max_line_length": 192, "alphanum_fraction": 0.6977260122, "num_tokens": 3907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4334587912280619}}
{"text": "% ================================================================\n%                          DOCUMENTO\n% ================================================================\n\n\\documentclass{scrbook}\n\n% ================================================================\n%                          PACCHETTI\n% ================================================================\n\n% dare una spiegazione\n\\usepackage{tikz}\n\\usetikzlibrary{arrows}\n\n% ??\n\\usepackage{amsmath,amssymb,amsthm,thmtools}\n\n% glossario\n\\usepackage{makeidx}\n\n% ??\n\\usepackage{mathtools} % per \\MoveEqLeft\n\n% QR-code\n\\usepackage{qrcode}\n\n\\usepackage{array} % per formattare le colonne di un tabular\n\n% ================================================================\n%                           ALIAS ?\n% ================================================================\n\n% sono presi da paolini\n% https://github.com/paolini/AnalisiUno/blob/master/AnalisiUno.tex\n\n\\newcommand{\\eps}{\\varepsilon}\n\\renewcommand{\\phi}{\\varphi}\n\\newcommand{\\loc}{\\mathit{loc}}\n\\newcommand{\\weakto}{\\rightharpoonup}\n\\newcommand{\\implied}{\\Longleftarrow}\n\\let\\subsetstrict\\subset\n\\renewcommand{\\subset}{\\subseteq}\n\\renewcommand{\\supset}{\\supseteq}\n\n% calligraphic letters\n\\newcommand{\\A}{\\mathcal A}\n\\newcommand{\\B}{\\mathcal B}\n\\newcommand{\\C}{\\mathcal C}\n\\newcommand{\\D}{\\mathcal D}\n\\newcommand{\\E}{\\mathcal E}\n\\newcommand{\\F}{\\mathcal F}\n\\newcommand{\\FL}{\\mathcal F\\!\\mathcal L}\n\\renewcommand{\\H}{\\mathcal H}\n\\newcommand{\\K}{\\mathcal K}\n\\renewcommand{\\L}{\\mathcal L}\n\\newcommand{\\M}{\\mathcal M}\n\\renewcommand{\\P}{\\mathcal P}\n\\renewcommand{\\S}{\\mathcal S}\n\\newcommand{\\U}{\\mathcal U} %% intorni\n\n% blackboard letters\n\\newcommand{\\CC}{\\mathbb C}\n\\newcommand{\\HH}{\\mathbb H}\n\\newcommand{\\KK}{\\mathbb K}\n\\newcommand{\\NN}{\\mathbb N}\n\\newcommand{\\QQ}{\\mathbb Q}\n\\newcommand{\\RR}{\\mathbb R}\n\\newcommand{\\TT}{\\mathbb T}\n\\newcommand{\\ZZ}{\\mathbb Z}\n\n\\newcommand{\\abs}[1]{{\\left|#1\\right|}}\n\\newcommand{\\Abs}[1]{{\\left\\Vert #1\\right\\Vert}}\n\\newcommand{\\enclose}[1]{{\\left( #1 \\right)}}\n\\newcommand{\\Enclose}[1]{{\\left[ #1 \\right]}}\n\\newcommand{\\ENCLOSE}[1]{{\\left\\{ #1 \\right\\}}}\n\\newcommand{\\floor}[1]{\\left\\lfloor #1 \\right\\rfloor}\n\\newcommand{\\ceil}[1]{\\left\\lceil #1 \\right\\rceil}\n\n\\newcommand{\\To}{\\rightrightarrows}\n\\renewcommand{\\vec}[1]{\\boldsymbol #1}\n\\newcommand{\\defeq}{:=}\n\\DeclareMathOperator{\\divergence}{div}\n\\renewcommand{\\div}{\\divergence}\n% \\DeclareMathOperator{\\ker}{ker}  %% already defined\n\\DeclareMathOperator{\\Imaginarypart}{Im}\n\\renewcommand{\\Im}{\\Imaginarypart}\n\\DeclareMathOperator{\\Realpart}{Re}\n\\renewcommand{\\Re}{\\Realpart}\n%\\DeclareMathOperator{\\arg}{arg}\n\\DeclareMathOperator{\\tg}{tg}\n\\DeclareMathOperator{\\arctg}{arctg}\n\\DeclareMathOperator{\\tgh}{tgh}\n\\DeclareMathOperator{\\settsinh}{settsinh}\n\\DeclareMathOperator{\\settcosh}{settcosh}\n\\DeclareMathOperator{\\setttgh}{setttgh}\n\\DeclareMathOperator{\\tr}{tr}\n\\DeclareMathOperator{\\im}{im}\n\\DeclareMathOperator{\\sgn}{sgn}\n\\DeclareMathOperator{\\diag}{diag}\n\n\\declaretheoremstyle[\nspaceabove=6pt, spacebelow=6pt,\npostheadspace=1em,\nqed=,\n%shaded={rulecolor=blue!20,rulewidth=1pt,bgcolor=blue!5}\n]{theorem_style}\n\n\\declaretheoremstyle[\nspaceabove=6pt, spacebelow=6pt,\npostheadspace=1em,\nqed=,\n%shaded={rulecolor=yellow!50,rulewidth=1pt,bgcolor=yellow!5}\n]{axiom_style}\n\n\\numberwithin{equation}{chapter}\n\\declaretheorem[name=Teorema,numberwithin=chapter]{theorem}\n\\declaretheorem[name=Lemma,sibling=theorem]{lemma}\n\\declaretheorem[name=Proposizione,sibling=theorem]{proposition}\n\\declaretheorem[name=Corollario,sibling=theorem]{corollary}\n\\declaretheorem[name=Paradosso,sibling=theorem]{paradox}\n\\declaretheorem[style=axiom_style,name=Assioma,sibling=theorem]{axiom}\n\\declaretheorem[name=Definizione,sibling=theorem]{definition}\n\\declaretheorem[style=exercise_style,name=Esempio,sibling=theorem]{example}\n\\declaretheorem[style=exercise_style,name=Esercizio,sibling=theorem]{exercise}\n\\declaretheorem[style=exercise_style,name=Osservazione,sibling=theorem]{remark}\n\n% ================================================================\n%                           DOCUMENTO\n% ================================================================\n\n% inizio documento\n\\begin{document}\n\n% definizione titolo\n\\title{Formule utili\\\\\\mbox{}\\\\\n\\qrcode{https://github.com/i-friends/mah_tips}\n}\n\\author{Luca Ciucci e chi altro si vuole aggiungere}\n\\maketitle% genera titolo\n\n\\section{Introduction}\nHere is the text of your introduction.\n\n\\begin{equation}\n\\A\\AA\n    \\label{simple_equation}\n    \\alpha = \\sqrt{ \\beta }\n\\end{equation}\n\n\\subsection{Subsection Heading Here}\nWrite your subsection text here.\n\n\n\\section{Conclusion}\nWrite your conclusion here.\n\n\\include{chapters/analisi}\n\n\\end{document}", "meta": {"hexsha": "a0d6182e220f436c958511577961604433c66110", "size": 4681, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tips.tex", "max_stars_repo_name": "i-friends/mah_tips", "max_stars_repo_head_hexsha": "890c092646bd1381e9ed999d0f991c6351aaa4bf", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tips.tex", "max_issues_repo_name": "i-friends/mah_tips", "max_issues_repo_head_hexsha": "890c092646bd1381e9ed999d0f991c6351aaa4bf", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tips.tex", "max_forks_repo_name": "i-friends/mah_tips", "max_forks_repo_head_hexsha": "890c092646bd1381e9ed999d0f991c6351aaa4bf", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4402515723, "max_line_length": 79, "alphanum_fraction": 0.6524246956, "num_tokens": 1378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.4334587912280619}}
{"text": "\\section{The high energy $\\gamma$-nucleon and $\\gamma$-nucleus\n interactions.}\n \n\\hspace{1.0em}We consider the following kinematic \nvariables for $\\gamma$-nucleon\nscattering: the Bjorken-$x$ variable defined as $x=Q^2/2m\\nu$ with $Q^2$, $\\nu$\nand $m$ the photon virtuality, the photon energy and nucleon mass,\nrespectively.\nThe the squared total energy of the $\\gamma$-nucleon system is given by\n$s=Q^2(1-x)/x + m^2$. We restrict consideration to\n the range of small $x$-values and  $Q^2$ is much\nless than $s$.\n\nThe Generalized Vector Dominance Model (GVDM) \\cite{BSY78}\n assumes that the virtual photon \nfluctuates into intermediate $q\\bar{q}$-states $V$ of mass $M$ which\n subsequently may \ninteract with a nucleon $N$. \nThus the total photon-nucleon cross section\n can be expressed by a relation \\cite{PRW95}:\n\\begin{equation}\n\\begin{array}{c}\n\\label{HEGI1}\\sigma_{\\gamma N}(s,Q^2)=4\\pi\\alpha_{em}\\int_{M^2_0}^{M^2_{1}}\ndM^2D(M^2)\\times \\\\\n\\times (\\frac{M^2}{M^2+Q^2})^2(1+\\epsilon\\frac{Q^2}{M^2})\\sigma_{VN}(s,Q^2),\n\\end{array}\n\\end{equation}\nwhere integration over $M^2$ should be performed between $M^2_0=4m^2_{\\pi}$\n and $M^2=s$.\nHere $\\alpha_{em} = e^2/4\\pi = 1/137$ and the density\n of $q\\bar{q}$-system per\nunit mass-squared is given by\n\\begin{equation}\n\\label{HEGI2}D(M^2)= \\frac{R_{e^{+}e^{-}}(M^2)}{12\\pi^2M^2},\n\\end{equation}\n\\begin{equation}\n\\label{HEGI3} R_{e^{+}e^{-}}(M^2)=\\frac{\\sigma_{e^{+}e^{-}\\rightarrow\nhadrons}(M^2)}{\\sigma_{e^{+}e^{-}\\rightarrow\n\\mu^{+}\\mu^{-}}(M^2)}\\approx 3\\Sigma_{f}e^2_{f},\n\\end{equation}\nwhere $e^2_{f}$ the squared charge of quark with flavor $f$. \n$\\epsilon$ is the\nratio between the fluxes of longitudinally\n and transversally polarized photons.\n\nSimilarly the\n inelastic cross section for the scattering of a $\\gamma$ with virtuality\n$Q^2$ and with  a nucleus $A$ at impact parameter $B$ \nand the $\\gamma$-nucleon c.m.\nenergy squared $s$ is given by \\cite{ERR97}:\n\\begin{equation}\n\\begin{array}{c}\n\\label{HEGI4}\\sigma_{\\gamma A}(s,Q^2,B)=4\\pi\\alpha_{em}\\int_{M^2_0}^{M^2_{1}}\ndM^2D(M^2)\\times \\\\\n\\times (\\frac{M^2}{M^2+Q^2})^2(1+\\epsilon\\frac{Q^2}{M^2})\\sigma_{VA}(s,Q^2,B),\n\\end{array}\n\\end{equation}\n\nTo calculate $\\gamma$-nucleon or $\\gamma$-nucleus inelastic cross sections \nwe need model for the $M^2$-, \n $Q^2$- and $s$-dependence of the $\\sigma_{VN}$ or $\\sigma_{VA}$. For \n these we  apply the \nGribov-Regge approach, similarly as it was done for $h$-nucleon or $h$-nucleus \ninelastic cross sections.\n\nThe \n effective cross section for the interaction of a $q\\bar{q}$-system with\nsquared mass $M^2$ with nucleus for the coherence length\n\\begin{equation}\n\\label{HEGI5} d=\\frac{2\\nu}{M^2+Q^2}\n\\end{equation}\nexceeding the average distance between two nucleons\ncan be written as follows\n\\begin{equation}\n\\begin{array}{c}\n\\label{HEGI6}\\sigma_{V A}(s,Q^2,B)=\\int \\prod_{i=1}^{A} \nd^3 r_i\\rho_A({\\bf r}_i)\n\\times \\\\\n\\times (1 - |\\prod_{i=1}^{A}[1-u(s,Q^2,M^2, b^2_i)]|^2).\n\\end{array}\n\\end{equation}\nHere the amplitude (eikonal) \n$u(s,Q^2,M^2, b^2_i)$ for the interaction of \nthe hadronic fluctuation with $i$-th nucleon \nis given by \\cite{ERR97}\n\\begin{equation}\n\\begin{array}{c}\n\\label{HEGI7}u(s,Q^2,M^2,{\\bf b}_i)=\n\\frac{\\sigma_{VN}(s,Q^2,M^2)} {8 \\pi \\lambda(s,Q^2,M^2)} \\times \\\\\n\\times (1-i \\rho \\exp{[-\\frac{b^2}{4\\lambda(s,Q^2,M^2)}]},\n\\end{array}\n\\end{equation}\nwhere $\\rho\\approx 0$ is the ratio of real and imaginary parts of scattering \namplitude at $0$ angle.\nThe amplitude parameters: the effective $q\\bar{q}$-nucleon cross section  \n\\begin{equation}\n\\label{HEGI8} \\sigma_{VN}(s,Q^2,M^2)=\\frac{\\tilde{\\sigma}_{VN}(s,Q^2)}{M^2+Q^2+C^2},\n\\end{equation}\nwhere $C^2=2$ \\ GeV$^2$,\nand\n\\begin{equation}\n\\label{HEGI9}\\lambda(s,Q^2,M^2)=2+\\frac{m^2_{\\rho}}{M^2+Q^2} + \n\\alpha_{P}^{\\prime}\n\\ln{(\\frac{s}{M^2+Q^2})}. \n\\end{equation}\nThe values of $\\tilde{\\sigma}_{VN}(s,Q^2)$ are calculated in paper\n\\cite{ERR97}.\nIt was shown \\cite{ERR97} that $Q^2$ dependence of $\\sigma_{VN}(s,Q^2)$ \nis very week at $Q^2 < m^2_{rho} + C^2$, where $m_{\\rho}$ is \n$\\rho$-meson mass, and we omitted this dependence. We also use \n$\\sigma_{VN}(s,Q^2)$ calculated  in \\cite{ERR97} at $M^2=m^2_{rho}$.\n\n If coherence length is smaller that an internuclear distance integrated \nover $B$ then cross section \n$\\sigma_{VA}=A\\sigma_{VN}$.\n\n", "meta": {"hexsha": "6c0316ed4164831239ffcc2d277cf29f05874648", "size": 4274, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant4/hadronic/theory_driven/GammaInteraction/HighEnergyGammaInteraction.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant4/hadronic/theory_driven/GammaInteraction/HighEnergyGammaInteraction.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant4/hadronic/theory_driven/GammaInteraction/HighEnergyGammaInteraction.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.5299145299, "max_line_length": 84, "alphanum_fraction": 0.6799251287, "num_tokens": 1655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4334587912280619}}
{"text": "\\section{Closed-loop \\tuner for asynchronous training}\n\\label{sec:async_app}\nIn Section~\\ref{sec:async_tuner}, we briefly discuss the closed-loop momentum control mechanism in \\asynctuner. In this section, after presenting more preliminaries on asynchrony, we show with details on the mechanism: \nit measures the dynamics on a running system and controls momentum with a negative feedback loop.\n\\paragraph{Preliminaries}\nAsynchrony is a popular parallelization technique \\citep{recht2011hogwild} that avoids synchronization barriers.\nWhen training on $M$ asynchronous workers, staleness (the number of model updates between a worker's read and write operations) is on average $\\tau=M-1$,\ni.e., the gradient in the SGD update is delayed by $\\tau$ iterations as $\\nabla f_{S_{t - \\tau}}(x_{t - \\tau} )$.\nAsynchrony yields faster steps, but can\nincrease the number of iterations to achieve the same solution,\na tradeoff between hardware and statistical \nefficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n\\citet{mitliagkas2016asynchrony} interpret asynchrony as added momentum dynamics.\nExperiments in \\citet{hadjis2016omnivore} support this finding, and demonstrate that reducing algorithmic momentum can compensate for asynchrony-induced momentum\nand significantly reduce the number of iterations for convergence.\nMotivated by that result, we use the model\nin~\\eqref{equ:exp_async_update_app}, where the total momentum, $\\mu_T$, includes both asynchrony-induced and algorithmic  momentum, $\\mu$, in~\\eqref{eqn:momentum_gd}.\n\\begin{equation}\n\t\\mathbb{E}[ x_{t+1} - x_t ] \n\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n\\label{equ:exp_async_update_app}\n\\end{equation}\nWe will use this expression to design an estimator for the value of total momentum, $\\hat{\\mu}_T$.\nThis estimator is a basic building block of \\asynctuner, that {\\em removes the need to manually compensate for the effects of asynchrony}.\n\n\n\n\\paragraph{Measuring the momentum dynamics}\n\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\nEquation~\\eqref{equ:exp_async_update} gives an estimate of $\\hat{\\mu}_T$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update}.\n\\begin{align}\n\\hat{\\mu}_T\n\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n\t\t\t\t\t\\right)\n\\label{eqn:momentum_measurement}\n\\end{align}\nWe use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \nThis way we get a total momentum measurement from each variable; \nthe median combines them into a more robust estimate.\n\n\\paragraph{Closing the asynchrony loop}\nGiven a reliable measurement of $\\mu_{T}$, \nwe can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n\\Asynctuner in Algorithm~\\ref{alg:async-algo} %(in Appendix~\\ref{sec:async_yf}) \nuses a simple negative feedback loop to achieve the adjustment.\n%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%Closing the loop, as we will see, improves performance significantly.\n%Note for asynchronous-parallel training, as the estimates and parameter tuning is unstable in the beginning when there are only a small number of iterations, we use initial learning $\\frac{1}{\\tau + 1}$ instead of $1.0$ to prevent overflow in the beginning. \n\n%\\begin{algorithm}[H]\n%\t\\caption{\\Asynctuner}\n%\t\\begin{algorithmic}[1]\n%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%\t\\For { $t\\gets1$ to $T$}\n%\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n%\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n%\t\\State $\\hat{\\mu_T} \n%\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n%\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n%\t\\EndFor\n%\\end{algorithmic}\n%\\label{alg:async-algo}\n%\\end{algorithm}\n\n\n\n\n%In Section~\\ref{sec:async_tuner}, we briefly discuss the mechanism of our designed \\Asynctuner in asynchronous-parallel setting. In this appendix, we expand the details in total momentum estimator, $\\hat{\\mu_T}$, and present the full \\Asynctuner in Algorithm~\\ref{alg:async-algo} with extensive discussion.\n%\\paragraph{Measuring the momentum dynamics}\n%Remember, we use the formula in~\\eqref{equ:exp_async_update_app} to model the momentum dynamics in asynchronous-parallel systems\n%\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\n%\\begin{equation}\n%\t\\mathbb{E}[ x_{t+1} - x_t ] \n%\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n%\\label{equ:exp_async_update_app}\n%\\end{equation}\n%Equation~\\eqref{eqn:momentum_measurement_app} gives an estimate of $\\hat{\\mu_T}$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update_app}.\n%\\begin{align}\n%\\hat{\\mu_T}\n%\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)\n%\\label{eqn:momentum_measurement_app}\n%\\end{align}\n%We use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \n%This way we get a total momentum measurement from each variable; \n%the median combines them into a more robust estimate.\n%\n%%\\label{subsec:closed_loop_YF}\n%%\\begin{figure}\n%%\\centering\n%%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%%\t\\caption{\n%%\tMomentum dynamics on CIFAR100 ResNet.\n%%\tRunning \\tuner, total momentum is equal to algorithmic momentum in a synchronous setting (left). Total momentum is greater than algorithmic momentum on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%%\tUsing the momentum feedback mechanism of \\asynctuner, lowers algorithmic momentum and brings total momentum to match the target value on 16 asynchronous workers (right).\n%%\tRed dots are individual total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%%The solid red line is a running average of those estimates.\t\n%%\t}\n%%\t\\label{fig:we-can-measure}\n%%\\end{figure}\n%\n%\\paragraph{Closing the asynchrony loop}\n%Given a reliable measurement of $\\mu_{T}$, \n%we can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n%\\Asynctuner in Algorithm~\\ref{alg:async-algo} %(in Appendix~\\ref{sec:async_yf}) \n%uses a simple negative feedback loop to achieve the adjustment.\n%%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%%Closing the loop, as we will see, improves performance significantly.\n%%%Note for asynchronous-parallel training, as the estimates and parameter tuning is unstable in the beginning when there are only a small number of iterations, we use initial learning $\\frac{1}{\\tau + 1}$ instead of $1.0$ to prevent overflow in the beginning. \n%%\n%%%\\begin{algorithm}[H]\n%%%\t\\caption{\\Asynctuner}\n%%%\t\\begin{algorithmic}[1]\n%%%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%%\t\\For { $t\\gets1$ to $T$}\n%%%\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n%%%\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n%%%\t\\State $\\hat{\\mu_T} \n%%%\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n%%%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n%%%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%%%\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n%%%\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n%%%\t\\EndFor\n%%%\\end{algorithmic}\n%%%\\label{alg:async-algo}\n%%%\\end{algorithm}\n%%\n%\n%\n%\n\n\n\n\n\\begin{algorithm}[h]\n\t\\caption{\\Asynctuner}\n\t\\begin{algorithmic}[1]\n%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n\t\\For { $t\\gets1$ to $T$}\n\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n\t\\State $\\hat{\\mu_T} \n\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n\t\\EndFor\n\\end{algorithmic}\n\\label{alg:async-algo}\n\\end{algorithm}\n\n", "meta": {"hexsha": "b927bbd8a9776cebf7a56ad06d26c108e6fb0ad2", "size": 9965, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "async_app.tex", "max_stars_repo_name": "mitliagkas/dshs", "max_stars_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "async_app.tex", "max_issues_repo_name": "mitliagkas/dshs", "max_issues_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "async_app.tex", "max_forks_repo_name": "mitliagkas/dshs", "max_forks_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.0301204819, "max_line_length": 307, "alphanum_fraction": 0.7057701957, "num_tokens": 3127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4334587912280619}}
{"text": "%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[twoside,english]{paper}\n\\usepackage{lmodern}\n\\renewcommand{\\ttdefault}{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage[a4paper]{geometry}\n\\geometry{verbose,tmargin=3cm,bmargin=2.5cm,lmargin=2cm,rmargin=2cm}\n\\usepackage{color}\n\\usepackage{babel}\n\\usepackage{float}\n\\usepackage{bm}\n\\usepackage{amsthm}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{esint}\n\\usepackage[unicode=true,pdfusetitle,\n bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,\n breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]\n {hyperref}\n\\usepackage{breakurl}\n\\usepackage{mathrsfs}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n%% Because html converters don't know tabularnewline\n\\providecommand{\\tabularnewline}{\\\\}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{babel}\n\n\\@ifundefined{showcaptionsetup}{}{%\n \\PassOptionsToPackage{caption=false}{subfig}}\n\\usepackage{subfig}\n\\makeatother\n\n\\begin{document}\n\n\\title{Computation of the charged current structure functions}\n\n\\maketitle\n\n\\section{The structure of the observables}\n\nThe structure in terms of PDFs of the charged current (CC) structure\nfunctions is complicated by the mixing between down- and up-type\nquarks provided by the CKM matrix. As a first step, we write the\n$\\mathcal{O}(\\alpha_s)$ contribution to $F=F_2,F_L$ (we will consider\n$F_3$ later) in a convenient way as:\n\\begin{equation}\\label{compactNu}\nF^{\\nu} = \\sum_{U=u,c,t}\\sum_{D=d,s,b}|V_{UD}|^2\\left[C_\\pm\\left(D +\\overline{U}\\right) +2 C_gg\\right]\n\\end{equation}\nand:\n\\begin{equation}\\label{compactNub}\nF^{\\overline{\\nu}} = \\sum_{U=u,c,t}\\sum_{D=d,s,b}|V_{UD}|^2\\left[C_\\pm\\left(\\overline{D} +U\\right) +2 C_gg\\right] \n\\end{equation}\nwhere we have omitted the convolution symbol and an overall factor\n$2x$. At this order we don't have to worry about whether $C_+$ or\n$C_-$ has to be used because they coincide. However, in the following\nit will appear naturally which one has be used and where. One can\ncombine the expressions above conveniently as:\n\\begin{equation}\nF^{\\pm} \\equiv \\frac{F^{\\nu} \\pm F^{\\overline{\\nu}}}2=\\frac12\n\\sum_{U=u,c,t}\\sum_{D=d,s,b}|V_{UD}|^2\\left[C_\\pm\\left(D^\\pm\n    \\pm U^\\pm\\right) + P^{\\pm}4C_gg\\right]\n\\end{equation}\nwhere we have used the usual definition $q^{\\pm} = q\\pm\\overline{q}$\nand defined the projector:\n\\begin{equation}\nP^\\pm=\\frac{1\\pm1}2\\,.\n\\end{equation}\nIt should be noted that the subscript $\\pm$ to the quark coefficient\nfunction $C_\\pm$ because is now associated to each of $F^\\pm$.\n\nNow we need to express these observables in terms of PDFs in the\nevolution basis. The starting point is the relation:\n\\begin{equation}\\label{TranformationBella}\nq_i^\\pm = \\sum_{j=1}^6M_{ij}d^\\pm_j\\,,\n\\end{equation}\nwhere $d^\\pm_j$ belong to the QCD evolution basis, that is:\n$d^+_1=\\Sigma$, $d^+_2=-T_3$, $d^+_3=T_8$, $d^+_4=T_{15}$, $d^+_5=T_{24}$, and\n$d^+_6=T_{35}$ and $d^-_1=V$, $d^-_2=-V_3$, $d^-_3=V_8$, $d^-_4=V_{15}$,\n$d^-_5=V_{24}$, and $d^-_6=V_{35}$.  Note that here we are using the more\n``natural'' ordering for the distibutions $q_i=\\{d,u,s,c,b,t\\}$ rather\nthan that where $u$ comes before $d$; this is the reason of the minus\nsign in front of $T_3$ and $V_3$. The trasformation matrix $M_{ij}$\ncan be written as:\n\\begin{equation}\\label{TransDef}\n\\begin{array}{l}\n\\displaystyle M_{ij}=\\theta_{ji}\\frac{1-\\delta_{ij}j}{j(j-1)}\\quad j\\geq 2\\,,\\\\\n\\\\\n\\displaystyle M_{i1} = \\frac{1}{6}\\,,\n\\end{array}\n\\end{equation}\nwith $\\theta_{ji}=1$ for $j\\geq i$ and zero otherwise. In addition,\none can show that $M_{ij}$ is such that:\n\\begin{equation}\\label{eq:properties}\n\\sum_{j=1}^6M_{ij} = 0\\,,\\quad\\mbox{and}\\quad \\sum_{i=1}^6M_{ij} = \\delta_{1j}\\,.\n\\end{equation}\n\nUsing eq.~(\\ref{TranformationBella}) we can make the following\nidentifications:\n\\begin{equation}\nD^{\\pm} = q_{2j-1}^\\pm\\quad\\mbox{and}\\quad U^{\\pm} =\nq_{2j}^\\pm\\,,\\quad j=1,2,3\\,,\n\\end{equation}\nso that we can write:\n\\begin{equation}\nF^\\pm=\n\\frac12\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2\\left[C_\\pm\\left(q_{2j-1}^\\pm\n    \\pm q_{2i}^\\pm\\right) + 4P^{\\pm} C_g g\\right]\\,.\n\\end{equation}\nUsing the definition of $M_{ij}$ in eq.~(\\ref{TransDef}), we can\nrewrite $F^{\\pm}$ in terms of PDFs in the evolution basis as:\n\\begin{equation}\\label{eq:decompF2L}\nF^\\pm=\n\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 F_{ij}^\\pm\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{F2Ldef}\nF_{ij}^\\pm=\nC_g 2P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\pm \\frac16 d_1^\\pm\n+ C_\\pm\\sum_{k=2}^6\\frac{\\theta_{k,2j-1}(1-\\delta_{2j-1,k}k)\\pm \\theta_{k,2i}(1-\\delta_{2i,k}k) }{2k(k-1)}d_k^\\pm\\,.\n\\end{equation}\n\nEq.~(\\ref{F2Ldef}) is valid only for $F_2$ and $F_3$. In order to\nobtain a similar equation also for $F_3$, one needs to change sign to\nthe antiquark distributions, $i.e.$\n$\\overline{q}_i\\rightarrow - \\overline{q}_i$. In the QCD evolution\nbasis, this has the consequence of exchanging the $T$-like\ndistributions with the $V$-like ones, that is to say\n$d_k^+\\leftrightarrow d_k^-$. It is the easy to see that:\n\\begin{equation}\nF_3^\\pm=\n\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 F_{3,ij}^\\pm\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{F3def}\nF_{3,ij}^\\pm=\nC_g 2P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\mp \\frac16 d_1^\\pm\n+ C_\\pm\\sum_{k=2}^6\\frac{\\theta_{k,2j-1}(1-\\delta_{2j-1,k}k)\\mp \\theta_{k,2i}(1-\\delta_{2i,k}k) }{2k(k-1)}d_k^\\pm\\,.\n\\end{equation}\n\nIt is now useful to consider the inclusive structure functions and\nexploit the unitarity of the CKM matrix elements $V_{UD}$:\n\\begin{equation}\n\\sum_{i=1}^3|V_{2i,(2j-1)}|^2 = \\sum_{j=1}^3|V_{2i,(2j-1)}|^2 = 1\\quad\\Rightarrow\\quad \\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 = 3\\,.\n\\end{equation}\nSumming over $i$ and $j$ in eq.~(\\ref{eq:decompF2L}) and using\neq.~(\\ref{F2Ldef}), one obtains:\n\\begin{equation}\nF^\\pm=\nC_g 6P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\pm \\frac12 d_1^\\pm\n+ \\frac12 C_\\pm\\sum_{k=2}^6 d_k^\\pm\\sum_{l=1}^6(\\pm 1)^{l+1}M_{lk}\\,.\n\\end{equation}\nConsidering separately $F^+$ and $F^-$ and using\neq.~(\\ref{eq:properties}), one finds:\n\\begin{equation}\nF^+= C_g 6g + C_+^{\\rm S} \\frac12 d_1^+\n\\end{equation}\nand:\n\\begin{equation}\nF^-= \\frac12 C_-\\sum_{k=2}^6\\left[\\frac{P^+}{k-1}-\\frac{P^-}{k}\\right]d_k^-\\,,\n\\end{equation}\nwith the even/odd projectors defined as:\n\\begin{equation}\nP_k^{\\pm} = \\frac{1\\pm(-1)^k}{2}\\,.\n\\end{equation}\n\nIt should be pointed out that such simple expressions (independent of\nthe CMK matrix elements) is achievable only if it is possible to\nfactorize the non-singlet coefficient functions as implicitly done in\neqs.~(\\ref{F2Ldef}) and~(\\ref{F3def}). In fact, this is possible only\nin the ZM case in which the coefficient functions of each PDF\ncombination is the same.\n\nFor $F_3$ we find:\n\\begin{equation}\nF_3^+= C_g 6g + C_-^{\\rm S} \\frac12 d_1^-\n\\end{equation}\nand:\n\\begin{equation}\nF_3^-= \\frac12 C_+\\sum_{k=2}^6\\left[\\frac{P_k^+}{k-1}-\\frac{P_k^-}{k}\\right]d_k^+\\,.\n\\end{equation}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "0ee7cb838c1cb35a73ab123340590cf14af969e2", "size": 7158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/CCDIS.tex", "max_stars_repo_name": "intrepid42/apfelxx", "max_stars_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/CCDIS.tex", "max_issues_repo_name": "intrepid42/apfelxx", "max_issues_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/CCDIS.tex", "max_forks_repo_name": "intrepid42/apfelxx", "max_forks_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7641509434, "max_line_length": 135, "alphanum_fraction": 0.6856663873, "num_tokens": 2754, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.43341840443989454}}
{"text": "\\chapter{\\label{chap:deep-anns}Deep neural networks}\n\\xdef\\xvec{10mm}\n\\xdef\\yvec{15mm}\n\n\n\\emph{Deep learning} refers to a set of machine learning methods\nthat have recently been (re)popularized.\nOne of the important aspects of the deep learning is\nthe use of deeper neural networks with more than one hidden layers.\nThey have been successfully applied to many machine learning methods,\nand they are also the dominant approach used in\nthe natural language processing.\nDeep ANNs are not just fully-connected feed-forward networks\nwith multiple hidden layers as the one presented\nin Figure~\\ref{fig:deep-ff-network}.\nThe typical architectures used in the field involve\n\\emph{sparse} connectivity and \\emph{weight sharing}.\nThis lecture will introduce two common architectures,\n\\emph{recurrent networks} (RNNs) and \\emph{convolutional networks} (CNNs).\n\\begin{marginfigure}\n  \\centering\n%      \\tikzset{external/export next=false}\n      \\tikzsetnextfilename{deep-network}\n\t\t\t\\begin{tikzpicture}[shorten >=1pt,->,x=10mm, y=13mm,\n\t\t\t\t\t\t\t\t\t\t\t\t\tblue!40!black]\n\t\t\t\t\\tikzset{neuron/.style={draw,%\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcircle,%\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfill=black!20,%\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner sep=0,%\n                                minimum size=8}\n        };\n\n        \\foreach \\x in {1, ..., 4} {\n          \\node (n-0-\\x) at (\\x, 0) {};\n\t\t\t\t\t\\foreach \\y in {1, ..., 4} {\n\t\t\t\t\t\t\\node[neuron] (n-\\y-\\x) at (\\x, \\y) {};\n\t\t\t\t\t}\n        }\n        \\foreach \\x in {1, ..., 4} {\n\t\t\t\t\t\\foreach \\y in {1, ..., 4} {\n            \\pgfmathparse{int(\\y-1)}\n            \\xdef\\yy{\\pgfmathresult};\n            \\foreach \\xx in {1, ..., 4} {\n              \\draw (n-\\yy-\\xx) -- (n-\\y-\\x);\n            }\n\t\t\t\t\t}\n        }\n\n        \\node[yshift=-2mm] at (n-0-1) {$x_{1}$};\n        \\node[yshift=-2mm] at (n-0-4) {$x_{m}$};\n        \\node at (2.5, 0) {\\ldots};\n        \\node[neuron] (o-1) at (2, 5) {};\n        \\node[neuron] (o-2) at (3, 5) {};\n\n        \\foreach \\x in {1, ..., 4} {\n\t\t\t\t\t\\foreach \\y in {1, ..., 2} {\n              \\draw (n-4-\\x) -- (o-\\y);\n          }\n        }\n      \\end{tikzpicture}\n  \\caption{A deep feed-forward (fully-connected) network.}\n  \\label{fig:deep-ff-network}\n\\end{marginfigure}\n\nEarlier, we noted that an ANN with a single hidden layer is\na universal function approximator.\nThat is, it can approximate any computable function\nwith arbitrary precision.\nThen, a natural question to ask is `why should one use more than one layer?'\nThe first reason is related to the proof that ANNs with a single hidden layer\nare universal approximator.\nThe proof is very general,\nand there is no way to tell how many units one needs in\nthe single hidden layer.\nThe second reason is to do with the fact that\ncertain problems seem to suit well to ANN architectures\nwith multiple layer.\nThese involve problems where layers, or hierarchies of features are useful.\nA common example from image processing is,\nfor example,\nrecognizing objects that are composed of simple shapes,\nwhich are combination of even simpler lines or curves (e.g., edges in the image)\nwhich in turn are combinations of smaller parts,\nand so on.\nHowever,\nthe depth does not have to be only be for a hierarchy of features.\nAs we will see soon,\nit one can also represent time as depth in a deep network.\n\nAlthough there has been many interesting recent developments,\nmany of the ideas are developed during 1980's and 1990's.\nThe most important reason for the present success and the renewed interest\nis probably the developments in computing hardware.\nParticularly, availability of vector processors,\nsuch as graphical processing units (GPUs) in personal computers,\nthat perform linear algebra operations efficiently\nmade training large neural networks feasible.\nThe increased availability of labeled and unlabeled data is another reason.\nAt present,\nthe deep networks are the default or dominant method in many fields,\nincluding NLP.\nIn this lecture, we will introduce two architectures that are commonly used\nin NLP, namely RNNs and CNNs,\nand discuss some of the common practices and issues that arise\nwhile training deep networks.\n\n\\section{Recurrent neural networks}\n\n\\begin{marginfigure}\n  \\centering\n%  \\tikzset{external/export next=false}\n  \\tikzsetnextfilename{rnn-example}\n    \\begin{tikzpicture}[blue!50!black,x=\\xvec,y=\\yvec]\n      \\tikzset{neuron/.style={draw,%\n                              circle,%\n                              inner sep=1pt,%\n                              minimum size=6mm,%\n                              fill=black!20%\n        }\n      };\n      \\foreach \\x in {1, ..., 4} {\n        \\node (i-\\x) at (\\x, 0) {$x_{\\x}$};\n        \\node[neuron] (h-\\x) at (\\x, 1) {$h_{\\x}$};\n      }\n      \\node[neuron] (o) at (2.5, 2) {$y$};\n      \\foreach \\x in {1, ..., 4} {\n        \\foreach \\y in {1, ..., 4} {\n          \\draw[->] (i-\\x) -- (h-\\y);\n        }\n        \\draw[->] (h-\\x) -- (o);\n      }\n      \\draw[very thick] ([xshift=-2mm,yshift=-2mm]h-1.south west) \n        rectangle ([xshift=2mm,yshift=2mm]h-4.north east);\n      \\draw[very thick,->,>=stealth]\n        ([yshift=1mm,xshift=-2mm]h-1.north) arc (45:335:0.5);\n    \\end{tikzpicture}\n  \\caption{A schematic representation of a recurrent network.\n    The thick recurrent link on the hidden layer indicates\n    connections from each hidden unit to every hidden unit\n    (including itself).\n  }\n  \\label{fig:rnn-example}\n\\end{marginfigure}\nRecurrent neural networks (RNNs) are sequence learning models.\nUnlike feed-forward networks which only has a forward flow of information\nduring prediction,\nRNNs include (time-delayed) loops.\nFigure~\\ref{fig:rnn-example} presents a typical RNN.\nWithout the thick recurrent link presented, the RNN is simply\na feed forward network.\nWhat makes RNNs special is the backwards loop over the hidden units.\nThis makes an RNN to use the information in the previous hidden states\nas well as the current input.\nHence, although the RNNs process a single input item (e.g., word)\nat a time, they have a memory,\nthey may make use of the information from the past observations\n(e.g., earlier words).\n\n\\begin{marginfigure}\n  \\centering\n%      \\tikzset{external/export next=false}\n      \\tikzsetnextfilename{rnn-elman-network}\n      \\begin{tikzpicture}[blue!50!black,x=8mm]\n        \\tikzset{layer/.style={draw,%\n                               inner sep=1pt,%\n                               minimum width=20mm,%\n                               minimum height=7mm%\n          }\n        };\n\n        \\node[layer,draw=none] (inp) at (0,0) {Input};\n        \\node[layer,fill=black!20,left=8mm of inp] (c) {Context units};\n        \\node[layer,fill=black!20,above=1cm of inp] (h) {Hidden units};\n        \\node[layer,fill=black!20,above=1cm of h] (o) {Output units};\n        \\draw[very thick,->,shorten >=1pt,>=stealth] (inp) -- (h);\n        \\draw[very thick,->,shorten >=1pt,>=stealth] (h) -- (o);\n        \\draw[very thick,->,shorten >=1pt,>=stealth] (c) -- (h);\n        \\draw[red,yshift=1mm,inner sep=0pt,minimum width=9mm,minimum height=5mm,very thick,->,>=stealth] (h.west) arc (90:158:2.2)\n          node[above,sloped,midway,black] {copy};\n      \\end{tikzpicture}\n  \\caption{Another schematic representation of a recurrent network,\n    which used describing simple recurrent networks\n    (SRNs, also known as Elman networks).\n    The link with label `copy' does not have any associated weights.\n  }\n  \\label{fig:srn}\n\\end{marginfigure}\nAnother way to look at a recurrent network,\noften used for introducing \\emph{simple recurrent networks}\n(SRNs) is to assume that we have a set of `context' units\nwhich are the copies of the hidden units from the past time step.\nThis is shown in Figure~\\ref{fig:srn},\nwhere the special link labeled `copy' does not have any learned weights,\nbut the other links,\nincluding the one from the context unit to the hidden units,\nhave weights that are learned.\nAs a result,\nthe hidden units can combine the information\nfrom the past hidden representation and the current input.\nThis representation should make it clear the forward operation of\nan RNN. \n\n\nIn an SRN, like the one presented in Figure~\\ref{fig:srn},\nit is also possible to apply the standard backpropagation (BP) algorithm,\nsince the weights that are learned are feed-forward.\nHowever, applying standard BP\nmeans that error is not backpropagated more than one time step.\nIn modern recurrent networks, \na modified version of the BP algorithm,\noften called \\emph{backpropagation through time} (BPTT), is used.\nTo understand the BPTT,\nit is useful to unfold, or unroll the network.\nAn unrolled recurrent network is presented in Figure~\\ref{fig:rnn-unrolled}.\n\\begin{figure}\n  \\centering\n%      \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{rnn-unrolled}\n    \\begin{tikzpicture}\n      \\tikzset{layer/.style={draw,%\n                             inner sep=1pt,%\n                             minimum width=12mm,%\n                             minimum height=8mm,%\n                             fill=black!20%\n        }\n      };\n      \\tikzset{ilayer/.style={layer,fill=white,rounded corners}\n      };\n\n      \\node[] (x0) {$\\vect{x}^{(0)}$};\n      \\node[right=of x0] (x1) {$\\vect{x}^{(1)}$};\n      \\node[right=of x1] (x2) {\\dots};\n      \\node[right=of x2] (x3) {$\\vect{x}^{(t-1)}$};\n      \\node[right=of x3] (x4) {$\\vect{x}^{(t)}$};\n      \\node[layer,above of=x0,yshift=5mm] (h0) {$h^{(0)}$};\n      \\node[layer,above of=x1,yshift=5mm] (h1) {$h^{(1)}$};\n      \\node[above of=x2,yshift=5mm] (h2) {\\ldots};\n      \\node[layer,above of=x3,yshift=5mm] (h3) {$h^{(t-1)}$};\n      \\node[layer,above of=x4,yshift=5mm] (h4) {$h^{(t)}$};\n      \\node[layer,above=10mm of h0] (y0) {$y^{(0)}$};\n      \\node[layer,above=10mm of h1] (y1) {$y^{(1)}$};\n      \\node[above=10mm of h2] (y2) {\\ldots};\n      \\node[layer,above=10mm of h3] (y3) {$y^{(t-1)}$};\n      \\node[layer,above=10mm of h4] (y4) {$y^{(t)}$};\n      \\foreach \\x in {0, ..., 4}{\n        \\ifthenelse{\\x = 2}{}{%\n          \\draw[very thick,->,shorten >=1pt,>=stealth,orange]\n            (x\\x) -- (h\\x);\n          \\draw[very thick,->,shorten >=1pt,>=stealth,blue]\n            (h\\x) -- (y\\x);\n        }\n        \\ifthenelse{\\x = 0}{}{%\n          \\pgfmathparse{int(int(\\x)-1)};\n          \\xdef\\prevx{\\pgfmathresult};\n          \\draw[very thick,->,shorten >=1pt,>=stealth]\n              (h\\prevx) -- (h\\x);\n        }\n      }\n    \\end{tikzpicture}\n  \\caption{An unrolled RNN.\n    The superscripts indicate the time steps.\n    Note that the weights represented with the links with the same color\n    are \\emph{shared}.\n  }\n  \\label{fig:rnn-unrolled}\n\\end{figure}\n\nThe representation in in Figure~\\ref{fig:rnn-unrolled} is describes the\nsame type of network described in Figure~\\ref{fig:rnn-example}.\nThe difference is, in Figure~\\ref{fig:rnn-unrolled},\nwe represent each time step separately.\nThis representation also turns the network into a deep feed-forward network.\nAnd application of the BP algorithm is also straightforward.\nThe error made at any time step is reflected the input and\nhidden layer representations before this time step.\nIt is also important to realize in Figure~\\ref{fig:rnn-unrolled} is that,\nalthough the network is deep, most parameters are shared.\n\nAlthough BPTT gives us a way to apply BP to recurrent networks,\nthe (time)depth in RNNs lead to an problem called \\emph{unstable gradients}.\nTo appreciate the problem,\nremember that updates applied to weights in each layer is \ncalculated using the chain rule of derivatives.\nAs a result, \nthe update applied to the weights in earlier stages of a deep network\nwill be composed of a large number long chain of (matrix) multiplications.\nMultiplying a series of (positive) numbers less than \\num{1}\nwill cause the error signal to be very small,\nslowing down learning, maybe to the extent that nothing is learned.\nSimilarly, multiplying a series of (positive) numbers greater than \\num{1}\nwill cause the error signal to be too large,\ncausing instabilities due to large weight updates.\nThe former case is called \\emph{vanishing gradients},\nand the latter is called \\emph{exploding gradients} in the literature.\n\nTo solve the exploding gradients,\noften a simple technique called \\emph{gradient clipping} is used.\nGradient clipping simply means truncating gradients\nlarger than a particular value to a fixed threshold.\nThe solution of the vanishing gradients is more involved.\n\n\\subsection{Gated recurrent networks}\nTo solve the vanishing gradient problem,\nand allow an RNN to learn through a longer time distance,\na type of RNNs that are called \\emph{gated RNNs} are used.\nWe will not go into the details of the gated recurrent networks in this class.\nHowever, we briefly mention two variants that are popular in the field.\n\n\\begin{marginfigure}\n  \\centering\n%    \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{lstm-cell}\n    \\begin{tikzpicture}[y=6mm,x=6mm,thick,font=\\scriptsize]\n      \\draw[rounded corners] (0,0) rectangle (6,5);\n      \\node[draw,inner sep=2pt] (n1) at (1,2) {$\\sigma_{f}$};\n      \\node[draw,inner sep=2pt] (n2) at (2,2) {$\\sigma_{i}$};\n      \\node[font=\\tiny,fill=gray!30,draw,inner sep=2pt] (n3) at (3,2) {tanh};\n      \\node[draw,inner sep=2pt] (n4) at (4,2) {$\\sigma_{o}$};\n      \\node[draw,circle,inner sep=0pt] (f) at (3,3) {$\\times$};\n      \\node[draw,circle,inner sep=0pt] (o) at (5,2) {$\\times$};\n      \\node[draw,circle,inner sep=0pt] (c1) at (1,4) {$\\times$};\n      \\node[draw,circle,inner sep=0pt] (c2) at (3,4) {$+$};\n      \\node[font=\\tiny,draw,ellipse,minimum width=2.5em,inner sep=1pt] (co) at (5,3) {tanh};\n      \\draw[->] (-0.2,4) -- (c1);\n      \\draw[->] (c1)   -- (c2);\n      \\draw[->] (c2)   -- (6.2,4);\n\n      \\draw[->,rounded corners] (-0.2,1) -- (4,1) -- (n4.south);\n      \\draw[->] (1,-0.2) -- (n1);\n      \\draw[->] (2,1) -- (n2);\n      \\draw[->] (3,1) -- (n3);\n\n      \\draw[->] (n1) -- (c1);\n      \\draw[->,rounded corners] (n2) -- (2,3) -- (f);\n      \\draw[->] (n3) -- (f);\n      \\draw[->] (f) -- (c2);\n\n      \\draw[->] (n4) -- (o);\n      \\draw[->] (5,4) -- (co);\n      \\draw[->] (co) -- (o);\n      \\draw[->,rounded corners] (o) -- (5,1) -- (6.2, 1);\n\n      \\node[anchor=east] at (-0.2,4) {$c^\\text{(t-1)}$};\n      \\node[anchor=east] at (-0.2,1) {$h^\\text{(t-1)}$};\n      \\node[anchor=west] at (6.2,4) {$c^\\text{(t)}$};\n      \\node[anchor=west] at (6.2,1) {$h^\\text{(t)}$};\n\n      \\node[anchor=north] at (1,-0.2) {$x^{(t)}$};\n    \\end{tikzpicture}\n  \\caption{A schematic representation an LSTM cell.\n    The drawing similar to the ones from\n    a \\href{https://colah.github.io/posts/2015-08-Understanding-LSTMs/}{blog post by Chris Olah}.\n  }\n  \\label{fig:lstm}\n\\end{marginfigure}\nThe \\emph{long-short-term memory} (LSTM) cell,\nwhich is presented in Figure~\\ref{fig:lstm},\ncontrols the information kept, added or removed in the hidden representation\nthrough a number of `gates'.\nThe LSTM keeps two vectors of hidden representations,\nthe one called the `hidden state' (`\\vect{h}' in the figure)\nand the other one is called the `cell state' (`\\vect{c}' in the figure).\nThe idea is the that the cell state is the keeps the memory,\nwhile a combination of the cell state, previous hidden state,\nand the current input is passed to the output layer.\nBoth the cell state and the hidden layer is also passed to the next\ntime step after a number of operations.\nThe unshaded square blocks in the figure are called gates.\nThey are simply ANN layers with sigmoid activation function.\nThe circles (and the ellipse) in the figure represent \nelement-wise vector operations.\nThe forget gate ($\\sigma_{f}$)\ncontrols what is removed (or kept) from the cell state\nand they control what is removed, and added to cell state\nbased on the previous hidden state and the current input.\nThe input gate ($\\sigma_{i}$) controls what is added to the cell state.\nAnd the output gate ($\\sigma_{o}$) controls the hidden unit output.\n\nThe LSTM and its variants has been used successfully\nin many sequence learning tasks.\nA somewhat simpler variant,\ncalled simply \\emph{gated recurrent unit} (GRU),\nhas also become quite popular,\nand likely to be found in many standard neural network tools and libraries.\nThe gated RNNs are complex models,\nthe success of one variant or the other differs in different applications.\nHowever, in for most uses, gated RNNs yield better results than simple RNNs.\n\n\\subsection{Different uses of RNNs}\n\nRNNs have been used in a number of different linguistic problems.\nThe architecture is flexible, and can be extended in many ways.\nHere, we briefly go through some of the common variations.\n\nA very common practice is to use \\emph{bidirectional} RNNs.%\nA bidirectional RNN is composed of two RNNs,\none run forward as we discussed above,\nand another one run backwards through the sequence. \nThe hidden representations from both RNNs are then combined\nand fed to the later layers in the network architecture.\nUnless the application requires online sequential processing,\nbidirectional networks are possible,\nand often perform better than unidirectional variants.\nA bidirectional RNN is shown in Figure~\\ref{fig:bidirectional-rnn}.\n\\begin{marginfigure}\n  \\centering\n%    \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{rnn-bidirectional}\n    \\begin{tikzpicture}[x=5mm]\n      \\tikzset{layer/.style={draw,%\n                             inner sep=1pt,%\n                             minimum width=6mm,%\n                             minimum height=4mm,%\n                             fill=black!20%\n        }\n      };\n      \\tikzset{ilayer/.style={layer,fill=white,rounded corners}\n      };\n\n      \\node[font=\\scriptsize] (x0) {$\\vect{x}^\\text{(t-1)}$};\n      \\node[font=\\scriptsize,right=6mm of x0] (x1) {$\\vect{x}^\\text{(t)}$};\n      \\node[font=\\scriptsize,right=6mm of x1] (x2) {$\\vect{x}^\\text{(t+1)}$};\n\n      \\node[layer,above of=x0,yshift=5mm] (h0) {};\n      \\node[layer,above of=x1,yshift=5mm] (h1) {};\n      \\node[layer,above of=x2,yshift=5mm] (h2) {};\n\n      \\node[layer,above of=h0,yshift=5mm] (hh0) {};\n      \\node[layer,above of=h1,yshift=5mm] (hh1) {};\n      \\node[layer,above of=h2,yshift=5mm] (hh2) {};\n\n      \\node[font=\\scriptsize,layer,above=8mm of hh0] (y0) {$y^\\text{(t-1)}$};\n      \\node[font=\\scriptsize,layer,above=8mm of hh1] (y1) {$y^\\text{(t)}$};\n      \\node[font=\\scriptsize,layer,above=8mm of hh2] (y2) {$y^\\text{(t-1)}$};\n\n      \\foreach \\x in {0, 1, 2} {\n        \\draw[->,>=stealth] (x\\x) -- (h\\x);\n        \\draw[->,>=stealth] (hh\\x) -- (y\\x);\n      }\n\n      \\draw[->,>=stealth] ([xshift=-5mm]h0.west) -- (h0);\n      \\draw[->,>=stealth] (h0) -- (h1);\n      \\draw[->,>=stealth] (h1) -- (h2);\n      \\draw[->,>=stealth] (h2) -- ([xshift=5mm]h2.east);\n\n      \\draw[->,>=stealth] (hh0) -- ([xshift=-5mm]hh0.west);\n      \\draw[->,>=stealth] (hh2) -- (hh1);\n      \\draw[->,>=stealth] (hh1) -- (hh0);\n      \\draw[->,>=stealth] ([xshift=5mm]hh2.east) -- (hh2);\n\n      \\draw[->] (x0) to[bend left=30] (hh0);\n      \\draw[->] (x1) to[bend left=30] (hh1);\n      \\draw[->] (x2) to[bend left=30] (hh2);\n      \\draw[->] (h0) to[bend right=35] (y0);\n      \\draw[->] (h1) to[bend right=35] (y1);\n      \\draw[->] (h2) to[bend right=35] (y2);\n%      \\draw[->,>=stealth] (x0.north west) arc (210:135:1.9);\n%      \\draw[->,>=stealth] (x1.north west) arc (210:135:1.9);\n%      \\draw[->,>=stealth] (x2.north west) arc (210:135:1.9);\n%      \\draw[->,>=stealth] ([yshift=-2mm]h0.north east)\n%        arc[start angle=-30, end angle=45, radius=2.2];\n%      \\draw[->,>=stealth] ([yshift=-2mm]h1.north east)\n%        arc[start angle=-30, end angle=45, radius=2.2];\n%      \\draw[->,>=stealth] ([yshift=-2mm]h2.north east)\n%        arc[start angle=-30, end angle=45, radius=2.2];\n\n%      \\node at ([xshift=-3cm]h0.west) {Forward states};\n%      \\node at ([xshift=-1cm]h0.west) {\\ldots};\n%      \\node at ([xshift=1cm]h2.east) {\\ldots};\n%      \\node at ([xshift=-3cm]hh0.west) {Backward states};\n%      \\node at ([xshift=-1cm]hh0.west) {\\ldots};\n%      \\node at ([xshift=1cm]hh2.east) {\\ldots};\n\n    \\end{tikzpicture}\n  \\caption{A bidirectional RNN.} \n  \\label{fig:bidirectional-rnn}\n\\end{marginfigure}\n\nRNNs can be used for a typical sequence model such as hidden Markov models,\nIn this case, the we use output of the RNN at each time step\nto predict a label as shown in Figure~\\ref{fig:rnn-unrolled}.\nSuch a network learns a one-to-one mapping\nbetween equal-length inputs and the outputs.\nThe output layer is typically a classification\n(e.g., using softmax activation).\nThis type of networks have many applications in NLP\ntypical examples including POS tagging, and named entity recognition (NER).\n\nAnother use of RNNs is depicted in Figure~\\ref{fig:rnn-many-to-one}.\nIn this case the intermediate representations build by the RNN \nis not used for any prediction.\nThe network builds a representation $h^{(t)}$ for the whole sequence,\nand this representation is used for assigning a label to the sequence.\nThis RNN configuration is used frequently for sequence classification tasks,\ne.g., text classification tasks like spam detection.%\n\\sidenote[][-3\\baselineskip]{A variation of this architecture,\n  where all the intermediate representations are combined somehow\n  for a single final prediction is also common.}\n\\begin{figure}\n  \\centering\n%    \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{rnn-many-to-one}\n  \\begin{tikzpicture}\n    \\tikzset{layer/.style={draw,%\n                           inner sep=1pt,%\n                           minimum width=12mm,%\n                           minimum height=8mm,%\n                           fill=black!20%\n      }\n    };\n    \\tikzset{ilayer/.style={layer,fill=white,rounded corners}\n    };\n\n    \\node[] (x0) {$\\vect{x}^{(0)}$};\n    \\node[right=of x0] (x1) {$\\vect{x}^{(1)}$};\n    \\node[right=of x1] (x2) {\\dots};\n    \\node[right=of x2] (x3) {$\\vect{x}^{(t-1)}$};\n    \\node[right=of x3] (x4) {$\\vect{x}^{(t)}$};\n    \\node[layer,above of=x0,yshift=5mm] (h0) {$h^{(0)}$};\n    \\node[layer,above of=x1,yshift=5mm] (h1) {$h^{(1)}$};\n    \\node[above of=x2,yshift=5mm] (h2) {\\ldots};\n    \\node[layer,above of=x3,yshift=5mm] (h3) {$h^{(t-1)}$};\n    \\node[layer,above of=x4,yshift=5mm] (h4) {$h^{(t)}$};\n\n    \\node[layer,above=10mm of h4] (y4) {$y^{(t)}$};\n    \\foreach \\x in {0, ..., 4}{\n      \\ifthenelse{\\x = 2}{}{%\n        \\draw[very thick,->,shorten >=1pt,>=stealth]\n          (x\\x) -- (h\\x);\n      }\n      \\ifthenelse{\\x = 0}{}{%\n        \\pgfmathparse{int(int(\\x)-1)};\n        \\xdef\\prevx{\\pgfmathresult};\n        \\draw[very thick,->,shorten >=1pt,>=stealth]\n            (h\\prevx) -- (h\\x);\n      }\n    }\n    \\draw[very thick,->,shorten >=1pt,>=stealth] (h4) -- (y4);\n  \\end{tikzpicture}\n  \\caption{An RNN for sequence classification.\n    Only the final representation built by the RNN is used for prediction.} \n  \\label{fig:rnn-many-to-one}\n\\end{figure}\n\nOn final standard variant that is interesting for NLP applications\ncalled a \\emph{sequence-to-sequence} (or seq2seq) network.\nIn fact, this is an encoder--decoder architecture,\nwhere both encoder and the decoder are recurrent networks.\nIn this setup, shown in Figure~\\ref{fig:rnn-seq2seq},\nthe encoder RNN builds a representation for the complete input sequence, \nwhich typically is terminated by a special end-of-sequence symbol.\nThe decoder's hidden layer is initialized using this representation,\nand it is expected to produce the output sequence,\nfollowed by the end-of-sequence symbol.\nA very common variation in many applications is \nto provide the previous output as input to the encoder\n(shown with the gray curved arrows in the figure).\nNote that we can train the network gold-standard output sequence.\nHowever, during prediction time, the model has to rely on its own output.\n\\begin{figure*}\n  \\centering\n%    \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{rnn-seq2seq}\n  \\begin{tikzpicture}[\n      minimum width=12mm,\n      minimum height=8mm,\n    ]\n    \\tikzset{layer/.style={draw,%\n                           inner sep=1pt,%\n                           minimum width=10mm,%\n                           minimum height=8mm,%\n                           fill=black!20%\n      }\n    };\n    %    \\tikzset{ilayer/.style={layer,fill=white,rounded corners}};\n\n    \\node[] (x0) {$\\vect{x}^{(0)}$};\n    \\node[right=of x0] (x1) {$\\vect{x}^{(1)}$};\n    \\node[right=of x1] (x2) {\\dots};\n    \\node[right=of x2] (x3) {$\\langle\\text{eos}\\rangle$};\n    \\node[right=of x3] (x4) {};\n    \\node[right=of x4] (x5) {};\n    \\node[right=of x5] (x6) {};\n    \\node[right=of x6] (x7) {};\n\n    \\node[layer,above=of x0] (h0) {};\n    \\node[layer,above=of x1] (h1) {};\n    \\node[above=of x2] (h2) {\\ldots};\n    \\node[layer,above=of x3] (h3) {};\n    \\node[layer,above=of x4] (h4) {};\n    \\node[above=of x5] (h5) {\\ldots};\n    \\node[layer,above=of x6] (h6) {};\n    \\node[layer,above=of x7] (h7) {};\n\n    \\node[layer,above=of h3.base] (y3) {$y^{(1)}$};\n    \\node[layer,above=of h4.base] (y4) {$y^{(2)}$};\n    \\node[above=of h5.base] (y5) {\\ldots};\n    \\node[layer,above=of h6.base] (y6) {$y^{(t)}$};\n    \\node[layer,above=of h7.base] (y7) {$\\langle\\text{eos}\\rangle$};\n    \\foreach \\x in {0, ..., 7}{\n      \\ifthenelse{\\x = 2 \\OR \\x > 3}{}{%\n        \\draw[thick,->,shorten >=1pt,>=stealth]\n          (x\\x) -- (h\\x);\n      }\n      \\ifthenelse{\\x = 0}{}{%\n        \\pgfmathparse{int(int(\\x)-1)};\n        \\xdef\\prevx{\\pgfmathresult};\n        \\draw[thick,->,shorten >=1pt,>=stealth]\n            (h\\prevx) -- (h\\x);\n      }\n    }\n    \\draw[gray,thick,->] (y3.north) \n      .. controls ++(45:3) and ++(45:-3) ..\n      (h4.south);\n    \\draw[gray,thick,->] (y6.north) \n      .. controls ++(45:3) and ++(45:-3) ..\n      (h7.south);\n    \\draw[thick,->,shorten >=1pt,>=stealth] (h4) -- (y4);\n    \\draw[thick,->,shorten >=1pt,>=stealth] (h3) -- (y3);\n  \\end{tikzpicture}\n  \\caption{A sequence-to-sequence model.}\n  \\label{fig:rnn-seq2seq}\n\\end{figure*}\n\nSequence-to-sequence networks similar to the one in Figure~\\ref{fig:rnn-seq2seq}\nare capable of transforming a sequence\nto another sequence with a different length.\nThey are used in many applications,\nprobably most popular application being machine translation.\nThe modern seq2seq models are generally more complex than\nthe one described above.  \nA very popular extension to such models,\ncalled an \\emph{attention mechanism}\nto provide the intermediate representations built by the encoder\nto the decoder time steps,\noften passing through another network component that learns\nwhat parts of the input is more important for the present prediction task.\nIt is also common to use deeper, stacked,\nRNN layers for both encoder and the decoder,\nand bidirectional RNNs for the encoder part of the network.%\n\\sidenote{Can we use a bidirectional layer for the decoder?}\n\n\\section{Convolutional networks}\n\nConvolutional neural networks (CNNs) are another type of popular ANN architecture.\nThey have become particularly popular in image processing tasks,\nbut they also made their way into language processing.\n\nConvolution is an operation, a filter, applied to a signal,\nwhich transforms it based on the neighbouring values at any point.\nIt has its roots in in signal processing,\nwhere it is typically applied to a continuous signal.\nHowever, for our purposes it is a filter that transforms each discrete unit\nbased on its neighbors.\n\n\\begin{marginfigure}\n  \\centering\n%    \\tikzset{external/export next=false}\n    \\tikzsetnextfilename{convolution-images}\n    \\begin{tikzpicture}[blue!50!black,x=2.8mm,y=2.8mm]\n%      \\draw[gray!50,very thin] (0,0) grid[step=1] (20,8);\n      \\draw[step=1] (0,0) grid[thin] (6,6);\n      \\draw[step=1] (8,3) grid[thin] (11,6);\n      \\draw[step=1] (13,1) grid[thin] (17,5);\n\n      \\xdef\\x{2}\n      \\xdef\\y{2}\n      \\draw[red,very thick,fill=red!40,opacity=0.2] \n        ($(\\x,\\y) + (-1, -1) $)  rectangle ($(\\x,\\y) + (2, 2)$);\n      \\draw[red,very thick,fill=red!40] \n        (\\x,\\y)  rectangle ($(\\x,\\y) + (1, 1)$);\n      \\draw[blue,very thick,fill=blue!40]\n        ($(\\x, \\y) + (12,0)$) rectangle ($(\\x, \\y) + (13,1)$);\n      \\draw[red] ($ (\\x, \\y) + (2,-1)$) -- (8,3);\n      \\draw[red] ($ (\\x, \\y) + (2,2)$) -- (8,6);\n      \\draw[blue] (11,3) -- ($ (\\x, \\y) + (12,0) $);\n      \\draw[blue] (11,6) -- ($ (\\x, \\y) + (12,1) $);\n\n      \\node[anchor=south,font=\\footnotesize] at (3, 6)\n        {Input ($\\textcolor{red}{\\vect{X}}$)};\n      \\node[anchor=south,font=\\footnotesize] at (9.5, 6)\n        {Filter ($\\vect{W}$)};\n      \\node[anchor=south,font=\\footnotesize] at (15, 6)\n        {Output ($\\textcolor{blue}{\\vect{Y}}$)};\n      \\node[anchor=south,font=\\footnotesize] at (9.5, 0)\n        {$\\textcolor{blue}{y_{i}} = \\sum\\limits_{i} w_{i} \\textcolor{red}{x_{i}}$};\n    \\end{tikzpicture}\n    \\caption{A demonstration of convolution in image processing.\n      Every pixel in the image is passed through a filter,\n      where the transformed value of the pixel is a weighted\n      combination of its original value and its neighbors.\n    }\\label{fig:image-convolution}\n\\end{marginfigure}\nIn image processing a filter is typically a square matrix,\nthat slides over the complete image to transform every pixel,\nas demonstrated in Figure~\\ref{fig:image-convolution}.\nNote that the convolution is not well-defined on the pixels\nat the edges of the image.\nIn practice, one `pads' the images\n(with values appropriate for the filter applied)\nto obtain a transformed image with the same size as the original image.\nOtherwise, the result would be a smaller image (as in Figure~\\ref{fig:image-convolution}).\n\n\\begin{marginfigure}\n  \\centering\n  \\begin{tcolorbox}[center upper,center lower,]\n      Blurring\n      \\[\n        \\frac{1}{16} \\begin{bmatrix}\n          1 & 2 & 1 \\\\\n          2 & 4 & 2 \\\\\n          1 & 2 & 1 \\\\\n        \\end{bmatrix}\n      \\]\n      \\tcblower\n     Edge detection\n      \\[\n        \\begin{bmatrix}\n          -1 & -1 & -1 \\\\\n          -1 &  8 & -1 \\\\\n          -1 & -1 & -1 \\\\\n        \\end{bmatrix}\n      \\]\n  \\end{tcolorbox}\n  \\caption{Two example filters (convolutions) used in image processing:\n  blurring (top) and edge detection (bottom).}\n  \\label{fig:image-covolution-examples}\n\\end{marginfigure}\nIn standard image processing software many of the operations on images are\ndone through convolution operations.\nFigure~\\ref{fig:image-covolution-examples} shows two common filters used\nby image processing software.\nThe first one, blurring, replaces a pixel\nwith a weighted average of its neighborhood,\nmaking all pixels similar to their neighbors\nand removing the details from the image.\nThe second filter shown, edge detection,\nis probably more useful for machine learning.\nThe filter replaces pixels with similar intensities with its neighbors\nwith numbers close to 0,\nwhile the pixels that are different from their neighbors\nare assigned to larger intensity values.\n\nThe fixed filters demonstrated above are useful (and used)\nin image processing software.\nHowever, for machine learning we want to \\emph{learn} these filters.\nIn a typical CNN application, we learn many such filters,\ntrained on the task we are interested in.%\n\\sidenote{Note that the values in the filter matrices above are\n  the parameters that we want to learn.}\nThe hope is that each filter learns some useful aspect of the data.\nFor example, edges with different slants from given pixels.\nIt is also very common to stack the convolutional layers.\nIn a nutshell,\nthe idea with multiple layers of convolution is to\nlearn a hierarchy of filters.\nContinuing with the examples with edges with different orientations,\nanother layer build on edges may learn useful (geometric) shapes,\nand yet another layer may recognize object composed of these shapes,\nand so on.\nFigure~\\ref{fig:convolution-layers} first two stages\nof this hypothetical scenario.\nIf our aim is, for example, predicting whether an image contains people,\nconvolutions over the shapes\nshown in the lower part of Figure~\\ref{fig:convolution-layers}\nare likely to  be useful.\n\\begin{marginfigure}\n  \\centering\n  \\begin{tcolorbox}[center upper,center lower,]\n          \\tikzset{external/export next=false}\n%          \\tikzsetnextfilename{cnn-image-example-features1}%\n          \\tikz[x=5mm,y=5mm,thick]%\n            {\\draw (0,0) -- (0,1)\n                   (1,1) -- (2,0)\n                   (3,0) -- (4,1)\n                   (5, 0.5) -- (6, 0.5);}\n    \\tcblower\n          \\tikzset{external/export next=false}\n%          \\tikzsetnextfilename{cnn-image-example-features2}%\n            \\tikz[x=5mm,y=5mm,thick]%\n            {\\draw (0,0) rectangle (1,1);\n             \\draw (2,0.5) -- (3,0) -- (4,0.5) -- (3, 1) -- cycle;\n             \\draw (5.3,0) -- (5.4,1)\n                   (5.8, 1) -- (6.0, 0)\n                   (5.5, 0) -- (5.6, 0.6) -- (5.7, 0);}\n  \\end{tcolorbox}\n  \\caption{Results of possible applications of layers of convolutions.\n    First layer of convolution may learn different filters for\n    edges with different orientations (top),\n    while another layer built on it may learn geometric shapes built with them\n    (bottom).\n    Yet another layer may be used to detect objects,\n    like houses, windows, people,\n    based on these shapes (not shown in the figure).\n  }\n  \\label{fig:convolution-layers}\n\\end{marginfigure}\n\nWe discussed convolutions in the context of 2D objects (images),\nsince they are most commonly used in this area.\nHowever, they can easily be extended to 3D objects\n(e.g., for processing videos),\nor applicable to 1D sequences (for speech and language processing).\n\n\\begin{marginfigure}\n  \\centering\n  \\tikzset{external/export next=false}\n    \\begin{tikzpicture}[blue!50!black,\n                        x=5mm, y=5mm,\n                        minimum size=5mm,\n                        node distance=6mm,\n                        inner sep=0pt]\n      \\tikzset{nedge/.style={>=stealth,->,thick}}\n      \\tikzset{elabel/.style={midway,\n                              sloped,\n                              above,\n                              yshift=-1ex,\n                              font=\\footnotesize}}\n      \\node (x1) {$x_{1}$};\n      \\node[above=15mm of x1] (h1) {};\n      \\foreach \\x in {2, ..., 5} {%\n        \\pgfmathparse{int(\\x)-1};\n        \\xdef\\prevx{\\pgfmathresult};\n        \\node[right=of x\\prevx] (x\\x) {$x_{\\x}$};\n        \\ifthenelse{\\x = 5}{}{%\n          \\node[right=of h\\prevx,circle,fill=black!25] (h\\x) {$h_{\\x}$};\n        }\n      };\n      \\draw[nedge,blue] (x1) -- (h2)\n        node[elabel,xshift=-3mm] {$w_{\\text{-}1}$};\n      \\draw[nedge] (x2) -- (h2)\n        node[elabel] {$w_{0}$};\n      \\draw[nedge,blue] (x2) -- (h3)\n        node[elabel,xshift=-3mm] {$w_{1}$};\n      \\draw[nedge,red] (x3) -- (h2)\n        node[elabel,xshift=-3mm] {$w_{1}$};\n      \\draw[nedge] (x3) -- (h3)\n        node[elabel] {$w_{0}$};\n      \\draw[nedge,blue] (x3) -- (h4)\n        node[elabel,xshift=-3mm] {$w_{\\text{-}1}$};\n      \\draw[nedge,red] (x4) -- (h3)\n        node[elabel,xshift=-3mm] {$w_{1}$};\n      \\draw[nedge] (x4) -- (h4) node[elabel] {$w_{0}$};\n      \\draw[nedge,red] (x5) -- (h4)\n        node[elabel,xshift=-3mm] {$w_{1}$};\n    \\end{tikzpicture}\n  \\caption{Demonstration of  1D convolution.\n    The weights indicated with the same colors are\n    the same regardless of their position in the sequence.\n  }\n  \\label{fig:covolution-1d}\n\\end{marginfigure}\nNow we look at the convolutions more closely,\nbut assuming that we work on a single-dimensional sequence.\nThe units in the sequence, for our purposes,\ncan be (representations of) words, characters, phonemes,\nor other linguistic objects.\nFigure~\\ref{fig:covolution-1d} shows convolutions applied to such a sequence.\nIf we were running this convolutional network on words,\nthe convolution would learn something (useful) about word trigrams.\nFor example, the final aim is sentiment classification,\nthis convolution would result in higher values at the hidden representation\nif for trigrams that are associated with negative or positive sentiments.\nThere are two aspects of the CNNs that set them apart\nfrom typical neural networks such as MLP.\nFirst, the weights are \\emph{shared},\nthe same filter is run through the entire sequence\nwithout modifying the weights during prediction.\nAnd second,\nthe input layer and the hidden layers are not fully connected.\nAs well as being suitable for picking certain features,\nthese aspects reduce the number of parameters learned,\nand complexity of the network.\nIn practice, many such filters\n(possibly with different input window size)\nused in combination with multiple layers of convolutions,\nand finally with a fully connected prediction layer,\ne.g., a sigmoid or softmax classifier.\n\n\\begin{marginfigure}\n  \\centering\n    \\tikzset{external/export next=false}\n%    \\tikzsetnextfilename{cnn-pooling}\n    \\begin{tikzpicture}[blue!50!black,\n                        x=5mm, y=5mm,\n                        minimum size=5mm,\n                        node distance=4mm,\n                        inner sep=0pt]\n      \\tikzset{nedge/.style={>=stealth,->,thick}}\n      \\tikzset{elabel/.style={midway,\n                              sloped,above,\n                              yshift=-1ex,\n                              font=\\footnotesize}}\n      \\node (x1) {$x_{1}$};\n      \\node[above=1cm of x1,circle,fill=black!25] (h1) {$h_{1}$};\n      \\node[above=1cm of h1] (hh1) {};\n      \\foreach \\x in {2, ..., 5} {%\n        \\pgfmathparse{int(int(\\x)-1)};\n        \\xdef\\prevx{\\pgfmathresult};\n        \\node[right=of x\\prevx] (x\\x) {$x_{\\x}$};\n        \\node[right=of h\\prevx,circle,fill=black!25] (h\\x) {$h_{\\x}$};\n        \\ifthenelse{\\x = 5}{}{%\n          \\node[right=of hh\\prevx,circle,fill=black!25]\n            (hh\\x) {$h_{\\prevx}^{'}$};\n        }\n      };\n      \\draw[nedge] (x1) -- (h1);\n      \\draw[nedge,blue] (x1) -- (h2);\n      \\draw[nedge,red] (x2) -- (h1);\n      \\draw[nedge] (x2) -- (h2);\n      \\draw[nedge,blue] (x2) -- (h3);\n      \\draw[nedge,red] (x3) -- (h2);\n      \\draw[nedge] (x3) -- (h3);\n      \\draw[nedge,blue] (x3) -- (h4);\n      \\draw[nedge,red] (x4) -- (h3);\n      \\draw[nedge] (x4) -- (h4);\n      \\draw[nedge,blue] (x4) -- (h5);\n      \\draw[nedge,red] (x5) -- (h4);\n      \\draw[nedge] (x5) -- (h5);\n\n      \n      \\draw[nedge] (h1) -- (hh2);\n      \\draw[nedge] (h2) -- (hh2);\n      \\draw[nedge] (h3) -- (hh2);\n      \\draw[nedge] (h2) -- (hh3);\n      \\draw[nedge] (h3) -- (hh3);\n      \\draw[nedge] (h4) -- (hh3);\n      \\draw[nedge] (h3) -- (hh4);\n      \\draw[nedge] (h4) -- (hh4);\n      \\draw[nedge] (h5) -- (hh4);\n\n      \\node[left=of h1,rotate=90,font=\\footnotesize] {Convolution};\n      \\node[left=of hh1,rotate=90,font=\\footnotesize] {Pooling};\n\n    \\end{tikzpicture}\n  \\caption{Demonstration of  pooling.\n  }\n  \\label{fig:cnn-pooling}\n\\end{marginfigure}\nReturning to the example of sentiment classification,\na CNN layer like the one in Figure~\\ref{fig:covolution-1d} will\ndiscover a trigram with high-sentiment content wherever it occurs\nin the sequence.\nHowever downstream classification layer need to still consider\nhidden layer activations as separate features.\nIn many problems,\nwe do not want this location sensitivity.\nFor example, a phrase like \\emph{not worth seeing} in a movie review\nis an indication of a negative sentiment wherever it appears.\nTo make the features learned by convolutions\n\\emph{location invariant}, a concept called \\emph{pooling} is applied.\nPooling simply calculates a statistics,\nmost commonly `maximum', over a range of its inputs.\nWhen it is applied to convolutions as in Figure~\\ref{fig:cnn-pooling},\nthe new features are relatively location invariant.\nAnother aspect of the pooling you to note is that,\nit is a fixed operation,\nthere are no weights to learned in the pooling layer.\n\nIf we apply the `max pooling',\nthe value of $h_{1}'$ in the figure is\nthe maximum of $h_{1}$, $h_{2}$ and $h_{3}$,\nwhich means if the convolution detects any interesting trigrams\nfrom $x_{1}$ to $x_{4}$, it $h_{1}'$ will indicate it.\nHence, to some extent, a classifier that uses\nthe output of the network shown in Figure~\\ref{fig:cnn-pooling}\nwill be insensitive to the location of the feature detected by the convolution.\nHowever, Figure~\\ref{fig:cnn-pooling} still retains some location sensitivity,\nwhich may be useful for some applications.\nFor example, for a face recognition network,\nit is likely important to detect eyes above a nose.\nIn problems where location is not useful at all\n(which is the case in many text classification examples)\none can pool over the complete convolution output,\npassing a single feature to the classifier from this filter.%\nRemember that we typically use many convolutions,\nhence, in this case,\nthe classifier will be given a single feature from each convolution.\n\n\\begin{marginfigure}\n  \\centering\n    \\tikzset{external/export next=false}\n%    \\tikzsetnextfilename{cnn-pooling}\n    \\begin{tikzpicture}[blue!50!black,\n                        x=5mm, y=5mm,\n                        minimum size=5mm,\n                        node distance=4mm,\n                        inner sep=0pt]\n      \\tikzset{nedge/.style={>=stealth,->,thick}}\n      \\tikzset{elabel/.style={midway,\n                              sloped,above,\n                              yshift=-1ex,\n                              font=\\footnotesize}}\n      \\node (x1) {$x_{1}$};\n      \\node[above=1cm of x1,circle,fill=black!25] (h1) {$h_{1}$};\n      \\foreach \\x in {2, ..., 5} {%\n        \\pgfmathparse{int(int(\\x)-1)};\n        \\xdef\\prevx{\\pgfmathresult};\n        \\node[right=of x\\prevx] (x\\x) {$x_{\\x}$};\n        \\node[right=of h\\prevx,circle,fill=black!25] (h\\x) {$h_{\\x}$};\n      };\n      \n      \\node[above=1cm of h2,circle,fill=black!25] (hh1) {$h_{1}^{'}$};\n      \\node[above=1cm of h4,circle,fill=black!25] (hh2) {$h_{2}^{'}$};\n\n      \\draw[nedge] (x1) -- (h1);\n      \\draw[nedge,blue] (x1) -- (h2);\n      \\draw[nedge,red] (x2) -- (h1);\n      \\draw[nedge] (x2) -- (h2);\n      \\draw[nedge,blue] (x2) -- (h3);\n      \\draw[nedge,red] (x3) -- (h2);\n      \\draw[nedge] (x3) -- (h3);\n      \\draw[nedge,blue] (x3) -- (h4);\n      \\draw[nedge,red] (x4) -- (h3);\n      \\draw[nedge] (x4) -- (h4);\n      \\draw[nedge,blue] (x4) -- (h5);\n      \\draw[nedge,red] (x5) -- (h4);\n      \\draw[nedge] (x5) -- (h5);\n\n      \n      \\draw[nedge] (h1) -- (hh1);\n      \\draw[nedge] (h2) -- (hh1);\n      \\draw[nedge] (h3) -- (hh1);\n      \\draw[nedge] (h3) -- (hh2);\n      \\draw[nedge] (h4) -- (hh2);\n      \\draw[nedge] (h5) -- (hh2);\n\n    \\end{tikzpicture}\n  \\caption{The same network presented in Figure~\\ref{fig:cnn-pooling},\n    but the pooling layer has a stride of \\num{3}.\n  }\n  \\label{fig:cnn-stride}\n\\end{marginfigure}\nFor both convolutions and pooling,\nthe examples we looked at so far cover the whole sequence\nby shifting the filter one unit at a time.\nIt is common to define a larger \\emph{stride},\nthat shifts the convolution or pooling over more\nthan one unit at a time.\nFigure~\\ref{fig:cnn-stride} repeats the network shown\nin Figure~\\ref{fig:cnn-pooling} with a stride of \\num{3} on the pooling layer.\nWith this configuration,\neach output of the pooling layer covers exactly half of the convolutions.\nHowever, note that due to hierarchical nature of the network,\nthey are affected by larger spans of input.\n\nMost CNNs used in practice are deep,\nresulting in diminishing numbers of features\nwhen successive convolution or pooling layers are\nstacked without \\emph{padding} as shown in Figure~\\ref{fig:cnn-no-padding}.\nThis is sometimes called \\emph{valid} padding,\nmeaning that each convolution is calculated on real data.\nHowever, it is a common practice to pad the input,\ntypically with \\num{0}s,\nso that the output of the network stays stable.\nFigure~\\ref{fig:cnn-padding} shows an example of padding applied\nto the same network.\nHere, each layer is padded from both sides with a single `imaginary' input.\nFor an image, this would mean padding the matrix from all sides.\nWith a stride of \\num{1},\npadding only one unit from all sides as in Figure~\\ref{fig:cnn-padding}\nresults in an output the same dimensions as the input.\nHence, it is often called \\emph{same} padding.\nWith a larger stride, however, this would result in a reduction\nin the output dimension more than expected from the stride.\nIn such cases it is an option to pad as many values as necessary\nto make sure that the output is of expected dimension,\nwhich is sometimes called \\emph{full} padding.\n\n\\begin{marginfigure}\n  \\centering\n      \\tikzset{external/export next=false}\n%      \\tikzsetnextfilename{cnn-padding}\n      \\begin{tikzpicture}[x=4mm,y=8mm,blue!50!black]\n        \\tikzset{nedge/.style={>=stealth,->}}\n        \\tikzset{neuron/.style={draw,%\n                                circle,%\n                                fill=black!20,%\n                                inner sep=0,%\n                                minimum size=8}\n        }\n          \\node[inner sep=0, minimum size=8] at (-1, 0) {};\n          \\foreach \\y in {0, ..., 4} {\n            \\pgfmathparse{int(\\y+1)};\n            \\xdef\\xstart{\\pgfmathresult};\n            \\pgfmathparse{int(9-\\y)};\n            \\xdef\\xend{\\pgfmathresult};\n            \\foreach \\x in {\\xstart, ..., \\xend} {\n              \\node[neuron] (n-\\x-\\y) at (\\x, \\y) {};\n              \\ifthenelse{\\y = 0}{}{%\n                \\pgfmathparse{int(\\y-1)};\n                \\xdef\\prevy{\\pgfmathresult};\n                \\pgfmathparse{int(\\x-1)};\n                \\xdef\\prevx{\\pgfmathresult};\n                \\pgfmathparse{int(\\x+1)};\n                \\xdef\\nextx{\\pgfmathresult};\n                \\draw[nedge] (n-\\prevx-\\prevy) -- (n-\\x-\\y);\n                \\draw[nedge] (n-\\x-\\prevy) -- (n-\\x-\\y);\n                \\draw[nedge] (n-\\nextx-\\prevy) -- (n-\\x-\\y);\n              }\n            }\n          }\n          \\node[inner sep=0, minimum size=8] at (10, 0) {};\n      \\end{tikzpicture}\n  \\caption{A deep CNN network without padding.}\n  \\label{fig:cnn-no-padding}\n\\end{marginfigure}\n\\begin{marginfigure}\n  \\centering\n      \\tikzset{external/export next=false}\n%      \\tikzsetnextfilename{cnn-padding}\n      \\begin{tikzpicture}[x=4mm,y=8mm,blue!50!black]\n        \\tikzset{nedge/.style={>=stealth,->}}\n        \\tikzset{neuron/.style={draw,%\n                                circle,%\n                                fill=black!20,%\n                                inner sep=0,%\n                                minimum size=8}\n        }\n          \\foreach \\y in {0, ..., 4} {\n            \\ifthenelse{\\y = 4}{}{%\n              \\node[neuron,fill=white] (n--1-\\y) at (-1, \\y) {};\n              \\node[neuron,fill=white] (n-10-\\y) at (10, \\y) {};\n            }\n            \\foreach \\x in {0, ..., 9} {\n              \\node[neuron] (n-\\x-\\y) at (\\x, \\y) {};\n              \\ifthenelse{\\y = 0}{}{%\n                \\pgfmathparse{int(\\y-1)};\n                \\xdef\\prevy{\\pgfmathresult};\n                \\pgfmathparse{int(\\x-1)};\n                \\xdef\\prevx{\\pgfmathresult};\n                \\pgfmathparse{int(\\x+1)};\n                \\xdef\\nextx{\\pgfmathresult};\n                \\draw[nedge] (n-\\prevx-\\prevy) -- (n-\\x-\\y);\n                \\draw[nedge] (n-\\x-\\prevy) -- (n-\\x-\\y);\n                \\draw[nedge] (n-\\nextx-\\prevy) -- (n-\\x-\\y);\n              }\n            }\n          }\n      \\end{tikzpicture}\n  \\caption{The same network in Figure~\\ref{fig:cnn-no-padding} with padding.\n  }\n  \\label{fig:cnn-padding}\n\\end{marginfigure}\n\nIn NLP, most common use of CNNs is text classification.\nGiven a sequence of texts,\nwe typically define multiple convolutions, or filters.\nEach convolution, after training,\nwill detect an `n-gram' feature with the width of the convolution.\nAlthough in theory a larger convolution width should learn\nfeatures within its window that are based on a (discontinuous) sub-sequence,\nexamples of convolutions with different sizes are sometime used.\nFigure~\\ref{fig:cnn-sentiment} demonstrates a possibly way to use\nCNNs for text classification.\nThe first layer in the network is typically an \\emph{embedding} layer,\na dense (as opposed to sparse one-hot) representation of the words\n(we will cover embeddings later in this class). \nThe example uses three convolutions,\nfirst two with width \\num{2},\nand the last one with width \\num{3}.\nThe first convolution in the example, finds something interesting\nin input bigram \\emph{not really},\nwhile the second one is more sensitive to bigram \\emph{really worth}.\nThe network does a max pooling over the whole sequence,\nand then uses the resulting representations as an input to\na classifier with a single hidden layer.\nThe final layer, a single (likely sigmoid) unit is used for binary classification.\n\n\\begin{figure}\n  \\tikzset{external/export next=false}\n%  \\tikzsetnextfilename{cnn-in-nlp-example}\n  \\begin{tikzpicture}[x=1cm, y=1cm,blue!50!black,thick, node distance=2mm]\n    \\tikzset{inp/.style={minimum width=2cm,minimum height=6mm}}\n\n    \\node[inp] (not) at (0,0) {not};\n    \\node[inp,right=of not] (really) {really};\n    \\node[inp,right=of really] (worth) {worth};\n    \\node[inp,right=of worth] (seeing) {seeing};\n\n    \\foreach \\n in {not, really, worth, seeing} {\n      \\node[above=of \\n,inner sep=0pt] (V-\\n) \n        {\\tikz{\\draw[thick] (0,0) grid[step=5mm] (1.5,0.5);}};\n    }\n\n    \\node[inner sep=0pt] (c-1) at (1,2.5)\n      {\\tikz{\\draw[thick,inner sep=0pt] (0,0) grid[step=5mm] (2.0,0.5);}};\n    \\node[right=of c-1,inner sep=0pt] (c-2) \n      {\\tikz{\\draw[thick,inner sep=0pt] (0,0) grid[step=5mm] (2.0,0.5);}};\n    \\node[right=of c-2,inner sep=0pt] (c-3) \n      {\\tikz{\\draw[thick,inner sep=0pt] (0,0) grid[step=5mm] (2.0,0.5);}};\n\n    \\draw[red] (V-not.north west) -- (c-1.south west);\n    \\draw[red] (V-really.north east) -- ($(c-1.south west) + (0.5, 0) $);\n\n    \\draw[red] (V-really.north west) -- ($(c-1.south west) + (0.5, 0) $);\n    \\draw[red] (V-worth.north east) -- ($(c-1.south west) + (1.0, 0) $);\n\n    \\draw[blue] (V-not.north west) -- (c-2.south west);\n    \\draw[blue] (V-really.north east) -- ($(c-2.south west) + (0.5, 0) $);\n\n    \\draw[very thick,red, fill=red!80] (c-1.south west) \n      rectangle ($ (c-1.south west) + (0.5, 0.5) $);\n\n    \\draw[very thick,red,fill=red!30] ($ (c-1.south west) + (0.5, 0) $)\n      rectangle ($ (c-1.south west) + (1, 0.5) $);\n\n    \\draw[very thick,blue, fill=blue!30] (c-2.south west) \n      rectangle ($ (c-2.south west) + (0.5, 0.5) $);\n\n    \\draw[blue] (V-really.north west) -- ($(c-2.south west) + (0.5, 0) $);\n    \\draw[blue] (V-worth.north east) -- ($(c-2.south west) + (1, 0) $);\n\n    \\draw[very thick,blue, fill=blue!80] ($(c-2.south west) + (0.5, 0) $) \n      rectangle ($ (c-2.south west) + (1, 0.5) $);\n\n    \\draw[orange] (V-not.north west) -- (c-3.south west);\n    \\draw[orange] (V-worth.north east) -- ($(c-3.south west) + (0.5, 0) $);\n    \\draw[very thick,orange, fill=orange!30] (c-3.south west) \n      rectangle ($ (c-3.south west) + (0.5, 0.5) $);\n\n    \\node[draw, minimum height=5mm, minimum width=5mm, inner sep=0pt,%\n          above=8mm of c-1, fill=red!80] (p-1) {};\n    \\node[draw, minimum height=5mm, minimum width=5mm, inner sep=0pt,%\n          above=8mm of c-2, fill=blue!80] (p-2) {};\n    \\node[draw, minimum height=5mm, minimum width=5mm, inner sep=0pt,%\n          above=8mm of c-3, fill=orange!30] (p-3) {};\n\n    \\draw (c-1.north west) -- (p-1.south west);\n    \\draw (c-1.north east) -- (p-1.south east);\n    \\draw (c-2.north west) -- (p-2.south west);\n    \\draw (c-2.north east) -- (p-2.south east);\n    \\draw (c-3.north west) -- (p-3.south west);\n    \\draw (c-3.north east) -- (p-3.south east);\n\n    \\node[draw,circle, minimum size=5mm, inner sep=0pt,%\n          above=8mm of p-1] (h-1) {};\n    \\node[draw,circle, minimum size=5mm, inner sep=0pt,%\n          above=8mm of p-2] (h-2) {};\n    \\node[draw,circle, minimum size=5mm, inner sep=0pt,%\n          above=8mm of p-3] (h-3) {};\n\n    \\node[draw,circle, minimum size=5mm, inner sep=0pt,%\n          above=8mm of h-2] (o) {};\n\n    \\draw[->] (p-1) -- (h-1);\n    \\draw[->] (p-1) -- (h-2);\n    \\draw[->] (p-1) -- (h-3);\n    \\draw[->] (p-2) -- (h-1);\n    \\draw[->] (p-2) -- (h-2);\n    \\draw[->] (p-2) -- (h-3);\n    \\draw[->] (p-3) -- (h-1);\n    \\draw[->] (p-3) -- (h-2);\n    \\draw[->] (p-3) -- (h-3);\n\n    \\draw[->] (h-1) -- (o);\n    \\draw[->] (h-2) -- (o);\n    \\draw[->] (h-3) -- (o);\n\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,0) {Input};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,0.8) {Word vectors};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,1.5) {Convolution};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,2.5) {Feature maps};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,3.2) {Pooling};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,3.9) {Features};\n    \\node[blue,anchor=east,font=\\footnotesize] at (-1,5.2) {Classifier};\n  \\end{tikzpicture}\n  \\caption{A demonstration of CNNs used for text classification.}\n  \\label{fig:cnn-sentiment}\n\\end{figure}\n\nIn real-life examples,\nespecially in image processing systems,\nCNNs are typically deeper and also more structured.\nThis may make their training difficult despite the sparse connectivity\nand shared weights.\nFor very large systems, it is also a common practice to pre-train components\nof the network piece-by-piece.\nIn the NLP applications\nlike the one demonstrated in Figure~\\ref{fig:cnn-sentiment},\nthe embeddings are typically trained separately,\nand most of the time training continues on the task as well.\n\n", "meta": {"hexsha": "88f08959dc33556ea0a5756ebfdb14296c99bda9", "size": 53035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "deep-networks.tex", "max_stars_repo_name": "coltekin/snlp-notes", "max_stars_repo_head_hexsha": "02dddcda0a8ff24f959675f0ad6a9079d573f49b", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-08-05T12:58:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-21T14:17:47.000Z", "max_issues_repo_path": "deep-networks.tex", "max_issues_repo_name": "coltekin/snlp-notes", "max_issues_repo_head_hexsha": "02dddcda0a8ff24f959675f0ad6a9079d573f49b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "deep-networks.tex", "max_forks_repo_name": "coltekin/snlp-notes", "max_forks_repo_head_hexsha": "02dddcda0a8ff24f959675f0ad6a9079d573f49b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.304517134, "max_line_length": 130, "alphanum_fraction": 0.6270764589, "num_tokens": 16395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.43341840407678295}}
{"text": "\\section{Generate synthetic data}\n\\label{S:SYNTHETIC}\nThe creation of synthetic data is possible using OpenBDLM.\nThe analysis of synthetic data is useful for validation, test, and debugging purposes because the true value of the hidden states and model parameters are known.\nOpenBDLM uses the transition model  of the state-space modelling approach (see Section~\\ref{SS:LGSSM}) to create realistic synthetic data.\nThere are two ways for creating synthetic data using OpenBDLM:\n\n\\begin{itemize}\n\\item From the interactive tool\n\\item From an existing project.\n\\end{itemize}\n\n\\subsection{Generate synthetic data using the interactive tool}\nThe creation of the synthetic data from the interactive tool (option \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!0!} from the starting menu) enables the creation of synthetic data from scratch. \nOpenBDLM requests the user to provide the number of time series, and to define the time vector (starting time, end time, timestep).\nIn the next step, the user has to define the time-series dependence (if applicable), to provide the number of model class, and to define a set of block components for each time series, as well as model constrains between model classes (if applicable).\nDefault values for initial hidden states mean values and model parameters are automatically assigned for each block component.\nIn the case of two model classes, the synthetic baseline will switch between the first and the second model class according to the transition probability values (see Section~\\ref{SS:THSKF}).\nThe amplitude of each synthetic anomaly (i.e. change of the local trend) is sampled randomly in a normal distribution of zero mean and standard deviation $\\sigma_{w}^{12}$ as defined in the switching process noise transition matrix.\nAlternately, the user may choose to create \\emph{custom anomalies}.\nIn such a case, the beginning (in sample index), duration (in number of samples) and amplitude (in change of the local trend) of each anomaly is user specified.\nThe information about custom anomaly are stored in the field \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!custom_anomalies! of the structure variable \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc!:\n\\begin{itemize}\n\\item \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc.custom_anomalies.start_custom_anomalies!: this field stores a $1\\times \\mathtt{A}$ vector of integers, where $\\mathtt{A}$ is the total number of synthetic anomaly. Each value indicates the sample index of the anomaly start.\n\\item \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc.custom_anomalies.duration_custom_anomalies!: this field stores a $1\\times \\mathtt{A}$ vector of integers, where $\\mathtt{A}$ is the total number of synthetic anomaly. Each value indicates the anomaly duration in number of samples.\n\\item \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc.custom_anomalies.amplitude_custom_anomalies!: this field stores a $1\\times \\mathtt{A}$ vector of real number, where $\\mathtt{A}$ is the total number of synthetic anomaly. Each value indicates the amplitude of the anomaly in change of the local trend.\n\\end{itemize}\nThe synthetic data are saved in \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!DATA_*.mat! and \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!*.csv! data files, and a \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!PROJ_*.mat! project file is created that stores the information about the model (structure variable \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!model!), and the true hidden states (see structure variable \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!estimation.ref!).\n\n\n\n\n\n\\begin{table}[h]\n     \\caption{Default value of model parameters and initial hidden states $\\bm{\\mu}_{0}$ and $\\mathbf{\\Sigma}_{0}$ for synthetic data generation.} \n     \\centering\n     \\begin{tabular}{r|lp{3.1cm}p{4cm}}\\toprule\n        & $\\bm{\\theta}$ & $\\bm{\\mu}_{0}$ & diag$(\\mathbf{\\Sigma}_{0})$ \\\\\\cmidrule(lr){1-4}\n    $\\mathtt{LL}$   &  $\\sigma_{w}^{\\mathtt{LL}}=0$ &$[10]$ & $[0.1^{2}]$ \\\\\n    $\\mathtt{LT}$    & $\\sigma_{w}^{\\mathtt{LT}}=10^{-7}$ &  $[10, -0.1\\times10^{-2}]$ & $[0.1^{2}, 0.1^{2}]$ \\\\\n     $\\mathtt{LA}$   & $\\sigma_{w}^{\\mathtt{LA}}=10^{-8}$  &  $[10, -0.1\\times10^{-2} , -0.1\\times10^{-5}]$ & $[0.1^{2}, 0.1^{2}, 0.1^{2}]$ \\\\\n     $\\mathtt{P}$  &  $p=[365.24, 1, 182.62] $, $\\sigma_{w}^{\\mathtt{P}}=0$  &$[10, 10]$ & $[0.2^{2}, 0.2^{2}]$  \\\\\n     $\\mathtt{KR}$  & $p=[365.24]$, $\\ell=0.5$, $\\sigma_{w,0}^{\\mathtt{KR}}=\\sigma_{w,1}^{\\mathtt{KR}}=0$ &  $[$$-0.97$, $1.65$, $1.73$, $-1.91$, $0.23$, $0.37$, $-2.89$, $-0.22$, $0.73$, $-1.83$$]$ & $[$$0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$, $0.01^{2}$$]$  \\\\  \n         $\\mathtt{AR}$   &  $\\phi^{\\mathtt{AR}}=0.75$, $\\sigma_{w}^{\\mathtt{AR}}=1$  &$[0]$ & $[0.1^{2}]$ \\\\\\bottomrule\n     \\end{tabular}\n\\label{table:defaultsynthetic}\n\\end{table}\n\n\\subsection{Generate synthetic data from an existing project}\n\n\n\nOnce a project is loaded, it is possible to create synthetic data from it (option \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!16!} from the main menu (see Listing~\\ref{LST:OpenBDLMMainMenu}).\nThe synthetic data time vector will be the same as the time vector in memory, and missing data will be replicated.\nThe model used to create the synthetic data will be the same as the model of the current project, including current initial hidden states as well as model parameters values.\nThe creation of synthetic data in this way is particularly useful to closely mimic real dataset.\nThe synthetic data are saved in \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!DATA_new_*.mat! and \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!*.csv! data files, and a \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!PROJ_new_*.mat! new project file is created that stores the information about the model (structure variable \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!model!), and the true hidden states (see structure variable \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!estimation.ref!).\n\n\n\n\n\n\n\\subsection{Synthetic data generation functions}\n\n\nThe synthetic data creation workflow is presented Figure~\\ref{FIG:SyntheticDataCreationWorkflow}. \nThe OpenBLDM functions used for synthetic data creation are:\n\n\\begin{description}[style=unboxed]\\setlength\\itemsep{0em}\n\\item[Pilot function for synthetic data creation] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,model,estimation,misc]=piloteSimulateData(data,model,estimation,misc)\n  \\end{lstlisting}\n\n\\item[Creates synthetic data] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,model,estimation,misc]=SimulateData(data,model,misc,varargin)\n  \\end{lstlisting}\n\n\\item[Create synthetic data from transition probabilities] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data, model, estimation, misc]=simulateDataFromTransitionProbabilities(data,model,misc)\n  \\end{lstlisting}\n\n\\item[Create synthetic data from custom anomalies (for two model classes only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,model,estimation,misc]=simulateDataFromCustomAnomalies(data,model,misc)\n  \\end{lstlisting}\n\n  \\item[Models configuration for synthetic data (for synthetic data creation from interactive tool only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,model,estimation,misc]=configureModelForDataSimulation(data,model,estimation,misc)\n \\end{lstlisting}\n \n \\item[Requests user inputs to define the number of synthetic time series to create (for synthetic data creation from interactive tool only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n  [data,misc]=defineDataLabels(data,misc)\n \\end{lstlisting}\n \n\\item[Requests user inputs to define synthetic data time vector (for synthetic data creation from interactive tool only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,misc]=defineTimestamps(data,misc)\n \\end{lstlisting}\n\n\\end{description}\n\n\n\n\\begin{figure}[h]\n  \\centering\n  \\captionsetup{justification=centering}\n\\scalebox{0.7}{\n\\begin{tikzpicture}\n\n\\node[paralightgray](inputSDC){\\begin{tabular}{c}  \\lstinline[ basicstyle = \\mlttfamily \\small]!data! \\\\ \\lstinline[ basicstyle = \\mlttfamily \\small]!model.param_properties! \\\\ \\lstinline[ basicstyle = \\mlttfamily \\small]!model.initX, initV, initS! \\end{tabular}};\n\\node[eslightgray](piloteSDC)[below of = inputSDC, yshift = -1cm]{\\phantom{} piloteSimulateData.m \\phantom{}};\n\\node[eslightgray](SDC)[below of = piloteSDC, yshift = -1cm]{\\phantom{} SimulateData.m \\phantom{}};\n\\node[testlightgray](testCustom)[below of = SDC, yshift = -1.5cm]{\\begin{tabular}{c}  custom  \\\\ anomalies ?  \\end{tabular}};\n\\node[eslightgray](SDCtransition)[below of = testCustom, yshift = -1.75cm, xshift = -3cm]{\\begin{tabular}{c} SimulateData \\\\ FromTransitionProbabilities.m \\end{tabular}};\n\\node[eslightgray](SDCcustom)[below of = testCustom , yshift = -1.75cm, xshift = 3cm]{\\begin{tabular}{c} SimulateData \\\\ FromCustomAnomalies.m \\end{tabular}};\n\\node[paralightgray](outputSDC)[below of = inputSDC, yshift = -10cm]{\\lstinline[ basicstyle = \\mlttfamily \\small]!estimation.ref!};\n%\n\\path[->, draw, thick] (inputSDC)edge(piloteSDC);\n\\path[->, draw, thick] (piloteSDC)edge(SDC);\n\\path[->, draw, thick] (SDC)edge(testCustom);\n\\path[->, draw, thick] (testCustom.east) -| (2cm,-6.5cm) -| node[pos=0.25, above]{yes} (SDCcustom);\n\\path[->, draw, thick] (testCustom.west) -| (-2cm,-6.5cm) -| node[pos=0.25, above]{no} (SDCtransition);\n\\path[->, draw, thick] (SDCtransition.south) |- (0cm,-10cm) -|  (outputSDC.north);\n\\path[->, draw, thick] (SDCcustom.south) |- (0cm,-10cm) -|  (outputSDC.north);\n\\end{tikzpicture} } \n\\caption{Synthetic data creation workflow} \\label{FIG:SyntheticDataCreationWorkflow}\n\\end{figure}", "meta": {"hexsha": "6d775414aeed2c78b70c3efdd141bbe9331563b7", "size": 10569, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pdf_doc/section/OpenBDLMCreatingSyntheticData.tex", "max_stars_repo_name": "CivML-PolyMtl/OpenBDLM", "max_stars_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-19T23:42:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T17:32:11.000Z", "max_issues_repo_path": "doc/pdf_doc/section/OpenBDLMCreatingSyntheticData.tex", "max_issues_repo_name": "bhargobdeka/OpenBDLM", "max_issues_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pdf_doc/section/OpenBDLMCreatingSyntheticData.tex", "max_forks_repo_name": "bhargobdeka/OpenBDLM", "max_forks_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-10-18T07:18:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:26:06.000Z", "avg_line_length": 79.4661654135, "max_line_length": 672, "alphanum_fraction": 0.7352635065, "num_tokens": 3118, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6513548511303336, "lm_q1q2_score": 0.43341838678938327}}
{"text": "\\chapter{Numbers and Arithmetic}\\label{refnums}\n\\index{Arbitrary precision arithmetic,}\n\\index{Precision,arbitrary}\n\\index{R\\textsc{exx},arithmetic}\n \\nr{} arithmetic attempts to carry out the usual operations\n(including addition, subtraction, multiplication, and division) in as\n\"natural\" a way as possible.\nWhat this really means is that the rules followed are those that are\nconventionally taught in schools and colleges.\nHowever, it was found that unfortunately the rules used vary\nconsiderably (indeed much more than generally appreciated) from person\nto person and from application to application and in ways that are not\nalways predictable.\nThe \\nr{} arithmetic described here is therefore a compromise which\n(although not the simplest) should provide acceptable results in most\napplications.\n\\section{Introduction}\\label{arithintro}\n \n\\index{Numbers,}\nNumbers can be expressed in \\nr{} very flexibly (leading and trailing\nblanks are permitted, exponential notation may be used) and follow\nconventional syntax.\nSome valid numbers are:\n\\begin{lstlisting}\n     12          /* A whole number               */\n   '-76'         /* A signed whole number        */\n     12.76       /* Some decimal places          */\n ' +  0.003 '    /* Blanks around the sign, etc. */\n     17.         /* Equal to 17                  */\n      '.5'       /* Equal to 0.5                 */\n     4E+9        /* Exponential notation         */\n      0.73e-7    /* Exponential notation         */\n\\end{lstlisting}\n\\index{Exponential notation,}\n(Exponential notation means that the number includes a sign and a power\nof ten following an \"\\textbf{E}\" that indicates how the decimal\npoint will be shifted.  Thus \\textbf{4E+9} above is just a short way\nof writing \\textbf{4000000000}, and \\textbf{0.73e-7} is short\nfor \\textbf{0.000000073}.)\n\\index{Operators,arithmetic}\n\\index{Numbers,arithmetic on}\n\\index{Arithmetic,operators}\n\\index{Integer division,}\n\\index{Division,integer}\n\\index{Remainder operator,}\n The arithmetic operators include\naddition (indicated by a \"\\textbf{+}\"),\nsubtraction (\"\\textbf{-}\"),\nmultiplication (\"\\textbf{*}\"),\npower (\"\\textbf{**}\"), and\ndivision (\"\\textbf{/}\").\nThere are also two further division operators:\ninteger divide (\"\\textbf{\\%}\") which divides and returns the integer part, and\nremainder (\"\\textbf{//}\") which divides and returns the remainder.\nPrefix plus (\"\\textbf{+}\") and\nprefix minus (\"\\textbf{-}\") operators are also provided.\n\\index{Rounding,}\n When two numbers are combined by an operation, \\nr{} uses a set of\nrules to define what the result will be (and how the result is to be\nrepresented as a character string).\nThese rules are defined in the next section, but in summary:\n\\begin{itemize}\n\\item Results will be calculated with up to some maximum number of\nsignificant digits.\nThat is, if a result required more than 9 digits it would normally be\nrounded to 9 digits.\nFor instance, the division of 2 by 3 would result in 0.666666667 (it\nwould require an infinite number of digits for perfect accuracy).\n \nYou can change the default of 9 significant digits by using the\n\\keyword{numeric digits} instruction.  This lets you calculate using\nas many digits as you need - thousands, if necessary.\n\\item Except for the division and power operators, trailing zeros are\npreserved (this is in contrast to most electronic calculators, which\nremove all trailing zeros in the decimal part of results).\nSo, for example:\n\\begin{lstlisting}\n2.40 + 2  =>  4.40\n2.40 - 2  =>  0.40\n2.40 * 2  =>  4.80\n2.40 / 2  =>  1.2\n\\end{lstlisting}\nThis preservation of trailing zeros is desirable for most\ncalculations (and especially financial calculations).\n If necessary, trailing zeros may be easily removed with the\n \\textbf{strip} method (see page \\pageref{refstrip}) , or by division by 1.\n\\item A zero result is always expressed as the single\ndigit \\textbf{'0'}.\n\\item \nExponential form is used for a result depending on its value and\nthe setting of \\keyword{numeric digits} (the default is 9 digits).\nIf the number of places needed before the decimal point exceeds this\nsetting, or the absolute value of the number is less\nthan \\textbf{0.000001}, then the number will be expressed in\nexponential notation; thus\n\\begin{lstlisting}\n1e+6 * 1e+6\n\\end{lstlisting}\nresults in \"\\textbf{1E+12}\" instead of\n\"\\textbf{1000000000000}\", and\n\\begin{lstlisting}\n1 / 3E+10\n\\end{lstlisting}\nresults in \"\\textbf{3.33333333E-11}\" instead of\n\"\\textbf{0.0000000000333333333}\".\n\\item \nAny mixture of Arabic numerals (0-9) and  Extra digits (see page \\pageref{refsyms}) \ncan be used for the digits in numbers used in calculations.  The results\nare expressed using Arabic numerals.\n\\end{itemize}\n\\section{Definition}\\label{arithdefinition}\n This definition describes arithmetic for \\nr{} strings\n(type \\textbf{R\\textsc{exx}}).\nThe arithmetic operations are identical to those defined in the ANSI\nstandard for R\\textsc{exx}.\n\\index{ANSI standard,arithmetic definition}\n\\footnote{\nAmerican National Standard for Information Technology -\nProgramming Language REXX, X3.274-1996, American National\nStandards Institute, New York, 1996.\n}\n\\subsection{Numbers}\\label{refdefnum}\n\\index{Numbers,definition}\n A \\emph{number} in \\nr{} is a character string that includes one or\nmore decimal digits, with an optional decimal point.\nThe decimal point may be embedded in the digits, or may be prefixed or\nsuffixed to them.\nThe group of digits (and optional point) thus constructed may have\nleading or trailing blanks, and an optional sign (\"\\textbf{+}\"\nor \"\\textbf{-}\") which must come before any digits or decimal\npoint.\nThe sign may also have leading or trailing blanks.\nThus:\n\\index{Numeric,part of a number}\n\\index{Digits,in numbers}\n\\begin{alltt}\nsign    ::=  + | -\ndigit   ::=  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\ndigits  ::=  digit [digit]...\nnumeric ::=  digits . [digits]\n             | [.] digits\nnumber  ::=  [blank]... [sign [blank]...]\n             numeric [blank]...\n\\end{alltt}\n\n\\index{Extra digits,in numbers}\nwhere if the implementation supports  extra digits (see page \\pageref{refsyms}) \nthese are also accepted as \\emph{digit}s, providing that they\nrepresent values in the range zero through nine.\nIn this case each extra digit is treated as though it were\nthe corresponding character in the range 0-9.\n\\index{Period,in numbers}\n\\index{. (period),in numbers}\n Note that a single period alone is not a valid number.\n\\subsection{Precision}\\label{refndi2}\n\\index{Arithmetic,precision}\n\\index{Precision,of arithmetic}\n\\index{Significant digits, in arithmetic,}\n\\index{DIGITS,on NUMERIC instruction}\n\\index{NUMERIC,DIGITS}\n The maximum number of significant digits that can result from an\narithmetic operation is controlled by the \\keyword{digits} keyword on the\n \\keyword{numeric} instruction (see page \\pageref{refnumeric}) :\n\\begin{alltt}\n\\keyword{numeric digits} [\\emph{expression}];\n\\end{alltt}\nThe expression is evaluated and must result in a positive whole\nnumber.\nThis defines the precision (number of significant digits) to which\narithmetic calculations will be carried out; results will be rounded to\nthat precision,\nif necessary.\n If no expression is specified, then the default precision is used.\nThe default precision is 9, that is, all implementations must support\nat least nine digits of precision.  An implementation-dependent maximum\n(equal to or larger than 9) may apply: an attempt to exceed this will\ncause execution of the instruction to terminate with an exception.\nThus if an algorithm is defined to use more than 9 digits then if\nthe \\keyword{numeric digits} instruction succeeds then the computation\nwill proceed and produce identical results to any other implementation.\n Note that \\keyword{numeric digits} may set values below the default of\nnine.\nSmall values, however, should be used with care - the loss of\nprecision and rounding thus requested will affect all \\nr{}\ncomputations, including (for example) the computation of new values for\nthe control variable in loops.\n \nIn the remainder of this section, the notation \\textbf{digits} refers\nto the current setting of \\keyword{numeric digits}.\nThis setting may also be referred to in expressions in programs by using\nthe \\textbf{digits}  special word (see page \\pageref{refspecial}) .\n\\subsection{Arithmetic operators}\n\\index{Operators,arithmetic}\n\\index{Numbers,arithmetic on}\n\\index{Arithmetic,operators}\n \n\\nr{} arithmetic is effected by the operators \"\\textbf{+}\",\n\"\\textbf{-}\", \"\\textbf{*}\", \"\\textbf{/}\",\n\"\\textbf{\\%}\", \"\\textbf{//}\", and \"\\textbf{**}\"\n(add, subtract, multiply, divide, integer divide, remainder, and power)\nwhich all act upon two terms, together with the prefix operators\n\"\\textbf{+}\" and \"\\textbf{-}\" (plus and minus)\nwhich both act on a single term.\nThe result of all these operations is a \\nr{} string, of\ntype \\textbf{R\\textsc{exx}}.\nThis section describes the way in which these operations are carried\nout.\n Before every arithmetic operation, the term or terms being operated\nupon have any extra digits converted to the corresponding Arabic numeral\n(the digits 0-9).  They then have leading zeros removed (noting the\nposition of any decimal point, and leaving just one zero if all the\ndigits in the number are zeros) and are then truncated\nto \\textbf{digits+1} significant digits\n\\footnote{\n\\index{Guard digit in arithmetic,}\nThat is, to the precision set by \\keyword{numeric digits}, plus one extra\n\"guard\" digit.\n}\n(if necessary) before being used in the computation.\nThe operation is then carried out under up to double that precision, as\ndescribed under the individual operations below.\nWhen the operation is completed, the result is rounded if necessary to\nthe precision specified by the \\keyword{numeric digits} instruction.\n\\index{Rounding,definition}\n Rounding is done in the \"traditional\" manner, in that the extra\n(guard) digit is inspected and values of 5 through 9 are rounded up,\nand values of 0 through 4 are rounded down.\n\\footnote{\n\\index{,}\nEven/odd rounding would require the ability to calculate to arbitrary\nprecision (that is, to a precision not governed by the setting of\n\\keyword{numeric digits}) at any time and is therefore not the mechanism\ndefined for \\nr{}.\n}\n A conventional zero is supplied preceding a decimal point if\notherwise there would be no digit before it.  Trailing zeros are\nretained for addition, subtraction, and multiplication, according to\nthe rules given below, except that a result of zero is always expressed\nas the single character \\textbf{'0'}.  For division, insignificant\ntrailing zeros are removed after rounding.\n \nThe  \\textbf{format} method (see page \\pageref{refformat})  is defined to allow a\nnumber to be represented in a particular format if the standard result\nprovided by \\nr{} does not meet requirements.\n\\subsection{Arithmetic operation rules - basic operators}\\label{}\n\\index{Trailing zeros,}\n\\index{Arithmetic,operation rules}\n The basic operators (addition, subtraction, multiplication, and\ndivision) operate on numbers as follows:\n\\begin{description}\n\\item[Addition and subtraction]\n\\index{Addition,definition}\n\\index{+ plus sign,addition operator}\n\\index{Subtraction,definition}\n\\index{- minus sign,subtraction operator}\n\\index{Prefix operators,arithmetic}\n\nIf either number is zero then the other number, rounded\nto \\textbf{digits} digits if necessary, is used as the result (with\nsign adjustment as appropriate).\nOtherwise, the two numbers are extended on the right and left as\nnecessary up to a total maximum of \\textbf{digits+1} digits.\n \nThe number with smaller absolute value may therefore lose some or\nall of its digits on the right.\n\\footnote{\nIn the example, the number \\textbf{yy.yyyyy} would have three digits\ntruncated if \\textbf{digits} were \\textbf{5}.\n}\nThe numbers are then added or subtracted as appropriate.  For example:\n\\begin{alltt}\nxxxx.xxx + yy.yyyyy\n\\end{alltt}\nbecomes:\n\\begin{alltt}\n  xxxx.xxx00\n+ 00yy.yyyyy\n------------\n  zzzz.zzzzz\n\\end{alltt}\n.sumadd\nThe result is then rounded to \\textbf{digits} digits if necessary,\ntaking into account any extra (carry) digit on the left after an\naddition, but otherwise counting from the position corresponding to the\nmost significant digit of the terms being added or subtracted.\nFinally, any insignificant leading zeros are removed.\n The \\emph{prefix operators} are evaluated using the same rules;\nthe operations \"\\textbf{+number}\" and \"\\textbf{-number}\"\nare calculated as \"\\textbf{0+number}\" and\n\"\\textbf{0-number}\", respectively.\n\\item[Multiplication]\n\\index{Multiplication,definition}\n\\index{* multiplication operator,}\n\nThe numbers are multiplied together (\"long multiplication\")\nresulting in a number which may be as long as the sum of the lengths of\nthe two operands.  For example:\n\\begin{alltt}\nxxx.xxx * yy.yyyyy\n\\end{alltt}\nbecomes:\n\\begin{alltt}\nzzzzz.zzzzzzzz\n\\end{alltt}\nand the result is then rounded to \\textbf{digits} digits if\nnecessary, counting from the first significant digit of the result.\n\\item[Division]\n\\index{Division,definition}\n\nFor the division:\n\\begin{alltt}\nyyy / xxxxx\n\\end{alltt}\nthe following steps are taken: first, the number\n\"\\textbf{yyy}\" is extended\nwith zeros on the right until it is larger than\nthe number \"\\textbf{xxxxx}\" (with note being taken of the change\nin the power of ten that this implies).  Thus in this example,\n\"\\textbf{yyy}\"\nmight become\n\"\\textbf{yyy00}\".\nTraditional long division then takes place, which can be written:\n\\begin{alltt}\n         zzzz\n      .------\nxxxxx | yyy00\n\\end{alltt}\n\nThe length of the result (\"\\textbf{zzzz}\") is such that the\nrightmost \"\\textbf{z}\" will be at least as far right as the\nrightmost digit of the (extended) \"\\textbf{y}\" number in the\nexample.  During the division, the \"\\textbf{y}\" number will be\nextended further as necessary, and the \"\\textbf{z}\" number\n(which will not include any leading zeros) may increase up\nto \\textbf{digits+1} digits, at which point the division stops and the\nresult is rounded.\nFollowing completion of the division (and rounding if necessary),\ninsignificant trailing zeros are removed.\n\\end{description}\n \\textbf{Examples:}\n\\begin{alltt}\n/* With 'numeric digits 5' */\n12+7.00     ==  19.00\n1.3-1.07    ==  0.23\n1.3-2.07    ==  -0.77\n1.20*3      ==  3.60\n7*3         ==  21\n0.9*0.8     ==  0.72\n1/3         ==  0.33333\n2/3         ==  0.66667\n5/2         ==  2.5\n1/10        ==  0.1\n12/12       ==  1\n8.0/2       ==  4\n\\end{alltt}\n\\textbf{Note: }With all the basic operators, the position of the decimal point\nin the terms being operated upon is arbitrary.\nThe operations may be carried out as integer operations with the\nexponent being calculated and applied afterwards.\nTherefore the significant digits of a result are not in any way\ndependent on the position of the decimal point in either of the terms\ninvolved in the operation.\n\\subsection{Arithmetic operation rules - additional operators}\n The operation rules for the power (\"\\textbf{**}\"),\ninteger division (\"\\textbf{\\%}\"), and remainder\n(\"\\textbf{//}\") operators are as follows:\n\\begin{description}\n\\item[Power]\\label{refpower}\n\n\\index{Exponentiation,definition}\n\\index{Power operator,definition}\nThe \"\\textbf{**}\" (power) operator raises a number (on the\nleft of the operator) to a power (on the right of the operator).\nThe term on the right is rounded to \\textbf{digits} digits (if\nnecessary), and must, after any rounding, be a whole number, which may\nbe positive, negative, or zero.\nIf negative, the absolute value of the power is used, and then the\nresult is inverted (divided into 1).\n \nFor calculating the power, the number is effectively multiplied by\nitself for the number of times expressed by the power, and finally\ntrailing zeros are removed (as though the result were divided by one).\n In practice (see note below for the reasons), the power is\ncalculated by the process of left-to-right binary reduction.\nFor \"\\textbf{x**n}\": \"\\textbf{n}\" is converted to\nbinary, and a temporary accumulator is set to 1.\nIf \"\\textbf{n}\" has the value 0 then the initial calculation is\ncomplete.\nOtherwise each bit (starting at the first non-zero bit) is inspected\nfrom left to right.\nIf the current bit is 1 then the accumulator is multiplied by\n\"\\textbf{x}\".\nIf all bits have now been inspected then the initial calculation is\ncomplete, otherwise the accumulator is squared by multiplication and the\nnext bit is inspected.\nWhen the initial calculation is complete, the temporary result is\ndivided into 1 if the power was negative.\n \nThe multiplications and division are done under the normal\narithmetic operation rules, detailed earlier in this section, using a\nprecision of \\textbf{digits+elength+1} digits.\nHere, \\textbf{elength} is the length in decimal digits of the integer\npart of the whole number \"\\textbf{n}\" (\\emph{i.e.}, excluding any sign,\ndecimal part, decimal point, or insignificant leading zeros, as though\nthe operation \\textbf{n\\%1} had been carried out and any sign removed).\nFinally, the result is rounded to \\textbf{digits} digits, if\nnecessary, and insignificant trailing zeros are removed.\n\\item[Integer division]\n\n\\index{Integer division,definition}\n\nThe \"\\textbf{\\%}\" (integer divide) operator divides two numbers\nand returns the integer part of the result.\nThe result returned is defined to be that which would result from\nrepeatedly subtracting the divisor from the dividend while the dividend\nis larger than the divisor.  During this subtraction, the absolute\nvalues of both the dividend and the divisor are used: the sign of the\nfinal result is the same as that which would result if normal division\nwere used.\n The result returned will have no fractional part (that is, no\ndecimal point or zeros following it).\nIf the result cannot be expressed exactly within \\textbf{digits}\ndigits, the operation is in error and will fail - that is, the\nresult cannot have more digits than the current setting of \\keyword{numeric\ndigits}.\nFor example, \\textbf{10000000000\\%3} requires ten digits to express the\nresult exactly (\\textbf{3333333333}) and would therefore fail\nif \\textbf{digits} were \\textbf{9} or smaller.\n\\item[Remainder]\n\n\\index{Remainder operator,definition}\nThe \"\\textbf{//}\" (remainder) operator will return the remainder\nfrom integer division, and is defined\nas being the residue of the dividend after the operation of calculating\ninteger division as just described.\nThe sign of the remainder, if non-zero, is the same as that of the\noriginal dividend.\n This operation will fail under the same conditions as integer\ndivision (that is, if integer division on the same two terms would\nfail, the remainder cannot be calculated).\n\\end{description}\n \\textbf{Examples:}\n\\begin{lstlisting}\n/* Again with 'numeric digits 5' */\n2**3        ==  8\n2**-3       ==  0.125\n1.7**8      ==  69.758\n2\\%3         ==  0\n2.1//3      ==  2.1\n10\\%3        ==  3\n10//3       ==  1\n-10//3      ==  -1\n10.2//1     ==  0.2\n10//0.3     ==  0.1\n3.6//1.3    ==  1.0\n\\end{lstlisting}\n \\textbf{Notes:}\n\\begin{enumerate}\n\\item A particular algorithm for calculating powers is described, since\nit is efficient (though not optimal) and considerably reduces the\nnumber of actual multiplications performed.\nIt therefore gives better performance than the simpler definition of\nrepeated multiplication.\nSince results could possibly differ from those of repeated\nmultiplication, the algorithm must be defined here so that different\nimplementations will give identical results for the same operation on\nthe same values.\nOther algorithms for this (and other) operations may always be used, so\nlong as they give identical results to those described here.\n\\item The integer divide and remainder operators are defined so that they\nmay be calculated as a by-product of the standard division operation\n(described above).  The division process is ended as soon as the\ninteger result is available; the residue of the dividend is the\nremainder.\n\\end{enumerate}\n\\subsection{Numeric comparisons}\\label{arithnumericcomparisons}\n\\index{Arithmetic,comparisons}\n\\index{Operators,comparative}\n\\index{Comparison,of numbers}\n\\index{Numbers,comparison of}\n Any of the  comparative operators (see page \\pageref{refcomps})  may be used\nfor comparing numeric strings.\nHowever, the strict comparisons (for example, \"\\textbf{==}\" and\n\"\\textbf{>{}>}\") are not numeric comparative operators and should\nnot normally be used for comparing numbers, since they compare from left\nto right and leading and trailing blanks (and leading zeros) are\nsignificant for these operators.\n Numeric comparison, using the normal comparative operators, is\neffected by subtracting the two numbers (calculating the difference) and\nthen comparing the result with \\textbf{'0'} - that is, the\noperation:\n\\begin{lstlisting}\nA ? B\n\\end{lstlisting}\nwhere \"\\textbf{?}\" is any normal comparative operator, is\nidentical to:\n\\begin{lstlisting}\n(A - B) ? '0'\n\\end{lstlisting}\nIt is therefore the \\emph{difference} between two numbers, when\nsubtracted under \\nr{} subtraction rules, that determines their equality.\n\\subsection{Exponential notation}\n\\index{Ten, powers of,}\n\\index{Pure numbers,}\n The definition of numbers  above (see page \\pageref{refdefnum}) \ndescribes \"pure\" numbers, in the sense that the character strings\nthat describe numbers can be very long.\n \\textbf{Examples:}\n\\begin{lstlisting}\nsay  10000000000 * 10000000000\n/* would display: 100000000000000000000 */\n\nsay  0.00000000001 * 0.00000000001\n/* would display: 0.0000000000000000000001 */\n\\end{lstlisting}\nFor both large and small numbers some form of exponential notation\nis useful, both to make such long numbers more readable and to make\nevaluation possible in extreme cases.  In addition, exponential notation\nis used whenever the \"pure\" form would give misleading\ninformation.  For example:\n\\begin{lstlisting}\nnumeric digits 5\nsay 54321*54321\n\\end{lstlisting}\nwould display \"\\textbf{2950800000}\" if long form were to be\nused.\nThis is misleading, as it appears that the result is an exact multiple\nof 100000, and so \\nr{} would express the result in exponential\nnotation, in this case \"\\textbf{2.9508E+9}\".\n\\index{Numbers,definition}\n\\index{Mantissa of exponential numbers,}\n\\index{Significand of exponential numbers,}\n\\index{Numeric,part of a number}\n\\index{Powers of ten in numbers,}\n\\index{Exponential notation,definition}\n\\index{E-notation,definition}\n The definition of \\emph{number} (see above) is therefore extended\nby replacing the description of \\textbf{numeric} by the following:\n\\begin{alltt}\nmantissa ::=  digits . [digits]\n              | [.] digits\nnumeric  ::=  mantissa [E sign digits]\n\\end{alltt}\nIn other words, the numeric part of a number may be followed by an\n\"\\textbf{E}\" (indicating an exponential part), a sign,\nand an integer following the sign that represents a power of ten that is\nto be applied.\nThe \"\\textbf{E}\" may be in uppercase or lowercase.\nNote that no blanks are permitted within this part of a number, but the\ninteger may have leading zeros.\n \\textbf{Examples:}\n\\begin{alltt}\n12E+11  =  1200000000000\n12E-5   =  0.00012\n 12e+4  =  120000\n\\end{alltt}\n All valid numbers may be used as data for arithmetic.  The results\nof calculations will be returned in exponential form depending on the\nsetting of \\keyword{numeric digits}.\nIf the number of places needed before the decimal point\nexceeds \\textbf{digits}, or if the absolute value of the result is\nless than \\textbf{0.000001}, then exponential form will be used.\nThe exponential form generated by \\nr{} always has a sign following the\n\"\\textbf{E}\".\nIf the exponent is 0 then the exponential part is omitted - that\nis, an exponential part of \"\\textbf{E+0}\" will never be\ngenerated.\n If the default format for a number is not satisfactory for a\nparticular application, then the \\textbf{format} method may be used to\ncontrol its format.  Using this, numbers may be explicitly converted to\nexponential form or even forced to be returned in \"pure\" form.\n\\index{Notation,scientific}\n\\index{Notation,engineering}\n\\index{Exponential notation,}\n\\index{E-notation,}\n\\index{Scientific notation,}\n\\index{Engineering notation,}\n\\index{FORM,option of NUMERIC instruction}\n\\index{NUMERIC,FORM}\n\\label{refnfo2}\n Different exponential notations may be selected with the\n \\keyword{numeric form} instruction (see page \\pageref{refnform}) .\nThis instruction allows the selection of either scientific or\nengineering notation.\n\\emph{Scientific notation} adjusts the power of ten so there is a\nsingle non-zero digit to the left of the decimal point.\n\\emph{Engineering notation} causes powers of ten to be expressed as a\nmultiple of three - the integer part may therefore range\nfrom \\textbf{1} through \\textbf{999}.\n \\textbf{Examples:}\n\\begin{lstlisting}\nnumeric form scientific\nsay 123.45 * 1e11\n/* would display: 1.2345E+13 */\n\nnumeric form engineering\nsay 123.45  * 1e11\n/* would display: 12.345E+12 */\n\\end{lstlisting}\n The default exponential notation is scientific.\n\\subsection{Whole numbers}\\label{refwholed}\n\\index{Whole numbers,definition}\n\\index{DIGITS,effect on whole numbers}\n Within the set of numbers understood by \\nr{} it is useful to\ndistinguish the subset defined as \\emph{whole numbers}.\n \nA \\emph{whole number} in \\nr{} is a number that has a decimal part\nwhich is all zeros (or that has no decimal part).\n\\subsection{Numbers used directly by \\nr{}}\\label{refnumuse}\n\\index{Numbers,use of by \\nr{}}\n\\index{Functions,numeric arguments of}\n\\index{Rounding,when numbers used}\n\\index{DIGITS,rounding when numbers used}\n As discussed above, the result of any arithmetic operation is\nrounded (if necessary) according to the setting of \\keyword{numeric digits}.\nSimilarly, when a number (which has not necessarily been involved in an\narithmetic operation) is used directly by \\nr{} then the same rounding\nis also applied, just as though the operation of adding the number\nto \\textbf{0} had been carried out.\nAfter this operation, the integer part of the number must have no more\ndigits than the current setting of \\keyword{numeric digits}.\n \nIn the following cases, the number used must be a whole number and\nan implementation restriction on the largest number that can be used\nmay apply:\n\\begin{itemize}\n\\item positional patterns, including variable positional patterns,\nin  parsing templates (see page \\pageref{refparsing}) \n\\item the power value (right hand operand) of the power operator (see page \\pageref{refpower}).\n\\item the values of \\emph{exprr} and \\emph{exprf} (following the\n\\keyword{for} keyword) in the  \\keyword{loop} instruction (see page \\pageref{refloop}) \n\\item the value of \\emph{exprd} (following the \\keyword{digits}\nkeyword) in the  \\keyword{numeric} instruction (see page \\pageref{refnumeric}) .\n\\end{itemize}\n \\textbf{Implementation minimum:} A minimum length of 9 digits must\nbe supported for these uses of whole numbers by a \\nr{} language\nprocessor.\n\\subsection{Implementation independence}\n\\index{Arithmetic,implementation independence}\n The \\nr{} arithmetic rules are defined in detail, so that when a\ngiven program is run the results of all computations are sufficiently\ndefined that the same answer will result for all correct\nimplementations.  Differences due to the underlying machine\narchitecture will not affect computations.\n This contrasts with most other programming languages, and with\n binary arithmetic (see page \\pageref{refbinary})  in \\nr{}, where the\nresult obtained may depend on the implementation because the precision\nand algorithms used by the language processor are defined by the\nimplementation rather than by the language.\n\\subsection{Exceptions and errors}\n\\index{Exceptions,during arithmetic}\n\\index{Errors during arithmetic,}\n\\index{Arithmetic,exceptions}\n\\index{Arithmetic,errors}\n\\index{Arithmetic,overflow}\n\\index{Arithmetic,underflow}\n\\index{Overflow, arithmetic,}\n\\index{Underflow, arithmetic,}\n The following exceptions and errors may be signalled during arithmetic:\n\\begin{itemize}\n\\item Divide exception\n This exception will be signalled if division by zero was attempted,\nor if the integer result of an integer divide or remainder operation had\ntoo many digits.\n\\item Overflow/Underflow exception\n This exception will be signalled if the exponential part of a result\n(from an operation that is not an attempt to divide by zero) would\nexceed the range that can be handled by the language processor, when the\nresult is formatted according to the current settings of \\keyword{numeric\ndigits} and \\keyword{numeric form}.\nThe language defines a minimum capability for the exponential part,\nnamely exponents whose absolute value is at least as large as the\nlargest number that can be expressed as an exact integer in default\nprecision.\nThus, since the default precision is nine, implementations must support\nexponents in the range \\textbf{-999999999}\nthrough \\textbf{999999999}.\n\\item Insufficient storage\n Storage is needed for calculations and intermediate results, and on\noccasion an arithmetic operation may fail due to lack of storage.\nThis is considered an operating environment error as usual, rather\nthan an arithmetical exception.\n\\end{itemize}\n \\emph{In the reference implementation, the exceptions and error types\nused for these three cases\nare \\textbf{DivideException}, \\textbf{ExponentOverflowException},\nand \\textbf{OutOfMemoryError}, respectively.}\n\\index{,}\n\\index{,}\n\\index{,}\n", "meta": {"hexsha": "83577695b37e771b7b477318588827897e5592c8", "size": 29250, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/nrl/nr3arith.tex", "max_stars_repo_name": "RexxLA/NetRexx", "max_stars_repo_head_hexsha": "ec27b6e3f908fbc50cb6dc54696daea68ae59103", "max_stars_repo_licenses": ["ICU"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documentation/nrl/nr3arith.tex", "max_issues_repo_name": "RexxLA/NetRexx", "max_issues_repo_head_hexsha": "ec27b6e3f908fbc50cb6dc54696daea68ae59103", "max_issues_repo_licenses": ["ICU"], "max_issues_count": 25, "max_issues_repo_issues_event_min_datetime": "2022-01-24T12:13:53.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-01T16:14:50.000Z", "max_forks_repo_path": "documentation/nrl/nr3arith.tex", "max_forks_repo_name": "RexxLA/NetRexx", "max_forks_repo_head_hexsha": "ec27b6e3f908fbc50cb6dc54696daea68ae59103", "max_forks_repo_licenses": ["ICU"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.3299565847, "max_line_length": 95, "alphanum_fraction": 0.7644444444, "num_tokens": 7375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.4332994452397806}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Monday\\\\ 2020-12-21, \\\\ compiled \\\\ \\today}\n\nLet us continue with gauge-invariant cosmological perturbations.\nLet us now give a gauge-invariant definition for the matter velocity: \n%\n\\begin{align} \\label{eq:matter-velocity-gauge-invariant}\n2 v _{s} = 2 v^{\\parallel} + \\chi^{\\parallel, \\prime}\n\\,,\n\\end{align}\n%\nwhere, as usual, by ``matter'' we mean anything which goes on the right-hand side of the Einstein equations, and \\(s\\) means ``scalar''. \n\nThis velocity is related to the amplitude of the \\textbf{shear tensor} for the matter velocity: specifically, from the shear tensor \\(\\sigma_{\\mu \\nu }\\) we can define the quantity \\(\\qty(\\sigma^{ij} \\sigma_{ij} /2 )^{1/2}\\). \n\nFor the scalar part, we have (following the notation by Bardeen)\n%\n\\begin{align}\n\\epsilon_m &= \\delta \\rho + \\rho_0' \\qty(v^{\\parallel} + \\omega^{\\parallel} )  \\\\\n\\rho_0 &= \\rho_0 (\\eta )\n\\,.\n\\end{align}\n\nNote that energy density perturbations themselves are not gauge invariant. \nThe quantity \\(\\epsilon _m\\) corresponds to \\(\\delta \\rho \\) in the gauge where \\(v^{\\parallel} + \\omega^{\\parallel} = 0\\), which means that we are selecting constant-\\(\\eta \\) hypersurfaces which are orthogonal to the worldlines of the fluid: the fluid's rest frame. \n\nThe quantity \\(v^{\\parallel} + \\omega^{\\parallel}\\) enters into the expression for \\(T^{0}_{i}\\), which describes the momentum flux of the fluid. \nWe also define \n%\n\\begin{align}\n2 E_g = 2 \\delta \\rho + \\rho_0' \\qty(2 \\omega^{\\parallel} - \\chi^{\\parallel, \\prime})\n\\,,\n\\end{align}\n%\nwhich is also equal to \\(\\delta \\rho \\) in the gauge in which \\(2 \\omega^{\\parallel} - \\chi^{\\parallel, \\prime} = 0\\), which is the zero-shear or Poisson gauge. \n\nWe can also construct one vector perturbation, since we start with two and remove one with the gauge degree of freedom described as \\(d^{i}\\): \n%\n\\begin{align}\n\\Psi_i = \\omega^{\\perp}_i - \\chi_i^{\\perp, \\prime}\n\\,.\n\\end{align}\n\nThis is related to the amplitude of the vector geometric component of the geometric shear \\(\\sigma_{\\mu \\nu }\\). \nThis term describes frame-dragging effects. \n\nThe matter velocity can be described as \n%\n\\begin{align}\nV^{i}_{s} = v^{i}_{\\perp} + \\chi^{i, \\prime}_{\\perp}\n\\marginnote{Compare to \\eqref{eq:matter-velocity-gauge-invariant}.}\n\\,.\n\\end{align}\n\nAlso, we can define \n%\n\\begin{align}\nV^{i}_{c} = v^{i}_{\\perp} + \\omega^{i}_{\\perp}\n\\,.\n\\end{align}\n\nThis is related to the amplitude of the vorticity\\footnote{Local angular velocity of fluid elements} tensor \\(\\omega_{\\mu \\nu }\\) (and, specifically, the quantity \\(\\qty(\\omega^{ij} \\omega_{ij} / 2)^{1/2}\\)). \n\nAs for tensor perturbation modes, linear tensor perturbations are automatically gauge-invariant (at linear order, at least): \n%\n\\begin{align}\n\\chi^{T, \\prime}_{ij} =\n\\chi^{T}_{ij} \n\\,.\n\\end{align}\n\n\\section{Perturbed Einstein Equations}\n\nLet us write the equations of motion for these linear cosmological perturbations. \nWe start from the Einstein equations \\(G_{\\mu \\nu } = 8 \\pi G T_{\\mu \\nu }\\), and the Bianchi identities \\(T^{\\mu \\nu }_{; \\nu } = 0\\). \nThe Einstein tensor is defined as \n%\n\\begin{align}\nG_{\\mu \\nu } &= R_{\\mu \\nu } - \\frac{1}{2} g_{\\mu \\nu } R  \\\\\nR_{\\mu \\nu } &= R^{\\alpha }_{\\mu \\alpha \\nu }  \\\\\nR^{\\alpha }_{\\mu \\nu \\beta }&\\sim \\pdv{\\Gamma }{x} + \\Gamma^2  \\\\\n\\Gamma^{\\mu }_{\\nu \\rho } &\\sim g^{-1} \\pdv{g}{x}\n\\,.\n\\end{align}\n\nWe can compute the nonvanishing Christoffel symbols in the unperturbed case (see, for example, the notes for Theoretical Cosmology), and then the perturbations of these; note that the inverse of a perturbed metric can be computed by inverting the perturbation according to the flat metric only (see \\cite[eq.\\ 8.20]{tissinoGeneralRelativityExercises2020}):\n%\n\\begin{align}\n\\delta \\Gamma^{0}_{00} &= \\psi '  \\\\\n\\delta \\Gamma^{0}_{0i} &= \\partial_{i} \\psi + \\frac{a'}{a} \\partial_{i} \\omega^{\\parallel}  \\\\\n\\delta \\Gamma^{i}_{00} &= \\frac{a'}{a} \\partial^{i} \\omega^{\\parallel} + \\partial^{i} \\omega^{\\parallel, \\prime} + \\partial^{i} \\psi  \\\\\n\\delta \\Gamma^{0}_{ij} &= -2 \\frac{a'}{a} \\psi \\delta_{ij} - \\partial_{i} \\partial_{j} \\omega^{\\parallel} - 2 \\frac{a'}{a} \\phi \\delta_{ij} \n- \\phi ' \\delta_{ij} + \\frac{a'}{a} D_{ij} \\chi^{\\parallel} + \\frac{1}{2} D_{ij} \\chi^{\\parallel, \\prime}  \\\\\n\\delta \\Gamma^{i}_{0j} &= - \\phi \\delta^{i}_{j} + \\frac{1}{2} D^{i}_{j} \\chi^{\\parallel, \\prime}  \\\\\n\\delta \\Gamma^{i}_{jk} &= \\dots\n\\,.\n\\end{align}\n\nThe spatial components of the metric can be written as \n%\n\\begin{align}\ng_{ij} = \\underbrace{a^2(\\eta ) \\qty[1 - 2 \\phi ] \\delta_{ij}}_{a^2(\\eta , \\vec{x})} + \\dots\n\\,,\n\\end{align}\n%\nwhere we can express \n%\n\\begin{align}\na(\\eta , \\vec{x}) = a(\\eta ) \\qty(1 - \\phi (\\eta , \\vec{x}))\n\\,,\n\\end{align}\n%\ntherefore \\(\\delta a = - a \\phi \\), which means that \n%\n\\begin{align}\n\\delta \\qty( \\frac{a^{\\prime}}{a}) = - \\phi '\n\\,.\n\\end{align}\n\nThe unperturbed Ricci tensor reads \n%\n\\begin{align}\nR_{00} &= - 3 \\frac{a''}{a} + 3 \\qty( \\frac{a'}{a})^2  \\\\\nR_{ij} &=  \\qty[\\frac{a''}{a} + \\qty(\\frac{a'}{a})^2] \\delta_{ij} \n\\,.\n\\end{align}\n\nIts perturbation is \n%\n\\begin{align}\n\\delta R_{00} &= \\frac{a'}{a} \\nabla^2 \\omega^{\\parallel} + \\nabla^2 \\omega^{\\parallel, \\prime} + 3 \\phi^{\\parallel} + 3 \\frac{a'}{a} \\phi' + 3 \\frac{a'}{a} \\psi '  \\\\\n\\delta R_{0i} &= \\frac{a'}{a} \\partial_{i} \\omega^{\\parallel} + \\qty(\\frac{a'}{a})^2 \\partial_{i} \\omega^{\\parallel} +2 \\partial_{i} \\phi' + 2 \\frac{a'}{a} \\partial_{i} \\psi + \\frac{1}{2} \\partial_{k} D^{k}_i \\qty(\\chi_{\\parallel})'  \\\\\n\\delta R_{ij} &= \\dots\n\\,.\n\\end{align}\n\n\\todo[inline]{Copy full expressions from the notes.}\n\nThe Ricci scalar \\(R\\) is given by \\(R = (6/a^2) (a' / a)\\) in flat FRLW, while its perturbation is \n%\n\\begin{align}\n\\delta R &= \\frac{1}{a^2} \\qty(- 6 \\frac{a'}{a} \\nabla^2\\omega^{\\parallel} - 2 \\nabla^2 \\omega^{\\parallel, \\prime} - 2 \\nabla^2 \\psi - 6 \\phi^{\\parallel} - 6 \\frac{a'}{a} \\psi' - 18 \\frac{a'}{a} \\phi ' - 12 \\frac{a''}{a} \\psi + 4 \\nabla^2 \\phi + \\partial_{k} \\partial^{i} D^{k}_{i} \\chi^{\\parallel})\n\\,.\n\\end{align}\n\nThis expression is fully general, in a specific gauge it can be significantly simplified.  \nThe stress-energy tensor we will use is given by \n%\n\\begin{align}\nT_{\\mu \\nu } = \\rho u_\\mu u_\\nu + p h_{\\mu \\nu } + \\Pi_{\\mu \\nu }\n\\,,\n\\end{align}\n%\nwhere \\(\\Pi^{\\mu }_{\\mu } = \\Pi_{\\mu \\nu } u^{\\nu } = 0\\). This allows us to account for imperfections in the fluid. The only nonvanishing components of \\(\\Pi \\) are the spatial ones \\(\\Pi_{ij}\\). \nThis is true in any frame. \n\nWe can write it as \n%\n\\begin{align}\n\\Pi_{ij} = D_{ij} \\Pi^{\\parallel} + 2\\Pi^{\\perp}_{(i, j)} + \\Pi^{T}_{ij}\n\\,,\n\\end{align}\n%\nwhere, as usual, \\(D_{ij} = \\partial_{i} \\partial_{j} - (1/3) \\delta_{ij} \\nabla^2\\). \nThe component \n%\n\\begin{align}\n- T^{0}_{0} &= \\rho_{0} (\\eta ) + \\delta \\rho (\\eta , \\vec{x})  \\\\\n&= \\rho_0 (\\eta ) \\qty(1 + \\delta ) \n\\,,\n\\end{align}\n%\nwhile \n%\n\\begin{align}\np = p_0 (\\eta ) \\qty(1 + \\Pi _L) \n\\,,\n\\end{align}\n%\nwhere \\(\\Pi _L = \\delta p / p_0 (\\eta )\\). The \\(L\\) stands for ``longitudinal''. \n\nThe unperturbed spatial components of the stress-energy tensor read:\n%\n\\begin{align}\nT^{i}_{j} &= p_0 (\\eta ) \\qty[ \\qty(1 + \\Pi _L) \\delta^{i}_{j} + \\Pi_{T, j}^{i}]  \\\\\n\\Pi_{T, j}^{i} &= \\eval{\\frac{\\Pi^{i}_{j}}{p_0 (\\eta )}}_{\\text{traceless}}\n\\,.\n\\end{align}\n\nThe perturbation reads \n%\n\\begin{align}\n\\delta T^{0}_{i} = \\qty(\\rho_0 + p_0 ) \\qty(v_i + \\omega _i )\n&\n\\text{or}\n&\n\\delta T^{i}_{0} = - (\\rho_0 + p_0 ) v^{i}\n\\,.\n\\end{align}\n\nThis is quite general: it is the density of the \\(i\\)-component of the fluid's momentum, or the flux of energy in the \\(i\\)-th direction.\n\nThe linearly perturbed \\(00\\) EFE for scalar perturbation (as they are decoupled from the vector and tensor ones) reads \n%\n\\begin{align}\n\\frac{3 a'}{a} \\qty(\\hat{\\phi}' + \\frac{a'}{a} \\psi ) - \\nabla^2 \\qty(\\hat{\\phi} + \\frac{a'}{a} \\sigma ) = - 4 \\pi G a^2 \\delta \\rho \n\\,,\n\\end{align}\n%\nwhere \\(\\hat{\\phi} = \\phi + (1/6) \\nabla^2 \\chi^{\\parallel}\\) and \\(\\sigma = - \\omega^{\\parallel} + (1/2) \\chi^{\\parallel, \\prime}\\). \n\nThe \\(0i\\) equation is \n%\n\\begin{align}\n\\hat{\\phi}' + \\frac{a'}{a} \\psi = - 4 \\pi G a^2 \\qty(\\rho_0 + p_0 )V\n\\,,\n\\end{align}\n%\nwhere \\(V = v^{\\parallel} + \\omega^{\\parallel}\\). \nThese two are not really ``evolution'' equations, they should be interpreted as constraints (to relate with \\(\\delta T_{00} \\) and \\(\\delta T_{0i}\\)) for the evolution of the other components. \nOn the other hand, from the trace of the \\(ij\\) equations we find \n%\n\\begin{align}\n\\hat{\\phi}'' + 2 \\frac{a'}{a} \\hat{\\phi}' + \\frac{a'}{a} \\psi +\n\\qty[2 \\qty(\\frac{a'}{a})' + \\qty(\\frac{a'}{a})^2] \\psi \n= 4 \\pi G a^2 \\qty(\\Pi _L + \\frac{2}{3} \\nabla^2 \\Pi _T)p_0 \n\\,,\n\\end{align}\n%\nwhere the \\(T\\) in \\(\\Pi _T = \\Pi^{\\parallel} / p_0 (\\eta )\\) means ``traceless''. \nFrom the traceless part of these equations we find \n%\n\\begin{align}\n\\sigma ' + 2 \\frac{a'}{a} \\sigma + \\hat{\\phi} - \\psi = 8 \\pi G a^2 \\Pi _T p_0 \n\\,.\n\\end{align}\n\nSo far we have not chosen a gauge; let us now put ourselves in the Poisson gauge. Here, \n%\n\\begin{align}\n\\omega^{\\parallel} = 0 = \\chi^{\\parallel}\n\\,.\n\\end{align}\n\nThen, \\(\\hat{\\phi} = \\phi = - \\Phi _H\\), and \\(\\psi = \\Psi _A\\). \nNow \\(\\sigma = - \\omega^{\\parallel} + (1/2) \\chi^{\\parallel, \\prime} = 0\\). \nThen, the equations reads \n%\n\\begin{align}\n\\phi - \\psi &= 8 \\pi G a^2 \\Pi_T p_0  \\\\\n\\Phi _H + \\Psi _A  &= - 8 \\pi G a^2 \\Pi _T  p_0 \n\\,.\n\\end{align}\n\nIf the anisotropic stress can be neglected, then \\(\\phi = \\psi \\); this is the case for CDM, not so for nonisotropic relativistic particles or modified gravity. \nIf this is the case, then we can write the evolution equation in a simpler way: \\(\\Pi _T\\) vanishes, by definition \\(\\Pi _L p_0 = \\delta p\\), which we can split into \n%\n\\begin{align}\n\\delta p = c_s^2 \\delta \\rho + \\delta p _{\\text{non-adiab}}\n\\,,\n\\end{align}\n%\nand considering only the adiabatic part we find \n%\n\\begin{align}\n\\Phi _H'' + 3 \\qty(1 + c_s^2) \\frac{a'}{a} \\Phi _H' + \n\\qty[2 \\qty(\\frac{a'}{a})' + \\qty(1 + 3 c_s^2) \\qty(\\frac{a'}{a})^2\n- c_s^2 \\nabla^2] \\Phi _H = 0\n\\,,\n\\end{align}\n%\nwhich is an isolated evolution equation for \\(\\Phi _H\\), a wave-like propagation equation. \n\nThe Poisson gauge is the most Newton-like one: the evolution equation becomes \n%\n\\begin{align}\n- \\nabla^2 \\Phi _H &= 4 \\pi G a^2 \\underbrace{\\qty(\\delta \\rho - \\frac{3 a'}{a} (\\rho_0 + p_0 )V )}_{\\epsilon_{m}}  \n\\marginnote{Inserting the \\(0i\\) equation into the \\(00\\) one.}\n\\\\\n&= 4 \\pi G a^2\\epsilon_m\n\\,,\n\\end{align}\n%\na Poisson equation. \n\nFor the vector perturbation \\(\\Psi_i\\), we find (from the \\(0i\\) equation)\n%\n\\begin{align}\n\\nabla^2\\Psi _i = 16 \\pi G a^2 \\qty(\\rho_0 + p_0 ) V_{i, c}\n\\,,\n\\end{align}\n%\nwhile for the tensor perturbations, starting from the traceless part of the \\(ij\\) EFE, we get \n%\n\\begin{align}\n\\chi_{ij}^{\\prime \\prime, T} + 2 \\frac{a'}{a} \\chi^{T, \\prime}_{ij} - \\nabla^2 \\chi^{T}_{ij} = 16 \\pi G a^2p_0 (\\eta ) \\Pi^{T}_{ij}\n\\,.\n\\end{align}\n\nWe should also perturb for the matter source of the equations: \\(T^{\\mu \\nu }_{; \\nu } =0 \\). \nThe energy density continuity equation (\\(\\mu = 0\\)) reads \n%\n\\begin{align} \\label{eq:energy-density-continuity-equation}\n\\delta \\rho ' + \\frac{3 a'}{a} \\qty(\\delta p + \\delta \\rho ) - 3 \\qty(\\rho_0 + p_0 )  \\hat{\\phi}' + \\qty(\\rho_0 + p_0 ) \\nabla^2 \\qty(V + \\sigma ) &= 0\n\\,,\n\\end{align}\n%\nwhile for \\(\\mu = i\\) we get \n%\n\\begin{align}\nV' + \\qty(1 + 3 c_s^2) \\frac{a'}{a} V + \\psi + \\frac{1}{(\\rho_0 + p_0 )} \\qty(\\delta p + \\frac{2}{3} p_0 \\nabla^2 \\Pi _T) &= 0\n\\,.\n\\end{align}\n\nThe curvature perturbation on uniform energy density hypersurfaces is \n%\n\\begin{align}\n\\zeta = - \\hat{\\phi} - H \\frac{ \\delta \\rho }{\\dot{\\rho}_0 } = - \\hat{\\phi} - \\frac{a'}{a} \\frac{ \\delta \\rho }{\\rho_0 '}\n\\,,\n\\end{align}\n%\nwhere, as usual, \\(\\hat{\\phi} = \\phi + (1/6) \\nabla^2 \\chi^{\\parallel}\\). \n\nIn a uniform energy density gauge \\(\\zeta = - \\hat{\\phi}\\); also in the flat gauge we have \\(\\hat{\\phi} = 0\\), which tells us that \\(\\zeta \\) is an energy density perturbation. \nOn super-horizon scales and taking equation \\eqref{eq:energy-density-continuity-equation} in the gauge where \\(\\delta \\rho = 0\\), the Laplacian in the energy density continuity equation can be taken to vanish (\\(k \\ll 1\\)), and we can express it as \n%\n\\begin{align}\n\\zeta ' = - \\frac{a'}{a} \\frac{ \\delta p}{\\rho_0 + p_0 }\n\\,,\n\\end{align}\n%\nbut we must evaluate this in the uniform energy density gauge the adiabatic contribution to the pressure perturbation vanishes, therefore we are left with \n%\n\\begin{align}\n\\zeta ' = - \\frac{a'}{a} \\frac{ \\delta p _{\\text{non-adiabatic}}}{\\rho_0 + p_0 }\n\\,.\n\\end{align}\n\nFor single-field models of slow-roll inflation, we find that on super-horizon scales\n%\n\\begin{align}\n\\delta p _{\\text{non-adiabatic}} \\propto \\frac{k^2 \\Phi _H}{a^2} \\approx 0 \\implies \\zeta \\approx \\const \n\\,.\n\\end{align}\n\nThe continuity equation for vector perturbations reads \n%\n\\begin{align}\n\\qty[(\\rho_0 +p_0 ) V_{ic}]' + \\frac{4 a'}{a} (\\rho_0 + p_0 ) V_{ic} \n= - \\nabla_k \\qty(\\Pi^{\\perp k}_{, i} + \\Pi^{\\perp, k}_{i})\n\\,.\n\\end{align}\n\nBy Kelvin's circulation theorem, vorticity is conserved along trajectories unless there are dissipative effects.\nThen, the divergence on the right-hand side of this equation vanishes, therefore we can write the left-hand side as \n%\n\\begin{align}\na^3 \\qty(\\rho_0 + p_0 ) V_{ic} a = \\const\n\\,.\n\\end{align}\n\nThis amounts to a momentum times \\(a\\), so the equation represents the conservation of the intrinsic angular momentum. \n\n\\end{document}\n", "meta": {"hexsha": "d1ce5d5ba1ca00496174e9d67c7e069141b065d4", "size": 13466, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/early_universe/dec21.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/early_universe/dec21.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/early_universe/dec21.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 36.6920980926, "max_line_length": 356, "alphanum_fraction": 0.6301054508, "num_tokens": 4983, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4332994446953017}}
{"text": "\\section{Universal Optimisations}\n\\label{sec:universal}\n\nThere are some optimisations that apply to \\emph{all} solvers. These universal optimisations efficiently\ntry to reduce the overall complexity of a given parity game in order to reduce the effort spent by any solver. \nClearly, such optimisations have to ensure that a solution of the modified game can be effectively and \nefficiently translated back into a valid solution of the original game.\n\nIn the following we describe optimisations that are implemented on top of every solving algrithm:\nSCC decomposition, detection of special cases, and compression. The next section then describes a generic\nalgorithm that uses (some of -- depending on the configuration) these optimisations in order to call\na real solver on as few and little parts of a game as possible.   \n\n\n\\subsection{SCC Decomposition}\n\nLet $G = (V, V_0, V_1, E, \\Omega)$ be a parity game. A \\emph{strongly connected component} (SCC) is a non-empty set \n$S \\subseteq V$ with the property that every node in $S$ can reach every other node in $S$, i.e. $uE^*v$ for \nall $u, v \\in S$ (where $E^*$ denotes the transitive-reflexive closure of $E$). A strongly connected component \n$S$ is \\emph{proper} iff $uE^+v$ for all $u, v \\in S$ (where $E^+$ denotes the transitive closure of $E$). In \nother words: An SCC $S$ is proper iff $|S| > 1$ or $S = \\{u\\}$ and $uEu$.\n\n\\begin{theorem}[\\cite{tarjan:146}]\nEvery parity game $G = (V,V_0,V_1,E,\\Omega)$ can, in time $\\mathcal{O}(|E|)$, be partitioned into SCCs \n$S_0, ..., S_n$ with $V = \\bigcup_{i \\leq n} S_i$ and $S_i \\cap S_j = \\emptyset$ for all $i \\not= j$.\n\\end{theorem}\n\nAdditionally there is a strict partial ordering $\\rightarrow$ on these SCCs which is defined as follows:\n\\begin{displaymath}\nS_i \\rightarrow S_j \\quad:\\iff\\quad i \\not= j \\wedge \\exists u \\in S_i,\\, v \\in S_j:\\, uEv\n\\end{displaymath}\nThis strict partial ordering is generally known as the \\emph{topology} of the SCC decomposition. An SCC $S$\nis called \\emph{final} w.r.t.\\ $\\to$ if there is no SCC $T$ s.t.\\ $S \\to T$. Note that every SCC topology\nof a finite graph must have at least one final SCC.\n\nSCC decomposition of parity games as a universal optimisation works as follows. First, the game is decomposed \ninto SCCs along with the computation of the strict partial ordering $\\rightarrow$. Then, all final SCCs \nwith respect to $\\rightarrow$ are solved by a parity game solver. Since these SCCs are not connected to any \nother SCCs, all solutions obtained in this manner can be directly used as solutions in the global game.\n\nSecond, the attractors for both players with respect to the computed winning sets of all maximal solved SCCs \nare computed and removed from the game. The remainder is still a game, but because of the removal some of the\noriginal SCCs may not be SCCs anymore. All ``damaged'' ex-SCCs are again decomposed into SCCs and replaced by \nthe new respective decomposition. \n%(Note: There is no need to actually replace the SCC in the data structure; it is more convenient to implement\n% this by recursion).\nIn this way, the remaining decomposition can be used again to solve the rest of the game, again starting\nwith those SCCs that are now final. \n%Note that it is convenient to automatically solve improper SCCs since otherwise they usually need to be \n%treated differently than normal SCCs in the real solving algorithms.\n\n\n%\\subsection{Excision of Dominions}\n\n%Although there is no obvious way to further reduce a parity game to smaller sub games that need to be solved, \n\nWith this SCC decomposition it is not necessary to require solvers to solve an entire SCC let alone an entire\ngame. Instead it suffices to have them solve at least a dominion for one of the players. Given an SCC $S$ and\ntwo dominions $D_0, D_1 \\subseteq S$ with $D_0 \\subseteq W_0$ and $D_1 \\subseteq W_1$, one simply computes the \nattractors $A_i := \\attr{}{i}{D_i}$ and considers the induced subgame $(S \\setminus A_0) \\setminus A_1$ which \ncan be recursively solved by decomposition into SCCs etc.\n\n% The excision of dominions is particularly useful for algorithms using a certain heuristic to generate ``good'' \n% strategies or for algorithms trying to find small dominions locally; some solution algorithms of the following \n% subsection will apply the dominion excision approach. Since the excision of a dominion possibly leads to a new \n% subgame that can be optimised and decomposed again, this optimisation can be very powerful.\\TODO{Sehr schwammiger\n% Paragraph.}\n\n\n\\subsection{Detection of Special Cases}\n\nThere are certain kinds of special games that can be solved very efficiently by the following procedures. \nW.l.o.g.\\ we can assume games to be proper strongly connected components. Remember that SCCs which are not proper\nconsist of a single node $v$ only that does not have an edge back to itself. The winner of $v$ is the owner\niff there is a successor that he/she wins. Since all successors belong to topologically greater SCCs we can\nassume them to be solved already, and thus, the winner of $v$ is easily determined.\n\n\\begin{itemize}\n\\item \\emph{Self-cycle games}: Suppose there is a node $v$ such that $vEv$. Then there are two cases depending on\nthe node's owner $p$ and the parity of the node's priority. If $\\Omega(v) \\not\\equiv_2 p$ then taking the edge \n$(v,v)$ is always a bad choice for player $p$ and this edge can be removed from the game for as long as \ntotality is preserved. If $\\Omega(v) \\equiv_2 p$ then taking this edge is always good in the sense that \n$\\{v\\}$ is a dominion for player $p$. Hence, its attractor can be removed as described above.\n\n\\item \\emph{One-parity games}: If all nodes in a proper SCC have the same parity, the whole game is obviously won \nby the corresponding player no matter which transition the player uses. Hence, a winning strategy can be found \nby random choice.\n\n\\item \\emph{One-player games}: A game $G$ is a one-player game for player $i$ iff for all $v \\in V_{1 - i}$ we have\n$|vE| = 1$. Such a one-player game that is an SCC can be solved using a simple fixed-point iteration. \n%\\begin{align*}\n%E_0\\,\\, &:= E \\\\\n%E_{j + 1} &:= \\{(u, v) \\mid uE_jv \\vee \\exists w:(uE_jw \\wedge wE_jv \\wedge \\Omega(u) \\geq \\Omega(w) \\wedge \\Omega(u) \\equiv_2 i )\\} \\\\\n%E'\\,\\, &:= \\bigcup_{j \\in \\Nat} E_j\n%\\end{align*}\n%Now the following holds: \nPlayer $i$ wins the game iff there is a node $u$ with $\\Omega(u) \\equiv_2 i$ and $u$ is reachable from itself\non a path that does not contain a priority greater than $\\Omega(u)$.\n% As player $i$ wins the game iff there is a cycle in the game won by player $i$ the fixed point iteration \n%simply computes which nodes having parity $i$ can reach itself without seeing a greater priority than their \n%own. Thus, if $E'$ connects $i$-parity nodes with itself, there needs to be a cycle using that particular \n%node being won by player $i$. The conversion also holds: If there is no $i$-parity node $u$ s.t. $uE'u$ then \n%the whole SCC is won by player $1-i$.\nIf there is such a cycle won by player $i$ then the rest of the SCC lies in the attractor of the cycle (since \nplayer $i$ is the only one to make choices); otherwise, if there is no cycle won by player $i$, the whole game \nis won by player $1-i$.\n\\end{itemize}\n\n\n\\subsection{Priority Compression}\n\nThe complexity of a parity game rises with the number of different priorities in the game. This optimisation step\nattempts to reduce this number. Note that it is not the actual values of priorities that determine the winner.\nIt is rather their \\emph{parity} on the one hand and their \\emph{ordering} on the other. For instance, if there are \ntwo priorities $p_1 < p_2$ in a game with $p_1 \\equiv_2 p_2$ but there is no $p'$ such that $p_1 < p' < p_2$ and \n$p' \\not\\equiv_2 p_1$ then every occurrence of $p_2$ can be replaced by $p_1$. \n\nIn general, let $P = (p_0,\\ldots,p_k)$ be the list of all the priorities occurring in a game $G = (V,V_0,V_1,E,\\Omega)$ \ns.t.\\ $p_{i-1} < p_i$ for all $0 \\le i < k$. W.l.o.g.\\ we assume $p_0$ to be even. If the least priority occurring in\n$G$ is odd, then simply add $p_0 = 0$ to this list which does not affect the construction in any way. We will also\nuse $P$ to denote the \\emph{set} of all elements in $P$.\n\nTake a decomposition of $P$ into maximal sublists of elements with the same parity, i.e.\\ \n\\begin{displaymath}\nP \\enspace = \\enspace (p_{0,0},\\ldots,p_{0,m_0},p_{1,0},\\ldots,p_{1,m_1},\\ldots,p_{n,0},\\ldots,p_{n,m_n})\n\\end{displaymath}\nwith $p_{i,j} \\equiv_2 p_{i,j'}$ for all $0 \\le i \\le n$, $0 \\le j < j' \\le m_i$ and \n$p_{i,m_i} \\not\\equiv_2 p_{i+1,0}$ for all $0 \\le i < n$. This defines a partial mapping $\\omega: \\Nat \\to \\Nat$ as \n\\begin{displaymath}\n\\omega(p) \\enspace = \\enspace \n\\begin{cases} \ni &, \\mbox{if } p = p_{i,j} \\mbox{ for some } j  \\\\\n\\mathrm{undefined} &, \\mbox{otherwise}\n\\end{cases}\n\\end{displaymath}\nNote the following facts about $\\omega$:\n\\begin{itemize}\n\\item $\\omega$ is defined on all priorities occurring in $G$;\n\\item $\\omega$ is \\emph{decreasing}: we have $\\omega(p) \\le p$ for all $p \\in P$;\n\\item $\\omega$ is \\emph{monotone}: for all $p,p'$ with $p \\le p'$ we have $\\omega(p) \\le \\omega(p')$;\n\\item $\\omega$ \\emph{preserves parities}: we have $\\omega(p) \\equiv_2 p$ for all $p \\in P$;\n\\item $\\omega$ is \\emph{dense}: for all $p,p' \\in P$ with $\\omega(p)+1 < \\omega(p')$ there is a $p''$ with \n$\\omega(p) < \\omega(p'') < \\omega(p')$.\n\\end{itemize} \nNow define another parity game $G' := (V,V_0,V_1,E,\\Omega')$ with $\\Omega'(v) := \\omega(\\Omega(v))$. I.e.\\ $G'$\nresults from $G$ by reducing the priorities according to the function $\\omega$. Then $G'$ is equivalent to $G$\nin the sense that the players' winning regions coincide in the two games, and a winning strategy $\\sigma$ for\nsome player $i$ in $G$ is also a winning strategy for him/her in $G'$ and vice-versa. This is guaranteed by the\nproperties of $\\omega$ identified above: due to monotonicity and preservation of parities, the greatest priority\nocurring in an infinite play in $G$ is even iff it is even in the same play in $G'$. The property of being\ndecreasing guarantees that this should in general be an optimisation, and density says that $G'$ is optimal \nw.r.t.\\ this optimisation. \n \n% \\begin{lemma}\n% Every parity game $G = (V,V_0,V_1,E,\\Omega)$ induces an equivalent parity game $G' = (V,V_0,V_1,E,\\Omega')$ where \n% $\\Omega'$ is inductively defined as follows:\n% \\begin{displaymath}\n% \\Omega'(v) \\enspace := \\enspace\n% \\begin{cases}\n% m(v) \\enspace, &\\mbox{if } \\Omega(v) \\equiv_2 m(v) \\\\\n% m(v) + 1 & \\mbox{otherwise}\n% \\end{cases}\n% \\end{displaymath}\n% and\n% \\begin{displaymath}\n% m(v) \\enspace := \\enspace \\max \\{0, \\Omega'(w) \\mid \\Omega(w) < \\Omega(v)\\}\n% \\end{displaymath}\n% Then $W_0(G) = W_0(G')$, $W_1(G) = W_1(G')$ and every winning strategy for player $i \\in \\{0, 1\\}$ w.r.t. $G$ is a winning strategy for player $i$ w.r.t. $G'$ and vice versa.\n% \\end{lemma}\n\n% Since $\\Omega(v) \\leq \\Omega(w)$ iff $\\Omega'(v) \\leq \\Omega'(w)$ as well as $\\Omega(v) \\equiv_2 \\Omega'(v)$ it is not hard to see that the greatest priority occurring infinitely often in a play w.r.t. $G$ has the same parity as w.r.t. $G'$.\n\n\n\n\\subsection{Priority Propagation}\n\nNote that any play visiting a node $v$ has to -- due to totality -- also visit one of the successors of \n$v$. Now suppose that the priorities of all successors of $v$ are greater than the priority of $v$ itself.\nThen $v$'s priority is irrelevant in the sense that no play is won by either player because $v$'s priority\noccurs in it. For those plays not visiting $v$ at all this is trivial and for those plays that do visit\n$v$ this is simply because $v$ is certainly not the geatest priority occurring in this play, let alone\noccurring infinitely often. Hence, $v$'s priority can be replaced by a greater one. \n\nIn general, let $G = (V,V_0,V_1,E,\\Omega)$. Applying \\emph{backwards propagation} in node $v$ results in\nthe game $G' = (V,V_0,V_1,E,\\Omega')$ where \n$\\Omega' = \\Omega[v \\mapsto \\max \\{ \\Omega(v), \\min \\{ \\Omega(w) \\mid w \\in vE \\} \\}]$.\nSimilarly, \\emph{forwards propagation} replaces $v$'s priority with the minimum of all\npriorities of its predecessors if that is greater than its current priority. It is equally sound because\nany play that visits $v$ infinitely often must visit one of its predecessors infinitely often too.\n\nBoth backwards and forwards propagation can be iterated and combined thus reducing the range of priorities\nin a game.\n\n\n\n\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "f9e515ff2c5174487da0eb3c42c339ce7b813cf3", "size": 12534, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/univopt.tex", "max_stars_repo_name": "tcsprojects/pgsolver", "max_stars_repo_head_hexsha": "88202c9452ccdcd4092280b4e76c31a16085d14c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2016-04-03T22:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T20:53:38.000Z", "max_issues_repo_path": "doc/univopt.tex", "max_issues_repo_name": "tcsprojects/pgsolver", "max_issues_repo_head_hexsha": "88202c9452ccdcd4092280b4e76c31a16085d14c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2015-03-28T15:29:29.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-22T16:48:34.000Z", "max_forks_repo_path": "doc/univopt.tex", "max_forks_repo_name": "tcsprojects/pgsolver", "max_forks_repo_head_hexsha": "88202c9452ccdcd4092280b4e76c31a16085d14c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2015-01-06T10:32:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T15:58:23.000Z", "avg_line_length": 61.7438423645, "max_line_length": 243, "alphanum_fraction": 0.7221158449, "num_tokens": 3637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4332994406916829}}
{"text": "\\newpage{}\n\n\\hypertarget{a004---reducing-dispersion-by-assigning-a-concrete-value-per-word-and-learning-from-it}{%\n\\section{A004 - reducing dispersion by assigning a concrete value per\nword and learning from\nit}\\label{a004---reducing-dispersion-by-assigning-a-concrete-value-per-word-and-learning-from-it}}\n\nA001 collects as many different values for each word as it can get. When\nestimating, it uses any of those values more or less randomly (of cause\nsmoothend by the fact that we take 100 random values and then only use a\nvalue from a certain position representing the percentage of certainty\nwe want to have). Anyways, that hinders our ability to ``learn''.\n\nThe idea behind this algorithm is to assign just one value to each word.\nThis way, when we see our error margin we might design a little learning\nalgorithm.\n\nFor example: - create an average model - while the mean squared error is\nhigher than \\ldots{} - create 10 mutation of that model, for example by\nrandomly adding or substracting 1/10th of the value to each weight of\neach word. - calculate the mean squared error for each mutation - take\nthe model with the least mean squared error and repeat\n", "meta": {"hexsha": "239e22029776800b18fa503b502d3864cf2a69f8", "size": 1163, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/10000-_Algorithms/A004/index_fr.tex", "max_stars_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_stars_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-09-12T17:24:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-22T06:43:27.000Z", "max_issues_repo_path": "Documentation/10000-_Algorithms/A004/index_fr.tex", "max_issues_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_issues_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 52, "max_issues_repo_issues_event_min_datetime": "2021-08-13T00:24:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-26T10:01:19.000Z", "max_forks_repo_path": "Documentation/10000-_Algorithms/A007/index_fr.tex", "max_forks_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_forks_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.5652173913, "max_line_length": 102, "alphanum_fraction": 0.7876182287, "num_tokens": 277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.43329942304377084}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{siunitx}\n\\usepackage{hyperref}\n\\usepackage{xcolor}\n\\large\n\n\\begin{document}\n\n \\title{GST108 : Introduction to Quantitative Reasoning}\n\n\\author{Oghenemaro Egbodo}\n\\maketitle\n\\newpage\n\\tableofcontents\n\\centering\n\\newpage\n\n\n\\section{Introduction}\nA logic gate is a building block of a digital circuit which is at the heart of any computer operation.\n\\\\\n\\subsection{LOGIC GATES}\nA logic gate is an idealized model of computation or physical electronic device implementing a Boolean function, a logical operation performed on one or more binary inputs that produces a single binary output. \n\\includegraphics{unknown.png}\n\\newpage\nBehind every digital system is a logic gate.\\\\\n\\includegraphics{unknown.jpeg}\n\\newpage\nLogic gates perform logical operations that take binary input (0s and 1s) and produce  a single binary output. They are used in most electronic device including.\\\\\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\begin{tabular}{|l|c|c|}\n\t\t\t\\hline\n\t\t Smartphones & Tablets & Memory Devices\\\\\n\t\t \\hline\n\t\t \\includegraphics[width=0.2\\linewidth]{Unknown-1.jpeg} & \\includegraphics[width=0.2\\linewidth]{Unknown-2.jpeg} & \\includegraphics[width=0.2\\linewidth]{Unknown-3.jpeg}\\\\\n\t\t \\hline\n\t\\end{tabular}\n\\end{center}\n\\end{table}\n\\newpage\n Now think of a logic gate like a light switch, it is either in an ON or OFF position. Similarly, the input output terminals are always in one of two binary positions false(0) and true(1). Each gate has its own logic or set of rules that determines how it acts based on multiple inputs outlined in a truth table.\n\\newpage\nCombining 10s, 1000s or millions of logic gates makes it possible for a computer to perform highly complex operations and tasks at ever increasing speeds.\n\\newpage\nA gate is a basic electronic circuit which operates on one or more signals to produce an output signal. \nLogic gates are digital circuits constructed from diodes, transistors, and resistors connected in such a way that the circuit output is the result of a basic logic operation \\textbf{(OR, AND, NOT)} performed on the inputs.\n\\newpage\n\\section{TYPES OF LOGIC GATES}\nFundamental gates are \\textbf{AND, OR} and \\textbf{NOT}\\\\\n\\includegraphics[width=0.3\\linewidth]{images.png}\\\\\nDerived Gates are \\textbf{NAND, NOR, XOR} and \\textbf{XNOR} (derived from the fundamental gates)\\\\\nUniversal Gates are \\textbf{NAND} and \\textbf{NOR} gates (the fundamental logic gates can be realized through them).\n\\\\\n\\newpage\n\\subsection{AND Gate}\nThe expression C = A X B reads as “C equals A AND B.“\\\\\nThe multiplication sign (X) stands for the AND operation, same for ordinary multiplication of 1s and 0s.\\\\\n \\includegraphics[width=0.5\\linewidth]{Picture 1.png} \\\\\nThe AND operation produces a true output (result of 1) only for the single case when all of the input variables are 1 and a false output (result of 0) where one or more inputs are 0.\n\\\\\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.5\\linewidth]{Unknown-4}\n\\end{figure}\n\\newpage\n\\includegraphics[width=0.2\\linewidth]{Picture 1-0.png} \\includegraphics[width=0.2\\linewidth]{Picture 1-1.png}\\\\\n\\includegraphics[width=0.2\\linewidth]{Picture 1-2.png} \\includegraphics[width=0.2\\linewidth]{Picture 1-3.png}\\\\\n\\newpage\n\\subsection{OR Gate}\nThe expression C = A + B reads as “C equals A OR B\". It is the inclusive “OR”\n\\\\\nThe Addition (+) sign stands for the OR operation\n\\\\\n\\includegraphics{Picture 2.png}\\\\\nThe OR operation produces a true output (result of 1) when any of the input variable is 1 and a false output (result of 0) only when all the input variables are 0.\n\\\\\n\\includegraphics{images-1.png}\n\\newpage\n\\includegraphics[width=0.3\\linewidth]{Picture 2-0.png} \\includegraphics[width=0.3\\linewidth]{Picture 2-1.png}\\\\\n\\includegraphics[width=0.3\\linewidth]{Picture 2-2.png} \\includegraphics[width=0.3\\linewidth]{Picture 2-3.png}\\\\\n\\newpage\n\\subsection{NOT GATE}\nThe NOT gate is called a logical inverter.\\\\\nIt has only one input. It reverses the original input (A) to give an inverted output C.\\\\\nC = NOT A or C = $\\overline{A}$\\\\\n\\includegraphics{Picture 3.png}\\\\\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.5\\linewidth]{Unknown-3}\n\\end{figure}\n\\newpage\n\\includegraphics[width=0.3\\linewidth]{Picture 4.png} \\includegraphics[width=0.3\\linewidth]{Picture 4-1.png}\n\\newpage\n\\subsection{NOR GATE}\nThe NOR (NOT OR) gate circuit is an inverter OR gate.\\\\\nC=$\\overline{(A+B)}$\\\\\nReads as C = NOT of A or B.\\\\\n\\includegraphics[width=0.3\\linewidth]{Picture 5.png}\\includegraphics[width=0.1\\linewidth]{Picture 5.1.png}  \\includegraphics[width=0.3\\linewidth]{Picture 5.2.png}\\\\\n\\includegraphics[width=0.3\\linewidth]{Unknown-4.png}\n\\newpage\n\\includegraphics[width=1.0\\linewidth]{Picture 6}\\\\\n\\newpage\n\n\\subsection{NAND GATE}\nThe NAND (NOT AND) Gate is an inverted AND Gate.\\\\\nC = $\\overline{((A x B)}$\\\\\nReads as C = NOT of A AND B.\\\\\nThe NAND Gate gives a false output (result of 0) only when both inputs are true (1).\\\\\n\\includegraphics[width=0.3\\linewidth]{Picture 7.png}\\includegraphics[width=0.1\\linewidth]{Picture 5.1.png}\\includegraphics[width=0.3\\linewidth]{Picture 7-1.png}\\\\\n\\includegraphics[width=0.5\\linewidth]{Unknown-5.png}\n\\newpage\n\\includegraphics[width=1.0\\linewidth]{Picture}\n\\newpage\n\\subsection{XOR GATE}\nAn XOR (exclusive OR) gate acts in the same way as the exclusive OR logical connector. \\\\\nIt gives a true output (result of 1) if one, and only one, of the inputs to the gate is true (1), i.e either or but not both.\\\\\nc = A $\\oplus$ B = A.$\\overline{B}$ + $\\overline{A}$.B\\\\\n\\includegraphics[width=0.4\\linewidth]{8} \\includegraphics[width=0.1\\linewidth]{Picture 5.1.png} \\includegraphics[width=0.4\\linewidth]{9}\\\\\n\\includegraphics[width=0.5\\linewidth]{Unknown-6.png}\\\\\n\\newpage\n\\subsection{XNOR GATE}\nThe XNOR (exclusive - NOR) gate is a combination XOR gate followed by an inverter. It is represented by the $\\odot$\\\\\nIts gives a  true output (1), if the inputs are the same, and a false output (0) if the inputs are different.\\\\\nC=$\\overline{A \\oplus B}$ = $\\overline{(\\overline{A}.B + A.\\overline{B})}$\\\\\n\\includegraphics[width=0.3\\linewidth]{10}\\includegraphics[width=0.1\\linewidth]{Picture 5.1.png} \\includegraphics[width=0.3\\linewidth]{11.1}\\\\\n\\includegraphics[width=0.8\\linewidth]{Unknown-7.png}\\\\\n\\newpage\n\\section{Logic Gates and their Truth Tables}\n\\includegraphics[width=1.0\\linewidth]{11}\n\\newpage\n\\section{Summary}\nUsing different combination of logic gates, complex operations can be performed.\\cite{grace2020} \\\\\nWith the Universal logic gates - NAND and NOR, any other gate can be built.\\\\\nThere is no limit to the number of gates that can be arranged together in a single device.\\\\\nHowever, in practice, there is a limit to the number of gates that can be packed into a given physical space. \n\\\\\nArrays of logic gates are found in digital integrated circuits.\n\\\\\n\\newpage\n\\subsection{Summary contd.}\nThe logic gates are abstract representations of real electronic circuits.\\cite{grace2021study}\\\\\nIn computers, Logic gates are built using transistors combined with other electrical components like resistors and diodes. \\\\\nThese electrical components are wired together in order to transform a particular input to give a desired output.\\\\\n\\href{https://www.youtube.com/watch?v=sTu3LwpF6XI&t=481s}{Making Logic Gates from Transistors\\textbf{(click to watch)}}\n\\newpage\n\\section{QUIZ}\nWhat is the output of an AND gate if the inputs are 1 and 0?\n\\\\\nExplain the difference between the AND gate and the OR gate.\\\\\nWhat is the output of a NOT gate if the inputs is 0?\\\\\nWhich logic gate is this?\n\\includegraphics[width=0.1\\linewidth]{12}\\\\\nWhich gate is also known as a logical converter?\n\\\\\n\\newpage\n\\bibliographystyle{ieeetr}\n\\bibliography{daBib}\n\\newpage\n\\includegraphics[width=1.0\\linewidth]{thanks}\n\n\\end{document}", "meta": {"hexsha": "32a4fe9d3e6dcfdd4ba659c4a8ef729e2fd498c7", "size": 7792, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week 5 P2.tex", "max_stars_repo_name": "EgbodoM2003/MaroCSC102", "max_stars_repo_head_hexsha": "44628b606b6ac9d467600b45c02ccc5d8b565803", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week 5 P2.tex", "max_issues_repo_name": "EgbodoM2003/MaroCSC102", "max_issues_repo_head_hexsha": "44628b606b6ac9d467600b45c02ccc5d8b565803", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week 5 P2.tex", "max_forks_repo_name": "EgbodoM2003/MaroCSC102", "max_forks_repo_head_hexsha": "44628b606b6ac9d467600b45c02ccc5d8b565803", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.8036809816, "max_line_length": 312, "alphanum_fraction": 0.7589835729, "num_tokens": 2296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.4332740021639}}
{"text": "%!TEX TX-program = xelatex\n\\documentclass{article}\n\\usepackage{allan-eason}\n\n\\usetikzlibrary{positioning}\n\\usetikzlibrary{svg.path}\n\n\\graphicspath{ {./images/}} \n\n\\newcommand{\\Title}{\\LaTeX\\ Test File}\n\\newcommand{\\Author}{Eason S.}\n\n\\title{\\Title}\n\\author{\\Author}\n\\date{\\today}\n\n\\geometry{a4paper, scale=0.8}\n\n\\lhead{\\Title}\n\n\\begin{document}\n\n\t\\maketitle\n\n\t\\section{Maxwell's Equations}\n\n\t\t\\subsection{Integral Format}\n\n\t\t\t\\defword{Maxwell's Equations} (in forms of \\defword{Integral}):\n\n\t\t\t\\begin{align}\n\t\t\t\t\\oiint_{S} \\vect{D} \\cdot \\diff \\vect{S} = \\sum q &= \\int_V \\rho \\diff V,\\\\\n\t\t\t\t\\oiint_{S} \\vect{B} \\cdot \\diff \\vect{S} &= 0,\\\\\n\t\t\t\t\\oint_{L} \\vect{H} \\cdot \\diff \\vect{l} = I + I_{\\diff} &= \\int_{S} \\vect{j} \\cdot \\diff \\vect{S} + \\int_{S} \\frac{\\partial \\vect{D}}{\\partial t} \\cdot \\diff \\vect{S},\\\\\n\t\t\t\t\\oint_{L} \\vect{E} \\cdot \\diff \\vect{l} = - \\frac{\\diff \\varPhi}{\\diff t} &= - \\int_{S} \\frac{\\partial \\vect{B}}{\\partial t} \\cdot \\diff \\vect{S}.\n\t\t\t\\end{align}\n\n\t\t\tHere, (1) states for the \\defword{Gauss Theorem} in an \\defword{Electric Field}, while (2) states for the \\defword{Gauss Theorem} in an \\defword{Magnetic Field}. (3) states for the relationship between \\defword{A Changing Electric Field} and a magnetic field, or \\defword{Ampere's Circulation Theorem}. (4) states for the relationship between \\defword{A Changing Magnetic Field} and a electric field, or \\defword{Faraday's Theorem of induction}.\n\n\t\\section{Partial Derivative}\n\n\t\t\\subsection{Definition}\n\n\t\t\tLet \\(t=f(x, y, \\ldots)\\), the \\defword{Partial Derivative} of \\(f\\) towards \\(x\\) is\n\n\t\t\t\\[\n\t\t\t\tf'_{x} = \\partial_x f = D_x f = D_1 f = \\frac{\\partial}{\\partial x} f = \\frac{\\partial f}{\\partial x} = \\lim_{\\Delta x \\rightarrow 0} \\frac{f(x + \\Delta x, y, \\ldots) - f(x, y, \\ldots)}{\\Delta x}.\n\t\t\t\\]\n\n\t\t\tDefine vector \\(\\vect{a} = (x, y, \\ldots), \\vect{\\hat{e}_x} = (1, 0, \\ldots)\\), therefore\n\n\t\t\t\\[\n\t\t\t\t\\frac{\\partial}{\\partial x} f = \\lim_{x\\rightarrow 0} \\frac{f(\\vect{a} + h \\vect{e_x}) - f(\\vect{a})}{h}.\n\t\t\t\\]\n\n\t\t\\subsection{Gradient}\n\n\t\t\tDefine \\defword{Gradient} as following:\n\n\t\t\t\\[\n\t\t\t\t\\Grad f(\\vect{a}) = \\nabla f(\\vect{a}) = \\left(\\at{\\frac{\\partial f}{\\partial x}}{\\vect{a}}, \\at{\\frac{\\partial f}{\\partial y}}{\\vect{a}}, \\ldots\\right).\n\t\t\t\\]\n\n\t\t\tWe usually deine Gradient as following in a 3-Dimensional Space:\n\n\t\t\t\\[\n\t\t\t\t\\Grad = \\nabla = \\left[\\frac{\\partial}{\\partial x}\\right]\\vect{\\hat{e}_x} + \\left[\\frac{\\partial}{\\partial y}\\right]\\vect{\\hat{e}_y} + \\left[\\frac{\\partial}{\\partial z}\\right]\\vect{\\hat{e}_z}.\n\t\t\t\\]\n\n\t\t\\subsection{Directional Derivative}\n\n\t\t\tDefine the \\defword{Directional Derivative} along vector \\(\\vect{v} = \\left(v_1, v_2, \\ldots\\right)\\),\n\n\t\t\t\\[\n\t\t\t\t\\nabla_{\\vect{v}} f(\\vect{a}) = \\lim_{x \\rightarrow 0} \\frac{f(\\vect{a} + h \\vect{v}) - f(\\vect{a})}{h}.\n\t\t\t\\]\n\n\t\t\\subsection{Laplace Operator}\n\n\t\t\tDefine the \\defword{Laplace Operator} as following:\n\n\t\t\t\\[\n\t\t\t\t\\Delta = \\frac{\\partial^2}{\\partial x^2} + \\frac{\\partial^2}{\\partial y^2} + \\frac{\\partial^2}{\\partial z^2} = \\nabla \\cdot \\nabla = \\nabla^2.\n\t\t\t\\]\n\n\t\t\\subsection{Divergence}\n\n\t\t\tDefine the \\defword{Divergence} of a vector as following: (it outputs a value)\n\n\t\t\t\\[\n\t\t\t\t\\Div \\vect{v} = \\nabla \\cdot \\vect{v} = \\left(\\frac{\\partial}{\\partial x}, \\frac{\\partial}{\\partial y}, \\frac{\\partial}{\\partial z} \\right) \\cdot \\left(v_x, v_y, v_z\\right) = \\frac{\\partial v_x}{\\partial x} + \\frac{\\partial v_y}{\\partial y} + \\frac{\\partial v_z}{\\partial z}.\n\t\t\t\\]\n\n\n\\end{document}", "meta": {"hexsha": "fd14b6172224e4985b8ab868c16a03c119c1e815", "size": 3465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX Test File/LaTeX Test File.tex", "max_stars_repo_name": "EasonSYC/LaTeX-Templates", "max_stars_repo_head_hexsha": "224b477345887ac6bab199b76d49f4bcd9c26917", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX Test File/LaTeX Test File.tex", "max_issues_repo_name": "EasonSYC/LaTeX-Templates", "max_issues_repo_head_hexsha": "224b477345887ac6bab199b76d49f4bcd9c26917", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX Test File/LaTeX Test File.tex", "max_forks_repo_name": "EasonSYC/LaTeX-Templates", "max_forks_repo_head_hexsha": "224b477345887ac6bab199b76d49f4bcd9c26917", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4736842105, "max_line_length": 448, "alphanum_fraction": 0.6308802309, "num_tokens": 1300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.43327399869117467}}
{"text": "\\documentclass{article}\n\n\\usepackage{tabu}\n\\usepackage{pbox}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{xcolor}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{setspace}\n\\usepackage{tikz}\n\\usepackage{circuitikz}\n\n\\frenchspacing\n\\setlength{\\parskip}{1em}\n\\renewcommand{\\arraystretch}{1.5}\n\\setlength\\parindent{0pt}\n\\DeclareMathSizes{10}{12}{8}{6}\n\n\\begin{document}\n\n\\section{MOSFETs}\n\n\\textbf{Definitions:}\n\n\\vspace{-5mm}\n\\begin{itemize} \\itemsep0pt\n\t\\item \\(k_n \\equiv \\mu_nC_{ox} \\frac{W}{L}\\), \\(k_p \\equiv \\mu_pC_{ox} \\frac{W}{L}\\)\n\t\\item \\(k'_n \\equiv \\mu_nC_{ox}\\), \\(k'_p \\equiv \\mu_pC_{ox}\\)\n\t\\item \\(V_{OV} \\equiv V_{GS}-V_{th}\\)\n\t\\item \\(V_A \\equiv \\frac{1}{\\lambda}\\)\n\t\\item \\(V'_A \\equiv \\frac{V_A}{L}\\)\n\t\\item \\(g_m \\equiv \\frac{\\partial i_D}{\\partial v_{GS}} = \\frac{i_d}{v_{gs}}\\)\n\\end{itemize}\n\n\\textbf{Large signal characteristics, \\(k=k_n\\) or \\(k_p\\) as appropriate:}\n\n\\begin{tabu}{  l  X  X  }\n\t\\hline\n\tRegion & Condition & Properties \\\\ \\hline\n\tSaturation & \\(|V_{GS}| > |V_{th}| \\bigwedge |V_{DS}| \\geq |V_{OV}|\\) &\n\t\\pbox{10cm}{\n\t\t\\vspace{1mm}\n\t\t\\(\\begin{aligned}\n\t\t\t\t\tI_D &= \\frac{k}{2} V_{OV}^2 (1+\\frac{V_{DS}}{V_A}) \\\\\n\t\t\t\t\t&\\approx \\frac{k}{2} V_{OV}^2\n\t\t\\end{aligned}\\)\n\t}\\\\\n\n\tTriode & \\(|V_{GS}| > |V_{th}| \\bigwedge |V_{DS}| \\leq |V_{OV}|\\) &\n\t\\pbox{10cm}{ \\(I_D = k(|V_{OV}|-\\frac{1}{2}|V_{DS}|)|V_{DS}|\\) } \\\\\n\n\tCutoff & \\(|V_{GS}| \\leq |V_{th}|\\) & \\(I_D = 0\\)\\\\\n\t\\hline\n\\end{tabu}\n\nFor N-channel devices, all absolute value operations can be ignored.\n\n\\vspace{5mm}\n\\textbf{Small signal characteristics (saturation only):}\n\n\\begin{circuitikz}[american voltages] \\draw\n\t\t(0,2) node[anchor=east]{G}\n\t\tto[short, o-] (1,2)\n\t\tto[open, v<=\\(v_{gs}\\)] (1,0)\n\t\t(1,0) -- (3,0)\n\t\tto[short, -o] (3,-1)\n\t\tnode[anchor=east]{S}\n\t\t(3,2) to[american controlled current source, l_=\\(g_mv_{gs}\\), -*] (3,0)\n\t\t-- (5,0)\n\t\tto[R, l=\\(r_o\\), -*] (5,2)\n\t\t(3,2) -- (5,2)\n\t\tto[short, -o] (6,2)\n\t\tnode[anchor=west]{D}\n;\n\\end{circuitikz}\n\n\\vspace{-5mm}\n\\begin{itemize}\n\t\\item \\(g_m = \\frac{2I_D}{V_{OV}} = k|V_{OV}| = \\sqrt{2kI_D}\\)\n\t\\item \\(r_o = \\frac{V_A}{I_D}\\)\n\\end{itemize}\n\n\\newpage\n\\section{BJTs}\n\n\\textbf{Definitions:}\n\n\\vspace{-5mm}\n\\begin{itemize} \\itemsep0pt\n\t\\item \\(V_T \\equiv \\frac{kT}{q} \\approx 25\\text{mV}\\)\n\t\\item \\(\\alpha \\equiv \\frac{\\beta}{\\beta + 1}\\)\n\t\\item \\(g_m \\equiv \\frac{\\partial I_C}{\\partial V_{BE}}\\)\n\\end{itemize}\n\n\\textbf{Large signal characteristics:}\n\n\\begin{tabu}{  l  X  X  }\n\t\\hline\n\tRegion & Condition & Properties \\\\ \\hline\n\n\tSaturation & Both junctions forward biased &\n\t\\pbox{10cm}{\n\t\t\\vspace{-5mm}\n\t\t\\setstretch{1.2}\n\t\t\\(|V_{BE}| \\approx 0.7\\text{V}\\) \\\\\n\t\t\\(|V_{CE}| \\approx 0.2\\text{V}\\) \\\\\n\t\t\\(|V_{BC}| \\approx 0.5\\text{V}\\) \\\\\n\t\t\\(I_C = \\beta_{forced} I_B\\)\n\t}\n\t\\\\[-13mm]\n\n\tActive & EB junction forward biased, CB junction reverse biased &\n\t\\pbox{10cm}{\n\t\t\\setstretch{1.3}\n\t\t\\(\\begin{aligned}\n\t\t\t\t\tI_C &= I_S e^{\\frac{|V_{BE}|}{V_T}} (1 + \\frac{V_{CE}}{V_A}) \\\\[-3mm]\n\t\t\t\t\t\t   &\\approx I_S e^{\\frac{|V_{BE}|}{V_T}}\n\t\t\\end{aligned} \\) \\\\\n\t\t\\(I_C = \\beta I_B\\) \\\\\n\t\t\\(I_E = \\frac{I_C}{\\alpha} = I_B + I_C\\) \\\\\n\t\t\\(|V_{BE}| \\text{is effectively limited at around 0.7V}\\)\n\t} \\\\[-5mm]\n\n\tCutoff & Both junctions reverse biased & \\(I_C = I_B = 0\\) \\\\[1mm]\n\t\\hline\n\\end{tabu}\n\nA junction is considered forward biased if the voltage over it is greater than 0.4V. For NPN devices, all absolute value operations can be ignored.\n\n\\vspace{5mm}\n\\textbf{Small signal characteristics (active only):}\n\n\\begin{circuitikz}[american voltages] \\draw\n\t\t(0,2) node[anchor=east]{B}\n\t\tto[short, o-] (1,2)\n\t\tto[R, l=\\(r_\\pi\\), v<=\\(v_{be}\\)] (1,0)\n\t\t(1,0) -- (4,0)\n\t\tto[short, -o] (4,-1)\n\t\tnode[anchor=east]{E}\n\t\t(4,2) to[american controlled current source, l_=\\(g_mv_{be}\\), -*] (4,0)\n\t\t-- (6,0)\n\t\tto[R, l=\\(r_o\\), -*] (6,2)\n\t\t(4,2) -- (6,2)\n\t\tto[short, -o] (7,2)\n\t\tnode[anchor=west]{C}\n;\n\\end{circuitikz}\n\n\\vspace{-5mm}\n\\begin{itemize}\n\t\\item \\(g_m = \\frac{I_C}{V_T}\\)\n\t\\item \\(r_{\\pi} = \\frac{\\beta}{g_m} = \\frac{V_T}{I_B}\\)\n\t\\item \\(r_o = \\frac{V_A}{I_C}\\)\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "b115a2348bb212754b1b4d26c185adbba8d3a2e1", "size": 4029, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "transistor-cheatsheet.tex", "max_stars_repo_name": "j201/transistor-cheatsheet", "max_stars_repo_head_hexsha": "afea8738294e5c26601398bb8fac5c053a794a38", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "transistor-cheatsheet.tex", "max_issues_repo_name": "j201/transistor-cheatsheet", "max_issues_repo_head_hexsha": "afea8738294e5c26601398bb8fac5c053a794a38", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-10-24T03:20:55.000Z", "max_issues_repo_issues_event_max_datetime": "2015-11-25T19:11:54.000Z", "max_forks_repo_path": "transistor-cheatsheet.tex", "max_forks_repo_name": "j201/transistor-cheatsheet", "max_forks_repo_head_hexsha": "afea8738294e5c26601398bb8fac5c053a794a38", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6624203822, "max_line_length": 147, "alphanum_fraction": 0.5994043187, "num_tokens": 1734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.4332057613953686}}
{"text": "\\section{Conclusion}\n\nThe main research question is whether Chinese stocks show a positive return-variance correlation.\nWe cannot claim that in general since, in all periods, more than half of the Chinese companies' leverage effect is insignificant, i.e.\\ the posterior $\\rho$'s 5\\% to 95\\% credible interval contains the 0.\nOn the other hand, we see that the Chinese market participants uniformly have weaker leverage effect than the German ones.\nMoreover, sometimes they even have anti-leverage.\n\nExamining further differences and similarities is most interesting with the global crisis of 2007 in mind.\nWe found proof for $\\rho$ being shifted to the negative direction throughout the crisis.\nEven though the negative shift is present unquestionably in both countries, the hectic changes of the leverage effect in China bring doubts about the importance of the crisis as a driving factor.\n\nWhile $\\rho$ behaves similarly in China and in Germany throughout the crisis, estimates of $\\phi$ contrast the two countries at the same period.\nWhen there is a trend in the volatility, i.e.\\ it is not constant plus white noise, then there is high autocorrelation and persistence.\nThese trends exist in the German stocks' volatilities around the Subprime Crisis and the European Debt Crisis, so at those times $\\phi$ is considerably larger than its prior.\nOn the contrary, this phenomenon is not present in China.\n\n\\subsection*{Future work}\n\nWhile there are many possible explanations for the leverage effect, there is not any for the anti-leverage effect, to the best of our knowledge.\nUnusual regulations are likely to be the main factor here, but a different investment culture is also a possible reason.\nEither way, a microeconomics-based approach could be the key that models agents maximising utility in a well designed environment.\n\nFinally, time-varying leverage effect models could be another direction for improvements.\nSimple linear functions would not be sufficient to model the shifts in crises, probably a higher order polynomial that still avoids overfitting, or an ARCH process for $\\rho$ would increase the predictive power.\nWe did not find such attempts in the literature.\n\n", "meta": {"hexsha": "a5a24b53edeed64a33a9c0ae578ef68ce22b3c56", "size": 2184, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/sections/conclusion.tex", "max_stars_repo_name": "hdarjus/master-thesis", "max_stars_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-23T12:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-23T12:51:22.000Z", "max_issues_repo_path": "thesis/sections/conclusion.tex", "max_issues_repo_name": "hdarjus/master-thesis-WU", "max_issues_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/sections/conclusion.tex", "max_forks_repo_name": "hdarjus/master-thesis-WU", "max_forks_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-12T00:39:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-12T00:39:19.000Z", "avg_line_length": 80.8888888889, "max_line_length": 211, "alphanum_fraction": 0.8067765568, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.43320575747002726}}
{"text": "\\section{Realizability-Enforcing Limiter}\n\\label{sec:limiter}\n\nCondition~2 of Theorem~\\ref{the:realizableDGIMEX} requires that the polynomial approximation $\\vect{\\cM}_{h}=\\vect{\\cM}_{h}^{(j)}$ ($j\\in\\{0,\\ldots,i-1\\}$) is realizable in every point in the quadrature set $S=\\cup_{k=1}^{d}\\hat{\\vect{S}}^{k}$.  \nFollowing Zhang \\& Shu \\cite{zhangShu_2010a} we use the limiter in \\cite{liuOsher_1996} to enforce the bounds on the zeroth moment $\\cJ$.  \n%The bound-preserving DG-IMEX method developed in previous sections is designed to preserve realizability of the cell averaged moments, i.e., $\\vect{\\cM}_{\\bK}\\in\\cR$, provided sufficiently accurate quadratures are used to integrate integrals in the DG method, a CFL condition is satisfied, and that the polynomial approximation $\\vect{\\cM}_{h}$, at time $t^{n}$, is realizable in a set of quadrature points in each element $\\bK$.  \n%We denote this quadrature set by $S=\\cup_{k=1}^{d}\\hat{\\vect{S}}^{k}\\subset\\bK$.  \n%In the DG method, we use the limiter proposed by Zhang \\& Shu \\cite{zhangShu_2010a} for scalar conservation laws to enforce the bounds on the zeroth moment $\\cJ$ (see also \\cite{liuOsher_1996}).  \nWe replace the polynomial $\\cJ_{h}(\\vect{x})$ with the limited polynomial\n\\begin{equation}\n  \\tilde{\\cJ}_{h}(\\vect{x})\n  =\\vartheta_{1}\\,\\cJ_{h}(\\vect{x})+(1-\\vartheta_{1})\\,\\cJ_{\\bK},\n  \\label{eq:limitDensity}\n\\end{equation}\nwhere the limiter parameter $\\vartheta_{1}$ is given by\n\\begin{equation}\n  \\vartheta_{1}\n  =\\min\\Big\\{\\,\\Big|\\f{M-\\cJ_{\\bK}}{M_{S}-\\cJ_{\\bK}}\\Big|,\\Big|\\f{m-\\cJ_{\\bK}}{m_{S}-\\cJ_{\\bK}}\\Big|,1\\,\\Big\\},\n\\end{equation}\nwith $m=0$ and $M=1$, and\n\\begin{equation}\n  M_{S}=\\max_{\\vect{x}\\in S}\\cJ_{h}(\\vect{x})\n  \\quad\\text{and}\\quad\n  m_{S}=\\min_{\\vect{x}\\in S}\\cJ_{h}(\\vect{x}).  \n\\end{equation}\n\nIn the next step, we ensure realizability of the moments by following the framework of \\cite{zhangShu_2010b}, developed to ensure positivity of the pressure when solving the Euler equations of gas dynamics.  \nWe let $\\widetilde{\\vect{\\cM}}_{h}=\\big(\\tilde{\\cJ}_{h},\\vect{\\cH}_{h}\\big)^{T}$.  \nThen, if $\\widetilde{\\bcM}_{h}$ lies outside $\\cR$ for any quadrature point $\\vect{x}_{q}\\in S$, i.e., $\\gamma(\\widetilde{\\bcM}_{h})<0$, there exists an intersection point of the straight line, $\\vect{s}_{q}(\\psi)$, connecting $\\vect{\\cM}_{\\bK}\\in\\cR$ and $\\widetilde{\\vect{\\cM}}_{h}$ evaluated in the troubled quadrature point $\\vect{x}_{q}$, denoted $\\widetilde{\\vect{\\cM}}_{q}$, and the boundary of $\\cR$.  \nThis line is given by the convex combination \n\\begin{equation}\n  \\vect{s}_{q}(\\psi)=\\psi\\,\\widetilde{\\vect{\\cM}}_{q}+(1-\\psi)\\,\\bcM_{\\bK},\n\\end{equation}\nwhere $\\psi\\in[0,1]$, and the intersection point $\\psi_{q}$ is obtained by solving $\\gamma(\\bs_{q}(\\psi))=0$ for $\\psi$, using the bisection algorithm\\footnote{In practice, $\\psi$ needs not be accurate to many significant digits, and the bisection algorithm can be terminated after a few iterations.}.  \nWe then replace the polynomial representation $\\widetilde{\\vect{\\cM}}_{h}\\to\\widehat{\\vect{\\cM}}_{h}$, where\n\\begin{equation}\n  \\widehat{\\vect{\\cM}}_{h}(\\vect{x})=\\vartheta_{2}\\,\\widetilde{\\vect{\\cM}}_{h}(\\vect{x})+(1-\\vartheta_{2})\\,\\vect{\\cM}_{\\bK},\n  \\label{eq:limitMoments}\n\\end{equation}\nand $\\vartheta_{2}=\\min_{q}\\psi_{q}$ is the smallest $\\psi$ obtained in the element by considering all the troubled quadrature points.  \nThis limiter is conservative in the sense that it preserves the cell-average $\\widehat{\\vect{\\cM}}_{\\bK}=\\widetilde{\\vect{\\cM}}_{\\bK}=\\vect{\\cM}_{\\bK}$.  \n\nThe realizability-preserving property of the DG-IMEX scheme results from the following theorem.\n\\begin{theorem}\n  Consider the IMEX scheme in Eqs.~\\eqref{imexStages}-\\eqref{eq:imexCorrection} applied to the DG discretization of the two-moment model in Eq.~\\eqref{eq:semidiscreteDG}.  \n  Suppose that\n  \\begin{itemize}\n    \\item[1.] The conditions of Theorem~\\ref{the:realizableDGIMEX} hold.  \n    \\item[2.] With $\\vect{\\cM}_{\\bK}^{(i)}\\in\\cR$, the limiter described above is invoked to enforce \n    \\begin{equation*}\n      \\vect{\\cM}_{h}^{(i)}(\\vect{x})\\in\\cR ~ \\text{for all} ~ \\vect{x} \\in S.  \n    \\end{equation*}\n    \\item[3.] The IMEX scheme is GSA.  \n  \\end{itemize}\n  Then $\\vect{\\bcM}_{\\bK}^{n+1}\\in\\cR$.  \n  \\label{the:realizableDGIMEX2}\n\\end{theorem}\n\\begin{proof}\n  By Theorem~\\ref{the:realizableDGIMEX} (with $i=1$), we have $\\vect{\\cM}_{\\bK}^{(1)}\\in\\cR$.  \n  Application of the realizability-enforcing limiter gives $\\vect{\\cM}_{h}^{(1)}(\\vect{x})\\in\\cR$ for all $\\vect{x} \\in S$.  \n  Repeated application of these steps give $\\vect{\\cM}_{h}^{(i)}(\\vect{x})\\in\\cR$ for all $\\vect{x} \\in S$ and $i\\in\\{1,\\ldots,s\\}$.  \n  Since the IMEX scheme is GSA, $\\tilde{\\vect{\\cM}}_{\\bK}^{n+1}\\in\\cR$.  \n  Finally, $\\vect{\\bcM}_{\\bK}^{n+1}\\in\\cR$ follows from Lemma~\\ref{lem:imexCorrectionCellAverage}.  \n\\end{proof}", "meta": {"hexsha": "89e879e74c506c712bfaa62f47966fa0cba8ec61", "size": 4850, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/realizableFermionicM1/sections/limiter.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/realizableFermionicM1/sections/limiter.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/realizableFermionicM1/sections/limiter.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 75.78125, "max_line_length": 432, "alphanum_fraction": 0.6837113402, "num_tokens": 1730, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.43320574569400283}}
{"text": "\\documentclass[a4paper,11pt]{article}\n%\\documentclass[a4paper,11pt]{scrartcl}\n\n\n\n\\input{../preambles/preamble}\n\\input{../preambles/unicode}\n\n\\setmainlanguage{english}\n\\setotherlanguages{german,greek,russian}\n\n\\input{../preambles/math-single}\n\\input{../preambles/math-brac}\n\\input{../preambles/math-thm}\n\\input{../preambles/phys-chem}\n\n\\setromanfont[Mapping=tex-text]{Linux Libertine O}\n% \\setsansfont[Mapping=tex-text]{DejaVu Sans}\n% \\setmonofont[Mapping=tex-text]{DejaVu Sans Mono}\n\n\\usepackage[style=authoryear-icomp,\n\t\t\tbackend=biber]{biblatex}\n\\addbibresource{../singular-dynamics.bib}\n\n\\title{Notes on Canonical Singular Dynamics}\n\\author{Yi-Fan Wang (王\\ 一帆)}\n%\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\section{Classical formalism}\n\nLagrangian with velocity\n\\begin{equation}\nL^\\text{v} \\coloneqq \\fat{L}{\\dot{q} = v}\n\\end{equation}\nEquations of motion\n\\begin{equation}\n\\sum_j M_{ij}\\dot{v}_j = K^\\text{v}_i,\\quad\n\\dot{q}_i = v_i.\n\\end{equation}\nwhere\n\\begin{equation}\n\\rfun{M_{ij}}{q,v} \\coloneqq \\frpa{^2 L^\\text{v}}{v_i\\,\\partial v_j}.\n\\end{equation}\n\nAdding\n\\begin{equation}\np_i \\coloneqq \\frpa{L^\\text{v}}{v_i}.% \\eqqcolon \\rfun{\\ol{p}_i}{q,v}.\n\\end{equation}\nVariation of\n\\begin{equation}\n\\sfun{S}{q, p; v} \\coloneqq \\int\\dd t\\,\\sbr{L^\\text{v} + \\sum_i \np_i\\rbr{\\dot{q}_i - v_i}}.\n\\end{equation}\ngives the \\emph{Euler--Lagrange equations with velocities}\n\\begin{equation}\n\\dot{q}_i = v_i,\\quad\n\\dot{p}_i = \\frpa{L^\\text{v}}{q_i},\\quad\np_i = \\frpa{L^\\text{v}}{v_i}.\n\\end{equation}\n\nHamiltonian with velocity\n\\begin{equation}\n\\rfun{H^\\text{v}}{q, p; v} \\coloneqq \\sum_i p_i v_i - L^\\text{v}.\n\\end{equation}\nIdentities\n\\begin{equation}\n\\frpa{H^\\text{v}}{q_i} \\equiv - \\frpa{L^\\text{v}}{q_i},\\quad\n\\frpa{H^\\text{v}}{p_i} \\equiv v_i,\\quad\n\\frpa{H^\\text{v}}{v_i} \\equiv p_i - \\frpa{L^\\text{v}}{v_i}.\n\\end{equation}\nVariation of\n\\begin{equation}\n\\sfun{S}{q, p; v} \\coloneqq \\int\\dd t\\,\\sbr{\\sum_i \np_i \\dot{q}_i - H^\\text{v}}\n\\end{equation}\ngives the \\emph{canonical equations with velocities}\n\\begin{equation}\n\\dot{q}_i = \\sbr{q_i, H^\\text{v}}_\\text{P},\\quad\n\\dot{p}_i = \\sbr{p_i, H^\\text{v}}_\\text{P},\\quad\n\\frpa{H^\\text{v}}{v_i} = 0,\n\\end{equation}\nwhere the \\emph{Poisson bracket} is defined as\n\\begin{equation}\n\\sbr{f^\\text{v}, g^\\text{v}}_\\text{P} \\coloneqq \n\\sum_i\\rbr{\\frpa{f^\\text{v}}{q_i}\\frpa{g^\\text{v}}{p_i} -\n\\frpa{f^\\text{v}}{p_i}\\frpa{g^\\text{v}}{q_i}}.\n\\end{equation}\n\n$v_a = \\rfun{\\ol{v}_a}{q,p;\\cbr{v_\\alpha}}$ can be solved, $a = 1, 2, \\ldots, \nr_M$; $v_\\alpha$ \ncannot be solved, $\\alpha = r_M + 1, \\ldots, n$, where $r_M = \\rank M$.\n\n(need to show $v_a = \\rfun{\\ol{v}_a}{q,p_a}$)\n\n\\emph{Primary constraints in the standard form}\n\\begin{equation}\n\\rfun{\\Phi_\\alpha}{q, p} \\coloneqq\n\\fat{\\frpa{H^\\text{v}}{v_\\alpha}}{\\cbr{v_\\alpha = \\ol{v}_\\alpha}} \\equiv\np_\\alpha - \\rfun{\\ol{p}_\\alpha}{q, \\cbr{p_a}},\n\\end{equation}\nwhere\n\\begin{equation}\n\\rfun{\\ol{p}_\\alpha}{q, \\cbr{p_a}} \n\\coloneqq \\fat{\\frpa{L^\\text{v}}{v_\\alpha}}{\\cbr{v_a = \\ol{v}_a}}.\n\\end{equation}\n\n\n\\emph{Hamiltonian with primary constraint}\n\\begin{equation}\nH^\\text{p} \\coloneqq \\fat{H^\\text{v}}{\\cbr{v_a = \\ol{v}_a}} \\equiv\n\\rfun{H^\\text{v}}{q, p; \\cbr{\\rfun{\\ol{v}^a}{q, p_a; \\cbr{v_\\alpha}}, \nv_\\alpha}}.\n\\end{equation}\n\n\\emph{Subspace of primary constraints}\n\\begin{equation}\n\\Gamma_\\text{P} = \\cbr{ \\rbr{q, p}\\, |\\, \\rfun{\\Phi_\\alpha}{q, p} = 0, \n\\forall \\alpha}\n\\end{equation}\n\nSince\n\\begin{equation}\n\\frpa{H^\\text{p}}{v_\\alpha} =\n\\fat{\\frpa{H^\\text{v}}{v_\\alpha}}{\\cbr{v_a = \\ol{v}_a}} = \\Phi_\\alpha\n\\equiv p_\\alpha - \\rfun{\\ol{p}_\\alpha}{q, \\cbr{p_a}},\n\\end{equation}\n$H^\\text{p}$ is linear in $v_\\alpha$. One writes\n\\begin{equation}\n\\rfun{H^\\text{p}}{q, \\cbr{p_a}; \\cbr{p_\\alpha}, \\cbr{v_\\alpha}} = \\rfun{H}{q, \n\\cbr{p_a}} + \\sum_\\alpha v_\\alpha \\Phi_\\alpha,\n\\end{equation}\nwhere $H^\\text{c}$ is the \\emph{canonical Hamiltonian} or simply \n\\emph{Hamiltonian}.\n\n\\paragraph{Proposition}\n$H^\\text{c}$ is independent of $\\cbr{p_\\alpha}$.\n\n\\paragraph{Proposition}\nCanonical equations with primary constraints\n\\begin{align}\n\\dot{q}_i &= \\sbr{q_i, H}_\\text{P} + \\sum_\\beta v_\\beta \n\\sbr{q_i, \\phi_\\beta}_\\text{P},\n\\label{eq:q-i-primary}\\\\\n\\dot{p}_i &= \\sbr{p_i, H}_\\text{P} + \\sum_\\beta v_\\beta \n\\sbr{p_i, \\phi_\\beta}_\\text{P}, \\\\\n\\rfun{\\Phi_\\alpha}{q, p} &= 0,\n\\end{align}\nwhere $v_\\beta$'s are undetermined. Note that \\cref{eq:q-i-primary} for $i = \n\\alpha$ holds identically: $\\dot{q}_\\alpha = \\dot{q}_\\alpha$.\n\nWeak equality: $f_1 \\approx f_2$ iff $\\fat{f_1}{\\Gamma_\\text{P}} = \n\\fat{f_2}{\\Gamma_\\text{P}}$.\n\n\\paragraph{Proposition} if $f$ and $g$ are two functions over the phase space \n$\\Gamma$, and $f \\approx h$, then\n\\begin{align}\n\\frpa{}{q_i} \\rbr{f-\\sum_\\beta \\phi_\\beta \\frpa{f}{p_\\beta}} &\\approx \n\\frpa{}{q_i} \\rbr{h-\\sum_\\beta \\phi_\\beta \\frpa{h}{p_\\beta}}, \\\\\n\\frpa{}{p_i} \\rbr{f-\\sum_\\beta \\phi_\\beta \\frpa{f}{p_\\beta}} &\\approx \n\\frpa{}{p_i} \\rbr{h-\\sum_\\beta \\phi_\\beta \\frpa{h}{p_\\beta}}.\n\\end{align}\n\n\\paragraph{Corollary}\n$\\forall H_1 \\approx H$,\n\\begin{equation}\n\\dot{q}_i \\approx \\sbr{q_i, H}_\\text{P},\\qquad\n\\dot{p}_i \\approx \\sbr{p_i, H}_\\text{P}.\n\\end{equation}\n\nPrimary and second constraints $\\phi^{(1,)}_\\mu$, $\\phi^{(2,)}_\\omega$; first \nand second class constraints $\\phi^{(,1)}_u$, $\\phi^{(,2)}_w$.\n\n\n\n\\section{Examples}\n\n%\\begin{equation}\n%L^\\text{v} = \\frac{1}{2} \\sum_{i,j}\\rfun{W_{ij}}{q} v_i v_j + \\sum_i \n%\\rfun{\\eta_i}{q} \n%v_i - \\rfun{V}{q}.\n%\\end{equation}\n\n%\\begin{equation}\n%p_i = \\frpa{L^\\text{v}}{v_i} = \\sum_{i,j} W_{ij} v_j + \\eta_i.\n%\\end{equation}\n\n%Let\n%\\begin{align}\n%\\sum_j W_{ij} e_j^{(a)} &= \\lambda^{(a)} e_i \\neq 0, \\\\\n%\\sum_j W_{ij} e_j^{(\\alpha)} &= 0.\n%\\end{align}\n\n\\subsection{Toy examples}\n\n\\subsubsection*{Example 0}\n\\cite[sec.\\ 1.2]{Gitman1990}\n\\begin{equation}\nL = \\frac{1}{2}\\rbr{\\dot{x}-y}^2\n\\end{equation}\n\n\n\\subsubsection*{Example 1}\n\\begin{equation}\nL = \\frac{1}{2} \\dot{x}^2 + \\dot{x} y - \\frac{1}{2}\\rbr{x-y}^2.\n\\end{equation}\n\nOne has\n\\begin{equation}\nL^\\text{v} = \\frac{1}{2} v_x^2 + v_x y - \\frac{1}{2} \\rbr{x-y}^2,\n\\end{equation}\nso that\n\\begin{equation}\np_x = \\frpa{L^\\text{v}}{v_x} = v_x + y, \\qquad p_y = 0,\n\\end{equation}\nthus\n\\begin{equation}\n\\ol{v}_x = p_x - y.\n\\end{equation}\nSo that $v_y$ is the primary inexpressible velocity.\n\nThe Hamiltonian with velocity reads\n\\begin{equation}\n\\rfun{H^\\text{v}}{q, p; v} = v_x p_x + v_y p_y - \\frac{1}{2} v_x^2 - v_x y \n+ \\frac{1}{2}\\rbr{x-y}^2,\n\\end{equation}\nwhilst the Hamiltonians are\n\\begin{align}\n\\rfun{H^\\text{p}}{q, p; \\ol{v}_x, v_y} &= H^\\text{c} + v_y \\Phi_1,\\\\\n\\rfun{H^\\text{c}}{q, p} &= \\frac{1}{2}\\rbr{p_x - y}^2 + \\frac{1}{2} \\rbr{x-y}^2,\n\\end{align}\nwhere the only primary constraint $\\Phi_1 = p_y$.\n\nPersistence condition of $\\Phi_1$ leads to\n\\begin{equation}\n0 \\approx \\sbr{\\Phi_1, H^\\text{p}}_\\text{P} = p_x + x - 2y \\eqqcolon \\Phi_2.\n\\end{equation}\nNote that $\\sbr{\\Phi_1, \\Phi_2} = p_x - x$ does not vanish on $\\Gamma$, thus \n$\\Phi_{1,2}$ are second-class constraints, and no more constraint can be \ngenerated. To solve for $v_y$ one evaluates\n\\begin{equation}\n0 \\eqqcolon \\sbr{\\Phi_1, H^\\text{p}}_\\text{P} = p_x - x - 2v_y,\n\\end{equation}\nso that $v_y \\coloneqq \\rbr{p_x - x}/2$ solves the constraint.\n\nOne also has\n\\begin{equation}\nQ_{\\alpha\\beta} = \\sbr{\\Phi_\\alpha, \\Phi_\\beta}_\\text{P} =\n\\begin{pmatrix} 0 & +2 \\\\ -2 & 0 \\end{pmatrix},\\qquad\n\\rbr{Q^{-1}}_{\\alpha\\beta} =\n\\begin{pmatrix} 0 & -1/2 \\\\ +1/2 & 0 \\end{pmatrix},\n\\end{equation}\nso that the Dirac brackets are defined as\n\\begin{equation}\n\\sbr{f,g}_\\text{D} \\coloneqq \\sbr{f,g}_\\text{P} + \\frac{1}{2}\n\\rbr{\\sbr{f,p_y}_\\text{P}\\sbr{p_x+x-2y,g}_\\text{P}\n-\\sbr{f,p_x+x-2y}_\\text{P}\\sbr{p_y,g}_\\text{P}}.\n\\end{equation}\nThe fundamental ones different from Possion brackets are\n\\begin{equation}\n\\sbr{x,y}_\\text{D} = \\sbr{y,p_x}_\\text{D} = \\frac{1}{2},\\qquad\n\\sbr{y,p_y}_\\text{D} = 0.\n\\end{equation}\n\\textbf{Last one different from book?}\n\n\n\n\n\n\n\n\\subsubsection*{Example 2}\n\n\\begin{equation}\nL = \\frac{1}{2}\\dot{x}^2 + \\dot{x} y + \\frac{1}{2}\\rbr{x-y}^2\n\\end{equation}\n\nPrimary constraint\n\\begin{equation}\np_y = 0;\n\\end{equation}\nHamiltonian with primary constraint\n\\begin{equation}\nH^\\text{p} = \\frac{1}{2}p_x^2 - p_x y - \\frac{1}{2} x^2 + xy + v_y p_y.\n\\end{equation}\n\n\\subsection*{Example 3}\n\n\\begin{equation}\nL = \\frac{1}{2} \\rbr{\\dot{q}_2 - \\ee^{q_1}}^2 + \\frac{1}{2} \\rbr{\\dot{q}_3 - \nq_2}^2.\n\\end{equation}\n\n\n\n\\subsection{Parametrised systems}\n\n\\subsubsection*{Non-relativistic point particle}\n\n\\cite[sec.\\ 3.1.1]{Kiefer2012}\n\\begin{equation}\n\\sfun{S}{\\rfun{q}{t}} \\coloneqq \\int_{t_1}^{t_2}\\dd t\\,\\rfun{L}{q, \\frde{q}{t}}\n\\end{equation}\n\n\n\n\\subsubsection*{Relativistic charged point particle}\n\n\\cite[sec.\\ 16]{Landau1975},\n\\cite[sec.\\ 3.1.2]{Kiefer2012}\n\\begin{equation}\nS \\coloneqq \\int -m\\,\\dd s + e \\rfun{A_\\mu}{x} \\,\\dd x^\\mu \\eqqcolon \\int\\dd \n\\tau\\, L,\\\\\n\\label{eq:point-charged-action}\n\\end{equation}\nwhere the Lagrangian reads\n\\begin{equation}\nL = -m \\sqrt{-\\eta_{\\mu\\nu} \\dot{x}^\\mu \\dot{x}^\\nu } + q \\dot{x}^\\mu \n\\rfun{A_\\mu}{x}.\n\\end{equation}\n\n\\begin{equation}\nM_{\\mu\\nu} \\coloneqq \\frpa{^2 L^\\text{v}}{v^\\mu\\,\\partial v^\\nu} = \nm\\frac{-\\eta_{\\mu\\nu}\\eta_{\\alpha\\beta} + \\eta_{\\mu\\alpha}\\eta_{\\nu\\beta}}% \n{\\rbr{-\\eta_{\\rho\\sigma}v^\\rho v^\\sigma}^{3/2}} v^\\alpha v^\\beta,\n\\end{equation}\nwhich has one and only one eigenvector with null eigenvalue\n\\begin{equation}\nv^\\mu M_{\\mu\\nu} = 0.\n\\end{equation}\n\nMomenta\n\\begin{equation}\np_\\mu = \\frpa{L^\\text{v}}{v^\\mu} = \n\\frac{m\\eta_{\\mu\\nu}v^\\nu}{\\sqrt{-\\eta_{\\rho\\sigma}v^\\rho v^\\sigma}} + q A_\\mu.\n\\label{eq:point-charged-pvrel}\n\\end{equation}\nIf one chooses $v^0$ to be the primary inexpressible velocity, then eliminating\n$p_0$ in \\cref{eq:point-charged-pvrel} yields\n\\begin{equation}\nv^i = \\frac{\\xi \\eta^{ij} \\rbr{p_j - q A_j} v^0}{\\sqrt{m^2 + \\eta^{kl}\n\\rbr{p_k - q A_k}\\rbr{p_l - q A_l}}},\n\\label{eq:point-charged-pvrel0}\n\\end{equation}\nwhere $\\xi = \\sgn v^0$. In the following $\\xi = +1$ will be chosen.\n\nInserting \\cref{eq:point-charged-pvrel0} into the Hamiltonian with velocity\n\\begin{equation}\nH^\\text{v} = v^\\mu p_\\mu - L^\\text{v} = m\\sqrt{-\\eta_{\\mu\\nu}v^\\mu v^\\nu} + \nv^\\mu\\rbr{p_\\mu - q \\rfun{A_\\mu}{x}},\n\\end{equation}\none obtains the Hamiltonian with primary constraint\n\\begin{equation}\nH^\\text{p} = v^0 \\rbr{p_0 - q A_0 + \\sqrt{m^2 + \\eta^{kl}\n\\rbr{p_k - q A_k}\\rbr{p_l - q A_l}}},\n\\end{equation}\nwhere only a primary constraint survives, which is obviously a first-class \nconstraint\n\\begin{equation}\n\\phi^{(1,1)} = p_0 - q A_0 + \\sqrt{m^2 + \\eta^{kl}\n\\rbr{p_k - q A_k}\\rbr{p_l - q A_l}},\n\\end{equation}\nand the canonical Hamiltonian vanishes\n\\begin{equation}\nH^\\text{c} = 0.\n\\end{equation}\n\nTo compare, note in the non-covariant formalism (\\cite[sec.\\ 8]{Landau1975})\n\\begin{equation}\nS = \\int \\dd t\\,L,\\qquad L = -m\\sqrt{1-\\dot{\\vec{x}}^2} - q \\phi +\nq \\dot{\\vec{x}} \\cdot \\vec{A},\n\\end{equation}\nthe system is regular, and the canonical Hamiltonian reads\n\\begin{equation}\nH^\\text{c} = \\sqrt{m^2 + \\rbr{\\vec{p}-q\\vec{A}}^2} + q\\phi,\n\\end{equation}\nwhich corresponds to setting $\\phi^{(1,1)} = 0$, $p_0 \\to -H^\\text{c}$ \n($p_\\mu = \\rbr{-E, \\vec{p}}$), and noting $A_\\mu = \\rbr{-\\phi, \\vec{A}}$.\n\n\\subsubsection*{Relativistic point particle with einbein}\n\n\\cite[sec.\\ 2.1]{Blumenhagen2013}\n\\begin{equation}\nL \\coloneqq \\frac{1}{2} \\rbr{e^{-1}\\eta_{\\mu\\nu}\\dot{x}^\\mu \\dot{x}^\\nu - m^2 e}\n\\label{eq:point-aux-lagrangian}\n\\end{equation}\n\n\\begin{equation}\np_\\mu = \\frpa{L^\\text{v}}{v^\\mu} = e^{-1}\\eta_{\\mu\\nu}v^\\nu, \\qquad\np_e = 0.\n\\end{equation}\nChoosing $v^e$ to be the primary inexpressible velocity, one has\n\\begin{equation}\nv^\\mu = e\\eta^{\\mu\\nu}p_\\nu.\n\\end{equation}\n\nHamiltonian with velocity\n\\begin{equation}\nH^\\text{v} = v^\\mu p_\\mu + v^e p_e + \\frac{1}{2} \\rbr{-e^{-1} \\eta_{\\mu\\nu} \nv^\\mu v^\\nu + m^2 e};\n\\end{equation}\nHamiltonian with primary constraint\n\\begin{equation}\nH^\\text{p} = \\frac{e}{2} \\rbr{\\eta^{\\mu\\nu}p_\\mu p_\\nu + m^2} + v^e p_e;\n\\end{equation}\ncanonical Hamiltonian\n\\begin{equation}\nH^\\text{c} = \\frac{e}{2} \\rbr{\\eta^{\\mu\\nu}p_\\mu p_\\nu + m^2}.\n\\end{equation}\n\nThe only primary constraint\n\\begin{equation}\n\\Phi^{(1,)} = p_e;\n\\end{equation}\nits time evolution\n\\begin{align}\n\\sbr{\\Phi^{(1,)}, H^\\text{p}}_\\text{P} &=\n\\sbr{p_e, e}_\\text{P}\\frac{1}{2}\\rbr{\\eta^{\\mu\\nu}p_\\mu p_\\nu + m^2}\n\\nonumber \\\\\n&= -\\frac{1}{2}\\rbr{\\eta^{\\mu\\nu}p_\\mu p_\\nu + m^2}.\n\\end{align}\nChoose\n\\begin{equation}\n\\Phi^{(2,)} = \\eta^{\\mu\\nu}p_\\mu p_\\nu + m^2,\n\\end{equation}\nwhose Possion bracket with $H^\\text{p}$ vanishes; furthermore,\n\\begin{equation}\n\\sbr{\\Phi^{(1,)},\\Phi^{(2,)}}_\\text{P} \\equiv 0.\n\\end{equation}\nThus one ends up with two first-class constraints.\n\n\n\n\\subsubsection{Neutral scalar field}\n\\cite[sec.\\ 3.3]{Kiefer2012}\n\n\\subsection{Maxwell--Proca theory}\n\n\\begin{equation}\n\\Ld = -\\frac{1}{4} F_{\\mu\\nu} F^{\\mu\\nu} - \\frac{1}{2} m^2 A_\\mu A^\\mu\n+ A_\\mu J^\\mu,\n\\end{equation}\nwhere $m > 0$ corresponds to the Proca theory \\cite[sec.\\ 2.3]{Gitman1990}, and \n$m = 0$ the Maxwell theory \\cite[sec.\\ 3.3.3]{Rothe2010}, \\cite[sec.\\ \n2.4]{Gitman1990}.\n\nLagrangian density with velocity\n\\begin{equation}\n\\Ld^\\text{v} = \\frac{1}{2} \\rbr{V_i - \\partial_i A_0}^2 - \\frac{1}{4} F_{ij}^2 \n+ \\frac{m^2}{2} \\rbr{A_0^2 - A_i^2} + A_0 J^0 + A_i J^i;\n\\end{equation}\nmomenta density\n\\begin{equation}\nB^0 \\coloneqq \\frpa{\\Ld^\\text{v}}{V_0} = 0,\\qquad\nB^i \\coloneqq \\frpa{\\Ld^\\text{v}}{V_i} = V^i - \\partial^i A_0;\n\\end{equation}\nHamiltonians\n\\begin{align}\n\\mscrH^\\text{p} &= \\mscrH^\\text{c} + V_0 \\Phi_1,\\\\\n\\mscrH^\\text{c} &= \\frac{1}{2} \\rbr{B^i}^2 + B^i \\partial_i A_0 + \\frac{1}{4} \nF_{ij}^2 + \\frac{m^2}{2} \\rbr{-A_0^2 + A_i^2} - A_0 J^0 - A_i J^i,\\\\\n\\end{align}\nwhere\n\\begin{equation}\n\\Phi_1 = B^0\n\\end{equation}\nis the only primary constraint.\n\n\n\\begin{align}\n\\sbr{\\rfun{\\Phi_1}{\\vec{x}_1},\\rfun{\\mscrH^\\text{p}}{\\vec{x}_2}}_\\text{P} &=\n\\sbr{\\rbr{B^0}_1,\\rbr{B^i\\partial_i A_0-\\frac{m^2}{2}A_0^2-A_0 J^0}_2}_\\text{P}\n\\nonumber \\\\\n&= \\rbr{-B^i\\partial_i + m^2 A_0 - J_0}_2 \n\\rfun{\\delta}{\\vec{x}_1-\\vec{x}_2},\n\\end{align}\nwhere $J_0 = -J^0$. Integration with $\\dd^d x_2$ yields the secondary constraint\n\\begin{equation}\n\\sbr{\\Phi_1, H^\\text{p}}_\\text{P} = \\partial_i B^i + m^2 A_0 - J_0 \n\\eqqcolon \\Phi_2,\n\\end{equation}\nso that\n\\begin{equation}\n\\sbr{\\rfun{\\Phi_1}{\\vec{x}_1},\\rfun{\\Phi_2}{\\vec{x}_2}}_\\text{P} = \n-m^2\\rfun{\\delta}{\\vec{x}_1-\\vec{x}_2}.\n\\label{eq:Maxwell-Proca-Q}\n\\end{equation}\nOne may further compute\n\\begin{equation}\n\\sbr{\\rfun{\\Phi_2}{\\vec{x}_1}, \\rfun{\\mscrH^\\text{c}}{\\vec{x}_2}}_\\text{P} = \n\\sbr{\\rbr{\\partial_i B^i}_1,\n\\rbr{\\frac{1}{4} F_{jk}^2 + \\frac{m^2}{2} A_j^2 - A_j J^j}_2}_\\text{P},\n\\end{equation}\nin which\n\\begin{align}\n\\sbr{\\rbr{\\partial_i B^i}_1, \\rbr{\\frac{1}{4} F_{jk}^2}_2}_\\text{P} &=\n\\rbr{\\partial_j A_k - \\partial_k A_j}_2 \\rbr{\\partial_i}_1\n\\sbr{\\rbr{B^i}_1, \\rbr{\\partial^j A^k}_2}_\\text{P} \\nonumber \\\\\n&= -\\rbr{F^{ij} \\partial_j}_2 \\rbr{\\partial_i}_1\n\\rfun{\\delta}{\\vec{x}_1-\\vec{x}_2}.\n\\end{align}\nThe Poisson bracket can be evaluated to be\n\\begin{equation}\n\\sbr{\\rfun{\\Phi_2}{\\vec{x}_1}, \\rfun{\\mscrH^\\text{c}}{\\vec{x}_2}}_\\text{P} =\n-\\rbr{F^{ij} \\partial_j + m^2 A^i + J^i}_2 \\rbr{\\partial_i}_1 \n\\rfun{\\delta}{\\vec{x}_1-\\vec{x}_2}.\n\\end{equation}\nIntegration with $\\dd^3 x_2$ yields\n\\begin{equation}\n\\sbr{\\Phi_2, H^\\text{c}}_\\text{P} = -\\partial_i\\rbr{m^2 A^i + J^i}.\n\\end{equation}\n\nFor Proca theory $m > 0$ , then the algorithm terminates, and one obtains a \npure second-class system.\n\\begin{equation}\n\\mbfQ = \\begin{pmatrix}0 & -m^2 \\\\ +m^2 & 0\\end{pmatrix},\n\\qquad\n\\mbfQ^{-1} = \\begin{pmatrix}0 & +m^{-2} \\\\ -m^{-2} & 0\\end{pmatrix}.\n\\end{equation}\nDirac bracket\n\\begin{equation}\n\\begin{split}\n&\\phantom{}\n\\sbr{\\rfun{f}{\\vec{x}_1},\\rfun{g}{\\vec{x}_2}}_\\text{D} =\n\\sbr{\\rbr{f}_1, \\rbr{g}_2}_\\text{P} + \\int \\dd^d x_3 \\\\\n\\Bigl(&- \\sbr{\\rbr{f}_1, \\rbr{B^0}_3}_\\text{P}\n\\sbr{\\rbr{m^{-2}\\partial_i B^i + A_0}_3, \\rbr{g}_2}_\\text{P} \\\\\n&+ \\sbr{\\rbr{f}_1, \\rbr{m^{-2}\\partial_i B^i + A_0}_3}_\\text{P}\n\\sbr{\\rbr{B^0}_3, \\rbr{g}_2}_\\text{P} \\Bigr).\n\\end{split}\n\\end{equation}\nThe fundamental ones different from Poisson brackets are\n\\begin{equation}\n\\sbr{\\rfun{A_0}{\\vec{x}_1},\\rfun{A_i}{\\vec{x}_2}}_\\text{D} =\nm^{-2} \\rbr{\\partial_i}_1 \\rfun{\\delta}{\\vec{x}_1 - \\vec{x}_2},\\qquad\n\\sbr{\\rfun{A_0}{\\vec{x}_1},\\rfun{B^0}{\\vec{x}_2}}_\\text{D} = 0.\n\\end{equation}\n\nIntroducing the regularising coordinates\n\\begin{alignat}{3}\n\\alpha_i &= A_i + m^{-2}\\rbr{\\partial_i B^0 - J_i},&\\qquad \\beta^i &= B^i; \\\\\n\\alpha_0 &= A_0 + m^{-2}\\rbr{\\partial_i B^i - J_0},&\\qquad \\beta^0 &= B^0.\n\\end{alignat}\nNote that $J^i = J_i$. It is easy to show that\n\\begin{align}\n\\sbr{\\rfun{\\alpha_i}{\\vec{x}_1},\\rfun{\\beta^j}{\\vec{x}_2}}_\\text{D} &= \n\\delta^i_j\\rfun{\\delta}{\\vec{x}_1,\\vec{x}_2},\\\\\n\\sbr{\\rfun{\\alpha_i}{\\vec{x}_1},\\rfun{\\alpha_j}{\\vec{x}_2}}_\\text{D} &= 0 =\n\\sbr{\\rfun{\\beta^i}{\\vec{x}_1},\\rfun{\\beta^j}{\\vec{x}_2}}_\\text{D}.\n\\end{align}\nFurthermore, one has\n\\begin{equation}\n\\mscrH^\\text{p} = \\mscrH^\\text{phy}+\\mscrH^\\text{con}+\\mscrH^\\text{irr},\n\\end{equation}\nwhere\n\\begin{align}\n\\begin{split}\n\\mscrH^\\text{phy} &= \\frac{1}{2}\\rbr{\\beta^i}^2 + \\frac{m^2}{2}\\alpha_i^2 +\n\\frac{1}{4}\\rbr{\\partial_i \\alpha_j - \\partial_j \\alpha_i}^2 + \n\\frac{1}{2m^2}\\rbr{\\partial_i \\beta^i}^2 \\\\\n&\\quad +\\frac{1}{m^2} J^0 \\partial_i \\beta^i,\n\\end{split}\\\\\n\\mscrH^\\text{con} &= -\\frac{m^2}{2}\\alpha_0^2 - \\frac{1}{2m^2} \n\\rbr{\\partial_i \\beta^0}^2,\\\\\n\\begin{split}\n\\mscrH^\\text{irr} &= \\partial_i\\rbr{\\alpha_0\\beta^i - \\beta^0\\alpha_i + \n\\frac{1}{m^2}\\rbr{\\beta^0\\partial_i\\beta^0 - \n\\beta^i\\partial_j\\beta^j - J^0 \\beta^i}} \\\\\n&\\quad + \\frac{1}{2m^2}\\rbr{\\rbr{J^0}^2 - \\rbr{J^i}^2}.\n\\end{split}\n\\end{align}\nFurther more,\n\\begin{equation}\n\\Phi_1 = \\beta^0,\\qquad\\Phi_2 = m^2\\alpha_0 \\propto \\alpha_0.\n\\end{equation}\nThus the $\\rbr{\\alpha_i, \\beta^i}$ are regular pairs of canonical variables, \nwhereas $\\rbr{\\alpha_0, \\beta^0}$ are the singular variables as constraints. \nThe canonical dynamics of the physical $\\rbr{\\alpha_i, \\beta^i}$'s are \ndetermined by $\\mscrH^\\text{phy}$ as a regular system.\n\n\\textbf{Should one compute $\\mscrH^\\text{a}$ here?}\n\n\nFor Maxwell theory $m = 0$.\n\n\n\n\n\n\n\n\n\n%\\subsection{Dirac field}\n\n%\\subsection{Gauge theories}\n\n%\\subsubsection{Spinor electrodynamics}\n\n%\\subsubsection{Yang--Mills theory}\n\n%\\subsubsection{Yang--Mills--Higgs theory}\n\n\\subsection{String theories}\n\n\\subsubsection*{Nambu--Gotō action}\n\nGeneralising the kinetic part of \\eqref{eq:point-charged-action}, one has\n\\begin{equation}\nS_\\text{NG} \\coloneqq -T \\int_\\Sigma \\dd A\n\\eqqcolon -T \\int_\\Sigma\\dd^2\\sigma \\Ld,\n\\end{equation}\nwhere the Lagrangian density\n\\begin{equation}\n\\Ld = \\sqrt{-\\Gamma},\\quad\n\\Gamma \\coloneqq \\det \\Gamma_{\\alpha\\beta},\\quad\n\\Gamma_{\\alpha\\beta} \\coloneqq \\frpa{X^\\nu}{\\sigma^\\alpha} \n\\frpa{X_\\nu}{\\sigma^\\alpha}.\n\\end{equation}\n\n\nHistorically \\cite{Nambu1970,Goto1971}; Reference e.g.\\ \n\\cite{Blumenhagen2013}\n\\cite[sec.\\ 3.2]{Kiefer2012}\n\n\\subsubsection*{Polyakov action}\n\nGeneralising \\eqref{eq:point-aux-lagrangian}\n\\begin{equation}\n\\sfun{S_\\text{P}}{X^\\mu, h_{\\alpha\\beta}} = -\\frac{T}{2}\\int_\\Sigma \\Ld,\n\\end{equation}\nwhere\n\\begin{equation}\n\\Ld \\coloneqq \\sqrt{-h} h^{\\alpha\\beta}\\Gamma_{\\alpha\\beta}.\n\\end{equation}\n\n\n\nHistorically \\cite{Brink1976,Deser1976,Polyakov1981};\nReference\n\\cite[sec.\\ 3.2]{Kiefer2012}\n\n\n\n\n\n\n\n\\subsection{Gravitation theories}\n\n\\subsubsection*{Closed Friedmann universe}\nThis part adapts \\cite[sec.\\ 8.1.2]{Kiefer2012}.\n\nThe total action reads\n\\begin{equation}\nS \\coloneqq S_\\text{EG} + S_\\phi,\n\\end{equation}\nwhere $S_\\text{EG}$ follows \\eqref{eq:action-einstein-gravity}, and\n\\begin{equation}\nS_\\phi \\coloneqq \\int_\\mscrM\\dd^4 x\\, \\sqrt{-g}\\,\n\\rbr{-\\frac{1}{2} g^{\\mu\\nu} \\rbr{\\nabla_\\mu\\phi} \\rbr{\\nabla_\\nu\\phi}\n-m^2\\phi^2}.\n\\end{equation}\n\nAdapting\n\\begin{equation}\n\\dd s^2 = -\\rfun{N^2}{t}\\,\\dd t^2 + \\rfun{a^2}{t}\\,\\dd\\Omega_3^2,\n\\end{equation}\nwhere\n\\begin{equation}\n\\d\\Omega_3^2 = \\dd\\chi^2+\\sin^2\\chi\\,\\rbr{\\dd\\theta^2+\\sin^2\\theta\\,\\dd\\phi^2}.\n\\end{equation}\nOne has\n\\begin{equation}\n\\sqrt{-g} = N a^3 \\sin^2\\chi\\,\\sin\\theta,\\qquad\n\\sqrt{h} = a^3\\sin^2\\chi\\,\\sin\\theta;\n\\end{equation}\nwhereas\n\\begin{equation}\nR = \\frac{6}{N^2}\\rbr{-\\frac{\\dot{N}\\dot{a}}{Na} + \\frac{\\ddot{a}}{a} + \n\\rbr{\\frac{\\dot{a}}{a}}^2} + \\frac{6}{a^2},\\qquad\nK = \\frac{3\\dot{a}}{Na}.\n\\end{equation}\n\n\\begin{equation}\nS_\\text{EG} = \\frac{A_3}{16\\pp\\nG} \\rbr{\\int_{t_1}^{t_2} \\dd t\nNa^3\\rbr{R - 2\\Lambda} - \\sbr{\\frac{6\\dot{a}a^2}{N}}_{t_1}^{t_2}},\n\\end{equation}\nwhere\n\\begin{equation}\nA_3 = \\int \\sin^2\\chi\\,\\sin\\theta\\,\\dd\\chi\\,\\dd\\theta\\,\\dd\\phi = 2\\pp^2.\n\\end{equation}\nThe term proportional to $\\ddot{a}/a$ in the integrand can be integrated by\nparts\n\\begin{equation}\n\\int_{t_1}^{t_2} \\dd t\\,Na^3 \\frac{6}{N^2} \\frac{\\ddot{a}}{a}\n= 6\\rbr{\\sbr{\\frac{\\dot{a}a^2}{N}}_{t_1}^{t_2} - \\int_{t_1}^{t_2}\\dd t\n\\,\\dot{a}\\frde{}{t}\\frac{a^2}{N^2}},\n\\end{equation}\nin which the first term cancels the Gibbons--Hawking--York term. One has\n\\begin{equation}\nS_\\text{EG} = \\frac{3\\pp}{4\\nG}\\int_{t_1}^{t_2} \\dd t\\,\n\\rbr{-\\frac{a}{N}\\dot{a}^2 + N a - \\frac{\\Lambda}{3}N a^3}.\n\\end{equation}\n\nThe matter part of the action reads\n\\begin{equation}\nS_\\phi = \\pp^2 \\int_{t_1}^{t_2}\\dd t\\,\na^3 \\rbr{\\frac{1}{N}\\dot{\\phi}^2 - m^2N\\phi^2}.\n\\end{equation}\n\nLagrangian with velocity\n\\begin{equation}\nL^\\text{v} = \\frac{3\\pp}{4\\nG}\\rbr{-\\frac{a}{N} {v^a}^2 + Na - \n\\frac{\\Lambda}{3} Na^3} + \\pp^2 a^3 \\rbr{\\frac{1}{N}{v^\\phi}^2 - m^2 N \n\\phi^2}.\n\\end{equation}\nCanonical momenta\n\\begin{equation}\np_N \\coloneqq \\frpa{L^\\text{v}}{v^N} = 0,\\quad\np_a \\coloneqq \\frpa{L^\\text{v}}{v^a} = -\\frac{3\\pp}{2\\nG} \\frac{a}{N} v^a,\\quad\np_\\phi \\coloneqq \\frpa{L^\\text{v}}{v^\\phi} = 2\\pp^2 \\frac{a^3}{N} v^\\phi.\n\\end{equation}\nChoosing $v^N$ to be the primary inexpressible velocity, one obtains\n\\begin{align}\nH^\\text{p} &= -N H_\\perp + v^N \\Phi, \\\\\nH^\\text{c} &= -N H_\\perp,\n\\end{align}\nwhere\n\\begin{align}\nH_\\perp &\\coloneqq \\frac{\\nG}{3\\pp} \\frac{p_a^2}{a}  - \\frac{1}{4\\pp^2} \n\\frac{p_\\phi^2}{a^3}  - \\frac{3\\pp}{4\\nG}\\rbr{\\frac{\\Lambda}{3}a^2 - 1}a\n- \\pp^2 m^2 a^3 \\phi^2, \\\\\n\\Phi &= p_N\n\\end{align}\nare the \\emph{Hamiltonian constraint} and the primary constraint, respectively.\n\nEvaluating the time evolution of $\\Phi$ yields\n\\begin{equation}\n\\sbr{\\Phi,H^t}_\\text{P} = H_\\perp,\n\\end{equation}\nso that the Hamiltonian constraint is indeed a constraint. There is no further \nconstraint, and $\\sbr{\\Phi, H_\\perp}_\\text{P}$ vanishes identically. Therefore \nthere are two and only two first-class constraints.\n\n\n\n\n\n\\subsubsection{Einstein--Hilbert action}\n\n\\begin{equation}\nS_\\text{EG} = S_\\text{EH} + S_\\text{GHY},\n\\label{eq:action-einstein-gravity}\n\\end{equation}\n\\begin{equation}\nS_\\text{EH} = \\frac{1}{16\\pp\\nG}\\int_\\mscrM\\dd^4 x\\,\\sqrt{-g} \n\\rbr{R-2\\mitLambda},\n\\end{equation}\nand\n\\begin{equation}\nS_\\text{GHY} = -\\frac{1}{8\\pp\\nG}\\int_{\\partial\\mscrM}\\dd^3 x\\,\\sqrt{h} K,\n\\end{equation}\nwhich is named after \\cite{Gibbons1977,York1972} but actually already mentioned \nin \\cite{Einstein1916}. See \\cite{Dyer2009} for a brief review.\n\n\n\\printbibliography\n\n\\end{document}\n", "meta": {"hexsha": "5948464b9933deb8c5359c751887c87bc9989afe", "size": 22866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/canonical/canonical.tex", "max_stars_repo_name": "cmp0xff/singular-dynamics", "max_stars_repo_head_hexsha": "3eae6f0462c21894efa73ccdc4e1ecde80f5c623", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/canonical/canonical.tex", "max_issues_repo_name": "cmp0xff/singular-dynamics", "max_issues_repo_head_hexsha": "3eae6f0462c21894efa73ccdc4e1ecde80f5c623", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/canonical/canonical.tex", "max_forks_repo_name": "cmp0xff/singular-dynamics", "max_forks_repo_head_hexsha": "3eae6f0462c21894efa73ccdc4e1ecde80f5c623", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5808538163, "max_line_length": 80, "alphanum_fraction": 0.6493046445, "num_tokens": 10058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4331818707949549}}
{"text": "\\section{Trim Analysis}\nThis section details the computation of ``trim'' (steady flight) configurations, in which the vehicle acceleration components along body axes are zero and the rotor response is periodic and briefly describes the pseudo-code used to include the free-vortex wake during trim.\n\nThe ODEs of interest are strongly coupled to each other,  especially for the rotor dynamics. Explicit expressions for the accelerations (second time derivatives of displacements) as a function of forcing and velocities are lengthy and cumbersome to manipulate. One way to simplify the beam equations is to make small-angle assumptions and use an ordering scheme (Ref. \\cite{Datta}), which then restricts the validity of the analysis to small angles. Alternately, it is possible to use the original form of the governing ODEs \n\\begin{equation}\n\\label{eqn:allodes}\n\\vector{f}(\\dot{\\vector{y}}, \\textrm{ } \\vector{y},\\textrm{ } \\vector{u},\\textrm{ } t\\textrm{ } ) \\quad = \\quad \\overline{\\boldsymbol\\epsilon} \\quad = \\quad \\vector{0}\n\\end{equation}\nwith a \\emph{class} of techniques that, given an initial guess $\\vector{y}_0(t)$, obtain a solution $\\vector{y}(t)$ such that $e(\\overline{\\boldsymbol\\epsilon}) < \\delta$, where $e(\\overline{\\boldsymbol\\epsilon})$ is an error metric and $\\delta$ is a user-specified threshold that is used to terminate the solution process to required numerical precision. Thus, the task of simulating vehicle dynamics is simplified to that of programming the logic for computing \\emph{numerical} values of $\\overline{\\boldsymbol\\epsilon}$ for a given $\\vector{y}, \\dot{\\vector{y}}, \\vector{u}$ and leveraging open-source subprograms from NETLIB for obtaining trim solutions and simulating maneuvering flight (Ref. \\cite{CeliSoln}).\n\n\\subsection{\\textbf{Definition of Trim}}\nThe term ``trim'' is used to refer to a steady flight condition in which the translational and angular acceleration components along and about the body axes are zero. Therefore, trim includes steady level flight, steady climbing flight, steady level turns and steady climbing/descending turns of constant radii. The concept of rotorcraft trim evolved from the corresponding definition for fixed-wing platforms, and so it is useful to define aircraft trim first.\n\n\\subsubsection{Aircraft Trim}\nTrim for a fixed-wind aircraft is defined as a steady flight condition in which the control settings, orientations and velocity of the vehicle produce forces (inertial and aerodynamic) that exactly cancel out contibutions from gravity and buoyancy, thus allowing the aircraft to remain in its state of rest or uniform motion `` indefinitely \". The force distributions on a fixed-wing aircraft in trim are steady, hence the aerodynamic and inertial loads at any two instants in time will be near-identical. There may still be fluctuations in these loads at extremely high frequencies (determined by the RPMs of the various rotors inside the engine), but the amplitudes of these fluctuations are so small that their effect on aircraft trim is negligible.\\\\\nUnlike a fixed wing, the aerodynamic and inertial loads generated by each rotor blade are not steady. In forward flight, rotor blades experience time-varying dynamic pressures and operating angles of attack, and therefore undergoes unsteady motion in response to these time-varying force and moment distributions along the span. These unsteady motions result in time-varying inertial blade loads in addition to the fluctuating aerodynamic loads, hence the forces transmitted to the airframe are vibratory in nature. With these considerations, rotor trim can be defined. \n\n\\subsubsection{Rotor trim}\nWhen the controls for a rotor (collective and cyclic pitch inputs) are held constant, the rotor is said to be trimmed if the blade response is periodic, i.e. it has reached steady-state, and the forces and moments, when averaged over this period, do not change over successive cycles. Often, the time period is assumed to be that reqiured for one rotor revolution, due to the cyclic variation of the free-stream velocities as seen by the blade and the kinematics of the pitch control system.\n\n\\subsubsection{Rotorcraft Trim}\nJust as fixed-wing trim is not significantly affect by engine vibrations, it is assumed that, for the purposes of enforcing body force and moment equilibrium, rotorcraft trim is insensitive to the \\emph{oscillatory} forces and moments transmitted to the hub. Instead, the \\emph{time-averaged} forces and moments will be used to represent the contributions from rotor loads to Eqs. (\\ref{eqn:bodyF1}) - (\\ref{eqn:bodyM3}). This assumption is justified since the vibratory loads manifest at sufficiently large frequencies that the airframe response is negligible and the vehicle trim state is unaffected (Ref. \\cite{Kim}). When the blade motion is periodic \\emph{and} the time-averaged forces and moments generated by the rotor are sufficient for establishing vehicle force and moment equilibrium, the system is said to be in \\emph{coupled trim} or \\emph{propulsive trim}. \n \nThe most general case of trim considered is a steady coordinated helical climbing turn of constant radius (Ref. \\cite{CeliTurn}). This flight condition is defined by three parameters : the flight speed $V$, the flight path angle $\\gamma$ (positive for climb) and the turn rate $\\dot{\\psi}$ (positive for nose-right turns). Using this definition,\n\\begin{itemize}\n\\item Steady level turning flight is a special case in which $\\gamma$ = 0 (constant altitude)\n\\item Steady climbing flight is a special case in which $\\dot{\\psi}$ = 0\n\\item Steady level forward flight is a special case in which $\\gamma$ = 0 and $\\dot{\\psi}$ = 0 \n\\item Hover is a special case in which $\\gamma$ = 0, $V$ = 0 and $\\dot{\\psi}$ = 0\n\\end{itemize}\nMathematically, trim is enforced by imposing additional conditions on the govering ODE set Eq. (\\ref{eqn:allodes}). For the rotorcraft trim problem, the differential equations reduce to nonlinear algebraic equations that may be represented as \n\\begin{equation}\n\\label{eqn:allAE}\n\\vector{F}(\\vector{X}) \\quad = \\quad \\overline{\\boldsymbol\\epsilon}_\\textrm{trim} \\quad = \\quad \\vector{0}\n\\end{equation}\nThe problem of trim is then converted to solving a set of algebraic equations for the so-called \\emph{trim unknowns}. The trim unknowns include the rotor response, vehicle attitudes, rotor induced inflow ratios and the pilot controls. Solution of the trim equations is achieved by manipulation of the trim variables $\\vector{X}$ using a numerical solver (Ref. \\cite{HYBRD}) until an error metric e($\\rvert\\overline{\\boldsymbol\\epsilon}\\rvert_\\textrm{trim}$) falls below a user-specified threshold $\\delta_\\textrm{trim}$. To avoid formulating an over-determined or under-determined system of equations, the number of trim variables $\\vector{X}$ must be equal to the number of trim equations $\\vector{F}$. The trim equations and corresponding trim variables are given in the following section. The trim solver is called \\textbf{hybrd}, a NETLIB subroutine from the package \\textbf{MINPACK}. The wrappers used for various types of trim are\n\\begin{itemize}\n\\item \\textbf{AEResiduals} : simultaneous vehicle-rotor trim with harmonic balance\n\\item \\textbf{AEResFET} : vehicle trim with numerical FET\n\\item \\textbf{AEResRotorResponse} : obtain rotor response with fixed controls\n\\item \\textbf{AEResQddot} : obtain blade accelerations for fixed controls and response\n\\item \\textbf{AEResAirframe} : obtain airframe vibratory response \n\\end{itemize}\n\nThe programming logic for all these cases is common, i.e. the calculation of the ODE residuals is unchanged. It is only the manipulation of these residuals that is unique to each of these adapters that \\textbf{numerically convert the governing ODEs to algebraic (trim) equations}. \n\\subsection{\\textbf{Trim Equations and Trim Variables}}\n\\begin{itemize}\n\\item \\textbf{The components of time-averaged fuselage translational and rotational accelerations along and about the body axes must be zero}, as given in Eqs. (\\ref{eqn:bodyF1}) - (\\ref{eqn:bodyM3}). Using `` T '' to represent time period for one rotor revolution, the first six trim equations are\n\\begin{eqnarray}\n\\label{eqn:vehicleeqm1}\n\\int_0^{T} \\dot{u}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB1}} \\quad = \\quad 0 \\\\\n\\int_0^{T} \\dot{v}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB2}} \\quad = \\quad 0 \\\\\n\\int_0^{T} \\dot{w}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB3}} \\quad = \\quad 0 \\\\\n\\int_0^{T} \\dot{p}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB4}} \\quad = \\quad 0 \\\\\n\\int_0^{T} \\dot{q}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB5}} \\quad = \\quad 0 \\\\\n\\label{eqn:vehicleeqm2}\n\\int_0^{T} \\dot{r}_{_\\textrm{F }} dt \\quad = \\quad \\epsilon_{_\\textrm{RB6}} \\quad = \\quad 0 \n\\end{eqnarray}\nEquations (\\ref{eqn:vehicleeqm1}) - (\\ref{eqn:vehicleeqm2}) constitute the six trim conditions that enforce vehicle force and moment equilibrium under steady flight conditions. The corresponding trim variables are the pilot controls ($\\delta_0$, $\\delta_\\textrm{lat}$, $\\delta_\\textrm{lon}$, $\\delta_\\textrm{ped}$) and the fuselage pitch and roll attitudes ($\\phi_{_\\textrm{F}}$, $\\theta_{_\\textrm{F}}$). The last two trim variables are indirect controls, in the sense that they cannot be immediately adjusted by the pilot. Instead, the vehicle has to be \\emph{flown into} these orientations using the four direct controls that influence the lift distributions over the rotor disks. The trim equation residuals for the airframe are set in \\textbf{update\\_airframe\\_AEResiduals}.\n\n\\item \\textbf{The rotor must be trimmed}, i.e. the motions of all blades must be individually periodic. Since we assume that all blades are identical, it follows that \\textbf{all blades must exhibit identical motions} with phase offsets corresponding to their relative azimuthal spacing. Therefore, the problem of obtaining the motion of all blades of a particular rotor is simplified to that of obtaining the motion of a reference blade. Without loss of generality, the first blade is chosen to be the reference blade. \n\nA further assumption is made at this stage to simplify the analysis - that the resulting periodic blade motion is well-represented using a Fourier series in integer multiples of the rotor frequency $\\Omega$. This method is often called \\emph{harmonic balance}, and can capture the dominant blade motions (with regard to flight dynamics) using the first few harmonics. \\textbf{A Galerkin method with harmonic balance is used to obtain the time-resolution of the rotating blade modes}. The generalized coordinates of a blade at azimuth $\\psi$ can be approximated to\n\\begin{equation}\n\\label{eqn:qharm}\n\\grkvec{\\eta}_{j}(\\psi) \\quad \\approx \\quad \\grkvec{\\eta}_0 \\quad + \\quad \\sum_{k=1}^\\textrm{Nh} \\left(\\grkvec{\\eta}_\\textrm{kc} \\textrm{ } \\cos k\\psi \\quad + \\quad \\grkvec{\\eta}_\\textrm{ks} \\textrm{ } \\sin k\\psi \\right)\n\\end{equation}\n$\\grkvec{\\eta}_0$ represents the steady part of the generalized coordinates, and the amplitudes of the sine and cosine components for the \\mbox{`` $k^\\textrm{th}$ ''} harmonic are \\mbox{($\\grkvec{\\eta}_{kc}$ , $\\grkvec{\\eta}_{ks}$)}. \nThe N$_\\textrm{m}$(1+2 N$_\\textrm{h}$) Fourier coefficients are the trim variables that define the rotor blade motions with respect to the undeformed rotating preconed axes. These Fourier coefficients are used to compute the blade deflections which are substituted into the beam equations, to yield the mode-weighted ODE residuals \n\\begin{equation}\n\\overline{\\boldsymbol\\epsilon}_\\textrm{blade 1} \\quad = \\quad \\vector{f}_\\textrm{beam} (\\vector{y}_1, \\textrm{ }\\dot{\\vector{y}}_1, \\textrm{ } \\vector{u}, \\textrm{ }t) \n\\end{equation}\nHere, $\\vector{f}_\\textrm{beam}$ represents the ODEs governing rotating beam dynamics, i.e. the mode-weighted flap, lag and torsion equations. $\\vector{y}_1$ represents a subset of the state vector that contains the 12 rigid-body fuselage states and the generalized coordinates (together with their first time derivatives) for the reference blade. Since we are using Galerkin's method, the corresponding trim equations are obtained by weighting the beam equations with the azimuthal shape functions and integrating over one revolution. The algebraic equation residuals corresponding to the steady, cosine and sine components of blade motions are \n\\begin{align}\n\\grkvec{\\epsilon}_\\textrm{steady} \\quad = \\quad &\\int_{0}^T \\grkvec{\\epsilon}_\\textrm{blade 1} (t) \\qquad \\qquad \\quad \\textrm{ } dt\\\\\n\\grkvec{\\epsilon}_\\textrm{cos,k} \\quad = \\quad &\\int_{0}^T \\grkvec{\\epsilon}_\\textrm{blade 1} (t) \\quad \\cos k \\Omega t \\quad dt\\\\\n\\grkvec{\\epsilon}_\\textrm{sin,k} \\quad = \\quad &\\int_{0}^T \\grkvec{\\epsilon}_\\textrm{blade 1} (t) \\quad \\sin k \\Omega t \\quad dt\n\\end{align}\nThese residuals are computed in \\textbf{update\\_rotor\\_AEResiduals}. \n\\item \\textbf{The components of helicopter linear, angular velocities along fuselage body axes, and roll and pitch attitudes must be time-invariant} \\\\\nFor trimmed flight, the vehicle must move at constant speed V. The orientation of the free-stream velocity vector relative to the airframe can be described using the spherical angles $\\alpha_{_\\textrm{F}}$ and $\\beta_{_\\textrm{F}}$ as defined in Eq. (\\ref{eqn:fusab}). The translation velocity components along helicopter body axes are \n\\begin{equation}\n\\label{eqn:uvwf}\n\\left.\n\\begin{aligned}\nu_{_\\textrm{F}} \\quad = \\quad &\\textrm{V} \\textrm{ }\\cos \\alpha_{_\\textrm{F}} \\cos \\beta_{_\\textrm{F}} \\\\\nv_{_\\textrm{F}} \\quad = \\quad &\\textrm{V} \\textrm{ }\\sin \\beta_{_\\textrm{F}} \\\\\nw_{_\\textrm{F}} \\quad = \\quad &\\textrm{V} \\textrm{ }\\sin \\alpha_{_\\textrm{F}} \\cos \\beta_{_\\textrm{F}} \\qquad \\qquad\n\\end{aligned}\n\\right\\}\n\\end{equation}\nThe rigid-body trim variables are converted to states in \\textbf{interpret\\_trim\\_variables}, and the rotor trim variables are converted to states in \\textbf{interpret\\_rotor\\_trimvars}. \n\nThe helicopter yaw rate $\\dot{\\psi}_{_\\textrm{F}}$ must be constant and the Euler pitch and roll attitudes must be time-invariant. Applying these conditions to Eqs. (\\ref{eqn:pqrf}), the angular velocity components along body axes are obtained as  \n\\begin{equation}\n\\label{eqn:angturn}\n\\left.\n\\begin{aligned}\np_{_\\textrm{F}} \\quad = & -\\dot{\\psi}_{_\\textrm{F}} \\sin \\theta_{_\\textrm{F}} \\qquad \\\\\nq_{_\\textrm{F}} \\quad = &\\quad \\dot{\\psi}_{_\\textrm{F}} \\cos \\theta_{_\\textrm{F}} \\sin \\phi_{_\\textrm{F}} \\qquad  \\\\\nr_{_\\textrm{F}} \\quad = &\\quad \\dot{\\psi}_{_\\textrm{F}} \\cos \\theta_{_\\textrm{F}} \\cos \\phi_{_\\textrm{F}} \\quad \\qquad \\quad \n\\end{aligned}\n\\right\\}\n\\end{equation}\nAt low forward speeds, the reduced dynamic pressure on the vertical stabilizer renders it ineffective for producing anti-torque. Therefore, \\textbf{below a certain threshold airspeed, the helicopter is constrained to fly with zero sideslip angle}, i.e. \n\\[ \\beta_{_\\textrm{F}} \\quad = \\quad 0 \\]\n\\textbf{Above the threshold airspeed, all turns must be coordinated} to increase ride comfort and reduce the danger of entering a spin. Mathematically, turn coordination is enforced by setting the cumulative component of inertial and gravitational forces along the $\\ihat{j}_{_\\textrm{B}}$ direction to zero. Substituting Eqs. (\\ref{eqn:uvwf}) and Eqs. (\\ref{eqn:angturn}) in Eq. (\\ref{eqn:bodyF2}) yields the residual of the turn coordination equation as \n\\begin{equation}\n\\label{eqn:turncoord}\n\\epsilon_\\textrm{coord} \\quad = \\quad \\textrm{V} \\dot{\\psi}_{_\\textrm{F}} \\cos \\beta_{_\\textrm{F}} (\\cos \\alpha_{_\\textrm{F}} \\cos \\theta_{_\\textrm{F}} \\cos \\phi_{_\\textrm{F}} \\textrm{ }+\\textrm{ } \\sin \\theta_{_\\textrm{F}} \\sin \\alpha_{_\\textrm{F}}) - g \\sin \\phi_{_\\textrm{F}} \\cos \\theta_{_\\textrm{F}}\n\\end{equation}\nAnother kinematic relationship exists between the climb angle $\\gamma$, the Euler angles ($\\psi$, $\\theta$, $\\phi$)$_{_\\textrm{F}}$  and the wind angles ($\\alpha$, $\\beta$)$_{_\\textrm{F}}$. To determine this relationship, consider the velocity components of the helicopter along fuselage body axes, as given in Eqs. (\\ref{eqn:uvwf}). The velocity components along the earth-fixed axes can be obtained using the rotation matrix from body axes to gravity axes as \n\\begin{equation}\n\\begin{Bmatrix} \\dot{\\textrm{x}}_{_\\textrm{F}} \\\\\\dot{\\textrm{y}}_{_\\textrm{F}} \\\\ \\dot{\\textrm{z}}_{_\\textrm{F}} \\end{Bmatrix} \\quad = \\quad \\tee_{GB} \\begin{Bmatrix} u_{_\\textrm{F}} \\\\ v_{_\\textrm{F}} \\\\ w_{_\\textrm{F}} \\end{Bmatrix}\n\\end{equation}\nThe component along $\\ihat{k}_{_\\textrm{G}}$ is given by the third row of the right hand side. By definition, the same velocity component is equal to \n\\[ \\dot{\\textrm{z}}_{_\\textrm{F}} \\quad = \\quad -V \\sin \\gamma\\]\nThe negative sign accounts for the fact that $\\ihat{k}_{_\\textrm{G}}$ points downward and a positive $\\gamma$ indicates a steady increase in altitude. \\textbf{The equation of flight path} can be obtained by comparing the two expressions for $\\dot{\\textrm{z}}_{_\\textrm{F}}$ above, and dividing by the velocity magnitude V. The residual of this trim equation is \n\\begin{equation}\n\\label{eqn:fp}\n\\left.\n\\begin{aligned}\n\\epsilon_{_\\textrm{FP}} \\quad = \\quad & \\cos \\alpha_{_\\textrm{F}} \\cos \\beta_{_\\textrm{F}} \\sin \\theta_{_\\textrm{F}} \\quad - \\quad \\sin \\gamma_{_\\textrm{F}} \\\\\n- & \\cos \\theta_{_\\textrm{F}}(\\sin \\beta_{_\\textrm{F}} \\sin \\phi_{_\\textrm{F}} \\textrm{ + } \\sin \\alpha_{_\\textrm{F}} \\cos \\beta_{_\\textrm{F}} \\cos \\phi_{_\\textrm{F}}) \\qquad \\qquad\n\\end{aligned}\n\\right\\}\n\\end{equation}\nThe trim variables corresponding to the turn coordination and flight path equations are ($\\alpha_{_\\textrm{F}}$, $\\beta_{_\\textrm{F}}$). Perfect hover with identically zero forward speed is simulated by replacing the flight path equation with \n\\begin{equation*}\n\\epsilon_{_\\textrm{FP}} \\quad = \\quad \\alpha_{_\\textrm{F}} \\qquad \\qquad \\textbf{\\textrm{at hover}}\n\\end{equation*}\nThe kinematic consistency equations are computed in the routine \\textbf{FPTCRes}. \n\\item \\textbf{The inflow ratios are time-invariant} when averaged over one revolution of the main rotor. The corresponding trim equation residuals are  \n\\begin{align*}\n\\epsilon_{\\lambda_{TR}} \\quad = \\quad &\\int_0^T \\dot{\\lambda}_{_\\textrm{TR}} \\textrm{ }dt \\\\\n\\epsilon_{\\lambda_{0,MR}} \\quad = \\quad &\\int_0^T \\dot{\\lambda}_{0_\\textrm{MR}} \\textrm{ }dt \\\\\n\\epsilon_{\\lambda_{1c,MR}} \\quad = \\quad &\\int_0^T \\dot{\\lambda}_{\\textrm{1c}_\\textrm{MR}} \\textrm{ }dt \\\\\n\\epsilon_{\\lambda_{1s,MR}} \\quad = \\quad &\\int_0^T \\dot{\\lambda}_{\\textrm{1s}_\\textrm{MR}} \\textrm{ }dt \n\\end{align*}\n\\end{itemize}\nThe ODEs governing the inflow dynamics are converted to trim equations in the routine \\textbf{update\\_inflow\\_AEResiduals}.\n\\subsection{\\textbf{Free-Vortex Wake Model in Trim}}\nWhen the free wake model is used in trim, all the trim conditions given in the previous sections are enforced. The main rotor inflow equations are initially used to generate a starting guess for the trim controls, rotor response and fuselage orientations. Once trim is achieved with dynamic inflow, the main rotor inflow equations are removed from the trim equations and a `` loose-coupling '' procedure is used to periodically exchange information over one rotor revolution between the aerodynamics and rotor/flight dynamics. Reference \\cite{Alfred} provides details on the loose-coupling trim procedure, and a brief summary is given here for completeness.\n\n\\begin{enumerate}\n\\item With the trim controls, fuselage velocity and blade motions from the previous iteration, the free wake solution is marched forward in time until the L1 norm of the inflow over the rotor disk reduces below a threshold value $\\delta_\\textrm{inflow}$. This operation is performed by the routine \\textbf{converge\\_wake\\_inflow}.\n\\item The inflow distribution over the rotor disk is computed from the converged free wake geometry and frozen. This step is performed by the routine \\textbf{rindvt} (wake folder). \n\\item Using this \\textit{frozen} inflow distribution, the trim procedure is applied a solution for simultaneous vehicle equilibrium and rotor response periodicity. Once trim is achieved with the inflow distribution from step 2, the structural/flight dynamics are \\emph{frozen}. This procedure is performed by the routine \\textbf{AESolver}.\n\\item Steps 1-3 are repeatedly performed until the L1 norm of trim variables (excluding 2/rev and higher rotor harmonics) reduce below a threshold $\\delta_{_\\textrm{TV}}$. This operation is controlled by the routine \\textbf{iterative\\_trim}.\n\\end{enumerate}\n\n\\subsection{\\textbf{Galerkin vs. Rayleigh-Ritz, FET vs. Harmonic Balance}}\nThere are two key differences between \\textbf{UMARC} and \\textbf{HeliUM}. \n\\begin{itemize}\n\\item \\textbf{The first difference is the time resolution of the rotor modes}. While HeliUM uses harmonic balance to obtain simultaneous rotor-vehicle trim, \\textbf{UMARC} uses a Finite Element in Time method, using local polynomials to express the time-variation of blade motion. This choice of time shape function (trigonometric vs. Lagrangian interpolation polynomials) implies that blade inertial loads are computed differently in the two codes, and each method exhibits its own strengths and deficiencies. For example, Lagrangian time shape functions yield necessarily discontinuous accelerations across time nodes, while harmonic balance \\textit{forces} continuity in displacement, velocity and acceleration. The validity of harmonic balance comes into question when there is impulsive loading on the blade at moderate advance ratios due to dynamic stall or advancing blade compressibility.\n\\item \\textbf{The second key difference is the technique used to manipulate the rotor dynamics and recast the equations into a solvable form.} The choice of a semi-implicit (partially numerical) formulation of the beam equations in \\textbf{HeliUM} allows for using a state-space representation throughout the analysis, which eliminates duplication in programming. However, the dynamics are ``hidden'' in the numbers, which are generated only during run-time. For beginners, the subtleties in the trim process, i.e. a numerical reduction of the governing ODEs to algebraic equations is not immediately obvious. The biggest advantage of this approach is the sheer power and flexibility afforded to the developer in terms of adding features in a modular fashion. In \\textbf{UMARC}, the analytically derived rotating beam equations of motion are recast into a linearized form with select Taylor-series expansions about zero deflection. This formulation is easier to grasp, since terms like acceleration and Coriolis force appear explicitly in the equations of motion. This ``explicitness'' is numerically more efficient to implement, since it replaces sines and cosines with polynomial approximations. However, adding additional physical effects (e.g. time-varying RPM fluctuations, hub angular velocities/accelerations, free-stream flow velocity acceleration) requires re-derivation of parts of the analysis, and the lead time for expanding program capabilities is considerable. The art of cherry-picking cross-couplings in flap, lag and torsion based on an ordering scheme quickly balloons into an exercise in superhuman book-keeping, and is extremely error-prone. Further, programming these long expressions (the physical origins of which are lost in the reduction of sines and cosines to polynomials) does not leave a clean trail of code to follow. \n\\end{itemize}\n\nIn this section, I describe how to combine the best of both worlds - i.e. preserve the modularity of a state-space representation with large deflections, while simultaneously obtaining accurate inertial loads using Finite Element in Time, using a modification of the \\textbf{UMARC} trim process.\n\n\\subsection{\\textbf{Conventional trim process for rotors}}\n\\textbf{Disclaimer}: I have skipped the non-essential steps in an attempt to be concise. Wherever possible, higher spatial and time derivatives must be eliminated using integration by parts. Using a simple example of a rotor blade undergoing elastic flap deflections, the \\textbf{UMARC} rotor trim process is explained here. The rotor blade is modeled as a rotating Euler-Bernoulli beam, with its flap dynamics governed by the PDE\n\\begin{equation}\n\\left( EI w''\\right)'' \\spc + \\spc m\\ddot{w} \\spc - \\spc \\left(T w'\\right)' \\quad = \\quad f_z(w, \\dot{w}, \\theta_\\textrm{con}, t)\n\\end{equation} \nThe blade deflections are split into a space-dependent and time-dependent part, assuming separation of variables of the form \n\\begin{equation}\nw(x,t) \\quad = \\quad \\sum q_j(t) \\spc V_i(x)\n\\end{equation}\nThe aim of rotor trim is to find the rotor motions $w(x,t)$ such that the governing PDE is satisfied \\textit{not at every point on the beam}, but instead in an \\textit{approximate} sense (see Sections \\ref{sec:galerkin} and \\ref{sec:modes}). (While \\textbf{UMARC} uses a Rayleigh-Ritz forumation to obtain the blade governing equations, a Galerkin method yields identical results for the same trial functions) Thus, the aim is to satisfy the following \\textit{ODEs} \n\\begin{equation}\n\\int_0^L \\left[\\spc \\left( EI w''\\right)'' \\spc + \\spc m\\ddot{w} \\spc - \\spc \\left(T w'\\right)' \\spc \\right] \\phi_i(x) dx \\quad = \\quad \\int_0^L f_z \\spc \\phi_i(x) dx \n\\end{equation}\nThere are as many ODEs as there are weighting functions $\\phi_i$. The right hand side of the \\textit{weak} formulation is the external loading (aerodynamics). Since the aerodynamic loads depend on blade motion velocities, there are ``hidden'' dependencies of $f_z$ on $w, \\dot{w}$ and $\\ddot{w}$. To solve for $w$ ``analytically'', these dependencies are ``exposed'' using analytical Taylor-series expansions for $f_z$ as \n\\begin{equation}\nf_z \\quad = \\quad f_0 \\spc + \\spc + \\frac{df}{dw} (w - w_0) \\spc + \\spc \\frac{df}{d\\dot{w}} (\\dot{w} - \\dot{w}_0) \\spc + \\spc \\cdots\n\\end{equation}\nApplying separation of variables, the weak formulation can be written as a spring-mass-damper type second-order ODE, given by \n\\begin{equation}\n\\vector{M} \\ddot{\\vector{q}} \\spc + \\spc \\vector{C} \\dot{\\vector{q}} \\spc + \\spc \\vector{K} \\vector{q} \\quad = \\quad \\vector{F}_0(t) \\spc + \\spc \\vector{F}_\\textrm{non-lin}(t)\n\\end{equation}\nThe terms \\textbf{F}$_0(t)$ is dependent only on control inputs, and \\textbf{F}$_\\textrm{non-lin}(t)$ contains the ``higher-order terms'' resulting from the Taylor-series expansion. The mass and stiffness matrices depend only on blade properties, and can be used to perform modal reduction (Section \\ref{sec:modes}) to yield the modal equations\n\\begin{equation}\n\\left[\\overline{\\vector{M}}\\right] \\ddot{\\grkvec\\eta} \\spc + \\spc \\left[\\overline{\\vector{C}}\\right] \\dot{\\grkvec\\eta} \\spc + \\spc \\left[\\overline{\\vector{K}}\\right] \\grkvec\\eta \\quad = \\quad \\overline{\\vector{F}}(t)\n\\end{equation}\nHere, $\\left[\\overline{\\spc}\\right]$ represents a modal matrix, obtained from the \\textit{nodal} matrices using the transformation\n\\begin{equation}\n\\left[\\vector{modal}\\right] \\quad = \\quad \\vector{V}^\\textrm{T} \\spc \\left[\\vector{nodal}\\right] \\spc \\vector{V}\n\\end{equation}\nHere, $\\vector{V}$ represents a matrix of eigenvectors.\n\nUsing these finite numbers of ODEs, an approximate solution is applied again to obtain the time resolution of the rotor modes $\\grkvec\\eta$. Instead of solving the modal equations for \\textit{each} point in time, the time history of rotor modes over one revolution (in rotor trim) is expanded as a linear combination of trial functions as \n\\begin{equation}\n\\grkvec\\eta(t) \\quad = \\quad \\sum H_j(t) \\grkvec\\xi_j\n\\end{equation}\nThe approximate solution is obtained by satisfying the following condition\n\\begin{equation}\n\\left[ \\int_0^T \\vector{H}^\\textrm{T} \\left( \\left[\\overline{\\vector{M}}\\right] \\ddot{\\vector{H}} \\spc + \\spc \\left[\\overline{\\vector{C}}\\right] \\dot{\\vector{H}} \\spc + \\spc \\left[\\overline{\\vector{K}}\\right] \\vector{H} \\right) \\spc dt \\right] \\grkvec\\xi \\quad = \\quad \\int_0^T \\vector{H}^\\textrm{T} \\spc \\overline{\\vector{F}} \\spc dt\n\\end{equation}\nThe coefficient matrix on the left hand side that multiplies $\\grkvec\\xi$ is evaluated numerically from the modal mass, damping and stiffness matrices, since the non-linearities are packaged into locally-linearized additions to the left hand side. The right hand side is also evaluated numerically from the control inputs and rotor operating condition, and a system of linear equations is solved to obtain the time shape function coefficients of the rotor modes. Since the blade accelerations are discontinuous when using finite elements in time with Lagrangian or Hermitian shape functions, they are instead obtained by inverting the modal equations, i.e.\n\\begin{equation}\n\\ddot{\\grkvec\\eta} \\quad = \\quad \\left[\\overline{\\vector{M}}\\right]^{-1} \\left( \\spc \\overline{\\vector{F}}(t) \\spc - \\spc \\left[\\overline{\\vector{C}}\\right] \\dot{\\grkvec\\eta} \\spc - \\spc \\left[\\overline{\\vector{K}}\\right] \\grkvec\\eta \\spc \\right)\n\\end{equation}\nTo recap,\n\\begin{itemize} \n\\item Linearization of aerodynamic, structural and inertial loads, combined with the small-angles assumption provides analytical expressions that can be manipulated to obtain the rotor response.\n\\item Replacing trigonometric expressions with polynomials increases computational efficiency, while preserving more than 95\\% accuracy.\n\\item \\textbf{An ordering scheme is required to deal with lengthy analytical expressions, and the formulation must be re-derived for different materials (e.g. composites)}\n\\item In \\textbf{UMARC}, the processes of vehicle trim and rotor trim are isolated from each other. Using the blade mode shapes and the coefficients of the individual time shape functions $\\grkvec\\eta$, the airloads and inertial loads can be computed for a given set of controls. These controls are iteratively adjusted starting from an initial guess using a Jacobian trim process. \\textbf{Thus, the rotor trim process is hand-crafted using explicit analytical expressions, but the vehicle trim process is handled numerically.}\n\\end{itemize}\n\n\\subsection{\\textbf{Numerical FET}}\nThe basic idea is to apply \\textbf{UMARC}'s \\textit{vehicle trim} numerical approach to also obtain the rotor motions using the following steps\n\\begin{itemize}\n\\item Assume that $w(x,t) \\quad = \\quad \\sum \\sum \\xi_{ij} \\spc V_i(x) \\spc H_j(t)$ is available as an initial guess (instead of a quantity that needs to be ``solved for''). $V_i(x)$ is the spatial trial function, $H_j(t)$ is the temporal trial function and $\\xi_{ij}$  is the time shape function coefficient of a rotor blade mode. \n\\item For a given set of $V_i(x)$, $H_j(t)$, find $\\xi_{ij}$ such that the following set of \\textit{approximate} equations are satisfied\n\\begin{equation}\n\\int_0^T H_j(t) \\int_0^L \\left(\\textrm{LHS} - \\textrm{RHS}\\right) V_i(x) \\spc dx \\spc dt \\quad = \\quad  \\epsilon_{ij} \\quad = \\quad 0\n\\end{equation}\n\\item Starting from an initial guess, iteratively adjust $\\xi_{ij}$ to minimize $|\\epsilon_{ij}|$, $i = 1, 2, \\cdots N_m, \\quad j = 1, 2, \\cdots N_t$. The advantage of this approach is that the deflections are ``known'' at every time instant and point on the beam, and the need for small-angle approximations or analytical expressions are eliminated entirely. The present beam model is therefore spatially ``exact''.\n\\item By replacing the time shape functions $H_j(t)$ with trigonometric functions, we also preserve the ability to switch to harmonic balance without changing the trim structure.\n\\item The calculation of inertial loads and vehicle trim process uses the same framework, and the numerical routines need not be duplicated. \n\\item The rotor dynamics are, in effect, invisible to the trim solver. This modularity allows for adding additional complexity to the simulation (e.g. axial degrees of freedom, trailing-edge flaps or multiple rotors) without having to modify the rest of the code.\n\\end{itemize}\n\n\\subsubsection{Accelerated FET using Harmonic Balance}\nThe main disadvantage of FET is that the rotor and vehicle trim processes must be decoupled due to the discontinuities in the second time derivatives of the time shape functions. Obtaining the vehicle trim Jacobian is the most computationally expensive step in the trim process, since each set of trial controls require a trimmed rotor to obtain accurate hub loads. The key idea, therefore, is to speed up the computation of this Jacobian so that faster solutions may be obtained with FET. \nBy contrast, harmonic balance enforces continuity in accelerations, which allows for simultaneous vehicle and rotor trim at the cost of ignoring step changes in aerodynamic forcing (e.g. advancing blade shocks and retreating blade stall). This capability allows us to write the trim equations for the coupled rotor-body system as \n\\begin{equation}\n\\begin{Bmatrix} \\grkvec\\epsilon_\\textrm{NR} \\\\ \\grkvec\\epsilon_\\textrm{R} \\end{Bmatrix} \\quad = \\quad \\begin{Bmatrix} \\vector{f}_\\textrm{NR} (\\vector{x}_\\textrm{NR}, \\spc \\vector{x}_\\textrm{R}) \\\\ \\vector{f}_\\textrm{R} (\\vector{x}_\\textrm{NR}, \\spc \\vector{x}_\\textrm{R}) \\end{Bmatrix}\n\\end{equation}\n$\\grkvec\\epsilon$ represents the residuals of the trim equations, $\\vector{x}$ denotes the trim variables and the subscripts denote non-rotating (NR) and rotating (R) components, i.e. everything but the rotor motions, and the rotor motions. Using finite-differences, the Jacobian matrix \\textbf{J} may be partitioned as\n\\begin{equation}\n\\begin{Bmatrix} \\grkvec\\epsilon_\\textrm{NR} \\\\ \\grkvec\\epsilon_\\textrm{R} \\end{Bmatrix} \\quad = \\quad \\begin{bmatrix} \\vector{J}_{11} & \\vector{J}_{12} \\\\ \\vector{J}_{21} & \\vector{J}_{22} \\end{bmatrix} \\spc \\begin{Bmatrix} \\Delta \\vector{x}_\\textrm{NR} \\\\ \\Delta \\vector{x}_\\textrm{R}  \\end{Bmatrix}\n\\end{equation}\nThe linearized rotor trim equations may be written as\n\\begin{equation}\n\\grkvec\\epsilon_\\textrm{R} \\quad = \\quad \\textbf{J}_{21} \\spc \\Delta \\textbf{x}_\\textrm{NR} \\spc + \\spc \\textbf{J}_{22} \\spc \\Delta \\textbf{x}_\\textrm{R}\n\\end{equation}\nThe linearized vehicle trim equations may be written as\n\\begin{equation}\n\\grkvec\\epsilon_\\textrm{NR} \\quad = \\quad \\textbf{J}_{11} \\spc \\Delta \\textbf{x}_\\textrm{NR} \\spc + \\spc \\textbf{J}_{12} \\spc \\Delta \\textbf{x}_\\textrm{R}\n\\end{equation}\nFor harmonic balance, the entire Jacobian \\textbf{J} is used for simultaneous rotor-vehicle trim. For FET, we require a \\textit{reduced} Jacobian that represents the sensitivity of integrated vehicle loads to changes in vehicle trim variables, \\textit{with a trimmed rotor}. Expanding on the operative word,\n\\[ \\textrm{\\textbf{For a trimmed rotor}} \\qquad \\grkvec\\epsilon_\\textrm{R} \\quad = \\quad \\vector{0} \\]\nThus,\n\\[ \\textbf{J}_{21} \\spc \\Delta \\textbf{x}_\\textrm{NR} \\spc + \\spc \\textbf{J}_{22} \\spc \\Delta \\textbf{x}_\\textrm{R} \\quad = \\quad \\vector{0} \\]\nThe rotor trim variables may be obtained in terms of the vehicle trim variables as \n\\[ \\Delta\\textbf{x}_\\textrm{R} \\quad = \\quad -\\textbf{J}_{22}^{-1} \\spc \\textbf{J}_{21} \\spc \\Delta\\textbf{x}_\\textrm{NR} \\]\nSubstituting this expression in the linearized vehicle trim equations to yield\n\\begin{align*}\n\\grkvec\\epsilon_\\textrm{NR} \\quad = \\quad &\\textbf{J}_{11} \\spc \\Delta \\textbf{x}_\\textrm{NR} \\spc - \\spc \\textbf{J}_{12} \\spc \\textbf{J}_{22}^{-1} \\spc \\textbf{J}_{21} \\spc \\Delta\\textbf{x}_\\textrm{R} \\\\\n\\spc = \\quad & \\left(\\spc \\textbf{J}_{11} \\spc - \\spc \\textbf{J}_{12} \\spc \\textbf{J}_{22}^{-1} \\spc \\textbf{J}_{21} \\spc \\right) \\spc \\Delta \\textbf{x}_\\textrm{R}\n\\end{align*}\nAn inspection of the above expression reveals that the FET trim Jacobian is \n\\begin{equation}\n\\textbf{J}_\\textrm{FET} \\quad = \\quad \\textbf{J}_{11} \\spc - \\spc \\textbf{J}_{12} \\spc \\textbf{J}_{22}^{-1} \\spc \\textbf{J}_{21}\n\\end{equation}\nPartitions of the trim Jacobians from Harmonic Balance can be manipulated and reduced for use with FET, therefore bypassing the most time-consuming part of the computations. This manner of reduction of a sensitivity matrix is similar to the procedure used to obtain a stability derivative model of a helicopter. \n", "meta": {"hexsha": "dd66b05eede328a3c8cbb1344fceb14c22c3b721", "size": 35941, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Autodoc/theory_prog_manual/Trim.tex", "max_stars_repo_name": "ananthsridharan/vtol_sizing", "max_stars_repo_head_hexsha": "3f754e1bd3cebdb5b5c68c8a2d84c47be1df2f02", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-03-24T10:20:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-22T18:49:25.000Z", "max_issues_repo_path": "Autodoc/theory_prog_manual/Trim.tex", "max_issues_repo_name": "ananthsridharan/vtol_sizing", "max_issues_repo_head_hexsha": "3f754e1bd3cebdb5b5c68c8a2d84c47be1df2f02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-12-08T10:26:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-04T18:19:59.000Z", "max_forks_repo_path": "Autodoc/theory_prog_manual/Trim.tex", "max_forks_repo_name": "ananthsridharan/vtol_sizing", "max_forks_repo_head_hexsha": "3f754e1bd3cebdb5b5c68c8a2d84c47be1df2f02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2018-11-27T21:21:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-20T15:44:18.000Z", "avg_line_length": 138.2346153846, "max_line_length": 1849, "alphanum_fraction": 0.761525834, "num_tokens": 10043, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.43318187079495485}}
{"text": "\\section{Feynman Diagramm}\n\nHaving introduced Gell-Mann and Low theorem, the only left is how to calculate the expectation values of time-ordered operators in Eq \\ref{greenexp}.\nIn this section, we will show how to use a diagrammatic approach to calculate them with the help of Wicki's theorem.\n\nHowever, since we have mentioned that all perturbation theory gives the same result, one way wonder why do we need such a strange approach?\nThen answer is the algebraic way to calculate perturbation terms is so complicated that it is difficult to understand what does it represent for.\nIn contrast, Feynman diagrams give a simple visualization of what would otherwise be an arcane and abstract formula.\nAs David Kaiser writes, \"since the middle of the 20th century, theoretical physicists have increasingly turned to this tool to help them undertake critical calculations\", and so \"Feynman diagrams have revolutionized nearly every aspect of theoretical physics\". \\cite{kaiser}\n\nBefore introducing Wick's theorem, let's first have an observation of the expression we want to calculate:\n\\begin{equation}\n\t\\langle\\Phi_{0}|\n\t\\hat{\\mathcal{T}} \\left[ c_u^{\\dagger} c_v^{\\dagger} \\ldots c_i c_j \\ldots \\right]\n\t| \\Phi_{0}\\rangle\n\\end{equation}\n\nSince creation operator add an electron while annihilation operator remove an electron, they must be paired somehow to get a nonzero final result.\nMathematically, we give the definition of physical and unphysical operators:\n\nSince creation and annihilation operators will give the following effects on Hartree-Fock state:\n\\begin{equation} \\label{cceffect}\n\t\\begin{aligned}\n\t\tc_{p}^{\\dagger} | \\Phi_{0} \\rangle=\\left\\{\\begin{array}{ll}{ | \\Phi_{p}^{N+1} \\rangle} & {\\text { for } n_{p}=0} \\\\ {0} & {\\text { for } n_{p}=1}\\end{array}\\right.\n\t\t\\\\\n\t\tc_{p} | \\Phi_{0} \\rangle=\\left\\{\\begin{array}{ll}{ | \\Phi_{p}^{N-1} \\rangle} & {\\text { for } n_{p}=1} \\\\ {0} & {\\text { for } n_{p}=0}\\end{array}\\right.\n\t\\end{aligned}\n\\end{equation}\nAn operator is referred to as physical if the outcome is an $N\\pm 1$ state (first and third case in \\ref{cceffect}) and unphysical if the outcome is 0 (second and fourth case in \\ref{cceffect}).\n\nThen we define the normal-ordered product, which puts all physical operators to the left of unphysical operators:\n\\begin{equation}\n\t\\hat{\\mathcal{N}}\\left[O_{i} O_{j} O_{k} \\ldots\\right] \\equiv(-1)^{P^{\\prime}} O_{P^{\\prime}(i)} O_{P^{\\prime}(j)} \\ldots\n\\end{equation}\n\nThe so-called \"pairing\" process is formally defined as contraction:\n\\begin{equation}\n\t\\wick{\n\t\t\\c1 O_{r} \\c1 O_{s} \\equiv \\hat{\\mathcal{T}}\\left[O_{r} O_{s}\\right]-\\hat{\\mathcal{N}}\\left[O_{r} O_{s}\\right]\n\t}\n\\end{equation}\n\nWick's theorem \\cite{wickproof} establishes a reformulation of a general time-ordered product\nof fermion operators in terms of normal-ordered products and contractions. It may be stated as follows:\n\nA $\\hat{\\mathcal{T}}$ product of m fermion operators can be transformed into a sum of $\\hat{\\mathcal{T}}$ products with all possible contractions of $k = 0, 1, \\dots, [m/2]$ operator pairs:\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\hat{\\boldsymbol{T}}\\left[O_{i} O_{j} O_{k} O_{l} \\ldots O_{r} O_{s} O_{t}\\right]&=\n\t\t\\hat{\\mathcal{N}}\\left[O_{i} O_{j} O_{k} O_{l} \\ldots O_{r} O_{s} O_{t}\\right]\n\t\t\\\\\n\t\t&+\\hat{\\mathcal{N}}\\left[\\wick{\\c1 O_{i} \\c1 O_{j} O_{k} \\ldots}\\right] +\\hat{\\mathcal{N}}\\left[\\wick{\\c1 O_{i} O_{j} \\c1 O_{k} \\ldots}\\right]+\\ldots\n\t\t\\\\\n\t\t&+\\hat{\\mathcal{N}}\\left[\\wick{\\c1 O_{i} \\c1 O_{j} \\c1 O_{k} \\c1 O_{l} \\ldots}\\right]+\\ldots\n\t\t\\\\\n\t\t&+\\hat{\\mathcal{N}}\\left[\\wick{\\c3 O_{i} \\c2 O_{j} \\c1 O_{k} \\ldots \\c1 O_{r} \\c2 O_{s} \\c3 O_{t}}\\right] \\ldots\n\t\\end{aligned}\n\\end{equation}\n\nAccording to the property of the $\\hat{\\mathcal{N}}$ products, only the fully contracted terms contribute to the expectation value:\n\\begin{equation}\n\t\\langle\\Phi_{0}|\n\t\\hat{\\mathcal{T}}\\left[O_{i} O_{j} O_{k} O_{l} \\ldots O_{r} O_{s} O_{t}\\right]\n\t| \\Phi_{0}\\rangle\n\t=\\hat{\\mathcal{N}}\\left[\\wick{\\c3 O_{i} \\c2 O_{j} \\c1 O_{k} \\ldots \\c1  O_{r} \\c2 O_{s} \\c3 O_{t}}\\right]+\\ldots\n\\end{equation}\n\nWith Wick's theorem, we can finally calculate Green functions by series.\nThe perturbed Hamiltonian is:\n\\begin{equation}\n\t\\hat{H}_{I}(t)=\\sum w_{r s} c_{r}^{\\dagger}(t) c_{s}(t)+\\frac{1}{2} \\sum V_{u v r s} c_{u}^{\\dagger}(t) c_{v}^{\\dagger}(t) c_{s}(t) c_{r}(t)\n\\end{equation}\n\nFirst Order:\n\\begin{equation}\n\t\\begin{aligned}\n\t\t&i \\tilde{G}_{p q}^{(1)}\\left(t, t^{\\prime}\\right)=\n\t\t(-i) \\frac{1}{2} \\sum_{r, s} w_{r s} \n\t\t\\int_{-\\infty}^{\\infty} \\mathrm{d} t_{1} e^{-\\epsilon|t_{1}|}\n\t\t\\langle\\Phi_{0}|\n\t\t\\hat{\\mathcal{T}}\\left[\n\t\t\tc_{r}^{\\dagger}\\left(t_{1}\\right) \n\t\t\tc_{s}\\left(t_{1}\\right) \n\t\t\tc_{p}(t)\n\t\t\tc_{q}^{\\dagger}\\left(t^{\\prime}\\right)\n\t\t\t\\right]\n\t\t| \\Phi_{0}\\rangle\n\t\\\\\n\t\t&+(-i) \\frac{1}{2} \\sum_{u, v, r, s} V_{u v r s} \n\t\t\\int_{-\\infty}^{\\infty} \\mathrm{d} t_{1} e^{-\\epsilon|t_{1}|}\n\t\t\\langle\\Phi_{0}|\n\t\t\\hat{\\mathcal{T}}\\left[\n\t\t\tc_{u}^{\\dagger}\\left(t_{1}\\right) \n\t\t\tc_{v}^{\\dagger}\\left(t_{1}\\right)\n\t\t\tc_{s}\\left(t_{1}\\right) \n\t\t\tc_{r}\\left(t_{1}\\right)\n\t\t\tc_{p}(t)\n\t\t\tc_{q}^{\\dagger}\\left(t^{\\prime}\\right)\n\t\t\\right]\n\t\t| \\Phi_{0}\\rangle\n\t\\end{aligned}\n\\end{equation}\n\nThen we calculate the time-ordered products:\n\\begin{equation}\n\t\\begin{aligned}\n\t\t&w_{rs}\n\t\t\\langle\\Phi_{0}|\n\t\t\\hat{\\mathcal{T}}\\left[\n\t\t\tc_{r}^{\\dagger}\\left(t_{1}\\right) \n\t\t\tc_{s}\\left(t_{1}\\right) \n\t\t\tc_{p}(t)\n\t\t\tc_{q}^{\\dagger}\\left(t^{\\prime}\\right)\n\t\t\t\\right]\n\t\t| \\Phi_{0}\\rangle\n\t\t\\\\\n\t\t=&w_{rs} (G^0_{pr}(t,t_1) G^0_{sq}(t_1,t^{\\prime}) - G^0_{rs}(t_1,t_1) G^0_{pq}(t,t^{\\prime}))\n\t\t\\\\\n\t\t=&w_{pq} G^0_p(t,t_1) G^0_q(t_1,t^{\\prime}) - w_{rr} G^0_r(t_1,t_1) \\delta_{pq} G^0_{p}(t,t^{\\prime})\n\t\t\\\\\n\t\t=&A+B\n\t\\end{aligned}\n\\end{equation}\nwhere $G^0_{pq}(t,t^{\\prime}) = \\delta_{pq} G^0_{p}(t,t^{\\prime})$ is used in the last step\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t&V_{uvrs}\n\t\t\\langle\\Phi_{0}|\n\t\t\\hat{\\mathcal{T}}\\left[\n\t\t\tc_{u}^{\\dagger}\\left(t_{1}\\right) \n\t\t\tc_{v}^{\\dagger}\\left(t_{1}\\right)\n\t\t\tc_{s}\\left(t_{1}\\right) \n\t\t\tc_{r}\\left(t_{1}\\right)\n\t\t\tc_{p}(t)\n\t\t\tc_{q}^{\\dagger}\\left(t^{\\prime}\\right)\n\t\t\\right]\n\t\t| \\Phi_{0}\\rangle\n\t\t\\\\\n\t\t=& -V_{pr[qr]} G^0_{p}(t,t_1) G^0_{r}(t_1,t_1) G^0_{q}(t_1,t^{\\prime})\n\t\t- V_{rs[rs]} G^0_r(t_1,t_1) G^0_s(t_1,t_1) \\delta_{pq} G^0_p(t,t^{\\prime})\n\t\t\\\\\n\t\t=&C+D\n\t\\end{aligned}\n\\end{equation}\n\nThe idea of feynman diagram is to assign each expression (A, B, C, D) here to a diagram.\nThe rule is to assign each time (including $t$, $t^{\\prime}$ and time appearing as integration variable) a vertex, to assign each free Green function a line or curve which connects the two vertices corresponding to the time variables of the Green function itself.\nThe starting time of the Green function in interest is always on the bottom while in end time is always on the top.\n\nIn expression A, free Green function first propagate from time $t$ to $t_1$, and then from $t_1$ to $t^{\\prime}$, which corresponds to a connected line as is shown in Diagram A.\nIn expression B, one free Green function propagates from $t$ to $t^{\\prime}$, which corresponds to a line, while the other propagates from $t_1$ to itself, which corresponds to a loop (a curve ends at the starting vertex).\nThe case C and D are also similar, except that $t_1$ has four indexes, which means it should be connected to four lines or curves.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\begin{subfigure}{0.2\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[height=3cm]{figures/diagramA.png}\n\t\t\\caption{Diagram A}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.2\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[height=3cm]{figures/diagramB.png}\n\t\t\\caption{Diagram B}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.2\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[height=3cm]{figures/diagramC.png}\n\t\t\\caption{Diagram C}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.2\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[height=3cm]{figures/diagramD.png}\n\t\t\\caption{Diagram D}\n\t\\end{subfigure}\n\\end{figure}\n\nAdditionally, we find that in the $w_{rs}$ case (A and B), there is always one incoming line and one outcoming line for each intermediate vertex, which is because of one creation operator and one annihilation operator in the expression $W=w_{rs} c_r^{\\dagger} c_s$.\nIn the $V_{uvrs}$ case (C and D), there are always two incoming lines and two outcoming lines for each intermediate vertex, which is because of two creation operators and two annihilation operators in the expression $V=\\frac{1}{2}V_{uvrs} c_u^{\\dagger} c_v^{\\dagger} c_s c_r$.\n\nCompared with the expressions, the diagrams are very simple, which is one of its advantages.\nIn fact, Feynman diagram can not only show the structure of expression, but can also restore all the algebraic details.\nThis means that, instead of doing any algebraic calculation, we can just draw all the possible diagrams and then use some rules to translate to algebraic results.\nThen we will derive the rules:\n\nFor each vertex, we assign $w_{rs}$ or $V_{uv[rs]}$ depending on whether it's a $w$ vertex or a $V$ vertex:\n\n\\hspace{0.2\\textwidth}\n\\begin{minipage}{0.08\\textwidth}\n\t\\includegraphics[height=3cm]{figures/vertexW.png}\n\\end{minipage}\n\\begin{minipage}{0.2\\textwidth}\n\t$=w_{rs}$\n\\end{minipage}\n\\begin{minipage}{0.18\\textwidth}\n\t\\includegraphics[height=3cm]{figures/vertexV.png}\n\\end{minipage}\n\\begin{minipage}{0.1\\textwidth}\n\t$=V_{uv[rs]}$\n\\end{minipage}\n\nIt is easy to understand the result of $w$ vertex, since $W=w_{rs} c_r^{\\dagger} c_s$.\nFor the $V$ case, $V=\\frac{1}{2}V_{uvrs} c_u^{\\dagger} c_v^{\\dagger} c_s c_r$.\nWick's theorem states all possible of contraction should be included, thus any algebraic expression will have \"partners\" that the only difference is the exchange of index $u$ and $v$, or $s$ and $r$, or both.\nThus, instead of $\\frac{1}{2}V_{uvrs}$, the proper magnitude should be $\\frac{1}{2}V_{[uv][rs]}=V_{uv[rs]}$.\n\nHowever, it is not always the case, since sometimes we will meet double counting.\nFor example in the double loop in Diagram D, which corresponds to algebraic expression\n\\begin{equation}\n\t\\langle\\Phi_{0}|\n\t\\hat{\\mathcal{T}}\\left[\n\t\tc_{u}^{\\dagger}\\left(t_{1}\\right) \n\t\tc_{v}^{\\dagger}\\left(t_{1}\\right)\n\t\tc_{s}\\left(t_{1}\\right) \n\t\tc_{r}\\left(t_{1}\\right)\n\t\\right]\n\t| \\Phi_{0}\\rangle\n\\end{equation}\n\nObviously, there is only two contraction schemes, i.e. $u$ with $s$, $v$ with $r$, or $u$ with $r$, $v$ with $s$. \nThus, we meet double counting here.\nGenerally, when two lines are equal, double counting happens.\nThus, the final result should be divided by two for each pair of equal lines.\n\n\nEach line or curve is assigned by its corresponding Green function, which is also easy to understand.\nIn the case of higher orders, the expression is \n\\begin{equation} \\label{greenexp}\n\\begin{aligned}\n\ti \\tilde{G}^n_{p q}\\left(t, t^{\\prime}\\right)\n\t=& \\frac{(-i)^{n}}{n !} \n\t\\int_{-\\infty}^{\\infty} \\mathrm{d} t_{1} e^{-\\epsilon|t_{1}|} \\ldots \\int_{-\\infty}^{\\infty} \\mathrm{d} t_{n} e^{-\\epsilon|t_{n}|}\n\t\\\\\n\t& \\langle\\Phi_{0}|\n\t\\hat{\\boldsymbol{T}}\\left[\\hat{H}_{I}\\left(t_{1}\\right) \\ldots \\hat{H}_{I}\\left(t_{n}\\right) c_{p}(t) c_{q}^{\\dagger}\\left(t^{\\prime}\\right)\\right]|\n\t\\Phi_{0}\\rangle\n\\end{aligned}\n\\end{equation}\nwhich has a factor of $\\frac{(-i)^n}{n!}$.\n\nHowever, $t_1 \\dots t_n$ are treated on each footing and can also be exchanged when calculating the time-ordered product, thus it will contribute a factor $n!$.\nThus the overall factor is $(-i)^n$.\n\nLast but not least, we need to determine the overall sign of the expression.\nUnfortunately, it is impossible to determine the sign just from diagram, thus one must go back to any one of the algebraic expressions and then count how many times one need to commute creation and annihilation operator in the expression of time-ordered product.\n\nFeynman diagram drawn by above rules is refered as Abrikosov diagram.\n\nThen we go back to the calculation of first order Green function.\nLet's first focus on expression B and D.\nBoth parts contain $G^0_{pq}(t,t^{\\prime})$, which corresponds to a separate line in Diagram B and D.\nNow we introduce the famous linked-cluster theorem, which states that all diagrams contain a separate $G^0_{pq}(t,t^{\\prime}$ line will be canceled by the denominator of Eq \\ref{greenexp}.\nThe proof is given in the reference \\cite{main}.\nHere we take first order Green function as an example.\n\nUp to the first order, Green function can be written as\n\\begin{equation}\n\t\\begin{aligned}\n\t\ti\\tilde{G}_{pq}(t,t^{\\prime})=&i \\delta_{pq} G^0_{p}(t,t^{\\prime})\n\t\t\\\\\n\t\t+&w_{pq} G^0_p(t,t_1) G^0_q(t_1,t^{\\prime}) - w_{rr} G^0_r(t_1,t_1) \\delta_{pq} G^0_{p}(t,t^{\\prime})\n\t\t\\\\\n\t\t-&V_{pr[qr]} G^0_{p}(t,t_1) G^0_{r}(t_1,t_1) G^0_{q}(t_1,t^{\\prime})\n\t\t- V_{rs[rs]} G^0_r(t_1,t_1) G^0_s(t_1,t_1) \\delta_{pq} G^0_p(t,t^{\\prime})\n\t\t\\\\\n\t\t+&O(2)\n\t\\end{aligned}\n\\end{equation}\nwhile the denominator is \n\\begin{equation}\n\t\\langle\\Phi_{0}|\\hat{U}_{\\epsilon}(0,-\\infty)| \\Phi_{0}\\rangle=1\n\t\t- w_{rr} G^0_r(t_1,t_1)\n\t\t- V_{rs[rs]} G^0_r(t_1,t_1) G^0_s(t_1,t_1)\n\t\t+ O(2)\n\\end{equation}\n\nThus up to the first order,  the overall Green function reads\n\\begin{equation}\n\ti G_{pq}(t,t^{\\prime})=i \\delta_{pq} G^0_{p}(t,t^{\\prime})\n\t+w_{pq} G^0_p(t,t_1) G^0_q(t_1,t^{\\prime})\n\t-V_{pr[qr]} G^0_{p}(t,t_1) G^0_{r}(t_1,t_1) G^0_{q}(t_1,t^{\\prime}) +O(2)\n\\end{equation}\nwhere all unlinked diagrams are canceled.\n\nAs we mentioned before, both the numerator and denominator contains divergent terms, which will be canceled after division.\nIn fact, the divergent parts are exactly the unlinked diagrams.\nThus, linked-cluster theorem decreases the number of diagrams we need to calculate, and also guarantees the result is finite and thus physical.\n\nThen we analyze the rest terms of first order Green function:\n\\begin{equation}\n\t\\begin{aligned}\n\t\ti G^1_{pq}(t,t^{\\prime}) &= w_{pq} G^0_p(t,t_1) G^0_q(t_1,t^{\\prime})\n\t\t-V_{pr[qr]} G^0_{p}(t,t_1) G^0_{r}(t_1,t_1) G^0_{q}(t_1,t^{\\prime})\n\t\t\\\\\n\t\t&= G^0_p(t,t_1) G^0_q(t_1,t^{\\prime}) (w_{pq}-V_{pr[qr]}G^0_r(t_1,t_1)\n\t\t\\\\\n\t\t&= G^0_p(t,t_1) G^0_q(t_1,t^{\\prime}) (w_{pq}+V_{pr[qr]}n_r)\n\t\t\\\\\n\t\t&=0\n\t\\end{aligned}\n\\end{equation}\nwhere \n\\begin{equation}\n\t\\begin{aligned}\n\t\tG^0_r(t_1,t_1)&=G^0_r(t_1,t_1^{+})\n\t\t\\\\\n\t\t&=- \\langle\\Phi_{0}|\n\t\tc_r^{\\dagger} c_r\n\t\t| \\Phi_{0}\\rangle\n\t\t\\\\\n\t\t&=-n_r\n\t\\end{aligned}\n\\end{equation}\nis used.\n\nIn fact, the diagrams that contain $w$ vertex will always cancel with the diagrams that contain free Green function line starting and ending with the same $V$ vertex.\nAccording to Eq \\ref{greenexp}, $H_I$, which is $W$ and $V$ always appear together.\nThus, any diagram contain $V_{pr[qr]}n_r$ will automatically contain $r_{pq}$.\nThis result means that we can skip all diagrams with $W$ vertex and that contain free Green function line starting and ending with the same $V$ vertex at the same time.\nThus, we will not consider $W$ vertex in the following.\n\nThen we summarize the Feynman rules for Abrikosov diagram:\n\\begin{itemize}\n\t\\item Draw all topologically distinct connected diagrams with $n$ interaction dots and $2n + 1$ directed (solid) free Green’s function starting at the outer vertex $(p, t)$ and ending at the outer vertex $(q, t^{\\prime})$.\n\t\tAt each interaction dot, two Green function start and two end; assign a time argument to each interaction dot.\n\t\\item Attach one-particle indices and time arguments to the free Green function lines; the arrows define the order of the time arguments. Replace the graphical symbols (free Green function lines and interaction dots) by the respective analytical expressions.\n\t\\item Sum over indices and integrate over time arguments of the inner vertices.\n\t\\item The overall phase of an Abrikosov diagram can only be fixed by inspecting one of the Feynman diagrams comprised in the Abrikosov diagram.\n\t\tThe phase is to be adapted in such a way that this Feynman diagram is reproduced correctly by the Abrikosov expression.\n\t\\item Apply a factor of $\\frac{1}{2}$ for each pair of (topologically) equivalent free Green function lines to compensate for double counting of Feynman diagrams. Double counting may arise for other reasons at fourth and higher order, and this possibility must be checked at the level of Feynman diagrams.\n\\end{itemize}\n\nWe calculate the second order Green function as the end of this section:\nAccording to the Feynman diagram, we first draw all possible topologically inequivalent diagrams.\nIn the case of second order Green function, there is only one diagram:\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[height=4cm]{figures/order2.png}\n\t\\caption{Diagram of second order Green function}\n\\end{figure}\n\nNote that the two curves are identical ( start and end with the same vertices).\nThus, according the Feynman rules, we can easily determine the second order Green function up to a overall sign:\n\\begin{equation} \\label{order2}\n\t\\begin{aligned} \n\tG_{p q}^{(2)}\\left(t, t^{\\prime}\\right)=\\pm \\frac{1}{2} \\sum_{r, u, v_{-\\infty}} & \\int_{-\\infty}^{\\infty} \\mathrm{d} t_{1} \\int_{-\\infty}^{\\infty} \\mathrm{d} t_{2} V_{p r[u v]} V_{u v[q r]} \n\t\\\\ \n\t& G_{p}^{0}\\left(t, t_{1}\\right) G_{u}^{0}\\left(t_{1}, t_{2}\\right) G_{v}^{0}\\left(t_{1}, t_{2}\\right) G_{r}^{0}\\left(t_{2}, t_{1}\\right) G_{q}^{0}\\left(t_{2}, t^{\\prime}\\right) \n\t\\end{aligned}\n\\end{equation}\n\nTo determine the overall sign, we only need to consider the case\n\\begin{equation}\n\t\\langle\\Phi_{0}|\n\t\\hat{\\mathcal{T}}\\left[\n\t\t\\wick{\\c4 c_{u}^{\\dagger}\\left(t_{1}\\right) \\c3 c_{v}^{\\dagger}\\left(t_{1}\\right) \\c2 c_{s}\\left(t_{1}\\right) \\c1 c_{r}\\left(t_{1}\\right) \\c1 c_{i}^{\\dagger}\\left(t_{2}\\right) \\c2 c_{j}^{\\dagger}\\left(t_{2}\\right) \\c3 c_{l}\\left(t_{2}\\right) \\c1 c_{k}\\left(t_{2}\\right) \\c4 c_{p}(t) \\c1 c_{q}^{\\dagger}\\left(t^{\\prime}\\right)}\n\t\t\\right]\n\t\t| \\Phi_{0}\\rangle\n\\end{equation}\nwhich gives an overall sign of $-1$, which is canceled with the factor $(-i)^2$.\n\nThus the overall sign of expression Eq \\ref{order2} should be positive.\n\n", "meta": {"hexsha": "dfeea5716a774e2f2b0f97d0d7c8bc9de45ca77e", "size": 17778, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/propagator.tex", "max_stars_repo_name": "SUSYUSTC/bachelor_thesis", "max_stars_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/propagator.tex", "max_issues_repo_name": "SUSYUSTC/bachelor_thesis", "max_issues_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/propagator.tex", "max_forks_repo_name": "SUSYUSTC/bachelor_thesis", "max_forks_repo_head_hexsha": "6ed40c7edf566436e9083f67172bba966732026c", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.7068493151, "max_line_length": 328, "alphanum_fraction": 0.695916301, "num_tokens": 6186, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.672331705744791, "lm_q1q2_score": 0.4331329647276005}}
{"text": "\\documentclass[]{article}\n \\usepackage{amsmath}\n \\usepackage{amssymb}\n \\usepackage{mathdots}\n% \\usepackage{amsthm}\n% \\usepackage{textcomp}\n \\parindent=0mm\n \\parskip=2.5mm\n% \\parindent=0mm\n% \\renewcommand{\\arraystretch}{1.35}\n% \\usepackage{cite}\n\n%\\usepackage[acronym,nonumberlist]{glossaries}\n%\\makeglossaries \n\\usepackage{graphicx}\n\\graphicspath{{Figures/}}\n\\usepackage[small,bf,up]{caption}\n\\providecommand{\\diff}[3]{\\frac{d^{#3} #1}{d #2^{#3}}}\n\\providecommand{\\pdiff}[3]{\\frac{\\partial^{#3} #1}{\\partial #2^{#3}}}\n\\providecommand{\\abs}[1]{\\left \\lvert#1\\right \\rvert}\n\\providecommand{\\etal}[0]{\\textit{et al. }}\n\\oddsidemargin 15mm                        % 1 inch + lefthand margin on odd numbered pages\n\\evensidemargin 15mm                       % 1 inch + lefthand margin on even numbered pages\n\\textwidth 145mm  \n\n%\\usepackage[round]{natbib}\n%\n\\setcounter{MaxMatrixCols}{20}\n\\usepackage[square,numbers,comma,sort&compress]{natbib}\n\\usepackage{listings} \n%\\bibliographystyle{plainnat}\n\\bibliographystyle{unsrt}\n%\\usepackage{nomencl}\n%\\nomlabelwidth=15mm\n%\\makeindex\n%\\makenomenclature\n\n\\date{\\today}\n\\title{Probabilistic Transient Propagation (PTP), Background and Mathematics}\n\n\\author{Richard Collins}\n\n\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n \n\\end{abstract}\n\n\\section{Transient Equations}\nHere we are going to model the basic transient equations, \n\\begin{equation}\\label{TranEqns}\n \\begin{split}\n \\pdiff{H}{t}{} + \\frac{a^2}{gA}\\pdiff{Q}{x}{} &= 0 \\\\\n\\pdiff{H}{x}{} + \\frac{1}{gA}\\pdiff{Q}{t}{} + \\frac{\\lambda}{2 g DA^2}Q \\abs{Q} &= 0\n \\end{split}\n\\end{equation}\n\nThese are a pair of coupled non-linear hyperbolic partial differential equations that describe the change in head and flow along a pipe.\nThey need to be coupled with suitable, initial and boundary conditions to complete the solution.\n\n\\section{Method of Characteristics}\nThe standard solution technique for solving \\eqref{TranEqns} numerical is to use the Method of Characteristics (MOC).  \nThe MOC converts the partial differential equations into ordinary differential equations along characteristic lines in the solution space, along which the information about changes flows.\nTo apply the MOC to \\eqref{TranEqns} we first multiply the momentum equation by a currently unknown factor $K$, then add the two equations together:\n\\begin{equation}\n \\pdiff{H}{t}{} + \\frac{a^2}{gA}\\pdiff{Q}{x}{} + K \\pdiff{H}{x}{} + K \\frac{1}{gA}\\pdiff{Q}{t}{} + K \\frac{\\lambda}{2 g DA^2}Q \\abs{Q} = 0\n\\end{equation}\nwithout explicitly going into why, if we set $K$ to be the wavespeed $a$, then we get the following:  (NOTE THIS ISN'T QUITE RIGHT CHECK WITH WYLIE AND STREETER)\n\\begin{equation}\n \\pdiff{H}{t}{} + a \\pdiff{H}{x}{} + \\frac{a}{gA}\\left(\\pdiff{Q}{t}{} + a \\pdiff{Q}{x}{} \\right) + \\frac{a \\lambda}{2 g DA^2}Q \\abs{Q} = 0\n\\end{equation}\nThe total derivative of a function $f(x,t)$ w.r.t time is given by $\\pdiff{f}{t}{} + \\diff{x}{t}{}\\pdiff{f}{x}{}$ so we can see that we have formed a series of total derivatives.\n\\begin{equation}\n \\diff{H}{t}{} \\pm \\frac{a}{gA}\\diff{Q}{t}{} \\pm \\frac{a \\lambda}{2 g DA^2}Q \\abs{Q} = 0\n\\end{equation}\nthis pair of equations is only valid along the lines when \n\\begin{equation}\n \\diff{x}{t}{} = \\pm a\n\\end{equation}\n\nTo simplify the calculations below we will rewrite the equation as:\n\\begin{equation}\n \\diff{H}{t}{} \\pm B \\diff{Q}{t}{} \\pm \\frac{R}{\\Delta x} Q \\abs{Q} = 0\n\\end{equation}\nwith $B = \\frac{a}{g A}$ and $R = \\frac{\\lambda \\Delta x}{2 g D A^2}$.\nNote: that $R$ contains some modelling error.\n\n\nNEEDS A BIT IN HERE ABOUT HOW TO GET TO THE NEXT BIT\n\n\\begin{figure}[htp]\n \\centering\n \\caption{Mesh discretisation for the MOC}\n \\label{MOCmesh}\n\\end{figure}\n\nThe equations need to be integrated along the lines AP and B, which is easy for the first pair of terms but becomes complicated for the final term.\n\nOnce we have integrated along the two lines then we have the pair of equations:\n\\begin{equation}\\label{posChar}\n H_P = C_p + B_p Q_P\n\\end{equation}\nand\n\\begin{equation}\\label{negChar}\n H_P = C_m + B_m Q_P\n\\end{equation}\n\nwith the constants of integration given by:\n\\begin{equation}\n \\begin{split}\n  C_p &= H_A + Q_A \\left(B - R \\abs{Q_A} (1-\\epsilon)\\right) \\\\\n  B_p &= B + \\epsilon R \\abs{Q_A} \\\\\n  C_m &= H_B - Q_B \\left(B - R \\abs{Q_B} (1-\\epsilon)\\right) \\\\\n  B_m &= B + \\epsilon R \\abs{Q_B} \\\\ \n \\end{split}\n\\end{equation}\n\nwe will explore the use of $\\epsilon$ a little later.\n\nIf we combine \\eqref{posChar} and \\eqref{negChar} we can generate equations that take the information from both the forward and backward characteristic for head and flow at the current point.\n\\begin{equation}\\label{BaseEqn}\n \\begin{split}\n  H_P &= \\frac{B_m C_p + B_p C_m}{B_m + B_p} \\\\\n  Q_P &= \\frac{C_p - C_m}{B_m + B_p} \\\\\n \\end{split}\n\\end{equation}\n\nThese two equations are the fundamental equations that we will use going forward. \n$C_m$, $B_m$, $C_p$ and $B_p$ are functions of the flows and heads at the adjacent points.\n\n\n\\section{Kalman Filter}\nSTUFF HERE ON THE BACKGROUND TO THE KALMAN FILTER\n\n\\begin{equation}\n\\begin{split}\n \\mathbf{\\hat{x}}_t &= \\mathbf{F}_t \\mathbf{\\hat{x}}_{t-1} + \\mathbf{B} \\mathbf{u}_t + \\mathbf{\\hat{w}}_t \\\\\n \\mathbf{\\hat{z}}_t &= \\mathbf{H}_t \\mathbf{\\hat{x}}_t + \\mathbf{\\hat{v}}_t \\\\\n\\end{split}\n\\end{equation}\n\n\\subsection{Ability to use the Kalman Filter to model the transient equations}\nAs mentioned above the Kalman filter can be used to model linear dynamic models, however the transient equations are non-linear.\nTherefore we will have to do some linearisation to make the equations suitable to be modelled in this way.\nThere are a number of approaches that will work, see Section \\ref{EKF} for a more general approach, however here we will use a simpler technique.\nIf we look at the original equations \\eqref{TranEqns} we see that, if we assume $A$, $D$, $a$ and $\\lambda$ are constants, the only non-linearity is in the flow in the final term of the momentum equation.\nTherefore if we can linearise this then the equation will be linear and suitable for modelling with the Kalman Filter.\n\nIf we assume that the changes in flow rate during the transient are small, and the flow rate  remains close to the original flow rate then we can say that:\n\\begin{equation}\n Q\\abs{Q} \\approx Q Q_0\n\\end{equation}\nwhere $Q_0$ is the initial flow at the start of the simulation.\n$Q_0$ obviously remains a constant and the equations are now linear.\n\\begin{equation}\\label{TranEqnsLinear}\n \\begin{split}\n \\pdiff{H}{t}{} + \\frac{a^2}{gA}\\pdiff{Q}{x}{} &= 0 \\\\\n\\pdiff{H}{x}{} + \\frac{1}{gA}\\pdiff{Q}{t}{} + \\frac{\\lambda Q_0}{2 g DA^2}Q &= 0\n \\end{split}\n\\end{equation}\n\nIf we apply the MOC to this pair of equations, we again get \\eqref{BaseEqn}, however the characteristics are slightly modified.\n\\begin{equation}\n \\begin{split}\n  C_p &= H_A +  B Q_A - R Q_A Q_0 \\\\\n  B_p &= B \\\\\n  C_m &= H_B - B Q_B + R Q_B Q_0\\\\\n  B_m &= B  \\\\ \n \\end{split}\n\\end{equation}\n\nThe full equations for predicting the head and flow rate at $P$ are simple enough to be worth writing out in full.\n\\begin{equation}\\label{LinearH}\n H_P = \\frac{1}{2} \\left[H_A +  H_B + \\left(-R Q_0 + B \\right)Q_A + \\left(R Q_0 - B\\right) Q_B \\right]\n\\end{equation}\nand\n\\begin{equation}\\label{LinearQ}\n Q_P = \\frac{1}{2} \\left[\\frac{H_A}{B} + \\frac{H_B}{B} + \\left(1-\\frac{R Q_0}{B} \\right)Q_A + \\left(1-\\frac{R Q_0}{B}\\right)Q_B    \\right]\n\\end{equation}\n\nWe can rewrite this is a more Kalman filter type way:\n\\begin{equation}\n\\begin{split}\n \\mathbf{x}_{h,t} &= \\frac{1}{2} \\left[ \\mathbf{x}_{h-1,t-1} +   \\mathbf{x}_{h+1,t-1} \\left(-R Q_0 + B \\right) \\mathbf{x}_{q-1,t-1} + \\left(R Q_0 - B\\right)  \\mathbf{x}_{q+1,t-1} \\right]\\\\\n  \\mathbf{x}_{q,t} &= \\frac{1}{2} \\left[\\frac{\\mathbf{x}_{h-1,t-1}}{B} + \\frac{\\mathbf{x}_{h+1,t-1}}{B} + \\left(1-\\frac{R Q_0}{B} \\right)\\mathbf{x}_{q-1,t-1} + \\left(1-\\frac{R Q_0}{B}\\right)\\mathbf{x}_{q+1,t-1}    \\right]\n \\end{split}\n\\end{equation}\nwhere $h$ is now the position in the state vector corresponding to the head at $P$ and $q$ is the position corresponding to the flow rate at $P$.\n\n\nThe construction of the dynamics matrix can then be seen to be:\n\\begin{equation}\n\\begin{bmatrix}\n\\vdots \\\\\n x_{h-1} \\\\\n x_{h} \\\\\n x_{h+1} \\\\\n \\vdots \\\\\n  x_{q-1} \\\\\n x_{q} \\\\\n x_{q+1} \\\\\n  \\vdots\n\\end{bmatrix}_t\n=\n\\begin{bmatrix}\n\\ddots & \\dots& \\dots& \\dots& \\dots& \\dots& \\dots&\\dots &\\iddots\\\\\n\\dots 0 & \\frac{1}{2}& 0 & \\frac{1}{2} & 0 \\dots0&  \\frac{1}{2}\\left(-R Q_0 + B \\right) & 0 & \\frac{1}{2}\\left(R Q_0 - B\\right)&0\\dots \\\\ \n\\vdots & \\vdots& \\vdots& \\vdots& \\vdots& \\vdots& \\vdots& \\vdots& \\vdots\\\\\n\\dots 0 & \\frac{1}{2 B} &0& \\frac{1}{2 B} & 0  \\dots 0  & \\frac{1}{2} \\left(1-\\frac{R Q_0}{B} \\right) & 0 & \\frac{1}{2} \\left(1-\\frac{R Q_0}{B} \\right) & 0\\dots\\\\\n\\iddots & \\dots& \\dots& \\dots& \\dots& \\dots& \\dots &\\dots &\\ddots\\\\\n\\end{bmatrix}\n\\begin{bmatrix}\n\\vdots \\\\\n x_{h-1} \\\\\n x_{h} \\\\\n x_{h+1} \\\\\n \\vdots \\\\\n  x_{q-1} \\\\\n x_{q} \\\\\n x_{q+1} \\\\\n  \\vdots\n\\end{bmatrix}_{t-1}\n\\end{equation}\nwhich is a nicely sparse matrix.\n\n\\subsection{How Gaussian are the uncertainties?}\nKalman filters only really work with Gaussian uncertainty (noise). \nSo there is a question of how close to Gaussian are any uncertainties.\nIf we look at \\eqref{LinearH} and \\eqref{LinearQ} we can see that as well as uncertainty in the state we need to account for uncertainty in $R$ and $B$ and some combinations of these factors.\n\n\\begin{equation}\n B = \\frac{a}{g A}\n\\end{equation}\n\n\\begin{equation}\n R = \\frac{\\lambda \\Delta x}{2 g D A^2}\n\\end{equation}\n\n\n\\section{Extended Kalman Filter}\\label{EKF}\nNote that the full transient equations are non-linear so the standard Kalman filter approach is unavailable. \nInstead we have to use the extended Kalman filter which uses the Jacobian of the evolution equations to approximate the evolution of the system covariance. \n\n\nHere we include the Extended Kalman Filter Equations. \n\nThe basic equation relies on the ability to formulate the problem into a way which allows the next state of the system is only a function of the previous state, some control inputs (which we will not consider for now) and some uncertainty.\n\\begin{equation}\n\\begin{split}\n \\mathbf{\\hat{x}}_t &= f(\\mathbf{\\hat{x}}_{t-1}) + \\mathbf{\\hat{w}}_t \\\\\n \\mathbf{\\hat{z}}_t &= h(\\mathbf{\\hat{x}}_t) + \\mathbf{\\hat{v}}_t \\\\\n\\end{split}\n\\end{equation}\n\nwhere $f(\\cdot)$ and $h(\\cdot)$ are some, potentially, non-linear mappings of the evolution of the state and the measurements, and $w$ and $v$ are the zero-mean Gaussian noise vectors. \nThe state evolution can be calculated in what ever non-linear way is most appropriate, i.e. by a matrix method, or any other technique. \n\\begin{equation}\n \\mathbf{\\hat{x}}_t = f(\\mathbf{\\hat{x}_{t-1}})\n\\end{equation}\nhowever the covariance matrices are calculated using:\n\\begin{equation}\n \\mathbf{P}_t = \\mathbf{F}_{k-1} \\mathbf{P}_{t-1} \\mathbf{F}_{k-1}^T + \\mathbf{Q}_{t-1}\n\\end{equation}\n\nwhere $\\mathbf{F}$ is the Jacobian matrix of the function $f(\\cdot)$\n\\begin{equation}\n \\mathbf{F} = \\pdiff{f}{\\mathbf{\\hat{x}}}{}\n\\end{equation}\n\n\n\\subsection{Calculation of the Jacobian}\nTo calculate the Jacobian of the evolution equation we first need to determine our state vectors and actually what our state evolution equations are:\n\n\\subsubsection{State Vector}\nIn this formulation the state vector is composed of the Heads and flows at each nodal position, however due to the non-linearity we also need to include the pipe diameter, friction factor (and possibly the pipe wave speed) on each pipe reach between nodes.  \nIf the number of Nodes in the model is $N$, the size of our state vector (not including wavespeed) will be $2N + 2(N-1) = 4N -2$, (or $5N-3$ if wave speed is included).\n\n\n\n\\end{document}\n", "meta": {"hexsha": "1fe9f6e89d6c0b98725e8f5c3af323b5e339f990", "size": 11685, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Probabilistic_Transient_Propagation_Modelling.tex", "max_stars_repo_name": "richpaulcol/PTP_Documentation", "max_stars_repo_head_hexsha": "7ce6aed00f423a41369567ba2bc08605f40e2cd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Probabilistic_Transient_Propagation_Modelling.tex", "max_issues_repo_name": "richpaulcol/PTP_Documentation", "max_issues_repo_head_hexsha": "7ce6aed00f423a41369567ba2bc08605f40e2cd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Probabilistic_Transient_Propagation_Modelling.tex", "max_forks_repo_name": "richpaulcol/PTP_Documentation", "max_forks_repo_head_hexsha": "7ce6aed00f423a41369567ba2bc08605f40e2cd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.1443661972, "max_line_length": 258, "alphanum_fraction": 0.6958493795, "num_tokens": 3901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4331329604979374}}
{"text": "\\chapter{Dynamical Systems}\n\\label{chp:dynamicalsystems}\n\n\\begin{multicols}{2}[\\subsubsection*{Contents of this chapter}]\n   \\printcontents{}{1}{\\setcounter{tocdepth}{2}}\n\\end{multicols}\n\nThis is dangerously familiar ground for physicists. A dynamical system is some system:\n\n\\begin{equation}\n\\partial_t\\mathbf{x} = \\mathbf{f}(\\mathbf{x},t,\\mathbf{u};\\mathbf{\\beta})\n\\end{equation}\n\nWhere $\\mathbf{x}$ are the state space coordinates of the system at some time $t$, and $\\mathbf{f}$ is the \\textit{dynamics} of the system. $\\mathbf{u}$ is some control input and $\\mathbf{\\beta}$ are parameters. A system where $\\mathbf{f}$ depends on time is called \\textit{non-autonomous} and a system that has an $\\mathbf{f}$ that does not depend on time is called \\textit{autonomous}.  \n\nConventionally, the dynamics $\\mathbf{f}$ are derived from first principles. Increasingly, it is possible to infer them from data. Challenges arise from:\n\n\\begin{itemize}\n\\item Nonlinear $\\mathbf{f}$, that is, the system cannot be described in the form $\\partial_t\\mathbf{x}=\\mathbf{Ax}$\n\\item Unknown $\\mathbf{f}$\n\\item High dimensional state vector $\\mathbf{x}$\n\\item Chaos, Transients\n\\item Noise, Stochastic forcing functions\n\\item Multiscale dynamics\n\\item Uncertainty (in parameters etc.)\n\\end{itemize}\n\n\\section{Mode Decompositions}\nModal decompositions express the evolving state of a system in terms of a superposition of basis vectors that are the eigenfunctions of a time-translation operator. In general, the rank of the basis space is the same as the state space dimension, but in practice only a few of those modes have \"energy\". That means that the description of a system in terms of a modal decomposition often requires orders of magnitude fewer parameters than the description of the state space. Extracting the dominant modes also amounts to extracting the dominant dynamics of the system, with the assumption possibly being that the discarded low-energy modes are noise. In so far, modal decomposition runs closely parallel to decomposition-based dimensionality reduction techniques such as SVD, PCA and ICA, though explicitly introducing the notion of a trajectory through time.\n\nThe modes are properties of the time translation operator and the state space. Therefore, the description in terms of modes is compatible with an arbitrary, unpredictable forcing function acting on the system, so long as it does not affect the time translation operator or the state space. For example, the description of the oscillation of a guitar string in terms of modes remains valid regardless of the song that is being played. However, changing the length of the string increases the size of the state space, and increasing the tension in the string accelerates its reversion from being struck away from its equilibrium, and therefore it's time translation operator. In those cases the modes of the system are changed.   \n\n\n\\section{Koopman and Frobenius-Perron Operators}\nThe Koopman Operator, or composition operator, is the classical analogue of the time translation operator $e^{-i\\mathbf{\\hat{H}}t/\\hbar}$ in quantum mechanics. It describes dynamics in terms of the \\textit{Heisenberg Picture}, in which operators, rather than states, have time-dependence. It describes autonomous systems (in quantum mechanics, that would be a system where the Hamiltonian $\\mathbf{\\hat{H}}$ nor the size of the state space depend on time).\n\nConsider a dynamical system evolving on a manifold $\\mathscr{M}$, so that, in discrete time:\n\n\\begin{equation}\n\\mathbf{x}_{k+1} = \\mathbf{f}(\\mathbf{x}_{k})\n\\end{equation}\n\nWhere $\\mathbf{x}\\in\\mathscr{M}$ are the state space coordinates of the system at a given time. Given a scalar valued function on the state space $g:\\mathscr{M} \\rightarrow \\mathbb{R}$, the Koopman Operator $\\mathbf{\\hat{K}}$ acts as:\n\n\\begin{equation}\n\\mathbf{\\hat{K}}g(\\mathbf{x}) = g(\\mathbf{f}(\\mathbf{x}))\n\\end{equation} \n\nWhich acts as time translation by one step.\n\nThe Koopman Operator is infinite dimensional and linear, even though the dynamical system might be nonlinear with a finite state space. The Frobenius-Perron Operator (sometimes also Ruelle Operator, Ruelle-Frobenius-Perron Operator, or Transfer Operator) is the right adjoint of the Koopman operator, so that an approximation of one provides an approximation of the other. Rather than a function in state space, it translates the state space density in time. Let $\\mathbf{\\hat{P}}$ be the Frobenius-Perron Operator. Let the state space density be $\\rho(\\mathbf{x}$, and define some operator $\\mathbf{\\hat{A}}$, so that $\\mathbf{\\hat{A}}\\rho(\\mathbf{x}) = g(\\mathbf{x})$. Then, in terms of either the Koopman or the Frobenius-Perron approach, the average value of the quantity $\\left< g(\\mathbf{x}(t))\\right>$ at time $t$ in the Koopman picture or in the Frobenius-Perron picture is \\cite{cvitanovic2016chaos,salova2019koopman}:\n\n\\begin{equation}\n\\begin{array}{rl}\n\\left< g(\\mathbf{x}(t))\\right> =& \\int_\\mathscr{M} \\mathrm{d}x \\mathbf{\\hat{K}}(t)\\mathbf{\\hat{A}}\\rho(\\mathbf{x}) \\\\\n& \\int_\\mathscr{M} \\mathrm{d}x \\mathbf{\\hat{A}}\\mathbf{\\hat{P}}(t)\\rho(\\mathbf{x})\n\\end{array}\n\\end{equation}\n\nWhich implies that $\\mathbf{\\hat{K}}(t)\\mathbf{\\hat{A}} \\left[\\mathbf{\\hat{P}}(t)\\right]^{-1} = \\left[\\mathbf{\\hat{K}}(t) \\right]^{-1} \\mathbf{\\hat{A}} \\mathbf{\\hat{P}}(t) = \\mathbf{\\hat{A}}$.\n\n\nThe function $g(\\mathbf{x}(t))$ is an \\textit{observable} of the system, which might be a pixel value, the value of a stock portfolio, the energy of a particle, or something like that. The state space coordinates $\\mathbf{x}(t)$ may or may not correspond to quantities that are actually observable. Their role is to uniquely parametrize the possible states of the system. The Koopman Operator acts on observables, which is probably why it seems to come up more often in data-driven work. \n\n\n% POD \n\n\\section{Proper Orthogonal Decomposition (POD)}\nProper Orthogonal Decomposition (POD) seeks a lower-rank representation of a dynamical system that, as far as I can see, is entirely analogous to SVD or PCA \\cite{megretski2004pod}. Given a system $\\mathbf{x}(t) \\in \\mathbb{R}^n$, one looks for a low-rank projection $\\Pi_r$ that minimizes the expected value of the error:\n\n\\begin{equation}\n\\argmin \\mathbb{E}_t||\\mathbf{x}(t) - \\mathbf{\\Pi}\\mathbf{x}(t)||_{2}\n\\end{equation} \n\nThis is the same loss function as for PCA, and so the projection matrix $\\mathbf{\\Pi}_r = \\sum_{i=1}^{r} \\mathbf{v}_i\\mathbf{v}^T_i$ where $\\mathbf{v}_i$ is the $i$th principal component vector. \n\nThe POD does not have anything to say about the dynamics of a system, indeed, the time-ordering of the snapshots has no effect on the result. As such, performing POD on a system across different time windows should yield different decompositions unless the system is completely at rest, even when the dynamics of the system are steady. The first orthogonal component is simply the point in state space that the system is most correlated with across the observed time-frame.  \n\n% DMD\n\\section{Dynamic Mode Decomposition (DMD)}\n\\label{sec:dmd}\nDynamic Mode Decomposition (DMD) fits a reduced-rank, linear dynamical system to multi-dimensional time-series data. The rank-reduction is useful when the state space is very high-dimensional, for example when each time step is an image with many pixels. Canonically, fitting and rank reduction relies on SVD, so that the method is based on $L^2$ loss. It originated in the fluid dynamics community, where very high-dimensional state spaces are common because dynamics must be resolved across many length scales.\n\nIn case of plain-vanilla DMD, the dataset consists of pairs of snapshots of the system, which show the system at two subsequent time steps, i.e. $\\{(\\mathbf{x}_t,\\mathbf{y}_t): \\mathbf{y}_t = \\mathbf{x}_{t+\\delta t} \\}$. Often, the different pairs show the system on different state space trajectories. That is, they may originate with many different \"incarnations\" of the system. To me it looks basically like an VAR(1) model, except that it can handle a very high dimensional state vector by extracting the leading eigendecomposition of the coefficient matrix without having to calculate it. It also looks a lot like fitting the transition matrix of a Markov Chain.\n\nGiven a set of $m$ snapshots of the system $\\{\\mathbf{x}_t:\\ t\\in[1,m], \\mathbf{x}_t \\in \\mathbb{R}^{n}\\}$, let $\\mathbf{X}_{1,m-1} = \\left[\\mathbf{x}_1,\\mathbf{x}_2,...,\\mathbf{x}_{t-1},\\mathbf{x}_{m-1}\\right]$ be the matrix of state vectors from $t\\in[1,m-1]$ and $\\mathbf{X}_{2,m}$ be the matrix of state vectors advanced by one time step from $t\\in[2,m]$. Then dynamic mode decomposition essentially looks for linear dynamics using linear regression:\n\n\\begin{equation}\n\\mathbf{X}_{2,m} = \\mathbf{A}\\mathbf{X}_{1,m-1}\n\\end{equation}\n\nWhere $\\mathbf{A} \\in \\mathbb{R}^{n\\times n}$ is square and therefore diagonalizable, but may be very large.\n\nLet $a_{i,j}$ be the entry in the $i$th row and $j$th column of $\\mathbf{A}$. Elementwise, the equation for the $i$th state variable at time $t$, $x_{i,t} = [\\mathbf{x}_t]_i$ is written:\n\n\\begin{equation}\nx_{i,t} = \\sum_j a_{i,j} x_{i,t-1}\n\\end{equation}\n\nThe eigenvectors of $\\mathbf{A}$  correspond to normal modes of the system. The corresponding eigenvectors, which may be real or complex, predict the evolution of the mode over time.\n\nThe size of $\\mathbf{A}\\in\\mathbb{R}^{n\\times n}$ may be so large that extracting its eigenvectors and eigenvalues may be computationally intractable. DMD instead derives a smaller matrix $\\mathbf{A'}$ that has the same eigenvalues as $\\mathbf{A}$ and uses those to also finds the eigenvectors.\n\n\\begin{equation}\n\\begin{array}{ll}\n1. & \\mathbf{X}_{1,m-1} = \\mathbf{U}\\mathbf{\\Sigma}\\mathbf{V}^T,\\ \\ \\ \\ \\mathbf{X}_{2,m} = \\mathbf{AU\\Sigma V}^T\\\\\n2. & \\mathbf{U}^T\\mathbf{X}_{2,m}\\mathbf{V\\Sigma}^{-1} = \\mathbf{U}^{T}\\mathbf{AU} = \\mathbf{A'}\\\\\n3. & \\mathbf{A'}\\mathbf{W} = \\mathbf{W}\\mathbf{\\Lambda} \\\\\n4. & \\mathbf{\\Phi} = \\mathbf{X}^T\\mathbf{V\\Sigma}^{-1}\\mathbf{W}\n\\end{array}\n\\end{equation}\n \nIf the system has low dimensional structure, the matrix $\\mathbf{A'}$ can be further reduced by only keeping the first $r$ vectors in $\\mathbf{U}$. The final transformation$\\mathbf{\\Phi}$ gives high-dimensional eigenvectors of the full matrix $\\mathbf{A}$. \n\n\\citeasnoun{stevebrunton} suggests that DMD is, in spirit, a combination of principal component analysis and the Fourier transform in time. The fact that DMD exists in a regression framework there are a huge number of extensions that can be leveraged. In particular, \\citeasnoun{stevebrunton} delves into combining DMD with compressed sensing. What is surprising is that the dynamics that are modeled by DMD are not necessarily linear. The matrix $\\mathbf{A}$ is large enough to approximate nonlinear dynamics.\n\n\n\\section{Extended Dynamical Mode Decomposition (EDMD)}\n\\label{sec:edmd}\n\n\n\\section{Sparse Identification of Nonlinear Dynamics (SINDy)}\n\\label{sec:sindy}\n\n\\section{DMD with Irregularly Sampled Timesteps}\n", "meta": {"hexsha": "b4208267641f2f915439bc8e71fac3650ed19b59", "size": 11005, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/dynamicalsystems.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/dynamicalsystems.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/dynamicalsystems.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.3412698413, "max_line_length": 927, "alphanum_fraction": 0.7542026352, "num_tokens": 3031, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6442250928250376, "lm_q1q2_score": 0.4331329597723167}}
{"text": "\\chapter{Generative Adversarial Networks} \\label{cha:gans}\n\\glsunset{GAN}\n\n\\acp{GAN} fall into a particular subfield of machine learning called \\textit{generative modeling}, the goal of this area of study is to be able to generate original data based on a training dataset. As mentioned in \\autoref{sub:unsupervised_learning}, the data found in real life scenarios for any given situation is just a very tiny fraction of all the possible values in the input space, recall the \\gls{MNIST} example given, just a minuscule subset of all possible images can be sensibly interpreted as digits. It can be said that real world data has some structure, and generative models aim to replicate this structure in order to sample from it.\n\n\n\\section{Generative Models and Data Distributions}\n\\textcite{nipsGAN2017} explains that any dataset is made of samples taken from some probability distribution $p_{data}$ that defines the structure of the data, and all the different techniques in generative modeling are trying to produce a $p_{model}$ to replicate as close as possible the underlying distribution of the data.\n\nIf $p_{data}$ was known for a given problem, then it could be used by itself to generate original data, but calculating this distribution is basically impossible for all but the simplest datasets, so the most a model can do is try to replicate it. To better understand the complexities in probability distributions it can be helpful to look at some characteristics in the, relatively simple, \\gls{MNIST} dataset.\n\nRecall that the \\gls{MNIST} dataset consists of $70,000$ grayscale images of size $28\\times28$, and these images are color inverted. When introducing the dataset in \\autoref{sec:mnist} the images were inverted again to show the original colors, but here the properties will be analyzed without making any preprocessing on the data. First it is helpful to look at what is the mean and variance for each pixel in the \\gls{MNIST} dataset, these values are shown in \\autoref{fig:mnist_mean_var}.\n\\begin{figure}[h]\n    \\centering\n    \\caption{\\gls{MNIST} mean and variance}\n    \\includegraphics[width=0.65\\textwidth]{chapters/GANs/figures/mnist_mean_var.pdf}\n    \\fonte{From the author (2021)}\n    \\label{fig:mnist_mean_var}\n\\end{figure}\n\nThe information in \\autoref{fig:mnist_mean_var} already gives some insight into how the data is structured, the edges of the image practically see no change since all the digits are centered, and it is possible to see dips in brightness in the middle-top and middle-bottom of the digits; these represent the spaces that all the digits are drawn around (i.e. the two holes in the number $8$).\n\nAnother way to see the distribution is to directly plot the probability of seeing the different values for a pixel, this is done by counting how many times each value has appeared in a selected pixel for all images in the dataset, the probability is then the number of value occurrences divided by the total number of images. Doing this for one of the center pixels, in row 15 and column 15, the end result is the probability distribution seen in \\autoref{fig:mnist_pixel_dist}.\n\\begin{figure}[hbt]\n    \\centering\n    \\caption{Probability distribution of values in pixel (15,15) of \\gls{MNIST}}\n    \\includegraphics[width=0.6\\textwidth]{chapters/GANs/figures/mnist_dist_pixel_14x14.pdf}\n    \\fonte{From the author (2021)}\n    \\label{fig:mnist_pixel_dist}\n\\end{figure}\n\nThe probability distribution in \\autoref{fig:mnist_pixel_dist} gives even more information about the dataset, it can be seen that the values are either completely black, or a very bright white. Any grayish values are very unlikely since with handwriting digits the strokes are very sharp and well defined. It is possible to extend \\autoref{fig:mnist_pixel_dist} by calculating the distribution for a whole column of pixels, the result is a 3D surface, where the new axis represents the corresponding pixel in the column. \\autoref{fig:mnist_column_dist} shows this surface for columns 2 and 15 of the \\gls{MNIST} dataset, note that the digit besides the shape is there only to illustrate the position of the column, the distribution is for the entire dataset.\n\\begin{figure}[hbt]\n    \\centering\n    \\caption{Probability distribution of values in columns of \\gls{MNIST}}\n    \\begin{subfigure}{0.7\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{chapters/GANs/figures/mnist_highlight_dist_column_1.pdf}\n        \\caption{Column 2}\n    \\end{subfigure}\n    \n    \\begin{subfigure}{0.7\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{chapters/GANs/figures/mnist_highlight_dist_column_14.pdf}\n        \\caption{Column 15}\n    \\end{subfigure}\n    \n    \\fonte{From the author (2021)}\n    \\label{fig:mnist_column_dist}\n\\end{figure}\n\nThe probabilities shown in \\autoref{fig:mnist_column_dist} reinforce what was seen for the mean and variance of the images in \\autoref{fig:mnist_mean_var}, for the edges the probability is basically 100\\% that a pixel will be completely black, while for the center column it is possible to see the probabilities being split into very dark or very light pixel values, it even has two slight peaks for the black pixels representing the spaces between the digits (i.e. the holes in the number $8$) as also seen for the mean and variance case.\n\nOne may think that this would be enough to represent and generate new data, since the probability distribution for each pixel is already calculated, wouldn't all the image be described? And by sampling the distribution for each pixel, wouldn't it be possible to generate new images of digits? It is certainly possible to try, \\autoref{fig:mnist_simple_sample} show three examples of images generated by sampling from the pixel distributions.\n\\begin{figure} [hbt]\n    \\centering\n    \\caption{Images generated by sampling from the pixel distributions of \\gls{MNIST}}\n    \\includegraphics[width=0.8\\textwidth]{chapters/GANs/figures/mnist_simple_samples.pdf}\n    \\fonte{From the author (2021)}\n    \\label{fig:mnist_simple_sample}\n\\end{figure}\n\nThe sampled images surely have some similarities, but they are far from being digits. Although the probability distributions calculated are very helpful in giving some insight into the dataset, they consider the pixels as completely independent from one another. In reality, neighbouring pixels influence the values of each other, for handwritten digits a pixel will practically never be white while its neighbours are all black, instead it is much more likely that a white pixel will have some of its neighbours also being white in order to produce a stroke in the image. By averaging out all the influences of every pixel, the resulting distributions are those seen in \\autoref{fig:mnist_pixel_dist} and \\autoref{fig:mnist_column_dist}; they are valid descriptions of the data, but cannot be used to fully represent the underlying structure.\n\nThe results in \\autoref{fig:mnist_simple_sample} are similar to an effect seen in some neural network models, the data has many possible correct representations, but instead of picking a single one, the model averages out everything and ends up with a blurry mixture that badly represents the data. This can be seen for example in models that colorize black and white images \\cite{automaticColorization2016} (e.g. averaging reds, yellows, blues and all other common car colors, results in painting most cars in the same bland sepia tones), and models that aim to increase the resolution of images \\cite{ganSuperResolution2016}.\n\nOne of the advantages of \\acp{GAN} is that they are more resistant to these kinds of problems, \\autoref{fig:super_resolution} bellow shows an example where the original image was downscaled and different approaches were used to upscale the result back to its original size. Note how the \\gls{GAN} (called SRGAN) produces sharper results when compared with the algorithmic approach of bicubic upscaling and with another neural network that does not use a \\gls{GAN} architecture (SRResNet) \\textbf{--} this latter case has some understanding of the underlying structure, but it suffers to pick one good solution and instead ends up averaging all possible answers resulting in a blurry image \\cite{nipsGAN2017}.\n\\begin{figure}[hbt]\n    \\centering\n    \\caption{Comparison of different upscaling techniques (upscaling $\\times4$)}\n    \\includegraphics[width=0.9\\textwidth]{chapters/GANs/figures/superResolution.png}\n    \\fonte{Adapted from \\textcite{ganSuperResolution2016}}\n    \\label{fig:super_resolution}\n\\end{figure}\n\nIn the next section the reason why \\acp{GAN} are better at this will be explored more deeply. For now these examples show how complex the probability distributions of data can be (even knowing all the probabilities for each pixel still is not enough), given this complexity it is only possible to approximate the distributions, and generative models are a way of doing that.\n\nOne may question the purpose of generative models since the idea behind them is simply to generate more of what there is already a lot of. Indeed for cases like \\gls{MNIST} there is little value in generating a lot more digits, this problem has been solved since the 1990's \\cite{mnist1998}, and now it only serves as a learning and benchmark tool. However the use of generative models can be extended to more diverse situations, as already seen for upscaling images in \\autoref{fig:super_resolution}. \\textcite{nipsGAN2017} highlights some other uses of generative models, including: different ways to incorporate these models into Reinforcement Learning, leveraging unlabelled data as seen in semi-supervised learning, image-to-image translation, and creation of art.\n\n\n\\section{The GAN Architecture} \\label{sec:gan_architecture}\nThe \\gls{GAN} is a type of neural network that was introduced by \\textcite{gans2014} as an alternative to other generative models at the time. The main idea behind it is the competition of two different networks, a \\textit{generator} and a \\textit{discriminator}, hence the term \\textit{Adversarial} in Generative Adversarial Network. The discriminator is trained with the simple goal of detecting if any given sample belongs or not to the original dataset. The generator on the other hand is trained to make the discriminator fail, its goal is to create samples that the discriminator will consider real.\n\nA common analogy given for this process is that of the police trying to identify counterfeit money \\cite{nipsGAN2017}, the generator in this analogy is the criminals, and the discriminator is the police. The criminals will start making bad replicas that are easy for the police to learn to distinguish from real money, this will force the criminals to make better copies and in turn demand more from the police. If this keeps going forever, in the end the criminals would be so good at counterfeiting that the result would be indistinguishable from real money and the police would have no better way than to guess the answer (50\\% accuracy). This idea stems from game theory and is known as the \\textit{Nash Equilibrium} of the system, the result was rigorously proven in the original \\gls{GAN} paper \\cite{gans2014} for the case where a discriminator is trained to the optimum before each step in the generator.\n\nLeaving behind the analogy, the real implementation and training of a \\gls{GAN} consists of creating the generator ($G$) and discriminator ($D$) networks, and defining a new loss function ($J^{(G)}, J^{(D)}$) for each one. The networks can be built in any way, using fully connected, convolutional, or any other kind of layer. The discriminator input must be of the same shape as the input data and it should output a single number between 0 and 1 (a sigmoid can be used in the last layer), this number represents the probability of the input being real.\n\nThe output of the generator must also be the same shape as the input data since it will be fed to the discriminator. However, the generator input should be a $n$ dimensional vector, this vector is usually randomly sampled from a random uniform or Gaussian distribution and is called the \\textit{latent vector} ($\\bm{z}$), the $n$ dimensional vector space is called the \\textit{latent space} (\\gls{latent_space}). When describing samples from a distribution the common notation is $\\bm{z}\\sim p_{\\mathcal{Z}}$, this means that the value $\\bm{z}$ assumes the probability distribution $p_{\\mathcal{Z}}$ (e.g. random Gaussian).\n\nThe process of training the discriminator consists of sampling a batch of real data $\\bm{x}\\sim p_{data}$ and a batch of latent vectors $\\bm{z}\\sim p_{\\bm{z}}$, the values of $\\bm{z}$ are fed to the generator to produce a batch of fake data $G(\\bm{z})$; the discriminator is trained to label $\\bm{x}$ as $1$ (real) and $G(\\bm{z})$ as $0$ (fake). The generator never sees the data, it is trained using only $G(\\bm{z})$. \\autoref{fig:gan_diagram} shows a diagram of how these networks use the data for training.\n\\begin{figure}[hbt]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{chapters/GANs/figures/gan.pdf}\n    \\caption{Diagram of data use in training GANs}\n    \\label{fig:gan_diagram}\n\\end{figure}\n\nTo understand how these networks can learn, it is necessary to delve deeper into the theory and analyse how their loss function is defined. In the general sense, both the generator $G$ and discriminator $D$ are just functions of multiple variables. The generator is a map $G:\\mathcal{Z} \\to \\mathcal{X}$, where $\\mathcal{Z}$ is the latent space, defined by a probability distribution $p_{\\bm{z}}$, and \\gls{input_space} is the true data space, defined by a probability distribution $p_{data}$. The discriminator is a map $D:\\mathcal{X} \\to \\mathbb{R}$ and $0 \\leq D(\\bm{x}) \\leq 1$ (i.e. the probability of $\\bm{x}$ belonging to the real data). In most practical cases $D$ and $G$ are implemented with neural networks, parameterized by $\\bm{\\theta}^{(D)}$ and $\\bm{\\theta}^{(G)}$ respectively.\n\nThe idea behind \\acp{GAN} stems from Game Theory, where two agents compete against each other in a non-cooperative game \\cite{improvedGANS2016}, the solution for this game is called the Nash equilibrium and in this situation both players have achieved their best expected value given the state of their adversary. Training a \\gls{GAN} is a \\textit{minimax} game that aims to reach the Nash equilibrium between the generator and the discriminator, the objective of these networks is given by \\autoref{eq:gan_original_objective} \\cite{gans2014}.\n\\begin{equation} \\label{eq:gan_original_objective}\n    \\min_{G} \\max_{D} V(D,G) =\n    \\mathbb{E}_{\\bm{x}\\sim p_{data}}\\bigl\\lbrack \\log(D(\\bm{x})) \\bigr\\rbrack + \n    \\mathbb{E}_{\\bm{z}\\sim p_{z}}\\bigl\\lbrack \\log(1 - D(G(\\bm{z}))) \\bigr\\rbrack\n\\end{equation}\n\n\\autoref{eq:gan_original_objective} can be quite intimidating at first, but it is more easily understood by breaking it down into parts. First it is important to define what the symbol \\gls{expected_value} means, this symbols represents the \\textit{Expected value} of the operation between the square brackets. The expected value is a concept in statistics that means the average value that a variable will assume given some probability distribution, suppose for example rolling a 6-sided die, the expected value of the dice roll $n$ given the probability distribution $n\\sim p_{dice}$ is given by \\autoref{eq:expected_value_dice}.\n\\begin{equation} \\label{eq:expected_value_dice}\n    \\mathbb{E}_{n\\sim p_{dice}}(n) = \\sum_{n=1}^{6}{n \\cdot p_{dice}(n)} = 3.5\n\\end{equation}\n\nMore generally, the expected value $\\mathbb{E}$ of a function $f(x)$, for all values $x$ following a probability distribution $p$, is represented as $\\mathbb{E}_{x\\sim p(x)}(f(x))$ (the use of square brackets in \\autoref{eq:gan_original_objective} is not needed, it was only used to better separate the terms). This value is calculated as the sum of the values $f(x)$ multiplied by their respective probability given the distribution $p$. The general case for a finite probability distribution is represented in \\autoref{eq:expected_value_discrete}.\n\\begin{equation} \\label{eq:expected_value_discrete}\n    \\mathbb{E}_{x\\sim p}\\left( f(x) \\right) = \\sum_{i}{f(x_i) p(x_i)}\n\\end{equation}\n\nWhen dealing with continuous probability distributions the summation in \\autoref{eq:expected_value_discrete} is replaced by an integral, but in the context of machine learning most problems fall into the discrete category and the expected value is commonly approximated by calculating it from a mini-batch of data instead of the whole dataset.\n\nWith this understanding of expected value, it is possible to come back to the objective function in \\autoref{eq:gan_original_objective}. Note that this is a minimax game, both the generator and discriminator are dependent on the same value $V(D,G)$, the discriminator tries to maximize the value, while the generator tries to minimize it. So the objective can be broken down into two loss functions $J^{(D)}$ and $J^{(G)}$, where each network is trying to minimize their own loss.\n\nThe objective of the discriminator is to maximize $V(D,G)$, this can be re-framed as a minimization problem over a loss function $J^{(D)} = -V(D,G)$ as mentioned by \\textcite{nipsGAN2017}. So the loss for the discriminator is given by:\n\\begin{equation} \\label{eq:discriminator_loss}\n    J^{(D)}(\\bm{\\theta}^{(D)},\\bm{\\theta}^{(G)}) = \n    -\\mathbb{E}_{\\bm{x}\\sim p_{data}}\\left\\lbrack \\log(D(\\bm{x})) \\right\\rbrack\n    -\\mathbb{E}_{\\bm{z}\\sim p_{z}}\\left\\lbrack \\log(1 - D(G(\\bm{z}))) \\right\\rbrack\n\\end{equation}\n\nObserve what \\autoref{eq:discriminator_loss} is saying, for the first term, $-\\log(D(\\bm{x}))$ will tend to infinity as $D(\\bm{x}) \\to 0$, the minimum value is $0$ for when $D(\\bm{x})$ is exactly $1$; in other words, this term will be minimized when the discriminator correctly assigns the real data $\\bm{x}$ as being $100\\%$ real. The second term, $\\log(1 - D(G(\\bm{z})))$ will be minimized in the opposite way, when $D(G(\\bm{z}))$ is equal to $0$; this means that this term encourages the discriminator to correctly assign the fake data as being fake.\n\nThe loss for the generator in the minimax game is simply the negative of the loss of the discriminator loss, $J^{(G)} = -J^{(D)} = V(D,G)$. One thing to note in the loss for the generator is that the first term of $V(D,G)$, as seen in \\autoref{eq:gan_original_objective}, only depends on $D$, so it can be ignored since the generator can't affect the parameters $\\bm{\\theta}^{(D)}$. Then the loss for the generator can be written as the equivalent expression shown in \\autoref{eq:generator_loss}.\n\\begin{equation} \\label{eq:generator_loss}\n    J^{(G)}(\\bm{\\theta}^{(D)},\\bm{\\theta}^{(G)}) = \n    \\mathbb{E}_{\\bm{z}\\sim p_{z}}\\bigl\\lbrack \\log(1 - D(G(\\bm{z}))) \\bigr\\rbrack\n\\end{equation}\n\nIn this case, $\\log(1 - D(G(\\bm{z})))$ will be minimized when $D(G(\\bm{z}))$ is equal to 1; in other words, the loss of the generator is minimized when the discriminator incorrectly classifies the fake data as being real, the generator is encouraged to reduce the discriminator accuracy.\n\nOne may wonder how can this game converge to producing a $p_{model}$ similar to $p_{data}$. To understand that, first it is necessary to understand how the difference between two probability distributions is measured. Much like distances between two points in space, that can be measured in different ways to produce different properties in that space (e.g. $\\ell_2$ norm for the familiar Euclidean Space), there are multiple definitions of distance between probability distributions. Some definitions produce better properties that can be leveraged to solve particular problems, in the original \\gls{GAN} proposal, \\textcite{gans2014} proved that the objective given by \\autoref{eq:gan_original_objective} is equivalent to reducing the distance called the Jensen-Shannon (JS) divergence.\n\nThe JS divergence is written in terms of another function, the Kullback-Leibler (KL) divergence. The use of the KL divergence can be found in many areas of machine learning, not just generative models, this is a very powerful metric that is closely tied to the concepts of information entropy and cross-entropy. The KL divergence between two probability distributions $p$ and $q$ is given by \\autoref{eq:kl_divergence} \\cite[p. 71-72]{deepLearningBook2016}.\n\\begin{equation} \\label{eq:kl_divergence}\n    D_{KL}(p \\;\\|\\; q) =\n    \\mathbb{E}_{x\\sim p}\\left( \\log\\frac{P(x)}{Q(x)} \\right) = \n    \\sum_{x}{P(x)\\left( \\log\\frac{P(x)}{Q(x)} \\right)}\n\\end{equation}\n\nOne common characteristic between many metrics of distance for probability distributions is that they are not symmetric, that means that the distance between $p$ and $q$ is not the same as the distance between $q$ and $p$, this asymmetry is also present in the KL divergence as can be seen in \\autoref{eq:kl_divergence} \\textbf{--} it is for this reason that the name divergence is used instead of distance. Contrary to that, the JS divergence, although being called a divergence, is actually symmetric; it is defined in terms of the KL divergence as shown in \\autoref{eq:js_divergence}.\n\\begin{equation} \\label{eq:js_divergence}\n    D_{JS}(p \\;\\|\\; q) = \\frac{1}{2}D_{KL}(p \\;\\|\\; m) + \\frac{1}{2}D_{KL}(q \\;\\|\\; m) \\qquad \\text{where} \\qquad\n    m = \\frac{p + q}{2}\n\\end{equation}\n\nFor both the KL and JS divergences, a value of 0 represents that the distributions $p$ and $q$ are the same, and minimizing these divergences brings the two distributions closer. As mentioned before, \\textcite{gans2014} proved that the \\gls{GAN} objective function given in \\autoref{eq:gan_original_objective} minimizes the JS divergence and in turn should converge $p_{model}$ to $p_{data}$. The authors also proved that this convergence point equates to the optimal discriminator being unable to differentiate between real and fake data, having the same accuracy as a random guess ($50\\%$).\n\nThe details of the proof are out of the scope of this document, the important information to take is how the networks reproduce the data distribution (by minimaxing the objective function) and why this works (equivalent to reducing the JS divergence). One important detail is that the proof relied on the fact that the updates to $G$ and $D$ were made directly in function space, the same argument does not apply to the situations seen in practice, where the updates to the functions are made on parameter space (i.e. $\\bm{\\theta^{(G)}}$, $\\bm{\\theta^{(D)}}$) \\cite{nipsGAN2017}. This is not a problem in many situations, but there are multiple situations where this approach has been shown to diverge, or to cycle around the equilibrium without convergence; some examples of this are shown by \\textcite{improvedGANS2016}, \\textcite{wasserstein2017}, \\textcite{wgan-gp2017} and \\textcite{which_GAN_converge2018}.\n\nOne problem of minimizing the loss function of the generator $J^{(G)}$ as seen in \\autoref{eq:generator_loss}, is that, in the start of training when the generator is still bad at producing results, the discriminator can become too good and will recognize the fake data with very high certainty; this confidence will saturate the discriminator output and give vanishing gradients for the generator updates, making training extremely slow. Given this problem, the original paper \\cite{gans2014} proposed a change to the loss of the generator; instead of minimizing the probability of the discriminator being correct, the generator should maximize the probability of the discriminator making a mistake. This equates to minimizing the loss function shown in \\autoref{eq:gan_logD_trick}.\n\\begin{equation} \\label{eq:gan_logD_trick}\n    J^{(G)} = -\\mathbb{E}_{z\\sim p_{z}}(\\log D(G(\\bm{z})))\n\\end{equation}\n\nIt is important to mention that this new loss function is an empirical recommendation, the theoretical arguments of convergence do not apply when training the generator with this function \\cite{gans2014}. However, this does not seem to be a big problem in practical situations and is usually the preferred loss function between the two.\n\nAnother point worth mentioning is that for the theoretical argument of convergence, the generator updates would be made in relation with an optimal discriminator, this would mean that for each generator step, there should be multiple updates in the discriminator in order to have it be optimal for the current generator. At the beginning this was implemented as a new hyperparameter that would define how many updates to the discriminator would be made before updating the generator \\cite{gans2014}, but later \\textcite{principled_gan_methods2017} have shown that the optimal discriminator has gradient $0$ almost everywhere, making it impossible to train \\acp{GAN} through gradient descent. This hyperparameter has since fallen out of fashion and usually \\acp{GAN} are trained one step for each network, the original inventor of \\acp{GAN} would also say: ``Many authors recommend running more steps of one player than the other, but as of late 2016, the author’s opinion is that the protocol that works the best in practice is simultaneous gradient descent, with one step for each player.'' \\cite{nipsGAN2017}.\n\nOne may note how often the theory either fails to apply to practical cases or is replaced by empirical solutions that work better. This is very much the case not only for \\acp{GAN}, but for many other areas of machine learning, ``[...] even though these [Artificial Neural Networks] are very useful tools based on well-known mathematical methods, we actually understand surprisingly little of why certain models work and others don’t'' \\cite{visualizingFeatures2015}. In most \\gls{GAN} methods introduced with a theoretical basis behind them, it is very common to see assumptions being made in order for the theorems proposed to apply \\textbf{--} see for example the original \\gls{GAN} paper \\cite{gans2014}, or \\cite{wasserstein2017} and \\cite{TTUR_FID2017}.\n\n\\subsection{Mode Collapse}\nOne of the main problems faced when training \\acp{GAN} is when the generator learns to map many, or all possible latent vectors in $\\mathcal{Z}$ to the same point $\\bm{x}$ in $\\mathcal{X}$, this is called a mode collapse, also known as the ``Helvetica Scenario''. \\textcite{nipsGAN2017} says that complete mode collapse is the most common form of harmful non-convergence in GANs and that, although complete collapse is rare, partial collapse is a frequent occurrence.\n\nAs an example of mode collapse, consider the case of training a \\gls{GAN} to generate the handwritten digits of \\gls{MNIST}, the generator collapsing could be that it only produces the number $6$ for all latent vectors, it may produce convincing results, but it can't represent the full distribution. This in theory could be useful, since new generators could be trained for each separate mode of the data (e.g. one generator for each digit). However this is usually not desirable, still considering the \\gls{MNIST} example, after many iterations the discriminator would learn to be more suspicious of the number $6$ and the generator would then try to find a next mode to collapse (e.g. the number $8$); thus, both networks would be forever stuck changing modes and never reaching convergence \\cite{improvedGANS2016}.\n\\begin{figure}[hbt]\n    \\centering\n    \\caption{Mode collapse on \\gls{MNIST}}\n    \\includegraphics[width=0.5\\textwidth]{chapters/GANs/figures/mode-collapse.png}\n    \\fonte{From the author (2021)}\n    \\label{fig:mode_collapse_mnist}\n\\end{figure}\n\n\\autoref{fig:mode_collapse_mnist} shows an example of extreme mode collapse that can happen when training \\acp{GAN}, in this particular case the generator is a simple neural network of fully connected layers, having a single hidden layer, and being trained on the \\gls{MNIST} dataset\\footnote{\n    When producing this image, the networks were trained four different times with different sets of hyperparameters, and in all cases the mode collapse happened on the number 1. This probably indicates that this is the easiest pattern for the generator to learn, but most importantly, it gives another counterargument on why it is usually not desirable to train several networks one for each mode, since it is difficult to produce the correct mode.\n}.\n\n\n\\section{Proposed improvements}\nSince their introduction in 2014, \\acp{GAN} have become very popular for their capabilities but also for their difficult of being trained \\cite{wgan-gp2017} and evaluated \\cite{principled_gan_methods2017}. Many improvements have been proposed, of note between them are changes that aim to make training more stable and faster, reduce the effect of mode collapse, produce better results, scale the results to higher resolutions (in case of images), make the latent space have nicer properties, introduce new metrics of quality, and condition the generator on some know input in order to guide the generation process.\n\nThis section will explore some of the more popular methods, this is by no means an exhaustive list, the goal is only to introduce the techniques that were part of the empirical experiments in this document (see \\autoref{cha:experiments}).\n\n\\subsection{DCGAN}\n\\glsreset{DCGAN}\nThe original \\gls{GAN} suffered from training stability and difficulty of scaling to larger resolutions (in the case of images), \\textcite{dcgan2015} were able to compile different popular techniques at the time to produce an architecture for the generator and discriminator that would produce better results and be more stable. They called this type of model a \\gls{DCGAN} since they abandoned the use of fully connected and pooling layers in favor of using only convolutional and transposed convolutional layers.\n\nDifferent from the other proposed improvements that will be mentioned later, the \\gls{DCGAN} did not introduce any new way of training or using the data differently, it was simply a clever style of architecture that would produce better results. But the results were indeed very good, so much so that by 2016 most \\gls{GAN} architectures were at least loosely based on the \\gls{DCGAN} \\cite{nipsGAN2017}.\n\nThe overall architecture can be summarized as follows \\cite{dcgan2015}:\n\\begin{itemize}\n    \\item No fully connected hidden layers and no pooling layers overall, only uses convolution or transposed convolutions to change the dimensions of the input.\n    \\item Use of Batch Normalization in all layers of both networks, except the input layer of the discriminator and output layer of the generator.\n    \\item Use LeakyReLU for all layers of the discriminator and ReLU for all layers of the generator, use only \\gls{tanh} in the last layer of the generator in order to produce the normalized images (i.e. interval $[-1, 1]$).\n    \\item Use of the Adam optimizer\n\\end{itemize}\n\n\\textcite{dcgan2015} were able to have stable training with the \\gls{DCGAN} on a range of different datasets, the architecture was also robust enough to allow for building deeper models and generating higher resolutions. They also showed a surprising property by applying arithmetic on the latent space $\\mathcal{Z}$, by taking some random latent vectors that would produce images of mans with glasses and averaging them, the result would be an average vector $\\bm{z}(\\text{``man with glasses''})$ that would represent this type of image; by also calculating $\\bm{z}(\\text{``man without glasses''})$ and $\\bm{z}(\\text{``woman without glasses''})$, and combining the vectors in the following way $\\bm{z}(\\text{``man with glasses''})$ - $\\bm{z}(\\text{``man without glasses''})$ + $\\bm{z}(\\text{``woman without glasses''})$, the result would be a latent vector that when fed to the generator would produce an image of a woman with glasses.\n\n\\subsection{Conditional GAN} \\label{sub:cgan}\n\\glsreset{CGAN}\nOne of the main advantages of \\acp{GAN} is that they can be trained with unlabeled data, this allows for learning with millions of real samples, such a volume of data is almost always very expensive and time consuming to have labelled. However, one of the earliest proposal for improvement was made by \\textcite{conditionalGAN2014}, they argue about the benefits of leveraging the labels when training the \\acp{GAN}.\n\nThis approach is conceptually very simple, when training the original \\gls{GAN} the generator is fed some noise vector from $\\mathcal{Z}$ and produces a fake sample $G(\\bm{z})$, the discriminator then takes this and another real sample $\\bm{x}$ to produce $D(G(\\bm{z}))$ and $D(\\bm{x})$. For a \\gls{CGAN}, everything is the same except for the fact that both the generator and discriminator are also given a label $\\bm{y}$ for the data generated; this means that the generator will produce $G(\\bm{z} | \\bm{y})$ and the output of the discriminator will be $D(G(\\bm{z} | \\bm{y}))$ and $D(\\bm{x | \\bm{y}})$.\n\nThe logic behind this approach is that it encourages the generator to learn how to distinguish the data as people do, \\textcite{nipsGAN2017} comments that this may help the generator in optimizing the solution, but it also could be that the results produced are not necessarily closer to the real distribution, but instead that they favor characteristics that appeal to the human vision.\n\nOne advantage of this model is that it allows for more fine control over the result, in the unlabelled \\gls{GAN} the results are random since they come from a sample of the latent space distribution; with \\gls{CGAN} the label input can be used to set the class of the output, while the latent vector can be sampled multiple times to produce variation.\n\nA question about the implementation of \\acp{CGAN} is: how the label can be incorporated into the latent vector and the input image? In the original paper, \\textcite{conditionalGAN2014} had the labels be represented as one-hot encoded vectors. For the generator the input $\\bm{z}$ and the label vector $\\bm{y}$ would be mapped into two layers of 200 and 1000 neurons respectively, these layers would then be combined into another layer that would have the label information imbued. A similar process would happen for the discriminator, it would map both the input and label into two one-dimensional layers and combine them into a new layer.\n\nThis way of combining the label with the data has mostly been replaced since then. A better way of doing that is to use embedding layers to represent the class label instead of one hot vectors, this layer should be mapped with a dense layer to a higher dimension and be reshaped into a channel of the input volume to the corresponding network (i.e. generator or discriminator). \\autoref{fig:cgan} shows a diagram of how the label is incorporated into the channels using embedding layers. \n\\begin{figure}\n    \\centering\n    \\caption{Generator and discriminator networks for \\gls{CGAN}}\n    \\includegraphics[width=0.8\\textwidth]{chapters/GANs/figures/cgan.pdf}\n    \\fonte{From the author (2021)}\n    \\label{fig:cgan}\n\\end{figure}\n\n\\subsection{Wasserstein GAN} \\label{sub:wgan}\nOne of the problems when training \\acp{GAN} by trying to minimize the Jensen-Shannon divergence is that this metric does not produce the best gradients for the generator to learn, recall that \\textcite{principled_gan_methods2017} have showed that for the optimal discriminator the gradient is equal to $0$ almost everywhere. The authors also explain that the Kullbak-Leibler divergence is also problematic since it can produce very high or very low values in different areas of the distributions, making training very difficult.\n\n\\textcite{wasserstein2017} introduce a simple example of a uniform probability for all points in the line segment $x=0$, $0 \\leq y \\leq 1$ on the $xy$ plane. They showed that any modeled distribution $x=\\theta$ and $0 \\leq y \\leq 1$, that is parameterized by a single value $\\theta$, will not converge when training with the JS, KL, and reverse KL divergences, or with the total variation distance\\footnote{\n    The details are out of the scope of this document, but the mathematical inclined reader is encouraged to check the original paper.\n}. They propose the \\gls{EM} or Wasserstein distance as an alternative to these other metrics and showed that in the proposed example, this distance produces a continuous value that provides usable gradients everywhere.\n\nThe motivation behind this choice of function is heavily inspired by theory. For this document most of the details will be omitted, and only the most relevant information will be quickly cited in order to reach the conclusions and information about the practical implementation. The \\gls{EM} distance between two probability distributions $p$ and $q$ is defined by \\autoref{eq:em_distance_scary}, ``where $\\Sigma(p, q)$ denotes the set of all joint distributions $\\gamma(x, y)$ whose marginals are respectively $p$ and $q$'' \\cite{wasserstein2017}.\n\\begin{equation} \\label{eq:em_distance_scary}\n    W(p, q) = \\inf_{\\gamma \\in \\Sigma(p, q)} \\mathbb{E}_{(x,y)\\sim\\gamma}\\left\\| x - y \\right\\|  \n\\end{equation}\n\nIn this equation the \\textit{infimum} ($\\inf$) can be interpreted as the greatest lower bound, so the \\gls{EM} distance is given by the $\\gamma$ distribution that satisfies the greatest lower bound condition for the corresponding expected value. There is an intuitive interpretation of this distance in terms of real world mechanics, consider that $p$ and $q$ describe two mass distributions with equal total mass, then the Wasserstein distance is equivalent to the minimum amount of energy necessary to move the masses around in order to transform the distribution $p$ into $q$, for this reason that it is also called the Earth Mover distance.\n\nCalculating this distance in this form is extremely difficult, but by using the Kantorovich-Rubinstein duality the original authors rewrote the distance as shown in \\autoref{eq:em_distance} \\cite{wasserstein2017}.\n\\begin{equation} \\label{eq:em_distance}\n    W(p, q) = \\sup_{\\|f\\|_{L} \\: \\leq \\: 1}{\n        \\mathbb{E}_{x\\sim p}f(x) - \\mathbb{E}_{x\\sim q}f(x)\n    }\n\\end{equation}\n\nThe \\textit{supremum} ($\\sup$) in this equation is also interpreted as the least upper bound and the restriction $\\|f\\|_{L} \\: \\leq \\: 1$ indicates that $f$ must be 1-Lipschitz continuous. A function $f$ is said to be K-Lipschitz continuous for a constant K when the following inequality holds \\cite{lipschitz20XX}.\n\\begin{equation}\n    | f(x) - f(y) | \\leq K | x - y |  \\qquad \\forall x,y\n\\end{equation}\n\nThe inequality above can be interpreted as sliding a cone with inclination $K$ on every point of $f$ and if all the values of the function are outside the cone then the function is K-Lipschitz continuous.\n\n\\textcite{wasserstein2017} note that the 1-Lipschitz continuity can be replaced by a K-Lipschitz restriction while still maintaining the correct EM distance up to a multiplicative constant $K \\cdot W(p,q)$. They also consider solving an easier problem by using a parameterized function $f_{\\bm{\\theta}}$, with $\\bm{\\theta}$ belonging to the parameter space $\\Theta$, and replacing the $\\sup$ with a $\\max$. The simplified problem is given by \\autoref{eq:em_distance_simpler}.\n\\begin{equation} \\label{eq:em_distance_simpler}\n    \\max_{\\bm{\\theta} \\in \\Theta} {\n        \\mathbb{E}_{x\\sim p}f_{\\bm{\\theta}}(x) - \\mathbb{E}_{x\\sim q}f_{\\bm{\\theta}}(x)\n    }\n\\end{equation}\n\nThis simplified problem relies on the assumption that the supremum can be found for some set of parameters $\\bm{\\theta}$, but if this is true, then the \\gls{EM} distance can be calculated (up to a multiplicative factor) by implementing $f$ as a neural network and using gradient ascent to maximize the value in \\autoref{eq:em_distance_simpler} \\cite{wasserstein2017}.\n\nTo better understand how this works, the problem in \\autoref{eq:em_distance_simpler} can be written in terms of $p_{data}$, $p_{model}$ and a generator $G$ as shown in \\autoref{eq:em_distance_critic}.\n\\begin{align} \\label{eq:em_distance_critic}\n    & \\max_{\\bm{\\theta} \\in \\Theta} {\n        \\mathbb{E}_{\\bm{x}\\sim p_{data}}f_{\\bm{\\theta}}(\\bm{x}) -\n        \\mathbb{E}_{\\bm{x}\\sim p_{model}}f_{\\bm{\\theta}}(\\bm{x})\n    } = \\nonumber \\\\[10pt]\n    & \\max_{\\bm{\\theta} \\in \\Theta} {\n        \\mathbb{E}_{\\bm{x}\\sim p_{data}}f_{\\bm{\\theta}}(\\bm{x}) -\n        \\mathbb{E}_{\\bm{z}\\sim p_{\\bm{z}}}f_{\\bm{\\theta}}(G(\\bm{z}))\n    }\n\\end{align}\n\nOne may wonder where is the discriminator in all of this, the astute reader may have already realized that the discriminator is the function $f$. For the \\gls{WGAN} however, the output of this function is not a probability but instead it can be any number; the interpretation is that the discriminator is scoring the data that it sees, so it is more commonly referred to as the \\textit{critic}.\n\nThe goal of the critic is to approximate the \\gls{EM} distance between the data and model distributions $W(p_{data}, p_{model})$, and it does that by maximizing the value in \\autoref{eq:em_distance_critic}. How can the generator use this to learn a good probability distribution?\n\nSince the goal of the generator is to minimize the distance between the real and modeled distributions, its objective should be to minimize the value produced by the critic. \\textcite{wasserstein2017} proved (theorem 3 of paper) that the gradient of the \\gls{EM} distance for a generator parameterized by $\\bm{\\theta}$ is given by \\autoref{eq:wgan_generator_grad}.\n\\begin{equation} \\label{eq:wgan_generator_grad}\n    \\nabla_{\\bm{\\theta}} W(p_{data}, p_{model}) = -\\mathbb{E}_{\\bm{z}\\sim p_{\\bm{z}}}{\n        \\left\\lbrack \\nabla_{\\bm{\\theta}}f(G(\\bm{z})) \\right\\rbrack\n    }\n\\end{equation}\n\nAlthough the theory is very heavy, the implementations changes are rather simple. The loss for the critic will be just the mean of the fake outputs $f(G(\\bm{z}))$ minus the mean of the real outputs $f(\\bm{x})$; in simpler terms, by minimizing this loss the critic is trying to give high scores for the real data and low scores for fake data. On the other hand, the loss for the generator is simply the negative mean of the fake outputs $f(G(\\bm{z}))$, by minimizing this loss the generator is trying to maximize the score that the critic gives to the data that it produces.\n\nOne detail that was left to the side until now is the condition that the critic must be a K-Lipschitz continuous function, this is essential in order for the distance approximation to be valid and it is something that is not restricted by normal implementations of neural networks. The solution proposed by the authors was \\textit{weight clipping}, that is, limiting the parameters of the critic to a interval $\\left\\lbrack-c, c\\right\\rbrack$ where $c$ is a constant hyperparameter. This is rather an unrefined solution, even the authors recognized that ``weight clipping is a clearly terrible way to enforce a Lipschitz constraint'' \\cite{wasserstein2017}, but it was their best solution at the time and they encouraged further research to find a better way; and this improvement came in the form of a gradient penalty, in the next section this method will be explored further.\n\n\\subsection{WGAN with Gradient Penalty} \\label{sub:wgan_gp}\nOne drawback about the \\gls{WGAN} method is the hard restriction on the critic's parameters by way of weight clipping, this not only introduces a new hyperparameter $c$ that determines the clipping interval, but also leads to optimization difficulties as shown by \\textcite{wgan-gp2017}; they demonstrated that when training, the gradients can either explode or vanish if $c$ was not carefully chosen, and that the critic is biased to much simpler functions.\n\n\\textcite{wgan-gp2017} proposed a new method to restrict the critic without needing to resort to hard clipping of the parameters. They base their technique by showing that the 1-Lipschitz function $f$ on \\autoref{eq:em_distance} has a gradient of norm equal to $1$ almost everywhere under the distributions $p$ and $q$. Using this information, the loss function for the critic can be regularized to penalize for gradients that have norm far from $1$, thus the name \\gls{WGAN-GP}. \\autoref{eq:wgan_gp_loss} shows the regularized loss for the critic.\n\\begin{equation} \\label{eq:wgan_gp_loss}\n    J^{(C)} = \\LaTeXunderbrace{\\strut\n        \\mathbb{E}_{\\bm{z}\\sim p_{\\bm{z}}} {\\bigl\\lbrack f(G(\\bm{z})) \\bigr\\rbrack} - \n        \\mathbb{E}_{\\bm{x}\\sim p_{\\bm{data}}} {\\bigl\\lbrack f(\\bm{x}) \\bigr\\rbrack}\n    }_{\\text{WGAN critic loss}} +\n    \\LaTeXunderbrace{\n        \\lambda\\:\\mathbb{E}_{\\hat{\\bm{x}}\\sim p_{\\bm{x}}} {\n            \\left\\lbrack (\\| \\nabla_{\\hat{\\bm{x}}}f(\\hat{\\bm{x}})\\|_{2} - 1)^{2} \\right\\rbrack\n        }\n    }_{\\text{Gradient Penalty}}\n\\end{equation}\n\nFor this loss function, $\\lambda$ is a new hyperparameter that defines the strength of the penalty (the original paper suggested that $\\lambda = 10$ was a good value that applied to many situations), the probability distribution $p_{\\bm{x}}$ is a uniform probability in the line between one real sample $\\bm{x}$ and one fake sample $G(\\bm{z})$, and $\\hat{\\bm{x}}$ is a sample from this distribution. What this means is that the gradient penalty is calculated by taking, for each pair of real and fake samples, a random point in the linear interpolation between them, and calculating the gradient of the critic with respect to this interpolation. Since the penalty is calculated per individual pairs, the critic should not use batch normalization since that would interfere with the penalty value, \\textcite{wgan-gp2017} recommend using layer normalization as an alternative.\n\n\n\\subsection{Other techniques}\nThe experiments in this document also tried some other methods that will be described more briefly here.\n\n% \\subsubsection{Style-based GAN}\n% This is the technique used in the StyleGan \\cite{styleGAN2018} architecture, it proposes that the latent space $\\mathcal{Z}$ be mapped to another space $\\mathcal{W}$ using another neural network, and adding the mapped vector $w \\in \\mathcal{W}$ to the generator in a style-based fashion using only their mean and variances. This type of generator produced very high quality results in a variety of different datasets and the details of its implementation are much more elaborate, but the simplified model built in the experiments was not fully explored and failed to produce good results; so for the sake of brevity, only this short explanation will be given.\n\n\\subsubsection{One Sided Label Smoothing}\nAdding noise to labels is an old technique that has been proved useful in different areas of machine learning, in the context of \\acp{GAN} it would change the objective of the discriminator from assigning the values $0$ for fake data and $1$ for real data, to a smoothed version like $0.1$ and $0.9$ for fake and real respectively.\n\nHowever, \\textcite{improvedGANS2016} have shown that smoothing the fake labels would cause problems for convergence in some areas of the probability distribution, so they recommending smoothing only the real label.\n\n\\subsubsection{Upsampling Methods}\nThe basic building block for upscaling the image in the generator for the \\gls{DCGAN} is the transposed convolution layer, however, \\textcite{deconvolutionArtifacts2016} have shown that this type of upsampling causes checkerboard artifacts in the images and recommend instead using a normal bilinear or nearest neighbour upsampling, followed by a normal convolutional layer. The experiments in this document tried comparing these three types of upsampling for different \\acp{GAN} and datasets.\n\n\n\\section{Evaluating GANs} \\label{sec:measure_gans}\n\\acp{GAN} are not only difficult to train, but also to evaluate. Consider for example two different \\acp{GAN} that produce the handwritten digits of \\gls{MNIST} and the desire is to compare them to see which one produces the more realistic or more varied results, how would one achieve such task?\n\nComparing two classifiers is relatively easy, the most natural way is just to observe their accuracy in the test dataset and see which one is higher. For \\acp{GAN} on the other hand this is not so simple, remember that \\textcite{gans2014} proved that the optimal discriminator would be unable to distinguish between real and fake data, and thus would have an accuracy of 50\\%. But simply aiming for this value of accuracy would not work, since a discriminator that tosses a coin to decide would in fact produce the same value.\n\nFor many image generation applications, the most important aspect is to produce samples that are appealing to the human eye, so ultimately, a qualitative analysis made by people is very important. However, this is not a reliable measure of quality, \\textcite{improvedGANS2016} have observed that workers on Amazon Mechanical Turk would produce varied results and the simple act of giving feedback would influence their accuracy; the authors also noted that they could easily distinguish real from the fake data produced by their models trained on the \\gls{CIFAR}-10 dataset (over $95\\%$ accuracy), while the workers would make mistakes much more frequently ($78.7\\%$ accuracy).\n\nAnother problem of human evaluation is the fact that it is not so easy for a person to detect the variation of the model, the generator might produce very good samples while in a mode collapse state. The challenge is to evaluate not only the quality of individual samples, but also the variation over many samples. This is very challenging problem that still is not completely solved, being an active area of research, with new metrics still being proposed \\textbf{--} see for example \\cite{new_gan_metric_1} and \\cite{new_gan_metric_2}. One yet unmentioned advantage of the \\gls{WGAN} loss is that it can also be used to evaluate the models, the value of the \\gls{EM} distance has been shown to correlate with the quality of the image generated \\cite{wasserstein2017}.\n\nCurrently, two of the most popular metrics are the \\gls{IS} and \\gls{FID}, while the \\gls{IS} has largely been replaced by \\gls{FID}, both show good correlation with the image quality and also with image variety. For this document these were the two metrics used to evaluate the models in the experiments.\n\n\\subsection{Inception Score}\nJust like a classifier can be used to predict the class of the test dataset, it can also be used to predict artificially generated images. If the classifier has a good accuracy, then it would make sense for it to be able to classify generated data with high confidence, given that this data is similar to the real data. This is the idea behind the \\gls{IS}, bad samples would make a classifier be unsure of the right class, while good samples would produce very confident classifications.\n\nIn more defined terms, the value of how confident a classifier is that some input $\\bm{x}$ belongs to a class $y$ is the conditional probability of $p(y | \\bm{x})$, the idea is to calculate this over all labels $y$, and this value ideally should have a clear spike at some $y$, representing a high confidence classification\\footnote{\n    It is out of the scope of this document, but for those aware of the concept, the desired distribution should have low entropy\n} \\cite{improvedGANS2016}. By just measuring this value it would be possible to have an idea of the quality of the generated samples by the confidence of the classifier, but this alone would not be enough to detect the variety of the model, it is desired that the generator create samples in all classes, without giving preference to any particular label. This is equivalent of saying that $p(y)$ should be as uniform as possible\\footnote{\n    Equivalent to high entropy\n} \\cite{coursera_IS}.\n\nBy combining these two ideas, the \\gls{IS} is calculated from the KL divergence between these two probability distributions as shown in \\autoref{eq:inception_score}, note that the exponential operator is used only to make the numbers easier to interpret \\cite{improvedGANS2016}.\n\\begin{equation} \\label{eq:inception_score}\n    \\IncScore = \\exp\\bigl({\\mathbb{E}_{\\bm{x}\\sim p_{model}}{\n        \\bigl\\lbrack D_{KL}(p(y | \\bm{x}) \\;\\|\\; p(y)) \\bigr\\rbrack\n    }}\\bigr)\n\\end{equation}\n\nSince the desired behaviour is for $p(y | \\bm{x})$ to be very well defined at a single point while $p(y)$ should be completely uniform, then the KL divergence between those two should be as high as possible, this means that for the \\gls{IS}, higher values means better results. To calculate the expected value expected value it is necessary to average the results over many generated samples in order to have a close approximation of the true value, the original authors used $50,000$ in their experiments \\cite{improvedGANS2016}.\n\nThe remaining detail is what classifier to use when calculating the \\gls{IS}, this metric uses the Inception v3 model \\cite{inceptionV3_2015}, hence the name Inception Score. The Inception model is a very powerful model trained on 1000 classes of the ImageNet dataset of natural images, so it is very sensible as the classifier of choice. There are however some limitations, since the model was trained on ImageNet it may not offer good classification for datasets that are too different from natural images (like \\gls{MNIST}) or from the 1000 classes learned.\n\nOther shortcomings of the \\gls{IS} are that it could give very high scores for models that generate only a single good image for each category (a form of mode collapse) and that it also completely ignores the training dataset (the very thing that the generator is trying to model) \\cite{coursera_IS}.\n\n\n\\subsection{Fréchet Inception Distance}\nThe \\gls{FID} metric was introduce as an improvement over the previous \\gls{IS}, it was shown to correlate well with human perception and be more consistent than the \\gls{IS} for different types of disturbances to the images (i.e. the \\gls{FID} consistently gets worse as images get more disturbed, while the \\gls{IS} fluctuates) \\cite{TTUR_FID2017}.\n\nThe Inception v3 model is also used to calculate this metric, but instead of using the class predictions from the output layer like the \\gls{IS}, the \\gls{FID} uses features from the last global pooling layer. To understand why this is a useful choice it is important to know how computer vision models see the data. The idea behind deep learning models is that each layer of the network can capture a different level of abstraction in the data, for example, the layers start detecting edges, followed then by shapes, textures, and finally high level patterns. The Inception v3 model takes as input $299\\times299\\times3$ images and reduces them to a $1024$ dimensional vector of features, this is a compression of about $262$ times the original size; with such aggressive reduction it is imperative for the model to learn only the most relevant features, these are able to describe the data in a much more abstract level without being affected by unimportant things like small random noise.\n\nFor a well behaved model like Inception v3, if two images share similar feature vectors, they are probably very similar in an abstract sense as well. Two images of cats will have similar features, even more so if the cats have similar colors, pose or fur. By using the feature layer to measure the \\gls{FID} it is possible to evaluate how well the model represents the structure of the data, and not punish it if it cannot reproduce the exact images of the training set.\n\nThe \\gls{FID} uses another metric for the difference between probability distributions called the Fréchet Distance, the difference is calculated between the distributions of the feature vectors for the real and fake images. For practical purposes only the mean and covariance are considered, so it is assumed that the distributions follow a multidimensional Gaussian, making the \\gls{FID} metric be calculated as shown in \\autoref{eq:fid} \\cite{TTUR_FID2017}.\n\\begin{equation} \\label{eq:fid}\n    \\FID = \\|\\bm{\\mu}_{data} - \\bm{\\mu}_{model}\\|_{2}^{2} + \n    \\Tr\\bigl(\\bm{V}_{data} + \\bm{V}_{model} - 2(\\bm{V}_{data} \\cdot \\bm{V}_{model})^{\\frac{1}{2}}\\bigr)\n\\end{equation}\n\nIn this equation $\\bm{\\mu}$ and $\\bm{V}$ represent the mean vector and the covariance matrix for the feature vectors, calculated for a big enough sample of the real and fake data (i.e. $50,000$). The $\\Tr$ operator calculates the trace of the matrix (i.e. the sum of all the elements of the main diagonal), and the matrix square root inside the trace is not calculated element-wise, it is instead the actual square root of the entire matrix. Since this metric is a distance between real and fake data and it is desirable for this distance to be small, then for the \\gls{FID}, lower values means better results.\n\nOne of the main advantages of the \\gls{FID} is that it considers the training dataset in the evaluation, so a better model would be the one who can better replicate the structure of the data used to learn. This metric is considered better than the \\gls{IS} and has generally replaced it \\cite{coursera_IS}, however it still suffer from some of the same shortcomings, notably the fact that it only works for evaluating \\acp{GAN} in the image domain and that it still relies on the specifics of the Inception v3 model.\n\n\\subsection{Using other classifiers}\nAlthough the original \\gls{IS} and \\gls{FID} rely on the Inception v3 model, the same metrics could be calculated using another classifier trained specifically for the data used in training the \\gls{GAN} model \\textbf{--} for this document this will be called the \\gls{CS} and \\gls{FCD} respectively \\textbf{--} this can produce more accurate results for datasets like \\gls{MNIST} that contain very different images from the ones in ImageNet used to train Inception v3.\n\nOne disadvantage of this approach is that it is not useful when comparing models evaluated with different classifiers, however it is always possible to fall back to the original \\gls{IS} and \\gls{FID} as a common ground for comparison, keeping in mind that these metrics may not be very accurate anyway depending on the dataset.\n\nFor the experiments in this document it was decided to train individual classifiers for each dataset in order to produce more accurate metrics, the comparisons with other published models was judged less relevant since the idea is to compare all the techniques experimented on, it falls off the main scope of this document to directly compare the results of other works. Also because for some of the older methods, the \\gls{IS} and \\gls{FID} metrics were not even introduced at the time.\n", "meta": {"hexsha": "0e34ab8dc71bcf577417ce3f60efb8fe94097d50", "size": 58420, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Overleaf/chapters/GANs/index.tex", "max_stars_repo_name": "PatrickHoeckler/tcc_gan", "max_stars_repo_head_hexsha": "0fa63fff9c6a3bbee57af38683c492a8b120e24a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-20T22:17:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T06:19:44.000Z", "max_issues_repo_path": "Overleaf/chapters/GANs/index.tex", "max_issues_repo_name": "PatrickHoeckler/tcc_gan", "max_issues_repo_head_hexsha": "0fa63fff9c6a3bbee57af38683c492a8b120e24a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Overleaf/chapters/GANs/index.tex", "max_forks_repo_name": "PatrickHoeckler/tcc_gan", "max_forks_repo_head_hexsha": "0fa63fff9c6a3bbee57af38683c492a8b120e24a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 152.9319371728, "max_line_length": 1111, "alphanum_fraction": 0.7747860322, "num_tokens": 14170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6442250928250376, "lm_q1q2_score": 0.4331329597723167}}
{"text": "\\documentclass[12pt]{article}         % the type of document and font size (default 10pt)\n\\usepackage[margin=1.0in]{geometry}   % sets all margins to 1in, can be changed\n\\usepackage{moreverb}                 % for verbatimtabinput -- LaTeX environment\n\\usepackage{amssymb}                  % for many mathematical symbols\n\\usepackage[pdftex]{lscape}           % for landscaped tables\n\\usepackage{longtable}                % for tables that break over multiple pages\n\\usepackage{blkarray}\n\\usepackage{amsmath}\n\\usepackage{bbm}\n\\DeclareMathOperator*{\\plim}{plim}\n\n\\title{Modelling uncertainty in the production process}\n\\author{Takemyprocs}\n\\usepackage{Sweave}\n\\begin{document}\n\\input{uncertainty_intermediate_inputs-concordance}\n\n\\maketitle\n\n\\abstract{We use probability theory and statistics to provide a framework to tackle uncertainty in production. In particular, we focus on the problem of getting an uncertain amount of product given a fixed amount of inputs. Therefore, we ignore the production process itself and treat it like it was a black box. We discuss uncertainty of the product distribution in terms of its mean and variance. Then, we apply this framework to intermediate inputs within a stochastic optimization problem.}\n\n\\section{A parametric model for stochastic products}\nSuppose we use a fixed integer quantity of a single input to procuce random integer quantities for $n$ different products. Also, assume the maximum attainable quantity for every output is fixed at the integer value $M$. Therefore, every time we engage into the production process we end up with an output vector where each element $x_i\\in \\mathbb{Z}$ oscillates within the interval $[0,M]$. Although we can jointly model all products, we decided to work with a more parsimonious approach. Concretely, we assume that product outcomes processes are independent but not identical between them. If they truly are, we can safely ignore any correlation between product outcomes.\n\n\\subsection{The categorical distribution}\nWe model a representative product outcome as coming from a categorical distribution, a discrete probability distribution. The categorial distribution can be viewed as a special case of the multinomial distribution with a single drawing. The probability mass function (PMF) for this distribution is the following:\n\n\\begin{equation}\n\\begin{split}\nf(x\\vert p_1,p_2,...,p_M) = p_0^{\\mathbbm{1}[x=0]} & p_1^{\\mathbbm{1}[x=1]}p_2^{\\mathbbm{1}[x=2]}...p_M^{\\mathbbm{1}[x=M]} = \\prod_{j=0}^M p_j^{\\mathbbm{1}[x=j]} \\\\\n&\\sum_{j=0}^M p_j = 1\n\\end{split}\n\\end{equation}\n\nwhere the product $x$ can take values from $0$ to $M$, and $\\mathbbm{1}[\\cdot]$ is the indicator function\\footnote{This function takes the value of $1$ when the argument is true, otherwise is equal to $0$}. Also, for notation simplicity we define $p_j:=$ Pr$(x=j)$. Some outcomes may be more likely to occur than others so in general $p_j$ lies within the $[0,1]$ range and all probabilities add up to $1$. To this point, we must stress the fact that what we are indeed proposing is a finite count distribution to model the product quantity, customary choices are the binomial distribution or the beta-binomial distribution. However, such distributions imposes a common structure to all probabilities. Although we use the categorical distribution, we do not attemp to treat the outcome as a categorical variable but rather treat it as a integer or count variable with no a priori assumptions over the probability of ocurrence.\n\n\\section{Estimation}\nNow we are ready to use real data in order to estimate the categorical distribution parameters (outcome probabilities). We adopt a maximum likelihood estimation (MLE) approach, that is we aim to find a set of parameter that maximize the likelihood of obtaining the real data. Before we derive the likelihood function for the categorical distribution, keep in mind that for a single event (production process) we can obtain 1 out of $M+1$ results (from $0$ to $M$) in terms of product, so we can arrange our data as follows:\n\n\\[\n\\begin{blockarray}{ccccc}\n& x=0 & x=1 & ... & x=M \\\\\n\\begin{block}{c(cccc)}\n  i=1 & 0 & 1 & ...    & 0 \\\\\n  i=2 & 1 & 0 & ...    & 0 \\\\\n  \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n  i=N & 0 & 0 & ...    & 1 \\\\\n\\end{block}\n\\end{blockarray}\n \\]\n\n\\subsection{Log-likelihood function}\n\nOn every single event $i$ we end up with one and only one of the $M+1$ possible results. We use a binary indicator to highlight the outcome we obtained on that event. To deriver the likelihood function $\\mathcal{L}(\\cdot)$ we start by writing the PMF for the categorical function, but we instead treat data as given rather than parameters:\n\n\\begin{equation}\n\\mathcal{L}(p_0,p_1,...,p_M\\vert x) = \\prod_{i=1}^N \\left(\\prod_{j=0}^M p_j^{\\mathbbm{1}[x_i=j]}\\right)\n\\end{equation}\n\nHere we use $x_i$ to denote the $x$ outcome in the $i$-th event. Now, is customary to deal with the log-likelihood function instead of the likelihood one. The reason lies in the simplicity of computation once we use a mathematical program to estimate parameters, also recall that the $\\log$ function is a monotone transformation so optimize $\\log\\mathcal{L}$ is equivalent to optimize $\\mathcal{L}$.\n\n\\begin{equation}\n\\log\\mathcal{L}(p_0,p_1,...,p_M\\vert x) = \\sum_{i=1}^N \\left(\\sum_{j=0}^M \\mathbbm{1}[x_i=j]\\log p_j\\right)\n\\end{equation}\n\nWe can expand this double summation to get the following expression of the log-likelihood function:\n\n\\begin{equation}\n\\begin{split}\n\\log\\mathcal{L}(p_0,p_1,...,p_M\\vert x) & = \\left(\\sum_{i=1}^N \\mathbbm{1}[x_i=0]\\right)\\log p_0 + \\left(\\sum_{i=1}^N \\mathbbm{1}[x_i=1]\\right)\\log p_1 + ... \\\\\n& + \\left(\\sum_{i=1}^N \\mathbbm{1}[x_i=M]\\right)\\log p_M \n\\end{split}\n\\end{equation}\n\nAs we see, the log-likelihood function can be interpreted as the weighted sum of the log of parameters where weights are equal to all events where the outcome ocurred.\n\n\\subsection{MLE}\n\nWe aim to maximize the value of the log-likelihood function subject to the natural constraint that claims parameters must add up to $1$. Essentially, there are two ways to solve this problem: the analytical and the numerical approach. At first, we derive and discuss some results under the analytical approach but in practice we use the numerical procedure since variance computations require working with a Hessian matrix which is hard to handle under the analytical approach.\n\n\\begin{equation}\n\\begin{aligned}\n\\max_{p_0,p_1,...,p_M} \\quad & \\log\\mathcal{L}(p_0,p_1,...,p_M\\vert x) \\\\\n\\textrm{s.t.} \\quad & \\sum_{j=0}^M p_j = 1\\\\\n  & p_0,p_1,...,p_M\\in [0,1] \\\\\n\\end{aligned}\n\\end{equation}\n\nThis problem resembles the non-linear programming under equality constraints. By using Lagrange Multipliers (LM) we can obtain first order conditions (FOC) for every parameter $p_j$, and by including the parameter restriction per se we can obtain the maximum likelihood estimator for $p_j$, denoted as $\\hat{p}_j$:\n\n\\begin{equation}\n\\hat{p}_j = \\dfrac{\\sum_{i=1}^N \\mathbbm{1}[x_i=j]}{N}\n\\end{equation}\n\nAs you can see, the MLE for $p_j$ is the mean of the related outcome in the sample. It is worth noting that we are not interested on these probabilities per se but instead we want to get an estimate of the average value of the count variable that takes a finite number of outcomes. As with every discrete random variable we define the mean value of such variable as follow:\n\n\\begin{equation}\n\\mathbf{\\hat{E}}(x) = \\hat{p}_0\\times 0 + \\hat{p}_1\\times 1 + ... + \\hat{p}_M\\times M = \\sum_{j=0}^{M} \\hat{p}_j\\times j\n\\end{equation}\n\nNow, we want to discuss how much confident is the measure $\\mathbf{\\hat{E}}(x)$. In order to do so, we delve into variance estimation issues in the MLE approach. In particular, we aim to get a confidence interval for $\\mathbf{\\hat{E}}(x)$ rather than $\\hat{p}_j$. However, keep in mind that $\\mathbf{\\hat{E}}(x)$ is a function of $\\hat{p}_j$.\n\n\\subsection{Variance Estimation and Confidence Intervals}\nThe maximum likelihood estimator has desirable asymptotic properties given that we work with a large sample size. It is consistent (it converges in probability to the population parameter), asymptotically normally distributed and asymptotically efficient (it reaches the minimal variance attainable by all consistent estimators, this is known as the Cramer-Rao lower bound). We summarize these properties as follows:\n\n\\begin{equation}\n\\begin{split}\n& \\plim_{n\\to \\infty} \\hat{\\textbf{p}} = \\textbf{p} \\\\\n& \\hat{\\textbf{p}} \\overset{a}{\\to} \\mathcal{N}\\left[\\textbf{p},\\textbf{I}\\left(\\textbf{p}\\right)^{-1}\\right] \\\\\n& \\textbf{I}\\left(\\textbf{p}\\right) = -E\\left[\\dfrac{\\partial^2 \\log\\mathcal{L}}{\\partial \\textbf{p} \\partial \\textbf{p}^{T}} \\right] \\\\\n\\end{split}\n\\end{equation}\n\nwhere $n$ is the sample size, and $\\textbf{I}\\left(\\textbf{p}\\right)$ is the information matrix. This matrix is equal to the expected value of the Hessian matrix associated to the optimization problem and evaluated at the population parameter vector $\\textbf{p} = p_0,p_1,...,p_M$. We must note it is difficult to obtain $\\textbf{I}\\left(\\textbf{p}\\right)$ not only because we need to obtain the analytical form of a Hessian matrix (which entails calculating second and cross derivatives) but also because we need to do so many times in order to obtain its expected value. In practice we retain the negative of the numerical Hessian matrix associated to the MLE and treat it as an estimate of $\\textbf{I}\\left(\\textbf{p}\\right)$. In turn, we treat the inverse of such matrix as an estimate of the covariance matrix for estimator vector $\\hat{\\textbf{p}}$.\n\n\n\\subsubsection{The Delta Method}\nAs you may remember, we are not interested in obtaining a CI for an arbitrary parameter $\\hat{p}_j$ but rather we aim to obtain a CI for $\\mathbf{\\hat{E}}(x)$. One way to do so is by using the Delta Method for the multivariate case: To keep using the same notation, suppose we have a vector of $M+1$ estimates, called $\\hat{\\textbf{p}}=(\\hat{p}_0,\\hat{p}_1,...,\\hat{p}_M)$, and their related covariance matrix, called $\\textbf{I}\\left(\\textbf{p}\\right)^{-1}$. We aim to find the covariance matrix of a vector of estimators that are a set of functions of the raw vector estimators, say $\\textbf{f}(\\hat{\\textbf{p}})$. If $\\textbf{f}(\\cdot)$ is a set of $C^1$ functions and $\\hat{\\textbf{p}}$ is normally distributed as in equation $(8)$ then:\n\n\\begin{equation}\n\\textbf{f}(\\hat{\\textbf{p}}) \\overset{a}{\\to} \\mathcal{N}\\left[\\textbf{f}(\\textbf{p}),\\textbf{f'}(\\textbf{p})\\textbf{I}\\left(\\textbf{p}\\right)^{-1}\\textbf{f'}(\\textbf{p})^{T}\\right]\n\\end{equation}\n\nwhere $\\textbf{f'}(\\textbf{p})$ is the Jacobian matrix of first derivatives of every new estimator w.r.t each raw estimator. Since $\\mathbf{\\hat{E}}(x)$ is a function of raw parameters $\\hat{p}_j$, then we can use the Delta Method to provide a CI for $\\mathbf{\\hat{E}}(x)$. Once we obtain a standard deviation for $\\mathbf{\\hat{E}}(x)$, say $\\sigma$, we use the following formula for the CI of a normal distribution:\n\n\\begin{equation}\nCI(\\mathbf{\\hat{E}}(x)) = \\mathbf{\\hat{E}}(x) \\pm z^{*}_{\\alpha /2}\\dfrac{\\sigma}{\\sqrt n}\n\\end{equation}\n\nwhere $z^{*}_{\\alpha /2}$ is the critical value of the standard normal distribution for a Type I error level of $\\alpha$ and $n$ is the sample size. The alternative is to use the bootstrapping method which we discuss in the next section.\n\n\\newpage\n\n\\subsubsection{The Bootstrapping Method}\n\n\\end{document}\n", "meta": {"hexsha": "415f98681b636dd479671b201660abd737e8f79f", "size": 11422, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "uncertainty_intermediate_inputs.tex", "max_stars_repo_name": "Takemyprocs/Optimal-buying-and-selling-at-the-auction-house", "max_stars_repo_head_hexsha": "7b42f0cfe018b356cb344be7148237258933f849", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "uncertainty_intermediate_inputs.tex", "max_issues_repo_name": "Takemyprocs/Optimal-buying-and-selling-at-the-auction-house", "max_issues_repo_head_hexsha": "7b42f0cfe018b356cb344be7148237258933f849", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "uncertainty_intermediate_inputs.tex", "max_forks_repo_name": "Takemyprocs/Optimal-buying-and-selling-at-the-auction-house", "max_forks_repo_head_hexsha": "7b42f0cfe018b356cb344be7148237258933f849", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.3722627737, "max_line_length": 926, "alphanum_fraction": 0.7391875328, "num_tokens": 3206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.43313295626827436}}
{"text": "\\appendix\n\\part{Appendix}\n\\label{part:appendix}\n\n\\chapter{Syntax and options}\n\n\\section{Robust statistics (robstat)}\n\\label{sec:syntax:robstat}                                                      \\todo{This section will be replaced.\n                                                                                The plan is to collect the different\n                                                                                tools in new command \\stcmd{robstat}}\n\n\\subsection{Classical estimators}\n\nClassical estimators are readily available in Stata via the \\texttt{summarize}\ncommand using the \\texttt{detail} option.\n\n\\subsection{Quantile-based estimators}\n\nQuantile based estimators are not readily available in Stata but can easily be\ncalculated using the \\texttt{centile} command. For example, for a statistical\nseries $x$, we compute:\n\n\\begin{description}\n\\item the \\emph{median} $Q_{0.5;n}$ by\n\\end{description}\n\n\\texttt{centile x, centile(50)}\n\n\\texttt{local med=r(c\\_1)}\n\n\\begin{description}\n\\item the \\emph{corrected interquartile range} $\\stsc{IQR}_c$ by\n\\end{description}\n\n\\texttt{centile x, centile(25 75)}\n\n\\texttt{local iqr=(r(c\\_2)-r(c\\_1))*0.7413}\n\n\\begin{description}\n\\item the Yule and Kendall skewness coefficient $\\stsc{SK}_{0.25;n}$ by\n\\end{description}\n\n\\texttt{centile x, centile(25 50 75)}\n\n\\texttt{local sk=(r(c\\_1)+r(c\\_3)-2*r(c\\_2))/(r(c\\_2)-r(c\\_1))}\n\n\\begin{description}\n\\item the quantile tail weight measures $\\stsc{LQW}_{0.25;n}$ and\n$\\stsc{RQW}_{0.25;n}$ by\n\\end{description}\n\n\\texttt{centile body, centile(12.5 25 37.5 62.5 75 87.5)}\n\n\\texttt{local lqw=-(r(c\\_1)+r(c\\_3)-2*r(c\\_2))/(r(c\\_3)-r(c\\_1))}\n\n\\texttt{local rqw=(r(c\\_4)+r(c\\_6)-2*r(c\\_5))/(r(c\\_6)-r(c\\_4))}\n\n\\subsection{Pairwise-based estimators}\n\nAs explained in the previous sections, the location, scale, skewness and tails\nheaviness estimators based on pairwise combinations or comparisons of the\nobservations are particularly interesting because they perform better than the\nclassical or quantile-based estimators, namely in terms of robustness. But\nthey require at first sight a heavy computation time of an order of $n^2$.\nFortunately, as explained in \\citet{croux:rousseeuw:1992}, an efficient\nalgorithm proposed by \\citet{johnson:mizoguchi:1978} allows to substantially reduce the computation time to an order of\n$n\\log n$ and, hence, allows to use these robust estimators even in very large\ndatasets. This algorithm has been programmed in Stata (cf.\\\n\\citealp{gelade:verardi:vermandele:2015}) and is involved in the Stata\ncomputation of the pairwise-based estimators.\n\nFor these pairwise-based estimators, the Stata commands are \\texttt{hl} (for\nthe Hodges-Lehman location estimator $\\stsc{HL}_n$), \\texttt{qn} (for the\nRousseeuw and Croux $Q_n$ estimator), \\texttt{medcouple} (for Brys'\nmedcouple $\\stsc{MC}_n$, left medcouple $\\stsc{LMC}_n$ and right\nmedcouple $\\stsc{RMC}_n$).\\ The corresponding syntaxes are:\n\n\\underline{\\textbf{Location}}\n\n\\medskip\n\n\\textbf{Title}\n\nhl -- Hodges and Lehman (1963) robust measure of location\n\n\\smallskip\n\n\\textbf{Syntax}\n\nhl varname [if] [in]\n\n\\bigskip\n\n\\underline{\\textbf{Dispersion}}\n\n\\medskip\n\n\\textbf{Title}\n\nqn -- Rousseeuw and Croux (1993) robust measure of dispersion\n\n\\smallskip\n\n\\textbf{Syntax}\n\nqn varname [if] [in]\n\n\\bigskip\n\n\\underline{\\textbf{Skewness and heavyness of the tails}}\n\n\\medskip\n\n\\textbf{Title}\n\nmedcouple -- medcouple measure of asymmetry and heaviness of the tails\n\n\\smallskip\n\n\\textbf{Syntax}\n\nmedcouple varname [if] [in] [, lmc rmc nomc]\n\n\\bigskip\n\n----------------------------------------------------------------------------------\n\n\\textbf{options description}\n\n----------------------------------------------------------------------------------\n\n\\underline{Main} \\smallskip\n\n\\texttt{lmc} specifies to calculate the medcouple only for those informations\nsmaller than the median. This is an indicator of the heaviness of the left tail.\n\n\\texttt{rmc} Specifies to calculate the medcouple only for those informations\nlarger than the median. This is an indicator of the heaviness of the right tail.\n\n\\texttt{nomc} Specifies not to calculate the global medcouple. This is for\ninstance useful when one is only interested in the heaviness of the tails.\n\n\\subsection{Normality tests}\n\nThe Stata command \\textquotedblleft\\texttt{robjb} \\textit{varname} [if]\n[in]\\textquotedblright\\ has been created to apply these robust tests of\nnormality. This command implements the test considering both skewness and\nheaviness of tails by default. Two mutually exclusive options are available:\n\\texttt{skewness} and \\texttt{kurtosis}. If the former is used, a test based\nexclusively on the skewness is performed while if the latter is called, a test\nbased exclusively on the heaviness of the tails is performed.\n\n\\subsection{Boxplot}\n\nDESCRIBE\\ HERE\\ THE\\ COMMAND, FOR\\ THE\\ MOMENT\\ WE\\ HAVE\n\n\\bigskip\n\n\\textbf{Title}\n\nbox\\_out - Boxplot for skewed and/or heavy-tailed distributions\n\n\\textbf{Syntax}\n\nbox\\_out varname [if] [in] [, out(varname) bdp(\\#) perc(\\#) nograph]\n\n\\underline{\\textbf{Description}}\n\nbox\\_out Creates the boxplot for skewed and/or heavy-tailed distributions\n\n----------------------------------------------------------------------------------\n\n\\textbf{options description}\n\n----------------------------------------------------------------------------------\n\n\\underline{Main} \\smallskip\n\n\\texttt{out(varname)} Identifies the new variable to be created to identify\nindividuals outside the fence defined by the whiskers\n\n\\texttt{bdp(integer)} Sets the desired Break-down point (in \\%). It is 10\\% by default\n\n\\texttt{perc(real)} Sets the desired percentage of points outside the whiskers\nin case of uncontaminated data.\n\n\\texttt{nograph} Suppresses the graph\n\nbox\\_out saves the following in e():\n\n\\texttt{e(g) }Estimated skewness parameter of the underlying Tukey g and h distribution\n\n\\texttt{e(h)} Estimated elongation parameter of the underlying Tukey g and h distribution\n\n\\texttt{e(upperW)} Value of the upper whisker\n\n\\texttt{e(lowerW)} Value of the lower whisker\n\n\n\n\n\\section{Robust linear regression (robreg)}\n\\label{sec:syntax:robreg}\n\n\\stcmd{robreg} provides a number of robust estimators for linear\nregression models. The syntax of \\stcmd{robreg} is:\n\n\\begin{stsyntax}\n    robreg \n    \\stit{estimator} \n    \\depvar\\\n    \\optindepvars\\\n    \\optif\\\n    \\optin\\\n    %\\optweight\\\n    \\optional{, \\stit{options}}\n\\end{stsyntax}\n\n\\noindent\nwhere \\stit{estimator} is one of the following:\n\n\\hangpara\n    \\stcmd{mm} to fit the efficient high breakdown \\stsc{MM} estimator proposed\n    by \\citet{yohai:1987}. On the first stage, a high breakdown \\stsc{S}\n    estimator is applied to estimate the residual scale and derive starting\n    values for the coefficients vector. On the second stage, an efficient\n    bisquare \\stsc{M} estimator is applied to obtain the final coefficient\n    estimates.\n\n\\hangpara\n    \\stcmd{gm} \\alert{to be implemented}\n\n\\hangpara\n    \\stcmd{m} to fit regression \\stcmd{M} estimators \\citep{huber73} using\n    iteratively reweighted least squares (\\stsc{IRWLS}).\n\n\\hangpara\n    \\stcmd{s} to fit the high breakdown \\stcmd{S} estimator introduced by\n    \\citet{rousseeuw:yohai:1984} using the fast algorithm by\n    \\cite{salibian:yohai:2006} with a nonsingular subsampling refinement as\n    proposed by \\citet{Koller:2012}.\n\n\\hangpara\n    \\stcmd{lms}, \\stcmd{lqs}, or \\stcmd{lts} to fit the least median of squares\n    (\\stsc{LMS}), the least quantile of squares (\\stsc{LQS}; a generalization\n    of \\stsc{LMS}), or the least trimmed squares (\\stsc{LTS}) estimator,\n    respectively \\citep{rousseeuw:leroy:1987}. Estimation is carried out using\n    simple resampling without local improvement (e.g.\\\n    \\citealp[197]{rousseeuw:leroy:1987}). Computation of standard errors is not\n    supported for \\stcmd{lms}, \\stcmd{lqs}, and \\stcmd{lts}.\n\n\\noindent \\stcmd{robreg} without arguments replays the previous results; see\n\\uref{20.3 Replaying prior results}. \\stcmd{robreg} saves its results in\n\\stcmd{e()}, so that post estimation commands can be applied; see \\uref{20\nEstimation and postestimation commands}. Type \\stcmd{ereturn list} to list the\n\\stcmd{e()}-returns after estimation; see \\pref{ereturn}.\n\n\\subsection{Options for robreg mm}\n\n\\subsubsection{Main}\n\n\\hangpara\n    \\stcmd{\\underbar{eff}iciency(\\num)} sets the gaussian efficiency of the \\stsc{MM}\n    estimator (i.e., the asymptotic relative efficiency compared to the\n    \\stsc{LS} or \\stsc{ML} estimator in case of i.i.d.\\ normal errors). The\n    efficiency is determined by appropriate choice of the tuning constant for\n    the bisquare \\stsc{M} estimator in the second stage of the \\stsc{MM}\n    algorithm. \\num\\ must be between 0.1 and 99.9. The default for the\n    \\stsc{MM} estimator is \\stcmd{efficiency(85)}, as suggested by\n    \\citet[144]{maronna:etal:2006}.\n\n\\hangpara\n    \\stcmd{bp(\\num)} sets the breakdown point of the \\stsc{MM} estimator. The\n    breakdown point is determined by appropriate choice of the tuning constant\n    for the \\stsc{S} estimator in the first stage of the \\stsc{MM} algorithm.\n    \\num\\ must be between 1 and 50. The default is \\stcmd{bp(50)}.\n\n\\hangpara\n    \\stcmd{\\underbar{haus}man} performs a generalized Hausman test of the \\stsc{MM}\n    estimate against the \\stsc{S} estimate. A significant Hausman test\n    indicates that the \\stsc{MM} estimate significantly deviates from the\n    \\stsc{S} estimate.\n\n\n\\subsubsection{Biweight M estimate}\n\n\\hangpara\n    \\stcmd{k(\\num)} specifies the tuning constant for the bisquare \\stsc{M}\n    estimator in the second stage of the \\stsc{MM} algorithm. \\stcmd{k()} not\n    allowed if \\stcmd{efficiency()} is specified.\n\n\\hangpara\n    \\stcmd{\\underbar{tol}erance(\\num)} specifies the tolerance for the weights of the\n    \\stsc{IRWLS} algorithm used to fit the bisquare \\stsc{M} estimator. When\n    the maximum absolute change in the weights from one iteration to the next\n    is less than or equal to \\stcmd{tolerance()}, the convergence criterion is\n    satisfied. The default is \\stcmd{tolerance(1e-6)}.\n\n\\hangpara\n    \\stcmd{\\underbar{iter}ate(\\num)} specifies the maximum number of iterations for the\n    IRWLS algorithm used to fit the bisquare \\stsc{M} estimator. If convergence\n    is not reached within \\stcmd{iterate()} iterations, the algorithm stops and\n    returns error. The default is \\stcmd{iterate(16000)} or as set by\n    \\stcmd{set maxiter} (see \\rref{maximize}).\n\n\\hangpara\n    \\stcmd{relax} causes the \\stsc{IRWLS} algorithm to return the current\n    results instead of returning error if convergence is not reached.\n\n\\hangpara\n    \\stcmd{\\dunderbar{g}enerate(\\stit{newvar})} stores the final weights of the\n    \\stsc{IRWLS} algorithm in variable \\stit{newvar}.\n\n\\hangpara\n    \\stcmd{\\underbar{re}place} permits \\stcmd{robreg} to overwrite existing variables.\n\n\\subsubsection{Initial S estimate}\n\n\\hangpara\n    \\stcmd{\\underbar{n}samp(\\num)} specifies the number of trial samples for the search\n    algorithm of the \\stsc{S} estimator in the first stage of the \\stsc{MM}\n    algorithm. The default value is determined according to formula\n    $\n    \\lceil \\ln(\\alpha) / \\ln(1 - (1 - \\varepsilon)^p) \\rceil\n    $\n    within a range of 50 to 10000, where $p$ is the number of coefficients in\n    the model and $\\alpha = 0.01$ and $\\varepsilon = 0.2$ (see\n    \\citealp{salibian:yohai:2006} for a justification of the formula). The\n    default values for $\\alpha$ and $\\varepsilon$ can be changed via\n    \\stcmd{sopts()} (see below).\n\n\\hangpara\n    \\stcmd{\\underbar{s}opts(\\stit{options})} specifies additional options to be passed\n    through to the \\stsc{S} estimator. See the section on options for\n    \\stcmd{robreg s} below.\n\n\\hangpara\n    \\stcmd{save(\\stit{name})} saves the results of the \\stsc{S} estimator under\n    \\stit{name} using \\stcmd{estimates store} (see \\rref{estimates}).\n\n\\subsubsection{Standard errors}\n\n\\hangpara\n    \\stcmd{vce(\\underbar{nor}obust)} causes standard errors to be computed\n    using traditional formulas assuming constant error variance. The default\n    is to compute robust standard errors as suggested by \\citet{Croux:2003}\n    (using formula $\\stsc{Avar}_1$; the traditional formula is equivalent to\n    $\\stsc{Avar}_{2s}$).\n\n\\hangpara\n    \\stcmd{\\underbar{nor}obust} is a synonym for \\stcmd{vce(norobust)}\n\n\\subsubsection{Reporting}\n\n\\hangpara\n    \\stcmd{\\underbar{l}evel(\\num)} specifies the level for confidence intervals. The\n    default is \\stcmd{level(95)} or as set by \\stcmd{set level} (see\n    \\rref{level}).\n\n\\hangpara\n    \\stcmd{first} causes the first stage \\stsc{S} estimate to be displayed.\n\n\\hangpara\n    \\stcmd{\\underbar{nodot}s} suppresses the progress dots of the \\stsc{S} estimator\n    search algorithm.\n\n\\hangpara\n    \\stcmd{\\underbar{lo}g} displays the iteration log of the second stage \\stsc{IRWLS}\n    algorithm.\n    \n\\hangpara\n    \\stit{display\\_options} are various display options; see \\rref{estimation\n    options}.\n\n\\subsection{Options for robreg gm}\n\n\\alert{To be completed.}\n\n\\subsection{Options for robreg m}\n\n\\subsubsection{Main}\n\n\\hangpara\n    \\stcmd{\\underbar{h}uber} causes the Huber objective function to be used\n    (monotone \\stsc{M} estimator). This is the default.\n\n\\hangpara\n    \\stcmd{\\underbar{bi}weight} causes the biweight or bisquare objective function to be\n    used (redescending \\stsc{M} estimator). \\stcmd{bisquare} is a synonym for\n    \\stcmd{biweight}. The solution of a redescending \\stsc{M} estimator may\n    depend on the starting values.\n\n\\hangpara\n    \\stcmd{\\underbar{eff}iciency(\\num)} sets the gaussian efficiency (i.e.\\ the asymptotic\n    relative efficiency compared to the \\stsc{LS} or \\stsc{ML} estimator in\n    case of i.i.d.\\ normal errors) by appropriate choice of the tuning\n    constant. \\num\\ must be between 63.7 and 99.9 for \\stcmd{huber} and between\n    0.1 and 99.9 for \\stcmd{biweight}. The default is \\stcmd{efficiency(95)}.\n\n\\hangpara\n    \\stcmd{k(\\num)} specifies the tuning constant. \\stcmd{k()} not allowed if\n    \\stcmd{efficiency()} is specified.\n\n\\subsubsection{IRWLS algorithm}\n\n\\hangpara\n    \\stcmd{\\underbar{tol}erance(\\num)} specifies the tolerance for the weights of the\n    \\stsc{IRWLS} algorithm. When the maximum absolute change in the weights\n    from one iteration to the next is less than or equal to\n    \\stcmd{tolerance()}, the convergence criterion is satisfied. The default is\n    \\stcmd{tolerance(1e-6)}.\n\n\\hangpara\n    \\stcmd{\\underbar{iter}ate(\\num)} specifies the maximum number of iterations for the\n    \\stsc{IRWLS} algorithm. If convergence is not reached within\n    \\stcmd{iterate()} iterations, the algorithm stops and returns error. The\n    default is \\stcmd{iterate(16000)} or as set by \\stcmd{set maxiter} (see\n    \\rref{maximize}).\n\n\\hangpara\n    \\stcmd{relax} causes the \\stsc{IRWLS} algorithm to return the current results\n    instead of returning error if convergence is not reached. For example,\n    to fit a one-step \\stsc{M} estimate specify \\stcmd{relax} together with\n    \\stcmd{iterate(1)}.\n\n\\hangpara\n    \\stcmd{\\dunderbar{g}enerate(\\stit{newvar})} stores the final weights of the\n    \\stsc{IRWLS} algorithm in variable \\stit{newvar}.\n\n\\hangpara\n    \\stcmd{\\underbar{re}place} permits \\stcmd{robreg} to overwrite existing variables.\n\n\\subsubsection{Initial estimate}\n\n\\hangpara\n    \\stcmd{init(\\textit{arg})} determines the choice of the initial estimate\n    that provides the starting values for the \\stsc{IRWLS} algorithm.\n    \\stit{arg} may be \\stcmd{lav} for the \\stsc{LAV} estimator (a.k.a.\\ median\n    regression; fitted using \\stcmd{qreg}, see \\rref{qreg}), \\stcmd{ols} for\n    the least squares estimator (fitted using \\stcmd{regress}, see\n    \\rref{regress}), \\stit{name} for an estimation set stored under\n    \\stit{name}, or \\stcmd{.} for the currently active estimation results. The\n    default is \\stcmd{init(lav)}.\n\n\\hangpara\n    \\stcmd{save(\\stit{name})} saves initial \\stcmd{lav} or \\stcmd{ols} estimate\n    under \\stit{name} using \\stcmd{estimates store} (see \\rref{estimates}).\n\n\\subsubsection{Scale estimate}\n\n\\hangpara\n    \\stcmd{\\underbar{s}cale(\\num)} provides a preliminary value for the residual scale\n    that will be held constant. The default is to use the normalized median of\n    the $(n-p)$ largest absolute residuals from the initial fit, where $n$ is\n    the sample size and $p$ is the number of coefficients, as an estimate of\n    the residual scale (\\stsc{MADN}).\n\n\\hangpara\n    \\stcmd{\\dunderbar{update}scale} causes the \\stsc{MADN} scale estimate to be updated in\n    each iteration of the \\stsc{IRWLS} algorithm. \\stcmd{updatescale} has no\n    effect if \\stcmd{scale()} is specified.\n\n\\hangpara\n    \\stcmd{\\underbar{cen}ter} causes the \\stsc{MADN} scale estimate to be computed based\n    on median centered residuals. \\stcmd{center} has no effect if\n    \\stcmd{scale()} is specified.\n\n\\subsubsection{Standard errors}\n\n\\hangpara\n    \\stcmd{vce(\\underbar{nor}obust)} causes standard errors to be computed\n    using traditional formulas assuming constant error variance. The default\n    is to compute robust standard errors as suggested by \\citet{Croux:2003}\n    (using formula $\\stsc{Avar}_1$; the traditional formula is equivalent to\n    $\\stsc{Avar}_{2s}$).\n\n\\hangpara\n    \\stcmd{vce(pv)} causes traditional standard errors to be computed using the\n    pseudo-values approach \\citep{street.etal.AmStat.1988}. \\stcmd{vce(pv)} is\n    equivalent to \\stcmd{vce(norobust)} but includes some small sample\n    correction.\n\n\\hangpara\n    \\stcmd{\\underbar{nor}obust} is a synonym for \\stcmd{vce(norobust)}\n\n\\hangpara\n    \\stcmd{nose} skips the computation of standard errors.\n\n\\subsubsection{Reporting}\n\n\\hangpara\n    \\stcmd{\\underbar{l}evel(\\num)} specifies the level for confidence intervals. The\n    default is \\stcmd{level(95)} or as set by \\stcmd{set level} (see\n    \\rref{level}).\n\n\\hangpara\n    \\stcmd{first} causes the initial estimate to be displayed.\n\n\\hangpara\n    \\stcmd{\\underbar{lo}g} displays the iteration log of the second stage \\stsc{IRWLS}\n    algorithm.\n\n\\hangpara\n    \\stit{display\\_options} are various display options; see \\rref{estimation\n    options}.\n\n\\subsection{Options for robreg s}\n\n\\subsubsection{Main}\n\n\\hangpara\n    \\stcmd{bp(\\num)} sets the breakdown point by appropriate choice of the\n    tuning constant (this also determines the gaussian efficiency). \\num\\\n    must be between 1 and 50. The default is \\stcmd{bp(50)}.\n\n\\hangpara\n    \\stcmd{k(\\num)} specifies the tuning constant. \\stcmd{k()} not allowed if\n    \\stcmd{bp()} is specified.\n    \n\\hangpara\n    \\stcmd{\\underbar{haus}man} performs a generalized Hausman test of the least squares\n    estimate against the \\stsc{S} estimate. A significant Hausman test\n    indicates that the least squares estimate significantly deviates from the\n    \\stsc{S} estimate.\n\n\\subsubsection{Resampling algorithm}\n\n\\hangpara\n    \\stcmd{\\underbar{c}ategorical(\\stit{varlist})} specifies the variables to be treated\n    as categorical. The default is to detect and treat all dummy variables as\n    categorical. If \\stcmd{categorical()} is specified, the detection of dummy\n    variables is deactivated and only the variables identified by\n    \\stcmd{categorical()} are treated as categorical. Variables from\n    \\stcmd{categorical()} that are not found in \\stit{indepvars} will be\n    automatically added to the end of \\stit{indepvars}. \\stcmd{categorical()}\n    may contain factor variables; see \\uref{11.4.3 Factor variables}.\n    \\alert{I changed the default behavior, if I remember right. Needs to be updated.}\n\n\\hangpara\n    \\stcmd{\\underbar{noc}ategorical} treats all variables as continuous.\n\n\\hangpara\n    \\stcmd{\\dunderbar{nonsing}ular} use nonsingular subsampling \\alert{needs to be completed; \n    nonsingular should be default}\n\n\\hangpara\n    \\stcmd{\\underbar{n}samp(\\num)} specifies the number of trial samples for the search\n    algorithm. The default value is determined according to formula\n    $\n    \\lceil \\ln(\\alpha) / \\ln(1 - (1 - \\varepsilon)^p) \\rceil\n    $\n    within a range of 50 to 10000, where $p$ is the number of coefficients in\n    the model and $\\alpha$ and $\\varepsilon$ are set by \\stcmd{alpha()} and\n    \\stcmd{epsilon()} (see \\citealp{salibian:yohai:2006} for a justification of\n    the formula).\n\n\\hangpara\n    \\stcmd{alpha(\\num)} specifies the maximum admissible risk of drawing a set\n    of samples of which none is free of outliers. This is a parameter in the\n    formula for the computation of the required number samples (see above). The\n    default is \\stcmd{alpha(0.01)} (i.e.\\ 1 percent). \\stcmd{alpha()} has no\n    effect if \\stcmd{nsamp()} is specified.\n\n\\hangpara\n    \\stcmd{\\dunderbar{eps}ilon(\\num)} specifies the assumed maximum fraction of\n    contaminated data. This is a parameter in the formula for the computation\n    of the required number samples (see above). The default is\n    \\stcmd{epsilon(0.2)} (i.e.\\ 20 percent). \\stcmd{epsilon()} has no effect if\n    \\stcmd{nsamp()} is specified.\n\n\\hangpara\n    \\stcmd{\\underbar{nk}eep(\\num)} specifies the number of best candidates to be\n    kept for final refinement. The default is \\stcmd{nkeep(2)}.\n\n\\hangpara\n    \\stcmd{\\dunderbar{rstep}s(\\num)} specifies the number of local improvement steps\n    applied to the candidates. The default is \\stcmd{rsteps(1)}.\n\n\\hangpara\n    \\stcmd{\\underbar{stol}erance(\\num)} specifies the tolerance for the scale estimate of\n    the candidates. When the absolute relative change in the scale from one\n    iteration to the next is less than or equal to \\stcmd{stolerance()}, the\n    convergence criterion is satisfied. The default is \\stcmd{stolerance(1e-6)}.\n\n\\hangpara\n    \\stcmd{\\underbar{siter}ate(\\num)} specifies the maximum number of iterations for the\n    scale estimate of the candidates. If convergence is not reached within\n    \\stcmd{siterate()} iterations, the algorithm stops and returns error. The\n    default is \\stcmd{siterate(16000)} or as set by \\stcmd{set maxiter} (see\n    \\rref{maximize}).\n\n\\hangpara\n    \\stcmd{\\underbar{tol}erance(\\num)} specifies the tolerance for the coefficients in the\n    refinement \\stsc{IRWLS} algorithm. When the maximum relative change in the\n    coefficient vector from one iteration to the next is less than or equal to\n    \\stcmd{tolerance()}, the convergence criterion is satisfied. The default is\n    \\stcmd{tolerance(1e-6)}.\n\n\\hangpara\n    \\stcmd{\\underbar{iter}ate(\\num)} specifies the maximum number of iterations for the\n    refinement \\stsc{IRWLS} algorithm. If convergence is not reached within\n    \\stcmd{iterate()} iterations, the algorithm stops and returns error. The\n    default is \\stcmd{iterate(16000)} or as set by \\stcmd{set maxiter} (see\n    \\rref{maximize}).\n\n\\hangpara\n    \\stcmd{\\dunderbar{sstep}s(\\num)} specifies the number of approximation steps for the\n    scale estimate within each \\stsc{RWLS} iteration. The default is\n    \\stcmd{ssteps(1)}.\n\n\\hangpara\n    \\stcmd{\\dunderbar{srstep}s(\\num)} n of iterations for p-subset scale; default: until\n    convergence \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\underbar{ceff}iciency(\\num)} efficiency of M for catvars; default\n    \\stcmd{cefficiency(95)} \\alert{revise!}\n\n\\hangpara\n    \\stcmd{ck(\\num)} k of M for catvars; not allowed with \\stcmd{cefficiency()}\n    \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\dunderbar{cstep}s(\\num)} approx. steps for catvar M within p-subset; default\n    \\stcmd{cstep(0)} \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\underbar{noxr}esid} do not residualize continuous variables \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\dunderbar{fstep}s(\\num)} approx. iteration in final backfit rounds; default:\n    until convergence \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\underbar{nback}fit(\\num)} n of final backfit rounds; default: 20\n    \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\underbar{nobr}eak} do not exit final backfitting if scale increases\n    \\alert{revise!}\n\n\\hangpara\n    \\stcmd{\\dunderbar{g}enerate(\\stit{newvar})} stores the final \\stsc{IRWLS} weights from\n    the best solution in variable \\stit{newvar}.\n\n\\hangpara\n    \\stcmd{\\underbar{re}place} permits \\stcmd{robreg} to overwrite existing variables.\n\n\\subsubsection{Standard errors}\n\n\\hangpara\n    \\stcmd{vce(\\underbar{nor}obust)} causes standard errors to be computed using\n    traditional formulas assuming constant error variance. The default is to\n    compute robust standard errors as suggested by \\citet{Croux:2003} (using\n    formula $\\stsc{Avar}_1$; the traditional formula is equivalent to\n    $\\stsc{Avar}_{2s}$).\n    \n\\hangpara\n    \\stcmd{\\underbar{nor}obust} is a synonym for \\stcmd{vce(norobust)}\n\n\\hangpara\n    \\stcmd{nose} skips the computation of standard errors.\n\n\\subsubsection{Reporting}\n\n\\hangpara\n    \\stcmd{\\underbar{l}evel(\\num)} specifies the level for confidence intervals. The\n    default is \\stcmd{level(95)} or as set by \\stcmd{set level} (see\n    \\rref{level}).\n\n\\hangpara\n    \\stcmd{\\underbar{nodot}s} suppresses the progress dots of the search algorithm.\n\n\\hangpara\n    \\stit{display\\_options} are various display options; see \\rref{estimation\n    options}.\n\n\\subsection{Options for robreg lms, robreg lqs, and robreg lts}\n\n\\subsubsection{Main}\n\n\\hangpara\n    \\stcmd{bp(\\num)} sets the breakdown point, where \\num\\ may be in $(0,0.5]$. \\stcmd{bp()}\n    determines the $h$ parameter for the \\stsc{LQS} and \\stsc{LTS} estimators as\n    $\n    h = \\lfloor(1-\\num) \\cdot n\\rfloor + \\lfloor\\num \\cdot (p + 1)\\rfloor\n    $\n    where $n$ is the sample size and $p$ is the number of coefficients. The\n    default is \\stcmd{bp(0.5)}. \\stcmd{bp()} is not allowed with\n    \\stcmd{robreg lms}.\n\n\\subsubsection{Resampling algorithm}\n\n\\hangpara\n    \\stcmd{\\underbar{n}samp(\\num)} specifies the number of trial samples for the search\n    algorithm. The default value is determined according to formula\n    $\n    \\lceil \\ln(\\alpha) / \\ln(1 - (1 - \\varepsilon)^p) \\rceil\n    $\n    within a range of 50 to 10000, where $p$ is the number of coefficients in\n    the model and $\\alpha$ and $\\varepsilon$ are set by \\stcmd{alpha()} and\n    \\stcmd{epsilon()}.\n\n\\hangpara\n    \\stcmd{alpha(\\num)} specifies the maximum admissible risk of drawing a set\n    of samples of which none is free of outliers. This is a parameter in the\n    formula for the computation of the required number samples (see above). The\n    default is \\stcmd{alpha(0.01)} (i.e.\\ 1 percent). \\stcmd{alpha()} has no\n    effect if \\stcmd{nsamp()} is specified.\n\n\\hangpara\n    \\stcmd{\\dunderbar{eps}ilon(\\num)} specifies the assumed maximum fraction of\n    contaminated data. This is a parameter in the formula for the computation\n    of the required number samples (see above). The default is\n    \\stcmd{epsilon(0.2)} (i.e.\\ 20 percent). \\stcmd{epsilon()} has no effect if\n    \\stcmd{nsamp()} is specified.\n\n\\hangpara\n    \\stcmd{\\dunderbar{g}enerate(\\stit{newvar})} stores a variable \\stit{newvar} that marks the\n    minimizing trial sample.\n\n\\hangpara\n    \\stcmd{\\underbar{re}place} permits \\stcmd{robreg} to overwrite existing variables.\n\n\\subsubsection{Reporting}\n\n\\hangpara\n    \\stcmd{\\underbar{nodot}s} suppresses the progress dots of the search algorithm.\n\n\\hangpara\n    \\stit{display\\_options} are various display options; see \\rref{estimation\n    options}.\n\n\\section{Robust logistics regression (roblogit)}\n\\label{sec:syntax:roblogit}\n\n\\section{Robust multivariate statistics (robmv)}\n\\label{sec:syntax:robmv}", "meta": {"hexsha": "42e531f6539c94b8d6c2ff53de404a2b9cc33c32", "size": 27339, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "stbook/appendix.tex", "max_stars_repo_name": "benjann/robregbk", "max_stars_repo_head_hexsha": "8bda32e4ce56fc354c3f469ba52ca7163e53b43f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-25T14:21:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-25T14:21:56.000Z", "max_issues_repo_path": "stbook/appendix.tex", "max_issues_repo_name": "benjann/robregbk", "max_issues_repo_head_hexsha": "8bda32e4ce56fc354c3f469ba52ca7163e53b43f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "stbook/appendix.tex", "max_forks_repo_name": "benjann/robregbk", "max_forks_repo_head_hexsha": "8bda32e4ce56fc354c3f469ba52ca7163e53b43f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-05-19T07:27:04.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-26T02:04:46.000Z", "avg_line_length": 37.0447154472, "max_line_length": 119, "alphanum_fraction": 0.7157174732, "num_tokens": 7883, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.4331329562682743}}
{"text": "\\section{Optoelectronic coupling}\n\nThe non-interacting system displays valley selective optical excitations.\nLight of a particular polarization only couples to one valley.\nSince the superconducting state is\na coherent condensate admixing the two valleys,\nwe address whether pair-breaking displays similar valley selectivity.\nIn particular, we explore whether or not the two quasiparticles generated\nby circularly polarized light, with total energy larger than\n$Δ + Δ_{\\vK}$, occupy opposite valleys,\nwith one in the conduction band and the other in the valence band.\n\nThe optical excitations arise from the Berry curvature,\nwhich acts as an effective angular momentum.\nThe electromagnetic potential $\\vc{A}$,\nwith polarization vector $\\vc{ϵ}$,\nis introduced using minimal coupling,\n$H_{τ {\\s}}^{ν ν'} \\ofK\n→ H_{τ {\\s}}^{ν ν'} \\of{\\vK + e \\vc{A}}$,\nwhere, in the dipole approximation,\n$\\vc{A} = 2 \\re{\\vc{ϵ} A_0 e^{- i ω t}}$.\nThis yields a perturbed Hamiltonian\n$H → H + H^A$, where\n$H^A = H' e^{- i ω t} + H'^† e^{i ω t}$,\nwith\n\\begin{equation}\n  H'\n  = ∑_{\\vK, τ, {\\s}}\n    H'_τ\n    {d^-_{τ {\\s}}}^† \\ofK\n    d^+_{τ {\\s}} \\ofK\n  - ∑_{\\vK, τ, {\\s}}\n    H'_{-τ}\n    {d^+_{τ {\\s}}}^† \\ofK\n    d^-_{τ {\\s}} \\ofK,\n\\end{equation}\nand\n$H'_τ\n= a t e A_0\n\\left( τ \\vc{\\hat{x}} + i \\vc{\\hat{y}} \\right) · \\vc{ϵ}$.\nThe transition rate is proportional to the modulus-squared\nof the optical matrix elements,\n$\\vc{P}_{τ {\\s}}^{n n'} \\ofK$,\ndefined by\n\\begin{equation}\n  H^A\n  = ∑_{\\substack{\\vK, τ, {\\s} \\\\ n, n'}}\n    \\frac{e A_0}{m_0}\n    \\vc{ϵ} · \\vc{P}_{τ {\\s}}^{n n'} \\ofK\n    {c_{τ {\\s}}^n}^† \\ofK\n    c_{τ {\\s}}^{n'} \\ofK.\n\\end{equation}\nFor circularly polarized light, in the absence of superconductivity,\n$\\vc{ϵ}_± = \\left( \\vc{\\hat{x}} ± i \\vc{\\hat{y}} \\right) / \\sqrt{2}$ and\n\\begin{equation}\n  \\label{eq:optical}\n  \\vc{ϵ}_± · \\vc{P}_{τ {\\s}}^{+ -} \\of{\\vK}\n  = ∓ τ \\sqrt{2} a t m_0\n    e^{± i ϕ}\n    \\sin^2 {\\frac{\\fnTheta{∓ τ}}{2}}.\n\\end{equation}\nSee \\cref{s:appendix:optical} for a full derivation.\n\nThe transition rate matrix elements\nfor optical excitations from the BCS ground state\nare given by \\cref{eq:optical}\nmultiplied by a coherence factor $\\sin {β_{\\vK}}$.\nSince $\\fnTheta{-} - \\fnTheta{+} = τ π$,\nswitching either the valley or polarization transforms\n$\\sin → \\cos$ in \\cref{eq:optical}, giving matrix elements\n$\\abs{P_±} = \\abs{\\vc{ϵ}_± · \\vc{P}_{++}^{+ -} \\ofK \\sin {β_{\\vK}}}$\ncorresponding to matching ($P_+$) or mismatching ($P_-$)\npolarization-valley indexes.\nFor a given valley, a chosen polarization of light couples more strongly\nthan the other, as is evident comparing $\\abs{P_+}^2$ to $\\abs{P_-}^2$\nand shown in \\cref{fig:optical}.\nFor incident light with energy $Δ + \\abs{λ_{\\vK}}$,\nright circularly polarized light ($+$) has a higher probability\nof promoting a quasiparticle to the right conduction band,\nas reflected in the larger matrix element $\\abs{P_+}^2 ≫ \\abs{P_-}^2$.\nAs depicted in \\cref{fig:optical-excitation},\nthe partner of the Cooper pair is in the valence band in the opposite valley.\nThe other valley has the opposite dependence on polarization.\n\nThis key new result opens the door for valley control of excitations\nfrom a coherent ground state.\nFor example, the two quasiparticles have the same charge and Berry curvature\n(see below).\nIn the presence of an electric filed,\nthey both acquire the same transverse anomalous velocity.\nThus, in contrast to the response in the normal state,\nan anomalous Hall effect is anticipated\nwith no accompanying spin current.\n\n\\begin{figure}[b]\n  \\includegraphics[width=\\columnwidth]{figures/optical-transitions-bcs}\n  \\caption{%\n    Optical transition rate matrix elements\n    $\\left| P_± \\right|^2$\n    in the superconducting phase\n    as a function of the ratio of the quasiparticle energy\n    $λ_{\\vK}$ to the superconducting gap $Δ_{\\vK}$.\n    Material parameters for \\ce{MoSe2}, \\ce{WS2}, and \\ce{WSe2}\n    are given in~\\cite{PhysRevLett.108.196802}\n    and a gap of $Δ_{\\vK} = \\SI{7.5}{\\milli\\electronvolt}$\n    is chosen for illustrative purposes.\n    The order-of-magnitude contrast between\n    $\\left|P_+\\right|^2$ and $\\left|P_-\\right|^2$\n    causes the optical-valley selectivity.\n  }\\label{fig:optical}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics[width=\\columnwidth]{figures/bcs-excitation}\n  \\caption{%\n    Pair-breaking by right circularly polarized light\n    leads to an electron in the conduction band of the right valley\n    and a partner in the valence band of the left valley.\n    The valleys interchange for left circularly polarized light.\n  }\\label{fig:optical-excitation}\n\\end{figure}\n", "meta": {"hexsha": "6a12845d6a301adc3dd75f8d3a54c5e2330dbf82", "size": 4593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/_dichalcogenides-optical.tex", "max_stars_repo_name": "razor-x/doctoral-thesis", "max_stars_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-25T23:01:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-25T23:01:11.000Z", "max_issues_repo_path": "tex/_dichalcogenides-optical.tex", "max_issues_repo_name": "evansosenko/doctoral-thesis", "max_issues_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/_dichalcogenides-optical.tex", "max_forks_repo_name": "evansosenko/doctoral-thesis", "max_forks_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6475409836, "max_line_length": 77, "alphanum_fraction": 0.6901807098, "num_tokens": 1492, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.43313295131299073}}
{"text": "\\chapter{solutions/magnetostatics}\n\\begin{abox}\n\tPractice set 1 solutions/magnetostatics\n\t\\end{abox}\n\\begin{enumerate}\n\\begin{minipage}{\\textwidth}\n\t\\item The magnetic field at a distance $R$ from a long straight wire carrying a steady current $I$ is proportional to\n\t\\exyear{NET 2012}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $I R$\n\t\\task[\\textbf{B.}] $I / R^{2}$\n\t\\task[\\textbf{C.}]$I^{2} / R^{2}$\n\t\\task[\\textbf{D.}]$I / R$\n\\end{tasks}\n\\begin{answer}\n\tThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item The vector potential $\\vec{A}$ due to a magnetic moment $\\vec{m}$ at a point $\\vec{r}$ is given by $\\vec{A}=\\frac{\\vec{m} \\times \\vec{r}}{r^{3}}$.\n\tIf $\\vec{m}$ is directed along the positive $z$-axis, the $x$ - component of the magnetic field, at the point $\\vec{r}$, is\n\t\\exyear{NET 2011}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{3 m y z}{r^{5}}$\n\t\\task[\\textbf{B.}] $-\\frac{3 m x y}{r^{5}}$\n\t\\task[\\textbf{C.}]$\\frac{3 m x z}{r^{5}}$\n\t\\task[\\textbf{D.}]$\\frac{3 m\\left(z^{2}-x y\\right)}{r^{5}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\vec{m}&=m \\hat{z}\\\\\n\t \\text { and }\\\\\n\t \\vec{B}&=\\vec{\\nabla} \\times \\vec{A}=\\frac{m}{r^{3}}(2 \\cos \\theta \\hat{r}+\\sin \\theta \\hat{\\theta})=\\frac{1}{r^{3}}[3(\\vec{m} \\cdot \\hat{r}) \\hat{r}-\\vec{m}] \\\\\n \\vec{B}&=\\frac{1}{r^{3}}\\left[3 m \\hat{z} \\cdot\\left(\\frac{x \\hat{x}+y \\hat{y}+z \\hat{z}}{r}\\right) \\frac{\\vec{r}}{r}-m \\hat{z}\\right] \\\\\n   B_{x}&=\\frac{3 m x z}{r^{5}}\n\t\\end{align*}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item An infinite solenoid with its axis of symmetry along the $z$-direction carries a steady current $I$.\n\tThe vector potential $\\vec{A}$ at a distance $R$ from the axis\n\t\\exyear{NET 2012}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=3cm]{NET1}\n\t\\end{figure}\n\\end{minipage}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}]is constant inside and varies as $R$ outside the solenoid\n\t\\task[\\textbf{B.}] varies as $R$ inside and is constant outside the solenoid\n\t\\task[\\textbf{C.}]varies as $\\frac{1}{R}$ inside and as $R$ outside the solenoid\n\t\\task[\\textbf{D.}]varies as $R$ inside and as $\\frac{1}{R}$ outside the solenoid\n\\end{tasks}\n\\begin{answer}\n\tThe correct option is \\textbf{(d)}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item The force between two long and parallel wires carrying currents $I_{1}$ and $I_{2}$ and separated by a distance $D$ is proportional to\n\t\\exyear{NET 2013}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $I_{1} I_{2} / D$\n\t\\task[\\textbf{B.}]$\\left(I_{1}+I_{2}\\right) / D$\n\t\\task[\\textbf{C.}]$\\left(I_{1} I_{2} / D\\right)^{2}$\n\t\\task[\\textbf{D.}]$I_{1} I_{2} / D^{2}$\n\\end{tasks}\n\\begin{answer}\n\tThe correct option is \\textbf{(a)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A time-dependent current $\\vec{I}(t)=K t \\hat{z}$ (where $K$ is a constant) is switched on at $t=0$ in an infinite current-carrying wire. The magnetic vector potential at a perpendicular distance $a$ from the wire is given (for time $t>a / c$ ) by\n\t\\exyear{NET 2014}\n\\end{minipage}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] $\\hat{z} \\frac{\\mu_{0} K}{4 \\pi c} \\int_{-\\sqrt{c^{2} t^{2}-a^{2}}}^{\\sqrt{c^{2} t^{2}-a^{2}}} d z \\frac{c t-\\sqrt{a^{2}+z^{2}}}{\\left(a^{2}+z^{2}\\right)^{1 / 2}}$\n\t\\task[\\textbf{B.}] $\\hat{z} \\frac{\\mu_{0} K}{4 \\pi} \\int_{-c t}^{c t} d z \\frac{t}{\\left(a^{2}+z^{2}\\right)^{1 / 2}}$\n\t\\task[\\textbf{C.}] $\\hat{z} \\frac{\\mu_{0} K}{4 \\pi c} \\int_{-c t}^{c t} d z \\frac{c t-\\sqrt{a^{2}+z^{2}}}{\\left(a^{2}+z^{2}\\right)^{1 / 2}}$\n\t\\task[\\textbf{D.}] $\\hat{z} \\frac{\\mu_{0} K}{4 \\pi} \\int_{-\\sqrt{c^{2} t^{2}-a^{2}}}^{\\sqrt{c^{2} t^{2}-a^{2}}} d z \\frac{t}{\\left(a^{2}+z^{2}\\right)^{1 / 2}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{diagram-20211011(26)-crop}\n\t\\end{figure}\n\t \\begin{align*}\n\t\\vec{A} &=\\hat{z} \\frac{\\mu_{0}}{4 \\pi} \\int_{-\\infty}^{\\infty} \\frac{I\\left(t_{r}\\right)}{R} d z=\\hat{z} \\frac{\\mu_{0}}{4 \\pi} \\int_{-\\infty}^{\\infty} \\frac{K(t-R / c)}{R} d z \\\\\n\t\\Rightarrow \\vec{A} &=\\hat{z} \\frac{\\mu_{0} K}{4 \\pi c} \\int_{-\\sqrt{c^{2} t^{2}-a^{2}}}^{\\sqrt{c^{2} t^{2}-a^{2}}} d z \\frac{c t-\\sqrt{a^{2}+z^{2}}}{\\left(a^{2}+z^{2}\\right)^{1 / 2}}\n\t\\end{align*}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A charged particle moves in a helical path under the influence of a constant magnetic field. The initial velocity is such that the component along the magnetic field is twice the component in the plane normal to the magnetic field.\n\tThe ratio $\\ell / R$ of the pitch $\\ell$ to the radius $R$ of the helical path is\n\t\\exyear{NET 2014}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\pi / 2$\n\t\\task[\\textbf{B.}]$4 \\pi$\n\t\\task[\\textbf{C.}]$2 \\pi$\n\t\\task[\\textbf{D.}]$\\pi$\n\\end{tasks}\n\\begin{answer}\n\t$v_{\\|}=2 v_{\\perp}$\\\\\n\tPitch of the helix $l=v_{\\|} T=v_{\\|} \\frac{2 \\pi R}{v_{\\perp}}=2 v_{\\perp} \\frac{2 \\pi R}{v_{\\perp}}=4 \\pi R \\Rightarrow \\frac{l}{R}=4 \\pi$\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A proton moves with a speed of $300 \\mathrm{~m} / \\mathrm{s}$ in a circular orbit in the $x y$-plan in a magnetic field 1 tesla along the positive $z$-direction. When an electric field of $1 \\mathrm{~V} / \\mathrm{m}$ is applied along the positive $y$-direction, the center of the circular orbit\n\t\\exyear{NET 2014}\n\\end{minipage}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] remains stationary\n\t\\task[\\textbf{B.}]moves at $1 \\mathrm{~m} / \\mathrm{s}$ along the negative $x$-direction\n\t\\task[\\textbf{C.}]moves at $1 \\mathrm{~m} / \\mathrm{s}$ along the positive $z$ - direction\n\t\\task[\\textbf{D.}] moves at $1 \\mathrm{~m} / \\mathrm{s}$ along the positive $x$ - direction\n\\end{tasks}\n\\begin{answer}\n\tChange particle will deflect in $+x$-direction with $v=\\frac{E}{B}=\\frac{1}{1}=1 \\mathrm{~m} / \\mathrm{s} .$\\\\\n\tThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item Given a uniform magnetic field $B=B_{0} \\hat{k}$ (where $B_{0}$ is a constant), a possible choice for the magnetic vector potential $A$ is\n\t\\exyear{NET 2015}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $B_{0} y \\hat{i}$\n\t\\task[\\textbf{B.}] $-B_{0} y \\hat{i}$\n\t\\task[\\textbf{C.}] $B_{0}(x \\hat{j}+y \\hat{i})$\n\t\\task[\\textbf{D.}]$B_{0}(x \\hat{i}+y \\hat{j})$\n\\end{tasks}\n\\begin{answer}\n\t(a) $\\vec{\\nabla} \\times \\vec{A}=-B_{0} \\hat{k}$\\\\\n\t(b) $\\vec{\\nabla} \\times \\vec{A}=B_{0} \\hat{k}$\\\\\n\t(c) $\\vec{\\nabla} \\times \\vec{A}=0$\\\\\n\t(d) $\\vec{\\nabla} \\times \\vec{A}=0$\\\\\n\tThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A small magnetic needle is kept at $(0,0)$ with its moment along the $x$-axis. Another small magnetic needle is at the point $(1,1)$ and is free to rotate in the $x y$ - plane. In equilibrium the angle $\\theta$ between their magnetic moments is such that\n\t\\exyear{NET 2015}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\tan \\theta=\\frac{1}{3}$\n\t\\task[\\textbf{B.}]$\\tan \\theta=0$\n\t\\task[\\textbf{C.}]$\\tan \\theta=3$\n\t\\task[\\textbf{D.}]$\\tan \\theta=1$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=6cm]{diagram-20211011(38)-crop}\n\t\\end{figure}\n\t\\begin{align*}\n\t&U=\\frac{\\mu_{0}}{4 \\pi r^{3}}\\left[\\vec{m}_{1} \\cdot \\vec{m}_{2}-3\\left(\\vec{m}_{1} \\cdot \\hat{r}\\right)\\left(\\vec{m}_{2} \\cdot \\hat{r}\\right)\\right]\\\\\n\t&U=\\frac{\\mu_{0} m_{1} m_{2}}{4 \\pi r^{3}}\\left[\\cos \\theta-3 \\cos 45^{0} \\cos \\left(\\theta-45^{0}\\right)\\right]\n\t\\intertext{For stable position energy is minimum i.e.}\n\t&\\frac{\\partial U}{\\partial \\theta}=0 \\Rightarrow \\frac{\\mu_{0} m_{1} m_{2}}{4 \\pi r^{3}}\\left[-\\sin \\theta+\\frac{3}{\\sqrt{2}} \\sin \\left(\\theta-45^{\\circ}\\right)\\right]=0 \\\\\n\t&\\Rightarrow \\sin \\theta=\\frac{3}{\\sqrt{2}}\\left(\\frac{\\sin \\theta}{\\sqrt{2}}-\\frac{\\cos \\theta}{\\sqrt{2}}\\right) \\Rightarrow \\tan \\theta=3\n\t\\end{align*}\n\tThe correct option \\textbf{(c)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A dipole of moment $\\vec{p}$, oscillating at frequency $\\omega$, radiates spherical waves. The vector potential at large distance is\\\\\n\t$$\\vec{A}(\\vec{r})=\\frac{\\mu_{0}}{4 \\pi} i \\omega \\frac{e^{i k r}}{r} \\vec{p}$$\t\n\t$\\text { To order }\\left(\\frac{1}{r}\\right) \\text { the magnetic field } \\vec{B} \\text { at a point } \\vec{r}=r \\hat{n} \\text { is }$\n\t\\exyear{NET 2015}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $-\\frac{\\mu_{0}}{4 \\pi} \\frac{\\omega^{2}}{C}(\\hat{n} \\cdot \\vec{p}) \\hat{n} \\frac{e^{i k r}}{r}$\n\t\\task[\\textbf{B.}]$-\\frac{\\mu_{0}}{4 \\pi} \\frac{\\omega^{2}}{C}(\\hat{n} \\times \\vec{p}) \\frac{e^{i k r}}{r}$\n\t\\task[\\textbf{C.}]$-\\frac{\\mu_{0}}{4 \\pi} \\omega^{2} k(\\hat{n} \\cdot \\vec{p}) \\vec{p} \\frac{e^{i k r}}{r}$\n\t\\task[\\textbf{D.}]$-\\frac{\\pi_{0}}{4 \\pi} \\frac{\\omega^{2}}{C} \\vec{p} \\frac{e^{i k r}}{r}$\n\\end{tasks}\n\\begin{answer}\n\tLet $\\vec{p}=p \\hat{z}$, then $\\vec{B}$ must be in $\\hat{\\phi}$ direction.\\\\\n\tCheck $\\hat{n} \\times \\vec{p}=\\hat{r} \\times \\hat{z}=\\hat{\\phi}$.\\\\ \n\tThe correct option is (b).\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A loop of radius $a$, carrying a current $I$, is placed in a uniform magnetic field $B$. If the normal to the loop is denoted by $\\hat{n}$, the force $\\vec{F}$ and the torque $\\vec{T}$ on the loop are\n\t\\exyear{NET 2015}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\vec{F}=0$ and $\\vec{T}=\\pi a^{2} I \\hat{\\mathrm{n}} \\times B$\n\t\\task[\\textbf{B.}]$\\vec{F}=\\frac{\\mu_{0}}{4 \\pi} \\vec{I} \\times \\vec{B}$\n\t\\task[\\textbf{C.}]$\\vec{F}=\\frac{\\mu_{0}}{4 \\pi} \\vec{I} \\times \\vec{B}$ and $\\vec{T}=I \\hat{\\mathrm{n}} \\times \\vec{B}$\n\t\\task[\\textbf{D.}]$\\vec{F}=0$ and $\\vec{T}=\\frac{1}{\\mu_{0} \\varepsilon_{0}} I \\vec{B}$\n\\end{tasks}\n\\begin{answer}\n\tIn uniform field $\\vec{F}=0$\n\tTorque $\\vec{T}=\\vec{m} \\times \\vec{B}=\\pi a^{2}$ In $\\times \\vec{B}$\\\\\n\tThe correct option is \\textbf{(a)}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A conducting circular disc of radius $r$ and resistivity $\\rho$ rotates with an angular velocity $\\omega$ in a magnetic field $B$ perpendicular to it. A voltmeter is connected as shown in the figure below. Assuming its internal resistance to be infinite, the reading on the voltmeter\n\t\\exyear{NET 2016}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20211011(46)-crop}\n\t\\end{figure}\n\\end{minipage}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] depends on $\\omega, B, r$ and $\\rho$\n\t\\task[\\textbf{B.}]depends on $\\omega, B$ and $r$ but not on $\\rho$\n\t\\task[\\textbf{C.}]is zero because the flux through the loop is not changing\n\t\\task[\\textbf{D.}]is zero because a current the flows in the direction of $B$\n\\end{tasks}\n\\begin{answer}\n\tForce experienced by charge is\n\t$$\n\t\\vec{F}=q(\\vec{v} \\times \\vec{B}) \\text { and } v=r \\omega\n\t$$\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A set of $N$ concentric circular loops of wire, each carrying a steady current $I$ in the same direction, is arranged in a plane. The radius of the first loop is $r_{1}=a$ and the radius of the $n^{\\text {th }}$ loop is given by $r_{n}=n r_{n-1}$. The magnitude $B$ of the magnetic field at the centre of the circles in the limit $N \\rightarrow \\infty$, is\n\t\\exyear{NET 2016}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\mu_{0} I\\left(e^{2}-1\\right) / 4 \\pi a$\n\t\\task[\\textbf{B.}]$\\mu_{0} I(e-1) / \\pi a$\n\t\\task[\\textbf{C.}]$\\mu_{0} I\\left(e^{2}-1\\right) / 8 a$\n\t\\task[\\textbf{D.}]$\\mu_{0} I(e-1) / 2 a$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t&B=\\frac{\\mu_{0} I}{2}\\left(\\frac{1}{r_{1}}+\\frac{1}{r_{2}}+\\frac{1}{r_{3}}+\\ldots \\ldots . \\frac{1}{r_{n}}\\right)\\\\\n\t&r_{1}=a \\\\\n\t&r_{n}=n r_{n-1} \\\\\n\t&r_{1}=r_{0}=a, r_{2}=2 r_{1}=2 a, r_{3}=3 r_{2}=3.2 a \\text { and } r_{4}=4 r_{3}=4.3 .2 a \\\\\n\t&\\Rightarrow B=\\frac{\\mu_{0} I}{2 a}\\left(1+\\frac{1}{2}+\\frac{1}{3.2}+\\frac{1}{4.3 .2}+\\ldots \\ldots\\right) \\\\\n\t&B=\\frac{\\mu_{0} I}{2 a}\\left(\\sum_{n=1}^{N} \\frac{1}{\\lfloor n}\\right) \\\\\n\t&e^{x}=\\sum_{n=0}^{\\infty} \\frac{x^{n}}{\\lfloor n} \\Rightarrow e=\\sum_{n=0}^{\\infty} \\frac{1}{\\lfloor n}=1+\\sum_{n=1}^{\\infty} \\frac{1}{\\lfloor n} \\Rightarrow \\sum_{n=1}^{\\infty} \\frac{1}{\\lfloor n}=e-1 \\\\\n\t&\\lim _{N \\rightarrow \\infty}\\left(\\sum_{n=l}^{N} \\frac{1}{n}\\right)=e-1 \\Rightarrow B=\\frac{\\mu_{0} I}{2 a}(e-1)\n\t\\end{align*}\t\n\tTHe correct option is \\textbf{(d)}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A constant current $I$ is flowing in a piece of wire that is bent into a loop as shown in the figure.\\\\\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=5cm,width=7cm]{diagram-20211011(54)-crop}\n\t\\end{figure}\n\t$\\text { The magnitude of the magnetic field at the point } O \\text { is }$\n\t\\exyear{NET 2017}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\mu_{0} I}{4 \\pi \\sqrt{5}} \\ln \\left(\\frac{a}{b}\\right)$\n\t\\task[\\textbf{B.}]$\\frac{\\mu_{0} I}{4 \\pi \\sqrt{5}}\\left(\\frac{1}{a}-\\frac{1}{b}\\right)$\n\t\\task[\\textbf{C.}]$\\frac{\\mu_{0} I}{4 \\pi \\sqrt{5}}\\left(\\frac{1}{a}\\right)$\n\t\\task[\\textbf{D.}]$\\frac{\\mu_{0} I}{4 \\pi \\sqrt{5}}\\left(\\frac{1}{b}\\right)$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20211011(55)-crop}\n\t\\end{figure}\n\t\\begin{align*}\n\t\\vec{B}&=\\frac{\\mu_{0} I}{4 \\pi d}\\left(\\sin \\theta_{2}-\\sin \\theta_{1}\\right) \\hat{\\phi}\\\\\n\t\\intertext{Magnetic field due to left and right segment of 2a}\n\tB_{2 a}&=\\frac{\\mu_{0} I}{4 \\pi a}\\left(\\frac{2 a}{\\sqrt{5 a}}\\right) \\otimes\\\\\n\t\\intertext{Field due to upper segment of $2 a$}\n\t&=\\frac{\\mu_{0} I}{4 \\pi(2 a)} \\times\\left(\\frac{a}{\\sqrt{5} a}+\\frac{a}{\\sqrt{5} a}\\right)\\\\\n\t\\text{Net field}\\\\\n\tB_{2 a}&=2 \\times \\frac{\\mu_{0} I}{4 \\pi a} \\times \\frac{2}{\\sqrt{5}}+\\frac{\\mu_{0} I}{4 \\pi a} \\times \\frac{1}{\\sqrt{5}}\\\\\n\tB_{2 a}&=\\frac{\\mu_{0} I}{4 \\pi a} \\sqrt{5} \\otimes(\\text { inward })\\\\\n\t\\text{similarly,} B_{2 b}&=\\frac{\\mu_{0} I}{4 \\pi b} \\sqrt{5} \\odot \\text{(outward)}\\\\\n\\text{\tNet field}\\\\\n B&=B_{2 a}-B_{2 b}=\\frac{\\mu_{0} I}{4 \\pi} \\sqrt{5}\\left(\\frac{1}{a}-\\frac{1}{b}\\right)\\\\\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A circular current carrying loop of radius $a$ carries a steady current. A constant electric charge is kept at the centre of the loop. The electric and magnetic fields, $\\vec{E}$ and $\\vec{B}$ respectively, at a distance $d$ vertically above the centre of the loop satisfy\n\t\\exyear{NET 2017}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\vec{E} \\perp \\vec{B}$\n\t\\task[\\textbf{B.}] $\\vec{E}=0$\n\t\\task[\\textbf{C.}]$\\vec{\\nabla}(\\vec{E} \\cdot \\vec{B})=0$\n\t\\task[\\textbf{D.}]$\\vec{\\nabla} \\cdot(\\vec{E} \\times \\vec{B})=0$\n\\end{tasks}\n\\begin{answer}\n\t$\\vec{E} \\times \\vec{B}=0 \\Rightarrow \\vec{\\nabla} \\cdot(\\vec{E} \\times \\vec{B})=0$\\\\\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item \\text { The loop shown in the figure below carries a steady current } I \\\\\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{diagram-20211011(11)-crop}\n\t\\end{figure}\n\t$\\text { The magnitude of the magnetic field at the point } O \\text { is }$\n\t\\exyear{NET 2018}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\mu_{0} I}{2 a}$\n\t\\task[\\textbf{B.}]$\\frac{\\mu_{0} I}{6 a}$\n\t\\task[\\textbf{C.}]$\\frac{\\mu_{0} I}{4 a}$\n\t\\task[\\textbf{D.}]$\\frac{\\mu_{0} I}{3 a}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t& B_{a}=\\frac{1}{2} \\frac{\\mu_{0} I}{2 a} \\odot,\\\\\n\t& B_{3 a}=\\frac{1}{2} \\frac{\\mu_{0} I}{2(3 a)} \\otimes \\\\\n\t&B=B_{a}-B_{3 a}=\\frac{\\mu_{0} I}{4 a}\\left(1-\\frac{1}{3}\\right)=\\frac{\\mu_{0} I}{6 a}\n\t\\end{align*}\n\tTHe correct option is \\textbf{(b)}\t\n\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item Two current-carrying circular loops, each of radius $R$, are placed perpendicular to each other, as shown in the figure.\n\t\n\tThe loop in the $x y$ - plane carries a current $I_{0}$ while that in the $x z$-plane carries a current $2 I_{0}$. The resulting magnetic field $\\vec{B}$ at the origin is\n\t\\exyear{NET 2018 dec}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20211011(12)-crop}\n\t\\end{figure}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\mu_{0} l_{0}}{2 R}[2 \\hat{j}+\\hat{k}]$ \n\t\\task[\\textbf{B.}]$\\frac{\\mu_{0} l_{0}}{2 R}[2 \\hat{j}-\\hat{k}]$\n\t\\task[\\textbf{C.}]$\\frac{\\mu_{0} l_{0}}{2 R}[-2 \\hat{j}+\\hat{k}]$\n\t\\task[\\textbf{D.}]$\\frac{\\mu_{0} l_{0}}{2 R}[-2 \\hat{j}-\\hat{k}]$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\intertext{Field due to loop in $x y$ plane is} \n\t\\vec{B}_{1}&=\\frac{\\mu_{0} I_{0}}{2 R} \\hat{z}\\\\\n\t\\intertext{Field due to loop in $x z$ plane is}\n\t\\vec{B}_{2}&=\\frac{\\mu_{0}\\left(2 I_{0}\\right)}{2 R}(-\\hat{y})\\\\\n\t\\text{Resultant field}\\\\\n\t \\vec{B}&=\\vec{B}_{1}+\\vec{B}_{2}=\\frac{\\mu_{0} I_{0}}{2 R}(-2 \\hat{y}+\\hat{z})\n\t\\end{align*}\n\tThe correct option is \\textbf{(c)}\t\n\\end{answer}\n\\end{enumerate}\n\\newpage\n\\begin{abox}\n\tPractice set 2 solutions\n\t\\end{abox}\n\\begin{enumerate}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item Two magnetic dipoles of magnitude $m$ each are placed in a plane as shown in figure The energy of interaction is given by\n\t\t\\exyear{GATE 2010}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210817(13)-crop}\n\t\t\t\\caption{}\n\t\t\t\\label{}\n\t\t\\end{figure}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}] Zero\n\t\t\\task[\\textbf{B.}]$\\frac{\\mu_{0} m^{2}}{4 \\pi d^{3}}$\n\t\t\\task[\\textbf{C.}]$\\frac{3 \\mu_{0} m^{2}}{2 \\pi d^{3}}$\n\t\t\\task[\\textbf{D.}]$-\\frac{3 \\mu_{0} m^{2}}{8 \\pi d^{3}}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tU&=\\frac{\\mu_{0}}{4 \\pi r^{3}}\\left[\\vec{m}_{1} \\cdot \\bar{m}_{2}-3\\left(\\vec{m}_{1} \\cdot \\hat{r}\\right)\\left(\\vec{m}_{2} \\cdot \\hat{r}\\right)\\right] \\\\\n\t\t\\text { Since } \\vec{m}_{1} \\perp \\vec{m}_{2} &\\Rightarrow \\vec{m}_{1} \\cdot \\vec{m}_{2}=0\\\\\n\t\t U&=\\frac{\\mu_{0}}{4 \\pi d^{3}}\\left[-3 \\times m \\cos 45^{0} \\times m \\cos 45^{0}\\right] \\\\\n\t\t\\Rightarrow U&=-\\frac{3 \\mu_{0} m^{2}}{8 \\pi d^{3}}\n\t\t\\end{align*}\t\n\t\tThe correct option is \\textbf{(d)}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item If a force $\\vec{F}$ is derivable from a potential function $V(r)$, where $r$ is the distance from the origin of the coordinate system, it follows that\n\t\t\\exyear{GATE 2011}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}]$\\vec{\\nabla} \\times \\vec{F}=0$\n\t\t\\task[\\textbf{B.}]$\\vec{\\nabla} \\cdot \\vec{F}=0$\n\t\t\\task[\\textbf{C.}]$\\vec{\\nabla} V=0$\n\t\t\\task[\\textbf{D.}]$\\nabla^{2} V=0$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tThe correct option is \\textbf{(a)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A uniform surface current is flowing in the positive $y$-direction over an infinite sheet lying in $x-y$ plane. The direction of the magnetic field is\n\t\t\\exyear{GATE 2011}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}]along $\\hat{i}$ for $z>0$ and along $-\\hat{i}$ for $z<0$\n\t\t\\task[\\textbf{B.}]along $\\hat{k}$ for $z>0$ and along $-\\hat{k}$ for $z<0$\n\t\t\\task[\\textbf{C.}]along $-\\hat{i}$ for $z>0$ and along $\\hat{i}$ for $z<0$\n\t\t\\task[\\textbf{D.}]along $-\\hat{k}$ for $z>0$ and along $\\hat{k}$ for $z<0$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tThe correct option is \\textbf{(a)}\n\t\\end{answer}\n\\begin{minipage}{\\textwidth}\n\t\\item A magnetic dipole of dipole moment $\\vec{m}$ is placed in a non-uniform magnetic field $\\vec{B} .$ If the position vector of the dipole is $\\vec{r}$, the torque acting on the dipole about the origin is\n\t\\exyear{GATE 2011}\n\\end{minipage}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\vec{r} \\times(\\vec{m} \\times \\vec{B})$\n\t\\task[\\textbf{B.}]$\\vec{r} \\times \\vec{\\nabla}(\\vec{m} \\cdot \\vec{B})$\n\t\\task[\\textbf{C.}]$\\vec{m} \\times \\vec{B}$\n\t\\task[\\textbf{D.}]$\\vec{m} \\times \\vec{B}+\\vec{r} \\times \\nabla(\\vec{m} \\cdot \\vec{B})$\n\\end{tasks}\n\\begin{answer}\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item Which of the following expressions for a vector potential $\\vec{A} \\underline{\\text { DOES NOT }}$ represent a uniform magnetic field of magnitude $B_{0}$ along the $z$-direction?\n\t\t\\exyear{GATE 2011}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}] $\\vec{A}=\\left(0, B_{0} x, 0\\right)$\n\t\t\\task[\\textbf{B.}]$\\vec{A}=\\left(-B_{0} y, 0,0\\right)$\n\t\t\\task[\\textbf{C.}]$\\vec{A}=\\left(\\frac{B_{0} x}{2}, \\frac{B_{0} y}{2}, 0\\right)$\n\t\t\\task[\\textbf{D.}] $\\vec{A}=\\left(-\\frac{B_{0} y}{2}, \\frac{B_{0} x}{2}, 0\\right)$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t$\\vec{B} \\neq \\vec{\\nabla} \\times \\vec{A}$\\\\\n\t\tThe correct option is \\textbf{(c)}\t\n\t\\end{answer}\n\t\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item In a constant magnetic field of $0.6$ Tesla along the $\\mathrm{z}$ direction, find the value of the path integral $\\oint \\vec{A} \\cdot \\overrightarrow{d l}$ in the units of (Tesla $m^{2}$ ) on a square loop of side length $(1 / \\sqrt{2})$ meters. The normal to the loop makes an angle of $60^{\\circ}$ to the z-axis, as shown in the figure.\\\\\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210817(19)-crop-crop}\n\t\t\\end{figure}\t\n\t\tThe answer should be up to two decimal places.\n\t\t\\exyear{GATE}\t\n\t\\end{minipage}\n\t\\begin{answer}\t\n\t\t$$\\oint \\vec{A} \\cdot \\overrightarrow{d l}=\\int_{S}(\\vec{\\nabla} \\times \\vec{A}) d \\vec{a}=\\int_{S} \\vec{B} \\cdot d \\vec{a}=B A \\cos 60^{0}=0.6 \\times\\left(\\frac{1}{\\sqrt{2}}\\right)^{2} \\times \\frac{1}{2}=0.15 T . m^{2}$$\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item The value of the magnetic field required to maintain non-relativistic protons of energy $1 \\mathrm{MeV}$ in a circular orbit of radius $100 \\mathrm{~mm}$ is Tesla\n\t\t\\exyear{GATE 2014}\n\t\\end{minipage}\n\t\\begin{answer}\n\t\\begin{align*}\t\n\tE&=\\frac{q^{2} B^{2} R^{2}}{2 m_{p}} \\Rightarrow 1.6 \\times 10^{-13}=\\frac{\\left(1.6 \\times 10^{-19}\\right)^{2} B^{2}(0.1)^{2}}{2\\left(1.67 \\times 10^{-27}\\right)}\\\\\n\t\\Rightarrow B^{2}&=\\frac{1.6 \\times 10^{-13} \\times 2\\left(1.67 \\times 10^{-27}\\right)}{\\left(1.6 \\times 10^{-19}\\right)^{2}(0.1)^{2}} \\\\\n\t\\Rightarrow B^{2}&=\\frac{10^{-13} \\times 2\\left(1.67 \\times 10^{-27}\\right)}{\\left(1.6 \\times 10^{-38}\\right)(0.01)}=\\frac{3.34 \\times 10^{-40}}{1.6 \\times 10^{-40}}=2.08\\\\\n\t\\Rightarrow B&=\\sqrt{2.08} \\text { Tesla }=1.44 \\text { Tesla }\n\t\\end{align*}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item Given that the magnetic flux through the closed loop $P Q R S P$ is $\\phi$. If $\\int_{P}^{R} \\vec{A} \\cdot \\vec{d} l=\\phi_{1}$ along $P Q R$, the value of $\\int^{R} \\vec{A} \\cdot \\vec{d} l$ along $P S R$ is\n\t\t\\exyear{GATE 2015}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210818(2)-crop}\n\t\t\\end{figure}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}](a) $\\phi-\\phi_{1}$\n\t\t\\task[\\textbf{B.}] $\\phi_{1}-\\phi$\n\t\t\\task[\\textbf{C.}]$-\\phi_{1}$\n\t\t\\task[\\textbf{D.}] $\\phi_{1}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t$$\\phi=\\int_{s} \\vec{B} \\cdot d \\vec{a}=\\oint \\vec{A} \\cdot d \\vec{l}=\\int_{P}^{R} \\vec{A} \\cdot d \\vec{l}+\\int_{R}^{P} \\vec{A} \\cdot d \\vec{l} \\Rightarrow \\phi=\\phi_{1}-\\int_{P}^{R} \\vec{A} \\cdot d \\vec{l} \\Rightarrow \\int_{P}^{R} \\vec{A} \\cdot d \\vec{l}=\\phi_{1}-\\phi$$\n\t\tThe correct option is \\textbf{(b)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item Which of the following magnetic vector potentials gives rise to a uniform magnetic field $B_{0} \\hat{k} ?$\n\t\t\\exyear{GATE 2016}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $B_{0} z \\hat{k}$\n\t\t\\task[\\textbf{B.}]$-B_{0} x \\hat{j}$\n\t\t\\task[\\textbf{C.}]$\\frac{B_{0}}{2}(-y \\hat{i}+x \\hat{j})$\n\t\t\\task[\\textbf{D.}]$\\frac{B_{0}}{2}(y \\hat{i}+x \\hat{j})$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t(a) $\\vec{\\nabla} \\times \\vec{A}=0$\\\\\n\t\t(b) $\\vec{\\nabla} \\times \\vec{A}=-B_{0} \\hat{k}$\\\\\n\t\t(c) $\\vec{\\nabla} \\times \\vec{A}=B_{0} \\hat{k}$\\\\\n\t\t(d) $\\vec{\\nabla} \\times \\vec{A}=0$\\\\\n\t\tThe correct option is \\textbf{(c)}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item The magnitude of the magnetic dipole moment associated with a square shaped loop carrying a steady current $I$ is $m$. If this loop is changed to a circular shape with the same current $I$ passing through it, the magnetic dipole moment becomes $\\frac{p m}{\\pi} .$ The value of $p$ is\n\t\t\\exyear{GATE 2016}\n\t\\end{minipage}\n\t\\begin{answer}\n\t\tMagnetic dipole moment associated with a square shaped loop (let side is $a$ ) carrying a steady current $I$ is $m=I a^{2}$.\n\t\t\n\t\tMagnetic dipole moment associated with a circular shaped loop (let radius is $r$ ) carrying a steady current $I$ is $m^{\\prime}=I \\pi r^{2}$.\n\t\tHere $4 a=2 \\pi r \\Rightarrow r=\\frac{2 a}{\\pi} \\Rightarrow m^{\\prime}=I \\pi r^{2}=I \\pi\\left(\\frac{2 a}{\\pi}\\right)^{2}=\\frac{4 I a^{2}}{\\pi}=\\frac{4 m}{\\pi}$\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item An infinite solenoid carries a time varying current $I(t)=A t^{2}$, with $A \\neq 0 .$ The axis of the solenoid is along the $\\hat{z}$ direction. $\\hat{r}$ and $\\hat{\\theta}$ are the usual radial and polar directions in cylindrical polar coordinates. $\\vec{B}=B_{r} \\hat{r}+B_{\\theta} \\hat{\\theta}+B_{z} \\hat{z}$ is the magnetic field at a point outside the solenoid. Which one of the following statements is true?\n\t\t\\exyear{GATE 2017}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $B_{r}=0, B_{\\theta}=0, B_{z}=0$\n\t\t\\task[\\textbf{B.}]$B_{r} \\neq 0, B_{\\theta} \\neq 0, B_{z}=0$\n\t\t\\task[\\textbf{C.}] $B_{r} \\neq 0, B_{\\theta} \\neq 0, B_{z} \\neq 0$\n\t\t\\task[\\textbf{D.}] $B_{r}=0, B_{\\theta}=0, B_{z} \\neq 0$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tThe correct option is \\textbf{(d)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item An infinitely long straight wire is carrying a steady current $I$. The ratio of magnetic energy density at distance $r_{1}$ to that at $r_{2}\\left(=2 r_{1}\\right)$ from the wire is\n\t\t\\exyear{GATE 2018}\n\t\\end{minipage}\n\t\\begin{answer}\n\t\t$$ u_{B}=\\frac{B^{2}}{2 \\mu_{0}} \\propto \\frac{1}{r^{2}} \\Rightarrow \\frac{u_{B 1}}{u_{B 2}}=\\frac{r_{2}^{2}}{r_{1}^{2}}=\\frac{\\left(2 r_{1}\\right)}{r_{1}^{2}}=4$$\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A constant and uniform magnetic field $\\vec{B}=B_{0} \\hat{k}$ pervades all space. Which one of the following is the correct choice for the vector potential in Coulomb gauge?\n\t\t\\exyear{GATE 2018}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}] $-B_{0}(x+y) \\hat{i}$\n\t\t\\task[\\textbf{B.}]$B_{0}(x+y) \\hat{j}$\n\t\t\\task[\\textbf{C.}] $B_{0} x \\hat{j}$\n\t\t\\task[\\textbf{D.}]$-\\frac{1}{2} B_{0}(x \\hat{i}-y \\hat{j})$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tCheck option (c),\n\t\t$$\n\t\t\\vec{\\nabla} \\cdot \\vec{A}=0, \\vec{B}=\\vec{\\nabla} \\times \\vec{A}=B_{0} \\hat{k}\n\t\t$$\n\t\tThe correct option is \\textbf{(c)}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item  A solid cylinder of radius $R$ has total charge $Q$ distributed uniformly over its volume. It is rotating about its axis with angular speed $\\omega$. The magnitude of the total magnetic moment of the cylinder is\n\t\t\\exyear{GATE 2019}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}](a) $Q R^{2} \\omega$\n\t\t\\task[\\textbf{B.}]$\\frac{1}{2} Q R^{2} \\omega$\n\t\t\\task[\\textbf{C.}]$\\frac{1}{4} Q R^{2} \\omega$\n\t\t\\task[\\textbf{D.}]$\\frac{1}{8} Q R^{2} \\omega$\n\t\\end{tasks}\n\t\\begin{answer}\n\\begin{align*}\n\t\\intertext{\tMagnetic moment due to disc} \n\\mu&=\\frac{\\pi \\sigma \\omega R^{4}}{4}\\\\\n\\text{\tDue to cylinder}\\\\\n d \\mu&=\\frac{\\pi \\omega R^{4}}{4}(\\rho d z) \\quad(\\sigma \\rightarrow \\rho d z)\\\\\n\\mu&=\\frac{\\pi \\omega R^{4}}{4} \\int_{0}^{L} \\frac{Q}{\\pi R^{2} L} d z=\\frac{Q \\omega R^{4}}{4}\t\n\\end{align*}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item An infinitely long wire parallel to the $x$-axis is kept at $z=d$ and carries a current $I$ in the positive $x$ direction above a superconductor filling the region $z \\leq 0$ (see figure). The magnetic field $\\vec{B}$ inside the superconductor is zero so that the field just outside the superconductor is parallel to its surface. The magnetic field due to this configuration at a point $(x, y, z>0)$ is\n\t\t\\exyear{GATE 2019}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=5cm,width=5cm]{diagram-20210818(14)-crop-crop}\n\t\t\t\\caption{}\n\t\t\t\\label{}\n\t\t\\end{figure}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}]$\\left(\\frac{\\mu_{0} I}{2 \\pi}\\right) \\frac{-(z-d) \\hat{j}+y \\hat{k}}{\\left[y^{2}+(z-d)^{2}\\right]}$\n\t\t\\task[\\textbf{B.}]$\\left(\\frac{\\mu_{0} I}{2 \\pi}\\right)\\left[\\frac{-(z-d) \\hat{j}+y \\hat{k}}{y^{2}+(z-d)^{2}}+\\frac{(z+d) \\hat{j}-y \\hat{k}}{y^{2}+(z+d)^{2}}\\right]$\n\t\t\\task[\\textbf{C.}]$\\text { (c) }\\left(\\frac{\\mu_{0} I}{2 \\pi}\\right)\\left[\\frac{-(z-d) \\hat{j}+y \\hat{k}}{y^{2}+(z-d)^{2}}-\\frac{(z+d) \\hat{j}-y \\hat{k}}{y^{2}+(z+d)^{2}}\\right]$\n\t\t\\task[\\textbf{D.}]$\\text { (d) }\\left(\\frac{\\mu_{0} I}{2 \\pi}\\right)\\left[\\frac{y \\hat{j}+(z-d) \\hat{k}}{y^{2}+(z-d)^{2}}+\\frac{y \\hat{j}-(z+d) \\hat{k}}{y^{2}+(z+d)^{2}}\\right]$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t$\\text { Verify that } \\vec{B}=0, \\text { when } d=0$\\\\\n\t\tThe correct option is \\textbf{(b)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item The vector potential inside a long solenoid with $n$ turns per unit length and carrying current $I$, written in cylindrical coordinates is $\\vec{A}(s, \\phi, z)=\\frac{\\mu_{0} n I}{2} s \\hat{\\phi}$. If the term $\\frac{\\mu_{0} n I}{2} s(\\alpha \\cos \\phi \\hat{\\phi}+\\beta \\sin \\phi \\hat{s})$, where $\\alpha \\neq 0, \\beta \\neq 0$ is added to $\\vec{A}(S, \\phi, z)$, the magnetic field remains the same if\n\t\t\\exyear{GATE 2019}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}]$\\alpha=\\beta$\n\t\t\\task[\\textbf{B.}]$\\alpha=-\\beta$\n\t\t\\task[\\textbf{C.}]$\\alpha=2 \\beta$\n\t\t\\task[\\textbf{D.}]$\\alpha=\\frac{\\beta}{2}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t&\\text { Solution: } \\vec{B}=\\vec{\\nabla} \\times \\vec{A}=\\frac{1}{r}\\left|\\begin{array}{ccc}\n\t\t\\hat{r} & r \\hat{\\phi} & \\hat{z} \\\\\n\t\t\\frac{\\partial}{\\partial r} & \\frac{\\partial}{\\partial \\phi} & \\frac{\\partial}{\\partial z} \\\\\n\t\tA_{r} & r A_{\\phi} & 0\n\t\t\\end{array}\\right|=\\mu_{0} n I \\hat{z} \\\\\n\t\t&\\vec{B}^{\\prime}=\\vec{\\nabla} \\times \\vec{A}^{\\prime}=\\frac{1}{r}\\left|\\begin{array}{ccc}\n\t\t\\hat{r} & r \\hat{\\phi} & \\hat{z} \\\\\n\t\t\\frac{\\partial}{\\partial r} & \\frac{\\partial}{\\partial \\phi} & \\frac{\\partial}{\\partial z} \\\\\n\t\tA_{r} & r A_{\\phi} & 0\n\t\t\\end{array}\\right|=\\mu_{0} n I\\left[(\\alpha \\cos \\phi+1)-\\frac{\\beta \\cos \\phi}{2}\\right] \\hat{z} \\\\\n\t\t&\\text { Equate } \\vec{B}^{\\prime}=\\vec{B} \\Rightarrow\\left[(\\alpha \\cos \\phi+1)-\\frac{\\beta \\cos \\phi}{2}\\right]=\\mu_{0} n I \\\\\n\t\t&\\Rightarrow \\alpha \\cos \\phi=\\frac{\\beta}{2} \\cos \\phi \\Rightarrow \\alpha=\\frac{\\beta}{2}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(d)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A magnetic field $\\vec{B}=B_{0}(\\hat{i}+2 \\hat{j}-4 \\hat{k})$ exists at point. If a test charge moving with a velocity, $\\vec{v}=v_{0}(3 \\hat{i}-\\hat{j}+2 \\hat{k})$ experiences no force at a certain point, the electric field at that point in SI units is\n\t\t\\exyear{JEST 2012}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\vec{E}=-v_{0} B_{0}(3 \\hat{i}-2 \\hat{j}-4 \\hat{k})$\n\t\t\\task[\\textbf{B.}]$\\vec{E}=-v_{0} B_{0}(\\hat{i}+\\hat{j}+7 \\hat{k})$\n\t\t\\task[\\textbf{C.}]$\\vec{E}=v_{0} B_{0}(14 \\hat{j}+7 \\hat{k})$\n\t\t\\task[\\textbf{D.}]$\\vec{E}=-v_{0} B_{0}(14 \\hat{j}+7 \\hat{k})$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t \\begin{align*}\n\t\t\\vec{F} &=q[\\vec{E}+\\vec{v} \\times \\vec{B}]=0 \\Rightarrow \\vec{E}=-(\\vec{v} \\times \\vec{B}) \\\\\n\t\t\\Rightarrow \\vec{E} &=-v_{0} B_{0}\\{(4-4) \\hat{i}+(2+12) \\hat{j}+(6+1) \\hat{k}\\}\\\\\n\t\t&=-v_{0} B_{0}(14 \\hat{j}+7 \\hat{k})\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A small magnet is dropped down a long vertical copper tube in a uniform gravitational field. After a long time, the magnet\n\t\t\\exyear{JEST 2012}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] attains a constant velocity\n\t\t\\task[\\textbf{B.}] moves with a constant acceleration\n\t\t\\task[\\textbf{C.}] moves with a constant deceleration\n\t\t\\task[\\textbf{D.}]executes simple harmonic motion\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tThe correct option is \\textbf{(a)}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A thin uniform ring carrying charge $Q$ and mass $M$ rotates about its axis. What is the gyromagnetic ratio (defined as ratio of magnetic dipole moment to the angular momentum) of this ring?\n\t\t\\exyear{JEST 2013}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\frac{Q}{2 \\pi M}$\n\t\t\\task[\\textbf{B.}]$\\frac{Q}{M}$\n\t\t\\task[\\textbf{C.}]$\\frac{Q}{2 M}$\n\t\t\\task[\\textbf{D.}]$\\frac{Q}{\\pi M}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tMagnetic dipole moment $M^{\\prime}=I A=\\frac{Q}{T} \\pi r^{2} \\Rightarrow \\frac{Q}{2 \\pi T} \\times 2 \\pi \\times \\pi r^{2}=\\frac{Q \\omega r^{2}}{2}$\\\\\n\t\tAngular momentum $J=M r^{2} \\omega \\Rightarrow \\frac{M^{\\prime}}{J}=\\frac{Q}{2 M}$\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item The electric and magnetic field caused by an accelerated charged particle are found to scale as $E \\propto r^{-n}$ and $B \\propto r^{-m}$ at large distances. What are the value of $n$ and $m$ ?\n\t\t\\exyear{JEST 2013}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $n=1, m=2$\n\t\t\\task[\\textbf{B.}] $n=2, m=1$\n\t\t\\task[\\textbf{C.}]$n=1, m=1$\n\t\t\\task[\\textbf{D.}]$n=2, m=2$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\\begin{align*}\n\t\t\\intertext{For large distance}\n\tF&=\\frac{q a \\sin \\theta}{r}\\\\\n\t, B&=\\frac{q a \\sin \\theta}{r}\\\\\n\t\\Rightarrow E &\\propto \\frac{1}{r},\\\\\n\tB &\\propto \\frac{1}{r} \\\\\n\t\\text{So} \\quad m&=n=1\n\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A system of two circular co-axial coils carrying equal currents $I$ along same direction having equal radius $R$ and separated by a distance $R$ (as shown in the figure below). The magnitude of magnetic field at the midpoint $P$ is given by\n\t\t\\exyear{JEST 2014}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210809(7)-crop}\n\t\t\t\\caption{}\n\t\t\t\\label{}\n\t\t\\end{figure}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}](a) $\\frac{\\mu_{0} I}{2 \\sqrt{2} R}$\n\t\t\\task[\\textbf{B.}]$\\frac{4 \\mu_{0} I}{5 \\sqrt{5} R}$\n\t\t\\task[\\textbf{C.}]$\\frac{8 \\mu_{0} I}{5 \\sqrt{5} R}$\n\t\t\\task[\\textbf{D.}] 0\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\because B&=\\frac{\\mu_{0} I R^{2}}{2\\left(R^{2}+d^{2}\\right)^{\\frac{3}{2}}}\\\\ B_{1}&=\\frac{\\mu_{0} I R^{2}}{2\\left(R^{2}+\\frac{R^{2}}{4}\\right)^{\\frac{3}{2}}}\\\\\n\t\tB_{2}&=\\frac{\\mu_{0} I R^{2}}{2\\left(R^{2}+\\frac{R^{2}}{4}\\right)^{\\frac{3}{2}}} \\because d=\\frac{R}{2} \\\\\n\t\tB&=B_{1}+B_{2}\\\\\n\t\t&=\\frac{\\mu_{0} I \\times 2}{2 R\\left(\\frac{5}{4}\\right)^{\\frac{3}{2}}}\\\\\n\t\tB&=\\frac{\\mu_{0} I 4^{\\frac{3}{2}}}{R \\quad 5^{\\frac{3}{2}}}=\\frac{8 \\mu_{0} I}{5 \\sqrt{5} R}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\t\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A charged particle is released at time $t=0$, from the origin in the presence of uniform static electric and magnetic fields given by $E=E_{0} \\hat{y}$ and $B=B_{0} \\hat{z}$ respectively. Which of the following statements is true for $t>0$ ?\n\t\t\\exyear{JEST 2015}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] The particle moves along the $x$-axis.\n\t\t\\task[\\textbf{B.}]The particle moves in a circular orbit.\n\t\t\\task[\\textbf{C.}]The particle moves in the $(x, y)$ plane.\n\t\t\\task[\\textbf{D.}] Particle moves in the $(y, z)$ plane\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tIn a cycloid charged particle will be always confined in a plane perpendicular to B.\\\\\n\t\tThe correct option is \\textbf{(c)}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item The strength of magnetic field at the center of a regular hexagon with sides of length $a$ carrying a steady current $I$ is:\n\t\t\\exyear{JEST 2016}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\frac{\\mu_{0} I}{\\sqrt{3} \\pi a}$ \n\t\t\\task[\\textbf{B.}]$\\frac{\\sqrt{6} \\mu_{0} I}{\\pi a}$\n\t\t\\task[\\textbf{C.}]$\\frac{3 \\mu_{0} I}{\\pi a}$\n\t\t\\task[\\textbf{D.}]$\\frac{\\sqrt{3} \\mu_{0} I}{\\pi a}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=6cm]{jest 3-crop}\n\t\t\\end{figure}\n\t\t\\begin{align*}\n\t\td&=a \\cos 30^{\\circ}=\\frac{\\sqrt{3}}{2} a \\\\\n\t\t\\because B&=\\frac{\\mu_{0} I}{4 \\pi d}\\left(\\sin \\theta_{2}-\\sin \\theta_{1}\\right) \\\\\n\t\t\\Rightarrow B_{1}&=\\frac{\\mu_{0} I}{4 \\pi d} 2 \\sin 30^{\\circ}=\\frac{\\mu_{0} I}{4 \\pi \\frac{\\sqrt{3}}{2} a} 2 \\sin 30^{\\circ}=\\frac{\\mu_{0} I}{2 \\sqrt{3} \\pi a} \\\\\n\t\t\\Rightarrow B&=6 B_{1}=6 \\times \\frac{\\mu_{0} I}{2 \\sqrt{3} \\pi a}=\\frac{3 \\mu_{0} I}{\\sqrt{3} \\pi a}=\\frac{\\sqrt{3} \\mu_{0} I}{\\pi a}\n\t\t\\end{align*}\n\t\\end{answer}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item A wire with uniform line charge density $\\lambda$ per unit length carries a current $I$ as shown in the figure. Take the permittivity and permeability of the medium to be $\\varepsilon_{0}=\\mu_{0}=1 . \\mathrm{A}$ particle of charge $q$ is at a distance $r$ and is travelling along a trajectory parallel to the wire. What is the speed of the charge?\n\t\t\\exyear{JEST 2019}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=4cm,width=6cm]{jest-crop}\n\t\t\\end{figure}\n\t\\end{minipage}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\frac{\\lambda}{I}$ \n\t\t\\task[\\textbf{B.}]$\\frac{\\lambda}{2 I}$\n\t\t\\task[\\textbf{C.}]$\\frac{\\lambda}{3 I}$\n\t\t\\task[\\textbf{D.}]$\\frac{4 \\lambda}{I}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=3cm,width=5cm]{jest2-crop(1)}\n\t\t\\end{figure}\n\t\\begin{align*}\n\t\tE&=\\frac{\\lambda}{2 \\pi \\varepsilon_{0} r} \\text { and } B=\\frac{\\mu_{0} I}{2 \\pi r}\\\\\n\t\\intertext{Net force on  $q$ is zero i.e.}\n\t\\vec{F}&=0\\\\\n\t\\Rightarrow q[\\vec{E}+(\\vec{v} \\times \\vec{B})]&=0\\\\\n\tE&=v B \\Rightarrow \\frac{\\lambda}{2 \\pi \\varepsilon_{0} r}=v \\frac{\\mu_{0} I}{2 \\pi r} \\Rightarrow v=\\frac{\\lambda}{I} \\quad \\because \\varepsilon_{0}=\\mu_{0}=1\n\t\\end{align*}\nThe correct option is \\textbf{(a)}\t\n\t\\end{answer}\n\\end{enumerate}", "meta": {"hexsha": "921d3f57d72b2fa28309250c369b24d2f9fd1456", "size": 37413, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Electrodynamics- CSIR/chapter/solution magnetostatics.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Electrodynamics- CSIR/chapter/solution magnetostatics.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Electrodynamics- CSIR/chapter/solution magnetostatics.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.1514745308, "max_line_length": 421, "alphanum_fraction": 0.62275145, "num_tokens": 15644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250374, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.4331329428536646}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\section*{NYU Physics I---Problem Set 10}\n\nDue Thursday 2018 November 15 at the beginning of lecture.\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n\\textsl{(a)}~A car of mass $M$ is moving at speed $v$ in the $x$\ndirection. Its center of mass is a height $h$ above the ground.  What\nis the angular momentum of the car with respect to a reference point\n\\emph{on the ground}?\n\n\\textsl{(b)}~If this same car is accelerating at acceleration $a$\nin the $x$ direction, then its angular momentum is changing with time,\nright? If so, there must be a net torque on the car? What must be\nthe magnitude of that net torque? Again, answer this with respect\nto a reference point \\emph{on the ground}.\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n\\textsl{(a)}~A figure skater spins in place on frictionless ice at\nangular speed $\\omega_i$ with her hands outstretched.  She has a total\nmoment of inertia $I_i$.  As the skater draws her hands into her body,\nher moment of inertia decreases to $I_f=I_i/2$.  Does her kinetic\nenergy $K$ increase, decrease, or stay the same?  If it increases,\nwhere does the energy come from?  If it decreases, where does the\nenergy go to?  \\emph{Explain all your answers concisely but clearly:\nWhat is conserved? That is, think in terms of conserved quantities.}\n\n\\textsl{(b)}~Now estimate the moments of inertia: $I_i$ of an ice\nskater with her hands outstretched, and $I_f$ of an ice skater with\nher hands drawn in.  Is the factor of 2 used in part \\textsl{(a)}\nreasonable?\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}\\label{cue}%\n\\textsl{(a)}~Immediately after being hit, at $t=0$, a cue ball of mass\n$M$ and radius $R$ slides along the felt at speed $v_i$, not rotating\nat all.  As time goes on, the ball slows down (because of friction)\nand, at the same time, starts to spin.  Draw a free-body diagram for\nthe cue ball.  At what time $t_\\mathrm{r}$ does the ball get to the\nsituation of ``rolling without slipping''?  Assume that there is a\ncoefficient $\\mu$ of sliding friction. You will have to look up (or\ncompute) the moment of inertia $I$ for a uniform sphere.\n\n\\textsl{(b)}~Plot $v(t)$ and $R\\,\\omega(t)$ vs $t$ on a single plot.\n\\emph{Note that the two things I have asked you to plot have the same\ndimensions.}  Clearly label $t_\\mathrm{r}$ on your diagram.\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n\\textsl{(a)}~A hockey puck (a uniform disk of mass $m$, radius $r$,\nand thickness $t$), slides without friction on ice with initial speed\n$v_0$.  It strikes an identical puck tangentially, as shown in the\nfigure, and sticks to it.  The second puck is initially at rest and\nalso can slide without friction.  What is the final (linear) velocity\n(speed $v$ and direction) of the stuck-together pucks?  What is the\nmoment of inertia $I_f$ and final angular speed of rotation $\\omega$\nof the system around its center of mass?  What fraction of the initial\nkinetic energy (if any) is lost; \\textit{ie,} what is $[K_i-K_f]/K_i$?\n\\\\ \\rule{0.25\\textwidth}{0pt}\n\\resizebox{0.50\\textwidth}{!}{\\includegraphics{tangpucks.eps}}\n\\\\\n\n\\emph{Draw a clear diagram with a clearly labeled reference point used\nto compute the angular momentum; recall that any angular momentum\ncalculation is with respect to your chosen origin.}\n\n\\textsl{(b)}~If the pucks had hit dead-on, the stuck-together pucks,\nafter the collision, would not be rotating.  Which of your answers\n($v$, $\\omega$, and $[K_i-K_f]/K_i$) will be different in this case?\nIf the fractional loss in kinetic energy is different, explain where\nthe difference in energy went.\n\n\\paragraph{Extra Problem (will not be graded for credit):}%\nIn \\problemname~\\ref{cue}, between the initial hit of the cue ball by the cue (that is, when the\ncue ball wasn't rotating at all) and the end of the cue ball\nslide (that is, when the cue ball switches to rolling without\nslipping), how much rotational kinetic energy ($I\\,\\omega^2 / 2$) was\ncreated? How much linear kinetic energy ($m\\,v^2 / 2$) was lost? How\nmuch heat was generated? This extra problem refers to the pool problem\nabove.\n\n\\end{document}\n", "meta": {"hexsha": "79dfcabfde03f44732d63d738e2e08b8dd150e43", "size": 4198, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/physics1_ps10.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/physics1_ps10.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/physics1_ps10.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.9761904762, "max_line_length": 96, "alphanum_fraction": 0.747498809, "num_tokens": 1184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301064, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.4330784352698502}}
{"text": "\n\\chapter{Particle Physics Theory}\nThere are four so called \"fundamental forces\" that are able to describe the interactions and dynamics of every single thing in the universe. \n\n\\begin{itemize}\n    \\item Electromagnetism: Describes the propagation of light and pushing and pulling of charges around each other. This force is responsible for the majority of what we as humans see and feel in everyday life. Lifetimes of decay's coming from this force are $10^{-20} - 10^{-16}$ s. $\\pi^0\\rightarrow \\gamma\\gamma$ decay's through this force in $10^{-17}$ s.\n    \\item The Weak Force: This describes how radioactive decay happens within a nucleus and is responsible for the strange particle called the neutrino. In some way, this force is \"unified\" with electromagnetism at some large energy scale, meaning the two merge together into one. Lifetimes of decay's coming from this force are $10^{-13} - 10^{3}$ s. $\\pi^{+/-} \\rightarrow \\mu+\\nu$ decay from this force in a much longer time of $10^{-8}$ s.\n    \\item The Strong Force: This is what keeps the constituents of a nucleus (protons) from getting pushed away from each other due to electromagnetic repulsion (they are all the same charge). This force is weak at short distances, but gets stronger as you get further away and is described by Quantum Chromodynamics. Lifetimes of decay's coming from this force are $10^{-23} - 10^{-20}$ s. \n    \\item Gravity: This is what pulled the earth together and keeps you from flying off into space. It is extremely weak when compared to electromagnetism. Each of the other forces can be put into a framework consistent with Quantum Mechanics except Gravity.\n\\end{itemize}\n\n\n%\\begin{center}\n%\\begin{tabular}{ | c | c| c |} \n%\\hline\n% Particle & Mass & Rule of thumb\\\\ \\hline\n% Electron & 0.5 MeV $m_e$ & \\\\ \n% Proton & 1 GeV  &$m_p \\approx 2000 ~m_e$\\\\\n%Muon & 0.1 GeV & $m_\\mu \\approx 200 ~m_e$  \\\\ \n%\\hline\n%\\end{tabular}\n%\\end{center}\n\n\\section{Continuum Mechanics}\nEach of the three forces we actually understand in detail (Electromagnetism, the Weak Force, and the Strong Force) can be described by something called Quantum Field Theory (QFT). To understand how any of it makes sense, it is nice to begin with a set of things that are simpler to understand then build on what we know. Continuum mechanics deals with the ``field\" aspect of QFT, and is typically the aspect that people have seen the least of. \n\nParticle physics typically uses Lagrangian mechanics, since the Lagrangians can be made relativistically invariant, as opposed to  Hamiltonians (an energy) which cannot be.\n\nImagine a set of identical masses $m$ attached to each other by identical springs with constant $k$ all put in a row. The Lagrangian, which tells us how each mass will move, is simply given by the sum of each masses kinetic energy $T$ minus its potential energy $V$ from the spring it is attached to\n\n\\begin{align}\n    L = T - V = \\frac{1}{2}\\sum_i \\Big[m \\dot{x}_i^2 - k(x_i - x_{i+1})^2\\Big]\n\\end{align}\nThe meaning of continuum mechanics is that we take the distance between the springs to be effectively zero. This has an effect of making the potential term turn into\n\\begin{align}\n    V_i =\\lim_{a\\to 0} ~k a^2 \\Big(\\frac{x_i - x_{i+1}}{a}\\Big)^2 = ka^2 \\Big(\\frac{d x_i}{d a}\\Big)^2\n\\end{align}\nThe quantity $ka = Y$ turns out to be a physical quantity independent of size called Young's modulus which is derived from Hooke's law \\cite{goldstein}. This allows us to write the Lagrangian as \n\\begin{align}\n    L = \\lim_{a\\to 0} \\frac{1}{2}\\sum_i a\\Big[\\mu \\dot{x}_i^2 - Y\\Big(\\frac{d x_i}{d a}\\Big)^2\\Big]\n\\end{align}\nWith $\\mu = m/a$, mass per unit length. Since $a$ is infinitesimally small, what we are really doing is integrating over all the different masses along the line. To match notation later, we write the displacement of each mass from it's equilibrium position as $\\phi$ and the position of wherever we are along the chain as $x$. Our Lagrangian thus becomes\n\\begin{align}\n    L = \\frac{1}{2}\\int dx \\Big[\\mu \\dot{\\phi}^2 - Y\\Big(\\frac{d\\phi}{d x}\\Big)^2\\Big]\n\\end{align}\nThis was sleight of hand, what we have actually done is create a ``field\" of the harmonic oscillators, i.e. for each point in space, there is a specific value of the spring's displacement from zero. We describe the integrand as the ``Lagrangian Density\" which generalizes to three dimensions with\n\\begin{align}\n    L = \\int dx^3 ~\\mathcal{L}\n\\end{align}\nWhat this tells us is that in general, a given Lagrangian (or equivalently a Lagrangian density) can be a function of\n\n\\begin{align}\n    \\mathcal{L} = \\mathcal{L}\\Big(\\phi, \\frac{d\\phi}{dx},\\frac{d\\phi}{dt}, x,t\\Big)\n\\end{align}\nHamilton's principle says that the Action of any physical system should be minimized to have it occur, so we use the standard tricks of Classical Mechanics to solve for the Euler-Lagrange equations of the system.\n\\begin{align}\n    \\delta S = \\delta\\int_1^2 dt \\int dx ~\\mathcal{L} = 0\n\\end{align}\nTypically, a system of $n$ degrees of freedom have $n$ Lagrange equations of motion, so one would expect an infinite number of Euler-Lagrange equations in the limit of a spring at each point. It turns out that by considering $d\\phi/dx$ as a variable and re-deriving the equations of motion, we find just one \\cite{goldstein}, of the form\n\\begin{align}\n    \\frac{d}{dt}\\left(\\frac{\\partial\\mathcal{L}}{\\partial\\frac{d\\phi}{dt}}\\right) + \\frac{d}{dx}\\left(\\frac{\\partial\\mathcal{L}}{\\partial \\frac{d\\phi}{dx}}\\right) - \\frac{\\partial\\mathcal{L}}{\\partial \\phi} = 0\n\\end{align}\n\nDeriving the equations of motion for a three dimensional case is straightforward and gives us another term for each spatial component. It is typical to use four-dimensional space coordinates to represent the equations of motion with\n\\begin{align}\n    x^\\mu = (x^0, x^1, x^2, x^3) = (t, x, y,z)\n\\end{align}\nIn units where $c=1$, typical in Particle Physics. We can use a shorthand for derivatives with \n\\begin{align}\n    \\partial^\\mu \\equiv \\frac{\\partial}{\\partial x_\\mu} && \\partial_\\mu \\equiv \\frac{\\partial}{\\partial x^\\mu}\n\\end{align}\nSo we can write the three dimensional case concisely as\n\\begin{align}\n    \\frac{d}{dt}\\left(\\frac{\\partial\\mathcal{L}}{\\partial\\frac{d\\phi}{dt}}\\right) + \\frac{d}{dx}\\left(\\frac{\\partial\\mathcal{L}}{\\partial \\frac{d\\phi}{dx}}\\right) +\\frac{d}{dy}\\left(\\frac{\\partial\\mathcal{L}}{\\partial \\frac{d\\phi}{dy}}\\right) + \\frac{d}{dz}\\left(\\frac{\\partial\\mathcal{L}}{\\partial \\frac{d\\phi}{dz}}\\right) = \\partial_\\mu \\left(\\frac{\\partial\\mathcal{L}}{\\partial(\\partial_\\mu\\phi)}\\right)\n\\end{align}\nThus the Euler-Lagrange equations for a field in three dimensions is given by\n\\begin{align}\\label{euler-lagrange}\n    \\boxed{\\partial_\\mu \\left(\\frac{\\partial\\mathcal{L}}{\\partial(\\partial_\\mu\\phi)}\\right) - \\frac{\\partial\\mathcal{L}}{\\partial \\phi} = 0}\n\\end{align}\nUsing this notation, we can even simplify the form of the Lagrangian itself. In three dimensions, the Lagrangian for a field of harmonic oscillators becomes\n\\begin{align}\\label{harm-osc-lagrange}\n    \\mathcal{L} = \\frac{1}{2}(\\partial_\\mu\\phi)(\\partial^\\mu \\phi) \\equiv \\frac{1}{2}(\\partial\\phi)^2\n\\end{align}\n\n\\section{Noether's Theorem}\n\n\nNoether's theorem is of critical importance in modern theoretical physics and tells us that for every symmetry of the action, we will have a conserved quantity that is associated with it. Let's consider whatever it is we want to do to the system as a change in the field $\\phi$ at any point $x$. We can even think of changing the coordinates themselves as changing the field itself at any position or time.\n\n\\begin{align}\n    \\phi'(x) = \\phi(x) + \\delta\\phi(x)\n\\end{align}\nSince our Lagrangian is written in terms of these fields, in general, we expect a change it how it looks as well\n\n\\begin{align}\\label{lprime}\n    \\mathcal{L}'(x) = \\mathcal{L}(x) +\\delta\\mathcal{L}(x)\n\\end{align}\nThis will also amount to a change in our Action, with\n\n\\begin{align}\\label{daction}\n    \\delta S = \\int d^4x~\\delta\\mathcal{L}(x) \n\\end{align}\n\nWe can expand the change in the Lagrangian to first order in the change of the fields, since we consider only an infinitesimal change in our field.\n\n\\begin{align}\n    \\delta\\mathcal{L} &= \\frac{\\partial\\mathcal{L}(x)}{\\partial\\phi}\\delta\\phi + \\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial_\\mu\\phi)}(\\partial_\\mu\\delta\\phi) \\\\\n    &= \\left(\\frac{\\partial\\mathcal{L}(x)}{\\partial\\phi}- \\partial_\\mu\\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial_\\mu\\phi)}\\right)\\delta\\phi + \\partial_\\mu\\left(\\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial_\\mu\\phi)}\\delta\\phi\\right)\n\\end{align}\nWhere we used the chain rule to rewrite the terms on the right. If the fields minimize the Action, they must obey the Euler-Lagrange equation (\\ref{euler-lagrange}). So we have that the change in the action is \n\\begin{align}\\label{deltaS1}\n    \\delta S  &= \\int d^4x~\\partial_\\mu\\left(\\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial_\\mu\\phi)}\\delta\\phi\\right) \n\\end{align}\nThis term is in general not zero, but we can use a trick to leave the action invariant, which is our definition of a symmetry. When deriving the Euler-Lagrange equations, we take the actual variation in the fields $\\delta\\phi$ to be zero at the boundaries of integration, which means it doesn't care if we add a full derivative\\cite{peskin}\n\\begin{align}\n\\mathcal{L}(x)\\rightarrow\\mathcal{L}(x) + \\partial_\\mu\\mathcal{J}^\\mu(x)\n\\end{align}\nThis is because the volume integral of a full derivative can be converted into a surface integral by the generalization of the divergence theorem. \nKnowing that we will always get a change in the Action given by equation (\\ref{deltaS1}), and that we have the freedom to add an arbitrary surface term $\\partial_\\mu\\mathcal{J}^\\mu(x)$ which can change the Action but not the Euler-Lagrange equations, we can combine the two to give us no change in the action. \n\\begin{align}\n\\delta S = 0 = \\int d^4x~\\partial_\\mu\\left(\\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial_\\mu\\phi)}\\delta\\phi-\\mathcal{J}(x)\\right) \n\\end{align}\n\nWe see the integrand here must zero, which allows us to define the conserved current\n\\begin{align}\\label{noether}\nj^\\mu(x) = \\frac{\\partial\\mathcal{L}(x)}{\\partial(\\partial^\\mu\\phi)}\\delta\\phi-\\mathcal{J}(x) &&\\partial_\\mu j^\\mu(x) = 0\n\\end{align}\nThe conservation law tells us that \n\\begin{align}\nQ = \\int j^0 d^3x\n\\end{align}\nIs a constant in time, derived from the fact that the change in our fields $\\delta\\phi$ add a total derivative term to our Lagrangian which is the exact opposite the one we get from changing the Lagrangian to first order in the fields $\\phi$. Our symmetries must be defined in a way that give us this property, the general method for finding symmetries of a system goes as \n\n\\begin{enumerate}\n    \\item For a Lagrangian $\\mathcal{L}$, concoct a field symmetry transformation $\\delta\\phi$\n    \\item Plug in the new field to see how the Lagrangian changes, and verify it is by a total derivative $\\partial_\\mu\\mathcal{J}^\\mu(x)$. This tells us we have a valid symmetry.\n    \\item Now calculate the term from the Lagrangian to find the conserved current by equation (\\ref{noether})\n\\end{enumerate}\n\nSome typical examples of symmetries and their corresponding conserved quantity are given below\n\n\\begin{center}\n\\begin{tabular}{ | c | c|} \n\\hline\n Symmetry & Conserved Quantity\\\\ \\hline\n Time Translation & Energy  \\\\ \n Space Translation & Momentum  \\\\\nRotation in Space & Angular Momentum \\\\ \nCoordinate Inversion & Spatial Parity\\\\\nCharge Conjugation & Charge parity \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\n\\section{Relativistic Quantum Mechanics}\nThe standard equation for the evolution of a wave function in non-relativistic quantum mechanics is given by the Schrodinger equation (in natural units $c=1,\\hbar=1$) \\cite{banfi}\n\n\\begin{align}\ni\\frac{\\partial}{\\partial t}\\psi(x,t) =\\Big(-\\frac{1}{2m}\\nabla^2 + V(x)\\Big)\\psi(x,t)\n\\end{align}\nThis equation is analogous to\n\\begin{align}\nE = \\frac{\\textbf{p}^2}{2m} + V\n\\end{align}\nBy making the quantum mechanical replacements\n\\begin{align}\nE &\\rightarrow i\\frac{\\partial}{\\partial t}\\\\\n\\textbf{p} &\\rightarrow i\\nabla\n\\end{align}\nWe can make a quantum mechanical equivalent to Einstein's relativistic formula\n\\begin{align}\nE^2 = \\textbf{p}^2 + m^2\n\\end{align}\nGiving us\n\\begin{align}\n- \\frac{\\partial^2}{\\partial t^2}\\phi(x,t) = \\Big(-\\nabla^2 + m^2\\Big)\\phi(x,t)\n\\end{align}\nSimplifying the notation using\n\\begin{align}\n\\frac{\\partial^2}{\\partial t^2} - \\nabla^2 = \\partial_\\mu\\partial^\\mu\n\\end{align}\nWe can write the \\textbf{Klein-Gordon equation} as \n\\begin{align}\n\\boxed{(\\partial_\\mu\\partial^\\mu + m^2)\\phi(x,t) = 0}\n\\end{align}\nThis is of course, an equation of motion. We want to find a Lagrangian that gives us the Euler-Lagrange equations equivalent to this. It turns out that\\cite{peskin} the Lagrangian we need is\n\n\\begin{align}\n\\mathcal{L}(x) = \\frac{1}{2}(\\partial\\phi)^2 - \\frac{1}{2}m^2\\phi^2\n\\end{align}\n\nWe see that the first term is the same as (Eq. \\ref{harm-osc-lagrange}) the classical Lagrangian for a field of harmonic oscillators, with an additional term involving a mass $m$ associated with the field $\\phi$ itself. This term is not analogous to the mass in a classical spring system, since in the infinitesimal limit it's value at any point in space would be near zero. We note that this term is \\emph{quadratic} in the field. The term can be thought of as being associated with having the field having a non-zero value at all \\cite{peskin}; a \\emph{potential} term instead of kinetic, as it was classically.\n\n\\section{Important Lagrangians}\n\\subsection{Lagrangian for a Scalar Field (Spin-0)}\nThe equation for a single, scalar field $\\phi$ is given by the Klein-Gordon equation\n\\begin{align}\\label{kg-lagrange}\n\\mathcal{L}(x) = \\frac{1}{2}(\\partial\\phi)^2 - \\frac{1}{2}m^2\\phi^2\n\\end{align}\n\\subsection{Dirac Lagrangian for a Spinor (Spin-$\\frac{1}{2}$)}\nThe spinor field is relevant for particles of spin $\\frac{1}{2}$ and mass $m$. We treat $\\psi$ and $\\bar{\\psi}$ as independent field variables. The Lagrangian turns out to be\n\\begin{align}\\label{dirac_lagrangian}\n\\mathcal{L}(x) = i\\bar{\\psi}\\gamma^\\mu\\partial_\\mu\\psi - m\\bar{\\psi}\\psi\n\\end{align}\nThis gives two separate Euler-Lagrange equations\n\\begin{align}\ni\\gamma^\\mu\\partial_\\mu\\psi - m\\psi = 0 && i\\partial_\\mu\\bar{\\psi}\\gamma^\\mu + m \\bar{\\psi} = 0\n\\end{align}\n\\subsection{Proca Lagrangian for a Vector Field (Spin-1)}\nUsed for particles of spin-1 and mass $m$\n\\begin{align}\\label{proca}\n\\mathcal{L}(x) = -\\frac{1}{16\\pi}F^{\\mu\\nu}F_{\\mu\\nu} +\\frac{1}{8\\pi}m^2A^\\nu A_\\nu\n\\end{align}\nWhere \n\\begin{align}\nF^{\\mu\\nu}\\equiv \\partial^\\mu A^\\nu -\\partial^\\nu A^\\mu\n\\end{align}\nGives Euler-Lagrange equation\n\\begin{align}\n\\partial_\\mu F^{\\mu\\nu} + m^2A^\\nu = 0\n\\end{align}\nIf we set $m$ equal to 0, this is exactly the equations for Maxwell's equation in empty space.\n\n\\section{Gauge Invariance}\\label{gauge-inv}\nLooking at the Dirac Lagrangian (Equation \\ref{dirac_lagrangian} used for particles with spin-$\\frac{1}{2}$) we try to make it locally gauge invariant for no good reason at all\\cite{griffiths_ep} with\n\\begin{align}\n\\psi(x) \\rightarrow e^{iq\\lambda(x)}\\psi\n\\end{align}\nSince there is a derivative term, by the chain rule we get an extra term that falls out from the exponent, which requires us to add an extra term to the Lagrangian in the first place to cancel it\n\\begin{align}\n    \\mathcal{L}(x) = [i\\bar{\\psi}\\gamma^\\mu\\partial_\\mu\\psi - m\\bar{\\psi}\\psi] - (q\\bar{\\psi}\\gamma^\\mu\\psi)A_\\mu\n\\end{align}\nThis is equivalent to replacing each derivative with the covariant derivative\n\\begin{align}\n\\partial_\\mu \\rightarrow \\mathcal{D}_\\mu \\equiv \\partial_\\mu +iqA_\\mu\n\\end{align}\nWhere $A_\\mu$ is a \"gauge\" field with a transformation rule\n\\begin{align}\\label{gauge-transform}\nA_\\mu \\rightarrow A_\\mu + \\partial_\\mu\\lambda\n\\end{align}\n\nSince we introduce this new field $A_\\mu$, we have to include it's \"free\" term in the Lagrangian. It is a vector field since it is a 4-vector, which requires us to use the Proca Equation (\\ref{proca}) and also makes it so any type of particle associated with it has Spin-1. The second term in the Proca equation is not invariant, so we require that the mass associated with the particle from this field is zero. The full Lagrangian, with both the Spinor field and the new and necessary Proca Field is\n\\begin{align}\n\\mathcal{L}(x) = [i\\bar{\\psi}\\gamma^\\mu\\partial_\\mu\\psi - m\\bar{\\psi}\\psi] + \\left[\\frac{-1}{16\\pi}F^{\\mu\\nu}F_{\\mu\\nu}\\right]- (q\\bar{\\psi}\\gamma^\\mu\\psi)A_\\mu\n\\end{align}\nWith $F^{\\mu\\nu}\\equiv \\partial^\\mu A^\\nu - \\partial^\\nu A^\\mu$ Therefore by the requirement of local gauge invariance on a spin-1/2 field, we are required to add a spin-1 field that couples to it. This equation in fact reproduces all of electrodynamics with $J^\\mu = q(\\bar{\\psi}\\gamma^\\mu\\psi)$.\n\n\\section{Yang Mills Theory}\nIf we have a Lagrangian which contains multiple fields, i.e. two spin $\\frac{1}{2}$ fields $\\psi_1, \\psi_2$ \\cite{griffiths_ep}\n\\begin{align}\n\\mathcal{L} = [i\\bar{\\psi}_1\\gamma^\\mu\\partial_\\mu\\psi_1 - m_1\\bar{\\psi}_1\\psi_1] + [i\\bar{\\psi}_2\\gamma^\\mu\\partial_\\mu\\psi_2 - m_1\\bar{\\psi}_2\\psi_2]\n\\end{align}\n\nWe notice there is a symmetry in the Lagrangian which inspires us to write them as a two component column vector\n\\begin{align}\n\\psi \\equiv \\begin{pmatrix}\n\\psi_1\\\\\n\\psi_2\n\\end{pmatrix}\n\\end{align}\nSo the Lagrangian becomes\n\\begin{align}\n\\mathcal{L} = i\\bar{\\psi}\\gamma^\\mu\\partial_\\mu\\psi - \\bar{\\psi}M\\psi\n\\end{align}\nwith\n\\begin{align}\nM = \\begin{pmatrix}\nm_1 & 0\\\\\n0 & m_2\n\\end{pmatrix}\n\\end{align}\n\nThis allows us to come up with transformations on the Lagrangian that look like\n\n\\begin{align}\n\\psi\\rightarrow U\\psi\n\\end{align} \nWhere $U$ is any unitary matrix, which can be written as\n\\begin{align}\nU = e^{iH}\n\\end{align}\nWith $H$ being Hermitian. The most general form of a Hermitian $2\\times2$ matrix is\n\\begin{align}\nH = \\theta 1 + \\boldsymbol{\\tau}\\cdot\\textbf{a}\n\\end{align} \nWhere $\\boldsymbol{\\tau}$ are the Pauli matrices. These would be global symmetries of whatever Lagrangian we have, none of this is Yang Mills yet. The idea behind Yang-Mills theory is to let exponent be dependent on $x^\\mu$, making the Lagrangian locally invariant instead of globally invariant.\n\\begin{align}\n\\psi\\rightarrow S\\psi && S\\equiv e^{-iq\\boldsymbol{\\tau}\\cdot\\boldsymbol{\\lambda}(x)}\n\\end{align}\nAfter you do this, the derivative terms get screwed with again a la Section \\ref{gauge-inv}, so you need to swap all the derivatives to covariant derivatives\n\\begin{align}\n\\mathcal{D}_\\mu \\equiv \\partial_\\mu + iq\\boldsymbol{\\tau}\\cdot\\textbf{A}\n\\end{align}\nSince the Pauli matrices form $SU(2)$ which is non-Abelian, the field ends up transforming in a different way with $\\textbf{A}$ following the transformation rule\n\\begin{align}\n\\textbf{A}_\\mu \\rightarrow\\textbf{A}_\\mu + \\partial_\\mu\\boldsymbol{\\lambda} + 2q(\\boldsymbol{\\lambda}(x)\\times\\textbf{A})\n\\end{align}\nSimilar to equation \\ref{gauge-transform}. We now have to add 3 new vector fields to the Lagrangian, each of which have their mass term excluded by the invariance again. The field strength also changes because of the non-Abelian nature of $SU(2)$ with\n\\begin{align}\n\\textbf{F}^{\\mu\\nu}\\equiv \\partial^\\mu\\textbf{A}^\\nu - \\partial^\\nu\\textbf{A}^\\mu - 2q\\textbf{A}^\\mu\\times\\textbf{A}^\\nu\n\\end{align}\nFinally we get the complete Yang-Mills Lagrangian as \n\\begin{align}\n\\mathcal{L} = i\\bar{\\psi}\\gamma^\\mu\\partial_\\mu\\psi - m\\bar{\\psi}\\psi - \\frac{1}{4}\\textbf{F}^{\\mu\\nu}\\textbf{F}_{\\mu\\nu} - (q\\bar{\\psi}\\gamma^\\mu\\boldsymbol{\\tau}\\psi)\\cdot\\textbf{A}\n\\end{align}\nThis kind of procedure is extendable to higher order symmetry groups.\n\n\n\\section{Electro-Weak Mixing and the Higgs}\nData on electromagnetic and weak processes suggest the interactions are invariant under weak isospin $SU(2)_L$ and weak hypercharge $U(1)_Y$ \\cite{halzen}. The trick with the Higgs is we add a scalar field $\\phi$ which is an $SU(2)$ doublet that also respects the symmetries we already have.\n\n\\begin{align}\n\\phi = \\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}(\\phi_1+i\\phi_2)\\\\\n\\frac{1}{\\sqrt{2}}(\\phi_3 +i\\phi_4)\n\\end{pmatrix}\n\\end{align}\nThis inspires us to write the electroweak Lagrangian (without anything other than this new scalar field and Spin-1 fields coming from the requirement of $SU(2)$ and $U(1)$ gauge invariance) as\n\\begin{align}\n\\mathcal{L} = (\\mathcal{D}_\\mu\\phi)^\\dagger(\\mathcal{D}^\\mu\\phi) + \\mu^2\\phi^\\dagger\\phi- \\frac{\\lambda}{4}(\\phi^\\dagger\\phi)^2 -\\frac{1}{4}\\textbf{F}_{\\mu\\nu}\\textbf{F}^{\\mu\\nu} - \\frac{1}{4}G_{\\mu\\nu}G^{\\mu\\nu}\n\\end{align}\nWith \n\\begin{align}\n\\mathcal{D}^\\mu &= \\partial^\\mu + ig\\boldsymbol{\\tau}\\cdot\\textbf{W}^\\mu/2 + ig'B^\\mu/2\\\\\n\\textbf{F}^{\\mu\\nu} &= \\partial^\\mu\\textbf{W}^\\nu - \\partial^\\nu - g\\textbf{W}^\\mu\\times\\textbf{W}^\\nu\\\\\nG_{\\mu\\nu} &= \\partial^\\mu B^\\nu - \\partial^\\nu B^\\mu\n\\end{align}\n\nWhere $\\textbf{W}$ is the field corresponding to weak isospin from coming from $SU(2)$ and $B$ is weak hypercharge from $U(1)$. These are just putting together the two things in the last sections. The unique addition to the Lagrangian is the potential that is unstable at $\\phi = 0$. The symmetry of the system is then hidden because the minimum of the potential (about which the Lagrangian will be moved around) requires us to arbitrarily pick some (asymmetrical) ground state. We pick\n\\begin{align}\\label{higgs_vacuum}\n\\phi = \\begin{pmatrix}\n0\\\\\n\\frac{1}{\\sqrt{2}}(v+H)\n\\end{pmatrix}\n\\end{align}\nWhere $v$ represents the non-zero expecation value of the vacuum, shifting the field to the true minimum of the potential, and $H$ is the field representing small oscillations about that minimum. Keeping terms that are second order, writing everything out gives us\n\\begin{align}\\label{higgs-lagrangian}\n\\mathcal{L} &= \\frac{1}{2}\\partial_\\mu H\\partial^\\mu H -\\mu^2H^2\\\\\n&-\\frac{1}{4}(\\partial_\\mu W_{1\\nu} - \\partial_\\nu W_{1\\mu})(\\partial^\\mu W^\\nu_{1} - \\partial^\\nu W^\\mu_{1}) +\\frac{1}{8}g^2v^2W_{1\\mu}W^\\mu_1\\\\\n&-\\frac{1}{4}(\\partial_\\mu W_{2\\nu} - \\partial_\\nu W_{2\\mu})(\\partial^\\mu W^\\nu_{2} - \\partial^\\nu W^\\mu_{2}) +\\frac{1}{8}g^2v^2W_{2\\mu}W^\\mu_2\\\\\n&-\\frac{1}{4}(\\partial_\\mu W_{3\\nu} - \\partial_\\nu W_{3\\mu})(\\partial^\\mu W^\\nu_{3} - \\partial^\\nu W^\\mu_{3}) - \\frac{1}{4}G_{\\mu\\nu}G^{\\mu\\nu}\\\\\n&+\\frac{1}{8}v^2(gW_{3\\mu}-g'B_\\mu)(gW_3^\\mu - g'B^\\mu)\n\\end{align}\nOur Lagrangian now looks very suggestive. The $H$ field, which arose from the addition of the scalar field, now has a mass term $M_H = \\sqrt{2}\\mu$ when looked at in the form of the Klein-Gordon Lagrangian (Eq. \\ref{kg-lagrange}), similarly two of the Spin-1 fields also gain a mass according to the Proca Lagrangian (Eq. \\ref{proca}) with\n\\begin{align}\nM_1 = M_2 = qv/2 = M_W\n\\end{align}\nThe last lines show $W_3$ and $B$ are mixed. You can take a normalized linear combination of the two defining\n\\begin{align}\nZ^\\mu = \\cos\\theta_W W_3^\\mu -\\sin\\theta_W B^\\mu\n\\end{align}\nwith \n\\begin{align}\n\\cos\\theta_W = g/\\sqrt{g^2+g'^2}\n\\end{align}\nand the orthogonal combination\n\\begin{align}\nA^\\mu = \\sin\\theta_W W_3^\\mu + \\cos\\theta_W B^\\mu\n\\end{align}\nWhich let you rewrite the last two lines of equation \\ref{higgs-lagrangian} as\n\\begin{align}\n-\\frac{1}{4}(\\partial_\\mu Z_\\nu - \\partial_\\nu Z_\\mu)(\\partial^\\mu Z^\\nu -\\partial^\\nu Z^\\mu) + \\frac{1}{8}v^2(g^2 + g'^2)Z_\\mu Z^\\mu - \\frac{1}{4}F_{\\mu\\nu}F^{\\mu\\nu}\n\\end{align}\nThis lets us find another mass term with\n\\begin{align}\nM_Z = \\frac{1}{2}v(g^2+g'^2)^{1/2} = M_W/\\cos\\theta_W\n\\end{align}\nand\n\\begin{align}\nM_A = 0\n\\end{align}\nThese masses and fields correspond exactly to the $W^{+/-}$, $Z$, and $\\gamma$ bosons.\n\\section{Masses of the Fermions}\n If you consider the mass term of an electron\n\\begin{align}\n-m_e\\bar{e}e &= -m_e\\bar{e}[\\frac{1}{2}(1-\\gamma^5)+\\frac{1}{2}(1+\\gamma^5)]e\\\\&= -m_e(\\bar{e}_R e_L + \\bar{e}_L e_R)\n\\end{align}\n\"Since $e_L$ is a member of an isospin double and $e_R$ is a singlet, this term manifestly breaks gauge invariance\" \\cite{halzen}. Because of this, we can't put this term into the Lagrangian initially, resulting in all the fermions being massless.\n\nIt turns out that the same Higgs doublet we added to give the weak bosons mass, can be used again to give masses to the leptons and quarks. You add a coupling term to the fermions that looks like\n\\begin{align}\n\\mathcal{L}_e = -G_e\\left[ (\\bar{\\nu}_e,\\bar{e})_L\\begin{pmatrix}\n\\phi^+\\\\\n\\phi^0\n\\end{pmatrix}e_R + \\bar{e}_R(\\phi^-,\\bar{\\phi}^0)\\begin{pmatrix}\n\\nu_e\\\\\ne\n\\end{pmatrix}_L\\right]\n\\end{align}\nUsing the same definition for the field as in Equation \\ref{higgs_vacuum}, we find\n\\begin{align}\nL_e = -\\frac{G_e}{\\sqrt{2}}v(\\bar{e}_Le_R+\\bar{e}_R+e_L) -\\frac{G_e}{\\sqrt{2}}(\\bar{e}_le_r+\\bar{e}_Re_L)H\n\\end{align}\nIf we choose $G_e$ so\n\\begin{align}\nm_e = \\frac{G_ev}{\\sqrt{2}}\n\\end{align}\nwe end up with a term for the electron mass, a similar procedure is done for the rest of the fermions. $G_e$ is arbitrary, so the actual electron mass is not predicted and the coupling term is so small it hasn't produced a detectable effect in electroweak interactions.\n\n%\n%\\section{Classical Quantization}\\footnote{HEP 2015 Notes}\n%In classical mechanics, we define the conjugate momentum as \n%\\begin{align}\n%p_q = \\frac{\\partial L}{\\partial \\dot{q}}\n%\\end{align}\n%We follow an analogous procedure for the fields, writing \n%\\begin{align}\n%\\pi(x) = \\frac{\\partial \\mathcal{L}}{\\partial \\dot{\\phi}}\n%\\end{align}\n%The next thing we do is make the fields \"quantum\" by giving them an analogous relation to their wavefunction counterparts\n%\\begin{align}\n%[\\hat{x}_i,\\hat{p}_j] &= i\\delta_{ij}\\\\\n%[\\hat{p}_i,\\hat{p}_j] &= [\\hat{x}_i,\\hat{x}_j] = 0\n%\\end{align}\n%The first step is to think of the fields now as operators acting on a Hilbert space. This means we treat the fields as observables acting on states.\\footnote{Add more here}. \n%\\begin{align}\n%\\phi(x)\\rightarrow \\hat{\\phi}(x) && \\pi(x)\\rightarrow \\hat{\\pi}(x)\n%\\end{align}\n%We give them the equivalent relations, with\n%\\begin{align}\n%[\\hat{\\phi}(\\textbf{x},t),\\hat{\\pi}(\\textbf{y},t)] &= i\\delta(\\textbf{x}-\\textbf{y})\\\\\n%[\\hat{\\pi}(\\textbf{x},t),\\hat{\\pi}(\\textbf{y},t)] &= [\\hat{\\phi}(\\textbf{x},t),\\hat{\\phi}(\\textbf{y},t)] = 0\n%\\end{align}\n%\n%\n%Check HEP Summer school 2015 Notes\n%\n%pg. 21 canonical quantization\n%pg. 23 how ladder operators turn out to be the same in QFT\n%pg. 25 simple definition of renormalization\n%pg. 26 why we label $|k\\rangle$ a one particle state\n%pg. 27 scalar boson fields commute (?)\n%pg. 30 scattering matrix? probably want to read another paper on this\n%\n%pg. 59 has good dirac equation stuff\n%\n%\n%Peskin pg. 14 antiparticle stuff?\n%pg. 17 physical interpretation of Klein Gordon hamiltonian\n%\\section{Group Theory}\n%\n%A group is a set of elements that can move between themselves. By calling the entire group itself $G$, which contains $g_1, g_2, ... g_N$ elements ($N$ is the order og $G$). The group is defined in the following way\n%\\begin{enumerate}\n%   \\item $g_1g_2\\exists G$ for all $g_1, g_2\\exists G$. Which says when we multiply two elements, we get another element that is still within the group back\n%   \\item $(g_1g_2)g_3 = g_1(g_2g_3)$ for $g_1, g_2, g_3\\exists G$. Which says when given a specific order to multiply the elements, the sequencing of multiplication doesn't matter\n%   \\item There is an identity element $e$ which gives $eg = ge = g$ for all $g\\exists G$. This says there is one element that does not change any of the other elements.\n%   \\item For every element $g$, there is an inverse $g^{-1}$ such that $gg^{-1} = e$. Which allows us, from any element, to return to the identity\n%\\end{enumerate}\n%\n%Groups themselves are abstract entities defined by just the rules to get between elements. In physics, we use a \\textbf{representation} of a group, which is the group put into matrix form such that it obeys the same rules as its definition.\n%\\begin{gather}\n%\\begin{align}\n%\\textrm{Group} && \\textrm{Representation}\\\\\n%g_1g_2 = g_3 && D(g_1)D(g_2) = D(g_3)\n%\\end{align}\n%\\end{gather}\n%\\footnote{make this look nicer} Where $D(g_1)$ is a matrix representation of the group element $g_1$ etc. \n%\n%TODO:\n%\\begin{itemize}\n%   \\item SO(3) can have matrices that represent it of arbitrary size?\n%   \\item Put example of what a matrix tensor product looks like (from comp notes)\n%   \\item Irreducible representation\n%\\end{itemize}\n%\n%\n%\\subsection{Lie Groups}\n%Of particular importance in physics are \\textbf{Lie groups}, groups in which you can change infinitesimally between their elements. This allows you to Taylor expand ... TODO\n%\n%\\subsection{SO(3)}\n%Consider the addition of angular momentum of two spin $1/2$ particles, $a$ and $b$ the Hilbert space in which they live both have dimension\n%\\begin{align}\n%d_i = (2j_i + 1)\n%\\end{align}\n%where $i ~\\exists~(a,b)$. So $d_i = 2$ in the case of spin 1/2 particles ($\\uparrow$ and $\\downarrow$). The dimension of their combination is the product of both dimensions\n%\\begin{align}\n%d_{ab} = (2j_a+1)(2j_b+1)\n%\\end{align}\n%giving us 4. Considering each particle individually, we have a set of operators that \"represent\" the legal group operations that are allowed to make on the ket that would match with another potential bra. Following the same notation we look for the tensor product of the two representations\n%\\begin{align}\n%D^{(j_a)}\\otimes D^{(j_b)}\n%\\end{align}\n%\n%It can be shown\\footnote{Sakurai pg 230} that when you combine any two particles with angular momentum $j, j'$ you can describe any transformation on the system as a whole in terms of a sum of irreducible representations.\n%\n%\\begin{align}\n%D^{(j)}\\otimes D^{(j')} = \\bigoplus^{j+j'}_{l=|j-j'|} D^{(l)}\n%\\end{align}\n%\n%TODO remind what the sum looks like. This in effect means the particles, when put together, act as if they are an independent set of particles with different spin.\n%\n%\n%\\section{Transformation of Fields}\n%Lorentz symmetry tells whatever theory you make to obey the laws of special relativity. It dictates that however fast you are going, you won't see anything going faster than the speed of light. Poincare symmetry is a generalization of Lorentz symmetry that dictates that however fast, and wherever you are, you won't find anything going faster than the speed of light. The transformation law is \n%\n%\\begin{align}\n%x'^\\mu = a^\\mu + \\Lambda^{\\mu}_\\nu x^\\nu\n%\\end{align}\n%\n%Where $a^\\mu$ is the translation in space between the two coordinate systems, and $\\Lambda^\\mu_\\nu$ is a matrix characterizing whatever boost you apply to the system. \n%\n%\n%DO WE NEED THE POINCARE STUFF HERE??\n%\n%One can consider an infinitesimal Lorentz transformation as\n%\n%\\begin{align}\n%\\Lambda^\\mu_\\nu = \\delta^\\mu_\\nu + \\omega^\\mu_\\nu\n%\\end{align}\n%\n%Where $\\delta^\\mu_\\nu$ is just the identity matrix, and $\\omega^\\mu_\\nu$ characterizes the small transformation of the vector from where it was before. In shorthand, one writes\n%\\begin{align}\\label{infinitesimallorentz}\n%\\Lambda = 1 + \\omega\n%\\end{align}\n% We can now consider how the fields themselves change under Lorentz transforms. It turns out that\\footnote{Huang pg.45} relativistic fields transform according to irreducible representations of the Lorentz group in the same way wavefunctions in a central potential transform under irreducible representations of SO(3). We can write the transformation in general as\n%\n%\\begin{align}\n%\\phi_a'(x') = S_{ab}(\\Lambda)\\phi_b(x)\n%\\end{align}\n%\n%Where $a = 1,2,..., K$ where $K$ is the dimension of whatever irreducible representation of the Lorentz group we need for our field. Since the Lorentz group is a Lie group, we can consider infinitesimal transformations, and Taylor expand $S_{ab}$ using equation (\\ref{infinitesimallorentz})\n%\n%\\begin{align}\n%S_{ab}(\\Lambda) = S_{ab}(1+\\omega)  \\approx S_{ab}(1) + \\omega_{\\mu\\nu} S'^{\\mu\\nu}_{ab} = \\delta_{ab} + \\omega_{\\mu\\nu} S'^{\\mu\\nu}_{ab}\n%\\end{align}\n%We can instead write\n%\n%\\begin{align}\\label{fieldtransform}\n%S_{ab} = \\delta_{ab} +\\frac{1}{2}\\omega_{\\mu\\nu}\\Sigma_{ab}^{\\mu\\nu}\n%\\end{align}\n%Which will be convenient later. We can also expand the left side of the equation, since $x' = \\Lambda x$ with\n%\\begin{align}\n%\\phi'_a(x) = \\phi_a'(x + \\omega x) = \\phi'_a(x) + \\omega_{\\mu\\nu}x^\\nu\\partial^\\mu\\phi'_a(x)\n%\\end{align}\n%\n%It turns out that\\footnote{Huang pg.43} $\\omega^{\\mu\\nu} = -\\omega^{\\nu\\mu}$, which allows us to write\n%\\begin{align}\n%\\phi'_a(x) = \\phi_a(x) - \\frac{1}{2}\\omega_{\\mu\\nu}(x^\\mu\\partial^\\nu - x^\\nu\\partial^\\mu)\\phi'_a(x)\n%\\end{align}\n%The rightmost term happens to be the generalized angular momentum operator. When putting everything together, we see that \n%\\begin{align}\n%\\phi'_a(x) = \\phi_a(x) + \\frac{1}{2}\\omega_{\\mu\\nu}[(x^\\mu\\partial^\\nu - x^\\nu\\partial^\\mu)\\delta_{ab} + \\Sigma^{\\mu\\nu}_{ab}]\\phi_b(x)\n%\\end{align}\n%This identifies $\\Sigma^{\\mu\\nu}$ as \\emph{spin} matrices, since they are added to the generalized angular momentum.\n%\n%\\subsection{Scalar Field}\n%   A scalar field by definition does not change under a Lorentz transform\n%   \\begin{align}\n%   \\phi_a'(x') = \\phi_a(x)\n%   \\end{align}\n%   This means that the new field has same as the value as the old field in same effective location when swapping frames. Since in this case $S_{ab} = \\delta_{ab}$, this implies that \n%   \\begin{align}\n%   \\Sigma_{ab}^{\\mu\\nu} = 0\n%   \\end{align}\n%   Or simply put, the spin of the scalar field is zero.\n%\\subsection{Vector Field}\n%   A vector field by changes as a four vector under Lorentz transformation. Typically written as $A^\\mu$, we have\n%   \\begin{align}\n%   A'^\\mu(x') = \\Lambda^\\mu_\\nu A^\\nu(x)\n%   \\end{align}\n%   By equation (\\ref{fieldtransform}), we identify\n%   \\begin{align}\n%   \\omega_{ab} = \\frac{1}{2}\\omega_{\\mu\\nu}\\Sigma^{\\mu\\nu}_{ab}\n%   \\end{align}\n%   It can be shown\\footnote{Huang pg. 78} (TODO) that this field has spin 1.\n%\\subsection{Spinor Field}\n%These fields are more complicated TODO\n%\n%\n%\n%\n%\\subsection{Misc}\n%Introduced Poincare group, and finite dimensional representations of the Lorentz Algebra (D'Hoker pg.29). This will cover what scalars, pseudoscalars, etc actually are.\n%\n%\\begin{itemize}\n%   \\item Somehow from poincare invariance of the theory, all group elements in the theory break down into being elements of the tensor product of two spin groups?\n%   \\item Similarity transformation\n%   \\begin{align}\n%   A' = PAP^{-1}\n%   \\end{align}\n%\\end{itemize}\n%\n%\\section{Construction of the Standard Model}\n%In general, the way field theories are constructed are by\n%\\begin{enumerate}\n%\\item Write down the symmetries you want your system to have (i.e. angular momentum conservation, parity conservation, Lorentz invariance)\n%\\item With the help of Noether's theorem, write down the most general renormalizable Lagrangian that obeys these symmetries \n%\\item Test that whatever your wrote down has predictions that experiment has actually shown\n%\\end{enumerate}\n%\n%Pg. 68 Huang has good stuff from the point of view of symmetries\n%\n%\\section{Electricity and Magnetism}\n%\n%Special Relativity tells us that the maximum speed anything can travel at is $c$ and that the laws of physics must remain the same in any frame. This gives us Lorentz symmetry, which we take as true for all Quantum Field Theories going forward. This means the equations we write down to describe physical laws must be \\emph{covariant}, or that both sides must transform in the same way under a Lorentz transformation.\n%\n%\n%Electricity and Magnetism was the first force to be put in the framework of Quantum Field Theory, called Quantum Electrodynamics (QED). \n% \n%\n%\\section{Extra stuff to squeeze in}\n%E and M - We know that the kinetic energy of a particle is given by\n%\\begin{align}\n%   T = \\frac{\\textbf{p}^2}{2m} = \\frac{(m\\textbf{v}+q\\textbf{A})^2}{2m}\n%\\end{align}\n%And the potential energy of an electromagnetic system is given by\n%\\begin{align}\n%   U = q\\phi\n%\\end{align}\n%This gives us the full Lagrangian of a particle in an electromagnetic field as\n%\\begin{align}\n%   L = T - U = \\frac{(m\\textbf{v}+q\\textbf{A})^2}{2m} - q\\phi - \\frac{1}{2}\\epsilon_0\\int dr^3(E^2 + c^2B^2)\n%\\end{align}\n%\n%\n%\n%\"method becomes applicable to MAxwell's theory when we regard the electromagnetic field/potential at every point in space as independent generalized coordinates - equal footing with coordinates of a charged particle.\n%\n%\\section{Quantum Field Theory}\n%In quantum field theory, it is useful to describe the dynamics of a system in terms of the Lagrangian, which happens to be Lorentz invariant as opposed to the Hamiltonian which is not (since energy changes under a boost). \n%\n%A field $\\psi(\\textbf{x},t)$ is just something that has a value at every point in space $\\textbf{x}$ and time $t$\n%-- derive e\\&m lagrangian, show that it is stress tensor thing\n%-- show how e\\&M lagrangian has a conserved current $\\partial^\\mu j_\\mu$ and show that it is charge conservation\n%-- generalize it for qcd, etc, then do qft?\n%\n%\n%Huang is good\n%\\begin{itemize}\n%   \\item Lagrangian density is Lorentz invariant, so we use that instead of the Hamiltonian density, which is not (energy changes as we change frames).\n%   \\item Positive frequency part of $\\psi$ annihilates a particle and its negative frequency part creates an antiparticle. Similarly, $\\psi^\\dagger$ either creates a particle or annihilates an antiparticle. In light of this we can say that for the real field, the particle is its own antiparticle\n%\\end{itemize}\n%Things to eventually understand\n%\\begin{itemize}\n%   \\item What is a quantum field /  how to come to the formalism that is used\n%    \\begin{itemize}\n%       \\item Particles/ Antiparticles\n%       \\item Why Lagrangian?\n%       \\item Equation of motion from action\n%       \\item Relativistic vs non-relativistic\n%   \\end{itemize}\n%   \\item How Feynman diagrams / perturbation theory makes sense from QFT formalism\n%   \\begin{itemize}\n%       \\item How things get put into propagator, vertices, etc (Griffiths?)\n%   \\end{itemize}\n%   \\item Relationship between field and particles\n%   \\item Conserved currents / charges\n%    \\begin{itemize}\n%    \\item Should also include convincing explanation of Higgs boson giving everything mass\n%    \\item \"Instantaneous forces acting at a distance, such as appear in New\n%    ton’s gravitational\n%    force and Coulomb’s electrostatic force, are incompatible with spec\n%    ial relativity. No signal\n%    can travel faster than the speed of light. Instead, in a relativistic\n%    theory, the interaction\n%    must be\n%    mediated\n%    by another particle.\" D;Hoker\n%    \\item \n%    \\end{itemize}\n%   \\item \n%\\end{itemize}\n%\n%\\section{Misc}\n%\n%More Stuff:\n%\\begin{itemize}\n%\\item Charge conjugation $C|p\\rangle = |\\bar{p}\\rangle $\n%\\end{itemize}\n%\n%\n%\\begin{align}\n%   \\pi^\\mu \\equiv \\frac{\\partial \\mathcal{L}}{\\partial \\phi_\\mu}\n%\\end{align}\n%We write the canonical momentum as \n%\\begin{align}\n%   \\pi \\equiv \\pi^0 = \\frac{\\partial\\mathcal{L}}{\\partial \\dot{\\phi}}\n%\\end{align}\n%\n%$\\phi(\\textbf{x})$ is a scalar field, just like potential in electromagnetism (correct?) and $\\pi(\\textbf{x})$ is the momentum density of the field with\n%\\begin{align}\n%   \\dot{\\phi}(\\textbf{x}) = \\pi(\\textbf{x})\n%\\end{align}\n%\n%\\begin{align}\n%   [\\phi(\\textbf{x}),\\pi(\\textbf{x}')] = -i\\delta(\\textbf{x}-\\textbf{x}')\n%\\end{align}\n%This tells us we can know the position and momentum at two different points (?), called Microcausality.\n%\n%The gamma matrices are\n%\\begin{align}\n%   \\gamma^0 = \n%\\left(\n%{\\begin{array}{cc}\n%I&0\\\\\n%0&-I\\\\\n%\\end{array}}\n%\\right) \n%&& \\gamma^i = \n%\\left(\n%{\\begin{array}{cc}\n%0&\\sigma_i\\\\\n%-\\sigma_i &0\\\\\n%\\end{array}}\n%\\right)\n%\\end{align}\n%\n%The ideal for QFT is you write the action in terms of a field, which you minimize like in normal classical mechanics.\n%\n%\n%\n%The Euler Lagrange equation for a field are given by\n%\\begin{align}\n%   \\frac{\\partial\\mathcal{L}}{\\partial\\phi_r} = \\partial_\\mu \\frac{\\partial \\mathcal{L}}{\\partial(\\partial_\\mu\\phi_r)}\n%\\end{align}\n%This is actually 4 or 8 equations? index notation?\n%\n%\\begin{align}\n%   \\partial\\!\\!\\!/ = \\gamma^\\mu\\partial_\\mu\n%\\end{align}\n%\n%\\begin{align}\n%   \\bar{\\psi} \\equiv \\psi^\\dagger\\gamma^0\n%\\end{align}\n%\n%\\begin{align}\n%   \\gamma^5 = i\\gamma^0\\gamma^1\\gamma^2\\gamma^3\n%\\end{align}\n%\n%\n%A global symmetry is $\\psi \\rightarrow \\psi' = e^{i\\alpha G}\\psi$. A broken symmetry is where you have a potential well that is not centered at zero(?). Local symmetry is $\\psi(x) \\rightarrow \\psi'(x) = e^{i\\alpha(x)G}\\psi(x)$. Can't turn all global symmetries in local symmetries. Look at Gauge Theories in particle physics pg. 42\n%\n%Normal naming conventions go like\n%\n%\\begin{align}\n%   \\textrm{scalar~field}&& \\phi \\\\\n%   \\textrm{spinor~field}&& \\phi \\\\\n%   \\textrm{vector~field}&& A^\\mu \\\\\n%\\end{align}\n%\n%\\section{Pop Culture}\n\n\\section{Outstanding Puzzles}\n\\begin{itemize}\n    \\item Matter-Antimatter Asymmetry\n    \\item Dark Matter\n    \\item Dark Energy\n    \\item Hierarchy Problem\n\\end{itemize}\n\n\n\\subsection{Dark Matter}\nWeird velocity curves in galaxy suggest that there is matter there. Also apparently the universe would stabilize quickly enough to for galaxies / solar systems if there wasn't the mass from dark matter [cite]. Ordinary matter does not clump enough to be a dark matter candidate [Bob Cousins].\n\\section{Modern Topics}\n\\subsection{Supersymmetry}\n\n\\subsection{Neutrino Oscillation}\nIt turns out neutrinos oscillate between each other, violating individual lepton number (still globally conserved) because their mass eigenstates are not weak eigenstates. The probability for a $\\nu_e$ to turn into a $\\nu_\\mu$ is given by\n\\begin{align}\nP(\\nu_e\\rightarrow\\nu_\\mu) = \\sin^22\\theta\\sin^2\\frac{1.27\\Delta m^2L}{E}\n\\end{align}\nWhere $L$ is the distance traveled in m and $E$ is the neutrino energy in MeV. This also tells us there is a difference in mass between the neutrinos (i.e. at least two have mass at all). Can tell this happens by creating a $\\nu_\\mu$ beam, by slamming protons into a wall, then detecting (Section \\ref{neutrino}) the neutrinos far away, seeing that you have more $\\nu_e$ than you expect. Led to Nobel Prize in 2015 (Kajita and McDonald). \n\n\\subsection{Neutrinoless Double Beta Decay}\nReaction in which two neutrons of a nucleus decay to protons at the same time. This emits two electrons, and two electron neutrinos with it. If the neutrinos are Majorana fermions (i.e. they are their own antiparticle) it is hypothesized that this decay could happen without the neutrinos being emitted at all, since they would both annihilate each other. It is measured by looking at the summed electron energy and knowing the energy difference between the nuclear states.\n\n\n\\subsection{Proton Decay}\nBaryon number (amount of quarks) conservation currently prevents the proton from decaying, since it is the lightest baryon (made of three quarks). The decay is proposed to look like\n\\begin{align}\n    p^+ \\rightarrow \\pi^0 + e^+\n\\end{align}\n\nWhere the $\\pi^0$ is a meson (only two quarks). Some \"Grand Unified Theories\" (GUTs) predict another force that mediates this decay outside of the standard model with a very heavy mediator $m_X \\sim 10^{15}$ GeV. Assuming the coupling is similar to that of weak coupling, you can extract a rough lifetime with\n\\begin{align}\n\\frac{\\tau_p}{\\tau_W} = \\frac{\\Gamma_W}{\\Gamma_p} = \\propto\\frac{|\\mathcal{M}_W|^2}{|\\mathcal{M}_p|^2}\n\\end{align}\nTaking a typical weak lifetime of $\\tau_W = 10^{-11}$ and knowing\n\\begin{align}\n|\\mathcal{M}|^2\\propto\\frac{1}{m^4}\n\\end{align}\nWe have that \\begin{align}\n\\tau_p = \\frac{m_X^4}{m_W^4}\\tau_W\n\\end{align}\nAfter plugging everything in, the lifetime then comes out huge\n\n\\begin{align}\n    \\tau_p \\sim 10^{34} ~\\textrm{years}\n\\end{align}\n\nYou can look for these decays using huge water tanks (50,000 tons) that look for Cherenkov light from the initial positron and similar signatures from the $\\pi^0 \\rightarrow \\gamma\\gamma$ where the $\\gamma\\rightarrow e^+e^-$ and those leptons then radiate as well. This is works because the lifetime is exponential, so even if you have an extremely long lifetime, if you look at a huge amount of protons, you will find some small number (something like 10 a year are expected in the 50,000 ton tank).\n\n%\\subsection{Hidden Sector}\n\n%\\subsection{Displaced Particles}\n%\\footnote{Illuminating Dark Photons with Higgs - Curtin2015}\n%\n%Models\n%\\begin{itemize}\n%    \\item Hidden Sector - \n%\\end{itemize}\n\n\n\\subsection{Misc}\n\nPlank scale mass is limit of elementary particle size, if it was larger, would form a blackhole\nBhabha scattering = $e^+e^-\\rightarrow e^+e^-$\n\n\\subsection{Drell-Yan Process}\nOccurs when a quark-antiquark pair annihilate to create a virtual (off-shell) photon or $Z$ boson. The force carrier then pair produces leptons and is a large background in most particle physics experiments looking at lepton pairs.\n\n\n\\centerline{\n\\feynmandiagram [horizontal=a to b] {\ni1 [particle=\\(\\overline q\\)] -- [fermion] a -- [fermion] i2 [particle=\\(q\\)],\na -- [photon, edge label=\\(\\gamma^*\\)] b,\nf1 [particle=\\(l^+\\)] -- [fermion] b -- [fermion] f2 [particle=\\(l^-\\)],\n};\n}\n\\section{Misc}\n\n\\subsection{CKM Matrix}\nLepton number is always conserved\\footnote{Except for neutrino oscillations}, meaning that if you have one flavor of lepton (say a muon) you have to keep it around in the form of either a muon or a muon neutrino. Quarks violate \"flavor\" through something called the Cabibbo-Kobayashi-Maskawa (CKM) matrix.\n\n\\begin{align}\n\\begin{pmatrix}\nd'\\\\\ns'\\\\\nb'\n\\end{pmatrix} = \\begin{pmatrix}\nV_{ud}&V_{us}&V_{ub}\\\\\nV_{cd}&V_{cs}&V_{cb}\\\\\nV_{td}&V_{ts}&V_{tb}\n\\end{pmatrix} \\begin{pmatrix}\nd\\\\\ns\\\\\nb\n\\end{pmatrix}\n\\end{align}\nThe matrix clues us into the transition probabilities from one type of quark to another. The transition is proportional to $|V_{ij}|^2$ from one quark $i$ to another $j$. You can notice that all the transitions are from a quark with one charge to a different charge, this is because flavor can only change through exchange of a $W$. The use of $(d,s,b)$ as a vector is convention, to get the transition from $u$ to whatever, need to invert the matrix.\n\n\\subsection{OZI Rule}\\label{ozi}\nIf you can separate a Feynman diagram into a part just containing the incoming state and one containing the outgoing state by cutting out gluon lines, it will be strongly suppressed.\n\n%\\begin{itemize}\n%   \\item Introduce continuum mechanics (QFT Intro pdf)\n%   \\item Show how free field is derived for E\\&M (https://physics.stackexchange.com/questions/34241/deriving-lagrangian-density-for-electromagnetic-field\n%   \\item Write full Lagrangian for E\\&M\n%\\end{itemize}", "meta": {"hexsha": "9b03ce5706ab63869ab4d1022573a9fe29bdf849", "size": 46422, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "physics/particlePhysicsInTheory.tex", "max_stars_repo_name": "williamnash/notes", "max_stars_repo_head_hexsha": "6f89e27c51a1c0e14b3a24eab825299fb406fc2f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "physics/particlePhysicsInTheory.tex", "max_issues_repo_name": "williamnash/notes", "max_issues_repo_head_hexsha": "6f89e27c51a1c0e14b3a24eab825299fb406fc2f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2020-08-23T23:01:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-16T23:17:43.000Z", "max_forks_repo_path": "physics/particlePhysicsInTheory.tex", "max_forks_repo_name": "williamnash/notes", "max_forks_repo_head_hexsha": "6f89e27c51a1c0e14b3a24eab825299fb406fc2f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.6141176471, "max_line_length": 613, "alphanum_fraction": 0.7240532506, "num_tokens": 14187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.43307843375475175}}
{"text": "\n\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\begin{document}\n\n\\title{PS8}\n\\author{gaoningjing0012 }\n\\date{March 2020}\n\n\n\n\n\\maketitle\n\n\\begin{document}\n\\begin{table}[ht]\n\\centering\n\\begin{tabular}{rrrrrrrr}\n  \\hline\n& beta & beta.hat.OLS & beta.hat.LBFGS & beta.hat.NM & beta.hat.MLE\\\\\n  \\hline\n X1&1.5005793&1.500579&2.1712663&2.1712666&2.1712663\\\\\n X2&-0.9912363 &-0.9912364&0.4958889&0.4958889&0.4958889\\\\\n X3&-0.2472996 &-0.2472997&0.8292439&0.8292438&0.8292439\\\\\n X4&0.7443806 & 0.7443806&-0.3151552&-0.3151550& -0.3151550\\\\\n X5&3.5035336 & 3.5035338&-0.7235620&-0.7235619&-0.7235622\\\\\n X6&-1.9988728 &-1.9988729&-1.0234978&-1.0234978& -1.0234983\\\\\n X7&0.5022677  &0.5022677&2.1712663&2.1712666&0.3006270\\\\\n X8&0.9974800  &0.9974801&0.4958889&0.4958889&2.1712663\\\\\n X9&1.2556600  &1.2556600&0.8292439&0.8292438&0.4958889\\\\\nX10&1.9987691  &1.9987692&-0.3151552&-0.3151550& 0.8292439\\\\\n   \\hline\n\\end{tabular}\n\\end{table}\n\n\nwe can see from the above table, we can see my estimates close to the true value. and the Nelder Mead is a little bit bigger than the LBFGS.\n\n\n\\section{  }\n\\begin{table}[!htbp] \\centering \n  \\caption{} \n  \\label{} \n\\begin{tabular}{@{\\extracolsep{5pt}}lc} \n\\\\[-1.8ex]\\hline \n\\hline \\\\[-1.8ex] \n & \\multicolumn{1}{c}{\\textit{Dependent variable:}} \\\\ \n\\cline{2-2} \n\\\\[-1.8ex] & Y \\\\ \n\\hline \\\\[-1.8ex] \n X1 & 1.501$^{***}$ \\\\ \n  & (0.002) \\\\ \n  & \\\\ \n X2 & $-$0.991$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X3 & $-$0.247$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X4 & 0.744$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X5 & 3.504$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X6 & $-$1.999$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X7 & 0.502$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X8 & 0.997$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X9 & 1.256$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n X10 & 1.999$^{***}$ \\\\ \n  & (0.003) \\\\ \n  & \\\\ \n\\hline \\\\[-1.8ex] \nObservations & 100,000 \\\\ \nR$^{2}$ & 0.971 \\\\ \nAdjusted R$^{2}$ & 0.971 \\\\ \nResidual Std. Error & 0.500 (df = 99990) \\\\ \nF Statistic & 338,240.000$^{***}$ (df = 10; 99990) \\\\ \n\\hline \n\\hline \\\\[-1.8ex] \n\\textit{Note:}  & \\multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\\\ \n\\end{tabular} \n\\end{table} \n\n\\end{document}\n", "meta": {"hexsha": "c16797e627ae3c5c75f3f8b9fb1512e561366600", "size": 2183, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProblemSets/PS8/PS8_Gao.tex", "max_stars_repo_name": "gao0012/DScourseS20", "max_stars_repo_head_hexsha": "539d31b792becc2eaf2ff95665cd23da23e58903", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-17T05:08:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-17T05:08:18.000Z", "max_issues_repo_path": "ProblemSets/PS8/PS8_Gao.tex", "max_issues_repo_name": "gao0012/DScourseS20", "max_issues_repo_head_hexsha": "539d31b792becc2eaf2ff95665cd23da23e58903", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProblemSets/PS8/PS8_Gao.tex", "max_forks_repo_name": "gao0012/DScourseS20", "max_forks_repo_head_hexsha": "539d31b792becc2eaf2ff95665cd23da23e58903", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.9789473684, "max_line_length": 140, "alphanum_fraction": 0.546037563, "num_tokens": 1089, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.43307843375475163}}
{"text": "\\documentclass[letterpaper,10pt]{article}\n\\usepackage[margin=2cm]{geometry}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\n\\newcommand{\\panhline}{\\begin{center}\\rule{\\textwidth}{1pt}\\end{center}}\n\n\\title{\\textbf{Parametric Models: from data to models}}\n\\author{Pradeep Ravikumar (Instructor), HMW-Alexander (Noter)}\n\n\\begin{document}\n\n\\maketitle\n\n\\panhline\n\\href{../index.html}{Back to Index}\n\n\\panhline\n\\tableofcontents\n\n\\section*{Resources}\n\n\\begin{itemize}\n\t\\item \\href{../../Lectures/02_ParametricModels.pdf}{Lecture}\n\\end{itemize}\n\n\\panhline\n\n\\section{Recall Model-based ML}\n\t\n\\href{../01_Introduction/document.html}{Model-based ML}\n\n\\section{Model Learning: Data to Model}\n\nQuestiongs:\n\\begin{itemize}\n\t\\item What are the principles in going from data to model?\n\t\\item What are the guarantees of these methods?\n\\end{itemize}\n\n\\subsection{Bernoulli Distribution Example}\n\n\\begin{itemize}\n\t\\item Bernoulli distribution model\n\t\\begin{itemize}\n\t\t\\item $X$ is a random variable with Bernoulli distribution when:\n\t\t\\begin{itemize}\n\t\t\t\\item $X$ takes values in $\\{0,1\\}$\n\t\t\t\\item $P(X=1)=\\theta,~P(X=0)=1-\\theta$\n\t\t\t\\item Where $\\theta\\in[0,1]$\n\t\t\\end{itemize}\n\t\\end{itemize}\n\t\\item Draw \\textbf{independent} samples that are \\textbf{identically distributed} from same distribution model, Bernoulli distribution.\n\t\\begin{itemize}\n\t\t\\item If we observe an event $X\\in\\{0,1\\}$, its probability $P(X)$ is $\\theta^X(1-\\theta)^{1-X}$\n\t\t\\item Then the probability of data:\n\t\t\\begin{equation}\n\t\t\\begin{array}{rcl}\n\t\t\t\\mathbb{P}(X_1,X_2,...,X_n;\\theta) & = & \\prod_{i=1}^{n}{P(X_i)} \\\\\n\t\t\t\t\t\t\t\t\t\t\t   & = & \\prod_{i=1}^{n}{p^{X_i}(1-p)^{1-X_i}} \\\\\n\t\t\t\t\t\t\t\t\t\t\t   & = & p^{\\sum_{i=1}^{n}{X_i}}(1-p)^{n-\\sum_{i=1}^{n}{X_i}} \\\\\n\t\t\t\t\t\t\t\t\t\t\t   & = & p^{n_1}(1-p)^{n-n_1}\n\t\t\\end{array}\n\t\t\\end{equation}\n\t\\end{itemize}\n\t\\item Maximum Likelihood ($p(D|\\theta)$) Estimator (MLE)\n\t\\begin{itemize}\n\t\t\\item Choose $\\theta$ that maximizes the probability of observed data.\n\t\t\\begin{equation}\n\t\t\\begin{array}{rcl}\n\t\t\\hat{\\theta} & = & \\arg\\max_\\theta{\\mathbb{P}(X_1,\\dots,X_n;\\theta)} \\\\\n\t\t\t\t\t & = & \\arg\\max_\\theta{\\theta^{n_1}(1-\\theta)^{n-n_1}} \\\\\n\t\t\t\t\t & = & \\arg\\max_\\theta{n_1\\log\\theta+(n-n_1)\\log(1-\\theta)}\\\\\n\t\t\t\t\t & \\Rightarrow & \\frac{n_1}{\\hat{\\theta}}-\\frac{n-n_1}{1-\\hat{\\theta}} = 0 \\\\\n\t\t\t\t\t & \\Rightarrow & \\hat{\\theta}_{MLE} = \\frac{n_1}{n}\n\t\t\\end{array}\n\t\t\\end{equation}\n\t\t\\item MLE for parametric models\n\t\t\\begin{itemize}\n\t\t\t\\item Data: $X_1, X_2, \\dots, X_n$\n\t\t\t\\item Model: $P(X|\\theta)$ with parameters $\\theta$\n\t\t\t\\item Assumption: data drawn \\textbf{i.i.d} from distribution $P(X|\\theta^*)$ for some unknown $\\theta^*$\n\t\t\t\\item Mission: recover $\\theta^*$ from data $X_1,X_2,\\dots,X_n$\n\t\t\t\\item Likelihood function: $L(\\theta):=\\prod_{i=1}^{n}{P(X_i|\\theta)}$\n\t\t\t\\item Maximum Likelihood Estimator (MLE): find that parameter $\\theta$ that would maximize the likelihood of $\\theta$.\n\t\t\\end{itemize}\n\t\\end{itemize}\n\\end{itemize}\n\n\\subsection{How good is this MLE?}\n\n\\begin{itemize}\n\t\\item Consistency:\n\t\\begin{itemize}\n\t\t\\item As we sample more and more times, we want our estimator to converge (in probability) to the true probability.\n\t\t\\item For Bernoulli distribution example, we get the $\\hat{\\theta}=\\frac{1}{n}\\sum_{i=1}^{n}{X_i} \\rightarrow \\theta$ in probability as $n \\rightarrow \\infty$ by the \\textbf{Law of Large Numbers}\\footnote{It does not apply to distributions for whom Expected values do not exist. One example of such a distribution is the Cauchy distribution where the mean and the variance are undefined.}.\n\t\t\\item An estimator $\\hat{\\theta}(X_1,\\dots,X_n)$ where $X_i\\sim P(X;\\theta^*)$ is consistent if $\\hat{\\theta}\\rightarrow \\theta^*$ in probability as $n\\rightarrow \\infty$.\n\t\\end{itemize}\n\t\\item Unbiasedness:\n\t\\begin{itemize}\n\t\t\\item The estimator $\\hat{\\theta}$ is random: it depends on the samples drawn from a random distribution model with parameter $\\theta$. It would be great if the expectation $\\mathbb{E}[\\hat{\\theta}]$ of the estimator $\\hat{\\theta}$ be equal to the ``true\" probability. This property is called unbiasedness.\n\t\t\\item For Bernoulli example:\n\t\t\\begin{equation}\n\t\t\\begin{array}{rcl}\n\t\t\\mathbb{E}(\\hat{\\theta}) & = & \\mathbb{E}(\\frac{n_1}{n}) \\\\\n\t\t\t\t\t\t\t\t & = & \\mathbb{E}(\\frac{\\sum_{i=1}^{n}X_i}{n}) \\\\\n\t\t\t\t\t\t\t\t & = & \\frac{1}{n}\\sum_{i=1}^{n}{\\mathbb{E}(X_i)} \\\\\n\t\t\t\t\t\t\t\t & = & \\mathbb{E}(X_1) \\\\\n\t\t\t\t\t\t\t\t & = & \\theta\n\t\t\\end{array}\n\t\t\\end{equation}\n\t\\end{itemize}\n\\end{itemize}\n\n\\subsection{Gaussian Distribution Example}\n\nGaussian Distribution:\n$$P(x|\\mu,\\sigma)=\\frac{1}{\\sigma\\sqrt{2\\pi}}\\exp(-\\frac{(x-\\mu)^2}{2\\sigma^2})=\\mathcal{N}(\\mu,\\sigma^2)$$\n\\begin{itemize}\n\t\\item Affine transformation:\n\t\\begin{itemize}\n\t\t\\item $X \\sim \\mathcal{N}(\\mu,\\sigma^2)$\n\t\t\\item $Y=aX+b \\sim \\mathcal{N}(a\\mu+b,a^2\\sigma^2)$\n\t\\end{itemize}\n\t\\item Sum of Gaussians:\n\t\\begin{itemize}\n\t\t\\item $X \\sim \\mathcal{N}(\\mu_X,\\sigma^2_X)$, $Y \\sim \\mathcal{N}(\\mu_Y,\\sigma^2_Y)$\n\t\t\\item $Z=X+Y \\sim \\mathcal{N}(\\mu_X+\\mu_Y,\\sigma^2_X+\\sigma^2_Y)$\n\t\\end{itemize}\n\\end{itemize}\n\nMLE for Gaussian mean and variance:\n\\begin{itemize}\n\t\\item $\\hat{\\mu}_{MLE}=\\frac{1}{n}\\sum_{i=1}^{n}{x_i}$\n\t\\item $\\hat{\\sigma}^2_{MLE}=\\frac{1}{n}\\sum_{i=1}^{n}{(x_i-\\hat{\\mu})^2}$\n\\end{itemize}\n\n\\subsubsection{The Biased Variance of a Gaussian}\n\nThe unbiased variance estimator:\n$\\hat{\\sigma}^2_{unbiased}=\\frac{n}{n-1}\\hat{\\sigma}^2_{MLE}$\n\nProof:\n\\begin{equation}\n\\begin{array}{rcl}\n\\mathbb{E}(\\sigma^2_{MLE}) & = & \\mathbb{E}(\\frac{1}{n}\\sum_{i=1}^{n}{(x_i-\\hat{\\mu})^2}) \\\\\n\t\t\t\t\t\t   & = & \\frac{1}{n}\\mathbb{E}(\\sum_{i=1}^{n}{(x_i^2-2x_i\\hat{\\mu}+\\hat{\\mu}^2)}) \\\\\n   \t\t\t\t\t\t   & = & \\frac{1}{n}\\mathbb{E}(\\sum_{i=1}^{n}{x_i^2}-\\sum_{i=1}^{n}{2x_i\\hat{\\mu}}+\\sum_{i=1}^{n}{\\hat{\\mu}^2}) \\\\\n   \t\t\t\t\t\t   & = & \\frac{1}{n}\\mathbb{E}(\\sum_{i=1}^{n}{x_i^2}-2n\\hat{\\mu}^2+n\\hat{\\mu}^2) \\\\\n   \t\t\t\t\t\t   & = & \\frac{1}{n}\\mathbb{E}(\\sum_{i=1}^{n}{x_i^2}-n\\hat{\\mu}^2) \\\\\n   \t\t\t\t\t\t   & = & \\frac{1}{n}\\sum_{i=1}^{n}{\\mathbb{E}(x_i^2)-\\mathbb{E}(\\hat{\\mu}^2)}\\\\\n\t\t\t\t\t\t   & = & \\mathbb{E}(x_i^2)-\\mathbb{E}(\\hat{\\mu}^2) \\\\\n\t\t\t\t\t\t   & = & (\\sigma^2(x_i)+\\mathbb{E}(x_i)^2)-(\\sigma^2(\\hat{\\mu})+\\mathbb{E}(\\hat{\\mu})^2) \\\\\n\t\t\t\t\t\t   & = & \\sigma^2(x_i) - \\sigma^2(\\hat{\\mu}) \\\\\n\t\t\t\t\t\t   & = & \\sigma^2(x_i) - \\sigma^2(\\frac{1}{n}\\sum_{i=1}^{n}{x_i}) \\\\\n\t\t\t\t\t\t   & = & \\sigma^2(x_i) - \\frac{1}{n^2}\\sigma^2(\\sum_{i=1}^{n}{x_i}) \\\\\n\t\t\t\t\t\t   & = & \\sigma^2(x_i) - \\frac{1}{n^2}n\\sigma^2(x_i) \\\\\n\t\t\t\t\t\t   & = & \\frac{n-1}{n}\\sigma^2(x_i)\n\\end{array}\n\\end{equation}\n\n\\section{Convergence Rates of Estimator}\n\n\\subsection{Simple Bound (Hoeffding's Inequality)}\n\nIn probability theory, Hoeffding's inequality provides an upper bound on the probability that the sum of random variables deviates from its expected value. It can be applied to the important special case of identically distributed Bernoulli random variables.\n\\begin{itemize}\n\t\\item Let $X_1,\\dots,X_n$ be independent random variables bounded by the interval $[0,1]:0\\leq X_i \\leq 1$.\n\t\\item and $\\hat{\\theta}=\\bar{X}=\\frac{1}{n}\\sum_{i=1}^{n}{X_i}$\n\t\\item then $\\forall \\epsilon>0,~P(|\\hat{\\theta}-\\mathbb{E}(\\hat{\\theta})| \\geq \\tau) \\leq \\exp(-2n\\epsilon^2)$\n\\end{itemize}\n\n\\subsection{PAC (Probably Approximate Correct) Learning}\n\nPAC is a learning framework. Its initials stand for: Probably Approximately Correct. PAC learning aims to provide bounds (worst case estimates) on the size of the dataset.\n\nThe terminology 'Probably Approximately Correct' comes from the requirement that with high probability (greater than 1-delta) the error rate(epsilon) will be small. \n\nPAC bounds are very conservative, i.e they strongly over-estimate the size of the dataset required to give good generalization.\n\nA more detailed version about PAC theory include origin, introduction, framework, etc. can be found at:\n\\url{http://web.cs.iastate.edu/~honavar/pac.pdf}\n\nBesides, one very interesting comment I have seen is that\n\"PAC is the bridge between statistic and machine learning.\"\n\n\\section{Computational Issues of MLE}\n\nWhen number of parameters, or number of samples n is large, computing the MLE is a large-scale optimization problem.\n\n\\end{document}\n\n\n\n", "meta": {"hexsha": "e4e2d20bd2af3b3d0eb0a4a06225be9c635c27b7", "size": 8181, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/02_ParametricModels/document.tex", "max_stars_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_stars_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-03-04T01:53:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-14T09:17:05.000Z", "max_issues_repo_path": "Notes/02_ParametricModels/document.tex", "max_issues_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_issues_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/02_ParametricModels/document.tex", "max_forks_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_forks_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-10-20T15:07:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-20T15:07:29.000Z", "avg_line_length": 41.1105527638, "max_line_length": 391, "alphanum_fraction": 0.6559100354, "num_tokens": 2922, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.43307842110175465}}
{"text": "\\section{Search}\n\\label{sec:search}\n\nAs the search space of possible DSP program is extremely large, our search procedures must be exceptionally efficient. \nAs a first foray into DSP-PBE, we restrict ourselves to only synthesizing low-pass and high-pass filters, and global volume adjustment.\nThese two filters have the key property that they are quasi-commutative -- when the thresholds of these filters do not overlap, applying a low-pass and then a high-pass is the same as applying a high-pass and then a low-pass.\nAlthough our approach has no theoretical basis for being applicable to non-commutative filters (for example, delay lines or ring filters), we do attempt to use our approach on such filters in Sec~\\ref{sec:future}.\nWe leave a more thorough exploration of non-commutative filters to future work.\n\n\\subsection{Gradient Descent}\n\nGradient descent is a technique commonly used in modelling and machine learning.\nGiven a cost function, which represents the disagreement between a proposed model and the actual data, gradient descent can be used efficiently to minimize the cost and generate the model of best fit.\nGradient descent is only guaranteed to terminate with the globally minimal cost if the cost function being optimized is convex -- this is because gradient descent will ``descend'' along the surface of the cost function, in each step following the steepest gradient.\nWhile we were not able to design our aural distance function from Section~\\ref{sec:distance} to be convex, our cost function does demonstrate some properties of convexity that allow gradient descent to produce useful results, even if the result is not guaranteed to be the global minimum.\nWe will describe here some properties of our distance metric that were helpful in minimizing the cost of the synthesized filter, as well as the shortcomings of our design, and how we try to overcome them by adjusting our implementation of gradient descent.\n\n\\begin{figure}[!h]\n%\\includegraphics[width=\\columnwidth]{figs/distCurves} \n\\include{figs/distCurves}\n\\caption{The distance curves showing the convex-like shape of the aural distance function. Each curve is the distance between an input file, and a filter applied to that file - $dist(I, \\synthFilter(I))$.}\n\\label{fig:distCurves}\n\\end{figure}\n\nIn order to visualize the rough shape of our distance metric, we plot the distance between pairs of examples, and various possible DSP filters in Figure~\\ref{fig:distCurves}.\nHere we only visualize the distance curves in the dimension of the low-pass filter.\nNotice that the curves exhibit a clear ``saddle'', which represents the minimum cost.\nIn the ideal case, gradient descent will find these points.\nNote that we do not have these graphs available during synthesis -- producing the entire graph as in Figure~\\ref{fig:distCurves} is prohibitively expensive.\n\nIn Figure~\\ref{fig:distCurves}, the last curve we plot is the distance between \\texttt{cartoon-spring.wav} and \\texttt{cartoon-spring-hpf1500.wav}, the same file with a high pass filter applied with a threshold of 1500 Hz.\nNotice that as the threshold of the low-pass filter applied to the input example (\\texttt{cartoon-spring.wav} increases, the distance to the output example decreases. \nThis is because as a low-pass filter's threshold increases, it allows more and more frequencies to pass into the output -- thereby having less of an effect.\nWhereas in the case of the \\texttt{cartoon-spring-hpf1500.wav}, the true filter is a high-pass filter, so the less we apply a low-pass filter, the closer we get to the correct filter.\n\n\\begin{figure}\n%\\includegraphics[width=\\columnwidth]{figs/distCurveZoom} \n\\include{figs/distCurveZoom}\n\\caption{Zooming in (1000 to 1500 Hz) on a portion of a curve from Figure~\\ref{fig:distCurves}, we see the aural distance function is not perfectly convex on the micro scale.}\n\\label{fig:microDist}\n\\end{figure}\n\nAlthough Fig.~\\ref{fig:distCurves} depicts on one dimension of the search space (low-pass filter threshold), the actual space we need to search has many more dimensions.\nIn our implementation, we only explore a space of two DSP filters and volume adjustment, but this already results in 5 dimensional space (each filter requires both a threshold value and an amplitude value for how much of the filter to apply).\nIn general, this space becomes even larger for DSP-PBE as more DSP primitives (ring filter, white noise, delay etc) are added.\nTo speed up gradient descent, we use stochastic gradient descent, so that in each step, we only move in $d<5$ number of dimensions.\n\n\\subsection{Dealing with Non-convexity}\nThere are a number challenges with working with gradient descent in the aural DSP domain because our distance metric is not convex.\nOn the micro scale, the distance function is susceptible to noise and not entirely smooth, as shown in Figure~\\ref{fig:microDist}.\nIn order to handle the micro scale variations, we use a periodic restart of the gradient descent.\nThis means that every $n$ rounds, as defined by the user, the gradient descent will backtrack to the best solution it has found so far.\nIntuitively, the choice of $n$ represents how far gradient descent is allowed to explore a path of optimization before it is forced to give-up on that direction if it has not found any benefit to this direction.\nThe best value for $n$ then must be determined based on the trade-off of potential time wasted on poor choices, and the potential benefit of these choices.\nIn our implementation we use $n=4$ after a holistic evaluation of the convexity of the aural distance function.\nThe stochastic gradient descent will then continue, selecting dimensions to explore in each round using a new random seed.\n\n\\begin{figure}\n%\\includegraphics[width=\\columnwidth]{figs/distCurveMacro} \n\\include{figs/distCurveMacro}\n\\caption{Looking at the portion of a curve from Figure~\\ref{fig:distCurves} between 8k Hz and 20k Hz, we see the aural distance function is not perfectly convex on the macro scale. In this case, that is because the sample has very few frequencies above the 8k Hz range.}\n\\label{fig:macroDist}\n\\end{figure}\n\nOn the macro scale, we face the challenge that the distance function is again not convex -- there are many local minima and long plateaus, as shown in Figure~\\ref{fig:macroDist}.\nIn order to overcome this, we must carefully pick the initial value for gradient descent.\nIf we pick a value in the middle of a plateau, the gradient descent algorithm will not find any significant gradient, and conclude we have reached the convergence condition.\nIn our current implementation, we iterate at large intervals (1000 Hz) of possible threshold values for both low and high pass filters.\nWe choose possible DSP programs that use only low pass, only high pass, and both low and high pass filters.\nAfter evaluating these, we take the lowest cost initial DSP program, and start gradient descent from that point.\n\nFinally, one of the key parts of a good application of gradient descent is the choice of the parameters such as the learning rate and the convergence goal.\nThese parameters must be adjusted based on the values observed from the cost (in our case, distance) function.\nWhile the details of tuning gradient descent are outside the scope of this paper, it suffices to note that any change in the distance metric will likely also require a readjustment of these parameters.\n\n", "meta": {"hexsha": "c87d4649d6609fff162015c279688a1acf9a8ff3", "size": 7392, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/FARM-18/secs/search.tex", "max_stars_repo_name": "Yale-OMI/DSP-PBE", "max_stars_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-03T02:36:39.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-03T02:36:39.000Z", "max_issues_repo_path": "papers/FARM-18/secs/search.tex", "max_issues_repo_name": "Yale-OMI/DSP-PBE", "max_issues_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2018-11-16T21:50:44.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-16T18:57:19.000Z", "max_forks_repo_path": "papers/FARM-18/secs/search.tex", "max_forks_repo_name": "Yale-OMI/DSP-PBE", "max_forks_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.2631578947, "max_line_length": 288, "alphanum_fraction": 0.7987012987, "num_tokens": 1616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.43307688024765}}
{"text": "\\chapter{Pointfree funcoids as a generalization of frames}\n\nI define an injection from the set of frames to the set of pointfree endo-funcoids.\n\nThis article is a rough partial draft of a future longer writing.\n\n\\section{Definitions}\n\n\\subsection{Pointfree funcoid induced by a co-frame}\n\nLet $\\mathfrak{L}$ is a co-frame.\n\nWe will define pointfree funcoid $\\Uparrow \\mathfrak{L}$.\n\nLet $\\mathcal{B} (\\mathfrak{L})$ is a boolean lattice whose co-subframe\n$\\mathfrak{L}$ is. (That this mapping exists follows from\n{\\cite{stone-spaces}}, page 53.) There may be probably more than one such\nmapping, but we just choose one $\\mathcal{B}$ arbitrarily.\n\nDefine $\\cl (A) = \\bigsqcap \\left\\{ X \\in \\mathfrak{L} \\hspace{1em} |\n\\hspace{1em} X \\sqsupseteq A \\right\\}$.\n\nHere $\\bigsqcap$ can be taken on either $\\mathfrak{L}$ or $\\mathcal{B}\n(\\mathfrak{L})$ as they are the same.\n\n\\begin{obvious}\n  $\\cl \\in \\mathfrak{L}^{\\mathcal{B} (\\mathfrak{L})}$.\n\\end{obvious}\n\n$\\cl (A \\sqcup B) = \\bigsqcap \\left\\{ X \\in \\mathfrak{L} \\hspace{1em} |\n\\hspace{1em} X \\sqsupseteq A \\sqcup B \\right\\} = \\bigsqcap \\left\\{ X \\in\n\\mathfrak{L} \\hspace{1em} | \\hspace{1em} X \\sqsupseteq A, X \\sqsupseteq B\n\\right\\} = \\bigsqcap \\left\\{ X_1 \\sqcup X_2 \\hspace{1em} | \\hspace{1em} X_1\n\\sqsupseteq A, X_2 \\sqsupseteq B \\right\\} = \\bigsqcap \\left\\{ X_1 \\hspace{1em}\n| \\hspace{1em} X_1 \\sqsupseteq A \\right\\} \\sqcup \\bigsqcap \\left\\{ X_2\n\\hspace{1em} | \\hspace{1em} X_2 \\sqsupseteq B \\right\\} = \\cl A \\sqcup\n\\cl B$.\n\n$\\cl 0 = 0$ is obvious.\n\nHence we are under conditions of the theorem 14.26 in my book.\n\nSo there exists a unique pointfree endo-funcoid $\\Uparrow \\mathfrak{L} \\in\n\\mathsf{FCD} (\\mathfrak{F} (\\mathcal{B} (\\mathfrak{L})) , \\mathfrak{F}\n(\\mathcal{B} (\\mathfrak{L})))$ such that\n\\[ \\langle \\Uparrow \\mathfrak{L} \\rangle \\mathcal{X} = \\bigsqcap^{\\mathfrak{F}\n   (\\mathcal{B} (\\mathfrak{L}))} \\langle \\cl \\rangle\n   \\up^{\\text{$(\\mathfrak{F} (\\mathcal{B} (\\mathfrak{L})) , \\mathfrak{P}\n   (\\mathcal{B} (\\mathfrak{L})))$}}  \\mathcal{X} \\]\nfor every filter $\\mathcal{X} \\in \\mathfrak{F} (\\mathcal{B} (\\mathfrak{L}))$.\n\n\\subsection{Co-frame induced by a pointfree funcoid}\n\nThe co-frame $\\Downarrow f$ for some pointfree endo-funcoids $f$ will be\ndefined to be the reverse of $\\Uparrow$. See below for exact meaning of being\nreverse.\n\nLet restore the co-frame $\\mathfrak{L}$ from the pointfree funcoid $\\Uparrow\n\\mathfrak{L}$.\n\nLet poset $\\Downarrow f$ for every pointfree funcoid $f$ is defined by the\nformula:\n\\[ \\Downarrow f = \\left\\{ X \\in Z (\\Ob f) \\hspace{1em} | \\hspace{1em}\n   \\supfun{f} X = X \\right\\} . \\]\n\\begin{rem}\n  It seems that $\\Downarrow$ is \\emph{not} a monovalued function from\n  $\\mathsf{pFCD}$ to $\\Ob (\\mathbf{Frm})$.\n\\end{rem}\n\n\\subsection{Isomorphism of co-frames through pointfree funcoids}\n\n\\begin{rem}\n  $\\mathfrak{P} (\\mathcal{B} (\\mathfrak{L})) = Z (\\mathfrak{F} (\\mathcal{B}\n  (\\mathfrak{L})))$ (theorem 4.137 in {\\cite{volume-1}}).\n\\end{rem}\n\n\\begin{thm}\n  $\\mathfrak{L} \\mapsto \\Downarrow \\Uparrow \\mathfrak{L}$ (where\n  $\\mathfrak{L}$ ranges all small frames) is an order isomorphism.\n\\end{thm}\n\n\\begin{proof}\n  Let $A' \\in \\Downarrow \\Uparrow \\mathfrak{L}$. Then there exists $A \\in\n  \\mathcal{B} (\\mathfrak{L})$ such that $A' = \\uparrow^{\\mathcal{B}\n  (\\mathfrak{L})} A$.\n  \n  $\\supfun{f} A' = \\uparrow^{\\mathcal{B} (\\mathfrak{L})} \\cl A$.\n  \n  $\\supfun{f} A' = A'$ that is $\\uparrow^{\\mathcal{B} (\\mathfrak{L})}\n  \\cl A = A' = \\uparrow^{\\mathcal{B} (\\mathfrak{L})} A$. So $\\cl A\n  = A$ and thus $A \\in \\mathfrak{L}$.\n  \n  Let now $A \\in \\mathfrak{L}$. Then take $A' = \\uparrow^{\\mathcal{B}\n  (\\mathfrak{L})} A$. We have $\\supfun{f} A' = \\cl A =\n  \\uparrow^{\\mathcal{B} (\\mathfrak{L})} A = A'$. So $A' \\in \\Downarrow\n  \\Uparrow \\mathfrak{L}$.\n  \n  We have proved that it is a bijection.\n  \n  Because $A$ and $A'$ are related by the equation $A' = \\uparrow^{\\mathcal{B}\n  (\\mathfrak{L})} A$ it is obvious that this is an order embedding.\n\\end{proof}\n\n\\section{Postface}\n\nPointfree funcoids are a \\textbf{massive} generalization of locales and\nframes: They don't only require the lattice of filters to be boolean but these\ncan be even not lattices of filters at all but just arbitrary posets. I think\na new era in pointfree topology starts.\n\nMuch work is yet needed to relate different properties of frames and locales\nwith corresponding properties of pointfree funcoids.", "meta": {"hexsha": "2b1d0c12b1c3f1a0638520ff8cf22f0dde20b7b3", "size": 4375, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-frames.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-frames.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-frames.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0625, "max_line_length": 83, "alphanum_fraction": 0.6731428571, "num_tokens": 1660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.43307687354066876}}
{"text": "The authors simulate planetesimal and binary interactions using the parallelized gravitational N-body code PKDGRAV in the University of Bristol’s Advanced Computing Research\nCentre. But as the simulations can get computationally expensive, they limit the resolution of the planetesimal disk to N = $10^6$ particles so as to be able to get statistically confident conclusions in a practical time frame\n\n\\subsubsection{Initial Conditions}\n The authors develop three simulations; two of which are of a circumbinary disk representative of the Kepler-34 system(ie., inner and outer disk boundaries include the current location of Kepler-34(AB)b) but vary in the masses of planetesimals by a factor of 1000 in order to determine the effect of inter-planetesimal gravity on the collision outcome and the third is of a control simulation around a single star using the same time step and disk parameters to set a benchmark for conditions known to sustain planetesimal accretion. \n\\\\\nThe simulations are run with short time steps for over thousnads of orbits as the binary system has a high eccentricity and low orbital period. The simulations are started with unperturbed planetesimal disks. The disk around the binary perturbs from the initial eccentricity distribution into a eccentricity wave structure within 25 orbits. After over 1000 orbits it reaches a quasi steady state with low and high eccentricity planetesimals on crossing orbits\nIt is at this point that they turn on collisions and allow the planetesimals to collisionally evolve.\n\n\n\\subsubsection{Collision Model}\nFor this the authors use the collision model EDACM which has been integrated into PKDGRAV and can handle a variety of collision outcomes. Analytic determination of the outcome provides substantial improvements in computational efficiency and outcome accuracy and is done using a series of scaling laws which require only the collider impact velocity, impact parameter, mass ratio, and two fixed material property parameters.\n\\\\\nAfter collisions, fragments with mass less than $m_0 = 1.7 \\times 10^{21}$ g are not resolved and are put into one of 10 radial bins depending on the colliders location, in order to maintain a practical value of N. These unresolved debris do not offer friction to the resolved planetesimals, although the total momentum of the system is conserved in the accretion process.\n", "meta": {"hexsha": "8944c1095f611dbe835163deb68781bf1e6e5c1b", "size": 2372, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "computational-physics/N-BODY SIMULATIONS OF KEPLER-34/Kepler_method.tex", "max_stars_repo_name": "Abhishek-Gupta-GitHub/review-papers-2021", "max_stars_repo_head_hexsha": "1420a8bc8ac6d8d1c421c05dbee33227b203a627", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "computational-physics/N-BODY SIMULATIONS OF KEPLER-34/Kepler_method.tex", "max_issues_repo_name": "Abhishek-Gupta-GitHub/review-papers-2021", "max_issues_repo_head_hexsha": "1420a8bc8ac6d8d1c421c05dbee33227b203a627", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "computational-physics/N-BODY SIMULATIONS OF KEPLER-34/Kepler_method.tex", "max_forks_repo_name": "Abhishek-Gupta-GitHub/review-papers-2021", "max_forks_repo_head_hexsha": "1420a8bc8ac6d8d1c421c05dbee33227b203a627", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 158.1333333333, "max_line_length": 534, "alphanum_fraction": 0.8229342327, "num_tokens": 477, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4329190412109455}}
{"text": "%%\n%% /docs/report/content/chapters/comparison.tex\n%%\n%% Created by Paul Warkentin <paul@warkentin.email> on 24/07/2018.\n%% Updated by Paul Warkentin <paul@warkentin.email> on 25/07/2018.\n%%\n\n\\section{Comparison}\n\\label{section:comparison}\n\nNext to the SSD network are many other object detection algorithms published. In this section, we will take a look at two other networks.\n\n\\subsection{Faster R-CNN}\n\nFaster R-CNN \\cite{fasterrcnn2015} is a faster version of the Region-based Convolutional Neural Network (in short R-CNN). R-CNN uses an algorithm called Selective Search to propose objects and reduces the number of region proposals to around 2000. For each regional proposal, CNN features are calculated and finally classified. Faster R-CNN replaces that Selective Search with a convolutional network as the Selective Search is very slow. The new convolutional network is called Region Proposal Network (in short RPN) that generates regions of interests. \\\\\n\nWith Faster R-CNN, the idea of anchor boxes comes to life. For each location in a feature map extracted by convolutional layers from the image, anchor boxes with 3 different scales and 3 different aspect ratios are computed, resulting in 9 anchor boxes per location. A sliding window is then run spatially on these feature maps which are then fed to another network for classification and regression. The regression network predicts a bounding box, the classification network outputs a probability indicating whether the predicted box contains an object or background.\n\n\\subsection{YOLO}\n\nYou Ony Look Once (in short YOLO) \\cite{yolo2016} is a Regression-based object detector. We will look into YOLOv2 here. \\\\\n\nYOLO takes an image of size $448 \\times 448$ as input and feeds it to a convolutional neural network with a tensor of $(7, 7, 1024)$ as output. This tensor is then fed into two fully connected layers that performs linear regression. The final output is then a tensor of size $(7, 7, 30)$ . Each cell in the $7 \\times 7$ grid predicts two bounding boxes and its confidence scores. The score measures how accurate the bounding box is and how likely the box contains an object or background.\n", "meta": {"hexsha": "bf0964f38b52586e0b3d1319941da9e92731865f", "size": 2168, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/report/content/chapters/comparison.tex", "max_stars_repo_name": "paulwarkentin/tf-ssd-vgg", "max_stars_repo_head_hexsha": "f48e3ccbb8eb092d3cb82a9d90164c7328880477", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/report/content/chapters/comparison.tex", "max_issues_repo_name": "paulwarkentin/tf-ssd-vgg", "max_issues_repo_head_hexsha": "f48e3ccbb8eb092d3cb82a9d90164c7328880477", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/report/content/chapters/comparison.tex", "max_forks_repo_name": "paulwarkentin/tf-ssd-vgg", "max_forks_repo_head_hexsha": "f48e3ccbb8eb092d3cb82a9d90164c7328880477", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 90.3333333333, "max_line_length": 568, "alphanum_fraction": 0.7919741697, "num_tokens": 502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43291903284438016}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n\n\\subsection*{checkgrad.m} \n\n\\begin{par}\n\\textbf{Summary:} checkgrad checks the derivatives in a function, by comparing them to finite differences approximations. The partial derivatives and the approximation are printed and the norm of the difference divided by the norm of the sum is returned as an indication of accuracy.\n\\end{par} \\vspace{1em}\n\n\\begin{verbatim}  function [d dy dh] = checkgrad(f, X, e, varargin)\\end{verbatim}\n    \\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\n\\begin{lstlisting}\n%\t\tf          function handle to function that needs to be checked.\n%              The function f should be of the type [fX, dfX] = f(X, varargin)\n%              where fX is the function value and dfX is the gradient of fX\n%              with respect to the parameters X\n%   X          parameters (can be a vector or a struct)\n%   e          small perturbation used for finite differences (1e-4 is good)\n%   varargin   other arguments that are passed on to the function f\n%\n%\n% *Output arguments:*\n%\n%   d          relative error of analytical vs. finite difference gradient\n%   dy         analytical gradient\n%   dh         finite difference gradient\n%\n%\n% Copyright (C) 2008-2013 by\n% Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.\n%\n% Last modified: 2013-03-21\n%\n\\end{lstlisting}\n\n\n\\subsection*{High-Level Steps} \n\n\\begin{enumerate}\n\\setlength{\\itemsep}{-1ex}\n   \\item Analytical gradient\n   \\item Numerical gradient via finite differences\n   \\item Relative error\n\\end{enumerate}\n\n\\begin{lstlisting}\nfunction [d dy dh] = checkgrad(f, X, e, varargin)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\n% 1. Analytical gradient\nZ = unwrap(X); NZ = length(Z);                 % number of input variables\n[y dy] = feval(f, X, varargin{:});             % get the partial derivatives dy\n[D E] = size(y); y = y(:); Ny = length(y);     % number of output variables\nif iscell(dy) || isstruct(dy); dy = unwrap(dy); end;\ndy = reshape(dy,Ny,NZ);\n\n% 2. Finite difference approximation\ndh = zeros(Ny,NZ);\nfor j = 1:NZ\n  dx = zeros(length(Z),1);\n  dx(j) = dx(j) + e;                               % perturb a single dimension\n  y2 = feval(f, rewrap(X,Z+dx), varargin{:});\n  y1 = feval(f, rewrap(X,Z-dx), varargin{:});\n  dh(:,j) = (y2(:) - y1(:))/(2*e);\nend\n\n% 3. Compute error\n% norm of diff divided by norm of sum\nd = sqrt(sum((dh-dy).^2,2)./sum((dh+dy).^2,2));\nsmall = max(abs([dy dh]),[],2) < 1e-5; % small derivatives are poorly tested ...\nd(d > 1e-3 & small) = NaN;             % ... by finite differences\nd = reshape(d,D,E);\n\ndisp('   Analytic  Numerical');\nfor i=1:Ny;\n    disp([dy(i,:)' dh(i,:)']);                           % print the two vectors\n    fprintf('d = %e\\n\\n',d(i))\nend\n\nif Ny > 1; disp('For all outputs, d = '); disp(d); end; fprintf('\\n');\n\\end{lstlisting}\n", "meta": {"hexsha": "099f810165d5ebf9f760cc7bead40ebdcd48dc49", "size": 2957, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/checkgrad.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/checkgrad.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/checkgrad.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 30.8020833333, "max_line_length": 283, "alphanum_fraction": 0.6347649645, "num_tokens": 851, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.43291902357135303}}
{"text": "\\epigraph{``Since Newton, mankind has come to realise that the law of physics are always expressed in the language of differential equations\"}{Steven Strogatz}\n\n\\section{RNN}\n\\subsection{Introduction}\nWeather forecasting has traditionally been done by physical models of the atmosphere, which are unstable to perturbations, and thus are inaccurate for large periods of time\\cite{why_rnn}. Since machine learning techniques are more sensitive to perturbations, it would be logical to combine a neural network with a physical model. Weather forecasting is a sequential data problem, therefore, a recurrent neural network is the most suitable option for this task. \n\n\\begin{definition}\nA recurrent neural network is a class of artificial neural networks where connections between nodes form a directed graph along a temporal sequence.\n\\end{definition}\n\nBefore, we delve into the specific example of using a recurrent neural network to predict the future state of the atmosphere, it is necessary to review what a recurrent neural network is. Recurrent Neural Networks (RNNs) are neural networks that are used in situations where data is presented in a sequence. For example, let's say you want to predict the future position of a fast-moving ball. Without information on the previous position of the ball, it is only possible to make an inaccurate guess. If you had, however, a large number of snapshots of the previous position, you are then able to predict the future position of the ball with some certainty. RNNs excel at modelling sequential data such as this. This is due to sequential memory.\n\nIn order to intuitively understand sequential memory, the prime example would be the alphabet. While it is easy to say the alphabet from A-Z, it is much harder to go from Z-A. There is a logical reason why this is difficult. As a child, you learn the alphabet in a sequence. Sequential memory is a mechanism that makes it easier for your brain to recognise sequence patterns.\n\nIn a traditional neural network, there is an input layer, hidden layer, and an output layer. In a recurrent neural network, a loop is added to pass information forward as seen in the diagram below (provided by Towards Data Science)\\cite{intro_rnn}:\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.2\\linewidth]{Images/rnn.png}\n    \\caption{Visualisation of a Recurrent Neural Network}\n\\end{figure}\n\nThe information that is forwarded is the hidden layer, which is a representation of previous inputs. How this works in practise is that you initialise your network layers and the initial hidden state. The shape and dimension of the hidden state will be dependent on the shape and dimension of your recurrent neural network. Then you loop through your inputs, pass the relevant parameter and hidden state into the RNN. The RNN returns the output and a modified hidden state. Last you pass the output of the hidden state to the output layer of the model, and it returns a prediction. \n\nThere is, however, a major problem known as short-term memory. Short-term memory is caused by something known as the vanishing gradient problem, which is also prevalent in other neural network architectures. As the RNN processes more steps, it has troubles retaining information from previous steps. Short-Term memory and the vanishing gradient is due to the nature of back-propagation. This can be comprehended through understanding how a neural network is trained\\cite{intro_rnn}.\n\n\\begin{definition}\nBack-propagation is an algorithm used to train and optimise neural networks.\n\\end{definition}\n\nTo train a recurrent neural network, you use an application of back-propagation called back-propagation through time. Training a neural network has three major steps. First, the relevant data vector is normalised between 0 and 1, the vector is fed into the RNN, and it goes through an activation function. The activation function utilised in the software is the rectified linear activation function\\cite{lstm_rnn}. \n\n\\begin{definition}\nThe rectified linear activation function is a piece-wise linear function that will output the input directly if is positive, otherwise, it will output zero.\n\\end{definition}\n\nThe function is linear for values greater than zero, meaning it has a lot of the desirable properties of a linear activation function when training a neural network using back-propagation. Yet, it is a nonlinear function as negative values are always output as zero. As a result, the rectified function is linear for half of the input domain and nonlinear for the other half, it is referred to as a piece-wise linear function\\cite{relu}. This nonlinear element is extremely important if the system has a nonlinear component, for example in predicting the evolution of the future state of the atmosphere.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.65\\linewidth]{Images/relu.png}\n    \\caption{Sketch of the Rectified Linear Activation Function}\n\\end{figure}\n\nSecond, it outputs the results. Third, it compares the prediction to the observed state using a loss function.\n\n\\begin{definition}\nA loss function outputs an error value which is an estimate of how poorly the network is performing.\n\\end{definition}\n\nThe lost function that will be utilised in the software will be the function for mean squared error. The reason for choosing this particular function is that it heavily penalises large errors, as it squares the difference between the predicted and actual value. A large error in a weather forecast is highly undesirable, hence, the use of this function. The function is represented below:\n\n\\begin{equation}\n    MSE = \\frac{1}{n}\\sum_{i=1}^n(Y_i-\\hat{Y_i})^2\n\\end{equation}\n\nIf  a vector of $n$ predictions is generated from a sample of $n$ data points on all variables, and $Y$ is the vector of observed values of the variable being predicted, with $\\hat{Y_i}$ being the predicted values.\n\n\\begin{definition}\nMean squared error is the average squared difference between the estimated values and the actual value.\n\\end{definition}\n\nReturning to the training of the RNN, it uses that error value from the loss function to do back propagation which calculates the gradients for each time step in the network. The gradient is the value used to adjust the networks internal weights, allowing the network to learn. The bigger the gradient, the bigger the adjustments and vice versa. Here is where the problem lies. When doing back propagation, the gradient of the current time step is calculated with respect to the effects of the gradients, in the time step before it. So if the adjustments to the time step before it is small, then adjustments to the current time step will be even smaller.  The gradient values will exponentially shrink as it propagates through each time step. That causes gradients to exponentially shrink as it back propagates down. The earlier layers fail to do any learning as the internal weights are barely being adjusted due to extremely small gradients.\n\nBecause of vanishing gradients, the RNN doesn’t learn the long-range dependencies across time steps. So not being able to learn on earlier time steps causes the network to have a short-term memory. In order to combat this, a long short-term memory is used\\cite{intro_rnn}.\n\n\\subsection{LSTM}\nLSTM's were created as a solution to the short-term memory problem. They have internal mechanisms called gates that can regulate the flow of information. These gates can learn which data in a sequence is important to keep or throw away. By doing that, it can pass relevant information down the long chain of sequences to make predictions. For example, if you were interested in buying a particular product, you might read a review in order to determine if the purchase of the product is a good decision. When you read a review, your brain subconsciously only remembers important keywords. You pick up words like ``amazing\", ``superb\", or ``awful\", you don't remember words such as \"the\", \"as\", or \"because\". This is what an LSTM does, it learns to keep only the relevant information to make predictions.\n\nAn LSTM has a similar control flow as a recurrent neural network. It processes data passing on information as it propagates forward. The differences are the operations within the LSTM’s cells. The core concept of LSTM’s are the cell state, and it’s various gates. The cell state is the method by which information is transferred down the sequence chain. The cell state, in theory, can carry relevant information throughout the processing of the sequence. So even information from the earlier time steps can make its way to later time steps, reducing the effects of short-term memory. As the cell state goes on its journey, information gets added or removed to the cell state via gates\\cite{lstm_rnn}.\n\n\\begin{definition}\nA gate is an electric circuit with an output which depends on the combination of several inputs.\n\\end{definition}\n\nGates contain the sigmoid activation function. The sigmoid activation function squishes values between 0 and 1. That is helpful to update or forget data because any number getting multiplied by 0 is 0, causing values to disappears or be ``forgotten\". Any number multiplied by 1 is the same value therefore that value stays the same or is ``kept\".\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.65\\linewidth]{Images/sigmoid.png}\n    \\caption{Sketch of the Sigmoid Activation Function}\n\\end{figure}\n\nThere are three types of gates utilised within a neural network: a forget gate, an input gate, and an output gate. A forget gate decides what information should be thrown away or kept. Information from the previous hidden state and information from the current input is passed through the sigmoid function. An input gate is where the previous hidden state and current input are passed into a sigmoid function. The output gate decides what the next hidden state should be. The hidden state is also used for predictions. First, we pass the previous hidden state and the current input into a sigmoid function. Then we pass the newly modified cell state to the rectified linear activation function. We multiply the rectified linear activation function output with the sigmoid output to decide what information the hidden state should carry. The output is the hidden state. The new cell state and the new hidden state is then carried over to the next time step\\cite{lstm_rnn}.\n\n\\subsection{Convolutional LSTM Network}\nThe formulation of a numerical weather prediction model is a spatiotemporal sequence forecasting problem that can be solved under a general sequence-to-sequence learning framework. \n\n\\begin{definition}\nA spatiotemporal sequence is a sequence that contains both spatial and temporal information.\n\\end{definition}\n\nIn order to better model the spatiotemporal relationships, this project will utilise ConvLSTM layers; which was proposed by Xingjian Shi et. al\\cite{convlstm}. This spatiotemporal sequence forecasting problem is different from the one-step time series forecasting problem because the prediction target of the problem is a sequence which contains both spatial and temporal structures. Although a LSTM layer has proven powerful for handling temporal correlation, it contains too much redundancy for spatial data. To address this problem, this project will use a ConvLSTM layer which has convolutional structures in both the input-to-state and state-to-state transitions\\cite{convlstm}.\n\nThe major drawback of LSTMs is in the handling spatiotemporal data due to its usage of full connections in input-to-state and state-to-state transitions in which no spatial information is encoded. To overcome this problem, a distinguishing feature of a ConvLSTM cell is that all the inputs and gates of the ConvLSTM layer are 3D tensors whose last two dimensions are spatial dimensions. To get a better picture of the inputs and states, we may imagine them as vectors standing on a spatial grid. The ConvLSTM determines the future state of a certain cell in the grid by the inputs and past states of its local neighbour. This can easily be achieved by using a convolution operator in the state-to-state and input-to-state transitions\\cite{convlstm}. This is what the ConvLSTM layer does.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{Images/convlstm.png}\n    \\caption{The architecture of a ConvLSTM cell.}\n\\end{figure}\n\n\\section{Dataset}\n\\subsection{ERA5 Atmospheric Reanalysis Dataset}\\label{era5_dataset}\nERA5 provides hourly estimates of a large number of atmospheric, land and oceanic climate variables. The data covers the Earth on a 30km grid and resolves the atmosphere using 137 levels from the surface up to a height of 80km. ERA5 includes information about uncertainties for all variables at reduced spatial and temporal resolutions. Quality-assured monthly updates of ERA5 are published within 3 months of real time. Preliminary daily updates of the dataset are available to users within 5 days of real time. ERA5 combines vast amounts of historical observations into global estimates using advanced modelling and data assimilation systems\\cite{era5}.\n\nThe ERA5 reanalysis dataset was used for training, validating and testing the performance of the neural network architecture. Reanalysis datasets provide the best guess of the atmospheric state at any point in time by combining a forecast model with the available observations. The raw data is available hourly for 40 years from 1979 to 2019 on a $0.25^{\\circ}$ latitude-longitude grid ($721 \\times 1440$ grid points) with 37 vertical levels. Since this raw dataset is quite significant, it is necessary to regrid the dataset to a lower resolution and use a smaller fraction of the available dataset\\cite{rasp2020weatherbench}.  The poles were excluded from the dataset in order to avoid a singularity, and the potential negative impact that could have on predictive ability of the neural network.\n\nIt was ultimately decided to use a spatial resolution of $1^{\\circ}$ ($179 \\times 360$ grid points) and a temporal resolution of 2 hours. The data is split into yearly NetCDF files for each variable. The entire dataset at $0.25^{\\circ}$ resolution has a size of 400GB, before the dataset was interpolated to a grid of a lower resolution. The prognostic variables of interest are temperature and geopotential, and were chosen based on meteorological considerations. Geopotential, and temperature are prognostic state variables in most physical numerical weather prediction and climate models\\cite{rasp2020weatherbench}. \n\n\\subsection{Integrated Forecasting System}\\label{ifs_section}\nThe Integrated Forecast System is a global numerical weather prediction system developed and maintained by the European Centre for Medium-Range Weather Forecasts organisation. The version of the IFS run at ECMWF is often referred to as the ``ECMWF\" or the ``European model\" in North America, to distinguish it from the American GFS. It comprises of a spectral atmospheric model with a terrain-following vertical coordinate system coupled to a 4D variational data assimilation system. In 1997 the IFS became the first operational forecasting system to use a 4D variational, data assimilation system\n\n\\begin{definition}\n4D dimensional variational data assimilation system adjusts a short-range forecast, called the background, in space and time to bring it into closer agreement with meteorological observations.\n\\end{definition}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.8\\linewidth]{Images/ifs.jpg}\n    \\caption{ECMWF Integrated Forecast System}\n\\end{figure}\n\nIt is one of the predominant global medium-range models in general use worldwide; its most prominent rival in the 6–10 day medium range include the American Global Forecast System, the Canadian Global Environmental Multiscale Model and the UK Met Office Unified Model. For context, Met Éireann utilises the IFS for medium-range forecasts; however for short-range forecasts, Met Éireann uses its own HARMONIE-AROME NWP model. The operational configuration consists of $1000 \\times 900$ grid points in the horizontal at 2.5km resolution, with 65 levels in the vertical. A 54-hour forecast is produced four times a day, at 00Z, 06Z, 12Z and 18Z\\cite{harmonie_arome_nwp}. \n\nThe IFS is the gold standard of medium-range numerical weather prediction. The current IFS deterministic forecast is computed on a cluster with 11,664 cores. One 10 day forecast at 10 km resolution takes around 1 hour of real time to compute\\cite{rasp2020weatherbench}. The Integrated Forecasting System will be used as a comparison against the neural network.\n\nTo provide physical baselines more in line with the current resolution of the neural network, it was compared against the IFS model at two coarser horizontal resolutions, T42 (approximately $2.8^{\\circ}$) with 62 vertical levels and T63 (approximately $1.9^{\\circ}$) with 137 vertical levels. It must be noted that I personally did not generate such forecasts, or perform the analysis on said forecasts. It acquired the results from Weather Bench, a benchmark dataset for data-driven weather forecasting. According to said source; computationally, a single forecast takes 270 seconds for the T42 model and 503 seconds for the T64 model on a single XC40 node with 36 cores.\n\n\\section{Implementation}\\label{implement_rnn}\nDrawing from knowledge of current numerical weather prediction model frameworks, it may seem intuitive to train a machine learning model to produce the best possible single‐step forecast from a given atmospheric state. In practice, this can yield a model that performs well for short‐range forecasts but diverges from reality for longer range predictions. This is because there are no constraints on the CNN, physical or mathematical, that would prevent it from diverging from reality when its prediction fed back in as inputs no longer resemble an atmospheric state in the training data. In order to nudge the numerical weather prediction model toward learning to predict longer‐term weather and improve its long‐term stability, the model will be trained on multiple iterated predictive steps. \n\nInitially, the model inputs included two time steps and it is tasked with predicting two output time steps. This resulted in the first couple of time step predictions producing relatively decent result, however, it quickly diverged from reality after this point. Hence, it was necessary to increase both the time steps and the output time steps to six. This increased the overall numerical stability of the model. \n\nThe dataset consists of three features: air temperature at a pressure surface of 850 hPa, geopotential at a pressure surface of 500 hPa, and air temperature at 2 metres above the surface. For a single day, there is twelve observations. The goal for this project will be to predict the relevant atmospheric parameter in 12 hours time given the last twelve hours of data. In order to make such predictions, it is necessary to create a window of the last 6 ($\\frac{12}{2}$) observations to train the model\\cite{time_series}. The neural network was trained on observational data from 2009 to 2015. The remainder of the dataset, 2016 to 2019, was preserved for validation, testing and benchmarking the neural network against physics-based models. The model was built using the open‐source Keras library for Python with Google's TensorFlow backend\\cite{numerical_stability}.\n\n\\begin{minted}[mathescape,linenos,frame=lines]{python}\n# Optimiser.\nopt = Adam(lr=1e-3, decay=1e-5)\n\\end{minted}\n\nAdam optimisation was chosen as the most appropriate optimiser for this particular model. This is a stochastic gradient descent method that is based on adaptive estimation of first-order and second-order moments. This method is computationally efficient, has little memory requirements, invariant to diagonal rescaling of gradients, and is well suited for problems that are large in terms of parameters.\n\n\\begin{minted}[mathescape,linenos,frame=lines]{python}\n# First layer of model.\nmodel.add(\n    ConvLSTM2D(\n        filters=64, \n        kernel_size=(7, 7),\n        input_shape=(6, 179, 360, 3), \n        padding='same', \n        return_sequences=True, \n        activation='tanh', \n        recurrent_activation='hard_sigmoid',\n        kernel_initializer='glorot_uniform', \n        unit_forget_bias=True, \n        dropout=0.3, \n        recurrent_dropout=0.3, \n        go_backwards=True\n    )\n)\n\\end{minted}\n\nThe above code is the first layer of the model. The activation functions utilised in this layer are predefined within Tensorflow, and have been described at great length previously. The model consists of four ConvLSTM layers in total, with similar parameters as the aforementioned layer with a few variations.\n\n\\begin{minted}[mathescape,linenos,frame=lines]{python}\n# Batch normalisation.\nmodel.add(BatchNormalization())\n\\end{minted}\n\nA consistent challenge in machine learning is that the model is updated layer-by-layer backward from the output to the input using an estimate of error that assumes the weights in the layers prior to the current layer are fixed. Because all layers are changed during an update, the update procedure is forever chasing a moving target. A batch normalisation layer occurs after each ConvLSTM layer to resolve this problem.  \n\n\\begin{definition}\nBatch normalization is a technique to help coordinate the update of multiple layers in the model.\n\\end{definition}\n\nIt does this by scaling the output of the layer, specifically by standardising the activation of each input variable per mini-batch, such as the activation of a node from the previous layer. Standardising the activation of the prior layer means that assumptions the subsequent layer makes about the spread and distribution of inputs during the weight update will not change. This has the effect of stabilising and speeding-up the training process of neural networks\\cite{batch_normalization}.\n\n\\begin{minted}[mathescape,linenos,frame=lines]{python}\n# Dropout.\nmodel.add(Dropout(0.1))\n\\end{minted}\n\nEach batch normalisation layer is then followed by a dropout. Dropout is a regularisation method that approximates training a large number of neural networks with different architectures in parallel. During training, some number of layer outputs are randomly ignored or “dropped out.” This has the effect of making the layer look-like and be treated-like a layer with a different number of nodes and connectivity to the prior layer. In effect, each update to a layer during training is performed with a different “view” of the configured layer. Dropout has the effect of making the training process noisy, forcing nodes within a layer to probabilistically take on more or less responsibility for the inputs. This conceptualisation suggests that perhaps dropout breaks-up situations where network layers co-adapt to correct mistakes from prior layers, in turn making the model more robust\\cite{dropout}.\n\n\\begin{minted}[mathescape,linenos,frame=lines]{python}\n# Add dense layer.\nmodel.add(Dense(3))\n\\end{minted}\n\nFollowing the final ConvLSTM layer, a dense layer is implemented. The dense layer is a neural network layer that is connected deeply, which means each neuron in the dense layer receives input from all neurons of its previous layer\\cite{dense}. In our case, it results in the model outputting the expected shape by reducing the filters down to the three previously mentioned features. The code for the model in its entirety can be found in appendix \\ref{model_code}. \n", "meta": {"hexsha": "a630574ed1d1651b95f09d1eba56f24cd283b963", "size": 23523, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "btyste/2021/project-book/Chapters/Model_Architecture.tex", "max_stars_repo_name": "amsimp/papers", "max_stars_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-15T10:06:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-15T10:06:17.000Z", "max_issues_repo_path": "btyste/2021/project-book/Chapters/Model_Architecture.tex", "max_issues_repo_name": "amsimp/papers", "max_issues_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "btyste/2021/project-book/Chapters/Model_Architecture.tex", "max_forks_repo_name": "amsimp/papers", "max_forks_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.515625, "max_line_length": 971, "alphanum_fraction": 0.803086341, "num_tokens": 4941, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.43291902357135303}}
{"text": "\\documentclass{article}\n\n\\title{\\sc\\LARGE CSCA67 Tutorial, Week 8\\\\\n{\\Large Nov. 2nd-Nov. 6th, 2015}}\n\\date{}\n\\author{\\sc Compiled by {\\em G. Singh Cadieux}\\\\[1ex]\n\\sc Adapted from\\\\\nD. Cunningham. \\textit{A logical introduction to proof}. Springer, 2012. \\&\\\\\nA. Bretscher, \\href{http://www.utsc.utoronto.ca/~bretscher/a67/lectures/predicates.pdf}{\\em CSCA67 Week 8 Lecture Notes}}\n\n\\usepackage{fullpage}\n\\usepackage{amsmath,amssymb}\n\\usepackage{color}\n%\\usepackage{multirow}\n\\usepackage{tikz}\n\\usepackage{hyperref}\n%\\usepackage{array}\n\n\\setlength{\\parindent}{0pt}\n\n\\begin{document}\n\\maketitle\n\n\\section{\\sc More formal logic problems}\n\n\\subsection*{Q: {\\em Show that $(a\\vee b)\\wedge\\neg(a\\wedge b)$ is logically equivalent to $a\\leftrightarrow \\neg b$ using truth tables.}}\nUsing the method discussed last week, we construct a truth table for each of the statements.\\\\\n(The truth table shown below merges the two truth tables into one.)\n\\begin{center}\n\\begin{tabular}{cc|c|c|c|c||c|c}\n$a$&$b$&$a\\wedge b$&$\\neg(a\\wedge b)$&$a\\vee b$&$(a\\vee b)\\wedge\\neg(a\\wedge b)$&$\\neg b$&$a\\leftrightarrow \\neg b$\\\\\\hline\nT&T&T&F&T&F&F&F\\\\\nT&F&F&T&T&T&T&T\\\\\nF&T&F&T&T&T&F&T\\\\\nF&F&F&T&F&F&T&F\n\\end{tabular}\n\\end{center}\nWe have shown that the truth table for $(a\\vee b)\\wedge\\neg(a\\wedge b)$ and the truth table for $a\\leftrightarrow \\neg b$ are identical (the truth value of two statements is the same, given the same combination of truth values of $a$ and $b$). Thus, the two statements are logically equivalent.\n\n\\subsection*{Q: {\\em Construct a truth table for $(p\\vee r)\\wedge(r\\wedge q)$.}}\n\\begin{center}\n\\begin{tabular}{ccc|c|c|c}\n$p$&$q$&$r$&$p\\vee r$&$r\\wedge q$&$(p\\vee r)\\wedge(r\\wedge q)$\\\\\\hline\nT&T&T&T&T&T\\\\\nT&T&F&T&F&F\\\\\nT&F&T&T&F&F\\\\\nT&F&F&T&F&F\\\\\nF&T&T&T&T&T\\\\\nF&T&F&F&F&F\\\\\nF&F&T&T&F&F\\\\\nF&F&F&F&F&F\n\\end{tabular}\n\\end{center}\n\n\\subsection*{Q: {\\em Shade regions of a Venn diagram where $(p\\vee r)\\wedge(r\\wedge q)$ is true.}}\nLet $p$ be the statement ``$x\\in P$\", $q$ be the statement ``$x\\in Q$\", and $r$ be the statement ``$x\\in R$\", where $P,Q,R$ are sets.\\\\\nThen $(p\\vee r)\\wedge(r\\wedge q)$ represents the region(s) of the Venn diagram where $x\\in P$ and $x\\in Q$, or where $x\\in R$ and $x\\in Q$.\\\\[1ex]\nLet us first shade in the region where $x\\in P$ or $x\\in R$ (red). Then let us shade in the region where $x\\in R$ and $x\\in Q$ (blue). The intersection between these regions represents our statement, since they are joined by an ``and.\"\n\\begin{center}\n\\begin{tikzpicture}\n\\filldraw[red!70] (0,0) circle[radius=0.5in];\n\\draw (0.75in,0) circle[radius=0.5in];\n\\filldraw[red!70] (0.375in,0.6in) circle[radius=0.5in];\n\\begin{scope}\n\\path[clip] (0.375in,0.6in) circle[radius=0.5in];\n\\draw[fill=blue!70,fill opacity=0.5] (0.75in,0) circle[radius=0.5in];\n\\end{scope}\n\\draw (-.65in,-.65in) rectangle (1.4in,1.25in);\n\\draw (0,0) circle[radius=0.5in];\n\\draw (0.375in,0.6in) circle[radius=0.5in];\n\\node at (0,0) {$P$};\n\\node at (0.75in,0) {$Q$};\n\\node at (0.375in,0.6in) {$R$};\n\\node at (-.5in,1.1in) {$\\mathcal{U}$};\n\\end{tikzpicture}\\qquad\n\\begin{tikzpicture}[a/.style={pin={[pin distance=.7in]above right:${\\color{red}p,\\,q,\\,r}$}}]\n\\draw (0,0) circle[radius=0.5in];\n\\draw (0.75in,0) circle[radius=0.5in];\n\\draw (0.375in,0.6in) circle[radius=0.5in];\n\\draw (-.65in,-.65in) rectangle (1.4in,1.25in);\n\\node at (-.1in,-.1in) {${\\color{red}p},\\,q,\\,r$};\n\\node at (0.85in,-.1in) {$p,\\,{\\color{red}q},\\,r$};\n\\node at (0.375in,0.7in) {$p,\\,q,\\,{\\color{red}r}$};\n\\node at (-.3in,1in) {$p,\\,q,\\,r$};\n\\node[pin={above right:$p,\\,{\\color{red}q,\\,r}$}] at (.7in,.3in) {};\n\\node[pin={above left:${\\color{red}p},\\,q,\\,{\\color{red}r}$}] at (.05in,.3in) {};\n\\node[pin={below:${\\color{red}p,\\,q},\\,r$}] at (.375in,-.2in) {};\n\\node[a] at (.3in,.2in) {};\n\\end{tikzpicture}\n\\end{center}\n\\textsc{Notice} that the Venn diagram and the truth table for this statement are equivalent. The regions that are shaded in the diagram correspond to the rows of the truth table where the statement is true, and the regions that are not shaded correspond to the rows where the statement is false.\n\n\\subsection*{{\\normalsize Let $d$ represent ``David likes baseball.\"\\\\\nLet $j$ represent ``Jaime likes gymnastics.\"\\\\\nLet $a$ represent ``Anna likes hockey.\"}\\\\\nQ: {\\em Translate each of the following propositions into English.}}\n\\subsubsection*{a) $\\neg d\\wedge j\\wedge a$}\nWe start with the most specific statement: $\\neg d$ is the negation of ``David likes baseball\", which we express in English as ``David does not like baseball\".\\\\[1ex]\nThen, $\\neg d\\wedge j\\wedge a$ is the 3-way conjunction (``and\") of ``David does not like baseball\", ``Jaime likes gymnastics\", and ``Anna likes hockey\".\\\\[1ex]\nThus, in English, our statement is ``David does not like baseball and Jaime likes gymnastics and Anna likes hockey\".\nWe might also express this as ``David does not like baseball \\textit{but} Jaime likes gymnastics and Anna likes hockey\", as well as a number of other sentence structures.\n\n\\subsubsection*{b) $\\neg (d\\wedge j)$}\nAgain, we start with the most specific statement: $d\\wedge j$ is the conjunction of ``David likes baseball\" and ``Jaime likes gymnastics\", which we express as ``David likes baseball and Jaime likes gymnastics\".\\\\[1ex]\nThen, $\\neg (d\\wedge j)$ is the negation of ``David likes baseball and Jaime likes gymnastics\".\\\\[1ex]\nThus, in English, our statement is ``It is not the case that David likes baseball and Jaime likes gymnastics\".\nWe might express this more naturally as ``David does not like baseball or Jaime does not like gymnastics\" (which is really the English translation of an equivalent but different logic statement).\n\n\\subsubsection*{c) $\\neg d\\vee\\neg a$}\nAs above, we translate $\\neg d$ to ``David does not like baseball\", and similarly, $\\neg a$ becomes ``Anna does not like hockey\".\\\\[1ex]\nThen, $\\neg d\\vee\\neg a$ is the disjunction (``or\") of ``David does not like baseball\" and ``Anna does not like hockey\".\\\\[1ex]\nThus, in English, our statement is ``David does not like baseball or Anna does not like hockey\".\n\n\\subsubsection*{d) $(d\\wedge a)\\vee j$}\nWe start with the most specific statement: $d\\wedge a$ is the conjunction of ``David likes baseball\" and ``Anna likes hockey\", which we express in English as ``David likes baseball and Anna likes hockey\".\\\\[1ex]\nThen, $(d\\wedge a)\\vee j$ is the disjunction of ``David likes baseball and Anna likes hockey\", and ``Jaime likes gymnastics\".\\\\[1ex]\nThus, in English, our statement is ``David likes baseball and Anna likes hockey, or Jaime likes gymnastics\".\\\\\nThe comma separating ``David likes [\\ldots]\" and ``or Jaime likes gymnastics\" is meant to indicate that these are two separate clauses of the sentence, so that it is not interpreted as a conjunction of ``David likes baseball\" and ``Anna likes hockey, or Jaime likes gymnastics\".\n\n\\subsection*{Q: {\\em Translate each of the following English sentences into formal logic.}}\n\\subsubsection*{a) ``Jaime doesn't like gymnastics but David likes baseball.\"}\n\nWe start with the most general statement: from the language ``\\ldots but\\ldots\", we know that the statement is a conjunction (``and\").\\\\[1ex]\nThen the first part of the conjunction ``Jaime doesn't like gymnastics\" is the negation of ``Jaime likes gynmastics\".\\\\[1ex]\nThus, in formal logic, our statement is $\\neg j\\wedge d$.\n\n\\subsubsection*{b) ``Either David likes baseball or Anna likes hockey, and Jaime likes gymnastics.\"}\n\nAgain, we start with the most general statement: from the language ``\\ldots and\\ldots\", we know that the statement is a conjunction.\\\\[1ex]\nThen the first part of the conjunction ``Either David likes baseball or Anna likes hockey\" is the disjunction (``or\") of ``David likes baseball\" and ``Anna likes hockey\".\\\\\nHowever, we must be careful: in English, the use of the word ``either\" implies exclusion. The ``$x$ or $y$\" we have previously seen is true if $x$ or $y$ or \\textit{both} are true (known as ``inclusive or\"); this ``either $x$ or $y$\" is true if $x$ or $y$ are true, but \\textit{not} if both are true.\\\\\nWe can express this more clearly as ``David likes baseball and Anna doesn't like hockey, or David doesn't like baseball and Anna likes hockey\".\\\\[1ex]\nThus, in formal logic, our statement is $((d\\wedge\\neg a)\\vee(\\neg d\\wedge a))\\wedge j$.\\\\[1ex]\nAlternatively, because of the ambiguity of the English language, we may consider this statement to be a disjunction of ``David likes baseball\" and ``Anna likes hockey, and Jaime likes gymnastics\". The comma separating ``Either David likes baseball or Anna likes hockey\" and `` and Jaime likes gymnastics\" suggests that this is not the case, but it is possible.\\\\\nThen our statement would be $(d\\wedge\\neg(a\\wedge j))\\vee(\\neg d\\wedge(a\\wedge j))$.\n\n\\subsubsection*{c) ``If Anna likes hockey then David likes baseball.\"}\n\nFrom the language ``if\\ldots then\\ldots\", we know that the statement is an implication, with ``Anna likes hockey\" as the antecedent (first half) and ``David likes baseball\" as the consequent (second half).\\\\[1ex]\nThus, in formal logic, our statement is $a\\to d$.\n\n\\section{\\sc Predicate Logic}\nSo far, we have discussed something that we have referred to as ``formal logic.\" However, we have only studied one branch of formal logic, which we will now properly call \\textsc{sentential logic} (also known as ``propositional logic\").\\\\[1ex]\nHere, we introduce another branch of formal logic: \\textsc{predicate logic}.\\\\[1em]\nPredicate logic addresses some of the limitations of sentential logic:\n\\begin{itemize}\n\\item Sentential logic cannot express quantitities/categories, eg. ``\\textit{Every} person has a mother,\" ``\\textit{Some} horses are white\"\n\\item Sentential logic cannot express relationships between properties, eg. ``If X is married to Y, then Y is married to X\"\n\\end{itemize}\n\nPredicate logic uses \\textsc{predicates} instead of statements/propositions. Predicates are sentences containing variables which can be assigned values. For example, ``$x>5$\" is a predicate, where $x$ is the variable.\\\\[1ex]\nPredicates are \\textit{not} statements themselves because they have no inherent truth value.\\\\\n\\textsc{Consider}: can we say definitively that ``$x>5$\" is true or false?\\\\[1ex]\nHowever, once the variable(s) in the predicate have been assigned values, then the sentence becomes a statement. For example, if we let $x=3$, then ``$x>5$\" is a false statement, and if we let $x=6$, then ``$x>5$\" is a true statement.\n\n\\subsection{\\em Syntax}\n\nThe language of sentential logic is composed of: sentence symbols, operators/connectives, and parentheses.\\\\\nSince predicate logic uses predicates rather than statements, it uses predicate symbols rather than sentence symbols.\\\\ Predicate symbols typically follow mathematical function notation, eg. $\\overbrace{P(\\underbrace{x}_{\\text{variable}})}^{\\text{predicate}}$.\\\\\nThe name of the predicate is typically a single uppercase letter, and the variable is denoted as a single lowercase letter.\\\\[1ex]\n\\textsc{Note} that, as with a mathematical function, the letter chosen to represent the variable is simply a placeholder. $P(x)$ is identical to $P(y),\\,P(z)$, etc.\\\\[1em]\nWe can then use the same connectives as in sentential logic to combine predicates and create compound predicates, eg.\n\\begin{itemize}\n\\item $P(x):\\,2x=6$\n\t\\begin{itemize}\n\t\\item $P(3)$ is true\n\t\\item $P(10)$ is false\n\t\\end{itemize}\n\\item $Q(x,y):\\,``x\\text{ is larger than }y\"$\n\t\\begin{itemize}\n\t\\item $Q(\\text{Earth},\\text{moon})$ is true\n\t\\item $Q(\\text{apple},\\text{car})$ is false\n\t\\end{itemize}\n\\item $R(x):\\,x<10$\n\\item $P(x)\\wedge R(x)\\equiv ``x\\text{ is between 5 and 10}\"$\n\t\\begin{itemize}\n\t\\item $P(6)\\wedge R(6)$ is true\n\t\\item $P(14)\\wedge R(14)$ is false\n\t\\end{itemize}\n\\end{itemize}\n\\textsc{Note} that, although $x$ is a placeholder, $x$ represents the same value everywhere it is used within a predicate. For example, if we create the compound predicate $P(x)\\wedge R(x)$, we cannot assign values such that we have $P(6)\\wedge R(14)$.\\\\[1ex]\nConversely, different variables may represent different values. For example, if we create the compound predicate $P(x)\\wedge R(y)$, we \\textit{can} assign $x=6$ and $y=14$ such that we have $P(6)\\wedge R(14)$.\n\\begin{itemize}\n\\item $S(x):\\,x<20$\n\\item $\\neg S(x)\\equiv ``x$ is greater than or equal to 20\"\n\\item $R(x)\\to S(x)\\equiv$ ``if $x$ is less than 10, then it is also less than 20\"\n\t\\begin{itemize}\n\t\\item $R(3)\\to S(3)$ is true\n\t\\item $R(25)\\to S(25)$ is (vacuously) true\n\t\\end{itemize}\n\\end{itemize}\nPredicate logic also adds operators called \\textsc{quantifiers}, which allow us to describe ranges of values for variables, rather than assigning them individual values.\\\\[1em]\nThe \\textsc{existential} quantifier is denoted $\\exists$ and means ``(there) exists.\"\\\\[1ex]\nFor example, if $P(x):\\,``x^2=5\"$, then $\\exists x(P(x))$ means ``There exists (at least) one value of $x$ for which $x^2=5$\". The statement $\\exists x(P(x))$ is true, since $P(\\sqrt{5})$ and $P(-\\sqrt{5})$ are both true.\\\\[1ex]\nIf $Q(x):\\,``x^2=-5\"$, then $\\exists x(Q(x))$ means ``There exists (at least) one value of $x$ for which $x^2=-5$\", which is false (assuming that $x$ is restricted to the set of reals).\\\\[1em]\nThe \\textsc{universal} quantifier is denoted $\\forall$ and means ``for all/every.\"\\\\[1ex]\nFor example, if $P(x):\\,``x^2=5\"$, then $\\forall x(P(x))$ means ``For every possible value of $x$, $x^2=5$\". The statement $\\forall x(P(x))$ is false, since only $P(\\sqrt{5})$ and $P(-\\sqrt{5})$ are true, and $P(x)$ is false for any other value of $x$.\\\\[1ex]\nIf $R(x):\\,x>5$ and $S(x):\\,x>7$, then $\\forall x(S(x)\\to R(x))$ means ``For every possible value of $x$, if $x$ is greater than 7, $x$ is also greater than 5\". We know that this statement is true, since $5<7$ and $7<x$.\\\\[1em]\nAs with sentential logic, we may use parentheses to group predicates and operators. When parentheses are omitted, the operators are applied according to the following precedence rules:\n\\begin{center}\n\\begin{tikzpicture}\n\\draw[<->] (0,0) node[left,align=center,font=\\small] {highest\\\\precedence} \n-- (.5,0) node[above] {$\\neg$}\n-- (1.5,0) node[above] {$\\wedge$}\n-- (2.5,0) node[above] {$\\vee$}\n-- (3.5,0) node[align=center] {$\\exists$\\\\$\\forall$}\n-- (4.5,0) node[align=center] {$\\to$\\\\$\\leftrightarrow$}\n-- (5,0) node[align=center,right,font=\\small] {lowest\\\\precedence};\n\\end{tikzpicture}\n\\end{center}\n\n\\subsection{\\em Ordering of quantifiers}\n\nWhen we have a statement containing multiple, different quantifiers, such as $\\forall x\\exists y(P(x,y))$, the quantified variables are read left to right. For example, if $P(x,y):\\,x\\cdot y=5$, then $\\forall x\\exists y(P(x,y))$ means ``For every number $x$, there exists a number $y$ such that $x\\cdot y=5$\".\\\\[1ex]\n\\textsc{Does the} meaning of the sentence change if we reorder the quantifiers?\\\\\nIt depends upon the predicate.\\\\[1ex]\nFor example, if $P(x,y):\\,x>y$, then $\\forall x\\exists y(P(x,y))$ means ``For every number $x$, there exists a number $y$ such that $x$ is greater than $y$\".\\\\\nWe know that this statement is true because the set of integers (or reals, depending upon the allowed values of $x$) is infinite. Thus, by definition, there is always a number larger than any number we choose from the set.\\\\[1ex]\nBut $\\exists y\\forall x(P(x,y))$ means ``There exists a number $y$ such that, for every number $x$, $x$ is greater than $y$\".\\\\\nWe know that this statement is false because it is saying that there is some minimum integer (since every other integer is larger than it). Since the integers are infinite, this is impossible.\\\\[1ex]\nHere, the order of the quantifiers is significant.\n\n\\subsection{\\em Negation of quantifiers}\n\nIn addition to negating predicates using the negation operator, we want to be able to negate quantifiers - that is, we want to be able to say ``There does \\textit{not} exist\\ldots\" and ``\\textit{It is not the case that} for all\\ldots\".\\\\[1ex]\nFor some predicate $P(x)$, ``There does \\textit{not} exist an $x$ such that $P(x)$ is true\" is equivalent to saying ``$P(x)$ is false for every value of $x$\", which we can write formally as $\\forall x(\\neg P(x))$.\\\\[1ex]\nFor some predicate $P(x)$, ``\\textit{It is not the case that}, for every value of $x$, $P(x)$ is true\" is equivalent to saying ``There is some value of $x$ for which $P(x)$ is false\", which we can write formally as $\\exists x(\\neg P(x))$.\\\\[1ex]\nThus, the negation of $\\exists x(P(x))$ is $\\forall x(\\neg P(x))$ and the negation of $\\forall x(P(x))$ is $\\exists x(\\neg P(x))$.\\\\[1em]\nFor example, if $P(x)$: ``$x$ is tall\", where $x$ is a person, then\n\\begin{itemize}\n\\item $\\exists x(P(x))$ means ``There exists a person who is tall\"\n\\item $\\forall x(\\neg(P(x))$ means ``Every person is not tall\", or ``There does not exist a person who is tall\"\n\\item $\\forall x(P(x))$ means ``All people are tall\"\n\\item $\\exists x(\\neg P(x))$ means ``There exists a person who is not tall\", or ``Not every person is tall\"\n\\end{itemize}\n\n\\section{\\sc Additional practice problems}\nLet $P(x,y)$ be the predicate ``$x\\cdot y=12$\", where $x,y$ are integers.\\\\\n{\\bf Q: Which of the following statements is true?}\n\\begin{itemize}\n\\item $P(3,4)$\n\\item $P(3,5)$\n\\item $P(2,6)\\vee P(3,7)$\n\\item $\\forall x,\\forall y(P(x,y)\\to P(y,x))$\n\\item $\\forall x,\\exists y(P(x,y))$\n\\end{itemize}\n\\vspace{1ex}Given the predicates\\\\\n$L(x)=$``$x$ is a lion.\"\\\\\n$F(x)=$``$x$ is fuzzy.\"\\\\\nwhere $x$ is a mammal,\\\\\n{\\bf Q: Translate ``All lions are fuzzy\" into predicate logic.}\\\\[1ex]\n{\\bf Q: Translate ``Some lions are fuzzy\" into predicate logic.}\\\\[1em]\nConsider the three predicates\\\\\n$P(x)$ symbolizes the statement ``$x$ is a prime number\"\\\\\n$E(x)$ symbolizes the statement ``$x$ is even\"\\\\\n$D(x, y)$ symbolizes the statement ``$x$ evenly divides $y$\"\\\\\nwhere $x$ and $y$ represent integers.\\\\\n{\\bf Q: Find some values for the variables that make the following logical formulas true, and others making them false.}\n\\begin{itemize}\n\\item $P(x) \\wedge E(x)$\n\\item $E(x) \\vee D(x, y)$\n\\item $\\neg P(x) \\wedge D(x, y)$\n\\item $D(x, y) \\to\\neg P(x)$\n\\end{itemize}\n\\vspace{1ex}\\textit{Tarski's World} is a computer program that is meant to be an introduction to predicate logic.\\\\\nYou can build two-dimensional worlds of shapes, describe them using predicates, and test whether your predicates are true or false.\\\\\nExperiment with Tarski's World using the following implementation: \\href{http://courses.cs.washington.edu/courses/cse590d/03sp/tarski/tarski.html}{Tarski's World (Java Applet)}\n\n\\end{document}", "meta": {"hexsha": "ee5d827b8b62137b7ed62439409ad2b523cbe3c5", "size": 18481, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "teaching/resources/Formal-Logic-Predicate-Logic-Tut.tex", "max_stars_repo_name": "ozhanghe/ozhanghe.github.io", "max_stars_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-23T17:23:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-23T17:23:00.000Z", "max_issues_repo_path": "teaching/resources/Formal-Logic-Predicate-Logic-Tut.tex", "max_issues_repo_name": "ozhanghe/ozhanghe.github.io", "max_issues_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-06-05T03:48:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-18T03:30:18.000Z", "max_forks_repo_path": "teaching/resources/Formal-Logic-Predicate-Logic-Tut.tex", "max_forks_repo_name": "ozhanghe/ozhanghe.github.io", "max_forks_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-11T13:35:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T05:34:01.000Z", "avg_line_length": 68.7026022305, "max_line_length": 362, "alphanum_fraction": 0.7021806179, "num_tokens": 5831, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.803173801068221, "lm_q1q2_score": 0.43289720207171906}}
{"text": "\\vsssub\n\\subsubsection{~$S_{in} + S_{ds}$: \\wam\\ cycle 4 (ECWAM)} \\label{sec:ST3}\n\\vsssub\n\n\\opthead{ST3}{\\wam\\ model}{F. Ardhuin}\n\n\\noindent \nThe wind-wave interaction source terms described here are based on the wave\ngrowth theory of \\cite{art:Miles57}, modified by \\cite{art:Jan82}. The\npressure-slope correlations that give rise to part of the wave generation are\nparameterized following \\cite{art:Jan91}. \n%A wave dissipation term due to shear\n%stresses variations in phase with the orbital velocity is added for the swell\n%part of the spectrum, based on the swell decay observations of\n%\\cite{art:ACC09}.\n\nThis parameterization was further extended by \\cite{rep:AB02} to take into\naccount a stronger gustiness in unstable atmospheric conditions. This effect is\nincluded in the present parameterization and is activated with the optional\n{\\code STAB3} switch. The formula used in {\\code STAB3} is not described herein. \nFor that, the reader is referred to \\cite{rep:AB02}. If {\\code STAB3} is used, the air-sea \ntemperature differences should be provided by the user, e.g. using {\\file ww3\\_prep}.\n\nEfforts have been made to make the present implementation as\nclose as possible to the one in the ECWAM model \\citep{rep:Bea05}, in\nparticular the stress lookup tables were verified to be identical. \nLater modifications include the addition of a negative part in the wind input \nto represent swell dissipation.\n\nThe source term reads \\citep{bk:Jan04}\n\\begin{equation}\n\\cS_{in}(k,\\theta) =\n\\frac{\\rho_a}{\\rho_w}\\frac{\\beta_{\\mathrm{max}}}{\\kappa^2}{\\mathrm e}^{Z}Z^4\n\\left(\\frac{u_\\star}{C}+z_\\alpha\\right)^2 \\cos^{p_{in}}(\\theta - \\theta_u) \\sigma N\n\\left(k,\\theta\\right) + S_{out}(k,\\theta),\\label{eq:SinWAM4}\n\\end{equation}\n\n\\noindent where $\\rho_a$ and $\\rho_w$ are the air and water densities,\n$\\beta_{\\mathrm{max}}$ is a non-dimensional growth parameter (constant),\n$\\kappa$ is von K\\'{a}rm\\'{a}n' constant, and $p_{in}$ is a constant that\ncontrols the directional distribution of $\\cS_{in}$. In the present\nimplementation the air/water density ratio ${\\rho_a}/{\\rho_w}$ is constant. We\ndefine $Z=\\log(\\mu)$ where $\\mu$ is given by \\cite{art:Jan91}  Eq.~(16), and\ncorrected for intermediate water depths, so that\n\n\\begin{equation}\nZ=\\log(k z_1)+\\kappa/\\left[\\cos\\left(\\theta - \\theta_u\\right)\n\\left(u_\\star/C + z_\\alpha \\right)\\right],\n\\end{equation}\n\n\\noindent\nwhere $z_1$ is a roughness length modified by the wave-supported stress\n$\\tau_w$, and $z_\\alpha$ is a wave age tuning parameter\\footnote{Although this\ntuning parameter $z_\\alpha$ is not well described in WAM-Cycle4 documentation,\nit has an important effect on wave growth. Essentially it shifts the wave age\nof the long waves, which typically increases the growth, and even generates\nwaves that travel faster than the wind. This accounts for some gustiness in\nthe wind and should possibly be resolution-dependent. For reference, this\nparameter was not properly set in early versions of the SWAN model, as\ndiscovered by R. Lalbeharry.}.  The roughness $z_1$ is defined as,\n\n\\begin{eqnarray}\nU_{10}&=&\\frac{u_\\star}{\\kappa} \\log\\left(\\frac{z_u}{z_1}\\right) \\\\\nz_1&=&\\alpha_0 \\frac{\\tau}{ \\sqrt{1-\\tau_w/\\tau}},\n\\end{eqnarray}\n\n\\noindent\nwhere $\\tau=u_\\star^2$, and $z_u$ is the height at which the wind is\nspecified. These two equations provide an implicit functional dependence of\n$u_\\star$ on $U_{10}$ and $\\tau_w/\\tau$. This relationship is then tabulated\n\\citep{art:Jan91, rep:Bea07}.\n\nAn important part of the parameterization is the calculation of the\nwave-supported stress $\\tau_w$,\n\n\\begin{equation}\n\\tau_w=\\left|\\int_0^{k_{\\max}} \\int_0^{2 \\pi} \\frac{\\cS_{in}(k',\\theta)}{C}\n\\left(\\cos \\theta, \\sin \\theta \\right)  {\\mathrm d} k' \\mathrm d \\theta +\n\\tau_{\\mathrm{hf}}(u_\\star,\\alpha) \\left(\\cos \\theta_u, \\sin \\theta_u \\right)\n\\right|,\\label{eq:tauwint}\n\\end{equation}\n\n\\noindent\nwhich includes the resolved part of the spectrum, up to $k_{\\max}$, as well as\nthe stress supported by shorter waves, $\\tau_{\\mathrm{hf}}$. Assuming a\n$f^{-X}$ diagnostic tail beyond the highest frequency, $\\tau_{\\mathrm{hf}}$ is\ngiven by\n\n\\begin{eqnarray}\n\\tau_{\\mathrm{hf}}(u_\\star,\\alpha)&= &\\frac{u_{\\star}^2}{g^2}\n\\frac{\\sigma_{\\max}^X 2 \\pi \\sigma }{2 \\pi C_g(k_{\\max})} \\int_0^{2 \\pi} N\n\\left(k_{\\max},\\theta \\right)\n\\max\\left\\{0,\\cos\\left(\\theta-\\theta_u\\right)\\right\\}^3 d \\theta \\nonumber \\\\\n& & \\times \\frac{\\beta_{\\mathrm{max}}}{\\kappa^2}\n\\int_{\\sigma_{\\max}}^{0.05*g/u_\\star} \\frac{{\\mathrm\ne}^{Z_{\\mathrm{hf}}}Z_{\\mathrm{hf}}^4}{\\sigma^{X-4}} {\\mathrm d} \\sigma\n\\label{eq:tauhfint}\n\\end{eqnarray}\n\n\\noindent\nwhere the second integral is a function of $u_\\star$ and the Charnock\ncoefficient $\\alpha$ only, which is easily tabulated. In practice the\ncalculation is coded with $X=5$, and the variable $Z_{\\mathrm{hf}}$ is defined\nby,\n\n\\begin{equation}\nZ_{\\mathrm{hf}}(\\sigma)=\\log(k z_1)+\\min\\left\\{\\kappa/\\left(u_\\star/C +\nz_\\alpha \\right),20\\right\\}.\n\\end{equation}\n\n\\noindent\nThis parameterization is sensitive to the spectral level at $k_{\\max}$.\nA higher spectral level will lead to a larger value of $u_\\star$ and thus\npositive feedback on the wind input via $z_1$. This sensitivity is exacerbated\nby the sensitivity of the high-frequency spectral level to the presence of\nswell via the dissipation term.\n\n\\begin{table}[htb]\n\\begin{center}\n\\begin{tabular}{|l|c|c|c|c|c|} \\hline \\hline\nPar.         &  WWATCH var.           & namelist & WAM4 & BJA   & Bidlot 2012 \\\\\n\\hline\n  $z_u$ &  ZWND                       & SIN3 & 10.0    & 10.0   & 10.0   \\\\\n  $\\alpha_0$ &  ALPHA0                & SIN3 & 0.01    & 0.0095 &  0.0095 \\\\\n  $\\beta_{\\mathrm{max}}$ & BETAMAX    & SIN3 & 1.2     & 1.2    & 1.2  \\\\\n  $p_{\\mathrm{in}}$ &  SINTHP         & SIN3 & 2       & 2      & 2  \\\\\n  $z_\\alpha$ &  ZALP                  & SIN3 & 0.0110  & 0.0110 &  0.0080 \\\\\n  $s_1$ &  SWELLF                     & SIN3 & 0.0     & 0.0    & 1.0   \\\\\n\\hline\n\\end{tabular} \\end{center}\n\\caption{Parameter values for WAM4, BJA and the 2012 update in the ECWAM model. Source term\n  parameterizations that can be reset via the {\\F SIN3} and {\\F SDS3} namelist. BJA is\n  generally better than WAM4. The default parameters in ST3 corresponds to BJA. Please\n  note that the names of the variables only apply to the namelists. In the source\n  term module the names are slightly different, with a doubled first letter, in\n  order to differentiate the variables from the pointers to these variables.} \\label{tab:WAM4_parSIN}\n\\botline\n\\end{table}\n\n\\begin{table}[htb] \n\\begin{center}\n\\begin{tabular}{|l|c|c|c|c|c|} \\hline \\hline\nPar.                               &  WWATCH var.         & namelist & WAM4 & BJA   & Bidlot 2012 \\\\\n\\hline\n  $C_{\\mathrm{ds}}$                 &  SDSC1          & SDS3 & -4.5 & -2.1& -1.33       \\\\\n  $p$                               &  WNMEANP        & SDS3 & -0.5 & 0.5 &  0.5        \\\\\n  $p_{\\mathrm{tail}}$               &  WNMEANPTAIL    & SDS3 & -0.5 & 0.5 &  0.5        \\\\\n  $\\delta_1$                        &  SDSDELTA1      & SDS3 & 0.5  & 0.4 &  0.5        \\\\\n  $\\delta_2$                        &  SDSDELTA2      & SDS3 & 0.5  & 0.6 &  0.5 \\\\\n  \\hline \\hline\n\\end{tabular} \\end{center}\n\\caption{Parameter values for WAM4, BJA and the update by \\cite{pro:Bid12}. Source term\nparameterizations that can be reset via the {\\F SDS3} namelist. BJA is generally\nbetter than WAM4. Please note that the\nnames of the variables only apply to the namelists. In the source term module\nthe names are slightly different, with a doubled first letter, in order to\ndifferentiate the variables from the pointers to these variables.} \\label{tab:WAM4_parSDS}\n\\botline\n\\end{table}\n\n\nA linear damping of swells was introduced in the operational ECWAM model in September 2009. It takes \nthe form given by \\cite{bk:Jan04} \n\n\\begin{equation}\nS_{out}(k,\\theta)= 2 s_1  \\kappa \\frac{\\rho_a }{\\rho_w} \\left(\\frac{u_\\star}{C}\\right)^2 \n\\left[\\cos \\left(\\theta - \\theta_u\\right) - \\frac{\\kappa C}{u_\\star \\log(k z_0)}\\right]\n\\end{equation}\n\n\\noindent where $s_1$ is set to 1 when this damping is used and 0 otherwise. For $s_1=0$ \nthe parameterization is the WAM4 or BJA parameterization (see Table \\ref{tab:WAM4_parSIN}). \n\nDue to the increase in high-frequency input compared to WAM3, the dissipation\nfunction was adapted by Janssen (1994) from the WAM3 dissipation, and later\nreshaped by \\cite{rep:Bea05}. That later modification is referred to as \"BJA\" for Bidlot, \nJanssen and Abdallah. A more recent modification, strongly improved the model results for \nPacific swells, at the price of an underestimation of the highest sea states. This \ncorresponds to the ECMWF WAM model contained in the IFS version CY38R1 \\citep{pro:Bid12}. Note that these parameters were optimized for use of neutral winds from the \noperational ECMWF analysis. Using these with other wind products may require a re-tuning of these coefficients. For example, with NCEP or CFSRR winds, the value of BETAMAX \nshould probably be reduced or ZWND increased. \n\n\nThe generic form of the WAM4 dissipation term is,\n\n\\begin{equation}\nS_{ds}\\left(k,\\theta\\right)^{\\mathrm{WAM}} = C_{ds} \\overline{\\alpha}^2\n \\overline{\\sigma} \\left[\\delta_1 \\frac{k}{\\overline{k}} + \\delta_2\n\\left(\\frac{k}{\\overline{k}}\\right)^2\\right]\\label{eq:SdsWAM4}\nN\\left(k,\\theta\\right)\n\\end{equation}\n\n\\noindent\nwhere $C_{ds}$ is a non-dimensional constant $\\delta_1$ and $\\delta_2$ are\nweight parameters,\n\n\\begin{equation}\n\\overline{k}=\\left[\\frac{\\int k^p N\\left(k,\\theta\\right) {\\mathrm d}\n\\theta}{\\int N\\left(k,\\theta\\right) {\\mathrm d} \\theta}\\right]^{1/p}\n\\end{equation}\n\n\\noindent\nwith $p$ a constant power. Similarly, the mean frequency is defined as\n\n\\begin{equation}\n\\overline{\\sigma}=\\left[\\frac{\\int \\sigma^p N\\left(k,\\theta\\right) {\\mathrm d}\n\\theta}{ \\int N\\left(k,\\theta\\right) {\\mathrm d} \\theta}\\right]^{1/p},\n\\end{equation}\n\n\\noindent\nso that the mean steepness is $\\overline{\\alpha}=E \\overline{k}^2$.\n\nThe mean frequency also occurs in the definition of the maximum frequency of\nprognostic integration of the source terms. Since the definition of that\nfrequency may be different from that of the source term it is defined with\nanother exponent $p_{\\mathrm{tail}}$.\n\nUnfortunately these parameterizations are sensitive to swell. An increase in\nswell height typically reduces dissipation at the windsea peak because the mean wavenumber $\\overline{k}$ and \nthus the mean steepness $\\overline{\\alpha}$ are reduced. For $p< 2$, as in the WAM-Cycle 4 and BJA\nparameterizations, this sensitivity is much larger and opposite to the expected effect of\nshort wave modulation by long waves.\n\nThe source term code was generalized to\nallow the use of WAM4, BJA or others ECWAM parameterization, via a simple change of\nthe parameters in the namelists {\\F SIN3} and {\\F SDS3}, see Tables \\ref{tab:WAM4_parSIN} and \\ref{tab:WAM4_parSDS}. At present, the default values of the namelist\nparameters correspond to BJA \\citep{rep:Bea05}.\n\n", "meta": {"hexsha": "91a7fca1058a1ba38450b0f96c30850f9524852d", "size": 10925, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/eqs/ST3.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/eqs/ST3.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/eqs/ST3.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 47.9166666667, "max_line_length": 172, "alphanum_fraction": 0.7022425629, "num_tokens": 3474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.43289719953239686}}
{"text": "\\documentclass{report}\n\\usepackage{amsfonts, amsmath, amssymb, hyperref}\n\\renewcommand{\\chaptername}{}\n\\setlength{\\parindent}{0pt}\n\n\\title{Solutions to exercises in SICP (2e)}\n\\author{Paul Tan (\\href{http://pauljxtan.com}{website}, \\href{https://github.com/pauljxtan}{github})}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\chapter{Exercise 1.10}\n\nThis is a pretty fun exercise in rendering Scheme procedures in mathematical notation. Personally, I find it helps with visualizing the recursive process. \\\\\n\nAckermann's function is defined in the question as\n\n\\begin{equation}\n  A(x, y) = \\begin{cases}\n    0 & \\text{if } y = 0 \\\\\n    2y & \\text{if } x = 0 \\\\\n    2 & \\text{if } y = 1 \\\\\n    A(x - 1, A(x, y - 1)) & \\text{otherwise}\n  \\end{cases}\n\\end{equation}\n\nFor each of the given expressions, we have\n\n\\begin{align*}\n  A(1, 10) &= A(0, A(1, 9)) \\\\\n           &= A(0, A(0, A(1, 8))) \\\\\n           &= A(0, A(0, A(0, A(1, 7)))) \\\\\n           &= A(0, A(0, A(0, A(0, A(1, 6))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(1, 5)))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(1, 4))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 3)))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 2))))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 1)))))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2))))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2\\cdot2)))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2\\cdot2\\cdot2))))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, A(0, 2\\cdot2\\cdot2\\cdot2)))))) \\\\\n           &= A(0, A(0, A(0, A(0, A(0, 2\\cdot2\\cdot2\\cdot2\\cdot2))))) \\\\\n           &= A(0, A(0, A(0, A(0, 2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2)))) \\\\\n           &= A(0, A(0, A(0, 2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2))) \\\\\n           &= A(0, A(0, 2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2)) \\\\\n           &= A(0, 2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2) \\\\\n           &= 2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2\\cdot2 \\\\\n           &= 2^{10}\n\\end{align*}\n\nIn general, it appears that for $n > 0$ we have\n\n\\begin{equation}\n  A(1, n) = 2^n\n\\end{equation}\n\n(Recall that $A(1, 0) = 0$ by definition.) \\\\\n\nNext expression:\n\n\\begin{align*}\n  A(2, 4) &= A(1, A(2, 3)) \\\\\n          &= A(1, A(1, A(2, 2))) \\\\\n          &= A(1, A(1, A(1, A(2, 1)))) \\\\\n          &= A(1, A(1, A(1, 2))) \\\\\n          &= A(1, A(1, 2^2)) \\quad &\\text{using the result found above} \\\\\n          &= A(1, 2^{2^2}) \\quad &\\text{ditto} \\\\\n          &= 2^{2^{2^2}} \\quad &\\text{and again} \\\\\n          &= 2^{2^4} \\\\\n          &= 2^{16} \\\\\n          &= 65536\n\\end{align*}\n\nAnd one more:\n\n\\begin{align*}\n  A(3, 3) &= A(2, A(3, 2)) \\\\\n          &= A(2, A(2, A(3, 1))) \\\\\n          &= A(2, A(2, 2)) \\\\\n          &= A(2, A(1, A(2, 1)) \\\\\n          &= A(2, A(1, 2)) \\\\\n          &= A(2, A(0, A(1, 1))) \\\\\n          &= A(2, A(0, 2)) \\\\\n          &= A(2, 4) \\\\\n          &= A(1, A(2, 3)) \\\\\n          &= A(1, A(1, A(2, 2))) \\\\\n          &= A(1, A(1, A(1, A(2, 1)))) \\\\\n          &= A(1, A(1, A(1, 2))) \\\\\n          &= A(1, A(1, A(0, A(1, 1)))) \\\\\n          &= A(1, A(1, A(0, 2))) \\\\\n          &= A(1, A(1, 4)) & \\text{familiar pattern emerging\\dots} \\\\\n          &= A(1, A(0, A(1, 3))) \\\\\n          &= A(1, A(0, A(0, A(1, 2)))) \\\\\n          &= A(1, A(0, A(0, A(0, A(1, 1))))) \\\\\n          &= A(1, A(0, A(0, A(0, 2)))) \\\\\n          &= A(1, A(0, A(0, 4))) \\\\\n          &= A(1, A(0, 8)) \\\\\n          &= A(1, 16) \\\\\n          &= 2^{16} \\\\\n          &= 65536 \\\\\n\\end{align*}\n\n(Gotta say, the way the equations ``fan'' in and out like that is pretty neat. First it fans out 3 times, then 2, then just once on the final expansion.) \\\\\n\nJust to check, I computed these values in \\textbf{sicp\\_1-10\\_check.scm} and they are indeed correct. Phew! \\\\\n\nThe last part is essentially the same idea, but with a variable parameter $n$. Let's see\\dots\n\n\\begin{align*}\n  f(n) &= A(0, n) \\\\\n       &= 2n\n\\end{align*}\n\n\\begin{align*}\n  g(n) &= A(1, n) \\\\\n       &= A(0, A(1, n - 1)) \\\\\n       &= 2 \\cdot A(1, n - 1) \\\\\n       &= 2 \\cdot A(0, A(1, n - 2)) \\\\\n       &= 2 \\cdot 2 \\cdot A(1, n - 2) \\\\\n       &= \\dots & \\text{follow the pattern\\dots} \\\\\n       &= 2^{n - 1} \\cdot A(1, 1) \\\\\n       &= 2^{n - 1} \\cdot 2 \\\\\n       &= 2^n & \\text{as found earlier!}\n\\end{align*}\n\n\\begin{align*}\n  h(n) &= A(2, n) \\\\\n       &= A(1, A(2, n - 1)) \\\\\n       &= A(1, A(1, A(2, n - 2))) \\\\\n       &= A(1, A(1, A(1, A(2, n - 3)))) \\\\\n\\end{align*}\n\nAt this point, note that the levels of nesting is equal to the number $m$ in $n - m$ at the end\\dots\n\n\\begin{align*}\n  \\Rightarrow h(n)\n       &= A(1, A(1, A(1, \\dots A(1, A(2, 1)) \\dots ))) \\\\\n       &= A(1, A(1, A(1, \\dots A(1, 2) \\dots ))) & \\text{We know what $A(1, n)$ is from earlier!} \\\\\n       &= A(1, A(1, A(1, \\dots 2^2 \\dots ))) & \\text{Now we \"fold\" it back in $n - 1$ times\\dots} \\\\\n       &= 2^{2^{2^{\\dots}}} & \\text{with $n$ \"2\"s} \\\\\n\\end{align*}\n\nThat is,\n\n\\begin{align*}\n  A(2, 1) &= 2 \\\\\n  A(2, 2) &= 2^2 = 4 \\\\\n  A(2, 3) &= 2^{2^2} = 16 \\\\\n  A(2, 4) &= 2^{2^{2^2}} = 65536 \\quad \\text{(as we found earlier)}\n\\end{align*}\n\nand so on. To be honest, I have no idea how to formulate this as a ``concise mathematical definition''. Any suggestions welcome\\dots\n\n\\end{document}\n", "meta": {"hexsha": "b99de0c9a40b7bfc4ae454b8f324004ea296ebbb", "size": 5289, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sicp_exs/tex/sicp_exs.tex", "max_stars_repo_name": "pauljxtan/miscellany", "max_stars_repo_head_hexsha": "e8e424e5bbb646a5796dc0c6617df5a6aa4dc86c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sicp_exs/tex/sicp_exs.tex", "max_issues_repo_name": "pauljxtan/miscellany", "max_issues_repo_head_hexsha": "e8e424e5bbb646a5796dc0c6617df5a6aa4dc86c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sicp_exs/tex/sicp_exs.tex", "max_forks_repo_name": "pauljxtan/miscellany", "max_forks_repo_head_hexsha": "e8e424e5bbb646a5796dc0c6617df5a6aa4dc86c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.4746835443, "max_line_length": 157, "alphanum_fraction": 0.4494233314, "num_tokens": 2322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.8459424334245618, "lm_q1q2_score": 0.4328827898071962}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{bussproofs}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\usepackage[a4paper, total={7in, 10in}]{geometry}\n\n\\newenvironment{scprooftree}[1]%\n  {\\gdef\\scalefactor{#1}\\begin{center}\\proofSkipAmount \\leavevmode}%\n  {\\scalebox{\\scalefactor}{\\DisplayProof}\\proofSkipAmount \\end{center} }\n\n\\begin{document}\n\n{\\Huge Natural Deduction on Predicate Logic} \\\\\n\nAll this work is based on the book \\textit{Logic and Structure} by Dirk Van Dalen.\n\n\\section*{Strategy to build correct derivations in Predicate Logic}\n\n\\noindent\\fbox{%\n    \\parbox{\\textwidth}{%\n\\textbf{From an university test:} \\\\ \\\\\n\nLet $\\Gamma = \\{(\\exists x)P_1(x), (\\exists x)(\\exists y)(\\neg P_2 (x, y)), (\\forall x)(P_1 (x) \\rightarrow (\\exists y)P_2 (x,y)) \\}$ \\\\\n\nBuild a derivation that proves the following: \\\\\n$$\\Gamma \\cup \\{ (\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y)) \\} \\vdash (\\exists x)(\\exists y)(\\neg P_3 (x, y))$$\n    }%\n}\n\\newline\n\\newline\\newline\n\\noindent\\fbox{%\n    \\parbox{\\textwidth}{%\nFirst of all build the derivation without canceling any hypotheses:\\\\\n    }%\n}\n\\begin{scprooftree}{0.8}\n  \\AxiomC{$(\\exists x)(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$\\neg P_2 (x, y)$}\n  \\AxiomC{$(\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *6}$}\n  \\UnaryInfC{$(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *5}$}\n  \\UnaryInfC{$P_3 (x,y) \\leftrightarrow P_2 (x,y)$}\n  \\AxiomC{$P_3 (x, y)$}\n  \\RightLabel{$E_{\\leftrightarrow 1}$}\n  \\BinaryInfC{$P_2 (x, y)$}\n  \\RightLabel{$E_{\\neg}$}\n  \\BinaryInfC{$\\bot$}\n  \\LeftLabel{(3)}\n  \\RightLabel{$I_{\\neg}$}\n  \\UnaryInfC{$\\neg P_3 (x, y)$}\n  \\RightLabel{$I_{\\exists *4}$}\n  \\UnaryInfC{$(\\exists y)(\\neg P_3 (x, y))$}\n  \\RightLabel{$I_{\\exists *3}$}\n  \\UnaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(2)}\n  \\RightLabel{$E_{\\exists *2}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n\\end{scprooftree}\n\n\nDuring the construction the following hypotheses were generated:\n\\begin{enumerate}\n\\item $(\\exists y)(\\neg P_2 (x, y))$\n\\item $\\neg P_2 (x, y)$\n\\item $P_3 (x, y)$\n\\end{enumerate}\n\n\\noindent\\fbox{%\n    \\parbox{\\textwidth}{%\nNext, start checking every atomic step top-down. In each atomic step, if the rule needs proofs we write them down. If the rule generated hypotheses we cancel them. If you can give a correct proof for all rules that need it, the derivation is correct. \\\\\n    }%\n}\n\\begin{itemize}\n  \\item [$E_{\\forall *6}$]:\n  \\item This rule doesn't generate hypotheses.\n  \\item \\textbf{*6 justification:} $x$ is free for $x$ in any formula (in particular, in: $(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$).\n\\end{itemize}\n\n\\begin{itemize}\n  \\item [$E_{\\forall *5}$:]\n  \\item This rule doesn't generate hypotheses.\n  \\item \\textbf{*5 justification:} $y$ is free for $y$ in any formula (in particular, in $(P_3 (x,y) \\leftrightarrow P_2 (x,y))$). \n\\end{itemize}\n\n\\begin{itemize}\n  \\item [$E_{\\leftrightarrow 1}$:]\n  \\item This rule doesn't generate hypotheses and doesn't need justification. \n\\end{itemize}\n\n\\begin{itemize}\n  \\item [$E_{\\neg 1}$:]\n  \\item This rule doesn't generate hypotheses doesn't need justification.\n\\end{itemize}\n\\newpage\n\n\\begin{itemize}\n  \\item [$I_{\\neg 1}$:]\n  \\item This rule generates the hypotheses ($P_3 (x, y)$), se let's cancel it.\n  \\item This rule doesn't need justification.\\\\\n\\end{itemize}\n\nThe derivation at this step is: \\\\\n\n\\begin{scprooftree}{0.8}\n  \\AxiomC{$(\\exists x)(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$\\neg P_2 (x, y)$}\n  \\AxiomC{$(\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *6}$}\n  \\UnaryInfC{$(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *5}$}\n  \\UnaryInfC{$P_3 (x,y) \\leftrightarrow P_2 (x,y)$}\n  \\AxiomC{$[P_3 (x, y)]^3$}\n  \\RightLabel{$E_{\\leftrightarrow 1}$}\n  \\BinaryInfC{$P_2 (x, y)$}\n  \\RightLabel{$E_{\\neg}$}\n  \\BinaryInfC{$\\bot$}\n  \\LeftLabel{(3)}\n  \\RightLabel{$I_{\\neg}$}\n  \\UnaryInfC{$\\neg P_3 (x, y)$}\n  \\RightLabel{$I_{\\exists *4}$}\n  \\UnaryInfC{$(\\exists y)(\\neg P_3 (x, y))$}\n  \\RightLabel{$I_{\\exists *3}$}\n  \\UnaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(2)}\n  \\RightLabel{$E_{\\exists *2}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n\\end{scprooftree}\n\n\\begin{itemize}\n  \\item [$I_{\\exists *4}$:]\n  \\item This rule doesn't generate hypotheses.\n  \\item \\textbf{*4 justification:} $y$ is free for $y $ in any formula (in particular, in $\\neg P_3 (x,y)$).\n\\end{itemize}\n\n\\begin{itemize}\n  \\item [$I_{\\exists *3}$:]\n  \\item This rule doesn't generate hypotheses.\n  \\item \\textbf{*3 justification:} $x$ is free for $x$ in any formula (in particular, in $(\\exists y)(\\neg P_3 (x,y))$).\n\\end{itemize}\n\n\\begin{itemize}\n  \\item [$E_{\\exists *2}$:]\n  \\item This rule generates the hypotheses $\\neg P_2 (x, y)$, let's cancel it.\n  \\item \\textbf{*2 justification:} $y \\not\\in$ $FV((\\exists x)(\\exists y)(\\neg P_3 (x, y)))$, $y \\not\\in$ $FV((\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y)))$. \\\\\n  \\textbf{Note that there's no need to check if other hypotheses contain $y$ free: ($P_3 (x,y)$ ni en $\\neg P_2 (x,y)$) as in this step they are canceled.}\\\\\n\\end{itemize}\n\nThe derivation at this step is: \\\\\n\\begin{scprooftree}{0.8}\n  \\AxiomC{$(\\exists x)(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$[\\neg P_2 (x, y)]^2$}\n  \\AxiomC{$(\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *6}$}\n  \\UnaryInfC{$(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *5}$}\n  \\UnaryInfC{$P_3 (x,y) \\leftrightarrow P_2 (x,y)$}\n  \\AxiomC{$[P_3 (x, y)]^3$}\n  \\RightLabel{$E_{\\leftrightarrow 1}$}\n  \\BinaryInfC{$P_2 (x, y)$}\n  \\RightLabel{$E_{\\neg}$}\n  \\BinaryInfC{$\\bot$}\n  \\LeftLabel{(3)}\n  \\RightLabel{$I_{\\neg}$}\n  \\UnaryInfC{$\\neg P_3 (x, y)$}\n  \\RightLabel{$I_{\\exists *4}$}\n  \\UnaryInfC{$(\\exists y)(\\neg P_3 (x, y))$}\n  \\RightLabel{$I_{\\exists *3}$}\n  \\UnaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(2)}\n  \\RightLabel{$E_{\\exists *2}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n\\end{scprooftree}\n\n\\newpage\n\n\\begin{itemize}\n\\item [$E_{\\exists *1}$:]\n\\item This rule generates the hypotheses: $(\\exists y)(\\neg P_2 (x, y))$, let's cancel it.\n\\item \\textbf{*1 justification:} $x \\not\\in$ $FV((\\exists x)(\\exists y)(\\neg P_3 (x, y)))$, $x \\not\\in$ $FV((\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y)))$.\\\\\n\\textbf{Let's note that for this case also there's no need to check if any other hypotheses contain $x$ free: ($P_3 (x,y)$ ni en $\\neg P_2 (x,y)$) because they are all canceled.}\\\\\n\\end{itemize}\n\nThe derivation at this step is: \\\\\n\n\\begin{scprooftree}{0.8}\n  \\AxiomC{$(\\exists x)(\\exists y)(\\neg P_2 (x, y))$}\n  \\AxiomC{$[(\\exists y)(\\neg P_2 (x, y))]^1$}\n  \\AxiomC{$[\\neg P_2 (x, y)]]^2$}\n  \\AxiomC{$(\\forall x)(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *6}$}\n  \\UnaryInfC{$(\\forall y)(P_3 (x,y) \\leftrightarrow P_2 (x,y))$}\n  \\RightLabel{$E_{\\forall *5}$}\n  \\UnaryInfC{$P_3 (x,y) \\leftrightarrow P_2 (x,y)$}\n  \\AxiomC{$[P_3 (x, y)]^3$}\n  \\RightLabel{$E_{\\leftrightarrow 1}$}\n  \\BinaryInfC{$P_2 (x, y)$}\n  \\RightLabel{$E_{\\neg}$}\n  \\BinaryInfC{$\\bot$}\n  \\LeftLabel{(3)}\n  \\RightLabel{$I_{\\neg}$}\n  \\UnaryInfC{$\\neg P_3 (x, y)$}\n  \\RightLabel{$I_{\\exists *4}$}\n  \\UnaryInfC{$(\\exists y)(\\neg P_3 (x, y))$}\n  \\RightLabel{$I_{\\exists *3}$}\n  \\UnaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(2)}\n  \\RightLabel{$E_{\\exists *2}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists x)(\\exists y)(\\neg P_3 (x, y))$}\n\\end{scprooftree}\n\nAnd this, together with the justifications is the complete finished derivation.\n\n\\newpage\n\n\\section{How to use identity rules.}\n\nSpecial thanks to Prof. Luis Sierra (FIng UdelaR) for the corrections. \\\\\n\n\\noindent\\fbox{%\n    \\parbox{\\textwidth}{%\n\\textbf{From an university test:} \\newline \\newline\nBuild a derivation that proves:\n$$(\\forall x)P(x, f(x)), (\\exists y)f(y) =' y \\vdash (\\exists z)P(f(z), z)$$\n    }%\n}\n\\newline \\newline\n\nFirst of all, looking at the premises we can figure out that to reach the conclusion, using substition in the application of the rule $E_{\\forall}$ won't lead us anywhere. For example, if we wanted to reach $(\\exists z)P(f(z), z)$ with the premise $(\\forall x)P(x, f(x))$, we should apply the rule $E_{\\forall}$. If we wanted to obtain $f(z)$ instead of $x$, when substituting, we would get $P(f(z), f(f(z)))$. The only way to swawp the arguments of $P$ is by using the rule $RI4'$. \\\\\n\nLet's build the derivation: \\\\\n\nAll we can do with the premises we have is an existential elimination:\n\n\\begin{prooftree}\n\\AxiomC{$(\\exists y)f(y) =' y$}\n\\AxiomC{$(\\exists z)P(f(z), z)$}\n\\LeftLabel{(1)}\n\\RightLabel{$E_{\\exists *1}$}\n\\BinaryInfC{$(\\exists z)P(f(z), z)$}\n\\end{prooftree}\n\nHere, we obtained the hypotheses $f(y) =' y$. Checking the premises again we can see that with $(\\forall x)P(x, f(x))$, by applying the rule $E_{\\forall}$ and substituting adequately we obtain $P(y, f(y))$. If we manage to substitute in this formula in a way that we get $P(f(y), y)$, applying the rule $I_{\\exists}$ and substituting adequately we can obtain $(\\exists z)P(f(z), z)$. We can do this by using the identity rule $RI4'$.\nDoing this, the resulting derivation is:\n\n\\begin{prooftree}\n  \\AxiomC{$(\\exists y)f(y) =' y$}\n  \\AxiomC{$(\\forall x)P(f(x), x)$}\n  \\UnaryInfC{$P(f(y), y)$}\n  \\AxiomC{$f(y) =' y$}\n  \\AxiomC{$f(y) =' y$}\n  \\UnaryInfC{$y =' f(y)$}\n  \\TrinaryInfC{$P(f(y), y)$}\n  \\UnaryInfC{$(\\exists z)P(f(z), z)$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists z)P(f(z), z)$}\n\\end{prooftree}\n\nBy adding the rules in each step and using the strategy of the previous example, we have built the derivation: \\\\\n\n\\noindent\\fbox{%\n    \\parbox{\\textwidth}{%\n \\textbf{*4}: $y$ free for $x$ in $P(f(x), x).$ \\\\\n \\textbf{*3}: $y$ free for $z_1$; $f(y)$ free for $z_2$ en $P(z_1,z_2)$. \\\\\n $f(y)$ free for $z_1$; $y$ free for $z_2$ en $P(z_1,z_2)$.\\\\\n \\textbf{*2}: $y$ free for $z$ en $P(f(z), z)$.\\\\\n \\textbf{*1}: $y$ $\\not \\in$ $FV(\\{(\\exists z)P(f(z), z), (\\forall x)P(f(x), x)\\}).$\n    }%\n}\n\n\\begin{prooftree}\n  \\AxiomC{$(\\exists y)f(y) =' y$}\n  \\AxiomC{$[f(y) =' y]^1$}\n  \\RightLabel{$RI2$}\n  \\UnaryInfC{$y =' f(y)$}\n  \\AxiomC{$[f(y) =' y]^1$}\n  \\AxiomC{$(\\forall x)P(x, f(x))$}\n  \\RightLabel{$E_{\\forall *4}$}\n  \\UnaryInfC{$P(z_1,z_2)[y/z_1,f(y)/z_2])$}\n  \\RightLabel{$RI4'_{*3}$}\n  \\TrinaryInfC{$P(z_1,z_2)[f(y)/z_1,y/z_2)]$}\n  \\RightLabel{$I_{\\exists *2}$}\n  \\UnaryInfC{$(\\exists z)P(f(z), z)$}\n  \\LeftLabel{(1)}\n  \\RightLabel{$E_{\\exists *1}$}\n  \\BinaryInfC{$(\\exists z)P(f(z), z)$}\n\\end{prooftree}\n\n\\end{document}\n", "meta": {"hexsha": "21e08ce92521d35e67f9012a9a5711cae7cf7237", "size": 11271, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "natural_deduction/natural_deduction_in_predicate_logic.tex", "max_stars_repo_name": "novalic/mathProblems", "max_stars_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-04-22T11:03:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-01T21:06:53.000Z", "max_issues_repo_path": "natural_deduction/natural_deduction_in_predicate_logic.tex", "max_issues_repo_name": "novalic/articles", "max_issues_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "natural_deduction/natural_deduction_in_predicate_logic.tex", "max_forks_repo_name": "novalic/articles", "max_forks_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.5941558442, "max_line_length": 485, "alphanum_fraction": 0.6245231124, "num_tokens": 4383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.607663184043154, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.43279728056438277}}
{"text": "\\section{Thermalization via a Nonlinear Boson Diffusion Equation (NBDE)}\n\n\\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation I}\n\\vspace{0.5em}\nThe following derivation follows reference \\cite{Wolschin2018}. \\\\[0.5em]\n\\begin{itemize}\n\\item The starting point for our investigation is the \\alert{Boltzmann eqn.} (cf. Pavel's talk). %write it down\n\\item For \\alert{spatial homogeneity} of the the boson distribution function $f(\\mathbf{x}, \\mathbf{p}, t)$ and a \\alert{spherically symmetric momentum dependence} the equation for the single-particle occupation numbers  $n_j \\equiv n_{\\mathrm{th}}(\\varepsilon_j,t)$ reads:\n\\begin{align}\n\\frac{\\partial n_1}{\\partial t} &= \\sum_{\\varepsilon_2,\\varepsilon_3,\\varepsilon_4}\\langle V^{\\phantom{.}2}\\rangle G(\\varepsilon_1+\\varepsilon_2,\\varepsilon_3+\\varepsilon_4)\\\\\n&\\times \\left[(1+n_1)(1+n_2)n_3n_4 - (1+n_3)(1+n_4)n_1n_2\\right]\n\\end{align}\n\n\\item The \\alert{collision term} can be written in the form of a \\alert{Master eqn.}:\n\\begin{equation}\n\\frac{\\partial n_1}{\\partial_t} = (1+n_1)\\sum_{\\varepsilon_4}W_{4\\rightarrow 1}n_4\t- \\sum_{\\varepsilon_4}W_{1\\rightarrow 4}(1+n_4)\t\n\\end{equation}\nwith\n\\begin{equation}\nW_{4\\rightarrow 1}=  W_{41}g_1 = \\sum_{\\varepsilon_2, \\varepsilon_3} \\langle V^{\\phantom{.}2}\\rangle G(\\varepsilon_1+\\varepsilon_2,\\varepsilon_3+\\varepsilon_4)(1+n_2)n_3\n\\end{equation}\n\\end{itemize} \n\\end{frame}\n\n\\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation II}\n\\begin{itemize}\n\t\\item In continuum $\\sum\\rightarrow\\int$ and introduce \\alert{density of states} $g_j \\equiv g(\\varepsilon_j)$.\n\t\\item If $G$ acquires a width in a finite system: \n\t\\begin{equation}\n\t\tW_{14}=W_{41}=W\\left[\\frac{1}{2}(\\varepsilon_4+\\varepsilon_1),\\underbrace{\\abs{\\varepsilon_4-\\varepsilon_1}}_{=: x}\\right]\n\t\\end{equation}\n\t\\item Perform a \\alert{gradient expansion} of $n_4$ and $g_4n_4$ around $x\\approx 0$.\n\t\\item Introduce \\alert{transport coefficients} via moments of the transition probability:\n\\begin{align}\n\tD &= \\frac{g_1}{2}\\int\\limits_0^{\\infty}\\dd x\\ W(\\varepsilon_1,x) \\ x^2 \\\\\n\tv &= g_1^{-1}\\frac{d}{d\\varepsilon_1}(g_1D) \n\\end{align}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation III}\n\\begin{itemize}\n\t\\item Nonlinear partial differential equation for $n \\equiv n(\\varepsilon_1,t) = n(\\varepsilon,t)$:\n\t\t\\begin{equation}\n\t\t\t\\frac{\\partial n}{\\partial t} = -\\frac{\\partial}{\\partial\\varepsilon}\\left[v\\cdot n(1+n) + n\\frac{\\partial n}{\\partial\\varepsilon}\\right] + \\frac{\\partial^2}{\\partial\\varepsilon^2}\\left[Dn\\right]\\label{eqn:nbde1}\n\t\t\\end{equation}\n\n\t\\item Consider the limit of constant transport coefficients:\n\t\t\\begin{equation}\n\t\t\t\\frac{\\partial n}{\\partial t} = -v\\frac{\\partial}{\\partial\\varepsilon}\\left[n(1+n)\\right] + D\\frac{\\partial^2 n}{\\partial\\varepsilon^2}\\label{eqn:nbde2}\n\t\t\\end{equation}\n\n\\item Thermal \\alert{Bose-Einstein distribution} provides stationary solution:\n\\begin{equation}\n\tn_{\\mathrm{eq}}(\\varepsilon) = \\frac{1}{\\exp(\\frac{\\varepsilon-\\mu}{T}) - 1}\n\\end{equation}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Some Remarks}\n\\begin{itemize}\n\t\\item The present model does \\alert{not} resolve the 2nd-order phase transition.\n\t\\item The effects of condensation are included (cf. the following figures).\n\t\\item A treatment resolving the singularity at $\\epsilon=\\mu$ is presented later.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Linear Relaxation-Time Approximation (RTA)}\n\\begin{itemize}\n\t\\item Given some initial distribution $n_{\\mathrm{i}}(\\varepsilon)$ we find an approximated solution for the thermalization process via the RTA:\n\\begin{equation}\n\t\\frac{\\partial n_{\\mathrm{rel}}}{\\partial t} = \\frac{(n_{\\mathrm{eq}} - n_{\\mathrm{\nrel}})}{\\tau_{\\mathrm{eq}}}\n\\end{equation}\nwith solution:\n\\begin{equation}\n\tn_{\\mathrm{rel}}(\\varepsilon,t) = n_{\\mathrm{i}}(\\varepsilon)\\cdot\\exp\\left(-\\frac{t}{\\tau_{\\mathrm{eq}}}\\right) +  n_{\\mathrm{eq}}(\\varepsilon)\\left(1-\\exp\\left(-\\frac{t}{\\tau_{\\mathrm{eq}}}\\right)\\right)\n\\end{equation}\t\nwhere $\\tau_{\\mathrm{eq}} = 4D/(9v^2)$.\n\\item Motivated by the study of early stages of RHICs, the initial distribution is chosen such that:\n\\begin{equation}\n\tn_{\\mathrm{i}}(\\varepsilon) = N_{\\mathrm{i}}\\cdot\\theta\\left(1-\\varepsilon/Q_{\\mathrm{s}}\\right)\\cdot\\theta(\\varepsilon) \\label{eqn:rta_initial}\n\\end{equation}\nwith limiting momentum $Q_{\\mathrm{s}} \\sim \\tau_0^{-1} \\approx 1\\ \\mathrm{GeV}$.\\mycite{Mueller1999}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Results for the RTA}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/rta}\n\\caption{Relaxation of a finite Bose system towards the equilibrium. \\cite{Wolschin2018} \\\\ \nHere $T = -D/v \\simeq 0.4\\ \\mathrm{GeV}$, $\\tau_{\\mathrm{eq}} = 4D/(9v^2) = 0.33\\cdot 10^{-23} \\mathrm{s} \\simeq 1\\ \\mathrm{fm/c}$ and the timesteps are $\\left\\{0.1, 0.25, 0.5,\\infty\\right\\}$ (in units of $10^{-23}s$) from top to bottom.}\n\\end{figure}\n\\end{frame}\n%TODO: Maybe add another slide about conservation etc.\n\n\\begin{frame}{Exact Solution of the Nonlinear Boson Diffusion Equation} \n\\begin{itemize}\n\t\\item To solve eqn. (\\ref{eqn:nbde1}) analytically, we perform the following \\alert{nonlinear transformation:}\n\t\\begin{equation}\n\t\tn(\\varepsilon,t) = -\\frac{D}{v}\\frac{\\partial \\ln \\mathcal{Z}(\\varepsilon,t)}{\\partial\\varepsilon}\n\t\\end{equation}\n\twhich reduces our problem to a \\alert{linear diffusion eqn.} for $ \\mathcal{Z}(\\varepsilon,t)$:\n\t\\begin{equation}\n\t\t\\frac{\\partial  \\mathcal{Z}}{\\partial t} = -v\\frac{\\partial  \\mathcal{Z}}{\\partial \\varepsilon} +  D\\frac{\\partial^2  \\mathcal{Z}}{\\partial \\varepsilon^2}\n\t\\end{equation}\n\t\\item Solutions to this equation can be written as:\n \\begin{equation}\nn(\\varepsilon, t)=\\frac{1}{2 v} \\frac{\\int_{-\\infty}^{+\\infty} \\frac{\\varepsilon-x}{t} F(x)\\cdot G_{\\mathrm{free}}(\\varepsilon-x,t)\\ \\dd x}{\\int_{-\\infty}^{+\\infty} F(x)\\cdot G_{\\mathrm{free}}(\\varepsilon-x,t)\\ \\dd x}-\\frac{1}{2}\n\\end{equation}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Additional Definitions} \n\\begin{itemize}\n\\item The quantities appearing in the solution are the \\alert{free Green's function}\n\\begin{align}\n\tG_{\\mathrm{free}}(\\varepsilon-x,t) = \\exp\\left[-\\frac{(\\varepsilon-x)^2}{4Dt}\\right],\\\\\n\\end{align}\nand the implementation of the \\alert{initial conditions}\n\\begin{equation}\n\t    F(x)  = \\exp\\left[-\\frac{1}{2D}(vx+2v\\int_0^x n_{\\mathrm{i}}(y) \\dd y) \\right].\n\\end{equation}\n\\item They define the \\alert{free partition function} via: \n\\begin{equation}\n\t\\mathcal{Z}(\\varepsilon,t) = a(t)\\cdot\\int_{\\infty}^{\\infty} G_{\\mathrm{free}}(\\varepsilon,x,t)\\cdot F(x)\\ \\dd x\n\\end{equation}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Results for the Solution of the NBDE I}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/nbde_positive_range}\n\\caption{Equilibration of a finite Bose system from the NBDE. \\cite{Wolschin2018} \\\\ \nThe integration range is restricted to $x \\geq 0$. Here $T\\simeq 0.4\\ \\mathrm{GeV}$, $\\tau_{\\mathrm{eq}} =  0.33\\cdot 10^{-23} \\mathrm{s}$ and the timesteps are $\\left\\{0.005, 0.05, 0.15,0.5\\right\\}$ (in units of $10^{-23}s$) from top to bottom.}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{Results for the Solution of the NBDE II}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/nbde_full_range}\n\\caption{Equilibration of a finite Bose system from the NBDE. \\cite{Wolschin2018} \\\\ \nThe integration range is extended to $-\\infty \\leq x \\leq \\infty$. Here $T\\simeq 0.4\\ \\mathrm{GeV}$, $\\tau_{\\mathrm{eq}} =  0.33\\cdot 10^{-23} \\mathrm{s}$ and the timesteps are $\\left\\{0.005, 0.05, 0.15,0.5\\right\\}$ (in units of $10^{-23}s$) from top to bottom.}\n\\end{figure}\n\\end{frame}\n\n\n\\begin{frame}{Results for the Solution of the NBDE III}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/nbde_gaussian}\n\\caption{Equilibration of a finite Bose system from the NBDE for Gaussian initial conditions $n_{\\mathrm{i}}(\\varepsilon) = N_{\\mathrm{i}}\\left(\\sqrt{2\\pi}\\sigma\\right)^{-1}\\exp\\left((\\varepsilon - \\langle\\varepsilon\\rangle)/(2\\sigma^2)\\right)$ with $\\sigma = 0.04\\ \\mathrm{GeV}$. \\cite{Wolschin2018} \\\\ \nHere $T\\simeq 0.4\\ \\mathrm{GeV}$, $\\tau_{\\mathrm{eq}} =  0.33\\cdot 10^{-23} \\mathrm{s}$ and the timesteps are $\\left\\{0.002, 0.006, 0.02, 0.2\\right\\}$ (in units of $10^{-23}s$) from top to bottom.}\n\\end{figure}\n\\end{frame}\n\n\n\n\\begin{frame}{Treating the Singularity}\nThis part is based on the publication \\cite{Wolschin2020_1} which provides an extension of \\cite{Wolschin2018} and was published just recently.\\\\[0.5em]\t\n\\begin{itemize}\n\t\\item To account for the singularity at $\\varepsilon=\\mu < 0$ we have to modify the initial distribution given before (eqn. (\\ref{eqn:rta_initial})) as follows:\n\t\\begin{equation}\n\t\t\\tilde{n_{\\mathrm{i}}}(\\varepsilon) = n_{\\mathrm{i}}(\\varepsilon) + \\frac{1}{\\exp\\left(\\frac{\\varepsilon-\\mu}{T}\\right)-1}\n\t\\end{equation}\n\t\\item The chemical potential $\\mu$ has to be treated as a fixed parameter.\n\t\\item Considering the limit $\\lim_{\\varepsilon\\rightarrow\\mu^{+}}\\ n(\\varepsilon,t) = \\infty\\ \\forall t$ yields $\\mathcal{Z}(\\mu,t) = 0$.\n\t\\item This results in a modified expression for the Green's function\n\t\\begin{equation}\n\t\tG(\\varepsilon,x,t) = G_{\\mathrm{free}}(\\varepsilon-\\mu,x,t) - G_{\\mathrm{free}}(\\varepsilon-\\mu,-x,t)\n\t\\end{equation}\n\\end{itemize} \n\\end{frame}\n\n\\begin{frame}{Results for the RTA for the modified Initial Conditions}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/rta_full}\n\\caption{Local thermalization of gluons in the linear RTA for $\\mu<0$. \\cite{Wolschin2020_1} \\\\ \nHere $T \\simeq 513\\ \\mathrm{MeV}$ and the timesteps are $\\left\\{0.02, 0.08, 0.15,0.3,0.6\\right\\}$ (in units of $\\mathrm{fm}/c$) from top to bottom.}\n\\end{figure}\n\\end{frame}\n%TODO: Elaborate on Solutions#2\n\\begin{frame}{Results for the full Solution of the NBDE}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{figures/nbde_full_result}\n\\caption{Local thermalization of gluons from the time-dependent solutions of the NBDE for $\\mu<0$. \\cite{Wolschin2020_1} \\\\ \nHere $T \\simeq 513\\ \\mathrm{MeV}$ and the timesteps are $\\left\\{6\\cdot10^{-5}, 6\\cdot10^{-4}, 6\\cdot10^{-3},0.12,0.36\\right\\}$ (in units of $\\mathrm{fm}/c$) from top to bottom.}\n\\end{figure}\n\\end{frame}", "meta": {"hexsha": "c7ab4a65d72107c9df22709258d44258bf718033", "size": 10217, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "talk/content/04_nbde.tex", "max_stars_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_stars_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "talk/content/04_nbde.tex", "max_issues_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_issues_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "talk/content/04_nbde.tex", "max_forks_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_forks_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.1275510204, "max_line_length": 304, "alphanum_fraction": 0.7119506705, "num_tokens": 3664, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.43279726673164254}}
{"text": "\\chapter{PV Panel Curves and simulation program} \\label{ap:pvPanelCurves}\n\n\tThis appendix shows the simulation curves of the photovoltaic panel static equation \\eqref{eq:PVPanelModelModified}. It also shows listing \\ref{lst:pvPanelCurves}, the Python program used to obtain those curves. The parameter values of the photovoltaic panels are denoted in table \\ref{tab:panelParameters}.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[angle = -90, width = 0.9\\textwidth]{../images/pvPanelCurves/ivCurve.pdf}\n\t\\caption{Panel transconductance (continuous) and MPP (dashed) curves with fixed temperature $\\theta_{SRC}$ and varying irradiance.}\n\t\\label{fig:ivCurve}\n\\end{figure}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[angle = -90, width = 0.9\\textwidth]{../images/pvPanelCurves/pvCurve.pdf}\n\t\\caption{Panel power(continuous) and MPP (dashed) curves with fixed temperature $\\theta_{SRC}$ and varying irradiance.}\n\t\\label{fig:pvCurve}\n\\end{figure}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[angle = -90, width = 0.9\\textwidth]{../images/pvPanelCurves/ivCurveVaryingTemperature.pdf}\n\t\\caption{Panel transconductance (continuous) and MPP (dashed) curves with fixed irradiation $\\phi_{SRC}$ and varying temperature.}\n\t\\label{fig:ivCurveVaryingTemperature}\n\\end{figure}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[angle = -90, width = 0.9\\textwidth]{../images/pvPanelCurves/pvCurveVaryingTemperature.pdf}\n\t\\caption{Panel power (continuous) and MPP (dashed) curves with fixed irradiation $\\phi_{SRC}$ and varying temperature.}\n\t\\label{fig:pvCurveVaryingTemperature}\n\\end{figure}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[angle = -90, width = 0.9\\textwidth]{../images/pvPanelCurves/vocVersusIrradiance.pdf}\n\t\\caption{Panel open-circuit voltage versus irradiance and temperature.}\n\t\\label{fig:vocVersusIrradiance}\n\\end{figure}\n\n\t\\lstinputlisting[caption = {Python PV panel simulation program developed to generate figures \\ref{fig:ivCurve} to \\ref{fig:pvCurveVaryingTemperature}}, label = {lst:pvPanelCurves}, style = apaListing, language = Python]{../images/pvPanelCurves/mppTracking.py}\n", "meta": {"hexsha": "3bf8ef791b4c20b9283b309d0c46e3e886090d10", "size": 2102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/appendixes/appendix1.tex", "max_stars_repo_name": "Gondolindrim/apaThesis", "max_stars_repo_head_hexsha": "04505aecd3e83d1b0a18fb491841c7a92172bab4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/appendixes/appendix1.tex", "max_issues_repo_name": "Gondolindrim/apaThesis", "max_issues_repo_head_hexsha": "04505aecd3e83d1b0a18fb491841c7a92172bab4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/appendixes/appendix1.tex", "max_forks_repo_name": "Gondolindrim/apaThesis", "max_forks_repo_head_hexsha": "04505aecd3e83d1b0a18fb491841c7a92172bab4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2682926829, "max_line_length": 308, "alphanum_fraction": 0.7764034253, "num_tokens": 622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.43268496766982767}}
{"text": "\\begin{comment}\n\n Licensed to the Apache Software Foundation (ASF) under one\n or more contributor license agreements.  See the NOTICE file\n distributed with this work for additional information\n regarding copyright ownership.  The ASF licenses this file\n to you under the Apache License, Version 2.0 (the\n \"License\"); you may not use this file except in compliance\n with the License.  You may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing,\n software distributed under the License is distributed on an\n \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n KIND, either express or implied.  See the License for the\n specific language governing permissions and limitations\n under the License.\n\n\\end{comment}\n\n\\subsection{Principal Component Analysis}\n\\label{pca}\n\n\\noindent{\\bf Description}\n\nPrincipal Component Analysis (PCA) is a simple, non-parametric method to transform the given data set with possibly correlated columns into a set of linearly uncorrelated or orthogonal columns, called {\\em principal components}. The principal components are ordered in such a way that the first component accounts for the largest possible variance, followed by remaining principal components in the decreasing order of the amount of variance captured from the data. PCA is often used as a dimensionality reduction technique, where the original data is projected or rotated onto a low-dimensional space with basis vectors defined by top-$K$ (for a given value of $K$) principal components.\n\\\\\n\n\\noindent{\\bf Usage}\n\n\\begin{tabbing}\n\\texttt{-f} \\textit{path}/\\texttt{PCA.dml -nvargs} \n\\=\\texttt{INPUT=}\\textit{path}/\\textit{file} \n  \\texttt{K=}\\textit{int} \\\\\n\\>\\texttt{CENTER=}\\textit{0/1}\n  \\texttt{SCALE=}\\textit{0/1}\\\\\n\\>\\texttt{PROJDATA=}\\textit{0/1}\n  \\texttt{OFMT=}\\textit{csv}/\\textit{text}\\\\\n\\>\\texttt{MODEL=}\\textit{path}$\\vert$\\textit{file}\n  \\texttt{OUTPUT=}\\textit{path}/\\textit{file}\n\\end{tabbing}\n\n\\noindent{\\bf Arguments}\n\n\\begin{itemize}\n\\item INPUT: Location (on HDFS) to read the input matrix.\n\\item K: Indicates dimension of the new vector space constructed from $K$ principal components. It must be a value between $1$ and the number of columns in the input data.\n\\item CENTER (default: {\\tt 0}): Indicates whether or not to {\\em center} input data prior to the computation of principal components.\n\\item SCALE (default: {\\tt 0}): Indicates whether or not to {\\em scale} input data prior to the computation of principal components.\n\\item PROJDATA: Indicates whether or not the input data must be projected on to new vector space defined over principal components.\n\\item OFMT (default: {\\tt csv}): Specifies the output format. Choice of comma-separated values (csv) or as a sparse-matrix (text).\n\\item MODEL: Either the location (on HDFS) where the computed model is stored; or the location of an existing model.\n\\item OUTPUT: Location (on HDFS) to store the data rotated on to the new vector space.\n\\end{itemize}\n\n\\noindent{\\bf Details}\n\nPrincipal Component Analysis (PCA) is a non-parametric procedure for orthogonal linear transformation of the input data to a new coordinate system, such that the greatest variance by some projection of the data comes to lie on the first coordinate (called the first principal component), the second greatest variance on the second coordinate, and so on. In other words, PCA first selects a normalized direction in $m$-dimensional space ($m$ is the number of columns in the input data) along which the variance in input data is maximized -- this is referred to as the first principal component. It then repeatedly finds other directions (principal components) in which the variance is maximized. At every step, PCA restricts the search for only those directions that are perpendicular to all previously selected directions. By doing so, PCA aims to reduce the redundancy among input variables. To understand the notion of redundancy, consider an extreme scenario with a data set comprising of two variables, where the first one denotes some quantity expressed in meters, and the other variable represents the same quantity but in inches. Both these variables evidently capture redundant information, and hence one of them can be removed. In a general scenario, keeping solely the linear combination of input variables would both express the data more concisely and reduce the number of variables. This is why PCA is often used as a dimensionality reduction technique.\n\nThe specific method to compute such a new coordinate system is as follows -- compute a covariance matrix $C$ that measures the strength of correlation among all pairs of variables in the input data; factorize $C$ according to eigen decomposition to calculate its eigenvalues and eigenvectors; and finally, order eigenvectors in the decreasing order of their corresponding eigenvalue. The computed eigenvectors (also known as {\\em loadings}) define the new coordinate system and the square root of eigen values provide the amount of variance in the input data explained by each coordinate or eigenvector. \n\\\\\n\n%As an example, consider the data in Table~\\ref{tab:pca_data}. \n\\begin{comment}\n\\begin{table}\n\\parbox{.35\\linewidth}{\n\\centering\n\\begin{tabular}{cc}\n  \\hline\n  x & y \\\\\n  \\hline\n  2.5 & 2.4  \\\\\n  0.5 & 0.7  \\\\\n  2.2 & 2.9  \\\\\n  1.9 & 2.2  \\\\\n  3.1 & 3.0  \\\\\n  2.3 & 2.7  \\\\\n  2 & 1.6  \\\\\n  1 & 1.1  \\\\\n  1.5 & 1.6  \\\\\n  1.1 & 0.9  \\\\\n\t\\hline\n\\end{tabular}\n\\caption{Input Data}\n\\label{tab:pca_data}\n}\n\\hfill\n\\parbox{.55\\linewidth}{\n\\centering\n\\begin{tabular}{cc}\n  \\hline\n  x & y \\\\\n  \\hline\n  .69  & .49  \\\\\n  -1.31  & -1.21  \\\\\n  .39  & .99  \\\\\n  .09  & .29  \\\\\n  1.29  & 1.09  \\\\\n  .49  & .79  \\\\\n  .19  & -.31  \\\\\n  -.81  & -.81  \\\\\n  -.31  & -.31  \\\\\n  -.71  & -1.01  \\\\\n  \\hline\n\\end{tabular}\n\\caption{Data after centering and scaling}\n\\label{tab:pca_scaled_data}\n}\n\\end{table}\n\\end{comment}\n\n\\noindent{\\bf Returns}\nWhen MODEL is not provided, PCA procedure is applied on INPUT data to generate MODEL as well as the rotated data OUTPUT (if PROJDATA is set to $1$) in the new coordinate system. \nThe produced model consists of basis vectors MODEL$/dominant.eigen.vectors$ for the new coordinate system; eigen values MODEL$/dominant.eigen.values$; and the standard deviation MODEL$/dominant.eigen.standard.deviations$ of principal components.\nWhen MODEL is provided, INPUT data is rotated according to the coordinate system defined by MODEL$/dominant.eigen.vectors$. The resulting data is stored at location OUTPUT.\n\\\\\n\n\\noindent{\\bf Examples}\n\n\\begin{verbatim}\nhadoop jar SystemML.jar -f PCA.dml -nvargs \n            INPUT=/user/biuser/input.mtx  K=10\n            CENTER=1  SCALE=1\n            OFMT=csv PROJDATA=1\n\t\t\t\t    # location to store model and rotated data\n            OUTPUT=/user/biuser/pca_output/   \n\\end{verbatim}\n\n\\begin{verbatim}\nhadoop jar SystemML.jar -f PCA.dml -nvargs \n            INPUT=/user/biuser/test_input.mtx  K=10\n            CENTER=1  SCALE=1\n            OFMT=csv PROJDATA=1\n\t\t\t\t    # location of an existing model\n            MODEL=/user/biuser/pca_output/       \n\t\t\t\t    # location of rotated data\n            OUTPUT=/user/biuser/test_output.mtx  \n\\end{verbatim}\n\n\n\n", "meta": {"hexsha": "cef750ee687024ffc585ee98141db2f91ec66fc2", "size": 7219, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Algorithms Reference/PCA.tex", "max_stars_repo_name": "fschueler/systemml", "max_stars_repo_head_hexsha": "cdd0bacf845a0d4eeb3ec3e260ae1e3a96d706ef", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2016-03-03T09:23:25.000Z", "max_stars_repo_stars_event_max_datetime": "2017-02-21T22:09:57.000Z", "max_issues_repo_path": "docs/Algorithms Reference/PCA.tex", "max_issues_repo_name": "fschueler/systemml", "max_issues_repo_head_hexsha": "cdd0bacf845a0d4eeb3ec3e260ae1e3a96d706ef", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-09-26T10:58:55.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-26T10:58:55.000Z", "max_forks_repo_path": "docs/Algorithms Reference/PCA.tex", "max_forks_repo_name": "fschueler/systemml", "max_forks_repo_head_hexsha": "cdd0bacf845a0d4eeb3ec3e260ae1e3a96d706ef", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2016-01-18T01:50:25.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-03T20:25:44.000Z", "avg_line_length": 50.4825174825, "max_line_length": 1466, "alphanum_fraction": 0.7387449785, "num_tokens": 1859, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6992544335934765, "lm_q1q2_score": 0.43268496171628157}}
{"text": "% chapter included in vclmanual.tex\n\\documentclass[vcl_manual.tex]{subfiles}\n\\begin{document}\n\n\\flushleft\n\n\\chapter{Boolean operations and per-element branches}\\label{chap:BooleanOperations}\nConsider this piece of C++ code:\n\n\\begin{lstlisting}[frame=none]\nint a[4], b[4], c[4], d[4];\n  ...\nfor (int i = 0; i < 4; i++) {\n    d[i] = (a[i] > 0 && a[i] < 10) ? b[i] : c[i];\n}\n\\end{lstlisting}\n\\vspacesmall\n\nWe can do this with vectors in the following way:\n\n\\begin{lstlisting}[frame=none]\nVec4i a, b, c, d;\n  ...\nd = select(a > 0 & a < 10, b, c);\n\\end{lstlisting}\n\\vspacesmall\n\nThe \\codei{select} function is similar to the \\codei{?:}  operator. \nIt has three vector parameters: The first parameter is a boolean vector that chooses between the elements of the second and the third vector parameter. \n\\vspacesmall\n\nThe relational operators \\codei{\\textgreater}, \\codei{\\textgreater=}, \\codei{\\textless}, \\codei{\\textless=}, \\codei{==}, \\codei{!=} produce boolean vectors, \nwhich accept the boolean operations \\codei{\\&}, \n\\codei{|}, \\codei{$\\wedge$}, \\codei{$\\sim$} (and, or, exclusive or, not). \n\\vspacesmall\n\nIn the above example, the expressions \\codei{a \\textgreater{} 0} and \\codei{a \\textless{} 10} are boolean vectors of type \\codei{Vec4ib}. The boolean vectors must have a type that matches the data vectors they are used with. Table \\ref{table:BooleanVectorClasses} on page \\pageref{table:BooleanVectorClasses} shows which boolean vector class to use for each vector type.\n\\vspacesmall\n\nThe vector elements that are not selected are calculated anyway because normally all parts of a vector are calculated. For example:\n\n\\begin{lstlisting}[frame=none]\nVec4f a(-1.0f, 0.0f, 1.0f, 2.0f);\nVec4f b = select(a >= 0.0f, sqrt(a), 0.0f);\n\\end{lstlisting}\n\\vspacesmall\n\nHere, we will be calculating the square root of -1 even though we are not using it. This will not cause problems if floating point exceptions are masked off, which they normally are. A safe solution that works even if floating point exceptions are enabled would be:\n\n\\begin{lstlisting}[frame=none]\nVec4f a(-1.0f, 0.0f, 1.0f, 2.0f);\nVec4f b = sqrt(max(a, 0.0f));\n\\end{lstlisting}\n\\vspacesmall\n\n\nLikewise, the \\codei{\\&} and \\codei{|} operators are calculating both input operands, even if the second operand is not needed. The following examples illustrates this:\n\n\\begin{lstlisting}[frame=none]\n// array version:\nfloat a[4] = {0.0f, 1.0f, 2.0f, 3.0f};\nfloat b[4];\nfor (int i = 0; i < 4; i++) {\n   if (a[i] > 0.0f && 1.0f/a[i] != 4.0f) {\n      b[i] = a[i]; \n   }\n   else {\n      b[i] = 1.0f;   \n   }\n}\n\\end{lstlisting}\n\\vspacesmall\n\nand the vector version of the same:\n\n\\begin{lstlisting}[frame=none]\nVec4f a(0.0f, 1.0f, 2.0f, 3.0f);\nVec4f b = select(a > 0.0f & 1.0f/a != 4.0f, a, 1.0f);\n\\end{lstlisting}\n\\vspacesmall\n\nIn the array version, we will never divide by zero because the \\codei{\\&\\&} operator does not evaluate the second operand when the first operand is false. But in the vector version, we are indeed dividing by zero because the \\codei{\\&} operator always evaluates both operands. The vector class library defines the operators \\codei{\\&\\&} and \\codei{||} as synonyms for \\codei{\\&} and \\codei{|} for convenience, but they are still doing the bitwise AND or OR operation, so \\codei{\\&} and \\codei{|} are actually more representative of what these operators really do. This example should be changed to:\n\n\\begin{lstlisting}[frame=none]\nVec4f a(0.0f, 1.0f, 2.0f, 3.0f);\nVec4f b = select(a > 0.0f & a != 0.25f, a, 1.0f);\n\\end{lstlisting}\n\\vspacesmall\n\n\n\\section{Internal representation of boolean vectors}\\label{InternalRepresentationOfBoolean}\n\nThe way boolean vectors are stored depends on the instruction set and the Vector Class Library (VCL) version.\nOlder instruction sets have the boolean vectors stored with the same number of bits as the data vectors they are applied to (broad boolean vectors). The later instruction sets AVX512 and AVX512VL allow boolean vectors to be stored with only one bit for each element (compact boolean vectors). \n\\vspacesmall\n\nVersion 1.xx of the VCL is using the broad boolean vectors for the sake of backwards compatibility, while version 2.xx is prioritizing the more efficient compact boolean vectors when the appropriate instruction set is enabled. The boolean vector sizes are summarized in the following table.\n\\vspacesmall\n\n\\label{tableBooleanVectorSizes}\n\\begin{tabular}{|p{50mm}|p{40mm}|p{40mm}|}\n\\hline\n\\bfseries Data vector size \\newline and instruction set & \\bfseries VCL version 1 \\newline Boolean vectors & \\bfseries VCL version 2 \\newline Boolean vectors \\\\ \\hline\n128 bits & broad & broad  \\\\ \\hline\n128 bits with AVX512VL & broad & compact \\\\ \\hline\n256 bits & broad & broad  \\\\ \\hline\n256 bits with AVX512VL & broad & compact \\\\ \\hline\n512 bits & broad & broad  \\\\ \\hline\n512 bits with AVX512F & compact & compact \\\\ \\hline\n\\end{tabular}\n\\vspacebig\n\nThe broad boolean vectors are stored as integer vectors with the same number of bits per element as the integer or floating point vectors they are used for. For example, the broad boolean vector class \\codei{Vec4fb} is stored as a vector of four 32-bit integers because it is used with vectors \\codei{Vec4f} of four single precision floating point numbers, using 32 bits each. The broad boolean vector class \\codei{Vec4db} is stored as a vector of four 64-bit integers because it is used with vectors \\codei{Vec4d} of four double precision floating point numbers, using 64 bits each. Note that the integer representation of true in a broad boolean vector element is not 1, but  -1. The representation of false is 0. Any other values than 0 and -1 in broad boolean vectors will produce wrong and inconsistent results that depend on the instruction set.\n\\vspacesmall\n\nThe compact boolean vectors are stored with one bit per element (at least 8 bits). \nYou should make no assumption about how boolean vectors are stored if your code may be compiled for different instruction sets or different versions of VCL. For example,\n\\codei{Vec16ib} uses 16 bits of storage when compiling for AVX512, but 512 bits of storage when compiling for AVX2. Do not store boolean vectors directly to binary files, and do not transmit boolean vectors between different functions that may be compiled for different instruction sets or different VCL versions.\n\\vspacesmall\n\nDifferent compact boolean vectors are mutually compatible if they have the same number of elements. Different broad boolean vectors are mutually compatible if they have the same number of elements and the same number of bits. Broad and compact boolean vectors are not compatible with each other. See page \\pageref{ConversionBetweenBooleanTypes} for conversion between different types of boolean vectors.\n\\vspacesmall\n\n\n\\section{Functions for use with booleans}\\label{FunctionsForBooleans}\n\n\\vspacesmall\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & vector select(boolean vector s, vector a, vector b) \\\\ \\hline\n\\bfseries Defined for & all integer and floating point vector classes \\\\ \\hline\n\\bfseries Description & branch per element.\\newline\nresult[i] = s[i] ? a[i] : b[i] \\\\ \\hline\n\\bfseries Efficiency & good \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i a(-1, 0, 1, 2);\nVec4i b = select(a>0, a+10, a-10); // b = (-11,-10,11,12)\n\\end{lstlisting}\n\\vspacesmall\n\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & if\\_add(boolean vector f, vector a, vector b) \\\\ \\hline\n\\bfseries Defined for & all integer and floating point vector classes \\\\ \\hline\n\\bfseries Description & conditional addition \\newline\nresult[i] = f[i] ? (a[i] + b[i]) : a[i] \\\\ \\hline\n\\bfseries Efficiency & good \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i a(-1, 0, 1, 2);\nVec4i b = if_add(a < 0, a, 100);  // b = (99,0,1,2)\n\\end{lstlisting}\n\\vspacesmall\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & if\\_sub(boolean vector f, vector a, vector b) \\\\ \\hline\n\\bfseries Defined for & all integer and floating point vector classes \\\\ \\hline\n\\bfseries Description & conditional subtraction \\newline\nresult[i] = f[i] ? (a[i] - b[i]) : a[i] \\\\ \\hline\n\\bfseries Efficiency & good \\\\ \\hline\n\\end{tabular}\n\\vspacebig\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & vector if\\_mul(boolean vector f, vector a, vector b) \\\\ \\hline\n\\bfseries Defined for & all integer and floating point vector classes \\\\ \\hline\n\\bfseries Description & conditional multiplication\\newline\nresult[i] = f[i] ? (a[i] * b[i]) : a[i] \\\\ \\hline\n\\bfseries Efficiency & good \\\\ \\hline\n\\end{tabular}\n\\vspacebig\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & vector if\\_div(boolean vector f, vector a, vector b) \\\\ \\hline\n\\bfseries Defined for & all floating point vector classes \\\\ \\hline\n\\bfseries Description & conditional division\\newline\nresult[i] = f[i] ? (a[i] / b[i]) : a[i] \\\\ \\hline\n\\bfseries Efficiency & medium \\\\ \\hline\n\\end{tabular}\n\\vspacebig\n\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & vector andnot(vector, vector) \\\\ \\hline\n\\bfseries Defined for & all boolean vector classes \\\\ \\hline\n\\bfseries Description & andnot(a,b) = a \\& $\\sim$ b \\\\ \\hline\n\\bfseries Efficiency & good \\\\ \\hline\n\\end{tabular}\n\\vspacebig\n\n  \n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & bool horizontal\\_and(boolean vector) \\\\ \\hline\n\\bfseries Defined for & all boolean vector classes \\\\ \\hline\n\\bfseries Description & The output is the AND combination of all elements \\\\ \\hline\n\\bfseries Efficiency & Medium for broad boolean vectors. Better if SSE4.1 or later. Good for compact boolean vectors \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i a(-1, 0, 1, 2);\nbool  b = horizontal_and(a > 0);  // b = false\n\\end{lstlisting}\n\\vspacesmall\n\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & bool horizontal\\_or(boolean vector) \\\\ \\hline\n\\bfseries Defined for & all boolean vector classes \\\\ \\hline\n\\bfseries Description & The output is the OR combination of all elements \\\\ \\hline\n\\bfseries Efficiency & Medium for broad boolean vectors. Better if SSE4.1 or later. Good for compact boolean vectors \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i a(-1, 0, 1, 2);\nbool  b = horizontal_or(a > 0);  // b = true\n\\end{lstlisting}\n\\vspacesmall\n\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & int horizontal\\_find\\_first(boolean vector) \\\\ \\hline\n\\bfseries Defined for & all boolean vector classes \\\\ \\hline\n\\bfseries Description & Returns an index to the first element that is true.\nReturns -1 if all elements are false \\\\ \\hline\n\\bfseries Efficiency & medium \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i  a(1, 2, 3, 4);\nVec4i  b(0, 2, 3, 5);\nint c = horizontal_find_first(a == b);  // c = 1\n\\end{lstlisting}\n\\vspacesmall\n\n\n\\begin{tabular}{|p{30mm}|p{120mm}|}\n\\hline\n\\bfseries Function & unsigned int horizontal\\_count(boolean vector) \\\\ \\hline\n\\bfseries Defined for & all boolean vector classes \\\\ \\hline\n\\bfseries Description & counts the number of elements that are true \\\\ \\hline\n\\bfseries Efficiency & medium if SSE4.2 or later \\\\ \\hline\n\\end{tabular}\n\\begin{lstlisting}[frame=none]\n// Example:\nVec4i  a(1, 2, 3, 4);\nVec4i  b(0, 2, 3, 5);\nint c = horizontal_count(a == b);  // c = 2\n\\end{lstlisting}\n\\vspacesmall\n\n\\end{document}\n", "meta": {"hexsha": "16a5c214d5eb9efc24247f4644d451ecddce62c5", "size": 11365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "vcl_bool.tex", "max_stars_repo_name": "haferburg/manual", "max_stars_repo_head_hexsha": "c7b365e7a7bbd3c155ff85edf9c6084311b0c10d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2019-08-05T13:15:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-17T03:17:29.000Z", "max_issues_repo_path": "vcl_bool.tex", "max_issues_repo_name": "haferburg/manual", "max_issues_repo_head_hexsha": "c7b365e7a7bbd3c155ff85edf9c6084311b0c10d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-03T05:13:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-03T05:13:02.000Z", "max_forks_repo_path": "vcl_bool.tex", "max_forks_repo_name": "haferburg/manual", "max_forks_repo_head_hexsha": "c7b365e7a7bbd3c155ff85edf9c6084311b0c10d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2019-08-08T08:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T08:39:06.000Z", "avg_line_length": 43.2129277567, "max_line_length": 851, "alphanum_fraction": 0.7296964364, "num_tokens": 3409, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.4326849578381626}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 7, Section 1.7: 6, 10, 12, 18, 21, 29, 36, 37}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{6.}\n$\\begin{bmatrix} -4&-3&0&0&0 \\\\ 0&-1&5&0 \\\\ 0&0&-15&0 \\\\ 0&0&0&0  \\end{bmatrix}$\\\\\n\nAs we can see the three basic variables give the trivial solution and no free variable. Therefore the columns of A are linearly independent. \n\\subsection*{10. A)}\n$v_3$ in span $\\{v_1, v_2\\}$\\\\\nThe augmented matrix is:\\\\\n$\\begin{bmatrix} 1&-3&2 \\\\ -3&9&-5 \\\\ -5&15&h  \\end{bmatrix}$\\\\\nThe reduced matrix is:\\\\\n$\\begin{bmatrix} 1&-3&2 \\\\ 0&0&1 \\\\ 0&0&10+h  \\end{bmatrix}$\\\\\nAs we can see, $0 = 1$ is not possible, therefore the system has no solution to this equation. \n\\subsection*{10. B)}\nThe reduced matrix is:\\\\\n$\\begin{bmatrix} 1&-3&2&0 \\\\0&0&1&0 \\\\ 0&0&10+h&0  \\end{bmatrix}$\\\\\nIf the system has a non trivial solution then $\\{v_1, v_2, v_3\\}$ is linearly dependent. For non-trivial solutions, $10+h = 0$ means that $h = -10$. $x_2$ is a free variable, which means we have a non-trivial solution. \n\\subsection*{12.}\nThe system is linearly dependent. Therefore the system has a non-trivial solution and $h = -18$\n\\subsection*{18.}\nLinearly dependent. \n\\subsection*{21. A)}\nSince the homogeneous system $Ax = 0$ always has the trivial solution, that means that regardless of A, to possess linearly independent columns, $Ax = 0$ always has a trivial solution. This means the statement is not true. \n\\subsection*{21. B)}\nIf we consider that linear combinations of all vectors then set $S = 0$, then there exists at least one nonzero scalar to satisfy the equation. \\\\\nSince that means every vector in the set $S$ can be left on one side of the equation and all other vectors are on the other side that shows that S is a linear combination of the other vectors, meaning the statement is true. \\\\\n\\subsection*{21. C)}\nThe columns of any 4x5 matrix are linearly dependent. The statement is true. \n\\subsection*{21. D)}\nIf x and y are linearly independent then z is in the span of $\\{x,y\\}$. \\\\\nTherefore any one of the conditions are true (they can't be true simultaneously) \n\\subsection*{36.}\nBy theorem 7, it is true. \n\\subsection*{37.}\nThe given set of vectors $\\{v_1, v_2, v_3\\}$ are linearly dependent and so the set of vectors $\\{v_1, v_2, v_3, v_4\\}$ are linearly dependent, hence the statement is true. \n\n\n\n\n\\end{document}", "meta": {"hexsha": "2b7283ea9a53cdb4cba5918fd8367c3a44774a61", "size": 2715, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LinearAlgebra/Homework7.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LinearAlgebra/Homework7.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LinearAlgebra/Homework7.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0169491525, "max_line_length": 226, "alphanum_fraction": 0.7046040516, "num_tokens": 924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4326849539600433}}
{"text": "\\chapter{Experimental Concepts}\nThis chapter serves as a reminder of commonly used ideas in high-energy physics (HEP) experiments.\n\n\\section{Experimental possibilities}\nIn reality there are rather few experimental possibilities for HEP experiments:\n\\begin{itemize}\n\\item Scatter one particle off another and observe the reaction;\n\\item Generate a particle in a reaction and observe its decay;\n\\item Detect neutrinos and observe neutrino oscillations;\n\\item Measure a particular particle's properties such as mass, charge, spin, parity, lifetime.\n\\end{itemize}\n\n\\section{Cross section}\nThe cross section, $\\sigma$, for a particular reaction is proportional to the probability for the interaction to take place. In HEP experiments, it is expressed in the unit barns, where $\\SI{1}{\\barn} = \\SI{1e-28}{\\meter^2}$.\n\n\\subsection{Beam incident on a target}\nAssume the beam is comprised of bunches with $N_B$ particles per bunch. The beam is incident on a target with area $A$, length $l$ inside the luminous region, and mass density $\\rho$. Then the number of target particles seen by the beam is\n\\begin{equation}\nN_T = \\frac{Al\\rho N_A}{m}\n\\end{equation}\nwhere $N_A$ is Avagadro's number and $m$ is the molecular mass, such that $N_A/m$ is the mass of each target particle.\n\nNow we can define the cross section as\n\\begin{align}\nP(\\text{interaction}) &= (\\text{Number of target particles per unit area}) \\times \\sigma \\\\\n&= \\frac{Al\\rho N_A}{m} \\times \\frac{\\sigma}{A} \\nonumber \\\\\n&= \\frac{l\\rho N_A \\sigma}{m}.\n\\end{align}\nTherefore the total number of interactions per bunch is given by\n\\begin{equation}\nN_I = \\frac{l\\rho N_A N_B \\sigma}{m}.\n\\end{equation}\nNow take the target and bunch to contain number densities $n_B$ and $n_T$ of particles, respectively. They have relative speed $u \\simeq c$. Then the number of target particles in the luminous region is $n_T V$, so the probability of interaction may now be written\n\\begin{equation}\nP(\\text{interaction}) = \\frac{n_T V \\sigma}{A}.\n\\end{equation}\nThere are $n_B u A$ beam particles passing through the luminous region per second, so the rate of interactions is\n\\begin{equation}\n\\frac{\\dd N_I}{\\dd t} = n_B n_T V u \\sigma.\n\\end{equation}\n\n\\subsection{Beam-beam collision}\nFor a circular collider, assume a rotation frequency $f$ for both counter-circulating beams consisting of $n$ bunches, each with $N_B$ particles and area $A$. Then the rate of interactions is\n\\begin{align}\n\\frac{\\dd N_I}{\\dd t} &= P(\\text{collision}) \\times (\\text{particles per second in one beam}) \\\\\n&= \\frac{N_B \\sigma}{A} \\times n f N_B \\nonumber \\\\\n&= \\frac{n f N_B^2 \\sigma}{A} \\label{eq:collRate}.\n\\end{align}\n\n\\section{Luminosity}\nUsing the result from \\eqref{eq:collRate}, we define the instantaneous luminosity\n\\begin{equation}\\boxed{\nL \\equiv \\frac{1}{\\sigma} \\frac{\\dd N_I}{\\dd t}\n}\\end{equation}\nhence for beam-beam collisions\n\\begin{equation}\nL = \\frac{n f N_B^2}{A}.\n\\end{equation}\n\nIn an effort to increase the luminosity, focussing magnets near to the collision regions are used to decrease the bunch area. Also, the number of particles per bunch should be made as large as possible while also maintaining a stable bunch.\n\nSpontaneous luminosity tends to decrease with run time due to collision remnants decreasing the vacuum in the beam pipe and consequently deforming the bunches. An LHC beam has a typical lifetime of around 10--15 hours (the lifetime is the time for $L$ to decay by a factor $e$). At this point the beam is dumped and a new beam is accelerated and injected into the storage ring ready for collisions.\n\nThe units of $L$ are typically \\si{\\per \\pico\\barn \\per \\second}. To get a measure of the total number of interactions observed, and hence the amount of data collected, $L$ may be integrated to give the integrated luminosity,\n\\begin{equation}\\boxed{\nL_\\text{int} = \\int L \\, \\dd t\n}\n\\end{equation}\nwhich often has the units of inverse femtobarns, \\si{\\per \\femto \\barn}.\n\n\\section{Natural units and conversion factors}\nIn natural units, we have $\\hbar = c = 1$. $c$ is the conversion factor between space and time or mass and energy, and $\\hbar$ is the conversion between energy and time. Consider the units of their product:\n\\begin{align}\n[\\hbar c] &= [ET][LT^{-1}] \\nonumber \\\\\n&= [E][L].\n\\end{align}\nNow we have $c = \\SI{3e8}{\\meter\\per\\second}$ and $\\hbar = \\SI{1.05e-34}{\\joule\\second} = \\SI{6.56e-22}{\\mega\\electronvolt\\second}$, so\n\\begin{equation}\\boxed{\n\\hbar c = \\SI{197}{\\mega \\electronvolt \\femto \\meter} \\equiv 1}.\n\\end{equation}\nTherefore, we have\n\\begin{equation}\n\\SI{1}{\\giga\\electronvolt} = \\frac{1000}{\\SI{197}{\\femto\\meter}} = \\SI{5.08e15}{\\per\\meter} = \\SI{1.52e24}{\\per\\second}\n\\end{equation}\n\\begin{equation}\n\\Rightarrow\\quad \\frac{1}{\\si{\\giga\\electronvolt^2}} = \\SI{3.88e-32}{\\meter^2} = \\SI{0.388}{\\milli\\barn}.\n\\end{equation}\n", "meta": {"hexsha": "cabbf6d2f73c036d28252d2b646c132859eebc25", "size": 4816, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/2_Experimental_Concepts.tex", "max_stars_repo_name": "adambozson/Standard-Model-I", "max_stars_repo_head_hexsha": "9ea0d388c93f21d1c636ee18c9210a1b91169308", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/2_Experimental_Concepts.tex", "max_issues_repo_name": "adambozson/Standard-Model-I", "max_issues_repo_head_hexsha": "9ea0d388c93f21d1c636ee18c9210a1b91169308", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/2_Experimental_Concepts.tex", "max_forks_repo_name": "adambozson/Standard-Model-I", "max_forks_repo_head_hexsha": "9ea0d388c93f21d1c636ee18c9210a1b91169308", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.7272727273, "max_line_length": 398, "alphanum_fraction": 0.7381644518, "num_tokens": 1406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4326849462038048}}
{"text": "% \\newappendix{Algorithmic details for estimating surplus description length} \\label{sec:sdl_details}\n\n% Recall that the SDL is defined as\n% \\begin{align}\n%         m_{\\mathrm{SDL}}(\\phi, \\mathcal{D}, \\mathcal{A},\\eps) &= \\sum_{n=1}^\\infty \\Big[ L(\\mathcal{A}_\\phi, n) - \\eps \\Big]_+\n% \\end{align}\n% For simplicity, we assume that $L$ is bounded in $[0,1]$. Note that this can be achieved by truncating the cross-entropy loss.\n\n% \\begin{algorithm}\n% \\caption{Estimate surplus error}\n% \\label{alg:sdl}\n% \\KwIn{tolerance $\\eps $, max iterations $M$, number of datasets $K$, representation $ \\phi$, data distribution $\\mathcal{D}$, algorithm $\\mathcal{A}$ }\n% \\KwOut{Estimate $\\hat m $ of  $m(\\phi, \\mathcal{D}, \\eps, \\mathcal{A})$ and indicator $ I$ of whether this estimate is tight or lower bound}\n% \\vspace{1mm} \\hrule \\vspace{1mm}\n% Sample $ K$ datasets $ D_M^{k}\\sim \\mathcal{D}$ of size $ M+1$\\\\\n% \\For{$n = 1$ \\KwTo $M$}{\n%     For each $ k \\in [K]$, run $ \\mathcal{A}$ on $ D_M^{k}[1:n]$ to produce a predictor $ \\hat p_n^k$\\\\\n%     Take $ K $ test samples $ (x_k, y_k) = D_M^k[M+1]$\\\\\n%     Evaluate $ \\hat L_n = \\frac{1}{K}\\sum_{k=1}^K \\ell(\\hat p_n^k, x_k , y_k) $\n%     }\n% Set $ \\hat m = \\sum_{n=1}^M [\\hat L_n - \\eps]_+$ \\vspace{1mm}\\\\\n% \\lIf {$ \\hat L_M \\leq \\eps/2$} {Set $I = $ \\texttt{tight} \\textbf{else} {Set $ I = $ \\texttt{lower bound}}}\n% \\Return $\\hat m, I$\n% \\end{algorithm}\n\n% In our experiments we replace $D^k_M[1:n]$ of Algorithm \\ref{alg:sdl} with sampled subsets of size $n$ from a single evaluation dataset.\n% Additionally, we use between 10 and 20 values of $n$ instead of evaluating $L(\\mathcal{A}_\\phi, n)$ at every integer between $1$ and $M$.\n% This strategy, also used by \\citet{Blier2018TheDL} and \\citet{Voita2020InformationTheoreticPW}, corresponds to the description length under a code which updates only periodically during transmission of the data instead of after every single point.\n\n% \\begin{theorem}\n% Let the loss function $L$ be bounded in $[0,1]$ and assume that it is decreasing in $ n$. With $ (M+1)K $ datapoints, if the sample complexity is less than $ M$, the above algorithm returns an estimate $ \\hat m$ such that with probability at least $ 1- \\delta$\n% \\begin{align}\n%     |\\hat m - m(\\phi, \\mathcal{D}, \\eps, \\mathcal{A})| \\leq  M\\sqrt{ \\frac{\\log (2M/\\delta)}{2K}}.\n% \\end{align}\n% If $ K \\geq \\frac{\\log(1/\\delta)}{2\\eps^2}$ and the algorithm returns \\texttt{tight} then with probability at least $ 1-\\delta$ the sample complexity is less than $ M $ and the above bound holds.\n% \\end{theorem}\n% \\begin{proof}\n% First we apply a Hoeffding bound to show that each $ \\hat L_n$ is estimated well. For any $ n$, we have\n% \\begin{align}\n%     P \\bigg( \\big|\\hat L_n   - L(\\mathcal{A}_\\phi,n)  \\big| > \\sqrt{\\frac{\\log(2M/\\delta)}{2K}} \\bigg) \\leq 2 \\exp\\bigg(-2K  \\frac{\\log(2M/\\delta)}{2K}\\bigg) = 2 \\frac{\\delta}{2M} = \\frac{\\delta}{M}\n% \\end{align}\n% since each $ \\ell(\\hat p_n^k, x_k , y_k)$ is an independent variable, bounded in [0,1] with expectation $ L(\\mathcal{A}_\\phi, n)$.\n\n% Now when sample complexity is less than $ M$, we use a union bound to translate this to a high probability bound on error of $ \\hat m$, so that with probability at least $ 1- \\delta$:\n% \\begin{align}\n%     |\\hat m - m(\\phi, \\mathcal{D}, \\eps, \\mathcal{A})| &= \\bigg|\\sum_{n=1}^M [\\hat L_n - \\eps]_+  - [L(\\mathcal{A}_\\phi,n) - \\eps]_+  \\bigg|\\\\\n%     &\\leq \\sum_{n=1}^M\\bigg| [\\hat L_n - \\eps]_+  - [L(\\mathcal{A}_\\phi,n) - \\eps]_+ \\bigg|\\\\\n%     &\\leq \\sum_{n=1}^M \\bigg|\\hat L_n - L(\\mathcal{A}_\\phi,n) \\bigg|\\\\\n%     &\\leq M \\sqrt{ \\frac{\\log (2M/\\delta)}{2K}}\n% \\end{align}\n% This gives us the first part of the claim.\n\n% We want to know that when the algorithm returns \\texttt{tight}, the estimate can be trusted (i.e. that we set $ M $ large enough). Under the assumption of large enough $K$, and by an application of Hoeffding, we have that\n% \\begin{align}\n%     P \\bigg(  L(\\mathcal{A}_\\phi,M) - \\hat L_M  > \\eps/2 \\bigg) \\leq  \\exp\\bigg(-2K \\eps^2 \\bigg) \\leq  \\exp\\bigg(-2 \\frac{\\log(1/\\delta)}{2\\eps^2} \\eps^2 \\bigg) = \\delta\n% \\end{align}\n% If $ \\hat L_M \\leq \\eps/2$, this means that $ L(\\mathcal{A}_\\phi,M) \\leq \\eps$ with probability at least $ 1-\\delta$. By the assumption of decreasing loss, this means the sample complexity is less than $ M$, so the bound on the error of $ \\hat m$ holds.\n% \\end{proof}\n\n\n\n% \\newappendix{Algorithmic details for estimating sample complexity} \\label{sec:sc_details}\n% Recall that $\\eps$ sample complexity ($\\eps$SC) is defined as\n% \\begin{align}\n%      m_{\\eps\\mathrm{SC}}(\\phi, \\mathcal{D}, \\mathcal{A},\\eps) &= \\min \\Big\\{ n \\in \\mathbb{N} : L(\\mathcal{A}_\\phi, n) \\leq \\eps \\Big\\}.\n% \\end{align}\n\n% We estimate $m_{\\eps\\mathrm{SC}}$ via recursive grid search. To be more precise, we first define a search interval $[1,N]$, where $N$ is a large enough number such that $L(\\mathcal{A}_\\phi,N) \\ll \\eps$. Then, we partition the search interval in to 10 sub-intervals and estimate risk of hypothesis learned from $D^n \\sim \\mathcal{D}^n$ with high confidence for each sub-interval. We then find the leftmost sub-interval that potentially contains $m_{\\eps\\mathrm{SC}}$ and proceed recursively. This procedure is formalized in Algorithm~\\ref{alg:esc} and its guarantee is given by Theorem~\\ref{thm:esc}.\n% \\begin{algorithm}[h!]\n% \\caption{Estimate sample complexity via recursive grid search}\n% \\label{alg:esc}\n% \\KwIn{Search upper limit $N$, parameters $\\eps$, confidence parameter $\\delta$, data distribution $\\mathcal{D}$, and learning algorithm $\\mathcal{A}$.}\n% \\KwOut{Estimate $\\hat{m}$ such that $m_{\\eps\\mathrm{SC}}(\\phi,\\mathcal{D},\\mathcal{A},\\eps) \\le \\hat m$ with probability $1-\\delta$.}\n% \\vspace{1mm} \\hrule \\vspace{1mm}\n% let $S = 2\\log (20k/\\delta)/\\eps^2$, and let $[\\ell,u]$ be the search interval initialized at $\\ell = 1, u = N$.\\\\\n% \\For{$r=1$ \\KwTo $k$}{\n%     Partition $[\\ell,u]$ into 10 equispaced bins and let $\\Delta$ be the length of each bin. \\\\\n%     \\For{$j = 1$ \\KwTo $10$}{\n%         Set $n = \\ell + j \\Delta$. \\\\\n%         Compute $\\hat L_n = \\frac{1}{S}\\sum_{i=1}^S \\ell(\\mathcal{A}(D^n_i),x_i,y_i)$ for $S$ independent draws of $D^n$ and test sample $(x,y)$. \\\\\n%         \\If{$\\hat L_n \\le \\eps/2$}{\n%         Set $u = n$ and $\\ell = n - \\Delta$. \\\\\n%         \\textbf{break}\n%         }\n%         }\n% }\n% \\Return $\\hat m = u$, which satisfies $m_{\\eps\\mathrm{SC}}(\\phi,\\mathcal{D},\\mathcal{A},\\eps) \\le \\hat m$ with probability $1-\\delta$, where the randomness is over independent draws of $D^n$ and test samples $(x,y)$.\n% \\end{algorithm}\n\n% \\begin{theorem}\n% \\label{thm:esc}\n% Let the loss function $L$ be bounded in $[0,1]$ and assume that it is decreasing in $ n$. Then, Algorithm~\\ref{alg:esc} returns an estimate $ \\hat m$ that satisfies $m_{\\eps\\mathrm{SC}}(\\phi,\\mathcal{D},\\mathcal{A},\\eps) \\le \\hat m$ with probability at least $ 1- \\delta$.\n% \\end{theorem}\n\n% \\begin{proof}\n% By Hoeffding, the probability that $|\\hat L_n-L(\\mathcal{A}_{\\phi},n)| \\ge \\eps/2$, where $\\hat L$ is computed with $S = 2\\log(20k/\\delta)/\\eps^2$ independent draws of $D^n \\sim \\mathcal{D}^n$ and $(x,y) \\sim \\mathcal{D}$, is less than $\\delta/(10k)$. The algorithm terminates after evaluating $\\hat L$ on at most $10k$ different $n$'s. By a union bound, the probability that $|\\hat L_n - L(\\mathcal{A}_{\\phi},n)| \\le \\eps/2$ for all $n$ used by the algorithm is at least $1-\\delta$. Hence, $\\hat L_n \\le \\eps/2$ implies $L(\\mathcal{A}_\\phi,n) \\le \\eps$ with probability at least $1-\\delta$.\n% \\end{proof}\n\n\\newappendix{Experimental details} \\label{sec:experiment_details}\n\nIn each experiment we first estimate the loss-data curve using a fixed number of dataset sizes $n$ and multiple random seeds, then compute each measure from that curve.\nReported values of SDL correspond to the estimated area between the loss-data curve and the line $y=\\eps$ using Riemann sums with the values taken from the left edge of the interval.\nThis is the same as the chunking procedure of \\citet{Voita2020InformationTheoreticPW} and is equivalent to the code length of transmitting each chunk of data using a fixed model and switching models between intervals.\nReported values of $\\eps$SC correspond to the first measured $n$ at which the loss is less than $\\eps$.\n\nAll of the experiments were performed on a single server with 4 NVidia Titan X GPUs, and on this hardware no experiment took longer than an hour.\nAll of the code for our experiments, as well as that used to generate our plots and tables, is included in the supplement.\n\n\n\\subsection{MNIST experiments}\n\nFor our experiments on MNIST, we implement a highly-performant vectorized library in \\hyperlink{https://jax.readthedocs.io/en/latest/}{JAX} to construct loss-data curves.\nWith this implementation it takes about one minute to estimate the loss-data curve with one sample at each of 20 settings of $n$.\nWe approximate the loss-data curves at 20 settings of $n$ log-uniformly spaced on the interval $[10, 50000]$ and evaluate loss on the test set to approximate the population loss.\nAt each dataset size $n$ we perform the same number of updates to the model; we experimented with early stopping for smaller $n$ but found that it made no difference on this dataset.\nIn order to obtain lower-variance estimates of the expected risk at each $n$, we run 8 random seeds for each representation at each dataset size, where each random seed corresponds to a random initialization of the probe network and a random subsample of the evaluation dataset.\n\nProbes consist of two-hidden-layer MLPs with hidden dimension 512 and ReLU activations.\nAll probes and representations are trained with the Adam optimizer \\citep{Kingma2015AdamAM} with learning rate $10^{-4}$.\n\nEach representation is normalized to have zero mean and unit variance before probing to ensure that differences in scaling and centering do not disrupt learning.\nThe representations of the data we evaluate are implemented as follows.\n\n\\paragraph{Raw pixels.}\nThe raw MNIST pixels are provided by the Pytorch \\texttt{datasets} library \\citep{Paszke2019PyTorchAI}.\nIt has dimension $28 \\times 28 = 784$.\n\n\\paragraph{CIFAR.}\nThe CIFAR representation is given by the last hidden layer of a convolutional neural network trained on the CIFAR-10 dataset.\nThis representation has dimension 784 to match the size of the raw pixels.\nThe network architecture is as follows:\n\n\\begin{verbatim}\n    nn.Conv2d(1, 32, 3, 1),\n    nn.ReLU(),\n    nn.MaxPool2d(2),\n    nn.Conv2d(32, 64, 3, 1),\n    nn.ReLU(),\n    nn.MaxPool2d(2),\n    nn.Flatten(),\n    nn.Linear(1600, 784)\n    nn.ReLU()\n    nn.Linear(784, 10)\n    nn.LogSoftmax()\n\\end{verbatim}\n\n\\paragraph{VAE.}\nThe VAE (variational autoencoder; \\citet{Kingma2014AutoEncodingVB,Rezende2014StochasticBA}) representation is given by a variational autoencoder trained to generate the MNIST digits.\nThis VAE's latent variable has dimension 8.\nWe use the mean output of the encoder as the representation of the data.\nThe network architecture is as follows:\n\\begin{verbatim}\nself.encoder_layers = nn.Sequential(\n    nn.Linear(784, 400),\n    nn.ReLU(),\n    nn.Linear(400, 400),\n    nn.ReLU(),\n    nn.Linear(400, 400),\n    nn.ReLU(),\n)\nself.mean = nn.Linear(400, 8)\nself.variance = nn.Linear(400, 8)\n\nself.decoder_layers = nn.Sequential(\n    nn.Linear(8, 400),\n    nn.ReLU(),\n    nn.Linear(400, 400),\n    nn.ReLU(),\n    nn.Linear(400, 784),\n)\n\\end{verbatim}\n\n\\subsection{Part of speech experiments}\n\nWe follow the methodology and use the official code\\endnote{Code available at \\url{https://github.com/lena-voita/description-length-probing}.} of \\citet{Voita2020InformationTheoreticPW} for our part of speech experiments using ELMo \\citep{Peters2018DeepCW} pretrained representations.\nIn order to obtain lower-variance estimates of the expected risk at each $n$, we run 4 random seeds for each representation at each dataset size, where each random seed corresponds to a random initialization of the probe network and a random subsample of the evaluation dataset.\nWe approximate the loss-data curves at 10 settings of $n$ log-uniformly spaced on the range of the available data $n \\in [10, 10^6]$.\nTo more precisely estimate $\\eps$SC, we perform one recursive grid search step: we space 10 settings over the range which in the first round saw $L(\\mathcal{A}_\\phi, n)$ transition from above to below $\\eps$.\n\nProbes consist of the MLP-2 model of \\citet{Hewitt2019DesigningProbes,Voita2020InformationTheoreticPW} and all training parameters are the same as in those works.\n", "meta": {"hexsha": "2bdfb85c571f0bb718f470e0fb797ae53be82eac", "size": 12516, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/repr-eval-appendix.tex", "max_stars_repo_name": "willwhitney/dissertation", "max_stars_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-20T20:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-20T20:31:06.000Z", "max_issues_repo_path": "content/repr-eval-appendix.tex", "max_issues_repo_name": "willwhitney/doctoral-thesis", "max_issues_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/repr-eval-appendix.tex", "max_forks_repo_name": "willwhitney/doctoral-thesis", "max_forks_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-25T13:01:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-25T13:01:43.000Z", "avg_line_length": 69.1491712707, "max_line_length": 601, "alphanum_fraction": 0.6975870885, "num_tokens": 3883, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4326849462038048}}
{"text": "﻿\\begin{appendix}\r\n\\section{Examples}\r\n\r\n\\subsection{Leech word square-freeness}\r\nLet us consider the SLP $\\slp{L}$ that derives substring of Leech square free word: \r\n\r\n\\begin{center}\r\n$\\slpterm{L}{1}{a}, \\slpterm{L}{2}{b}, \\slpterm{L}{3}{c}, \\slpnonterm{L}{4}{2}{3}, \\slpnonterm{L}{5}{2}{1},\r\n\\slpnonterm{L}{6}{1}{4}$\r\n\r\n$\\slpnonterm{L}{7}{3}{4}, \\slpnonterm{L}{8}{6}{5}, \\slpnonterm{L}{9}{8}{4}, \\slpnonterm{L}{10}{8}{7},\r\n\\slpnonterm{L}{11}{10}{9}$\r\n\\end{center}\r\n\r\nParse tree for $\\slp{L}$ presented at figure 4.\r\n\r\n\\begin{figure}[th]\r\n\\LeechSLP\r\n\\end{figure}\r\n\r\nLet us check square freeness of $\\slp{L}$. Since $|L| = 15$ then the algorithm check the following segments of root\r\nlength: [1, 1], [2, 3], [4, 7]. Notice that rules of $\\slp{L}$ already ordered by length of derived text.\r\n\r\n\\begin{itemize}\r\n  \\item \\textbf{checking square freeness of squares that root length equals to 1}\r\n  \r\n  Firstly the algorithm skip terminal rules. Next it consecutively look for squares exactly in other rules. For\r\n  instance, let us consider how it checks $\\slpnonterm{L}{10}{8}{7}$. The algorithm find $L_8[5] = a$ and $L_7[1] = c$\r\n  using $\\slp{L}_{10}$. Since $a \\neq c$ it moves to $\\slp{L}_{11}$.\r\n  \r\n  It is clear that $\\slp{L}_4, \\dots, \\slp{L}_{11}$ have no squares of length 2 around its cut positions.\r\n  \\item \\textbf{checking square freeness of squares that root length belong to [2, 3]}\r\n  \r\n  The algorithm skip all rules that have length less 4 (i.e. $\\slp{L}_1, \\dots, \\slp{L}_7$). For instance, let us\r\n  consider how it checks $\\slpnonterm{L}{8}{6}{5}$. Since $|L_8| = 5$ and block length is equal to 1 then the algorithm\r\n  construct an SLP $\\slp{L}_8'$ that derives text \\emph{\\$~\\$~\\$~\\$~\\$~a~b~c~b~a~\\$~\\$~\\$~\\$~\\$~\\$}, where \\emph{\\$} is\r\n  special symbol not from $\\Sigma$. At figure 5 presented partition of $L_8'$ into blocks of length 1.\r\n  \r\n  \\LeechWordPartitionSimple\r\n  \r\n  Remind that the algorithm necessary to check blocks $B_5, \\dots, B_{12}$. It no need to check $B_5$ since it contains\r\n  \\emph{\\$}. Also it no need to check $B_9$ and $B_{10}$ since the search area is out of $L_8$. For instance, let us\r\n  consider how it checks $B_7$. The algorithm build $\\slp{L}_8'\\substr{6}{7}$ that derives $B_7$ and  \r\n  $\\slp{L}_8'\\substr{8}{11}$ that derives search area $B_9 \\cdot B_{10}$. Next it runs pattern matching algorithm on\r\n  $\\slp{L}_8'\\substr{6}{7}$, $\\slp{L}_8'\\substr{8}{11}$ and obtain occurrence of $B_7$ at position 9 of $L_8'$. Finally\r\n  it runs \\textbf{SubsExt} problem with the following parameters: $\\slp{L}_8'$ and positions 6, 7, 8, 9. The algorithm\r\n  obtains $\\ell_{ex} = r_{ex} = 0$. Since $\\ell_{ex} + r_{ex} = 0 = a - (k - 1) \\cdot 2^{i-2} = 8 - (9 - 1) \\cdot 1$ then\r\n  algorithm moves to $L_9$.\r\n\r\n  \\item \\textbf{checking square freeness of squares that root length belongs to [4, 7]}\r\n  \r\n  The algorithm skip all rules that have length less 8 (i.e. $\\slp{L}_1, \\dots, \\slp{L}_9$). For instance, let us\r\n  consider how it checks $\\slpnonterm{L}{11}{10}{9}$. Firstly it construct an SLP $\\slp{L}_{11}'$ that derives $L$\r\n  surrounded with \\emph{\\$} and $|L_{11}'| = 32$. At figure 6 presented partition of $L_{11}'$ into blocks of length\r\n  2. \r\n  \r\n  \\LeechWordPartitionComplex\r\n\r\n  Next the algorithm find no squares for $B_5, \\dots, B_8$ since pattern matching algorithm returns empty set of\r\n  results. Next the algorithm find occurrence of $B_9$ at position 22 of $L_{11}'$ and run \\textbf{SubsExt}\r\n  problem with the following parameters: $\\slp{L}_{11}'$ and positions 16, 18, 20, 22. Since $\\ell_{ex} = r_{ex} = 0$ the\r\n  algorithm moves to $B_{10}$. Finally the algorithm find no squares for $B_{10}, B_{11}, B_{12}$ since correspond\r\n  search areas contains \\emph{\\$}.\r\n\\end{itemize}\r\n\r\n\\subsection{Construction PS-table for $\\slp{F}_7$}\r\n\r\nLet us consider how the algorithm construct PS-table for $\\slp{F}_7$ that derives text \\emph{a~b~a~a~b~a~b~a~a~b~a~a~b}.\r\nThe PS-table size is equal to $(\\lfloor\\log |F_7|\\rfloor+1)\\times (|\\slp{F}_7|+1) = 4 \\times 8$. \r\n\r\n\\begin{itemize}\r\n  \\item \\textbf{looking for squares that root length equals to 1}\r\n  \r\n  Firstly the algorithm mark cells with $\\varnothing$ for rules with length less than 2. Next it consecutively look for\r\n  squares exactly in other rules. PS(1, 3) = $\\varnothing$ since $F_1[1] = a \\neq b = F_2[1]$. Analogously PS(1, 4) =\r\n  PS(1, 6) = $\\varnothing$. PS(1, 5) = \\{1, 3, 3\\} since $F_4[3] = a = F_3[1]$. PS(1, 7) = \\{1, 8, 8\\} since $F_6[8] = a\r\n  = F_5[1]$. After first step PS-table has the following view: \r\n  \r\n  \\begin{figure}[h]\r\n\t  {\\footnotesize\\noindent\r\n\t\t\\begin{tabular}{|c|c|c|c|c|c|c|c|} \\hline\r\n\t \t& $\\slpterm{F}{1}{a}$ & $\\slpterm{F}{2}{b}$ & $\\slpnonterm{F}{3}{1}{2}$ & $\\slpnonterm{F}{4}{3}{1}$ &\r\n\t \t$\\slpnonterm{F}{5}{4}{3}$ & $\\slpnonterm{F}{6}{5}{4}$ & $\\slpnonterm{F}{7}{6}{5}$ \\\\ \\hline\r\n\t\r\n\t \t[1, 1] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{1, 3, 3\\} & $\\varnothing$ & \\{1, 8, 8\\} \\\\\r\n\t \t\\hline\r\n\t\r\n\t \t[2, 3] & & & & & & & \\\\ \\hline\r\n\t\r\n\t \t[4, 7] & & & & & & & \\\\ \\hline\r\n\t\t\\end{tabular}\r\n\t  }\r\n  \\end{figure}\r\n  \r\n  \\item \\textbf{looking for squares that root length belongs to [2, 3]}\r\n  \r\n  The algorithm mark cells with $\\varnothing$ for rules with length less than 4. For instance, let us consider\r\n  how the algorithm fill PS(2, 6). The algorithm construct SLP $\\slp{F}_6'$ that derives text\r\n  \\emph{\\$~\\$~\\$~a~b~a~a~b~a~b~a~\\$~\\$~\\$~\\$~\\$} of length 16. At figure 7 presented partition of $F_6'$ into blocks.\r\n  \r\n  \\FibonacciWordPartition\r\n  \r\n  $B_5$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_5$ at position 8 of $F_6'$ on  \r\n  $\\slp{F}_{6}'\\substr{5}{6}, \\slp{F}_{6}'\\substr{7}{9}$; the substring extending algorithm obtain $\\ell_{ex} = r_{ex} = 1$\r\n  on $\\slp{F}_{6}'$ with parameters 5, 6, 8, 9; so family of repetitions \\{3, 7, 7\\} was found;\r\n  \r\n  $B_6$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_6$ at position 9 of $F_6'$ on  \r\n  $\\slp{F}_{6}'\\substr{6}{7}, \\slp{F}_{6}'\\substr{8}{10}$; the substring extending algorithm obtain $\\ell_{ex} = 2, r_{ex}\r\n  = 0$ on $\\slp{F}_{6}'$ with parameters 6, 7, 9, 10; so family of repetitions \\{3, 7, 7\\} was found;\r\n  \r\n  $B_7$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_7$ at position 9 of $F_6'$ on  \r\n  $\\slp{F}_{6}'\\substr{7}{8}, \\slp{F}_{6}'\\substr{9}{11}$; the substring extending algorithm obtain $\\ell_{ex} = 0, r_{ex}\r\n  = 1$ on $\\slp{F}_{6}'$ with parameters 7, 8, 9, 10; so no family of repetitions was found;\r\n  \r\n  $B_8$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_8$ at position 10 of $F_6'$ on  \r\n  $\\slp{F}_{6}'\\substr{8}{9}, \\slp{F}_{6}'\\substr{10}{12}$; the substring extending algorithm obtain $\\ell_{ex} = r_{ex}\r\n  = 1$ on $\\slp{F}_{6}'$ with parameters 8, 9, 10, 11; so family of repetitions \\{2, 8, 9\\} was found;\r\n  \r\n  $B_9$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_9$ at position 11 of $F_6'$ on  \r\n  $\\slp{F}_{6}'\\substr{9}{10}, \\slp{F}_{6}'\\substr{11}{13}$; the substring extending algorithm obtain $\\ell_{ex} = 1,\r\n  r_{ex} = 0$ on $\\slp{F}_{6}'$ with parameters 9, 10, 11, 12; so family of repetitions \\{2, 9, 9\\} was found;\r\n  \r\n  The algorithm skip blocks $B_{10}, \\dots, B_{12}$ since the search area consist of \\emph{\\$}. After merging families \r\n  of repetitions the algorithm have the following result: \\{3, 7, 7\\}, \\{2, 8, 9\\}. Finally the algorithm check purity\r\n  of families and shift them form $F_{6}'$ to $F_6$. \r\n  \r\n  After second step PS-table has the following view:\r\n  \r\n  \\begin{figure}[h]\r\n\t  {\\footnotesize\\noindent\r\n\t\t\\begin{tabular}{|c|c|c|c|c|c|c|c|} \\hline\r\n\t \t& $\\slpterm{F}{1}{a}$ & $\\slpterm{F}{2}{b}$ & $\\slpnonterm{F}{3}{1}{2}$ & $\\slpnonterm{F}{4}{3}{1}$ &\r\n\t \t$\\slpnonterm{F}{5}{4}{3}$ & $\\slpnonterm{F}{6}{5}{4}$ & $\\slpnonterm{F}{7}{6}{5}$ \\\\ \\hline\r\n\t\r\n\t \t[1, 1] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{1, 3, 3\\} & $\\varnothing$ & \\{1, 8, 8\\} \\\\\r\n\t \t\\hline\r\n\t\r\n\t \t[2, 3] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{3, 4, 4\\}, \\{2, 5, 6\\} &\r\n\t \t\\{3, 10, 10\\} \\\\ \t\\hline\r\n\t\r\n\t \t[4, 7] & & & & & & & \\\\ \\hline\r\n\t\t\\end{tabular}\r\n\t  }\r\n  \\end{figure}\r\n  \r\n  \\item \\textbf{looking for squares that root length belongs to [4, 7]}\r\n  \r\n  The algorithm mark cells with $\\varnothing$ for rules with length less than 8. The algorithm construct SLP\r\n  $\\slp{F}_7'$ that surrounds with \\emph{\\$} and has length 32. At figure 8 presented partition of $F_7'$ into\r\n  blocks. Let us consider how the algorithm fill PS(3, 7). It skips $B_5$ since $B_5$ contains \\emph{\\$}. \r\n  \r\n   \\FibonacciWordPartitionComplex\r\n  \r\n  $B_6$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_6$ at position 15; the substring extending algorithm\r\n  obtain $\\ell_{ex} = 1, r_{ex} = 3$ on $\\slp{F}_{7}'$ with parameters 10, 12, 14, 18; so family of repetitions \\{5, 14,\r\n  15\\} was found;\r\n  \r\n  $B_7$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_7$ at position 17; the substring extending algorithm\r\n  obtain $\\ell_{ex} = 3, r_{ex} = 1$ on $\\slp{F}_{7}'$ with parameters 12, 14, 16, 20; so family of repetitions \\{5, 14,\r\n  15\\} was found;\r\n  \r\n  $B_8$: using \\textbf{PM} problem the algorithm obtain occurrence of $B_8$ at position 20; the substring extending algorithm\r\n  obtain $\\ell_{ex} = r_{ex} = 0$ on $\\slp{F}_{7}'$ with parameters 14, 16, 18, 22; so there are no families of\r\n  repetitions;\r\n  \r\n  $B_9$: using \\textbf{PM} problem the algorithm obtain no occurrence of $B_9$; so there are no families of repetitions;\r\n  \r\n  The algorithm skips $B_{10}$ and $B_{11}$ since search areas consist of \\emph{\\$}. It skips $B_{12}$ since $B_{12}$\r\n  contains \\emph{\\$}. After merging families of repetitions the algorithm have the following result: \\{5, 14, 15\\}. \r\n  Finally the algorithm check purity of families and shift them form $F_{7}'$ to $F_7$.\r\n  \r\n  Finally PS-table has the following view:\r\n  \r\n  \\begin{figure}[h]\r\n\t  {\\footnotesize\\noindent\r\n\t\t\\begin{tabular}{|c|c|c|c|c|c|c|c|} \\hline\r\n\t \t& $\\slpterm{F}{1}{a}$ & $\\slpterm{F}{2}{b}$ & $\\slpnonterm{F}{3}{1}{2}$ & $\\slpnonterm{F}{4}{3}{1}$ &\r\n\t \t$\\slpnonterm{F}{5}{4}{3}$ & $\\slpnonterm{F}{6}{5}{4}$ & $\\slpnonterm{F}{7}{6}{5}$ \\\\ \\hline\r\n\t\r\n\t \t[1, 1] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{1, 3, 3\\} & $\\varnothing$ & \\{1, 8, 8\\} \\\\\r\n\t \t\\hline\r\n\t\r\n\t \t[2, 3] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{3, 4, 4\\}, \\{2, 5, 6\\} &\r\n\t \t\\{3, 10, 10\\} \\\\ \\hline\r\n\t\r\n\t \t[4, 7] & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & \\{5, 5, 6\\}\r\n\t \t\\\\ \\hline\r\n\t\t\\end{tabular}\r\n\t  }\r\n  \\end{figure}\r\n\\end{itemize}\r\n\r\n\\subsection{Text with complex family of pure squares}\r\nLet us consider an SLP $\\slp{E} = \\slp{E}_l \\cdot \\slp{E}_r$ such that $\\slp{E}_l$ derives text $(a~b~a~b~a)^6~a~b~a$\r\nand $\\slp{E}_r$ derives text $b~a~a~b~a~(a~b~a~b~a)^7$. So $\\slp{E}$ derives text $(a~b~a~b~a)^7~a~b~a~(a~b~a~b~a)^7$\r\nand $|E| = 73$. Let us consider how the algorithm looking for pure squares for rule $\\slp{E}$ and segment [16, 31]. The \r\nalgorithm construct SLP $\\slp{E}'$ that surrounds with \\emph{\\$} and has length 128. The partition of $E'$ into blocks\r\npresented at figure 9. \r\n\r\n\\ComplexExamplePartititon\r\n\r\nLet us consider how the algorithm process block $B_8$. It find occurrence of $B_8$ in $B_9 \\cdot B_{10}$ at positions\r\n$\\prog{72}{2}{5}$. Since the algorithm find more than one occurrence it extends periodicity to calculate parameters\r\n$\\alpha_L, \\alpha_R, \\gamma_L, \\gamma_R$. So $\\alpha_L = \\infty, \\alpha_R = 69, \\gamma_L = 66, \\gamma_R = \\infty$.\r\nAccording to lemma !!! the algorithm find complex family of pure squares associated with each of root length \\{18, 23\\} \r\nand centred at positions \\{66, 67, 68, 69\\}. Next we write every root from the family exactly: \r\n\r\n\\begin{itemize}\r\n  \\item \\textbf{roots of length 18}\r\n\r\n  $a~b~a(a~b~a~b~a)^3$, $b~a(a~b~a~b~a)^3a$, $a(a~b~a~b~a)^3a~b$, $(a~b~a~b~a)^3a~b~a$;\r\n  \\item \\textbf{roots of length 23}\r\n  \r\n  $a~b~a(a~b~a~b~a)^4$, $b~a(a~b~a~b~a)^4a$, $a(a~b~a~b~a)^4a~b$, $(a~b~a~b~a)^4a~b~a$;\r\n\\end{itemize}\r\n\r\n\\end{appendix}", "meta": {"hexsha": "fc00fca2e851461c0924aad0bc0c9a800568ca93", "size": 12247, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "texfiles/Khvorost/cas_problem/appendix.tex", "max_stars_repo_name": "jaamal/overclocking", "max_stars_repo_head_hexsha": "b40db5a72710c691ca558e22626c5c382fd3677a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "texfiles/Khvorost/cas_problem/appendix.tex", "max_issues_repo_name": "jaamal/overclocking", "max_issues_repo_head_hexsha": "b40db5a72710c691ca558e22626c5c382fd3677a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-04-11T12:58:50.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-12T10:54:35.000Z", "max_forks_repo_path": "texfiles/Khvorost/cas_problem/appendix.tex", "max_forks_repo_name": "jaamal/overclocking", "max_forks_repo_head_hexsha": "b40db5a72710c691ca558e22626c5c382fd3677a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.4377880184, "max_line_length": 126, "alphanum_fraction": 0.6268473912, "num_tokens": 4686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.43268494025025894}}
{"text": "\\documentclass{article}\n\\usepackage[legalpaper, portrait, margin=0.99in]{geometry}\n\n% Language setting\n% Replace `english' with e.g. `spanish' to change the document language\n\\usepackage[english]{babel}\n\n% Set page size and margins\n% Replace `letterpaper' with`a4paper' for UK/EU standard size\n\\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\n% Useful packages\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{authblk}\n\\usepackage{amsfonts} \n\\usepackage{comment}\n\n\\title{Vectorized Adjoint Sensitivity Method for Graph Convolutional Neural Ordinary Differential Equations}\n\\author[1]{Jack Cai}\n\\affil[1]{University of Toronto, Division of Engineering Science}\n\\date{August 9, 2021}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nThis document, as the title stated, is meant to provide a vectorized implementation of adjoint dynamics calculation for Graph Convolutional Neural Ordinary Differential Equations (GCDE). The adjoint sensitivity method is the gradient approximation method for neural ODEs that replaces the back propagation. When implemented on libraries such as PyTorch or Tensorflow, the adjoint can be calculated by autograd functions without the need for a hand-derived formula. In applications such as edge computing and in memristor crossbars, however, autograds are not available, and therefore we need a vectorized derivation of adjoint dynamics to efficiently map the system on hardware. This document will go over the basics, then move on to derive the vectorized adjoint dynamics for GCDE.\n\\end{abstract}\n\n\\section{Introduction and Preliminaries}\n\nNeural Ordinary Differential Equations (ODE) is a class of residual neural networks that frames the layer-wise propagation of hidden states into an initial value problem using differential equation solvers. \n\\begin{equation}\nh_{t+1} = h_{t} + f(h_{t}, \\theta_{t})\n\\end{equation}\nA typical residual network may have layer wise transformation of hidden states looks like Equation (1). If we add more layers and take smaller time step, then the entire problem can be framed as an ODE defined by Equation (2), and a solution at time $t_{1}$ defined by Equation (3). \n\\begin{equation}\n\\frac{dh(t)}{dt} = f(h(t), t, \\theta)\n\\end{equation}\n\\begin{equation}\nh(t_{1}) = h(t_{0}) + \\int_{t_{0}}^{t_{1}} f(h(t), t, \\theta)dt\n\\end{equation}\nCompared to conventional deep neural networks (DNNs), neural ODE uses less parameters applied more times to the hidden states, thereby achieves the depth of DNN while having higher memory efficiency. \n\n\\subsection{Adjoint sensitivity method}\nThe adjoint sensitivity method is used for automatic differentiation for neural ODE. Unlike traditional backpropagation, a quantity named adjoint is calculated for each $t$ and another ODE solver is used to integrate the overall gradient. Let $L()$ be the scaler loss function for the neural ODE, the adjoint is defined as $a(t) = \\frac{\\partial L}{\\partial h(t)}$, and its dynamic is given by Equation (4):\n\\begin{equation}\n\\frac{da(t)}{dt} = -a(t)^{T}\\frac{\\partial f(h(t), t, \\theta)}{\\partial h}\n\\end{equation}\nThe adjoint at each instant is calculated by a backward ODE solver, and the overall gradient of the parameters $\\frac{\\partial L}{\\partial \\theta}$ is given by Equation (5), which is integrated by another ODE solver:\n\\begin{equation}\n\\frac{\\partial L}{\\partial \\theta} = -\\int_{t_{1}}^{t_{0}} a(t)^{T}\\frac{\\partial f(h(t), t, \\theta)}{\\partial \\theta}dt\n\\end{equation}\nThe proof and intuition behind adjoint sensitivity method is presented in the original paper. For the scope of this paper, we are only focused on how Equation (4) and (5) can be vectorized for GCDE. \n\n\\subsection{GCDE}\nGCDE, in short, is the neural ODE version of the state of the art graph learning method Graph Convolutional Neural Network (GCN). For GCN and GCDE, hidden state is represented by a matrix H of dimension $\\mathbb{R}^{N\\times C}$, representing $N$ nodes with $C$ features. Each layer of GCN or each step of GCDE involves node-wise exchange of information and convolution on nodes. The dynamic of GCDE (which is the same as the layer-wise propagation of GCN) is given by Equation (6), where $A\\in\\mathbb{R}^{N\\times N}$ is symmetric that represents the graph topology and $W\\in\\mathbb{R}^{C\\times C}$ represents the convolution filters:\n\\begin{equation}\n\\frac{dH(t)}{dt} = f(H(t), A, W) = ReLU(AH(t)W)\n\\end{equation}\nTo calculate the adjoint, we need to calculate calculate the Jacobian of the function $f(H(t), A, W)$, namely $\\frac{\\partial f(H(t), A, W)}{\\partial H(t)}$ and $\\frac{\\partial f(H(t), A, W)}{\\partial W}$. This poses us a challenge as we will have to unroll the matrix into vectors. While this can be done easily with built-in autograd functions in PyTorch and Tensorflow, it becomes messy when we write it out to obtain an analytical vectorized solution. \n\n\\subsection{Matrix conventions}\nBefore we delve into deriving the adjoint dynamics, I would like to discuss some convention used in this document. All matrices are represented by capital letters, all vectors are represented by bold lower case letter, all entries within a matrix are represented by the $i$,$j$ subscripts which denotes the $i_{th}$ and $j_{th}$ entry of the matrix, and all entries within a vector are represented by a single subscript denoting the index. For example, $A$ is a matrix, $\\mathbf{b}$ is a vector, $a_{1, 2}$ denotes the $1, 2$ entry of $A$, and $b_{2}$ denotes the second entry of $\\mathbf{b}$. We use $``:\"$ to denote the entire indices along a row or column, so that we represent the $i_{th}$ row of $A$ as $\\mathbf{a}_{i,:}$, and we represent $j_{th}$ column of A as $\\mathbf{a}_{:,j}$.\n\n\\subsection{Multivariable calculus conventions}\n \nLet $f: \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$ where it takes in a vector $\\mathbf{x} \\in\\mathbb{R}^{n}$ and output a vector $\\mathbf{y} \\in\\mathbb{R}^{m}$, i.e.:\n\n\\begin{equation}\n\\begin{bmatrix}\n    y_{1}       \\\\\n    y_{2}      \\\\\n    \\vdots \\\\\n    y_{m}      \n\\end{bmatrix}\n= f(\n\\begin{bmatrix}\n    x_{1} \\\\\n    x_{2} \\\\\n    \\vdots \\\\\n    x_{n} \n\\end{bmatrix}\n)\n\\end{equation}\nThen the Jacobian matrix $J_{f} \\in \\mathbb{R}^{m\\times n}$ is defined as:\n\n\\begin{equation}\nJ_{f} = f(\n\\begin{bmatrix}\n    \\frac{\\partial y_{1}}{\\partial x_{1}} & \\frac{\\partial y_{1}}{\\partial x_{2}} &\\hdots & \\frac{\\partial y_{1}}{\\partial x_{n}} \\\\\n    \\frac{\\partial y_{2}}{\\partial x_{1}}  & \\ddots &\\hdots & \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial y_{m}}{\\partial x_{1}}  & \\hdots & \\hdots & \\frac{\\partial y_{m}}{\\partial x_{n}} \n\\end{bmatrix}\n)\n\\end{equation}\nFollowing this convention, let $f: \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$ and $g: \\mathbb{R}^{m} \\rightarrow \\mathbb{R}^{p}$, then $g \\circ f: \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{p}$. The chain rule is defined as: \n\\begin{equation}\n    J_{g \\circ f} = J_{g}\\cdot J_{f}\n\\end{equation}\n\n\\subsection{Partial derivatives of a matrix}\nFinding the Jacobian for GCDE is challenging not only because it is a composite function, but also because the input is a matrix, we need to unroll the matrix into vectors to match our matrix Jacobian convention. Let $roll()$ and $unroll()$ to be such operations:\n\\begin{equation}\n    \\mathbb{R}^{m\\times n}\\ni A = roll(\\mathbf{a}), \\mathbf{a}\\in\\mathbb{R}^{mn}\n\\end{equation}\n\\begin{equation}\n    \\mathbb{R}^{mn}\\ni\\mathbf{a} = unroll(A),  A\\in\\mathbb{R}^{m\\times n}\n\\end{equation}\nThe example below illustrate how they can be used. Suppose $f: \\mathbb{R}^{m\\times n} \\rightarrow \\mathbb{R}^{p\\times n}$ defined by $f(A) = BA$, where $B \\in \\mathbb{R}^{p\\times m}$. Using Equation (10) and (11), we can convert $f$ into $g: \\mathbb{R}^{mn}\\rightarrow \\mathbb{R}^{pn}$, such that:\n\\begin{equation}\n    g(\\mathbf{a}) = unroll(B(roll(\\mathbf{a})))\n\\end{equation}\nAs a result, we can obtained a Jacobian matrix $J_{g} \\in \\mathbb{R}^{pn\\times mn}$, which follows the convention defined in section 1.4. The way we unroll a matrix could be by rows or by columns -- it really depends on the situation.\n\\section{Adjoint derivation for GCDE}\nThe key of finding the Jacobian matrix for $f(H(t), A, W)$ is to find the Jacobian matrix for the three-matrix multiplication step, as the derivative for $ReLU$ is just an elementwise binary step function. So before we moving on solving the Jacobian matrix for the whole thing, let's consider the general case function $f(A) = XAY: \\mathbb{R}^{n\\times p}  \\rightarrow \\mathbb{R}^{m\\times q}$ where $X\\in\\mathbb{R}^{m\\times n}$, $A\\in\\mathbb{R}^{n\\times p}$, and $Y\\in\\mathbb{R}^{p\\times q}$. We can think of it as composite function $f(A) = h\\circ g(A)$, where:\n\\begin{equation}\n    g(A) = XA = B, B\\in\\mathbb{R}^{m\\times p}\n\\end{equation}\n\\begin{equation}\nh(B) = BY = C, C\\in\\mathbb{R}^{m\\times q}\n\\end{equation}\nAccording to our convention, we need to unroll the matrix into vectors in order to calculate the Jacobian matrix. Let $\\widehat{g}$ and $\\widehat{h}$ to denote them and $\\mathbf{a} = unroll(A)$ and $\\mathbf{b} = unroll(B)$:\n\\begin{equation}\n\\widehat{g}(\\mathbf{a}) = unroll(X(roll(\\mathbf{a})))\n\\end{equation}\n\\begin{equation}\n\\widehat{h}(\\mathbf{b}) = unroll((roll(\\mathbf{b}))Y)\\end{equation}\n\\begin{center}\n    $\\widehat{f}(\\mathbf{a}) = \\widehat{h}\\circ\\widehat{g}(\\mathbf{a})$\n\\end{center}\nHence, according to chain rule, the Jacobian matrix $J_{\\widehat{h}\\circ\\widehat{g}} = J_{\\widehat{h}}\\cdot J_{\\widehat{g}}$ and we will calculate it step by step below.\n\n\\subsection{Jacobian matrix $J_{\\widehat{g}}$ for $g(A)=XA$}\nWe will start by breaking $X$ into rows and $A$ into columns. According to our convention outlined in section 1.3, Equation (13) becomes:\n\n\\begin{center}$g(A) = XA = \\begin{bmatrix} \\mathbf{x}_{1,:} \\\\ \\vdots \\\\ \\mathbf{x}_{1,:} \\end{bmatrix} \\begin{bmatrix} \\mathbf{a}_{:,1} && \\hdots && \\mathbf{a}_{:,p} \\end{bmatrix} \\\\$\n\\end{center}\n\n\\begin{center}$\n= \\begin{bmatrix}\n    \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1} & \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2} &\\hdots & \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,p} \\\\\n    \\mathbf{x}_{2,:} \\cdot \\mathbf{a}_{:,1}  & \\ddots &\\hdots & \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\mathbf{x}_{m,:} \\cdot \\mathbf{a}_{:,1}  & \\hdots & \\hdots & \\mathbf{x}_{m,:} \\cdot \\mathbf{a}_{:,p}\n\\end{bmatrix}\n= \\begin{bmatrix}\n    b_{1, 1} & b_{1,2} &\\hdots & b_{1,p} \\\\\n    b_{2,1}  & \\ddots &\\hdots & \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    b_{m,1}  & \\hdots & \\hdots & b_{m,p}\n\\end{bmatrix}\n$\n\\end{center}\nSince we used rows of $X$ and columns of $A$, for our convenience, we will unroll $B$ by rows and $A$ by columns. Therefore our Jacobian matrix $J_{\\widehat{g}}$ becomes:\n\\begin{center}$\nJ_{\\widehat{g}} = \n\\begin{bmatrix}\n    \\frac{\\partial b_{1,1}}{\\partial a_{1,1}} & \\frac{\\partial b_{1,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial b_{1,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial b_{1,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial b_{1, 2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial b_{1,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial b_{2,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial b_{m,p}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial b_{m,p}}{\\partial a_{n,p}}\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n    \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{1,1}} & \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial \\mathbf{x}_{2,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial \\mathbf{x}_{m,:} \\cdot \\mathbf{a}_{:,m}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial \\mathbf{x}_{m,:} \\cdot \\mathbf{a}_{:,p}}{\\partial a_{n,p}}\n\\end{bmatrix}\n$\n\\end{center}\nNotice that for $\\frac{\\partial \\mathbf{x}_{1, :} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{2,1}}$, the partial derivative is non-zero because $\\mathbf{x}_{1, :} \\cdot \\mathbf{a}_{:,1}$ depends on the entry $a_{2,1}$; whereas for $\\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2}}{\\partial a_{1,1}}$, the partial derivative is zero because $a_{1,1}$ is not an entry inside the column vector $\\mathbf{a}_{:, 2}$, therefore change in $a_{1,1}$ do not impact $\\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2}$. \\textit{The entry must be within the column vector to have a non-zero partial derivative}. Following this pattern, our Jacobian matrix $J_{\\widehat{g}}$ becomes:\n\\begin{center}$\nJ_{\\widehat{g}} = \\begin{bmatrix}\n    \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{1,1}} & \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{2,1}} &\\hdots &  0 &\\hdots & 0 \\\\\n    0  & \\ddots &\\hdots & \\frac{\\partial \\mathbf{x}_{1,:} \\cdot \\mathbf{a}_{:,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial \\mathbf{x}_{2,:} \\cdot \\mathbf{a}_{:,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    0  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial \\mathbf{x}_{m,:} \\cdot \\mathbf{a}_{:,p}}{\\partial a_{n,p}}\n\\end{bmatrix}\n$\n\\end{center}\nTaking the derivative of the dot product, vectorize it and we get the Jacobian matrix $J_{\\widehat{g}}$:\n\\begin{equation}\nJ_{\\widehat{g}} = \\begin{bmatrix}\n    x_{1,1} &\\hdots & x_{1,n}&  0 &\\hdots & 0 \\\\\n    0   &\\ddots & 0 &x_{1,1}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    x_{2,1}  & \\vdots & x_{2,n} & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    0  & \\hdots & \\hdots & \\hdots & \\hdots & x_{m,n}\n\\end{bmatrix} = \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n    \\mathbf{x}_{2,:}  & &   &  \\\\\n      & \\mathbf{x}_{2,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{2,:}\\\\\n     & \\hdots& \\hdots &\\\\\n     \\mathbf{x}_{m,:}  & &   &  \\\\\n      & \\mathbf{x}_{m,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{m,:}\n\\end{bmatrix}\n\\in \\mathbb{R}^{mp \\times np}\n\\end{equation}\n\n\\subsection{Jacobian matrix $J_{\\widehat{h}}$ for $h(B)=BY$}\nSimilarly to section 2.1, we will start by breaking $B$ and $Y$ into rows and columns. So Equation (14) becomes:\n\n\\begin{center}$\nh(B) = BY = \\begin{bmatrix} \\mathbf{b}_{1,:} \\\\ \\vdots \\\\ \\mathbf{b}_{m,:} \\end{bmatrix} \n\\begin{bmatrix} \\mathbf{y}_{:,1} && \\hdots && \\mathbf{y}_{:,q} \\end{bmatrix} \\\\$\n\\end{center}\n\n\\begin{center}$\n= \\begin{bmatrix}\n    \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} & \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,2} &\\hdots & \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,p} \\\\\n    \\mathbf{b}_{2,:} \\cdot \\mathbf{y}_{:,1}  & \\ddots &\\hdots & \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\mathbf{b}_{m,:} \\cdot \\mathbf{y}_{:,1}  & \\hdots & \\hdots & \\mathbf{b}_{m,:} \\cdot \\mathbf{y}_{:,p}\n\\end{bmatrix}\n= \\begin{bmatrix}\n    c_{1,1} & c_{1,2} &\\hdots & c_{1,p} \\\\\n    c_{2,1}  & \\ddots &\\hdots & \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    c_{m,1}  & \\hdots & \\hdots & c_{m,p}\n\\end{bmatrix}\n$\n\\end{center}\nWe will unroll B by rows and C by columns to construct our Jacobian matrix:\n\\begin{center}$\nJ_{\\widehat{h}} = \n\\begin{bmatrix}\n    \\frac{\\partial c_{1,1}}{\\partial b_{1,1}} & \\frac{\\partial c_{1,1}}{\\partial b_{1,2}} &\\hdots &  \\frac{\\partial c_{1,1}}{\\partial b_{2,1}} &\\hdots & \\frac{\\partial c_{1,1}}{\\partial b_{m,p}} \\\\\n    \\frac{\\partial c_{1,2}}{\\partial b_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial c_{1,2}}{\\partial b_{2,1}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial c_{2,1}}{\\partial b_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial c_{m,q}}{\\partial b_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial c_{m,q}}{\\partial b_{m,p}}\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n    \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{1,1}} & \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{1,2}} &\\hdots &  \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{2,1}} &\\hdots & \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{m,p}} \\\\\n    \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,2} }{\\partial b_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,2} }{\\partial b_{2,1}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial \\mathbf{b}_{2,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial \\mathbf{b}_{m,:} \\cdot \\mathbf{y}_{:,q} }{\\partial b_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial \\mathbf{b}_{m,:} \\cdot \\mathbf{y}_{:,q} }{\\partial b_{m,p}}\n\\end{bmatrix}\n$\n\\end{center}\nBy the pattern that non-pairing entry and row vectors have zero partial derivatives, the Jacobian matrix can be reduced to:\n\\begin{center}$\nJ_{\\widehat{h}}\n=\n\\begin{bmatrix}\n    \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{1,1}} & \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,1} }{\\partial b_{1,2}} &\\hdots &  0 &\\hdots & 0 \\\\\n    \\frac{\\partial \\mathbf{b}_{1,:} \\cdot \\mathbf{y}_{:,2} }{\\partial b_{1,1}}  & \\ddots &\\hdots & 0 & \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    0 & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    0  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial \\mathbf{b}_{m,:} \\cdot \\mathbf{y}_{:,q} }{\\partial b_{m,p}}\n\\end{bmatrix}\n$\n\\end{center}\nTaking the partial derivatives of the dot product:\n\\begin{center}$\nJ_{\\widehat{h}}\n=\n\\begin{bmatrix}\n    y_{1,1} & y_{2,1} &\\hdots & y_{p,1}&  0 &\\hdots & 0 \\\\\n    y_{1,2}  & \\vdots &\\ddots  &y_{p,2}&0& \\hdots& \\vdots \\\\\n    \\vdots &\\vdots& \\vdots & \\ddots & \\hdots & \\hdots & \\vdots\\\\\n    y_{1,q} & y_{2,q} & \\vdots & y_{p,q}& 0 & \\hdots & \\vdots\\\\\n    0& 0 & \\vdots & 0& y_{1,1} & \\hdots & \\vdots\\\\\n    0 & 0 & \\vdots & 0& y_{1,2} & \\hdots & \\vdots\\\\\n    \\vdots&\\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    0 & 0 & \\vdots & 0& y_{1,q} & \\hdots & \\vdots\\\\\n    \\vdots&\\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    0  &\\hdots& \\hdots & \\hdots & \\hdots & \\hdots & y_{p,q}\n\\end{bmatrix}\n$\n\\end{center}\nNotice that the diagonal $q\\times p$ blocks are $Y^T$, therefore:\n\\begin{equation}\nJ_{\\widehat{h}}\n=\n\\begin{bmatrix}\n    Y^T \\\\ & Y^T \\\\ & & Y^T \\\\ & & & \\ddots \\\\ & & & & Y^T\n\\end{bmatrix} \\in \\mathbb{R}^{mq \\times mp}\n\\end{equation}\n\n\\subsection{Calculating $J_{\\widehat{h}\\circ\\widehat{g}} $ from the chain rule}\nBy the chain rule, we calculate $J_{\\widehat{h}\\circ\\widehat{g}} \\in \\mathbb{R}^{mq \\times np}$ by $J_{\\widehat{h}}\\cdot J_{\\widehat{g}}$:\n\\begin{center}$\nJ_{\\widehat{h}}\\cdot J_{\\widehat{g}}\n=\n\\begin{bmatrix}\n    Y^T \\\\ & Y^T \\\\ & & Y^T \\\\ & & & \\ddots \\\\ & & & & Y^T\n\\end{bmatrix} \\cdot \n\\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n     & \\hdots& \\hdots &\\\\\n     \\mathbf{x}_{m,:}  & &   &  \\\\\n      & \\mathbf{x}_{m,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{m,:}\n\\end{bmatrix}\n$\n\\end{center}\nTo simplify the matrix multiplication, we break done $Y^T$ to (note that $\\mathbf{y}_{i,:}^T \\in \\mathbb{R}^{q\\times1}$ is the transpose of the first row of $Y$):\n\\begin{center}$\nY^T=\\begin{bmatrix}\n    \\mathbf{y}_{1,:}^T & \\mathbf{y}_{2,:}^T & \\hdots & \\mathbf{y}_{p,:}^T\n\\end{bmatrix} \n$\\end{center}\nAnd we break the matrix multiplication blocks by blocks:\n\\begin{center}\n    $J_{\\widehat{h}}\\cdot J_{\\widehat{g}}=\n    \\begin{bmatrix}\n    \\begin{bmatrix}Y^T & \\textbf{0}& \\hdots& \\textbf{0}\\end{bmatrix} \\cdot J_{\\widehat{g}}\\\\\n    \\begin{bmatrix}\\textbf{0}& Y^T& \\hdots& \\textbf{0}\\end{bmatrix} \\cdot J_{\\widehat{g}}\\\\\n    \\hdots     \\\\\n     \\begin{bmatrix}\\textbf{0} & \\textbf{0}& \\hdots& Y^T\\end{bmatrix} \\cdot J_{\\widehat{g}}   \n    \\end{bmatrix} \n    $\n\\end{center}\nLet's look at the first block:\n\\begin{equation}\n\\begin{bmatrix}Y^T & \\textbf{0}& \\hdots& \\textbf{0}\\end{bmatrix} \\cdot J_{\\widehat{g}} = \n    \\begin{bmatrix}\n    Y^T & \\textbf{0}& \\hdots& \\textbf{0}\n\\end{bmatrix} \\cdot \n\\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n     & \\hdots& \\hdots &\\\\\n     \\mathbf{x}_{m,:}  & &   &  \\\\\n      & \\mathbf{x}_{m,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{m,:}\n\\end{bmatrix}\n\\end{equation}\nNote that since $Y^T$  $\\in q\\times p$, only the first $p$ rows of $J_{\\widehat{g}}$ matters. Hence Equation (19) becomes: \n\\begin{center}\n    $Y^T \\cdot\n    \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n\\end{bmatrix}$\n\\end{center}\n\n\\begin{center}\n    $=\\begin{bmatrix}\n    \\mathbf{y}_{1,:}^T & \\mathbf{y}_{2,:}^T & \\hdots & \\mathbf{y}_{p,:}^T\n\\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n\\end{bmatrix}$\n\\end{center}\n\\begin{center}\n    $= \\begin{bmatrix}\n     \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{1,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{1,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{1,:}\\end{bmatrix} \\in \\mathbb{R}^{q\\times pn}$\n\\end{center}\nIf we repeat for other blocks, we would get the Jacobian matrix for $J_{\\widehat{h}\\circ\\widehat{g}} $ to be:\n\n\\begin{equation}\n    J_{\\widehat{h}\\circ\\widehat{g}} = \\begin{bmatrix}\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{1,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{1,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{1,:} \\\\\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{2,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{2,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{2,:} \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots \\\\\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{m,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{m,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{m,:} \\\\\n     \\end{bmatrix} \\in \\mathbb{R}^{qm \\times pn}\n\\end{equation}\nIt is also important to keep in mind what each entry within $J_{\\widehat{h}\\circ\\widehat{g}}$ mean:\n\\begin{center}\n    $J_{\\widehat{h}\\circ\\widehat{g}}=J_{\\widehat{h}}\\cdot J_{\\widehat{g}} = \n    \\begin{bmatrix}\n    \\frac{\\partial c_{1,1}}{\\partial b_{1,1}} & \\frac{\\partial c_{1,1}}{\\partial b_{1,2}} &\\hdots &  \\frac{\\partial c_{1,1}}{\\partial b_{2,1}} &\\hdots & \\frac{\\partial c_{1,1}}{\\partial b_{m,p}} \\\\\n    \\frac{\\partial c_{1,2}}{\\partial b_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial c_{1,2}}{\\partial b_{2,1}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial c_{2,1}}{\\partial b_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial c_{m,q}}{\\partial b_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial c_{m,q}}{\\partial b_{m,p}}\n\\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n    \\frac{\\partial b_{1,1}}{\\partial a_{1,1}} & \\frac{\\partial b_{1,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial b_{1,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial b_{1,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial b_{1, 2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial b_{1,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial b_{2,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial b_{m,p}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial b_{m,p}}{\\partial a_{n,p}}\n\\end{bmatrix}\n$\n\\end{center}\n\\begin{equation}\n    = \\begin{bmatrix}\n    \\frac{\\partial c_{1,1}}{\\partial a_{1,1}} & \\frac{\\partial c_{1,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial c_{1,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial c_{1,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial c_{1,2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial c_{1,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial c_{2,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial c_{m,q}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial c_{m,q}}{\\partial a_{n,p}}\n\\end{bmatrix}\n\\end{equation}\n\n\n\\subsection{Adjoint calculation}\nNow we have successfully found the general solution of Jacobian matrix for $f(A)=XAY$ and $g(A)=XA$ (or more precisely, the unrolled version of them, namely $f(\\mathbf{a})$ and $\\widehat{g}(\\mathbf{a})$, and it is time to apply them in the adjoint calculation for GCDE, as they are the special cases of the general solutions outlined in section 2.1-2.3. Back in section 1.2 I stated that we need to find the Jacobian matrix $\\frac{\\partial f(H(t), A, W)}{\\partial H(t)}$ and $\\frac{\\partial f(H(t), A, W)}{\\partial W}$; well that does not actually make sense in our convention since (1) $H(t)$ is not a vector and (2) the adjoint must be a vector, which means $\\frac{\\partial L}{\\partial H(t)}$ should also be unrolled. Therefore, a GCDE version of adjoint dynamics for Equation (4) and (5) is:\n\\begin{equation}\n    -a(t)^{T}\\frac{\\partial f(h(t), t, \\theta)}{\\partial h} \\rightarrow \n    -\\frac{\\partial L}{\\partial \\mathbf{h}(t)}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{h}(t)} \n\\end{equation}\n\\begin{equation}\n    -a(t)^{T}\\frac{\\partial f(h(t), t, \\theta)}{\\partial \\theta} \\rightarrow\n        -\\frac{\\partial L}{\\partial \\mathbf{h}(t)}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{w}}\n\\end{equation}\nwhere $\\mathbf{h}(t) = unroll(H(t))$, $\\mathbf{w} = unroll(W)$, and $\\widehat{f}(\\mathbf{h}(t), A, W) = unroll(f(roll(\\mathbf{h}(t)), A, W))$.\nHowever, this does not stop us to find a vectorized equivalence for Equation (4) and (5) for GCDE implementation on hardware, as keeping the matrices unrolled greatly increases the dimensions and could not take the parallel in-memory computing advantages brought by memristor crossbars. \n\n\n%The first adjoint, $\\frac{\\partial L}{\\partial H(t)}^T\\cdot\\frac{\\partial f(H(t), A, W)}{\\partial H(t)}$\n\n%$\\frac{\\partial f(H(t), A, W)}{\\partial H(t)}$ and $\\frac{\\partial f(H(t), A, W)}{\\partial W}$\n\n\\subsection{Vectorized Equation (22)}\nWe start the vectorization from the general case $f(A)=XAY$ we discussed in the earlier sections. Let $ \\mathbb{R}^{m\\times q}\\ni C = f(A)$, and $\\mathbb{R}^{mq}\\ni\\mathbf{c} = unroll(C)$, we unroll $C$ row by row so that its partial derivatives with respect to a scalar loss function $L$ has the form:\n\\begin{center}\n    $\\frac{\\partial L}{\\partial \\mathbf{c}} = \n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial c_{1,1}} \\\\ \\vdots \\\\\\frac{\\partial L}{\\partial c_{1,q}}\\\\ \\frac{\\partial L}{\\partial c_{2,1}} \\\\ \\vdots \\\\ \\frac{\\partial L}{\\partial c_{m,q}}\n    \\end{bmatrix} =\n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}}^T \\\\ \\frac{\\partial L}{\\partial \\mathbf{c}_{2,:}}^T\\\\ \\vdots \\\\ \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}}^T\n    \\end{bmatrix} \\in \\mathbb{R}^{mq}, \\frac{\\partial L}{\\partial \\mathbf{c}_{i,:}} \\in \\mathbb{R}^{1\\times q}\n    $ \n\\end{center}\nWe want to find (a reminder that $\\widehat{f}(\\mathbf{a})$ is a unrolled version of $f(A)$):\n\\begin{center}\n$\n-\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} \\frac{\\partial \\widehat{f}(\\mathbf{a})}{\\partial \\mathbf{a}}=\n-\\frac{\\partial L}{\\partial \\mathbf{c}}^{T}  J_{\\widehat{f}} = -\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}$\n\\end{center}\nExpand and plug in Equation (20):\n\\begin{center}\n    $ -\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}} = \n    -\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{c}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}}\n    \\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{1,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{1,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{1,:} \\\\\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{2,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{2,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{2,:} \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots \\\\\n    \\mathbf{y}_{1,:}^T\\cdot\\mathbf{x}_{m,:}  &  \\mathbf{y}_{2,:}^T\\cdot\\mathbf{x}_{m,:} & \\hdots & \\mathbf{y}_{p,:}^T\\cdot\\mathbf{x}_{m,:} \\\\\n     \\end{bmatrix}\n    $\n\\end{center}\nSince $\\frac{\\partial L}{\\partial \\mathbf{c}_{i,:}} \\in \\mathbb{R}^{1\\times q}$ and $\\mathbf{y}^T_{i,:}\\cdot \\mathbf{x}_{j,:} \\in \\mathbb{R}^{q\\times n}$, the blocks defined above have matching dimensions. Hence we can take their dot product directly:\n\\begin{center}\n    $ -\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}} = -\n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:}\\cdot \\mathbf{x}_{1,:}  + \\hdots + \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:}\\cdot \\mathbf{x}_{m,:}  &\n        \\hdots & \n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{p,:}\\cdot \\mathbf{x}_{1,:}   + \\hdots + \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{p,:}\\cdot \\mathbf{x}_{m,:} \n    \\end{bmatrix}\n    $\n\\end{center}\nNote that this dot product is a long $1\\times np$ vector, and we can simplify it by rolling it into a $p\\times n$ matrix:\n\n\\begin{equation}\n    -roll(\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = -\n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:}\\cdot \\mathbf{x}_{1,:}   + \\hdots + \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:}\\cdot \\mathbf{x}_{m,:} \\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{2,:}\\cdot \\mathbf{x}_{1,:}   + \\hdots + \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{2,:}\\cdot \\mathbf{x}_{m,:} \\\\\n        \\vdots\\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{p,:}\\cdot \\mathbf{x}_{1,:}   + \\hdots + \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{p,:}\\cdot \\mathbf{x}_{m,:} \n    \\end{bmatrix}\n\\end{equation}\nEquation (24) can be further simplified:\n\\begin{center}\n    $-roll(\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:} \\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{2,:}  &\\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m, :}} \\cdot \\mathbf{y}^T_{2,:}\\\\\n        \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{p,:} &  \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{p,:} \n    \\end{bmatrix} \\cdot \\begin{bmatrix}\n        \\mathbf{x}_{1,:} \\\\ \\mathbf{x}_{2,:} \\\\ \\vdots \\\\ \\mathbf{x}_{m,:}\n    \\end{bmatrix} = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:} \\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{2,:}  &\\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m, :}} \\cdot \\mathbf{y}^T_{2,:}\\\\\n        \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{p,:} &  \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{p,:} \n    \\end{bmatrix} \\cdot X$\n\\end{center}\nLet:\n\\begin{center}\n    $E = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:} \\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{2,:}  &\\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m, :}} \\cdot \\mathbf{y}^T_{2,:}\\\\\n        \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{p,:} &  \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{p,:} \n    \\end{bmatrix}$\n\\end{center}\nWe can simplify E further by looking at it row by row. The first row of E is:\n\\begin{equation}\n    \\mathbf{e}_{1,:} = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} \\cdot \\mathbf{y}^T_{1,:} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}} \\cdot \\mathbf{y}^T_{1,:}\n    \\end{bmatrix}\n\\end{equation}\nNotice that each entry within Equation (25) is a scalar because $\\frac{\\partial L}{\\partial \\mathbf{c}_{i,:}} \\in \\mathbb{R}^{1\\times q}$ and $\\mathbf{y}^T_{1,:} \\in \\mathbb{R}^{q\\times 1}$. Therefore, we can manipulate Equation (25) such that: \n\\begin{center}\n    $\\mathbf{e}_{1,:} = (\\mathbf{y}^T_{1,:})^{T} \\cdot \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}}^{T} & \\frac{\\partial L}{\\partial \\mathbf{c}_{2,:}}^{T} & \\hdots &\\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}}^{T} \n    \\end{bmatrix} = \\mathbf{y}_{1,:} \\cdot \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}}^{T} & \\frac{\\partial L}{\\partial \\mathbf{c}_{2,:}}^{T} & \\hdots &\\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}}^{T} \n    \\end{bmatrix}$\n\\end{center}\nWe define $\\frac{\\partial L}{\\partial C}$ having matching entries to $C$:\n\\begin{center}\n    $\\frac{\\partial L}{\\partial C} = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial c_{1,1}} & \\frac{\\partial L}{\\partial c_{1,2}} & \\hdots &\\frac{\\partial L}{\\partial c_{1,q} } \\\\\n        \\frac{\\partial L}{\\partial c_{2,1}} & \\ddots & \\hdots &\\vdots \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial c_{m,1}} & \\hdots & \\hdots &\\frac{\\partial L}{\\partial c_{m,q}}\n    \\end{bmatrix}$\n\\end{center}\nTherefore:\n\\begin{center}\n        $\\mathbf{e}_{1,:} = \\mathbf{y}_{1,:} \\cdot \\frac{\\partial L}{\\partial C}^T$\n\\end{center}\nIf we repeat for all rows of $E$, then:\n\\begin{center}\n   $E = \\begin{bmatrix}\n        \\mathbf{y}_{1,:} \\cdot \\frac{\\partial L}{\\partial C}^T \\\\\n        \\mathbf{y}_{2,:} \\cdot \\frac{\\partial L}{\\partial C}^T\\\\\n        \\vdots \\\\\n        \\mathbf{y}_{p,:} \\cdot \\frac{\\partial L}{\\partial C}^T\n    \\end{bmatrix}\n    = \\begin{bmatrix}\n        \\mathbf{y}_{1,:}  \\\\\n        \\mathbf{y}_{2,:} \\\\\n        \\vdots \\\\\n        \\mathbf{y}_{p,:} \n    \\end{bmatrix} \\cdot \\frac{\\partial L}{\\partial C}^T = Y \\cdot \\frac{\\partial L}{\\partial C}^T$\n\\end{center}\nAs a result:\n\\begin{equation}\n    -roll(\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = -E \\cdot X = -Y \\cdot \\frac{\\partial L}{\\partial C}^T \\cdot X\n\\end{equation}\nWe need to keep in mind what this matrix actually represents. So we go back to Equation (21):\n\\begin{center}\n    $ -roll(\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = \n    -roll(\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{c}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{c}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{c}_{m,:}}\n    \\end{bmatrix} \\cdot= \\begin{bmatrix}\n    \\frac{\\partial c_{1,1}}{\\partial a_{1,1}} & \\frac{\\partial c_{1,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial c_{1,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial c_{1,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial c_{1,2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial c_{1,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial c_{2,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial c_{m,q}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial c_{m,q}}{\\partial a_{n,p}}\n\\end{bmatrix})\n    $\n\\end{center}\n\n\\begin{center}\n$=-roll(\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial a_{1,1}} & \\frac{\\partial L}{\\partial a_{2,1}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,1}} & \\frac{\\partial L}{\\partial a_{1,2}} & \\hdots& \\frac{\\partial L}{\\partial a_{n,p}}\n    \\end{bmatrix})$\n\\end{center}\n\\begin{equation}\n=-\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial a_{1,1}} & \\frac{\\partial L}{\\partial a_{2,1}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,1}} \\\\\n        \\frac{\\partial L}{\\partial a_{1,2}} & \\frac{\\partial L}{\\partial a_{2,2}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,2}} \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial a_{1,p}} & \\frac{\\partial L}{\\partial a_{2,p}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,p}} \n    \\end{bmatrix}=\n    -\\begin{bmatrix}\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,1}}^T- \\\\\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,2}}^T- \\\\\n        \\vdots\\\\\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,p}}^T- \\\\\n    \\end{bmatrix}\n\\end{equation}\nNotice that the entries of this matrix matches the transpose of $A$. Hence, in order to match the entries of $A$, we will take Equation (27)'s transpose -- and here we found the general vectorized adjoint solution for $f(A)$:\n\\begin{center}\n    $vectorized(-\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = -\\begin{bmatrix}\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,1}}^T- \\\\\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,2}}^T- \\\\\n        \\vdots\\\\\n        -\\frac{\\partial L}{\\partial \\mathbf{a}_{:,p}}^T- \\\\\n    \\end{bmatrix}^T = -(Y \\cdot \\frac{\\partial L}{\\partial C}^T \\cdot X)^T $\n\\end{center}\n\\begin{equation}\n    vectorized(-\\frac{\\partial L}{\\partial \\mathbf{c}}^{T} J_{\\widehat{h}\\circ\\widehat{g}}) = -X^T \\cdot \\frac{\\partial L}{\\partial C} \\cdot Y^T\n\\end{equation}\nThe adjoint dynamics shown in Equation (22) for GCDE is just a special of Equation (28). The derivative of the $ReLU()$ activation function is an element-wise binary step function:\n\\begin{equation}\n    step(x)=\n    \\begin{cases} \n      1 & x>0 \\\\\n      0 & x\\leq 0 \n   \\end{cases}\n\\end{equation}\nHence, let $\\odot$ denote the Hadamard product between matrices, by chain rule and Equation (28), the vectorized Equation (22) is:\n\\begin{center}\n    $vectorized(-\\frac{\\partial L}{\\partial \\mathbf{h}(t)}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{h}(t)}) = \n    -A^T \\cdot (\\frac{\\partial L}{\\partial H(t)} \\odot step(H(t)))\\cdot W^T$\n\\end{center}\nwhere:\n\\begin{center}\n    $\\frac{\\partial L}{\\partial H(t)} = roll(\\frac{\\partial L}{\\partial \\mathbf{h}(t)})=\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial h_{1,1}} & \\frac{\\partial L}{\\partial h_{1,2}} & \\hdots &\\frac{\\partial L}{\\partial h_{1,q} } \\\\\n        \\frac{\\partial L}{\\partial h_{2,1}} & \\ddots & \\hdots &\\vdots \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial h_{m,1}} & \\hdots & \\hdots &\\frac{\\partial L}{\\partial h_{m,q}}\n    \\end{bmatrix}$\n\\end{center}\nSince by definition of GCDE, the graph topology matrix A is always symmetric, the final vectorized Equation (22) is:\n\\begin{equation}\n vectorized(-\\frac{\\partial L}{\\partial \\mathbf{h}(t)}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{h}(t)}) = \n    -A \\cdot (\\frac{\\partial L}{\\partial H(t)} \\odot step(H(t)))\\cdot W^T\n\\end{equation}\n\\subsection{Vectorized Equation (23)}\nWe will again vectorize Equation (23) from a general case, $g(A)=XA$. This is because we can treat $AH(t)$ in Equation (6) as a single matrix that linearly transforms $W$. Let $ \\mathbb{R}^{m\\times p}\\ni B = g(A)$, and $\\mathbb{R}^{mp}\\ni\\mathbf{b} = unroll(B)$, we unroll $B$ row by row so that its partial derivatives with respect to a scalar loss function $L$ has the form:\n\\begin{center}\n    $\\frac{\\partial L}{\\partial \\mathbf{b}} = \n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial b_{1,1}} \\\\ \\vdots \\\\\\frac{\\partial L}{\\partial b_{1,p}}\\\\ \\frac{\\partial L}{\\partial b_{2,1}} \\\\ \\vdots \\\\ \\frac{\\partial L}{\\partial b_{m,p}}\n    \\end{bmatrix} =\n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{b}_{1,:}}^T \\\\ \\frac{\\partial L}{\\partial \\mathbf{b}_{2,:}}^T\\\\ \\vdots \\\\ \\frac{\\partial L}{\\partial \\mathbf{b}_{m,:}}^T\n    \\end{bmatrix} \\in \\mathbb{R}^{mp}, \\frac{\\partial L}{\\partial \\mathbf{b}_{i,:}} \\in \\mathbb{R}^{1\\times p}\n    $ \n\\end{center}\nIn addition, we define\n\\begin{center}\n    $\\frac{\\partial L}{\\partial B} = \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial b_{1,1}} & \\frac{\\partial L}{\\partial b_{1,2}} & \\hdots &\\frac{\\partial L}{\\partial b_{1,q} } \\\\\n        \\frac{\\partial L}{\\partial b_{2,1}} & \\ddots & \\hdots &\\vdots \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial b_{m,1}} & \\hdots & \\hdots &\\frac{\\partial L}{\\partial b_{m,q}}\n    \\end{bmatrix}$\n\\end{center}\nSince we are considering the general case $g(A)=XA$ and we are given an arbitury adjoint $\\mathbf{b}$, we can change Equation (17) to:\n\\begin{center}\n$-\\frac{\\partial L}{\\partial \\mathbf{h}(t)}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{w}} \\rightarrow \n-\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} \\frac{\\partial \\widehat{g}(\\mathbf{a})}{\\partial \\mathbf{a}} = -\\frac{\\partial L}{\\partial \\mathbf{b}}^{T}  J_{\\widehat{g}}$\n\\end{center}\nExpand and plug in Equation (17):\n\\begin{center}\n    $ -\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}} = \n    -\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{b}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{b}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{b}_{m,:}}\n    \\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  & &   &  \\\\\n      & \\mathbf{x}_{1,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{1,:}\\\\\n     & \\hdots& \\hdots &\\\\\n     \\mathbf{x}_{m,:}  & &   &  \\\\\n      & \\mathbf{x}_{m,:} & &  \\\\\n     &  & \\ddots &\\\\\n     &  &  & \\mathbf{x}_{m,:}\n\\end{bmatrix}$\n\\end{center}\nWe again break it into blocks:\n\\begin{center}\n    $ -\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}} = \n    -\\begin{bmatrix} \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{b}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{b}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{b}_{m,:}}\n    \\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  \\\\\n       \\vdots\\\\\n    \\textbf{0} \\\\\n     \\mathbf{x}_{2,:} \\\\\n      \\vdots\\\\\n     \\mathbf{x}_{m,:} \\\\\n    \\vdots\\\\\n    \\textbf{0} \\\\\n\\end{bmatrix} \\hdots \n    \\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{b}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{b}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{b}_{m,:}}\n    \\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n      \\textbf{0} \\\\\n       \\vdots\\\\\n    \\mathbf{x}_{1,:} \\\\\n      \\textbf{0} \\\\\n      \\vdots\\\\\n      \\textbf{0}\\\\\n    \\vdots\\\\\n    \\mathbf{x}_{m,:} \\\\\n\\end{bmatrix}\n\\end{bmatrix}$\n\\end{center}\nIf we expand the first block:\n\\begin{center}\n    $\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial \\mathbf{b}_{1,:}} & \\frac{\\partial L}{\\partial \\mathbf{b}_{2,:}} & \\hdots & \\frac{\\partial L}{\\partial \\mathbf{b}_{m,:}}\n    \\end{bmatrix} \\cdot\n    \\begin{bmatrix}\n     \\mathbf{x}_{1,:}  \\\\\n       \\vdots\\\\\n    \\textbf{0} \\\\\n     \\mathbf{x}_{2,:} \\\\\n      \\vdots\\\\\n     \\mathbf{x}_{m,:} \\\\\n    \\vdots\\\\\n    \\textbf{0} \\\\\n\\end{bmatrix}  = \\begin{bmatrix}\n \\frac{\\partial L}{\\partial b_{1,1}} \\cdot x_{1,1} + \\frac{\\partial L}{\\partial b_{2,1}} \\cdot x_{2,1} + \\hdots + \\frac{\\partial L}{\\partial b_{m,1}} \\cdot x_{m,1} \\\\\n \\frac{\\partial L}{\\partial b_{1,1}} \\cdot x_{1,2} + \\frac{\\partial L}{\\partial b_{2,1}} \\cdot x_{2,2} + \\hdots + \\frac{\\partial L}{\\partial b_{m,1}} \\cdot x_{m,2} \\\\\n \\vdots\\\\\n \\frac{\\partial L}{\\partial b_{1,1}} \\cdot x_{1,p} + \\frac{\\partial L}{\\partial b_{2,1}} \\cdot x_{2,p} + \\hdots + \\frac{\\partial L}{\\partial b_{m,1}} \\cdot x_{m,p} \n\\end{bmatrix}^T$\n\\end{center}\n\\begin{center}\n    $= (\\begin{bmatrix}\n  x_{1,1} &  x_{2,1} & \\hdots &  x_{m,1} \\\\\n  x_{1,2} &  x_{2,2} & \\hdots &  x_{m,2} \\\\\n \\vdots &\\vdots& \\ddots &\\vdots\\\\\n  x_{1,p} &  x_{2,p} & \\hdots &  x_{m,p} \n\\end{bmatrix} \\cdot \\begin{bmatrix}\n \\frac{\\partial L}{\\partial b_{1,1}} \\\\ \\frac{\\partial L}{\\partial b_{2,1}} \\\\ \\vdots \\\\ \\frac{\\partial L}{\\partial b_{m,1}}\n\\end{bmatrix})^T = (X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}})^T$\n\\end{center}\nIf we repeat for other blocks, we would get:\n\\begin{center}\n    $ -\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}} = \\begin{bmatrix}\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}} \\\\ \n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,2}} \\\\\n    \\vdots\\\\\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,p}}\n    \\end{bmatrix}^T$ or $ (-\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}})^T = \\begin{bmatrix}\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}} \\\\ \n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,2}} \\\\\n    \\vdots\\\\\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,p}}\n    \\end{bmatrix}$\n\\end{center}\nWe will make it vectorized by rolling it into a $n\\times p$ matrix:\n\\begin{center}\n    $roll((-\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}})^T) = -\\begin{bmatrix}\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}} & \n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,2}} &\n    \\hdots&\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,p}}\n    \\end{bmatrix}$\n\\end{center}\nFurther vectorization could be done:\n\\begin{center}\n    $-\\begin{bmatrix}\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}} & \n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,2}} &\n    \\hdots&\n    X^T \\cdot \\frac{\\partial L}{\\partial \\mathbf{b}_{:,p}}\n    \\end{bmatrix} = -X^T \\cdot \\begin{bmatrix}\n     \\frac{\\partial L}{\\partial \\mathbf{b}_{:,1}} & \n     \\frac{\\partial L}{\\partial \\mathbf{b}_{:,2}} &\n    \\hdots&\n     \\frac{\\partial L}{\\partial \\mathbf{b}_{:,p}}\n    \\end{bmatrix}$\n\\end{center}\n\\begin{equation}\n    = -X^T \\cdot \\frac{\\partial L}{\\partial B}\n\\end{equation}\nOf course, we need to keep in mind what $-X^T \\cdot \\frac{\\partial L}{\\partial B}$ actually represents:\n\\begin{center}\n    $roll((-\\frac{\\partial L}{\\partial \\mathbf{b}}^{T} J_{\\widehat{g}})^T) =  -(\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial b_{1,1}} & \\hdots &\\frac{\\partial L}{\\partial b_{1,p}}& \\frac{\\partial L}{\\partial b_{2,1}} & \\hdots & \\frac{\\partial L}{\\partial b_{m,p}}\n    \\end{bmatrix} \\cdot \\begin{bmatrix}\n    \\frac{\\partial b_{1,1}}{\\partial a_{1,1}} & \\frac{\\partial b_{1,1}}{\\partial a_{2,1}} &\\hdots &  \\frac{\\partial b_{1,1}}{\\partial a_{1,2}} &\\hdots & \\frac{\\partial b_{1,1}}{\\partial a_{n,p}} \\\\\n    \\frac{\\partial b_{1, 2}}{\\partial a_{1,1}}  & \\ddots &\\hdots & \\frac{\\partial b_{1,2}}{\\partial a_{1,2}}& \\hdots& \\vdots \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots & \\hdots & \\vdots\\\\\n    \\frac{\\partial b_{2,1}}{\\partial a_{1,1}} & \\vdots & \\vdots & \\ddots & \\hdots & \\vdots\\\\\n    \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\frac{\\partial b_{m,p}}{\\partial a_{1,1}}  & \\hdots & \\hdots & \\hdots & \\hdots & \\frac{\\partial b_{m,p}}{\\partial a_{n,p}}\n\\end{bmatrix})^T$\n\\end{center}\n\\begin{center}\n$=-roll(\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial a_{1,1}} & \\frac{\\partial L}{\\partial a_{2,1}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,1}} & \\frac{\\partial L}{\\partial a_{1,2}} & \\hdots& \\frac{\\partial L}{\\partial a_{n,p}}\n    \\end{bmatrix}^T)$\n\\end{center}\n\\begin{equation}\n=-\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial a_{1,1}} & \\frac{\\partial L}{\\partial a_{1,2}} & \\hdots & \\frac{\\partial L}{\\partial a_{1,p}} \\\\\n        \\frac{\\partial L}{\\partial a_{2,1}} & \\frac{\\partial L}{\\partial a_{2,2}} & \\hdots & \\frac{\\partial L}{\\partial a_{2,p}} \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial a_{n,1}} & \\frac{\\partial L}{\\partial a_{n,2}} & \\hdots & \\frac{\\partial L}{\\partial a_{n,p}} \n    \\end{bmatrix}\n\\end{equation}\n\\begin{center}\n    $ = -X^T \\cdot \\frac{\\partial L}{\\partial B}$\n\\end{center}\nSince the entries of $-X^T\\cdot \\frac{\\partial L}{\\partial B}$ matches $A$, Equation (31) is a good vectorized solution. Therefore:\n\\begin{center}\n    $vectorized(-\\frac{\\partial L}{\\partial \\mathbf{b}}^{T}  J_{\\widehat{g}}) = -X^T\\cdot \\frac{\\partial L}{\\partial B}$\n\\end{center}\nNow if we plug Equation (31) into our GCDE special case, and if we define:\n\\begin{center}\n    $\\frac{\\partial L}{\\partial W} = roll(\\frac{\\partial L}{\\partial \\mathbf{w}})=\\begin{bmatrix}\n        \\frac{\\partial L}{\\partial w_{1,1}} & \\frac{\\partial L}{\\partial w_{1,2}} & \\hdots &\\frac{\\partial L}{\\partial w_{1,q} } \\\\\n        \\frac{\\partial L}{\\partial w_{2,1}} & \\ddots & \\hdots &\\vdots \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots\\\\\n        \\frac{\\partial L}{\\partial w_{m,1}} & \\hdots & \\hdots &\\frac{\\partial L}{\\partial w_{m,q}}\n    \\end{bmatrix}$\n\\end{center}\nThen the vectorized Equation (23) is:\n\\begin{equation}\n vectorized(-\\frac{\\partial L}{\\partial \\mathbf{w}}^{T}  \\frac{\\partial \\widehat{f}(\\mathbf{h}(t), A, W)}{\\partial \\mathbf{w}}) = \n    -(AH(t))^T \\cdot (\\frac{\\partial L}{\\partial W} \\odot step(H(t)))\n\\end{equation}\n\\subsection{Summary}\nIn conclusion, we have found the vectorized adjoint dynamics for GCDE. Using the vectorized adjoint dynamics, we do not need to unroll the hidden states and parameters, and we could take the advantages of the in-memory matrices programmed on memristor crossbar.\n\\section*{Acknowledgement}\nI thank Louis Primeau for his thorough tutorial on multivariable calculus and matrix unrolling for Jacobian calculation. I thank Nafiseh Ghoroghchian for her guide on matrix differentiation and proofread of the work.\n\\bibliographystyle{alpha}\n\\bibliography{sample}\nNeural ODE: https://arxiv.org/pdf/1806.07366.pdf \\\\\nGCDE: https://arxiv.org/pdf/1911.07532.pdf \\\\\nGCN: https://arxiv.org/pdf/1609.02907.pdf \\\\\nMultivariable calculus crash course, Louis Primeau \\\\\nNeural ODE for Memristor Crossbar, Louis Primeau\n\\end{document}", "meta": {"hexsha": "ddac198bbe5aee85043e913e120ea0cf927a445b", "size": 50669, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "caixunshiren/Vectorized-Adjoint-Sensitivity-Method-for-Graph-Convolutional-Neural-ODE", "max_stars_repo_head_hexsha": "c606cf58c417c6921dfedf8ef43a4ad1df9c2ccb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "caixunshiren/Vectorized-Adjoint-Sensitivity-Method-for-Graph-Convolutional-Neural-ODE", "max_issues_repo_head_hexsha": "c606cf58c417c6921dfedf8ef43a4ad1df9c2ccb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "caixunshiren/Vectorized-Adjoint-Sensitivity-Method-for-Graph-Convolutional-Neural-ODE", "max_forks_repo_head_hexsha": "c606cf58c417c6921dfedf8ef43a4ad1df9c2ccb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.6808009423, "max_line_length": 794, "alphanum_fraction": 0.6086561803, "num_tokens": 19260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.43265775569025283}}
{"text": "\\section{Method}\nThe method is summarized in figure~\\ref{fig:workflow}. It consists of three main phases:\n\\begin{enumerate*}[(i)]\n\t\\item feature extraction,\n\t\\item classification, and\n\t\\item delineation of linear elements.\n\\end{enumerate*}\n%\\bigskip\n\\begin{figure}[!b]\n\t\\centering\n\t\\begin{tikzpicture}[node distance=0.70cm, scale=0.7, every node/.style={transform shape}]\n\t\n\t\\node (in1) [io] {Raw Point Cloud};\n\t\n\t\\node (param) [title, below=of in1] {Feature extraction};\n\t\\node (pro1) [process, below left=2.5cm and -1.6cm=of param, fill=darkorange!20] {Compute nearest neighbours};\n\t\\node (pro2) [process, below=of pro1, fill=darkorange!20] {Compute neighbourhood features};\n\t\n\t\\begin{scope}[on background layer]\n\t\\node (fit1) [fit=(param)(pro1)(pro2), inner sep=4pt, transform shape=false, draw=black!80, fill=darkorange, fill opacity=0.5] {};\n\t\\end{scope}\n\t\n\t\\node (out1) [io, above right=-0.55cm and 4.5cm=of fit1] {Point Cloud Features};\n\t\\node (in2) [io, right=of out1] {Manually Classified Point Cloud};\n\t\n\t\\node (class) [title, below right=1.5cm and 5.7cm=of out1] {Classification};\n\t\\node (pro4) [process, below left=2.5cm and -6.6cm=of class, fill=lightblue!20] {Remove irrelevant points};\n\t\\node (pro5) [process, below=of pro4, fill=lightblue!20] {Create random forest classifier using manually classified point cloud};\n\t\\node (pro6) [process, below=of pro5, fill=lightblue!20] {Assess performance using cross validation};\n\t\\node (pro7) [process, above right=-3.67cm and 7.5cm=of pro6, fill=lightblue!20] {Classify unknown points};\n\t\\node (pro8) [process, below=of pro7, fill=lightblue!20] {Compute cylindrical neighbourhoods of vegetation points};\n\t\\node (pro9) [process, below=of pro8, fill=lightblue!20] {Seperate trees from low vegetation using height difference};\n\t\n\t\\begin{scope}[on background layer]\n\t\\node (fit2) [fit=(class)(pro4)(pro5)(pro6)(pro7)(pro8)(pro9), inner sep=4pt, transform shape=false, draw=black!80, fill=lightblue, fill opacity=0.5] {};\n\t\\end{scope}\n\t\n\t\\node (out2) [io, above right= -0.55cm and 13.5cm=of fit2] {Classified Point Cloud};\n\t\n\t\\node (lin) [title, below=of out2] {Linear Elements};\n\t\\node (pro10) [process, below left=2.5cm and -15.6cm=of lin, fill=turquoise!20] {Convert to 2D and downsample};\n\t\\node (pro11) [process, below=of pro10, fill=turquoise!20] {Grow regions based on rectangularity};\n\t\\node (pro12) [process, below=of pro11, fill=turquoise!20] {Merge directionally aligned regions};\n\t\\node (pro13) [process, below=of pro12, fill=turquoise!20] {Assess the elongatedness of the regions};\n\t\n\t\\begin{scope}[on background layer]\n\t\\node (fit3) [fit=(lin)(pro10)(pro11)(pro12)(pro13), inner sep=4pt, transform shape=false, draw=black!80, fill=turquoise, fill opacity=0.5] {};\n\t\\end{scope}\n\t\n\t\\node (out3) [io, below=of fit3] {Linear vegetation elements};\n\t\n\t\\draw [arrow] (in1) -- (fit1);\n\t\\draw [arrow] (fit1) -| +(2.6,0) |- (out1.west);\n\t\\draw [arrow] (out1.south) |- +(0,-0.45) -| (fit2.north); %(out1.south|-fit2.north);\n\t\\draw [arrow] (fit2) -| +(4.5,0) |- (out2.west);\n\t\\draw [arrow] (out2) -- (fit3);\n\t\\draw [arrow] (in2.south) |- +(0,-0.195) -| (fit2.north); %(in2.south|-fit2.north);\n\t\n\t\\draw [arrow] (pro1) -- (pro2);\n\t\n\t\\draw [arrow] (pro4) -- (pro5);\n\t\\draw [arrow] (pro5) -- (pro6);\n\t\\draw [arrow] (pro5) -| +(2,0) |- (pro7);\n\t\\draw [arrow] (pro7) -- (pro8);\n\t\\draw [arrow] (pro8) -- (pro9);\n\t\n\t\\draw [arrow] (pro10) -- (pro11);\n\t\\draw [arrow] (pro11) -- (pro12);\n\t\\draw [arrow] (pro12) -- (pro13);\n\t\n\t\\draw [arrow] (fit3) -- (out3);\n\t\n\t\\end{tikzpicture}\n\t\\caption{Overview of the method in a work flow diagram.}\n\t\\label{fig:workflow}\n\\end{figure}\n\n\\subsection{Feature extraction}\nA point cloud \\(\\mathcal{P}\\) is a set of points \\(\\{p_{1}, p_{2}, \\dots, p_{n}\\}\\) \\(\\in \\mathbb{R}^3\\). Each point \\(p_{i}\\) consists of the X, Y and Z coordinates of the point and additional information on the intensity (\\(I\\)) of the return signal, the return number, and the number of returns (\\(R_{t}\\)) at \\(p_{i}\\) is known (figure~\\ref{fig:LiDAR}).\nA normalized return number (\\(R_{n}\\)) was calculated by dividing the return number by the number of returns~\\citep{guo2011relevance}.\n\nFor each point \\(p_{i}\\) a neighbourhood set \\(\\mathcal{N}_{i}\\) of points \\(\\{q_{1}, q_{2}, \\dots, q_{k}\\}\\) is defined, where \\(q_{1} = p_{i}\\). \n%This can be done in three ways:\n%\\begin{enumerate*}[(i)]\n%\t\\item a \\(k\\)-nearest neighbours neighbourhood, where the first \\(k\\ (-1)\\) nearest points to \\(p_{i}\\) are part of the neighbourhood,\n%\t\\item a spherical neighbourhood, where all the points within a certain radius (\\(r_{s}\\)) of \\(p_{i}\\) belong to the neighbourhood, and\n%\t\\item a cylindrical neighbourhood, which includes all points within a cylinder with infinite height and a certain radius (\\(r_{c}\\)) of \\(p_{i}\\).\n%\\end{enumerate*}\nThis neighbourhood was determined using a \\(k\\)-nearest neighbours method with a \\(k\\) of 50. This method was used instead of spherical neighbourhood of a certain radius, because it is harder to define a suitable radius which works for fluctuating point densities within and across datasets~\\citep{weinmann2014semantic}.\n\nTo determine these neighbours a k-d tree data structure was constructed, which is a multidimensional binary search tree that can be used for efficient nearest neighbour searches~\\citep{bentley1975kdtree}.\n\nFor each neighbourhood some basic geometric properties are computed \\citep{weinmann2015semantic}:\n\n{\\setlength{\\abovedisplayskip}{0pt}\n\\begin{flalign}\n\t\\label{eq:deltaz}\n\t&\\text{Height difference:}&&& \\Delta_{Z_{i}} &= \\max_{j:\\mathcal{N}_{i}}(q_{Z_{j}}) - \\min_{j:\\mathcal{N}_{i}}(q_{Z_{j}}) &&&\\\\\n\t\\label{eq:stdz}\n\t&\\text{Height standard deviation:}&&& \\sigma_{Z_{i}} &= \\sqrt{\\frac{1}{k} \\sum_{j=1}^k (q_{Z_{j}} - \\overline{q_{Z}})^2} &&&\\\\\n\t\\label{eq:radius}\n\t&\\text{Local radius:}&&& r_{l_{i}} &= \\max_{j: \\mathcal{N}_{i}}(|p_{i} - q_{j}|) &&&\\\\\n\t\\label{eq:density}\n\t&\\text{Local point density:}&&& D_{i} &= \\frac{k}{\\frac{4}{3} \\pi r_{l_{i}}^3} &&&\n\\end{flalign}\n\nAdditionally the neighbourhood of a point can be used to characterize local surface features as first described by~\\citet{hoppe1992surface}, and further developed by~\\citet{pauly2002efficient}, who used the local structure tensor to estimate the surface normals (the vector perpendicular to the surface (\\(\\vec{N} = (N_{x}, N_{y}, N_{z})\\))) and to define the surface variation (equation~\\ref{eq:surfacevariation}). The structure tensor describes the directions of the neighbourhood of a point by determining the covariance matrix of the X, Y and Z coordinates of the points and computing the eigenvalues (\\(\\lambda_{1}, \\lambda_{2}, \\lambda_{3}\\), where \\(\\lambda_{1} > \\lambda_{2} > \\lambda_{3}\\)) and eigenvectors of this matrix. The magnitude of the eigenvalues of this covariance matrix describe the spread of points in the direction of the eigenvector. By ranking the eigenvectors based on the respective eigenvalues the spread in the three principle directions of a local point cloud can be quantified. This was expanded upon by~\\citet{west2004context} to the following eight structure tensor features:\n\n\\begin{flalign}\n\\label{eq:linearity}\n&\\text{Linearity: }&&& L_{\\lambda} &= \\frac{\\lambda_{1} - \\lambda_{2}}{\\lambda_{1}}&&&\\\\\n\\label{eq:planarity}\n&\\text{Planarity: }&&& P_{\\lambda} &= \\frac{\\lambda_{2} - \\lambda_{3}}{\\lambda_{1}}&&&\\\\\n\\label{eq:sphericity}\n&\\text{Sphericity: }&&& S_{\\lambda} &= \\frac{\\lambda_{3}}{\\lambda_{1}}&&&\\\\\n\\label{eq:omnivariance}\n&\\text{Omnivariance: }&&& O_{\\lambda} &= \\sqrt[3]{\\lambda_{1} \\lambda_{2} \\lambda_{3}}&&&\\\\\n\\label{eq:anisotropy}\n&\\text{Anisotropy: }&&& A_{\\lambda} &= \\frac{\\lambda_{1} - \\lambda_{3}}{\\lambda_{1}}&&&\\\\\n\\label{eq:eigenentropy}\n&\\text{Eigenentropy: }&&& E_{\\lambda} &= -\\lambda_{1}\\ln(\\lambda_{1}) -\\lambda_{2}\\ln(\\lambda_{2}) -\\lambda_{3}\\ln(\\lambda_{3})&&&\\\\\n\\label{eq:sumofeigenvalues}\n&\\text{Sum of eigenvalues: }&&& \\sum_{\\lambda} &= \\lambda_{1} + \\lambda_{2} + \\lambda_{3}&&&\\\\\n\\label{eq:surfacevariation}\n&\\text{Local surface variation: }&&& C_{\\lambda} &= \\frac{\\lambda_{3}}{\\lambda_{1} + \\lambda_{2} + \\lambda_{3}}&&&\n\\end{flalign}\n\nTo avoid using an unnecessarily large feature set the correlation between all the features was checked by calculating pearson coefficients. Of the pairs of two extremely correlated features (above 0.98), one was removed. This resulted in the removal of anisotropy, which is negatively correlated with sphericity, and eigenentropy, which is correlated with omnivariance.\n\nConsequently the resulting feature set used for the classification was \\(\\{I, R_{t}, R_{n}, \\Delta_{Z}, \\sigma_{Z}, r_{l}, D, N_{z}, L_{\\lambda}, P_{\\lambda}, S_{\\lambda}, O_{\\lambda}, \\sum_{\\lambda}, C_{\\lambda}\\}\\).\n\n\\subsection{Classification}\n\\label{sec:class}\nSince the linear vegetation elements consist of either trees or low vegetation (shrubs and small trees) the point cloud needs to be classified into \\textit{trees}, \\textit{low vegetation}, and \\textit{irrelevant} points. The difference between trees and low vegetation is ambiguous and is dependent on interpretation. In previous research this boundary has been set at varying height values, ranging from 1.5~\\citep{bork2007integrating}, to 3.5~\\citep{antonarakis2008object}, to 4~\\citep{koukoulas2005spatial}, to 5 meters~\\citep{khosravipour2014generating}. We set this boundary at 4m. The irrelevant points are returns of which the linearity does not need to be checked. This may include very low vegetation (herbs), bare ground, water, buildings, and other man made objects.\n\n\\subsubsection{Data trimming}\nTo speed up the classification first points were removed which were certain not relevant. This was done based on the planarity (equation~\\ref{eq:planarity}) and sphericity (equation~\\ref{eq:sphericity}) features discussed earlier. Since scanning vegetation (which is larger than herbs) always results in a locally very scattered point cloud, with points spread out throughout the 3D space, points with a locally planar neighbourhood can be removed. That is to say points with a high planarity value, \\(P_{\\lambda} > 0.7\\), and a low sphericity value, \\(S_{\\lambda} < 0.05\\), were removed. These values were manually selected in a conservative way to make sure every point removed was certainly not relevant, while still removing a large portion of points.\n \n\\subsubsection{Supervised classification}\nThe remaining point cloud was classified into \\textit{vegetation} and \\textit{irrelevant} using a random forest classifier. The random forest algorithm creates a collection of decision trees each based on a random subset of the training data~\\citep{ho1998random}. These decision trees are computed by a Classification And Regression Tree (CART) algorithm, which creates splits that minimize a gini impurity index~\\citep{breiman1984classification}. This impurity index is the probability a randomly picked sample would be misclassified, given it was randomly classified conform the distribution of classes. For each point, each tree in the forest determines a class, and the class which gets selected by the majority of the trees is chosen as the final classification~\\citep{breiman2001random}.\n\nTraining and testing data was created by analysing the research area and manually segmenting areas of \\textit{vegetation} and \\textit{irrelevant}. This was done based on the point cloud and aerial photos~\\citep{PDOK2015luchtfoto}. \n\nBecause the point cloud is trimmed based on planarity/sphericity and it concerns an agricultural landscape it has become very imbalanced, having a lot more \\textit{vegetation} than \\textit{irrelevant} points, which was also very noticeable in the training and testing data. Imbalanced training data can lead to undesirable classification results~\\citep{he2009learning}. Therefore a balanced random forest was used, where instead of the decision trees being made using bootstrap samples of the entire training dataset, a bootstrap sample was taken from only the minority class and a random sample was taken of the majority class based on the size of the minority class sample~\\citep{Chen2004using}. Employing enough trees eventually all majority class data gets used, while still maintaining a balance between the two classes. The size of the majority sample compared to the minority sample can be adjusted to find the best balance.\n\nThe random forest parameters (i.e. maximum depth, maximum number of features, minimal samples per leaf, minimal samples per split) and the ratio between minority and majority samples were optimized using a cross validated grid search.\n\n\\subsubsection{Accuracy Assessment}\n\nTo assess the accuracy of the classification a confusion matrix was used. Such a matrix shows the predicted and the actual classes of the tested pixels/points. It gives an overview of the performance of the classification in that it identifies and quantifies the errors. Using this matrix a precision (user's accuracy), recall (producer's accuracy), and overall accuracy can be calculated~\\citep{stehman1997selecting}, but these metrics are unable to provide a good picture of the performance of a classifier when the data is very imbalanced.\n\nInstead, three metrics, which provide a useful indication of performance even when dealing with a very imbalanced dataset, were used~\\citep{sun2009classification, lopez2013insight}. These are:\n\\begin{enumerate*}[(i)]\n\t\\item the receiver operating characteristic (ROC) curve~\\citep{bradley1997use},\n\t\\item the Matthew's correlation coefficient (MCC)~\\citep{matthews1975comparison}, and\n\t\\item the geometric mean~\\citep{kubat1998machine}.\n\\end{enumerate*}\n\nTo create a ROC-curve the true positive rate is plotted against the false positive rate at various decision thresholds. The area under a ROC-curve (AUC) is a measure for the performance of the classifier~\\citep{bradley1997use}.\n\nThe MCC analyses the correlation between the observed and the predicted data and is defined as follows:\n\n\\begin{equation}\n\t\\label{eq:MCC}\n\t{\\text{MCC}}={\\frac  {TP\\times TN-FP\\times FN}{{\\sqrt  {(TP+FP)(TP+FN)(TN+FP)(TN+FN)}}}}\n\\end{equation}\n\nwhere TP are the true positives, TN the true negatives, FP the false positives, and FN the false negatives. It often gives a more balanced evaluation of a classifier than the precision, recall and accuracy~\\citep{baldi2000assessing} and it is an effective metric for unbalanced datasets~\\citep{kohavi1995study}.\n\nThe geometric mean of the recall of both classes evaluates the balanced performance of the classifier for the two classes~\\citep{kubat1998machine, sun2009classification}.\n\nThese scores were acquired by performing a 10-fold cross validation. This is done by splitting the data into 10 randomly mutually exclusive subsets and using a subset as testing data on a classifier trained on the remaining data~\\citep{kohavi1995study}. This method is effective against overfitting and does not further reduce the training data (which a test and validation set would).\n\nTo assess which features are most influential when separating vegetation from non-vegetation a feature importance analysis was performed. This is done by summing the decreases in gini impurity due to a feature in all the trees divided by the total amount of trees~\\citep{breiman2002manual}.\n\n\\subsubsection{Delineating trees and low vegetation}\nTo divide the vegetation class into \\textit{tree} and \\textit{low vegetation} for each point a cylindrical neighbourhood was determined, which includes all points within a cylinder with infinite height and a radius of 2 meters. Within this neighbourhood the height difference (equation~\\ref{eq:deltaz}) was computed. As mentioned earlier, if this value exceeded 4 meters the point was classified as a \\textit{tree} point, otherwise as a \\textit{low vegetation} point.\n\n\\subsection{Delineating Linear Elements}\nTo delineate linear from non-linear vegetation elements the two classes were segmented into rectangular objects, since those can be assessed for linearity by their length and width. This is done by growing regions within the relevant points as long as the shape remains rectangular. \n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[scale=0.40]{./img/downsample}\n\t\\caption{An example showing the tree points before and after downsampling.}\n\t\\label{fig:downsample}\n\\end{figure}\nSince the linearity of an object is solely determined by the 2D spatial distribution of points, the point cloud was converted to 2D by removing the Z-coordinate from all the points. To speed up the computation the 2D point cloud was spatially downsampled to 1 meter distance between all points for low vegetation and 2 meter for trees (figure~\\ref{fig:downsample}). Low vegetation objects are often smaller than trees and consequently require more points for an accurate delineation. This leads to a slightly less precise delineation, but results in a substantially decreased computation time.\n\n\\subsubsection{Rectangularity}\n\\begin{figure}\n\t\\centering\n\t\\input{./img/hulls.tikz}\n\t\\caption{An example showing the different hulls used for determining the rectangularity.}\n\t\\label{fig:hulls}\n\\end{figure}\nThe rectangularity of an object can be described as the ratio between the area of an object and the area of its minimum bounding rectangle~\\citep{rosin1999measuring}.\n\nThe minimum bounding rectangle (figure~\\ref{fig:hulls}) is computed with rotating calipers as described by~\\citet{toussaint1983solving}. First a convex hull is determined for the points, which is the smallest convex set of points which contains every point (figure~\\ref{fig:hulls}), by using the QuickHull algorithm as defined by~\\citet{preparata1985computational}. The minimum bounding rectangle has a side collinear with one of the edges of the convex hull~\\citep{freeman1975determining}. Consequently while rotating by the angles of the edges rectangles can be created using the minima and maxima of the coordinates in the rotated system. Keeping track of the rectangle with the minimal area the minimum bounding rectangle can be found.\n\nThe area of the object can be found by computing an alpha shape of the set of points belonging to the object~\\citep{edelsbrunner1983shape}. An alpha shape is a hull, similar to a convex hull, which describes the shape of a set of points (figure~\\ref{fig:hulls}). It is created by computing a Delaunay triangulation of the points~\\citep{delaunay1934sphere} and removing the triangles with a circumradius higher than \\(1/\\alpha\\), where \\(\\alpha\\) is a parameter which consequently influences the amount of triangles removed from the triangulation and thus the shape and area of the alpha shape. Higher alphas lead to more complex shapes, while lower ones to more smooth shapes (figure~\\ref{fig:hulls}).\n\n\\subsubsection{Region Growing}\nTo segment the point cloud into rectangular objects a region growing segmentation technique was used. This method was introduced by \\citet{besl1988segmentation} and has since been an effective approach to segment a point cloud~\\citep{tovari2005segmentation, rabbani2006segmentation, nurunnabi2012robust, vosselman2013point, elberink2014user, vo2015octree}. The region growing method consists of two main steps: seed selection and region growing. The seed locations can be selected randomly or based on some properties of the points. The growing is based on a similarity criterion based on the proximity and attributes of the points.\n\nThe region growing used in this method is a bit different. Instead of using the attributes to compare the points and grow based on some similarity criteria, the regions are grown based only on proximity and a constraint of rectangularity (figure~\\ref{fig:regiongrowing}). The seed selection is done based on the coordinates to minimize the chances of starting at boundary regions.\n\n\\begin{figure}\n\t\\centering\n\t\\input{./img/regiongrowing.tikz}\n\t\\caption{An example showing the region growing process.}\n\t\\label{fig:regiongrowing}\n\\end{figure}\n\nThus the point with the minimal x-coordinate and its 20 closest neighbours were used as the starting region (given this region is rectangular, otherwise the point is discarded and the process repeated) and subsequently points were added as long as the region’s rectangularity did not drop below a threshold of 0.55. This threshold was determined by experimentation and manual evaluation. Once no more new points could be added to the region the procedure was repeated for the next region until all the points are checked.\n\n\\subsubsection{Merging Objects}\nThe objects can still be quite fragmented after they have been grown, especially for curved regions. To fix this, objects were merged which were\n\\begin{enumerate*}[(i)]\n\t\\item in proximity of each other,\n\t\\item aligned with each other, and\n\t\\item facing about the same direction.\n\\end{enumerate*}\nThe direction was determined by computing the angle between one of the long sides of the minimum bounding box and the x-axis. The alignment was checked by comparing the angle of the line between the two centre points of the objects with the directions. Once merged the lengths of the objects were added and the maximum of the widths taken as the new width.\n\n\\subsubsection{Elongatedness}\nThe resulting rectangular regions were assessed for linearity by determining the elongatedness of an object, which is defined as the ratio between its length and its width~\\citep{nagao2013structural}. \n\nThe minimum elongatedness of objects was set at 2.5, based on a manual trial and error. To prevent long, but wide patches of forest to be classified as linear elements a maximum width of 60 meters was used.\n\n\\subsubsection{Accuracy Assesment}\nTo assess the accuracy of the delineation of linear objects a manual delineation was done. First a polygon was made both from the tree and low vegetation points using alpha shapes. Subsequently the two polygons were manually further segmented into objects. Finally the polygons belonging to a linear object according to our interpretation were manually marked as being linear. The resulting map was compared with the automated delineation. This was done by a difference map and confusion matrices where we compared the true positive, true negative, false positive and false negative in area. Since this data is, unlike before, not very imbalanced we can use traditional metrics for accuracy. Therefore a user's, producer's and overall accuracy was calculated, as well as an F1, kappa and MCC score~\\citep{congalton2008assessing}.\n\n\\subsection{Software \\& Hardware}\nWe chose to use solely free and open source software (FOSS), for two main reasons:\n\\begin{enumerate*}[(i)]\n\t\\item to avoid `black boxes', where it is unclear exactly what calculations or algorithms are being used to produce the results, and\n\t\\item to make the method more easily runnable with cloud- or supercomputing solutions, and thus able to compute for very large areas.\n\\end{enumerate*}\n\nThe large majority was made in Python (2.7.12) with the NumPy~(1.11.2), SciPy~(0.18.1), pandas~(0.18.1), scikit-learn~(0.17.1) and Shapely~(1.5.13) libraries. For the preprocessing of data LASTools~(version~160429) and CloudCompare~(v2.8) were used and Cloudcompare was also used for visualizing and downsampling the point cloud.\n\nFor the computation a desktop computer was used with an Intel Xeon E3-1220 3.1 GHz quad-core processor and 16GB of RAM.\n", "meta": {"hexsha": "642b2ede0bf02f350fbba469d7c253336d9aa5ea", "size": 23268, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/tex/method.tex", "max_stars_repo_name": "huhongjun/delineating-linear-elements", "max_stars_repo_head_hexsha": "dd0328acf52a1c3913b8848e83cacacaf23841d9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/tex/method.tex", "max_issues_repo_name": "huhongjun/delineating-linear-elements", "max_issues_repo_head_hexsha": "dd0328acf52a1c3913b8848e83cacacaf23841d9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/tex/method.tex", "max_forks_repo_name": "huhongjun/delineating-linear-elements", "max_forks_repo_head_hexsha": "dd0328acf52a1c3913b8848e83cacacaf23841d9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.3606557377, "max_line_length": 1109, "alphanum_fraction": 0.7655148702, "num_tokens": 6203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4326577510100533}}
{"text": "\\thispagestyle{empty}\r\n%----------------------------------------------------------------------\r\n\\chapter{Control and optimization}\r\n\\label{control.chap}\r\n%----------------------------------------------------------------------\r\n\r\n\\section{Objectives}\r\n%----------------------------------------------------------------------\r\nOnce a system has been enough understood, there is still to do the main work: enhance it. This means most of the time optimization, and control can be seen as an online optimization (i. e. continuously making the system better). There are several control techniques as there are many optimization techniques. Since this reader aims at keeping things practical, we will not develop all possible ideas here. Instead we insist onto 2 main ideas:\r\n\\begin{enumerate}\r\n\t\\item explicit a criteria to be optimized: in principle, this is rooted in the system description and what we want to do with the system. There are many ways to enhance a system, and very often the models are too complicated to have an explicit optimum (whenever they have one). But without criteria, there is even no way to know what is better (or worse).\r\n\t\\item simplify the model so that the optimization (or control) problem can be solved by simple tools. As a rule, it is often better to get a simple but efficient control rather than to try to compute the optimal one. This rules also holds for optimization: the best is the enemy of the good; well enough is enough in lots of practical systems.\r\n\\end{enumerate}\r\n\r\nTherefore some tools for PDE are applied in the next sections as well as simple tools that can be applied by smartly simplifying the problem.\r\n\r\n\\section{Tools and examples}\r\n\r\n\\subsection{Kalman filter}\r\n\\input{control-kalman}\r\n\r\n\\subsection{PID control}\r\n\r\n\\subsection{Adjoint optimization}\r\n\r\n", "meta": {"hexsha": "10923d545408bb10b931d0cb4361bbd0a476f8ca", "size": 1807, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "control.tex", "max_stars_repo_name": "QinganZhao/Course-Support-for-CE-291F-Control-and-Optimization-of-Distributed-Parameters-Systems", "max_stars_repo_head_hexsha": "3bbe532eab793efa6c3a3a4569d155dd39c0102c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-01-08T02:54:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-29T06:19:28.000Z", "max_issues_repo_path": "control.tex", "max_issues_repo_name": "QinganZhao/Course-Support-for-CE-291F-Control-and-Optimization-of-Distributed-Parameters-Systems", "max_issues_repo_head_hexsha": "3bbe532eab793efa6c3a3a4569d155dd39c0102c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "control.tex", "max_forks_repo_name": "QinganZhao/Course-Support-for-CE-291F-Control-and-Optimization-of-Distributed-Parameters-Systems", "max_forks_repo_head_hexsha": "3bbe532eab793efa6c3a3a4569d155dd39c0102c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-16T17:29:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-16T17:29:03.000Z", "avg_line_length": 69.5, "max_line_length": 443, "alphanum_fraction": 0.6873270614, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.4326577421931178}}
{"text": "\\chapter{Basic Concepts}\n\\label{Chp:Concepts}\n\nThe GraphBLAS C API is used to construct  \ngraph algorithms expressed ``in the language of linear algebra.''\nGraphs are expressed as matrices, and the operations over \nthese matrices are generalized through the use of a\nsemiring algebraic structure.\n\nIn this chapter, we will define the basic concepts used to\ndefine the GraphBLAS C API.  We provide the following elements:\n\\begin{itemize}\n\\item Glossary of terms used in this document.  \n\n\\item Notation\n\n\\item Execution model\n\n\\item Error model\n\n\\end{itemize}\n\n\\section{Glossary}\n\n%TGM I'm leaving a few definitions in here just as examples\n\n\\subsection{Basic definitions}\n\n\\glossBegin\n\n\\glossItem{application} A program that calls methods from the GraphBLAS C API to\nsolve a problem.\n\n\\glossItem{GraphBLAS C API} The application programming interface that fully defines the types, objects, \nliterals, and other elements of the C binding to the GraphBLAS.\n\n\\glossEnd\n\n\\subsection{Objects and their structure}\n\n\\glossBegin\n\\glossItem{handle}  A variable that uses one of the GraphBLAS opaque data types.\nThe value of this variable holds a reference to a GraphBLAS object but not the contents of the object itself.\nHence, assigning a value of one handle to another variable copies the reference to the GraphBLAS object\nbut not the contents of the object.\n\n\\glossItem{non-opaque datatype} Any datatype that exposes its internal structure.   \nThis is contrasted\nwith an \\emph{opaque datatype} that hides its internal structure and can\nbe manipulated only through an API.\n\n\\glossEnd\n\n\n\n\\vfill\n\n\\newgeometry{left=2.5cm,top=2cm,bottom=2cm}\n\n\\section{Notation}\n\n\\begin{tabular}[H]{l|p{5in}}\nNotation & Description \\\\\n\\hline\n$\\Dout, \\Dinn, \\Din1, \\Din2$  & Refers to output and input domains of various GraphBLAS operators. \\\\\n$\\bDout(*), \\bDinn(*),$ & Evaluates to output and input domains of GraphBLAS operators (usually \\\\\n~~~~$\\bDin1(*), \\bDin2(*)$ & a unary or binary operator, or semiring). \\\\\n$\\mathbf{D}(*)$   & Evaluates to the (only) domain of a GraphBLAS object (usually a monoid, vector, or matrix). \\\\ \n$f$             & An arbitrary unary function, usually a component of a unary operator. \\\\\n$\\mathbf{f}(F_u)$ & Evaluates to the unary function contained in the unary operator given as the argument. \\\\\n$\\odot$         & An arbitrary binary function, usually a component of a binary operator. \\\\\n$\\mathbf{\\bigodot}(*)$ & Evaluates to the binary function contained in the binary operator or monoid given as the argument. \\\\\n$\\otimes$       & Multiplicative binary operator of a semiring. \\\\\n$\\oplus$        & Additive binary operator of a semiring. \\\\\n$\\mathbf{\\bigotimes}(S)$ & Evaluates to the multiplicative binary operator of the semiring given as the argument. \\\\\n$\\mathbf{\\bigoplus}(S)$ & Evaluates to the additive binary operator of the semiring given as the argument. \\\\\n$\\mathbf{0}(*)$   & The identity of a monoid, or the additive identity of a GraphBLAS semiring. \\\\\n$\\mathbf{L}(*)$   & The contents (all stored values) of the vector or matrix GraphBLAS objects.  For a vector, it is the set of (index, value) pairs, and for a matrix it is the set of (row, col, value) triples. \\\\\n$\\mathbf{v}(i)$ or $v_i$   & The $i^{th}$ element of the vector $\\vector{v}$.\\\\\n$\\mathbf{size}(\\vector{v})$ & The size of the vector $\\vector{v}$.\\\\\n$\\mathbf{ind}(\\vector{v})$ & The set of indices corresponding to the stored values of the vector $\\vector{v}$.\\\\\n$\\mathbf{nrows}(\\vector{A})$ & The number of rows in the $\\matrix{A}$.\\\\\n$\\mathbf{ncols}(\\vector{A})$ & The number of columns in the $\\matrix{A}$.\\\\\n$\\mathbf{indrow}(\\vector{A})$ & The set of row indices corresponding to rows in $\\matrix{A}$ that have stored values.  \\\\\n$\\mathbf{indcol}(\\vector{A})$ & The set of column indices corresponding to columns in $\\matrix{A}$ that have stored values. \\\\\n$\\mathbf{ind}(\\vector{A})$ & The set of $(i,j)$ indices corresponding to the stored values of the matrix. \\\\\n$\\mathbf{A}(i,j)$ or $A_{ij}$ & The element of $\\matrix{A}$ with row index $i$ and column index $j$.\\\\\n$\\matrix{A}(:,j)$ & The $j^{th}$ column of the the matrix $\\matrix{A}$.\\\\\n$\\matrix{A}(i,:)$ & The $i^{th}$ row of the the matrix $\\matrix{A}$.\\\\\n$\\matrix{A}^T$ &The transpose of the matrix $\\matrix{A}$. \\\\\n$\\neg\\matrix{M}$ & The complement of $\\matrix{M}$.\\\\\n$\\vector{\\widetilde{t}}$ & A temporary object created  by the GraphBLAS implementation. \\\\\n$<type>$ & A method argument type that is {\\sf void *} or one of the types from Table~\\ref{Tab:PredefinedTypes}. \\\\\n{\\sf GrB\\_ALL} & A method argument literal to indicate that all indices of an input array should be used.\\\\\n{\\sf GrB\\_Type} & A method argument type that is either a user defined type or one of the  types from Table~\\ref{Tab:PredefinedTypes}.\\\\\n{\\sf GrB\\_Object} &  A method argument type referencing any of the GraphBLAS object types.\\\\\n{\\sf GrB\\_NULL} & The GraphBLAS NULL.\\\\\n\\end{tabular}\n\n\\restoregeometry\n\n\\section{Error model}\n\n\n\n\\section{Execution Model}\n\\label{Sec:ExecutionModel}\n\n%% TGM: I've left the GraphBLAS model here just as a point of reference.\n\nA program using the GraphBLAS C API constructs GraphBLAS objects,\nmanipulates them to implement a graph algorithm, and then extracts\nvalues from the GraphBLAS objects as the result of the algorithm.\nFunctions defined within the GraphBLAS C API that manipulate GraphBLAS\nobjects are called \\emph{methods}.  If the method corresponds to one\nof the operations defined in the GraphBLAS mathematical specification,\nwe refer to the method as an \\emph{operation}.\n\nGraph algorithms are expressed as an ordered collection of GraphBLAS\nmethod calls defined by the order they are encountered in a program.\nThis is called the \\emph{program order}.  Each method in the collection\nuniquely and unambiguously defines the output GraphBLAS objects based\non the GraphBLAS operation and the input GraphBLAS objects. This is the\ncase as long as there are no execution errors, which can put objects in\nan invalid state (see Section~\\ref{Sec:ErrorModel}).\n\nThe GraphBLAS method calls in program order are organized into contiguous\nand nonoverlapping \\emph{sequences}.  A sequence is an ordered collection\nof method calls as encountered by an executing thread. (For more on\nthreads and GraphBLAS, see Section~\\ref{Sec:ThreadSafety}.)  A sequence\nbegins with either (1) the first GraphBLAS method called by a thread,\nor (2) the first method called by a thread after the end of the\nprevious sequence.  A sequence can end (terminate) in a variety of ways.\nA call to the GraphBLAS {\\sf GrB\\_wait()} method (Section~\\ref{Sec:GrB_wait})\nalways ends a sequence.  The GraphBLAS {\\sf GrB\\_finalize()} method\n(Section~\\ref{Sec:GrB_finalize}) also implicitly ends a sequence. Finally,\nin blocking mode (see below), each GraphBLAS method starts and ends its\nown sequence.\n\nThe GraphBLAS objects are fully defined at any point in a sequence by\nthe methods in the sequence as long as there are no execution errors.\nIn particular, as soon as a GraphBLAS method call returns, its output\ncan be used in the next GraphBLAS method call.  However, individual\noperations in a sequence may not be \\emph{complete}. We say that an\noperation is complete when all the computations in the operation have\nfinished and all the values of its output object have been produced and\ncommitted to the address space of the program. Furthermore, no additional\nexecution time can be charged to a completed operation and no additional\nerrors can be attributed to a completed operation.\n\nThe opaqueness of GraphBLAS objects allows execution to proceed\nfrom one method to the next even when operations are not complete.\nProcessing of nonopaque objects is never deferred in GraphBLAS. That is,\nmethods that consume nonopaque objects (\\eg, {\\sf GrB\\_Matrix\\_build()},\nSection~\\ref{Sec:Matrix_build}) and methods that produce nonopaque objects (\\eg,\n{\\sf GrB\\_Matrix\\_extractTuples()}, Section~\\ref{Sec:Matrix_extractTuples})\nalways finish consuming or producing those nonopaque objects before\nreturning.   \n\n\\comment{Furthermore, methods that extract values from opaque GraphBLAS objects\ninto nonopaque user objects (see Table~\\ref{Tab:ExtractMethods})\nalways force completion of all pending computations on the \ncorresponding GraphBLAS source object.\n\n\\begin{table}[htb]\n    \\hrule\n    \\begin{center}\n        \\caption{Methods that extract values from a GraphBLAS object, thereby\n        forcing completion of the operations contributing to that particular object.}\n        \\label{Tab:ExtractMethods}\n\n        \\begin{tabular}{l|l}\n            Method    & Section \\\\ \\hline\n\n            {\\sf GrB\\_Vector\\_nvals}        & \\ref{Sec:Vector_nvals}        \\\\\n            {\\sf GrB\\_Vector\\_extractElement}     & \\ref{Sec:extract_single_element_vec}    \\\\\n            {\\sf GrB\\_Vector\\_extractTuples}    & \\ref{Sec:Vector_extractTuples}    \\\\\n            {\\sf GrB\\_Matrix\\_nvals}        & \\ref{Sec:Matrix_nvals}        \\\\\n            {\\sf GrB\\_Matrix\\_extractElement}     & \\ref{Sec:extract_single_element_mat}    \\\\\n            {\\sf GrB\\_Matrix\\_extractTuples}    & \\ref{Sec:Matrix_extractTuples}    \\\\\n            {\\sf GrB\\_reduce} (vector-scalar variant)        & \\ref{Sec:Reduce_vector_scalar}        \\\\\n            {\\sf GrB\\_reduce} (matrix-scalar variant)        & \\ref{Sec:Reduce_matrix_scalar}        \\\\\n        \\end{tabular}\n    \\end{center}\n    \\hrule\n\\end{table}\n}\n\n\n\\section{Error Model}\n\\label{Sec:ErrorModel}\n\n%%TGM  I've left the GraphBLAS model here as a point of reference\n\nAll GraphBLAS methods return a value of type {\\sf GrB\\_Info} to provide\ninformation available to the system at the time the method returns. The\nreturned value can be either {\\sf GrB\\_SUCCESS} or one of the defined\nerror values shown in Table~\\ref{Tab:ErrorValues}. The errors fall into\ntwo groups: API errors (Table~\\ref{Tab:ErrorValues}(a)) and execution\nerrors (Table~\\ref{Tab:ErrorValues}(b)).\n\n\\begin{table}[bh]\n\\hrule\n\\begin{center}\n\\caption{Error values returned by GraphBLAS methods.}\n\\label{Tab:ErrorValues}\n\n\\vspace{1\\baselineskip}\n(a) API errors\n\\vspace{1\\baselineskip}\n\n\\begin{tabular}{l|p{3in}}\nError code    & Description \\\\ \\hline\n{\\sf GrB\\_UNINITIALIZED\\_OBJECT} & A GraphBLAS object is passed to a method before {\\sf new} was called on it.\\\\\n{\\sf GrB\\_NULL\\_POINTER} & A NULL is passed for a pointer parameter. \\\\\n{\\sf GrB\\_INVALID\\_VALUE} & Miscellaneous incorrect values. \\\\\n{\\sf GrB\\_INVALID\\_INDEX} & Indices passed are larger than dimensions of the matrix or vector being accessed. \\\\\n{\\sf GrB\\_DOMAIN\\_MISMATCH} & A mismatch between domains of collections and operations when user-defined domains are in use.\\\\\n{\\sf GrB\\_DIMENSION\\_MISMATCH} & Operations on matrices and vectors with incompatible dimensions. \\\\\n{\\sf GrB\\_OUTPUT\\_NOT\\_EMPTY} & An attempt was made to build a matrix or vector using an output object that already contains valid tuples (elements).\\\\\n%{\\sf GrB\\_NO\\_VALUE} & An attempt was made to extract a value from a tuple within a matrix or vector for which there is no stored value. \n{\\sf GrB\\_NO\\_VALUE} & A location in a matrix or vector is being accessed that has no stored value at the specified location. \\scott{It depends on whether or not the non-opaque scalar is\nwell-defined on return from {\\sf extract}}\\\\\n\\end{tabular}\n\n\\vspace{1\\baselineskip}\n(b) Execution errors\n\\vspace{1\\baselineskip}\n\n\\begin{tabular}{l|p{3in}}\nError code    & Description \\\\ \\hline\n{\\sf GrB\\_OUT\\_OF\\_MEMORY}         & Not enough memory for operations. \\\\\n{\\sf GrB\\_INSUFFICIENT\\_SPACE}     & The array provided is not large enough to hold output. \\\\\n{\\sf GrB\\_INVALID\\_OBJECT}         & One of the opaque GraphBLAS objects (input or output) is in an invalid state caused by a previous execution error. \\\\\n{\\sf GrB\\_INDEX\\_OUT\\_OF\\_BOUNDS}  & Reference to a vector or matrix element that is outside the defined dimensions of the object. \\\\\n{\\sf GrB\\_PANIC}        & Unknown internal error. \\\\\n\\end{tabular}\n\n\\end{center}\n\\hrule\n\\end{table}\n\nAn API error means that a GraphBLAS method was called with parameters that\nviolate the rules for that method.  These errors are restricted to those\nthat can be determined by inspecting the types and domains of GraphBLAS\nobjects, GraphBLAS operators, or the values of scalar parameters fixed at\nthe time a method is called.  API errors are deterministic and consistent\nacross platforms and implementations.  API errors are never deferred,\neven in nonblocking mode. That is, if a method is called in a manner\nthat would generate an API error, it always returns with the appropriate\nAPI error value.  If a GraphBLAS method returns with an API error, it\nis guaranteed that none of the arguments to the method (or any other\nprogram data) have been modified.\n\nExecution errors indicate that something went wrong during the execution\nof a legal GraphBLAS method invocation.  Their occurrence may depend on\nspecifics of the executing environment and data values being manipulated.\nThis does not mean that execution errors are the fault of the GraphBLAS\nimplementation.  For example, a memory leak could arise from an error in\nan application's source code (a ``program error''), but it may manifest\nitself in different points of a program's execution (or not at all)\ndepending on the platform, problem size, or what else is running at\nthat time.  Index-out-of-bounds and insuficient space execution errors\nalways indicate a program error.\n\nIn blocking mode, where each method executes to completion, a returned\nexecution error value applies to the specific method.  If a GraphBLAS\nmethod, executing in blocking mode, returns with any execution error\nfrom Table~\\ref{Tab:ErrorValues}(b) other than {\\sf GrB\\_PANIC}, it\nis guaranteed that no argument used as input-only has been modified.\nOutput arguments may be left in an invalid state, and their use downstream\nin the program flow may cause additional errors.  If a GraphBLAS method\nreturns with a {\\sf GrB\\_PANIC} execution error, no guarantees can be\nmade about the state of any program data.\n\nIn nonblocking mode, execution errors can be deferred.  A return value\nof {\\sf GrB\\_SUCCESS} only guarantees that there are no API errors in\nthe method invocation.  If an execution error value is returned by a\nmethod in nonblocking mode, it indicates that an error was found during\nexecution of the sequence, up to and including the {\\sf GrB\\_wait()}\nmethod (Section~\\ref{Sec:GrB_wait}) call that ends the sequence. When possible, that return value\nwill provide information concerning the cause of the error.\n\nAs discussed in Section~\\ref{Sec:GrB_waitOne}, a {\\sf GrB\\_wait(obj)} on\na specific GraphBLAS object {\\sf obj} does not necessarily end a\nsequence. However, no additional errors on the methods of the sequence that \nhave {\\sf obj} as an {\\sf OUT} or {\\sf INOUT} argument can be reported.\nFrom a GraphBLAS perspective, those methods are {\\em complete}.\n\nIf a GraphBLAS method, executing in nonblocking mode, returns with\nany execution error from Table~\\ref{Tab:ErrorValues}(b) other than\n{\\sf GrB\\_PANIC}, it is guaranteed that no argument used as input-only\nthrough the entire sequence has been modified.  Any output argument in\nthe sequence may be left in an invalid state and its use downstream in the\nprogram flow may cause additional errors.  If a GraphBLAS method returns\nwith a {\\sf GrB\\_PANIC}, no guarantees can be made about the state of\nany program data.\n\n\\begin{figure}[tb]\n    \\hrule\n    \\vspace{1\\baselineskip}\n    \\begin{center}\n        \\begin{minipage}{3in}\n            \\begin{verbatim}\n            const char *GrB_error();\n            \\end{verbatim}\n        \\end{minipage}\n    \\end{center}\n    \\caption{Signature of {\\sf GrB\\_error()} function.}\n    \\label{Fig:GrB_error}\n    \\hrule\n\\end{figure}\n\nAfter a call to any GraphBLAS method, the program can retrieve additional\nerror information (beyond the error code returned by the method) though a\ncall to the function {\\sf GrB\\_error()}. The signature of that function is\nshown in Figure~\\ref{Fig:GrB_error}.  The function returns a pointer to a \nNULL-terminated string, and the contents of that string are implementation \ndependent. In particular, a null string (not a {\\sf NULL} pointer) is always a valid error string.\nThe pointer is valid until the next call to any GraphBLAS method by the same thread.\n{\\sf GrB\\_error()} is a thread-safe function, in the sense that multiple threads can\ncall it simultaneously and each will get its own error string back, referring to the\nlast GraphBLAS method it called.\n", "meta": {"hexsha": "dd086e1b3b9d7abd547ce3251eb42dc5ac333a1f", "size": 16501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lagraph_spec/basic_concepts.tex", "max_stars_repo_name": "GraphBLAS/LAGraph-Working-Group", "max_stars_repo_head_hexsha": "30662a6ad814baeda21c46025411254558b977db", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-01T14:13:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-26T17:09:05.000Z", "max_issues_repo_path": "lagraph_spec/basic_concepts.tex", "max_issues_repo_name": "GraphBLAS/LAGraph-Working-Group", "max_issues_repo_head_hexsha": "30662a6ad814baeda21c46025411254558b977db", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-03-18T14:24:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-25T10:26:37.000Z", "max_forks_repo_path": "lagraph_spec/basic_concepts.tex", "max_forks_repo_name": "GraphBLAS/LAGraph-Working-Group", "max_forks_repo_head_hexsha": "30662a6ad814baeda21c46025411254558b977db", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-06-03T14:51:06.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-13T14:15:35.000Z", "avg_line_length": 50.9290123457, "max_line_length": 213, "alphanum_fraction": 0.7451669596, "num_tokens": 4248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.432657738056382}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{a4wide}\n\\usepackage{relsize}\n\\usepackage{indentfirst}\n\\usepackage{minted}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\usepackage{amsmath, amssymb, amsfonts, amsthm}\n\\usepackage{hyperref}\n\\usepackage[capitalise]{cleveref}\n\\usepackage[toc, page]{appendix}\n\n\\AtBeginEnvironment{minted}{\\let\\itshape\\relax}\n\n\\begin{document}\n\n\\section*{Exercise 1}\n\nSee \\cref{fig:dhparam}.\n\n\\section*{Exercise 2}\n\nSee \\Cref{fig:dsa-prime,fig:dsa-generator}.\n\n\\section*{Exercise 3}\n\nWithout the \\texttt{dsaparam} option, the generation of DH parameters takes much longer because it\ngenerates a \\textit{strong prime}, \\textit{i.e.} a prime number $p$ such that $(p-1)/2$ is also prime.\nThis ensures that the multiplicative group $\\mathbb{Z}_p^\\ast$ does not contain small subgroups. The\nexistence of small subgroups within a larger group in a cryptographic protocol is undesirable in the\nsense that it confines shared secrets to a smaller set of possible values than if it were to use the\nwhole group $\\mathbb{Z}_p^\\ast$. \n\nOn the other hand, using the \\texttt{dsaparam} DSA rather than DH parameters are read or generate, which\nare then they are converted to DH format, making the key exchange process more efficient.\n\n\\vspace{\\baselineskip}\n\n\\textbf{Note:} See \\cref{fig:sage-dh,fig:sage-dsa}.\n\n\\section*{Exercise 4}\n\nRunning the following function with the previously generated DH parameters, we can see that\n$X^y \\ (\\mathrm{mod} \\ p) = Y^x \\ (\\mathrm{mod} \\ p)$ holds.\n\n\\vspace{\\baselineskip}\n\n\\begin{minted}{py}\nfrom sage.all import *\n\ndef ex4(p, q):\n    x = randrange(q)\n    y = randrange(q)\n\n    X = Mod(q ** x, p)\n    Y = Mod(q ** y, p)\n\n    return Mod(X ** y, p) == Mod(Y ** x, p)\n\\end{minted}\n\n\\vspace{\\baselineskip}\n\n\\textbf{Note:} See \\cref{fig:ex4-dhparam,fig:ex4-dsa}.\n\n\\section*{Exercise 5}\n\nWe know that $p = 1373, g = 2, X = 974$ and $y = 871$. We can determine $Y$ by computing the\nfollowing:\n\n\\[\nY = g^y \\ \\mathrm{mod} \\ p = 2^{871} \\ \\mathrm{mod} \\ 1373 = 805\n\\]\n\nKnowing the value of $X$ and $y$, we can then determine the shared secret $g^{xy}$ by computing\nthe following:\n\n\\[\ng^{xy} = (g^x)^y = X ^ y = 974 ^ {871} \\ \\mathrm{mod} \\ 1373 = 397\n\\]\n\n\\pagebreak\n\nFinally, we can find Alice's secret exponent by solving:\n\n\\[\nX = g^x \\ \\mathrm{mod} \\ p \\Leftrightarrow 974 = 2^x \\ \\mathrm{mod} \\ 1373 \\Leftrightarrow x = 587\n\\]\n\n\\section*{Exercise 6}\n\nThe Computational Diffie-Hellman Problem (CHD) consists in computing the shared secret $g^{ab}$ given\nonly the public values $g^a$ and $g^b$, and not any of the secret values $a$ or $b$. The motivation\nis to ensure that even if an eavesdropper captures $g^a$ and $g^b$, they will not be able to determine\nthe shared secret $g^{ab}$.\n\nThe Decisional Diffie-Hellman Problem (DDH) is stronger than the CDH. To ensure that an attacker can't\nlearn anything about the shared secret $g^{ab}$, this value needs only to be indistinguishable from a\nrandom group element. This being said, given $g^a, g^b$ and a value that is either $g^{ab}$ or $g^c$\nfor a random value $c$, each with probability $1/2$, the DDH problem consists of determining whether\n$g^{ab}$ was chosen. \n\nAn algorithm that solves the Computational Diffie–Hellman problem can be used to solve the Decisional\nDiffie–Hellman problem. Given $g^a, g^b$ and $g^c$, and assuming we can solve CDH, we can derive $g^{ab}$\nfrom $g^a$ and $g^b$. Then, to solve DDH, we only have to check if the result equals $g^c$.\n\n\\pagebreak\n\n\\begin{appendices}\n\n\\section*{Exercise 1}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.9\\textwidth]{img/dhparam.png}\n    \\caption{Generation of DH parameters without the \\texttt{dsaparam} option}\n    \\label{fig:dhparam}\n\\end{figure}\n\n\\section*{Exercise 2}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{img/dsa-prime.png}\n    \\caption{Prime number generated using DH parameter generation with the \\texttt{dsaparam} option}\n    \\label{fig:dsa-prime}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{img/dsa-generator.png}\n    \\caption{Group generator generated using DH parameter generation with the \\texttt{dsaparam} option}\n    \\label{fig:dsa-generator}\n\\end{figure}\n\n\\section*{Exercise 3}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/dh-sage.png}\n    \\caption{Prime number generated using DH parameter generation without the \\texttt{dsaparam} option}\n    \\label{fig:sage-dh}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/dsa-sage.png}\n    \\caption{Prime number generated using DH parameter generation with the \\texttt{dsaparam} option}\n    \\label{fig:sage-dsa}\n\\end{figure}\n\n\\section*{Exercise 4}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/dh-py.png}\n    \\caption{Checking that $X^y \\ (\\mathrm{mod} \\ p) = Y^x \\ (\\mathrm{mod} \\ p)$ holds for the DH parameters generated without the \\texttt{dsaparam} option}\n    \\label{fig:ex4-dhparam}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/dsa-py.png}\n    \\caption{Checking that $X^y \\ (\\mathrm{mod} \\ p) = Y^x \\ (\\mathrm{mod} \\ p)$ holds for the DH parameters generated with the \\texttt{dsaparam} option}\n    \\label{fig:ex4-dsa}\n\\end{figure}\n\n\\end{appendices}\n\n\\end{document}\n", "meta": {"hexsha": "28f65423628976e5e14421552e46194939bba5c0", "size": 5354, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CA/7-DH/tex/main.tex", "max_stars_repo_name": "ruipedro16/FCUP-MSI", "max_stars_repo_head_hexsha": "6e86087b1b4ff73a789fefcdb1e41bc117cfdf5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CA/7-DH/tex/main.tex", "max_issues_repo_name": "ruipedro16/FCUP-MSI", "max_issues_repo_head_hexsha": "6e86087b1b4ff73a789fefcdb1e41bc117cfdf5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CA/7-DH/tex/main.tex", "max_forks_repo_name": "ruipedro16/FCUP-MSI", "max_forks_repo_head_hexsha": "6e86087b1b4ff73a789fefcdb1e41bc117cfdf5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1279069767, "max_line_length": 156, "alphanum_fraction": 0.7108703773, "num_tokens": 1685, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704502361149, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.43248301742053874}}
{"text": "\\documentclass[12pt]{article}\n    \\usepackage{mathtools}\n    \\usepackage[hidelinks]{hyperref}\n    \\usepackage{color}\n    \\usepackage{fancyref}\n    \\usepackage{lastpage}\n    \\usepackage{fancyhdr}\n    \n    \\usepackage{pagecolor}\n    % \\pagecolor{black}\n    % \\color{white}\n\n    \\pagestyle{fancy}\n    \\fancyhf{}\n    \\fancyhead[LO]{TMA4140: Homework set 7}\n    \\fancyhead[RO]{Henry S. Sjøen \\& Toralf Tokheim}\n    \\fancyfoot[CO]{\\thepage\\ of \\pageref{LastPage}}\n\n    \\definecolor{darkred}{RGB}{200, 0, 0}\n\n  \\author{Henry S. Sjøen \\& Toralf Tokheim}\n  \\title{\n  \\textbf{TMA4140 - Homework Exercise Set 7}}\n\\begin{document}\n    \\maketitle\n    \\thispagestyle{empty}\n    \\pagebreak\n    \\tableofcontents\n    \\pagebreak\n\n    \\section{Section 8.1} \n    % Obligatoriske: 11, 20; \n    % Anbefalte: 19, 21.\n    \\subsection{Exercise 11}\n    \\textbf{a) Find a recurrence relation for the number of ways to climb n stairs if the person climbing the stairs can take one stair or two stairs at a time.}\\\\\n    $ a_n=a_{n-1}+a_{n-2} $ when $n > 2$\\\\\n    \\textbf{b) What are the initial conditions?}\\\\\n    % Only one way to reach \"The zero-step\", is not to move, witch also is a move. $a_0 = 1$\\\\\n    To reach the first step there is only one solution, taking one single step $a_1=1$\\\\\n    To reach the second step, we can take either two single steps or one double step. $a_2=2$\\\\\n    \\textbf{c) In how many ways can this person climb a flight of eight stairs?}\\\\\n    A lot... \n    \\begin{equation}\n        \\begin{split}\n            % 8 enere\n            % 0 toer\n            1+1+1+1+1+1+1+1=8\\\\\n            % 6 enere\n            % 1 toer\n            % Gir oss 7 bokser\n            % og også 7 permutasjoner\n            2+1+1+1+1+1+1=8\\\\\n            1+2+1+1+1+1+1=8\\\\\n            1+1+2+1+1+1+1=8\\\\\n            1+1+1+2+1+1+1=8\\\\\n            1+1+1+1+2+1+1=8\\\\\n            1+1+1+1+1+2+1=8\\\\\n            1+1+1+1+1+1+2=8\\\\\n            % 4 enere\n            % 2 toere\n            % Gir oss 6 bokser\n            2+2+1+1+1+1=8\\\\\n            2+1+2+1+1+1=8\\\\\n            2+1+1+2+1+1=8\\\\\n            2+1+1+1+2+1=8\\\\\n            2+1+1+1+1+2=8\\\\\n            % \n            1+2+2+1+1+1=8\\\\\n            1+2+1+2+1+1=8\\\\\n            1+2+1+1+2+1=8\\\\\n            1+2+1+1+1+2=8\\\\\n            % \n            % \n            1+1+2+2+1+1=8\\\\\n            1+1+2+1+2+1=8\\\\\n            1+1+2+1+1+2=8\\\\\n            % \n            1+1+1+2+2+1=8\\\\\n            1+1+1+2+1+2=8\\\\\n            % \n            1+1+1+1+2+2=8\\\\\n            % \n            % 2 enere\n            % 3 toere\n            2+2+2+1+1=8\\\\\n            2+2+1+2+1=8\\\\\n            2+2+1+1+2=8\\\\\n            2+1+2+1+2=8\\\\\n            2+1+1+2+2=8\\\\\n            1+2+2+2+1=8\\\\\n            1+2+2+1+2=8\\\\\n            1+2+1+2+2=8\\\\\n            1+1+2+2+2=8\\\\\n            % 0 enere\n            % 4 toere\n            2+2+2+2=8\\\\\n        \\end{split}\n    \\end{equation}\n\n    I missed one above, but easier to calculate it...\n    $ a_n=a_{n-1}+a_{n-2} $ when $n > 2$\\\\\n\n    \\begin{equation}\n        \\begin{split}\n            a_n&=a_{n-1}+a_{n-2} | n>2\\\\\n            % a_0&=1,\n            a_1&=1,a_2=2\\\\ \n            % a_2&=a_{2-1}+a_{2-2}=a_{1}+a_{0}=1+1=2\\\\\n            a_3&=a_{3-1}+a_{3-2}=a_{2}+a_{1}=2+1=3\\\\\n            a_4&=a_{4-1}+a_{4-2}=a_{3}+a_{2}=3+2=5\\\\\n            a_5&=a_{5-1}+a_{5-2}=a_{4}+a_{3}=5+3=8\\\\\n            a_6&=a_{6-1}+a_{6-2}=a_{5}+a_{4}=8+5=13\\\\\n            a_7&=a_{7-1}+a_{7-2}=a_{6}+a_{5}=13+8=21\\\\\n            a_8&=a_{8-1}+a_{8-2}=a_{7}+a_{6}=21+13=34\n        \\end{split}\n    \\end{equation}\n\n    There are 34 possible ways to climb the flight of $8$ stairs using only $1$ or $2$ steps at a time.\n\n    \\subsection{Exercise 20}\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-8.1-problem-20e-solution-9780073383095-exc\n    A bus driver pays all tolls, using only nickels and dimes, by throwing one coin at a time into the mechanical toll collector.\\\\\n    \\textbf{a)} Find a recurrence relation for the number of different ways the bus driver can pay a toll of n cents (where the order in which the coins are used matters).\\\\\n    1 Nickel =  5 cents, 1 Dime = 10 cents.\\\\\n    Let $a_n$ be the number of ways the busdriver can pay a toll of $n$ cents.\\\\\n    If last coin Nickel $a_{n-5}$, If last coin Dime $a_{n-10}$\\\\\n    Then the recurrence relation can be given as...\n    $a_n=a_{n-5}+a_{n-10} | n \\geq 10$\n    And since nickels and dimes are of multiple of 5 we can further write it as ...\n    $a_{5n}=a_{5(n-1)} + a_{5(n-2)} | n \\geq 2$.\n    Where the initial conditions are $a_0=1; a_5=1;$\n    \\textbf{b)} In how many different ways can the driver pay a toll of 45 cents?\n    We must calculate $a_{45}$\n    \\begin{equation}\n        \\begin{split}\n            a_{5n}&=a_{5(n-1)} + a_{5(n-2)}\\\\\n            a_0&=1; a_5=1\\\\\n            a_{10}&=2\\\\\n            a_{15}&=3\\\\\n            a_{20}&=5\\\\\n            a_{25}&=8\\\\\n            a_{30}&=13\\\\\n            a_{35}&=21\\\\\n            a_{40}&=34\\\\\n            a_{45}&=55\n        \\end{split}\n    \\end{equation}\n\n    \\section{Section 8.2} \n    % Obligatoriske: 3c,d,e,g, 6, 11, 42; \n    % Anbefalte: 40.\n    \n    \\subsection{Exercise 3} %todo\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-8.2-problem-3E-solution-9780073383095-exc\n    Solve these recurrence relations together with the initial conditions given.\\\\\n    \\textbf{c)} $ a_n=5a_{n-1} - 6a_{n-2} $ for $ n \\geq 2, a_0=1, a_1=0 $\\\\\n    Comparing the given recurrence with the general relation we get $C_1=5,c_2=-6$ and rest of the coefficients are $0$.\n    Our characteristic equation will be $r^2=5r^1-6r^0$, so...\n    \\begin{equation}\n        \\begin{split}\n            r^2-5r^1+6r^0=0\\\\\n            r^2-5r+6r=0\\\\\n            r^2-3r-2r+6=0\\\\\n            (r-3)(r-2)=0\n        \\end{split}\n    \\end{equation}\n    That is, $r=3,2$.\n    Solution will be of the form $a_n=a_1r_2^n$. Setting in the value of $r$ and use the initial condition.\n    $n=0,1$...\\\\\n    \\begin{equation}\n        \\begin{split}\n            a_n=a_1r_1^n\\\\\n            a_n=a_1(2)^n+a_2(3)^n\n        \\end{split}\n    \\end{equation}\n    When $n=0$, then...\n    \\begin{equation}\n        \\begin{split}\n            a_0=a_1(2)^0+a_2(3)^0\\\\\n            1=a_1+a_2\\\\\n            a_1=1-a_2\n        \\end{split}\n    \\end{equation}\n    When $n=1$, then...\n    \\begin{equation}\n        \\begin{split}\n            a_1=a_1(2)^1+a_2(3)^1\\\\\n            0=2a_1+3a_2\n        \\end{split}\n    \\end{equation}\n    Put the value of $a_1=1-a_2$ in the equation $2a_1+3a_2=0$...\n    \\begin{equation}\n        \\begin{split}\n            2(1-a_2)+3a_2=0\\\\\n            2-2a_2+3a_2=0\\\\\n            a_2=-2\n        \\end{split}\n    \\end{equation}\n    Put the value of $a_2=-2$ in the equation $a_1=1-a_2$ and we get $a_1=3$.\n    Put the value of $a_1,a_2$ in the equation $a_n=a_1r_1^n+a_2r_2^n$ to get the final solution $a_n=3 \\times (2)^n-2 \\times (3)^n$.\n\n    \\textbf{d)} $ a_n=4a_{n-1} - 4a_{n-2} $ for $ n \\geq 2, a_0=6, a_1=8 $\\\\\n    Comparing the given recurrence relation with the general relation we get $c_1=4$ $c_2=-4$ and the rest of the coefficients are 0.\n    The corresponding characteristic equation will be $r^2=4r^1-4r^0$. So,\n    \\begin{equation}\n        \\begin{split}\n            r^2-4r+4=0\\\\\n            r^2-2r-2r+4=0\\\\\n            (r-2)(r-2)=0\n        \\end{split}\n    \\end{equation}\n    Since we have a repeated root, the solution will be of the form $a_n=a_1r_1^n+a_2nr_2^n$.\n    Putting the value of $r$ and useing the initial conditions $n=0,1$ and get...\n    \\begin{equation}\n        \\begin{split}\n            a_n=a_1r_1^n+a_2nr_2^n\\\\\n            a_n=a_1(2)^n+a_2n(2)^n\n        \\end{split}\n    \\end{equation}\n    when $n=0$...\n    \\begin{equation}\n        \\begin{split}\n            a_0=a_1(2)^0+a_20(2)^0\\\\\n            6=a_1\n        \\end{split}\n    \\end{equation}\nWhen $n=1$...\n    \n\\begin{equation}\n    \\begin{split}\n        a_1=a_1(2)^1+a_21(2)^1\\\\\n        8=2a_1+2a_2\n    \\end{split}\n\\end{equation}\nPut the value of $a_1=6$ in the equation $8=2a_1+2a_2$ to get...\n\\begin{equation}\n    \\begin{split}\n        2a_1+2a_2=8\\\\\n        12+2a_2=8\\\\\n        2a_2=8-12\\\\\n        a_2=-2\n    \\end{split}\n\\end{equation}\nPut the value of $a_1,a_2$ in the equation $a_n=a_1r_1^n+a_2nr_2^n$ to get the desired solution.\nThus, the solution is $a_n=6\\cdot (2)^n-2\\cdot n \\cdot (2)^n$.\n    \\textbf{e)} $ a_n=-4a_{n-1} - 4a_{n-2} $ for $ n \\geq 2, a_0=0, a_1=1 $\\\\\n    \\textbf{g)} $ a_n=\\frac{a_{n-2}}{4} $ for $ n \\geq 2, a_0=1, a_1=0 $\n    \\subsection{Exercise 6} %todo\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-8.2-problem-6E-solution-9780073383095-exc\n    How many different messages can be transmitted in $n$ microseconds using three different signals if one signal requires $1$ microsecond for transmittal, the other two signals require $2$ microseconds each for transmittal, and a signal in a message is followed immediately by the next signal?\n\n    \\subsection{Exercise 11}\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-8.2-problem-11E-solution-9780073383095-exc\n    The Lucas numbers satisfy the recurrence relation\n    \\begin{equation}\n        L_n=L_{n-1}+L_{n-2}\n    \\end{equation}\n    and the initial conditions $L_0 = 2$ and $L_1=1$.\n\n    \\textbf{a)} Show that $L_n = f_{N-1}+f_{n+1}$ for $n=2,3,...,$ where $f_n$ is the $n$th Fibonacci number.\\\\\n    \\textbf{b)} Find an explicit formula for the Lucas numbers.\nAnswer: \n     $Ln = ((1+sqr(5))/2)+((1-sqr(5))/(2))$        \n\n    \\subsection{Exercise 42} %todo\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-8.2-problem-42E-solution-9780073383095-exc\n    Show that if $a_n =a_{n-1} + a_{n-2}, a_0=s$ and $a1 =t$, where $s$ and $t$ are constants, then $a_n = sf_{n-1} + tf_n$ for all positive integers $n$.\n\n    \n\n    \\section{Section 5.1} \n    % Obligatoriske: 4, 6, 14, (4, 6, 14); \n    % Anbefalte: 9, 10.\n\n    \\subsection{Exercise 4}\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-5.1-problem-4E-solution-9780073383095-exc\n    Let $P(n)$ be the statement that $1^3 + 2^3 + \\cdots + n^3 = (n(n + 1)/2)^2$ for the positive integer $n$.\\\\\n%     \\textbf{a) What is the statement $P(1)$?}\\\\\n%     \\textbf{b) Show that $P(1)$ is $true$, completing the basis step of the proof.}\\\\\n%     \\textbf{c) What is the inductive hypothesis?}\\\\\n%     \\textbf{d) What do you need to prove in the inductive step?}\\\\\n%    \\textbf{ e) Complete the inductive step, identifying where you use the inductive hypothesis.}\\\\\n%     \\textbf{f) Explain why these steps show that this formula is $true$ whenever $n$ is a positive integer.}\n    % \n    % \\begin{enumerate}[label=\\alph*)]\n        \n        $P(1): 1^3 = (\\frac{1(1+1)}{2})^2$\n        Basis step:\n            $P(1): 1^3 = (\\frac{1(1+1)}{2})^2 = 1$ \\\\\n            $P(1)$ is true, which completes the basis step of a proof by\n                induction for $P(k)$\n    \n        The inductive hypothesis consists of two parts: \\\\\n            - $P(b)$ holds true \\\\\n            - $P(k) \\rightarrow P(k+1)$ holds true\\\\\n            Then $P(k), \\quad \\forall k > b$\n    \n            In other words, if $P$ is true for the first step, and $P$ holds true for an arbitrary step implies $P$ holds true for the next step, then $P$ holds true for all steps. \\\\\n    \n        You need to prove the first step $P(b)$, and then you need to prove\n            $P(k) \\rightarrow P(k+1)$\n    \n                    \\begin{align}\n                        \\intertext{Basis step:}\n                        1^3 = (1(1+1)/2)^2 = 1 \\\\\n                        \\intertext{LHS = RHS}\n                        \\intertext{Inductive step:}\n                        \\sum_{n=1}^k{n^3} = \\Big(\\frac{k(k+1)}{2}\\Big)^2 \\\\ %\\label{eq:4e_k}\n                        \\intertext{We assume $P(k)$ is true for an arbitrary integer $k$. We can replace $k$ with $k+1$. Out goal is to show that if $P(k)$ holds then $P(k+1)$ must hold}\n                        \\sum_{n=1}^{k+1}{n^3} = \\Big(\\frac{(k+1)((k+1)+1)}{2}\\Big)^2 \\\\\n                        \\sum_{n=1}^{k}{n^3} + (k+1)^3 = \\Big(\\frac{(k+1)(k+2)}{2}\\Big)^2 \\\\\n                        = \\Big(\\frac{(k^2+3k+2)}{2}\\Big)^2 \\\\\n                        = \\Big(\\frac{(k(k+1))}{2} + (k+1)\\Big)^2 \\\\\n                        \\sum_{n=1}^{k}{n^3} + (k+1)^3 = \\Big(\\frac{(k(k+1))}{2}\\Big)^2 + k(k+1)(k+1) + (k+1)^2 \\\\\n                        \\intertext{We subtract  $\\sum_{n=1}^k{n^3} = \\Big(\\frac{k(k+1)}{2}\\Big)^2$ from the equation and have}\n                        (k+1)^3 = k(k+1)^2 + (k+1)^2 \\\\\n                        (k+1)^3 = (k+1)(k+1)^2 = (k+1)^3 \\\\\n                        \\intertext{LHS = RHS. This means that if $P(k)$ holds true,\n                        then $P(k+1)$ must also be true, which by the inductive\n                        hypothesis means that $\\forall k \\geq 1, \\quad P(k)$ holds true}\n                    \\end{align}\n\n    \\subsection{Exercise 6}\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-5.1-problem-6E-solution-9780073383095-exc\n    Prove that $s1 \\cdot 1!+2 \\cdot 2! + \\cdots + n \\cdot n! = (n+1)!-1$ whenever $n$ is a positive integer.\n    \\begin{align}\n        \\intertext{Basis step:}\n        1\\cdot 1\\! = (1 + 1)! - 1 \\\\\n        1 = (2)! - 1 = 2 - 1 = 1\\\\\n        \\intertext{LHS = RHS, so $P(1)$ holds true}\n        \\intertext{Inductive step:}\n        \\sum_{n = 1}^k{n\\cdot n!} = (k + 1)! - 1 \\\\ %\\label{eq:1-6-k}\n        \\intertext{We assume that $P(k)$ holds for all $k > 1$, and replace\n            $k$ with $k+1$}\n        \\sum_{n = 1}^{k+1}{n\\cdot n!} = ((k+1) + 1)! - 1 \\\\\n        (k+1)\\cdot(k+1)! + \\sum_{n = 1}^{k}{n\\cdot n!}  = (k+2)! - 1 \\\\\n        (k+1)\\cdot(k+1)! + \\sum_{n = 1}^{k}{n\\cdot n!}  = (k+2)(k+1)! - 1 \\\\\n        \\intertext{We subtract $\\sum_{n = 1}^k{n\\cdot n!} = (k + 1)! - 1$ from the equation and get}\n        (k+1)\\cdot(k+1)! +  = (k+2)(k+1)! - 1 - \\big( (k+1)! - 1\\big)\\\\\n        (k+1)\\cdot(k+1)! +  = (k+2)(k+1)!  -  (k+1)! \\\\\n        (k+1)\\cdot(k+1)! +  = k(k+1)! + 2(k+1)! - (k+1)! \\\\\n        (k+1)\\cdot(k+1)! +  = k(k+1)! + (k+1)!  \\\\\n        (k+1)\\cdot(k+1)! +  = (k+1)\\cdot(k+1)!  \\\\\n        \\intertext{LHS = RHS, so $P(k)$ must hold for all $k > 1$}\n    \\end{align}\n\n\n    \\subsection{Exercise 14}\n    % https://www.chegg.com/homework-help/bus-driver-pays-tolls-using-nickels-dimes-throwing-one-coin-chapter-5.1-problem-14E-solution-9780073383095-exc\n    Prove that for every positive integer $n$, $\\sum_{k=1}^{n}k2^k=(n-1)2^{n+1}+2$.\n            \\begin{align}\n                \\intertext{$P(k)$:}\n                \\sum_{n=1}^k{ n2^n} = (k-1)2^{k+1} + 2 %\\label{eq:1-14-k}\\\n                \\intertext{Basis step:}\n                1\\cdot 2^1 = (1-1)2^2{1+1} + 2 = 2\\\n                \\intertext{LHS = RHS, so $P(1)$ holds true}\n                \\intertext{Induction step:}\n                \\intertext{Replacing $n$ with $k+1$ in $\\sum_{n=1}^k{ n2^n} = (k-1)2^{k+1} + 2$ gives us}\n                \\sum_{n=1}^{k+1}{ n2^n} = ((k+1)-1)2^{(k+1)+1} + 2 \\\\\n                (k+1)2^{k+1} + \\sum_{n=1}^{k}{ n2^n} = k2^{k+2} + 2 \\\\\n                (k+1)2^{k+1} + \\sum_{n=1}^{k}{ n2^n} = 2k2^{k+1} + 2 \\\\\n                \\intertext{We subtract $\\sum_{n=1}^k{ n2^n} = (k-1)2^{k+1} + 2$ from the equation and get}\n                (k+1)2^{k+1} = 2k2^{k+1} + 2 - \\big((k-1)2^{k+1} + 2\\big) \\\\\n                (k+1)2^{k+1} = 2k2^{k+1} - (k-1)2^{k+1} \\\\\n                (k+1)2^{k+1} = (2k - (k-1)) 2^{k+1}\\\\\n                (k+1)2^{k+1} = (k+1)2^{k+1}\\\\\n                \\intertext{LHS = RHS, so $P(k)$ must hold for all $k > 1$}\n            \\end{align}\n\\end{document}", "meta": {"hexsha": "583846c9e9f2e3c621d28ef520bce8af87078b1d", "size": 15811, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "O7/o7.tex", "max_stars_repo_name": "SjoenH/TMA4140-2018", "max_stars_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "O7/o7.tex", "max_issues_repo_name": "SjoenH/TMA4140-2018", "max_issues_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-09-16T20:12:23.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-24T09:17:53.000Z", "max_forks_repo_path": "O7/o7.tex", "max_forks_repo_name": "SjoenH/TMA4140-2018", "max_forks_repo_head_hexsha": "9d2973b94f62f2d30328de3db5f496a42f900ebf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8482384824, "max_line_length": 295, "alphanum_fraction": 0.51868952, "num_tokens": 6245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7745833945721304, "lm_q1q2_score": 0.432470818553549}}
{"text": "% !TeX encoding = UTF-8\n% !TeX program = pdflatex\n\n\\documentclass[11pt]{article}\n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{lineno}\n\\lstloadlanguages{Python}\n\\lstset{%\n\tbasicstyle=\\fontsize{10}{11}\\ttfamily\\color{black},\n\tcommentstyle=\\ttfamily\\color{red},\n\tkeywordstyle=\\ttfamily\\color{blue},\n\tstringstyle=\\color{orange},\n\ttabsize=2,\n\tnumbers=left,\n\tnumberstyle=\\tiny,\n\tfirstnumber=1,\n\tnumberfirstline=false,\n\tframe=single,\n\tshowstringspaces=false,\n\tinputencoding=utf8,\n\tbreaklines=true\n}\n\\usepackage{amsmath}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\title{Homework 1 - Algorithm Design \\\\ \\bigskip \\large Sapienza University of Rome}\n\\date{\\today}\n\\author{Marco Costa 1691388}\n\n\\begin{document}\n\\maketitle\n\n\\section{Exercise 1}\nThe goal of this exercise is to cluster the points of \\textbf{X} using the first \\textit{\\textbf{k}} points \\textbf{C = $\\mathbf{\\{ \\pi(X)_{1},...,\\pi(X)_{k} \\}}$} as center (where $\\mathit{\\pi(X)}$ is a permutation). For any \\textit{\\textbf{k}}, the output should be optimal with respect of the objective function $\\mathbf{\\displaystyle\\max_{x \\in X} \\min_{c \\in C} d(x,c)}$. \\\\\nThis problem is known as k-center clustering problem, and it's NP-HARD. \\\\\nFortunately, it is possible to find an approximation using a greedy algorithm. \\\\\nThe greedy clustering algorithm simply chooses the point farthest away from the current set of centers in each iteration as the new center. It can be described in this way:\n\\begin{itemize}\n\t\\item Pick an arbitrary point $\\mathbf{c_{i}}$ into $\\mathbf{C}$;\n\t\\item For every point $\\mathbf{x \\in X}$ compute $\\mathbf{d_{i}(x,c_{i})}$;\n\t\\item Pick the point $\\mathbf{c_{i}}$ with the highest distance from $\\mathbf{c_{i-1}}$ ($\\displaystyle\\max_{x \\in X} d(x, c_{i})$).\n\tIn this case, distance must be 3. If there are no points that have the distance 3, then the distance must be 1;\n\t\\item Add it to the set of centers $\\mathbf{C}$;\n\t\\item Continue till \\textit{\\textbf{k}} centers are found (\\textit{i=1,...,k}).\n\\end{itemize}\n\n\\subsection{Analysis of the algorithm}\n\\begin{itemize}\n\t\\item The $i^{th}$ iteration of choosing the $i^{th}$ center takes $\\mathbf{O(|X|)}$ time.\n\t\\item There are  \\textit{\\textbf{k }} iterations, so overall the algorithm takes $\\mathbf{O(k|X|)}$ time.\n\\end{itemize}\n\n\\subsection{Proof}\nThe correctness of this algorithm can be proved by contradiction.\\\\\nAssume that $\\mathbf{O^{*} = \\{c^{∗}_{1},...,c^{∗}_{k}\\}}$ is an optimal solution for the problem and $\\mathbf{S = \\{c_{1},...,c_{k}\\}}$ the solution given by the greedy algorithm. If $\\mathbf{S \\ne O^{*}}$ so there is at\nleast an optimum center $\\mathbf{\\bar{c}}$\nwhich belongs to $\\mathbf{O^{*}}$ but not to $\\mathbf{S}$. This means that, if this point was selected at the $\\mathbf{(i-1)^{th}}$ iteration of the optimum\nalgorithm because it has distance 3 from the center, so the greedy algorithm has\nnot selected it as the optimum value to satisfy the objective function. But\nthis is not possible, it first insert into the partition all\nthe points of the space which have distance equals to 3 from the center\nand after the points with distance equals to 1 if needed.\n\n\\subsection{2-approximation}\nThe solution obtained using the greedy algorithm (the set $\\mathbf{C}$) is a 2-approximation to the optimal solution ($\\mathbf{r^{C}_{\\infty}(X) \\le 2r^{opt}_{\\infty}}(X,k)$). \n\n\\subsubsection{Proof}\nCase 1: Every cluster of $\\mathbf{C_{opt}}$ contains exactly one point of $\\mathbf{C}$. \n\\begin{itemize}\n\t\\item Consider a point $\\mathbf{x \\in X}$;\n\t\\item Let $\\mathbf{\\bar{c}}$ be the center it belongs to in $\\mathbf{C_{opt}}$;\n\t\\item Let $\\mathbf{\\bar{k}}$ be the center of $\\mathbf{C}$ that is in $\\mathbf{\\Pi(C_{opt},\\bar{c})}$;\n\t\\item $\\mathbf{d(x,\\bar{c}) = d(x,C_{opt}) \\le r^{opt}_{\\infty}(X,k)}$;\n\t\\item Similarly, $\\mathbf{d(\\bar{k},\\bar{c}) = d(\\bar{k},C_{opt}) \\le r^{opt}_{\\infty}(X,k)}$;\n\t\\item By the triangle inequality: $\\mathbf{d(x,\\bar{k}) \\le d(x,\\bar{c}) + d(\\bar{c},\\bar{k}) \\le 2r^{opt}_{\\infty}(X,k)}$\t.\n\\end{itemize}\n\nCase 2: There are two centers $\\mathbf{\\bar{k}}$ and $\\mathbf{\\bar{u}}$ of $\\mathbf{C}$ that is in $\\mathbf{\\Pi(C_{opt},\\bar{c})}$, for some $\\mathbf{\\bar{c} \\in C_{opt}}$\n\\begin{itemize}\n\t\\item Assume, without loss of generality, that $\\mathbf{\\bar{u}}$ was added later to the center set $\\mathbf{C}$ by the greedy algorithm in the $\\mathbf{i^{th}}$ iteration;\n\t\\item But since the greedy algorithm always chooses the point furthest away from the current set of centers, we have that $\\mathbf{\\bar{c} \\in C_{i-1}}$, and \\\\ $\\mathbf{r^{C}_{\\infty}(X) \\le r^{C_{i-1}}_{\\infty}(X) = d(\\bar{u},C_{i-1}) \\le d(\\bar{u},\\bar{k}) \\le d(\\bar{u},\\bar{c}) + d(\\bar{c},\\bar{k}) \\le 2r^{opt}_{\\infty}(X,k)}$.\n\\end{itemize}\n\n\\section{Exercise 2}\nIt's possible to solve this problem using a bipartite graph \\textbf{G(S,A,C)}, where \\textbf{S} is the set containing streets, \\textbf{A} is the set containing avenues and \\textbf{C} is the set containing checkpoints (so a checkpoint is an edge that connects a street in \\textbf{S} with an avenue in \\textbf{A}).\nThe goal is to find a vertex set $\\mathbf{T \\subseteq S \\bigcup A}$ of minimum size.\nSo the problem is a minimum vertex cover problem\n(because we want to find a set of vertices such that every edge of the graph\nhas at least one endpoint in the set). It's possible to find \\textbf{T} with:\n\\begin{itemize}\n\t\\item Ford-Fulkerson’s algorithm to find the maximum matching;\n\t\\item Konig's theorem, which states that in any bipartite graph, the number of edges in a maximum matching is equal to the number of vertices in a minimum vertex cover.\n\\end{itemize}\nLet’s consider \\textbf{M}, a maximum cardinality matching in \\textbf{G}. A matching is an edge set $\\mathbf{M \\subseteq E}$ such that no two edges of M have the same endpoint. Konig's theorem proves that the size of a\nmaximum matching M is equal to the size of the minimum cardinality vertex cover \\textbf{T}. \\\\\nIt's possible to find the maximum matching set \\textbf{M} applying Ford-Fulkerson algorithm in the bipartite flow network \\textbf{G(S,A,C)}.\n\\\\\nNow it's possible to derive from the maximum alternating forest, built starting\nfrom non matched vertices in \\textbf{S}, the minimum vertex cover set \\textbf{T} using Konig's theorem.\\\\ \nThis set represent the minimum\nset of streets and avenues in which it's necessary to place cameras for covering checkpoints.\n\n\\subsection{Analysis}\nThe cost of this algorithm is dominated by the finding of the maximum\nflow (the cost of Ford-Fulkerson’s algorithm). So the total cost is \\textbf{O(\\textit{f}$|C|$)}, where \\textit{\\textbf{f}} is the maximum flow found and \\textbf{C} is the set of the checkpoints.\n\n\\section{Exercise 3}\nIt's possible to solve this problem considering a complete graph \\textbf{G(P,R)} where $\\mathbf{P = M \\bigcup F}$ is the set of friends (\\textbf{M} is the set of male friends and \\textbf{F} is the set of female friends) and R is the set of their relations (the edges of the graph). \\\\\nEach  edge\nhas weight equals to 0 if the two friends don’t like each other, 1 otherwise. \\\\\nThe goal is to find a subset I of people who\nlike each other and who are equally bipartite (so equal number of male and\nfemale friends). \\\\\nThe first point of the problem can be solved considering it as a k-clique problem. The algorithm proceed in this way:\n\\begin{enumerate}\n\t\\item For each $\\mathbf{\\textbf{\\textit{k}} \\in \\{2,|V|\\}}$ it computes the k-clique and stores the cliques with \\textbf{\\textit{k}} edges in a set \\textbf{S};\n\t\\item For each clique in \\textbf{S} it computes the maximum bipartite matching in order to satisfy the second point (equal number of male and female);\n\t\\item For each value of \\textbf{\\textit{k}} it finds the maximum bipartite matching $\\mathbf{M_{k}}$ which maximizes the value \\\\\n\t$\\mathbf{maxVal_{k} = \\frac{1}{|M_{k}}} \\sum_{(u,v) \\in M_{k}}weight(u,v)$;\n\t\\item At the end it finds the maximum value between the various $\\mathbf{maxVal_{k}}$ with $\\mathbf{\\textbf{\\textit{k}} \\in \\{2,|V|\\}}$ and returns the maximum matching corresponding to this value.\n\\end{enumerate}\n\n\\subsubsection{Implementation (pseudocode)}\n\\begin{algorithm}\n\t\\label{euclid}\n\t\\begin{algorithmic}[1]\n\t\t\\State $V \\gets vertices$\n\t\t\\State $E \\gets edges$\n\t\t\\State $G \\gets graph$\n\t\t\\State $maxD[|V|] \\gets [0]$\n\t\t\\State $maxI[k] \\gets$ [ ]\n\t\t\\For{$k \\gets$ 0 to $|V|$}\n\t\t\\State $S \\gets$ find-all k-cliques()\n\t\t\\For{s in S}\n\t\t\\State I $\\gets$ bipartite matching of s\n\t\t\\If{sum weight(s)/$|I| >$ maxD[k]}\n\t\t\\State $maxD[k] \\gets weight(s)/|I|$\n\t\t\\State $maxI[k] \\gets I$\n\t\t\\EndIf\n\t\t\\EndFor\n\t\t\\EndFor\n\t\t\\State $index \\gets max(maxD)$\n\t\t\\State\\Return maxI[index] \n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Proof}\nThis algorithm uses the k-clique problem, which is NP-COMPLETE, in fact, the reduction of this problem is polynomial. For this reason the implemented algorithm is NP-COMPLETE too.\n\n\\section{Exercise 4}\nThe input of the algorithm is the following:\n\\begin{itemize}\n\t\\item costs: a list of tuple where the first element is the timestamp of the task, the second one is the cost of outsourcing;\n\t\\item C: hiring cost;\n\t\\item S: severance cost;\n\t\\item s: daily salary.\n\\end{itemize}\nFor first, the algorithm computes how many tasks with different timestamp there are. In this way it's possible to overlap tasks.\nAfter that, it joins the overlapping tasks generating a matrix in which there are the timestamps in the first row and the outsourcing costs in the second one.\nThen it generates a total cost matrix and initializes the first column, calculates the lowest cost for each instant using the costs of the previous instant and at the end returns the minimum total cost.\n\n\\subsection{Analysis}\nThe cost of the algorithm depends on iterative loops so it is linear: O(T), where T is the last\ntime unit to consider. \\\\\n\n\\subsection{Proof}\nTo prove the correctness of the algorithm we could use proof by induction.\nWe consider as basis step the first two couple of values inside total cost matrix , at this moment i = 0\nand the min of them is the min cost so far. As induction hypothesis we suppose that for i = k the\ncost computed as min of the couple of values inside total cost matrix is optimal. The inductive step is to\nprove that also for i = k + 1 the cost is optimal.\n\n\\subsection{Implementation}\nThe algorithm is implemented in \\textit{\\textbf{Python}}.\n\\begin{lstlisting}[language=Python, caption=minCost]\ndef minCost(costs, C, S, s):\n\n\t# Determine the number of different tasks\n\tT = 0\n\ttime = 0\n\tfor cost in costs:\n\t\tif cost[0] != time:\n\t\t\ttime = cost[0]\n\t\t\tT += 1\n\n\t# Initialize outsourcing cost matrix\n\toutsource = [[0 for x in range(0, T+1)] for x in range(0, 2)]\n\n\t# Initialize total cost matrix\n\ttc = [[0 for x in range(0, T+1)] for x in range(0, 2)]\n\n\t# Construck outsourcing cost matrix joining different tasks with the same timestamp\n\ttime = 0\n\ti = 0\n\tj = 0\n\tfor cost in costs:\n\t\tif j == 0:\n\t\t\toutsource[0][i] = cost[0]\n\t\t\toutsource[1][i] = cost[1]\n\t\t\ttime = cost[0]\n\t\t\tj += 1\n\t\telse:\n\t\t\tif time == cost[0]:\n\t\t\t\toutsource[1][i] += cost[1]\n\t\t\telse:\n\t\t\t\ti += 1\n\t\t\t\toutsource[0][i] = cost[0]\n\t\t\t\toutsource[1][i] = cost[1]\n\t\t\t\ttime = cost[0]\n\n\t# Initialize first column of total cost matrix \n\ttc[0][0] = s + C\n\ttc[1][0] = outsource[1][0]\n\n\t# Construct rest of the total cost matrix \n\tfor i in range(1, T):\n\t\ttc[0][i] = min(tc[0][i-1] + (outsource[0][i] - outsource[0][i-1]) * s, tc[1][i-1] + C + s)\n\t\ttc[1][i] = min(tc[0][i-1] + S + outsource[1][i], tc[1][i-1] + outsource[1][i])\n\n\t# Return the minimum cost\n\treturn min(tc[0][T-1], tc[1][T-1])\n\\end{lstlisting}\n\n\\section{Exercise 5}\n\\subsection{First part}\nThe first part of the exercise can be solved using the Minimum Spanning Tree cycle property: \\\\\n\\textit{For any cycle \\textbf{C} in the graph,\nif the weight of an edge \\textbf{e} of \\textbf{C} is larger than the weights of all other\nedges of \\textbf{C}, then e cannot belong to the MST}.\n\\\\\nThe algorithm is based on a \\textbf{DFS}. It determine if the\ntwo endpoints of \\textit{\\textbf{e}} are connected with a cycle respecting the property\nmentioned before. \\\\\nHow it works:\n\\begin{enumerate}\n\t\\item Run the DFS from one of the end-points of the\ninput edge \\textit{\\textbf{e}} (\\textbf{u} or \\textbf{v} for the edge \\textit{\\textbf{(u, v, weight)}}) considering only outgoing edges which\nhave weight less than the one of \\textit{\\textbf{e}};\n\t\\item \\begin{itemize}\n\t\t\\item Case 1: If at the end of the \\textbf{DFS}, the two vertices \\textbf{u} and \\textbf{v}\nget connected, then the edge \\textit{\\textbf{e}} can't be part of any \\textbf{MST}\nbecause of the cycle property, in fact in this case there exists\na cycle in the graph \\textbf{G} containing the edge \\textit{\\textbf{e}} where \\textit{\\textbf{e}} is the\nedge with maximum weight.\n\t\t\\item Case 2: If at the end of the \\textbf{DFS} \\textbf{u} and\n\\textbf{v} stay disconnected, then there is not a cycle between \\textbf{u} and\n\\textbf{v} where \\textit{\\textbf{e}} is the edge with maximum weight, so the edge\nconsidered can be part of the \\textbf{MST}.\n\t\\end{itemize}\n\\end{enumerate}\nThe cost of this algorithm is dominated from the one of the \\textbf{DFS}, which\nis \\textbf{O($|V| + |E|$)}.\n\n\\subsection{Second part}\nFor this second part, the algorithm described before was used to check if\nthe given edge \\textit{\\textbf{e}} could be part of a Minimum Spanning Tree. After\nchecking the previous condition, Kruskal’s algorithm was used to compute\nthe \\textbf{MST} containing \\textit{\\textbf{e}}: the cost of this algorithm is\n\\textbf{O($|E|log|E|$)}.\n\n\\subsubsection{Implementation}\nThe algorithm is implemented in \\textit{\\textbf{Python}}.\n\\begin{lstlisting}[language=Python, caption=MST given an edge]\ndef give_a_mst(self, edge):\n\tif self.edge_in_mst(edge):\n\t\tprint(\"The edge\",str(edge),\"belongs to MST!\")\n\t\tprint(\"Minimum Spanning Tree:\", end=\"\")\n\t\treturn self.kruskal()\n\telse:\n\t\tprint(\"The edge\",str(edge),\"doesn't belong to MST!\")\n\t\treturn None\n\\end{lstlisting}\nThis algorithm is very symple: \\\\\nIt checks if the edge is contained in the MST using the algorithm described in the first part.\\\\\nIf the result is positive, then the Kruskal's algorithm is executed and the MST is output, otherwise nothing is returned.\n\n\\begin{lstlisting}[language=Python, caption=Kruskal's algorithm]\ndef kruskal(self):\n\tparent = dict()\n\trank = dict()\n\n\tfor vertex in self.vertex:\n\t\tparent[vertex] = vertex\n\t\trank[vertex] = 0\n\n\tdef find(vertex):\n\t\tif parent[vertex] != vertex:\n\t\t\tparent[vertex] = find(parent[vertex])\n\t\treturn parent[vertex]\n\n\tdef union(vertex1, vertex2):\n\t\troot1 = find(vertex1)\n\t\troot2 = find(vertex2)\n\t\tif rank[root1] < rank[root2]:\n\t\t\tparent[root1] = root2\n\t\telif rank[root1] > rank[root2]:\n\t\t\tparent[root2] = root1\n\t\telse:\n\t\t\tparent[root2] = root1\n\t\t\trank[root2] += 1\n\n\tmst = Graph(\"directed\")\n\tminimum_spanning_tree = set()\n\tedges = self.sorted_by_weight()\n\tfor edge in edges:\n\t\tv1, v2, w = edge\n\t\tif find(v1) != find(v2):\n\t\t\tunion(v1, v2)\n\t\t\tminimum_spanning_tree.add(edge)\n\tfor node in self.get_nodes():\n\t\tmst.add_node(node)\n\tfor edge in minimum_spanning_tree:\n\t\tmst.add_edge(edge)\n\treturn mst\n\\end{lstlisting}\n\n\\appendix\n\\section{Code}\nThe whole implementation of the exercises are attached in the archive \\\\ \\textit{HW1-AD\\_Marco\\_Costa\\_1691388.tar.gz}\n\n\\end{document}", "meta": {"hexsha": "7203de2d72a98bd73029afc1c6bf97bc88567fb9", "size": 15387, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Old/Homework 1 (2018-2019)/Solution.tex", "max_stars_repo_name": "marcocosta96/AD-Homeworks", "max_stars_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Old/Homework 1 (2018-2019)/Solution.tex", "max_issues_repo_name": "marcocosta96/AD-Homeworks", "max_issues_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Old/Homework 1 (2018-2019)/Solution.tex", "max_forks_repo_name": "marcocosta96/AD-Homeworks", "max_forks_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.9115853659, "max_line_length": 379, "alphanum_fraction": 0.7130694742, "num_tokens": 4676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073802837477, "lm_q2_score": 0.7853085909370422, "lm_q1q2_score": 0.43239670597016605}}
{"text": "\\documentclass[12pt]{article}\n\\author{David Alves}\n\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{dirtytalk}\n\\usepackage[a4paper]{geometry}\n\\usepackage{forest}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{multicol}\n\\usepackage{nth}\n\\usepackage{relsize}\n\\usepackage{skak}\n\\usepackage{tikz}\n\\usepackage{tikz-qtree}\n\\usepackage{titling}\n\\usepackage{wrapfig}\n\\usepackage{xcolor}\n\n\\usetikzlibrary{decorations.pathreplacing}\n\\usetikzlibrary{patterns}\n\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\def\\multichoose#1#2{\\ensuremath{\\left(\\kern-.3em\\left(\\genfrac{}{}{0pt}{}{#1}{#2}\\right)\\kern-.3em\\right)}}\n\n\\newcommand{\\ts}[1]{\\textsuperscript{#1}}\n\n\\newcommand{\\ProblemStatement}[1]{\n\\subsection*{Problem Statement}\n#1\n\\subsection*{Solution}\n}\n\n% If uncommented, next line hides problem statements \n%\\renewcommand{\\ProblemStatement}[1]{}\n\n\n\\title{Math 142 Problem Set 11}\n\\author{David Alves}\n\\date{2016-11-10}\n\n\\begin{document}\n\\pagenumbering{gobble}\n\n\\begin{center}\n\\large \\thetitle \\\\\n\\theauthor \\\\\n\\thedate\n\\end{center}\n\n\\subsection*{Sources}\n\n    \\begin{itemize}\n    \\item http://tex.stackexchange.com and https://www.sharelatex.com for help with \\LaTeX\n    \\item Wikipedia for definition of Harmonic numbers\n    \\item Wolfram$\\vert$Alpha for help with factoring polynomials\n    \\end{itemize}\n\n\\section{Strange Dice (Optional)}\n\\ProblemStatement{\nHow many ways are there to make two fair 6-sided dice with natural number values (fair in the sense that each face lands up with same probability, but the sides can have freedom of numbers, including duplication) such that rolling them gives the same probability distribution on the sum of the two dice as two normal fair 6-sided dice? (for example, if we have a die with sides (0, 1, 2, 3, 4, 5) and another with sides (2,3,4,5,6,7), we get the same distribution as two normal dice (why?) but this is not legal as I wanted natural numbers)\n}\n\nThere are two ways: $(1,2,3,4,5,6)\\times2$ and $(1,2,2,3,3,4), (1,3,4,5,6,8)$.\n\\begin{proof}\nYou can represent normal die using the generating function $x + x^2 + x^3 + x^4 + x^5 + x^6$, since there is one way to get each possible value in $[1,6]$. Rolling two normal dice is represented by squaring the generating function as follows:\n\n\\begin{multline*}\n(x + x^2 + x^3 + x^4 + x^5 + x^6)^2 = \\\\x^2+2 x^3+3 x^4+4 x^5+5 x^6+6 x^7+5 x^8+4 x^9+3 x^{10}+2x^{11}+x^{12}\n\\end{multline*}\n\nThis question asks how many ways to factor this polynomial into two polynomials $A$ and $B$ such that:\n\\begin{enumerate}\n    \\item Every side has a natural number of dots, meaning that every term in both $A$ and $B$ is at least $x$.\n    \\item Each die has six sides, meaning that $A$ and $B$ both contain six terms. \n\\end{enumerate}\n\nWe first factor the polynomial:\n\\begin{align*}\n    (x + x^2 + x^3 + x^4 + x^5 + x^6)^2 &= \\left(x(1 + x + x^2 + x^3 + x^4 + x^5)\\right)^2\\\\\n    &= \\left(x\\frac{(x^6-1)}{x-1}\\right)^2\\\\\n    &= \\left(x\\frac{(x + 1)(x^2 - x + 1)(x-1)(x^2+x+1)}{x-1}\\right)^2\\\\\n    &= \\left(x(x + 1)(x^2 - x + 1)(x^2+x+1)\\right)^2\\\\\n    &= x^2(x + 1)^2(x^2 - x + 1)^2(x^2+x+1)^2\\\\\n\\end{align*}\n\nSince we know that every term in $A$ and $B$ is at least $x$, each of them needs to get one of the two $x$ factors. Trying each of the possible ways to distribute the remaining factors gives two valid arrangements:\n\\begin{multline*}\n    A = B = x(x+1)(x^2 - x + 1)(x^2+x+1) = (1,2,3,4,5,6)\\times 2 \\text{ (Normal dice)}\\\\\n    A = x(x+1)(x^2 - x + 1)^2(x^2+x+1), B = x(x+1)(x^2+x+1)\\\\\n    = (1,2,2,3,3,4), (1,3,4,5,6,8) \\text{ (Strange dice)}\\\\\n\\end{multline*}\n\\end{proof}\n\n\\section{Paths Through Trees}\n\\ProblemStatement{\nRecall that a tree has many definitions. Suppose you're only allowed to use the definition that there are $n - 1$ edges on $n$ vertices with no cycles. Prove that you can go from any vertex to any other vertex via a path (i.e. the tree is not separated into 2 parts inaccessible from each other).\n}\n\nLet a \\emph{connected component} be a set of vertices and edges such that you can get from any vertex in the component to any other vertex via some path which is a subset of that component's edges. Consider the edges of the graph in some arbitrary order. We will add the edges one at a time to the graph. Before any edges have been added, the graph consists of $n$ connected components each with one vertex. Now add the first edge to the graph, which connects two separate connected components (each with 1 vertex), leaving $n-1$ connected components. Each additional edge added to the graph connects two vertices in separate connected components, turning them into a single connected component. It must connect two vertices in different connected components because if the edge connected some $u,v$ inside the same connected component then there would be two paths from $u$ to $v$: One using the new edge and one through the other edges in that connected component, which contradicts our statement that there are no cycles. Thus each edge added to the graph reduces the number of connected components by one, so after adding all $n-1$ edges there is only one connected component, and thus you can get from any vertex to any other vertex via a path.\n\n\n\\section{Triangle Game (Optional)}\n\\ProblemStatement{\nDescribe (and prove) an optimal strategy of playing the triangle game we played in class for n = 5 vertices.\n}\n\nBelow is a diagram showing a strategy for Player 1 that can force a win regardless of how Player 2 plays. Solid edges are Player 1 moves, while dashed edges are Player 2 moves. Only one graph per isomorphic group is shown.\n\\colorlet{lightred}{red!45}\n\n\\begin{center}\n\\begin{tikzpicture}\n    \\node[shape=circle,draw=black] (A1) at (4+0,24+1) {};\n    \\node[shape=circle,draw=black] (B1) at (4+.951,24+.309) {};\n    \\node[shape=circle,draw=black] (C1) at (4+.588,24-.809) {};\n    \\node[shape=circle,draw=black] (D1) at (4-.588,24-.809) {};\n    \\node[shape=circle,draw=black] (E1) at (4-.951,24+.309) {} ;\n    \\path [-,line width=1pt,color=blue] (A1) edge node[left] {} (B1) node[yshift=-6.5em,color=black] {Initial Move};\n    \n    \\draw [->,line width=2.5,black!25] (2.5,22.5) -- (1.5,21.5);    \n    \\node[shape=circle,draw=black] (A2) at (0+0,20+1) {};\n    \\node[shape=circle,draw=black] (B2) at (0+.951,20+.309) {};\n    \\node[shape=circle,draw=black] (C2) at (0+.588,20-.809) {};\n    \\node[shape=circle,draw=black] (D2) at (0-.588,20-.809) {};\n    \\node[shape=circle,draw=black] (E2) at (0-.951,20+.309) {} ;\n    \\path [-,line width=1pt] (A2) edge node[left] {} (B2) node[yshift=-6.5em] {\\parbox{4.5cm}{Player 2's move shares a vertex with initial move}};\n    \\path [-,line width=1pt,style=dashed,color=blue] (A2) edge node[left] {} (C2);\n    \n    \\draw [->,line width=2.5,black!25] (5.5,22.5) -- (6.5,21.5);\n    \\node[shape=circle,draw=black] (A3) at (8+0,20+1) {};\n    \\node[shape=circle,draw=black] (B3) at (8+.951,20+.309) {};\n    \\node[shape=circle,draw=black] (C3) at (8+.588,20-.809) {};\n    \\node[shape=circle,draw=black] (D3) at (8-.588,20-.809) {};\n    \\node[shape=circle,draw=black] (E3) at (8-.951,20+.309) {} ;\n    \\path [-,line width=1pt] (A3) edge node[left] {} (B3) node[yshift=-6.5em] {\\parbox{5.5cm}{Player 2's move does not share a vertex with initial move}};\n    \\path [-,line width=1pt,style=dashed,color=blue] (D3) edge node[left] {} (C3);\n\n    \\draw [->,line width=2.5,black!25] (0,17.5) -- (0,16.5);\n    \\node[shape=circle,draw=black] (A4) at (0+0,15+1) {};\n    \\node[shape=circle,draw=black] (B4) at (0+.951,15+.309) {};\n    \\node[shape=circle,draw=black] (C4) at (0+.588,15-.809) {};\n    \\node[shape=circle,draw=black] (D4) at (0-.588,15-.809) {};\n    \\node[shape=circle,draw=black] (E4) at (0-.951,15+.309) {} ;\n    \\path [-,line width=1pt] (A4) edge node[left] {} (B4) node[yshift=-6.5em] {};\n    \\path [-,line width=1pt,style=dashed] (A4) edge node[left] {} (C4);\n    \\path [-,line width=1pt,color=blue] (A4) edge node[left] {} (E4);\n    \n    \\draw [->,line width=2.5,black!25] (8,17.5) -- (8,16.5);\n    \\node[shape=circle,draw=black] (A5) at (8+0,15+1) {};\n    \\node[shape=circle,draw=black] (B5) at (8+.951,15+.309) {};\n    \\node[shape=circle,draw=black] (C5) at (8+.588,15-.809) {};\n    \\node[shape=circle,draw=black] (D5) at (8-.588,15-.809) {};\n    \\node[shape=circle,draw=black] (E5) at (8-.951,15+.309) {} ;\n    \\path [-,line width=1pt] (A5) edge node[left] {} (B5) node[yshift=-6.5em] {};\n    \\path [-,line width=1pt,style=dashed] (D5) edge node[left] {} (C5);\n    \\path [-,line width=1pt,color=blue] (A5) edge node[left] {} (E5);\n    \n    \\draw [->,line width=2.5,black!25] (0,13) -- (0,12);\n    \\node[shape=circle,draw=black] (A6) at (0+0,10+1) {};\n    \\node[shape=circle,draw=black] (B6) at (0+.951,10+.309) {};\n    \\node[shape=circle,draw=black] (C6) at (0+.588,10-.809) {};\n    \\node[shape=circle,draw=black] (D6) at (0-.588,10-.809) {};\n    \\node[shape=circle,draw=black] (E6) at (0-.951,10+.309) {} ;\n    \\path [-,line width=1pt] (A6) edge node[left] {} (B6) node[yshift=-6.3em] {Forced move for player 2};\n    \\path [-,line width=1pt,style=dashed] (A6) edge node[left] {} (C6);\n    \\path [-,line width=1pt] (A6) edge node[left] {} (E6);\n    \\path [-,line width=1pt,style=dashed,color=blue] (E6) edge node[left] {} (B6);\n\n    \\draw [->,line width=2.5,black!25] (8,13) -- (8,12);    \n    \\node[shape=circle,draw=black] (A7) at (8+0,10+1) {};\n    \\node[shape=circle,draw=black] (B7) at (8+.951,10+.309*1.3) {};\n    \\node[shape=circle,draw=black] (C7) at (8+.588,10-.809*1.3) {};\n    \\node[shape=circle,draw=black] (D7) at (8-.588,10-.809*1.3) {};\n    \\node[shape=circle,draw=black] (E7) at (8-.951,10+.309*1.3) {} ;\n    \\path [-,line width=1pt] (A7) edge node[left] {} (B7) node[yshift=-6.3em] {Forced move for player 2};\n    \\path [-,line width=1pt,style=dashed] (D7) edge node[left] {} (C7);\n    \\path [-,line width=1pt] (A7) edge node[left] {} (E7);\n    \\path [-,line width=1pt,style=dashed,color=blue] (E7) edge node[left] {} (B7);\n    \n    \\draw [->,line width=2.5,black!25] (0,7.75) -- (0,6.75);\n    \\node[shape=circle,draw=black] (A8) at (0+0,5+1) {};\n    \\node[shape=circle,draw=black] (B8) at (0+.951,5+.309) {};\n    \\node[shape=circle,draw=black] (C8) at (0+.588,5-.809) {};\n    \\node[shape=circle,draw=black] (D8) at (0-.588,5-.809) {};\n    \\node[shape=circle,draw=black] (E8) at (0-.951,5+.309) {} ;\n    \\path [-,line width=1pt] (A8) edge node[left] {} (B8) node[yshift=-7em] {\\parbox{7.1cm}{Player 1 has forced a win because Player 2 can only play one of the moves in red; Player 1 will use the other to win}};\n    \\path [-,line width=1pt,style=dashed] (A8) edge node[left] {} (C8);\n    \\path [-,line width=1pt] (A8) edge node[left] {} (E8);\n    \\path [-,line width=1pt,style=dashed] (E8) edge node[left] {} (B8);\n    \\path [-,line width=1pt,color=blue] (A8) edge node[left] {} (D8);\n    \\path [-,line width=1pt,style=dashed,color=lightred] (E8) edge node[left] {} (D8);\n    \\path [-,line width=1pt,style=dashed,color=lightred] (B8) edge node[left] {} (D8);\n\n    \\draw [->,line width=2.5,black!25] (8,7.75) -- (8,6.75);\n    \\node[shape=circle,draw=black] (A9) at (8+0,5+1) {};\n    \\node[shape=circle,draw=black] (B9) at (8+.951,5+.309) {};\n    \\node[shape=circle,draw=black] (C9) at (8+.588,5-.809) {};\n    \\node[shape=circle,draw=black] (D9) at (8-.588,5-.809) {};\n    \\node[shape=circle,draw=black] (E9) at (8-.951,5+.309) {} ;\n    \\path [-,line width=1pt] (A9) edge node[left] {} (B9) node[yshift=-7em] {\\parbox{7.1cm}{Player 1 has forced a win because Player 2 can only play one of the moves in red; Player 1 will use the other to win}};\n    \\path [-,line width=1pt,style=dashed] (D9) edge node[left] {} (C9);\n    \\path [-,line width=1pt] (A9) edge node[left] {} (E9);\n    \\path [-,line width=1pt,style=dashed] (E9) edge node[left] {} (B9);\n    \\path [-,line width=1pt,color=blue] (A9) edge node[left] {} (D9);\n    \\path [-,line width=1pt,style=dashed,color=lightred] (E9) edge node[left] {} (D9);\n    \\path [-,line width=1pt,style=dashed,color=lightred] (B9) edge node[left] {} (D9);\n\\end{tikzpicture}\n\\end{center}\n\n\n\\section{Sum of Choices}\n\\ProblemStatement{\n    Calculate $\\sum_{k=1}^n \\binom{k}{m} \\frac{1}{k}$.\n}\n\n\\[\n    \\sum_{k=1}^n \\binom{k}{m} \\frac{1}{k} = \n    \\begin{cases}\n        H_n &: m = 0\\\\\n        \\frac{1}{m} \\binom{n}{m} &: m \\ge 1\\\\\n    \\end{cases}\n\\]\n\n\\begin{proof}\nFor $m=0$, we have $\\sum_{k=1}^n \\frac{1}{k} = H_n$, the nth harmonic number by definition.\nFor $m \\ge 1$,\n\\begin{align*}\n    \\sum_{k=1}^n \\binom{k}{m} \\frac{1}{k} &=\\sum_{k=1}^n \\frac{k!}{m!(k-m)!} \\frac{1}{k}\\\\\n    &=\\sum_{k=1}^n \\frac{(k-1)!}{m!(k-m)!}\\\\\n    &=\\frac{1}{m} \\sum_{k=1}^n \\frac{(k-1)!}{(m-1)!(k-m)!}\\\\\n    &=\\frac{1}{m} \\sum_{k=1}^n \\binom{k-1}{m-1}\n\\end{align*}\n\nFrom previous work, we know that the sum of diagonal elements in Pascal's triangle is $\\sum_{a=0}^b \\binom{a}{c} = \\binom{b+1}{c+1}$, thus by setting $a=k-1$, $c=m-1$, $b=n-1$ we obtain $\\sum_{k=1}^n \\binom{k-1}{m-1}=\\binom{n}{m}$ and thus $\n    \\sum_{k=1}^n \\binom{k}{m} \\frac{1}{k} = \\frac{1}{m} \\binom{n}{m}: m \\ge 1$.\n\\end{proof}\n\n\n\n\\section{Counting Functions}\n\\ProblemStatement{\nHow many functions $f : [n] \\rightarrow [n]$ are there such that for all $i < j$, we have $f(i) \\leq f(j)$?\n}\n\nThere are $\\binom{2n-1}{n}$ functions on $[n] \\rightarrow [n]$ such that for all $i < j$, $f(i) \\leq f(j)$. \n\n\\begin{proof}\nThere is a bijection between these functions and paths from $(0, 0)$ to ${(n, n-1)}$ which consist of single steps $(+1, 0)$ or $(0, +1)$. To construct such a path from a function, do the following:\n\\begin{enumerate}\n    \\item For each value $a$ in the domain of $f$, draw a step from at $(a-1, f(a)-1)$ to $(a, f(a)-1)$. \n    \\item Draw vertical lines to connect the horizontal steps, as needed.\n    \\item Draw vertical lines to connect $(0,0)$ to $(0, f(1)-1)$ and $(n, f(n)-1)$ to $(n,n-1)$, as needed.\n\\end{enumerate}\n\nAdditionally, any path from $(0,0)$ to $(n,n-1)$ consisting of only steps $(+1, 0)$ or $(0, +1)$ has a unique corresponding function $f(i)$ defined by $f(i) = 1 + y-$coordinate of the step from $x=i$ to $x=i+1$. Thus there's a bijection between these paths and these functions. We know from previous work that the number of such paths is equal to $\\binom{2n-1}{n}$ since it is equivalent to having a list made up of $2n-1$ instructions, $n$ of which are \\say{go right} while the rest are \\say{go up}.\n\\end{proof}\n\\newcommand{\\bijectpath}[3]{\\scalebox{.8}{\n\\begin{tikzpicture}\n\\draw[step=1.0,black,thin,color=black,opacity=.35] (0,0) grid (3,2);\n\\draw [-,line width=1pt] (0,0) -- (0,#1-1) --\n    (1, #1-1) node[shape=circle,fill=black,minimum width=.2cm,inner sep=0pt] {} -- \n    (1, #2-1) --\n    (2, #2-1) node[shape=circle,fill=black,minimum width=.2cm,inner sep=0pt] {} -- \n    (2, #3-1) --\n    (3, #3-1)node[shape=circle,fill=black,minimum width=.2cm,inner sep=0pt] {} -- \n    (3, 2);\n\\node [above] at (5.85,-.5) {\\parbox{3em}{\n    \\begin{align*}\n    \\iff f(x) = \n    \\begin{cases}\n    #1&: x=1\\\\\n    #2&: x=2\\\\\n    #3&: x=3\\\\\n\\end{cases}\n    \\end{align*}\n}};\n\\end{tikzpicture}\n}\n}\n\n\\noindent\\ignorespacesafterend\n\\bijectpath{1}{1}{1} \\hspace{2em} \\bijectpath{1}{1}{2}\\\\\n\\bijectpath{1}{1}{3} \\hspace{2em} \\bijectpath{1}{2}{2}\\\\\n\\bijectpath{1}{2}{3} \\hspace{2em} \\bijectpath{1}{3}{3}\\\\\n\\bijectpath{2}{2}{2} \\hspace{2em} \\bijectpath{2}{2}{3}\\\\\n\\bijectpath{2}{3}{3} \\hspace{2em} \\bijectpath{3}{3}{3}\n\n\n\n\n\n\\section{Time Spent \\& Thoughts}\nThis was really time consuming. I either need to stop trying to do the optional problems or not attempt to take this class while working full time. :) I probably spent about 15 hours on this assignment. I enjoyed problems 1, 3, and 5 quite a bit. Problem 4 took a long time to figure out and wasn't very interesting, although it's probably good practice.\n\\end{document}\n", "meta": {"hexsha": "2a31a3519f81092bcbb3f7e835bea3a5b653dd31", "size": 15790, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "math142_ps11.tex", "max_stars_repo_name": "dalves/combinatorics", "max_stars_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T14:26:36.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T14:26:36.000Z", "max_issues_repo_path": "math142_ps11.tex", "max_issues_repo_name": "dalves/combinatorics", "max_issues_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "math142_ps11.tex", "max_forks_repo_name": "dalves/combinatorics", "max_forks_repo_head_hexsha": "059a05b548401df59099a6ba93109f736e0b9ed7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.8093645485, "max_line_length": 1249, "alphanum_fraction": 0.6407219759, "num_tokens": 5849, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.4323966888548266}}
{"text": "  \n\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tcolorbox, bm, tikz, pgfplots}\n\\pgfplotsset{compat = 1.16}\n\n\\everymath{\\displaystyle}\n\n\\title{Radical Equations and Inequalities}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\maketitle\n\\end{frame}\n\n\\section{Solve radical equations}\n\n\\begin{frame}{Solving Radical Equations}\nWhen solving radical equations, we want to try our best to isolate the radical on one side of the equation (if possible). \\newline\\\\\t\\pause\n\nThen we can raise both sides to the power that is the root of the radical.    \\newline\\\\\t\\pause\n\nHowever, sometimes you may end up with extraneous solutions.\n\\end{frame}\n\n\\begin{frame}{Example 1}\nSolve each. Remember to check for extraneous solutions.\t\\newline\\\\\n(a) \\quad $\\sqrt{5x+1} = 4$\n\\begin{align*}\n\\onslide<2->{\\sqrt{5x+1} &= 4} \\\\[6pt]\n\\onslide<3->{\\left(\\sqrt{5x+1}\\right)^2 &= 4^2} \\\\[6pt]\n\\onslide<4->{5x+1 &= 16} \\\\[6pt]\n\\onslide<5->{x &= 3}\n\\end{align*}\n\\onslide<6->{Check: $\\sqrt{5(3)+1} = 4?$}\n\\onslide<7->{\\quad Yes}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $\\sqrt{8-x} + 7 = 10$\n\\begin{align*}\n\\onslide<2->{\\sqrt{8-x} + 7 &= 10} \\\\[6pt]\n\\onslide<3->{\\sqrt{8-x} &= 3} \\\\[6pt]\n\\onslide<4->{8-x &= 9} \\\\[6pt]\n\\onslide<5->{x &= -1}\n\\end{align*}\n\\onslide<6->{Check: $\\sqrt{8-(-1)} + 7 = 10?$}\n\\onslide<7->{\\quad Yes}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $\\sqrt[3]{x-10} = 3$\n\\begin{align*}\n\\onslide<2->{\\sqrt[3]{x-10} &= 3} \\\\[6pt]\n\\onslide<3->{\\left(\\sqrt[3]{x-10}\\right)^3 &= 3^3} \\\\[6pt]\n\\onslide<4->{x - 10 &= 27} \\\\[6pt]\n\\onslide<5->{x &= 37}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(d) \\quad $3\\sqrt{x}+12=9$\n\\begin{align*}\n\\onslide<2->{3\\sqrt{x}+12 &= 9} \\\\[6pt]\n\\onslide<3->{3\\sqrt{x} &= -3} \\\\[6pt]\n\\onslide<4->{\\sqrt{x} &= -1} \\\\[6pt]\n\\onslide<5->{x &= 1}\n\\end{align*}\n\\onslide<6->{Check: $3\\sqrt{1}+12=9?$}\n\\onslide<7->{\\quad No}\t\\newline\\\\\n\\onslide<8->{No Solution $\\varnothing$}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(e) \\quad $\\sqrt{2x-7}=\\sqrt{3x-12}$\n\\begin{align*}\n\\onslide<2->{\\sqrt{2x-7} &= \\sqrt{3x-12}} \\\\[6pt]\n\\onslide<3->{2x - 7 &= 3x - 12} \\\\[6pt]\n\\onslide<4->{x &= 5}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(f) \\quad $x-3=\\sqrt{x-1}$\n\\begin{align*}\n\\onslide<2->{x-3 &= \\sqrt{x-1}} \\\\[6pt]\n\\onslide<3->{(x-3)^2 &= \\left(\\sqrt{x-1}\\right)^2} \\\\[6pt]\n\\onslide<4->{x^2-6x+9 &= x-1} \\\\[6pt]\n\\onslide<5->{x^2 - 7x + 10 &= 0} \\\\[6pt]\n\\onslide<6->{(x-2)(x-5) &= 0} \\\\[6pt]\n\\onslide<7->{x &= 2, 5}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1 \\quad $x-3=\\sqrt{x-1}$}\n\\[x = 2 \\quad x=5\\]\nCheck:\t\\newline\\\\\n\\onslide<2->{$x=2$ is extraneous} \\newline\\\\\n\\onslide<3->{$x=5$ is valid} \\newline\\\\\n\\onslide<4->{Final answer: $x=5$}\n\\end{frame}\n\n\\section{Solve equations with rational exponents}\n\n\\begin{frame}{Equations with Rational Exponents}\nWhen dealing with rational exponents, recall that raising a power to a power will result in multiplying the exponents together. \\newline\\\\\t\\pause\n\nUsing this knowledge, we can isolate the radicand by raising both sides of the equation to the \\underline{reciprocal} of the exponent.\n\\end{frame}\n\n\\begin{frame}{Example 2}\nSolve each of the following. Remember to check for extraneous solutions.\t\\newline\\\\\n(a) \t\\quad $x^{2/3} = 3$\n\\begin{align*}\n\\onslide<2->{x^{2/3} &= 3} \\\\[8pt]\n\\onslide<3->{\\left(x^{2/3}\\right)^{3/2} &= 3^{3/2}} \\\\[8pt]\n\\onslide<4->{x &= 3^{3/2}} \\\\[8pt]\n\\onslide<5->{&= \\sqrt{27}} \\\\[8pt]\n\\onslide<6->{&= 3\\sqrt{3}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(b) \t\\quad $\\left(x-1\\right)^{-2/3} = 1$\n\\begin{align*}\n\\onslide<2->{\\left(x-1\\right)^{-2/3} &= 1} \\\\[8pt]\n\\onslide<3->{\\left(\\left(x-1\\right)^{-2/3}\\right)^{-3/2} &= 1^{-3/2}} \\\\[8pt]\n\\onslide<4->{x-1 &= 1} \\\\[8pt]\n\\onslide<5->{x &= 2}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(c) \t\\quad $\\left(x+2\\right)^{3/2} = -1$\n\\begin{align*}\n\\onslide<2->{\\left(x+2\\right)^{3/2} &= -1} \\\\[8pt]\n\\onslide<3->{\\left(\\left(x+2\\right)^{3/2}\\right)^{2/3} &= (-1)^{2/3}} \\\\[8pt]\n\\onslide<4->{x+2 &= 1} \\\\[8pt]\n\\onslide<5->{x &= -1}\n\\end{align*}\n\\onslide<6->{\\[\\text{No solution } \\varnothing \\]}\n\\end{frame}\n\n\\section{Solve radical inequalities}\n\n\\begin{frame}{Solving Radical Inequalities}\nWhen solving inequalities, use the same techniques as solving the equations, then use number lines and test values to solve inequalities.  \\newline\\\\\t\\pause\n\nThis gives us the advantage of solving any inequality after learning how to solve its equation form.\t\\newline\\\\\t\\pause\n\n\\alert{\\textbf{Important: }} Remember, when dealing with \\textbf{even roots}, the domain of the radicand is $\\geq 0$.\n\\end{frame}\n\n\\begin{frame}{Example 3}\nSolve each of the following and graph your solution on a number line.\t\\newline\\\\\n(a)\t\\quad\t$\\sqrt{x-3} - 3 < 4$\n\\begin{align*}\n\\onslide<2->{\\sqrt{x-3} - 3 &= 4} \\\\[6pt]\n\\onslide<3->{\\sqrt{x-3} &= 7} \\\\[6pt]\n\\onslide<4->{x-3 &= 49} \\\\[6pt]\n\\onslide<5->{x &= 52}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 3\t\\quad\t$\\sqrt{x-3} - 3 < 4$}\nCritical value of $x$ is 52.\t\\newline\\\\\n\\onslide<2->{For $\\sqrt{x-3}$, $x-3$ must be $\\geq 0$, so $x \\geq 3$}\t\\newline\\\\\n\\onslide<3->{\n\\begin{center}\n\\begin{tikzpicture}\n\\draw [<->] (-2,0) -- (2,0);\n\\draw (1,0.15) -- (1,-0.15) node [below] {$52$};\n\\draw (-1,0.15) -- (-1,-0.15) node [below] {$3$};\n\\onslide<4->{\\draw[color=blue,fill=white] (1,0) circle [radius=2.5pt];\n\\draw[fill=blue,color=blue] (-1,0) circle [radius=2.5pt];}\n\\onslide<5->{\\draw[color=blue, ultra thick, shorten >= 2.5pt, shorten >= 2.5pt] (-1,0) -- (1,0);}\n\\end{tikzpicture}\n\\end{center}\n}\n\\onslide<6->{\\[3 \\leq x < 52\\]}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(b)\t\\quad\t$\\sqrt[3]{2x+3} \\geq \\sqrt[3]{x+12}$\n\\begin{align*}\n\\onslide<2->{\\sqrt[3]{2x+3} &= \\sqrt[3]{x+12}} \\\\[6pt]\n\\onslide<3->{2x+3 &= x+12} \\\\[6pt]\n\\onslide<4->{x &= 9}\n\\end{align*}\n\\onslide<5->{\n\\begin{center}\n\\begin{tikzpicture}\n\\draw [<->] (-2,0) -- (2,0);\n\\draw (0,0.15) -- (0,-0.15) node [below] {$9$};\n\\onslide<6->{\\draw[color=blue,fill=blue] (0,0) circle [radius=2.5pt];}\n\\onslide<7->{\\draw[color=blue,ultra thick, ->] (0,0) -- (2,0);}\n\\end{tikzpicture}\n\\end{center}\n}\n\\onslide<8->{\\[x \\geq 9 \\]}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(c)\t\\quad\t$\\sqrt{2x-1} \\leq 2x-1$\n\\begin{align*}\n\\onslide<2->{\\sqrt{2x-1} &= 2x-1} \\\\[6pt]\n\\onslide<3->{\\left(\\sqrt{2x-1}\\right)^2 &= (2x-1)^2} \\\\[6pt]\n\\onslide<4->{2x-1 &= 4x^2 - 4x + 1} \\\\[6pt]\n\\onslide<5->{4x^2 - 6x + 2 &= 0} \\\\[6pt]\n\\onslide<6->{x &= \\frac{1}{2}, \\quad 1}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 3 \\quad $\\sqrt{2x-1} \\leq 2x-1$}\n\\begin{center}\n\\begin{tikzpicture}\n\\draw[<->] (-2.5,0) -- (2.5,0);\n\\draw (-1,0.15) -- (-1,-0.15) node [below] {$\\frac{1}{2}$};\n\\draw (1,0.15) -- (1,-0.15) node [below] {$1$};\n\\onslide<2->{\\draw[color=blue,fill=blue] (-1,0) circle [radius=2.5pt];\n\t\t\t\t\t\\draw[color=blue,fill=blue] (1,0) circle [radius=2.5pt];\n}\n\\onslide<3->{\\draw[color=blue, ultra thick, ->] (1,0) -- (2.5,0);}\n\\end{tikzpicture}\n\\end{center}\n\\onslide<4->{\\[x = \\frac{1}{2} \\quad \\text{or} \\quad x \\geq 1\\]}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "a463f78aa22c735dfc61508f2cc2dfe890ecb9bd", "size": 7223, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Radical_Equations_and_Inequalities(BEAMER).tex", "max_stars_repo_name": "BryanBain/HA2_BEAMER", "max_stars_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Radical_Equations_and_Inequalities(BEAMER).tex", "max_issues_repo_name": "BryanBain/HA2_BEAMER", "max_issues_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Radical_Equations_and_Inequalities(BEAMER).tex", "max_forks_repo_name": "BryanBain/HA2_BEAMER", "max_forks_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:45.000Z", "avg_line_length": 29.6024590164, "max_line_length": 156, "alphanum_fraction": 0.6101342932, "num_tokens": 3101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352403, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.43239668885482657}}
{"text": "\\vssub\n\\subsection{~Simple ice blocking ({\\code IC0})} \\label{sub:num_ice}\n\\opthead{IC0}{\\ws}{H. L. Tolman} %\\conthead{\\ws}{H. L. Tolman}\n\n\\noindent\nIce covered sea is considered as `land' in \\ws, assuming zero wave energy and\nboundary conditions at ice edges are identical to boundary conditions at shore\nlines. Grid points are taken out of the calculation if the ice concentration\nbecomes larger than a user-defined concentration. If the ice concentration\ndrops below its critical value, the corresponding grid point is\n`re-activated'. The spectrum is then initialized with a PM spectrum based on\nthe local wind direction with a peak frequency corresponding to the\nsecond-highest discrete frequency in the grid. A low energy spectrum is used to\nassure that spectra are realistic, even for shallow coastal points.\n\nThe above discontinuous ice treatment represents the default model setting in\n\\ws. In the framework of the modeling of unresolved obstacles as discussed in\n\\para\\ref{sub:num_obst}, a continuous method is also available, as given by\n\\cite{tol:OMOD03a}. In this method, a user-defined critical ice concentration\nat which obstruction begins ($\\epsilon_{c,0}$) and is complete\n($\\epsilon_{c,n}$) are given (defaults are $\\epsilon_{c,0} = \\epsilon_{c,n} =\n0.5$, i.e., discontinuous treatment of ice). From these critical\nconcentrations, corresponding decay length scales are calculated as\n\n\\begin{equation}\nl_0 = \\epsilon_{c,0} \\min ( \\Delta x , \\Delta y )\n, \\label{eq:l0}\n\\end{equation}\n\\begin{equation}\nl_n = \\epsilon_{c,n} \\min ( \\Delta x , \\Delta y )\n, \\label{eq:ln}\n\\end{equation}\n\n\\noindent\nfrom which cell transmissions in $x$ and $y$ ($\\alpha_x$ and $\\alpha_y$,\nrespectively) are calculated as\n\n\\begin{equation}\n\\alpha_x = \\left \\{ \\begin{array}{ccl}\n 1 & \\mbox{for} & \\epsilon \\Delta x < l_0 \\\\\n 0 & \\mbox{for} & \\epsilon \\Delta x > l_n \\\\\n\\frac{l_n - \\epsilon \\Delta x}{l_n - l_0} & \\multicolumn{2}{c}{\\mbox{otherwise}} \n\\end{array} \\right .\n\\:\\:\\: , \\:\\:\\:\n\\alpha_y = \\left \\{ \\begin{array}{ccl}\n 1 & \\mbox{for} & \\epsilon \\Delta y < l_0 \\\\\n 0 & \\mbox{for} & \\epsilon \\Delta y > l_n \\\\\n\\frac{l_n - \\epsilon \\Delta y}{l_n - l_0} & \\multicolumn{2}{c}{\\mbox{otherwise}} \n\\end{array} \\right .\n\\:\\:\\: . \\label{eq:ice_0} \n\\end{equation}\n\n\\noindent\nDetails of this model can be found in \\cite{tol:OMOD03a}.\n\nUpdating of the ice map within the model takes place at the discrete model\ntime approximately half way in between the valid times of the old and new ice\nmaps. The map will not be updated, if the time stamps of both ice fields are\nidentical.\n\nThe above description pertains to the switch {\\code IC0}. Note that either ice transmissions for propagation ({\\code IC0}), or ice as a source term can be used ({\\code IC1}, {\\code IC2}, {\\code IC3}), but not both approaches at the same time.\n", "meta": {"hexsha": "195c777e056e4f1eccf8d9167014e415a7a1abbf", "size": 2808, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/num/ice.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/num/ice.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/num/ice.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 45.2903225806, "max_line_length": 242, "alphanum_fraction": 0.7254273504, "num_tokens": 823, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085758631159, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4323966860882217}}
{"text": "% -*- mode:Noweb; noweb-code-mode: sml-mode -*-% ===> this file was generated automatically by noweave --- better not edit it\n\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{noweb}\n\\usepackage{hyperref}\n\\date{}\n\\author{}\n\n\\title{COL765 - Assignment 2}\n\\author{Nilaksh Agarwal \\\\\n                2015PH10813}\n\\date{}\n\\begin{document}\n\\maketitle\n\\section{Introduction}\nThe purpose of this assignment was to develop a module to regenerate a Tree, given it's in-order traversal. I have used the document \\href{http://www.cse.iitd.ernet.in/~sak/courses/ilfp/recover.pdf}{Rambling Through Woods on a Sunny Morning} for reference and also used the Binary Tree signature and structure given in the same.\n\n\\section{The complications with inorder traversal}\n\nUnlike preorder or postorder traversals, inorder traversals have no structural information in them. For example, in a preorder traversal, all values occurring to the right of a given node, are the descendants of that node. Similarly, to the left for postorder traversals. \\\\\n\nIn an inorder traversal however, there is no such structural information available, and moreover, there is some noise added to this as well. \\\\\n\nThis is clearly visualized with the 3 following trees, which all have the same inorder traversal: \\\\[0.5cm]\n\\begin{center}\n        \\includegraphics[width=14cm]{Inorder_wrong.jpg}\n\\end{center}\n\n\\section{The Binary Tree Signature}\n\nHere we define a basic datatype for bintree:\n\n\\nwfilename{2015PH10813.nw}\\nwbegincode{1}\\sublabel{NW6NVqj-4XyAA2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-4XyAA2-1}}}\\moddef{Node~{\\nwtagstyle{}\\subpageref{NW6NVqj-4XyAA2-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-4WBYwn-1}\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n        datatype 'a bintree = \n                Empty \n                | Node of 'a * 'a bintree * 'a bintree\n\\nwused{\\\\{NW6NVqj-4WBYwn-1}\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\nWe also define a option datatype, since we intend to store the empty Leaf nodes as well\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW6NVqj-4JPyOG-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-4JPyOG-1}}}\\moddef{Option~{\\nwtagstyle{}\\subpageref{NW6NVqj-4JPyOG-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-4WBYwn-1}\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n        datatype 'a option = NONE | SOME of 'a\n\\nwused{\\\\{NW6NVqj-4WBYwn-1}\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\nWe define our regular preorder \\& postorder functions like in the \\href{http://www.cse.iitd.ernet.in/~sak/courses/ilfp/recover.pdf}{document}. Here \\textbf{'a option list} implies a list which can contain \\textbf{NONE} in case of Empty subtree or \\textbf{SOME of value}\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW6NVqj-azPlp-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-azPlp-1}}}\\moddef{PrePostSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-azPlp-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-4WBYwn-1}}\\nwenddeflinemarkup\n        val preorder : 'a bintree ->  'a option list\n        val postorder : 'a bintree -> 'a option list\n\\nwused{\\\\{NW6NVqj-4WBYwn-1}}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\nHowever, for inorder, this is not enough. We need some addition \\textit{Cosmetic Sugar} to gain the missing structural information in this traversal. Hence, we include the depth of a node defined to be 0 for the root node, and the depth of any child is 1 + the depth of their parent. \\\\\nSo, our node now contains a Tuple (value, depth) which is returned from the inorder traversal. Now we can define the signatures of the inorder and inorderInverse\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW6NVqj-2NTUdd-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2NTUdd-1}}}\\moddef{InSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-2NTUdd-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-4WBYwn-1}}\\nwenddeflinemarkup\n        val inorder : 'a bintree -> ('a option * int) list\n        val inorderInverse : ('a option * int) list -> 'a bintree\n\\nwused{\\\\{NW6NVqj-4WBYwn-1}}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\nOne last function we use to check if two given trees are equal. For this, we find their preorder and postorder traversals, and check their equality. \n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW6NVqj-3QvoFw-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-3QvoFw-1}}}\\moddef{equalSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-3QvoFw-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-4WBYwn-1}}\\nwenddeflinemarkup\n        val checkTrees : ''a bintree * ''a bintree -> bool\n\\nwused{\\\\{NW6NVqj-4WBYwn-1}}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\nNow we can put everything together in our Signature\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW6NVqj-4WBYwn-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-4WBYwn-1}}}\\moddef{bintreeSignature-complete~{\\nwtagstyle{}\\subpageref{NW6NVqj-4WBYwn-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\nsignature BINTREE = \nsig\n\\LA{}Node~{\\nwtagstyle{}\\subpageref{NW6NVqj-4XyAA2-1}}\\RA{}\n\\LA{}Option~{\\nwtagstyle{}\\subpageref{NW6NVqj-4JPyOG-1}}\\RA{}\n        exception Empty_bintree;\n        exception InvalidTraversal;\n\\LA{}PrePostSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-azPlp-1}}\\RA{}\n\\LA{}InSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-2NTUdd-1}}\\RA{}\n\\LA{}equalSig~{\\nwtagstyle{}\\subpageref{NW6NVqj-3QvoFw-1}}\\RA{}\nend\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\n\\section{The Binary Tree Structure}\n\nSimilarly to the \\href{http://www.cse.iitd.ernet.in/~sak/courses/ilfp/recover.pdf}{document} we define the preorder \\& postorder functions using the tail recursive forms. \\\\\n\nWe use \\textbf{NONE} to indicate empty nodes and \\textbf{SOME of val}\nto indicate nodes with value \\textbf{val}\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NW6NVqj-FYIyT-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-FYIyT-1}}}\\moddef{preorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-FYIyT-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n    local \n        fun pre(Empty, Llist) = NONE::Llist\n                | pre(Node(N,Ltree, Rtree),Llist) = \n                let\n                        val Mlist = pre(Rtree,Llist)\n                        val Nlist = pre(Ltree,Mlist)\n                in\n                        SOME N :: Nlist\n                end\n        in \n                fun preorder T = pre(T,[])\n        end\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NW6NVqj-2drSLa-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2drSLa-1}}}\\moddef{postorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-2drSLa-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n    local \n        fun post(Empty, Llist) = NONE::Llist\n                | post(Node(N,Ltree, Rtree),Llist) = \n                let\n                        val Mlist = post(Rtree,SOME N::Llist)\n                        val Nlist = post(Ltree,Mlist)\n                in\n                        Nlist\n                end\n        in \n                fun postorder T = post(T,[])\n        end\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\nIn inorder however, we need to store the depth of the node as well, since we are unable to figure out any strucural information from the traversal\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NW6NVqj-N7IVZ-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-N7IVZ-1}}}\\moddef{inorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-N7IVZ-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n        local \n        fun ino(Empty, Llist,i) = (NONE,i)::Llist\n                | ino(Node(N,Ltree, Rtree),Llist,i) = \n                let\n                        val Mlist = ino(Rtree,Llist,i+1)\n                        val Nlist = ino(Ltree,(SOME N,i)::Mlist,i+1)\n                in\n                        Nlist\n                end\n        in \n                fun inorder T = ino(T,[],0)\n        end\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\nHere we store (value,depth) as a tuple in the node. \\\\\n\n\\subsection{The Inorder Inverse}\n\nBefore we start the inorder inverse function, we define some facts about our updated inorder Traversal (with heights)\n\n\\textit{\\begin{enumerate}\n    \\item In any inorder traversal ($\\bot$,\\_) is the first and last element\n    \\item If any inorder traversal has more than 1 element, the tree is non-empty\n    \\item The descendants of a node always have a depth greater than the depth of the node. (\\textbf{m},h1) \\& (\\textbf{n},h2) : n is a descendant of m if (h2 \\textgreater h1)\n    \\item Any node m that has a height greater than a node l = (v,h) is either a descendant of l or a descendant of a sibling of l\n    \\item Any slice of the form [(\\textbf{$\\bot$},h+1), (\\textbf{v},h), ($\\neq \\bot \\neq$,h+1)] determines a unique leaf node in the tree with height h.\n    \\item Any slice of the form [(\\textbf{$\\bot$},h+2), (\\textbf{m},h+1), (\\textbf{$\\bot$}, h+2), (\\textbf{l},h), (\\textbf{$\\bot$},h+1)] where m $\\neq \\bot \\neq$ l are values of the nodes, determines a unique subtree rooted at l whose left child is the leaf node m and the right child is empty\n    \\item Any slice of the form [(\\textbf{$\\bot$},h+1), (\\textbf{l},h), (\\textbf{$\\bot$}, h+2), (\\textbf{m},h+1), (\\textbf{$\\bot$},h+2)] where m $\\neq \\bot \\neq$ l   are values of the nodes, determines a unique subtree rooted at l whose right\n    child is the leaf node m and the left child is empty.\n    \\item Any slice of the form [(\\textbf{T1},h+1), (\\textbf{v},h), (\\textbf{T2},h+1)] where T1  $\\neq \\bot \\neq$ T2 are subtrees/leaf nodes determines a subtree rooted at v with T1 and T2 as it's left and right children\n\\end{enumerate}}\n\n\\textbf{Uniqueness of Inorder Traversal}: No two distinct binary trees can yield the same inorder traversal.\n\\textit{Proof:} The proof follows from the definition of inorder traversal and the previous facts (especially the if and only if\nconditions) Further the statements yield an inductive proof along with a case analysis of the inductive step \\\\\n\nNow we define some helper functions to create this inorder inverse. The first function converts a inorder traversal into a list of Bintree nodes. \n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NW6NVqj-3s4e0t-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-3s4e0t-1}}}\\moddef{Nodify~{\\nwtagstyle{}\\subpageref{NW6NVqj-3s4e0t-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-D88LJ-1}}\\nwenddeflinemarkup\n    fun  Nodify[] = []\n                | Nodify (h::t) = \n                Node(h,Empty,Empty)::Nodify(t)\n\\nwused{\\\\{NW6NVqj-D88LJ-1}}\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\nThe next function joins 3 nodes into a single node if the height of the middle node is one less than the other two.\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NW6NVqj-4eyur2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-4eyur2-1}}}\\moddef{joinNodes~{\\nwtagstyle{}\\subpageref{NW6NVqj-4eyur2-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-D88LJ-1}}\\nwenddeflinemarkup\n                fun joinNodes(T1 as Node((v1,h1),_,_), T2 as Node((v2,h2),_,_), T3 as Node((v3,h3),_,_)) =\n                if(h1=h3 andalso (h1-1)=h2) then\n                        [Node((v2,h2),T1,T3)]\n                else\n                        [T1,T2,T3]\n                | joinNodes(T1,T2,T3) = raise InvalidTraversal\n\\nwused{\\\\{NW6NVqj-D88LJ-1}}\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\nThe next function goes over a list of notes and tries combining all the successive nodes triplets\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NW6NVqj-2W3UBo-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2W3UBo-1}}}\\moddef{CombineIter~{\\nwtagstyle{}\\subpageref{NW6NVqj-2W3UBo-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-D88LJ-1}}\\nwenddeflinemarkup\n        fun combineIter(h1::h2::h3::[]) = \n                        joinNodes(h1,h2,h3)\n                | combineIter(L as h1::h2::h3::tl) = \n                let\n                        val M = joinNodes(h1,h2,h3) @ tl\n                in\n                        List.hd(M) :: combineIter(List.tl(M))\n                end\n                | combineIter (L as h1::h2::[]) = L\n                | combineIter L = raise InvalidTraversal\n\\nwused{\\\\{NW6NVqj-D88LJ-1}}\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\nNow, a function keeps calling the iterative joining function until only one node remains\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NW6NVqj-3BQdfV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-3BQdfV-1}}}\\moddef{Combine~{\\nwtagstyle{}\\subpageref{NW6NVqj-3BQdfV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-D88LJ-1}}\\nwenddeflinemarkup\n                fun combine(hd::[]) = hd\n                | combine L =  \n                let\n                        val M = combineIter L\n                in\n                        combine M\n                end\n\\nwused{\\\\{NW6NVqj-D88LJ-1}}\\nwendcode{}\\nwbegindocs{26}\\nwdocspar\n\nThis tree created has Complete nodes even for Empty Leaf nodes. We need to clean this up and remove the extra Empty Nodes\n\n\\nwenddocs{}\\nwbegincode{27}\\sublabel{NW6NVqj-8c9SM-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-8c9SM-1}}}\\moddef{treeClean~{\\nwtagstyle{}\\subpageref{NW6NVqj-8c9SM-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-D88LJ-1}}\\nwenddeflinemarkup\n                fun treeClean(Node((SOME v,_),Ltree,Rtree)) = \n                let\n                        val LClean = treeClean(Ltree)\n                        val RClean = treeClean(Rtree)\n                in\n                        Node(v, LClean, RClean)\n                end\n                | treeClean(T) = Empty\n\\nwused{\\\\{NW6NVqj-D88LJ-1}}\\nwendcode{}\\nwbegindocs{28}\\nwdocspar\n\nNow we can put it all together in our inorderInverse\n\n\\nwenddocs{}\\nwbegincode{29}\\sublabel{NW6NVqj-D88LJ-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-D88LJ-1}}}\\moddef{inorderInverse~{\\nwtagstyle{}\\subpageref{NW6NVqj-D88LJ-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n    local\n        \\LA{}Nodify~{\\nwtagstyle{}\\subpageref{NW6NVqj-3s4e0t-1}}\\RA{}\n        \\LA{}joinNodes~{\\nwtagstyle{}\\subpageref{NW6NVqj-4eyur2-1}}\\RA{}\n        \\LA{}CombineIter~{\\nwtagstyle{}\\subpageref{NW6NVqj-2W3UBo-1}}\\RA{}\n        \\LA{}Combine~{\\nwtagstyle{}\\subpageref{NW6NVqj-3BQdfV-1}}\\RA{}\n        \\LA{}treeClean~{\\nwtagstyle{}\\subpageref{NW6NVqj-8c9SM-1}}\\RA{}\n    in\n        fun inorderInverse(L) = \n                        treeClean (combine (Nodify L))\n\n        end\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{30}\\nwdocspar\n\nHaving gotten a tree back from an inorder inverse, we would like to define a function to check if the tree is the same as our original tree. We can do the same by comparing their preorder \\& postorder traversal. (Since in the \\href{http://www.cse.iitd.ernet.in/~sak/courses/ilfp/recover.pdf}{document} the uniqueness of preorder/postorder traversals has been proved. For this we need to check if two lists generated by the traversals are the same\n\n\\nwenddocs{}\\nwbegincode{31}\\sublabel{NW6NVqj-2cpULM-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2cpULM-1}}}\\moddef{checkList~{\\nwtagstyle{}\\subpageref{NW6NVqj-2cpULM-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-1Uzkdr-1}}\\nwenddeflinemarkup\n    fun checkList([],[]) = true\n                | checkList([],_) = false\n                | checkList(_,[]) = false\n                | checkList(NONE::t1, NONE::t2) = checkList(t1,t2)\n                | checkList(SOME h1::t1, SOME h2::t2) = \n                if(h1=h2) then\n                        checkList(t1,t2)\n                else\n                        false\n                | checkList(_,_) = false\n\\nwused{\\\\{NW6NVqj-1Uzkdr-1}}\\nwendcode{}\\nwbegindocs{32}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{33}\\sublabel{NW6NVqj-1Uzkdr-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-1Uzkdr-1}}}\\moddef{checkTrees~{\\nwtagstyle{}\\subpageref{NW6NVqj-1Uzkdr-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-2nTQtw-1}}\\nwenddeflinemarkup\n    local\n                \\LA{}checkList~{\\nwtagstyle{}\\subpageref{NW6NVqj-2cpULM-1}}\\RA{}\n        in\n                fun checkTrees(T1,T2) = \n                let\n                        val pre1 = preorder(T1)\n                        val pre2 = preorder(T2)\n                        val pos1 = postorder(T1)\n                        val pos2 = postorder(T2)\n                in\n                        if(checkList(pre1,pre2) andalso checkList(pos1,pos2)) then\n                                true\n                        else\n                                false\n                end\n        end\n\\nwused{\\\\{NW6NVqj-2nTQtw-1}}\\nwendcode{}\\nwbegindocs{34}\\nwdocspar\n\nNow we put it all together into our Bintree structure\n\n\\nwenddocs{}\\nwbegincode{35}\\sublabel{NW6NVqj-2nTQtw-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2nTQtw-1}}}\\moddef{bintreeStructure-complete~{\\nwtagstyle{}\\subpageref{NW6NVqj-2nTQtw-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\n\\LA{}bintreeSignature-complete~{\\nwtagstyle{}\\subpageref{NW6NVqj-4WBYwn-1}}\\RA{}\nstructure Bintree : BINTREE = \nstruct\n    \\LA{}Node~{\\nwtagstyle{}\\subpageref{NW6NVqj-4XyAA2-1}}\\RA{}\n    \\LA{}Option~{\\nwtagstyle{}\\subpageref{NW6NVqj-4JPyOG-1}}\\RA{}\n    \n    exception Empty_bintree\n        exception InvalidTraversal\n        \n        \\LA{}preorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-FYIyT-1}}\\RA{}\n        \\LA{}postorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-2drSLa-1}}\\RA{}\n        \\LA{}inorder~{\\nwtagstyle{}\\subpageref{NW6NVqj-N7IVZ-1}}\\RA{}\n    \\LA{}inorderInverse~{\\nwtagstyle{}\\subpageref{NW6NVqj-D88LJ-1}}\\RA{}\n    \\LA{}checkTrees~{\\nwtagstyle{}\\subpageref{NW6NVqj-1Uzkdr-1}}\\RA{}\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{36}\\nwdocspar\n\n\\section{Test Cases}\n\nWe define the following test cases to check the performance of our inorderInverse \n\n\\begin{center}\n        \\includegraphics[width=14cm]{Test1.jpg}\n        \\\\\n        \\includegraphics[width=14cm]{Test2.jpg}\n\\end{center}\n\\nwenddocs{}\\nwbegincode{37}\\sublabel{NW6NVqj-2obuBU-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2obuBU-1}}}\\moddef{test1~{\\nwtagstyle{}\\subpageref{NW6NVqj-2obuBU-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t7 = Node (7, Empty, Empty);\n        val t6 = Node (6, t7, Empty);\n        val t5 = Node (5, Empty, Empty);\n        val t4 = Node (4, Empty, Empty);\n        val t3 = Node (3, t5, t6);\n        val t2 = Node (2, Empty, t4);\nin\n        val test1 = Node (1, t2, t3);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{38}\\nwdocspar\n\\nwenddocs{}\\nwbegincode{39}\\sublabel{NW6NVqj-PItlY-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-PItlY-1}}}\\moddef{test2~{\\nwtagstyle{}\\subpageref{NW6NVqj-PItlY-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t15 = Node (15, Empty, Empty);\n        val t14 = Node (14, Empty, Empty);\n        val t13 = Node (13, Empty, Empty);\n        val t12 = Node (12, Empty, Empty);\n        val t11 = Node (11, Empty, Empty);\n        val t10 = Node (10, Empty, Empty);\n        val t9 = Node (9, Empty, Empty);\n        val t8 = Node (8, Empty, Empty);\n        val t7 = Node(7, t14, t15);\n        val t6 = Node (6, t12, t13);\n        val t5 = Node (5, t10, t11);\n        val t4 = Node (4, t8, t9);\n        val t3 = Node (3, t6, t7);\n        val t2 = Node (2, t4, t5);\nin\n        val test2 = Node (1, t2, t3);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{40}\\nwdocspar\n\\nwenddocs{}\\nwbegincode{41}\\sublabel{NW6NVqj-4A3yQS-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-4A3yQS-1}}}\\moddef{test3~{\\nwtagstyle{}\\subpageref{NW6NVqj-4A3yQS-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t11 = Node (11, Empty, Empty);\n        val t10 = Node (10, Empty, Empty);\n        val t9 = Node (9, Empty, Empty);\n        val t8 = Node (8, Empty, Empty);\n        val t5 = Node (5, t10, t11);\n        val t4 = Node (4, t8, t9);\n        val t2 = Node (2, t4, t5);\nin\n        val test3 = Node (1, t2, Empty);\nend\n\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegincode{42}\\sublabel{NW6NVqj-1UZpaq-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-1UZpaq-1}}}\\moddef{test4~{\\nwtagstyle{}\\subpageref{NW6NVqj-1UZpaq-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t15 = Node (15, Empty, Empty);\n        val t14 = Node (14, Empty, Empty);\n        val t13 = Node (13, Empty, Empty);\n        val t12 = Node (12, Empty, Empty);\n        val t7 = Node(7, t14, t15);\n        val t6 = Node (6, t12, t13);\n        val t3 = Node (3, t6, t7);\nin\n        val test4 = Node (1, Empty, t3);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{43}\\nwdocspar\n\\nwenddocs{}\\nwbegincode{44}\\sublabel{NW6NVqj-30oemG-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-30oemG-1}}}\\moddef{test5~{\\nwtagstyle{}\\subpageref{NW6NVqj-30oemG-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t4 = Node (4, Empty, Empty);\n        val t3 = Node (3, t4, Empty);\n        val t2 = Node (2, t3, Empty);\nin\n        val test5 = Node (1, t2, Empty);\nend\n\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegincode{45}\\sublabel{NW6NVqj-mrbYu-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-mrbYu-1}}}\\moddef{test6~{\\nwtagstyle{}\\subpageref{NW6NVqj-mrbYu-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t4 = Node (4, Empty, Empty);\n        val t3 = Node (3, Empty, t4);\n        val t2 = Node (2, Empty, t3);\nin\n        val test6 = Node (1, Empty, t2);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{46}\\nwdocspar\n\\nwenddocs{}\\nwbegincode{47}\\sublabel{NW6NVqj-446Oh6-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-446Oh6-1}}}\\moddef{test7~{\\nwtagstyle{}\\subpageref{NW6NVqj-446Oh6-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t7 = Node (7, Empty, Empty);\n        val t6 = Node (6, Empty, Empty);\n        val t5 = Node (5, Empty, t7);\n        val t4 = Node (4, t6, Empty);\n        val t3 = Node (3, Empty, t5);\n        val t2 = Node (2, t4, Empty);\nin\n        val test7 = Node (1, t2, t3);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{48}\\nwdocspar\n\\nwenddocs{}\\nwbegincode{49}\\sublabel{NW6NVqj-25u5CK-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-25u5CK-1}}}\\moddef{test8~{\\nwtagstyle{}\\subpageref{NW6NVqj-25u5CK-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nlocal\n        val t7 = Node (7, Empty, Empty);\n        val t6 = Node (6, Empty, Empty);\n        val t5 = Node (5, Empty, t7);\n        val t4 = Node (4, t6, Empty);\n        val t3 = Node (3, t5, Empty);\n        val t2 = Node (2, Empty, t4);\nin\n        val test8 = Node (1, t2, t3);\nend\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{50}\\nwdocspar\n\nAfter this, to check if our inorderInverse works for each test case, we simply checkTrees between the inorderInverse generated tree and the original tree\n\n\\nwenddocs{}\\nwbegincode{51}\\sublabel{NW6NVqj-2UuN4Q-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-2UuN4Q-1}}}\\moddef{testCheck~{\\nwtagstyle{}\\subpageref{NW6NVqj-2UuN4Q-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW6NVqj-stHGb-1}}\\nwenddeflinemarkup\nval test1_check = checkTrees(inorderInverse(inorder(test1)),test1);\nval test2_check = checkTrees(inorderInverse(inorder(test2)),test2);\nval test3_check = checkTrees(inorderInverse(inorder(test3)),test3);\nval test4_check = checkTrees(inorderInverse(inorder(test4)),test4);\nval test5_check = checkTrees(inorderInverse(inorder(test5)),test5);\nval test6_check = checkTrees(inorderInverse(inorder(test6)),test6);\nval test7_check = checkTrees(inorderInverse(inorder(test7)),test7);\nval test8_check = checkTrees(inorderInverse(inorder(test8)),test8);\n\\nwused{\\\\{NW6NVqj-stHGb-1}}\\nwendcode{}\\nwbegindocs{52}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{53}\\sublabel{NW6NVqj-stHGb-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW6NVqj-stHGb-1}}}\\moddef{testCase-complete~{\\nwtagstyle{}\\subpageref{NW6NVqj-stHGb-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\n\\LA{}bintreeStructure-complete~{\\nwtagstyle{}\\subpageref{NW6NVqj-2nTQtw-1}}\\RA{}\nopen Bintree;\n\n\\LA{}test1~{\\nwtagstyle{}\\subpageref{NW6NVqj-2obuBU-1}}\\RA{}\n\\LA{}test2~{\\nwtagstyle{}\\subpageref{NW6NVqj-PItlY-1}}\\RA{}\n\\LA{}test3~{\\nwtagstyle{}\\subpageref{NW6NVqj-4A3yQS-1}}\\RA{}\n\\LA{}test4~{\\nwtagstyle{}\\subpageref{NW6NVqj-1UZpaq-1}}\\RA{}\n\\LA{}test5~{\\nwtagstyle{}\\subpageref{NW6NVqj-30oemG-1}}\\RA{}\n\\LA{}test6~{\\nwtagstyle{}\\subpageref{NW6NVqj-mrbYu-1}}\\RA{}\n\\LA{}test7~{\\nwtagstyle{}\\subpageref{NW6NVqj-446Oh6-1}}\\RA{}\n\\LA{}test8~{\\nwtagstyle{}\\subpageref{NW6NVqj-25u5CK-1}}\\RA{}\n\\LA{}testCheck~{\\nwtagstyle{}\\subpageref{NW6NVqj-2UuN4Q-1}}\\RA{}\n\\nwnotused{testCase-complete}\\nwendcode{}\n\n\\nwixlogsorted{c}{{bintreeSignature-complete}{NW6NVqj-4WBYwn-1}{\\nwixd{NW6NVqj-4WBYwn-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{bintreeStructure-complete}{NW6NVqj-2nTQtw-1}{\\nwixd{NW6NVqj-2nTQtw-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{checkList}{NW6NVqj-2cpULM-1}{\\nwixd{NW6NVqj-2cpULM-1}\\nwixu{NW6NVqj-1Uzkdr-1}}}%\n\\nwixlogsorted{c}{{checkTrees}{NW6NVqj-1Uzkdr-1}{\\nwixd{NW6NVqj-1Uzkdr-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{Combine}{NW6NVqj-3BQdfV-1}{\\nwixd{NW6NVqj-3BQdfV-1}\\nwixu{NW6NVqj-D88LJ-1}}}%\n\\nwixlogsorted{c}{{CombineIter}{NW6NVqj-2W3UBo-1}{\\nwixd{NW6NVqj-2W3UBo-1}\\nwixu{NW6NVqj-D88LJ-1}}}%\n\\nwixlogsorted{c}{{equalSig}{NW6NVqj-3QvoFw-1}{\\nwixd{NW6NVqj-3QvoFw-1}\\nwixu{NW6NVqj-4WBYwn-1}}}%\n\\nwixlogsorted{c}{{inorder}{NW6NVqj-N7IVZ-1}{\\nwixd{NW6NVqj-N7IVZ-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{inorderInverse}{NW6NVqj-D88LJ-1}{\\nwixd{NW6NVqj-D88LJ-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{InSig}{NW6NVqj-2NTUdd-1}{\\nwixd{NW6NVqj-2NTUdd-1}\\nwixu{NW6NVqj-4WBYwn-1}}}%\n\\nwixlogsorted{c}{{joinNodes}{NW6NVqj-4eyur2-1}{\\nwixd{NW6NVqj-4eyur2-1}\\nwixu{NW6NVqj-D88LJ-1}}}%\n\\nwixlogsorted{c}{{Node}{NW6NVqj-4XyAA2-1}{\\nwixd{NW6NVqj-4XyAA2-1}\\nwixu{NW6NVqj-4WBYwn-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{Nodify}{NW6NVqj-3s4e0t-1}{\\nwixd{NW6NVqj-3s4e0t-1}\\nwixu{NW6NVqj-D88LJ-1}}}%\n\\nwixlogsorted{c}{{Option}{NW6NVqj-4JPyOG-1}{\\nwixd{NW6NVqj-4JPyOG-1}\\nwixu{NW6NVqj-4WBYwn-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{postorder}{NW6NVqj-2drSLa-1}{\\nwixd{NW6NVqj-2drSLa-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{preorder}{NW6NVqj-FYIyT-1}{\\nwixd{NW6NVqj-FYIyT-1}\\nwixu{NW6NVqj-2nTQtw-1}}}%\n\\nwixlogsorted{c}{{PrePostSig}{NW6NVqj-azPlp-1}{\\nwixd{NW6NVqj-azPlp-1}\\nwixu{NW6NVqj-4WBYwn-1}}}%\n\\nwixlogsorted{c}{{test1}{NW6NVqj-2obuBU-1}{\\nwixd{NW6NVqj-2obuBU-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test2}{NW6NVqj-PItlY-1}{\\nwixd{NW6NVqj-PItlY-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test3}{NW6NVqj-4A3yQS-1}{\\nwixd{NW6NVqj-4A3yQS-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test4}{NW6NVqj-1UZpaq-1}{\\nwixd{NW6NVqj-1UZpaq-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test5}{NW6NVqj-30oemG-1}{\\nwixd{NW6NVqj-30oemG-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test6}{NW6NVqj-mrbYu-1}{\\nwixd{NW6NVqj-mrbYu-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test7}{NW6NVqj-446Oh6-1}{\\nwixd{NW6NVqj-446Oh6-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{test8}{NW6NVqj-25u5CK-1}{\\nwixd{NW6NVqj-25u5CK-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{testCase-complete}{NW6NVqj-stHGb-1}{\\nwixd{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{testCheck}{NW6NVqj-2UuN4Q-1}{\\nwixd{NW6NVqj-2UuN4Q-1}\\nwixu{NW6NVqj-stHGb-1}}}%\n\\nwixlogsorted{c}{{treeClean}{NW6NVqj-8c9SM-1}{\\nwixd{NW6NVqj-8c9SM-1}\\nwixu{NW6NVqj-D88LJ-1}}}%\n\\nwbegindocs{54}\\nwdocspar\n\nThe reason to choose these particular test cases since it covers some particular ambiguous cases such as a fully dense tree (Test2), a highly skewed tree (Test5 and Test6) as well as a initially skewed and then dense tree (Test3 and Test4) or a highly hollow tree (Test7) as well as a tree containing alternative oriented children (Test8)\n\nThe checkTrees function checks the inorderInverse generated tree vs the original tree. For all these testcases, the output is true.\n\n\\end{document}\n\\nwenddocs{}\n", "meta": {"hexsha": "9753d814bf38ad90e267ce2dca9ab7656e4ee1eb", "size": 28289, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment2/output/output.tex", "max_stars_repo_name": "nilax97/ilfp", "max_stars_repo_head_hexsha": "94dce71df443f2ce2047495a6e4bcdd280633171", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-05-31T07:03:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-31T07:05:57.000Z", "max_issues_repo_path": "assignment2/output/output.tex", "max_issues_repo_name": "nilax97/ilfp", "max_issues_repo_head_hexsha": "94dce71df443f2ce2047495a6e4bcdd280633171", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment2/output/output.tex", "max_forks_repo_name": "nilax97/ilfp", "max_forks_repo_head_hexsha": "94dce71df443f2ce2047495a6e4bcdd280633171", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.7663755459, "max_line_length": 446, "alphanum_fraction": 0.6844709958, "num_tokens": 10911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.4323966860882217}}
{"text": "\\setcounter{table}{0}\n\\setcounter{figure}{0}\n\\renewcommand{\\thetable}{\\mbox{E.\\arabic{table}}}%\n\\renewcommand{\\thefigure}{\\mbox{E--\\arabic{figure}}}%\n\n\n\\chapter{Operator Precedence Hierarchy}\n\n\\markboth{{\\color{cyan}APPENDIX\\,E\\,\\,$\\bullet$\\,\\,}Operator Precedence Hierarchy}\n{{\\color{cyan}APPENDIX\\,E\\,\\,$\\bullet$\\,\\,}Operator Precedence Hierarchy}\n\n%%\\appendixright{E}{Operator Precedence Hierarchy}\n\n\\noindent Table E.1 summarizes the precedence and\nassociativity relationships for Java operators.   Within a single\nexpression, an operator of order {\\it m} would be evaluated before an\noperator of order {\\it n} if $m < n$. Operators having the same order\nare evaluated according to their association order.  For example, the\nexpression\n\n\\begin{jjjlisting}\n\\begin{lstlisting}\n25 + 5 * 2 + 3\n\\end{lstlisting}\n\\end{jjjlisting}\n\n\\noindent would be evaluated in the order shown by the following\nparenthesized expression:\n\n\\begin{jjjlisting}\n\\begin{lstlisting}\n(25 + (5 * 2)) + 3   ==> (25 + 10) + 3 ==> 35 + 3  ==> 38\n\\end{lstlisting}\n\\end{jjjlisting}\n\n\\noindent In other words, because \\verb|*| has higher precedence\nthan \\verb|+|, the multiplication operation is done before either of\nthe addition operations.   And because addition associates from left to\nright, addition operations are performed from left to right.\n\n\n\nMost operators associate from left to right, but note that assignment\noperators associate from right to left.   For example, consider the\nfollowing code segment:\n\n\\begin{jjjlisting}\n\\begin{lstlisting}\nint i, j, k;\ni = j = k = 100;     // Equivalent to i = (j = (k = 100));\n\\end{lstlisting}\n\\end{jjjlisting}\n\n\\begin{table}[h]\n%\\hphantom{\\caption{Java operator precedence and associativity table.\\index{precedence table}}}\n\\TBT{0pc}{Java operator precedence and associativity table.}\n\\hspace*{-6pt}\\begin{tabular}{clll}\n\\multicolumn{4}{l}{\\color{cyan}\\rule{29pc}{1pt}}\\\\[2pt]\n%%%%\\TBCH{{\\bf Order}} & \\TBCH{{\\bf Operator}} & \\TBCH{{\\bf Operation}} & \\TBCH{{\\bf Association}}\n{\\bf Order} & {\\bf Operator} & {\\bf Operation} & {\\bf Association}\n\\\\[-4pt]\\multicolumn{4}{l}{\\color{cyan}\\rule{29pc}{0.5pt}}\\\\[2pt]\n0 &\\verb|(  )|&{\\it Parentheses}\\cr\n1 &\\verb|++   -- |$\\;\\cdot$&{\\it Postincrement,  Postdecrement, Dot Operator}&{\\it L to R}\\cr\n2 &\\verb|++   --  +  -  !|&{\\it Preincrement,  Predecrement, }&{\\it R to L}\\cr\n  &&{\\it Unary plus,  Unary minus,  Boolean NOT}&\\cr\n3 &\\verb|(type)  new|&{\\it Type  Cast, Object Instantiation}&{\\it R to L}\\cr\n4 &\\verb|*  /  %|&{\\it Multiplication,  Division,  Modulus}&{\\it L to R}\\cr\n5 &\\verb|+ -  +|&{\\it Addition,  Subtraction,  String Concatenation}&{\\it L to R}\\cr\n6 &\\verb|<  >  <=  >=|&{\\it Relational  Operators}&{\\it L to R}\\cr\n7 &\\verb|==   !=|&{\\it Equality  Operators}&{\\it L to R}\\cr\n8 &$\\wedge$&{\\it Boolean  XOR}&{\\it L to R}\\cr\n9 &\\verb|&&|&{\\it Boolean  AND}&{\\it L to R}\\cr\n10&\\verb||||&{\\it Boolean  OR}&{\\it L to R}\\cr\n11&\\verb|= += -= *= /= %=|&{\\it Assignment  Operators}&{\\it R to L}\n\\\\[-4pt]\\multicolumn{4}{l}{\\color{cyan}\\rule{29pc}{1pt}}\n\\end{tabular}\n\\endTB\n\\end{table}\n\n\\noindent  In this case, each variable will be assigned 100 as its\nvalue.  But it's important that this expression be evaluated from right\nto left.  First, {\\it k} is assigned 100. Then its value is assigned\nto {\\it j}. And finally {\\it j}'s value is assigned to {\\it i}.\n\nFor expressions containing mixed operators, it's always a good idea to\nuse parentheses to clarify the order of evaluation.  This will also\nhelp avoid subtle syntax and semantic errors.\n", "meta": {"hexsha": "c78658484caec616b80e19c097117c753c4a996e", "size": 3514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "texfiles/e.tex", "max_stars_repo_name": "ram8647/javajavajava", "max_stars_repo_head_hexsha": "dbd8496496d1d2feee23c41b3f58ebc33fa42d12", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-05T17:04:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T17:04:32.000Z", "max_issues_repo_path": "texfiles/e.tex", "max_issues_repo_name": "ram8647/javajavajava", "max_issues_repo_head_hexsha": "dbd8496496d1d2feee23c41b3f58ebc33fa42d12", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-06-02T18:00:05.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-02T18:00:05.000Z", "max_forks_repo_path": "texfiles/e.tex", "max_forks_repo_name": "ram8647/javajavajava", "max_forks_repo_head_hexsha": "dbd8496496d1d2feee23c41b3f58ebc33fa42d12", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-06-01T01:26:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T01:20:50.000Z", "avg_line_length": 39.9318181818, "max_line_length": 98, "alphanum_fraction": 0.6861126921, "num_tokens": 1145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7853085708384736, "lm_q1q2_score": 0.4323966833216166}}
{"text": "%!TEX root = <JHU-SIMPLEX_proposal.tex>\n% \\clearpage\n\\section{Statement of Work}\n\\label{sec:sow}\n% \\emph{The SOW must provide a detailed task breakdown, citing specific tasks and their connection to the interim milestones and metrics, as applicable. Each year of the project should be separately defined. The SOW must not include proprietary information. For each defined task/subtask, provide:\n% % \n% (1) A general description of the objective.\n% (2) A detailed description of the approach to be taken to accomplish each defined task/subtask.\n% (3) Identification of the primary organization responsible for task execution (prime contractor, subcontractor(s), consultant(s)), by name.\n% (4) A measurable milestone, (e.g., a deliverable, demonstration, or other event/activity that marks task completion).\n% (5) A definition of all deliverables (e.g., data, reports, software) to be provided to the Government in support of the proposed tasks/subtasks.}\n% \n\n\n\n\n\\subsection{Phase I}\n\n\n\\subsubsection{Task 1: Mathematical Formalism}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{RAG Embedding:} Completion of the theoretical development and associated data structures of our RAG representation system. This includes establishing baseline methods for embeddings RAGs and populations thereof.  Specifically, we will explore both JOFC and tensor factorization methodologies, to enable understanding of the computational and statistical advantages and disadvantages of each for embedding high-dimensional non-Euclidean RAGS.\n\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstration that RAGs are able to meet TA1 goals, including encoding quantitative and qualitative knowledge, and express functional relationship among entities in complex systems.\n\\item \\textbf{Deliverables:} Description of mathematical framework and preliminary benchmarks evaluating performance on open access data sets and simulations.\n\\end{compactitem}\n\n\n\\subsubsection{Task 2: Computational Infrastructure}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Data Management:} Implementation of baseline algorithms for context-aware reasoning and inference using the representation. Development of an initial computational and data management platform, including establishing common data formats, common methods and format for query and analysis of results, and a common API through which all domain-specific users will access the framework. We will also extend our dense spatial and semantic databases, as well as our graph data format to support time-varying data, along with multi-modal data.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Completion of Phase I prototype software and services.\n\\item \\textbf{Deliverables:} Open source software and documentation for end-to-end prototype.\n\\end{compactitem}\n\n\n\n\\subsubsection{Task 3: Datafication}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Data Ingest:} Completion of data ingest techniques. Completion of research and design into microscopic and mesoscopic specific analysis tools.  Demonstration of auto-data ingestion and registration of multiple different modalities (functional to structural for both microscopic and mesoscopic data). More specifically, we will have ingested CLARITY, LFM, and M$^3$RI data into the same database schema; all M$^3$RI data will be co-registered.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstration of operational auto-ingestion and registration on two different use-cases.\n\\item \\textbf{Deliverables:} Open source software and documentation for datafication techniques, as well as image datasets ingested and RAGs estimated from all different data modalities.\n\\end{compactitem}\n\n\n\\subsubsection{Task 4: Discovery}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{RAG Construction:} \n Completion of research and design into microscopic and mesoscopic specific analysis tools, by designing metrics appropriate for the different data modalities.  This includes both the microscale and mesoscale functional time-series, converting into RAGs via utilizing qualitative information.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstration of RAG construction on both use cases.\n\\item \\textbf{Deliverables:} Open source software and documentation RAG construction techniques, as well as the derived RAGs available via our Web-services.\n\\end{compactitem}\n\n\n\n\\subsubsection{Task 5: Program Management}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Phase I:} Ensure successful execution of the effort. Manage the proposed effort using a proven methodology for project planning, resource allocation, task specification, and monitoring. Establish a baseline project plan with a list of tasks, specifications, requirements, and timelines; update plan periodically; document updates to the plan and share them with the project team and DARPA PM.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Meet Phase I goals.\n\\item \\textbf{Deliverables:} \n(1) Comprehensive quarterly technical reports that include updates systems architecture and progress made on milestones for Phase I;\n(2) Brief month reports, including preprints of technical reports;\n(3) Final Technical Report;\n(4) Monthly Financial Reports.\n\\end{compactitem}\n\n\n\n\\subsection{Phase II}\n\n\n\n\n\n\\subsubsection{Task 1: Mathematical Formalism}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{FlashRAG:} Implementation of all embedding and construction methodologies in FlashGraph to enable scalable implementations and processing.  Moreover, all constructed RAGs will obtain multilevel representations.  We will build R bindings to enable easy use of FlashGraph for data scientists.  We will check that our implementations and bindings yield approximately the same answer as benchmark methods, on data sufficiently small that benchmark methods can run.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Fully operational FlashGraph and R bindings for embedding and constructing methodologies.\n\\item \\textbf{Deliverables:} Open source software and documentation for end-to-end prototype for embedding and constructing RAGs. This includes an R package for FlashGraph.\n\\end{compactitem}\n\n\n\\subsubsection{Task 2: Computational Infrastructure}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Remote Access:} Implementation of prototype platform for remote access. This will include Web-services for uploading the raw data, and downloading the derived data products (RAGs and intermediate data products), as well as both 2D and 3D visualization and annotation tools, which will support multiple kinds of analytic overlays, all of which will support multiple data scales. Moreover, we will have made theoretical and practical refinements to the representation to enable scalable implementation of several foundational algorithms on RAGs, implementing the embedding methodologies developed in Task 1 of Phase I into our semi-external memory formalism.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Fully operational Web-services supporting uploading, visualizing, annotation, querying, downloading, and analyzing the data.\n\\item \\textbf{Deliverables:} Open source software and documentation for end-to-end prototype. This includes an R package for FlashGraph which extends it capabilities to RAGs, rather than simply graphs.\n\\end{compactitem}\n\n\n\\subsubsection{Task 3: Datafication}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Data Register:} Integration of domain-specific computational models across modalities and scales. This includes completion of statistical multi-modal referencing, including alignment of structural and functional imaging data, for both microscopic and mesoscopic data sets.  We will also complete functional inference capabilities. We will align data both via scaling up multidimensional out-of-core image alignment algorithms, and RAG matching, which extends graph matching by incorporating attributes.  This will enable us to determine optimal alignments using data priors and known topological structure, rather than relying on images to align well.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstration of multi-modal registration for both microscopic and mesoscopic use cases.\n\\item \\textbf{Deliverables:} Open source software and documentation for datafication techniques, as well as registered multi-modal image datasets ingested and aligned RAGs from both microscale and mesoscale.\n\\end{compactitem}\n\n\n\\subsubsection{Task 4: Discovery}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{RAG Summary Statistics:} Utilize RAG knowledge representation to estimate population moments, motifs, and/or modes from both  micro- and meso-scale RAGs.  More specifically, we will utilize the various joint embedding methodologies developed in Task 1 to estimate these summary statistics.  The different approaches, JOFC versus tensor factorization, will enable incorporating different kinds of prior knowledge and constraints, so they will therefore lead to different bias/variance trade-offs.  We will explore these options empirical on the real data, to complement our experiments in Task 1, to discover both (i) the best methods for estimation these summary statistics, and (ii) the best estimates of the summary statistics for the two different scales.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstration utility of RAG representation of data for estimating summary statistics for multi-modal data.\n\\item \\textbf{Deliverables:} Estimated summary statistics from micro- and meso-scale RAGs available for download in various formats, as well as open source code for the different estimators. \n\\end{compactitem}\n\n\n\n% \\subsubsection{Task 4: Discovery}\n% \\begin{compactitem}\n% \\item \\textbf{Goal:} \\emph{RAG Independence:} Instantiation of first-generation analysis tools, including tests for independence between connectivity and graph, vertex, and/or edge attributes, and application of those tools to both use cases. We will leverage the RAG representation system to discover whether mouse or human graph connectivity is independent of graph attributes. For both inference tasks, we will utilize and extending the scalable embedding methodologies developed in Task 2 of Phase II. \n% \\item \\textbf{Primary Site:} JHU\n% \\item \\textbf{Milestone:} Demonstration utility of RAG representation of data for multi-modal neuroscientific discoveries for both microscale and mesoscale.\n% \\item \\textbf{Deliverables:} Discovered multi-modal motifs from microscale data and hypothesis testing results and visualizations from mesoscale data.\n% \\end{compactitem}\n\n\\subsubsection{Task 5: Program Management}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Phase II Goals:} Ensure successful execution of the effort. Manage the proposed effort using a proven methodology for project planning, resource allocation, task specification, and monitoring. Establish a baseline project plan with a list of tasks, specifications, requirements, and timelines; update plan periodically; document updates to the plan and share them with the project team and DARPA PM.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Meet Phase II goals.\n\\item \\textbf{Deliverables:} \n(1) Comprehensive quarterly technical reports that include updates systems architecture and progress made on milestones for Phase II;\n(2) Brief month reports, including preprints of technical reports;\n(3) Final Technical Report;\n(4) Monthly Financial Reports.\n\\end{compactitem}\n\n\n\\subsection{Phase III}\n\n\n\n\\subsubsection{Task 1: Mathematical Formalism}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{RAG Testing:} Demonstration of capabilities and objectives on both microscale and mesoscale data, as well as one additional SIMPLEX performer. To achieve this, we will extend our embedding methodologies, to derive provably approximately optimal embeddings for conducting one-sample and two-sample tests on RAGs; two fundamental testing procedures in statistics.  Our tests will leverage our ability to efficiently sample RAGs, as they will be resampling based tests, analogs to the classic parametric and non-parametric bootstrap.  We will apply these tests to test, for example, whether our data are sampled from relatively simple RAGs statistical models, and whether population means that we obtained in Phase I are significantly different from one another.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Demonstrate our mechanism for relating qualitative and quantitative knowledge, and relating multiple heterogeneous datasets, on both heterogeneous scales (use cases). Specifically, testing whether multiple heterogeneous datasets are statistically different from one another.\n\\item \\textbf{Deliverables:} Description of capabilities, emphasizing generalizability to multiple use cases, open source code from implementing our tests, visualizations and numerical summaries of test results.\n\\end{compactitem}\n\n\n% \\subsubsection{Task 1: Mathematical Formalism}\n% \\begin{compactitem}\n% \\item \\textbf{Goal:} \\emph{RAG Learning:} Completion of mathematical tools for hypothesis generation, testing, and model validation using RAGs. This will include context aware algorithms capable of running in interactive time.  More specifically, we will extend the toolbox of inferential techniques to include unsupervised, semi-supervised, and fully supervised methods for clustering RAGs.  All these methods will utilize  the estimation and embedding strategies developed in the previous tasks for this proposal.  Moreover, we will extend such embedding methodologies to optimize them for the particular learning tasks.  Theoretical and numerical results will support the utility of these methodologies.\n% \\item \\textbf{Primary Site:} JHU\n% \\item \\textbf{Milestone:} Demonstration of the full suite of mathematical capabilities on RAGs, including estimating, testing, and un-/semi-/fully-supervised learning methodologies. \n% \\item \\textbf{Deliverables:} Complete description of capabilities of RAGs, as well as open source code to run all analyses in R on commodity hardware.\n% \\end{compactitem}\n\n\n\\subsubsection{Task 2: Computational Infrastructure}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Local Analysis:} Completion of an integrated system on both heterogeneous scales (as well as additional domains).  This system ingests and registers imaging data and semantic and qualitative knowledge, converts them into RAGs, allows query and recall, visualization, hypothesis generation, and analysis. We will also release open source packages containing all of the key resources, such as an R package (which calls igraph or FlashGraph) containing all of the developed methods, and GPU optimized visualization and annotation tools. This will enable anybody to implement analyses locally by running the code on their machine.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Fully operation Web-services to auto-ingest, register, store in compact representation, and query, as well as operate locally.\n\\item \\textbf{Deliverables:} Open source software and documentation for end-to-end prototype. including FlashGraphR and GPU optimized visualization and annotation tool.\n\\end{compactitem}\n\n\n\\subsubsection{Task 3: Datafication}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Quality Control:} Completion of quality control of all datasets.  For each different modality, and each different scale, we will have already converted the raw data into RAGs.  Now, we will build automatic quality controls, so that with each dataset, we automatically generate a quality control report, quantifying the key quality metrics appropriate for that data (see Table \\ref{tab:qa}).   \n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} All datasets have been checked for quality.\n\\item \\textbf{Deliverables:} Open source software and documentation for datafication techniques, including quality control scripts, and resulting outputs.\n\\end{compactitem}\n\n\n\\subsubsection{Task 4: Discovery}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{RAG Prediction:} Completion of toolset for analysis, modeling, and data-driven hypothesis generation and testing in both microscale and mesoscale heterogeneous use cases. This will include multiscale prediction; prediction of mouse status from microscale RAGs, and human personality from human RAGs.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone:} Successful integration with TA1 technology and end-of-program demonstrations of our integrated system on both microscale and mesocale.\n\\item \\textbf{Deliverables:} All data-derived products available for visualization utilizing our Web-services and quality control pages, as well as for download and further analysis using our open source code.\n\\end{compactitem}\n\n\n\\subsubsection{Task 5: Program Management}\n\\begin{compactitem}\n\\item \\textbf{Goal:} \\emph{Phase III:} Ensure successful execution of the effort. Manage the proposed effort using a proven methodology for project planning, resource allocation, task specification, and monitoring. Establish a baseline project plan with a list of tasks, specifications, requirements, and timelines; update plan periodically; document updates to the plan and share them with the project team and DARPA PM.\n\\item \\textbf{Primary Site:} JHU\n\\item \\textbf{Milestone} Meet Phase III goals.\n\\item \\textbf{Deliverables:} \n(1) Comprehensive quarterly technical reports that include updates systems architecture and progress made on milestones for Phase III;\n(2) Brief month reports, including preprints of technical reports;\n(3) Final Technical Report;\n(4) Monthly Financial Reports.\n\\end{compactitem}", "meta": {"hexsha": "35bc7c4c44eccfcec5fb8201623fde26e94c2d0f", "size": 17630, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Addendum/content/addendum_SOW.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Addendum/content/addendum_SOW.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Addendum/content/addendum_SOW.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.4923857868, "max_line_length": 786, "alphanum_fraction": 0.8112308565, "num_tokens": 3847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851918, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4323588306259022}}
{"text": "% Abstract ====================================================================\n\n\\pdfbookmark[1]{Abstract}{Abstract}\n\\chapter*{Abstract}\n\nData analysis and machine learning have become an integrative part of the\nmodern scientific methodology, offering automated procedures for the prediction\nof a phenomenon based on past observations, unraveling underlying patterns in\ndata and providing insights about the problem. Yet, caution should\navoid using machine learning as a black-box tool, but rather consider it as a\nmethodology, with a rational thought process that is entirely dependent on the\nproblem under study. In particular, the use of algorithms\nshould ideally require a reasonable understanding of their\nmechanisms, properties and limitations, in order to better apprehend and\ninterpret their results.\n\nAccordingly, the goal of this thesis is to provide an in-depth\nanalysis of random forests, consistently calling into\nquestion each and every part of the algorithm, in order to shed new light on\nits learning capabilities, inner workings and interpretability. The first\npart of this work studies the induction of decision trees and the construction of\nensembles of randomized trees, motivating their design and purpose whenever\npossible. Our contributions follow with an original complexity\nanalysis of random forests, showing their good computational performance\nand scalability, along with an in-depth discussion of their\nimplementation details, as contributed within Scikit-Learn.\n\nIn the second part of this work, we analyze and discuss the interpretability of\nrandom forests in the eyes of variable importance measures. The core of our\ncontributions rests in the theoretical characterization of the Mean Decrease of\nImpurity variable importance measure, from which we prove and derive some of\nits properties in the case of multiway totally randomized trees and in\nasymptotic conditions. In consequence of this work, our analysis  demonstrates\nthat variable importances as computed from non-totally randomized trees (e.g.,\nstandard Random Forest) suffer from a combination of defects, due to masking\neffects, misestimations of node impurity or due to the binary structure of\ndecision trees.\n\nFinally, the last part of this dissertation addresses limitations of random\nforests in the context of large datasets. Through extensive experiments, we\nshow that subsampling both samples and features simultaneously provides on par\nperformance while lowering at the same time the memory requirements. Overall\nthis paradigm highlights an intriguing practical fact: there is often no need\nto build single models over immensely large datasets. Good performance can\noften be achieved by building models on (very) small random parts of the data\nand then combining them all in an ensemble, thereby avoiding all practical\nburdens of making large data fit into memory.\n", "meta": {"hexsha": "5d327ee3ad0fdc98c6cf609a0b262883df905fdb", "size": 2864, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/frontback/abstract.tex", "max_stars_repo_name": "mathkann/understanding-random-forests", "max_stars_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 353, "max_stars_repo_stars_event_min_datetime": "2015-01-03T13:34:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T05:16:30.000Z", "max_issues_repo_path": "tex/frontback/abstract.tex", "max_issues_repo_name": "mathkann/understanding-random-forests", "max_issues_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-06-29T05:43:41.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-29T05:43:41.000Z", "max_forks_repo_path": "tex/frontback/abstract.tex", "max_forks_repo_name": "mathkann/understanding-random-forests", "max_forks_repo_head_hexsha": "d2c5e0174d1a778be37a495083d756b2829160ec", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 153, "max_forks_repo_forks_event_min_datetime": "2015-01-14T03:46:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-26T10:13:51.000Z", "avg_line_length": 59.6666666667, "max_line_length": 81, "alphanum_fraction": 0.8093575419, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.432349213183719}}
{"text": "\\RequirePackage[l2tabu, orthodox]{nag}\n\\documentclass{article}\n\n\\usepackage[letterpaper]{geometry}\n\\usepackage{booktabs}\n\\usepackage{mathtools}\n\\usepackage[binary-units=true]{siunitx}\n\\usepackage{tikz}\n\n\\title{ECE 487 Assignment 5}\n\\author{Michael Kwok}\n\\begin{document}\n\n\\maketitle\n\\subsection*{Stop and Wait ARQ}\nRound trip time: \\(\\frac{600000}{3 \\times 10^8} = 2 \\times 10^{-3}\\)\n2 Timeouts: \\(0.5 + 0.5\\) seconds\\\\\n1 Successful round trip: \\(2 \\times 10^{-3}\\) \\\\\nTotal time: \\(1.002\\) seconds\\\\\nData sent: \\(1000\\) bits\\\\\nThroughput: \\( \\frac{1000}{1.002} = \\SI{998}{\\bit\\per\\second}\\)\n\n\\subsection*{ALOHA station throughput}\n\\(T_{fr} = \\SI{0.4}{\\milli\\second}\\)\n\n\\subsubsection*{Pure}\n\\(G = 0.5\\) to get maximum throughput.\\\\\nSystem frames per second: \\( G \\cdot \\frac{1000}{0.4} = 1250 \\text{Frames per Second} \\) \\\\\n50 stations, so average frames per second per station: \\(\\frac{1250}{50} = 25\\)\n\n\\subsubsection*{Slotted}\n\\(G = 1\\) to get maximum throughput.\\\\\nSystem frames per second: \\( G \\cdot \\frac{1000}{0.4} = 2500 \\text{Frames per Second} \\) \\\\\n50 stations, so average frames per second per station: \\(\\frac{2500}{50} = 50\\)\n\n\\subsection*{ALOHA system throughput}\n\\(T_{fr} = \\frac{2000}{10^6} = \\SI{2}{\\milli\\second}\\)\n\n\\(G = \\frac{500}{\\frac{1000}{2}} = 1\\)\n\n\\(50 \\cdot 10 = 500\\) Frames sent per second\n\n\\subsubsection*{Pure}\n\\(S = G \\cdot e^{-2} = 0.135 \\) \\\\\nSystem throughput: \\(500 \\cdot 0.135 = 67.7\\) Frames per second\n\n\\subsubsection*{Slotted}\n\\(S = G \\cdot e^{-1} = 0.368 \\) \\\\\nSystem throughput: \\(500 \\cdot 0.368 = 183.9\\) Frames per second\n\n\\subsection*{CSMA/CD}\n\n\\ifx\\du\\undefined\n    \\newlength{\\du}\n\\fi\n\\setlength{\\du}{15\\unitlength}\n\\begin{tikzpicture}\n    \\pgftransformxscale{0.998158}\n    \\pgftransformyscale{-0.998158}\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\definecolor{dialinecolor}{rgb}{1.000000, 1.000000, 1.000000}\n    \\pgfsetfillcolor{dialinecolor}\n    \\definecolor{dialinecolor}{rgb}{1.000000, 1.000000, 1.000000}\n    \\pgfsetfillcolor{dialinecolor}\n    \\fill (13.000000\\du,8.000000\\du)--(13.000000\\du,10.000000\\du)--(17.000000\\du,10.000000\\du)--(17.000000\\du,8.000000\\du)--cycle;\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetmiterjoin\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\draw (13.000000\\du,8.000000\\du)--(13.000000\\du,10.000000\\du)--(17.000000\\du,10.000000\\du)--(17.000000\\du,8.000000\\du)--cycle;\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node at (15.000000\\du,9.194053\\du){A};\n    \\definecolor{dialinecolor}{rgb}{1.000000, 1.000000, 1.000000}\n    \\pgfsetfillcolor{dialinecolor}\n    \\fill (23.000000\\du,8.000000\\du)--(23.000000\\du,10.000000\\du)--(27.000000\\du,10.000000\\du)--(27.000000\\du,8.000000\\du)--cycle;\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetmiterjoin\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\draw (23.000000\\du,8.000000\\du)--(23.000000\\du,10.000000\\du)--(27.000000\\du,10.000000\\du)--(27.000000\\du,8.000000\\du)--cycle;\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node at (25.000000\\du,9.194053\\du){B};\n    \\definecolor{dialinecolor}{rgb}{1.000000, 1.000000, 1.000000}\n    \\pgfsetfillcolor{dialinecolor}\n    \\fill (33.000000\\du,8.000000\\du)--(33.000000\\du,10.000000\\du)--(37.000000\\du,10.000000\\du)--(37.000000\\du,8.000000\\du)--cycle;\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetmiterjoin\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\draw (33.000000\\du,8.000000\\du)--(33.000000\\du,10.000000\\du)--(37.000000\\du,10.000000\\du)--(37.000000\\du,8.000000\\du)--cycle;\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node at (35.000000\\du,9.194053\\du){C};\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (15.000000\\du,10.000000\\du)--(15.000000\\du,20.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (25.000000\\du,10.000000\\du)--(25.000000\\du,20.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (35.000000\\du,10.000000\\du)--(35.000000\\du,20.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\pgfsetarrowsend{to}\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (15.000000\\du,10.000000\\du)--(35.000000\\du,18.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\pgfsetarrowsend{to}\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (25.000000\\du,12.000000\\du)--(15.000000\\du,16.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\pgfsetarrowsend{to}\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (25.000000\\du,12.000000\\du)--(35.000000\\du,16.000000\\du);\n    }\n    \\pgfsetlinewidth{0.100000\\du}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetdash{}{0pt}\n    \\pgfsetbuttcap\n    {\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetfillcolor{dialinecolor}\n        % was here!!!\n        \\pgfsetarrowsend{to}\n        \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n        \\pgfsetstrokecolor{dialinecolor}\n        \\draw (35.000000\\du,14.000000\\du)--(15.000000\\du,20.000000\\du);\n    }\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (14.000000\\du,10.000000\\du){};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (14.000000\\du,10.000000\\du){};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,10.000000\\du){0uS};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,12.000000\\du){1uS};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,14.000000\\du){2uS};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,16.000000\\du){3uS};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,18.000000\\du){4uS};\n    % setfont left to latex\n    \\definecolor{dialinecolor}{rgb}{0.000000, 0.000000, 0.000000}\n    \\pgfsetstrokecolor{dialinecolor}\n    \\node[anchor=west] at (27.000000\\du,20.000000\\du){5uS};\n\\end{tikzpicture}\n\nTransmission rate: \\(10\\times 10 ^{6} \\times 3 \\times 10 ^{-6} = \\SI{30}{\\bit\\per\\second}\\)\\\\\nA will transmit for \\SI{3}{\\micro\\second}, \\SI{30}{\\bit}\\\\\nB will transmit for \\SI{1}{\\micro\\second}, \\SI{10}{\\bit}\\\\\nC will transmit for \\SI{1}{\\micro\\second}, \\SI{10}{\\bit}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "475169e7b4643d64f74e4143d06a15c530f63088", "size": 9105, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignments/ECE487/Assignment5.tex", "max_stars_repo_name": "n30phyte/SchoolDocuments", "max_stars_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignments/ECE487/Assignment5.tex", "max_issues_repo_name": "n30phyte/SchoolDocuments", "max_issues_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignments/ECE487/Assignment5.tex", "max_forks_repo_name": "n30phyte/SchoolDocuments", "max_forks_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5805084746, "max_line_length": 130, "alphanum_fraction": 0.6606260297, "num_tokens": 3697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.43234921036062157}}
{"text": "\\subsection{KENN with multiloss function}\nIn previous experiments, it has been observed that the pre-KENN network adapts to the presence of KENN regardless of the parameters configuration. From these results comes the intuition to make the pre-KENN network more independent, with the purpose of exploiting the logical knowledge more effectively. To achieve this, the idea is to define a custom multiloss function to simultaneously improve the quality of the pre-KENN and post-KENN predictions.\n\n%\\subsubsection{Multiloss function}\nThe proposed multiloss function is computed by combining the Binary Cross-Entropy (BCE) loss values obtained from the pre-KENN and post-KENN preactivations. To make it possible, the model has been adapted to provide two outputs: one before and one after KENN's layer. The goal is to optimize the post-KENN predictions while preserving a discrete quality of pre-KENN predictions. The final loss is computed by the convex combination of the two losses whose influences are regulated by the parameter $ \\alpha $. The resulting formula is the following:\n\n% \\begin{gather*}\n%     L(y_{pred},y_{true}) = \\alpha \\cdot BCE(y_{prekenn}, y_{true}) + (1 - \\alpha) \\cdot BCE(y_{postkenn}, y_{true})\n% \\end{gather*}\n\n\\begin{gather*}\n    L(Y, Y', Y_{t}) = \\alpha \\cdot BCE(Y, Y_{t}) + (1 - \\alpha) \\cdot BCE(Y', Y_{t})\n\\end{gather*}\nwhere $Y$ denotes the pre-KENN predictions, $Y'$ the post-KENN predictions, and $Y_{t}$ the values of the ground truth.\n\n\n\\subsubsection{Setup}\nThe models involved in this experiment are trained following the \\textit{Setup B}. The configuration of the other parameters is the following:\n\\begin{itemize}\n    \\item \\textbf{KB modes:} Bottom Up and Top Down\n    \\item \\textbf{initial clause weights:} 0.5 and variable\\footnote{With the term ``variable\" we mean that each clause can be initialized with a different value. The original implementation of KENN did not contemplate this possibility when setting clause weights as learnable parameters, so we introduced a small modification to make it possible.}\n    \\item \\textbf{learnable clause weights}\n    \\item \\textbf{encoder:} DistilBERT and BERT, with adapters\n    \\item \\textbf{loss function:} multiloss with $\\alpha = 0.5$\n\\end{itemize}\nThe total number of configurations obtained by varying these parameters is 8. Since the pre-KENN network is expected to be less influenced by KENN, the clause weights are set as learnable parameters with small initial values to start with a soft influence and let the network establish the relevance of each clause. Indeed, the choice of learnable clause weights allows us to study the weight evolution during the epochs and determine which are the most useful and the least useful clauses. Furthermore, for each clause, the types that are the antecedents of an implication rule (i.e., the types that propagate the information and uniquely characterize the used KBs) have been studied to look for some recurring behavioral patterns. The \\textit{Hybrid} mode is excluded from this study because it involves the same clauses of \\textit{Bottom Up} and \\textit{Top Down}, but with the addition of noise due to the presence of conflicts. For this reason, it would not have been possible to carry out an accurate analysis.\n\n\\subsubsection{Results on FIGER}\n\\paragraph{DistilBERT}\nThe results obtained using DistilBERT as encoder show some very interesting behaviors of the clause weights. Starting from the Bottom Up, if we look at the distribution of final clause weights in Figure~\\ref{fig:weight_distrib_distilbert_figer_bu_multiloss} we can see that almost every weight decreases its initial value. This attitude is not observable in Figure~\\ref{fig:weight_distrib_distilbert_figer_bu_learnable} when using KENN with a standard loss and learnable weights. If we look at the figure, we can see widely different results since almost every weight increases its starting value. The same trend is detectable in the Top Down mode, as shown in Figure~\\ref{fig:weight_distrib_distilbert_figer_td}.\n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_distrib_distilbert_figer_bu_multiloss.png}\n         \\caption{Multiloss model - Epoch 55 (563K examples)}\n         \\label{fig:weight_distrib_distilbert_figer_bu_multiloss}\n     \\end{subfigure}\n     \\hspace{10px}\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_distrib_distilbert_figer_bu_learnable.png}\n         \\caption{Standard loss model - Epoch 42 (430K examples)}\n         \\label{fig:weight_distrib_distilbert_figer_bu_learnable}\n     \\end{subfigure}\n    \\caption{Distributions of the final learned clause weights for the Bottom Up KB mode using DistilBERT-based models - FIGER}\n    \\label{fig:weight_distrib_distilbert_figer_bu}\n\\end{figure}\n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_distrib_distilbert_figer_td_multiloss.png}\n         \\caption{Multiloss model - Epoch 42 (430K examples)}\n         \\label{fig:weight_distrib_distilbert_figer_td_multiloss}\n     \\end{subfigure}\n     \\hspace{10px}\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_distrib_distilbert_figer_td_learnable.png}\n         \\caption{Standard loss model - Epoch 39 (399K examples)}\n         \\label{fig:weight_distrib_distilbert_figer_td_learnable}\n     \\end{subfigure}\n    \\caption{Distributions of the final learned clause weights for the Top Down KB mode using DistilBERT-based models - FIGER}\n    \\label{fig:weight_distrib_distilbert_figer_td}\n\\end{figure}\n\n\nMoving on to the analysis of the types involved in the clauses we can observe an unexpected behavior. For both Bottom Up and Top Down modes, this study intercepts a remarkable fact: the more a type occurs in the training set, the lower the final weight of its clause. The few clauses that preserve a high weight are those whose antecedents are the rarest in the dataset. Starting from the Bottom Up mode, we can see in Figure~\\ref{fig:weight_freq_distilbert_figer_bu_multiloss} a graph showing the relation between the final weight and the frequency of each type S. Looking at the figure, we can clearly observe that there is a strong correlation between weight and frequency. Indeed, the correlation coefficient is -0.77. The Top Down mode (Figure~\\ref{fig:weight_freq_distilbert_figer_td_multiloss}) also presents a negative correlation, this time of -0.68 with respect to the frequencies of types F.\n%This behavior may be explained by the fact that KENN introduces too much noise to types that the network can already predict discretely without the use of knowledge. \n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_distilbert_figer_bu_multiloss.png}\n         \\caption{Bottom Up - Epoch 55 (563K examples)}\n         \\label{fig:weight_freq_distilbert_figer_bu_multiloss}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_distilbert_figer_td_multiloss.png}\n         \\caption{Top Down - Epoch 42 (430K examples)}\n         \\label{fig:weight_freq_distilbert_figer_td_multiloss}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using DistilBERT - FIGER}\n    \\label{fig:weight_freq_distilbert_figer}\n\\end{figure}\n\nBy inspecting the weight evolution over the epochs, it emerged that the clause weights keep decreasing until the last epoch, but it is not known for how long they would have continued. To observe in advance the effect of higher epochs and see if some clauses would have reached a weight close to zero, new models were trained starting from variable weights assigned with respect to the frequency of the antecedents of each clause. Clauses involving popular types were assigned a weight of 0.2, while the others kept a weight of 0.5. The weight assignment is based on a frequency threshold of 70K for Bottom Up and 50K for Top Down\\footnote{the values are chosen by observing the graphs, without formalizing a mathematical criterion}. The results of these runs are shown in Figure~\\ref{fig:weight_freq_distilbert_figer_bu_multiloss_variable} and Figure~\\ref{fig:weight_freq_distilbert_figer_td_multiloss_variable} for Bottom Up and Top Down, respectively. As we can see, most clause weights decreased their values even when starting from lower initial values.\n%However, by analyzing the weight evolution, it emerged that their decrease over the epochs was slowed down. The reason for this fact is that clauses now have less influence on the final prediction, so they are penalized in a minor way by the loss function.\n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_distilbert_figer_bu_multiloss_variable.png}\n         \\caption{Bottom Up - Epoch 71 (727K examples)}\n         \\label{fig:weight_freq_distilbert_figer_bu_multiloss_variable}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_distilbert_figer_td_multiloss_variable.png}\n         \\caption{Top Down - Epoch 42 (430K examples)}\n         \\label{fig:weight_freq_distilbert_figer_td_multiloss_variable}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using DistilBERT and \\textit{variable} clause weights - FIGER}\n    \\label{fig:weight_freq_distilbert_figer_variable}\n\\end{figure}\n\n\\paragraph{BERT}\nThe experiments performed using BERT showed an identical behavior. The results obtained with weights set to 0.5 for every clause are shown in Figure~\\ref{fig:weight_freq_bert_figer}. The correlation between weight and frequency is similar (-0.76 in Bottom Up, -0.74 in Top Down) as well as the weight evolution during the epochs. The only difference with respect to DistilBERT is that BERT needs fewer epochs to converge, so its weights have decreased less as it performed fewer backward propagation operations. Much lower weights are reached when using the setup with variable weights as reported in Figure~\\ref{fig:weight_freq_bert_figer_variable}.\n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_figer_bu_multiloss.png}\n         \\caption{Bottom Up - Epoch 35 (358K training examples)}\n         \\label{fig:weight_freq_bert_figer_bu_multiloss}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_figer_td_multiloss.png}\n         \\caption{Top Down - Epoch 35 (358K training examples)}\n         \\label{fig:weight_freq_bert_figer_td_multiloss}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using BERT - FIGER}\n    \\label{fig:weight_freq_bert_figer}\n\\end{figure}\n\n\\begin{figure}[bth]\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_figer_bu_multiloss_variable.png}\n         \\caption{Bottom Up - Epoch 49 (501K training examples)}\n         \\label{fig:weight_freq_bert_figer_bu_multiloss_variable}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_figer_td_multiloss_variable.png}\n         \\caption{Top Down - Epoch 33 (337K training examples)}\n         \\label{fig:weight_freq_bert_figer_td_multiloss_variable}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using BERT and \\textit{variable} clause weights - FIGER}\n    \\label{fig:weight_freq_bert_figer_variable}\n\\end{figure}\n\n\n\\subsubsection{Results on BBN}\nThe experiments on BBN were performed directly on BERT. In Figure~\\ref{fig:weight_freq_bert_bbn} are represented the graphs of weights and frequencies using the same weight for each clause. The correlation coefficients of the Bottom Up and Top Down modes are -0.73 and -0.55, respectively. The results obtained after repeating the experiments using variable weights are shown in Figure~\\ref{fig:weight_freq_bert_bbn_variable}. The weight assignment is based on a frequency threshold of 1700 for Bottom Up and 1500 for Top Down\\footnote{the values are chosen by observing the graphs, without formalizing a mathematical criterion}. Looking at the graphs, it is possible to observe that most of the weights continued to decrease.\n\n\\begin{figure}\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_bbn_bu_multiloss.png}\n         \\caption{Bottom Up - Epoch 28 (286K training examples)}\n         \\label{fig:weight_freq_bert_bbn_bu_multiloss}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_bbn_td_multiloss.png}\n         \\caption{Top Down - Epoch 19 (194K training examples)}\n         \\label{fig:weight_freq_bert_bbn_td_multiloss}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using BERT - BBN}\n    \\label{fig:weight_freq_bert_bbn}\n\\end{figure}\n\n\\begin{figure}\n     \\centering\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_bbn_bu_multiloss_variable.png}\n         \\caption{Bottom Up - Epoch 19 (194K training examples)}\n         \\label{fig:weight_freq_bert_bbn_bu_multiloss_variable}\n         \\vspace{10px}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.7\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/weight_freq_bert_bbn_td_multiloss_variable.png}\n         \\caption{Top Down - Epoch 19 (194K training examples)}\n         \\label{fig:weight_freq_bert_bbn_td_multiloss_variable}\n     \\end{subfigure}\n    \\caption{Relation between types frequency (log scale) and final clause weights of multiloss models using BERT and \\textit{variable} clause weights - BBN}\n    \\label{fig:weight_freq_bert_bbn_variable}\n\\end{figure}\n\n\n\n\\subsubsection{Conclusion}\nThe multiloss experiments showed that the pre-KENN network suffers the presence of some logical clauses when it is forced to not adapt its predictions to KENN. In particular, it has been possible to see that the learning process penalized clauses involving the most frequent types much more than the others. This behavior can be motivated by the fact that if a network sees a lot of instances labeled with some types, then it becomes able to correctly classify them without needing logical knowledge. For this reason, it seems that the action of KENN on frequent types is seen as noise added to the final predictions. Conversely, the enhancement of rarer types is not penalized by the learning process, so logical clauses seem to be helpful for the network when few examples labeled with those types are available. For this reason, using a multiloss setup could be a reasonable choice to exploit logical knowledge only where needed, thus avoiding having side effects on the types that are easier to predict.\n\n", "meta": {"hexsha": "130373432f4e62560fdcad3064f108f18c83fed1", "size": 15857, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "project/experiments/multiloss.tex", "max_stars_repo_name": "christianbernasconi96/MasterThesis", "max_stars_repo_head_hexsha": "6211ff86af247aace530912c4eca9019365d606e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "project/experiments/multiloss.tex", "max_issues_repo_name": "christianbernasconi96/MasterThesis", "max_issues_repo_head_hexsha": "6211ff86af247aace530912c4eca9019365d606e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project/experiments/multiloss.tex", "max_forks_repo_name": "christianbernasconi96/MasterThesis", "max_forks_repo_head_hexsha": "6211ff86af247aace530912c4eca9019365d606e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.1133004926, "max_line_length": 1058, "alphanum_fraction": 0.7645834647, "num_tokens": 3940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4323492090936783}}
{"text": "\\documentclass{beamer}\n\n\\usetheme{uhh}\n\\showtotalframenumber\n\\showuhhlogoeachframe\n\\showsections\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\n\\usepackage{listings}\n\\lstset{\n  language=python\n  }\n\n\\title{Part 04: Implementing Word2Vec in Tensorflow}\n\\author{Fabian Barteld, Benjamin Milde}\n\\date[20.06.2016]{June 20, 2016}\n\n\\AtBeginSection[]\n{\n   %%%%% section title\n   % This is how it would look like in Beamer:\n   % \\begin{frame}\n   %     \\frametitle{Overview}\n   %     \\tableofcontents[sections={2-3},currentsection,sectionstyle=show/hide,subsectionstyle=hide]\n   % \\end{frame}\n  \\begin{frame}[plain]\n  \\begin{tikzpicture}[overlay]\n    \\relax%\n    \\fill[blueuhh,opacity=1] (-10,-10)\n    rectangle(\\the\\paperwidth,\\the\\paperheight);\n  \\end{tikzpicture}\n   \\begin{tikzpicture}[overlay]\n    \\relax%\n    \\fill[white,opacity=1] (-5,-1.2)\n    rectangle(\\the\\paperwidth,0.5) node[pos=0.5,black]{\\LARGE\\insertsectionhead};\n  \\end{tikzpicture}\n  \\end{frame}\n\n  %%%% add subsection to show navigation dots\n  \\subsection{}\n}\n\n\\begin{document}\n\n\\maketitle\n\n%\\begin{frame}\n%  \\frametitle{Overview}\n%\n%  \\tableofcontents\n%\n%\\end{frame}\n\n\\section{Introduction}\n\n\\begin{frame}[fragile]\n\\frametitle{Training embeddings}\n  \\begin{itemize}\n\t\\item We will now implement Word2Vec in Tensorflow\n\t\\item (Slides smiliar to https://www.tensorflow.org/tutorials/word2vec)\n\t\\includegraphics[width=0.7\\textwidth]{04_skipgram_vs_cbow}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Main concepts I}\n  \\begin{itemize}\n     \n    \\item  Neural probabilistic language models are traditionally trained using the maximum likelihood (ML) principle (where $w_t$ is the target word and $h$ is the context):\n\t \n\t \\end{itemize}\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{04_w2v_01}\n\\end{center}\t \n\t \n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Main concepts II}\n  \\begin{itemize}\n     \n    \\item  Neural probabilistic language models are traditionally trained using the maximum likelihood (ML) principle (where $w_t$ is the target word and $h$ is the context):\n\t \n\t \\end{itemize}\n\n$$P(w_t | h) = \\text{softmax}(\\text{score}(w_t, h)) = $$\n\t$$ \\frac{\\ exp\\{\\text{score}(w_t, h) \\} } {\\sum_\\text{Word w' in Vocab} \\ exp\\{ \\text{score}(w', h) \\}}$$\t \n\t \n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Main concepts III}\n  \n    \\begin{itemize}\n\n\t\\item We train this model by maximizing its log-likelihood on the training set, i.e. by maximizing:\n\n\t$$  J_\\text{ML} = \\log P(w_t | h) \\ = $$\n\t$$  \\text{score}(w_t, h) - \\log \\left( \\sum_\\text{Word w' in Vocab} \\exp { \\text{score}(w', h) } \\right). $$\n\t\n\t\\item However this is very expensive, because we need to compute and normalize each probability using the score for all other $V$ words $w'$ in the current context $h$, at every training step.\n\t\\end{itemize}\n  \n\\end{frame} \n\n\\begin{frame}\n  \\frametitle{Main concepts IV - NCE}\n  \n    \\begin{itemize}\n    \\item Noise Contrastive Estimation (NCE)\n\t\\item For feature learning in word2vec we do not need a full probabilistic model. Instead, we train to discriminate the real target words $w_t$ from $k$ imaginary (noise) words w~:\n\t\n\t\\end{itemize}\n\t\n\t\\begin{center}\n\t\\includegraphics[width=0.6\\textwidth]{04_w2v_02}\n\t\\end{center}  \n  \n\\end{frame} \n\n\n\\begin{frame}\n  \\frametitle{Main concepts V - NCE}\n  \n  \\begin{itemize}\n\\item Mathematically, the objective is to maximize:\n\n$$J_\\text{NCE} = \\log Q_\\theta(D=1 |w_t, h) + k \\mathop{\\mathbb{E}}\\limits_{\\tilde w \\sim P_\\text{noise}} \\left[ \\log Q_\\theta(D = 0 |\\tilde w, h) \\right]$$\n\n\\item discriminate the real target words \\(w_t\\) from \\(k\\) imaginary (noise) words \\(\\tilde w\\)\n\\item where $Q_\\theta(D=1 | w, h)$ is the binary logistic regression probability\n\\item under the model of seeing the word $w$ in the context $h$ and assigning the label 1 for datapoint $D$, calculated in terms of the learned embedding vectors $\\theta$\n\n\\end{itemize}\n\\end{frame} \n\n\\begin{frame}\n  \\frametitle{Impl. I - Tensorflow W2V}\n    \\begin{itemize}\n    \t\\item In practice we approximate the expectation by drawing k contrastive words from the noise distribution (i.e. we compute a Monte Carlo average) \n   $$J_\\text{NCE} \\approx \\log Q_\\theta(D=1 |w_t, h) +  \\sum_{i=1, w \\sim P_\\text{noise}}^{k}  \\left[ \\log Q_\\theta(D = 0 |\\tilde w, h) \\right]$$ \n   \\item Now we can choose $k \\neq |V|$, in practice 5-10 for small datasets, 2-5 for large datasets\n   \\item Negative sampling, as in the word2vec paper, is a variant of NCE and uses a specific distribution (uniform raised to the power of 3/4)\n   \n \\end{itemize}\n\\end{frame} \n\n\\begin{frame}[fragile]\n  \\frametitle{Impl. II - Tensorflow W2V}\n  \\begin{lstlisting}\n\nloss = tf.reduce_mean(\n  tf.nn.nce_loss(weights=nce_weights,\n                 biases=nce_biases,\n                 labels=train_labels,\n                 inputs=embed,\n                 num_sampled=num_sampled,\n                 num_classes=vocabulary_size))\n    \\end{lstlisting}\n    \n  \\begin{itemize}\n  \t\\item We can use the NCE loss op of Tensorflow to construct a variant of word2vec. Internally, nce\\_weights also uses embedding\\_lookup and does a form of negative sampling  directly in Tensorflow.\n  \\end{itemize}\n\\end{frame}\n    \n \\begin{frame}[fragile]\n  \\frametitle{Impl. III - Tensorflow W2V}\n  The embeddings matrix is a variable that we want to optimize:\n  \\begin{lstlisting}\nembeddings = tf.Variable(\ntf.random_uniform([vocabulary_size,\nembedding_size], -1.0, 1.0))\n\\end{lstlisting}    \n\\end{frame}\n\n \\begin{frame}[fragile]\n \\frametitle{Impl. IIII - Tensorflow W2V}\nWe also need variables for the nce\\_loss:\n\n\\begin{footnotesize}\n\\begin{lstlisting}\nnce_weights = tf.Variable(\n  tf.truncated_normal([vocabulary_size, embedding_size],\nstddev=1.0 / math.sqrt(embedding_size)))\nnce_biases = tf.Variable(tf.zeros([vocabulary_size]))\n\\end{lstlisting}   \n\\end{footnotesize}    \n\\end{frame}\n\n \\begin{frame}[fragile]\n  \\frametitle{Impl. IV - embedding\\_lookup:}\n  \n  \\begin{footnotesize}\n \\begin{lstlisting}\nembed = tf.nn.embedding_lookup(embeddings, train_inputs)\n\\end{lstlisting}\n\\end{footnotesize}    \n\ne.g. If your list of sentences is: $\\big[[0, 1], [0, 3]\\big]$ (sentence 1 is $[0, 1]$, sentence 2 is $[0, 3]$, the function will compute a tensor of embeddings, which will be of shape $(2, 2, \\text{embedding\\_size})$ and will look like:\n\\\\\n$$[[\\text{embedding0, embedding1}], [\\text{embedding0, embedding3}]]$$\n\n\\end{frame}\n\n \\begin{frame}[fragile]\n\n  \\frametitle{Exercise 1 - simple version}\n   \\begin{itemize}\n   \t\t\\item Lets put it together: We can use tf.nn.embedding\\_lookup for the input projection and tf.nn.nce\\_loss for the loss (no other layers needed!).\n\t\t\\item For simplicity, lets also implement CBOW and Skipgram with a window size of 1. \n\t\t\\item E.g. for \"the quick brown fox jumped over the lazy dog\"\n\t\t\\item (context, target) pairs: ([the, brown], quick), ([quick, fox], brown), ([brown, jumped], fox)\n\t\t\\item We can simplify to: (the, quick), (brown, quick), (quick, brown), (fox, brown), ... \\textbf{CBOW}\n\t\t\\item or (quick, the), (quick, brown), (brown, quick), (brown, fox), ... \\textbf{Skip-gram}\n\t\\end{itemize}\n\\end{frame}\n\n \\begin{frame}[fragile]\n\n  \\frametitle{Exercise 2 - advanced version}\n   \\begin{itemize}\n\t\t\\item Lets try to make a version that does not use tf.nn.nce\\_loss, as easy as that makes our lives!\n\t\t\\item We can also do the negative sampling on the host and code up a linear regression as in the previous tutorials\n\t\t\\item Host will assign labels (1 for true context pairs, 0 for noise pairs)\n\t\t\\item You have to change the code in the get\\_batch function and the inputs to your model and adapt your model accordingly\t\t\n\t\\end{itemize}\n\\end{frame}\n\n \\begin{frame}[fragile]\n \n \\frametitle{Hints}\n  \\begin{itemize}\n\t\t\\item Hint1: The negative samples need a second embedding matrix\n\t\t\\item Hint2: For the loss, to get the logits, use the dot product between embedding pairs.\n\t\t\\item Hint3: There is no tf.dot(), but you can combine tf.reduce\\_sum(x,1) and tf.multiply(a,b).\n\t\t\\item Hint4: Readable pure Python code with comments: , or if you're feeling masochistic the original uncommented word2vec C impl at: \n\t\\end{itemize}\n\t\t\n\\end{frame}\n\n\n \\begin{frame}[fragile]\n \n \\frametitle{Tensorboard}\n  \\begin{itemize}\n\t\t\\item Visualize loss, embeddings and much more in your browser\n\t\t\\item You need to add a few lines of code to tell Tensorboard what to log\n\t\t\\item Make sure train\\_summary\\_dir is a new directory for every new experiment!\n\t\\end{itemize}\n\t\t\t\n\t\\begin{tiny}\n\\begin{lstlisting}\n loss_summary = tf.summary.scalar('loss', loss) \n train_summary_op = tf.summary.merge_all()\n summary_writer = tf.summary.FileWriter(train_summary_dir, sess.graph)\n\\end{lstlisting}   \n\\end{tiny}    \n\t\n\\end{frame}\n\n\\begin{frame}[fragile]\n \n \\frametitle{Tensorboard}\n  \\begin{itemize}\n\t\t\\item You need to regularly call the train\\_summary\\_op in training\n\t\t\\item Not as often as the training step, because it will otherwise slowdown your training if you have more complex summaries\n\t\\end{itemize}\n\t\t\t\n\\begin{tiny}\n\\begin{lstlisting}\nif current_step % 100==0 and current_step != 0:\n\tsummary_str = sess.run(train_summary_op, feed_dict=feed_dict)\n\tsummary_writer.add_summary(summary_str, current_step)\n\\end{lstlisting}   \n\\end{tiny}    \n\t\n\\end{frame}\n\n\\begin{frame}[fragile]\n \\frametitle{Tensorboard - running it}\n \\begin{tiny}\n \\begin{lstlisting}\npython3 -m tensorflow.tensorboard  --logdir=w2v_summaries_1499773534\n--host=127.0.0.1\n\\end{lstlisting}   \n\\end{tiny}\n \\includegraphics[width=0.5\\textwidth]{04_loss}\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n \\frametitle{Tensorboard - embeddings}\n   \\begin{itemize}\n\t\t\\item Possible to nicely visualize embeddigs, see \\url{https://www.tensorflow.org/get_started/embedding_viz}\n\t\t\\item Also checkout \\url{http://projector.tensorflow.org/}, live demo of pretrained embeddings\n\t\t\\includegraphics[width=0.5\\textwidth]{04_embed_viz.png}\n\t\\end{itemize}\n\\end{frame}\n\n \n%\\begin{frame}[fragile]\n%  \\frametitle{Layer based APIs vs. Graphs based}\n%  \n%Disadvantage: Difficult to express structures like these:\n%  \n%    \\includegraphics[angle=-90,width=0.75\\textwidth]{graph_example}\n%\n%Increasing evidence that these kind of deeply connected networks are very useful.\n%  \n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Layer based APIs vs. Graphs based}\n%  \\begin{itemize}\n%\t\t\\item  Since Tensorflow uses computation graphs, the declaration of the model allows for a higher expressivity\n%\t\t\\item  Has a steeper learning curve in the beginning\n%\t\t\\item  In the newer versions of tensorflow, you can also mix layer-like APIs with the computation graph\n%\t\t\\item  We will focus on not using any short cuts, as this has a higher learning effect and only make use of standard ops in the beginning\n%  \\end{itemize}\n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%\\frametitle{First steps - Lets open spyder}\n%\n%\\includegraphics[width=1.0\\textwidth]{spyder}\n%\n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%\\frametitle{First steps - Necessary imports}\n%\n%\\begin{lstlisting}\n%import numpy as np\n%import tensorflow as tf\n%\\end{lstlisting}\n%\n%\\begin{itemize}\n% \t\\item Outside of graph computations, we usually store data in Numpy arrays.\n% \t\\item Numpy arrays are the main objects to transfer data to inputs of the graph and from outputs of the graph.\n% \t\\item Numpy arrays are also an abstraction for (homogeneous) multidimensional arrays.\n%\\end{itemize}\n%\n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%\\frametitle{Generating some random data}\n%\n%\\begin{lstlisting}\n%#some random test data\n%a_data = np.random.rand(256)\n%b_data = np.random.rand(256)\n%\\end{lstlisting}\n%\n%\\begin{itemize}\n%\t\\item Now a and b contain vectors of length 256 with random floats. E.g. print(a\\_data) returns:\n%\\end{itemize}\n%\n%\\begin{lstlisting}\n%[ 0.54976368  0.87790201  0.96528541 ..., \n% 0.05281365  0.48556404  0.46848266]\n%  \\end{lstlisting}\n%\n%\\end{frame} \n%\n%\n%\\begin{frame}[fragile]\n%\\frametitle{Declare the computation graph}\n%\n%\\begin{lstlisting}\n%#construct the graph\n%a = tf.placeholder(tf.float32, [256])\n%b = tf.placeholder(tf.float32, [256])\n%\n%x = a+b \n%\\end{lstlisting}\n%\n%\\begin{itemize}\n%\\item The placeholders can later be used to input data to the computation graph\n%\\item The operation x = a+b does not immediatly add something, it creates a graph.\n%\\item In fact, print(x) returns: \n%\\end{itemize}\n%\n%\\begin{lstlisting}\n%Tensor(\"add:0\", shape=(256,), dtype=float32)\n%\\end{lstlisting}\n%\n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%\\frametitle{A session on a computation device}\n%\n%\\begin{lstlisting}\n%with tf.device('/cpu'):\n%    with tf.Session() as sess:\n%       x_data = sess.run(x, {a: a_data, b: b_data})  \n%       print(x_data)\n%\\end{lstlisting}\n%\n%\\begin{itemize}\n%\\item This fills the inputs a and b with a\\_data and b\\_data (our random data), runs the computation graph and retrieves the results of x in x\\_data\n%\\item Obviously not terrible useful as is, but you could run the operation easily on a gpu by changing tf.device('/cpu') to  tf.device('/gpu:1'). Copying data to and from the GPU is handled automatically for you.\n%\\end{itemize}\n%\n%\\end{frame} \n%\n%\\begin{frame}[fragile]\n%\\frametitle{Small warm up exercise!}\n%\n%\\begin{itemize}\n%\t\\item We change a and b to random matrices:\n%\\end{itemize}\n%\n%\\begin{lstlisting}\n%a = np.random.rand(256, 128)\n%b = np.random.rand(128, 512)\n%\\end{lstlisting}\n%\n%\\begin{itemize}\n%\t\\item Calculate the resulting matrix of shape (256, 512) in TensorFlow.\n%\\end{itemize}\n%\n%\\end{frame} \n\n%\\section{Simple Optimization}\n%\n%% https://medium.com/@saxenarohan97/intro-to-tensorflow-solving-a-simple-regression-problem-e87b42fd4845\n%% https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/linear_regression.py\n%\\begin{frame}\n%  \\frametitle{Linear Regression}\n%\n%  \\begin{itemize}\n%  \\item Given: $(x_1, y_1)$, \\ldots, $(x_n,y_n)$\n%  \\item Goal: find $w$ and $b$ such that:\n%    \\begin{displaymath}\n%      \\argmin_{w, b} \\frac{\\sum^n_{i=1} (\\hat{y}_i - y_i)^2}{n}\n%    \\end{displaymath}\n%    where $\\hat{y}_i = wx_i + b$.\n%  \\end{itemize}\n%\n%\\end{frame}\n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Define model parameters}\n%  Model: $\\hat{y}_i = wx_i + b$\n%\n%\\begin{lstlisting}\n%w = tf.Variable(np.random.randn(), name=\"weight\")\n%b = tf.Variable(np.random.randn(), name=\"bias\")\n%\\end{lstlisting}\n%\\end{frame}\n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Define the model}\n%\n%  \\begin{displaymath}\n%    \\begin{pmatrix} \\hat{y}_1\\\\\\vdots\\\\\\hat{y}_n\\end{pmatrix} =\n%    \\begin{pmatrix} w\\\\\\vdots\\\\w\\end{pmatrix} *\n%    \\begin{pmatrix} \\hat{x}_1\\\\\\vdots\\\\\\hat{x}_n\\end{pmatrix} +\n%    \\begin{pmatrix} b\\\\\\vdots\\\\b\\end{pmatrix}\n%  \\end{displaymath}\n%\n%\\begin{lstlisting}\n%yhat = tf.add(tf.multiply(X, w), b)\n%\\end{lstlisting}\n%\n%{\\footnotesize The scalars $w$ and $b$ are converted into vectors of the same\n%  length as X (broadcast); \\url{https://www.tensorflow.org/performance/xla/broadcasting}}\n%\n%\\end{frame}\n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Define the loss}\n%\n%\\begin{lstlisting}\n%loss = tf.reduce_mean(tf.square(y - yhat))\n%\\end{lstlisting}\n%\n%\\end{frame}\n%\n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Optimization}\n%\n%\\begin{lstlisting}\n%epochs = 10\n%optimizer = tf.train.GradientDescentOptimizer(\n%    learning_rate).minimize(loss)\n%\n%with tf.Session() as sess:\n%    ## initalize parameters\n%    sess.run(tf.global_variables_initializer())\n%\n%    for i in list(range(epochs)):\n%        ## run one epoch\n%        sess.run(optimizer)\n%        ## print result and loss\n%        print(sess.run(yhat) + ' ' + sess.run(loss))\n%\\end{lstlisting}\n%\n%\\end{frame}\n%\n%\\begin{frame}[fragile]\n%  \\frametitle{Hands on: Simple optimization}\n%\n%  \\begin{enumerate}\n%  \\item Do a linear regression to learn $y = 2x + 1$\n%  \\item Do a multiple linear regression with Boston housing prices\n%  \\end{enumerate}\n%\n%\\begin{lstlisting}\n%from sklearn.datasets import load_boston\n%from sklearn.preprocessing import scale\n%\n%total_X, total_Y = load_boston(True)\n%total_x = scale(total_x)\n%\\end{lstlisting}\n%\\end{frame}\n%\n%% https://www.tensorflow.org/tutorials/wide\n%% https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/logistic_regression.py\n%\\begin{frame}\n%  \\frametitle{Logistic regression}\n%\n%  TODO\n%  tf.sigmoid\n%\n%\\end{frame}\n%\n%\\begin{frame}\n%  \\frametitle{Hands on: Regression model}\n%\n%  TODO: more complex example\n%\\end{frame}\n\n\\end{document}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-engine: luatex\n%%% End:\n", "meta": {"hexsha": "a5dc2dbd35626af6188a4476bbf15ceef3ef0f41", "size": 16404, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "dump/04_embeddings.tex", "max_stars_repo_name": "uhh-lt/dl-seminar", "max_stars_repo_head_hexsha": "b146db2f63462a7d795c43b484dc9e8ca38fb4d6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dump/04_embeddings.tex", "max_issues_repo_name": "uhh-lt/dl-seminar", "max_issues_repo_head_hexsha": "b146db2f63462a7d795c43b484dc9e8ca38fb4d6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dump/04_embeddings.tex", "max_forks_repo_name": "uhh-lt/dl-seminar", "max_forks_repo_head_hexsha": "b146db2f63462a7d795c43b484dc9e8ca38fb4d6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.043956044, "max_line_length": 236, "alphanum_fraction": 0.7042184833, "num_tokens": 5047, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341026367784, "lm_q2_score": 0.682573734412324, "lm_q1q2_score": 0.43234920909367813}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n\\input{../header2.tex}\n\n\\title{Phys 220A -- Classical Mechanics -- Lec14}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{25}{11}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\setlength{\\unitlength}{1mm}\n\\maketitle\n\n\n\\section{More on rigid bodies}\n\nFor an angular momentum $\\v \\omega$ we have kinetic energy \n\\begin{eqn}\nT = \\frac{1}{2} \\sum_{ij} \\omega_i I_{ij} \\omega_j\n\\end{eqn}\nand angular momentum\n\\begin{eqn}\nL_i = \\sum_j I_{ij} \\omega_j.\n\\end{eqn}\n[One or both of these are independent of frame?] Recall the Euler equations\n\\begin{eqn}\nI \\vd \\omega = \\v \\omega \\times (I \\v \\omega),\n\\end{eqn}\nor in the frame of the principal axes\n\\begin{align}\nI_1 \\od{\\omega_1}{t} &= (I_2 - I_3) \\omega_2 \\omega_3, \\\\\nI_2 \\od{\\omega_2}{t} &= (I_3 - I_1) \\omega_3 \\omega_1, \\\\\nI_3 \\od{\\omega_3}{t} &= (I_1 - I_2) \\omega_1 \\omega_2.\n\\end{align}\n\n\n\\subsection{Stability of solutions}\n\nSuppose without loss of generality that $I_1 < I_2 < I_3$. Then we can write our solutions as\n\\begin{align}\n\\omega_1 &= \\omega + \\eta_1, \\\\\n\\omega_2 &= 0 + \\eta_2, \\\\\n\\omega_3 &= 0 + \\eta_3.\n\\end{align}\nFor some reason we have a 0th order case\n\\begin{eqn}\n\\od{\\omega}{t} = 0 \n\\qquad \\implies \\qquad\n\\omega = \\text{const}\n\\end{eqn}\nand a 1st order case\n\\begin{eqn}\n\\od{\\eta_1}{t} = 0 \n\\end{eqn}\nin which case we can set $\\eta_1 = 0$ (can be absorbed into $\\omega$ [what?]) Then we can write ODEs for $\\eta_2, \\eta_3$,\n\\begin{eqn}\n\\od{\\eta_2}{t} = J_2 \\eta_3, \\qquad\n\\od{\\eta_3}{t} = J_3 \\eta_2\n\\end{eqn}\nwhere\n\\begin{eqn}\nJ_2 = \\frac{I_3 - I_1}{I_2} \\, \\omega, \\qquad\nJ_3 = \\frac{I_1 - I_2}{I_3} \\, \\omega.\n\\end{eqn}\nSo in general we can write\n\\begin{eqn}\n\\pmat{\\dot \\eta_2 \\\\ \\dot \\eta_3} = \\pmat{0 & J_2 \\\\ J_3 & 0} \\pmat{\\eta_2 \\\\ \\eta_3},\n\\end{eqn}\nwhich has solutions\n\\begin{eqn}\n\\eta_i(t) = e^{\\lambda t} \\eta_i(0), \\quad i = 2,3\n\\end{eqn}\nwhere $\\lambda$ is determined by\n\\begin{eqn}\n0 = \\det \\pmat{\\lambda & -J_2 \\\\ -J_3 & \\lambda} = \\lambda^2 - J_2 J_3 \\qquad\n\\implies \\qquad\n\\lambda = \\pm \\sqrt{J_2 J_3}.\n\\end{eqn}\nSo we have\n\\begin{eqn}\n\\lambda = \n\\begin{cases}\n\\pm i \\sqrt{\\abs{J_2 J_3}}, & J_2 J_3 < 0 \\\\\n\\pm \\sqrt{\\abs{J_2 J_3}}, & J_2 J_3 > 0\n\\end{cases}\n\\end{eqn}\nwhich is stable in the first case and unstable in the second case. In our case $I_1 < I_2 < I_3$ so $J_2 > 0$ and $J_3 < 0$ so it's stable. In other cases it can be unstable. \n\n\n\\subsection{Geometrical (Poinsot) Picture of Conserved Quantities}\n\n[stuff about intersections of ellipsoids and spheres]\n\n[something about why choice of Euler angles is nice]\n\n\n\\subsection{Example: Heavy symmetric top}\n\n[missed last hour]\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "383be0f8af82b7ee58537de714d918430b5c784e", "size": 2843, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "classical/lec14.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "classical/lec14.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "classical/lec14.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8454545455, "max_line_length": 175, "alphanum_fraction": 0.6700668308, "num_tokens": 1112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4323492050036375}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.67.084023 equation (20)}\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'momentum.json'\n   cdblib.create (jsonfile)\n\n   defG2GBar = cdblib.get ('defG2GBar','gamma.json')\n\n   # --------------------------------------------------------------------------\n   # Momentum constraint pt.1\n\n   Mom := D_{j}{K^{i j} - g^{i j} trK}.                                       # cdb(Mom.101,Mom)\n\n   defDgD := D_{a}{g_{b c}} -> 0.\n   defDgU := D_{a}{g^{b c}} -> 0.\n\n   defDtrK   := D_{a}{trK} -> \\partial_{a}{trK}.\n   defDexp   := D_{a}{\\exp(-4\\phi)} -> -4\\exp(-4\\phi) \\partial_{a}{\\phi}.\n\n   distribute   (Mom)                                                         # cdb(Mom.102,Mom)\n   product_rule (Mom)                                                         # cdb(Mom.103,Mom)\n   substitute   (Mom, defDgU)                                                 # cdb(Mom.104,Mom)\n\n   defK2ABarU := K^{i j} -> \\exp(-4\\phi) ABar^{i j} + (1/3) g^{i j} trK.\n\n   substitute   (Mom, defK2ABarU)                                             # cdb(Mom.105,Mom)\n   distribute   (Mom)                                                         # cdb(Mom.106,Mom)\n   product_rule (Mom)                                                         # cdb(Mom.107,Mom)\n   substitute   (Mom, defDtrK)                                                # cdb(Mom.108,Mom)\n   substitute   (Mom, defDgU)                                                 # cdb(Mom.109,Mom)\n   substitute   (Mom, defDexp)                                                # cdb(Mom.110,Mom)\n\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}\n      {\\cal D}^{j}\n         = \\Cdb*{Mom.101}\n         = \\Cdb*{Mom.102}\n         = \\Cdb*{Mom.103}\n         = \\Cdb*{Mom.104}\n         = \\Cdb*{Mom.105}\n         = \\Cdb*{Mom.106}\n         = \\Cdb*{Mom.107}\n         = \\Cdb*{Mom.108}\n         = \\Cdb*{Mom.109}\n         = \\Cdb*{Mom.110}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   # --------------------------------------------------------------------------\n   # Momentum constraint pt.2\n\n   confMom := \\exp(4\\phi) @(Mom).\n\n   defG2GBarU := g^{i j} -> \\exp(-4\\phi) gBar^{i j}.\n\n   distribute   (confMom)                                                     # cdb(confMom.101,confMom)\n   substitute   (confMom, defG2GBarU)                                         # cdb(confMom.102,confMom)\n   map_sympy    (confMom, \"simplify\")                                         # cdb(confMom.103,confMom)\n\n   defDAabU  := D_{a}{ABar^{b c}} ->  \\partial_{a}{ABar^{b c}}\n                                    + \\Gamma^{b}_{i a} ABar^{i c}\n                                    + \\Gamma^{c}_{i a} ABar^{b i}.\n\n   substitute     (confMom, defDAabU)                                         # cdb(confMom.104,confMom)\n   substitute     (confMom, defG2GBar)                                        # cdb(confMom.105,confMom)\n   distribute     (confMom)                                                   # cdb(confMom.106,confMom)\n   confMom = product_sort (confMom)                                           # cdb(confMom.107,confMom)\n   rename_dummies (confMom)                                                   # cdb(confMom.108,confMom)\n   canonicalise   (confMom)                                                   # cdb(confMom.109,confMom)\n   substitute     (confMom, $gBar^{i}_{i} -> 3$)                              # cdb(confMom.110,confMom)\n   substitute     (confMom, $gBar_{i j} ABar^{i j} -> 0$)                     # cdb(confMom.111,confMom)\n   substitute     (confMom, $gBar_{a i} gBar^{i b} -> gBar_{a}^{b}$)          # cdb(confMom.112,confMom)\n   substitute     (confMom, $GammaBar^{b}_{a b} -> 0$)                        # cdb(confMom.113,confMom) # follows from det gBar = 1\n   eliminate_kronecker (confMom)                                              # cdb(confMom.114,confMom)\n   rename_dummies (confMom)\n   canonicalise   (confMom)                                                   # cdb(confMom.115,confMom)\n\n   cdblib.put ('confMom',confMom,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}\n      \\exp(4\\phi) {\\cal D}^{j}\n         = \\Cdb*{confMom.101}\n         = \\Cdb*{confMom.102}\n         = \\Cdb*{confMom.103}\n         = \\Cdb*{confMom.104}\n         = \\Cdb*[\\hskip3.0cm\\hfill]{confMom.105}\n         = \\Cdb*[\\hskip2.0cm\\hfill]{confMom.106}\n         = \\Cdb*[\\hskip2.0cm\\hfill]{confMom.107}\n         = \\Cdb*[\\hskip2.0cm\\hfill]{confMom.108}\n         = \\Cdb*[\\hskip2.5cm\\hfill]{confMom.109}\n         = \\Cdb*{confMom.110}\n         = \\Cdb*{confMom.111}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}\n      \\exp(4\\phi) {\\cal D}^{j}\n         = \\Cdb*{confMom.112}\n         = \\Cdb*{confMom.113}\n         = \\Cdb*{confMom.114}\n         = \\Cdb*{confMom.115}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   tmpA := @(confMom).                                              # cdb(confMom.201,tmpA)\n   tmpB := @(confMom).\n\n   X^{b c}_{a}::Weight(label=numX).\n\n   Xbca := \\partial_{a}{ABar^{b c}}.                                # cdb(confMom.202,Xbca)\n\n   foo := \\partial_{a}{ABar^{b c}} -> X^{b c}_{a}.\n   bah := X^{b c}_{a} -> \\partial_{a}{ABar^{b c}}.\n\n   substitute  (tmpA, foo)                                          # cdb(confMom.203,tmpA)\n   substitute  (tmpB, foo)                                          # cdb(confMom.204,tmpB)\n   drop_weight (tmpA, $numX=1$)                                     # cdb(confMom.205,tmpA)\n   keep_weight (tmpB, $numX=1$)                                     # cdb(confMom.206,tmpB)\n   substitute  (tmpB, bah)                                          # cdb(confMom.207,tmpB)\n\n   tmpC := - @(tmpA).                                               # cdb(confMom.208,tmpC)\n\n   defMomSub := @(tmpB) -> @(tmpC).                                 # cdb(confMom.209,defMomSub)\n\n   cdblib.put ('defMomSub',defMomSub,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} 0 =  \\Cdb*{confMom.201} \\end{dmath*}\n   \\begin{dmath*} 0 =  \\Cdb*{confMom.203} \\end{dmath*}\n   \\begin{dmath*}\n      \\cdb{confMom.202} = \\Cdb*{confMom.206}\n                        = \\Cdb*{confMom.208}\n   \\end{dmath*}\n   \\begin{dmath*} \\Cdb*{confMom.209} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   # --------------------------------------------------------------------------\n   # Check against prd67.\n\n   foo := @(confMom).                                   # cdb(prd67.eq20.lcb,foo)\n   bah  = cdblib.get('prd67.eq20.rhs','prd67.json')     # cdb(prd67.eq20.prd,bah)\n\n   diff := @(foo) - @(bah).\n\n   distribute     (diff)\n   diff = product_sort (diff)\n   rename_dummies (diff)\n   map_sympy      (diff, \"simplify\")\n   canonicalise   (diff)                                # cdb(prd67.eq20.chk,diff)\n\\end{cadabra}\n\n% \\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{prd67.eq20.lcb} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{prd67.eq20.prd} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{prd67.eq20.chk} \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "d2ff035111efa772d54c06aaf2001ae7ab664c84", "size": 7101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/momentum.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-equations", "max_stars_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-13T18:47:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-13T18:47:34.000Z", "max_issues_repo_path": "source/momentum.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-equations", "max_issues_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/momentum.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-equations", "max_forks_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.984375, "max_line_length": 132, "alphanum_fraction": 0.4379664836, "num_tokens": 2206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.43234919146657147}}
{"text": "\\section{Broadcast time}\\label{sec:startnodetime}\n\nFiles \\code{\\{low,high\\}-density-time.ipynb} contain the analysis for the\nbroadcast time needed to reach the 98th percentile of the coverage. The analysis\nhas been done fixing all the factors (also \\(R\\)) and by just varying the\nposition of the starting user. Configurations used are\n``StartNodePositionLowDensityTime'' and ``StartNodePositionHighDensityTime''.\n\nWe get the results shown in \\tableref{table:startnodetimeresults}.\n\n\\begin{table}[hbt]\n\t\\centering\n\t\\begin{tabular}{lcccc}\n\t\t\\multicolumn{5}{c}{Low density (98th percentile broadcast time)}\\\\\n\t\t\\toprule\n\t\tStart Node Pos\\@. & Mean & Std\\@. Dev\\@. & Min\\@. & Max\\@. \\\\\n\t\t\\midrule\n\t\tCenter & \\(35.166667s\\) & \\(1.533158s\\) & \\(31s\\) & \\(40s\\) \\\\[16pt]\n\t\tBorder & \\(53.7s\\) & \\(1.914554s\\) & \\(50s\\) & \\(58s\\) \\\\[16pt]\n\t\tCorner & \\(65.1s\\) & \\(2.186952s\\) & \\(61s\\) & \\(70s\\) \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\\\\[16pt]\n\t\\begin{tabular}{lcccc}\n\t\t\\multicolumn{5}{c}{High density (98th percentile broadcast time)}\\\\\n\t\t\\toprule\n\t\tStart Node Pos\\@. & Mean & Std\\@. Dev\\@. & Min\\@. & Max\\@. \\\\\n\t\t\\midrule\n\t\tCenter & \\(32.533333s\\) & \\(2.161311s\\) & \\(30s\\) & \\(39s\\) \\\\[16pt]\n\t\tBorder & \\(48.666667s\\) & \\(2.039833s\\) & \\(45s\\) & \\(53s\\) \\\\[16pt]\n\t\tCorner & \\(57.7s\\) & \\(1.803254s\\) & \\(55s\\) & \\(62s\\) \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\caption{With the starting node at the border or the corner, we get an\n\thigher broadcast time compared to the case where the starting node is at\n\tthe center}\\label{table:startnodetimeresults}\n\\end{table}\n\nAs we can see, as the starting node moves near to the border/corner, we get\nhigher values for both the mean broadcast time. This can be explained by the\nfact that, when the starting node is in the corner, the message need to traverse\nthe entire length of the floorplan in both its dimensions.  When, instead, it\nstarts from the center, since it is sent out radially by the user, the message\njust needs to cover half of the side of the floorplan in each dimension. The\nstandard deviation is higher in the corner for the low density scenario but it\nis lower in the high density scenario: a higher number of users leads to a lower\nvariance.\n\nSo, if possibile, also for the broadcast time, is better to set the starting\nnode near the center or, at least, avoid borders and corners of the floorplan.\n", "meta": {"hexsha": "7d60d0d193096f0eba24100b0dca9baa8b1ccc90", "size": 2338, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/chapters/starting-node/time.tex", "max_stars_repo_name": "SpeedJack/pecsn", "max_stars_repo_head_hexsha": "40c757cddec978e06de766c9dff00abf57ccd6b3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/chapters/starting-node/time.tex", "max_issues_repo_name": "SpeedJack/pecsn", "max_issues_repo_head_hexsha": "40c757cddec978e06de766c9dff00abf57ccd6b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/chapters/starting-node/time.tex", "max_forks_repo_name": "SpeedJack/pecsn", "max_forks_repo_head_hexsha": "40c757cddec978e06de766c9dff00abf57ccd6b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.76, "max_line_length": 80, "alphanum_fraction": 0.6988879384, "num_tokens": 741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7341195210831258, "lm_q1q2_score": 0.4323150066503391}}
{"text": "\\chapter{NAND, NOR gates}\n%\\ref{sec:background}.\n\n\\section{Aim}\n%\\label{sec:objectives}\n\tTo verify and interpret the logic and truth table for NAND, NOR gates using Resistor Transistor Logic (RTL)\n\n\\section{Apparatus}\n%\\label{sec:objectives}\n\t\\begin{itemize}\n\t\t\\tightlist\n\t\t\\item Kit for realization of gates\n\t\t\\item Connecting Leads\n\t\\end{itemize}\n\n\\section{Circuits}\n\t\n\n\\section{Theory}\n\tLogic gates are the basic building blocks of any digital system. Logic gates are electronic circuits having one or more than one input and only one output. The relationship between the input and the output is based on a certain logic. Based on this, logic gates are named as:\n\t\\begin{enumerate}\n\t\t\\tightlist\n\t\t\\item AND gate\n\t\t\\item OR gate\n\t\t\\item NOT gate\n\t\t\\item NAND gate\n\t\t\\item NOT gate\n\t\t\\item Ex-OR gate\n\t\t\\item Ex-NOR gate\n\t\\end{enumerate}\n\t\n\t\\subsection{NAND gate}\n\tThis is a NOT-AND gate which is equal to an AND gate followed by a NOT gate. The outputs of all NAND gates are high if any of the inputs are low. The symbol is an AND gate with a small circle on the output. The small circle represents inversion.\n\t\\begin{align*}\n\t\tY &= \\overline{A . B}\n\t\\end{align*}\n\tA simple 2-input logic NAND gate can be constructed using RTL (Resistor-transistor-logic) switches connected together as shown in Figure \\ref{fig:nand_circuit} with the inputs connected directly to the transistor bases. Either transistor must be cut-off or “OFF” for an output at Q.\n\t\\begin{figure}[ht]\n\t\t\\centering \n\t\t\\subfloat[Symbol]\n\t\t{\n\t\t\t\\begin{circuitikz} \\draw\n\t\t\t\t(0,0) node[nand port] (myand1) {}\n\t\t\t\t(myand1.in 1) node[anchor=east] {A}\n\t\t\t\t(myand1.in 2) node[anchor=east] {B}\n\t\t\t\t(myand1.out) node[anchor=west] {Y}\n\t\t\t\t;\n\t\t\t\\end{circuitikz}\n\t\t\t\\label{fig:nand_symbol}\n\t\t}\t\n\t\t\\hfill\n\t\t\\subfloat[Truth Table]\n\t\t{\n\t\t\t\\begin{tabular}{|c|c|c|}\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{2}{|c|}{Input} & Output \\\\\n\t\t\t\t\\hline\n\t\t\t\t$A$ & $B$ & $Y=\\overline{A.B}$ \\\\\n\t\t\t\t\\hline\n\t\t\t\t0 & 0 & 1 \\\\\n\t\t\t\t\\hline\n\t\t\t\t0 & 1 & 1 \\\\\n\t\t\t\t\\hline\n\t\t\t\t1 & 0 & 1 \\\\\n\t\t\t\t\\hline\n\t\t\t\t1 & 1 & 0 \\\\\n\t\t\t\t\\hline\n\t\t\t\\end{tabular}\n\t\t\t\\label{fig:nand_table}\n\t\t}\n\t\t\\hfill\n\t\t\\subfloat[RTL Design]{\n\t\t\t\\includegraphics[width=0.25\\textwidth,valign=c]{img/exp2/fig1}\n\t\t\t\\label{fig:nand_circuit}\n\t\t}\n\t\t\\caption{\\textit{NAND gate}}\n\t\\end{figure}\n\t\n\t\n\t\\subsection{NOR gate}\n\t\tThis is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of all NOR gates are low if any of the inputs are high. The symbol is an OR gate with a small circle on the output. The small circle represents inversion.\n\t\t\\begin{align*}\n\t\t\tY &= \\overline{A + B}\n\t\t\\end{align*}\t\t\n\t\tA simple 2-input logic NOR gate can be constructed using RTL (Resistor-transistor-logic) switches connected together as shown in Figure \\ref{fig:nor_circuit} with the inputs connected directly to the transistor bases. Both transistors must be cut-off or “OFF” for an output at Q.\n\t\t\\begin{figure}[ht]\n\t\t\t\\centering \n\t\t\t\\subfloat[Symbol]\n\t\t\t{\n\t\t\t\t\\begin{circuitikz} \\draw\n\t\t\t\t\t(0,0) node[nor port] (myand1) {}\n\t\t\t\t\t(myand1.in 1) node[anchor=east] {A}\n\t\t\t\t\t(myand1.in 2) node[anchor=east] {B}\n\t\t\t\t\t(myand1.out) node[anchor=west] {Y}\n\t\t\t\t\t;\n\t\t\t\t\\end{circuitikz}\n\t\t\t\t\\label{fig:nor_symbol}\n\t\t\t}\t\n\t\t\t\\hfill\n\t\t\t\\subfloat[Truth Table]\n\t\t\t{\n\t\t\t\t\\begin{tabular}{|c|c|c|}\n\t\t\t\t\t\\hline\n\t\t\t\t\t\\multicolumn{2}{|c|}{Input} & Output \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\t$A$ & $B$ & $Y=\\overline{A+B}$ \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\t0 & 0 & 1 \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\t0 & 1 & 0 \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\t1 & 0 & 0 \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\t1 & 1 & 0 \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\\end{tabular}\n\t\t\t\t\\label{fig:nor_table}\n\t\t\t}\n\t\t\t\\hfill\n\t\t\t\\subfloat[RTL Design]{\n\t\t\t\t\\includegraphics[width=0.25\\textwidth,valign=c]{img/exp2/fig2}\n\t\t\t\t\\label{fig:nor_circuit}\n\t\t\t}\n\t\t\t\\caption{\\textit{NOR gate}}\n\t\t\\end{figure}\n\t\t\n\\section{Procedure}\n\t\\subsection{NAND gate}\n\t\t\\begin{figure}[ht]\n\t\t\t\\centering \n\t\t\t\\subfloat[Simulator 1]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig3}\n\t\t\t\t\\label{fig:nand_sim:1}}\t\n\t\t\t\\hfill\n\t\t\t\\subfloat[Simulator 2]{\\includegraphics[width=0.4\\textwidth,valign=c]{img/exp2/fig4}\n\t\t\t\t\\label{fig:nand_sim:2}}\t\t\t\n\t\t\t\\caption{\\textit{Simulator for realizing circuit for NAND gate}}\n\t\t\\end{figure}\n\t\t\\subsubsection{Simulator 1}\n\t\t\t\\begin{enumerate}\n\t\t\t\t\\tightlist\n\t\t\t\t\\item Connect the supply(+5V) to the circuit.\n\t\t\t\t\\item Press the switches for inputs \"A\" and \"B\".\t\t\t\n\t\t\t\t\\item The bulb glows if any one or both the switches are OFF else it won't glow.\n\t\t\t\t\\item Repeat step-2 and step-3 for all state of inputs.\n\t\t\t\\end{enumerate}\n\t\t\\subsubsection{Simulator 2}\n\t\t\t\\begin{enumerate}\n\t\t\t\t\\tightlist\n\t\t\t\t\\item Enter the Boolean input \"A\" and \"B\".\n\t\t\t\t\\item Enter the Boolean output for your corresponding inputs.\n\t\t\t\t\\item Click on \"Check\" Button to verify your output.\t\t\t\n\t\t\t\\end{enumerate}\t\n\n\t\\subsection{NOR gate}\n\t\t\\begin{figure}[ht]\n\t\t\t\\centering \n\t\t\t\\subfloat[Simulator 1]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig5}\n\t\t\t\t\\label{fig:nor_sim:1}}\t\n\t\t\t\\hfill\n\t\t\t\\subfloat[Simulator 2]{\\includegraphics[width=0.4\\textwidth,valign=c]{img/exp2/fig6}\n\t\t\t\t\\label{fig:nor_sim:2}}\n\t\t\t\\caption{\\textit{Simulator for realizing circuit for NOR gate}}\n\t\t\\end{figure}\n\t\t\\subsubsection{Simulator 1}\n\t\t\t\\begin{enumerate}\n\t\t\t\t\\tightlist\n\t\t\t\t\\item Connect the supply(+5V) to the circuit.\n\t\t\t\t\\item Press the switches for inputs \"A\" and \"B\".\t\t\t\n\t\t\t\t\\item The bulb glows if both the switches are OFF else it won't glow.\n\t\t\t\t\\item Repeat step-2 and step-3 for all state of inputs.\n\t\t\t\\end{enumerate}\n\t\t\\subsubsection{Simulator 2}\n\t\t\t\\begin{enumerate}\n\t\t\t\t\\tightlist\n\t\t\t\t\\item Enter the Boolean input \"A\" and \"B\".\n\t\t\t\t\\item Enter the Boolean output for your corresponding inputs.\n\t\t\t\t\\item Click on \"Check\" Button to verify your output.\t\t\t\n\t\t\t\\end{enumerate}\n\n\\section{Observations}\n\t\\subsection{NAND gate}\n\t\t\t\\begin{figure}[ht]\n\t\t\t\t\\centering \n\t\t\t\t\\subfloat[Either of the Inputs OFF, LED is ON]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig7}\n\t\t\t\t\t\\label{fig:nand_obs:1}}\t\n\t\t\t\t\\hfill\n\t\t\t\t\\subfloat[Both Inputs ON, LED is OFF]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig8}\n\t\t\t\t\t\\label{fig:nand_obs:2}}\t\t\t\n\t\t\t\t\\caption{\\textit{Observations for different Input Values}}\n\t\t\t\\end{figure}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.85\\linewidth]{img/exp2/fig9}\n\t\t\t\t\\caption{\\textit{Observations for verification of Truth Table of the NAND gate}}\n\t\t\t\t\\label{fig:nand_obs_2}\n\t\t\t\\end{figure}\n\n\\pagebreak\n\t\\subsection{NOR gate}\n\t\t\t\\begin{figure}[ht]\n\t\t\t\t\\centering \n\t\t\t\t\\subfloat[Either of the Inputs ON, LED is OFF]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig10}\n\t\t\t\t\t\\label{fig:nor_obs:1}}\t\n\t\t\t\t\\hfill\n\t\t\t\t\\subfloat[Both Inputs OFF, LED is ON]{\\includegraphics[width=0.45\\textwidth,valign=c]{img/exp2/fig11}\n\t\t\t\t\t\\label{fig:nor_obs:2}}\n\t\t\t\t\\caption{\\textit{Observations for different Input Values}}\n\t\t\t\\end{figure}\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.85\\linewidth]{img/exp2/fig12}\n\t\t\t\t\\caption{\\textit{Observations for verification of Truth Table of the NOR gate}}\n\t\t\t\t\\label{fig:nor_obs_2}\n\t\t\t\\end{figure}\n\t\t\t\n\\section{Precautions}\n\t\\begin{enumerate}\n\t\t\\tightlist\n\t\t\\item Make the connections when power supply is OFF.\n\t\t\\item Ensure that the connections are tight.\n\t\t\\item Change the status of inputs only when power supply is OFF.\n\t\\end{enumerate}", "meta": {"hexsha": "9fc52c9e26b57ea658fbc62ad4c81e36fa009c3d", "size": 7292, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Semester 3/DCLD_File/sections/2-exp2.tex", "max_stars_repo_name": "anhatsingh/Anhat_LATEX", "max_stars_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Semester 3/DCLD_File/sections/2-exp2.tex", "max_issues_repo_name": "anhatsingh/Anhat_LATEX", "max_issues_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Semester 3/DCLD_File/sections/2-exp2.tex", "max_forks_repo_name": "anhatsingh/Anhat_LATEX", "max_forks_repo_head_hexsha": "2d4601493b243949e9ba7a7abe59f59168e4d50a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8468468468, "max_line_length": 283, "alphanum_fraction": 0.6766319254, "num_tokens": 2511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381372136563, "lm_q2_score": 0.7905303162021596, "lm_q1q2_score": 0.43221307249129143}}
{"text": "\\newpage\\section{Problems}\n\n\t\n\t\\prob{https://artofproblemsolving.com/community/c6h355783p1932923}{ISL 2009 C1}{E}{Consider $ 2009 $ cards, each having one gold side and one black side, lying on parallel on a long table. Initially all cards show their gold sides. Two player, standing by the same long side of the table, play a game with alternating moves. Each move consists of choosing a block of $ 50 $ consecutive cards, the leftmost of which is showing gold, and turning them all over, so those which showed gold now show black and vice versa. The last player who can make a legal move wins.\n\n\t\t\\begin{enumerate}\n\t\t\t\\item  Does the game necessarily end?\n\t\t\t\\item  Does there exist a winning strategy for the starting player?\n\t\t\\end{enumerate}}\\label{problem:extremal_case_whole_3}\n\n\t\\solu{Simplicity is the key.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h355915p1934456}{ISL 2009 C3}{H}{Let $ n $ be a positive integer. Given a sequence $ \\varepsilon_1 $ , $ \\dots $ , $ \\varepsilon_{n - 1} $ with $ \\varepsilon_i = 0 $ or $ \\varepsilon_i = 1 $ for each $ i = 1 $ , $ \\dots $ , $ n - 1 $ , the sequences $ a_0 $ , $ \\dots $ , $ a_n $ and $ b_0 $ , $ \\dots $ , $ b_n $ are constructed by the following rules:\n\n\t\t\\[a_0 = b_0 = 1, \\quad a_1 = b_1 = 7,\\]\n\n\t\t\\[\\begin{array}{lll} a_{i+1} = \\begin{cases} 2a_{i-1} + 3a_i, \\\\ 3a_{i-1} + a_i, \\end{cases} & \\begin{array}{l} \\text{if } \\varepsilon_i = 0, \\\\ \\text{if } \\varepsilon_i = 1, \\end{array} & \\text{for each } i = 1, \\dots, n - 1,\n\n\t\t\\\\[15pt] b_{i+1}= \\begin{cases} 2b_{i-1} + 3b_i, \\\\ 3b_{i-1} + b_i, \\end{cases} & \\begin{array}{l} \\text{if } \\varepsilon_{n-i} = 0, \\\\ \\text{if } \\varepsilon_{n-i} = 1, \\end{array} & \\text{for each } i = 1, \\dots, n - 1. \\end{array}\\]\n\n\t\tProve that $ a_n = b_n $.}\\label{problem:bijection_3}\\label{problem:recursive_solution_3}\n\n\t\\solu{\\hl{Got the idea, will try later.}}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1634977p10278658}{ARO 2018 P11.5}{E}{On the table, there're $ 1000 $ cards arranged on a circle. On each card, a positive integer was written so that all $ 1000 $ numbers are distinct. First, Vasya selects one of the card, remove it from the circle, and do the following operation: If on the last card taken out was written positive integer $ k $ , count the $ k^{th} $ clockwise card not removed, from that position, then remove it and repeat the operation. This continues until only one card left on the table. Is it possible that, initially, there's a card $ A $ such that, no matter what other card Vasya selects as first card, the one that left is always card $ A $ ?}\\label{problem:constructive_algo_7}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1441121p8200413}{ARO 2017 P9.1}{E}{In country some cities are connected by oneway flights (There are no more then one flight between two cities). City $ A $ called \"available\" for city $ B $ , if there is flight from $ B $ to $ A $ , maybe with some transfers. It is known, that for every 2 cities $ P $ and $ Q $ exist city $ R $ , such that $ P $ and $ Q $ are available from $ R $. Prove, that exist city $ A $ , such that every city is available for $ A $.}\\label{problem:induction_type1_3}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1632768p10256373}{ARO 2018 10.3}{E}{A positive integer $ k $ is given. Initially, $ N $ cells are marked on an infinite checkered plane. We say that the cross of a cell $ A $ is the set of all cells lying in the same row or in the same column as $ A $. By a turn, it is allowed to mark an unmarked cell $ A $ if the cross of $ A $ contains at least $ k $ marked cells. It appears that every cell can be marked in a sequence of such turns. Determine the smallest possible value of $ N $.}\\label{problem:constructive_algo_2}\n\n\t\\solu{First find the construction.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1635128p10279946}{ARO 2018 P9.5}{E}{On the circle, $ 99 $ points are marked, dividing this circle into $ 99 $ equal arcs. Petya and Vasya play the game, taking turns. Petya goes first; on his first move, he paints in red or blue any marked point. Then each player can paint on his own turn, in red or blue, any uncolored marked point adjacent to the already painted one. Vasya wins, if after painting all points there is an equilateral triangle, all three vertices's of which are colored in the same color. Could Petya prevent him?}\\label{problem:forget_and_focus_1}\n\n\t\\solu{Think of what Petya must do to prevent immediate losing.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h24077p152742}{ISL 2004 C2}{E}{Let $ {n} $ and $ k $ be positive integers. There are given $ {n} $ circles in the plane. Every two of them intersect at two distinct points, and all points of intersection they determine are pairwise distinct (i. e. no three circles have a common point). No three circles have a point in common. Each intersection point must be colored with one of $ n $ distinct colors so that each color is used at least once and exactly $ k $ distinct colors occur on each circle. Find all values of $ n\\geq 2 $ and $ k $ for which such a coloring is possible.}\\label{problem:induction_type1_1}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h40115p251391}{ISL 2004 C3}{E}{The following operation is allowed on a finite graph: Choose an arbitrary cycle of length 4 (if there is any), choose an arbitrary edge in that cycle, and delete it from the graph. For a fixed integer $ {n\\ge 4} $ , find the least number of edges of a graph that can be obtained by repeated applications of this operation from the complete graph on $ n $ vertices's (where each pair of vertices's are joined by an edge).}\\label{problem:bipartite_graph_2}\n\n\t\\solu{Walk backwards. or the same thing with \\hrf{lemma:bipartite_graph}{Bipartite Graphs}.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h476661p2668792}{Iran TST 2012 P4}{E}{Consider $ m+1 $ horizontal and $ n+1 $ vertical lines ( $ m,n\\ge 4 $ ) in the plane forming an $ m\\times n $ table. Cosider a closed path on the segments of this table such that it does not intersect itself and also it passes through all $ (m-1)(n-1) $ interior vertices's (each vertex is an intersection point of two lines) and it doesn't pass through any of outer vertices. Suppose $ A $ is the number of vertices's such that the path passes through them straight forward, $ B $ number of the table squares that only their two opposite sides are used in the path, and $ C $ number of the table squares that none of their sides is used in the path. Prove that $ A=B-C+m+n-1 $.}\\label{problem:double_counting_2}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/q2h1060228p4589671}{AoPS}{E}{Given $ 2n+1 $ irrational numbers, prove that one can pick $ n $ from them s.t. no two of the choosen $ n $ sum up to a rational number.}\\label{problem:bipartite_graph_1}\\label{problem:graph_representation_3}\n\n\t\\solu{Use a graph theory representation.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h542686p3131086}{Bulgarian IMO TST 2004, Day 3, Problem 3}{H}{Prove that among any $ 2n+1 $ irrational numbers there are $ n+1 $ numbers such that the sum of any $ k $ of them is irrational, for all $ k \\in \\{1,2,3,\\ldots, n+1 \\} $.}\\label{problem:add_time_5}\\label{problem:constructive_algo_1}\n\n\t\\solu{We first create a set $ B $ such that any linear combination of the elements in it are irrational. Then for convenience, we add $ 1 $ to it, so that now the sum equals to $ 0 $ of any linear combinations. An algorithm for building it comes into our mind, which leaves some other original elements, which we then later add to the final solution set $ A $ along with the elements in the set $ B $ except $ 1 $.}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h176p611}{ISL 1997 P4}{E}{An $ n\\times n $ matrix whose entries come from the set $ S = \\{1,2, . . . ,2n-1\\} $ is called a ``silver matrix'' if, for each $ i = 1,2, . . . , n $ , the $ i $ -th row and the $ i $ -th column together contain all elements of $ S $. Show that:\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\item there is no silver matrix for $ n = 1997 $ ;\n\t\t\t\\item silver matrices exist for infinitely many values of $ n $.\n\t\\end{enumerate}}\\label{problem:induction_type1_2}\n\n\t\\solu{Proving that for odd $ n $ 's isn't hard. Then A small try-around with $ n=2, 4 $ , we see a pattern that leads to a construction for $ 2^n $ }\n\n\n\n\n\n\n\t\\prob{}{}{E}{A rectangle is completely partitioned into smaller rectangles such that each smaller rectangles has at least one integral side. Prove that the original rectangle also has at least one integral side.}\\label{problem:extreme_object_5}\n\n\t\\solu{Try a special grid system with $.5\\times .5 $ boxes.}\n\n\t\\solu{Consider the number of corners in the rectangle.}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h40197p251895}{ISL 2004 C5}{M}{ $ A $ and $ B $ play a game, given an integer $ N $, $ A $ writes down $ 1 $ first, then every player sees the last number written and if it is $ n $ then in his turn he writes $ n+1 $ or $ 2n $ , but his number cannot be bigger than $ N $. The player who writes $ N $ wins. For which values of $ N $ does $ B $ win?}\\label{problem:win_lose_1}\n\n\t\\solu{Trying with smaller cases, it's easy. Using most important game theory \\hrf{win_lose}{trick}.}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h155692p874978}{ISL 2006 C1}{E}{We have $ n \\geq 2 $ lamps $ L_1, L_2 \\dots L_n $ in a row, each of them being either on or off. Every second we simultaneously modify the state of each lamp as follows: if the lamp $ L_i $ and its neighbors (only one neighbor for $ i = 1 $ or $ i = n $ , two neighbors for other $ i $ ) are in the same state, then $ L_i $ is switched off; otherwise, $ L_i $ is switched on. Initially all the lamps are off except the leftmost one which is on.\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\item  Prove that there are infinitely many integers $ n $ for which all the lamps will eventually be off.\n\t\t\t\\item  Prove that there are infinitely many integers $ n $ for which the lamps will never be all off\n\t\\end{enumerate}}\\label{problem:induction_type1_4}\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h155696p874991}{ISL 2006 C4}{M}{A cake has the form of an $ n \\times n $ square composed of $ n^2 $ unit squares. Strawberries lie on some of the unit squares so that each row or column contains exactly one strawberry; call this arrangement $ \\mathbb{A} $.\n\n\t\tLet $ \\mathbb{B} $ be another such arrangement. Suppose that every grid rectangle with one vertex at the top left corner of the cake contains no fewer strawberries of arrangement $ \\mathbb{B} $ than of arrangement $ \\mathbb{A} $. Prove that arrangement $ \\mathbb{B} $ can be obtained from $ \\mathbb{A} $ by performing a number of switches, defined as follows:\n\n\t\tA switch consists in selecting a grid rectangle with only two strawberries, situated at its top right corner and bottom left corner, and moving these two strawberries to the other two corners of that rectangle.}\\label{problem:extreme_object_6}\n\n\t\\solu{When the first approach fails, don't throw that idea yet. Stick to it, as it is most probably the closest to a correct solution. Taking the smallest rectangle with $ 0 $ 's equal to $ 1 $ 's, we see that we can 'shrink' the rectangle. Which leads to a solution instantly.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1113184p5083546}{ISL 2014 C2}{E}{We have $ 2^m $ sheets of paper, with the number $ 1 $ written on each of them. We perform the following operation. In every step we choose two distinct sheets; if the numbers on the two sheets are $ a $ and $ b $ , then we erase these numbers and write the number $ a + b $ on both sheets. Prove that after $ m2^{m -1} $ steps, the sum of the numbers on all the sheets is at least $ 4^m $.}\\label{problem:invariant_rules_of_thumb_1}\n\n\t\\solu{When you know that the problem can be solved using invariants, go through all of the possible invariants (from \\href{invariant_rules_of_thumb}{the rules of thumb}). Don't give up on one so quickly. And product and sum are actually more close than you think. Because if you are told to prove some bound on the sum, then product can come very handy. After all there is AM-GM to connect sum and product.}\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1480694p8639260}{ISL 2016 C3}{E}{Let $ n $ be a positive integer relatively prime to $ 6 $. We paint the vertices's of a regular $ n $ -gon with three colours so that there is an odd number of vertices's of each colour. Show that there exists an isosceles triangle whose three vertices's are of different colours.}\\label{problem:double_counting_1}\n\n\t\\solu{Double Count with the number of points of each colors.}\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h5052p15988}{Iran TST 2002 P3}{E}{A ``2-line'' is the area between two parallel lines. Length of ``2-line'' is distance of two parallel lines. We have covered unit circle with some ``2-lines''. Prove sum of lengths of ``2-lines'' is at least $ 2 $.}\\label{problem:extreme_object_4}\n\n\t\\solu{Consider the ``2-line'' of the largest length.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h209803p1155601}{ARO 2008 P9.5}{E}{The distance between two cells of an infinite chessboard is defined as the minimum number to moves needed for a king to move from one to the other. On the board are chosen three cells on pairwise distances equal to $ 100 $. How many cells are there that are at the distance $ 50 $ from each of the three cells?}\\label{problem:forget_and_focus_3}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h424768p2403861}{USAMO 1986 P2}{E}{During a certain lecture, each of five mathematicians fell asleep exactly twice. For each pair of mathematicians, there was some moment when both were asleep simultaneously. Prove that, at some moment, three of them were sleeping simultaneously.}\\label{problem:graph_representation_1}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/q2h607881p3617126}{Mexican Regional 2014 P6}{E}{Let $ A=n\\times n $ be a $ \\{0, 1\\} $ matrix, where each row is different. Prove that you can remove a column such that the resulting $ n\\times (n-1) $ matrix has $ n $ different rows.}\\label{problem:induction_type2_2}\\label{problem:graph_representation_2}\n\n\t\\solu{Try to represent the sets in a nicer way, with graph. or. Induction on the number of columns deleted and the number or different rows being there.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1480685p8639240}{IMO 2017 P5}{M (H)}{An integer $ N \\ge 2 $ is given. A collection of $ N(N + 1) $ soccer players, no two of whom are of the same height, stand in a row. Show that Sir Alex can always remove $ N(N - 1) $ players from this row leaving a new row of $ 2N $ players in which the following $ N $ conditions hold:\n\n\t\t( $ 1 $ ) no one stands between the two tallest players,\n\n\t\t( $ 2 $ ) no one stands between the third and fourth tallest players,\n\n\t\t$ \\;\\;\\vdots $\n\n\t\t( $ N $ ) no one stands between the two shortest players.} \\label{problem:matrix_creation_1}\n\n\t\\solu{ $ N(N+1) $ , rows, removing $ \\dots $ these things just begs for to be arranged in a \\hrf{matrix_creation}{systematic} order. As arranging thing in a matrix is the simplest way, we arrange the bad-bois in a $ N \\cdot (N+1) $ matrix. Now finding the algorithm is not very hard.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h60737p366461}{ISL 1990 P3}{E}{Let $ n \\geq 3 $ and consider a set $ E $ of $ 2n - 1 $ distinct points on a circle. Suppose that exactly $ k $ of these points are to be colored black. Such a coloring is good if there is at least one pair of black points such that the interior of one of the arcs between them contains exactly $ n $ points from $ E $. Find the smallest value of $ k $ so that every such coloring of $ k $ points of $ E $ is good.}\\label{problem:alternating_chains_1}\n\n\t\\solu{Creating a graph and using \\hrf{alternating_chains}{Alternating Chains Technique}}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h54501p340035}{USAMO 1999 P1}{E}{Some checkers placed on an $ n \\times n $ checkerboard satisfy the following conditions:\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\item  every square that does not contain a checker shares a side with one that does;\n\n\t\t\t\\item  given any pair of squares that contain checkers, there is a sequence of squares containing checkers, starting and ending with the given squares, such that every two consecutive squares of the sequence share a side.\n\t\t\\end{enumerate}\n\n\t\tProve that at least $ (n^{2}-2)/3 $ checkers have been placed on the board.}\\label{problem:add_time_4}\n\n\n\t\\solu{As the problem simply seems to exist, we can't count how much contribution a checker cntaining square contributes to the whole board. So we place \\hrf{add_time}{one at a time} and see the changes.}\n\n\n\t\\gene{www.hehe.com}{USAMO 1999 P1 generalization}{Find the smallest positive integer $ m $ such that if $ m $ squares of an $ n\\times n $ board are colored, then there will exist $ 3 $ colored squares whose centers form a right triangle with sides parallel to the edges of the board.}\\label{problem:induction_type1_22}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h597127p3543383}{ISL 2013 C1}{E}{Let $ n $ be an positive integer. Find the smallest integer $ k $ with the following property; Given any real numbers $ a_1 , \\cdots , a_d $ such that $ a_1 + a_2 + \\cdots + a_d = n $ and $ 0 \\le a_i \\le 1 $ for $ i=1,2,\\cdots ,d $ , it is possible to partition these numbers into $ k $ groups (some of which may be empty) such that the sum of the numbers in each group is at most $ 1 $.}\\label{problem:extremal_case_whole_1}\n\n\t\\solu{Think about the worst case where $ d $ is the minimum and the ans is $ d $ , it would only be possible if each $ a_i> \\frac{1}{2} $ but this can't be true, so, the ans is $ 2n-1 $. Now the ques should become obvious.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h587946p3480604}{Brazilian Olympic Revenge 2014}{M}{Let $ n $ a positive integer. In a $ 2n\\times 2n $ board, $ 1\\times n $ and $ n\\times 1 $ pieces are arranged without overlap. Call an arrangement maximal if it is impossible to put a new piece in the board without overlapping the previous ones. Find the least $ k $ such that there is a maximal arrangement that uses $ k $ pieces.}\\label{problem:add_time_2}\\label{problem:extremal_case_whole_2}\n\n\t\\solu{Intuition gives that there is at least one $ n $ -mino in each row. But we can easily guess that there is no maximal arrangement with $ 2n $ minos. Suppose in a maximal arrangement, there are no vertical $ n $ -mino, that means there are more than $ 2n+1 $ n-minos. So suppose that there is at least one vertical suppose that it lies in a column $ i $ between $ 1 $ and $ n $. Then we have that there is at least one $ n $ -mino in each column in between $ 1 $ and $ i $. If there is one in between $ 1 $ and $ 2n $ , say $ j $ , then there is one in each of the columns on the right side of it. Then we count horizontal $ n $ -minos, we show that $ 2n+1 $ is the answer.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h287859p1555905}{ISL 2008 C1}{E}{In the plane we consider rectangles whose sides are parallel to the coordinate axes and have positive length. Such a rectangle will be called a box. Two boxes intersect if they have a common point in their interior or on their boundary. Find the largest $ n $ for which there exist $ n $ boxes $ B_1, B_2\\dots B_n $ such that $ B_i $ and $ B_j $ intersect if and only if $ i \\not\\equiv j\\pm 1\\ (\\bmod\\ n) $.}\\label{problem:add_time_3}\\label{problem:extreme_object_2}\n\n\t\\solu{Instead of focusing on building the boxes from only one side (i.e. starting with $ 1, 2\\dots $ , we should include $ n $ in our investigation, and follow from both direction, (i.e. $ 1, 2\\dots $ and $ \\dots , n-1, n $ ).}\n\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c5h202905p1116177}{USAMO 2008 P4}{E}{Let $ \\mathcal{P} $ be a convex polygon with $ n $ sides, $ n\\ge3 $. Any set of $ n - 3 $ diagonals of $ \\mathcal{P} $ that do not intersect in the interior of the polygon determine a triangulation of $ \\mathcal{P} $ into $ n - 2 $ triangles. If $ \\mathcal{P} $ is regular and there is a triangulation of $ \\mathcal{P} $ consisting of only isosceles triangles, find all the possible values of $ n $.}\n\n\t\\solu{It’s not hard after getting the ans.}\\label{problem:extreme_object_1}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1238107p6307111}{ARO 2016 P3}{M}{We have a sheet of paper, divided into $ 100\\times 100 $ unit squares. In some squares, we put right-angled isosceles triangles with $ leg=1 $ (Every triangle lies in one unit square and is half of this square). Every unit grid segment (boundary too) is under one $ leg $ of a triangle. Find maximal number of unit squares, that don't contains any triangles.}\n\n\t\\solu{What is the minimum number of triangles you can use in a row? Create a good row \\hrf{add_time}{one at a time}}\\label{problem:add_time_1}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h546367p3162058}{India TST 2013 Test 3, P1}{E}{For a positive integer $ n $ , a \\textit{Sum-Friendly Odd Partition} of $ n $ is a sequence $ \\left( a_1, a_2\\dots a_k\\right) $ of odd positive integers with $ a_1\\leq a_2\\leq\\dots\\leq a_k $ and $ a_1+a_2+\\dots +a_k = n $ such that for all positive integers $ m\\leq n $ , $ m $ can be uniquely written as a subsum $ m = a_{i_1}+a_{i_2}+\\dots +a_{i_r} $. (Two subsums $ a_{i_1}+a_{i_2}+\\dots +a_{i_r} $ and $ a_{j_1}+a_{j_2}+\\dots +a_{j_s} $ with $ i_1< i_2<\\dots < i_r $ and $ j_1< j_2 <\\dots < j_s $ are considered the same if $ r = s $ and $ a_{i_l}=a_{j_l} $ for $ 1\\leq l\\leq r $.) For example, $ \\left( 1,1,3,3\\right) $ is a \\textit{sum-friendly odd partition} of $ 8 $. Find the number of sum-friendly odd partitions of $ 9999 $.}\\label{problem:recursive_solution_1}\n\n\t\\solu{Firstly we explore one SFOP \\hrf{recursive_solution}{at a time}. Which gives us a way to tell what $ a_{i+1} $ is going to be by looking at $ a_1\\dots a_i $.}\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h418796p2363537}{IMO 2011 P2}{H}{Let $ \\mathcal{S} $ be a finite set of at least two points in the plane. Assume that no three points of $ \\mathcal S $ are collinear. A windmill is a process that starts with a line $ \\ell $ going through a single point $ P \\in \\mathcal S $. The line rotates clockwise about the pivot $ P $ until the first time that the line meets some other point belonging to $ \\mathcal S $. This point, $ Q $ , takes over as the new pivot, and the line now rotates clockwise about $ Q $ , until it next meets a point of $ \\mathcal S $. This process continues indefinitely.\n\n\t\tShow that we can choose a point $ P $ in $ \\mathcal S $ and a line $ \\ell $ going through $ P $ such that the resulting windmill uses each point of $ \\mathcal S $ as a pivot infinitely many times.}\\label{problem:extreme_object_3}\n\n\t\\solu{Some workaround gives us the idea that the starting line has to be kinda ``\\hrf{extreme_object}{in between}'' the points. Formal words could be: the line should divide the set of points in two sets so that the two sets have equal number of points. Once we take a such line, we see that after every move we get a new line which has similar properties of the first line.}\n\n\t\\solu{So moral of the story is that if you get some vague idea that something has to satisfy something-ish, remove the -ish part, and try with a formal assumption.}\n\n\n\n\n\n\n\t\\prob{http://ioinformatics.org/locations/ioi16/contest/day2/messy.pdf}{IOI 2016 P5}{M}{A computer bug has a permutation $ P $ of length $ 2^k = N $ that changes any string added to a DS according to the permutation, i.e. it makes $ S[i]=S[P[i]] $. Your task it to find the permutation in the following ways:\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\item You can add at most $ n\\log_{2}n $ $ N $ bit binary strings to the DS.\n\t\t\t\\item You can ask at most $ n\\log_{2}n $, in the form of $ N $ bit binary strings. The answer will be ``true'' if the string exists in the DS after the Bug had changed the strings and ``no'' otherwise.\n\t\\end{enumerate}}\\label{problem:divide_and_conquer_5}\n\n\t\\solu{Typical Divide and Conquer approach. You want to do the same thing for $ N = \\frac{N}{2} $, and to do so you need to tell exactly what the first $ \\frac{N}{2} $ terms of the permutation are. To do this, you can use at most $ N $ questions. This is easy, you first add strings with only one bit present in the first $ \\frac{N}{2} $ positions, and then ask $ N $ questions with only one bit in every $ N $ positions. This maps the first $ \\frac{N}{2} $ numbers of the permutation to a set of $ \\frac{N}{2} $ integers. And we can proceed by induction now.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h17458p119184}{ISL 2001 C6}{M}{For a positive integer $n$ define a sequence of zeros and ones to be balanced if it contains $n$ zeros and $n$ ones. Two balanced sequences $a$ and $b$ are neighbors if you can move one of the $2n$ symbols of $a$ to another position to form $b$. For instance, when $n = 4$, the balanced sequences $01101001$ and $00110101$ are neighbors because the third (or fourth) zero in the first sequence can be moved to the first or second position to form the second sequence. Prove that there is a set $S$ of at most $\\frac{1}{n+1} \\binom{2n}{n}$ balanced sequences such that every balanced sequence is equal to or is a neighbor of at least one sequence in $S$.}\\label{problem:forget_and_focus_4}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h18502p124456}{ISL 1998 C4}{M}{Let $U=\\{1,2,\\ldots ,n\\}$, where $n\\geq 3$. A subset $S$ of $U$ is said to be split by an arrangement of the elements of $U$ if an element not in $S$ occurs in the arrangement somewhere between two elements of $S$. For example, 13542 splits $\\{1,2,3\\}$ but not $\\{3,4,5\\}$. Prove that for any $n-2$ subsets of $U$, each containing at least 2 and at most $n-1$ elements, there is an arrangement of the elements of $U$ which splits all of them.}\\label{problem:induction_type1_21}\\label{problem:extreme_object_11}\n\n\t\\solu{If we try to apply induction, we see that the sets with $ 2 $ and $ n-1 $ elements create problems, so we handle them first.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h289581p1566044}{USA TST 2009 P1}{M}{Let $m$ and $n$ be positive integers. Mr. Fat has a set $S$ containing every rectangular tile with integer side lengths and area of a power of $2$. Mr. Fat also has a rectangle $R$ with dimensions $2^m \\times 2^n$ and a $1 \\times 1$ square removed from one of the corners. Mr. Fat wants to choose $m + n$ rectangles from $S$, with respective areas $2^0, 2^1, \\ldots, 2^{m + n - 1}$, and then tile $R$ with the chosen rectangles. Prove that this can be done in at most $(m + n)!$ ways.}\\label{problem:bijection_10}\\label{problem:extreme_object_12}\n\n\t\\solu{The fact that this can be done in $ (m+n)! $ asks for a bijective proof. Now an intuition gives us that we have to sort the tiles wrt the missing square in some way. Now since the numbers }\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1238105p6307095}{ARO 2016 P1}{E}{There are $ 30 $ teams in \\textbf{NBA} and every team play $ 82 $ games in the year. Bosses of \\textbf{NBA} want to divide all teams on Western and Eastern Conferences (not necessarily equally), such that the number of games between teams from different conferences is half of the number of all games. Can they do it?}\n\n\t\\solu{You want to divide something. Check the parity.}\\label{problem:invariant_rules_of_thumb_7}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1288343p6805414}{AoPS}{M}{Each edge of a polyhedron is oriented with an arrow such that at each vertex, there is at least one arrow leaving the vertex and at least one arrow entering the vertex. Prove that there exists a face on the polyhedron such that the edges on its boundary form a directed cycle.}\\label{problem:extreme_object_13}\n\n\t\\solu{The trick which is used to prove Euler's Polyhedron theorem.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h596929p3542094}{ISL 2014 C3}{M}{Let $ n \\ge 2 $ be an integer. Consider an $ n \\times n $ chessboard consisting of $ n^2 $ unit squares. A configuration of $ n $ rooks on this board is peaceful if every row and every column contains exactly one rook. Find the greatest positive integer $ k $ such that, for each peaceful configuration of $ n $ rooks, there is a $ k \\times k $ square which does not contain a rook on any of its $ k^2 $ unit squares.}\\label{problem:extremal_case_whole_7}\n\n\t\\solu{Guessing the \"Correct\" ans is the challenge, think of the worst case you can produce.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h472958p2648127}{APMO 2012 P2}{E}{Into each box of a $ n \\times n $ square grid, a real number greater than or equal to $ 0 $ and less than or equal to $ 1 $ is inserted. Consider splitting the grid into $2$ non-empty rectangles consisting of boxes of the grid by drawing a line parallel either to the horizontal or the vertical side of the grid. Suppose that for at least one of the resulting rectangles the sum of the numbers in the boxes within the rectangle is less than or equal to $ 1 $, no matter how the grid is split into $2$ such rectangles. Determine the maximum possible value for the sum of all the $ n \\times n $ numbers inserted into the boxes. Find the ans for $ k $-dimension grids too.}\\label{problem:extreme_object_14}\n\n\n\t\\solu{As the maximal rectangle defines other smaller rectangles in it, we take that.}\n\n\n\n\n\t\\prob{www.hehe.com}{Indian Postal Coaching 2011}{M}{Consider $ 2011^2 $ points arranged in the form of a $ 2011 \\times 2011 $ grid. What is the maximum number of points that can be chosen among them so that no four of them form the vertices's of either an isosceles trapezium or a rectangle whose parallel sides are parallel to the grid lines?}\\label{problem:forget_and_focus_6}\n\n\t\\solu{Since we need to maintain the relation of perpendicular bisectors, we focus on perp bisectors and the points on one line only and then count.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h418686p2362296}{ISL 2010 C2}{M}{On some planet, there are $2^N$ countries $(N \\geq 4).$ Each country has a flag $N$ units wide and one unit high composed of $N$ fields of size $1 \\times 1,$ each field being either yellow or blue. No two countries have the same flag. We say that a set of $N$ flags is diverse if these flags can be arranged into an $N \\times N$ square so that all $N$ fields on its main diagonal will have the same color. Determine the smallest positive integer $M$ such that among any $M$ distinct flags, there exist $N$ flags forming a diverse set.}\\label{problem:induction_type1_6}\n\n\n\t\\solu{Using induction we see that if we have found the value of $ M $ for $ N-1 $, then possibly the value for $ M_N $ is twice as large than $ M_{N-1} $. With some further calculation, we see that if we have $ 2*M_{N-1}-1 = M_N $, then we can pick half of them and apply induction and still be left with a `lot' of flags to choose the $ N $th element of the diverse set.\\\\\\\\ After that the only work left is to proof for $ N=4 $. Which is easy casework.}\n\n\t\\solu{Another way to prove the ans, is to prove the bound for any non-diverse set. In this case, we use hall's marriage to prove the contradiction.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h147501p834073}{Iran TST 2007 P2}{E}{Let $A$ be the largest subset of $\\{1,\\dots,n\\}$ such that for each $x\\in A$, $x$ divides at most one other element in $A$. Prove that \\[\\frac{2n}3\\leq |A|\\leq \\left\\lceil \\frac{3n}4\\right\\rceil. \\]}\\label{problem:divide_and_conquer_6}\n\n\t\\solu{Partition the set optimally.}\n\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1485051p8702069}{India IMO Camp 2017}{H}{Find all positive integers $ n $ s.t. the set $ \\{1, 2, \\dots, 3n\\} $ can be partitioned into $ n $ triplets $ (a_i, b_i, c_i) $ such that $ a_i+b_i=c_i $ for all $ 1 \\le i \\le n $.}\\label{problem:constructive_algo_11}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h546169p3160560}{ISL 2012 C2}{TE}{Let $ n \\geq 1 $ be an integer. What is the maximum number of disjoint pairs of elements of the set $ \\{ 1,2,\\ldots , n \\} $ such that the sums of the different pairs are different integers not exceeding $ n $ ?}\\label{problem:constructive_algo_12}\n\n\t\\solu{As Usual, first find the ans. Using double counting is quite natural. Working with small cases easily gives a construction.}\n\n\n\n\n\t\\prob{http://codeforces.com/problemset/problem/989/C}{CodeForces 989C}{E}{}\\label{problem:constructive_algo_13}\n\n\n\n\n\t\\prob{http://codeforces.com/problemset/problem/989/B}{CodeForces 989B}{E}{}\\label{problem:constructive_algo_14}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h488537p2737645}{ISL 2011 A5}{MH}{Prove that for every positive integer $ n $ , the set $ \\{2, 3, \\ldots, 3n+1\\} $ can be partitioned into $ n $ triples in such a way that the numbers from each triple are the lengths of the sides of some obtuse triangle.}\\label{problem:constructive_algo_15}\n\n\t\\solu{What is the best way to choose the side lengths of an obtuse triangle? Obviously by maintaining some strict rules to get the third side from the first two sides and making the rules invariant. One way of doing this is to take $ (a,b,a+b-1) $.\n\n\t\tAfter that, some (literally this is the hardest part of the problem) experiment to find a construction. First, we try to partition the set into tuples of our desired form, but we soon realize that that can’t be done so easily. So we try a little bit of different approach and make one tuple different from the others. Luckily this approach gives us a nice construction.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1423008p8003911}{Iran TST 2017 D1P1}{TE}{In the country of Sugarland, there are $ 13 $ students in the IMO team selection camp. $ 6 $ team selection tests were taken and the results have came out. Assume that no students have the same score on the same test. To select the IMO team, the national committee of math Olympiad have decided to choose a permutation of these $ 6 $ tests and starting from the first test, the person with the highest score between the remaining students will become a member of the team. The committee is having a session to choose the permutation.\n\n\t\tIs it possible that all $ 13 $ students have a chance of being a team member?}\\label{problem:constructive_algo_16}\n\n\t\\solu{If a student is in $ x^{th} $ place in a test $ t_y $ , and he has a chance to get into the team iff the $ 1^th, 2^th\\dots {x-1}^th $ persons in test $ t_y $ are already in the team. So $ x\\leq 5 $. Make a $ 6\\cdot 6 $ grid with place $ \\cdot $ test. WHY?? Because it makes the best sense among other possible choices of the grid. A little bit of work produces a configuration where every student has a chance to get into the team.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h355784p1932924}{ISL 2009 C2}{M}{For any integer $ n\\geq 2 $ , let $ N(n) $ be the maximum number of triples $ (a_i, b_i, c_i) $ , $ i=1, 2 \\ldots, N(n) $ , consisting of nonnegative integers $ a_i $ , $ b_i $ and $ c_i $ such that the following two conditions are satisfied:\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\n\t\t\t\\item $ a_i+b_i+c_i=n $ for all $ i=1, \\ldots, N(n) $ ,\n\t\t\t\\item If $ i\\neq j $ then $ a_i\\neq a_j $ , $ b_i\\neq b_j $ and $ c_i\\neq c_j $\n\n\t\t\\end{enumerate}\n\n\t\tDetermine $ N(n) $ for all $ n\\geq 2 $.}\\label{problem:constructive_algo_17}\n\n\t\\solu{Find an upper bound. It’s easy. Then with some experiment, we see that this upper bound is achievable. So our next task is to find a construction. As it is related to $ 3 $ , we first try with $ n=3k $. Some experiment and experience gives us a construction.}\n\n\n\n\n\n\t\\prob{}{}{M}{Let $ n $ be an integer. What is the maximum number of disjoint pairs of elements of the set $ \\{ 1,2,\\ldots , n \\} $ such that the sums of the different pairs are different integers not exceeding $ n $ ?} \\label{problem:constructive_algo_18}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h17342p118721}{ISL 2002 C6}{H}{Let n be an even positive integer. Show that there is a permutation $ (x_1,x_2 \\dots x_n) $ of $ (1,2\\dots n) $ such that for every $ 1\\leq i\\leq n $ , the number $ x_{i+1} $ is one of the numbers $ 2x_i,2x_i-1,2x_i-n,2x_i-n-1 $. Hereby, we use the cyclic subscript convention, so that $ x_{n+1} $ means $ x_1 $.}\\label{problem:graph_representation_5}\n\n\t\\medskip Some experiments show that our graph has more than $ 2 $ incoming and outgoing degree in all vertexes expect the first and last vertexes. So our lemma won’t work yet. To make use of our lemma we take a graph with half of the vertexes of our original graph and make each vertex $ v_{2k} $ represent two integers: $ (2k-1, 2k) $. Simple argument shows that this graph has an Euler Circuit, and surprisingly this itself is sufficient, as we can follow this circuit to get every integers in the interval $ [1,n] $.\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1352165p7389115}{USA TST 2017 P1}{E}{In a sports league, each team uses a set of at most $ t $ signature colors. A set $ S $ of teams is color-identifiable if one can assign each team in $ S $ one of their signature colors, such that no team in $ S $ is assigned any signature color of a different team in $ S $.\\\\\n\n\t\tFor all positive integers $ n $ and $ t $, determine the maximum integer $ g(n, t) $ such that: In any sports league with exactly $ n $ distinct colors present over all teams, one can always find a color-identifiable set of size at least $ g(n, t) $.}\\label{problem:extremal_case_whole_8}\n\n\t\\solu{First, guess the answer, then try taking the minimal set.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c7h1554574p9472772}{Putnam 2017 A4}{E}{$ 2N $ students take a quiz in which the possible scores are $ 0, 1\\dots 10 $. It is given that each of these scores appeared at least once, and the average of their scores is $ 7.4 $. Prove that the students can be divided into two sets of $ N $ student with both sets having an average score of $ 7.4 $.}\\label{problem:constructive_algo_19}\n\n\t\\solu{We take a set $ S_1=\\{0, 1\\dots 10\\} $. Basically we have to partition the set of $ 2N $ into two equal sets with equal sum. So we pair $ S $ , and other leftovers and see what happens.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h126193p715430}{ISL 2005 C3}{MH}{Consider a $m\\times n$ rectangular board consisting of $mn$ unit squares. Two of its unit squares are called adjacent if they have a common edge, and a path is a sequence of unit squares in which any two consecutive squares are adjacent. Two paths are called non-intersecting if they don't share any common squares.\\\\\n\n\t\tEach unit square of the rectangular board can be colored black or white. We speak of a coloring of the board if all its $mn$ unit squares are colored.\\\\\n\n\t\tLet $N$ be the number of colorings of the board such that there exists at least one black path from the left edge of the board to its right edge. Let $M$ be the number of colorings of the board for which there exist at least two non-intersecting black paths from the left edge of the board to its right edge.\\\\\n\n\t\tProve that $N^{2}\\geq M\\times 2^{mn}$.}\\label{problem:bijection_11}\n\n\t\\solu{Bijective relation problem, the condition has $ \\times $, means we find a combinatorial model for the R.H.S. which is a pair of boards satisfying conditions. We want to show a surjection from this model to the model on the L.H.S.}\n\n\n\n\t\\prob{www.hehe.com}{Result by Erdos}{MH}{Given two \\emph{different} sequence of integers $ (a_1, a_2\\dots a_n), (b_1, b_2, \\dots b_n) $ such that two $ \\frac{n(n-1)}{2} $-tuples \\[ a_1+a_2, a_1+a_3\\dots a_{n-1}a_n\\ \\text{ and }\\ b_1+b_2, b_1+b_3\\dots b_{n-1}b_n \\] are equal upto permutation. Prove that $ n=2^k $ for some $ k $.}\\label{problem:generating_function_1}\\label{algebraic_manipulation}\n\n\n\t\\prob{www.hehe.com}{A reformulation of Catalan's Numbers}{MH}{Let $ n\\geq 3 $ students all have different heights. In how many ways can they be arranged such that the heights of any three of them are not from left to right in the order: medium, tall, short?}\\label{problem:catalan_recursion_1}\\label{problem:generating_function_3}\n\n\t\\solu{The proof uses derivatives to construct a polynomial similar to a \\textbf{Maclaurin Series}.}\n\n\n\t\\prob{}{}{E}{There are $n$ cubic polynomials with three distinct real roots each. Call them $P_1(x), P_2(x),\\dots, P_n(x)$. Furthermore for any two polynomials $P_i, P_j$, $P_i(x)P_j(x)=0$ has exactly $5$ distinct real roots. Let $S$ be the set of roots of the equation \\[P_1(x)P_2(x)\\dots P_n(x)=0\\]. Prove that\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\n\t\t\t\\item If for each $a, b$ there is exactly one $i \\in \\{1, \\dots n\\}$ such that $P_i(a)=P_i(b)=0$, then $n=7$.\n\t\t\t\\item If $n>7$, $|S| = 2n+1$.\n\n\t\\end{enumerate}}\\label{problem:extremal_case_whole_9}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1450192p8312110}{Serbia TST 2017 P2}{E}{Initially a pair $(x, y)$ is written on the board, such that exactly one of it's coordinates is odd. On such a pair we perform an operation to get pair $(\\frac x 2, y+\\frac x 2)$ if $2|x$ and $(x+\\frac y 2, \\frac y 2)$ if $2|y$. Prove that for every odd $n>1$ there is a even positive integer $b<n$ such that starting from the pair $(n, b)$ we will get the pair $(b, n)$ after finitely many operations.}\\label{problem:invariant_rules_of_thumb_8}\n\n\t\\solu{Finding a construction through investigation and realizing that the infos and operations on $ x $ only defines the changes are enough for this problem.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1450624p8316894}{Serbia TST 2017 P4}{E}{We have an $n \\times n$ square divided into unit squares. Each side of unit square is called unit segment. Some isosceles right triangles of hypotenuse $2$ are put on the square so all their vertices's are also vertices's of unit squares. For which $n$ it is possible that every unit segment belongs to exactly one triangle (unit segment belongs to a triangle even if it's on the border of the triangle)?}\\label{problem:constructive_algo_20}\n\n\t\\solu{Finding $ n $ is even, seeing $ 4 $ fails...}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1545675p9374373}{China MO 2018 P2}{M}{Let $n$ and $k$ be positive integers and let\n\t\t\\[T = \\{ (x,y,z) \\in \\mathbb{N}^3 \\mid 1 \\leq x,y,z \\leq n \\}\\]\n\t\tbe the length $n$ lattice cube. Suppose that $3n^2 - 3n + 1 + k$ points of $T$ are colored red such that if $P$ and $Q$ are red points and $PQ$ is parallel to one of the coordinate axes, then the whole line segment $PQ$ consists of only red points.\\\\\n\n\t\tProve that there exists at least $k$ unit cubes of length $1$, all of whose vertices's are colored red.}\\label{problem:double_counting_8}\n\n\n\t\\solu{The inductive solution is tedious, and since we have to count the number of ``good'' boxes, we can try double counting. Explicitly counting all the ``good'' boxes.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1546234p9380562}{China MO 2018 P5}{MH}{Let $n \\geq 3$ be an odd number and suppose that each square in a $n \\times n$ chessboard is colored either black or white. Two squares are considered adjacent if they are of the same color and share a common vertex and two squares $a,b$ are considered connected if there exists a sequence of squares $c_1,\\ldots,c_k$ with $c_1 = a, c_k = b$ such that $c_i, c_{i+1}$ are adjacent for $i=1,2,\\ldots,k-1$.\\\\\n\n\t\tFind the maximal number $M$ such that there exists a coloring admitting $M$ pairwise disconnected squares.}\n\n\t\\solu{It's not hard to get the ans, now that the answer is guesses, and we have tried to prove with induction and couldn't find anything good, we try double counting. We notice that all the connected components in the $ n\\times n $ are planar graphs. Now we use Euler's \\hrf{theorem:planar_graph_theorem}{theorem} on Planar Graphs to find a value of $ M $ wrt to other values, and we double count the other values.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h84550p490581}{USAMO 2006 P2}{E}{For a given positive integer $k$ find, in terms of $k$, the minimum value of $N$ for which there is a set of $2k + 1$ distinct positive integers that has sum greater than $N$ but every subset of size $k$ has sum at most $\\tfrac{N}{2}.$}\\label{problem:extremal_case_whole_10}\n\n\t\\solu{The best or simple looking set is the set of consecutive integers. So if there are some `holes', we can fill them up to some extent, this opens two sub-cases.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h34314p213007}{USAMO 2005 P1}{E}{Determine all composite positive integers $n$ for which it is possible to arrange all divisors of $n$ that are greater than $ 1 $ in a circle so that no two adjacent divisors are relatively prime.}\\label{problem:induction_type1_23}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h84558p490682}{USAMO 2005 P5}{E}{A mathematical frog jumps along the number line. The frog starts at $1$, and jumps according to the following rule: if the frog is at integer $n$, then it can jump either to $n+1$ or to $n + 2^{m_n+1}$ where $2^{m_n}$ is the largest power of $2$ that is a factor of $n$. Show that if $k \\geq 2$ is a positive integer and $i$ is a nonnegative integer, then the minimum number of jumps needed to reach $2^ik$ is greater than the minimum number of jumps needed to reach $2^i.$}\\label{problem:induction_type1_24}\n\n\t\\solu{The main idea is to notice that the operation only uses powers of $ 2 $. And it depends on only the power of $ 2 $ in the integers, and in the sequence of $ 2 $-powers, the operation is very nice.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h60727p366446}{ISL 1991 P10}{E}{Suppose $ \\,G\\,$ is a connected graph with $ \\,k\\,$ edges. Prove that it is possible to label the edges $ 1,2,\\ldots ,k\\,$ in such a way that at each vertex which belongs to two or more edges, the greatest common divisor of the integers labeling those edges is equal to $ 1 $.}\\label{problem:induction_type1_27}\n\n\n\n\t\\prob{}{}{E}{A robot has $ n $ modes, and programmed as such: in mode $ i $ the robot will go at a speed of $ i \\text{ms}^{-1} $ for $ i $ seconds. At the beginning of its journey, you have to give it a permutation of $ \\{1, 2, \\dots n \\} $. What is the maximum distance you can make the robot go?}\\label{problem:swapping_5}\n\n\n\n\t\\prob{}{}{E}{A slight variation of the previous problem, in this case, the problem goes at a speed of $ (n-1) \\text{ms}^{-1} $ for $ i $ seconds in mode $ i $.}\\label{problem:swapping_6}\n\n\n\n\n\t\\prob{}{}{E}{$ m $ people each ordered $ n $ books but because Ittihad was the mailman, he messed up. Everyone got $ n $ books but not necessarily the one they wanted you need to fix this. To go to a house from another house it takes one hour. You can carry one book with you during any trip (at most one). You know who has which books and all books are different (i,e, $ n * m $ different books). Prove that you can always finish the job in $ m*(n+\\frac{1}{2}) $ hours}\\label{problem:graph_representation_6}\n\n\t\\solu{Thinking about the penultimate step, when we have to go to a house empty handed. Thinking in this way gives us a way to pair the houses up, and since pairing...}\n\n\t\\solu{Another way to do this is to convert it to a multi-graph. Now go to a house and return with a book means removing two edges from that vertex. We play around with it for sometime}\n\n\n\n\n\t\\prob{}{}{E}{There are $ n $ campers in a camp and they will try to solve a IMO P6 but everyone has a confidence threshold (they will solve the problem by group solving). For example Laxem has threshold $ 5 $. I.e. if he's in the group, the group needs to contain at least $ 5 $ people (him included). A group is `confident' when everyone of the team is confident. Now MM wants to make a list of possible ``perfect confident'' groups. I.e. groups that are confident but adding anyone else will destroy the confidence. How long can his list be?}\\label{problem:extreme_object_15}\n\n\n\n\t\\prob{http://acm.timus.ru/problem.aspx?space=1&num=1862}{timus 1862}{ME}{}\\label{problem:binary_heap_1}\\label{problem:graph_representation_7}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h589935p3493451}{ARO 2014 P9.7}{E}{In a country, mathematicians chose an $\\alpha> 2$ and issued coins in denominations of 1 ruble, as well as $\\alpha ^k$ rubles for each positive integer k. $\\alpha$ was chosen so that the value of each coins, except the smallest, was irrational. Is it possible that any natural number of rubles can be formed with at most 6 of each denomination of coins?}\\label{problem:recursive_solution_6}\n\n\n\n\t\\prob{www.hehe.com}{Saint Petersburg 2001}{MH}{The number $n$ is written on a board. $A$ and $B$ take turns, each turn consisting of replacing the number $n$ on the board with $n - 1$ or $\\floor{\\frac{n+1}{2}}$. The player who writes the number $1$ wins. Who has the winning strategy?}\\label{problem:recursive_solution_7}\n\n\t\\solu{Recursively building the losing positions.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h405391p2262420}{ARO 2011 P11.6}{E}{There are more than $n^2$ stones on the table. Peter and Vasya play a game, Peter starts. Each turn, a player can take any prime number less than $n$ stones, or any multiple of $n$ stones, or $1$ stone. Prove that Peter always can take the last stone (regardless of Vasya's strategy).}\\label{problem:pairing_and_copying_1}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h147159p832730}{ARO 2007 P9.7}{E}{Two players by turns draw diagonals in a regular $(2n+1)$-gon ($n>1$). It is forbidden to draw a diagonal, which was already drawn, or intersects an odd number of already drawn diagonals. The player, who has no legal move, loses. Who has a winning strategy?}\\label{problem:graph_representation_8}\n\n\t\\solu{Turning the diagonals as vertices, and connection being intersections, we get a graph to play the game on. We then count the degrees.}\n\n\n\n\t\\prob{}{}{E}{After tiling a $ 6\\times 6 $ box with dominoes, prove that a line parallel to the sides of the box can be drawn that this line doesn't cut any dominoes.}\\label{problem:double_counting_9}\n\n\t\\solu{Double count how many lines ``cut'' a domino, and domino number.}\n\n\n\n\t\\prob{}{}{E}{There are $ 100 $ points on the plane. You have to cover them with discs, so that any two disks are at a distance of $ 1 $. Prove that you can do this in such a way that the total diameter of the disks is $ < 100 $.}\\label{problem:induction_type1_28}\n\n\t\\solu{As the number $ 100 $ is very random, we suspect that is true for all values. So we can use induction}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h589938p3493455}{ARO 2014 P10.8}{M}{Given are $n$ pairwise intersecting convex $k$-gons on the plane. Any of them can be transferred to any other by a homothety with a positive coefficient. Prove that there is a point in a plane belonging to at least $1 +\\frac{n-1}{2k}$ of these $k$-gons.}\\label{problem:changing_term_1}\n\n\t\\solu{The most natural such point should be a vertex of a polygon. And these kinda problems use PHP more often, so we will have to divide by $k$ somewhere. Again to find the polygon to use the PHP we will have to divide by $n$ also. So we want to have $nk$ in the denominator. We change the term to achieve this and Ta-Da! we get a fine term to work with.}\n\n\n\n\t\\prob{https://ioi2018.jp/wp-content/tasks/contest1/combo.pdf}{IOI 2018 P1}{E}{}\\label{problem:induction_type1_29}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h5976p20088}{German TST 2004 E7P3}{M}{We consider graphs with vertices colored black or white. \"Switching\" a vertex means: coloring it black if it was formerly white, and coloring it white if it was formerly black.\\\\\n\n\t\tConsider a finite graph with all vertices colored white. Now, we can do the following operation: Switch a vertex and simultaneously switch all of its neighbours (i. e. all vertices connected to this vertex by an edge). Can we, just by performing this operation several times, obtain a graph with all vertices colored black?}\\label{problem:induction_type1_30}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h17455p119177}{ISL 2001 C3}{E}{Define a $ k $-clique to be a set of $ k $ people such that every pair of them are acquainted with each other. At a certain party, every pair of $ 3 $-cliques has at least one person in common, and there are no $ 5 $-cliques. Prove that there are two or fewer people at the party whose departure leaves no $ 3 $-clique remaining.}\\label{problem:extreme_object_16}\n\n\t\\solu{Casework with the point where most of the triangles are joined.}\n\n\n\n\t--------------------\n\n\n\n\n\t\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h34314p213007}{USAMO 2005 P1}{E}{Determine all composite positive integers $n$ for which it is possible to arrange all divisors of $n$ that are greater than 1 in a circle so that no two adjacent divisors are relatively prime.}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h34317p213012}{USAMO 2005 P4}{E}{Legs $L_1, L_2, L_3, L_4$ of a square table each have length $n$, where $n$ is a positive integer. For how many ordered 4-tuples $(k_1, k_2, k_3, k_4)$ of nonnegative integers can we cut a piece of length $k_i$ from the end of leg $L_i \\; (i=1,2,3,4)$ and still have a stable table?\n\n\t\t(The table is stable if it can be placed so that all four of the leg ends touch the floor. Note that a cut leg of length 0 is permitted.)}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h84550p490581}{USAMO 2006 P2}{M}{For a given positive integer $k$ find, in terms of $k$, the minimum value of $N$ for which there is a set of $2k + 1$ distinct positive integers that has sum greater than $N$ but every subset of size $k$ has sum at most $\\tfrac{N}{2}.$}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h84558p490682}{USAMO 2006 P5}{M}{A mathematical frog jumps along the number line. The frog starts at $1$, and jumps according to the following rule: if the frog is at integer $n$, then it can jump either to $n+1$ or to $n + 2^{m_n+1}$ where $2^{m_n}$ is the largest power of $2$ that is a factor of $n.$ Show that if $k \\geq 2$ is a positive integer and $i$ is a nonnegative integer, then the minimum number of jumps needed to reach $2^ik$ is greater than the minimum number of jumps needed to reach $2^i$.}\t\n\n\n\t\\prob{https://artofproblemsolving.com/community/c5h274370p1485139}{USAMO 2009 P2}{EM}{Let $n$ be a positive integer. Determine the size of the largest subset of $\\{ -n, -n+1, \\dots, n-1, n\\}$ which does not contain three elements $a$, $b$, $c$ (not necessarily distinct) satisfying $a+b+c=0$.}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h514375p2889828}{ARO 1999 P9.8}{M}{There are $2000$ components in a circuit, every two of which were initially joined by a wire. The hooligans Vasya and Petya cut the wires one after another. Vasya, who starts, cuts one wire on his turn, while Petya cuts one or three. The hooligan who cuts the last wire from some component loses. Who has the winning strategy?}\n\\newpage\\section{Tricks}\n\n\n\t\\Faka\\Faka\\subsection{Bijection}\n\n\t{\n\n\tIdeas for the bijection function:\n\n\t\\begin{itemize}\n\n\t\t\\item Induction\n\t\t\\item Forming sets that are not already formed\n\t\t\\item Building combinatorial models from the investigation of the problem conditions.\n\t\t\\item Trying to define the later set by the former set.\n\n\t\\end{itemize}\n\n\n\t}\\faka\n\n\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:bijection_1}{ISL 2002 C1,}{Red-Blue Under $ x+y < n $ and Bijection}\n\t\t\\iref{problem:bijection_2}{OC Chap2 P2,}{Magic trick of hiding two digits}\n\t\t\\iref{problem:bijection_3}{ISL 2009 C3}{}\n\t\t\\iref{problem:bijection_4}{USAMO 1996 P4,}{Binary Strings NOT containing certain Combinations}\n\t\t\\iref{problem:bijection_5}{ISL 2008 C4,}{Lamp States and Probability}\n\t\t\\iref{problem:bijection_6}{APMO 2017 P3,}{Bijection Problem}\n\t\t\\iref{problem:bijection_7}{USAMO 2013 P2,}{Around the circle on points with move or $ 1 $ or $ 2 $}\n\t\t\\iref{problem:bijection_8}{APMO 2008 P2}{}\n\t\t\\iref{problem:bijection_9}{ISL 2006 C2}{}\n\t\t\\iref{problem:bijection_10}{USA TST 2009 P1}{}\n\t\t\\iref{problem:bijection_11}{ISL 2005 C3}{}\n\t\t\\iref{problem:bijection_12}{ISL 2002 C2}{Cover all black squares with L-tromino}\n\t\t\\iref{problem:bijection_13}{ISL 2002 C3}{Full-Sequences}\n\t\\end{enumerate}\n\n\n\n\n\n\n\n\n\t\\Faka\\subsubsection{Hall's Marriage Lemma\\label{hall_marriage}}\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:hall_marriage_1}{OC Chap2 P2}{}\n\t\t\\iref{problem:hall_marriage_2}{ARO 2005 P9.4}{}\n\t\\end{enumerate}\n\n\n\n\n\n\t\\newpage\\subsection{Extremal Principal}\n\n\n\n\n\t\\Faka\\subsubsection{Whole Extremal Cases\\label{extremal_case_whole}}{Exploring the extreme case as a whole}\n\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:extremal_case_whole_1}{ISL 2013 C1}{}\n\n\t\t\t\\iref{problem:extremal_case_whole_2}{Brazilian Olympic Revenge 2014}{}\n\t\t\t\\iref{problem:extremal_case_whole_3}{ISL 2009 C1}{}\n\t\t\t\\iref{problem:extremal_case_whole_4}{EGMO 2017 P2}{}\n\t\t\t\\iref{problem:extremal_case_whole_5}{APMO 2008 P2}{}\n\t\t\t\\iref{problem:extremal_case_whole_6}{Belarus 2001}{}\n\t\t\t\\iref{problem:extremal_case_whole_7}{ISL 2014 C3}{}\n\t\t\t\\iref{problem:extremal_case_whole_8}{USA TST 2017 P1}{}\n\t\t\t\\iref{problem:extremal_case_whole_9}{Polynomials and Roots problem}{}\n\t\t\t\\iref{problem:extremal_case_whole_10}{USAMO 2006 P2}{}\n\t\t\t\\iref{problem:extremal_case_whole_11}{ISL 2014 N3,}{Cape Town Coin problem}\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\t\\Faka\\subsubsection{Forget and Focus}{Explore only one part of the problem at a time, choose the most crucial part of the problem and focus only on that.}\\label{forget_and_focus}\n\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:forget_and_focus_1}{ARO 2018 P9.5}{}\n\t\t\t\\iref{problem:forget_and_focus_2}{Polish OI}{}\n\t\t\t\\iref{problem:forget_and_focus_3}{ARO 2008 P9.5}{}\n\t\t\t\\iref{problem:forget_and_focus_4}{ISL 2001 C6}{}\n\t\t\t\\iref{problem:forget_and_focus_5}{Swell Coloring}{}\n\t\t\t\\iref{problem:forget_and_focus_6}{Indian Postal Coaching 2011}{}\n\t\t\t\\iref{problem:forget_and_focus_7}{Romanian TST 2016 D1P2,}{associating $ x_i $ with $ S_i $}\n\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\t\t\\Faka\\paragraph{Swapping / Forget and Focus (2)}{Focusing on two neighboring elements in the extremal case.}\\label{swapping}\n\n\t\t\\begin{multicols}{2}\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:swapping_1}{Polish OI}{}\n\t\t\t\t\\iref{problem:swapping_2}{IOI 2007 P3}{}\n\t\t\t\t\\iref{problem:swapping_3}{Problem}{}\n\t\t\t\t\\iref{problem:swapping_4}{ARO 2014 P9.8}{}\n\t\t\t\t\\iref{problem:swapping_5}{Problem,}{Robot goes at a speed of $ i $ for $ i $ seconds in mode $ i $}\n\t\t\t\t\\iref{problem:swapping_6}{Problem,}{The same with speed $ n-i $}\n\t\t\t\\end{enumerate}\n\t\t\\end{multicols}\n\n\n\t\t\\Faka\\paragraph{Game Positions}{Considering Winning/Losing positions and describing the game with these definitions is an important game theory tactic.}\\label{win_lose}\n\n\t\t\\begin{multicols}{3}\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:win_lose_1}{ISL 2004 C5}{}\n\t\t\t\\end{enumerate}\n\t\t\\end{multicols}\n\n\n\n\n\n\t\\Faka\\subsubsection{Extreme Objects}{Concentrating on the Extreme object only}\\label{extreme_object}\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:extreme_object_1}{USAMO 2008 P4}{}\n\t\t\\iref{problem:extreme_object_2}{ISL 2008 C1}{}\n\t\t\\iref{problem:extreme_object_3}{IMO 2011 P2}{}\n\t\t\\iref{problem:extreme_object_4}{Iran TST 2002 P3}{}\n\t\t\\iref{problem:extreme_object_5}{Problem}{}\n\t\t\\iref{problem:extreme_object_6}{ISL 2006 C4}{}\n\t\t\\iref{problem:extreme_object_7}{ISL 2014 C1}{}\n\t\t\\iref{problem:extreme_object_8}{ARO 1993 P10.4}{}\n\t\t\\iref{problem:extreme_object_10}{Sunflower Lemma}{}\n\t\t\\iref{problem:extreme_object_11}{ISL 1998 C4}{}\n\t\t\\iref{problem:extreme_object_12}{USA TST 2009 P1}{}\n\t\t\\iref{problem:extreme_object_13}{AoPS}{}\n\t\t\\iref{problem:extreme_object_14}{APMO 2012 P2}{}\n\t\t\\iref{problem:extreme_object_15}{Problem,}{Confidence in solving a P6}\n\t\t\\iref{problem:extreme_object_16}{ISL 2001 C3,}{$ 3 $-cliques with common points}\n\t\t\\iref{problem:extreme_object_17}{ISL 2007 C2,}{dissecting a rectangle into $ n $ smaller rectangles, there exists a rectangle inside}\n\n\n\t\\end{enumerate}\n\n\n\n\n\t\\newpage\\subsection{Coloring}\n\n\n\t\t\\begin{itemize}\n\n\t\t\t\\item If the nodes are connected in lattice point manner, then \\textbf{Checkerboard} coloring is the most natural coloring technique. But if this coloring does not do any good, then there may be other alternatives and derivatives of checkerboard, like \\textbf{Pseudo Checkerboard} or \\textbf{Double Checkerboard}. The Pseudo Checkerboard's each row (or column) starts and end with the same color (If there are odd nodes in each row). In a Double Checkerboard, two consecutive nodes are of the same color. (You get the picture, don't you?)\n\n\t\t\t\\item Checkerboard with $ \\frac{1}{2}\\times \\frac{1}{2} $ sized cells. Proof of the rectangle with integer side problem.\n\n\t\t\t\\item Color with ``Roots of Unity''.\n\n\t\t\t\\item A knight's move always changes the color of the cell.\n\n\t\t\\end{itemize}\n\n\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:coloring_1}{USAMO 2014 P1}{}\n\t\t\\iref{problem:coloring_2}{USAMO 2008 P3}{}\n\t\t\\iref{problem:coloring_3}{IMO 2018 P4}{}\n\t\t\\iref{problem:coloring_4}{Codeforces 101954/G}{}\n\n\t\\end{enumerate}\n\n\n\t\\Faka\\subsubsection{Plane divided by lines}{In problems regarding the plane being divided by straight lines, color the plane with chessboard colors.}\\label{plane_coloring}\n\n\t\\begin{multicols}{3}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:plane_coloring_1}{EGMO 2017 P3}{{}}\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\n\n\t\\newpage\\subsection{Divide and Conquer\\label{divide_and_conquer}}\n\n\t\\vspace{10mm}\n\n\n\tDivide the problem/grid/graph into smaller pieces and work through them separately and finally join them together. The main difference between this and induction/recursion is that we have to actually work in the smaller cases instead of assuming that they are true.\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:divide_and_conquer_1}{USA TST 2011 P2,}{Capacity $ 1, 2 $ roads}\n\t\t\\iref{problem:divide_and_conquer_2}{CodeForces 744B,}{Finding the minimum number in the rows}\n\t\t\\iref{problem:divide_and_conquer_3}{Problem,}{Double binary search}\n\t\t\\iref{problem:divide_and_conquer_4}{ISL 2005 C1,}{Lamps in rooms}\n\t\t\\iref{problem:divide_and_conquer_5}{IOI 2016 P5,}{Bug changes the strings}\n\t\t\\iref{problem:divide_and_conquer_6}{Iran TST 2007 P2,}{$x$ divides at most one other element in $A$}\n\t\\end{enumerate}\n\n\n\n\n\t\\Faka\\subsubsection{Induction}{\\textbf{Cauchy Induction}: $ n \\rightarrow 2n, n \\rightarrow n-1 $ }\\label{induction}\n\n\n\t\tCan be used in almost any kind of problems, often called `\\textit{goriber bondhu}'.\n\n\t\t\\begin{itemize}\n\n\t\t\t\\item In MO probs $ 2-3-5-6 $ or SL $ 3+ $ (often $ 1, 2 $ as well) you can be sure that applying only induction isn't going to do any good. You'll need extra tools, and you might need to apply induction more than once.\n\n\t\t\t\\begin{itemize}\n\n\t\t\t\t\\item Sometimes, in graph probs, apply indution on more than one node gives better results.\n\t\t\t\t\\item Often you can set up your induction in more than one way, and finding the right way makes the problem much simpler.\n\t\t\t\t\\item Sometimes trying to prove more by adding a stronger induction hypothesis makes it easier to carry out the induction.\n\n\t\t\t\\end{itemize}\n\n\t\t\\end{itemize}\n\n\n\t\\faka\\textbf{Type 1}: $ n-1 \\rightarrow n $\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:induction_type1_1}{ISL 2004 C2,}{$ n $ circles intersect, colors}\n\t\t\\iref{problem:induction_type1_2}{ISL 1997 P4,}{Silver matrix}\n\t\t\\iref{problem:induction_type1_3}{ARO 2018 P11.5,}{an easy graph}\n\t\t\\iref{problem:induction_type1_4}{ISL 2006 C1,}{lamps will eventually be off}\n\t\t\\iref{problem:induction_type1_5}{ISL 2002 C1,}{bijection in $ x+y=n $ and red-blue colors}\n\t\t\\iref{problem:induction_type1_6}{ISL 2012 C2}{}\n\t\t\\iref{problem:induction_type1_7}{ARO 2013 P9.4}{}\n\t\t\\iref{problem:induction_type1_8}{ISL 2005 C2}{}\n\t\t\\iref{problem:induction_type1_9}{ISL 2013 C3}{}\n\t\t\\iref{problem:induction_type1_10}{ISL 2005 C1}{}\n\t\t\\iref{problem:induction_type1_11}{ISL 2016 C6,}{the ferry problem}\n\t\t\\iref{problem:induction_type1_12}{IMO SL 1985}{}\n\t\t\\iref{problem:induction_type1_13}{ELMO 2017 P5}{}\n\t\t\\iref{problem:induction_type1_14}{ISL 1990}{}\n\t\t\\iref{problem:induction_type1_15}{USAMO 2017 P4}{}\n\t\t\\iref{problem:induction_type1_16}{Jacob Tsimerman Induction}{}\n\t\t\\iref{problem:induction_type1_17}{All Russia 2017 9.1}{}\n\t\t\\iref{problem:induction_type1_18}{Iran TST 2008 D3P1}{}\n\t\t\\iref{problem:induction_type1_19}{USA TST 2011 D3P2}{}\n\t\t\\iref{problem:induction_type1_20}{Sunflower Lemma}{}\n\t\t\\iref{problem:induction_type1_21}{ISL 1998 C4}{}\n\t\t\\iref{problem:induction_type1_22}{Generalization of USAMO 1999 P1}{}\n\t\t\\iref{problem:induction_type1_23}{USAMO 2005 P1,}{arranging divisors on a circle with no co-prime neighbors}\n\t\t\\iref{problem:induction_type1_24}{USAMO 2006 P5,}{a frog jumps jumps of $ 2 $-powers}\n\t\t\\iref{problem:induction_type1_25}{Romanian TST 2016 D1P2,}{associating $ x_i $ with $ S_i $}\n\t\t\\iref{problem:induction_type1_26}{American Mathematical Monthly,}{$ n $ subsets from $ S={1\\dots n-1} $ and a weird relation}\n\t\t\\iref{problem:induction_type1_27}{ISL 1991 P10,}{Color the graph by numbers such that any vertex is gcd $ 1 $}\n\t\t\\iref{problem:induction_type1_28}{Problem,}{Circles $ 1 $ unit apart, gotta cover them up.}\n\t\t\\iref{problem:induction_type1_29}{IOI 2018 P1,}{Prefixes of a string}\n\t\t\\iref{problem:induction_type1_30}{German TST 2004 E7P3,}{A white graph to a black graph}\n\t\t\\iref{problem:induction_type1_31}{ISL 2002 C5,}{An finite family of sets of size $ r $ has a intersecting set of size $ r-1 $}\n\t\t\\iref{problem:induction_type1_32}{US Dec TST 2016, P1,}{$ k $ bijections, and cycles in those}\n\t\\end{enumerate}\n\n\n\n\t\\faka\\textbf{Type 2}: $ k (k<n-1) \\rightarrow n $\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:induction_type2_1}{ARO 2014 P9.3}{}\n\t\t\\iref{problem:induction_type2_2}{Mexican Regional 2014 P6}{}\n\t\t\\iref{problem:induction_type2_3}{USA TST 2011 P2}{}\n\t\t\\iref{problem:induction_type2_4}{ISL 2006 C2}{}\n\t\t\\iref{problem:induction_type2_5}{APMO 1999 P2}{$a_{i+j} \\leq a_i+a_j$}\n\t\\end{enumerate}\n\n\n\n\n\t\\Faka\\subsubsection{Inductive/Recursive Relations}{Building other solutions depending on already or easily tweakable solutions.}\\label{recursive_solution}\n\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:recursive_solution_1}{India TST 2013 Test 3, P1}{}\n\t\t\t\\iref{problem:recursive_solution_2}{ISL 2002 C1}{}\n\t\t\t\\iref{problem:recursive_solution_3}{ISL 2009 C3}{}\n\t\t\t\\iref{problem:recursive_solution_4}{USAMO 2013 P2}{}\n\t\t\t\\iref{problem:recursive_solution_5}{IMO 2011 P4}{}\n\t\t\t\\iref{problem:recursive_solution_6}{ARO 2014 P9.7,}{stable coin system with coins of value $ \\a^k $}\n\t\t\t\\iref{problem:recursive_solution_7}{Saint Petersburg 2001}{}\n\t\t\\end{enumerate}\n\n\n\n\n\n\t\t\\Faka\\paragraph{Catalan Numbers}{$ C_n = \\frac{1}{n+1}\\binom{2n}{n} $, this little number is associated with a lot of combinatorial setups. And has the \\hrf{lemma:catalan_recursion}{recursion}.}\\label{catalan_numbers}\n\n\n\n\n\t\\newpage\\subsection{Count the Shit Up}\n\n\n\t\\Faka\\subsubsection{Double Counting\\label{double_counting}}\n\n\tExplicitly count the number of things, but Twice!\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:double_counting_1}{ISL 2016 C3,}{$ n $-gon colored with $ 3 $ colors, exists isosceles triangle.}\n\t\t\\iref{problem:double_counting_2}{Iran TST 2012 P4,}{Path inside of a $ m\\times n $.}\n\t\t\\iref{problem:double_counting_3}{ISL 2014 C1,}{Dissecting a Rectangle wrt to some given points inside.}\n\t\t\\iref{problem:double_counting_4}{Problem,}{$ 10 $ person bookstore problem.}\n\t\t\\iref{problem:double_counting_5}{USA TST 2005 P1,}{Subsets of the set $ \\{1, 2,\\dots, mn\\} $}\n\t\t\\iref{problem:double_counting_6}{USAMO 2012 P2,}{$ 4 $ colors on the circle, rotating.}\n\t\t\\iref{problem:double_counting_7}{ISL 2004 C1,}{A Cauchy type function based on a coloring of the integers.}\n\t\t\\iref{problem:double_counting_8}{China MO 2018 P2,}{$ 3n^2-3n+1+k $ points are red, $ k $ good boxes exist.}\n\t\t\\iref{problem:double_counting_9}{Problem}{}\n\t\t\\iref{problem:double_counting_10}{ISL 2003 C3}{}\n\n\t\\end{enumerate}\n\n\n\n\n\n\t\\faka\\subsubsection{Generating Function\\label{generating_function}}\n\n\tFor a sequence $ A = (a_0, a_1, a_2 \\dots) $, the generating function$ E_A(x) $ for this sequence is of several types types:\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\item $ E_A(x) = a_0x^0 + a_1x^1 \\dots + a_ix^i \\dots $, Useful for usual recursive sequences.\n\n\t\t\\item $ E_A(x) = x^{a_0} + x^{a_1} \\dots + x^{a_i} \\dots $, Useful for sum of any two elements from \\emph{any} two sequences.\n\n\t\t\\item $ E_A(x) = \\prod (1 + x^{a_i}) $, Useful for sum of multiple numbers from one sequence.\n\n\t\t\\item $ E_A(t, x) = \\prod (t + x^{a_i}) $, Useful for keeping track of how many numbers are being added to the sum.\n\n\t\\end{enumerate}\n\n\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:generating_function_1}{Problem,}{two sequence's pairwise sum's tuples are the same, $ n=2^k $.}\n\t\t\\iref{problem:generating_function_2}{Result by Erdos,}{Partitioning the integers into arithmetic sequences.}\n\t\t\\iref{problem:generating_function_3}{Problem on Catalan's Recursion}{}\n\t\\end{enumerate}\n\n\n\n\n\n\n\t\t\\faka\\paragraph{Roots of Unity}{These things can be used in a lot of places, like coloring boards, coloring (dividing into modular classes) the integers, using as variables in generating functions etc.}\\label{roots_of_unity}\n\n\n\t\t\\begin{multicols}{2}\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:roots_of_unity_1}{Result by Erdos}{}\n\t\t\t\\end{enumerate}\n\t\t\\end{multicols}\n\n\n\n\n\n\t\\newpage\\subsection{Different Representation}\n\n\tRepresent the problem or the problem objects differently, usually by binary strings, graphs or matrices.\n\n\n\n\n\t\t\\Faka\\subsubsection{Binary}\\label{binary}\n\n\t\tAssociate a binary string to elements, like for handling subsets, add a string to each element, representing if it is in a certain set or not.\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:binary_1}{IOI Practice 2017}{}\n\t\t\t\t\\iref{problem:binary_2}{ISL 1988 P10}{}\n\t\t\t\\end{enumerate}\n\n\n\n\n\t\t\\Faka\\subsubsection{Binary Query}\\label{binary_query}\n\n\t\tAsking questions of the kind: if in the binary expansion of $ k $ , if the $ i $ th bit is $ 0 $ , add $ k $ to one kind of query and if it is $ 1 $ , then add it to another.\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:binary_query_1}{CodeForces 744B}{}\n\t\t\t\t\\iref{problem:binary_query_2}{Problem}{}\n\t\t\t\\end{enumerate}\n\n\n\n\n\t\t\\Faka\\subsubsection{Matrix Creation}\\label{matrix_creation}\n\n\t\tWhen there is some sort of $ a\\times b $ always try to create a matrix.\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:matrix_creation_1}{IMO 2017 P5}{}\n\t\t\t\\end{enumerate}\n\n\n\n\n\t\t\\Faka\\subsubsection{Graph}\\label{graph_representation}\n\n\n\t\tProblems concerning sets and their relations, consider representing using graph, with some fixed mapping rules. Some times changing grid cells into vertices's also helps.\n\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:graph_representation_1}{USAMO 1986 P2}{}\n\t\t\t\t\\iref{problem:graph_representation_2}{Mexican Regional 2014 P6}{}\n\t\t\t\t\\iref{problem:graph_representation_3}{AoPS}{}\n\t\t\t\t\\iref{problem:graph_representation_4}{ARO 2013 P9.5}{}\n\t\t\t\t\\iref{problem:graph_representation_5}{ISL 2002 C6}{}\n\t\t\t\t\\iref{problem:graph_representation_6}{Problem,}{Mailman messes up}\n\t\t\t\t\\iref{problem:graph_representation_7}{timus 1862,}{Sum of operations}\n\t\t\t\t\\iref{problem:graph_representation_8}{ARO 2007 P9.7,}{Adding diagrams that cut even number of already drawn ones}\n\t\t\t\t\\iref{problem:graph_representation_9}{ISL 2002 C3}{Full-Sequences}\n\t\t\t\\end{enumerate}\n\n\n\t\t\\Faka\\subsubsection{Changing the Target Term}\n\n\t\tChanging the term you have to achieve to a slightly more intuitive one, usually thinking about what values you can get more naturally from the given conditions, and to build a similar term from the original term.\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:changing_term_1}{ARO 2014 P10.8,}{Mutually intersecting $ k $-gons, one point inside of a bunch of gons}{}\n\n\t\t\t\\end{enumerate}\n\n\n\n\n\n\n\n\n\t\\newpage\\subsection{Algorithms}\n\n\n\t\t\\Faka\\subsubsection{Greedy Algorithm}\\label{greedy_algorithm}\n\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:greedy_algorithm_1}{ISL 2014 N3,}{Cape Town Coin problem}\n\t\t\t\\iref{problem:greedy_algorithm_2}{China TST 2006}{}\n\t\t\t\\iref{problem:greedy_algorithm_3}{Timus 1578}{}\n\n\t\t\\end{enumerate}\n\n\n\n\n\n\t\t\\Faka\\subsubsection{Constructive Algorithm}\\label{constructive_algo}\n\n\n\t\tIn these kinda problems, you have to prove using a construction. In other words, proof by \\emph{Existence}. The key is to add one object to the solution set one at a time depending on already added objects in the set and maintaining the problem conditions. Sometimes by adding additional constraints or prioritizing already given constraints.\n\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:constructive_algo_1}{Bulgarian IMO TST 2004, D3P3}{}\n\t\t\t\\iref{problem:constructive_algo_2}{ARO 2018 10.3}{}\n\t\t\t\\iref{problem:constructive_algo_3}{CodeForces 960/C}{}\n\t\t\t\\iref{problem:constructive_algo_4}{ARO 2005 P10.3, P11.2}{}\n\t\t\t\\iref{problem:constructive_algo_5}{IOI 2007 P3}{}\n\t\t\t\\iref{problem:constructive_algo_6}{Problem}{}\n\t\t\t\\iref{problem:constructive_algo_7}{ARO 2018 P11.5}{}\n\t\t\t\\iref{problem:constructive_algo_8}{ARO 2013 P9.4}{}\n\t\t\t\\iref{problem:constructive_algo_9}{ARO 2014 P9.8}{}\n\t\t\t\\iref{problem:constructive_algo_10}{ISL 2016 C1}{}\n\t\t\t\\iref{problem:constructive_algo_11}{India IMO Camp 2017}{}\n\t\t\t\\iref{problem:constructive_algo_12}{ISL 2012 C2}{}\n\t\t\t\\iref{problem:constructive_algo_13}{CodeForces 989C}{}\n\t\t\t\\iref{problem:constructive_algo_14}{CodeForces 989B}{}\n\t\t\t\\iref{problem:constructive_algo_15}{ISL 2011 A5}{}\n\t\t\t\\iref{problem:constructive_algo_16}{Iran TST 2017 D1P1}{}\n\t\t\t\\iref{problem:constructive_algo_17}{ISL 2009 C2}{}\n\t\t\t\\iref{problem:constructive_algo_18}{Problem}{}\n\t\t\t\\iref{problem:constructive_algo_19}{Putnam 2017 A4}{}\n\t\t\t\\iref{problem:constructive_algo_20}{Serbia TST 2017 P4}{}\n\t\t\t\\iref{problem:constructive_algo_21}{ISL 2014 A1}{}\n\t\t\t\\iref{problem:constructive_algo_22}{ISL 2005 N2,}{sequence that contains all of the integers}\n\t\t\t\\iref{problem:constructive_algo_23}{Problem,}{switch states of a row and column}\n\t\t\t\\iref{problem:constructive_algo_24}{USAMO 2015 P4,}{piles of stone on cells, mone on the corners of a rectangle}\n\t\t\t\\iref{problem:constructive_algo_25}{ISL 2003 C4}{}\n\n\t\t\\end{enumerate}\n\n\n\n\t\t\\Faka\\subsubsection{Element : Time}\\label{add_time}\n\n\t\tAdding an element of Time to give the static problem a dynamic view. In less formal words, if a problem environments seems to just *exist*, add a dynamic way to slowly visualize the environment to exist. One kind of constructive algorithm, but this algo doesn't build the answer or solution, instead it builds up the whole environment step by step.\n\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:add_time_1}{ARO 2016 P3}{}\n\t\t\t\\iref{problem:add_time_2}{Brazilian Olympic Revenge 2014}{}\n\t\t\t\\iref{problem:add_time_3}{ISL 2008 C1}{}\n\t\t\t\\iref{problem:add_time_4}{USAMO 1999 P1}{}\n\t\t\t\\iref{problem:add_time_5}{AoPS}{}\n\n\t\t\\end{enumerate}\n\n\n\n\t\t\\newpage\\subsubsection{Gaming Tricks}\n\n\n\t\t\t\\paragraph{Pairing and Copying}\n\n\t\t\t{Who said you can't cheat in a combinatorial game? Just follow your opponents movements, and copy them cleverly.}\n\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:pairing_and_copying_1}{ARO 2011 P11.6,}{Take a number of stones off the heap of size $ n^2 $}\n\n\t\t\t\\end{enumerate}\n\n\n\t\t\t\\paragraph{Nim Equivalence}\n\n\n\n\n\n\t\\newpage\\subsection{Invariance Rules of Thumb}\\label{invariant_rules_of_thumb}\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\item Natural Sum\n\t\t\t\\item Alternating Sum\n\t\t\t\\item Sum of Squares\n\t\t\t\\item Product\n\n\t\t\t\\item Giving weight to each of the elements, in problems where usually no trivial invariants exists. Like weights of $ 2^i, \\frac{1}{i}, \\text{roots of unity} $ etc. depending on the problem's nature.\n\t\t\\end{enumerate}\n\n\t\\begin{itemize}\n\n\t\t\\iref{problem:invariant_rules_of_thumb_1}{ISL 2014 C2,}{$ 1 $ written on $ 2^m $ papers and and an addition operation}\n\t\t\\iref{problem:invariant_rules_of_thumb_2}{ISL 2012 C1,}{Operation almost alike to swapping and sorting}\n\t\t\\iref{problem:invariant_rules_of_thumb_3}{Indian TST 2004,}{Pebble makes a clone and moves up and right}\n\t\t\\iref{problem:invariant_rules_of_thumb_4}{ISL 1998 C7,}{One lamp on each cell, switching one lamp switches neighbors}\n\t\t\\iref{problem:invariant_rules_of_thumb_5}{APMO 2017 P1,}{$ a-b+c-d+e=29 $}\n\t\t\\iref{problem:invariant_rules_of_thumb_6}{AoPS}{}\n\t\t\\iref{problem:invariant_rules_of_thumb_7}{ARO 2016 P1}{}\n\t\t\\iref{problem:invariant_rules_of_thumb_8}{Serbia TST 2017 P2,}{$ (x+y) \\rightarrow (\\frac{x}{2}, y+\\frac{x}{2}) $ or $ (x+\\frac{y}{2}, \\frac{y}{2}) $}\n\t\t\\iref{problem:invariant_rules_of_thumb_9}{ISL 1994 C3,}{$ 3 $ bank accounts}\n\t\t\\iref{problem:invariant_rules_of_thumb_10}{Codeforces 987E}{}\n\t\t\\iref{problem:invariant_rules_of_thumb_11}{ISL 2007 C4,}{Dividing a sequence with almost equal sum, and getting another sequence from it.}\n\t\t\\iref{problem:invariant_rules_of_thumb_12}{USAMO 2015 P4,}{piles of stone on cells, mone on the corners of a rectangle}\n\n\t\\end{itemize}\n\n\n\n\t\\Faka\\subsubsection{Monotonicity with strict constraints\\label{monotonicity_with_constraints}}\n\n\tIf regular monotonicity doesn't apply, then some monotonicity with special properties might work. Like keeping the sum \\emph{even}, \\emph{odd}, \\emph{square} etc.\n\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:monotonicity_with_constraints_1}{USAMO 2013 P6,}{Replace $ x $ with the difference of the two neighboring numbers.}\n\t\t\\iref{problem:monotonicity_with_constraints_2}{MEMO 2008, Team, P6,}{$ a, b \\rightarrow a+b, a+b $}\n\n\t\\end{enumerate}\n\n\n\n\n\n\n\n\n\t\\newpage\\subsection{Pigeonhole Principal}\\label{php}\n\n\n\n\t\\Faka\\subsubsection{Alternating Chains Technique}{In a Cyclic graph with $ n $ nodes, if your task is to color some of the nodes so that no two neighboring nodes will be colored, you can color at most $ \\floor{\\frac{n}{2}} $. And in a path, this value is $ \\ceil{\\frac{n}{2}} $ }\\label{alternating_chains}\n\n\t\\begin{multicols}{3}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:alternating_chains_1}{ISL 1990 P3}{}\n\t\t\t\\iref{problem:alternating_chains_2}{USAMO 2008 P3}{}\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\n\n\n\n\n\n\n\n\t\\newpage\\subsection{Other Useful Techniques and Philosophies}\n\n\n\t\\Faka\\subsubsection{Include potentially important players in the game}{If the problem condition is completely or partially but crucially depended on some problem object, but the proof condition doesn't directly depend on that object, think of a way to include that object in the proof condition.}\\label{add_stuffs}\n\n\n\t\\begin{multicols}{3}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:add_stuffs_1}{APMO 2017 P3}{}\n\t\t\t\\iref{problem:add_stuffs_2}{USAMO 2008 P5}{}\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\t\\Faka\\subsubsection{Finding the Tough Nut}{Solving an easier version of the problem with some sort of constraints lose, to find out exactly what makes the problem so tough. This way we get valuable information about on what our main focus should be.}\\label{finding_the_tough_nut}\n\n\n\n\n\n\n\n\n\t\\Faka\\subsubsection{eChen trick}{Subtract a constant from all the numbers to make the sum $ 0 $. This makes the numbers easier to handle.}\\label{minus_constant}\n\n\t\\begin{multicols}{3}\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{problem:minus_constant_1}{APMO 2017 P1}{}\n\t\t\t\\iref{problem:minus_constant_2}{ARO 2013 P9.5}{}\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\n\n\n\n\n\n\n\t\\Faka\\subsubsection{Send objects to the infinity}{If there are too many arbitrary objects in the problem, try making some of them vanish by sending them to the infinity.}\n\n\n\n\n\n\n\n\n\t\\Faka\\subsubsection{n+1 = (n-i) + (i+1)}{ $ n+1 = (n-i) + (i+1) $ might prove to be useful when applying induction to $ \\binom{n}{k} $ }\n\n\n\n\n\n\n\t\\Faka\\subsubsection{Convex Hulls, and Sandwiching two points}{You know what convex hull is. AND, One can draw two lines to separate two points - draw two parallel lines very close to the two points.}\\label{sandwiching_points}\n\n\n\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\\iref{problem:sandwiching_points_1}{ISL 2013 C2}{}\n\t\t\\iref{problem:convex_hull_1}{Putnam 1979,}{$ n $ red $ n $ blue, pair them}\n\t\t\\iref{problem:convex_hull_3}{USAMO 2005 P5,}{$ n $ red $ n $ blue, at least two segments dividing them}\n\t\t\\iref{problem:convex_hull_2}{ILL 1985}{}\n\t\\end{enumerate}\n\n\n\n\n\n\\newpage\\section{Binomial Identities}\n\n\n\t\t\\theo{https://en.wikipedia.org/wiki/Vandermonde's_identity}{Vandermonde's identity}{\\[ \\binom{m+n}{k} = \\sum_{i=0}^{k} \\binom{m}{i}\\binom{n}{k-i} \\]}\n\n\n\t\t\\theo{}{}{\\[\\binom{2n}{n} = \\binom{p}{0}^2 \\binom{p}{1}^2 \\dots + \\binom{p}{p}^2 \\]}\n\\newpage\\section{Sets}\n\n\t\\subsection{Lemmas}\n\n\n\t\t\\lem{Let $ S $ be a set with $ n $ elements, and let $ F $ be a family of subsets of S such that for any pair $ A, B $ in $ F $, $ A \\cap B \\not= \\varnothing $. Then $ |F| \\leq 2^{n-1} $ .}\\label{lemma:sets_lemma_1}\n\n\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\\iref{lemma:sets_lemma_1_1}{Iran TST 2008 D3P1}{}\n\t\t\\end{enumerate}\n\n\n\n\n\t\t\\lem{Let $ S $ be a set with $ n $ elements, and let $ F $ be a family of subsets of $ S $ such that for any pair $ A, B $ in $ F $, $ S $ is not contained by $ A \\cup B $. Then $ |F| \\leq 2^{n-1} $.}\\label{lemma:sets_lemma_2}\n\n\n\n\t\t\\lem{\\hl{Kleitman’s lemma} A set family $F$ is said to be downwards closed if the following holds: if $X$ is a set in $F$, then all subsets of $X$ are also sets in $F$. Similarly, $F$ is said to be upwards closed if whenever $X$ is a set in $F$, all sets containing $X$ are also sets in $F$. Let $F_1$ and $F_2 $be downwards closed families of subsets of $S = \\{1, 2, ..., n\\}$, and let $F_3$ be an upwards closed family of subsets of $S$. Then we have\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\item \\[ |F_1 \\cap F_2| \\geq \\frac{|F_1| \\cdot |F_2|}{2^n} \\]\n\t\t\t\t\\item \\[ |F_1 \\cap F_3| \\leq \\frac{|F_1| \\cdot |F_3|}{2^n} \\]\n\t\t\\end{enumerate}}\\label{lemma:sets_lemma_3_Kleitman}\n\n\n\n\n\t\t\\lem{Let $ S $ be a set with $ n $ elements, and let $ F $ be a family of subsets of $ S $ such that for any pair $ A, B $ in $ F $, $ A \\cap B \\not= \\varnothing $ and $ A \\cap B \\not= S $. Then $ |F| \\leq 2^{n-2} $.}\\label{lemma:sets_lemma_4}\n\n\t\t\\solu{Using the sets in \\hrf{lemma:sets_lemma_1}{lemma 1} and \\hrf{lemma:sets_lemma_1}{lemma 2}, defining upwards and downwards sets like in \\hrf{lemma:sets_lemma_3_Kleitman}{Kleitman's Lemma}.}\n\n\n\n\t\t\\lem{\\href{https://en.wikipedia.org/wiki/Sunflower_(mathematics)}{\\textbf{The Sunflower Lemma:}} A sunflower with $ k $ petals and a core $ X $ is a family of sets $ S_1, S_2,\\dots, S_k $ such that $ S_i\\cap S_j = X $ for each $ i \\neq j $. (The reason for the name is that the Venn diagram representation for such a family resembles a sunflower.) The sets $ S_i \\setminus X $ are known as petals and must be nonempty, though $ X $ can be empty. Show that if $ F $ is a family of sets of cardinality $ s $, and $ |F| > s!(k-1)^s $, then $ F $ contains a sunflower with $ k $ petals.}\\label{problem:induction_type1_20}\\label{problem:extreme_object_10}\n\n\n\t\t\\solu{Applying induction and considering the best case where $ |X|=0 $}\n\n\n\t\\newpage\\subsection{Extremal Set Theory}\n\n\t\t\\href{http://math.mit.edu/~cb_lee/18.318/lecture8.pdf}{MIT 18.314 Lecture-8}\n\n\n\t\t\\theo{}{Mirsky Theorem}{A set $ S $ with a chain of height $ h $ can’t be partitioned into $ t $ anti-chains if $ t < h $. In other words, the minimum number of sets in any anti-chain partition of $ S $ is equal to the maximum height of the chains in $ S $. (And Vice Versa)}\\label{theorem:mirsky_theorem}\n\n\n\t\t\\theo{}{}{In any poset, the largest cardinality of an antichain is at most the smallest cardinality of a chain-decomposition of that poset.}\n\n\n\t\t\\theo{}{Dilworth's Theorem}{Let $ P $ be a poset. Then there exist an antichain $ A $ and a chain decomposition $ \\mathcal{C} $ of $ P $ such that $ |A| = |\\mathcal{C}| $}\n\n\n\n\t\t\\theo{http://mathworld.wolfram.com/Erdos-SzekeresTheorem.html}{Erdos-Szekeres Theorem}{Any sequence of $ ab+1 $ real numbers contains either a monotonically decreasing subsequence of length $ a+1 $ or a monotonically increasing subsequence of length $ b+1 $. The more useful case is when $ a=b=n $. }\n\n\n\n\n\n\n\n\t\\newpage\\subsection{Problems}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h148835p841269}{USA TST 2005 P1}{E}{Let $ n $ be an integer greater than $ 1 $. For a positive integer $ m $ , let $ S_{m}= \\{ 1,2,\\ldots, mn\\} $. Suppose that there exists a $ 2n $ -element set $ T $ such that\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\n\t\t\t\t\\item each element of $ T $ is an $ m $ -element subset of $ S_{m} $\n\t\t\t\t\\item each pair of elements of $ T $ shares at most one common element\n\t\t\t\t\\item each element of $ S_{m} $ is contained in exactly two elements of $ T $\n\n\t\t\t\\end{enumerate}\n\n\t\t\tDetermine the maximum possible value of $ m $ in terms of $ n $.}\\label{problem:double_counting_5}\n\n\t\t\\solu{We use double counting to find the ans, after that the rest is easy.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h206650p1136980}{Iran TST 2008 D3P1}{E}{Let $S$ be a set with $n$ elements, and $F$ be a family of subsets of $S$ with $ 2^{n-1}$ elements, such that for each $A,B,C\\in F$, $A\\cap B\\cap C$ is not empty. Prove that the intersection of all of the elements of $F$ is not empty.}\\label{lemma:sets_lemma_1_1}\\label{problem:induction_type1_18}\n\n\t\t\\solu{Using Induction with \\hrf{lemma:sets_lemma_1}{this} lemma.}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6t309f6h1538018}{Romanian TST 2016 D1P2}{EM}{Let $n$ be a positive integer, and let $S_1, S_2,\\dots S_n$ be a collection of finite non-empty sets such that $$\\sum_{1\\leq i<j\\leq n}{\\frac{|S_i \\cap S_j|}{|S_i||S_j|}} <1.$$Prove that there exist pairwise distinct elements $x_1, x_2\\dots x_n$ such that $x_i$ is a member of $S_i$ for each index $i$.}\\label{problem:induction_type1_25}\\label{problem:forget_and_focus_7}\n\n\n\t\t\\solu{The Inductive proof reduces the problem to \\hrf{problem:induction_type1_26}{this} problem.}\n\n\t\t\\solu{The other approach is to focus on the given weird condition, and interpolate it to something nice, like probabilistic condition.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h225275p1252232}{American Mathematical Monthly problem E2309}{EM}{If $ A_1$, $ A_2$,\\dots $ A_n$ are $ n$ nonempty subsets of the set $ \\left\\{1,2,...,n - 1\\right\\}$, then prove that\n\n\t\t\t$ \\sum_{1\\leq i < j\\leq n}\\frac {\\left|A_i\\cap A_j\\right|}{\\left|A_i\\right|\\cdot\\left|A_j\\right|}\\geq 1$.}\\label{problem:induction_type1_26}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h362426p1986928}{CGMO 2010 P1}{E}{Let $n$ be an integer greater than two, and let $A_1,A_2, \\cdots , A_{2n}$ be pairwise distinct subsets of $\\{1, 2, ,n\\}$. Determine the maximum value of\n\t\t\t\\[\\sum_{i=1}^{2n} \\dfrac{|A_i \\cap A_{i+1}|}{|A_i| \\cdot |A_{i+1}|}\\]\n\t\t\tWhere $A_{2n+1}=A_1$ and $|X|$ denote the number of elements in $X.$}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17340p119108}{ISL 2002 C5}{M}{Let $r\\geq2$ be a fixed positive integer, and let $F$ be an infinite family of sets, each of size $r$, no two of which are disjoint. Prove that there exists a set of size $r-1$ that meets each set in $F$.}\\label{problem:induction_type1_31}\n\n\n\t\t\\gene{https://artofproblemsolving.com/community/c6h17340p7934669}{HMMT 2016 Team Round}{Fix positive integers $r>s$, and let $\\mathcal F$ be an infinite family of sets, each of size $r$, no two of which share fewer than $s$ elements. Prove that there exists a set of size $r-1$ that shares at least $s$ elements with each set in $F$.}\n\n\n\t\t\t\\solu{First idea, if we take an arbitrary set, we can say that there exists infinitely many sets $ \\in \\mathbb{F} $ which includes a fixed element from our test set. If we do this argument for $ r-1 $ times, we get a set $ X $ of $ r-1 $ elements, and an infinte family of sets that contains $ X $ completely. At this point the problem is trivial.}\n\n\n\t\t\t\\solu{Since it's tricky to work with one family, why not introduce another family, like the second monk. \\hrf{http://artofproblemsolving.com/community/c6h17340p3251745}{This} solution generalizes the problem as such.}\n\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h57290p352698}{ISL 1988 P10}{M}{Let $ N = \\{1,2 \\ldots, n\\}, n \\geq 2. $ A collection $ F = \\{A_1, \\ldots, A_t\\} $ of subsets $ A_i \\subseteq N, $  $ i = 1, \\ldots, t, $ is said to be separating, if for every pair $ \\{x,y\\} \\subseteq N, $ there is a set $ A_i \\in F $ so that $ A_i \\cap \\{x,y\\} $ contains just one element. $ F $ is said to be covering, if every element of $ N $ is contained in at least one set $ A_i \\in F. $ What is the smallest value $ f(n) $ of $ t, $ so there is a set $ F = \\{A_1, \\ldots, A_t\\} $ which is simultaneously separating and covering} \\label{problem:binary_2}\n\t\t\n\t\t\n\t\t\t\\solu{Using \\hrf{binary}{Binary} Representations for the elements as in or not in, we get an easy bijection.}\n\t\t\n\t\t\n\n\n\n\\newpage\\section{Algorithmic}\n\\newpage\\section{Graph Theory}\n\n\n\n\t\\subsection{Lemmas}\n\n\n\t\t\\lem{\\hl{\\textbf{Average of Degrees:}} In a graph $ G $ with $ n $ vertexes, let $ E $ be the set of all edges. Assign an integer $ f_i $ to every vertex $ v_i $ such that $ f_i $ equals to the everage degree of the neighbors of $ v_i $. We have, \\[ \\sum_{i=1}^{n} f_i \\geq 2\\vert E\\vert \\] }\\label{lemma:graph_lemma_1}\n\n\n\n\t\t\\lem{\\hl{\\textbf{Bipartite Graph Criteria:}} Any graph having only even cycles are BIPARTITE.}\\label{lemma:bipartite_graph}\n\n\n\t\t\\begin{multicols}{3}\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:bipartite_graph_1}{AoPS}{}\n\t\t\t\t\\iref{problem:bipartite_graph_2}{ISL 2004 C3}{}\n\t\t\t\t\\iref{problem:bipartite_graph_3}{Problem}{}\n\t\t\t\t\\iref{problem:bipartite_graph_4}{Problem}{}\n\t\t\t\\end{enumerate}\n\t\t\\end{multicols}\n\n\n\t\t\\lem{\\hl{\\textbf{Euler's Theorem on Planar Graphs:\\label{theorem:planar_graph_theorem}}} In a planar graph with $ V $ vertices, $ E $ edges and $ C $ cycles, the following condition is always satisfied: \\[V-E+C=1\\]}\n\n\n\t\t\\theo{http://www.ams.org/samplings/feature-column/fcarc-eulers-formula}{Euler's Polyhedron Formula\\label{lemma:planar_graph_polyhedron}}{For any polyhedron with $ E, V, F $ edges, vertices's and faces resp. the following relation holds \\[V+F=E+2\\]}\n\n\n\n\n\n\t\t\\theo{https://en.wikipedia.org/wiki/Prüfer_sequence}{Prüfer sequence}{Consider a labeled tree $ T $ with vertices's $ \\{1, 2, ..., n\\} $. At step $ i $, remove the leaf with the smallest label and set the $ i $th element of the \\textit{Prüfer sequence} to be the label of this leaf's neighbour. Prove that a Prüfer sequence of length $ n-2 $ defines a Tree with length $ n $. In other words, proof Prüfer bjection, and give an algorithm to build the tree from the Prüfer sequence.\n\n\t\t\t\\fig{.5}{prufer_code_example}{A labeled tree with Prüfer sequence $ {4,4,4,5} $.}\n\t\t}\n\n\n\t\t\\den{\\texttt{Cut:} A cut is a partition of the vertices of a graph into two disjoint subsets. Any cut determines a cut-set, the set of edges that have one endpoint in each subset of the partition. These edges are said to cross the cut. In a connected graph, each cut-set determines a unique cut, and in some cases cuts are identified with their cut-sets rather than with their vertex partitions.}\\label{definition:cut_graph_theory}\n\n\n\n\n\n\t\\newpage\\subsection{Problems}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h589936p3493453}{ARO 2014 P9.8\\label{tickets}}{H}{In a country of $ n $ cities, an express train runs both ways between any two cities. For any train, ticket prices either direction are equal, but for any different routes these prices are different. Prove that the traveler can select the starting city, leave it and go on, successively, $ n-1 $ trains, such that each fare is smaller than that of the previous fare. (A traveler can enter the same city several times.)}\n\n\n\n\t\t\\prob{}{}{E}{Given a bipartite graph, prove that the minimum number of colors required to color the edges of the graph such that no node is adjacent to $ 2 $ edges of same color is the maximum degree of the graph.}\\label{problem:bipartite_graph_3}\n\n\n\t\t\\prob{}{}{E}{For every bipartite graph prove that it's edges can be bicolored so that each node is adjacent to atmost $ \\ceil{\\frac{deg}{2}} $ edges of  any color.}\\label{problem:bipartite_graph_4}\n\n\n\t\t\t\\solu{Using the main property of a bipartite graph.}\n\n\n\t\t\t\\solu{After finding the cycle solution, to optimize it, we recall that we can find a Eulerian Path (if it exists) in $ O(V+E) $. Now we want to make the graph have a Eulerian path, so we add a vertice to both sides of the graph, and join them with odd vertices from the other side.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h364267}{Generalization}{\\hrf{tickets}{H}}{Let $ A $ be a set of $ n $ points in the space. From the family of all segments with endpoints in $ A $ , $ q $ segments have been selected and colored yellow. Suppose that all yellow segments are of different length. Prove that there exists a polygonal line composed of $ m $ yellow segments, where $ m\\geq\\frac{2q}{n} $ , arranged in order of increasing length.}\\label{problem:constructive_algo_9}\\label{problem:swapping_4}\n\n\t\t\t\\solu{Make one person go to every node. Then let the two people on the two sides of the most expensive edge swap their position. This ensures that every edge was used exactly 2 times. Using PHP, we have the desired result. Another solution is by \\hrf{theorem:mirsky_theorem}{this}}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h100733p568964}{ISL 2005 C1}{E}{A house has an even number of lamps distributed among its rooms in such a way that there are at least three lamps in every room. Each lamp shares a switch with exactly one other lamp, not necessarily from the same room. Each change in the switch shared by two lamps changes their states simultaneously. Prove that for every initial state of the lamps there exists a sequence of changes in some of the switches at the end of which each room contains lamps which are on as well as lamps which are off.}\\label{problem:divide_and_conquer_4}\\label{problem:induction_type1_10}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h597130p3543398}{ISL 2013 C3\\label{problem:induction_type1_9}}{M}{A crazy physicist discovered a new kind of particle which he called an $ i $ -mon, after some of them mysteriously appeared in his lab. Some pairs of $ i $ -mons in the lab can be entangled, and each $ i $ -mon can participate in many entanglement relations. The physicist has found a way to perform the following two kinds of operations with these particles, one operation at a time.\n\n\t\t\\begin{enumerate}\n\n\n\t\t\t\\item If some $ i $ -mon is entangled with an odd number of other $ i $ -mons in the lab, then the physicist can destroy it.\n\n\t\t\t\\item At any moment, he may double the whole family of $ i $ -mons in the lab by creating a copy $ I' $ of each $ i $ -mon $ I $. During this procedure, the two copies $ I' $ and $ J' $ become entangled if and only if the original $ i $ -mons $ I $ and $ J $ are entangled, and each copy $ I' $ becomes entangled with its original $ i $ -mon $ I $ ; no other entanglements occur or disappear at this moment.\n\n\t\t\\end{enumerate}}\n\n\n\t\t\t\\solu{Prove that the physicist may apply a sequence of much operations resulting in a family of $ i $ -mons, no two of which are entangled.\n\n\t\t\tAs there are an integer number of $ i $ -mons, it is quite natural to use induction. We try to find an algorithm to reduce the number of particles.\n\n\t\t\tAnother way to do this is to consider the chromatic number of the graph. If we can show that this number reduces after some move, then we are done by induction.}\n\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h104152p586762}{ISL 2005 C2\\label{problem:induction_type1_8}}{E}{A forest consists of rooted (i. e. oriented) trees. Each vertex of the forest is either a leaf or has two successors. A vertex $ v $ is called an extended successor of a vertex $ u $ if there is a chain of vertices's $ u_{0}=u , u_{1}, u_{2} \\dots u_{t-1} , u_{t}=v $ with $ t>0 $ such that the vertex $ u_{i+1} $ is a successor of the vertex $ u_{i} $ for every integer $ i $ with $ 0\\leq i\\leq t-1 $.\\\\\n\n\t\tLet $ k $ be a nonnegative integer. A vertex is called dynastic if it has two successors and each of these successors has at least $ k $ extended successors.\\\\\n\n\t\tProve that if the forest has $ n $ vertices, then there are at most $ \\frac{n}{k+2} $ dynastic vertices.}\n\n\t\t\t\\solu{Trying to apply induction, we realize the bound is very loosy. That's why when we try to add in the inductive step, the value becomes larger the the bound. To negate that overflow, we tighten the bound.}\n\n\t\t\t\\solu{The second and dummy approach is to first doing some smaller cases, finding small infos, taking the root, seeing that the bound doesnt work, but it would work if one of the successors of the root would have exactly or less than $ 2k+3 $ successors. As we can't always guarantee that, we look for such a vertex with $ 2k+3 $ successors. We do some work with it and by induction its done.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1441121p8200413}{All Russia 2017 9.1\\label{problem:induction_type1_17}}{E}{In a country some cities are connected by oneway flights (There are no more then one flight between two cities). City $ A $ called \"available\" for city $ B $ , if there is flight from $ B $ to $ A $ , maybe with some transfers. It is known, that for every 2 cities $ P $ and $ Q $ exist city $ R $ , such that $ P $ and $ Q $ are available from $ R $. Prove, that exist city $ A $ , such that every city is available for $ A $.}\n\n\n\n\t\t\\prob{www.google.com}{Jacob Tsimerman Induction}{E}{There are $ 2010 $ ninjas in the village of Konoha (what? Ninjas are cool.) Certain ninjas are friends, but it is known that there do not exist $ 3 $ ninjas such that they are all pairwise friends. Find the maximum possible number of pairs of friends.(If ninja $ A $ is friends with ninja $ B $ , then ninja $ B $ is also friends with ninja $ A $.)}\\label{problem:induction_type1_16}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c5h1434584p8117190}{USAMO 2017 P4}{M}{Let $ P_1 $ , $ P_2 $ , $ \\dots $ , $ P_{2n} $ be $ 2n $ distinct points on the unit circle $ x^2+y^2=1 $ , other than $ (1,0) $. Each point is colored either red or blue, with exactly $ n $ red points and $ n $ blue points. Let $ R_1 $ , $ R_2 $ , $ \\dots $ , $ R_n $ be any ordering of the red points. Let $ B_1 $ be the nearest blue point to $ R_1 $ traveling counterclockwise around the circle starting from $ R_1 $. Then let $ B_2 $ be the nearest of the remaining blue points to $ R_2 $ travelling counterclockwise around the circle from $ R_2 $ , and so on, until we have labeled all of the blue points $ B_1, \\dots, B_n $. Show that the number of counterclockwise arcs of the form $ R_i \\to B_i $ that contain the point $ (1,0) $ is independent of the way we chose the ordering $ R_1, \\dots, R_n $ of the red points.}\\label{problem:induction_type1_15}\n\n\t\t\t\\solu{As the ques is saying that the condition is true for every positive integer $ n $ , can't we try induction? Which part of the condition makes the problem challenging? Obviously the circle condition and the $ (1, 0) $ point. So Lets remove a ``problematic'' pair $ R_t, B_t $. We encounter some problems, but we can pull it out of there.}\n\n\n\n\n\t\t\\prob{www.hehe.com}{Swell coloring}{E}{Let $ K_n $ denote the complete graph on $ n $ vertices, that is, the graph with $ n $ vertices's such that every pair of vertices's is connected by an edge. A swell coloring of $ K_n $ is an assignment of a color to each of the edges such that the edges of any triangle are either all of distinct colors or all the same color. Further, more than one color must be used in total (otherwise trivially if all edges are the same color we would have a swell coloring). Show that if $ K_n $ can be swell colored with $ k $ colors, then $ k \\geq \\sqrt{n} + 1 $.}\\label{problem:forget_and_focus_5}\n\n\t\t\t\\solu{Concentrate on only one vertex.}\n\n\n\n\t\t\\prob{www.hehe.com}{Belarus 2001}{MH}{Given $ n $ people, any two are either friends or enemies, and friendship and enmity are mutual. I want to distribute hats to\tthem, in such a way that any two friends possess a hat of the same color but no two enemies possess a hat of the same color. Each person can receive multiple hats. What is the minimum number of colors required to always guarantee that I can do this?}\\label{problem:extremal_case_whole_6}\n\n\t\t\t\\solu{In this problem, finding the worst case is a big help, because once the answer is guessed, the things become really clear.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h420430p2374818}{USA TST 2011 D3P2}{M}{Let $n \\geq 1$ be an integer, and let $S$ be a set of integer pairs $(a,b)$ with $1 \\leq a < b \\leq 2^n$. Assume $|S| > n \\cdot 2^{n+1}$. Prove that there exists four integers $a < b < c < d$ such that $S$ contains all three pairs $(a,c)$, $(b,d)$ and $(a,d)$.}\\label{problem:induction_type1_19}\n\n\t\t\t\\solu{Using Induction to the first and last half of the set $ S $ shows us the \\hrf{finding_the_tough_nut}{hardest part} of the problem. Then ordering the left and right elements with some sort of hierarchy is all the work left to do.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1480703p8639274}{ISL 2016 C6}{H}{There are $ n \\geq 3 $ islands in a city. Initially, the ferry company offers some routes between some pairs of islands so that it is impossible to divide the islands into two groups such that no two islands in different groups are connected by a ferry route.\\\\\n\n\t\tAfter each year, the ferry company will close a ferry route between some two islands $ X $ and $ Y $. At the same time, in order to maintain its service, the company will open new routes according to the following rule: for any island which is connected to a ferry route to exactly one of $ X $ and $ Y $ , a new route between this island and the other of $ X $ and $ Y $ is added.\\\\\n\n\t\tSuppose at any moment, if we partition all islands into two nonempty groups in any way, then it is known that the ferry company will close a certain route connecting two islands from the two groups after some years. Prove that after some years there will be an island which is connected to all other islands by ferry routes.}\\label{problem:induction_type1_11}\n\n\t\t\t\\solu{It is only natural to use induction on this kinda problems. After some trying, we see that if we remove $ 1 $ node, We get to nowhere, but if we remove $ 2 $ nodes, we get something interesting. So now focus on those two nodes and the rest of the nodes separately. Its not hard from there.}\n\n\t\t\t\\solu{As it seems, the separation of the graph was the main observation. We can call this trick \\hl{Bringing Order in the Chaos}.}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1468154p8509521}{ELMO 2017 P5}{H}{The edges of $ K_{2017} $ are each labeled with $ 1, 2 $ or $ 3 $ such that any triangle has sum of labels at least $ 5. $ Determine the minimum possible average of all labels. (Here $ K_{2017} $ is defined as the complete graph on 2017 vertices's, with an edge between every pair of vertices's.)}\\label{problem:induction_type1_13}\n\n\t\t\t\\solu{First solution is by Induction. Firstly we see that keeping all three kind of edges is sooo much work to do. What we can do is to simplify this to graph having only $ \\lbrace 1, 2\\rbrace $ or $ \\lbrace 1, 3\\rbrace $ types of edges. We actually see this works. Now we can Pick one $ 2 $ (or $ 3 $ ) edge and delete it. We get a nice recursive relation. Bam.}\n\n\n\t\t\t\\solu{This solution is for elegancy which uses a nyc lemma:\\\\\n\n\n\t\t\tUsing \\hrf{lemma:graph_lemma_1}{this lemma} in our problem and considering the graph with all vertexes and all edges labeled $ 1 $ first and then considering the $ 3 $ label degree of each vertex we deduce that there must be at most $ 1008 $  $ 1 $ labeled edges more than $ 3 $ labeled edges in $ K_{2017} $.\\\\\n\n\t\t\tWe get the intuition of this by noticing that in a vertex $ v $ , if the number of $ 3 $ labeled edges connected to it is $ d_3 $ , the maximum $ 1 $ degree of the vertexes that are connected to $ v $ with a $ 1 $ labeled edge edge is $ m_1 $ , then $ d_3\\geq m_1-1 $. (This is pure intuition)\\\\\n\n\t\t\tAs our maximum is achieved when we take the minimum number of $ 3 $ labeled edges. So we take $ E_1 $  $ 1 $ labeled edges, $ E_1  – 1008 $  $ 3 $ labeled edges and the rest $ 2 $ labeled edges. We get our desired minimum average.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h535003p3067563}{ARO 2013 P9.5}{M}{ $ 2n $ real numbers with a positive sum are aligned in a circle. For each of the numbers, we can see there are two sets of $ n $ numbers such that this number is on the end. Prove that at least one of the numbers has a positive sum for both of these two sets.}\\label{problem:graph_representation_4}\\label{problem:minus_constant_2}\n\n\t\t\t\\solu{Then make a set with the sum of all $ n $ consecutive blocks of numbers. Then its only natural to use graph representation. And $ Ta-Da $.}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h420424p2374799}{USA TST 2011 P2}{H}{In the nation of Onewaynia, certain pairs of cities are connected by roads. Every road connects exactly two cities (roads are allowed to cross each other, e.g., via bridges). Some roads have a traffic capacity of 1 unit and other roads have a traffic capacity of $ 2 $ units. However, on every road, traffic is only allowed to travel in one direction. It is known that for every city, the sum of the capacities of the roads connected to it is always odd. The transportation minister needs to assign a direction to every road. Prove that he can do it in such a way that for every city, the difference between the sum of the capacities of roads entering the city and the sum of the capacities of roads leaving the city is always exactly one.}\\label{problem:divide_and_conquer_1}\\label{problem:induction_type2_3}\n\t\t\n\t\t\t\\solu{As there are two types of subgraph, $ 1 $ -type and $ 2 $ -type. By some work-arounds, we see that we have to work distinctly in both types of graphs. Firstly, if we work in type- $ 1 $ , we see after making a path from node $ x, y $ , the degrees of $ x, y $ will be $ \\{1, -1\\} $ and the degrees of other nodes on the path will be the same. After that, we make every nodes have degree either $ \\{1, -1\\} $. So after this operation we remove the $ 1 $ -edges. Now, when dealing with the type- $ 2 $ sub-graph. Start over from zero, we see that when making a path between nodes $ x, y $ the degree of those two changes parity, and other nodes on the path stays the same. So select two odd nodes.... }\n\t\t\t\n\t\t\t\\solu{Dealing with two different kind of edges simultaneously is messy, so we work with graph $ 1 $ and graph $ 2 $ differently. Now on both graphs, we can remove cycles. And in graph $ 2 $ , we see that we can remove any big paths if there is a edge $ 1 $ joining the two endpoints. Since if the new graph works then the previous graph works too. [Several cases to show here] And if there is no edge joining the two endpoints, replace the path by joining the two endpoints by a edge $ 2 $.\\\\\n\t\t\t\t\n\t\t\tNow there are only edge $ 1 $ s, and lone edge $ 2 $ s. Now dividing the graph $ 1 $ into paths of edge $ 1 $ , and dealing with several small cases, we are done.}\n\t\t\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h276187p1494557}{Iran TST 2009 P6}{E-M}{We have a closed path that goes from one vertex to another neighboring vertex, on the vertices of a $ n\\times n$ square which pass throgugh each vertex exactly once. Prove that we have two adjacent vertices such that if we cut the path at these two points then the length of each open paths is at least $ \\dfrac{n^2}{4} $.}\n\t\t\n\t\t\t\\solu{Draw a path, isn't it a unit square tiled path? Now can we relate the area of the tiled path with its perimeter? If we could do that, we would be able to replace two neighboring vertices by an edge inside the path, which seems to make the problem simpler.}\n\t\t\t\n\t\t\n\t\t\\prob{https://math.stackexchange.com/questions/1439430/algorithm-to-uniquely-determine-a-number-using-two-adjacent-digits}{OC Chap2 P2}{M}{Arutyun and Amayak perform a magic trick as follows. A spectator writes down on a board a sequence of $ N $ (decimal) digits. Amayak covers two adjacent digits by a black disc. Then Arutyun comes and says both closed digits (and their order). For which minimal $ N $ can this trick always work? NOTE: Arutyun and Amayak have a strategy determined beforehand.}\\label{problem:bijection_2}\\label{problem:hall_marriage_1}\n\t\t\n\t\t\t\\solu{We have to actually find a bijection between all of the combinations the spectator can create, and all of the combinations that Arutyun might see when he comes back. Which tells us to use ``Perfect Matching\" tricks.}\n\t\t\t\n\t\t\t\\solu{Existential proof: for this trick to always work, they have to make a bijection from a set of $ N $ digits with two covered, to an unique set of $ N $ digits. Consider a bijection from the set of $ 0-9 $ strings with length $ N $ to the set of $ 0-9 $ strings with length $ N $ with $ 2 $ adjacent digits unknown. There exist a bijection iff the two sets satisfy Hall's Marriage Theorem. By double counting we get the value of $ N $ from here.}\n\t\t\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h35320p220234}{ARO 2005 P9.4}{M}{ $ 100 $ people from $ 50 $ countries, two from each countries, stay on a circle. Prove that one may partition them onto $ 2 $ groups in such way that neither no two countrymen, nor three consecutive people on a circle, are in the same group.\\\\\n\t\t\t\n\t\t\t\\textbf{Variant:} There are $ 100 $ people from $ 25 $ countries sitting around a circular table. Prove that they can be separated into four classes, so that no two countrymen are in the same class, nor any two people sitting adjacent in the circle.}\\label{problem:hall_marriage_2}\n\t\t\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h514376p2889829}{ARO 1999 P10.1}{E}{There are three empty jugs on a table. Winnie the pooh, Rabbit, and Piglet put walnuts in the jugs one by one. They play successively, with the initial determined by a draw. Thereby Winnie the pooh plays either in the first or second jug, Rabbit in the second or third, and Piglet in the first or third. The player after whose move there are exactly 1999 walnuts loses the games. Show that Winnie the pooh and Piglet can cooperate so as to make Rabbit lose.}\n\t\t\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h5393p17438}{USAMO 2004, P4}{E}{Alice and Bob play a game on a $ 6 $ by $ 6 $ grid. On his or her turn, a player chooses a rational number not yet appearing in the grid and writes it in an empty square of the grid. Alice goes first and then the players alternate. When all squares have numbers written in them, in each row, the square with the greatest number in that row is colored black. Alice wins if she can then draw a line from the top of the grid to the bottom of the grid that stays in black squares, and Bob wins if she can't. (If two squares share a vertex, Alice can draw a line from one to the other that stays in those two squares.) Find, with proof, a winning strategy for one of the players.}\n\t\t\t\n\\newpage\\section{Game Theory}\n\n\\subsection{Games}\n\n\n\t\\den{\\href{file:///home/ahsan/pDB/main/combi/Game Theory/3.htm}{Nimbers:} Nimbers are simply `Nim values' which are assigned to a game configuration - these values are written as $ 0, *1, *2, *3 \\dots $ We shall first describe how to obtain the Nim values for the game Squaring the Number. First, the Nim value of $ n=0 $ is assigned $ 0 $, since it is a state in which neither player has a valid move. We then recursively adopt the following rule for each $ n $ : \\texttt{find all the possible moves from $ n $ and pick the smallest Nim value which does not occur among all these possible moves}.}\n\n\n\t\\theo{file:///home/ahsan/pDB/main/combi/Game Theory/3.htm}{Sprague-Grund Theorem}{The \\emph{Sprague–Grundy theorem} states that every impartial game under the normal play convention is equivalent to a nimber.}\n\n\n\n\t\\khela{https://en.wikipedia.org/wiki/Chip-firing_game}{Chip Firing Game}{Let $ G=(V, E) $ be a graph without any loops or multiedges. Let a number of $ s_i $ chips be stacked on vertex $ i $. The game follows with the player choosing a vertex $ i $, taking $ d_i $ chips from it ($ s_i-d_i > 0 $), and sending one chip to each of the neighbors of the vertex where $ d_i $ is the degree of $ i $. The Problem of this game is to determine when the game will be infinte.\\\\\n\n\t\t\\begin{itemize}\n\t\t\t\\item If $ N $ is the total number of edges in $ G $, and $ S $ is the total number of chips, then\n\t\\end{itemize}}\n\n\n\n\t\\khela{}{Cutting a stack in half}{Given a number of stacks, at his/her move, a player can choose a stack with even number stones, and divide it in two stacks with the same number of stones.}\n\n\n\t\\khela{}{Cutting a stack in several}{Given a number of stacks, at his/her move, a player can choose a stack, and divide it in several stacks with the same number of stones.}\n\n\n\n\n\n\n\\newpage\\subsection{Problems}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c5h202910p1116189}{USAMO 2008 P5}{M}{Three non-negative real numbers $ r_1 $ , $ r_2 $ , $ r_3 $ are written on a blackboard. These numbers have the property that there exist integers $ a_1 $ , $ a_2 $ , $ a_3 $ , not all zero, satisfying $ a_1r_1 + a_2r_2 + a_3r_3 = 0 $. We are permitted to perform the following operation: find two numbers $ x $ , $ y $ on the blackboard with $ x \\le y $ , then erase $ y $ and write $ y - x $ in its place. Prove that after a finite number of such operations, we can end up with at least one $ 0 $ on the blackboard.}\\label{problem:add_stuffs_2}\n\n\t\t\\solu{When can't get info out of the reals, try the integers. Observe the integers, and check if they have any invariant. Rule of thumb of finding an invariant.}\n\n\n\n\t\\prob{www.hehe.com}{USAMO 2014 P1}{E}{Let $ k $ be a positive integer. Two players $ A $ and $ B $ play a game on an infinite grid of regular hexagons. Initially all the grid cells are empty. Then the players alternately take turns with $ A $ moving first. In his move, $ A $ may choose two adjacent hexagons in the grid which are empty and place a counter in both of them. In his move, $ B $ may choose any counter on the board and remove it. If at any time there are $ k $ consecutive grid cells in a line all of which contain a counter, $ A $ wins. Find the minimum value of $ k $ for which $ A $ cannot win in a finite number of moves, or prove that no such minimum value exists.}\\label{problem:coloring_1}\n\n\t\t\\solu{Trying to block $ A $. We see that if we could alternately color the points black and white, we could've found some strategy for $ B $. But the triangle grid doesn’t seem very friendly. How can we color the triangles? And don't forget the details idiot.}\n\n\n\n\n\t\\prob{www.hehe.com}{Indian TST 2004}{M}{The game of pebbles is played as followed: Initially there is one pebble at $ (0, 0) $. In a move one can remove the pebble at $ (i, j) $ and put one pebble each at $ (i+1, j) $ and $ (i, j+1) $ , given that both $ (i+1, j) $ and $ (i, j+1) $ were empty. Prove that at any point in the game, there will be a pebble at some lattice point $ (a, b) $ with $ a+b\\leq 3 $.}\\label{problem:invariant_rules_of_thumb_3}\n\n\t\t\\solu{Two from one, means if the weight is reduced by half in the second level, then the sum would be the same.}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h18505p124463}{ISL 1998 C7}{H}{A solitaire game is played on an $ m\\times n $ rectangular board, using $ mn $ markers which are white on one side and black on the other. Initially, each square of the board contains a marker with its white side up, except for one corner square, which contains a marker with its black side up. In each move, one may take away one marker with its black side up, but must then turn over all markers which are in squares having an edge in common with the square of the removed marker. Determine all pairs $ (m,n) $ of positive integers such that all markers can be removed from the board.}\\label{problem:invariant_rules_of_thumb_4}\n\n\t\t\\solu{If we remove one marker, then this cell becomes useless. So the neighbors to this cell will act like they are not connected to this cell. Now if a cell is connected to $ w $ white cells, and $ b $ black cells, then the resulting board state will have $ b-w $ more cells. Now only this info doesn't build up an invariant. Notice that as we are doing moves, we are reducing neighborhood relations as well, in other words, neighborhood relations decrease by $ b+w $. So if we consider the sum $ W+E $ where $ W $ is the number of all white cells, and $ E $ is the number of all neighborhood relations, we get an invariant on this value.}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h514376p2889829}{ARO 1999 P10.1}{E}{There are three empty jugs on a table. Winnie the pooh, Rabbit, and Piglet put walnuts in the jugs one by one. They play successively, with the initial determined by a draw. Thereby Winnie the pooh plays either in the first or second jug, Rabbit in the second or third, and Piglet in the first or third. The player after whose move there are exactly 1999 walnuts loses the games. Show that Winnie the pooh and Piglet can cooperate so as to make Rabbit lose.}\n\n\\newpage\\section{Combinatorial Geometry}\n\n\nSome Notes:\n\n\\begin{enumerate}\n\t\\item \\href{https://blogm4e.files.wordpress.com/2016/08/combinatorial-geometry-maria-monks-mop-2010.pdf}{Combinatorial Geometry - Maria Monk (MOP 2010)}\n\\end{enumerate}\n\n\n\\subsection{Lemma}\n\n\n\\newpage\\subsection{Problems}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h535002p3067558}{ARO 2013 P9.4}{E}{$ N $ lines lie on a plane, no two of which are parallel and no three of which are concurrent. Prove that there exists a non-self-intersecting broken line $ A_1A_2A_3\\dots A_N $ with $ N $ parts, such that on each of the $ N $ lines lies exactly one of the $ N $ segments of the line.}\\label{problem:constructive_algo_8}\\label{problem:induction_type1_7}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1424941p8024557}{EGMO 2017 P3}{M}{There are $ 2017 $ lines in the plane such that no three of them go through the same point. Turbo the snail sits on a point on exactly one of the lines and starts sliding along the lines in the following fashion: she moves on a given line until she reaches an intersection of two lines. At the intersection, she follows her journey on the other line turning left or right, alternating her choice at each intersection point she reaches. She can only change direction at an intersection point. Can there exist a line segment through which she passes in both directions during her journey?}\\label{problem:plane_coloring_1}\n\n\t\\solu{The condition that tells us to go either right or left, seems very non-rigorous. So to rigorize this condition, instead of using right or left condition in the direction, we consider what’s on our right and left. (INTUITION) After some experiment we see (not all of us) that if we color the plane with two colors in a way where every neighboring regions have different colors, we find some interesting stuff. (CREATIVITY) With this we are done. \\hrf{plane_coloring}{Color the Plane}}\n\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h101306p571973}{ISL 2006 C2}{TE}{Let $ P $ be a regular $ 2006 $ -gon. A diagonal is called good if its endpoints divide the boundary of $ P $ into two parts, each composed of an odd number of sides of $ P $. The sides of $ P $ are also called good.\n\n\t\tSuppose $ P $ has been dissected into triangles by $ 2003 $ diagonals, no two of which have a common point in the interior of $ P $. Find the maximum number of isosceles triangles having two good sides that could appear in such a configuration.}\\label{problem:induction_type2_4}\\label{problem:bijection_9}\n\n\n\t\\solu{The straight way, induction.}\n\n\t\\solu{The intuitive way, bijection. There are at most $ n $ good triangles, there are $ 2n $ edges, so a mapping that takes a two edges to a single good triangle must exist. Finding it is not that hard.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h589865p3493114}{ARO 2014 P9.3}{E}{In a convex $ n $ -gon, several diagonals are drawn. Among these diagonals, a diagonal is called good if it intersects exactly one other diagonal drawn (in the interior of the $ n $ -gon). Find the maximum number of good diagonals.}\\label{problem:induction_type2_1}\n\n\t\\solu{There can be two cases, two good diagonals intersecting each other, and no two good diagonals intersecting each other. In the first case, we just use induction, and in the later, all of the good diagonals create a ``triangulation'' of the polygon, which gives us the numbers.}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1181527p5720110}{ISL 2013 C2, IMO 2013 P2}{E}{A configuration of $ 4027 $ points in the plane is called Colombian if it consists of $ 2013 $ red points and $ 2014 $ blue points, and no three of the points of the configuration are collinear. By drawing some lines, the plane is divided into several regions. An arrangement of lines is good for a Colombian configuration if the following two conditions are satisfied:\n\n\t\t\\begin{enumerate}\n\n\t\t\t\\item No line passes through any point of the configuration.\n\t\t\t\\item No region contains points of both colors.\n\n\t\t\\end{enumerate}\n\n\t\tFind the least value of $ k $ such that for any Colombian configuration of $ 4027 $ points, there is a good arrangement of $ k $ lines.}\\label{problem:sandwiching_points_1}\n\n\t\\solu{Obviously a n00b would think about induction. The only problem occurs when the convex hull completely consists of red points. In this case, after some investigation, we should get the sandwiching two points idea.}\n\n\t\\solu{Another way of inductive approach is like this, as the problem condition says that no region contains points of both colors, which means if we connect any two red and blue points, some line must bisect this segment. Now \\hrf{problem:convex_hull_1}{it is known} that there is non intersecting partition of the points in to red-blue segments. So suppose in such a partition, we draw bisectors of each segments. Now there will be some holes in this proof. We see that to fill this holes, we have to focus on two red points with their respective blue partners, and draw the two bisectors in a way that separates the two red points form the blue points. So to remove further holes, we get the sandwiching idea.}\n\n\n\n\n\n\t\\prob{www.hehe.com}{Putnam 1979\\label{Putnam_1979}}{E}{Let $ A $ be a set of $ 2n $ points in the plane, no three of which are collinear, $ n $ of them are colored red and the other blue. Prove that there are $ n $ line segments, no two with a point in common, such that the endpoints of each segment are points of $ A $ having different colors.}\\label{problem:convex_hull_1}\n\n\t\\solu{Strong induction, and a way to divide the points into two sets with the same number of red and blue points. Travel through the points around a certain point and keep track of the number of red and blue points.}\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h34319p213018}{USAMO 2005 P5}{E}{Let $n$ be an integer greater than 1. Suppose $2n$ points are given in the plane, no three of which are collinear. Suppose $n$ of the given $2n$ points are colored blue and the other $n$ colored red. A line in the plane is called a balancing line if it passes through one blue and one red point and, for each side of the line, the number of blue points on that side is equal to the number of red points on the same side. Prove that there exist at least two balancing lines.}\\label{problem:convex_hull_3}\n\n\t\\solu{Using the same idea as in \\hrf{Putnam_1979}{this} problem. }\n\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h366745p2018324}{ILL 1985}{E}{Let $A$ and $B$ be two finite disjoint sets of points in the plane such that no three distinct points in $A \\cup B$ are collinear. Assume that at least one of the sets $A, B$ contains at least five points. Show that there exists a triangle all of whose vertices's are contained in $A$ or in $B$ that does not contain in its interior any point from the other set.}\n\n\t\\solu{Concentrating on one of the sets five points such that there is no other points of the same set inside the hull of those five points.}\\label{problem:convex_hull_2}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h79789p456611}{APMO 1999 P5}{M}{Let $S$ be a set of $2n+1$ points in the plane such that no three are collinear and no four concyclic. A circle will be called ``Good'' if it has $ 3 $ points of $S$ on its circumference, $n-1$ points in its interior and $n-1$ points in its exterior. Prove that the number of good circles has the same parity as $n$.}\n\n\n\t\t\\solu{When thinking about induction, got a feeling that double counting with the number of good circles going through pairs of points might be useful, because a good circle will be counted three times, if we can show that every pair has odd number of good circles, we are done. So, take a pair. Now we need to `sort' the points somehow. See that, we can't sort the points in a trivial way with numbers, so moving to angles. Now setting conditions for a point inside of a circle in terms of angles, we see amazing patter, and an easy way to calculate the number of good circle of that pair of points.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h1113183p5083543}{ISL 2014 C1}{E}{Let $ n $ points be given inside a rectangle $ R $ such that no two of them lie on a line parallel to one of the sides of $ R $. The rectangle $ R $ is to be dissected into smaller rectangles with sides parallel to the sides of $ R $ in such a way that none of these rectangles contains any of the given points in its interior. Prove that we have to dissect $ R $ into at least $ n + 1 $ smaller rectangles.}\\label{problem:extreme_object_7}\\label{problem:double_counting_3}\n\n\t\\solu{Work with the largest continuous segments, and their endpoints.}\n\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h195050p1071295}{ISL 2007 C2}{EM}{A rectangle $ D$ is partitioned in several ($ \\ge2$) rectangles with sides parallel to those of $ D$. Given that any line parallel to one of the sides of $ D$, and having common points with the interior of $ D$, also has common interior points with the interior of at least one rectangle of the partition; prove that there is at least one rectangle of the partition having no common points with $ D$'s boundary.}\\label{problem:extreme_object_17}\n\n\t\t\\solu{There existing such a rectangle means that there is a rectangular region inside of the original rectangle. So what if we walked along the segments, and cut a smaller rectangle from the inside of the rectangle? Like the way in the game.}\n\n\t\t\\solu{Starting from one corner, and taking the opposite corner of the rectangle containing that corner, we use infinite decent to reach a contradiction.}\n\n\t\t\\solu{Using \\hrf{problem:extreme_object_7}{ISL 2014 C1} as a lemma.}\n\n\n\t\n\t\\prob{https://artofproblemsolving.com/community/c6h5753p18977}{ISL 2003 C2}{E}{Let $D_1$, $D_2$, ..., $D_n$ be closed discs in the plane. (A closed disc is the region limited by a circle, taken jointly with this circle.) Suppose that every point in the plane is contained in at most $2003$ discs $D_i$. Prove that there exists a disc $D_k$ which intersects at most $7\\cdot 2003 - 1 = 14020$ other discs $D_i$.}\n\t\n\t\t\\solu{Just go with the natural idea.}\n\t\n\t\\prob{https://artofproblemsolving.com/community/c6h5785p19086}{ISL 2003 C3}{E}{Let $n \\geq 5$ be a given integer. Determine the greatest integer $k$ for which there exists a polygon with $n$ vertices (convex or not, with non-selfintersecting boundary) having $k$ internal right angles.}\\label{problem:double_counting_10}\n\t\n\t\t\\solu{double count}\n\t\n\t\n\t\n\t\\prob{https://artofproblemsolving.com/community/c6h1389042p7736716}{Tournament of Towns 2015S S4}{A convex$N-$gon with equal sides is located inside a circle. Each side is extended in both directions up to the intersection with the circle so that it contains two new segments outside the polygon. Prove that one can paint some of these new $2N$ segments in red and the rest in blue so that the sum of lengths of all the red segments would be the same as for the blue ones.}\n\t\n\t\t\\solu{Just use what's the most natural, POP, on one vertex point.}\n\n\n\t\\prob{https://artofproblemsolving.com/community/c6h145844p825495}{USAMO 2007 P2}{E}{A square grid on the Euclidean plane consists of all points $(m,n)$, where $m$ and $n$ are integers. Is it possible to cover all grid points by an infinite family of discs with non-overlapping interiors if each disc in the family has radius at least $5$?}\n\t\n\t\t\n\t\\prob{https://artofproblemsolving.com/community/c6h1135648p5301617}{MEMO 2015 T4}{EM}{Let $N$ be a positive integer. In each of the $N^2$ unit squares of an $N\\times N$ board, one of the two diagonals is drawn. The drawn diagonals divide the $N\\times N$ board into $K$ regions. For each $N$, determine the smallest and the largest possible values of $K$.\n\t\t\\fig{.6}{MEMO2015T4}{}\n\t}\n\t\n\t\t\\solu{An Algorithmic Approach: Consider each diagonal as $ 0 $ or $ 1 $, prove that the maximum configuration is the one with alternating $ 0, 1 $s and the minimum one is the one with all $ 0 $s.}\n\t\t\n\t\t\\solu{A Counting Approach: Just count and bound with the minimum areas of the regions.}\n\\newpage\\section{Sequences}\n\n\n\t\\Faka\\subsection{Lemmas}\n\n\n\t\t\\theo{https://en.wikipedia.org/wiki/Van_der_Waerden's_theorem}{Van der Waerden's Theorem}{For any given positive integers$  r $ and $ k $, there is some number $ N $ such that if the integers $ \\{1, 2, ..., N\\} $ are colored, each with one of $ r $ different colors, then there are at least $ k $ integers in arithmetic progression all of the same color.}\n\n\n\n\t\\Faka\\subsection{Generating Function Lemmas}\n\n\n\t\t\\lem{The infinite series defined as following: \\[ a_0 = a_1 = 1,\\ a_n = \\prod_{i=0}^{n} a_ia_{n-i+1} = a_0a_{n-1} + a_1a_{n-2}\\dots + a_{n-1}a_0 \\] has the general term $ a_n = C_n = \\frac{1}{n+1} \\binom{2n}{n} $}\\label{lemma:catalan_recursion}\n\n\n\t\t\\begin{multicols}{2}\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\iref{problem:catalan_recursion_1}{Problem to do with generating function}{}\n\t\t\t\\end{enumerate}\n\t\t\\end{multicols}\n\n\n\n\t\\Faka\\subsection{Sequence Problems}\n\t\n\t\t\\href{http://alexanderrem.weebly.com/uploads/7/2/5/6/72566533/sequences.pdf}{Sequences - Alexander Remorov}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h68945p404543}{ISL 1990}{E}{Assume that the set of all positive integers is decomposed into $ r $ (disjoint) subsets $ A_1 \\cup A_2 \\cup \\dots \\cup A_r = \\mathbb{N}. $ Prove that one of them, say $ A_i, $ has the following property: There exists a positive $ m $ such that for any $ k $ one can find numbers $ a_1, a_2, \\ldots, a_k $ in $ A_i $ with $ 0 < a_{j+1} - a_j \\leq m, $  $ (1 \\leq j \\leq k-1) $.}\\label{problem:induction_type1_14}\n\n\n\n\t\t\\prob{https://mathoverflow.net/questions/25313/finitely-many-arithmetic-progressions}{Result by Erdos, Dividing the integers into arithmetic progressions}{E}{Let $ d_1, d_2,\\dots, d_k $ be differences of $ k $ arithmetic progressions that partition $ \\N $. Show that $ d_i=d_j $ for some $ i,j $.}\\label{problem:generating_function_2}\\label{problem:roots_of_unity_1}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h79784p456601}{APMO 1999 P1}{E}{Find the smallest positive integer $n$ with the following property: there does not exist an arithmetic progression of $1999$ real numbers containing exactly $n$ integers.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h79787p456607}{APMO 1999 P2}{E}{Let $a_1, a_2, \\dots$ be a sequence of real numbers satisfying $a_{i+j} \\leq a_i+a_j$ for all $i,j=1,2,\\dots$. Prove that\n\t\t\t\\[ a_1 + \\frac{a_2}{2} + \\frac{a_3}{3} + \\cdots + \\frac{a_n}{n} \\geq a_n \\]\n\t\t\tfor each positive integer $n$.}\\label{problem:induction_type2_5}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h125791p713182}{ISL 1994 A1}{E}{Let $ a_{0} = 1994$ and $ a_{n + 1} = \\frac {a_{n}^{2}}{a_{n} + 1}$ for each nonnegative integer $ n$. Prove that $ 1994 - n$ is the greatest integer less than or equal to $ a_{n}$, $ 0 \\leq n \\leq 998$}\n\t\t\n\t\t\t\\solu{Take the differences.}\n\n\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h214669p1186971}{ISL 2007 C4}{M}{Let $ A_0 = (a_1,\\dots,a_n)$ be a finite sequence of real numbers. For each $ k\\geq 0$, from the sequence $ A_k = (x_1,\\dots,x_k)$ we construct a new sequence $ A_{k + 1}$ in the following way.\n\t\t\n\t\t\\begin{enumerate}\n\t\t\t\\item We choose a partition $ \\{1,\\dots,n\\} = I\\cup J$, where $ I$ and $ J$ are two disjoint sets, such that the expression \\[ \\left|\\sum_{i\\in I}x_i - \\sum_{j\\in J}x_j\\right| \\] attains the smallest value. (We allow $ I$ or $ J$ to be empty; in this case the corresponding sum is 0.) If there are several such partitions, one is chosen arbitrarily.\n\t\t\t\\item We set $ A_{k + 1} = (y_1,\\dots,y_n)$ where $ y_i = x_i + 1$ if $ i\\in I$, and $ y_i = x_i - 1$ if $ i\\in J$.\n\t\t\\end{enumerate}\n\t\t\n\t\tProve that for some $ k$, the sequence $ A_k$ contains an element $ x$ such that $ |x|\\geq\\frac n2$.}\\label{problem:invariant_rules_of_thumb_11}\n\t\n\t\t\t\\solu{Suppose the contrary. Now, since $ A_i $ can only attain finite values, So $ A_i = A_j $ for some $ i, j $. Now, we are taking about changes here, so we need to think of some invariants. Firstly the sum, it's not much of an help, because it doesn't give us much control. So kinda sum-ish invariant with a bit more control is the sum of squares. We combine these two ideas.}\n\t\t\n\t\t\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h288840p1561573}{ISL 2009 A6}{EM}{Suppose that $ s_1,s_2,s_3, \\ldots$ is a strictly increasing sequence of positive integers such that the sub-sequences \\[s_{s_1},\\, s_{s_2},\\, s_{s_3},\\, \\ldots\\qquad\\text{and}\\qquad s_{s_1+1},\\, s_{s_2+1},\\, s_{s_3+1},\\, \\ldots\\] are both arithmetic progressions. Prove that the sequence $ s_1, s_2, s_3, \\ldots$ is itself an arithmetic progression.}\n\t\t\n\t\t\t\\solu{First notice that the two arithmetic sequences has the same common difference. Then notice that the diffrences of the original sequence is bounded. Another advice, give everything names. After naming the smallest difference and the largest differnce, we get two different inequalities, from where we deduce that the difference is constant.}\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\n\\newpage\\section{Exploring Configurations}\n\n\tProblems where there is some kind of a configuration is given, the question usually asks to proof or find some specific properties of the configuration.\n\n\n\t\\subsection{Problems}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1446909p8271411}{APMO 2017 P3}{H}{Let $ A(n) $ denote the number of sequences $ a_1\\geq a_2\\geq \\dots\\geq a_k $ of positive integers for which   $ \\sum_{i=1}^k a_k =n $ and each $ a_i+1 $ is a power of two. Let $ B(n) $ denote the number of sequences $ b_1\\geq b_2\\geq\\dots\\geq b_k $ of positive integers for which $ \\sum_{i=1}^k b_k =n $ and each inequality $ b_j\\geq 2b_{j+1} $ holds $ \\left( j=1,2\\dots m-1\\right) $. Prove that $ \\vert A(n)\\vert =\\vert B(n)\\vert $ for every positive integer. }\\label{problem:add_stuffs_1}\\label{problem:bijection_6}\n\n\t\t\t\\solu{A sequence of the first type can be rewritten as: \\[ n=x_1+3x_2+7x_3\\dots +(2^i-1)x_i+\\dots (2^k-1)x_k \\] Where $ x_i $ are non-negative integers. This motivates us to find a way to represent $ b_i $ as sums of $ ( 2^i-1)x_i $. Then since $ b_j\\geq 2b_{j+1} $, we write: $ b_i=2b_{i-1}+x_i $ with $ x_i $ being non-negative integers.}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h215429p1191679}{ISL 2008 C4}{M}{Let $ n $ and $ k $ be positive integers with $ k\\geq n $ and $ k-n $ an even number. Let $ 2n $ lamps labeled $ 1,2\\dots 2n $ be given, each of which can be either on or off. Initially, all the lamps are off. We consider sequences of steps: at each step one of the lamps is switched (from on to off or from off to on).\\\\\n\n\t\tLet $ N $ be the number of such sequences consisting of $ k $ steps and resulting in the state where lamps $ 1 $ through $ n $ are all on, and lamps $ n+1 $ through $ 2n $ are all off.\\\\\n\n\t\tLet $ M $ be number of such sequences consisting of $ k $ steps, resulting in the state where lamps $ 1 $ through $ n $ are all on, and lamps $ n+1 $ through $ 2n $ are all off, but where none of the lamps $ n+1 $ through $ 2n $ is ever switched on.\\\\\n\n\t\tDetermine $ \\frac{N}{M} $.}\\label{problem:bijection_5}\n\n\t\t\t\\solu{These type of problems most of the time have bijection or algo solutions. Think of a way to perform bijection from the set $ S\\{M\\} \\rightarrow S\\{N\\} $. Find an algorithm to get a sequence of the first type from a sequence of the second type.}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h57380p353058}{USAMO 1996 P4}{E}{An $ n $ -term sequence $ (x_1, x_2, \\ldots, x_n) $ in which each term is either 0 or 1 is called a binary sequence of length $ n $. Let $ a_n $ be the number of binary sequences of length $ n $ containing no three consecutive terms equal to 0, 1, 0 in that order. Let $ b_n $ be the number of binary sequences of length $ n $ that contain no four consecutive terms equal to 0, 0, 1, 1 or 1, 1, 0, 0 in that order. Prove that $ b_{n+1} = 2a_n $ for all positive integers $ n $.}\\label{problem:bijection_4}\n\n\t\t\\solu{These type of problems cries for a nice bijection. That is a way to get from $ a\\rightarrow b $ and vice versa. What if there is no $ 0,0,1,1 $ ? Or what if there is no $ 0,1,0 $ ? What is an one way bijection?}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1446905p8271388}{APMO 2017 P1}{M}{We call a $ 5 $ -tuple of integers arrangeable if its elements can be labeled $ a,b,c,d,e $ in some order so that $ a-b+c-d+e=29 $. Determine all $ 2017 $ -tuples of integers $ n_1,n_2,n_3\\dots n_{2017} $ such that if we place them in a circle in clockwise order, then any $ 5 $ -tuple of numbers in consecutive positions on the circle is arrangeable. }\\label{problem:minus_constant_1}\\label{problem:invariant_rules_of_thumb_5}\n\n\t\t\\solu{\\hrf{minus_constant}{EChen trick}.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h41116p258304}{ISL 2004 C1}{E}{There are $ 10001 $ students at an university. Some students join together to form several clubs (a student may belong to different clubs). Some clubs join together to form several societies (a club may belong to different societies). There are a total of $ k $ societies. Find all possible values of $ k $ so that the following conditions are satisfied:\n\n\t\t\t\\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt, font=\\footnotesize\\bfseries]\n\n\t\t\t\t\\item  Each pair of students are in exactly one club.\n\n\t\t\t\t\\item  For each student and each society, the student is in exactly one club of the society.\n\n\t\t\t\t\\item  Each club has an odd number of students. In addition, a club with $ {2m+1} $ students ( $ m $ is a positive integer) is in exactly $ m $ societies.\n\t\t\\end{enumerate}}\\label{problem:double_counting_7}\n\n\t\t\\solu{Just Double-Counting.}\n\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17336p118710}{ISL 2002 C1}{E}{Let $ n $ be a positive integer. Each point $ (x,y) $ in the plane, where $ x $ and $ y $ are non-negative integers with $ x+y<n $ , is coloured red or blue, subject to the following condition: if a point $ (x,y) $ is red, then so are all points $ (x',y') $ with $ x'\\leq x $ and $ y'\\leq y $. Let $ A $ be the number of ways to choose $ n $ blue points with distinct $ x $ -coordinates, and let $ B $ be the number of ways to choose $ n $ blue points with distinct $ y $ -coordinates. Prove that $ A=B $.}\\label{problem:induction_type1_5}\\label{problem:recursive_solution_2}\\label{problem:bijection_1}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c5h476723p2669115}{USAMO 2012 P2}{M}{A circle is divided into $ 432 $ congruent arcs by $ 432 $ points. The points are colored in four colors such that some $ 108 $ points are colored Red, some $ 108 $ points are colored Green, some $ 108 $ points are colored Blue, and the remaining $ 108 $ points are colored Yellow. Prove that one can choose three points of each color in such a way that the four triangles formed by the chosen points of the same color are congruent.}\\label{problem:double_counting_6}\n\n\t\t\\solu{Double counting saves the day :) The trick is to rotate ;)}\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h195492p1073989}{APMO 2008 P2}{EM}{Students in a class form groups each of which contains exactly three members such that any two distinct groups have at most one member in common. Prove that, when the class size is $ 46 $ , there is a set of $ 10 $ students in which no group is properly contained.}\\label{problem:bijection_8}\\label{problem:extremal_case_whole_5}\n\n\t\t\\solu{Taking the maximum set that follows the ``in which no group is properly contained'' rule. Now the elements that are \\emph{not} in this set, we can connect this element to only one of the pairs from the set. Now defining a bijection, and counting the elements, we are done.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h364231p2000940}{IMO SL 1985}{M}{A set of $ 1985 $ points is distributed around the circumference of a circle and each of the points is marked with $ 1 $ or $ -1 $. A point is called ``good'' if the partial sums that can be formed by starting at that point and proceeding around the circle for any distance in either direction are all strictly positive. Show that if the number of points marked with $ -1 $ is less than $ 662 $ , there must be at least one good point.}\\label{problem:induction_type1_12}\n\n\t\t\\solu{First thing to notice, the number $ 3*661 + 2 = 1985 $. And these numbers are completely random. So what if we try to replace $ 1985 $ by $ n $ ? Will the condition still hold?}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h418978p2365036}{IMO 2011 P4}{E}{Let $ n > 0 $ be an integer. We are given a balance and $ n $ weights of weight $ 2^0, 2^1, \\cdots, 2^{n-1} $. We are to place each of the $ n $ weights on the balance, one after another, in such a way that the right pan is never heavier than the left pan. At each step we choose one of the weights that has not yet been placed on the balance, and place it on either the left pan or the right pan, until all of the weights have been placed. Determine the number of ways in which this can be done.}\\label{problem:recursive_solution_5}\n\n\t\t\\solu{Writing the whole process as a sum, we see that only $ 2^0 $ is the odd term here, if we remove that we can divide by $ 2 $ to get a recursive formula.}\n\n\t\t\\solu{Calculating wrt to the last placed weight.}\n\n\t\t\\solu{Getting recursive formula considering the position of $ 2^{n-1} $.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c5h202936p1116367}{USAMO 2008 P3}{H}{Let $ n $ be a positive integer. Denote by $ S_n $ the set of points $ (x, y) $ with integer coordinates such that \\[ \\left\\lvert x\\right\\rvert + \\left\\lvert y + \\frac{1}{2} \\right\\rvert < n. \\] A path is a sequence of distinct points $ (x_1 , y_1), (x_2, y_2), \\ldots, (x_\\ell, y_\\ell) $ in $ S_n $ such that, for $ i = 2, \\ldots, \\ell $ , the distance between $ (x_i , y_i) $ and $ (x_{i-1} , y_{i-1} ) $ is $ 1 $ (in other words, the points $ (x_i, y_i) $ and $ (x_{i-1} , y_{i-1} ) $ are neighbors in the lattice of points with integer coordinates). Prove that the points in $ S_n $ cannot be partitioned into fewer than $ n $ paths (a partition of $ S_n $ into $ m $ paths is a set $ \\mathcal{P} $ of $ m $ nonempty paths such that each point in $ S_n $ appears in exactly one of the $ m $ paths in $ \\mathcal{P} $ ).}\\label{problem:alternating_chains_2}\\label{problem:coloring_2}\n\n\n\t\t\\solu{Graph + Partition, coloring is just natural. Again, the edges join two neighbor lattice points, so checkerboard coloring. But checkerboard doesn't do much good. So the next thing we try is to apply some derivations of it, pseudo!!! Well, overkill.}\n\n\n\t\t\\solu{For all n, induction is very natural. The optimal partition (the most beautiful one) and the longest path in it, say $ P $ , gives us a way to perform induction. As always, we suppose a partition with $ n-1 $ paths. As there are a lot of partitions, we need to choose a certain partition, say $ \\mathbb{M} $. Again as our goal is to include $ P $ in $ \\mathbb{M} $. So suppose that the set with all the points in $ P $ is $ A $. And further more, suppose that in $ \\mathbb{M} $ there is a path $ Q $ with $ \\vert Q\\cap A\\vert $ being maximal among all other partitions of the points. Some some easy case work shows that we must have $ P\\in \\mathbb{M} $.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c5h532235p3041823}{USAMO 2013 P2}{H}{For a positive integer $ n\\geq 3 $ plot $ n $ equally spaced points around a circle. Label one of them $ A $ , and place a marker at $ A $. One may move the marker forward in a clockwise direction to either the next point or the point after that. Hence there are a total of $ 2n $ distinct moves available; two from each point. Let $ a_n $ count the number of ways to advance around the circle exactly twice, beginning and ending at $ A $ , without repeating a move. Prove that $ a_{n-1}+a_n=2^n $ for all $ n\\geq 4 $.}\\label{problem:recursive_solution_4}\\label{problem:bijection_7}\n\n\n\t\t\\solu{Problems where there are multiple possible value of a function regardless of the current position, one of dealing with these is to assigning labels of these possible values to each points of the function, and this will give a combinatorial model and a way to deal it with bijection.}\n\n\t\t\\solu{First investigate the problem condition, $ a_n + a_{n-1} = 2^n $ , now, $ 2^n $ means the number of differently coloring every point black or white, and the left side is the number of such paths for $ n $ and $ n-1 $. Which means we should try to color the points and see what happens.}\n\n\t\t\\proof{EChen's solution: In this problem, the main obstacle seems to be the circle condition. And on top of that, on can land on the starting point. So things are pretty messed up here. What we want to do is to make things a little bit more easy to deal with. So our best option is to change the problem so that we get the similar problem with a different explanation. So we change the condition circle with matrix, $ 2 $ round with $ 2 $ rows. $ n $ points with $ n $ entries in each rows. What we get now is the same problem, just a bit easier to deal with. We call this \\hl{Tweak The Problem} strategy.}\n\n\n\n\t\t\\prob{}{}{E}{ $ 10 $ persons went to a bookstore. It is known that: Every person has bought 3 kinds on books and for every 2 persons, there is at least one kind of books which they both have bought. Let $ m_i $ be the number of the persons who bought the $ i^{th} $ kind of books and $ M= \\max\\lbrace m_i\\rbrace $ Find the smallest possible value of $ M $.}\\label{problem:double_counting_4}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17338p118714}{ISL 2002 C3}{EM}{Let $n$ be a positive integer. A sequence of $n$ positive integers (not necessarily distinct) is called full if it satisfies the following condition: for each positive integer $k\\geq2$, if the number $k$ appears in the sequence then so does the number $k-1$, and moreover the first occurrence of $k-1$ comes before the last occurrence of $k$. For each $n$, how many full sequences are there?}\\label{problem:bijection_13}\\label{problem:graph_representation_9}\n\n\t\t\t\\proof{After guessing the ans, the first thing that I did was to draw a level based graph. Suppose that a full sequence has $ k $ different entries. Then the top level contains the positions of $ k $ in the sequence sorted from left to right. The next level contains the positions of $ k-1 $ in the sequence sorted so, and so on till the last level. What I noticed is that if we draw arrows pointing from a larger integer to a smaller integer, the only arrows (or more like relations between entries of the sequence) we need to worry about are the arrows pointing left to right in each levels, and the arrows from the last entry of level $ i $ to the first entry of level $ i+1 $. After this, if we try with a smaller case, we see that this leads to a bijection from the set of sequences of length $ n $ with $ n $ different integers to the set of full-sequences of length $ n $.}\n\n\n\t\t\t\\solu{Another bijection approach is as followed, in a full-sequence, on first run, go from right to left, placing integers starting with $ 1 $ onwards on the $ 1 $'s in the sequence. on the second run continue counting and placing integers on the $ 2 $'s and so on.}\n\n\n\t\t\t\\solu{Another idea is to prove $ a_n = n a_{n-1} $. To do this, remove the rightmost $ 1 $ and do some casework.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h219938p1219679}{ISL 1994 C2}{M}{In a certain city, age is reckoned in terms of real numbers rather than integers. Every two citizens $x$ and $x'$ either know each other or do not know each other. Moreover, if they do not, then there exists a chain of citizens $x = x_0, x_1, \\ldots, x_n = x'$ for some integer $n \\geq 2$ such that $ x_{i-1}$ and $x_i$ know each other. In a census, all male citizens declare their ages, and there is at least one male citizen. Each female citizen provides only the information that her age is the average of the ages of all the citizens she knows. Prove that this is enough to determine uniquely the ages of all the female citizens.}\n\n\t\t\t\\solu{Describing the problem using matrix and vector spaces, the problem reduces to well known theorems of linear algebra.}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h93p261}{ISL 2003 C1}{E}{Let $A$ be a $101$-element subset of the set $S=\\{1,2,\\ldots,1000000\\}$. Prove that there exist numbers $t_1$, $t_2, \\ldots, t_{100}$ in $S$ such that the sets \\[ A_j=\\{x+t_j\\mid x\\in A\\},\\qquad j=1,2,\\ldots,100 \\] are pairwise disjoint.}\n\t\t\n\t\t\t\\solu{just count...}\n\n\n\n\n\t\\newpage\\subsection{Coloring Problems}\n\n\n\t\t\\lem{What is the maximum number of knights that can be placed on a chessboard such that no two knights attack each other?}\\label{lemma:maximum_knight_problem}\n\n\t\t\t\\solu{A knight's move always changes the color of the cell.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1424942p8024575}{EGMO 2017 P2}{M}{Find the smallest positive integer $ k $ for which there exists a colouring of the positive integers $ \\mathbb{Z}_{>0} $ with $ k $ colours and a function $ f:\\mathbb{Z}_{>0}\\to \\mathbb{Z}_{>0} $ with the following two properties:\n\n\t\t\\begin{enumerate}\n\n\t\t\t\\item For all positive integers $ m,n $ of the same colour, $ f(m+n)=f(m)+f(n). $\n\t\t\t\\item There are positive integers $ m,n $ such that $ f(m+n)\\ne f(m)+f(n). $\n\n\t\t\\end{enumerate}\n\n\t\tIn a colouring of $ \\mathbb{Z}_{>0} $ with $ k $ colours, every integer is coloured in exactly one of the $ k $ colours. In both $ (i) $ and $ (ii) $ the positive integers $ m,n $ are not necessarily distinct.}\\label{problem:extremal_case_whole_4}\n\n\t\t\t\\solu{Firstly a modular coloring shows that $ 1<k\\leq 2 $. For $ k=2 $ we do some trivial case works.}\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17337p118712}{ISL 2002 C2}{E}{For $n$ an odd positive integer, the unit squares of an $n\\times n$ chessboard are coloured alternately black and white, with the four corners coloured black. A it tromino is an $L$-shape formed by three connected unit squares. For which values of $n$ is it possible to cover all the black squares with non-overlapping trominos? When it is possible, what is the minimum number of trominos needed?}\\label{problem:bijection_12}\n\n\t\t\t\\solu{First find the first ans and a configuration that works. Then guess the second ans, and see from where that might come from, usually these anses come from some special set of problems, where bijection is applicable.}\n\n\n\n\t\t\\prob{http://codeforces.com/gym/101954/problem/G}{Codeforces 101954/G}{E/H}{Two Knights are given on a chessboard, one black one white. Which player has a winning possibility?}\\label{problem:coloring_4}\n\n\t\t\t\\solu{A knight's move always changes the color of the cell.}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1671290p10632348P}{IMO 2018 P4}{E/H}{A site is any point $(x, y)$ in the plane such that $x$ and $y$ are both positive integers less than or equal to 20.\\\\\n\n\t\t\tInitially, each of the 400 sites is unoccupied. Amy and Ben take turns placing stones with Amy going first. On her turn, Amy places a new red stone on an unoccupied site such that the distance between any two sites occupied by red stones is not equal to $\\sqrt{5}$. On his turn, Ben places a new blue stone on any unoccupied site. (A site occupied by a blue stone is allowed to be at any distance from any other occupied site.) They stop as soon as a player cannot place a stone.\\\\\n\n\t\t\tFind the greatest $K$ such that Amy can ensure that she places at least $K$ red stones, no matter how Ben places his blue stones.}\\label{problem:coloring_3}\n\n\n\t\t\t\\solu{Using the \\hrf{lemma:maximum_knight_problem}{maximum knight problem} as a lemma.}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h417987p2356844}{ARO 1993 P10.4}{M}{Thirty people sit at a round table. Each of them is either smart or dumb. Each of them is asked: \"Is your neighbor to the right smart or dumb?\" A smart person always answers correctly, while a dumb person can answer both correctly and incorrectly. It is known that the number of dumb people does not exceed $ F $. What is the largest possible value of $ F $ such that knowing what the answers of the people are, you can point at at least one person, knowing he is smart?}\\label{problem:extreme_object_8}\n\t\t\n\t\t\t\\solu{We see that the strings of truth only exist either when all people are dumb or the last one is the truthful one. Now we take the longest such string, and this sting has to be of the second kind. To prove this, we use bounding with the given constraint.}\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1389041p7736715}{Tournament of Towns 2015S S6}{E}{An Emperor invited $2015$ wizards to a festival. Each of the wizards knows who of them is good and who is evil, however the Emperor doesn’t know this. A good wizard always tells the truth, while an evil wizard can tell the truth or lie at any moment. The Emperor gives each wizard a card with a single question, maybe different for different wizards, and after that listens to the answers of all wizards which are either “yes” or “no”. Having listened to all the answers, the Emperor expels a single wizard through a magic door which shows if this wizard is good or evil. Then the Emperor makes new cards with questions and repeats the procedure with the remaining wizards, and so on. The Emperor may stop at any moment, and after this the Emperor may expel or not expel a wizard. Prove that the Emperor can expel all the evil wizards having expelled at most one good wizard.}\n\t\t\n\t\t\t\\solu{There is only one problem with the cyclic arrangement, that is what if all the answers are `yes'? We get rid of this problem by trying small case with $ n=3 $ and trying the most simple way to connect this strategy to any $ n $. Simplicity is the key.}\n\t\t\n\t\t\n\n        \n        \n        \\prob{https://artofproblemsolving.com/community/c6h1810172p12054756}{Turkey TST 2019 P1}{E}{In each one of the given $2019$ boxes, there are $2019$ stones numbered as $1,2,...,2019$ with total mass of $1$ kilogram. In all situations satisfying these conditions, if one can pick stones from different boxes with different numbers, with total mass of at least 1 kilogram, in $k$ different ways, what is the maximal of $k$?}\n        \n        \n        \n        \n            \\solu{Try to make a list of all the possible candidate of $2019$ tuple of stones. Then make tuples of $2019$ such tuples so that they contains every stones once. Now as their sum is $2019$ at least one of them which is at least 1. Now we can make $2018!$ such n-tuples of tuples, thus the ans is $2018!$ and find a construction for $2018!$.}\n        \n        \n        \n        \n        \n        \n        \n        \n        \n        \n        \n        \n        \n        \n\n", "meta": {"hexsha": "619f0d5acd01a1c1970eab8c2b3b4125b97a7414", "size": 159354, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combi/combi.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "combi/combi.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combi/combi.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 71.013368984, "max_line_length": 979, "alphanum_fraction": 0.7325828031, "num_tokens": 47451, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.43214596758517027}}
{"text": "\\chapter{Proofs in Sentential Logic}\n\\label{chap:proofsinSL}\n\\markright{Chap. \\ref{chap:proofsinSL}: Proofs in SL}\n\\setlength{\\parindent}{1em}\n\n\\newcounter{theorem}\n\\setcounter{theorem}{1}\n\n\\label{whole_slproof_chap} %uncomment and typeset twice to print the whole chapter.\n\n\n%rob: This chapter is based on the original Chapter 6. I took all the material on proof in SL and moved it earlier in the book so the students would have a chance to start doing derivations earlier. I have also expanded the opening material that wasn't in a Chapter section into its own Chapter section explaining the basic idea of a proof. \n\n% *******************************************\n% *\t\tSubstitution Instances and Proofs\t\t\t   *\t\n% *******************************************\n\n\\section{Substitution Instances and Proofs}\n\\label{sec:substitution_instances}\n\n% rob: Changed opening to add big picture stuff. What we did last chapter, what we will do this chapter. The ability to use deduction as an important mental skill\n\nIn the last chapter, we introduced the truth table method, which allowed us to check to see if various logical properties were present, such as whether a statement is a tautology or whether an argument is valid. The method in that chapter was semantic, because it relied on the meaning of symbols, specifically, whether they were interpreted as true or false. The nice thing about that method was that it was completely mechanical. If you just followed the rules like a robot, you would eventually get the right answer. You didn't need any special insight and there were no tough decisions to make. The downside to this method was that the tables quickly became way too long. It just isn't practical to make a 32 line table every time you have to deal with five different sentence letters. \n\nIn this chapter, we are going to introduce a new method for checking for validity and other logical properties. This time our method is going to be purely syntactic. We won't be at all concerned with what our symbols mean. We are just going to look at the way they are arranged. Our method here will be called a system of natural deduction. When you use a system of natural deduction, you won't do it mechanically. You will need to understand the logical structure of the argument and employ your insight. This is actually one of the reasons people like systems of natural deduction. They let us represent the logical structure of arguments in a way we can understand. Learning to represent and manipulate arguments this way is a core mental skill, used in fields like mathematics and computer programming. \n\nConsider two arguments in SL:\n\\begin{quotation}\n\\begin{tabu}{X[1,p,m]X[1,p,m]}\n\\textbf{Argument A} & \\textbf{Argument B} \\\\\n\\begin{earg*}\n\\item $P \\eor Q$\n\\item  $\\enot P$\n\\itemc[.2] Q\n\\end{earg*}\n&\n\n\\begin{earg*}\n\\item $P \\eif Q$\n\\item $P$\n\\itemc[.2] Q\n\\end{earg*}\n\n\\end{tabu}\n\\end{quotation}\n\nThese are both valid arguments. Go ahead and prove that for yourself by constructing the four-line truth tables. These particular valid arguments are examples of important kinds of \narguments that are given special names. Argument A is an example of a kind of argument traditionally called \\emph{disjunctive syllogism}. In the system of proof we will develop later in \nthe chapter, it will be given a newer name, \\emph{disjunction elimination} (\\eor-E). Given a disjunction and the negation of one of the disjuncts, the other disjunct follows as a valid \nconsequence. Argument B makes use of a different valid form: Given a conditional and its antecedent, the consequent follows as a valid consequence. This is traditionally called \n\\emph{modus ponens}. In our system it will be called \\emph{conditional elimination} (\\eif-E).\n\nBoth of the arguments above remain valid even if we substitute different sentence letters. You don't even need to run the truth tables again to see that these arguments are valid: \n\\begin{quotation}\n\\begin{tabu}{X[1,p,m]X[1,p,m]}\n\\textbf{Argument A*} & \\textbf{Argument B*} \\\\\n\\begin{earg*}\n\\item $A \\eor B$\n\\item $\\enot A$\n\\itemc[.2] B\n\\end{earg*}\n\n&\n\n\\begin{earg*}\n\\item $A \\eif B$\n\\item $A$\n\\itemc[.2] B\n\\end{earg*}\n\\end{tabu}\n\\end{quotation}\n\nReplacing $P$ with $A$ and $Q$ with $B$ changes nothing (so long as we are sure to replace \\emph{every} $P$ with an $A$ and every $Q$ with a $B$). What's more interesting is that we can replace the individual sentence letters in Argument A and Argument B with longer sentences in SL and the arguments will still be valid, as long as we do the substitutions consistently. Here are two more perfectly valid instances of disjunction and conditional elimination. \n\\begin{quotation}\n\\begin{tabu}{X[1,p,m]X[1,p,m]}\n\\textbf{Argument A**} & \\textbf{Argument B**} \\\\\n\\begin{earg*}\n\\item  $(C \\eand D) \\eor (E \\eor F)$\n\\item  $\\enot (C \\eand D)$\n\\itemc[.2] $E \\eor F$\n\\end{earg*}\n\n&\n\n\\begin{earg*}\n\\item $(G \\eif H) \\eif (I \\eor J)$\n\\item $(G \\eif H)$\n\\itemc[.2] $I \\eor J$\n\\end{earg*}\n\\end{tabu}\n\\end{quotation}\nAgain, you can check these using truth tables, although the 16 line truth tables begin to get tiresome. All of these arguments are what we call \\emph{substitution instances} of the same two logical forms. We call them that because you get them by replacing the sentence letters with other sentences, either sentence letters or longer sentences in SL. A substitution instance cannot change the sentential connectives of a sentence, however. The sentential connectives are what make the \\emph{logical form} of the sentence. We can write these logical forms using fancy script letters.\n\n\\begin{quotation}\n\\begin{tabu}{X[1,p,m]X[1,p,m]}\n\\textbf{Disjunction Elimination} \\newline (Disjunctive Syllogism) &\n\\textbf{Conditional Elimination} \\newline (Modus Ponens) \\\\\n\n\n\\begin{earg*}\n\\item $\\script{A} \\eor \\script{B}$\n\\item $\\enot \\script{A}$\n\\itemc[.2] \\script{B}\n\\end{earg*}\n\n&\n\n\\begin{earg*}\n\\item  $\\script{A} \\eif \\script{B}$\n\\item  $\\script{A}$\n\\itemc[.2] \\script{B}\n\\end{earg*}\n\\end{tabu}\n\\end{quotation}\n\nAs we explained in Chapter \\ref{chap:SL}, the fancy script letters are \\emph{metavariables}.  They are a part of our metalanguage and can refer to single sentence letters like $P$ or longer sentences like $A \\eiff (B \\eand (C \\eor D))$. \n\n\\newglossaryentry{sentence form}\n{\nname=sentence form,\ndescription={A sentence in SL that contains one or more metavariables in place of sentence letters.}\n}\n\n\n\n\\newglossaryentry{substitution instance}\n{\nname=substitution instance,\ndescription={A sentence that is created by consistently substituting sentences for one or more of the metavariables in a sentence form..}\n}\n\n\n\\newglossaryentry{argument form}\n{\nname=argument form,\ndescription={An argument that includes one or more sentence forms.}\n}\n\n\n\\newglossaryentry{substitution instance of an argument form}\n{\nname=substitution instance of an argument form,\ndescription={An argument obtained by consistently replacing the sentence forms in the argument form with their substitution instances..}\n}\n\n\n\nFormally, we can define a \\textsc{\\gls{sentence form}}\\label{def:sentence_form} as a sentence in SL that contains one or more metavariables in place of sentence letters. A \\textsc{\\gls{substitution instance}}\\label{def:substitution_instance} of that sentence form is then a sentence created by consistently substituting sentences for one or more of the metavariables in the sentence form. Here ``consistently substituting'' means replacing all instances of the metavariable with the same sentence. You cannot replace instances of the same metavariable with different sentences, or leave a metavariable as it is, if you have replaced other metavariables of that same type. An \\textsc{\\gls{argument form}}\\label{def:argument_form}\n is an argument that includes one or more sentence forms, and a \\textsc{\\gls{substitution instance of an argument form}}\\label{def:substitution instance_of_an_argument_form} of the argument form is the argument obtained by consistently replacing the sentence forms in the argument form with their substitution instances.\n\nOnce we start identifying valid argument forms like this, we have a new way of showing that longer arguments are valid. Truth tables are fun, but doing the 1028 line truth table for an argument with 10 sentence letters would be tedious. Worse, we would never be sure we hadn't made a little mistake in all those Ts and Fs. Part of the problem is that we have no way of knowing  \\emph{why} the argument is valid. The table gives you very little insight into how the premises work together. \n\nThe aim of a \\emph{proof system} is to show that particular arguments are valid in a way that allows us to understand the reasoning involved in the argument. Instead of representing all the premises and the conclusion in one table, we break the argument up into steps. Each step is a basic argument form of the sort we saw above, like disjunctive syllogism or modus ponens. Suppose we are given the premises $\\enot L \\eif (J \\eor L)$ and $\\enot L$ and wanted to show $J$. We can break this up into two smaller arguments, each of which is a substitution inference of a form we know is correct.\n\n\\begin{quotation}\n\\begin{tabu}{X[1,p,m]X[1,p,m]}\n\\textbf{Argument 1} & \\textbf{Argument 2} \\\\\n\\begin{earg*}\n\\item $\\enot L \\eif (J \\eor L)$\n\\item $\\enot L$\n\\itemc[.2] $J \\eor L$\n\\end{earg*}\n\n&\n\n\\begin{earg*}\n\\item $J \\eor L$\n\\item $\\enot L$\n\\itemc[.2] $J$\n\\end{earg*}\n\\end{tabu}\n\\end{quotation}\n\nThe first argument is a substitution instance of modus ponens and the second is a substitution instance of disjunctive syllogism, so we know they are both valid. Notice also that the conclusion of the first argument is the first premise of the second, and the second premise is the same in both arguments. Together, these arguments are enough to get us from $\\enot L \\eif (J \\eor L)$ and $\\enot L$ to $J$.\n\nThese two arguments take up a lot of space, though. To complete our proof system, we need a system for showing clearly how simple steps can combine to get us from premises to conclusions. The system we will use in this book was devised by the American logician Frederic Brenton Fitch (1908--1987). We begin by writing our premises on numbered lines with a bar on the left and a little bar underneath to represent the end of the premises. Then we write ``Want'' on the side followed by the conclusion we are trying to reach. If we wanted to write out arguments 1 and 2 above, we would begin like this.\n\n\\begin{proof}\n\t\\hypo{1}{\\enot L \\eif (J \\eor\\ L)}\n\t\\hypo{2}{\\enot L} \\by{Want: $J$}{}\t\t\t\n\\end{proof}\n\nWe then add the steps leading to the conclusion below the horizontal line, each time explaining off to the right why we are allowed to write the new line. This explanation consists of citing a rule and the prior lines the rule is applied to. In the example we have been working with we would begin like this\n\n\\begin{proof}\n\t\\hypo{1}{\\enot L \\eif (J \\eor L)}\n\t\\hypo{2}{\\enot L} \\by{Want: $J$}{}\n\t\\have{3}{J \\eor L} \\ce{1, 2}\n\\end{proof}\n\nand then go like this\n\n\\begin{proof}\n\t\\hypo{1}{\\enot L \\eif (J \\eor L)}\n\t\\hypo{2}{\\enot L} \\by{Want: $J$}{}\n\t\\have{3}{J \\eor L} \\ce {1, 2}\n\t\\have{4}{J} \\oe{2, 3}\n\\end{proof}\n\n\\newglossaryentry{proof}\n{\nname=proof,\ndescription={A sequence of sentences, where the first sentences of the sequence are assumptions, and all sentences after the assumptions follow from sentences earlier in the sequence according to the rules of derivation.}\n}\n\n\n\nThe little chart above is a \\emph{proof} that $J$ follows from $\\enot L \\eif (J \\eor L)$ and $\\enot L$. We will also call proofs like this \\emph{derivations}. Formally, a \\textsc{\\gls{proof}}\\label{def:proof} is a sequence of sentences. The first sentences of the sequence are assumptions; these are the premises of the argument. Every sentence later in the sequence follows from earlier sentences by one of the rules of proof. The final sentence of the sequence is the conclusion of the argument.\n\n\\iflabelexists{chap:proofsinQL}{In the remainder of this chapter, we will develop a system for proving sentences in SL. Later, in Chapter \\ref{chap:proofsinQL}, this will be expanded to cover Quantified Logic (QL). First, though, you should practice identifying substitution instances of sentences and longer rules.}{} \n\n%I added exercises for identifying substitution inferences, because many students need practice with this really basic form of pattern recognition. \n\n%%%%%  PRACTICE PROBLEMS %%%%%%%%%%%%%\n\n\\practiceproblems\n\\noindent\\problempart For each problem, a sentence form is given in metavariables. Identify which of the sentences after it are legitimate substitution instances of that form. \n\n\\begin{exercises}\n\\begin{longtabu}{X[1,p,m]X[1,p,m]} \n\n\\item $\\script{A} \\eand \\script{B}$: \n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $P \\eor Q$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$(A \\eif B) \\eand C$}}{\\item $(A \\eif B) \\eand C$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}] \\begin{flushleft}$[(A \\eand B) \\eif (B \\eand A)] \\linebreak \\eand (\\enot A \\eand \\enot B)$\\end{flushleft}}}{\\item \\begin{flushleft}$[(A \\eand B) \\eif (B \\eand A)] \\linebreak \\eand (\\enot A \\eand \\enot B)$\\end{flushleft}}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$[((A \\eand B) \\eand C) \\eand D] \\eand F$}}{\\item $[((A \\eand B) \\eand C) \\eand D] \\eand F$ } \n\t\\item[e.] $(A \\eand B) \\eif C$\n\t\\end{enumerate}\n\n&\n\n\\item $\\enot(\\script{P} \\eand \\script{Q})$\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot(A \\eand B)$}}{\\item $\\enot(A \\eand B)$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot(A \\eand A)$}}{\\item $\\enot(A \\eand A)$}\n\t\\item[c.] $\\enot A \\eand B$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{d.}}}]\\begin{flushleft}$\\enot((\\enot A \\eand B) \\eand (B \\eand \\enot A))$\\end{flushleft}}}{\\item \\begin{flushleft}$\\enot((\\enot A \\eand B) \\eand (B \\eand \\enot A))$\\end{flushleft}}\n\t\\item[e.] $\\enot(A \\eif B)$\n\t\\end{enumerate}\n\n\n\\\\\n\n\\item $\\enot \\script{A}$\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $\\enot A \\eif B$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot (A \\eif B)$}}{\\item $\\enot (A \\eif B)$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$\\enot[(G \\eif (H \\eor I)) \\eif G]$}}{\\item $\\enot[(G \\eif (H \\eor I)) \\eif G]$}\n\t\\item $\\enot G \\eand (\\enot B \\eand \\enot H)$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{e.}}}]$\\enot(G \\eand (B \\eand H))$}}{\\item $\\enot(G \\eand (B \\eand H))$}\n\t\\end{enumerate}\n&\n\n\\item $\\enot \\script{A} \\eif  \\script{B}$\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $\\enot A \\eand B$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot B \\eif A$}}{\\item $\\enot B \\eif A$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$\\enot(X \\eand Y) \\eif (Z \\eor B)$}}{\\item $\\enot(X \\eand Y) \\eif (Z \\eor B)$}\n\t\\item $\\enot(A \\eif B)$\n\t\\item $A \\eif \\enot B$\n\t\\end{enumerate}\n\\\\\n\n\\item $\\enot \\script{A} \\eiff \\enot \\script{Z}$\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $\\enot (P \\eiff Q)$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot(P \\eiff Q) \\eiff \\enot (Q \\eiff P)$}}{\\item $\\enot(P \\eiff Q) \\eiff \\enot (Q \\eiff P)$}\n\t\\item $\\enot H \\eif \\enot G$\n\t\\item $\\enot (A \\eand B) \\eiff C$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{e.}}}]\\begin{flushleft} $\\enot [\\enot (P \\eiff Q) \\eiff R] \\eiff \\enot S$ \\end{flushleft}}}{\\item \\begin{flushleft} $\\enot [\\enot (P \\eiff Q) \\eiff R] \\eiff \\enot S$ \\end{flushleft}}\n\t\\end{enumerate}\n\n&\n\n\\item $(\\script{A} \\eand \\script{B}) \\eor \\script{C}$\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $(P \\eor Q) \\eand R$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$(\\enot M \\eand \\enot D) \\eor C$}}{\\item $(\\enot M \\eand \\enot D) \\eor C$}\n\t\\item $(D \\eand R) \\eand (I \\eor D)$\n\t\\item $[(D \\eif O) \\eor A] \\eand D$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{e.}}}]$[(A \\eand B) \\eand C] \\eor (D \\eor A)$}}{\\item $[(A \\eand B) \\eand C] \\eor (D \\eor A)$}\n\t\\end{enumerate}\n%\\factoidbox{B, E}\n\n\n\\\\\n\n\\item $(\\script{A} \\eand \\script{B}) \\eor \\script{A}$\t\t\t\t\t\t\t\n\t\\begin{flushleft}\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item$((C \\eif D) \\eand E) \\eor A$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$(A \\eand A) \\eor A$}}{\\item$(A \\eand A) \\eor A$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$((C \\eif D) \\eand E) \\eor (C \\eif D)$}}{\\item$((C \\eif D) \\eand E) \\eor (C \\eif D)$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{d.}}}]$((G \\eand B) \\eand (Q \\eor R)) \\eor (G \\eand B)$}}{\\item$((G \\eand B) \\eand (Q \\eor R)) \\eor (G \\eand B)$}\n\t\\item$(P \\eor Q) \\eand P$\n\t\\end{enumerate}\n\t\\end{flushleft}\n\n&\n\\item $\\script{P} \\eif (\\script{P} \\eif \\script{Q})$\n\t\\begin{flushleft}\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $A \\eif (B \\eif C)$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$(A \\eand B) \\eif [(A \\eand B) \\eif C]$}}{\\item $(A \\eand B) \\eif [(A \\eand B) \\eif C]$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$(G \\eif B) \\eif [(G \\eif B) \\eif (G \\eif B)]$}}{\\item $(G \\eif B) \\eif [(G \\eif B) \\eif (G \\eif B)]$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{d.}}}]$M \\eif [M \\eif (D \\eand (C \\eand M))]$}}{\\item $M \\eif [M \\eif (D \\eand (C \\eand M))]$}\n\t\\item $(S \\eor O) \\eif [(O \\eor S) \\eif A]$\n\t\\end{enumerate}\n\t\\end{flushleft}\n\n\n\n\\\\\n\\item $\\enot \\script{A} \\eor (\\script{B} \\eand \\enot \\script{B})$\n\t\\begin{flushleft}\n\t\\begin{enumerate}[label=\\alph*.]\n\t\\item $\\enot P \\eor (Q \\eand \\enot P)$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$\\enot A \\eor (A \\eand \\enot A)$}}{\\item $\\enot A \\eor (A \\eand \\enot A)$}\n\t\\item $(P \\eif Q) \\eor [(P \\eif Q) \\eand \\enot R]$\n\t\\item $\\enot E \\eand (F \\eand \\enot F)$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{e.}}}]$\\enot G \\eor [(H \\eif G) \\eand \\enot (H \\eif G)]$}}{\\item $\\enot G \\eor [(H \\eif G) \\eand \\enot (H \\eif G)]$}\n\t\\end{enumerate}\n\t\\end{flushleft}\n\n&\n\n\n\\item\t$(\\script{P} \\eor \\script{Q}) \\eif \\enot(\\script{P} \\eand \\script{Q})$\n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\t\\item\t$A \\eif \\enot B$\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{b.}}}]$(A \\eor B) \\eif \\enot(A \\eand B)$}}{\\item\t$(A \\eor B) \\eif \\enot(A \\eand B)$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{c.}}}]$(A \\eor A) \\eif \\enot(A \\eand A)$}}{\\item\t$(A \\eor A) \\eif \\enot(A \\eand A)$}\n\t\\iflabelexists{showanswers}{{\\color{red}\\item [\\circled{\\emph{\\color{red}{d.}}}]$[(A \\eand B) \\eor (D \\eif E)] \\eif $ \\linebreak[4]$ \\enot[(A \\eand B) \\eand (D \\eif E)]$}}{$[(A \\eand B) \\eor (D \\eif E)] \\eif $ \\linebreak[4]$ \\enot[(A \\eand B) \\eand (D \\eif E)]$}\n\t\\item\t$(A \\eand B) \\eif \\enot(A \\eor B)$\n\t\\end{enumerate}\n\\end{flushleft} \n\n\\end{longtabu}\n\\end{exercises}\n\\noindent\\problempart For each problem, a sentence form is given in sentence variables. Identify which of the sentences after it are legitimate substitution instances of that form. \n\n\\begin{exercises}\n\\begin{longtabu}{p{2.5in}p{2.5in}}\n\n\\item $ \\script{P} \\eand \\script{P} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$A \\eand B$\n\\item \t$D \\eor D$\n\\item \t$Z \\eand Z$\n\\item \t$(Z \\eor B) \\eand (Z \\eand B)$\n\\item \t$(Z \\eor B) \\eand (Z \\eor B)$\n\\end{enumerate}\n\\end{flushleft}\n%\\begin{flushleft} \t\n%\\begin{enumerate}[label=\\alph*.]\n%\\item \t$A \\eand B$\n%\\item \t$D \\eor D$\n%\\item \t\\framebox{$Z \\eand Z$}\n%\\item \t$(Z \\eor B) \\eand (Z \\eand B)$\n%\\item \t\\framebox{$(Z \\eor B) \\eand (Z \\eor B)$}\n%\\end{enumerate}\n%\\end{flushleft}\n&\n\\item $ \\script{O} \\eand (\\script{N} \\eand \\script{N}) $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$A \\eand (B \\eand C)$\n\\item \t$A \\eand (A \\eand B)$\n\\item \t$(A \\eand B) \\eand B$\n\\item \t$A \\eand (B \\eand B)$\n\\item \t$(C\\eif D) \\eand (Q \\eand Q)$\n\\end{enumerate}\n\\end{flushleft}\n%\\begin{flushleft} \t\n%\\begin{enumerate}[label=\\alph*.]\n%\\item \t$A \\eand (B \\eand C)$\n%\\item \t$A \\eand (A \\eand B)$\n%\\item \t$(A \\eand B) \\eand B$\n%\\item \t\\framebox{$A \\eand (B \\eand B)$}\n%\\item \t\\framebox{$(C\\eif D) \\eand (Q \\eand Q)$}\n%\\end{enumerate}\n%\\end{flushleft}\n\\\\ \n\\item $ \\script{H} \\eif \\script{Z} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$E \\eif E$\n\\item \t$G \\eif H$\n\\item \t$G \\eif (I \\eif K)$\n\\item \t$[(I \\eif K) \\eif G] \\eif A$\n\\item \t$G \\eand (I \\eif K)$\n\\end{enumerate}\n\\end{flushleft}\n%\\begin{flushleft} \t\n%\\begin{enumerate}[label=\\alph*.]\n%\\item \t\\framebox{$E \\eif E$}\n%\\item \t\\framebox{$G \\eif H$}\n%\\item \t\\framebox{$G \\eif (I \\eif K)$}\n%\\item \t\\framebox{$[(I \\eif K) \\eif G] \\eif A$}\n%\\item \t$G \\eand (I \\eif K)$\n%\\end{enumerate}\n%\\end{flushleft}\n&\n\\item $ \\enot \\script{H} \\eand \\script{C} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$H \\eand C$\n\\item \t$\\enot (H \\eand C)$\n\\item \t$\\enot Q \\eand R$\n\\item \t$R \\eand \\enot Q$\n\\item \t$\\enot (X \\eiff Y) \\eand (Y \\eif Z)$\n\\end{enumerate}\n\\end{flushleft}\n%\\begin{flushleft} \t\n%\\begin{enumerate}[label=\\alph*.]\n%\\item \t$H \\eand C$\n%\\item \t$\\enot (H \\eand C)$\n%\\item \t\\framebox{$\\enot Q \\eand R}$\n%\\item \t$R \\eand \\enot Q$\n%\\item \t\\framebox{$\\enot (X \\eiff Y) \\eand (Y \\eif Z)$}\n%\\end{enumerate}\n%\\end{flushleft}\n\\\\\n\\item $ \\enot (\\script{G} \\eiff \\script{M}) $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$\\enot (K \\eiff K) $\n\\item \t$\\enot K \\eiff K$\n\\item \t$\\enot ((I \\eiff K) \\eiff (S \\eand S)) $\n\\item \t$\\enot (H \\eif (I \\eor J)$\n\\item \t$\\enot ((H \\eor F)  \\eiff (Z \\eif D) ) $\n\\end{enumerate}\n\\end{flushleft}\n&\n\\item $ (\\script{I} \\eif \\script{W}) \\eor \\script{W} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$(D \\eor E) \\eif E$\n\\item \t$(D \\eif E) \\eor E$\n\\item \t$ D \\eif (E \\eor E)\t$\n\\item \t$ ((W \\eand L) \\eif L) \\eor W$\n\\item \t$((W \\eand L) \\eif J) \\eor J$\n\\end{enumerate}\n\\end{flushleft}\n\n\\\\\n\n\\item $ \\script{M} \\eor (\\script{A} \\eor \\script{A}) $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$ A \\eor (A \\eor A) \t\t\t$\n\\item \t$ (A \\eor A) \\eor A\t\t\t$\n\\item \t$ C \\eor (C \\eor D)\t\t\t$\n\\item \t$ (R \\eif K) \\eor ((D \\eand G) \\eor (D \\eand G)) \t\t\t$\n\\item \t$ (P \\eand P)  \\eor ((\\enot H \\eand C) \\eor (\\enot H \\eand C)) \t\t\t$\n\\end{enumerate}\n\\end{flushleft}\n&\n\\item $ \\script{A} \\eif \\enot (\\script{G} \\eand \\script{G}) $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$B \\eiff \\enot (G \\eand G) \t\t\t$\n\\item \t$O \\eif \\enot (R \\eand D) \t\t\t$\n\\item \t$(H \\eif Z) \\eif (\\enot D\t\\eand D)\t\t$\n\\item \t$ (O \\eand (N \\eand N))  \\eif \\enot (F \\eand F)\t\t\t$\n\\item \t$\\enot D \\eand \\enot( (J \\eif J) \\eand (O \\eiff O) $ \n\\end{enumerate}\n\\end{flushleft}\n\\\\\n\\item $ \\enot ((\\script{K} \\eif \\script{K}) \\eor \\script{K}) \\eand \\script{G} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$\\enot (D \\eif D) (\\eor D \\eand L)\t \t\t\t$\n\\item \t$ \\enot (D \\eif (D \\eor (D \\eand L))\t\t\t\t$\n\\item \t$ \\enot ((D \\eif D) \\eor D) \\eand L\t\t\t$\n\\item \t$((\\enot K \\eif \\enot K) \\eor K) \\eand L \t\t\t$\n\\item \t$ \\enot ((D \\eif D) \\eor D) \\eand ((D \\eif D) \\eor D)\t\t\t$\n\\end{enumerate}\n\\end{flushleft}\n&\n\\item $ (\\script{B} \\eiff (\\script{N} \\eiff \\script{N})) \\eor \\script{N} $ \n\\begin{flushleft} \t\n\\begin{enumerate}[label=\\alph*.]\n\\item \t$(B \\eiff (N \\eiff (N \\eand N))) \\eor N  \t\t\t$ %nope\n\\item \t$((E \\eand T) \\eiff (V \\eiff V )) \\eor V  \t\t\t$  %yup\n\\item \t$ (B \\eiff (N \\eand N)) \\eor B\t\t\t$  %nope\n\\item \t$A \\eiff (N \\eiff (N \\eor N)))\t\t\t$ %nope\n\\item \t$((X \\eiff N) \\eiff N) \\eor N\t\t\t$ %nope\n\\end{enumerate}\n\\end{flushleft}\n\\end{longtabu}\n\\end{exercises}\n\n\\noindent\\problempart Use the following symbolization key in the gray bubble to create substitution instances of the sentences below.\n\n\\begin{mdframed}[style=mytablebox] \n\\begin{longtabu}{X[.5]X[.5]X[1]X[1]X[1]} \n$\\script{A}: B$ \t& \t$\\script{B}: \\enot C$  \t& $\\script{C}: A \\eif B$ &\n$\\script{D}:\\enot (B \\eand C)$  & $\\script{E}: D \\eiff E$\n\\end{longtabu}\n\\end{mdframed}\n\n\\begin{exercises}\n\\begin{longtabu}{X[1,l,m]X[1,p,m]} \n\\item $\\enot( \\script{A} \\eiff \\script{B})$ \n\\answer{$\\enot(B \\eiff  \\enot{C})$}\n&\n\n\\item $(\\script{B} \\eif \\script{C}) \\eand \\script{D}$ \n\n\n\\answer{$(\\enot{C} \\eif (A \\eif B)) \\eand \\enot(B \\eand C)$}\n\\\\\n\\item $\\script{D} \\eif (\\script{B} \\eand \\enot \\script{B}) $ \n\n\n\\answer{$\\enot(B \\eand C) \\eif (\\enot{C} \\eand \\enot \\enot{C}) $}\n&\n\\item $\\enot \\enot (\\script{C} \\eor \\script{E})$ \n\n\n\\answer{$\\enot \\enot ((A \\eif B) \\eor (D \\eiff E))$}\n\\\\\n\\item $\\enot \\script{C} \\eiff (\\enot \\enot \\script{D} \\eand \\script{E})$ \n\n\n\\answer{$\\enot (A \\eif B) \\eiff (\\enot \\enot \\enot(B \\eand C) \\eand (D \\eiff E))$}\n\n\\end{longtabu}\n\\end{exercises}\n\n\n\n\\noindent\\problempart Use the following symbolization key in the gray bubble to create substitution instances of the sentences below.\n\n\\begin{mdframed}[style=mytablebox] \n\\begin{longtabu}{X[1]X[1]X[1]X[.5]X[.5]} \n$\\script{A}: I \\eor (I \\eiff V)  $ \n&\t$\\script{B}: C \\eiff V$ \n&\t$\\script{C}: L \\eif X$  \n&\t$\\script{D}: V$  \n&\t$\\script{E}: U$ \n\\end{longtabu}\n\\end{mdframed}\n\n\\begin{exercises}\n\\begin{longtabu}{X[1,l,m]X[1,p,m]} \n\\item $\\enot \\script{A} \\eif \\enot \\script B$ \n&\n\\item $\\enot(\\script{B} \\eand \\script{D})$ \n\\\\\n\\item $(\\script{A} \\eif \\script{A}) \\eor (\\script{C} \\eif \\script{A})$ \n&\n\\item $[(\\script{A} \\eif \\script{B}) \\eif \\script{A}] \\eif \\script{A}$ \n\\\\\n\\item $\\script{A} \\eand (\\script{B} \\eand (\\script{C} \\eand (\\script{D} \\eand \\script{E})))$\n&\\\\\n\\end{longtabu}\n\\end{exercises}\n\n%%%%%%%%%%%%%%%%%% Part E\n\n\n\\noindent\\problempart \\label{sec4.1partC} Decide whether the following are examples of $\\eif$E (modus ponens).\n\n\\begin{exercises}\n\\begin{longtabu}{X[1,p,m]X[1,p,m]X[1,p,m]} \n\n\\item \\begin{earg*}\n\\item $A \\eif B$ \n\\item $B \\eif C$ \n\\itemc[.3] $A \\eif C$\n\\end{earg*}\n\\answer{\\framebox{Not MP}}\n\t\n&\n\n\\item \\begin{earg*}\t\n\\item$P \\eand Q$ \n\\item \t$P$ \n\\itemc[.3] \t $Q$\n\\end{earg*}\n\n\\answer{\\framebox{Not MP}}\n\t\n&\n\\item \\begin{earg*}\t\n\\item $P \\eif Q$ \n\\itemc[.3] \t$Q$\n\\end{earg*}\n\\answer{\\framebox{Not MP}}\n\n\\\\\n\\item \\begin{earg*}\t\n\\item $D \\eif E$ \n\\item \t$E$ \n\\itemc[.3] \t$D$\n\\end{earg*}\n\\answer{\\framebox{Not MP}}\n\n&\n\n\\item \\begin{earg*}\n\\item $(P \\eand Q) \\eif (Q \\eand V)$\n\\item \t$P \\eand Q$\n\\itemc[.3] \t $Q \\eand V$\n\\end{earg*}\n\\answer{\\framebox{MP}}\n\\end{longtabu}\n\\end{exercises}\n\t\n\n\\noindent\\problempart \\label{sec4.1partC} Decide whether the following are examples of $\\eif$E (modus ponens).\n\n\\begin{exercises}\n\\begin{longtabu}{X[1]X[1]} \n\\item \\begin{earg*}\n\\item\t$C \\eif D$  \n\\itemc[.3] \t $C$\n\\end{earg*}\n%\\frame{Not MP}\\\\\n\t\n&\n\n\\item \\begin{earg*}\n\\item $(C \\eand L) \\eif (E \\eor C)$ \n\\item $C \\eand L$ \n\\itemc[.3] \t  $E \\eor C$\n\\end{earg*}\n%\\framebox{MP}\n\t\n\\\\\n\\item \\begin{earg*}\n\\item  $\\enot A \\eif B$ \n\\item $\\enot B$ \n\\itemc[.3] \t $B$\n\\end{earg*}\n\t%\\framebox{Not MP}\\\\\n&\n\n\\item \\begin{earg*}\n\\item\t$X \\eif \\enot Y$ \n\\item  \t$\\enot Y$ \n\\itemc[.3] \t $\\therefore$\\ $X$\n\\end{earg*}\n%\\framebox{Not MP}\\\\\n\\\\\n\\item \\begin{earg*}\n\\item $G \\eif H$ \n\\item  $\\enot H$ \n\\itemc[.3] \t  $\\enot G$\n\\end{earg*}\n%\\framebox{Not MP}\\\\\n\n\\end{longtabu}\n\\end{exercises}\n\n\n%%%% part G\n\n\\noindent\\problempart Decide whether the following are examples of \\eor-E (disjunctive syllogism). \n\n\\begin{exercises}\n\\begin{longtabu}{X[1]X[1]} \n\\item \\begin{earg*}\n\\item $(A \\eif B) \\eor (X \\eif Y)$  \n\\item $\\enot A$  \n\\itemc[.3]  $X \\eif Y$\n\\end{earg*}\n\n\\answer{\\framebox{Not DS}}\n\n&\t\n\n\\item \\begin{earg*}\n\\item $[(S \\eor T) \\eor U] \\eor V$  \n\\item $\\enot[(S \\eor T) \\eor U]$  \n\\itemc[.3] $V$\n\\end{earg*}\n\\answer{\\framebox{DS}}\n\n\\\\\n\\item \\begin{earg*}\n\\item $P \\eor Q$  \n\\item $P$  \n\\itemc[.3] \\enot $Q$\n\\end{earg*}\n\\answer{\\framebox{Not DS}}\n\n&\n\\item \\begin{earg*}\n\\item $\\enot (A \\eor B)$  \n\\item $\\enot A$  \n\\itemc[.3] $B$\n\\end{earg*}\n\\answer{\\framebox{Not DS}}\n\\\\\n\n\\item \\begin{earg*}\n\\item $(P \\eor Q) \\eor R$  \n\\itemc[.3]  $R$\n\\answer{\\framebox{Not DS}}\n\\end{earg*}\n\n\\end{longtabu}\n\\end{exercises}\n\n\\noindent\\problempart Decide whether the following are examples of \\eor-E (disjunctive syllogism).\n\n\\begin{exercises}\n\\begin{longtabu}{X[1]X[1]} \n\\item \\begin{earg*} \n\\item $(C \\eand D) \\eor E$  \n\\item $(C \\eand D)$  \n\\itemc[.3] $E$\n\\end{earg*}\n%\\framebox{Not DS}\\\\\n&\n\n\\item \\begin{earg*} \n\\item $(P \\eor Q) \\eif R$  \n\\item $\\enot(P \\eor Q)$  \n\\itemc[.3] $R$\n\\end{earg*}\n%\\framebox{Not DS}\\\\\n\\\\\n\n\\item \\begin{earg*} \n\\item  $X \\eor (Y \\eif Z)$  \n\\item $\\enot X$  \n\\itemc[.3] $Y \\eif Z$\n\\end{earg*}\n%\\framebox{DS}\\\\\n\n&\n\\item \\begin{earg*} \n\\item $(P \\eor Q) \\eor R$  \n\\item  $\\enot P$  \n\\itemc[.3] $Q$\n\\end{earg*}\n%\\framebox{Not DS}\\\\\n\n\\\\\n\\item \\begin{earg*} \n\\item $A \\eor (B \\eor C)$  \n\\item $\\enot A$   \n\\itemc[.3]  $B \\eor C$\t\n\\end{earg*}\n%\\framebox{DS}\\\\\n\\end{longtabu}\n\\end{exercises}\n\n\n\n\n% *******************************************\n% *\t\t\t\tBasic Rules for Sentential Logic\t   *\t\n% *******************************************\n\n\\section{Basic Rules for Sentential Logic}\n\\setlength{\\parindent}{1em}\n%rob: I removed indirect and conditional proof from this section, so that they would have practice just doing direct proofs before they moved on to the fancy stuff. \n\nIn designing a proof system, we could just start with disjunctive syllogism and modus ponens. Whenever we discovered a valid argument that could not be proved with rules we already had, we could introduce new rules. Proceeding in this way, we would have an unsystematic grab bag of rules. We might accidentally add some rules, and we would surely end up with more rules than we need.\n\nInstead, we will develop what is called a \\define{system of natural deduction}. In a natural deduction system, there will be two rules for each logical operator: an introduction, and an elimination rule. The introduction rule will allow us to prove a sentence that has the operator you are ``introducing'' as its main connective. The elimination rule will allow us to prove something given a sentence that has the operator we are ``eliminating'' as the main logical operator.\n\nIn addition to the rules for each logical operator, we will also have a reiteration rule. If you already have shown something in the course of a proof, the reiteration rule allows you to repeat it on a new line. We can define the rule of reiteration like this\n\nReiteration (R)\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[n]{b}{\\script{A}} \\by{R}{a}\n\\end{proof}\n\nThis diagram shows how you can add lines to a proof using the rule of reiteration. As before, the script letters represent sentences of any length. The upper line shows the sentence that \ncomes earlier in the proof, and the bottom line shows the new sentence you are allowed to write and how you justify it. The reiteration rule above is justified by one line, the line that \nyou are reiterating. So the ``R $m$'' on line 2 of the proof means that the line is justified by the reiteration rule (R) applied to line $m$. The letters $m$ and $n$ are variables, not \nreal line numbers. In a real proof, they might be lines 5 and 7, or lines 1 and 2, or whatever. When we define the rule, however, we use variables to underscore the point that the rule \nmay be applied to any line that is already in the proof.\n\nObviously, the reiteration rule will not allow us to show anything \\emph{new}. For that, we will need more rules. The remainder of this section will give six basic introduction and \nelimination rules. This will be enough to do some basic proofs in SL. Sections \\ref{sec:conditional_proof} through \\ref{sec:indirect_proof} will explain introduction rules involved in \nfancier kinds of derivation called conditional proof and indirect proof. The remaining sections of this chapter will develop our system of natural deduction further and give you tips for \nplaying in it.\n\nAll of the rules introduced in this chapter are summarized starting on p.~\\pageref{sec:proof_rules}.\n\n%%%%%%%%%%%%%\n%rcr I added the proofrules label above -- added the rules at the end of the chapter\n%%%%%%%%%%%%\n\n\\subsection{Conjunction}\n\nThink for a moment: What would you need to show in order to prove $E \\eand F$?\n\nOf course, you could show $E \\eand F$ by proving $E$ and separately proving $F$. This holds even if the two conjuncts are not atomic sentences. If you can prove $[(A \\eor J) \\eif V]$ and  $[(V \\eif L) \\eiff (F \\eor N)]$, then you have effectively proved $[(A \\eor J) \\eif V] \\eand [(V \\eif L) \\eiff (F \\eor N)].$\nSo this will be our conjunction introduction rule, which we abbreviate {\\eand}I:\n\n\\begin{multicols}{2}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[n]{b}{\\script{B}}\n\t\\have[\\ ]{c}{\\script{A}\\eand\\script{B}} \\ai{a, b}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[n]{b}{\\script{B}}\n\t\\have[\\ ]{c}{\\script{B}\\eand\\script{A}} \\ai{a, b}\n\\end{proof}\n\n\\end{multicols}\n\nA line of proof must be justified by some rule, and here we have ``{\\eand}I $m$, $n$.'' This means: Conjunction introduction applied to line $m$ and line $n$. Again, these are variables, not real line numbers; $m$ is some line and $n$ is some other line. If you have $K$ on line 8 and $L$ on line 15, you can prove $(K\\eand L)$ at some later point in the proof with the justification ``{\\eand}I 8, 15.'' \n\nWe have written two versions of the rule to indicate that you can write the conjuncts in any order. Even though $K$ occurs before $L$ in the proof, you can derive $(L \\eand K)$ from them using the right-hand version {\\eand}I. You do not need to mark this in any special way in the proof.\n\nNow, consider the elimination rule for conjunction. What are you entitled to conclude from a sentence like $E \\eand F$? Surely, you are entitled to conclude $E$; if $E \\eand F$ were true, then $E$ would be true. Similarly, you are entitled to conclude $F$. This will be our conjunction elimination rule, which we \nabbreviate {\\eand}E:\n\n\\begin{multicols}{2}\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eand\\script{B}}\n\t\\have[\\ ]{a}{\\script{A}} \\ae{ab}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eand\\script{B}}\n\t\\have[\\ ]{a}{\\script{B}} \\ae{ab}\n\\end{proof}\n\\end{multicols}\n\nWhen you have a conjunction on some line of a proof, you can use {\\eand}E to derive either of the conjuncts. Again, we have written two versions of the rule to indicate that it can be applied to either side of the conjunction. The {\\eand}E rule requires only one sentence, so we write one line number as the justification for applying it. For example, both of these moves are acceptable in derivations. \n\n\\begin{multicols}{2}\n\\begin{proof}\n\\have[4]{4}{A \\eand (B \\eor C)}\n\\have[5]{5}{A} \\ae{4}\n\\end{proof}\n\n\\begin{proof}\n\\have[10]{10}{A \\eand (B \\eor C)}\n\\have[\\ldots]{...}{\\ldots}\n\\have[15]{15}{(B \\eor C)} \\by {\\eand E}{10}\n\\end{proof}\n\\end{multicols}\nSome textbooks will only let you use \\eand E on one side of a conjunction. They then make you \\emph{prove} that it works for the other side. We won't do this, because it is a pain in the neck. \n\nEven with just these two rules, we can provide some proofs. Consider this argument.\n\\begin{earg}\n\\item[] $[(A\\eor B)\\eif(C\\eor D)] \\eand [(E \\eor F) \\eif (G\\eor H)]$\n\\item[$\\therefore$] $[(E \\eor F) \\eif (G\\eor H)] \\eand [(A\\eor B)\\eif(C\\eor D)]$\n\\end{earg}\nThe main logical operator in both the premise and conclusion is a conjunction. Since the conjunction is symmetric, the argument is obviously valid. In order to provide a proof, we begin by writing down the premise. After the premises, we draw a horizontal line---everything below this line must be justified by a rule of proof. So the beginning of the proof looks like this:\n\n\\begin{proof}\n\t\\hypo{ab}{{[}(A\\eor B)\\eif(C\\eor D){]} \\eand {[}(E \\eor F) \\eif (G\\eor H){]}}\n\\end{proof}\n\nFrom the premise, we can get each of the conjuncts by {\\eand}E. The proof now looks like this:\n\n\\begin{proof}\n\t\\hypo{ab}{{[}(A\\eor B)\\eif(C\\eor D){]} \\eand {[}(E \\eor F) \\eif (G\\eor H){]}}\n\t\\have{a}{{[}(A\\eor B)\\eif(C\\eor D){]}} \\ae{ab}\n\t\\have{b}{{[}(E \\eor F) \\eif (G\\eor H){]}} \\ae{ab}\n\\end{proof}\n\nThe rule {\\eand}I requires that we have each of the conjuncts available somewhere in the proof. They can be separated from one another, and they can appear in any order. So by applying the {\\eand}I rule to lines 3 and 2, we arrive at the desired conclusion. The finished proof looks like this:\n\n\\begin{proof}\n\t\\hypo{ab}{{[}(A\\eor B)\\eif(C\\eor D){]} \\eand {[}(E \\eor F) \\eif (G\\eor H){]}}\n\n\t\\have{a}{{[}(A\\eor B)\\eif(C\\eor D){]}} \\ae{ab}\n\t\\have{b}{{[}(E \\eor F) \\eif (G\\eor H){]}} \\ae{ab}\n\t\\have{ba}{{[}(E \\eor F) \\eif (G\\eor H){]} \\eand {[}(A\\eor B)\\eif(C\\eor D){]}} \\ai{b,a}\n\\end{proof}\n\nThis proof is trivial, but it shows how we can use rules of proof together to demonstrate the validity of an argument form. Also: Using a truth table to show that this argument is valid would have required a staggering 256 lines, since there are eight sentence letters in the argument.\n\n%When we defined a wff, we did not allow for conjunctions with more than two conjuncts. If we had done so, then we could define a more general version of the rules of proof for conjunction.\n\n\n\\subsection{Disjunction}\nIf $M$ were true, then $M \\eor N$ would also be true. So the disjunction introduction rule ({\\eor}I) allows us to derive a disjunction if we have one of the two disjuncts:\n\n\\begin{multicols}{2}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{ab}{\\script{A}\\eor\\script{B}}\\oi{a}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{ab}{\\script{B}\\eor\\script{A}}\\oi{a}\n\\end{proof}\n\n\\end{multicols}\n\nLike the rule of conjunction elimination, this rule can be applied two ways. Also notice that \\script{B} can be \\emph{any} sentence whatsoever. So the following is a legitimate proof:\n\n\\begin{proof}\n\t\\hypo{m}{M}\n\t\\have{mmm}{M \\eor ([(A\\eiff B) \\eif (C \\eand D)] \\eiff [E \\eand F])}\\oi{m}\n\\end{proof}\n\nThis might seem odd. How can we prove a sentence that includes $A$, $B$, and the rest, from the simple sentence $M$---which has nothing to do with the other letters? The secret here is to remember that all the new letters are on just one side of a disjunction, and nothing on that side of the disjunction has to be true. As long as $M$ is true, we can add whatever we want after a disjunction and the whole thing will continue to be true. \n\nNow consider the disjunction elimination rule. What can you conclude from $M \\eor N$? You cannot conclude $M$. It might be $M$'s truth that makes $M \\eor N$ true, as in the example above, \nbut it might not. From $M \\eor N$ alone, you cannot conclude anything about either $M$ or $N$ specifically. If you also knew that $N$ was false, however, then you would be able to \nconclude $M$.\n\n\\begin{multicols}{2}\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{nb}{\\enot\\script{B}}\n\t\\have[\\ ]{a}{\\script{A}} \\oe{ab,nb}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{na}{\\enot\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\oe{ab,nb}\n\\end{proof}\n\\end{multicols}\n\nWe've seen this rule before: it is just disjunctive syllogism. Now that we are using a system of natural deduction, we are going to make it our rule for disjunction elimination ({\\eor}E). Once again, the rule works on both sides of the sentential connective. \n\n\\subsection{Conditionals and biconditionals}\n\nThe rule for conditional introduction is complicated because it requires a whole new kind of proof, called conditional proof. We will deal with this in the next section. For now, we will \nonly use the rule of conditional elimination.\n\nNothing follows from $M\\eif N$ alone, but if we have both $M \\eif N$ and $M$, then we can conclude $N$. This is another rule we've seen before: modus ponens. It now enters our system of \nnatural deduction as the conditional elimination rule ({\\eif}E).\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eif\\script{B}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\ce{ab,a}\n\\end{proof}\n\nBiconditional elimination ({\\eiff}E) will be a double-barreled version of conditional elimination. If you have the left-hand subsentence of the biconditional, you can derive the \nright-hand subsentence. If you have the right-hand subsentence, you can derive the left-hand subsentence. This is the rule:\n\n\\begin{multicols}{2}\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\be{ab,a}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n\t\\have[n]{a}{\\script{B}}\n\t\\have[\\ ]{b}{\\script{A}} \\be{ab,a}\n\\end{proof}\n\\end{multicols}\n\n\\subsection{Invalid argument forms}\n\n%rob: I added this brief subsection to make clear what was going to happen in the first problem part, and to re-emphasize the idea of invalid arguments\n\nIn section \\ref{sec:substitution_instances}, in the last two problem parts (p. \\pageref{sec4.1partC}), we saw that sometimes an argument looks like a legitimate substitution instance of a \nvalid argument form, but really isn't.  For instance, the problem set C asked you to identify instances of modus ponens. Below I'm giving you two of the answers.\n \n\\begin{multicols}{2}\n(5) Modus ponens\n\t\\begin{earg}\n\t\\item[1.] $(C \\eand L) \\eif (E \\eor C)$\n\t\\item[2.] $C \\eand L$\n\t\\item[] \\textcolor{white}{.}\\sout{\\hspace{.5\\linewidth}} \\textcolor{white}{.} \n\t\\item[$\\therefore$] $E \\eor C$\n\t\\end{earg}\n(7) \\emph{Not} modus ponens.\n\t\\begin{earg} \n\t\\item[1.] $D \\eif E$\n\t\\item[2.] $E$\n\\item[] \\textcolor{white}{.}\\sout{\\hspace{.2\\linewidth}} \\textcolor{white}{.} \n\t\\item[$\\therefore$] $D$\n\t\\end{earg}\n\\end{multicols}\nThe argument on the left is an example of a valid argument, because it is an instance of modus ponens, while the argument on the right is an example of an invalid argument, because it is not an example of modus ponens. (We originally defined the terms valid and invalid on p. \\pageref{def:valid}). Arguments like the one on the right, which try to trick you into thinking that they are instances of valid arguments, are called \\define{deductive fallacies}. The argument on the right is specifically called the fallacy of \\define{affirming the consequent}. In the system of natural deduction we are using in this textbook, modus ponens has been renamed ``conditional elimination,'' but it still works the same way. So you will need to be on the lookout for deductive fallacies like affirming the consequent as you construct proofs. \n\n\\subsection{Notation}\n\nThe rules we have learned in this chapter give us enough to start doing some basic derivations in SL. This will allow us to prove things syntactically which would have been too cumbersome to prove using the semantic method of truth tables. We now need to introduce a few more symbols to be clear about what methods of proof we are using. \n\nIn Chapter 1, we used the three dots $\\therefore$ to indicate generally that one thing followed from another. In chapter 3 we introduced the double turnstile, $\\sdtstile{}{}$, to indicate that one statement could be proven some others using truth tables. Now we are going to use a single turnstile, $\\sststile{}{}$, to indicate that we can derive a statement from a bunch of premises, using the system of natural deduction we have begun to introduce in this section. Thus we will write $\\{\\script{A}, \\script{B}, \\script{C}\\} \\sststile{}{} \\script{D}$, to indicate that there is a derivation going from the premises \\script{A}, \\script{B}, and \\script{C} to the conclusion \\script{D}. Note that these are metavariables, so I could be talking about any sentences in SL.\n\nThe single turnstile will work the same way the double turnstile did. So, in addition to the uses of the single turnstile above we can write  $\\sststile{}{} \\script{A}$ to indicate that \\script{A} can be proven a tautology using syntactic methods. We can write $\\script{A}\\nsststile{}{} \\hspace{.5em}  \\sststile{}{}\\script{B}$ to say that \\script{A} and \\script{B} can be proven logically equivalent using these derivations. You will learn how to do these later things at the end of the chapter. In the meantime, we need to practice our basic rules of derivation.\n\n%%%%%%%%%% PRACTICE PROBLEMS %%%%%%\n\\practiceproblems\n\\noindent\\problempart Some of the following arguments are legitimate instances of our six basic inference rules. The others are either invalid arguments or valid arguments that are still illegitimate because they would take multiple steps using our basic inference rules. For those that are legitimate, mark the rule that they are instances of. Mark those that are not ``Not a single inference.'' \n\n\\begin{exercises}\n\\begin{longtabu}{X[1]X[1]} \n\n\\item %1\n\t\\begin{earg*}\n\t\\item $R \\eor S$ \n\\itemc[.3] $S$\n\t\\end{earg*}\n\\answer{\\factoidbox{Not a single inference}}\n\n&\n\n\\item %2\n\t\\begin{earg*}\n\t\\item $(A \\eif B) \\eor (B \\eif A)$\n\t\\item $A \\eif B$\n\\itemc[.3] $B \\eif A$\n\t\\end{earg*}\n\n\\answer{\\factoidbox{Not a single inference}}\n\n\\\\\n\n\\item %3\n\t\\begin{earg*}\n\t\\item $P \\eand (Q \\eor R)$\n\\itemc[.3] $R$\n\t\\end{earg*}\n\\answer{\\factoidbox{Not a single inference}}\n\n&\n\\item %4\n\t\\begin{earg*}\n\t\\item $P \\eand (Q \\eand R)$\n\\itemc[.3] $P$\n\t\\end{earg*}\n\\answer{\t\t\\factoidbox{\\eand-Elimination}}\n\n\\\\\n\\item %5\n\t\\begin{earg*}\n\t\\item  $A$\n\\itemc[.3] $P \\eand (Q \\eif A)$\n\t\\end{earg*}\n\\answer{\\factoidbox{Not a single inference}}\n\n&\t\n\t\n\\item %6\n\t\\begin{earg*}\n\t\\item  $A$\n\t\\item  $B \\eand C$\n\\itemc[.3] $(A \\eand B) \\eand C$\n\t\\end{earg*}\n\\answer{\\factoidbox{\\begin{flushleft}Not a single inference. You need the associativity of \\eand to infer this.\\end{flushleft}}}\n\\\\\n\\item %7\n\t\\begin{earg*}\n\t\\item $(X \\eand Y) \\eiff (Z \\eand W)$\n\t\\item $Z \\eand W$\n\\itemc[.3] $X \\eand Y$\n\t\\end{earg*}\n\\answer{\t\\factoidbox{\\eiff-Elimination}}\n&\n\\item %8\n\t\\begin{earg*}\n\t\\item $((L \\eif M) \\eif N) \\eif O$\n\t\\item $L$\n\\itemc[.3] $M$\n\t\\end{earg*}\n\\answer{\t\\factoidbox{Not a single inference}}\n\n\\end{longtabu}\n\\end{exercises}\n\n\n\\noindent\\problempart Some of the following arguments are legitimate instances of our six basic inference rules. The others are either invalid arguments or valid arguments that are still illegitimate because they would take multiple steps using our basic inference rules. For those that are legitimate, mark the rule that they are instances of. Mark those that are not ``Not a single inference.''\n\n\\begin{exercises} \\vspace{-.5cm}\n\\begin{longtabu}{X[1]X[1]} \n\n\\item %1\n\t\\begin{earg*}\n\t\\item  $A \\eand B$\n \n\t\\itemc[.3]$A$ \t\n\t\\end{earg*}\n%\\factoidbox{\\eand-Elimination}\n&\n\n\\item %2\n\t\\begin{earg*}\n\t\\item $A \\eif (B \\eand (C \\eor D))$\n\t\\item $A$\n \n\t\\itemc[.3]$B \\eand (C \\eor D)$\n\t\\end{earg*}\n%\\factoidbox{\\eif-Elimination}\n\\\\\n\n\\item %3\n\t\\begin{earg*}\n\t\\item $P \\eand (Q \\eand R)$\n \n\t\\itemc[.3]$R$\n\t\\end{earg*}\n%\t\\factoidbox{\\begin{flushleft}Not a single inference. You need two uses of \\eand-elim. to do this\\end{flushleft}}\n&\n\n\\item %4\n\t\\begin{earg*}\n\t\\item  $P$\n \n\t\\itemc[.3] $P \\eor [A \\eand (B \\eiff C)]$\n\t\\end{earg*}\n%\t\\factoidbox{\\eor-Introduction}\n\\\\\n\n\\item %5\n\t\\begin{earg*}\n\t\\item  $M$\n\t\\item  $D \\eand C$\n \n\t\\itemc[.3] $M \\eand (D \\eand C)$\n\t\\end{earg*}\n%\t\\factoidbox{\\eand-Introduction}\n&\n\n\\item %6\n\t\\begin{earg*}\n\t\\item $(X \\eand Y) \\eif (Z \\eand W)$\n\t\\item $Z \\eand W$\n \n\t\\itemc[.3]$X \\eand Y$\n\t\\end{earg*}\n%\t\\factoidbox{Not a single inference}\n\\\\\n\n\\item %7\n\t\\begin{earg*}\n\t\\item $(X \\eand Y) \\eif (Z \\eand W)$\n\t\\item $\\enot (X \\eand Y)$\n \n\t\\itemc[.3]$\\enot(Z \\eand W)$\n\t\\end{earg*}\n%\t\\factoidbox{Not a single inference}\n&\n\n\\item %8\n\t\\begin{earg*}\n\t\\item $((L \\eif M) \\eif N) \\eif O$\n\t\\item $(L \\eif M) \\eif N$\n \n\t\\itemc[.3]$O$\n\t\\end{earg*}\n%\t\\factoidbox{\\eif-Elimination}\n\n\\end{longtabu}\n\\end{exercises}\n\n\\vspace{-8pt}\n\n\\noindent\\problempart \\label{pr.justifySLproof} Fill in the missing pieces in the following proofs. Some are missing the justification column on the right. Some are missing the left column that contains the actual steps, and some are missing lines from both columns.\n%rob: problem one was in the original problem section at the end of Chapter 6. \n\n\\begin{exercises}\n\\vspace{-.5cm}\n\\begin{longtabu}{X[1.4]X[1]} \n\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\\begin{proof}\n\t\\hypo{1}{W \\eif \\enot B}\n\t\\hypo{2}{A \\eand W}\n\t\\hypo{3}{B \\eor (J \\eand K)} \\by{Want: $K$}{}\n\t\\have{4}{W}{} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E,}{2}}{}\n\t\\have{5}{\\enot B} {} \\iflabelexists{showanswers}{\\by{\\color{red}\\eif E,} {1,4}}{}\n\t\\have{6}{J \\eand K} {} \\iflabelexists{showanswers}{\\by{\\color{red}\\eor E}{3,5}}{}\n\t\\have{7}{K}{} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{6}}{}\n\t\\end{proof}\n\n&\n\n\\item \\textcolor{white}{.} \n\\vspace{-16pt}\n\n\t\\begin{proof}\n\t\\hypo{1}{W \\eand B}\n\t\\hypo{2}{E \\eand Z} \\by{Want: $W \\eand Z$}{}\n\t\\have{3}{\\iflabelexists{showanswers}{\\color{red}W}{}} \\by{\\eand E}{1}\n\t\\have{4}{\\iflabelexists{showanswers}{\\color{red}Z}{}} \\by{\\eand E}{2}\n\t\\have{5}{W \\eand Z} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand I}{3, 4}}{}\n\t\\end{proof}\n\n\n\n\\\\\n\n\\item \\textcolor{white}{.} \n\\vspace{-16pt}\n\t\\begin{proof}\n\t\\hypo{1}{(A \\eand B) \\eand C} \\by{Want: $A \\eand (B \\eand C)$}{}\n\t\\have{2}{A \\eand B} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{1}}{}\t\n\t\\have{3}{C} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{1}}{}\n\t\\have{4}{A} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{2}}{}\n\t\\have{5}{B} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{2}}{}\n\t\\have{6}{B \\eand C} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand I}{3,5}}{}\n\t\\have{7}{A \\eand (B \\eand C)} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand I}{4,6}}{}\n\t\\end{proof}\n\n&\n\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\\begin{proof}\n\t\\hypo{1}{(\\enot A \\eand B) \\eif C}\n\t\\hypo{2}{\\enot A}\n\t\\hypo{3}{A \\eor B} \\by{Want: $C$}{}\n\t\\have{4}{\\iflabelexists{showanswers}{\\color{red}B}{}} \\by{\\eor E}{2, 3}\n\t\\have{5}{\\iflabelexists{showanswers}{\\color{red}\\enot A \\eand B}{}} \\by{\\eand I}{2, 4}\n\t\\have{6}{\\iflabelexists{showanswers}{\\color{red}C}{}} \\by{\\eif E}{1, 5}\n\t\\end{proof} \n\n\n%\\iflabelexists{showanswers}{\\by{\\color{red}foo}{bar}}{}\n%\\iflabelexists{showanswers}{\\color{red}Foo}{}\n\\\\\n\\vspace{-1cm}\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\t\\begin{proof}\n\t\\hypo{1}{\\enot A \\eand (\\enot B \\eand C)}\n\t\\hypo{2}{C \\eif (D \\eand (B \\eor E))}\n\t\\hypo{3}{(E \\eand \\enot A) \\eif F}\t\\by{Want: $D \\eand F$}{} \n\t\\have{4}{\\iflabelexists{showanswers}{\\color{red}\\enot A}{}} \\by{\\eand E}{1} \n\t\\have{5}{\\enot B \\eand C} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{1}}{} %\n\t\\have{6}{\\iflabelexists{showanswers}{\\color{red}\\enot B}{}} \\by{\\eand E}{5}\n\t\\have{7}{C} \\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{5}}{} %\n\t\\have{8}{\\iflabelexists{showanswers}{\\color{red}D \\eand (B \\eor E)}{}} \\by{\\eif E}{2, 7} \n\t\\have{9}{D}\\iflabelexists{showanswers}{\\by{\\color{red}\\eand E}{8}}{} %\n\t\\have{10}{\\iflabelexists{showanswers}{\\color{red}B \\eor E}{}} \\by{\\eand E}{8} \n\t\\have{11}{E} \\iflabelexists{showanswers}{\\by{\\color{red}\\eor  E}{6, 10}}{}\n\t\\have[12]{12}{\\iflabelexists{showanswers}{\\color{red}E \\eand \\enot A}{}} \\by{\\eand I}{4, 11} \n\t\\have[13]{13}{F} \\iflabelexists{showanswers}{\\by{\\color{red}\\eif E}{3, 12}}{}\n\t\\have[14]{14}{\\iflabelexists{showanswers}{\\color{red}D \\eand F}{}} \\by{\\eand I}{9, 13} \n\t\\end{proof}\n\n\\end{longtabu}\n\\end{exercises}\n\n\\noindent\\problempart \\label{pr.justifySLproof} Fill in the missing pieces in the following proofs. Some are missing the justification column on the right. Some are missing the left column that contains the actual steps, and some are missing lines from both columns.\n\n\\begin{exercises}\n\\begin{longtabu}{X[1]X[1]} \n\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\t\\begin{proof}\n\t\\hypo{1}{A \\eand \\enot B}\n\t\\hypo{2}{A \\eif \\enot C}\n\t\\hypo{3}{B \\eor (C \\eor D)}\t \\by{Want: $D$}{}\n\t\\have{4}{} \\by{\\eand E}{1}\n\t\\have{5}{} \\by{\\eand E}{1}\n\t\\have{6}{} \\by{\\eif E}{2, 4}\n\t\\have{7}{} \\by{\\eor E}{3, 5}\n\t\\have{8}{} \\by{\\eor E}{6,7}\n\t\\end{proof}\n&\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\t\\begin{proof}\n\t\\hypo{1}{W \\eor V}\n\t\\hypo{2}{I \\eand (\\enot Z \\eif \\enot W)}\n\t\\hypo{3}{I \\eif \\enot Z} \\by{Want: $I \\eand V$}{}\n\t\\have{4}{} \\ae{2}\n\t\\have{5}{} \\ae{2}\n\t\\have{6}{\\enot Z} \\by{}{}\n\t\\have{7}{} \\by{\\eif E}{5, 6}\n\t\\have{8}{V} \\by{}{}\n\t\\have{9}{} \\ai{4,8}\n\t\\end{proof}\n\\\\\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\t\t\n\\begin{proof}\n\\hypo{1}{\\enot P \\eand S) \\eiff S}\n\\hypo{2}{S \\eand (P \\eor Q)} \\by{Want: Q}{}\n\\have{3}{S} \\nix{\\by{\\eand E}{2}}\n\\have{4}{P \\eor Q} \\nix{\\by{\\eand E}{2}}\n\\have{5}{\\enot P \\eand S} \\nix{\\by{\\eiff E}{1, 3}}\n\\have{6}{\\enot P} \\nix{\\by{\\eand E}{5}}\n\\have{7}{Q} \\nix{\\by{\\eor E}{4, 6}}\n\\end{proof}\n\n&\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{1}{C \\eif (A \\eif B)}\n\\hypo{2}{D \\eor C}\n\\hypo{3}{\\enot D} \\by{Want: A \\eif B}{}\n\\have{4}{\\nix{C}} \\by{\\eor E}{2, 3}\n\\have{5}{\\nix{A \\eif B}} \\by{\\eif E}{1, 4}\n\\end{proof}\n\\\\\n\n\\item \\textcolor{white}{.}  \n\\vspace{-16pt}\n\n\t\\begin{proof}\n\t\\hypo{1}{X \\eand (Y \\eand Z)} \\by{Want: $(X \\eor A) \\eand [(Y \\eor B) \\eand (Z \\eand C)]$} {}\n\t\\have{2}{} \\ae{1}\n\t\\have{3}{} \\ae{1}\n\t\\have{4}{} \\ae{3}\n\t\\have{5}{} \\ae{3}\n\t\\have{6}{} \\oi{2}\n\t\\have{7}{} \\oi{4}\n\t\\have{8}{} \\oi{5}\n\t\\have{9}{} \\by{\\eand I}{7,8}\n\t\\have{10}{} \\ai{6,9}\n\t\\end{proof}\n\n\\end{longtabu}\n\\end{exercises}\n\n%%%%%PART E\n\n\\noindent\\problempart Derive the following.\n\n\\begin{enumerate}[label=(\\arabic*)]\n\\item \\{$A \\eif B, A\\} \\sststile{}{} A \\eand B$\n\n\\answer{\n\t\\begin{proof}\n\t\\hypo{1}{A \\eif B}\n\t\\hypo{2}{A} \\by{Want: A \\eand B}{}\n\t\\have{3}{B} \\by{\\eif E}{1,2}\n\t\\have{4}{A \\eand B} \\ai{2,3}\n\t\\end{proof}\n}\n\\item \\{$A \\eiff D, C, [(A \\eiff D) \\eand C] \\eif (C \\eiff B)\\} \\sststile{}{} B$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{A \\eiff D}\n\\hypo{2}{C}\n\\hypo{3}{((A \\eiff D) \\eand C) \\eif (C \\eiff B)} \\by{Want: B}{} \n\\have{4}{(A \\eiff D) \\eand C} \\by{\\eand I}{1, 2}\n\\have{5}{C \\eiff B} \\by{\\eif E}{3, 4}\n\\have{6}{B} \\by{\\eiff E}{2, 5}\n\\end{proof}\n}\n\n\\item \\{$A \\eiff B, B \\eiff C, C \\eif D, A\\} \\sststile{}{} D$\n\n\\answer{\n\t\\begin{proof}\n\t\\hypo{1}{A \\eiff B}\n\t\\hypo{2}{B \\eiff C}\n\t\\hypo{3}{C \\eiff D} \n\t\\hypo{4}{A}\t\\by{Want: D}{}\n\t\\have{5}{B} \\be{1, 4}\n\t\\have{6}{C} \\be{2, 5}\n\t\\have{7}{D} \\be{3, 6}\n\t\\end{proof}\n}\n\n\\item $\\{(A \\eif \\enot B) \\eand A, B \\eor C\\} \\sststile{}{} C$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{(A \\eif \\enot B) \\eand A}\n\\hypo{2}{B \\eor C} \\by{Want: C}{}\n\\have{3}{A \\eif \\enot B} \\by{\\eand E}{1}\n\\have{4}{A}\\by{\\eand E}{1}\n\\have{5}{\\enot B} \\by{\\eif E}{3, 4}\n\\have{6}{C} \\by{\\eor E}{2, 5}\n\\end{proof} \n}\n\n\\item $\\{(A \\eif B) \\eor (C \\eif (D \\eand E)), \\enot (A \\eif B), C\\} \\sststile{}{} D$\n\n\\answer{\n\t\\begin{proof}\n\t\\hypo{1}{(A \\eif B) \\eor (C \\eif (D \\eand E))} \n\t\\hypo{2}{\\enot (A \\eif B)}\n\t\\hypo{3}{C} \\by{Want: D}{}\n\t\\have{4}{C \\eif (D \\eand E)} \\oe{1, 3}\n\t\\have{5}{D \\eand E} \\ce{3, 4}\n\t\\have{6}{D} \\ae{5}\n\t\\end{proof}\n}\n\n\\item $\\{C \\eor (B \\eand  A),  \\enot C\\} \\sststile{}{} A \\eor A$\t\t%requires \\eorI\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{C \\eor (B \\eand A)}\n\\hypo{2}{\\enot C} \\by{Want: A \\eor A}{}\n\\have{3}{B \\eand A} \\oe{1, 2}\n\\have{4}{A} \\ae{3}\n\\have{5}{A \\eor A} \\oe{4}\n\\end{proof}\n}\n\n\\item $\\{A \\eor B, \\enot A, \\enot B\\} \\sststile{}{} C$\t\t\t\t%\\eorIE trick\n\n\\answer{\n\t\\begin{proof}\n\t\\hypo{1}{A \\eor B}\n\t\\hypo{2}{\\enot A}\n\t\\hypo{3}{\\enot B} \\by{Want: C}{}\n\t\\have{4}{B} \\oe{1, 2}\n\t\\have{5}{B \\eor C} \\oi{4}\n\t\\have{6}{C} \\oe{3, 5}\n\t\\end{proof}\n}\n\\end{enumerate}\n\n%%%%PART F\n\n\\noindent\\problempart Derive the following.\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\{A \\eand B, B \\eif C\\} \\sststile{}{} A \\eand (B \\eand C) $ %1\n\n%\\begin{proof}\n%\\hypo{1}{A \\eand B}\n%\\hypo{2}{B \\eif C}\t\\by{Want: A \\eand (B \\eand C)}{}\n%\\have{3}{A} \\ae{1}\n%\\have{4}{B} \\ae{1}\n%\\have{5}{C} \\ce{2, 4}\n%\\have{6}{B \\eand C} \\ai{4, 5}\n%\\have{7}{A \\eand (B \\eand C)} \\ai{3, 6}\n%\\end{proof}\n\n\\item $\\{(P \\eor R) \\eand (S \\eor R), \\enot R \\eand Q\\} \\sststile{}{} P \\eand (Q \\eor R)$\t\t%2\n\\item $\\{(X \\eand Y) \\eif Z, X \\eand W, W \\eif Y\\} \\sststile{}{} Z$ \t%3\n\n%\\begin{proof}\n%\\hypo{1}{(X \\eand Y) \\eif Z}\n%\\hypo{2}{X \\eand W}\n%\\hypo{3}{W \\eif Y} \\by{Want: Z}{}\n%\\have{4}{X} \\ae{2}\n%\\have{5}{W} \\ae{2}\n%\\have{6}{Y} \\ce{3, 5}\n%\\have{7}{X \\eand Y} \\ai{4, 6}\n%\\have{8}{Z} \\ce{1, 7}\n%\\end{proof}\n\n\\item $\\{A \\eor  (B \\eor  G), A \\eor  (B \\eor  H), \\enot A \\eand \\enot B\\} \\sststile{}{} G \\eand H $\t\t%4\n\n\\item $\\{P \\eand (Q \\eand \\enot R), R \\eor T\\} \\sststile{}{} T \\eor S$ \t\t%requires \\eorI\n\\item $\\{((A \\eif D) \\eor B) \\eor C, \\enot C, \\enot B, A\\} \\sststile{}{} D$\n\\item $\\{A \\eor \\enot\\enot B, \\enot B \\eor \\enot C, C \\eor A, \\enot A\\} \\sststile{}{}D\t\t$\t\t\t%\\eorIE trick\n\\end{enumerate}\n\n%%%%%%%% PART G\n\\noindent\\problempart Derive the following.\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $H \\eand A \\sststile{}{} A \\eand H\t$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{H \\eand A} \\by{Want: A \\eand H}{}\n\\have{2}{H} \\by{\\eand E}{1}\n\\have{3}{A} \\by{\\eand E}{1}\n\\have{4}{A \\eand H} \\by{\\eand I}{2, 3}\n\\end{proof}\n}\n\n\\item $\\{{P \\eor Q, D \\eif E, \\enot P \\eand D} \\} \\sststile{}{} E \\eand Q$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{P \\eor Q}\n\\hypo{2}{D \\eif E}\n\\hypo{3}{~P \\eand D}  \\by{Want: E \\eand Q}{}\n\\have{4}{~P} \\by{\\eand E}{3}\n\\have{5}{D} \\by{\\eand E 3}{}\n\\have{6}{Q} \\by{\\eor E}{1, 4}\n\\have{7}{E\t} \\by{\\eif E}{2, 5}\n\\have{8}{E \\eand Q} \\by{\\eand E}{6, 7}\n\\end{proof}\n}\n\n\\item $\\{\\enot A \\eif (A \\eor \\enot C), \\enot A, \\enot C \\eiff D \\} \\sststile{}{} D$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{~A \\eif (A \\eor ~C)}\n\\hypo{2}{~A}\n\\hypo{3}{~C \\eiff D} \\by{Want: D}{}\n\\have{4}{A \\eor ~C} \\by{\\eif E}{1, 2}\n\\have{5}{~C} \\by{\\eor E} {2, 4}\n\\have{6}{D} \\by{\\eiff E}{3, 5}\n\\end{proof}\n}\n\n\\item $\\{\\enot A \\eand C, A \\eor B, (B \\eand C) \\eif (D \\eand E) \\} \\sststile{}{} D$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{~A \\eand C}\n\\hypo{2}{A \\eor B}\n\\hypo{3}{(B \\eand C) \\eif (D \\eand E)} \\by{Want: D}{}\n\\have{4}{~A} \\by{\\eand E}{1}\n\\have{5}{C} \\by{\\eand E}{1}\n\\have{6}{B} \\by{\\eor E}{2, 4}\n\\have{7}{B \\eand C} \\by{\\eand E}{5, 6}\n\\have{8}{D \\eand E} \\by{\\eif E}{3, 7}\n\\have{9}{D}\\by{\\eand E}{8}\n\\end{proof}\n}\n\n\\item $\\{A \\eif (B \\eif (C \\eif D)), A \\eand (B \\eand C) \\} \\sststile{}{} D$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{A \\eif (B \\eif (C \\eif D))}\n\\hypo{2}{A \\eand (B \\eand C)} \\by{Want: D}{}\n\\have{3}{A} \\by{\\eand E}{2}\n\\have{4}{B \\eand C} \\by{\\eand E}{2}\n\\have{5}{B} \\by{\\eand E}{4}\n\\have{6}{C} \\by{\\eand E}{4}\n\\have{7}{B \\eif (C \\eif D)} \\by{\\eif E}{1, 3}\n\\have{8}{C \\eif D} \\by{\\eif E}{5, 7}\n\\have{9}{D} \\by{\\eif E}{6, 8}\n\\end{proof}\n}\n\n\n\\item $\\{E \\eor F, F \\eor G, \\enot F\\} \\sststile{}{} E \\eand G$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{E \\eor F}\n\\hypo{2}{F\\eor G}\n\\hypo{3}{\\enot F} \\by{Want: $E \\eand G$}{}\n\\have{4}{E} \\by{\\eor E}{1, 3}\n\\have{5}{G} \\by{\\eor E}{2, 3}\n\\have{6}{E \\eand G} \\by{\\eand I}{4, 5}\n\\end{proof}\n}\n\n\n\\item $\\{X \\eand (Z \\eor Y), \\enot Z, Y \\eif \\enot X\\} \\sststile{}{} A$  %\\eorIE trick\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{X \\eand (Z \\eor Y)}\n\\hypo{2}{\\enot Z}\n\\hypo{3}{Y \\eif \\enot X} \\by{Want: $A$}{}\n\\have{4}{X} \\by{\\eand E}{1}\n\\have{5}{Z \\eor Y} \\by{\\eand E}{1}\n\\have{6}{Y} \\by{\\eor E}{2, 5}\n\\have{7}{\\enot X} \\by{\\eif E}{3, 6}\n\\have{8}{X \\eor A} \\by{\\eor I}{4}\n\\have{9}{A} \\by{\\eor E}{7, 8}\n\\end{proof}\n}\n\n\\end{enumerate}\n\n%%%%%%PART H\n\n\n\\noindent\\problempart Derive the following.\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\{P \\eiff (Q \\eiff R)$,$ P$,$ P \\eif R\\} \\sststile{}{} Q$\n\n\\item $\\{A \\eif (B \\eif C), A, B\\} \\sststile{}{}C$\n\\item $\\{(X \\eor A) \\eif \\enot Y, Y \\eor (Z \\eand Q), X\\} \\sststile{}{}Z\t$\n\\item $\\{A \\eand (B \\eand C), A \\eand D, B \\eand E\\} \\sststile{}{}D \\eand (E \\eand C)\t\t$\n\\item $\\{A \\eand (B \\eor \\enot C), \\enot B \\eand (C \\eor E), E \\eif D \\} \\sststile{}{} D$\n\n%1.             A & (B ˅ ~C)\n%2.             ~B & (C ˅ E)\n%3.             E → D                                    Want: D\n%4.             A                                                             &-E 1      \n%5.             B ˅ ~C                                   &-E 1\n%6.             ~B                                                           &-E 2\n%7.             C ˅ E                                      &-E 2\n%8              ~C                                                            ˅E 5, 6\n%9.             E                                                               ˅E 7, 8\n%10.           D                                                             →E 3,10\n\n\\item $\\{A \\eif B, B \\eif C, C \\eif A, B, \\enot A\\} \\sststile{}{}D\t$  %\\eorIE trick\n\\item $\\{\\enot A \\eand B, A \\eor P, A \\eor Q, B \\eif R \\} \\sststile{}{} P \\eand (Q\\eand R)$\n\n\n\\end{enumerate}\n\n\\noindent\\problempart Translate the following arguments into SL and then show that they are valid. Be sure to write out your dictionary. \n\\begin{enumerate}[label=(\\arabic*)]\n\\item If Professor Plum did it, he did it with the rope in the kitchen. Either Professor Plum or Miss Scarlett did it, and it wasn't Miss Scarlett. Therefore the murder was in the kitchen.  \n%rob: note to self: problem 1 taken from test 4 SP08.\n\n\\answer{\nA: Professor Plum did it \\\\\nB: The murder was committed in the kitchen \\\\\nC: The murder was committed with the rope\\\\\nD: Miss Scarlett did it\n\n\n\\begin{proof}\n\\hypo{1}{A \\eif (B \\eand C)}\n\\hypo{2}{(A \\eor D) \\eand \\enot D} \\by{Want: B}{}\n\\have{3}{A \\eor D} \\ae{2}\n\\have{4}{\\enot D} \\ae{2}\n\\have{5}{A} \\oe{3, 4}\n\\have{6}{B \\eand C} \\ce{1, 5}\n\\have{7}{B} \\ae{6}\n\\end{proof}\n}\n\n\\item If you are going to replace the bathtub, you might as well redo the whole bathroom. If you redo the whole bathroom, you will have to replace all the plumbing on the north side of the house. You will spend a lot of money on this project if and only if you replace the plumbing on the north side of the house. You are definitely going to replace the bathtub. Therefore you will spend a lot of money on this project. \n\n\\answer{\nA: You are going to replace the bathtub \\\\\nB: You redo the whole bathroom.  \\\\\nC: You replace all the plumbing on the north side of the house. \\\\\nD: You will spend a lot of money on this project  \\\\ \n\n\n\\begin{proof}\n\\hypo{1}{A \\eif B}\n\\hypo{2}{B \\eif C}\n\\hypo{3}{C \\eiff D}\n\\hypo{4}{A} \\by{Want: D}{}\n\\have{5}{B} \\by{\\eif E}{1, 4}\n\\have{6}{C} \\by{\\eif E}{2, 5}\n\\have{7}{D}  \\by{\\eiff E}{3, 6}\n\\end{proof}\n}\n\n\\end{enumerate}\n\n\\noindent\\problempart\nTranslate the following arguments into SL and then show that they are valid. Be sure to write out your dictionary. \n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item Either Caroline is happy, or Joey is happy, but not both. If Joey teases Caroline, she is not happy. Joey is teasing Caroline. Therefore, Joey is happy.\n\n%A: Caroline is happy. \\hspace{.25in}\n%B: Joey is happy.\\hspace{.25in}\n%C: Joey teases Caroline. \\\\\n%\n%\\begin{proof}\n%\\hypo{1}{(A \\eor B) \\eand \\enot(A \\eand B)}\n%\\hypo{2}{C \\eif \\enot A}\n%\\hypo{3}{C} \\by{Want: B}{}\n%\\have{4}{A \\eor B} \\ae{1}\n%\\have{5}{\\enot A} \\ce{2, 3}\n%\\have{6}{B} \\oe{4,5}\n%\\end{proof}\n\n\\item Either grass is green or one of two other things: the sky is blue or snow is white. If my lawn is brown, the sky is gray, and if the sky is gray, it is not blue. If my lawn is brown, then grass is not green, and on top of that my lawn is brown. Therefore snow is white.\n%rob: note to self: replace this with a better problem sometime.\n\n\\end{enumerate}\n\n% *******************************************\n% *\t\t\tConditional Proof\t\t\t\t\t   *\t\n% *******************************************\n\\section{Conditional Proof}\n\\label{sec:conditional_proof}\n\\setlength{\\parindent}{1em}\n%I separated this out from the first section. \n\nSo far we have introduced introduction and elimination rules for the conjunction and disjunction, and elimination rules for the conditional and biconditional, but we have no introduction rules for conditionals and biconditionals, and no rules at all for negations. That's because these other rules require fancy kinds of derivations that involve putting proofs inside proofs. In this section, we will look at one of these kinds of proof, called conditional proof.\n\n%rob: added a transition paragraph.\n\n\\subsection{Conditional introduction}\nConsider this argument:\n\\begin{earg*}\n\\item $R \\eor F$\n\\itemc[.15] $\\enot R \\eif F$\n\\end{earg*}\nThe argument is valid. You can use the truth table to check it. Unfortunately, we don't have a way to prove it in our syntactic system of derivation. To help us see what our rule for \nconditional introduction should be, we can try to figure out what new rule would let us prove this obviously true argument.\n\nLet's start the proof in the usual way, like this:\n\n\\begin{proof}\n\t\\hypo{rf}{R \\eor F} \\by{Want: \\enot R \\eif F}{}\n\\end{proof}\n\nIf we had $\\enot R$ as a further premise, we could derive $F$ by the {\\eor}E rule. But sadly, we do not have $\\enot R$ as a premise, and we can't derive it directly from the premise we do have---so we cannot simply prove $F$. What we will do instead is start a \\emph{subproof}, a proof within the main proof. When we start a subproof, we draw another vertical line to indicate that we are no longer in the main proof. Then we write in an assumption for the subproof. This can be anything we want. Here, it will be helpful to assume $\\enot R$. Our proof now looks like this:\n\n\\begin{proof}\n\t\\hypo{rf}{R \\eor F}\\by{Want: \\enot R \\eif F}{}\n\t\\open\n\t\t\\hypo{nr}{\\enot R}\\by{Assumption for CD, Want: F}{}\n\t\\close\n\\end{proof}\n\nIt is important to notice that we are not claiming to have proved $\\enot R$. We do not need to write in any justification for the assumption line of a subproof. You can think of the subproof as posing the question: What could we show \\emph{if} $\\enot R$ were true? For one thing, we can derive $F$. To make this completely clear, I have annotated line 2 ``Assumption for CD,'' to indicate that this is an additional assumption we are making because we are using conditional derivation (CD). I have also added ``Want: F'' because that is what we will want to show during the subderivation. In the future I won't always include all this information in the annotation. But for now we will use it to be completely clear on what we will be doing.\n\nSo now let's go ahead and show F in the subderivation. \n\n\\begin{proof}\n\t\\hypo{rf}{R \\eor F}\\by{Want: \\enot R \\eif F}{}\n\t\\open\n\t\t\\hypo{nr}{\\enot R}\\by{Assumption for CD, Want: F}{}\n\t\t\\have{f}{F}\\oe{rf, nr}\n\t\\close\n\\end{proof}\n\nThis has shown that \\emph{if} we had $\\enot R$ as a premise, \\emph{then} we could prove $F$. In effect, we have proven $\\enot R \\eif F$. So the \nconditional introduction rule ({\\eif}I) will allow us to close the subproof and derive $\\enot R \\eif F$ in the main proof. Our final proof looks like this:\n\n\\begin{proof}\n\t\\hypo{rf}{R \\eor F}\\by{Want: \\enot R \\eif F}{}\n\t\\open\n\t\t\\hypo{nr}{\\enot R}\\by{Assumption for CD, Want: F}{}\n\t\t\\have{f}{F}\\oe{rf, nr}\n\t\\close\n\t\\have{nrf}{\\enot R \\eif F}\\ci{nr-f}\n\\end{proof}\n\nNotice that the justification for applying the {\\eif}I rule is the entire subproof. Usually that will be more than just two lines.\n\n%rob, I added a paragraph explaining the precise rules that govern subproofs and folded some later material into that paragraph\n\nNow that we have that example, let's lay out more precisely the rules for subproofs and then give the formal schemes for the rule of conditional and biconditional introduction. \n\n\\begin{enumerate}[leftmargin=1.5cm]\n\\item[\\define{Rule 1}] You can start a subproof on any line, except the last one, and introduce any assumptions with that subproof.\n\\item[\\define{Rule 2}] All subproofs must be closed by the time the proof is over.\n\\item[\\define{Rule 3}] Subproofs may closed at any time. Once closed, they can be used to justify \\eif I, \\eiff I, \\enot E, and \\enot I.\n\\item[\\define{Rule 4}] Nested subproofs must be closed before the outer subproof is closed.\n\\item[\\define{Rule 5}] Once the subproof is closed, lines in the subproof cannot be used in later justifications.\n\\end{enumerate}\n\nRule 1 gives you great power. You can assume anything you want, at any time. But with great power, comes great responsibility, and rules 2--5 explain what your responsibilities are. Making an assumption creates the burden of starting a subproof, and subproofs must end before the proof is done. (That's why we can't start a subproof on the last line.) Closing a subproof is called \\emph{discharging} the assumptions of that subproof. So we can summarize your responsibilities this way: You cannot complete a proof until you have discharged all of the assumptions introduced in subproofs. Once the assumptions are discharged, you can use the whole subproof as a justification, but not the individual lines. So you need to know going into the subproof what you are going to use it for once you get out. As in so many parts of life, you need an exit strategy.  \n\nWith those rules for subproofs in mind, the {\\eif}I rule looks like this:\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{a}{\\script{A}} \\by{want \\script{B}}{}\n\t\t\\have[n]{b}{\\script{B}}\n\t\\close\n\t\\have[\\ ]{ab}{\\script{A}\\eif\\script{B}}\\ci{a-b}\n\\end{proof}\n\nYou still might think this gives us too much power. In logic, the ultimate sign you have too much power is that given any premise \\script{A} you can prove any conclusion \\script{B}. Fortunately, our rules for subproofs don't let us do this. Imagine a proof that looks like this:\n\n\\begin{proof}\n\t\\hypo{a}{\\script{A}}\n\t\\open\n\t\t\\hypo{b1}{\\script{B}}\n\\end{proof}\n\nIt may seem as if a proof like this will let you reach any conclusion \\script{B} from any premise \\script{A}. But this is not the case. By rule 2, in order to complete a proof, you must close all of the subproofs, and we haven't done that. A subproof is only closed when the vertical line for that subproof ends. To put it another way, you  can't end a proof and still have two vertical lines going. \n\nYou still might think this system gives you too much power. Maybe we can try closing the subproof and writing \\script{B} in the main proof, like this \n\n\\begin{proof}\n\t\\hypo{a}{\\script{A}}\n\t\\open\n\t\t\\hypo{b1}{\\script{B}}\n\t\t\\have{b2}{\\script{B}} \\by{R}{b1}\n\t\\close\n\t\\have{b}{\\script B} \\by{R}{b2}\n\\end{proof}\n\nBut this is wrong, too. By rule 5, once you close a subproof, you cannot refer back to individual lines inside it.\n\nOf course, it is legitimate to do this:\n\n\\begin{proof}\n\t\\hypo{a}{\\script{A}}\n\t\\open\n\t\t\\hypo{b1}{\\script{B}}\n\t\t\\have{b2}{\\script{B}} \\by{R}{b1}\n\t\\close\n\t\\have{bb}{\\script{B}\\eif\\script{B}} \\ci{b1-b2}\n\\end{proof}\n\nThis should not seem so strange, though. Since \\script{B}\\eif\\script{B} is a tautology, no particular premises should be required to validly derive it. (Indeed, as we will see, a tautology follows from any premises.)\n\nWhen we introduce a subproof, we typically write what we want to derive in the right column, just like we did in the first example in this section. This is just so that we do not forget why we started the subproof if it goes on for five or ten lines. There is no ``want'' rule. It is a note to ourselves and not formally part of the proof.\n\nHaving an exit strategy when you launch a subproof is crucial. Even if you discharge an assumption properly, you might wind up with a final line that doesn't do you any good. In order to derive a conditional by {\\eif}I, for instance, you must assume the antecedent of the conditional in a subproof. The last line of the subproof must be the consequent of the conditional, and the whole conditional is the first line after the end of the subproof. Pick your assumptions so that you wind up with a conditional that you actually need. It is always permissible to close a subproof and discharge its assumptions, but it will not be helpful to do so until you get what you want.\n\n%This is also moved from the conditional section\n\nNow that we have the rule for conditional introduction, consider this argument:\n\\label{proofHS}\n\\begin{earg*}\n\\item $P \\eif Q$\n\\item $Q \\eif R$\n\\itemc[.15] $P \\eif R$\n\\end{earg*}\nWe begin the proof by writing the two premises as assumptions. Since the main logical operator in the conclusion is a conditional, we can expect to use the {\\eif}I rule. For that, we need a subproof---so we write in the antecedent of the conditional as an assumption of a subproof:\n\n\\begin{proof}\n\t\\hypo{pq}{P \\eif Q}\n\t\\hypo{qr}{Q \\eif R}\n\t\\open\n\t\t\\hypo{p}{P}\n\t\\close\n\\end{proof}\n\nWe made $P$ available by assuming it in a subproof, allowing us to use {\\eif}E on the first premise. This gives us $Q$, which allows us to use {\\eif}E on the second premise. Having derived  $R$, we close the subproof. By assuming $P$ we were able to prove $R$, so we apply the {\\eif}I rule and finish the proof.\n\n\\label{HSproof}\n\\begin{proof}\n\t\\hypo{pq}{P \\eif Q}\n\t\\hypo{qr}{Q \\eif R}\n\t\\open\n\t\t\\hypo{p}{P}\\by{want $R$}{}\n\t\t\\have{q}{Q}\\ce{pq,p}\n\t\t\\have{r}{R}\\ce{qr,q}\n\t\\close\n\t\\have{pr}{P \\eif R}\\ci{p-r}\n\\end{proof}\n\n\n\\subsection{Biconditional introduction}\n\nJust as the rule for biconditional elimination was a double-headed version of conditional elimination, our rule for biconditional introduction is a double-headed version of conditional introduction. In order to derive $W \\eiff X$, for instance, you must be able to prove $X$ by assuming $W$ \\emph{and} prove $W$ by assuming $X$. The biconditional introduction rule ({\\eiff}I) requires two subproofs. The subproofs can come in any order, and the second subproof does not need to come immediately after the first---but schematically, the rule works like this:\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{a1}{\\script{A}} \\by{want \\script{B}}{}\n\t\t\\have[n]{b1}{\\script{B}}\n\t\\close\n\t\\open\n\t\t\\hypo[p]{b2}{\\script{B}} \\by{want \\script{A}}{}\n\t\t\\have[q]{a2}{\\script{A}}\n\t\\close\n\t\\have[\\ ]{ab}{\\script{A}\\eiff\\script{B}}\\bi{a1-b1,b2-a2}\n\\end{proof}\n\nWe will call any proof that uses subproofs and either \\eif I or \\eiff I \\define{conditional proof}. By contrast, the first kind of proof you learned, where you only use the six basic \nrules, will be called \\define{direct proof}. In section \\ref{sec:indirect_proof} we will learn the third and final kind of proof \\emph{indirect proof}. But for now you should practice \nconditional proof.\n\n%%%%%%Practice Problems %%%%%%%%%%%%%%%\n\\practiceproblems\n\\noindent\\problempart Fill in the blanks in the following proofs. Be sure to include the ``Want'' line for each subproof.  %!@#$\n\n\\begin{exercises}\n\\item  \\textcolor{white}{.} % $\\{\\enot P \\eif (Q \\eor R), P \\eor \\enot Q\\} \\sststile{}{} \\enot P \\eif R$\n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{1}{\\enot P \\eif (Q \\eor R)}\n\\hypo{2}{P \\eor \\enot Q}  \\by{Want: \\enot P \\eif R}{}\n\\open\n\\hypo{3}{\\enot P} \\by{Want: \\iflabelexists{showanswers}{\\color{red} R}{}}{} \n\\have{4}{Q \\eor R}   \\iflabelexists{showanswers}{\\by{\\color{red} \\eif E}{1, 3}}{}\n\\have{5}{\\iflabelexists{showanswers}{\\color{red}\\enot Q}{}} \\oe{2, 3}\n\\have{6}{R}  \\iflabelexists{showanswers}{\\by{\\color{red} \\eor E}{2, 3}}{}\n\\close\n\\have{7}{\\enot P \\eif R} \\iflabelexists{showanswers}{\\by{\\color{red} \\eif I}{3-6}}{}\n\\end{proof}\n\n%\\begin{proof}\n%\\hypo{1}{\\enot P \\eif (Q \\eor R)}\n%\\hypo{2}{P \\eor \\enot Q}  \\by{Want: \\enot P \\eif R}{}\n%\\open\n%\\hypo{3}{\\enot P} \\by{Want: R}{}\n%\\have{4}{Q \\eor R} \\ce{1, 3}\n%\\have{5}{\\enot Q} \\oe{2, 3}\n%\\have{6}{R} \\oe{4,5}\n%\\close\n%\\have{7}{\\enot P \\eif R} \\ci{3-6}\n%\\end{proof}\n\n\\item  \\textcolor{white}{.} \\\\ % $\\{\\enot P \\eif (Q \\eor R), P \\eor \\enot Q\\} \\sststile{}{} \\enot P \\eif R$\n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{1}{A \\eor B}\n\\hypo{2}{B \\eif (B \\eif \\enot A)} \\by{Want: \\enot A \\eiff B}{}\n\t\\open\n\t\\hypo{3}{\\enot A} \\by{Want: \\iflabelexists{showanswers}{\\color{red}B}{}}{}\n\t\\have{4}{\\iflabelexists{showanswers}{\\color{red}B}{}} \\by{\\eor E}{1, 3}\n\t\\close\n\t\\open\n\t\\hypo{5}{B} \\by{Want: \\iflabelexists{showanswers}{\\color{red}\\enot A}{}}{}\n\t\\have{6}{B \\eif \\enot A} \\iflabelexists{showanswers}{ \\by{\\color{red}\\eif E}{2, 3}}{} % \n\t\\have{7}{\\iflabelexists{showanswers}{\\color{red}\\enot A}{}} \\by{\\eif E}{5, 6}\n\t\\close\n\\have{8}{\\enot A \\eiff B} \\iflabelexists{showanswers}{\\by{\\color{red}\\eiff I}{3-4, 5-7}}{}\n\\end{proof}\n\\end{exercises}\n\n \n\\noindent\\problempart Fill in the blanks in the following proofs. Be sure to include the ``Want'' line for each subproof. \n\n\\begin{exercises}\n\n\\item \\textcolor{white}{.} \\\\ % $\\{\\enot P \\eif (Q \\eor R), P \\eor \\enot Q\\} \\sststile{}{} \\enot P \\eif R$\n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{1}{B \\eif \\enot D}\n\\hypo{2}{A \\eif (D \\eor C)}  \\by{Want: $A \\eif (B \\eif C)$}{}\n\\open\n\\hypo{3}{A} \\by{ }{}\n\\open \n\\hypo{4}{} \\by{Want: C}{}\n\\have{5}{} \\ce{2, 3}\n\\have{6}{} \\ce{1, 4}\n\\have{7}{} \\oe{5, 6}\n\\close\n\\have{8}{} \\ci{4-7}\n\\close\n\\have{9}{} \\ci{3-8}\n\\end{proof}\n\n%\\item $B \\eif \\enot D, A \\eif (D \\eor C) $\\therefore$ A \\eif (B \\eif C)$\n%\\begin{proof}\n%\\hypo{1}{B \\eif \\enot D}\n%\\hypo{2}{A \\eif (D \\eor C)}  \\by{Want: A \\eif (B \\eif C)}{}\n%\\open\n%\\hypo{3}{A} \\by{Want: B \\eif C}{}\n%\\open \n%\\hypo{4}{B} \\by{Want: C}{}\n%\\have{5}{D \\eor C} \\ce{2, 3}\n%\\have{6}{\\enot D} \\ce{1, 4}\n%\\have{7}{C} \\oe{5, 6}\n%\\close\n%\\have{8}{B \\eif C} \\ci{4-7}\n%\\close\n%\\have{9}{A \\eif (B \\eif C)} \\ce{3-8}\n%\\end{proof}\n\n\n\\item \\textcolor{white}{.} \\\\ \n\\vspace{-16pt}\n\n\\begin{proof}\n\\hypo{1}{(G \\eor H) \\eif (S \\eand T)}\n\\hypo{2}{(T \\eor U) \\eif (C \\eand D)}\t\\by{Want: $G \\eif C$}{}\n\t\\open\n\t\\hypo{3}{\\nix{G}} \\by{Want: C}{}\n\t\\have{4}{G \\eor H} \\nix{\\by{\\eor I}{3}}\n\t\\have{5}{\\nix{S \\eor T}} \\by{\\eif E}{1, 4}\n\t\\have{6}{T} \\nix{\\by{\\eand E}{5}}\n\t\\have{7}{\\nix{T \\eor U}} \\by{\\eor I}{6}\n\t\\have{8}{C \\eand D} \\nix{\\by{\\eif E}{2, 7}}\n\t\\have{9}{\\nix{C}}\t\\by{\\eand E}{8}\n\t\\close\n\\have{10}{\\nix{G \\eif C}} \\by{\\eif I}{3-9}\n\\end{proof}\n\\end{exercises}\n\n\\noindent\\problempart Derive the following \n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item\t$\\{S \\eor Q, Q \\eif P \\}\\sststile{}{} \\enot S \\eif P  $ %Basic conditional\t\t\t\t\t\t\t\t\t\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{S \\eor Q}\n\\hypo{2}{Q \\eif P} \\by{Want: $\\enot S \\eif P$}{}\n\\open\n\\hypo{3}{\\enot S} \\by{Want: P}{}\n\\have{4}{Q} \\oe{1, 3}\n\\have{5}{P} \\ce{2, 4}\n\\close\n\\have{6}{\\enot S \\eif P} \\by{\\eif E}{3-5}\n\\end{proof}\n}\n\n\n\\item\t$\\{A \\eif C, B \\eif D\\}\\sststile{}{}  (A \\eand B) \\eif (C \\eand D)$ %Basic conditional\t\t\t\t\t\n\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{A \\eif C}\t\n\\hypo{2}{B \\eif D} \\by{Want: $(A \\eand B) \\eif (C \\eand D)$}{}\n\\open\n\\hypo{3}{A \\eand B} \\by{Want: C \\eand D}{}\n\\have{4}{A} \\ae{3}\n\\have{5}{B} \\ae{3}\n\\have{6}{C} \\ce{1, 4}\n\\have{7}{D} \\ce{2, 5}\n\\have{8}{C \\eand D} \\ai{6, 7}\n\\close\n\\have{9}{(A \\eand B) \\eif (C \\eand D)} \\by{\\eif I}{3-8}\n\\end{proof}\n}\n\n\n\\item $\\{K\\eand L\\} \\sststile{}{} K\\eiff L$ %Basic biconditional\n%originally Chapter 6, part B, number 1\n\\answer{\n\\begin{proof}\n\\hypo{1}{K \\eand L} \\by{want: $K \\eiff L$}{}\n\\open\n\\hypo{2}{K} \\by{Want: L}{}\n\\have{3}{L} \\ae{1}\n\\close\n\\open\n\\hypo{4}{L} \\by{Want: K}{}\n\\have{5}{K} \\ae{1}\n\\close\n\\have{6}{K \\eiff L} \\by{\\eiff E}{4-5, 6-7}\n\\end{proof}\n}\n\n\\item $\\{A\\eif (B\\eif C)\\} \\sststile{}{} (A\\eand B)\\eif C$ % Basic conditional, tempted to do the wrong thing\n%originally Chapter 6, part B, number 2\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{A\\eif (B\\eif C)} \\by{$(A\\eand B)\\eif C$}{}\n\\open\n\\hypo{2}{A \\eand B} \\by{Want: C}{}\n\\have{3}{A} \\ae{2}\n\\have{4}{B} \\ae{2}\n\\have{5}{B \\eif C} \\ce{1, 3}\n\\have{6}{C} \\ce{4, 5}\n\\close\n\\have{7}{(A \\eand B) \\eif C} \\by{\\eif I}{2--6}\n\\end{proof}\n}\n\n\\item $\\{A\\eiff B, B\\eiff C\\} \\sststile{}{} A\\eiff C$ %Basic biconditional\n%originally Chapter 6, part C, number 4\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{A \\eiff B}\n\\hypo{2}{B \\eiff C} \\by{Want: $A \\eiff C$}{}\n\\open\n\\hypo{3}{A} \\by{Want: C}{}\n\\have{4}{B} \\by{\\eiff E}{1, 3}\n\\have{5}{C} \\by{\\eiff E}{2, 4}\n\\close\n\\open\n\\hypo{6}{C} \\by{Want: A}{}\n\\have{7}{B} \\by{\\eiff E}{2, 6}\n\\have{8}{A} \\by{\\eiff E}{1, 7}\n\\close\n\\have{9}{A \\eiff C} \\by{\\eiff I}{3--5, 6--8}\n\\end{proof}\n}\n\n\\item $\\{P \\eif (Q \\eif R)\\} \\sststile{}{} Q \\eif (P \\eif R)$ %two subproofs\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{P \\eif (Q \\eif R)} \\by{Want: $Q \\eif (P \\eif R)$}{}\n\\open\n\\hypo{2}{Q} \\by{Want: $P \\eif R$}{}\n\\open\n\\hypo{3}{P} \\by{Want: $R$}{}\n\\have{4}{Q \\eif R} \\ce{1, 3}\n\\have{5}{R} \\ce{2, 4}\n\\close\n\\have{6}{P \\eif R} \\by{\\eif I}{3-5}\n\\close \n\\have{7}{Q \\eif (P \\eif R)} \\by{\\eif I}{2-6}\n\\end{proof}\n}\n\n\n\\item $\\{\\enot A, (B \\eand C) \\eif D\\} \\sststile{}{}(A \\eor B) \\eif (C \\eif D)$ %two subproofs  Modified from KMR T107 p. 82.\n\n\\answer{\n\\begin{proof}\n\n\\hypo{1}{\\enot A}\n\\hypo{2}{(B \\eand C) \\eif D} \\by{Want: (A \\eor B) \\eif (C \\eif D}{}\n\\open\n\\hypo{3}{A \\eor B} \\by{Want: C \\eif D}{}\n\\open\n\\hypo{4}{C}  \\by{Want: D}{}\n\\have{5}{B} \\oe{1, 4}\n\\have{6}{B \\eand C} \\ai{4, 5}\n\\have{7}{D} \\ce{2, 6}\n\\close\n\\have{8}{C \\eif D} \\ci{4-7}\n\\close\n\\have{9}{(A \\eor B) \\eif (C \\eif D)} \\ci{3-8}\n\\end{proof}\n}\n\n\n\n\n\n\\end{enumerate}\t\n\n\\noindent\\problempart Derive the following \n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\{X \\eiff (A \\eand B), B \\eiff Y, B \\eif A\\} \\sststile{}{} X \\eiff Y$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{X \\eiff (A \\eand B)}\n\\hypo{2}{B \\eiff Y}\n\\hypo{3}{B \\eif A} \\by{Want: X \\eiff Y}{} \n\\open\n\\hypo{4}{X} \\by{Want: Y}{}\n\\have{5}{A \\eand B} \\by{\\eiff E}{1, 4}\n\\have{6}{B} \\ae{5}\n\\have{7}{Y} \\by{\\eiff E}{2, 6}\n\\close\n\\open\n\\hypo{8}{Y} \\by{Want: X}{}\n\\have{9}{B} \\by{\\eiff E}{2, 8}\n\\have{10}{A} \\ce{3, 9}\n\\have{11}{A \\eand B} \\ai{9, 10}\n\\have{12}{X} \\by{\\eiff E}{1, 12}\n\\close\n\\have{13}{X \\eiff Y} \\by{\\eiff I}{4-7, 8-12} \n\\end{proof}\n}\n\n\\item $\\{B \\eif \\enot E, A \\eif \\enot D, D \\eor (E \\eor R), (R \\eand A) \\eif C\\} \\sststile{}{} A \\eif (B \\eif C)$ \n\n\\answer{\n\\begin{proof}\n\\hypo{}{B \\eif \\enot E}\n\\hypo{}{A \\eif \\enot D}\n\\hypo{}{D \\eor (E \\eor R)}\n\\hypo{}{(R \\eand A) \\eif C}\t\\by{Want: A \\eif (B \\eif C)}{} \n\\open\n\\hypo{}{A}\t\\by{Want: B \\eif C}{}\n\\open\n\\hypo{}{B}\t\\by{Want: C}{}\n\\have{}{\\enot E} \\by{\t\\eif E 1, 6}{}\n\\have{}{\\enot D} \\by{\\eif E 2, 5}{}\n\\have{}{E \\eor R} \\by{\\eor E 3, 7}{}\n\\have{}{R} \\by{\\eor E 7, 9}{}\n\\have{}{R \\eand} \\by{\\eand I 5, 10}{}\n\\have{}{C\t} \\by{\\eif E 4, 11}{}\n\\close\n\\have{}{B \\eif C} \\by{\\eif I 6-12}{}\n\\close\n\\have{}{A \\eif (B \\eif C)} \\by{\\eif I 5-13}{}\n\\end{proof}\n}\n\n\n\\item $\\{\\enot W \\eand \\enot E, Q \\eiff D\\} \\sststile{}{} (W \\eor Q) \\eiff (E \\eor D)$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{\\enot W \\eand \\eand E} \n\\hypo{2}{Q \\eiff D} \\by{Want: (W \\eor Q) \\eiff (E \\eor D)}{}\n\\have{3}{\\enot W} \\ae{1}\n\\have{4}{\\enot E} \\ae{1}\n\\open\n\\hypo{5}{W \\eor Q} \\by{Want: E \\eor D}{}\n\\have{6}{Q} \\oe{3, 5}\n\\have{7}{D} \\by{\\eiff E}{2, 6}\n\\have{8}{E \\eor D} \\oi{7}\n\\close\n\\open\n\\hypo{9}{E \\eor D} \\by{Want: W \\eor Q}{}\n\\have{10}{D} \\oe{4, 9}\n\\have{11}{Q} \\by{\\eiff E}{2, 10}\n\\have{12}{W \\eor Q} \\oi{11}\n\\close\n\\have{13}{(W \\eor Q) \\eiff (E \\eor D)} \\ci{5-8, 9-12}\n\\end{proof}\n}\n\n\n\\item $\\{(A \\eand B) \\eiff D, D \\eiff (X \\eand Y), C \\eiff Z\\} \\sststile{}{} A \\eand (B \\eand C) \\eiff X \\eand (Y \\eand Z)$ %long biconditional\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{(A \\eand B) \\eiff D}\n\\hypo{2}{D \\eiff (X \\eand Y)}\n\\hypo{3}{C \\eiff Z} \\by{A \\eand (B \\eand C) \\eiff X \\eand (Y \\eand Z)}{}\n\t\\open\n\t\\hypo{4}{A \\eand (B \\eand C)} \\by{Want: X \\eand (Y \\eand Z)}{}\n\t\\have{5}{A} \\ae{4}\n\t\\have{6}{B \\eand C} \\ae{4}\n\t\\have{7}{B} \\ae{6}\n\t\\have{8}{C} \\ae{6}\n\t\\have{9}{Z} \\by{\\eiff-E}{3, 8}\n\t\\have{10}{A \\eand B} \\ai{5, 7}\n\t\\have{11}{D} \\by{\\eiff-E}{1, 10}\n\t\\have{12}{X \\eand Y}  \\by{\\eiff-E}{2, 11}\n\t\\have{13}{X} \\ae{12}\n\t\\have{14}{Y} \\ae{12}\n\t\\have{15}{Y \\eand Z} \\ai{13, 14}\n\t\\have{16}{X \\eand (Y \\eand Z)} \\ai{13, 15}\n\t\\close\n\t\n\t\\open\n\t\\hypo{17}{X \\eand (Y \\eand Z)} \\by{Want: A \\eand (B \\eand C)}{} \n\t\\have{18}{X} \\ae{17}\n\t\\have{19}{Y \\eand Z} \\ae{17}\n\t\\have{20}{Y} \\ae{19}\n\t\\have{21}{Z} \\ae{19}\n\t\\have{22}{C}  \\by{\\eiff-E}{3, 22}\n\t\\have{23}{X \\eand Y} \\ai{18, 20}\n\t\\have{24}{D}  \\by{\\eiff-E}{2, 23}\n\t\\have{25}{A \\eand B}  \\by{\\eiff-E}{1, 24}\n\t\\have{26}{A} \\ae{25}\n\t\\have{27}{B} \\ae{25}\n\t\\have{28}{B \\eand C} \\ai{22, 27}\n\t\\have{29}{A \\eand (B \\eand C)} \\ai{26, 28}\n\t\\close\n\\have{30}{A \\eand (B \\eand C) \\eiff (X \\eand (Y \\eand Z)} \\by{\\eiff I, 4-16, 17-29}{}\n\\end{proof}\n}\n\n\n\\end{enumerate}\n\n%\\noindent\\problempart \n%Translate the following arguments in to SL and then show that they are valid. Be sure to write out your dictionary. \n\n\n% *******************************************\n% *\t\t\t\tIndirect Proof\t\t\t\t\t   *\t\n% *******************************************\n\n\\section{Indirect Proof}\n\\label{sec:indirect_proof}\n\n%signposting paragraph added\n\nThe last two rules we need to discuss are negation introduction (\\enot I)  and negation elimination (\\enot E). As with the rules of conditional and biconditional introduction, we have put off explaining the rules, because they require launching subproofs. In the case of negation introduction and elimination, these subproofs are designed to let us perform a special kind of derivation classically known as \\emph{reductio ad absurdum}, or simply \\emph{reductio}. \n\n%rob: changed the example to something less exact but more familiar\nA \\emph{reductio} in logic is a variation on a tactic we use in ordinary arguments all the time. In arguments we often stop to imagine, for a second, that what our opponent is saying is true, and then realize that it has unacceptable consequences. In so-called ``slippery slope'' arguments or ``arguments from consequences,'' we claim that doing one thing will will lead us to doing another thing which would be horrible. For instance, you might argue that legalizing physician assisted suicide for some patients might lead to the involuntary termination of lots of other sick people. These arguments are typically not very good, but they have a basic pattern whcih we can make rigorous  in our logical system. These arguments say ``if my opponent wins, all hell will break loose.'' In logic the equivalent of all hell breaking loose is asserting a contradiction. The worst thing you can do in logic is contradict yourself. The equivalent of our opponent being right in logic would be that a sentence we are trying to prove true turns out to be false (or alternately, that a sentence we are trying to prove false turns out to be true.) So, in developing the rules for reductio ad absurdum, we need to find a way to say ``if this sentence were false (or true), we would have to assert a contradiction.'' \n\n%The example from Magnus's version\n%\n%Here is a simple mathematical argument in English for the conclusion that there is no largest number:\n%\\begin{earg}\n%\\item[] Assume there \\emph{is} some greatest natural number. Call it $A$.\n%\\item[] That number plus one is also a natural number.\n%\\item[] Obviously, $A+1 > A$.\n%\\item[] So there is a natural number greater than $A$.\n%\\item[] This is impossible, since $A$ is assumed to be the greatest natural number.\n%\\item[$\\therefore$] There is no greatest natural number.\n%\\end{earg}\n%This argument form is traditionally called a \\emph{reductio}. Its full Latin name is \\emph{reductio ad absurdum}, which means ``reduction to absurdity.'' In a reductio, we assume something for the sake of argument---for example, that there is a greatest natural number. Then we show that the assumption leads to two contradictory sentences---for example, that $A$ is the greatest natural number and that it is not. In this way, we show that the original assumption must have been false.\n\nIn our system of natural deduction, this kind of proof will be known as \\define{indirect proof}.The basic rules for negation will allow for arguments like this. If we assume something and show that it leads to contradictory sentences, then we have proven the negation of the assumption. This is the negation introduction ({\\enot}I) rule:\n\n\\begin{multicols}{2}\n\n\\begin{proof}\n\\open\n\t\\hypo[m]{na}{\\script{A}}\\by{for reductio}{}\n\t\\have[n]{b}{\\script{B}}\n\t\\have{nb}{\\enot\\script{B}}\n\\close\n\\have{a}[\\ ]{\\enot\\script{A}}\\ni{na-nb}\n\\end{proof}\n\n\\begin{proof}\n\\open\n\t\\hypo[m]{na}{\\script{A}}\\by{for reductio}{}\n\t\\have[n]{b}{\\enot\\script{B}}\n\t\\have{nb}{\\script{B}}\n\\close\n\\have{a}[\\ ]{\\enot\\script{A}}\\ni{na-nb}\n\\end{proof}\n\n\\end{multicols}\n\n\nFor the rule to apply, the last two lines of the subproof must be an explicit contradiction: either the second sentence is the direct negation of the first, or vice versa. We write ``for \nreductio'' as a note to ourselves, a reminder of why we started the subproof. It is not formally part of the proof, and you can leave it out if you find it distracting.\n\nTo see how the rule works, suppose we want to prove a law of double negation $A$ $\\therefore$ $\\enot \\enot A$\n\\label{DN1}\n%doublenegation\n\n\\begin{proof}\n\\hypo{1}{A} \\by{Want: \\enot \\enot A}{}\n\t\\open\n\t\\hypo{2}{\\enot A} \\by{for reductio}{}\n\t\\have{3}{A} \\by{R}{1}\n\t\\have{4}{\\enot A} \\by{R}{2}\n\t\\close\n\\have{5}{\\enot \\enot A} \\ni{2-4}\n\\end{proof}\n\nThe {\\enot}E rule will work in much the same way. If we assume \\enot\\script{A} and show that it leads to a contradiction, we have effectively proven \\script{A}. So the rule looks like this:\n\n\\begin{multicols}{2}\n\\begin{proof}\n\\open\n\t\\hypo[m]{na}{\\enot\\script{A}}\\by{for reductio}{}\n\t\\have[n]{b}{\\script{B}}\n\t\\have{nb}{\\enot\\script{B}}\n\\close\n\\have{a}[\\ ]{\\script{A}}\\ne{na-nb}\n\\end{proof}\n\n\n\\begin{proof}\n\\open\n\t\\hypo[m]{na}{\\enot\\script{A}}\\by{for reductio}{}\n\t\\have[n]{b}{\\enot\\script{B}}\n\t\\have{nb}{\\script{B}}\n\\close\n\\have{a}[\\ ]{\\script{A}}\\ne{na-nb}\n\n\\end{proof}\n\\end{multicols}\n\nHere is a simple example of negation elimination at work. We can show $L \\eiff \\enot O, L \\eor \\enot O \\therefore L$ by assuming \\enot L, deriving a contradiction, and then using \\enot E.\n\n\\begin{proof}\n\\hypo{1}{L \\eiff \\enot O}\n\\hypo{2}{L \\eor \\enot O}\\by{Want: $L$}{}\n\\open\n\t\\hypo{3}{\\enot L}\\by{for reductio}{}\n\t\\have{4}{\\enot O} \\oe{2, 3}\n\t\\have{5}{L} \\be{1, 4}\n\t\\have{6}{\\enot L} \\by{R}{3}\n\\close\n\\have{7}{L}\\ne{3-6}\n\\end{proof}\n\nWith the addition of \\enot E and \\enot I, our system of natural deduction is complete. We can now prove that any valid argument is actually valid. This is really where the fun begins. \n\nOne important bit of strategy. Sometimes, you will launch a subproof right away by assuming the negation of the conclusion to the whole argument. Other times, you will use a subproof to get a piece of the conclusion you want, or some stepping stone to the conclusion you want. Here's a simple example. Suppose you were asked to show that this argument is valid: $\\enot(A \\eor B) \\therefore \\enot A \\eand \\enot B$. (The argument, by the way, is part of DeMorgan's Laws, some very useful equivalences which we will see more of later on.)\n\nYou need to set up the proof like this.\n\n\\begin{proof}\n\\hypo{1}{\\enot(A \\eor B)} \\by{Want $\\enot A \\eand \\enot B$}{}\n\\end{proof}\n\nSince you are trying to show $\\enot A \\eand \\enot B$, you could open a subproof with $\\enot(\\enot A \\eand \\enot B$) and try to derive a contradiction, but there is an easier way to do things. Since you are tying to prove a conjunction, you can set out to prove each conjunct separately. Each conjunct, then, would get its own reductio. Let's start by assuming $A$ in order to show $\\enot A$\n\n\\begin{proof}\n\\hypo{1}{\\enot(A \\eor B)} \\by{Want $\\enot A \\eand \\enot B$}{}\n\t\\open\n\t\\hypo{2}{A}\t\\by{for reductio}{}\n\t\\have{3}{A \\eor B} \\oi{2}\n\t\\have{4}{\\enot (A \\eor B)} \\by{R}{1}\n\t\\close\n\\have{5}{\\enot A} \\ni{2-4}\n\\end{proof}\n\n%\\pagebreak[4]\n\nWe can then finish the proof by showing $\\enot B$ and putting it together with $\\enot A$ and conjunction introduction. \n\n% Demorgan's negated disjunction to conjunction of negations.\n\\label{DeM1}\n\\begin{proof}\n\\hypo{1}{\\enot(A \\eor B)} \\by{Want $\\enot A \\eand \\enot B$}{}\n\t\\open\n\t\\hypo{2}{A}\t\\by{for reductio}{}\n\t\\have{3}{A \\eor B} \\oi{2}\n\t\\have{4}{\\enot (A \\eor B)} \\by{R}{1}\n\t\\close\n\\have{5}{\\enot A} \\ni{2-4}\n\t\\open\n\t\\hypo{6}{B}\t\\by{for reductio}{}\n\t\\have{7}{A \\eor B} \\oi{6}\n\t\\have{8}{\\enot (A \\eor B)} \\by{R}{1}\n\t\\close\n\\have{10}{\\enot B} \\ni{7-9}\n\\have{11}{\\enot A \\eand \\enot B} \\ai{6,10}\n\\end{proof}\n\n\n%%%%%%%%Practice problems  %%%%%%%%%%%%%%%%%  !@#$ \n \t\n\\practiceproblems\n\n\\noindent\\problempart Fill in the blanks in the following proofs.\n\n\\begin{multicols}{2}\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item \\textcolor{white}{.} \\\\ \n\\vspace{-16pt}\n%DeMorgans, conjunction of negations to negated disjunction\n\\label{DeM2}\n\\begin{proof}\n\\hypo{1}{\\enot A \\eand \\enot B} \\by{Want: \\iflabelexists{showanswers}{\\color{red}$\\enot (A \\eor B)$}{}}{}\n\\have{2}{\\enot A} \\iflabelexists{showanswers}{ \\by{\\color{red}\\eand E}{1}}{}\n\\have{3}{\\enot B} \\iflabelexists{showanswers}{ \\by{\\color{red}\\eand E}{1}}{}\n\\open\n\t\\hypo{4}{A \\eor B} \\by{for reductio}{}\n\t\\have{5}{B} \\iflabelexists{showanswers}{ \\by{\\color{red}\\eor E}{2, 4}}{}\n\t\\have{6}{\\enot B} \\iflabelexists{showanswers}{ \\by{\\color{red}R}{3}}{}\n\\close\n\\have{7}{\\enot(A \\eor B)} \\iflabelexists{showanswers}{\\by{\\color{red} \\enot I}{4-6}}{}\n\\end{proof}\n\n\\vspace{5cm}\n\n\\item \\textcolor{white}{.} \\\\ \n\\vspace{-16pt}\n%Demorgans disjunction of negations to a negated conjunction.\n\\label{DeM3}\n\\begin{proof}\n\\hypo{1}{\\enot A \\eor \\enot B} \\by{Want: $\\enot(A \\eand B)$}{}\n\t\\open\n\t\\hypo{2}{A \\eand B} \\by{for reductio}{}\n\t\\have{3}{\\iflabelexists{showanswers}{\\color{red}A}{}} \\ae{2}\t\n\t\\have{4}{\\iflabelexists{showanswers}{\\color{red}B}{}} \\ae{2}\n\t\t\\open\n\t\t\\hypo{5}{\\iflabelexists{showanswers}{\\color{red} \\enot A}{}}\\by{for reductio}{}\n\t\t\\have{6}{\\iflabelexists{showanswers}{\\color{red}A}{}} \\by{R}{3}\n\t\t\\have{7}{\\iflabelexists{showanswers}{\\color{red}\\enot A}{}} \\by{R}{5}\n\t\t\\close\n\t\\have{8}{\\enot \\enot A} \\iflabelexists{showanswers}{ \\by{\\color{red}\\enot I}{5-7}}{} \n\t\\have{9}{B} \\iflabelexists{showanswers}{ \\by{\\color{red}R}{4}}{} \n\t\\have{10}{\\enot B} \\iflabelexists{showanswers}{ \\by{\\color{red}\\eor E}{1, 8}}{} \n\t\\close\n\\have{11}{\\enot(A \\eand B)} \\iflabelexists{showanswers}{ \\by{\\color{red}\\enot I}{2-10}}{} \n\\end{proof}\n\n%Demorgans disjunction of negations to a negated conjunction.\n%\\begin{proof}\n%\\have{1}{\\enot A \\eor \\enot B} \\by{Want: \\enot(A \\eand B)}{}\n%\t\\open\n%\t\\hypo{2}{A \\eand B} \\by{for reductio}{}\n%\t\\have{3}{A} \\ae{2}\t\n%\t\\have{4}{B} \\ae{2}\n%\t\t\\open\n%\t\t\\hypo{5}{\\enot A} \\by{for reductio}{}\n%\t\t\\have{6}{A} \\by{R}{3}\n%\t\t\\have{7}{\\enot A} \\by{R}{5}\n%\t\t\\close\n%\t\\have{8}{\\enot \\enot A} \\ni{5-7}\n%\t\\have{9}{B} \\by{R}{4}\n%\t\\have{10}{\\enot B} \\oe{1, 8}\n%\t\\close\n%\\have{11}{\\enot(A \\eand B} \\ni{2-10}\n%\\end{proof}\n\\end{enumerate}\n\\end{multicols}\n\n\\noindent\\problempart Fill in the blanks in the following proofs.\n\n\\begin{enumerate}[label=(\\arabic*)]\n\\item \\textcolor{white}{.}  \n\\vspace{-20pt} %$P \\eif Q \\therefore \\enot P \\eor Q$\n%conditional disjunction, from conditional to disjunction\n\\begin{proof}\n\\hypo{1}{P \\eif Q} \\by{Want: $\\enot P \\eor Q$}{}\n\t\\open\n\t\\hypo{2}{\\hspace{1cm}} \\by{for reductio}{}\n\t\t\\open\n\t\t\\hypo{3}{\\hspace{1cm}} \\by{for reductio}{}\n\t\t\\have{4}{} \\ce{1, 3}\n\t\t\\have{5}{} \\oi{4}\n\t\t\\have{6}{} \\by{R}{2}\n\t\t\\close\n\t\\have{7}{\\enot P} \\ni{3-6}\n\t\\have{8}{ } \\oi{7}\n\t\\have{9}{ } \\by{R}{2}\n\t\\close\n\\have{10}{\\enot P \\eor Q} \\ne{2-9}\t\t\t\n\\end{proof}\n\n%\\begin{proof}\n%\\hypo{1}{P \\eif Q} \\by{Want: \\enot P \\eor Q}{}\n%\t\\open\n%\t\\hypo{2}{\\enot(\\enot P \\eor Q)} \\by{for reductio}{}\n%\t\t\\open\n%\t\t\\hypo{3}{P} \\by{for reductio}{}\n%\t\t\\have{4}{Q} \\ce{1, 3}\n%\t\t\\have{5}{\\enot P \\eor Q} \\oi{4}\n%\t\t\\have{6}{\\enot(\\enot P \\eor Q} \\by{R}{2}\n%\t\t\\close\n%\t\\have{7}{\\enot P} \\ni{3-6}\n%\t\\have{8}{\\enot P \\eor Q} \\oi{7}\n%\t\\have{9}{\\enot(\\enot P \\eor Q)} \\by{R}{2}\n%\t\\close\n%\\have{10}{\\enot P \\eor Q} \\ne{2-9}\t\t\t\n%\\end{proof}\n\n\n\\item \\textcolor{white}{.}  \n\\vspace{-18pt} %$(X\\eand Y)\\eor(X\\eand Z)$, $\\enot(X\\eand D)$, $D\\eor M$ $\\therefore$ $M$\n\n\\begin{proof}\n\\hypo{1}{(X\\eand Y)\\eor(X\\eand Z)}\n\\hypo{2}{\\enot(X\\eand D)}\n\\hypo{3}{D \\eor M} \\by{Want: M}{}\n\t\\open\n\t\\hypo{4}{\\hspace{1cm}} \\by{for reductio}{}\n\t\\have{5}{D} \\oe{ }\n\t\t\\open\n\t\t\\hypo{6}{\\hspace{1cm}} \\by{for reductio}{}\n\t\t\\have{7}{\\enot X \\eor \\enot Y} \n\t\t\t\\open\n\t\t\t\\hypo{8}{\\hspace{1cm}}\t\\by{for reductio}{}\n\t\t\t\\have{9}{X}\t\n\t\t\t\\have{10}{\\enot X}\t\n\t\t\t\\close\n\t\t\\have{11}{\\enot(X \\eand Y)} \\ni{8-10}\n\t\t\\have{12}{} \\oe{1, 11}\n\t\t\\have{13}{} \\ae{12}\n\t\t\\have{14}{} \\by{R}{6}\n\t\t\\close\n\t\\have{15}{X} \n\t\\have{16}{X \\eand D} \n\t\\have{17}{\\enot (X \\eand D)} \n\t\\close\n\\have{18}{M} \\ne{4-17}\n\\end{proof}\n\n%\\begin{proof}\n%\\have{1}{(X\\eand Y)\\eor(X\\eand Z)}\n%\\have{2}{\\enot(X\\eand D)}\n%\\have{3}{D \\eor M} \\by{Want: M}{}\n%\t\\open\n%\t\\hypo{4}{\\enot M} \\by{for reductio}{}\n%\t\\hypo{5}{D} \\oe{3, 4}\n%\t\t\\open\n%\t\t\\hypo{6}{\\enot X} \\by{for reductio}{}\n%\t\t\\have{7}{\\enot X \\eor \\enot Y} \\oi{6}\n%\t\t\t\\open\n%\t\t\t\\hypo{8}{X \\eand Y}\t\\by{for reductio}{}\n%\t\t\t\\have{9}{X}\t\\ae{8}\n%\t\t\t\\have{10}{\\enot X}\t\\by{R}{6}\n%\t\t\t\\close\n%\t\t\\have{11}{\\enot(X \\eand Y)} \\ni{8-10}\n%\t\t\\have{12}{X \\eand Z} \\oe{1, 11}\n%\t\t\\have{13}{X} \\ae{12}\n%\t\t\\have{14}{\\enot X} \\by{R}{6}\n%\t\t\\close\n%\t\\have{15}{X} \\ne{6-14}\n%\t\\have{16}{X \\eand D} \\ai{5, 15}\n%\t\\have{17}{\\enot (X \\eand D)} \\by{R}{2}\n%\t\\close\n%\\have{18}{M} \\ne{4-17}\n%\\end{proof}\n\n\\end{enumerate}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%   Part C: Derive the following using indirect derivation %%%%%\n\\noindent\\problempart Derive the following using indirect derivation. You may also have to use conditional derivation.\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\enot \\enot A  \\sststile{}{}  A$\n%Double negation removing negations\n\\label{DN2}\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{\\enot \\enot A} \\by{Want: $A$}{}\n\t\\open\n\t\\hypo{2}{\\enot A} \\by{for reductio}{}\n\t\\have{3}{\\enot \\enot A} \\by{R}{1}\n\t\\have{4}{\\enot A} \\by{R}{2}\n\t\\close\n\\have{5}{A} \\ne{2-4}\n\\end{proof}\n}\n\n\\item $\\{A \\eif B, \\enot B\\} \\sststile{}{} \\enot A$\n%modus tollens\n\\label{ModusTollens}\n\n\\answer{\n\\begin{proof}\n\t\\hypo{1}{A \\eif B}\n\t\\hypo{2}{\\enot B} \\by{Want: $\\enot A$}{}\n\t\t\\open\n\t\t\\hypo{3}{A} \\by{for reductio}{}\n\t\t\\have{4}{B} \\ce{1, 3}\n\t\t\\have{5}{\\enot B} \\by{R}{2}\n\t\t\\close\n\t\\have{6}{\\enot A} \\ni{3-5}\n\\end{proof}\n}\n\n\\item $A \\eif (\\enot B \\eor \\enot C) \\sststile{}{} A \\eif \\enot (B \\eand C)$\n%\n\\answer{\n\\begin{proof}\n\\hypo{1}{A \\eif (\\enot B \\eor \\enot C)} \\by{Want: $A \\eif \\enot (B \\eand C)$}{}\n\t\\open\n\t\\hypo{2}{A}\t\\by{Want: \\enot (B \\eand C)}{}\n\t\\have{3}{\\enot B \\eor \\enot C} \\ce{1,2}\t\t\n\t\t\\open\n\t\t\\hypo{4}{B \\eand C} \\by{for reductio}{}\n\t\t\\have{5}{B} \\ae{3}\n\t\t\\have{6}{C} \\ae{3}\n\t\t\t\\open\n\t\t\t\\hypo{7}{\\enot B} \\by{for reductio}{}\n\t\t\t\\have{8}{B} \\by{R}{4}\n\t\t\t\\have{9}{\\enot B} \\by{R}{6}\n\t\t\t\\close\n\t\t\\have{10}{\\enot \\enot B} \\ni{6-8}\n\t\t\\have{11}{\\enot C} \\oe{3, 10}\n\t\t\\have{12}{C} \\by{R}{5}\n\t\t\\close\n\t\\have{13}{\\enot (B \\eand C)} \\ni{3-11}\n\t\\close\n\\have{14}{A \\eif \\enot (B \\eand C)} \\ci{2-12} \n\\end{proof}\n}\n\\item $\\enot(A \\eand B) \\sststile{}{} \\enot A \\eor \\enot B$\n%DeMorgan's negated conjunction to disjunction of negations\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{\\enot(A \\eand B)} \\by{Want: \\enot A \\eor \\enot B}{}\n\t\\open\n\t\\hypo{2}{\\enot(\\enot A \\eor \\enot B)} \\by{for reductio}{}\n\t\t\\open\n\t\t\\hypo{3}{\\enot A} \\by{for reductio}{}\n\t\t\\have{4}{\\enot A \\eor  \\enot B} \\oi{3}\n\t\t\\have{5}{\\enot(\\enot A \\eor \\enot B)} \\by{R}{2}\n\t\t\\close\n\t\\have{6}{A} \\ne{3-5}\n\t\t\\open\n\t\t\\hypo{7}{\\enot B} \\by{for reductio}{}\n\t\t\\have{8}{\\enot A \\eor \\enot B} \\oi{7}\n\t\t\\have{9}{\\enot(\\enot A \\eor \\enot B)} \\by{R}{2}\n\t\t\\close\n\t\\have{10}{B} \\ne{7-9}\n\t\\have{11}{A \\eand B} \\ai{6, 10}\n\t\\have{12}{\\enot(A \\eand B)} \\by{R}{1}\n\t\\close\n\\have{13}{\\enot A \\eor \\enot B} \\ne{2-12}\n\\end{proof}\n}\n\n\\item $\\{\\enot F\\eif G, F\\eif H\\} \\sststile{}{} G\\eor H$\n\n\\answer{\n\\begin{proof}\n\\hypo{1}{\\enot F\\eif G}\n\\hypo{2}{F\\eif H} \\by{Want: $G\\eor H$}{}\n\t\\open\n\t\\hypo{3}{\\enot (G \\eor H)} \\by{for reductio}{}\n\t\t\\open\n\t\t\\hypo{4}{F} \\by{for reductio}{}\n\t\t\\have{5}{H} \\ce{2, 4}\n\t\t\\have{6}{G \\eor H} \\oi{5}\n\t\t\\have{7}{\\enot(G \\eor H)} \\by{R}{3}\n\t\t\\close\n\t\\have{8}{\\enot F} \\ni{4-7}\n\t\\have{9}{G} \\oe{1,8}\n\t\\have{10}{G \\eor H} \\oi{9}\n\t\\have{11}{\\enot (G \\eor H)} \\by{R}{3}\n\t\\close\n\\have{12}{G \\eor H} \\ne{3-11}\n\\end{proof}\n}\n\n\\item\t$\\{(T \\eand K) \\eor (C \\eand E), E \\eif \\enot C\\} \\sststile{}{}  T \\eand K$\n\n\\answer{\nThere are two solutions. In one, you look at the want line to figure out the assumption for the subproof. In the other, you think of another think you might want, and assume the negation of that.\n\n\\begin{proof}\n\\hypo{1.}{(T \\eand K) \\eor (C \\eand E)}\n\\hypo{2.}{E \\eif \\enot C} \t\t\t\\by{Want: T \\eand K}{}\n\\open\n\\hypo{3.}{\\enot (T \\eand K)} \\by{For Reductio}{}\n\\have{4.}{C \\eand E}\t \\by{\\eor E}{1, 4}\n\\have{5.}{E} \\by{\\eand E}{4}\n\\have{6.}{C} \\by{\\eand E}{5}\n\\have{7.}{\\enot C} \\by{\\enot E}{2, 6}\n\\close\n\\have{8.}{T \\eand K}\t\\by{\\enot E}{3-7}\n\\end{proof}\n\n\\begin{proof}\n\\hypo{1.}{(T \\eand K) \\eor (C \\eand E)}\n\\hypo{2.}{E \\eif \\enot C} \\by{Want: T \\eand K}{}\n\\open\n\\have{3.}{C \\eand  E}\t\\by{For Reductio}{}\n\\have{4.}{E}\\by{\\eand E}{3}\n\\have{5.}{C}\\by{\\eand E}{4}\n\\have{6.}{\\enot C}\\by{\\eif E}{2, 4}\n\\close\n\\have{7.}{\\enot (C \\eand E)}\\by{\\enot I}{3-4}\n\\have{8.}{T \\eand K}\\by{\\eor E}{1, 7}\n\\end{proof}\n}\n\n\\item $\\{(A \\eif B) \\}\\sststile{}{} (A \\eif \\enot B) \\eif \\enot A$\n\n\\answer{\n\\begin{proof}\n \\hypo{}{A \\eif B} \\by{Want: (A \\eif \\enot B) \\eif \\enot A}{}\n\\open\n\\hypo{}{A \\eif \\enot B} \\by{Want: \\enot A}{}\n\\open\n\\hypo{}{A} \\by{Want: A contradiction}{}\n\\have{}{B} \\by{\\eif E}{1, 3}\n\\have{}{\\enot B} \\by{\\eif E}{2, 3}\n\\close\n\\have{}{\\enot A} \\by{\\enot I}{3-5}\n\\close\n\\have{}{(A \\eif \\enot B) \\eif \\enot A} \\by{\\eif I}{2-6}\n\\end{proof}\n}\n\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%   Part D: Derive the following using indirect derivation %%%%%\n\\noindent\\problempart Derive the following using indirect derivation. You may also have to use conditional derivation.\n\\label{derivation_set_with_const_d}\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\{P \\eif Q, P \\eif \\enot Q\\} \\sststile{}{} \\enot P$\n\n%\\begin{proof}\n%\\hypo{1}{P \\eif Q}\n%\\hypo{2}{P \\eif \\enot Q} \\by{Want: \\enot P}{}\n%\t\\open\n%\t\\hypo{3}{P} \\by{for reductio}{}\n%\t\\have{4}{Q} \\ce{1, 3}\n%\t\\have{5}{\\enot Q} \\ce{2, 3}\n%\t\\close\n%\\have{6}{\\enot P} \\ni{3-5}\n%\\end{proof}\n\n\\item $(C\\eand D)\\eor E \\sststile{}{} E\\eor D$\n\n%\\begin{proof}\n%\\hypo{1}{(C\\eand D)\\eor E} \\by{Want: $E \\eor D$}{}\n%\t\\open\n%\t\\hypo{2}{\\enot (E \\eor D)} \\by{for reductio}{}\n%\t\t\\open\n%\t\t\\hypo{3}{E} \\by{for reductio}{}\n%\t\t\\have{4}{E \\eor D} \\oi{3}\n%\t\t\\have{5}{\\enot (E \\eor D)} \\by{R}{2}\n%\t\t\\close\n%\t\\have{6}{\\enot E} \\ni{3-5}\n%\t\\have{7}{C \\eand D} \\oe{1, 6}\n%\t\\have{8}{D} \\ae{7}\n%\t\\have{9}{E \\eor D} \\oi{8}\n%\t\\have{10}{\\enot (E \\eor D)}\t\\by{R}{2}\n%\t\\close\n%\\have{11}{E \\eor D} \\ne{2-10}\n%\\end{proof}\n\n\\item $M\\eor(N\\eif M) \\sststile{}{} \\enot M \\eif \\enot N$ \\label{DeM4}\n\n%\\begin{proof}\n%\\hypo{1}{M\\eor(N\\eif M)} \\by{want: \\enot M \\eif \\enot N}{}\n%\\open\n%\\hypo{2}{\\enot M} \\by{want: \\enot N}{}\n%\\have{3}{N \\eif M}\n%\\open\n%\\hypo{4}{N} \\by{want: M and \\enot M}{}\n%\\have{5}{M} \\ce{3, 4}\n%\\have{6}{\\enot M} \\by{R}{2}\n%\\close\n%\\have{7}{\\enot N} \\by{\\enot I}{4--6}\n%\\close\n%\\have{8}{\\enot M \\eif \\enot N} \\ci{2--7}\n%\\end{proof}\n\n\n\n\\item \\label{itm:const_d} \\{$A \\eor B, A \\eif C, B \\eif C\\} \\sststile{}{} C$\n\n%\\begin{proof}\n%\\hypo{1}{A \\eor B}\n%\\hypo{2}{A \\eif C}\n%\\hypo{3}{B \\eif C}  \\by{Want: C}{}\n%\t\\open\n%\t\\hypo{4}{\\enot C} \\by{for reductio}{}\n%\t\t\\open\n%\t\t\\hypo{5}{\\enot A} \\by{for reductio}{}\n%\t\t\\have{6}{B} \\oe{1,5}\n%\t\t\\have{7}{C} \\ce{3, 6}\n%\t\t\\have{8}{\\enot C} \\by{R}{7}\n%\t\t\\close\n%\t\\have{9}{A} \\ne{5-8}\n%\t\\have{10}{C} \\ce{2, 9}\n%\t\\have{11}{\\enot C} \\by{R}{4}\n%\t\\close\n%\\have{12}{C} \\ne{4-11}\n%\\end{proof}\n\n\\item\t$A \\eif (B \\eor (C \\eor D))  \\sststile{}{} \\enot[A \\eand (\\enot B \\eand (\\enot C \\eand \\enot D))] $\n\n%1.\tA → (B ˅ (C ˅ D)) \t\t\tWant: ~[A & (~B & (~C &~D))]\n%2.\t\tA & (~B & (~C &~D))\tFor reductio\n%3.\t\tA\t\t\t\t\t\t\t&E 2\n%4.\t\tB ˅ (C ˅ D)\t\t\t\t→E 1, 3\n%5.\t\t~B & (~C &~D)\t\t\t&E 2\n%6.\t\t~B\t\t\t\t\t\t\t&E 5\n%7.\t\tC ˅ D\t\t\t\t\t\t˅E 4, 6\n%8.\t\t~C & ~D\t\t\t\t\t&E 5\n%9.\t\t~C\t\t\t\t\t\t\t&E 8\n%10.\t\tD\t\t\t\t\t\t\t˅E 7, 9\n%11.\t\t~D\t\t\t\t\t\t\t&E 8\n%12.\t~[A & (~B & (~C &~D))]\t~I 2–11\t\n%\n\n\n\n\n\n\\end{enumerate}\n\n%\\noindent\\problempart \n%Translate the following arguments in to SL and then show that they are valid. Be sure to write out your dictionary. \n\n%\n%  This is the opening of the conditional formatting tag for typesetting only part of this chapter. Everything from here to the close tag will be skipped \n% unless the {whole_slproof_chap} label at the\n%  start of this chapter is uncommented.\n%\n\n\\iflabelexists{whole_slproof_chap}{\n\n% *******************************************\n% *\t\tTautologies and Equivalences\t\t\t\t   *\t\n% *******************************************\n\n\\section{Tautologies, Equivalences and Inconsistencies}\n\\label{sec:taut-eq-incon}\n\nSo far all we've looked at is whether conclusions follow validly from sets of premises. However, as we saw in the chapter on truth tables, there are other logical properties we want to \ninvestigate: whether a statement is a tautology, a contradiction or a contingent statement, whether two statements are equivalent, and whether sets of sentences are consistent. In this \nsection, we will look at using derivations to test for three properties which will be important in later sections, logical equivalence, inconsistency and being a tautology.\n\n\n\\newglossaryentry{syntactically logically equivalent in SL}\n{\nname=syntactically logically equivalent in SL,\ndescription={A property held by pairs of statements in SL if and only if there is a derivation which takes you from each one to the other one.}\n}\n\nWe can say that two statements are \\textsc{\\gls{syntactically logically equivalent in SL}} \\label{def:syntactically_logically_equivalent_in_sl} if you can derive each of them from the \nother. We can symbolize this the same way we symbolized semantic equivalence. When we introduced the double turnstile (p. \\pageref{defDoubleTurnstile}), we said we would write the symbol \nfacing both directions to indicate that two sentences were semantically equivalent, like this: $A \\eand B \\ndststile{}{} \\hspace{.5em} \\sdtstile{}{} B \\eand A$. We can do the same thing \nwith the single turnstile for syntactic equivalence, like this: $A \\eand B \\nsststile{}{} \\hspace{.5em} \\sststile{}{} B \\eand A$.\n\nFor an example of how we can show two sentences to be syntactically equivalent, consider the sentences $P \\eif (Q \\eif R)$ and $(P \\eif Q) \\eif (P \\eif R)$. \\label{theorem_DistributionOfImplicationOverImplication} To prove these logically equivalent using derivations, we simply use derivations to prove the equivalence one way, from P \\eif (Q \\eif R) to (P \\eif Q) \\eif (P \\eif R). And then we prove it going the other way, from (P \\eif Q) \\eif (P \\eif R) to P \\eif (Q \\eif R). We set up the proof going left to right like this: \n\n\\begin{proof}\n\\hypo{1}{P \\eif (Q \\eif R)}\t\\by{Want: (P \\eif Q) \\eif (P \\eif R)}{}\n\\end{proof}\n\nSince our want line is a conditional, we can set this up as a conditional proof. Once we set up the conditional proof, we also have a conditional in next want line, which means that we can put a conditional proof inside a conditional proof, like this.\n\n\\begin{proof}\n\\hypo{1}{P \\eif (Q \\eif R)}\t\\by{Want: (P \\eif Q) \\eif (P \\eif R)}{}\n\t\\open\n\t\\hypo{2}{P \\eif Q}\t\\by{Want: P \\eif R}{}\n\t\t\\open\n\t\t\\hypo{3}{P}\t\\by{Want: R}{}\n\\end{proof}\n\nThe completed proof for the equivalence going in one direction will look like this.\n\n\\begin{proof}\n\\hypo{1}{P \\eif (Q \\eif R)}\t\\by{Want: (P \\eif Q) \\eif (P \\eif R)}{}\n\t\\open\n\t\\hypo{2}{P \\eif Q}\t\\by{Want: P \\eif R}{}\n\t\t\\open\n\t\t\\hypo{3}{P}\t\\by{Want: R}{}\n\t\t\\have{4}{Q \\eif R} \\by{\\eif E}{1, 3}\n\t\t\\have{5}{Q}\t\\by{\\eif E}{2, 3}\n\t\t\\have{6}{R} \\by{\\eif E}{4, 5}\n\t\t\\close\n\t\\have{7}{P \\eif R} \\by{\\eif I}{3-6}\n\t\\close\n\\have{8}{(P \\eif Q) \\eif (P \\eif R)} \\by{\\eif I}{2-7}\n\\end{proof}\n\nThis shows that $P \\eif (Q \\eif R) \\sststile{}{} (P \\eif Q) \\eif (P \\eif R)$. In order to show $P \\eif (Q \\eif R) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} (P \\eif Q) \\eif (P \\eif R)$, we need to prove the equivalence going the other direction. That proof will look like this:\n\n\\begin{proof}\n\\hypo{1}{(P \\eif Q) \\eif (P \\eif R)}\t\\by{Want: P \\eif (Q \\eif R)}{}\n\t\\open\n\t\\hypo{2}{P} \\by{Want: Q \\eif R}{}\n\t\t\\open\n\t\t\\hypo{3}{Q} \\by{Want: R}{}\n\t\t\t\\open\n\t\t\t\\hypo{4}{P} \\by{Want: Q}{}\n\t\t\t\\have{5}{Q} \\by{R}{3}\n\t\t\t\\close\n\t\t\\have{6}{P \\eif Q} \\by{\\eif I}{4-5}\n\t\t\\have{7}{P \\eif R} \\by{\\eif E}{1, 6}\n\t\t\\have{8}{R} \\by{\\eif E}{2, 7}\n\t\t\\close\t\n\\have{9}{Q \\eif R} \\by{\\eif I}{3-8}\n\\close\n\\have{10}{P \\eif (Q \\eif R)} \\by{\\eif I}{2-9}\n\\end{proof}\nYou might think it is strange that we assume $P$ twice in this proof, but that is the way we have to do it. When we assume $P$ on line 2, our goal is to prove $P \\eif (Q \\eif R)$. Before we can finish that proof, we also need to know that $P \\eif Q$. This requires a different subproof. \n%%%%%\n%fixed a little typoe above where {} was instead of ()\n%%%%%\n\nThese two proofs show that $P \\eif (Q \\eif R)$ and $(P \\eif Q) \\eif (P \\eif R)$ are equivalent, so we can write $P \\eif (Q \\eif R) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} (P \\eif Q) \\eif (P \\eif R)$. \n\n\\newglossaryentry{syntactic tautology in SL}\n{\nname=syntactic tautology in SL,\ndescription={A statement in SL that can be derived without any premises}\n}\n\nWe can also prove that a sentence is a tautology using a derivation. A tautology is something that must be true as a matter of logic. If we want to put this in syntactic terms, we would say that \\textsc{\\gls{syntactic tautology in SL}} \\label{def:syntactic_tautology_in_sl} is a statement that can be derived without any premises, because its truth doesn't depend on anything else. Now that we have all of our rules for starting and ending subproofs, we can actually do this. Rather than listing any premises, we simply start a subproof at the beginning of the derivation. The rest of the proof can work only using premises assumed for the purposes of subproofs. By the end of the proof, you have discharged all these assumptions, and are left knowing a tautological statement without relying on any leftover premises. Consider this proof of the law of noncontradiction: $\\enot(G \\eand \\enot G)$. \\label{theorem_Noncontradiction}\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo{gng}{G\\eand \\enot G}\\by{for reductio}{}\n\t\t\\have{g}{G}\\ae{gng}\n\t\t\\have{ng}{\\enot G}\\ae{gng}\n\t\\close\n\t\\have{ngng}{\\enot(G \\eand \\enot G)}\\ni{gng-ng}\n\\end{proof}\n\nThis statement simply says that any sentence G cannot be both true and not true at the same time. We prove it by imagining what would happen if G were actually both true and not true, and \nthen pointing out that we already have our contradiction.\n\nIn the previous chapter, we expressed the fact that something could be proven a tautology using truth tables by writing the double turnstile in front of it. The law of noncontradiction \nabove could have been proven using truth tables, so we could write: $\\sdtstile{}{} \\enot(G \\eand \\enot G)$ In this chapter, we will use the single turnstile the same way, to indicate that \na sentence can be proven to be a tautology using a derivation. Thus the above proof entitles us to write $\\sststile{}{} \\enot(G \\eand \\enot G)$.\n\n\\newglossaryentry{syntactically logically inconsistent in SL}\n{\nname=syntactically logically inconsistent in SL,\ndescription={A property held by sets of statements in SL if and only if there is a derivation which results in a contradiction.}\n}\n\n%%%%%%%%%%\n%%rcr. Syntactically inconsistent\n%%%%%%%%%%\nFinally, the natural deduction method can be used to prove that a set of sentences are inconsistent. Recall our definition from\nSection~\\ref{sec:consistency}: a set of sentences in English are said to be inconsistent if they cannot all be true at the same time. Otherwise\nthey are consistent. \nWe were able to prove this semantic relationship in Chapter~\\ref{chap:truth_tables} by drawing a truth table for\nevery sentence in the set, and then inspecting the column under the main connective of each. If there was a single row in which every sentence\ncontained a T, then it was determined to be logically consistent. If there is not a single row in which all members of the set contains a T, then it was\ndetermined to be logically inconsistent.\n\nWhen we say that a set of sentences is inconsistent, we sometimes also say that it ``contains a contradiction''. By this, we mean that logically, it is not possible for all of the\nstatements to be true, taken together. However, more precisely, if a set of sentences is logically inconsistent, it does not ``contain\" a contradiction: rather, from a set of inconsistent\nsentences one can derive a contradiction. It is this relationship that we will exploit in a derivation, using either the indirect proof, or conditional proof method. We can say that two\nstatements are \\textsc{\\gls{syntactically logically inconsistent in SL}} \\label{def:syntactically_logically_inconsistent_in_sl} if you can derive a contradiction from them.\n\n\n\nLike invalid arguments, the natural deduction method cannot be used to show that a set of sentences is logically consistent, since the test for such a relationship\nwould involve showing that a contradiction \\emph{cannot} be derived. Of course, because of the strategic nature of the derivation rules, there is no independent\nrigorous test to distinguish between an attempted derivation in which no contradiction is logically possible, and one in which no derivation could be found.\nSince there are an infinite number of combinations of application of the derivation rules, but each derivation is finite, no such test can be performed.\n\nConsider this proof that the following set of sentences are logically inconsistent: \\{$P \\eif Q, P, \\enot Q$\\}.\n\n\\begin{proof}\n        \\hypo{1}{P \\eif Q}\n        \\hypo{2}{P}\n        \\hypo{3}{\\enot Q} \\by{Want: $P \\eand \\enot P$}{}\n        \\open\n                \\hypo{4}{P}\\by{for reductio}{}\n                \\have{5}{Q}\\by{\\eif I}{1, 4} \n                \\have{6}{\\enot Q} \\by{R}{3}\n        \\close\n                \\have{7}{\\enot P} \\by{IP}{4-6}\n                \\have{8}{P}{} \\by{R}{2}\n                \\have{9}{P \\eand \\enot P} \\by{\\eand I}{7, 8}\n\\end{proof}\n\nBy listing the set of sentences among our assumptions, we were able to derive a contradiction \\{$P, \\eand \\enot P$\\} using the indirect proof method. Since there \nis a derivation in which a contradiction can be derived from the set of sentences, we conclude that they are logically inconsistent.\n\n\\practiceproblems\n \t\n\n\\noindent\\problempart\nProve each of the following equivalences\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $J \\nsststile{}{} \\hspace{.5em} \\sststile{}{} J\\eor (L\\eand\\enot L)$\n%\\vspace{5pt}\n%$ \\sststile{}{}$\n%\\vspace{5pt}\n%\\begin{proof}\n%\t\t\\hypo{1}{J} \\by{Want: J \\eor(L \\eand \\enot L)}{}\n%\t\t\\have{2}{J \\eor (L \\eand \\enot L)} \\oi{1}\n%\\end{proof}\n%\\vspace{5pt}\n%$\\nsststile{}{}$\n%\\vspace{5pt}\n%\\begin{proof}\t\n%\t\t\\hypo{1}{J \\eor (L \\eand \\enot L)} \\by{Want: J}{}\n%\t\t\t\\open\n%\t\t\t\\hypo{2}{L \\eand \\enot L} \\by{for reductio}{}\n%\t\t\t\\have{3}{L} \\ae{4}\n%\t\t\t\\have{4}{\\enot L} \\ae{4}\n%\t\t\t\\close\n%\t\t\\have{5}{\\enot(L \\eand \\enot L)} \\ni{4-6}\n%\t\t\\have{6}{J} \\oe{3, 7}\n%\\end{proof}\n\n\n\\item $P \\eif (Q \\eif R) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} Q \\eif (P \\eif R)$\n\n%Modified from KMM T107 p. 82.\n\n%\\vspace{5pt}\n%$ \\sststile{}{}$\n%\\vspace{5pt}\n%\n%\\begin{proof}\n%\\hypo{1.}{P \\eif (Q \\eif R)} \\by{Want: Q \\eif (P \\eif R)}{}\n%\\open\n%\\hypo{2.}{Q} \\by{Want: P \\eif R}{}\n%\\open\n%\\hypo{3.}{P} \\by{Want: R}{}\n%\\have{4}{Q \\eif R } \\by{\\eif E}{1,3}\n%\\have{5.}{R} \\by{ \\eif E }{2, 4}\n%\\close\n%\\have{6}{P \\eif R } \\by{\\eif I}{3-5}\n%\\close\n%\\have{7.}{Q \\eif (P \\eif R)} \\by{\\eif I}{2-6}\n%\\end{proof}\n%\n%\\vspace{5pt}\n%$\\nsststile{}{}$\n%\\vspace{5pt}\n%\n%\n%\\begin{proof}\n%\\hypo{1.}{Q \\eif (P \\eif R)} \\by{Want: P \\eif (Q \\eif R)}{}\n%\\open\n%\\hypo{2.}{P} \\by{Want: Q \\eif R}{}\n%\\open\n%\\hypo{3.}{Q} \\by{Want: R}{}\n%\\have{4}{P \\eif R } \\by{\\eif E}{1,3}\n%\\have{5.}{R} \\by{ \\eif E }{2, 4}\n%\\close\n%\\have{6}{Q \\eif R } \\by{\\eif I}{3-5}\n%\\close\n%\\have{7.}{P \\eif (Q \\eif R)} \\by{\\eif I}{2-6}\n%\\end{proof}\n\n\\item $P \\eif \\enot P \\nsststile{}{} \\hspace{.5em} \\sststile{}{}  \\enot P $ %(KMM T115, p. 111)\n\n%\\vspace{5pt}\n%$ \\sststile{}{}$\n%\\vspace{5pt}\n%\n%\n%\\begin{proof}\n%\\hypo{1}{P \\eif \\enot P} \\by{Want:  \\enot P}{}\n%\t\\open\n%\t\\hypo{2}{P} \\by{Want: A contradiction}{}\n%\t\\have{3}{\\enot P} \\by{\\eif E}{1, 2}\n%\t\\have{4}{P} \\by{R}{2}\n%\t\\close\n%\\have{5}{P} \\by{\\enot E}{2-4}\n%\\end{proof}\n%\n%\\vspace{5pt}\n%$\\nsststile{}{}$\n%\\vspace{5pt}\n%\n%\\begin{proof}\n%\\hypo{1}{ \\enot P } \\by{Want: P \\eif \\enot P}{}\n%\t\\open\n%\t\\hypo{2}{P} \\by{Want: \\enot P}{}\n%\t\\have{3}{\\enot P} \\by{R}{1}\n%\t\\close\n%\\have{4}{P \\eif \\enot P} \\by{\\eif I}{2-3}\n%\\end{proof}\n%\n\n\\item $\\enot (P \\eiff Q) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} (P \\eiff \\enot Q) $ %(KMM T90 p. 110)\n\n%\\vspace{5pt}\n%$ \\sststile{}{}$\n%\\vspace{5pt}\n%\n%\\begin{proof}\n%\\hypo{1.}{\\enot (P \\eiff Q)} \\by{Want: $P \\eiff \\enot Q$}{}\n%\t\\open\n%\t\\hypo{2.}{P} \\by{Want: $\\enot Q$}{}\n%\t\t\\open\n%\t\t\\hypo{3.}{Q}\t\\by{Want: A contradiction}{}\n%\t\t\t\\open\n%\t\t\t\\hypo{4.}{P} \\by{Want: Q}{}\n%\t\t\t\\have{5.}{Q} \\by{R}{3}\n%\t\t\t\\close\n%\t\t\t\\open\n%\t\t\t\\hypo{6.}{Q} \\by{Want: P}{}\n%\t\t\t\\have{7.}{P} \\by{R}{2}\n%\t\t\t\\close\n%\t\t\\have{8.}{P \\eiff Q} \\by{\\eiff I}{4-5, 6-7}\n%\t\t\\have{9.}{\\enot(P \\eiff Q)} \\by{R}{1}\n%\t\t\\close\n%\t\\have{10.}{\\enot Q} \\by{\\enot I}{2-9}\n%\t\\close\n%\t\\open\n%\t\\hypo{a}{\\enot Q} \\by{Want: P}{}\n%\t\t\\open\n%\t\t\\hypo{b}{\\enot P} \\by{Want: A contradiction}{}\n%\t\t\t\\open\n%\t\t\t\\hypo{c}{P} \\by{Want: Q}{}\n%\t\t\t\\have{d}{P \\eor Q} \\by{\\eor I}{13}\n%\t\t\t\\have{e}{Q} \\by{\\eor E}{12, 14}\n%\t\t\t\\close\n%\t\t\t\\open\n%\t\t\t\\hypo{f}{Q} \\by{Want: P}{}\n%\t\t\t\\have{g}{Q \\eor P} \\by{\\eor I}{f}\n%\t\t\t\\have{h}{P} \\by{\\eor E}{f, g}\n%\t\t\t\\close\n%\t\t\\have{i}{P \\eiff Q} \\by{\\eiff I}{c-e, f-h}\n%\t\t\\have{j}{\\enot (P \\eiff Q)} \\by{R}{b}\n%\t\t\\close\n%\t\\have{21.}{P} \\by{\\enot I}{a-j}\n%\t\\close\n%\\have{22.}{P \\eiff \\enot Q} \\by{\\eiff I}{}\n%\\end{proof}\n%\n%\\vspace{5pt}\n%$\\nsststile{}{}$\n%\\vspace{5pt}\n%\n%\\begin{proof}\n%\\hypo{1}{P \\eiff \\enot Q} \\by {Want: \\enot (P \\eiff Q)}{}\n%\t\\open\n%\t\\hypo{2}{P \\eiff Q} \\by{Want: A contradiction}{}\n%\t\t\\open\n%\t\t\\hypo{3}{Q} \\by{Want: A contradiction}{}\n%\t\t\\have{4}{P} \\by{\\eiff E}{2, 3}\n%\t\t\\have{5}{\\enot Q} \\by{\\eiff E}{1, 4}\n%\t\t\\have{6}{Q} \\by{R}{3}\n%\t\t\\close\n%\t\\have{7}{\\enot Q} \\by{\\enot I}{3-6}\n%\t\\have{8}{P} \\by{\\eiff}{1, 7}\n%\t\\have{9}{Q}\\by{\\eiff}{2, 8}\n%\t\\have{10}{\\enot Q} \\by{R}{7}\n%\t\\close\n%\\have{11}{\\enot (P \\eiff Q)} \\by{\\enot I}{2-10}\n%\\end{proof}\n%\\vspace{15pt}\n\n\n\n\n\\end{enumerate}\n\n\\noindent\\problempart\nProve each of the following equivalences\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $(P \\eif R) \\eand (Q \\eif R) \\nsststile{}{} \\hspace{.5em} \\sststile{}{}(P \\eor Q) \\eif R $ %(KMM T50 p.109)\n\\item $(P \\eif (Q \\eor R)) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} (P \\eif Q) \\eor (P \\eif R)$ %(KMM T55 p.109)\n\\item $(P \\eiff Q)  \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\enot P \\eiff \\enot Q\t\t$ %(KMM T96 p.110)\n\\end{enumerate}\n\n%\\item $P \\eif Q \\nsststile{}{} \\hspace{.5em} \\sststile{}{}(R \\eor P) \\eif (R \\eor Q)$ %(KMM T56 p.109)\n% ^ removed because it doesn't work right to left. Check to see if this is really in KRR.\n\n\\noindent\\problempart\nProve each of the following tautologies\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $\\sststile{}{} O \\eif O$\t\t%KMM T1, p.41\n%\n%\t\\begin{proof}\n%\n%\t\\open\n%\t\\hypo{1}{O}\\by{Want: O}{}\n%\t\\have{2}{O}\\by{R}{1}\n%\t\\close\n%\t\\have{3}{O \\eif O} \\ci{1-2}\n%\n%\t\\end{proof}\n\n\\item $\\sststile{}{} N \\eor \\enot N$ \\label{theorem_ExcludedMiddle}\n\n%\t\\begin{proof}\n%\n%\t\\open\n%\t\\hypo{1}{\\enot (N \\eor \\enot N)} \\by{for reductio}{}\n%\t\\open\n%\t\\hypo{2}{N} \\by{for reductio}{}\n%\t\\have{3}{N \\eor \\enot N} \\oi{2}\n%\t\\have{4}{\\enot (N \\eor \\enot N)} \\by{R}{1}\n%\t\\close\n%\t\\have{5}{\\enot N} \\ni{2-4}\n%\t\\have{6}{N \\eor \\enot N} \\oi{5}\n%\t\\have{7}{\\enot (N \\eor \\enot N)} \\by{R}{1}\n%\t\\close\n%\t\\have{8}{N \\eor \\enot N} \\ne{2-7}\n%\n%\t\\end{proof}\n\n\\item $\\sststile{}{} \\enot(A \\eif \\enot C) \\eif (A \\eif C)$\n\n%\t\\begin{proof}\n%\t\n%\t\t\\open\n%\t\t\\hypo{1}{\\enot(A \\eif \\enot C)} \\by{Want: A \\eif C}{}\n%\t\t\t\\open\n%\t\t\t\\hypo{2}{A} \\by{Want: C}{}\n%\t\t\t\t\\open\n%\t\t\t\t\\hypo{3}{\\enot C} \\by{for reductio}{}\n%\t\t\t\t\t\\open\n%\t\t\t\t\t\\hypo{4}{A} \\by{Want: \\enot C}{}\n%\t\t\t\t\t\\have{5}{\\enot C} \\by{R}{3}\n%\t\t\t\t\t\\close\n%\t\t\t\t\\have{6}{A \\eif \\enot C} \\ci{4-5}\n%\t\t\t\t\\have{7}{\\enot (A \\eif \\enot C)} \\by{R}{1}\n%\t\t\t\t\\close\n%\t\t\t\\have{8}{C} \\ne{3-7}\n%\t\t\t\\close\n%\t\t\\have{9}{A \\eif C} \\ci{2-9}\n%\t\t\\close\n%\t\\have{10}{\\enot(A \\eif \\enot C) \\eif (A \\eif C)} \\ci{1-9}\n%\t\n%\t\\end{proof}\n\n\\item $\\sststile{}{} P \\eiff (P \\eor (Q \\eand P))$ \n\n%\n%1.\t\tP\t\t\t\tWant: P  (Q & P)\n%2.\t\tP  \t(Q & P)\t\tI 1\n%3.\t\tP  (Q & P)\t\tWant P\n%4\t\t\t~P\t\t\tFor reductio\n%5.\t\t\tQ & P\t\tE 3, 4\n%6.\t\t\tP\t\t\t&E 5\n%8.\t\t\t~P\t\t\tR 4\n%9.\t\tP\t\t\t\t~E 4\n%10.\tP ↔ (P  (Q & P)\tI 1¬–2, 3–9\n%\n%Appears in Hurley 10, 404 replace ASAP\n\n\\end{enumerate}\n\n\n\\noindent\\problempart\nProve each of the following tautologies\n\\begin{enumerate}[label=(\\arabic*)]\n\\item $\\sststile{}{} (B \\eif \\enot B) \\eiff \\enot B$\n\n%1.\t\tB \\eif ~B\t\tWant: ~B\n%2.\t\t\tB\t\t\tFor reductio\n%3.\t\t\t~B\t\t\t\\eif E 1, 2\n%4.\t\t\tB\t\t\tR2\n%5.\t\t~B\t\t\t\t~I 2–4\n%6.\t\t~B\t\t\t\tWant: B \\eif ~B\n%7.\t\t\tB\t\t\tWant: ~B\n%8.\t\t\t~B\t\t\tR6\n%9.\t\tB \\eif ~B\n%10\t(B \\eif ~B) \\eiff ~B\n\n\\item $\\sststile{}{} (P \\eif [P \\eif Q]) \\eif (P \\eif Q)$ %(KMM T9 p. 42)\n\n\\item $\\sststile{}{} (P \\eor \\enot P) \\eand (Q \\eiff Q) $ %(KMM T119 p.111)\n\n\\item $\\sststile{}{} (P \\eand \\enot P) \\eor  (Q \\eiff Q)$%(KMM T120 p.111)\n\n\\end{enumerate}\n\n%%%%%%%%%%\n%rcr incon problems\n%%%%%%%%%%\n\\noindent\\problempart   \n\\label{pr.derivation.inconsistent}\nShow that each set of sentences is inconsistent by deriving a contradiction.\n\\begin{enumerate}\n\\item \\{$A \\eif \\enot A$, $\\enot A \\eif A$\\}\\vspace{.5ex} %inconsistent. \n\\item \\{$A \\eor B$, $A \\eif C$, $B \\eif C$, $\\enot C$\\}\\vspace{.5ex} %  Inconsistent\n\\item \\{$B\\eand(C\\eor A)$, $A\\eif B$, $\\enot(B\\eor C)$\\}\\vspace{.5ex}  %inconsistent\n\\item \\{$A \\eand B$, $C\\eif \\enot B$, $C$\\} \\vspace{.5ex} %inconsistent\n\\item \\{$A\\eif B$, $B\\eif C$, $A$, $\\enot C$\\}\\vspace{.5ex} %inconsistent\n\\item \\{$A \\eif B$, $B \\eif C$, $\\enot(A \\eif C)$\\} \\vspace{.5ex} %inconsistent\n\\end{enumerate}\n\n\n\n\\noindent\\problempart   \n\\label{pr.derivation2.inconsistent2}\nShow that each set of sentences is inconsistent by deriving a contradiction.\n\\begin{enumerate}\n\\item \\{$P \\eif P$, $\\enot (P \\eif P)$  \\}\\vspace{.5ex}\n\\item \\{$P \\iff A$, $Q \\eif \\enot P$, $P$ \\}\\vspace{.5ex}\n\\item \\{$P \\eif \\enot P$, $\\enot P \\eif P)$ \\}\\vspace{.5ex}\n\\item \\{$\\enot P \\eor Q$, $R \\eif P$, $\\enot R \\eif P$  \\}\\vspace{.5ex}\n\\end{enumerate}\n\n\n\n\\noindent\\problempart   \n\\label{pr.derivation2.inconsistent3}\nShow that each set of sentences is inconsistent by deriving a contradiction.\n\\begin{enumerate}\n\\item \\{$C \\eiff G$, $G \\eiff \\enot C$\\}\\vspace{.5ex}\n\\item \\{$F \\eor T$, $(F \\eor T) \\eif (\\enot F \\eand \\enot T)$\\}\\vspace{.5ex}\n\\item \\{$J \\eor K$, $\\enot J \\eor \\enot K$, $J \\eiff K$\\}\\vspace{.5ex}\n\\item \\{$(G \\eor K) \\eif A$, $(A \\eor H) \\eif G$, $G \\eand \\enot A$\\}\\vspace{.5ex}\n\\item \\{$D \\eiff(\\enot P \\eand \\enot M)$, $P \\eiff (J \\eand \\enot F)$, $\\enot F \\eor \\enot D$, $D \\eand J$\\}\\vspace{.5ex}\n\\end{enumerate}\n\n\n\n\n\n%c l ) C=G,      G=-C\n\n\n%c3) JvK,   -Jv-K,   J=K\n%c4)  (GvK)>A,   (AvH)>G,  G&-A\n%c.5) D=(-P&-M),    P=(I&-F), -Fv-D, D&J\n\n\n\n\n\n\n% *******************************************\n% *\t\t\t\t\tDerived Rules\t\t\t\t   *\t\n% *******************************************\n\n\\section{Derived Rules}\n\\setlength{\\parindent}{1em}\n\n%rob: new opening paragraph, more ambitions for this section.\n\nNow that we have our five rules for introduction and our five rules for elimination, plus the rule of reiteration, our system is complete. If an argument is valid, and you can symbolize \nthat argument in SL, you can \\emph{prove} that the argument is valid using a derivation. (We will say a bit more about this in section \\ref{sec:rules_of_rep}.) Now that our system is \ncomplete, we can really begin to play around with it and explore the exciting logical world it creates.\n\nThere's an exciting logical world created by these eleven rules? Yes, yes there is. You can begin to see this by noticing that there are a lot of other interesting rules that we could \nhave used for our introduction and elimination rules, but didn't. In many textbooks, the system of natural deduction has a disjunction elimination rule that works like this:\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{ac}{\\script{A}\\eif\\script{C}}\n\t\\have[o]{bc}{\\script{B}\\eif\\script{C}}\n\t\\have[\\ ]{c}{\\script{C}} \\by{${\\eor}\\ast$}{ab,ac,bc}\n\\end{proof}\n\nYou might think our system is incomplete because it lacks this alternative rule of disjunction elimination. Yet this is not the case. If you can do a proof with this rule, you can do a \nproof with the basic rules of the natural deduction system. You actually proved this rule in problem \\ref{itm:const_d} of part \\ref{derivation_set_with_const_d} in the exercises for \nsection \\ref{sec:indirect_proof}. Furthermore, once you have a proof of this rule, you can use it inside other proofs whenever you think you would need a rule like $\\eor \\ast$. Simply use \nthe proof you gave in the last homework as a sort of recipe for generating a new series of steps to get you to a line saying $\\script{C} \\eor \\script{D}$\n\nBut adding lines to a proof using this recipe all the time would be a pain in the neck. What's worse, there are dozens of interesting possible rules out there, which we could have used \nfor our introduction and elimination rules, and which we now find ourselves replacing with recipes like the one above.\n\nFortunately our basic set of introduction and elimination rules, plus reiteration, was meant to be expanded on. That's part of the game we are playing here. The first system of deduction \ncreated in the Western tradition was the system of geometry created by Euclid (c 300 BCE). Euclid's \\emph{Elements} began with 10 basic laws, along with definitions of terms like \n``point,'' ``line,'' and ``plane.'' He then went on to prove hundreds of different theorems about geometry, and each time he proved a theorem he could use that theorem to help him prove \nlater theorems.\n\nWe can do the same thing in our system of natural deduction. What we need is a rule that will allow us to make up new rules. The new rules we add to the system will be called \\define{derived rules}. Our ten rules for adding and eliminating connectives are then the \\define{axioms} of SL. Now here is our rule for adding rules. \n\n{\\narrower \\narrower\n \n\\bf{Rule of Derived Theorem Introduction:} \\rm Given a derivation in SL of some argument $A_1$ \\ldots $A_n \\sststile{}{} B$, create the rule $\\script{A}_1$ \\ldots $\\script{A}_n \\sststile{}{} \\script{B}$ and assign a name to it of the form ``$T_n$'', to be read ``theorem n.'' Now given a derivation of some theorem $T_m$, where $n < m$, if $\\script{A_1}$ \\ldots $\\script{A_n}$ occur as earlier lines $x_1$ \\ldots $x_n$ in a proof, one may infer \\script{B}, and justify it ``$T_n$, $x_1$ \\ldots $x_n$'', so long as none of lines $x_1$ \\ldots $x_n$ are in a closed subproof.\n\\par\n}\n\n\nLet's make our rule $\\eor \\ast$ above our first theorem. The proof of $T_1$ is derived simply from the recipe above.\n\n{\\narrower\n\\bf $T_\\arabic{theorem} $ (Constructive Dilemma, CD): \\rm $ \\{ \\script{A} \\eor \\script {B}, \\script{A}\\eif\\script{C}, \\script{B}\\eif\\script{C} \\} \\sststile{}{} \t\\script{C}$\n\\addtocounter{theorem}{1}\n\\par\n}\n\nProof:\n\n\\begin{proof}\n\t\\hypo{1}{A\\eor B}\n\t\\hypo{2}{A\\eif C}\n\t\\hypo{3}{B \\eif C} \\by{want: C}{}\n\t\\open\n\t\t\\hypo{4}{\\enot{C}}\\by{for reductio}{}\n\t\t\t\\open\n\t\t\t\\hypo{5}{\\enot A} \\by{for reductio}{}\n\t\t\t\\have{6}{B} \\oe{1, 5}\n\t\t\t\\have{7}{C}\\ci{3, 6}\n\t\t\t\\have{8}{\\enot C} \\by{R}{4}\n\t\t\t\\close\n\t\t\\have{9}{A}\\ne{5-8}\n\t\t\\have{11}{C} \\ce{2, 10}\n\t\t\\have{12}{\\enot C} \\by{R}{4}\n\t\t\\close\n\t\\have{13}{C} \\ne{4-13}\t\t\n\\end{proof} \n\n\n\nInformally, we will refer to $T_1$ as ``Constructive Dilemma'' or by the abbreviation ``CD.'' Most theorems will have names and easy abbreviations like this. We will generally use the abbreviations to refer to the proofs when we use them in derivations, because they are easier to remember. \n\nSeveral other important theorems have already appeared as examples or in homework problems. We'll talk about most of them in the next section, when we discuss rules of replacement. In the meantime, there is one important one we need to introduce now\n\n{\\narrower\n$\\mathbf T_\\arabic{theorem}$  \\bf (Modus Tollens, MT): \\rm $\\{ \\script{A} \\eif \\script{B}, \\enot \\script{B} \\} \\sststile{}{} \\hspace{.25em} \\enot \\script{A}$\n\\addtocounter{theorem}{1}\n\\par}\n\nProof: See page \\pageref{ModusTollens}\n\nNow that we have some theorems, let's close by looking at how they can be used in a proof. \n\n\n$\\mathbf T_\\arabic{theorem}$ \\bf (Destructive Dilemma, DD): \\rm $ \\{ \\script{A} \\eif \\script{B}, \\script{A} \\eif \\script{C}, \\enot \\script{B} \\eor \\enot \\script{C} \\} \\sststile{}{} \\hspace{.25em} \\enot \\script{A}$\n\\addtocounter{theorem}{1}\n\n\\begin{proof}\n\\hypo{1}{A \\eif B}\n\\hypo{2}{A \\eif C}\n\\hypo{3}{\\enot B \\eor \\enot C} \\by{Want: \\enot A}{}\n\t\\open\n\t\\hypo{4}{A} \\by{for reductio}{}\n\t\\have{5}{B} \\ce{1, 4}\n\t\t\\open\n\t\t\\hypo{6}{\\enot B} \\by{For reductio}{}\n\t\t\\have{7}{B} \\by{R}{5}\n\t\t\\have{8}{\\enot B} \\by{R}{6}\n\t\t\\close\n\t\\have{9}{\\enot \\enot B} \\ni{6-8}\n\t\\have{10}{\\enot C} \\oe{3, 9}\n\t\\have{11}{A}\t\\by{R}{4}\n\t\\have{12}{\\enot A} \\by{MT}{2, 10}\n\t\\close\n\\have{13}{\\enot A} \\ni{4-12}\n\\end{proof}\n\n\n%%%%%%%%%%%%%%%%%          Practice problems %%%%%%\n\n\\practiceproblems\n \n\n\\noindent\\problempart\nProve the following theorems\n\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item $T_\\arabic{theorem}$ (Hypothetical Syllogism, HS): $ \\{ \\script{A} \\eif \\script{B}, \\script{B} \\eif \\script{C} \\} \\sststile{}{} \\hspace{.25em} \\script{A} \\eif \\script{C}$\n\\addtocounter{theorem}{1}\n\n\n%\\begin{proof}\n%\\hypo{1}{A \\eif B}\n%\\hypo{2}{B \\eif C} \\by{Want: A \\eif C}{}\n%\t\\open\n%\t\\hypo{3}{A} \\by{Want: C}{}\n%\t\\have{4}{B} \\ce{1, 3}\n%\t\\have{5}{C} \\ce{2, 4}\n%\t\\close\n%\\have{6}{A \\eif C} \\ci{3-5}\n%\\end{proof}\n\n\\item $T_\\arabic{theorem}$ (Idempotence of \\eor, Idem\\eor): $  \\script{A} \\eor \\script{A}  \\sststile{}{} \\script{A} $\n\\addtocounter{theorem}{1}\n\n\\item $T_\\arabic{theorem}$ (Idempotence of \\eand, Idem\\eand): $  \\script{A} \\sststile{}{} \\script{A} \\eand \\script{A} $\n\\addtocounter{theorem}{1}\n\n%\\begin{proof}\n%\\hypo{1}{A} \\by{Want A \\eand A}{}\n%\\have{2}{A} \\by{R}{1}\n%\\have{3}{A \\eand A} \\ai{1, 2}\n%\\end{proof}\n\n\\item $ T_\\arabic{theorem}$ (Weakening, WK): \\rm $\\script{A} \\sststile{}{} \\script{B} \\eif \\script{A}$ \\\\\n\\addtocounter{theorem}{1}\n\n\\end{enumerate}\n\n%\\item $\\enot\\enot\\enot\\enot G$, $G$\n\n\\noindent\\problempart\nProvide proofs using both axioms and derived rules to show each of the following.\n\\begin{enumerate}[label=(\\arabic*)]\n\\item \\{$M \\eand (\\enot N \\eif \\enot M) \\} \\sststile{}{} (N \\eand M) \\eor \\enot M$\n\n%\\begin{proof}\n%\\hypo{1}{M \\eand (\\enot N \\eif \\enot M)} \\by{Want: $(N \\eand M) \\eor \\enot M$}{}\n%\\have{2}{M} \\ae{1}\n%\\have{3}{\\enot N \\eif \\enot M} \\ae{1}\n%\t\\open\n%\t\\hypo{4}{\\enot N} \\by{For reductio}{}\n%\t\\have{5}{M} \\by{R}{2}\n%\t\\have{6}{\\enot M} \\by{\\eif E}{3, 4}\n%\t\\close\n%\\have{7}{N} \\ne{4-6}\n%\\have{8}{N \\eand M} \\ai{2, 7}\n%\\have{9}{(N \\eand M) \\eor M} \\oi{8}\n%\\end{proof}\n\n\n\n\\item \\{$C\\eif(E\\eand G)$, $\\enot C \\eif G$\\} $\\sststile{}{}$ $G$\n\\item \\{$(Z\\eand K)\\eiff(Y\\eand M)$, $D\\eand(D\\eif M)$\\} $\\sststile{}{}$ $Y\\eif Z$\n\n%\\begin{proof}\n%\\hypo{1}{(Z\\eand K)\\eiff(Y\\eand M)}\n%\\hypo{2}{D\\eand(D\\eif M)} \\by{Want: Y \\eif Z}{}\n%\\have[3]{3}{D} \\ae{2}\n%\\have[4]{4}{D \\eif M} \\ae{2}\n%\\have[5]{5}{M} \\ce{3-4}\n%\t\\open\n%\t\\hypo[6]{6}{Y} \\by{Want: Z}{}\n%\t\\have[7]{7}{Y \\eand M} \\ai{5, 6}\n%\t\\have[8]{8}{Z \\eand K} \\by{\\eiff E, 1, 7}{}\n%\t\\have[9]{9}{Z} \\ae{8}\n%\t\\close\n%\\have[10]{10}{Y \\eif Z} \\ci{6-9}\n%\\end{proof}\n\n\n\n\\item \\{$(W \\eor X) \\eor (Y \\eor Z)$, $X\\eif Y$, $\\enot Z$\\} $\\sststile{}{}$ $W\\eor Y$\n\\item \\{$(B \\eif C) \\eand (C \\eif D), (B \\eif D) \\eif A $ \\}$ \\sststile{}{}$ $A$\n\n%\\begin{proof}\n%\\hypo{1}{(B \\eif C) \\eand (C \\eif D)}\n%\\hypo{2}{(B \\eif D) \\eif A} \\by{Want: A}{}\\\n%\\have{3}{B \\eif C}\\by{\\eand E}{1}\n%\\have{4}{C \\eif D} \\by{\\eand E}{1}\n%\\have{5}{B \\eif D} \\by{HS}{3, 5}\n%\\have{6}{A} \\by{\\eif E}{2, 5}\n%\\end{proof}\n\n\n\\end{enumerate}\n\n\\noindent\\problempart\n\\begin{enumerate}[label=(\\arabic*)]\n\n\\item If you know that $\\script{A}\\sststile{}{}\\script{B}$, what can you say about $(\\script{A}\\eand\\script{C})\\sststile{}{}\\script{B}$? Explain your answer.\n\n%1) It is valid. If you know that \\script{A} on its own implies \\script{B}, then a proof of $(\\script{A}\\eand\\script{C})\\sststile{}{}\\script{B}$ would only require \\eand E and then the proof that $\\script{A}\\sststile{}{}\\script{B}$\n\n\n\\item If you know that $\\script{A}\\sststile{}{}\\script{B}$, what can you say about $(\\script{A}\\eor\\script{C})\\sststile{}{}\\script{B}$? Explain your answer.\n\\end{enumerate}\n\n\n\n\n\n% *******************************************\n% *\t\t\t\tRules of Replacement\t\t\t   *\t\n% *******************************************\n\\section{Rules of Replacement}\n\\label{sec:rules_of_rep}\n\\setlength{\\parindent}{1em}\n\n\n\nVery often in a derivation, you have probably been tempted to apply a rule to a part of a line. For instance, if you knew $F\\eif(G\\eand H)$ and wanted $F\\eif G$, you would be tempted to apply \\eand E to just the $G \\eand H$ part of $F \\eif (G \\eand H)$. But, of course you aren't allowed to do that. We will now introduce some new derived rules where you can do that. These are called \\define{rules of replacement}, because they can be used to replace part of a sentence with a logically equivalent expression. What makes the rules of replacement different from other derived rules is that they draw on only one previous line and are symmetrical, so that you can reverse premise and conclusion and still have a valid argument. Some of the most simple examples are Theorems $8-10$, the rules of commutativity for \\eand, \\eor, and \\eiff. \n\n{\\narrower\n\n\n$\\mathbf T_\\arabic{theorem}$  \\bf (Commutativity of \\eand, Comm\\eand): \\rm $(\\script{A}\\eand\\script{B}) \\nsststile{}{} \\hspace{.25em} \\sststile{}{}  (\\script{B}\\eand\\script{A})$\\\\ \n\\addtocounter{theorem}{1}\n$\\mathbf T_\\arabic{theorem}$  \\bf (Commutativity of \\eor, Comm\\eor): \\rm $(\\script{A}\\eor\\script{B}) \\nsststile{}{} \\hspace{.25em} \\sststile{}{} (\\script{B}\\eor\\script{A})$\\\\\n\\addtocounter{theorem}{1}\n$\\mathbf T_{\\arabic{theorem}}$  \\bf (Commutativity of \\eiff, Comm\\eiff): \\rm $(\\script{A}\\eiff\\script{B}) \\nsststile{}{} \\hspace{.25em} \\sststile{}{} (\\script{B}\\eiff\\script{A})$\n\\addtocounter{theorem}{1}\n\n\\par}\n\n\nYou will be asked to prove these in the homework. In the meantime, let's see an example of how they work in a proof. Suppose you wanted to prove $(M \\eor P) \\eif (P \\eand M)$, $\\therefore$\\ $(P \\eor M) \\eif (M \\eand P)$ You could do it using only the basic rules, but it will be long and inconvenient. With the Comm rules, we can provide a proof easily:\n\n\\begin{proof}\n\t\\hypo{1}{(M \\eor P) \\eif (P \\eand M)}\n\t\\have{2}{(P \\eor M) \\eif (P \\eand M)}\\by{Comm\\eand}{1}\n\t\\have{n}{(P \\eor M) \\eif (M \\eand P)}\\by{Comm\\eor}{2}\n\\end{proof}\n\nFormally, we can put our rule for deploying rules of replacement like this\n\n{\\narrower \\narrower\n \n\\noindent\\bf Inserting rules of replacement: \\rm Given a theorem T of the form $\\script{A} \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\script B$ and a line in a derivation \\script{C} which contains in it a sentence \\script{D}, where \\script{D} is a substitution instance of either \\script{A} or \\script{B}, replace \\script{D} with the equivalent substitution instance of the other side of theorem T. \n\\setlength{\\parindent}{1em}\n\n\\par}\n\n\\setlength{\\parindent}{1em}\n\nHere are some other important theorems that can act as rules of replacement. Some are theorems we have already proved, while you will be asked to prove others in the homework.\n\n{\\narrower\n\n$\\mathbf T_{\\arabic{theorem}}$ \\bf (Double Negation, DN): \\rm $\\script{A} \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} \\enot \\enot \\script{A}$\n\\addtocounter{theorem}{1}\n\\par}\nProof: See pages \\pageref{DN1} and \\pageref{DN2}. \n\n{\\narrower\n\n$\\mathbf T_{\\arabic{theorem}}$: \\rm $\\enot(\\script{A} \\eor \\script{B}) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} \\enot \\script{A} \\eand \\enot \\script{B}$\n\\addtocounter{theorem}{1}\n\\par}\nProof: See page \\pageref{DeM1}\n\n{\\narrower\n$\\mathbf T_{\\arabic{theorem}}$: \\rm $\\enot (\\script{A} \\eand \\script{B}) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} \\enot \\script{A} \\eor \\enot \\script{B}$\n\\addtocounter{theorem}{1}\n\\par}\n\nProof: See pages \\pageref{DeM3} and \\pageref{DeM4}.\n\n\n\n$ T_{12}$  and $T_{13}$ are collectively known as \\define{DeMorgan's Laws}, and we will use the abbreviation DeM to refer to either of them in proofs.\n\n\n{\\narrower\n\n$ \\mathbf T_{\\arabic{theorem}}$: \\rm $(\\script{A}\\eif\\script{B}) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} (\\enot\\script{A}\\eor\\script{B})$ \n\\addtocounter{theorem}{1}\n\n\n$ \\mathbf T_{\\arabic{theorem}}$: \\rm $(\\script{A}\\eor\\script{B}) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} (\\enot\\script{A}\\eif\\script{B})$  \n\\addtocounter{theorem}{1}\n\n\\par}\n\n$ T_{14}$ and $T_{15}$ are collectively known as the rule of Material Conditional (MC). You will prove them in the homework. \n\n \n$ \\mathbf T_{\\arabic{theorem}}$ \\bf (Biconditional Exportation, ex): \\rm $\\script{A}\\eiff \\script{B} \\nsststile{}{} \\hspace{.5em} \\sststile{}{} (\\script{A} \\eif \\script{B})\\eand(\\script{B}\\eif \\script{\\script{A}})$ \n\\addtocounter{theorem}{1}\n\\setlength{\\parindent}{1em}\n\nProof: See the homework.\n\n{\\narrower\n$ \\mathbf T_{\\arabic{theorem}}$ \\bf (Transposition, trans): \\rm $\\script{A}\\eif \\script{B} \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\hspace{.25em} \\enot \\script{B} \\eif \\enot \\script{A}$ \\addtocounter{theorem}{1}\n\\par}\n\nProof: See the homework.\n\n\nTo see how much these theorems can help us, consider this argument: $$\\enot(P \\eif Q) \\sststile{}{} P \\eand \\enot Q$$\n\nAs always, we could prove this argument using only the basic rules. With rules of replacement, though, the proof is much simpler:\n\n \n\n\\begin{proof}\n\t\\hypo{1}{\\enot(P \\eif Q)}\n\t\\have{2}{\\enot(\\enot P \\eor Q)}\\by{MC}{1}\n\t\\have{3}{\\enot\\enot P \\eand \\enot Q}\\by{DeM}{2}\n\t\\have{4}{P \\eand \\enot Q}\\by{DN}{3}\n\\end{proof}\n\n%Although they don't do it in the book, I've been in the habit of writing $(\\script{A}\\eand\\script{B}\\eand\\script{C})$ and dropping the inner pair of parentheses. This is fine. If we'd wanted to, we could have defined the basic rules in a more general way:\n\n%\\begin{proof}\n%\t\\have[n]{a1}{\\script{A}_1}\n%\t\\have{2}{\\script{A}_2}\n%\t\\have[\\vdots]{1}{\\vdots}\n%\t\\have[n]{an}{\\script{A}_n}\n%\t\\have[\\ ]{aaa}{\\script{A}_1~\\eand\\ldots\\eand~\\script{A}_n} \\ai{}\n%\\end{proof}\n\n%\\bigskip\n%\\begin{proof}\n%\t\\have{3}{\\script{A}_1~\\eand\\ldots\\eand~\\script{A}_n}\n%\t\\have{1}{\\script{A}_i} \\ae{}\n%\\end{proof}\n\n%\\bigskip\n%\\begin{proof}\n%\t\\have{1}{\\script{A}}\n%\t\\have{3}{\\script{A}\\eor\\script{B}_1\\eor\\script{B}_2\\ldots\\eor\\script{B}_n} \\ai{}\n%\\end{proof}\n\n%We don't need these extended versions, since for any given n we could prove them as a derived rule.\n\n\n\n\n%%%%%%%%%%%%%          Practice problems %%%%%%%%%\n \n\n\\practiceproblems\n\\noindent\\problempart\nProve $T_{8}$ through $T_{10}$. You may use $T_{1}$ through $T_7$ in your proofs.\n\n\\noindent\\problempart\nProve $T_{11}$ through $T_{17}$. You may use $T_{1}$ through $T_{12}$ in your proofs.\n\n\n\n\n% *******************************************\n% *\t\t\t\tProof Strategy\t\t\t\t\t   *\t\n% *******************************************\n\n\n\\section{Proof Strategy}\n\\setlength{\\parindent}{1em}\nThere is no simple recipe for proofs, and there is no substitute for practice. Here, though, are some rules of thumb and strategies to keep in mind.\n\n\\emph{Work backwards from what you want.}\nThe ultimate goal is to derive the conclusion. Look at the conclusion and ask what the introduction rule is for its main logical operator. This gives you an idea of what should happen \\emph{just before} the last line of the proof. Then you can treat this line as if it were your goal. Ask what you could do to derive this new goal. For example: If your conclusion is a conditional $\\script{A}\\eif\\script{B}$, plan to use the {\\eif}I rule. This requires starting a subproof in which you assume \\script{A}. In the subproof, you want to derive \\script{B}. Similarly, if your conclusion is a biconditional, $\\script{A} \\eiff \\script{B}$, plan on using {\\eiff}I and be prepared to launch two subproofs. If you are trying to prove a single sentence letter or a negated single sentence letter, you might plan on using indirect proof. \n\n%Rob: I removed QL examples here and put ih more SL examples\n\n\\emph{Work forwards from what you have.}\nWhen you are starting a proof, look at the premises; later, look at the sentences that you have derived so far. Think about the elimination rules for the main operators of these sentences. These will tell you what your options are. For example: If you have $A \\eand B$ use \\eand E to get $A$ and $B$ separately. If you have $A \\eor B$ see if you can find the negation of either $A$ or $B$ and use \\eor E.\n\n\\emph{Repeat as necessary.} Once you have decided how you might be able to get to the conclusion, ask what you might be able to do with the premises. Then consider the target sentences again and ask how you might reach them.  Remember, a long proof is formally just a number of short proofs linked together, so you can fill the gap by alternately working back from the conclusion and forward from the premises.\n\n%Rob: I deleted a sentence from ``work forward from what you have'' that didn't make sense and then merged other material in the the ``repeat as necessary'' section.. \n\n\\emph{Change what you are looking at.} Replacement rules can often make your life easier. If a proof seems impossible, try out some different substitutions.For example: It is often difficult to prove a disjunction using the basic rules. If you want to show $\\script{A}\\eor\\script{B}$, it is often easier to show $\\enot\\script{A}\\eif\\script{B}$ and use the MC rule. Some replacement rules should become second nature. If you see a negated disjunction, for instance, you should immediately think of DeMorgan's rule.\n\n\\emph{When all else fails, try indirect proof.} If you cannot find a way to show something directly, try assuming its negation. Remember that most proofs can be done either indirectly or directly. One way might be easier---or perhaps one sparks your imagination more than the other---but either one is formally legitimate.\n\n%Rob: I changed the way the advice is phrased to match the slogan I repeat in class.\n\n%\\emph{Persist.} Try different things. If one approach fails, then try something else.\n% Rob: deleted ``persist'' in favor of other advice.\n\n\\emph{Take a break} If you are completely stuck, put down your pen and paper, get up from your computer, and do something completely different for a while. Walk the dog. Do the dishes. Take a shower. I find it especially helpful to do something physically active. Doing other desk work or watching TV doesn't have the same effect. When you come back to the problem, everything will seem clearer. Of course, if you are in a testing situation, taking a break to walk around might not be advisible. Instead, switch to another problem.\n\nA lot of times, when you are stuck, your mind keeps trying the same solution again and again, even though you know it won't work. ``If I only knew $Q \\eif R$,'' you say to yourself, ``it would all work. Why can't I derive $Q \\eif R$!'' If you go away from a problem and then come back, you might not be as focused on That One Thing that you were sure you needed, and you can find a different approach.\n\n\t\n%I added the section on taking a break\n\n\n%%%%%%%Practice problems %%%%%%%%%\n\n\\practiceproblems\n \n\\noindent\\problempart\n \nShow the following theorems are valid. Feel free to use $T_{1}$ through $T_{17}$\n\n\\begin{enumerate}[label=(\\arabic*)]\n\\item $ T_{\\arabic{theorem}}$ (Associativity of \\eand, Ass\\eand): \\rm $(\\script{A} \\eand \\script{B}) \\eand \\script{C} \\nsststile{}{} \\hspace{.25em} \\sststile{}{} \\script{A} \\eand (\\script{B} \\eand \\script{C})$ \\\\ \\addtocounter{theorem}{1}\n\\item $ T_{\\arabic{theorem}}$  (Associativity of \\eor, Ass\\eor): \\rm $(\\script{A} \\eor \\script{B}) \\eor \\script{C} \\nsststile{}{} \\hspace{.25em} \\sststile{}{} \\script{A} \\eor (\\script{B} \\eor \\script{C})$ \t\\\\ \\addtocounter{theorem}{1}\n\\item $ T_{\\arabic{theorem}}$  (Associativity of \\eiff, Ass\\eiff): \\rm $(\\script{A} \\eiff \\script{B}) \\eiff \\script{C} \\nsststile{}{} \\hspace{.25em} \\sststile{}{} \\script{A} \\eiff (\\script{B} \\eiff \\script{C})$ \t\\addtocounter{theorem}{1}\n\\end{enumerate}\n\n\n% *******************************************\n% *\t\t\tSoundness and completeness\t\t\t   *\t\n% *******************************************\n\n%I merged sections 6.7, 6.8, and 6.9 and restricted the material to SL to create this section. \n\\section{Soundness and completeness}\n\\label{sec:soundness_and_completeness}\n In section \\ref{sec:taut-eq-incon}, we saw that we could use derivations to test for the same concepts we used truth tables to test for. Not only could we use derivations to prove that an argument is valid, \nwe could also use them to test if a statement is a tautology, if a pair of statements are equivalent, or if a set of sentences are inconsistent. We also started using the single turnstile \nthe same way we used the double turnstile. If we could prove that \\script{A} was a tautology with a truth table, we wrote $\\sdtstile{}{}\\script{A}$, and if we could prove it using a \nderivation, we wrote $\\sststile{}{}\\script{A}.$\n\nYou may have wondered at that point if the two kinds of turnstiles always worked the same way. If you can show that \\script{A} is a tautology using truth tables, can you also always show \nthat it is true using a derivation? Is the reverse true? Are these things also true for tautologies and pairs of equivalent sentences? As it turns out, the answer to all these questions \nand many more like them is yes. We can show this by defining all these concepts separately and then proving them equivalent. That is, we imagine that we actually have two notions of \nvalidity, $valid_{\\models}$ and $valid_{\\vdash}$ and then show that the two concepts always work the same way.\n\n\\newglossaryentry{syntactic contradiction in SL}\n{\nname=syntactic contradiction in SL,\ndescription={A statement in SL whose negation can be derived without any premises.}\n}\n\n\n   \n\\newglossaryentry{syntactically contingent in SL}\n{\nname=syntactically contingent in SL,\ndescription={A property held by a statement in SL if and only if it is not a syntactic tautology or a syntactic contradiction.}\n}\n\n\n\n\nTo begin with, we need to define all of our logical concepts separately for truth tables and derivations. A lot of this work has already been done. We handled all of the truth table definitions in Chapter \\ref{chap:truth_tables}. We have also already given syntactic definitions for a tautologies and pairs of logically equivalent sentences. The other definitions follow naturally. For most logical properties we can devise a test using derivations, and those that we cannot test for directly can be defined in terms of the concepts that we can define.\n\nFor instance, we defined a syntactic tautology as a statement that can be derived without any premises (p. \\pageref{def:syntactic_tautology_in_sl}). Since the negation of a contradiction is a tautology, we can define a \\textsc{\\gls{syntactic contradiction in SL}} \\label{def:syntactic_contradiction_in_sl} as a sentence whose negation can be derived without any premises. The syntactic definition of a contingent sentence is a little different. We don't have any practical, finite method for proving that a sentence is contingent using derivations, the way we did using truth tables. So we have to content ourselves with defining ``contingent sentence'' negatively. A sentence is \\textsc{\\gls{syntactically contingent in SL}} \\label{def:syntactically_contingent_in_sl} if it is not a syntactic tautology or contradiction. \n \n\\newglossaryentry{syntactically inconsistent in SL}\n{\nname=syntactically inconsistent in SL,\ndescription={A property held by sets of sentences in SL if and only if one can derive a contradiction from them.}\n}\n\n\\newglossaryentry{syntactically consistent in SL}\n{\nname=syntactically consistent in SL,\ndescription={A property held by sets of sentences in SL if and only if they are not syntactically inconsistent.}\n}\n\nA set of sentences is \\textsc{\\gls{syntactically inconsistent in SL}} \\label{def:syntactically_inconsistent_ in_sl} if and only if one can derive a contradiction from them. Consistency, on the other hand, is like contingency, in that we do not have a practical finite method to test for it directly. So again, we have to define a term negatively. A set of set of sentences is \\textsc{\\gls{syntactically consistent in SL}} \\label{def:syntactically consistent in SL} if and only if they are not syntactically inconsistent.\n    \n\\newglossaryentry{syntactically valid in SL}\n{\nname=syntactically valid in SL,\ndescription={A property held by arguments in SL if and only if there is a derivation that goes from the premises to the conclusion.}\n}\n\nFinally, an argument is \\textsc{\\gls{syntactically valid in SL}} \\label{def:syntactically_valid_in_SL} if and only if there is a derivation of it. All of these definitions are given in Table \\ref{table:truth_tables_or_derivations}.\n\n\n\\begin{sidewaystable}\n\\begin{mdframed}[style=mytablebox]\n\\tabulinesep=1ex\n\\begin{tabu}{X[.5,c,m] ||X[1,l,m] |X[1,l,m]}\n\\bf{Concept} \t\t&\t\\bf{Truth table (semantic) definition} \t&\t\\bf{Derivation (syntactic) definition} \\\\ \\hline \\hline\n\nTautology  &\tA statement whose truth table only has Ts under the main connective & A statement that can be derived without any premises.\t \\\\ \\hline\n \nContradiction\t\t&\tA statement whose truth table only has Fs under the main connective  &\tA statement whose negation can be derived without any premises\\\\ \\hline\n\nContingent sentence\t&\tA statement whose truth table contains both Ts and Fs under the main connective & A statement that is not a syntactic tautology or contradiction \\\\ \\hline\n\nEquivalent sentences &\tThe columns under the main connectives are identical.& The statements can be derived from each other\t\\\\ \\hline\n\nInconsistent sentences\t&\tSentences which do not have a single line in their truth table where they are all true.\t& Sentences which one can derive a contradiction from \\\\ \\hline\n\nConsistent sentences\t&\tSentences which have at least one line in their truth table where they are all true. & Sentences which are no inconsistent\t\\\\ \\hline\n\nValid argument\t\t&\tAn argument whose truth table has no lines where there are all Ts under main connectives for the premises and an F under the main connective for the conclusion.  & An argument where can derive the conclusion from the premises\t\\\\ \n\\end{tabu}\n\\end{mdframed}\n\\caption{Two ways to define logical concepts.}\n\\label{table:truth_tables_or_derivations}\n\\end{sidewaystable}\n\nAll of our concepts have now been defined both semantically and syntactically. How can we prove that these definitions always work the same way? A full proof here goes well beyond the scope of this book. However, we can sketch what it would be like. We will focus on showing the two notions of validity to be equivalent.  From that the other concepts will follow quickly. The proof will have to go in two directions. First we will have to show that things which are syntactically valid will also be semantically valid. In other words, everything that we can prove using derivations could also be proven using truth tables. Put symbolically, we want to show that $valid_{\\vdash}$ implies $valid_{\\models}$. Afterwards, we will need to show things in the other directions,  $valid_{\\models}$ implies $valid_{\\vdash}$\n\n\\newglossaryentry{soundness}\n{\nname=soundness,\ndescription={A property held by logical systems if and only if $\\sststile{}{}$ implies $\\sdtstile{}{}$}\n}\n\nThis argument from $\\sststile{}{}$ to $\\sdtstile{}{}$ is the problem of \\textsc{\\gls{soundness}}. \\label{def:soundness} A proof system is \\define{sound} if there are no derivations of arguments that can be shown invalid by truth tables. \\label{def_Soundness} Demonstrating that the proof system is sound would require showing that \\emph{any} possible proof is the proof of a valid argument. It would not be enough simply to succeed when trying to prove many valid arguments and to fail when trying to prove invalid ones.\n\nThe proof that we will sketch depends on the fact that we initially defined a sentence of SL using a recursive definition (see p. \\pageref{def:recursive_definition}). We could have also used recursive definitions to define a proper proof in SL and a proper truth table. \\nix{Later this will be a truth assignment}(Although we didn't.) If we had these definitions, we could then use a \\emph{recursive proof} to show the soundness of SL. A recursive proof works the same way a recursive definition does.With the recursive definition, we identified a group of base elements that were stipulated to be examples of the thing we were trying to define. In the case of a well formed formula, the base class was the set of sentence letters A, B, C \\ldots{}. We just announced that these were sentences. The second step of a recursive definition is to say that anything that is built up from your base class using certain rules also counts as an example of the thing you are defining. In the case of a definition of a sentence, the rules corresponded to the five sentential connectives (see p. \\pageref{def:sentence_of_SL}). Once you have established a recursive definition, you can use that definition to show that all the members of the class you have defined have a certain property. You simply prove that the property is true of the members of the base class, and then you prove that the rules for extending the base class don't change the property. This is what it means to give a recursive proof.\n\nEven though we don't have a recursive definition of a proof in SL, we can sketch how a recursive proof of the soundness of SL would go. Imagine a base class of one-line proofs, one for each of our eleven rules of inference. The members of this class would look like this $\\{\\script{A}, \\script{B}\\} \\sststile{}{} \\script{A} \\eand \\script{B}$; $\\script{A} \\eand \\script{B} \\sststile{}{}\\script{A}$; $\\{\\script{A} \\eor \\script{B}, \\enot\\script{A}\\} \\sststile{}{} \\script{B}$ \\ldots{} etc. Since some rules have a couple different forms, we would have to have add some members to this base class, for instance $\\script{A} \\eand \\script{B} \\sststile{}{} \\script{B}$ Notice that these are all statements in the metalanguage. The proof that SL is sound is not a part of SL, because SL does not have the power to talk about itself. \n\nYou can use truth tables to prove to yourself that each of these one-line proofs in this base class is $valid_{\\models}$. For instance the proof $\\{\\script{A}, \\script{B}\\} \\sststile{}{} \\script{A} \\eand \\script{B}$ corresponds to a truth table that shows $\\{\\script{A}, \\script{B}\\} \\sdtstile{}{} \\script{A} \\eand \\script{B}$ This establishes the first part of our recursive proof. \n\nThe next step is to show that adding lines to any proof will never change a $valid_{\\models}$ proof into an $invalid_{\\models}$ one. We would need to this for each of our eleven basic rules of inference. So, for instance, for \\eand{I} we need to show that for any proof $\\script{A}_{1} \\ldots{} \\script{A}_{n} \\sststile{}{} \\script {B}$ adding a line where we use \\eand{I} to infer $\\script{C} \\eand \\script{D}$, where $\\script{C} \\eand \\script{D}$ can be legitimately inferred from $\\{\\script{A}_{1} \\ldots{} \\script{A}_{n}, \\script {B}\\}$, would not change a valid proof into an invalid proof. But wait, if we can legitimately derive $\\script{C} \\eand \\script{D}$ from these premises, then $\\script{C} and \\script{D}$ must be already available in the proof. They are either members of  $\\{\\script{A}_{1} \\ldots{} \\script{A}_{n}, \\script {B}\\}$ or can be legitimately derived from them. As such, any truth table line in which the premises are true must be a truth table line in which \\script{C} and \\script{D} are true. According to the characteristic truth table for \\eand, this means that \\script{C}\\eand\\script{D} is also true on that line. Therefore, \\script{C}\\eand\\script{D} validly follows from the premises. This means that using the {\\eand}E rule to extend a valid proof produces another valid proof.\n\nIn order to show that the proof system is sound, we would need to show this for the other inference rules. Since the derived rules are consequences of the basic rules, it would suffice to provide similar arguments for the 11 other basic rules. This tedious exercise falls beyond the scope of this book.\n\nSo we have shown that $\\script{A} \\sststile{}{} \\script{B}$ implies $\\script{A} \\sdtstile{}{}\\script{B}.$ What about the other direction, that is why think that \\emph{every} argument that can be shown valid using truth tables can also be proven using a derivation. \n\n\\newglossaryentry{completeness}\n{\nname=completeness,\ndescription={A property held by logical systems if and only if $\\sdtstile{}{}$ implies $\\sststile{}{}$}\n}\n\nThis is the problem of completeness. A proof system has the property of  \\textsc{\\gls{completeness}} \\label{def:completeness} if and only if there is a derivation of every semantically valid argument. Proving that a system is complete is generally harder than proving that it is sound. Proving that a system is sound amounts to showing that all of the rules of your proof system work the way they are supposed to. Showing that a system is complete means showing that you have included \\emph{all} the rules you need, that you haven't left any out. Showing this is beyond the scope of this book. The important point is that, happily, the proof system for SL is both sound and complete. This is not the case for all proof systems and all formal languages. Because it is true of SL, we can choose to give proofs or give truth tables---whichever is easier for the task at hand.\n\nNow that we know that the truth table method is interchangeable with the method of derivation, you can chose which method you want to use for any given problem. Students often prefer to use truth tables, because a person can produce them purely mechanically, and that seems `easier'. However, we have already seen that truth tables become impossibly large after just a few sentence letters. On the other hand, there are a couple situations where using derivations simply isn't possible. We syntactically defined a contingent sentence as a sentence that couldn't be proven to be a tautology or a contradiction. There is no practical way to prove this kind of negative statement. We will never know if there isn't some proof out there that a statement is a contradiction and we just haven't found it yet. We have nothing to do in this situation but resort to truth tables. Similarly, we can use derivations to prove two sentences equivalent, but what if we want to prove that they are \\emph{not} equivalent? We have no way of proving that we will never find the relevant proof. So we have to fall back on truth tables again.\n\nTable \\ref{table.ProofOrModel} summarizes when it is best to give proofs and when it is best to give truth tables. \n\n\\begin{table}\n\\tabulinesep=1ex\n\\begin{mdframed}[style=mytablebox]\n\\begin{tabu}{X[.5,l,b] X[1,l,b] X[1,l,b]}\n\\underline{Property}\t\t& \\underline{To prove it present} \t&\t\\underline{To prove it absent} \\\\ \nBeing a tautology \t\t\t& Derive the statement  \t\t\t\t\t\t& Find the false line in the truth table for the sentence \\\\ \nBeing a contradiction \t\t&  Derive the negation of the statement  \t\t & Find the true line in the truth table for the sentence\\\\ \nContingency\t\t\t \t\t& Find a false line and a true line in the truth table for the statement & Prove the statement or its negation\\\\ \nEquivalence \t\t\t\t\t& Derive each statement from the other \t\t & Find a line in the truth tables for the statements where they have different values\\\\ \nConsistency\t \t\t\t\t& Find a line in truth table for the sentence where they all are true & Derive a contradiction from the sentences\\\\ \nValidity\t\t \t\t\t\t& Derive the conclusion form the premises & Find a line in the truth table where the premises are true and the conclusion false. \\\\ \n\\end{tabu}\n\\end{mdframed}\n\\caption{When to provide a truth table and when to provide a proof.}\n\\label{table.ProofOrModel}\n\\end{table}\n\n\n\n\\practiceproblems\n\\noindent\\problempart Use either a derivation or a truth table for each of the following. \n\\begin{enumerate}[label=(\\arabic*)]\n\\item Show that $A \\eif [((B \\eand C) \\eor D) \\eif A]$ is a tautology.\n\\item Show that $A \\eif (A \\eif B)$ is not a tautology\n\\item Show that the sentence $A \\eif \\enot{A}$ is not a contradiction.\n\\item Show that the sentence $A \\eiff \\enot A$ is a contradiction. \n\\item Show that the sentence $ \\enot (W \\eif (J \\eor J)) $ is contingent\n\\item Show that the sentence $ \\enot(X \\eor (Y \\eor Z)) \\eor (X \\eor (Y \\eor Z))$ is not contingent\n\\item Show that the sentence $B \\eif \\enot S$ is equivalent to the sentence $\\enot \\enot B \\eif \\enot S$\n\\item Show that the sentence $ \\enot (X \\eor O) $ is not equivalent to the sentence $X \\eand O$\n\\item Show that the set $\\{\\enot(A \\eor B), C, C \\eif A\\}$ is inconsistent.\n\\item Show that the set \\{\\enot(A \\eor B), \\enot{B}, B \\eif A\\} is consistent\n\\item Show that $\\enot(A \\eor (B \\eor C)) $ \\therefore $ \\enot{C}$ is valid.\n\\item Show that $\\enot(A \\eand (B \\eor C))$ \\therefore $ \\enot{C}$ is invalid. \n\\end{enumerate}\n\n\n\\noindent\\problempart Use either a derivation or a truth table for each of the following. \n\\begin{enumerate}[label=(\\arabic*)]\n\\item Show that $A \\eif (B \\eif A)$ is a tautology\n\\item Show that $\\enot (((N \\eiff Q) \\eor Q) \\eor N)$ is not a tautology\n\\item Show that $ Z \\eor (\\enot Z \\eiff Z) $ is contingent\n\\item Show that $ (L \\eiff ((N \\eif N) \\eif L)) \\eor H $ is not contingent\n\\item Show that $ (A \\eiff A) \\eand (B \\eand \\enot B)$ is a contradiction\n\\item Show that $ (B \\eiff (C \\eor B)) $ is not a contradiction.\n\\item Show that $ ((\\enot X \\eiff X) \\eor X) $ is equivalent to $X$\n\\item Show that $F \\eand (K \\eand R) $ is not equivalent to $ (F \\eiff (K \\eiff R)) $\n\\item Show that the set \\{$ \\enot (W \\eif W)$, $(W \\eiff W) \\eand W$, $E \\eor (W \\eif \\enot (E \\eand W))$\\} is inconsistent.\n\\item Show that the set  \\{$\\enot R \\eor C $, $(C \\eand R) \\eif \\not R$, $(\\enot (R \\eor R) \\eif R) $\\} is consistent.\n\\item Show that $\\enot \\enot (C \\eiff \\enot C), ((G \\eor C) \\eor G) \\therefore ((G \\eif C) \\eand G) $ is valid.\n\\item Show that $ \\enot \\enot L,  (C \\eif \\enot L) \\eif C) \\therefore \\enot C$ is invalid. \n\\end{enumerate}\n\n\n%\\noindent\\problempart\n%Show that each of the following is provably inconsistent.\n%\\begin{earg}\n%\\item \\{$Sa\\eif Tm$, $Tm \\eif Sa$, $Tm \\eand \\enot Sa$\\}\n%\\end{earg}\n%convert last item to something in SL\n\n% % Below is the closing tag for typesetting only part of the chapter. Everything up to here to the close tag will be skipped unless the {whole_slproof_chap} label at the start of this \n%chapter file is % uncommented.\n\n}{}\n\n\n\\section*{Rules of Inference Summary}\n\\label{sec:proof_rules}\n%%%%%%%%%%%%%%%%%\n%%%%%%%%%%rcr start proofrules\n%%%%%%%%%%%%%%%%%%\n\nReiteration (R):\n\\begin{proof}\n        \\have[m]{a}{\\script{A}}\n        \\have[n]{b}{\\script{A}} \\by{R}{a}\n\\end{proof}\n\nNegation Introduction ({\\enot}I):\n\n\\begin{multicols}{2}\n\n\\begin{proof}\n\\open\n        \\hypo[m]{na}{\\script{A}}\\by{for reductio}{}\n        \\have[n]{b}{\\script{B}}\n        \\have{nb}{\\enot\\script{B}}\n\\close\n\\have{a}[\\ ]{\\enot\\script{A}}\\ni{na-nb}\n\\end{proof}\n\n\\begin{proof}\n\\open\n        \\hypo[m]{na}{\\script{A}}\\by{for reductio}{}\n        \\have[n]{b}{\\enot\\script{B}}\n        \\have{nb}{\\script{B}}\n\\close\n\\have{a}[\\ ]{\\enot\\script{A}}\\ni{na-nb}\n\\end{proof}\n\n\\end{multicols}\n\n\n\nNegation Elimination ({\\enot}E):\n\n\\begin{multicols}{2}\n\\begin{proof}\n\\open\n        \\hypo[m]{na}{\\enot\\script{A}}\\by{for reductio}{}\n        \\have[n]{b}{\\script{B}}\n        \\have{nb}{\\enot\\script{B}}\n\\close\n\\have{a}[\\ ]{\\script{A}}\\ne{na-nb}\n\\end{proof}\n\n\n\\begin{proof}\n\\open\n        \\hypo[m]{na}{\\enot\\script{A}}\\by{for reductio}{}\n        \\have[n]{b}{\\enot\\script{B}}\n        \\have{nb}{\\script{B}}\n\\close\n\\have{a}[\\ ]{\\script{A}}\\ne{na-nb}\n\n\\end{proof}\n\\end{multicols}\n\n\n\nConjunction Introduction ({\\eand}I):\n \n\\begin{multicols}{2}\n\n\\begin{proof}\n        \\have[m]{a}{\\script{A}}\n        \\have[n]{b}{\\script{B}}\n        \\have[\\ ]{c}{\\script{A}\\eand\\script{B}} \\ai{a, b}\n\\end{proof}\n\n\\begin{proof}\n        \\have[m]{a}{\\script{A}}\n        \\have[n]{b}{\\script{B}}\n        \\have[\\ ]{c}{\\script{B}\\eand\\script{A}} \\ai{a, b}\n\\end{proof}\n\n\\end{multicols}\n\n\nConjunction Elimination ({\\eand}E):\n\n\\begin{multicols}{2}\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eand\\script{B}}\n        \\have[\\ ]{a}{\\script{A}} \\ae{ab}\n\\end{proof}\n\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eand\\script{B}}\n        \\have[\\ ]{a}{\\script{B}} \\ae{ab}\n\\end{proof}\n\\end{multicols}\n\n\n\n\nDisjunction Introduction ({\\eor}I):\n\n\\begin{multicols}{2}\n \n\\begin{proof}\n        \\have[m]{a}{\\script{A}}\n        \\have[\\ ]{ab}{\\script{A}\\eor\\script{B}}\\oi{a}\n\\end{proof}\n\n\\begin{proof}\n        \\have[m]{a}{\\script{A}}\n        \\have[\\ ]{ab}{\\script{B}\\eor\\script{A}}\\oi{a}\n\\end{proof}\n\n\\end{multicols}\n  \n\nDisjunction Elimination ({\\eor}E):\n\n\\begin{multicols}{2}\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eor\\script{B}}\n        \\have[n]{nb}{\\enot\\script{B}}\n        \\have[\\ ]{a}{\\script{A}} \\oe{ab,nb}\n\\end{proof}\n\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eor\\script{B}}\n        \\have[n]{na}{\\enot\\script{A}}\n        \\have[\\ ]{b}{\\script{B}} \\oe{ab,nb}\n\\end{proof}\n\\end{multicols}\n\n\nConditional Introduction({\\eif}I):\n\n\\begin{proof}\n        \\open\n                \\hypo[m]{a}{\\script{A}} \\by{want \\script{B}}{}\n                \\have[n]{b}{\\script{B}}\n        \\close\n        \\have[\\ ]{ab}{\\script{A}\\eif\\script{B}}\\ci{a-b}\n\\end{proof}\n\n\n\nConditional Elimination ({\\eif}E):\n\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eif\\script{B}}\n        \\have[n]{a}{\\script{A}}\n        \\have[\\ ]{b}{\\script{B}} \\ce{ab,a}\n\\end{proof}\n\n\nBiconditional Introduction({\\eiff}I):\n\n\\begin{proof}\n        \\open\n                \\hypo[m]{a1}{\\script{A}} \\by{want \\script{B}}{}\n                \\have[n]{b1}{\\script{B}}\n        \\close\n        \\open\n                \\hypo[p]{b2}{\\script{B}} \\by{want \\script{A}}{}\n                \\have[q]{a2}{\\script{A}}\n        \\close\n        \\have[\\ ]{ab}{\\script{A}\\eiff\\script{B}}\\bi{a1-b1,b2-a2}\n\\end{proof}\n\n\n\nBiconditional Elimination ({\\eiff}E):\n\n\\begin{multicols}{2}\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n        \\have[n]{a}{\\script{A}}\n        \\have[\\ ]{b}{\\script{B}} \\be{ab,a}\n\\end{proof}\n\n\\begin{proof}\n        \\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n        \\have[n]{a}{\\script{B}}\n        \\have[\\ ]{b}{\\script{A}} \\be{ab,a}\n\\end{proof}\n\\end{multicols}\n\n\n\n%%%%%%%%end proofrules\n\n\\section*{Key Terms}\n\\begin{multicols}{2}\n\\begin{sortedlist}\n\\sortitem{sentence form}{}\n\n\\sortitem{substitution instance}{}\n\n\\sortitem{argument form}{}\n\n\\sortitem{substitution instance of an argument form}{}\n\n\\sortitem{proof}{}\n\n\\iflabelexists{def:syntactically_logically_equivalent_in_sl}{\\sortitem{Syntactically logically equivalent in SL}{}}{}\n\n\\iflabelexists{def:syntactic_tautology_in_sl}{\\sortitem{Syntactic tautology in SL}{}}{}\n\n\\iflabelexists{syntactic contradiction in SL}{\\sortitem{Syntactic contradiction in SL}{}}{}\n\n\\iflabelexists{def:syntactically_contingent_in_sl}{\\sortitem{Syntactically contingent in SL}{}}{}\n\n\\iflabelexists{def:syntactically_inconsistent_ in_sl}{\\sortitem{Syntactically inconsistent in SL}{}}{}\n\n\\iflabelexists{def:syntactically consistent in SL}{\\sortitem{Syntactically consistent in SL}{}}{}\n\n\\iflabelexists{def:syntactically_valid_in_SL}{\\sortitem{Syntactically valid in SL}{}}{}\n\n\\iflabelexists{def:soundness}{\\sortitem{Soundness}{}}{}\n\n\\iflabelexists{def:completeness}{\\sortitem{Completeness}{}}{} \t\n\n\\end{sortedlist}\n\\end{multicols}\n\n\n\n\n\n\n\n", "meta": {"hexsha": "20bc467c79eac8bae677db592a3f94828bf51fd1", "size": 166213, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/ch08-proofsinsl.tex", "max_stars_repo_name": "robinson-philo/openintroduction", "max_stars_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/ch08-proofsinsl.tex", "max_issues_repo_name": "robinson-philo/openintroduction", "max_issues_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/ch08-proofsinsl.tex", "max_forks_repo_name": "robinson-philo/openintroduction", "max_forks_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8019636015, "max_line_length": 1492, "alphanum_fraction": 0.6572229609, "num_tokens": 61163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.4321459584469257}}
{"text": "%!TEX program = lualatex\n\n% Copyright (c) 2021 Thomas Jenni\n\n% Permission is hereby granted, free of charge, to any person obtaining a copy\n% of this software and associated documentation files (the \"Software\"), to deal\n% in the Software without restriction, including without limitation the rights\n% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n% copies of the Software, and to permit persons to whom the Software is\n% furnished to do so, subject to the following conditions:\n\n% The above copyright notice and this permission notice shall be included in all\n% copies or substantial portions of the Software.\n\n% THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n% SOFTWARE.\n\n\\documentclass{article}\n\n\\usepackage{luacode}\n\\usepackage{siunitx}\n\\usepackage{amsmath}\n\n% siunitx config\n\\sisetup{\n\toutput-decimal-marker = {.}, \n\tper-mode = symbol,\n\tseparate-uncertainty = false,\n\tadd-decimal-zero = true,\n\texponent-product = \\cdot,\n\tround-mode=off\n}\n\n% empty unit\n\\DeclareSIUnit\\unitless{}\n\n\\DeclareSIUnit\\inch{in}\n\n% init lua-physical\n\\begin{luacode}\nphysical = require(\"physical\")\nN = physical.Number\n\\end{luacode}\n\n\n\\newcommand{\\q}[1]{%\n\t\\directlua{tex.print(physical.Quantity.tosiunitx(#1,\"add-decimal-zero=true,scientific-notation=fixed,exponent-to-prefix=false\"))}%\n}\n\n\\newcommand{\\qs}[1]{%\n\t\\directlua{tex.print(physical.Quantity.tosiunitx(#1,\"scientific-notation=true,exponent-to-prefix=false,round-integer-to-decimal=true\"))}%\n}\n\n\\newcommand{\\qt}[1]{%\n\t\\directlua{tex.print(physical.Quantity.tosiunitx(#1,\"scientific-notation=engineering,exponent-to-prefix=true,round-integer-to-decimal=true\"))}%\n}\n\n\\newcommand{\\qn}[1]{%\n\t\\directlua{tex.print(physical.Quantity.tosiunitx(#1,\"add-decimal-zero=true,scientific-notation=fixed,exponent-to-prefix=false\",1))}%\n}\n\n\\newcommand{\\qu}[1]{%\n\t\\directlua{tex.print(physical.Quantity.tosiunitx(#1,nil,2))}%\n}\n\n\n\n\n\n\\begin{document}\n\n\\section*{Example for the {\\tt lua-physical} package}.\n\nCompile this Lua\\LaTeX file with the command `{\\tt lualatex lua-physical\\_example.tex}'.\n\n\n\n\\begin{enumerate}\n\n\\begin{luacode}\na = 12 * _cm\nb = 150 * _mm\nc = 1.5 * _m\n\nV = ( a * b * c ):to(_dm^3)\n\\end{luacode}\n\n\\item Find the volume of a cuboid with lengths $\\q{a}$,\n$\\q{b}$ and $\\q{c}$.\n%\n\\begin{equation*}\n  V= a \\cdot b \\cdot c\n  = \\q{a} \\cdot \\q{b} \\cdot \\q{c}\n  = \\underline{\\q{V}}\n\\end{equation*}\n\n\n\n\n\n\\begin{luacode}\nl = 12 * _in\n\\end{luacode}\n\n\\item Convert $\\q{l}$ to the unit $\\qu{_cm}$.\n%\n\\begin{equation*}\n  l = \\q{l} \\cdot \\frac{\\q{_in:to(_cm)}}{\\qu{_in}} = \\q{l:to(_cm)}\n\\end{equation*}\n\n\n\n\n\n\\begin{luacode}\nN.omitUncertainty = true\n\nd = N(1,0.0001) * ( _au ):to(_km)\nv = N(1,0.0001) * ( _c ):to(_km/_s)\nt = ( d/v ):to(_min)\n\\end{luacode}\n\n\\item Calculate the time, a lightray travels from the surface of the sun to the earth.\nThe mean distance from the sun to the eart is $\\qs{d}$. The speed of light is $\\q{v}$.\n%\n\\begin{equation*}\n  t = \\frac{d}{v} = \\frac{\\qs{d}}{\\q{v}} = \\underline{\\q{t}}\n\\end{equation*}\n\n\\end{enumerate}\n\n\n\\end{document}\n", "meta": {"hexsha": "70c729193d574713d15c7d42ca1cab9f521b7950", "size": 3427, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lua-physical_example.tex", "max_stars_repo_name": "tjenni/lua-physical", "max_stars_repo_head_hexsha": "9fcf1d17c6929650075a6214fa1968ddf3163855", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-04-20T06:20:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-24T09:33:33.000Z", "max_issues_repo_path": "lua-physical_example.tex", "max_issues_repo_name": "tjenni/lua-physical", "max_issues_repo_head_hexsha": "9fcf1d17c6929650075a6214fa1968ddf3163855", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-09-07T07:50:17.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-16T20:10:05.000Z", "max_forks_repo_path": "lua-physical_example.tex", "max_forks_repo_name": "tjenni/lua-physical", "max_forks_repo_head_hexsha": "9fcf1d17c6929650075a6214fa1968ddf3163855", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-09-04T18:08:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-13T13:00:25.000Z", "avg_line_length": 24.654676259, "max_line_length": 144, "alphanum_fraction": 0.7081995915, "num_tokens": 1057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.432117706438796}}
{"text": "%% SECTION HEADER /////////////////////////////////////////////////////////////////////////////////////\n\\section{Model-Assisted Damage Identification Function}\n\\label{sec:madif}\n\n%% SECTION CONTENT ////////////////////////////////////////////////////////////////////////////////////\nhe severity of damage was estimated based on the function determined with the numerical simulation.\nA simple flowchart given in Figure~\\ref{fig:Flowchart} represents a process for the sample assessment.\nWhen the structure model is developed, several computer simulations for various damage sizes must be conducted to determine the \\ac{madif}.\n%\\begin{figure}[H]\n%\t%\t\\begin{center}\n%\t\\includegraphics[width=1\\linewidth]{Chapter_7/flowchart}\n%\t%\t\\end{center}\n%\t\\caption{A flowchart representing the process for damage size estimation.}\n%\t\\label{fig:Flowchart}\n%\\end{figure}\nThe \\ac{madif} indicates the damage size according to measured damage index \\(I\\) normalized by the value obtained for the pristine sample \\(I^{ref}\\).\nIn the paper, two types of damage index \\(I\\) are considered: the energy \\(I_{eng}\\) and the maximum value of the half-width of the first package arrived in the sensor \\(I_{amp}\\), and these are defined as:\n\\begin{eqnarray}\n\tI_{eng}(\\Phi_D)=\\sum_{t=0}^{T} \\left (\\Psi_g(t,\\Phi_D)\\right )^2,\\quad I_{eng}^{ref}=\\sum_{t=0}^{T} \\left (\\Psi_g(t,0)\\right )^2,\\\\\n\tI_{amp}(\\Phi_D)=\\mathrm{max}\\left ( \\Psi_g(t,\\Phi_D)\\right ),\\quad I_{amp}^{ref}=\\mathrm{max}\\left ( \\Psi_g(t,0)\\right ),\n\t\\label{eq:I_amp}\n\\end{eqnarray}\nwhere \\textit{T} is a period of the signal.\n\\(\\Psi_g(t,\\Phi_D)\\) is for the damaged case scenario, whereas \\(\\Psi_g(t,0)\\) is for the pristine sample and it is realized in the same way by windowing the full-length signals of the sensor \\(\\Psi(t)\\) with a flattened Gaussian window \\emph{g(t)} as follows:\n\\begin{eqnarray}\n\t\\Psi_g(t)=\\Psi(t)g(t)= \\Psi(t)\\mathrm{exp}\\left(-\\left(\\frac{t-t_0}{0.6005612w_g}\\right) ^{12}\\right),\n\t\\label{eq:psi_g}\n\\end{eqnarray}\nwhere \\(t_0\\) is the center and \\(w_g=0.5N_c/f_c\\) is a half-width of the window.\nWindowing the signals ensures obtaining the signals without any reflections from the boundaries.\nThe determination of \\(\\Psi_g\\) is pictured in Figure~\\ref{fig:window_madif}a.\n\n\\begin{figure}[H]\n\t%\t\\begin{center}\n\t\\includegraphics[width=1\\linewidth]{Chapter_7/window_madif_03}\n\t%\t\\end{center}\n\t\\caption{(\\textbf{a}) The %MDPI: The hyphen in the picture should be changed to minus sign, e.g., ``-0.5'' to ``$-$0.5'', please change. Please check all like this in all figures. \n\t\tsensor signal \\(\\Psi(t)\\) windowed by a flattened Gaussian window \\(g(t)\\) and (\\textbf{b}) the damage size estimation from the \\ac{madif}.}\n\t\\label{fig:window_madif}\n\\end{figure}\nIn the time domain, an equivalent numerical signal to the signal registered by the \\ac{pzt} acquisition instrument is calculated as an average value of the electrical potential of the electrode surface\n\\begin{eqnarray}\n\t\\Psi^{n}(t) = \\frac{\\int_{\\Gamma_e}\\phi\\mathrm{d}\\Gamma}{\\Gamma_e},\n\t\\label{eq:psi}\n\\end{eqnarray}\nwhere \\(n=1\\) and \\(n=2\\) correspond to the homogenized and presented model, respectively.\n\nThe \\ac{madif} is achieved by approximating the inverse of the computed damage index that best matches the experimental one.\nFinally, the damage size \\(\\Phi_D\\) is obtained from the \\ac{madif} curve for measuring the normalized value of \\(I/I^{ref}\\) as it is presented in Figure~\\ref{fig:window_madif}b.", "meta": {"hexsha": "f89f7e16d0ea83041c3d60583c1f462c20ecb89a", "size": 3433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/proposal/Dissertation/Chapters/Chapter8/sec:di.tex", "max_stars_repo_name": "pfiborek/model-hc", "max_stars_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/proposal/Dissertation/Chapters/Chapter8/sec:di.tex", "max_issues_repo_name": "pfiborek/model-hc", "max_issues_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/proposal/Dissertation/Chapters/Chapter8/sec:di.tex", "max_forks_repo_name": "pfiborek/model-hc", "max_forks_repo_head_hexsha": "9e49fe23117fd320be14214e5ff6bafd2b1fc1a3", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.0612244898, "max_line_length": 260, "alphanum_fraction": 0.6970579668, "num_tokens": 975, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.432117706438796}}
{"text": "\\newcommand{\\HTSwiki}{\\cite{HighTempSuperconductor-wiki}}\n\\newcommand{\\RVBwiki}{\\cite{ResonatingValenceBondTheory-wiki}}\n\\newcommand{\\SCor}{\\cite{StronglyCorrelatedModels-paper}}\n\n\\section{Introduction}\n\n\\subsection{HighTempSuperconductors}\n\n\\subsubsection{Transition Temperatures}\nWhile normal {\\quo{superconductors usually have transition temperatures below $30 k$, high temperatures have been observed with transition temperatures as high as $138 k$}}\\HTSwiki\n\n\\subsubsection{Materials}\n\n\\paragraph{Certain cuprates} Compounds of copper and oxygen \\HTSwiki \\n\n{\\quo{Strong correlations}} have something to do {\\quo{with these compounds}} \\SCor\n\n\\paragraph{Hydrogen sulfide $H_2 S$} {\\quo{under extremely high pressure}} is the {\\quo{highest temperature superconductor known to date}}, with $T_c = 203 k$ \\HTSwiki\n\n\\paragraph{Ceramics}\n\t\\begin{itemize}\n\t\t\\item {\\quo{barium doped lanthanum and copper oxide}} with $T_c \\approx 35 k$ \\HTSwiki\n\t\t\\item {\\err{list some others?}}\n\t\\end{itemize}\n\n{\\qs{I think I’ll be investigating cuprates? But I initially thought it would be ceramics?}}{\\err{Find out which ones!}}\n\n\\subsubsection{Theories}\n\n\\paragraph{Resonating Valence Bond Theory} \\RVBwiki\n\n\\section{Models}\nThe {\\quo{two simplest models for strongly correlated electrons}} are \\SCor\n\t\\begin{itemize}\n\t\t\\item {\\quo{The Hubbard}} model \\SCor\n\t\t\\item {\\quo{The $t-J$}} model \\SCor\n\t\\end{itemize}\n\n{\\quo{P.W Anderson proposed that a resonating valence bond wave-function,}} consisting {\\quo{of a superposition of valence bond states, contains the ingredients to account for a consistent theory of}} these models \\SCor\n\n{\\quo{Variational Monte Carlo}} programs have been successful in {\\quo{describing some of the peculiar properties of these cuprates}}\n\n{\\na{Cedric’s Paper proposes an extension to these to include {\\quo{strongly correlated }} … maybe that’s what he wants me to do?}}\n\n\\section{Magnetism}\n\\subsection{Antiferromagnetism}\n\n\\section{DMFT}\n\n\\subsection{Aim}\n{\\quo{There are many interesting unsolved problems, such as high critical temperatures}} \\qi\n\n\\subsection{Perks}\n{\\quo{\n\tThe simple Hubbard {\\qs{(“truncated” PPP)}} model on a 2D lattice\n\t\t\\eq{-t \\sum_{ij, \\sigma}{c^\\dagger_{i\\sigma}c_{j\\sigma}} - \\mu \\sum_{i,\\sigma}{c^\\dagger_{i\\sigma}c_{i\\sigma}} + U \\sum_i{n_{i\\uparrow} n_{i\\downarrow}} }\n\tgives rise to many electronic phases, e.g.\n\t\t\\begin{itemize}\n\t\t\t\\item anti ferromagnetism\n\t\t\t\\item superconductors\n\t\t\\end{itemize}\n}} \\qi", "meta": {"hexsha": "4c7e4e3c8303a6ff1f2e4ae88e7653bbbb3e0e27", "size": 2456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Untitled.tex", "max_stars_repo_name": "HelinaBerhane/Project", "max_stars_repo_head_hexsha": "2b5aacabba219cd39d4d4eaba21a294507c68e9f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/Untitled.tex", "max_issues_repo_name": "HelinaBerhane/Project", "max_issues_repo_head_hexsha": "2b5aacabba219cd39d4d4eaba21a294507c68e9f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Untitled.tex", "max_forks_repo_name": "HelinaBerhane/Project", "max_forks_repo_head_hexsha": "2b5aacabba219cd39d4d4eaba21a294507c68e9f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.262295082, "max_line_length": 219, "alphanum_fraction": 0.7536644951, "num_tokens": 714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043814, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.43211769652491305}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{graphicx,wrapfig,lipsum}\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#4}\n\\newcommand{\\hmwkDueDate}{Due on 13th November, 2018}\n\\newcommand{\\hmwkClass}{Fluid Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n\\textbf{Acknowledgements} - I thank Junaid Majeed for discussions.\n\n\n\n\n\n\\begin{homeworkProblem}[1]\n\tIn ideal $2$D flow, $ \\div{\\va{u}} = 0 $. This means,\n\t\\begin{equation*}\n\t\\pdv{u}{x} + \\pdv{v}{y} = 0 \\implies u = \\pdv{\\psi}{y} \\qq{and} v = - \\pdv{\\psi}{x}\n\t\\end{equation*}\n\tHence, $ \\grad{\\psi} = \\pdv{\\psi}{x} \\vu{x} + \\pdv{\\psi}{y} \\vu{y} = -v \\vu{x} +  u \\vu{y} $. By definition $ \\va{u} = \\grad{\\phi} = u \\vu{x} + v \\vu{y} $. Now we can do the calculations required in the problem,\n\t\n\t\\begin{itemize}\n\t\t\\item $ \\grad{\\psi} \\vdot \\grad{\\phi} = (-v \\vu{x} +  u \\vu{y})  \\vdot  ( u \\vu{x} + v \\vu{y} ) = -vu + uv = 0$.\n\t\t\\item $ - \\grad{\\psi} \\cross \\grad{\\phi} = - (-v \\vu{x} +  u \\vu{y}) \\cross  ( u \\vu{x} + v \\vu{y} ) =  - (-v^2 - u^2 )\\vu{z} = \\abs{\\va{u}}^2 \\vu{z} $\n\t\t\\item $\\abs{\\grad{\\psi}}^2 = u^2 + v^2 \\qq{and}  \\abs{\\grad{\\phi}}^2 = u^2 + v^2 \\implies  \\abs{\\grad{\\psi}}^2 = \\abs{\\grad{\\phi}}^2$ \n\t\t\\item $ -\\vu{z} \\cross \\grad{\\psi} = -\\vu{z} \\cross (-v \\vu{x} +  u \\vu{y} ) = u \\vu{x} + v \\vu{y}  = \\grad{\\phi} $\n\t\\end{itemize}\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[2]\n\t\\begin{itemize}\n\t\t\\item For point source, $ \\va{u} = \\dfrac{q_s}{2 \\pi r} \\vu{r} $, where $ q_s $ is the source strength. In spherical polar coordinates, $  \\va{u} = \\pdv{\\phi}{r} \\vu{r} + \\frac{1}{r} \\pdv{\\phi}{\\theta} \\vu{\\theta} $. This means\n\t\t\\begin{equation*}\n\t\t\\phi = \\int \\pdv{\\phi}{r} dr + \\int \\dfrac{1}{r} \\pdv{\\phi}{\\theta} d\\theta  = \\dfrac{q_s}{2\\pi} \\ln r + constant\n\t\t\\end{equation*}\n\t\tFor lines of constant $ \\phi $,\n\t\t\\begin{align*}\n\t\t\\dfrac{q_s}{2\\pi} \\ln r &= C\\\\\n\t\t\\implies \\dfrac{q_s}{2\\pi r} \\dv{r}{x} &= 0\\\\\n\t\t\\implies \\dfrac{q_s}{2\\pi r^2} \\qty(2x + 2y \\dv{y}{x}) &= 0 \\implies  \\dv{y}{x} = - \\dfrac{x}{y} = m\n\t\t\\end{align*}\n\t\tAs velocity is radial, the streamlines are also radial straight lines passing through the origin. The slope of such straight lines is $ \\dfrac{y}{x} = - \\dfrac{1}{m} $. Hence the streamlines and lines of constant $ \\psi $ are perpendicular.\n\t\t\n\t\t\\item For point vortex, $ \\va{u} = \\dfrac{\\Gamma}{2 \\pi r} \\vu{\\theta} = \\dfrac{ -\\Gamma y}{2 \\pi (x^2 + y^2)} \\vu{x} + \\dfrac{ \\Gamma x}{2 \\pi (x^2 + y^2)} \\vu{y} $. This means,\n\t\t\\begin{equation*}\n\t\t\\phi =  \\dfrac{\\Gamma}{2 \\pi} \\tan^{-1} \\dfrac{y}{x} \\qq{and} \\psi = - \\dfrac{\\Gamma}{2 \\pi} \\ln r\n\t\t\\end{equation*}\n\t\tFor lines of constant $ \\phi $,\n\t\t\\begin{align*}\n\t\t\\dfrac{\\Gamma}{2 \\pi} \\tan^{-1} \\dfrac{y}{x} &= C_1\\\\\n\t\t\\implies \\dfrac{y}{x} &= constant = m_1\\\\\n\t\t\\implies  \\dv{y}{x} &= m_1\n\t\t\\end{align*}\n\t\tFor lines of constant $ \\psi $,\n\t\t\\begin{align*}\n\t\t\\dfrac{\\Gamma}{2 \\pi} \\ln r &= C_2\\\\\n\t\t\\implies r &= constant\\\\\n\t\t\\implies  x^2 + y^2 &= constant\\\\\n\t\t\\implies \\dv{y}{x} &= - \\dfrac{x}{y} = - \\dfrac{1}{m_1}\n\t\t\\end{align*}\n\t\tHence proved.\n\t\\end{itemize}\n\t\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[3]\n\tGiven $ A =  \\mqty[-1 & p \\\\ 0 & -2] $. The eigenvalues of $ A $ are $ \\lambda_1 = -1 $ and $ \\lambda_2 = -2 $ with corresponding (normalized) eigenvectors are $v_1 = \\mqty[1 & 0]^T$ and $ v_2 = \\mqty[\\dfrac{-p}{\\sqrt{1 + p^2}} & \\dfrac{1}{\\sqrt{1 + p^2}}]^T $. So, the resultant vector is,\n\t\\begin{align*}\n\tv &= v_1 e^{\\lambda_1 t} + v_2 e^{\\lambda_2 t}\\\\\n\t&= \\mqty[1 \\\\ 0] e^{-t} + \\dfrac{1}{\\sqrt{1 +p^2}}\\mqty[{-p} \\\\ {1}] e^{-2t}\\\\\n\tv &= \\mqty[e^{-t} -\\frac{p}{\\sqrt{1 + p^2}} e^{-2t} \\\\ \\frac{1}{\\sqrt{1 + p^2}} e^{-2t}]\\\\\n\t\\abs{v}^2 &= \\qty(e^{-t} -\\frac{p}{\\sqrt{1 + p^2}} e^{-2t} )^2 + \\qty(\\frac{1}{\\sqrt{1 + p^2}} e^{-2t})^2\\\\\n\t&= e^{-2t} + e^{-4t} - \\dfrac{2p}{\\sqrt{1 + p^2}} e^{-3t}\\\\\n\t\\dv{\\abs{v}^2}{t} &= -2 e^{-2t} -4 e^{-4t} + \\dfrac{6p}{\\sqrt{1 + p^2}} e^{-3t}\n \t\\end{align*}\n\tFor the resultant to grow, $ \\dv{\\abs{v}^2}{t} > 0 $.\n\t\\begin{align*}\n\t\\implies -2 e^{-2t} -4 e^{-4t} + \\dfrac{6p}{\\sqrt{1 + p^2}} e^{-3t} &> 0\\\\\n\t\\implies \\dfrac{p}{\\sqrt{1 + p^2}} &> \\dfrac{ e^{t} + 2 e^{-t}}{3}\n\t\\end{align*}\n\tThe function $ \\dfrac{ e^{t} + 2 e^{-t}}{3} $ has a minimum value of $ \\dfrac{2\\sqrt{2}}{3} $. Hence, for the resultant to grow for some finite time,\n\t\\begin{align*}\n\t\\dfrac{p}{\\sqrt{1 + p^2}} &> \\dfrac{2 \\sqrt{2}}{3}\\\\\n\t\\implies \\dfrac{p^2}{1 + p^2} &> \\dfrac{8}{9}\\\\\n\t\\implies p^2 &> 8 \\\\\n\t\\implies p &> 2 \\sqrt{2}\n\t\\end{align*}\n\tHence, the resultant will grow for some finite time if $ p > 2 \\sqrt{2} $.\n\t\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[4]\n\t\\begin{figure}[h!]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.09]{q2.jpg}\n\t\\end{figure}\n\tLet's first find the potential. As described in Problem 1, $ \\phi = \\dfrac{q_s}{2 \\pi} \\ln r $. So for this problem,\n\t\\begin{align*}\n\t\\phi &= -\\dfrac{q_s}{4 \\pi} \\ln [(x - \\epsilon/2)^2 + y^2] + \\dfrac{q_s}{4 \\pi} \\ln [(x + \\epsilon/2)^2 + y^2] \\\\\n\t&= \\dfrac{q_s}{4 \\pi} \\ln \\dfrac{(x + \\epsilon/2)^2 + y^2}{(x - \\epsilon/2)^2 + y^2}\\\\\n\t&= \\dfrac{q_s}{4 \\pi} \\ln \\dfrac{1 + \\epsilon x / r^2 }{1 - \\epsilon x /r^2 }\\\\\n\t&= \\dfrac{q_s}{4 \\pi} \\ln ({1 + 2\\epsilon x / r^2 })\\\\\n\t\\phi &= \\dfrac{q_s \\epsilon \\cos \\theta}{2 \\pi r}\n\t\\end{align*}\n\t\n\tHence, the velocity profile is,\n\t\\begin{equation*}\n\t\\va{u} = -\\dfrac{q_s \\epsilon \\cos \\theta}{2 \\pi r^2} \\vu{r} - \\dfrac{q_s \\epsilon \\sin \\theta}{2 \\pi r^2} \\vu{\\theta}\n\t\\end{equation*}\n\tFor the streamlines, we note that for a single point source at origin, \\begin{align*}\n\tu = \\dfrac{q_s x}{2 \\pi (x^2 + y^2)} &\\qq{and} v = \\dfrac{q_s y}{2 \\pi (x^2 + y^2)}\\\\\n\t\\therefore \\psi &= \\dfrac{q_s}{2 \\pi} \\tan^{-1} \\dfrac{y}{x}\n\t\\end{align*}\n\tHence, for this problem,\n\t\\begin{align*}\n\t\\psi &= -\\dfrac{q_s}{2 \\pi} \\tan^{-1} \\dfrac{y}{x - \\epsilon/2} + \\dfrac{q_s}{2 \\pi} \\tan^{-1} \\dfrac{y}{x + \\epsilon/2}\\\\\n\t&= \\dfrac{q_s}{2 \\pi} \\qty(\\tan^{-1} \\dfrac{y}{x + \\epsilon/2} - \\tan^{-1} \\dfrac{y}{x - \\epsilon/2} )\\\\\n\t&= \\dfrac{q_s}{2 \\pi} \\tan^{-1} \\dfrac{y(x - \\epsilon/2 - x - \\epsilon/2) }{x^2 + y^2}\\\\\n\t&= \\dfrac{q_s}{2 \\pi} \\tan^{-1} \\dfrac{-y\\epsilon}{r^2}\\\\\n\t\\psi &= - \\dfrac{q_s}{2 \\pi} \\dfrac{\\sin \\theta}{r}\n\t\\end{align*}\n\t\n\t\\begin{equation*}\n\t\\psi = - \\dfrac{q_s}{2 \\pi} \\dfrac{\\sin \\theta}{r} = constant \\implies \\dfrac{\\sin \\theta}{r } = \\dfrac{y}{x^2 + y^2} = \\dfrac{1}{2C} \\implies x^2 + (y - C)^2 = C^2\n\t\\end{equation*}\n\twhich is the equation of a circle with centre at $ (0,C) $ and radius $ C $.\n\\end{homeworkProblem}\n\n\\end{document}\n", "meta": {"hexsha": "92a1b10baa58d5fece7b1dd9416aafbc0f4f4d67", "size": 9721, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/fluids/assign_4/assign_4.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/fluids/assign_4/assign_4.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/fluids/assign_4/assign_4.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1887417219, "max_line_length": 291, "alphanum_fraction": 0.6127970373, "num_tokens": 4058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.4320673256650652}}
{"text": "\\section{Prefixed Tableaus}\n\n\\qquad For a fixed language $\\Li$, we can think on the logic \\textbf{L} as the set of all valid sentences relative to the class of all \\textbf{L}-structures. There is a natural interest to know if there is a constructive method to verify which sentence belong to the mentioned set. For this purpose proof methods have been developed and used. Here, among the variety of methods, we choose the method of \\textit{semantic tableaus}, more specifically, we are going to use the method of \\textit{prefixed modal tableaus} as introduced in \\cite{Fitting83}.\n\n\\qquad This choice is motivated by practical reasons: it is easier to find a proof using tableaus, if compared to axiomatic proof procedures; and the tableau method play a key role in the study of the Interpolation theorem for \\textbf{S5B} with propositional quantification.   \n\n\\qquad In this chapter, we are going to present a prefixed tableau system for \\textbf{S5} and \\textbf{S5B}, which, not surprisingly, are going to be called \\textbf{S5}-\\textit{tableau system} and \\textbf{S5B}-\\textit{tableau system}, respectively. Although the two systems are presented, we are going to prove the basic theorems (Soundness and Completness) only for the \\textbf{S5}-tableau system. The corresponding proofs for the other system are similar, so we believe that there would be no loss by omitting them.\n\n\\qquad Another detail worth noticing is that for tableaus is convenient to have $\\nao, \\e, \\ou, \\impli, \\Box, \\Diamond, \\todo, \\ex$ as primitive logical symbols. So, in this chapter only, we will assume that these symbols are primitive.\n\n\\qquad Let $\\Li$ be a language such that for any $n \\in \\omega$ there is an infinite list of $n$-ary relations. When working with tableaus is useful to add new variables called \\textit{parameters}. We use $\\Li^{+}$ to denote a language obtained from $\\Li$ which for each $n \\in \\omega - \\{0\\}$ there is an infinite list of parameters associated with $n$ (from now on we call an $n \\in \\omega - \\{0\\}$ a \\textit{prefix}). It is assumed that different prefixes never have the same parameters associated with them. We use $a^{1}, b^{1}, \\dots, a^{n}, b^{n}, \\dots$ as syntactical variables for parameters. $a^{n}$ indicates that $a$ is a parameter associated with the prefix $n$. It is easy to check that both $\\Li$ and $\\Li^{+}$ are countable languages.\n\n\\qquad The informal idea behind this is that each prefix $n$ names a possible world and the set of parameters associated with $n$ represent the domain of individuals in the world $n$. Of course, when working with \\textbf{S5B}-Tableaus $\\Li^{+}$ will have only parameters that are not associated with any prefix $n$ (they will be denoted by $a, b, \\dots$). \n\n\\qquad The formulas of $\\Li^{+}$  are defined in the same way as the formulas of $\\Li$, the only difference is that \\textit{there cannot be any bound occurrence of a parameter in a formula of} $\\Li^{+}$. Clearly, $\\FLi \\subset Fml(\\Li^{+})$.\n\n\\begin{defn}\nA \\textit{prefixed formula} is $n.$  $\\varphi$ where $n$ is a prefix and $\\varphi \\in  Fml(\\Li^{+})$.\n\\end{defn}\n\n\\begin{defn}\nA \\textit{prefixed tableau} $\\mathcal{T}$ is a tree whose nodes are prefixed formulas. We say that a branch $\\mathcal{B}$ of $\\mathcal{T}$ is \\textit{closed} if it contains $n.$ $\\varphi$ and $n.$ $\\nao \\varphi$ for some prefix $n$ and some formula $\\varphi \\in  Fml(\\Li^{+})$. Similarly, a prefixed tableau is closed if each branch of it is closed. A \\textit{tableau proof} of a sentence $\\varphi$ is a closed tableau with $1.$ $\\nao \\varphi$ at its root.\n\\end{defn}\n\n\\qquad To give a simple presentation it is useful to group the formulas of $\\Li^{+}$  in some categories. The next table defines what are called \\textit{alpha} and \\textit{beta} formulas and for each, two components. \n\n\\begin{center}\nAlpha and Beta Formulas\n\\end{center}\n\n$$\n\\begin{tabular}{c|c}\n$\\alpha$ & \\hspace{2mm} $\\alpha_1$ \\hspace{5mm} $\\alpha_2$\\\\\n\\hline\n$\\varphi \\e \\psi$ & \\hspace{2mm} $\\varphi$ \\hspace{5mm} $\\psi$  \\\\ \n$\\nao(\\varphi \\ou \\psi)$ & \\hspace{2mm} $\\nao\\varphi$ \\hspace{5mm} $\\nao\\psi$ \\\\ \n$\\nao(\\varphi \\impli \\psi)$ & \\hspace{2mm} $\\varphi$ \\hspace{5mm} $\\nao\\psi$ \\\\ \n\\end{tabular}\n\\quad\n\\begin{tabular}{c|c}\n$\\beta$ & \\hspace{2mm} $\\beta_1$ \\hspace{5mm} $\\beta_2$\\\\\n\\hline\n$\\varphi \\ou \\psi$ & \\hspace{2mm} $\\varphi$ \\hspace{5mm} $\\psi$  \\\\ \n$\\nao(\\varphi \\e \\psi)$ & \\hspace{2mm} $\\nao\\varphi$ \\hspace{5mm} $\\nao\\psi$ \\\\ \n$(\\varphi \\impli \\psi)$ & \\hspace{2mm} $\\nao\\varphi$ \\hspace{5mm} $\\psi$ \\\\ \n\\end{tabular}\n$$\n\n\n\\pagebreak\n\\qquad To deal with the modal operators $\\Box$ and $\\Diamond$, the next table defines the \\textit{nu} and \\textit{pi} formulas and their components.\n\n\\begin{center}\nNu and Pi Formulas\n\\end{center}\n\n$$\n\\begin{tabular}{c|c}\n$\\nu$ & \\hspace{2mm} $\\nu_0$ \\\\\n\\hline\n$\\Box \\varphi$ & \\hspace{2mm} $\\varphi$\\\\ \n$\\nao \\Diamond \\varphi$ & \\hspace{2mm} $\\nao \\varphi$\\\\ \n\\end{tabular}\n\\quad\n\\begin{tabular}{c|c}\n$\\pi$ & \\hspace{2mm} $\\pi_0$ \\\\\n\\hline\n$\\Diamond\\varphi$ & \\hspace{2mm} $\\varphi$\\\\ \n$\\nao \\Box \\varphi$ & \\hspace{2mm} $\\nao \\varphi$\\\\\n\\end{tabular}\n$$\n\n\\vspace{10mm}\n\n\\qquad The least two categories deals with the quantifiers $\\todo$ and $\\ex$. The following table defines the \\textit{gamma} and \\textit{delta} formula and their components.\n\n\\vspace{10mm}\n\n\n\n\\begin{center}\nGamma and Delta Formulas\n\\end{center}\n\n$$\n\\begin{tabular}{c|c}\n$\\gamma$ & \\hspace{2mm} $\\gamma(a)$ \\\\\n\\hline\n$\\todo x \\varphi$ & \\hspace{2mm} $\\varphi(a)$\\\\ \n$\\nao \\ex x \\varphi$ & \\hspace{1mm} $\\nao \\varphi(a)$\\\\ \n\\end{tabular}\n\\quad\n\\begin{tabular}{c|c}\n$\\delta$ & \\hspace{2mm} $\\delta(a)$ \\\\\n\\hline\n$\\ex x \\varphi$ & \\hspace{2mm} $\\varphi(a)$\\\\ \n$\\nao \\todo x \\varphi$ & \\hspace{1mm} $\\nao \\varphi(a)$\\\\\n\\end{tabular}\n$$\n\n\\vspace{10mm}\n\n\n\\qquad To construct a tableau for a sentence $\\varphi$ we start with $1.$ $\\nao \\varphi$ and we apply some \\textit{branch extension rules}. These rules are:\n\\pagebreak\n\\begin{center}\n\\textbf{Negation Rule}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$n.$ $\\nao \\nao \\psi$ \\\\\n\\hline\n$n.$ $\\psi$\n\\end{tabular}\n$$\n\n\\vspace{10mm}\n\n\n\\begin{center}\n\\textbf{Alpha and Beta Rules}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$n.$ $\\alpha$ \\\\\n\\hline\n$n.$ $\\alpha_1$\\\\\n$n.$ $\\alpha_2$\n\\end{tabular}\n\\quad\n\\begin{tabular}{c}\n$n.$ $\\beta$ \\\\\n\\hline\n$n.$ $\\beta_1$ $|$ $n.$ $\\beta_2$\n\\end{tabular}\n$$\n\n\\vspace{10mm}\n\n\n\\begin{center}\n\\textbf{Nu and Pi Rules}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$n.$ $\\nu$ \\\\\n\\hline\n$k.$ $\\nu_0$ \\\\\nfor $k$ used. \n\\end{tabular}\n\\quad\n\\begin{tabular}{c}\n$n.$ $\\pi$ \\\\\n\\hline\n$k.$ $\\pi_{0}$ \\\\\nfor $k$ new. \n\\end{tabular}\n$$\n\n\n\\pagebreak\n\\begin{center}\n\\textbf{Varying Domain Gamma and Delta Rules}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$n.$ $\\gamma$ \\\\\n\\hline\n$n.$ $\\gamma(a^{n})$ \\\\\nfor any $a^{n}$. \n\\end{tabular}\n\\quad\n\\begin{tabular}{c}\n$n.$ $\\delta$ \\\\\n\\hline\n$n.$ $\\delta(a^{n})$ \\\\\nfor $a^{n}$ new. \n\\end{tabular}\n$$\n\n\n\\vspace{10mm}\n\n\n\\begin{center}\n\\textbf{Constant Domain Gamma and Delta Rules}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$n.$ $\\gamma$ \\\\\n\\hline\n$n.$ $\\gamma(a)$ \\\\\nfor any $a$. \n\\end{tabular}\n\\quad\n\\begin{tabular}{c}\n$n.$ $\\delta$ \\\\\n\\hline\n$n.$ $\\delta(a)$ \\\\\nfor $a$ new. \n\\end{tabular}\n$$\n\n\n\n\\vspace{10mm}\n\\begin{center}\n\\textbf{Reflexivity Rule}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n\n\\hline\n$n.$ $a=a$ \\\\\n\\end{tabular}\n$$\n\\begin{center}\nfor any used $a$ and any used $n$. \n\\end{center}\n\n\n\n\\pagebreak\n\\begin{center}\n\\textbf{Substitutivity Rule}\n\\end{center}\n\n$$\n\\begin{tabular}{c}\n$k.$ $a=b$ \\\\\n$n.$ $\\varphi(a)$ \\\\\n\\hline\n$n.$ $\\varphi(b)$ \\\\\nfor any $k$. \n\\end{tabular}\n$$\n\n\n\\vspace{10mm}\n\n\n\\begin{defn}\nThe \\textbf{S5}-tableau system is a prefixed tableau system whose branch extension rules are all the rules listed above with the exception of the constant domain gamma rule and the constant domain delta rule. Analogously, the \\textbf{S5B}-tableau system is a prefixed tableau system whose branch extension rules are the same as the \\textbf{S5}-tableau system, but in the place of the varying domain gamma and delta rules, the \\textbf{S5B}-tableau system has the constant domain gamma and delta rules.\n\\end{defn}\n\n\\qquad We write $\\vdash_{\\textbf{L}}\\varphi$ to indicate that $\\varphi$ has a proof in the \\textbf{L}-tableau system. For example, the following is a proof of\n$\\vdash_{\\textbf{S5}} \\Box \\todo x \\Box \\ex y (x=y) \\impli (\\Box \\todo x Fx \\see  \\todo x \\Box Fx)$:\\\\\n\n\\vspace{10mm}\n\n\\Tree\n[ .{$1.$ $\\nao (\\Box \\todo x \\Box \\ex y$ $x=y$ $\\impli (\\Box \\todo x Fx \\see \\todo \\Box x Fx))$\\\\\n\t$1.$ $\\Box \\todo x \\Box \\ex y$ $x=y$\\\\\n\t$1.$ $\\nao (\\Box \\todo x Fx \\see \\todo x \\Box Fx)$\n}\n[.{$1.$ $\\Box \\todo x Fx$\\\\\n\t$1.$ $\\nao (\\todo x \\Box Fx)$\\\\\n\t$1.$ $\\nao (\\Box Fa^{1})$\\\\\n\t$2.$ $\\nao Fa^{1}$\\\\\n\t$1.$ $\\todo x \\Box \\ex y$ $x=y$\\\\\n\t$1.$ $\\Box \\ex y$ $a^{1}=y$\\\\\n\t$2.$ $\\ex y$ $a^{1}=y$\\\\\n\t$2.$ $a^{1}=a^{2}$\\\\\n\t$2.$ $\\nao Fa^{2}$\\\\\n\t$2.$ $\\todo x Fx$\\\\\n\t$2.$ $Fa^{2}$}\n]\n[.{$1.$ $\\todo x \\Box Fx$\\\\\n\t$1.$ $\\nao (\\Box \\todo x Fx)$\\\\\n\t$2.$ $\\nao (\\todo x Fx)$\\\\\n\t$2.$ $\\nao Fa^{2}$\\\\\n\t$2.$ $\\todo x \\Box \\ex y$ $x=y$\\\\\n\t$2.$ $\\Box \\ex y$ $a^{2}=y$\\\\\n\t$1.$ $\\ex y$ $a^{2}=y$\\\\\n\t$1.$ $a^{2}=a^{1}$\\\\\n\t$2.$ $\\nao Fa^{1}$\\\\\n\t$1.$ $\\Box Fa^{1}$\\\\\n\t$2.$ $Fa^{1}$}\n]\n]\n\n\\vspace{10mm}\n\n\n\n\n\\section{Soundness}\n\n\\begin{defn}\nLet $S$ be a set of prefixed formulas. We say that $S$ is S5-\\textit{satisfiable} if there is an S5-structure $\\A = \\strucAS$, a valuation $s$ and a function $f$ assigning to each prefix $n$ that occur in $S$ some member $f(n)$ of $\\W$ such that:\n\n\\begin{enumerate}[(i)]\n\\item if the parameter $a^{n}$ occur in $S$, then $s(a^{n}) \\in \\barD_{f(n)}$.\n\\item if $n.$ $\\varphi \\in S$, then $\\A, f(n) \\vSs \\varphi$.\n\\end{enumerate}\n\n\\end{defn}\n\n\n\\qquad A tableau branch is S5-satisfiable is the set of prefixed formulas on it is S5-satisfiable. And an S5-tableau is satisfiable if some branch of it is S5-satisfiable.\n\n\n\n\\begin{lema}\nSuppose $\\mathcal{T}$ is an S5-tableau that is S5-satisfiable. If any S5-tableau rule is applied to $\\mathcal{T}$, the resulting tableau is still S5-satisfiable. \n\\end{lema}\n\n\\begin{proof}\nSuppose that the branch $\\mathcal{B}$ of $\\mathcal{T}$ is S5-satisfiable, say $\\mathcal{B}$ is satisfiable in the S5-structure $\\A = \\strucAS$ with respect to the valuation $s$, using the function $f$. And say a tableau rule is applied to $\\mathcal{T}$. If it is applied on a branch other than $\\mathcal{B}$, the resulting tableau is trivially S5-satisfiable. So now we assume that the tableau   rule has been applied on $\\mathcal{B}$. \n\n\\qquad Since the argument for the negation rule, alpha rule, beta rule, reflexivity rule and substitutivity rule are straightforward, we omit them.  \n\n\\qquad If the applied rule was the \\textit{nu rule}, then for some prefixed formula $n.$ $\\nu$ occurring in $\\mathcal{B}$ we add $k.$ $\\nu_{0}$ for some k alredy occurring in $\\mathcal{B}$, i.e. we expand $\\mathcal{B}$ in the new branch $\\mathcal{B}$, $k.$ $\\nu_{0}$. By hypothesis, $\\A, f(n) \\vSs \\nu$. It is easy to see that for every $w\\p \\in \\W$, $\\A, w\\p \\vSs \\nu_{0}$. So for every prefix $m$ occurring in $\\mathcal{B}$, $\\A, f(m) \\vSs \\nu_{0}$; in particular, $\\A, f(k) \\vSs \\nu_{0}$. Therefore, $\\mathcal{B}$, $k.$ $\\nu_{0}$ is S5-satisfiable. \n\n\n\\qquad If the applied rule was the \\textit{pi rule}, then for some prefixed formula $n.$ $\\pi$ occurring in $\\mathcal{B}$ we expand $\\mathcal{B}$ in the new branch $\\mathcal{B}$, $k.$ $\\nu_{0}$ for a $k$ not occuring in $\\mathcal{B}$. By hypothesis, $\\A, f(n) \\vSs \\pi$; so there is a world $w\\p \\in \\W$ such that $\\A, w\\p \\vSs \\pi_{0}$. Let $f\\p = f \\cup \\{\\bl k, w\\p \\br\\}$. Since $k$ did not occur in $\\mathcal{B}$, $f\\p$ is a function from the set of prefixes of the branch $\\mathcal{B}$, $k.$ $\\nu_{0}$ to $\\W$. Clearly, the branch $\\mathcal{B}$, $k.$ $\\nu_{0}$ is satisfiable in $\\A$ with respect to the valuation $s$ using the function $f\\p$.\n\n\\qquad Now, suppose the applied rule was the \\textit{varying domain gamma rule}, then for some formula $n.$ $\\gamma$ occuring in  $\\mathcal{B}$, we expand $\\mathcal{B}$ in the new branch $\\mathcal{B}$, $n.$ $\\gamma(a^{n})$ where $a^{n}$ is any parameter associated with $n$.\n\n\\qquad If $a^{n}$ occurs in $\\mathcal{B}$, then by condition $(i)$ of Definition 16, $s(a^{n}) \\in \\barD_{f(n)}$. Let $s^{*}$ be an $x$-variant of $s$ such that for every variable $y$ of $\\Li^{+}$\n  \n$$\ns^{*}(y) = \\left\\{\n\\begin{array}{rcl}\ns(y) & \\mbox{if} & y \\neq x\\\\\ns(a^{n}) & \\mbox{if} & y = x\\\\\n\\end{array}\n\\right.\n$$\n\n\\qquad So, $s^{*}$ is an $x$-variant of $s$ at $f(n)$. By hypothesis, $\\A, f(n)\\vSs \\gamma$. Thus, for every $x$-variant $s\\p$ of $s$ at $f(n)$, $\\A, f(n)\\vSp \\gamma(x)$. In particular, $\\A, f(n)\\models_{s^{*}} \\gamma(x)$. By Proposition 3, $\\A, f(n)\\vSs \\gamma(a^{n})$. Therefore, $\\mathcal{B}$,  $n.$ $\\gamma(a^{n})$ is satisfiable in $\\A$ with respect to the valuation $s$ using the function $f$.\n\n\\qquad On the other hand if $a^{n}$ did not occur in $\\mathcal{B}$, then, since $\\barD_{f(n)} \\neq \\vazio$, there is a $c \\in \\barD_{f(n)}$. Let $s^{*}$ be a valuation such that for every variable $y$ of $\\Li^{+}$\n  \n$$\ns^{*}(y) = \\left\\{\n\\begin{array}{rcl}\ns(y) & \\mbox{if} & y \\neq a^{n}\\\\\nc & \\mbox{if} & y = a^{n}\\\\\n\\end{array}\n\\right.\n$$\n\n\\qquad  By hypothesis, $\\A, f(n)\\vSs \\gamma$. Thus, for every $x$-variant $s\\p$ of $s$ at $f(n)$, $\\A, f(n)\\vSp \\gamma(x)$. In particular, for an $x$-variant $s\\p$ of $s$ such that $s\\p(x)=c$, $\\A, f(n)\\vSp \\gamma(x)$. By Proposition 3, $\\A, f(n)\\models_{s^{*}} \\gamma(a^n)$. Using Proposition 2 it is easy to see that $s^{*}$ satisfies conditions (i) and (ii) of Definition 16. Therefore, $\\mathcal{B}$,  $n.$ $\\gamma(a^{n})$ is satisfiable in $\\A$ with respect to the valuation $s^{*}$ using the function $f$.\n\n\\qquad  At last, if the applied rule was the \\textit{varying domain delta rule}, then for some formula $n.$ $\\delta$ occurring in  $\\mathcal{B}$, we expand $\\mathcal{B}$ in the new branch $\\mathcal{B}$, $n.$ $\\delta(a^{n})$ where $a^{n}$ is a new parameter associated with $n$.\n\n\\qquad By hypothesis, $\\A, f(n)\\vSs \\delta$. Thus, for some $x$-variant $s\\p$ of $s$ at $f(n)$, $\\A, f(n)\\vSp \\delta(x)$. Let $s^{*}$ be a valuation such that for every variable $y$ of $\\Li^{+}$\n  \n$$\ns^{*}(y) = \\left\\{\n\\begin{array}{rcl}\ns(y) & \\mbox{if} & y \\neq a^{n}\\\\\ns\\p(x) & \\mbox{if} & y = a^{n}\\\\\n\\end{array}\n\\right.\n$$\n\n\\qquad Since $\\A, f(n)\\vSp \\delta(x)$, then by Proposition 3, $\\A, f(n)\\models_{s^{*}} \\delta(a^n)$. Once again, using Proposition 2 it is easy to see that $s^{*}$ satisfies conditions (i) and (ii) of Definition 16. Therefore $\\mathcal{B}$,  $n.$ $\\delta(a^{n})$ is satisfiable in $\\A$ with respect to the valuation $s^{*}$ using the function $f$.\n\\end{proof}\n\n\n\\begin{teor}\n(Soundness) For every $\\varphi \\in sen(\\Li)$, if $\\vdash_{S5} \\varphi$, then $\\vS \\varphi$.\n\\end{teor}\n\n\n\\begin{proof}\nSuppose $\\not\\vS \\varphi$, then there is an S5-structure $\\A$, a world $w$ and a valuation $s$ such that $\\A, w\\models_{s} \\nao\\varphi$. Then $\\{1.$ $\\nao \\varphi\\}$ is S5-satisfiable. Any tableau proof of $\\varphi$ has $1.$ $\\nao \\varphi$ at its root. By Lemma 1, any extension rule applied to $1.$ $\\nao \\varphi$ will generate an S5-satisfiable tableau. And, of course, an S5-satisfiable tableau is not closed. Therefore, $\\not \\vdash_{S5} \\varphi$\n\\end{proof}\n\n\\section{Completeness}\n\n\\begin{defn}\nWe now present a \\textit{systematic tableau construction} for \\textbf{S5}. As in \\cite{Fitting83}  we will work with each occurrence of a prefixed formula only once, but whenever we work with one of the form $n.$ $ \\nu$ and $n.$ $ \\gamma$ we add a fresh occurrence of it at the end of the branch. It is assumed that the tableau method has the property to declare that some occurrences are \"finished' (or \"used'). And we say that a tableau $\\mathcal{T}$ is a \\textit{systematic tableau} if it is generated by this construction.\n\n\\qquad A prefix formula is \\textit{atomic} if it is of the form $n.$ $\\psi$ or $n.$ $\\nao\\psi$ and $\\psi$ is an atomic formula. Since $\\Li^{+}$ is a countable language, we may arrange all the parameters of $\\Li^{+}$ in a list, this list will be refered as \\textit{initial list}.\n\n\\qquad Let $\\varphi$ be a sentence, as usual the method is described in stages.\n\n\\qquad \\textit{Stage $1)$} Begin by placing $1.$ $\\nao \\varphi$ at the origin.\n\n\\qquad Suppose $n$ stages of the construction have been completed. If the tableau we have constructed is closed, then stop. Likewise if every occurrence of a prefixed formulas is finished, then stop. Otherwise we go on to:\n\n\\qquad \\textit{Stage $n+1)$} Chose an occurrence of a prefixed formulas as closed to the origin as possible that has not been declared finished and which appears on at least one open branch, say $m.$ $\\psi$. If $m.$ $\\psi$ is atomic, simply declare the occurrence finished. This ends stage $n+1$. Otherwise we extend the tableau as follows:\n\n\\qquad For each open branch $\\mathcal{B}$ thought the occurrence of $m.$ $\\psi$:\n\n\\begin{itemize}\n\\item If $m.$ $\\psi$ is of the form $m.$ $\\nao \\nao \\theta$, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, m.$ $\\theta$. \n\\item If $m.$ $\\psi$ is of the form $m.$ $\\alpha$, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, m.$ $\\alpha_{1},m.$ $\\alpha_{2}$. \n\\item If $m.$ $\\psi$ is of the form $m.$ $\\beta$, then we simultaneously extend $\\mathcal{B}$ to the two branches $\\mathcal{B}, m.$ $\\beta_{1}$ and $\\mathcal{B}, m.$ $\\beta_{2}$.\n\\item If $m.$ $\\psi$ is of the form $m.$ $\\nu$ and $k_{1}, \\dots , k_{l}$ are all the prefixes occurring in $\\mathcal{B}$, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, k_{1}.$ $\\nu_{o}, \\dots, k_{l}.$ $\\nu_{0}, m.$ $\\nu$.\n\\item If $m.$ $\\psi$ is of the form $m.$ $\\pi$, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, k.$ $\\pi_{0}$ where $k$ is the least prefix not used on $\\mathcal{B}$.\n\\item If $m.$ $\\psi$ is of the form $m.$ $\\gamma$ and  $a_{1}, \\dots , a_{n}$ are the first $n$ parameters associated with $m$ of the initial list, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, m.$ $\\gamma(a_{1}), \\dots, m.$ $\\gamma(a_{n}), m.$ $\\gamma$.\n\\item If $m.$ $\\psi$ is of the form $m.$ $\\delta$, then we extend $\\mathcal{B}$ to the branch $\\mathcal{B}, m.$ $\\delta(a)$ where $a$ is the first parameter associated with $m$ of the initial list that has not yet been used on the branch $\\mathcal{B}$.\n\\end{itemize}\n\n\\qquad Having done this for each branch $\\mathcal{B}$ thought the particular occurrence of $m.$ $\\psi$  being considered, we declare that occurrence of $m.$ $\\psi$  \\textit{finished}. Immediately afterward, for every open branch $\\mathcal{B}$ we do the following:\n\n\\begin{itemize}\n\\item If a new prefix $k$ has been introduced to $\\mathcal{B}$ and $a_{1}, \\dots, a_{s}$ are all the parameter occurring on $\\mathcal{B}$, we extend $\\mathcal{B}$ to $\\mathcal{B}$, $k.$ $a_{1} = a_{1}, \\dots,k.$ $a_{s} = a_{s}$.   \n\\item If a new parameter $a$ has been introduced to $\\mathcal{B}$ and $k_{1}, \\dots, k_{s}$ are all the prefixes occurring on $\\mathcal{B}$, we extend $\\mathcal{B}$ to $\\mathcal{B}$, $k_{1}.$ $a=a, \\dots,k_{s}.$ $a = a$.   \n\\item For each $n.$ $a = a\\p$ and for each $k.$ $\\psi(a)$ occurring on $\\mathcal{B}$, we extend $\\mathcal{B}$ to $\\mathcal{B}, k.$ $\\psi(a\\p)$ provided that $k.$ $\\psi(a\\p)$ did not occur on $\\mathcal{B}$.  \n\\end{itemize}\n\n\\qquad This complete \\textit{stage} $n+1$.\n\\end{defn}\n\n\\qquad The above construction can terminate and produce a closed tableau; can terminate and produce a tableau with an open branch; or can never terminate. In the last case, we need a fact which inform us if a systematic tableau construction never terminate, then an infinite branch is involved. This fact is called \"K\\\"onig Lemma'. We are going to state this fact without proof, but such a proof can be found in \\cite{Fitting83}. \n\n\\qquad A tree is \\textit{finitely generated} if each node has only a finite number of immediate successors. And a tree is \\textit{infinite} if it has infinitely many nodes. A tableau is a finitely generate tree because any node has at most two immediate successors (when we apply the beta rule). Now the content of K\\\"onig Lemma is: \\\\\n\n\\vspace{10mm}\n\n\n\\textbf{K\\\"onig Lemma:} \\textit{If $\\mathcal{T}$ is an infinite tree which is finitely generated, then $\\mathcal{T}$ has an infinite branch $\\mathcal{B}$.}\n\\vspace{10mm}\n\n\n\\qquad Clearly, if a systematic tableau $\\mathcal{T}$ has an infinite branch $\\mathcal{B}$, $\\mathcal{B}$ is open. Therefore, if the systematic tableau construction never terminate, there must be an infinite open branch.\n\n\n\n\\begin{defn}\nLet $S$ be a set of prefixed formulas of $\\Li^{+}$. $S$ is S5-\\textit{downward saturated} if:\n\n\\begin{enumerate} [$(i)$]\n\n\\item For no atomic formula $\\varphi$ and no prefix $n$ do we have both $n.$ $\\varphi$ and $n.$ $\\nao \\varphi$ in $S$. \n\\item If $n.$ $\\nao\\nao\\varphi \\in S$, then $n.$ $\\varphi \\in S$.\n\\item If $n.$ $\\alpha \\in S$, then $n.$ $\\alpha_{1}, n.$ $\\alpha_{2} \\in S$.\n\\item If $n.$ $\\beta \\in S$, then $n.$ $\\beta_{1}$ or $n.$ $\\beta_{2} \\in S$.\n\\item If $n.$ $\\nu \\in S$, then for every prefix $k$ that occurs in $S$,  $k.$ $\\nu_{0} \\in S$.\n\\item If $n.$ $\\pi \\in S$, then for some prefix $k$ that occurs in $S$,  $k.$ $\\pi_{0} \\in S$.\n\\item If $n.$ $\\gamma \\in S$, then for every parameter $a$ associated with $n$, $n.$ $\\gamma(a) \\in S$.\n\\item If $n.$ $\\delta \\in S$, then for some parameter $a$ associated with $n$, $n.$ $\\delta(a) \\in S$.\n\\item If $n$ and $a$ both occur in $S$, then $n.$ $a=a \\in S$.\n\\item If $n.$ $a=a\\p ,k.$ $\\varphi(a) \\in S$, then $k.$ $\\varphi(a\\p) \\in S$.\n\\end{enumerate}\n\\end{defn}\n\n\n\\begin{pro}\nLet $\\mathcal{B}$ be a branch from a systematic tableau $\\mathcal{T}$ and $S$ be the set of all prefixed formulas occurring on $\\mathcal{B}$. If $\\mathcal{B}$  is an open branch, then $S$ is an S5-downward saturated set. \n\\end{pro}\n\n\n\\begin{proof}\nTo prove this fact we need to check that $S$ satisfies conditions $(i)-(x)$ of Definition 18. We will present here the argument only for the non-trivial ones.\n\n\\qquad $(v)$: Suppose $k.$ $\\nu \\in S$ and $m$ is a prefix occurring on some prefixed formula $m.$ $\\psi$ of $S$. Then, in some stage $n$, $m.$ $\\psi$ is not finished. If $k.$ $\\nu$ appear in some stage $n\\p$ and $n \\leq n\\p$ , then $m.$ $\\nu_{0}$ is added in the stage $n\\p +1$. On the other hand, if $k.$ $\\nu$ had appear in some stage $n\\p$ and $n\\p<n$, then, since we always introduce a fresh occurrence of $k.$ $\\nu$ in any stage, there is a not finished occurrence of $k.$ $\\nu$ in the stage $n$, so $m.$ $\\nu_{0}$ is added in the stage $n +1$. Therefore,  $m.$ $\\nu_{0} \\in S$.        \n\n\\qquad $(vii)$: Suppose $k.$ $\\gamma \\in S$ and $a$ is a parameter associated with $k$. Let $a_{1}, \\dots , a_{m}$ be all parameters associated with $k$ which come before $a$ in the initial list. Then, in some stage $n$, $k.$ $\\gamma$ is not finished. If $n = m+1$, then $k.$ $\\gamma(a)$ is added in the stage $m+2$. If $n<m+1$, then since we always introduce a fresh occurrence of $k.$ $\\gamma$ in any stage, there is a not finished occurrence of $k.$ $\\gamma$ in the stage $m+1$, so $k.$ $\\gamma(a)$ is added in the stage $m+2$. And if $n>m+1$, then $a_{1}, \\dots , a_{m},a, \\dots, a_{l}$ are the first $n$ parameters associated with $k$, so $k.$ $\\gamma(a)$ is added in the stage $n+1$. Therefore,  $k.$ $\\gamma(a) \\in S$.        \n\\end{proof}\n\n\\begin{lema}\nIf $S$ is S5-downward saturated, then $S$ is S5-satisfiable. \n\\end{lema}\n\n\\begin{proof}\nWe shall define an S5-structure $\\A$ using the formulas of $S$. First, for every parameter $a,b$ in $S$, we define:\n\n\\begin{center}\n$a \\thicksim b$ iff there is a prefix $n$ such that $n.$ $a=b \\in S$.\n\\end{center}\n\n\\qquad Using properties $(ix)$ and $(x)$ of Definition 18, it can be easily seen that $\\thicksim$ is an equivalence relation. We write $a^{\\circ}$ to denote the equivalence class of $a$. \n\n\\qquad Second, let $\\A = \\strucAS$ where:\n\n\n\\begin{itemize}\n\\item $\\W$ is the set of prefixes of $S$.\n\\item $\\D$ the set of all equivalence classes of $\\thicksim$.\n\\item $a^{\\circ} \\in \\barD_{n}$ iff there is a $b \\in a^{\\circ}$ such that $b$ is a parameter associated with $n$.\n\\item for any $a_1^{\\circ}, \\dots, a_k^{\\circ}$ in $\\D$, $\\bl a_1^{\\circ}, \\dots, a_k^{\\circ} \\br \\in \\I(F,n)$ iff $n.$  $Fa_1, \\dots, a_k \\in S$.\n\\end{itemize}\n\n\\qquad Again, using property $(x)$ of Definition 18, it can be seen that the definition of $\\I(F,n)$ depend only on the $a_i^{\\circ}$ and not on the $a_i$.\n\n\\qquad Now, let $s$ be a valuation in $\\A$ such that for every parameter $a$, $s(a)= a^{\\circ}$. To prove that $S$ is S5-satisfiable is enough to prove the following proposition:\n\n\n\\begin{center}\n(+) For each formula $\\varphi$ and for each prefix $n$ of $S$:\\\\\n$\\bullet$ If $n.$ $\\varphi \\in S$, then $\\A,n \\vSs \\varphi$. \\\\\n$\\bullet$ If $n.$ $\\nao \\varphi \\in S$, then $\\A,n \\nvSs \\varphi$.\n\\end{center}\n\n\\qquad (Proof of (+)) Induction on $\\varphi$.\n\\vspace{10mm}\n\n\n\n\n($\\varphi : = a=b$)\\\\\n\\qquad If $n.$ $a=b \\in S$, then $a\\thicksim b$. Thus, $a^{\\circ} = b^{\\circ}$. Hence, $s(a)=s(b)$ and so $\\A,n \\vSs a=b$. \n\n\\qquad If $n.$ $a\\neq b \\in S$, suppose $a\\thicksim b$. Then, for some prefix $m$, $m.$ $a = b \\in S$. By $(x)$ of Definition 18, $n.$ $b\\neq b \\in S$. By $(ix)$ of Definition 18, $n.$ $b= b \\in S$; contradicting condition $(i)$. Therefore, $a \\not \\thicksim b$, thus $a^{\\circ} \\neq b^{\\circ}$. Hence, $s(a)\\neq s(b)$ and so $\\A,n \\nvSs a=b$. \n\n\n\n\\vspace{10mm}\n\n($\\varphi: = Fa_{1},\\dots,a_{n}$)\\\\\n\\qquad If $n.$ $Fa_1, \\dots ,a_k \\in S$, then $\\bl a_1^{\\circ}, \\dots, a_k^{\\circ} \\br \\in \\I(F,n)$, i.e. $\\bl s(a_1), \\dots, s(a_k) \\br \\in \\I(F,n)$. And so  $\\A,n \\vSs Fa_1, \\dots ,a_k$.   \n\n\\qquad If $n.$ $\\nao Fa_1, \\dots ,a_k \\in S$, then, by condition $(i)$, $n.$ $Fa_1, \\dots ,a_k \\notin S$. So $\\bl a_1^{\\circ}, \\dots, a_k^{\\circ} \\br \\notin \\I(F,n)$, i.e. $\\bl s(a_1), \\dots, s(a_k) \\br \\notin \\I(F,n)$. And so  $\\A,n \\nvSs Fa_1, \\dots ,a_k$.     \n\\vspace{10mm}\n\n\n($\\varphi := \\nao \\psi$)\\\\\n\\qquad If $n.$ $\\nao \\psi \\in S$, then, by induction hypothesis, $\\A,n \\nvSs \\psi$; so $\\A,n \\vSs \\nao \\psi$. \n\n\\qquad If $n.$ $\\nao\\nao \\psi \\in S$, then, by condition $(ii)$, $n.$ $\\psi \\in S$. Thus, by induction hypothesis, $\\A,n \\vSs \\psi$; so $\\A,n \\nvSs \\nao\\psi$.  \n\n\\vspace{10mm}\n\n($\\varphi: = \\psi \\ou \\theta$)\\\\\n\\qquad If $n.$ $\\psi \\ou \\theta \\in S$, then, by condition $(iii)$, either $n.$ $\\psi \\in S$, or $n.$ $\\theta \\in S$.  By induction hypothesis, either $\\A,n \\vSs \\psi$ or $\\A,n \\vSs \\theta$; so $\\A,n \\vSs \\psi \\ou \\theta$. \n\n\\qquad If $n.$ $\\nao(\\psi \\ou \\theta) \\in S$, then, by condition $(iv)$, $n.$ $\\nao \\psi, n.$ $\\nao \\theta \\in S$. Thus, by induction hypothesis, $\\A,n \\nvSs \\psi$ and $\\A,n \\nvSs \\theta$; so $\\A,n \\nvSs \\psi\\ou\\theta$.  \n\\vspace{10mm}\n\n\n\\qquad The proof for $\\varphi := \\psi \\e \\theta$ and $\\varphi := \\psi \\impli \\theta$ are similar.\n\\vspace{10mm}\n\n\n\n($\\varphi: = \\Diamond \\psi$)\\\\\n\\qquad If $n.$ $\\Diamond \\psi \\in S$, then, by condition $(vi)$, for some prefix $k$ of $S$, $k.$ $\\psi \\in S$. By induction hypothesis, $\\A,k \\vSs \\psi$; so  $\\A,n \\vSs \\Diamond\\psi$.  \n\n\\qquad If $n.$ $\\nao\\Diamond\\psi \\in S$, then, by condition $(v)$, for every prefix $k$ of S, $k.$ $\\nao \\psi \\in S$. Thus, by induction hypothesis, for every $k \\in \\W$, $\\A,k \\nvSs \\psi$; so $\\A,n \\nvSs \\Diamond \\psi$.  \n\\vspace{10mm}\n\n\n\\qquad The proof for $\\varphi := \\Box\\psi$ is similar.\n\\vspace{10mm}\n\n\n\n($\\varphi := \\ex x \\psi$)\\\\\n\\qquad If $n.$ $\\ex x \\psi \\in S$, then, by condition $(viii)$, for some parameter $a$ associated with $n$, $n.$ $\\psi(a) \\in S$. By induction hypothesis, $\\A,n \\vSs \\psi(a)$. Since $a \\in a^{\\circ} = s(a)$ and $a$ is a parameter associated with $n$, then $a^{\\circ} \\in \\barD_{n}$. Let $s\\p$ be a valuation in $\\A$ such that for every variable $y$ of $\\Li^{+}$\n  \n$$\ns\\p(y) = \\left\\{\n\\begin{array}{rcl}\ns(y) & \\mbox{if} & y \\neq x\\\\\ns(a) & \\mbox{if} & y = x\\\\\n\\end{array}\n\\right.\n$$\n    \n\\qquad Clearly, $s\\p$ is an $x$-variant of $s$ at $n$. By Proposition 3, $\\A,n \\vSp \\psi$. So, $\\A,n \\vSs \\ex x\\psi$.      \n\n\\qquad If $n.$ $\\nao\\ex x \\psi\\in S$, then, by condition $(vii)$, for every parameter $a$ associated with $n$, $n.$ $\\nao \\psi(a) \\in S$. By induction hypothesis, for every parameter $a$ associated with $n$, $\\A,n \\vSs \\psi(a)$.\n\n\\qquad Suppose $\\A,n \\vSs \\ex x \\psi$. Then, for some $x$-variant $s\\p$ of $s$ at $n$, $\\A,n \\vSp \\psi$. Since $s\\p(x) \\in \\barD_{n}$, there is a parameter $b$ associated with $n$ such that $b \\in s\\p(x)$. So, $b^{\\circ} = s\\p(x)$, i.e. $s(b)= s\\p(x)$. By Proposition 3, $\\A,n \\vSs \\psi(b)$, a contradiction. Therefore, $\\A,n \\nvSs \\ex x \\psi$.    \n\\vspace{10mm}\n\n\\qquad The proof for $\\varphi := \\todo x\\psi$ is similar.\n\\end{proof}\n\n\\begin{teor}\n(Completeness) For every $\\varphi \\in sen(\\Li)$, if $\\vS\\varphi$, then $\\vdash_{\\textbf{S5}} \\varphi$\n\\end{teor}\n\n\\begin{proof}\nSuppose $\\not\\vdash_{\\textbf{S5}} \\varphi$. Then, $\\varphi$ has no S5-tableau proof, then a systematic tableau for $1.$  $\\nao \\varphi$ will wither terminate producing an open branch or will not terminate. By K\\\"onig's Lemma, in either case there will be an open branch $\\mathcal{B}$. Let $S$ be the set of all prefixed formulas occurring on $\\mathcal{B}$. By Proposition 7, $S$ is an S5-downward saturated set. By Lemma 2, $S$ is S5-satisfiable. Since $1.$ $\\nao \\varphi \\in S$, $\\nao \\varphi$ is S5-satisfiable. Therefore $\\not\\vS\\varphi$.\n\\end{proof}\n\n\n\\section{Compactness}\n\n\n\\begin{defn}\nLet $T$ be a set of sentences of $\\Li$. We modify the definition of systematic tableau construction in order to extend the tableau method for sets of sentences. Since both $\\Li$ and $\\Li^{+}$ are countable languages, $T$ is a countable set. Let $\\varphi_1, \\varphi_2, \\varphi_3, \\dots$ be a list of the member of $T$. The construction of the sistematic tableau for $T$ is described as follows:\n\n\\qquad \\textit{Stage $1)$} Begin by placing $1.$ $\\varphi_{1}$ at the origin\n\n\\qquad Suppose $n$ stages have been completed.\n\n\\qquad \\textit{Stage $n+1)$} Do everything as described in Definition 17. But before completing stage $n+1$, we extend each open branch $\\mathcal{B}$ to the branch $\\mathcal{B}, 1.$ $\\varphi_{n+1}$. \n\n\\end{defn}\n\n\\begin{teor}\n(Compactness) Let $\\{\\varphi\\}$, $T$ be set of sentences of $\\Li$. Then:\n\\begin{enumerate}[(a)]\n\\item If for every $T_{0} \\subseteq_{fin} T$, $T_{0}$ is S5-satisfiable, then $T$ is S5-satisfiable.\n\\item If $T\\vS \\varphi$, then for some $T_{0} \\subseteq_{fin} T$, $T_{0}\\vS \\varphi$.\n\\end{enumerate}\n\\end{teor}\n\n\\begin{proof}\n(a) By definition, the construction of the systematic tableau for $T$ can either terminate and produce a closed tableau or can never terminate. Suppose it terminates, then it terminates at some stage $n$. So the resulting tableau is the same as the tableau for the set $\\{\\varphi_1, \\dots, \\varphi_n\\}$. It can be easily seen, that if there is a closed tableau for $\\{\\varphi_1, \\dots, \\varphi_n\\}$, then there is a closed tableau for $\\varphi_1 \\e \\dots \\e \\varphi_n$; and so there is a closed tableau for $\\nao\\nao(\\varphi_1 \\e \\dots \\e \\varphi_n)$. Hence, $\\vdash_{\\textbf{S5}}\\nao(\\varphi_1 \\e \\dots \\e \\varphi_n)$. By Theorem 2, $\\vS\\nao(\\varphi_1 \\e \\dots \\e \\varphi_n)$; contradicting the assumption that $\\{\\varphi_1, \\dots, \\varphi_n\\}$ is S5-satisfiable. Therefore, the construction of the systematic tableau for $T$ never terminate. By K\\\"onig's Lemma, there is an infinite open branch $\\mathcal{B}$. Let $S$ be the set of all formulas occurring in $\\mathcal{B}$. Clearly, for every $\\varphi \\in T$, $1.$ $\\varphi \\in S$. By Proposition 7 and Lemma 2, $S$ is S5-satisfiable, and so $T$ is S5-satisfiable.   \n\n\n\\qquad (b) If $T\\vS \\varphi$, then $T \\cup \\{\\nao \\varphi\\}$ is not S5-satisfiable. By item (a), there is a $T_{0}\\cup\\{\\nao \\varphi\\}  \\subseteq_{fin} T \\cup \\{\\nao \\varphi\\}$ such that $T_{0}\\cup\\{\\nao \\varphi\\}$ is not S5-satisfiable. Hence, $T_{0}\\vS \\varphi$.\n\\end{proof}\n\n\n\n\n", "meta": {"hexsha": "3f9c83a6d6da63236189a25af149ee5a4057ceb9", "size": 31879, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/chapters/Completeness.tex", "max_stars_repo_name": "felipessalvatore/dissertacao_mestrado", "max_stars_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/chapters/Completeness.tex", "max_issues_repo_name": "felipessalvatore/dissertacao_mestrado", "max_issues_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/chapters/Completeness.tex", "max_forks_repo_name": "felipessalvatore/dissertacao_mestrado", "max_forks_repo_head_hexsha": "171d9f4d7b99fb6b70de04c109ff4f5d0f65ef4b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0048939641, "max_line_length": 1118, "alphanum_fraction": 0.645534678, "num_tokens": 11253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.4320673118006607}}
{"text": "% !TEX root = ../../../proposal.tex\n\n\\section{IPsec}\n\n%Description of IKEv1 and IKEv2.\n\nIPsec is a set of Layer-3 protocols which add confidentiality, data protection,\nsender authentication, and access control to IP traffic. IPsec is commonly used\nto implement VPNs.\n%IPsec provides two types of security service: Authentication Header (AH),\n%which provides sender authentication, and Encapsulating Security Payload\n%(ESP), which provides both sender authentication and payload encryption.  Each\n%of these services requires the communicating parties to establish shared\n%state, which includes the cryptographic algorithms used to provide the service\n%and the keys used as input for the cryptographic algorithms.\nIPsec uses the Internet Key Exchange (IKE) protocol to determine the keys used\nto secure a session. IPsec may use IKEv1~\\cite{rfc2409} or\nIKEv2~\\cite{rfc7296}. While IKEv2 is not backwards-compatible with IKEv1, the\ntwo protocols are similar in message structure and purpose. Both versions use\nDiffie-Hellman to negotiate shared secrets. The groups used are limited to a\nfixed set of pre-determined choices, which include the DSA groups from\nRFC~5114, each assigned a number by IANA~\\cite{rfc3526,rfc5114,rfc7296}.\n\n% IKE versions\n\\paragraph{IKEv1}\n%IKEv1 is a hybrid protocol built upon three other protocols:\n%ISAKMP~\\cite{rfc2408}, which establishes a framework for authentication and\n%key exchange; Oakley~\\cite{rfc2412}, which defines a series of key exchanges\n%and services based on the Diffie-Hellman key exchange; and\n%SKEME~\\cite{krawczyk1996skeme}, a key exchange protocol that provides\n%anonymity, repudiability, and quick key refreshement.  IKEv1 is formally\n%defined in RFCs 2407~\\cite{rfc2407}, 2408~\\cite{rfc2408}, and\n%2409~\\cite{rfc2409}. \nIKEv1~\\cite{rfc2407,rfc2408,rfc2409} has two basic methods for authenticated\nkey exchange: Main Mode and Aggressive Mode. Main Mode requires six messages to\nestablish the requisite state. The initiator sends a Security Association\n(\\texttt{SA}) payload, containing a selection of cipher suites and\nDiffie-Hellman groups they are willing to negotiate. The responder selects a\ncipher and responds with its own \\texttt{SA} payload. After the cipher suite is\nselected, the initiator and responder both transmit Key Exchange (\\texttt{KE})\npayloads containing public Diffie-Hellman values for the chosen group. At this\npoint, both parties compute shared key materials, denoted \\texttt{SKEYID}. When\nusing signatures for authentication, \\texttt{SKEYID} is computed\n$\\texttt{SKEYID} = \\operatorname{prf}(N_i | N_r, g^{x_ix_r})$.  For the other\ntwo authentication modes, pre-shared key and public-key encryption,\n\\texttt{SKEYID} is derived from the pre-shared key and session cookies,\nrespectively, and does not depend on the negotiated Diffie-Hellman shared\nsecret.\n\nEach party then in turn sends an authentication message (\\texttt{AUTH}) derived\nfrom a hash over \\texttt{SKEYID} and the handshake. The authentication messages\nare encrypted and authenticated using keys derived from the Diffie-Hellman\nsecret $g^{x_i x_r}$.  The responder only sends her \\texttt{AUTH} message after\nreceiving and validating the initiator's \\texttt{AUTH} message.\n\nAggressive Mode operates identically to Main Mode, but in order to reduce\nlatency, the initiator sends \\texttt{SA} and \\texttt{KE} messages together, and\nthe responder replies with its \\texttt{SA}, \\texttt{KE}, and \\texttt{AUTH}\nmessages together. In aggressive mode, the responder sends an authentication\nmessage first, and the authentication messages are not encrypted.\n\n\n\\paragraph{IKEv2}\n%IKE Version 2 (IKEv2) was released in RFC 4306~\\cite{rfc4306} to replace IKEv1\n%and the plethora of RFCs that define it. RFC 7296~\\cite{rfc7296} gives the\n%current version of the IKEv2 specification.\nIKEv2~\\cite{rfc4306,rfc7296} combines the \\texttt{SA} and \\texttt{KE} messages\ninto a single message. The initiator provides a best guess ciphersuite for the\n\\texttt{KE} message. If the responder accepts that proposal and chooses not to\nrenegotiate, the responder replies with a single message containing both\n\\texttt{SA} and \\texttt{KE} payloads. Both parties then send and verify\n\\texttt{AUTH} messages, starting with the initiator.  The authentication\nmessages are encrypted using session keys derived from the \\texttt{SKEYSEED}\nvalue which is derived from the negotiated Diffie-Hellman shared secret. The\nstandard authentication modes use public-key signatures over the handshake\nvalues.\n\n%IKE Group~23, the 2048-bit MODP group with a 224-bit subgroup, is particularly\n%vulnerable as shown in Section~\\ref{sec:ecm}.\n\n\\subsection{Small Subgroup Attacks in IPsec} There are several variants of\nsmall subgroup attacks against IKEv1 and IKEv2.  We describe the attacks\nagainst these protocols together in this section.\n\n\\paragraph{Small subgroup confinement attacks} First, consider attacks that can\nbe carried out by an attacking initiator or responder. In IKEv1 Main Mode and\nin IKEv2, either peer can carry out a small subgroup confinement attack against\nthe other by sending a generator of a small subgroup as its key exchange value.\nThe attacking peer must then guess the other peer's view of the Diffie-Hellman\nshared secret to compute the session keys to encrypt its authentication\nmessage, leading to a mostly online attack. However, in IKEv1 Aggressive Mode,\nthe responder sends its \\texttt{AUTH} message before the initiator, and this\nvalue is not encrypted with a session key. If signature authentication is being\nused, the \\texttt{SKEYID} and resulting hashes are derived from the\nDiffie-Hellman shared secret, so the initiator can perform an offline\nbrute-force attack against the responder's authentication message to learn\ntheir exponent in the small subgroup.\n\nNow, consider a man-in-the-middle attacker. Bhargavan, Delignat-Lavaud, and\nPironti~\\cite{bhargavan-channel-bindings-2015} describe a transcript synchronization\nattack against IKEv2 that relies on a small subgroup confinement attack.  A\nman-in-the-middle attacker initiates simultaneous connections with an initiator\nand a responder using identical nonces, and sends a generator $g_i$ for a\nsubgroup of small order $q_i$ to each as its \\texttt{KE} message.  The two\nsides have a $1/q_i$ chance of negotiating an identical shared secret, so an\nauthentication method depending only on nonces and shared secrets could be\nforwarded, and the session keys would be identical.\n\nIf the attacker also has knowledge of the secrets used for authentication, more\nattacks are possible.  Similar to the attack described for TLS, such an\nattacker can use a small subgroup confinement attack to force a connection to\nuse weak encryption. The attacker only needs to rewrite a small number of\nhandshake messages; any further encrypted communications can then be decrypted\nat leisure without requiring the man-in-the-middle attacker to continuously\nrewrite the connection. We consider a man-in-the-middle attacker who modifies\nthe key exchange message from both the initiator and the responder to\nsubstitute a generator $g_i$ of a subgroup of small order $q_i$.  The attacker\nmust then replace the handshake authentication messages, which would require\nknowledge of the long-term authentication secret.  We describe this attack for\neach of pre-shared key, signatures, and public-key authentication. \n\nFor pre-shared key authentication in IKEv1 Main Mode, IKEv1 Aggressive Mode,\nand IKEv2, the man-in-the-middle attacker must only know the pre-shared key to\nconstruct the authentication hash; the authentication message does not depend\non the negotiated Diffie-Hellman shared secret. With probability $1/q_i$, the\ntwo parties will agree on the Diffie-Hellman shared secret. The attacker can\nthen brute force this value after viewing messages encrypted with keys derived\nfrom it.\n\nFor signature authentication in IKEv1 Main Mode and in IKEv2, the signed hash\ntransmitted from each side is derived from the nonces and the negotiated shared\nsecret, which is confined to one of $q_i$ possible values.  The attacker must\nknow the private signing keys for both initiator and responder and brute force\n\\texttt{SKEYID} from the received signature in order to forge the modified\nauthentication signatures on each side. The communicating parties will have a\n$q_i$ chance of agreeing on the same value for the shared secret to allow the\nattack to succeed. For IKEv1 Aggressive Mode, the attack can be made to succeed\nevery time. The responder's key exchange message is sent together with their\nsignature which depends on the negotiated shared secret, so the\nman-in-the-middle attacker can brute force the $q_i$ possible values of the\nresponders private key $x_r$ and replace the responder's key exchange message\nwith $q_i^{x_r}$, forging an appropriate signature with their knowledge of the\nsigning key.\n\nFor public key authentication in IKEv1 Main Mode, IKEv1 Aggressive Mode, and\nIKEv2, the attacker must know the private keys corresponding to the public keys\nused to encrypt the ID and nonce values on both sides in order to forge a valid\nauthentication hash.  Since the authentication does not depend on the shared\nDiffie-Hellman negotiated value, a man-in-the-middle attacker must then brute\nforce the negotiated shared key once they receives a message encrypted with the\nderived key.  The two parties will agree on their view of the shared key with\nprobability $1/q_i$, allowing the attack to succeed.\n\n\\paragraph{Small subgroup key recovery attacks} Similar to TLS, an IKE\nresponder that reuses private exponents and does not verify that the initiator\nkey exchange values are in the correct subgroup is vulnerable to a small\nsubgroup key recovery attack. The most recent version of the IKEv2\nspecification has a section discussing reuse of Diffie-Hellman exponents,\nand states that ``because computing Diffie-Hellman exponentials is\ncomputationally expensive, an endpoint may find it advantageous to reuse those\nexponentials for multiple connection setups''~\\cite{rfc7296}. Following this\nrecommendation could leave a host open to a key recovery attack, depending on\nhow exponent reuse is implemented. A small subgroup key recovery attack on IKE\nwould be primarily offline for IKEv1 with signature authentication and for\nIKEv2 against the initiator.\n\nFor each subgroup of order $q_i$, the attacker's goal is to obtain a responder\n\\texttt{AUTH} message, which depends on the secret chosen by the responder. If\nan \\texttt{AUTH} message can be obtained, the attacker can brute-force the\nresponder's secret within the subgroup offline. This is possible if the server\nsupports IKEv1 Aggressive Mode, since the server authenticates before the\nclient, and signature authentication produces a value dependent on the\nnegotiated secret.  In all other IKE modes, the client authenticates first,\nleading to an online attack. The flow of the attack is identical to TLS; for\nmore details see Section~\\ref{sec:subgroup_tls}.\n\nFerguson and Schneier~\\cite{ferguson2000cryptographic} describe a hypothetical\nsmall-subgroup attack against the initiator where a man-in-the-middle attacker\nabuses undefined behavior with respect to UDP packet retransmissions. A\nmalicious party could ``retransmit'' many key exchange messages to an initiator\nand potentially receive a different authentication message in response to each,\nallowing a mostly offline key recovery attack.\n\n%The attacker must choose their key exchange value to be a generator of the\n%selected subgroup, which we call $g_i$.  When the responder computes the\n%shared secret, $g_i^a$, it will lie within the chosen subgroup.  The attacker\n%must guess $g_i^a \\bmod q_i$, and construct their \\texttt{AUTH} message\n%accordingly.  The responder will reply with an \\texttt{AUTH} message in the\n%event of a correct guess, and an error message otherwise.  With repeated\n%guessing, the attacker can learn the value of $g_i^a$ for each subgroup, and\n%take advantage of the Pollard labmda algorithm to solve for the rest of the\n%secret offline within the reduced search space.\n\n\\subsection{Implementations}\n\nWe examined several open-source IKE implementations to understand server\nbehavior.  In particular, we looked for implementations that generate small\nDiffie-Hellman exponents, repeat exponents across multiple connections, or do\nnot correctly validate subgroup order. Despite the suggestion in IKEv2 RFC 7296\nto reuse exponents~\\cite{rfc7296}, none of the implementations that we examined\nreused secret exponents. \n\n% This is already included in the intro\n%RFC 6989~\\cite{rfc6989} (``Additional Diffie-Hellman Tests for IKEv2'')\n%specifies additional checks that IKE implementations supporting MODP groups\n%with small subgroups should perform. The RFC requries IKE implementations to\n%choose between either checking that the peer's public value is in the correct\n%subgroup, or it must never reuse Diffie-Hellman private values. \n\nAll implementations we reviewed are based on FreeS/WAN~\\cite{freeswan}, a\nreference implementation of IPSec. The final release of FreeS/Wan, version\n2.06, was released in 2004. Version 2.04 was forked into\nOpenswan~\\cite{openswan} and strongSwan\\cite{strongswan}, with a further fork\nof Openswan into Libreswan~\\cite{libreswan} in 2012.  The final release of\nFreeS/WAN used constant length 256-bit exponents but did not support RFC~5114\nDSA groups, offering only the Oakley 1024-bit and 1536-bit groups that use safe\nprimes.\n\n\\IKEGroupSupportAndValidationTable\n\nOpenswan does not generate keys with short exponents. By default, RFC~5114\ngroups are not supported, although there is a compile-time option that can be\nexplicitly set to enable support for DSA groups.  strongSwan both supports\nRFC~5114 groups and has explicit hard-coded exponent sizes for each group. The\nexponent size for each of the RFC~5114 DSA groups matches the subgroup size.\nHowever, these exponent sizes are only used if the\n\\texttt{dh\\_exponent\\_ansi\\_x9\\_42} configuration option is set. It also\nincludes a routine inside an \\texttt{\\#ifdef} that validates subgroup order by\nchecking that $g^q \\equiv 1 \\bmod p$, but validation is not enabled by default.\nLibreswan uses Mozilla Network Security Services (NSS)~\\cite{nss-overview} to\ngenerate Diffie-Hellman keys. As discussed in Section~\\ref{subsec:nss}, NSS\ngenerates short exponents for Diffie-Hellman groups. Libreswan was forked from\nOpenswan after support for RFC~5114 was added, and retains support for those\ngroups if it is configured to use them. \n\nAlthough none of the implementations we examined were configured to reuse\nDiffie-Hellman exponents across connections, the failure to validate subgroup\norders even for the pre-specified groups renders these implementations fragile\nto future changes and vulnerable to subgroup confinement attacks.\n\nSeveral closed source implementations also provide support for RFC~5114\nGroup~24. These include Cisco's IOS~\\cite{ciscogroup24}, Juniper's\nJunos~\\cite{junosgroup24}, and Windows Server 2012 R2~\\cite{windowsgroup24}. We\nwere unable to examine the source code for these implementations to determine\nwhether or not they validate subgroup order.\n\n%\\IKEGroupSupportAndValidationTable\n\n\\subsection{Measurements}\n\nWe performed a series of Internet scans using ZMap to identify IKE responders.\nIn our analysis, we only consider hosts that respond to our ZMap scan probes.\nMany IKE hosts that filter their connections based on IP are excluded from our\nresults.  We further note that, depending on VPN server configurations, some\nresponders may continue with a negotiation that uses weak parameters until they\nare able to identify a configuration for the connecting initiator. At that\npoint, they might reject the connection. As an unauthenticated initiator, we\nhave no way of distinguishing this behavior from the behaviour of a VPN server\nthat legitimately accepts weak parameters. For a more detailed explanation of\npossible IKE responder behaviors in response to scanning probes, see\nWouters~\\cite{paul-wouters}.\n\nIn October 2016, we performed a series of scans offering the most common cipher\nsuites and group parameters we found in implementations to establish a baseline\npopulation for IKEv1 and IKEv2 responses. For IKEv1, the baseline scan offered\nOakley groups 2 and 14 and RFC~5114 groups 22, 23, and 24 for the group\nparameters; SHA1 or SHA256 for the hash function; pre-shared key or RSA\nsignatures for the authentication method; and AES-CBC, 3DES, and DES for the\nencryption algorithm.  Our IKEv2 baseline scan was similar, but also offered\nthe 256-bit and 384-bit ECP groups and AES-GCM for authenticated encryption.\n\nOn top of the baseline scans, we performed additional scans to measure support\nfor the non-safe RFC~5114 groups and for key exchange parameter validation.\nTable~\\ref{tab:ikegroupsupportandvalidation} shows the results of the October\nIKE scans.  For each RFC~5114 DSA group, we performed four handshakes with each\nhost; the first tested for support by sending a valid client key exchange\nvalue, and the three others tested values that should be rejected by a\nproperly-validating host. We did not scan using the key exchange value $0$\nbecause of a vulnerability present in unpatched Libreswan and Openswan\nimplementations that causes the IKE daemon to restart when it receives such a\nvalue~\\cite{cve-2015-3240}.\n\nWe considered a host to accept our key exchange value if after receiving the\nvalue, it continued the handshake without any indication of an error. We found\nthat 33.2\\% of IKEv1 hosts and 17.7\\% of IKEv2 hosts that responded to our\nbaseline scans supported using one of the RFC 5114 groups, and that a\nsurprising number of hosts failed to validate key exchange values.  24.8\\% of\nIKEv1 hosts that accepted Group 23 with a valid key exchange value also\naccepted $1 \\bmod p$ or $-1 \\bmod p$ as a key exchange value, even though this\nis explicitly warned against in the RFC~\\cite{rfc2412}.  This behavior leaves\nthese hosts open to a small subgroup confinement attack even for safe primes,\nas described in Section~\\ref{subsec:small-subgroup-attack}.\n\nFor safe groups, a check that the key exchange value is strictly between $1$\nand $p-1$ is sufficient validation. However, when using non-safe DSA primes, it\nis also necessary to verify that the key exchange value lies within the correct\nsubgroup (\\ie, $y^q \\equiv 1 \\bmod p$). To test this case, we constructed a\ngenerator of a subgroup that was not the intended DSA subgroup, and offered\nthat as our key exchange value. We did not find any IKEv1 hosts that rejected\nthis key exchange value after previously accepting a valid key exchange value\nfor the given group. For IKEv2, the results were similar with the exception of\nGroup 24, where still over 93\\% of hosts accepted this key exchange value. This\nsuggests that almost no hosts supporting DSA groups are correctly validating\nsubgroup order. \n\nWe observed that across all of the IKE scans, 109 IKEv1 hosts and 52 IKEv2\nhosts repeated a key exchange value. This may be due to entropy issues in key\ngeneration rather than static Diffie-Hellman exponents; we also found 15,891\nrepeated key exchange values across different IP addresses. We found no hosts\nthat used both repeated key exchange values and non-safe groups. We summarize\nthese results in Table~\\ref{tab:scandata}. \n\n%The results of these scans are presented in Table~\\ref{tab:scandata}.  To get\n%a an estimate of the number of hosts that support each IKE version, we\n%conducted scans of 1\\% of the IPv4 address space using Zmap. If the host\n%responded with a valid message for the IKE version we were scanning for, we\n%considered it to support that version. The numbers present for IKE support in\n%Table~\\ref{tab:scandata} are extrapolated from these 1\\% scans.\n\n%To measure support for each of the RFC 5114 DSA groups, we conducted\n%additional 1\\% scans for IKEv1 Main Mode and IKEv2. We advertised a variety of\n%common ciphersuite parameters, but only a single Diffie-Hellman group for each\n%of these scans.  We considered a host willing to negotiate that group if they\n%responded with a valid key exchange payload.  Table~\\ref{tab:scandata} shows\n%the number of hosts that were willing to negotiate any of the RFC 5114 DSA\n%groups for IKEv1 Main Mode and IKEv2.  These hosts fit at least one of the\n%four conditions for the small subgroup attack by using a prime $p$ where $p-1$\n%has small factors.\n\n%We performed additional scans to measure if any hosts repeated Diffie-Hellman\n%key exchange values. First, we performed two simultaneous IKEv1 Main Mode\n%scans proposing Group 23 only. In this scan, we did not observe any repeated\n%key exchange values. However, across all the IKE scans that we performed, we\n%observed that 109 hosts for IKEv1 and 52 hosts for IKEv2 repeated key exchange\n%values at least once with Group 2 (a 1024-bit MODP group).\n", "meta": {"hexsha": "9295af165fae0af1d37654026847826abb1baec8", "size": 20846, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/subgroup/paper/ipsec.tex", "max_stars_repo_name": "dadrian/dissertation", "max_stars_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "papers/subgroup/paper/ipsec.tex", "max_issues_repo_name": "dadrian/dissertation", "max_issues_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/subgroup/paper/ipsec.tex", "max_forks_repo_name": "dadrian/dissertation", "max_forks_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.0416666667, "max_line_length": 84, "alphanum_fraction": 0.8061498609, "num_tokens": 4993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680143008301, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4320058635810698}}
{"text": "\\title{Variational and Diffusion Monte Carlo approaches to the nuclear few- and many-body problem}\r\n\\author{Francesco Pederiva, Alessandro Roggero, Kevin E. Schmidt}\r\n\\institute{Francesco Pederiva \\at Physics Department, University of Trento, and INFN-TIFPA, Trento, Italy , \\email{francesco.pederiva@unitn.it} \\and Kevin E. Schmidt \\at Department of Physics, Arizona State University, Tempe AZ 85283-1506 (USA) \\email{kevin.schmidt@asu.edu} \\and\r\nAlessandro Roggero \\at Institute for Nuclear Theory, University of Washington, Seattle WA (USA) , \\email{roggero@uw.edu}}\r\n\r\n\\maketitle\r\n\\abstract{We review Quantum Monte Carlo methods, a class of stochastic methods allowing for solving the many-body Schr\\\"odinger equation for an arbitrary Hamiltonian. The basic elements of\r\nthe stochastic integration theory are first presented, followed by the implementation to the\r\nvariational solution of the quantum many-body problem. Projection algorithms are then introduced, beginning with a formulation in coordinate space for central potentials, in order to illustrate\r\nthe fundamental ideas. The extension to Hamiltonians with an explicit dependence on the spin-isospin degrees of freedom is then presented by making use of auxiliary fields (Auxiliary Field Diffusion Monte Carlo, AFDMC). Finally, we present the Configuration Interaction Monte Carlo algorithm (CIMC) a method to compute the ground state of general, local or non-local, Hamiltonians based on the configuration space sampling.}\r\n\r\n\\label{chapter:qmc}\r\n%\\maketile\r\n\r\n\r\n\\section{Monte Carlo methods in quantum many-body physics}\r\n\\subsection{Expectations in Quantum Mechanics}\r\nIn the previous chapters the authors pointed out in several different ways that the non-relativistic quantum many-body problem \r\nis equivalent to the solution of a very complicated differential equation, the many-body Schr\\\"odinger equation.\r\n\r\nAs it was illustrated, in the few-body case ($A<6$) it possible to find compute exact solutions. At the very least, one can expand the eigenfunctions on a basis set including $\\cal M$ elements,\r\ndiagonalize the Hamiltonian matrix, and try to reach convergence as a function of $\\cal M$. Unfortunately, this procedure becomes more and more expensive\r\nwhen the number of bodies $A$ increases. There are many ingenuous ways to improve the speed of convergence and the quality of the results. The price to pay often is the introduction of more or less controlled approximations.\r\n\r\nAll these approaches have one common feature: they end up with some closed expression for the eigenfunctions. However, we should remember that the wavefunction {\\it per se} is not an observable. In order to make predictions to be compared with experiments, we only need a way to compute {\\it expectations} of operators $\\hat{O}$ describing the observables we are interested in. \r\n\r\nGiven a many-body Hamiltonian $\\hat{H}$, we might want, for instance, to look for the ground state eigenfunction and eigenvalue. This means that we want to solve the following equation:\r\n\\begin{equation}\r\n\\label{eqchap9.s}\r\n\\hat{H}\\vert \\Psi_0\\rangle=E_0\\vert \\Psi_0\\rangle.\r\n\\end{equation}  \r\nAt this point we to provide a representation of the Hilbert space in term of some basis set.\r\nThis set will be denoted as $\\{|X\\rangle\\}$. Its elements could be eigenstates of the position\r\nor of the momentum operators, or eigenstates of a simpler Hamiltonian of which we know the exact spectrum. \r\nIn order to make the notation less cumbersome, we will assume that the quantum numbers $X$ characterizing the basis states are in the continuum. In the case of a discrete spectrum, integrals in the following have to be replaced by sums over all their possible values, without any loss of generality. As an example, $X$ could include the positions or the momenta of $A$ nucleons, and their spin and isospin values.  \r\n\r\nAll the physical information we need about the time-independent problem is then included in integrals of the form:\r\n\\begin{equation}\r\n\\langle O\\rangle \\equiv\\langle \\Psi_0\\vert\\hat{O}\\Psi_0\\rangle =\\frac{\\displaystyle\\int\\; dX dX'\\langle \\Psi_0\\vert X\\rangle\\langle X\\vert \\hat{O}\\vert X'\\rangle\\langle X'\\vert\\Psi_0\\rangle}\r\n{\\displaystyle\\int\\; dX \\vert\\langle X\\vert \\Psi_0\\rangle\\vert^2}.\r\n\\end{equation}\r\n\r\n\r\nThese integrals are apparently as hard to solve as the Schr\\\"odinger equation itself, even if we had access to the explicit form of the wavefunction. Is there any real gain in reformulating the problem this way?\r\n\r\nWe can first notice that expectations can in general be written in a slightly different form, independent of the nature of the operator $\\hat{O}$:\r\n\\begin{equation}\r\n\\langle O\\rangle =\\displaystyle\\frac{\\displaystyle\\int\\; dX \\vert \\langle X\\vert \\Psi_0\\rangle\\vert^2\\displaystyle\\displaystyle\\frac{\\langle X \\vert \\hat{O}\\Psi_0\\rangle}{\\langle X\\vert \\Psi_0\\rangle}}{\\displaystyle\\int\\; dX \\vert\\langle X \\vert \\Psi_0\\rangle \\vert^2}.\r\n\\end{equation}\r\nFor the moment we will just assume that the quotient appearing at numerator of the expectation is always well defined, and we will later discuss this aspect in more detail.\r\nThe standard quantum mechanical interpretation of the wavefunction tells us that the quantity:\r\n\\begin{equation}\r\nP[X]=\\frac{\\vert \\langle X\\vert \\Psi_0\\rangle\\vert^2}{\\displaystyle\\int\\; dX \\vert\\langle X \\vert \\Psi_0\\rangle \\vert^2},\r\n\\end{equation}  \r\nis the probability density of finding the system in the state $\\vert X \\rangle$ labeled by the set of quantum numbers $X$. Thereby, the expectation integral has the general form:\r\n\\begin{equation}\r\n\\langle O\\rangle =\\int\\; dX P[X]\\displaystyle\\frac{\\langle X \\vert \\hat{O}\\Psi_0\\rangle}{\\langle X\\vert \\Psi_0\\rangle},\r\n\\label{eq5}\r\n\\end{equation}\r\ni.e. the average of what we will call the {\\it local} operator $O_{loc}\\equiv \\frac{\\langle X \\vert \\hat{O}\\Psi_0\\rangle}{\\langle X\\vert \\Psi_0\\rangle}$ weighted with the probability of finding the system in a given state $\\vert X\\rangle$. \r\nIntegrals like that in Eq. (\\ref{eq5}) have a direct physical interpretation. In a measurement process what we would observe is essentially the result of a {\\it sampling process} of $P[X]$. The expectation of our operator is approximated by:\r\n\\begin{equation}\r\n\\langle O \\rangle \\simeq \\frac{1}{M}\\sum_{k=1}^M{O(X_k)},\r\n\\end{equation}\r\nwhere $M$ is the number of measurements performed, and $O(X_k)$ is a shorthand notation to \r\nindicate the value assumed by the observable $\\hat{O}$ in the state labeled by the quantum numbers $X_k$. The laws of statistics also give us a way of estimating a {\\it statistical} error on $\\langle O \\rangle$, and we know that the error decreases by increasing \r\nthe number of measurements. \r\n\r\nThere is here an important point to notice: in a physical measurement process we have {\\it no direct knowledge  of the wavefunction}, we just {\\it sample} its squared modulus! \r\n\r\nThis argument suggests that if we had a numerical way of sampling the squared modulus of a wavefunction, we could in principle compute expectations and make comparisons with experiments\r\nwithout needing an explicit expression of the wavefunction itself. Quantum Monte Carlo methods\r\naim exactly at solving the many-body Schr\\\"odinger equation by sampling its solutions, eventually\r\nwithout any need of an explicit analytical form.\r\n\r\nThe remainder of this chapter will be organized as follows. First we will discuss\r\nhow to perform calculations based on an accurate, explicit ansatz for the wavefunction of an $A$-body system interacting via a purely central potential, exploiting the variational principle of quantum mechanics (Variational Monte Carlo methods). Then we will discuss how to sample the exact ground state of the system by\r\nprojecting it out of an initial ansatz (Projection Monte Carlo methods). Finally, we will\r\nsee how these methods need to be extended when we are interested in studying Hamiltonians\r\nthat have an explicit dependence on the spin and isospin states of the particles, as it \r\nhappens for the modern interactions employed in nuclear physics.\r\n\r\n\\section{Variational wavefunctions and VMC for central potentials}\r\n\r\n\r\n\r\n\\subsection{Coordinate space formulation}\r\nAs previously discussed, we are in principle free to choose any representation of the Hilbert\r\nspace of the system we like, in order to compute expectations. The most convenient choice, for a system of particles interacting via a purely central potential, with no explicit dependence on the spin or isospin state, is to use the eigenstates of the\r\nposition operator. If $R={{\\bf r}_1,\\dots{\\bf r}_A}$ are the coordinates of the $A$ \r\n(identical)\\footnote{We will always refer to systems of identical particle throughout the text. The generalization to mixtures is normally straightforward, and it will not be discussed here.} particles of mass $m$ constituting the system, we have that:\r\n\\begin{equation}\r\n\\vert X\\rangle \\equiv \\vert R \\rangle\r\n\\end{equation}\r\nwith the normalization:\r\n\\begin{equation}\r\n\\langle R'\\vert R\\rangle = \\delta(R-R') \\,.\r\n\\end{equation}\r\nNotice that we are here considering a $3A$-dimensional Cartesian space, without decomposing it\r\nin the product of $A$ $3$-dimensional spaces. In this representation the wavefunction \r\nis simply given by:\r\n\\begin{equation}\r\n\\langle R\\vert\\Psi_0\\rangle \\equiv \\Psi_0(R)=\\Psi_0({\\bf r}_1,\\dots{\\bf r}_A).\r\n\\end{equation}\r\nThe Hamiltonian instead reads:\r\n\\begin{equation}\r\n\\hat{H}=\\sum_{i=1}^A \\frac{p_i^2}{2m}\r\n+V({\\bf r}_1,\\dots{\\bf r}_A),\r\n\\end{equation}\r\nor\r\n\\begin{equation}\r\n\\hat{H} = \\int dR \\vert R\\rangle\r\n\\left [\r\n-\\frac{\\hbar^2}{2m}\\sum_{i=1}^A \\nabla^2_i +V({\\bf r}_1,\\dots{\\bf r}_A)\r\n\\right ] \\langle R\\vert\\,,\r\n\\end{equation}\r\nwhere $V$ is the interparticle potential. \r\nSubstituting this form into Eq. (\\ref{eqchap9.s}), operating from the\r\nleft with $\\langle R\\vert$ gives the Schr\\\"odinger differential equation\r\n\\begin{equation}\r\n\\left [\r\n-\\frac{\\hbar^2}{2m}\\sum_{i=1}^A \\nabla^2_i +V({\\bf r}_1,\\dots{\\bf r}_A)\r\n\\right ] \\Psi_0(R) = E_0\\Psi_0(R) \\,.\r\n\\end{equation}\r\nWe will often use the same symbol for the Hilbert space operator\r\nand its differential form and write this simply as\r\n$\\hat H\\Psi_0(R)=E_0\\Psi_0(R)$; whether the\r\noperator or differential form is used can be discerned readily\r\nfrom context.\r\nIn this representation the states of the Hilbert space are sampled by sampling the particle\r\npositions from the squared modulus of the wavefunction $\\vert\\Psi_0(R)\\vert^2$. \r\n\r\n\\subsection{Variational principle and variational wavefunctions}\r\nAs already seen in the previous chapters, one of the possible ways to approximate\r\na solution of the many-body Schr\\\"odinger equation is to exploit the variational principle.\r\nGiven a {\\it trial state} $|\\Psi_T\\rangle$, the following inequality holds:\r\n\\begin{equation}\r\nE_T=\\frac{\\langle \\Psi_T\\vert \\hat{H}\\Psi_T\\rangle}{\\langle\\Psi_T\\vert\\Psi_T\\rangle}\\geq E_0,\r\n\\end{equation}\r\nwhere $E_0$ is the ground state eigenvalue of the Hamiltonian $\\hat{H}$. The equality holds\r\nif and only if $\\vert \\Psi_T\\rangle = \\vert \\Psi_0\\rangle$. The variational principle holds for the ground state, but also for excited states, provided that $\\vert \\Psi_T\\rangle$ is \r\northogonal to all the eigenstates having eigenvalue lower than that of the state one wants\r\nto approximate.\r\n\r\nIn coordinate space the formulation of the variational principle can be directly\r\ntransformed in a form equivalent to that of Eq. (\\ref{eq5}):\r\n\\begin{equation}\r\nE_T=  \\displaystyle\\frac{\\displaystyle\\int\\; dR \\vert \\Psi_T(R)\\vert^2\\displaystyle\\displaystyle\\frac{\\hat{H}\\Psi_T(R)}{ \\Psi_T(R)}}{\\displaystyle\\int\\; dR \\vert \\Psi_T(R) \\vert^2}\\geq E_0, \\label{eq911}\r\n\\end{equation}\r\nwhere $\\frac{\\hat{H}\\Psi_T(R)}{ \\Psi_T(R)}$ is called the {\\it local energy}. \r\nContrary to what happens in functional \r\nminimization approaches (such as the Hartree-Fock method), the variational \r\nprinciple is used to determine the best trial wavefunction within a class defined\r\nby some proper ansatz. The wavefunction will depend on a set of \r\n{\\it variational parameters} $\\{\\alpha\\}$. The solution of the variational problem\r\nwill therefore be given by the solution of the Euler problem:\r\n\\begin{equation}\r\n\\frac{\\delta E_T(\\{\\alpha \\})}{\\delta \\{\\alpha\\}}=0.\r\n\\end{equation} \r\nThis means that in order to find the variational solution to the Schr\\\"odinger problem we need to evaluate many times the integral of Eq.(\\ref{eq911}) using\r\ndifferent values of the variational parameters, and find the minimum trial eigenvalue. \r\n\\subsection{Monte Carlo evaluation of integrals}\r\nThe integral in Eq. (\\ref{eq911}) is in general defined in a $3A$-dimensional space. Since particles interact, we expect that the solution cannot be expressed as a product of single particle functions, and therefore the integral cannot be factorized in a product of simpler integrals. In this sense, the problem is strictly analogous to that of a classical gas at finite temperature $\\beta=1/{K_B T}$. In that case, given a classical Hamiltonian $H(p,q)=\\sum_{i=1}^{A}\\frac{p_i^2}{2m}+V(q_1\\dots q_A)$, the average energy of the system is given by:\r\n\\begin{equation}\r\nE=\\frac{3A}{2}K_B T+\\frac{1}{Z}\\int\\;dq_1\\cdots dq_A V(q_1\\cdots q_A)e^{-\\beta V(q_1\\cdots q_A)},\r\n\\end{equation}\r\nwhere \r\n\\begin{equation}\r\nZ\\equiv\\int\\;dq_1\\cdots dq_A e^{-\\beta V(q_1\\cdots q_A)}\r\n\\end{equation}\r\nis the {\\it configurational partition function} of the system. Also in this case the integral to be evaluated is of the same form as Eq. (\\ref{eq911}). We can distinguish in the integrand the product of a {\\it probability density}:\r\n\\begin{equation}\r\nP(q_1\\dots q_A)=\\frac{e^{-\\beta V(q_1\\cdots q_A)}}{Z},\r\n\\end{equation}\r\nand a function to be integrated which is the potential energy $V$. For classical systems we have a quite intuitive way of proceeding, which is at the basis of statistical mechanics. If we are able to compute (or measure) the potential for some given set of particle coordinates, and we average over many different configurations (sets of particle positions), we will obtain the estimate of the potential energy we need. \r\n\r\nThis fact can be easily formalized by making use of the Central Limit Theorem. Given a probability density $P[X]$ defined in a suitable event space $X$, let us consider an arbitrary function $F(X)$. One can define a stochastic variable:\r\n\\begin{equation}\r\nS_N(F)=\\frac{1}{N}\\sum_{i=1}^{N}F(X_i),\r\n\\end{equation}\r\nwhere the events $X_i$ are assumed to be {\\it statistically independent}, and are distributed according to $P[X]$. The stochastic variable $S_N(F)$ will in turn have its own probability density $P[S_N]$, which in general depends on the index $N$. The Central Limit Theorem states that for large $N$ the probability density $P[S_N]$ will be a Gaussian, namely:\r\n\\begin{equation}\r\n\\lim_{N\\rightarrow \\infty} P[S_N]=\\frac{1}{\\sqrt{2\\pi\\sigma^2_N(F)}}\\exp\\left\\{\\displaystyle-\\frac{(S_N-\\langle F\\rangle)^2}{2\\sigma^2_N(F)}\\right\\},\r\n\\end{equation}\r\nwhere we define the expectation of $F$ as:\r\n\\begin{equation}\r\n\\begin{split}\r\n&\\langle F\\rangle=\\int P[X]F(X)dX,\r\n\\\\\r\n&\\langle F^2\\rangle=\\int P[X]F^2(X)dX,\r\n\\end{split}\r\n\\end{equation}\r\nand\r\n\\begin{equation}\r\n\\sigma^2_N(F)=\\frac{1}{N}\\left[\\langle F^2\\rangle-\\langle F\\rangle^2\\right]\r\n\\end{equation}\r\nis the variance of the Gaussian.\r\nThe reported average is estimated as $S_N(F)$, while \r\n$\\langle F^2\\rangle-\\langle F\\rangle^2$ is estimated by\r\n$\\frac{N}{N-1}\\left [S_N(F^2)-S_N^2(F)\\right ]$.\r\nThis well known result is at the basis of all measurement theory. Averages over a set of measurements of a system provide the correct expectation of the measured quantity with an error that can be in turn estimated, and that decreases with the square root of the number of measurements $N$. \r\n\r\nThis result is very important from the point of view of numerical evaluation of integrals. If we had a way to numerically sample an arbitrary probability density $P[X]$, we could easily estimate integrals like that in Eq. (\\ref{eq911}). The statistical error associated with the estimate would decrease as the square root of the sampled points {\\it regardless of the dimensionality of the system}. \r\n\r\nFor a classical system, configurations might be generated by solving Newton's equations, possibly adding a thermostat in order to be consistent with the canonical averaging. However, this is not certainly possible for a quantum system. The solution is to use an artificial dynamics, provided that it generates (at least in some limit) configurations that are distributed according to the probability density we want to use. Once again, in order to simplify the following description we will work in the space of the coordinates of the $A$ particles, but the argument can be generalized to arbitrary spaces.\r\n\r\nA very detailed description of what follows in this section can be found in the book of Kalos and Whitlock\\cite{Kalos08} and references therein. \r\n\r\nWe start defining a {\\it transition matrix} $T_k(R_{k+1}\\leftarrow R_k)$ expressing the probability that in the $k$-th step of the dynamics the system moves from the configuration $R$ to a configuration $R'$. If at the first step the system is in a configuration $R_0$, sampled from an arbitrary distribution $P_0[R_0]$, the probability density of finding the system in a configuration $R_1$ at the next step will be given by:\r\n\\begin{equation}\r\nP_1[R_1] = \\int\\; dR_0 P_0[R_0]T_0(R_1\\leftarrow R_0).\r\n\\end{equation}\r\nWe the introduce an integral operator $\\hat{T}_0$ such that:\r\n\\begin{equation}\r\nP_1[R_1]=\\hat{T}_0 P[R_0].\r\n\\end{equation}\r\nWith this notation, the probability density of the configuration at an\r\narbitrary step $k$ will become:\r\n\\begin{equation}\r\nP_k[R_k]=\\hat{T}_{k-1} P[R_{k-1}]=\\hat{T}_{k-1}\\cdots\\hat{T}_{1}\r\n\\hat{T}_{0} P_0[R_0].\r\n\\end{equation}\r\nThe sequence of stochastic variables $R_k$ generated at each step of this procedure is called a {\\it Markov Chain}. Let us assume that $\\hat{T}_k$ does not depend on the index $k$. What we will generate is then a {\\it stationary} Markov Chain, for which the probability density generated at each step will only depend on the transition matrix and the probability density of the first element. In fact:\r\n\\begin{equation}\r\nP_k[R_k]=\\hat{T} P[R_{k-1}]=\\hat{T}\\cdots\\hat{T}\r\n\\hat{T} P_0[R_0]=\\hat{T}^kP_0[R_0].\r\n\\end{equation}\r\nUnder these assumptions one might wonder if the sequence is convergent (in functional sense), i.e. if a limiting probability density $P_\\infty[R]$ exists. It is interesting to notice that if such function exists, it has to be an eigenvector of the integral operator $\\hat{T}$. In fact, since we assume $\\hat{T}$ to be independent of $k$ we have:\r\n\\begin{eqnarray}\r\n\\begin{array}{rcl}\r\n\\lim_{k\\rightarrow\\infty}\\hat{T}P_k[R_k]&=&\\lim_{k\\rightarrow\\infty}P_{k+1}[R_{k+1}]\\nonumber\\\\\r\n\\\\\r\n\\hat{T}P_\\infty[R]&=&P_\\infty[R]\\nonumber.\r\n\\end{array}\r\n\\end{eqnarray}\r\nIt is also easy to realize that the eigenvalue is indeed 1. In fact, let us consider the general relation:\r\n\\begin{equation}\r\n\\hat{T}P_\\infty[R]=\\gamma P_\\infty[R].\r\n\\end{equation}\r\nThe recursive application of $\\hat{T}$ would give:\r\n\\begin{equation}\r\n\\hat{T}^k P_\\infty[R]=\\gamma^kP_\\infty[R].\r\n\\end{equation}\r\nIf $\\gamma\\neq 1$ we would lose the normalization property of $P\\infty[R]$.\r\n\r\nThese properties of stationary Markov chains can be exploited to sample a generic probability density $P[R]$. In fact, if we can determine the transition operator that has as eigenvector a {\\em given} $P_\\infty[R]$, a repeated application of such operator to an {\\em arbitrary} initial distribution of points will eventually generate a chain in which each element is distributed according to $P_\\infty[R]$. There is a simple recipe to construct such transition operator. We will assume that we have at hand a transition operator $\\hat{\\bar{T}}$ that we can sample (it could be as simple as a uniform probability within a given volume). We will split the searched transition operator\r\nin the product of $\\hat{\\bar{T}}$ and an unknown factor $\\hat{A}$ that we will call \"acceptance probability\", defined in such a way that:\r\n\\begin{equation}\r\n\\hat{\\bar{T}}\\hat{A}=\\hat{T}.\r\n\\end{equation}\r\n\r\nIn order for the system to preserve its equilibrium state once the probability\r\ndistribution is reached, we expect that the dynamics described by the random walk will not change the density of sampled points anywhere in the events space.  Transitions carrying away from a state $R$ to anywhere must be balanced by transitions leading from anywhere to the same state $R$:\r\n\\begin{equation}\r\n\\label{equilibrium}\r\n\\int dR' P(R)T(R'\\leftarrow R)= \\int dR' P(R')T(R\\leftarrow R') \\,.\r\n\\end{equation}\r\nOne way to enforce this condition is to impose the more\r\nstringent {\\it detailed balance} condition, which requires the {\\it integrands} in  Eq.(\\ref{equilibrium}) be equal:\r\n\\begin{equation}\r\nP(R)T(R'\\leftarrow R)=P(R')T(R\\leftarrow R') \\,.\r\n\\end{equation}\r\nThe detailed balance condition can be in turn recast into a requirement on the acceptance probability. In fact:\r\n\\begin{equation}\r\n\\frac{A(R'\\leftarrow R)}{A(R\\leftarrow R')}=\\frac{P(R')}{P(R)}\\frac{\\bar{T}(R\\leftarrow R')}{\\bar{T}(R'\\leftarrow R)}.\r\n\\label{detb2}\r\n\\end{equation} \r\nThe quantities on the r.h.s. of Eq. (\\ref{detb2}) are all known. The configuration $R'$ has to be sampled originating in $R$ from the given transition probability $\\bar{T}(R\\leftarrow R')$. The probability density $P(R)$ is the one we actually want to asymptotically sample. \r\nIf we interpret the $A$ values to be probabilities to actually keep the transition, then maximizing the possible $A$ values leads to the slightly modified version of Eq. (\\ref{detb2}):\r\n\\begin{equation}\r\nA(R'\\leftarrow R)=\\min\\left(\\frac{P(R')}{P(R)}\\frac{\\bar{T}(R\\leftarrow R')}{\\bar{T}(R'\\leftarrow R)},1\\right).\r\n\\end{equation} \r\nThis expression is often called the {\\it acceptance ratio}. In practice, it represents the probability according\r\nto which we have to {\\it accept} the new configuration as the new member of the Markov chain, rather than\r\nkeeping the original point as the next point in the chain.\\footnote{The standard jargon refers to this as a \"rejection\" event. However one has not to be confused: this is the result of a {\\it reversed} move, and generates a new element in the chain coincident with the starting point.}.\r\nFurther analysis shows that existence and uniqueness of the correct eigenvalue\r\n1 solution and therfore convergence to the correct distribution\r\nwill be guaranteed if (1) every allowed state can be reached\r\nfrom any other by a finite sequence of transitions and (2)\r\nthere are no cycle of states. The latter is guaranteed if there are\r\nany transitions that leave the system in the same state, that is any rejections.\r\n\r\nThere is a case in which the Eq. (\\ref{detb2}) further simplifies. If the transition matrix is taken to \r\nbe symmetric in the arguments $R$ and $R'$, the ratio becomes unity, and one is left with:\r\n\\begin{equation}\r\nA(R'\\leftarrow R)=\\min\\left(\\frac{P(R')}{P(R)},1\\right).\r\n\\end{equation} \r\nAt this point we have all the ingredients to describe an algorithm that performs a Monte Carlo evaluation\r\nof an integral such that of Eq. (\\ref{eq911}). In the following we will describe the simplest version,\r\ni.e. the so called \"Metropolis-Hastings algorithm\"~\\cite{Metropolis53,Hastings70}. \r\n\\begin{enumerate}\r\n\t\\item\r\n\tStart from an arbitrary configuration of the $A$ particles. If the potential has a strongly repulsive core one has to pay attention to avoid overlapping pairs.\r\n\t\\item\r\n\tSweep over the coordinates and generate new positions according to some transition probability. A simple choice is a uniform displacement within a cube of side $\\Delta$, i.e.:\r\n\t\\begin{equation}\r\n\t  \\bar{T}(R'\\leftarrow R)=\\left\\{ \r\n\t  \\begin{array}{cl}\r\n\t  \\frac{1}{\\Delta}&{\\rm if \\ \\ \\  } |R'^\\alpha_i-R^\\alpha_i|<\\frac{\\Delta}{2}\\\\\r\n\t  \\\\\r\n\t  0&{\\rm otherwise}\r\n\t  \\end{array}\r\n\t     \\right.\r\n\t\\end{equation}\r\n\twith $\\alpha =x,y,z$, and $i=1\\dots A$. This choice has the advantage of being symmetric. If we imagine\r\n\tto store our configuration in an array $R[0...2][0...A-1]$ the implementation of this step would read:\r\n\\begin{svgraybox}\r\n\t\\begin{algorithmic} \r\n\t\t\\State{MC\\_Move()}\r\n\t\t\\For{$i \\in \\{0,A-1\\}$}  \r\n\t\t\\For{$j \\in \\{0,2\\}$ }\r\n\t        \\State{$R_{new}[i][j]\\gets R[i][j]+(\\text{rand}()-0.5)*\\Delta$}\r\n\t\t\\EndFor\r\n\t\t\\EndFor\r\n\t\\end{algorithmic}\r\n\\end{svgraybox}\r\n    We will assume that the function ${\\rm rand}()$ generates a random number uniformly distributed\r\n    in $[0,1)$.\r\n    \\item \r\n    At this point we need to evaluate the acceptance ratio. This is easily done with our choice of the transition matrix, since we only need to evaluate the probability densities in $R$ and $R'$:\r\n    \\begin{equation}\r\n    A(R'\\leftarrow R)=\\min\\left(\\frac{|\\Psi_T(R')|^2}{|\\Psi_T(R)|^2},1\\right).\r\n    \\end{equation}\r\n    \\item\r\n    Next we need to decide whether we keep the proposed configuration as the next element in the chain or if we want to resort to the original one. If we define ${\\rm acc} = A(R'\\leftarrow R)$, then:\r\n\\begin{svgraybox}\r\n    \t\\begin{algorithmic} \r\n    \t\t\\State{Accept\\_reject()}\r\n    \t\t\\State{$\\xi = \\text{rand}()$}\r\n    \t\t\\If{$\\text{acc} > \\xi$}\r\n\t    \t\t\\State{$R[i][j]\\gets R_{new}[i][j]$}\r\n    \t\t\\EndIf\r\n    \t\\end{algorithmic}\r\n\\end{svgraybox}\r\n    \t\\item\r\n    \tAccording to the Central Limit Theorem, we now need to cumulate the values of the rest of the integrand. In the case of our variational calculation we need to sum up the local energies.\r\n    \tNotice that this step has to be taken whatever the result of the procedure described at the previous point. If we want to estimate the statistical error, we also need to cumulate the {\\it square}\r\n    \tof the local energy. \r\n\\begin{svgraybox}\r\n    \t\\begin{algorithmic} \r\n    \t   \\State{Acuest()}\r\n    \t   \\State{$\\text{eloc}\\gets \\frac{\\hat{H}\\Psi_T(R)}{\\Psi_T(R)}$}\r\n    \t   \\State{$\\text{ecum}\\gets \\text{ecum} + \\text{eloc}$}\r\n    \t   \\State{$\\text{ecum2}\\gets \\text{ecum2} + \\text{eloc}*\\text{eloc}$}\r\n    \t   \\end{algorithmic}\r\n\\end{svgraybox}\r\n    \t\\item\r\n    \tSteps 2 to 5 need to be repeated $N_{steps}$ times, where $N_{steps}$ must be sufficiently large to provide a small enough statistical error. The final estimate of the energy is given by\r\n    \t$\\langle E\\rangle \\pm \\Delta E$, where:\r\n    \t\\begin{eqnarray}\r\n    \t\\begin{array}{c}\r\n    \t\\langle E\\rangle = \\frac{1}{N_{steps}}\\cdot\\text{ecum}\\\\\r\n    \t\\\\ \r\n    \t\\Delta E = \\sqrt{\\frac{1}{N_{steps}-1}\\left(\\frac{1}{N_{steps}}\\cdot\\text{ecum2}-\\langle E\\rangle^2\\right)}\r\n    \t\\end{array}\r\n    \t\\end{eqnarray}\r\n  \\end{enumerate}\r\n  Notice that this algorithm could in principle be used to evaluate arbitrary integrals. In fact, it is\r\n  always possible to multiply and divide the integrand by a probability density $P(X)$ that can be used\r\n  to sample the values of $X$:\r\n  \\begin{equation}\r\n  I=\\int F(X) dX = \\int P[X]\\frac{F(X)}{P[X]}\r\n  \\end{equation}\r\n  \\subsubsection{Autocorrelations}\r\n  The main hypothesis underlying the Central Limit Theorem is that data used to construct the averages are sampled independently. While in a measurement process this is a quite reasonable assumption, in the case of the computation of an integral by means of any method based on the Markov chain theory (including the Metropolis-Hastings method) this requirement is not satisfied by construction. In fact, data are sampled based on a transition matrix, and the resulting random walk has a certain degree of memory of the past events. What are the consequences of such memory? Let us consider a sequence of points $X_1,X_2,\\cdots,X_N$ sampled via the Metropolis algorithm from some probability density $P[X]$. If we assume these data not to be independent, we have to consider the joint probability for the specific realization of the chain in order to estimate the integral of a given function $F$:\r\n  \\begin{equation}\r\n  I = \\frac{1}{N}\\sum_{i=1}^{N}\\int dX_1,dX_2,\\cdots dX_N P[X_1,X_2,\\cdots X_N]F(X_i).\r\n  \\end{equation}  \r\n  If the samples are independent then $P[X_1,X_2,\\cdots X_N]=P[X_1]P[X_2]\\cdots P[X_N]$, and we are in the case previously discussed. However, since we can arbitrarily exchange the indexes of the integration variables, we can easily see that the value of $I$ is unchanged despite the presence of correlations.\r\n  By construction,  in a Markov process two consecutive samples will always be correlated to each other. This seems to be inconsistent to the use we want to make of these samples, i.e. to apply the Central Limit Theorem to integration. However, we can hope that after a certain number of steps memory is lost, and data will become effectively independent.\r\n  Is it possible to estimate this typical {\\it autocorrelation length}?\r\n  Based on the previous argument one can define a measure of the autocorrelation by looking at the variance of the expectation of $F$ with respect to $P$: \r\n  \\begin{equation}\r\n   (\\Delta I)^2=\\left \\langle \\displaystyle\\frac{1}{N^2}\\sum_{i=1}^N F(X_i)\\sum_{i=1}^N F(X_j)\\right \\rangle-\\langle F\\rangle^2.\r\n  \\end{equation}\r\n  The corresponding standard deviation  is the estimate of the statistical error on the integral of $F$. The first term can be recast in the following way:\r\n  \\begin{eqnarray}\r\n  \\begin{array}{c}\r\n\\left  \\langle \\displaystyle\\frac{1}{N^2}\\sum_{i=1}^N F(X_i)\\sum_{i=1}^N F(X_j)\\right \\rangle=\\\\ \\\\\r\n  \\displaystyle \\frac{1}{N^2}\\sum_{i,j=1}^N\\int P[X_1,X_2,\\cdots X_N]F(X_i)F(X_j)dX_1\\cdots dX_N=\\\\ \\\\\r\n  \\displaystyle \\frac{1}{N^2}\\sum_{i,j=1}^N \\langle F(X_i)F(X_j)\\rangle.\r\n  \\end{array}\r\n  \\end{eqnarray}\r\n  Since the Markov chain is stationary, this quantity is expected to depend only on the difference of the indexes $\\tau=i-j$. We will then define an {\\it autocorrelation coefficient}:\r\n  \\begin{equation}\r\n  c(F)_\\tau =\\frac{\\langle F(X_i)F(X_{i+\\tau})\\rangle - \\langle F\\rangle^2}{\\langle F^2\\rangle - \\langle F\\rangle^2}.\r\n  \\end{equation}\r\n  The coefficient is normalized to the variance  $\\sigma^2(F)$, in such a way that $C(F)_0=1$. Correlation coefficients are related to the average of the product of the $F$ in the following way:\r\n  \\begin{equation}\r\n  \\langle F(X_i)F(X_{i+\\tau})\\rangle=c(F)_\\tau\\sigma^2(F)+\\langle F\\rangle^2.\r\n  \\end{equation} \r\n  We can use the previous expression to estimate the error on $I$:\r\n  \\begin{eqnarray}\r\n  \\begin{array}{c}\r\n  (\\Delta I)^2 = \\displaystyle\\frac{1}{N^2}\\sum_{i,j=1}^N \\langle F(X_i)F(X_j)\\rangle-\\langle F\\rangle^2=\\\\ \\\\ \r\n  \\displaystyle\\frac{1}{N}\\sigma^2(F)\\sum_{\\tau=1}^N c(F)_\\tau +\\langle F\\rangle^2-\\langle F\\rangle^2= \\frac{\\sigma^2(F)}{N}\\sum_{\\tau=1}^N c(F)_\\tau.\r\n  \\displaystyle \r\n  \\end{array}\r\n  \\end{eqnarray}\r\nAs it can be seen the error not only depends on the variance of $F$, but also on the sum over all the autocorrelation coefficients of $F$. This is the main consequence of having autocorrelated samples: the statistical error is underestimated by the variance of $F$, and needs to be corrected by a factor that depends on the autocorrelation length. \r\n\r\nUsually the coefficients $c(F)_\\tau$ have an exponential decay. If we approximate them as \r\n$c(F)_\\tau \\sim \\exp(-\\tau/{\\bar{\\tau}})$, the sum of the coefficients can be approximated as:\r\n\\begin{equation}\r\n\\sum_{\\tau=1}^{N}c(F)_\\tau\\sim\\int_{0}^{\\infty} d\\tau e^{-\\frac{\\tau}{\\bar{\\tau}}}=\\bar{\\tau}.\r\n\\end{equation}\r\nThis means that it is sufficient to fit the exponential decay of the autocorrelation coefficients in order to find an estimate of the characteristic autocorrelation length that corrects the estimate of the error on the integral. In particular the correct expression for the error is:\r\n\\begin{equation}\r\n\\Delta I\\simeq\\sqrt{\\frac{1}{N-1}\\sigma^2(F)\\bar{\\tau}},\r\n\\end{equation}\r\nwhich has a simple interpretation: We are not generating $N$ independent samples of the variable $X$ during our Markov process, but rather $N/\\bar{\\tau}$ of them, and this number must be used as the correct count of events for the error estimation.\r\n\r\nIt is important to be extremely careful about the estimation of autocorrelations. in many cases an underestimation of the statistical errors leads to a wrong interpretation of the results and to wrong physical conclusions.\r\n\r\nAutocorrelations also play a crucial role in choosing the step width $\\Delta$ in the Metropolis-Hastings algorithm. A common criterion is to choose it in such a way that the fraction of accepted moves is about 50\\%. However, the ideal value is clearly the one minimizing the autocorrelations among samples, and quite often this value corresponds to acceptances of the order 30 or 40\\%. \r\n\r\nOnce the value of $\\bar{\\tau}$ has been estimated, it is possible to organize the calculation in such a way that the statistical error computed by the code is more realistic by using a {\\it reblocking}\r\ntechnique. In practice the values of the quantity to be averaged are summed up in blocks of $N_b$ elements each:\r\n\\begin{equation}\r\nF^b_l=\\sum_{i=1}^{N_b} F(X_i).\r\n\\end{equation} \r\nThen, the $F^b_l$ are used as the data on which performing the computation of the variance and of the standard deviation. If $N_b\\gtrsim\\bar{\\tau}$, the standard deviation will be corrected by the effects of the autocorrelation of the original data.\r\nTypically calculations store block values so that the values can be\r\n``reblocked'' for example by combining pairs of blocks. The estimated\r\nerror should be unchanged if the blocks are uncorrelated. In addition,\r\nthe ratio of\r\nthe block variance to the variance of the original\r\nfunction can be used to estimate the number of independent saqmples,\r\nand therefore the autocorrelation time.\r\n\r\n\\subsection{Construction of the wavefunction and computational procedures}\r\n\r\nWhen performing a variational calculation, the first step consists of deciding which model wavefunction we intend to use. \r\n\r\nFirst of all we have to take care of the symmetry of the particles. Nucleons are Fermions, and therefore it is necessary to build an antisymmetric wavefunction. If the Hamiltonian does not contain terms acting on the spin or isospin state of a nucleon or of a pair of nucleons, each particle will preserve its own initial state. In this case it is easy to write an antisymmetric wavefunction simply using a product of Slater determinants, one for each species. \r\n\r\nTo build the determinants one needs some single particle orbitals. There are several possible choices. For nuclei linear combinations of Gaussians or the eigenstates of the harmonic oscillator are definitely an option. Another choice might be that of using orbitals coming from a Hartree-Fock calculation. In this case the orbitals contain some information about the fact that nucleons interact, but there usually is no consistency between the Hamiltonian used to compute the orbitals and the Hamiltonian we are interested in.\r\n\r\nThe basic starting point is then a wavefunction of the form:\r\n\\begin{equation}\r\n\\varphi(R)=\\text{det}[\\phi_j({\\bf r}_{p^\\uparrow_i})]\\text{det}[\\phi_j({\\bf  r}_{p^\\downarrow_i})]\\text{det}[\\phi_j({\\bf r}_{n^\\uparrow_i})]\\text{det}[\\phi_j({\\bf r}_{n^\\downarrow_i})],\r\n\\end{equation}\r\nIf we just limited ourselves to this kind of wavefunction we would miss most of the interesting physics that happens when particles are close together. A seen in the previous chapters, a very important role is played by the {\\it short range correlations}, that should introduce the many-body effects due to repulsion/attraction of particles at short distance. Contrarily to what one does in other methods, such as coupled clusters, in Quantum Monte Carlo calculations it is easier to work with wavefunctions containing {\\it explicit} two-, three- or many-body correlations. \r\n\r\nHere we will use the so-called {\\it Jastrow} factor, i.e. a product of two-body functions  that helps to reproduce the correlations from the pair-wise potential. The simplest version of a trial wavefunction therefore reads:\r\n\\begin{equation}\r\n\\Psi_T(R)=\\varphi(R)\\prod_{i<j}^Af(r_{ij}),\r\n\\end{equation}\r\nwhere $R=({\\bf r_1,\\cdots,r_A})$, and $f$ is the so called {\\it Jastrow function} (JF). How do we determine the JF? We have some information that we can exploit. In particular we might seek for analytic forms of $f$ that satisfy what is commonly called the {\\it cusp condition},(see e.g. Ref.\\cite{Cep77}) i.e. we must have:\r\n\\begin{equation}\r\n\\frac{\\hat{H}f(r_{ij})}{f(r_{ij})}<\\infty\r\n\\end{equation}\r\neverywhere in space. It is easy to realize that satisfying the cusp condition helps to prevent the local energy from fluctuating too much even in presence of a divergence of the potential, thereby reducing the variance and the statistical error. Usually in nuclear physics problems it is customary to take a further step.\r\nRecognizing that at small separations, the many-body Schr\\\"odinger equation\r\nis dominated by the short-range pair potential,\r\nthe two-body problem is solved to determine the $f$. In particular one can solve the following Schr\\\"odinger equation in relative coordinates:\r\n\\begin{equation}\r\n\\label{EqJas}\r\n-\\frac{\\hbar^2}{2m}\\nabla^2+qV(r)f(r)=\\epsilon f(r),\r\n\\end{equation}\r\nand impose the boundary condition that the function becomes a constant at a distance $h$ from the origin, where other parts of the Hamiltonian become important.  The quantities $q$ and $h$ are two variational parameters. One could in principle consider a third variational parameter in the Jastrow factor by using a modified Jastrow function $\\tilde{f}$ such that:\\begin{equation}\r\n\\tilde{f}(r)=e^{-b\\log f(r_{ij})}\r\n\\end{equation}\r\nThe function $f$ is usually determined by numerically solving Eq.(\\ref{EqJas}) with the Numerov or Runge-Kutta methods. One has to be careful that the resulting table has to be interpolated to compute the function at an arbitrary distance. Therefore it is important to choose an appropriate number of points (usually of the order of a few thousands).  \r\n\\begin{figure}\r\n\t\\\r\n\\end{figure}\r\nSingle particle orbitals can also be either tabulated or computed analytically. Tabulation guarantees in general a faster computation at the price of a loss in numerical accuracy.\r\n\r\nIn the code it is necessary to compute derivatives of the wavefunction in order to estimate the local energy. This can be done either numerically or analytically. A very good test for checking that there are no major mistakes either in the Monte Carlo evaluation of integrals or in the computation of the local energy is to use the so-called {\\it Jackson-Feenberg} identity for the kinetic energy.\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/qvar.eps}\r\n\t\\end{center}\r\n\t\\caption{An example of variational minimization of the energy. The estimate of the binding energy of a $^4$He nucleus described by the Minnesota potential is here plotted as a function of the quencher parameter $q$, for a fixed value of the healing distance $h$ (see text). The dotted line serves as a guide for the eye.}\r\n\t\\label{fig.var}\r\n\\end{figure}\r\nThe expectation of the kinetic energy is an integral of the form:\r\n\\begin{equation}\r\n\\label{T_PB}\r\n\\langle T\\rangle = \\frac{\\displaystyle-\\frac{\\hbar^2}{2m}\\int_\\Omega dR \\Psi^*(R)\\nabla^2\\Psi(R)}{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2},\r\n\\end{equation}\r\nwhere $\\Omega$ is the integration volume. Integrating the numerator by parts one gets:\r\n\\begin{equation}\r\n\\langle T\\rangle = \\frac{\\displaystyle\\frac{\\hbar^2}{2m}\\int_\\Omega dR \\nabla\\Psi^*(R)\\cdot\\nabla\\Psi(R)}{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2} -\\frac{\\displaystyle\\frac{\\hbar^2}{2m}\\int_{S(\\Omega)} dS\\Psi^*(R)\\nabla\\Psi(R) }{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2}.\r\n\\end{equation}\r\nThe surface term is zero if the wavefunction is well behaved. We are therefore left with the integral:\r\n\\begin{equation}\r\n\\label{T_JF1}\r\n\\langle T\\rangle = \\frac{\\displaystyle\\frac{\\hbar^2}{2m}\\int_\\Omega dR \\nabla\\Psi^*(R)\\nabla\\Psi(R)}{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2}= \\frac{\r\n\t\\displaystyle\\frac{\\hbar^2}{2m}\\int_\\Omega dR|\\Psi(R)|^2 \\frac{\\nabla\\Psi(R)}{\\Psi(R)}\\cdot\r\n\\frac{\\nabla\\Psi^*(R)}{\\Psi^*(R)}\r\n}{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2}.\r\n\\end{equation}\r\nWe can sum Eq.(\\ref{T_PB}) and Eq. (\\ref{T_JF1}), and divide by 2 in order to obtain a new kinetic energy estimator:\r\n\\begin{equation}\r\n\\langle T\\rangle_{JF} = \\frac{\r\n\t\\displaystyle\\frac{\\hbar^2}{4m}\\int_\\Omega dR|\\Psi(R)|^2 \\left[\\frac{\\nabla\\Psi^*(R)}{\\Psi^*(R)}\\cdot\r\n\t\\frac{\\nabla\\Psi(R)}{\\Psi(R)}-\\frac{\\nabla^2\\Psi(R)}{\\Psi(R)}\\right]\r\n}{\\displaystyle\\int_\\Omega dR |\\Psi(R)|^2}.\r\n\\end{equation}\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/jas.eps}\r\n\t\\end{center}\r\n\t\\caption{The central channel of the Minnesota potential (dashed-dotted line), and the corresponding numerical Jastrow function (solid line) evaluated for $h=3.1$, $q=1.4$, and $b=1$.}\r\n\\end{figure}\r\nThis is the {\\it Jackson-Feenberg} kinetic energy estimator. It is easy to see that configuration by configuration the value of the integrand of $T$ and $T_{JF}$ are different. However, they have to be the same on average (i.e. always within the current statistical error). The equivalence of the two estimators checks the integration procedure, the correctness of the implementation of the boundary conditions, and the computation of derivatives. If any of these quantities are wrong, the two estimates of the kinetic energy will differ. This is an extremely useful consistency check, and should always be used in a variational calculation.\r\n\r\nAt this point it is necessary to perform several calculations varying the parameters in the wavefunction, and looking for a minimum of the energy. In the next subsection we will describe algorithms that allow for performing this search in an automatic way. However, when the number of parameters is small, it is also possible in principle to perform a scan on a grid. \r\n\r\nIn Fig.\\ref{fig.var}, as an example, we report the behavior of the variational energy computed in a $^4$He nucleus, modeled with a two body Minnesota potential, and a wavefunction containing only a central Jastrow product. The spatial part of the orbital is an s-wave Gaussian with half width equal to 1.1fm. The energies have been computed for a fixed value of the healing distance $h=3.1$fm as a function of the quencher parameter $q$, keeping fixed the amplitude parameter $b=1$. Each run consists of an average over 6.4$\\times 10^5$ samples, preceded by $6.4\\times 10^4$ equilibration steps. \r\n\r\nAs it can be seen, there is a clear minimum of the energy. \r\nThe minimum can be determined with sufficient accuracy by fitting the resulting curve. A fit with a quadratic function predicts a minimum at $q\\sim1.4$. The corresponding eigenvalue is $E_T=-15.31(4)$MeV\\footnote{the number in parenthesis indicates the statistical error on the last figure}. The procedure should be repeated for different values of all other variational parameters until an absolute minimum is found. \r\n\r\nThe variational wavefunctions can be made arbitrarily richer in structure in order to improve the results, including what our physical intuition suggests as important terms to describe correlations. We will later discuss how to construct trial wavefunctions for realistic nuclear Hamiltonians.\r\nA full variational calculation for the $^4$He nucleus with the Minnesota potential, including Jastrow factors with a spin/isospin dependence would give a binding energy $E_T=-25.52(4)$MeV.\r\n\r\n \r\n\r\n\\subsection{Wave function optimization}\r\n\\subsubsection{Reweighting methods}\r\nThe brute-force optimization of the trial wave function becomes quite cumbersome with more than a few parameters. In general the problem is equivalent to searching an absolute minimum in a multi-dimensional space, and does not admit a simple solution.\r\nIf one is interested in a quick search for local minima, it is possible to compute the gradient of the energy in the parameter space, and use for instance some variant of the steepest descent method. Computation of gradients is based on the so-called ``reweighting method''. If we have a trial function depending on a set of parameters $\\{\\alpha\\}$, and another depending on a set $\\{\\alpha+\\delta\\alpha\\}$, it s not necessary to perform two independent calculations to compute the difference (which would also be affected by rather large statistical errors). In fact, the following identity holds):\r\n\\begin{equation}\r\n\\frac{\\int dR |\\Psi_T(R,\\{\\alpha+\\delta\\alpha\\})|^2 O(R)}{\\int dR |\\Psi_T(R,\\{\\alpha+\\delta\\alpha\\})|^2}=\r\n\\frac{\\int dR |\\Psi_T(R,\\{\\alpha\\})|^2 \\frac{|\\Psi_T(R,\\{\\alpha+\\delta\\alpha\\}|^2}{|\\Psi_T(R,\\{\\alpha\\})|^2}O(R)}{\\int dR |\\Psi_T(R,\\{\\alpha\\})|^2\\frac{|\\Psi_T(R,\\{\\alpha+\\delta\\alpha\\})|^2}{|\\Psi_T(R,\\{\\alpha+\\delta\\alpha\\})|^2}}\r\n\\end{equation}\r\nIt is therefore possible to use the configurations sampled from a trial wavefunction with a given parametrization $\\{\\alpha\\}$ to compute expectations over a wavefunction with a different parametrization $\\{\\alpha+\\delta\\alpha\\}$ by simply reweighting the values of the operator with the ration between the square moduli of the two wavefunctions:\r\n\\begin{equation}\r\n\\langle O_{\\{\\alpha+\\delta\\alpha\\}}\\rangle\\equiv\r\n\\frac{\\langle \\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\})|O(R_k)|\\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\})\\rangle}{\\langle \\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\})|\\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\})\\rangle}=\r\n\\frac{\\sum_k \\frac{|\\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\}|^2}{|\\Psi_T(R_k,\\{\\alpha\\}|^2}O(R_k)}{\\sum_k \\frac{|\\Psi_T(R_k,\\{\\alpha+\\delta\\alpha\\}|^2}{|\\Psi_T(R_k,\\{\\alpha\\}|^2}}\r\n\\end{equation}\r\nwhere the $R_k$ are sampled from $|\\Psi_T(R,\\{\\alpha\\})|^2$. Besides the obvious advantage of avoiding multiple calculations to compute the derivatives, the use of this reweighting technique allows direct computation of expectations of the gradients in the parameter space with very high accuracy. The access to gradients opens the way to the use of automated minimization algorithms such as the already mentioned steepest descent method, the Levemberg-Marquardt algorithm \\cite{Cyrus96} or the Linear Method \\cite{Toulouse07} briefly sketched below \r\n\r\n\\subsubsection{Power method}\r\n\\label{sec:pm}\r\nThere is another class of algorithms that have been recently introduced, and based on the power method. We will here discuss in particular the algorithm due to Sandro Sorella~\\cite{Sorella01}.\r\nThis algorithm was originally discussed in terms of\r\nthe Lanczos method, but for\r\na single multiplication by his propagator it\r\nbecomes equivalent to the simpler power method that we discuss here.\r\n\r\nFor $\\Lambda$ larger than the largest eigenvalue of the\r\neigenvectors contained in $|\\psi_n\\rangle$, operating\r\nwith $\\Lambda -H$ will multiply the ground state by a larger number\r\nthan any other state. Therefore iterating the equation\r\n\\begin{equation}\r\n|\\psi_{n+1}\\rangle = (\\Lambda-H)|\\psi_n\\rangle\r\n\\end{equation}\r\nwill converge to the ground state.\r\nOne way to implement this is to use a set of test functions (which, in\r\nprinciple, should be complete), $|\\phi_m\\rangle$. This gives the\r\nset of equations\r\n\\begin{equation}\r\n\\label{eq.power}\r\n\\langle \\phi_m |\\psi_{n+1}\\rangle = \\langle \\phi_m |(\\Lambda -H)|\\psi_n\\rangle\r\n\\,.\r\n\\end{equation}\r\n\r\n\r\nIn his original paper Sorella assumes $|\\psi_n \\rangle = |\\Psi_T\\rangle$, and next approximates\r\n$|\\psi_{n+1}\\rangle$ as a linear combination of the original state\r\nand the derivatives with respect to the parameters\r\n\\begin{eqnarray}\r\n\\label{eq:psiprime}\r\n|\\psi_{n+1}\\rangle &\\simeq& \\Delta \\alpha_0 |\\Psi_T\\rangle\r\n+\\sum_{n=1} \\Delta \\alpha_n \\partial_{\\alpha_n} |\\psi_T\\rangle\r\n\\equiv \\sum_{n=0} O^n |\\psi_T\\rangle \\Delta \\alpha_n\r\n\\end{eqnarray}\r\nand he uses the same functions for $|\\phi_m\\rangle$, so that\r\n\\begin{equation}\r\n|\\phi_m\\rangle = O^m |\\Psi_T\\rangle \\,.\r\n\\end{equation}\r\nWhen evaluated in the position representation, the $O^m$ for $m>0$ correspond\r\nto multiplying by the derivative of the logarithm of the trial function.\r\nSubstituting these expressions, and dividing by $\\langle \\Psi_T|\\Psi_T\\rangle$,\r\nEq. (\\ref{eq.power}) becomes\r\n\\begin{eqnarray}\r\n\\label{eq.first}\r\n\\frac{\\langle \\Psi_T |O^m (\\Lambda-H) |\\Psi_T\\rangle}\r\n{\\langle \\Psi_T |\\Psi_T\\rangle}\r\n= \\sum_{n=0} \\frac{\\langle \\Psi_T |O^m O^n |\\Psi_T\\rangle}\r\n{\\langle \\Psi_T |\\Psi_T\\rangle} \\Delta \\alpha_n\\,.\r\n\\end{eqnarray}\r\nThe expectation values can be calculated and the linear equations solved\r\nto get $\\Delta \\alpha_n$.\r\n\r\nAlternatively, the $m=0$ and $n=0$ terms can be separated. Writing\r\nthe trial function expectation of an operator $O$ as $\\langle O\\rangle$,\r\nEq. (\\ref{eq.first}) becomes\r\n\\begin{eqnarray}\r\n\\label{eq.m0}\r\n\\langle \\Lambda - H \\rangle = \\Delta \\alpha_0 + \\sum_{n=1} \\langle O^n\\rangle\r\n\\Delta \\alpha_n & m=0\\\\\r\n\\label{eq.mneq0}\r\n\\langle O^m (\\Lambda-H) \\rangle = \\langle O^m\\rangle \\Delta \\alpha_0\r\n+ \\sum_{n=1} \\langle O^m O^n\\rangle \\Delta \\alpha_n & m > 0 \\,.\r\n\\end{eqnarray}\r\nSubstituting Eq. \\ref{eq.m0} into Eq. (\\ref{eq.mneq0}) gives\r\n\\begin{equation}\r\n\\label{eq:srpar}\r\n\\langle O^m(\\Lambda - H) \\rangle -\\langle \\Lambda - H\\rangle \\langle O^m\\rangle\r\n= \\sum_{n=1} \\left [ \\langle O^mO^n\\rangle - \\langle O^m\\rangle\r\n\\langle O^n\\rangle \\right ] \\Delta \\alpha_n \\,.\r\n\\end{equation}\r\nSolving gives $\\Delta \\alpha_{n>0}$ and\r\nEq. (\\ref{eq.m0}) then gives the value for $\\Delta \\alpha_0$.\r\n\r\nIn either case, the result gives an approximation to the next trial\r\nfunction as a linear combination of the original function and its\r\nparameter derivatives. The new parameters are chosen to give this\r\nsame linear combination as the first two terms in the Taylor series.\r\nSince dividing the approximate expression for $|\\psi_{n+1}\\rangle$\r\nby $\\Delta\\alpha_0$ gives\r\nan expression that is the first two terms in the Taylor series,\r\nthe new parameters are\r\n\\begin{equation}\r\n\\alpha^{(\\rm new)}_{n>0} =\r\n\\alpha^{(\\rm old)}_n + \\frac{\\Delta \\alpha_{n>0}}{\\Delta \\alpha_0}\r\n\\end{equation}\r\n\r\n%The method can be applied to DMC by substituting the DMC propagator for\r\n%$\\Lambda-H$. Using a symmetric function for the importance function,\r\n%should allow better node optimization.\r\n\r\nMore recently Toulouse \\& Umrigar~\\cite{Toulouse07} proposed a much more efficient method\r\nwhere the Hamiltonian is diagonalized in the reduced space spanned by the $|\\phi_m\\rangle$.\r\nThe parameter variation is then given by the solution of the generalized eigenvalue equation\r\n\\begin{equation}\r\n\\label{eq:lmpar}\r\n\\sum_{n=0}\\frac{\\langle \\Psi_T |O^m H O^n|\\Psi_T\\rangle}\r\n{\\langle \\Psi_T |\\Psi_T\\rangle}\\Delta \\alpha_n\r\n= \\Delta E \\sum_{n=0} \\frac{\\langle \\Psi_T |O^m O^n |\\Psi_T\\rangle}\r\n{\\langle \\Psi_T |\\Psi_T\\rangle} \\Delta \\alpha_n\\,.\r\n\\end{equation}\r\nwith the lowest eigenvalue $\\Delta E^min$:\r\n\\begin{equation}\r\n\\alpha^{(\\rm new)}_{n>0} =\r\n\\alpha^{(\\rm old)}_n + \\frac{\\Delta \\alpha^{min}_{n>0}}{\\Delta \\alpha^{min}_0} .\r\n\\end{equation}\r\nThe gradient of the local energy is required for the expectation values \r\nappearing in~Eq.\\eqref{eq:lmpar}, and can be efficiently estimated using the\r\nreweighting technique presented in the previous section.\r\n\r\nWhen the parameters are far away from the minimum this approach can be less stable \r\nthan the previous one giving rise to large parameter variations that\r\ninvalidate the linear approximation Eq.~(\\ref{eq:psiprime}). A quick strategy is then to use \r\nthe solution of Eq.~(\\eqref{eq:srpar}) early on in the optimization process and then switch to\r\nEq.~(\\eqref{eq:lmpar}) when the resulting norm of the variation is below some threshold.\r\n\r\n\\section{Projection Monte Carlo Methods in coordinate space}\r\n%\\subsection{Propagation in imaginary time}\r\n\\subsection{General formulation}\r\n\\label{sec:generaldmc}\r\nVariational calculations provide only an upper bound for the ground-state eigenvalue of a \r\ngiven Hamiltonian. However, it is possible to use Monte Carlo algorithms to actually solve\r\nthe Schr\\\"odinger equation for an arbitrary number of interacting particles. This class of algorithms is bsed on the idea of imaginary time propagation.\r\n\r\nLet us consider a Hamiltonian $\\hat{H}$. The imaginary time evolution of an arbitrary state is defined starting by the standard time-dependent Schr\\\"odinger equation:\r\n\\begin{equation}\r\n-i\\hbar\\frac{\\partial}{\\partial t}|\\Psi(t)\\rangle = \\hat{H}|\\Psi(t)\\rangle.\r\n\\end{equation}\r\nIt is possible to Wick rotate, and introduce an {\\it imaginary time} $\\tau=\\frac{it}{\\hbar}$. The \r\ntime-dependent Schr\\\"odinger equation is transformed into an imaginary-time-dependent equation:\r\n\\begin{equation}\r\n-\\frac{\\partial}{\\partial \\tau}|\\Psi(\\tau)\\rangle = \\hat{H}|\\Psi(\\tau)\\rangle,\r\n\\end{equation}\r\nwhere\r\n$\\tau$ is defined as an {\\it inverse energy} that parametrizes the propagation of the quantum state.\r\nThe formal solution can be written using the imaginary time propagator\r\n\\begin{equation}\r\n\\vert\\Psi(\\tau)\\rangle=e^{-\\tau\\hat{H}}\\vert\\Psi(0)\\rangle\r\n\\end{equation}\r\nIt is possible to expand the initial state $\\vert \\Psi(0)\\rangle$ in eigenstates $\\vert\\phi_n\\rangle$ of the Hamiltonian itself, such that $\\hat{H}\\vert\\phi_n\\rangle=E_n\\vert\\phi_n\\rangle$. The imaginary time propagation of $\\vert\\Psi(0)\\rangle=\\sum_nc_n \\vert\\phi_n\\rangle$ becomes:\r\n\\begin{equation}\r\n\\vert\\Psi(\\tau)\\rangle=e^{-\\tau\\hat{H}}\\sum_n c_n\\vert\\phi_n\\rangle=\r\n\\sum_n c_n e^{-\\tau E_n}\\vert\\phi_n\\rangle\r\n\\end{equation}   \r\nLet us now consider the limit of the propagation for $\\tau\\rightarrow\\infty$. The coefficients of the expansion $c_n e^{-\\tau E_n}$ will either decrease (if $E_n>0$) or increase (if $E_n<0$) with the\r\nimaginary time, but in the limit the coefficient corresponding to the ground state of $\\hat{H}$, i.e.\r\n$c_0 e^{-\\tau E_0}$ will be dominant. This means that the imaginary time propagator has the interesting property of filtering out of an arbitrary state in the Hilbert space the ground state\r\nof a given Hamiltonian, provided that the state is not orthogonal to the ground state to begin with.\r\nWe want to stress a very important point. The ground state we are referring to is the {\\it mathematical} ground state of the Hamiltonian $\\hat{H}$. The {\\it physical} ground state needs to\r\ntake into account the symmetry of the particles, either bosons or fermions.\r\nIt is very easy to convince oneself that such mathematical ground state is always a nodeless function (i.e. it is zero nowhere but possibly on the boundaries of the domain of existence of the wavefunction expressed in some representation). This is because the propagator is a positive definite function, at least for a Hamiltonian of the standard form $\\hat{H}=\\hat{T}+\\hat{V}$, where $\\hat{T}$ is the kinetic energy of a system of free particles and $\\hat{V}$ is a local potential. In this case\r\nthe eigenvector corresponding to the largest eigenvalue of the propagator is positive definite within the domain that defines the system. The largest eigenvalue of the propagator corresponds to the lowest eigenvalue of $\\hat{H}$.\r\n\r\nNotice that the imaginary time propagator is hermitian not unitary, and the normalization of the projected ground state is not guaranteed in general. By means of a small change in the propagator definition it is possible to guarantee the normalization of the projected ground state. In fact, let us define the propagator as:\r\n\\begin{equation}\r\n\\label{eq:gentauprop}\r\n\\vert\\Psi(\\tau)\\rangle=e^{-\\tau(H-E_0)}\\vert\\Psi(0)\\rangle.\r\n\\end{equation}\r\nIt is easy to realize that in this case the amplitude of the component of the initial state along the ground state is preserved (while all other amplitudes decrease exponentially), and therefore the projected state is normalizable.\r\n\r\nWe will later discuss in detail the implications of these properties as concerns the application of imaginary-time propagation to many-fermion systems. \r\n\\subsection{Imaginary time propagator in coordinate representation}\r\n\\label{sec:dmccoord}\r\nWe will focus on a practical implementation of imaginary time propagation, and we will limit ourselves to a system of bosons (or Boltzmannions) which do admit a ground-state wavefunction that is positive definite. We will also consider Hamiltonians of the form mentioned in the previous subsection, in which the interaction is local.\r\nIn this case the propagator is easily represented in coordinates. Formally we would have:\r\n\\begin{equation}\r\n\\langle R \\vert\\Psi(\\tau)\\rangle=\\int dR' \\langle R\\vert e^{-\\tau(H-E_0)}\\vert R'\\rangle\\langle R'\\vert\\Psi(0)\\rangle,\\label{general_diff}\r\n\\end{equation}\r\nwhere we have inserted a complete set of position eigenstates.The propagator\r\n\\begin{equation}\r\n\\langle R \\vert e^{-\\tau(\\hat{H}-E_0)}\\vert R'\\rangle\r\n\\end{equation}\r\nseems to be still quite difficult to evaluate. However, let us break up the imaginary time interval\r\n$\\tau$ in two equal intervals $\\tau/2$. We can write\r\n\\begin{equation}\r\n\\langle R \\vert e^{-\\tau(\\hat{H}-E_0)}\\vert R'\\rangle=\\langle R \\vert e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}\\vert R'\\rangle,\r\n\\end{equation}\r\nsince $\\hat{H}$ obviously commutes with itself. Inserting a complete set we obtain:\r\n \\begin{equation}\r\n\\langle R \\vert e^{-\\tau(\\hat{H}-E_0)}\\vert R'\\rangle=\\int dR''\\langle R \\vert e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}\\vert R''\\rangle\\langle R''\\vert e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}\\vert R'\\rangle,\r\n\\end{equation}\r\nThis process can be iterated for an arbitrary large number of times $M$:\r\n\\begin{equation}\r\n\\langle R \\vert e^{-\\tau(\\hat{H}-E_0)}\\vert R'\\rangle=\\int\\cdots\\int dR''\\cdots dR^M\\langle R \\vert e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}\\vert R''\\rangle\\cdots\\langle R^M\\vert e^{-\\frac{\\tau}{2}(\\hat{H}-E_0)}\\vert R'\\rangle.\\label{path}\r\n\\end{equation}\r\nEach of the factors in the integrand corresponds to a propagation for a {\\it short} imaginary time $\\Delta\\tau=\\tau/M$.\r\nIn this case we can split the propagator using the Trotter-Suzuki formula:\r\n\\begin{equation}\r\ne^{-\\frac{\\Delta\\tau}{2}(\\hat{H}-E_0)}\\sim e^{-\\frac{\\Delta\\tau}{2}(\\hat{V}-E_0)}e^{-\\Delta\\tau\\hat{T}}e^{-\\frac{\\Delta\\tau}{2}(\\hat{V}-E_0)}+o(\\Delta\\tau^3)\r\n\\end{equation}\r\nThe representation in coordinates of each factor is known. The factors containing the potential, under the hypotheses made, are diagonal in the coordinates themselves, and simply become:\r\n\\begin{equation}\r\ne^{-\\frac{\\Delta\\tau}{2}(\\hat{V}-E_0)}\\vert R\\rangle = |R\\rangle e^{-\\frac{\\Delta\\tau}{2}(V(R)-E_0)},\r\n\\end{equation}\r\nwhile the kinetic term is the propagator of a set of $A$ free particles obeying the equation:\r\n\\begin{equation}\r\n-\\frac{\\partial}{\\partial\\tau}\\Psi(R,t)=-\\frac{\\hbar^2}{2m}\\nabla^2\\Psi(R,t)\\label{diffusion_eq}\r\n\\end{equation}\r\nThis is a classical {\\it free diffusion} equation. If we interpret $\\Psi(R,t)$ as a the density of the $A$ particles, its evolution in time will be given by the well known diffusion law:\r\n\\begin{equation}\r\n\\Psi(R,t)=\\frac{1}{(2\\pi\\frac{\\hbar^2}{m}\\Delta\\tau)^\\frac{3A}{2}}\\int dR'e^{-\\frac{(R-R')^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}\\Psi(R',0).\\label{free_propagator}\r\n\\end{equation}\r\nThe short-time approximation for the propagator, correct at order $\\Delta\\tau$ , will then become:\r\n\\begin{equation}\r\n\\langle R\\vert e^{-\\frac{\\Delta\\tau}{2}(\\hat{H}-E_0)}\\vert R'\\rangle\\sim\\frac{1}{(2\\pi\\frac{\\hbar^2}{m}\\Delta\\tau)^\\frac{3A}{2}}e^{-\\frac{\\Delta\\tau}{2}(V(R)-E_0)} e^{-\\frac{(R-R')^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}e^{-\\frac{\\Delta\\tau}{2}(V(R)-E_0)}.\\label{propagator}\r\n\\end{equation}\r\n\r\nAt this point it is possible to proceed in different ways. By substituting Eq.(\\ref{propagator}) in Eq.(\\ref{path}), one obtains an integral in which the integrand is a function of $M$ replicas of the coordinates of the particles in the system. The ground-state expectation value of an operator that is a function of the coordinates can then  be computed using on the left and on the right the imaginary time propagation started from an arbitrary state $\\Psi(R,0)$. The resulting expression is:\r\n\\begin{eqnarray}\r\n\\begin{array}{c}\r\n\\langle \\phi_0|O(R)|\\phi_0\\rangle = \r\n\\displaystyle\\lim_{\\tau\\rightarrow\\infty}\\langle \\Psi(R,\\tau)|O(R)|\\Psi(R,\\tau)\\rangle\\sim\\left(\\frac{1}{(2\\pi\\frac{\\hbar^2}{m}\\Delta\\tau)^\\frac{3A}{2}}\\right)^M\\times\\\\ \\\\\r\n\\times\\displaystyle \\int\\int\\cdots\\int dR\\;dR'\\cdots dR^M\\Psi(R,0)e^{-\\frac{\\Delta\\tau}{2}(V(R)-E_0)} e^{-\\frac{(R-R')^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}e^{-\\Delta\\tau(V(R')-E_0)}\r\n\\cdots O(R^{M/2}) \\\\ \\\\\r\n\\displaystyle\r\n\\cdots e^{-{\\Delta\\tau}(V(R^{M-1})-E_0)} e^{-\\frac{(R^{M-1}-R^M)^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}e^{-\\frac{\\Delta\\tau}{2}(V(R^M)-E_0)}\\Psi(R^M,0)\r\n\\end{array}\r\n\\end{eqnarray}\t\r\nThis expression is reminiscent of a path-integral formulation of the problem. The integral can in principle be computed by means of a  Metropolis-like algorithm, and gives the ground-state\r\nexpectation of an arbitrary observable, provided that the number of slices $M$ used is  large enough to guarantee a correct filtering of the ground state. This method is known as Path Integral Ground State Monte Carlo (PIGS-MC)~\\cite{Sarsa00}.\r\n\r\nHowever, there is a simpler way to implement the imaginary time propagation. Let us expand the initial state from which we want to project the ground state in eigenstates of the position:\r\n\\begin{equation}\r\n|\\Psi\\rangle \\simeq \\sum_i\\Psi(R_i)|R_i\\rangle\r\n\\end{equation} \r\nWe will call each of these points in coordinate space a {\\it walker}, and we will refer to the whole ensemble of points as to the {\\it population} of walkers. If we apply the short-time propagator to each walker, it is easy to understand its effect. We will call the application of the short-time propagator to the walker population an {\\it imaginary time step} (or simply a {\\it time step}). Each time step originates a new {\\it generation} of walkers.\r\n\r\nThe Gaussian factor in the propagator tells us the probability that a walker positioned in $R'$ is displaced to a new position $R$. Since the probability density is a Gaussian of variance\r\n$\\sigma^2=\\frac{\\hbar^2}{m}\\Delta\\tau$, the RMS displacement will be proportional to $\\sqrt{\\Delta\\tau}$ times a constant, which plays the role of a {\\it diffusion constant} $D$, equal to $\\frac{\\hbar^2}{m}$. For each coordinate of each particle we need to extract a random number\r\n$\\eta$ distributed as:\r\n\\begin{equation}\r\n\\label{eq:gaussprop}\r\nP[\\eta]=\\frac{1}{\\sqrt{2\\pi D \\Delta\\tau}}e^{-\\frac{\\eta^2}{2D\\Delta\\tau}}\r\n\\end{equation}\r\nand add it to to the original coordinate. \r\n\\begin{svgraybox}\r\n\t\\begin{algorithmic} \r\n\t\t\\State{DMC\\_Move()}\r\n\t\t\\For{$i \\in \\{0,A-1\\}$}  \r\n\t\t\\For{$j \\in \\{0,2\\}$ }\r\n\t\t\\State{$R_{new}[i][j]\\gets R[i][j]+D\\Delta\\tau[\\text{rgaus}()]$}\r\n\t\t\\EndFor\r\n\t\t\\EndFor\r\n\t\\end{algorithmic}\r\n\\end{svgraybox}\r\nThe function $\\text{rgaus}()$ generating normally-distributed random numbers is now universally available as a library routine, but it can easily be implemented starting from a uniform distribution by using the Box-Muller formula. \r\nThe part of the propagator depending on the potential has a slightly different interpretation. In the classical analogy we could say that the factor $W=e^{-\\frac{\\Delta\\tau}{2}(V(R^M)-E_0)}$ represents \r\nthe probability of a process to occur by which new points might be created in the time interval $\\Delta\\tau$ (if $W>1$) or destroyed (if $W<1$), or in other words, a process related to the presence of a source or a sink of walkers. $W$ is interpreted as the average number of walkers that this\r\nprocess would generate over time at the position $R$. As we will later see, this creation/absorption (or {\\it branching}) process is related to the fact that the normalization of the propagated state is not preserved.\r\nSince we cannot work with a non-integer number of walkers, we can use the following strategy\r\n\\begin{enumerate}\r\n\t\\item\r\n\tuse the quantity $W$ as a weight for the contribution to the estimates from the walker at a given position. Since in the short-time propagator we have two such factors, one from the initial position and on from te final position of the walker, we can use the product of the two as the total weight:\r\n\t\\begin{equation}\r\n\t\\label{eq:propw}\r\n\tW=\\exp\\left\\{ -\\Delta\\tau\\left[\\frac{V(R)+V(R')}{2}-E_0\\right]\\right\\}\r\n\t\\end{equation}\r\n\tEstimates will be integrals of the form $\\langle O\\rangle=\\int \\phi_0(R) O(R) dR$,\r\n\tand they can be computed as:\r\n\t\\begin{equation}\r\n\t   \\langle O\\rangle =\\frac{  \\sum_l^{N_{wk}}W_{kl}O(R_{kl})}\r\n\t   \t{\\sum_l^{N_{wk}}W_{kl}},\\label{dmc_averages}\r\n\t\\end{equation} \r\nwhere $N_{wk}$ is the number of walkers in a given generation. We will discuss later the specific form of the function $O$ for interesting cases.\r\n\\item\r\nIn order to generate a number of points that is correct on average, we can sample $N_{mult}$, the number of points to be generated for the next generation, in the following way:\r\n\\begin{equation}\r\nN_{mult}=\\text{int}(W+\\xi),\r\n\\end{equation}\r\nwhere $\\text{int}()$ is the function truncating the argument to an integer, and $\\xi$ is a random number in $[0,1)$. $N_{mult}$ could be $\\geq 1$, in which case the next generation will contain\r\n$N{mult}$ copies of the walker, or $0$, in which case the walker is suppressed. \r\n\\end{enumerate}\t\r\nThe projection of the ground state will be achieved when propagating for a sufficiently long imaginary time. This means that we need to evolve the population of walkers for a large number of time steps, and eventually we will sample a density of points with a distribution {\\it proportional} to the ground-state wavefunction. In the initial stage of the run, the energy and other estimators will have a value that is still strongly biased by the initial state. This means that the initial part of the propagation should be excluded from the averages. There is no automatic recipe to choose how much of the walk should be discarded. Usually it is convenient to monitor some observable (typically energy) and try to see where its value stops having a systematic trend as a function of the imaginary time. \r\n\r\nHow is the constant $E_0$ fixed? In principle it should be equal to the ground-state energy. This would mean that we need to know the solution of the problem... before solving it! In practice it is not strictly necessary to use the exact value of $E_0$, but it is sufficient to use a realistic variational estimate. The value of $E_0$ can also be used to reduce the fluctuations in the population of walkers due to the branching process, at the cost of introducing additional bias.\r\nFor example, it is possible to modify the weight of a given configuration in the following way:\r\n\\begin{equation}\r\n\\tilde{W}=\\frac{N_{t}}{N_g}\\exp\\left\\{ -\\Delta\\tau\\left[\\frac{V(R)+V(R')}{2}-E_0\\right]\\right\\}\r\n\\end{equation}\r\nwhere $N_t$ is a \"target\" number of walkers in the population and $N_g$ is the number of walkers in the current generation. This modified weight reacts to the variations of the population, increasing or decreasing the weight depending on whether $N_g$ is smaller or larger than $N_t$, respectively.\r\nThis modification obviously introduces a bias in the results, since it modifies the propagator. However, this bias will be linearly decreasing with the time-step $\\Delta\\tau$. The weight can  also be rewritten as:\r\n\\begin{equation}\r\n\\tilde{W}=\\exp\\left\\{ -\\Delta\\tau\\left[\\frac{V(R)+V(R')}{2}-\\tilde{E}\\right]\\right\\},\\label{weight2}\r\n\\end{equation}\r\nwhere\r\n\\begin{equation}\r\n\\tilde{E}=E_0+\\frac{1}{\\Delta\\tau}\\log\\left(\\frac{N_t}{N_g}\\right)\r\n\\end{equation}\r\nTherefore, at each generation the constant can be modified to keep the size of the population under control. \r\n\r\nThe weight can also be used to estimate the energy. In fact if we take the logarithm of both members of Eq. (\\ref{weight2}) we obtain:\r\n\\begin{equation}\r\n\\log{\\tilde{W}}=-\\Delta\\tau\\left[\\frac{V(R)+V(R')}{2}-\\tilde{E}\\right]\r\n\\end{equation}\r\nfrom which we obtain:\r\n\\begin{equation}\r\nE_0=\\frac{1}{\\Delta\\tau}\\log\\left(\\frac{N_g\\tilde{W}}{N_t}\\right)+\\frac{V(R)+V(R')}{2}.\r\n\\end{equation}\r\nThis is the so-called {\\it growth energy} estimator, and it can be used in principle to evaluate the\r\nground-state eigenvalue.\r\n\r\nA simpler way of evaluating the energy is to use a test function $\\Psi_T(R)$. In this case the idea is\r\nto evaluate the following matrix element:\r\n\\begin{equation}\r\n\\langle E\\rangle =\\frac{\\langle \\phi_0|\\hat{H}|\\Psi_T\\rangle}{\\langle \\phi_0|\\Psi_T\\rangle}=\\frac{\\int dR \\phi_0(R)\\hat{H}\\Psi_T(R)}{\\int dR \\phi_0(R)\\Psi_T(R)}\r\n\\end{equation}\r\nBoth numerator and denominator integrals are suitable for Monte Carlo evaluation.\r\nThe probability density that we sample is $\\phi_0(R)$, and the functions to be cumulated following the recipe in Eq. (\\ref{dmc_averages}) are $\\hat{H}\\Psi_T(R)$ and $\\Psi_T(R)$. The latter is necessary whenever $\\Psi_T(R)$ is not normalized. We will then have\r\n\\begin{equation}\r\n\\label{Eq._dmc_ave}\r\n\\langle E\\rangle=\\frac{\\langle \\hat{H}\\Psi_T\\rangle}{\\langle \\Psi_T\\rangle}.\r\n\\end{equation}\r\nHowever, due to the hermiticity of the hamiltonian, one has:\r\n\\begin{equation}\r\n\\langle E\\rangle =\\frac{\\langle \\phi_0|\\hat{H}|\\Psi_T\\rangle}{\\langle \\phi_0|\\Psi_T\\rangle}=\\frac{\\langle \\Psi_T|\\hat{H}|\\phi_0\\rangle}{\\langle \\phi_0|\\Psi_T\\rangle}=E_0,\r\n\\end{equation}\r\nindependent of the choice of $\\Psi_T(R)$. This is the most practical way to evaluate the energy eigenvalue and its standard deviation. Other observables can be evaluated in a similar way. However the results will always depend on the choice of the test function. We will discuss this aspect later.\r\n\r\nA last important remark remains to be made. In devising the algorithm we are making some approximations. First of all the imaginary time propagator is not exact, but is correct only at order $\\Delta\\tau^2$. This means that for any finite imaginary time step value, the answer will be biased of an amount proportional to $\\Delta\\tau^2$. The same holds for the population size whenever one wants to apply population control as described above. For any finite target population $N_t$ there will be a bias on the answer of order $1/N_t$. These biases can be corrected by performing several simulations with different values of $\\Delta\\tau$ and $N_t$, and then extrapolating to $\\Delta\\tau\\rightarrow 0$ and $1/N_t\\rightarrow 0$. As we will show in the last part of this chapter, methods exist to completely eliminate the time step bias. However, it is possible to reduce the bias with some minor modifications in the propagator and by introducing an acceptance/rejection mechanism (cite CYRUS TIME STEP).\r\n\\subsection{Application to the harmonic oscillator}\r\n\r\nA very simple illustration of the sense of the algorithm can be made by implementing to the one-dimensional harmonic oscillator. We consider the Hamiltonian:\r\n\\begin{equation}\r\n\\hat{H}=-\\frac{1}{2}\\frac{\\partial^2}{\\partial x^2}+\\frac{1}{2}x^2\r\n\\end{equation}\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/hists.eps}\r\n\t\\end{center}\r\n\t\\caption{Histogram of the walker population after $N$ DMC imaginary time steps for the harmonic oscillator Hamiltonian described in text. Here we used $\\Delta\\tau=10^{-3}$, with a target population of 4000 walkers.}\r\n\t\\label{fig.hist}\r\n\\end{figure}\r\nThe ground-state eigenvalue is $E_0=\\tfrac{1}{2}$ and the ground-state eigenfunction is the Gaussian $\\Psi_0(x)=\\frac{1}{\\pi^{1/4}}e^{-\\frac{x^2}{2}}$. As we have illustrated in the previous section, the propagation can start from any distribution of points with a density not orthogonal to the ground state. A very simple choice in this case is a constant. In Fig.\\ref{fig.hist} we can see how the histogram of the walkers evolves as a function of the imaginary time applying the algorithm described in the previous section, including population control. The initial uniform distribution of walkers in the interval $[-6,6]$ is transformed into the correct Gaussian density. The mechanism that leads to this result is easy to understand. Any walker finding itself after diffusion in a region where the potential is larger than the eigenvalue will tend to be suppressed, while walkers near the origin will tend to multiply themselves. This will result in a histogram peaked at the origin ad decaying fast to zero when moving away from it.\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/dmc_decay.eps}\r\n\t\\end{center}\r\n\t\\caption{Logarithm of the estimated energy averaged over a single generation as a function of the imaginary time in a run with a population target of 4000 walkers, and with an imaginary time step $\\Delta\\tau=10^{-4}$}\r\n\t\\label{fig.decay}\r\n\\end{figure}\r\n\r\n\r\nIn order to estimate the energy we need a test function. An approximation to the ground state might be given by the function:\r\n\\begin{equation}\r\n\\Psi_T(x)=\\frac{1}{1+x^2}.\r\n\\end{equation}\r\nWe can therefore estimate the energy by means of the following quotient (see Eq. (\\ref{Eq._dmc_ave})):\r\n\\begin{equation}\r\n\\langle E\\rangle = \\frac{\\sum_{i} w(x_i)\\frac{1-3x_i^2}{(1+x_i^2)^3}+\\frac{1}{2}\\frac{x_i^2}{1+x_i^2}}{\\sum_iw(x_i)\\frac{1}{1+x_i^2}},\r\n\\end{equation}\r\nwhere the sums runs first over all the generations (i.e. the imaginary time steps performed) and then over all the walkers belonging to a given generation.\r\n\r\nIn Fig. \\ref{fig.decay} we show the logarithm of the energy estimator averaged over each single generation as a function of the imaginary time. As we would expect from the general behavior of the coefficients of the excited states as function of the imaginary time, we see a clear exponential decay of the energy towards the exact eigenvalue. The figure clearly shows how the transient is not made up of a single exponential. The initial state needs includes a large number of excited states, that all need to be projected out before reaching the ground state.\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/walkers_dmc.eps}\r\n\t\\end{center}\r\n\t\\caption{Typical fluctuations of the walker population in a DMC run for the one dimensional harmonic oscillator. The target population in this case is 2000. The imaginary time step is\r\n\t\tset to $\\Delta\\tau=0.075$. }\r\n\t\\label{fig.walkers}\r\n\\end{figure}\r\nIn Fig. \\ref{fig.walkers}the typical behavior of the fluctuation in the walker number is reported. In the specific case the time step was set to $\\Delta\\tau=0.3$. Nevertheless, the walker number never departs from the target by more than 3\\%. This is the effect of the population control procedure described in the previous subsection. Unfortunately population control alone is not sufficient to guarantee a stable calculation. In presence of particle-particle interactions that diverge at the origin fluctuations in the number of walkers become extremely wide. This is the reason why it is necessary to introduce the so-called importance sampling, that we will discuss in a later section.\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/dmc_extr.eps}\r\n\t\\end{center}\r\n\t\\caption{TIllustration of the imaginary time-step extrapolation procedure. The energy is computed for different values of $\\Delta\\tau$, and the results are fitted with a linear function. The intercept will give the correct prediction for the eigenvalue. Notice that the results should still be extrapolated for an infinite population. Here we use a target number of walkers equal to 2000, and the runs consist of $10^5$ generations each. Errorbars refer to one standard deviation. The plotted value for $\\Delta\\tau=0$ and the corresponding errorbar are obtained from the linear fit of the data. }\r\n\t\\label{fig.extr}\r\n\\end{figure}\r\n\r\nFinally, in Fig. \\ref{fig.extr} we show one of the points discussed in the previous section, that is the bias of the result due to the finite imaginary time step. The difference between the energy estimate and the exact eigenvalue is plotted as a function of $\\Delta\\tau$ for a target population of 2000 walkers and a total of $10^5$ generations for each value of $\\Delta\\tau$. The observed bias is quite small, but well outside of the statistical error. The dependence on $\\Delta\\tau$ is quadratic, as expected from the analysis of the propagator. Interpolating the data with a function of the form $E=E_0+\\alpha(\\Delta\\tau)^2$ we predict $E_0$ to be  $(-3\\pm1)\\times 10^{-5}$. As it can be seen there is still a small residual bias due to the finitness of the population. Further extrapolation would be needed to recover the exact answer. \r\n \r\n\\subsection{Importance sampling}\r\nThe simple diffusion algorithm we have illustrated above suffers of a substantial deficiency when particles interact with a potential having a repulsive or attractive core. Since the free particle diffusion propagator does not have any information about the potential, particles have no restrictions to come close to each other. This means that the weights will suffer of large fluctuations whenever a pair of particles find themselves at short distance. The consequent fluctuations in the population make the computation unmanageable.  \r\n\r\nThe use of an importance function to guide the diffusion process  \\cite{Anderson76}  was the key to make  Diffusion Monte Carlo algorithms usable. The idea is to give up on the request of sampling the ground-state wavefunction, and rather try to sample a distribution that, asymptotically in imaginary time, is the product of the ground-state wavefunction and of a known function that is the best possible approximation to the ground state obtained, for instance, by means of a variational calculation. We will call this function $\\Psi_G$. Starting from Eq.(\\ref{general_diff}) we can multiply both sides by $\\Psi_G$ and obtain:\r\n\t\\begin{equation}\r\n\t\\Psi_G(R)\\Psi(R,\\Delta\\tau)=\\int dR' G'(R',R,\\Delta\\tau) \\Psi_G(R)\\Psi(R',0),\\label{is1}\r\n\t\\end{equation}\r\nwhere we have defined:\r\n\\begin{equation}\r\nG'(R,R',\\Delta\\tau)=\\frac{1}{(2\\pi\\frac{\\hbar^2}{m}\\Delta\\tau)^\\frac{3A}{2}}e^{-\\Delta\\tau(V(R')-E_0)} e^{-\\frac{(R'-R)^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}.\r\n\\end{equation}\r\nSince all the expressions we have written are correct at order $\\Delta\\tau$, for our purposes we can assume the equivalence of $G'$ and $G$. \r\nWe can multiply and divide the  integrand in Eq.(\\ref{is1}) by $\\Psi_G(R')$ to obtain:\r\n\\begin{equation}\r\n\\Psi_G(R)\\Psi(R,\\Delta\\tau)=\\int dR' G'(R',R,\\Delta\\tau) \\frac{\\Psi_G(R)}{\\Psi_G(R')}\\Psi_G(R')\\Psi(R',0),\\label{is2}.\r\n\\end{equation}\r\nIn Eq. (\\ref{is2}) we can identify a new walker density to be propagated, namely:\r\n\\begin{equation}\r\nf(R,\\tau)=\\Psi_G(R)\\Psi(R,\\tau),\r\n\\end{equation}\r\nand the corresponding propagator:\r\n\\begin{equation}\r\n\\tilde{G}(R,R',\\Delta\\tau)=G'(R,R',\\tau)\\frac{\\Psi_G(R)}{\\Psi_G(R')}.\r\n\\end{equation}\r\nThe quotient of the wavefunctions can be included in the weight, and provides a correction that prevents the walkers to excessively multiply or die near the divergent points of the potential\r\nThis point is better illustrated considering the short time limit it is possible to expand the ratio of the guiding functions. At first order in $\\Delta\\tau$ the result is:\r\n\\begin{equation}\r\n\\tilde{G}(R,R',\\Delta\\tau)\\simeq G_0(R,R',\\tau)\\left[1+\\frac{\\nabla\\Psi_G(R')}{\\Psi_G(R')}(R-R')+\\cdots\\right]\r\n\\end{equation}\r\nAt the same order we can regard the terms in bracket as the expansion of an exponential and write:\r\n \\begin{equation}\r\n \\tilde{G}(R,R',\\Delta\\tau)\\simeq G_0(R,R',\\tau)e^{\\frac{\\nabla\\Psi_G(R')}\r\n \t{\\Psi_G(R')}(R-R')}\r\n \\end{equation}\r\nThis can be combined with the Gaussian factor in $G_0$, and by completing the square (which introduces a term at order $\\Delta\\tau2$), the propagator is modified as follows:\r\n\\begin{equation}\r\n\\tilde{G}(R,R',\\Delta\\tau)\\simeq\\frac{1}{(2\\pi\\frac{\\hbar^2}{m}\\Delta\\tau)^\\frac{3A}{2}}e^{-\\frac{\\Delta\\tau}{2}(V(R')-E_0)} e^{-\\frac{(R-R'-\\frac{\\hbar^2}{m}\\Delta\\tau\\frac{\\nabla\\Psi_G(R')}{\\Psi_G(R')})^2}{2\\frac{\\hbar^2}{m}\\Delta\\tau}}e^{-\\frac{\\Delta\\tau}{2}(V(R)-E_0)}.\r\n\\end{equation}\r\nThe same expansion can be performed to compute the {\\it change in normalization} of the propagated density after a time step. The change in normalization is given by:\r\n\\begin{equation}\r\n{\\cal N}=\\int dR \\tilde{G}(R,R',\\tau),\\label{eq:norm}\r\n\\end{equation}\r\ni.e. the total weight of the final points $R$ that can be reached starting from $R'$.\r\nOnce more we can expand the ratio of the guiding functions in the propagator, but this time up to second order:\r\n\\begin{equation}\r\n\\tilde{G}(R,R',\\Delta\\tau)\\simeq G_0(R,R',\\tau)\\left[1+\\frac{\\nabla\\Psi_G(R')}{\\Psi_G(R')}(R-R')+\\frac{1}{2}\\frac{\\partial_{i\\alpha}\r\n\\partial_{j\\beta}\\Psi_G(R')(R-R')_{i\\alpha}(R-R')_{j\\beta}}{\\Psi_G(R')}+\\cdots\\right]\r\n\\end{equation}\r\nInserting the previous equation in Eq.(\\ref{eq:norm}) we can see that after integrating over $R$ the terms containing odd powers of $(R-R')$ disappear by parity. We are therefore left with:\r\n\\begin{equation}\r\n{\\cal N}=e^{-\\Delta\\tau[V(R')-E_0]}\\left[1+\\frac{1}{2}\\frac{\\nabla^2\\Psi_G(R')}{\\Psi_G(R')}\\frac{\\hbar^2}{m}\\Delta\\tau+\\cdots\\right]\r\n\\end{equation}\r\nWe can now use the same trick used above to write the expression in square parenthesis as an exponential. The result is:\r\n\\begin{equation}\r\n{\\cal N}= \\exp\\left[-\\Delta\\tau\\left(V(R')-\\frac{\\hbar^2}{2m}\\frac{\\nabla^2\\Psi_G(R')}{\\Psi_G(R')}-E_0z\\right)\\right]\r\n\\end{equation}\r\nIn the previous expression it is possible to immediately recognize the local energy. In fact, when using importance sampling, the normalization assumes the expression:\r\n\\begin{equation}\r\n{\\cal N}= \\exp\\left[-\\Delta\\tau\\left(\\frac{\\hat{H}\\Psi_G(R')}{\\Psi_G(R')}-E_0\\right)\\right]\r\n\\end{equation}\r\nThis is the new form of the weight factor that one needs to compute in order to determine the multiplicity of the walker at a given position. It is immediately clear that the fact that in the exponential we have the difference between the local energy, instead of the potential energy, and the reference eigenvalue $E_0$ essentially resolves the issue related to the fluctuations of the population related to a divergent behavior of the interaction. In fact, if we knew the exact solution the exponent would be identically zero, and the population would be absolutely stable. However, by means of an accurate variational calculation it is possible to obtain a very good approximation of the ground-state wavefunction, thereby reducing the fluctuations in the population to a minimum. \r\n\r\nThe algorithm including impotance sampling is modified in the following way.\r\n\\begin{enumerate}\r\n\\item\r\n   For each walker, and for each coordinate perform a \"drift\" move along the\r\n   gradient of the guiding function. This displacement is deterministic.\r\n\\begin{svgraybox}\r\n \t\\begin{algorithmic} \r\n \t\t\\State{DMC\\_Drift()}\r\n \t\t\\For{$i \\in \\{0,A-1\\}$}  \r\n \t\t\\For{$j \\in \\{0,2\\}$ }\r\n \t\t\\State{$R_{drift}[i][j]\\gets R[i][j]+\\frac{\\nabla\\Psi_G(R)}{\\Psi_G(R)}\\lvert_{[i][j]} D\\Delta\\tau$}\r\n \t\t\\EndFor\r\n \t\t\\EndFor\r\n \t\\end{algorithmic}\r\n\\end{svgraybox}\r\n\\item\r\nCycle again over coordinates and diffuse the position from $R_{drift}$ as in the non-importance sampled case.\r\n\\item\r\nCompute the new multiplicity of the walker and the weight to assign to estimators using\r\n\\begin{equation}\r\nW=\\exp\\left[-\\Delta\\tau\\left(\\frac{\\hat{H}\\Psi_G(R')}{\\Psi_G(R')}-E_0\\right)\\right]\r\n\\end{equation}\r\n\\end{enumerate}\r\nIn this way the walkers will asymptotically sample the distribution:\r\n\\begin{equation}\r\nf(R)=\\Psi_G(R)\\phi_0(R).\r\n\\end{equation}\r\nThis means that it is possible to evaluate integrals of the form:\r\n\\begin{equation}\r\n\\langle O\\rangle=\\frac{\\int dR f(R) O(R)}{\\int dR f(R)}.\r\n\\end{equation}\r\nAs in the previous case the evaluation of the exact energy eigenvalue can be easily obtained by using the local energy. In fact, the matrix element of the Hamiltonian between the guiding function\\footnote{It is always possible to project the energy from a function $\\Psi_T$ other than $\\Psi_G$, by introducing a further weighing factor $\\frac{\\Psi_T}{\\Psi_G}$. However this is very rarely used in standard applications.}  and the ground-state wavefunction is:  \r\n\\begin{equation}\r\n\\langle E\\rangle =\\frac{\\langle \\phi_0|\\hat{H}|\\Psi_G\\rangle}{\\langle \\phi_0|\\Psi_G\\rangle}=\\frac{\\int dR f(R)\\frac{\\hat{H}\\Psi_G(R)}{\\Psi_G(R)}}{\\int dR f(R)}\r\n\\end{equation}\r\nOnce more, because of the hermiticity of the Hamiltonian we will have that $\\langle E\\rangle =E_0$. All other estimators will be matrix elements of the operator between $\\Psi_G$ and $\\phi_0$. \r\n\r\n\\subsection{The fermion sign problem}\r\n\\label{sec:signprob}\r\nAs we have mentioned, imaginary time propagation projects out of an arbitrary initial state the absolute (mathematical) ground state of a given Hamiltonian $\\hat{H}$, which is always a nodeless function. One might correctly object that if the initial state is chosen in such a way not to have any overlap with this ground state, the projection will correctly give back some excited state of $\\hat{H}$. More rigorously, if our initial state has components only within a certain subspace of the total Hilbert space, which could be selected, for instance, by the wavefunction symmetry, then imaginary time propagation will end up projecting out the eigenstate with lowest eigenvalue within that given subspace.\r\n\r\nThis seems to be particularly useful when thinking of applying DMC-like algorithm to the study of many-fermion systems, as the nuclear systems we are interested in. The antisymmetry property of the fermionic ground state suggests that it should be sufficient to start from an arbitrary antisymmetric state $|\\Psi_A\\rangle$(provided it is not orthogonal to the fermion ground state) to obtain the sought solution. In fact, one might speculate that antisymmetry itself would guarantee that there is no overlap with the symmetric ground state since the beginning:\r\n\\begin{eqnarray}\r\n\\begin{array}{c}\r\n\\displaystyle\\lim_{\\tau\\rightarrow\\infty} e^{-\\tau(\\hat{H}-E_0^A)}|\\Psi_A(0)\\rangle=\r\n\\sum_n  e^{-\\tau(E_n-E_0^A)}\\langle \\phi_n|\\Psi_A\\rangle|\\phi_n\\rangle=\\\\ \\\\\r\n=\\langle \\phi_0^A|\\Psi_A\\rangle|\\phi_0^A\\rangle+\\displaystyle\\lim_{\\tau\\rightarrow\\infty}\\langle \\phi_0|\\Psi_A\\rangle|\\phi_0\\rangle e^{-\\tau(E_0-E_0^A)}\r\n\\end{array}\r\n\\end{eqnarray}\r\nHowever, this abstract formulation forgets that eventually we need to {\\it sample a probability density} in order to operate with a Monte Carlo integration, and any excited state will have a wavefunction changing sign somewhere, thereby breaking this requirement. If we had an exact knowledge of the {\\it nodal surface} of the ground state (i.e. of the set of points such that $\\phi_0^A(0)=0$), we could use an antisymmetric function $\\Psi_G^A(R)$ having the same nodal surface, and obtain by importance function the required positive definite density to sample:\r\n\\begin{equation}\r\n\\langle E\\rangle =\\frac{\\displaystyle\\langle \\phi_0^A|\\hat{H}|\\Psi_G^A\\rangle}{\\langle \\phi_0^A|\\Psi_G^A\\rangle}=\\frac{\\displaystyle\\int dR \\phi_0^A(R)\\Psi_G^A(R)\\frac{\\hat{H}\\Psi_G^A(R)}{\\displaystyle\\Psi_G^A(R)}}{\\displaystyle\\int dR \\phi_0^A(R)\\Psi_G^A(R)}.\r\n\\end{equation}\r\nIf $\\Psi_G^a(R)$ does not have the same nodal surface as $\\phi_0^A(R)$, we are once again in trouble. \r\n\r\nWe might have then the idea of separately sampling the positive and the negative part of the wave function. It is always possible to split an antisymmetric function as:\r\n\\begin{equation}\r\n\\psi^A(R)=\\Psi^+(R)-\\Psi^-(R),\r\n\\end{equation}\r\nwhere both $\\Psi^+$ and $\\Psi^-$ are positive definite functions. It is easy to see that each one, by linearity, is a solution of the Schr\\\"odinger equation with the same eigenvalue as the fermionic ground state. We can call $|R^+\\rangle$ the walkers sampling the positive part and $|R^-\\rangle$ the walkers sampling the negative part of $\\Psi^A$. The energy expectation could be computed as:\r\n\\begin{equation}\r\nE_0^A=\\frac{\\displaystyle\\int dR^+ f^{+}(R^+)\\frac{\\hat{H}\\Psi_G^A(R^+)}{\\Psi_G^A(R^+)}-\\int dR^+ f^{-}(R^-)\\frac{\\hat{H}\\Psi_G^A(R^-)}{\\Psi_G^A(R^-)}}{\\displaystyle\r\n \\int dR^+ f^+(R^+)\\Psi_G^A(R^+)-\\int dR^+ f^-(R^-)\\Psi_G^A(R^-)},\\label{signedaverage}\r\n\\end{equation}\r\nwhere $f^\\pm$, as above, has the meaning of the importance sampled density of walkers. However, once more we have to notice that since both $f^+$ and $f^-$ will obey the same imaginary time Schr\\\"odinger equation, the two densities will both converge to the ground-state density for $\\hat{H}$. This means that both the numerator and the denominator of Eq.(\\ref{signedaverage}) will tend to 0 in the limit $\\tau\\rightarrow\\infty$, and the ratio becomes undetermined.\r\nThe major effect that one can observe during the calculation is that the variance of the energy will become exponentially large, and the integral will be dominated by statistical noise. This is the so called {\\it fermion sign problem}. For some authors there is a prove that the computation of estimates such as Eq.(\\ref{signedaverage}) is an NP complex problem~\\cite{Troyer05}, and a solution will always require computer time that is exponentially increasing with the dimension of the system. However there are hints that by using methods that break this {\\it plus/minus symmetry}, based on correlated dynamics and cancellation methods it is possible to reduce the cost to a polynomial dependence \\cite{Kalos00,Assaraf07}.\r\n\r\n\\subsubsection{Fixed-node approximation}\r\n\\label{sec:fn}\r\nA possible way of circumventing the sign problem in the case in which the antisymmetric ground-state wavefunction has to be real is to use some artificial boundary conditions~\\cite{Ceperley80}.\r\n\r\nWe can define a nodal pocket $\\Omega(R)$ as the set of points that can be reached from $R$ without crossing the nodal surface at any point. For a standard Hamiltonian we can expect that for any pair of points $R',R$ not on the nodal surface of the wavefunction, there exist a permutation $P$ of the coordinates such that $PR'\\in \\Omega(R)$. This in turn means that all the space (but for the nodal surface, which has zero measure) can be covered by summing over all the permutations of the points lying in a single nodal pocket $\\Omega(R)$. This the so-called {\\it tiling theorem}. The tiling theorem implies that the fermion ground-state eigenvalue of the Schr\\\"odinger equation solved inside any $\\Omega(R)$ is the same as the eigenvalue of the problem solved on the whole space. \r\n\r\nThe prove of the tiling theorem is quite simple. If the tiling property does not hold for the antisymmetric ground state $\\phi^A_0(R)$, then $\\sum_P\\Omega(PR)$ will not completely cover the space, leaving out some regions. This means that somewhere there are two regions $\\Omega(R_a)$ and $\\Omega(R_b)$ that share part of the nodal surface and are not equivalent. It is then possible to construct a function with a lower eigenvalue in the region $\\Omega(R_a)\\bigcup\\Omega(R_b)$ by simply removing the common node and solving for the ground state of $\\hat{H}$ within that region. Let us call $\\phi^0_{ab}$ this function. Constructing an antisymmetric function $\\Psi_A(R)=\\sum_P(-1)^P\\phi^0_{ab}$ we will have an antisymmetric function with an eigenvalue lower than that of $\\phi^A_0(R)$, thereby violating the assumption that $\\phi_A^0$ is the antisymmetric ground state of $\\hat{H}$.\r\n\r\nBy the same kind of construction it is also possible to prove that the solution of the Schr\\\"odinger equation within a given nodal pocket $\\Omega(R)$ is always an upper bound of the true antisymmetric eigenvalue, and that the exact result is recovered if and only if the nodal surface of the wavefunction generated by replicating the pocket coincides with that of the exact eigenfunction.\r\n\r\nThe previous considerations suggest that solving  for the ground state of a given Hamiltonian within a nodal pocket $\\Omega(R)$ will provide an upper bound of the energy of a many-fermion system, which can in principle can by improved by improving the nodal structure of the test function used to determine the boundary conditions. This is called the {\\it fixed-node approximation}. In order to have zero density at the nodal surface we have to assume that at the border of the nodal pocket an infinite absorbing potential exists, such that walkers never cross that surface. From the point of view of the algorithm this introduces a very tiny modification in the code. We have to remember that we can solve for the ground state in {\\it any} pocket. This means that we do not need to care either of the initial position of the walkers or of the associated sign of the wavefunction. We said that the fixed-node approximation corresponds to modify the Hamiltonian as follows\r\n\\begin{equation}\r\n\\hat{\\tilde{H}}=\\hat{H}+V_\\Omega(R),\r\n\\end{equation}  \r\nwhere\r\n\\begin{equation}\r\nV_\\Omega(R)=\\left\\{ \r\n\\begin{array}{ll}\r\n\\infty \\text{\\ \\ \\ if\\ \\ \\ }R\\in S(\\Omega)\\\\\r\n0\\text{\\ \\ \\ \\ otherwise}\r\n\\end{array}\r\n \\right.\r\n\\end{equation}\r\n This means that every time the walker crosses the border of the nodal pocket $S(\\Omega)$ its weight becomes zero, and the walker is simply canceled from the population. Fixed node calculations are presently very widely employed especially in quantum chemistry and solid state physics applications (for a review of applications to many electron systems see Ref. \\cite{Foulkes01}). When the wavefunction needs to be complex it is no longer possible to define a nodal surface, and a different kind of approach has to be used. This will be discussed in the next section concerning the applications to the nuclear physics case.\r\n \\section{Quantum Monte Carlo for Nuclear Hamiltonians in coordinate space}\r\n %$Id: afdmc.tex,v 1.7 2011/02/03 14:49:52 schmidt Exp$  \r\n %\\subsection{Green's Function Monte Carlo}\r\n %\r\n %\r\n %The GFMC method works well for calculating the low lying states of nuclei\r\n %up to and including $^{12}$C. Its major problem is that the computational\r\n %costs scale exponentially with the number of particles, because of the\r\n %full spin isospin summations. Full spatial integrations\r\n %would also scale exponentially, and this problem is solved by Monte Carlo\r\n %sampling the positions. The obvious solution to the exponential scaling\r\n %of the spin-isospin sums is to perform them using Monte Carlo sampling\r\n %as well.\r\n %\r\n %Our goal is then to find a low variance method to sample the spin-isospin\r\n %degrees of freedom. The usual historical route would be to begin with a\r\n %variational Monte Carlo calculation with spin-isospin summations.\r\n %For example, using Eq. \\ref{xxx}, and instead of summing over the spin\r\n %degrees of freedom, we could sample them using a Metropolis et al.\\cite{Metropolis53}\r\n %method. For example, the energy expectation would be\r\n %\\begin{eqnarray}\r\n %E_V &=&\r\n %\\frac{\\sum_{S} \\int dR \\langle \\Psi_T|H|RS\\rangle \\langle RS|\\Psi_T\\rangle}\r\n %{\\sum_{S} \\int dR \\langle \\Psi_T|RS\\rangle \\langle RS|\\Psi_T\\rangle}\r\n %\\nonumber\\\\\r\n %&=& \\sum_S \\int dR P(R,S) E_L(R,S)\r\n %\\end{eqnarray}\r\n %where\r\n %\\begin{eqnarray}\r\n %P(R,S) &= &\r\n %\\frac{\\langle \\Psi_T|RS\\rangle \\langle RS|\\Psi_T\\rangle}\r\n %{\\sum_{S} \\int dR \\langle \\Psi_T|RS\\rangle \\langle RS|\\Psi_T\\rangle}\r\n %\\nonumber\\\\\r\n %E_L(R,S) &=& \\frac{\\langle \\Psi_T|H|RS\\rangle}{\\langle \\Psi_T|RS\\rangle} \\,.\r\n %\\end{eqnarray}\r\n %We could then sample the spin-isospin states. We could begin with any\r\n %given up/down and proton/neutron spin state for each particle that gives\r\n %a nonzero $\\langle RS|\\Psi_T\\rangle$ value, and make Metropolis et al.\r\n %moves by flipping spins and exchanging isospins. With a high quality\r\n %trial function, the local energy $E_L(R,S)$ will have low variance, and\r\n %the method would give an accurate variational energy upperbound.\r\n %\r\n %The problem here is not in devising a Monte Carlo method or finding a way\r\n %of sampling the spin-isospin variables. The problem, instead, is in the\r\n %calculation of the trial function. The Calculation of\r\n %the good trial functions described in section \\ref{xxx} scales exponentially\r\n %with particle number even for a single spin-isospin state. In fact the difference\r\n %in computational cost\r\n %of calculating the value of these trial functions for one spin-isospin state\r\n %and all off them is completely negligible.  The VMC and GFMC methods described\r\n %in section \\ref{xxx} can therefore lower the variance without increasing the\r\n %computational complexity by summing over all of the spin-isospin states.\r\n %\r\n %This tells us that in order to have an algorithm that has polynomial\r\n %scaling with particle number, we require a basis that is complete or overcomplete,\r\n %a trial state, and the evaluation of the wave function given by the\r\n %overlap of our trial and basis states must be calculable in polynomial time.\r\n %\r\n %To date, we have used the basis given by the outer product of nucleon position\r\n %states, and the outer product of single nucleon spin-isospin spinor states.\r\n %That is an element of this overcomplete basis is given by specifying the\r\n %$3A$ cartesian coordinates for the $A$ nucleons, and specifying four complex\r\n %amplitudes for each nucleon to be in a $|p\\uparrow$, $p\\downarrow$, $n\\uparrow$,\r\n %$n\\downarrow$ spin-isospin state. A basis state is then\r\n %\\begin{equation}\r\n %|R_n S_n\\rangle =\r\n %|r_1 s_1\\rangle \\otimes |r_2 s_2 \\rangle \\dots \\otimes |r_n s_n\\rangle\r\n %\\end{equation}\r\n %\r\n %Our trial functions must be antisymmetric under interchange. The only such\r\n %functions with polynomial scaling that we know how to write down are Slater\r\n %determinants or Pfaffians (BCS pairing functions), for example,\r\n %\\begin{eqnarray}\r\n %\\langle R S|\\Phi_{\\rm Slater}\\rangle &= &\r\n %{\\cal A} \\left [\r\n %\\langle \\vec r_1 s_1|\\phi_1\\rangle \r\n %\\langle \\vec r_2 s_2|\\phi_2\\rangle \r\n %\\dots\r\n %\\langle \\vec r_A s_A|\\phi_n\\rangle  \\right ]\r\n %\\nonumber\\\\\r\n %\\langle R S|\\Phi_{\\rm BCS}\\rangle &=&\r\n %{\\cal A} \\left [ \\langle \\vec r_1 s_1 \\vec r_2 s_2|\\psi_{\\rm cooper}\\rangle\r\n %\\langle \\vec r_3 s_3 \\vec r_4 s_4|\\psi_{\\rm cooper}\\rangle\r\n %\\dots\r\n %\\langle \\vec r_{A-1} s_{A-1} \\vec r_A s_A|\\psi_{\\rm cooper}\\rangle\r\n %\\right ]\r\n %\\end{eqnarray}\r\n %or linear combinations of them. Operating on these with the product of\r\n %correlation operators, Eq. \\ref{xxx}, again gives a state with\r\n %exponential scaling with nucleon number. For our AFDMC calculations, we\r\n %multiply these wave functions by a state-independent, or\r\n %central, Jastrow correlation. Calculations of the Slater determinants\r\n %and Pfaffians scale like $A^3$ when using standard dense matrix methods,\r\n %while the central Jastrow requires $A^2$ operations if its range is\r\n %the same order as the system size.\r\n %\r\n %These trial functions capture only the physics of the\r\n %gross shell structure of the nuclear\r\n %problem and the state independent part of the two-body interaction.\r\n %Devising trial functions that are both computationally efficient to\r\n %calculate and that capture the state-dependent two- and three-body\r\n %correlations that we know are important would greatly improve both\r\n %the statistical and systematic errors of quantum Monte Carlo methods\r\n %for nuclear problems.\r\n %\r\n %The trial wave functions above can be used for variational calculations.\r\n %However, the results are poor since the functions miss the\r\n %physics of the important tensor interactions. These functions can be\r\n %used as importance functions for AFDMC calculations where they have been\r\n %found adequate for this purpose in a variety of problems.\r\n \r\n \\subsection{General Auxiliary Field Formalism}\r\n \r\n \r\n We begin by looking at the auxiliary field formalism without importance\r\n sampling.\r\n All such diffusion Monte Carlo methods can be formulated as\r\n \\begin{eqnarray}\r\n \\label{eq.afdmc}\r\n |\\Psi(t+\\Delta t)\\rangle = \\int dX P(X) T(X) |\\Psi(t)\\rangle\r\n \\end{eqnarray}\r\n where $X$ is a set of variables which will become our auxiliary fields,\r\n $P(X)$ is a probability density,\r\n \\begin{eqnarray}\r\n P(X) &\\geq& 0\r\n \\nonumber\\\\\r\n \\int dX P(X) &=& 1\\,,\r\n \\end{eqnarray}\r\n and $T(X)$ is an operator that operates\r\n in the Hilbert space of $|\\Psi(t)\\rangle$.\r\n We are free to choose the variables $X$, the probability density $P(X)$,\r\n and the operator $T(X)$ subject only to the\r\n constraint that the integral gives the desired propagator\r\n \\begin{equation}\r\n e^{-(H-E_T)\\Delta t} = \\int dX P(X) T(X) \\,,\r\n \\end{equation}\r\n at least in the limit that $\\Delta t \\rightarrow 0$.\r\n \r\n In diffusion Monte Carlo methods, we represent the state $|\\Psi(t)\\rangle$\r\n as a linear combination of basis states which obviously must span the\r\n Hilbert space. These can be a complete set. An example is the position\r\n eigenstates used for diffusion Monte Carlo for central potentials.\r\n They can also form an overcomplete set such as\r\n or the position and spin/isospin bases used in the nuclear GFMC\r\n method and the position and\r\n overcomplete outer product of single particle\r\n spinor basis used in AFDMC, or the\r\n overcomplete single particle bases used in auxiliarly field methods\r\n such as those developed by Zhang and coworkers. For either case, we\r\n can denote these basis states as possible ``walkers.'' We will denote\r\n one of these walker states\r\n as $|RS\\rangle$ since we will be applying the method to\r\n systems where the basis is given by the positions of the particles, $R$,\r\n and a spinor for each spin-isospin of the particles, $S$.\r\n \r\n The state,\r\n $|\\Psi(t)\\rangle$, at\r\n time $t$ is represented in diffusion Monte Carlo methods as a\r\n linear combination of walker states\r\n \\begin{equation}\r\n \\label{eq.walkers}\r\n |\\Psi(t)\\rangle = \\sum_{i=1}^{N_W} w_i |R_i S_i\\rangle\r\n \\end{equation}\r\n where $w_i$ is a coefficient, often called the weight, and $N_W$ is the\r\n number of walkers.\r\n \r\n The key ingredient to implementing a diffusion Monte Carlo method is\r\n to choose the walker basis and the operator $T(X)$ such that when\r\n $T(X)$ operates on a walker basis state, it gives one and only one\r\n new walker basis state. That is we want\r\n \\begin{equation}\r\n \\label{eq.afop}\r\n T(X) |R S\\rangle = W(X,R,S) |R' S'\\rangle\r\n \\end{equation}\r\n where $|R' S'\\rangle$ is normalized in the same way as $|RS\\rangle$,\r\n and $W(X,R,S)$ is the change in the normalization from the propagation.\r\n \r\n Once we have arranged for Eq. \\ref{eq.afop} to be true, we can implement\r\n the diffusion Monte Carlo by starting with $|\\Psi(0)\\rangle$ written, as\r\n in Eq. \\ref{eq.walkers}, as any, not\r\n unreasonable, linear combination of walkers. For each walker, we sample\r\n $X$ values from $P(X)$, and use Eq. \\ref{eq.afop} to propagate to a new\r\n walker $|R_i' S_i'\\rangle$, with a new weight $w_i'$\r\n given by the proportionality\r\n constant of Eq. \\ref{eq.afop} multiplied by\r\n the original weight $w_i$. We branch on the magnitude of the weight,\r\n so usually, after branching, $w_i'=1$, where we are ignoring the\r\n fermion sign or phase problem for now and assuming that all of the\r\n weights are greater than or equal to zero. We will deal with the\r\n fermion case below.\r\n \r\n \\subsection{Operator expectations and importance sampling}\r\n \\subsubsection{Mixed averages}\r\n \\label{sec:mixav}\r\n Diffusion Monte Carlo methods efficiently calculate ground-state\r\n mixed averages\r\n \\begin{equation}\r\n \\label{eq:mixedobs}\r\n \\bar O_{\\rm mixed} = \\frac{\\langle \\Psi_T | O |\\Psi(t)\\rangle}{\\langle\r\n \t\\Psi_T|\\Psi(t)\\rangle}\r\n \\end{equation}\r\n where $|\\Psi_T\\rangle $ is  trial state.\r\n If $O$ is the Hamiltonian, operating on $|\\Psi(t)\\rangle$ shows\r\n that the result\r\n is the ground-state energy for large $t$. For other operators, for which\r\n the ground state is not an eigenstate, either\r\n approximate extrapolation methods or forward walking or its equivalent\r\n must be used to extract the correct ground-state expection value.\r\n \r\n Given a set of walkers as in Eq. \\ref{eq.walkers}, the mixed estimate can\r\n be calculated by\r\n \\begin{equation}\r\n \\bar O_{\\rm mixed} \\simeq\r\n \\frac{ \\sum_{i=1}^{N_w} w_i \\langle \\Psi_T|O|R_i S_i\\rangle}\r\n { \\sum_{i=1}^{N_w} w_i \\langle \\Psi_T|R_i S_i\\rangle}\r\n \\end{equation}\r\n where the right hand side differs from the correct result because\r\n of statistical errors from the sampling which decreases as $N_W^{-1/2}$,\r\n and possible population size bias which decreases as $N_W^{-1}$. Statistical\r\n errors can be minimized by reducing the variance through importance\r\n sampling.  Population\r\n bias also can be controlled with importance sampling, and, since it decays\r\n faster with population size, can be readily detected\r\n and removed by either taking larger numbers of walkers or extrapolation.\r\n \r\n Efficient Monte Carlo methods need to have low variance so that the\r\n statistical error bars can be made small. For our walker propagation,\r\n this means that we should sample new walkers not only corresponding to\r\n the weight they will receive from our algorithm, but with this weight\r\n multiplied by their expected survival probability. The imaginary time\r\n Schr\\\"odinger equation is self adjoint, so the optimum importance\r\n function is the desired function. Typically, a trial\r\n function that can be efficiently evaluated is determined variationally\r\n and used as an approximation to the optimum trial function. Usually\r\n this trial wave function is used as the importance\r\n function. Sometimes a different importance function is used, so we will\r\n write this more general case. \r\n \r\n \\subsubsection{Importance sampling}\r\n To add importance sampling, we arrange to sample our walkers from\r\n a new state which we call $|\\Psi_I \\Psi(t)\\rangle$ such that\r\n \\begin{equation}\r\n \\label{eq.iswf}\r\n \\langle R S |\\Psi_I\\Psi(t)\\rangle\r\n = \\langle \\Psi_I|RS\\rangle \\langle RS|\\Psi(t)\\rangle\r\n \\end{equation}\r\n so that\r\n \\begin{equation}\r\n \\label{eq.iswalker}\r\n |\\Psi_I \\Psi(t)\\rangle = \\sum_{i=1}^{N_w} w_i |R_iS_i\\rangle\r\n \\end{equation}\r\n An alternative way of looking at this is that\r\n the sampling probability for the walkers at $R_iS_i$ has been\r\n modified so that\r\n \\begin{equation}\r\n \\label{eq.imp}\r\n |\\Psi(t)\\rangle = \\sum_{i=1}^{N_w} w_i \\langle \\Psi_I|R_iS_i\\rangle^{-1}\r\n |R_i S_i\\rangle \\,.\r\n \\end{equation}\r\n Calculating a mixed average now becomes\r\n \\begin{equation}\r\n \\bar O_{\\rm mixed} = \\frac{\\sum_{i=1}^{N_w} w_i\r\n \t\\frac{\\langle \\Psi_T|R_iS_i\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}\r\n \t\\frac{\\langle \\Psi_T|O|R_iS_i\\rangle}{\\langle \\Psi_T|R_iS_i\\rangle}}\r\n {\\sum_{i=1}^{N_w} w_i\r\n \t\\frac{\\langle \\Psi_T|R_iS_i\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}\r\n } \\,.\r\n \\end{equation}\r\n For the usual case where $|\\Psi_I\\rangle = |\\Psi_T\\rangle$, and\r\n $w_i = 1$, we have\r\n \\begin{equation}\r\n \\bar O_{\\rm mixed} = \\frac{1}{N_w} \\sum_{i=1}^{N_w}\r\n \\frac{\\langle \\Psi_T|O|R_iS_i\\rangle}{\\langle \\Psi_T|R_iS_i\\rangle} \\,.\r\n \\end{equation}\r\n \r\n \r\n We substitute Eqs. \\ref{eq.iswf} and \\ref{eq.iswalker} into Eq. \\ref{eq.afdmc}\r\n \\begin{eqnarray}\r\n |\\Psi_I \\Psi(t+\\Delta t)\\rangle &=& \\sum_{i=1}^{N_w} w_i\r\n \\int dX P(X)\r\n \\frac{\\langle \\Psi_I|R_i'S_i'\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}\r\n T(X)|R_i S_i\\rangle\r\n \\nonumber\\\\\r\n &=&\r\n \\sum_{i=1}^{N_w} w_i\r\n \\int dX P(X)\r\n \\frac{\\langle \\Psi_I|T(X)|R_iS_i\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}\r\n \\frac{T(X)}{W(X,R_i,S_i)}|R_i S_i\\rangle\r\n \\end{eqnarray}\r\n where $|R_i'S_i'\\rangle$ is defined as in Eq. \\ref{eq.afop}.\r\n Notice that the operator $T(X)/W(X,R_i,S_i)$ operating on $|R_iS_i\\rangle$\r\n gives a normalized walker. The additional weight of this walker is given by\r\n $P(X)\\frac{\\langle \\Psi_I|T(X)|R_iS_i\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}$.\r\n We want to minimize fluctuations in this weight factor, and to do this\r\n we normalize it and sample from the normalized distribution. The\r\n normalization will be the weight.\r\n \r\n We write\r\n \\begin{eqnarray}\r\n {\\cal N} &=& \\int dX P(X)\\frac{\\langle \\Psi_I|T(X)|R_iS_i\\rangle}\r\n {\\langle \\Psi_I|R_iS_i\\rangle}\r\n \\nonumber\\\\\r\n &=& \r\n \\frac{\\langle \\Psi_I|e^{-(H-E_T)\\Delta t} |R_iS_i\\rangle}\r\n {\\langle \\Psi_I|R_iS_i\\rangle}\r\n \\nonumber\\\\\r\n &=& e^{-(E_L(R_i,S_i) -E_T)\\Delta t} + O(\\Delta t^2)\r\n \\end{eqnarray}\r\n where the local energy $E_L(R_i,S_i)$ is defined by\r\n \\begin{eqnarray}\r\n E_L(R_i,S_i) &=& \r\n \\frac{\\langle \\Psi_I|H|R_iS_i\\rangle}\r\n {\\langle \\Psi_I|R_iS_i\\rangle}\r\n \\end{eqnarray}\r\n and we now sample $X$ variables from the normalized distribution\r\n \\begin{eqnarray}\r\n \\tilde P(X) &=& {\\cal N}^{-1}\r\n P(X)\\frac{\\langle \\Psi_I|T(X)|R_iS_i\\rangle}{\\langle \\Psi_I|R_iS_i\\rangle}\\,.\r\n \\end{eqnarray}\r\n \r\n \r\n The importance sampled diffusion Monte Carlo in the auxiliary field\r\n formalism becomes\r\n \\begin{equation}\r\n \\label{eq.afdmcimp}\r\n |\\Psi_I\\Psi(t+\\Delta t)\\rangle = \\sum_{i=1}^{N_w}\r\n w_i \\int dX \\tilde P(X) e^{-(E_L(R_i,S_i) -E_T)\\Delta t}\r\n \\frac{T(X)}{W(X,R_i,S_i)} |R_iS_i\\rangle \\,.\r\n \\end{equation}\r\n We  propagate a walker by sampling an $X$ value from $\\tilde P(X)$,\r\n we include the local energy expression in the weight, and\r\n construct the new normalized\r\n walker position and spin state as $W^{-1}(X,R_i,S_i)T(X)|R_iS_i\\rangle$.\r\n In each of the equations above,\r\n the ratio of the wave function terms gives the walker weight.\r\n In Eq. \\ref{eq.afdmcimp} these terms have been combined to give a\r\n weight that depends on the local energy expectation value.\r\n All of the expectation values and weights\r\n contain ratios of trial wave functions\r\n so that any normalization factor multiplying the $|R S\\rangle$ cancels\r\n and any convenient normalization can be used. We can therefore drop\r\n the $W$ factors and normalize our walker kets at the end of a step.\r\n Typically just the \r\n walker positions are stored and the walker spinors are normalized to\r\n have magnitude 1.\r\n \r\n \\subsubsection{Importance sampling with a Hubbard-Stratonovich transformation}\r\n We often have Hamiltonians where\r\n the Hubbard-Stratonovich transformation\r\n \\begin{equation}\r\n e^{\\frac{O^2}{2}} = \\frac{1}{\\sqrt{2\\pi}}\r\n \\int_{-\\infty}^\\infty dx e^{-\\frac{x^2}{2}} e^{x O}\r\n \\end{equation}\r\n can be used\r\n to write a propagatator in the form of Eq. \\ref{eq.afop}. Examples are\r\n writing the kinetic energy as an integral over translations, or writing\r\n terms like $\\vec \\sigma_i \\cdot \\vec \\sigma_j =\r\n (\\vec \\sigma_i +\\vec \\sigma_j)^2 -6$ as an integral over\r\n spin rotations.\r\n \r\n Since we primarily use the Hubbard-Stratonovich transformation to define\r\n our auxiliary fields, it is useful to work out how importance sampling\r\n can be included within the short-time approximation for this particular\r\n case. We begin with a Hamiltonian that is quadratic in a set of $N_O$ operators\r\n (which for our nuclear problems will be momentum and spin-isospin operators)\r\n $O_n$,\r\n \\begin{equation}\r\n \\label{eq.sumofsquares}\r\n H = \\frac{1}{2}\\sum_{n=1}^{N_O} \\lambda_n O_n^2\r\n \\end{equation}\r\n so that the imaginary time propagator is\r\n \\begin{eqnarray}\r\n e^{-H \\Delta t} &=&  \\int dx \\frac{1}{(2\\pi)^{N_O/2}}\r\n e^{-\\frac{1}{2}\\sum_{n=1}^{N_O} x_n^2}\r\n e^{-i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t} O_n}\r\n \\nonumber\\\\\r\n && + ~ O(\\Delta t^2)\r\n \\end{eqnarray}\r\n where the $\\Delta t^2$ terms comes from the possible noncommutivity of the\r\n $O_n$.\r\n \r\n As before, we choose our walker basis and the operators $O_n$ such\r\n that operating on a walker,\r\n $|R S\\rangle$,\r\n with a term sampled from the integrand, gives a result\r\n proportional to another walker\r\n \\begin{equation}\r\n \\label{eq.walkerprop}\r\n e^{-i \\sum_{n=1}^{N_O} x_n\\sqrt{\\lambda \\Delta t} O_n}|RS\\rangle =\r\n W(\\{x_n\\},R,S) |R'S'\\rangle\r\n \\end{equation}\r\n where $\\{x_n\\}$ represents the set of sampled $x_n$ values.\r\n \r\n We now sample $\\tilde P(X)$ which is\r\n \\begin{eqnarray}\r\n \\tilde P(X) &=&\r\n {\\cal N}^{-1}\r\n e^{-\\frac{1}{2} \\sum_{n=1}^{N_O} x_n^2}\r\n \\frac{\\langle \\Psi_T |e^{-i\\sum_{n=1}^{N_O}\r\n \t\tx_n \\sqrt{\\lambda_n \\Delta t} O_n}|R S\\rangle}\r\n {\\langle \\Psi_T|RS\\rangle}\r\n \\nonumber\\\\\r\n &=& {\\cal N}^{-1}\r\n e^{-\\frac{1}{2} \\sum_{n=1}^{N_O} x_n^2}\r\n \\left (1 -i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t}\r\n \\frac{\\langle \\Psi_T|O_n|R S\\rangle}\r\n {\\langle \\Psi_T|R S\\rangle}\r\n - \\frac{1}{2}\\sum_{n=1,m=1}^{N_O}\r\n x_n x_m\\sqrt{\\lambda_m \\lambda_n} \\Delta t\r\n \\frac{\\langle \\Psi_T|O_nO_m|R S\\rangle}\r\n {\\langle \\Psi_T|R S\\rangle}\r\n + ... \\right )\r\n \\nonumber\\\\\r\n \\label{eq.hsimp}\r\n \\end{eqnarray}\r\n \r\n Notice that if we were to expand $T(X)/W(X,R_i,S_i)$ it would\r\n have the form $1 + O(x_n\\Delta t^{1/2}) + O(x_nx_m \\Delta t)+ ...$.\r\n Therefore if we drop terms of order $\\Delta t^2$, the $O(\\Delta t)$ term of\r\n $P(X)$ contributes only when it multiplies the 1 term from $T(X)/W(X,R_i,S_i)$.\r\n We can therefore integrate it\r\n over $X$ without changing the result to this\r\n order in $\\Delta t$. This term cancels the normalization, so that\r\n \\begin{eqnarray}\r\n \\tilde P(X) &=&\r\n e^{-\\frac{1}{2} \\sum_{n=1}^{N_O} x_n^2}\r\n \\left (1 -i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t}\r\n \\frac{\\langle \\Psi_T|O_n|R S\\rangle}\r\n {\\langle \\Psi_T|R S\\rangle} + O(\\Delta t^{3/2}) \\right )\r\n \\nonumber\\\\\r\n &=& e^{-\\frac{1}{2} \\sum_{n=1}^{N_O} x_n^2}\r\n e^{ -i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t}\r\n \t\\frac{\\langle \\Psi_T|O_n|R S\\rangle}{\\langle \\Psi_T|R S\\rangle}\r\n \t+\\sum_{n=1}^{N_O} \\lambda_n \r\n \t[\\frac{\\langle \\Psi_T|O_n|R S\\rangle}{\\langle \\Psi_T|R S\\rangle}]^2}\r\n +O(\\Delta t^{3/2})\r\n \\nonumber\\\\\r\n &=&\r\n \\exp\\left \\{-\\frac{1}{2} \\sum_{n=1}^{N_O} \r\n \\left [x_n+i\\sqrt{\\lambda_n \\Delta t}\r\n \\frac{\\langle \\Psi_T|O_n|R S\\rangle}{\\langle \\Psi_T|R S\\rangle}\r\n \\right ]^2 \\right \\}\r\n \\nonumber\\\\\r\n \\label{eq.hsimpexpanded}\r\n \\end{eqnarray}\r\n where in the last line, we have written the linear term in $x$ in the\r\n exponent, and included a canceling term so that only\r\n the linear term survives integration to order $\\Delta t$.\r\n \r\n We sample our expression by sampling $x_n$ from the shifted gaussian\r\n (Again, we assume here that\r\n $i\\sqrt{\\lambda_n \\Delta t}\\langle O_n \\rangle$ is real.\r\n We will discuss what to do for the complex case below.)\r\n \\begin{equation}\r\n x_n = \\chi_n -i \\sqrt{\\lambda_n\\Delta t} \\langle O_n\\rangle\r\n \\end{equation}\r\n where $\\chi_n$ is sampled from a gaussian with unit variance.\r\n The new unnormalized ket is\r\n \\begin{equation}\r\n |R'S'\\rangle = e^{-i\\sum_{n=1}^{N_O} x_n\\sqrt{\\lambda \\Delta t} O_n}\r\n |RS\\rangle \\langle \\Psi_T |RS\\rangle\r\n \\end{equation}\r\n and its weight is given by the local energy expression\r\n \\begin{equation}\r\n W(R',S') = e^{-[\\langle H \\rangle-E_T] \\Delta t}\r\n \\end{equation}\r\n \r\n \\subsection{Application to standard diffusion Monte Carlo}\r\n \\subsubsection{Diffusion Monte Carlo without importance sampling}\r\n It is helpful to apply the formalism above to derive\r\n the well known central potential\r\n diffusion Monte Carlo algorithm\\cite{Anderson76}.\r\n The Hamiltonian is\r\n \\begin{equation}\r\n H = \\sum_{j=1}^A \\sum_{\\alpha=1}^3 \\frac{p_{j\\alpha}^2}{2m} + V(R)\r\n \\end{equation}\r\n where $p_{j\\alpha}$ and $R$ operate on Hilbert space, and $p_{j\\alpha}$\r\n is the $\\alpha$ component of the momentum operator for the $j$th\r\n particle.\r\n Making the short-time approximation, the propagator can be written\r\n as\r\n \\begin{equation}\r\n e^{-(H-E_T)\\Delta t} = e^{\\sum_{j=1}^A\\sum_{\\alpha=1}^3\r\n \t\\frac{p_{j\\alpha}^2}{2m} \\Delta t}\r\n e^{-[V(R)-E_T]\\Delta t} + O(\\Delta t^2) \\,.\r\n \\end{equation}\r\n Since the Hamiltonian does not operate on the spin, we can drop the\r\n spin variable\r\n from the our walker expressions and take just a position basis $|R\\rangle$.\r\n Operating with the potential term\r\n \\begin{equation}\r\n e^{-[V(R)-E_T]\\Delta t}|R_j\\rangle = \r\n e^{-[V(R_j)-E_T]\\Delta t}|R_j\\rangle\r\n \\end{equation}\r\n clearly satisfies Eq. \\ref{eq.afop}. The kinetic energy part of the\r\n propagator does not satisfy Eq. \\ref{eq.afop}. However, by\r\n using the Hubbard-Stratonovich transformation,\r\n we can write the kinetic energy in terms of the translation operators\r\n $e^{-\\frac{i}{\\hbar} p_{j\\beta} a}$.\r\n We introduce the auxiliary field or Hubbard-Stratonovich variables,\r\n $x_{j\\alpha}$, and write\r\n \\begin{eqnarray}\r\n &&\r\n e^{-\\sum_{j=1}^A\\sum_{\\alpha=1}^3 \\frac{p_{j\\alpha}^2}{2m} \\Delta t} = \r\n \\nonumber\\\\\r\n &&\r\n \\prod_{j\\alpha} \\frac{1}{(2\\pi)^{3/2}} \\int d x_{j\\alpha}\r\n e^{-\\frac{x_{j\\alpha}^2}{2}}\r\n e^{-\\frac{i}{\\hbar} \\vec p_{j\\alpha}\r\n \tx_{j\\alpha} \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}}\r\n \\end{eqnarray}\r\n \r\n With this definition, $X$ is the set $\\{x_{j\\alpha}\\}$,\r\n for the $A$ particles,\r\n \\begin{equation}\r\n P(X) =\r\n \\prod_{j\\alpha} \\frac{1}{\\sqrt{2\\pi}} e^{-\\frac{x_{j\\alpha}^2}{2}} \\,,\r\n \\end{equation}\r\n and\r\n \\begin{eqnarray}\r\n T(X)|R\\rangle =\r\n e^{-[V(R)-E_T]\\Delta t} |R+\\Delta R\\rangle\r\n \\end{eqnarray}\r\n where $R' = R+\\Delta R$ is given by translating each particle's position in $R$\r\n \\begin{equation}\r\n r_{j\\alpha}' = r_{j\\alpha} + x_{j\\alpha} \\frac{\\hbar^2 \\Delta t}{m} \\,.\r\n \\end{equation}\r\n This is identical to the standard diffusion Monte Carlo algorithm without\r\n importance sampling. We move\r\n each particle with a gaussian distribution of variance\r\n $\\frac{\\hbar^2 \\Delta t}{m}$, and include a weight of\r\n $e^{-[V(R)-E_T]\\Delta t}$. We would then include branching on the weight\r\n to complete the algorithm.\r\n \r\n While the Hubbard-Stratonovich transformation is the most common, there are\r\n many other possibilities. For example, the propagator for the\r\n relativistic kinetic energy\r\n $\\sqrt{p^2 c^2 + m^2 c^4}-mc^2$ can be sampled by using\r\n \\begin{equation}\r\n e^{-\\left [\\sqrt{p^2 c^2 + m^2 c^4}-mc^2 \\right ] \\Delta t} =\r\n \\int d^3x f(x) e^{-\\frac{i}{\\hbar} \\vec p \\cdot \\vec x}\r\n \\end{equation}\r\n with\r\n \\begin{eqnarray}\r\n f(x) &=& \\int \\frac{d^3p}{(2\\pi)^3} e^{\\frac{i}{\\hbar} \\vec p \\cdot \\vec x}\r\n e^{-\\left [\\sqrt{p^2 c^2 + m^2 c^4}-mc^2 \\right ] \\Delta t}\r\n \\nonumber\\\\\r\n &=& e^{mc^2 \\Delta t}\r\n K_2 \\left ( \\frac{m c}{\\hbar} \\sqrt{x^2+c^2 \\Delta t^2} \\right )\r\n \\end{eqnarray}\r\n where $K_2$ is the modified Bessel function of order 2\\cite{carlson1993}.\r\n \r\n \r\n \\subsubsection{Importance sampled Diffusion Monte Carlo in the auxiliary field\r\n \tformulism}\r\n \r\n We break up the Hamiltonian as a kinetic and potential part. The potential\r\n part gives the usual $e^{-V(R) \\Delta t}$ weight, and we need to work only\r\n with the importance sampled kinetic energy part.\r\n The kinetic energy operator is already written as a sum of squares,\r\n \\begin{equation}\r\n KE = \\sum_{j\\alpha} \\frac{p_{j\\alpha}^2}{2m}\r\n \\end{equation}\r\n where $j$ is the particle label and $\\alpha$ is the $x$, $y$, or $z$ coordinate.\r\n We can identify $\\lambda_{j\\alpha} = m^{-1}$, and $O_{j\\alpha} = p_{j\\alpha}$.\r\n Substituting this into our previous formalism, we have\r\n \\begin{eqnarray}\r\n i \\sqrt{\\lambda_{j\\alpha} \\Delta t}\\langle O_{j\\alpha} \\rangle\r\n &=& i \\sqrt{\\frac{\\Delta t}{m}} \\frac{\\langle \\Psi_T |p_{j\\alpha}|RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle} \r\n \\nonumber\\\\\r\n &=& -\\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle}  \\,.\r\n \\end{eqnarray}\r\n The sampled value of $x_{j\\alpha}$ will be\r\n \\begin{equation}\r\n x_{j\\alpha} = \\chi_{j\\alpha} + \r\n \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle}\r\n \\end{equation}\r\n where the $\\chi_{j\\alpha}$ are sampled from a gaussian with unit variance.\r\n The new walker will be\r\n \\begin{equation}\r\n |R'S'\\rangle = e^{-\\frac{i}{\\hbar} \\sum_{j\\alpha} x_{j\\alpha}\r\n \t\\sqrt{\\frac{\\hbar^2 \\Delta t}{m}} p_{j\\alpha} }|R S\\rangle \\,.\r\n \\end{equation}\r\n Since\r\n $e^{-\\frac{i}{\\hbar} p_{j\\alpha} a}$ is the translation operator that\r\n translates the ket's $j\\alpha$ position coordinate by $a$.\r\n We have\r\n \\begin{eqnarray}\r\n S' &=& S\r\n \\nonumber\\\\\r\n R'_{j\\alpha} &=& R_{j\\alpha} + x_{j\\alpha}\\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\nonumber\\\\\r\n &=& R_{j\\alpha}+ \\chi_{j\\alpha} \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n +\r\n \\frac{\\hbar^2 \\Delta t}{m}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle}\r\n \\end{eqnarray}\r\n which is the standard diffusion Monte Carlo propagation. The weight factor\r\n is the local energy.\r\n \r\n \\subsection{Fixed-phase importance-sampled Diffusion Monte Carlo}\r\n \\label{sec:fixedph}\r\n The fixed-phase approximation\\cite{Ortiz93} was developed to extend the\r\n fixed-node approximation to electrons in a magnetic field where the\r\n ground-state wave function is complex. The approximation enforces the\r\n trial function's phase as the phase for the calculated ground state.\r\n Diffusion Monte Carlo is used to sample the magnitude of the ground\r\n state.\r\n \r\n If the walker phase has been chosen so that $\\langle \\Psi_T|R\\rangle$\r\n is real, the fixed-phase approximation requires that after propagation\r\n $\\langle \\Psi_T|R'\\rangle$ would also be real since an imaginary\r\n part would correspond to the calculated ground-state having a different\r\n phase than the trial function. Therefore in the implementation of the\r\n fixed-phase approximation\r\n we discard the imaginary part of the weight of a propagated walker.\r\n For an arbitrary initial phase, we discard the imaginary part of the\r\n ratio $\\frac{\\langle \\Psi_T|R'\\rangle}{\\langle \\Psi_T|R\\rangle}$ which\r\n means that the we replace the importance sampled factor in\r\n Eq. \\ref{eq.hsimp} with its real part\r\n \\begin{eqnarray}\r\n \\frac{\\langle \\Psi_T |\r\n \te^{-i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t} O_n}|R S\\rangle}\r\n {\\langle \\Psi_T|RS\\rangle}\r\n &\\rightarrow&\r\n \\nonumber\\\\\r\n {\\rm Re} \\left [ \\frac{\\langle \\Psi_T |\r\n \te^{-i\\sum_{n=1}^{N_O} x_n \\sqrt{\\lambda_n \\Delta t} O_n}|R S\\rangle}\r\n {\\langle \\Psi_T|RS\\rangle} \\right ] \\,.\r\n \\end{eqnarray}\r\n \r\n The fixed-phase algorithm for propagating a walker is then\r\n \\begin{enumerate}\r\n \t\\item\r\n \tPropagate to the new position (the spin does not change with a central\r\n \tpotential)\r\n \t\\begin{eqnarray}\r\n \tS' &=& S\r\n \t\\nonumber\\\\\r\n \tR'_{j\\alpha} &=&\r\n \tR_{j\\alpha}+ \\chi_{j\\alpha} \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \t+\r\n \t\\frac{\\hbar^2 \\Delta t}{m}\r\n \t{\\rm Re} \\left [ \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n \t{\\langle \\Psi_T |RS\\rangle} \\right ]\r\n \t\\nonumber\\\\\r\n \t\\end{eqnarray}\r\n \t\\item\r\n \tInclude a weight factor for the walker of\r\n \t\\begin{equation}\r\n \tW = e^{ -({\\rm Re} \\langle H\\rangle -E_T)\\Delta t}\r\n \t\\end{equation}\r\n \\end{enumerate}\r\n This is identical to the fixed-phase algorithm of Ortiz et al.\r\n \r\n We will see that similar approximations can be used for our spin-isospin\r\n dependent problems.\r\n \r\n \\subsection{Application to quadratic forms}\r\n \\label{sec.quad}\r\n Quadratic forms in operators that change from one walker to another\r\n can be diagonalized to produce the sum of squares needed for\r\n Eq. \\ref{eq.sumofsquares}. That is for\r\n \\begin{equation}\r\n H = \\frac{1}{2} \\sum_{ij} O_i A_{ij} O_j\r\n \\end{equation}\r\n with $A_{nm}$ real and symmetric, we can calculate the normalized\r\n real eigenvectors and eigenvalues of the matrix $A$,\r\n \\begin{eqnarray}\r\n \\sum_j A_{ij} \\psi_j^{(n)} &=& \\lambda_n |\\psi_i\\rangle\r\n \\nonumber\\\\\r\n \\sum_j \\psi_j^{(n)} \\psi_j^{(m)} &=& \\delta_{nm} \\,.\r\n \\end{eqnarray}\r\n The matrix is then\r\n \\begin{equation}\r\n A_{ij} = \\sum_n \\psi_i^{(n)} \\lambda_n\\psi_j^{(n)}\r\n \\end{equation}\r\n and substituting back we have\r\n \\begin{eqnarray}\r\n H = \\frac{1}{2} \\sum_n \\lambda_n {\\cal O}_n^2\r\n \\nonumber\\\\\r\n {\\cal O}_n = \\sum_j \\psi_j^{(n)} O_j \\,,\r\n \\end{eqnarray}\r\n which is now in the form of Eq. \\ref{eq.sumofsquares}.\r\n \r\n \\subsection{Auxiliary Field Breakups}\r\n There are many possible ways to break up the nuclear Hamiltonian using\r\n the auxiliary field formalism. As a concrete example let's look at\r\n the spinor propagator when we have a spin-exchange potential between $A$\r\n neutrons\r\n \\begin{equation}\r\n V = \\sum_{i<j}  v^{\\sigma}(r_{ij}) \\vec \\sigma_i \\cdot \\vec \\sigma_j\r\n \\end{equation}\r\n Taking the operators to be the $x$, $y$, and $z$ components of the\r\n Pauli operators for each particle, we have a quadratic form in these\r\n $3A$ operators. Since walker gives the positions of the neutrons, we know\r\n the value of $v^{\\sigma}(r_{ij})$ for all pairs. We can then write\r\n \\begin{equation}\r\n V = \r\n \\frac{1}{2} \\sum_{ij}^A B_{ij}\\sigma_{ix}\\sigma_{jx}\r\n +\\frac{1}{2} \\sum_{ij}^A B_{ij}\\sigma_{iy}\\sigma_{jy}\r\n +\\frac{1}{2} \\sum_{ij}^A B_{ij}\\sigma_{iz}\\sigma_{jz}\r\n \\end{equation}\r\n where $B_{ii} = 0$, and $B_{ij} = v^{\\sigma}(r_{ij})$ for  $i \\neq j$.\r\n Finding the eigenenvectors $\\psi^{(n)}_i$ and eigenvalues $\\lambda_n$\r\n of the $B$ matrix, we\r\n can write\r\n \\begin{eqnarray}\r\n V &=&\r\n \\frac{1}{2} \\sum_n \\lambda_n ({\\cal O}_{nx})^2\r\n +\\frac{1}{2} \\sum_n \\lambda_n ({\\cal O}_{ny})^2\r\n +\\frac{1}{2} \\sum_n \\lambda_n ({\\cal O}_{nz})^2\r\n \\nonumber\\\\\r\n {\\cal O}_{nx} &=& \\sum_{i=1}^A \\psi^{(n)}_i \\sigma_{ix}\r\n \\nonumber\\\\\r\n {\\cal O}_{ny} &=& \\sum_{i=1}^A \\psi^{(n)}_i \\sigma_{iy}\r\n \\nonumber\\\\\r\n {\\cal O}_{nz} &=& \\sum_{i=1}^A \\psi^{(n)}_i \\sigma_{iz} \\,.\r\n \\end{eqnarray}\r\n Using the Hubbard-Stratonovich transformation would give us $3A$ auxiliary\r\n fields.\r\n \r\n We can modify this transformation. For example, the diagonal\r\n elements of the $B$ matrix are zero. Adding a nonzero diagonal term $B_{jj}$,\r\n would give us additional terms proportonal to\r\n $\\sigma_{jx}^2 =\\sigma_{jy}^2 =\\sigma_{jz}^2 = 1$, that is,\r\n these would be additional purely central terms. Subtracting a corresponding\r\n central contribution would then give an identical interaction, but\r\n different eigenvectors and therefore different spin rotation operators.\r\n \r\n Another alternative would be to look at each term in the sum separately as\r\n a quadratic form of two operators. The resulting $2\\times 2$ matrices\r\n have two eigenvalues and eigenvectors so that\r\n \\begin{equation}\r\n v^\\sigma(r_{ij}) \\sigma_{ix} \\sigma_{jx}  =\r\n \\frac{1}{4} v^\\sigma(r_{ij})[\\sigma_{ix}+\\sigma_{jx}]^2\r\n -\\frac{1}{4} v^\\sigma(r_{ij})[\\sigma_{ix}-\\sigma_{jx}]^2\r\n \\end{equation}\r\n and each of the $3A(A-1)/2$ terms would require 2 auxiliary fields or\r\n $3A(A-1)$ total. We can reduce the number of auxiliary fields by including\r\n diagonal terms to our $2\\times 2$ matrix equal to the off diagonal terms.\r\n These make the eigenvector $(1,-1)/\\sqrt{2}$ have a zero eigenvalue,\r\n which then does not contribute\r\n \\begin{eqnarray}\r\n v^\\sigma(r_{ij}) \\sigma_{ix} \\sigma_{jx}  =\r\n \\frac{1}{2} v^\\sigma(r_{ij})[\\sigma_{ix}+\\sigma_{jx}]^2\r\n -v^\\sigma(r_{ij})\r\n \\end{eqnarray}\r\n where the second term on the right hand side\r\n is a central potential counter term that would be added\r\n to the physical central potential, and $3A(A-1)/2$ auxiliary fields\r\n would be required. This form could also be derived by expanding\r\n the square $[\\sigma_{ix}+\\sigma_{jx}]^2$.\r\n \r\n Each of these breakups gives the same net propagator after integration\r\n of the auxiliary fields. If a good importance function is used, and the\r\n sampling can be carried out, we would expect the local energy for a \r\n complete step to have low variance, and therefore the propagation to\r\n have low variance. The trade off then would be the complexity of constructing\r\n the operator combination versus the number of auxiliary fields needed\r\n in the propagation. In our work to date, we have used the full\r\n diagonalization to minimize the number of auxiliary field integrations.\r\n The cost of the diagonalization is order $A^3$ which is the same order\r\n as the cost for calculating a Slater determinant for the trial functions\r\n we need. However, it is easy to imagine having more complicated Hamiltonians\r\n where the cost of full diagonalization would be prohibitive (for example\r\n adding $\\Delta$ degrees of freedom to the nuclei) and a simpler breakup\r\n using more auxiliary fields would be more efficient.\r\n \r\n The best break up will be the one which optimizes the accuracy and variance\r\n of the results for a given amount of computational resources.\r\n \r\n \\subsection{AFDMC with the \\texorpdfstring{$v_6'$}{v\\textsixinferior'} potential for nuclear matter}\r\n The Argonne $v_6'$ potential includes central, spin and isospin exchange,\r\n and tensor interactions. Writing out the components, the Hamiltonian is\r\n \\begin{eqnarray}\r\n \\label{eq.hv6}\r\n H &=& \\sum_{i\\alpha} \\frac{p_{i\\alpha}^2}{2m}\r\n + \\sum_{i<j} v^c(r_{ij})\r\n + \\sum_{i<j,\\alpha\\beta} \\left \\{\r\n v^\\sigma(r_{ij})\\delta_{\\alpha\\beta}+v^t(r_{ij})\r\n \\left [  3 \\hat \\alpha \\cdot \\hat r_{ij}\r\n \\hat \\beta \\cdot \\hat r_{ij} -\\delta_{\\alpha\\beta} \\right] \\right \\}\r\n \\sigma_{i\\alpha}\\sigma_{j\\beta}\r\n \\nonumber\\\\\r\n &&\r\n + \\sum_{i<j,\\alpha\\beta\\gamma} \\left \\{\r\n v^{\\sigma\\tau}(r_{ij})\\delta_{\\alpha\\beta}+v^{t\\tau}(r_{ij})\r\n \\left [  3 \\hat \\alpha \\cdot \\hat r_{ij}\r\n \\hat \\beta \\cdot \\hat r_{ij} -\\delta_{\\alpha\\beta} \\right] \\right \\}\r\n [\\sigma_{i\\alpha}\\tau_{i\\gamma}][\\sigma_{j\\beta}\\tau_{j\\gamma}]\r\n + \\sum_{i<j,\\gamma}\r\n v^\\tau(r_{ij})\\tau_{i\\gamma}\\tau_{j\\gamma}\r\n \\end{eqnarray}\r\n where $\\alpha$ and $\\beta$ refer to the $x$, $y$, and $z$ components\r\n and $\\hat \\alpha$ $\\hat \\beta$ are the corresponding unit vectors.\r\n We work in a position basis. The potential is quadratic in\r\n the 15A spin-isospin operators\r\n $\\sigma_{i\\alpha}$, $\\tau_{i\\gamma}$, $\\sigma_{i\\alpha}\\tau_{i\\gamma}$.\r\n Since each spin-isospin operator can rotate the corresponding spin-isospinor\r\n the natural basis is the overcomplete basis of the outer product of these\r\n spin-isospinors -- one for each particle. A walker consists of an overall\r\n weight factor, and\r\n $x$, $y$, and $z$ coordinates\r\n and four\r\n complex numbers for the components of\r\n $|p\\uparrow\\rangle$, $|p\\downarrow\\rangle$,\r\n $|n\\uparrow\\rangle$, $|n\\downarrow\\rangle$ for\r\n each of the $A$ particles.\r\n \r\n \\subsubsection{The $v_6'$ Hamiltonian as a sum of operator squares}\r\n We now follow section \\ref{sec.quad} and define matrices\r\n \\begin{eqnarray}\r\n C^\\sigma_{i\\alpha,j\\beta} &=& \r\n v^\\sigma(r_{ij})\\delta_{\\alpha\\beta}+v^t(r_{ij})\r\n \\left [  3 \\hat \\alpha \\cdot \\hat r_{ij}\r\n \\hat \\beta \\cdot \\hat r_{ij} -\\delta_{\\alpha\\beta} \\right]\r\n \\nonumber\\\\\r\n C^{\\sigma\\tau}_{i\\alpha,j\\beta} &= &\r\n v^{\\sigma\\tau}(r_{ij})\\delta_{\\alpha\\beta}+v^{t\\tau}(r_{ij})\r\n \\left [  3 \\hat \\alpha \\cdot \\hat r_{ij}\r\n \\hat \\beta \\cdot \\hat r_{ij} -\\delta_{\\alpha\\beta} \\right]\r\n \\nonumber\\\\\r\n C^\\tau_{i,j} &=& v^\\tau(r_{ij})\r\n \\end{eqnarray}\r\n which have zero matrix elements when $i=j$. Their eigenvalues and\r\n normalized eigenvectors are defined as\r\n \\begin{eqnarray}\r\n \\sum_{j\\beta}\r\n C^\\sigma_{i\\alpha,j\\beta} \\psi^{\\sigma\\ (n)}_{j\\beta} &=& \\lambda^\\sigma_n\r\n \\psi^{\\sigma\\ (n)}_{i\\alpha}\r\n \\nonumber\\\\\r\n \\sum_{j\\beta}\r\n C^{\\sigma\\tau}_{i\\alpha,j\\beta} \\psi^{\\sigma\\ (n)}_{j\\beta} &=&\r\n \\lambda^{\\sigma\\tau}_n \\psi^{\\sigma\\tau\\ (n)}_{i\\alpha}\r\n \\nonumber\\\\\r\n \\sum_{j}\r\n C^{\\tau}_{i,j} \\psi^{\\tau\\ (n)}_{j} &=&\r\n \\lambda^{\\tau}_n \\psi^{\\tau\\ (n)}_{i}\r\n \\end{eqnarray}\r\n with operator combinations\r\n \\begin{eqnarray}\r\n O^\\sigma_n &=& \\sum_{i\\alpha} \\psi^{\\sigma\\ (n)}_{i\\alpha} \\sigma_{i\\alpha}\r\n \\nonumber\\\\\r\n O^{\\sigma\\tau}_{n\\beta} &=& \r\n \\sum_{i\\alpha} \\psi^{\\sigma\\tau\\ (n)}_{i\\alpha} \\sigma_{i\\alpha}\\tau_{i\\beta}\r\n \\nonumber\\\\\r\n O^\\tau_{n\\alpha} &=&\r\n \\sum_{i} \\psi^{\\tau\\ (n)}_{i} \\tau_{i\\alpha}\r\n \\end{eqnarray}\r\n The Hamiltonian becomes\r\n \\begin{eqnarray}\r\n H&=&\\sum_{i=1}^A\\sum_{\\alpha=1}^3 \\frac{p_{i\\alpha}^2}{2m}\r\n +\\sum_{i<j} v^{c}(r_{ij})\r\n +\\frac{1}{2} \\sum_{n=1}^{3A} \\lambda^\\sigma_n (O^\\sigma_n)^2\r\n \\nonumber\\\\\r\n &&\r\n +\\frac{1}{2} \\sum_{n=1}^{A}\\sum_{\\alpha=1}^3\r\n \\lambda^\\tau_n(O^\\tau_{n\\alpha})^2\r\n +\\frac{1}{2} \\sum_{n=1}^{3A} \\sum_{\\alpha=1}^3\r\n \\lambda^{\\sigma\\tau}_n(O^{\\sigma\\tau}_{n\\alpha})^2\r\n \\nonumber\\\\\r\n \\end{eqnarray}\r\n This is, of course, identical to the original Hamiltonian given in\r\n Eq. \\ref{eq.hv6}, but now it is in a form that makes the propagator\r\n easy to sample using auxiliary fields.\r\n \r\n \\subsubsection{Complex auxiliary fields}\r\n In realistic nuclear physics problems,\r\n the fermion sign problem necessarily becomes a phase problem\r\n since conservation of angular momentum requires that flipping a spin changes\r\n the orbital angular momentum, which induces an angular phase to the wave\r\n function. Various fixed-phase approximations can be used. The\r\n Hubbard-Stratonovich transformation integrates the auxiliary field over\r\n all real values with a gaussian weight. With importance sampling, the\r\n gaussian for $x_n$ is shifted by $i\\sqrt{\\lambda_n \\Delta t}\\langle O_n\\rangle$\r\n as shown in the last line of Eq. (\\ref{eq.hsimpexpanded}).\r\n As Zhang and Krakauer\\cite{Zhang2003} showed for electronic structure problems,\r\n it is equally valid to integrate the auxiliary field over any shifted\r\n contour, and by shifting the contour so that $x_n$ becomes complex\r\n and takes on the values\r\n $x_n  = z + i\\sqrt{\\lambda_n \\Delta t}\\langle O_n\\rangle$,\r\n $-\\infty < z < \\infty$. Integrating over these values does not change the\r\n result. However, now this factor is real. We implement the fixed phase\r\n approximation by taking the real part of $\\langle H \\rangle$.\r\n \r\n \r\n Note that this method cannot be used for the momentum operator. This is\r\n because the operator\r\n $e^{-\\frac{i}{\\hbar} p_{j\\alpha} a}$ is not bounded if $a$ has an imaginary\r\n part. We therefore implement the kinetic energy terms exactly as in the\r\n central potential fixed-phase approximation.\r\n \r\n There are of course other possible approximations that can be used. The\r\n auxiliary fields can be kept real. We find that the approximation is\r\n more accurate with Zhang-Krakauer prescription for auxiliary fields for\r\n the spin operators.\r\n \r\n \\subsubsection{The $v_6'$ algorithm}\r\n We can now give the complete algorithm used for the $v_6'$ potential.\r\n \\begin{enumerate}\r\n \t\\item\r\n \tWe begin with a set of walkers $|R_iS_i\\rangle$ which we sample from\r\n \tour trial function magnitude\r\n \tsquared, $|\\langle R S|\\Psi_T\\rangle|^2$, with Metropolis\r\n \tMonte Carlo. The walkers consist of the $3A$ coordinates of the\r\n \t$A$ particles, and $A$ 4-component normalized spinors.\r\n \t\\item\r\n \tFor each walker in turn we calculate the $C^\\sigma$, $C^\\tau$ and\r\n \t$C^{\\sigma\\tau}$ matrices, their eigenvalues, and their eigenvectors.\r\n \t\\item\r\n \tFrom the trial function and spinor values\r\n \twe evaluate $\\langle \\sigma_{j\\alpha}\\rangle$,\r\n \t$\\langle \\sigma_{j\\alpha}\\tau_{j\\beta}\\rangle$, $\\langle \\tau_{j\\alpha}\\rangle$,\r\n \t$\\langle p_{j\\alpha}\\rangle$, and $\\langle H\\rangle$.\r\n \t\\item\r\n \tWe sample the complex values for the spin-isospin auxiliary fields\r\n \t\\begin{equation}\r\n \tx_n  = \\chi_n + i\\sqrt{\\lambda_n \\Delta t}\\langle O_n\\rangle\r\n \t\\end{equation}\r\n \tand transform our walker spinors using\r\n \t\\begin{equation}\r\n \t|RS'\\rangle =\r\n \te^{-i\\sum_{n=1}^{N_O} x_n\\sqrt{\\lambda \\Delta t} O_n} |RS\\rangle\r\n \t\\end{equation}\r\n \tand normalize the spinors\r\n \t\\item\r\n \tWe sample the new positions from\r\n \t\\begin{equation}\r\n \tr_{j\\alpha}' = \r\n \tr_{j\\alpha}+ \\chi_{j\\alpha} \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \t+\r\n \t\\frac{\\hbar^2 \\Delta t}{m}\r\n \t{\\rm Re} \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n \t{\\langle \\Psi_T |RS\\rangle}\r\n \t\\end{equation}\r\n \t\\item\r\n \tThe weight of the new walker is given by\r\n \tW = $e^{- [{\\rm Re} \\langle H \\rangle - E_T]\\Delta t}$\r\n \t\\item\r\n \tWe branch on the walker weight, taking the number of new walkers\r\n \tto be the integer part of $W$ plus a uniform random value on $(0,1)$.\r\n \tIf the weight $W$ is negative, we discard the walker.\r\n \\end{enumerate}\r\n \r\n \\subsection{Isospin-independent spin-orbit interaction}\r\n \r\n Without isospin exchange, the spin orbit term for particles $j$ and $k$\r\n is\r\n \\begin{equation}\r\n \\frac{1}{4\\hbar}\r\n v_{LS}(r_{jk}) [(\\vec r_j-\\vec r_k) \\times (\\vec p_j-\\vec p_k)\r\n ]\\cdot ( \\vec\\sigma_j+\\vec \\sigma_k )\r\n \\end{equation}\r\n We can write the kinetic energy plus spin-orbit interaction Hamiltonian\r\n as\r\n \\begin{eqnarray}\r\n && \\sum_{j\\alpha} \\frac{p^2_{j\\alpha}}{2m} +\r\n \\frac{1}{4\\hbar}\\sum_{j<k}\r\n v_{LS}(r_{jk}) [(\\vec r_j-\\vec r_k) \\times (\\vec p_j-\\vec p_k)\r\n ]\\cdot ( \\vec\\sigma_j+\\vec \\sigma_k )\r\n \\nonumber\\\\\r\n &=& \\sum_{j\\alpha} \\frac{(p_{j\\alpha}+\\frac{m}{4\\hbar}\\sum_{k\\neq j}\r\n \tv_{LS}(r_{jk})\r\n \t[(\\vec \\sigma_j+\\vec \\sigma_k) \\times (\\vec r_j-\\vec r_k)]_\\alpha)^2}{2m}\r\n +V_{\\rm Counter}\r\n \\nonumber\\\\\r\n V_{\\rm Counter} &=& -\\frac{1}{2m} \\sum_{j\\alpha} \\left [\r\n \\frac{m}{4\\hbar}\\sum_{k\\neq j}\r\n v_{LS}(r_{jk})\r\n [(\\vec \\sigma_j+\\vec \\sigma_k) \\times (\\vec r_j-\\vec r_k)]_\\alpha \\right ]^2\r\n \\end{eqnarray}\r\n where the counter terms subtract off the unwanted interaction from\r\n completing the square.\r\n The counter terms do not depend on $\\vec p_j$, so they can be included\r\n with the rest of the local potential, and will contribute to the\r\n drift and the local energy for that part. However, we will see that the local\r\n energy part is canceled below (that is the final weight will be just the\r\n correct total local energy which does not include the counter terms).\r\n \r\n Using the Hubbard-Stratonovich break up with importance sampling, we have\r\n $\\lambda_{j\\alpha} = m^{-1}$, and\r\n \\begin{eqnarray}\r\n i\\sqrt{\\lambda_{j\\alpha}\\Delta t}\\langle O_{j\\alpha} \\rangle\r\n &=& -\\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle} +i \\sqrt{\\frac{m \\Delta t}{16 \\hbar^2}}\r\n \\sum_{k\\neq j}[(\\langle \\vec \\sigma_j\\rangle+\\langle \\vec \\sigma_k\\rangle)\\times\r\n \\vec r_{jk} ]_{\\alpha} v_{LS}(r_{jk})\\,.\r\n \\nonumber\\\\\r\n \\end{eqnarray}\r\n The sampled value of $x_{j\\alpha}$ will be\r\n \\begin{equation}\r\n x_{j\\alpha} = \\chi_{j\\alpha} + \r\n \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle}\r\n -i \\sqrt{\\frac{m \\Delta t}{16 \\hbar^2}}\r\n \\sum_{k\\neq j}[(\\langle \\vec \\sigma_j\\rangle+\\langle \\vec \\sigma_k\\rangle)\\times\r\n \\vec r_{jk} ]_{\\alpha} v_{LS}(r_{jk})\\,.\r\n \\end{equation}\r\n where our fixed-phase like approximation\r\n will modify this to keep the translation real, so that\r\n \\begin{equation}\r\n x_{j\\alpha} = \\chi_{j\\alpha} +  {\\rm Re}\\left \\{\r\n \\sqrt{\\frac{\\hbar^2 \\Delta t}{m}}\r\n \\frac{\\partial_{j\\alpha} \\langle \\Psi_T |RS\\rangle}\r\n {\\langle \\Psi_T |RS\\rangle}\r\n -i \\sqrt{\\frac{m \\Delta t}{16 \\hbar^2}}\r\n \\sum_{k\\neq j}[(\\langle \\vec \\sigma_j\\rangle+\\langle \\vec \\sigma_k\\rangle)\\times\r\n \\vec r_{jk} ]_{\\alpha} v_{LS}(r_{jk}) \\right \\}\\,.\r\n \\end{equation}\r\n The walker propagator is\r\n \\begin{eqnarray}\r\n |R'S'\\rangle = e^{-\\frac{i}{\\hbar} \\sum_{j\\alpha} x_{j\\alpha}\r\n \t\\sqrt{\\frac{\\hbar^2\\Delta t}{m}} p_{j\\alpha} }\r\n e^{i \\sum_{j\\alpha} x_{j\\alpha} \\sqrt{\\frac{m \\Delta t }{16\\hbar^2}}\r\n \t\\sum_{k\\neq j}[(\\vec \\sigma_j+ \\vec \\sigma_k)\\times\r\n \t\\vec r_{jk} ]_{\\alpha} v_{LS}(r_{jk}) }  |R S\\rangle\r\n \\end{eqnarray}\r\n \r\n The local energy term for the spin orbit will contain the kinetic energy,\r\n the spin orbit, and the negative of the counter terms. Therefore, the\r\n counter term contribution cancels in the weight, and the final weight is\r\n the local energy. \r\n \r\n \\section{GFMC with full spin-isospin summation}\r\n As mentioned above, current \r\n high quality trial wave functions for the coordinate space\r\n nuclear Hamiltonians require the same computational complexity to\r\n calculate either one or all of the spin-isospin amplitudes at a specified\r\n position for the particles. Very roughly for $A$ nucleons, each of which\r\n can be a proton or neutron with spin up or down, the number of\r\n spin-isospin amplitudes is $4^A$. Symmetries can lower\r\n this factor but not change its overall exponential character.\r\n \r\n Typically these calculations are done in either a good charge or good\r\n isospin basis. In a good charge basis, with $A$ nucleons, with $Z$ protons,\r\n the number of combinations of protons and neutrons is $\\frac{A!}{Z!(A-Z)!}$,\r\n while the tensor force can flip any of the spins so there are $2^A$ spin\r\n states. The total number of allowed spin-isospin states is\r\n the product of these factors. Sometimes the initial calculations are done\r\n with a Hamiltonian that conserves isospin and the charge symmetry breaking\r\n components are added perturbatively. In this case the number of states\r\n can be further reduced. Since $T_z = \\frac{2Z-A}{2}$, the number of\r\n isospin states $T$ states for a given $T_z \\le T$\r\n is given by the difference in the number\r\n of charge states with $T_z=T$ and $T_z=T+1$, which is\r\n $\\frac{A!}{(\\frac{A}{2}-T)!(\\frac{A}{2}+T)!}\\frac{2T+1}{\\frac{A}{2}+T+1}$.\r\n \r\n Time-reversal invariant states have a further factor of 2 reduction, since\r\n in that case, the time reversal operator\r\n \\begin{equation}\r\n {\\cal T} = \\left [ \\prod_{i=1}^A \\sigma_{ix}\\sigma_{iz}\\right ] K\r\n \\end{equation}\r\n relates the amplitudes of the states given by flipping all the spins.\r\n Here $K$ is the complex conjugating operator.\r\n \r\n Table \\ref{chapter9.t1}\r\n \\begin{table}\r\n \t\\begin{center}\r\n \t\\begin{tabular}{|c|c|c|c|c|}\r\n \t\t\\hline\r\n \t\tNucleus & Spin & Charge states & Total & Isospin/T Reversal\\\\\r\n \t\t\\hline\r\n \t\t$^4$He & 16 & 6 & 96 & 16\\\\\r\n \t\t$^8$Be & 256 & 70 & 17920 & 1792 \\\\\r\n \t\t$^{12}$C & 4096 & 924 & 3784704 & 270336 \\\\\r\n \t\t$^{16}$O & 65536 & 12870 & $8.4 \\times 10^8$ & $4.7 \\times 10^7$ \\\\\r\n \t\t\\hline\r\n \t\\end{tabular}\r\n \t\\end{center}\r\n \t\\caption{The number of spin-isospin amplitudes for the\r\n \t\tground states of some representative\r\n \t\tnuclei.}\r\n \t\\label{chapter9.t1}\r\n \\end{table}\r\n \r\n To see how this works, we can look at a straightforward generalization\r\n of a Jastrow-Slater trial state,\r\n \\begin{equation}\r\n |\\Psi_T\\rangle = \\left [ {\\cal S} \\prod_{i<j} \\sum_p\r\n f^{(p)}_{ij} O^{(p)}_{ij} \\right ] |\\Phi\\rangle\r\n \\end{equation}\r\n where $|\\Phi\\rangle$ is a model state, typically one or\r\n a small linear combination of antisymmetric\r\n products of single particle orbitals. The $p$ sum is over the\r\n same sort of operators as those in the potential (usually operators\r\n with gradients are either omitted or kept only at lowest order), with\r\n the Jastrow correlations $f^{(p)}_{ij}$ depending only on the spatial\r\n operator $|\\vec r_i - \\vec r_j|$, while the $O^{(p)}_{ij}$ contain\r\n spin-isospin operators and the unit vector operators\r\n $\\frac{\\vec r_i - \\vec r_j}{ |\\vec r_i - \\vec r_j|}$. The ${\\cal S}$\r\n is a symmetrizing operator applied to the Jastrow product, since\r\n the operators in general do not commute, so that the trial function\r\n is properly antisymmetric under interchange.\r\n \r\n To form a trial wave\r\n function we take the inner product with $\\langle R S|$ to obtain\r\n $\\Psi_T(R,S) = \\langle R S|\\Psi_T\\rangle$. The spatial operators\r\n operating to the left on their eigenstate $\\langle R S|$ are replaced\r\n by their eigenvalues. This leaves just the spin-isospin matrix elements.\r\n The model state is evaluated for all possible spin-isospin states as\r\n enumerated above, $\\langle R S'|\\Phi\\rangle$. In our spin-isospin\r\n basis, each of\r\n the operators $\\langle S''| O^{(p)}_{ij}|S'\\rangle$ is a sparse matrix which\r\n can either be tabulated or easily calculated as needed. For example,\r\n in the charge basis, acting on a single basis state, the interaction\r\n can change the spins of a pair to any of the 4 values. If the particles\r\n of the pair are a neutron and a proton, they can be interchanged. This\r\n shows that there are at most either 4 or 8 nonzero entries per row or\r\n column of the matrix representation. The construction of the Jastrow\r\n product is obtained by these repeated sparse-matrix multiplications.\r\n \r\n The symmetrizing operator has the factorial of the number of pairs\r\n terms. It would be prohibitive to calculate explicitly. However, the\r\n commutator terms are small, so the sum over orders of the operators\r\n is done by Monte Carlo sampling.\r\n \r\n Since much of the compuational time is spent in evaluating the trial\r\n wave functions, wave functions that include more complicated correlations\r\n as well as alpha particle clustering are often included. The simplest\r\n wave function above is adequate for the alpha particle.\r\n \r\n A GFMC calculation uses walkers given by positions for all the\r\n particles, and amplitudes for each of the possible spin-isospin\r\n states in the basis.\r\n \r\n In the simplest GFMC implementation, the so-called primitive approximation\r\n can be used. Here the propagator is \r\n \\begin{equation}\r\n \\left [\r\n \\prod_{i<j} e^{-\\tfrac{1}{2}\\tau \\sum_p v^{(p)}_{ij}} \r\n \\right ]\r\n e^{-\\tau \\sum_i \\frac{p_i^2}{2m}}\r\n \\left [\r\n \\prod_{i<j} e^{-\\tfrac{1}{2}\\tau \\sum_p v^{(p)}_{ij}} \r\n \\right ]\r\n \\end{equation}\r\n where the opposite order of the pairs is taken in the two products\r\n to minimize the time-step errors. The exponentials of the pair operators\r\n can be written as a linear combination of pair operators, and these\r\n are then operated on the walker states giving new amplitudes. The\r\n kinetic energy term is implemented by sampling a gaussian to give new\r\n positions.\r\n \r\n\r\n\\section{General projection algorithms in Fock space and non-local interactions}\r\nIn recent years, a number of projection algorithms working in a discrete Fock space (configuration \r\nspace) rather than in coordinate space have been proposed~\\cite{Booth09,Cleland10,Petruzielo12,Booth13,Mukherjee13,Roggero13}. While more similar to\r\nmore standard many-body techniques like Coupled Cluster (CC) and Many Body Perturbation Theory already covered in previous chapters\r\nthe adoption of statistical techniques in a configuration space has some advantage. First of all\r\nMonte Carlo techniques can be implemented with a much milder scaling with the system size enabling the\r\npossibility with a much larger number of basis states that build up the total Hilbert space. Contrary\r\nto eg. CC theory we can ensure that the final QMC estimate for the ground-state energy would\r\nbe an upper bound of the true eigenvalue, thus providing useful benchmark results. Also, working \r\non a finite many-body space allows practical calculations with non-local interactions, like those developed \r\nwithin the Chiral Effective Field Theory approach to nuclear forces, in a far more controllable way than not \r\nwith the continuous coordinate-space formulation exposed so far (as was done in~\\cite{Roggero14}).\r\nFinally, another great advantage of performing the Monte Carlo on a discrete Hilbert space is the possibility to\r\ndevise an efficient strategy to reduce the impact of the sign-problem by using cancellation techniques~\\cite{Booth09,Cleland10,Petruzielo12}\r\nin an analogous fashion to what was sketched at the end of Sec.~\\ref{sec:signprob}. Unfortunately we won't have space here to cover these aspects.\r\n\r\n\\subsection{Fock space formulation of Diffusion Monte Carlo}\r\n\\label{sec:cimc}\r\nTo set the stage let us take a finite set $\\mathcal{S}$ of single-particle (sp) states of size ${\\cal N}_s$ and \r\nconsider a general second--quantized fermionic Hamiltonian including two and possibly many--body interactions\r\n\\begin{equation}\r\n\\label{eqham}\r\nH=\\sum_{\\alpha \\in \\mathcal{S}} \\epsilon_\\alpha a^{\\dagger}_\\alpha a_\\alpha + \\sum_{\\alpha\\beta\\gamma\\delta\\in \\mathcal{S}} V_{\\alpha\\beta\\gamma\\delta} a^{\\dagger}_\\alpha a^{\\dagger}_\\beta a_\\delta a_\\gamma + \\dots \\;.\r\n%\\label{eqham}\r\n\\end{equation}\r\nIn this expression Greek letter indices indicates sp states (ie. $\\alpha$ is a collective label for all sp quantum \r\nnumbers), the operator $a^{\\dagger}_\\alpha$ ($a_\\alpha$) creates (destroys) a particle in the sp state $\\alpha$ \r\nand the $V_{\\alpha\\beta\\gamma\\delta}$ are general (anti--symmetrized) two-body interaction matrix elements:\r\n\\begin{equation}\r\n\\label{eq_ham}\r\nV_{\\alpha\\beta\\gamma\\delta} = \\langle \\alpha \\beta \\lvert \\hat{V} \\rvert \\gamma \\delta \\rangle - \\langle \\alpha \\beta \\lvert \\hat{V} \\rvert \\gamma \\delta \\rangle .% \\equiv \\langle i j \\vert \\vert a b \\rangle \r\n\\end{equation}.\r\nFor an $N$-fermion system the resulting Fock space would be spanned by the full set of $N$-particle \r\nSlater determinants that can be generated using the sp orbitals $\\alpha \\in \\mathcal{S}$. We will denote these \r\nSlater--determinants in the occupation number basis by $\\rvert \\mathbf{n} \\rangle$, where $\\mathbf{n} \\equiv \\{ n_\\alpha \\}$ and $n_\\alpha = 0,1$ \r\nare occupation number of the single--particle orbital $\\alpha$ satisfying $\\sum_\\alpha n_\\alpha=N$. For\r\nexample in a system composed by 2 identical fermions and with ${\\cal N}_s=4$ available sp states we will write\r\n\\begin{equation}\r\n\\rvert 0110 \\rangle \\equiv a^{\\dagger}_3 a^{\\dagger}_2 \\rvert 0\\rangle  \r\n\\end{equation}\r\nwhere $\\rvert 0 \\rangle$ is our vacuum state (that can be conveniently set to the Hartree-Fock ground state $\\Phi_{HF}$), while\r\n$a^{\\dagger}_2$ and $a^{\\dagger}_3$ creates a particle in sp state $2$ and $3$ respectively.\r\n\r\nWe can now use these states as a complete basis in our many--body Hilbert space and express a generic state in it as \r\n\\begin{equation}\r\n\\lvert \\Psi \\rangle = \\sum_{\\bf n} \\langle \\mathbf{n} \\vert \\Psi \\rangle \\lvert \\mathbf{n} \\rangle \\equiv \\sum_{\\bf n} \\Psi(\\bf{n}) \\lvert {\\bf n} \\rangle\r\n\\end{equation}\r\nwhere the sum is over all possible basis vectors that one can obtain from the ${\\cal N_S}$ single-particle orbitals.\r\n\r\nIt is important to notice at this point that no assumption is made on the locality of the \r\ninteraction, which translates into restrictions on the structure of the tensor $V_{\\alpha\\beta\\gamma\\delta}$. This \r\nshows already that possible non-local interactions can be cleanly incorporated in the formalism.\r\n\r\nAs was already introduced in Section~\\ref{sec:generaldmc}, the core idea behind a Diffusion Monte Carlo algorithm is\r\nto extract ground-state informations on the system by evolving in imaginary-time an initial guess for the lowest\r\neigenstate of the hamiltonian $H$: \r\n\\begin{equation}\r\n\\label{ci_evol}\r\n\\Psi_{\\tau + \\Delta\\tau} (\\mathbf{m}) = \\sum_{\\mathbf{n}} \\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle \\Psi_{\\tau} (\\mathbf{n}) .\r\n\\end{equation}\r\nwith a suitable projecton operator $P$ (cf. Eq.~(\\eqref{eq.afdmc}) and discussion above). \r\nIn order to illustrate how the evolution in \\eqref{ci_evol} can be implemented in a stochastic way, it will be usefull\r\nfirst to express the matrix elements of $P$ as follows\r\n\\begin{equation}\r\n\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle = p(\\mathbf{m},\\mathbf{n}) g(\\mathbf{n})\r\n\\end{equation}\r\nwith\r\n\\begin{equation}\r\n\\label{eq:CIMC_branching_factor}\r\ng(\\mathbf{n}) = \\sum_{\\mathbf{m}} \\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle \r\n\\end{equation}\r\nand\r\n\\begin{equation}\r\n\\label{eq:CIMC_prob}\r\np(\\mathbf{m},\\mathbf{n}) = \\frac{\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle}{\\sum_{\\mathbf{m}} \\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle }\r\n\\end{equation}.\r\nAt this point, provided the matrix elements $\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle \\geq 0$ we can interpret \r\n$p(\\mathbf{m},\\mathbf{n})$ for fixed $\\mathbf{n}$ as (normalized) probability distribution for the states $\\mathbf{m}$ and \r\n$g(\\mathbf{n})$ as a weight factor. This is analogous to what was done in Section~\\ref{sec:dmccoord} for the conventional coordinate--space formulations  \r\nwhere now $p$ takes the place of the gaussian Eq.~(\\eqref{eq:gaussprop}) while $g$ replaces the weight Eq.~(\\eqref{eq:propw}).\r\n\r\nImagine now that at a given imaginary--time $\\tau$ the wave--function $\\Psi_{\\tau}$ is non--negative in configuration \r\nspace\r\n\\begin{equation}\r\n\\Psi_{\\tau}(\\mathbf{n}) \\geq 0 \\forall\\mathbf{n} ,\r\n\\end{equation}\r\nthen we can represent it as an ensemble of configurations. Due to the non--negativity of the matrix elements of $P$, we also have\r\nthat the evolution described in \\eqref{ci_evol} preserves the signs\r\n\\begin{equation}\r\n\\Psi_{\\tau+\\Delta\\tau}(\\mathbf{m}) \\geq 0 \\; \\forall \\mathbf{m} .\r\n\\end{equation}\r\nThis suggests the following procedure for the stochastic imaginary--time evolution: \r\n\\begin{enumerate}\r\n \\item walker starts at configuration $\\mathbf{n}$ with weight $w(\\mathbf{n})$\r\n \\item a new configuration $\\mathbf{m}$ is chosen from the probability distribution $p(\\mathbf{m},\\mathbf{n})$\r\n \\item the walker's weight gets rescaled as $w(\\mathbf{n}) \\to w(\\mathbf{m})=w(\\mathbf{n})g(\\mathbf{n})$\r\n \\item reapeat from $1.$\r\n\\end{enumerate}\r\nIn order to improve efficiency one can include a {\\it branching} step where the new configuration in $\\mathbf{m}$\r\nis replicated according to its weight as explained in Sec.~\\ref{sec:dmccoord}.\r\n\r\nExpectation values of observables can then be estimated as usual (cf. Eq.~(\\eqref{eq:mixedobs})) with the mixed estimator\r\n\\begin{equation}\r\n\\begin{split}\r\n\\langle O\\rangle_{mixed} &= \\frac{\\langle \\Psi_T\\lvert O \\rvert \\Psi(\\tau)\\rangle}{\\langle \\Psi_T\\vert \\Psi(\\tau)\\rangle}= \\frac{  \\sum_l^{N_{w}} w(\\mathbf{m}_{l}) \\langle \\Psi_T\\lvert O \\rvert \\mathbf{m}_{l}\\rangle}{\\sum_l^{N_{w}}w(\\mathbf{m}_{l})\\Psi_T(\\mathbf{m}_{l})}\r\n\\end{split}\r\n\\end{equation} \r\nwhere $\\Psi_T$ is a trial state and the sums run over the walker population of size $N_w$.\r\n\r\nIn practice we have to choose some form for the evolution operator that appears in \\eqref{ci_evol}, a common choice in \r\ndiscrete spaces is on operator very similar to the one already encountered in the discussion of the Power Method Sec.~\\ref{sec:pm}:\r\n\\begin{equation}\r\n\\begin{split}\r\n\\label{eq:prop}\r\n\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle & = \\langle \\mathbf{m} \\lvert 1 - \\Delta\\tau \\left( H - E_T \\right) \\rvert \\mathbf{n} \\rangle \\\\\r\n& = \\delta_{\\mathbf{m},\\mathbf{n}} - \\Delta\\tau \\langle \\mathbf{m} \\lvert H - E_T \\rvert \\mathbf{n} \\rangle\r\n\\end{split}\r\n\\end{equation}\r\nwhere $E_T$ is an energy shift used in the simulation to preserve the norm of the solution (the constant $E_0$ introduced in Sec.~\\ref{sec:dmccoord}). \r\nConvergence to the ground--state by repeated application of the projector $P$ to the initial state $\\rvert \\Psi_0 \\rangle$\r\n\\begin{equation}\r\n\\vert\\Psi_{gs}\\rangle = \\lim_{M \\to \\infty} P^M \\vert \\Psi_0 \\rangle\r\n\\end{equation}\r\nis guaranteed provided that the eigenvalues of $P$ lie between $-1$ and $1$ in order to ensure the diagonal part remains positive definite.\r\nThis requirement translates into a condition on the imaginary-time step $\\Delta\\tau$ which has to satisfy the bound\r\n\\begin{equation}\r\n\\label{eq_bound_on_tau}\r\n\\Delta\\tau < 2/(E_{max}-E_{min}) \r\n\\end{equation}\r\nwhere $E_{max}$ and $E_{min}$ are respectively the maximum and minimum eigenvalue of $H$ in our finite basis. This upper bound becomes \r\ntighter and tighter as we increase the number of particle $N$ and/or the number of sp--states ${\\cal N}_s$. As a consequence the number $M$ of \r\niterations needed for convergence to the ground state increases dramatically. A way to deal with this problem is to\r\nemploy a different algorithm proposed in \\cite{Trivedi90} (see also \\cite{TenHaaf95,Sorella00} ) that allows us to sample directly \r\nfrom the exponential propagator\r\n\\begin{equation}\r\n\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle = \\langle \\mathbf{m} \\lvert e^{-\\Delta\\tau(H-E_T)} \\rvert \\mathbf{n} \\rangle\r\n\\end{equation}\r\nin analogy to Eq.~\\eqref{eq:gentauprop}, but now without any limitation on the choice of the imaginary time step $\\Delta \\tau$ that can be chosen\r\narbitrarily large. We leave the discussion of its details in Sec.~\\ref{sec:expprop}.\r\n\r\nIn our discussion so far we have assumed that the matrix elements on the projector that defines $p(\\mathbf{m},\\mathbf{n})$ in Eq.~(\\eqref{eq:CIMC_prob}) are\r\nactually positive definite. Under general circumstances however this is not the case. This clearly prevents the interpretation \r\nof $p({\\bf m},{\\bf n})$ as a probability distribution invalidating the naive approach employed above. In order to circumvent the problem we can use the same idea behind the\r\nfixed node (phase) approximation introduced in Sec.~\\ref{sec:fn}\r\n\r\nBefore continuing it is worth to mention that in principle one can still produce a stochastic evolution by absorbing the signs into the weight factor $g(\\mathbf{n})$\r\nwhile sampling off-diagonal moves using $\\left \\vert \\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle \\right\\vert$. However as briefly explained in Sec.~\\ref{sec:fn} \r\nthis is accompanied by an exponential decay of the signal to noise ratio as a function of the total projection time $\\tau = M \\Delta\\tau$. Recently it was shown \r\nthat by employing an annihilation step in the evolution this problem can be substantially alleviated \\cite{Booth09,Petruzielo12,Booth13}. At the end however these \r\nalgorithms have still an exponential scaling with system-size, though with a reduced exponent.\r\n\r\n\\subsection{Importance sampling and fixed-phase approximation}\r\n\\label{subsect:CCDMC-IS}\r\nAs we just mentioned, we can deal with the sign--problem in a way which is similar to standard coordinate--space QMC: we will use an initial ansatz $\\Phi_T$ \r\nfor the ground--state wave--function and use that to constrain the random walk in a region of the many--body Hilbert space where \r\n\\begin{equation}\r\n\\langle \\mathbf{m} \\lvert P \\rvert \\mathbf{n} \\rangle \\geq 0\r\n\\end{equation}\r\nis satisfied. In order for this scheme to be practical one needs a systematic way for reducing the bias coming from this approximation, e.g. we want the bias \r\nto go to zero as the ansatz $\\Phi_T$ goes towards the ground--state $\\Psi_{gs}$. That's exactly what is done in coordinate-space fixed-node(fixed-phase) QMC simulations \r\npresented in the previous sections.\r\n\r\nIn this derivation we will follow the work in \\cite{TenHaaf95,Sorella00} and generalize it to the case of complex--hermitian hamiltonians usually found in nuclear theory.\r\nSimilarly to what was done in Sec.~\\ref{sec:fixedph} the imaginary part of the solution is constrained to be the same of that of the trial wave--function\r\n\\begin{equation}\r\n\\Re [\\Psi^*(\\mathbf{n})\\Phi_T(\\mathbf{n})] = 0 \r\n\\end{equation}\r\nfor every distribution $\\Psi(\\mathbf{n})$ sampled in the random walk. In this expression $\\Re$ stands for the real part and $^*$ is complex--conjugation\r\n\r\nWe start by defining for any configurations $\\mathbf{n}$ and $\\mathbf{m}$ for which $|\\Phi_T(\\mathbf{n})| \\neq 0$ the following quantity:\r\n\\begin{equation}\r\n\\begin{split}\r\n\\label{CCDMC:ham_sign}\r\n\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} &= \\mbox{sign}\\; \\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T^*(\\mathbf{n})^{-1}\\right ]  \\\\\r\n &= \\mbox{sign} \\; \\frac{\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ]}{ \\lvert \\Phi_T (\\mathbf{n}) \\rvert ^2} = \\mathfrak{s}_{\\mathbf{n}\\mathbf{m}} .\r\n \\end{split}\r\n\\end{equation}\r\nNow define a one--parameter family of Hamiltonians $\\mathcal{H}_{\\gamma}$ defined over configurations $\\mathbf{n}$ (again such that\r\n$|\\Phi_T(\\mathbf{n})| \\neq 0$) with off--diagonal matrix elements given by\r\n\\begin{equation}\r\n  \\label{mh1}\r\n  \\langle \\mathbf{m} | \\mathcal{H}_{\\gamma} | \\mathbf{n} \\rangle  =\\left \\{ \\begin{array}{rl} -\\gamma \\langle \\mathbf{m} | H | \\mathbf{n} \\rangle&  \\quad    \\mathfrak{s}(\\mathbf{m},\\mathbf{n})  > 0 \\\\\r\n  \\langle \\mathbf{m} | H | \\mathbf{n} \\rangle&   \\quad  \\text{otherwise} \\end{array} \\right . \\;,\r\n\\end{equation}\r\nwhile the diagonal terms are\r\n\\begin{equation}\r\n\\begin{split}\r\n\\label{mh2}\r\n\\langle \\mathbf{n} | \\mathcal{H}_{\\gamma} | \\mathbf{n} \\rangle &= \\langle \\mathbf{n} | H | \\mathbf{n} \\rangle+ (1+\\gamma) \\displaystyle \\sum_{\\stackrel{ \\mathbf{m} \\neq\r\n\\mathbf{n}}{\\mathfrak{s}(\\mathbf{m},\\mathbf{n}) > 0}} \\mathfrak{s} (\\mathbf{m},\\mathbf{n})\\\\\r\n&= \\langle \\mathbf{n} | H | \\mathbf{n} \\rangle + \\sum_{\\mathbf{m}} h_{\\mathbf{m}\\mathbf{n}}\\\\\\;.\r\n\\end{split}\r\n\\end{equation}\r\nIn the limit where $\\gamma\\to-1$ we clearly recover the original Hamiltonian: \r\n\\begin{equation}\r\n\\mathcal{H}_{\\gamma = -1} \\equiv H .\r\n\\end{equation}\r\n\r\nWe proceed to define a corresponding family of propagators $\\mathcal{P}_{\\gamma}$ for configurations $\\mathbf{n}$ with $|\\Phi_T(\\mathbf{n})| \\neq 0$ by\r\n\\begin{equation}\r\n\\label{eq:CIMC_IS_prop}\r\n\\langle \\mathbf{m} \\lvert \\mathcal{P}_{\\gamma} \\rvert \\mathbf{n} \\rangle = \\delta_{\\mathbf{m},\\mathbf{n}} - \\Delta\\tau \\frac{\\Re \\left[ \\Phi^*_T(\\mathbf{m}) \\langle \\mathbf{m} \\lvert \\mathcal{H}_{\\gamma} - E_T \\rvert \\mathbf{n} \\rangle \\Phi_T(\\mathbf{n}) \\right]}{\\lvert \\Phi_T(\\mathbf{n}) \\rvert^2}\\; .\r\n\\end{equation}\r\nIt is clear now that for any $\\gamma \\geq 0$ we have \r\n\\begin{equation}\r\n\\langle \\mathbf{m} \\lvert \\mathcal{P}_{\\gamma} \\rvert \\mathbf{n} \\rangle \\geq 0 \r\n\\end{equation}\r\nand so the propagator $\\mathcal{P}$ is, by construction, free from the sign--problem. Performing the corresponding random--walk allows us to filter the state\r\n\\begin{equation}\r\n\\Phi_T(\\mathbf{n})\\phi_{\\gamma}^0(\\mathbf{n}) ,\r\n\\end{equation}\r\nwhere now $\\phi_{\\gamma}^0(\\mathbf{n})$ is the ground--state of the hamiltonian $\\mathcal{H}_{\\gamma}$. The ground--state energy $E_{\\gamma}$ \r\nobtained following this procedure can be proved (the proof is left to the Appendix) to be a strict upper bound for the true ground--state \r\nenergy $E_{0}$ of the true hamiltonian $H$. Moreover, this upper bound is tighter than the variational upper--bound provided by \r\n\\begin{equation}\r\nE_T = \\frac{\\langle \\Phi_T \\lvert H \\rvert \\Phi_T \\rangle}{\\langle \\Phi_T \\vert \\Phi_T \\rangle} \\ge E_0 .\r\n\\end{equation}\r\n\r\nAs you can show in Problem~\\ref{prob:egamma} any linear extrapolation of $E_{\\gamma}$ from any two values $\\gamma \\geq 0$ to $\\gamma = -1$ (which would correspond to the original hamiltonian) also\r\nprovides an upper--bound on $E_{gs}$ that is tighter than the individual $E_{\\gamma}$'s. A good compromise between the tightness of the upper--bound and the statistical noise in\r\nthe extrapolation is to choose two values of $\\gamma$: $0$ and $1$, thus giving the following energy estimator:\r\n\\begin{equation}\r\n\\label{cimc_extrap}\r\nE_{extr} = 2 E_{\\gamma=0} - E_{\\gamma=1}\r\n\\end{equation}\r\n\r\nTo ensure the success of the proposed method a good choice for the importance function $\\rvert \\Phi_T \\rangle$ is critical.\r\n\r\n% , we need a wave--function flexible enough to account for the relevant correlations\r\n% in the system and that at the same time can be evaluated sufficiently quickly on a computer.% In many strongly--interacting systems coupled--cluster theory provide an ansatz that fulfills the first criterion. \r\n\r\n\\subsection{Trial wave-functions from Coupled Cluster ansatz}\r\nAs have been pointed out before, a crucial role is played by the\r\nimportance function $\\Phi_T$ used to impose the constraint. This is especially true if we want\r\nto estimate expectation values of operators other than the energy (cf. discussion in Sec.~\\ref{sec:mixav}).\r\n\r\nFundamental prerequisites for a viable importance function are\r\n\\begin{enumerate}\r\n \\item enough flexibility to be able to account for the relevant correlations in the system\r\n \\item availability of an efficient way to evaluate its overlap with states explored during the random walk\r\n\\end{enumerate}\r\n\r\nWithin a Fock space formulation, an excellent choice for $\\Phi_T$ that satisfy the first requirement is given by the wave \r\nfunction generated in a Coupled Cluster calculation. Starting from a reference state,\r\nwhich usually is the Hartree-Fock solution of the problem, CC theory allows to\r\ninclude dynamical correlations into a new state as\r\n\\begin{equation}\r\n\\label{eq:ccwf}\r\n\\vert \\Psi_{CC}\\rangle = e^{\\hat{T}}\\vert \\Phi_{HF} \\rangle.\r\n\\end{equation}\r\nIn the above equation, correlations are introduced trough the excitation operator $\\hat{T}$ which\r\nin CC theory is hierarchically divided as \r\n\\begin{equation}\r\n\\hat{T}=\\hat{T}_1+\\hat{T}_2 + \\hat{T}_3+\\cdots \r\n\\end{equation}\r\ncounting the number of creation/annihilation operators that compose them. The first two terms are:\r\n\\begin{equation}\r\n\\hat{T}_1=\\sum_{\\alpha,\\beta \\in \\mathcal{S}} t_\\alpha^\\beta a^{\\dagger}_\\beta a_\\alpha\r\n \\;\\quad\\; \\hat{T}_2=\\frac{1}{4}\\sum_{\\alpha,\\beta,\\gamma,\\delta \\in \\mathcal{S}} t_{\\alpha\\beta}^{\\gamma\\delta} a^{\\dagger}_\\gamma a^{\\dagger}_\\delta a_\\alpha a_\\beta \\;\\;\\; \\cdots\r\n\\end{equation}\r\nThe final state $\\vert \\Psi_{CC}\\rangle$ will then be uniquely identified by the coefficients $t_\\alpha^\\beta$ and $t_{\\alpha\\beta}^{\\gamma\\delta}$ corresponding\r\nto single and double particle-hole excitations respectively. The exponentiated form of the CC wave-functions enables to effectively include\r\nsome correlations up to the maximum N-particle N-hole in a relatively compact way.\r\n\r\nBut is the wave--function in Eq.~(\\eqref{eq:ccwf}) also quick to evaluate?\r\nIn order to simplify the discussion we will focus here on the case of a homogeneous system \r\nthat can be described dropping the one-particle--one-hole excitation operator $\\hat{T}_1$ in \r\nthe expansion (which do not contribute due to translational invariance)\\footnote{Extension to singlets (p-h states) and triplets (3p-3h states) is simple}. \r\nIn this situation the lowest order of CC theory is the Coupled Cluster Doubles (CCD) approximation.\r\n\r\nTo set the notation, we will express a generic Slater-Determinant state describing an M-particle--M-hole state as\r\n\\begin{equation}\r\n\\rvert {\\bf m}\\rangle= a^\\dagger_{p_1}\\dots,a^\\dagger_{p_M}a_{h_1}\\dots,a_{h_M} \\vert \\Phi_{HF} \\rangle \\equiv \\; \\rvert \\Phi^{p_1,\\dots,p_M}_{h_1,\\dots,h_M} \\rangle.\r\n\\end{equation}\r\n%---------------------\r\nThe required amplitude can then be expressed as a superposition of $M-2$ particle/hole states\r\nthat can be generated from ${\\bf m}$. Eventually (the proof is tedious but straightforward) one obtains:\r\n\\begin{equation}\r\n\\label{eq:ccdeval}\r\n\\langle {\\bf m}\\vert \\Psi_{CC}\\rangle = \\sum_{\\gamma=2}^M\\sum_{\\mu<\\nu}^M (-1)^{\\gamma+\\mu+\\nu}t^{p_\\mu p_\\nu}_{h_1 h_\\gamma}\\Psi_{CC}^{M-2}\\left(\\substack{p_1,p_2,\\dots,p_{\\mu-1},p_{\\mu+1},\\dots,p_{\\nu-1},p_{\\nu+1},\\dots,p_M\\\\ h_2\\dots,h_{\\gamma-1},h_{\\gamma+1},\\dots,h_M}\\right)\r\n\\end{equation}\r\nassuming $p_1<p_2<\\dots<p_M$ and $h_1<h_2<\\dots<h_M$. The normalization is fixed in such a way that $\\langle \\Phi_{HF}\\vert \\Psi_{CC}\\rangle = 1$.\r\n\r\nOne way to implement Eq.~(\\eqref{eq:ccdeval}) is for instance trough a recursive function that takes as input some K-particle--K-hole state and \r\nreturns $1.0$ for $K=0$, the correct amplitude $t_{ij}^{ab}$ for $K=2$ and for $K>2$ calls itself again removing two particle and two hole states.\r\nClearly this approach becomes slow when states with large values of $K$ are sampled often during the random walk. Just to give an idea, for\r\ncalculations of pure neutron matter with soft Chiral EFT interactions we have $K\\leq6$ at densities $\\rho\\approx0.08 fm^{-3}$ (cf. discussion in~\\cite{Rrapaj16})\r\nand the calculation can be made very efficient.\r\n\r\nWithin CC theory the coefficients $t_{\\alpha\\beta}^{\\gamma\\delta}$ appearing in the equations above are to be obtained as the self--consistent solutions\r\nof the following non--linear equation:\r\n\\begin{equation}\r\n\\label{eq_CCD}\r\n\\langle \\Phi^{\\gamma\\delta}_{\\alpha\\beta} \\lvert \\hat{H} \\left( 1+\\hat{T}_2+\\frac{1}{2}\\hat{T}^2_2\\right) \\rvert\\Phi_{HF} \\rangle= \\left( \\frac{1}{4}\\sum_{\\alpha,\\beta,\\gamma,\\delta \\in \\mathcal{S}} \\langle \\alpha\\beta\\lvert\\rvert \\gamma\\delta\\rangle t_{\\alpha\\beta}^{\\gamma\\delta}\\right) t_{\\alpha\\beta}^{\\gamma\\delta}\r\n\\end{equation}\r\nwhere $\\langle \\alpha\\beta\\lvert\\rvert \\gamma\\delta\\rangle$ are the anti-symmetrized two-body matrix elements of the interaction defined in Eq.~(\\eqref{eq_ham}).\r\n\r\nSolving Eq.~(\\eqref{eq_CCD}) is in general a very expensive computational problem and within \r\nthe fixed--node approach all that matters are the signs in Eq.~(\\eqref{CCDMC:ham_sign}). It could \r\nthen be possible to find cheaper approximate ways to determine the doubles coefficients $t_{\\alpha\\beta}^{\\gamma\\delta}$ \r\nwhile still preserving a good quality in the fixed--node approximation. A quite precise and very\r\ncheap approximation that have been used successfully is to obtain the coefficients within second \r\norder Moeller--Plesset perturbation theory:\r\n\\begin{equation}\r\nt_{\\alpha\\beta}^{\\gamma\\delta} = \\frac{\\langle \\alpha\\beta\\lvert\\rvert \\gamma\\delta\\rangle }{\\eta_\\alpha+\\eta_\\beta-\\eta_\\gamma-\\eta_\\delta} \\quad  \\text{with} \\quad \\eta_i=\\epsilon_i+\\sum_{k\\in\\mathcal{S}} \\langle ik\\lvert\\rvert ik\\rangle\r\n\\end{equation}\r\nand $\\epsilon_i$ are the single particle energies appearing in the one body part of the Hamiltonian Eq.~(\\eqref{eqham}).\r\nThis is equivalent to truncating the self--consistent solution of \\eqref{eq_CCD} after the first iteration.\r\n\r\n\\subsection{Propagator sampling with no time-step error}\r\n\\label{sec:expprop}\r\nAs we pointed out before, in simulations employing the linear propagator \\eqref{eq:prop} raising the dimension of the basis set has a detrimental effect on the efficiency \r\nof the algorithm since in order to satisfy the bound Eq.~(\\eqref{eq_bound_on_tau}) we are forced to employ\r\nan exceedingly small time step. Moreover, in practice values of $\\tau$ much smaller than the\r\nmaximum value are usually employed due to the difficulty in obtaining reliable estimates of $E_{max}$ in realistic situations.\r\n\r\nTo further complicate the scenario, when lattice fixed-node(fixed-phase) methods are employed this maximum value is reduced even further because the diagonal\r\nmatrix elements of $P$ gets pushed towards the negative region by the addition of the sign--violating contributions $\\sum_{\\mathbf{m}} h_{\\mathbf{m}\\mathbf{n}}$ in Eq.~(\\eqref{mh2}). \r\nIf this method is used to control the sign--problem additional care has to be devoted in the choice of the time--step, greatly deteriorating the efficiency of the overall scheme.\r\n\r\nIn a discrete space however we can cope with the problem by using an algorithm firstly introduced by Trivedi and Ceperley~\\cite{Trivedi90}, which shares \r\nsimilarities with the Domains Green's Function Monte Carlo by Kalos, Levesque, and Verlet~\\cite{Kalos74}. The idea is to use directly (meaning sample from) the exponential propagator\r\n\\begin{equation}\r\n\\label{exp_prop}\r\nP^{exp}(\\tau,\\mathbf{m},\\mathbf{n}) = \\langle \\mathbf{m} \\lvert e^{-\\tau(H - E_T)} \\rvert \\mathbf{n}  \\rangle,\r\n\\end{equation}\r\nthat clearly has no problem with negative diagonal elements. These schemes usually come with the name of {\\it continuous--time} evolution.\r\n\r\nFor simplicity let us forget the sign--problem for the time being and imagine we are working with the positive-definite importance-sampled greens function \\eqref{eq:CIMC_IS_prop} \r\nwith $\\gamma=0$ and the corresponding Hamiltonian $\\widetilde{H}$ which then satisfies\r\n\\begin{equation}\r\n\\label{eq:hoffdpd}\r\n\\widetilde{H}_{\\mathbf{m},\\mathbf{n}} \\leq 0 \\quad\\quad \\forall \\; \\mathbf{m}\\neq \\mathbf{n} .\r\n\\end{equation}\r\nFurthermore, we will neglect the energy shift $E_T$ since its addition is straightforward.\r\n\r\nRecall that the propagator can be written as a product of a stochastic matrix $\\widetilde{p}_{\\mathbf{m},\\mathbf{n}}$ and a weight factor $\\widetilde{g}_{\\mathbf{n}}$ (cf. Sec.~\\ref{sec:cimc}):\r\n\\begin{equation}\r\n\\widetilde{P}_{\\mathbf{m},\\mathbf{n}}(\\Delta\\tau) = \\delta_{\\mathbf{m},\\mathbf{n}}- \\Delta  \\tau \\widetilde{H}_{\\mathbf{m},\\mathbf{n}} = \\widetilde{p}_{\\mathbf{m},\\mathbf{n}} \\widetilde{g}_{\\mathbf{n}}\r\n\\end{equation}\r\nwhere the two factors are given by:\r\n\\begin{equation}\r\n\\begin{split}\r\n\\widetilde{p}_{\\mathbf{m},\\mathbf{n}}&=\\frac{\\widetilde{P}_{\\mathbf{m},\\mathbf{n}}(\\Delta\\tau)}{\\widetilde{g}_{\\mathbf{n}}},\\\\\r\n\\widetilde{g}_{\\mathbf{n}} &= \\sum_{\\mathbf{m}} \\widetilde{P}_{\\mathbf{m},\\mathbf{n}}(\\Delta\\tau)=1-\\Delta\\tau E_L({\\mathbf{n}})\r\n\\end{split}\r\n\\end{equation}\r\nand in the last equation we have used the expression for the local energy\r\n\\begin{equation}\r\n\\label{eq:elocal}\r\nE_L({\\mathbf{n}}) = \\frac{\\langle \\Phi_T \\lvert H \\rvert \\mathbf{n}\\rangle}{\\langle\\Phi_T\\vert\\mathbf{n}\\rangle} = \\sum_\\mathbf{m} \\frac{\\Phi_T (\\mathbf{m}) \\langle\\mathbf{m}\\lvert H \\rvert \\mathbf{n}\\rangle}{\\Phi_T\\vert\\mathbf{n}\\rangle} \\equiv \\sum_\\mathbf{m} \\widetilde{H}_{\\mathbf{m},\\mathbf{n}} .\r\n\\end{equation}\r\n\r\nThe continuous--time limit is recovered by applying $M$ times $\\widetilde{P}(\\Delta\\tau)$ and letting $\\Delta \\tau \\to 0$ while preserving constant the product $\\tau=M\\Delta\\tau$:\r\n\\begin{equation}\r\n% \\begin{split}\r\n\\lim_{M \\to \\infty} \\widetilde{P}_{\\mathbf{m},\\mathbf{n}}(\\tau)^M = \\lim_{M \\to \\infty} \\left( 1 - \\frac{\\tau}{M}\\widetilde{H}_{\\mathbf{m},\\mathbf{n}} \\right)^{M}\r\n= \\lim_{\\Delta\\tau \\to 0} \\left( 1 - \\Delta\\tau \\widetilde{H}_{\\mathbf{m},\\mathbf{n}} \\right)^{\\frac{\\tau}{\\Delta\\tau}}\r\n= \\langle \\mathbf{m} \\lvert e^{-\\tau \\widetilde{H}} \\rvert \\mathbf{n} \\rangle .% = P^{exp}(\\tau,\\mathbf{m},\\mathbf{n}).\r\n% \\end{split}\r\n\\end{equation}\r\n\r\nNow note that if we let $\\Delta\\tau \\to 0$ the probability to make a diagonal move in a single step among the $M$ will accordingly go to $\\approx 1$, in fact:\r\n\\begin{equation}\r\n% \\begin{split}\r\nP_{diag} = \\frac{\\widetilde{P}_{\\mathbf{n},\\mathbf{n}}(\\Delta\\tau)}{\\widetilde{g}_{\\mathbf{n}}}\r\n= \\frac{1-\\Delta\\tau \\widetilde{H}_{\\mathbf{n},\\mathbf{n}}}{1-\\Delta\\tau E_L(\\mathbf{n})}\r\n\\xrightarrow{\\Delta\\tau \\to 0} 1\r\n% \\end{split}\r\n\\end{equation}\r\nsince the local--energy $E_L$ does not depend on the time step but just on the current configuration $\\mathbf{n}$. Accordingly, the probability of making $K$ consecutive diagonal moves will be:\r\n\\begin{equation}\r\n\\begin{split}\r\nP_{diag}^K &=\\left( \\frac{\\widetilde{P}_{\\mathbf{n},\\mathbf{n}}(\\Delta\\tau)}{\\widetilde{g}_{\\mathbf{n}}} \\right)^K = \\left( \\frac{1-\\Delta\\tau \\widetilde{H}_{\\mathbf{n},\\mathbf{n}}}{1-\\Delta\\tau E_L(\\mathbf{n})} \\right)^K\\\\\r\n&\\xrightarrow{K \\to \\infty} \\exp{\\left(\\tau (E_L(\\mathbf{n}) - \\widetilde{H}_{\\mathbf{n},\\mathbf{n}})\\right)} = \\exp{\\left(\\tau \\widetilde{H}^{off}_{\\mathbf{n}}\\right)} = f_{\\mathbf{n}}(\\tau)\r\n\\end{split}\r\n\\end{equation}\r\nwhere we have implicitly defined the off--diagonal sum \r\n\\begin{equation}\r\n\\label{eq:hoffd}\r\n\\widetilde{H}^{off}_{\\mathbf{n}} = \\sum_{\\mathbf{m}\\neq \\mathbf{n}} \\widetilde{H}_{\\mathbf{m},\\mathbf{n}} <0\r\n\\end{equation}\r\nand the inequality holds thanks to Eq.~(\\eqref{eq:hoffdpd}).\r\n\r\nThe elapsed time between consecutive off--diagonal moves is therefore distributed as an exponential \r\ndistribution $f_{\\mathbf{n}}(\\tau)$ with average time given by\r\n\\begin{equation}\r\n\\int_{0}^{\\infty} \\tau f_{\\mathbf{n}}(\\tau) = -\\frac{1}{\\widetilde{H}^{off}_{\\mathbf{n}}} = \\left\\vert \\frac{1}{\\widetilde{H}^{off}_{\\mathbf{n}}}\\right\\vert .\r\n\\end{equation}\r\nWe can then sample the time when the off-diagonal move happens by using a transformation technique: suppose we have a way to sample values $\\xi$ from a uniform distribution \r\n$g(\\xi) = \\text{const}$, due to conservation of probability the samples $\\tau$ drawn from the wanted $f_{\\mathbf{n}}(\\tau)$ will satisfy:\r\n\\begin{equation}\r\n\\label{eq_cdfsampling}\r\n\\vert f(\\tau) d\\tau \\vert = \\vert g(\\xi) d\\xi \\vert \\quad \\longrightarrow \\left\\vert \\frac{d \\xi(\\tau)}{d \\tau} \\right\\vert = f_{\\mathbf{n}}(\\tau)\r\n\\end{equation}\r\nwhere $\\tau$ are the samples drawn from the wanted PDF $f_{\\mathbf{n}}$. By solving now equation \\eqref{eq_cdfsampling} for $\\xi(\\tau)$ and performing the inversion to\r\n$\\tau=\\tau(\\xi)$ we obtain the following relation\r\n\\begin{equation}\r\n\\label{sampled_tau}\r\n\\tau_{\\xi}=\\frac{log(\\xi)}{\\widetilde{H}^{off}_{\\mathbf{n}}}.\r\n\\end{equation}\r\nthat allows to sample exactly from $f_{\\mathbf{n}}$ using only samples from a uniform distribution $\\xi \\in (0,1)$.\r\n\r\nWalkers undergoing such random walk accumulate weight during the $K$ diagonal--moves as well as from performing the off--diagonal step. The weight coming from the diagonal\r\nmoves is given by\r\n\\begin{equation}\r\nw_{\\mathbf{n}}=\\widetilde{g}_{\\mathbf{n}}^K = \\left( 1-\\Delta\\tau E_L(\\mathbf{n})\\right)^K \\xrightarrow{\\Delta\\tau \\to 0} e^{-\\tau E_L(\\mathbf{n})}.\r\n\\end{equation}\r\nFor the off--diagonal moves instead we have at least two options for sampling the new state $\\rvert \\mathbf{m}\\rangle$:\r\n\\begin{itemize}\r\n \\item heat-bath sampling: \r\n \\begin{equation}\r\n \\label{eq:heba}\r\nP_1(\\mathbf{m},\\mathbf{n})=\\widetilde{H}_{\\mathbf{m},\\mathbf{n}}/ \\widetilde{H}^{off}_{\\mathbf{n}}  \r\n \\end{equation} \r\n\\begin{enumerate}\r\n \\item new configuration $\\rvert \\mathbf{m}\\rangle$ is chosen using the normalized probability $P_1$\r\n \\item the off-diagonal weight would be $w_{\\mathbf{m},\\mathbf{n}}=1$\r\n\\end{enumerate}\r\n\r\n \\item uniform sampling: \r\n \\begin{equation}\r\nP_2(\\mathbf{m},\\mathbf{n})=1/N_{conn}\r\n\\end{equation}\r\n\\begin{enumerate}\r\n \\item new configuration $\\rvert \\mathbf{m}\\rangle$ is chosen among the $N_{conn}$ states connected to $\\rvert\\mathbf{n}\\rangle$\r\n \\item reweight the new walker using $w_{\\mathbf{m},\\mathbf{n}} = P_1(\\mathbf{m},\\mathbf{n})/P_2(\\mathbf{m},\\mathbf{n})$\r\n\\end{enumerate}\r\n\\end{itemize}\r\n\r\nThe first option is clearly more expensive per iteration than the second since an explicit calculation of the off-diagonal sum $\\widetilde{H}^{off}_{\\mathbf{n}}$ is \r\nneeded in order to normalize $P_1$. In the uniform sampling case however the weights $w_{\\mathbf{m},\\mathbf{n}}$ can have large fluctuations\r\nforcing the use of smaller time-steps to keep them under control. In our case since we already need to compute the off-diagonal\r\nsum in order to generate the fixed-phase hamiltonian Eq.~(\\eqref{mh1}) and Eq.~(\\eqref{mh2}) the heat-bath sampling comes with no additional\r\ncost. It is worth noting that other choice can be made that are more efficient when fixed-node(phase) is not employed at all \\cite{Holmes16}\r\nor when the transformation that produces $\\mathcal{H}_\\gamma$ is carried out only approximately \\cite{Kolodrubetz12}.\r\n\r\nFinally, in order for the measurements along the path to be unbiased we want to define equidistant \"time-slices\" along the random walk. In \r\norder to this we simply choose a target time-step $\\tau_t$ at the beginning then for each move we first sample a value of $\\tau_{\\xi}$ \r\nfrom Eq.~(\\eqref{sampled_tau}), if $\\tau_{\\xi} > \\tau_t$ we set $\\tau=\\tau_t$ and use correspondingly a diagonal move if instead $\\tau_{\\xi} < \\tau_t$ \r\nwe have to sample an off--diagonal move. The process is preformed until the sum of all the sampled $\\tau_{\\xi}$ reaches the target time $\\tau_t$. \r\nThe final algorithm for a single walker at $\\rvert \\mathbf{n}\\rangle$ is then as follows: \r\n\\begin{svgraybox}\r\n\\begin{algorithmic} \r\n\\State{EXP\\_Move()}\r\n\\State{$\\tau=\\tau_t$}\r\n\\Loop\r\n  \\State{$E_L(\\mathbf{n}) = \\sum_\\mathbf{m} \\widetilde{H}_{\\mathbf{m},\\mathbf{n}}$}\r\n  \\Comment{Eq.~\\eqref{eq:elocal}}\r\n  \\State{$\\widetilde{H}^{off}_\\mathbf{n} = E_L(\\mathbf{n}) - \\widetilde{H}_{\\mathbf{n},\\mathbf{n}}$}\r\n  \\Comment{Eq.~\\eqref{eq:hoffd}}\r\n  \\State{$\\xi = \\text{rand}()$}\r\n  \\State{$\\tau_\\xi=log(\\xi)/\\widetilde{H}^{off}_\\mathbf{n}$}\r\n  \\Comment{Eq.~\\eqref{sampled_tau}}\r\n  \\If{$\\tau_\\xi\\geq\\tau$}\r\n    \\State{$w(\\mathbf{n})\\to w(\\mathbf{n}) \\exp{\\left(-\\tau \\;E_L(\\mathbf{n})\\right)}$}\r\n    \\State{\\bf exit}\r\n  \\EndIf\r\n  \\State{$w(\\mathbf{n})\\to w(\\mathbf{n}) \\exp{\\left(-\\tau_\\xi \\;E_L(\\mathbf{n})\\right)}$}\r\n  \\State{$\\tau\\to\\tau-\\tau_\\xi$}\r\n  \\State{$\\mathbf{m} \\gets \\text{HeatBath}[P_1,\\mathbf{n}]$}%(\\mathbf{m},\\mathbf{n})=\\widetilde{H}_{\\mathbf{m},\\mathbf{n}}/\\widetilde{H}^{off}_{\\mathbf{n}}]$}\r\n%   \\State{Choose new state $\\mathbf{m}\\neq \\mathbf{n}$ according to $P_1(\\mathbf{m},\\mathbf{n})=\\widetilde{H}_{\\mathbf{m},\\mathbf{n}}/\\widetilde{H}^{off}_{\\mathbf{n}}$}\r\n  \\Comment{Eq.~\\eqref{eq:heba}}\r\n  \\State{$\\mathbf{n}\\to\\mathbf{m}$}\r\n\\EndLoop\r\n\\end{algorithmic}\r\n\\end{svgraybox}\r\nwhere the function $HeatBath[P,\\mathbf{n}]$ generates a new configuration according to the probability $P$ (eg. Eq.~(\\eqref{eq:heba})) starting \r\nfrom the current state $\\mathbf{n}$. In Problem~\\ref{prob:heatbath} you will try to devise an implementation of this function.\r\n\r\nAs a final remark, it is evident that the most expensive part of the algorithm is the computation of the local energy $E_L(\\mathbf{n}$ since it will require\r\na sum over all states connected to $\\mathbf{n}$ from the Hamiltonian and for each one $\\mathbf{m}$ of these we have to compute both the matrix element of \r\nthe Hamiltonian and the overlap with the trial function $\\Psi_T(\\mathbf{m})$. The use of symmetries to reduce the size of the sum is thus\r\nof fundamental importance to reach medium-sized systems. We can show this for the simple case of a homogeneous system with only two-body interactions\r\nso that the connected states will be all the possible 2-particle--2-hole excitations that can be obtained from the initial state $\\rvert\\mathbf{n}\\rangle$.\r\nNeglecting the construction of the transformed matrix $\\widetilde{H}$, we can then implement the calculation of the local energy as\r\n\\begin{svgraybox}\r\n\\begin{algorithmic} \r\n\\State{EL\\_calc1()}\r\n\\State{$E_L=0$}\r\n\\For{$i\\in occ(\\mathbf{n})$}\r\n  \\For{$j\\in occ(\\mathbf{n})$}\r\n    \\For{$a\\in \\mathcal{S}\\setminus occ(\\mathbf{n})$}\r\n      \\For{$b\\in \\mathcal{S}\\setminus occ(\\mathbf{n})$}\r\n        \\State{$\\rvert \\mathbf{m} \\rangle = a^{\\dagger}_a a^{\\dagger}_b a_i a_j \\rvert \\mathbf{n}\\rangle$}\r\n        \\State{$E_L = E_L + \\widetilde{H}_{\\mathbf{m},\\mathbf{n}}$}\r\n      \\EndFor\r\n    \\EndFor\r\n  \\EndFor\r\n\\EndFor\r\n\\State{$E_L=E_L/4$}\r\n\\end{algorithmic}\r\n\\end{svgraybox}\r\nwhere $occ(\\mathbf{n})$ is the set of single-particle states that are occupied in the initial state $\\mathbf{n}$. The above algorithm requires $O(N_{occ}^2{\\cal N}_s^2)$\r\nevaluations of the Hamiltonian. Many of these are however equivalent to other ones or just zero. For instance all the terms with $i=j$ or $a=b$ give zero\r\ndue to the Pauli principle. If we fix an ordering of the single particle orbitals in the many--body states and use anti-symmetrized matrix elements the configurations \r\nobtained interchanging eg. $i\\leftrightarrow j$ are equivalent. Finally if both momentum and spin are conserved, given the triple $(i,j,a)$ there exist only one single\r\nparticle state $b$ allowed. An implementation like\r\n\\begin{svgraybox}\r\n\\begin{algorithmic} \r\n\\State{EL\\_calc2()}\r\n\\State{$E_L=0$}\r\n\\For{$i\\in occ(\\mathbf{n})$}\r\n  \\For{$j<i\\in occ(\\mathbf{n})$}\r\n    \\For{$a\\in \\mathcal{S}\\setminus occ(\\mathbf{n})$}\r\n      \\State{$b\\gets FourthState[i,j,a]$}\r\n      \\If{$b\\in\\mathcal{S}\\setminus occ(\\mathbf{n})\\;$ \\bf{and} $\\;b<a$}\r\n        \\State{$\\rvert \\mathbf{m} \\rangle = a^{\\dagger}_a a^{\\dagger}_b a_i a_j \\rvert \\mathbf{n}\\rangle$}\r\n        \\State{$E_L = E_L + \\widetilde{H}_{\\mathbf{m},\\mathbf{n}}$}\r\n      \\EndIf\r\n    \\EndFor\r\n  \\EndFor\r\n\\EndFor\r\n\\end{algorithmic}\r\n\\end{svgraybox}\r\nwill take now only $O(N_{occ}^2{\\cal N}_s)$ evaluations of the Hamiltonian at most, and with a reduced prefactor with respect to the previous version. The function $FourthState$ returns \r\nthe only single particle state allowed by simmetry. \r\n\r\n\\subsection{Results}\r\nThe combination of imaginary time projection, use of importance function derived from CC calculations and no time-step error propagator make up the algorithm that goes under the name of Configuration Interaction Monte Carlo (CIMC).\r\nActual calculations with CIMC require a substantial amount of CPU time. Here we report some results obtained by making use of a simplified Hamiltonian in which the nucleon-nucleon interaction is described by the Minnesota interaction.\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/cimc_convergence.eps}\r\n\t\\end{center}\r\n\t\\caption{Convergence of the CIMC energies as a function of the number of shells used for a periodic cell of 66 neutrons at different densities.}\r\n\t\\label{fig.cimc_conv}\r\n\\end{figure}\r\nThe system under investigation is homogeneous pure neutron matter (PNM). In QMC calculations PNM is typically modeled as a periodic system containing A neutrons. The cell size is adjusted in such a way that the average density of the system is $\\rho$.\r\n\r\nIn Fig. \\ref{fig.cimc_conv} we show how the computed energy depends on the number of plane wave shells included in the model space. As it can be seen, it is necessary to pay attention to the convergence of th results, which can strongly depend on the specific details of the system. In this case, for instance, one can easily see how convergence is faster when the density is increased. \r\n\r\n\\begin{figure}\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=0.5]{Chapter9-figures/cimcccd.pdf}\r\n\t\\end{center}\r\n\t\\caption{Equation of state of neutron matter modeled as a periodic cell containing A=66 neutrons using the CIMC method and coupled cluster theory with doubes correlations. Single-particle states up to $N_{\\mathrm{max}}=36$ have been included.}\r\n\t\\label{fig.cimc_eos}\r\n\\end{figure}\r\n\r\nIn Fig. \\ref{fig.cimc_eos} the energy computed by CIMC shown for the same neutron matter model as a function of the density (the so called \"Equation of State\" of neutron matter) is compared with the coupled theory results with doubles (CCD) only discussed in the previous chapter. \r\nIn this calculation single-particle states up to $N_{\\mathrm{max}}=36$ have been used. The CIMCC and CCD results are converged to the fifth digit as function of \r\n$N_{\\mathrm{max}}$. The agreement between the two methods is at the level of the third digit after the decimal point for neutron matter with the \r\nMinnesota interaction. This is a striking agreement between such different many-body methods, in particular for larger densities where correlations and contributions from states above and below the Fermi level play a larger role, as seen from the difference between the reference energy and the CIMC and CCD energies.\r\nMost likely, there will be larger differences between different many-body methods when proton correlations are brought in, as well as when more realistic interaction models will be used. Such results will be presented elsewhere. In the next two chapters we will add results using two  additional many-body methods, the in-medium SRG approach described in chapter 10 and the Green's function approach of chapter 11.  \r\n\r\n\\section{Conclusions and perspectives}\r\n\r\nQuantum Monte Carlo methods are still one of the most powerful tools to attack general many body problems, and in particular the many-nucleon problem. Despite the fact that the Fermion sign problem prevents us so far from having strictly exact results for the solution of the Schr\\\"odinger equation, the accuracy that can be reached is very high, and in any cases it constitutes the current benchmark.\r\n\r\nAnother important general feature of QMC calculations is that they provide a very flexible framework in which it is possible to explore from low temperature condensed helium, to trapped fermions, from atoms and molecules ad solid state devices to nuclei and eventually lattice QCD. It is not rare that technical improvements spread across different disciplines, and the development of te method itself is a common ground that is often the subject of interdisciplinary workshops and conferences.  \r\n\r\nIn the field of nuclear physics it is possible that Fock-space based methods will eventually become the standard. Their main feature is the possibility of dealing with non-local interactions, which makes it possible to extend the use of QMC to the original formulations of $\\xi$-EFT potentials, and a whole class of soft-core interactions that so far have never been used in this context. On the other hand, the availability of more and more accurate versions of the AFDMC codes will open the access of accurate studies of the equation of state f neutron and nuclear matter, and of general baryonic matter of extreme importance for astrophysical applications, concerning in particular the physics of neutron stars. The possibility of extending accurate calculations to large $A$ systems is also crucial for understanding the phenomenology of exotic beams.\r\n\r\nIn this chapter we did not deal with the problem of evaluating excited states and dynamical quantities within a QMC framework. Several methods are nowadays available, mostly based on the evaluation of the Laplace transform of a given response function by means of the calculation of imaginary time correlation functions. Many technical advances have been recently made in this field (see e.g. Refs. \\cite{Galli, RoggeroHe, Lovato1,Lovato2}), and the subject is still under very active investigation. \r\n\r\nFinally, the hardest wall to climb remains the solution of the Fermion sign problem. Although there are claims that the problem is NP complete (which is true in general), thereby preventing any solution within standard classical computation, there are hints that many Hamiltonians of interest might admit a viable solution with polynomial scaling in $A$. This problem would definitely deserve more efforts than those that are presently devoted to its solution.  \r\n\\section{Problems}\r\n \\begin{prob}\r\n  Evaluate the following integral by means of the Metropolis algorithm\r\n  \\[\r\n  I=\\int_0^1 e^{x}-1\\, dx\r\n  \\]\r\n  sampling points from\r\n  \\begin{enumerate}\r\n  \t\\item P(x) = 1 for $x\\in[0,1]$\r\n  \t\\item P(x) = x for $x\\in[0,1]$\r\n  \\end{enumerate}\r\n  \\begin{itemize}\r\n  \t\\item\r\n  Compare the average and the statistical error for the cases 1) and 2). Which is the best estimate?\r\n  \\item\r\n  Try to figure out a way to sample a probability density proportional to $x^n$, and reevaluate the integral\r\n  $I$. How is the convergence and the statistical error behaving by increasing $n$? Try to give an explanation of the result.  \r\n  \\end{itemize}\r\n  \\end{prob}\r\n  \\begin{prob}\r\n  Try to sketch the general proof that for a generic integral $I$ defined as in problem 9.1 the best statistical error is obtained when sampling from a probability density proportional to F(x).\r\n  \\end{prob}\r\n  \\begin{prob}\r\n  Consider the one-dimensional Hamiltonian:\r\n  \\[\r\n  \\hat{H}=\\frac{1}{2}\\frac{d^2}{dx^2}+\\frac{1}{2}x^2\r\n  \\]\r\n  and consider the parametrized family of trial solutions $\\psi(x,\\alpha,\\beta)=e^{-\\alpha^2 x^2}-\\beta$. Compute by means of the  Metropolis algorithm the energy and the standard deviation of the energy as a function of $\\alpha$ keeping $\\beta=0.01$. Is the minimum found at the same value than for $\\beta =0$? Why?\r\n  \\end{prob}\r\n  \\begin{prob}\r\n  \tProve that the propagator defined in the integrand of Eq.(\\ref{free_propagator}) is the Green's function of the differential equation (\\ref{diffusion_eq}).\r\n  \\end{prob}\r\n  \\begin{prob}\r\n  \\label{prob:egamma}\r\n\tShow that the given two fixed-phase energies $E_{a}$ and $E_{b}$ obtained using the hamiltonians $\\mathcal{H}_{\\gamma}$ defined in Eq.~(\\eqref{mh1}) and Eq.~(\\eqref{mh2}) \r\n\twith $\\gamma=a$ and $\\gamma=b$ ($a,b\\geq 0$) the linear extrapolation to $\\gamma=-1$ (remember that $\\mathcal{H}_{-1}=H$) is still an upper bound. \r\n\t(Hint: show that $E_\\gamma$ is a convex function of the parameter $\\gamma$).\r\n  \\end{prob}\r\n  \\begin{prob}\r\n  \\label{prob:heatbath}\r\n        Implement the function $HeatBath[P,\\mathbf{n}]$ that appears in the algorithm EXP\\_Move() in Sec.~\\ref{sec:expprop}.\r\n  \\end{prob}\r\n\\begin{prob}\r\nIn the case of nuclear Hamiltonians spin is not a conserved quantity. Referring to the calculation of the local energy in Sec. 9.6.4, how would you modify the subroutine EL\\_calc2 to take into account the non-conservation of spin?\r\n\\end{prob}\r\n  \r\n\r\n\\section*{Appendix}\r\n\\addcontentsline{toc}{section}{Appendix}\r\nIn this appendix we give the proof of the upper--bound property for the auxiliary hamiltonians $\\mathcal{H}_{\\gamma}$, defined in Sec.~\\ref{subsect:CCDMC-IS}, for\r\nthe general complex--hermitian case (see \\cite{TenHaaf95} for the original proof in the real symmetric case).\r\nWe will concentrate in the simpler case $\\gamma=0$ in equations \\eqref{mh1} and \\eqref{mh2}, extension to the generic $\\gamma \\geq 0$ is then straightforward. In what follows\r\n we will use the shorthand $\\mathcal{H}_{\\gamma=0} \\equiv \\widetilde{H}$. Let $\\Psi(\\mathbf{n})$ be any arbitrary wave function, our goal is to show that \r\n\\begin{equation}\r\n\\Re [\\langle \\Psi \\lvert \\widetilde{H}\\rvert\\Psi \\rangle]\\geq\\Re\\left[ \\langle \\Psi |H|\\Psi \\rangle\\right]\\;. \r\n\\end{equation}\r\n\r\nLet us proceed by considering the following difference:\r\n\\begin{equation}\r\n\\begin{split}\r\n \\Re [\\langle \\Psi& \\lvert \\widetilde{H}\\rvert\\Psi \\rangle] -\\Re\\left[ \\langle \\Psi |H|\\Psi \\rangle\\right]=  \\sum_{\\mathbf{m}\\mathbf{n}} \\Re \\left[\\Psi^*(\\mathbf{m}) (\\widetilde{H}_{\\mathbf{m}\\mathbf{n}}-H_{\\mathbf{m}\\mathbf{n}})\\Psi(\\mathbf{n})\\right]\\\\ \r\n&= \\sum_{\\mathbf{m}\\mathbf{n}} h_{\\mathbf{m}\\mathbf{n}}  \\lvert\\Psi(\\mathbf{n})\\rvert^2 +\\sum_{\\mathbf{m}\\neq \\mathbf{n}}  \\Re \\left[\\Psi^*(\\mathbf{m}) (\\widetilde{H}_{\\mathbf{m}\\mathbf{n}}-H_{\\mathbf{m}\\mathbf{n}})\\Psi(\\mathbf{n})\\right]\\\\\r\n&= \\sum_{\\mathbf{n}} \\sum_{\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} \\neq -} \\lvert\\Psi(\\mathbf{n})\\rvert^2  \\frac{\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ]}{ \\lvert \\Phi_T (\\mathbf{n}) \\rvert ^2} - \\Re \\left [ \\Psi^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Psi(\\mathbf{n})\\right ]\\\\ \r\n%&= \\sum_n \\sum_{s_{mn} \\neq -} \\lvert\\Psi(n)\\rvert^2  (-p_{mn}) - \\Re \\left [ \\Psi^*(m) \\Phi(m) \\Phi(m)^{-1} H_{mn} \\Phi^*(n)^{-1}\\Phi^*(n)\\Psi(n)\\right ]\r\n\\end{split}\r\n\\end{equation}\r\nwhere the second sum is over all ${\\mathbf{m}\\mathbf{n}}$ pairs such that $\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}}$ of \\eqref{CCDMC:ham_sign} is positive--definite. The last term\r\n can now be rewritten as:\r\n\\begin{equation}\r\n\\begin{split}\r\n\\Re \\left [ \\Psi^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{\\mathbf{n}}} \\Psi(\\mathbf{\\mathbf{n}})\\right ] &= \\Re \\left [ \\Psi^*(\\mathbf{m}) \\Phi_T(\\mathbf{m}) \\Phi_T(\\mathbf{m})^{-1} H_{\\mathbf{m}\\mathbf{n}} \\Phi_T^*(\\mathbf{n})^{-1}\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n})\\right ]\\\\\r\n&= (\\Psi^*(\\mathbf{m}) \\Phi(\\mathbf{m}))\\Re \\left [\\Phi_T(\\mathbf{m})^{-1} H_{\\mathbf{m}\\mathbf{n}} \\Phi_T^*(\\mathbf{n})^{-1}\\right ] (\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n}))\\\\\r\n&= (\\Psi^*(\\mathbf{m}) \\Phi(\\mathbf{m}))\\Re \\left [\\frac{\\Phi_T^*(\\mathbf{m})}{\\lvert\\Phi_T(\\mathbf{m})\\rvert^2} H_{\\mathbf{m}\\mathbf{n}} \\frac{\\Phi_T(\\mathbf{n})}{\\lvert\\Phi_T(\\mathbf{n})\\rvert^2}\\right ] (\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n}))\\\\\r\n\\end{split}\r\n\\end{equation}\r\nwhere in the second step we used the fact that by employing a real propagator we are imposing a fixed--phase constraint,  ie $\\Im (\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n})) = 0$ for every $\\mathbf{n}$ explored in the random walk. The equation for the difference becomes:\r\n\\begin{equation}\r\n\\begin{split}\r\n \\Re [\\langle \\Psi& \\lvert \\widetilde{H}\\rvert\\Psi \\rangle] -\\Re\\left[ \\langle \\Psi |H|\\Psi \\rangle\\right]=  \\sum_{\\mathbf{m}\\mathbf{n}} \\Re \\left[\\Psi^*(\\mathbf{m}) (\\widetilde{H}_{\\mathbf{m}\\mathbf{n}}-H_{\\mathbf{m}\\mathbf{n}})\\Psi(\\mathbf{n})\\right]\\\\ \r\n&= \\sum_{\\mathbf{n}} \\sum_{\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} \\neq -} \\frac{\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ]}{ \\lvert \\Phi_T (\\mathbf{n}) \\rvert ^2}\\left( \\lvert\\Psi(\\mathbf{n})\\rvert^2  - \\frac{(\\Psi^*(\\mathbf{m}) \\Phi_T(\\mathbf{m}))  (\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n}))}{\\lvert\\Phi(\\mathbf{m})\\rvert^2 }\\right) \\;.\\\\\r\n\\end{split}\r\n\\end{equation}\r\n\r\nUsing again the fixed--phase constraint (ie. $(\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n})) \\equiv (\\Phi_T(\\mathbf{n})\\Psi^*(\\mathbf{n}))$) we can rewrite the numerator of the second term as:\r\n\\begin{equation}\r\n\\begin{split}\r\n(\\Psi^*(\\mathbf{m}) \\Phi_T(\\mathbf{m}))  (\\Phi_T^*(\\mathbf{n})\\Psi(\\mathbf{n})) &= -\\frac{1}{2} \\big( \\lvert \\Psi^*(\\mathbf{m}) \\Phi_T(\\mathbf{n}) - \\Phi_T^*(\\mathbf{m})\\Psi(\\mathbf{n})\\rvert^2 \\\\\r\n&\\quad- \\lvert \\Phi_T(\\mathbf{n})\\rvert^2\\lvert \\Psi(\\mathbf{m})\\rvert^2 -\\lvert \\Phi_T(\\mathbf{m})\\rvert^2\\lvert \\Psi(\\mathbf{n})\\rvert^2 \\big)\\\\\r\n\\end{split}\r\n\\end{equation}\r\nand then we have:\r\n\\begin{equation}\r\n\\begin{split}\r\n \\Re \\left[\\langle \\Psi \\lvert \\widetilde{H}\\rvert\\Psi \\rangle\\right] & -\\Re\\left[ \\langle \\Psi |H|\\Psi \\rangle\\right]=  \\sum_{\\mathbf{m}\\mathbf{n}} \\Re \\left[\\Psi^*(\\mathbf{m}) (\\widetilde{H}_{\\mathbf{m}\\mathbf{n}}-H_{\\mathbf{m}\\mathbf{n}})\\Psi(\\mathbf{n})\\right]\\\\ \r\n&= \\sum_{\\mathbf{n}} \\sum_{\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} \\neq -} \\frac{\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ]}{ \\lvert \\Phi_T(\\mathbf{n}) \\rvert ^2}\\bigg( \\lvert\\Psi(\\mathbf{n})\\rvert^2  + \\frac{ \\lvert \\Psi^*(\\mathbf{m}) \\Phi_T(\\mathbf{n}) - \\Phi_T^*(\\mathbf{m})\\Psi(\\mathbf{n})\\rvert^2}{2 \\lvert\\Phi_T(\\mathbf{m})\\rvert^2} \\\\  \r\n&- \\frac{ \\lvert \\Phi_T(\\mathbf{n})\\rvert^2\\lvert \\Psi(\\mathbf{m})\\rvert^2}{2\\lvert\\Phi_T(\\mathbf{m})\\rvert^2}- \\frac{ \\lvert \\Psi(\\mathbf{n})\\rvert^2}{2}\\bigg)\\\\\r\n&= (\\mbox{positive terms}) + \\sum_{\\mathbf{n}} \\sum_{\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} \\neq -} \\frac{\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ]}{ 2\\lvert \\Phi_T(\\mathbf{n}) \\rvert ^2}\\left( \\lvert\\Psi(\\mathbf{n})\\rvert^2  - \\frac{ \\lvert \\Phi_T(\\mathbf{n})\\rvert^2\\lvert \\Psi(\\mathbf{m})\\rvert^2}{\\lvert\\Phi_T(\\mathbf{m})\\rvert^2} \\right) \\\\  \r\n\\end{split}\r\n\\end{equation}\r\nNow we note that \r\n\\begin{equation*}\r\n\\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ] = \\Re \\left [ \\Phi_T^*(\\mathbf{n}) H_{\\mathbf{n}\\mathbf{m}} \\Phi_T(\\mathbf{m})\\right ]\r\n\\end{equation*}\r\nfor a complex--hermitian hamiltonian, we can then express the sums by allowing only unique $\\mathbf{m}\\mathbf{n}$ combinations:\r\n\\begin{equation}\r\n\\begin{split}\r\n \\Re \\left[\\langle \\Psi \\lvert \\widetilde{H}\\rvert\\Psi \\rangle\\right] & -\\Re\\left[ \\langle \\Psi |H|\\Psi \\rangle\\right]=  \\sum_{\\mathbf{m}\\mathbf{n}} \\Re \\left[\\Psi^*(\\mathbf{m}) (\\widetilde{H}_{\\mathbf{m}\\mathbf{n}}-H_{\\mathbf{m}\\mathbf{n}})\\Psi(\\mathbf{n})\\right]\\\\ \r\n&= (\\mbox{positive terms}) + \\\\\r\n&\\sum_{\\mathbf{n}} \\sum'_{\\mathfrak{s}_{\\mathbf{m}\\mathbf{n}} \\neq -} \\Re \\left [ \\Phi_T^*(\\mathbf{m}) H_{\\mathbf{m}\\mathbf{n}} \\Phi_T(\\mathbf{n})\\right ] \\bigg( \\frac{\\lvert\\Psi(\\mathbf{n})\\rvert^2}{2\\lvert\\Phi_T(\\mathbf{n})\\rvert^2} + \\frac{\\lvert\\Psi(\\mathbf{m})\\rvert^2}{2\\lvert\\Phi_T(\\mathbf{m})\\rvert^2}-\\\\\r\n& \\frac{ \\lvert \\Phi_T(\\mathbf{n})\\rvert^2\\lvert \\Psi(\\mathbf{m})\\rvert^2}{2\\lvert\\Phi_T(\\mathbf{m})\\rvert^2 \\lvert \\Phi_T(\\mathbf{n})\\rvert^2} - \\frac{ \\lvert \\Phi_T(\\mathbf{m})\\rvert^2\\lvert \\Psi(\\mathbf{n})\\rvert^2}{2 \\lvert \\Phi_T(\\mathbf{n})\\rvert^2\\lvert\\Phi_T(\\mathbf{m})\\rvert^2} \\bigg)\\\\\r\n&=  (\\mbox{positive terms})\r\n\\end{split}\r\n\\end{equation}\r\nwhich by definition is positive. The extension to the case with $\\gamma>0$ is straightforward since we are basically adding a positive constant to the difference.\r\n\r\n\\begin{thebibliography}{99.}%\r\n\\bibitem{Kalos08}\r\nM.H. Kalos and P.A Whitlock, {\\em Monte Carlo Methods} (Wiley-VCH, 2008)\r\n\\bibitem{Metropolis53}\r\nN. Metropolis, A. W. Rosenbluth, M. N. Rosenbluth, A. H. Teller and E. Teller,  J. Chem. Phys. {\\bf 21}, 1087 (1953)\r\n\\bibitem{Hastings70}\r\nW. K. Hastings,  Biometrika {\\bf 57}, 97 (1970)\r\n\\bibitem{Cep77}\r\nD. Ceperley, G. V. Chester, and M. H. Kalos, Phys. Rev. B {\\bf 16}, 3081 (1977)\r\n\\bibitem{Cyrus96}\r\nM.P. Nightingale and C.J. Umrigar, in \\emph{\"Recent Advances in Quantum Monte Carlo Methods\"}, edited by W.A. Lester, Jr., (World Scientific, 1996)\r\n\\bibitem{Toulouse07}\r\nJ. Toulouse and C. J. Umrigar,  J. Chem. Phys. {\\bf 126}, 084102 (2007)\r\n\\bibitem{Sorella01}\r\nS. Sorella,  Phys. Rev. B {\\bf 64}, 024512 (2001)\r\n\\bibitem{Sarsa00}\r\nA. Sarsa, K. E. Schmidt and W. R. Magro, J. Chem. Phys. {\\bf 113}, 1366 (2000)\r\n\\bibitem{Anderson76}\r\nJ. B. Anderson,  J. Chem. Phys. {\\bf 65}, 4121 (1976)\r\n\\bibitem{Troyer05}\r\nM. Troyer and U.-J. Wiese,  Phys. Rev. Lett. {\\bf 94}, 170201 (2005)\r\n\\bibitem{Kalos00}\r\nM. H. Kalos and F. Pederiva, Phys. Rev. Lett. {\\bf 85}, 3547 (2000)\r\n\\bibitem{Assaraf07}\r\nR. Assaraf, M. Caffarel and A. Khelif,  J. Phys. A Math. Theor. {\\bf 40}, 1181 (2007)\r\n\\bibitem{Ceperley80}\r\nD. M. Ceperley and B. J. Alder, Phys. Rev. Lett. {\\bf 45}, 566 (1980)\r\n\\bibitem{Foulkes01}\r\nW. M. C. Foulkes, L. Mitas, R. J. Needs, and G. Rajagopal, Rev. Mod. Phys. 73, 33 (2001)\r\n\\bibitem{Ortiz93}\r\nG. Ortiz, D. M. Ceperley, and R. M. Martin, Phys. Rev. Lett. {\\bf 71}, 2777 (1993)\r\n\\bibitem{carlson1993}\r\nJ. Carlson, V. R. Pandharipande, and R. Schiavilla,\r\nPhys. Rev. C {\\bf 47}, 484 (1993) \r\n\\bibitem{Zhang2003}\r\nS. Zhang and H. Krakauer,  Phys. Rev. Lett. {\\bf 90}, 136401 (2003)\r\n\\bibitem{Booth09}\r\nG. H. Booth, A. J. W. Thom, and A. Alavi,  J. Chem. Phys. {\\bf 131}, 054106 (2009)\r\n\\bibitem{Cleland10}\r\nD. Cleland, G. H. Booth, and A. Alavi, J. Chem. Phys. {\\bf 132}, 041103 (2010)\r\n\\bibitem{Petruzielo12} F. R. Petruzielo, A. A. Holmes, H. J. Changlani, M. P.\r\nNightingale, and C. J. Umrigar, Phys. Rev. Lett. {\\bf 109}, 230201 (2012)\r\n\\bibitem{Booth13}\r\nG. H. Booth, A. Gr\\\"uneis, G. Kresse, and A. Alavi, Nature\r\n{\\bf 493}, 365 (2013)\r\n\\bibitem{Mukherjee13}\r\nA. Mukherjee and Y. Alhassid,  Phys. Rev. A {\\bf 88}, 053622 (2013)\r\n\\bibitem{Roggero13}\r\nA. Roggero, A. Mukherjee, and F. Pederiva, Phys. Rev. B {\\bf 88}, 115138 (2013)\r\n\\bibitem{Roggero14}\r\nA. Roggero, A. Mukherjee, and F. Pederiva, Phys. Rev. Lett. {\\bf 112}, 221103 (2014)\r\n\\bibitem{Trivedi90}\r\nN. Trivedi and D. M. Ceperley, Phys. Rev. B {\\bf 41}, 4552 (1990)\r\n\\bibitem{Sorella00}\r\nS. Sorella and L. Capriotti,  Phys. Rev. B {\\bf 61}, 2599 (2000)\r\n\\bibitem{TenHaaf95}\r\nD. F. B. ten Haaf, H. J. M. van Bemmel, J. M. J. van Leeuwen, W. van Saarloos and D. M. Ceperley,  Phys. Rev. B {\\bf 51}, 13039 (1995)\r\n\\bibitem{Rrapaj16}\r\nE. Rrapaj, A. Roggero, and J. W. Holt, Phys. Rev. C {\\bf 93}, 065801 (2016)\r\n\\bibitem{Kalos74}\r\nM. H. Kalos, D. Levesque, and L. Verlet,  Phys. Rev. A {\\bf 9}, 2178 (1974)\r\n\\bibitem{Holmes16}\r\nA. Holmes, H. J. Changlani and C.J. Umrigar, J. Chem. Theory Comput. {\\bf 12}, 1561 (2016)\r\n\\bibitem{Kolodrubetz12}\r\nM. Kolodrubetz and B. K. Clark, Phys. Rev. B {\\bf 86}, 075109 (2012)\r\n\\bibitem{Galli}\r\nE. Vitali, M. Rossi, L. Reatto, and D. E. Galli,  Phys. Rev. B {\\bf 82}, 174510 (2010.\r\n\\bibitem{RoggeroHe}\r\nA. Roggero, F. Pederiva, and G. Orlandini, Phys. Rev. B {\\bf 88}, 094302 (2013)\r\n\\bibitem{Lovato1}\r\nA. Lovato, S. Gandolfi, R. Butler, J. Carlson, E. Lusk, S. C. Pieper, and R. Schiavilla,  Phys. Rev. Lett. {\\bf 111}, 092501, 2013\r\n\\bibitem{Lovato2}\r\nA. Lovato, S. Gandolfi, J. Carlson, S. C. Pieper, and R. Schiavilla, Phys. Rev. C {\\bf 91},062501(R) (2015)\r\n\\end{thebibliography}\r\n", "meta": {"hexsha": "cebab9c1a23ffeedddf6480d9ae8c2f28ec3ebba", "size": 200409, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/chapter9.tex", "max_stars_repo_name": "cpmoca/LectureNotesPhysics", "max_stars_repo_head_hexsha": "8e9f8c5d7f163ea10b14002850f7c79acc4513df", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2016-11-22T09:42:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T01:33:46.000Z", "max_issues_repo_path": "doc/src/chapter9.tex", "max_issues_repo_name": "cpmoca/LectureNotesPhysics", "max_issues_repo_head_hexsha": "8e9f8c5d7f163ea10b14002850f7c79acc4513df", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/chapter9.tex", "max_forks_repo_name": "cpmoca/LectureNotesPhysics", "max_forks_repo_head_hexsha": "8e9f8c5d7f163ea10b14002850f7c79acc4513df", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 25, "max_forks_repo_forks_event_min_datetime": "2016-05-24T22:54:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T00:08:19.000Z", "avg_line_length": 67.6600270088, "max_line_length": 1038, "alphanum_fraction": 0.7241491151, "num_tokens": 58687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.43200586027441495}}
{"text": "\\section{Ensemble Methods}\n\n\\smallskip \\hrule height 2pt \\smallskip\n\nVocab\n\\begin{itemize}\n\t\\item \\textbf{decision tree stump}: \n\t\\item \\textbf{decision stub}:  (used in lecture 10 pg 14: boosting)  ?? horizontal or vertical line only?  \n\t\\item \\textbf{axis aligned classifier}\n\\end{itemize}\n\nInstead of learning a single classifier, learn many weak classifiers that are good at different parts of the data. \nThe output class is a weighted vote of each classifier. \n\\begin{itemize}\n\t\\item classifiers that are most \"sure\" will vote with more conviction\n\t\\item classifiers will be most \"sure\" about a particular part of the space. \n\t\\item on average, these will do better than a single classifier. \n\\end{itemize}\n\n% transcribed understanding of audio from week 8\nThis is better than breaking up the space into a bunch of sub-spaces and making single classifiers for each.  \nIf you had single classifiers for sub-spaces, you would be losing information about the surroundings.\nIt is better to have all classifiers cover the whole space, but let them vote. \n\n\\subsection{Bagging vs Boosting}\n\\textbf{Bagging:} % http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning\n\\begin{itemize}\n\t\\item parallel ensemble: each model is built independently\n\t\\item aim to decrease variance, not bias\n\t\\item suitable for high variance low bias models (complex models)\n\t\\item \\textbf{samples are drawn with replacement}\n\t\\item each model in the ensemble vote with equal weight % https://en.wikipedia.org/wiki/Ensemble_learning\n\t\\item an example of a tree based method is random forest, which develop fully grown trees (note that RF modifies the grown procedure to reduce the correlation between trees)\n\\end{itemize}\n\n\\textbf{Boosting:}  % http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning\n\\begin{itemize}\n\t%\\item sequential ensemble: try to add new models that do well where previous models lack\n\t\\item \\textbf{incrementally building an ensemble by training each new model instance to emphasize the training instances that previous models mis-classified.} \n\t\\item aim to decrease bias, not variance\n\t\\item suitable for low variance high bias models\n\t\\item an example of a tree based method is gradient boosting\n\t\\item In some cases, boosting has been shown to yield better accuracy than bagging, but it also tends to be more likely to over-fit the training data. % https://en.wikipedia.org/wiki/Ensemble_learning\n\t\\item AdaBoost is the most common\n\\end{itemize}\n\n\n\\subsection{Bagging}\n\\textbf{\"Bagging\" = \\underline{B}ootstrap \\underline{AGG}regation.}\nFor $i = 1, 2, \\dots, K$:   (?? translate to english ??) \n\\begin{itemize}\n\t\\item $T_i \\leftarrow$ randomly select $M$ training instances with replacement.\n\t\\item $h_i \\leftarrow$ learn($T_i$)\n\\end{itemize}\nThen combine the $h_i$ together with uniform voting ($w_i = 1/K$ for all $i$).\n\n\\subsubsection{Example: CART decision boundary}\nCART is a decision tree learning algorithm. \\hfill \\\\\n\n100 bagged trees:  shades of blue/red indicate the strength of votes for particular classifications. \\hfill \\\\\nPicked random subsets of the data, and built classifiers.  These classifiers are weighted!! \\hfill \\\\  % week 8 audio\n?? (not the strength of different classifiers.)   \\hfill \\\\ \n?? Is white an overall uncertain vote ??   \\hfill \\\\ \n\\includegraphics[width=2in]{figures/100_bagged_trees.pdf} \\hfill \\\\\nApproximating the circle with a set of lines.  Piecewise linear functions. \\hfill \\\\ % wk 8 audio\nThe more trees you have, the smoother the boundary will be. \n\n\\subsubsection{Fighting the bias-variance tradeoff}\nSimple (a.k.a. weak) learners are good. \\hfill \\\\ \nExamples of weak learners we can use: \\hfill \\\\ \nNaive Bayes, logistic regression, perceptron, decision stumps, shallow decision trees, etc. \\hfill \\\\ \nThese learners have low variance; they don't usually overfit. \n\nBut simple (a.k.a. weak) learners are also bad: \\hfill \\\\ \nThey have high bias (high error), so you can't solve hard learning problems. \\hfill \\\\ \n\nThe solution: Boosting. \n\n\\subsection{Boosting}\n\n\\underline{TA summary:} \\hfill \\\\\nWe take a \"weak\" learner (e.g. a decision tree with depth 1), and learn the optimal classifier $h_1$. \nWe then reweight the data points, increasing the relative weight of the misclassified points, and learn an optimal classifier $h_2$ which is heavily biased against mislabelling the same points. \nWe repeat this process, and output a final classifier which uses a linear combination of the weak learners' predictions: $H(x) = sgn(\\sum_t \\alpha_t h_t(x))$. \nAlthough the weak learners may have high-bias, and therefore simple decision boundaries, the \"strong\" classifier can be a complicated decision boundary.\n\n\\begin{itemize}\n\t\\item Combine\tweak\tclassifiers\tto get very strong classifier.  \n\t\tThe weak classifiers only have to be slightly better than random on the training data. \n\t\tYou end up with a very strong classifier.  You can get zero training error. \n\t\\item AdaBoost is the most common algorithm\n\t\\item Similar to logistic regression:\n\t\t\\begin{itemize}\n\t\t\t\\item both linear models.  Boosting \"learns\" features.  \n\t\t\t\\item similar loss functions\n\t\t\t\\item single optimization (Logistic Regression) versus incrementally improving classification (Boosting) \n\t\t\\end{itemize}\n\t\\item  boosting with a weak classifier is better than using a fancy classifier. \n\t\tA boosted version will always do better than the vanilla one. \n\\end{itemize}\n\n\nAn approach to calculate the output using several different models and then average the result using a weighted average approach. \nBy combining the advantages and pitfalls of these approaches by varying your weighting formula you can come up with a good predictive force for a wider range of input data, using different narrowly tuned models.  % http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning\n\nBoosting is ensemble method. \\hfill \\\\\n\\underline{The idea}: given a weak learner, run it multiple times on (reweighted) training data, \n\tthen let the learned classifiers vote.  \\hfill \\\\\n\t\nOn each iteration $t$:\n\\begin{itemize}\n\t\\item weight each training example by how incorrectly it was classified.\n\t\\item learn a hypothesis: $h_t$\n\t\\item Use strength $\\alpha_t$ for this hypothesis. \n\\end{itemize}\nFinal classifier: $\\displaystyle h(x) = sign \\left( \\sum_i \\alpha_i h_i(x)  \\right)$ \\hfill \\\\\nThis is both useful in a practical sense and theoretically interesting. \n\nCan use boosting with any kind of classifier.  %https://www.youtube.com/watch?v=UHBmv7qCey4\n\n\\subsection{Bagging}\n\nStands for Bootstrap Aggregation. \\hfill \\\\\nThe way decrease the variance of your prediction by generating additional data for training from your original dataset using combinations with repetitions to produce multisets of the same cardinality/size as your original data. By increasing the size of your training set you can't improve the model predictive force, but just decrease the variance, narrowly tuning the prediction to expected outcome.  % http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning\n\n\\textbf{Bagging allows encoding a curvy decision boundary} with a bunch of weak classifiers. \\hfill \\\\\n \\hfill \\\\\n\nBy averaging a bunch of low bias, high variance functions, we can reduce the variance without significantly increasing the bias. \\hfill \\\\\n\nMaking a strong classifier out of a set of weak classifiers. \\hfill \\\\\n\\hfill \\\\\n\nWe should always avoid making hard decisions early.  % week 8 audo. \nSo don't put a lot of trust in classifiers early on in bagging. \nIf we did, the result might not generalize well.  \\hfill \\\\\n\nInstead, pay more attention to the ones you got wrong and less attention to the ones we got right.  % week 8 audio\n\nWe want instance based weighting, not classifier based weighting.  % week 8 audio\n\nWe want to have weights for each instance. \\hfill \\\\  \n\\underline{Protocol:}  % week 8 audio\n\\begin{itemize}\n\t\\item Start with uniform weights.  Each value is equally important. \n\t\\item Train classifier 1.  After this, instances are not equally important. \n\t\\item The points classifier 1 got correctly are now considered less important. \n\t\\item We want classifier 2 to be more worried about the ones that we got wrong. \n\\end{itemize}\n\n\\subsubsection{Example}\n\\includegraphics[width=2.5in]{figures/bagging_example.pdf}  \\hfill \\\\\nAfter making 300 classifiers, we can get a step-like decision boundary.  \nStopping at 100 would have been better; it is not over-fit (not shown).  \\hfill \\\\\n\nThe blue, green, yellow, and red lines:   % I e-mailed the forum to figure this out. \n\\begin{itemize}\n\t\\item blue = training error = same as usual.  Randomly choose a subset to hold-out for testing\n\t\\item green = test error = same as usual.  Randomly choose a subset to hold-out for testing\n\t\\item yellow = hypothesis error = the error of the new weak learner generated on that step \n\t\t\t(i.e. a decision stump) \\hfill \\\\\n\t\t\"Last classifier we added was 38\\% wrong. \" \n\t\tfor time = 100 when Hypothesis error said 0.38\n\t\\item red = theoretical bound = the bound on the training error, derived in the later slides\n\\end{itemize}\n% TA: Training/test sets are selected as always: randomly choosing a subset to hold-out for testing. Hypothesis error tells you the error of the new weak learner generated on that step (i.e. a decision stump). Theoretical bound is the bound on the training error, derived in the later slides.\n\n\\subsubsection{Learning from weighted data}  \nConsider a weighted data set: \\hfill \\\\\n\\begin{itemize}\n\t\\item $D(i)$ is the weight of the $i^{th}$ training example/point (not classifier!). \n\t\tIt gets bigger each time point $i$ is predicted incorrectly.  \n\t\tIt doesn't get smaller, but you normalize (see below). \n\t\t\\hfill \\\\\n\t\tPoint = $(\\bm{x}^i, \\bm{y}^i)$\n\t\\item interpretations:\n\t\t\\begin{itemize}\n\t\t\t\\item the $i^{th}$ training example counts as if it occurred $D(i)$ times\n\t\t\t\\item these extra counts mean that if we were to \"resample\" data, \n\t\t\t\twe would get more samples of \"heavier\" data points. \n\t\t\\end{itemize}\n\t\\item Now we always do weighted calculations:\n\t\t\\begin{itemize}\n\t\t\t\\item e.g. MLE for Naive Bayes\n\t\t\t\\item redefine Count(Y=y) to be a weighted count: \\hfill \\\\\n\t\t\t\t$\\displaystyle Count(Y=y) = \\sum_{j=1}^n D(j) \\delta (Y^j = y)$\n\t\t\t\\item ?? Is this counting the number of points we have right?? No.. what is it counting? \n\t\t\t\\item if point $j$ has been wrong many times before, \n\t\t\t\t\tit becomes more important, as reflected by $D(j)$ being large. \n\t\t\t\\item setting $D(j) = 1$ (or any constant value!) for all $j$ recreates the unweighted case. \n\t\t\\end{itemize}\n\\end{itemize}\n\n\nNote, we can use decision stumps for boosting.  Can also use logistic regression, but it isn't as easy to show as our clas stump example.  \\hfill \\\\\n\\hfill \\\\\n\nThat's just about weighing the samples.  How do we weight the classifiers? \nWe want to weight across \\underline{all} data points. \nUse $\\alpha$ to allow classifiers to have different votes. \n\n\\subsubsection{Algorithm: Binary case}\n\\underline{Given}: points $(x^1, y^1), \\dots, x^m, y^m$.  \\hfill \\\\\nFor this case, $x^i \\in \\mathbb{R}$, and binary labels: $y^i \\in \\{-1, +1\\}$ \\hfill \\\\\n\\underline{Initialize}: $D_1(i) = 1/m$ for $i=1, \\dot, m$.  \\hfill \\\\\nFor $t = 1, \\dots, T:$\n\\begin{itemize}\n\t\\item Train base classifier $h_t(x)$ using $D_t$\n\t\\item Chose the weight of importance for this classifier, $\\alpha_t$. \\hfill \\\\\n\t\tNote that this comes after training the classifier.  \\hfill \\\\\n\t\tThere are many possibilities for choosing $\\alpha$, which are discussed later.  \\hfill \\\\\n\t\\item Update, for $i= 1 \\dots m$:  \\hfill \\\\\n\t\t$D_{t+1}(i) \\propto D_t(i) exp(-\\alpha_t y^i h_t(x^i))$ \\hfill \\\\\n\t\t\t\twith normalization constant $\\displaystyle \\sum_{i=1}^M D_t(i) \\exp(-\\alpha_t y^i h_t(x^i))$ \n\t\t\\begin{itemize}\n\t\t\t\\item The $D$ is getting reweighted for the next round.  \\hfill \\\\\n\t\t\tWhat's happening inside: \\hfill \\\\\n\t\t\tIf $y^i h_t(x^i) > 0$, $h_i$ was correct.  \\hfill \\\\\n\t\t\tBut if $y^i h_t(x^i) < 0$, $h_i$ was wrong.  \\hfill \\\\\n\t\t\tYou multiply by $\\alpha_t$, which can flip the sign inside the $\\exp()$. \\hfill \\\\\n\t\t\tIf $h_i$ is correct and $\\alpha > 0$, then $D_{t+1}(i) < D_t(i)$.  \\hfill \\\\\n\t\t\tBut if $h_i$ is wrong and $\\alpha > 0$, then $D_{t+1}(i) > D_t(i)$.  \\hfill \\\\\n\t\t\\end{itemize}\n\t\\item Output a final classifier: $\\displaystyle h = sign \\left( \\sum_{i=1}^T \\alpha_t h_t(x) \\right)$ \\hfill \\\\\n\t\tThis is a linear sum of \"base\" (weak) classifier outputs. \\hfill \\\\\n\t\tNote that $D$ is no longer in the picture. \t\t\n\\end{itemize}\nIf you had two classifiers, your result would be $\\alpha_1 h_1 + \\alpha_2 h_2$\n\n\\textbf{How to chose $\\alpha$}: \\hfill \\\\\nFirst calculate $\\displaystyle  \\epsilon_t = \\sum_{i=1}^m D_t(i) \\delta(h_t(x^i \\neq y^i)))$ \\hfill \\\\\nThis is the error of $h_t$, weighted by $D_t$ \\hfill \\\\\nThen use $\\displaystyle  \\alpha_t = \\frac{1}{2} \\ln \\left( \\frac{1 - \\epsilon_t}{\\epsilon_t} \\right)$  (derived below) \\hfill \\\\\nThis transforms alpha according to:  \\hfill \\\\\n\\includegraphics[width=1.2in]{figures/alpha_from_epsilon.pdf}\n\\begin{itemize}\n\t\\item no errors:  $\\epsilon_t = 0 \\rightarrow \\alpha_t = \\infty$\n\t\\item all errors:  $\\epsilon_t = 1 \\rightarrow \\alpha_t = -\\infty$\n\t\\item random:  $\\epsilon_t = 0.5 \\rightarrow \\alpha_t = 0$\n\\end{itemize}\nTruncate at 2 or 3.  Don't want to allow weight = infinity. \\hfill \\\\  % week 9 audio\nThink of this like NB with weighting. \\hfill \\\\  % week 8 audio.\n\\underline{Why would we want/have negative weights on classifiers?} \\hfill \\\\\nA classifier that does worse than chance is backwards. \nIf it is worse than chance, flip the sign then use it. \nA classifier that is wrong 90\\% of the time is a good classifier.   \nA truly random classifier does not provide information.  Thow those away.\n\n\\hfill \\\\\nIf you get something right a bunch of times, the weight should converge to zero.  % week 8 audio\n\\hfill \\\\\n\nWe want to run this loop until it converges.  \nBut if we run it too long, it will overfit. \n\n\\subsubsection{How to chose $\\alpha_t$ for hypothesis $h_t$?}\nIt would be cool to find the $\\alpha_t$ that works best for that classifier, take derivative with respect to $\\alpha_t$, and find an $\\alpha$ that minimizes error. \\hfill \\\\\nWe can't optimize the training set error, but we can minimize a bound on it. \\hfill \\\\\n$\\displaystyle  \\sum_{i=1}^m \\delta(H(x^i) \\neq y^i) \\leq \\sum_{i=1}^m D_t(i) \\exp(-y^i f(x^i))$ \\hfill \\\\\nwhere $\\displaystyle f(x) = \\sum_t \\alpha_t h_t(x)$; $H(x) = sign(f(x))$ \\hfill \\\\\n\\includegraphics[width=2.5in]{figures/chosing_alpha_step_func.pdf}\n \nWe know the training set error (\\# of instances wrong) it is bounded by the sum on the right.\nWhy?  The left side of the equality is the left piece of the step function.\nThe exponential function of label*prediction has the expo curve.\nNote that \\textbf{the exponential curve is always above the step function}.\nSo we can use expo as the upper bound. \nThis is kind of like logistic regression: same form.\n\n% --------\n\\subsubsection{You can choose $\\alpha_t$ to minimize the error bound.}\nNote that each classifier is independent of alpha.  \nEach classifier is already a classifier by itself. \nWe want to train the weighted combinations of classifiers.  \nNote we are not directly using the error.  \nWe are using a function that maps the error to a \\# we can use. \nThat's the role of the alpha vs epsilon curve.  \nWe liked its properties. \nThere are two parameters in the $\\exp()$:  $h$ and $\\alpha.$\nYou can optimize for h and alpha together.\nWe have a way to make the classifier sand learn the weights at the same time.\nWe might still learn the classifiers first. \nFor those of you who care about joint optimization, you can flip between optimizing the two. \n\n\\includegraphics[width=2.7in]{figures/chosing_alpha--telescoping_sums.pdf}\n\n\\includegraphics[width=2.7in]{figures/chosing_alpha--telescoping_sums2.pdf}\n\nNote that our $D$ values are not going up by more than 1 each time, like the intro to the concept showed.\nThere is an exponential term that generally shrinks the sum of the $D$ values to 1 (at least in the class example).  \\hfill \\\\\n\\hfill \\\\\n\nAfter the third iteration for our class example:\n\\includegraphics[width=3.4in]{figures/boosting_example_3rd_iteration.pdf} \\hfill \\\\\nThe $\\epsilon$ values are dependent on the previous iteration's $D$ values, \n\tbut the current iterations $h$ classifier. \\hfill \\\\\nOnce you find your new $\\epsilon$ from your old $D$s and new $h$, \n\tyou can find $\\alpha$ and thus your new $D$s for the next round.   \\hfill \\\\\n%?? Does your previous classifier know anything about your other classifiers ??    \\hfill \\\\\n%?? Should we think of the fact that it was trained using $D$s from previous classifiers as knowledge about other classifiers ??   \\hfill \\\\\n?? Is it typical to have your alpha weights grow ??  Can I explain what is driving this ?? \n\\hfill \\\\\n\\hfill \\\\\n\n\\textbf{The D after normalization is a probability.}\n\n\\subsubsection{Assembling weak classifiers}\nIf each classifier is (at least slightly) better than random: $\\epsilon_t < 0.5$: \\hfill \\\\\nAnother bound on error:\n$$ \\frac{1}{m} \\sum_{i=1}^m \\delta (H(x^i) \\neq y^i) \\leq \\prod_t Z_t \\leq \\exp \\left( -2 \\sum_{t=1}^T (\\frac{1}{2} - \\epsilon_t)^2 \\right)$$\nThis implies training error will reach zero exponentially fast. \\hfill \\\\\nThe error is bounded by an exponential of how far you are from random. \\hfill \\\\\n\nNote that it isn't too hard to achieve better than random training error, especially for binary classification.   \\hfill \\\\\nBoosting is powerful!  \\hfill \\\\\n\nNote that test error can continue to decrease after training error goes to zero.  \n\n\\includegraphics[width=2.2in]{figures/boosting_train_test_error.pdf}\n\nAlso in this figure, the lack of up-tick at the right shows that boosting does not overfit. \n\n\\subsubsection{Using your classifier}\nSay you have a trained/converged classifier.\nThat means you have $h$s and $\\alpha$s : weak classifiers and their corresponding weights. \nPlug in new $x$ into $H(x)$ %, which puts into $H(x)$.\n\n\\textbf{How do we know when to stop? } \\hfill \\\\\nIf the training error keeps getting better we keep going.\nThis could lead to over-fitting, but it turns out boosting is robust to overfitting.   \\hfill \\\\\n(We didn't actually conclude when to stop in class.) \n\nThere was a theory (Freund \\& Schapire, 1996) that suggested \n$$ error_{true}(H) \\leq error_{train}(H) + \\tilde{\\mathcal{O}} \\left( \\sqrt{\\frac{Td}{m}} \\right) $$\nSuggests you don't want to use complicated classifiers in your boosting.  d would get high, we could end up over-fitting. % week 9 audio\n\n$T$: number of boosting rounds.  Higher $T$ $\\rightarrow$ looser bound.  \\hfill \\\\\n$d$: VC dimension of weak learner.  Measures complexity of classifier.  \\hfill \\\\\n$m$: number of training examples.  More data $\\rightarrow$ tighter bound.  \\hfill \\\\\n\\hfill \\\\\n\nIt turns out boosting is robust to overfitting.  The test set error decreases even after the training error reaches zero.  So this theory doesn't hold. \n\n\\subsubsection{Boosting and Logistic Regression}\nBoth smooth approximations of 0/1 step loss.\n\n\\includegraphics[width=2.2in]{figures/losses--boosting_and_logistic_regression.pdf}\n\n\\includegraphics[width=2.7in]{figures/logistic_regression_and_boosting_summary.pdf}\n\nAs noted above:\nSimilar to logistic regression:\n\\begin{itemize}\n\t\\item both linear models.  Boosting \"learns\" features.  \n\t\\item similar loss functions\n\t\\item single optimization (Logistic Regression) versus incrementally improving\n\\end{itemize} \n\n", "meta": {"hexsha": "16ce3cd857d6dc4ddd3bb96ed23f376e9dd8d774", "size": 19563, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/boosting.tex", "max_stars_repo_name": "JanetMatsen/Machine-Learning", "max_stars_repo_head_hexsha": "12e1f701eb7de89b97d5caffe86b0267731e4cb5", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2016-02-07T23:35:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-26T05:13:33.000Z", "max_issues_repo_path": "tex/boosting.tex", "max_issues_repo_name": "JanetMatsen/Machine-Learning", "max_issues_repo_head_hexsha": "12e1f701eb7de89b97d5caffe86b0267731e4cb5", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/boosting.tex", "max_forks_repo_name": "JanetMatsen/Machine-Learning", "max_forks_repo_head_hexsha": "12e1f701eb7de89b97d5caffe86b0267731e4cb5", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2016-08-29T00:15:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-06T22:36:19.000Z", "avg_line_length": 54.4930362117, "max_line_length": 501, "alphanum_fraction": 0.7396104892, "num_tokens": 5302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.43200585696776006}}
{"text": "\\section{System design and composition}\n\\subsection{Model}\nThe system is modelled in two parts: the moving base and the\\ldots\n% TODO: describe the moving base, and the attachment, whatever it ends up being.\n% Include physical models.\n\n\n% Describe the states of the system.\nWe argue for the folloing five states of the system:\n\\begin{inline-enum}\n\\item waiting for a command;\n\\item moving to a destination;\n\\item following a navigation-line;\n\\item picking an object up; and\n\\item dropping an object off.\n\\end{inline-enum}\nThe relation between these five states are visually described in the state machine of Fig~\\ref{fig:state_machine}.\n\\begin{figure*}[ht]\n  \\centering\n  \\begin{tikzpicture}\n    \\node[state, initial, accepting] (wait) {waiting for \\\\ command};\n    \\node[state, right of=wait] (move) {moving to \\\\ destination};\n    \\node[state, below of=move] (follow) {following \\\\ line};\n    \\node[state, right of=follow] (pickup) {picking \\\\ up object};\n    \\node[state, left of=follow] (dropoff) {dropping \\\\ off object};\n\n    \\path[->] (wait) edge node{Arrowhead \\\\ signal} (move)\n    (move) edge[sloped] node{line detected \\\\} (follow)\n    (follow) edge[sloped] node{station detection \\\\ (system w/o object)} (pickup)\n    (follow) edge[sloped] node{station detection \\\\ (system w/ object)} (dropoff)\n    (pickup) edge[sloped] node{object picked up \\\\} (move)\n    (dropoff) edge[sloped] node{object dropped \\\\} (wait)\n    ;\n  \\end{tikzpicture}\n  \\caption{High-level state machine of the system.}\n  \\label{fig:state_machine}\n\\end{figure*}\n\\subsubsection{Mobile platform}\nThe model used in this case is the unicycle model, due to the differential steering. \nThis is because of the mobile platform has only two wheels/trucks and it is not able to apply any steering angle to its wheels. \nThe only way this robot can change orientation is by giving different velocity on each wheel-driving servo on left- and right- side. \nWith this feature it is also possible to change the orientation of the mobile platform without changing the position of the platform. \nI.e. the robot is able to spin while the right-hand sidewheels have the same velocity as the left-hand side wheels, in opposite direction. \n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=0.4\\textwidth]{sections/assets/car-unicycle.png}\n\\caption{Unicycle model of a car-like robot. \n$v_L$ and $v_R$ represent the left- and right-hand side wheels' velocities respectively. \nThe robot follows a path around the instantaneous center of rotation (ICR) where $R_L$ and $R_R$ are the distances from left and right wheels to ICR respectively and $w$ is the distance between them.}\n\\label{fig:UnicycleModel}\n\\end{figure} \n\nAs shown in Fig.~\\ref{fig:UnicycleModel} The robot follows a curved path with the instantaneous center of rotation at its center. \nThe left-hand side wheels have velocity $v_L$ and moves along an arc with radius $R_L$ during the time that right-hand side wheels moves along another arc with radius $R_R$ at the speed of $v_R$. \nThe turning rate of the body is\n        \\begin{equation*}\n            \\dot{\\theta}= \\frac{v_L}{R_L} = \\frac{v_R}{R_R}\n        \\end{equation*}\n        since $R_R = R_L + W$ the expression can be simplified as\n        \\begin{equation}\n            \\dot{\\theta}= \\frac{v_R - v_L}{W} = \\frac{v_\\Delta}{W}\\label{eq:ThetaDot3}\n        \\end{equation}\n        the equations of motion for this model are\n        \\begin{eqnarray}\n            \\begin{aligned}\n                \\dot{x} &= v\\,cos(\\theta)\\\\\n                \\dot{y} &= v\\,sin(\\theta)\\\\\n                \\dot{\\theta} &= \\frac{v_\\Delta}{W}\n            \\end{aligned}\n            \\label{eq:MotionEq3}\n        \\end{eqnarray}\n        where the average velocity\\parencite{Corke2011} is given by\n        \\begin{equation}\n            v = \\frac{v_R + v_L}{2} \n            \\label{eq:av_velocity}\n        \\end{equation}{} \n\n\n\\subsection{Simulation}\n% Simulte the models from the previous section and show that it will work.\n% Motivate regulation approach.\n\n\\subsection{Hardware}\n% Explain the raspberry pi and it's attachments.\n\n\\subsection{Software}\n\\subsubsection{Reproducible system image generation}\n% Explain the repo's *.nix files and what they do\nThe system image of the Raspberry Pi is generated via the repository's \\texttt{mmc-image.nix} file ---\nan auxiliary \\texttt{build.sh} script is available to generate and subsequently flash a target storage device in a single command execution.\n\\texttt{mmc-image.nix} contains an expression of the Nix language.\nTogether with the usage of \\texttt{nixpkgs} --- an extensive library of build and package declarations,\n\\texttt{mmc-image.nix} allows us to reliably and reproducibly build a bootable image of the complete software environment the project requires.\nTo then boot the generated image, it only needs to be flashed on a MultiMediaCard (MMC\\footnote{Commonly referred to as: SD card, memory card.}) and slotted into the MMC-slot on the Raspberry Pi.\n\n% Explain the pros of Nix\nWhen building derivations (nomenclature for anything built with Nix: an executable binary, shared library file, a system environment, etc.) their dependencies are in complete isolation with each other, which effectively allows the avoidance of dependency hell.\\footnote{Colloquial term referring to the frustration often generated when dealing with version-specific dependencies.\nSee \\href{https://en.wikipedia.org/wiki/Dependency_hell}{Wikipedia}.}\n\n% Explain the rollback functionality git provide us.\nIn combination with git, one may trivially roll back to previous derivations that are known to work by checking out a commit and rebuilding.\n\n% Explain why treating the MMC as volatile is a good idea (MMCs have a tendency to just stop working).\nIn addition, by preferring a work flow where the target storage is considered volatile, any deficiencies of the target medium are mitigated.\n\n% TODO: improve\n\\subsubsection{System-external services}\nThe software environment generated for the Raspberry Pi automatically connects to Eduroam if credentials are available.\nEduroam places some limitations on connected clients: firewall, e.g.\nTo enable easy remote access to the system, a reverse SSH proxy is established with a known bastion host which has a static IP address.\nBy exposing this proxy via a known port on the bastion, any system connected to the Internet may trivially access the Raspberry Pi remotely via a static endpoint.\nWhile not a necessity for the project itself, this external service is a great convenience for ad-hoc experiments and general system debugging.\n\n% Explain the content of contrib/bastion.nix\n", "meta": {"hexsha": "6bb2c251d5c4d802eeaceed7b64ace602c34b383", "size": 6606, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/system-design.tex", "max_stars_repo_name": "lllalex/ed7039e", "max_stars_repo_head_hexsha": "7a56f5993730cd9f46adfb40c3e42aae06d71549", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/sections/system-design.tex", "max_issues_repo_name": "lllalex/ed7039e", "max_issues_repo_head_hexsha": "7a56f5993730cd9f46adfb40c3e42aae06d71549", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/sections/system-design.tex", "max_forks_repo_name": "lllalex/ed7039e", "max_forks_repo_head_hexsha": "7a56f5993730cd9f46adfb40c3e42aae06d71549", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.9482758621, "max_line_length": 379, "alphanum_fraction": 0.7403875265, "num_tokens": 1621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43199355421670754}}
{"text": "\n\\chapter{Data on the Sphere}\n\\label{ch_intro}\n\n\\section{Introduction}\n\nIn a number of areas of scientific activity, data is gathered which naturally maps to the sphere. For instance, remote sensing of the \nEarth's surface and atmosphere,\\emph{e.g.} with POLDER\\footnote{\\emph{http://polder.cnes.fr}}, generates spherical data maps which are \ncrucial for global and local geophysical studies such as understanding climate change, geodynamics or monitoring human-environment \ninteractions. More examples can be found in medical imaging or computer graphics. In astronomy and astrophysics, recent and upcoming \nground based and satellite borne experiments such as WMAP\\footnote{\\emph{http://map.gsfc.nasa.gov}} or Planck-Surveyor\\footnote{\\emph{http://astro.estec.esa.nl/Planck}} \nfor the observation of the Cosmic Microwave Background radiation field over the whole celestial sphere, have and will produce full-sky \nmaps in a wide range of wavelengths. These maps are necessarily digitized and hence distributed as a finite set of pixel values on some \ngrid. The properties of this grid will affect the subsequent analysis of the data, and a good choice will make standard computations, \nsuch as the spherical harmonics transform, much faster and accurate. Considerable work has been dedicated to the development of \npixelization schemes on the sphere. In particular, Healpix\\cite{healpix} is a sampling scheme which has some attractive geometrical \nfeatures profitably used in this spherical data analysis software package. \\\\\n\nProcessing spherical data maps requires specific tools or somehow adapting traditional methods used on flat images to the spherical \ntopology, such as multiscale transforms for image processing. Among these, Wavelets and related representations are by now successfully \nused in all areas of signal and image processing. Their recent inclusion in JPEG 2000 -- the new still-picture compression standard -- \nis an illustration of this lasting and significant impact. Wavelets are also very popular tools in astronomy \\cite{starck:book02} which \nhave led to very impressive results in denoising and detection applications. For instance, both the Chandra and the XMM data centers \nuse wavelets for the detection of extended sources in X-ray images. For denoising and deconvolution, wavelets have also demonstrated \nhow powerful they are for discriminating signal from noise \\cite{starck:sta02_2}. In cosmology, wavelets have been used in many studies \nsuch as for analyzing the spatial distribution of galaxies \\cite{astro:slezak93,astro:escalera95,starck:sta05,starck:martinez05}, \ndetermining the topology of the universe \\cite{astro:rocha04}, detecting non-Gaussianity in the CMB maps \\cite{gauss:aghanim99,gauss:barreiro01_1,wave:vielva04,starck:sta03_1},\r\nreconstructing the primordial power spectrum \\cite{astro:pia03}, measuring the galaxy power spectrum \\cite{astro:fang00} or reconstructing \nweak lensing mass maps \\cite{starck:sta05b}. It has also been shown that noise is a problem of major concern for N-body simulations of \nstructure formation in the early Universe and that using wavelets for removing noise from N-body simulations is equivalent to simulations \nwith two orders of magnitude more particles \\cite{rest:romeo03,rest:romeo04}. \r\n\nWavelets owe part of their success to their ability for sparse approximation of point singularities. However they are not as good at detecting \nhighly anisotropic features such as curvilinear singularities in images. This is where other multiscale systems such as Ridgelets \\cite{cur:candes99_1} \nand Curvelets \\cite{cur:donoho99,starck:sta01_3}, which exhibit high directional sensitivity and are highly anisotropic, come into play. Digital \nimplementations of both ridgelet and curvelet transforms for image denoising are described in \\cite{starck:sta01_3}. Inspired by the successes \nof \\emph{Euclidean} wavelets, ridgelets and curvelets, this package provides implementations of new multiscale decompositions for spherical images \nnamely the isotropic undecimated wavelet transform, the ridgelet transform and the curvelet transform each of which is invertible.\n\n\\section{Pixelization}\n\nDespite the apparent simplicity of the sphere, deriving numerical schemes on the sphere is not a trivial task. A major difficulty encountered \nin the design of numerical methods on the sphere is that of pixelization: there is no obvious way in which to reconcile the requirements \nfor a \\emph{maximally} uniform sampling and for an exact and invertible computation of the spherical harmonics decomposition of band-limited \nfunctions \\cite{healpix,icosahedron}. Also, the sampling strategy determines largely the achievable algorithmic complexity of these computations. \nSeveral sampling schemes have been proposed recently such as Tegmark's Icosahedron \\cite{icosahedron}, the Igloo \\cite{igloo} or Healpix \\cite{healpix} \nmethods which tend to favor approximate uniformity among other properties. The Glesp \\cite{glesp} pixelization was developed with a strong \nfocus on the accuracy of the spherical harmonics transform. \n\n\\subsection*{Healpix}\n\nThe Healpix representation is a curvilinear hierarchical partition of the sphere into quadrilateral pixels of exactly equal area but with \nvarying shape. The base resolution divides the sphere into 12 quadrilateral faces of equal area placed on three rings around the poles \nand equator. Each face is subsequently divided into $nside^{2}$ pixels following a quadrilateral multiscale tree structure. The pixel \ncenters are located on iso-latitude rings, and pixels from the same ring are equispaced in azimuth. This is critical for computational \nspeed of all operations involving the evaluation of spherical harmonics transforms, including standard numerical analysis operations such \nas convolutions, power spectrum estimation\\ldots \\\\\n\n\\begin{figure}\n\\centering\n\\includegraphics{pixelhealpix}\n\\caption{The Healpix sampling grid.}\n\\label{pixelhealpix}\n\\end{figure}\n\nAn important geometrical feature of the Healpix sampling grid is the hierarchical quadrilateral tree structure. This defines a \\emph{natural} \none-to-one mapping of the sphere sampled according to the Healpix grid, into twelve \\emph{flat} images, on all scales. It is then easy to \npartition a spherical map using Healpix into quadrilateral blocks of a specified size. One first extracts the twelve base-resolution faces, \nand each face is then decomposed into overlapping blocks of the specified size. This decomposition into blocks is an essential step of the \ntraditional \\emph{flat} 2D curvelet transform. Based on the reversible warping of the sphere into a set of flat images made possible by the \nHealpix sampling grid, the ridgelet and curvelet transforms can be extended to the sphere. \n\nWith the decomposition into blocks described above, there is no overlapping between neighboring blocks belonging to different base-resolution faces. \nThis may result for instance in blocking effects in denoising experiments \\emph{via} non linear filtering. It is possible to overcome this difficulty \nin some sense by working simultaneously with various rotations of the data with respect to the sampling grid. This will average out undesirable \neffects at edges between base resolution faces. \n\n\\section{Multiscale methods on the sphere}\n\n\\subsection{Wavelets on the sphere}\n\nIn the last years, several wavelet transforms on the sphere have been proposed. Schr{\\\"o}der and Sweldens \\cite{wave:sweldens95a} have developed \nan orthogonal wavelet transform on the sphere based on the Haar wavelet function which then suffers from the poor properties of the Haar function \nand the problems inherent to the orthogonal decomposition. A few papers describe continuous wavelet transforms on the sphere \\cite{wave:antoine99,wave:tenerio99,wave:cayon01,wave:holschneider96}. \nAn application to the detection of non-Gaussianity in the CMB radiation using the stereographic Mexican hat wavelet is reported in \\cite{wave:vielva04}. \nThese methods have been extended to directional wavelet transforms \\cite{wave:antoine01,wave:hobson04,wave:wiaux}. Although profitable for data \nanalysis, these continuous transforms lack an inverse transform and hence are clearly not suitable for restoration purposes. The algorithm proposed \nby Freeden and Maier\\cite{freeden97,freeden98}, based on the Spherical Harmonic Decomposition, is to our knowledge the only one to have an inverse transform.\\\\  \n\nA very popular wavelet algorithm in astrophysical applications is the so-called ``\\emph{\\`a trous} algorithm'' (a better name would be the \n``isotropic undecimated wavelet transform'' ), which possesses the following features: i) it is isotropic, ii) it is undecimated, iii) it uses \nan order three Box-Spline as scaling function. The isotropy of the wavelet function makes this decomposition optimal for the detection of \nisotropic objects. The non decimation makes the decomposition redundant (the number of coefficients in the decomposition is equal to the number \nof samples in the data multiplied by the number of scales) and allows us to avoid Gibbs aliasing after reconstruction in image restoration \napplications, as generally occurs with orthogonal or bi-orthogonal wavelet transforms. The choice of a $B_3$-spline is motivated by the fact \nthat we want an analyzing function close to a Gaussian, but verifying the dilation equation, which is required in order to have a fast transformation. \nFinally the last property of this algorithm is to provide a very straightforward reconstruction. Indeed, the sum of all the wavelet scales and \nof the coarsest resolution image reproduces exactly the original image. \\\\\n\nThe \\mrs package offers an implementation of a new isotropic wavelet transform on the sphere. Its properties are similar to those of the \\emph{\\`a trous} \nalgorithm and therefore should be very useful for data denoising and deconvolution. This algorithm, described in chapter~\\ref{ch_mms}, is directly derived\r\nfrom the FFT-based wavelet transform proposed in\\cite{starck:sta94_3} for aperture synthesis image restoration. It is relatively close to the Freeden and \nMaier \\cite{freeden98} method, except that the reconstruction process is as straightforward as in the \\emph{\\`a trous} algorithm (i.e. the sum of the scales \nreproduces the original data). This new wavelet transform can also be easily extended to a pyramidal wavelet transform, which may be very important for \nlarger data sets such such as from the future Planck experiment.\n\n\\subsection{Ridgelets and Curvelets on the sphere}\n \nWhen analyzing data which contains anisotropic features, wavelets are no longer optimal. This has motivated the development of new multiscale \ndecompositions such as the ridgelet and the curvelet transforms \\cite{cur:donoho99,starck:sta01_3}. Among possible applications of those data \nanalysis methods, it was shown in Starck et al. \\cite*{starck:sta03_1} that the \\emph{flat} curvelet transform could be useful for the detection \nof non Gaussianity in \\emph{flat} patches of CMB data, and also to discriminate among different causes of non Gaussianity. \r\n\nIn this area, further insight will come from the analysis of full-sky data mapped to the sphere thus requiring the development of a curvelet \ntransform on the sphere. The \\mrs package offers an implementation of ridgelet and curvelet transforms for spherical maps. Those implementations \nare derived as extensions of the digital ridgelet and curvelet transforms described in \\cite{starck:sta01_3}. The implemented undecimated isotropic \nwavelet transform on the sphere and the specific geometry of the Healpix sampling grid are important components of the present implementation of \ncurvelets on the sphere. \\\\\n \nFurther motivation for developing these new multiscale methods on the sphere follows from the results obtained in different data processing applications. \nAs described in chapter\\ref{ch_restore}, the \\mrs package provides the necessary tools to experiment with these new spherical multiscale transforms in \ndenoising applications, for instance using the Combined Filtering Method, which allows us to filter data on the sphere using both the Wavelet and the \nCurvelet transforms. The analysis of multichannel data mapped to the sphere, a problem encountered for instance in the processing of WMAP and Planck \nobservations, is another issue that is shown to benefit from the developed multiscale representations on the sphere. This is reported in chapter~\\ref{ch_mrs_ica} \nwhich is dedicated to describing some methods in multichannel data analysis extended to spherical maps which are implemented in the \\mrs package.  \n \n\\section{Processing of polarized datas on the sphere}\n\nPolarized maps are a special kind of multi-dimentionnal datas with strong links between their components. The polarization is of great importance \nin physics or astrophysics as it's analysis denotes fundamentals characteristics of the observed object or phenomenum. An example of great interest \nis today the cosmic microwave background \\cite{starck}.\n\nThe statistical analysis of the slight intensity fluctuations in the primordial cosmic microwave background radiation field, for which evidence was \nfound for the first time in the early 1990's in the observations made by COBE~\\cite{gauss:smoot92}, is a major issue in modern cosmology as these \nare strongly related to the cosmological scenarios describing the properties and evolution of our Universe. In the Big Bang model, the observed CMB \nanisotropies are an imprint of primordial fluctuations in baryon-photon density from a time when the temperature of the Universe was high enough above \n3000~K for matter and radiation to be tightly coupled. At that time, the attraction of gravity and the repulsive radiation pressure were opposed, thus \ngenerating so-called acoustic oscillations in the baryon-photon fluid, causing peaks and troughs to appear in the power spectrum of the spatial anisotropies \nof the CMB. With the Universe cooling down as it expanded, matter and radiation finally decoupled. Photons were set free in a nearly transparent Universe, \nwhile the density fluctuations collapsed under the effect of gravity into large scale structures such as galaxies or clusters of galaxies. Due to the \nexpansion of the Universe, the CMB photons are now observed in the microwave range but are still distributed according to an almost perfect black body \nemission law. Another major result was the measurement of the polarization state and anisotropies of the CMB radiation field by DASI~\\cite{dasi}. \nOnly a fraction of the total CMB radiation is polarized so that extremely sensitive instruments are needed. Polarization of the CMB radiation is a \nconsequence of the Thomson scattering of photons on electrons. But for the outgoing population of photons to be polarized, the radiation incident on \nthe scatterer needs to be anisotropic and have a quadrupole moment. The statistics of the CMB polarization anisotropies are also a source of information \nfor cosmology. Inference of cosmological parameters from the joint statistics of the CMB anisotropies should benefit from both the complementarity and \nthe redundancy of the information carried by the additional measurement of CMB polarization. Hence the full-sky maps with unprecedented sensitivity and \nangular resolution of both temperature and polarization anisotropies of the CMB to be delivered by the upcoming Planck Surveyor satellite experiment are \nawaited with excitement.\n\n\\subsection{Orthogonal representation of polarized datas}\n\\label{sec:polar}\n\n\\begin{figure*}[htb]\n\\includegraphics[width=\\textwidth]{fig_pola_qu_owt_trans.pdf}\n\\caption{Q-U orthogonal Wavelet Transform.}\n\\label{fig_qu_owt_trans}\n\\end{figure*}\nFull-sky CMB polarization data, as expected from the upcoming Planck experiment, consists of measurements of the Stokes parameters so that in addition \nto the temperature $T$ map, $Q$ and $U$ maps are given as well. The fourth Stokes parameter commonly denoted $V$ is a measure of circular polarization. \nIn the case of CMB which is not expected to have circularly polarized anisotropies, $V$ vanishes. The former three quantities, $T$, $Q$ and $U$ then \nfully describe the linear polarization state of the CMB radiation incident along some radial line of sight : $T$ is the total incoming intensity, $Q$ is \nthe difference between the intensities transmitted by two perfect orthogonal polarizers the directions of which define a reference frame in the tangent \nplane, and $U$ is the same as $Q$ but with polarizers rotated 45 degrees in that tangent plane. Clearly, $Q$ and $U$ are not invariant through a rotation \nof angle $\\phi$ of the local reference frame around the line of sight. In fact, it is easily shown that~:\n\\begin{eqnarray}\nQ ' = & \\cos (2 \\phi) Q + \\sin(2 \\phi) U \\\\ \\nonumber\nU ' = & \\cos (2 \\phi) U - \\sin(2 \\phi) Q \n\\end{eqnarray}\nwhich can also be written $Q' \\pm i U' = e^{\\mp i\\phi} ( Q \\pm i U )$ which by definition expresses the fact that the quantities $Q \\pm i U$ are \nspin-2 fields on the sphere. The suitable generalization of the Fourier representation for such fields is the spin-2 spherical harmonics basis \ndenoted $_{\\pm 2}Y_{\\ell m}$, in which we can expand~: \n\\begin{eqnarray}\\label{QU}\nQ \\pm i U  = \\sum_{\\ell, m} { _{\\pm 2}a_{\\ell m}} {_{\\pm 2}Y_{\\ell m} }\n\\end{eqnarray}\n\nIt is convenient~\\cite{zalda} to introduce the two quantities denoted $E$ and $B$ which are defined on the sphere by~:\n\\begin{eqnarray}\\label{EB}\nE = & \\sum_{\\ell, m} a_{\\ell m} ^E Y_{\\ell m} = \\sum_{\\ell, m} - \\frac{1}{2} ( {_{ 2}a_{\\ell m}} + {_{- 2}a_{\\ell m}} ) Y_{\\ell m} \\\\ \\nonumber\nB = & \\sum_{\\ell, m} a_{\\ell m} ^B Y_{\\ell m} = \\sum_{\\ell, m} i \\frac{1}{2} ( {_{ 2}a_{\\ell m}} - {_{- 2}a_{\\ell m}} ) Y_{\\ell m} \n\\end{eqnarray}\n\n\\subsection{Multiscale transform on the sphere for polarized datas}\n\nInprovements in the second version of the \\mrs package includes extension of the 1D multiscale transforms to the case of polarized maps with \nthe three fields $T$, $Q$ and $U$ (or the fields $T$, $E$ and $B$). The easiest way to build a multiscale transform for polarized data is to \nuse the Healpix\\footnote{http://healpix.jpl.nasa.gov} representation \\cite{pixel:healpix}, and to apply a bi-orthogonal wavelet transform \non each face of the Healpix map, separately for $Q$ and $U$. Fig.~\\ref{fig_qu_owt_trans} shows the flow-graph of this Q-U orthogonal wavelet \ntransform (QU-OWT). Most of the algorithms included in \\mrs for the processing of 1D images know have a version for polarized maps.\n\n% \\clearpage\n% \\newpage\n", "meta": {"hexsha": "73716d1ece8bf30f7291671b5ff4224d90fa86d2", "size": 18614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_isap/archive_tex/intro.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_isap/archive_tex/intro.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_isap/archive_tex/intro.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.4455958549, "max_line_length": 196, "alphanum_fraction": 0.8031051896, "num_tokens": 4313, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.43199354872705575}}
{"text": "\\documentclass{amsart}\n\\usepackage{amssymb} \n\\usepackage{amsmath} \n\\usepackage{hyperref}\n\\usepackage{enumerate}\n\\usepackage{mathtools}    \n\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\LL}{\\mathcal{L}}\n\n\\newcommand{\\F}{\\mathbb{F}}\n\\newcommand{\\Fp}{\\mathbb{F}_p}\n\\newcommand{\\Fq}{\\mathbb{F}_q}\n\n\\newcommand{\\M}{\\mathfrak{M}}\n\n\\newcommand{\\Hom}{\\operatorname{Hom}}\n\\newcommand{\\Isom}{\\operatorname{Isom}}\n\\newcommand{\\im}{\\operatorname{im}}\n\\newcommand{\\rank}{\\operatorname{rank}}\n\\newcommand{\\supp}{\\operatorname{Sup}}\n\\newcommand{\\ord}{\\operatorname{ord}}\n\\newcommand{\\cf}{\\operatorname{coef}}\n\\newcommand{\\spn}{\\operatorname{span}}\n\\newcommand{\\characteristic}{\\operatorname{char}}\n\n\\newcommand{\\NN}{\\operatorname{Norm}}\n\\newcommand{\\OK}{\\mathcal{O}_K}\n\\newcommand{\\Cl}{\\operatorname{Cl}}\n\\newcommand{\\lcm}{\\operatorname{lcm}}\n\\newcommand{\\sign}{\\operatorname{sign}}\n\\newcommand{\\remainder}{\\operatorname{remainder}}\n\\newcommand{\\quotient}{\\operatorname{quotient}}\n\n\n\\DeclarePairedDelimiterX\\set[2]{\\{}{\\}}{\\,#1 \\;\\delimsize\\vert\\; #2\\,}\n\n\n\\begin {document}\n\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{algorithm}[theorem]{Algorithm}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem*{conjecture}{Conjecture}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\n\\theoremstyle{remark}\n\\newtheorem{remark}[theorem]{Remark}\n\n\n\\title{Finiteness of the class group}\n\n\\maketitle\n\n%------------------------------------------\n\\section{Introduction}\\label{intro}\n%------------------------------------------\n\nIn order to formalize, e.~g.~ in the theorem prover \\emph{Lean}, the finiteness of the class group of rings of integers in number fields, we write some proof in detail. Much of the proof actually applies uniformly to the function field case, assuming (for the time being \\ldots) it's a separable extension of the \\lq base\\rq\\ field $\\Fq(t)$.\n\nNOTE: the only actual intended use of this informal document was to use it in combination with discussions, explanations, etc. to formalize finiteness results for class groups in Lean. In particular, with very few exceptions, no attempt was made to correct errors or complete omissions unless still beneficial for the formalization process.\nPerhaps it will be \\lq polished\\rq\\ a little bit more in the future.\n\n\n%------------------------------------------\n\\section{Notation and conventions}\\label{notation}\n%------------------------------------------\n\n\n%Throughout this paper we let $k,n \\in \\N$.\nFor ideals $I,J$ in some commutative ring $R$, we use standard divisibility-notation $I|J$, meaning $IH=J$ for some ideal $H$ in $R$.\n\n\n\n%------------------------------------------\n\\section{Preliminaries on Dedekind domains}\n%------------------------------------------\n\nFor ideals in Dedekind domains we have \\lq to contain is to divide\\rq. \n\\begin{proposition}\\label{prop contain is divide}\nLet $I,J$ be ideals in a Dedekind domain $R$. Then\n\\begin{equation}\\label{eqn contain is divide}\nI \\supseteq J \\Leftrightarrow I|J.\n\\end{equation}\n\\end{proposition}\n\n\\begin{proof}\n\\lq $\\Leftarrow$\\rq: trivial (assuming $I|J$, which means $J=IH$ for some ideal $H$, it remains to show $IH \\subseteq I$, which is obvious).\\\\\n\\lq $\\Rightarrow$\\rq: Assume $I \\supseteq J$. If $I=0$, then $J=0$, and hence $I|J$. We are left with the case $I\\not=0$.\nWe take as a starting point that nonzero fractional ideals in a Dedekind domain are invertible. So in particular $I$ is invertible. As fractional ideals we have $H:=I^{-1} J \\subseteq I^{-1} I=R$. So $H$ is in fact an ideal, and $I H=I I^{-1} J=J$ So $I|J$ (as ideals of $R$).\n\\end{proof}\n\nIt is convenient to have a characterization of prime ideals in terms of ideals only.\n\n\\begin{lemma}\\label{lem prime ideal ideals}\nLet $R$ be a commutative ring and $P$ be an ideal in $R$. Then $P$ is a prime ideal if and only if $P\\not=R$ and\n\\begin{equation}\\label{eqn prime ideal ideals}\n\\forall \\text{ ideals } I,J \\subseteq R: IJ \\subseteq P \\Rightarrow I \\subseteq P \\text{ or } J \\subseteq P.\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}\nUnfold definitions etc.\\ldots\n\\end{proof}\n\nLemma~\\ref{lem prime ideal ideals} and Proposition~\\ref{prop contain is divide} above, now yields the well known \\lq prime property\\rq, but now for ideals.\n\n\\begin{corollary}\\label{cor prime property ideal}\nLet $I,J,P$ be ideals in a Dedekind domain $R$ with $P$ prime. Then\n\\[ P|IJ \\Rightarrow \\left (P|I \\text{ or } P|J \\right).\\]\n\\end{corollary}\n\nAnother useful property is the \\emph{cancellation rule} for ideal multiplication in Dedekind domains.\n\n\\begin{proposition}\\label{prop cancellation ideals}\nLet $H,I,J$ be ideals in a Dedekind domain $R$ with $H$ nonzero. Then\n\\[ IH=JH \\Rightarrow I=J.\\]\n\\end{proposition}\n\n\\begin{proof}\nAgain, using the characterization of Dedekind domains that all nonzero fractional ideal are invertible, the result follow by multiplying LHS and RHS of $IH=JH$ by (the fractional ideal) $H^{-1}$.. \n\\end{proof}\n\n\nWe now have enough ingredients to our disposal to establish unique factorization in terms of ideals in a Dedekind domain.\n\\begin{theorem}\\label{thm Dedekind unique fac}\nLet $R$ be a Dedekind domain. Then every nonzero ideal $I$ of $R$ can be written as a product of prime ideals of $R$ in a unique way, apart from the order of the factors.\n\\end{theorem}\n\n\\begin{proof}\n\\emph{Existence.} If $I=R$, then we are done by the canonical convention that the empty product (of ideals) gives the unit ideal, i.e. $R$. So Let $I \\not=R$. By Zorn's Lemma we get that $I$ is contained in a maximal ideal, which is a nonzero prime ideal $P_1$.\n(If one does not like the appeal to Zorn's lemma, which is equivalent to the axiom of choice, then for $R=\\mathcal{O}_K$ one can also use $R/I$ is finite instead.)\nBy Proposition~\\ref{prop contain is divide} we see that $P_1|I$, i.e. $I=P_1 I_1$ for some nonzero ideal $I_1$ of $R$. Continuing inductively we get $I=P_1P_2\\ldots P_k I_k$ for nonzero prime ideals $P_1,P_2,\\ldots, P_k$ and nonzero ideal $I_k$ of $R$. If this process would continue indefinitely, then this woud give us an infinite ascending chain of ideals $I\\subsetneq I_1 \\subsetneq I_2 \\subsetneq \\ldots$. Since $R$ is Noetherian, this cannot happen, so we must have that for some $k$ the ideal $I_k$ is not divisible by a prime ideal, i.e. $I_k=R$ and consequently $I=P_1P_2\\ldots P_k$. This completes the existence part of the proof.\\\\\n\\emph{Uniqueness.} Let $I=P_1P_2\\ldots P_k=Q_1Q_2\\ldots Q_l$ be two factorizations of $I$ into (nonzero) prime ideals. By Corollary~\\ref{cor prime property ideal} (and induction) we get that $P_1$ divides $Q_i$ for some $i=1,2,\\ldots,l$. Since $Q_i$ is maximal we get $P_1=Q_i$. Change notation so that $i=1$. Now the cancellation rule, i.e. Proposition~\\ref{prop cancellation ideals}, gives $P_2 \\ldots P_k=Q_2 \\ldots Q_l$. With induction we get that $k=l$ and, after permuting the indices of the $Q_i$'s, that $P_i=Q_i$ for all $i$. This yields Theorem~\\ref{thm Dedekind unique fac}.\n\\end{proof}\n\n\\begin{proposition}\\label{prop finitely many ideal divisors}\nLet $I$ be a nonzero ideal in a Dedekind domain $R$. Then there are only finitely many ideals $J$ in $R$ such that $J|I$.\n\\end{proposition}\n\n\\begin{proof}\nThis follows e.~g.~ from unique factorization~\\ref{thm Dedekind unique fac}.\n\\end{proof}\n\n\n%------------------------------------------\n\\section{Further preliminaries}\n%------------------------------------------\n\nAn \\emph{absolute value} on a ring $R$ with values in an ordered ring $S$ is a function\n\\[R \\to S, \\quad x \\mapsto |x|\\]\nsatisfying for all $x,y \\in R$\n\\begin{itemize}\n\\item $|x|\\geq 0$;\n\\item $|x|=0 \\Leftrightarrow x=0$;\n\\item $|x y|=|x| |y|$;\n\\item $|x+y|\\leq |x|+|y|$.\n\\end{itemize} \n\nIf $R$ and $S$ are domains, with fields of fractions $K$ and $L$ respectively, then an absolute value on $R$ with values in $S$ extends uniquely to an absolute value on $K$ with values in $L$ by letting $|x/y|:=|x|/|y|$ for any $x,y \\in R$ with $y\\not=0$.\n\nWe note that it follows very quickly that \n\\[|1|=|-1|=1.\\]\n\nTwo easy examples are as follows.\n\\begin{lemma}\nThe following functions are absolute values.\n\\begin{itemize}\n\\item \\[ |.|_{\\text{arch}}: \\Z \\to \\Z, \\quad x \\mapsto \\sign(x)x\\]\n\\item For any domain $D$ and integer $c>1$\n\\[ |.|_{\\deg}: D[t] \\to \\Z, \\quad f \\mapsto c^{\\deg f} (\\text{if necessary, treat separately}\\ 0 \\mapsto 0).\\]\nIn particular, taking $D=\\F_q$ (a finite field with $q$ elements) and $c=q$, we get\n\\[ |.|_{\\deg}: \\F_q[t] \\to \\Z, \\quad |f|_{\\deg}=q^{\\deg f}.\\]\n\\end{itemize}\n\\end{lemma}\n\n\\begin{proof}\nWrite out definitions, and use standard properties of the degree function, i.e. $\\deg (fg)=\\deg f+\\deg g$ and $\\deg(f+g)\\leq \\max(\\deg f,\\deg g)$ (treating the zero polynomials separately, or setting $\\deg(0)=-\\infty$ with the appropriate operations/inequalities for $-\\infty$). The second case gives the stronger triangle inequality $|f+g|_{\\deg} \\leq \\max(|f|_{\\deg},|g|_{deg})$, which  immediately implies the weaker \\lq normal\\rq\\ triangle inequality.\n\\end{proof}\n\nWe note that taking $c=q$ for the last absolute value is just some natural normalisation choice. It is of no importance for the results here. So if e.~g.~ taking $c=2$ would make things easier, that choice would be fine too. Also, just considering $q=p$ (so $\\F_q=\\F_p \\simeq \\Z/p\\Z$) suffices for our purposes.\n\nA crude estimate for the determinant of a matrix is given below.\n\\begin{lemma}\nLet $R$ and $S$ be commutative rings with $S$ ordered, and $|.|:R \\to S$ an absolute value.\nLet $A$ be a matrix of size $n \\times n$ (for some $n\\in \\N$) with coefficients in $R$. Then \n\\[|\\det(A)|\\leq n! \\left(\\max_{1\\leq i,j\\leq n} |A_{i,j}|\\right)^n.\\]\n\\end{lemma}\n\n\\begin{proof}\nInduction using row expansion, or using permutation formula/definition for determinant.\n\\end{proof}\n\nThe following will be used for estimating norms.\n\n\\begin{corollary}\\label{cor estimate norm}\nLet $R$ and $S$ be commutative rings with $S$ ordered, and $|.|:R \\to S$ an absolute value.\nLet $A_1,\\ldots A_n$ be a matrix of size $n \\times n$ (for some nonzero $n\\in \\N$) with coefficients in $R$. Let $s_1\\ldots s_n \\in R$. Then \n\\[ \\left|\\det(\\sum_{k=1}^n s_k A_k) \\right| \\leq n! \\left(n \\max_{1\\leq i,j,k\\leq n} |(A_k)_{i,j}|\\right)^n \\left( \\max_{1\\leq k\\leq n}(|s_k|) \\right)^n.\\]\n\\end{corollary}\n\n%------------------------------------------\n\\section{Generalized division with remainder}\n%------------------------------------------\n\n$R$ is a PID (hence Dedekind domain) with nontrivial absolute value $|.| : R \\to \\Z$, and field of fractions $K$.\n$L$ is a finite and separable (for the time being..) field extension of $K$, and we let $S$ be the integral closure of $R$ in $L$. So $S$ is a Dedekind domain.\nWe have the norm map $\\NN: L \\to K$, restricting to a function $S \\to R$. Denote $n:=[L:K]$. Also assume $R$ to be infinite (our main theorem becomes trivial if $R$ is finite).\n\nWe also assume that $|.|: R \\to \\Z$ is a \\emph{Euclidean function}, i.e. for all $a,b \\in R$ with $b\\not=0$ there exists a $q \\in R$ such that $|a-qb|<|b|$.\nIn fact, we take $R$ to be a Euclidean domain as defined in Lean. So it comes with a choice of quotient function $q: R^2 \\to \\Z$ (ignoring currying in this math writeup).\n%, and the well founded relation ...\n\nSince $R$ is a PID, $S$ contains an $R$-integral basis, i.e. there are (basis elements) $b_1,b_2,\\ldots,b_n \\in S$ such that for every $x \\in S$ there are unique (scalars) $s_1,s_2,\\ldots s_n \\in R$ with $x=\\sum_{i=1}^n s_i b_i$.\nThe scalars define a function $s: S \\to R^n, x \\mapsto (s_1,\\ldots,s_n)$, which is obviously $R$-linear.\n\nWe start with an estimate on norms.\n\n\\begin{lemma}\\label{lem norm estimate}\nThere exists a constant $C \\in \\R_{> 0}$, depending only on the $R$-integral basis $b_1,\\ldots,b_n \\in S$, such that for any $x=\\sum_{i=1}^n s_i b_i \\in S$\n\\[|\\NN(x)| \\leq C (\\max_i |s_i|)^n.\\] \n\\end{lemma}\n\n\\begin{proof}\nFollows from Corollary~\\ref{cor estimate norm}.\n\\end{proof}\n\nWe will focus on Euclidean domains with the property that \\lq sufficiently many remainders come arbitrary close to each other\\rq (in higher dimensions) in the following sense.\n\n\\begin{definition}\\label{def admissible}\nWe call $R$ \\emph{admissible} if both:\n\\begin{itemize}\n\\item We have a function $\\M : \\R_{>0} \\times \\N \\to \\N$;\n\\item For all $ \\epsilon \\in \\R_{>0}$, $n \\in \\N$, $b \\in R$, and $A : \\N_{\\leq \\M(\\epsilon,n)} \\to R^n$ there exists $j,k \\in \\N_{\\leq \\M(\\epsilon,n)}$ such that\n\\[j \\neq k \\text{ and for all } i\\in\\{1,\\ldots,n\\},\\ |\\remainder(A(k)_i,b)-\\remainder(A(j)_i,b)| < \\epsilon |b|.\\]\n\\end{itemize}\n\\end{definition}\n\nThere are equivalent, arguably cleaner, definitions (e.~g.~ without actually incorporating division with remainder), but for the time being this one seems to work just fine. (And will probably be handy for actual computations at some point.)\n\nWe will show later that $\\Z$ and $\\Fq[t]$ are admissible domains.\nNow our main ingredient for the finiteness of the class group.\n\n\\begin{theorem} Assume $R$ is admissible.\nThere exists a finite set $M \\subset R-\\{0\\}$, depending only on the $R$-integral basis $b_1,\\ldots,b_n \\in S$, such that\nfor all $a \\in S$ and $b \\in R-\\{0\\}$ there exist $q \\in S$ and $r \\in M$ with $|\\NN(ra-qb)| < |\\NN(b)|$.\n\\end{theorem}\n\n\\begin{proof}\n\nLet $C$ be as in Lemma~\\ref{lem norm estimate} and choose $\\epsilon \\in \\R_{>0}$ such that\n\\begin{equation}\\label{eqn choice epsilon}\n\\epsilon \\leq 1/\\sqrt[n]{C}.\n\\end{equation}\nLet $\\M$ be as in Definition~\\ref{def admissible}.\n\nWrite $a=\\sum_{i=1}^n s_i b_i$ ($s_i\\in R)$.\n\nChoose $\\M(\\epsilon,n)+1$ \\emph{distinct} elements $\\mu^{(0)},\\ldots,\\mu^{(\\M(\\epsilon,n))}$ of $R$ (possible since we assumed $R$ to be infinite).\nAnd let $M:=\\{\\mu^{(k)}-\\mu^{(j)} : 0\\leq j<k\\leq \\M(\\epsilon,n)\\}$, so $M \\subseteq R-\\{0\\}$ (the containment is in fact strict since $M$ is finite and $R$ is not).\n\nFor any $j \\in \\{0,\\ldots,\\M(\\epsilon,n)\\}$ and $i \\in \\{1,\\ldots n\\}$ we let $q^{(j)}_i:=\\quotient(\\mu^{(j)} s_i,b)$ and $r^{(j)}_i:=\\remainder(\\mu^{(j)} s_i,b)$. So $q^{(j)}_i,r^{(j)}_i \\in R$ and\n\\[\\mu^{(j)} s_i =q^{(j)}_i b+r^{(j)}_i \\text{ and } |r^{(j)}_i|<|b|,\\]\nand hence\n\\begin{equation}\\label{eqn vector q and r}\n\\mu^{(j)} a=\\sum_{i=1}^n \\mu^{(j)} s_i b_i= \\sum_{i=1}^n (q^{(j)}_i b+r^{(j)}_i)b_i=\\left( \\sum_{i=1}^n q^{(j)}_i b_i\\right)b+\\sum_{i=1}^n r^{(j)}_i b_i.\n\\end{equation}\nConsider the function $A : \\N_{\\leq \\M(\\epsilon,n)} \\to R^n,\\ j \\mapsto (\\mu^{(j)} s_1,\\ldots,\\mu^{(j)} s_n)$. Then by Definition~\\ref{def admissible} we have indices $j,k$ with $0\\leq j<k\\leq \\M(\\epsilon,n)$ such that \n\\begin{equation}\\label{eqn remainder bounds}\n\\text{for all } i \\in\\{1,\\ldots,n\\},\\ |r^{(k)}_i - r^{(j)}_i| < \\epsilon |b|.\n\\end{equation}\nNow define\n\\[r:=\\mu^{(k)}-\\mu^{(j)} \\in M\\]\nand\n\\[q:=\\sum_{i=1}^n (q^{(k)}_i-q^{(j)}_i) b_i \\in S.\\]\nThen by~\\eqref{eqn vector q and r} (with that $j$ specialised to both (the new) $j$ and $k$), we have\n\\[ra-qb=\\sum_{i=1}^n \\left(r^{(k)}_i - r^{(j)}_i\\right) b_i.\\]\nSo it remains to show that\n\\begin{equation}\\label{eqn final norm estimate}\n\\left|\\NN \\left(\\sum_{i=1}^n \\left(r^{(k)}_i - r^{(j)}_i\\right) b_i\\right)\\right| < |\\NN(b)|.\n\\end{equation}\nNote that since $b \\in R$ (coerced into $S$ before taking the norm), we get\n\\begin{equation}\\label{eqn norm b}\n\\NN(b)=b^n.\n\\end{equation}\nNow we have\n\\begin{alignat*}{3}\n& \\left|\\NN \\left(\\sum_{i=1}^n \\left(r^{(k)}_i - r^{(j)}_i\\right) b_i\\right)\\right|  && \\leq C\\left( \\max_i |r^{(k)}_i - r^{(j)}_i| \\right)^n  && \\quad \\text{(by Lemma~\\ref{lem norm estimate})}\\\\\n& && < C (\\epsilon |b|)^n&& \\quad \\text{(by~\\eqref{eqn remainder bounds})}\\\\\n& && \\leq |b|^n&& \\quad \\text{(by~\\eqref{eqn choice epsilon} )}\\\\\n& && =|\\NN(b)| && \\quad \\text{(by multiplicativity of $|.|$ and~\\eqref{eqn norm b})}.\n\\end{alignat*}\nThis proves~\\eqref{eqn final norm estimate} and thereby finishes the proof of the theorem.\n\\end{proof}\n\nNow we need to generalize the result above from $b \\in R$ to $b \\in S$ (nonzero).\n\n\\begin{corollary}\\label{cor generalized norm euclidean}\nAssume $R$ is admissible.\nThere exists a finite set $M \\subset R-\\{0\\}$, depending only on the $R$-integral basis $b_1,\\ldots,b_n \\in S$, such that\nfor all $a, b \\in S$ with $b \\not=0$ there exist $q \\in S$ and $r \\in M$ with $|\\NN(ra-qb)| < |\\NN(b)|$.\n\\end{corollary}\n\n\\begin{proof}\nUnfold definitions (via $\\gamma=a/b)$ and use multiplicativity of the norm \\ldots\n\\end{proof}\n\n\n\n%------------------------------------------\n\\section{Finiteness of the class group in the admissible case}\n%------------------------------------------\n\nNotation as in previous section.\n\nThe following is a trivial statement about choosing an element of minimal nonzero absolute norm in a nonzero ideal (which obviously also holds for any subset containing a nonzero element).\n\\begin{lemma}\\label{lem element of nonzero minimal norm}\nLet $I$ be a nonzero ideal of $S$. Then there exists a nonzero $b \\in I$ such that for all $c \\in I$\n\\begin{equation}\\label{eqn element of nonzero minimal norm}\n|\\NN(c)| < |\\NN(b)| \\Rightarrow c=0.\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}\nTrivial, namely $\\{|\\NN(b)| : b \\in I-\\{0\\} \\}$ contains a smallest element, which is a positive integer \\ldots\n\\end{proof}\n\n\\begin{theorem}\nLet $M$ be as in Corollary~\\ref{cor generalized norm euclidean} and let $m$ be a nonzero common multiple of all elements in $M$ (e.~g.~ the product, so it exists).\nThen for any nonzero ideal $I$ of $S$, there exists an ideal $J$ of $S$ such that $I \\sim J$ and $J | \\langle m \\rangle_S$.\n\\end{theorem}\n\n\\begin{proof}\nLet $I$ be a nonzero ideal of $S$.\n\\begin{itemize}\n\\item Choose a nonzero $b \\in I$ such that for all $c \\in I$ we have~\\eqref{eqn element of nonzero minimal norm}.\n(Possible by Lemma\\ref{lem element of nonzero minimal norm}.)\n\\item Let $a \\in I$. Since $M$ is as in Corollary~\\ref{cor generalized norm euclidean}, we get $q \\in S$ and $r \\in M$ with $|\\NN(r a-qb)| < |\\NN(b)|$. Let $c:=ra-qb \\in I$ (since $a,b \\in I$), then the previous item gives us $ra-qb=0$, i.e.\n\\[ra=qb.\\]\n\\item\nSo $\\langle m \\rangle_S I \\subseteq \\langle b \\rangle$.\n\\item\nNow $ \\langle m \\rangle I = \\langle b \\rangle J$ for a nonzero ideal $J$ of $S$, and consequently $I \\sim J$. Furthermore, $b \\in I$, so $ \\langle b \\rangle \\subset I$, so $ \\langle m \\rangle \\langle b \\rangle \\subset \\langle m \\rangle I = \\langle b \\rangle J$. This gives $\\langle m \\rangle \\subset J$, and hence $J | \\langle m \\rangle$. \n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}\\label{thm class group finite admissible} \nThe class group of $S$ is finite.\n\\end{theorem}\n\n\\begin{proof}\nPrevious theorem, together with Proposition~\\ref{prop finitely many ideal divisors} gives finitely may possibilities for $J$. So finitely many possibilities for $\\overline{I} \\in \\Cl(S)$. Hence $\\Cl(S)$ is finite.\n\\end{proof}\n\n%------------------------------------------\n\\section{Admissibility of $\\Z$ and $\\F_q[t]$}\n%------------------------------------------\n\n\\begin{lemma}\\label{lem Z admissible}\n$\\Z$ (with $|.|_{\\text{arch}}$) is admissible.\n\\end{lemma}\n\n\\begin{proof}\nThis easily follows directly from the box principle\\ldots\n\\end{proof}\n\nThe remainder of this section is about the admissibility of $\\F_q[t]$, where $\\F_q$ denotes a finite field wit $q$ elements.\nThe key is the following result.\n\n\\begin{lemma}\nLet $D \\in \\N$, $b \\in \\F_q[t]$ (nonzero if that makes live easier), and define $M:=q^D$. Then for every function\n$A_1: \\N_{\\leq M} \\to \\F_q[t]$ with $\\forall j \\in  \\N_{\\leq M}, \\deg A_1(j) < \\deg b$, there exists $j,k \\in \\N_{\\leq M}$ such that\n\\[j \\neq k \\text{ and } \\deg(A_1(k)-A_1(j)) < \\deg b-D.\\]\n\\end{lemma}\n\n\\begin{proof}\nWLOG $D \\leq \\deg b$ (note we use $\\deg 0 = -\\infty < $ any integer).\n\nEvery $A_1(j)$ is of the form $\\sum_{i \\in \\N_{< \\deg b}} c_i^{(j)} t^i$ with coefficients $c_i^{(j)} \\in \\F_q$.\nThere are a priori $M=q^D$ possibilities for the coefficients $c_{\\deg b-1}^{(j)}, c_{\\deg b-2}^{(j)},\\ldots, c_{\\deg b-D}^{(j)}$.\nSo by the box principle, among the $q^D+1$ polynomials $A_1(0), \\ldots, A_1(M)$, there must be at least two, say $A_1(j), A_1(k),\\ j\\not=k$ with coefficients \n\\[c_{\\deg b-1}^{(j)}=c_{\\deg b-1}^{(k)}, c_{\\deg b-2}^{(j)}= c_{\\deg b-2}^{(k)},\\ldots, c_{\\deg b-D}^{(j)}= c_{\\deg b-D}^{(k)}.\\] Hence we can write\n \\[A_1(k)-A_1(j)=\\sum_{i \\in \\N_{<\\deg b-D}} (c_i^{(k)}-c_i^{(j)}) t^i,\\]\ni.e. $\\deg (A_1(k)-A_1(j))<\\deg b-D$, as was to be shown.\n\\end{proof}\n\nWe now translate the previous lemma.\n\\begin{lemma}\nLet $\\epsilon \\in \\R_{>0}$, $b \\in \\F_q[t]$, and choose $D \\in \\N$ such that $M:=q^D\\geq 1/\\epsilon$ (e.~g.~ $D:=\\operatorname{ceiling} (-\\log \\epsilon/\\log q)$).\nThen for every function\n$A_1: \\N_{\\leq M} \\to \\F_q[t]$ there exists $j,k \\in \\N_{\\leq M}$ such that\n\\[j \\neq k \\text{ and } |\\remainder(A_1(k),b)-\\remainder(A_1(j),b)| < \\epsilon |b|.\\]\n\\end{lemma}\n\n\\begin{proof}\nChoose $A_1$ and write $f_i:= |\\remainder(A_1(i),b)|$, so $\\deg f_i < \\deg b$. By the previous Lemma we have $j\\not=k$ such that\n\\[\\deg (f_k-f_j) <\\deg b -D.\\]\nIt suffices to show that\n\\[|f_k-f_j| <\\epsilon |b|.\\]\nThis holds, since:\n\\[ |f_k-f_j|=q^{\\deg(f_k-f_j)}<q^{\\deg b -D}=q^{\\deg b}/M=|b|/M\\leq \\epsilon |b|.\\]\n\\end{proof}\n\n\n\\begin{lemma}\\label{lem admissible 1D}\nFor $R=\\F_q[t]$ both:\n\\begin{itemize}\n\\item we have a function $\\M_1 : \\R_{>0} \\to \\N$;\n\\item for all $ \\epsilon \\in \\R_{>0}$, $b \\in R$, and $A_1: \\N_{\\leq \\M_1(\\epsilon)} \\to R$ there exists $j,k \\in \\N_{\\leq \\M_1(\\epsilon)}$ such that\n\\[j \\neq k \\text{ and } |\\remainder(A_1(k),b)-\\remainder(A_1(j),b)| < \\epsilon |b|.\\]\n\\end{itemize}\n\\end{lemma}\n\n\\begin{proof}\nFollows from previous lemma (with $\\M_1(\\epsilon)=M=q^D$).\n\\end{proof}\n\n\\begin{lemma}\\label{lem Fqt admissible}\n$\\F_q[t]$ (with $|.|_{\\deg}$) is admissible.\n\\end{lemma}\n\n\\begin{proof}\nFollows from Lemma~\\ref{lem admissible 1D} for any $R$ with a nonarchimedean absolute value, by using the box principle\\ldots\n(Taking $\\M(\\epsilon,n)=\\M_1(\\epsilon)^n$.)\n\\end{proof}\n\n%------------------------------------------\n\\section{On the finiteness of the class group for global fields}\n%------------------------------------------\n\nLet $\\F$ be a finite field. Let us specialise to $R=\\Z$ or $R=\\F[t]$, with fraction field $K=\\Q$ or $K=\\F(t)$ respectively. As before, we let $L$ be a finite separable field extension of $K$ (where separability is automatic if $K=\\Q$) and denote by $S$ the integral closure of $R$ in $L$, called the ring of integers of $L$ (which strictly speaking depends on $R$ in the positive characteristic case).\n\nFrom Lemmata~\\ref{lem Z admissible} and~\\ref{lem Fqt admissible} together with Theorem~\\ref{thm class group finite admissible} we now get our main theorem.\n\n\\begin{theorem}\nThe class group of $S$ is finite.\n\\end{theorem}\n\n\\end{document}\n\n\n%------------------------------------------\n\\section{Example: The class group of $\\Q[\\sqrt{-5}]$}\n%------------------------------------------\n\nWe claim that for $K=\\Q(\\sqrt{-5})$, the statements hold for $M=2$.\n...\n\nMore precisely,  $J | \\langle 2 \\rangle = \\langle 2,1+\\sqrt{-5} \\rangle^2$, where $P:=\\langle 2,1+\\sqrt{-5} \\rangle$ is a nonprincipal prime ideal. From which we now see that $\\Cl(\\OK)=\\{\\overline{\\OK},\\overline{P}\\}$, in particular $h(\\OK)=\\#\\Cl(\\OK)=2$.\n\n\\end{document}\n\n\n%------------------------------------------\n\\bibliographystyle{amsplain}\n%------------------------------------------\n\n\\bibliography{FinitenessClassGrou[}\n\n", "meta": {"hexsha": "5b01f68b75e6587b666e182bbf0f272bd6d38bf1", "size": 23533, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FiniteClassGroup.tex", "max_stars_repo_name": "lean-forward/class-number-journal", "max_stars_repo_head_hexsha": "4b87fc8870e034b30634cea9549dec618c851ca7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FiniteClassGroup.tex", "max_issues_repo_name": "lean-forward/class-number-journal", "max_issues_repo_head_hexsha": "4b87fc8870e034b30634cea9549dec618c851ca7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FiniteClassGroup.tex", "max_forks_repo_name": "lean-forward/class-number-journal", "max_forks_repo_head_hexsha": "4b87fc8870e034b30634cea9549dec618c851ca7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.1769722814, "max_line_length": 642, "alphanum_fraction": 0.6563973994, "num_tokens": 7931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044135, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43199354468384005}}
{"text": "\\documentclass[]{article}\n\n\\usepackage{caption,subcaption,graphicx,float,url,amsmath,amssymb,amsthm,tocloft,cancel,mathrsfs}\n\\usepackage[toc,nonumberlist]{glossaries}\n\\usepackage{glossaries-extra,thmtools,gensymb,braket,bm,tensor}\n\\usepackage[toc,page]{appendix}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage[toc,page]{appendix}\n\\newcommand\\numberthis{\\addtocounter{equation}{1}\\tag{\\theequation}}\n\\newcommand{\\Lagr}{\\mathscr{L}}\n\\newtheorem{thm}{Theorem}\n\\newtheorem{defn}[thm]{Definition}\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lemma}[thm]{Lemma}\n\\graphicspath{{figs/}}\n\\widowpenalty10000\n\\clubpenalty10000\n\\setcounter{tocdepth}{2}\n\n%opening\n\\title{Theoretical Minimum\\\\General Relativity\\\\Exercises}\n\\author{Simon Crase (compiler)\\\\simon@greenweaves.nz}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\tThese are some exercises arising from the \\emph{General Relativity}\\cite{susskind2012general} lectures from Leonard Susskind's \\emph{Theoretical Minimum} series\\cite{susskind2007theoretical}. Section \\ref{sec:schwartzchild:metric} contains a derivation of the Schwarzschild metric. Section \\ref{sec:gravitational:waves} examines linearized solutions and gravitational waves.\n\t\n\tDisclaimer: I have created these notes as an aide-m\\'emoire for my own use; if you find them useful, you are welcome, but I'd appreciate hearing from you. They are not intended \n\tas a substitute for listening to the lectures. The intellectual property for all material derived from the lectures belongs, of course, to Professor Susskind; any mistakes, however, are my own.\n\t\n\tThe notes were created using TexStudio\\cite{TexStudio}, which I recommend for compiling them to a PDF, and the bibliography was created using JabRef\\cite{Jabref}.\n\\end{abstract}\n\n\\tableofcontents\n\\listoffigures\n\\listoftables\n\\listoftheorems\n\n\t\n\\section{Schwarzschild Metric}\\label{sec:schwartzchild:metric}\n\nThe Schwarzschild Metric is presented, without proof, in \\cite[Lecture 6]{susskind2012general}. In this section the coordinates are denoted: $(t,r,\\theta,\\phi)$. The summation convention is observed for all other indices: e.g. $\\Gamma\\indices{^\\alpha_{\\gamma\\alpha}}$ denoted summation over the dummy index $\\alpha$, but $\\Gamma\\indices{^\\theta_{\\gamma\\theta}}$ is not summed.\n\n\\subsection{Ansatz}\nWe will seek a solution of the form\\cite{Adler1965Introduction}:\n\n\\begin{align*}\n\tdt^2 =& e^{\\nu(r)} dt^2 -e^{\\lambda(r)} dr^2 -r^2 d \\Omega^2 \\text{, where} \\numberthis \\label{eq:schwartzschild:ansatz}\\\\\n\td \\Omega^2 =&d\\theta^2 + cos^2 \\theta d\\phi^2 \n\\end{align*}\n\nThe  non-zero $g_{\\mu\\nu}$ are:\n\\begin{align*}\n\tg_{tt}=& e^{\\nu(r)}\\\\\n\tg_{rr}=&-e^{\\lambda(r)}\\\\\n\tg_{\\theta\\theta}=&-r^2\\\\\n\tg_{\\phi\\phi}=&-r^2 \\cos^2 \\theta\\\\\n\\end{align*}\n\nThe $g^{\\mu\\nu}$ are the inverse of the $g_{\\mu\\nu}$, so: \n\\begin{align*}\n\tg^{tt}=& e^{-\\nu(r)}\\\\\n\tg^{rr}=&-e^{-\\lambda(r)}\\\\\n\tg^{\\theta\\theta}=&-\\frac{1}{r^2}\\\\\n\tg^{\\phi\\phi}=&-\\frac{1}{r^2 \\cos^2 \\theta}\n\\end{align*}\n\nThe only non-zero derivatives of $g^{\\mu\\nu}$ are:\n\\begin{align*}\n\t\\partial_r g_{tt}=& \\nu^\\prime(r) e^{\\nu(r)}\\\\\n\t\\partial_r g_{rr}=& -\\lambda^\\prime(r) e^{\\lambda(r)}\\\\\n\t\\partial_r g_{\\theta\\theta}=& -2 r\\\\\n\t\\partial_r g_{\\phi\\phi}=& -2 r \\cos^2 \\theta\\\\\n\t\\partial_\\theta g_{\\phi\\phi}=& 2 r^2 \\cos \\theta \\sin \\theta\n\\end{align*}\n\n\\subsection{Christoffel Symbols}\n\nWe start be enquiring which Christoffel are not identically zero. For each $\\rho$ we ask whether there are any $(\\mu,\\nu)$ for which the terms making up $\\Gamma\\indices{^\\rho_{\\mu\\nu}}$ are non-zero.\n\n\\begin{align*}\n\t\\Gamma\\indices{^t_{\\mu\\nu}} =&\\frac{1}{2} \\big[\\underbrace{ \\partial_\\mu g_{t\\nu}}_\\text{$\\mu=r,\\nu=t$} + \\underbrace{\\partial_\\nu g_{\\mu t}}_\\text{$\\mu=t,\\nu=r$} - \\underbrace{\\partial_t g_{\\mu\\nu}}_\\text{$\\equiv0$}\\big] e^{-\\nu(r)}\\\\\n\t\\Gamma\\indices{^t_{rt}}=&\\frac{1}{2} \\partial_r g_{tt}  e^{-\\nu(r)}\\\\\n\t=&\\frac{1}{2}\\nu^\\prime(r) \\cancel{e^{\\nu(r)}}\\cancel{e^{-\\nu(r)}}\\\\\n\t=&\\frac{\\nu^\\prime(r)}{2}\\\\\n\t\\Gamma\\indices{^t_{tr}}=&\\frac{\\nu^\\prime(r)}{2}\\\\\n\t\\Gamma\\indices{^t_{rt}}=&\\Gamma\\indices{^t_{tr}}=\\frac{\\nu^\\prime(r)}{2} \\numberthis \\label{eq:Gamma:ttr}\n\\end{align*}\n\n\\begin{align*}\n\t\\Gamma\\indices{^r_{\\mu\\nu}} =& - \\frac{1}{2} \\big[\\underbrace{ \\partial_\\mu g_{r\\nu}}_\\text{$\\mu=\\nu=r$} + \\underbrace{\\partial_\\nu g_{\\mu r}}_\\text{ $\\mu=\\nu=r$} - \\underbrace{\\partial_r g_{\\mu\\nu}}_\\text{$\\mu=\\nu$}\\big] e^{-\\lambda(r)}\\\\\n\t\\Gamma\\indices{^r_{tt}} =&-\\frac{1}{2} \\big[-\\partial_r g_{tt}\\big]e^{-\\lambda(r)}\\\\\n\t=&\\frac{1}{2} \\big[\\nu^\\prime(r) e^{\\nu(r)}\\big] e^{-\\lambda(r)}\\\\\n\t=& \\frac{1}{2} \\nu^\\prime(r) e^{\\nu(r)-\\lambda(r)} \\numberthis \\label{eq:Gamma:rtt}\\\\\n\t\\Gamma\\indices{^r_{rr}} =&-\\frac{1}{2}\\big[\\partial_r g_{rr}\\big] e^{-\\lambda(r)}\\\\\n\t=&\\frac{1}{2}\\big[\\lambda^\\prime(r) \\cancel{e^{\\lambda(r)}}\\big] \\cancel{e^{-\\lambda(r)}}\\\\\n\t=&\\frac{\\lambda^\\prime(r)}{2} \\numberthis \\label{eq:Gamma:rrr}\\\\\n\t\\Gamma\\indices{^r_{\\theta\\theta}} =&-\\frac{1}{2}\\big[-\\partial_r g_{\\theta\\theta}\\big] e^{-\\lambda(r)}\\\\\n\t=&\\frac{1}{\\cancel{2}}\\big[-\\cancel{2} r \\big] e^{-\\lambda(r)}\\\\\n\t=& -r  e^{-\\lambda(r)}\\numberthis \\label{eq:Gamma:rtHtH}\\\\\n\t\\Gamma\\indices{^r_{\\phi\\phi}} =&-\\frac{1}{2} \\big[-\\partial_r g_{\\phi\\phi}\\big]e^{-\\lambda(r)}\\\\\n\t=&\\frac{1}{\\cancel{2}} \\big[-\\cancel{2} r \\cos^2 \\theta\\big]e^{-\\lambda(r)}\\\\\n\t=& -r \\cos^2 \\theta e^{-\\lambda(r)} \\numberthis \\label{eq:Gamma:rpHpH}\n\\end{align*}\n\n\\begin{align*}\n\t\\Gamma\\indices{^\\theta_{\\mu\\nu}} =&- \\frac{1}{2} \\big[\\underbrace{ \\partial_\\mu g_{\\theta\\nu}}_\\text{$\\mu=r,\\nu=\\theta$} + \\underbrace{\\partial_\\nu g_{\\mu \\theta}}_\\text{$\\mu=\\theta,\\nu=r$} - \\underbrace{\\partial_\\theta g_{\\mu\\nu}}_\\text{$\\mu=\\nu=\\phi$}\\big] \\frac{1}{r^2} \\\\\n\t\\Gamma\\indices{^\\theta_{r\\theta}} =& - \\frac{1}{2} \\big[\\partial_r g_{\\theta\\theta} \\big] \\frac{1}{r^2}\\\\\n\t=& - \\frac{1}{2} \\big[-2r \\big] \\frac{1}{r^2}\\\\\n\t=& \\frac{1}{r} \\\\\n\t\\Gamma\\indices{^\\theta_{r\\theta}} =& \\Gamma\\indices{^\\theta_{\\theta r}} =\\frac{1}{r} \\numberthis \\label{eq:Gamma:tHtHr}\\\\\n\t\\Gamma\\indices{^\\theta_{\\phi\\phi}} =&- \\frac{1}{2} \\big[-\\partial_\\theta g_{\\phi\\phi}\\big] \\frac{1}{r^2}\\\\\n\t=& \\frac{1}{\\cancel{2}} \\big[\\cancel{2} \\bcancel{r^2} \\cos \\theta \\sin \\theta\\big] \\frac{1}{\\bcancel{r^2}}\\\\\n\t=& \\cos \\theta \\sin \\theta \\numberthis \\label{eq:Gamma:tHpHpH}\t\t\n\\end{align*}\n\n\\begin{align*}\n\t\\Gamma\\indices{^\\phi_{\\mu\\nu}} =&- \\frac{1}{2} \\big[\\underbrace{ \\partial_\\mu g_{\\phi\\nu}}_\\text{$\\mu\\in\\{\\theta,r\\},\\nu=\\phi$} + \\underbrace{\\partial_\\nu g_{\\mu \\phi}}_\\text{$\\mu=\\phi,\\nu\\in\\{\\theta,r\\}$} - \\underbrace{\\partial_\\phi g_{\\mu\\nu}}_\\text{$\\equiv0$}\\big] \\frac{1}{r^2 \\cos^2 \\theta} \\\\\n\t\\Gamma\\indices{^\\phi_{\\theta\\phi}} =&- \\frac{1}{2} \\big[ \\partial_\\theta g_{\\phi\\phi} \\big] \\frac{1}{r^2 \\cos^2 \\theta}\\\\\n\t=&- \\frac{1}{2} \\big[ 2 r^2 \\cos \\theta \\sin \\theta \\big] \\frac{1}{r^2 \\cos^2 \\theta}\\\\\n\t=&-\\tan \\theta \\\\\n\t\\Gamma\\indices{^\\phi_{\\theta\\phi}} =&\\Gamma\\indices{^\\phi_{\\phi\\theta}} = -\\tan \\theta \\numberthis \\label{eq:Gamma:pHpHtH}\\\\\n\t\\Gamma\\indices{^\\phi_{r\\phi}} =& - \\frac{1}{2} \\big[\\partial_r g_{\\phi\\phi}\\big] \\frac{1}{r^2 \\cos^2 \\theta}\t\\\\\n\t=& \\bcancel{-} \\frac{1}{\\cancel{2}} \\big[\\bcancel{-} \\cancel{2} r \\xcancel{\\cos^2 \\theta} \\big] \\frac{1}{r^2 \\xcancel{\\cos^2 \\theta}}\t\\\\\n\t=& \\frac{1}{r}\\\\\n\t\\Gamma\\indices{^\\phi_{r\\phi}} =& \\Gamma\\indices{^\\phi_{\\phi r}} = \\frac{1}{r} \\numberthis \\label{eq:Gamma:pHrpH}\n\\end{align*}\n\n\\subsection{Riemann \\& Ricci Tensors}\n\nFrom \\cite[Lecture II]{akhmedov2016lectures}\n\\begin{align*}\n\tR\\indices{^\\mu_{\\nu\\alpha\\beta}} =& \\partial_\\alpha \\Gamma\\indices{^\\mu_{\\nu\\beta}} - \\partial_\\beta \\Gamma\\indices{^\\mu_{\\nu\\alpha}} + \\Gamma\\indices{^\\mu_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\nu\\beta}} - \\Gamma\\indices{^\\mu_{\\gamma\\beta}} \\Gamma\\indices{^\\gamma_{\\nu\\alpha}}\\\\\n\tR_{\\mu\\nu} =& R\\indices{^\\alpha_{\\mu\\alpha\\nu}}\\\\\n\t=& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{\\mu\\nu}} - \\partial_\\nu \\Gamma\\indices{^\\alpha_{\\mu\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\mu\\nu}} - \\Gamma\\indices{^\\alpha_{\\gamma\\nu}} \\Gamma\\indices{^\\gamma_{\\mu\\alpha}}\\\\\n\tR =& R_{\\mu\\nu} g^{\\mu\\nu}\n\\end{align*}\n\nWe compute the components of $R_{\\mu\\nu}$.\n\n\\subsubsection{$R_{tt}$ and $R_{rr}$}\nSince (\\ref{eq:schwartzschild:ansatz}) contains two unknown functions, I expect to be able to determine them from two components of $R_{\\mu\\nu}$.\n\n\\begin{align*}\n\tR_{tt} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{tt}} - \\underbrace{\\partial_t \\Gamma\\indices{^\\alpha_{t\\alpha}}}_\\text{$=0$} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{tt}} - \\Gamma\\indices{^\\alpha_{\\gamma t}} \\Gamma\\indices{^\\gamma_{t\\alpha}} \\\\\n\t=& \\partial_r \\Gamma\\indices{^r_{tt}}  + \\big[\\Gamma\\indices{^t_{rt}}+\\Gamma\\indices{^r_{rr}} + \\Gamma\\indices{^\\theta_{r\\theta}}+ \\Gamma\\indices{^\\phi_{r\\phi}}\\big] \\Gamma\\indices{^r_{tt}} - 2\\Gamma\\indices{^t_{r t}} \\Gamma\\indices{^r_{tt}} \\\\\n\t=& \\partial_r \\Gamma\\indices{^r_{tt}}  + \\big[-\\Gamma\\indices{^t_{rt}}+\\Gamma\\indices{^r_{rr}} + \\Gamma\\indices{^\\theta_{r\\theta}}+ \\Gamma\\indices{^\\phi_{r\\phi}}\\big] \\Gamma\\indices{^r_{tt}} \\\\\n\t=& \\partial_r \\big[\\frac{1}{2} \\nu^\\prime(r) e^{\\nu(r)-\\lambda(r)}\\big]  + \\big[-\\frac{\\nu^\\prime(r)}{2}+\\frac{\\lambda^\\prime(r)}{2} + \\frac{1}{r} + \\frac{1}{r}\\big] \\frac{1}{2} \\nu^\\prime(r) e^{\\nu(r)-\\lambda(r)}  \\\\\n\t=& \\frac{1}{2} \\big[ \\nu^{\\prime\\prime}(r) + \\nu^\\prime(r) \\big(\\nu^\\prime(r)-\\lambda^\\prime(r)\\big)\\big] e^{\\nu(r)-\\lambda(r)}+ \\big[-\\frac{\\nu^\\prime(r)-\\lambda^\\prime(r)}{2} + \\frac{2}{r}\\big] \\frac{1}{2} \\nu^\\prime(r) e^{\\nu(r)-\\lambda(r)} \\\\\n\t=& \\frac{1}{2} \\bigg[\\nu^{\\prime\\prime}(r) + \\frac{1}{2}\\nu^\\prime(r) \\big(\\nu^\\prime(r)-\\lambda^\\prime(r)\\big)+ \\frac{2}{r}\\nu^\\prime(r)\\bigg] e^{\\nu(r)-\\lambda(r)} \\numberthis \\label{eq:Rtt}\n\\end{align*}\n\n\\begin{align*}\n\tR_{rr} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{rr}} - \\partial_r \\Gamma\\indices{^\\alpha_{r\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{rr}} - \\Gamma\\indices{^\\alpha_{\\gamma r}} \\Gamma\\indices{^\\gamma_{r\\alpha}}\\\\\n\t=& \\underbrace{\\partial_t \\Gamma\\indices{^t_{rr}}}_\\text{$=0$} + \\cancel{\\partial_r \\Gamma\\indices{^r_{rr}} } +\\underbrace{\\partial_\\theta \\Gamma\\indices{^\\theta_{rr}}}_\\text{$=0$} + \\underbrace{\\partial_\\phi \\Gamma\\indices{^\\phi_{rr}}}_\\text{$=0$}\\\\\n\t&- \\partial_r \\Gamma\\indices{^t_{rt}} - \\cancel{\\partial_r \\Gamma\\indices{^r_{rr}}} - \\partial_r \\Gamma\\indices{^\\theta_{r\\theta}} - \\partial_r \\Gamma\\indices{^\\phi_{r\\phi}}\\\\\n\t&+ \\big[\\Gamma\\indices{^t_{rt}} + \\bcancel{\\Gamma\\indices{^r_{rr}}} + \\Gamma\\indices{^\\theta_{r\\theta}}  + \\Gamma\\indices{^\\phi_{r\\phi}}\\big] \\Gamma\\indices{^r_{rr}}\\\\\n\t&- \\Gamma\\indices{^t_{t r}} \\Gamma\\indices{^t_{rt}} - \\bcancel{\\Gamma\\indices{^r_{r r}} \\Gamma\\indices{^r_{rr}}} - \\Gamma\\indices{^\\theta_{\\theta r}} \\Gamma\\indices{^\\theta_{r\\theta}} - \\Gamma\\indices{^\\phi_{\\phi r}} \\Gamma\\indices{^\\phi_{r\\phi}}\\\\\n\t=& - \\partial_r \\frac{\\nu^\\prime(r)}{2}  - \\partial_r \\frac{1}{r} - \\partial_r \\frac{1}{r} + \\big[\\frac{\\nu^\\prime(r)}{2}  + \\frac{1}{r}  + \\frac{1}{r}\\big] \\frac{\\lambda^\\prime(r)}{2}- \\big(\\frac{\\nu^\\prime(r)}{2}\\big)^2 -  \\frac{1}{r^2}  - \\frac{1}{r^2}\\\\\n\t=& -\\frac{\\nu^{\\prime\\prime}(r)}{2} + \\cancel{\\frac{2}{r^2}} + \\bigg(\\frac{\\nu^\\prime(r)}{2}  + \\frac{2}{r}  \\bigg) \\frac{\\lambda^\\prime(r)}{2}- \\big(\\frac{\\nu^\\prime(r)}{2}\\big)^2 -  \\cancel{\\frac{2}{r^2}} \\\\\n\t=& -\\frac{1}{2}\\bigg[\\nu^{\\prime\\prime}(r) - \\bigg(\\frac{\\nu^\\prime(r)}{2}  + \\frac{2}{r}  \\bigg) \\lambda^\\prime(r) + \\frac{\\big(\\nu^\\prime(r)\\big)^2}{2}\\bigg] \\numberthis \\label{eq:Rrr}\n\\end{align*}\n\n\\subsubsection{Determination of $\\nu$ and $\\lambda$}\n\nWe now have enough information to determine $\\nu$ and $\\lambda$. From (\\ref{eq:Rtt}) and (\\ref{eq:Rrr})\n\n\\begin{align*}\n\t\\nu^{\\prime\\prime}(r) + \\frac{1}{2}\\nu^\\prime(r) \\big(\\nu^\\prime(r)-\\lambda^\\prime(r)\\big)+ \\frac{2}{r}\\nu^\\prime(r)=&0 \\numberthis \\label{eq:Rtt:a}\\\\\n\t\\nu^{\\prime\\prime}(r) - \\bigg(\\frac{\\nu^\\prime(r)}{2}  + \\frac{2}{r}  \\bigg) \\lambda^\\prime(r) + \\frac{\\big(\\nu^\\prime(r)\\big)^2}{2}=&0\\\\\n\\end{align*}\nSubtracting these equations:\n\\begin{align*}\n\t\\cancel{\\nu^{\\prime\\prime}(r)} + \\frac{1}{2}\\nu^\\prime(r) \\big(\\nu^\\prime(r)-\\lambda^\\prime(r)\\big)+ \\frac{2}{r}\\nu^\\prime(r)-\\cancel{\\nu^{\\prime\\prime}(r)} + \\bigg(\\frac{\\nu^\\prime(r)}{2}  + \\frac{2}{r}  \\bigg) \\lambda^\\prime(r) - \\frac{\\big(\\nu^\\prime(r)\\big)^2}{2}=&0\\\\\n\\end{align*}\n\n\\begin{align*}\n\t \\frac{1}{2}\\nu^\\prime(r) \\big(\\cancel{\\nu^\\prime(r)}-\\bcancel{\\lambda^\\prime(r)}\\big)+ \\frac{2}{r}\\nu^\\prime(r) + \\bigg(\\bcancel{\\frac{\\nu^\\prime(r)}{2}}  + \\frac{2}{r}  \\bigg) \\lambda^\\prime(r) - \\cancel{\\frac{\\big(\\nu^\\prime(r)\\big)^2}{2}}=&0\\\\\n\t \\frac{2}{r}\\big(\\nu^\\prime(r)+\\lambda^\\prime(r)\\big)=&0\\\\\n\t \\nu^\\prime(r)+\\lambda^\\prime(r)=&0 \\text{, so for some constant $c$}\\\\\n\t e^\\lambda(r) =& \\frac{c}{e^\\nu(r)}  \\numberthis \\label{eq:lambda:nu}\n\\end{align*}\n\nSubstituting in (\\ref{eq:Rtt:a}):\n\\begin{align*}\n\t\\nu^{\\prime\\prime}(r) + \\nu^\\prime(r)^2 + \\frac{2}{r}\\nu^\\prime(r)=&0 \\numberthis \\label{eq:nu} \\text{. Now}\\\\\n\t\\big[r e^{\\nu(r)}\\big]^{\\prime\\prime}=& \\big[e^\\nu+r \\nu^\\prime e^\\nu\\big]^\\prime\\\\\n\t=& \\big[e^\\nu \\nu^\\prime + e^\\nu \\nu^\\prime + r \\nu^{\\prime\\prime} e^\\nu + r (\\nu^\\prime)^2 e^\\nu\\big]\\\\\n\t=& r e^\\nu\\big[\\frac{2}{r} + \\nu^{\\prime\\prime} + (\\nu^\\prime)^2\\big] \\text{, so (\\ref{eq:nu}) becomes:}\\\\\n\t\\big[r e^{\\nu(r)}\\big]^{\\prime\\prime}=&0, \\text{, or}\\\\\n\tr e^{\\nu(r)} =&ar + b\t\\text{, for some constants $a$ and $b$}\\\\\n\te^{\\nu(r)} =&a + \\frac{b}{r}\n\\end{align*}\n\nNow we know that the metric (\\ref{eq:schwartzschild:ansatz}) should be Minkowskian at infinity, which requires $\\nu(r)\\rightarrow 1$ as $r \\rightarrow \\infty$, so from:\n\\begin{align*}\n\tdt^2 =& \\big(a + \\frac{b}{r}\\big) dt^2 - \\frac{c}{a + \\frac{b}{r}} dr^2 -r^2 d  \\Omega^2 \\text{, for some we see that:}\\\\\n\ta =& \\frac{c}{a}=1 \\text{, using (\\ref{eq:lambda:nu}), i.e.} \\\\\n\tc=1\n\\end{align*}\n\nWe saw in \\cite[Lecture 5]{susskind2012general} that we need $g_{00}\\approxeq1-\\frac{2MG}{r}$ for small $r$, in order to get agreement with Newtonian gravity, hence $b=-2MG$, and (\\ref{eq:schwartzschild:ansatz}) becomes:\n\n\\begin{align*}\n\tdt^2 =& \\big(1-\\frac{2MG}{R}\\big) dt^2 - \\frac{dr^2}{1-\\frac{2MG}{R}}  -r^2 d  \\Omega^2 \\numberthis \\label{eq:schwartzschild:solved}\n\\end{align*}\n\n\\subsubsection{$R_{\\theta\\theta}$ and $R_{\\phi\\phi}$}\nWe need to establish that the remaining diagonal elements are zero using the metric (\\ref{eq:schwartzschild:solved}). We will find the following Lemma useful:\n\\begin{lemma}$\\partial_r \\big[r  e^{-\\lambda(r)}\\big]=1$ \\label{lemma:dL}\n\\end{lemma}\n\n\\begin{proof}\n\tFrom (\\ref{eq:schwartzschild:solved})\n\t\\begin{align*}\n\te^{\\lambda(r)} =& \\frac{1}{1 - \\frac{2MG}{r}} \\text{, whence}\\\\\n\t\\partial_r \\big[r  e^{-\\lambda(r)}\\big] =& \\partial_r \\big[r(1 - \\frac{2MG}{r})\\big]\\\\\n\t=& \\partial_r [r-2MG]\\\\\n\t=& 1\n\t\\end{align*}\n\\end{proof}\n\n\\begin{align*}\n\tR_{\\theta\\theta} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{\\theta\\theta}} - \\partial_\\theta \\Gamma\\indices{^\\alpha_{\\theta\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\theta\\theta}} - \\Gamma\\indices{^\\alpha_{\\gamma\\theta}} \\Gamma\\indices{^\\gamma_{\\theta\\alpha}}\\\\\n\t=& \\partial_r \\Gamma\\indices{^r_{\\theta\\theta}} - \\partial_\\theta \\big[\\Gamma\\indices{^\\phi_{\\theta\\phi}}+\\Gamma\\indices{^r_{\\theta r}}\\big] + \\bigg(\\Gamma\\indices{^t_{rt}}+\\Gamma\\indices{^r_{rr}}+\\cancel{\\Gamma\\indices{^\\theta_{r\\theta}}}+\\Gamma\\indices{^\\phi_{r\\phi}}\\bigg) \\Gamma\\indices{^r_{\\theta\\theta}}\\\\ &-\\cancel{ \\Gamma\\indices{^r_{\\theta\\theta}} \\Gamma\\indices{^\\theta_{\\theta r}}}  - \\Gamma\\indices{^\\theta_{r\\theta}} \\Gamma\\indices{^r_{\\theta\\theta}} -\\Gamma\\indices{^r_{r\\theta}} \\Gamma\\indices{^r_{\\theta r}} - \\Gamma\\indices{^\\phi_{\\phi\\theta}} \\Gamma\\indices{^\\phi_{\\phi\\theta}}\\\\\n\t=& \\partial_r \\bigg[-r  e^{-\\lambda(r)}\\bigg] - \\partial_\\theta \\bigg[-\\tan \\theta +\\frac{1}{r}\\bigg] \\\\\n\t &+ \\bigg(\\underbrace{\\frac{\\nu^\\prime(r)}{2}+\\frac{\\lambda^\\prime(r)}{2}}_\\text{$=0$ from (\\ref{eq:lambda:nu})}+\\cancel{\\frac{1}{\\bcancel{r}}\\bigg)\\bigg[ -\\bcancel{r}  e^{-\\lambda(r)}\\bigg]}\\\\\n\t & + \\cancel{\\frac{r e^{-\\lambda(r)}}{r}}\t -\\frac{1}{r^2} - \\tan^2 \\theta  \\numberthis \\label{eq:R:theta:theta}\\\\\n    & - \\underbrace{1}_\\text{\\text{From Lemma \\ref{lemma:dL}}} + \\underbrace{\\sec^2 \\theta}_\\text{$=1+\\tan^2 \\theta$} + \\cancel{\\frac{1}{r^2}} -\\cancel{\\frac{1}{r^2}} - \\tan^2 \\theta \\\\\n\t=& 0 \\text{, as expected.}\n\\end{align*}\n\nSince the calculation of $R_{\\phi\\phi}$ has proved complex, I have expanded the terms, and used the cancel symbol to mark vanishing Christoffel symbols.\n\n\\begin{align*}\n\t\\partial_\\alpha \\Gamma\\indices{^\\alpha_{\\phi\\phi}} - \\partial_\\phi \\Gamma\\indices{^\\alpha_{\\phi\\alpha}} =& \\partial_r \\big[- \\cos^2 \\theta r e^{-\\lambda(r)}\\big]+ \\partial_\\theta \\big[\\cos\\theta \\sin\\theta\\big]-\\underbrace{\\partial_\\phi \\Gamma\\indices{^\\alpha_{\\phi\\alpha}}}_\\text{= 0}\\\\\n\t=& - \\cos^2 \\theta \\cdot \\underbrace{\\partial_r \\big[ r e^{-\\lambda(r)}\\big]}_\\text{$=1$ from Lemma \\ref{lemma:dL}}+ \\partial_\\theta \\big[\\cos\\theta \\sin\\theta\\big]\\\\\n\t=& - \\bcancel{\\cos^2 \\theta} -\\sin^2\\theta +\\bcancel{\\cos^2 \\theta} \\numberthis \\label{eq:phi:phi:deriv}\n\\end{align*}\n\n\\begin{align*}\n\t\\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\phi\\phi}} =&\\Gamma\\indices{^\\alpha_{t\\alpha}} \\cancel{\\Gamma\\indices{^t_{\\phi\\phi}}}+ \\Gamma\\indices{^\\alpha_{r\\alpha}} \\Gamma\\indices{^r_{\\phi\\phi}}+\\Gamma\\indices{^\\alpha_{\\theta\\alpha}} \\Gamma\\indices{^\\theta_{\\phi\\phi}}+\\Gamma\\indices{^\\alpha_{\\phi\\alpha}} \\cancel{\\Gamma\\indices{^\\phi_{\\phi\\phi}}}\\\\\n\t=&\\big[\\Gamma\\indices{^t_{rt}}+\\Gamma\\indices{^r_{rr}}+\\Gamma\\indices{^\\theta_{r\\theta}}+\\Gamma\\indices{^\\phi_{r\\phi}}\\big] \\Gamma\\indices{^r_{\\phi\\phi}}\\\\\n\t+&\\big[\\cancel{\\Gamma\\indices{^t_{\\theta t}}}+\\cancel{\\Gamma\\indices{^r_{\\theta r}}}+\\cancel{\\Gamma\\indices{^\\theta_{\\theta\\theta}}}+\\Gamma\\indices{^\\phi_{\\theta\\phi}}\\big] \\Gamma\\indices{^\\theta_{\\phi\\phi}}\\\\\n\t=& \\big[\\underbrace{\\frac{\\nu^\\prime}{2} + \\frac{\\lambda^\\prime}{2}}_\\text{$=0$}+\\frac{1}{r}+\\frac{1}{r}\\big]\\big[-r \\cos^2\\theta e^{-\\lambda}\\big] - \\tan \\theta \\cos \\theta \\sin \\theta\\\\\n\t=& - 2 \\cos^2\\theta e^{-\\lambda} -\\sin^2\\theta\\numberthis \\label{eq:prod:1}\n\\end{align*}\n\n\n\n\\begin{align*}\n\t\\Gamma\\indices{^\\alpha_{\\gamma\\phi}} \\Gamma\\indices{^\\gamma_{\\phi\\alpha}}=& \\cancel{\\Gamma\\indices{^t_{t\\phi}}} \\Gamma\\indices{^t_{\\phi t}}+\\cancel{\\Gamma\\indices{^t_{r\\phi}}} \\Gamma\\indices{^r_{\\phi t}}+\\cancel{\\Gamma\\indices{^t_{\\theta\\phi}}} \\Gamma\\indices{^\\theta_{\\phi t}}+\\cancel{\\Gamma\\indices{^t_{\\phi\\phi}}} \\Gamma\\indices{^\\phi_{\\phi t}}\\\\\n\t&+ \\cancel{\\Gamma\\indices{^r_{t\\phi}}} \\Gamma\\indices{^t_{\\phi r}} + \\cancel{\\Gamma\\indices{^r_{r\\phi}}} \\Gamma\\indices{^r_{\\phi r}}+ \\cancel{\\Gamma\\indices{^r_{\\theta\\phi}}} \\Gamma\\indices{^\\theta_{\\phi r}}+ \\Gamma\\indices{^r_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi r}}\\\\\n\t&+ \\cancel{\\Gamma\\indices{^\\theta_{t\\phi}}} \\Gamma\\indices{^t_{\\phi\\theta}}+ \\cancel{\\Gamma\\indices{^\\theta_{r\\phi}}} \\Gamma\\indices{^r_{\\phi\\theta}}+ \\cancel{\\Gamma\\indices{^\\theta_{\\theta\\phi}}} \\Gamma\\indices{^\\theta_{\\phi\\theta}}+ \\Gamma\\indices{^\\theta_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi\\theta}} \\\\\n\t&+ \\cancel{\\Gamma\\indices{^\\phi_{t\\phi}}} \\Gamma\\indices{^t_{\\phi\\phi}}+ \\Gamma\\indices{^\\phi_{r\\phi}} \\Gamma\\indices{^r_{\\phi\\phi}}+ \\Gamma\\indices{^\\phi_{\\theta\\phi}} \\Gamma\\indices{^\\theta_{\\phi\\phi}}+ \\cancel{\\Gamma\\indices{^\\phi_{\\phi\\phi}}} \\Gamma\\indices{^\\phi_{\\phi\\phi}}\\\\\n\t=& \\Gamma\\indices{^r_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi r}}+  \\Gamma\\indices{^\\theta_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi\\theta}} + \\Gamma\\indices{^\\phi_{r\\phi}} \\Gamma\\indices{^r_{\\phi\\phi}}+ \\Gamma\\indices{^\\phi_{\\theta\\phi}} \\Gamma\\indices{^\\theta_{\\phi\\phi}}\\\\\n\t=& 2 \\Gamma\\indices{^r_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi r}}+  2 \\Gamma\\indices{^\\theta_{\\phi\\phi}} \\Gamma\\indices{^\\phi_{\\phi\\theta}}\\\\\n\t=& -2\\bcancel{ r} \\cos^2 \\theta e^{- \\lambda(r)} \\frac{1}{\\bcancel{r}}  - 2 cos\\theta \\sin\\theta \\tan\\theta\\\\\n\t=& -2 \\cos^2 \\theta e^{- \\lambda(r)}   - 2 \\bcancel{cos\\theta} \\sin\\theta \\frac{\\sin\\theta}{\\bcancel{cos\\theta}} \\\\\n\t=& -2 \\cos^2 \\theta e^{- \\lambda(r)}   - 2  \\sin^2\\theta  \\numberthis \\label{eq:prod:2}\n\\end{align*}\n\n\nCombining these three equations:\n\\begin{align*} \n\tR_{\\phi\\phi} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{\\phi\\phi}} - \\partial_\\phi \\Gamma\\indices{^\\alpha_{\\phi\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\phi\\phi}} - \\Gamma\\indices{^\\alpha_{\\gamma\\phi}} \\Gamma\\indices{^\\gamma_{\\phi\\alpha}}\\\\\n\t=&\\underbrace{ -\\sin^2\\theta}_\\text{from (\\ref{eq:phi:phi:deriv})} - \\underbrace{\\big[\\bcancel{2\\cos^2\\theta e^{-\\lambda}} +\\sin^2\\theta\\big]}_\\text{from (\\ref{eq:prod:1})} + \\underbrace{\\bcancel{2 \\cos^2 \\theta e^{- \\lambda(r)}}   + 2  \\sin^2\\theta}_\\text{from (\\ref{eq:prod:2})}\\\\\n\t=&0\n\\end{align*}\n\n\n\n\\subsubsection{Off diagonal elements}\nIt is easy to show that the off-diagonal terms vanish. With the exception of $R_{r\\theta}$ there is no need to expand the $\\Gamma$; we merely use our knowledge of which $\\Gamma$ and $\\partial_\\alpha \\Gamma$ are non-zero.\n\n\\begin{align*}\n\tR_{tr} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{tr}} - \\partial_r \\Gamma\\indices{^\\alpha_{t\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{tr}} - \\Gamma\\indices{^\\alpha_{\\gamma r}} \\Gamma\\indices{^\\gamma_{t\\alpha}}\\\\\n\t=&\\partial_t \\Gamma\\indices{^t_{tr}} - \\underbrace{\\partial_r \\Gamma\\indices{^\\alpha_{t\\alpha}}}_\\text{$=0$} + \\underbrace{\\Gamma\\indices{^\\alpha_{t\\alpha}}}_\\text{$=0$} \\Gamma\\indices{^t_{tr}} - \\underbrace{\\Gamma\\indices{^t_{r r}}}_\\text{$=0$} \\Gamma\\indices{^r_{tt}} -\\underbrace{ \\Gamma\\indices{^r_{t r}}}_\\text{$=0$} \\Gamma\\indices{^t_{tr}}\\\\\n\t=&0\n\\end{align*}\n\n\\begin{align*}\n\tR_{t\\theta} =& \\underbrace{\\partial_\\alpha \\Gamma\\indices{^\\alpha_{t\\theta}} - \\partial_\\theta \\Gamma\\indices{^\\alpha_{t\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{t\\theta}}}_\\text{These terms all vanish} - \\Gamma\\indices{^\\alpha_{\\gamma\\theta}} \\Gamma\\indices{^\\gamma_{t\\alpha}}\\\\\n\t=&  - \\Gamma\\indices{^r_{\\theta\\theta}} \\underbrace{\\Gamma\\indices{^\\theta_{tr}}}_\\text{$=0$}  - \\Gamma\\indices{^\\theta_{r\\theta}} \\underbrace{\\Gamma\\indices{^r_{t\\theta}}}_\\text{$=0$} \\\\\n\t=&0 \n\\end{align*}\n\n\\begin{align*}\n\tR_{t\\phi} =& \\underbrace{\\partial_\\alpha \\Gamma\\indices{^\\alpha_{t\\phi}} - \\partial_\\phi \\Gamma\\indices{^\\alpha_{t\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{t\\phi}} }_\\text{These terms all vanish}- \\Gamma\\indices{^\\alpha_{\\gamma\\phi}} \\Gamma\\indices{^\\gamma_{t\\alpha}}\\\\\n\t=& - \\Gamma\\indices{^r_{\\phi\\phi}} \\underbrace{\\Gamma\\indices{^\\phi_{tr}}}_\\text{$=0$} - \\Gamma\\indices{^\\phi_{\\theta\\phi}} \\underbrace{\\Gamma\\indices{^\\theta_{t\\phi}}}_\\text{$=0$}- \\Gamma\\indices{^\\phi_{r\\phi}} \\underbrace{\\Gamma\\indices{^r_{t\\phi}}}_\\text{$=0$}\\\\\n\t&=0\n\\end{align*}\n\n $R_{r\\theta}$ does not require a knowledge of $\\mu(r)$ or $\\nu(r)$.\n \n\\begin{align*}\n\tR_{r\\theta} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{r\\theta}} - \\partial_\\theta \\Gamma\\indices{^\\alpha_{r\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{r\\theta}} - \\Gamma\\indices{^\\alpha_{\\gamma\\theta}} \\Gamma\\indices{^\\gamma_{r\\alpha}}\\\\\n\t=& \\underbrace{\\partial_r \\Gamma\\indices{^r_{r\\theta}}}_\\text{$=0$} - \\underbrace{\\partial_\\theta \\big(\\Gamma\\indices{^\\theta_{r\\theta}}+\\Gamma\\indices{^r_{rr}}\\big)}_\\text{$=0$} + \\Gamma\\indices{^\\phi_{\\theta\\phi}} \\Gamma\\indices{^\\theta_{r\\theta}} - \\Gamma\\indices{^r_{\\theta\\theta}} \\underbrace{\\Gamma\\indices{^\\theta_{rr}}}_\\text{$=0$} - \\Gamma\\indices{^\\theta_{r\\theta}} \\underbrace{\\Gamma\\indices{^r_{r\\theta}}}_\\text{$=0$}- \\Gamma\\indices{^\\phi_{\\phi\\theta}} \\Gamma\\indices{^\\phi_{r\\phi}}\\\\\n\t=&-\\frac{1}{r^2} -\\cancel{\\frac{1}{r}\\tan \\theta} + \\cancel{\\frac{1}{r}\\tan \\theta}\\\\\n\t=& 0\n\\end{align*}\n\n\\begin{align*}\n\tR_{r\\phi} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{r\\phi}} - \\partial_\\phi \\Gamma\\indices{^\\alpha_{r\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{r\\phi}} - \\Gamma\\indices{^\\alpha_{\\gamma\\phi}} \\Gamma\\indices{^\\gamma_{r\\alpha}}\\\\\n\t=& \\underbrace{\\partial_\\phi \\Gamma\\indices{^\\phi_{r\\phi}}}_\\text{$=0$} - \\underbrace{\\partial_\\phi \\Gamma\\indices{^\\alpha_{r\\alpha}}}_\\text{$=0$} + \\underbrace{\\Gamma\\indices{^\\alpha_{\\phi\\alpha}}}_\\text{$=0$} \\Gamma\\indices{^\\phi_{r\\phi}} - \\Gamma\\indices{^\\phi_{\\theta\\phi}} \\underbrace{\\Gamma\\indices{^\\theta_{r\\phi}}}_\\text{$=0$} - \\Gamma\\indices{^\\phi_{r\\phi}} \\underbrace{\\Gamma\\indices{^r_{r\\phi}}}_\\text{$=0$}\\\\\n\t=&0\n\\end{align*}\n\n\\begin{align*}\n\tR_{\\theta\\phi} =& \\partial_\\alpha \\Gamma\\indices{^\\alpha_{\\theta\\phi}} - \\partial_\\phi \\Gamma\\indices{^\\alpha_{\\theta\\alpha}} + \\Gamma\\indices{^\\alpha_{\\gamma\\alpha}} \\Gamma\\indices{^\\gamma_{\\theta\\phi}} - \\Gamma\\indices{^\\alpha_{\\gamma\\phi}} \\Gamma\\indices{^\\gamma_{\\theta\\alpha}}\\\\\n\t=& \\underbrace{\\partial_\\phi \\Gamma\\indices{^\\phi_{\\theta\\phi}}}_\\text{$=0$} - \\underbrace{\\partial_\\phi \\Gamma\\indices{^\\alpha_{\\theta\\alpha}}}_\\text{$=0$} + \\underbrace{\\Gamma\\indices{^\\alpha_{\\phi\\alpha}}}_\\text{$=0$} \\Gamma\\indices{^\\phi_{\\theta\\phi}} - \\underbrace{\\Gamma\\indices{^\\phi_{\\phi\\phi}}}_\\text{$=0$} \\Gamma\\indices{^\\phi_{\\theta\\phi}}\\\\\n\t=&0\n\\end{align*}\n\n\\section{Gravitational waves}\\label{sec:gravitational:waves}\n\nGravitational waves are presented, in \\cite[Lecture 10]{susskind2012general}.\nIn this section the coordinates are denoted: $(t,x,y,x)$. The summation convention is observed for all other indices: e.g. $\\Gamma\\indices{^\\alpha_{\\gamma\\alpha}}$ denotes summation over the dummy index $\\alpha$, but $\\Gamma\\indices{^x_{\\gamma x}}$ is not summed.\n\\subsection{Linearized Field Equations}\n\nFrom \\cite[Lecture 10]{susskind2012general}:\n\\begin{align*}\n\t\\Gamma\\indices{^{\\tau}_{\\mu\\nu}} =&\\frac{1}{2} \\big[ \\partial_\\mu g_{\\sigma\\nu} + \\partial_\\nu g_{\\mu\\sigma} - \\partial_\\sigma g_{\\mu\\nu}\\big] g^{\\sigma\\tau}\\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\mu h_{\\sigma\\nu} + \\partial_\\nu h_{\\mu\\sigma} - \\partial_\\sigma h_{\\mu\\nu}\\big] \\big[\\eta^{\\sigma\\tau }- O(h)\\big]\\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\mu h_{\\sigma\\nu} + \\partial_\\nu h_{\\mu\\sigma} - \\partial_\\sigma h_{\\mu\\nu}\\big] \\eta^{\\sigma\\tau }- O(h^2) \\numberthis \\label{eq:Gamma:small}\n\\end{align*}\n\n\\subsection{Riemann and Ricci Tensors}\nFrom \\cite[Lecture 3]{susskind2012general}:\n\\begin{align*}\n\tR\\indices{^\\alpha_{\\beta\\gamma\\delta}} =& \\partial_\\gamma\\Gamma\\indices{^\\alpha_{\\beta\\delta}}-\\partial_\\delta\\Gamma\\indices{^\\alpha_{\\beta\\gamma}} + O(\\Gamma^2) \\text{. Now using $o(\\Gamma)=o(h)$ from (\\ref{eq:Gamma:small})} \\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\gamma\\partial_\\beta h_{\\sigma\\delta} + \\partial_\\gamma\\partial_\\delta h_{\\beta\\sigma} - \\partial_\\gamma\\partial_\\sigma h_{\\beta\\delta}\\big] \\eta^{\\sigma\\alpha }- \\frac{1}{2} \\big[ \\partial_\\delta\\partial_\\gamma h_{\\sigma\\beta} + \\partial_\\delta\\partial_\\beta h_{\\gamma\\sigma} - \\partial_\\delta\\partial_\\sigma h_{\\beta\\gamma}\\big] \\eta^{\\sigma\\alpha }+ O(h^2)\\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\gamma\\partial_\\beta h_{\\sigma\\delta} + \\partial_\\gamma\\partial_\\delta h_{\\beta\\sigma} - \\partial_\\gamma\\partial_\\sigma h_{\\beta\\delta} - \\partial_\\delta\\partial_\\gamma h_{\\sigma\\beta} - \\partial_\\delta\\partial_\\beta h_{\\gamma\\sigma} + \\partial_\\delta\\partial_\\sigma h_{\\beta\\gamma}\\big] \\eta^{\\sigma\\alpha }+ O(h^2)\n\\end{align*}\nDropping $O(h^2)$ and contracting\n\\begin{align*}\n\tR_{\\beta\\delta} =& \tR\\indices{^\\alpha_{\\beta\\alpha\\delta}}\\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\alpha\\partial_\\beta h_{\\sigma\\delta} + \\cancel{\\partial_\\alpha\\partial_\\delta h_{\\beta\\sigma}} - \\partial_\\alpha\\partial_\\sigma h_{\\beta\\delta} - \\cancel{\\partial_\\delta\\partial_\\alpha h_{\\sigma\\beta}} - \\partial_\\delta\\partial_\\beta h_{\\alpha\\sigma} + \\partial_\\delta\\partial_\\sigma h_{\\beta\\alpha}\\big] \\eta^{\\sigma\\alpha }\n\t\\\\\n\t=& \\frac{1}{2} \\big[ \\partial_\\alpha\\partial_\\beta h_{\\sigma\\delta} - \\partial_\\alpha\\partial_\\sigma h_{\\beta\\delta} -  \\partial_\\delta\\partial_\\beta h_{\\alpha\\sigma} + \\partial_\\delta\\partial_\\sigma h_{\\beta\\alpha}\\big] \\eta^{\\sigma\\alpha } \\numberthis \\label{eq:linearized}\\\\\n\t=& 0 \\text{ in empty space}.\n\\end{align*}\nNow $\\eta^{00}=-1$, $\\eta^{ii}=+1$, and all other values are zero, so Einstein's field equations become:\n\\begin{align*}\n\t\\sum_i\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}\\big]}_\\text{(d)}\\\\\n\t=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)} \\numberthis \\label{eq:expanded_h}\n\\end{align*}\n\n\\subsection{Ansatz}\n\nWe will look for plane wave solutions propagating along the $z$ axis.\n\n\\begin{align*}\n\th_{\\mu\\nu}(x,t)=&h^0_{\\mu\\nu} \\sin\\big(k(t-z)\\big)\\\\\n\t\\partial_0^2 h_{\\mu\\nu}=& -k^2 h_{\\mu\\nu}\\\\\n\t\\partial_z^2 h_{\\mu\\nu}=& -k^2 h_{\\mu\\nu}\\\\\n\t\\partial_0 \\partial_z  h_{\\mu\\nu}=& k^2 h_{\\mu\\nu}\\\\\n\t\\partial_z \\partial_0  h_{\\mu\\nu}=& k^2 h_{\\mu\\nu}\n\\end{align*}\nAll other partial derivatives are zero.\n\nThe terms on the left hand side of (\\ref{eq:expanded_h}) become:\n\\begin{align*}\n\t(a)\t\\sum_i \\partial_i\\partial_\\beta h_{i\\delta} =& \\begin{cases}\n\t\t\t\\partial_z\\partial_\\beta h_{z\\delta} \\text{, $\\beta\\in \\{z,t\\}$}\\\\\n\t\t\t0 \\text{, otherwise.}\n\t\t\\end{cases}\\\\\n\t(b)\t\\sum_i \\partial_i\\partial_i h_{\\beta\\delta} =& \\partial_z\\partial_z h_{\\beta\\delta}\\\\\n\t(c)\t\\sum_i \\partial_\\delta \\partial_\\beta h_{ii} =&\\begin{cases}\n\t\\partial_\\delta \\partial_\\beta \\sum_i h_{ii} \\text{, $\\beta\\&\\delta\\in\\{z,t\\}$}\\\\\n\t0 \\text{, otherwise}.\n\t\\end{cases}\\\\\n\t(d)\t\\sum_i \\partial_\\delta\\partial_i h_{\\beta i} =& \\begin{cases}\n\t\\partial_\\delta\\partial_z h_{\\beta z} \\text {, $\\delta\\in\\{z,t\\}$}\\\\\n\t0 \\text{, otherwise }\n\t\\end{cases}\n\\end{align*}\n\nThe terms on the right hand side of (\\ref{eq:expanded_h}) become:\n\\begin{align*}\n\t(e)\\;\t\\partial_0\\partial_\\beta h_{0\\delta}=&0 \\text{ unless $\\beta\\in\\{z,t\\}$ }\\\\\n\t(f)\\;\t\\partial_0\\partial_0 h_{\\beta\\delta}\\ne&0\\\\\n\t(g)\\;\t\\partial_\\delta\\partial_\\beta h_{00}=&0 \\text{ unless $\\beta\\&\\delta\\in\\{z,t\\}$ }\\\\\n\t(h)\\;\t\\partial_\\delta\\partial_0 h_{\\beta 0}=&0\\text{ unless $\\delta\\in\\{z,t\\}$ }&\n\\end{align*}\n\n\\subsection{Detailed Constraints}\nSubstituting $\\beta=0,\\delta=0$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}\\big]}_\\text{(d)}\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)}- \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} - \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)} \\\\\n\t&\\underbrace{\\partial_z\\partial_t h_{zt}}_\\text{(a)} - \\underbrace{\\partial_z\\partial_z h_{tt}}_\\text{(b)} -  \\underbrace{\\partial_t\\partial_t \\sum_i h_{ii}}_\\text{(c)} + \\underbrace{\\partial_t\\partial_z h_{tt}}_\\text{(d)}\\\\\n\t&=\\underbrace{\\cancel{\\partial_t\\partial_t h_{tt}}}_\\text{(e)}- \\underbrace{\\cancel{\\partial_t\\partial_t h_{tt}}}_\\text{(f)} - \\underbrace{\\bcancel{\\partial_t\\partial_t h_{tt}}}_\\text{(g)} + \\underbrace{\\bcancel{\\partial_t\\partial_t h_{tt}}}_\\text{(h)} \\\\\n\t0=&\\partial_z\\partial_t h_{zt} - \\partial_z\\partial_z h_{tt} -  \\partial_t\\partial_t \\sum_i h_{ii} + \\partial_t\\partial_z h_{t z}\\\\\n\t=&k^2 \\big[h^0_{zt}+h^0_{tt}+\\sum_ih^0_{ii}+h^0_{tz}\\big] \\sin\\big(k(t-z)\\big)\\\\\n\t0=& 2h^0_{zt}+h^0_{tt}+\\sum_ih^0_{ii} \\numberthis \\label{eq:con:00}\n\t\\end{align*}\n\t\n\tSubstituting $\\beta=0,\\delta=1$ in (\\ref{eq:expanded_h}):\n\t\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\partial_z\\partial_t h_{zx}-\\partial_z\\partial_z h_{tx}=\\cancel{\\partial_t\\partial_t h_{tx}}-\\cancel{\\partial_t\\partial_t h_{tx}}\\\\\n\t0=&k^2 \\big[h^0_{zx}+h^0_{tx}\\big] \\sin\\big(k(t-z)\\big)\\\\\n\t0=&h^0_{zx}+h^0_{tx}  \\numberthis \\label{eq:con:01}\n\\end{align*}\n\nSubstituting $\\beta=0,\\delta=2$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{\\partial_z\\partial_t h_{zy}}_\\text{(a)} - \\underbrace{\\partial_z\\partial_z h_{ty}}_\\text{(b)} =\\underbrace{\\cancel{\\partial_t\\partial_t h_{ty}}}_\\text{(e)} - \\underbrace{\\cancel{\\partial_t\\partial_t h_{ty}}}_\\text{(f)}\\\\\n\t0=&k^2 \\big[h^0_{zy}+h^0_{ty}\\big] \\sin\\big(k(t-z)\\big)\\\\\n\t0=& h^0_{zy}+h^0_{ty} \\numberthis \\label{eq:con:02}\n\\end{align*}\n\nSubstituting $\\beta=0,\\delta=3$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{\\partial_z\\partial_t h_{zz}}_\\text{(a)} - \\underbrace{\\xcancel{\\partial_z\\partial_z h_{tz}}}_\\text{(b)} -  \\underbrace{\\partial_z\\partial_t \\sum_i h_{ii}}_\\text{(c)} + \\underbrace{\\xcancel{\\partial_z\\partial_z h_{tz}}}_\\text{(d)}\\\\\n\t&=\\underbrace{\\cancel{\\partial_t\\partial_t h_{tz}}}_\\text{(e)} - \\underbrace{\\cancel{\\partial_t\\partial_t h_{tz}}}_\\text{(f)} -  \\underbrace{\\bcancel{\\partial_z\\partial_t h_{tt}}}_\\text{(g)} + \\underbrace{\\bcancel{\\partial_z\\partial_t h_{tt}}}_\\text{(h)}\\\\\n\t0=&k^2 \\big[h^0_{xx}+h^0_{yy}\\big] \\sin\\big(k(t-z)\\big)\\\\\n\t0=&h^0_{xx}+h^0_{yy} \\numberthis \\label{eq:con:03}\n\\end{align*}\n\nSubstituting $\\beta=1,\\delta=1$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{0}_\\text{(a)} - \\underbrace{\\partial_z\\partial_z h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{0}_\\text{(c)} + \\underbrace{0}_\\text{(d)}\\\\\n\t&=\\underbrace{0}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{0}_\\text{(g)} + \\underbrace{0}_\\text{(h)}\\\\\n\t0=&\\partial_z\\partial_z h_{xx}-\\partial_0\\partial_0 h_{xx}\\\\\n\t0=&k^2 \\big[ h^0_{xx} - h^0_{xx}\\big] \\sin\\big(k(t-z)\\big) \\text{ an empty constraint }\n\\end{align*}\n\nSubstituting $\\beta=1,\\delta=2$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{0}_\\text{(a)} - \\underbrace{\\partial_z\\partial_z h_{xy}}_\\text{(b)} -  \\underbrace{0}_\\text{(c)} + \\underbrace{0}_\\text{(d)}\\\\\n\t&=\\underbrace{0}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{xy}}_\\text{(f)} -  \\underbrace{0}_\\text{(g)} + \\underbrace{0}_\\text{(h)}\\\\\n\t0=& \\partial_z\\partial_z h_{\\beta\\delta} -\\partial_0\\partial_0 h_{\\beta\\delta}\\\\\n\t0=&k^2 \\big[h^0_{xy}-h^0_{xy}\\big] \\sin\\big(k(t-z)\\big) \\text{ an empty constraint }\n\\end{align*}\n\nSubstituting $\\beta=1,\\delta=3$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{0}_\\text{(a)} - \\underbrace{\\cancel{\\partial_z\\partial_z h_{xz}}}_\\text{(b)} -  \\underbrace{0}_\\text{(c)} + \\underbrace{\\cancel{\\partial_z\\partial_z h_{x z}}}_\\text{(d)}\\\\\n\t&=\\underbrace{0}_\\text{(e)} - \\underbrace{\\partial_t\\partial_t h_{xz}}_\\text{(f)} -  \\underbrace{0}_\\text{(g)} + \\underbrace{\\partial_z\\partial_t h_{xt}}_\\text{(h)}\\\\\n\t0=&\\partial_t\\partial_t h_{xz}-\\partial_z\\partial_t h_{xt}\\\\\n\t=&k^2 \\big[h^0_{xz}+h^0_{xt}\\big] \\sin\\big(k(t-z)\\big)\\\\\n\t0=&h^0_{xz}+h^0_{xt} \\text{, which is the same as (\\ref{eq:con:01})}\n\\end{align*}\n\nSubstituting $\\beta=2,\\delta=2$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{0}_\\text{(a)} - \\underbrace{\\partial_z\\partial_z h_{yy}}_\\text{(b)} -  \\underbrace{0}_\\text{(c)} + \\underbrace{0}_\\text{(d)}\\\\\n\t&=\\underbrace{0}_\\text{(e)} - \\underbrace{\\partial_t\\partial_t h_{yy}}_\\text{(f)} -  \\underbrace{0}_\\text{(g)} + \\underbrace{0}_\\text{(h)}\\\\\n\t0=&\\partial_z\\partial_z h_{yy}-\\partial_t\\partial_t h_{yy}\\\\\n\t=&k^2 \\big[h^0_{yy}-h^0_{yy}\\big] \\sin\\big(k(t-z)\\big) \\\\\n\t0=&h^0_{yy}-h^0_{yy} \\text{ an empty constraint}\n\\end{align*}\n\nSubstituting $\\beta=2,\\delta=3$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{0}_\\text{(a)} - \\underbrace{\\cancel{\\partial_z\\partial_z h_{yz}}}_\\text{(b)} -  \\underbrace{0}_\\text{(c)} + \\underbrace{\\cancel{\\partial_z\\partial_z h_{yz}}}_\\text{(d)}\\\\\n\t&=\\underbrace{0}_\\text{(e)} - \\underbrace{\\partial_t\\partial_t h_{yz}}_\\text{(f)} -  \\underbrace{0}_\\text{(g)} + \\underbrace{\\partial_z\\partial_t h_{yt}}_\\text{(h)}\\\\\n\t0=&\\partial_t\\partial_t h_{yz}-\\partial_z\\partial_t h_{yt}\\\\\n\t=&k^2 \\big[ h_{yz}+h_{yt}\\big] \\sin\\big(k(t-z)\\big) \\\\\n\t0=&  h_{yz}+h_{yt} \\text{, which is the same as (\\ref{eq:con:02})}\n\\end{align*}\n\nSubstituting $\\beta=3,\\delta=3$ in (\\ref{eq:expanded_h}):\n\\begin{align*}\n\t\\sum_i&\\big[\\underbrace{\\partial_i\\partial_\\beta h_{i\\delta}}_\\text{(a)} - \\underbrace{\\partial_i\\partial_i h_{\\beta\\delta}}_\\text{(b)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{ii}}_\\text{(c)} + \\underbrace{\\partial_\\delta\\partial_i h_{\\beta i}}_\\text{(d)}\\big]\\\\\n\t&=\\underbrace{\\partial_0\\partial_\\beta h_{0\\delta}}_\\text{(e)} - \\underbrace{\\partial_0\\partial_0 h_{\\beta\\delta}}_\\text{(f)} -  \\underbrace{\\partial_\\delta\\partial_\\beta h_{00}}_\\text{(g)} + \\underbrace{\\partial_\\delta\\partial_0 h_{\\beta 0}}_\\text{(h)}\\\\\n\t&\\underbrace{\\cancel{\\partial_z\\partial_z h_{zz}}}_\\text{(a)} - \\underbrace{\\cancel{\\partial_z\\partial_z h_{zz}}}_\\text{(b)} -  \\underbrace{\\partial_z\\partial_z \\sum_i h_{ii}}_\\text{(c)} + \\underbrace{\\partial_z\\partial_z h_{zz}}_\\text{(d)}\\\\\n\t&=\\underbrace{\\partial_t\\partial_z h_{tz}}_\\text{(e)} - \\underbrace{\\partial_t\\partial_t h_{zz}}_\\text{(f)} -  \\underbrace{\\partial_z\\partial_z h_{tt}}_\\text{(g)} + \\underbrace{\\partial_z\\partial_t h_{zt}}_\\text{(h)}\\\\\n\t0=& \\partial_z\\partial_z\\big(h_{xx}+h_{yy}\\big) + \\partial_t\\partial_z h_{tz} - \\partial_t\\partial_t h_{zz} - \\partial_z\\partial_z h_{tt} +\\partial_z\\partial_t h_{zt}\\\\\n\t=&k^2 \\big[-h^0_{xx} - h^0_{yy} + h^0_{tz} +  h^0_{zz} + h^0_{tt} + h^0_{zt}\\big] \\sin\\big(k(t-z)\\big)l_\\delta\\partial_\\beta h_{00} - \\partial_\\delta\\partial_0 h_{\\beta 0} \\\\\n\t0=&\\underbrace{-h^0_{xx} - h^0_{yy}}_\\text{$=0$ from (\\ref{eq:con:03})} + h^0_{tz} +  h^0_{zz} + h^0_{tt} + h^0_{zt}\\\\\n\t=&  +  h^0_{zz} + h^0_{tt} + 2h^0_{zt} \\numberthis \\label{eq:con:33}\n\\end{align*}\t\n\n\\subsection{Summary of Constraints}\n\nTable \\ref{table:constraints} shows there are only 5 constraints on the 10 parameters $h^0_{\\mu\\nu}$, so there are indeed plane wave solutions.\n\n\\begin{table}[H]\n\t\\begin{center}\n\t\t\\caption{Constraints on the parameters $h^0_{\\mu\\nu}$}\\label{table:constraints}\n\t\t\\begin{tabular}{|c|l|} \\hline\n\t\t\t\\#&Constraint\\\\ \\hline\n\t\t\t(\\ref{eq:con:00})&$2h^0_{zt}+h^0_{tt}+\\underbrace{h^0_{xx}+h^0_{yy}}_\\text{$=0$ from (\\ref{eq:con:03})}+h^0_{zz} =0$\\\\ \\hline\n\t\t\t(\\ref{eq:con:01})&$h^0_{zx}+h^0_{tx}=0$\\\\ \\hline\n\t\t\t(\\ref{eq:con:02})&$h^0_{zy}+h^0_{ty}=0$\\\\ \\hline\n\t\t\t(\\ref{eq:con:03})&$h^0_{xx}+h^0_{yy}=0$\\\\ \\hline\n\t\t\t(\\ref{eq:con:33})&$h^0_{zz} + h^0_{tt} + 2h^0_{zt}=0$\\\\ \\hline\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\t\n\t\n\t\n\n\\bibliographystyle{unsrt}\n\\addcontentsline{toc}{section}{Bibliography}\n\\raggedright\n\\bibliography{tm}\n\\end{document}\n", "meta": {"hexsha": "f92385323ea9c69e01b930d99f91e71221721824", "size": 42639, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gr-exercises.tex", "max_stars_repo_name": "weka511/tm", "max_stars_repo_head_hexsha": "091aa09764b70d860cca7926658937363a9e1e83", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gr-exercises.tex", "max_issues_repo_name": "weka511/tm", "max_issues_repo_head_hexsha": "091aa09764b70d860cca7926658937363a9e1e83", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2021-07-15T19:53:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-03T22:54:10.000Z", "max_forks_repo_path": "gr-exercises.tex", "max_forks_repo_name": "weka511/tm", "max_forks_repo_head_hexsha": "091aa09764b70d860cca7926658937363a9e1e83", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.683908046, "max_line_length": 598, "alphanum_fraction": 0.6558784212, "num_tokens": 16734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044135, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43199354468384005}}
{"text": "\\section{Improving Parameter Estimates by Solving Sequences of SIPs}\\label{sec:mud-pde-sequence}\nWhen progressing from two dimensions to five in the process of refining our estimate of $g$, we did so using an equal amount of parameter samples despite the volume of the spaces differing.\nThe measure of $\\pspace$ (i.e., $\\pmeas(\\pspace)$), increased by a factor of $64$ while all else was held constant.\nToo many of the functions considered by the initial density are impractical to consider because of their roughness.\nIn the linear examples of \\ref{sec:high-dim-linear-example}, it is shown that initial densities which ascribe higher likelihood to the true parameter lead to MUD estimates that are more accurate.\nBy making better use of our model-evaluation budget of $1000$ samples for the PDE example, we find that both $\\qoi_\\text{1D}$ and $\\qoi_\\text{5D}$ perform significantly better in their ability to resolve $\\paramref$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Motivations for a New Initial Density}\nReducing the volume of the support of the initial density will allow the samples drawn from it to better predict the collected data.\nRecall from Example~\\ref{subsec:pde-example} that two maps are used to solve the SIP: $\\qoi_{1D}$ and $\\qoi_{2D}$ and MUD points are shown for representative examples.\nWe use the solutions from those examples\\---namely the ratio which updates the initial density\\---to inform the construction of a new initial density in five dimensions.\nIn Figure~\\ref{fig:pde-highd-2d-updated}, we plot the initial densities associated with $\\qoi_{1D}$ and $\\qoi_{2D}$ and remark that the scalar--valued QoI map identifies a contour which appears to trace a straight line through $\\pspace$.\nThis is helpful for identifying the correlation structure and defining a lower-dimensional subspace to perform rejection sampling. However, the solution that comes from using $\\qoi_{2D}$ is better at reducing uncertainty.\nTaken together, these observations suggest a number of sampling strategies to generate a new initial density.\n\n\\begin{figure}\n\\centering\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_updated_D2_scalar.png}\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_updated_D2_vector.png}\n\\caption{\n100 measurements are used to solve the SIP for the PDE problem with $\\qoi_{1D}$ and $\\qoi_{2D}$.\n}\n\\label{fig:pde-highd-2d-updated}\n\\end{figure}\n\nBy considering the relationship between the parameters and the types of functions that are possible given the solution to a 2-D inverse problem, we are able to create a more restricted parameter space in five dimensions.\n\nFor a detailed discussion of how a new initial density is constructed for this example, we refer the interested reader to Appendix~\\ref{ext:pde-5d-initial}.\nWe summarize the procedure briefly:\nFirst we generate uniform i.i.d. samples in the three dimensions associated with the new knot points by defining independent bounds for each and taking samples from the cross-product of the directions.\\footnote{\nThe bounds for each are determined by looking at piecewise-linear estimates of $g$ that come from sampling the updated density for the vector--valued solution.\n}\nWe generate $\\nsamps=1000$ i.i.d. samples from this 2-D uniform density\\footnote{\nThe (computational) cover is described by a procedure which involves the SVD of samples from the scalar--valued solutions in order to capture the correlation structure.\nThe use of the $\\qoi_\\text{1D}$ solution is due to the paucity of samples accepted from the vector--valued solution.\nThe structure of the latter updated density is more amenable to form a good estimate of this correlation direction in parameter space.\n}\n, and join them with the three other directions to form the new initial sample set, the functions from which generate the curves shown in Figure~\\ref{fig:pde-highd-alt-initial-5d}.\n\n\\begin{figure}\n\\centering\n  \\includegraphics[width=0.675\\linewidth]{figures/pde-highd/pde-highd_init_D5-alt}\n\\caption{\nInitial density constructed for the second attempt at the five--dimensional inverse problem, with the structure of solutions learned from the 2-D example incorporated into the selection of bounds in each direction.\n}\n\\label{fig:pde-highd-alt-initial-5d}\n\\end{figure}\n\nThe new initial curves in \\ref{fig:pde-highd-alt-initial-5d}\\---especially when contrasted to those in Fig.~\\ref{fig:pde-highd-initial-5d}\\---represent a far more reasonable set of possibilities.\nThe slope of the functions considered now all only have a single sign change, a marked improvement over the two or three that many samples from \\ref{fig:pde-highd-initial-5d} exhibited.\nWe note that such considerations of smoothness could be avoided by parameterizing $g$ with a basis of some sort, but that problem is beyond the scope of this work.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{SIP Solutions using New Initial Density}\nWe now come to the solutions that arise from solving the same five--dimensional inverse problem of interpolating the values of $g$ through equispaced knot points, with both types of maps, in Figure~\\ref{fig:pde-highd-5d-alt-mud}.\nThe difference in comparison to the solutions in Fig.~\\ref{fig:pde-highd-5d-mud} is stark: no longer are the estimated functions dramatically under-estimating the local minimum of $g$.\nThe inadequacy of approximation error is attributable to the choice of knot points imposing a regular structure.\nSince $g$'s minimum lies between two knot points, the best approximation of where this minimum is will by definition still be incorrect.\n\n\\begin{figure}\n\\centering\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_pair_D5-alt-5-1_m20.png}\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_pair_D5-alt-5-5_m20.png}\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_pair_D5-alt-5-1_m100.png}\n  \\includegraphics[width=0.45\\linewidth]{figures/pde-highd/pde-highd_pair_D5-alt-5-5_m100.png}\n\\caption{Solutions to the SIP using one hundred measurements for $\\ndata = 20$ (top) and $100$ (bottom).\n(Left): Scalar-valued solutions for alternative approach to the five-dimensional problem.\n(Right): Vector-valued solutions.\n}\n\\label{fig:pde-highd-5d-alt-mud}\n\\end{figure}\n\nEven when only $20$ measurements are incorporated into constructing the QoI maps, there is a considerable improvement in the predicted boundary conditions when using a better initial density, as seen by comparing the solutions in Fig.~\\ref{fig:pde-highd-5d-alt-mud} to Fig.~\\ref{fig:pde-highd-5d-mud}.\nOwing to the reduced volume of support for the initial density, both QoI maps resolve the residuals similarly, especially as more data are incorporated (shown in the bottom of \\ref{fig:pde-highd-5d-alt-mud}).\nSince ``unreasonable'' functions are no longer being considered, both maps produce qualitatively similar estimates.\n\n\\subsection{Demonstration of Reduction in Uncertainty}\nAs a final note on this experiment, we contrast the resulting $L^2$-errors to $g$\\footnote{derived from computational approximation with the trapezoidal rule} of these MUD solutions, to the previous two examples in Figure~\\ref{fig:pde-highd-5d-hist}.\nWith each successive problem, our uncertainty is reduced and the MUD solutions have lower variance and improved accuracy.\nNote that they appear to be moving towards a value away from zero, which represents a fixed bias (five equispaced knots can only approximate this particular $g$ so well).\n\n\\begin{figure}\n\\centering\n  \\includegraphics[width=0.675\\linewidth]{figures/pde-highd/pde-highd_hist_D5_t5-0E-01}\n\\caption{\nComparison of the 2D initial errors to the 5D ones, as well as the reduction of uncertainty that solving a SIP problem for each provides.\n}\n\\label{fig:pde-highd-5d-hist}\n\\end{figure}\n", "meta": {"hexsha": "5ed14e30e0e2fd8be5b2758d6a29bacb6df3fd32", "size": 7999, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "extensions/mud_pde_sequence.tex", "max_stars_repo_name": "mathematicalmichael/thesis", "max_stars_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-04-24T08:05:49.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-28T20:34:29.000Z", "max_issues_repo_path": "extensions/mud_pde_sequence.tex", "max_issues_repo_name": "mathematicalmichael/thesis", "max_issues_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2019-12-27T23:15:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T17:52:57.000Z", "max_forks_repo_path": "extensions/mud_pde_sequence.tex", "max_forks_repo_name": "mathematicalmichael/thesis", "max_forks_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 85.0957446809, "max_line_length": 301, "alphanum_fraction": 0.7692211526, "num_tokens": 1887, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.43199354468384}}
{"text": "%auto-ignore\n\\providecommand{\\MainFolder}{..}\n\\documentclass[\\MainFolder/Text.tex]{subfiles}\n\n\\begin{document}\n\\section{Poincar\\'e DGA's and Poincar\\'e duality models}\\label{SubSec:PoincModel}\n\\allowdisplaybreaks\n\\Correct[noline,caption={DONE Hom to weak Hom}]{Homotopy to weak homotopy}\n\\Correct[noline,caption={DONE Add orientation to the data of PDGA}]{Add orientation to the data of PDGA}\n\\Correct[noline,caption={DONE Change integral to or}]{Change integral to or}\n\n\nIn this section, we restrict to non-negatively graded unital commutative $\\DGA$'s, which we denote by $\\nnuCDGA$. In this case, the notions of orientation and of cyclic structure agree by Proposition~\\ref{Prop:OrAndCyc}.\n\nWe modify and combine definitions from~\\cite{Van2019} and~\\cite{Lambrechts2007} as follows.\n\n\\begin{Definition}[Dif.~Poincar\\'e duality algebra, $\\PDGA$ and formality]\\label{Def:PDGA}\nA \\emph{differential Poincar\\'e duality algebra of degree $n$} is a $\\nnuCDGA$ $(V,\\Dd,\\wedge)$ of finite type with orientation~$\\Or$ in degree~$n$ such that the induced pairing on $V$ satisfies Poincar\\'e duality. If $\\Dd = 0$, we call it just \\emph{Poincar\\'e duality algebra.}\n\nA \\emph{Poincar\\'e~$\\DGA$ (shortly $\\PDGA$) of degree $n$} is a $\\nnuCDGA$ $(V,\\Dd,\\wedge)$ together with an orientation $\\Or^\\H: \\H(V) \\rightarrow \\R$  of degree $n$ which makes $\\H(V)$ into a Poincar\\'e duality algebra.\n\nA \\emph{morphism of $\\PDGA$'s} $(V_1,\\Dd_1,\\wedge_1,\\Or^\\H_1)$ and $(V_2,\\Dd_2,\\wedge_2,\\Or^\\H_2)$ is a $\\DGA$-morphism $f: V_1 \\rightarrow V_2$ such that the induced map $f_*: \\H(V_1) \\rightarrow \\H(V_2)$ preserves orientation, i.e., it holds $\\Or_2^\\H \\circ f_* = \\Or_1^\\H$.\n\nA \\emph{quasi-isomorphism (or weak equivalence)} of $\\PDGA$'s is a morphism of $\\PDGA$'s $f: V_1 \\rightarrow V_2$ such that $f_*: \\H(V_1) \\rightarrow \\H(V_2)$ is an isomorphism of oriented $\\DGA$'s.\n\nTwo $\\PDGA$'s are \\emph{weakly homotopy equivalent (or isomorphic in the homotopy category)} if they are connected by a zig-zag of $\\PDGA$-quasi-isomorphisms.\n\nA $\\PDGA$ is \\emph{formal} if it is weakly homotopy equivalent (as a $\\PDGA$) to its homology.\n\\end{Definition}\n\nIt follows from Proposition~\\ref{Prop:OrAndCyc} that a differential Poincar\\'e duality algebra according to Definition~\\ref{Def:PDGA} is precisely a cyclic $\\DGA$ from Part~I. In particular, it is finite dimensional. However, if we relax finite type, unitality or commutativity, we obtain a different notion.\n\n\\begin{Remark}[Frobenius algebra]\nA differential Poincar\\'e duality algebra, resp.~a cyclic $\\DGA$, is precisely a finite-dimensional symmetric dg-Frobenius algebra from \\cite[p.~13]{Vallette2012} or \\cite[Theorem~1.1]{Cohen2006}. \n\\end{Remark}\n%Notice that $\\DGA$-morphisms of differential Poincar\\'e duality algebras preserve $\\Or^V$ if and only if they preserve $\\Or^\\H$, and in this case, they are injective by \\eqref{Lem:AutomaticInjectivity}.\n\n\\begin{Definition}[Poincar\\'e duality model]\\label{Def:PDModel}\nA \\emph{Poincar\\'e duality model} of a $\\PDGA$ $(V,\\Dd,\\wedge,\\Or^\\H)$ is a differential Poincar\\'e duality algebra $(\\Model,\\Dd^\\Model,\\wedge^\\Model,\\Or^\\Model)$ which is weakly homotopy equivalent to $V$ as a $\\PDGA$.\n\nWe call a Poincar\\'e duality model \\emph{small} if $\\VansQuotient(\\VansSmall(\\Model)) \\simeq \\Model$ for every Hodge decomposition.\n\\end{Definition}\n\n\\begin{Remark}[On Poincar\\'e duality models]\n\\begin{RemarkList}\n\\item The definition of a Poincar\\'e duality model in~\\cite{Lambrechts2007} requires only weak homotopy equivalence of $\\DGA$'s, i.e., it does not require quasi-isomorphisms to preserve orientation on homology.\n\n\\item In general, a Sullivan minimal model $\\Lambda U$ fails easily to be a Poincar\\'e duality model because it often has non-zero elements in degree $>n$, e.g., powers of even generators; see Example~\\ref{Ex:SphereModel} for $\\Sph{2}$. \n\nFor a compact connected Lie group $G$, the subalgebra of harmonic forms $\\Harm$ for any biinvariant Riemannian metric is isomorphic to a free algebra on odd generators, see \\cite[Chapter~1]{Felix2008}. Therefore, $\\Harm$ with zero differential and the induced cyclic structure is at the same time the Sullivan minimal model and a Poincar\\'e duality model for $\\DR(G)$.\n\n\\item Poincar\\'e duality models are not ``strongly unique'' in the sense that two Poincar\\'e duality models of the same algebra must not be isomorphic; see Example~\\ref{Ex:SUsix} for $\\mathrm{SU}(6)$. However, there is a ``weak uniqueness'' statement in Proposition~\\ref{Prop:LambrechtUnique} below. The situation is similar to the situation with Sullivan and minimal Sullivan models; see \\cite{Felix2008}. We introduced ``smallness'' in Definition~\\ref{Def:PDModel} as a candidate for a minimality condition on a Poincar\\'e duality model which might imply its ``strong uniqueness''; see Question~\\ref{Q:QuestionsPonc}.\n\\qedhere\n\\end{RemarkList}\n\\end{Remark}\n\nConsider the functor from $\\PDGA$'s to $\\DGA$'s which forgets the orientation on homology. We have the following trivial yet somewhat surprising observation.\n\n\\begin{Proposition}[$\\PDGA$-formality is the same as $\\DGA$-formality]\\label{Prop:PoincModelOfFormal}\nA Poincar\\'e $\\DGA$ $(V,\\Dd,\\wedge,\\Or^\\H)$ is formal (as a $\\PDGA$) if and only if it is formal as a $\\DGA$.\n%In this case, $(\\H(V),\\wedge,\\int)$ is its minimal Poincar\\'e duality model.\n\\end{Proposition}\n\\begin{proof}\nThe ``only if'' part is clear.\n\nAs for the ``if'' part, let \n\\begin{equation}\\label{Eq:ZZ}\nV \\longleftarrow \\bullet \\dotsb \\bullet \\longrightarrow \\H(V)\n\\end{equation}\nbe a weak homotopy equivalence of $\\DGA$'s. Denote by $f: \\H(V) \\rightarrow \\H(V)$ the isomorphism on homology induced by \\eqref{Eq:ZZ} from the left to the right. We adjoin $\\H(V)$ to the right of~\\eqref{Eq:ZZ} to obtain the homotopy\n\\begin{equation}\\label{Eq:ZZII}\nV \\longleftarrow \\bullet \\dotsb \\bullet \\longrightarrow \\H(V) \\xrightarrow{f^{-1}} \\H(V)\n\\end{equation}\nwhose induced map on homology from the left to the right is the identity. Therefore, we can orient homologies of the inner nodes of~\\eqref{Eq:ZZII} so that all maps preserve orientation on homology.\n\\end{proof}\n\nThe next proposition will be used to show the existence of Poincar\\'e duality models.\n\n\\begin{Proposition}[Extension of Hodge type]\\label{Prop:ExtensionOfHodgeType}\nLet $V$ be a $\\PDGA$ of degree $n\\ge 5$ which is of finite type and satisfies $V^0=\\Span\\{1\\}$ and $V^1 = 0$. Then it is a retract of an oriented $\\DGA$ $\\LambrechtsExtension(V)$ of Hodge type in the category of $\\PDGA$'s.\n\\end{Proposition}\n\n\\begin{proof}\nPick an arbitrary harmonic subspace $\\Harm$ and an arbitrary complement $C$ of $\\ker \\Dd$ in $V$.\nIf $C$ is not perpendicular to $\\Harm$, replace it with $\\{c - \\pi(c)\\mid c\\in C\\}$, where $\\pi: V \\rightarrow \\Harm$ is the orthogonal projection.\nWe start with $l=\\lceil \\frac{n}{2} \\rceil$ and apply Lemma~\\ref{Lemma:Exte} inductively to get an extension $\\hat{V} = V \\otimes \\Lambda$ which admits a decomposition \n\\begin{equation}\\label{Eq:HatDecomp}\n\\hat{V} = \\hat{\\Harm}\\oplus\\Dd\\hat{V}\\oplus\\hat{C}\n\\end{equation}\nof type \\eqref{Eq:DecompOfV} such that there is a complement $\\hat{E}$ of $\\hat{C}^\\perp$ in $\\hat{C}$ and a linear map $\\hat{\\rho}: \\hat{E}^{\\lceil n/2\\rceil}\\oplus\\dotsb\\oplus\\hat{E}^n\\rightarrow\\Dd\\hat{V}$ such that \\eqref{Eq:ConditionTemp} and \\eqref{Eq:ConditionTempII} hold.\nWe consider a linear map\n\\[\n\\kappa: \\hat{C} \\longrightarrow \\Dd \\hat{V}\n\\]\nsuch that\n\\[\n\\kappa(e)=\n\\begin{cases}\n\t0 & \\text{for }e\\in \\hat{E}^i\\text{ with }i<\\lceil\\frac{n}{2}\\rceil,\\\\\n\t\\hat{\\rho}(e) & \\text{for }e\\in \\hat{E}^i\\text{ with } i>\\lceil\\frac{n}{2}\\rceil, \\\\\n\\end{cases}\\quad\\text{and}\\quad \\kappa(c^\\perp) = 0\\quad\\text{for }c^\\perp\\in\\hat{C}^\\perp.\n\\]\nThe case $n = 2k$ and $e\\in \\hat{E}^k$ is specified as follows.\nIf $k$ is even, then $\\langle \\cdot,\\cdot \\rangle: \\hat{E}^{k}\\otimes \\hat{E}^{k} \\rightarrow \\R$ is an inner product, and there is an orthonormal basis $\\eta_1$, $\\dotsc$, $\\eta_m$ for some $m\\in\\N$.\nWe require\n\\begin{equation}\\label{Eq:InnerProdCase}\n \\kappa(\\eta_i) = \\frac{1}{2}\\hat{\\rho}(\\eta_i)\\quad\\text{for all }i=1, \\dotsc, m.\n\\end{equation}\nIf $k$ is odd, then $\\langle \\cdot,\\cdot \\rangle: \\hat{E}^{k}\\otimes \\hat{E}^{k} \\rightarrow \\R$ is a symplectic form, and there is a symplectic basis $\\eta_1$, $\\theta_1$, $\\dotsc$, $\\eta_m$, $\\theta_m$ for some $m\\in\\N$.\nWe use the convention $\\langle \\theta_i,\\eta_j\\rangle = \\delta_{ij}$ for $i$, $j=1$,~$\\dotsc$, $m$.\nWe require \n\\begin{equation}\\label{Eq:SymplCase}\n \\kappa(\\eta_i) = \\hat{\\rho}(\\eta_i)\\quad\\text{and}\\quad\\kappa(\\theta_i)= 0\\quad\\text{for }i=1,\\dotsc,m.\n\\end{equation}\nLet \n\\[\n\\hat{C}' \\coloneqq \\{c - \\kappa(c) \\mid c\\in \\hat{C}\\}.\n\\]\nThis is a complement of $\\ker \\Dd$ in $\\hat{V}$ perpendicular to $\\hat{\\Harm}$ because $\\hat{C}$ is and $\\im \\kappa \\subset\\Dd\\hat{V}$.\nGiven homogenous $c_1$, $c_2\\in \\hat{C}$ with $\\deg c_1 + \\deg c_2 = n$ and $\\deg c_1 \\le \\deg c_2$, write $c_1 = c^\\perp_1 + e_1$ and $c_2 = c^\\perp_2 + e_2$ for $c_1^\\perp$, $c_2^\\perp \\in \\hat{C}^\\perp$ and $e_1$, $e_2\\in\\hat{E}$, and compute\n\\begin{align*}\n\\langle c_1 - \\kappa(c_1), c_2 - \\kappa(c_2) \\rangle &= \\langle c_1, c_2 \\rangle - \\langle \\kappa(c_1), c_2 \\rangle - \\langle c_1, \\kappa(c_2) \\rangle\\\\\n&=\\begin{aligned}[t]\n&\\underbrace{\\langle e_1, e_2 \\rangle - \\langle \\kappa(e_1), e_2 \\rangle - \\langle e_1, \\kappa(e_2) \\rangle}_{\\eqqcolon(*)} \\\\ &{}-\\underbrace{\\langle\\kappa(e_1),c_2^\\perp\\rangle - \\langle c_1^\\perp, \\kappa(e_2)\\rangle}_{\\eqqcolon(**)}.\n\\end{aligned}\n\\end{align*}\nNow, $(**)=0$ because of \\eqref{Eq:ConditionTempII}.\nAs for $(*)$, if $\\deg c_1 < \\deg c_2$, then\n\\begin{align*}\n(**) &= \\langle e_1, e_2 \\rangle - \\langle e_1,\\kappa(e_2)\\rangle \\\\\n     &= \\langle e_1, e_2 \\rangle - \\langle e_1,\\hat{\\rho}(e_2)\\rangle \\\\ \n     &= 0\n\\end{align*}\nbecause of \\eqref{Eq:ConditionTemp}.\nIf $\\deg c_1 = \\deg c_2 = k$ and $k$ is even, we plug in the orthonormal basis and get using \\eqref{Eq:InnerProdCase} that\n\\begin{align*}\ne_1 = \\eta_i,\\ e_2 = \\eta_j:  && (**) &= \\langle \\eta_i, \\eta_j \\rangle - \\langle \\kappa(\\eta_i),\\eta_j\\rangle - \\langle \\eta_i,\\kappa(\\eta_j)\\rangle \\\\\n&& & = \\langle \\eta_i, \\eta_j\\rangle - \\langle \\eta_j, \\kappa(\\eta_i)\\rangle - \\langle \\eta_i, \\kappa(\\eta_j)\\rangle \\\\\n&& & = \\langle \\eta_i, \\eta_j \\rangle - \\frac{1}{2}\\langle \\eta_j, \\hat{\\rho}(\\eta_i)\\rangle - \\frac{1}{2}\\langle\\eta_i,\\hat{\\rho}(\\eta_j)\\rangle\\\\\n&& & = \\langle \\eta_i, \\eta_j \\rangle - \\frac{1}{2}\\langle \\eta_j, \\eta_i \\rangle - \\frac{1}{2}\\langle \\eta_i, \\eta_j \\rangle \\\\\n&& & = 0.\n\\end{align*}\nIf $k$ is odd, we plug in the symplectic basis and get using \\eqref{Eq:SymplCase} that\n\\begin{align*}\ne_1 = \\eta_i,\\ e_2 = \\eta_j: && (**) &= \\langle \\eta_j, \\kappa(\\eta_i) \\rangle - \\langle \\eta_i, \\kappa(\\eta_j) \\rangle \\\\\n&& &= \\langle \\eta_j, \\hat{\\rho}(\\eta_j) \\rangle - \\langle \\eta_i, \\hat{\\rho}(\\eta_j) \\rangle \\\\\n&& &= 0, \\\\\ne_1 = \\theta_i,\\ e_2 = \\eta_j: && (**) &= \\langle \\theta_i, \\eta_j\\rangle - \\langle \\theta_i, \\kappa(\\eta_j) \\rangle \\\\\n&& &= \\langle \\theta_i, \\eta_j\\rangle - \\langle \\theta_i, \\hat{\\rho}(\\eta_j) \\rangle \\\\\n&& &= 0, \\\\\ne_1 = \\theta_i,\\ e_2 = \\theta_j: && (**) &= 0.\n\\end{align*}\nThis shows that $\\hat{C}\\perp\\hat{C}$, and hence \\eqref{Eq:HatDecomp} is a Hodge decomposition.\n\nFinally, because $\\hat{V} = V \\otimes \\Lambda$ as a $\\DGA$, both the inclusion $\\iota: V \\rightarrow \\hat{V}$ of $V$ into $\\hat{V}_0$ and the projection $\\pi: \\hat{V} \\rightarrow V$ from $\\hat{V}_0$ onto $V$ are $\\DGA$ morphisms.\nBecause $\\pi \\circ \\iota = \\Id$ and because $\\iota_*$ is an orientation preserving isomorphism, $\\pi_*$ is an orientation preserving isomorphism as well.\nTherefore, $V$ is a retract of $\\LambrechtsExtension(V)\\coloneqq\\hat{V}$ in the category of $\\PDGA$'s.\n\\end{proof}\n\nThe next example shows that the Sullivan minimal model is sometimes of Hodge type.\n\n\\begin{Example}[Sullivan minimal model of $\\Sph{2}$ is of Hodge type]\\label{Ex:SphereModel}\nThe Sullivan minimal model of $\\Sph{2}$ is the free graded commutative algebra $\\Model\\coloneqq\\Lambda(\\eta_2,\\eta_3)$ with $\\Abs{\\eta_2}=2$, $\\Abs{\\eta_3}=3$, $\\Dd \\eta_2 = 0$ and $\\Dd\\eta_3=\\eta_2\\wedge\\eta_2$.\nFrom degree reasons, it holds $\\Model = \\Span\\{\\eta_2^k \\eta_3^l \\mid k\\ge 0, l \\in \\{0,1\\}\\}$ as a graded vector space.\nWe have a canonical decomposition $\\Model = \\Harm \\oplus \\Dd \\Model \\oplus C$, where $\\Harm = \\Span\\{\\eta_2\\}$, $\\Dd \\Model = \\Span\\{\\eta_2^k \\mid k \\ge 2 \\}$ and $C = \\Span\\{\\eta_2^{k}\\eta_3 \\mid k \\ge 0\\}$.\nWe define an orientation $\\Or : \\Model \\rightarrow \\R$ in degree $2$ by $\\Or(\\eta_2) \\coloneqq 1$ on $\\Harm$ and by $0$ on $\\Dd \\Model$ and $C$.\nIt is easy to see that $C\\perp \\Harm$ and $C\\perp C$ with respect to the induced cyclic structure $\\langle \\cdot,\\cdot\\rangle$. \nConsider the $\\DGA$-quasi-isomorphism $f: \\Model \\rightarrow \\DR(\\Sph{2})$ defined by $f(\\eta_2)\\coloneqq \\Vol$ and $f(\\eta_3)\\coloneqq 0$.\nClearly, it is orientation preserving.\nWe have $\\Model/\\Model^\\perp\\simeq \\Lambda(\\eta_2)$\n\\end{Example}\n\nThe following proposition about the existence of a Poincar\\'e dualiy model of a Poincar\\'e $\\DGA$ $V$ with $\\H^1(V)=0$ was originally proven in \\cite[Theorem~1.1]{Lambrechts2007}.\nIt was formulated in the category of $\\DGA$'s, i.e., not checking whether the arrows are orientation preserving on homology.\nThe idea was to construct an extension $\\LambrechtsExtension(\\Lambda U )$ of the Sullivan minimal model $\\Lambda U$ of~$V$ and an orientation on it such that the degenerate subspace is acyclic; the Poincar\\'e duality model is then obtained by taking the quotient.\nThe extension is constructed by adding elements which kill the so called orphans.\n\nBy Proposition~\\ref{Prop:HodgeAcyc}, we know that $V^\\perp$ is acyclic if and only if $V$ is of Hodge type ($V$ needs to be of finite type for the direct implication).\nBased on this, we give a new construction of $\\LambrechtsExtension(\\Lambda U)$ using Lemma~\\ref{Lemma:Exte}, i.e., by adding exact partners to non-degenerates.\nOur construction works for $n\\ge 5$, whereas the assumption of \\cite{Lambrechts2007} is $n\\ge 7$.\nWe also do not need $\\Dd (\\Lambda U)^2 = 0$, although it follows from $\\H^1(V) = 0$.\nIt is also clear from our construction that the arrows preserve orientation on homology.\nHowever, this can be checked for the construction of \\cite{Lambrechts2007} as well.\n\n\\begin{Proposition}[Existence of Poincar\\'e duality model for $\\H^1 = 0$]\\label{Prop:ExOfLambrStan}\nA~Poincar\\'e $\\DGA$ $V$ with $\\H^0(V) = \\Span\\{1\\}$ and $\\H^1(V)=0$ admits a Poincar\\'e duality model $\\Model$.\n%If moreover $\\H^2 = \\H^3 = 0$, then for any two finite dimensional Poincar\\'e duality models $M_1$ and $M_2$ there is another finite dimensional Poincar\\'e duality model $M_3$ and the zig-zag of orientation preserving quasi-isomorphisms\n%$$\\begin{tikzcd}\n%& M_3 & \\\\\n%M_1\\arrow{ur} & & M_2.\\arrow{ul}\n%\\end{tikzcd}$$\n\\end{Proposition}\n\\begin{proof}\nIf $\\Or^\\H$ comes from a pairing on $V$ which is of Hodge type, then we can take $\\Model=\\VansQuotient(\\VansSmall(V))$. The weak homotopy equivalence of $\\PDGA$'s looks like\n\\begin{equation}\\label{Eq:ModOne}\n\\begin{tikzcd}\n &  \\VansSmall(V) \\arrow[two heads]{dl}\\arrow[hook]{dr} & \\\\\n \\VansQuotient(\\VansSmall(V)) & & V.\n\\end{tikzcd}\n\\end{equation}\nIf $V$ is not of Hodge type, we proceed as follows. Let $n$ be the degree of the orientation on $\\H(V)$.\nIf $n\\le 6$, then $V$ is formal as a $\\DGA$ by~\\cite{Miller1979}, and we can take $\\Model=\\H(V)$ by Proposition~\\ref{Prop:PoincModelOfFormal}.\nThe weak homotopy equivalence of $\\PDGA$'s looks like\n\\begin{equation}\\label{Eq:ModTwo}\n\\begin{tikzcd}\n & \\Lambda U \\arrow{dl}\\arrow{dr} & \\\\\n \\H(V) & & V,\n\\end{tikzcd}\n\\end{equation}\nwhere $\\Lambda U$ is the Sullivan minimal model of $V$.\nThe Sullivan minimal model $W\\coloneqq \\Lambda U$ is of finite type and satisfies $W^0 = \\R$, $W^1 = 0$ and $\\Dd W^2 = 0$.\nSuppose that $n\\ge 7$.\nLet $\\LambrechtsExtension(W)$ be the extension of $W$ of Hodge type either from Proposition~\\ref{Prop:ExtensionOfHodgeType} or from \\cite[Section~4]{Lambrechts2007}.\nThis extension is of finite type, the inclusion $W\\hookrightarrow\\LambrechtsExtension(W)$ is a quasi-isomorphism of $\\DGA$'s and $\\LambrechtsExtension(W)^\\perp$ is acyclic.\nMoreover, $W\\hookrightarrow\\LambrechtsExtension(W)$ preserves orientation on homology.\nWe take $\\Model = \\VansQuotient(\\LambrechtsExtension(\\Lambda U))$ and obtain the following weak homotopy equivalence of $\\PDGA$'s:\n\\begin{equation}\\label{Eq:ModThree}\\begin{tikzcd}\n & \\Lambda U \\arrow{dl}\\arrow{dr} & \\\\\n\\VansQuotient(\\LambrechtsExtension(\\Lambda V))& & V.\n\\end{tikzcd}\\end{equation}\nThis proves the proposition.\n\\end{proof}\n\nThe following is mostly \\cite[Theorem~7.1]{Lambrechts2007}.\nIn addition, we check that the orientation on homology is preserved.\nAlso, by using our extension of Hodge type, we can improve from $n\\ge 7$ to $n\\ge 5$.\n\n\\begin{Proposition}[``Weak uniqueness'' of Poincar\\'e duality model]\\label{Prop:LambrechtUnique}\nLet $V_1$ and $V_2$ be differential Poincar\\'e duality algebras of degree $n$ which are weakly homotopy equivalent as $\\PDGA$'s.\nSuppose that $\\H^0(V_1)=\\H^0(V_2)=\\Span\\{1\\}$ and $\\H^1(V_1) = \\H^1(V_2) = 0$.\nIn addition, suppose that $\\H^2(V_1) = \\H^2(V_2) = 0$, $V_1^1 = V_2^1 = 0$ and $n\\ge 5$.\nThen there is a differential Poincar\\'e duality algebra $V_3$ and $\\PDGA$-quasi-isomorphisms\\footnote{These are automatically injective and orientation preserving.}\n\\begin{equation}\\label{Eq:LambrechtsZigZag}\n\\begin{tikzcd}\n& V_3 & \\\\\nV_1\\arrow{ur}& & \\arrow{ul}V_2.\n\\end{tikzcd}\n\\end{equation}\n%Moreover, $V_3$ is of finite type, $V_3^0 = \\R$, $V_3^1 = 0$ and $\\Dd V^3 = 0$.\n\\end{Proposition}\n\\begin{proof}\nBy the assumption, there is $k\\ge 1$ and a zig-zag of $\\PDGA$-quasi-isomorphisms\n\\begin{equation}\\label{Eq:ZigZag}\nV_1 \\longleftarrow Z_1 \\longrightarrow Z_2 \\longleftarrow Z_3 \\longrightarrow Z_4 \\longleftarrow \\dotsb \\longleftarrow Z_k \\longrightarrow V_2.\n\\end{equation}\nConsider the Sullivan minimal model $\\Lambda U \\rightarrow Z_2$ and use the Lifting Lemma \\cite[Lemma~2.15]{Felix2008} to construct $\\DGA$-quasi-isomorphisms $\\Lambda U \\rightarrow Z_1$ and $\\Lambda U \\rightarrow Z_3$ such that the diagram\n$$\\begin{tikzcd}\n& \\Lambda U \\arrow{d} \\arrow{ld} \\arrow{rd} & \\\\\nZ_1 \\arrow{r} & Z_2 & \\arrow{l} Z_3\n\\end{tikzcd}$$\ncommutes up to homotopy of $\\DGA$'s. It is easy to see that there is an orientation on $\\H(\\Lambda U)$ such that all morphisms preserve orientation on homology. Therefore, we can replace the segment $V_1 \\longleftarrow Z_1 \\longrightarrow Z_2 \\longleftarrow Z_3 \\longrightarrow Z_4$ in \\eqref{Eq:ZigZag} by $V_1 \\longleftarrow \\Lambda U \\longrightarrow Z_4$. Repeating this process, we can shorten \\eqref{Eq:ZigZag} to \n\\begin{equation}\\label{Eq:DiagDiag}\n\\begin{tikzcd}\n& \\Lambda U \\arrow{dr}{f_2} \\arrow[swap]{dl}{f_1} & \\\\\nV_1 & & V_2,\n\\end{tikzcd}\n\\end{equation}\nwhere $f_1$ and $f_2$ are $\\PDGA$-quasi-isomorphisms. In order to take $\\VansQuotient(\\LambrechtsExtension(\\Lambda U))$ and obtain a zig-zag with three terms, we have to revert the arrows in \\eqref{Eq:DiagDiag}. The trick from~\\cite{Lambrechts2007} is the following:\n\nConsider the relative minimal model of the multiplication $\\mu: \\Lambda U \\otimes \\Lambda U \\rightarrow \\Lambda U$; from \\cite[Example~2.48]{Felix2008}, it is given by\n\\begin{equation}\\label{Eq:RelMinMod}\n\\begin{tikzcd}\n\\Lambda U \\otimes \\Lambda U\\arrow{r}{\\mu} \\arrow{rd}{i} & \\Lambda U \\\\\n& M(\\mu)\\coloneqq \\Lambda U \\otimes \\Lambda U \\otimes \\Lambda(U[1]), \\arrow{u}{p}\n\\end{tikzcd}\n\\end{equation}\nwhere $i$ is the inclusion into the first two factors, which is a cofibration, and $p$ is a surjective quasi-isomorphism. Let $\\iota_i : \\Lambda U \\rightarrow \\Lambda U \\otimes \\Lambda U$ for $i=1$, $2$ be the inclusions to the first and the second factor, respectively. Because $\\mu \\circ \\iota_i = \\Id$ and $p$ is a quasi-isomorphism, the maps $i \\circ \\iota_i : \\Lambda U \\rightarrow M(\\mu)$ for $i=1$, $2$ are quasi-isomorphisms. Moreover, it is easy to see that $\\H(M(\\mu))$ inherits an orientation such that $p_*$ and $(i\\circ \\iota_i)_*$ are orientation preserving. To transfer this situation to $V_i$, we use the diagram\n\\begin{equation}\\label{Eq:Pushout}\n\\begin{tikzcd}\n\\Lambda U \\arrow{r}{f_i}\\arrow{d}{\\iota_i}& V_1 \\arrow{d}{\\iota_i^V} \\\\\n\\Lambda U \\otimes \\Lambda U \\arrow{r}{f_1\\otimes f_2} \\arrow{d}{i} & V_1 \\otimes V_2 \\arrow{d}{g_2} \\\\\nM(\\mu) \\arrow{r}{g_1} & \\tilde{V}_3 \\coloneqq  M(\\mu) \\otimes_{\\Lambda U \\otimes \\Lambda U} (V_1\\otimes V_2),\n\\end{tikzcd}\n\\end{equation}\nwhere $\\iota_i^V : V_i \\rightarrow V_1 \\otimes V_2$ for $i=1$, $2$ are inclusions. The lower square, i.e., the maps $g_1$, $g_2$ and the $\\DGA$ $\\tilde{V}_3$, is a pushout diagram (see \\cite[Example~1.4]{LoopSpaces}). According to~\\cite{MO204414}, the model category of $\\nnuCDGA$ is proper, and hence pushouts along cofibrations preserve quasi-isomorphisms. Therefore, $f_1\\otimes f_2$ being a quasi-isomorphism implies that $g_1$ is a quasi-isomorphism. We push the orientation to~$\\H(\\tilde{V}_3)$ via $g_{1*}$. Since $i\\circ \\iota_i$, $g_1$ and $f_i$ are quasi-isomorphisms preserving orientation on homology, it follows that $h_i\\coloneqq g_2\\circ \\iota_i^V:  V_i \\rightarrow V_3$ are quasi-isomorphisms preserving orientation of homology as well. It holds\n\\[\n\\tilde{V}_3 \\simeq \\Lambda(U[1]) \\otimes V_1 \\otimes V_2.\n\\]\nClearly, $\\tilde{V}_3$ is of finite type.\nUsing $\\H^1(V_i) = \\H^2(V_i) = 0$, we have $U^1 = U^2 = 0$, and hence $(\\Lambda(U[1]))^1 = 0$.\nThis together with $V_i^1 = 0$ implies that $\\tilde{V}_3^1 = 0$.\n%$\\tilde{V}_3^1 = 0$ and $\\tilde{V}_3^2 = \\tilde{V}_1^0 \\otimes \\tilde{V}_2^0 \\otimes U^{3} = 0$ hold due to the additional assumptions.\nTherefore, all conditions for an application of the Hodge extension $\\LambrechtsExtension$ from Proposition~\\ref{Prop:ExtensionOfHodgeType} are satisfied, and we can set\n$$ V_3\\coloneqq \\VansQuotient(\\LambrechtsExtension(\\tilde{V}_3)). $$\nThis finishes the proof.\n%\n%I could have started with Poincar\\'e $\\DGA$'s (i.e., Poincar\\'e duality algebra on homology) and obtain a Poincar\\'e DGA $\\tilde{V}_3$ and subsequently a Poincar\\'e model. Hence quasi-isomorphic $\\PDGA$'s, then there exists a Poincar\\'e model $V_3$ and the arrows to them.\n%\n%Suppose we have started with differential Poincar\\'e duality algebras, then we obtain isomorphisms of small algebras. \n\\end{proof}\n\n\\begin{Conjecture}\\label{Conj:PDGALST}\nThe additional assumptions of Proposition~\\ref{Prop:LambrechtUnique} can be dropped.\n\\end{Conjecture}\n\n\\begin{Remark}[Weak uniqueness in the case of $\\H^1(V)=0$ and $n\\le 3$]\n For $n=1$, there is no differential Poincar\\'e duality algebra $V$ with $\\H^1(V) = 0$.\n \n For $n=2$, a general differential Poincar\\'e duality algebra can be written in terms of its Hodge decomposition as\n \\begin{align*}\n \tV^2 & = \\Span\\{\\Vol\\}\\oplus \\Dd C^1\\\\\n\tV^1 & = \\Dd C^0 \\oplus C^1\\\\\n\tV^0 & = \\Span\\{1\\} \\oplus C^0.\n \\end{align*}\n Now, $\\Harm = \\Span\\{1\\}\\oplus \\Span\\{\\Vol\\}$ is a dg-subalgebra which is itself a Poincar\\'e duality algebra. Therefore, two differential Poincar\\'e duality algebras with $\\H(V_1)\\simeq \\H(V_2)$ and $\\H^1(V_i) = 0$ are connected via the zig-zag\n\\[\n\\begin{tikzcd}\n& \\Harm \\arrow{dr}{} \\arrow[swap]{dl}{} & \\\\\nV_1 & & V_2.\n\\end{tikzcd}\n\\]\nFor $n=3$, we have \n\\begin{align*}\n\tV^3 & = \\Span\\{\\Vol\\} \\oplus \\Dd C^2\\\\\n \tV^2 & =\\Dd C^1 \\oplus C^2 \\\\\n\tV^1 & = \\Dd C^0 \\oplus C^1\\\\\n\tV^0 & = \\Span\\{1\\} \\oplus C^0,\n\\end{align*}\nand the same situation as for $n=2$ occurs.\n\nFor $n=4$ and $V^1 = 0$, we have $V \\simeq \\Harm$.\n\\end{Remark}\n\nWe would like to define a ``minimal Poincar\\'e duality model''. We motivate this notion in the following remark.\n\n\\begin{Remark}[Model and minimal model]\\label{Rem:Models}\nWe shall understand models and minimal models in terms of model categories and their homotopy categories.\n\nLet us illustrate this on Sullivan models. A Sullivan $\\DGA$ is a free graded commutative algebra $\\Lambda U$ over a positively graded vector space $U$ which admits a well-ordered homogenous basis $(v_\\alpha)$ such that $\\Dd v_\\alpha \\in \\Lambda(v_\\beta \\mid \\beta < \\alpha)$ ($\\coloneqq$\\,the subalgebra of $\\Lambda U$ generated by the $v_\\beta$'s) for all $\\alpha$. A Sullivan $\\DGA$ is called minimal if $\\im \\Dd \\subset \\Lambda_{\\ge 2} U$ ($\\coloneqq$\\,the set of decomposable elements).\n\nAccording to \\cite[Theorem~4.3]{Bousfield1976}, the category $\\nnuCDGA$ is a model category with weak equivalences being $\\DGA$-quasi-isomorphisms, fibrations being degree-wise surjective $\\DGA$-morphisms and cofibrations being retracts of relative Sullivan algebras (see \\cite[Proposition~2.22 and Proposition~2.28]{Felix2008}). Cofibrant objects are then precisely Sullivan algebras. \n\nSo, the homotopy extension property holds already for Sullivan $\\DGA$'s. To see the role of minimality, we shall descent to the homotopy category. The homotopy category is constructed from a model category by localizing morphisms at weak equivalences. An isomorphism in the homotopy category, called weak homotopy equivalence, corresponds to a zig-zag of weak equivalences. If $V_1$ is weakly homotopy equivalent to $V_2$, we say that $V_2$ is a model of $V_1$. If there is a weak equivalence $V_2 \\rightarrow V_1$, we say that $V_2$ is a resolution of~$V_1$. We understand minimality as a condition which is in each weak homotopy equivalence class satisfied by at most one object up to isomorphism in the model category. If minimal models exist, they form a skeleton of the homotopy category. This is precisely the case of $\\nnuCDGA$ and minimal Sullivan algebras. Indeed, by \\cite[Theorem~2.24]{Felix2008}, every connected $\\nnuCDGA$ is resolved by a minimal Sullivan algebra. Next, by \\cite[Proposition~2.26]{Felix2008}, a $\\DGA$-morphism lifts to resolutions by Sullivan algebras, and by \\cite[Corollary~2.13]{Felix2008}, quasi-isomorphic minimal Sullivan $\\DGA$'s are isomorphic. Finally, this implies that weakly homotopy equivalent minimal Sullivan algebras are isomorphic, and hence are minimal in the sense above.\n\nAs another example, for an operad (or properad) $\\Operad$, one wants to construct a dg-operad~$\\Operad_\\infty$ which is a quasi-free resolution of $\\Operad$ (see \\cite{Vallette2012}). Quasi-free means that after forgetting the differential, the operad $\\Operad_\\infty$ is free over $\\Perm$-bimodules. This is similar to Sullivan models which are free over vector spaces. For quadratic operads, $\\Operad_\\infty$ is often constructed as the cobar construction $\\Omega$ of the Koszul dual cooperad $\\Operad^{\\mbox{!`}}$. This is the case of $\\AInfty$, $\\LInfty$ or of the properad $\\IBLInfty$. The differential on $\\Omega \\Operad^{\\mbox{!`}}$ is the extension of the decomposition on~$\\Operad^{\\mbox{!`}}$ to a derivative, and hence it has decomposable image (c.f., the explicit formula~\\cite[Formula~(2)]{Peksova2018}). This is similar to minimal Sullivan models. It would be interesting to know whether $\\Operad_\\infty$ can be constructed using the same inductive method of ``killing'' and ``adding'' generators of homology as Sullivan minimal models. \n\nFinally, let us note that in \\cite{Cirici2019}, they use the inductive method to construct (minimal) models of $\\Operad$-algebras for a wide class of operads $\\Operad$. Note that cyclic $\\AInfty$-algebras can be formulated in the language of cyclic operads. However, in the case of $\\PDGA$'s, we have the non-degenerate pairing on homology and an operadic description is not clear.\n\\end{Remark}\n%\\begin{Lemma}\n%Let $f: V_1 \\rightarrow V_2$ be an orientation preserving quasi-isomorphism of differential Poincar\\'e duality algebras $(V_1,\\Dd_1,\\wedge_1,\\Or_1)$ and $(V_2,\\Dd_2,\\wedge_2,\\Or_2)$. Then $f$ is injective and... \\todo{What more properties? Dies there exist a dg-ideal $Z$ s.t. $V_2 = Z \\oplus f(V_1)$?}  \n%\\end{Lemma}\n%\\begin{proof}\n%It follows easily that $f$ is injective. Now we have $V = W \\oplus W_\\perp$. From the cyclicity of $\\Dd$ we get $\\Dd W_\\perp \\subset V$. We would like to construct a complementary differential graded ideal. We still haven't used the fact that $W$ is a subalgebra and the cyclicity.\n%\\end{proof}\n%\n%\\begin{Lemma}\n%A cyclic cochain complex which is of finite-type (degreewise finite dimensional) and satisfies Poincar\\'e duality is of Hodge type. \n%\\end{Lemma}\n%\\begin{proof}\n%\n%\\end{proof}\n%\n%\\begin{Lemma}\n%Let $V$ be of finite type. Then Poincar\\'e duality is equivalent to non-degeneracy.\n%\\end{Lemma}\n%\n%Therefore, Poincar\\'e duality algebras are contained in degrees $0$ $\\dots$ $n$.\n%\n%\n%\n%\\begin{Lemma}\n%Any two small algebras are isomorphic.\n%\\end{Lemma}\n%\\begin{proof}\n%\\end{proof}\n%\n%\\begin{Lemma}\n%If $V$ is differential Poincar\\'e duality algebra of finite type, then $Q(V_{\\text{small}})$ is a weakly equivalent differential Poincar\\'e duality algebra of finite type.\n%\\end{Lemma}\n%\n%\\begin{Lemma}\n%Let $V$ be a differential Poincar\\'e duality algebra of finite type. Then the sequence of taking $Q(\\bullet_{smallal}$ stabilizes. I.e. there are going to be isomorphic.\n%\\end{Lemma}\n%\\begin{proof}\n%Clear for finite dimensional.\n%\\end{proof}\n%\n%\\begin{Lemma}\n%Any two minimal Poincar\\'e duality models are isomorphic.\n%\\end{Lemma}\n\n%Consider small Poincar\\'e duality models. Let $(V,\\Dd,\\wedge,\\Or^\\H)$ be a $\\PDGA$ with $\\H^0(V) = \\R$ and $\\H^1(V)=0$. Proposition~\\ref{Prop:ExOfLambrStan} gives a Poincar\\'e duality model $\\Model$. Proposition~\\ref{Prop:PropPropertiessd} asserts that $\\VansQuotient(\\VansSmall(\\Model))$ is small and Proposition~\\ref{Prop:HodgeAcyc} asserts that it is weakly homotopy equivalent to $\\Model$ and hence to $V$ as a $\\PDGA$. Therefore, small Poincar\\'e duality models exist. Let $\\Model_1$ and $\\Model_2$ be two small Poincar\\'e duality models of $V$. Pick any of their Hodge decompositions. Proposition~\\ref{Prop:LambrechtUnique}, more generally Conjecture~\\ref{Conj:PDGALST}, gives the diagram \\eqref{Eq:LambrechtsZigZag}, where $V_1 = \\Model_1$, $V_2 = \\Model_2$ and $V_3$ are differential Poincar\\'e duality algebras and the maps, which we denote by $f_1: V_1 \\rightarrow V_3$ and $f_2: V_2\\rightarrow V_3$, are $\\PDGA$-quasi-isomorphisms. Lemma~\\ref{Eq:LemSmallSub} asserts that there are Hodge decompositions of $V_3$ with small subalgebras $\\VansSmall_1(V_3)$ and $\\VansSmall_2(V_3)$ such that $f_1$ and $f_2$ induce pairing preserving isomorphisms $\\VansSmall(V_1) \\simeq \\VansSmall_1(V_3)$ and $\\VansSmall(V_2) \\simeq \\VansSmall_2(V_3)$, respectively. Conjecture~\\ref{Conj:UnieqSmal} asserts that $\\VansQuotient(\\VansSmall_1(V_3)) \\simeq \\VansQuotient(\\VansSmall_2(V_3))$. In total, we have\n%$$ \\Model_1 \\simeq \\VansQuotient(\\VansSmall(\\Model_1)) \\simeq \\VansQuotient(\\VansSmall_1(V_3))\\simeq \\VansQuotient(\\VansSmall_2(V_3)) \\simeq \\VansQuotient(\\VansSmall(\\Model_2)) \\simeq \\Model_2 $$\n%as differential Poincar\\'e duality algebras.\n%\\begin{Corollary}[Small Poincar\\'e duality models are minimal]\\label{Cor:SmalPoinc}\n%Small Poincar\\'e duality models exist when $\\H^0 = \\R$ and $\\H^1 = 0$ and are unique up to an isomorphism provided that the conjectures from Sections~\\ref{SubSec:CycStr} and~\\ref{SubSec:PoincModel} are true.\n%\\end{Corollary}\n\nThe following example shows that the zig-zag of a Poincar\\'e duality model can not always be shortened to one arrow.\n\n\\begin{Example}[No Poincar\\'e dualiy model with one arrow]\\phantomsection\\label{Ex:NoOneArrow}\n\\begin{ExampleList}\n\\item The closed genus $2$ surface $\\Sigma_2$ does not admit a Poincar\\'e duality model $A$ with just one arrow $A \\rightarrow \\DR(\\Sigma_2)$. Suppose the contrary. We consider the quasi-isomorphism $f:A\\rightarrow \\DR(\\Sigma_2)$ and compute for homogenous $v_1$, $v_2\\in A$ the following:\n\\begin{align*}\n\\langle f(v_1),f(v_2)\\rangle &= \\pm \\langle f(v_1)\\wedge f(v_2),1 \\rangle\\\\\n&= \\pm \\langle f(v_1\\wedge v_2),1 \\rangle\\\\\n&= \\pm \\langle [f(v_1\\wedge v_2)],[1]\\rangle\\qquad\\text{(*)}\\\\\n&= \\pm \\langle f_*[v_1\\wedge v_2], f^*[1] \\rangle\\\\\n&= \\pm \\langle [v_1\\wedge v_2],[1]\\rangle\\\\\n&= \\pm \\langle v_1\\wedge v_2, 1 \\rangle\\qquad(*) \\\\\n&= \\langle v_1, v_2 \\rangle.\n\\end{align*}\nStars hold because the only non-zero case is when $\\deg(v_1) + \\deg(v_2) = \\deg(\\langle\\cdot,\\cdot\\rangle)$, and hence $\\Dd (v_1\\wedge v_2) = 0$ because non-degeneracy implies vanishing of higher degrees. We see that $f$ preserves the pairing on the chain-level and is injective by non-degeneracy. We can thus assume that $A\\subset\\DR(\\Sigma_2)$ is a dg-subalgebra equipped with the restriction of the intersection pairing. Since $\\dim(A)<\\infty$, there is a Hodge decomposition\n\\begin{align*}\n\tA^2 &= \\Harm^2 \\oplus \\Dd C^1\\\\\n\tA^1 &= \\Harm^1 \\oplus \\Dd C^0 \\oplus C^1\\\\\n\tA^0 &= \\Harm^0 \\oplus C^0.\n\\end{align*}\nIf $1\\neq f\\in C^{\\infty}(\\Sigma_2)$, then $f^k$, $k\\in \\N_0$ are linearly independent over $\\R$. Therefore, it must hold $\\Harm^0 = \\Span\\{1\\}$ and $C^0 = 0$. Duality implies $\\Dd C^1 = 0$, and hence $\\Harm^2$ is spanned by $\\omega \\in \\DR^2(\\Sigma_2)$ with $\\int_{\\Sigma_2}\\omega = 1$. It holds even $C^1=0$ as $\\ker \\Dd \\cap C = 0$ in a Hodge decomposition. Since $A\\simeq \\H(\\Sigma_2)$ as a $\\DGA$, there are closed $\\alpha_1$, $\\beta_1$, $\\alpha_2$, $\\beta_2\\in\\DR^1(\\Sigma_2)$ such that $\\Harm^1 = \\Span\\{\\alpha_1, \\beta_1, \\alpha_2, \\beta_2\\}$ and such that for all $x\\in\\Sigma_2$ the following holds:\n\\begin{align*}\n\t\\alpha_1(x) \\wedge \\alpha_2(x) &=  \\alpha_1(x) \\wedge \\beta_2(x) = 0\\\\\n\t\\quad\\alpha_1(x)\\wedge\\beta_1(x) &= \\alpha_2(x)\\wedge\\beta_2(x) = \\omega(x).\n\\end{align*}\nTaking an $x\\in \\Sigma_2$ with $\\omega(x) \\neq 0$ gives a contradiction.\n\n\\item  The simply-connected $4$-manifold $\\CP^{2\\# 7}$, where $\\#$ denotes the connected sum, does not admit a Poincar\\'e duality model $A$ with just one arrow $A \\rightarrow \\DR(M)$. Similarly as in the proof for $\\Sigma_2$, we can restrict to the case $A\\subset\\DR(\\CP^{2 \\# 7})$. We obtain $A^4 = \\Harm^4 = \\langle \\omega \\rangle$ for a somewhere non-vanishing $4$-form $\\omega$ and $\\Harm^2 = \\langle K_0, \\dotsc, K_6 \\rangle$ such that for all $x\\in \\CP^{2\\#7}$ the following holds:\n\\begin{align*}\n\tK_i(x)\\wedge K_i(x) &= \\pm \\omega(x) \\\\\n\tK_i(x) \\wedge K_j(x) &= 0.\n\\end{align*}\nWe now view $K_i(x)$ as vectors in $\\R^6$ so that $K_0(x)\\wedge K_j(x) = 0$ corresponds to taking the scalar product. If $\\sum_{i=0}^6 \\lambda_i K_i(x) = 0$ for some $\\lambda_i\\in \\R$ with $\\lambda_{i_0} \\neq 0$, then\n\\[\n0 = K_{i_0}(x) \\wedge \\Bigl(\\sum_{i=0}^6 \\lambda_i K_i(x)\\Bigr) = \\pm \\lambda_{i_0} \\omega(x).\n\\]\nTherefore, $\\omega(x) \\neq 0$ implies that $K_i(x)$ are linearly independent. Hence, in this case, $K_0(x) \\wedge K_i(x) = 0$ for all $i=1$, $\\dotsc$, $6$ implies $K_0(x) = 0$, which is a contradiction with $K_0(x) \\wedge K_0(x) = \\omega(x)$.\\qedhere\n\\end{ExampleList}\n\\end{Example}\n\n\n\\begin{Questions}\\phantomsection\\label{Q:QuestionsPonc}\n\\begin{RemarkList}\n%\\item Is it possible to prove Proposition~\\ref{Prop:LambrechtUnique} for $n\\le 6$ when formality holds in an easier way?\n\\item Give an example of a Sullivan minimal model $f: \\Lambda U \\rightarrow V$ of a $\\PDGA$ $V$ which is not of Hodge type for any orientation such that $f_*: \\H(\\Lambda U) \\rightarrow \\H(V)$ is orientation preserving.\n\\item Can the additional assumptions in Lemma~\\ref{Lemma:Exte} and Proposition~\\ref{Prop:ExtensionOfHodgeType} be dropped?\n%\\item Is t a model category structure on Poincar\\'e $\\DGA$'s ?\n%\\item Sullivan's inductive construction gives a minimal model which resolves $V$. The construction of Proposition~\\ref{Prop:ExOfLambrStan} does not resolve $V$ in any case \\eqref{Eq:ModOne}, \\eqref{Eq:ModTwo} and \\eqref{Eq:ModThree}. Is it possible to resolve a $\\PDGA$ by a Poincar\\'e duality model? It is clearly possible in the geometrically formal case, i.e., when there is a $\\DGA$-quasi-isomorphism $\\H(V)\\rightarrow V$.\n%For the sake of comparison with Sullivan's inductive construction, it might be interesting to know whether $\\VansQuotient(\\VansSmall(\\cdot))$ is free over $\\DGA$'s of Hodge type and whether its differential has decomposable image.\n\\item Is smallness or minimal dimension the correct notion of ``minimality'' of a Poincar\\'e duality model?  \\qedhere\n\\end{RemarkList}\n\\end{Questions}\n\n\n\\end{document}\n", "meta": {"hexsha": "2339d7ec219dc09c2973834415efbbe06786da6a", "size": 36110, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Subfiles/Form_PDGA.tex", "max_stars_repo_name": "p135246/phd-thesis", "max_stars_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subfiles/Form_PDGA.tex", "max_issues_repo_name": "p135246/phd-thesis", "max_issues_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subfiles/Form_PDGA.tex", "max_forks_repo_name": "p135246/phd-thesis", "max_forks_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.3288288288, "max_line_length": 1399, "alphanum_fraction": 0.7122126835, "num_tokens": 12503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.431993539194188}}
{"text": "% !TeX root = ../main.tex\r\n\\documentclass[../main.tex]{subfiles}\r\n\\begin{document}\r\n\\section{The Model}\r\n\\stepcounter{Counter}\r\n\\begin{ModelGroupElement}\r\nFor any parameter \\(\\kappa, n\\),\r\n\\begin{align*}\r\n\\elements&\\coloneqq M\\\\\r\n\\groupoperation{\\elements}&\\coloneqq\\cdot\\\\\r\n\\charts{\\elements}&\\coloneqq\\tensor{X}{}\\mapsto\\tensor{\\theta}{}\\\\\r\n\\innerprod{\\elements}&\\coloneqq g\\\\\r\n\\points{\\elements}&\\equiv R\\\\\r\n\\transformations{\\elements}&\\equiv M\\\\\r\n\\end{align*}\r\nfor injective smooth function \\(K\\colon\\kappa\\mapsto\\lambda=\\sign{\\kappa}\\sqrt{\\abs{\\kappa}}\\in\\R\\to\\R\\).\r\n\\end{ModelGroupElement}\r\n\\begin{ModelGroupAssertion}\r\n\\end{ModelGroupAssertion}\r\n\\begin{ModelCurvatureAssertion}\r\n\\end{ModelCurvatureAssertion}\r\n\\end{document}", "meta": {"hexsha": "01da5329d34f405764927e5443c66e8897de7b9c", "size": 731, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/assertion.tex", "max_stars_repo_name": "30MA19-02/proof", "max_stars_repo_head_hexsha": "24d95d419e5632a2cc08a9c9bc94e89e262afc04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/assertion.tex", "max_issues_repo_name": "30MA19-02/proof", "max_issues_repo_head_hexsha": "24d95d419e5632a2cc08a9c9bc94e89e262afc04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/assertion.tex", "max_forks_repo_name": "30MA19-02/proof", "max_forks_repo_head_hexsha": "24d95d419e5632a2cc08a9c9bc94e89e262afc04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.2272727273, "max_line_length": 106, "alphanum_fraction": 0.7222982216, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619979547273, "lm_q2_score": 0.5156199157230156, "lm_q1q2_score": 0.4318935432620789}}
{"text": "%-------------------------------------------------------------------------------\n\\section{Mathematical / physical description}\\label{sec:method}\n%-------------------------------------------------------------------------------\nIn the following, we describe the SKYCORR sky correction procedure in more\ndetail (also see Section~\\ref{sec:algorithm}). First, we discuss how emission\nlines are identified in the input science and sky spectra\n(Section~\\ref{sec:linesearch}). This procedure also derives the typical line\nFWHM (Section~\\ref{sec:linesearch}). Next, the subtraction of the remaining\ncontinua from the identified line spectra is described\n(Section~\\ref{sec:contsub}). Then, the airglow model is discussed\n(Section~\\ref{sec:airglow}). It is an essential input for scaling the\nreference sky line spectrum to fit the science line spectrum\n(Section~\\ref{sec:linefit}). The fitting procedure also allows adapting the\nwavelength grids (Section~\\ref{sec:wavegrid}). The final step of the sky\ncorrection procedure is the sky subtraction itself. This operation is just the\nsubtraction of the best-fit sky line spectrum and the unscaled sky continuum\nspectrum from the input science spectrum (see also\nSection~\\ref{sec:algorithm}).\n\n%-------------------------------------------------------------------------------\n\\subsection{Line finder}\\label{sec:linesearch}\n%-------------------------------------------------------------------------------\nThe sky correction procedure focuses on fitting the airglow emission lines in\nan input science spectrum by scaling a reference sky line spectrum. Hence,\nobject and sky continua have to be subtracted in advance. This requires\nidentification of line and continuum pixels in the input spectra. Spectral\nlines are identified by an approach that uses the first derivative of the\nspectrum. Thus, line pixels can be recognised by their large flux gradients.\nEmission line peaks can be identified by a change from positive to negative\nvalues of the first derivative.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=17cm,clip=true]\n{figures/X-Shooter_spec_deriv_1_6-1_605.pdf}\n\\caption[]{X-Shooter sky spectrum {\\tt sky\\_xshoo\\_28}. The upper panel shows\nthe entire wavelength range $\\lambda=1.0...2.0\\,\\mu$m with the zoom range\n$\\lambda=1.6...1.605\\,\\mu$m (red lines) shown in the middle panel containing a\nprominent single emission line. In the lower panel the first derivative of this\nline is given, which shows a significant change in the values. Such changes\nare used as signature to identify emission lines (marked by the light blue\nvertical lines in the panels).}\n\\label{fig:xshoo1}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=9.5cm,clip=true]\n{figures/TEST-SINFO-J_with_lines.pdf}\n\\caption[]{SINFONI $J$-band sky spectrum with detected emission lines\n(blue = isolated lines used for the FWHM estimate).}\n\\label{fig:sinfoj1}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=9.5cm,clip=true]\n{figures/N4625-SINFO-H_with_lines.pdf}\n\\caption[]{SINFONI $H$-band sky spectrum + arbitrarily scaled NGC\\,4625\nspectrum at $z = 0.5$ + 5 artificial emission lines of equal intensity with\ndetected emission lines (blue = isolated lines used for the FWHM estimate).}\n\\label{fig:sinfoh1}\n\\end{figure}\n\nFigure~\\ref{fig:xshoo1} shows the X-Shooter spectrum {\\tt sky\\_xshoo\\_28} (see\nSection~\\ref{sec:evaluation}) in the upper panel. A zoom-in to the wavelength\nrange $\\lambda=1.6...1.605\\,\\mu$m isolates a prominent single emission line\n(middle panel). The first derivative of the same spectral range (lower panel)\nreveals a significant change from positive to negative values allowing\ndetection of emission lines. Single emission lines are identified by this\nparticular signature. Note that only changes $\\geq1\\sigma$ above the noise\nlevel are taken into account to avoid spurious detections from noise or broad\nlines caused by blending.\n\nLine identification via the first derivative allows robust characterisation of\nlines also in case of strong (pseudo)\\-continuum variations. This is necessary\nas isolated lines are required for estimating their FWHM.\nFigures~\\ref{fig:sinfoj1} and \\ref{fig:sinfoh1} show a SINFONI $J$-band and\n$H$-band spectrum, respectively. In the latter a simulated object\nspectrum was added to the sky emission (see Section~\\ref{sec:evaluation} for\nmore information). The distinct emission peak at $\\lambda\\sim1.25....1.3\\,\\mu$m\nin the $J$-band is a pseudocontinuum caused by many unresolved O$_2$ sky lines,\nwhereas in the $H$-band observation a real continuum is visible. In both cases,\nindividual emission lines could be identified.\n\nAll detected lines are assembled in a line list, which is refined by an\niterative method depending on the estimation of the sky line FWHM (see\nSection~\\ref{sec:FWHM}). This procedure requires identification of strong,\nisolated lines. Therefore, the line finder checks the previously identified\nline peaks, applying criteria characterising isolated lines. For a line to be\nmarked as isolated, it has to be sufficiently separated from other lines and\nits peak has to have a symmetric shape. The first criterion can be influenced\nby the user. The parameter file includes the unitless scaling parameter {\\sc\nmin\\_line\\_dist} that is internally multiplied by the line FWHM in pixels.\nAlso, this parameter is included in the driver file (see\nSection~\\ref{sec:params}). Since the FWHM is optimised in an iterative\nprocedure (see Section~\\ref{sec:FWHM}), the given value in the file is only\nused as first guess.\n\nFor strong and well separated lines, the described line finding method is very\nrobust. However, for low resolution spectra with many blended lines a major\nfraction of lines may be missed. Therefore, the line list of the airglow model\nis being used (see Section~\\ref{sec:airglow}) to find previously unidentified\nlines that have fluxes above the median flux of the lines identified by the\nderivative approach times the {\\sc fluxlim} parameter of the parameter file. By\ndefault, {\\sc fluxlim} is set to -1, which indicates an iterative approach\nstarting with 0.005 and doubling the previous value in subsequent iterations.\nIf the higher limit does not spare sufficient continuum pixels for the\ncontinuum interpolation (see Section~\\ref{sec:contsub}), \\ie\\ at least 20\\% of\nall pixels distributed over more than 90\\% of the wavelength range, the\nprocedure is stopped and 0.005 is eventually selected, otherwise the threshold\nvalue is doubled (\\ie\\ 0.02 is taken). This process is repeated as long as a\nsufficient number of continuum pixels are left over or a value of 0.08 is\nreached. The number of pixels characterised as line pixels for each line\nincluded from the line list depends on the given line FWHM (see above and\nSection~\\ref{sec:FWHM}). The combination of line pixels identified by both\nmethods gives a good estimate of the spectral ranges covered by significant\nairglow lines (see Figure~\\ref{fig:lineflags}).\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=12cm,clip=true]{figures/scd_illlineflags.pdf}\n\\caption[]{Line flags identified in a part of a SINFONI $H$-band spectrum. The\nmeaning of the flags is as follows: 0 = continuum, 1 = line pixel,\n2 = line peak, 3 = isolated line peak.}\n\\label{fig:lineflags}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n\\subsection{Line FWHM estimator}\\label{sec:FWHM}\n%-------------------------------------------------------------------------------\nFor calculating the airglow model (see Section~\\ref{sec:airglow}), it is\nrequired to convert total line fluxes as provided by the input line list into\nfluxes per wavelength interval. Consequently, it is necessary to know the\ntypical FWHM of the airglow lines, which is the only line shape parameter\nassuming a Gaussian line profile. The line finder described in the previous\nSection~\\ref{sec:linesearch} searches for isolated lines that are suitable for\nderiving a FWHM. After the subtraction of the continuum (see\nSection~\\ref{sec:contsub}), the FWHM estimation can be performed by fitting a\nGaussian to the line pixels belonging to each isolated line. For the fitting\nprocedure, the C version of the least-squares fitting library MPFIT by\nC.~Markwardt~\\cite{CMPFIT} based on the FORTRAN fitting routine MINPACK-1 by\nMor\\'e et al.~\\cite{MOR80} is used (see also Section~\\ref{sec:linefit}).\nThe FWHM measurements of all isolated lines are averaged to obtain the typical\nFWHM of the input spectrum. In order to avoid blended lines contributing to\nthe resulting mean, a $\\sigma$-clipping approach is applied to skip\nsuspiciuosly high FWHM. The method is based on computing the median absolute\ndifference between the data points and their median and the subsequent\napplication of Huber's method for an iterative clipping of outliers\n\\cite{huber} and the derivation of reliable mean and standard deviation from\nthe unclipped values. If less than five isolated lines remain after clipping,\nthe median FWHM is taken.\n\nThe fact that the estimated value of the FWHM affects the search for isolated\nlines (see Section~\\ref{sec:linesearch}), which are required for the FWHM\nestimation, necessitates an iterative approach in which line finder, continuum\nsubtractor, and FWHM estimator are called several times in turn in order to\nobtain a stable and trustworthy FWHM. This iterative procedure is terminated if\nconvergence is reached for the mean FWHM. The convergence criterion is\nprovided by the parameter {\\sc ltol} (see Section~\\ref{sec:params}).\n\nFor instruments like X-Shooter, whose spectra show a roughly linear increase of\nthe FWHM with wavelength, this can be considered by the setting the parameter\n{\\sc varfwhm} to 1. In this case, the FWHM estimates of the individual lines\nare converted to correspond to the FWHM, which would be measured at the\ncentral wavelength of the full spectrum, assuming a linear change of the\nFWHM with wavelength. The converted FWHM are then used to calculate the mean\nFWHM as discussed above. The linear change of the FWHM is also considered for\nthe separation of lines and continuum (see Section~\\ref{sec:linesearch}) and\nthe calculation of the pixel contributions of the different line groups\n(see Section~\\ref{sec:linefit}).\n\n%-------------------------------------------------------------------------------\n\\subsection{Continuum subtraction}\\label{sec:contsub}\n%-------------------------------------------------------------------------------\n\\begin{figure}\n\\centering\n\\includegraphics[width=12cm,clip=true]{figures/smd2_logcomp.pdf}\n\\caption[]{Components of the SM-01 sky model for wavelengths between $0.3$ and\n6\\,$\\mu$m in logarithmic flux units. The example with Moon above the horizon\nshows the scattered moonlight, scattered starlight, zodiacal light, thermal\nemission by telescope and instrument, molecular emission of the lower\natmosphere, airglow emission lines of the upper atmosphere, and\nairglow/residual continuum.}\n\\label{fig:logcomp}\n\\end{figure}\n\nThe adaptation of the reference sky line spectrum to the airglow lines in the\ninput science spectrum by multiplying factors to physically motivated line\ngroups (see Section~\\ref{sec:airglow}) requires that any kind of continuum is\nsubtracted before this procedure. In particular, the object continuum can cause\nproblems, since it is not present in the reference sky spectrum. However, sky\nspectra also show continuum emission. The main components are scattered\nmoonlight, scattered starlight, zodiacal light, thermal emission from the lower\natmosphere by greenhouse gases and the telescope itself, and airglow continuum\nemission, which is related most probably to chemiluminescent reactions in the\nupper atmosphere involving nitric oxide (see Section~\\ref{sec:airglow}, Noll et\nal.~\\cite{NOL12}, and Khomich et al.~\\cite{KHO08} and references therein). As\nFigure~\\ref{fig:logcomp} indicates, the main continuum component is the\nairglow/residual continuum\\footnote{Note that this component is very difficult\nto determine. Its measured intensity strongly depends on the accuracy of the\nother components, the quality of the flux calibration, and possible\ninstrumental continua. For this reason, it should also been seen as residual\ncontinuum.}, which dominates shortwards of the thermal regime with the\nexception of the UV and optical if the Moon is up. The variable airglow\ncontinuum (see Figure~\\ref{fig:illfeatvar}) cannot be corrected by a fitting\nprocedure like for the airglow lines (see Section~\\ref{sec:airglow}), since\nobject and sky continuum cannot be separated in the science spectrum (cf.\nSection~\\ref{sec:davies}). Therefore, it has to be assumed that the sky\ncontinuum in the science spectrum does not differ much from the one in the\nreference sky spectrum. If this requirement is fulfilled, a simple subtraction\nof the continua in both input spectra of the sky correction procedure should\nprovide results with good quality.\n\nSKYCORR obtains the continua in the input science and sky spectra using line\nidentification flags (see Figure~\\ref{fig:lineflags}) set in the course of the\nline search described in Section~\\ref{sec:linesearch}. All pixels not flagged\nas line pixels are connected by linear interpolation. Thorough identification\nof continuum pixels guaranteed, this is the most efficient approach even in the\ncase of line blends covering wide wavelength ranges.\n\n%-------------------------------------------------------------------------------\n\\subsection{Airglow model}\\label{sec:airglow}\n%-------------------------------------------------------------------------------\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]{figures/varclasses.eps}\n\\caption[]{Variability classes for sky emission lines. The following groups are\ndefined: green O\\,I, Na\\,I\\,D, red O\\,I, OH, and O$_2$. The weak lines (green\ncurves) are scaled by a factor of 30 for Na\\,I\\,D, red O\\,I, and O$_2$, and a\nfactor of 10 for OH.}\n\\label{fig:varclasses}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[height=\\textwidth,angle=-90,clip=true]\n{figures/scd_illfeatvar.pdf}\n\\caption[]{Variability correction for the five sky line classes and the\nairglow continuum of the sky model. The variability is shown as a function of\nthe bimonthly period (1 = Dec/Jan, ..., 6 = Oct/Nov), time bin (third of the\nnight), and the solar activity measured by the solar radio flux\n(sfu~$= 0.01$\\,MJy).}\n\\label{fig:illfeatvar}\n\\end{figure}\n\n\\begin{table}\n\\caption[]{Description of A groups in the input line list}\n\\label{tab:Agroups}\n\\centering\n\\footnotesize\n\\vspace{5pt}\n\\begin{tabular}{c c c l}\n\\hline\\hline\n\\noalign{\\smallskip}\nID & $N_\\mathrm{lin}$ & Wavelength range [\\mum] & Description \\\\\n\\noalign{\\smallskip}\n\\hline\n\\noalign{\\smallskip}\n 1 &  61 & 0.314 - 0.872 & green O\\,I at 0.5577\\,$\\mu$m + unidentified lines \\\\\n 2 &   3 & 0.589 - 0.770 & Na\\,I\\,D + other lines from alkali metals \\\\\n 3 &  23 & 0.389 - 0.845 & red O\\,I at 0.6300\\,$\\mu$m + other thermospheric\n                           lines \\\\\n 4 &   1 & 0.467 - 0.467 & OH(7-0) \\\\\n 5 &   8 & 0.491 - 0.495 & OH(8-1) \\\\\n 6 &  22 & 0.519 - 0.536 & OH(9-2) \\\\\n 7 &  12 & 0.526 - 0.535 & OH(6-0) \\\\\n 8 &  23 & 0.554 - 0.570 & OH(7-1) \\\\\n 9 &  41 & 0.587 - 0.634 & OH(8-2) \\\\\n10 &  49 & 0.624 - 0.655 & OH(9-3) \\\\\n11 &   2 & 0.672 - 0.674 & OH(10-4) \\\\\n12 &  27 & 0.614 - 0.695 & OH(5-0) \\\\\n13 &  83 & 0.647 - 0.754 & OH(6-1) \\\\\n14 & 113 & 0.681 - 0.782 & OH(7-2) \\\\\n15 & 111 & 0.720 - 0.815 & OH(8-3) \\\\\n16 &  72 & 0.768 - 0.822 & OH(9-4) \\\\\n17 &   7 & 0.827 - 0.839 & OH(10-5) \\\\\n18 &  85 & 0.745 - 0.910 & OH(4-0) \\\\\n19 & 113 & 0.781 - 0.914 & OH(5-1) \\\\\n20 & 111 & 0.826 - 0.916 & OH(6-2) \\\\\n21 & 110 & 0.873 - 0.937 & OH(7-3) \\\\\n22 & 116 & 0.931 - 1.007 & OH(8-4) \\\\\n23 & 120 & 0.994 - 1.081 & OH(9-5) \\\\\n24 & 100 & 0.965 - 1.043 & OH(3-0) \\\\\n25 & 110 & 1.015 - 1.098 & OH(4-1) \\\\\n26 & 112 & 1.069 - 1.168 & OH(5-2) \\\\\n27 & 118 & 1.129 - 1.236 & OH(6-3) \\\\\n28 & 120 & 1.197 - 1.314 & OH(7-4) \\\\\n29 & 124 & 1.275 - 1.420 & OH(8-5) \\\\\n30 & 128 & 1.366 - 1.531 & OH(9-6) \\\\\n31 & 112 & 1.392 - 1.558 & OH(2-0) \\\\\n32 & 118 & 1.461 - 1.654 & OH(3-1) \\\\\n33 & 122 & 1.537 - 1.743 & OH(4-2) \\\\\n34 & 122 & 1.622 - 1.842 & OH(5-3) \\\\\n35 & 124 & 1.717 - 1.978 & OH(6-4) \\\\\n36 & 126 & 1.825 - 2.110 & OH(7-5) \\\\\n37 & 130 & 1.951 - 2.265 & OH(8-6) \\\\\n38 & 130 & 2.101 - 2.454 & OH(9-7) \\\\\n39 & 450 & 0.314 - 0.532 & O$_2$(A-X) (Herzberg I) \\\\\n40 &   5 & 0.324 - 0.410 & O$_2$(c-X) (Herzberg II) \\\\\n41 & 396 & 0.326 - 0.550 & O$_2$(A'-a) (Chamberlain) \\\\\n42 &  65 & 0.382 - 0.509 & O$_2$(c-b) \\\\\n43 & 208 & 0.656 - 0.806 & O$_2$(b-X) (v' > v'') \\\\\n44 & 194 & 0.761 - 0.816 & O$_2$(b-X) (v' = v'') \\\\\n45 & 103 & 0.861 - 0.922 & O$_2$(b-X) (v' < v''; atmospheric 0-1 band\n                           inclusive) \\\\\n46 & 161 & 1.240 - 1.305 & O$_2$(a-X)(0-0) (IR atmospheric system) \\\\\n47 &  73 & 1.555 - 1.598 & O$_2$(a-X)(0-1) (IR atmospheric system) \\\\\n\\noalign{\\smallskip}\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}\n\\caption[]{Description of B groups in the input line list}\n\\label{tab:Bgroups}\n\\centering\n\\footnotesize\n\\vspace{5pt}\n\\begin{tabular}{c c l l}\n\\hline\\hline\n\\noalign{\\smallskip}\nID & Molecule & Upper state(s) & Remarks$^\\mathrm{a}$ \\\\\n\\noalign{\\smallskip}\n\\hline\n\\noalign{\\smallskip}\n 1 & OH & $X^2\\Pi_{1/2}$, $J' = 1/2$  & Q2(0.5), P2(1.5) \\\\\n 2 & OH & $X^2\\Pi_{3/2}$, $J' = 3/2$  & Q1(1.5), P1(2.5) \\\\\n 3 & OH & $X^2\\Pi_{1/2}$, $J' = 3/2$  & R2(0.5), Q2(1.5), P2(2.5) \\\\\n 4 & OH & $X^2\\Pi_{3/2}$, $J' = 5/2$  & R1(1.5), Q1(2.5), P1(3.5) \\\\\n 5 & OH & $X^2\\Pi_{1/2}$, $J' = 5/2$  & R2(1.5), Q2(2.5), P2(3.5) \\\\\n 6 & OH & $X^2\\Pi_{3/2}$, $J' = 7/2$  & R1(2.5), Q1(3.5), P1(4.5) \\\\\n 7 & OH & $X^2\\Pi_{1/2}$, $J' = 7/2$  & R2(2.5), Q2(3.5), P2(4.5) \\\\\n 8 & OH & $X^2\\Pi_{3/2}$, $J' = 9/2$  & R1(3.5), Q1(4.5), P1(5.5) \\\\\n 9 & OH & $X^2\\Pi_{1/2}$, $J' = 9/2$  & R2(3.5), Q2(4.5), P2(5.5) \\\\\n10 & OH & $X^2\\Pi_{3/2}$, $J' = 11/2$ & R1(4.5), Q1(5.5), P1(6.5) \\\\\n11 & O$_2$ & $b^1\\Sigma^+_g$, $J' = 0, 2, 4$ & \\\\\n12 & O$_2$ & $b^1\\Sigma^+_g$, $J' = 6, 8$ & \\\\\n13 & O$_2$ & $b^1\\Sigma^+_g$, $J' = 10, 12$ & \\\\\n14 & O$_2$ & $b^1\\Sigma^+_g$, $J' = 14, 16$ & \\\\\n15 & O$_2$ & $a^1\\Delta_g$, $J' = 2, 4$ & $v'' = 0$ \\\\\n16 & O$_2$ & $a^1\\Delta_g$, $J' = 6, 8$ & $v'' = 0$ \\\\\n17 & O$_2$ & $a^1\\Delta_g$, $J' = 10, 12$ & $v'' = 0$ \\\\\n18 & O$_2$ & $a^1\\Delta_g$, $J' = 14, 16$ & $v'' = 0$ \\\\\n19 & O$_2$ & $a^1\\Delta_g$, $J' = 18, 20$ & $v'' = 0$ \\\\\n20 & O$_2$ & $a^1\\Delta_g$, $J' = 20, 22$ & $v'' = 0$ \\\\\n21 & O$_2$ & $a^1\\Delta_g$, $J' = 2, 4$ & $v'' \\ne 0$ \\\\\n22 & O$_2$ & $a^1\\Delta_g$, $J' = 6, 8$ & $v'' \\ne 0$ \\\\\n23 & O$_2$ & $a^1\\Delta_g$, $J' = 10, 12$ & $v'' \\ne 0$ \\\\\n24 & O$_2$ & $a^1\\Delta_g$, $J' = 14, 16$ & $v'' \\ne 0$ \\\\\n\\noalign{\\smallskip}\n\\hline\n\\end{tabular}\n\\footnotesize\n\\begin{list}{}{}\n\\item[$^\\mathrm{a}$] OH rotational transitions or lower vibrational level for\nO$_2$(a-X) transitions\n\\end{list}\n\\end{table}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_plotohbands_opt.pdf}\n\\caption[]{A group identifications of OH bands (cf. Table~\\ref{tab:Agroups}) in\nthe wavelength range between 0.54 and 1.02\\,\\mum{} that have Q1(1.5) lines\n(see Table~\\ref{tab:Bgroups} and Figure~\\ref{fig:ohband}) stronger than\n0.01\\,$\\gamma\\,{\\rm s}^{-1}\\,{\\rm m}^{-2}\\,{\\rm arcsec}^{-2}$. The wavelengths and\nzenithal mean fluxes (considering absorption in the lower atmosphere) tabulated\nin the input line list are plotted. Note that the bands with numbers up to 21\nappear twice as strong as the bands at longer wavelengths, since the\ncorresponding lines were taken from the Hanuschik \\cite{HAN03} atlas, where OH\ndoublets are often unresolved and are listed as one line only.}\n\\label{fig:ohbands_opt}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_plotohbands_ir.pdf}\n\\caption[]{A group identifications of the OH bands (cf.\nTable~\\ref{tab:Agroups}) in the wavelength range between 0.95 and 2.05\\,\\mum{}.\nThe wavelengths and zenithal mean fluxes tabulated in the input line list are\nplotted.}\n\\label{fig:ohbands_ir}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_plotohband.pdf}\n\\caption[]{B group identifications of the transitions of an OH band with the\nsame rotational upper state (cf. Table~\\ref{tab:Bgroups}). The tabulated\nwavelengths and zenithal mean fluxes of the lines of the OH(6-4) band are shown\nas example. Dashed and solid lines indicate transitions of the $X^2\\Pi_{1/2}$ and\n$X^2\\Pi_{3/2}$ state, respectively. The figure also indicates the R-, Q-, and\nP-branches that correspond to transitions with a change of the total angular\nmomentum by -1, 0, and 1, respectively.}\n\\label{fig:ohband}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_ploto2b01band.pdf}\n\\caption[]{B group identifications of the transitions of the band\nO$_2$(b-X)(0-1) with a similar rotational upper state (cf.\nTable~\\ref{tab:Bgroups}). The tabulated wavelengths and zenithal mean fluxes of\nthe lines of the 4 different branches (2 R- and 2 P-branches) are shown (cf.\nFigure~\\ref{fig:ohband}).}\n\\label{fig:o2b01band}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_ploto2a00band.pdf}\n\\caption[]{B group identifications of the transitions of the band\nO$_2$(a-X)(0-0) with a similar rotational upper state (cf.\nTable~\\ref{tab:Bgroups}). The tabulated wavelengths and zenithal mean fluxes of\nthe lines of the 9 different branches (3 R-, 3 Q-, and 3 P-branches) are shown\n(cf. Figure~\\ref{fig:ohband}). The band is strongly affected by self\nabsorption in the lower atmosphere.}\n\\label{fig:o2a00band}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,clip=true]\n{figures/scd_ploto2a01band.pdf}\n\\caption[]{B group identifications of the transitions of the band\nO$_2$(a-X)(0-1) with a similar rotational upper state (cf.\nTable~\\ref{tab:Bgroups}). The tabulated wavelengths and zenithal mean fluxes of\nthe lines of the 9 different branches (3 R-, 3 Q-, and 3 P-branches) are shown\n(cf. Figure~\\ref{fig:ohband}).}\n\\label{fig:o2a01band}\n\\end{figure}\n\nThe wavelength range from the near-UV to the near-IR is characterised by strong\nemission lines. Most of them constitute band structures. This airglow (see\nKhomich et al.~\\cite{KHO08} for a comprehensive discussion) mostly originates\nin the mesopause region at about 90\\,km. In addition, some lines arise in the\nionospheric F2-layer at about 270\\,km. In general, airglow is caused by\nchemiluminescence, \\ie\\ chemical reactions that lead to light emission by the\ndecay of excited electronic states of reaction products. Apart from atomic\noxygen and sodium, the oxygen (O$_2$) and hydroxyl (OH) molecules are the most\nimportant reaction products in this context. In general, airglow lines show\nstrong variability from time scales in the order of minutes to years. This\nbehaviour can be explained by the solar activity cycle, seasonal changes in\ntemperature, pressure, and chemical composition of the emission layers, the\nday-night contrast, dynamical effects such as gravity waves, or geomagnetic\ndisturbances.\n\nThe SKYCORR project aims at correcting airglow emission in science spectra by\nmeans of reference sky spectra taken at a different time. As the airglow is\nhighly variable, the strength of the emission lines in a reference spectrum has\nto be adapted, though. This is achieved by a fitting procedure that is\ndiscussed in Section~\\ref{sec:linefit}. Since emission lines belonging to the\nscience target should not be reproduced by the optimised sky spectrum and\nfinally removed, it is advisable to adapt as many lines as possible by a\nsingle fitting parameter. Every group should contain airglow lines that are not\naffected by object lines and that can be used to determine a realistic\ncorrection factor for the reference sky spectrum. The number of lines that can\nbe combined is limited by the fact that they should show an almost identical\nvariability behaviour.\n\nAs basis for the definition of suitable line groups, the airglow line model\ndeveloped in the course of the SM-01 project for an advanced sky background\nmodel for \\ac{ESO} exposure time calculators was used (see \\cite{SM01} User\nManual; Noll et al.~\\cite{NOL12}). This semi-empirical model consists of a line\nlist with line intensities for mean observing conditions and prescriptions for\nthe correction of the line strength depending on molecular species, solar\nactivity, season, night time, and zenith distance of the target. The latter\nthree input parameters can be retrieved from the \\ac{FITS} header of the sky\nspectrum file. The solar activity is provided as solar radio flux at 10.7\\,cm\neither directly by {\\sc solflux} in the parameter file or by the corresponding\nmonthly average (default) in a file offered by {\\tt www.spaceweather.gc.ca}\n(see Section~\\ref{sec:params}). In the wavelength range from $0.3143$ to\n$0.9228$\\,\\mum{}, the line list consists of data taken from Cosby et\nal.~\\cite{COS06} (supplemented by unpublished UVES 800U data) who incorporated\nthe UVES-based sky emission line atlas of Hanuschik \\cite{HAN03}. At longer\nwavelengths the calculated OH lines of Rousselot et al.~\\cite{ROU00} were\nincluded. However, their line strengths were corrected for the Einstein factors\nof Goldman et al.~\\cite{GOL98} instead of using the original, outdated ones of\nMies~\\cite{MIE74}. This resulted in correction factors for OH band strengths\nbetween 0.38 and 2.06. Moreover, the flux decrease of airglow lines by\nmolecular absorption in the lower atmosphere was corrected by the\nmultiplication of the airglow line spectrum with Doppler line widths for\ntypical temperatures of about 200\\,K by the high-resolution\n($\\lambda / \\Delta\\lambda \\approx 10^6$) Paranal annual-mean transmission\ncurve for an airmass of 1.25\\footnote{Although the atmospheric\ntransmission depends on airmass and weather conditions, only a fixed airglow\nflux correction was applied in order to avoid time-consuming calculations at\nvery high resolution and the input of temperature and water vapour profiles.\nMoreover, the optical airglow atlas of Hanuschik \\cite{HAN03} is also\ncharacterised by a fixed transmission correction due to the use of UVES mean\nspectra. For most observing conditions, the deviation of the true airglow\nabsorption from the assumed one is expected to be minor in terms of the results\nof SKYCORR.} (see Noll et al. \\cite{NOL12}). The transmission curve was\ncomputed by means of the radiative transfer code LBLRTM (see Clough et al.\n\\cite{CLO05} and \\cite{LBLRTM}). Note that SKYCORR applies the Paranal mean\ntransmission curve for zenith (corrected for the target airmass) to the\nunextincted fluxes in the input line list. For this purpose, the line list\ncontains separate columns for unextincted line fluxes and zenithal transmission\nvalues. Finally, the Rousselot et al.~lines were scaled to the Cosby et\nal.~lines between $0.642$ and $0.858$\\,\\mum{}. The strongest O$_2$ bands in the\nnear-IR at $1.27$ and $1.58$\\,\\mum{} were included in the line list by adding\ndata from the HITRAN database (see Rothman et al.~\\cite{ROT09} and\n\\cite{HITRAN}). The mean band strength was roughly estimated evaluating the\nratio of O$_2$ to OH lines in 26 IR X-Shooter spectra. For this purpose, the\nO$_2$ lines had to be extincted depending on the airmass values of the\nX-Shooter spectra. In the case of the $1.27$\\,\\mum{} band, this caused\nsignificant changes in the line fluxes due to the strong resonant absorption of\nairglow photons by tropospheric/stratospheric O$_2$ molecules in the ground\nstate.\n\nThe SM-01 sky model assigns the listed lines to five different variability\nclasses (see Figure~\\ref{fig:varclasses}). These variability classes result\nfrom analysing a sample of 1189 optical FORS spectra (Patat~\\cite{PAT08}). From\nthis sample, the lines' dependence on solar radio flux and time of observation\n(see Figure~\\ref{fig:illfeatvar}) was derived. The latter was quantified using\na grid of six double month periods starting with Dec/Jan and three night time\nbins of equal length. The reference line strengths in the line list represent\nthe mean of the five solar activity cycles 19 to 23, \\ie\\ the years 1954 to\n2007.\n\nAssigning airglow lines to the classes (1) green O\\,I, (2) Na\\,I\\,D,\n(3) red O\\,I, (4) OH, and (5) O$_2$ using the rough predictions from the sky\nmodel is not sufficient for achieving a line intensity accuracy on the percent\nlevel and better, which is required for a sky subtraction procedure like\nSKYCORR. Typically, intensity variations of lines within a variability class\nare larger. The ratios of line strengths of different variability classes vary\nby a factor of two or even more.\n\nIn principle, an identical variability behaviour can be expected for\ntransitions with the same upper energy level. In this case, the ratios of line\nintensities should be fixed and only determined by quantities such as Einstein\ncoefficients and statistical weights. On the other hand, the excitation and\npopulation of different energy levels depends on variable quantities such as\ntemperature, pressure, and chemical abundances. Therefore, it is a promising\nansatz to define line groups depending on the upper energy level. However,\ntaking all relevant energy levels of the molecules OH and O$_2$ into account\nwould result in a very large number of line groups. Moreover, each group would\nconsist of only a few significant lines. This would result in statistical\nfluctuations, which could make the line intensity correction uncertain if\ncrucial lines of a group were affected by, \\eg, CCD defects or object emission\nlines (see Section~\\ref{sec:linefit}). Fortunately, as their energies are\nrather different, it is possible to separate electronic, vibrational, and\nrotational transitions of molecules. The electronic/vibrational transition\ndetermines the band and the rotational transition identifies a single line or\ndoublet (as in case of OH) within a band. Since the distribution of energy\nlevels is very similar for all bands of an electronic transition, each line can\nbe assigned to two different classes that are defined by the upper vibrational\nand rotational state. This approach reduces the number of required line groups\nsignificantly. Moreover, for OH only the electronic ground state is relevant,\nwhich splits up into the sub-levels $X^2\\Pi_{1/2}$ and $X^2\\Pi_{3/2}$ due to the\ncoupling of spin and orbital angular momentum (see Rousselot et\nal.~\\cite{ROU00}). For O$_2$, the electronic transitions are more important\nthan the vibrational ones, since the intensity differences of the bands of an\nelectronic transition are very large. Consequently, there are only three O$_2$\nbands that significantly contribute to the airglow, namely\nO$_2$(b-X)(0-1)\\footnote{The notation used is as follows: molecule (upper -\nlower electronic state) (upper - lower vibrational state). The letters `a',\n`b', and 'X' are shortcuts for the states  $a^1\\Delta_g$, $b^1\\Sigma^+_g$, and\n$X^3\\Sigma^-_g$. The vibrational states are numbered depending on the energy\nand starting from 0 for the lowest level.} (the very strong (0-0) band is\nalmost completely absorbed in the lower atmosphere), O$_2$(a-X)(0-0), and\nO$_2$(a-X)(0-1).\n\nTables~\\ref{tab:Agroups} and \\ref{tab:Bgroups} list the final grouping of\nairglow lines. Line groups with the same upper electronic/vibrational level are\ncalled ``A groups'' and those with the same (OH) or a similar (O$_2$) upper\nrotational level are labelled as ``B groups''. Most OH bands (apart from a\nfew very weak ones) are identified in the Figures~\\ref{fig:ohbands_opt} and\n\\ref{fig:ohbands_ir}. Although bands such as OH(4-1) and OH(4-2) have the same\nupper vibrational level, they represent independent variability groups.\nAlthough significantly increasing the number of A groups, the fact that real\ndata suffer from calibration uncertainties, makes this procedure a necessity.\nAs OH bands with the same upper vibrational level are widely separated, it is\ntherefore safer to vary such bands independently. Figures~\\ref{fig:ohband},\n\\ref{fig:o2b01band}, \\ref{fig:o2a00band}, and \\ref{fig:o2a01band} show\nidentifications of the rotational B groups for an example OH band,\nO$_2$(b-X)(0-1), O$_2$(a-X)(0-0), and O$_2$(a-X)(0-1), respectively. Although\nthe two O$_2$(a-X) bands belong to the same roto-vibrational system, their\nB groups were defined separately due to the completely different line flux\ndistribution which is caused by self absorption in the (0-0) band. B groups of\nO$_2$ bands consist of lines from two rotational upper levels in order to\nmake sure that enough lines can be identified for the group scaling (see\nSection~\\ref{sec:linefit}). The weak lines of each band are not included in a B\ngroup as they are difficult to fit. Furthermore, this measure avoids a\ndegeneration of fit parameters.\n\nThe described grouping is reminiscent of the approach of Davies~\\cite{DAV07}.\nHowever, it is much more complex, since Davies only incorporates near-IR OH\nbands, O$_2$(a-X)(0-0), and two rotational groups resembling our B\\,2 and B\\,4\nclasses (see Table~\\ref{tab:Bgroups}).\n\n%-------------------------------------------------------------------------------\n\\subsection{Airglow line fitter}\\label{sec:linefit}\n%-------------------------------------------------------------------------------\nTo prepare a reference sky line spectrum taken at a different time than the\ncorresponding science spectrum for a background subtraction, this reference\nspectrum has to be adapted. To this end, Davies~\\cite{DAV07} sub-divides the\nwavelength range into sections depending on the OH band structure and\nsubsequently scales these sections independently according to the sections'\nflux ratio of science and sky spectra. Problematic are cases where different\nline groups have significant overlap. While the OH bands covered in SINFONI\n$H$-band spectra exhibit only little overlap and no significant band of other\nmolecules are present, at lower wavelengths the situation is less favourable\n(see Section~\\ref{sec:airglow}). Even so, measuring the scaling factors for\ngroups with the same upper rotational level is difficult. Here, the flux of\nindividual lines has to be derived, which requires that the selected lines are\nisolated. Typically, this is not the case for Q transitions, which are\ncharacterised by a constant total angular momentum (see\nFigure~\\ref{fig:ohband}). Furthermore, the separation of variability groups\nbecomes even more difficult if the spectral resolution is relatively low as in\nthe case of the FORS spectra shown in Figure~\\ref{fig:varclasses}.\n\nTo overcome these limitations, the SKYCORR project pursues a completely\ndifferent approach to obtaining the scaling factors for the different line\ngroups defined in Section~\\ref{sec:airglow}. In SKYCORR, the contributions of\nthe line groups to each pixel of the sky spectrum are estimated. Subsequently,\nthe resulting spectra for each line class ($\\le 100$\\% of the total sky flux)\nare scaled.\n\nThis is performed applying the airglow model presented in the previous section.\nThe wavelengths and intensities of the lines and their group identifications\ncan be converted into intensities of the different line groups for each pixel.\nThis requires a convolution of the lines from the line list with a kernel\nsimilar to the instrumental profile of the observed spectra. The mean FWHM of\nthe sky lines, which was obtained in a previous step (see\nSection~\\ref{sec:FWHM}), is used for creating a sufficently realistic Gaussian\nkernel. In order to treat intensity ratios of overlapping lines as\nrealistically as possible, the airglow variability model from Noll et\nal.~\\cite{NOL12} (see Section~\\ref{sec:airglow}) was included. This allows one\nto rougly correct for the influence of solar activity, season, and night time\non the main line variability classes green O\\,I, Na\\,I\\,D, red O\\,I, OH, and\nO$_2$.\n\nDifferent line groups contributing to the same pixel implies that the sky\nscaling factors cannot be derived by a simple division of line fluxes of\nscience and sky spectrum anymore. Instead, each scaling factor of the\nindividual line groups has to be included in a fitting procedure as a free\nfitting parameter. For this purpose, the C library MPFIT by\nC.~Markwardt~\\cite{CMPFIT} (see Section~\\ref{sec:FWHM}) was used. The $\\chi^2$\nminimisation procedure of this routine is based on a Levenberg-Marquardt\ntechnique (see Mor\\'e et al. \\cite{MOR80}), an iterative search algorithm\ncharacterised by gradient-controlled jumps in parameter space. Since this\ntechnique is potentially prone to finding local minima, reasonable starting\nvalues and constraints for the fit parameters are required. For this reason,\nthe mean ratios of the line peaks in the science and sky spectrum are\ncalculated for each line group (see Section~\\ref{sec:airglow}). Only those\nspectrum pixels are included that were identified as line peak (see\nSection~\\ref{sec:linesearch}) or are separated from a peak by not more than\nhalf a line FWHM (see Section~\\ref{sec:FWHM}) and have a relative contribution\nof the selected line group of at least {\\sc weightlim} (default: 0.67; see\nSection~\\ref{sec:params}). Moreover, pixels with unreasonable flux ratios are\nrejected by applying a global $\\sigma$ limit that is derived from the full\nset of line peaks and is provided by the parameter {\\sc siglim} (default: 15;\nsee Section~\\ref{sec:params}). In this way, strong object emission lines can be\nidentified in the science line spectrum and excluded. Finally, the\n$\\sigma$-clipping approach with variable $\\sigma$ limit described in\nSection~\\ref{sec:FWHM} is applied to the selected pixels of each group\nseparately in order to further improve the pixel selection. The remaining\npixels of this procedure are taken for the initial line group scaling {\\em and}\nfitting algorithm, \\ie\\ only those pixels are considered for the $\\chi^2$\ncalculation. If suitable pixels cannot be found for a line group, a mean\nflux ratio of the corresponding system of electronic transitions (\\eg\\ OH; see\nSection~\\ref{sec:airglow}) or a global flux ratio is taken for A groups and a\nvalue of 1 is assumed for B groups. For most sky spectra this approach should\nresult in a good first guess sufficient for achieving rapid convergence to the\nglobal minimum (see Section~\\ref{sec:evaluation}).\n\nAs an option the fitting can be restricted to uncertain line groups only. The\ndecision on the group selection depends on the parameter {\\sc fitlim} (see\nSection~\\ref{sec:params}) which provides a limiting ratio of the RMS and\nthe mean of the group-specific scaling factors. By default this value is set\nto 0, \\ie\\ all fittable line groups are considered.\n\n%-------------------------------------------------------------------------------\n\\subsection{Correction of wavelength grid}\\label{sec:wavegrid}\n%-------------------------------------------------------------------------------\n\nSince the sky lines of the science spectrum are removed by a scaled reference\nsky line spectrum, it is imperative that the wavelength grids of both spectra\nare aligned. Differences of less than a pixel can already significantly\ndeteriorate the quality of the sky subtraction. Relatively large deviations can\noccur if a lamp spectrum taken in daytime at different ambient conditions than\nthe science spectrum is used for the wavelength calibration. However, even\nsubpixel shifts that are routinely observed in data taken under perfect\nconditions can cause problems.\n\nFor this reason, SKYCORR offers optional correction of the wavelength grid by\napplying a Chebyshev polynomial of degree\n$n_\\mathrm{w}$\n\\begin{equation}\n\\lambda' = \\sum_{i = 0}^{n_\\mathrm{w}} c_i t_i,\n\\end{equation}\nwhere\n\\begin{equation}\nt_i = \\left\\{ \\begin{array}{ll}\n1 & \\textrm{for\\ } i = 0 \\\\\n\\lambda & \\textrm{for\\ } i = 1 \\\\\n2 \\, \\lambda \\, t_{i-1} - t_{i-2} & \\textrm{for\\ } i \\ge 2\n\\end{array} \\right.\n\\end{equation}\nand $\\lambda$ ranging from -1 to 1. The temporary conversion of the wavelength\ngrid to a fixed interval results in coefficients $c_i$ independent of the\nwavelength range and step size of the input spectrum. The wavelength solution\nis not changed if $c_1 = 1$ and $c_i = 0$ for all other $i$. It is possible\nto set an individual start value for the constant term $c_0$ via the parameter\n{\\sc cheby\\_const} (see Section~\\ref{sec:params}). In this way, significant\npossible shifts between the wavelength grids of the science and the sky\nspectrum can be considered.\n\nThe coefficients $c_i$ are determined by an iterative procedure. This process\nis initialised with two subsequent estimates (for a better $\\sigma$-clipping)\nand a fit of the line flux correction factors (see Section~\\ref{sec:linefit}).\nDuring this first iteration the wavelength grid remains untouched. In the next\nstep, the coefficients $c_0$ and $c_1$ are fitted using MPFIT. Now, a new\nestimate is calculated and the line flux correction factors are fitted again.\nThen the next iteration starts by fitting the wavelength grid, now applying a\nChebyshev polynomial of degree 2. After that, the line scaling factors are\nadapted again in order to incorporate the change of the wavelength grid. Each\niteration increases $n_\\mathrm{w}$ by 1 and uses the results of the\nprevious iteration as input. The search for the best polynomial degree is\ncontrolled by the three input parameters {\\sc cheby\\_min}, {\\sc cheby\\_max},\nand {\\sc wtol} (see Section~\\ref{sec:params}). The iteration process is stopped\nonce the maximum polynomial degree given by {\\sc cheby\\_max} is reached. For a\nvalue of -1, no wavelength grid correction is performed. The parameter\n{\\sc cheby\\_min} indicates the minimum degree, \\ie\\ the minimum number of\niterations. For $n_\\mathrm{w}$ not less than {\\sc cheby\\_min}, the code checks\nwhether the resulting $\\chi^2$ shows a relative $\\chi^2$ improvement of at\nleast {\\sc wtol} (default: $1 \\times 10^{-3}$) compared to the best $\\chi^2$, so\nfar. If this is not the case the procedure stops and the results for the\npolynomial with the lowest $\\chi^2$ are taken. An exception is a choice of\n{\\sc cheby\\_min}~>~{\\sc cheby\\_max}. In this case, the code runs until\n{\\sc cheby\\_max} is reached and the corresponding results for this degree are\ntaken, regardless of the results for the lower polynomial degrees. The default\nvalues for {\\sc cheby\\_max} and {\\sc cheby\\_min} are 7 and 3, respectively.\n\nIndependent of the use of a Chebyshev polynomial, the modified sky spectrum has\nto be rebinned to the wavelength grid of the science spectrum. For this task,\nthe code offers two options, which can be selected by the parameter\n{\\sc rebintype} (see Section~\\ref{sec:params}). The first method adds up the\nfractional fluxes of input pixels contributing to the wavelength range of the\noutput pixel. The second approach is based on the convolution of the input\nspectrum with a pixel-dependent asymmetric damped sinc kernel\n\\begin{equation}\nf(k) = e^{-((k - s) / \\delta)^2} \\, \\frac{\\sin(\\pi (k - s))}{\\pi (k - s)},\n\\end{equation}\nwith $k$ being an integer variable ranging from $-k_\\mathrm{max}$ to\n$k_\\mathrm{max}$. The damping constant $\\delta$ and the kernel radius\n$k_\\mathrm{max}$ are fixed and have the values 3.25 and 5. The parameter $s$ is\nthe subpixel shift of the sky spectrum relative to the science spectrum. It is\na function of the pixel position and ranges from $-0.5$ to $0.5$. For shifts\nabove half a pixel, complete pixels are treated by a simple renumbering of the\ninput pixels in the output spectrum. No convolution is performed for this\ninteger part of the pixel shift. The approach is similar to the one used in the\nIDL routine ``sshift2d.pro'' of the Lowell Buie Library \\cite{SINC}. However,\nthe original programme is for a constant shift of the entire spectrum only. A\nwavelength-dependent shift is not a problem as long as the amount of the shift\nchanges slowly with the spectrum pixels and the pixel size is nearly constant\nfor the whole input and output wavelength grids. These requirements are\nsufficiently met if inconsistencies of the wavelength grids are in the order of\n1\\,pixel and if the functional dependence of differences can be described by a\nlow order polynomial. The relatively complicate rebinning method described\nabove is able to effectively suppress broadening of spectral lines, which\ntypically occurs if a spectrum is rebinned to a shifted grid of similar pixel\nsize. The line-broadening suppression is achieved by alternating positive and\nnegative contributions to the kernel as incorporated in the sinc shift method.\nTherefore, the sinc shift method produces the best results if significant\nsubpixel shifts close to half a pixel are frequent. However, for a very good\nagreement of the wavelength grids with subpixel shifts close to zero, it might\nbe better to use the simple rebinning method. In such a case, the relatively\nbroad sinc kernel influences the spectrum more than simple regridding.\n", "meta": {"hexsha": "5036734d06146ab357b81114f1ef4e673f869be2", "size": 44862, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "skycorr/doc/SC_UM_method.tex", "max_stars_repo_name": "sdss/lvmsky", "max_stars_repo_head_hexsha": "3d612f37af71f08b1423d28a6bbe6351ca41ae0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "skycorr/doc/SC_UM_method.tex", "max_issues_repo_name": "sdss/lvmsky", "max_issues_repo_head_hexsha": "3d612f37af71f08b1423d28a6bbe6351ca41ae0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "skycorr/doc/SC_UM_method.tex", "max_forks_repo_name": "sdss/lvmsky", "max_forks_repo_head_hexsha": "3d612f37af71f08b1423d28a6bbe6351ca41ae0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.7374517375, "max_line_length": 82, "alphanum_fraction": 0.7386652401, "num_tokens": 12372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4318311316975781}}
{"text": "\\chapter{Results of simulation of the six models.}\nIn this chapter the simulation of the six models is presented. First the histograms of data, test statistics are presented for each model, and at the end the analysis is presented. All of the models have $10^6$ samples.\n%\\noindent First we begin with the study of model 1. The generated data to use are shown in figure \\ref{fig:DensPlotA10B04C2}. An example of an sample generated by our Gibbs with Metropolis-Hastings step is shown in figure \\ref{fig:SampleA10B04C2}. This sample seem to somewhat follow the rate function for model 1. Further the test statistics are used to check if the sampler generates right samples. The different test statistics are shown in figures \\ref{fig:CramerA10B04C2}, \\ref{fig:GreenwoodA10B04C2}, \\ref{fig:LaplaceA10B04C2} and \\ref{fig:KolmogovA10B04C2}. \n%By studying these figures one notices that the observed value from original data set are close to the mean for almost all of the test statistics. Furthermore the calculated p-values for the samples are shown in table \\ref{tab:model1P}. From this table we notices that all of the p-values are larger than $\\alpha$-levels of 0.05 and 0.1. Hence we can keep the hypothesis that the samples are from model 1.\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA10B04C2.png}\n\\caption{Histogram of data for model 1 given $a = 10$, $b = 0.4$ and $c = 2$.}\n\\label{fig:DensPlotA10B04C2}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA10B04C2.png}\n\\caption{Histogram of a sample for model 1.}\n\\label{fig:SampleA10B04C2}\n\\end{subfigure}\n\\caption{Data and sample from model 1.}\n\\label{fig:datasampmod1}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA10B04C2.png}{fig:DensPlotA10B04C2}{Histogram of data for model 1 given $a = 10$, $b = 0.4$ and $c = 2$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA10B04C2.png}{fig:SampleA10B04C2}{Histogram of a sample for model 1 given $a = 10$, $b = 0.4$ and $c = 2$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA10B04C2.png}{fig:CramerA10B04C2}{Histogram of a modified Cramer von Mises statistics for generated samples from model 1. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA10B04C2.png}{fig:GreenwoodA10B04C2}{Histogram of a Greenwood statistics for generated samples from model 1. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA10B04C2.png}{fig:LaplaceA10B04C2}{Histogram of a Laplace statistics for generated samples from model 1. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA10B04C2.png}{fig:KolmogorovA10B04C2}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 1. The red line is the observed test statistic value.}\n%\\begin{tab}{ccccc}{tab:model1P}{Calculated p-values from model 1.}\n%\t~\t&\tCramer\t& \tGreenwood & Laplace & Kolmogov\t\\\\\n%\t\\midrule\n\t%1\t\t&\t\t0.33\t&\t0.332 & 0.694 & 0.435\t\t\t\\\\\n%\\end{tab}\n%\\noindent Further we continue with analysis of model 2. The generated data for model 2 is shown in figure \\ref{fig:DensPlotA160B2CM3}. A sample generated from this data is shown in figure \\ref{fig:SampleA160B2CM3}. While the test statistics for this model are shown in figures \\ref{fig:CramerA160B2CM3}, \\ref{fig:GreenwoodA160B2CM3}, \\ref{fig:LaplaceA160B2CM3} and \\ref{fig:KolmogovA160B2CM3}. From these figues we see that all of the observed values for the test statistics are not extreme values. The corresponding p-values are shown i table \\ref{tab:model2P}. Since the test statistics have no extremes and the p-values are above $\\alpha-$levels $0.05$ and $0.10$ the samples must originate from the same model as the original data set, as expected.\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA160B2CM3.png}\n\\caption{Histogram of data for model 2 given $a = 160$, $b = 2$ and $c = -3$.}\n\\label{fig:DensPlotA160B2CM3}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA160B2CM3.png}\n\\caption{Histogram of a sample for model 2.}\n\\label{fig:SampleA160B2CM3}\n\\end{subfigure}\n\\caption{Data and sample from model 2.}\n\\label{fig:datasampmod2}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA160B2CM3.png}{fig:DensPlotA160B2CM3}{Histogram of data for model 2 given $a = 160$, $b = 2$ and $c = -3$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA160B2CM3.png}{fig:SampleA160B2CM3}{Histogram of a sample for model 2 given $a = 160$, $b = 2$ and $c = -3$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA160B2CM3.png}{fig:CramerA160B2CM3}{Histogram of a modified Cramer von Mises statistics for generated samples from model 2. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA160B2CM3.png}{fig:GreenwoodA160B2CM3}{Histogram of a Greenwood statistics for generated samples from model 2. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA160B2CM3.png}{fig:LaplaceA160B2CM3}{Histogram of a Laplace statistics for generated samples from model 2. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA160B2CM3.png}{fig:KolmogovA160B2CM3}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 2. The red line is the observed test statistic value.}\n\n%%\\begin{tab}{ccccc}{tab:model2P}{Calculated p-values from model 2.}\n%\t~\t&\tCramer\t& \tGreenwood & Laplace & Kolmogov\t\\\\\n%\t\\midrule\n%\t2\t\t&\t\t0.54134\t&\t0.78838 & 0.67615 & 0.56128\t\t\t\\\\\n%\\end{tab}\n%\\noindent For model 3 the generated data is shown in figure \\ref{fig:DensPlotA20B2C1}, and a sample is shown in figure \\ref{fig:SampleA20B2C1}. We see that the sample and original data follow the same structure. The test statistics for this model are shown in figures \\ref{fig:CramerA20B2C1}, \\ref{fig:GreenwoodA20B2C1}, \\ref{fig:LaplaceA20B2C1} and \\ref{fig:KolmogovA20B2C1}. The p-values for this model are listed in table \\ref{tab:model3P}.\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA20B2C1.png}\n\\caption{Histogram of data for model 3 given $a = 20$, $b = 2$ and $c = 1$.}\n\\label{fig:DensPlotA20B2C1}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA20B2C1.png}\n\\caption{Histogram of a sample for model 3.}\n\\label{fig:SampleA20B2C1}\n\\end{subfigure}\n\\caption{Data and sample from model 3.}\n\\label{fig:datasampmod3}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA20B2C1.png}{fig:DensPlotA20B2C1}{Histogram of data for model 3 given $a = 20$, $b = 2$ and $c = 1$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA20B2C1.png}{fig:SampleA20B2C1}{Histogram of a sample for model 3 given $a = 20$, $b = 2$ and $c = 1$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA20B2C1.png}{fig:CramerA20B2C1}{Histogram of a modified Cramer von Mises statistics for generated samples from model 3. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA20B2C1.png}{fig:GreenwoodA20B2C1}{Histogram of a Greenwood statistics for generated samples from model 3. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA20B2C1.png}{fig:LaplaceA20B2C1}{Histogram of a Laplace statistics for generated samples from model 3. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA20B2C1.png}{fig:KolmogovA20B2C1}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 3. The red line is the observed test statistic value.}\n%\\begin{tab}{ccccc}{tab:model3P}{Calculated p-values from model 3.}\n%\t~\t&\tCramer\t& \tGreenwood & Laplace & Kolmogov\t\\\\\n%\t\\midrule\n%\tModel 3\t\t&\t\t0.73098\t&\t0.85268 & 0.7947 & 0.32012\t\t\t\\\\\n%\\end{tab}\n%\\noindent For model 4 the generated data is shown in figure \\ref{fig:DensPlotA30B07C0}, and a sample is shown in figure \\ref{fig:SampleA30B07C0}. We see that the sample and original data follow the same structure. The test statistics for this model are shown in figures \\ref{fig:CramerA30B07C0}, \\ref{fig:GreenwoodA30B07C0}, \\ref{fig:LaplaceA30B07C0} and \\ref{fig:KolmogovA30B07C0}.\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA30B07C0.png}\n\\caption{Histogram of data for model 4 given $a = 30$, $b = 0.7$ and $c = 0$.}\n\\label{fig:DensPlotA30B07C0}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA30B07C0.png}\n\\caption{Histogram of a sample for model 4.}\n\\label{fig:SampleA30B07C0}\n\\end{subfigure}\n\\caption{Data and sample from model 4.}\n\\label{fig:datasampmod4}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA30B07C0.png}{fig:DensPlotA30B07C0}{Histogram of data for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA30B07C0.png}{fig:SampleA30B07C0}{Histogram of a sample for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA30B07C0.png}{fig:CramerA30B07C0}{Histogram of a modified Cramer von Mises statistics for generated samples from model 4. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA30B07C0.png}{fig:GreenwoodA30B07C0}{Histogram of a Greenwood statistics for generated samples from model 4. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA30B07C0.png}{fig:LaplaceA30B07C0}{Histogram of a Laplace statistics for generated samples from model 4. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA30B07C0.png}{fig:KolmogovA30B07C0}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 4. The red line is the observed test statistic value.}\n%\\begin{tab}{ccccc}{tab:model4P}{Calculated p-values from model 4.}\n%\t~\t&\tCramer\t& \tGreenwood & Laplace & Kolmogov\t\\\\\n%\t\\midrule\n%\tModel 4\t\t&\t\t0.66713\t&\t0.70516 & 0.83144 & 0.80452\t\t\t\\\\\n%\\end{tab}\n%\\noindent For model 5 the generated data is shown in figure \\ref{fig:DensPlotA50B2CM1}, and a sample is shown in figure \\ref{fig:SampleA50B2CM1}. We see that the sample and original data follow the same structure. The test statistics for this model are shown in figures \\ref{fig:CramerA50B2CM1}, \\ref{fig:GreenwoodA50B2CM1}, \\ref{fig:LaplaceA50B2CM1} and \\ref{fig:KolmogovA50B2CM1}. \n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA50B2CM1.png}\n\\caption{Histogram of data for model 5 given $a = 50$, $b = 2$ and $c = -1$.}\n\\label{fig:DensPlotA50B2CM1}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA50B2CM1.png}\n\\caption{Histogram of a sample for model 5.}\n\\label{fig:SampleA50B2CM1}\n\\end{subfigure}\n\\caption{Data and sample from model 5.}\n\\label{fig:datasampmod5}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA50B2CM1.png}{fig:DensPlotA50B2CM1}{Histogram of data for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA50B2CM1.png}{fig:SampleA50B2CM1}{Histogram of a sample for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA50B2CM1.png}{fig:CramerA50B2CM1}{Histogram of a modified Cramer von Mises statistics for generated samples from model 5. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA50B2CM1.png}{fig:GreenwoodA50B2CM1}{Histogram of a Greenwood statistics for generated samples from model 5. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA50B2CM1.png}{fig:LaplaceA50B2CM1}{Histogram of a Laplace statistics for generated samples from model 5. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA50B2CM1.png}{fig:KolmogovA50B2CM1}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 5. The red line is the observed test statistic value.}\n%\\begin{tab}{ccccc}{tab:model5P}{Calculated p-values from model 5.}\n%\t~\t&\tCramer\t& \tGreenwood & Laplace & Kolmogov\t\\\\\n%\t\\midrule\n%\tModel 5\t\t&\t\t0.6518\t&\t0.54926 & 0.85544 & 0.77968\t\t\t\\\\\n%\\end{tab}\n%\\noindent For model 6 the generated data is shown in figure \\ref{fig:DensPlotA6B3C2}, and a sample is shown in figure \\ref{fig:SampleA6B3C2}. We see that the sample and original data follow the same structure. The test statistics for this model are shown in figures \\ref{fig:CramerA6B3C2}, \\ref{fig:GreenwoodA6B3C2}, \\ref{fig:LaplaceA6B3C2} and \\ref{fig:KolmogovA6B3C2}. The p-values for this model are listed in table \\ref{tab:model6P}. Here the p-values are both high and low. However the lowest p-value is higher than the $\\alpha$-levels.\n%\\noindent For model 5 the generated data is shown in figure \\ref{fig:DensPlotA50B2CM1}, and a sample is shown in figure \\ref{fig:SampleA50B2CM1}. We see that the sample and original data follow the same structure. The test statistics for this model are shown in figures \\ref{fig:CramerA50B2CM1}, \\ref{fig:GreenwoodA50B2CM1}, \\ref{fig:LaplaceA50B2CM1} and \\ref{fig:KolmogovA50B2CM1}. \n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/DensPlotA6B3C2.png}\n\\caption{Histogram of data for model 6 given $a = 6$, $b = 3$ and $c = 2$.}\n\\label{fig:DensPlotA6B3C2}\n\\end{subfigure}\n\\hspace{1em}\n\\begin{subfigure}[H]{0.45\\textwidth}\n\\includegraphics[width=\\textwidth]{fig/SampleA6B3C2.png}\n\\caption{Histogram of a sample for model 6.}\n\\label{fig:SampleA6B3C2}\n\\end{subfigure}\n\\caption{Data and sample from model 6.}\n\\label{fig:datasampmod6}\n\\end{figure}\n%\\includefigure[width=0.9\\textwidth]{fig/DensPlotA6B3C2.png}{fig:DensPlotA6B3C2}{Histogram of data for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n%\\includefigure[width=0.9\\textwidth]{fig/SampleA6B3C2.png}{fig:SampleA6B3C2}{Histogram of a sample for model 4 given $a = 20$, $b = 2$ and $c = 1$.}\n\\includefigure[width=0.8\\textwidth]{fig/CramerA6B3C2.png}{fig:CramerA6B3C2}{Histogram of a modified Cramer von Mises statistics for generated samples from model 6. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/GreenwoodA6B3C2.png}{fig:GreenwoodA6B3C2}{Histogram of a Greenwood statistics for generated samples from model 6. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/LaplaceA6B3C2.png}{fig:LaplaceA6B3C2}{Histogram of a Laplace statistics for generated samples from model 6. The red line is the observed test statistic value.}\n\\includefigure[width=0.8\\textwidth]{fig/KolmogorovA6B3C2.png}{fig:KolmogovA6B3C2}{Histogram of a modified Kolmogorov-Smirnov statistics for generated samples from model 6. The red line is the observed test statistic value.}\n\\begin{tab}{ccccc}{tab:models}{Calculated p-values for the six models.}\n\tModel\t&\tCramer\t& \tGreenwood & Kolmogorov & Laplace\t\\\\\n\t\\midrule\n\t1\t\t&\t\t0.620169\t&\t0.427880 & 0.717796 & 0.317228\t\t\t\\\\\n\t2\t\t&\t\t0.587691\t&\t0.976846 & 0.746255 & 0.698202\t\t\t\\\\\n\t3\t\t&\t\t0.720697\t&\t0.137568 & 0.851505 & 0.636406\t\t\t\\\\\n\t4\t\t&\t\t0.555303\t&\t0.898198 & 0.669570 & 0.947336\t\t\t\\\\\n\t5\t\t&\t\t0.351427\t&\t0.934180 & 0.108536 & 0.279662\t\t\t\\\\\n\t6\t\t&\t\t0.653474\t&\t0.209442 & 0.661944 & 0.408058\t\t\t\\\\\n\\end{tab}\n\\noindent %We see that for all of the models tried the null hypothesis has not been rejected, and for many of the p-values have been high. Hence the sampler generates samples from the right distribution.\n%The p-values for the different models are shown in table \\ref{tab:models}\nFirst we start with analysis of model 1. By comparing the generated data and sample data in figure \\ref{fig:datasampmod1} we can't say that they have the same distribution. Hence further analysis is needed. By looking at the distribution of test statistics and observed test statistics in figures \\ref{fig:CramerA10B04C2}, \\ref{fig:GreenwoodA10B04C2}, \\ref{fig:LaplaceA10B04C2} and \\ref{fig:KolmogorovA10B04C2}. From these figures we see that the oberserved test statistics have no extreme values. This is a strong indication that the null hypothesis should be kept. By looking at the p-values for model 1 in table \\ref{tab:models} we see that all of the p-values are higher than the $\\alpha$-levels of $0.05$ and $0.1$. Hence the null hypothesis that the samples comes from the right distribution is kept.\n\\\\\n\\\\\nFor model 2 a sample and generated data are shown in figure \\ref{fig:datasampmod2}. Here we see no direct link between the sample and generated data. From the figues with test statistics \\ref{fig:CramerA160B2CM3},  \\ref{fig:GreenwoodA160B2CM3}, \\ref{fig:LaplaceA160B2CM3} and \\ref{fig:KolmogovA160B2CM3} the observed test statistics are not extreme values. Hence strong indication that samples are from the same distribution as generated data. By comparing p-values against $\\alpha$-levels of 0.05 and 0.1, the null hypothesis cannot be rejected.\n\\\\\n\\\\\nFor model 3, 4, 5 and 6 there seem to be correlation between samples and generated data in figures \\ref{fig:datasampmod3}, \\ref{fig:datasampmod4}, \\ref{fig:datasampmod5}, \\ref{fig:datasampmod6}. Most of the oberserved test statistics for the models have no extreme values. The closest to extreme values are the Greenwood statistic in model 3 and Kolmogorov statistic in model 6.  Since the extreme values seem to be for a few statistics one can say that there is correlation between samples and data. By a closer look at the p-values in table \\ref{tab:models}. All of the p-values for model 3, 4, 5 and 6 are above the $\\alpha$-levels $0.05$ and $0.1$. Hence the null hypothesis cannot be rejected for model 3, 4, 5 and 6.\n\\\\\n\\\\\nSince the algorithm was able to generate samples from model 2 and 4, the algorithm can generate samples familiar to the gamma distribution. Model 1 is also of interest, since the rate function is some similar to the bathtub curve \\cite{rausand2004system}. These 3 models are very relevant for reliability analysis.\n\\\\\n\\\\\nA quick note on the accuracy for the MLE for $a$, $b$ and $c$. The accuracy of the estimated paramters might be poor because of the few data points in a sample. The accuracy can be increased by increasing the number of data points.", "meta": {"hexsha": "b13dd0b737b6834b7727bd68b5a2a15fa8201474", "size": 18637, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/chapters/applicationAndResults.tex", "max_stars_repo_name": "mariufa/ProsjektOppgave", "max_stars_repo_head_hexsha": "3ef2fda314c55322de20f19ca861e4268a5e2d08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/chapters/applicationAndResults.tex", "max_issues_repo_name": "mariufa/ProsjektOppgave", "max_issues_repo_head_hexsha": "3ef2fda314c55322de20f19ca861e4268a5e2d08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/chapters/applicationAndResults.tex", "max_forks_repo_name": "mariufa/ProsjektOppgave", "max_forks_repo_head_hexsha": "3ef2fda314c55322de20f19ca861e4268a5e2d08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.5647668394, "max_line_length": 806, "alphanum_fraction": 0.7687932607, "num_tokens": 6325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7577943658046608, "lm_q1q2_score": 0.4318311285804956}}
{"text": "\\section{\\limdds are exponentially more succinct than \\qmdds}\n\\label{sec:exponential-separations}\n%\\todo[inline]{Vedran:     Sec 4: not what I would expect to read as the first sentence  -0 title says QMDDs... sentence does not mention them but talks about stabilizers... clarify.\n%\tMaybe: the goal of this section is to prove that... [btw.. if that is the goal, why is this not the title? aha.. because that is the ultimate goal? Then: one of the main goals of the paper is to shiw that.. in order to do so we first show.. but now I see you say \"this section shows a stronger result\". so I think the first sentence is not what you want}\n\n%In the following sections, we show that LIMDDs can efficiently represent (this section) and manipulate (sec.~\\ref{sec:quantum-simulation}) a strict superset of all stabilizer states.\nIn this section, we show that \\limdds can be exponentially more succinct than the union of \\qmdds and stabilizer states (\\autoref{thm:limdd-superset-qmdd-plus-stabilizers}).\nNamely, we show that polynomial-sized $G$-\\limdds can represent stabilizer states, using $G=\\textsf{Pauli}$, (\\autoref{thm:pauli-limdd-is-stabilizer}) whereas \\qmdds require exponential space to represent cluster states (\\autoref{thm:graph-state-qmdd-lower-bound}).\nIn \\autoref{sec:graph-state-lower-bound} and \\autoref{sec:graph-states-limdds}, we show that \\limdds retain this exponential advantage even when we use the parameter $G=\\braket{Z}$ or $G=\\braket{X}$.\\footnote{Note that the proofs in this section do not rely on the specialized definition of reduced \\limdds, but only on the parametrized \\autoref{def:limdd}.}\nWe emphasize that this section regards \\emph{representation} of quantum states; in \\autoref{sec:quantum-simulation}, we show that by using \\limdds to represent quantum states, we can \\emph{simulate} quantum circuits.\n\n\\begin{wrapfigure}{r}{9cm}\n    \\vspace{-1em}\n%    \\begin{centering}\n\t\\includegraphics[width=0.55\\textwidth]{pics/complexity-inclusion-diagram-no-torus.pdf}\n\t\\caption{\n\t    \\label{fig:complexity-classes-inclusion-diagram}\n        Relations between classes of quantum states and families of polynomial-size decision diagrams.\n        Every arrow denotes a strict inclusion of sets; in particular, each solid arrow $D_1\\to D_2$ denotes an exponential separation between two decision diagram families, i.e., some quantum states have polynomial-size diagrams of type $D_2$, but have only exponential-size diagrams of type $D_1$. The dotted arrows represent inclusion.\n%        \\todo[inline]{remove DT}\n    }\n    %\\vspace{-1em}\n%    \\end{centering}\n\\end{wrapfigure}\n\n\\autoref{fig:complexity-classes-inclusion-diagram} visualizes the results from this section.\nThe boxes with $\\braket{Z}$-\\limdd denote the \\limdd with parameter \\mbox{$G=\\braket{Z}$}, i.e., \\limdds where the labels on edges are all of the form \\mbox{$\\lambda P_n\\otimes\\cdots\\otimes P_1$} where \\mbox{$P_j\\in \\{\\mathbb I, Z\\}$}.\nAlthough of course every $\\braket{Z}$-\\limdd is a Pauli-\\limdd, this parameterization is interesting in its own right because it requires only polynomial size to represent any graph state.\nSimilarly, the $\\braket{X}$-\\limdd can succinctly represent a set of stabilizer states we call ``XOR states.''\n\\autoref{sec:graph-states-limdds} proves these results, and proves that \\qmdds require exponential size for all these states. \n%Namely, we show that $\\braket{Z}$-\\limdds can represents graph states (\\autoref{thm:z-limdd-is-graph-state}), and that $\\braket{X}$-\\limdds can represent so-called ``XOR-states'' (\\autoref{thm:x-limdd-is-hyperplane}).\n\n\n\n\n\\begin{theorem}[Exponential separation between Pauli-\\limdd versus QMDD union stabilizer states]\n\t\\label{thm:limdd-superset-qmdd-plus-stabilizers}\n\tThe set of quantum states represented by polynomial-size Pauli-\\limdds is a strict superset of the union of stabilizer states and polynomial-size \\qmdds.\n\\end{theorem}\n\\begin{proof}\n    Each $n$-qubit stabilizer state can be represented by a Pauli-\\limdd of $n$ nodes (\\autoref{thm:pauli-limdd-is-stabilizer}).\n    Moreover, if a state has a polynomial-size \\qmdd, it also has a polynomial-size \\limdd, due to our earlier remark that a \\qmdd can be seen as a \\glimdd with $G=\\set{\\mathbb I}$, i.e., each label is of the form $\\lambda\\mathbb I$ with $\\lambda\\in\\mathbb C$.\n%    This shows that the union of stabilizer states and polynomial-size QMDDs is included in the set of polynomial-sizee Pauli-\\limdds.\n    To show that polynomial-size Pauli-\\limdds represent strictly more than these two classes of states, consider $\\ket{\\phi}:= \\ket{T}\\otimes \\ket{G_n}$, where $\\ket{T}=\\ket{0}+e^{i\\pi/4}\\ket{1}$, and where $\\ket{G_n}$ is the graph state on the $n\\times n$ grid.\n    We note that $\\ket{\\phi}$ is not a stabilizer state, because each computational-basis coefficient of a stabilizer state is of the form $z\\cdot 1/\\sqrt{2}^k$ for $z\\in \\{\\pm 1, \\pm i\\}$ and some integer $k\\geq 1$ \\cite{nest2005local}, while $\\bra{1}\\otimes \\bra{0}^{\\otimes n} \\ket{\\phi} = e^{i\\pi/4} \\cdot \\frac{1}{\\sqrt{2}}^n$ is not of this form.\n    Moreover, its canonical \\qmdd is a root node $\\lnode{1}{v_G}{e^{i\\pi/4}}{v_G}$ where $v_G$ is the root node of the QMDD for $\\ket{G_n}$, which has exponential size (\\autoref{thm:graph-state-qmdd-lower-bound}).\n    In contrast, the reduced Pauli-\\limdd for $\\ket{G_n}$ (with root node $w_G$) has $n$ nodes (because $\\ket{G_n}$ is a stabilizer state), and hence a polynomial-size Pauli-\\limdd for $\\ket{T} \\otimes \\ket{G_n}$ has root node with $\\lnode{\\unit}{v_G}{e^{i\\pi/4} \\unit}{v_G}$.\n\\end{proof}\n\n\n%In the following proofs, we  use a subset of \\limdds, called Tower \\limdds formalized in \\autoref{def:tower}.\n%\\begin{definition}[Tower \\glimdd]\n%    \\label{def:tower}\n%\tA \\glimdd is called a Tower \\glimdd if it has one node in each layer, i.e., if, for each node, both outgoing edges point to the same target (although these edges may have different labels).\n%\\end{definition}\n%\n%\\autoref{thm:pauli-limdd-is-stabilizer} characterizes the Tower Pauli-\\limdds.\n%It is stated here informally; for details and a proof, see \\autoref{sec:proof-stabilizer-states-tower-limdds}\n\nNow we give the two statements leading up to \\autoref{thm:limdd-superset-qmdd-plus-stabilizers}: \\pauli-\\limdds represent stabilizer states succinctly (\\autoref{thm:pauli-limdd-is-stabilizer}) but \\qmdds representing stabilizer states are necessarily large (\\autoref{thm:graph-state-qmdd-lower-bound}).\nIn this theorem, by a Tower \\limdd we mean a \\limdd which has a single node on each level.\n\n\\begin{theorem}[Tower Pauli-\\limdds are stabilizer states]\n\t\\label{thm:pauli-limdd-is-stabilizer}\n    Let $n>0$.\n    Each $n$-qubit stabilizer state is represented by a reduced Tower Pauli-\\limdd on $n$ nodes with high edge label factors $\\in \\{0, \\pm 1, \\pm i\\}$.\n\tConversely, every such \\limdd represents a stabilizer state.\n\\end{theorem}\n\\begin{proof}[Proof sketch]\n    We sketch here why each stabilizer state is represented by a reduced Tower Pauli-\\limdd and give a full proof in \\autoref{thm:pauli-tower-limdds-are-stabilizer-states}.\n    Let $\\ket{\\psi}$ be a stabilizer state.\n    If $\\ket{\\psi} = \\ket{x}\\ket{\\psi'}$ for some $x\\in \\{0, 1\\}$ and $\\ket{\\psi'}$, then $\\ket{\\psi'}$ is a stabilizer state and it is represented by a Tower Pauli-\\limdd which has a root node with a low edge label $\\id$, high edge label $0$ and root edge labelled $X^x \\otimes \\id$, to the root node of the Tower Pauli-\\limdd of $\\ket{\\psi'}$.\n\tOtherwise, $\\ket{\\psi}\\propto \\ket{0}\\ket{\\psi_0}+\\ket{1}\\ket{\\psi_1}$, where both $\\ket{\\psi_0}$ and $\\ket{\\psi_1}$ are stabilizer states.\n    Moreover, if $\\ket{\\psi}$ is a stabilizer state, there is always a set of single-qubit Pauli gates $P_1,\\ldots, P_n$ and a $\\lambda \\in \\{\\pm 1, \\pm i\\}$ such that $\\ket{\\psi_1}=\\lambda P_n\\otimes\\cdots\\otimes P_1\\ket{\\psi_0}$.\n\tThat is, in our terminology, the states $\\ket{\\psi_0}$ and $\\ket{\\psi_1}$ are \\emph{isomorphic}.\n\tHence $\\ket{\\psi}$ can be written as\n\t\\begin{align}\n\t\t\\ket{\\psi}=\\ket{0}\\ket{\\psi_0} + \\lambda \\ket{1}\\otimes \\left(P_n\\otimes\\cdots\\otimes P_1\\ket{\\psi_0}\\right)\n\t\\end{align}\n\tThis expression suggests the following representation as a Tower Pauli-\\limdd: the root node represents $\\ket{\\psi}$, both its outgoing edges point to a node representing $\\ket{\\psi_0}$, and its high edge is labeled with the isomorphism $\\lambda P_n\\otimes\\cdots\\otimes P_1$; this strategy is then applied recursively to $\\ket{\\psi_0}$ and its two subfunctions.\n    This procedure yields a semi-reduced Tower-Pauli-\\limdd, which can be made reduced by making all high labels canonical, from bottom to top.\n\\end{proof}\n\n\\begin{lemma}\n\t\\label{thm:graph-state-qmdd-lower-bound}\n\tDenote by $\\ket{G_n}$ the graph state on the $n \\times n$ lattice.\n\tEach \\qmdd representing the cluster state $\\ket{G_n}$ has at least $2^{\\floor{n/12}}$ nodes.\n\\end{lemma}\n\\begin{proof}[Proof sketch]\n\tConsider a partition of the vertices of the $n\\times n$ lattice into two sets $S$ and $T$ of size $\\frac{1}{2}n^2$, corresponding to the first $\\frac{1}{2}n^2$ qubits under some variable order.\n\tThen there are at least $\\lfloor n/3 \\rfloor$ vertices in $S$ that are adjacent to a vertex in $T$ \\cite[Th. 11]{lipton1979generalized}.\n\tBecause the degree of the nodes is small, many vertices on this boundary influence the amplitude function independently of one another.\n\tFrom this independence, it follows that, for any variable order,\n\tthe partial assignments $\\vec a \\in \\set{0,1}^{\\frac{1}{2}n^2}$ induce\n\t$2^{\\lfloor n/12 \\rfloor}$ different subfunctions $f_{\\vec a}$, where\n\t$f\\colon \\set{0,1}^{n^2} \\rightarrow \\mathbb C$\n\tis the amplitude function of $\\ket{G_n}$.\n\tThe lemma follows by noting that a \\qmdd has a single node per unique subfunction modulo phase.\n\tFor details see \\autoref{sec:graph-state-lower-bound}.\n\\end{proof}\n\n%In \\autoref{sec:proof-stabilizer-states-tower-limdds}, we characterize Tower $\\braket{Z}$-\\limdds (\\autoref{thm:z-limdd-is-graph-state}) and Tower $\\braket{X}$-\\limdds (\\autoref{thm:x-limdd-is-hyperplane}), and we give two more exponential separations (\\autoref{thm:exponential-lower-bound-hyperplane} and \\autoref{thm:exponential-separation-add-vs-qmdd}).\n%Proofs of the characterizations appear in \\autoref{sec:proof-stabilizer-states-tower-limdds}.\n\n%\\begin{theorem}[Tower $\\braket{Z}$-\\limdds are graph states]\n%\t\\label{thm:z-limdd-is-graph-state}\n%\tFor every graph state, there is a Tower-$\\braket{Z}$-\\limdd which represents that state.\n%\tConversely, every Tower-$\\braket{Z}$-\\limdd represents some graph state.\n%\\end{theorem}\n%\n%\\autoref{thm:x-limdd-is-hyperplane} talks about uniform superpositions.\n%If $S\\subseteq\\{0,1\\}^n$ is any set of $n$-bit vectors, then we are interested in the uniform superposition over the elements of $S$:\n%\\begin{align}\n%\t\\ket{\\chi_S}=\\frac{1}{\\sqrt{|S|}}\\sum_{x\\in S}\\ket{x}\n%\\end{align}\n%\n%\\begin{theorem}[Tower $\\braket{X}$-\\limdds are XOR-states]\n%\t\\label{thm:x-limdd-is-hyperplane}\n%\tFor every hyperplane $H\\subseteq \\{0,1\\}^n$, there is a Tower-$\\braket{X}$-\\limdd which represents the state $\\ket{\\chi_H}$.\n%\tConversely, every Tower-$\\braket{X}$-\\limdd represents the state $\\ket{\\chi_H}$ for some hyperplane $H$.\n%\\end{theorem}\n%\n%\\begin{theorem}[X lower bound]\n%\t\\label{thm:exponential-lower-bound-hyperplane}\n%\t\\todo[inline]{To do: fetch this theorem from a previous version of the document -LV}\n%\\end{theorem}\\todo{Why do we need this?}\n\nFinally, we note an exponential separation between \\qmdds and \\adds.\nAlthough we do believe this fact may be known in the decision diagram community, to the best of our knowledge this separation does not appear in the literature.\n\n\\begin{theorem}\n\t\\label{thm:exponential-separation-add-vs-qmdd}\n\tThere is an infinite family of quantum states $\\{\\ket{\\phi_n}_n\\}_{n}$ such that every \\add needs $\\Theta(2^n)$ nodes to store $\\ket{\\phi_n}$, but every \\qmdd needs only $\\Theta(n)$ nodes.\n\\end{theorem}\n\\begin{proof}\n\tThe family of states is\n\t\\begin{align*}\n\t\t\\ket{\\phi_n}=(\\ket{0}+e^{i\\pi}\\ket{1})\\otimes (\\ket{0}+e^{i\\pi2^{-1}}\\ket{1})\\otimes \\cdots \\otimes (\\ket{0}+e^{i\\pi2^{-n+1}}\\ket{1}),\n\t\\end{align*}\n\twhich is a product state and can thus be represented by a \\qmdd on $n$ nodes.\n\tIn contrast, the computational-basis amplitudes are $\\langle x |\\phi_n\\rangle = e^{i\\pi x2^{-n}}/\\sqrt{2^n}$ for $x \\in \\{0, 1, \\dots, 2^n-1\\}$ in binary notation, and therefore no two $\\ket{x}$ share the same amplitude, resulting in $2^n$ leaves of the~\\add.\n\\end{proof}\n\n\n%\\todo[inline]{The next section shows that LIMDDs not only represent a larger set of quantum states, but can also manipulate them efficiently, realizing a new method of simulation of quantum computing. In Section 6, we introduce some quantum circuits which LIMDDs can simulate efficiently, but which we suspect cannot be simulated with with existing simulators.}\n", "meta": {"hexsha": "b5499cafaadf95c3a200285203af59c4df0932c8", "size": 12831, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Src/CS/sections/exponential_separations.tex", "max_stars_repo_name": "Katafotic/latex_parsing", "max_stars_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Src/CS/sections/exponential_separations.tex", "max_issues_repo_name": "Katafotic/latex_parsing", "max_issues_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Src/CS/sections/exponential_separations.tex", "max_forks_repo_name": "Katafotic/latex_parsing", "max_forks_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.8835616438, "max_line_length": 362, "alphanum_fraction": 0.7335359676, "num_tokens": 3867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43150425060756736}}
{"text": "\\def\\module{M4P63 Algebra IV}\n\\def\\lecturer{Dr John Britnell}\n\\def\\term{Spring 2020}\n\\def\\cover{\n$$\n\\begin{tikzcd}[ampersand replacement=\\&, column sep=small]\n\\& 0 \\arrow{d} \\& \\vdots \\& 0 \\arrow{d} \\& \\vdots \\& 0 \\arrow{d} \\& \\vdots \\& \\& \\\\\n0 \\arrow{r} \\& \\ker d_n^A \\arrow{rr} \\arrow{dr} \\& \\& \\ker d_n^B \\arrow{rr} \\arrow{dr} \\& \\& \\ker d_n^C \\arrow{dr} \\& \\& \\& \\\\\n\\& 0 \\arrow{r} \\& A_{n + 1} \\arrow[from=uu, crossing over]{} \\arrow[near start]{rr}{f_{n + 1}} \\& \\& B_{n + 1} \\arrow[from=uu, crossing over]{} \\arrow[near start]{rr}{g_{n + 1}} \\& \\& C_{n + 1} \\arrow[from=uu, crossing over]{} \\arrow{r} \\& 0 \\& \\\\\n\\& 0 \\arrow{d} \\& \\& 0 \\arrow{d} \\& \\& 0 \\arrow{d} \\& \\& \\& \\\\\n0 \\arrow{r} \\& \\ker d_{n - 1}^A \\arrow{rr} \\arrow{dr} \\& \\& \\ker d_{n - 1}^B \\arrow{rr} \\arrow{dr} \\& \\& \\ker d_{n - 1}^C \\arrow{dr} \\& \\& \\& \\\\\n\\& 0 \\arrow{r} \\& A_n \\arrow[from=uuu, crossing over, near start]{}[swap]{d_n^A} \\arrow[near end]{rr}[swap]{f_n} \\arrow{dr} \\arrow[near end]{ddd}{d_{n - 1}^A} \\& \\& B_n \\arrow[from=uuu, crossing over, near start]{}[swap]{d_n^B} \\arrow[near start]{rr}{g_n} \\arrow{dr} \\arrow[near end]{ddd}{d_{n - 1}^B} \\& \\& C_n \\arrow[from=uuu, crossing over, near start]{}[swap]{d_n^C} \\arrow{r} \\arrow{dr} \\arrow[near end]{ddd}{d_{n - 1}^C} \\& 0 \\& \\\\\n\\& \\& \\& \\coker d_n^A \\arrow[from=uuuuurr, crossing over, in=195, out=15]{} \\arrow[crossing over]{rr} \\arrow{d} \\& \\& \\coker d_n^B \\arrow[crossing over]{rr} \\arrow{d} \\& \\& \\coker d_n^C \\arrow{r} \\arrow{d} \\& 0 \\\\\n\\& \\& \\& 0 \\& \\& 0 \\& \\& 0 \\& \\\\\n\\& 0 \\arrow{r} \\& A_{n - 1} \\arrow[near end]{rr}[swap]{f_{n - 1}} \\arrow{dr} \\arrow{dd} \\& \\& B_{n - 1} \\arrow[near end]{rr}[swap]{g_{n - 1}} \\arrow{dr} \\arrow{dd} \\& \\& C_{n - 1} \\arrow{r} \\arrow{dr} \\arrow{dd} \\& 0 \\& \\\\\n\\& \\& \\& \\coker d_{n - 1}^A \\arrow[from=uuuuurr, crossing over, in=195, out=15]{} \\arrow[crossing over]{rr} \\arrow{d} \\& \\& \\coker d_{n - 1}^B \\arrow[crossing over]{rr} \\arrow{d} \\& \\& \\coker d_{n - 1}^C \\arrow{r} \\arrow{d} \\& 0 \\\\\n\\& \\& \\vdots \\& 0 \\& \\vdots \\& 0 \\& \\vdots \\& 0 \\& \\\\\n\\end{tikzcd}\n$$\n}\n\\def\\syllabus{Exact sequences. Hom and tensor product. Projective and free modules. Injective and divisible modules. Flat and torsion-free modules. Projective and injective resolutions. Chain and cochain complexes. Homology and cohomology. Derived functors. Tor and torsion. Ext and extensions. Global dimension.}\n\\def\\thm{section}\n\n\\input{../style/header}\n\n\\begin{document}\n\n\\input{../style/cover}\n\n\\setcounter{section}{0}\n\n\\section{Modules over a ring}\n\n\\lecture{1}{Friday}{10/01/20}\n\nLet $ R $ be an \\textbf{associative ring with unity}, that is an abelian group written additively with a multiplication which is associative but not necessarily commutative, with an identity one, and distributive laws $ a\\br{b + c} = ab + ac $ and $ \\br{a + b}c = ac + bc $. Then\n$$ R^* = \\cbr{r \\in R \\st \\exists s \\in R, \\ rs = 1 = sr} $$\nis the \\textbf{unit group} of $ R $. If $ R^* = R \\setminus \\cbr{0} $ then $ R $ is a \\textbf{division ring}, or a \\textbf{skew field}. In the case that $ R $ is commutative, $ R $ is a \\textbf{field}.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Fields $ \\CC $, $ \\RR $, $ \\QQ $, and $ \\FF_q $, the field with $ q = p^a $ elements with $ p $ a prime and $ a \\ge 1 $.\n\\item The skew field $ \\HH = \\cbr{a + bi + cj + dk \\st a, b, c, d \\in \\RR} $ where $ i^2 = j^2 = k^2 = ijk = -1 $.\n\\item Other rings are polynomial rings $ k\\sbr{x} $ for $ k $ a field, more generally $ k\\sbr{x_1, \\dots, x_p} $, and $ \\Mat_n k $, the $ n \\times n $ matrices with entries from $ k $, a field.\n\\end{itemize}\n\\end{example*}\n\n\\subsection{Modules over rings}\n\n\\begin{definition}\nLet $ R $ be a ring. A \\textbf{left $ R $-module} is an abelian group $ M $, written additively, together with a function $ * : R \\times M \\to M $ satisfying\n$$ r * \\br{m_1 + m_2} = r * m_1 + r * m_2, \\qquad \\br{r_1 + r_2} * m = r_1 * m + r_2 * m, \\qquad \\br{r_1r_2} * m = r_1 * \\br{r_2 * m}, \\qquad 1 * m = m. $$\n\\end{definition}\n\nWe write $ rm $ for $ r * m $.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item $ R $ is itself a left $ R $-module, with $ * $ as ring multiplication. More generally, let $ I $ be a left ideal of $ R $, so $ I $ is an additive subgroup, and $ rI \\le I $ for all $ r \\in R $. Then $ I $ is an $ R $-module, with $ * $ as ring multiplication.\n\\item Let $ k $ be a field. Then any vector space over $ k $ is a $ k $-module, and vice versa.\n\\item Any abelian group is a $ \\ZZ $-module, with $ * $ defined by $ na = a + \\dots + a $ for $ n \\in \\ZZ^+ $ and $ a \\in A $, and $ \\br{-n}a = -\\br{na} $.\n\\item Let $ k $ be a field. Let $ k^n $ be column vectors. Then $ k^n $ is a left $ \\Mat_n k $-module, with $ * $ as the usual matrix-vector multiplication.\n\\item Let $ M \\in \\Mat_n k $. Then we can define a left $ k\\sbr{x} $-module structure on $ k^n $ by letting $ x $ act as $ M $ on $ k^n $. So $ \\br{x^2 + 3x - 2} * v = M^2v + 3Mv - 2v $.\n\\item Let $ G $ be a group. Any representation of $ G $ over the field $ k $ is a left module for $ k\\sbr{G} $, the \\textbf{group algebra}, a vector space over $ k $ with elements of $ G $ as a basis, with multiplication derived from that of $ G $.\n\\end{itemize}\n\\end{example*}\n\n\\begin{definition}\nA \\textbf{right $ R $-module} is defined similarly, with the $ R $-multiplication on the right, so $ M $ an abelian group under $ + $, and a map $ M \\times R \\to M $ satisfying\n$$ \\br{m_1 + m_2} * r = m_1 * r + m_2 * r, \\qquad m * \\br{r_1 + r_2} = m * r_1 + m * r_2, \\qquad m * \\br{r_1r_2} = \\br{m * r_1} * r_2, \\qquad m * 1 = m. $$\n\\end{definition}\n\nLeft and right modules are not quite the same. If we amend this definition by putting the ring multiplication on the left, the third axiom becomes $ \\br{r_1r_2}m = r_2\\br{r_1m} $. But in a left module, we have $ \\br{r_1r_2}m = r_1\\br{r_2m} $.\n\n\\begin{definition}\nLet $ R $ be a ring. The \\textbf{opposite ring} $ R^{\\op} $ is $ R $ with a redefined multiplication $ r *_{R^{\\op}} s = s *_R r $.\n\\end{definition}\n\nIt is easy to see that a left $ R $-module is the same as a right $ R^{\\op} $-module, and vice versa. If $ R $ is commutative then $ R = R^{\\op} $.\n\n\\begin{exercise*}\nShow that $ \\Mat_n k \\cong \\Mat_n k^{\\op} $.\n\\end{exercise*}\n\nExcept where otherwise stated, $ R $-modules are assumed to be left $ R $-modules.\n\n\\pagebreak\n\n\\subsection{Homomorphisms and submodules}\n\n\\begin{definition}\nLet $ M_1 $ and $ M_2 $ be $ R $-modules. A map $ f : M_1 \\to M_2 $ is an \\textbf{$ R $-module homomorphism} if\n\\begin{itemize}\n\\item $ f $ is a group homomorphism, with respect to the $ + $ operations, and\n\\item $ f\\br{rm} = rf\\br{m} $, for $ r \\in R $ and $ m \\in M $.\n\\end{itemize}\nIf $ f $ is bijective, then it is an \\textbf{$ R $-module isomorphism}.\n\\end{definition}\n\n\\begin{definition}\nAn additive subgroup $ L \\le M $ is a \\textbf{submodule} if $ rL \\le L $ for $ r \\in R $. In this case we automatically get an $ R $-module structure on the quotient $ M / L $ with multiplication given by $ r\\br{m + L} = rm + L $.\n\\end{definition}\n\n\\begin{theorem}[First isomorphism theorem]\nLet $ f : M_1 \\to M_2 $ be an $ R $-module homomorphism. Then\n$$ \\im f \\le M_2, \\qquad \\ker f \\le M_1, \\qquad \\im f \\cong M / \\ker f. $$\n\\end{theorem}\n\nThe other isomorphism theorems have $ R $-module versions too.\n\n\\subsection{Direct products and direct sums}\n\n\\lecture{2}{Monday}{13/01/20}\n\nLet $ S $ be a set. We have a collection of $ R $-modules $ \\br{M_s}_S $ indexed by $ S $.\n\n\\begin{definition}\nThe \\textbf{direct product} is\n$$ \\prod_{s \\in S} M_s = \\cbr{\\br{m_s}_S \\st m_s \\in M_s}, $$\nwith coordinate-wise addition and $ R $-multiplication, so\n$$ \\br{m_s}_S + \\br{n_s}_S = \\br{m_s + n_s}_S, \\qquad r\\br{m_s}_S = \\br{rm_s}_S. $$\n\\end{definition}\n\nIf $ M_s = M $ for all $ s \\in S $, then we write $ M^S $ for $ \\prod_{s \\in S} M_s $.\n\n\\begin{definition}\nThe \\textbf{direct sum} is\n$$ \\bigoplus_{s \\in S} M_s = \\cbr{\\br{m_s}_S \\st \\text{all but finitely many coordinates} \\ m_s \\ \\text{are zero}} \\le \\prod_{s \\in S} M_s. $$\n\\end{definition}\n\nIf $ S $ is finite then the direct product and the direct sum are equal.\n\n\\begin{example*}\nLet $ M = \\ZZ_2 $, as a $ \\ZZ $-module, and let $ S = \\NN $. Then $ \\bigoplus_{s \\in \\NN} \\ZZ_2 $ is a countable $ \\ZZ $-module but $ \\prod_{s \\in \\NN} \\ZZ_2 = \\ZZ_2^\\NN $ is uncountable.\n\\end{example*}\n\nWhen $ \\abs{S} = 2 $, generally we write $ M_1 \\oplus M_2 $ for the direct sum, or product. There are natural injective maps, or $ R $-module homomorphisms\n$$ \\function[\\iota_A]{A}{A \\oplus B}{a}{\\br{a, 0}}, \\qquad \\function[\\iota_B]{B}{A \\oplus B}{b}{\\br{0, b}}, $$\nand surjective maps\n$$ \\function[\\pi_A]{A \\oplus B}{A}{\\br{a, b}}{a}, \\qquad \\function[\\pi_B]{A \\oplus B}{B}{\\br{a, b}}{b}. $$\n\n\\subsection{Exact sequences}\n\n\\begin{definition}\nSuppose we have a sequence of $ R $-modules $ \\dots, M_{n - 1}, M_n, M_{n + 1}, \\dots $, with maps $ f_n : M_n \\to M_{n + 1} $. Say the sequence is \\textbf{exact at $ M_n $} if $ \\im f_{n - 1} = \\ker f_n $. The sequence is \\textbf{exact} if it is exact everywhere. A \\textbf{short exact sequence} is an exact sequence\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0. $$\n\\end{definition}\n\n\\begin{note*}\n$ \\alpha $ is injective and $ \\beta $ is surjective.\n\\end{note*}\n\n\\pagebreak\n\nBy the first isomorphism theorem, $ B / \\im \\alpha \\cong C $, where $ \\im \\alpha \\cong A $. An easy case is $ B \\cong A \\oplus C $, with $ \\im \\alpha = \\im \\iota_A = A \\oplus 0 $ and $ \\im \\beta = \\im \\pi_\\beta = C $. We say that the short exact sequence \\textbf{splits} in this case.\n\n\\begin{example*}\nA non-split short exact sequence of $ \\ZZ $-modules, or abelian groups, is\n$$ 0 \\to \\ZZ_2 \\to \\ZZ_4 \\to \\ZZ_2 \\to 0. $$\n\\end{example*}\n\n\\begin{proposition}\nA short exact sequence\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0 $$\nis split if and only if there exists an $ R $-module homomorphism $ \\sigma : C \\to B $ such that $ \\beta \\circ \\sigma = \\id_C $.\n\\end{proposition}\n\nSuch a $ \\sigma $ is called a \\textbf{section} of $ \\beta $.\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Suppose that the short exact sequence is split. So assume $ B = A \\oplus C $, with $ \\alpha = \\iota_A $ and $ \\beta = \\pi_C $. Now $ \\iota_C $ is a section for $ \\beta $.\n\\item[$ \\impliedby $] For the converse, suppose that $ \\sigma $ is a section for $ \\beta $. We want $ f : A \\oplus C \\xrightarrow{\\sim} B $ such that $ f \\circ \\iota_A = \\alpha $ and $ \\beta \\circ f = \\pi_C $, so\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r}{\\iota_A} \\arrow[cong]{d} & A \\oplus C \\arrow{r}{\\pi_C} \\arrow{d}{f} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r}[swap]{\\alpha} & B \\arrow{r}[swap]{\\beta} & C \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nDefine\n$$ \\function[f]{A \\times C}{B}{\\br{a, c}}{\\alpha\\br{a} + \\sigma\\br{c}}. $$\nNeed to check the following.\n\\begin{itemize}\n\\item $ f $ is an $ R $-module homomorphism. \\footnote{Exercise}\n\\item $ f $ is injective. Suppose $ f\\br{a, c} = 0 $. Then $ \\alpha\\br{a} + \\sigma\\br{c} = 0 $. Now $ \\alpha\\br{a} \\in \\im \\alpha = \\ker \\beta $, so $ \\beta\\br{\\alpha\\br{a} + \\sigma\\br{c}} = \\beta\\br{\\sigma\\br{c}} = c $. Since $ \\alpha\\br{a} + \\sigma\\br{c} = 0 $, we have $ c = 0 $. Hence $ \\alpha\\br{a} = 0 $, and so $ a = 0 $ since $ \\alpha $ is injective. We have shown that $ f $ is injective.\n\\item $ f $ is surjective. Let $ b \\in B $. Let $ c = \\beta\\br{b} $. We have $ \\br{\\beta \\circ \\sigma}\\br{c} = c = \\beta\\br{b} $, so $ b - \\sigma\\br{c} \\in \\ker \\beta = \\im \\alpha $. So there exists $ a \\in A $ with $ \\alpha\\br{a} = b - \\sigma\\br{c} $. Then $ b = \\alpha\\br{a} + \\sigma\\br{c} = f\\br{a, c} $.\n\\item $ f \\circ \\iota_A = \\alpha $ and $ \\beta \\circ f = \\pi_C $. Immediate from the construction of $ f $.\n\\end{itemize}\n\\end{itemize}\n\\end{proof}\n\n\\begin{proposition}\nThe short exact sequence\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0 $$\nis split if and only if there exists $ \\rho : B \\to A $ such that $ \\rho \\circ \\alpha = \\id_A $.\n\\end{proposition}\n\nSuch a $ \\rho $ is a \\textbf{retraction} of $ \\alpha $.\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Once again, if the short exact sequence is split then the existence of $ \\rho $ is clear.\n\\item[$ \\impliedby $] Suppose that $ \\rho $ is a retraction for $ \\alpha $. We define $ f : B \\xrightarrow{\\sim} A \\oplus C $ such that $ f \\circ \\alpha = \\iota_A $ and $ \\pi_C \\circ f = \\beta $. Do this by\n$$ \\function[g]{B}{A \\oplus C}{b}{\\br{\\rho\\br{b}, \\beta\\br{b}}}. $$\nDetails are omitted.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\n\\section{Projective and injective modules}\n\n\\subsection{Projective modules}\n\n\\lecture{3}{Tuesday}{14/01/20}\n\n\\begin{definition}\nAn $ R $-module $ M $ is \\textbf{projective} if any surjective map $ \\beta : B \\to M $ has a section. In other words, any short exact sequence\n$$ 0 \\to A \\to B \\to M \\to 0 $$\nsplits.\n\\end{definition}\n\n\\begin{example*}\nThe $ R $-module $ R $ is projective. Let\n$$ 0 \\to A \\to B \\xrightarrow{\\beta} R \\to 0 $$\nbe a short exact sequence. Since $ \\beta $ is surjective, there exists $ b \\in B $ such that $ \\beta\\br{b} = 1 $. Now for all $ r \\in R $, $ \\beta\\br{rb} = r $. Now define\n$$ \\function[\\sigma]{R}{B}{r}{rb}. $$\nThen $ \\sigma $ is a section for $ \\beta $.\n\\end{example*}\n\n\\begin{proposition}\nAn $ R $-module $ M $ is projective if and only if whenever $ \\beta : B \\to C $ is surjective, and $ f : M \\to C $, there exists $ g : M \\to B $ such that $ f = \\beta \\circ g $, so\n$$\n\\begin{tikzcd}[row sep=small]\n& & & M \\arrow[dashed]{dl}[swap]{g} \\arrow{d}{f} & \\\\\n0 \\arrow{r} & A \\arrow{r} & B \\arrow{r}[swap]{\\beta} & C \\arrow{r} & 0\n\\end{tikzcd}.\n$$\n\\end{proposition}\n\nSuch a $ g $ is called a \\textbf{lift} of $ f $.\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\impliedby $] Suppose that whenever $ \\beta : B \\to C $ is surjective and $ f : M \\to C $ then there exists $ g : M \\to B $ with $ f = \\beta \\circ g $. Suppose $ \\beta : B \\to M $ is a surjective map. Define $ f : M \\to M $ to be $ \\id_M $. Then there exists $ g : M \\to B $ such that $ f = \\beta \\circ g $, so $ \\id_M = \\beta \\circ g $. So $ g $ is a section for $ \\beta $, and so $ M $ is projective.\n\\item[$ \\implies $] For the converse, suppose $ \\beta : B \\to C $ is surjective, and $ f : M \\to C $. We construct a module $ X $ to complete a commuting square\n$$\n\\begin{tikzcd}\nX \\arrow{r}{\\epsilon} \\arrow{d}[swap]{\\delta} & M \\arrow{d}{f} \\\\\nB \\arrow{r}[swap]{\\beta} & C\n\\end{tikzcd}.\n$$\nLet $ X $ be the submodule of $ B \\oplus M $ defined by\n$$ X = \\cbr{\\br{b, m} \\st \\beta\\br{b} = f\\br{m}}. $$\nThe maps $ \\delta $ and $ \\epsilon $ are just $ \\pi_B $ and $ \\pi_M $ respectively, in their restrictions to $ X $. It is clear that $ X \\le B \\oplus M $, and that the square above commutes. Now suppose that $ M $ is projective. Since $ \\beta $ is surjective, we see that for all $ m \\in M $ there exists $ b \\in B $ with $ \\beta\\br{b} = f\\br{m} $. It follows that $ \\epsilon : X \\to M $ is surjective. So $ \\epsilon $ has a section $ \\sigma : M \\to X $. Define $ g = \\delta \\circ \\sigma : M \\to B $, so\n$$\n\\begin{tikzcd}\nX \\arrow[bend left=15]{r}{\\epsilon} \\arrow{d}[swap]{\\delta} & M \\arrow[bend left=15, dashed]{l}{\\sigma} \\arrow[dashed]{dl}{g} \\arrow{d}{f} \\\\\nB \\arrow{r}[swap]{\\beta} & C\n\\end{tikzcd}.\n$$\nSince $ \\beta \\circ \\delta = f \\circ \\epsilon $, we have\n$$ \\br{\\beta \\circ g}\\br{m} = \\br{\\beta \\circ \\delta \\circ \\sigma}\\br{m} = \\br{f \\circ \\epsilon \\circ \\sigma}\\br{m} = \\br{f \\circ \\id_M}\\br{m} = f\\br{m}, \\qquad m \\in M. $$\nSo $ \\beta \\circ g = f $ as required.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\nSuch an $ X $ is the \\textbf{pullback} of $ \\beta $ and $ f $, and there is a short exact sequence\n$$ 0 \\to A \\to X \\to M \\to 0. $$\n\n\\subsection{Free modules}\n\n\\begin{definition}\nAn $ R $-module $ M $ is \\textbf{free} if $ M $ is a direct sum of copies of $ R $, so\n$$ M = \\bigoplus_{s \\in S} R. $$\nA \\textbf{basis} for a module $ M $ is a set $ T $ of elements such that every element $ m \\in M $ has a unique expression as\n$$ m = \\sum_{i = 1}^m r_it_i, \\qquad r_i \\in R, \\qquad t_i \\in T. $$\n\\end{definition}\n\nIf $ M = \\bigoplus_{s \\in S} R $, then $ M $ has a basis consisting of elements with exactly one coordinate one, and the rest zero. On the other hand, if $ M $ has a basis $ T $ then it is straightforward to show that $ M \\cong \\bigoplus_{t \\in T} R $. \\footnote{Exercise}\n\n\\begin{proposition}\nLet $ F $ be a free $ R $-module with basis $ T $. Let $ M $ be some $ R $-module, and let $ \\psi : T \\to M $ be a set map. Then $ \\psi $ extends uniquely to an $ R $-module homomorphism $ \\psi : F \\to M $.\n\\end{proposition}\n\n\\begin{proof}\nEach element of $ F $ has a unique expression as $ \\sum_i r_it_i $ for $ r_i \\in R $ and $ t_i \\in T $. Now define\n$$ \\function[\\psi]{F}{M}{\\sum_i r_it_i}{\\sum_i r_i\\psi\\br{t_i}}. $$\nIt is easy to check that this respects $ + $ and $ R $-multiplication.\n\\end{proof}\n\n\\begin{proposition}\nA module $ M $ is projective if and only if there exists $ N $ such that $ M \\oplus N $ is free, so projective modules are direct summands of free modules.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Suppose $ M $ is projective. Let $ F $ be the free module with basis $ \\cbr{b_m \\st m \\in M} $. Now the map $ b_m \\mapsto m $ extends to an $ R $-module homomorphism $ F \\to M $, which is clearly surjective. Then if $ K = \\ker \\psi $, we have a short exact sequence\n$$ 0 \\to K \\to F \\xrightarrow{\\psi} M \\to 0. $$\nSince $ M $ is projective, there is a section $ \\sigma $ for $ \\psi $, and so the short exact sequence splits, and $ F \\cong K \\oplus M $.\n\n\\lecture{4}{Friday}{17/01/20}\n\n\\item[$ \\impliedby $] Suppose that $ M \\oplus N = F $, a free module with basis $ T $. Suppose $ \\beta : B \\to C $ is surjective, and that $ f : M \\to C $. Note that $ f \\circ \\pi_M : F \\to C $. Let $ m_t = \\pi_M\\br{t} $. For each $ t \\in T $, let $ b_t \\in B $ be such that $ \\beta\\br{b_t} = f\\br{m_t} $. The set map\n$$ \\function{T}{B}{t}{b_t} $$\nextends to a homomorphism $ g' : F \\to B $. Now define $ g : M \\to B $ by $ g = g' \\circ \\iota_M $. We need to show $ f = \\beta \\circ g $. Take $ m \\in M $. Then $ \\iota_M\\br{m} = \\br{m, 0} \\in F $ can be written as $ \\sum_i r_it_i $, where $ t_i \\in T $ and $ r_i \\in R $. Applying $ \\pi_M $, $ m = \\sum_i r_im_{t_i} $. Then\n$$ g\\br{m} = \\br{g' \\circ \\iota_M}\\br{m} = g'\\br{\\sum_i r_it_i} = \\sum_i r_ib_{t_i}. $$\nSo\n$$ \\br{\\beta \\circ g}\\br{m} = \\beta\\br{\\sum_i r_ib_{t_i}} = \\sum_i r_i\\beta\\br{b_{t_i}} = \\sum_i r_if\\br{m_{t_i}} = f\\br{\\sum_i r_im_{t_i}} = f\\br{m}. $$\nHence $ \\beta \\circ g = f $. So $ M $ is projective, as required.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Injective modules}\n\n\\begin{definition}\nLet $ M $ be an $ R $-module. Then $ M $ is \\textbf{injective} if whenever $ \\alpha : M \\to B $ is an injective map, it has a retraction $ \\rho : B \\to M $, so $ \\rho \\circ \\alpha = \\id_M $. Equivalently, every short exact sequence\n$$ 0 \\to M \\to B \\to C \\to 0 $$\nsplits.\n\\end{definition}\n\n\\begin{example*}\nLet $ k $ be a field. Then $ k $-modules are vector spaces. Every $ k $-module is injective. Suppose $ M $ and $ N $ are $ k $-vector spaces and $ \\alpha : M \\to N $ is a injective map. Then $ \\im \\alpha $ is a submodule, or subspace, of $ N $. Take a basis for $ \\im \\alpha $, and extend to a basis for $ N $. The basis vectors not in $ \\im \\alpha $ form a basis for a complementary subspace $ U $, so $ N = \\im \\alpha \\oplus U $. Now $ \\pi_{\\im \\alpha} $ is surjective, and $ \\alpha : M \\to \\im \\alpha $ is an isomorphism. This gives a retraction $ N \\to M $.\n\\end{example*}\n\nIf $ R $ is a general ring, the module $ R $ need not be injective.\n\n\\begin{example*}\nLet $ R = \\ZZ $. Then $ R $-modules are abelian groups. There exists an injective $ \\alpha : \\ZZ \\to \\QQ $. But $ \\ZZ $ is not a quotient of $ \\QQ $, \\footnote{Exercise} so no retraction exists for $ \\alpha $.\n\\end{example*}\n\n\\begin{proposition}\nAn $ R $-module $ M $ is injective if and only if whenever $ \\alpha : A \\to B $ is injective, and $ f : A \\to M $, there exists $ g : B \\to M $ such that $ f = g \\circ \\alpha $.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\impliedby $] Suppose that whenever $ \\alpha : A \\to B $ is injective, and $ f : A \\to M $, there exists $ g : B \\to M $ such that $ f = g \\circ \\alpha $. Suppose that $ \\alpha : M \\to B $ is injective. We have a map $ M \\to M $, namely $ \\id_M $. There exists $ g : B \\to M $ such that $ \\id_M = g \\circ \\alpha $. So $ g $ is a retraction for $ \\alpha $, and so $ M $ is injective.\n\\item[$ \\implies $] For the converse, suppose $ \\alpha : A \\to B $ is injective, and $ M $ is an injective module, with $ f : A \\to M $. We define a module $ Y $ completing a square\n$$\n\\begin{tikzcd}\nA \\arrow{r}{\\alpha} \\arrow{d}[swap]{f} & B \\arrow{d}{\\delta} \\\\\nM \\arrow{r}[swap]{\\epsilon} & Y\n\\end{tikzcd},\n$$\nwith $ \\epsilon \\circ f = \\delta \\circ \\alpha $. Let $ Y $ be a quotient of $ B \\oplus M $, by the kernel\n$$ K = \\cbr{\\br{\\alpha\\br{a}, -f\\br{a}} \\st a \\in A}. $$\nLet $ \\gamma : B \\oplus M \\to \\br{B \\oplus M} / K $ be the canonical quotient map. Then we define $ \\delta = \\gamma \\circ \\iota_B $ and $ \\epsilon = \\gamma \\circ \\iota_M $. By construction, we have\n\\begin{align*}\n\\br{\\epsilon \\circ f}\\br{a}\n& = \\br{\\gamma \\circ \\iota_M \\circ f}\\br{a}\n= \\gamma\\br{0, f\\br{a}}\n= \\br{0, f\\br{a}} + K \\\\\n& = \\br{\\alpha\\br{a}, 0} + K\n= \\gamma\\br{\\alpha\\br{a}, 0}\n= \\br{\\gamma \\circ \\iota_B \\circ \\alpha}\\br{a}\n= \\br{\\delta \\circ \\alpha}\\br{a},\n\\end{align*}\nsince $ \\br{\\alpha\\br{a}, -f\\br{a}} \\in K $. Hence $ \\epsilon \\circ f = \\delta \\circ \\alpha $ as stated. Claim that $ \\epsilon $ is injective. Suppose $ \\epsilon\\br{m} = 0 $. Then $ \\iota_M\\br{m} \\in K $, so $ \\br{0, m} = \\br{\\alpha\\br{a}, -f\\br{a}} $ for some $ a \\in A $. But $ \\alpha\\br{a} = 0 $, so $ a = 0 $, and so $ m = -f\\br{0} = 0 $. Since $ M $ is injective, $ \\epsilon $ has a retraction $ \\rho : Y \\to M $. Define $ g : B \\to M $ by $ g = \\rho \\circ \\delta $, so\n$$\n\\begin{tikzcd}\nA \\arrow{r}{\\alpha} \\arrow{d}[swap]{f} & B \\arrow[dashed]{dl}[swap]{g} \\arrow{d}{\\delta} \\\\\nM \\arrow[bend right=15]{r}[swap]{\\epsilon} & Y \\arrow[bend right=15, dashed]{l}[swap]{\\rho}\n\\end{tikzcd},\n$$\nWe know that $ \\br{\\epsilon \\circ f}\\br{a} = \\br{\\delta \\circ \\alpha}\\br{a} $ for all $ a \\in A $. So\n$$ f\\br{a} = \\br{\\id_M \\circ f}\\br{a} = \\br{\\rho \\circ \\epsilon \\circ f}\\br{a} = \\br{\\rho \\circ \\delta \\circ \\alpha}\\br{a} = \\br{g \\circ \\alpha}\\br{a}, $$\nso $ f = g \\circ \\alpha $ as required.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\nWe know that projectives are direct summands of free modules. We might hope for a dual version of this for injective modules. But there is no straightforward way of doing this.\n\n\\lecture{5}{Monday}{20/01/20}\n\n\\begin{proposition}[Baer's criterion for injectivity]\nLet $ M $ be an $ R $-module. Then $ M $ is injective if and only if every $ R $-module map $ f : I \\to M $, where $ I $ is a left ideal of $ R $, has the form $ f\\br{x} = xm $ for some $ m \\in M $. Equivalently, every map $ I \\to M $ extends to a map $ R \\to M $.\n\\end{proposition}\n\nWhy are these two conditions equivalent? If $ f\\br{x} = xm $ for $ x \\in I $, then we can extend $ f $ to $ R $ by $ f\\br{r} = rm $. Conversely, suppose that $ f : I \\to M $ extends to $ f^+ : R \\to M $. Let $ m = f^+\\br{1} $. Then for all $ r \\in R $, $ f^+\\br{r} = rm $, and so $ f\\br{x} = xm $ for $ x \\in I $. The proof requires Zorn's lemma.\n\n\\begin{lemma}[Zorn's lemma]\nLet $ X $ be a non-empty set, partially ordered by $ \\le $. If every chain, or totally ordered subset, in $ X $ has an upper bound in $ X $, then $ X $ has a maximal element.\n\\end{lemma}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\impliedby $] Suppose $ \\alpha : A \\to B $, where $ \\alpha $ is injective. Suppose $ f : A \\to M $. We want to show there exists $ g : B \\to M $ such that $ f = g \\circ \\alpha $. We have $ \\im \\alpha \\le B $. Define\n$$ X = \\cbr{\\br{L, h} \\st \\im \\alpha \\le L \\le B, \\ h : L \\to M, \\ f = h \\circ \\alpha}. $$\nNote that $ X \\ne \\emptyset $ since $ \\br{\\im \\alpha, f \\circ \\alpha^{-1}} $ is in it. Define $ \\le $ on $ X $ by $ \\br{L_1, h_1} \\le \\br{L_2, h_2} $ if $ L_1 \\le L_2 $ and $ h_2 $ extends $ h_1 $, so $ \\eval{h_2}_{L_1} = h_1 $. Suppose $ \\cbr{\\br{L_s, h_s} \\st s \\in S} $ is a chain in $ X $. Set $ L = \\bigcup_{s \\in S} L_s $. Then $ \\im \\alpha \\le L \\le B $. Define\n$$ \\function[h]{L}{M}{l}{h_s\\br{l}}, \\qquad l \\in L_s. $$\nThis does not depend on the choice of $ s $. Then $ \\br{L, h} $ is an upper bound for the chain $ \\cbr{\\br{L_s, h_s} \\st s \\in S} $. Hence $ X $ has a maximal element, $ \\br{L_0, h_0} $. We want to show that $ L_0 = B $. Then we may set $ g = h_0 $. Suppose that $ L_0 \\ne B $. Let $ b \\in B \\setminus L_0 $. Note that $ Rb \\le B $. Consider\n$$ L_0 + Rb = \\cbr{l + rb \\st l \\in L_0, \\ r \\in R} \\le B. $$\nWe would like to extend $ h_0 $ to $ h_0^+ $ by specifying an image for $ h_0^+\\br{b} $. The problem is that $ Rb \\cap L_0 $ may not be $ \\cbr{0} $, and if $ rb \\in L_0 $ then we require $ rh_0^+\\br{b} = h_0\\br{rb} $, otherwise $ h_0^+ $ will not be well-defined. Note that $ I = \\cbr{r \\in R \\st rb \\in L_0} $ is a left ideal for $ R $. Suppose that $ M $ has the condition from Baer's criterion, so every map $ I \\to M $ has the form $ x \\mapsto xm $ for some $ m \\in M $. Note that $ \\cbr{xb \\st x \\in I} $ is a submodule of $ L_0 $. Define a map\n$$ \\function[\\delta]{I}{M}{x}{h_0\\br{xb}}. $$\nThis is an $ R $-module homomorphism. So $ \\delta\\br{x} = xm $ for some $ m \\in M $. Hence $ h_0\\br{xb} = xm $ for all $ x \\in I $. So we can safely define $ h_0^+\\br{b} = m $. Now $ \\br{L_0 + Rb, h_0^+} \\in X $, and $ \\br{L_0, h_0} < \\br{L_0 + Rb, h_0^+} $, which contradicts the maximality of $ \\br{L_0, h_0} $. Hence $ L_0 = B $, and we are done.\n\\item[$ \\implies $] The converse is left as an exercise. \\footnote{Exercise}\n\\end{itemize}\n\\end{proof}\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item Suppose $ R $ is a field. Then the only ideals of $ R $ are zero and $ R $. Any map $ 0 \\to M $, for $ M $ an $ R $-module, can be extended to the zero map $ R \\to M $. Hence any $ R $-module is injective.\n\\item Let $ \\ZZ $ be a module for itself. The ideals of $ \\ZZ $ are $ k\\ZZ $ for $ k \\in \\ZZ $. Define\n$$ \\function[f]{k\\ZZ}{\\ZZ}{km}{m}. $$\nIf $ k \\ne 0, \\pm 1 $, then $ f\\br{k} = 1 $, and so $ f\\br{x} \\ne xm $ for $ m \\in \\ZZ $, since one is not divisible by $ k $ in $ \\ZZ $. So Baer's criterion fails, and $ \\ZZ $ is not injective. We already knew that $ \\ZZ \\to \\QQ $ has no retraction.\n\\item $ \\QQ $ is injective as a $ \\ZZ $-module. Suppose we have a map $ f : k\\ZZ \\to \\QQ $ for $ k \\ne 0 $. Let $ q = f\\br{k} $. Then $ f\\br{kt} = qt = \\br{q / k}kt $. So $ f\\br{x} = x\\br{q / k} $ for all $ x $, so $ \\QQ $ satisfies Baer's criterion.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\n\\section{Hom and tensor products}\n\n\\subsection{Hom}\n\n\\lecture{6}{Tuesday}{21/01/20}\n\nLet $ A $ and $ B $ be two $ R $-modules.\n\n\\begin{definition}\nDefine\n$$ \\Hom_R\\br{A, B} = \\cbr{\\text{$ R $-module homomorphisms} \\ A \\to B}. $$\n\\end{definition}\n\nWe can define a natural addition on $ \\Hom_R\\br{A, B} $ by defining $ f_1 + f_2 $ by\n$$ \\br{f_1 + f_2}\\br{a} = f_1\\br{a} + f_2\\br{b}, \\qquad f_1, f_2 \\in \\Hom_R\\br{A, B}. $$\nThis gives $ \\Hom_R\\br{A, B} $ the structure of an abelian group. Why does $ \\Hom_R\\br{A, B} $ not carry an $ R $-module structure in general? The only obvious candidate for $ rf $ is\n$$ \\br{rf}\\br{a} = rf\\br{a} = f\\br{ra}, \\qquad r \\in R, \\qquad f \\in \\Hom_R\\br{A, B}. $$\nNow suppose $ s \\in R $. We have $ \\br{rf}\\br{sa} = rf\\br{sa} = rsf\\br{a} $. But for $ rf $ to be a homomorphism, we would need $ \\br{rf}\\br{sa} = s\\br{rf}\\br{a} = srf\\br{a} $. If $ R $ is non-commutative, then $ rs $ may not be $ sr $, and so $ rf $ is not an $ R $-module homomorphism in general. Clearly, however, if $ R $ is commutative then $ rf $ is an $ R $-module homomorphism, and $ \\Hom_R\\br{A, B} $ has an $ R $-module structure. The following are observations.\n\n\\begin{proposition}\nSuppose $ A, A_1, A_2, B, B_1, B_2, M $ are $ R $-modules, and $ \\alpha : A \\to B $.\n\\begin{itemize}\n\\item $ \\Hom_R\\br{A_1 \\oplus A_2, B} \\cong \\Hom_R\\br{A_1, B} \\oplus \\Hom_R\\br{A_2, B} $.\n\\item $ \\Hom_R\\br{A, B_1 \\oplus B_2} \\cong \\Hom_R\\br{A, B_1} \\oplus \\Hom_R\\br{A, B_2} $.\n\\item We can define\n$$ \\function[\\alpha_*]{\\Hom_R\\br{M, A}}{\\Hom_R\\br{M, B}}{f}{\\alpha \\circ f}, \\qquad f : M \\to A. $$\n\\item We can also define\n$$ \\function[\\alpha^*]{\\Hom_R\\br{B, M}}{\\Hom_R\\br{A, M}}{g}{g \\circ \\alpha}, \\qquad g : B \\to M. $$\n\\end{itemize}\n\\end{proposition}\n\nThus Hom is a bifunctor between the category of $ R $-modules and the category of abelian groups, additive in both arguments, covariant in the second argument and contravariant in the first argument.\n\\begin{itemize}\n\\item \\textbf{Bi} means Hom takes two arguments.\n\\item \\textbf{Functor} means that homomorphisms between $ R $-modules turn into abelian group homomorphisms.\n\\item \\textbf{Covariant} means the homomorphism goes in the same direction.\n\\item \\textbf{Contravariant} means the direction gets reversed.\n\\item \\textbf{Additive} in both arguments means Hom respects direct sums.\n\\end{itemize}\n\n\\begin{proposition}\nSuppose $ \\alpha : A \\to B $ is surjective. Then $ \\alpha^* : \\Hom_R\\br{B, M} \\to \\Hom_R\\br{A, M} $ is injective.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ f_1, f_2 : B \\to M $ are such that $ \\alpha^*f_1 = \\alpha^*f_2 $. Then $ f_1 \\circ \\alpha = f_2 \\circ \\alpha $, so $ \\br{f_1 \\circ \\alpha}\\br{a} = \\br{f_2 \\circ \\alpha}\\br{a} $ for all $ a \\in A $. Let $ b \\in B $. Then $ b = \\alpha\\br{a} $ for some $ a $, since $ \\alpha $ is surjective, so $ f_1\\br{b} = \\br{f_1 \\circ \\alpha}\\br{a} = \\br{f_2 \\circ \\alpha}\\br{a} = f_2\\br{b} $, so $ f_1 = f_2 $.\n\\end{proof}\n\n\\begin{proposition}\nSuppose $ \\alpha : A \\to B $ is injective. Then $ \\alpha_* : \\Hom_R\\br{M, A} \\to \\Hom_R\\br{M, B} $ is injective.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ f_1, f_2 : M \\to A $, and $ \\alpha_*f_1 = \\alpha_*f_2 $. Then $ \\alpha \\circ f_1 = \\alpha \\circ f_2 $, so $ \\br{\\alpha \\circ f_1}\\br{m} = \\br{\\alpha \\circ f_2}\\br{m} $ for all $ m \\in M $. But $ \\alpha $ is injective, so this implies $ f_1\\br{m} = f_2\\br{m} $ for all $ m \\in M $.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{proposition}\nSuppose\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0 $$\nis a short exact sequence of $ R $-modules. Then we have an exact sequence\n$$ 0 \\to \\Hom_R\\br{C, M} \\xrightarrow{\\beta^*} \\Hom_R\\br{B, M} \\xrightarrow{\\alpha^*} \\Hom_R\\br{A, M}. $$\n\\end{proposition}\n\n\\begin{proof}\nThis is exact at $ \\Hom_R\\br{C, M} $, since $ \\beta^* $ is injective. Claim that the sequence is also exact at $ \\Hom_R\\br{B, M} $, so it is an exact sequence. It is not necessarily a short exact sequence since $ \\alpha^* $ is not generally surjective. Let $ g : B \\to M $. We have\n$$ g \\in \\ker \\alpha^* \\iff \\alpha^*g = 0 \\iff g \\circ \\alpha = 0 \\iff \\br{g \\circ \\alpha}\\br{A} = 0 \\iff \\im \\alpha \\le \\ker g \\iff \\ker \\beta \\le \\ker g, $$\nThen $ g \\in \\ker \\alpha^* $ if and only if for all $ b_1, b_2 \\in B $, $ \\beta\\br{b_1} = \\beta\\br{b_2} $ implies that $ g\\br{b_1} = g\\br{b_2} $, which is if and only if the $ R $-module homomorphism defined by\n$$ \\function[f]{C}{M}{c}{g\\br{b}}, \\qquad \\beta\\br{b} = c $$\nis well-defined, since $ \\beta $ is surjective. Thus\n$$ g \\in \\ker \\alpha^* \\qquad \\iff \\qquad \\exists f \\in \\Hom_R\\br{C, M}, \\ \\beta^*f = g \\qquad \\iff \\qquad g \\in \\im \\beta^*. $$\nHence $ \\ker \\alpha^* = \\im \\beta^* $. So the sequence is exact at $ \\Hom_R\\br{B, M} $.\n\\end{proof}\n\n\\lecture{7}{Friday}{24/01/20}\n\n\\begin{example*}\nThese examples show that $ \\alpha : A \\to B $ is injective does not imply $ \\alpha^* : \\Hom_R\\br{B, M} \\to \\Hom_R\\br{A, M} $ is surjective.\n\\begin{itemize}\n\\item The inclusion $ \\alpha : \\ZZ \\to \\QQ $ is a $ \\ZZ $-module homomorphism. Let $ M = \\ZZ $. Then we get $ \\alpha^* : \\Hom_\\ZZ\\br{\\QQ, \\ZZ} \\to \\Hom_\\ZZ\\br{\\ZZ, \\ZZ} $. Then $ \\alpha $ is injective, but $ \\alpha^* $ is not surjective. Why is this? In fact $ \\Hom_\\ZZ\\br{\\QQ, \\ZZ} = 0 $. Suppose\n$$ \\function[f]{\\QQ}{\\ZZ}{1}{k \\ne 0}. $$\nSuppose $ p \\nmid k $. Then there is no possible image for $ 1 / p \\in \\QQ $, since we would require $ pf\\br{1 / p} = f\\br{1} = k $. But $ \\Hom_\\ZZ\\br{\\ZZ, \\ZZ} \\cong \\ZZ $, so $ \\alpha^* $ is not surjective.\n\\item Let $ \\alpha : k\\ZZ \\to \\ZZ $ be the inclusion, so $ \\alpha $ is injective and not surjective. Let $ M = \\ZZ $. So we get $ \\alpha^* : \\Hom_\\ZZ\\br{\\ZZ, \\ZZ} \\to \\Hom_\\ZZ\\br{k\\ZZ, \\ZZ} $. Suppose that $ g \\in \\im \\alpha^* $. Then $ g = f \\circ \\alpha $, where $ f : \\ZZ \\to \\ZZ $. Then $ g\\br{k} = f\\br{k} = kf\\br{1} $, so $ \\im g \\le k\\ZZ $. But there exists $ g \\in \\Hom_\\ZZ\\br{k\\ZZ, \\ZZ} $ such that $ g\\br{k} = 1 $. So this $ g \\notin \\im \\alpha^* $, so $ \\alpha^* $ is not surjective.\n\\end{itemize}\n\\end{example*}\n\n\\begin{proposition}\nLet\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0 $$\nbe exact. Then\n$$ 0 \\to \\Hom_R\\br{M, A} \\xrightarrow{\\alpha_*} \\Hom_R\\br{M, B} \\xrightarrow{\\beta_*} \\Hom_R\\br{M, C} $$\nis exact.\n\\end{proposition}\n\n\\begin{proof}\nWe already know that $ \\alpha $ injective implies that $ \\alpha_* $ is injective, so the sequence is exact at $ \\Hom_R\\br{M, A} $. We show that $ \\ker \\beta_* = \\im \\alpha_* $. Suppose $ g \\in \\Hom_R\\br{M, B} $. Then\n$$ g \\in \\ker \\beta_* \\qquad \\iff \\qquad \\br{\\beta \\circ g}\\br{M} = 0 \\qquad \\iff \\qquad \\im g \\le \\ker \\beta \\qquad \\iff \\qquad \\im g \\le \\im \\alpha. $$\nNote there exists $ \\alpha^{-1} : \\im \\alpha \\to A $. If $ \\im g \\le \\im \\alpha $, then $ \\alpha^{-1} \\circ g : M \\to A $. If $ f = \\alpha^{-1} \\circ g $, then $ \\alpha \\circ f = g $, so $ g \\in \\im \\alpha_* $. Conversely, if $ g \\in \\im \\alpha_* $, then $ g = \\alpha \\circ f $ for some $ f \\in \\Hom_R\\br{M, A} $ and so $ \\im g \\le \\im \\alpha $. So\n$$ g \\in \\ker \\beta_* \\qquad \\iff \\qquad \\im g \\le \\im \\alpha \\qquad \\iff \\qquad g \\in \\im \\alpha_*. $$\nHence $ \\ker \\beta_* = \\im \\alpha_* $. So the sequence is exact at $ \\Hom_R\\br{M, B} $.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{example*}\nThese examples show that $ \\beta : B \\to C $ is surjective does not imply $ \\beta_* : \\Hom_R\\br{M, B} \\to \\Hom_R\\br{M, C} $ is surjective.\n\\begin{itemize}\n\\item Let\n$$ \\function[\\beta]{\\sum_{q \\in \\QQ} \\ZZ}{\\QQ}{e_q}{q}. $$\nIn general $ \\beta : \\sum_{m \\in M} R \\to M $ defined by mapping the basis vector $ e_m $ to $ m $, is a surjective homomorphism, so $ \\beta $ is surjective. Let $ M = \\QQ $. So we get $ \\beta_* : \\Hom_\\ZZ\\br{\\QQ, \\sum_{q \\in \\QQ} \\ZZ} \\to \\Hom_\\ZZ\\br{\\QQ, \\QQ} $. Claim that $ \\Hom_\\ZZ\\br{\\QQ, \\sum_{q \\in \\QQ} \\ZZ} $ is trivial. Suppose $ f : \\QQ \\to \\sum_{q \\in \\QQ} \\ZZ $ is not zero. Suppose $ f\\br{q_0} \\ne 0 $. Then there exist $ q_1, \\dots, q_t \\in \\QQ $ and $ a_1, \\dots, a_t \\in \\ZZ $ such that $ f\\br{q_0} = \\sum_{i = 1}^t a_ie_{q_i} $. Now the projection of $ \\sum_{q \\in \\QQ} \\ZZ $ onto $ \\ZZ e_{q_1} $ is a non-trivial $ \\ZZ $-module homomorphism. But $ \\ZZ e_{q_1} \\cong \\ZZ $, and so no non-trivial map $ \\QQ \\to \\ZZ e_{q_1} $ exists. But $ \\Hom_\\ZZ\\br{\\QQ, \\QQ} $ is not trivial, so $ \\beta_* $ is not surjective.\n\\item Let\n$$ 0 \\to \\ZZ_2 \\to \\ZZ_4 \\to \\ZZ_2 \\to 0 $$\nbe a short exact sequence of $ \\ZZ $-modules. Then we have\n$$\n\\begin{tikzcd}[row sep=tiny]\n0 \\arrow{r} & \\Hom_\\ZZ\\br{\\ZZ_2, \\ZZ_2} \\arrow{r}{\\alpha_*} \\arrow[cong]{d} & \\Hom_\\ZZ\\br{\\ZZ_2, \\ZZ_4} \\arrow{r}{\\beta_*} \\arrow[cong]{d} & \\Hom_\\ZZ\\br{\\ZZ_2, \\ZZ_2} \\arrow[cong]{d} \\\\\n& \\ZZ_2 & \\ZZ_2 & \\ZZ_2\n\\end{tikzcd}.\n$$\nBut there is no short exact sequence of abelian groups\n$$ 0 \\to \\ZZ_2 \\to \\ZZ_2 \\to \\ZZ_2 \\to 0, $$\nand so $ \\beta_* $ cannot be surjective.\n\\end{itemize}\n\\end{example*}\n\n\\begin{proposition}\nLet $ M $ be an $ R $-module. Then $ M $ is injective if and only if for every injective map $ \\alpha : A \\to B $, we get $ \\alpha^* : \\Hom_R\\br{B, M} \\to \\Hom_R\\br{A, M} $ is surjective.\n\\end{proposition}\n\n\\begin{proof}\n$ M $ is injective if and only if for all injective $ \\alpha : A \\to B $ and for all $ f \\in \\Hom_R\\br{A, M} $, there exists $ g \\in \\Hom_R\\br{B, M} $ such that $ f = g \\circ \\alpha $, so $ f = \\alpha^*g $. This is if and only if for all injective $ \\alpha : A \\to B $, $ f \\in \\im \\alpha^* $ for all $ f \\in \\Hom_R\\br{A, M} $, which is if and only if $ \\alpha^* $ is surjective.\n\\end{proof}\n\n\\begin{proposition}\nLet $ M $ be an $ R $-module. Then $ M $ is projective if and only if whenever $ \\beta : B \\to C $ is surjective, the map $ \\beta_* : \\Hom_R\\br{M, B} \\to \\Hom_R\\br{M, C} $ is surjective.\n\\end{proposition}\n\n\\begin{proof}\n$ M $ is projective if and only if whenever $ \\beta : B \\to C $ is surjective, and $ f \\in \\Hom_R\\br{M, C} $, there exists $ g \\in \\Hom_R\\br{M, B} $ such that $ f = \\beta \\circ g $. This is if and only if whenever $ \\beta : B \\to C $ is surjective, and $ f \\in \\Hom_R\\br{M, C} $, then $ f \\in \\im \\beta_* $, which is if and only if $ \\beta_* $ is surjective.\n\\end{proof}\n\n\\subsection{The snake lemma}\n\n\\lecture{8}{Monday}{27/01/20}\n\nLet $ \\alpha : A \\to B $ be an $ R $-module homomorphism. The \\textbf{cokernel} of $ \\alpha $ is $ B / \\im \\alpha $, written $ \\coker \\alpha $. The sequence\n$$ 0 \\to \\ker \\alpha \\to A \\xrightarrow{\\alpha} B \\to \\coker \\alpha \\to 0 $$\nis exact.\n\n\\begin{lemma}[The snake lemma]\nSuppose we have a commutative diagram\n$$\n\\begin{tikzcd}\n& A \\arrow{r}{\\alpha} \\arrow{d}{f} & B \\arrow{r}{\\beta} \\arrow{d}{g} & C \\arrow{r} \\arrow{d}{h} & 0 \\\\\n0 \\arrow{r} & X \\arrow{r}[swap]{\\phi} & Y \\arrow{r}[swap]{\\psi} & Z &\n\\end{tikzcd},\n$$\nwhere the rows are exact. Then we obtain an exact sequence\n$$ \\ker f \\xrightarrow{\\alpha} \\ker g \\xrightarrow{\\beta} \\ker h \\xrightarrow{\\delta} \\coker f \\xrightarrow{\\overline{\\phi}} \\coker g \\xrightarrow{\\overline{\\psi}} \\coker h. $$\n\\end{lemma}\n\n\\pagebreak\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item The maps $ \\alpha : \\ker f \\to \\ker g $ and $ \\beta : \\ker g \\to \\ker h $ are obtained simply by restricting $ \\alpha $ and $ \\beta $ respectively. Observe that if $ a \\in \\ker f $ then $ f\\br{a} = 0 $, so $ \\br{\\phi \\circ f}\\br{a} = 0 $. But $ \\phi \\circ f = g \\circ \\alpha $, and so $ \\br{g \\circ \\alpha}\\br{a} = 0 $, so $ \\alpha\\br{a} \\in \\ker g $, which is what we wanted. Similarly for $ \\beta : \\ker g \\to \\ker h $.\n\\item The maps $ \\overline{\\phi} : \\coker f \\to \\coker g $ and $ \\overline{\\psi} : \\coker g \\to \\coker h $ are induced from $ \\phi $ and $ \\psi $ by\n$$ \\overline{\\phi}\\br{x + \\im f} = \\phi\\br{x} + \\im g, \\qquad \\overline{\\psi}\\br{y + \\im g} = \\psi\\br{y} + \\im h. $$\nCheck that these maps make sense. Suppose $ x_1 + \\im f = x_2 + \\im f $. Then $ x_1 - x_2 \\in \\im f $, so there exists $ a \\in A $ such that $ f\\br{a} = x_1 - x_2 $. Now\n$$ \\phi\\br{x_1} - \\phi\\br{x_2} = \\phi\\br{x_1 - x_2} = \\br{\\phi \\circ f}\\br{a} = \\br{g \\circ \\alpha}\\br{a} \\in \\im g. $$\nSo $ \\phi\\br{x_1} + \\im g = \\phi\\br{x_2} + \\im g $. So $ \\overline{\\phi} $ is well-defined, and $ \\overline{\\psi} $ is shown to be well-defined by a similar argument.\n\\item How is the \\textbf{connecting homomorphism} $ \\delta $ defined? Since $ \\beta $ is surjective, for all $ c \\in C $, there exists $ b \\in B $ with $ \\beta\\br{b} = c $. Suppose $ c \\in \\ker h $. Then $ \\br{h \\circ \\beta}\\br{b} = 0 $, so $ \\br{\\psi \\circ g}\\br{b} = 0 $. Hence $ g\\br{b} \\in \\ker \\psi = \\im \\phi $. Define\n$$ \\delta\\br{c} = x + \\im f, \\qquad \\phi\\br{x} = g\\br{b}, \\qquad \\beta\\br{b} = c. $$\nCheck this is well-defined. Suppose $ b_1, b_2, x_1, x_2 $ are such that $ \\phi\\br{x_1} = g\\br{b_1} $ and $ \\phi\\br{x_2} = g\\br{b_2} $, and $ \\beta\\br{b_1} = \\beta\\br{b_2} = c $. We have $ b_1 - b_2 \\in \\ker \\beta = \\im \\alpha $. So $ b_1 - b_2 = \\alpha\\br{a} $ for some $ a \\in A $. Then\n$$ \\br{\\phi \\circ f}\\br{a} = \\br{g \\circ \\alpha}\\br{a} = g\\br{b_1 - b_2} = g\\br{b_1} - g\\br{b_2} = \\phi\\br{x_1} - \\phi\\br{x_2} = \\phi\\br{x_1 - x_2}. $$\nBut $ \\phi $ is injective, and so $ f\\br{a} = x_1 - x_2 $, and so $ x_1 + \\im f = x_2 + \\im f $. So $ \\delta $ is well-defined.\n\\end{itemize}\nExactness of the sequence is an exercise, on problem sheet. \\footnote{Exercise}\n\\end{proof}\n\n\\subsection{Tensor products}\n\n\\begin{definition}\nLet $ M $ be a left $ R $-module, and let $ L $ be a right $ R $-module. The \\textbf{tensor product} $ L \\otimes_R M $ is an abelian group generated as an abelian group by a set of \\textbf{pure tensors} $ \\cbr{l \\otimes m \\st l \\in L, \\ m \\in M} $ subject to the relations\n$$ l_1 \\otimes m + l_2 \\otimes m = \\br{l_1 + l_2} \\otimes m, \\qquad l_1, l_2 \\in L, \\qquad m \\in M, $$\n$$ l \\otimes m_1 + l \\otimes m_2 = l \\otimes \\br{m_1 + m_2}, \\qquad l \\in L, \\qquad m_1, m_2 \\in M, $$\n$$ \\br{lr} \\otimes m = l \\otimes \\br{rm}, \\qquad l \\in L, \\qquad m \\in M, \\qquad r \\in R. $$\n\\end{definition}\n\nThe following are observations.\n\\begin{itemize}\n\\item In general, not every element of $ L \\otimes_R M $ is a pure tensor. A general element of $ L \\otimes_R M $ is a $ \\ZZ $-linear combination of pure tensors.\n\\item If $ R $ is commutative, $ L $ can be a left module, since left and right modules are the same. Also, in this case, $ L \\otimes_R M $ has an $ R $-module structure, by $ r\\br{l \\otimes m} = rl \\otimes m $.\n\\item Suppose that $ S $ is a set of generators for $ L $, as an abelian group, and $ T $ is a set of generators for $ M $, as an abelian group. Then a smaller generating set for $ L \\otimes_R M $ is $ \\cbr{s \\otimes t \\st s \\in S, \\ t \\in T} $. This is because if\n$$ l = \\sum_{i = 1}^p a_is_i, \\qquad m = \\sum_{j = 1}^q b_jt_j, \\qquad s_i \\in S, \\qquad t_i \\in T, \\qquad a_i, b_i \\in \\ZZ, $$\nthen, from the relations,\n$$ l \\otimes m = \\sum_{i = 1}^p \\sum_{j = 1}^q a_ib_j\\br{s_i \\otimes t_j}. $$\n\\end{itemize}\n\n\\pagebreak\n\n\\begin{example*}\nTensor products can be counter intuitive, such as $ \\ZZ_2 \\otimes_\\ZZ \\ZZ_3 = 0 $. Why? Observe that for $ x \\in \\ZZ_2 $, $ x3 = 3x = x $. So\n$$ x \\otimes y = x3 \\otimes y = x \\otimes 3y = x \\otimes 0 = x \\otimes y - x \\otimes y = 0, \\qquad x \\in \\ZZ_2, \\qquad y \\in \\ZZ_3. $$\n\\end{example*}\n\n\\lecture{9}{Tuesday}{28/01/20}\n\n\\begin{theorem}[Universal property of tensor products]\nLet $ A $ be a right $ R $-module and $ B $ a left $ R $-module. Let $ C $ be an abelian group. Let $ f : A \\times B \\to C $ be a map, not necessarily a homomorphism, which is $ \\ZZ $-linear in both arguments, so\n$$ f\\br{a_1 + a_2, b} = f\\br{a_1, b} + f\\br{a_2, b}, \\qquad a_1, a_2 \\in A, \\qquad b \\in B, $$\n$$ f\\br{a, b_1 + b_2} = f\\br{a, b_1} + f\\br{a, b_2}, \\qquad a \\in A, \\qquad b_1, b_2 \\in B, $$\nand such that\n$$ f\\br{ar, b} = f\\br{a, rb}, \\qquad a \\in A, \\qquad b \\in B, \\qquad r \\in R. $$\nThen there is a unique homomorphism\n$$ \\function[g]{A \\otimes_R B}{C}{a \\otimes b}{f\\br{a, b}}. $$\n\\end{theorem}\n\n\\begin{proof}\nIn formal group theoretic terms, the tensor product $ A \\otimes_R B $ is a quotient $ F / K $, where $ F $ is the free abelian group on the set of pure tensors $ a \\otimes b $, and $ K $ is the subgroup of $ F $ generated by elements of the form\n$$ \\br{a_1 + a_2} \\otimes b - a_1 \\otimes b - a_2 \\otimes b, \\qquad a \\otimes \\br{b_1 + b_2} - a \\otimes b_1 - a \\otimes b_2, \\qquad ar \\otimes b - a \\otimes rb. $$\nThe universal property of free abelian groups states that if $ F $ is free abelian on a set $ S $, then any set map $ S \\to C $, for $ C $ an abelian group, extends uniquely to a homomorphism $ F \\to C $. In the situation under discussion, we have a map\n$$ g' : \\cbr{a \\otimes b \\st a \\in A, \\ b \\in B} \\to C. $$\nSo $ g' $ extends uniquely to a homomorphism $ F \\to C $. The conditions stipulated on $ f $ guarantee that $ g'\\br{K} = 0 $. So $ g' $ induces a map $ g : F / K \\to C $, which is what we want, since $ F / K = A \\otimes_R B $. This establishes the existence of $ g $. Since the images of the pure tensors under $ g $ are specified, it is clear that $ g $ is unique.\n\\end{proof}\n\n\\begin{corollary}\n\\hfill\n\\begin{enumerate}\n\\item Let $ M $ be a left $ R $-module. Then $ R \\otimes_R M \\cong M $, via the map\n$$ \\function[f]{M}{R \\otimes_R M}{m}{1 \\otimes m}. $$\n\\item Let $ M $ be a right $ R $-module. Then $ M \\otimes_R R \\cong M $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item It is clear that $ f $ is a homomorphism of abelian groups. Now $ r \\otimes m = 1 \\otimes rm $, so $ R \\otimes_R M $ is generated by $ \\cbr{1 \\otimes m \\st m \\in M} $, so $ f $ is surjective. For injectivity of $ f $, we need the universal property. Define a bilinear map\n$$ \\function{R \\times M}{M}{\\br{r, m}}{rm}. $$\nThis induces a homomorphism\n$$ \\function[g]{R \\otimes_R M}{M}{r \\otimes m}{rm}. $$\nIt is easy to check that $ g $ is an inverse for $ f $, so $ f $ is bijective.\n\\item By the same argument as $ 1 $.\n\\end{enumerate}\n\\end{proof}\n\n\\pagebreak\n\n\\begin{corollary}\n\\hfill\n\\begin{enumerate}\n\\item Let $ A $ and $ B $ be right $ R $-modules, and $ C $ a left $ R $-module. Then $ \\br{A \\oplus B} \\otimes_R C \\cong \\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C} $, via the map\n$$ \\function[f]{\\br{A \\oplus B} \\otimes_R C}{\\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C}}{\\br{a, b} \\otimes c}{\\br{a \\otimes c, b \\otimes c}}. $$\n\\item Let $ A $ be a right $ R $-module, and $ B $ and $ C $ left $ R $-modules. Then $ A \\otimes_R \\br{B \\oplus C} \\cong \\br{A \\otimes_R B} \\oplus \\br{A \\otimes_R C} $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item Take a bilinear map, that is $ \\ZZ $-bilinear in both arguments, and respecting $ R $-multiplication,\n$$ \\function{A \\oplus B \\times C}{\\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C}}{\\br{\\br{a, b}, c}}{\\br{a \\otimes c, b \\otimes c}}. $$\nThis induces a homomorphism $ f : \\br{A \\oplus B} \\otimes_R C \\to \\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C} $ with the description as given above. Now take the bilinear map given by\n$$ \\function{A \\times C}{\\br{A \\oplus B} \\otimes_R C}{\\br{a, c}}{\\br{a, 0} \\otimes c}. $$\nThis induces a homomorphism $ g_1 : A \\otimes_R C \\to \\br{A \\oplus B} \\otimes_R C $. Similarly, we get a homomorphism $ g_2 : B \\otimes_R C \\to \\br{A \\oplus B} \\otimes_R C $. Now define\n$$ \\function[g = g_1 \\oplus g_2]{\\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C}}{\\br{A \\oplus B} \\otimes_R C}{\\br{x, y}}{g_1\\br{x} + g_2\\br{y}}. $$\nIt is easy to check that $ f $ and $ g $ are mutually inverse, so both isomorphisms.\n\\item Similarly.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{corollary}\nLet $ A $ be an abelian group. Then\n\\begin{enumerate}\n\\item $ \\ZZ_n \\otimes_\\ZZ A \\cong A / nA $, and\n\\item $ A \\otimes_\\ZZ \\ZZ_n \\cong A / nA $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item Define a map by\n$$ \\function[f]{A}{\\ZZ_n \\otimes_\\ZZ A}{a}{1 \\otimes a}. $$\nSuppose $ a_0 \\in A $ such that $ a_0 = na $ for some $ a $. Then $ f\\br{a_0} = 1 \\otimes a_0 = 1 \\otimes na = n \\otimes a = 0 $ so $ nA \\le \\ker f $. So $ f $ induces a map $ \\overline{f} : A / nA \\to \\ZZ_n \\otimes_\\ZZ A $. Notice that the pure tensor $ k \\otimes a $ is equal to $ 1 \\otimes ka $, so $ \\ZZ_n \\otimes_\\ZZ A $ is generated by $ \\cbr{1 \\otimes a \\st a \\in A} $. So $ \\overline{f} $ is surjective. For injectivity, use the universal property. We have a bilinear map\n$$ \\function[g]{\\ZZ_n \\times A}{A / nA}{\\br{k, a}}{ka + nA}. $$\nThis is well-defined and bilinear. So extends to a homomorphism $ \\overline{g} : \\ZZ_n \\otimes_\\ZZ A \\to A / nA $. It is easy to check that $ \\overline{g} \\circ \\overline{f} = \\id_{A / nA} $, so $ \\overline{f} $ is injective.\n\\item Similarly.\n\\end{enumerate}\n\\end{proof}\n\n\\pagebreak\n\n\\lecture{10}{Friday}{31/01/20}\n\n\\begin{proposition}\nLet $ \\alpha : A \\to B $ be a homomorphism of right $ R $-modules. Let $ M $ be a left $ R $-module. There is a unique abelian group homomorphism\n$$ \\function[\\alpha']{A \\otimes_R M}{B \\otimes_R M}{a \\otimes m}{\\alpha\\br{a} \\otimes m}, \\qquad a \\in A, \\qquad m \\in M. $$\n\\end{proposition}\n\n\\begin{proof}\nThe set map defined by\n$$ \\function[f]{A \\times M}{B \\otimes_R M}{\\br{a, m}}{\\alpha\\br{a} \\otimes m} $$\nis linear in both arguments, and we have\n$$ f\\br{ar, m} = \\alpha\\br{ar} \\otimes m = \\alpha\\br{a}r \\otimes m = \\alpha\\br{a} \\otimes rm = f\\br{a, rm}. $$\nNow by the universal property of tensor products, $ f $ gives rise to a unique homomorphism $ \\alpha' : A \\otimes_R M \\to B \\otimes_R M $ with the properties claimed.\n\\end{proof}\n\n\\begin{proposition}\nSuppose $ \\alpha : A \\to B $ is surjective. Then $ \\alpha' : A \\otimes_R M \\to B \\otimes_R M $ is surjective.\n\\end{proposition}\n\n\\begin{proof}\nSince $ \\alpha $ is surjective, every pure tensor $ b \\otimes m \\in B \\otimes_R M $ is equal to $ \\alpha\\br{a} \\otimes m $ for some $ a \\in A $. So $ b \\otimes m = \\alpha'\\br{a \\otimes m} \\in \\im \\alpha' $. Since $ B \\otimes_R M $ is generated by its pure tensors, $ \\alpha' $ is surjective.\n\\end{proof}\n\nAn observation is that it is not true that $ A \\to B $ is injective implies $ A \\otimes_R M \\to B \\otimes_R M $ is injective.\n\n\\begin{example*}\nLet\n$$ \\function[\\alpha]{\\ZZ_2}{\\ZZ_4}{1}{2}, $$\nwhich is injective. Consider\n$$ \\function[\\alpha']{\\ZZ_2 \\otimes_\\ZZ \\ZZ_2 \\cong \\ZZ_2}{\\ZZ_4 \\otimes_\\ZZ \\ZZ_2}{1 \\otimes 1}{2 \\otimes 1 = 1 \\otimes 2 = 0}. $$\nSo $ \\alpha' $ is the zero map, which is not injective.\n\\end{example*}\n\n\\begin{proposition}\nLet\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0 $$\nbe a short exact sequence of right $ R $-modules. Then the sequence\n$$ A \\otimes_R M \\xrightarrow{\\alpha'} B \\otimes_R M \\xrightarrow{\\beta'} C \\otimes_R M \\to 0 $$\nis exact.\n\\end{proposition}\n\n\\begin{proof}\nSince $ \\beta' $ is surjective, the sequence is exact at $ C \\otimes_R M $. We show it is exact at $ B \\otimes_R M $. Since $ \\beta $ is surjective, for every $ c \\in C $, there exists $ f\\br{c} \\in B $ such that $ \\beta\\br{f\\br{c}} = c $. Here $ f $ is a set map $ C \\to B $, which is not uniquely defined in general. Suppose that $ \\beta\\br{b} = c $. Then $ b - f\\br{c} \\in \\ker \\beta = \\im \\alpha $, so $ f\\br{c} + \\im \\alpha = b + \\im \\alpha $. Define a set map by\n$$ \\function[g]{C \\times M}{\\br{B \\otimes_R M} / \\im \\alpha'}{\\br{c, m}}{f\\br{c} \\otimes m + \\im \\alpha'}. $$\nNote that if $ \\beta\\br{b} = c $, then $ b \\otimes m - f\\br{c} \\otimes m = \\alpha\\br{a} \\otimes m \\in \\im \\alpha' $ for some $ a \\in A $. We can check that $ g $ is linear in both arguments. For example, for the first argument, we have $ g\\br{c_1 + c_2, m} = f\\br{c_1 + c_2} \\otimes m + \\im \\alpha' $. Now $ \\beta\\br{f\\br{c_1 + c_2}} = c_1 + c_2 = \\beta\\br{f\\br{c_1}} + \\beta\\br{f\\br{c_2}} = \\beta\\br{f\\br{c_1} + f\\br{c_2}} $ so\n$$ g\\br{c_1 + c_2, m} = \\br{f\\br{c_1} + f\\br{c_2}} \\otimes m + \\im \\alpha' = f\\br{c_1} \\otimes m + f\\br{c_2} \\otimes m + \\im \\alpha' = g\\br{c_1, m} + g\\br{c_2, m}. $$\nAlso, we have $ g\\br{cr, m} = f\\br{cr} \\otimes m + \\im \\alpha' $. But $ \\beta\\br{f\\br{cr}} = cr = \\beta\\br{f\\br{c}r} $, so $ f\\br{cr} \\otimes m + \\im \\alpha' = f\\br{c}r \\otimes m + \\im \\alpha' $. So\n$$ g\\br{cr, m} = f\\br{c}r \\otimes m + \\im \\alpha' = f\\br{c} \\otimes rm + \\im \\alpha' = g\\br{c, rm}. $$\n\n\\pagebreak\n\nBy the universal property, there is a unique homomorphism\n$$ \\function[\\psi]{C \\otimes_R M}{\\br{B \\otimes_R M} / \\im \\alpha'}{c \\otimes m}{f\\br{c} \\otimes m + \\im \\alpha'}. $$\nNext observe that $ \\br{\\beta' \\circ \\alpha'}\\br{a \\otimes m} = \\br{\\beta \\circ \\alpha}\\br{a} \\otimes m = 0 $, since $ \\im \\alpha = \\ker \\beta $. Since $ A \\otimes_R M $ is generated by pure tensors, we have $ \\beta' \\circ \\alpha' = 0 $. So $ \\im \\alpha' \\le \\ker \\beta' $. Hence $ \\beta' $ induces a map\n$$ \\phi : \\br{B \\otimes_R M} / \\im \\alpha' \\to C \\otimes_R M. $$\nIt is easy to check that $ \\phi $ and $ \\psi $ are mutually inverse, and so both are isomorphisms. In particular $ \\phi $ is injective, and so $ \\im \\alpha' = \\ker \\beta' $ as required.\n\\end{proof}\n\n\\subsection{Flat modules}\n\n\\begin{definition}\nA left $ R $-module $ M $ is \\textbf{flat} if $ A \\to B $ is injective implies that $ A \\otimes_R M \\to B \\otimes_R M $ is injective.\n\\end{definition}\n\nIf $ M $ is flat then any short exact sequence of right $ R $-modules\n$$ 0 \\to A \\to B \\to C \\to 0 $$\ncorresponds to a short exact sequence of abelian groups\n$$ 0 \\to A \\otimes_R M \\to B \\otimes_R M \\to C \\otimes_R M \\to 0. $$\n\n\\begin{proposition}\n\\label{prop:projectiveflat}\nEvery projective module is flat.\n\\end{proposition}\n\nThis follows from two lemmas.\n\n\\begin{lemma}\n\\label{lem:projectiveflat1}\n$ P \\oplus Q $ is flat if and only if $ P $ and $ Q $ are both flat.\n\\end{lemma}\n\n\\begin{proof}\nRecall there is a canonical isomorphism\n$$ A \\otimes_R \\br{P \\oplus Q} \\cong \\br{A \\otimes_R P} \\oplus \\br{A \\otimes_R Q}. $$\nSuppose $ \\alpha : A \\to B $ is injective. Then $ \\alpha' : A \\otimes_R \\br{P \\oplus Q} \\to B \\otimes_R \\br{P \\oplus Q} $ corresponds to\n$$ \\functions[\\overline{\\alpha'}]{\\br{A \\otimes_R P} \\oplus \\br{A \\otimes_R Q}}{\\br{B \\otimes_R P} \\oplus \\br{B \\otimes_R Q}}{\\br{a \\otimes p, 0}}{\\br{\\alpha\\br{a} \\otimes p, 0}}{\\br{0, a \\otimes q}}{\\br{0, \\alpha\\br{a} \\otimes q}}. $$\nIt is clear from this that $ \\overline{\\alpha'} $ is injective if and only if $ A \\otimes_R P \\to B \\otimes_R P $ and $ A \\otimes_R Q \\to B \\otimes_R Q $ are injective, and Lemma \\ref{lem:projectiveflat1} follows immediately.\n\\end{proof}\n\n\\begin{lemma}\n\\label{lem:projectiveflat2}\nEvery free $ R $-module is flat.\n\\end{lemma}\n\n\\lecture{11}{Monday}{03/02/20}\n\nLecture 11 is a problems class.\n\n\\lecture{12}{Tuesday}{04/02/20}\n\n\\begin{proof}\nWe know $ \\br{A \\oplus B} \\otimes_R C \\cong \\br{A \\otimes_R C} \\oplus \\br{B \\otimes_R C} $. Similarly,\n$$ \\br{\\bigoplus_{s \\in S} A_s} \\otimes_R C \\cong \\bigoplus_{s \\in S} \\br{A_s \\otimes_R C}. $$\nSo Lemma \\ref{lem:projectiveflat1} generalises, so $ \\bigoplus_{s \\in S} A_s $ is flat if and only if all of the $ A_s $ are flat for $ s \\in S $. Let $ F $ be free. Then $ F = \\bigoplus_{s \\in S} R $, and so $ F $ is flat if and only if $ R $ is flat. But for any $ R $-module in $ A $, we have $ A \\otimes_R R \\cong A $, so\n$$\n\\begin{tikzcd}[row sep=tiny]\nA \\arrow{r}{\\alpha} \\arrow[cong]{d} & B \\arrow[cong]{d} \\\\\nA \\otimes_R R \\arrow[dashed]{r}[swap]{\\alpha'} & B \\otimes_R R\n\\end{tikzcd},\n$$\nand it is easy to check that $ R $ is flat.\n\\end{proof}\n\n\\begin{proof}[Proof of Proposition \\ref{prop:projectiveflat}]\nLemma \\ref{lem:projectiveflat1} and Lemma \\ref{lem:projectiveflat2} imply Proposition \\ref{prop:projectiveflat}, since a projective module is a direct summand of a free module.\n\\end{proof}\n\n\\pagebreak\n\n\\section{Modules over a PID}\n\nThere exist flat modules which are not projective. We will show that $ \\QQ $ as a module for $ \\ZZ $ is flat, and it is easy to see it is not projective. To do this we will study the case of modules over a PID. Recall that $ R $ is an \\textbf{integral domain} if $ R $ is commutative and $ rs = 0 $ implies that $ r = 0 $ or $ s = 0 $ for $ r, s \\in R $. An integral domain is a \\textbf{PID} if every ideal is $ \\abr{a} = \\cbr{ra \\st r \\in R} $ for some $ a \\in R $.\n\n\\begin{example*}\nThe ring $ \\ZZ $ is an example of a PID.\n\\end{example*}\n\n\\subsection{Free and projective modules}\n\n\\begin{proposition}\nLet $ R $ be a PID. Then every projective $ R $-module is free. Equivalently, every summand of a free module is free. In fact we will show that any submodule of a free module is free. Moreover, if $ F_1 \\le F_2 $, where $ F_1 $ and $ F_2 $ are free, and if $ B_1 $ and $ B_2 $ are bases for $ F_1 $ and $ F_2 $ respectively, then $ \\abs{B_1} \\le \\abs{B_2} $. In particular, if $ M \\le R^n $, then $ M \\cong R^m $ for some $ m \\le n $.\n\\end{proposition}\n\nFor this, we will need the well-ordering theorem.\n\n\\begin{theorem}[Well-ordering theorem]\nLet $ X $ be a set. There exists a well-order $ \\le $ on $ X $, that is a total order such that every non-empty subset of $ X $ has a least element.\n\\end{theorem}\n\n\\begin{corollary}[Transfinite induction]\nLet $ X $ be a non-empty set well-ordered by $ \\le $. Let $ x_0 $ be the least element of $ X $. Let $ S \\subseteq X $. If $ x_0 \\in S $, and $ s < t $ implies $ s \\in S $ implies that $ t \\in S $, then $ S = X $.\n\\end{corollary}\n\n\\begin{proof}\nLet $ F = \\bigoplus_{s \\in S} R $. Let $ \\le $ be a well-order on $ S $. For $ s \\in S $, let $ \\pi_s $ be the projection map $ F \\to R $ onto the $ s $-coordinate. Let $ e_s $ be the element of $ F $ with one in coordinate $ s $, and zero elsewhere. Suppose $ U \\le F $ is an $ R $-submodule of $ F $. Define $ R_t $ to be the submodule of $ F $ generated by $ \\cbr{e_s \\st s \\le t} $, so\n$$ R_t = \\sp \\cbr{e_s \\st s \\le t}. $$\nSo if $ t_1 \\le t_2 $ then $ R_{t_1} \\le R_{t_2} $. Let\n$$ U_t = U \\cap R_t. $$\nSo $ t_1 < t_2 $ implies that $ U_{t_1} \\le U_{t_2} $. Consider $ \\pi_s\\br{U_s} $. This is an ideal of $ R $. Hence there exists $ a_s \\in R $ such that $ \\pi_s\\br{U_s} = \\abr{a_s} $, since $ R $ is a PID. For each $ s $, let $ u_s \\in U_s $ be such that $ \\pi_s\\br{u_s} = a_s $. In cases where $ a_s = 0 $, assume $ u_s = 0 $. Let\n$$ B = \\cbr{u_s \\st s \\in S, \\ u_s \\ne 0}. $$\n\\begin{itemize}\n\\item Claim that $ B $ generates $ U $. We will actually prove that $ B_t = \\cbr{u_s \\st s \\le t} $ generates $ U_t $, using transfinite induction. If $ s_0 $ is the least element of $ S $, it is easy to see that $ \\cbr{u_{s_0}} $ generates $ U_{s_0} $. Suppose $ B_t $ generates $ U_t $ for all $ t < t_0 $. Let $ u \\in U_{t_0} $. Then $ \\pi_{t_0}\\br{u} = ra_{t_0} $. Hence $ \\pi_{t_0}\\br{u - ru_{t_0}} = 0 $. So $ u - ru_{t_0} $ has zero in the $ t_0 $-coordinate, so $ u - ru_{t_0} \\in \\sp \\cbr{e_s \\st s < t_0} $. Clearly $ u - ru_{t_0} \\in U $. We have $ u - ru_{t_0} = \\sum_{i = 1}^q r_ie_{s_i} $, where $ s_i < t_0 $, and $ s_1 < \\dots < s_q $. Then\n$$ u - ru_{t_0} \\in U \\cap R_{s_q} = U_{s_q} = \\sp B_{s_q}, $$\nby the inductive hypothesis. Hence $ u \\in \\sp \\br{B_{s_q} \\cup \\cbr{u_{t_0}}} \\subseteq \\sp B_{t_0} $. Hence $ B_{t_0} $ generates $ U_{t_0} $, as required.\n\\item Next we show the linear independence of $ B $. Suppose we have a linear combination of elements of $ B $ equal to zero. Say $ \\sum_{i = 1}^k r_iu_{s_i} = 0 $. Assume $ s_1 < \\dots < s_k $. We have\n$$ \\pi_{s_k}\\br{\\sum_{i = 1}^k r_iu_{s_i}} = \\sum_{i = 1}^k r_i\\pi_{s_k}\\br{u_{s_i}}. $$\nNow $ u_{s_i} \\in U_{s_i} \\subseteq R_{s_i} $, and so $ \\pi_{s_k}\\br{u_{s_i}} = 0 $ if $ s_i < s_k $. Hence $ r_k\\pi_{s_k}\\br{u_{s_k}} = 0 $, so $ r_ka_{s_k} = 0 $. But $ a_{s_k} \\ne 0 $, and $ R $ is an integral domain. So $ r_k = 0 $. It follows easily that $ r_i = 0 $ for all $ i $, so $ B $ is linearly independent.\n\\end{itemize}\nWe have shown that $ B $ is a basis for $ U $. Hence $ U $ is free. Since the elements of $ B $ are indexed by a subset of $ S $, we have $ \\abs{B} \\le \\abs{S} $.\n\\end{proof}\n\n\\lecture{13}{Friday}{07/02/20}\n\nLecture 13 is a problems class.\n\n\\pagebreak\n\n\\subsection{Injective and divisible modules}\n\n\\lecture{14}{Monday}{10/02/20}\n\n\\begin{definition}\nLet $ R $ be an integral domain, and $ M $ an $ R $-module. Let $ m \\in M $. Say that $ m $ is \\textbf{infinitely divisible} if for all $ r \\in R \\setminus \\cbr{0} $ there exists $ l \\in M $ such that $ rl = m $.\n\\end{definition}\n\n\\begin{proposition}\nThe divisible elements of $ M $ form a submodule, $ \\D\\br{M} $.\n\\end{proposition}\n\n\\begin{proof}\nEasy.\n\\end{proof}\n\n\\begin{definition}\nIf $ \\D\\br{M} = M $, then $ M $ is \\textbf{divisible}.\n\\end{definition}\n\n\\begin{proposition}\nLet $ R $ be an integral domain. Then if an $ R $-module $ M $ is injective then it is divisible.\n\\end{proposition}\n\n\\begin{proof}\nRecall that for an integral domain $ R $, and $ a \\in R \\setminus \\cbr{0} $, the map\n$$ \\function[f]{R}{\\abr{a}}{r}{ra} $$\nis an isomorphism. Suppose $ M $ is an injective $ R $-module. Let\n$$ \\function[g]{R}{M}{1}{m}. $$\nThen $ g \\circ f^{-1} $ is a homomorphism $ \\abr{a} \\to M $, and $ \\br{g \\circ f^{-1}}\\br{a} = g\\br{1} = m $. Now by Baer's criterion, there is a map $ h : R \\to M $ extending $ g \\circ f^{-1} $. Now $ ah\\br{1} = h\\br{a} = \\br{g \\circ f^{-1}}\\br{a} = m $. Hence there exists $ l \\in M $ such that $ al = m $. So $ m $ is a divisible element, and so $ M $ is divisible.\n\\end{proof}\n\n\\begin{proposition}\nLet $ R $ be a PID. If $ M $ is a divisible $ R $-module then $ M $ is injective.\n\\end{proposition}\n\nSo divisible is equal to injective when $ R $ is a PID.\n\n\\begin{proof}\nWe use Baer's criterion. Let $ I $ be an ideal of $ R $, and $ f : I \\to M $ an $ R $-module homomorphism. Since $ R $ is a PID, $ I = \\abr{a} $ for some $ a \\in R $. Suppose $ f\\br{a} = m $. If $ a = 0 $ there is nothing to prove, since the zero map $ R \\to M $ extends $ f $. So assume $ a \\ne 0 $. Since $ m $ is divisible, there exists $ l \\in M $ with $ al = m $. Now the map given by\n$$ \\function{R}{M}{1}{l} $$\nextends $ f $. So Baer's criterion is satisfied, and so $ M $ is injective.\n\\end{proof}\n\n\\subsection{Flat and torsion-free modules}\n\n\\begin{definition}\nLet $ R $ be an integral domain. Let $ M $ be an $ R $-module. Say that $ m \\in M $ is a \\textbf{torsion element} if there exists $ r \\in R \\setminus \\cbr{0} $ such that $ rm = 0 $.\n\\end{definition}\n\n\\begin{proposition}\nThe torsion elements of $ M $ form a submodule $ \\T\\br{M} $.\n\\end{proposition}\n\n\\begin{proof}\nEasy, using the fact that integral domains are commutative.\n\\end{proof}\n\n\\begin{definition}\nIf $ \\T\\br{M} = 0 $, then $ M $ is \\textbf{torsion-free}. If $ \\T\\br{M} = M $, then $ M $ is a \\textbf{torsion module}.\n\\end{definition}\n\n\\begin{proposition}\nLet $ R $ be an integral domain. Let $ M $ be a flat $ R $-module. Then $ M $ is torsion-free.\n\\end{proposition}\n\n\\begin{proof}\nLet $ a \\in R \\setminus \\cbr{0} $. Then\n$$ \\function[f]{R}{R}{1}{a} $$\nis an injective $ R $-module homomorphism. Suppose that $ M $ is flat. Then the map\n$$ \\function[g]{R \\otimes_R M}{R \\otimes_R M}{r \\otimes m}{ra \\otimes m = r \\otimes am} $$\nis injective. But $ R \\otimes_R M $ is canonically isomorphic to $ M $, under which the map $ g $ corresponds to $ m \\mapsto am $. Since $ g $ is injective, we have $ am \\ne 0 $ for $ m \\ne 0 $. Hence $ m $ is not a torsion element, if $ m \\ne 0 $, and so $ M $ is torsion-free.\n\\end{proof}\n\n\\pagebreak\n\nWe now build up to the following.\n\n\\begin{proposition}\n\\label{prop:torsionflat}\nLet $ R $ be a PID. If $ M $ is a torsion-free $ R $-module then $ M $ is flat.\n\\end{proposition}\n\nThe following is the strategy. We want to prove that whenever $ \\alpha : A \\to B $ is injective, so is $ \\alpha' : A \\otimes_R M \\to B \\otimes_R M $, where $ M $ is torsion-free.\n\\begin{enumerate}\n\\item Prove this in the case that $ B $ is free, and $ A $ is a submodule of $ B $, and $ \\alpha $ is the inclusion map, by\n\\begin{itemize}\n\\item first reducing the problem to the case that $ A $ and $ B $ are finitely generated, so $ B \\cong R^n $, and\n\\item then using induction on the rank $ n $ of $ B $.\n\\end{itemize}\n\\item Show the general case follows from $ 1 $.\n\\end{enumerate}\n\n\\begin{lemma}\n\\label{lem:torsionflat1}\nLet $ R $ be a PID, let $ I = \\abr{a} $ be an ideal of $ R $, and let $ M $ be a torsion-free $ R $-module. Then $ g : I \\otimes_R M \\to R \\otimes_R M $ is injective.\n\\end{lemma}\n\n\\begin{proof}\nThe homomorphism given by\n$$ \\function{R}{I}{r}{ra} $$\ngives a map $ f : R \\otimes_R M \\to I \\otimes_R M $. Now $ g \\circ f $ is a map\n$$ \\function{R \\otimes_R M}{R \\otimes_R M}{m}{ma}. $$\nNow $ f $ is surjective, and $ g \\circ f $ is injective, since $ M $ is torsion-free. But this implies that $ g $ is injective, as required.\n\\end{proof}\n\nThe following is the reduction to the finitely generated case.\n\n\\begin{lemma}\n\\label{lem:torsionflat2}\nLet $ A $ be a right $ R $-module. Let $ M $ be a left $ R $-module. Suppose $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = 0 $ in $ A \\otimes_R M $. There exists a finitely generated submodule $ A_0 \\le A $ such that $ a_i \\in A_0 $ for all $ i $, and $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = 0 $ in $ A_0 \\otimes_R M $.\n\\end{lemma}\n\n\\begin{proof}\nRecall that $ A \\otimes_R M = \\F_{\\ab}\\br{A \\times M} / K $ where $ K $ is generated by certain relators. If $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = 0 $ in $ A \\otimes_R M $, then in $ \\F_{\\ab}\\br{A \\times M} $, we have $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} \\in K $. So there exist relators $ s_1, \\dots, s_q $, or their negations, such that\n$$ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = \\sum_{i = 1}^q s_i. $$\nOnly finitely many elements of $ A $ are involved in the relators $ s_1, \\dots, s_q $. Let $ A_0 $ be generated by these together with $ a_1, \\dots, a_t $. Then certainly $ a_i \\in A_0 $ for all $ i $. And $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = \\sum_{i = 1}^q s_i $ in $ \\F_{\\ab}\\br{A_0 \\times M} $ so $ \\sum_{i = 1}^t \\br{a_i \\otimes m_i} = 0 $ in $ A_0 \\otimes_R M $. Clearly $ A_0 $ is finitely generated.\n\\end{proof}\n\n\\lecture{15}{Tuesday}{11/02/20}\n\nWe can assume that $ A $ is finitely generated.\n\n\\begin{lemma}\n\\label{lem:torsionflat3}\nLet $ F = \\F\\br{S} = \\bigoplus_{s \\in S} R $. Let $ U $ be a finitely generated submodule of $ F $. Then there exists a finite $ T \\subseteq S $ such that $ U \\le \\F\\br{T} $, and for any $ M $, the map $ \\F\\br{T} \\otimes_R M \\to \\F\\br{S} \\otimes_R M $ is injective.\n\\end{lemma}\n\n\\begin{proof}\nLet $ u_1, \\dots, u_q $ be generators for $ U $. Every $ u_i $ is an $ R $-linear combination of elements of $ S $. Since each of these linear combinations mentions only finitely many elements of $ S $, there is a finite subset $ T \\subseteq S $ such that every $ u_i $ is an $ R $-linear combination of elements of $ T $. So $ U \\le \\F\\br{T} $. We have $ \\F\\br{S} = \\F\\br{T} \\oplus \\F\\br{S \\setminus T} $, and so\n$$ \\F\\br{S} \\otimes_R M \\cong \\br{\\F\\br{T} \\otimes_R M} \\oplus \\br{\\F\\br{S \\setminus T} \\otimes_R M}. $$\nIt follows that the natural map $ \\F\\br{T} \\otimes_R M \\to \\F\\br{S} \\otimes_R M $ is injective.\n\\end{proof}\n\n\\pagebreak\n\nLemma \\ref{lem:torsionflat2} and Lemma \\ref{lem:torsionflat3} tell us that if $ F $ is free and $ U \\le F $, and if $ M $ is an $ R $-module, if $ U \\otimes_R M \\to F \\otimes_R M $ is not injective, then there exists a finitely generated $ U_0 < U $ and a finite rank free submodule $ F_0 < F $ such that $ U_0 \\otimes_R M \\to F_0 \\otimes_R M $ is not injective.\n\n\\begin{lemma}\n\\label{lem:torsionflat4}\nLet $ R $ be a PID. Let $ F $ be free, and $ U \\le F $. Let $ M $ be torsion-free. Then $ U \\otimes_R M \\to F \\otimes_R M $ is injective.\n\\end{lemma}\n\n\\begin{proof}\nWe assume that $ F = R^n $. We do this by induction on $ n $.\n\\begin{itemize}[leftmargin=1.5in]\n\\item[Base case.] Let $ n = 1 $. So $ F $ is $ R $, and $ U $ is an ideal of $ R $. By Lemma \\ref{lem:torsionflat1}, $ U \\otimes_R M \\to F \\otimes_R M $ is injective in this case.\n\\item[Inductive hypothesis.] $ U \\le F = R^{n - 1} $ implies that $ U \\otimes_R M \\to F \\otimes_R M $ is injective.\n\\item[Inductive step.] Assume $ U \\le F = R^n $. Write $ R^n = R \\oplus R^{n - 1} $. So we have a short exact sequence\n$$ 0 \\to R \\to R^n \\to R^{n - 1} \\to 0. $$\nWe also have a short exact sequence\n$$ 0 \\to U_1 \\to U \\to \\pi_{R^{n - 1}}\\br{U} \\to 0, $$\nwhere $ U_1 = U \\cap \\br{R \\oplus 0^{n - 1}} $. Identifying $ R $ with $ R \\oplus 0^{n - 1} $, we get a commuting diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & U_1 \\arrow{r} \\arrow{d} & U \\arrow{r} \\arrow{d} & \\pi_{R^{n - 1}}\\br{U} \\arrow{r} \\arrow{d} & 0 \\\\\n0 \\arrow{r} & R \\arrow{r} & R^n \\arrow{r} & R^{n - 1} \\arrow{r} & 0\n\\end{tikzcd},\n$$\nwhere the vertical maps are inclusions, and the rows are exact. Tensoring everything with $ M $, we get a new commuting diagram\n$$\n\\begin{tikzcd}\n& U_1 \\otimes_R M \\arrow{r} \\arrow{d}{f} & U \\otimes_R M \\arrow{r} \\arrow{d}{g} & \\pi_{R^{n - 1}}\\br{U} \\otimes_R M \\arrow{r} \\arrow{d}{h} & 0 \\\\\n0 \\arrow{r} & R \\otimes_R M \\arrow{r} & R^n \\otimes_R M \\arrow{r} & R^{n - 1} \\otimes_R M \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nThe initial zero in the bottom row comes from the fact that\n$$ 0 \\to R \\to R^n \\to R^{n - 1} \\to 0 $$\nis split, since $ R^n = R \\oplus R^{n - 1} $, and so\n$$ R^n \\otimes_R M \\cong \\br{R \\otimes_R M} \\oplus \\br{R^{n - 1} \\otimes_R M}. $$\nNow $ f $ is injective by Lemma \\ref{lem:torsionflat1}, and $ h $ is injective by the inductive hypothesis. The snake lemma tells us that the sequence\n$$ \\ker f \\to \\ker g \\to \\ker h $$\nis exact at $ \\ker g $. So\n$$ 0 \\to \\ker g \\to 0 $$\nis exact, and so $ \\ker g = 0 $. So $ g $ is injective, and this completes the induction.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\n\\begin{proof}[Proof of Proposition \\ref{prop:torsionflat}]\nProve that if $ \\alpha : A \\to B $ is injective, and $ M $ is torsion-free, over a PID $ R $, then $ \\alpha' : A \\otimes_R M \\to B \\otimes_R M $ is injective. There exists a free module $ F $ such that $ B $ is quotient of $ F $. So there is a short exact sequence\n$$ 0 \\to K \\to F \\xrightarrow{\\delta} B \\to 0. $$\nNow $ A \\cong \\alpha A = \\im \\alpha $. Let $ F_A $ be the $ \\delta $-preimage of $ \\alpha A $. Then $ K < F_A $, and we have another short exact sequence\n$$ 0 \\to K \\to F_A \\to \\alpha A \\to 0. $$\nWe have a commuting diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & K \\arrow{r} \\arrow[cong]{d} & F_A \\arrow{r} \\arrow[hookrightarrow]{d} & \\alpha A \\arrow{r} \\arrow[hookrightarrow]{d} & 0 \\\\\n0 \\arrow{r} & K \\arrow{r} & F \\arrow{r} & B \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nTensoring with $ M $,\n$$\n\\begin{tikzcd}\nK \\otimes_R M \\arrow{r}{\\beta} \\arrow[cong]{d} & F_A \\otimes_R M \\arrow{r}{\\gamma} \\arrow{d}{f} & \\alpha A \\otimes_R M \\arrow{r} \\arrow{d}{g} & 0 \\\\\nK \\otimes_R M \\arrow{r}[swap]{\\delta} & F \\otimes_R M \\arrow{r}[swap]{\\epsilon} & B \\otimes_R M \\arrow{r} & 0\n\\end{tikzcd}\n$$\nis commuting, and exact along rows. Let $ u \\in \\ker g \\le \\alpha A \\otimes_R M \\cong A \\otimes_R M $. Since $ \\gamma $ is surjective, there is $ w \\in F_A \\otimes_R M $ with $ \\gamma\\br{w} = u $. So $ \\br{g \\circ \\gamma}\\br{w} = 0 $. So $ \\br{\\epsilon \\circ f}\\br{w} = 0 $. So $ f\\br{w} \\in \\ker \\epsilon = \\im \\delta $, so $ f\\br{w} = \\delta\\br{k} $ for $ k \\in K \\otimes_R M $. Since $ f $ is injective, by Lemma \\ref{lem:torsionflat4}, we get $ w = \\beta\\br{k} \\in \\im \\beta $. So $ w \\in \\ker \\gamma $, so $ u = 0 $. Hence $ g $ is injective, as required.\n\\end{proof}\n\nWe have shown that if $ R $ is a PID, and if $ M $ is torsion-free, then $ M $ is flat.\n\n\\subsection{Modules over PIDs}\n\n\\lecture{16}{Friday}{14/02/20}\n\nFor an $ R $-module $ M $\n$$ \\text{free} \\implies \\text{projective} \\implies \\text{flat} \\implies \\text{torsion-free}, \\qquad \\text{injective} \\implies \\text{divisible}. $$\nOver a PID\n$$ \\text{free} \\iff \\text{projective} \\implies \\text{flat} \\iff \\text{torsion-free}, \\qquad \\text{injective} \\iff \\text{divisible}. $$\nDo we have projective if and only if flat, over a general ring, or over a PID? The answer is no.\n\n\\begin{example*}\nThe $ \\ZZ $-module $ \\QQ $ is torsion-free, so flat. Is $ \\QQ $ projective? Is $ \\QQ $ free, since $ \\ZZ $ is a PID? Consider a free $ \\ZZ $-module $ F = \\bigoplus_{s \\in S} \\ZZ $. Let $ s_0 \\in S $. Then let $ x = \\br{x_s}_{s \\in S} $, where\n$$ x_s =\n\\begin{cases}\n1 & s = s_0 \\\\\n0 & \\text{otherwise}\n\\end{cases}\n\\in F. $$\nIt is clear there are no $ y \\in F $ such that $ 2y = x $. So $ x $ is not a divisible element of $ F $. Indeed, $ \\D\\br{F} = \\cbr{0} $. But $ \\D\\br{\\QQ} = \\QQ $. Hence $ \\QQ \\not\\cong F $. So $ \\QQ $ is an example of a flat module which is not projective.\n\\end{example*}\n\n\\pagebreak\n\n\\section{Projective and injective resolutions}\n\n\\begin{definition}\nLet $ M $ be an $ R $-module. A \\textbf{resolution}, or \\textbf{left resolution}, for $ M $ is a sequence of $ R $-modules $ A_0, A_1, A_2, \\dots $, with homomorphisms $ d : A_{i + 1} \\to A_i $, and also a homomorphism $ A_0 \\to M $, such that\n$$ \\dots \\xrightarrow{d} A_2 \\xrightarrow{d} A_1 \\xrightarrow{d} A_0 \\to M \\to 0 $$\nis an exact sequence, where $ d $ is the \\textbf{differential}. If all of the modules $ A_i $ have a property $ \\PPP $, we call this a \\textbf{$ \\PPP $-resolution}. So we can talk about \\textbf{free resolutions}, \\textbf{projective resolutions}, and \\textbf{flat resolutions}.\n\\end{definition}\n\nWe do not use the term injective resolution in this context.\n\n\\begin{definition}\nA \\textbf{right resolution}, or \\textbf{coresolution}, for $ M $ is a sequence of $ R $-modules $ A^0, A^1, A^2, \\dots $, with homomorphisms $ d : A^i \\to A^{i + 1} $, and $ M \\to A^0 $, such that\n$$ 0 \\to M \\to A^0 \\xrightarrow{d} A^1 \\xrightarrow{d} A^2 \\xrightarrow{d} \\dots $$\nis exact. If the modules $ A^i $ have a property $ \\PPP $, we can refer to a \\textbf{right $ \\PPP $-resolution}. An \\textbf{injective resolution} always means a right injective resolution.\n\\end{definition}\n\n\\subsection{Existence of projective resolutions}\n\n\\begin{proposition}\nLet $ M $ be an $ R $-module. Then $ M $ has free, projective, and flat resolutions.\n\\end{proposition}\n\n\\begin{proof}\nSince free implies projective implies flat, it is enough to show that free resolutions exist. Use the fact that for any module $ L $, there exist a free module $ F $ and $ K \\le F $ such that $ L \\cong F / K $. So we get a short exact sequence\n$$ 0 \\to K \\to F \\to L \\to 0. $$\nIt follows that we can find $ F_0, F_1, F_2, \\dots $, and $ K_0 \\le F_0, K_1 \\le F_1, K_2 \\le F_2, \\dots $ such that\n$$ 0 \\to K_0 \\to F_0 \\to M \\to 0, \\qquad 0 \\to K_1 \\to F_1 \\to K_0 \\to 0, \\qquad 0 \\to K_2 \\to F_2 \\to K_1 \\to 0, \\qquad \\dots $$\nare all exact. Since $ K_i \\le F_i $, we may consider the maps $ F_{i + 1} \\to K_i $ as maps $ F_{i + 1} \\to F_i $ with image $ K_i $. But $ K_i $ is the kernel of the map $ F_i \\to K_{i - 1} $, so the sequence\n$$ \\dots \\to F_2 \\to F_1 \\to F_0 \\to M \\to 0 $$\nis exact, and a free resolution for $ M $.\n\\end{proof}\n\n\\subsection{Existence of injective resolutions}\n\nInjective coresolutions exist too, but the proof is more intricate. It involves making use of properties of the abelian group $ \\QQ / \\ZZ $.\n\n\\begin{proposition}\nLet $ A $ be an abelian group, and let $ a \\in A \\setminus \\cbr{0} $. There is a homomorphism $ f : A \\to \\QQ / \\ZZ $ such that $ f\\br{a} \\ne 0 $.\n\\end{proposition}\n\n\\begin{proof}\nStart by defining\n$$ \\function[f_0]{\\abr{a}}{\\QQ / \\ZZ}{a}{\n\\begin{cases}\n\\tfrac{1}{t} + \\ZZ & a \\ \\text{has finite order} \\ t \\\\\n\\tfrac{1}{2} + \\ZZ & a \\ \\text{has infinite order}\n\\end{cases}\n}. $$\nWe will use Zorn's lemma. Let $ X $ be the set\n$$ \\cbr{\\br{B, f} \\st B \\le A, \\ a \\in B, \\ f : B \\to \\QQ / \\ZZ, \\ f \\ \\text{extends} \\ f_0}. $$\nThen $ X $ is non-empty, since $ \\br{\\abr{a}, f_0} \\in X $. Define a partial order $ \\le $ on $ X $ by $ \\br{B_1, f_1} \\le \\br{B_2, f_2} $ if $ B_1 \\le B_2 $ and $ f_2 $ extends $ f_1 $. Let $ \\cbr{\\br{B_s, f_s} \\st s \\in S} $ be a chain in $ X $, where $ S $ is a suitable indexing set. Then $ \\cbr{B_s \\st s \\in S} $ is a chain of subgroups of $ A $. So the union $ B = \\bigcup_{s \\in S} B_s $ is a subgroup of $ A $, containing $ a $. Define\n$$ \\function[f]{B}{\\QQ / \\ZZ}{b}{f_s\\br{b}}, \\qquad b \\in B_s. $$\n\n\\pagebreak\n\nThis is well-defined since if $ b \\in B_t $ then $ f_s\\br{b} = f_t\\br{b} $. Now $ \\br{B, f} $ is an upper bound for $ \\cbr{B_s \\st s \\in S} $ in $ X $. So by Zorn's lemma, $ X $ has a maximal element, which we will call $ \\br{B, f} $. We show that $ B = A $. Since $ f\\br{a} = f_0\\br{a} $, this will complete the proof. Suppose $ x \\in A \\setminus B $. Then let $ I < \\ZZ $ be defined by\n$$ I = \\cbr{k \\st kx \\in B}. $$\nSince $ \\ZZ $ is a PID, we have $ I = n\\ZZ $ for some $ n $. We have $ \\abr{B, x} \\le A $, and $ \\abr{B, x} \\cong \\br{B \\oplus \\abr{x}} / \\abr{nx - b_0} $, where $ b_0 = nx $ in $ A $. Define\n$$ \\function[\\phi]{B \\oplus \\abr{x}}{\\QQ / \\ZZ}{\\br{b, kx}}{f\\br{b} + \\dfrac{kf\\br{b_0}}{n}}, $$\nso sending $ x $ to $ f\\br{b_0} / n $. We see that $ \\phi\\br{nx - b_0} = 0 $, so $ \\phi $ induces a map $ \\br{B \\oplus \\abr{x}} / \\abr{nx - b_0} \\to \\QQ / \\ZZ $, and hence a map $ f' : \\abr{B, x} \\to \\QQ / \\ZZ $. But $ f'\\br{a} = f_0\\br{a} $, so $ \\br{\\abr{B, x}, f} $ is an element of $ X $ greater than $ \\br{B, f} $, contradicting maximality of $ \\br{B, f} $. Hence $ B = A $ as required.\n\\end{proof}\n\n\\lecture{17}{Monday}{17/02/20}\n\n\\begin{proposition}\nFor every abelian group $ A $, there is an injective abelian group $ I $ such that $ A $ is isomorphic to a subgroup of $ I $.\n\\end{proposition}\n\n\\begin{proof}\nWe know that $ \\QQ / \\ZZ $ is injective, as a $ \\ZZ $-module, since it is divisible, and $ \\ZZ $ is a PID. So $ \\prod_{s \\in S} \\QQ / \\ZZ $ is also injective. Take $ S = A \\setminus \\cbr{0} $. Then define, for each $ s \\in S $, $ f_s : A \\to \\QQ / \\ZZ $ such that $ f_s\\br{s} \\ne 0 $. Define\n$$ \\function[f]{A}{\\prod_{s \\in S} \\QQ / \\ZZ}{a}{\\br{f_s\\br{a}}_{s \\in S}}. $$\nNow if $ s \\in A \\setminus \\cbr{0} $, then $ f_s\\br{s} \\ne 0 $, so $ f\\br{s} \\ne 0 $. So $ f $ is injective. It is easy to check that $ f $ is a homomorphism.\n\\end{proof}\n\n\\begin{proposition}\nLet $ M $ be a right $ R $-module, and let $ A $ be an abelian group. Then $ \\Hom_\\ZZ\\br{M, A} $ is a left $ R $-module, with the $ R $-action defined by $ \\br{rf}\\br{m} = f\\br{mr} $.\n\\end{proposition}\n\n\\begin{proof}\nThis is clearer if we write the map $ f $ on the right instead of the left. Then the definition becomes $ \\br{m}\\br{rf} = \\br{mr}f $, and it is easy to see this works.\n\\end{proof}\n\n\\begin{proposition}\nLet $ M $ be a left $ R $-module, and $ A $ an abelian group. Then $ \\Hom_\\ZZ\\br{R, A} $ is a left $ R $-module, and there is a natural isomorphism\n$$ \\Hom_R\\br{M, \\Hom_\\ZZ\\br{R, A}} \\cong \\Hom_\\ZZ\\br{M, A}. $$\n\\end{proposition}\n\n\\begin{proof}\nWrite $ H = \\Hom_\\ZZ\\br{R, A} $. Define\n$$ \\function[\\Phi]{\\Hom_R\\br{M, H}}{\\Hom_\\ZZ\\br{M, A}}{f}{\\br{m \\mapsto f\\br{m}\\br{1}}}, \\qquad m \\in M, \\qquad 1 \\in R. $$\nCheck the following.\n\\begin{itemize}\n\\item $ \\Phi\\br{f} $ is a homomorphism, since\n\\begin{align*}\n\\Phi\\br{f}\\br{m_1 + m_2}\n& = f\\br{m_1 + m_2}\\br{1} \\\\\n& = \\br{f\\br{m_1} + f\\br{m_2}}\\br{1} \\\\\n& = f\\br{m_1}\\br{1} + f\\br{m_2}\\br{1} & \\text{definition of} \\ + \\ \\text{in} \\ \\Hom_\\ZZ\\br{R, A} \\\\\n& = \\Phi\\br{f}\\br{m_1} + \\Phi\\br{f}\\br{m_2}.\n\\end{align*}\n\\item $ \\Phi $ is a homomorphism, since\n\\begin{align*}\n\\Phi\\br{f_1 + f_2}\\br{m}\n& = \\br{f_1 + f_2}\\br{m}\\br{1} \\\\\n& = \\br{f_1\\br{m} + f_2\\br{m}}\\br{1} & \\text{definition of} \\ + \\ \\text{in} \\ \\Hom_\\ZZ\\br{M, A} \\\\\n& = f_1\\br{m}\\br{1} + f_2\\br{m}\\br{1} \\\\\n& = \\Phi\\br{f_1}\\br{m} + \\Phi\\br{f_2}\\br{m} \\\\\n& = \\br{\\Phi\\br{f_1} + \\Phi\\br{f_2}}\\br{m} & \\text{definition of} \\ + \\ \\text{in} \\ \\Hom_\\ZZ\\br{M, A},\n\\end{align*}\nso since $ m $ was arbitrary, $ \\Phi\\br{f_1 + f_2} = \\Phi\\br{f_1} + \\Phi\\br{f_2} $.\n\\end{itemize}\n\n\\pagebreak\n\nNow define\n$$ \\function[\\Psi]{\\Hom_\\ZZ\\br{M, A}}{\\Hom_R\\br{M, H}}{p}{\\br{m \\mapsto \\br{r \\mapsto p\\br{rm}}}}, \\qquad m \\in M, \\qquad r \\in R. $$\nCheck the following.\n\\begin{itemize}\n\\item $ \\Psi\\br{p}\\br{m} $ is a homomorphism, since\n\\begin{align*}\n\\Psi\\br{p}\\br{m}\\br{r_1 + r_2}\n& = p\\br{\\br{r_1 + r_2}m}\n= p\\br{r_1m + r_2m} \\\\\n& = p\\br{r_1m} + p\\br{r_2m}\n= \\Psi\\br{p}\\br{m}\\br{r_1} + \\Psi\\br{p}\\br{m}\\br{r_1}.\n\\end{align*}\n\\item $ \\Psi\\br{p} $ is an $ R $-module homomorphism, since\n\\begin{align*}\n\\Psi\\br{p}\\br{m_1 + m_2}\\br{r}\n& = p\\br{r\\br{m_1 + m_2}}\n= p\\br{rm_1 + rm_2}\n= p\\br{rm_1} + p\\br{rm_2} \\\\\n& = \\Psi\\br{p}\\br{m_1}\\br{r} + \\Psi\\br{p}\\br{m_2}\\br{r}\n= \\br{\\Psi\\br{p}\\br{m_1} + \\Psi\\br{p}\\br{m_2}}\\br{r},\n\\end{align*}\nso $ \\Psi\\br{p}\\br{m_1 + m_2} = \\Psi\\br{p}\\br{m_1} + \\Psi\\br{p}\\br{m_2} $, and for $ h \\in H $, we have $ \\br{sh}\\br{r} = h\\br{rs} $, by definition of the $ R $-module structure on $ H $, so\n$$ s\\Psi\\br{p}\\br{m}\\br{r} = \\Psi\\br{p}\\br{m}\\br{rs} = p\\br{rsm} = \\Psi\\br{p}\\br{sm}\\br{r}, $$\nso $ s\\Psi\\br{p}\\br{m} = \\Psi\\br{p}\\br{sm} $.\n\\item $ \\Psi $ is a homomorphism, since\n\\begin{align*}\n\\Psi\\br{p_1 + p_2}\\br{m}\\br{r}\n& = \\br{p_1 + p_2}\\br{rm}\n= p_1\\br{rm} + p_2\\br{rm} \\\\\n& = \\Psi\\br{p_1}\\br{m}\\br{r} + \\Psi\\br{p_2}\\br{m}\\br{r}\n= \\br{\\Psi\\br{p_1} + \\Psi\\br{p_2}}\\br{m}\\br{r},\n\\end{align*}\nso $ \\Psi\\br{p_1 + p_2} = \\Psi\\br{p_1} + \\Psi\\br{p_2} $.\n\\end{itemize}\nThen $ \\Psi \\circ \\Phi = \\id_{\\Hom_R\\br{M, H}} $ and $ \\Phi \\circ \\Psi = \\id_{\\Hom_\\ZZ\\br{M, A}} $. \\footnote{Exercise} Hence $ \\Phi $ and $ \\Psi $ are isomorphisms.\n\\end{proof}\n\nWe are interested in the case $ A = \\QQ / \\ZZ $. Write $ S = \\Hom_\\ZZ\\br{R, \\QQ / \\ZZ} $.\n\n\\lecture{18}{Tuesday}{18/02/20}\n\n\\begin{proposition}\n$ S $ is injective as a left $ R $-module.\n\\end{proposition}\n\n\\begin{proof}\nLet $ M $ and $ N $ be $ R $-modules, and $ \\alpha : M \\to N $ an injective homomorphism. By identifying $ M $ with $ \\im \\alpha $, we may assume that $ M \\le N $, and $ \\alpha $ is the inclusion map. Since $ \\QQ / \\ZZ $ is injective as an abelian group, any $ \\ZZ $-module homomorphism $ M \\to S $ extends to a homomorphism $ N \\to S $. Define\n$$ \\function[\\Theta]{\\Hom_\\ZZ\\br{N, \\QQ / \\ZZ}}{\\Hom_\\ZZ\\br{M, \\QQ / \\ZZ}}{f}{\\eval{f}_M}, $$\nthe restriction to $ M $. We see that $ \\Theta $ is surjective. Similarly, we can define\n$$ \\function[\\Theta']{\\Hom_R\\br{N, S}}{\\Hom_R\\br{M, S}}{f}{\\eval{f}_M}. $$\nThen $ \\Theta' $ is an abelian group homomorphism. But we know there is a naturally defined isomorphism between $ \\Hom_R\\br{M, S} $ and $ \\Hom_\\ZZ\\br{M, \\QQ / \\ZZ} $. So we get\n$$\n\\begin{tikzcd}\n\\Hom_\\ZZ\\br{N, \\QQ / \\ZZ} \\arrow{r}{\\Theta} \\arrow{d}{\\sim}[swap]{\\Psi} & \\Hom_\\ZZ\\br{M, \\QQ / \\ZZ} \\arrow{d}{\\Psi}[swap]{\\sim} \\\\\n\\Hom_R\\br{N, S} \\arrow{r}[swap]{\\Theta'} & \\Hom_R\\br{M, S}\n\\end{tikzcd}.\n$$\nIt is easy to see that this diagram commutes. It follows that $ \\Theta' $ is surjective. So any $ R $-module homomorphism $ M \\to S $ extends to a homomorphism $ N \\to S $. Hence $ S $ is injective.\n\\end{proof}\n\n\\pagebreak\n\n\\begin{proposition}\nLet $ M $ be a left $ R $-module, and $ m \\in M \\setminus \\cbr{0} $. Then there exists an $ R $-module homomorphism $ f : M \\to S $ such that $ f\\br{m} \\ne 0 $.\n\\end{proposition}\n\n\\begin{proof}\nWe know there is an abelian group homomorphism $ g : M \\to \\QQ / \\ZZ $ such that $ g\\br{m} \\ne 0 $. Now $ \\Psi\\br{g} \\in \\Hom_R\\br{M, S} $, and $ \\Psi\\br{g}\\br{m}\\br{1} = g\\br{m} \\ne 0 $ for $ 1 \\in R $, so $ \\Psi\\br{g}\\br{m} $ is not the zero map.\n\\end{proof}\n\n\\begin{proposition}\nLet $ M $ be a left $ R $-module. There exists an injective $ R $-module $ I $ such that $ M $ is isomorphic to a submodule of $ I $. Equivalently, there exists an injection $ M \\to I $.\n\\end{proposition}\n\n\\begin{proof}\nSame as abelian groups. Let $ T = M \\setminus \\cbr{0} $. Then $ I = \\prod_{t \\in T} S $ is injective. Let $ f_t $ be a homomorphism $ M \\to S $ such that $ f_t\\br{t} \\ne 0 $. Then\n$$ \\function[f]{M}{I}{m}{\\br{f_t\\br{m}}_{t \\in T}} $$\nis injective, and a homomorphism.\n\\end{proof}\n\n\\begin{proposition}\nEvery $ R $-module admits an injective resolution.\n\\end{proposition}\n\nThus there exist injective $ I_0, I_1, I_2, \\dots $ such that\n$$ 0 \\to M \\to I_0 \\to I_1 \\to I_2 \\to \\dots $$\nis exact.\n\n\\begin{proof}\nLet $ M $ be an $ R $-module. Then $ M $ injects into some injective module $ I_0 $. Let $ C_0 = I_0 / \\im \\br{M \\to I_0} $. Then $ C_0 $ injects into some injective $ I_1 $. This induces a map $ I_0 \\to I_1 $ whose kernel is $ \\im \\br{M \\to I_0} $. Further terms in the sequence are constructed in an identical manner.\n\\end{proof}\n\n\\subsection{Uniqueness of projective resolutions}\n\n\\begin{proposition}\n\\label{prop:projectiveresolution}\nLet $ M $ and $ N $ be $ R $-modules, and $ \\phi : M \\to N $. Let $ \\br{P_i} $ be a projective resolution for $ M $, and $ \\br{Q_i} $ a projective resolution for $ N $.\n\\begin{enumerate}\n\\item There exist $ R $-module homomorphisms $ f_i : P_i \\to Q_i $ such that the diagram\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_2} & P_2 \\arrow{r}{d_1} \\arrow[dashed]{d}{f_2} & P_1 \\arrow{r}{d_0} \\arrow[dashed]{d}{f_1} & P_0 \\arrow{r}{p} \\arrow[dashed]{d}{f_0} & M \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\n\\dots \\arrow{r}[swap]{d_2'} & Q_2 \\arrow{r}[swap]{d_1'} & Q_1 \\arrow{r}[swap]{d_0'} & Q_0 \\arrow{r}[swap]{q} & N \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes.\n\\item Let $ g_i : P_i \\to Q_i $ be such that the diagram\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_2} & P_2 \\arrow{r}{d_1} \\arrow[bend right=30]{d}[swap]{g_2} \\arrow[bend left=30]{d}{f_2} & P_1 \\arrow{r}{d_0} \\arrow[bend right=30]{d}[swap]{g_1} \\arrow[bend left=30]{d}{f_1} & P_0 \\arrow{r}{p} \\arrow[bend right=30]{d}[swap]{g_0} \\arrow[bend left=30]{d}{f_0} & M \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\n\\dots \\arrow{r}[swap]{d_2'} & Q_2 \\arrow{r}[swap]{d_1'} & Q_1 \\arrow{r}[swap]{d_0'} & Q_0 \\arrow{r}[swap]{q} & N \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes. Then there exist homomorphisms $ s_i : P_i \\to Q_{i + 1} $ such that\n$$ g_i - f_i =\n\\begin{cases}\ns_{i - 1} \\circ d_{i - 1} + d_i' \\circ s_i & i > 0 \\\\\nd_0' \\circ s_0 & i = 0\n\\end{cases},\n$$\nso\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_2} & P_2 \\arrow{r}{d_1} \\arrow[dashed]{dl}[swap]{s_2} & P_1 \\arrow{r}{d_0} \\arrow[dashed]{dl}[swap]{s_1} & P_0 \\arrow{r}{p} \\arrow[dashed]{dl}[swap]{s_0} & M \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\n\\dots \\arrow{r}[swap]{d_2'} & Q_2 \\arrow{r}[swap]{d_1'} & Q_1 \\arrow{r}[swap]{d_0'} & Q_0 \\arrow{r}[swap]{q} & N \\arrow{r} & 0\n\\end{tikzcd}.\n$$\n\\end{enumerate}\n\\end{proposition}\n\n\\pagebreak\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item The map $ q : Q_0 \\to N $ is surjective. There is a map $ p : P_0 \\to N $, given by composing $ P_0 \\to M $ with $ \\phi $. Since $ P_0 $ is projective there exists $ f_0 : P_0 \\to Q_0 $ such that $ p = q \\circ f_0 $. Suppose the maps $ f_0, \\dots, f_{t - 1} $ have been constructed, so\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_t} & P_t \\arrow{r}{d_{t - 1}} \\arrow[dashed]{d}{f_t} & P_{t - 1} \\arrow{r}{d_{t - 2}} \\arrow{d}{f_{t - 1}} & P_{t - 2} \\arrow{d}{f_{t - 2}} \\arrow{r} & \\dots \\\\\n\\dots \\arrow{r}[swap]{d_t'} & Q_t \\arrow{r}[swap]{d_{t - 1}'} & Q_{t - 1} \\arrow{r}[swap]{d_{t - 2}'} & Q_{t - 2} \\arrow{r} & \\dots\n\\end{tikzcd}.\n$$\nObserve that $ d_{t - 2}' \\circ f_{t - 1} \\circ d_{t - 1} = f_{t - 2} \\circ d_{t - 2} \\circ d_{t - 1} $, since the existing squares of the diagram commute. But $ d_{t - 2} \\circ d_{t - 1} = 0 $. So $ d_{t - 2}' \\circ f_{t - 1} \\circ d_{t - 1} = 0 $, so $ \\im \\br{f_{t - 1} \\circ d_{t - 1}} \\le \\ker d_{t - 2}' = \\im d_{t - 1}' $. Now the map $ d_{t - 1}' : Q_t \\to \\im d_{t - 1}' $ is obviously surjective, and $ P_t $ is projective. So there is a map $ f_t : P_t \\to Q_t $ such that $ f_{t - 1} \\circ d_{t - 1} = d_{t - 1}' \\circ f_t $. Now inductively, maps $ f_i $ exist for all $ i $.\n\\item We want $ s_i $ such that $ g_i - f_i = d_i' \\circ s_i + s_{i - 1} \\circ d_{i - 1} $. Let $ h_i = g_i - f_i $. We see that the diagram\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_2} & P_2 \\arrow{r}{d_1} \\arrow{d}{h_2} & P_1 \\arrow{r}{d_0} \\arrow{d}{h_1} & P_0 \\arrow{r}{p} \\arrow{d}{h_0} & M \\arrow{r} \\arrow{d}{0} & 0 \\\\\n\\dots \\arrow{r}[swap]{d_2'} & Q_2 \\arrow{r}[swap]{d_1'} & Q_1 \\arrow{r}[swap]{d_0'} & Q_0 \\arrow{r}[swap]{q} & N \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes, since we want $ h_i \\circ d_i = d_i' \\circ h_{i + 1} $, but we have\n$$ h_i \\circ d_i = g_i \\circ d_i - f_i \\circ d_i = d_i' \\circ g_{i + 1} - d_i' \\circ f_{i + 1} = d_i' \\circ h_{i + 1}', $$\nso we are fine.\n\\begin{itemize}[leftmargin=1in]\n\\item[Base case.] Let $ x \\in P_0 $. Then $ \\br{q \\circ h_0}\\br{x} = \\br{0 \\circ p}\\br{x} = 0 $ so $ \\im h_0 \\le \\ker q = \\im d_0' $. We have a surjective map $ d_0' : Q_1 \\to \\im d_0' $, and a map $ h_0 : P_0 \\to \\im d_0' $. Since $ P_0 $ is projective, there exists $ s_0 : P_0 \\to Q_1 $ such that $ h_0 = d_0' \\circ s_0 $.\n\\item[Inductive step.] Suppose we have maps $ s_0, \\dots, s_{t - 1} $, with $ s_i : P_i \\to Q_{i + 1} $, and $ h_i = d_i' \\circ s_i + s_{i - 1} \\circ d_{i - 1} $ for $ i = 1, \\dots, t - 1 $, so\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_{t + 1}} & P_{t + 1} \\arrow{r}{d_t} \\arrow{d}[swap]{h_{t + 1}} & P_t \\arrow{r}{d_{t - 1}} \\arrow[dashed]{dl}[swap]{s_t} \\arrow{d}[swap]{h_t} & P_{t - 1} \\arrow{r}{d_{t - 2}} \\arrow{dl}[swap]{s_{t - 1}} \\arrow{d}[swap]{h_{t - 1}} & P_{t - 2} \\arrow{r}{d_{t - 3}} \\arrow{dl}[swap]{s_{t - 2}} \\arrow{d}[swap]{h_{t - 2}} & \\dots \\\\\n\\dots \\arrow{r}[swap]{d_{t + 1}'} & Q_{t + 1} \\arrow{r}[swap]{d_t'} & Q_t \\arrow{r}[swap]{d_{t - 1}'} & Q_{t - 1} \\arrow{r}[swap]{d_{t - 2}'} & Q_{t - 2} \\arrow{r}[swap]{d_{t - 3}'} & \\dots\n\\end{tikzcd}.\n$$\nLook at $ h_t - s_{t - 1} \\circ d_{t - 1} $. We want to show that the image of this map is contained in $ \\im d_t' = \\ker d_{t - 1}' $. So check\n\\begin{align*}\nd_{t - 1}' \\circ \\br{h_t - s_{t - 1} \\circ d_{t - 1}}\n& = d_{t - 1}' \\circ h_t - d_{t - 1}' \\circ s_{t - 1} \\circ d_{t - 1} \\\\\n& = h_{t - 1} \\circ d_{t - 1} - \\br{h_{t - 1} - s_{t - 2} \\circ d_{t - 2}} \\circ d_{t - 1} \\\\\n& = h_{t - 1} \\circ d_{t - 1} - h_{t - 1} \\circ d_{t - 1} + s_{t - 2} \\circ d_{t - 2} \\circ d_{t - 1}.\n\\end{align*}\nNow $ d_{t - 2} \\circ d_{t - 1} = 0 $, so we have $ d_{t - 1}' \\circ \\br{h_t - s_{t - 1} \\circ d_{t - 1}} = 0 $. So $ h_t - s_{t - 1} \\circ d_{t - 1} \\in \\ker d_{t - 1}' $. Now we have the situation\n$$\n\\begin{tikzcd}\n& P_t \\arrow[dashed]{dl}[swap]{s_t} \\arrow{d}{h_t - s_{t - 1} \\circ d_{t - 1}} \\\\\nQ_{t + 1} \\arrow{r}[swap]{d_t'} & \\im d_t'\n\\end{tikzcd},\n$$\nand since $ P_t $ is projective, there exists $ s_t $ such that $ d_t' \\circ s_t = h_t - s_{t - 1} \\circ d_{t - 1} $, so $ h_t = d_t' \\circ s_t + s_{t - 1} \\circ d_{t - 1} $ as required.\n\\end{itemize}\n\\end{enumerate}\n\\end{proof}\n\n\\pagebreak\n\n\\subsection{Uniqueness of injective resolutions}\n\nThe following is the equivalent result for injectives.\n\n\\begin{proposition}\nLet $ M $ and $ N $ be $ R $-modules, and $ \\phi : M \\to N $ a homomorphism. Let $ \\br{I_t} $ be an injective resolution for $ M $, and $ \\br{J_t} $ an injective resolution for $ N $. Then\n\\begin{itemize}\n\\item there exist maps $ f_i : I_i \\to J_i $ such that the diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & M \\arrow{r}{i} \\arrow{d}{\\phi} & I_0 \\arrow{r}{d_0} \\arrow[dashed]{d}{f_0} & I_1 \\arrow{r}{d_1} \\arrow[dashed]{d}{f_1} & I_2 \\arrow{r}{d_2} \\arrow[dashed]{d}{f_2} & \\dots \\\\\n0 \\arrow{r} & N \\arrow{r}[swap]{j} & J_0 \\arrow{r}[swap]{d_0'} & J_1 \\arrow{r}[swap]{d_1'} & J_2 \\arrow{r}[swap]{d_2'} & \\dots\n\\end{tikzcd}\n$$\ncommutes, and\n\\item if $ \\br{g_i} $ is another set of maps $ g_i : I_i \\to J_i $ such that the diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & M \\arrow{r}{i} \\arrow{d}{\\psi} & I_0 \\arrow{r}{d_0} \\arrow[bend right=30]{d}[swap]{f_0} \\arrow[bend left=30]{d}{g_0} & I_1 \\arrow{r}{d_1} \\arrow[bend right=30]{d}[swap]{f_1} \\arrow[bend left=30]{d}{g_1} & I_2 \\arrow{r}{d_2} \\arrow[bend right=30]{d}[swap]{f_2} \\arrow[bend left=30]{d}{g_2} & \\dots \\\\\n0 \\arrow{r} & N \\arrow{r}[swap]{j} & J_0 \\arrow{r}[swap]{d_0'} & J_1 \\arrow{r}[swap]{d_1'} & J_2 \\arrow{r}[swap]{d_2'} & \\dots\n\\end{tikzcd}\n$$\ncommutes, then there exist maps $ s_i : I_{i + 1} \\to J_i $ such that\n$$ g_i - f_i =\n\\begin{cases}\ns_i \\circ d_i + d_{i - 1}' \\circ s_{i - 1} & i > 0 \\\\\ns_0 \\circ d_0 & i = 0\n\\end{cases},\n$$\nso\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & M \\arrow{r}{i} \\arrow{d}{\\psi} & I_0 \\arrow{r}{d_0} & I_1 \\arrow{r}{d_1} \\arrow[dashed]{dl}[swap]{s_0} & I_2 \\arrow{r}{d_2} \\arrow[dashed]{dl}[swap]{s_1} & \\dots \\arrow[dashed]{dl}[swap]{s_2} \\\\\n0 \\arrow{r} & N \\arrow{r}[swap]{j} & J_0 \\arrow{r}[swap]{d_0'} & J_1 \\arrow{r}[swap]{d_1'} & J_2 \\arrow{r}[swap]{d_2'} & \\dots\n\\end{tikzcd}.\n$$\n\\end{itemize}\n\\end{proposition}\n\n\\begin{proof}\nVery similar to Proposition \\ref{prop:projectiveresolution}.\n\\end{proof}\n\n\\lecture{19}{Friday}{21/02/20}\n\nLecture 19 is a problems class.\n\n\\pagebreak\n\n\\section{Chain complexes and homology}\n\n\\subsection{Chain complexes}\n\n\\lecture{20}{Monday}{24/02/20}\n\n\\begin{definition}\nA \\textbf{chain complex} is a series $ A_* = \\br{A_i} $, with maps $ d_i^A = d_i = d : A_{i + 1} \\to A_i $ such that $ d^2 = 0 $, that is $ d_{i + 1} \\circ d_i = 0 $, or $ \\im d_{i + 1} \\le \\ker d_i $, so\n$$ \\dots \\xrightarrow{d_2} A_2 \\xrightarrow{d_1} A_1 \\xrightarrow{d_0} A_0. $$\n\\end{definition}\n\n\\begin{definition}\nA \\textbf{cochain complex} is a series $ A^* = \\br{A^i} $ with maps $ d_i^A = d_i = d : A^i \\to A^{i + 1} $ such that $ d^2 = 0 $, or $ \\im d_i \\le \\ker d_{i + 1} $, so\n$$ A^0 \\xrightarrow{d_0} A^1 \\xrightarrow{d_1} A^2 \\xrightarrow{d_2} \\dots. $$\n\\end{definition}\n\nLet $ A_* $ and $ B_* $ be chain complexes. Let $ f = \\br{f_i} $ be a family of $ R $-module homomorphisms $ f_i : A_i \\to B_i $. Say that $ f $ is a \\textbf{map of chain complexes} if $ f \\circ d = d \\circ f $, that is $ f_i \\circ d_i^A = d_i^B \\circ f_{i + 1} $. So\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_{n + 1}} & A_{n + 1} \\arrow{r}{d_n} \\arrow{d}{f_{n + 1}} & A_n \\arrow{r}{d_{n - 1}} \\arrow{d}{f_n} & A_{n - 1} \\arrow{r}{d_{n - 2}} \\arrow{d}{f_{n - 1}} & \\dots \\\\\n\\dots \\arrow{r}[swap]{d_{n + 1}} & B_{n + 1} \\arrow{r}[swap]{d_n} & B_n \\arrow{r}[swap]{d_{n - 1}} & A_{n - 1} \\arrow{r}[swap]{d_{n - 2}} & \\dots\n\\end{tikzcd}\n$$\ncommutes. Say that $ f $ \\textbf{has property $ \\PPP $} if all $ f_i $ have property $ \\PPP $, where $ \\PPP $ is injective, surjective, etc. A sequence\n$$ A_* \\xrightarrow{f} B_* \\xrightarrow{g} C_* $$\nis \\textbf{exact} at $ B_* $ if\n$$ A_n \\xrightarrow{f_n} B_n \\xrightarrow{g_n} C_n $$\nis exact at $ B_n $ for all $ n $. A sequence of chain complexes is \\textbf{exact} if it is exact everywhere. An exact sequence\n$$ 0 \\to A_* \\to B_* \\to C_* \\to 0 $$\nis a \\textbf{short exact sequence} of chain complexes.\n\n\\subsection{Homology groups}\n\n\\begin{definition}\nLet $ A_* $ be a chain complex. The \\textbf{$ n $-th homology group} of $ A_* $ is $ \\ker d_{n - 1} / \\im d_n $. We write $ \\H_n\\br{A_*} $. Also write $ \\H_*\\br{A_*} = \\br{\\H_n\\br{A_*}} $.\n\\end{definition}\n\n\\begin{definition}\nLet $ A^* $ be a cochain complex. The \\textbf{$ n $-th cohomology group} of $ A^* $ is $ \\ker d_n / \\im d_{n - 1} $. We write $ \\H^n\\br{A^*} $, and $ \\H^*\\br{A^*} = \\br{\\H^n\\br{A^*}} $.\n\\end{definition}\n\n\\begin{example*}\nLet $ A_i = \\ZZ^3 $ for all $ i $, and let $ d\\br{a, b, c} = \\br{0, 0, a} $. Certainly $ d^2 = 0 $, so this is a chain complex. Then $ \\ker d = \\cbr{\\br{0, b, c}} = 0 \\oplus \\ZZ^2 $ and $ \\im d = \\cbr{\\br{0, 0, a}} = 0^2 \\oplus \\ZZ $. Now $ \\ker d_{n - 1} / \\im d_n = \\cbr{\\br{0, b, 0} + 0^2 \\oplus \\ZZ} $.\n\\end{example*}\n\n\\begin{proposition}\nA map of chain complexes $ f : A_* \\to B_* $ induces a map on the homology,\n$$ f_* : \\H_*\\br{A_*} \\to \\H_*\\br{B_*}, $$\ngiven by\n$$ \\function[f_{*i}]{\\H_i\\br{A_*}}{\\H_i\\br{B_*}}{x + \\im d_i^A}{f_i\\br{x} + \\im d_i^B}. $$\n\\end{proposition}\n\n\\begin{proof}\nLet $ x \\in \\ker d_{i - 1}^A $. Then $ \\br{f_{i - 1} \\circ d_{i - 1}^A}\\br{x} = 0 $, so $ \\br{d_{i - 1}^B \\circ f_i}\\br{x} = 0 $. Hence $ f_i\\br{x} \\in \\ker d_{i - 1}^B $. So $ f_i $ certainly induces a map $ \\overline{f_i} : \\ker d_{i - 1}^A \\to \\ker d_{i - 1}^B / \\im d_i^B $. Let $ x \\in \\im d_i^A $. So there exists $ y \\in A_{i + 1} $ with $ d_i^A\\br{y} = x $. Now $ f_i\\br{x} = \\br{f_i \\circ d_i^A}\\br{y} = \\br{d_i^B \\circ f_{i + 1}}\\br{y} \\in \\im d_i^B $, so $ \\overline{f_i}\\br{x} = 0 $. Hence $ \\im d_i^A \\le \\ker \\overline{f_i} $ so $ \\overline{f_i} $ induces a map\n$$ \\H_i\\br{A_*} = \\ker d_{i - 1}^A / \\im d_i^A \\to \\ker d_{i - 1}^B / \\im d_i^B = \\H_i\\br{B_*}. $$\n\\end{proof}\n\n\\pagebreak\n\nLet $ A_* $ and $ B_* $ be chain complexes, and let $ f $ and $ g $ be maps between them. We say that $ f $ and $ g $ are \\textbf{equal up to homotopy} if there exist maps $ s_i : A_i \\to B_{i + 1} $ such that\n$$ g_i - f_i = s_{i - 1} \\circ d_{i - 1}^A + d_i^B \\circ s_i. $$\n\n\\begin{proposition}\nIf $ f, g : A_* \\to B_* $ are equal up to homotopy, then $ f_* = g_* $, so $ f $ and $ g $ induce the same map on homology.\n\\end{proposition}\n\n\\begin{proof}\nExercise. \\footnote{Exercise}\n\\end{proof}\n\n\\subsection{The long exact sequence in homology}\n\n\\begin{proposition}\n\\label{prop:homologysequence}\nLet\n$$ 0 \\to A_* \\xrightarrow{f} B_* \\xrightarrow{g} C_* \\to 0 $$\nbe a short exact sequence. This induces a long exact sequence of homology groups,\n$$ \\dots \\to \\H_{n + 1}\\br{A_*} \\to \\H_{n + 1}\\br{B_*} \\to \\H_{n + 1}\\br{C_*} \\to \\H_n\\br{A_*} \\to \\H_n\\br{B_*} \\to \\H_n\\br{C_*} \\to \\dots. $$\n\\end{proposition}\n\n\\begin{proof}\nWe have a commuting diagram with exact rows\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A_{n + 1} \\arrow{r}{f_{n + 1}} \\arrow{d}{d_n^A} & B_{n + 1} \\arrow{r}{g_{n + 1}} \\arrow{d}{d_n^B} & C_{n + 1} \\arrow{r} \\arrow{d}{d_n^C} & 0 \\\\\n0 \\arrow{r} & A_n \\arrow{r}[swap]{f_n} & B_n \\arrow{r}[swap]{g_n} & C_n \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nNotice $ \\im d_n \\le \\ker d_{n - 1} $, so we can change this to\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A_{n + 1} \\arrow{r}{f_{n + 1}} \\arrow{d}{d_n^A} & B_{n + 1} \\arrow{r}{g_{n + 1}} \\arrow{d}{d_n^B} & C_{n + 1} \\arrow{r} \\arrow{d}{d_n^C} & 0 \\\\\n0 \\arrow{r} & \\ker d_{n - 1}^A \\arrow{r}[swap]{f_n} & \\ker d_{n - 1}^B \\arrow{r}[swap]{g_n} & \\ker d_{n - 1}^C &\n\\end{tikzcd}.\n$$\nNow $ \\im d_{n + 1} \\le \\ker d_n $, so the maps $ A_{n + 1} \\to \\ker d_{n + 1} $ induce maps $ A_{n + 1} / \\im d_{n + 1} \\to \\ker d_{n - 1} $. So we get a diagram\n$$\n\\begin{tikzcd}\n& A_{n + 1} / \\im d_{n + 1}^A \\arrow{r}{f_{n + 1}} \\arrow{d}{\\overline{d_n^A}} & B_{n + 1} / \\im d_{n + 1}^B \\arrow{r}{g_{n + 1}} \\arrow{d}{\\overline{d_n^B}} & C_{n + 1} / \\im d_{n + 1}^C \\arrow{r} \\arrow{d}{\\overline{d_n^C}} & 0 \\\\\n0 \\arrow{r} & \\ker d_{n - 1}^A \\arrow{r}[swap]{f_n} & \\ker d_{n - 1}^B \\arrow{r}[swap]{g_n} & \\ker d_{n - 1}^C &\n\\end{tikzcd}.\n$$\nWe are now in the position to apply the snake lemma, so\n$$ \\ker \\overline{d_n^A} \\to \\ker \\overline{d_n^B} \\to \\ker \\overline{d_n^C} \\to \\coker \\overline{d_n^A} \\to \\coker \\overline{d_n^B} \\to \\coker \\overline{d_n^C} $$\nis an exact sequence. Then\n$$ \\ker \\overline{d_n^A} = \\ker d_n^A / \\im d_{n + 1}^A = \\H_{n + 1}\\br{A_*}, \\qquad \\coker \\overline{d_n^A} = \\ker d_{n - 1}^A / \\im d_n^A = \\H_n\\br{A_*}. $$\nSimilarly for $ B_* $ and $ C_* $. So we have an exact sequence\n$$ \\H_{n + 1}\\br{A_*} \\to \\H_{n + 1}\\br{B_*} \\to \\H_{n + 1}\\br{C_*} \\to \\H_n\\br{A_*} \\to \\H_n\\br{B_*} \\to \\H_n\\br{C_*}. $$\nSince consecutive values of $ i $ give sequences overlapping in three terms we can glue them together, to give the long exact sequence in Proposition \\ref{prop:homologysequence}.\n\\end{proof}\n\n\\pagebreak\n\n\\section{Derived functors}\n\n\\subsection{Covariant and contravariant functors}\n\n\\lecture{21}{Tuesday}{25/02/20}\n\nThe following are two variations.\n\n\\begin{definition}\nA \\textbf{covariant functor} $ F $ from the category of left or right $ R $-modules to the category of abelian groups is a map from $ R $-modules to abelian groups such that if $ \\phi : M \\to N $ is an $ R $-module homomorphism then there exists an abelian group homomorphism\n$$ F\\br{\\phi} : F\\br{M} \\to F\\br{N}, $$\nwhich respects identity maps, so $ F\\br{\\id_M} = \\id_{F\\br{M}} $, and respects composition, so\n$$ F\\br{\\phi_1 \\circ \\phi_2} = F\\br{\\phi_1} \\circ F\\br{\\phi_2}. $$\n\\end{definition}\n\nThe map $ F $ on homomorphisms is \\textbf{additive} if $ F\\br{\\phi_1 + \\phi_2} = F\\br{\\phi_1} + F\\br{\\phi_2} $. If\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nis a short exact sequence, then $ F $ is \\textbf{right exact} if\n$$ F\\br{A} \\to F\\br{B} \\to F\\br{C} \\to 0 $$\nis exact, and \\textbf{left exact} if\n$$ 0 \\to F\\br{A} \\to F\\br{B} \\to F\\br{C} $$\nis exact. Then $ F $ is \\textbf{exact} if both left and right exact.\n\n\\begin{definition}\nA \\textbf{contravariant functor} $ F $ from the category of left or right $ R $-modules to the category of abelian groups is a map from $ R $-modules to abelian groups such that if $ \\phi : M \\to N $ is an $ R $-module homomorphism then there exists an abelian group homomorphism\n$$ F\\br{\\phi} : F\\br{N} \\to F\\br{M}, $$\nwhich respects identity maps, so $ F\\br{\\id_M} = \\id_{F\\br{M}} $, and respects composition, so\n$$ F\\br{\\phi_1 \\circ \\phi_2} = F\\br{\\phi_2} \\circ F\\br{\\phi_1}. $$\n\\end{definition}\n\nSimilarly, if\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nis a short exact sequence, then $ F $ is \\textbf{right exact} if\n$$ F\\br{C} \\to F\\br{B} \\to F\\br{A} \\to 0 $$\nis exact, and \\textbf{left exact} if\n$$ 0 \\to F\\br{C} \\to F\\br{B} \\to F\\br{A} $$\nis exact.\n\n\\begin{example*}\nThe following are some functors we have seen. Fix a left $ R $-module $ M $.\n\\begin{itemize}\n\\item $ F\\br{A} = \\Hom_R\\br{M, A} $, where\n$$ \\function[F\\br{\\phi}]{F\\br{A} = \\Hom_R\\br{M, A}}{F\\br{B} = \\Hom_R\\br{M, B}}{f}{\\phi \\circ f}, \\qquad \\phi : A \\to B, $$\nis covariant, left exact, and exact if and only if $ M $ is projective.\n\\item $ F\\br{A} = \\Hom_R\\br{A, M} $, where\n$$ \\function[F\\br{\\phi}]{F\\br{B} = \\Hom_R\\br{B, M}}{F\\br{A} = \\Hom_R\\br{A, M}}{f}{f \\circ \\phi}, \\qquad \\phi : A \\to B, $$\nis contravariant, left exact, and exact if and only if $ M $ is injective.\n\\item For $ A $ a right $ R $-module, $ F\\br{A} = A \\otimes_R M $ is covariant, right exact, and exact if and only if $ M $ is flat.\n\\end{itemize}\n\\end{example*}\n\n\\pagebreak\n\n\\subsection{Left derived functors}\n\nLet $ F $ be the functor $ F\\br{A} = A \\otimes_R M $, where $ M $ is a fixed $ R $-module. Let $ P_* \\to A $ be a projective resolution for $ A $. So $ P_* = \\br{P_i}_{i \\ge 0} $ for $ P_i $ projective, and\n$$ \\dots \\xrightarrow{d_2} P_2 \\xrightarrow{d_1} P_1 \\xrightarrow{d_0} P_0 \\xrightarrow{\\phi} A \\to 0 $$\nis exact. Consider the sequence\n$$ \\dots \\to P_2 \\to P_1 \\to P_0 \\to 0. $$\nThis is no longer exact, but it is a chain complex. And if we apply $ F $, we get a chain complex $ F\\br{P_*} $,\n$$ \\dots \\to F\\br{P_2} \\to F\\br{P_1} \\to F\\br{P_0} \\to 0. $$\nDefine \\textbf{left derived functors}\n$$ \\L_nF\\br{A} = \\H_n\\br{F\\br{P_*}}. $$\n\n\\begin{theorem}\n\\hfill\n\\begin{enumerate}\n\\item $ \\L_nF\\br{A} $ does not depend on the choice of resolution $ P_* $.\n\\item $ \\L_nF $ is an additive functor from right $ R $-modules to abelian groups.\n\\item $ \\L_0F\\br{A} = F\\br{A} $.\n\\end{enumerate}\n\\end{theorem}\n\n\\lecture{22}{Friday}{28/02/20}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item Let $ P_* \\to A $ and $ Q_* \\to A $ be projective resolutions. Then there exist maps of chain complexes $ f : P_* \\to Q_* $ and $ g : Q_* \\to P_* $. So $ g \\circ f : P_* \\to P_* $, so\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{d_2} & P_2 \\arrow{r}{d_1} \\arrow{d}{g_2 \\circ f_2} & P_1 \\arrow{r}{d_0} \\arrow{d}{g_1 \\circ f_1} & P_0 \\arrow{r} \\arrow{d}{g_0 \\circ f_0} & A \\arrow{r} \\arrow{d}{\\id} & 0 \\\\\n\\dots \\arrow{r}[swap]{d_2} & P_2 \\arrow{r}[swap]{d_1} & P_1 \\arrow{r}[swap]{d_0} & P_0 \\arrow{r} & A \\arrow{r} & 0\n\\end{tikzcd},\n$$\nand $ g \\circ f $ is equal to $ \\id $ up to homotopy. Apply $ F $ to everything. Since $ F $ is right exact,\n$$\n\\begin{tikzcd}\n\\dots \\arrow{r}{F\\br{d_2}} & F\\br{P_2} \\arrow{r}{F\\br{d_1}} \\arrow{d}{F\\br{g_2} \\circ F\\br{f_2}} & F\\br{P_1} \\arrow{r}{F\\br{d_0}} \\arrow{d}{F\\br{g_1} \\circ F\\br{f_1}} & F\\br{P_0} \\arrow{r} \\arrow{d}{F\\br{g_0} \\circ F\\br{f_0}} & F\\br{A} \\arrow{r} \\arrow{d}{\\id} & 0 \\\\\n\\dots \\arrow{r}[swap]{F\\br{d_2}} & F\\br{P_2} \\arrow{r}[swap]{F\\br{d_1}} & F\\br{P_1} \\arrow{r}[swap]{F\\br{d_0}} & F\\br{P_0} \\arrow{r} & F\\br{A} \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nThe diagram remains commutative, since $ F $ preserves composition. Now\n$$ g_i \\circ f_i - \\id = s_{i - 1} \\circ d_{i - 1} + d_i \\circ s_i, $$\nfor suitable maps $ s_i $. Then\n$$ F\\br{g_i} \\circ F\\br{f_i} - \\id = F\\br{s_{i - 1}} \\circ F\\br{d_{i - 1}} + F\\br{d_i} \\circ F\\br{s_i}, $$\nso $ F\\br{g_i} \\circ F\\br{f_i} $ is $ \\id $ up to homotopy. Hence $ F\\br{g} \\circ F\\br{f} $ induces the identity on homology $ \\H_*\\br{F\\br{P_*}} $. Also $ F\\br{f} \\circ F\\br{g} $ induces the identity on $ \\H_*\\br{F\\br{Q_*}} $. Now we have\n$$ \\overline{F\\br{f_i}} : \\H_i\\br{F\\br{P_*}} \\to \\H_i\\br{F\\br{Q_*}}, \\qquad \\overline{F\\br{g_i}} : \\H_i\\br{F\\br{Q_*}} \\to \\H_i\\br{F\\br{P_*}}, $$\nand $ \\overline{F\\br{f_i}} \\circ \\overline{F\\br{g_i}} = \\id $ and $ \\overline{F\\br{g_i}} \\circ \\overline{F\\br{f_i}} = \\id $, so $ \\overline{F\\br{f_i}} $ and $ \\overline{F\\br{g_i}} $ are isomorphisms. So\n$$ \\H_n\\br{F\\br{P_*}} \\cong \\H_n\\br{F\\br{Q_*}}, $$\nas required. This argument tells us nothing about $ \\H_0\\br{F\\br{P_*}} $.\n\n\\pagebreak\n\n\\item Let $ \\phi : A \\to B $. Let $ P_* \\to A $ and $ Q_* \\to B $ be projective resolutions. Then there exists $ f : P_* \\to Q_* $ such that\n$$\n\\begin{tikzcd}\nP_* \\arrow{r} \\arrow{d}[swap]{f} & A \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\nQ_* \\arrow{r} & B \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes. Then $ F $ is covariant and right exact. So\n$$\n\\begin{tikzcd}\nF\\br{P_*} \\arrow{r} \\arrow{d}[swap]{F\\br{f}} & F\\br{A} \\arrow{r} \\arrow{d}{F\\br{\\phi}} & 0 \\\\\nF\\br{Q_*} \\arrow{r} & F\\br{B} \\arrow{r} & 0\n\\end{tikzcd}\n$$\nis commutative, where $ F\\br{f} = \\br{F\\br{f_i}} $. If $ g : P_* \\to Q_* $ is such that\n$$\n\\begin{tikzcd}\nP_* \\arrow{r} \\arrow{d}[swap]{g} & A \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\nQ_* \\arrow{r} & B \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes, then $ \\overline{f} $ and $ \\overline{g} $, the induced maps on homology, are equal. So there exists a map $ \\overline{F\\br{f_i}} : \\L_iF\\br{A} \\to \\L_iF\\br{B} $, and is independent of the choice of $ f $. So we can write $ \\L_nF\\br{\\phi} = \\overline{F\\br{f_i}} $. Then $ \\L_nF $ preserves $ \\id $ and compositions and is additive, since $ F $ is an additive functor. \\footnote{Exercise}\n\\item We have a short exact sequence\n$$ 0 \\to \\im d_0 \\xrightarrow{\\subset} P_0 \\xrightarrow{\\phi} A \\to 0. $$\nSince $ F $ is right exact, we get an exact sequence\n$$ F\\br{\\im d_0} \\to F\\br{P_0} \\to F\\br{A} \\to 0. $$\nNow $ d_0 : P_1 \\to \\im d_0 $ is surjective, and $ F $ preserves surjectivity. So $ F\\br{d_0} : F\\br{P_1} \\to F\\br{\\im d_0} $ is surjective. So\n$$ F\\br{P_1} \\to F\\br{P_0} \\to F\\br{A} \\to 0 $$\nis exact. So, setting $ P_{-1} = 0 $, we get $ \\L_0F\\br{P_*} = F\\br{P_0} / \\im F\\br{d_0} = F\\br{A} $.\n\\end{enumerate}\n\\end{proof}\n\n\\subsection{The long exact sequence of left derived functors}\n\n\\begin{proposition}[Horseshoe lemma]\nSuppose\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nis an exact sequence of $ R $-modules. Suppose $ P_* \\to A $ and $ R_* \\to C $ are projective resolutions. Define $ Q_i = P_i \\oplus R_i $. Then there exist maps $ Q_{i + 1} \\to Q_i $ and $ Q_0 \\to B $ such that $ Q_* \\to B $ is a projective resolution, and such that\n$$\n\\begin{tikzcd}[row sep=small]\n& 0 \\arrow{d} & 0 \\arrow{d} & 0 \\arrow{d} & 0 \\arrow{d} & \\\\\n\\dots \\arrow{r} & P_2 \\arrow{r} \\arrow{d}{\\iota} & P_1 \\arrow{r} \\arrow{d}{\\iota} & P_0 \\arrow{r} \\arrow{d}{\\iota} & A \\arrow{r} \\arrow{d} & 0 \\\\\n\\dots \\arrow[dashed]{r} & Q_2 \\arrow[dashed]{r} \\arrow{d}{\\pi} & Q_1 \\arrow[dashed]{r} \\arrow{d}{\\pi} & Q_0 \\arrow[dashed]{r} \\arrow{d}{\\pi} & B \\arrow[dashed]{r} \\arrow{d} & 0 \\\\\n\\dots \\arrow{r} & R_2 \\arrow{r} \\arrow{d} & R_1 \\arrow{r} \\arrow{d} & R_0 \\arrow{r} \\arrow{d} & C \\arrow{r} \\arrow{d} & 0 \\\\\n& 0 & 0 & 0 & 0 &\n\\end{tikzcd}\n$$\ncommutes, where if $ x \\in P_i $ and $ y \\in R_i $ then $ \\iota\\br{x} = \\br{x, 0} $ and $ \\pi\\br{x, y} = y $.\n\\end{proposition}\n\n\\pagebreak\n\n\\begin{proof}\nNote that $ Q_i $ is a direct sum of projectives, so is itself projective. We have the setup\n$$\n\\begin{tikzcd}[row sep=small]\n0 \\arrow{d} & 0 \\arrow{d} & \\\\\nP_0 \\arrow{r}{\\phi} \\arrow{d}[swap]{\\iota} & A \\arrow{r} \\arrow{d}{f} & 0 \\\\\nQ_0 \\arrow{d}[swap]{\\pi} & B \\arrow{d}{g} & \\\\\nR_0 \\arrow{r}[swap]{\\psi} \\arrow{d} & C \\arrow{r} \\arrow{d} & 0 \\\\\n0 & 0 &\n\\end{tikzcd}.\n$$\nSince $ B \\to C $ is surjective, and $ R_0 $ is projective, there exists $ h : R_0 \\to B $ such that $ g \\circ h = \\psi $. Now define\n$$ \\function[\\chi]{Q_0}{B}{\\br{x, y}}{\\br{f \\circ \\phi}\\br{x} + h\\br{y}}, \\qquad x \\in P_0, \\qquad y \\in R_0. $$\nThis construction guarantees that the squares are commutative. It is easy to see that $ \\chi $ is surjective, so\n$$\n\\begin{tikzcd}[row sep=small]\n0 \\arrow{d} & 0 \\arrow{d} & \\\\\nP_0 \\arrow{r}{\\phi} \\arrow{d}[swap]{\\iota} & A \\arrow{r} \\arrow{d}{f} & 0 \\\\\nQ_0 \\arrow[dashed]{r}{\\chi} \\arrow{d}[swap]{\\pi} & B \\arrow[dashed]{r} \\arrow{d}{g} & 0 \\\\\nR_0 \\arrow[dashed]{ur}{h} \\arrow{r}[swap]{\\psi} \\arrow{d} & C \\arrow{r} \\arrow{d} & 0 \\\\\n0 & 0 &\n\\end{tikzcd}.\n$$\nNow we have a short exact sequence\n$$ 0 \\to \\ker \\phi \\xrightarrow{\\iota} \\ker \\chi \\xrightarrow{\\pi} \\ker \\psi \\to 0, $$\nby the snake lemma. So now we can iterate, replacing $ A, B, C $ with these kernels, to construct a map $ Q_1 \\to Q_0 $, and so on.\n\\end{proof}\n\n\\begin{proposition}\nLet $ F $ be an additive functor, and let $ A $ and $ B $ be $ R $-modules. There is a canonical isomorphism $ F\\br{A} \\oplus F\\br{B} \\to F\\br{A \\oplus B} $.\n\\end{proposition}\n\n\\begin{proof}\nLet $ M = A \\oplus B $. Consider functions\n$$ \\function[p_1]{M}{M}{\\br{a, b}}{\\br{a, 0}}, \\qquad \\function[p_2]{M}{M}{\\br{a, b}}{\\br{0, b}}. $$\nThen\n$$ p_i^2 = p_i, \\qquad p_1 \\circ p_2 = p_2 \\circ p_1 = 0, \\qquad p_1 + p_2 = \\id_M. $$\nIf $ q_1 $ and $ q_2 $ are maps on a module $ M $ satisfying these relations, then $ M = q_1\\br{M} \\oplus q_2\\br{M} $.\n\\end{proof}\n\n\\lecture{23}{Monday}{02/03/20}\n\n\\begin{proposition}\nLet\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nbe a short exact sequence of right $ R $-modules. This gives rise to a long exact sequence\n$$ \\dots \\to \\L_nF\\br{A} \\to \\L_nF\\br{B} \\to \\L_nF\\br{C} \\to \\dots \\to \\L_0F\\br{A} \\to \\L_0F\\br{B} \\to \\L_0F\\br{C} \\to 0. $$\n\\end{proposition}\n\n\\pagebreak\n\n\\begin{proof}\nLet $ P_* \\to A $ be a projective resolution and $ R_* \\to C $ be a projective resolution. By the horseshoe lemma, there exists a projective resolution $ Q_* \\to B $ such that\n$$ 0 \\to P_* \\to Q_* \\to R_* \\to 0 $$\nis a split short exact sequence of chain complexes, that is $ Q_i = P_i \\oplus R_i $. Since $ Q_i = P_i \\oplus R_i $, and since $ F $ is an additive functor, we have $ F\\br{Q_i} = F\\br{P_i} \\oplus F\\br{R_i} $. So\n$$ 0 \\to F\\br{P_*} \\to F\\br{Q_*} \\to F\\br{R_*} \\to 0 $$\nis a short exact sequence. Therefore we get a long exact sequence on homology,\n$$ \\dots \\to \\H_n\\br{F\\br{P_*}} \\to \\H_n\\br{F\\br{Q_*}} \\to \\H_n\\br{F\\br{R_*}} \\to \\dots. $$\nSince $ \\H_n\\br{F\\br{P_*}} = \\L_nF\\br{A} $ this gives the long sequence that we need. Since $ \\L_0F\\br{A} = F\\br{A} $, and $ F $ is right exact, the sequence terminates\n$$ \\L_0F\\br{A} \\to \\L_0F\\br{B} \\to \\L_0F\\br{C} \\to 0, $$\nas required.\n\\end{proof}\n\n\\subsection{General derived functors}\n\n\\begin{proposition}\n\\hfill\n\\begin{itemize}\n\\item Let $ F $ be any covariant, right exact, additive functor from left or right $ R $-modules to abelian groups. Then the left derived functors $ \\L_nF $ can be defined in just the same way as we did for the case $ F\\br{A} = A \\otimes_R M $. All of the results we have proved follow in the more general case, by the same arguments.\n\\item If $ F $ is a covariant, left exact, additive functor from $ R $-modules to abelian groups, then we can define \\textbf{right derived functors} $ \\R^iF $ in a similar manner. Instead of working with a projective resolution, we use an injective resolution,\n$$ 0 \\to A \\to I_0 \\to I_1 \\to I_2 \\to \\dots. $$\nBy similar arguments, we show that $ \\R^iF\\br{A} $ is independent of the choice of injective resolution. All of the results we proved for left derived functors have natural analogies for right derived functors. The argument requires a version of the horseshoe lemma for injective resolutions, which is exactly what one might expect.\n\\item We can even construct derived functors for contravariant functors. If $ F $ is contravariant and right exact, so\n$$ 0 \\to A \\to I_0 \\to I_1 \\to I_2 \\to \\dots $$\ngives\n$$ \\dots \\to F\\br{I_2} \\to F\\br{I_1} \\to F\\br{I_0} \\to F\\br{A} \\to 0, $$\nwe get a left derived functor, which is defined using an injective resolution. If $ F $ is contravariant and left exact, so\n$$ \\dots \\to P_2 \\to P_1 \\to P_0 \\to A \\to 0 $$\ngives\n$$ 0 \\to F\\br{A} \\to F\\br{P_0} \\to F\\br{P_1} \\to F\\br{P_2} \\to \\dots, $$\nwe get a right derived functor, which is defined using a projective resolution.\n\\end{itemize}\n\\end{proposition}\n\n\\pagebreak\n\n\\section{Tor and Ext functors}\n\n\\subsection{Tor and Ext}\n\n\\begin{definition}\nLet $ F $ be the functor $ F\\br{A} = A \\otimes_R B $. Then $ F $ is covariant, right exact, and additive. So $ \\L_nF $ exists. Define\n$$ \\Tor_i^R\\br{A, B} = \\L_iF\\br{A}. $$\n\\end{definition}\n\n\\begin{fact*}\nLet $ F' $ be the functor $ F'\\br{B} = A \\otimes_R B $. Then $ F' $ is covariant, right exact, and additive. So $ \\L_nF' $ exists. We have\n$$ \\L_iF'\\br{B} \\cong \\L_iF\\br{A} = \\Tor_i^R\\br{A, B}. $$\n\\end{fact*}\n\n\\begin{definition}\nLet $ F $ be the functor $ F\\br{B} = \\Hom_R\\br{A, B} $. Then $ F $ is covariant, left exact, and additive, so $ \\R^nF $ exists. Define\n$$ \\Ext_R^i\\br{A, B} = \\R^iF\\br{B}. $$\n\\end{definition}\n\n\\begin{fact*}\nLet $ F' $ be the functor $ F'\\br{A} = \\Hom_R\\br{A, B} $. Then $ F' $ is contravariant, left exact, and additive, so $ \\R^nF' $ exists. We have\n$$ \\R^iF'\\br{A} \\cong \\R^iF\\br{B} = \\Ext_R^i\\br{A, B}. $$\n\\end{fact*}\n\nThe two facts above are the \\textbf{balancing theorems} for Tor and Ext. Their proof is beyond the scope of the course. The following is an observation. Suppose $ A $ is projective. Then a projective resolution for $ A $ is\n$$ 0 \\to \\dots \\to 0 \\to A \\xrightarrow{\\id} A \\to 0. $$\nSo $ \\L_iF\\br{A} = 0 $ for $ i \\ge 1 $, and $ \\L_0F\\br{A} = F\\br{A} $, for $ F $ possessing left derived functors. Similarly, if $ A $ is injective, then an injective resolution is\n$$ 0 \\to A \\xrightarrow{\\id} A \\to 0 \\to \\dots \\to 0, $$\nso $ \\R^iF\\br{A} = 0 $ for $ i \\ge 1 $, and $ \\R^0F\\br{A} = F\\br{A} $, for $ F $ possessing right derived functors.\n\n\\subsection{Tor, flatness, and torsion}\n\nIn fact the property $ \\Tor_i^R\\br{A, B} = 0 $ for all $ i \\ge 1 $ characterises flat modules, so either $ A $ or $ B $ is flat.\n\n\\begin{proposition}\nLet $ F\\br{A} = A \\otimes_R B $. Then $ \\Tor_i^R\\br{A, B} = \\L_iF\\br{A} = 0 $ for all $ i \\ge 1 $ and for all $ A $ if and only if $ B $ is flat.\n\\end{proposition}\n\nSimilarly if $ F'\\br{B} = A \\otimes_R B $, then $ \\L_iF'\\br{B} = 0 $ for all $ i \\ge 1 $ and for all $ B $ if and only if $ A $ is flat.\n\n\\lecture{24}{Tuesday}{03/03/20}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\impliedby $] If $ B $ is flat then $ F\\br{A} = A \\otimes_R B $ is exact, so\n$$ 0 \\to L \\to M \\to N \\to 0 $$\nis exact implies that\n$$ 0 \\to F\\br{L} \\to F\\br{M} \\to F\\br{N} \\to 0 $$\nis exact, or $ F $ maps kernels to kernels and cokernels to cokernels. Let $ P_* \\to A $ be a projective resolution. Then\n$$ \\dots \\to P_2 \\to P_1 \\to P_0 \\to 0 $$\nis exact everywhere except $ P_0 $. So\n$$ \\dots \\to F\\br{P_2} \\to F\\br{P_1} \\to F\\br{P_0} \\to 0 $$\nis exact everywhere except $ F\\br{P_0} $. So $ \\L_nF\\br{P_*} = 0 $ for $ n \\ge 1 $. But $ \\L_nF\\br{P_*} = \\Tor_n^R\\br{A, B} $.\n\n\\pagebreak\n\n\\item[$ \\implies $] Conversely, suppose $ \\Tor_1^R\\br{A, B} = 0 $ for all $ A $. Let\n$$ 0 \\to L \\to M \\to N \\to 0 $$\nbe exact. This gives a long exact sequence of homology groups\n$$\n\\begin{tikzcd}[column sep=small, row sep=tiny]\n\\dots \\arrow{r} & \\L_1F\\br{L} \\arrow{r} & \\L_1F\\br{M} \\arrow{r} & \\L_1F\\br{N} \\arrow{r} \\arrow[cong]{d} & L \\otimes_R B \\arrow{r} & M \\otimes_R B \\arrow{r} & N \\otimes_R B \\arrow{r} & 0 \\\\\n& & & \\Tor_1^R\\br{N, B} & & & &\n\\end{tikzcd}.\n$$\nSince $ \\Tor_1^R\\br{N, B} = 0 $, we get a short exact sequence\n$$ 0 \\to L \\otimes_R B \\to M \\otimes_R B \\to N \\otimes_R B \\to 0. $$\nSo $ F\\br{A} = A \\otimes_R B $ is left exact, and so $ B $ is flat.\n\\end{itemize}\n\\end{proof}\n\n\\begin{proposition}\nLet $ A $ and $ B $ be abelian groups. Then\n$$ \\Tor_n^\\ZZ\\br{A, B} = 0, \\qquad n > 1. $$\n\\end{proposition}\n\n\\begin{proof}\n$ A $ is a quotient of some free module $ K $, say\n$$ K \\xrightarrow{f} A \\to 0. $$\nNow $ \\ker f \\le K $, and since $ \\ZZ $ is a PID, $ \\ker f $ is free, since it is a submodule of a free module. So\n$$ \\dots \\to 0 \\to \\ker f \\to K \\to A \\to 0 $$\nis a projective resolution for $ A $. Since all of the modules above $ P_1 $ in the resolution are zero, clearly $ \\H_n\\br{F\\br{P_*}} = 0 $ for $ n > 1 $.\n\\end{proof}\n\n\\begin{fact*}\n$$ \\Tor_1^\\ZZ\\br{A, \\QQ / \\ZZ} = \\T\\br{A} = \\cbr{a \\in A \\st a \\ \\text{has finite order}}. $$\nThe proof is omitted.\n\\end{fact*}\n\n\\subsection{Baer sums of extensions}\n\n\\begin{proposition}\nLet $ A $ and $ B $ be abelian groups. Then\n$$ \\Ext_\\ZZ^n\\br{A, B} = 0, \\qquad n > 1. $$\n\\end{proposition}\n\n\\begin{proof}\nProblem sheet question.\n\\end{proof}\n\nMore generally, $ \\Ext_R^1\\br{A, C} $ tells us about \\textbf{extensions} of $ C $ by $ A $, that is $ B $ such that\n$$ 0 \\to A \\to B \\to C \\to 0. $$\nLet $ B_1 $ and $ B_2 $ be two extensions of $ C $ by $ A $. Write $ B_1 \\sim B_2 $ if there exists a \\textbf{map of extensions} $ f : B_1 \\to B_2 $ such that\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r}{\\alpha_1} \\arrow[cong]{d} & B_1 \\arrow{r}{\\beta_1} \\arrow{d}{f} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r}[swap]{\\alpha_2} & B_2 \\arrow{r}[swap]{\\beta_2} & C \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes.\n\n\\pagebreak\n\n\\begin{proposition}\nAny such $ f $ is an isomorphism.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item $ f $ is surjective. Suppose $ y \\in B_2 $. Then $ \\beta_2\\br{y} \\in C $, and $ \\beta_1 $ is surjective, so $ \\beta_2\\br{y} = \\beta_1\\br{x} $ for some $ x \\in B_1 $. Now $ f\\br{x} - y \\in \\ker \\beta_2 = \\im \\alpha_2 $, so $ f\\br{x} - y = \\alpha_2\\br{a} $ for some $ a \\in A $. So $ f\\br{x} - y = \\br{f \\circ \\alpha_1}\\br{a} $, and so $ y = f\\br{x} - \\br{f \\circ \\alpha_1}\\br{a} = f\\br{x - \\alpha_1\\br{a}} $.\n\\item $ f $ is injective. Suppose $ f\\br{x} = f\\br{y} $ for $ x, y \\in B_1 $. Then $ f\\br{x - y} = 0 $, so $ \\br{\\beta_2 \\circ f}\\br{x - y} = 0 $, so $ \\beta_1\\br{x - y} = 0 $. So $ x - y \\in \\ker \\beta_1 = \\im \\alpha_1 $, so $ x - y = \\alpha_1\\br{a} $ for some $ a \\in A $. Now $ \\alpha_2\\br{a} = \\br{f \\circ \\alpha_1}\\br{a} = f\\br{x - y} = 0 $. But $ \\alpha_2 $ is injective, so $ a = 0 $, so $ x - y = 0 $.\n\\end{itemize}\n\\end{proof}\n\nHence the relation $ \\sim $ is an equivalence relation. Write $ \\E_C\\br{A} $ for the set of $ \\sim $-equivalence classes. We will put an abelian group structure on $ \\E_C\\br{A} $. Let $ B_1 $ and $ B_2 $ be extensions, so\n$$ 0 \\to A \\xrightarrow{\\alpha_1} B_1 \\xrightarrow{\\beta_1} C \\to 0, \\qquad 0 \\to A \\xrightarrow{\\alpha_2} B_2 \\xrightarrow{\\beta_2} C \\to 0. $$\nDefine maps $ \\alpha^* $ and $ \\beta^* $ by\n$$ \\function[\\alpha^*]{A}{B_1 \\oplus B_2}{a}{\\br{\\alpha_1\\br{a}, -\\alpha_2\\br{a}}}, \\qquad \\function[\\beta^*]{B_1 \\oplus B_2}{C}{\\br{b_1, b_2}}{\\beta_1\\br{b_1} - \\beta_2\\br{b_2}}. $$\nNow $ \\beta^* \\circ \\alpha^* = 0 $. So\n$$ 0 \\to A \\xrightarrow{\\alpha^*} B_1 \\oplus B_2 \\xrightarrow{\\beta^*} C \\to 0 $$\nis a chain complex. Define $ \\sbr{H} = \\sbr{\\H\\br{B_1, B_2}} $, the \\textbf{Baer sum} of $ \\sbr{B_1} $ and $ \\sbr{B_2} $, to be the homology group at $ B_1 \\oplus B_2 $, that is $ H = \\ker \\beta^* / \\im \\alpha^* $. More explicitly,\n$$ H = \\cbr{\\br{b_1, b_2} \\in B_1 \\oplus B_2 \\st \\beta_1\\br{b_1} = \\beta_2\\br{b_2}} / \\cbr{\\br{\\alpha_1\\br{a}, -\\alpha_2\\br{a}} \\st a \\in A}. $$\nClearly $ H $ is an $ R $-module. Now define maps by\n$$ \\function[\\alpha]{A}{H}{a}{\\br{\\alpha_1\\br{a}, 0} + \\im \\alpha^*}, \\qquad \\function[\\beta]{H}{C}{\\br{b_1, b_2} + \\im \\alpha^*}{\\beta_1\\br{b_1}}. $$\n\n\\lecture{25}{Friday}{06/03/20}\n\n\\begin{note*}\n\\hfill\n\\begin{itemize}\n\\item $ \\br{b_1, b_2} \\in \\ker \\beta^* $, so $ \\beta_1\\br{b_1} = \\beta_2\\br{b_2} $.\n\\item $ \\br{\\alpha_1\\br{a}, 0} = \\br{0, \\alpha_2\\br{a}} + \\br{\\alpha_1\\br{a}, -\\alpha_2\\br{a}} $, so $ \\br{\\alpha_1\\br{a}, 0} + \\im \\alpha^* = \\br{0, \\alpha_2\\br{a}} + \\im \\alpha^* $.\n\\end{itemize}\n\\end{note*}\n\n\\begin{proposition}\n$$ 0 \\to A \\xrightarrow{\\alpha} H \\xrightarrow{\\beta} C \\to 0 $$\nis a short exact sequence.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item First check that $ \\beta $ is well-defined. If $ \\br{b_1, b_2} \\in \\br{b_1', b_2'} + \\im \\alpha^* $ then $ \\br{b_1, b_2} = \\br{b_1', b_2'} + \\br{\\alpha_1\\br{a}, -\\alpha_2\\br{a}} $ for some $ a \\in A $. So\n$$ \\beta\\br{\\br{b_1, b_2} + \\im \\alpha^*} = \\beta_1\\br{b_1} = \\beta_1\\br{b_1 - \\alpha_1\\br{a}} = \\beta\\br{\\br{b_1', b_2'} + \\im \\alpha^*}, $$\nsince $ \\beta_1 \\circ \\alpha_1 = 0 $.\n\\item Next check $ \\alpha $ is injective. Suppose $ \\alpha\\br{a} = \\br{0, 0} + \\im \\alpha^* $. Then $ \\br{\\alpha_1\\br{a}, 0} = \\alpha^*a' $ for some $ a' $. So $ \\br{\\alpha_1\\br{a}, 0} = \\br{\\alpha_1\\br{a'}, -\\alpha_2\\br{a'}} $. Since $ \\alpha_1 $ and $ \\alpha_2 $ are injective, $ a = a' = 0 $.\n\\item Next, show $ \\beta $ is surjective. Take $ c \\in C $. Then $ c = \\beta_1\\br{b_1} $ for some $ b_1 \\in B_1 $. Since $ \\beta_2 $ is surjective, there exists $ b_2 \\in B_2 $ with $ \\beta_2\\br{b_2} = \\beta_1\\br{b_1} = c $. Now $ \\br{b_1, b_2} \\in \\ker \\beta^* $, and $ \\beta\\br{\\br{b_1, b_2} + \\im \\alpha^*} = \\beta_1\\br{b_1} = c $.\n\n\\pagebreak\n\n\\item Finally, show that\n$$ 0 \\to A \\to H \\to C \\to 0 $$\nis exact, that is $ \\ker \\beta = \\im \\alpha $. It is clear that $ \\im \\alpha \\le \\ker \\beta $, since $ \\beta_1 \\circ \\alpha_1 = 0 $. For the reverse containment, let $ \\br{b_1, b_2} + \\im \\alpha^* \\in \\ker \\beta $. So $ \\br{b_1, b_2} \\in \\ker \\beta^* $, so $ \\beta_1\\br{b_1} = \\beta_2\\br{b_2} $. And $ \\beta_1\\br{b_1} = 0 $, so $ \\beta_2\\br{b_2} = 0 $ as well. But $ \\ker \\beta_i = \\im \\alpha_i $ for $ i = 1, 2 $, so there exist $ a_1, a_2 \\in A $ with $ \\alpha_1\\br{a_1} = b_1 $ and $ \\alpha_2\\br{a_2} = b_2 $. Now\n\\begin{align*}\n\\br{b_1, b_2}\n& = \\br{\\alpha_1\\br{a_1}, \\alpha_2\\br{a_2}}\n= \\br{\\alpha_1\\br{a_1 + a_2}, 0} + \\br{-\\alpha_1\\br{a_2}, \\alpha_2\\br{a_2}} \\\\\n& \\in \\br{\\alpha_1\\br{a_1 + a_2}, 0} + \\im \\alpha^*\n= \\alpha\\br{a_1 + a_2}\n\\in \\im \\alpha.\n\\end{align*}\n\\end{itemize}\n\\end{proof}\n\nWe have shown that $ H $ is an extension of $ C $ by $ A $.\n\n\\begin{proposition}\nIf $ B_1 \\sim B_1' $ and $ B_2 \\sim B_2' $ then $ \\H\\br{B_1, B_2} \\sim \\H\\br{B_1', B_2'} $, where $ B \\sim B' $ if there exists a map of extensions $ f : B \\to B' $ such that\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & B \\arrow{r} \\arrow{d}{f} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & B' \\arrow{r} & C \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes.\n\\end{proposition}\n\n\\begin{proof}\nSuppose $ f_1 : B_1 \\to B_1' $ and $ f_2 : B_2 \\to B_2' $ are maps of extensions. Then there exists a map of chain complexes\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & B_1 \\oplus B_2 \\arrow{r} \\arrow{d}{\\br{f_1, f_2}} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & B_1' \\oplus B_2' \\arrow{r} & C \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nThis induces a map on homology, $ \\overline{f} : \\H\\br{B_1, B_2} \\to \\H\\br{B_1', B_2'} $. It is easy to check\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & \\H\\br{B_1, B_2} \\arrow{r} \\arrow{d}{\\overline{f}} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & \\H\\br{B_1', B_2'} \\arrow{r} & C \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes, so $ \\H\\br{B_1, B_2} \\sim \\H\\br{B_1', B_2'} $.\n\\end{proof}\n\nWrite $ \\sbr{B} $ for the equivalence class of $ B $. If $ H = \\H\\br{B_1, B_2} $, write $ \\sbr{H} = \\sbr{B_1} + \\sbr{B_2} $, or $ \\sbr{H} = \\sbr{B_1} +_\\B \\sbr{B_2} $.\n\n\\begin{proposition}\n$ + $ gives an abelian group operation on the set $ \\E_C\\br{A} $ of equivalence classes of extensions.\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item Check $ + $ is commutative. This follows easily from the facts that\n$$ \\alpha\\br{a} = \\br{\\alpha_1\\br{0}, 0} + \\im \\alpha^* = \\br{0, \\alpha_2\\br{a}} + \\im \\alpha^*, \\qquad \\beta\\br{\\br{b_1, b_2} + \\im \\alpha^*} = \\beta_1\\br{b_1} = \\beta_2\\br{b_2}. $$\n\\item Associativity is an exercise. \\footnote{Exercise}\n\\item The identity is $ \\sbr{A \\oplus C} $, the \\textbf{split extension}. Let\n$$ 0 \\to A \\xrightarrow{\\alpha} A \\oplus C \\xrightarrow{\\beta} C \\to 0, \\qquad 0 \\to A \\xrightarrow{\\alpha'} B \\xrightarrow{\\beta'} C \\to 0. $$\nThere is a map $ \\pi : A \\oplus C \\to A $ such that $ \\pi \\circ \\alpha = \\id_A $. Consider a map\n$$ \\function[f]{\\H\\br{B, A \\oplus C}}{B}{\\br{b_1, b_2} + \\im \\alpha^*}{b_1 + \\alpha'\\br{a}}, \\qquad \\beta'\\br{b_1} = \\beta\\br{b_2}, \\qquad b_2 = \\br{a, c} \\in A \\oplus C. $$\nIt is easy to check this gives a map of extensions.\n\n\\pagebreak\n\n\\item Inverses. Suppose\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0. $$\nThen the inverse of $ \\sbr{B} $ is given by the extension\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\xrightarrow{-\\beta} C \\to 0. $$\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Ext and classes of extensions}\n\n\\lecture{26}{Monday}{09/03/20}\n\n\\begin{definition}\nLet\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nbe an extension of $ C $ by $ A $. The \\textbf{class} of this extension is simply defined as $ \\eta\\br{\\id_C} $ in the long exact sequence\n$$ 0 \\to \\Hom_R\\br{C, A} \\to \\Hom_R\\br{C, B} \\to \\Hom_R\\br{C, C} \\xrightarrow{\\eta} \\Ext_R^1\\br{C, A} \\to \\dots. $$\n\\end{definition}\n\n\\begin{proposition}\n\\label{prop:extensionclass}\n\\hfill\n\\begin{itemize}\n\\item Equivalent extensions have the same class.\n\\item The map between equivalence classes of extensions and $ \\Ext_R^1\\br{C, A} $ is a bijection.\n\\item In fact class is an isomorphism $ \\br{\\E_C\\br{A}, +_\\B} \\to \\Ext_R^1\\br{C, A} $.\n\\end{itemize}\n\\end{proposition}\n\n\\begin{lemma}\n\\label{lem:extensionclass}\nSuppose\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & L \\arrow{r} \\arrow{d} & M \\arrow{r} \\arrow{d} & N \\arrow{r} \\arrow{d} & 0 \\\\\n0 \\arrow{r} & X \\arrow{r} & Y \\arrow{r} & Z \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes, where the rows are exact. We get long exact sequences\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & \\Ext_R^0\\br{C, L} \\arrow{r} \\arrow{d} & \\Ext_R^0\\br{C, M} \\arrow{r} \\arrow{d} & \\Ext_R^0\\br{C, N} \\arrow{r} \\arrow{d} & \\Ext_R^1\\br{C, L} \\arrow{r} \\arrow{d} & \\dots \\\\\n0 \\arrow{r} & \\Ext_R^0\\br{C, X} \\arrow{r} & \\Ext_R^0\\br{C, Y} \\arrow{r} & \\Ext_R^0\\br{C, Z} \\arrow{r} & \\Ext_R^1\\br{C, X} \\arrow{r} & \\dots\n\\end{tikzcd},\n$$\nwhere the vertical arrows are given by the functoriality of $ \\Ext_R^1\\br{C, -} $. This diagram commutes.\n\\end{lemma}\n\n\\begin{proof}\nOmitted.\n\\end{proof}\n\n\\begin{proof}[Proof of Proposition \\ref{prop:extensionclass}]\nWe show that class gives a map $ \\E_C\\br{A} \\to \\Ext_R^1\\br{C, A} $, which is bijective.\n\\begin{itemize}\n\\item Every element of $ \\Ext_R^1\\br{C, A} $ is the class of an extension. Take $ x \\in \\Ext_R^1\\br{C, A} $. Let $ I $ be an injective module containing $ A $ as a submodule. Then\n$$ 0 \\to A \\to I \\to I / A \\to 0 $$\nis a short exact sequence, which gives a long exact sequence\n$$ 0 \\to \\Hom_R\\br{C, A} \\to \\Hom_R\\br{C, I} \\to \\Hom_R\\br{C, I / A} \\xrightarrow{\\mu} \\Ext_R^1\\br{C, A} \\to \\Ext_R^1\\br{C, I} \\to \\dots. $$\nThen $ \\Ext_R^1\\br{C, I} = 0 $ since $ I $ is injective. So $ \\mu $ is surjective. Let $ \\phi \\in \\Hom_R\\br{C, I / A} $ be such that $ \\mu\\br{\\phi} = x $, and let\n$$ X_\\phi = \\cbr{\\br{i, c} \\in I \\oplus C \\st i + A = \\phi\\br{c}} $$\nbe the pullback via $ \\phi $, so\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r}{\\iota_A} \\arrow[cong]{d} & X_\\phi \\arrow{r}{\\pi_C} \\arrow{d}{\\pi_I} & C \\arrow{r} \\arrow{d}{\\phi} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r}[swap]{\\le} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd}.\n$$\n\n\\pagebreak\n\nFrom Lemma \\ref{lem:extensionclass}, there is a commuting square\n$$\n\\begin{tikzcd}\n\\Hom_R\\br{C, C} \\arrow{r}{\\eta} \\arrow{d}[swap]{\\overline{\\phi}} & \\Ext_R^1\\br{C, A} \\arrow[cong]{d} \\\\\n\\Hom_R\\br{C, I / A} \\arrow{r}[swap]{\\mu} & \\Ext_R^1\\br{C, A}\n\\end{tikzcd}.\n$$\nFor $ f \\in \\Hom_R\\br{C, C} $, $ \\overline{\\phi}\\br{f} = \\phi \\circ f $. So the class of the extension\n$$ 0 \\to A \\to B \\to C \\to 0 $$\nis $ \\eta\\br{\\id_C} = \\mu\\br{\\phi \\circ \\id_C} = \\mu\\br{\\phi} = x $.\n\\item Extensions giving the same class are equivalent. Suppose that $ \\psi $ is another element of $ \\Hom_R\\br{C, I / A} $ such that $ \\mu\\br{\\psi} = x $. Tracing back through the definition of the connecting homomorphism, in the proof of the snake lemma, it can be shown that $ \\psi = \\phi + q \\circ f $, where $ f : C \\to I $, and $ q $ is the quotient map $ I \\to I / A $. Now it is easy to show that the map given by\n$$ \\function{I \\oplus C}{I \\oplus C}{\\br{i, c}}{\\br{i + f\\br{c}, c}} $$\nis bijective, and it maps $ X_\\phi \\to X_\\psi $. The diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & X_\\phi \\arrow{r} \\arrow{d}{f} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & X_\\psi \\arrow{r} & C \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes, and so the extensions are equivalent. We need to show that every extension arises as $ X_\\phi $ for some $ \\phi $. Suppose\n$$ 0 \\to A \\xrightarrow{\\alpha} B \\to C \\to 0 $$\nis an extension. Let $ A \\le I $ where $ I $ is injective. Then there exists $ \\lambda : B \\to I $ such that $ \\br{\\lambda \\circ \\alpha}\\br{a} = a $ for all $ a \\in A $. We have $ \\lambda' : C \\cong B / \\alpha\\br{A} \\to I / A $. We get short exact sequences\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & B \\arrow{r} \\arrow{d}{\\lambda} & C \\arrow{r} \\arrow{d}{\\lambda'} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nNow we have $ B \\cong X_{\\lambda'} $, since this is the same construction as before.\n\n\\lecture{27}{Tuesday}{10/03/20}\n\n\\item Equivalent extensions have the same class. Suppose\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & B_1 \\arrow{r} \\arrow{d}{f} & C \\arrow{r} \\arrow[cong]{d} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & B_2 \\arrow{r} & C \\arrow{r} & 0\n\\end{tikzcd}\n$$\ncommutes. We get maps\n$$\n\\begin{tikzcd}[row sep=tiny]\n\\Hom_R\\br{C, C} \\arrow{r}{\\mu_1} \\arrow[cong]{d} & \\Ext_R^1\\br{C, A} \\arrow[cong]{d} \\\\\n\\Hom_R\\br{C, C} \\arrow{r}[swap]{\\mu_2} & \\Ext_R^1\\br{C, A}\n\\end{tikzcd}\n$$\ncommuting. So $ \\mu_1 = \\mu_2 $. Hence the extensions $ B_1 $ and $ B_2 $ have the same class.\n\\end{itemize}\n\n\\pagebreak\n\nIt remains to show that it is a group homomorphism. Let\n$$ 0 \\to A \\to B_i \\to C \\to 0, \\qquad i = 1, 2. $$\nSuppose $ B_i = X_{\\phi_i} $ for $ \\phi_i : C \\to I / A $, where $ I $ is an injective containing $ A $. From the arguments earlier, we have\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & B_i \\arrow{r} \\arrow{d}{\\rho_i} & C \\arrow{r} \\arrow{d}{\\phi_i} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nUse the diagram above for $ i = 1, 2 $ to construct a new commuting diagram\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\oplus A \\arrow{r} \\arrow{d}{+} & B_1 \\oplus B_2 \\arrow{r} \\arrow{d}{\\rho_1 + \\rho_2} & C \\oplus C \\arrow{r} \\arrow{d}{\\phi_1 + \\phi_2} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd}.\n$$\nDefine\n$$ A^+ = \\cbr{\\br{a, a} \\st a \\in A} \\le A \\oplus A, \\qquad A^- = \\cbr{\\br{a, -a} \\st a \\in A} \\le A \\oplus A, \\qquad C^+ = \\cbr{\\br{c, c} \\st c \\in C} \\le C \\oplus C. $$\nQuotienting by $ A^- $, $ \\br{A \\oplus A} / A^- \\cong A $, since $ \\br{a_1, a_2} = \\br{a_1 + a_2, 0} - \\br{a_2, -a_2} $. Then\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & \\br{B_1 \\oplus B_2} / A' \\arrow{r} \\arrow{d} & C \\oplus C \\arrow{r} \\arrow{d}{\\phi_1 + \\phi_2} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd},\n$$\nwhere $ A' $ is the image of $ A^- $ in $ B_1 \\oplus B_2 $, so if\n$$ A \\xrightarrow{\\alpha_1} B_1 \\xrightarrow{\\beta_1} C, \\qquad A \\xrightarrow{\\alpha_2} B_2 \\xrightarrow{\\beta_2} C, $$\nthen $ A' = \\cbr{\\br{\\alpha_1\\br{a}, -\\alpha_2\\br{a}}} $. Let $ X \\le \\br{B_1 \\oplus B_2} / A' $ be the preimage of $ C^+ $ in the map $ \\br{B_1 \\oplus B_2} / A' \\to C \\oplus C $. Then\n$$ 0 \\to A \\to X \\to C^+ \\to 0 $$\nis exact, and we have $ C^+ \\cong C $. We get\n$$\n\\begin{tikzcd}\n0 \\arrow{r} & A \\arrow{r} \\arrow[cong]{d} & X \\arrow{r} \\arrow{d} & C \\arrow{r} \\arrow{d}{\\phi_1 + \\phi_2} & 0 \\\\\n0 \\arrow{r} & A \\arrow{r} & I \\arrow{r} & I / A \\arrow{r} & 0\n\\end{tikzcd},\n$$\nidentifying the maps\n$$ \\function[\\phi_1 + \\phi_2]{C \\oplus C}{I / A}{\\br{c, c}}{\\phi_1\\br{c} + \\phi_2\\br{c}}, \\qquad \\function[\\phi_1 + \\phi_2]{C}{I / A}{c}{\\phi_1\\br{c} + \\phi_2\\br{c}}, $$\nso $ X = X_{\\phi_1 + \\phi_2} $. Recall from the definition of the Baer sum,\n$$ 0 \\to A \\xrightarrow{\\br{\\alpha_1, -\\alpha_2}} B_1 \\oplus B_2 \\xrightarrow{\\beta_1 - \\beta_2} C \\to 0, $$\nand $ H = \\ker \\br{\\beta_1 - \\beta_2} / \\im \\br{\\alpha_1, -\\alpha_2} $. But $ \\im \\br{\\alpha_1, -\\alpha_2} $ is precisely the module $ A' $, and $ \\ker \\br{\\beta_1 - \\beta_2} $ is the preimage of $ C^+ $ in $ B_1 \\oplus B_2 $. So $ X = H $, and so $ \\sbr{X_{\\phi_1}} + \\sbr{X_{\\phi_2}} = \\sbr{X_{\\phi_1 + \\phi_2}} $.\n\\end{proof}\n\n\\pagebreak\n\nWe have shown that elements of $ \\Ext_R^1\\br{C, A} $ corresponds to equivalence classes of extensions. Since the identity in $ \\E_C\\br{A} $ is the class of split extensions, it follows that $ 0 \\in \\Ext_R^1\\br{C, A} $ corresponds to split extensions $ C \\oplus A $.\n\n\\begin{example*}\nTake $ R = \\ZZ $. Calculate $ \\Ext_\\ZZ^1\\br{\\ZZ_n, H} $ for $ H $ an abelian group. Use the functor $ F\\br{A} = \\Hom_\\ZZ\\br{A, H} $. This is contravariant, so we need a projective resolution of $ \\ZZ_n $. This is given by\n$$ 0 \\to \\ZZ \\xrightarrow{n} \\ZZ \\to \\ZZ_n \\to 0. $$\nThis gives a long exact sequence\n$$ 0 \\to \\Hom_\\ZZ\\br{\\ZZ_n, H} \\to \\Hom_\\ZZ\\br{\\ZZ, H} \\xrightarrow{n} \\Hom_\\ZZ\\br{\\ZZ, H} \\to \\Ext_\\ZZ^1\\br{\\ZZ_n, H} \\to 0, $$\nsince $ \\Ext_\\ZZ^i\\br{\\ZZ, H} = 0 $ for $ i > 0 $ since $ \\ZZ $ is projective. Now\n$$ \\Hom_\\ZZ\\br{\\ZZ_n, H} \\cong H_n = \\cbr{h \\in H \\st nh = 0}, \\qquad \\Hom_\\ZZ\\br{\\ZZ, H} \\cong H. $$\nSo\n$$ 0 \\to H_n \\to H \\xrightarrow{n} H \\to \\Ext_\\ZZ^1\\br{\\ZZ_n, H} \\to 0, $$\nso $ \\Ext_\\ZZ^1\\br{\\ZZ_n, H} \\cong H / nH $. Take $ n = 4 $ and $ H = \\ZZ_4 $. Then $ \\Ext_R^1\\br{\\ZZ_4, \\ZZ_4} \\cong \\ZZ_4 $. What are the extensions of $ \\ZZ_4 $ by $ \\ZZ_4 $? These are $ \\ZZ_{16} $ twice, $ \\ZZ_8 \\oplus \\ZZ_2 $, and $ \\ZZ_4 \\oplus \\ZZ_4 $.\n\\end{example*}\n\n\\lecture{28}{Friday}{13/03/20}\n\nLecture 28 is a problems class.\n\n\\pagebreak\n\n\\section{Dimension}\n\n\\subsection{Projective, injective, and flat dimensions}\n\n\\lecture{29}{Monday}{16/03/20}\n\n\\begin{definition}\nLet $ M $ be a $ R $-module. The \\textbf{projective dimension} $ \\pd M $ is the smallest $ d $ such that there exists a projective resolution $ P_* \\to M $ such that $ P_{d + 1} = 0 $, or infinity if no such $ d $ exists. The \\textbf{injective dimension} $ \\id M $ is similar for injective resolutions. The \\textbf{flat dimension} is similar for flat resolutions.\n\\end{definition}\n\nEvery projective is flat, so $ \\fd M \\le \\pd M $.\n\n\\begin{example*}\n\\hfill\n\\begin{itemize}\n\\item $ \\ZZ $ as a module for itself. Then $ \\ZZ $ is projective, and flat, so a projective, or flat, resolution is\n$$ 0 \\to \\ZZ \\to \\ZZ \\to 0, $$\nso $ \\fd \\ZZ = \\pd \\ZZ = 0 $. Since $ \\ZZ $ is not injective, an injective resolution is\n$$ 0 \\to \\ZZ \\to \\QQ / \\ZZ \\to \\QQ / \\ZZ \\to 0, $$\nso $ \\id \\ZZ = 1 $.\n\\item $ \\QQ $ as a module for $ \\ZZ $. This is flat but not projective, so $ \\fd \\QQ = 0 $ and $ \\pd \\QQ = 1 $.\n\\end{itemize}\n\\end{example*}\n\n\\begin{proposition}\n\\label{prop:projectivedimension}\nThe following are equivalent.\n\\begin{itemize}\n\\item $ \\pd M \\le d $.\n\\item $ \\Ext_R^{d + 1}\\br{M, N} = 0 $ for all $ N $.\n\\end{itemize}\n\\end{proposition}\n\n\\begin{fact*}\n$ \\Ext_R^{d + 1}\\br{M, N} \\cong \\Ext_R^1\\br{K_{d - 1}, N} $.\n\\end{fact*}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Assume $ \\pd M \\le d $. Then there exists a projective resolution\n$$ 0 \\to P_d \\to \\dots \\to P_0 \\to M \\to 0. $$\nLet $ F $ be the functor $ F\\br{A} = \\Hom_R\\br{A, N} $. Then $ \\Ext_R^*\\br{M, N} $ is calculated from the chain complex\n$$ 0 \\to F\\br{P_d} \\to \\dots \\to F\\br{P_{d - 1}} \\to F\\br{P_0} \\to 0, $$\nso clearly $ \\Ext_R^n\\br{M, N} = \\L_nF\\br{P_*} = 0 $ for $ n > d $.\n\\item[$ \\impliedby $] For the converse, suppose that $ \\Ext_R^{d + 1}\\br{M, N} = 0 $ for all $ N $. Suppose\n$$ P_{d - 1} \\to P_{d - 2} \\to \\dots \\to P_0 \\to M \\to 0 $$\nis exact. Let $ K_{d - 1} $ be the kernel of $ P_{d - 1} \\to P_{d - 2} $, the $ \\br{d - 1} $-dimensional \\textbf{syzygy} of $ M $. So\n$$ 0 \\to K_{d - 1} \\to P_{d - 1} \\to P_{d - 2} \\to \\dots \\to P_0 \\to M \\to 0. $$\nSuppose $ \\Ext_R^{d + 1}\\br{M, N} = 0 $. Then $ \\Ext_R^1\\br{K_{d - 1}, N} = 0 $. So $ K_{d - 1} $ is projective. Hence\n$$ 0 \\to K_{d - 1} \\to P_{d - 1} \\to P_{d - 2} \\to \\dots \\to P_0 \\to M \\to 0 $$\nis a projective resolution. So $ \\pd M \\le d $.\n\\end{itemize}\n\\end{proof}\n\n\\pagebreak\n\n\\begin{proposition}\nThe following are equivalent.\n\\begin{itemize}\n\\item $ \\id N \\le d $.\n\\item $ \\Ext_R^{d + 1}\\br{M, N} = 0 $ for all $ M $.\n\\end{itemize}\n\\end{proposition}\n\n\\begin{proof}\nSimilar to Proposition \\ref{prop:projectivedimension}. Use the \\textbf{cosyzygy}.\n\\end{proof}\n\n\\begin{proposition}\nThe following are equivalent.\n\\begin{itemize}\n\\item $ \\fd M \\le d $.\n\\item $ \\Tor_{d + 1}^R\\br{M, N} = 0 $ for all $ N $.\n\\end{itemize}\n\\end{proposition}\n\n\\begin{fact*}\nAny flat resolution for $ M $ can be used to calculate Tor.\n\\end{fact*}\n\n\\begin{proof}\nUsing the fact, the proof is the same as above.\n\\end{proof}\n\n\\subsection{Global dimension}\n\nWe will be interested in defining dimension for the ring $ R $.\n\n\\begin{proposition}\n$$ \\sup \\cbr{\\pd M \\st M \\ \\text{a left $ R $-module}} = \\sup \\cbr{\\id M \\st M \\ \\text{a left $ R $-module}} = \\sup \\cbr{d \\st \\exists M, N, \\ \\Ext_R^d\\br{M, N} \\ne 0}, $$\nwhere the supremums are in $ \\NN \\cup \\cbr{\\infty} $.\n\\end{proposition}\n\nThis number is the \\textbf{left global dimension} $ \\lgd R $ of $ R $. The \\textbf{right global dimension} $ \\rgd R $ is defined similarly, but using right modules. There exist rings $ R $ such that $ \\lgd R \\ne \\rgd R $.\n\n\\begin{definition}\nSay that $ R $ satisfies the \\textbf{ascending chain condition on right ideals} if whenever $ I_0 \\le I_1 \\le \\dots $ is a chain of right ideals, there exists $ d $ such that $ I_d = I_{d + 1} = \\dots $. The condition that $ R $ satisfies the \\textbf{ascending chain condition on left ideals} is similar. If $ R $ satisfies the ascending chain condition on both left and right ideals, it is \\textbf{noetherian}.\n\\end{definition}\n\n\\begin{fact*}\nFor any noetherian ring $ R $, $ \\lgd R = \\rgd R $.\n\\end{fact*}\n\nSo in this context we can refer to \\textbf{global dimension}, $ \\gd R $.\n\n\\begin{proposition}\n$$ \\sup \\cbr{\\fd N \\st N \\ \\text{a left $ R $-module}} = \\sup \\cbr{\\fd M \\st M \\ \\text{a right $ R $-module}} = \\sup \\cbr{d \\st \\exists M, N, \\ \\Tor_d^R\\br{M, N} \\ne 0}. $$\n\\end{proposition}\n\nThis number is the \\textbf{weak global dimension} $ \\wgd R $. Since $ \\fd M \\le \\pd M $, $ \\wgd R \\le \\gd R $.\n\n\\subsection{Krull dimension}\n\n\\lecture{30}{Tuesday}{17/03/20}\n\nThe following is another ring dimension. Let $ R $ be a commutative ring. Then $ I \\le R $ is \\textbf{prime} if $ I \\ne R $, and $ ab \\in I $ implies that $ a \\in I $ or $ b \\in I $. In particular, any maximal ideal of $ R $ is prime.\n\n\\begin{definition}\nThe \\textbf{Krull dimension}, $ \\dim R $, is the length of the longest chain of prime ideals of $ R $.\n\\end{definition}\n\n\\begin{example*}\nLet $ V $ be an \\textbf{affine variety} in $ F^n $, so $ V $ is defined by the zeros of a set of polynomials in $ F\\sbr{x_1, \\dots, x_n} $. Then $ V $ corresponds to an ideal $ I_V $ in $ F\\sbr{x_1, \\dots, x_n} $, and $ V $ is \\textbf{irreducible} if $ I_V $ is prime. Then\n$$ \\dim F\\sbr{x_1, \\dots, x_n} / I_V = \\dim V. $$\n\\end{example*}\n\n\\begin{fact*}\n$ \\dim R \\le \\gd R $.\n\\end{fact*}\n\n\\pagebreak\n\n\\begin{definition}\nA ring is \\textbf{local} if it has a unique maximal ideal, so the non-units of $ R $ form an ideal. Let $ I \\le R $ be a prime ideal. The \\textbf{localisation} of $ R $ at $ I $ is the ring\n$$ \\cbr{\\dfrac{r}{q} \\st r \\in R, \\ q \\in R \\setminus I}. $$\n\\end{definition}\n\nThe unique maximal ideal is\n$$ \\cbr{\\dfrac{i}{q} \\st i \\in I, \\ q \\in R \\setminus I}, $$\nso this ring is local. This is a basic tool in algebraic geometry.\n\n\\begin{theorem}[Serre]\nLet $ R $ be a noetherian local ring such that $ \\dim R $ is finite. Then\n$$ \\dim R = \\gd R. $$\n\\end{theorem}\n\n\\begin{example*}\n$ R = F\\sbr{x_1, \\dots, x_n} $ corresponds to the zero variety. This is not local, but $ \\dim R = \\gd R = n $. The fact that $ \\gd R = n $ is \\textbf{Hilbert's syzygy theorem}.\n\\begin{itemize}\n\\item Let $ n = 3 $. Note that $ F $ is a module for $ R $, by the multiplication $ x_i\\lambda = 0 $ for all $ x_i $ and $ \\lambda \\in F $. Let us calculate a projective resolution, keeping track of the syzygies. If\n$$ 0 \\to K_1 \\to R \\to F \\to 0, $$\nthen\n\\begin{align*}\nK_1\n& = \\ker \\br{\\functions{R}{F}{x_i}{0}{1}{1}} \\\\\n& = \\abr{x_1, x_2, x_3}\n\\le R.\n\\end{align*}\nIf\n$$ 0 \\to K_2 \\to R^3 \\to K_1 \\to 0, $$\nthen\n\\begin{align*}\nK_2\n& = \\ker \\br{\\function{R^3}{K_1}{\\br{r_1, r_2, r_3}}{r_1x_1 + r_2x_2 + r_3x_3}} \\\\\n& = \\cbr{\\br{r_1, r_2, r_3} \\st r_1x_1 + r_2x_2 + r_3x_3 = 0} \\\\\n& = \\abr{\\br{0, x_3, -x_2}, \\br{-x_3, 0, x_1}, \\br{x_2, -x_1, 0}}\n\\le R^3.\n\\end{align*}\nIf\n$$ 0 \\to K_3 \\to R^3 \\to K_2 \\to 0, $$\nthen\n\\begin{align*}\nK_3\n& = \\ker \\br{\\function{R^3}{K_2}{\\br{r_1, r_2, r_3}}{\\br{r_3x_2 - r_2x_3, r_1x_3 - r_3x_1, r_2x_1 - r_1x_2}}} \\\\\n& = \\abr{\\br{x_1, x_2, x_3}}\n\\cong R.\n\\end{align*}\nOur projective resolution is\n$$ 0 \\to R \\to R^3 \\to R^3 \\to R \\to F \\to 0. $$\n\\item Generally for arbitrary $ n $, this construction gives\n$$ P_j = R^{\\binom{n}{j}}. $$\nGenerators of $ K_j \\le P_{j - 1} $ correspond to subsets of size $ j $ of $ \\cbr{1, \\dots, n} $. The generator corresponding to a subset $ S $ of size $ j $ will have a coordinate for each subset $ T $ of size $ j - 1 $. This coordinate is zero if $ T \\not\\subseteq S $ and $ \\pm x_i $ if $ S = T \\cup \\cbr{i} $.\n\\end{itemize}\nThis is an example of a \\textbf{Koszul complex}, and is a technique used for calculating syzygies explicitly in certain situations.\n\\end{example*}\n\n\\end{document}", "meta": {"hexsha": "e99c5de39dc753c78643cdaee6c02f3de05a0430", "size": 140133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "M4P63 Algebra IV/M4P63.tex", "max_stars_repo_name": "icl-notes/GANT", "max_stars_repo_head_hexsha": "0228d21307fbaa7971f4446d89a160d7dfc174a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2019-04-19T17:03:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-18T06:57:07.000Z", "max_issues_repo_path": "M4P63 Algebra IV/M4P63.tex", "max_issues_repo_name": "Multramate/IC-GANT", "max_issues_repo_head_hexsha": "ea1e3a1d97a2761bc1d0b60eea0c2cec91e17917", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-09-06T15:04:32.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-06T16:14:54.000Z", "max_forks_repo_path": "M4P63 Algebra IV/M4P63.tex", "max_forks_repo_name": "Multramate/IC-GANT", "max_forks_repo_head_hexsha": "ea1e3a1d97a2761bc1d0b60eea0c2cec91e17917", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-04-28T02:00:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-06T13:09:15.000Z", "avg_line_length": 57.9061983471, "max_line_length": 830, "alphanum_fraction": 0.6092997367, "num_tokens": 57517, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4315042468240134}}
{"text": "% Copyright 2019 by Till Tantau\n%\n% This file may be distributed and/or modified\n%\n% 1. under the LaTeX Project Public License and/or\n% 2. under the GNU Free Documentation License.\n%\n% See the file doc/generic/pgf/licenses/LICENSE for more details.\n\n\n\\section{Polar Axes}\n\\label{section-dv-polar}\n\n\\subsection{Overview}\n\n\\begin{tikzlibrary}{datavisualization.polar}\n    This library contains keys that allow you to create plots in a polar axis\n    system is used.\n\\end{tikzlibrary}\n\nIn a \\emph{polar axis system} two attributes are visualized by displacing a\ndata point as follows: One attribute is used to compute a an angle (a\ndirection) while a second attribute is used as a radius (a distance). The angle\ncan be measured in degrees, radians, or can be scaled arbitrarily.\n%\n\\begin{codeexample}[\n    width=8.5cm,\n    preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}},\n]\n\\tikz \\datavisualization [\n  scientific polar axes={0 to pi, clean},\n  all axes=grid,\n  style sheet=vary hue,\n  legend=below\n  ]\n  [visualize as smooth line=sin,\n   sin={label in legend={text=$1+\\sin \\alpha$}}]\n  data [format=function] {\n    var  angle : interval [0:pi];\n    func radius = sin(\\value{angle}r) + 1;\n  }\n  [visualize as smooth line=cos,\n   cos={label in legend={text=$1+\\cos\\alpha$}}]\n  data [format=function] {\n    var  angle : interval [0:pi];\n    func radius = cos(\\value{angle}r) + 1;\n  };\n\\end{codeexample}\n\nMost of the time, in order to create a polar axis system, you will just use the\n|scientific polar axes| key, which takes a number of options that allow you to\nconfigure the axis system in greater detail. This key is documented in\nSection~\\ref{section-dv-sci-polar-axes}. Internally, this key uses more low\nlevel keys which are documented in the en suite sections.\n\nIt is worthwhile to note that the axes of a polar axis system are, still,\nnormal axes of the data visualization system. In particular, all the\nconfigurations possible for, say, Cartesian axes also apply to the ``angle\naxis'' and the ``radius axis'' of a polar axis system. For instance, you can\ncould make both axes logarithmic or style their ticks:\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}}]\n\\tikz[baseline] \\datavisualization [\n  scientific axes={clean},\n  x axis={attribute=angle, ticks={minor steps between steps=4}},\n  y axis={attribute=radius, ticks={some, style=red!80!black}},\n  all axes=grid,\n  visualize as smooth line=sin]\n  data [format=function] {\n    var t : interval [-3:3];\n    func angle = exp(\\value t);\n    func radius = \\value{t}*\\value{t};\n  };\n\\qquad\n\\tikz[baseline] \\datavisualization [\n  scientific polar axes={right half clockwise, clean},\n  angle axis={logarithmic,\n    ticks={\n      minor steps between steps=8,\n      major also at/.list={2,3,4,5,15,20}}},\n  radius axis={ticks={some, style=red!80!black}},\n  all axes=grid,\n  visualize as smooth line=sin]\n  data [format=function] {\n    var t : interval [-3:3];\n    func angle = exp(\\value t);\n    func radius = \\value{t}*\\value{t};\n  };\n\\end{codeexample}\n\n\n\\subsection{Scientific Polar Axis System}\n\\label{section-dv-sci-polar-axes}\n\n\\begin{key}{/tikz/data visualization/scientific polar axes=\\meta{options}}\n    This key installs a polar axis system that can be used in a ``scientific''\n    publication. Two axes are created called the |angle axis| and the\n    |radius axis|. Unlike ``normal'' Cartesian axes, these axes do not point in\n    a specific direction. Rather, the |radius axis| is used to map the values\n    of one attribute to a distance from the origin while the |angle axis| is\n    used to map the values of another attribute to a rotation angle.\n\n    The \\meta{options} will be executed with the path prefix\n    %\n\\begin{codeexample}[code only]\n/tikz/data visualization/scientific polar axes\n\\end{codeexample}\n    %\n    The permissible keys are documented in the later subsections of this\n    section.\n\n    Let us start with the configuration of the radius axis since it is easier.\n    Firstly, you should specify which attribute is linked to the radius. The\n    default is |radius|, but you will typically wish to change this. As with\n    any other axis, the |attribute| key is used to configure the axis, see\n    Section~\\ref{section-dv-axis-attribute} for details. You can also apply all\n    other configurations to the radius axis like, say, |unit length| or\n    |length| or |style|. Note, however, that the |logarithmic| key will not\n    work with the radius axis for a |scientific polar axes| system since the\n    attribute value zero is always placed at the center -- and for a\n    logarithmic plot the value |0| cannot be mapped.\n    %\n\\begin{codeexample}[\n    width=8.8cm,\n    preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}},\n]\n\\tikz \\datavisualization [\n  scientific polar axes,\n  radius axis={\n    attribute=distance,\n    ticks={step=5000},\n    padding=1.5em,\n    length=3cm,\n    grid\n  },\n  visualize as smooth line]\ndata [format=function] {\n  var  angle : interval [0:100];\n  func distance = \\value{angle}*\\value{angle};\n};\n\\end{codeexample}\n\n    For the |angle axis|, you can also specify an attribute using the\n    |attribute| key. However, for this axis the mapping of a value to an actual\n    angle is a complicated process involving many considerations of how the\n    polar axis system should be visualized. For this reason, there are a large\n    number of predefined such mappings documented in\n    Section~\\ref{section-dv-angle-ranges}. Finally, as for a |scientific plot|,\n    you can configure where the ticks should be shown using the keys\n    |inner ticks|, |outer ticks|, and |clean|, documented below.\n\\end{key}\n\n\n\\subsubsection{Tick Placements}\n\n\\begin{key}{/tikz/data visualization/scientific polar axes/outer ticks}\n    This key, which is the default, causes ticks to be drawn ``outside'' the\n    outer ``ring'' of the polar axes:\n    %\n\\begin{codeexample}[\n    width=8.8cm,\n    preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}},\n]\n\\tikz \\datavisualization [\n  scientific polar axes={outer ticks, 0 to 180},\n  visualize as smooth line]\ndata [format=function] {\n  var  angle : interval [0:100];\n  func radius = \\value{angle};\n};\n\\end{codeexample}\n    %\n\\end{key}\n\n\\begin{key}{/tikz/data visualization/scientific polar axes/inner ticks}\n    This key causes the ticks to be ``turned to the inside''. I do not\n    recommend using this key.\n    %\n\\begin{codeexample}[\n    width=8.8cm,\n    preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}},\n]\n\\tikz \\datavisualization [\n  scientific polar axes={inner ticks, 0 to 180},\n  visualize as smooth line]\ndata [format=function] {\n  var  angle : interval [0:100];\n  func radius = \\value{angle};\n};\n\\end{codeexample}\n    %\n\\end{key}\n\n\\begin{key}{/tikz/data visualization/scientific polar axes/clean}\n    This key separates the area where the data is shown from the area where the\n    ticks are shown. Usually, this is the best choice for the tick placement\n    since it avoids a collision of data and explanations.\n    %\n\\begin{codeexample}[\n    width=8.8cm,\n    preamble={\\usetikzlibrary{\n    datavisualization.formats.functions,\n    datavisualization.polar,\n}},\n]\n\\tikz \\datavisualization [\n  scientific polar axes={clean, 0 to 180},\n  visualize as smooth line]\ndata [format=function] {\n  var  angle : interval [0:100];\n  func radius = \\value{angle};\n};\n\\end{codeexample}\n    %\n\\end{key}\n\n\n\\subsubsection{Angle Ranges}\n\\label{section-dv-angle-ranges}\n\nSuppose you create a polar plot in which the radius values vary between, say,\n$567$ and $1234$. Then the normal axis scaling mechanisms can be used to\ncompute a good scaling for the ``radius axis'': Place the value $1234$ at a\ndistance of , say, $5\\,\\mathrm{cm}$ from the origin and place the value $0$ at\nthe origin. Now, by comparison, suppose that the values of the angle axis's\nattribute ranged between, say, $10$ and $75.7$. In this case, we may wish the\nangles to be scaled so that the minimum value is horizontal and the maximum\nvalue is vertical. But we may also wish the a value of $0$ is horizontal and a\nvalue of $90$ is vertical.\n\nSince it is unclear which interpretation is the right one, you have to use an\noption to select which should happen. The applicable options fall into three\ncategories:\n%\n\\begin{itemize}\n    \\item Options that request the scaling to be done in such a way that the\n        attribute is interpreted as a value in degrees and such that the\n        minimum and maximum of the depicted range is a multiple of $90^\\circ$.\n        For instance, the option |0 to 180| causes the angle axis to range from\n        $0^\\circ$ to $180^\\circ$, independently of the actual range of the\n        values.\n    \\item Options that work as above, but use radians rather than degrees. An\n        example is the option |0 to pi|.\n    \\item Options that map the minimum value in the data to a horizontal or\n        vertical line and the maximum value to another such line. This is\n        useful when the values neither directly correspond to degrees or\n        radians. In this case, the angle axis may also be a logarithmic axis.\n\\end{itemize}\n\nIn addition to the above categories, all of the option documented in the\nfollowing implicitly also select quadrants that are used to depict the data.\nFor instance, the |0 to 90| key and also the |0 to pi half| key setup the polar\naxis system in such a way that only first (upper right) quadrant is used. No\ncheck is done whether the data fill actually lie in this quadrant -- if it does\nnot, the data will ``bleed outside'' the range. Naturally, with a key like\n|0 to 360| or |0 to 2pi| this cannot happen.\n\nIn order to save some space in this manual, in the following the different\npossible keys are only given in a table together with a small example for each\nkey. The examples were created using the following code:\n%\n\\begin{codeexample}[preamble={\\usetikzlibrary{datavisualization.polar}}]\n\\tikz \\datavisualization [\n  scientific polar axes={\n    clean,\n    0 to 90  % the option\n  },\n  angle axis={ticks={step=30}},\n  radius axis={length=1cm, ticks={step=1}},\n  visualize as scatter]\ndata point [angle=20, radius=0.5]\ndata point [angle=30, radius=1]\ndata point [angle=40, radius=1.5];\n\\end{codeexample}\n\nFor the options on radians, the angle values have been replaced by |0.2|,\n|0.3|, and |0.4| and the stepping has been changed by setting |step=(pi/6)|.\nFor the quadrant options, no stepping is set at all (it is computed\nautomatically).\n\n\\def\\polarexample#1#2#3#4#5{%\n  \\texttt{#1}%\n  \\indexkey{/tikz/data visualization/scientific polar axes/#1}&\n  \\tikz [baseline]{\\path(-2.25cm,0)(2.25cm,0); \\datavisualization [\n    scientific polar axes={clean, #1},\n    angle axis={ticks={#2}},\n    radius axis={length=1cm, ticks={step=1}},\n    visualize as scatter\n    ]\n    data point [angle=#3, radius=0.5]\n    data point [angle=#4, radius=1]\n    data point [angle=#5, radius=1.5];\n    \\path ([yshift=-1em]current bounding box.south);\n  }&\n  \\tikz [baseline]{\\path(-2.25cm,0)(2.25cm,0); \\datavisualization [\n    scientific polar axes={outer ticks, #1},\n    angle axis={ticks={#2}},\n    radius axis={length=1cm, ticks={step=1}},\n    visualize as scatter\n    ]\n    data point [angle=#3, radius=0.5]\n    data point [angle=#4, radius=1]\n    data point [angle=#5, radius=1.5];\n    \\path ([yshift=-1em]current bounding box.south);\n  }\n  \\\\\n}\n\n\\begin{tabular}{lcc}\n    \\emph{Option} & \\emph{With clean ticks} & \\emph{With outer ticks} \\\\\n    \\polarexample{0 to 90}{step=30}{20}{30}{40}\n    \\polarexample{-90 to 0}{step=30}{20}{30}{40}\n    \\polarexample{0 to 180}{step=30}{20}{30}{40}\n    \\polarexample{-90 to 90}{step=30}{20}{30}{40}\n    \\polarexample{0 to 360}{step=30}{20}{30}{40}\n    \\polarexample{-180 to 180}{step=30}{20}{30}{40}\n\\end{tabular}\n\n\\begin{tabular}{lcc}\n    \\emph{Option} & \\emph{With clean ticks} & \\emph{With outer ticks} \\\\\n    \\polarexample{0 to pi half}{step=(pi/6)}{0.2}{0.3}{0.4}\n    \\polarexample{-pi half to 0}{step=(pi/6)}{0.2}{0.3}{0.4}\n    \\polarexample{0 to pi}{step=(pi/6)}{0.2}{0.3}{0.4}\n    \\polarexample{-pi half to pi half}{step=(pi/6)}{0.2}{0.3}{0.4}\n    \\polarexample{0 to 2pi}{step=(pi/6)}{0.2}{0.3}{0.4}\n    \\polarexample{-pi to pi}{step=(pi/6)}{0.2}{0.3}{0.4}\n\\end{tabular}\n\n\\begin{tabular}{lcc}\n    \\emph{Option} & \\emph{With clean ticks} & \\emph{With outer ticks} \\\\\n    \\polarexample{quadrant}{}{20}{30}{40}\n    \\polarexample{quadrant clockwise}{}{20}{30}{40}\n    \\polarexample{fourth quadrant}{}{20}{30}{40}\n    \\polarexample{fourth quadrant clockwise}{}{20}{30}{40}\n    \\polarexample{upper half}{}{20}{30}{40}\n    \\polarexample{upper half clockwise}{}{20}{30}{40}\n    \\polarexample{lower half}{}{20}{30}{40}\n    \\polarexample{lower half clockwise}{}{20}{30}{40}\n\\end{tabular}\n\n\\begin{tabular}{lcc}\n    \\emph{Option} & \\emph{With clean ticks} & \\emph{With outer ticks} \\\\\n    \\polarexample{left half}{}{20}{30}{40}\n    \\polarexample{left half clockwise}{}{20}{30}{40}\n    \\polarexample{right half}{}{20}{30}{40}\n    \\polarexample{right half clockwise}{}{20}{30}{40}\n\\end{tabular}\n\n\n\\subsection{Advanced: Creating a New Polar Axis System}\n\n\\begin{key}{/tikz/data visualization/new polar axes=|\\char`\\{|\\meta{angle axis name}|\\char`\\}||\\char`\\{|\\meta{radius axis name}|\\char`\\}|}\n    This key actually creates two axes, whose names are give as parameters: An\n    \\emph{angle axis} and a \\emph{radius axis}. These two axes work in concert\n    in the following way: Suppose a data point has two attributes called\n    |angle| and |radius| (these attribute names can be changed by changing the\n    |attribute| of the \\meta{angle axis name} or the \\meta{radius axis name},\n    respectively). These two attributes are then scaled as usual, resulting in\n    two ``reasonable'' values $a$ (for the angle) and $r$ (for the radius).\n    Then, the data point gets visualized (in principle, details will follow) at\n    a position on the page that is at a distance of $r$ from the origin and at\n    an angle of~$a$.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{datavisualization.polar}}]\n\\tikz \\datavisualization\n    [new polar axes={angle axis}{radius axis},\n     radius axis={length=2cm},\n     visualize as scatter]\n  data [format=named] {\n    angle={0,20,...,160}, radius={0,...,5}\n  };\n\\end{codeexample}\n    %\n    In detail, the \\meta{angle axis} keeps track of two vectors $v_0$ and\n    $v_{90}$, each of which will usually have unit length (length |1pt|) and\n    which point in two different directions. Given a radius $r$ (measured in\n    \\TeX\\ |pt|s, so if the radius attribute |10pt|, then $r$ would be $10$) and\n    an angle $a$, let $s$ be the sine of $a$ and let $c$ be the cosine of $a$,\n    where $a$ is a number is degrees (so $s$ would be $1$ for $a = 90$). Then,\n    the current page position is shifted by $c \\cdot r$ times $v_0$ and,\n    additionally, by $s \\cdot r$ times $v_{90}$. This means that in the ``polar\n    coordinate system'' $v_0$ is the unit vector along the ``$0^\\circ$-axis''\n    and $v_{90}$ is the unit vector along ``$90^\\circ$-axis''. The values of\n    $v_0$ and $v_{90}$ can be changed using the following key on the\n    \\meta{angle axis}:\n    %\n    \\begin{key}{/tikz/data visualization/axis options/unit vectors=%\n            |\\char`\\{|\\meta{unit vector 0 degrees}|\\char`\\}\\char`\\{|\\meta{unit vector 90 degrees}|\\char`\\}|\n            (initially {\\char`\\{(1pt,0pt)\\char`\\}\\char`\\{(0pt,1pt)\\char`\\}})%\n    }\n    Both the \\meta{unit vector 0 degrees} and the \\meta{unit vector 90 degrees}\n    are \\tikzname\\ coordinates:\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{datavisualization.polar}}]\n\\tikz \\datavisualization\n    [new polar axes={angle axis}{radius axis},\n     radius axis={unit length=1cm},\n     angle axis={unit vectors={(10:1pt)}{(60:1pt)}},\n     visualize as scatter]\n  data [format=named] {\n    angle={0,90}, radius={0.25,0.5,...,2}\n  };\n\\end{codeexample}\n    \\end{key}\n\\end{key}\n\nOnce created, the |angle axis| can be scaled conveniently using the following\nkeys:\n\n\\begin{key}{/tikz/data visualization/axis options/degrees}\n    When this key is passed to the angle axis of a polar axis system, it sets\n    up the scaling so that a value of |360| on this axis corresponds to a\n    complete circle.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{datavisualization.polar}}]\n\\tikz \\datavisualization\n    [new polar axes={angle axis}{radius axis},\n     radius axis={unit length=1cm},\n     angle axis={degrees},\n     visualize as scatter]\n  data [format=named] {\n    angle={10,90}, radius={0.25,0.5,...,2}\n  };\n\\end{codeexample}\n    %\n\\end{key}\n\n\\begin{key}{/tikz/data visualization/axis options/radians}\n    In contrast to |degrees|, this option sets up things so that a value of\n    |2*pi| on this axis corresponds to a complete circle.\n    %\n\\begin{codeexample}[preamble={\\usetikzlibrary{datavisualization.polar}}]\n\\tikz \\datavisualization\n    [new polar axes={angle axis}{radius axis},\n     radius axis={unit length=1cm},\n     angle axis={radians},\n     visualize as scatter]\n  data [format=named] {\n    angle={0,1.5}, radius={0.25,0.5,...,2}\n  };\n\\end{codeexample}\n    %\n\\end{key}\n", "meta": {"hexsha": "bbba69dee468f53449c470e28223626970240540", "size": 17294, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex", "max_stars_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_stars_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex", "max_issues_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_issues_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Texlive_Windows_x32/2020/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex", "max_forks_repo_name": "waqas4afzal/LatexUrduBooksTools", "max_forks_repo_head_hexsha": "52fe6e0cd5af6b4610fd344a7392cca11bc5a72e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6775599129, "max_line_length": 138, "alphanum_fraction": 0.6938822713, "num_tokens": 5055, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324418, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.43150423682889083}}
{"text": "Build-up objects allows modeling accumulation of contaminants on the surfaces throughout the simulation period. In order to assign build-up to an block object, the user first should introduce a build-up object by right-clicking \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Build-ups} and then clicking on \\textbf{Add Build-up}. Build-up can be applied to both constituents and particles. Two pre-defined build-up models have been provided in the model including \\textbf{Linear} and \\textbf{Exponential} models: \n\n\\begin{itemize}\n\\item \\textbf{Linear build-up model: } In the linear model it is assumed that the build-up occurs at a constant rate. So the accumulation term in the mass-balance equation will be:\n\\begin{equation}\n\\label{eq:34}\n\\dot{m} = k_{bld} A_s \n\\end{equation}\n\n\\item \\textbf{Exponential build-up model: } This model is based on the widely accepted assumption based on several observations that the built-up mass on surfaces reaches a plateau after a certain times due to the resuspension of the accumulated pollutants as a result of wind or traffic \\citep{alley1981}. The form of the equation is as follows: \n\\begin{equation}\n\\label{eq:35}\n\\dot{m} = k_{bld} A_s (1-\\frac{C}{C_{bsat}})\n\\end{equation}\nin this equation $C$ is surface concentration of the accumulating contaminant typically considered as sorbed to the surface of a catchment segment and $C_{bsat}$ is the saturation accumulation concentration. \n\\end{itemize}\n\\subsubsection{Properties of a build-up object: }\nIn this subsection the properties of build-up objects are described: \n\\begin{itemize}\n    \n\\item \\textbf{Name: } This indicates the name of a build-up object. The name is used when assigning build-up to blocks. \n\\item \\textbf{Accumulation Rate: } The build-up rate constant $k_{bld}$ is entered here. \n\\item \\textbf{Constituent: } This indicate which constituent to be accumulated based on the build-up mode. Multiple build-up objects can be assigned to a single block. \n\\item \\textbf{Model: } Using this property, the user can specify what model to be used to model build-up. \n\\item \\textbf{Saturation: } The saturation concentration $C_{bsat}$ in Eq. \\ref{eq:35}.\n\\item \\textbf{Sorbed/Attached: } Indicates whether the build-up should be considered as sorbed to the solid phase. The recommendation is to set this property to \\textit{Yes} since build-up typically occur during dry periods when there is no aqueous phase available. \n\\end{itemize}\n\\input{build-up-ex.tex}", "meta": {"hexsha": "22c067885cf9290eb1ad3bd96ae2d646c55fa0aa", "size": 2498, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GIFMod User's Manual/Build-up.tex", "max_stars_repo_name": "ArashMassoudieh/GIFMod_", "max_stars_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-11-20T19:32:27.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-28T06:08:45.000Z", "max_issues_repo_path": "GIFMod User's Manual/Build-up.tex", "max_issues_repo_name": "ArashMassoudieh/GIFMod_", "max_issues_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-07-04T05:40:30.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-04T05:43:37.000Z", "max_forks_repo_path": "GIFMod User's Manual/Build-up.tex", "max_forks_repo_name": "ArashMassoudieh/GIFMod_", "max_forks_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-11-09T22:00:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-30T10:56:08.000Z", "avg_line_length": 89.2142857143, "max_line_length": 547, "alphanum_fraction": 0.7778222578, "num_tokens": 625, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.43150423547335104}}
{"text": "\\documentclass{beamer}\n\\usetheme{Boadilla}\n\\setbeamertemplate{navigation symbols}{}\n\\usepackage[latin1]{inputenc}\n\\usepackage{amsmath, amsfonts, amssymb}\n\n\\usepackage{commath} % defines \\norm{}\n\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\n\\newtheorem{prop}{Proposition}\n\n\\begin{document}\n\\begin{frame}{Notation}\n  \\begin{itemize}\n  \\item $G = (V,E)$ undirected graph\n  \\item set $T \\subset V$ of terminals \n  \\item set $N = V \\setminus T$ of non-terminals\n  \\item $E(S) = \\{\\{i,j\\} \\in E: i,j \\in S\\}$ for some $S \\subseteq V$\n  \\end{itemize}\n\\end{frame}\n\n\\section{Separation routines}\n\\begin{frame}{Considered constraint}\n  \\begin{itemize}\n  \\item $\\sum\\limits_{e \\in E(S)} x_e \\leq \\sum\\limits_{v \\in S\n    \\setminus \\{k\\}} y_v$ for $k \\in S \\subseteq N$\n  \\item let $k \\in N$ be fixed and let $(x^*,y^*)$ be non-negative\n  \\item consider $\\min\\limits_{S \\subseteq N, k \\in S} f(S)$ where\n    $f(S) = \\sum\\limits_{v \\in S \\setminus \\{k\\}} y^*_v -\n    \\sum\\limits_{e \\in E(S)} x^*_e$ for $S \\subseteq N$\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{equation*}\n    f(S) = \\sum\\limits_{v \\in S \\setminus \\{k\\}} y^*_v -\n    \\sum\\limits_{e \\in E(S)} x^*_e = \\sum\\limits_{j \\in S} d_j -\n    \\sum\\limits_{i,j \\in S} q_{ij}\n  \\end{equation*}\n  with\n  \\begin{itemize}\n    \\item $d_j = y^*_j$ for $j \\in S \\setminus \\{k\\}$; 0 otherwise\n    \\item $q_{ij} = q_{ji} = \\frac{1}{2} x^*_e$ where $e = \\{i,j\\}$\n      for $i,j \\in S$; 0 otherwise\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Compute min s-t cut}\n  \\begin{itemize}\n  \\item consider digraph $D = (V_1 \\cup V_2 \\cup \\{s,t\\}, A)$ where\n  \\item $V_1 = \\{\\{i,j\\} \\in N: x^*_{\\{i,j\\}} > 0\\}$\n  \\item $V_2 = \\{j \\in N: y^*_j > 0\\}$\n  \\item $A = A_1 \\cup A_2 \\cup A_3$ where\n    \\begin{itemize}\n      \\item $A_1 = \\{(u,v) : u \\in V_1, v \\in V_2, u \\cap v \\neq\n        \\emptyset\\}$\n      \\item $A_2 = \\{(s,u) : u \\in V_1\\}$\n      \\item $A_3 = \\{(v,t) : v \\in V_2\\}$\n    \\end{itemize}\n  \\item with capacities $c_a$ for $a \\in A$:\n    \\begin{itemize}\n    \\item $c_a = \\infty$ for $a \\in A_1$\n    \\item $c_{\\{s,u\\}} = y^*_u$ for $\\{s,u\\} \\in A_2$\n    \\item $c_{\\{v,t\\}} = x^*_v$ for $\\{v,t\\} \\in A_3$\n    \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "e22c7c999a6f774169299c37fbb355c725ca0c45", "size": 2219, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/separation.tex", "max_stars_repo_name": "asbestian/connected_subgraph", "max_stars_repo_head_hexsha": "adeb6a6265585fd2893f9c12f14c657f8df4af19", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/separation.tex", "max_issues_repo_name": "asbestian/connected_subgraph", "max_issues_repo_head_hexsha": "adeb6a6265585fd2893f9c12f14c657f8df4af19", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/separation.tex", "max_forks_repo_name": "asbestian/connected_subgraph", "max_forks_repo_head_hexsha": "adeb6a6265585fd2893f9c12f14c657f8df4af19", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8194444444, "max_line_length": 70, "alphanum_fraction": 0.5763857594, "num_tokens": 957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.431504235473351}}
{"text": "\\documentclass[thesis.tex]{subfiles}\n\n\\begin{document}\n\\emph{Ab initio} structure calculations of many-fermion systems such as those in nuclear and electronic structure aim to describe emergent phenomena from the constituent particles subject to the underlying microscopic Hamiltonian.  This amounts to finding the solution to the many-body Schr\\\"{o}dinger equation.  However, a calculation of the exact solution needs to account for all possible correlations among the particles and thus scales factorially.  This motivates the need for approximations to the exact solution that account for the most important correlations.  This chapter first establishes the formalism necessary to define the many-body problem then illustrates several successive approximations to its solution.  Because the type of fermions and the underlying Hamiltonian can be kept generic until specific systems are considered, the formalism and many-body methods can be kept generic as well.\n\n\n\\section{Independent-Particle Model}\nThe nonrelativistic $A$-body quantum problem begins with the Schr\\\"{o}dinger equation,\n\\begin{equation} \\label{eq:schrodinger}\n  \\Ham\\Psi_{\\nu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right) = E_{\\nu}\\Psi_{\\nu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right),\n\\end{equation}\nfor the correlated wave function $\\Psi_{\\nu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right)$ and the corresponding energy $E_{\\nu}$.  The Hamiltonian can be written generically as a sum of $k$-body pieces which, in principle, can contain up to $A$-body interactions,\n\\begin{align} \\label{eq:hamiltonian}\n  \\Ham &= \\HamB{1} + \\HamB{2} + \\HamB{3} + \\cdots \\notag \\\\\n  &= \\sum^{A}_{\\mathclap{i}}\\HamB{1}\\left(\\mathbf{r}_{i}\\right) + \\sum^{A}_{\\mathclap{i<j}}\\HamB{2}\\left(\\mathbf{r}_{i},\\mathbf{r}_{j}\\right) + \\sum^{A}_{\\mathclap{i<j<k}}\\HamB{3}\\left(\\mathbf{r}_{i},\\mathbf{r}_{j},\\mathbf{r}_{k}\\right) + \\cdots.\n\\end{align}\nThe one-body term can contain the kinetic energy operator, $\\frac{-\\hbar^{2}}{2m}\\nabla^{2}_{i}$, as well as any external potential while the higher-order terms contain inter-particle interactions.\n\nAn intuitive way to formulate the solution to the many-body Schr\\\"{o}dinger equation is to express the collective wave function in terms of independent single-particle wave functions, or orbitals $\\phi\\left(\\mathbf{r}\\right)$.  In this \\textit{independent-particle model}, a selection of single-particle wave functions, known as the single-particle basis, are constructed by solving the Schr\\\"{o}dinger equation for a single particle in either a mean-field potential for bound systems or in free space for infinite systems.  Then a many-body wave function is constructed as a product of these single-particle orbits.  This simple model is justified because it becomes exact when inter-particle interactions are completely suppressed and is useful because it provides an intuitive way to interpret complicated many-body dynamics as processes involving few single-particle wave functions.\n\nA many-body wave function of fermions must be anti-symmetric with respect to particle exchange so that the Pauli exclusion principle is followed, such that no single-particle wave function is occupied by more than one fermion.  This condition is satisfied by a wave function in the form of a \\textit{Slater determinant} \\cite{SLATER1929},\n\\begin{equation} \\label{eq:slaterdeterminant}\n  \\Phi\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right) =\n  \\frac{1}{\\sqrt{A!}}\\begin{vmatrix}\n    \\phi_{1}\\left(\\mathbf{r}_{1}\\right) & \\phi_{1}\\left(\\mathbf{r}_{2}\\right) & \\cdots & \\phi_{1}\\left(\\mathbf{r}_{A}\\right) \\\\\n    \\phi_{2}\\left(\\mathbf{r}_{1}\\right) & \\phi_{2}\\left(\\mathbf{r}_{2}\\right) & \\cdots & \\phi_{2}\\left(\\mathbf{r}_{A}\\right) \\\\\n    \\vdots & \\vdots & \\ddots & \\vdots \\\\\n    \\phi_{A}\\left(\\mathbf{r}_{1}\\right) & \\phi_{A}\\left(\\mathbf{r}_{2}\\right) & \\cdots & \\phi_{A}\\left(\\mathbf{r}_{A}\\right)\n  \\end{vmatrix},\n\\end{equation}\nwhere $A$ is the number of particles in the system and $\\phi_{p}\\left(\\mathbf{r}_{\\mu}\\right)$ is the $p$-th orbital filled with the $\\mu$-th particle.\n\nIf the orbitals are constructed from an appropriate phenomenological potential, a Slater determinant composed of the $A$ lowest orbitals can represent a fairly good approximation to the ground state for a closed-shell system, where the lowest-energy Slater determinant can be uniquely determined.  The set of all Slater determinants in a certain model space of single-particle wave functions defines a complete $A$-body Hilbert space such that a generic wave function can be written as a linear combination of Slater determinants,\n\\begin{equation}\n  \\Psi_{\\nu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right) = \\sum_{\\mathclap{\\mu = 1}}^{\\mathcal{N}} C^{\\mu}_{\\nu}\\Phi_{\\mu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right),\n\\end{equation}\nwhere $C^{\\mu}_{\\nu} = \\braket{\\Psi\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right)}{\\Phi^{\\mu}_{\\nu}\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right)}$.  The number of Slater determinants $\\mathcal{N}$ in an A-body Hilbert space with $N$ orbits is given by,\n\\begin{equation} \\label{eq:factorialscaling}\n  \\mathcal{N} = \\left(\\begin{matrix} N \\\\ A \\end{matrix}\\right) = \\frac{N!}{A!(N - A)!},\n\\end{equation}\nwhich shows the factorial scaling of the exact problem.  However, to reduce the size of the problem, progressively more significant Slater determinants can be chosen to systematically refine approximations to the full solution.\n\n\\section{Second Quantization}\nEven with the simplification of the independent-particle model, the many-body Schr\\\"{o}dinger equation is an unwieldy and complex system of coupled differential equations.  A useful reformulation of this equation is to promote the single-particle orbits to operators in a step known as \\textit{second quantization} (see e.g., \\cite{SHAVITT2009,FETTER2003043536}).  In this framework, a Slater determinant is represented by a string of occupied orbitals,\n\\begin{equation}\n  \\Phi\\left(\\mathbf{r}_{1},\\cdots,\\mathbf{r}_{A}\\right) \\equiv \\mathcal{A}\\left(\\phi_{p_{1}}\\ \\phi_{p_{2}}\\ \\phi_{p_{3}} \\cdots \\phi_{p_{N}}\\right) \\equiv \\ket{p_{1}\\ p_{2}\\ p_{3} \\cdots p_{N}},\n\\end{equation}\nwhere $\\mathcal{A}$ represents a permutation and normalization operator to correspond with Eq.\\ \\eqref{eq:slaterdeterminant}.  These second-quantized Slater determinants can be constructed with the use of operators that correspond to specific orbitals.  A \\textit{creation} operator, $\\co{p}$, places a particle in the $p$ orbital, and an \\textit{annihilation} operator, $\\ao{p}$, removes a particle from the $p$ orbital,\n\\begin{equation}\n  \\co{p}\\ket{0} = \\ket{p} \\hspace{2cm} \\ao{p}\\ket{p} = \\ket{0},\n\\end{equation}\nwhere $\\ket{0}$ represents the true vacuum, a state void of any particles.  Because there must be a correspondence between the original first quantization and second quantization, these creation an annihilation operators obey the following anticommutation relations ($[ \\hat{A},\\hat{B} ]_{+} = \\hat{A}\\hat{B} + \\hat{B}\\hat{A}$),\n\\begin{equation} \\label{eq:anticommutation}\n  [ \\co{p},\\ao{q} ]_{+} = \\delta_{pq} \\hspace{1cm} [ \\co{p},\\co{q} ]_{+} = [ \\ao{p},\\ao{q} ]_{+} = 0,\n\\end{equation}\nwhich guarantee that wave functions comprised of these operators obey antisymmetry and the Pauli exclusion principle required of fermionic systems.\n\nThe Hamiltonian in the form of Eq.\\ \\eqref{eq:hamiltonian} can be written with second-quantized operators as,\n\\begin{equation}\n  \\Ham = \\sum_{\\mathclap{pq}}\\Hint{1}{p}{q}\\ \\co{p}\\ao{q} + \\frac{1}{4}\\sum_{\\mathclap{pqrs}}\\Hint{2}{pq}{rs}\\ \\co{p}\\co{q}\\ao{s}\\ao{r} + \\frac{1}{36}\\sum_{\\mathclap{pqrstu}}\\Hint{3}{pqr}{stu}\\ \\co{p}\\co{q}\\co{r}\\ao{u}\\ao{t}\\ao{s} + \\cdots,\n\\end{equation}\nwhere the prefactors account for the double counting of particle-particle interactions, and the matrix elements represent integrals over the relevant single-particle wave functions,\n\\begin{gather} \\label{eq:braket_integration}\n    \\Hint{1}{p}{q} \\equiv \\int d\\mathbf{r}_{1}\\  \\phi^{*}_{p}\\left(\\mathbf{r}_{1}\\right) \\HamB{1}\\left(\\mathbf{r}_{1}\\right) \\phi_{q}\\left(\\mathbf{r}_{1}\\right) \\notag \\\\\n    \\Hint{2}{pq}{rs} \\equiv \\int d\\mathbf{r}_{1} d\\mathbf{r}_{2}\\  \\phi^{*}_{p}\\left(\\mathbf{r}_{1}\\right)\\phi^{*}_{q}\\left(\\mathbf{r}_{2}\\right) \\HamB{2}\\left(\\mathbf{r}_{1},\\mathbf{r}_{2}\\right) \\left[\\phi_{r}\\left(\\mathbf{r}_{1}\\right)\\phi_{s}\\left(\\mathbf{r}_{2}\\right) - \\phi_{s}\\left(\\mathbf{r}_{1}\\right)\\phi_{r}\\left(\\mathbf{r}_{2}\\right)\\right] \\notag \\\\\n    \\vdots\n\\end{gather}\nMatrix elements involving two or more particles include exchange terms which guarantee that they are also antisymmetric,\n\\begin{gather} \\label{eq:anti_sym_ME}\n  \\Hint{2}{pq}{rs} = -\\Hint{2}{qp}{rs} = -\\Hint{2}{pq}{sr} = \\Hint{2}{qp}{sr} \\notag \\\\\n  \\Hint{3}{pqr}{stu} = -\\Hint{3}{qpr}{stu} = -\\Hint{3}{pqr}{tsu} = \\Hint{3}{qpr}{tsu} = \\cdots\n\\end{gather}\nThese definitions apply regardless of the form of the Hamiltonian, and thus this formalism remains generic to the particular system.  Second quantization is a crucial step in simplifying the many-body Schr\\\"{o}dinger equation because it reduces the complexity of the spatial and spin degrees of freedom within the single-particle wave functions and interactions into precomputed matrix elements.  The remaining effort is reduced to algebraic expressions involving creation and annihilation operators.\n\n\n\\section{Normal Ordering}\nIt's convenient to define an $A$-particle reference state, where states are filled from the true vacuum up to a closed shell, known as the Fermi level.  This reference state must be uniquely determined from the number of particles in the system and therefore nondegenerate with other Slater determinants,\n\\begin{equation}\n  \\refket = \\normord{\\prod_{i}^{A}\\co{i}}\\vacket.\n\\end{equation}\nThis reference determinant defines a new \\textit{Fermi vacuum}. States above the Fermi vacuum are called \\textit{particle} states and will be denoted with the indices $a,b,c,d...$ while states below the Fermi vacuum are called \\textit{hole} states and will be denoted with the indices $i,j,k,l...$. Generic states above or below the Fermi vacuum will be denoted with the indices $p,q,r,s...$.\n\n\\begin{figure}\n  \\centering\n  \\mbox{{\\large $\\refket\\ =\\ $}} $\\vcenter{\\hbox{\\includegraphics[height=4cm]{manybody/IPM.pdf}}}$\n  \\caption{A depiction of the closed-shell reference state in the independent particle model.  Each horizontal line represents a shell of single-particle orbits, represented by circles, and the dotted line represents the Fermi level which separates the unoccupied \\textit{particle} states from the occupied \\textit{hole} states.}\n  \\label{fig:reference_state}\n\\end{figure}\n\nAny other Slater determinant can be constructed relative to this reference state by adding particles and/or removing holes.  A Slater determinant with $A$ particles added and $B$ holes removed from reference state is known as a $\\ph{A}{B}$ excitation.  A $\\ph{1}{1}$ state is constructed by removing a particle in the occupied state $i$ and adding a particle in the unoccupied state $a$,\n\\begin{equation} \\label{eq:1p1h_ket_states}\n  \\ket{\\Phi^{a}_{i}} &\\equiv \\co{a}\\ao{i}\\ket{\\Phi}.\n\\end{equation}\nEquivalently, a $\\ph{2}{2}$ state is constructed by removing particles in states $i$ and $j$ then adding them to states $b$ and $a$,\n\\begin{equation} \\label{eq:2p2h_ket_states}\n  \\ket{\\Phi^{ab}_{ij}} &\\equiv \\co{a}\\co{b}\\ao{j}\\ao{i}\\ket{\\Phi}.\n\\end{equation}\nThe number of creation and annihilation operators doesn't neccessarily have to be equal.  For instance, a single particle can be added on top of the reference state with a single creation operator,\n\\begin{equation} \\label{eq:1p_ket_states}\n  \\ket{\\Phi^{a}} &\\equiv \\co{a}\\ket{\\Phi},\n\\end{equation}\nand a particle can be removed with a single annihilation operator,\n\\begin{equation} \\label{eq:1h_ket_states}\n  \\ket{\\Phi_{i}} &\\equiv \\ao{i}\\ket{\\Phi}.\n\\end{equation}\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}{\\textwidth}\n    \\centering\n    $\\ket{\\Phi^{a}_{i}}\\ = \\vcenter{\\hbox{\\includegraphics[height=3cm]{manybody/1p1h.pdf}}} \\hspace{2cm} \\ket{\\Phi^{ab}_{ij}}\\ = \\vcenter{\\hbox{\\includegraphics[height=3cm]{manybody/2p2h.pdf}}}$\n  \\end{subfigure}\n  \\vspace{0.5cm}\n  \n  \\begin{subfigure}{\\textwidth}\n    \\centering\n    $\\ket{\\Phi^{a}}\\ = \\vcenter{\\hbox{\\includegraphics[height=3cm]{manybody/PA.pdf}}} \\hspace{2cm} \\ket{\\Phi_{i}}\\ = \\vcenter{\\hbox{\\includegraphics[height=3cm]{manybody/PR.pdf}}}$\n  \\end{subfigure}\n  \\caption{A depiction of $\\ph{1}{1}$, $\\ph{2}{2}$, $\\ph{1}{0}$, and $\\ph{0}{1}$ Slater determinants defined relative to the reference state in the independent particle model.}\n  \\label{fig:excitations}\n\\end{figure}\n  \nUsing these definitions, hole-creation and particle-annihilation operators vanish when acting on the Fermi vacuum from the left, $\\co{i}\\refket=\\ao{a}\\refket=0$. Conversely, hole-annihilation and particle-creation operators vanish when acting on the Fermi vacuum from the right, $\\refbra\\ao{i}=\\refbra\\co{a}=0$.\n\nThese results can be exploited to simplify expressions involving strings of creation and annihilation operators by a procedure called \\textit{normal ordering} with respect to the Fermi vacuum. Denoted by $\\normord{\\cdots}$, normal ordering permutes a string of creation and annihilation operators so that hole-annihilation and particle-creation operators are to the left of hole-creation and particle-annihilation operators, which guarantees that normal ordered operators vanish on the Fermi vacuum, $\\refbra\\normord{\\cdots} = 0$ and $\\normord{\\cdots}\\refket = 0$.\n\\begin{equation} \\label{eq:normorddef}\n  \\normord{\\co{j}\\cdots\\ao{i}\\cdots\\ao{b}\\cdots\\co{a}} = (-1)^{\\sigma}\\ao{i}\\cdots\\co{a}\\cdots\\co{j}\\cdots\\ao{b},\n\\end{equation}\nwhere $\\sigma$ is the number of two-state permutations required to do the normal ordering.\n\n\n\\section{Wick's Theorem} \\label{section:wicks_theorem}\nAt this point, the many-body problem has been reduced to computing long strings of creation and annihilation operators between the normal-ordered Hamiltonian and the correlated wave function using Eq.\\ \\eqref{eq:anticommutation}.  Instead of using a brute-force approach by permuting over and over, a further simplification known as \\textit{Wick's theorem} \\cite{WICK1950} can be introduced.  A Wick contraction of two operators with respect to the reference state is defined as\n\\begin{equation} \\label{eq:wick1}\n  \\contraction[1.0ex]{}{\\hat{A}}{}{\\hat{B}}\n  \\hat{A}\\hat{B} = \\hat{A}\\hat{B} - \\normord{\\hat{A}\\hat{B}}.\n\\end{equation}\nWhich, given the definition in Eq.\\ \\eqref{eq:normorddef} and the anticommutation relations int Eq.\\ \\eqref{eq:anticommutation}, means that the only nonzero contractions are of the form,\n\\begin{equation} \\label{eq:wick2}\n  \\contraction[1.0ex]{}{\\hat{a}}{^{\\dagger}_{i}}{\\hat{a}}\n  \\hat{a}^{\\dagger}_{i}\\hat{a}_{j} = \\delta_{ij} \\hspace{1.0cm} \\text{and} \\hspace{1.0cm}\n  \\contraction[1.0ex]{}{\\hat{a}}{_{a}}{\\hat{a}}\n  \\hat{a}_{a}\\hat{a}_{b}^{\\dagger} = \\delta_{ab}.\n\\end{equation}\nBecause contracted operators simply represent a Kronecker delta, they can be removed from a normal ordered product by permuting the product $\\sigma$ times so that the contracted operators are next to each other,\n\\begin{equation} \\label{eq:wick3}\n  \\contraction[1.0ex]{\\{ \\hat{A}\\cdots}{\\hat{B}}{\\cdots}{\\hat{C}}\n  \\{ \\hat{A}\\cdots\\hat{B}\\cdots\\hat{C}\\cdots\\hat{D} \\} = (-1)^{\\sigma}\n  \\contraction[1.0ex]{\\{ \\hat{A}\\cdots}{\\hat{B}}{}{\\hat{C}}\n  \\{ \\hat{A}\\cdots\\hat{B}\\hat{C}\\cdots\\hat{D} \\} = (-1)^{\\sigma}\n  \\contraction[1.0ex]{}{\\hat{B}}{}{\\hat{C}}\n  \\hat{B}\\hat{C}\\{ \\hat{A}\\cdots\\hat{D} \\}.\n\\end{equation}\nThese different definitions for operator manipulation come together to define the time-independent Wick's theorem, which reformulates a product of operators as the sum of its normal-ordered form and all possible contractions of its normal-ordered form,\n\\begin{equation} \\label{eq:wick4}\n  \\hat{A}\\hat{B}\\hat{C}\\cdots\\ =\\ \\normord{\\hat{A}\\hat{B}\\hat{C}\\cdots}\\\n  +\\ \\sum_{\\mathclap{\\substack{\\text{one-} \\\\ \\text{contractions}}}}\n  \\contraction[1.0ex]{\\{ }{\\hat{A}}{\\hat{B}\\hat{C}}{\\cdots}\n  \\{ \\hat{A}\\hat{B}\\hat{C}\\cdots \\}\\\n  +\\ \\sum_{\\mathclap{\\substack{\\text{two-} \\\\ \\text{contractions}}}}\n  \\contraction[0.8ex]{\\{ }{\\hat{A}}{\\hat{B}\\hat{C}}{\\cdots}\n  \\contraction[1.2ex]{\\{ \\hat{A}}{\\hat{B}}{\\hat{C}\\cdots}{}\n  \\{ \\hat{A}\\hat{B}\\hat{C}\\cdots \\}\\\n  +\\ \\cdots\\ +\\ \\sum_{\\mathclap{\\substack{\\text{all-} \\\\ \\text{contractions}}}}\n  \\contraction[0.6ex]{\\{ }{\\hat{A}}{\\hat{B}\\hat{C}}{\\cdots}\n  \\contraction[1.0ex]{\\{ \\hat{A}}{\\hat{B}}{\\hat{C}\\cdots}{\\ }\n  \\contraction[1.4ex]{\\{ \\hat{A}\\hat{B}}{\\hat{C}}{\\cdots\\ \\ \\ }{}\n  \\{ \\hat{A}\\hat{B}\\hat{C}\\cdots\\ \\ \\ \\}.\n\\end{equation}\n\nWick's theorem is incredibly useful in many-body techniques because complicated expressions of operators can be expressed as diagrams that are easy to compute with simple diagrammatic rules which correspond to Eqs.\\ \\eqref{eq:anticommutation},\\eqref{eq:wick2}, and \\eqref{eq:wick3}.  These diagrammatic techniques are an integral component to deriving expressions used in this work, and their underlying rules are extensively discussed in \\cite{SHAVITT2009}.\n\nA powerful application of Wick's theorem is to rewrite the Hamiltonian in Eq.\\ \\eqref{eq:hamiltonian} as a sum of normal-ordered operators in the form of Eq.\\ \\eqref{eq:wick4},\n\\begin{equation} \\label{eq:HamN}\n  \\Ham = E_{0} + \\sum_{\\mathclap{pq}}\\fint{p}{q}\\normord{\\co{p}\\ao{q}} + \\frac{1}{4}\\sum_{\\mathclap{pqrs}}\\vint{pq}{rs}\\normord{\\co{p}\\co{q}\\ao{s}\\ao{r}} + \\frac{1}{36}\\sum_{\\mathclap{pqrstu}}\\wint{pqr}{stu}\\normord{\\co{p}\\co{q}\\co{r}\\ao{u}\\ao{t}\\ao{s}} + \\cdots.\n\\end{equation}\nThis form of the Hamiltonian can be split into a zero-body component $E_{0}$, known as the \\textit{reference energy}, and the remaining \\textit{normal-ordered Hamiltonian}, $\\HamN$,\n\\begin{equation} \\label{eq:HamN1}\n  \\HamN = \\sum_{\\mathclap{pq}}\\fint{p}{q}\\normord{\\co{p}\\ao{q}} + \\frac{1}{4}\\sum_{\\mathclap{pqrs}}\\vint{pq}{rs}\\normord{\\co{p}\\co{q}\\ao{s}\\ao{r}} + \\frac{1}{36}\\sum_{\\mathclap{pqrstu}}\\wint{pqr}{stu}\\normord{\\co{p}\\co{q}\\co{r}\\ao{u}\\ao{t}\\ao{s}} + \\cdots.\n\\end{equation}\n\nThe reference energy, $E_{0}$, contains fully-contracted terms, and because the Hamiltonian operators are ordered so that the creation operators appear before the annihilations operators, only terms that contract \\textit{hole} states in the form $\\contraction[0.8ex]{\\{ \\cdots}{\\hat{a}}{^{\\dagger}_{i}\\cdots}{\\hat{a}}\\{ \\cdots\\co{i}\\cdots\\ao{j}\\cdots \\}$ are nonzero.  Therefore, the zero-body component of the normal ordered Hamiltonian can be written as a sums over all hole states for each component of the original Hamiltonian,\n\\begin{equation} \\label{eq:HamN_0}\n  E_{0} = \\sum_{\\mathclap{i}}\\Hint{1}{i}{i} + \\frac{1}{2}\\sum_{\\mathclap{ij}}\\Hint{2}{ij}{ij} + \\frac{1}{6}\\sum_{\\mathclap{ijk}}\\Hint{3}{ijk}{ijk} \\cdots.\n\\end{equation}\nIn a compact diagrammatic form, this sum can be drawn as the sum of connected vertices (\\raisebox{-5pt}{\\mbox{\\includegraphics[height=15pt]{diagrams/Hamiltonian/Hamiltonian-figure12.pdf}}}, \\raisebox{-5pt}{\\mbox{\\includegraphics[height=15pt]{diagrams/Hamiltonian/Hamiltonian-figure13.pdf}}}, etc...) corresponding to the components of the original Hamiltonian in Eq.\\ \\eqref{eq:hamiltonian},\n\\begin{equation}\n  E_{0} = \\diagram{Hamiltonian/Hamiltonian-figure0} + \\diagram{Hamiltonian/Hamiltonian-figure1} + \\diagram{Hamiltonian/Hamiltonian-figure2} + \\cdots.\n\\end{equation}\nThe number of lines connected to each vertex defines its type such that the single vertex corresponds to the one-body Hamiltonian, the double vertex corresponds to the two-body Hamiltonian, etc...  The looped lines represent a sum over all hole states.  The reference energy is also equivalent to the Hamiltonian expectation value for the reference state,\n\\begin{equation} \\label{eq:E_ref}\n  E_{0} = \\element{\\Ref}{\\Ham}{\\Ref}.\n\\end{equation}\n\nThe second component of the normal-ordered Hamiltonian, $\\fint{p}{q}\\normord{\\co{p}\\ao{q}}$, contains terms that have all operators contracted except for one pair.  Like the fully-contracted term, these contractions must involve only hole states,\n\\begin{equation} \\label{eq:HamN_1}\n  \\fint{p}{q} = \\Hint{1}{p}{q} + \\sum_{\\mathclap{i}}\\Hint{2}{pi}{qi} + \\frac{1}{2}\\sum_{\\mathclap{ij}}\\Hint{3}{pij}{qij} + \\cdots.\n\\end{equation}\nIn diagrammatic notation, the uncontracted pair of operators is represented as two external lines connected to each vertex which, because they are generic states, are drawn as unoriented lines,\n\\begin{equation}\n  \\diagram{Hamiltonian/Hamiltonian-figure3} = \\diagram{Hamiltonian/Hamiltonian-figure4} + \\diagram{Hamiltonian/Hamiltonian-figure5} + \\diagram{Hamiltonian/Hamiltonian-figure6} + \\cdots.\n\\end{equation}\nWhen a line represents a particle state, it will contain an arrow directed upwards while a line representing a hole state will contain an arrow directed downwards.\n\nThe two-body term, $\\vint{pq}{rs}\\normord{\\co{p}\\co{q}\\ao{s}\\ao{r}}$, follows in the same manner such that it represents all terms of the original Hamiltonian with all but two pairs of operators contracted.  Like the zero-body and one-body terms, the two-body term contains the original two-body term $\\HamB{2}$ as well as density-dependent terms that sum over hole states in higher-body Hamiltonian terms, leaving four external lines for each diagram vertex,\n\\begin{align} \\label{eq:HamN_2}\n  \\vint{pq}{rs} &= \\Hint{2}{pq}{rs} + \\sum_{\\mathclap{i}}\\Hint{3}{pqi}{rsi} + \\cdots \\notag \\\\\n  \\diagram{Hamiltonian/Hamiltonian-figure7} &= \\diagram{Hamiltonian/Hamiltonian-figure8} + \\diagram{Hamiltonian/Hamiltonian-figure9} + \\cdots.\n\\end{align}\n\nThree- and four-body normal-ordered terms can also be calculated by following the same procedure, but in practice are truncated at the two- or three-body level.  Because normal ordering the Hamiltonian has the effect of shuffling higher-order interactions into lower-order terms, it becomes feasible to include computationally expensive many-body interactions as normal-ordered few-body interactions.  Also, it reorganizes many-body correlations into the reference state so that additional correlations around the Fermi surface can be treated as a perturbation.  Therefore, from this point forward, the many-body problem will be formulated in terms of the normal-ordered terms in Eq.\\ \\eqref{eq:HamN}, and the bare interactions will be truncated beyond the three-body level for computational feasibility.  Electronic systems are naturally truncated at the level of the two-body Coulomb interaction, while nuclear systems can be successfully described with the two-body normal-ordered piece of the three-body force, in the form of Eq.\\ \\eqref{eq:HamN_2}.\n\nWith this new partition, the many-body Schr\\\"{o}dinger equation for the ground state $\\ket{\\Corr}$ can be written in terms of the normal-ordered Hamiltonian as,\n\\begin{gather} \\label{eq:normal_schrodinger}\n  \\Ham\\ket{\\Psi} = (E_{0} + \\HamN)\\ket{\\Psi} = E\\ket{\\Psi} \\notag \\\\\n  \\longrightarrow\\ \\ \\HamN\\ket{\\Psi} = (E - E_{0})\\ket{\\Psi} = \\Ecorr\\ket{\\Psi},\n\\end{gather}\nwhere $\\Ecorr$ is known as the \\textit{correlation energy}.\n\nNow that the many-body quantum problem has been formulated, different approaches to solving that problem can be proposed and analyzed.  Because taking account of correlations from all particles simultaneously is a demanding--and for some systems, computationally impossible--endeavor, methods for solving the many-body Schr\\\"{o}dinger equation should be systematically improvable. Successful methods with this quality incorporate the most dominant correlations in lower-order solutions and approach the exact solution when more and more orders are included.\n\n\\section{Hartree--Fock Method} \\label{section:hartree-fock}\nA successful, first-order approximation to any many-body method comes from noticing that each individual particle feels a mean-field potential from the cumulative interactions with all the other particles.  The \\textit{Hartree-Fock} (HF) method \\cite{HARTREE1928,FOCK1930} aims to transform the original single-particle basis to a Hartree-Fock basis where each orbital is the eigenfunction of its corresponding mean-field.  Because the transformation of a single orbital changes its effect on every other particle, this process must be performed iteratively until self-consistency between all the orbitals is reached, which is why this method is also known as the \\textit{Self-Consistent Field} (SCF) method.\n\nThis mean-field picture results from the following procedure.  It begins by minimizing the reference energy with respect to the reference state.  This functional is just the zero-body piece of the normal-ordered Hamiltonian,\n\\begin{equation}\n  E_{\\text{HF}}\\left[ \\Ref \\right] = \\element{\\Ref}{\\Ham}{\\Ref} = \\sum_{\\mathclap{i}}\\Hint{1}{i}{i} + \\frac{1}{2}\\sum_{\\mathclap{ij}}\\Hint{2}{ij}{ij} + \\frac{1}{6}\\sum_{\\mathclap{ijk}}\\Hint{3}{ijk}{ijk}.\n\\end{equation}\nTransforming the reference determinant can be accomplished by rotating the state within the single-particle basis by use of the \\textit{Thouless theorem} \\cite{THOULESS1960225}, which states that any Slater determinant can be written as the product of any other Slater determinant and an exponentiated single-excitation operator,\n\\begin{equation} \\label{eq:thouless}\n  \\ket{\\Phi'} = e^{\\hat{C}_{1}}\\refket, \\hspace{1cm} \\text{where\\ \\ } \\hat{C}_{1} = \\sum_{a i}C^{a}_{i}\\normord{ \\co{a}\\ao{i} }.\n\\end{equation}\nIf the difference between the two Slater determinants is dominated by single excitations, this transformation can be approximated by expanding the exponential and ignoring higher-order terms,\n\\begin{equation} \\label{eq:thouless_limit}\n  \\ket{\\Phi'} \\simeq \\left( 1 + \\sum_{a i}C^{a}_{i}\\normord{ \\co{a}\\ao{i} } \\right)\\refket.\n\\end{equation}\n\nThe reference energy functional can now be written as a sum of the original reference state and new terms that incorporate the single-excitation variation,\n\\begin{equation} \\label{eq:hf_thouless}\n  E_{\\text{HF}}\\left[ \\Phi' \\right] = \\element{\\Phi'}{\\Ham}{\\Phi'} \\simeq E_{\\text{HF}}\\left[ \\Ref \\right] + \\sum_{a i}C^{a}_{i}\\refbra\\Ham\\ket{\\Phi^{a}_{i}} + \\sum_{a i}C^{a*}_{\\ i}\\bra{\\Phi^{a}_{i}}\\Ham\\refket.\n\\end{equation}\nThe minimum of this functional is found by differentiating the expression with respect to the coefficients $C^{a}_{i}$ and setting the result to zero,\n\\begin{equation} \\label{eq:del_hf_thouless}\n  \\delta E_{\\text{HF}}\\left[ \\Phi' \\right] \\simeq \\sum_{a i}\\delta C^{a}_{i}\\refbra\\Ham\\ket{\\Phi^{a}_{i}} + \\sum_{a i}\\delta C^{a*}_{\\ i}\\bra{\\Phi^{a}_{i}}\\Ham\\refket = 0.\n\\end{equation}\n\nBecause this expression is Hermitian, both terms must vanish independently so that,\n\\begin{equation} \\label{eq:brillouin}\n  \\refbra\\Ham\\ket{\\Phi^{a}_{i}} = \\bra{\\Phi^{a}_{i}}\\Ham\\refket = 0.\n\\end{equation}\nThis condition is the result of the \\textit{Brillouin theorem} \\cite{BRILLOUIN1932}, which states that the Hamiltonian matrix element must vanish between an optimized Hartree-Fock ground state and any single excitation from it. The Brillouin condition is satisfied by diagonalizing the one-body piece of the normal-ordered Hamiltonian $\\fint{p}{q}$ (Eq.\\ \\eqref{eq:HamN_1}), known as the \\textit{Fock} operator, such that off-diagonal pieces like $\\refbra\\Ham\\ket{\\Phi^{a}_{i}} = \\fint{i}{a}$ and $\\bra{\\Phi^{a}_{i}}\\Ham\\refket = \\fint{a}{i}$ vanish.  Diagonalizing the Fock operator can be written schematically as,\n\\begin{gather} \\label{eq:fock_operator}\n  \\varepsilon^{p}_{q}\\delta_{pq}\\ \\ \\longleftarrow\\ \\ \\Hint{1}{p}{q} + \\sum_{\\mathclap{i}}\\Hint{2}{pi}{qi} + \\frac{1}{2}\\sum_{\\mathclap{ij}}\\Hint{3}{pij}{qij} \\notag \\\\\n  \\diagram{Hamiltonian/Hamiltonian-figure3}\\ \\ \\longleftarrow\\ \\ \\diagram{Hamiltonian/Hamiltonian-figure4} + \\diagram{Hamiltonian/Hamiltonian-figure5} + \\diagram{Hamiltonian/Hamiltonian-figure6},\n\\end{gather}\nwhere $\\varepsilon^{p}_{q}$ is the eigenvalue of the Fock operator, and its diagrammatic form vanishes when the external indices differ.\n\nA practical way of solving this system of equations is to express each new orbital in the unknown Hatree-Fock basis, $\\ket{p'} \\equiv \\phi_{p'}\\left(\\mathbf{r}\\right)$, denoted with primed labels, as a linear combination of the known single-particle basis states, $\\ket{p} \\equiv \\phi_{p}\\left(\\mathbf{r}\\right)$, denoted without primed labels.  These two bases are related by a unitary transformation $C^{p}_{p'} \\equiv \\braket{p}{p'}$,\n\\begin{equation} \\label{eq:fock_matrix_prime}\n  \\ket{p'} = \\sum_{p}\\braket{p}{p'}\\ket{p} = \\sum_{p}C^{p}_{p'}\\ket{p}.\n\\end{equation}\nThen the Fock matrix can be written in terms of the Hartree-Fock basis,\n\\begin{gather}\n  \\fint{p'}{q'} = \\Hint{1}{p'}{q'} + \\sum_{\\mathclap{i'}}\\Hint{2}{p'i'}{q'i'} + \\frac{1}{2}\\sum_{\\mathclap{i'j'}}\\Hint{3}{p'i'j'}{q'i'j'} \\notag \\\\\n  = \\sum_{\\mathclap{pq}}C^{p'*}_{p}\\Hint{1}{p}{q}C^{q}_{q'} + \\sum_{\\mathclap{\\substack{i' \\\\ prqs}}}C^{p'*}_{p}C^{i'*}_{r}\\Hint{2}{pr}{qs}C^{q}_{q'}C^{s}_{i'} + \\frac{1}{2}\\sum_{\\mathclap{\\substack{i'j' \\\\ prsqtu}}}C^{p'*}_{p}C^{i'*}_{r}C^{j'*}_{s}\\Hint{3}{prs}{qtu}C^{q}_{q'}C^{t}_{i'}C^{u}_{j'}.\n\\end{gather}\nDefining the first-order density matrix $\\gamma^{p}_{q}$ as the product of expansion coefficients, summed over all shared hole states,\n\\begin{equation}\n  \\gamma^{p}_{q} = \\sum_{i'}C^{p}_{i'}C^{i'*}_{q},\n\\end{equation}\nEq.\\ \\eqref{eq:fock_matrix_prime} is simplified to,\n\\begin{equation}\n  \\fint{p'}{q'} = \\sum_{\\mathclap{pq}}C^{p'*}_{p}\\left[ \\Hint{1}{p}{q} + \\sum_{\\mathclap{rs}}\\gamma^{r}_{s}\\Hint{2}{pr}{qs} + \\frac{1}{2}\\sum_{\\mathclap{rstu}}\\gamma^{r}_{t}\\gamma^{s}_{u}\\Hint{3}{prs}{qtu} \\right]C^{q}_{q'}\\ \\ \\longrightarrow\\ \\ \\varepsilon^{p'}_{q'}\\delta_{p'q'}.\n\\end{equation}\nTherefore, the Hartree-Fock equations are ultimately expressed as an eigenvalue problem according to Eq.\\ \\eqref{eq:fock_operator} where the matrix to diagonalize is the Fock matrix in the form,\n\\begin{equation}\n  \\hat{F}^{p}_{q}\\left(\\hat{C}\\right) = \\Hint{1}{p}{q} + \\sum_{\\mathclap{rs}}\\gamma^{s}_{r}\\Hint{2}{pr}{qs} + \\frac{1}{2}\\sum_{\\mathclap{rstu}}\\gamma^{t}_{r}\\gamma^{u}_{s}\\Hint{3}{prs}{qtu},\n\\end{equation}\nand the matrix of coefficients, $\\hat{C} = C^{p}_{p'}$, is the unitary operator that transforms the matrix to a diagonal form,\n\\begin{equation}\n  \\sum_{\\mathclap{pq}}C^{p'*}_{p}F^{p}_{q}\\left(\\hat{C}\\right)C^{q}_{q'} = \\varepsilon^{p'}_{q'}\\delta_{p'q'}\n\\end{equation}\nThe iterative nature of the solution comes from the dependence of the Fock matrix on the transformation coefficients. These Hartree-Fock equations are solved numerically by using an iterative algorithm where the Fock matrix is built using a known set of coefficients and diagonalized to obtain an updated set of coefficients.  This process is repeated until the unitary set of coefficients is unchanged within a certain tolerance.  For most calculations, using the identity matrix as an initial guess for the coefficients is sufficient.  To improve the rate of convergence, techniques such as the direct inversion of the iterative subspace (DIIS) \\cite{PULAY1980393,PULAY1982556} or Broyden's method \\cite{BROYDEN1965557} can be implemented.  And, to avoid any oscillatory behavior around the solution, techniques such as the level-shifting method or \\textit{ad hoc} linear mixing can be implemented to dampen the large changes between iterations.\n\nTo make use of the HF solution as the reference state for post-HF calculations, the Hamiltonian matrix elements must be transformed to the new basis and the normal-ordered pieces redefined to account for the additional reordering of one-particle correlations into the HF energy.  The one-body piece from Eq.\\ \\eqref{eq:HamN_1} is simply the resulting eigenvalues of the diagonalized Fock matrix,\n\\begin{equation} \\label{eq:HF_Ham_1}\n  \\fint{p'}{q'} = \\varepsilon^{p'}_{q'}\\delta_{p'q'}.\n\\end{equation}\nFor the two-body term, Eq.\\ \\eqref{eq:HamN_2}, first the density-dependent component of the three-body interaction is written with the first-order density matrix.  Then the remaining states are transformed according to Eq.\\ \\eqref{eq:fock_matrix_prime},\n\\begin{equation} \\label{eq:HF_Ham_2}\n  \\vint{p'q'}{r's'} = \\sum_{\\mathclap{pqrs}} C^{p'*}_{p}C^{q'*}_{q}\\left(\\Hint{2}{pq}{rs} + \\Hint{3}{pqt}{rsu}\\gamma^{u}_{t}\\right)C^{r}_{r'}C^{s}_{s'}.\n\\end{equation}\nThe reference energy from Eqns.\\ \\eqref{eq:HamN_0} and \\eqref{eq:E_ref} can be written in terms of the transformed one- and two-body Hamiltonian, Eqns.\\ \\eqref{eq:HamN_1} and \\eqref{eq:HamN_2}, and the original three-body term using first-order density matrices,\n\\begin{equation} \\label{eq:EF_Ham_0}\n  E_{0} = \\sum_{\\mathclap{i'}}\\varepsilon^{i'}_{i'} - \\frac{1}{2}\\sum_{\\mathclap{i'j'}}\\vint{i'j'}{i'j'} + \\frac{1}{6}\\ \\sum_{\\mathclap{pqrstu}}\\Hint{3}{pqr}{stu}\\gamma^{s}_{p}\\gamma^{t}_{q}\\gamma^{r}_{u}.\n\\end{equation}\nAdditionally, any operators that are constructed in the original basis must be transformed in a similar manner.  For example, a one-body operator $\\hat{O}$ in the Hartree-Fock basis is,\n\\begin{gather}\n  \\hat{O} = \\sum_{\\mathclap{p'q'}}\\opint{}{p'}{q'}\\normord{\\co{p'}\\ao{q'}} = \\sum_{\\mathclap{p'q'pq}}C^{p'*}_{p}\\opint{}{p}{q}C^{q}_{q'}\\normord{\\co{p'}\\ao{q'}} \\notag \\\\\n  \\longrightarrow\\ \\ \\ \\opint{}{p'}{q'} = \\sum_{\\mathclap{pq}}C^{p'*}_{p}\\opint{}{p}{q}C^{q}_{q'}.\n\\end{gather}\n\nBecause the Hartree-Fock basis is diagonal in the one-body piece of the Hamiltonian, any terms that include off-diagonal elements automatically vanish, greatly simplifying any post-Hartree-Fock methods.  From this point on, all calculations will use the Hartree-Fock basis unless stated otherwise, and prime symbols will be omitted.\n\n\n\\section{Configuration-Interaction} \\label{section:configuration_interaction}\nThe most generic way to write a correlated wave function in a given basis is as a linear combination of all possible Slater determinants.  This expansion can, in principle, consist of the $\\ph{0}{0}$ reference state and all possible $\\ph{N}{N}$ excitations up to $\\ph{A}{A}$ excitations,\n\\begin{equation} \\label{eq:ci_expansion}\n  \\ket{\\Psi_{\\nu}} = \\sum_{\\nu_{i}}^{\\mathcal{N}}C_{\\nu_{i}}\\ket{\\Phi_{\\nu_{i}}} = C_{0}\\ket{\\Phi_{0}} + \\sum_{N=1}^{A}\\left(\\frac{1}{N!}\\right)^2 \\sum_{\\substack{a_{1} \\ldots a_{N} \\\\ i_{1} \\ldots i_{N}}} C^{a_{1} \\ldots a_{N}}_{i_{1} \\ldots i_{N}}\\ket{\\Phi^{a_{1} \\ldots a_{N}}_{i_{1} \\ldots i_{N}}}.\n\\end{equation}\nUsing this form of the wave function in Eq.\\ \\eqref{eq:ci_expansion}, the normal-ordered Schr\\\"{o}dinger equation can be reformulated as a standard matrix eigenvalue problem,\n\\begin{gather}\n  \\HamN\\ket{\\Psi_{\\nu}} = \\Ecorr_{\\nu}\\ket{\\Psi_{\\nu}}\\ \\ \\longrightarrow\\ \\ \\element{\\Psi_{\\mu}}{\\HamN}{\\Psi_{\\nu}} = \\Ecorr_{\\nu}\\braket{\\Psi_{\\mu}}{\\Psi_{\\nu}} \\notag \\\\\n  = \\sum_{\\mathclap{\\mu_{i}\\nu_{i}}}C^{*}_{\\mu_{i}}\\element{\\Phi_{\\mu_{i}}}{\\HamN}{\\Phi_{\\nu_{i}}}C_{\\nu_{i}} = \\Ecorr_{\\nu}\\sum_{\\mathclap{\\mu_{i}\\nu_{i}}}C^{*}_{\\mu_{i}}C_{\\nu_{i}}\\delta_{\\mu_{i}\\nu_{i}} \\notag \\\\\n  \\longrightarrow\\ \\ \\mathbf{C}^{\\text{T}}_{\\mu}\\left(\\element{\\Phi_{\\mu_{i}}}{\\HamN}{\\Phi_{\\nu_{i}}} - \\Ecorr_{\\nu}\\mathbf{I}\\right)\\mathbf{C}_{\\nu} = 0.\n\\end{gather}\nIn this case, the matrix elements are Hamiltonian terms that connect two Slater determinants, and the eigenvectors are the ground and excited states in the form of Eq.\\ \\eqref{eq:ci_expansion}.  The matrix elements can be found with the help of the Slater-Condon rules \\cite{SLATER1929,CONDON1930} which, because the Hamiltonian is restricted to one- and two-body terms, require that any terms connecting Slater determinants which differ by more than two single-particle states vanish.  Also, because the one-body Hamiltonian is diagonal in the Hartree-Fock basis, it only contributes to diagonal elements of the CI matrix.  Some examples of these matrix elements are,\n\\begin{gather} \\label{eq:slater_condon}\n  \\element{\\Phi^{a}_{i}}{\\Ham}{\\Phi^{a}_{i}} = \\Edenom{}{a} - \\Edenom{}{i} - \\vint{ia}{ia}, \\notag \\\\\n  \\element{\\Phi^{ab}_{ij}}{\\Ham}{\\Phi^{cd}_{ij}} = \\vint{ab}{cd}, \\notag \\\\\n  \\element{\\Phi^{abc}_{ijk}}{\\Ham}{\\Phi^{abd}_{ijl}} = -\\vint{lc}{kd}.\n\\end{gather}\n\nBecause the configuration-interaction method exhaustively captures all the correlations of a many-body system, it is considered an ``exact'' method within a certain model space and becomes truly exact as the number of single-particle states is increased to infinity.  However, there is a price to pay for this exactness.  The number of Slater determinants in a certain model space, $\\mathcal{N}$, scales factorially according to Eq.\\ \\eqref{eq:factorialscaling} and the configuration-interaction matrix scales as $\\mathcal{N}^{2}$.  For sufficiently-sized model spaces, the memory required for this matrix quickly becomes unmanagable even for the largest supercomputers, see Fig.\\ \\ref{fig:fciscaling}.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=\\textwidth]{manybody/FCIscaling.png}\n  \\caption{Scaling of the matrix size and number of non-zero matrix elements for nuclear CI calculations of light nuclei.  Even for modestly-sized model spaces, the memory requirements approach the limit of petascale supercomputers ($\\sim 10^{10}$).  Figure taken from \\cite{SHAO2016}.}\n  \\label{fig:fciscaling}\n\\end{figure}\n\nHowever, for a reference state that is a good approximation to the true ground state, few-body excitations generally dominate the wave functions for low-lying states \\cite{SHERRILL1999143}.  This can be exploited by truncating the expansion in Eq.\\ \\eqref{eq:ci_expansion}.  Owing to the two-body nature of the interaction, the lowest appropriate truncation is also at the two-body level, known as configuration interaction with singles and doubles (CISD),\n\\begin{equation} \\label{eq:cisd_expansion}\n  \\ket{\\Psi_{\\nu}} = C_{0}\\ket{\\Phi_{0}} + \\sum_{\\mathclap{a i}} C^{a}_{i}\\ket{\\Phi^{a}_{i}} + \\frac{1}{4}\\sum_{\\mathclap{a b i j}} C^{ab}_{ij}\\ket{\\Phi^{ab}_{ij}}.\n\\end{equation}\nThis is a very straightforward and tractable way to approximate the many-body Schr\\\"{o}dinger equation, and it can be systematically improved by adding more excitations such as triples (CISDT) or triples and quadruples (CISDTQ).  But the drawback to this simplicity is that any truncated CI method is not size-extensive such that any extensive property of a system, like the energy, would scale with the size of the system.  A desirable many-body method will be both systematically improvable and size-extensive while maintaining computational feasibility.\n\n\n\\section{Many-Body Perturbation Theory} \\label{section:MBPT}\nOne many-body method that is both size-extensive and systematically improvable treats particle-particle interactions as a perturbation to the mean-field potential and is known as many-body perturbation theory (MBPT) \\cite{MOLLER1934,HUBBARD1957539,HUGENHOLTZ1957481,SHAVITT2009}.  The Hamiltonian is partitioned into a diagonal piece and the interaction piece,\n\\begin{gather} \\label{eq:mbpt_hamiltonian}\n  \\Ham = \\Ham_{0} + \\hat{V},\\ \\ \\text{with} \\notag \\\\\n  \\Ham_{0} = E_{0} + \\sum_{\\mathclap{p}}\\fint{p}{p}\\normord{\\co{p}\\ao{p}}\\ \\ \\text{and} \\notag \\\\\n  \\hat{V} = \\frac{1}{4}\\sum_{\\mathclap{pqrs}}\\vint{pq}{rs}\\normord{\\co{p}\\co{q}\\ao{s}\\ao{r}}.\n\\end{gather}\nWhen not in the Hartree-Fock basis, the interaction piece has the additional off-diagonal Fock term, $\\sum_{p\\neq q}\\fint{p}{q}\\normord{\\co{p}\\ao{q}}$.  This means that the reference state is an eigenstate of the zero-order piece of the Hamiltonian,\n\\begin{equation}\n  \\Ham_{0}\\refket = \\left(E_{0} + \\sum_{\\mathclap{i}}\\fint{i}{i}\\normord{\\co{i}\\ao{i}}\\right)\\refket = \\left(E_{0} + \\sum_{\\mathclap{i}}\\Edenom{}{i}\\right)\\refket = E^{(0)}_{0}\\refket.\n\\end{equation}\nUsing \\textit{intermediate normalization}, which sets $\\braket{\\Ref}{\\Psi} = 1$, the Schr\\\"{o}dinger equation, Eq.\\ \\eqref{eq:schrodinger} for the ground state becomes,\n\\begin{align}\n  \\refbra\\mathop{(\\Ham_{0} + \\hat{V})}\\corrket &= \\refbra\\Ham_{0}\\corrket + \\refbra\\hat{V}\\corrket = E\\braket{\\Phi}{\\Psi} \\notag \\\\\n  &= E^{(0)}\\braket{\\Phi}{\\Psi} + \\refbra\\hat{V}\\corrket = E^{(0)} + \\Delta E_{0} = E, \\label{eq:mbpt_schrodinger}\n\\end{align}\nwhere the energy difference is $\\Delta E_{0} \\equiv \\refbra\\hat{V}\\corrket$.\n\nNext, the projection operators $\\hat{P}$ and $\\hat{Q}$ can be introduced,\n\\begin{gather}\n  \\hat{P} = \\ket{\\Phi_{0}}\\bra{\\Phi_{0}}, \\\\\n  \\hat{Q} = \\sum_{n\\neq 0}\\ket{\\Phi_{n}}\\bra{\\Phi_{n}} = 1 - \\ket{\\Phi_{0}}\\bra{\\Phi_{0}}.\n\\end{gather}\nThe $\\hat{P}$ operator isolates the reference-state component of any Slater determinant while the $\\hat{Q}$ operator isolates all components \\textit{except} the reference-state component out of any Slater determinant.  Both these operators are idempotent, which means that $\\hat{P}^{2} = \\hat{P}$ and $\\hat{Q}^{2} = \\hat{Q}$, and because of intermediate normalization, the correlated wave function can be written as $\\ket{\\Psi} = \\mathop{(\\hat{P} + \\hat{Q})}\\ket{\\Psi} = \\ket{\\Phi} + \\hat{Q}\\ket{\\Psi}$.  Also, both operators commute with the unperturbed part of the Hamiltonian, $\\Ham_{0}\\hat{P} = \\hat{P}\\Ham_{0}$ and $\\Ham_{0}\\hat{Q} = \\hat{Q}\\Ham_{0}$.  These identities can be applied to an alternate version of the Schr\\\"{o}dinger equation which defines a particular version of perturbation theory known as Raleigh-Schr\\\"{o}dinger perturbation theory (RSPT) \\cite{RAYLEIGH1894,SCHRODINGER1926}. In this version, the zeroth-order energy $E^{(0)}$ is added to both sides of the Schr\\\"{o}dinger equation.  Acting with $\\hat{Q}$ and rearranging terms gives,\n\\begin{gather}\n  \\hat{Q}\\mathop{(E^{(0)} - \\Ham_{0})}\\ket{\\Psi} = \\hat{Q}\\mathop{(E^{(0)} + \\hat{V} - E)}\\ket{\\Psi} \\notag \\\\\n  \\hat{Q}\\mathop{(E^{(0)} - \\Ham_{0})}\\hat{Q}\\ket{\\Psi} = \\hat{Q}\\mathop{(\\hat{V} - \\Delta E_{0})}\\ket{\\Psi},\n\\end{gather}\nwhere $\\Delta E_{0} \\equiv E - E^{(0)} = \\refbra\\hat{V}\\corrket$.  The operator $\\hat{Q}\\mathop{(E^{(0)} - \\Ham_{0})}\\hat{Q}$ is invertible because $\\mathop{(E^{(0)} - \\Ham_{0})^{-1}}$ is never singular in $Q$-space.  Therefore, the operator $\\hat{R}_{0} = \\hat{Q}\\mathop{(E^{(0)} - \\Ham_{0})^{-1}}\\hat{Q}$, known as the \\textit{resolvent}, can be applied to both sides which gives,\n\\begin{equation}\n  \\hat{Q}\\ket{\\Psi} = \\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\ket{\\Psi}.\n\\end{equation}\nThe left-hand side of this equation can be rewritten as $\\hat{Q}\\ket{\\Psi} = \\corrket - \\refket$ to result in the generating equation for RSPT,\n\\begin{equation} \\label{eq:MBPT_Q}\n  \\ket{\\Psi} = \\ket{\\Phi} + \\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\ket{\\Psi}.\n\\end{equation}\nBecause the single-particle states are eigenfunctions of the zeroth-order Hamiltonian, they are also eigenfunctions of the resolvent, with the resulting eigenvalues, $\\Edenom{}{}$, are known as \\textit{energy denominators}.  Applying the resolvent operator to any state orthogonal to the reference state, see Eqs.\\ \\eqref{eq:1p1h_ket_states} - \\eqref{eq:1h_ket_states}, gives the following relation,\n\\begin{gather} \\label{eq:energy_denominators}\n  \\hat{R}_{0}\\stateket{a_{1}\\cdots a_{N}}{i_{1}\\cdots i_{N}} = \\frac{1}{\\Edenom{a_{1}\\cdots a_{N}}{i_{1}\\cdots i_{N}}}\\stateket{a_{1}\\cdots a_{N}}{i_{1}\\cdots i_{N}},\\ \\ \\text{where} \\notag \\\\\n  \\Edenom{a_{1}\\cdots a_{N}}{i_{1}\\cdots i_{N}} = \\varepsilon_{i_{1}} + \\cdots + \\varepsilon_{i_{N}} - \\varepsilon_{a_{1}} - \\cdots - \\varepsilon_{a_{N}}.\n\\end{gather}\n\nEquation \\eqref{eq:MBPT_Q} can be iterated infinitely to give the solution for the fully correlated wave function,\n\\begin{equation} \\label{eq:MBPT_wave1}\n  \\ket{\\Psi} = \\sum_{n=0}^{\\infty}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket.\n\\end{equation}\nApplying this form of the correlated wave function into Eq.\\ \\eqref{eq:mbpt_schrodinger} results in the energy difference,\n\\begin{equation} \\label{eq:MBPT_energy1}\n  \\Delta E_{0} = \\refbra\\hat{V}\\corrket = \\sum_{n=0}^{\\infty}\\refbra\\hat{V}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket\n\\end{equation}\n\nThe immediate problem with these equations is that the right-hand sides contain the target energy difference $\\Delta E_{0}$ for which these equations are meant to solve.  This can be remedied by expanding the right-hand sides and rearranging terms.  Using the fact that $\\hat{R}_{0}\\Delta E_{0}\\refket = \\Delta E_{0}\\hat{R}_{0}\\refket = 0$, the first-order energy $E^{(1)} = \\element{\\Ref}{\\hat{V}}{\\Ref}$, and the shifted term $\\widetilde{V} \\equiv \\hat{V} - E^{(1)}$, these simplify to,\n\\begin{align}\n  \\ket{\\Psi} - \\refket &= \\hat{R}_{0}\\hat{V}\\refket + \\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\hat{V}\\refket \\notag \\\\\n  &+ \\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\hat{V}\\refket - \\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\hat{V}}{\\Ref}\\hat{R}^{2}_{0}\\hat{V}\\refket + \\cdots \\\\\n  \\Delta E_{0} &= \\element{\\Ref}{\\hat{V}}{\\Ref} + \\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\hat{V}}{\\Ref} + \\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\hat{V}}{\\Ref} \\notag \\\\\n  &+ \\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\widetilde{V}\\hat{R}_{0}\\hat{V}}{\\Ref} - \\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\hat{V}}{\\Ref}\\element{\\Ref}{\\hat{V}\\hat{R}^{2}_{0}\\hat{V}}{\\Ref} + \\cdots\n\\end{align}\nThe order of each term can be easily identified by counting the numbers of times that $\\hat{V}$ or $\\widetilde{V}$ appears.  At the third order in the wave function and the fourth order in the energy, \\textit{renormalization} terms make their first appearance.  These terms contain separated and closed factors in the form of lower-order energy terms, such as $\\element{\\Ref}{\\hat{V}\\hat{R}_{0}\\hat{V}}{\\Ref} \\equiv E^{(2)}$.  Terms that do not contain normalization factors are known as \\textit{principal} terms.\n\n\\subsection{Factorization Theorem} \\label{section:factorization_theorem}\nA powerful application of diagrammatic techniques known as the \\textit{factorization theorem} \\cite{HUGENHOLTZ1957481,FRANTZ196016,BRANDOW1967} can immediately be used to simplify these expansions.  By factoring sums of \\textit{unlinked} diagrams, where two or more parts of a diagram are closed and separated, from the principal terms, it can be shown that they exactly cancel with the renormalization terms at each order.  In the following factorization, two fourth-order energy diagrams which differ by only the time-ordering of the interaction vertices are added together.  By multiplying each term by an appropriate factor so that they share a common denominator, the additive property of the energy denominators ($\\Edenom{ab}{ij} + \\Edenom{cd}{kl} = \\Edenom{abcd}{ijkl}$) can be exploited to remove the addition of both terms, now written as the product of two terms,  \n\\begin{gather} \\label{eq:factorization1}\n  \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ij}{ab}\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{ab}{ij}\\Edenom{abcd}{ijkl}\\Edenom{cd}{kl}} + \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ij}{ab}\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{ab}{ij}\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}} = \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\vint{ij}{ab}\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}\\frac{\\Edenom{ab}{ij} + \\Edenom{cd}{kl}}{\\left(\\Edenom{ab}{ij}\\right)^{2}\\Edenom{abcd}{ijkl}\\Edenom{cd}{kl}} \\notag \\\\\n  = \\frac{1}{4}\\sum_{\\mathclap{abij}}\\frac{\\vint{ij}{ab}\\vint{ab}{ij}}{\\left(\\Edenom{ab}{ij}\\right)^{2}}\\cdot\\frac{1}{4}\\sum_{\\mathclap{cdkl}}\\frac{\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{cd}{kl}} = \\braket{\\Psi^{(1)}_{n}}{\\Psi^{(1)}_{n}}E^{(2)}_{n}.\n\\end{gather}\nIn diagrammatic form, these sums are represented by internal lines between vertices.  The common resolvent in each term, drawn as a line through the relevant state, is removed, and the common diagrams which result are shown as a product (see \\cite{SHAVITT2009} for more details),\n\\begin{equation} \\label{eq:factorization1}\n  \\xdiagram{MBPT/MBPT-figure23} + \\xdiagram{MBPT/MBPT-figure24} = \\xdiagram{MBPT/MBPT-figure25}.\n\\end{equation}\n\n\nA similar factorization can be performed on the wave function terms.  The following example uses two similar third-order terms with different time-ordered interaction vertices.  Once again, the additive property of the energy denominators is used to factor the common denominator between the terms, resulting in the product of two lower-order terms,\n\\begin{gather} \\label{eq:factorization2}\n  \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{cd}{kl}\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}}\\ket{\\Phi^{ab}_{ij}} + \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{ab}{ij}\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}}\\ket{\\Phi^{ab}_{ij}} = \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\vint{ab}{ij}\\vint{kl}{cd}\\vint{cd}{kl}\\frac{\\Edenom{ab}{ij} + \\Edenom{cd}{kl}}{\\left(\\Edenom{ab}{ij}\\right)^{2}\\Edenom{abcd}{ijkl}\\Edenom{cd}{kl}}\\ket{\\Phi^{ab}_{ij}} \\notag \\\\\n  = \\frac{1}{4}\\sum_{\\mathclap{abij}}\\frac{\\vint{ab}{ij}}{\\left(\\Edenom{ab}{ij}\\right)^{2}}\\ket{\\Phi^{ab}_{ij}}\\cdot\\frac{1}{4}\\sum_{\\mathclap{cdkl}}\\frac{\\vint{kl}{cd}\\vint{cd}{kl}}{\\Edenom{cd}{kl}} = \\frac{\\ket{\\Psi^{(1)}_{n}}}{\\Edenom{}{n}}E^{(2)}_{n} \\notag \\\\\n  \\xdiagram{MBPT/MBPT-figure26} + \\xdiagram{MBPT/MBPT-figure27} = \\xdiagram{MBPT/MBPT-figure28}\n\\end{gather}\n\nThe factorization theorem is also valid with off-diagonal Fock terms and applies to the MBPT expansions of both the wave function and energy.  Therefore, the MBPT expansions in Eqs.\\ \\eqref{eq:MBPT_wave1} and \\eqref{eq:MBPT_energy1} can be written in terms of \\textit{linked diagrams} only \\cite{GOLDSTONE1957267},\n\\begin{gather} \\label{eq:linked_MBPT}\n  \\ket{\\Psi} = \\sum_{n=0}^{\\infty}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket_{\\mathrm{L}}, \\\\\n  \\Delta E_{0} = \\sum_{n=0}^{\\infty}\\refbra\\hat{V}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket_{\\mathrm{L}},\n\\end{gather}\nwhere ``$\\mathrm{L}$'' denotes that no diagrams with closed, disconnected pieces should be included.  This result not only simplifies the MBPT expressions, but it guarantees the size-extensivity of the MBPT wave function at each order \\cite{SHAVITT2009}.  Also, it is a useful step towards coupled-cluster theory which reorganizes the connected diagrams from MBPT such that certain classes can be summed to infinite order, see section \\ref{section:linkedcluster}.\n\n\n\\end{document}\n", "meta": {"hexsha": "7a87257353d8a63e8c317ad4817a739f6c886593", "size": 50193, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ManyBody.tex", "max_stars_repo_name": "novarios/Thesis", "max_stars_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ManyBody.tex", "max_issues_repo_name": "novarios/Thesis", "max_issues_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ManyBody.tex", "max_forks_repo_name": "novarios/Thesis", "max_forks_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 117.5480093677, "max_line_length": 1059, "alphanum_fraction": 0.7211563365, "num_tokens": 16151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4314467341531434}}
{"text": "% !TeX root = ../thesis.tex\n% !TeX spellcheck = en_GB\n% !TeX encoding = UTF-8\n\n\nIn the last chapter, we saw that exotic options usually cannot be priced in a closed-form formula using the Black-Scholes model. The way out is by using numerical methods. These methods range from using discrete models (which converge to continuous models, as remarked in Chapter \\ref{cha:models}), to discretisation of the Black-Scholes PDE or using Monte Carlo simulations.\n\nThe advantage of using the Cox-Ross-Rubinstein model is that it converges to the Black-Scholes model as the number of time steps increases to infinity. But the exponential number of paths ($2^n$ to be exact, where $n$ is the number of time steps) make the method very slow and memory intensive, making it computably impractical. A logical step would be to modify the basic Cox-Ross-Rubinstein model to allow for approximations. In this direction, Gaudenzi et al\\cite{Gaudenzi2010} introduced a new method called the \\emph{singular points method} for pricing certain path-dependent options in an efficient manner.\n\nIn this chapter, we will mainly focus on applying the singular points method to price Asian options. In Asian options, the price is expressed as a function of some form of averaging on the underlying's price. Popular Asian options use the arithmetic or geometric means as the average. Again, Asian options may be exercised only at maturity (European) or at any time before maturity (American). They may give the owner of the option the right to either sell (put) or buy (call). Theoretically, we will only study calls, because the framework for puts one may be derived in the exact same way.\n\n\n\n\\section{Literature Review}\n\\label{sec:asian-literature-review}\n\nBefore we go into the details of the singular points method, we shall look into the pre-existing methods of pricing Asian options, and discuss their advantages and disadvantages briefly. As we remarked in Section \\ref{subsec:continuous-other}, Asian options with arithmetic mean cannot be valued by closed-form formulae in the Black–Scholes model, and their valuation requires the use of numerical methods. Here we consider a tree method for pricing these types of options.\n\nThe main barrier to applying the Cox–Ross–Rubinstein method \\cite{Cox1979} introduced in Chapter \\ref{cha:models} to Asian options with arithmetic averages is the exponential increase in the number of paths that the underlying may take, and this increases the computational difficulty very quickly as we increase the number of time steps.\n\n\\paragraph{Tree methods}\nAlternative feasible approaches were proposed by Hull and White (1993) \\cite{Hull1993}, and Barraquand and Pudet (1996) \\cite{Barraquand1996}. The main idea behind their procedures is to restrict the range of all the possible arithmetic averages to a set of representative values. These values are selected in order to span all the possible values of the averages achievable at each node of the tree. The price is then computed by a backward induction procedure in which the prices associated with averages not included in the set of representative values are obtained by interpolation. Both of these methods reduce the computational complexity to $ O(n^3) $, $ n $ being the number of steps. Nevertheless, the advantage of speed is offset by the fact that it is difficult to control the precision of the approximations and the convergence to the continuous value. This was highlighted by Forsyth \\emph{et al} \\cite{Forsyth2002} in 2002. Forsyth \\emph{et al} also proved that a procedure of order $ O(n^{\\frac{7}{2}}) $ is necessary in order to assure the convergence of these algorithms.\n\nLater, Chalasani \\emph{et al} (1999) \\cite{Chalasani1999} proposed a totally different approach, which allowed them to obtain thin upper and lower bounds on the exact Cox–Ross–Rubinstein binomial price for American Asian options. Their method requires a forward procedure and a backward induction. This algorithm significantly increases the precision of the estimates but requires a very large amount of memory and has computational complexity $ O(n^4) $.\n\n\\paragraph{PDE based methods}\nAll of the above were tree methods. More recently, very efficient partial differential equation (PDE)-based methods have been introduced by Vecer (2001) \\cite{Vecer2001} and d'Halluin et al (2005) \\cite{dHalluin2005}. In Vecer's method, the price of the Asian option is characterized by a simple one-dimensional partial differential equation which could be applied to both continuous and discrete average Asian option. The computational complexity is $ O(n^2) $. This approach cannot be applied to American fixed-strike Asian options, which, on the other hand, can be treated using the semi-lagrangian approach of d'Halluin \\emph{et al}.\n\nTable \\ref{tab:asian-literature-review} briefly reviews the discussion above.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Pre-existing methods for Asian options}\n\t\\label{tab:asian-literature-review}\n\t% \\rowcolors{1}{Burlywood1}{}\n\t\\begin{tabular}{cccl}\n\t\t\\toprule\n\t\tMethod  &  Type  &  Complexity  &  Remarks  \\\\\n\t\t\\midrule\n\t\tBinomial  &  Tree  &  $ O(2^n) $  &  simple, accurate, convergence to continuous  \\\\\n\t\tHull \\& White  &  Tree  &  $ O(n^3) $  &  accuracy and convergence problems  \\\\\n\t\tBarraquand \\& Pudet  &  Tree  &  $ O(n^3) $  &  accuracy and convergence problems  \\\\\n\t\tChalasani et al  &  Tree  &  $ O(n^4) $  &  thin bounds, but very large memory  \\\\\n\t\tVecer  &  PDE  &  $ O(n^2) $  &  not universally applicable  \\\\\n\t\td'Halluin  &  PDE  &  NA  &  more general than Vecer \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\nA number of these algorithms has been implemented in Premia 13. Premia is a software designed for option pricing, hedging and financial model calibration. It has been developed by the `MathFi' team in INRIA. It is provided with its C/C++ source code and an extensive scientific documentation. More information about Premia can be found at the dedicated  website\\footnote{\\url{https://www.rocq.inria.fr/mathfi/Premia/}}.\n\n\n\\section{The exact binomial algorithm}\n\\label{sec:asian-binom}\nIn what follows, we shall assume that the evolution of the prices of the risky asset $ (S_t)_t $ is governed by the Black-Scholes stochastic differential equation as discussed in Equation \\ref{eq:continuous-risky-sde-risk-neutral} of Chapter \\ref{cha:models}. Its solution is given by Equation \\ref{eq:continous-risky}b. Whenever there is a continuous dividend yield, we modify the equation according the remark \\ref{rem:continuous-dividend}.\n\nConsider the discrete model. If the number of time steps in the binomial tree is $ n $, then the corresponding time step is $ \\Delta T = \\frac{T}{n} $. The lognormal diffusion process $ (S_{i \\Delta T})_{i \\in [n]} $ is approximated by the Cox–Ross–Rubinstein binomial process (refer Equation \\ref{eq:discrete-risky-prod-iid}).\n\\begin{equation*}\n\tS_i = s_0 \\prod_{j=1}^{i} T_j  \\qquad  \\forall i \\in [n] .\n\\end{equation*}\n\nAs usual, we represent the risk-neutral probability by $ p = \\frac{R - d}{u - d} $, where $ u = d^{-1} = e^{\\sigma \\sqrt{\\Delta T}} $. We denote the effective rate of interest in each period as $ R \\coloneqq e^{r \\Delta T} $. We note that $R$ is not an instantaneous quantity, but one which is constant on an interval of time.\n\nAsian options are dependent on the average prices of the underlying risky asset. The price of an Asian option of the American type with initial time $ 0 $ and maturity $ T $ is given by the risk-neutral expectation calculated at an optimal stopping time (see Definiton \\ref{dfn:discrete-optimal-stopping-time} from Chapter \\ref{cha:models}).\n\\begin{equation}\n\tP(0, s_0, a_0) = \\sup_{\\tau \\in \\mathcal{T}_{[0,T]}}  \\E^* \\left(  e^{-r \\tau} \\  h(S_{\\tau}, A_{\\tau})  \\mid  S_0 = s_0, A_0 = s_0  \\right)\n\\end{equation}\nThe quantities used in the formula are explained below.\n\\begin{description}\n\t\\item[$ \\mathcal{T}_{[0,T]} $] the set of all stopping times with values in $ [0, T ] $\n\t\\item[$ h $] the payoff function, dependent on both the underlying's price and its average\n\t\\item[$ S_{\\tau} $] the underlying's price at time $ \\tau $\n\t\\item[$ A_{\\tau} $] (some form of) the average of the price of the underlying asset over the period $ [0, \\tau] $\n\\end{description}\n\nLet $ K $ denote the strike price. The price function may be one of the following\n\\begin{description}\n\t\\item[fixed Asian call] $ h(A_T) = (A_T - K)_+ $\n\t\\item[fixed Asian put] $ h(A_T) = (K - A_T)_+ $\n\t\\item[floating Asian call] $ h(S_T, A_T) = (S_T - A_T)_+ $\n\t\\item[floating Asian put] $ h(S_T, A_T) = (A_T - S_T)_+ $\n\\end{description}\n\n\n\\begin{dfn}[arithmetic mean]\n\tThe arithmetic mean of a set of $ n+1 $ numbers $ \\{ S_i \\}_{i \\in [n]} $ is given by:\n\t\\begin{equation}\n\t\\label{eq:am}\n\tA_{n} = \\frac{\\sum_{i=0}^n S_i}{n+1}\n\t\\end{equation}\n\\end{dfn}\n\nIn the rest of the chapter, we will assume that the average means arithmetic mean, unless otherwise stated.\n\nIn the Cox–Ross–Rubinstein model, consider a node at time $ i $. Let the price of the underlying be given by $ x $, and the arithmetic mean of the underlying till time $ i $ be given by $ y $. There are two possibilities for the asset price in the next time $ t = i + 1 $, namely $ x u $ and $ x d $. The average corresponding to the up and down movements become:\n\\begin{align*}\n\tA_{i+1}^u  &=  \\frac{(i+1) A_i + x u}{i+2}  =  \\frac{(i+1) y + x u}{i+2}  \\\\\n\tA_{i+1}^d  &=  \\frac{(i+1) A_i + x d}{i+2}  =  \\frac{(i+1) y + x d}{i+2}\n\\end{align*}\n\nDue to the Markov property of the pair of processes $ (S_t, A_t)_t $, we may use those as state variables in our evaluation formula. The price at time $ 0 $ of the Asian option of the European type with payoff function $ h(x, y) $ is given by $ v(0, s_0, s_0) $ (since $ a_0 = s_0 $), where the functions $ v(i, x, y) $ can be computed by the following backward dynamic programming equations, which are discounted risk-neutral expectation of the prices at the next time.\n\\begin{subequations}\n\t\\label{eq:asian-dp-eu}\n\t\\begin{align}\n\t\tv(n, x, y)  &=  h(x,y)  \\\\\n\t\tv(i, x, y)  &=  \\frac{1}{R} \\left(  p v \\left( i + 1, x u, \\frac{(i + 1) y + x u}{i + 2} \\right)  \\right.  \\\\\n\t\t&  \\qquad  \\left. + (1-p) v \\left( i + 1, x d, \\frac{(i + 1) y + x d}{i + 2} \\right)  \\right)  \\qquad   \\forall i \\in [n - 1]  \\nonumber\n\t\\end{align}\n\\end{subequations}\n\nIn case of Asian options of the American type, we modify the equations accordingly.\n\\begin{subequations}\n\t\\label{eq:asian-dp-am}\n\t\\begin{align}\n\t\tv(n, x, y)  &=  h(x,y)  \\\\\n\t\tv(i, x, y)  &=  \\max \\left\\lbrace  h(x, y), \\frac{1}{R} \\left(  p v \\left( i + 1, x u, \\frac{(i + 1) y + x u}{i + 2} \\right)  \\right. \\right. \\\\\n\t\t&  \\qquad  \\left. \\left. + (1-p) v \\left( i + 1, x d, \\frac{(i + 1) y + x d}{i + 2} \\right)  \\right)  \\right\\rbrace  \\qquad  \\forall i \\in [n - 1]  \\nonumber\n\t\\end{align}\n\\end{subequations}\n\nThe payoff is a function of the average, which is clearly path-dependent. Thus, the option is path-dependent, and the corresponding price tree is non-recombinant. This makes the classical binomial method infeasible after a small number of steps. Note that the binomial tree for the underlying is always recombinant for constant volatility.\n\n\n\\section{The singular points method}\n\\label{sec:asian-method}\n\nThe price of an Asian option at each instance is a continuous function of the underlying's average. Since the number of paths to a node in a binomial tree is finite, we have that at each node of the underlying's binomial tree, the option price may be represented as a piecewise-linear, continuous, convex function of the average. We shall develop the theoretical idea in this section. In the subsequent section, we shall see that the nature of the function allows us to make approximations with \\emph{a priori} error bounds.\n\n\n\\begin{dfn}[singular points and singular values] \\label{def:asian-sp}\n\tLet $ P = (P_i)_{i \\in [n]} = ( (x_i, y_i) )_{i \\in [n]} $, $ n \\in \\mathbb{N} $ be a sequence of points such that\n\t\\begin{subequations}\n\t\t\\label{eq:asian-conditions}\n\t\t\\begin{align}\n\t\t\ta =& x_0 < x_1 < \\dots < x_{n-1} < x_n = b  \\\\\n\t\t\tm_{i+1} :=& \\frac{y_{i+1} - y_{i}}{x_{i+1} - x_{i}} \\le \\frac{y_{i+2} - y_{i+1}}{x_{i+2} - x_{i+1}} = m_{i+2} \\qquad \\forall i \\in \\{ 1, \\dots, n-1 \\} .  \\label{eq:asian-condition-slope}\n\t\t\\end{align}\n\t\\end{subequations}\n\t\n\tLet $ f:[a,b] \\to [0, \\infty) $ be the function obtained by linear interpolation of the points in $P$. From the definition of $f$ and \\ref{eq:asian-condition-slope}, the function is continuous, piecewise-linear and convex.\n\t\n\tThen, the elements of $P$ are called \\emph{singular points of $f$} and the abscissae $ \\{ x_i \\}_{i \\in [n]} $ are called \\emph{singular values of $f$}.\n\\end{dfn}\n\n\n\\begin{rem}\n\t\\label{rem:asian-char}\n\tWe note that the singular points characterise such a function completely. This can be seen from the following representation of the function.\n\t\\begin{equation}\n\t\t\\label{eq:asian-function-repr}\n\t\tf(x) = y_0 + \\sum_{i=1}^n [ m_i ( \\min \\{x_{i}, x \\} - \\min \\{ x_{i-1}, x \\} ) ] .\n\t\\end{equation}\n\tWhere $ m_{i+1} = \\frac{y_{i+1} - y_{i}}{x_{i+1} - x_{i}} $ represents the slope of the function between $ x_{i} $ and $ x_{i+1} $.\n\\end{rem}\n\n\\begin{rem}\n\tFrom the conditions \\ref{eq:asian-conditions}, we get the following inequality.\n\t\\begin{equation*}\n\t\ty_0 < y_1 < \\dots < y_{n-1} < y_n\n\t\\end{equation*}\n\tSo it is equivalent to sort points using either abscissae or ordinates.\n\\end{rem}\n\n\n\n\\subsection{Upper estimates}\n\\label{subsec:asian-upper-estimates}\n\nThe following lemmas shall provide us with the necessary framework for upper and lower estimates for approximations on the functions generated by singular points.\n\n\\begin{lmm}[Upper estimate]\n\t\\label{lmm:asian-upper-estimate}\n\tLet $ f:[a,b] \\to [0, \\infty) $ be a continuous, piecewise-linear, convex function characterised by the singular points $ P = ( (x_i, y_i) )_{i \\in [n]} $. Then, if a point $ (x_j, y_j), j \\in \\{ 1, \\dots, n-1\\} $ is removed from the sequence, the function $ f_u: [a,b] \\to [0, \\infty) $ obtained by the new sequence $ (P_i)_{i \\in [n] \\setminus \\{ j \\}} $ is also continuous, piecewise-linear and convex, and\n\t\\begin{equation}\n\t\tf_u(x) \\ge f(x) \\qquad \\forall x \\in [a,b]\n\t\\end{equation}\n\\end{lmm}\n\n\\begin{proof}\n\tBy construction, $ \\forall x \\notin ( x_{j-1} , x_{j+1} ) $, we have $ f_u(x) = f(x) $.\n\t\n\tAgain, by construction, $ \\forall x \\in ( x_{j-1} , x_{j+1} ), f_u(x) = (1-t) f(x_{j-1}) + t f(x_{j+1}) $, where $ t = \\frac{ x - x_{j-1} }{ x_{j+1} - x_{j-1} } $.\n\t\n\tNow, we have:\n\t\\begin{alignat*}{9}\n\t\t          && x_{j-1}  & <  \\qquad x          && <  x_{j+1} \\\\\n\t\t\\implies  &&       0  & <  \\quad x - x_{j-1} && <  x_{j+1} - x_{j-1} \\\\\n\t\t\\implies  &&       0  & <  \\frac{ x - x_{j-1} }{ x_{j+1} - x_{j-1} } && <  1 \\\\\n\t\t\\implies  &&       0  & <  \\qquad t          && <  1\n\t\\end{alignat*}\n\t\n\t$f$ is convex $\\implies \\forall t \\in (0,1), \\; f( (1-t) x_{j-1} + t x_{j+1} ) < (1-t) f(x_{j-1}) + t f(x_{j+1}) $.\n\t\n\tThus, $ f_u(x) \\ge f(x) \\; \\forall x \\in [a,b]$.\n\\end{proof}\n\nRefer to Figure \\ref{fig:asian-upper-estimate} for a graphical representation of the above lemma.\n\\begin{figure}\n\t\\centering\n\t\n\t\\definecolor{qqzzqq}{rgb}{0.,0.6,0.}\n\t\\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}\n\t\\definecolor{ffqqqq}{rgb}{1.,0.,0.}\n\t\\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}\n\t\\definecolor{qqqqff}{rgb}{0.,0.,1.}\n\t\\definecolor{zzttqq}{rgb}{0.6,0.2,0.}\n\t\\definecolor{eqeqeq}{rgb}{0.8784313725490196,0.8784313725490196,0.8784313725490196}\n\t\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.7cm,y=0.7cm]\n\t\\draw [color=eqeqeq,dotted, xstep=1.4cm,ystep=1.4cm] (-1.,-1.) grid (17.,13.);\n\t\\draw[->,color=black] (0.,0.) -- (17.,0.);\n\t\\foreach \\x in {,2.,4.,6.,8.,10.,12.,14.,16.}\n\t\\draw[shift={(\\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);\n\t\\draw[color=black] (16.503014413215865,0.12712930521358398) node [anchor=south west] { A};\n\t\\draw[->,color=black] (0.,0.) -- (0.,13.);\n\t\\foreach \\y in {,2.,4.,6.,8.,10.,12.}\n\t\\draw[shift={(0,\\y)},color=black] (2pt,0pt) -- (-2pt,0pt);\n\t\\draw[color=black] (0.158911605284918,12.306834374720047) node [anchor=west] { P};\n\t\\clip(-1.,-1.) rectangle (17.,13.);\n\t\\draw [line width=1.2pt,color=qqqqff] (8.,4.25)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (16.,12.)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (8.,4.25)-- (4.,2.5);\n\t\\draw [line width=1.2pt,color=qqqqff] (4.,2.5)-- (1.,2.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (12.,8.)-- (12.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (8.,4.25)-- (8.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (4.,2.5)-- (4.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (1.,2.)-- (1.,0.);\n\t\\draw [line width=1.6pt,dash pattern=on 1pt off 2pt on 4pt off 4pt,color=ffqqqq] (4.,2.5)-- (12.,8.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (16.,12.)-- (16.,0.);\n\t\\draw [line width=1.2pt,dotted,color=qqzzqq] (8.,5.25)-- (8.,4.25);\n\t\\begin{scriptsize}\n\t\\draw [fill=zzttqq] (16.,12.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.40766745004491,11.448711564528356) node {$S_5$};\n\t\\draw [fill=zzttqq] (12.,8.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.371312675807992,7.507703102907252) node {$S_4$};\n\t\\draw [fill=zzttqq] (8.,4.25) circle (1.5pt);\n\t\\draw[color=zzttqq] (8.36674022262806,3.693823946499732) node {$S_3$};\n\t\\draw [fill=zzttqq] (4.,2.5) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.362167769448127,1.9775783261163484) node {$S_2$};\n\t\\draw[color=qqqqff] (9.669815385964387,5.441851893186511) node {$f$};\n\t\\draw[color=qqqqff] (6.300889353924126,3.0899597467352082) node {f};\n\t\\draw [fill=zzttqq] (1.,2.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.4064119111486517,1.7233197156891804) node {$S_1$};\n\t\\draw [fill=zzttqq] (16.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.185191202646024,-0.5014431255485392) node {$A_5$};\n\t\\draw [fill=zzttqq] (12.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.117054107352125,-0.5332254518519353) node {$A_4$};\n\t\\draw [fill=zzttqq] (8.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (8.080699333115207,-0.5967901044587272) node {$A_3$};\n\t\\draw [fill=zzttqq] (4.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.04434455887829,-0.6285724307621232) node {$A_2$};\n\t\\draw [fill=zzttqq] (1.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.056806379521832,-0.5967901044587272) node {$A_1$};\n\t\\draw[color=ffqqqq] (9.002386643767732,6.49066866119858) node {$f_u$};\n\t\\draw [fill=xdxdff] (8.,5.25) circle (1.5pt);\n\t\\draw[color=xdxdff] (7.476835233032519,5.4100695668831165) node {$R_3$};\n\t\\draw[color=qqzzqq] (8.36674022262806,4.837987693421987) node {$\\varepsilon_3$};\n\t\\end{scriptsize}\n\t\\end{tikzpicture}\n\t\n\t\\caption[Upper estimate]{Illustration of Lemma \\ref{lmm:asian-upper-estimate} with $ j = 3 $}\n\t\\label{fig:asian-upper-estimate}\n\\end{figure}\n\n\n\n\\subsection{Lower estimates}\n\\label{subsec:asian-lower-estimates}\n\n\\begin{lmm}[Lower estimate]\n\t\\label{lmm:asian-lower-estimate}\n\tLet $ f:[a,b] \\to [0, \\infty) $ be a continuous, piecewise-linear, convex function characterised by the singular points $ P = ( (x_i, y_i) )_{i \\in [n]} $. Let $ l_{j} $ be the line segment joining points $ P_{j-1} $ and $ P_{j} $. Similarly, let $ l_{j+2} $ be the line segment joining points $ P_{j+1} $ and $ P_{j+2} $. Denote the intersection of the line segments $ l_{j} $ and $ l_{j+2} $ by $ \\bar{P} = ( \\bar{x}, \\bar{y} ) $.\n\t\n\tThen the function $ f_d: [a,b] \\to [0, \\infty) $ characterised by $ (P_0, \\dots, P_{j-1}, \\bar{P}, P_{j+2}, \\dots, P_n) $ is also continuous, piecewise-linear and convex, and\n\t\\begin{equation}\n\t\tf_d(x) \\le f(x) \\qquad \\forall x \\in [a,b]\n\t\\end{equation}\n\\end{lmm}\n\n\\begin{proof}\n\tFirst we show the convexity of $f_d$. We know that $f$ satisfies the property of increasing slopes, that is $ m_{i} \\le m_{i+1} \\le m_{i+2} $. Since $f_d$ is obtained from $f$ by removing the line segment $l_{j+1}$, for $f_d$ we have that $ m_{i} \\le m_{i+2} $, which implies that the function $f_d$ is still convex.\n\t\n\tSecondly, to prove the inequality, we may look at the convex function $f$ as if it has been obtained by removing point $ \\bar{P} $ from the convex function $f_d$. Then, if $ \\bar{x} \\in ( x_{j} , x_{j+1} ) $, we have, using Lemma \\ref{lmm:asian-upper-estimate}, that $ f_d(x) \\le f(x) \\qquad \\forall x \\in [a,b] $.\n\\end{proof}\n\nRefer to Figure \\ref{fig:asian-lower-estimate} for a graphical representation of the above lemma.\n\\begin{figure}\n\t\\centering\n\t\n\t\\definecolor{qqwuqq}{rgb}{0.,0.39215686274509803,0.}\n\t\\definecolor{ffqqqq}{rgb}{1.,0.,0.}\n\t\\definecolor{ffqqff}{rgb}{1.,0.,1.}\n\t\\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}\n\t\\definecolor{qqqqff}{rgb}{0.,0.,1.}\n\t\\definecolor{zzttqq}{rgb}{0.6,0.2,0.}\n\t\\definecolor{eqeqeq}{rgb}{0.8784313725490196,0.8784313725490196,0.8784313725490196}\n\t\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.7cm,y=0.7cm]\n\t\\draw [color=eqeqeq,dotted, xstep=1.4cm,ystep=1.4cm] (-1.,-1.) grid (17.,13.);\n\t\\draw[->,color=black] (0.,0.) -- (17.,0.);\n\t\\foreach \\x in {,2.,4.,6.,8.,10.,12.,14.,16.}\n\t\\draw[shift={(\\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);\n\t\\draw[color=black] (16.63393630769859,0.10062658140528617) node [anchor=south west] { A};\n\t\\draw[->,color=black] (0.,0.) -- (0.,13.);\n\t\\foreach \\y in {,2.,4.,6.,8.,10.,12.}\n\t\\draw[shift={(0,\\y)},color=black] (2pt,0pt) -- (-2pt,0pt);\n\t\\draw[color=black] (0.12578320593052933,12.290527463477607) node [anchor=west] { P};\n\t\\clip(-1.,-1.) rectangle (17.,13.);\n\t\\draw [line width=1.2pt,color=qqqqff] (6.,4.)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (16.,12.)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (6.,4.)-- (4.,3.);\n\t\\draw [line width=1.2pt,color=qqqqff] (4.,3.)-- (1.,2.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (12.,8.)-- (12.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (6.,4.)-- (6.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (4.,3.)-- (4.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (1.,2.)-- (1.,0.);\n\t\\draw [line width=1.6pt,dash pattern=on 2pt off 2pt,color=ffqqqq] (6.,4.)-- (10.,6.);\n\t\\draw [line width=1.6pt,dash pattern=on 2pt off 2pt,color=ffqqqq] (12.,8.)-- (10.,6.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (10.,6.)-- (10.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (16.,12.)-- (16.,0.);\n\t\\draw [line width=1.6pt,dotted] (10.00153846153846,6.667692307692308)-- (10.,6.);\n\t\\begin{scriptsize}\n\t\\draw [fill=zzttqq] (16.,12.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.231430048720895,11.611298038991926) node {$S_5$};\n\t\\draw [fill=zzttqq] (12.,8.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.281837382502273,7.460451556023871) node {$S_4$};\n\t\\draw [fill=zzttqq] (6.,4.) circle (1.5pt);\n\t\\draw[color=zzttqq] (6.294556780209077,3.636641462622997) node {$S_3$};\n\t\\draw [fill=zzttqq] (4.,3.) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.256868844134502,2.6052190032188136) node {$S_2$};\n\t\\draw[color=qqqqff] (8.40771463984197,6.1523059977551515) node {$f$};\n\t\\draw [fill=zzttqq] (1.,2.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.3135418253601145,1.775049706625203) node {$S_1$};\n\t\\draw [fill=zzttqq] (16.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.030176919232048,-0.5142050203450577) node {$A_5$};\n\t\\draw [fill=zzttqq] (12.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.055427611827321,-0.48904837499373616) node {$A_4$};\n\t\\draw [fill=zzttqq] (6.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (6.068147009534124,-0.48904837499373616) node {$A_3$};\n\t\\draw [fill=zzttqq] (4.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.005302432273442,-0.5393616656963793) node {$A_2$};\n\t\\draw [fill=zzttqq] (1.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.011662131126844,-0.5393616656963793) node {$A_1$};\n\t\\draw [fill=zzttqq] (10.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (9.992583034566639,-0.5142050203450577) node {$\\bar{A}$};\n\t\\draw [fill=ffqqff] (10.,6.) circle (1.5pt);\n\t\\draw[color=ffqqff] (10.29446272879991,5.422763282566826) node {$\\bar{R}$};\n\t\\draw[color=ffqqqq] (8.307088075097546,4.642907276675858) node {$f_d$};\n\t\\draw[color=ffqqqq] (11.174945170313615,6.655438904781581) node {$f_d$};\n\t\\draw [fill=qqwuqq] (10.00153846153846,6.667692307692308) circle (1.5pt);\n\t\\draw[color=qqwuqq] (9.766173263891687,7.234041747861977) node {$\\bar{S}$};\n\t\\draw[color=black] (10.319619369986015,6.3284025152144014) node {$\\delta_4$};\n\t\\end{scriptsize}\n\t\\end{tikzpicture}\n\t\n\t\\caption[Lower estimate]{Illustration of Lemma \\ref{lmm:asian-lower-estimate} with $ j = 3 $}\n\t\\label{fig:asian-lower-estimate}\n\\end{figure}\n\n\nThe lemmas \\ref{lmm:asian-upper-estimate} and \\ref{lmm:asian-lower-estimate}, will be used later to reduce both the computational complexity and the memory requirement of the algorithm by removing points or edges, effectively simplifying the function.\n\n\n\n\\subsection{Notations and conventions}\n\\label{subsec:asian-notations}\n\nIn this and subsequent sections, we shall use the convention that $ [n] = \\{ 0, 1, 2, \\dots, n \\} $.\n\nLet the number of time steps be $n$. Let $i$ denote the highlighted time step, and $j$ represent the number of up movements. In this way, we may represent any node by $ N_{i,j} $. For example, in Figure \\ref{fig:asian-paths}, the node denoted by $ S_0 u^2 d $ would be represented as $ N_{3,2} $.\n\nThe price of the underlying at each node $ N_{i,j} $ is denoted by $ S_{i,j} $. Since there are $j$ up movements, there must be $ i-j $ down movements, and thus\n\\begin{equation} \\label{eq:asian-am-ij}\n\tS_{i,j} = S_0 u^{j} d^{i-j} = S_0 u^{j} u^{-(i-j)} = S_0 u^{-i+2j} \\qquad \\forall i \\in [n], \\ \\forall j \\in [i]\n\\end{equation}\n\n\n\\begin{prp}\n\tThe number of paths to a node $ N_{i,j} $ is $ \\binom{i}{j} $.\n\\end{prp}\n\n\\begin{proof}\n\tAt each point in a path, we may choose either an up movement or a down movement. To reach node $ N_{i,j} $, we much choose $j$ up movements among $i$ possibilities. The result follows immediately.\n\\end{proof}\n\n\nWe denote the number of singular points in a node $ N_{i,j} $ by $ L_{i,j} $, where $ L_{i,j} \\in \\left[ \\binom{i}{j} \\right] $. The $ l^\\mathrm{th} $ average (in ascending order) ($ l \\in \\{ 1, \\dots, L_{i,j} \\} $) is denoted by $ A_{i,j}^l $, and the corresponding price by $ P_{i,j}^l $. Thus the singular points characterising the price function are $ ( ( A_{i,j}^l, P_{i,j}^l ) )_{l \\in \\{ 1, \\dots, L_{i,j} \\} } $.\n\n\n\\begin{dfn}[singular average and singular price]\n\tIn the particular case of Asian options with arithmetic mean, each $ A_{i,j}^l $ is called a \\emph{singular average} and each $ P_{i,j}^l $ is called a  \\emph{singular price}.\n\\end{dfn}\n\n\nWe recall some basic definitions and derive simple results for the maximum and minimum attainable value of the averages on each node.\n\n\n\\begin{dfn}[Path]\n\tA path is a sequence $(j_i)_{i \\in [n]}$ such that $j_{i+1} \\in \\{ j_i,j_i+1 \\}$.\n\\end{dfn}\n\n\\begin{eg}\n\tIn Figure \\ref{fig:asian-paths}, two paths are shown using red/thicker and blue/thick arrows. The other arrows are in grey/thin. The two paths have the same value at maturity, but give different averages.\n\\end{eg}\n\n\n\\begin{figure}[h]\n\t% Recombining 4-step binomial tree for Cox-Ross-Rubinstein model\n\t\\begin{tikzpicture}\n\t\t\\matrix[column sep=10mm,row sep=1mm] (tree){\n\t\t\t& & & & \\node[term] (u4) {$S_0u^4$}; \\\\\n\t\t\t& & & \\node[nterm] (u3) {$S_0u^3$}; & \\\\\n\t\t\t& & \\node[nterm] (u2) {$\\bm{S_0 u^2}$}; & & \\node[term] (u3d) {$S_0u^3d$}; \\\\\n\t\t\t& \\node[nterm] (u) {$ \\bm{S_0 u} $}; & & \\node[nterm] (u2d) {$\\bm{S_0 u^2 d}$};\\\\\n\t\t\t\\node[term] (s) {$ \\bm{S_0} $}; & & \\node[nterm] (ud) {$ \\bm{S_0 u d} $}; & & \\node[term] (u2d2) {$ \\bm{S_0 u^2 d^2} $ }; \\\\\n\t\t\t& \\node[nterm] (d) {$ \\bm{S_0 d} $}; & &\t\\node[nterm] (ud2) {$\\bm{S_0 u d^2}$};\\\\\n\t\t\t& & \\node[nterm] (d2) {$S_0d^2$}; & & \\node[term] (ud3) {$S_0ud^3$}; \\\\\n\t\t\t& & & \\node[nterm] (d3) {$S_0d^3$}; & \\\\\n\t\t\t& & & & \\node[term] (d4) {$S_0d^4$}; \\\\\n\t\t};\n\t\t% Lines out of s\n\t\t\\draw[->,red,ultra thick] (s) -- (u) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,blue,thick] (s) -- (d) node[midway,below,sloped] {$p_d$};\n\t\t% Lines out of u\n\t\t\\draw[->,red,ultra thick] (u) -- (u2) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,gray] (u) -- (ud) node[midway,above,sloped] {$p_d$};\n\t\t% Lines out of d\n\t\t\\draw[->,blue,thick] (d) -- (ud) node[midway,below,sloped] {$p_u$};\n\t\t\\draw[->,gray] (d) -- (d2) node[midway,below,sloped] {$p_d$};\n\t\t% Lines out of u2\n\t\t\\draw[->,gray] (u2) -- (u3) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,red,ultra thick] (u2) -- (u2d) node[midway,above,sloped] {$p_d$};\n\t\t% Lines out of ud\n\t\t\\draw[->,gray] (ud) -- (u2d) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,blue,thick] (ud) -- (ud2) node[midway,below,sloped] {$p_d$};\n\t\t% Lines out of d2\n\t\t\\draw[->,gray] (d2) -- (ud2) node[midway,below,sloped] {$p_u$};\n\t\t\\draw[->,gray] (d2) -- (d3) node[midway,below,sloped] {$p_d$};\n\t\t% Lines out of u3\n\t\t\\draw[->,gray] (u3) -- (u4) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,gray] (u3) -- (u3d) node[midway,above,sloped] {$p_d$};\n\t\t% Lines out of u2d\n\t\t\\draw[->,gray] (u2d) -- (u3d) node[midway,above,sloped] {$p_u$};\n\t\t\\draw[->,red,ultra thick] (u2d) -- (u2d2) node[midway,above,sloped] {$p_d$};\n\t\t% Lines out of ud2\n\t\t\\draw[->,blue,thick] (ud2) -- (u2d2) node[midway,below,sloped] {$p_u$};\n\t\t\\draw[->,gray] (ud2) -- (ud3) node[midway,below,sloped] {$p_d$};\n\t\t% Lines out of d3\n\t\t\\draw[->,gray] (d3) -- (ud3) node[midway,below,sloped] {$p_u$};\n\t\t\\draw[->,gray] (d3) -- (d4) node[midway,below,sloped] {$p_d$};\n\t\\end{tikzpicture}\n\t\\caption[Path diagram]{Different paths leading to a single destination}\n\t\\label{fig:asian-paths}\n\\end{figure}\n\n\n\\begin{thm}[Path inequality]\n\t\\label{thm:asian-up-dn-path}\n\tLet there be two paths $\\alpha$ and $\\beta$, such that $S_{i,j_i^\\alpha} \\ge S_{i,j_i^\\beta} \\; \\forall i$, where $ ( j_i^\\alpha )_{i \\in [n]} $ and $ ( j_i^\\beta )_{i \\in [n]} $ denote the paths as defined above. Denote the corresponding averages by $A^\\alpha$ and $A^\\beta$, respectively. Then $ A^\\alpha \\ge A^\\beta $.\n\\end{thm}\n\n\\begin{proof}\n\tClearly if $S_{i,j_i^\\alpha} = S_{i,j_i^\\beta} \\; \\forall i$, then $A^\\alpha = A^\\beta$.\n\t\n\tWe only need to show the result in the case of strict inequality at one time.\n\tLet $ S_{i,j_i^\\alpha} = S_{i,j_i^\\beta} \\; \\forall i \\in [n] \\setminus \\{l\\} $, and $ S_{l,j_l^\\alpha} > S_{l,j_l^\\beta}$.\n\t\n\tNow, from equation \\ref{eq:am}, we have:\n\t\\begin{align*}\n\t\t(n+1) A_{n,j}^\\alpha &= \\sum_{i=0}^{l-1} S_{i,j_i} + S_{l,j_l^\\alpha} + \\sum_{i=l+1}^{n} S_{i,j_i} \\\\\n\t\t(n+1) A_{n,j}^\\beta &= \\sum_{i=0}^{l-1} S_{i,j_i} + S_{l,j_l^\\beta} + \\sum_{i=l+1}^{n} S_{i,j_i} \\\\\n\t\t\\implies (n+1) \\left(A_{n,j}^\\alpha - A_{n,j}^\\beta\\right) &= S_{l,j_l^\\alpha} - S_{l,j_l^\\beta} \\\\\n\t\t\t\t\t\t\t\t\t\t\t\t &= S_{l-1,j_{l-1}} u_l - S_{l-1,j_{l-1}} d_l \\\\\n\t\t\t\t\t\t\t\t\t\t\t\t &= S_{l-1,j_{l-1}} (u_l - d_l) > 0 \\qquad (u_l > d_l \\text{ by definition}) \\\\\n\t\t\\implies A_{n,j}^\\alpha > A_{n,j}^\\beta\n\t\\end{align*}\n\t\n\tIterating this procedure, we obtain the general case.\n\\end{proof}\n\n\n\\begin{rem}\n\tThe path $\\alpha$ signifies a path \\emph{above} and $\\beta$ a path \\emph{below} in the usual depiction of the binomial tree (the up movement shown above the down movement). Thus, a path which never goes below another cannot have a lower arithmetic mean than the other.\n\\end{rem}\n\n\n\\begin{crr}\n\t\\label{crr:asian-up-dn-path}\n\tAt each node $ N(i,j) $, the following hold:\n\t\\begin{enumerate}\n\t\\item The minimum average possible $ A_{i,j}^{\\min} $ is attained by the path corresponding to the path corresponding to the path with $(i-j)$ down movements followed by $j$ up movements, and\n\t\t\\begin{equation}\t\\label{eq:asian-Amin}\n\t\t\tA_{i,j}^{\\min} = \\frac{S_0}{i+1} \\left( \\frac{1 - d^{i-j+1}}{1-d} + d^{i-j} u \\frac{1 - u^{j}}{1-u} \\right)\n\t\t\\end{equation}\n\t\\item The maximum average possible $ A_{i,j}^{\\max} $ is attained by the path corresponding to the path with $j$ up movements followed by $(i-j)$ down movements, and\n\t\t\\begin{equation} \\label{eq:asian-Amax}\n\t\t\tA_{i,j}^{\\max} = \\frac{S_0}{i+1} \\left( \\frac{1 - u^{j+1}}{1-u} + u^{j} d \\frac{1 - d^{i-j-1}}{1-d} \\right)\n\t\t\\end{equation}\n\t\\end{enumerate}\n\\end{crr}\n\n\\begin{proof}\n\tWe show the proof only for the case of the maximum, since the case of the minimum can be shown by using the exact same argument.\n\t\n\tFrom Theorem \\ref{thm:asian-up-dn-path}, the result about path with the maximum average holds directly, since there cannot be a path above the one given by $j$ up movements followed by $(i-j)$ down movements.\n\t\n\tThe subsequent formula may be derived as follows.\n\t\\begin{align*}\n\t\t(i+1) A_{i,j}^{\\max} &= \\underbrace{ ( S_0 + S_0 u + S_0 u^2 + \\dots + S_0 u^j ) }_\\text{up movement} + \\underbrace{ ( S_0 u^j d + S_0 u^j d^2 + \\dots + S_0 u^j d^{i-j} ) }_\\text{down movement} \\\\\n\t\t&= S_0 ( (1 + u + u^2 + \\dots + u^j ) + u^j d ( 1 + d + \\dots + d^{i-j-1} ) ) \\\\\n\t\t&= S_0 \\left( \\sum_{k=0}^j u^k + u^j d \\sum_{k=0}^{i-j-1} d^k \\right) \\\\\n\t\t&= S_0 \\left( \\frac{1 - u^{j+1}}{1-u} + u^{j} d \\frac{1 - d^{i-j-1}}{1-d} \\right) \\qquad \\text{(Geometric series)} \\\\\n\t\t\\implies A_{i,j}^{\\max} &= \\frac{S_0}{i+1} \\left( \\frac{1 - u^{j+1}}{1-u} + u^{j} d \\frac{1 - d^{i-j-1}}{1-d} \\right)\n\t\\end{align*}\n\\end{proof}\n\nTable \\ref{tab:asian-notations} summarises the discussion above.\n\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Summary of notations}\n\t\\label{tab:asian-notations}\n%\t\\rowcolors{1}{Burlywood1}{}\n\t\\begin{tabular}{cccl}\n\t\t\\toprule\n\t\tSymbol & Range & Formula & Description \\\\\n\t\t\\midrule\n\t\t$ i $ & $ [ n ] $ & & highlighted time step \\\\\n\t\t$ j $ & $ [ i ] $ & & number of up movements \\\\\n\t\t$ N_{i,j} $ & & & node fixed by $ (i,j) $ \\\\\n\t\t$ S_{i,j} $ & $ [0, \\infty) $ & Eq \\ref{eq:asian-am-ij} & value of the underlying at node $ N_{i,j} $ \\\\\n\t\t$ L_{i,j} $ & $ \\left[ \\binom{i}{j} \\right] $ & & number of singular points in node $ N_{i,j} $ \\\\\n\t\t$ l $ & $ \\{ 1, \\dots, L \\} $ & & index for points in ascending order of averages \\\\\n\t\t$ A_{i,j}^{\\min} $ & $ [0, \\infty) $ & Eq \\ref{eq:asian-Amin} & minimum average attainable for node $ N_{i,j} $ \\\\\n\t\t$ A_{i,j}^{\\max} $ & $ [0, \\infty) $ & Eq \\ref{eq:asian-Amax} & maximum average attainable for node $ N_{i,j} $ \\\\\n\t\t$ A_{i,j}^l $ & $ \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $ & Eq \\ref{eq:am} & $ l^\\mathrm{th} $ singular average of node $ N_{i,j} $ \\\\\n\t\t$ P_{i,j}^l $ & & & price corresponding to the average $ A_{i,j}^l $ \\\\\n\t\t$ (A_{i,j}^l, P_{i,j}^l) $ & & & $ l^\\mathrm{th} $ singular point of node $ N_{i,j} $ \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\n\n\\section{Fixed-strike Asian options of the European type}\n\\label{sec:fixed-strike-eu}\n\nWe start with the simplest case. For this type of option, the pay-off at maturity is dependent only on (some type of) average $ A_T $ at maturity $ T $ and a fixed constant $ K $, and is given by the following function.\n\\begin{equation}\n\t\\label{eq:asian-price-eu-asian-am}\n\tP_T = (A_T - K)_+\n\\end{equation}\n\nIn each node of the binomial tree, we have a set of possible averages depending on the paths which may be taken to arrive at the node, and prices corresponding to each of those averages. We shall show that these points satisfy condition \\ref{eq:asian-conditions}, so the price function is piecewise-linear, convex and continuous, and is completely characterised by these points. In essence, we consider not only averages that are effectively achievable but all the possible averages between the minimum and maximum realized at that point. This gives us the continuous representation of prices. The intuitive idea is that as the time step is reduced to zero, this function converges to the price function of the continuous time model.\n\nWe start with the prices at maturity, and proceed using backward iteration. The exact details are explained below.\n\n\n\\subsubsection*{At maturity ($ i = n $)}\n\nFrom equations \\ref{eq:asian-Amin} and \\ref{eq:asian-Amax}, putting $i = n$, we get\n\\begin{align*}\n\tA_{n,j}^{\\min} &= \\frac{S_0}{n+1} \\left( \\frac{1 - d^{n-j+1}}{1-d} + d^{n-j} u \\frac{1 - u^{j}}{1-u} \\right) \\\\\n\tA_{n,j}^{\\max} &= \\frac{S_0}{n+1} \\left( \\frac{1 - u^{j+1}}{1-u} + u^{j} d \\frac{1 - d^{n-j-1}}{1-d} \\right)\n\\end{align*}\n\nIn defining the price function, we note that three cases may arise.\n\\begin{itemize}\n\\item $ j \\in \\{ 0, n \\} $ \\\\\n\tIn this case, there can be only one path to these nodes, so there is only one average, implying one price and one singular point.\n\t\n\\item $ j \\notin \\{ 0, n \\} $ and $ K \\in ( A_{n,j}^{\\min}, A_{n,j}^{\\max} ) $ \\\\\t\n\tIn this case, the price function is characterised by three singular points ($ L_{i,j} = 3 $), $ ( A_{n,j}^l , P_{n,j}^l )_{l \\in \\{ 1, 2, 3 \\} } $, since we need to compare the averages with the fixed strike price $ K $. The points are as follows.  \\\\\n\t\\begin{equation}\n\t\t\\label{eq:asian-price-maturity-kin}\n\t\t\\begin{aligned}\n\t\t\t( A_{n,j}^1 , P_{n,j}^1 ) &= ( A_{n,j}^{\\min} , 0 ) \\\\\n\t\t\t( A_{n,j}^2 , P_{n,j}^2 ) &= ( K , 0 ) \\\\\n\t\t\t( A_{n,j}^3 , P_{n,j}^3 ) &= ( A_{n,j}^{\\max} , A_{n,j}^{\\max} - K ) \\\\\n\t\t\\end{aligned}\n\t\\end{equation} \\label{eq:asian-price-maturity-kout}\n\t\n\\item $ j \\notin \\{ 0, n \\} $ and $ K \\notin ( A_{n,j}^{\\min}, A_{n,j}^{\\max} ) $ \\\\\n\tIn this case, the price function is characterised by only two singular points ($ L_{i,j} = 2 $), $ ( A_{n,j}^l , P_{n,j}^l )_{l \\in \\{ 1, 2 \\} } $, which are as follows. \\\\\n\t\\begin{equation}\n\t\t\\label{eq:asian-price-maturity-knotin}\n\t\t\\begin{aligned}\n\t\t\t( A_{n,j}^1 , P_{n,j}^1 ) &= ( A_{n,j}^{\\min} , ( A_{n,j}^{\\min} - K )_+ ) \\\\\n\t\t\t( A_{n,j}^2 , P_{n,j}^2 ) &= ( A_{n,j}^{\\max} , ( A_{n,j}^{\\max} - K )_+ ) \\\\\n\t\t\\end{aligned}\n\t\\end{equation}\n\\end{itemize}\n\n\\begin{lmm}[Price function at maturity ($ i < n $)]\n\t\\label{lmm:asian-pr-maturity}\n\tAt each node at maturity, the price function $ { v_{n,j}: \\left[ A_{n,j}^{\\min}, A_{n,j}^{\\max} \\right] \\to \\left[ ( A_{n,j}^{\\min} - K )_+ , ( A_{n,j}^{\\max} - K )_+ \\right] } $ defined as $ v_{n,j}(A) = (A - K)_+ $ is continuous, piecewise-linear and convex.\n\\end{lmm}\n\\begin{proof}\n\tThe singular points satisfy the conditions \\ref{eq:asian-conditions}. So for each $ A \\in \\left[ A_{n,j}^{\\min}, A_{n,j}^{\\max} \\right] $, the price function ${ v_{n,j}(A) }$ characterised by the singular points is continuous, piecewise-linear and convex by remark \\ref{rem:asian-char}.\n\\end{proof}\n\n\n\n\\subsubsection*{Before maturity ($ i < n $)}\n\n\\begin{lmm}[Price function at any node]\n\t\\label{lmm:asian-dsc-expt}\n\tAt any node $ N_{i,j} $, the price function $ v_{i,j}: \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] \\to [0, \\infty) $ is continuous, piecewise-linear and convex.\n\\end{lmm}\n\n\\begin{proof}\n\tWe shall prove this using backward induction, the base case at maturity being true by virtue of Lemma \\ref{lmm:asian-pr-maturity}.\n\tWe now consider step $ i = n-1 $. Let $A_u$ and $A_d$ respectively represent the averages after an up and down movement corresponding to an average $A$. From equation \\ref{eq:am}, we get\n\t\\begin{subequations}\n\t\t\\label{eq:asian-av-up-dn}\n\t\t\\begin{align}\n\t\t\tA_u &= \\frac{ (i+1) A + S_0 u^{-i+2j+1} }{ i+2 } \\\\\n\t\t\tA_d &= \\frac{ (i+1) A + S_0 u^{-i+2j-1} }{ i+2 }\n\t\t\\end{align}\n\t\\end{subequations}\n\tSince the options is of the European type, applying the no-arbitrage condition, the price function $ v_{i,j}: \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] \\to [0, \\infty) $ is obtained by considering the discounted expectation value.\n\t\\begin{equation}\n\t\t\\label{eq:asian-dsc-expt}\n\t\tv_{i,j}(A) = \\frac{1}{R} \\left[ p v_{i+1,j+1}(A_u) + (1 - p) v_{i+1,j}(A_d) \\right]\n\t\\end{equation}\n\tFrom equation \\ref{eq:asian-av-up-dn}, we get that $A_u$ and $A_d$ are linear functions of $A$. Thus, $ v_{i+1,j+1}(A_u) = v_{n,j+1}(A_u)$ and $ v_{i+1,j}(A_d) = v_{n,j}(A_d) $ are piecewise-linear convex continuous functions of $A_u$ and $A_d$ respectively. Thus, $ v_{i+1,j+1} $ and $ v_{i+1,j} $ may be seen as a linear combination of the above functions, and is thus piecewise-linear, convex and continuous itself. Again, from equation \\ref{eq:asian-dsc-expt}, we get that $v_{i,j}$ is a convex combination of such functions, and the proof is complete.\n\t\n\tWe showed that if at time $ i+1 $, if the price function is continuous, piecewise-linear and convex, so is it for time $ i $. Since this is true for $ i+1 = n $, the same logic applied iteratively proves that the functions retain the characteristics for all $ i \\in [n] $.\n\\end{proof}\n\n\n\\begin{rem}\n\tFrom Lemma \\ref{lmm:asian-dsc-expt}, we see that the price function may be characterised by singular points.\n\\end{rem}\n\n\n\n\\subsection{Evaluation of singular points}\n\\label{subsec:asian-eu-eval}\n\nThe evaluation of singular points for any node $ N_{i,j} $ is done by the following algorithm, which works in a backward fashion in time, starting from the maturity.\n\nWe note that for the only influencing nodes for the node $ N_{i,j} $ are $ N_{i+1,j+1} $ and $ N_{i+1,j} $. Thus we need to calculate the price of the option for each singular average belonging to either of these nodes.\n\n\n\\paragraph{Up movement}\n\nFirst we take each singular average $ A_{i+1,j}^l $ belonging to $ N_{i+1,j} $ and project it to $ N_{i,j} $ via the following relation.\n\\begin{equation}\n\t\\label{eq:asian-proj-up}\n\tB^l = \\frac{ ( i+2) A_{i+1,j}^l - S_0 u^{-i+2j-1} }{ i+1 }\n\\end{equation}\nThus, $ B^l $ is that average which after a down movement of the asset gives us the average $ A_{i+1,j}^l $.\n\nNext, we note that $ B^l $ is an increasing function of $ l $, since a higher average at time step $ i $ would yield a higher average at time $ i+1 $. This in turn implies the following:\n\\begin{itemize}\n\\item $ B^{L_{i+1,j}} = A_{i+i,j}^{\\max} \\; \\forall j $\n\\item $ B^1 \\notin \\left[ A_{i+i,j}^{\\min}, A_{i+i,j}^{\\max} \\right] \\ \\forall j \\in \\{1, \\dots, i-1 \\} $\n\\end{itemize}\nEach $ B^l \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $ becomes the singular average of $ N_{i,j} $.\n\nIn this way, we have determined the first coordinate of the singular points. We need to determine the second coordinate, or the prices $ v_{i,j}(B^l) $, $ \\forall B^l \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $, in order to determine the singular points completely. The idea is to calculate the discounted expected value of the price corresponding to each average $ B^l $ at $ N_{i,j} $. In order to be able to do this, we need the prices corresponding to the average projected to the node $ N_{i+1,j+1} $.\n\nWe consider an up movement of the underlying asset from node $ N_{i,j} $. In this case, $ B^l $ transforms into the average $ B^l_u = \\left( (i+1) B^l + S_0 u^{-i+2j+1} \\right) / ( i+2 ) $. Clearly, this average cannot belong to the set of averages associated with the node $ N_{i+1,j+1} $. Thus, we need to find the index $s$ such that $ B^l_u \\in \\left[ A_{i+1,j+1}^{s} , A_{i+1,j+1}^{s+1} \\right] $. In the intervals the price function is linear, and thus we have\n\\begin{equation}\n\t\\label{eq:asian-up-lint}\n\tv_{i+1,j+1} \\left( B^l_u \\right) = \\frac{ P_{i+1,j+1}^{s+1} - P_{i+1,j+1}^{s} }{ A_{i+1,j+1}^{s+1} - A_{i+1,j+1}^{s} } \\left( B^l_u - A_{i+1,j+1}^{s} \\right) + P_{i+1,j+1}^{s} .\n\\end{equation}\n\nWe follow this up by calculating the price associated with the singular value $ B^l $ by evaluating the discounted expectation value.\n\\begin{equation}\n\t\\label{eq:asian-up-pr}\n\tv_{i,j}( B^l ) = \\frac{1}{R} \\left[ p v_{i+1,j+1} \\left( B^l_u \\right) + (1 - p) v_{i+1,j} \\left( A_{i+1,j}^l \\right) \\right] .\n\\end{equation}\n\nFigure \\ref{fig:asian-2tr-up} depicts the idea.\n\\begin{figure}[h]\n\t\\begin{tikzpicture}\n\t\\matrix (tree) [column sep=25mm, row sep=1mm]{\n\t\t\\node[header] (t0) {$ t = i $};  &  \\node[header] (t1) {$ t = i+1 $}; \\\\\n\t\t&  \\node[term] (u) {$ B^l_u $}; \\\\\n\t\t\\node[term] (s) {$ B^l $};  &  \\\\\n\t\t&  \\node[term] (d) {$ A_{i+1,j}^l $}; \\\\\n\t};\n\t\\draw[->] (s) -- (u) node[midway,above,sloped] {Step 2};\n\t\\draw[->] (d) -- (s) node[midway,below,sloped] {Step 1};\n\t\\end{tikzpicture}\n\t\n\t\\caption{Up movement}\n\t\\label{fig:asian-2tr-up}\n\\end{figure}\n\n\n\n\\paragraph{Down movement}\n\nWe now proceed to formulate the theory for the downward movement in the exact same fashion. Define the new average $ C^l $ at the node $ N_{i,j} $ via the relation\n\\begin{equation}\n\t\\label{eq:asian-proj-dn}\n\tC^l = \\frac{ ( i+2) A_{i+1,j+1}^l - S_0 u^{-i+2j+1} }{ i+1 }\n\\end{equation}\n\nAgain, we note that\n\\begin{itemize}\n\\item $ C^1 = A_{i,j}^{\\min} \\ \\forall j $\n\\item $ C^{L_{i+1,j+1}} \\notin \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] \\ \\forall j \\in \\{1, \\dots, i-1 \\} $\n\\item $ C^l_d = \\left( (i+1) C^l + S_0 u^{-i+2j-1} \\right) / ( i+2 ) $\n\\end{itemize}\nEach $ C^l \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $ becomes the singular average of $ N_{i,j} $.\n\nFor $ v_{i,j}( C^l ) $, $ \\forall C^l \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $, we now have the following.\n\\begin{equation}\n\t\\label{eq:asian-dn-lint}\n\tv_{i+1,j+1} \\left( C^l_d \\right) = \\frac{ P_{i+1,j}^{s+1} - P_{i+1,j}^{s} }{ A_{i+1,j}^{s+1} - A_{i+1,j}^{s} } \\left( C^l_d - A_{i+1,j}^{s} \\right) + P_{i+1,j}^{s}\n\\end{equation}\n\n\\begin{equation}\n\t\\label{eq:asian-dn-pr}\n\tv_{i,j}( C^l ) = \\frac{1}{R} \\left[ p v_{i+1,j+1} \\left( A_{i+1,j+1}^l \\right) + (1 - p) v_{i+1,j} \\left( C^l_d \\right) \\right]\n\\end{equation}\n\nFigure \\ref{fig:asian-2tr-dn} depicts the idea.\n\\begin{figure}[h]\n\t\\begin{tikzpicture}\n\t\\matrix (tree) [column sep=25mm, row sep=1mm]{\n\t\t\\node[header] (t0) {$ t = i $};  &  \\node[header] (t1) {$ t = i+1 $}; \\\\\n\t\t&  \\node[term] (u) {$ A_{i+1,j+1}^l $}; \\\\\n\t\t\\node[term] (s) {$ C^l $};  &  \\\\\n\t\t&  \\node[term] (d) {$ C^l_d $}; \\\\\n\t};\n\t\\draw[->] (u) -- (s) node[midway,above,sloped] {Step 1};\n\t\\draw[->] (s) -- (d) node[midway,below,sloped] {Step 2};\n\t\\end{tikzpicture}\n\t\n\t\\caption{Down movement}\n\t\\label{fig:asian-2tr-dn}\n\\end{figure}\n\n\n\\paragraph{Aggregation}\n\nNow we have the singular points for both up and down movements. We sort these points in ascending order of the first coordinate, i.e. the averages $ B^l $ and $ C^l $ that belong to $ \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] $. These is an exhaustive list of all the singular points in the node (by construction). We note that $ L_{i,j} \\le L_{i+1,j} + L_{i+1,j+1} - 2 $.\n\nThis procedure is applied to all nodes, starting from maturity and proceeding backwards. At the `edge' nodes $ N_{i,0} $ and $ N_{i,i} $, there is only one singular point whose price is given as follows\n\\begin{subequations}\n\t\\label{eq:asian-terminal-nodes}\n\t\\begin{align}\n\t\tP_{i,0}^1 &= \\frac{1}{R} \\left[ p P_{i+1,0}^1 + (1 - p) P_{i+1,1}^1 \\right] \\\\\n\t\tP_{i,i}^1 &= \\frac{1}{R} \\left[ p P_{i+1,i+1}^1 + (1 - p) P_{i+1,i}^{L_{i+1,i}} \\right]\n\t\\end{align}\n\\end{subequations}\n\nThus we have a complete description of the price function at each node of the binomial tree. The price $ P_{0,0}^1 $ is exactly the binomial price relative to the tree with $n$ steps of a fixed-strike European call option.\n\n\n\\section{Fixed-strike Asian options of the American type}\n\\label{sec:fixed-strike-am}\n\nWe now consider the American case. At maturity we have the same situation as in the European case. The price function is $ v_{n,j} (A) = (A - K)_+ $ for $ A \\in [ A_{n,j}^{\\min}, A_{n,j}^{\\max} ] $, and it is characterized by the same singular points.\n\nConsider the step $ i = n - 1 $. At the node $ N_{i,j} $, we first compute, by using the procedure described in the previous section (European case), the singular points associated with this node, thus obtaining the continuation value function $ v_{n,j}^c (A) $ (note that this is nothing but $ v_{n,j} (A) $ in the European case). But now, we must also account for exercise rights at this time. Thus, we have\n\\begin{equation}\n\tv_{n,j} (A)  =  \\max \\{ \\underbrace{A - K}_{\\text{exercise}}, \\underbrace{v_{n,j}^c (A)}_{\\text{hold}} \\} .\n\\end{equation}\n\nNote that $ v_{i,j} (A) $ is still a piecewise-linear convex function, since maximum is a convex function, and the composition of two convex function is convex. For this reason, we can again characterize it by its singular points. In order to compute the singular points associated with the American case, we first remark that the slopes characterizing the piecewise-linear convex function $ v_{i,j}^c (A) $ are all smaller than 1.\n\n\n\\begin{prp}[boundedness of slope]\n\tThe slopes characterizing the piecewise-linear convex function $ v_{i,j}^c (A) $ are all smaller than $ 1, \\  \\forall A \\in \\left(  A_{i,j}^{l}, A_{i,j}^{l+1}  \\right)  \\  \\forall l \\in \\{ 1, 2, \\dots, L_{i,j} \\} $.\n\\end{prp}\n\nOf course, at the singular points, due to piecewise linearity, the function is not differentiable and thus admits no slope.\n\n\\begin{proof}\n\tFirst, note that differentiating Equations \\ref{eq:asian-av-up-dn} with respect to $ A $, we get\n\t\\begin{equation*}\n\t\t\\od{A_u}{A} = \\od{A_d}{A} = \\frac{i+1}{1+2} < 1 .\n\t\\end{equation*}\n\t\n\tNow, we differentiate $ v_{i,j}^c $ with respect to $ A $ in Equation \\ref{eq:asian-dsc-expt} to get\n\t\\begin{align*}\n\t\t\\od{v_{i,j}^c}{A}  &=  \\frac{1}{R} \\left(  p \\od{v_{i+1,j+1}}{A} + (1 - p) \\od{v_{i+1,j}}{A}  \\right)  \\\\\n\t\t&=  \\frac{1}{R} \\left(  p \\od{v_{i+1,j+1}}{A_u} \\od{A_u}{A} + (1 - p) \\od{v_{i+1,j}}{A_d} \\od{A_d}{A}  \\right)  \\\\\n\t\t&= \\frac{1}{R} \\frac{i+1}{1+2} \\left(  p \\od{v_{i+1,j+1}}{A_u} + (1 - p) \\od{v_{i+1,j}}{A_d}  \\right)\n\t\\end{align*}\n\t\n\tNow, let $ i = n - 1 $. Then $ v_{i+1, \\cdot} = v_{n, \\cdot} $. Clearly, from Section \\ref{sec:fixed-strike-eu} (the price function at maturity), in each of the three cases, the price function can have a slope of either 0 or 1. In the above equation, considering $ r > 0 $, we have $ R > 1 $, and consequently, $ R^{-1} < 1 $. Also, $ p, 1-p \\in [0,1] $. Putting all the inequalities in the last expression of $ \\od{v_{i,j}^c}{A} $, we obtain $ \\od{v_{n-1,j}^c}{A} < 1 $.\n\t\n\tClearly, the slope in any previous time $ i < n - 1 $ can never be equal to unity by the exact same logic. The proof is complete by backward induction.\n\\end{proof}\n\n\nHence there are two possible cases, as follows.\n\n\\begin{enumerate}\n\t\\item $ A_{i,j}^{\\max} - K  \\le  v_{i,j}^c ( A_{i,j}^{\\max} ) $. This implies that $ v_{i,j} \\equiv v_{i,j}^c $. The singular points remain the same.\n\t\\item $ A_{i,j}^{\\max} - K  <  v_{i,j}^c ( A_{i,j}^{\\max} ) $. This case has two subcases, as follows.\n\t\\begin{enumerate}\n\t\t\\item $ A_{i,j}^{\\min} - K  \\ge  v_{i,j}^c ( A_{i,j}^{\\min} ) $. This implies that $ v_{i,j} (A) = (A - K), \\  \\forall A \\in [ A_{i,j}^{\\min}, A_{i,j}^{\\max} ] $, so the only singular points points are $ \\left(  A_{i,j}^{\\min}, A_{i,j}^{\\min} - K  \\right) $ and $ \\left(  A_{i,j}^{\\max}, A_{i,j}^{\\max} - K  \\right) $.\n\t\t\\item $ A_{i,j}^{\\min} - K  <  v_{i,j}^c ( A_{i,j}^{\\min} ) $. This means that there is a unique average $ \\bar{A} $ at which point the continuation value equals the early exercise. Let $ j_0 $ be the largest index such that $ A_{i,j}^{j_0} < \\bar{A} $. The new set of singular points becomes (see Figure \\ref{fig:asian-american-estimate} for a graphical representation)\n\t\t\\begin{equation*}\n\t\t\t\\left\\lbrace  \\left( A_{i,j}^{1}, P_{i,j}^{1} \\right), \\left( A_{i,j}^{j_0}, P_{i,j}^{j_0} \\right), \\left( \\bar{A}, \\bar{A} - K \\right), \\left( A_{i,j}^{\\max}, A_{i,j}^{\\max} - K \\right)  \\right\\rbrace\n\t\t\\end{equation*}\n\t\\end{enumerate}\n\\end{enumerate}\n\nWe can repeat the same procedure iteratively for $ i = n-2, \\dots, 0 $. At the final step, we get only one singular point, which gives us $ P_{0,0}^1 $, the exact American binomial price relative to the tree with $ n $ steps.\n\n\\begin{figure}[h]\n\t\\centering\n\t\n\t\\definecolor{aqaqaq}{rgb}{0.6274509803921569,0.6274509803921569,0.6274509803921569}\n\t\\definecolor{ffqqqq}{rgb}{1.,0.,0.}\n\t\\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}\n\t\\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}\n\t\\definecolor{qqqqff}{rgb}{0.,0.,1.}\n\t\\definecolor{zzttqq}{rgb}{0.6,0.2,0.}\n\t\\definecolor{eqeqeq}{rgb}{0.8784313725490196,0.8784313725490196,0.8784313725490196}\n\t\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.7cm,y=0.7cm]\n\t\\draw [color=eqeqeq,dotted, xstep=1.4cm,ystep=1.4cm] (-0.5,-0.5) grid (17.,14.5);\n\t\\draw[->,color=black] (0.,0.) -- (17.,0.);\n\t\\foreach \\x in {,2.,4.,6.,8.,10.,12.,14.,16.}\n\t\\draw[shift={(\\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);\n\t\\draw[color=black] (16.810032796001327,0.10062658140528617) node [anchor=south west] { A};\n\t\\draw[->,color=black] (0.,0.) -- (0.,14.5);\n\t\\foreach \\y in {,2.,4.,6.,8.,10.,12.,14.}\n\t\\draw[shift={(0,\\y)},color=black] (2pt,0pt) -- (-2pt,0pt);\n\t\\draw[color=black] (0.1257832059305293,14.101805928772759) node [anchor=west] { P};\n\t\\clip(-0.5,-0.5) rectangle (17.,14.5);\n\t\\draw [line width=1.2pt,color=qqqqff] (6.,4.)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (16.,12.)-- (12.,8.);\n\t\\draw [line width=1.2pt,color=qqqqff] (6.,4.)-- (4.,3.);\n\t\\draw [line width=1.2pt,color=qqqqff] (4.,3.)-- (1.,2.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (12.,8.)-- (12.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (6.,4.)-- (6.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (4.,3.)-- (4.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (1.,2.)-- (1.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (16.,12.)-- (16.,0.);\n\t\\draw [line width=1.6pt,dash pattern=on 1pt off 2pt on 4pt off 4pt,color=ffqqqq] (8.003076923076923,5.335384615384616)-- (16.,13.33);\n\t\\draw [dash pattern=on 1pt off 2pt on 4pt off 4pt,color=ffqqqq] (2.66,0.)-- (8.003076923076923,5.335384615384616);\n\t\\draw [color=aqaqaq] (8.003076923076923,5.335384615384616)-- (8.,0.);\n\t\\draw [color=aqaqaq] (8.003076923076923,5.335384615384616)-- (0.,5.34);\n\t\\begin{scriptsize}\n\t\\draw [fill=zzttqq] (16.,12.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.23143004872089,11.611298038991926) node {$S_5$};\n\t\\draw [fill=zzttqq] (12.,8.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.281837382502271,7.460451556023871) node {$S_4$};\n\t\\draw [fill=zzttqq] (6.,4.) circle (1.5pt);\n\t\\draw[color=zzttqq] (6.294556780209076,3.636641462622997) node {$S_3$};\n\t\\draw [fill=zzttqq] (4.,3.) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.256868844134502,2.6052190032188136) node {$S_2$};\n\t\\draw[color=qqqqff] (9.891956469822214,6.252932579160437) node {$f$};\n\t\\draw [fill=zzttqq] (1.,2.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.3135418253601157,1.775049706625203) node {$S_1$};\n\t\\draw [fill=zzttqq] (16.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (16.206273407534784,-0.3381085028858069) node {$A_5$};\n\t\\draw [fill=zzttqq] (12.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (12.23152410013006,-0.31295185753448534) node {$A_4$};\n\t\\draw [fill=zzttqq] (6.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (6.219086856650759,-0.3381085028858069) node {$A_3$};\n\t\\draw [fill=zzttqq] (4.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (4.105928997017866,-0.3381085028858069) node {$A_2$};\n\t\\draw [fill=zzttqq] (1.,0.) circle (1.5pt);\n\t\\draw[color=zzttqq] (1.087132054685163,-0.3381085028858069) node {$A_1$};\n\t\\draw [fill=xdxdff] (8.003076923076923,5.335384615384616) circle (1.5pt);\n\t\\draw[color=xdxdff] (7.678172045444898,5.850426253539292) node {$S_{34}$};\n\t\\draw [fill=qqqqff] (16.,13.33) circle (1.5pt);\n\t\\draw[color=qqqqff] (16.306899972279208,13.749612893854257) node {$S_5'$};\n\t\\draw[color=ffqqqq] (11.829017841152366,10.177369253966598) node {$f_{bar}$};\n\t\\draw [fill=qqqqff] (2.66,0.) circle (1.5pt);\n\t\\draw[color=qqqqff] (2.6216871670376203,-0.3129518575344853) node {$K$};\n\t\\draw [fill=qqqqff] (8.,0.) circle (1.5pt);\n\t\\draw[color=qqqqff] (8.28193143391144,-0.31295185753448534) node {$\\bar{A}$};\n\t\\draw [fill=xdxdff] (0.,5.34) circle (1.5pt);\n\t\\draw[color=xdxdff] (0.030553124868716808,5.020256956945682) node {$\\bar{P}$};\n\t\\end{scriptsize}\n\t\\end{tikzpicture}\n\t\n\t\\caption[Estimate in the American case]{American case: $ \\bar{A} $ inserted, $ A_4 $ removed}\n\t\\label{fig:asian-american-estimate}\n\\end{figure}\n\n\\begin{rem}[computational complexity -- European vs. American]\n\tIf we use approximations (as explained in the next section), the number of singular points in the American case can never be greater than the European case (even though right now we cannot determine the theoretical complexity of even the European case). Thus, the American procedure cannot be slower than the European one. In case we also take approximations into account, the American case is expected to be faster heuristically, but cannot be proved in general. Figure \\ref{fig:asian-american-estimate} illustrates this. $ A_{\\text{bar}} $ is inserted, and all points except for the last, is removed. Thus, if the number of points after $ A_{\\text{bar}} $ is huge, this would remove all those points. This is not possible in the European case.\n\\end{rem}\n\n\\begin{rem}[put]\n\tFor an Asian put, the exact same procedure has to be followed.\n\\end{rem}\n\n\\begin{rem}[floating]\n\tIn this case, we modify the procedure as follows: at maturity the singular points depend not on the strike $ K $ but rather on the underlying value at each node $ S_{i,j} $. Therefore the new singular points are obtained by replacing $ K $ by $ S_{i,j} $. The backward procedure is the same as before, just properly taking into account the new intrinsic values.\n\\end{rem}\n\n\\begin{rem}[lookback options]\n\tLookback options can also be similarly priced. In fact, in this case the algorithm admits several simplifications. We shall not study lookback options in this thesis. The interested reader should refer to \\cite[Section 4]{Gaudenzi2010}.\n\\end{rem}\n\n\n\\section{Approximation}\n\\label{sec:asian-approx}\nThe above sections introduced the singular points method, a procedure to evaluate the exact binomial price of an Asian option. Since for any node $ N_{i,j} $, we have that $ L_{i,j} \\le L_{i+1,j} + L_{i+1,j+1} - 2 $, the resulting algorithm has exponential complexity, same as that of the binomial method.\n\nWhere this method shines, though, is its ability to use approximations to drastically reduce the order of complexity from exponential to polynomial time. The singular points method can be used to obtain upper and lower bounds of the binomial price at a fraction of the computational cost. Moreover, we can specify \\emph{a priori} bounds on the error. We shall see that these are just simple consequences of Lemmas \\ref{lmm:asian-upper-estimate} and \\ref{lmm:asian-lower-estimate}.\n\n\\subsection{Upper bound}\n\\label{subsec:asian-ub}\nIn order to obtain an upper bound, we remove selected points from each node. That this is a upper estimate of the exact binomial price is guaranteed by Lemma \\ref{lmm:asian-upper-estimate}.\n\nRemoval of points may be done on the basis of various criteria. One such method is as follows.\n\nConsider the set of singular points $ C $ associated with the node $ N_{i,j} $ and the corresponding price value function $ v_{i,j} (A) $. Let $ v_{i,j}^u (A) $ be the price value function obtained by removing a point $ \\left( A_{i,j}^{l}, P_{i,j}^{l} \\right) $ from $ C $. We have\n\\begin{equation}\n\tv_{i,j}^u (A) - v_{i,j} (A)  \\le  \\epsilon_l  \\qquad  \\forall A \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right],\n\\end{equation}\nwhere\n\\begin{equation}\n\t\\epsilon_l  =  v_{i,j}^u \\left( A_{i,j}^{l} \\right) - v_{i,j} \\left( A_{i,j}^{l} \\right)  =  \\frac{ P_{i,j}^{l+1} - P_{i,j}^{l-1} }{ A_{i,j}^{l+1} - A_{i,j}^{l-1} } \\left( A_{i,j}^{l} - A_{i,j}^{l-1} \\right) + \\left( P_{i,j}^{l-1} - P_{i,j}^{l} \\right) .\n\\end{equation}\n\nTherefore, given any tolerance $ h > 0 $, we may remove a point $ \\left( A_{i,j}^{l}, P_{i,j}^{l} \\right) $ only if $ \\epsilon_l < h $. Repeating this procedure sequentially at each node of the tree, while avoiding the elimination of two consecutive singular points, we can conclude that the upper estimate thus obtained differs from the exact binomial value by at most $ n h $.\n\n\n\\subsection{Lower bound}\n\\label{subsec:asian-lb}\nThe computational procedure is quite similar to the procedure of approximation using upper bounds. The theoretical foundation of this part is given by Lemma \\ref{lmm:asian-lower-estimate}. If we remove the points $ \\left( A_{i,j}^{l-1}, P_{i,j}^{l-1} \\right) $ and $ \\left( A_{i,j}^{l}, P_{i,j}^{l} \\right) $, and add the point $ (\\bar{x}, \\bar{y} ) $ as described in Lemma \\ref{lmm:asian-lower-estimate}, the new function is never greater than the original one, and the differences between the values at any point is bounded over by $ \\delta_l $, that is\n\\begin{equation}\n\tv_{i,j} (A) - v_{i,j}^d (A)  \\le  \\delta_l  \\qquad  \\forall A \\in \\left[ A_{i,j}^{\\min}, A_{i,j}^{\\max} \\right] ,\n\\end{equation}\nwhere\n\\begin{equation}\n\t\\delta_l  =  v_{i,j} (A) - v_{i,j}^d (A)  =  \\frac{ P_{i,j}^{l} - P_{i,j}^{l-1} }{ A_{i,j}^{l} - A_{i,j}^{l-1} } \\left( \\bar{x} - A_{i,j}^{l-1} \\right) + \\left( P_{i,j}^{l-1} - \\bar{y} \\right) .\n\\end{equation}\n\nAgain, we allow for the operation only if $ \\delta_l < h $.\n\nAn implementation methodology is as follows. At each node $ N_{ij} $, we consider the starting four points $ \\left( A_{i,j}^1, P_{i,j}^1 \\right) $, $ \\left( A_{i,j}^2, P_{i,j}^2 \\right) $, $ \\left( A_{i,j}^3, P_{i,j}^3 \\right) $, $ \\left( A_{i,j}^4, P_{i,j}^4 \\right) $. Calculate $ \\delta_3 $. If $ \\delta_3 < h $, we add the point $ (\\bar{x}, \\bar{y}) $ and remove the points corresponding to $ \\left( A_{i,j}^2, P_{i,j}^2 \\right) $ and $ \\left( A_{i,j}^3, P_{i,j}^3 \\right) $. The procedure will continue by considering the four new points $ (\\bar{x}, \\bar{y}) $, $ \\left( A_{i,j}^4, P_{i,j}^4 \\right) $, $ \\left( A_{i,j}^5, P_{i,j}^5 \\right) $, $ \\left( A_{i,j}^6, P_{i,j}^6 \\right) $ and proceeding in the exact same way. On the other hand, if $ \\delta_3 \\ge h $, then we do not remove any points and the procedure will continue by considering the four new points $ \\left( A_{i,j}^2, P_{i,j}^2 \\right) $, $ \\left( A_{i,j}^3, P_{i,j}^3 \\right) $, $ \\left( A_{i,j}^4, P_{i,j}^4 \\right) $, $ \\left( A_{i,j}^5, P_{i,j}^5 \\right) $. The procedure is repeated until all the singular points of the node has been taken into account.\n\n\\begin{rem}[Convergence]\n\tWe know that Jiang and Dai (2005) \\cite{Jiang2004} proved the convergence of the exact binomial algorithm for European/American path-dependent options to the Black-Scholes prices, with rate of convergence of $ O( \\Delta T ) $. The possibility of obtaining estimates of the exact binomial price with an error control allows us to prove easily the convergence of our method to the continuous value. By choosing $ h $ to depend on $ n $ so that $ n h(n) \\to 0 $, we have that the corresponding sequences of upper and lower estimates converge to the continuous price value. Moreover, the choice $ h(n) = O(\\frac{1}{n^2}) $ guarantees that the order of convergence is $ O( \\Delta T ) $.\n\\end{rem}\n\n\\begin{rem}[Computational complexity -- theoretical considerations]\n\tThe key issue in assessing the theoretical complexity of the algorithm lies in the upper and lower bound computation. Since the number of singular points eliminated depends on various factors, and we do not control the number of singular points directly, it is difficult to theoretically calculate the order of complexity of the algorithm. The dependence of number of singular points and their nature (closeness, convexity) on the initial data might be a fruitful area of research, and this in turn might give us clues as to how the problem of finding complexity theoretically might be tackled. Nevertheless, the numerical results indicate that the method is quite competitive in practice.\n\\end{rem}\n\n\n\n\\clearpage\n\\section{The program}\n\\label{sec:asian-program}\n\n\\subsection{Algorithm}\n\n\\begin{algorithm}[H]\n\t\\DontPrintSemicolon\n\t\n\t\\KwIn{\\\\\n\t\t\\qquad \\emph{Contract details}  \\\\\n\t\t\\qquad \\quad time to maturity: $ T $, strike price: $ K $ \\\\\n\t\t\\qquad \\quad type: arithmetic/geometric, call/put, European/American, fixed/floating  \\\\\n\t\t\n\t\t\\qquad \\emph{Details of the underlying asset}  \\\\\n\t\t\\qquad \\quad initial price: $ s_0 $, volatility: $ \\sigma $, continuous dividend rate: $ q $  \\\\\n\t\t\n\t\t\\qquad \\emph{Market parameters} -- spot interest rate: $ r $ \\\\\n\t\t\n\t\t\\qquad \\emph{Computational parameters} -- time steps: $ n $, error bound: $ h $ \\\\\n\t}\n\t\n\t\\KwOut{The price of the option at the initial time}\n\t\n\t\\Begin{\n\t\tSet $ \\Delta T, u, p $ from the formulae in Section \\ref{sec:asian-binom}. \\;\n\t\t\n\t\tCompute the singular points at maturity using Equation \\ref{eq:asian-price-maturity-kin} and \\ref{eq:asian-price-maturity-knotin}. \\;\n\t\t\n\t\t\\For{$ i \\in \\{ N-1, \\dots, 0 \\} $}{\n\t\t\tEvaluate $ P_{i,0}^1 $ and $ P_{i,i}^1 $ by Equation \\ref{eq:asian-terminal-nodes} with the early exercise.\n\t\t\t\n\t\t\t\\ForAll{$ N_{i,j}, \\  j \\in \\{ 1, \\dots, i-1 \\} $}{\n\t\t\t\tUsing Equation \\ref{eq:asian-proj-up}, $\\forall A_{i+1,j}^l, \\forall l \\in \\{ 1, \\dots, L_{i+1,j} \\} $, compute $ B^l $. \\;\n\t\t\t\t\n\t\t\t\t$ \\forall B^l \\in \\left[  A_{i,j}^{\\min}, A_{i,j}^{\\max}  \\right] $, compute $ v_{i,j}^c ( B^l ) $ by Equations \\ref{eq:asian-up-lint} and \\ref{eq:asian-up-pr}. \\;\n\t\t\t\t\n\t\t\t\tUsing Equation \\ref{eq:asian-proj-dn}, $\\forall A_{i+1,j+1}^l, \\forall l \\in \\{ 1, \\dots, L_{i+1,j+1} \\} $, compute $ C^l $. \\;\n\t\t\t\t\n\t\t\t\t$ \\forall C^l \\in \\left[  A_{i,j}^{\\min}, A_{i,j}^{\\max}  \\right] $, compute $ v_{i,j}^c ( C^l ) $ by Equations \\ref{eq:asian-dn-lint} and \\ref{eq:asian-dn-pr}. \\;\n\t\t\t\t\n\t\t\t\tSort the averages $ \\{ B^l \\}_l \\cup \\{ C^l \\}_l \\in \\left[  A_{i,j}^{\\min}, A_{i,j}^{\\max}  \\right] $ to obtain the set of $ L_{i,j} $ singular points. \\;\n\t\t\t\t\n\t\t\t\tCompute the American price according to Section \\ref{sec:fixed-strike-am} and obtain a new set of singular points with a new cardinality denoted, for simplicity, by $ L_{i,j} $ again. \\;\n\t\t\t\t\n\t\t\t\t\\Switch(Approximation){upper or lower}{\n\t\t\t\t\t\\Case{upper bound} {Follow Section \\ref{subsec:asian-ub} \\;}\n\t\t\t\t\t\\Case{lower bound} {Follow Section \\ref{subsec:asian-lb} \\;}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\\KwRet{$ P_{0,0}^1 $    \\tcp*{the upper or lower estimate of the exact binomial price with error smaller that $ nh $.} }\n\t}\n\t\n\t\\caption{Pricing cliquet options using the singular points method}\n\\end{algorithm}\n\n\n\\clearpage\n\\subsection{Implementation}\nThe algorithm was implemented in Python 3.5.0 (2015-09-13).\n\n\\inputminted[tabsize=2]{python}{../code/asian.py}\n\\label{lst:asian}\n\n\n\\clearpage\n\\section{Extensibility}\n\\label{sec:asian-extensions}\n\nLet us recapitulate the conditions required for the singular points method to work in the case of Asian options with arithmetic mean.\n\\begin{itemize}\n\t\\item The ability to calculate the upper and lower bounds of the mean for all nodes of the tree.\n\t\\item The recombinant nature of the tree for the underlying. Note that the tree for the option prices are \\emph{not} recombinant.\n\t\\item Convexity and piecewise-linearity of the price function on the mean of the underlying.\n\t\\item Constant volatility\n\\end{itemize}\n\nKeeping these in mind, let us look at the possibility of extending the singular points method to the following cases:\n\\begin{enumerate}\n\t\\item Asian options with geometric mean and fixed volatility.\n\t\\item Asian options with arithmetic mean and local volatility.\n\\end{enumerate}\n\n\n\n\\paragraph{Geometric mean and fixed volatility}\nIn the case of geometric options, we have a closed form formula under the Black-Scholes market model. Let us try to extend the singular points method to this case.\n\nFirstly, we show that the result about the maximum and minimum paths still hold in the geometric case.\n\n\\begin{dfn}[Geometric mean]\n\tThe geometric mean of the risky asset's prices $ (S_i)_{i \\in [n]} $ is given by:\n\t\\begin{equation}\n\t\t\\label{eq:gm}\n\t\tG_{n} = \\left( \\prod_{i=0}^n S_i \\right) ^{\\frac{1}{n+1}}\n\t\\end{equation}\n\\end{dfn}\n\n\n\\begin{lmm}\n\tAt each node $N(i,j)$, the following hold:\n\t\\begin{enumerate}\n\t\\item The maximum average possible $ G_{i,j}^{\\max} $ is attained by the path corresponding to the path with $j$ up movements followed by $(i-j)$ down movements.\n\t\\item The minimum average possible $ G_{i,j}^{\\min} $ is attained by the path corresponding to the path corresponding to the path with $(i-j)$ down movements followed by $j$ up movements.\n\t\\end{enumerate}\n\\end{lmm}\n\n\\begin{proof}\n\tThe proof is the same as Corollary \\ref{crr:asian-up-dn-path}, with $A$ replaced by $G$ and relevant modifications.\n\\end{proof}\n\n\nOne of the central ideas behind the singular points method is that the price of the option is a convex, piecewise-linear function of the average $A$. But in the geometric case, this no longer holds true. For example, take a node $N_{i,j}$ with $ i = n-1 $. The price function given by $ v_{i,j}(G) $, with $ G \\in [G^{min},G^{max}] $, can be calculated by the discounted expectation value.\n\\begin{align}\n\tv_{i,j}(G) &= \\frac{1}{R} \\left[ p v_{i+1,j+1}(G_u) + (1-p) v_{i+1,j}(G_d) \\right] \\\\\n\tG_u &= \\left( G^{i+1} S_0 u^{-i+2j+1} \\right)^{\\frac{1}{i+2}} \\propto G^{\\frac{i+1}{i+2}} \\\\\n\tG_d &= \\left( G^{i+1} S_0 u^{-i+2j-1} \\right)^{\\frac{1}{i+2}} \\propto G^{\\frac{i+1}{i+2}}\n\\end{align}\nClearly, the final function $ v_{i,j} $ is not linear in $G$. Rather it is piecewise-concave. Thus we cannot use the singular points method in this case.\n\n\n\\paragraph{Arithmetic mean with local volatility}\nIn this case, the tree for the underlying is not recombinant, so we do not have more than one singular point in one (non-recombining) node. Essentially, we cannot use the singular points method for local volatility models.\n\n\n\n\\section{Results and conclusion}\n\\label{sec:asian-results}\n\nWe assume that the initial value of the stock price is $ s_0 = 100 $, the maturity is $ T = 1 $, the force of interest rate is $ r = 0.1 $ and the continuous dividend yield is $ q = 0.03 $. We will consider two choices for volatility, $ \\sigma = 0.2 $ and $ \\sigma = 0.4 $, and two choices for the strike, $ K = 90 $ and $ K = 110 $. The time steps ($ n $) taken into consideration are 10, 25, 50, 100, 200 and 400.\n\n\nAll simulations were run on a computer with the following specifications.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Computer specifications}\n\t\\label{tab:specs}\n\t%\t\\rowcolors{1}{Burlywood1}{}\n\t\\begin{tabular}{ll}\n\t\t\\toprule\n\t\tItem  &  Details  \\\\\n\t\t\\midrule\n\t\tProcessor  &  Intel\\textregistered  Celeron\\textregistered  N2840  @ 2.16GHz (2 CPUs)  \\\\\n\t\tArchitecture  &  64-bit  \\\\\n\t\tMemory  &  4 GB  \\\\\n\t\tOperating system  &  Arch Linux  \\\\\n\t\tPython  &  v3.5.0 (2015-09-13)  \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\nTable \\ref{tab:asian-results} highlights the prices obtained using the binomial method ($ n = 10 $ and $ n = 25 $), and the singular points method for the aforementioned time steps.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Results for Asian options}\n\t\\label{tab:asian-results}\n\t%\t\\rowcolors{1}{Burlywood1}{}\n\t\\begin{tabular}{crcccc}\n\t\t\\toprule\n\t\t&         &  \\multicolumn{2}{c}{$ K = 90 $}  &  \\multicolumn{2}{c}{$ K = 110 $}  \\\\\n\t\t       \\cmidrule(lr){3-4}\\cmidrule(lr){5-6}\n\t\t&  $ n $  &  $ \\sigma = 0.2 $  &  $ \\sigma = 0.4 $  &  $ \\sigma = 0.2 $  &  $ \\sigma = 0.4 $  \\\\\n\t\t\\midrule\n\t\t\\multirow{2}{2em}{Bin}\n\t\t&   10  &  14.5912  &  17.8033  &  2.5100  &  6.6523  \\\\\n\t\t&   25  &  15.1535  &  18.6786  &  2.6270  &  7.3451  \\\\\n\t\t\\midrule\n\t\t\\multirow{6}{2em}{SP}\n\t\t&   10  &  14.5925  &  17.8068  &  2.5090  &  6.6511  \\\\\n\t\t&   25  &  15.1535  &  18.6785  &  2.6270  &  7.3449  \\\\\n\t\t&   50  &  15.3524  &  19.0420  &  2.6673  &  7.4563  \\\\\n\t\t&  100  &  15.4732  &  19.2696  &  2.6886  &  7.5174  \\\\\n\t\t&  200  &  15.5453  &  19.4065  &  2.6996  &  7.5502  \\\\\n\t\t&  400  &  15.5861  &  19.4845  &  2.7053  &  7.5674  \\\\\n\t\t\\midrule\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\nBy comparing our results with the exact binomial value obtained for $ n = 10 $, we can confirm that the method gives correct results. In fact, from Table \\ref{tab:asian-results} and also \\cite[Tables 1 -- 2 and 4 -- 7]{Gaudenzi2010}, we observe that the prices are monotonically increasing with respect to the number of time steps, and seem to gradually converge towards a limiting value.\n\n\n\\paragraph{Concluding remarks}\nThus, we have seen that the singular points method fails to be generalised, its shortcomings being the inability to deal with Asian options with geometric mean and to deal with local volatility cases. Nevertheless, it is quite efficient in its domain. It is comparatively fast, having experimental order of complexity $ O(n^3) $. It also allows specification of \\emph{a priori} error bounds, both upper and lower. Numerical results reported by \\cite{Gaudenzi2010} shows that the method outperforms alternative algorithms, and may be viewed as an improvement on previous tree methods.\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "0879aecaa36018aacb936fca78303b7353c0d4f1", "size": 71825, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MathMods/Thesis/docs/tex/asian.tex", "max_stars_repo_name": "homdx/edu", "max_stars_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MathMods/Thesis/docs/tex/asian.tex", "max_issues_repo_name": "homdx/edu", "max_issues_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MathMods/Thesis/docs/tex/asian.tex", "max_forks_repo_name": "homdx/edu", "max_forks_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-09-15T21:30:43.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-15T21:30:43.000Z", "avg_line_length": 62.949167397, "max_line_length": 1129, "alphanum_fraction": 0.6645875392, "num_tokens": 26156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.43144673065542044}}
{"text": "\\chapter{Dictionary methods}\n\n\\section{LZ77}\n\nThe LZ77 is based on the idea of sliding window divided to two parts, search buffer (SB) and lookahead buffer (LB).\nCurrent position is always between SB and LB and is initialized on the first character of the string. In each iteration LZ77 produces a triplet $(\\texttt{i}, \\texttt{j}, \\texttt{a})$ by searching longest possible prefix of LB within SB, where:\n\\begin{itemize}\n  \\item[\\texttt{i}] is an index (counted from current position to the left),\n  \\item[\\texttt{j}] is a count (number of matching symbols),\n  \\item[\\texttt{a}] is a following symbol (first different symbol afther the match).\n\\end{itemize}\nThe dot will be used to mark current position and we consider $|SB|=6$ and $|LB|=4$.\n\n\\subsection{Examples}\n\nGiven\n$$T = \\texttt{aabaabaaabaaabaa}$$,\nthe algorithm proceeds as follows.\n$$T = \\texttt{.aabaabaaabaaabaa}$$\n$$ \\texttt{(0, 0, a)} $$\n$$T = \\texttt{a.abaabaaabaaabaa}$$\n$$ \\texttt{(0, 1, b)} $$\n$$T = \\texttt{aab.aabaaabaaabaa}$$\n$$ \\texttt{(2, 3, a)} $$\n$$T = \\texttt{aabaaba.aabaaabaa}$$\n$$ \\texttt{(3, 3, a)} $$\n$$T = \\texttt{aabaabaaaba.aabaa}$$\n$$ \\texttt{(3, 3, a)} $$\n$$T = \\texttt{aabaabaaabaaaba.a}$$\n$$ \\texttt{(0, 0, a)} $$\n$$T = \\texttt{aabaabaaabaaabaa.}$$\nThe following symbol can never be empty, so even if there would a match for it in the SB, is is not going to be used.\nResult: $$ \\texttt{(0, 0, a), (0, 1, b), (2, 3, a), (3, 3, a), (3, 3, a), (0, 0, a)} $$\n\nGiven\n$$T = \\texttt{abababcacacababa}$$,\nthe algorithm proceeds as follows.\n$$T = \\texttt{.abababcacacababa}$$\n$$ \\texttt{(0, 0, a)} $$\n$$T = \\texttt{a.bababcacacababa}$$\n$$ \\texttt{(0, 0, b)} $$\n$$T = \\texttt{ab.ababcacacababa}$$\n$$ \\texttt{(1, 3, b)} $$\nNotice this special case, where we actually cross the boundary between SB and LB. It can be done because each additional symbol will be known during the decompression.\n$$T = \\texttt{ababab.cacacababa}$$\n$$ \\texttt{(0, 0, c)} $$\n$$T = \\texttt{abababc.acacababa}$$\n$$ \\texttt{(2, 1, c)} $$\n$$T = \\texttt{abababcac.acababa}$$\n$$ \\texttt{(1, 3, b)} $$\nAgain similar case as before.\n$$T = \\texttt{abababcacacab.aba}$$\n$$ \\texttt{(1, 2, a)} $$\n$$T = \\texttt{abababcacacababa.}$$\nResult: $$ \\texttt{(0, 0, a), (0, 0, b), (1, 3, b), (0, 0, c), (2, 1, c), (1, 3, b), (1, 2, a)} $$\n\nDecompression is follows the same pattern and it is actually simpler, because there is no need to search for the best match. The only think done in each step is the copying symbols from SB (and possibly LB) into the LB.\n\nYou can examine the special case above during decompression, consider this state:\n$$T = \\texttt{abababcac.}$$,\nwhere you want to add the following triplet:\n$$ \\texttt{(1, 3, b)} $$\nYou need to copy $3$ symbols from possition $1$ and the append \\texttt{b} resulting in this:\n$$T = \\texttt{abababcac.acab}$$.\nAs you can see, the \\texttt{ac} was copied from SB and then \\texttt{a} from LB and then it was followed with \\texttt{a} as the following symbol.\n\n\\section{LZ78}\n\nIn LZ78 the sliding window is replaced with standard trie like dictionary where nodes are numbered from $0$ incrementally and their number is used as reference. In each iteration algorithm produces a pair $(\\texttt{i}, \\texttt{a})$ by searching longest possible prefix from current position in the dictionary, where:\n\\begin{itemize}\n  \\item[\\texttt{i}] is an index into the dictionary,\n  \\item[\\texttt{a}] is a following symbol.\n\\end{itemize}\nThe dictionary is extended after each iteration by the processed string.\n\n\\clearpage\n\\subsection{Examples}\n\nGiven\n$$T = \\texttt{aabaabaaabaaabaa}$$, \nthe algorithm stars with empty tree containing only root node which represents empty string $\\varepsilon$ with index $0$.\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(0, a)} $$\n\nNode 1 for \\texttt{a} is added.\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}}]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(1, b)}$$\n\nNode 2 for \\texttt{ab} is added.\n\n\\begin{marginfigure}[-1.5cm]\n\\hspace{1cm}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(1, a)}$$\n\nNode 3 for \\texttt{aa} is added.\n\n\\begin{marginfigure}[-1.5cm]\n\\hspace{2cm}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]\n                                                [3,edge label={node[el style, draw=none]{a}}]]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(0, b)}$$\n\nNode 4 for \\texttt{b} is added.\n\n\\begin{marginfigure}[-1.3cm]\n\\hspace{3.25cm}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]\n                                                [3,edge label={node[el style, draw=none]{a}}]]\n   [4,edge label={node[el style, draw=none]{b}}]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(3, a)}$$\n\nNode 5 for \\texttt{aaa} is added.\n\n\\begin{marginfigure}[-1.3cm]\n\\hspace{4.4cm}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]\n                                                [3,edge label={node[el style, draw=none]{a}} [5,edge label={node[el style, draw=none]{a}}]]]\n   [4,edge label={node[el style, draw=none]{b}}]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(4, a)}$$\n\nNode 6 for \\texttt{ba} is added.\n\n\\begin{marginfigure}[-2.4cm]\n\\hspace{2.25cm}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]\n                                                [3,edge label={node[el style, draw=none]{a}} [5,edge label={node[el style, draw=none]{a}}]]]\n   [4,edge label={node[el style, draw=none]{b}} [6,edge label={node[el style, draw=none]{a}}]]]\n\\end{forest}\n\\end{marginfigure}\n\n$$ \\texttt{(3, b)}$$\n\nNode 7 for \\texttt{aab} is added.\n\n\\begin{marginfigure}[-2.6cm]\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n[0 [1,edge label={node[el style, draw=none]{a}} [2,edge label={node[el style, draw=none]{b}}]\n                                                [3,edge label={node[el style, draw=none]{a}} [5,edge label={node[el style, draw=none]{a}}] \n                                                                                             [7,edge label={node[el style, draw=none]{b}}]]]\n   [4,edge label={node[el style, draw=none]{b}} [6,edge label={node[el style, draw=none]{a}}]]]\n\\end{forest}\n  \n  \\caption{$LZ78(\\text{aabaabaaabaaabaa})$}\n\\end{marginfigure}\n\n$$ \\texttt{(1, a)}$$\n\nResult: $$ \\texttt{(0, a), (1, b), (1, a), (0, b), (3, a), (4, a), (3, b), (1, a)}$$\n\nGiven\n$$T = \\texttt{abababcacacababa}$$,\nthe algorithm proceeds similarly as with the previous example.\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n  [0 [1,edge label={node[el style, draw=none]{a}} [3,edge label={node[el style, draw=none]{b}} [4,edge label={node[el style, draw=none]{c}}]]\n                                                  [5,edge label={node[el style, draw=none]{c}} [5,edge label={node[el style, draw=none]{a}}]]]\n     [2,edge label={node[el style, draw=none]{b}} [7,edge label={node[el style, draw=none]{a}}]]]\n\\end{forest}\n\n  \\caption{$LZ78(\\text{abababcacacababa})$}\n\n\\end{marginfigure}\n\nResult: $$ \\texttt{(0, a), (0, b), (1, b), (3, c), (1, c), (5, a), (2, a), (2, a)}$$\n\nThe decompression proceeds simiarly by building an index using trie or table.\n\nGiven: $$ \\texttt{(0, a), (1, b), (1, a), (0, b), (3, a), (4, a), (3, b), (1, a)}$$\nthe algorithm stars with empty table containing only empty string $\\varepsilon$ with index $0$.\n\nIn each step you process a pair from the compressed input and add new index into dictionary. The encoded pair is decoded based on the previously added values.\n\n\\begin{figure}\n  \\begin{center}\n  \\begin{tabular}{c|l|l}\n    index & enc. phrase & dec. phrase \\\\\n    \\hline\n    0 & $\\varepsilon$ & $\\varepsilon$\\\\\n    1 & 0a & \\texttt{a}\\\\\n    2 & 1b & \\texttt{ab}\\\\\n    3 & 1a & \\texttt{aa}\\\\\n    4 & 0b & \\texttt{b}\\\\\n    5 & 3a & \\texttt{aaa}\\\\\n    6 & 4a & \\texttt{ba}\\\\\n    7 & 3b & \\texttt{aab}\\\\\n    8 & 1a & \\texttt{aa}\\\\\n  \\end{tabular}\n  \\end{center}\n  \\caption{$LZ78^R(LZ78(\\text{aabaabaaabaaabaa}))$}\n\\end{figure}\n\nGiven: $$ \\texttt{(0, a), (0, b), (1, b), (3, c), (1, c), (5, a), (2, a), (2, a)}$$\nthe algorithm stars with empty table containing only empty string $\\varepsilon$ with index $0$.\n\nIn each step you process a pair from the compressed input and add new index into dictionary. The encoded pair is decoded based on the previously added values.\n\n\\begin{figure}\n  \\begin{center}\n  \\begin{tabular}{c|l|l}\n    index & enc. phrase & dec. phrase \\\\\n    \\hline\n    0 & $\\varepsilon$ & $\\varepsilon$\\\\\n    1 & 0a & \\texttt{a}\\\\\n    2 & 0b & \\texttt{b}\\\\\n    3 & 1b & \\texttt{ab}\\\\\n    4 & 3c & \\texttt{abc}\\\\\n    5 & 1c & \\texttt{ac}\\\\\n    6 & 5a & \\texttt{aca}\\\\\n    7 & 2a & \\texttt{ba}\\\\\n    8 & 2a & \\texttt{ba}\\\\\n  \\end{tabular}\n  \\end{center}\n  \\caption{$LZ78^R(LZ78(\\text{abababcacacababa}))$}\n\\end{figure}\n\nThis method has no special cases.\n\n\\section{LZW}\n\nLZW behaves similarly as LZ78, but the following symbol is dropped and in each iteration algorithm produces just the indes into the dictionary \\texttt{i}. The dictionary is not initialized empty, but contains all characters of the alphabet instead.\nThe dictionary is extended after each iteration by the processed string and a following symbol. You can think about it that the following character is encoded this way. That trere is a overlap between string added into the dictionary then next processed string.\nWe consider alphabet $\\Sigma = \\{\\texttt{a}, \\texttt{b}, \\texttt{c}\\}$.\n\n\\begin{figure}\n\\begin{center}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n  [0 [1,edge label={node[el style, draw=none]{a}}]                                         \n     [2,edge label={node[el style, draw=none]{b}}]\n     [3,edge label={node[el style, draw=none]{c}}]]\n\\end{forest}\n\\end{center}\n  \\caption{LZW - newly initialized dictionary}\n\\end{figure}\n\nGiven\n$$T = \\texttt{aabaabaaabaaabaa}$$,\nthe algorithm proceeds as follows.\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n  [0 [1,edge label={node[el style, draw=none]{a}} [4,edge label={node[el style, draw=none]{a}} [7,edge label={node[el style, draw=none]{b}} [9,edge label={node[el style, draw=none]{a}}]] [10,edge label={node[el style, draw=none]{a}}]]\n                                                  [5,edge label={node[el style, draw=none]{b}} [11,edge label={node[el style, draw=none]{a}}]]]                                         \n     [2,edge label={node[el style, draw=none]{b}} [6,edge label={node[el style, draw=none]{a}} [8,edge label={node[el style, draw=none]{a}}]]]\n     [3,edge label={node[el style, draw=none]{c}}]]\n\\end{forest}\n\n  \\caption{$LZW(\\text{aabaabaaabaaabaa})$}\n\\end{marginfigure}\n\nResult: $$ \\texttt{1, 1, 2, 4, 6, 7, 4, 5, 4}$$\n\nGiven\n$$T = \\texttt{abababcacacababa}$$,\nthe algorithm proceeds as follows.\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n  [0 [1,edge label={node[el style, draw=none]{a}} [4,edge label={node[el style, draw=none]{b}} [6,edge label={node[el style, draw=none]{a}}] [7,edge label={node[el style, draw=none]{c}}]]\n                                                  [9,edge label={node[el style, draw=none]{c}}]]                                         \n     [2,edge label={node[el style, draw=none]{b}} [5,edge label={node[el style, draw=none]{a}} [12,edge label={node[el style, draw=none]{b}}]]]\n     [3,edge label={node[el style, draw=none]{c}} [8,edge label={node[el style, draw=none]{a}} [10,edge label={node[el style, draw=none]{c}}] [11,edge label={node[el style, draw=none]{b}}]]]]\n\\end{forest}\n\n  \\caption{$LZW(\\text{aabaabaaabaaabaa})$}\n\\end{marginfigure}\n\nResult: $$ \\texttt{1, 2, 4, 4, 3, 1, 8, 8, 5, 5}$$\n\nThe decompression proceeds simiarly by building an index using trie or table. After second number is decoded adding into dictionary starts. The phrases added is alway the previous number plus the first carracter or decoded current number.\n\nGiven: $$ \\texttt{1, 1, 2, 4, 6, 7, 4, 5, 4}$$\nthe algorithm stars with table containing empty string $\\varepsilon$ with index $0$ and all symbols of the alphabet with increasing indexes.\n\nIn each step you process a pair from the compressed input and add new index into dictionary. The encoded pair is decoded based on the previously added values.\n\n\\begin{figure*}\n  \\begin{center}\n  \\begin{tabular}{c|l|l}\n    index & enc. phrase & dec. phrase \\\\\n    \\hline\n    0 & $\\varepsilon$ & $\\varepsilon$\\\\\n    1 & a & \\texttt{a}\\\\\n    2 & b & \\texttt{b}\\\\\n    3 & c & \\texttt{c}\\\\\n    4 & 1a & \\texttt{aa}\\\\\n    5 & 1b & \\texttt{ab}\\\\\n    6 & 2a & \\texttt{ba}\\\\\n    7 & 4b & \\texttt{aab}\\\\\n    8 & 6a & \\texttt{baa}\\\\\n    9 & 7a & \\texttt{aaba}\\\\\n    10 & 4a & \\texttt{aaa}\\\\\n    11 & 5a & \\texttt{aba}\\\\\n  \\end{tabular}\n  \\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\n    \\hline\n    1 & 1 & 2 & 4 & 6 & 7 & 4 & 5 & 4\\\\\n    \\hline\n    a & a & b & aa & ba & aab & aa & ab & aa\\\\\n    \\hline\n  \\end{tabular}\n  \\end{center}\n  \\caption{$LZWW^R(LWZ(\\text{aabaabaaabaaabaa}))$}\n\\end{figure*}\n\nGiven: $$ \\texttt{1, 2, 4, 4, 3, 1, 8, 8, 5, 5}$$\nthe algorithm stars with table containing empty string $\\varepsilon$ with index $0$ and all symbols of the alphabet with increasing indexes.\n\nIn each step you process a pair from the compressed input and add new index into dictionary. The encoded pair is decoded based on the previously added values.\n\n\\begin{figure*}\n  \\begin{center}\n  \\begin{tabular}{c|l|l}\n    index & enc. phrase & dec. phrase \\\\\n    \\hline\n    0 & $\\varepsilon$ & $\\varepsilon$\\\\\n    1 & a & \\texttt{a}\\\\\n    2 & b & \\texttt{b}\\\\\n    3 & c & \\texttt{c}\\\\\n    4 & 1b & \\texttt{ab}\\\\\n    5 & 2a & \\texttt{ba}\\\\\n    6 & 4a & \\texttt{aba}\\\\\n    7 & 4c & \\texttt{abc}\\\\\n    8 & 3a & \\texttt{ca}\\\\\n    9 & 1c & \\texttt{ac}\\\\\n    10 & 8c & \\texttt{cac}\\\\\n    11 & 8b & \\texttt{cab}\\\\\n    12 & 5b & \\texttt{bab}\\\\\n  \\end{tabular}\n  \\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}\n    \\hline\n    1 & 2 & 4 & 4 & 3 & 1 & 8 & 8 & 5 & 5\\\\\n    \\hline\n    a & b & ab & ab & c & a & ca & ca & ba & ba\\\\\n    \\hline\n  \\end{tabular}\n  \\end{center}\n  \\caption{$LZW^R(LZW(\\text{abababcacacababa}))$}\n\\end{figure*}\n\nThe algorithm has one special case - when the currently encoded string is a prefix minus $1$ character from the next string. If this case does not concerd one of the initial nodes, it is represented by a node which parent has index minus $1$.\n\nGiven\n$$T = \\texttt{abbbbabc}$$,\nthe algorithm proceeds as follows..\n\n\\begin{marginfigure}\n\\begin{forest}\n  for tree={child anchor=north,inner sep=5pt},\n%\n  [0 [1,edge label={node[el style, draw=none]{a}} [4,edge label={node[el style, draw=none]{b}}]]                                         \n     [2,edge label={node[el style, draw=none]{b}} [5,edge label={node[el style, draw=none]{b}} [7,edge label={node[el style, draw=none]{b}}]] [6,edge label={node[el style, draw=none]{a}}]]\n     [3,edge label={node[el style, draw=none]{c}}]]\n\\end{forest}\n\n  \\caption{$LZW(\\text{abbbbabc})$}\n\\end{marginfigure}\n\nResult: $$ \\texttt{1, 2, 5, 2, 4, 3}$$\n\nGiven: $$ \\texttt{1, 2, 5, 2, 4, 3}$$\nthe algorithm stars with table containing empty string $\\varepsilon$ with index $0$ and all symbols of the alphabet with increasing indexes.\n\nIn each step you process a pair from the compressed input and add new index into dictionary. The encoded pair is decoded based on the previously added values.\n\n\\begin{figure}\n  \\begin{center}\n  \\begin{tabular}{c|l|l}\n    index & enc. phrase & dec. phrase \\\\\n    \\hline\n    0 & $\\varepsilon$ & $\\varepsilon$\\\\\n    1 & a & \\texttt{a}\\\\\n    2 & b & \\texttt{b}\\\\\n    3 & c & \\texttt{c}\\\\\n    4 & 1b & \\texttt{ab}\\\\\n    5 & 5b & \\texttt{bb}\\\\\n    6 & 5b & \\texttt{bbb}\\\\\n    7 & 2a & \\texttt{ba}\\\\\n  \\end{tabular}\n  \\begin{tabular}{|c|c|c|c|c|c|}\n    \\hline\n    1 & 2 & 5 & 2 & 4 & 3\\\\\n    \\hline\n    a & b & bb & b & ab & c\\\\\n    \\hline\n  \\end{tabular}\n  \\end{center}\n  \\caption{$LZW^R(LZW(\\text{abbbbabc}))$}\n\\end{figure}\n\n\\section{Homework}\n\n\\begin{itemize}\n  \\item Try to figure out efficient way how to encode outputs from LZ77, LZ78 and LZW methods. \n  \\item Try to figure out how many bits you will need for the encoding.\n  \\item Try to calculate compression rations. \n\\end{itemize}\n", "meta": {"hexsha": "d00bca2ca6b08a47d2edcdac98d12186aea301f9", "size": 16719, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "kod/ch5.tex", "max_stars_repo_name": "exander77/handouts", "max_stars_repo_head_hexsha": "c30e8f1128bc71ea69c7a83daaf8915b6a8eff36", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "kod/ch5.tex", "max_issues_repo_name": "exander77/handouts", "max_issues_repo_head_hexsha": "c30e8f1128bc71ea69c7a83daaf8915b6a8eff36", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "kod/ch5.tex", "max_forks_repo_name": "exander77/handouts", "max_forks_repo_head_hexsha": "c30e8f1128bc71ea69c7a83daaf8915b6a8eff36", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.9889380531, "max_line_length": 316, "alphanum_fraction": 0.6220467731, "num_tokens": 5931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.7520125848754471, "lm_q1q2_score": 0.4314133820755918}}
{"text": "\\section{Reinforcement Learning}\n\\label{sec:rl_theory}\n\n\\subsection{The Environment/Agent Interface}\n\nIn the real world learning happens by trial and error. Reinforcement learning is an attempt to formalize this study of ``learning by interaction''. The problem of learning by trial and error has a natural formulation by the environment/agent interface, which is graphically represented in figure \\ref{fig:agent_enviroment_interface}. Note, this entire section draws heavily from the book Reinforcement Learning by \\textcite{sutton_reinforcement_2018}, regarding naming conventions, algorithms and notation.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.35]{figures/agent_environment_interface.png}\n    \\caption{Agent/Environment Interface}\n    \\label{fig:agent_enviroment_interface}\n\\end{figure}\n\nThe concept can be phrased the following way: An agent will over a series of discreet time steps $(t=1, 2, \\cdots, T)$ take an action which will lead to some sort of reward (or in economic terms utility). For each time step the agent receives information about the state $S_t$ of the environment $\\mathcal{E}$. The agent then takes an action $A_t$, which prompts the environment $\\mathcal{E}$  to return a reward $R_{t+1}$, and a new state $S_{t+1}$. This process continues until the game terminates. The agent's sole purpose is to maximize the cumulative rewards throughout the game. It should be noted here that $R_t \\in \\R$ such that the agent is optimizing over a sum of scalars. The game will lead to a trajectory of states, actions and rewards that look like:\n\n\\begin{equation}\n    S_0, A_0, R_1, S_1, A_1, R_2, S_2, A_2, \\cdots ,R_{T-1}, S_{T-1}, A_{T-1}, R_{T}\n\\end{equation}\n\nCertain assumptions is necessary to perform any sort of modelling. The most fundamental assumption reinforcement learning relies on, is that of the Markov decision process: A Markov decision process (MDP) abides to:\n\n\\begin{equation}\\label{eq:mdp1}\n    p(s_t, r_t \\mid s_{t-1},  a_{t-1}) = p(s_t, r_t \\mid s_{t-1},\\cdots, s_{0}, a_{t-1}, \\cdots, a_{0}) = P(S_t = s_t, R_t = r_t \\mid S_{t-1} = s_t, A_{t-1} = a_t)\n\\end{equation}\n\nBreaking equation \\eqref{eq:mdp1} down reveals that the MDP follows a true probability distribution. That is, a joint probability distribution describes $R_t$ and $S_t$. Another important feature is that the probability distribution of $S_t$ and $R_t$ only depends on the last state and action. This turns out to be an instrumental assumption for doing any sort modelling, the implication being that the state $s_t$ contains all relevant information about the past, hence the name, \\textit{Markov} Decision Process. First, the assumption implies, that the size of the probability distribution would not grow linearly as more and more states and actions was represented for the agent, yielding the computations more and more expensive. Second, it allows for backward induction and dynamic programming (a topic which will be discussed later).  Lastly one must ensure that when a system is modelled, the state represents all relevant information about the past. Multiple statements can be derived from \\eqref{eq:mdp1}, but most importantly one can derive the expected reward:\n\n\\begin{equation}\n    \\E[R_t \\mid A_{t-1} = a_{t-1}, S_{t-1} = {s_{t-1}}] = \\int_{r_t} r_t \\int_{s_t} p(r_t, s_t \\mid a_{t-1} s_{t-1}) d s_t d r_t \n\\end{equation}\n\nThe agent's goal is to maximize the cumulative rewards, which can be formulated as:\n\n\\begin{equation}\\label{eq:cum_rewards}\n   G_t = R_{t+1}, R_{t+2}, R_{t+3}, \\cdots R_{T}\n\\end{equation}\n\nThe formulation in \\eqref{eq:cum_rewards} can be problematic with continuing tasks. That is if $T \\rightarrow \\infty$. Therefore discounting of rewards is usually implemented, which have the nice economic implications, that agents in the real world tend to be impatient, and therefore more realistically model real human agents:\n\n\\begin{equation}\n    G_t = R_{t+1} + \\gamma R_{t+2} + \\gamma^2 R_{t+3} + \\cdots = \\sum_{k=0}^{T - t} \\gamma^k R_{t+k+1}\n\\end{equation}\n\nWith $\\gamma$ being the discount rate, yielding a geometric series, that is known to converge, if $R_k$ is bounded.\n\n\\subsection{Value Function, Q-Function, Policy Function and the Bellman Equation}\n\nThe value function represents the expected discounted cumulative returns from following a policy, $\\pi$. The value function can be said to approximate the value of a strategy:\n\n\\begin{equation}\\label{eq:value_function1}\n    v_{t}^{\\pi}(s_t) = \\E_t [G_t \\mid S_t = s_t] = \\E_t \\lsp \\sum_{k=0}^{T - t} \\gamma^k R_{t+k+1} \\bigg\\vert S_t = s_t \\rsp \n\\end{equation}\n\n\nA couple of things to note about \\eqref{eq:value_function1}: Since the expectation is taken over a sum, one can instead take the sum over the expectations, yielding it possible to calculate the individual expected returns from following a policy, and using those to calculate the value function. Another concept that closely resembles the value-function is the Q-function:\n\n\\begin{equation}\n    q_t^{\\pi} (s_t, a_t) = \\E_t [G_t \\mid S_t = s_t, A_t = a_t ] = \\E_t \\lsp \\sum_{k=0}^{T - t} \\gamma^k R_{t+k+1} \\bigg\\vert S_t = s_t, A_t = a_t\\rsp \n\\end{equation}\n\nThe Q-function only differs from the value function by also conditioning on the action, and not only the state. The value function and the Q-function shares the property, that it maps the expected value of a state (or state action pair) to a scalar value, where this value represents the cumulative, discounted rewards of following a certain policy. This has the nice property of allowing the agent to choose an action which maps to the highest expected value, $G_t$.\n\nThe Bellman equation can be expressed, using the expression for the value function:\n\n\\begin{equation}\n    v^{\\pi}_{t} (s_t) = \\E_t [G_t \\mid S_t] = \\E_t  \\lsp R_{t+1} + \\gamma G_{t+1} \\mid S_t \\rsp = \\E_t \\lsp R_{t+1} + \\gamma v_{t+1}^{\\pi}(S_{t+1}) \\rsp\n\\end{equation}\n\nOne should consider that $\\E [v_{t+1}^\\pi(s_{t+1})]$ does not imply $v_{t+1}^{\\pi}(\\E[s_{t+1}])$, which has the consequence of considerable computational markup when solving a model using the Bellman Equation as an update rule.\n\nLastly some information about the policy function.  A policy function defines how the agent chooses an action:\n\n\\begin{equation}\n    \\pi_t : \\statespace \\mapsto \\actionspace \n\\end{equation}\n\nIn general reinforcement learning algorithms falls in two distinct categories: Algorithms that directly estimate the policy function or algorithms that work by estimating the value function (or Q-function), and use this to find the optimal policy. In this paper the primary focus will be on the latter category of algorithms.\n\n\\subsection{Relationship to Dynamic Programming}\\label{sec:dynamic_programming}\n\nDynamic programming, invented by Richard Bellman, allows for a way to find the optimal policy, $\\pi^{*}$, and the associated value function, $v^{\\pi^{*}}$. Dynamic programming has a set of practical and formal requirements. First, the size of the state space should be limited. This is due to the fact, that number of computations will increase exponentially with the number of states, what Richard Bellman described as ``The Curse of Dimensionality''. Secondly it requires that the entire MDP is known. Here one should distinguish between an environment and a model of an environment. In this paper the model and the environment coincide, but this is not always the case. An example could be a self driving car. Because the self driving car does not have a perfect model of the environment, dynamic programming cannot be used as an algorithm for navigating the environment. In other words, unless the joint probability distribution of states and actions can be formulated explicitly, dynamic programming is not feasible. In general, it can be said that dynamic programming (and also reinforcement learning) is to use the value function to structure the search for good policies  \\parencite{sutton_reinforcement_2018}.  The optimal value function  implies that one knows the optimal policy:\n\n\\begin{equation}\n    v_t^{*}(s_t) = \\underset{a}{\\max}  \\E \\lsp R_{t+1} + \\gamma v^{*}_{t+1}(S_{t+1}) \\mid S_t = s_t, A_t = a\\rsp \n\\end{equation}\n\nDynamic programming problems can be solved by two different approaches: \\textit{value function iteration} and \\textit{policy function iteration}.\n\n\\textit{Policy function iteration} consists of two steps: 1) an evaluation step. Which calculates the value of a policy, and 2) a policy improvement step.\nThe first step can be considered a prediction step. By following a given policy the associated value function can be estimated. This is done by sweeping through the state space calculating the expected value of the state following the policy. This process continues until the algorithm has converged. In this context convergence implies the difference between the previous estimation of the value function and the current estimation of the value function, only differs below some threshold. The second step, policy improvement, works by searching through the state space, seeing if diverging from the current policy yields higher expected cumulative returns. An alternative phrasing is: Assume that the policy used for the evaluation step is optimal. Then there should be no other strategy that would yield a higher value-function for all possible states. This can be expressed more formally as:\n\n\\begin{equation}\n     \\E \\lsp R_{t+1} + \\gamma v^{*}_{t+1}(S_{t+1}) \\mid S_t = s_t, A_t = \\pi_t^*(s_t) \\rsp \\geq \\E \\lsp R_{t+1} + \\gamma \\tilde{v}_{t+1}(S_{t+1}) \\mid S_t = s_t, A_t =\\tilde{\\pi}_t(s_t) \\rsp \\qquad \\forall s_t \\in \\statespace\n\\end{equation}\n\nWhere $\\tilde{\\pi}$ is any arbitrary policy. If at any point in the state space one can find a policy that yields a higher value function than the current, then one should switch policy, which yields an updated, superior policy! The process alternates between policy evaluation and policy improvement, until no better policy can be found. A graphical representation of the process can be considered as shown in equation \\eqref{eq:policyevaluation} where $\\overset{\\textbf{E}}{\\longrightarrow}$ denotes a policy evaluation and $\\overset{\\textbf{I}}{\\longrightarrow}$ denotes policy improvement:\n\n\\begin{equation}\n    \\label{eq:policyevaluation}\n    \\pi^0 \\overset{\\textbf{E}}{\\longrightarrow}\n    v^{\\pi^0} \\overset{\\textbf{I}}{\\longrightarrow} \\pi^1 \\overset{\\textbf{E}}{\\longrightarrow} v^{\\pi^1} \\overset{\\textbf{I}}{\\longrightarrow} \\cdots \\overset{\\textbf{I}}{\\longrightarrow} \\pi^* \\overset{\\textbf{E}}{\\longrightarrow} v^{\\pi^*}\n\\end{equation}\n\nThe second approach \\textit{value function iteration} computes a max over the value function implying only a single sweep through the state space in each iteration of the loop. The max operation yields value function iteration a considerably faster solution method. Value function iteration can be considered using the Bellman equation as an update rule \\parencite{sutton_reinforcement_2018}. The algorithm for value function iteration is described below:\n\n\\begin{algorithm}[H]\n\\SetAlgoLined\n\\KwResult{Yielding $\\pi^*, v^*$}\n Algorithm parameter $\\theta > 0$ determining accuracy of estimation\\;\n Initialize $V(s)\\quad \\forall s \\in \\statespace$ except $V(terminal) = 0$\\;\n \\While{$\\Delta > \\theta$}{\n    $\\Delta \\la 0$ \\; \n    \\ForEach{$s \\in \\statespace$}{\n        $v \\la V(s)$ \\;\n        $V(s) \\la \\underset{a}{\\max} \\E [R_{t+1}  + \\gamma V(S_{t+1}) \\mid A_t = a, S_t = s] $ \\;\n        $\\Delta \\la \\max (\\Delta, \\mid  v - V(s) \\mid )$\n    }\n }\n \\caption{Value Function Iteration}\n\\end{algorithm}\n\n So for each sweep through the state space a single sweep of policy evaluation and a single sweep of policy improvement is performed. Again this algorithm terminates when the difference between the value function of the last sweep and the current value function is below some threshold.\n \n In economics a dynamic programming solution will usually have the addition of using backwards induction. This is due to the fact the age evolves deterministically. The model assumes an agent acting over $T$ time steps, terminating when the agent reaches a certain age. So in a sense, the agent moves in a deterministic fashion towards the termination of the environment. This implies that one can solve such a model by only doing a single sweep through the state space! The agent will maximize its value function in the terminating period. Now using this value associated with the terminating period, the agent can consider his actions in $T-1$, remembering the Bellman equation can be used as an update rule:\n \n \\begin{equation}\n     V_{T-1}(s_{t-1}) = \\underset{a}{\\max}\\E [R_T + \\gamma V_T (S_T) \\mid S_{T-1} = s_{T-1}, A_{T-1} = a]\n \\end{equation}\n \n In other words, one can model all possible states that the agent can encounter in each time step of the model, making it possible to find the optimal value function $v^{\\pi^*}$ and policy function $\\pi^{*}$ by a single sweep through the state space using a combination of dynamic programming and backwards induction. The implementation of value function iteration in this paper will be explored in section \\ref{sec:solution_methods}. In the reinforcement learning literature, this concept of updating the estimate of the value of a state based on value estimates of other states, is called bootstrapping\\footnote{In economics bootstrapping will usually refer to a non-parametric, sample based approach for doing inference of a parameter estimate. These things are unrelated.}. \n\n Before moving on to other reinforcement learning techniques, the concept of \\textit{Generalized Policy Iteration} (GPI) is introduced. GPI is the concept of letting policy iteration and policy improvement interact with the intention of having the policy converge to the optimal policy. In practice the policy evaluation will be done with respect to the current policy. Policy improvement will be greedy with respect to the current value function. As described by \\textcite{sutton_reinforcement_2018}: The value function stabilizes only when it is consistent with the current policy, and the policy stabilizes\nonly when it is greedy with respect to the current value function.\nThus, both processes stabilize only when a policy has been found that is greedy with respect to its own evaluation function. This implies that the Bellman optimality equation holds, and thus that the policy and the value function are optimal.\n \n \\subsection{Overview of Reinforcement Learning Techniques}\n \nTwo different reinforcement learning methods will be presented in section \\ref{sec:solution_methods}. Here I present some basic information that makes the reader able to digest the material presented. First it is important to address why not only use dynamic programming. Dynamic programming requires that a perfect model of the environment is accessible. This is due to the fact, that when calculating the expected value function for each action, the probability distribution of the reward and the next state, needs to formulated in an explicit form. The other techniques presented here does not have the same requirement. Secondly DP methods require that the size of the state space must be limited. The implementations presented later does not have the same requirements, allowing for approximating the value function and/or the policy function. Below I explain two different methods of learning \\textit{Monte Carlo Methods} and \\textit{Temporal Difference Learning} these being the two foundations of the reinforcement learning methods presented later. It is also useful to distinguish between \\textit{control} and \\textit{prediction}. Prediction can be considered the step of estimating the value function, whereas control relates to how to approximate optimal policies. Finally, one should make a distinction between \\textit{off-policy} and \\textit{on-policy} methods. \\textcite{sutton_reinforcement_2018} describes the difference as: On-policy methods attempt to evaluate or improve the policy that is used to make decisions, whereas off-policy methods evaluate or improve a policy different from that used to generate the data.\n\n\\subsubsection{Monte Carlo Methods}\n\nBefore delving into MC-methods it is appropriate to introduce some more terminology: When talking about an \\textit{episode} it should be understood as an agent moving through the environment from start to termination. When talking about a \\textit{step} it should be understood as going from one state to the next in the environment. \n\nFirst consider the problem of Monte Carlo prediction. The best way to get a sense of prediction with Monte Carlo methods is to present an algorithm:\n\n\\begin{algorithm}[H]\n\\SetAlgoLined\n\\KwResult{Yielding $v^{\\pi}$}\n Input: policy $\\pi$ to be evaluated\\;\n $Returns(s) \\la$ an empty list $s \\in \\statespace$\\; \n \\While{Forever}{\n    Generate an episode: $S_0, A_0, R_1, S_1, A_1, \\cdots S_{T-1}, A_{t-1}, R_T$\\; \n    $G \\la 0$ \\;\n    \\ForEach{step in episode, $t = \\{T -1 , T-2 , \\cdots, 0\\}$}{\n        $G \\la \\gamma G + R_{t+1}$\\;\n        \\If{$S_t \\notin \\{S_{t-1}, S_{t-2}, \\cdots S_0 \\}$}{\n            Append $G$ to $Returns(S_t)$ \\;\n            $V(S_t) \\la average(Returns(S_t))$ \\;\n        }\n    }\n }\n \\caption{First-Visit MC prediction, for estimating $v^{\\pi}$}\n \\label{alg:mcfirstvisit}\n\\end{algorithm}\n\nAlgorithm \\ref{alg:mcfirstvisit} shows how the general concept of estimating the value function for given policy. The agent follows the policy until the game terminates. Starting from the terminating state, a reversed experience replay is performed using the discounted rewards to approximate the value function for each state the agent visited. However, the algorithm above relies on a model of the environment. If not such a model is present, one will need to estimate the value of each action. Instead of considering the value function, the Q-function (state-action pair) is used for Monte Carlo estimation. It is assumed that the policy stays constant. That is, the policy does not update as more and more episodes are experienced, which defeats the purpose of learning how to interact with the environment. This can be addressed by updating the policy, and then discard old experience. Another possibility is to accept the non-stationarity of the data collected, and update the policy using the data from a previous policy, hoping that with time the algorithm will converge. This is in fact generalized policy iteration.\n\nConsider now how to do Monte Carlo Control, i.e., approximating the optimal policy. Just as with policy iteration the pattern followed is:\n\n\\begin{equation}\n    \\label{eq:montecarlocontrol}\n    \\pi^0 \\overset{\\textbf{E}}{\\longrightarrow}\n    q^{\\pi^0} \\overset{\\textbf{I}}{\\longrightarrow} \\pi^1 \\overset{\\textbf{E}}{\\longrightarrow} q^{\\pi^1} \\overset{\\textbf{I}}{\\longrightarrow} \\cdots \\overset{\\textbf{I}}{\\longrightarrow} \\pi^* \\overset{\\textbf{E}}{\\longrightarrow} q^{\\pi^*}\n\\end{equation}\nPolicy evaluation is done as described above. Policy improvement is done by making the policy greedy with respect to the current estimated Q-function \\parencite{sutton_reinforcement_2018}. Since the Q-function instead of the value function is used, no model is needed to construct a greedy policy \\parencite{sutton_reinforcement_2018}. The greedy policy is the one that for each $s \\in \\statespace$ deterministically chooses an action with maximal action-value:\n\n\\begin{equation}\n    \\pi(S_t) = \\underset{a}{\\argmax}  Q( S_t, a )\n\\end{equation}\n\nNow this algorithm rests on the assumption of \\textit{exploring starts} and on the assumption of \\textit{infinite episodes}. The assumption of infinite episodes is to ensure convergence, and in practice the algorithm is usually run until the algorithm has converged by some high number of episodes. The more problematic assumption is that of exploring starts. This is due to the fact, that in reality one cannot assume that there is a non-zero probability of starting in all states $s \\in \\statespace$, and proceed the episode from that starting point. This is an essential assumption, because otherwise, one could not know the value function of unexplored states without visiting them. \n\nThe problem of not visiting every state is closely related to the exploration vs. exploitation trade-off. If an algorithm acts greedy (only exploits) new and better policies will never be discovered. The exploration of the state space can be done by either on-policy control or off-policy control. The exploration will in this paper be done by $\\epsilon$-greedy algorithms. $\\epsilon$-greedy algorithms chooses with probability $1 - \\epsilon$ a (uniformly) random action each step, else it greedily chooses the action that corresponds to the highest Q-value. The next section will give an example of both on-policy and off-policy methods. \n\n\\subsubsection{Temporal Difference Learning}\n\nTemporal Difference (TD) learning combines ideas taken from Dynamic Programming and Monte Carlo Methods. It takes from Monte Carlo methods, that you do not need a perfect model of the environment. It takes from Dynamic Programming the bootstrapping, i.e., it uses learned estimates to update, without needing the final outcome. Just as Monte Carlo methods, Temporal difference methods has a prediction and control element.\n\nTD prediction can be summarized in the equation:\n\n\\begin{equation}\n    V(S_t) \\leftarrow V(S_t) + \\alpha \\lsp R_{t+1} + \\gamma V(S_{t+1}) - V(S_t) \\rsp\n\\end{equation}\n\nThe equation states that $V(S_t)$ should be updated according to the return in a given period + the value function of the next period $V(S_{t+1})$. This method is called TD(0), since it only uses 1 step to update the value function. In essence TD methods learn a guess from a guess. Compared to MC methods the TD methods can learn at each step; update its estimate at each point in time. It is also proven, that for any policy $\\pi$ kept fixed, then a TD(0) algorithm will converge to $v^{\\pi}$ \\parencite{sutton_reinforcement_2018}. Even though, an open mathematical question, in practice it is found that TD methods converge faster than MC methods \\parencite{sutton_reinforcement_2018}.\n\nControl with temporal difference learning, can also be separated into on-policy control and off-policy control. The most used on-policy control for TD methods is called SARSA (state, action, reward, state, action). Just as with MC methods a need to trade off exploitation and exploration is present. The agent want to see new parts of the state space (exploration), but should also use (exploit) what is assumed to be the optimal choice given the value function associated with the current value function. Consider the policy generating the data being an $\\epsilon$-greedy algorithm. In this case, instead of using the value function, consider the case of using the state-action pair function $Q(S_t, A_t)$, yielding the update rule:\n\n\\begin{equation}\n    Q(S_t, A_t) \\leftarrow Q(S_t, A_t) + \\alpha \\lsp R_{t+1} + \\gamma Q(S_{t+1}, A_{t+1}) - Q(S_t, A_t) \\rsp\n\\end{equation}\n\nThis update is made after each step visiting a non-terminal state of the environment. \nNow notice here that the update rule uses the realized state $S_{t+1}$ and $A_{t+1}$. In other words the data that is used to update the estimate is the data generated from following the epsilon greedy policy! \n\nOff-policy control can be done by using Q-learning. Q-learning has the slight twist on the update rule compared to SARSA that:\n\n\\begin{equation}\n    Q(S_t, A_t) \\leftarrow Q(S_t, A_t) + \\alpha \\lsp R_{t+1} + \\gamma \\underset{a}{\\max} Q(S_{t + 1}, a) - Q(S_t, A_t) \\rsp \n\\end{equation}\nActions is still chosen by an $\\epsilon$-greedy policy, the difference here being the update rule uses a different policy than the actual policy followed. This is due to the fact that the Q-function is updated under the assumption of greedily choosing an action in time $t+1$ conditional on the state. Q-learning and double Q-learning will be explored in depth later when describing the algorithms used in this paper.\n\n\\subsection{Landmarks}\n\nFinally, a brief overview of environments/games where reinforcement learning have been instrumental to the current hype of reinforcement learning. The first big success of reinforcement learning was made by Tesauro in 1992 creating an agent capable of learning to play backgammon trough self play \\parencite{sutton_reinforcement_2018}. Using an artificial neural network to approximate the value function, and using a temporal difference algorithm, the algorithm was capable of playing expert level backgammon. In 2011 the IBM Watson algorithm won in jeopardy using the same methods as Tesauro did for his backgammon agent \\parencite{sutton_reinforcement_2018}. In 2013 the company DeepMind (now acquired by google), showed that it was possible for a reinforcement learning algorithm to learn to play video games. Here an important feat was, that it was fed the raw image input and used an artificial neural network to transform this image into a representation of the state space allowing for navigating in the environment \\parencite{mnih_playing_2013}. In 2016 DeepMind created AlphaGo and a year later AlphaGo Zero, which learned to master the game of Go. This was assumed in a long time to be a hard problem for learning algorithms due to its very large state and action space \\parencite{silver_general_2018}. The first iteration used expert players to learn the game, while the AlphaGo zero used only self play. These examples show, that the capabilities of these algorithms to learn to navigate complicated environments, might leave a way for high dimensional dynamic economic models to be solved using reinforcement learning methods.", "meta": {"hexsha": "d53e40190ac88a11308763360e2cb07ee6d31203", "size": 25655, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/rl_theory.tex", "max_stars_repo_name": "JakartaLaw/speciale", "max_stars_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/rl_theory.tex", "max_issues_repo_name": "JakartaLaw/speciale", "max_issues_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/rl_theory.tex", "max_forks_repo_name": "JakartaLaw/speciale", "max_forks_repo_head_hexsha": "95d89c281b9d8f73065a823cba97a5bedcbf129d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 118.7731481481, "max_line_length": 1640, "alphanum_fraction": 0.7705710388, "num_tokens": 6256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.43141338207559177}}
{"text": "%%\n%% Author: novitoll\n%% 2/17/18\n%%\n\n% Preamble\n\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\graphicspath{ {code/} }\n\n\\title{CVT: Lecture 3}\n\\date{2018-02-16}\n\\author{Novitoll}\n\n% Document\n\\begin{document}\n    \\maketitle\n    \\pagenumbering{arabic}\n\n    \\section{Task}\n    \\begin{enumerate}\n        \\item Get the text image\n        \\item Gray-scale it, White -> black, black <- white --> gray\n        \\item Blur, Make it common\n        \\item Thresholding binarize\n        \\item Morphology closing, reduce noize\n        \\item Find contours, bounding box\n        \\item According to the coordinates of contours, classify text from image\n    \\end{enumerate}\n\n    Note: Cropping text lines from text image by boundaries is not effective as it's not stable to the noises\n    That's why gradients (transition of W to B, B to W) are more useful in real world data\n\n    \\section{Gradients}\n\n    Apply kernel [-1, 0, 1]  as the filter to find gradients:\n\n    \\includegraphics[scale=0.7]{gradients.png}\n\n    Popular kernels:\n\n    Sobel - sum gathered in the center of matrix, can be transposed to calculate grads vertically\n    Scharr - more restricted on sides, can be applied vertically\n    Laplacian - gradients, calculates vertically and horizontally at once\n\n    \\includegraphics[scale=0.7]{filters.png}\n\n    Example of the input with the noise and how gradients of vertical projection + Sobel smoothing works\n\n    \\includegraphics[scale=0.7]{output-gradient.png}\n\n\\end{document}", "meta": {"hexsha": "ef2d53aa1a2b1fd6c8bd9d28670487aca9df5a29", "size": 1502, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "w2l1/notes.tex", "max_stars_repo_name": "Novitoll/cvt-academy-2018", "max_stars_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-02-28T10:37:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T08:51:32.000Z", "max_issues_repo_path": "w2l1/notes.tex", "max_issues_repo_name": "Novitoll/cvt-academy-2018", "max_issues_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "w2l1/notes.tex", "max_forks_repo_name": "Novitoll/cvt-academy-2018", "max_forks_repo_head_hexsha": "dc22f53241f237481a99901fb944a8fcc59aece5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3396226415, "max_line_length": 109, "alphanum_fraction": 0.7017310253, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.4314133788871876}}
{"text": "\\documentclass[a4paper]{llncs}\n\n\\usepackage{etex}\n\\usepackage{nag}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\n\\usepackage{amsmath,amssymb,stmaryrd}\n\\usepackage{cite}\n\\usepackage{tikz}\n\\usetikzlibrary{matrix,positioning,backgrounds,shapes,automata,fit}\n\\usepackage{mathpartir}\n\n\\usepackage[\n  pdftex,\n  pdfusetitle,\n  pdfborder={0 0 0}]{hyperref}\n\n\\usepackage{fixme}\n\\fxsetup{\n status=draft\n}\n\n\\renewcommand*\\sectionautorefname{Section}\n\\renewcommand*\\subsectionautorefname{Section}\n\\renewcommand*\\subsubsectionautorefname{Section}\n\\newcommand{\\etal}{\\emph{et~al.}}\n\n\\include{isamarkup}\n\\include{isadecl}\n\n\\DeclareIsaConst{ert}{\\isaconst{ert}}\n\\DeclareIsaConst{cost}{\\isaconst{cost}}\n\\DeclareIsaConst{K}{\\isaconst{K}}\n\n\\hyphenation{Isa-belle hy-poth-esis co-data-type co-data-types\n  co-al-ge-bra co-al-ge-bras co-al-ge-bra-ic co-in-duct co-in-duct-ive\n  co-in-duct-ion co-re-cur-sor co-re-cur-sors co-re-cur-sion co-re-cur-sive\n  meas-sur-able}\n\n\\pagestyle{plain}\n\n\\title{Formalising Semantics for Expected Running Time of Probabilistic Programs \\\\ (Rough Diamond)}\n\\author{Johannes Hölzl}\n\\authorrunning{J. Hölzl}\n\\titlerunning{Expected Running Time of Probabilistic Programs}\n\\institute{Fakultät für Informatik, TU München, \\email{hoelzl@in.tum.de}}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\nWe formalise two semantics observing the expected running time of pGCL programs.\nThe first semantics is a denotational semantics providing a direct computation of the running time, similar to the weakest pre-expectation transformer.\nThe second semantics interprets a pGCL program in terms of a Markov decision process (MDPs), i.e.~it provides an operational semantics.\nFinally we show the equivalence of both running time semantics.\n\nWe want to use this work to implement a program logic in Isabelle/HOL to verify the expected running time of pGCL programs.\nWe base it on recent work by Kaminski, Katoen, Matheja, and Olmedo.\nWe also formalise the expected running time for a simple symmetric random walk discovering a flaw in the original proof.\n\n\\end{abstract}\n\n\\section{Introduction}\\label{introduction}\n\nWe want to implement expected running time analysis in Isabelle/HOL based on Kaminski~\\etal~\\cite{kaminski2016ert}.\nThey present semantics and proof rules to analyse the expected running time of probabilistic guarded command language (pGCL) programs.\npGCL is an interesting programming language as it admits probabilistic and non-deterministic choice, as well as unbounded while loops~\\cite{mciver2004arp}.\n\nFollowing \\cite{kaminski2016ert}, in \\autoref{sec:mdp} we formalise two running time semantics for pGCL and show their equivalence: a denotational one expressed as expectation transformer of type \\isa{(\\tv{s} \\t{=>} \\t{ennreal}) \\t{=>} (\\tv{s} \\t{=>} \\t{ennreal})}, and a operational one defining a Markov decision process (MDP).\nThis proof follows the equivalence proof of pGCL semantics on the expectation of program variables in \\cite{hoelzl2016mdp} derived from the pen-and-paper proof by Gretz \\etal~\\cite{gretz2014pgclsem}.\n\nBased on these formalisations we analyse the simple symmetric random walk, and show that the expected running time is infinite.\nWe started with the proof provided in \\cite{kaminski2016ert}, but we discovered a flaw in the proof of the lower $\\omega$-invariant based on the denotational semantics. \nNow, our solution combines results from the probability measure of the operational semantics and the fixed point solution from the denotational semantics.\n\nBoth proofs are based on our formalisation of Markov chains and MDPs~\\cite{hoelzl2016mdp}. The formalisation in this paper is on BitBucket%\n\\footnote{\\url{https://bitbucket.org/johannes2011/avgrun}}.\n\n\\section{Preliminaries}\n\nThe formulas in this paper are oriented on Isabelle's syntax: type annotations are written \\isa{t \\hastype \\tv{t}}, type variables can be annotated with type classes \\isa{t \\hastype \\tv{t} \\hastype \\mathit{tc}} (i.e.~\\isa{t} has type \\isa{\\tv{t}} which is in type class \\isa{\\mathit{tc}}), and type constructors are written in post-fix notation: e.g.~\\isa{\\t{set}{\\tv{a}}}. We write \\isa{\\t{int}} for integers, \\isa{\\t{ennreal}} for extended non-negative real numbers: $[0, \\infty]$, \\isa{\\t{stream}{\\tv{a}}} for infinite streams of \\isa{\\tv{a}}, \\isa{\\t{pmf}{\\tv{a}}} for probability mass functions (i.e.~discrete distributions) on \\isa{\\tv{a}}. The state space is usually the type variable \\isa{\\tv{s}}.\nOn infinite streams \\isa{\\c{sdrop}~n~\\omega} drops the first $n$ elements from the stream $\\omega$: \\isa{\\c{sdrop}~0~\\omega = \\omega} and \\isa{\\c{sdrop}~(n+1)~(s{\\cdot}\\omega) = \\c{sdrop}~n~\\omega}.\n\n\\paragraph{Least fixed points}\nA central tool to define semantics are least fixed points on complete lattices: \\isa{\\tv{a}\\t{=>}(\\tv{b}\\hastype\\t{completelattice})}, \\isa{\\t{bool}}, \\isa{\\t{enat}}, and \\isa{\\t{ennreal}}.\nLeast fixed points are defined as \\isa{\\c{lfp}~f = \\bigsqcap \\{ u \\mid f\\,u \\le u \\} }.\nFor a monotone function $f$, we get the equations \\isa{\\c{lfp}\\,f = f\\,(\\c{lfp}\\,f)}.\nFixed point theory also gives nice algebraic rules: the rolling rule ``rolls'' a composed fixed point: \\isa{g\\,(\\c{lfp}\\,(\\lambda x.~f\\,(g\\,x))) = \\c{lfp}\\,(\\lambda x.~g\\,(f\\,x)))} for monotone $f$ and $g$, and the diagonal rule for nested fixed points: \\isa{\\c{lfp}\\,(\\lambda x.~\\c{lfp}\\,(f\\,x)) = \\c{lfp}\\,(\\lambda x.~f\\,x\\,x)}, for $f$ monotone in both arguments.\n\nTo use least fixed points in measure theory, countable approximations are necessary.\nThis is possible if the function $f$ is sup-continuous: $f\\,(\\bigsqcup_i C\\,i) = \\bigsqcup_i f\\,(C\\,i)$ for all chains~$C$.\nThen $f$ is monotone and \\isa{\\c{lfp}\\,f = \\bigsqcup_i f^i\\,\\bot}.\nFor our proofs we also need an induction and a transfer rule%\n\\footnote{In our formalisation, the transfer rule is stronger: expectation requires measurability, hence we restrict the elements to which we apply $\\alpha$ by some predicate~$P$.}:\n%\n\\begin{mathpar}\n\\inferrule{\\isa{\\c{mono}\\,f} \\\\\n  \\isa{\\forall x \\le \\c{lfp}\\,f.~P\\,x \\c{-->} P\\,(f\\,x)} \\\\\n  \\isa{\\forall S.~(\\forall x \\in S.~P\\,x) \\c{-->} P\\,(\\bigsqcup S)}\n}{\\isa{P\\,(\\c{lfp}\\,f)}} \\and\n\\inferrule{\\isa{\\c{supcontinuous}\\,f, g, \\textrm{and}~\\alpha} \\\\\n\\isa{\\alpha\\,\\bot \\le \\c{lfp}\\,g} \\\\ \\alpha \\circ f = g \\circ \\alpha}%\n{\\isa{\\alpha (\\c{lfp}\\,f) = \\c{lfp}\\,g}}\n\\end{mathpar}\n\n\\paragraph{Markov chains (MCs) and Markov decision processes (MDPs)}\nAn overview of Isabelle's MC and MDP theory is found in~\\cite{hoelzl2016mdp, hoelzl2013thesis}.\nA MC is defined by a transition function \\isa{K \\hastype \\tv{a}\\t{=>}\\t{pmf}{\\tv{a}}}, inducing an expectation: \\isa{\\mathbb{E}^K_s[f]} is the expectation of $f$ over all traces in $K$ starting in $s$.\nA MDP is defined by a transition function \\isa{K \\hastype \\tv{a}\\t{=>}\\t{set}{\\t{pmf}{\\tv{a}}}}, inducing the maximal expectation: \\isa{\\hat{\\mathbb{E}}^{K}_s[f]} is the supremum of all expectation of $f$ over all traces in $K$ starting in $s$.\nBoth expectations \\isa{\\mathbb{E}^K_s[f]} and \\isa{\\hat{\\mathbb{E}}^K_s[f]} have values in \\isa{\\t{ennreal}}, which is a complete lattice.\nBoth are sup-continuous on measurable functions (called \\emph{monotone convergent} in measure theory), which allows us to apply the transfer rule when $f$ is defined as a least fixed point.\nAlso both expectations support an iteration rule, i.e. we can compute them by first taking a step in $K$ and then continue in the resulting state $t$:\n%\n\\[ \\isa{\\mathbb{E}^K_s[f] = \\int_t \\mathbb{E}^K_t[\\lambda \\omega.~f(t\\cdot\\omega)] \\mathsf{d}K_s} \\quad \\textrm{and} \\quad\n\\isa{\\hat{\\mathbb{E}}^K_s[f] = \\bigsqcup_{D \\in K_s} \\int_t \\hat{\\mathbb{E}}^K_t[\\lambda \\omega.~f(t\\cdot\\omega)] \\mathsf{d}D}. \\]\n%\nWhere $t\\cdot\\omega$ is the stream constructor and $\\int f\\mathsf{d}D$ is the integral over the pmf~$D$.\n\n\\section{Probabilistic Guarded Command Language (pGCL)}\n\nThe probabilistic guarded command language (pGCL) is a simple programming language allowing probabilistic assignment, non-deterministic choice and arbitrary While-loops. A thorough description of it using the weakest pre-expectation transformer (wp) semantics is found in McIver and Morgan~\\cite{mciver2004arp}. Gretz~\\etal~\\cite{gretz2014pgclsem} shows the equivalence of wp with a operational semantics based on MDPs.\nHurd~\\cite{hurd2005pgcl} and Cock~\\cite{cock2012pgcl} provide a shallow embedding of pGCL in HOL4 and Isabelle/HOL.\nWe follow the definition in Kaminski~\\etal~\\cite{kaminski2016ert}.\n\n\\begin{figure}[t]\n\\[ \\isa{ \\begin{array}{lcl@{~|~}l}\n\\t{pgcl}{\\tv{s}} & = & \\c{Empty} ~~~~|~~~~ \\c{Skip} ~~~~|~~~~ \\c{Halt}\n& \\c{Assign}~(\\tv{s} \\t{=>} \\t{pmf}{\\tv{s}}) \\\\\n& | & \\c{Seq}~(\\t{pgcl}{\\tv{s}})~(\\t{pgcl}{\\tv{s}}) \n& \\c{Par}~(\\t{pgcl}{\\tv{s}})~(\\t{pgcl}{\\tv{s}}) \\\\\n& | & \\c{If}~(\\tv{s} \\t{=>} \\t{bool})~(\\t{pgcl}{\\tv{s}})~(\\t{pgcl}{\\tv{s}})\n& \\c{While}~(\\tv{s} \\t{=>} \\t{bool})~(\\t{pgcl}{\\tv{s}})\n\\end{array} } \\]\n\\caption{pGCL syntax}\\label{fig:syntax}\n\\end{figure}\n%\nIn \\autoref{fig:syntax} we define a datatype representing pGCL programs over an arbitrary program state of type~\\isa{\\tv{s}}.\n\\isa{\\c{Empty}} has not running time.\n\\isa{\\c{Halt}} immediately aborts the program.\n\\isa{\\c{Seq}} is for sequential composition.\n\\isa{\\c{Par}} is for non-deterministic choice, i.e.~both commands are executed and then one of the results is chosen.\n\\isa{\\c{Assign}}, \\isa{\\c{If}}, and \\isa{\\c{While}} have the expected behaviour, and all three commands require one time step.\nA probabilistic choice is possible with \\isa{\\c{Assign}~u}, where $u$ is a probabilistic state transformer (\\isa{\\tv{s} \\t{=>} \\t{pmf}{\\tv{s}}}).\nThe expected running time of \\isa{\\c{Assign}~u} weights each possible running time with the outcome of $u$.\nThe assignment is deterministic is $u$ is a Dirac distribution, i.e.~assigning probability $1$ to exactly one value.\nWe need the datatype to have a deep embedding of pGCL programs, which is necessary for the construction of the MDP.\n\n\\begin{figure}[t]\n\\begin{flalign*} \\isa{ \\begin{array}{lccl}\n\\multicolumn{4}{l}{%\n\\c{ert} \\hastype \\t{pgcl}{\\tv{s}} \\t{=>} (\\tv{s} \\t{=>} \\t{ennreal}) \\t{=>} (\\tv{s} \\t{=>} \\t{ennreal})} \\\\\n\\c{ert}~\\c{Empty} & f & = &\nf \\\\\n\\c{ert}~\\c{Skip} & f & = &\n1 + f \\\\\n\\c{ert}~\\c{Halt} & f & = & \n0 \\\\\n\\c{ert}~(\\c{Assign}~u) & f & = & 1 +\n\\displaystyle \\lambda x.\\, \\int_y f\\,y ~d(u\\,x) \\\\\n\\c{ert}~(\\c{Seq}~c_1~c_2) & f & = &\n\\c{ert}~c_1~(\\c{ert}~c_2~f) \\\\\n\\c{ert}~(\\c{Par}~c_1~c_2) & f & = &\n\\c{ert}~c_1~f \\sqcup \\c{ert}~c_2~f \\\\\n\\c{ert}~(\\c{If}~g~c_1~c_2) & f & = &\n1 + \\lambda x.\\, \\c{if} g~x \\c{then} \\c{ert}~c_1~f~x \\c{else} \\c{ert}~c_2~f~x \\\\\n\\c{ert}~(\\c{While}~g~c) & f & = &\n\\c{lfp}~(\\lambda W\\,x.\\, 1 + \\c{if} g~x \\c{then} \\c{ert}~c~W\\,x \\c{else} f~x)\n\\end{array} } \\end{flalign*}\n\\caption{Expectation transformer semantics for pGCL running times}\\label{fig:ert}\n\\end{figure}\n\n\\begin{figure}[t]\n\\[ \\isa{ \\begin{array}{lccl}\n\\multicolumn{4}{l}{%\n\\c{K} \\hastype (\\t{pgcl}{\\tv{s}} \\t{*} \\tv{s}) \\t{=>} \\t{set}{\\t{pmf}{(\\t{pgcl}{\\tv{s}} \\t{*} \\tv{s})}}} \\\\\n\\c{K} (\\c{Empty},&s) & = &\n\\c{det}{\\c{Empty}}{s} \\\\\n\\c{K} (\\c{Skip},&s) & = &\n\\c{det}{\\c{Empty}}{s} \\\\\n\\c{K} (\\c{Halt},&s) & = &\n\\c{det}{\\c{Halt}}{s} \\\\\n\\c{K} (\\c{Assign}~u,&s) & = &\n\\{ [\\lambda s'.\\, (\\c{Empty}, s')]~(u~s) \\} \\\\\n\\c{K} (\\c{Seq}~c_1~c_2,&s) & = & \\left[\\lambda (c', s').\\, \\left(\\left\\{ %\n\\begin{array}{ll}\nc_2 & \\textrm{if}~c'= \\c{Empty} \\\\\n\\c{Halt} & \\textrm{if}~c'= \\c{Halt} \\\\\n\\c{Seq}~c'~c_2 & \\textrm{otherwise}\n\\end{array} %\n\\right\\}, s'\\right)\\right]~\\c{K}~(c_1, s) \\\\\n\\c{K} (\\c{Par}~c_1~c_2,&s) & = & \n\\c{det}{c_1}{s} \\cup \\c{det}{c_2}{s} \\\\\n\\c{K} (\\c{If}~g~c_1~c_2,&s) & = &\n\\c{if} g\\, s \\c{then}~ \\c{det}{c_1}{s} ~\\c{else}~ \\c{det}{c_2}{s} \\\\\n\\c{K} (\\c{While}~g~c,&s) & = &\n\\c{if} g\\,s \\c{then}~ \\c{det}{\\c{Seq}~c~(\\c{While}~g~c)}{s} ~\\c{else}~ \\c{det}{\\c{Empty}}{s}\n\\end{array} } \\]\n%\n\\[ \\isa{ \\begin{array}{lllccl@{\\qquad\\qquad}lllccl}\n\\multicolumn{12}{l}{%\n\\c{cost} \\hastype (\\tv{s} \\t{=>} \\t{ennreal}) \\t{=>} \\t{pgcl}{\\tv{s}} \\t{=>} \\tv{s} \\t{=>} \\t{ennreal} \\t{=>} \\t{ennreal}} \\\\\n\\c{cost}~f&\\c{Empty} & s & \\c{_} & = & f s &\n\\c{cost}~\\c{_}&(\\c{Seq}~\\c{Empty}~\\c{_}) & \\c{_} & x & = & x \\\\\n\\c{cost}~\\c{_}&\\c{Halt} & \\c{_} & \\c{_} & = & 0 &\n\\c{cost}~f&(\\c{Seq}~c~\\c{_}) & s & x & = & \\c{cost}~f~c~s~x \\\\\n\\c{cost}~\\c{_}&(\\c{Par}\\;\\c{_}\\,\\c{_}) & s & x & = & x &\n\\c{cost}~\\c{_}&\\c{_} & \\c{_} & x & = & 1 + x\n\\end{array} } \\]\n\\begin{center}\n  \\isa{\\c{det}{c}{s}} is the singleton set of the singleton distribution $(c, s)$.\\\\\n  $[f]\\mu$ maps $f$ over all elements of $\\mu$\n\\end{center}\n%\n\\caption{MDP semantics for pGCL running times}\\label{fig:mdp}\n\\end{figure}\n\n\\paragraph{Expected Running Time}\n\nThe denotational semantics for the running time is given as an expectation transformer, which is similar to the denotational semantics for the expectation of program variables as weakest pre-expectation transformers.\nAgain we follow the definition in Kaminski~\\etal~\\cite{kaminski2016ert}.\nIn \\autoref{fig:ert} we define the expectation transformer \\isa{\\c{ert}} taking a pGCL command $c$ and an expectation $f$, where $f$ assigns an expected running time to each terminal state of $c$.\nThis gives a simple recursive definition of the \\isa{\\c{Seq}} case, for the expected running time of a pGCL program we will set $f = 0$.\nWe proved some validating theorems about expectation transformer \\isa{\\c{ert}}, i.e.~continuity and monotonicity of \\isa{\\c{ert}~c}, closed under constant addition for \\isa{\\c{Halt}}-free programs, sub-additivitiy, etc.  \n\n\\paragraph{MDP Semantics}\\label{sec:mdp}\n\nFor the operational small-step semantics we introduce a MDP constructed per pGCL program, and compute the expected number of steps until the program terminates.\nIn \\autoref{fig:mdp} we define the MDP by its transition function $K$ and the per-state cost function \\isa{\\c{cost}~f~c~s~x}.\nThe per-state cost \\isa{\\c{cost}~f~c~s~x} computes the running time cost associated with the program $c$ at state $s$.\nHere the program is seen as a list of statements, hence we walk along a list of \\isa{\\c{Seq}} and only look at its left-most leaf.\nIf the program is \\isa{\\c{Empty}} the MDP is stopped and we return $f~s$ containing further running time cost we want to associated to a finished state $s$ (in most cases this will be $0$, but it is essential in the induction case of \\autoref{thm:erteq}).\nWhen the execution continues we also add~$x$, c.f.~the definition of \\isa{\\c{coststream}}.\n\nThe transition function $K$ induces now a set of trace spaces, one for each possible resolution of the non-deterministic choices introduced by \\isa{\\c{Par}}.\nWe write $\\hat{\\mathbb{E}}^{K}_{(c, s)}[f]$ for the maximal expectation of \\isa{f \\hastype \\t{stream}{(\\t{pgcl}{\\tv{s}} \\t{*} \\tv{s})} \\t{=>} \\t{ennreal}} when the MDP starts in $(c, s)$.   \nWe define the cost of a trace as the sum of \\isa{\\c{cost}} over all states in the trace:\n%\n\\[ \\isa{\\c{coststream}~f~((c, s){\\cdot}\\omega) \\stackrel{\\c{lfp}}{=} \\c{cost}~f~c~s~(\\c{coststream}~f~\\omega)} \\]\n%\nFinally the maximal expectation of \\isa{\\c{coststream}} computes \\isa{\\c{ert}}:%\n\\begin{theorem}\\label{thm:erteq}\n$ \\isa{\\hat{\\mathbb{E}}^{K}_{(c, s)}[\\c{coststream}~f] = \\c{ert}~c~f~s} $\n\\end{theorem}\n\\begin{proof}[Induction on $c$] The interesting cases are \\isa{\\c{Seq}} and \\isa{\\c{While}}.\nFor \\isa{\\c{Seq}} we prove the equation \n\\isa{\\hat{\\mathbb{E}}^{K}_{(\\c{Seq}~a~b, s)}[\\c{coststream}~f] \n  = \\hat{\\mathbb{E}}^{K}_{(a, s)}[\\c{coststream}~(\\lambda s.~\\hat{\\mathbb{E}}^{K}_{(b, s)}[\\c{coststream}~f])]},\nby fixed point induction in both directions.\nFor \\isa{\\c{While}} we prove\n\\[\\isa{\\hat{\\mathbb{E}}^{K}_{(\\c{While}~g~c, s)}[\\c{coststream}~f] =\n\\c{lfp}~(\\lambda F\\;s.\\;1+\\c{if} g\\,s \\c{then} \\hat{\\mathbb{E}}^{K}_{(c, s)}[\\c{coststream}~f] \\c{else} f\\;s)\\;s}\\]\nby equating it to a completely unrolled version using fixed point induction and then massaging it in the right form using the rolling and diagonal rules. \\qed\n\\end{proof}\n\n\\section{Simple Symmetric Random Walk}\\label{sec:ssrw}\n\nAs an application for the expected running time analysis Kaminski~\\etal~\\cite{kaminski2016ert} chose the simple random walk.\nAs difference to \\cite{kaminski2016ert} we do not use $\\omega$-invariants to prove the infinite running time, but the correspondence of the program with a Markov chain (there is no non-deterministic choice).\n\nThe simple symmetric random walk (\\isa{\\c{srw}}) is a Markov chain on $\\mathbb{Z}$, in each step $i$ it goes uniformly to $i + 1$ or $i - 1$ (i.e. in both cases with probability $1/2$).\nSurprisingly, but well known (and formalised by Hurd~\\cite{hurd2002thesis}), it reaches each point with probability $1$.\nEqually surprising, the expected time for the srw to go from $i$ to $i + 1$ is infinite!\nKaminski~\\etal~\\cite{kaminski2016ert} prove this by providing a lower $\\omega$-invariant.\nUnfortunately, this proof has a flaw: in Appendix~B.1 of \\cite{kaminski2016ert-ext} (the extended version of \\cite{kaminski2016ert}), the equation $1 + \\llbracket x > 0 \\rrbracket \\cdot 2 + \\llbracket 1 < x \\le n + 1 \\rrbracket \\cdot \\infty + \\llbracket 0 < x \\le n - 1 \\rrbracket \\cdot \\infty\n= 1 + \\llbracket x > 0 \\rrbracket \\cdot 2 + \\llbracket 0 < x \\le n + 1 \\rrbracket \\cdot \\infty$\ndoes not hold for $n=0$ and $x=1$. \nThe author knows from private communication with Kaminski~\\etal~that it still is possible to use a lower $\\omega$-invariant.\nUnfortunately, the necessary invariant gets much more complicated.\n\nAfter discovering the flaw in the proof, we tried a more traditional proof.\nThe usual approach in random walk theory uses the generating function of the first hitting time.\nUnfortunately, this would require quite some formalizations in combinatorics, e.g.~Stirling numbers and more theorems about generating functions than available in \\cite{hoelzl2016mdp}. \nFinally, we choose an approach similar to \\cite{hurd2002thesis}, i.e.~we set up a linear equation system and prove that the only solution is infinity.\n\nNow, \\isa{\\c{srw} \\hastype \\t{int} \\t{=>} \\t{pmf}{\\t{int}}} is the transition function for the simple symmetric random walk.\nThe expected time to reach $j$ when started in $i$ is written \\isa{H~i~j \\stackrel{\\c{def}}{=} \\mathbb{E}^{\\c{srw}}_{i}[f~j]}, where \\isa{f~j~(k\\cdot\\omega) \\stackrel{\\c{lfp}}{=}~ \\c{if} j = k \\c{then} 0 \\c{else} 1 + f~j~\\omega} is the first hitting time.\nNow we need to prove the following rules: (I) \\isa{H~j~i = H~j~k + H~k~i} if \\isa{i \\le j \\le k},\n(II) \\isa{H~(i+t)~(j+t) = H~i~j}, (III) \\isa{H~i~j = H~j~i} and (VI) \\isa{H~i~j = (\\c{if} i = j \\c{then} 0 \\c{else} 1 + (H~i~(j+1) + H~i~(j-1)) / 2)}. From these rules we can derive $H~i~j = \\infty$ for $i \\not= j$.\n\nRule (VI) is derived the expectation transformer semantics.\nBut it is not clear to us how to prove rule (I) by only applying fixed point transformations or induction.\nInstead we prove (I) in a measure theoretic way:\n\n\\begin{align}\nH~j~k + H~k~i \n  & = \\mathbb{E}^{\\isa{\\c{srw}}}_j[f~j + H~k~i] \\nonumber\\\\\n  & = \\sum_n (n + H~k~i)\\cdot \\Pr_j(f~k = n) \\label{eq:fin}\\\\\n  & = \\isa{\\sum_n \\mathbb{E}^{\\c{srw}}_j[\\lambda \\omega.~(n + f~i~(\\c{sdrop}~n~\\omega)) \\cdot \n     \\llbracket f~k~\\omega = n\\rrbracket]} \\nonumber \\\\\n  & = \\isa{\\sum_n \\mathbb{E}^{\\c{srw}}_j[f~i]} = H~j~i \\label{eq:f}\n\\end{align}\n%\n\\autoref{eq:fin} requires that $f~k$ is finite with probability $1$, we do a case distinction: if it is not finite a.e.~the result follows from $H~j~i \\ge H~j~k = \\infty$.\n\\autoref{eq:f} is now simply proved by induction on $n$.\nThe proofs for Equations~\\ref{eq:fin} and~\\ref{eq:f} essentially operate on each trace~$\\omega$ in our probability space, making them inherently dependent on the trace space.\n\n\\begin{theorem}[The running time of \\isa{\\c{srw}} is infinite.]\n$ H~i~j = \\infty ~~\\textrm{if}~~ i \\not= j. $\n\\end{theorem}\n\n\\section{Coupon Collector}\n\nAnother example we formalised is the coupon collector example from \\cite{kaminski2016ert}.\nThe idea is to compute the expected time until we collect $N$ different coupons from a uniform, independent and infinite source of coupons.\nThe left side of \\autoref{fig:cc} shows our concrete implementation $\\mathtt{CC}_N$, the right side is its refinement (there is no array $cp$ necessary).\nBy fixed point transformations we show that the (refined) inner loop's running time has a Geometric distribution, and hence the expected running time for $\\mathtt{CC}_N$ is:\n$ \\isa{\\c{ert}~\\mathtt{CC}_N~0~s = 2 + 4N + 2N\\sum_{i = 1}^{N} \\frac{1}{i} } $ for $N>0$.\n\n\\begin{figure}\n\n\\[\n\\begin{array}{lr@{}c@{}ll}\nx := 0, cp := [\\overbrace{F, \\ldots, F}^{N~\\textrm{times}}], i := 0\n& & & &\nc := 0, b := F\n\\\\\n\\mathtt{WHILE}~x < N~\\mathtt{DO}\n& x&{\\rightarrow}&c &\n\\mathtt{WHILE}~c < N~\\mathtt{DO}\n\\\\\n\\quad \\mathtt{WHILE}~cp[i]~\\mathtt{DO}~ i :\\sim \\mathrm{Unif}\\{0, \\ldots, N\\}\n& \\quad cp[i]&{\\rightarrow}&b \\quad &\n\\quad \\mathtt{WHILE}~b~\\mathtt{DO}~ b :\\sim \\mathrm{Bern}(x/N)\n\\\\\n\\quad cp[i] := T, x := x + 1\n& & |cp| = x & &\n\\quad b := T, c := c + 1\n\\\\\n\\end{array}\n\\]\n\n\\caption{The Coupon Collector in pGCL and its refinement}\\label{fig:cc}\n\\end{figure}\n\n\\section{Related Work}\n\nThe first formalisation of probabilistic programs was by Hurd~\\cite{hurd2002thesis} in \\texttt{hol98}, formalising a trace space for a stream of probabilistic bits.\nHurd~\\etal~\\cite{hurd2005pgcl} is different approach, formalising the weakest pre-expectation transformer semantics of pGCL in HOL4.\nBoth formalisations are not related.\nAudebaud and Paulin-Mohring~\\cite{audebaud2009randomizedalgos} use a shallow embedding of a probability monad in Coq.\n\n\\pagebreak\n\\noindent \nCock~\\cite{cock2012pgcl} provides a VCG for pGCL in Isabelle/HOL.\nHölzl and Nipkow~\\cite{hoelzl2012casestudies, hoelzl2013thesis} formalises MCs and analyses the expected running time of the ZeroConf protocol.\nOn the basis of \\cite{hoelzl2013thesis} formalises MDPs and shows the equivalence of the weakest pre-expectation transformer (based on the pen-and-paper proof in \\cite{gretz2014pgclsem}).\n\nUnlike \\autoref{thm:erteq}, these formalisations either define denotational semantics~\\cite{hurd2005pgcl, audebaud2009randomizedalgos, cock2012pgcl}, or operational semantics~\\cite{hurd2002thesis, hoelzl2012casestudies, hoelzl2013thesis}, none of them relate both semantics.\n\n\\section{Conclusion and Future Work}\n\nWhile formalising the random walk example in \\cite{kaminski2016ert} we found an essential flaw in the proof in\\cite{kaminski2016ert-ext}.\nOur solution seams to indicate, that for the verification of expected running times an $\\omega$-invariant approach is not enough.\nWhile the expectation transformer gives us a nice verification condition generator (e.g.~\\cite{cock2012pgcl}), the trace space might be required to get additional information i.e.~fairness and termination.\nThe equivalence between the expectation transformer semantics and the MDP semantics provides the required bridge between both worlds.\nAlso we might require a probabilistic, relational Hoare logic (maybe based on \\cite{lochbihler2016proboracles}) to automate tasks like \\autoref{fig:cc}.\n\n\\bibliographystyle{lncs}\n\n\\bibliography{itp2016}\n\n\\end{document}\n", "meta": {"hexsha": "99b50e046ebf769e7326256088f78aa0db16cbf5", "size": 23006, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "itp2016/main.tex", "max_stars_repo_name": "maxhaslbeck/verERT", "max_stars_repo_head_hexsha": "193188292620a60005e528a78247323eb53084bc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "itp2016/main.tex", "max_issues_repo_name": "maxhaslbeck/verERT", "max_issues_repo_head_hexsha": "193188292620a60005e528a78247323eb53084bc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-12-17T14:00:52.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-18T18:16:20.000Z", "max_forks_repo_path": "itp2016/main.tex", "max_forks_repo_name": "maxhaslbeck/verERT", "max_forks_repo_head_hexsha": "193188292620a60005e528a78247323eb53084bc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.8579234973, "max_line_length": 705, "alphanum_fraction": 0.694210206, "num_tokens": 8035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4314133756987834}}
{"text": "As discussed in Sec.~\\ref{sec:pp_physics_jets}, color confinement prevents the existence of free quarks and gluons.\nA quark or gluon produced at the LHC typically undergoes hadronization and presents itself in the detector as a collection of collimated particles.\nJets are built from PF candidates, using the anti-$k_{\\text{T}}$ clustering algorithm~\\cite{Cacciari:2008gp,Cacciari:2011ma} with a distance parameter of 0.4.\nThe input PF candidates have charged hadron subtraction (CHS) applied, meaning charged hadrons associated with vertices other than the primary vertex of that event are removed.\nCHS reduces the contribution of particles originating from pileup vertices.\nOnce the jets are built from PF candidates, three steps are taken to correct the jets' energies.\n\nFirst, a pileup offset correction is applied to remove additional jet contributions from pileup not removed by CHS.\nThe pileup contributions not remove by CHS are primarily charged hadrons not matched to a good vertex and PF photons.\nThe individual jet energies are corrected by a multiplicative factor derived in simulation, parametrized in bins of jet area ($A$), $\\rho, \\pT,$ and $\\eta$.\nTypical values for the pileup offset corrections are shown in Fig.~\\ref{fig:evt_jet_pu_corrections}.\n\\begin{figure} [h!]\n    \\centering\n    \\begin{tabular}{c c}\n        \\includegraphics[width=0.48\\linewidth]{figures/event_reconstruction_and_selection/jetmet8Tev_Figure_009-c.png} &\n        \\includegraphics[width=0.48\\linewidth]{figures/event_reconstruction_and_selection/jetmet8Tev_Figure_009-d.png}\n    \\end{tabular}\n    \\caption{Pileup offset correction values as a function of jet \\pT (left) and jet $|\\eta|$ (right). Taken from~\\cite{Khachatryan_2017_jets}.}\n    \\label{fig:evt_jet_pu_corrections}\n\\end{figure}\n\nSecond, jet energy scale corrections designed to correct for the detector response to jets are derived in simulation, again in bins of jet area ($A$), $\\rho, \\pT,$ and $\\eta$.\nThe goal of this step is to correct the reconstructed jet energy to match that of the true jet energy (only available in simulation).\nTypical values for the jet energy scale corrections are shown in Fig.~\\ref{fig:evt_jet_jec_corrections}. \n\\begin{figure} [h!]\n    \\centering\n    \\begin{tabular}{c c}\n        \\includegraphics[width=0.48\\linewidth]{figures/event_reconstruction_and_selection/jetmet8Tev_Figure_014-a.png} &\n        \\includegraphics[width=0.48\\linewidth]{figures/event_reconstruction_and_selection/jetmet8Tev_Figure_014-b.png}\n    \\end{tabular}\n    \\caption{Jet energy scale correction values as a function of jet \\pT (left) and jet $|\\eta|$ (right). Taken from~\\cite{Khachatryan_2017_jets}.}\n    \\label{fig:evt_jet_jec_corrections}\n\\end{figure}\n\nThird, remaining differences between data and simulation are corrected with a residual correction applied to data, derived as a function of \\pT and $\\eta$.\nA variety of event topologies ($\\gamma$ + jets, \\Zee + jets, \\Zuu + jets, and di-jet) are used to derive these corrections.\nIn each topology, the underlying strategy is the same: exploit the momentum conservation in the transverse plane betwen a well-measured reference object and the jet to be corrected.\nThe fact that the reference object ($\\gamma$, \\Zee, \\Zuu, a well-measured central jet) is well-measured allows us to infer the true energy of the jet to be corrected.\nThe full details of these procedures are described in Ref.~\\cite{Khachatryan_2017_jets}.\n\nJets used in the \\ttH analysis are first corrected with the procedures described in this section.\nThey are further required to have $\\pT > 25$ GeV and $|\\eta| < 2.4$ and must pass a loose pileup jet ID criteria.\nThe loose pileup jet ID criteria is based on a BDT designed to discriminate between jets originating from pileup interactions and those originating from the primary vertex in the event.\nThe BDT is trained with variables describing the jets' shape as well as additional track information.\nJets are finally also required to not be overlapping with any photons or leptons in the event, requiring $\\Delta R(\\text{jet}, \\text{photon/lepton}) > 0.4$.\n\n\\subsubsection*{b-Tagged Jets}\nHadronic jets at the LHC typically result from the hadronization of either a quark or gluon (with the exception of top quarks, which decay before they are able to hadronize).\nJets originating from a light-flavor quark (u,d,s) or a gluon are typically indistinguishable in the CMS detector.\nHowever, jets originating from c or b quarks often have distinguishing features. \nWhile hadrons containing only light-flavor quarks (as would typically be produced by the hadronization of a light-flavor quark or a gluon) often reach the calorimeters before decaying, hadrons containing b quarks tend to decay on a length scale of a few millimeters when produced at typical LHC energies.\nHadrons containing charm quarks frequently decay even sooner than this.\nThe resolution of the tracker is sufficient to distinguish the vertices of these decays, called ``secondary vertices'', from the primary vertices in the event.\n\nJet flavor tagging algorithms attempt to exploit information about the secondary vertices associated with a given jet to determine the flavor of the quark (or gluon) it originated from.\nMachine learning algorithms are often used to classify jet flavor, using information about the secondary vertices, tracks, and pf candidates associated with a given jet.\nRecently, algorithms built with deep neural networks have shown significantly improved jet flavor tagging performance over more traditionally used methods, such as those based on boosted decision trees~\\cite{Guest_2016}.\nThe DeepCSV~\\cite{Sirunyan_2018_deepcsv} algorithm is one such DNN-based tagger.\nFor a given jet, the algorithm assigns multiple flavor scores, indicating its degree of certainty that the jet originated from a quark of that flavor.\nDeepCSV outputs scores corresponding to its degree of certainty that the jet originated from a b quark, c quark, light flavor quark (u,d,s) or gluon, and a \\bb pair (four scores).\nThe performance of DeepCSV (purple) and other commonly used jet flavor algorithms is shown in Fig.~\\ref{fig:evt_jet_btag}.\n\\begin{figure} [h!]\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/event_reconstruction_and_selection/deepcsv_Figure_016.png}\n    \\caption{Misidentification rate as a function of b-tagging efficiency, shown for b vs. c jet discrimination (dotted lines) and b vs. light jet discrimination (solid lines). Taken from~\\cite{Sirunyan_2018_deepcsv}.}\n    \\label{fig:evt_jet_btag}\n\\end{figure}\n\nJet flavor tagging is particularly useful for the \\ttH analysis, as two b quarks are produced in the decay of the \\ttb pair.\nAs the multi-jet, \\gjets, and \\dipho backgrounds primarily feature jets originating from light flavor quarks or gluons, the ability to select b-tagged jets allows for rejection of a significant component of the overall background.\n", "meta": {"hexsha": "6e4ffcf5e79b73839639d8ebbfc8ed82b36cdf21", "size": 6907, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "event_reconstruction_and_selection/jets.tex", "max_stars_repo_name": "sam-may/phd_thesis", "max_stars_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "event_reconstruction_and_selection/jets.tex", "max_issues_repo_name": "sam-may/phd_thesis", "max_issues_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "event_reconstruction_and_selection/jets.tex", "max_forks_repo_name": "sam-may/phd_thesis", "max_forks_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.2816901408, "max_line_length": 304, "alphanum_fraction": 0.7915158535, "num_tokens": 1658, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4314133756987834}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on ??\n\n\\section{Minimal Polynomials}\n\\label{sec:minimal_polynomials}\n\n\\begin{prop}\n\tLet \\(\\alpha \\) be an algebraic element over \\(F\\).\n\t\\begin{enumerate}[(a).]\n\t\t\\item Then there exists a monic irreducible polynomial of minimal degree \\(m_{\\alpha ,F}(x) \\in F[x]\\) which has \\(\\alpha \\) as a root.\n\t\t\\item A polynomial \\(f(x) \\in F[x]\\) has \\(\\alpha \\) as a root if and only if \\(m_{\\alpha ,F}(x) \\mid f(x)\\) in \\(F[x]\\).\n\t\t\\item The polynomial \\(m_{\\alpha ,F}(x)\\) with the property in (a) is unique.\n\t\\end{enumerate}\n\\end{prop}\nWe can see the minimal polynomial must be irreducible, because otherwise one of its factors would have \\(\\alpha \\) as a root and hence has degree smaller than \\(m_{\\alpha ,F}(x)\\), contradicting our hypothesis. The divisibility \\(m_{\\alpha ,F}(x) \\mid f(x)\\) follows from the division algorithm in \\(F[x]\\). The divisibility and minimality conditions together give uniqueness.\n\\begin{cor}\n\tIf \\(K / F\\) is a field extension, and \\(\\alpha \\) is algebraic over both \\(F\\) and \\(K\\), then \\(m_{\\alpha ,K}(x)\\) divides \\(m_{\\alpha ,F}(x)\\) in \\(K[x]\\).\n\\end{cor}\nThis directly follows as \\(m_{\\alpha ,F}(x)\\) has a root \\(\\alpha \\) in \\(K\\) and hence (b) gives us divisibility.\n\\begin{defn}\n\tThe polynomial \\(m_{\\alpha ,F}(x)\\) is called the \\textbf{minimal polynomial of \\(\\alpha \\) over \\(F\\)}. The degree of \\(m_\\alpha (x)\\) is called the \\textbf{degree of \\(\\alpha \\)}.\\\\\n\nIn other words, the minimal polynomial of \\(\\alpha \\) over \\(F\\) is a monic irreducible polynomial over \\(F\\) that has \\(\\alpha \\) as a root. Alternatively, it is a monic polynomial over \\(F\\) of minimal degree with \\(\\alpha \\) as a root-- both imply the other.\n\\end{defn}\n\n\\begin{prop}\n\tLet \\(\\alpha \\) be algebraic over \\(F\\). Then\n\t\\begin{align*}\n\t\tF(\\alpha ) \\cong F[x] / (m_{\\alpha }(x))\n\t\\end{align*}\n\tSo that \\([F(\\alpha ):F] = \\textrm{deg}m_{\\alpha }(x) \\equiv \\textrm{deg}\\alpha\\).\n\\end{prop}\n\n\\begin{prop}\n\tAn element \\(\\alpha  \\in F\\) is algebraic over \\(F\\) if and only if the simple extension \\(F(\\alpha ) / F\\) is finite.\\\\\n\n\tIf \\(\\alpha \\in K\\) with \\([K:F] = n\\), then \\(\\textrm{deg}(\\alpha) \\leq n\\).\n\\end{prop}\nThis follows by applying linear dependence to powers \\(\\alpha^i\\) with \\(i = 0,1,\\ldots,n\\).\n\\begin{cor}\n\tIf \\(K / F\\) is finite, then \\(K / F\\) is algebraic.\n\\end{cor}\n\n\\begin{exmp}\n\tTake \\(F\\) to be a field with \\(\\textrm{char}(F) \\neq 2\\). Consider \\(K/F\\) of degree 2, which is hence algebraic. Let \\(\\alpha  \\in K / F\\) so that \\(\\alpha \\) is a root of a polynomial over \\(F\\) of degree 1 or 2. Because \\(\\alpha \\not\\in F\\), the polynomial must has degree 2.\\\\\n\n\tThis implies that \\(m_{\\alpha ,F}(x) = x^2+bx+c\\) for \\(b,c \\in F\\). This implies that \\(F(\\alpha )\\) has the same dimension of \\(K\\) and hence \\(K = F(\\alpha )\\) (as \\(K\\) is a field extension of \\(F(\\alpha )\\). This implies that \\(K = F(\\sqrt{b^2-4ac} )\\) and so any degree 2 extension of a field \\(F\\) with characteristic not equal to \\(2\\) is of the form \\(F(\\sqrt{D} )\\) for \\(D\\) a non-square element of \\(F\\).\\\\\n\n\tConversely, for such a field, \\([F(\\sqrt{D} ) : F] = 2\\) and hence extensions of the form \\(F(\\sqrt{D} ) / F\\) are called \\textbf{quadratic extensions of \\(F\\)}.\n\\end{exmp}\n\\end{document}\n", "meta": {"hexsha": "27666ab78f7321faff1a4fea95f90218bed48bdc", "size": 3664, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture16 - MinimalPoly.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture16 - MinimalPoly.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture16 - MinimalPoly.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.1014492754, "max_line_length": 419, "alphanum_fraction": 0.6509279476, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032313, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.4313120917843759}}
{"text": "\\documentclass[9pt,a4paper]{article}\n\n\\usepackage{amsmath,amsfonts,mathrsfs, amssymb, amsthm}\n\\usepackage{calc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{comment}\n\\usepackage{nicefrac}\n\\usepackage{todonotes}\n\\usepackage{abstract}\n\\usepackage{subfig}\n\\usepackage{rotating}\n\\usepackage{setspace}\n\n\\usepackage{ulem}\n\\normalem\n\n\\usepackage{titlesec}\n\\titleformat{\\section}{\\large\\bfseries}{\\thesection}{1em}{}\n\\titleformat{\\subsection}{\\normalsize\\bfseries}{\\thesubsection}{1em}{}\n\n\\usepackage[english]{babel}\n\\usepackage[round]{natbib}\n\n%\\setlength{\\parindent}{0in}\n\\usepackage{paralist}\n\\usepackage{fancyhdr,lastpage}\n\n\\usepackage{color,hyperref}\n\n%\\setstretch{baselinestretch}\n\n\\usepackage{tabularx}\n\\newcolumntype{R}[1]{>{\\raggedleft\\arraybackslash}p{#1}}\n\n\\newcommand{\\tab}{\\hspace{4 pt}~}\n\n\\newcommand{\\st}{\\text{s.t.} \\quad}\n\\newcommand{\\free}{\\text{ (free) } }\n\\newcommand{\\botcomma}{\\; , \\,}\n\n\\newcommand{\\fixedx}{\\mathbf{\\overline{x}_i}}\n\\newcommand{\\upfixedx}{^{\\mathbf{(\\overline{x}_i)}}}\n\\newcommand{\\one}{\\mathbf{1}}\n\\newcommand{\\zero}{\\mathbf{0}}\n\\newcommand{\\upone}{^{\\mathbf{(1)}}}\n\\newcommand{\\upzero}{^{\\mathbf{(0)}}}\n\n\\newcommand{\\on}{^{\\,\\text{on}}}\n\\newcommand{\\off}{^{\\,\\text{off}}}\n\n\\DeclareMathOperator*{\\argmin}{\\arg \\min}\n\n\\title{\\Large An exact solution method for \\\\ binary equilibrium problems with compensation \\\\ \n\tand the power market uplift problem\n\\author{\\normalsize Daniel Huppmann, Sauleh Siddiqui \\\\\n\t\\small huppmann@iiasa.ac.at, siddiqui@jhu.edu\n}\n\\date{\\normalsize Mathematical cheat sheet, \\today}\n}\n\n% Linearize variables, relax constraints\n% We call it \"binary quasi-equilibrium\"\n\n\\begin{document}\n\\maketitle\n\nThis document summarizes the mathematical formulation \nfor easier reference of the GAMS implementation \nprovided under an open-source license on GitHub\n(\\url{http://danielhuppmann.github.io/binary_equilibrium/}). \nAll equation numbers in this document are identical \nto the published version of the manuscript.\n\n\\vspace{4 pt} \\noindent\nPlease cite as: \n\\newline \nD.~Huppmann and S.~Siddiqui. \nAn exact solution method for binary equilibrium problems with compensation\nand the power market uplift problem. \n\\newline\n\\emph{European Journal of Operation Research}, 266(2):622-638, 2018 \\\\ \ndoi: \\href{https://dx.doi.org/10.1016/j.ejor.2017.09.032}{10.1016/j.ejor.2017.09.032}\n\n\\section*{Theoretical formulation (Section 3.4)}\n\n\\setcounter{equation}{13}\n\\begin{subequations} \\label{model:overall:problem}\n\\begin{align}\n\\min_{\n\\substack{x_i,y_i,\n\\widetilde{y}\\upfixedx_i,\\widetilde{\\lambda}\\upfixedx_i \\\\  \\kappa\\upfixedx_i,\\zeta\\upfixedx_i}}\n\\quad F\\Big(\\big(x_i,y_i\\big)_{i \\in I}\\Big) + G\\Big(\\big(\\zeta\\upfixedx_i\\big)_{i \\in I}\\Big) \\hspace{3 cm} \\label{model:overall:problem:objective}\n\\end{align}\n\\vspace{-0.5 cm}\\begin{align}\n% first order conditions of y_i (specific formulation 1)\n\\st \\nabla_{y_i} \\, f_i\\Big(\\one,\\widetilde{y}_i\\upone,y_{-i}\\Big) + \\big(\\widetilde{\\lambda}_i\\upone\\big)^T \\nabla_{y_i} \\, g_i\\Big(\\one,\\widetilde{y}_i\\upone\\Big) &= 0 \\label{model:overall:problem:KKT:1}\\\\\n%\n0 \\leq - g_i\\Big(\\one,\\widetilde{y}_i\\upone \\Big)& \\ \\bot \\ \\widetilde{\\lambda}_i\\upone \\geq 0 \\label{model:overall:problem:KKT:constraints:1} \\\\\n% first order conditions of y_i (specific formulation 0)\n\\nabla_{y_i} \\, f_i\\Big(\\zero,\\widetilde{y}_i\\upzero,y_{-i}\\Big) + \\big(\\widetilde{\\lambda}_i\\upzero\\big)^T \\nabla_{y_i} \\, g_i\\Big(\\zero,\\widetilde{y}_i\\upzero\\Big) &= 0 \\label{model:overall:problem:KKT:0}\\\\\n%\n0 \\leq - g_i\\Big(\\zero,\\widetilde{y}_i\\upzero \\Big)& \\ \\bot \\ \\widetilde{\\lambda}_i\\upzero \\geq 0 \\label{model:overall:problem:KKT:constraints:0} \\\\\n% incentive compatibility\nf_i\\Big(\\one,y_i\\upone,y_{-i}\\Big) + \\kappa_i\\upone - \\zeta_i\\upone - \\kappa_i\\upzero + \\zeta_i\\upzero&= f_i\\Big(\\zero,y_i\\upzero,y_{-i}\\Big) \\label{model:overall:problem:incentive} \\\\\n% translation\n\\kappa_i\\upone + \\zeta_i\\upone&\\leq  x_i \\, \\widetilde{K}  \\label{model:overall:problem:duals1} \\\\\n\\kappa_i\\upzero + \\zeta_i\\upzero&\\leq \\big(1-x_i\\big) \\, \\widetilde{K}  \\label{model:overall:problem:duals0} \\\\\n% % % translation of individual optimal solution to other players\n\\widetilde{y}_i\\upzero - x_i \\, \\widetilde{K} \\leq y_i &\\leq \\widetilde{y}_i\\upzero + x_i \\, \\widetilde{K}  \\label{model:overall:problem:translate0} \\\\\n\\widetilde{y}_i\\upone - \\big(1-x_i \\big) \\, \\widetilde{K} \\leq\ny_i &\\leq \\widetilde{y}_i\\upone + \\big(1-x_i \\big) \\, \\widetilde{K} \\label{model:overall:problem:translate1} \\\\\nx_i \\in \\{0,1\\}, \\big(y_i,\\widetilde{y}_i\\upfixedx \\big) \\in \\mathbb{R}^{3m}, \\big(\\lambda_i\\upfixedx, \n& \\kappa_i\\upfixedx,\\zeta_i\\upfixedx\\big) \\in \\mathbb{R}_+^{2k+4}\n \\nonumber\n\\end{align}\n\\end{subequations}\n\n\\vfill\n\\newpage\n\\setcounter{table}{1}\n\\begin{table}\n\t\\begin{center}\n\t\t\\begin{small}\n\t\t\t\\begin{tabular}{p{0.1 cm}p{1.9 cm}@{ ... }p{8.5 cm}}\n\t\t\t\t\\hline\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{3}{l}{\\textbf{Sets \\& Mappings}} \\\\\n\t\t\t\t&$n,m \\in N$\t& nodes \\\\\n\t\t\t\t&$t \\in T$\t\t& time step, hours \\\\\n\t\t\t\t&$i \\in I$\t\t& generators, power plant units \\\\\n\t\t\t\t&$j \\in J$\t\t& load, demand units \\\\\n\t\t\t\t&$l \\in L$\t\t& power lines \\\\\n\t\t\t\t&$i \\in I_n, j \\in J_n$ & generator/load unit mapping to node $n$ \\\\\n\t\t\t\t&$n(i), n(j)$ & node mapping to generator $i$/load unit $j$ \\\\\n\t\t\t\t&$\\phi \\in \\Phi$\t& set of dispatch options (schedules) for each generator \\\\\n\t\t\t\t&$t \\in T_\\phi$\t& hours in which a generator is active in dispatch option $\\phi$ \\\\\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{3}{l}{\\textbf{Primal variables}} \\\\\n\t\t\t\t&$x_{ti}$\t\t& on/off decision for generator $i$ in hour $t$ \\\\\n\t\t\t\t&$z\\on_{ti},z\\off_{ti}$ & inter-temporal start-up/shut-down decision \\\\\n\t\t\t\t&$y_{ti}$\t\t& actual generation by generator $i$ in hour $t$ \\\\\n\t\t\t\t&$y\\on_{ti}$\t\t& generation if binary variable is fixed at $\\fixedx$ \\\\\n\t\t\t\t&$d_{tj}$\t\t& demand by unit $j$ in hour $t$ \\\\\n\t\t\t\t&$\\delta_{tn}$\t& voltage angle \\\\\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{3}{l}{\\textbf{Dual variables}} \\\\\n\t\t\t\t&$\\alpha\\on_{ti},\\beta\\on_{ti}$\t& dual to minimum activity/maximum generation capacity \\\\\n\t\t\t\t&$\\nu_{tj}$\t\t\t& dual to maximum load constraint \\\\\n\t\t\t\t&$\\mu^+_{tl},\\mu^-_{tl}$ & dual to voltage angle band constraints \\\\\n\t\t\t\t&$\\xi^+_{tn},\\xi^-_{tn}$ & dual to thermal line capacity constraints \\\\\n\t\t\t\t&$\\gamma_t$\t& dual to slack bus constraints \\\\\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{3}{l}{\\textbf{Switch and compensation variables}} \\\\\n\t\t\t\t&$p_{tn}$\t\t& locational marginal price \\\\\n\t\t\t\t&$\\kappa\\on_{ti},\\kappa\\off_{ti}$\t& switch value (defined per time step)\\\\\n\t\t\t\t&$\\zeta_{i}$ & compensation payment (defined over entire time horizon) \\\\\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{3}{l}{\\textbf{Parameters}} \\\\\n\t\t\t\t&$c^G_{i}$\t\t& linear generation costs \\\\\n\t\t\t\t&$c\\on_i,c\\off_i$\t\t& start-up/shut-down costs \\\\\n\t\t\t\t&$c^D_{\\phi}$\t\t& commitment costs in dispatch option $\\phi$ (start-up, shut-down)\\\\\n\t\t\t\t&$g^{min}_i$\t\t& minimum activity level if power plant is online \\\\\n\t\t\t\t&$g^{max}_i$\t\t& maximum generation capacity \\\\\n\t\t\t\t&$x^{init}_i$\t\t& power plant status at start of model horizon ($t=0$)\\\\\n\t\t\t\t&$u^D_{tj}$\t\t\t& utility of demand unit $j$ for using electricity \\\\\n\t\t\t\t&$d^{max}_{tj}$\t& maximum load of unit $j$ \\\\\n\t\t\t\t&$f^{max}_l$\t\t& thermal capacity of power line $l$ \\\\\n\t\t\t\t&$B_{nk},H_{lk}$\t\t\t& line/node susceptance/network transfer matrices \\\\\n\t\t\t\t\\hline\n\t\t\t\t\\hline\n\t\t\t\\end{tabular}\n\t\t\\end{small}\n\t\t\\caption{Notation for the nodal power market problem} \\label{table:example:notation}\n\t\\end{center}\n\\end{table}\n\n\\section*{The power market application (Section 4)} \\label{sec:example}\n\\setcounter{equation}{15}\n\n\\subsubsection*{The generator's optimization problem}\nEach generator~$i \\in I$ seeks to maximize her profits from generating and selling electricity over the time horizon $t \\in T$:\n\\begin{subequations} \\label{example:generator:optimization}\n\\begin{align} \n\\min_{x_{ti},y_{ti},z\\on_{ti},z\\off_{ti}} &\\quad  - p_{tn(i)} y_{ti} + c^G_{i} y_{ti} + c\\on_{i} z\\on_{ti} + c\\off_{i} z\\off_{ti}  \\label{example:generator:objective} \\\\\n&\\st x_{ti} g_i^{min} \\leq y_{ti} \\leq x_{ti} g_i^{max} \\quad \\big(\\alpha\\on_{ti},\\beta\\on_{ti}\\big)  \\label{example:generator:con:generation} \\\\\n& \\hspace{0.8 cm} x_{ti} - x_{(t-1)i} = z\\on_{ti} - z\\off_{ti} \\label{example:generator:con:intertemporal} \\\\\n& \\hspace{1 cm} x_{ti} \\in \\{0,1\\}, \\quad y_{ti},z\\on_{ti},z\\off_{ti}  \\in \\mathbb{R}_+ \\nonumber\n\\end{align}\n\\end{subequations}\n\n\n\\subsubsection*{Demand for electricity and network constraints}\nThe other side of the market is a player seeking to maximize the welfare (utility) of consumers while guaranteeing feasibility of the transmission system, given locational marginal prices~$p_{tn}$.\nA set of units~$j \\in J$ consume electricity (load~$d_{tj}$), each located at a specific node~$n(j)$. The sets~$I_n$ and~$J_n$ are the generators and load units located at node~$n$, respectively. There are a set of power lines~$l \\in L$ connecting the nodes; the direct-current load flow (DCLF) characteristics are captured using the susceptance matrix~$B_{nm}$ (node-to-node) and network transfer matrix~$H_{nl}$ (node-to-line mapping). This approach is equivalent to a power transfer distribution factor (PTDF) matrix. \n\\setcounter{equation}{17}\n\n\\begin{subequations}\\label{example:ISO:optimization}\n\\begin{align}\n\\min_{d_{tj}, \\delta_{tn}} \\quad \\sum_{j \\in J} p_{tn(j)} \\big(d_{tj} + \\sum_{m \\in N} B_{nm} \\delta_{tm} \\big) - u^D_{tj} d_{tj} &\n\\label{example:ISO:optimization:objective} \\\\\n\t\\st d^{max}_{tj} - d_{tj} \\geq 0 &\\quad (\\nu_{tj}) \\label{example:ISO:optimization:demand:max} \\\\[4 pt]\nf^{max}_l - \\sum_{n \\in N} H_{ln} \\delta_{tn} \\geq 0 &\\quad (\\mu^+_{tl}) \\label{example:ISO:optimization:flow:pos} \\\\[-2 pt]\nf^{max}_l + \\sum_{n \\in N} H_{ln} \\delta_{tn} \\geq 0 &\\quad (\\mu^-_{tl})\\label{example:ISO:optimization:flow:neg} \\\\[-4 pt]\n\\pi - \\delta_{tn} \\geq 0 &\\quad (\\xi^+_{tn}) \\label{example:ISO:optimization:angle:pos} \\\\[2 pt]\n\\pi + \\delta_{tn} \\geq 0 &\\quad (\\xi^-_{tn}) \\label{example:ISO:optimization:angle:neg} \\\\[2 pt]\n\\delta_{t\\hat{n}} = 0  & \\quad (\\gamma_t) \\label{example:ISO:slackbus}\n\\end{align}\n\\end{subequations}\n\n\n\\subsubsection*{The bi-level multi-objective program}\n\\begin{subequations} \n\\begin{align}\n\\min \\ \\sum_{t \\in T} \\bigg[\n\\sum_{i \\in I} c^G_{i} y_{ti} + c\\on_{i} z\\on_{ti} + c\\off_{i} z\\off_{ti}\n- \\sum_{j \\in J} & u^D_{tj} d_{tj}\n\\bigg]\n+ \\sum_{i \\in I} \\zeta_i \n\t\\tag{20a} \\label{example:MO:optimization} \\\\[5 pt]\n% subject to energy balance constraint at each node\n\\st \\sum_{j \\in J_n} d_{tj} - \\sum_{i \\in I_n} y_{ti} + \\sum_{m \\in N} B_{nm} \\delta_{tm} = 0 &\n\\tag{20b} \\label{example:MO:MBC} \\\\ \n% demand stationarity condition and network feasibility constraints\n0 \\leq - u^D_{tj} + p_{tn(j)} + \\nu_{tj} &\\quad \\bot \\quad d_{tj} \\geq 0 \n\t\\tag{19a} \\label{example:ISO:KKT:demand} \\\\[2 pt]\n0 = \\sum_{m\\in N} B_{mn} p_{tm} \n+ \\sum_{l \\in L} H_{ln} \\big( \\mu^+_{tl} - \\mu^-_{tl}\\big) \\quad & \\nonumber \\\\[- 4 pt]\n+ \\xi^+_{tn} - \\xi^-_{tn} - \n\\genfrac\\{\\}{0pt}{0}{\\gamma_t \\quad \\text{if }n = \\hat{n}}{0 \\quad \\text{else} \\hspace{0.55 cm}}\n& \\quad \\botcomma \\quad \\delta_{tn} \\free \\tag{19b} \\label{example:ISO:KKT:delta} \\\\\n0 \\leq d^{max}_{tj} - d_{tj} &\\quad \\bot \\quad \\nu_{tj} \\geq 0 \n\t\\tag{19c} \\label{example:ISO:KKT:demand:max} \\\\\n0 \\leq f^{max}_l - \\sum_{n \\in N} H_{ln} \\delta_{tn} &\\quad \\bot \\quad \\mu^+_{tl} \\geq 0 \n\t\\tag{19d} \\label{example:ISO:KKT:flow:pos} \\\\\n0 \\leq f^{max}_l + \\sum_{n \\in N} H_{ln} \\delta_{tn} &\\quad \\bot \\quad  \\mu^-_{tl} \\geq 0\n\t\\tag{19e}  \\label{example:ISO:KKT:flow:neg} \\\\\n0 \\leq \\pi - \\delta_{tn} &\\quad \\bot \\quad \\xi^+_{tn} \\geq 0\n\t\\tag{19f}  \\label{example:ISO:KKT:angle:pos} \\\\\n0 \\leq \\pi + \\delta_{tn} &\\quad \\bot \\quad \\xi^-_{tn} \\geq 0 \n\t\\tag{19g} \\label{example:ISO:KKT:angle:neg} \\\\[2 pt]\n0 = \\delta_{t\\hat{n}}  &\\quad \\botcomma \\quad \\gamma_t \\free \n\t\\tag{19h} \\label{example:ISO:KKT:slackbus} \\\\\n% generator optimality conditions (for x=1)\n0 = c^G_{i} - p_{tn(i)} + \\beta\\on_{ti} - \\alpha\\on_{ti} &\\quad \\botcomma \\quad y\\on_{ti} \\free \n\t\\tag{17a} \\\\\n0 \\leq - g^{min}_{ti} + y\\on_{ti} &\\quad \\bot \\quad \\alpha\\on_{ti} \\geq 0 \n\t\\tag{17b} \\label{example:generator:KKT:min} \\\\\n0 \\leq g^{max}_{ti} - y\\on_{ti} &\\quad \\bot \\quad \\beta\\on_{ti} \\geq 0 \n\t\\tag{17c} \\label{example:generator:KKT:max} \\\\\n% binary equilibrium formulation\nx_{(t-1)i} + z\\on_{ti} - z\\off_{ti} = x_{ti} &\n\t\\tag{21a} \\label{example:BNE:generator:intertemporal} \\\\\n\\beta\\on_{ti} g^{max}_{ti} - \\alpha\\on_{ti} g^{min}_{ti} - \\kappa\\on_{ti} + \\kappa\\off_{ti} =0 &\n\t\\tag{21b} \\label{example:BNE:generator:profits} \\\\\n|\\kappa\\on_{ti}| \\leq x_{ti} \\, \\widetilde{K} &\n\t\\tag{21c} \\label{example:BNE:kappa_on} \\\\\n|\\kappa\\off_{ti}| \\leq (1-x_{ti}) \\, \\widetilde{K} &\n\t\\tag{21d} \\label{example:BNE:kappa_off} \\\\\n\\sum_{t \\in T} \\bigg[\\kappa\\on_{ti}\n- c\\on_{i} z\\on_{ti} -  c\\off_{i} z\\off_{ti}  \\bigg] + \\zeta_{i}\n\\geq & \\quad \\nonumber \\\\ \n\\sum_{t \\in T_\\phi} \\bigg[\\beta\\on_{ti} g^{max}_{ti} - \\alpha\\on_{ti} g^{min}_{ti}& \\bigg]\n- c^D_{\\phi i} \n\\quad \\forall~\\phi \\in \\Phi \n\t\\tag{21e}\\label{example:BNE:generator:incentive} \\\\\n0 \\leq y_{ti} &\\leq x_{ti} \\, g^{max}_{ti} \n\t\\tag{21f} \\\\[2pt]\ny\\on_{ti} - (1-x_{ti}) \\, g^{max}_{ti} \\leq y_{ti} &\\leq y\\on_{ti} + (1-x_{ti}) \\, g^{max}_{ti}\n\t\\tag{21g} \n\\end{align}\n\\end{subequations}\n\\end{document}", "meta": {"hexsha": "52c0dfb4ff502b35b3ec78a909d76637ff3b3cb7", "size": 13133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/binary_equilibrium_math.tex", "max_stars_repo_name": "danielhuppmann/binary_equilibrium", "max_stars_repo_head_hexsha": "a8c73e7c77192f244af54707f1f2a3619a312326", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-01-28T15:20:16.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-01T22:31:25.000Z", "max_issues_repo_path": "tex/binary_equilibrium_math.tex", "max_issues_repo_name": "danielhuppmann/binary_equilibrium", "max_issues_repo_head_hexsha": "a8c73e7c77192f244af54707f1f2a3619a312326", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/binary_equilibrium_math.tex", "max_forks_repo_name": "danielhuppmann/binary_equilibrium", "max_forks_repo_head_hexsha": "a8c73e7c77192f244af54707f1f2a3619a312326", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-18T05:03:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-18T05:03:14.000Z", "avg_line_length": 48.2830882353, "max_line_length": 521, "alphanum_fraction": 0.6647376837, "num_tokens": 5147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4313120917843758}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\n\n\\title{Chapter 6\\\\Eigenvalue Problems}\n\\author{solutions by Hikari}\n\\date{August 2021}\n\n\n\\begin{document}\n\n\n\\newcommand{\\br}[2]{\\langle#1|#2\\rangle}\n\\newcommand{\\brr}[2]{\\left\\langle#1|#2\\right\\rangle}\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\M}{\\mathrm}\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\VE}{\\mathbf{\\hat{e}}}\n\\newcommand{\\ket}[1]{|#1\\rangle}\n\\newcommand{\\bra}[1]{\\langle#1|}\n\n\\maketitle\n\n\\section*{6.2 Matrix Eigenvalue Problems}\n\n\\newcommand{\\n}{\\lambda}\n\\paragraph{6.2.1}\n\\[\n\\begin{vmatrix}\n1-\\n&0&1\\\\\n0&1-\\n&0\\\\\n1&0&1-\\n\n\\end{vmatrix}=\n(1-\\n)(2-\\n)(-\\n)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=0,\\qquad && x_1+x_3=0,\\qquad && x_2=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_2=1,\\qquad && x_3=0,\\qquad && x_1=0,\\qquad && \\V{c}_2=(0,1,0)\\\\\n    & \\n_3=2,\\qquad && -x_1+x_3=0,\\qquad && -x_2=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{2}}(1,0,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.2}\n\\[\n\\begin{vmatrix}\n1-\\n&\\sqrt{2}&0\\\\\n\\sqrt{2}&-\\n&0\\\\\n0&0&-\\n\n\\end{vmatrix}=\n-\\n(\\n-2)(\\n+1)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1,\\qquad && 2x_1+\\sqrt{2}x_2=0,\\qquad && x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{3}}(1,-\\sqrt{2},0)\\\\\n    & \\n_2=0,\\qquad && x_1+\\sqrt{2}x_2=0,\\qquad && \\sqrt{2}x_1=0,\\qquad && \\V{c}_2=(0,0,1)\\\\\n    & \\n_3=2,\\qquad && -x_1+\\sqrt{2}x_2=0,\\qquad && -2x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{3}}(\\sqrt{2},1,0)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.3}\n\\[\n\\begin{vmatrix}\n1-\\n&1&0\\\\\n1&-\\n&1\\\\\n0&1&1-\\n\n\\end{vmatrix}=\n(1-\\n)(\\n-2)(\\n+1)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1,\\qquad && 2x_1+x_2=0,\\qquad && x_1+x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{6}}(1,-2,1)\\\\\n    & \\n_2=1,\\qquad && x_2=0,\\qquad && x_1-x_2+x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_3=2,\\qquad && -x_1+x_2=0,\\qquad && x_1-2 x_2+x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{3}}(1,1,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.4}\n\\[\n\\begin{vmatrix}\n 1-\\n&\\sqrt{8} &0 \\\\\n \\sqrt{8}& 1-\\n&\\sqrt{8} \\\\\n0 &\\sqrt{8} & 1-\\n\n\\end{vmatrix}=\n(1-\\n)(5-\\n)(-3-\\n)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-3 ,\\qquad && 4x_1+\\sqrt{8}x_2=0,\\qquad && \\sqrt{8}x_2+4x_3=0,\\qquad && \\V{c}_1=\\frac{1}{2}(1,-\\sqrt{2},1)\\\\\n    & \\n_2=1 ,\\qquad && \\sqrt{8}x_2=0,\\qquad && \\sqrt{8}x_1+\\sqrt{8}x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_3=5 ,\\qquad && -4x_1+\\sqrt{8}x_2=0,\\qquad && \\sqrt{8}x_2-4x_3=0,\\qquad && \\V{c}_3=\\frac{1}{2}(1,\\sqrt{2},1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.5}\n\\[\n\\begin{vmatrix}\n 1-\\n& 0& 0\\\\\n 0& 1-\\n&1 \\\\\n 0& 1& 1-\\n\n\\end{vmatrix}=\n(1-\\n)(2-\\n)(-\\n)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=0 ,\\qquad && x_1=0,\\qquad && x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(0,1,-1)\\\\\n    & \\n_2=1 ,\\qquad && x_3=0,\\qquad && x_2=0,\\qquad && \\V{c}_2=(1,0,0)\\\\\n    & \\n_3=2 ,\\qquad && -x_1=0,\\qquad && -x_2+x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{2}}(0,1,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.6}\n\\[\n\\begin{vmatrix}\n 1-\\n& 0& 0\\\\\n 0& 1-\\n& \\sqrt{2}\\\\\n 0&\\sqrt{2} & -\\n\n\\end{vmatrix}=\n(1-\\n)(\\n-2)(\\n+1)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1 ,\\qquad && 2x_1=0,\\qquad && 2x_2+\\sqrt{2}x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{3}}(0,-1,\\sqrt{2})\\\\\n    & \\n_2=1 ,\\qquad && \\sqrt{2}x_3=0,\\qquad && \\sqrt{2}x_2-x_3=0,\\qquad && \\V{c}_2=(1,0,0)\\\\\n    & \\n_3=2 ,\\qquad && -x_1=0,\\qquad && -x_2+\\sqrt{2}x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{3}}(0,\\sqrt{2},1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.7}\n\\[\n\\begin{vmatrix}\n -\\n&1 &0 \\\\\n 1& -\\n&1 \\\\\n 0& 1& -\\n\n\\end{vmatrix}=\n(-\\n)(\\n+\\sqrt{2})(\\n-\\sqrt{2})=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-\\sqrt{2} ,\\qquad && \\sqrt{2}x_1+x_2=0,\\qquad && x_2+\\sqrt{2}x_3=0,\\qquad && \\V{c}_1=\\frac{1}{2}(1,-\\sqrt{2},1)\\\\\n    & \\n_2=0 ,\\qquad && x_2=0,\\qquad && x_1+x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_3=\\sqrt{2} ,\\qquad && -\\sqrt{2}x_1+x_2=0,\\qquad && x_2-\\sqrt{2}x_3=0,\\qquad && \\V{c}_3=\\frac{1}{2}(1,\\sqrt{2},1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.8}\n\\[\n\\begin{vmatrix}\n 2-\\n&0 &0 \\\\\n 0& 1-\\n&1 \\\\\n 0&1 & 1-\\n\n\\end{vmatrix}=\n(2-\\n)(2-\\n)(-\\n)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_1=0 ,\\qquad && 2x_1=0,\\qquad && x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(0,1,-1)\\\\\n    & \\n_{2,3}=2 ,\\qquad && -x_2+x_3=0,\\qquad && \\qquad && \\V{c}_2=(1,0,0)\\qquad&&\\textit{(not unique)}\\\\\n    &\\qquad && \\qquad && \\qquad && \\V{c}_3=\\frac{1}{\\sqrt{2}}(0,1,1)\\qquad&&\\textit{(not unique)}\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.9}\n\\[\n\\begin{vmatrix}\n -\\n&1&1 \\\\\n1 & -\\n& 1\\\\\n1 & 1& -\\n\n\\end{vmatrix}=\n-(\\n+1)(\\n-2)(\\n+1)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_{1,2}=-1 ,\\qquad && x_1+x_2+x_3=0,\\qquad && \\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(1,-1,0)\\quad &&\\textit{(not unique)}\\\\\n    & \\qquad && \\qquad && \\qquad && \\V{c}_2=\\frac{1}{\\sqrt{6}}(1,1,-2)\\qquad &&\\textit{(not unique)}\\\\\n    & \\n_3=2 ,\\qquad && -2x_1+x_2+x_3=0,\\qquad && x_1+x_2-2x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{3}}(1,1,1) \\\\\n\\end{alignat*}\n\n\\paragraph{6.2.10}\n\\[\n\\begin{vmatrix}\n 1-\\n&-1 &-1 \\\\\n -1& 1-\\n& -1\\\\\n -1&-1 & 1-\\n\n\\end{vmatrix}=\n-(\\n-2)(\\n-2)(\\n+1)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_1=-1 ,\\qquad && 2x_1-x_2-x_3=0,\\qquad && -x_1-x_2+2x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{3}}(1,1,1)\\\\\n    & \\n_{2,3}=2 ,\\qquad && -x_1-x_2-x_3=0,\\qquad && \\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,-1,0)  \\quad &&\\textit{(not unique)}\\\\\n    &  \\qquad && \\qquad && \\qquad && \\V{c}_3=  \\frac{1}{\\sqrt{6}}(1,1,-2)\\quad &&\\textit{(not unique)}\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.11}\n\\[\n\\begin{vmatrix}\n 1-\\n&1 &1 \\\\\n 1& 1-\\n&1 \\\\\n 1& 1& 1-\\n\n\\end{vmatrix}=\n-\\n^2(\\n-3)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_{1,2}=0 ,\\qquad && x_1+x_2+x_3=0,\\qquad && \\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(1,-1,0)  \\quad &&\\textit{(not unique)}\\\\\n    &  \\qquad && \\qquad && \\qquad && \\V{c}_2=\\frac{1}{\\sqrt{6}}(1,1,-2)  \\quad &&\\textit{(not unique)}\\\\\n    & \\n_3=3 ,\\qquad && -2x_1+x_2+x_3=0,\\qquad && x_1+x_2-2x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{3}}(1,1,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.12}\n\\[\n\\begin{vmatrix}\n 5-\\n&0 &2 \\\\\n 0& 1-\\n&0 \\\\\n 2& 0& 2-\\n\n\\end{vmatrix}=\n-(\\n-1)(\\n-6)(\\n-1)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_{1,2}=1 ,\\qquad && 2x_1+x_3=0,\\qquad && \\qquad && \\V{c}_1=(0,1,0)  \\quad &&\\textit{(not unique)}\\\\\n    & \\qquad && \\qquad && \\qquad && \\V{c}_2=\\frac{1}{\\sqrt{5}}(1,0,-2)  \\quad &&\\textit{(not unique)}\\\\\n    & \\n_3=6 ,\\qquad && -x_1+2x_3=0,\\qquad && -5x_2=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{5}}(2,0,1)  \\\\\n\\end{alignat*}\n\n\\paragraph{6.2.13}\n\\[\n\\begin{vmatrix}\n 1-\\n& 1&0 \\\\\n 1& 1-\\n&0 \\\\\n 0& 0& -\\n\n\\end{vmatrix}=\n-\\n^2(\\n-2)=0\n\\]\n\\begin{alignat*}{5}\n    & \\n_{1,2}=0 ,\\qquad && x_1+x_2=0,\\qquad && \\qquad && \\V{c}_1=(0,0,1)  \\quad &&\\textit{(not unique)}\\\\\n    & \\qquad && \\qquad && \\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,-1,0)  \\quad &&\\textit{(not unique)}\\\\\n    & \\n_3=2 ,\\qquad && -x_1+x_2=0,\\qquad && -2x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{2}}(1,1,0)  \\\\\n\\end{alignat*}\n\n\\paragraph{6.2.14}\n\\[\n\\begin{vmatrix}\n 5-\\n&0 &\\sqrt{3} \\\\\n 0& 3-\\n&0 \\\\\n \\sqrt{3}&0 & 3-\\n\n\\end{vmatrix}=\n-(\\n-3)(\\n-6)(\\n-2)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=2 ,\\qquad && \\sqrt{3}x_1+x_3=0,\\qquad && x_2=0,\\qquad && \\V{c}_1=\\frac{1}{2}(1,0,-\\sqrt{3})\\\\\n    & \\n_2=3 ,\\qquad && 2x_1+\\sqrt{3}x_3=0,\\qquad && \\sqrt{3}x_1=0,\\qquad && \\V{c}_2=(0,1,0)\\\\\n    & \\n_3=6 ,\\qquad && -x_1+\\sqrt{3}x_3=0,\\qquad && -3x_2=0,\\qquad && \\V{c}_3=\\frac{1}{2}(\\sqrt{3},0,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.2.15}\n\\renewcommand{\\arraystretch}{1.5}\nFor every real coefficient homogeneous quadratic function (equation) in three variables \\[a_{11}x^2+a_{22}y^2+a_{33}z^2+a_{12}xy+a_{13}xz+a_{23}yz=1\\]\nit can be verified that it is equivalent to the matrix equation \n\\[\n\\begin{pmatrix}\nx,y,z\n\\end{pmatrix}\n\\begin{pmatrix}\na_{11}&\\frac{a_{12}}{2}&\\frac{a_{13}}{2}\\\\\n\\frac{a_{12}}{2}&a_{22}&\\frac{a_{23}}{2}\\\\\n\\frac{a_{13}}{2}&\\frac{a_{23}}{2}&a_{33}\n\\end{pmatrix}\n\\begin{pmatrix}\nx\\\\y\\\\z\n\\end{pmatrix}=1\n\\]\nNote that the middle matrix is Hermitian, so it can be diagonalized by a unitary transformation, which will transform the equation to \n\\[\n\\begin{pmatrix}\nx',y',z'\n\\end{pmatrix}\n\\begin{pmatrix}\n\\n_1&0&0\\\\\n0&\\n_2&0\\\\\n0&0&\\n_3\n\\end{pmatrix}\n\\begin{pmatrix}\nx'\\\\y'\\\\z'\n\\end{pmatrix}=1\n\\]\nor $\\n_1(x')^2+\\n_2(y')^2+\\n_3(z')^2=1$, which can be an ellipsoid, hyperboloid, elliptic cylinder, hyperbolic cylinder, or two parallel planes, depends on the sign of $\\n_1,\\n_2,\\n_3$.\n\n\\renewcommand{\\arraystretch}{1}\n$x^2+2xy+2y^2+2yz+z^2=1$ is equivalent to \n\\[\n\\begin{pmatrix}\nx,y,z\n\\end{pmatrix}\n\\begin{pmatrix}\n1&1&0\\\\\n1&2&1\\\\\n0&1&1\n\\end{pmatrix}\n\\begin{pmatrix}\nx\\\\y\\\\z\n\\end{pmatrix}=1\n\\]\nFind the eigenvectors to diagonalize it:\n\\[\n\\begin{vmatrix}\n1-\\n&1&0\\\\\n1&2-\\n&1\\\\\n0&1&1-\\n\n\\end{vmatrix}=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=0 ,\\qquad && x_1+x_2=0,\\qquad && x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{3}}(1,-1,1)\\\\\n    & \\n_2=1 ,\\qquad && x_2=0,\\qquad && x_1+x_2+x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_3=3 ,\\qquad && -2x_1+x_2=0,\\qquad && x_2-2x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{6}}(1,2,1)\\\\\n\\end{alignat*}\nTransform into the $\\V{c}_1,\\V{c}_2,\\V{c}_3$ basis, the equation becomes\n\\[\n\\begin{pmatrix}\nx',y',z'\n\\end{pmatrix}\n\\begin{pmatrix}\n0&0&0\\\\\n0&1&0\\\\\n0&0&3\n\\end{pmatrix}\n\\begin{pmatrix}\nx'\\\\y'\\\\z'\n\\end{pmatrix}=1\n\\]\nor\n\\[\n(y')^2+3(z')^2=1\n\\]\nwhich is an elliptic cylinder.\nThe axis of cylinder is in the $x'$ direction, which is the $\\V{c}_1$ direction, $(1,-1,1)$.\nThe major axis of ellipse is in the $y'$ direction,  which is the $\\V{c}_2$ direction, $(1,0,-1)$, with the length of semi-major axis being $1$.\nThe minor axis of ellipse is in the $z'$ direction,  which is the $\\V{c}_3$ direction, $(1,2,1)$, with the length of semi-minor axis being $\\frac{1}{\\sqrt{3}}$.\n\n\\section*{6.4 Hermitian Matrix Diagonalization}\n\n\\paragraph{6.4.1}\n\\[\n\\M{A}\\V{x}=\\n\\V{x}\n\\]\n\\[\n\\M{G}\\M{A}\\M{G}^{-1}\\M{G}\\V{x}=\\n\\M{G}\\V{x}\n\\]\n\\[\n\\M{A}'\\V{x}'=\\n\\V{x}'\n\\]\nthe same is for the transformation from $\\M{A}'$ to $\\M{A}$. So if $\\n$ is an eigenvalue of $\\M{A}$, it is an eigenvalue of $\\M{A}'$, and vice versa. So $\\M{A}'$ and $\\M{A}$ have the same eigenvalues (though the eigenvectors may be different.)\n\nThe invariance of trace and determinant under similarity transformation can be shown by the invariance of eigenvalues along with the fact that sum of eigenvalues equals trace (compare the coefficient of $\\n^{n-1}$ in $\\det(\\M{A}-\\n \\M{I})=(-1)^n(\\n^n-(\\mathrm{tr} \\M{A})\\n^{n-1}+\\cdots)=(-1)^n(\\n-\\n_1)\\cdots(\\n-\\n_n)$\\;) and product of eigenvalues equals determinant (let $\\n=0$ in $\\det(\\M{A}-\\n \\M{I})=(\\n_1-\\n)\\cdots(\\n_n-\\n)$). However, they can be proved more simply by\n\\newcommand{\\tr}{\\mathrm{tr}}\n\\[\n\\tr(\\M{G}\\M{A}\\M{G}^{-1})=\\tr(\\M{A}\\M{G}^{-1}\\M{G})=\\tr(\\M{A})\n\\]\n\\[\n\\det(\\M{G}\\M{A}\\M{G}^{-1})=\\det(\\M{G})\\det(\\M{A})\\det(\\M{G}^{-1})=\\det(\\M{A})\n\\]\n\n\\paragraph{6.4.2}\n(The theorem is correct only when the eigenvectors form a complete set, which means the number of independent eigenvectors is equal to the dimension of the matrix.)\n\nIf matrix $\\M{A}$ has real eigenvalues and orthonormal eigenvectors, then by transforming into the basis of the eigenvectors , it will be diagonalized, with the diagonal components being the real eigenvalues:\n\\[\n\\M{A}=\\M{U}\\M{A'}\\M{U}^{-1}\n\\]\n($\\M{U}$ is unitary, $\\M{A'}$ is diagonal and real, and therefore Hermitian)\n\\[\n\\M{A}^\\dagger=(\\M{U}\\M{A'}\\M{U}^{-1})^\\dagger=(U^{-1})^\\dagger(A')^\\dagger(U)^\\dagger=\\M{U}\\M{A'}\\M{U}^{-1}=\\M{A}\n\\]\nso $\\M{A}$ is Hermitian.\n\n\\paragraph{6.4.3}\n(A non-symmetric real matrix cannot be diagonalized by an orthogonal transformation, but may be diagonalized by an unitary transformation)\n\nIf $\\M{A}$ is real and non-symmetric, but can be diagonalized by an orthogonal transformation, then\n\\[\n\\M{A}=\\M{S}\\M{A'}\\M{S}^{-1}\n\\]\n$\\M{S}$ is orthogonal, and $\\M{A'}$ is diagonal. Then\n\\[\n\\M{A}^T=(\\M{S}^{-1})^T(\\M{A'})^T\\M{S}^T=\\M{S}\\M{A'}\\M{S}^{-1}=\\M{A}\n\\]\nso $A$ is symmetric, contradict.\n\nTo show a non-symmetric real matrix may be diagonalized by an unitary transformation, we give a counterexample:\n\\[\n\\M{A}=\n\\begin{pmatrix}\n1&1\\\\\n-1&1\n\\end{pmatrix}\\qquad \\M{U}=\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1&-i\\\\\n1&i\n\\end{pmatrix}\n\\]\nit can be checked that $\\M{U}$ is unitary:\n\\[\n\\M{U}\\M{U}^\\dagger=\n\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1&-i\\\\1&i\n\\end{pmatrix}\n\\begin{pmatrix}\n1&1\\\\\ni&-i\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0\\\\0&1\n\\end{pmatrix}=\\M{I}\n\\]\nand\n\\[\n\\M{U}\\M{A}\\M{U}^{-1}=\n\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1&-i\\\\1&i\n\\end{pmatrix}\n\\begin{pmatrix}\n1&1\\\\\n-1&1\n\\end{pmatrix}\n\\begin{pmatrix}\n1&1\\\\\ni&-i\n\\end{pmatrix}=\n\\begin{pmatrix}\n1+i&0\\\\\n0&1-i\n\\end{pmatrix}\n\\]\nso an non-symmetric real matrix may be diagonalized by an unitary transformation.\n\n\\paragraph{6.4.4}\n$L_x,L_y,L_z$ are Hermitain, so\n\\[\n(\\V{L}^2)^\\dagger=(L_x^2)^\\dagger+(L_y^2)^\\dagger+(L_z^2)^\\dagger=L_x^2+L_y^2+L_z^2=\\V{L}^2\n\\]\nso $\\V{L}^2$ is Hermitian, and therefore its eigenvalues are real.\n\\medskip\n\nLet $\\V{x}$ be an eigenvector of $\\V{L}^2$, so $\\V{L}^2\\V{x}=\\n\\V{x}$. Then\n\\[\n\\br{\\V{x}|\\V{L}^2}{\\V{x}}=\\br{\\V{x}|L_x^2}{\\V{x}}+\\br{\\V{x}|L_y^2}{\\V{x}}+\\br{\\V{x}|L_z^2}{\\V{x}}=\\br{L_x\\V{x}}{L_x\\V{x}}+\\br{L_y\\V{x}}{L_y\\V{x}}+\\br{L_z\\V{x}}{L_z\\V{x}}\\geq0\n\\]\nbut also\n\\[\n\\br{\\V{x}|\\V{L}^2}{\\V{x}}=\\n\\br{\\V{x}}{\\V{x}}\n\\]\nso $\\n\\br{\\V{x}}{\\V{x}}\\geq0$, and therefore $\\n\\geq0$.\n\n\\paragraph{6.4.5}\n\\[\n\\M{A}\\V{x_i}=\\n_i\\V{x_i}\n\\]\n\\[\n\\V{x_i}=\\M{A}^{-1}\\M{A}\\V{x_i}=\\n_i\\V{A}^{-1}\\V{x_i}\n\\]\nso\n\\[\n\\M{A}^{-1}\\V{x_i}=\\frac{1}{\\n_i}\\V{x_i}\n\\]\n\n\\paragraph{6.4.6}\n(a) By making $\\n=0$ in $\\det(\\M{A}-\\n\\M{I})=(\\n_1-\\n)\\cdots(\\n_n-\\n)$, we know that $\\det(\\M{A})$ equals to the product of its eigenvalues. So $\\det(\\M{A})=0$ means that at least one of its eigenvalue is zero, then let $\\V{x}$ be the eigenvector corresponding to the eigenvalue, we have\n\\[\n\\M{A}\\V{x}=0\\V{x}=0\n\\]\n(\nIt is a circular reasoning because the existence of eigenvector corresponding to an eigenvalue depends on the fact that $\\V{x}$ exists when\n\\[\n(\\M{A}-\\n\\M{I})\\V{x}=0\n\\]\nand $\\det(\\M{A}-\\n\\M{I})=0$, while this is exactly what we want to prove in this problem. However, a formal proof probably requires knowledge of linear algebra such as rank, Gaussian elimination, etc, which are beyond the scope of the book and probably not intended by the author.\n)\n\n(b) If $\\M{A}|\\V{v}\\rangle=0$, then $|\\V{v}\\rangle$ is an eigenvector of $\\M{A}$ with zero eigenvalue. So\n\\[\n\\det(\\M{A})=\\n_1\\n_2\\cdots\\n_n=0\n\\]\nand therefore $\\M{A}$ is singular.\n\n\\paragraph{6.4.7}\n\\renewcommand{\\arraystretch}{1.0}\nTransform $\\M{A}$ and $\\M{B}$ into their orthonormal eigenvector basis (which is unitary because $\\M{A}$ and $\\M{B}$ are Hermitian), we have\n\\[\n\\M{U}_1\\M{A}\\M{U}_1^{-1}=\n\\begin{pmatrix}\n\\n_1&&\\\\\n &\\ddots& \\\\\n  & &\\n_n\n\\end{pmatrix}=\n\\M{U}_2\\M{B}\\M{U}_2^{-1}\n\\]\nso\n\\[\n\\M{A}=\\M{U}_1^{-1}\\M{U}_2\\M{B}\\M{U}_2^{-1}\\M{U}_1\n=(\\M{U}_1^{-1}\\M{U}_2)\\M{B}(\\M{U}_1^{-1}\\M{U}_2)^{-1}=\\M{U}\\M{B}\\M{U}^{-1}\n\\]\n\n\\paragraph{6.4.8}\n\\renewcommand{\\arraystretch}{1.5}\n\\[\n\\M{M}_x:\\quad\n\\begin{vmatrix}\n -\\n&\\frac{1}{\\sqrt{2}} &0 \\\\\n \\frac{1}{\\sqrt{2}} & -\\n&\\frac{1}{\\sqrt{2}} \\\\\n 0 &\\frac{1}{\\sqrt{2}} &-\\n\n\\end{vmatrix}=\n-\\n(\\n-1)(\\n+1)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1 ,\\qquad && x_1+\\frac{1}{\\sqrt{2}}x_2=0,\\qquad && \\frac{1}{\\sqrt{2}}x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{2}(1,-\\sqrt{2},1) \\\\\n    & \\n_2=0 ,\\qquad && x_2=0,\\qquad && \\frac{1}{\\sqrt{2}}x_1+\\frac{1}{\\sqrt{2}}x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,-1)\\\\\n    & \\n_3=1 ,\\qquad && -x_1+\\frac{1}{\\sqrt{2}}x_2=0,\\qquad && \\frac{1}{\\sqrt{2}}x_2-x_3=0,\\qquad && \\V{c}_3=\\frac{1}{2}(1,\\sqrt{2},1) \\\\\n\\end{alignat*}\n\\[\n\\M{M}_y:\\quad\n\\begin{vmatrix}\n -\\n&\\frac{-i}{\\sqrt{2}} &0 \\\\\n \\frac{i}{\\sqrt{2}} & -\\n&\\frac{-i}{\\sqrt{2}} \\\\\n 0 &\\frac{i}{\\sqrt{2}} &-\\n\n\\end{vmatrix}=\n-\\n(\\n-1)(\\n+1)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1 ,\\qquad && x_1-\\frac{i}{\\sqrt{2}}x_2=0,\\qquad && \\frac{i}{\\sqrt{2}}x_2+x_3=0,\\qquad && \\V{c}_1=\\frac{1}{2}(1,-\\sqrt{2}i,-1) \\\\\n    & \\n_2=0 ,\\qquad && \\frac{-i}{\\sqrt{2}}x_2=0,\\qquad && \\frac{i}{\\sqrt{2}}x_1-\\frac{i}{\\sqrt{2}}x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,0,1)\\\\\n    & \\n_3=1 ,\\qquad && -x_1-\\frac{i}{\\sqrt{2}}x_2=0,\\qquad && \\frac{i}{\\sqrt{2}}x_2-x_3=0,\\qquad && \\V{c}_3=\\frac{1}{2}(1,\\sqrt{2}i,-1) \\\\\n\\end{alignat*}\n\\[\n\\M{M}_z:\\quad\n\\begin{vmatrix}\n 1-\\n&0 &0 \\\\\n 0 & -\\n&0 \\\\\n 0 &0 &-1-\\n\n\\end{vmatrix}=\n\\n(1-\\n)(1+\\n)=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=-1 ,\\qquad && 2x_1=0,\\qquad && x_2=0,\\qquad && \\V{c}_1=(0,0,1) \\\\\n    & \\n_2=0 ,\\qquad && x_1=0,\\qquad && -x_3=0,\\qquad && \\V{c}_2=(0,1,0)\\\\\n    & \\n_3=1 ,\\qquad && -x_2=0,\\qquad && -2x_3=0,\\qquad && \\V{c}_3=(1,0,0) \\\\\n\\end{alignat*}\n\n\\paragraph{6.4.9}\n(a) \n\\[\na'_{ij}=\\br{\\varphi'_i|\\M{A}}{\\varphi'_j}=\\br{\\varphi_i\\cos\\theta-\\varphi_j\\sin\\theta|\\M{A}}{\\varphi_i\\sin\\theta+\\varphi_j\\cos\\theta}\n\\]\n\\[\n=\\br{\\varphi_i|\\M{A}}{\\varphi_i}\\sin\\theta\\cos\\theta+\\br{\\varphi_i|\\M{A}}{\\varphi_j}\\cos^2\\theta-\\br{\\varphi_j|\\M{A}}{\\varphi_i}\\sin^2\\theta-\\br{\\varphi_j|\\M{A}}{\\varphi_j}\\sin\\theta\\cos\\theta\n\\]\n\\[\n=a_{ii}\\sin\\theta\\cos\\theta+a_{ij}\\cos^2\\theta-a_{ji}\\sin^2\\theta-a_{jj}\\sin\\theta\\cos\\theta\n\\]\n\\[\n=a_{ij}\\cos2\\theta-(a_{jj}-a_{ii})\\frac{1}{2}\\sin2\\theta=0\n\\]\nwhen $\\frac{2a_{ij}}{a_{jj}-a_{ii}}=\\frac{\\sin2\\theta}{\\cos2\\theta}=\\tan2\\theta$\n\\medskip\n\n(b) \n\\[\na'_{\\mu\\nu}=\\br{\\varphi'_\\mu|\\M{A}}{\\varphi'_\\nu}=\\br{\\varphi_\\mu|\\M{A}}{\\varphi_\\nu}=a_{\\mu\\nu}\n\\]\n\n(c) \n\\[\na'_{ii}=\\br{\\varphi'_i|\\M{A}}{\\varphi'_i}=\\br{\\varphi_i\\cos\\theta-\\varphi_j\\sin\\theta|\\M{A}}{\\varphi_i\\cos\\theta-\\varphi_j\\sin\\theta}\n\\]\n\\[\n=\\br{\\varphi_i|\\M{A}}{\\varphi_i}\\cos^2\\theta-\\br{\\varphi_i|\\M{A}}{\\varphi_j}\\sin\\theta\\cos\\theta-\\br{\\varphi_j|\\M{A}}{\\varphi_i}\\sin\\theta\\cos\\theta+\\br{\\varphi_j|\\M{A}}{\\varphi_j}\\sin^2\\theta\n\\]\n\\[\n=a_{ii}\\cos^2\\theta+a_{jj}\\sin^2\\theta-2a_{ij}\\sin\\theta\\cos\\theta\n\\]\n\\[\na'_{jj}=\\br{\\varphi'_j|\\M{A}}{\\varphi'_j}=\\br{\\varphi_i\\sin\\theta+\\varphi_j\\cos\\theta|\\M{A}}{\\varphi_i\\sin\\theta+\\varphi_j\\cos\\theta}\n\\]\n\\[\n=\\br{\\varphi_i|\\M{A}}{\\varphi_i}\\sin^2\\theta+\\br{\\varphi_i|\\M{A}}{\\varphi_j}\\sin\\theta\\cos\\theta+\\br{\\varphi_j|\\M{A}}{\\varphi_i}\\sin\\theta\\cos\\theta+\\br{\\varphi_j|\\M{A}}{\\varphi_j}\\cos^2\\theta\n\\]\n\\[\n=a_{ii}\\sin^2\\theta+a_{jj}\\cos^2\\theta+2a_{ij}\\sin\\theta\\cos\\theta\n\\]\n\\[\n\\tr(\\M{A'})-\\tr(\\M{A})=a'_{ii}+a'_{jj}-a_{ii}-a_{jj}=0\n\\]\n\n(d) \n\\[\na'_{i\\mu}=\\br{\\varphi'_i|\\M{A}}{\\varphi'_\\mu}=\\br{\\varphi_i\\cos\\theta-\\varphi_j\\sin\\theta|\\M{A}}{\\varphi_\\mu}=a_{i\\mu}\\cos\\theta-a_{j\\mu}\\sin\\theta\n\\]\n\\[\na'_{j\\mu}=\\br{\\varphi'_j|\\M{A}}{\\varphi'_\\mu}=\\br{\\varphi_i\\sin\\theta+\\varphi_j\\cos\\theta|\\M{A}}{\\varphi_\\mu}=a_{i\\mu}\\sin\\theta+a_{j\\mu}\\cos\\theta\n\\]\nNote that $a_{i\\mu}'^2+a_{j\\mu}'^2-a_{i\\mu}^2-a_{j\\mu}^2=0$. Let $S$ be the sum of the squares\nof the off-diagonal elements of $\\M{A}$, and let $\\mu,\\nu\\neq i,j$, \\,$\\mu\\neq\\nu$, then\n\\[\nS'-S=\\sum_\\mu\\sum_\\nu(a_{\\mu\\nu}'^2-a_{\\mu\\nu}^2)+\\sum_\\mu(a_{i\\mu}'^2+a_{j\\mu}'^2-a_{i\\mu}^2-a_{j\\mu}^2)-\\sum_\\mu(a_{\\mu i}'^2+a_{\\mu j}'^2-a_{\\mu i}^2-a_{\\mu j}^2)\\,+(a_{ij}'^2+a_{ji}'^2-a_{ij}^2-a_{ji}^2)\n\\]\\[\n=-2a_{ij}^2\\]\nbecause the first three summations are zero.\n\n\\section*{6.5 Normal Matrices}\n\n\\paragraph{6.5.1}\n\\[\n\\begin{vmatrix}\n 2-\\n&4 \\\\\n 1 & 2-\\n \n\\end{vmatrix}=\n\\n(\\n-4)=0\n\\]\n\\begin{alignat*}{3}\n    & \\n_1=0 ,\\qquad && x_1+2x_2=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{5}}(2,-1) \\\\\n    & \\n_2=4 ,\\qquad && x_1-2x_2=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{5}}(2,1)\\\\\n\\end{alignat*}\n\n\\paragraph{6.5.2}\n\\renewcommand{\\arraystretch}{1.0}\nLet \n\\[\n\\M{A}=\\begin{pmatrix}\na&b\\\\c&d\n\\end{pmatrix}\n\\]\nthen its eigenvalue $\\n$ satisfies\n\\[\n\\begin{vmatrix}\na-\\n&b\\\\c&d-\\n\n\\end{vmatrix}=\\n^2-\\n(a+d)+(ad-bc)=\\n^2-\\n\\,\\mathrm{trace}(\\M{A})+\\det(\\M{A})=0\n\\]\n\n\\paragraph{6.5.3}\n\\[\n\\M{U}\\V{c}=\\n\\V{c}\n\\]\n\\[\n\\V{c}^\\dagger\\M{U}^\\dagger=\\n^*\\V{c}^\\dagger\n\\]\n\\[\n(\\n^*\\V{c}^\\dagger)(\\n\\V{c})=|\\n|^2\\V{c}^\\dagger\\V{c}=\\V{c}^\\dagger\\M{U}^\\dagger\\M{U}\\V{c}=\\V{c}^\\dagger\\V{c}\n\\]\nso \n\\[|\\n|^2=1\\]\n\n\\paragraph{6.5.4}\n(The results hold only when the orthogonal matrix is a rotation, not a reflection, which means the determinant is $1$, not $-1$.)\n\n(a)\nTransform the matrix to the coordinate system where the axis of rotation coincides with the new $x$-axis, then it becomes\n\\[\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\varphi&\\sin\\varphi\\\\\n0&-\\sin\\varphi&\\cos\\varphi\n\\end{pmatrix}\n\\]\nBy exercise 6.4.1, the trace (sum of eigenvalues) of a matrix is invariant under a similarity transformation, so the sum of the three eigenvalues of the original matrix equals the trace of the new matrix, which is \n\\[\n1+2\\cos\\varphi\n\\]\n\n(b) By exercise 6.4.1, the determinant (product of eigenvalues) of a matrix is invariant under a similarity transformation, so the product of the three eigenvalues of the original matrix equals the determinant of the new matrix, which is $\\cos^2\\varphi+\\sin^2\\varphi=1$. Let the other two eigenvalues be $a$ and $b$, then \n\\[\na+b=2\\cos\\varphi,\\qquad ab=1\n\\]\nso\n\\[\na+\\frac{1}{a}=2\\cos\\varphi\n\\]\nsolving for $a$, we have \n\\[\na=\\frac{2\\cos\\varphi\\pm\\sqrt{4\\cos^\\varphi-4}}{2}=\\cos\\varphi\\pm i\\sin\\varphi=e^{i\\varphi}, e^{-i\\varphi}\n\\]\nSo one of $a,b$ must be $e^{i\\varphi}$, and the other must be $e^{-i\\varphi}$.\n\n\\paragraph{6.5.5}\nExpand $\\V{y}$ in the orthonormal basis of $\\V{x}_i$, we have\n\\[\n\\br{\\V{y}|\\M{A}}{\\V{y}}=\\sum_i\\sum_j\\br{\\V{y}}{\\V{x}_j}\\br{\\V{x}_i|\\M{A}}{\\V{x}_j}\\br{\\V{x}_j}{\\V{y}}\n\\]\n\\[\n=\\sum_i\\sum_j\\br{\\V{y}}{\\V{x}_j}\\delta_{ij}\\n_i\\br{\\V{x}_j}{\\V{y}}\n\\]\n\\[\n=\\sum_i|y_i|^2\\n_i\n\\]\nNote that $\\br{\\V{y}}{\\V{y}}=\\sum_i|y_i|^2=1$, and $|y_i|^2\\geq0$, so\n\\[\n\\n_1=(\\sum_i|y_i|^2)\\n_1\\leq\\sum_i|y_i|^2\\n_i\\leq(\\sum_i|y_i|^2)\\n_n=\\n_n\n\\]\nso\n\\[\n\\n_1\\leq\\br{\\V{y}|\\M{A}}{\\V{y}}\\leq\\n_n\n\\]\n\n\\paragraph{6.5.6}\nThe eigenvalues of a Hermitian matrix is real, and the eigenvalues of a unitary matrix have unit magnitude (from exercise 6.5.3), so the eigenvalues can only be $\\pm1$.\n\n\\paragraph{6.5.7}\nTo prove the statement, we only need the anti-commuting condition and the fact that the metrics are non-singular (because they are unitary). If $\\gamma_i\\gamma_j=-\\gamma_j\\gamma_i$, then \n\\[\n\\det(\\gamma_i)\\det(\\gamma_j)=(-1)^n\\det(\\gamma_j)\\det(\\gamma_i)\n\\]\nBecause $\\det(\\gamma_i),\\det(\\gamma_i)\\neq0$, so $(-1)^n=1$, which means $n$ is even.\n\\medskip\n\nTo show that $2\\times2$ matrices are inadequate to form a set of four anticommuting, Hermitian,\nunitary matrices, let the matrix satisfying the conditions be \n\\[\n\\begin{pmatrix}\na&b\\\\c&d\n\\end{pmatrix}\n\\]\nIt is Hermitian, so $c=b^*$, and $a,d$ are real:\n\\[\n\\begin{pmatrix}\na&b\\\\b^*&d\n\\end{pmatrix}\n\\]\nIt is unitary, so\n\\[\n\\begin{pmatrix}\na&b\\\\b^*&d\n\\end{pmatrix}\n\\begin{pmatrix}\na&b\\\\b^*&d\n\\end{pmatrix}=\\begin{pmatrix}\na^2+|b|^2&b(a+d)\\\\\nb^*(a+d)&d^2+|b|^2\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0\\\\0&1\n\\end{pmatrix}\n\\]\nso $b=0$ or $a+d=0$. \n\nIf $a+d=0$, then $a^2+|b|^2=1$, which means we can find $0\\leq\\theta\\leq\\frac{\\pi}{2}$ such that $a^2=\\cos^2\\theta$, $|b|^2=\\sin^2\\theta$. So the matrix has the form\n\\[\\pm\n\\begin{pmatrix}\n\\cos\\theta&\\sin\\theta e^{i\\varphi}\\\\\n\\sin\\theta e^{-i\\varphi}& -\\cos\\theta\n\\end{pmatrix}\n\\]\n\nIf $b=0$, then $a,d=\\pm1$. If $a,d$ have same sign, then the matrix is $\\pm\\M{I}$, and it will contradict with the anti-commuting property because $\\M{A}\\M{I}+\\M{I}\\M{A}=0$ implies $\\M{A}=0$. Therefore, it must be $a=1,d=-1$ or $a=-1,d=1$, which is of the form of above equation by making $\\theta=0$. \n\nNow using the anti-commuting property,\n\\[\n\\begin{pmatrix}\n\\cos\\theta_1&\\sin\\theta_1 e^{i\\varphi_1}\\\\\n\\sin\\theta_1 e^{-i\\varphi_1}& -\\cos\\theta_1\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\theta_2&\\sin\\theta_2 e^{i\\varphi_2}\\\\\n\\sin\\theta_2 e^{-i\\varphi_2}& -\\cos\\theta_2\n\\end{pmatrix}+\n\\begin{pmatrix}\n\\cos\\theta_2&\\sin\\theta_2 e^{i\\varphi_2}\\\\\n\\sin\\theta_2 e^{-i\\varphi_2}& -\\cos\\theta_2\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\theta_1&\\sin\\theta_1 e^{i\\varphi_1}\\\\\n\\sin\\theta_1 e^{-i\\varphi_1}& -\\cos\\theta_1\n\\end{pmatrix}\\]\n\\[\n=\\begin{pmatrix}\n2\\cos\\theta_1\\cos\\theta_2+2\\sin\\theta_1\\sin\\theta_2\\cos(\\varphi_1-\\varphi_2)& 0\\\\\n0& 2\\cos\\theta_1\\cos\\theta_2+2\\sin\\theta_1\\sin\\theta_2\\cos(\\varphi_1-\\varphi_2)\n\\end{pmatrix}\n\\]\nso \n\\[\n2\\cos\\theta_1\\cos\\theta_2+2\\sin\\theta_1\\sin\\theta_2\\cos(\\varphi_1-\\varphi_2)=0\n\\]\nBecause both the terms are non-negative ($0\\leq\\theta\\leq\\frac{\\pi}{2}$), we must have \\[\\cos\\theta_1\\cos\\theta_2=0\\] and \\[\\sin\\theta_1\\sin\\theta_2\\cos(\\varphi_1-\\varphi_2)=0\\]\nFrom $\\cos\\theta_1\\cos\\theta_2=0$ we know at most one of the matrix can have non-zero $\\cos\\theta$, which means except this matrix, all the other matrices have $\\theta=\\frac{\\pi}{2}$.\n\nFrom $\\sin\\theta_1\\sin\\theta_2\\cos(\\varphi_1-\\varphi_2)=0$, we know when $\\theta_1,\\theta_2=\\frac{\\pi}{2}$, we must have $\\varphi_1-\\varphi_2=\\pm\\frac{\\pi}{2}$, which means there are at most two matrices with $\\theta=\\frac{\\pi}{2}$.\n\nIn conclusion, we can have at most two matrices with $\\theta=\\frac{\\pi}{2}$ and one matrix with $\\theta\\neq\\frac{\\pi}{2}$, so it is inadequate for $2\\times2$ matrices to form four anticommuting, Hermitian,\nunitary matrices.\n\\medskip\n\n(The three Pauli matrices are:\n\\begin{alignat*}{3}\n    & \\theta=0 ,\\qquad&& && \\sigma_1=\\begin{pmatrix}0&1\\\\1&0\\end{pmatrix}\\\\\n    & \\theta=\\frac{\\pi}{2},\\qquad&& \\varphi=-\\frac{\\pi}{2},\\qquad&&\\sigma_2=\\begin{pmatrix}0&-i\\\\i&0\\end{pmatrix}\\\\\n    & \\theta=\\frac{\\pi}{2},\\qquad && \\varphi=0 ,\\qquad&& \\sigma_3=\n\\begin{pmatrix}\n1&0\\\\0&-1\n\\end{pmatrix}\\\\\n\\end{alignat*}\nwhich are anticommuting, Hermitian and\nunitary.\n)\n\n\\paragraph{6.5.8}\n\\[\n|\\V{y}\\rangle=\\sum_n|\\V{x}_n\\rangle\\br{\\V{x}_n}{\\V{y}}\n\\]\nso\n\\[\n\\M{A}|\\V{y}\\rangle=\\sum_n\\M{A}|\\V{x}_n\\rangle\\br{\\V{x}_n}{\\V{y}}=\\sum_n\\n_n|\\V{x}_n\\rangle\\br{\\V{x}_n}{\\V{y}}=\\left(\\sum_n\\n_n|\\V{x_n}\\rangle\\langle\\V{x}_n|\\right)|\\V{y}\\rangle\n\\]\n\\[\n\\M{A}=\\sum_n\\n_n|\\V{x_n}\\rangle\\langle\\V{x}_n|\n\\]\n\n\\paragraph{6.5.9}\n\\[\n\\begin{pmatrix}\n1&0\\\\0&1\n\\end{pmatrix}\n\\M{A}\n\\begin{pmatrix}\n1&0\\\\0&1\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0\\\\0&-1\n\\end{pmatrix}\n\\]\nso\n\\[\n\\M{A}=\\begin{pmatrix}\n1&0\\\\0&-1\n\\end{pmatrix}\n\\]\n\n\\paragraph{6.5.10}\n\\[\n\\M{A}\\ket{\\V{u}_j}=\\n_j\\ket{\\V{u}_j}\n\\]\n\\[\n\\M{A}^\\dagger\\ket{\\V{v}_i}=\\n_i\\ket{\\V{v}_i}\n\\]\nso\n\\[\n\\br{\\V{v}_i|\\M{A}}{\\V{u}_j}=\\n_j\\br{\\V{v}_i}{\\V{u}_j}=\\n_i^*\\br{\\V{v}_i}{\\V{u}_j}\n\\]\nif $\\n_j\\neq\\n_i^*$, we must have $\\br{\\V{v}_i}{\\V{u}_j}=0$.\n\n\\paragraph{6.5.11}\n(a) \n\\[\n(\\tilde{\\M{A}}\\M{A})\\ket{\\V{f}_n}=\\n_n\\tilde{\\M{A}}\\ket{\\V{g}_n}=\\n_n^2\\ket{\\V{f}_n}\n\\]\n\n(b)\n\\[\n(\\M{A}\\tilde{\\M{A}})\\ket{\\V{g}_n}=\\n_n\\M{A}\\ket{\\V{f}_n}=\\n_n^2\\ket{\\V{g}_n}\n\\]\n\n(c)\n\\[\n(\\tilde{\\M{A}}\\M{A})^\\dagger=\\M{A}^\\dagger(\\tilde{\\M{A}})^\\dagger=\\tilde{\\M{A}}\\M{A}\n\\]\n\\[\n(\\M{A}\\tilde{\\M{A}})^\\dagger=(\\tilde{\\M{A}})^\\dagger\\M{A}^\\dagger=\\M{A}\\tilde{\\M{A}}\n\\]\nso $(\\tilde{\\M{A}}\\M{A})$ and $(\\M{A}\\tilde{\\M{A}})$ are Hermitian, which means their eigenvectors $\\ket{\\V{f}_n}$ and $\\ket{\\V{g}_n}$ form an orthogonal set, and their eigenvalue $\\n_n^2$ is real.\n\n\\paragraph{6.5.12}\n\\[\n\\ket{\\V{y}}=\\sum_n\\ket{\\V{f}_n}\\br{\\V{f}_n}{\\V{y}}\n\\]\n\\[\n\\M{A}\\ket{\\V{y}}=\\sum_n\\M{A}\\ket{\\V{f}_n}\\br{\\V{f}_n}{\\V{y}}=\\sum_n\\n_n\\ket{\\V{g}_n}\\br{\\V{f}_n}{\\V{y}}=\\left(\\sum_n\\n_n\\ket{\\V{g}_n}\\bra{\\V{f}_n} \\right)\\ket{\\V{y}}\n\\]\nso\n\\[\n\\M{A}=\\sum_n\\n_n\\ket{\\V{g}_n}\\bra{\\V{f}_n}\n\\]\n\n\\paragraph{6.5.13}\n(a) \n\\[\n\\tilde{\\M{A}}=\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&1\\\\2&-4\n\\end{pmatrix}\\qquad\n\\tilde{\\M{A}}\\M{A}=\n\\begin{pmatrix}\n1&0\\\\0&4\n\\end{pmatrix}\\qquad\n\\M{A}\\tilde{\\M{A}}=\\frac{1}{5}\n\\begin{pmatrix}\n8&-6\\\\-6&17\n\\end{pmatrix}\n\\]\n\n(b) \n\\renewcommand{\\arraystretch}{1.5}\n\\[\n\\begin{vmatrix}\n \\frac{8}{5}-\\n_n^2&\\frac{-6}{5} \\\\\n \\frac{-6}{5} & \\frac{17}{5}-\\n_n^2 \n\\end{vmatrix}=\n(\\n_n^2-1)(\\n_n^2-4)=0\n\\]\n\\begin{alignat*}{3}\n    & \\n_1^2=1 ,\\qquad && x_1-2x_2=0,\\qquad && \\V{g}_1=\\frac{1}{\\sqrt{5}}(2,1) \\\\\n    & \\n_2^2=4 ,\\qquad && 2x_1+x_2=0,\\qquad && \\V{g}_2=\\frac{1}{\\sqrt{5}}(1,-2)\\\\\n\\end{alignat*}\n\n(c)\n\\[\n\\begin{vmatrix}\n 1-\\n_n^2&0 \\\\\n0& 4-\\n_n^2 \n\\end{vmatrix}=\n(\\n_n^2-1)(\\n_n^2-4)=0\n\\]\n\\begin{alignat*}{3}\n    & \\n_1^2=1 ,\\qquad && 3x_2=0,\\qquad && \\V{f}_1=(1,0) \\\\\n    & \\n_2^2=4 ,\\qquad && -3x_1=0,\\qquad && \\V{f}_2=(0,1)\\\\\n\\end{alignat*}\n\n(d) \n$\\n_1^2=1$ ($\\n_1=1$) :\n\\[\n\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&2\\\\1&-4\n\\end{pmatrix}\n\\begin{pmatrix}\n1\\\\0\n\\end{pmatrix}=1\\cdot\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2\\\\1\n\\end{pmatrix}\n\\]\n\\[\n\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&1\\\\2&-4\n\\end{pmatrix}\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2\\\\1\n\\end{pmatrix}=1\\cdot\\begin{pmatrix}\n1\\\\0\n\\end{pmatrix}\n\\]\n\n$\\n_2^2=4$ ($\\n_2=2$) :\n\\[\n\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&2\\\\1&-4\n\\end{pmatrix}\n\\begin{pmatrix}\n0\\\\1\n\\end{pmatrix}=2\\cdot\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n1\\\\-2\n\\end{pmatrix}\n\\]\n\\[\n\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&1\\\\2&-4\n\\end{pmatrix}\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n1\\\\-2\n\\end{pmatrix}=2\\cdot\\begin{pmatrix}\n0\\\\1\n\\end{pmatrix}\n\\]\n\n(e)\n\\[\n\\sum_n\\n_n\\ket{\\V{g}_n}\\bra{\\V{f}_n}=1\\cdot\n\\begin{pmatrix}\n\\frac{2}{\\sqrt{5}}\\\\\\frac{1}{\\sqrt{5}}\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0\n\\end{pmatrix}+2\\cdot\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{5}}\\\\\\frac{-2}{\\sqrt{5}}\n\\end{pmatrix}\n\\begin{pmatrix}\n0&1\n\\end{pmatrix}=\n\\frac{1}{\\sqrt{5}}\n\\begin{pmatrix}\n2&2\\\\1&-4\n\\end{pmatrix}=\\M{A}\n\\]\n\n\\paragraph{6.5.14}\n(a)\n\\[\n\\M{A}=\\sum_n\\n_n\\ket{\\V{g}_n}\\bra{\\V{f}_n}=1\\cdot\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}\\\\\\frac{1}{\\sqrt{2}}\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0\n\\end{pmatrix}-1\\cdot\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}\\\\\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}\n\\begin{pmatrix}\n0&1\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\n\\end{pmatrix}=\n\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1&-1\\\\1&1\n\\end{pmatrix}\n\\]\n\n(b) \n\\[\n\\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n1&-1\\\\1&1\n\\end{pmatrix}\n\\begin{pmatrix}\n1\\\\0\n\\end{pmatrix}=1\\cdot\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1\\\\1\n\\end{pmatrix}\n\\]\n\\[\n\\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n1&-1\\\\1&1\n\\end{pmatrix}\n\\begin{pmatrix}\n0\\\\1\n\\end{pmatrix}=-1\\cdot\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1\\\\-1\n\\end{pmatrix}\n\\]\n\n(c)\n\\[\n\\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n1&1\\\\-1&1\n\\end{pmatrix}\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1\\\\1\n\\end{pmatrix}=1\\cdot\n\\begin{pmatrix}\n1\\\\0\n\\end{pmatrix}\n\\]\n\\[\n\\frac{1}{\\sqrt{2}}\\begin{pmatrix}\n1&1\\\\-1&1\n\\end{pmatrix}\\frac{1}{\\sqrt{2}}\n\\begin{pmatrix}\n1\\\\-1\n\\end{pmatrix}=-1\\cdot\n\\begin{pmatrix}\n0\\\\1\n\\end{pmatrix}\n\\]\n\n\\paragraph{6.5.15}\n(a)\n\\[\n\\M{U}^\\dagger=e^{-ia\\M{H}^\\dagger}=e^{-ia\\M{H}}=\\M{U}^{-1}\n\\]\nso $\\M{U}$ is unitary.\n\n(b) \n\\[\n\\M{U}^\\dagger\\M{U}=e^{-ia\\M{H}^\\dagger}e^{ia\\M{H}}=e^{ia(\\M{H-\\M{H}^\\dagger})}=\\M{I}=e^{i2n\\pi\\M{I}}\n\\]\nso $a(\\M{H}-\\M{H}^\\dagger)=2n\\pi\\M{I}$. Because $\\M{H}-\\M{H}^\\dagger$ is independent of $a$, so it must be $n=0$, and therefore $\\M{H}-\\M{H}^\\dagger=0$, $\\M{H}=\\M{H}^\\dagger$, which means $\\M{H}$ is Hermitian.\n\n(c) It can be verified that $u_j=e^{iah_j}$, with $u_j$ and $h_j$ being eigenvalues of $\\M{U}$ and $\\M{H}$. Transform into the eigenvector basis, and note that determinant and trace of a matrix is invariant under unitary transformation, we have\n\\[\n\\det\\M{U}=\\prod_j u_j=\\prod_j e^{iah_j}=e^{ia\\sum_j h_j}=e^{ia\\,\\mathrm{trace}\\M{H}}\n\\]\nso when $\\mathrm{trace}\\,\\M{H}=0$, $\\det\\M{U}=1$.\n\\medskip\n\n(d) When $\\det\\M{U}=1=e^{i2n\\pi}$, $a\\,\\mathrm{trace}\\,\\M{H}=2n\\pi$, and because $\\M{H}$ is independent of $a$, it must be $n=\n0$, so $\\mathrm{trace}\\,\\M{H}=0$.\n\n\\paragraph{6.5.16}\n$\\M{B}$ is defined as \\[\\M{B}=\\sum_{j=0}^\\infty\\frac{1}{j!}\\M{A}^j\\]\nIf $\\V{x}_i$ is an eigenvector of $\\M{A}$, so $\\M{A}\\V{x}_i=A_i\\V{x}_i$, then \n\\[\n\\M{B}\\V{x}_i=\\sum_{j=o}^\\infty\\frac{1}{j!}\\M{A}^j\n\\V{x}_i=\\sum_{j=0}^\\infty\\frac{1}{j!}(A_i)^j\\V{x}_i=e^{A_i}\\V{x}_i\\]\nwhich means $\\V{x}_i$ is also an eigenvector of $\\M{B}$ with eigenvalue being $e^{A_i}$.\n\n\\paragraph{6.5.17}\nLet $\\V{x}$ be an eigenvector of $\\M{P}$ so $\\M{P}\\V{x}=\\rho_\\lambda\\V{x}$. Then\n\\[\n\\M{P}^2\\V{x}=\\M{P}(\\M{P}\\V{x})=\\M{P}(\\rho_\\lambda\\V{x})=(\\rho_\\lambda)^2\\V{x}\n\\]\nBut also\n\\[\n\\M{P}^2\\V{x}=\\M{P}\\V{x}=\\rho_\\lambda\\V{x}\n\\]\nso $(\\rho_\\lambda)^2=\\rho_\\lambda$, which means $\\rho_\\lambda=0,1$.\n\n\\paragraph{6.5.18}\n$\\br{\\V{x}_i|\\M{A}}{\\V{x}_j}=\\lambda_j\\br{\\V{x}_i}{\\V{x}_j}=\\lambda_j\\delta_{ij}$. So\n\\[\n\\br{\\V{x}|\\M{A}}{\\V{x}}=\\left( \\bra{\\V{x}_1}+\\sum_{i=2}^n\\delta_i\\bra{\\V{x}_i} \\right)\\M{A}\\left( \\ket{\\V{x}_1}+\\sum_{j=2}^n\\delta_j\\ket{\\V{x}_i} \\right)\n\\]\n\\[\n=\\br{\\V{x}_1|\\M{A}}{\\V{x}_1}+\\sum_{j=2}^n\\delta_j\\br{\\V{x}_1|\\M{A}}{\\V{x}_j}+\\sum_{i=2}^n\\delta_i^*\\br{\\V{x}_i|\\M{A}}{\\V{x}_1}+\\sum_{i=2}^n\\sum_{j=2}^n\\delta_i^*\\delta_j\\br{\\V{x}_i|\\M{A}}{\\V{x}_j}\n\\]\n\\[\n=\\lambda_1\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\lambda_i\\br{\\V{x}_i}{\\V{x}_i}\n\\]\nand\n\\[\n\\br{\\V{x}}{\\V{x}}=\\left( \\bra{\\V{x}_1}+\\sum_{i=2}^n\\delta_i\\bra{\\V{x}_i} \\right)\\left( \\ket{\\V{x}_1}+\\sum_{j=2}^n\\delta_j\\ket{\\V{x}_i} \\right)\n\\]\n\\[\n=\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{j=2}^n\\delta_j\\br{\\V{x}_1}{\\V{x}_j}+\\sum_{i=2}^n\\delta_i^*\\br{\\V{x}_i}{\\V{x}_1}+\\sum_{i=2}^n\\sum_{j=2}^n\\delta_i^*\\delta_j\\br{\\V{x}_i}{\\V{x}_j}\n\\]\n\\[\n=\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\br{\\V{x}_i}{\\V{x}_i}\n\\]\nso\n\\[\n\\frac{\\br{\\V{x}|\\M{A}}{\\V{x}}}{\\br{\\V{x}}{\\V{x}}}=\\frac{\\lambda_1\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\lambda_i\\br{\\V{x}_i}{\\V{x}_i}}{\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\br{\\V{x}_i}{\\V{x}_i}}\\leq\n\\frac{\\lambda_1\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\lambda_1\\br{\\V{x}_i}{\\V{x}_i}}{\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\br{\\V{x}_i}{\\V{x}_i}}=\\lambda_1\n\\]\nand the error in $\\lambda_1$ is \n\\[\n\\lambda_1-\\frac{\\br{\\V{x}|\\M{A}}{\\V{x}}}{\\br{\\V{x}}{\\V{x}}}=\\frac{\\sum_{i=2}^n|\\delta_i|^2(\\lambda_1-\\lambda_i)\\br{\\V{x}_i}{\\V{x}_i}}{\\br{\\V{x}_1}{\\V{x}_1}+\\sum_{i=2}^n|\\delta_i|^2\\br{\\V{x}_i}{\\V{x}_i}}\\simeq\n\\frac{\\sum_{i=2 }^n|\\delta_i|^2(\\lambda_1-\\lambda_i)\\br{\\V{x}_i}{\\V{x}_i}}{\\br{\\V{x}_1}{\\V{x}_1}}\n\\]\nso the error is of the order of $|\\delta_i|^2$.\n\n\\paragraph{6.5.19}\n(a) \n\\begin{align*}\n    m\\ddot{x_1}&=-kx_1+k(x_2-x_1)=-2kx_1+kx_2\\\\\n    m\\ddot{x_2}&=k(x_1-x_2)-kx_2=kx_1-2kx_2\n\\end{align*}\n\n(b)\nTo find the normal mode, let $x_1(t)=x_1\\sin\\omega t$,\\; $x_2(t)=x_2\\sin\\omega t$. Substitute and cancel\nout $\\sin\\omega t$, we have\n\\[\n\\begin{pmatrix}\n\\frac{2k}{m}&\\frac{-k}{m}\\\\\n\\frac{-k}{m}&\\frac{2k}{m}\n\\end{pmatrix}\n\\begin{pmatrix}\nx_1\\\\x_2\n\\end{pmatrix}=\\omega^2\n\\begin{pmatrix}\nx_1\\\\x_2\n\\end{pmatrix}\n\\]\nso the secular equation is \n\\[\n\\begin{vmatrix}\n\\frac{2k}{m}-\\omega^2&\\frac{-k}{m}\\\\\n\\frac{-k}{m}&\\frac{2k}{m}-\\omega^2\n\\end{vmatrix}=\n(\\omega^2-\\frac{k}{m})(\\omega^2-\\frac{3k}{m})=0\n\\]\n\\begin{alignat*}{3}\n    & \\omega^2=\\frac{k}{m} ,\\qquad && x_1-x_2=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{2}}(1,1) \\\\\n    & \\omega^2=\\frac{3k}{m} ,\\qquad && -x_1-x_2=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{2}}(1,-1) \\\\\n\\end{alignat*}\n\n(c) For $\\omega^2=\\frac{k}{m}$, $x_1=x_2$, so the two masses vibrate in phase (move together). For $\\omega^2=\\frac{3k}{m}$, $x_1=-x_2$, so the two masses vibrate in anti-symmetry movement.\n\n\\paragraph{6.5.20}\nFollow the proof in Section 6.5 (p.319), we know if $\\M{A}\\V{x}_j=\\lambda_j\\V{x}_j$, or $(\\M{A}-\\lambda_j\\M{I})\\ket{\\V{x}_j}=0$, then we have $(\\M{A}^\\dagger-\\lambda_j^*\\M{I})\\ket{\\V{x}_j}=0$, or $\\M{A}^\\dagger\\V{x}_j=\\lambda_j^*\\V{x}_j$, so $\\ket{\\V{x}_j}$ is also an eigenvector of $\\M{A}^\\dagger$ with eigenvalue $\\lambda_j^*$.\n\\[\n\\frac{\\M{A}+\\M{A}^\\dagger}{2}\\V{x}_j=\\frac{\\n_j+\\n_j^*}{2}\\V{x}_j=\\mathfrak{Re}(\\n_j)\\,\\V{x}_j\n\\]\nso $\\V{x}_j$ is an eigenvector of $\\frac{\\M{A}+\\M{A}^\\dagger}{2}$ with $\\mathfrak{Re}(\\n_j)$ as eigenvalue.\n\\[\n\\frac{\\M{A}-\\M{A}^\\dagger}{2i}\\V{x}_j=\\frac{\\n_j-\\n_j^*}{2i}\\V{x}_j=\\mathfrak{Im}(\\n_j)\\,\\V{x}_j\n\\]\nso $\\V{x}_j$ is an eigenvector of $\\frac{\\M{A}-\\M{A}^\\dagger}{2i}$ with $\\mathfrak{Im}(\\n_j)$ as eigenvalue.\n\n\\paragraph{6.5.21}\n(a) Substituting into Eq. 3.37, we have\n\\[\n\\M{U}=\n\\begin{pmatrix}\n\\frac{1}{2}&\\frac{-1}{2}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{2}&\\frac{-1}{2}&\\frac{-1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\n\\end{pmatrix}\n\\]\n\n(b)\n\\[\n\\begin{vmatrix}\n\\frac{1}{2}-\\n&\\frac{-1}{2}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{2}&\\frac{-1}{2}-\\n&\\frac{-1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&-\\n\n\\end{vmatrix}=-(\\n-1)(\\n-\\frac{-1+\\sqrt{3}i}{2})(\\n-\\frac{-1-\\sqrt{3}i}{2})=0\n\\]\n\\begin{alignat*}{4}\n    & \\n_1=1,\\qquad && -x_1-x_2+\\sqrt{2}x_3=0,\\qquad && x_1-3x_2-\\sqrt{2}x_3=0,\\qquad && \\V{c}_1=\\frac{1}{\\sqrt{3}}(\\sqrt{2},0,1)\\\\\n    & \\n_2=\\frac{-1+\\sqrt{3}i}{2},\\qquad && (2-\\sqrt{3}i)x_1-x_2+\\sqrt{2}x_3=0,\\qquad && x_1-\\sqrt{3}ix_2-\\sqrt{2}x_3=0,\\qquad && \\V{c}_2=\\frac{1}{\\sqrt{6}}(1,-\\sqrt{3}i,-\\sqrt{2})\\\\\n    & \\n_3=\\frac{-1-\\sqrt{3}i}{2},\\qquad && (2+\\sqrt{3}i)x_1-x_2+\\sqrt{2}x_3=0,\\qquad && x_1+\\sqrt{3}ix_2-\\sqrt{2}x_3=0,\\qquad && \\V{c}_3=\\frac{1}{\\sqrt{6}}(1,\\sqrt{3}i,-\\sqrt{2})\\\\\n\\end{alignat*}\nThe eigenvector with $\\n=1$ is in the direction of rotation axis, which is $\\V{c}_1=\\frac{1}{\\sqrt{3}}(\\sqrt{2},0,1)$.\nFrom Exercise 6.5.4, we know the other two eigenvalues of a rotation are $e^{i\\varphi}$ and $e^{-i\\varphi}$. Compared with $\\n_2=e^{i\\frac{2\\pi}{3}}$, $\\n_3=e^{-i\\frac{2\\pi}{3}}$, we know the rotation angle is $\\frac{2\\pi}{3}$.\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "fd134958a4670ff76609e27716d4bb1a219b8725", "size": 36432, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 06/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 06/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 06/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9605263158, "max_line_length": 475, "alphanum_fraction": 0.5846783048, "num_tokens": 18034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.43129199668478124}}
{"text": "\\documentclass[english]{../thermomemo/thermomemo}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{amsmath}\n%\\input{mathdef}\n\\usepackage[per-mode=symbol]{siunitx}\n\\usepackage[numbers]{natbib}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{array}% improves tabular environment.\n\\usepackage{dcolumn}% also improves tabular environment, with decimal centring.\n\\usepackage{chemformula}     % For easy typing of chemical formulae\n\\usepackage{booktabs}\n\\usepackage{a4wide}\n\\usepackage{xspace}\n\\usepackage{todonotes}\n\\presetkeys{todonotes}{inline}{}\n\\usepackage{subcaption,caption}\n%\\pdfminorversion=4\n\\usepackage{tikz}\n\\usetikzlibrary{arrows}\n\\usetikzlibrary{snakes}\n\\usepackage{verbatim}\n\\usepackage{hyperref}\n\\hypersetup{\n  colorlinks=true,\n  linkcolor=blue,\n  urlcolor=blue,\n  citecolor=blue\n}\n\\usepackage{blkarray, bigstrut}\n\n%\n% Egendefinerte\n%\n% Kolonnetyper for array.sty:\n\\newcolumntype{C}{>{$}c<{$}}% for å slippe å taste inn disse $\n\\newcolumntype{L}{>{$}l<{$}}% for å slippe å taste inn disse $\n%\n\\newcommand*{\\unit}[1]{\\ensuremath{\\,\\mathrm{#1}}}\n\\newcommand*{\\uunit}[1]{\\ensuremath{\\mathrm{#1}}}\n%\\newcommand*{\\od}[3][]{\\frac{\\mathrm{d}^{#1}#2}{\\mathrm{d}{#3}^{#1}}}% ordinary derivative\n\\newcommand*{\\od}[3][]{\\frac{\\dif^{#1}#2}{\\dif{#3}^{#1}}}% ordinary derivative\n\\newcommand*{\\pd}[3][]{\\frac{\\partial^{#1}#2}{\\partial{#3}^{#1}}}% partial derivative\n\\newcommand*{\\pdc}[3]{\\frac{\\partial^{2}#1}{\\partial{#2}\\partial{#3}}}% partial derivative\n\\newcommand*{\\pdt}[3][]{{\\partial^{#1}#2}/{\\partial{#3}^{#1}}}% partial\n                                % derivative for inline use.\n\\newcommand{\\pone}[3]{\\frac{\\partial #1}{\\partial #2}_{#3}}% partial\n                                % derivative with information of\n                                % constant variables\n\\newcommand{\\ponel}[3]{\\frac{\\partial #1}{\\partial #2}\\bigg|_{#3}} % partial derivative with informatio of constant variable. A line is added.\n\\newcommand{\\ptwo}[3]{\\frac{\\partial^{2} #1}{\\partial #2 \\partial\n    #3}} % partial differential in two different variables\n\\newcommand{\\pdn}[3]{\\frac{\\partial^{#1}#2}{\\partial{#3}^{#1}}}% partial derivative\n\\newcommand*{\\pder}[2]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)}\n\\newcommand*{\\pdder}[2]{\\left(\\frac{\\partial^2 #1}{\\partial #2^2}\\right)}\n\\newcommand*{\\pdersub}[3]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)_{#3}}\n\n% Total derivative:\n\\newcommand*{\\ttd}[2]{\\frac{\\mathrm{D} #1}{\\mathrm{D} #2}}\n\\newcommand*{\\td}[2]{\\frac{\\mathrm{d} #1}{\\mathrm{d} #2}}\n\\newcommand*{\\ddt}{\\frac{\\partial}{\\partial t}}\n\\newcommand*{\\ddx}{\\frac{\\partial}{\\partial x}}\n% Vectors etc:\n% For Computer Modern:\n\n\\DeclareMathAlphabet{\\mathsfsl}{OT1}{cmss}{m}{sl}\n\\renewcommand*{\\vec}[1]{\\boldsymbol{#1}}%\n\\newcommand*{\\vektor}[1]{\\boldsymbol{#1}}%\n\\newcommand*{\\tensor}[1]{\\mathsfsl{#1}}% 2. order tensor\n\\newcommand*{\\matr}[1]{\\tensor{#1}}% matrix\n\\renewcommand*{\\div}{\\boldsymbol{\\nabla\\cdot}}% divergence\n\\newcommand*{\\grad}{\\boldsymbol{\\nabla}}% gradient\n% fancy differential from Claudio Beccari, TUGboat:\n% adjusts spacing automatically\n\\makeatletter\n\\newcommand*{\\dif}{\\@ifnextchar^{\\DIfF}{\\DIfF^{}}}\n\\def\\DIfF^#1{\\mathop{\\mathrm{\\mathstrut d}}\\nolimits^{#1}\\gobblesp@ce}\n\\def\\gobblesp@ce{\\futurelet\\diffarg\\opsp@ce}\n\\def\\opsp@ce{%\n  \\let\\DiffSpace\\!%\n  \\ifx\\diffarg(%\n    \\let\\DiffSpace\\relax\n  \\else\n    \\ifx\\diffarg[%\n      \\let\\DiffSpace\\relax\n    \\else\n      \\ifx\\diffarg\\{%\n        \\let\\DiffSpace\\relax\n      \\fi\\fi\\fi\\DiffSpace}\n\\makeatother\n%\n\\newcommand*{\\me}{\\mathrm{e}}% e is not a variable (2.718281828...)\n%\\newcommand*{\\mi}{\\mathrm{i}}%  nor i (\\sqrt{-1})\n\\newcommand*{\\mpi}{\\uppi}% nor pi (3.141592...) (works for for Lucida)\n%\n% lav tekst-indeks/subscript/pedex\n\\newcommand*{\\ped}[1]{\\ensuremath{_{\\text{#1}}}}\n% høy tekst-indeks/superscript/apex\n\\newcommand*{\\ap}[1]{\\ensuremath{^{\\text{#1}}}}\n\\newcommand*{\\apr}[1]{\\ensuremath{^{\\mathrm{#1}}}}\n\\newcommand*{\\pedr}[1]{\\ensuremath{_{\\mathrm{#1}}}}\n%\n\\newcommand*{\\volfrac}{\\alpha}% volume fraction\n\\newcommand*{\\surften}{\\sigma}% coeff. of surface tension\n\\newcommand*{\\curv}{\\kappa}% curvature\n\\newcommand*{\\ls}{\\phi}% level-set function\n\\newcommand*{\\ep}{\\Phi}% electric potential\n\\newcommand*{\\perm}{\\varepsilon}% electric permittivity\n\\newcommand*{\\visc}{\\mu}% molecular (dymamic) viscosity\n\\newcommand*{\\kvisc}{\\nu}% kinematic viscosity\n\\newcommand*{\\cfl}{C}% CFL number\n\n\\newcommand*{\\cons}{\\vec U}\n\\newcommand*{\\flux}{\\vec F}\n\\newcommand*{\\dens}{\\rho}\n\\newcommand*{\\svol}{\\ensuremath v}\n\\newcommand*{\\temp}{\\ensuremath T}\n\\newcommand*{\\vel}{\\ensuremath u}\n\\newcommand*{\\mom}{\\dens\\vel}\n\\newcommand*{\\toten}{\\ensuremath E}\n\\newcommand*{\\inten}{\\ensuremath e}\n\\newcommand*{\\press}{\\ensuremath p}\n\\renewcommand*{\\ss}{\\ensuremath a}\n\\newcommand*{\\jac}{\\matr A}\n%\n\\newcommand*{\\abs}[1]{\\lvert#1\\rvert}\n\\newcommand*{\\bigabs}[1]{\\bigl\\lvert#1\\bigr\\rvert}\n\\newcommand*{\\biggabs}[1]{\\biggl\\lvert#1\\biggr\\rvert}\n\\newcommand*{\\norm}[1]{\\lVert#1\\rVert}\n%\n\\newcommand*{\\e}[1]{\\times 10^{#1}}\n\\newcommand*{\\ex}[1]{\\times 10^{#1}}%shorthand -- for use e.g. in tables\n\\newcommand*{\\exi}[1]{10^{#1}}%shorthand -- for use e.g. in tables\n\\newcommand*{\\nondim}[1]{\\ensuremath{\\mathit{#1}}}% italic iflg. ISO. (???)\n\\newcommand*{\\rey}{\\nondim{Re}}\n\\newcommand*{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}%acronyms etc.\n\n\\newcommand{\\nto}{\\ensuremath{\\mbox{N}_{\\mbox{\\scriptsize 2}}}}\n\\newcommand{\\chfire}{\\ensuremath{\\mbox{CH}_{\\mbox{\\scriptsize 4}}}}\n%\\newcommand*{\\checked}{\\ding{51}}\n\\newcommand{\\coto}{\\ensuremath{\\text{CO}_{\\text{\\scriptsize 2}}}}\n\\newcommand{\\celsius}{\\ensuremath{^\\circ\\text{C}}}\n\\newcommand{\\clap}{Clapeyron~}\n\\newcommand{\\subl}{\\ensuremath{\\text{sub}}}\n\\newcommand{\\spec}{\\text{spec}}\n\\newcommand{\\sat}{\\text{sat}}\n\\newcommand{\\sol}{\\text{sol}}\n\\newcommand{\\liq}{\\text{liq}}\n\\newcommand{\\vap}{\\text{vap}}\n\\newcommand{\\amb}{\\text{amb}}\n\\newcommand{\\tr}{\\text{tr}}\n\\newcommand{\\crit}{\\text{crit}}\n\\newcommand{\\entr}{\\ensuremath{\\text{s}}}\n\\newcommand{\\fus}{\\text{fus}}\n\\newcommand{\\flash}[1]{\\ensuremath{#1\\text{-flash}}}\n\\newcommand{\\spce}[2]{\\ensuremath{#1\\, #2\\text{ space}}}\n\\newcommand{\\spanwagner}{\\text{Span--Wagner}}\n\\newcommand{\\triplepoint}{\\text{TP triple point}}\n\\newcommand{\\wrpt}{\\text{with respect to~}}\n\\newcommand{\\tpd}{\\ensuremath{\\text{tpd}}\\xspace}\n\\newcommand{\\TPD}{\\ensuremath{\\text{TPD}}\\xspace}\n\\newcommand{\\lp}{\\ensuremath{\\left(}\\xspace}\n\\newcommand{\\rp}{\\ensuremath{\\right)}\\xspace}\n\\newcommand{\\mbn}[0]{\\mathbf n}\n\\newcommand{\\mbe}[0]{\\mathbf e}\n\\newcommand{\\mbx}[0]{\\mathbf x}\n\\newcommand{\\app}{\\ensuremath{\\text{App}}\\xspace}\n\\newcommand{\\nacl}{\\ensuremath{\\text{\\ch{NaCl}}}\\xspace}\n\\newcommand{\\na}{\\ensuremath{\\text{\\ch{Na+}}}\\xspace}\n\\newcommand{\\cl}{\\ensuremath{\\text{\\ch{Cl-}}}\\xspace}\n\\newcommand{\\ideal}{\\ensuremath{\\text{Id}}\\xspace}\n\n\\title{Apparent composition approach}\n\\author{Morten Hammer}\n\n\\graphicspath{{gfx/}}\n\n\\begin{document}\n\\frontmatter\n\\tableofcontents\n\\section{Introduction}\n\\citet[Chap. 13, Sec. 7]{Michelsen2007} describe the apparent\ncomposition approach in the context of chemical\nreactions. \\citet[App. C.3]{Mogensen2014} uses this approach when\nmodelling phase equilibrium for electrolyte system, using the salts as\napparent composition.\n\nThe idea is to use a model with all species ($\\vektor{n}$) to model\nother species, the apparent species ($\\vektor{e}$). The relation\nbetween the apparent and real species are derived from the following,\n\\begin{equation}\n  A\\lp T, V, \\mbe \\rp = A\\lp T, V, \\mbn \\rp,\n\\label{eq:helmholtz}\n\\end{equation}\nand its differentials. We immediately see that the volume and\ntemperature differentials are unaffected by the mole number\nrepresentation.\n\nUsing salt (\\ch{NaCl}) to represent ions (\\ch{Na+},\\ch{Cl-}) as an\nexample, some additional differentials are required. The apparent mole\nvector will then be $\\mbe$ (salts) while the actual mole vector will\nbe $\\mbn$ (ions). We then have,\n\n\\begin{align}\n  F\\lp T, V, \\mbn \\rp &= F\\lp T, V, \\mbe \\rp,\\\\\n  F_i^\\app = \\pdersub{F}{e_i}{T,V} &=\n  \\sum_k\\pdersub{F}{n_k}{T,V}\\pder{n_k}{e_i}\n  = \\sum_k v_{ik} \\pdersub{F}{n_k}{T,V},\\\\\n  F_{ij}^\\app &\n  = \\sum_k v_{ik} \\sum_m v_{jm} F_{ij}.\n\\end{align}\nHere $v_{ik}$ is the stoichiometric composition of ion $j$ in salt\n$i$. For a system of \\ch{NaCl}, \\ch{H2O} and \\ch{CO2}, $\\mathbf{v}$\nwill look as follows,\n\\begin{equation}\n  \\begin{blockarray}{*{4}{c} l}\n    \\begin{block}{*{4}{>{$\\footnotesize}c<{$}} l}\n      \\ch{H2O} & \\ch{CO2} & \\ch{Na+} & \\ch{Cl-} & \\\\\n    \\end{block}\n    \\begin{block}{[*{4}{c}]>{$\\footnotesize}l<{$}}\n      1 & 0 & 0 & 0  \\bigstrut[t] & \\ch{H2O} \\\\\n      0 & 1 & 0 & 0 & \\ch{CO2} \\\\\n      0 & 0 & 1 & 1 & \\ch{NaCl} \\\\\n    \\end{block}\n  \\end{blockarray}\n\\end{equation}\n\nWith this approach, no special handling of the charge balance in the\nphases are required when calculating phase equilibrium. Another\nadvantage is equilibrium calculation of solid \\ch{NaCl}, as the\nsolid fugacity only need to equate the fugacity of the fictitious\ndissolved salt component.\n\n\\section{Thermodynamic differentials}\n\nIf we consider the chemical potentials (enthalpy, entropy, Gibbs free\nenergy, Helmholtz free energy or internal energy) as a function of the\nreal or apparent composition, the value remains the same. IE. it is\nonly the compositional differentials of the potentials that differ\nwhen introducing the apparent composition.\n\nWe therefore need to map only the fugacities, compressibillity factor\nand their differentials.\n\n\\subsection{Compressibillity factor}\nFor the compressibillity factor, the following applies,\n\\begin{equation}\n  \\frac{PV}{RT} = \\sum_j e_j Z^\\app = \\sum_i n_i Z.\n  \\label{eq:compressibillity_factor_relation}\n\\end{equation}\nWe therefore have\n\\begin{equation}\n  Z^\\app = Z \\frac{\\sum_i n_i}{\\sum_j e_j }.\n  \\label{eq:compressibillity_factor}\n\\end{equation}\nThe pressure and temperature differential must be scaled in the same\nmanner for the apparent mode, while the compositional differentials\nare slightly more complicated.\n\n\\subsection{Fugacity coefficients}\n\\begin{equation}\n  \\ln \\lp x_\\nacl^\\app \\varphi_\\nacl^\\app \\rp  = v_\\na \\ln \\lp x_\\na \\varphi_\\na \\rp + v_\\cl \\ln \\lp x_\\cl \\varphi_\\cl \\rp\n\\label{eq:fugacity_coeff}\n\\end{equation}\n\nAssuming we have one mole of water, and want to look at the infinite\ndilution value of $\\ln \\varphi_\\nacl^\\app$. The mole number relation between \\nacl and the ions \\na and \\cl are one-to-one, giving,\n\\begin{gather}\n  \\ln n_\\nacl + \\ln \\varphi_\\nacl^\\app - \\ln \\lp 1 + n_\\nacl \\rp  = 2 \\ln n_\\nacl + \\ln \\lp\\varphi_\\na\\varphi_\\cl\\rp - 2\\ln \\lp 1 + 2 n_\\nacl \\rp \\nonumber \\\\\n  \\ln \\varphi_\\nacl^\\app = \\ln n_\\nacl + \\ln \\lp\\varphi_\\na\\varphi_\\cl\\rp - 2\\ln \\lp 1 + 2 n_\\nacl \\rp + \\ln \\lp 1 + n_\\nacl \\rp \\nonumber \\\\\n  \\lim_{n_\\nacl \\rightarrow 0}\\ln \\varphi_\\nacl^\\app = \\lim_{n_\\nacl \\rightarrow 0} \\ln \\lp n_\\nacl \\varphi_\\na\\varphi_\\cl\\rp \\rightarrow - \\infty\n\\label{eq:fugacity_coeff_inf}\n\\end{gather}\n\nSince the fugacity depend on the composition, and the infinite\ndilution fugacity approaches an infinity value, this approach can be\nchallenging to handle numerically.\n\n\\subsubsection{Differentials}\nAdditionally there is an effect of the difference in overall mole\nnumbers, as $\\sum_i n_i \\neq \\sum_i e_i$. See Maribo--Mogensen\n\\cite[App. C.3]{Mogensen2014}.\n\nThe equilibrium condition becomes,\n\\begin{equation}\n  \\ln \\lp \\frac{x^\\app \\varphi^\\app P}{P^0} \\rp  = \\sum_j v_{ij} \\ln \\lp \\frac{x_j \\varphi_j P}{P^0} \\rp\n\\label{eq:fugacity}\n\\end{equation}\n\nTo describe the apparent fugacity coefficient, the relation become,\n\\begin{equation}\n  \\ln \\varphi^\\app_i  = \\sum_j v_{ij} \\ln x_j \\varphi_j - \\ln x_i^\\app - \\lp 1 - \\sum_j v_{ij} \\rp \\ln \\frac{P}{P^0}\n\\label{eq:fugacity_coeff_app}\n\\end{equation}\nDifferentiating with respect to temperature,\n\\begin{equation}\n  \\pd{\\ln \\varphi^\\app_i}{T}  = \\sum_j v_{ij} \\ln \\pd{\\varphi_j}{T}.\n\\label{eq:fugacity_coeff_app_T}\n\\end{equation}\nDifferentiating with respect to pressure,\n\\begin{equation}\n  \\pd{\\ln \\varphi^\\app_i}{P}  = \\sum_j v_{ij} \\ln \\pd{\\varphi_j}{P} - \\frac{1}{P} + \\frac{\\sum_j v_{ij}}{P}.\n\\label{eq:fugacity_coeff_app_P}\n\\end{equation}\n\nDifferentiating with respect to mole numbers, using $\\sum_i e_i = e_T$,\n$n_T = \\sum_j \\sum_i v_{ij} e_i = n_T$, and\n\n\\begin{align}\n  x_j  &= \\frac{\\sum_l v_{jl} e_l}{n_T}\\\\\n  \\pd{\\ln x_j}{e_k} &= \\sum_l \\lp\\pd{n_l}{e_k}\\rp \\lp \\pd{\\ln x_i}{n_l} \\rp = \\sum_l v_{kl} \\lp \\pd{\\ln n_j}{n_l} -\\pd{\\ln n_T}{n_l} \\rp \\nonumber \\\\\n  &= \\sum_l v_{kl} \\lp \\frac{\\delta_{jl}}{n_l} - \\frac{1}{n_T} \\rp = \\frac{v_{kj}}{n_j} - \\frac{\\sum_l v_{kl}}{n_T},\n\\label{eq:x_ion}\n\\end{align}\n\n\\begin{align}\n  \\pd{\\ln \\varphi^\\app_i}{e_k}  &= - \\frac{\\delta_{ik}}{e_k} + \\frac{1}{e_T} + \\sum_j v_{ij} \\pd{\\ln \\varphi_j}{e_k} + \\sum_j v_{ij} \\pd{\\ln x_j}{e_k} \\nonumber \\\\\n  &= - \\frac{\\delta_{ik}}{e_k} + \\frac{1}{e_T} + \\sum_j v_{ij} \\sum_l v_{kl} \\pd{\\ln \\varphi_j}{n_l} + \\sum_j v_{ij} \\lp \\frac{v_{kj}}{n_j} - \\frac{\\sum_l v_{kl}}{n_T} \\rp\n\\label{eq:fugacity_coeff_app_n}\n\\end{align}\n\n\\subsection{Ideal properties}\nIn order to calculate equilibrium between a salt (solid), and the\napparent composition in the fluid phases, the ideal Gibbs free energy\nis required.\n\nFor the enthalpy we have,\n\\begin{equation}\n  h^\\ideal \\lp \\vektor{e},  T \\rp = \\sum_j e_j h_j^\\ideal \\lp T \\rp,\n\\label{eq:id_enthalpy}\n\\end{equation}\nand for the entropy,\n\\begin{equation}\n  s^\\ideal \\lp \\vektor{e},  T, P \\rp = \\sum_j e_j \\lp s_j^{\\ideal,*} \\lp T \\rp  - R \\ln \\frac{e_j}{e_T} - R \\ln P \\rp.\n\\label{eq:id_entropy}\n\\end{equation}\nHere $s_j^{\\ideal,*} \\lp T \\rp$ simply is the temperature integral of $Cp(T)/T$.\n\nThe ideal Gibbs free energy is,\n\\begin{equation}\n  g^\\ideal \\lp \\vektor{e},  T, P \\rp = h^\\ideal \\lp \\vektor{e},  T \\rp - T s^\\ideal \\lp \\vektor{e},  T, P \\rp.\n\\label{eq:id_gibbs}\n\\end{equation}\n\nThe ideal chemical potential therefore becomes,\n\\begin{align}\n  \\mu_i &= \\pd{g^\\ideal}{e_i} = h^\\ideal_i - T \\lp s_i^{\\ideal,*}  - R \\ln \\frac{e_i}{e_T} - R \\ln P \\rp, \\\\\n  &= h^\\ideal_i - T s_i^{\\ideal,*}  + RT \\ln \\lp x_i P \\rp.\n\\label{eq:id_chempot}\n\\end{align}\n\nSince the $\\ln \\lp x_i P \\rp$ is accounted for in the fugacity\ncoefficient, we only need to account for $h^\\ideal_i - T\ns_i^{\\ideal,*}$.\n\n\\clearpage\n\\bibliographystyle{plainnat}\n\\bibliography{../thermopack}\n\n\\end{document}\n", "meta": {"hexsha": "c9354f4543acc9975c5f60c98564cc1940d45742", "size": 14201, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/memo/apparent/apparent.tex", "max_stars_repo_name": "SINTEF/Thermopack", "max_stars_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2020-10-14T07:51:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T04:59:23.000Z", "max_issues_repo_path": "doc/memo/apparent/apparent.tex", "max_issues_repo_name": "SINTEF/Thermopack", "max_issues_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2020-10-26T11:43:43.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T22:06:30.000Z", "max_forks_repo_path": "doc/memo/apparent/apparent.tex", "max_forks_repo_name": "SINTEF/Thermopack", "max_forks_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2020-10-27T13:04:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T04:59:24.000Z", "avg_line_length": 39.229281768, "max_line_length": 171, "alphanum_fraction": 0.6832617421, "num_tokens": 5172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4312919894506858}}
{"text": "\\section{Refinement Reflection}\n\\label{sec:formalism}\n\\label{sec:types-reflection}\n\nOur first step towards formalizing refinement\nreflection is a core calculus \\corelan with an\n\\emph{undecidable} type system based on\ndenotational semantics.\nWe show how the soundness of the type system\nallows us to \\emph{prove theorems} using \\corelan.\n\n%\n%% Note that \\smtlan programs are a subset of\n%% \\corelan programs derivations\n%%\n%% a subset of \\corelan where the that forms a\n%% decidable logic of\n%% refinements, and use it to obtain \\corelan with\n%% decidable SMT-based algorithmic typing.\n\n\\subsection{Syntax}\n\\input{text/refinementreflection/syntax}\n%\nFigure~\\ref{fig:syntax} summarizes the syntax of \\corelan,\nwhich is essentially the calculus \\undeclang~\\cite{Vazou14}\nwith explicit recursion and a special $\\erefname$ binding form\nto denote terms that are reflected into the refinement logic.\n%\nIn \\corelan refinements $r$ are arbitrary expressions $e$\n(hence $r ::= e$ in Figure~\\ref{fig:syntax}).\n%\nThis choice allows us to prove preservation and progress,\nbut renders typechecking undecidable.\n%\nIn \\S~\\ref{sec:algorithmic} we will see how to recover\ndecidability by soundly approximating refinements.\n\nThe syntactic elements of \\corelan are layered into\nprimitive constants, values, expressions, binders\nand programs.\n\n\\mypara{Constants}\nThe primitive constants of \\corelan\ninclude all the primitive logical\noperators $\\op$, here, the set $\\{ =, <\\}$.\n%\nMoreover, they include the\nprimitive booleans $\\etrue$, $\\efalse$,\nintegers $\\mathtt{-1}, \\mathtt{0}$, $\\mathtt{1}$, \\etc,\nand logical operators $\\mathtt{\\land}$, $\\mathtt{\\lor}$, $\\mathtt{\\lnot}$, \\etc.\n\n\\mypara{Data Constructors}\n%\nWe encode data constructors as special constants.\n% Each data type has an equality predicate $\\haseq{T}$\n% that is true only if values of type $T$ can be finitely compared.\nFor example the data type \\tintlist, which represents\nfinite lists of integers, has two data constructors: $\\dnull$ (``nil'')\nand $\\dcons$ (``cons'').\n% and satisfies $\\haseq{\\tintlist}$.\n\n%% NV Arity is not used anywhere\n%%Each data type has an arity $\\arity{T}$ that represents\n%%the exact number of data constructors that return\n%%a value of type $T$.\n%\n%%For example the data type \\tintlist, which represents\n%%lists of integers, has two data constructors: $\\dnull$ (``nil'')\n%%and $\\dcons$ (``cons'') and so has arity $2$.\n\n\n\\mypara{Values \\& Expressions}\n%\nThe values of \\corelan include\nconstants, $\\lambda$-abstractions\n$\\efun{x}{\\typ}{e}$, and fully\napplied data constructors $D$\nthat wrap values.\n%\nThe expressions of \\corelan\ninclude values and variables $x$,\napplications $\\eapp{e}{e}$, and\n$\\mathtt{case}$ expressions.\n\n\\mypara{Binders \\& Programs}\n%\nA \\emph{binder} $\\bd$ is a series of possibly recursive\nlet definitions, followed by an expression.\n%\nA \\emph{program} \\prog is a series of $\\erefname$\ndefinitions, each of which names a function\nthat can be reflected into the refinement\nlogic, followed by a binder.\n%\nThe stratification of programs via binders\nis required so that arbitrary recursive definitions\nare allowed but cannot be inserted into the logic\nvia refinements or reflection.\n%\n(We \\emph{can} allow non-recursive $\\mathtt{let}$\nbinders in $e$, but omit them for simplicity.)\n\n\\subsection{Operational Semantics}\n\nFigure~\\ref{fig:syntax} summarizes the small\nstep contextual $\\beta$-reduction semantics for\n\\corelan.\n%\n%%There are two points to note.\n%%%\n%%First, we allow for reductions under\n%%data constructors, and thus, values may\n%%be further reduced.\n%%%\n%%Second, for simplicity, we treat both\n%%$\\eletname$ and $\\erefname$ as possibly\n%%recursive (\\ie $\\mathtt{let\\ rec}$) binders.\n%% Note that, for simplicity, we treat each\n%% $\\eletname$ as a possibly\n%% recursive (\\ie $\\mathtt{let\\ rec}$) binder.\n%\nWe write \\evalj{e}{e'}{j} if there exist\n$e_1,\\ldots,e_j$ such that $e$ is $e_1$,\n$e'$ is $e_j$ and $\\forall i,j, 1 \\leq i < j$,\nwe have $\\evals{e_i}{e_{i+1}}$.\n%\nWe write $\\evalsto{e}{e'}$ if there exists\nsome finite $j$ such that $\\evalj{e}{e'}{j}$.\n%\nWe define $\\betaeq{}{}$ to be the reflexive,\nsymmetric, transitive closure of $\\evals{}{}$.\n\n\\mypara{Constants} Application of a constant requires the\nargument be reduced to a value; in a single step the\nexpression is reduced to the output of the primitive\nconstant operation.\n%\nFor example, consider $=$, the primitive equality\noperator on integers.\n%\nWe have $\\ceval{=}{n} \\defeq =_n$\nwhere $\\ceval{=_n}{m}$ equals \\etrue\niff $m$ is the same as $n$.\n%\n%\\mypara{Equality}\n%\nWe assume that the equality operator\nis defined \\emph{for all} values,\nand, for functions, is defined as\nextensional equality.\n%\nThat is, for all\n$f$ and\n$f'$\nwe have\n$\\evals{(f = f')}{\\etrue}\n  \\quad \\mbox{iff} \\quad\n  \\forall v.\\ \\betaeq{f\\ v}{f'\\ v}$.\n%\nWe assume source \\emph{terms} only contain implementable equalities\nover non-function types; the above only appears in \\emph{refinements}\nand allows us to state and prove facts about extensional\nequality~\\S~\\ref{subsec:extensionality}.\n%% % \\RJ{CHECK}\n\n%%That is, for all\n%%$f \\defeq \\efun{x}{\\typ}{e}$ and\n%%$f' \\defeq \\efun{x}{\\typ}{e'}$\n%%we have\n%%$$\\evals{(f = f')}{\\etrue}\n%%  \\quad \\mbox{iff} \\quad\n%%  \\forall v.\\ \\evalsto{(\\SUBST{e}{x}{v} = \\SUBST{e'}{x}{v})}{\\etrue}\n%%$$\n\n\n\\subsection{Types}\n\n\\corelan types include basic types, which are \\emph{refined} with predicates,\nand dependent function types.\n%\n\\emph{Basic types} \\btyp comprise integers, booleans, and a family of data-types\n$T$ (representing lists, trees \\etc.)\n%\nFor example the data type \\tintlist represents lists of integers.\n%\nWe refine basic types with predicates (boolean valued expressions \\refa) to obtain\n\\emph{basic refinement types} $\\tref{v}{\\btyp}{\\refa}$.\n%\nFinally, we have dependent \\emph{function types} $\\tfun{x}{\\typ_x}{\\typ}$\nwhere the input $x$ has the type $\\typ_x$ and the output $\\typ$ may\nrefer to the input binder $x$.\n%\nWe write $\\btyp$ to abbreviate $\\tref{v}{\\btyp}{\\etrue}$,\nand \\tfunbasic{\\typ_x}{\\typ} to abbreviate \\tfun{x}{\\typ_x}{\\typ} if\n$x$ does not appear in $\\typ$.\n%\nWe use $r$ to refer to refinements.\n\n\n\\mypara{Denotations}\n%\nEach type $\\typ$ \\emph{denotes} a set of expressions $\\interp{\\typ}$,\nthat are defined via the dynamic semantics~\\cite{Knowles10}.\n%\nLet $\\shape{\\typ}$ be the type we get if we erase all refinements\nfrom $\\typ$ and $\\bhastype{}{e}{\\shape{\\typ}}$ be the\nstandard typing relation for the typed lambda calculus.\n%\nThen, we define the denotation of types as:\n\\begin{align*}\n\\interp{\\tref{x}{\\btyp}{r}} \\defeq &\n    \\{e \\mid  \\bhastype{}{e}{\\btyp},\n              \\mbox{ if } \\evalsto{e}{w}\n              \\mbox{ then } \\evalsto{r\\subst{x}{w}}{\\etrue} \\}\\\\\n\\interp{\\tfun{x}{\\typ_x}{\\typ}} \\defeq &\n    \\{e \\mid  \\bhastype{}{e}{\\shape{\\tfunbasic{\\typ_x}{\\typ}}},\n              \\forall e_x \\in \\interp{\\typ_x}.\\ \\eapp{e}{e_x} \\in \\interp{\\typ\\subst{x}{e_x}}\n    \\}\n\\end{align*}\n\n\n\\mypara{Constants}\nFor each constant $c$ we define its type \\constty{c}\nsuch that $c \\in \\interp{\\constty{c}}$.\n%\nFor example,\n%\n$$\n\\begin{array}{lcl}\n\\constty{3} &\\doteq& \\tref{v}{\\tint}{v = 3}\\\\\n\\constty{+} &\\doteq& \\tfun{\\ttx}{\\tint}{\\tfun{\\tty}{\\tint}{\\tref{v}{\\tint}{v = x + y}}}\\\\\n\\constty{\\leq} &\\doteq& \\tfun{\\ttx}{\\tint}{\\tfun{\\tty}{\\tint}{\\tref{v}{\\tbool}{v \\Leftrightarrow x \\leq y}}}\\\\\n\\end{array}\n$$\n%\nSo, by definition we get the constant typing lemma\n%\n\\begin{lemma}{[Constant Typing]}\\label{lemma:constants}\nEvery constant $c \\in \\interp{\\constty{c}}$.\n\\end{lemma}\n%\nThus, if $\\constty{c} \\defeq \\tfun{x}{\\typ_x}{\\typ}$,\nthen for every value $w \\in \\interp{\\typ_x}$, we require\n$\\ceval{c}{w} \\in \\interp{\\typ\\subst{x}{w}}$.\n\n%% \\mypara{Equality}\n%% The equality predicate\n%% $\\haseq{B}$, is defined to be true for \\tint and \\tbool,\n%% and for each type constructor $T$\n%% whose values can be finitely compared.\n%% %\n%% So, by definition we get the equality lemma\n%% %\n%% \\begin{lemma}{[Equality]}\\label{lemma:equality}\n%% If $\\haseq{B}$ then for each value $\\bhastype{\\emptyset}{w}{B}$\n%% \\evalsto{w = w}{\\etrue}\n%% \\end{lemma}\n\n\\subsection{Refinement Reflection}\n\\label{subsec:logicalannotations}\n%\nThe simple, but key idea in our work is to\n\\emph{strengthen} the output type of functions\nwith a refinement that \\emph{reflects} the\ndefinition of the function in the logic.\n%\nWe do this by treating each\n%\n$\\erefname$-binder:\n%\n${\\erefb{f}{\\gtyp}{e}{\\prog}}$\n%\nas a $\\eletname$-binder:\n%\n${\\eletb{f}{\\exacttype{\\gtyp}{e}}{e}{\\prog}}$\n%\nduring type checking (rule $\\rtreflect$ in Figure~\\ref{fig:typing}).\n\n\\mypara{Reflection}\n%\nWe write \\exacttype{\\typ}{e} for the \\emph{reflection}\nof term $e$ into the type $\\typ$,  defined by strengthening\n\\typ as:\n%\n$$\n\\begin{array}{lcl}\n\\exacttype{\\tref{v}{\\btyp}{r}}{e}\n  & \\defeq\n  & \\tref{v}{\\btyp}{r \\land v = e}\\\\\n\\exacttype{\\tfun{x}{\\typ_x}{\\typ}}{\\efun{y}{}{e}}\n  & \\defeq\n  & \\tfun{x}{\\typ_x}{\\exacttype{\\typ}{e\\subst{y}{x}}}\n\\end{array}\n$$\n%\nAs an example, recall from \\S~\\ref{sec:refinementreflection:overview}\nthat the @reflect fib @ strengthens the type of\n@fib@ with the reflected refinement @fibP@.\n%% NV In Overview, we have fibP v n = v = fib n && fibR v n\n%% NV Here we get the reflection part (fibR v n)\n%% NV which we can verify\n%% NV at each fix invocation we also get the v = fib n portion\n%% NV via the exact rule\n%% NV We can not add the v = fib n as a port condition, because\n%% NV we cannot prove it.\n\n\n\\mypara{Consequences for Verification}\n%\nReflection has two consequences for verification.\n%\nFirst, the reflected refinement is \\emph{not trusted};\nit is itself verified (as a valid output type)\nduring type checking.\n%\nSecond, instead of being tethered to quantifier\ninstantiation heuristics or having to program\n``triggers'' as in Dafny~\\citep{dafny} or\n\\fstar~\\citep{fstar}\n%\nthe programmer can predictably ``unfold'' the\ndefinition of the function during a proof simply\nby ``calling'' the function, which we have found\nto be a very natural way of structuring\nproofs~\\S~\\ref{sec:evaluation}.\n\n\n\\subsection{Refining \\& Reflecting Data Constructors with Measures}\n\\label{subsec:measures}\n\\label{subsec:list}\n\n% We reuse the notion of \\emph{measures}~\\cite{Vazou14}\n% to reflect functions over datatypes into the refinement\n% logic.\n\nWe assume that each data type is equipped with\na set of \\emph{measures} which are \\emph{unary}\nfunctions whose (1)~domain is the data type, and\n(2)~body is a single case-expression over the\ndatatype~\\cite{Vazou14}:\n%\n$$\\emeasb{f}\n         {\\gtyp}\n         {\\efun{x}{\\typ}{\\ecase{y}{x}{\\dc_i}{\\overline{z}}{e_i}}}$$\n%\nFor example, @len@ measures the size of an $\\tintlist$:\n%\n\\begin{code}\n  measure len :: [Int] -> Nat\n  len = \\x -> case x of\n                []     -> 0\n                (x:xs) -> 1 + len xs\n\\end{code}\n\n\\mypara{Checking and Projection}\n%\nWe assume the existence of measures that\n\\emph{check} the top-level constructor,\nand \\emph{project} their individual fields.\n%\n\\NV{Remove this pointer since we removed the text}\nIn \\S~\\ref{subsec:embedding} we show how to\nuse these measures to reflect functions over\ndatatypes.\n%\n% Such measures are straightforward to generate\n% automatically from the data-type definition.)\n%\nFor example, for lists, we assume the existence of measures:\n%\n\\begin{code}\n  isNil []      = True\n  isNil (x:xs)  = False\n\n  isCons (x:xs) = True\n  isCons []     = False\n\n  sel1 (x:xs)   = x\n  sel2 (x:xs)   = xs\n\\end{code}\n\n\\mypara{Refining Data Constructors with Measures}\n%\nWe use measures to strengthen the types\nof data constructors, and we use these\nstrengthened types during construction\nand destruction (pattern-matching).\n%\nLet:\n%\n(1)~$\\dc$ be a data constructor,\n   with \\emph{unrefined} type\n   $\\tfun{\\overline{x}}{\\overline{\\gtyp}}{T}$\n%\n(2)~the $i$-th measure definition with\n   domain $T$ is:\n%\n$$\\emeasb{f_i}\n         {\\gtyp}\n         {\\efun{x}{\\typ}{\\ecase{y}{x}{\\dc}{\\overline{z}}{e_{i}}}}\n$$\n%\nThen, the refined type of $\\dc$ is defined:\n$$\n\\constty{\\dc} \\defeq\n   \\tfun{\\overline{x}}\n        {\\overline{\\typ}}\n        {\\tref{v}{T}{ \\wedge_i f_i\\ v = \\SUBST{e_{i}}{\\overline{z}}{\\overline{x}}}}\n$$\n\nThus, each data constructor's output type is refined to reflect\nthe definition of each of its measures.\n%\nFor example, we use the measures @len@, @isNil@, @isCons@, @sel1@,\nand @sel2@ to strengthen the types of $\\dnull$ and $\\dcons$ to:\n%\n\\begin{align*}\n\\constty{\\dnull}  \\defeq & \\tref{v}{\\tintlist}{r_{\\dnull}} \\\\\n\\constty{\\dcons}  \\defeq & \\tfun{x}{\\tint}\n                                   {\\tfun{\\mathit{xs}}\n                                         {\\tintlist}\n                                         {\\tref{v}{\\tintlist}{r_\\dcons}}}\n\\intertext{where the output refinements are}\nr_{\\dnull} \\defeq &\\ \\mathtt{len}\\ v = 0\n             \\land  \\mathtt{isNil}\\ v\n             \\land  \\lnot \\mathtt{isCons}\\ v \\\\\nr_{\\dcons} \\defeq &\\ \\mathtt{len}\\ v = 1 + \\mathtt{len}\\ \\mathit{xs}\n             \\land  \\lnot \\mathtt{isNil}\\ v\n             \\land  \\mathtt{isCons}\\ v \\\\\n             \\land & \\  \\mathtt{sel1}\\ v = x\n             \\land  \\mathtt{sel2}\\ v = \\mathit{xs}\n\\end{align*}\n%\nIt is easy to prove that Lemma~\\ref{lemma:constants}\nholds for data constructors, by construction.\n%\nFor example, $\\mathtt{len}\\ \\dnull = 0$ evaluates to $\\tttrue$.\n\n\n%%\n%% The above annotation \\emph{strengthens} the types of data constructors\n%% $\\dc_i$ to reflect the\n%% behavior of $f$:\n%%\n%%\n%% \\preproc{\\eletrecoptsmall{f}{\\efun{x}{\\typ}{\\ecase{y}{x}{\\dc_i}{\\overline{z}}{e_i}}}{\\gtyp}{M}{\\prog}}\n%%\n%% %\n%% Where \\exacttypefun{f}{\\gtyp}{e} strengthens the result $v$ of the type \\typ to exactly\n%% describe that $f\\ v = e$:\n%% %\n%% \\begin{align*}\n%% \\exacttypefun{f}{\\tref{v}{\\btyp}{r}}{e} &= \\tref{v}{\\btyp}{r \\land f\\ v = e}\\\\\n%% \\exacttypefun{f}{\\tfun{x}{\\typ_x}{\\typ}}{\\efun{y}{}{e}} &=\\tfun{x}{\\typ_x}{\\exacttype{\\typ}{e\\subst{y}{x}}}\n%% \\end{align*}\n\n\\subsection{Typing Rules}\n\\input{text/refinementreflection/typing}\n%\nNext, we present the type-checking\njudgments and rules of \\corelan.\n\n\\mypara{Environments and Closing Substitutions}\nA \\emph{type environment} $\\env$ is a sequence of type bindings\n$\\tbind{x_1}{\\typ_1},\\ldots,\\tbind{x_n}{\\typ_n}$. An environment\ndenotes a set of \\emph{closing substitutions} $\\sto$ which are\nsequences of expression bindings:\n$\\gbind{x_1}{e_1}, \\ldots, \\gbind{x_n}{e_n}$ such that:\n$$\n\\interp{\\env} \\defeq  \\{\\sto \\mid \\forall \\tbind{x}{\\typ} \\in \\Env.\n                                    \\sto(x) \\in \\interp{\\applysub{\\sto}{\\typ}} \\}\n$$\n\n\\mypara{Judgments}\nWe use environments to define three kinds of\nrules: Well-formedness, Subtyping,\nand Typing~\\citep{Knowles10,Vazou14}.\n%\n%\\mypara{Well-formedness}\nA judgment \\iswellformed{\\env}{\\typ} states that\nthe refinement type $\\typ$ is well-formed in\nthe environment $\\env$.\n%\nIntuitively, the type $\\typ$ is well-formed if all\nthe refinements in $\\typ$ are $\\tbool$-typed in $\\env$.\n%\n%\\mypara{Subtyping}\nA judgment \\issubtype{\\env}{\\typ_1}{\\typ_2} states\nthat the type $\\typ_1$ is a subtype of %the type\n$\\typ_2$ in the environment $\\env$.\n%\nInformally, $\\typ_1$ is a subtype of $\\typ_2$ if, when\nthe free variables of $\\typ_1$ and $\\typ_2$\nare bound to expressions described by $\\env$,\nthe denotation of $\\typ_1$\nis \\emph{contained in} the denotation of $\\typ_2$.\n%\nSubtyping of basic types reduces to denotational containment checking.\n%\n%\\mypara{Implication}\n%%A judgment \\issubref{\\Env}{p_1}{p_2} states\n%%that the predicate $p_1$ \\emph{implies}\n%%the predicate $p_2$ in the environment $\\Env$.\n%\nThat is, for any closing substitution $\\sto$\nin the denotation of $\\env$, for every expression $e$,\nif $e \\in \\interp{\\applysub{\\sto}{\\typ_1}}$ then\n$ e \\in \\interp{\\applysub{\\sto}{\\typ_2}}$.\n%\n%\\mypara{Typing}\nA judgment \\hastype{\\env}{\\prog}{\\typ} states that\nthe program $\\prog$ has the type $\\typ$ in\nthe environment $\\env$.\nThat is, when the free variables in $\\prog$ are\nbound to expressions described by $\\env$, the\nprogram $\\prog$ will evaluate to a value\ndescribed by $\\typ$.\n\n\\mypara{Rules}\n%\nAll but three of the rules are standard~\\cite{Knowles10,Vazou14}.\n%\nFirst, rule \\rtreflect is used to strengthen the type of each\nreflected binder with its definition, as described previously\nin \\S~\\ref{subsec:logicalannotations}.\n%\n% \\NV{FIX:Eq}\n% applies only to expressions that can be finitely compared\n% (\\ie whose type satisfies the \\haseq{B} predicate) and\nSecond, rule \\rtexact strengthens the expression with\na singleton type equating the value and the expression\n(\\ie reflecting the expression in the type).\n%\nThis is a generalization of the ``selfification'' rules\nfrom \\cite{Ou2004,Knowles10}, and is required to\nequate the reflected functions with their definitions.\n%\nFor example, the application $(\\fib\\ 1)$ is typed as\n${\\tref{v}{\\tint}{\\fibdef\\ v\\ 1 \\wedge v = \\fib\\ 1}}$ where\nthe first conjunct comes from the (reflection-strengthened)\noutput refinement of \\fib~\\S~\\ref{sec:refinementreflection:overview}, and\nthe second conjunct comes from rule~\\rtexact.\n%\nFinally, rule \\rtfix is used to type the intermediate\n$\\texttt{fix}$ expressions that appear, not in the\nsurface language but as intermediate terms in the\noperational semantics.\n\n\\mypara{Soundness}\nFollowing \\undeclang~\\citep{Vazou14}, we can show that\nevaluation preserves typing and that typing implies\ndenotational inclusion.\n%\n\\begin{theorem}{[Soundness of \\corelan]}\\label{thm:safety}\n\\begin{itemize}\n\\item\\textbf{Denotations}\nIf $\\hastype{\\env}{\\prog}{\\typ}$ then\n$\\forall \\sto\\in \\interp{\\env}. \\applysub{\\sto}{\\prog} \\in \\interp{\\applysub{\\sto}{\\typ}}$.\n\\item\\textbf{Preservation}\nIf \\hastype{\\emptyset}{\\prog}{\\typ}\n       and $\\evalsto{\\prog}{w}$ then $\\hastype{\\emptyset}{w}{\\typ}$.\n\\end{itemize}\n\\end{theorem}\n\n\\subsection{From Programs \\& Types to Propositions \\& Proofs}\n\nThe denotational soundness Theorem~\\ref{thm:safety}\nlets us interpret well typed programs as proofs of\npropositions.\n\n\\NV{say that definition is a context that will be used later}\n\\mypara{``Definitions''}\nA \\emph{definition} $\\defn$ is a sequence of reflected binders:\n%\n$$\\defn \\ ::= \\ \\bullet \\spmid \\erefb{x}{\\gtyp}{e}{\\defn}$$\n%\nA \\emph{definition's environment} $\\env(\\defn)$ comprises\nits binders and their reflected types:\n%\n\\begin{align*}\n\\aenv(\\bullet)                    \\defeq & \\emptyset \\\\\n\\aenv(\\erefb{f}{\\gtyp}{e}{\\defn}) \\defeq & (f, \\exacttype{\\gtyp}{e}),\\ \\env(\\defn) \\\\\n\\end{align*}\n%\nA \\emph{definition's substitution} $\\sto(\\defn)$ maps each binder\nto its definition:\n%\n\\begin{align*}\n\\sto(\\bullet)                     \\defeq & \\emptysto \\\\\n\\sto(\\erefb{f}{\\gtyp}{e}{\\defn})  \\defeq & \\extendsto{f}{\\efix{f}\\ e}{\\sto(\\defn)}\n\\end{align*}\n\n\\mypara{``Propositions''}\n%\nA \\emph{proposition} is a type\n%\n$$\\tbind{x_1}{\\typ_1} \\rightarrow \\ldots\n  \\rightarrow \\tbind{x_n}{\\typ_n}\n  \\rightarrow \\tref{v}{\\tunit}{\\ppn}$$\n%\nFor brevity, we abbreviate propositions like the above to\n%\n$\\tfun{\\overline{x}}{\\overline{\\typ}}{\\ttref{\\ppn}}$\n%\nand we call $\\ppn$ the \\emph{proposition's refinement}.\n%\nFor simplicity we assume that $\\freevars{\\typ_i} = \\emptyset$.\n\n\\mypara{``Validity''}\n%\n\\NV{add termination: proofs should provably terminates}\n\nA proposition $\\tfun{\\overline{x}}{\\overline{\\typ}}{\\ttref{\\ppn}}$\nis \\emph{valid under} $\\defn$ if\n%\n$$\\forall \\overline{w} \\in \\interp{\\overline{\\typ}}.\\\n  \\evalsto{\\applysub{\\sto(\\defn)}{\\SUBST{\\ppn}{\\overline{x}}{\\overline{w}}}}{\\etrue}$$\n%\nThat is, the proposition is valid if its refinement\nevaluates to $\\etrue$ for every (well typed)\ninterpretation for its parameters $\\overline{x}$\nunder $\\defn$.\n\n\\mypara{``Proofs''}\n%\nA binder $\\bd$ \\emph{proves} a proposition $\\gtyp$ under $\\defn$ if\n$$\\hastype{\\emptyset}{\\defn[\\eletb{x}{\\typ}{\\bd}{\\eunit}]}{\\tunit}$$\n%\nThat is, if the binder $\\bd$ has the proposition's type $\\gtyp$\nunder the definition $\\defn$'s environment.\n\n\\begin{theorem}{[Proofs]} \\label{thm:validity}\nIf $\\bd$ proves $\\typ$ under $\\defn$ then $\\typ$ is valid under $d$.\n\\end{theorem}\n\n\\begin{proof}\nAs $\\bd$ proves $\\typ$ under $\\defn$, we have\n%\n\\begin{align}\n\\hastype{\\emptyset}{\\defn[\\eletb{x}{\\typ}{\\bd}{\\eunit}]}{\\tunit}\n\\label{pf:1} \\\\\n%\n\\intertext{By Theorem~\\ref{thm:safety} on \\ref{pf:1} we get}\n%\n\\sto(\\defn) \\in \\interp{\\env(\\defn)} \\label{pf:2}\\\\\n%\n\\intertext{Furthermore,  by the typing rules \\ref{pf:1}\nimplies $\\hastype{\\env(\\defn)}{\\bd}{\\typ}$ and hence, via Theorem~\\ref{thm:safety}}\n%\n\\forall \\sub \\in \\interp{\\env(\\defn)}.\\ \\applysub{\\sub}{\\bd} \\in \\interp{\\applysub{\\sub}{\\typ}}\n\\label{pf:3} \\\\\n\\intertext{Together, \\ref{pf:2} and \\ref{pf:3} imply}\n\\applysub{\\sto(\\defn)}{\\bd} \\in \\interp{\\applysub{\\sto(\\defn)}{\\typ}}\n\\label{pf:4}\n\\intertext{By the definition of type denotations, we have}\n%\n\\interp{\\applysub{\\sto(\\defn)}{\\typ}}\n  \\defeq \\{ f\\ |\\ \\typ \\mbox{ is valid under}\\ \\defn\\}\n  \\label{pf:5}\n\\end{align}\nBy \\ref{pf:4}, the above set is not empty, and hence $\\typ$ is valid under $\\defn$.\n\\end{proof}\n\n\n%%%%%  \\begin{definition}[Theorem]\n%%%%%  Let $\\aenv=\\aenv(\\prog)$ be the set of axioms for some program \\prog.\n%%%%%  Then\n%%%%%  $\\typ\\defeq\\tbind{x_1}{\\typ_1} \\rightarrow \\dots \\rightarrow \\tbind{x_n}{\\typ_n} \\rightarrow \\ttreft{v}{\\btyp}{\\refa}$\n%%%%%  is a theorem if\n%%%%%  $\\freevars{\\refa} \\subseteq \\{x_1, \\dots, x_n\\} \\cup \\domain{\\aenv}$,\n%%%%%  and for simplicity $\\freevars{\\typ_i} = \\emptyset$.\n%%%%%\n%%%%%  Moreover, every expression $e'$ such that  \\hastype{\\aenv}{e'}{\\typ}\n%%%%%  provides a proof of the theorem $\\typ$ with respect to the definitions in \\prog.\n%%%%%  \\end{definition}\n%%%%%  %\n%%%%%  In other words, any expression $e'$ provides an evidence that the theorem expressed\n%%%%%  by \\typ holds.\n%%%%%  The above definition is an instance of the Curry-Howard correspondence,\n%%%%%  where programs as interpreted as proofs or the theorems expressed by their types.\n%%%%%  %\n%%%%%  %% Moreover, since the proof of the theorem is any expression $e'$ with type $\\typ$\n%%%%%  %% the definition states that our proof system is proof irrelevant.\n%%%%%\n%%%%%  \\begin{theorem}\n%%%%%  Let $\\aenv=\\aenv(\\prog)$.\n%%%%%  For every theorem\n%%%%%  $\\typ \\equiv \\tbind{x_1}{\\typ_1} \\rightarrow \\dots \\rightarrow \\tbind{x_n}{\\typ_n} \\rightarrow \\ttreft{v}{\\btyp}{\\refa}$\n%%%%%  with a proof $e_\\typ$ with respect to $p$,\n%%%%%  then $\\forall x_1\\in\\interp{\\typ_1},\\dots, x_n\\in\\interp{\\typ_n}. \\evalsto{\\applysub{\\Theta_\\aenv(\\prog)}{\\refa}}{\\etrue}$.\n%%%%%  \\end{theorem}\n%%%%%  \\begin{myproof}\n%%%%%  Since \\hastype{\\aenv}{e_\\typ}{\\typ}\n%%%%%  by Theorem~\\ref{thm:safety} we have\n%%%%%  $\\forall \\sub \\in \\interp{\\aenv}.\n%%%%%  \\applysub{\\sub}{e_\\typ} \\in \\interp{\\applysub{\\sub}{\\typ}}\n%%%%%  $.\n%%%%%  %\n%%%%%  Since \\prog type checks\n%%%%%  we have $\\Theta_\\aenv(\\prog)\\in\\interp{\\aenv}$, thus\n%%%%%  $\\applysub{\\Theta_\\aenv(\\prog)}{\\refa} \\in \\interp{\\applysub{\\Theta_\\aenv(\\prog)}{\\typ}}$.\n%%%%%  %\n%%%%%  By the Definition of Type Denotations we have\n%%%%%  $\\interp{\\typ} =  \\{f |\\forall x_1\\in\\interp{\\typ_1},\\dots, x_n\\in\\interp{\\typ_n}. \\evalsto{\\applysub{\\Theta_\\aenv(\\prog)}{\\refa}}{\\etrue} \\}$.\n%%%%%  %\n%%%%%  But $e_\\typ$ is a witness that the set \\interp{\\typ} is not empty, thus\n%%%%%  $\\forall x_1\\in\\interp{\\typ_1},\\dots, x_n\\in\\interp{\\typ_n}. \\evalsto{\\applysub{\\Theta_\\aenv(\\prog)}{\\refa}}{\\etrue}$.\n%%%%%  \\end{myproof}\n\n%% Theta_\\aenv(\\eletrec{f}{e}{\\gtyp}{L}{\\prog})\n %% & = (f, \\efix{f}\\ e),\\aenv(p) \\\\\n%% \\Theta_\\aenv(\\elet{f}{e}{\\gtyp}{L}{\\prog})\n %% & = (f, e),\\aenv(p) \\\\\n%% \\Theta_\\aenv(\\eletrecopt{f}{e}{\\gtyp}{}{\\prog})\n %% & = \\Theta_\\aenv(p) \\\\\n%% \\Theta_\\aenv(e) &= \\emptyset\n%% \\end{align*}\n\n%% A proposition is \\emph{well-formed} under $\\defn$ if\n%% $\\freevars{\\refa} \\subseteq \\{x_1, \\dots, x_n\\} \\cup \\domain{\\aenv}$,\n\n\n\\mypara{Example: Fibonacci is increasing}\n%\nIn \\S~\\ref{sec:refinementreflection:overview} we verified that\nunder a definition $\\defn$ that includes \\fibname,\nthe term \\fibincrname proves\n$${\\tfun{n}{\\tnat}{\\ttref{\\fib{n} \\leq \\fib{(n+1)}}}}$$\n%\nThus, by Theorem~\\ref{thm:validity} we get\n%that the \\fib{}, as defined in $\\defn$ is increasing\n%\n%$$\n%\\forall n\\in\\interp{\\tnat}. \\evalsto{\\fib{n} \\leq \\fib{(n+1)}}{\\etrue}\n%$$\n%Equivalently\n$$\n\\forall n. \\evalsto{0 \\leq n}{\\etrue} \\Rightarrow \\evalsto{\\fib{n} \\leq \\fib{(n+1)}}{\\etrue}\n$$\n", "meta": {"hexsha": "6ec14b9d2c604c929355df939d9d3931423f60e0", "size": 24135, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinementreflection/theory.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinementreflection/theory.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinementreflection/theory.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 32.6148648649, "max_line_length": 150, "alphanum_fraction": 0.6722187694, "num_tokens": 7965, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.43129198945068575}}
{"text": "\\begin{comment}\n\n Licensed to the Apache Software Foundation (ASF) under one\n or more contributor license agreements.  See the NOTICE file\n distributed with this work for additional information\n regarding copyright ownership.  The ASF licenses this file\n to you under the Apache License, Version 2.0 (the\n \"License\"); you may not use this file except in compliance\n with the License.  You may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing,\n software distributed under the License is distributed on an\n \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n KIND, either express or implied.  See the License for the\n specific language governing permissions and limitations\n under the License.\n\n\\end{comment}\n\n\\subsection{Multinomial Logistic Regression}\n\n\\noindent{\\bf Description}\n\\smallskip\n\nOur logistic regression script performs both binomial and multinomial logistic regression.\nThe script is given a dataset $(X, Y)$ where matrix $X$ has $m$~columns and matrix $Y$ has\none column; both $X$ and~$Y$ have $n$~rows.  The rows of $X$ and~$Y$ are viewed as a collection\nof records: $(X, Y) = (x_i, y_i)_{i=1}^n$ where $x_i$ is a numerical vector of explanatory\n(feature) variables and $y_i$ is a categorical response variable.\nEach row~$x_i$ in~$X$ has size~\\mbox{$\\dim x_i = m$}, while its corresponding $y_i$ is an\ninteger that represents the observed response value for record~$i$.\n\nThe goal of logistic regression is to learn a linear model over the feature vector\n$x_i$ that can be used to predict how likely each categorical label is expected to\nbe observed as the actual~$y_i$.\nNote that logistic regression predicts more than a label: it predicts the probability\nfor every possible label.  The binomial case allows only two possible labels, the\nmultinomial case has no such restriction.\n\nJust as linear regression estimates the mean value $\\mu_i$ of a numerical response\nvariable, logistic regression does the same for category label probabilities.\nIn linear regression, the mean of $y_i$ is estimated as a linear combination of the features:\n$\\mu_i = \\beta_0 + \\beta_1 x_{i,1} + \\ldots + \\beta_m x_{i,m} = \\beta_0 + x_i\\beta_{1:m}$.\nIn logistic regression, the\nlabel probability has to lie between 0 and~1, so a link function is applied to connect\nit to $\\beta_0 + x_i\\beta_{1:m}$.  If there are just two possible category labels, for example\n0~and~1, the logistic link looks as follows:\n\\begin{equation*}\n\\Prob[y_i\\,{=}\\,1\\mid x_i; \\beta] \\,=\\, \n\\frac{e^{\\,\\beta_0 + x_i\\beta_{1:m}}}{1 + e^{\\,\\beta_0 + x_i\\beta_{1:m}}};\n\\quad\n\\Prob[y_i\\,{=}\\,0\\mid x_i; \\beta] \\,=\\, \n\\frac{1}{1 + e^{\\,\\beta_0 + x_i\\beta_{1:m}}}\n\\end{equation*}\nHere category label~0 serves as the \\emph{baseline}, and function\n$\\exp(\\beta_0 + x_i\\beta_{1:m})$\nshows how likely we expect to see ``$y_i = 1$'' in comparison to the baseline.\nLike in a loaded coin, the predicted odds of seeing 1~versus~0 are\n$\\exp(\\beta_0 + x_i\\beta_{1:m})$ to~1,\nwith each feature $x_{i,j}$ multiplying its own factor $\\exp(\\beta_j x_{i,j})$ to the odds.\nGiven a large collection of pairs $(x_i, y_i)$, $i=1\\ldots n$, logistic regression seeks\nto find the $\\beta_j$'s that maximize the product of probabilities\n\\hbox{$\\Prob[y_i\\mid x_i; \\beta]$}\nfor actually observed $y_i$-labels (assuming no regularization).\n\nMultinomial logistic regression~\\cite{Agresti2002:CDA} extends this link to $k \\geq 3$ possible\ncategories.  Again we identify one category as the baseline, for example the $k$-th category.\nInstead of a coin, here we have a loaded multisided die, one side per category.  Each non-baseline\ncategory $l = 1\\ldots k\\,{-}\\,1$ has its own vector $(\\beta_{0,l}, \\beta_{1,l}, \\ldots, \\beta_{m,l})$\nof regression parameters with the intercept, making up a matrix $B$ of size\n$(m\\,{+}\\,1)\\times(k\\,{-}\\,1)$.  The predicted odds of seeing non-baseline category~$l$ versus\nthe baseline~$k$ are $\\exp\\big(\\beta_{0,l} + \\sum\\nolimits_{j=1}^m x_{i,j}\\beta_{j,l}\\big)$\nto~1, and the predicted probabilities are:\n\\begin{align}\nl < k:\\quad\\Prob[y_i\\,{=}\\,\\makebox[0.5em][c]{$l$}\\mid x_i; B] \\,\\,\\,{=}\\,\\,\\,&\n\\frac{\\exp\\big(\\beta_{0,l} + \\sum\\nolimits_{j=1}^m x_{i,j}\\beta_{j,l}\\big)}%\n{1 \\,+\\, \\sum_{l'=1}^{k-1}\\exp\\big(\\beta_{0,l'} + \\sum\\nolimits_{j=1}^m x_{i,j}\\beta_{j,l'}\\big)};\n\\label{eqn:mlogreg:nonbaseprob}\\\\\n\\Prob[y_i\\,{=}\\,\\makebox[0.5em][c]{$k$}\\mid x_i; B] \\,\\,\\,{=}\\,\\,\\,& \\frac{1}%\n{1 \\,+\\, \\sum_{l'=1}^{k-1}\\exp\\big(\\beta_{0,l'} + \\sum\\nolimits_{j=1}^m x_{i,j}\\beta_{j,l'}\\big)}.\n\\label{eqn:mlogreg:baseprob}\n\\end{align}\nThe goal of the regression is to estimate the parameter matrix~$B$ from the provided dataset\n$(X, Y) = (x_i, y_i)_{i=1}^n$ by maximizing the product of \\hbox{$\\Prob[y_i\\mid x_i; B]$}\nover the observed labels~$y_i$.  Taking its logarithm, negating, and adding a regularization term\ngives us a minimization objective:\n\\begin{equation}\nf(B; X, Y) \\,\\,=\\,\\,\n-\\sum_{i=1}^n \\,\\log \\Prob[y_i\\mid x_i; B] \\,+\\,\n\\frac{\\lambda}{2} \\sum_{j=1}^m \\sum_{l=1}^{k-1} |\\beta_{j,l}|^2\n\\,\\,\\to\\,\\,\\min\n\\label{eqn:mlogreg:loss}\n\\end{equation}\nThe optional regularization term is added to mitigate overfitting and degeneracy in the data;\nto reduce bias, the intercepts $\\beta_{0,l}$ are not regularized.  Once the~$\\beta_{j,l}$'s\nare accurately estimated, we can make predictions about the category label~$y$ for a new\nfeature vector~$x$ using Eqs.~(\\ref{eqn:mlogreg:nonbaseprob}) and~(\\ref{eqn:mlogreg:baseprob}).\n\n\\smallskip\n\\noindent{\\bf Usage}\n\\smallskip\n\n{\\hangindent=\\parindent\\noindent\\it%\n{\\tt{}-f }path/\\/{\\tt{}MultiLogReg.dml}\n{\\tt{} -nvargs}\n{\\tt{} X=}path/file\n{\\tt{} Y=}path/file\n{\\tt{} B=}path/file\n{\\tt{} Log=}path/file\n{\\tt{} icpt=}int\n{\\tt{} reg=}double\n{\\tt{} tol=}double\n{\\tt{} moi=}int\n{\\tt{} mii=}int\n{\\tt{} fmt=}format\n\n}\n\n\n\\smallskip\n\\noindent{\\bf Arguments}\n\\begin{Description}\n\\item[{\\tt X}:]\nLocation (on HDFS) to read the input matrix of feature vectors; each row constitutes\none feature vector.\n\\item[{\\tt Y}:]\nLocation to read the input one-column matrix of category labels that correspond to\nfeature vectors in~{\\tt X}.  Note the following:\\\\\n-- Each non-baseline category label must be a positive integer.\\\\\n-- If all labels are positive, the largest represents the baseline category.\\\\\n-- If non-positive labels such as $-1$ or~$0$ are present, then they represent the (same)\nbaseline category and are converted to label $\\max(\\texttt{Y})\\,{+}\\,1$.\n\\item[{\\tt B}:]\nLocation to store the matrix of estimated regression parameters (the $\\beta_{j, l}$'s),\nwith the intercept parameters~$\\beta_{0, l}$ at position {\\tt B[}$m\\,{+}\\,1$, $l${\\tt ]}\nif available.  The size of {\\tt B} is $(m\\,{+}\\,1)\\times (k\\,{-}\\,1)$ with the intercepts\nor $m \\times (k\\,{-}\\,1)$ without the intercepts, one column per non-baseline category\nand one row per feature.\n\\item[{\\tt Log}:] (default:\\mbox{ }{\\tt \" \"})\nLocation to store iteration-specific variables for monitoring and debugging purposes,\nsee Table~\\ref{table:mlogreg:log} for details.\n\\item[{\\tt icpt}:] (default:\\mbox{ }{\\tt 0})\nIntercept and shifting/rescaling of the features in~$X$:\\\\\n{\\tt 0} = no intercept (hence no~$\\beta_0$), no shifting/rescaling of the features;\\\\\n{\\tt 1} = add intercept, but do not shift/rescale the features in~$X$;\\\\\n{\\tt 2} = add intercept, shift/rescale the features in~$X$ to mean~0, variance~1\n\\item[{\\tt reg}:] (default:\\mbox{ }{\\tt 0.0})\nL2-regularization parameter (lambda)\n\\item[{\\tt tol}:] (default:\\mbox{ }{\\tt 0.000001})\nTolerance (epsilon) used in the convergence criterion\n\\item[{\\tt moi}:] (default:\\mbox{ }{\\tt 100})\nMaximum number of outer (Fisher scoring) iterations\n\\item[{\\tt mii}:] (default:\\mbox{ }{\\tt 0})\nMaximum number of inner (conjugate gradient) iterations, or~0 if no maximum\nlimit provided\n\\item[{\\tt fmt}:] (default:\\mbox{ }{\\tt \"text\"})\nMatrix file output format, such as {\\tt text}, {\\tt mm}, or {\\tt csv};\nsee read/write functions in SystemDS Language Reference for details.\n\\end{Description}\n\n\n\\begin{table}[t]\\small\\centerline{%\n\\begin{tabular}{|ll|}\n\\hline\nName & Meaning \\\\\n\\hline\n{\\tt LINEAR\\_TERM\\_MIN}  & The minimum value of $X \\pxp B$, used to check for overflows \\\\\n{\\tt LINEAR\\_TERM\\_MAX}  & The maximum value of $X \\pxp B$, used to check for overflows \\\\\n{\\tt NUM\\_CG\\_ITERS}     & Number of inner (Conj.\\ Gradient) iterations in this outer iteration \\\\\n{\\tt IS\\_TRUST\\_REACHED} & $1 = {}$trust region boundary was reached, $0 = {}$otherwise \\\\\n{\\tt POINT\\_STEP\\_NORM}  & L2-norm of iteration step from old point (matrix $B$) to new point \\\\\n{\\tt OBJECTIVE}          & The loss function we minimize (negative regularized log-likelihood) \\\\\n{\\tt OBJ\\_DROP\\_REAL}    & Reduction in the objective during this iteration, actual value \\\\\n{\\tt OBJ\\_DROP\\_PRED}    & Reduction in the objective predicted by a quadratic approximation \\\\\n{\\tt OBJ\\_DROP\\_RATIO}   & Actual-to-predicted reduction ratio, used to update the trust region \\\\\n{\\tt IS\\_POINT\\_UPDATED} & $1 = {}$new point accepted; $0 = {}$new point rejected, old point restored \\\\\n{\\tt GRADIENT\\_NORM}     & L2-norm of the loss function gradient (omitted if point is rejected) \\\\\n{\\tt TRUST\\_DELTA}       & Updated trust region size, the ``delta'' \\\\\n\\hline\n\\end{tabular}}\n\\caption{\nThe {\\tt Log} file for multinomial logistic regression contains the above \\mbox{per-}iteration\nvariables in CSV format, each line containing triple (Name, Iteration\\#, Value) with Iteration\\#\nbeing~0 for initial values.}\n\\label{table:mlogreg:log}\n\\end{table}\n\n\n\\noindent{\\bf Details}\n\\smallskip\n\nWe estimate the logistic regression parameters via L2-regularized negative\nlog-likelihood minimization~(\\ref{eqn:mlogreg:loss}).\nThe optimization method used in the script closely follows the trust region\nNewton method for logistic regression described in~\\cite{Lin2008:logistic}.\nFor convenience, let us make some changes in notation:\n\\begin{Itemize}\n\\item Convert the input vector of observed category labels into an indicator matrix $Y$\nof size $n \\times k$ such that $Y_{i, l} = 1$ if the $i$-th category label is~$l$ and\n$Y_{i, l} = 0$ otherwise;\n\\item Append an extra column of all ones, i.e.\\ $(1, 1, \\ldots, 1)^T$, as the\n$m\\,{+}\\,1$-st column to the feature matrix $X$ to represent the intercept;\n\\item Append an all-zero column as the $k$-th column to $B$, the matrix of regression\nparameters, to represent the baseline category;\n\\item Convert the regularization constant $\\lambda$ into matrix $\\Lambda$ of the same\nsize as $B$, placing 0's into the $m\\,{+}\\,1$-st row to disable intercept regularization,\nand placing $\\lambda$'s everywhere else.\n\\end{Itemize}\nNow the ($n\\,{\\times}\\,k$)-matrix of predicted probabilities given\nby (\\ref{eqn:mlogreg:nonbaseprob}) and~(\\ref{eqn:mlogreg:baseprob})\nand the objective function $f$ in~(\\ref{eqn:mlogreg:loss}) have the matrix form\n\\begin{align*}\nP \\,\\,&=\\,\\, \\exp(XB) \\,\\,/\\,\\, \\big(\\exp(XB)\\,1_{k\\times k}\\big)\\\\\nf \\,\\,&=\\,\\, - \\,\\,{\\textstyle\\sum} \\,\\,Y \\cdot (X B)\\, + \\,\n{\\textstyle\\sum}\\,\\log\\big(\\exp(XB)\\,1_{k\\times 1}\\big) \\,+ \\,\n(1/2)\\,\\, {\\textstyle\\sum} \\,\\,\\Lambda \\cdot B \\cdot B\n\\end{align*}\nwhere operations $\\cdot\\,$, $/$, $\\exp$, and $\\log$ are applied cellwise,\nand $\\textstyle\\sum$ denotes the sum of all cells in a matrix.\nThe gradient of~$f$ with respect to~$B$ can be represented as a matrix too:\n\\begin{equation*}\n\\nabla f \\,\\,=\\,\\, X^T (P - Y) \\,+\\, \\Lambda \\cdot B\n\\end{equation*}\nThe Hessian $\\mathcal{H}$ of~$f$ is a tensor, but, fortunately, the conjugate\ngradient inner loop of the trust region algorithm in~\\cite{Lin2008:logistic}\ndoes not need to instantiate it.  We only need to multiply $\\mathcal{H}$ by\nordinary matrices of the same size as $B$ and $\\nabla f$, and this can be done\nin matrix form:\n\\begin{equation*}\n\\mathcal{H}V \\,\\,=\\,\\, X^T \\big( Q \\,-\\, P \\cdot (Q\\,1_{k\\times k}) \\big) \\,+\\,\n\\Lambda \\cdot V, \\,\\,\\,\\,\\textrm{where}\\,\\,\\,\\,Q \\,=\\, P \\cdot (XV)\n\\end{equation*}\nAt each Newton iteration (the \\emph{outer} iteration) the minimization algorithm\napproximates the difference $\\varDelta f(S; B) = f(B + S; X, Y) \\,-\\, f(B; X, Y)$\nattained in the objective function after a step $B \\mapsto B\\,{+}\\,S$ by a\nsecond-degree formula\n\\begin{equation*}\n\\varDelta f(S; B) \\,\\,\\,\\approx\\,\\,\\, (1/2)\\,\\,{\\textstyle\\sum}\\,\\,S \\cdot \\mathcal{H}S\n \\,+\\, {\\textstyle\\sum}\\,\\,S\\cdot \\nabla f\n\\end{equation*}\nThis approximation is then minimized by trust-region conjugate gradient iterations\n(the \\emph{inner} iterations) subject to the constraint $\\|S\\|_2 \\leq \\delta$.\nThe trust region size $\\delta$ is initialized as $0.5\\sqrt{m}\\,/ \\max\\nolimits_i \\|x_i\\|_2$\nand updated as described in~\\cite{Lin2008:logistic}.\nUsers can specify the maximum number of the outer and the inner iterations with\ninput parameters {\\tt moi} and {\\tt mii}, respectively.  The iterative minimizer\nterminates successfully if $\\|\\nabla f\\|_2 < \\eps\\,\\|\\nabla f_{B=0}\\|_2$,\nwhere $\\eps > 0$ is a tolerance supplied by the user via input parameter~{\\tt tol}.\n\n\\smallskip\n\\noindent{\\bf Returns}\n\\smallskip\n\nThe estimated regression parameters (the $\\hat{\\beta}_{j, l}$) are populated into\na matrix and written to an HDFS file whose path/name was provided as the ``{\\tt B}''\ninput argument.  Only the non-baseline categories ($1\\leq l \\leq k\\,{-}\\,1$) have\ntheir $\\hat{\\beta}_{j, l}$ in the output; to add the baseline category, just append\na column of zeros.  If {\\tt icpt=0} in the input command line, no intercepts are used\nand {\\tt B} has size $m\\times (k\\,{-}\\,1)$; otherwise {\\tt B} has size \n$(m\\,{+}\\,1)\\times (k\\,{-}\\,1)$\nand the intercepts are in the $m\\,{+}\\,1$-st row.  If {\\tt icpt=2}, then initially\nthe feature columns in~$X$ are shifted to mean${} = 0$ and rescaled to variance${} = 1$.\nAfter the iterations converge, the $\\hat{\\beta}_{j, l}$'s are rescaled and shifted\nto work with the original features.\n\n\n\\smallskip\n\\noindent{\\bf Examples}\n\\smallskip\n\n{\\hangindent=\\parindent\\noindent\\tt\n\\hml -f MultiLogReg.dml -nvargs X=/user/biadmin/X.mtx \n  Y=/user/biadmin/Y.mtx B=/user/biadmin/B.mtx fmt=csv\n  icpt=2 reg=1.0 tol=0.0001 moi=100 mii=10 Log=/user/biadmin/log.csv\n\n}\n\n\n\\smallskip\n\\noindent{\\bf References}\n\\begin{itemize}\n\\item A.~Agresti.\n\\newblock {\\em Categorical Data Analysis}.\n\\newblock Wiley Series in Probability and Statistics. Wiley-Interscience,  second edition, 2002.\n\\end{itemize}\n", "meta": {"hexsha": "ea5aaab7a392809db2c9f5178321a0365ffe9d58", "size": 14317, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg-ref/LogReg.tex", "max_stars_repo_name": "j143/systemds-doc", "max_stars_repo_head_hexsha": "ca01a1fafa6d79cce5ff9b443cb96c7cb4c11805", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "alg-ref/LogReg.tex", "max_issues_repo_name": "j143/systemds-doc", "max_issues_repo_head_hexsha": "ca01a1fafa6d79cce5ff9b443cb96c7cb4c11805", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg-ref/LogReg.tex", "max_forks_repo_name": "j143/systemds-doc", "max_forks_repo_head_hexsha": "ca01a1fafa6d79cce5ff9b443cb96c7cb4c11805", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.7118055556, "max_line_length": 104, "alphanum_fraction": 0.6997275966, "num_tokens": 4563, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.43119415501647385}}
{"text": "\\par\n\\subsection{{\\tt DV} : {\\tt double} vector methods}\n\\label{subsection:Utilities:proto:DV}\n\\par\n%=======================================================================\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble * DVinit ( int n, double val ) ;\n\\end{verbatim}\n\\index{DVinit@{\\tt DVinit()}}\nThis is the allocator and initializer method for {\\tt double} vectors.\nStorage for an array with size {\\tt n} is found and each\nentry is filled with {\\tt val}.\nA pointer to the array is returned.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble * DVinit2 ( int n ) ;\n\\end{verbatim}\n\\index{DVinit2@{\\tt DVinit2()}}\nThis is an allocator method for {\\tt double} vectors.\nStorage for an array with size {\\tt n} is found.\nA pointer to the array is returned.\nNote, on return, there will likely be garbage in the array.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVfree ( int vec[] ) ;\n\\end{verbatim}\n\\index{DVfree@{\\tt DVfree()}}\nThis method releases the storage taken by {\\tt vec[]}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVfprintf ( FILE *fp, int n, double y[] ) ;\n\\end{verbatim}\n\\index{DVfprintf@{\\tt DVfprintf()}}\nThis method prints {\\tt n} entries in {\\tt y[]} to file {\\tt fp}.\nThe format is new line followed by lines of six {\\tt double}'s in\n{\\tt \"\\%12.4e\"} format.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVfscanf ( FILE *fp, int n, double y[] ) ;\n\\end{verbatim}\n\\index{DVfscanf@{\\tt DVfscanf()}}\nThis method scans in {\\tt double}'s from file {\\tt fp} and places them\nin the array {\\tt y[]}.\nIt tries to read in {\\tt n} {\\tt double}'s, and returns the number\nthat were actually read.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVadd ( int n, double y[], double x[] ) ;\n\\end{verbatim}\n\\index{DVadd@{\\tt DVadd()}}\nThis method adds {\\tt n} entries from {\\tt x[]} to {\\tt y[]},\ni.e.,\n{\\tt y[i] += x[i]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy ( int n, double y[], double alpha, double x[] ) ;\n\\end{verbatim}\n\\index{DVaxpy@{\\tt DVaxpy()}}\nThis method adds a scaled multiple of {\\tt n} entries from {\\tt x[]} \ninto {\\tt y[]},\ni.e.,\n{\\tt y[i] += alpha * x[i]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy2 ( int n, double z[], double a, double x[],\n               double b, double y[] ) ;\n\\end{verbatim}\n\\index{DVaxpy@{\\tt DVaxpy()}}\nThis method adds a scaled multiple of two vectors {\\tt x[]} \nand {\\tt y[]} to another vector {\\tt z[]}, i.e.,\ni.e.,\n{\\tt z[i] += a * x[i] + b * y[i]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy33 ( int n, double y0[], double y1[], double y2[], \n                double alpha, double x0[], double x1[], double x2[] ) ;\n\\end{verbatim}\n\\index{DVaxpy33@{\\tt DVaxpy33()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] + alpha[2] * x2[]\ny1[] = y1[] + alpha[3] * x0[] + alpha[4] * x1[] + alpha[5] * x2[]\ny2[] = y2[] + alpha[6] * x0[] + alpha[7] * x1[] + alpha[8] * x2[]\n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy32 ( int n, double y0[], double y1[], double y2[], \n                double alpha, double x0[], double x1[] ) ;\n\\end{verbatim}\n\\index{DVaxpy32@{\\tt DVaxpy32()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] \ny1[] = y1[] + alpha[2] * x0[] + alpha[3] * x1[] \ny2[] = y2[] + alpha[4] * x0[] + alpha[5] * x1[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy31 ( int n, double y0[], double y1[], double y2[], \n                double alpha, double x0[], double x1[] ) ;\n\\end{verbatim}\n\\index{DVaxpy31@{\\tt DVaxpy31()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] \ny1[] = y1[] + alpha[1] * x0[] \ny2[] = y2[] + alpha[2] * x0[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy23 ( int n, double y0[], double y1[], \n                double alpha, double x0[], double x1[], double x2[] ) ;\n\\end{verbatim}\n\\index{DVaxpy23@{\\tt DVaxpy23()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] + alpha[2] * x2[]\ny1[] = y1[] + alpha[3] * x0[] + alpha[4] * x1[] + alpha[5] * x2[]\n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy22 ( int n, double y0[], double y1[], \n                double alpha, double x0[], double x1[] ) ;\n\\end{verbatim}\n\\index{DVaxpy22@{\\tt DVaxpy22()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] \ny1[] = y1[] + alpha[2] * x0[] + alpha[3] * x1[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy21 ( int n, double y0[], double y1[], double alpha, double x0[] ) ;\n\\end{verbatim}\n\\index{DVaxpy21@{\\tt DVaxpy21()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] \ny1[] = y1[] + alpha[1] * x0[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy13 ( int n, double y0[], \n                double alpha, double x0[], double x1[], double x2[] ) ;\n\\end{verbatim}\n\\index{DVaxpy13@{\\tt DVaxpy13()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] + alpha[2] * x2[]\n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy12 ( int n, double y0[], double alpha, double x0[], double x1[] ) ;\n\\end{verbatim}\n\\index{DVaxpy12@{\\tt DVaxpy12()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] + alpha[1] * x1[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpy11 ( int n, double y0[], double alpha, double x0[] ) ;\n\\end{verbatim}\n\\index{DVaxpy11@{\\tt DVaxpy11()}}\nThis method computes this computation.\n\\begin{verbatim}\ny0[] = y0[] + alpha[0] * x0[] \n\\end{verbatim}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVaxpyi ( int n, double y[], int index[], double alpha, double x[] ) ;\n\\end{verbatim}\n\\index{DVaxpyi@{\\tt DVaxpyi()}}\nThis method scatteradds \na scaled multiple of {\\tt n} entries from {\\tt x[]} \ninto {\\tt y[]},\ni.e.,\n{\\tt y[index[i]] += alpha * x[i]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVcompress ( int n1, double x1[], double y1[],\n                  int n2, double x2[], double y2[] ) ;\n\\end{verbatim}\n\\index{DVcompress@{\\tt DVcompress()}}\nGiven a pair of arrays {\\tt x1[n1]} and {\\tt y1[n1]},\nfill {\\tt x2[n2]} and {\\tt y2[n2]} with a subset of the\n{\\tt (x1[j],y1[j]} entries whose distribution is an approximation.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVcopy ( int n, double y[], double x[] ) ;\n\\end{verbatim}\n\\index{DVcopy@{\\tt DVcopy()}}\nThis method copies {\\tt n} entries from {\\tt x[]} to {\\tt y[]},\ni.e.,\n{\\tt y[i] = x[i]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot ( int n, double y[], double x[] ) ;\n\\end{verbatim}\n\\index{DVdot@{\\tt DVdot()}}\nThis method returns the dot product of the vector {\\tt x[]} and\n{\\tt y[]},\ni.e., return\n$\\sum_{\\tt i = 0}^{\\tt n-1} ({\\tt x[i] * y[i]})$.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot33 ( int n, double row0[], double row1[], double row2[], \n              double col0[], double col1[], double col2[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot33@{\\tt DVdot33()}}\nThis method computes nine dot products.\n\\par\n\\begin{tabular}{lll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col2[i]}$ \\\\\n$\\displaystyle{\\tt sums[3]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[4]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[5]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col2[i]}$ \\\\\n$\\displaystyle{\\tt sums[6]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[7]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[8]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col2[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot32 ( int n, double row0[], double row1[], double row2[], \n              double col0[], double col1[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot32@{\\tt DVdot32()}}\nThis method computes six dot products.\n\\par\n\\begin{tabular}{ll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ \\\\\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[3]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col1[i]}$ \\\\\n$\\displaystyle{\\tt sums[4]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[5]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col1[i]}$\n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot31 ( int n, double row0[], double row1[], double row2[], \n              double col0[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot31@{\\tt DVdot31()}}\nThis method computes three dot products.\n\\par\n\\begin{tabular}{l}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ \\\\\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ \\\\\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row2[i] * col0[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot23 ( int n, double row0[], double row1[],         \n              double col0[], double col1[], double col2[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot23@{\\tt DVdot23()}}\nThis method computes six dot products.\n\\par\n\\begin{tabular}{lll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col2[i]}$ \\\\\n$\\displaystyle{\\tt sums[3]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[4]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[5]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col2[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot22 ( int n, double row0[], double row1[], \n              double col0[], double col1[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot22@{\\tt DVdot22()}}\nThis method computes four dot products.\n\\par\n\\begin{tabular}{ll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ \\\\\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[3]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col1[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot21 ( int n, double row0[], double row1[], \n              double col0[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot21@{\\tt DVdot21()}}\nThis method computes two dot products.\n\\par\n\\begin{tabular}{l}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ \\\\\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row1[i] * col0[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot13 ( int n, double row0[], \n              double col0[], double col1[], double col2[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot13@{\\tt DVdot13()}}\nThis method computes six dot products.\n\\par\n\\begin{tabular}{lll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ &\n$\\displaystyle{\\tt sums[2]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col2[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot12 ( int n, double row0[], double row1[], \n              double col0[], double col1[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot12@{\\tt DVdot12()}}\nThis method computes two dot products.\n\\par\n\\begin{tabular}{ll}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$ &\n$\\displaystyle{\\tt sums[1]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col1[i]}$ \n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdot11 ( int n, double row0[], double col0[], double sums[] ) ;\n\\end{verbatim}\n\\index{DVdot11@{\\tt DVdot11()}}\nThis method computes one dot product.\n\\par\n\\begin{tabular}{l}\n$\\displaystyle{\\tt sums[0]}\n               = \\sum_{\\tt i = 0}^{\\tt n-1} {\\tt row0[i] * col0[i]}$\n\\end{tabular}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nint DVdoti ( int n, double y[], int index[], double x[] ) ;\n\\end{verbatim}\n\\index{DVdoti@{\\tt DVdoti()}}\nThis method returns the indexed dot product \n$\\displaystyle \\sum_{{\\tt i=0}}^{{\\tt n-1}} {\\tt y[index[i]] * x[i]}$.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVfill ( int n, double y[], double val ) ;\n\\end{verbatim}\n\\index{DVfill@{\\tt DVfill()}}\nThis method fills {\\tt n} entries in {\\tt y[]} with {\\tt val}, \ni.e.,\n{\\tt y[i] = val} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVgather ( int n, double y[], double x[], int index[] ) ;\n\\end{verbatim}\n\\index{DVgather@{\\tt DVgather()}}\n{\\tt y[i] = x[index[i]]} for {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVgatherAddZero ( int n, double y[], double x[], int index[] ) ;\n\\end{verbatim}\n\\index{DVgatherAddZero@{\\tt DVgatherAddZero()}}\n{\\tt y[i] += x[index[i]]} and\n{\\tt x[index[i]] = 0} \nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVgatherZero ( int n, double y[], double x[], int index[] ) ;\n\\end{verbatim}\n\\index{DVgatherZero@{\\tt DVgatherZero()}}\n{\\tt y[i] = x[index[i]]} and\n{\\tt x[index[i]] = 0} \n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVinvPerm ( int n, double y[], int index[] ) ;\n\\end{verbatim}\n\\index{DVinvPerm@{\\tt DVinvPerm()}}\nThis method permutes the vector y as follows.\ni.e.,\n{\\tt y[index[i]] := y[i]}.\nSee {\\tt DVperm()} for a similar function.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVmax ( int n, double y[], int *ploc ) ;\n\\end{verbatim}\n\\index{DVmax@{\\tt DVmax()}}\nThis method returns the maximum entry in {\\tt y[0:n-1]}\nand puts the first location where it was found into the address\n{\\tt ploc}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVmaxabs ( int n, double y[], int *ploc ) ;\n\\end{verbatim}\n\\index{DVmaxabs@{\\tt DVmaxabs()}}\nThis method returns the maximum magnitude of entries in \n{\\tt y[0:n-1]} and puts the first location where \nit was found into the address {\\tt ploc}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVmin ( int n, double y[], int *ploc ) ;\n\\end{verbatim}\n\\index{DVmin@{\\tt DVmin()}}\nThis method returns the minimum entry in {\\tt y[0:n-1]}\nand puts the first location where it was found into the address\n{\\tt ploc}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVminabs ( int n, double y[], int *ploc ) ;\n\\end{verbatim}\n\\index{DVminabs@{\\tt DVminabs()}}\nThis method returns the minimum magnitude of entries in \n{\\tt y[0:n-1]} and puts the first location where \nit was found into the address {\\tt ploc}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVperm ( int n, double y[], int index[] ) ;\n\\end{verbatim}\n\\index{DVperm@{\\tt DVperm()}}\nThis method permutes the vector y as follows.\ni.e.,\n{\\tt y[i] := y[index[i]]}.\nSee {\\tt DVinvPerm()} for a similar function.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVramp ( int n, double y[], double start, double inc ) ;\n\\end{verbatim}\n\\index{DVramp@{\\tt DVramp()}}\nThis method fills {\\tt n} entries in {\\tt y[]} with \nvalues \n{\\tt start},\n{\\tt start + inc},\n{\\tt start + 2*inc},\n{\\tt start + 3*inc}, etc.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscale ( int n, double y[], double alpha ) ;\n\\end{verbatim}\n\\index{DVscale@{\\tt DVscale()}}\nThis method scales a vector {\\tt y[]} by {\\tt alpha},\ni.e.,\n{\\tt y[i] *= alpha}.\nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscale2 ( int n, double x[], double y[], \n                double a, double b, double c, double d ) ;\n\\end{verbatim}\n\\index{DVscale@{\\tt DVscale()}}\nThis method scales two vectors {\\tt y[]} by a $2 \\times 2$ matrix,\ni.e.,\n$$\n\\left \\lbrack \\begin{array}{ccc}\n{\\tt x[0]} & \\ldots & {\\tt x[n-1]} \\\\\n{\\tt y[0]} & \\ldots & {\\tt y[n-1]} \n\\end{array} \\right \\rbrack\n:= \n\\left \\lbrack \\begin{array}{cc}\n{\\tt a} & {\\tt b} \\\\\n{\\tt c} & {\\tt d}\n\\end{array} \\right \\rbrack\n\\left \\lbrack \\begin{array}{ccc}\n{\\tt x[0]} & \\ldots & {\\tt x[n-1]} \\\\\n{\\tt y[0]} & \\ldots & {\\tt y[n-1]} \n\\end{array} \\right \\rbrack.\n$$\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscatter ( int n, double y[], int index[], double x[] ) ;\n\\end{verbatim}\n\\index{DVscatter@{\\tt DVscatter()}}\nThis method scatters {\\tt n} entries of {\\tt x[]} into {\\tt y[]} \nas follows,\n{\\tt y[index[i]] = x[i]} \nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscatterAdd ( int n, double y[], int index[], double x[] ) ;\n\\end{verbatim}\n\\index{DVscatterAdd@{\\tt DVscatterAdd()}}\nThis method scatters/adds {\\tt n} entries of {\\tt x[]} into {\\tt y[]} \nas follows,\n{\\tt y[index[i]] += x[i]} \nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscatterAddZero ( int n, double y[], int index[], double x[] ) ;\n\\end{verbatim}\n\\index{DVscatterAddZero@{\\tt DVscatterAddZero()}}\nThis method scatters/adds {\\tt n} entries of {\\tt x[]} into {\\tt y[]} \nas follows,\n{\\tt y[index[i]] += x[i]} \nfor {\\tt 0 <= i < n},\nand then zeros the entries in {\\tt x[*]}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVscatterZero ( int n, double y[], int index[], double x[] ) ;\n\\end{verbatim}\n\\index{DVscatterZero@{\\tt DVscatterZero()}}\nThis method scatters {\\tt n} entries of {\\tt x[]} into {\\tt y[]} \nas follows,\n{\\tt y[index[i]] = x[i]} \nfor {\\tt 0 <= i < n}\nand then zeros the entries in {\\tt x[*]}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVsub ( int n, double y[], double x[] ) ;\n\\end{verbatim}\n\\index{DVsub@{\\tt DVsub()}}\nThis method subtracts {\\tt n} entries from {\\tt x[]} to {\\tt y[]},\ni.e.,\n{\\tt y[i] -= x[i]}\nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVsum ( int n, double y[] ) ;\n\\end{verbatim}\n\\index{DVsum@{\\tt DVsum()}}\nThis method returns the sum of the first {\\tt n} entries \nin the vector {\\tt x[]},\ni.e., return\n$\\sum_{\\tt i = 0}^{\\tt n-1} {\\tt x[i]}$.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndouble DVsumabs ( int n, double y[] ) ;\n\\end{verbatim}\n\\index{DVsumabs@{\\tt DVsumabs()}}\nThis method returns the sum of the absolute values of the \nfirst {\\tt n} entries in the vector {\\tt x[]},\ni.e., return\n$\\sum_{\\tt i = 0}^{\\tt n-1} {\\tt abs(x[i])}$.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVswap ( int n, double y[], double x[] ) ;\n\\end{verbatim}\n\\index{DVswap@{\\tt DVswap()}}\nThis method swaps the {\\tt x[]} and {\\tt y[]} vectors as follows.\ni.e.,\n{\\tt y[i] := x[i]} and\n{\\tt x[i] := y[i]} \nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVzero ( int n, double y[] ) ;\n\\end{verbatim}\n\\index{DVzero@{\\tt DVzero()}}\nThis method zeroes {\\tt n} entries in {\\tt y[]},\ni.e.,\n{\\tt y[i] = 0} \nfor {\\tt 0 <= i < n}.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid DVshuffle ( int n, double y[], int seed ) ;\n\\end{verbatim}\n\\index{DVshuffle@{\\tt DVshuffle()}}\nThis method shuffles the first {\\tt n} entries in {\\tt y[]}.\nThe value {\\tt seed} is the seed to a random number generator,\nand one can get repeatable behavior by repeating {\\tt seed}.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n", "meta": {"hexsha": "c2255feed70acb809d13fcbe1d45f9fddc6042fb", "size": 22987, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/Utilities/doc/DV.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/Utilities/doc/DV.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/Utilities/doc/DV.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 35.6387596899, "max_line_length": 78, "alphanum_fraction": 0.4881019707, "num_tokens": 6777, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6513548782017746, "lm_q1q2_score": 0.43114669417824136}}
{"text": "\\section{Specification of $\\lambda_Q$} \\label{spec}\n\nIn this section we give the language specification of $\\lambda_Q$, including the syntax, typing rules and syntactic sugars.\nThe syntax and typing rules of the quantum circuit are similar to Qwire \\cite{qwire}.\nThe operational semantics are not given in this section.\nInstead, we give a transformation from $\\lambda_Q$ to $QASM$ in the section of frontend, which gives semantics to each syntax of $\\lambda_Q$.\nInterested readers can refer to the operational semantics of simply-typed $\\lambda$-calculus and Qwire.\n\n\\subsection{Syntax}\nThe syntax of the traditional part (terms, values, types) is an extended version of simply-typed $\\lambda$-calcus with $\\trun\\ C$ and $\\kappa \\ p:W . C$, which are used to interact with the quantum part.\nThe syntax of the quantum part (circuits, wire types, wire patterns, gates, gate types) is similar to the syntax of Qwire.\n% \\mycomment{twh}{modify syntax (especially gate)}\n\n\\begin{longtable}[c]{lclr}\n  % \\caption{syntax}\n  \\label{tab:table1}\\\\\n  \\toprule\n  $t$ &$::=$ &  &\\textbf{terms}: \\\\\n      & &$x$ &variable\\\\\n      & &$\\unit$ &constant unit\\\\\n      & &$\\true$ &constant true\\\\\n      & &$\\false$ &constant false\\\\\n      & &$\\lambda\\ x:T.t$ &function abstraction\\\\\n      & &$t\\ t$ &function application\\\\\n      & &$(t, t)$ &pair\\\\\n      & &$t.1$ &first projection\\\\\n      & &$t.2$ &second projection\\\\\n      & &$\\tif\\ t\\ \\tthen\\ t\\ \\telse\\ t$ &conditional\\\\\n      & &$\\trun\\ C$ &static lifting\\\\\n      & &$\\kappa \\ p:W . C$ &circuit abstraction\\\\\n      % & &0 &constant zero\\\\\n      % & &succ $t$ &successor\\\\\n      % & &pred $t$ &predecessor\\\\\n      % & &iszero $t$ & zero test\\\\\n  \\\\\n  \n  $v$ &$::=$ &  &\\textbf{values}: \\\\\n      & &$\\lambda\\ x:T.t$ &abstraction value\\\\\n      & &$(v, v)$ &pair value\\\\\n      & &$\\unit$ &unit value\\\\\n      & &$\\true$ &true value\\\\\n      & &$\\false$ &false value\\\\\n      & &$\\kappa\\ p:W . C$ &circuit value\\\\\n  \\\\\n\n  $T$ &$::=$ &  &\\textbf{types}: \\\\\n      & &$\\Unit$ &unit type\\\\\n      & &$\\Bool$ &boolean type \\\\\n      & &$T\\times T$ &product type\\\\\n      & &$T\\to T$ &function type\\\\\n      & &$T\\leadsto T$ &circuit type\\\\\n      % & &Nat &type of natural numbers\\\\\n      % & &Vector $t$ &type family of vectors\\\\\n  \\\\\n\n  $\\Gamma$ &$::=$ &  &\\textbf{contexts}: \\\\\n      & &$\\varnothing$ &empty context\\\\\n      & &$\\Gamma,x:T$ &term variable binding\\\\\n  \\\\\n\n\n  $W$ &$::=$ &  &\\textbf{wire types}: \\\\\n      & &$\\One$ &wire unit type\\\\\n      & &$\\Bit$ &bit type \\\\\n      & &$\\Qubit$ &qubit type \\\\\n      & &$W \\otimes W$ &wire product type \\\\\n  \\\\\n\n  $p$ &$::=$ &  &\\textbf{wire patterns}: \\\\\n      & &$()$ &empty\\\\\n      & &$w$ &wire variable \\\\\n      & &$(p,p)$ &wire pair \\\\\n  \\\\\n\n  $C$ &$::=$ &  &\\textbf{circuits}: \\\\\n      & &$\\toutput\\ p$ &output a pattern \\\\\n      & &$p_2 \\from \\gate\\ g\\ p_1 ; C$ &gate application \\\\\n      & &$p \\from C ; C$ &circuit composition \\\\\n      & &$x \\hookleftarrow \\lift\\ p ; C$ &dynamic lifting \\\\\n      & &$\\capp\\ t\\ \\mathtt{to}\\  p$ &circuit application \\\\\n  \\\\\n\n  $g$ &$::=$ &  &\\textbf{gates}: \\\\\n      & &$\\new_0$ &generate a bit 0 \\\\\n      & &$\\new_1$ &generate a bit 1 \\\\\n      & &$\\init_0$ &generate a qubit 0 \\\\\n      & &$\\init_1$ &generate a qubit 1 \\\\\n      & &$\\meas$ &measurement gate \\\\\n      & &$\\discard$ &disgard gate \\\\\n      & &$\\Ha$ &Hadamard gate \\\\\n      & &$\\X$ &Pauli-X gate \\\\\n      & &$\\Z$ &Pauli-Z gate \\\\\n      & &$\\CNOT$ &CNOT gate \\\\\n  \\\\\n\n  $G$ &$::=$ &  &\\textbf{gate types}:\\\\\n      & &$\\mathcal{G}(W, W)$ &simple gate type\\\\\n  \\\\\n\n  $\\Omega$ &$::=$ &  &\\textbf{wire contexts}: \\\\\n      & &$\\varnothing$ &empty context\\\\\n      & &$\\Omega,w:W$ &wire variable binding\\\\\n  \\\\\n  % TODO: add the condition of well-formed contexts\n\n  \\bottomrule\n  \n\\end{longtable}\n\n\\subsection{Typing Rules} \\label{typing}\nThe main feature of the language design of $\\lambda_Q$ is to use linear type system to guarantee no quantum bit is used twice or not used at all.\nTo state the type inference rules of $\\lambda_Q$, we first need to define what is a \\textbf{well-formed wire context}, which is used to maintain variables used by quantum circuit in the calculus.\nThis context is actually corresponding to the context of linear variables in the traditional linear type system.\n\\begin{Def}[Well-formed Wire Contexts]\n  A wire context $\\Omega$ is well-formed, if there are no duplicate wire variables in it.\n  For simplicity, we always assume the wire contexts are well-formed in the following contexts. And when we write $\\Omega_1, \\Omega_2$, we require $\\Omega_1$ and $\\Omega_2$ to be disjoint to preserve the well-formedness.\n\\end{Def}\n\nSince there are some different kinds of terms: ($\\lambda$-)terms, wire patterns, gates and circuits, we have defined several different typing relations for each of them.\n\\begin{itemize}\n  \\item $\\Omega \\vdash p : W$ is the typing relation for patterns.\n  \\item $\\Gamma ; \\Omega \\vdash C : W$ is the typing relation for circuits;\n  \\item $\\Gamma \\vdash t:T$ is the typing relation for ($\\lambda$-)terms;\n  \\item $g : G$ is the typing relation for gates.\n\\end{itemize}\n\n\\subsubsection{Typing rules for gates}\nNote that since we only support built-in gates, the typing rules for gates are extremely simple, just assigning a type to each built-in gate.\n\n\\noindent \\textbf{Typing rules for gates}: $\\boxed{g : G}$\n\n~\n\n\\renewcommand\\arraystretch{2.5}\n\\begin{longtable}[c]{cr}\n  $ \\infer{\\new_0 : \\calG(\\One, \\Bit)}{}$ & \\\\\n  $ \\infer{\\new_1 : \\calG(\\One, \\Bit)}{}$ & \\\\\n  $ \\infer{\\init_0 : \\calG(\\One, \\Qubit)}{}$ & \\\\\n  $ \\infer{\\init_1 : \\calG(\\One, \\Qubit)}{}$ & \\\\\n  $ \\infer{\\meas : \\calG(\\Qubit, \\Bit)}{}$ & \\\\\n  $ \\infer{\\discard : \\calG(\\Bit, \\One)}{}$ & \\\\\n  $ \\infer{\\Ha : \\calG(\\Qubit, \\Qubit)}{}$ & \\\\\n  $ \\infer{\\X : \\calG(\\Qubit, \\Qubit)}{}$ & \\\\\n  $ \\infer{\\Z : \\calG(\\Qubit, \\Qubit)}{}$ & \\\\\n  $ \\infer{\\CNOT : \\calG((\\Qubit, \\Qubit), (\\Qubit, \\Qubit))}{}$ & \\\\\n\\end{longtable}\n\n\\subsubsection{Typing rules for patterns}\nThe patterns are used to construct complex gates.\nPatterns are destructed when doing pattern matching in gate application, circuit composition and dynamic lifting.\n\n\\noindent \\textbf{Typing rules for patterns}: $\\boxed{\\Omega \\vdash p : W}$\n\\renewcommand\\arraystretch{2.5}\n\\begin{longtable}[c]{cr}\n  $ \\infer{\\varnothing \\vdash ():One}{}$ & \\\\\n  $ \\infer{w:W \\vdash w:W}{}$ & \\\\\n  $ \\infer{\\Omega_1, \\Omega_2 \\vdash (p_1,p_2):W_1\\otimes W_2}{\\Omega_1 \\vdash p_1 : W_1  &\\Omega_2 \\vdash p_2 : W_2} $ & \\\\\n\\end{longtable}\n\n\\subsubsection{Typing rules for circuits}\nThe typing rules for circuit uses linear type. The context $\\Gamma$ is for normal (traditional) variables and the context $\\Omega$ is for linear (quantum) variables.\n\n\\noindent \\textbf{Typing rules for circuits}: $\\boxed{\\Gamma;\\Omega\\vdash C:W}$\n\n\n\\renewcommand\\arraystretch{3} \n\\begin{longtable}[c]{cr}\n  $\\infer{\\Gamma;\\Omega\\vdash \\toutput\\ p:W}{\\Omega\\vdash p : W}$ &(C-OUTPUT)\\\\\n  $\\infer{\\Gamma;\\Omega_1,\\Omega\\vdash p_2 \\from \\gate\\ g\\ p_1 ; C:W}{g:\\calG(W_1, W_2) &\\Omega_1\\vdash p_1:W_1 &\\Omega_2\\vdash p_2:W_2 &\\Gamma ; \\Omega_2,\\Omega \\vdash C:W}$ &(C-GATE)\\\\\n  $\\infer{\\Gamma;\\Omega_1,\\Omega_2\\vdash p \\from C ; C':W'}{\\Gamma;\\Omega_1\\vdash C:W &\\Omega \\vdash p:W &\\Gamma;\\Omega,\\Omega_2 \\vdash C':W'}$ &(C-COMPOSE)\\\\\n  $\\infer{\\Gamma;\\Omega,\\Omega'\\vdash x \\hookleftarrow \\lift\\ p ; C:W'}{\\Omega\\vdash p:W &\\Gamma,x:|W|;\\Omega' \\vdash C:W'}$ &(C-LIFT)\\\\\n  $\\infer{\\Gamma;\\Omega\\vdash \\capp\\ t\\ \\mathtt{to}\\ p : W_2}{\\Gamma\\vdash t:W_1\\leadsto W_2 &\\Omega\\vdash p:W_1}$ &(C-CAPP)\\\\\n  \n\\end{longtable}\n\n\\subsubsection{Typing rules for terms}\n\n\\noindent \\textbf{Typing rules for ($\\lambda$-)terms}: $\\boxed{\\Gamma\\vdash t:T}$\n\n\\renewcommand\\arraystretch{3}\n\\begin{longtable}[c]{cr}\n  $\\infer{\\Gamma\\vdash \\trun\\ C : |W| }{\\Gamma;\\varnothing \\vdash C:W}$ &(T-RUN)\\\\\n  $\\infer{\\Gamma\\vdash \\kappa\\ p:W_1 . C: W_1\\leadsto W_2 }{\\Omega\\vdash p:W_1 &\\Gamma;\\Omega\\vdash C:W_2}$ &(T-CABS)\\\\\n  $\\infer{\\Gamma\\vdash x:T}{x:T\\in \\Gamma}$ &(T-VAR)\\\\\n  $\\infer{\\Gamma\\vdash \\lambda\\ x:T_1.t_2 : T_1\\to T_2}{\\Gamma,x:T_1 \\vdash t_2:T_2}$ &(T-ABS)\\\\\n  $\\infer{\\Gamma\\vdash t_1\\ t_2 : T_{12}}{\\Gamma\\vdash t_1:T_{11}\\to T_{12} & \\Gamma\\vdash t_2:T_{11}}$ &(T-APP)\\\\\n  $\\infer{\\Gamma\\vdash\\true : Bool}{}$ &(T-TRUE)\\\\\n  $\\infer{\\Gamma\\vdash\\false : Bool}{}$ &(T-FALSE)\\\\\n  $\\infer{\\tif\\ t_1\\ \\tthen\\ t_2\\ \\telse\\ t_3 : T}{\\Gamma\\vdash t_1:\\Bool &\\Gamma\\vdash t_2:T &\\Gamma\\vdash t_3:T}$ &(T-IF)\\\\\n  $\\infer{\\Gamma\\vdash\\unit : Unit}{}$ &(T-UNIT)\\\\\n  $\\infer{\\Gamma\\vdash (t_1,t_2) : T_1\\times T_2}{\\Gamma\\vdash t_1:T_1 &\\Gamma\\vdash t_2:T_2}$ &(T-PAIR)\\\\\n  $\\infer{\\Gamma\\vdash t.1 : T_1}{\\Gamma\\vdash t : T_1\\times T_2}$ &(T-FST)\\\\\n  $\\infer{\\Gamma\\vdash t.2 : T_2}{\\Gamma\\vdash t : T_1\\times T_2}$ &(T-SEC)\\\\\n\\end{longtable}\n\n% \\begin{longtable}[c]{cr}\n%   $\\infer{\\Gamma\\vdash x:T}{x:T\\in\\Gamma &\\Gamma\\vdash T::*}$ &(T-VAR)\\\\\n%   $\\infer{\\Gamma\\vdash \\lambda x:S.t\\ :\\Pi x:S.T}{\\Gamma\\vdash S::* &\\Gamma,x:S\\vdash t:T}$ &(T-ABS)\\\\\n%   $\\infer{\\Gamma \\vdash t_1\\ t_2 : [x\\mapsto t_2]T}{\\Gamma\\vdash t_1:\\Pi x:S.T &\\Gamma\\vdash t_2:S}$ &(T-APP)\\\\\n%   $\\infer{\\Gamma\\vdash (t_1,t_2:\\Sigma x:S.T)\\ :\\Sigma x:S.T}{\\Gamma \\vdash t_1:S &\\Gamma\\vdash t_2:[x\\mapsto t_1]T}$ &(T-PAIR)\\\\\n%   $\\infer{\\Gamma\\vdash t.1:S}{\\Gamma\\vdash t:\\Sigma x:S.T}$ &(T-PROJ1)\\\\\n%   $\\infer{\\Gamma\\vdash t.2:[x\\mapsto t.1]T}{\\Gamma\\vdash t:\\Sigma x:S.T}$ &(T-PROJ2)\\\\\n%   $\\infer{\\Gamma\\vdash t:T'}{\\Gamma\\vdash t:T &\\Gamma\\vdash T\\equiv T'::*}$ &(T-CONV)\\\\\n% \\end{longtable}\n\n\\subsection{Syntactic Sugar}\nIn programming languages, it is useful to design some syntactic sugar to make it easier for programmer to programming.\nWe introduce a syntactic sugar to $\\lambda_Q$ to abstract one common form of gate application.\n$$p \\from \\gate\\ g\\ p;\\toutput\\ p \\ =\\ \\gate'\\ g\\ p$$", "meta": {"hexsha": "74d89cd4ec704be23684e199896a381299012e68", "size": 9762, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/specification.tex", "max_stars_repo_name": "thwfhk/lambdaQ", "max_stars_repo_head_hexsha": "834c0a42e234f486ac0f7b55f76e096d70cf7262", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-04-10T08:42:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-09T07:09:53.000Z", "max_issues_repo_path": "report/specification.tex", "max_issues_repo_name": "thwfhk/lambdaQ", "max_issues_repo_head_hexsha": "834c0a42e234f486ac0f7b55f76e096d70cf7262", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/specification.tex", "max_forks_repo_name": "thwfhk/lambdaQ", "max_forks_repo_head_hexsha": "834c0a42e234f486ac0f7b55f76e096d70cf7262", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-05-09T06:13:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-09T06:13:15.000Z", "avg_line_length": 46.7081339713, "max_line_length": 220, "alphanum_fraction": 0.6145257119, "num_tokens": 3491, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4311466939066609}}
{"text": "\\section{Experiments}%\n\\label{sec:experiments}\n\nWe use a custom implementation in C++ of all algorithm.\n\nWe used almost the same setup of the first grid presented by \\citeauthor{comp_mcts_mo}\\cite{comp_mcts_mo}.\nOnly we considered one precise setup to compare multiple algorithms.\nWe consider a \\gls{twm} problem on a \\(8 \\times 8\\) grid. \nWe consider \\(2\\) firefighter team.\nThe rewards of cells start at \\(-1\\) on the bottom left corner and increase by the by \\(-1\\) for each cell between a cell and the bottom left corner according to the manhattan distance.\nOnly neighbors cell can ignite each other with a probability of \\(0.06\\).\nFirefighter teams have a \\(0.8\\) probability to extinguish any burning cell.\nWe then follow the following procedure to obtain a root state\n\n\\begin{enumerate}\n    \\item Initialize all the cells with \\(66\\) fuel. \n    \\item Ignite the bottom left corner.\n    \\item Let the fire propagate with no cost for \\(66\\) turn.\n    \\item Scale down the amount of fuel on each cell by \\(.06\\) to avoid too long computation\n\\end{enumerate}\n\nWe use the same algorithm on \\(100\\) different root states, obtain by the previous procedure.\nWe then aggregate the results together to have an average value.\nWe used different algorithms:\n\n\\begin{itemize}\n    \\item random: select a random action among legal ones every turn.\n    \\item \\gls{uct} with \\(60\\) seconds of search time and an exploration parameter \\(c\\) equal to 1.\n    \\item \\gls{grave} with 60 seconds of search time, an \\textit{bias}  of \\(0.01\\) and a \\textit{ref} equal to 50.\n    \\item \\gls{nrpa} with a root level 2 and 25 iterations per level.\n    \\item \\gls{snrpa} with a root level 2 and 25 iterations per level and 100 playount at level 0.\n\\end{itemize}\n\nAll algortihms are rerun every turn, allowing us to use \\gls{nrpa} by taking the first action in the returned sequence.\nWe also included a version of the \\gls{snrpa} called \\textit{srnpa\\_os} which is not rerun every turn but run only once on the root state.\nWe then take the returned sequence and use it just like in a \\gls{snrpa} playout.\nThis allow us to use the \\gls{snrpa} with a level of 3 and 50 iteration per level with 100 playout at level 0 while still having a reasonable time of computation.\n\nThe figure \\ref{fig:results} presents the aggragated results of a 100 run for each algorithm with the parameters presented before.\nThe blue and yellow bar shows respectively the average highest reward obtainable from the root state and the average lowest reward obtainable from the root state.\nThese two values are computed before running the algorithm by considering the best case scenario and the worst one.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{./src/figures/moustache.png}\n    \\caption{Results on 100 simulation for different algorithm as described in section~\\ref{sub:results} for different algorithms}\n    \\label{fig:results}\n\\end{figure}\n\nThe results show that the \\gls{snrpa} performs significately better than other algorithm. \nWe find strange that \\gls{grave} algorithm performs so poorly and we extend the possibility of a non-wanted behaviour due to a code mistakes but we could not find one.\nThe \\gls{nrpa} still performs better than the random algorithm which suggest that good sequences might be close to what the \\gls{snrpa} find.\n\nWe wanted to see how the number of playout at level 0 impact the performance of the \\gls{snrpa}.\nWe run, on the same setup as experiment 1 (see section~\\ref{ssub:experiment_1}), 100 times the \\gls{snrpa} with the same parameters.\nOnly one had 100 playout at level 0 and the other had 1000.\n\nThe results are shown in figure~\\ref{fig:results_snrpa_playout}.\nIt shows that a bigger number of playouts tends to improve vastly the performance of the algorithm for a computation cost that does not increase that vastly.\nThe playout of the \\gls{snrpa} are much simpler than the playout of the \\gls{nrpa} and are computed much more faster.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{./src/figures/moustache_snrpa.png}\n    \\caption{Comparison between a \\gls{snrpa} with 100 playout at level 0 and a \\gls{snrpa} with a 1000}\n    \\label{fig:results_snrpa_playout}\n\\end{figure}\n\nThe \\gls{snrpa} seems to perform very well on this setup of grid.\nIt would be interesting to test it on other setup and problems, even on non stochastic ones where the \\gls{nrpa} perform very well.\nBy lack of computational power and time we will most likely presents these tests later on another paper.\n\n", "meta": {"hexsha": "352a180529a779f4311f1eea10c0af3e69b93c7b", "size": 4542, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/report/src/sections/experiments/experiments.tex", "max_stars_repo_name": "XanX3601/stochastic_mcts_optimization", "max_stars_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documents/report/src/sections/experiments/experiments.tex", "max_issues_repo_name": "XanX3601/stochastic_mcts_optimization", "max_issues_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/report/src/sections/experiments/experiments.tex", "max_forks_repo_name": "XanX3601/stochastic_mcts_optimization", "max_forks_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.2191780822, "max_line_length": 185, "alphanum_fraction": 0.7659621312, "num_tokens": 1182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.4311466895626497}}
{"text": "\\documentclass{paper}\n\n\\usepackage[utf8x]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{booktabs}\n\\usepackage{tikz}\n\n\\usetikzlibrary{shapes,calc,through,intersections,angles,quotes}\n\n\\title{Tilt constraint for look around}\n\n\\begin{document}\n\n\\section{Forward}\n\n\\begin{tikzpicture}[]\n  \\def\\r{3}\n  \\node at (0, 0)[circle,fill,inner sep=1] (c) {};\n  \\node[label=right:eye] at (8, -1.5)[circle,fill,inner sep=1] (p1) {};\n  \\coordinate (p2) at (40:\\r);\n\n  \\node[label=below left:ctr] at (0:\\r)[circle,fill,inner sep=1] (p3) {};\n\n  \\node [name path=Circle1,draw,circle through=(p2)] at (c) {};\n  \\draw (p2) -- (p1);\n  \\draw (p2) -- node[above] {$r$} (c);\n  \\draw[dashed] (p2) -- (40:\\r*2) coordinate (p5);\n  \\draw (p1) -- node[below] {$d$} (p3);\n  \\draw[] (c) -- node[above] {$r$} (p3);\n  \\coordinate (p4) at ($(p3) + (5,0)$);\n  \\coordinate (p6) at (intersection of p3--p4 and p1--p2);\n\n  \\draw[] (p3) -- node[above] {$L$} (p6);\n  \\draw[dashed] (p6) -- (p4);\n\n\n  \\pic [draw, <->, \"\\tiny $\\Delta\\rho$\", angle eccentricity=1.3, angle radius=30] {angle = p2--p1--p3};\n  \\pic [draw, <->, \"\\tiny $\\alpha$\", angle eccentricity=1.2, angle radius=25] {angle = p1--p3--p4};\n\n  \\pic [draw, <->, \"\\tiny $\\Omega$\", angle eccentricity=1.5, angle radius=15] {angle = p1--p2--p5};\n\n  \\pic [draw, <->, \"\\tiny $\\Delta\\rho + \\alpha$\", angle eccentricity=1.8, angle radius=20] {angle = p1--p6--p4};\n\\end{tikzpicture}\\vspace{1em}\n\nCalculate center tilt angle measured at the virtual sphere when applying\na look around tilt angle.\n\n\\begin{table}[h!tb]\n  \\centering\n  \\begin{tabular}{l l}\n  \\toprule\n  \\textbf{Variable} & \\textbf{Description} \\\\\n  \\midrule\n  $r$ & Earth radius \\\\\n  $d$ & Distance from eye to center \\\\\n  $\\alpha$ & Current tilt angle at center \\\\\n  $\\Delta \\rho$ & Look around angle delta \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n\\begingroup\n\\addtolength{\\jot}{0.5em}\n\\begin{align*}\n  \\frac{L}{\\sin{\\left(\\Delta\\rho\\right)}} & = \\frac{d}{\\sin{\\left(\\pi - \\Delta\\rho - \\alpha\\right)}} = \\frac{d}{\\sin{\\left(\\Delta\\rho + \\alpha\\right)}} \\\\\n  L & = d \\frac{\\sin{\\left(\\Delta\\rho\\right)}}{\\sin{\\left(\\Delta\\rho + \\alpha\\right)}} \\\\\n  \\frac{\\sin{\\left(\\Omega\\right)}}{r + L} & = \\frac{\\sin{\\left(\\Delta\\rho + \\alpha\\right)}}{r} \\\\\n  \\Omega & = \\sin^{-1}{\\left( \\sin{\\left(\\Delta \\rho + \\alpha\\right)} + \\frac{d}{r} \\sin{\\left(\\Delta \\rho\\right)} \\right)}\n\\end{align*}\n\\endgroup\n\n\\section{Inverse}\n\n\\begin{tikzpicture}[]\n  \\def\\r{3}\n  \\node at (0, 0)[circle,fill,inner sep=1] (c) {};\n  \\node[label=right:eye] at (8, -1.5)[circle,fill,inner sep=1] (p1) {};\n  \\coordinate (p2) at (40:\\r);\n\n  \\node[label=below left:ctr] at (0:\\r)[circle,fill,inner sep=1] (p3) {};\n\n  \\node [name path=Circle1,draw,circle through=(p2)] at (c) {};\n  \\draw (p2) -- (p1);\n  \\draw (p2) -- node[above] {$r$} (c);\n  \\draw[dashed] (p2) -- (40:\\r*2) coordinate (p5);\n  \\draw (p1) -- (p3);\n  \\draw[] (c) -- node[above] {$r$} (p3);\n  \\coordinate (p4) at ($(p3) + (5,0)$);\n  \\coordinate (p6) at (intersection of p3--p4 and p1--p2);\n\n  \\draw[dashed] (p3) -- (p4);\n\n  \\draw[] (c) -- node[below] {$e$} (p1);\n\n\n  \\pic [draw, <->, \"\\tiny $\\Delta\\rho$\", angle eccentricity=1.3, angle radius=30] {angle = p2--p1--p3};\n  \\pic [draw, <->, \"\\tiny $\\alpha$\", angle eccentricity=1.2, angle radius=25] {angle = p1--p3--p4};\n\n  \\pic [draw, <->, \"\\tiny $\\Omega$\", angle eccentricity=1.5, angle radius=15] {angle = p1--p2--p5};\n\n  \\pic [draw, <->, \"\\tiny $\\alpha_2$\", angle eccentricity=1.15, angle radius=50] {angle = p2--p1--c};\n  \\pic [draw, <->, \"\\tiny $\\alpha_1$\", angle eccentricity=1.12, angle radius=64] {angle = p3--p1--c};\n\\end{tikzpicture}\\vspace{1em}\n\nCalculate look around tilt delta to achieve a specific center tilt angle\nmeasured at the virtual sphere.\n\n\\begin{table}[h!tb]\n  \\centering\n  \\begin{tabular}{l l}\n  \\toprule\n  \\textbf{Variable} & \\textbf{Description} \\\\\n  \\midrule\n  $r$ & Earth radius \\\\\n  $d$ & Distance from eye to center \\\\\n  $e$ & Distance from eye to earth center \\\\\n  $\\alpha$ & Desired tilt angle when meeting constraint \\\\\n  $\\Omega$ & Current tilt angle at center \\\\\n  \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n\\begingroup\n\\addtolength{\\jot}{1em}\n\\begin{align*}\n  \\frac{\\sin{\\left(\\alpha_1\\right)}}{r} & = \\frac{\\sin{\\left(\\alpha\\right)}}{e},~~~~\n  \\alpha_1 = \\sin^{-1}{\\left(\\frac{r}{e} \\sin{\\left(\\alpha\\right)}\\right)} \\\\\n  \\frac{\\sin{\\left(\\alpha_2\\right)}}{r} & = \\frac{\\sin{\\left(\\Omega\\right)}}{e},~~~~\n  \\alpha_2 = \\sin^{-1}{\\left(\\frac{r}{e} \\sin{\\left(\\Omega\\right)}\\right)} \\\\\n  \\Delta \\rho & = \\alpha_2 - \\alpha_1 =\n  \\sin^{-1}{\\left(\\frac{r}{e} \\sin{\\left(\\Omega\\right)}\\right)} - \\sin^{-1}{\\left(\\frac{r}{e} \\sin{\\left(\\alpha\\right)}\\right)}\n\\end{align*}\n\\endgroup\n\n\\end{document}\n", "meta": {"hexsha": "ebf4b89c3ac41217c8a30515b3194850dd8ebb51", "size": 4673, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "node_modules/arcgis-js-api/views/3d/camera/constraintUtils/look-around.tex", "max_stars_repo_name": "rihorn/ky-libaries", "max_stars_repo_head_hexsha": "a3ae1e743b62b9784cd62c4983740c6bc037fbf1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-05-06T08:23:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-04T12:58:11.000Z", "max_issues_repo_path": "node_modules/arcgis-js-api/views/3d/camera/constraintUtils/look-around.tex", "max_issues_repo_name": "rihorn/ky-libaries", "max_issues_repo_head_hexsha": "a3ae1e743b62b9784cd62c4983740c6bc037fbf1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/arcgis-js-api/views/3d/camera/constraintUtils/look-around.tex", "max_forks_repo_name": "rihorn/ky-libaries", "max_forks_repo_head_hexsha": "a3ae1e743b62b9784cd62c4983740c6bc037fbf1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-05T18:59:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-05T18:59:25.000Z", "avg_line_length": 34.3602941176, "max_line_length": 154, "alphanum_fraction": 0.6023967473, "num_tokens": 1798, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.43114668521863836}}
{"text": "\\documentclass[final,3p,times,pdflatex]{elsarticle}\n\\usepackage{axodraw}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{color} % LCT: for text editing\n\\usepackage{amsfonts} % LCT: for Germanic \"e\" and \"m\" to match \\Re and \\Im\n\n\\bibstyle{elsarticle-num}\n\n% beginning of macros\n\\def\\SOFTSUSY{{\\tt SOFTSUSY}}\n\\def\\NMSSMTools{{\\tt NMSSMTools}}\n\\def\\code#1{\\small{\\tt #1}\\normalsize}\n\\newcommand{\\nn}{\\nonumber}\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\ba}{\\begin{eqnarray}}\n\\newcommand{\\ea}{\\end{eqnarray}}\n\\newcommand{\\Zv}{\\,\\mathbf{\\backslash}\\mkern-11.0mu{\\mathbb{Z}}_{3}} % AGW: Backslash looks better\n\\newcommand{\\ds}{\\displaystyle}\n\\newcommand{\\overbar}[1]{\\mkern 1.5mu\\overline{\\mkern-1.5mu#1\\mkern-1.5mu}\\mkern 1.5mu}\n% for RGEs\n\\newcommand{\\lamsq}{\\lambda^2}\n\\newcommand{\\kapsq}{\\kappa^2}\n\\newcommand{\\tr}{\\mathrm{Tr}}\n\\newcommand{\\dt}{\\frac{d}{dt}}\n\\newcommand{\\mhusq}{m^2_{H_2}}\n\\newcommand{\\mhdsq}{m^2_{H_1}}\n\\newcommand{\\mlamsq}{M_\\lambda^2}\n\\newcommand{\\mkapsq}{M_\\kappa^2}\n\\newcommand{\\mssq}{m_S^2}\n\\newcommand{\\mtrisq}{m_3^2}\n\\newcommand{\\msprsq}{m_S'^2}\n\\newcommand{\\mqsq}{m_{\\tilde{Q}}^2}\n\\newcommand{\\mdsq}{m_{\\tilde{d}}^2}\n\\newcommand{\\musq}{m_{\\tilde{u}}^2}\n\\newcommand{\\mlsq}{m_{\\tilde{L}}^2}\n\\newcommand{\\mesq}{m_{\\tilde{e}}^2}\n\\newcommand{\\Alam}{a_\\lambda/\\lambda}\n\\newcommand{\\Akap}{a_\\kappa/\\kappa}\n\\newcommand{\\Musq}{M_u^2}\n\\newcommand{\\Mdsq}{M_d^2}\n\\newcommand{\\Mesq}{M_e^2}\n\\newcommand{\\MSbar}{{\\overline{MS}}}\n\\DeclareMathOperator{\\sign}{sign}\n% text editing\n\\newcommand*{\\red}[1]{\\textcolor{red}{#1}}\n\\def\\at{\\alpha_t}\n\\def\\ab{\\alpha_b}\n\\def\\as{\\alpha_s}\n\\def\\atau{\\alpha_{\\tau}}\n%%\n% LCT: big O notation should not in calligraphic font\n\\def\\oat{O(\\at)}\n\\def\\oab{O(\\ab)}\n\\def\\oatau{O(\\atau)}\n\\def\\oatab{O(\\at\\ab)}\n\\def\\oatas{O(\\at\\as)}\n\\def\\oabas{O(\\ab\\as)}\n\\def\\oatababq{O(\\at\\ab + \\ab^2)}\n\\def\\oatqatababq{O(\\at^2 + \\at\\ab + \\ab^2)}\n\\def\\oatasatq{O(\\at\\as + \\at^2)}\n\\def\\oatasabas{O(\\at\\as +\\ab\\as)}\n\\def\\oatasabasatq{O(\\at\\as + \\at^2 +\\ab\\as)}\n\\def\\oatq{O(\\at^2)}\n\\def\\oabq{O(\\ab^2)}\n\\def\\oatauq{O(\\atau^2)}\n\\def\\oabatau{O(\\ab \\atau)}\n\\def\\oas{O(\\as)}\n\\def\\oatauqatab{O(\\atau^2 +\\ab \\atau )}\n% end of macros\n\n\\journal{Computer Physics Communications}\n\n\\begin{document}\n\n\\begin{frontmatter}\n\n%%% Adelaide preprint number\n\\begin{flushright}\nADP-13-33/T853\n\\end{flushright}\n\n\\title{Next-to-Minimal SOFTSUSY}\n\n\\author[damtp]{B.C.~Allanach}\n\\author[adelaide]{P.~Athron}\n\\author[adelaide,bern]{Lewis~C.~Tunstall\\corref{cor1}}\n\\ead{tunstall@itp.unibe.ch}\n\\cortext[cor1]{Corresponding author}\n\\author[dresden]{A.~Voigt}\n\\author[adelaide]{A.G.~Williams}\n\\address[damtp]{DAMTP, CMS, University of Cambridge, Wilberforce road, Cambridge, CB3\n  0WA, United Kingdom}\n\\address[adelaide]{ARC Centre of Excellence for Particle Physics at \nthe Tera-scale, School of Chemistry and Physics, University of Adelaide, \nAdelaide SA 5005 Australia}\n\\address[bern]{Albert Einstein Center for Fundamental Physics, Institute for Theoretical Physics, University of Bern, Sidlerstrasse 5, CH-3012 Bern, Switzerland}\n\\address[dresden]{Institut f\\\"ur Kern- und Teilchenphysik,\nTU Dresden, Zellescher Weg 19, 01069 Dresden, Germany}\n\n\\begin{abstract}\n  We describe an extension to the\n  \\SOFTSUSY~program that provides for the calculation of the sparticle spectrum in the\n  {\\em Next-to-Minimal} Supersymmetric Standard Model (NMSSM), where a chiral\n  superfield that is a singlet of the Standard Model gauge group is added to\n  the Minimal Supersymmetric Standard Model (MSSM) fields. Often, a $\\mathbb{Z}_3$\n  symmetry is \n  imposed upon the model. \\SOFTSUSY~can calculate the spectrum in this\n  case as well as the case where general $\\mathbb{Z}_3$ violating (denoted as $\\Zv$) terms are\n  added to \n  the soft supersymmetry breaking terms and the superpotential. \n  The user provides a theoretical boundary condition for the couplings and\n  mass terms of the singlet.\n  Radiative electroweak symmetry breaking data along with\n  electroweak and CKM matrix data are used\n  as weak-scale boundary conditions. \n  The renormalisation group equations are solved\n  numerically between the weak scale and a high energy scale using a nested\n  iterative algorithm. \n  This paper serves as a manual to the\n  NMSSM mode of the program, detailing the approximations and\n  conventions used. \n\\end{abstract}\n\n\\begin{keyword}\nsparticle, \nNMSSM, Higgs\n\\PACS 12.60.Jv\n\\PACS 14.80.Ly\n\\end{keyword}\n\\end{frontmatter}\n\n\\section{Program Summary}\n\\noindent{\\em Program title:} \\SOFTSUSY{}\\\\\n{\\em Program obtainable   from:} {\\tt http://softsusy.hepforge.org/}\\\\\n{\\em Distribution format:}\\/ tar.gz\\\\\n{\\em Programming language:} {\\tt C++}, {\\tt fortran}\\\\\n{\\em Computer:}\\/ Personal computer.\\\\\n{\\em Operating system:}\\/ Tested on Linux 3.x\\\\\n{\\em Word size:}\\/ 64 bits.\\\\\n{\\em External routines:}\\/ None.\\\\\n{\\em Typical running time:}\\/ A few seconds per parameter point.\\\\\n{\\em Nature of problem:}\\/ Calculating supersymmetric particle spectrum and\nmixing parameters in the next-to-minimal minimal supersymmetric standard\nmodel. The solution to the renormalisation group equations must be consistent\nwith boundary conditions on supersymmetry breaking parameters, as\nwell as on the weak-scale boundary condition on gauge \ncouplings, Yukawa couplings and the Higgs potential parameters.\\\\\n{\\em Solution method:}\\/ Nested iterative algorithm and numerical minimisation\nof the Higgs potential. \\\\\n{\\em Restrictions:} \\SOFTSUSY~will provide a solution only in the\nperturbative regime and it\nassumes that all couplings of the model are real\n(i.e.\\ $CP-$conserving). If the parameter point under investigation is\nnon-physical for some reason (for example because the electroweak potential\ndoes not have an acceptable minimum), \\SOFTSUSY{} returns an error message.\\\\\n{\\em CPC Classification:} 11.1 and 11.6.\\\\\n{\\em Does the new version supersede the previous version?:} Yes.\\\\\n{\\em Reasons for the new version:} Major extension to include the\nnext-to-minimal supersymmetric standard model.\\\\\n{\\em Summary of revisions:} Added additional supersymmetric and supersymmetry\nbreaking parameters associated with the additional gauge singlet. Electroweak\nsymmetry breaking conditions are significantly changed in the next-to-minimal\nmode, and some sparticle mixing changes. An interface to \\NMSSMTools~has also\nbeen included. Some of the object structure has also changed, and the command\nline interface has been made more user friendly.\n\n\\newpage\n\n\\section{Introduction}\n\nWhile TeV-scale supersymmetric particles have not yet been found\\footnote{In some\n  cases, lower   bounds of 1 \nTeV or more have been placed upon gluinos and squarks by LHC experiments.}\nat the LHC~\\cite{Aad:2013wta,CMSspart}, searches for them continue along with\ncontinuing strong theoretical interest in supersymmetric (SUSY) models. \nThis is a\ntestament to the \ntheoretical successes of weak-scale supersymmetry: chiefly the resolution of\nthe technical hierarchy problem, improvement of the apparent unification of Standard\nModel (SM) gauge couplings and the provision of a potential \ndark matter candidate. \nIn order to pursue SUSY phenomenology, a long calculational chain is\nrequired~\\cite{Allanach:2008zn}. Typically, this chain begins with the\ncalculation of the \nsupersymmetric spectrum, including the couplings of the various sparticles and\nHiggs bosons. Currently, in the Minimal Supersymmetric Standard Model (MSSM), there\nare several spectrum generators: {\\tt\n  ISASUSY}~\\cite{Baer:1993ae}, {\\tt \n  SOFTSUSY}~\\cite{Allanach:2001kg}, {\\tt   SPheno}~\\cite{Porod:2003um}, {\\tt\n  SUSEFLAV}~\\cite{Chowdhury:2011zr} and {\\tt SUSPECT}~\\cite{Djouadi:2002ze}. \nInformation from these spectrum generators is then passed to other programs\n(for example those that calculate decays, that simulate collider events, or\nthat calculate the thermal relic density of dark matter) via data in the SUSY\nLes Houches Accord format~\\cite{Skands:2003cj}.\n\nRecently a boson was discovered in the CMS and \nATLAS experiments at over the 5$-\\sigma$\nlevel~\\cite{Aad:2012tfa,Chatrchyan:2012ufa} with properties consistent\nwith the SM Higgs boson. Using 4.8 fb$^{-1}$ of 7 TeV data and 20.7\nfb$^{-1}$ of 8 TeV data, ATLAS measures the mass to be\n$m_h=125.5\\pm0.2^{+0.5}_{-0.6}$ GeV by combining the $H \\rightarrow \\gamma\n\\gamma$ and $H \\rightarrow ZZ$ decay channels~\\cite{ATLAS-CONF-2013-014}.\nIn CMS, these channels give the combined constraint $m_h=125.3 \\pm0.4 \\pm0.5$\nGeV in 5.1 fb$^{-1}$ of 7 TeV data and 5.3 fb$^{-1}$ of 8 TeV data. \nIn the MSSM, one can often obtain a CP even Higgs that couples in a similar\nway to the Standard Model Higgs boson. At tree-level, its mass is bounded by\n$m_{h^0} < M_Z$, at odds with the LHC experiments' mass measurements. \nHowever,\nthe radiative corrections to the CP even Higgs mass can be sizeable,\nparticularly those from stops. The corrections are larger if the stops are\nheavy, and if they are heavily mixed. Indeed, the MSSM has enough\nflexibility~\\cite{Djouadi:2013lra} such that the experimental values of\n$m_{h^0}$ are achievable with TeV-scale stops and large mixing. On the other\nhand, these relatively heavy stops reintroduce the little hierarchy problem,\nrequiring cancellation (at the level of one in several tens) \nbetween apparently unrelated parameters in the MSSM Higgs potential. \nThus, we have the well known correlation~\\cite{Barbieri:1998uv} between a\nhigher Higgs mass $m_{h^0}>106$ GeV and a higher level of apparently unnatural\ncancellation. In several\nwell-studied simple models of supersymmetry breaking mediation, the\nproblem is much exacerbated~\\cite{Arbey:2011ab}. \n\nIn order to reduce the unnatural cancellations implied by the Higgs mass\nmeasurement~\\cite{Delgado:2010uj,Ellwanger:2011mu,King:2012tr,Perelstein:2012qg,Gherghetta:2012gb}, \none can augment the MSSM by a gauge singlet chiral\nsuperfield~\\cite{BasteroGil:2000bw,Ellwanger:2009dp,Maniatis:2009re}. This model is referred to as the \nNext-to-Minimal \nSupersymmetric Standard Model (NMSSM)~\\cite{NMSSM}. We shall distinguish\nbetween a \nversion where an extra symmetry is assumed (often a $\\mathbb{Z}_3$ symmetry) \nand a version where it is not\n($\\Zv$)~\\cite{Delgado:2010uj,Ell08,Ross:2011xv,Ross:2012nr}. \nIn the MSSM, (based on a two Higgs doublet version of the SM with\nsoftly broken $N=1$ global supersymmetry)\nthe tree-level bound upon the Higgs mass comes from the fact that \nthe quartic Higgs couplings are related to the electroweak gauge couplings by\nsupersymmetry. The Higgs potential is modified by the addition of a gauge\nsinglet, and the resulting lightest CP even Higgs boson can receive additional\npositive corrections to its mass at tree-level. In addition, the neutral Higgs\npotential (now a function of three fields rather than two in the MSSM) is\nheavily modified, with associated potential reductions in the unnatural\ncancellations. Along with other factors this had lead to considerable interest in the NMSSM\nin the recent literature and benchmarks points with a $125$ GeV Higgs have already been proposed \\cite{King:2012is}.\nIt is therefore essential for the research community\nto have access to a variety of reliable computational tools to calculate the relevant NMSSM observables. \n\nAs mentioned above in the MSSM case, the initial step in a calculational\nchain is \ntypically spectrum and couplings calculation. Currently, there is one\nout-of-the-box package {\\tt NMSPEC}~\\cite{Ellwanger:2006rn} which calculates\nthe spectrum of the \nNMSSM, matching weak-scale data with theoretical boundary conditions on\nsupersymmetry breaking and Higgs potential parameters. However, one can also \nmarry {\\tt SARAH}~\\cite{Staub:2009bi,Staub:2010jh,Staub:2012pb,Staub:2013tta} with {\\tt\n  SPheno}~\\cite{Porod:2003um} in order to be \nable to \ncalculate the spectrum after setting up the model.\\footnote{This has also been done in some non-NMSSM contexts --- for a recent example see \\cite{Bharucha:2013ela}.} The NMSSM was included in\nan extended version of the SUSY Les Houches Accord~\\cite{Allanach:2008qq} so\nthat this \ninformation may be passed to programs performing other calculations. For\ninstance, \n{\\tt\n  NMHDECAY}~\\cite{Ellwanger:2005dv} is \ncapable of calculating the NMSSM Higgs decays, and\n{\\tt NMSDECAY}~\\cite{Muhlleitner:2003vg,Das:2011dg} calculates sparticle\ndecays. \\code{PYTHIA}~\\cite{Sjostrand:2007gs} is then capable of simulating\nparticle collisions in the NMSSM and, in addition, \\code{micrOMEGAs}~\\cite{Belanger:2008sj}\ncan calculate the thermal dark matter relic density.\n\nHaving several public spectrum generators for the MSSM has proved fruitful for\nthe community. As well as comparisons and bug-finding, the various generators\nhave different levels of approximations and are able to calculate in different\ngeneralisations of the MSSM. For example, some are easier (or harder) to use for certain\nassumptions about supersymmetry breaking mediation. \nThe advantages of having\nseveral supported, publicly available spectrum generators naturally also\nextends to the \ncase of the increasingly popular NMSSM.\nThe extension of {\\tt SOFTSUSY} to include the\nNMSSM will hopefully aid the\naccuracy and feasibility of a variety of NMSSM studies. \n\nIn the present paper, we focus on the recent components that have been added to\n{\\tt SOFTSUSY} in order to include the effects of the gauge singlet\nsuperfield. Up-to-date versions of this manual (along with other {\\tt\n  SOFTSUSY} manuals) \nwill be released along with the\ncode in the {\\tt doc/}~subdirectory. The other manuals in this subdirectory detail the standard\n$R-$parity conserving MSSM~\\cite{Allanach:2001kg}, \nthe $R-$parity violating MSSM~\\cite{Allanach:2009bv} and the loop-level\nneutrino mass \ncomputation in the $R-$parity violating MSSM~\\cite{Allanach:2011de}.\nThe remainder of the paper proceeds as follows: in section~\\ref{sec:notation}, we\nintroduce the NMSSM supersymmetric parameters and the soft supersymmetry\nbreaking \nparameters using our conventions.  In section~\\ref{sec:calculation}, we describe\nthe algorithm \nemployed to calculate the spectrum of masses and couplings of NMSSM\nparticles, detailing our level of approximation for various parts of the\ncalculation. More technical information is relegated to the appendices. In\nsection~\\ref{sec:run}, we explain how to run the program. The class structure,\nalong with the data contained within each class, is shown in\nsection~\\ref{sec:objects}. Finally, in section~\\ref{sec:RGEs}, we reproduce\nthe renormalisation group equations of the NMSSM to two-loops including the\nfull 3 by 3 flavour structure. \n\n\\section{NMSSM Parameters \\label{sec:notation}}\n\nIn this section, we introduce the NMSSM parameters\nin the \\SOFTSUSY~conventions. The translations to the variable\nnames used in the program code are shown explicitly in\nsection~\\ref{sec:objects}.  \n\n\\subsection{Supersymmetric parameters \\label{susypars}}\nThe chiral superfield particle content of the NMSSM has the \nfollowing $SU(3)_c\\times SU(2)_L\\times U(1)_Y$ quantum numbers\n\\begin{align}\nL&:(1,2,-\\tfrac{1}{2})\\,, & \\bar{E}&:(1,1,1)\\,, & \nQ&:(3,2,\\tfrac{1}{6})\\,,  & \\bar{U}&:(\\overline 3,1,-\\tfrac{2}{3})\\,, \\notag \\\\\n\\bar{D}&:(\\overline 3,1,\\tfrac{1}{3})\\,, & H_1&:(1,2,-\\tfrac{1}{2})\\,, & \nH_2&:(1,2,\\tfrac{1}{2})\\,, & S&:(1,1,0)\\,.\n\\label{fields}\n\\end{align}\n$S$ is the gauge singlet chiral superfield that is particular to the NMSSM. \n$L$, $Q$, $H_1$, and $H_2$ are the left-handed doublet lepton and quark \nsuperfields and the two Higgs doublets. $\\bar{E}$, $\\bar{U}$, and $\\bar{D}$ are \nthe lepton, up-type quark and down-type quark right-handed superfield singlets, \nrespectively. Note that the lepton doublet superfields $L^a_i$ and the Higgs \ndoublet superfield $H_1$ coupling to the down-type quarks have the same \nSM gauge quantum numbers. We denote an $SU(3)$ colour \nindex of the fundamental representation by  $\\{x,y,z\\} \\in \\{1,2,3 \\}$. The \n$SU(2)_L$ fundamental representation indices are denoted by \n$\\{a,b,c\\} \\in \\{1,2\\}$ and the generation indices by $\\{i,j,k\\} \\in \\{1,2,3\\}$.\n $\\epsilon_{xyz}=\\epsilon^{xyz}$ and  $\\epsilon_{ab}=\\epsilon^{ab}$ are totally\nantisymmetric tensors, with $\\epsilon_{123}=1$ and $\\epsilon_{12}=1$, \nrespectively.  Currently, only real couplings in the superpotential and Lagrangian are \nincluded. \n\nThe full renormalisable, $R-$parity conserving superpotential is given by\n%\n\\begin{align} \n W_{\\Zv}  &=  \\epsilon_{ab} \\left[ (Y_E)_{ij} L_i^b H_1^a \\bar{E}_{j} \n+ (Y_D)_{ij} Q_i^{bx} H_1^a \\bar{D}_{jx} \n+ (Y_U)_{ij} Q_i^{ax} H_2^b \\bar{U}_{jx} \n+ (\\lambda S + \\mu)(H^a_2 H^b_1) \\right]  + \\xi_FS \n+ \\frac{\\mu^\\prime}{2} S^{2} + \\frac{\\kappa}{3}S^{3} \\\\\n%\n&= W_\\mathrm{MSSM}^{\\mu =0} \n+ \\epsilon_{ab}\\left[ (\\lambda S + \\mu)(H^a_2 H^b_1) \\right]  \n+ \\xi_FS + \\frac{\\mu^\\prime}{2}S^{2} + \\frac{\\kappa}{3} S^{3} \\,\n\\label{eq:WZ3V}\n\\end{align}\n%\n\\noindent where $(Y_{U,D,E})_{ij}$ and $\\lambda,\\kappa$ are dimensionless Yukawa \ncouplings, $\\mu$ and $\\mu'$ are supersymmetric mass terms, and $\\xi_F$ encodes \nthe effects of the supersymmetric tadpole term.  We use\nthe subscript $\\Zv$~to reflect the fact that this superpotential \ncontains terms which violate the $\\mathbb{Z}_3$ symmetry that is commonly \nimposed on the NMSSM.  Imposing the $\\mathbb{Z}_3$ symmetry restricts the \nsuperpotential to\n%\n\\begin{align} \n W_{\\mathbb{Z}_3} &= \\epsilon_{ab} \\left[(Y_E)_{ij} L_i^b H_1^a \\bar{E}_{j} \n+ (Y_D)_{ij} Q_i^{bx} H_1^a \\bar{D}_{jx} + (Y_U)_{ij} Q_i^{ax} H_2^b \\bar{U}_{jx}  \n+ \\lambda S(H^a_2 H^b_1) \\right] + \\frac{\\kappa}{3}S^{3} \\\\\n%\n&= W_\\mathrm{MSSM}^{\\mu =0}  + \\epsilon_{ab} \\lambda S (H^a_2 H^b_1) \n+ \\frac{\\kappa}{3}S^{3}.\n\\label{eq:WZ3C}\n\\end{align}\n%\n\\noindent The $\\mathbb{Z}_3$-NMSSM superpotential Eq.~(\\ref{eq:WZ3C}) contains no \nexplicit mass parameter, thereby allowing a solution to the $\\mu$-problem when \nthe singlet field acquires a Vacuum Expectation Value (VEV) and generates an \neffective $\\mu$ term of the right size. As such, it is sometimes referred to as \nthe scale invariant NMSSM in the literature.  In this paper, we will always \nwrite $\\mathbb{Z}_3$-NMSSM for the $\\mathbb{Z}_3$ conserving case \nEq.~(\\ref{eq:WZ3C}) and $\\Zv$-NMSSM for the general $\\mathbb{Z}_3$ violating one \nEq.~(\\ref{eq:WZ3V}). \n\nFor parameters common to both the MSSM and either the $\\mathbb{Z}_3$-NMSSM or \n$\\Zv$-NMSSM, a comparison of the \\SOFTSUSY~conventions and the literature can be \nfound in Table 1 of the MSSM \\SOFTSUSY~manual \\cite{Allanach:2001kg}.  Elsewhere, \nour conventions are those of the SUSY Les Houches Accord~\\cite{Allanach:2008qq} \nand thus consistent with the review of Ellwanger, Hugonie and Teixeira (EHT) \n \\cite{Ellwanger:2009dp} and also Ref.~\\cite{Degrassi:2009yq}. (Note however that \nour definitions of the neutral Higgs VEVs (section~\\ref{sec:hpot}) differ by a \nfactor of $\\sqrt{2}$ compared to Refs.~\\cite{Ellwanger:2009dp,Degrassi:2009yq}.)\n\n\\subsection{Next-to-minimal SUSY breaking parameters \\label{sec:susybreak}}\nThe soft breaking scalar potential is given by\n\n\\be \nV_{\\textrm{soft}} = V_3 + V_2\\big|^{}_{m_3^2=0} + m_S^2|S|^2 \n+ \\epsilon_{ab} \\lambda A_\\lambda S H^a_2 H^b_1 \n+ \\frac{\\kappa A_\\kappa}{3} S^3 + V_{\\Zv} \\,,\n\\ee \n%\nwhere all $\\Zv$~terms are included in\n\\be \nV_{\\Zv} =  \\xi_S S + \\frac{m_S^{\\prime \\, 2}}{2} S^2\n  + \\epsilon_{ab} m_3^2 H_2^a H_1^b + \\textrm{h.c.} \\,.\n\\label{eq:VZ3V}\n\\ee\n% \nExpressions for the trilinear scalar interaction potential $V_3$ and scalar \nbilinear SUSY breaking potential $V_2$  of the MSSM are given in Sect.\\ 2.2 of \nthe \\SOFTSUSY~manual \\cite{Allanach:2001kg} for the $R$-parity conserving MSSM.\n The notation $V_2\\big|_{m_3^2=0}$ indicates that the $\\Zv$~soft bilinear mass \n$m_3^2$ present in $V_2$ is set to zero to avoid double counting with the third term in Eq.~(\\ref{eq:VZ3V}).\n\n\\subsection{Higgs potential and electroweak symmetry breaking}\\label{sec:hpot}\nAt tree-level, the Higgs potential is given by\n%\n\\begin{align}\nV_\\mathrm{Higgs} &=  V^H_F + V^H_D + V_{\\rm soft}^H  \\\\\n&=  V^{\\mu=0}_\\mathrm{MSSM} + V^{HN}_{F} + V_{\\rm soft}^{HN}\\,,\n%\n\\end{align} \nwhere \n\\begin{align}\nV^{HN}_{F} &=   |\\lambda S + \\mu|^2 (|H_2|^2+|H_1|^2) + |\\lambda H_2H_1\n+\\kappa S^2 + \\mu^\\prime S + \\xi_S|^2  \\,, \\label{eq:HpotF} \\\\\n V_{\\rm soft}^{HN}  &=   m_S^2|S|^2\n+ \\Bigg(\\lambda A_{\\lambda}SH_2H_1+\\frac{\\kappa}{3} A_{\\kappa}S^3+ \\ds\\frac{m_S^{\\prime \\, 2}}{2} S^2 + \\xi_S S + \\textrm{h.c.} \\Bigg)\\,.\n\\label{eq:HpotS} \n\\end{align}\n\n\\noindent The three neutral Higgs fields then pick up VEVs\n%  \n\\be \n        \\langle H_1^0 \\rangle = \\ds\\frac{1}{\\sqrt{2}}{v_1 \\choose 0}\\,, \n\\qquad  \\langle H_2^0 \\rangle = \\ds\\frac{1}{\\sqrt{2}}{0 \\choose v_2}\\,, \n\\qquad  \\langle S \\rangle =  \\ds\\frac{1}{\\sqrt{2}}s\\,, \n\\label{eq:potmin} \n\\ee\n%  \n\\noindent which are related to the soft masses via the minimization conditions\n%\n\\begin{align}\nm_{H_1}^2&= -\\frac{M_Z^2}{2}\\cos(2\\beta) - \\ds\\frac{\\lamsq}{2} v_2^2\n + (m_3^2)_\\textrm{eff} \\tan\\beta \n- |\\mu_\\textrm{eff}|^2\\,, \\label{eq:mind}\\\\\nm_{H_2}^2&= \\frac{M_Z^2}{2}\\cos(2\\beta) - \\ds\\frac{\\lamsq}{2}v_1^2 \n+  \\frac{(m_3^2)_\\textrm{eff}}{\\tan\\beta} \n- |\\mu_\\textrm{eff}|^2 \\,, \\label{eq:minu} \\\\\nm_S^2 &= -\\kappa^2 s^2 - \\ds\\frac{\\lamsq}{2} \nv^2 + \\kappa\\lambda v_2v_1\n+ \\lambda A_{\\lambda} \\frac{v_2v_1}{\\sqrt{2}s}\n-\\kappa A_{\\kappa}s  - m^{\\prime \\,2}_S - \\mu^{\\prime \\,2} + 2 \\kappa \\xi_F  - 3 \\kappa s \\mu^\\prime \\,,\n\\label{eq:mins}\n\\end{align}\nwhere $M_Z^2 = \\tfrac{1}{4}\\bar{g}^2(v_1^2+v_2^2)$ and $\\overline{g} = (g_2^2+g^{\\prime 2})^{1/2}$ \nfor gauge couplings $g_2$ and $g^{\\prime}=\\sqrt{3/5}g_1$ of $SU(2)_L$ and (unnormalised) \n$U(1)$ interactions respectively.\n%\nWe have $\\tan \\beta = v_2 /  v_1$ and for simplicity we have introduced\n\\be (m_3^2)_\\textrm{eff} \\equiv\n \\ds\\frac{ \\lambda s}{\\sqrt{2}} B_\\textrm{eff} + \\widehat{m}_3^2\\,, \\ee and\n\\be  \\mu_\\textrm{eff} \\equiv\n \\mu + \\frac{\\lambda s}{\\sqrt{2}}\\,, \\;\\;\\;\\; B_\\textrm{eff}\\equiv A_\\lambda+\\ds\\frac{\\kappa s}{\\sqrt{2}}\\,, \\;\\;\\;\\; \\widehat{m}_3^2 \\equiv m_3^2 + \\lambda \\Bigg(\\ds\\frac{\\mu^\\prime s}{\\sqrt{2}} + \\xi_F\\Bigg)\\,. \\ee\n\n\n \n\n\\subsection{Tree-level masses \\label{sec:tree}}\nThe chargino and sfermion masses are obtained by substituting \n$\\mu\\to\\mu_\\textrm{eff}$ into the MSSM expressions. The neutralino mass matrix \nis contained in the Lagrangian term  \n$-\\frac{1}{2}{\\tilde\\psi^0}{}^T{\\cal M}_{\\tilde\\psi^0}\\tilde\\psi^0$ + h.c., where \n$\\tilde\\psi^0 =$ $(-i\\tilde b,$ \n$-i\\tilde w^3,$ $\\tilde h_1,$ $\\tilde h_2, \\tilde{s})^T$ and\n%\n\\begin{equation}\n{\\cal M}_{\\tilde\\psi^0} \\ =\\ \\left(\\begin{array}{ccccc} \nM_1 & 0 &-M_Zc_\\beta s_W & M_Zs_\\beta s_W & 0 \\\\\n 0 & M_2 & M_Zc_\\beta c_W & -M_Zs_\\beta c_W & 0 \\\\ \n-M_Zc_\\beta s_W & M_Zc_\\beta c_W & 0 & -\\mu & -\\lambda v_2 \\\\\nM_Zs_\\beta s_W & -M_Zs_\\beta c_W & -\\mu & 0 & - \\lambda v_1 \\\\\n0 & 0 & 0 & 0 & 2 \\kappa s + \\mu^\\prime\n\\end{array} \\right)\\,. \\label{mchi0}\n\\end{equation} \nWe use $s$ and $c$ for sine and cosine, so that\n$s_\\beta\\equiv\\sin\\beta,\\ c_{\\beta}\\equiv\\cos\\beta$ and $s_W (c_W)$ is\nthe sine (cosine) of the weak mixing angle.  \nThe 5 by 5 neutralino mixing matrix is an orthogonal matrix $O$ with real \nentries, such that $O^T {\\cal M}_{\\tilde\\psi^0} O$ is diagonal. The neutralinos \n$\\chi^0_i$ are defined such that their absolute masses increase with increasing \n$i$. Note that some of their mass values can be negative. \n\nThe CP-even gauge eigenstates $(H^0)^T = (H_1^0,\\, H_2^0, \\, S)$ are rotated into\n mass eigenstates $(h^0)^T = (h_1, h_2, h_3)$ by a mixing matrix $R$,\n%\n\\be \nh^0 = R H^0\\,. \n\\ee \n%\nThe mass matrix $M^2_{H^0}$ is obtained by expanding $H_{1,2}$ and $S$ about their \nVEVs (\\ref{eq:potmin}) and identifying terms $-(H^0)^T M^2_{H^0} H^0$ in the Lagrangian.  \nTypically, the resulting matrix elements $(M_{H^0}^2)_{ij}$ are simplified by using the \ntree-level electroweak symmetry breaking (EWSB) conditions (\\ref{eq:mind}-\\ref{eq:mins}) \nin order to eliminate the soft terms $m_{H_1}^2$, $m_{H_2}^2$ and $m_S^2$.  This is \nequivalent to defining  \n%\n\\be\n(M_{H^0}^2)_{ij} \\equiv  \\ds\\frac{\\partial^2 V}{\\partial v_i \\partial v_j} \n- \\ds\\frac{\\delta_{ij}}{v_i}\\ds\\frac{\\partial V}{\\partial v_i} \\qquad \\mbox{with } v_3\\equiv s\\,,\n\\ee\n%\nand under this prescription we find    \n%\n\\ba\n (M_{H^0}^2)_{11} & = & M_Z^2 c_\\beta^2 \n + \\Bigg(\\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n \\widehat{m}_3^2\\Bigg)\\,\\tan\\beta\\,,\\\\\n (M_{H^0}^2)_{12} & = & (4\\lambda^2 - \\overline{g}^2) \\ds\\frac{v_2 v_1 }{4}- \n \\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} - \\widehat{m}_3^2\\,, \\\\ \n (M_{H^0}^2)_{13} & = & \\lambda \\Bigg[2 \\mu_\\textrm{eff}\\,\\ds\\frac{ v_1}{\\sqrt{2}} -\n (B_\\textrm{eff} + \\kappa s + \\mu')\\ds\\frac{ v_2}{\\sqrt{2}}\\Bigg]\\,,\\\\\n (M_{H^0}^2)_{22} & = & M_Z^2 s_\\beta^2 + \\Bigg(\\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n\\widehat{m}_3^2\\Bigg)/\\tan\\beta\\, \\\\\n (M_{H^0}^2)_{23} & = & \\lambda \\Bigg[2 \\mu_\\textrm{eff}\\, \\ds\\frac{ v_2}{\\sqrt{2}} -\n(B_\\textrm{eff} + \\frac{\\kappa s}{\\sqrt{2}} + \\mu')\\ds\\frac{ v_1}{\\sqrt{2}}\\Bigg]\\,, \\\\\n (M_{H^0}^2)_{33} & = & \\ds\\frac{\\lambda}{\\sqrt{2}} (A_\\lambda + \\mu') \\frac{v_2 v_1}{s}\n+ \\frac{\\kappa s}{\\sqrt{2}} (A_\\kappa + 4\\frac{\\kappa s}{\\sqrt{2}}+ 3 \\mu') - \\sqrt{2}(\\xi_S + \\xi_F \\mu')/s\\,.\n\\label{eq:MH0}\n\\ea\n\nThe three imaginary components of the neutral Higgs fields \n$(H^I)^T = (H^I_1, H_2^I, S^I)$ mix to give the two physical CP odd bosons \n$A_{1,2}$ and the Goldstone boson $G^0$.  A mixing matrix $P$ relates the two \nbases\n%\n\\be \na = P H^I\\,, \n\\ee\n%\nwhere $a^T = (G^0,A_1,A_2)$.  Here, $P$ matches the conventions of \n\\cite{Degrassi:2009yq}, while deleting the first row from $P$ produces the 2 by\n 3 mixing matrix for the physical CP-odd Higgs bosons in SLHA2 conventions \\cite{Allanach:2008qq}. Following EHT \\cite{Ellwanger:2009dp}, the entries of the \n3 by 3 mass matrix $ M^{\\prime \\, 2}_{P}$ in the $H^I$ basis read\n%\n\\ba\n( M^{\\prime \\, 2}_{P})_{11} & = & \\Bigg(\\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n\\widehat{m}_3^2\\Bigg)\\,\\tan\\beta , \\\\\n( M^{\\prime \\, 2}_{P})_{12} & = & \\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n\\widehat{m}_3^2, \\\\\n( M^{\\prime \\, 2}_{P})_{13} & = & \\lambda v_u (A_\\lambda - 2\\kappa s - \\mu'), \\\\\n( M^{\\prime \\, 2}_{P})_{22} & = & \\Bigg(\\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n\\widehat{m}_3^2\\Bigg)/\\tan\\beta ,  \\\\\n( M^{\\prime \\, 2}_{P})_{23} & = & \\lambda v_d (A_\\lambda - 2\\kappa s - \\mu')\\\\\n( M^{\\prime \\, 2}_{P})_{33} & = & \\lambda (B_\\textrm{eff}+3\\kappa s +\\mu')\\ds\\frac{v_u\nv_d}{s} -3\\kappa A_\\kappa s  -2 m_{S}'^2 -\\kappa \\mu' s \n-\\xi_F\\left(4\\kappa + \\frac{\\mu'}{s}\\right) -\\ds\\frac{\\xi_S}{s}.\n\\label{eq:MA0}\n\\ea\n%\nwhere tree-level EWSB has been imposed.\n\nNote that --- as in the MSSM --- the mixing of the Goldstone boson $G^0$ depends\n only on $\\tan\\beta$. As shown in EHT \\cite{Ellwanger:2009dp}, this can be seen \nby first performing a rotation by $\\beta$, which converts $M^{\\prime\\, 2}_P$ to be \nblock diagonal.  The resulting 2 by 2 submatrix may then be diagonalised. \nTherefore the CP-odd mixing can be stored as a single mixing angle.%\n  \\footnote{\\SOFTSUSY~does this internally by storing $\\theta_{A^0}$ in the \n    {\\tt sPhysical} object (see Eq.~(\\ref{nmssmsoftsusy})).  Note that the\n    SLHA output \n    gives the 3 by 2 mixing matrix and thus matches SLHA2 conventions.}\n\nFinally, the charged Higgs fields in the mass basis contain one massless \ncharged Goldstone boson $G^{\\pm}$ and a charged Higgs, $H^\\pm$ with mass\n%\n\\be \nm_{H^\\pm}^2 = \\left(\\ds\\frac{\\lambda s}{\\sqrt{2}} B_\\textrm{eff} +\n\\widehat{m}_3^2\\right)(\\tan \\beta + \\cot \\beta) + M_W^2 - \\ds\\frac{\\lambda^2 v^2}{2}\\,. \n%\n\\ee\n  \n\\section{Calculation Algorithm \\label{sec:calculation}}\nWe now describe the algorithm used to perform the calculation.  The full \niterative algorithm to determine the mass spectrum is shown schematically in \nFig.~\\ref{fig:algorithm}.  Here we will provide a detailed description of this \nprocedure and specify all contributions that are included in the calculation.\n\nAs in MSSM \\SOFTSUSY, the SM fermion and gauge boson masses, and the\n couplings $\\alpha(M_Z)$, $G_F^\\mu$, and $\\alpha_s(M_z)$ act as low energy \nconstraints. Below $M_Z$, the evolution of these input parameters proceeds in \nthe manner described in Sect.\\ 3.1 of the MSSM \\SOFTSUSY~manual \n\\cite{Allanach:2001kg}.  Similarly, the initial guess for the SUSY preserving \n$\\overline{DR}$ parameters at $m_t$ follows the procedure outlined in Sect.\\ 3.2\nof \\cite{Allanach:2001kg}, with the additional NMSSM parameters \n$\\{\\lambda, \\kappa, s, \\xi_F, \\mu^\\prime \\}$ either initially set to their \n(user specified) input values, or to zero in the case when $\\kappa$ and $s$ are \ntreated as outputs from the EWSB conditions (section~\\ref{ewsb}).\n\n\\begin{figure}\n\\begin{center}\n\\begin{picture}(323,245)\n\\put(10,0){\\makebox(280,10)[c]{\\fbox{7.\\ Calculate Higgs and\n      sparticle pole masses at $M_{SUSY}$. Run to $M_Z$.}}}\n\\put(10,40){\\makebox(280,10)[c]{\\fbox{6.\\ Run to $M_Z$.}}}\n\\put(150,76.5){\\vector(0,-1){23}}\n\\put(10,80){\\makebox(280,10)[c]{\\fbox{5.\\ Run to $M_X$. Apply soft breaking\nand NMSSM SUSY boundary conditions.}}}\n\\put(150,116.5){\\vector(0,-1){23}}\n\\put(10,120){\\makebox(280,10)[c]{\\fbox{4.\\ EWSB with iterative solution for $\\mu_\\textrm{eff}$, outputs $\\{s,\\kappa,m_S\\}$ in $\\mathbb{Z}_3$-NMSSM and $\\{\\mu, m_3^2, \\xi_S \\}$ in $\\Zv$-NMSSM.}}}\n\\put(150,156){\\vector(0,-1){23}}\n\\put(10,160){\\makebox(280,10)[c]{\\fbox{3.\\ Run to $M_{SUSY}$.}}}\n\\put(30,170){convergence}\n\\DashLine(110,165)(-70,165){5}\n\\DashLine(-70,165)(-70,5){5}\n\\DashLine(-70,5)(10,5){5}\n\\put(10,5){\\vector(1,0){2}}\n\\put(150,197){\\vector(0,-1){24}}\n\\put(150,239){\\vector(0,-1){26}}\n\\put(60,245){\\fbox{1.\\ SUSY radiative corrections to\n$g_i(M_Z)$.}}\n\\put(10,200){\\makebox(280,10)[c]{\\fbox{2.SUSY radiative corrections to\n$h_{t,b,\\tau}(M_Z)$.}}} \n\\put(182,45){\\line(1,0){190}}\n\\put(371,45){\\line(0,1){200}}\n\\put(371,245){\\vector(-1,0){143}}\n\\end{picture}\n\\end{center}\n\\caption{Iterative algorithm used to calculate the NMSSM spectrum. \nThe initial step is the\nuppermost one. $M_{SUSY}$ is the scale at which the EWSB\nconditions \nare imposed, as discussed in the text. $M_X$ is the scale at which the high\nenergy SUSY breaking boundary conditions are imposed. Although Higgs and\nsparticle masses are calculated at $M_{SUSY}$, the empirical values of \nelectroweak boson and quark/lepton masses are imposed at $M_Z$. It is the\n\\SOFTSUSY~convention to evolve $\\overbar{DR}$ couplings to $M_Z$ as the final step,\nalthough in the SLHA2 output~\\cite{Allanach:2008qq}, various couplings at\n$M_{SUSY}$ are output. \n\\label{fig:algorithm}}\n\\end{figure}\n\n\n\\subsection{Running of NMSSM couplings~\\label{running}}\nFollowing the initial guess at $m_t$, the two-loop $\\beta$ functions of the \n$\\Zv$-NMSSM are used to evolve the SUSY preserving parameters to a user \nspecified scale $M_X$. If gauge unification has been specified as a boundary \ncondition, $M_X$ is revised to leading-log order to provide a more accurate \nvalue upon the next iteration:\n%\n\\begin{equation}\nM_X^{\\textrm{new}} = M_X \\exp \n\\left({\\frac{g_2(M_X) - g_1(M_X)}{g_1'(M_X) - g_2'(M_X)}}\\right)\\,,\n\\label{mguteq}\n\\end{equation}\n%\nwhere primes denote derivatives calculated to two-loop order.   \n\nIn all stages of the calculation, the evolution of the NMSSM parameters is \ngoverned by three family, two-loop renormalization group equations (RGEs), whose\n form \\cite{MV94,Yam94} for a general, $N=1$ semi-simple SUSY gauge \ntheory is known. From these general results, it is possible to derive the \nexplicit expressions of the RGEs in a chosen model (e.g.\\ the work of Martin and\n Vaughn \\cite{MV94} provides a complete list of the RGEs for the MSSM).  \n\nIn the case of the NMSSM considered here, it is a simple task to generalize the \nMSSM expressions \\cite{MV94} to include contributions due to superpotential \nparameters such as $\\lambda$ and their soft SUSY-breaking counterparts \n$a_\\lambda$.  (Naturally, the RGEs for such parameters must be derived \nseparately.)  The two-loop RGEs for the $§\\Zv$-NMSSM are presented in the review by EHT \\cite{Ellwanger:2009dp}, with  \nthe third family approximation\n%\n\\begin{equation}\nY_U \\approx \\left(\\begin{array}{c c c} \n0 & 0 & 0 \\\\\n0 & 0 & 0 \\\\\n0 & 0 & y_t \n\\end{array}\\right) \\,, \\qquad\n%\nY_D \\approx \\left(\\begin{array}{c c c} \n0 & 0 & 0 \\\\\n0 & 0 & 0 \\\\\n0 & 0 & y_b \n\\end{array}\\right) \\,, \\qquad\n%\nY_E \\approx \\left(\\begin{array}{c c c} \n0 & 0 & 0 \\\\\n0 & 0 & 0 \\\\\n0 & 0 & y_e \n\\end{array}\\right)\\,,\n\\label{eq:3rd fam} \n\\end{equation}\n%\nimposed to simplify the resulting expressions.\nHowever, in \\SOFTSUSY~the whole calculation is performed with quark \nflavor-mixing between all three families, so it is necessary to derive the \nadditional NMSSM contributions from the general RGEs \\cite{MV94,Yam94}.  The \nresulting expressions are collected in section~\\ref{sec:RGEs} and in each case we have \nfound agreement with the results of EHT \\cite{Ellwanger:2009dp} once the third \nfamily approximation Eq.~(\\ref{eq:3rd fam}) is enforced.  Note that in the \n\\SOFTSUSY~conventions, all $\\beta$ functions are real.\nWe also incorporate the two-loop running for $\\tan\\beta$ and the Higgs VEVs  \n$v_{1,2}$ and $s$.  Here, we make use of the results obtained by \nSperling et al.\\ \\cite{Sper13,Sper13-2}, where the pure   NMSSM contributions \nare reproduced in section~\\ref{sec:RGEs}.\nThe program can be made to run faster by switching off the two-loop\n renormalization of the scalar masses and tri-linear scalar couplings.\nOnce the user-supplied boundary conditions are applied at $M_X$, the whole \nensemble of NMSSM soft breaking and SUSY preserving couplings are evolved to \n$M_Z$. The inclusion of radiative corrections to the gauge and Yukawa couplings \n(steps 1 and 2 in Fig.~\\ref{fig:algorithm}), and NMSSM renormalization (step 3)\n is analogous to MSSM \\SOFTSUSY~--- for details we refer the reader to sections\n3.3 and 3.4 of the \\SOFTSUSY~manual \\cite{Allanach:2001kg}.\n\n\\subsection{Low energy boundary conditions and electroweak \nsymmetry breaking \\label{ewsb}} \nThe electroweak symmetry breaking (EWSB) conditions (\\ref{eq:mind}-\\ref{eq:mins}) \nallow one to constrain three model parameters of the theory.  With the central value \nfor the $Z$ pole mass $M_Z$ taken as input, we rewrite Eqs.~(\\ref{eq:mind}) and \n(\\ref{eq:minu}) in terms of $\\mu_\\textrm{eff}^2$ and $(m_3^2)_\\textrm{eff}$, as in \nthe MSSM.  By including tadpole corrections $t_i$ and the transverse self energy $\\Pi^T_{ZZ}$ of the \n$Z$ boson, we find\n%\n\\begin{align}\n  \\mu_\\textrm{eff}^2(M_{SUSY}) &=\n  \\frac{m_{\\overline{H}_1}^2(M_{SUSY}) -\n    m_{\\overline{H}_2}^2(M_{SUSY}) \\tan^2 \\beta(M_{SUSY})}{\\tan^2\n    \\beta(M_{SUSY}) - 1} - \\frac{1}{2} M_{\\overline Z}^2\n  (M_{SUSY})\\label{eq:mueffcond}\\\\ \n%\n  (m^2_3)_\\textrm{eff}(M_{SUSY})&=\\frac{\\sin{2\\beta}(M_{SUSY})}{2}\\Bigg\\{\\overline{m}_{H_u}^2(M_{SUSY})+\\overline{m}_{H_d}^2(M_{SUSY})+\n  2\\mu_\\textrm{eff}^2(M_{SUSY})\\Bigg[1+\\frac{\\overline{M}_z^2}{\\overline{g}^2s^2}(M_{SUSY})\\Bigg]\\Bigg\\}\\,,\n  \\label{eq:bmucond}\n\\end{align} \n% \nwhere \n$m_{\\overline{H}_i}^2 = m_{H_i}^2 - t_i/v_i$, \n$M_{\\overline Z}^2(M_{SUSY}) = M_Z^2 + \\Re\\mathfrak{e}\\Pi_{ZZ}^T(M_{SUSY})$ is the \n$\\overline{DR}$ running (mass)$^2$ of the $Z$ boson.  Through Eqs.~(\\ref{eq:mueffcond}) and (\\ref{eq:bmucond}) we\ncan fix $\\mu_\\textrm{eff}$ and $(m^2_3)_\\textrm{eff}$ in a similar manner\nto the MSSM.  Note however, that in this case these are {\\it effective} \nparameters constructed from several model parameters, so we must select which\nof the latter are fixed.\nIn the $\\mathbb{Z}_3$-NMSSM, we fix $s$ via Eq.~\\ref{eq:mueffcond} and $\\kappa$\nvia Eq.~\\ref{eq:bmucond}, and use the third EWSB condition to fix\n$m_S^2$.  In the $\\Zv$-NMSSM, we have more freedom and can choose to fix\n$\\mu$ and $m_3^2$ --- as in the MSSM --- and use the third EWSB\ncondition to fix $\\xi_S$.\nAlternatively, the EWSB conditions can be used to fix the soft Higgs\nmasses $m_{H_1}^2$, $m_{H_2}^2$ and $m_S^2$, see\n\\ref{sec:run}.\n\nThe full one-loop tadpole corrections\n from \\cite{Degrassi:2009yq} are implemented, along with NMSSM two-loop \n$\\oatas$ and $\\oabas$ contributions \\cite{Degrassi:2009yq} to the tadpoles.%\n\\footnote{We thank Pietro Slavich for kindly supplying us with the {\\tt FORTRAN}\n files.}\n The two loop corrections from the MSSM are used for $\\oatq$, $\\oabatau$, \n$\\oabq$, $\\oatauq$ and $\\oatab$, though it should be noted that these are not\ncomplete in the NMSSM.  In both one-loop and two-loop cases, the tadpole \ncorrections themselves depend on the output from the EWSB conditions, therefore \nan iteration is employed to find a self consistent solution.\nAfter the EWSB iteration converges, the whole set of NMSSM parameters are run to\n $m_Z$. As detailed in Section 3.3 of \\cite{Allanach:2001kg}, the gauge \ncouplings $g_1$, $g_2$ and $g_3$ (where $g_1$ is the GUT normalised gauge \ncoupling of $U(1)_Y$) and third family $\\overline{DR}$ Yukawa couplings, $y_t$, \n$y_b$ and $y_\\tau$ are fixed, including the precision corrections at $M_Z$.  Note\n however, that the expressions for the one-loop self energies of the gauge \nbosons and fermions are modified to match those given in \\cite{Degrassi:2009yq}\n for the NMSSM.\n\n\\SOFTSUSY~calculates corrections to $\\sin \\theta_W$ following the procedure outlined \nin \\cite{Pierce:1997zz}.  We use the same procedure in the NMSSM, with expressions \nfor the MSSM self energies \\cite{Pierce:1997zz} generalised to include NMSSM contributions \n\\cite{Degrassi:2009yq}.  In the Higgs sector, we only consider contributions from the \nlightest NMSSM Higgs, since contributions from heavy Higgs states are negligible \n\\cite{Pierce:1997zz}.  This is achieved by taking the Higgs state whose mass and coupling \nproduces the contributions listed in \\cite{Pierce:1997zz} once the MSSM limit is taken.  \nNote that this ensures a simple MSSM limit for threshold corrections. \n\nIn the $\\Zv$-NMSSM, the parameters $\\kappa$, $s$, $\\xi_F$ and $\\mu^\\prime$ are \nreset to their input values at $M_Z$.  The parameters are then evolved back to \n$M_{\\rm SUSY}$ where $M_Z^2$ and $\\tan\\beta$ are predicted as part of a consistency \ncheck.  If the user has specified that any of the parameters $\\lambda$, $\\kappa$, $s$, \n$\\xi_F$ and $\\mu'$  are to be input at the SUSY scale rather than the default option of \ninputting them at the GUT scale\\footnote{See \\ref{sec:run} for details on how to do this.} \nthen they are set here.  \n\nIn general, the scalar Higgs potential (in both the $\\mathbb{Z}_3$- and \n$\\Zv$-NMSSM) can possess several local minima \\cite{Ellwanger:2009dp}, so we \ninclude a test at $M_{\\rm SUSY}$ to determine whether the chosen parameter space \npoint corresponds to a global minimum (as done in the {\\tt NMSPEC}~\\cite{Ellwanger:2006rn} \nCHECKMIN routine).  The test works by comparing the value of the physical potential at \nthe VEVs $v_u,v_d,s$ against scenarios where two or more VEVs are zero.  We \ninclude one-loop radiative corrections to the effective potential from third \ngeneration quarks and squarks; corrections from other sfermions are negligible \ndue to their small Yukawa couplings. The parameters are then evolved back up to $M_X$ and \nthe procedure is repeated until convergence is achieved, as shown in Fig.~\\ref{fig:algorithm}. \n(If the iteration does not converge to the desired accuracy, \\SOFTSUSY~outputs a \n{\\tt No convergence} warning message --- see also Appendix C in \\cite{Allanach:2001kg}.)\n\n\\subsection{NMSSM spectrum \\label{spec}}\nAfter the iteration has converged we calculate the pole masses.  The\nHiggs pole masses are calculated using one-loop self energies from Degrassi and \nSlavich \\cite{Degrassi:2009yq}, with additional $\\Zv$~contributions to the \ntriple Higgs couplings included (see Appendix A of EHT \\cite{Ellwanger:2009dp}).\nTwo-loop corrections \\cite{Degrassi:2009yq} of $\\oatas$ and $\\oabas$ are \nincorporated via {\\tt FORTRAN} files provided by Pietro Slavich.  Contributions \nof order $\\oatq$, $\\oabatau$, $\\oabq$, $\\oatauq$ and $\\oatab$ are included from \nthe MSSM {\\tt FORTRAN} files (also supplied by Pietro Slavich), but we note that\n these expressions receive additional NMSSM contributions which are currently \nunavailable.  Consequently, our calculation is not correct to this order, but \nrather to $\\oatas$ and $\\oabas$.  Nevertheless, the higher order MSSM \ncontributions provide (a) a good approximation in the vicinity of the MSSM limit\n, and (b) easier comparisons against MSSM results.\n\nThe sfermions, neutralinos and charginos also receive new NMSSM corrections to \ntheir self energies. To the best of our knowledge, the required expressions are \npresented only in \\cite{Staub:2010ty}. However, we found a number of \ntypographical errors in the published results \\cite{Staub:2010ty}, whose \norigin%\n\\footnote{F.~Staub, private communication.} \nwas due to the need to manually condense the auto-generated \\LaTeX~output from \n{\\tt SARAH} \\cite{Staub:2009bi,Staub:2010jh,Staub:2012pb,Staub:2013tta}.  In \nparticular, the self energy expressions generated by {\\tt SARAH} do not contain \nthese errors. Therefore, we used a combination of results listed in \n\\cite{Staub:2010ty}, auto-generated \\LaTeX~output from {\\tt SARAH} for the self \nenergies, plus individual checks of our own.\nFinally, all one-loop self energies, tadpole corrections, and two-loop RGEs were\n unit tested against code pieces auto-generated from {\\tt FlexibleSUSY} \n\\cite{flexi-susy}, an in development {\\tt MATHEMATICA} package for generating \n{\\tt C++} code which makes use of the aforementioned {\\tt SARAH} package. \n\n\n\\section*{Acknowledgments}\nThis work has been partially supported by STFC \nand by the Australian Research Council through its Centres of Excellence \nprogram. The Albert Einstein Center for Fundamental Physics at the University \nof Bern is supported by the ``Innovations- und Kooperationsprojekt C-13'' of the\n ``Schweizerische Universit\\\"{a}tskonferenz SUK/CRUS''.\n\nWe thank Pietro Slavich for supplying us with the NMSSM {\\tt FORTRAN} files with\ntwo-loop $\\oatas$ and $\\oabas$ contributions to the Higgs masses and also a\n{\\tt FORTRAN} file with one-loop self energies (which we used as a cross check),\n as well as his helpful explanations on how to use them. We thank Florian \nStaub for responding quickly to our questions regarding \\cite{Staub:2010ty}, and\n on questions and bug reports when comparing against {\\tt SARAH} and \n{\\tt FlexibleSUSY}. We also thank Ben Farmer for providing useful feedback after\n using a pre-release verion of the code.  \n\nPA and AV thank Dominik St\\\"ockinger for many helpful comments and discussions \nregarding the precision corrections included here, and also thank both him and \nJae-hyeon Park for listening to a number of discussions about this project in \ngeneral and for offering helpful remarks. PA also thanks Roman Nevzorov for \nuseful discussions.  LCT is supported by the Federal Commission for Scholarships\n for Foreign Students (FCS).  \n\n\\appendix\n\n\\section{Running \\SOFTSUSY}\n\\label{sec:run}\n\n\\SOFTSUSY~produces an executable called \\code{softpoint.x}. For the calculation\nof the spectrum of single points in parameter space, we recommend the\nSUSY Les Houches Accord 2 (SLHA2)~\\cite{Allanach:2008qq}  input/output\noption. The user must provide a file (e.g.\\ the example file included\nin the \\SOFTSUSY~distribution\n\\code{rpvHouchesInput}), that specifies the model dependent input\nparameters. The program may then be run with\n\\small\n\\begin{verbatim}\n ./softpoint.x leshouches < nmssmHouchesInput\n\\end{verbatim}\n\\normalsize\n\nNMSSM-\\SOFTSUSY\\ accepts input files compliant with the SLHA2 format given in Ref.~\\cite{Allanach:2008qq} and supports the setting of all SLHA2\ninput blocks associated with non-complex couplings.  The set of input\nparameters which also exist in the MSSM are entered as described in\n\\cite{Skands:2003cj}, just as for the MSSM version of \\SOFTSUSY, while\nthe new NMSSM parameters are all given in the \\code{EXTPAR} block as\noutlined in \\cite{Allanach:2008qq}.  For example one can specify:\n%\n\\begin{verbatim}\nBlock EXTPAR\n   23   0                    # mu\n   24   0                    # Bmu / (cos(beta) * sin(beta))\n   61   0.1                  # lambda(MX)\n   62   0.1                  # kappa(MX)\n   63   1000                 # A_lambda(MX)\n   64   1000                 # A_kappa(MX)\n   65   100                  # (lambda * <S>)(MX)\n   66   100                  # xi_F(MX)\n   67   0                    # xi_S(MX)\n   68   0                    # mu'(MX)\n   69   0                    # m'_S^2(MX)\n   70   1000                 # m_S^2(MX)\n\\end{verbatim}\n%\nBy default all parameters are input at $M_X$ (defined in entry 0 in\nblock EXTPAR).  In case the parameters $\\lambda$, $\\kappa$, $\\lambda\ns / \\sqrt{2}$, $\\xi_F$ and $\\mu'$ should be input at $M_{SUSY}$ a corresponding\n$-1$ entry in the block \\code{QEXTPAR} has to be given:\n%\n\\begin{verbatim}\nBlock QEXTPAR\n   61   -1                   # input lambda at Msusy\n   62   -1                   # input kappa at Msusy\n   65   -1                   # input lambda * <S> at Msusy\n   66   -1                   # input xi_F at Msusy\n   68   -1                   # input mu' at Msusy\n\\end{verbatim}\n%\nParameters that are output of the EWSB conditions cannot be given in\nthe \\code{EXTPAR} block.  For the $\\mathbb{Z}_3$-NMSSM these are $s$,\n$\\kappa$ and $m_S^2$.  In the $\\Zv$-NMSSM these are $\\mu$, $m_3^2$ and\n$\\xi_S$.\n\nInstead of choosing the above parameter sets as EWSB output, it is also\npossible to let the EWSB conditions determine $m_{H_1}^2$, $m_{H_2}^2$\nand $m_S^2$.  This behaviour can be enabled by setting entry $18$ in\nblock \\SOFTSUSY\\ to $1$:\n%\n\\begin{verbatim}\nBlock SOFTSUSY\n   18   1                    # use soft Higgs masses as EWSB output\n\\end{verbatim}\n\nFor the SLHA2 input option, \nthe output will also be given in \nSLHA2 format. Such output can be used for\ninput into other programs which subscribe to the accord, such as\n\\code{PYTHIA}~\\cite{Sjostrand:2007gs} (for\nsimulating sparticle production and decays at colliders), for example. For\nfurther details on the format of \nthe input and output file, see Refs.~\\cite{Allanach:2008qq} and \\cite{Skands:2003cj}.\n\nAn alternative input option for \\SOFTSUSY\\ is to input the parameters via the command-line interface. As of {\\tt SOFTSUSY 3.4}, the command line interface of \\code{softpoint.x} has\nchanged, see \\code{softpoint.x --help}.  For the NMSSM, the syntax is\n%\n\\small\n\\begin{verbatim}\n ./softpoint.x nmssm <susy-breaking-model> [NMSSM flags] [NMSSM parameters] [general options]\n\\end{verbatim}\n\\normalsize\n%\nwhere \\code{sugra} is the only currently available susy-breaking\nmodel.  The general options are listed in Ref.~\\cite{Allanach:2001kg}\n%\\tablename~\\ref{tab:general-cmd-line-options} \nand the NMSSM flags and\nparameter options are listed in\n\\tablename~\\ref{tab:nmssm-cmd-line-options}.\n%\n\\begin{table}[tbh]\n  \\centering\n  \\begin{tabular}{ll}\n    NMSSM flags & description \\\\\n    \\hline\n    \\code{--lambdaAtMsusy} & input $\\lambda$ at scale $M_{SUSY}$ \\\\\n    \\hline\\\\\n    NMSSM parameters & description \\\\\n    \\hline\n    \\code{--m0=<value>} & unified soft scalar mass \\\\\n    \\code{--m12=<value>} & unified soft gaugino mass \\\\\n    \\code{--a0=<value>} & unified trilinear coupling \\\\\n    \\code{--tanBeta=<value>} & $\\tan\\beta$ \\\\\n    \\code{--mHd2=<value>} & soft down-type Higgs mass squared $m_{H_1}^2$ \\\\\n    \\code{--mHu2=<value>} & soft up-type Higgs mass squared $m_{H_2}^2$ \\\\\n    \\code{--mu=<value>} & $\\mu$ parameter \\\\\n    \\code{--BmuOverCosBetaSinBeta=<value>} & $B\\mu/(\\cos\\beta \\sin\\beta)$ \\\\\n    \\code{--lambda=<value>} & trilinear superpotential coupling $\\lambda$ \\\\\n    \\code{--kappa=<value>} & trilinear superpotential coupling $\\kappa$ \\\\\n    \\code{--Alambda=<value>} & trilinear soft coupling $A_\\lambda$ \\\\\n    \\code{--Akappa=<value>} & trilinear soft coupling $A_\\kappa$ \\\\\n    \\code{--lambdaS=<value>} & $\\lambda \\langle S \\rangle = \\lambda s / \\sqrt{2}$ \\\\\n    \\code{--xiF=<value>} & linear superpotential coupling $\\xi_F$ \\\\\n    \\code{--xiS=<value>} & linear soft coupling $\\xi_S$ \\\\\n    \\code{--muPrime=<value>} & bilinear superpotential coupling $\\mu'$ \\\\\n    \\code{--mPrimeS2=<value>} & bilinear soft coupling $m_{S}'^2$ \\\\\n    \\code{--mS2=<value>} & bilinear soft mass $m_{S}^2$ \\\\\n    \\hline\n  \\end{tabular}\n  \\caption{NMSSM command line options for \\code{softpoint.x}}\n  \\label{tab:nmssm-cmd-line-options}\n\\end{table}\n\n\\section{Calculating decays with \\NMSSMTools\\label{sec:decays}}\n\n\\SOFTSUSY\\ has a compatibility mode which interfaces with \\NMSSMTools\\\nto calculate sparticle decays in the NMSSM.  To enable it, the\nuser has to first install \\NMSSMTools\\ and then run the\n\\code{setup\\_nmssmtools.sh} script\n%\n\\begin{verbatim}\n  $ cd /path/to/NMSSMTools/\n  $ wget http://www.th.u-psud.fr/NMHDECAY/NMSSMTools_4.1.2.tgz\n  $ tar xf NMSSMTools_4.1.2.tgz\n  $ cd /path/to/softsusy/\n  $ ./setup_nmssmtools.sh \\\n       --nmssmtools-dir=/path/to/NMSSMTools/NMSSMTools_4.1.2 \\\n       --compile\n\\end{verbatim}\n%\nThe \\code{setup\\_nmssmtools.sh} script copies \\code{nmProcessSpec.f}\nand \\code{Makefile.nmssmtools} from the \\SOFTSUSY\\ directory to the\n{\\tt main/} directory within the \\NMSSMTools\\ folder.  If the \\code{--compile}\nflag is provided, \\NMSSMTools\\ is recompiled.  Afterwards the user can\ngenerate a NMSSM spectrum with \\SOFTSUSY\\ and use \\NMSSMTools\\ to\ncalculate the decays.  The \\code{softsusy\\_nmssmtools.x} script combines\nthese two steps:\n%\n\\begin{verbatim}\n  $ ./softsusy_nmssmtools.x leshouches < slhaInput > slhaOutput\n\\end{verbatim}\n%\nHere \\code{slhaInput} is an SLHA input file with the SOFTSUSY block\nentry $15$ set to $1$.  Additional \\NMSSMTools\\ specific flags can also\nbe used with entries $16$ and $17$, which are past to \\NMSSMTools\\ as\nMODSEL blocks $9$ and $10$ respectively, following the \\NMSSMTools\\\nconvention.\n%\n\\begin{verbatim}\n   Block SOFTSUSY\n      15   1      # NMSSMTools compatible output (default: 0) \n      16   4      # Select Micromegas option for NMSSMTools\n                  # (default: 0) 0=no, 1=relic density only\n                  # 2=direct detection + relic density, \n                  # 3=indirect detection + relic density\n                  # 4=all  \n      17   1      # 1:sparticle decays via NMSDECAY (default: 0)\n\\end{verbatim}\n%\nAfter \\code{softsusy\\_nmssmtools.x} is called, the following three output\nfiles can be found in the \\NMSSMTools\\ directory\n\\code{NMSSMTools\\_4.1.2/main/}. The file \\code{nmProcessSpec-decay}\ncontains the sparticle decays in form of SLHA DECAY blocks,\n\\code{nmProcessSpec-omega} will contain the output from \\code{micrOMEGAS} if entry 16 is selected to be non-zero and\n\\code{nmProcessSpec-spectr} contains the spectrum calculated by\n\\NMSSMTools.\n\n\\section{Class Structure\\label{sec:objects}}\n\nWe now go on to sketch the NMSSM class hierarchy.  Only methods and\ndata which are deemed of possible importance for prospective users are\nmentioned here, but there are many others within the program itself.\n\n\n\\subsection{General structure}\n\n\\begin{figure}\n  \\begin{center}\n    \\begin{picture}(200,200)\n      \\GBox(200,200)(0,0){0.9}\n      \\ArrowLine(100,180)(100,150)\n      \\ArrowLine(100,150)(100,110)\n      \\ArrowLine(100,110)(100,60)\n      \\SetPFont{Teletype}{10}\n      \\put(0,0){\\framebox(200,200){}}\n      \\BText(100,180){RGE}\n      \\BText(100,150){MssmSusy}\n      \\B2Text(100,110){SoftPars<MssmSusy>}{= SoftParsMssm}\n      \\B2Text(100,60){Softsusy<SoftParsMssm>}{= MssmSoftsusy}\n    \\end{picture}\\hfill\n    \\begin{picture}(200,200)\n      \\GBox(200,200)(0,0){0.9}\n      \\ArrowLine(100,175)(100,150)\n      \\ArrowLine(100,150)(100,125)\n      \\ArrowLine(100,125)(100,100)\n      \\ArrowLine(100,100)(100,75)\n      \\ArrowLine(100,75)(100,50)\n      \\ArrowLine(100,50)(100,25)\n      \\SetPFont{Teletype}{10}\n      \\put(0,0){\\framebox(200,200){}}\n      \\BText(100,175){RGE}\n      \\BText(100,150){MssmSusy}\n      \\BText(100,125){NmssmSusy}\n      \\BText(100,100){SoftPars<NmssmSusy>}\n      \\BText(100,75){SoftParsNmssm}\n      \\BText(100,50){Softsusy<SoftParsNmssm>}\n      \\BText(100,25){NmssmSoftsusy}\n    \\end{picture}\n    \\caption{\\label{fig:objstruc} Heuristic high-level class\n      structure of \\SOFTSUSY. Inheritance is displayed by the\n      arrows and {\\tt typedef}s are displayed by the equals signs.}\n  \\end{center}\n\\end{figure}\n\nTo implement the NMSSM (and other non-minimal supersymmetric models),\nthe \\SOFTSUSY~class hierarchy was generalized with the following\nrequirements in mind:\n%\n\\begin{itemize}\n\\item The class of supersymmetric parameters (gauge couplings,\n  superpotential parameters and VEVs), whose beta functions are\n  independent of soft-breaking parameters, should be at the top of the\n  class hierarchy.  This makes them usable independently of the\n  soft-breaking parameters, for example during the initial guess.\n\n\\item One should be able to reuse as much MSSM code as possible, for\n  example by inheriting from existing MSSM classes.\n\\end{itemize}\n\nThe above requirements were implemented by the following changes:\n%\n\\begin{enumerate}\n\\item The class of the soft breaking MSSM parameters and their beta\n  functions was converted into the class template \\code{SoftPars<Susy>}.\n  The template parameter represents the class of supersymmetric\n  parameters, from which \\code{SoftPars<Susy>} inherits.  The class\n  which contains \\emph{all} MSSM parameters and beta functions,\n  \\code{SoftParsMssm}, was made a typedef for\n  \\code{SoftPars<MssmSusy>}, where \\code{MssmSusy} is the class that\n  contains the supersymmetric MSSM parameters and beta functions.\n\\begin{verbatim}\ntemplate <class Susy>\nclass SoftPars : public Susy {\n   // implementation of soft breaking MSSM parameters\n   // and their beta functions\n};\n\ntypedef SoftPars<MssmSusy> SoftParsMssm;\n\\end{verbatim}\n  This approach makes it possible to have a class of soft breaking\n  MSSM parameters but with a different set of supersymmetric\n  parameters.  This mechanism is used in the NMSSM, see\n  Section~\\ref{nmssmsoftpars}. \n\n\\item The class which organises the MSSM mass spectrum calculation was\n  converted into the class template \\code{Softsusy<SoftPars>}.  The\n  template parameter represents the class of all model parameters and\n  beta functions, from which \\code{Softsusy<SoftPars>} inherits.\n  \\code{MssmSoftsusy} was made a \\code{typedef} for\n  \\code{Softsusy<SoftParsMssm>}.\n\\begin{verbatim}\ntemplate <class SoftPars>\nclass Softsusy : public SoftPars {\n   // organisation of MSSM mass spectrum calculation\n   // using model parameters in SoftPars\n};\n\ntypedef Softsusy<SoftParsMssm> MssmSoftsusy;\n\\end{verbatim}\n  This approach makes it possible to have a MSSM spectrum calculation\n  class but with an arbitrary set of model parameters.  This mechanism\n  is used in the NMSSM, see~\\ref{nmssmsoftsusy}.\n\\end{enumerate}\n\n\\subsection{\\code{NmssmSusy}~class}\n\\label{nmssmsusy}\n\nThe class of supersymmetric NMSSM parameters and beta functions,\n\\code{NmssmSusy}, inherits from \\code{MssmSusy} to reuse the MSSM\nparameters and beta functions, see \\figurename~\\ref{fig:objstruc}.  It\nadds data members and access methods for the new supersymmetric NMSSM\nparameters, which can be found in \\tablename~\\ref{tab:nmssmsusy}.\n%\n\\begin{table}\n  \\centering\n  \\begin{tabular}{lll}\n    data variable & & methods \\\\\\hline\n    \\code{\\small double lambda, kappa} & trilinear superpotential &\n    \\code{\\small displayLambda}\n    \\\\\n    $\\lambda$, $\\kappa$ & couplings & \\code{\\small displayKappa}\n    \\\\\\hline\n    \\code{\\small double mupr} & bilinear superpotential &\n    \\code{\\small displayMupr}\n    \\\\\n    $\\mu'$ & coupling &\n    \\\\\\hline\n    \\code{\\small double xiF} & linear superpotential &\n    \\code{\\small displayXiF}\n    \\\\\n    $\\xi_F$ & coupling &\n    \\\\\\hline\n    \\code{\\small double sVEV} & VEV of singlet field &\n    \\code{\\small displaySVEV}\n    \\\\\n    $s$ & &\n    \\\\\\hline\n    \\code{\\small double muEff} & effective $\\mu$ term &\n    \\code{\\small displayMuEff}\n    \\\\\n    $\\mu_\\textrm{eff}=\\mu + \\lambda \\langle S \\rangle / \\sqrt{2}$ & coupling &\n    \\\\\\hline\n    \\normalsize\n  \\end{tabular}\n  \\caption{\\code{NmssmSusy} class data and accessor methods\n    \\label{tab:nmssmsusy}}\n\\end{table}\n\n\\subsection{\\code{SoftParsNmssm}~class}\n\\label{nmssmsoftpars}\n\nTo implement the class of soft-breaking NMSSM parameters,\n\\code{SoftParsNmssm}, the \\code{SoftPars<Susy>} template is\ninstantiated using \\code{NmssmSusy} as template parameter.  Thereby\none obtains the class of MSSM soft-breaking beta functions, using\nsupersymmetric NMSSM parameters.  \\code{SoftParsNmssm} then inherits\nfrom \\code{SoftPars<NmssmSusy>} to add extra NMSSM contributions to\nthe soft-breaking beta functions:\n%\n\\begin{verbatim}\nclass NmssmSusy : public MssmSusy {\n   // implement supersymmetric NMSSM parameter beta functions\n   // by reusing MSSM ones\n};\n\nclass SoftParsNmssm : public SoftPars<NmssmSusy> {\n   // implement soft-breaking NMSSM parameter beta functions\n   // by reusing MSSM ones\n};\n\\end{verbatim}\n%\nFurthermore, \\code{SoftParsNmssm} adds new soft-breaking NMSSM data\nmembers and access methods, which are listed in\n\\tablename~\\ref{tab:nmssmsoftpars}.\n%\n\\begin{table}\n  \\centering\n  \\begin{tabular}{lll}\n    data variable & & methods \\\\\\hline\n    \\code{\\small double alambda, akappa} & trilinear soft &\n    \\code{\\small displayTrialambda}\n    \\\\\n    $a_\\lambda$, $a_\\kappa$ & parameters & \\code{\\small displayTriakappa}\n    \\\\\\hline\n    $A_\\lambda$ & $a_\\lambda / \\lambda$ & \\code{\\small displaySoftAlambda}\n    \\\\\n    $A_\\kappa$ & $a_\\kappa / \\kappa$ & \\code{\\small displaySoftAkappa}\n    \\\\\\hline\n    \\code{\\small double mSpsq} & bilinear soft &\n    \\code{\\small displayMspSquared}\n    \\\\\n    $m_{S}'^2$ & parameters &\n    \\\\\\hline\n    \\code{\\small double mSsq} & soft scalar mass &\n    \\code{\\small displayMsSquared}\n    \\\\\n    $m_S^2$ & &\n    \\\\\\hline\n    \\code{\\small double xiS} & linear soft &\n    \\code{\\small displayXiS}\n    \\\\\n    $\\xi_S$ & parameters &\n    \\\\\\hline\n    \\normalsize\n  \\end{tabular}\n  \\caption{\\code{SoftParsNmssm} class data and accessor methods\n    \\label{tab:nmssmsoftpars}}\n\\end{table}\n\n\\subsection{\\code{NmssmSoftsusy}~class}\n\\label{nmssmsoftsusy}\n\nTo create the NMSSM spectrum calculation class, \\code{NmssmSoftsusy},\nthe \\code{Softsusy<SoftPars>} template class is instantiated using\n\\code{SoftParsNmssm} as template parameter.  Thereby one obtains an\nNMSSM spectrum calculator, which uses NMSSM parameters and beta\nfunctions.  \\code{NmssmSoftsusy} then inherits from\n\\code{Softsusy<SoftParsNmssm>} and overwrites MSSM functions to\naccount for the extra NMSSM particles:\n%\n\\begin{verbatim}\nclass NmssmSoftsusy : public Softsusy<SoftParsNmssm> {\n   // organise NMSSM spectrum calculation reusing MSSM functions\n};\n\\end{verbatim}\n%\nTo implement the NMSSM pole masses and mixing matrices, the\n\\code{sPhysical} structure had to be generalized, as in\n\\tablename~\\ref{tab:sphys}.\n%\n\\begin{table}\n  \\centering\n  \\begin{tabular}{ll}\n    data variable & description \\\\ \\hline\n    \\code{DoubleVector mh0,mA0} & vectors of neutral Higgs masses $m_{h^0_{1\\ldots n}}, m_{A^0_{1\\ldots m}}$\\\\\n    & (MSSM: $n=2, m=1$, NMSSM: $n=3, m=2$) \\\\\n    \\code{double mHpm} & charged Higgs mass $m_{H^\\pm}$ \\\\\n    \\code{DoubleVector msnu} & vector of $m_{{\\tilde \\nu}_{i=1 \\ldots 3}}$ masses \\\\\n    \\code{DoubleVector mch,mneut} & vectors of $m_{{\\chi^\\pm}_{i=1 \\ldots 2}}$, \n    $m_{{\\chi^0}_{i=1 \\ldots n}}$ respectively \\\\\n    & (MSSM: $n=4$, NMSSM: $n=5$) \\\\\n    \\code{double mGluino} & gluino mass $m_{\\tilde g}$ \\\\\n    \\code{DoubleMatrix mixNeut} & orthogonal neutralino mixing matrix $O$\\\\\n    & (MSSM: 4 by 4, NMSSM: 5 by 5)\\\\\n    \\code{double thetaL, thetaR} & $\\theta_{L, R}$ chargino mixing angles \\\\\n    \\code{double thetat, thetab} & $\\theta_{t,b}$ sparticle mixing angles \\\\\n    \\code{double thetatau} & $\\theta_{\\tau}$ sparticle mixing angle \\\\\n    \\code{double thetaH} & CP-even Higgs mixing angle $\\alpha$ in the MSSM \\\\\n    \\code{double thetaA0} & CP-odd Higgs mixing angle $\\theta_{A^0}$ in the NMSSM \\\\\n    \\code{DoubleMatrix mixh0} & orthogonal CP-even Higgs mixing matrix $R$ in the NMSSM \\\\\n    \\code{DoubleMatrix mu, md, me} & (2 by 3) matrices of up squark, down squark\n    and\\\\\n    &  charged slepton masses \\\\\n  \\end{tabular}\n  \\caption{\\label{tab:sphys}\\code{sPhysical} structure. Masses are pole\n    masses, and stored in units of GeV. Mixing angles are in radian\n    units.}\n\\end{table}\n\n\\section{Renormalization Group Equations for the NMSSM}\\label{sec:RGEs}\nIn this section, we present the components of the one- and two-loop renormalization group equations (RGEs) which belong exclusively to the NMSSM.  Our expressions have been derived in the $\\overline{\\mbox{DR}}$ scheme from existing results \\cite{MV94,Yam94} for general SUSY gauge theories. The complete RGEs are then obtained by combing the expressions below with those for the MSSM \\cite{MV94}.\n\n\\subsection{Yukawa Couplings}\nFor $t = \\ln Q$, the trilinear superpotential parameter $Y^{ijk}$ evolves \naccording to the general expression \\cite{MV94}\n%\n\\begin{equation}\n\\dt Y^{ijk} = Y^{ijp}\\Gamma_p^k + Y^{kjp}\\Gamma_p^i + Y^{ikp}\\Gamma_p^j\\,,\n\\label{eq:Yuk rges}\n\\end{equation}\n%\nwhere \n%\n\\begin{equation}\n\\Gamma_i^j = \\frac{1}{16\\pi^2}\\gamma_i^{(1)j} \n+ \\frac{1}{(16\\pi^2)^2}\\gamma_{i}^{(2)j}\\,, \n\\end{equation}\n%\nand $\\gamma^{(1,2)j}_i$ are the one- and two-loop anomalous dimensions \nrespectively.  Note that the $3\\times 3$ Yukawa matrices $Y_{U,D,E}$ are \nobtained by identifying indices in Eq.~(\\ref{eq:Yuk rges}) with the relevant chiral superfields in the superpotential.%\n\\footnote{For example, for $k=H_2$ we have $Y^{ijH_2}\\equiv (Y_U)^{ij}$.}  \n\nAt one-loop order, the only addition to the MSSM expressions \n\\cite{MV94} for the $Y_{U,D,E}$ RGEs is the inclusion of $\\lamsq$ terms \nwhich originate from the Higgs anomalous dimensions\n%\n\\begin{align}\n\\left.\\gamma^{(1) H_1}_{H_1}\\right|_\\lambda = \\lamsq \n\\quad \\mbox{and} \\quad \\left.\\gamma^{(1) H_2}_{H_2} \\right|_\\lambda = \\lamsq\\,.\n\\end{align}\n%\nAt two-loop order, all the gauge-Yukawa contributions from $\\lambda$ cancel for \neach $\\gamma_i^{(2)j}$, so the additional contributions arising in the NMSSM are \nsimply given by\n%\n\\begin{align}\n\\left.\\gamma_{L_i}^{(2)L_j}\\right|_\\lambda &= -\\lamsq (Y_E Y_E^\\dagger)_i^j\\,, \\\\\n%\n\\left.\\gamma_{E_i}^{(2)E_j}\\right|_\\lambda &= -2\\lamsq (Y_E^\\dagger Y_E)_i^j\\,, \\\\\n%\n\\left.\\gamma_{Q_i}^{(2)Q_j}\\right|_\\lambda &= -\\lamsq (Y_U Y_U^\\dagger)_i^j \n- \\lamsq (Y_D Y_D^\\dagger)_i^j\\,, \\\\\n%\n\\left.\\gamma_{D_i}^{(2)D_j}\\right|_\\lambda &= -2\\lamsq (Y_D^\\dagger Y_D)_i^j\\,, \\\\\n%\n\\left.\\gamma_{U_i}^{(2)U_j}\\right|_\\lambda &= -2\\lamsq (Y_U^\\dagger Y_U)_i^j \\,, \\\\\n%\n\\left.\\gamma_{H_1}^{(2)H_1}\\right|_\\lambda &= -3\\lambda^4 -2\\lamsq\\kapsq \n- 3\\lamsq \\tr(Y_U Y_U^\\dagger)\\,, \\\\\n%\n\\left.\\gamma_{H_2}^{(2)H_2}\\right|_\\lambda &= -3\\lambda^4 -2\\lamsq\\kapsq \n- 3\\lamsq \\tr(Y_D Y_D^\\dagger) - \\lamsq \\tr(Y_E Y_E^\\dagger)\\,.\n\\end{align}\n%\n\nIn a similar manner, the RGEs for $\\lambda$ and $\\kappa$ are obtained from Eq.~(\\ref{eq:Yuk rges}), with\n\\begin{align}\n\\dt\\lambda &= \\lambda (\\Gamma^{H_1}_{H_1} + \\Gamma^{H_2}_{H_2} + \\Gamma^S_S)\\,, \\\\\n%\n\\dt\\kappa &= 3\\kappa \\Gamma_S^S\\,,\n\\end{align}\n%\nwhere the one- and two-loop expressions for the singlet anomalous dimension \nare given by\n%\n\\begin{align}\n\\gamma_S^{(1)S} &= 2\\lamsq + 2\\kapsq\\,,\\\\\n%\n\\gamma_S^{(2)S} &= -4\\lambda^4 - 8\\kappa^4 - 8 \\kapsq\\lamsq \n- 6\\lamsq \\tr(Y_UY_U^\\dagger) - 6\\lamsq \\tr(Y_UY_U^\\dagger) \n- 2\\lamsq \\tr(Y_EY_E^\\dagger) + \\tfrac{6}{5}g_1^2\\lamsq + 6g_2^2\\lamsq\\,.\n\\end{align} \n\n\n\n\\subsection{Gauge Couplings}\nIn the NMSSM, the one-loop RGEs of the for the gauge couplings $g_a$ are \nidentical to those for the MSSM.  At two-loop order however, the $\\lambda$ \ncoupling appears through the term\n%\n\\begin{equation}\n\\dt g_a \\ni - \\frac{g_a^3}{(16\\pi^2)^2} Y_{ijk}Y^{ijk} C_a(k)/d(G_a)\\,,  \n\\label{eqn:dg}\n\\end{equation}\n%\nwhere $d(G_a)$ is the dimension of the adjoint representation of gauge group \n$G_a$.  The result is\n%\n\\begin{equation}\n\\left. \\dt g_a\\right|_\\lambda = -\\frac{g_a^3}{(16\\pi^2)^2}\\lamsq \\Lambda_a^{(2)}\\,,\n\\qquad \\Lambda_a^{(2)} = (\\tfrac{6}{5},2,0)\\,,\n\\label{eq:dg}\n\\end{equation}\n%\nwhere we have taken into account the additional factor of 2 which arises from \ntracing over $SU(2)$ group indices in Eq.~(\\ref{eqn:dg}).\n\n\\subsection{Gaugino Mass Parameters}\nAs for the gauge couplings above, we need only consider the addition of the \n$\\lambda^2$ terms arising from\n%\n\\begin{equation}\n\\dt M_a \\ni \\frac{2g_a^2}{(16\\pi^2)^2} \n\\frac{(T_A^{ijk} - M_a Y^{ijk}) Y_{ijk}C_a(k)}{d(G_a)}\\,,\n\\label{eqn:dM}\n\\end{equation}\n%\nwhere $T_A^{ijk}$ is a trilinear soft SUSY-breaking parameter. By evaluating the summations in Eq.~(\\ref{eqn:dM}), we find\n%\n\\begin{equation}\n\\left. \\dt M_a\\right|_{\\lambda} = \\frac{2g_a^2}{(16\\pi^2)^2} (\\lambda a_\\lambda - \\lambda^2 M_a)\\Lambda^{(2)}_a\\,,\n\\end{equation}\n%\nwith $\\Lambda_a^{(2)}$ as given in (\\ref{eq:dg}).\n\n\\subsection{$\\mu$ Parameters}\nThe general expression \\cite{MV94,Yam94} for the SUSY-conserving bilinear terms is given by  \n%\n\\begin{equation}\n\\dt \\mu^{ij} = \\mu^{ip}\\Gamma_p^j + \\mu^{jp}\\Gamma_p^i\\,,\n\\end{equation}\n%\nfrom which we obtain\n%\n\\begin{align}\n\\dt\\mu &= \\mu (\\Gamma_{H_1}^{H_1} + \\Gamma_{H_2}^{H_2}), \\notag \\\\\n%\n\\dt\\mu' &= 2\\mu' \\Gamma_S^S\n\\end{align}\n%\n\n\\subsection{Trilinear Couplings}\nIf we denote $T_A^{ijk}$ as a soft SUSY-breaking trilinear, then the evolution at two-loop is given by \n%\n\\begin{equation}\n\\dt T_A^{ijk} = \\frac{1}{16\\pi^2} \\left[\\beta_{T_A}^{(1)}\\right]^{ijk} \n+ \\frac{1}{(16\\pi^2)^2} \\left[\\beta_{T_A}^{(2)}\\right]^{ijk}\\,,\n\\end{equation}\n%\nwhere the explicit expressions for the $\\beta$ functions can be found in \\cite{MV94}.  \nFor $T = U,D,E$, the $\\lambda$ contribution to the one-loop $\\beta$ function \narises from the following factor\n%\n\\begin{equation}\n\\left[\\beta_{T_A}^{(1)}\\right]^{ij} \\ni \\tfrac{1}{2} (T_A)^{ij} \nY_{H_\\alpha mn}Y^{mnH_\\alpha} + (Y_x)^{ij} Y_{H_\\alpha mn}T_A^{mnH_\\alpha}\\,,\n\\end{equation}\n%\nwhere there is {\\it no summation} over $\\alpha = 1,2$, with the index \ndetermined by the choice of $T$ (e.g.\\ if $T=U$ then $\\alpha = 2$). Expanding \nthe indices leads to\n%\n\\begin{equation}\n\\left.\\left[\\beta_{T_A}^{(1)}\\right]^{ij}\\right|_\\lambda = (T_A)^{ij}\\lambda^2 \n+ (Y_x)^{ij} 2\\lambda a_\\lambda\\,. \\label{eqn: beta hx}\n\\end{equation}\n%\n\nThe two-loop expressions involve a large number of summations so to minimize the proliferation of generation indices we choose to express our results in terms of $3\\times 3$ matrices:\n%\n\\begin{align}\n\\left.\\beta_{ U_A}^{(2)}\\right|_\\lambda =& -\\lamsq U_A\\big[ 3\\lamsq + 2\\kapsq \n+ 3\\tr( Y_D Y_D^\\dagger) + \\tr( Y_E Y_E^\\dagger) \\big] \n-\\lamsq\\big[ 5 Y_U Y_U^\\dagger U_A + 4 U_A Y_U^\\dagger Y_U +  Y_D Y_D^\\dagger U_A \n+ 2 D_A Y_D^\\dagger Y_U \\big] \\notag \\\\\n%\n&-2\\lambda  a_\\lambda Y_U\\big[ 3\\lamsq + 2\\kapsq + 3\\tr( Y_D Y_D^\\dagger) \n+ \\tr( Y_E Y_E^\\dagger) \\big] -2\\lamsq Y_U\\big[ 3\\lambda  a_\\lambda \n+ 2\\kappa a_\\kappa + 3\\tr( D_A Y_D^\\dagger) + \\tr( E_A Y_E^\\dagger) \\big] \\notag \\\\\n%\n&-2\\lambda  a_\\lambda\\big[ 3 Y_U Y_U^\\dagger Y_U +  Y_D Y_D^\\dagger Y_U \\big]\\,, \\\\\n%\n%\n\\left.\\beta_{ D_A}^{(2)}\\right|_\\lambda =& -\\lamsq D_A\\big[ 3\\lamsq + 2\\kapsq \n+ 3\\tr( Y_U Y_U^\\dagger) \\big] \n-\\lamsq\\big[ 5 Y_D Y_D^\\dagger D_A + 4 D_A Y_D^\\dagger Y_D + 2 U_A Y_U^\\dagger Y_D \n+  Y_U Y_U^\\dagger D_A \\big] \\notag \\\\\n%\n&-2\\lambda  a_\\lambda  Y_D\\big[ 3\\lamsq + 2\\kapsq + 3\\tr( Y_U Y_U^\\dagger) \\big]\n-2\\lamsq Y_D\\big[ 3\\lambda  a_\\lambda + 2\\kappa a_\\kappa \n+ 3\\tr( U_A Y_U^\\dagger) \\big] -2\\lambda  a_\\lambda\\big[ 3 Y_D Y_D^\\dagger Y_D \n+  Y_U Y_U^\\dagger Y_D\\big]\\,,  \\\\\n%\n%\n\\left.\\beta_{ E_A}^{(2)}\\right|_\\lambda =& -\\lamsq  E_A\\big[ 3\\lamsq + 2\\kapsq \n+ 3\\tr( Y_U Y_U^\\dagger) \\big] \n-\\lamsq\\big[ 5 Y_E Y_E^\\dagger E_A + 4 E_A Y_E^\\dagger Y_E \\big] \n-2\\lambda  a_\\lambda  Y_E\\big[ 3\\lamsq + 2\\kapsq + 3\\tr( Y_U Y_U^\\dagger) \\notag \\\\\n%\n&-2\\lamsq Y_E\\big[ 3\\lambda a_\\lambda + 2\\kappa a_\\kappa + 3\\tr( U_A Y_U^\\dagger) \n\\big] -6\\lambda a_\\lambda  Y_E Y_E^\\dagger Y_E\\,.\n\\end{align}\n\nFor $a_\\lambda$, the one-loop $\\beta$ function reads in full\n%\n\\begin{align}\n\\beta_{a_\\lambda}^{(1)} =&\\, \\tfrac{1}{2}a_\\lambda (Y_{H_1mn}Y^{mnH_1} + Y_{H_2mn}Y^{mnH_2}\n + Y_{Smn}Y^{mnS}) + \\lambda (Y_{H_1mn}T_A^{mnH_1} + Y_{H_2mn}T_A^{mnH_2} \n+ Y_{Smn}T_A^{mnS}) \\notag \\\\\n%\n&- 4\\sum_{a=1,2,3} (a_\\lambda - 2M_a\\lambda)g_a^2C_a(H)\\,,\n\\end{align}\n%\nfrom which the various sums immediately yield\n%\n\\begin{align}\n\\beta_{a_\\lambda}^{(1)} =&\\, a_\\lambda[3\\tr( Y_U  Y_U^\\dagger) + 3\\tr( Y_D  Y_D^\\dagger) \n+ \\tr( Y_E  Y_E^\\dagger) + 12\\lamsq + 2\\kapsq - \\tfrac{3}{5}g_1^2 - 3g_2^2] \n\\notag \\\\\n%\n&+ \\lambda[6\\tr( U_A  Y_U^\\dagger) + 6\\tr( D_A  Y_D^\\dagger) + 2\\tr( E_A  Y_E^\\dagger)\n+ 4a_\\kappa\\kappa + \\tfrac{6}{5}g_1^2M_1 + 6g_2^2M_2]\\,.\n\\end{align}\n%\nThe two-loop expression is given by\n\\begin{align}\n\\beta_{a_\\lambda}^{(2)} =&-50\\lambda^4 a_\\lambda \n- 36\\lambda\\tr(U_A Y_U^\\dagger Y_U Y_U^\\dagger) \n- 36\\lambda\\tr(D_A Y_D^\\dagger Y_D Y_D^\\dagger)\n- 12\\lambda\\tr(E_A Y_E^\\dagger Y_E Y_E^\\dagger) \n- 9a_\\lambda\\tr( Y_U Y_U^\\dagger Y_U Y_U^\\dagger) \\notag \\\\\n%\n&- 9a_\\lambda\\tr( Y_D Y_D^\\dagger Y_D Y_D^\\dagger) \n- 3a_\\lambda\\tr( Y_E Y_E^\\dagger Y_E Y_E^\\dagger) - 8\\kappa^4 a_\\lambda \n- 32\\lambda\\kappa^3 a_\\kappa - 12\\lamsq\\kapsq a_\\lambda \\notag \\\\\n%\n&-18\\lambda^3\\big[ (\\Alam)\\tr( Y_U Y_U^\\dagger) + \\tr(U_A Y_U^\\dagger)\\big] \n- 18\\lambda^3\\big[(\\Alam)\\tr( Y_D Y_D^\\dagger) + \\tr(D_A Y_D^\\dagger)\\big] \\notag \\\\\n%\n&-6\\lambda^3\\big[(\\Alam)\\tr( Y_E Y_E^\\dagger) + \\tr(E_A Y_E^\\dagger)\\big] \n-24\\lambda^3\\kapsq\\big[ (\\Alam) + (\\Akap)\\big]\n-12\\lambda\\big[ \\tr(U_A Y_U^\\dagger Y_D Y_D^\\dagger) \n+ \\tr(D_A Y_D^\\dagger Y_U Y_U^\\dagger) \\big] \\notag \\\\\n%\n&-3\\lamsq a_\\lambda\\big[ 3\\tr( Y_U Y_U^\\dagger) + 3\\tr( Y_D Y_D^\\dagger) \n+ \\tr( Y_E Y_E^\\dagger) \\big] -6a_\\lambda\\tr( Y_U Y_U^\\dagger Y_D Y_D^\\dagger) \n+ \\tfrac{12}{5}g_1^2\\lamsq\\big[ \\tfrac{3}{2}a_\\lambda - \\lambda M_1\\big] \\notag \\\\\n%\n&+\\tfrac{8}{5}g_1^2\\lambda\\big[ \\tr(U_A Y_U^\\dagger) - M_1\\tr( Y_U Y_U^\\dagger) \\big]\n-\\tfrac{4}{5}g_1^2\\lambda\\big[ \\tr(D_A Y_D^\\dagger) - M_1\\tr( Y_D Y_D^\\dagger)\\big] \n+\\tfrac{12}{5}g_1^2\\lambda\\big[\\tr(E_A Y_E^\\dagger) - M_1\\tr( Y_E Y_E^\\dagger)\\big] \n\\notag \\\\\n%\n&+\\tfrac{2}{5}g_1^2 a_\\lambda\\big[ 2\\tr( Y_U Y_U^\\dagger) - \\tr( Y_D Y_D^\\dagger) \n+ 3\\tr( Y_E Y_e^\\dagger) \\big] + 12g_2^2\\lamsq\\big[ \\tfrac{3}{2}a_\\lambda \n- \\lambda M_2\\big] \\notag \\\\\n%\n&+32g_3^2\\lambda\\big[ \\tr(U_A Y_U^\\dagger) - M_3\\tr( Y_U Y_U^\\dagger) \\big]\n+32g_3^2\\lambda\\big[\\tr(D_A Y_D^\\dagger) - M_3\\tr( Y_D Y_D^\\dagger) \\big] \n+ 16g_3^2 a_\\lambda\\big[ \\tr( Y_U Y_U^\\dagger) + \\tr( Y_D Y_D^\\dagger) \\big] \\notag \\\\\n%\n&+ \\tfrac{1}{50}g_1^4\\lambda\\big[ 207(\\Alam) - 828M_1\\big] \n+ \\tfrac{1}{2}g_2^4\\lambda\\big[ 15(\\Alam) - 60M_2\\big]\n+\\tfrac{9}{5}g_1^2 g_2^2\\lambda\\big[ (\\Alam) - 2(M_1 + M_2)\\big] \\,.\n\\end{align}\n\nFor $a_\\kappa$, the one-loop calculation is similar to that of $a_\\lambda$, with \nthe result\n%\n\\begin{equation}\n\\beta_{a_\\kappa}^{(1)} = 18a_\\kappa\\kappa^2 + 12a_\\lambda\\kappa\\lambda \n+ 6a_\\kappa\\lamsq\\,.\n\\end{equation}\n%\nAt two-loop we have\n%\n\\begin{align}\n\\beta_{a_\\kappa}^{2)} =& -120\\kappa^4 a_\\kappa - 12\\lambda^4 a_\\kappa \n- 48\\lambda^3\\kappa a_\\lambda - 48\\lamsq\\kappa^3\\big[ (\\Alam) + (\\Akap)\\big]\n-24\\lamsq\\kapsq a_\\kappa \\notag \\\\\n%\n&-36\\lamsq\\kappa\\big[ \\tr( U_A Y_u^\\dagger) + (\\Alam)\\tr( Y_u Y_u^\\dagger)\\big]\n-36\\lamsq\\kappa\\big[ \\tr( D_A Y_d^\\dagger) + (\\Alam)\\tr( Y_d Y_d^\\dagger)\\big] \n\\notag \\\\\n%\n&-12\\lamsq\\kappa\\big[ \\tr( E_A Y_e^\\dagger) + (\\Alam)\\tr( Y_e Y_e^\\dagger)\\big]\n-6\\lamsq a_\\kappa\\big[ 3\\tr( Y_u Y_u^\\dagger) + 3\\tr( Y_d Y_d^\\dagger) \n+ \\tr( Y_e Y_e^\\dagger) \\big] \\notag \\\\\n%\n&+ \\tfrac{36}{5}g_1^2\\lamsq\\kappa\\big[ (\\Alam) + \\tfrac{1}{2}(\\Akap) - M_1\\big] \n+ 36g_2^2\\lamsq \\kappa\\big[ (\\Alam) + \\tfrac{1}{2}(\\Akap) - M_2 \\big]\\,.\n\\end{align}\n\n\\subsection{Higgs Masses}\nTo determine the $\\lambda$ and $\\kappa$ contributions to the Higgs masses, it is useful to define \\cite{Ellwanger:2009dp} the following quantities \n%\n\\begin{align}\n\\mlamsq =& \\mhdsq + \\mhusq + \\mssq + a_\\lambda^2/\\lamsq\\,, \\notag \\\\\n%\n\\mkapsq =& 3\\mssq + a_\\kappa^2/\\kapsq\\,, \\notag \\\\\n%\n\\Musq =& \\tr(\\mqsq Y_u Y_u^\\dagger) + \\tr( Y_u\\musq Y_u^\\dagger)\n+ \\mhusq\\tr( Y_u Y_u^\\dagger) + \\tr( U_A U_A^\\dagger)\\,, \\notag \\\\\n%\n\\Mdsq =& \\tr(\\mqsq Y_d Y_d^\\dagger) + \\tr( Y_d\\mdsq Y_d^\\dagger) \n+ \\mhdsq\\tr( Y_d Y_d^\\dagger) + \\tr( D_A D_A^\\dagger)\\,, \\notag \\\\\n%\n\\Mesq =& \\tr(\\mlsq Y_e Y_e^\\dagger) + \\tr( Y_e\\mesq Y_e^\\dagger) \n+ \\mhdsq\\tr( Y_e Y_e^\\dagger) + \\tr( E_A E_A^\\dagger)\\,. \\notag \\\\\n\\end{align}\n%\nBoth the up- and down-type Higgs masses $m_{H_2}$ and $m_{H_1}$ receive the same \n$\\lambda$ contribution at one-loop order, \n%\n\\begin{equation}\n\\left.\\beta_{m_{H_\\alpha}^2}^{(1)}\\right|_\\lambda = 2\\lamsq \\mlamsq\\,, \\qquad \\alpha = 1,2\\,.\n\\end{equation}\n%\n\nThe two-loop expressions for $m_{H_2}^2$ are \n%\n\\begin{align}\n\\left.\\beta_{m_{H_2}^2}^{(2)}\\right|_\\lambda =& -12\\lambda^4\\big\\{ M_\\lambda^2 + (\\Alam)^2\\big\\} \n- 6\\lamsq\\big\\{ \\Mdsq + M_\\lambda^2\\tr( Y_d Y_d^\\dagger) + 2(a_\\lambda/\\lambda)\\tr( D_A Y_d^\\dagger) \\big\\} \\notag \\\\\n%\n&-2\\lamsq\\big\\{ \\Mesq + M_\\lambda^2\\tr( Y_e Y_e^\\dagger) + 2(a_\\lambda/\\lambda)\\tr( E_A Y_e^\\dagger)\\big\\}\n%\n-4\\lamsq\\kapsq\\big\\{ M_\\lambda^2 + M_\\kappa^2 + 2(a_\\lambda/\\lambda)(a_\\kappa/\\kappa) \\big\\}  \\notag \\\\\n%\n&+ \\tfrac{6}{5}g_1^2\\lamsq(\\mhdsq-\\mhusq) \\,,\n\\end{align}\n%\nwith a similar result for $m_{H_1}^2$,\n%\n\\begin{align}\n\\left.\\beta_{m_{H_1}^2}^{(2)}\\right|_\\lambda =& -12\\lambda^4\\big\\{M_\\lambda^2 + (\\Alam)^2\\big\\} \n- 6\\lamsq\\big\\{ \\Musq + M_\\lambda^2\\tr( Y_u Y_u^\\dagger) + 2(a_\\lambda/\\lambda)\\tr( U_A Y_u^\\dagger) \\big\\} \\notag \\\\\n%\n&-4\\lamsq\\kapsq\\big\\{ M_\\lambda^2 + M_\\kappa^2 + 2(a_\\lambda/\\lambda)(a_\\kappa/\\kappa) \\big\\} \n- \\tfrac{6}{5}g_1^2\\lamsq(\\mhdsq-\\mhusq)\\,.\n\\end{align}\n\nFor the singlet mass $m_S$, the one-loop result is\n%\n\\begin{equation}\n\\beta_{m_S^2}^{(1)} = Y_{Spq}Y^{pqS}m_S^2 + 2Y_{Spq}Y^{Spr}(m^2)^q_r + h_{Spq}h^{Spq}\\,, \\label{eqn:beta mSsq}\n\\end{equation}\n%\nwhere \n%\n\\begin{align}\nY_{Spq}Y^{Spr}(m^2)^q_r &= 2\\lamsq(\\mhdsq + \\mhusq) + 4\\kapsq m_S^2\\,, \\notag \\\\\n%\nh_{Spq}h^{Spq} &= 4a_\\lambda^2 + 4a_\\kappa^2\\,,\n\\end{align}\n%\nand thus Eq.~(\\ref{eqn:beta mSsq}) becomes\n%\n\\begin{equation}\n\\beta_{m_S^2}^{(1)} = 4\\lamsq \\mlamsq + 4\\kapsq \\mkapsq\\,.\n\\end{equation}\n%\nAt two-loop we get\n\\begin{align}\n\\beta_{m_S^2}^{(2)} =& -16\\lambda^4\\big\\{ \\mlamsq + (\\Alam)^2\\big\\} - 32\\kappa^4\\big\\{ \\mkapsq + (\\Akap)^2\\big\\}\n-12\\lamsq\\big\\{ \\mlamsq\\tr( Y_u Y_u^\\dagger) + \\Musq + 2(\\Alam)\\tr( U_A Y_u^\\dagger)\\big\\} \\notag \\\\\n%\n&- 12\\lamsq\\big\\{ \\mlamsq\\tr( Y_d Y_d^\\dagger) + \\Mdsq + 2(\\Alam)\\tr( D_A Y_d^\\dagger) \\big\\} \n- 4\\lamsq\\big\\{ \\mlamsq\\tr( Y_e Y_e^\\dagger) + \\Mesq + 2(\\Alam)\\tr( E_A Y_e^\\dagger) \\big\\} \\notag \\\\\n%\n&- 16\\lamsq\\kapsq\\big\\{ \\mlamsq + \\mkapsq + 2(\\Alam)(\\Akap) \\big\\}\n+ \\tfrac{12}{5}g_1^2\\lamsq \\big\\{ \\mlamsq - 2M_1[(\\Alam) - M_1] \\big\\} \\notag \\\\\n%\n&+ 12g_2^2\\lamsq\\big\\{ \\mlamsq -2M_2[(\\Alam) - M_2]\\big\\}\n\\end{align}\n\n\\subsection{Squark and Slepton Masses}\nThe squark and slepton masses only receive contributions from $\\lambda,\\kappa$ at two-loop order.  The results are listed below, where $\\mathbf{1}$ is a $3\\times 3$ unit matrix.\n%\n\\begin{align}\n\\left.\\beta_{\\mqsq}^{(2)}\\right|_\\lambda =& -\\lamsq \\big\\{ 2 Y_u^\\dagger\\musq Y_u + \\mqsq Y_u Y_u^\\dagger +  Y_u Y_u^\\dagger\\mqsq \\notag \n+ 2\\mhusq Y_u Y_u^\\dagger + 2 U_A U_A^\\dagger + 2\\mlamsq Y_u Y_u^\\dagger \n+ 2a_\\lambda/\\lambda(  Y_u U_A^\\dagger +  U_A Y_u^\\dagger) \\big\\} \\notag \\\\\n%\n&-\\lamsq\\big\\{ 2 Y_d^\\dagger\\mdsq Y_d + \\mqsq Y_d Y_d^\\dagger +  Y_d Y_d^\\dagger\\mqsq \n+ 2\\mhdsq Y_d Y_d^\\dagger + 2 D_A D_A^\\dagger + 2\\mlamsq Y_d Y_d^\\dagger \n+ 2a_\\lambda/\\lambda(  Y_d D_A^\\dagger +  D_A Y_d^\\dagger) \\big\\} \\notag \\\\\n%\n&+ \\tfrac{2}{5}g_1^2\\lamsq(\\mhdsq - \\mhusq)\\mathbf{1}\\,,\n\\end{align}\n%\n%\n\\begin{align}\n\\left.\\beta_{\\musq}^{(2)}\\right|_\\lambda =& -2\\lamsq \\big\\{ 2 Y_u^\\dagger\\mqsq Y_u + \\musq Y_u^\\dagger Y_u +  Y_u^\\dagger Y_u\\musq \n+ 2\\mhusq Y_u^\\dagger Y_u + 2 U_A^\\dagger U_A + 2\\mlamsq Y_u^\\dagger Y_u \n+ 2a_\\lambda/\\lambda(  Y_u^\\dagger U_A +  U_A^\\dagger Y_u) \\big\\}  \\notag \\\\\n%\n&- \\tfrac{8}{5}g_1^2\\lamsq(\\mhdsq - \\mhusq)\\mathbf{1}\\,,\n\\end{align}\n%\n%\n\\begin{align}\n\\left.\\beta_{\\mdsq}^{(2)}\\right|_\\lambda =& -2\\lamsq \\big\\{ 2 Y_d^\\dagger\\mqsq Y_d + \\mdsq Y_d^\\dagger Y_d +  Y_d^\\dagger Y_d\\mdsq \n+ 2\\mhdsq Y_d^\\dagger Y_d + 2 D_A^\\dagger D_A + 2\\mlamsq Y_d^\\dagger Y_d \n+ 2a_\\lambda/\\lambda(  Y_d^\\dagger D_A +  D_A^\\dagger Y_d) \\big\\} \\notag \\\\\n%\n&+ \\tfrac{4}{5}g_1^2\\lamsq(\\mhdsq - \\mhusq)\\mathbf{1}\\,,\n\\end{align}\n%\n%\n\\begin{align}\n\\left.\\beta_{\\mlsq}^{(2)}\\right|_\\lambda =& -\\lamsq \\big\\{ 2 Y_e^\\dagger\\mesq Y_e + \\mlsq Y_e Y_e^\\dagger +  Y_e Y_e^\\dagger\\mlsq \n+ 2\\mhdsq Y_e Y_e^\\dagger + 2 E_A E_A^\\dagger + 2\\mlamsq Y_e Y_e^\\dagger \n+ 2a_\\lambda/\\lambda(  Y_e E_A^\\dagger +  E_A Y_e^\\dagger) \\big\\} \\notag \\\\\n%\n&- \\tfrac{6}{5}g_1^2\\lamsq(\\mhdsq - \\mhusq)\\mathbf{1}\\,,\n\\end{align}\n%\n%\n\\begin{align}\n\\left.\\beta_{\\mesq}^{(2)}\\right|_\\lambda =& -2\\lamsq \\big\\{ 2 Y_e^\\dagger\\mlsq Y_e + \\mesq Y_e^\\dagger Y_e +  Y_e^\\dagger Y_e\\mesq \n+ 2\\mhdsq Y_e^\\dagger Y_e + 2 E_A^\\dagger E_A + 2\\mlamsq Y_e^\\dagger Y_e\n+ 2a_\\lambda/\\lambda(  Y_e^\\dagger E_A +  E_A^\\dagger Y_e) \\big\\} \\notag \\\\\n%\n&+ \\tfrac{12}{5}g_1^2\\lamsq(\\mhdsq - \\mhusq)\\mathbf{1}\\,.\n\\end{align}\n\n\\subsection{Tadpole Terms}\nThe general RGE for a SUSY-conserving tadpole term reads\n%\n\\begin{equation}\n\\dt L^i = L^p\\Gamma_p^i\\,,\n\\end{equation}\n%\nand thus for $i=S$ one has\n%\n\\begin{equation}\n\\dt \\xi_F = \\xi_F \\Gamma_S^S\\,.\n\\end{equation}\n%\nFor the soft SUSY-breaking term $\\xi_S$, we use the general RGE from \\cite{Yam94} because Martin and Vaughn \\cite{MV94} do not include the tadpole as part of $\\mathcal{L}_{\\mathrm{soft}}$.  The relevant RGE reads\n%\n\\begin{equation}\n\\dt \\xi_S = \\frac{1}{16\\pi^2} \\beta_{\\xi_S}^{(1)} + \\frac{1}{(16\\pi^2)^2} \\beta_{\\xi_S}^{(2)}\\,,\n\\end{equation}\n%\nwhere the one-loop $\\beta$ function is given by\n%\n\\begin{align}\n\\beta_{\\xi^{}_S}^{(1)} &= 2(\\lamsq + \\kapsq)\\xi^{}_S + 4(\\lambda a_\\lambda + \\kappa a_\\kappa)\\xi^{}_F + 2\\mu'(2\\lambda m_3^2 + \\kappa m_S'^2) \\notag \\\\\n%\n&+ 4[\\lambda\\mu (\\mhusq + \\mhdsq) + \\kappa\\mu' \\mssq]\\mu_{jl} + 4a_\\lambda m_3^2 + 2a_\\kappa m_S'^2\\,.\n\\end{align}\n%\nAt two-loop we obtain\n%\n\\begin{align}\n\\beta_{\\xi^{}_S}^{(2)} =& -4\\lambda^4\\big\\{ \\xi_S + 4(\\Alam)\\xi_F\\big\\} \n- 8\\kappa^4\\big\\{ \\xi_S + 4(\\Akap)\\xi_F\\big\\} \n-6\\lamsq\\big\\{ \\xi_S\\tr( Y_u Y_u^\\dagger)+ 2[(\\Alam)\\tr( Y_u Y_u^\\dagger) + \\tr( U_A Y_u^\\dagger)]\\big\\}\\xi_F \\notag \\\\\n%\n&-6\\lamsq\\big\\{\\xi_S\\tr( Y_d Y_d^\\dagger) + 2[(\\Alam)\\tr( Y_d Y_d^\\dagger) + \\tr( D_A Y_d^\\dagger)]\\big\\}\\xi_F  \\notag \\\\\n%\n&-2\\lamsq\\big\\{\\xi_S\\tr( Y_e Y_e^\\dagger) + 2[(\\Alam)\\tr( Y_e Y_e^\\dagger) + \\tr( E_A Y_e^\\dagger)]\\big\\}\\xi_F \\notag \\\\\n%\n&-8\\lamsq\\kapsq\\big\\{ \\xi_S + 2[(\\Alam) + (\\Akap)]\\xi_F\\big\\} \\notag \\\\\n%\n&-12\\lambda\\big\\{ \\mtrisq[(\\Alam) + \\mu']\\tr( Y_u Y_u^\\dagger) + \\mtrisq\\tr( U_A Y_u^\\dagger)\n+ \\mu\\{\\Musq + [(\\Alam) + \\mu']\\tr( U_A Y_u^\\dagger) + [\\mhdsq + \\mhusq]\\tr( Y_u Y_u^\\dagger)\\} \\big\\} \\notag \\\\\n%\n&-12\\lambda\\big\\{ \\mtrisq[(\\Alam) + \\mu']\\tr( Y_d Y_d^\\dagger) + \\mtrisq\\tr( D_A Y_d^\\dagger)\n+ \\mu\\{\\Mdsq + [(\\Alam) +\\mu']\\tr( D_A Y_d^\\dagger) + [\\mhdsq + \\mhusq]\\tr( Y_d Y_d^\\dagger)\\} \\big\\}  \\notag \\\\\n%\n&-4\\lambda\\big\\{ \\mtrisq[(\\Alam)+ \\mu']\\tr( Y_e Y_e^\\dagger) + \\mtrisq\\tr( E_A Y_e^\\dagger)\n+ \\mu\\{\\Mesq + [(\\Alam) +\\mu']\\tr( E_A Y_e^\\dagger) + [\\mhdsq + \\mhusq]\\tr( Y_e Y_e^\\dagger)\\} \\big\\} \\notag \\\\\n%\n&-8\\lambda^3\\big\\{ \\mtrisq[2(\\Alam) + \\mu'] + \\mu[\\mlamsq + (\\Alam)[(\\Alam) + \\mu'] + \\mhdsq + \\mhusq]\\big\\} \\notag \\\\\n%\n&-8\\lamsq\\kappa\\big\\{ \\msprsq[(\\Alam) + (\\Akap) + \\mu']\n+ \\mu'[\\mlamsq + (\\Alam)[(\\Akap) + \\mu'] + 2\\mssq] \\big\\} \\notag \\\\\n%\n&-8\\kappa^3\\big\\{ \\msprsq[2(\\Akap) + \\mu'] \n+ \\mu'[\\mkapsq + (\\Akap)[(\\Akap) + \\mu'] + 2\\mssq] \\big\\} \\notag \\\\\n%\n&+ \\tfrac{6}{5}\\lambda g_1^2\\big\\{ 3\\mtrisq[(\\Alam) + \\mu' - M_1]\n+ 2\\mu[\\mhdsq + \\mhusq -(\\Alam)M_1 - \\mu' M_1 + 2M_1^2] \n+ \\lambda[2\\xi_F[(\\Alam) - M_1]  + \\xi_S] \\big\\} \\notag \\\\\n%\n&+ 3\\lambda g_2^2\\big\\{ 3\\mtrisq[(\\Alam) + \\mu' - M_2]\n+ 2\\mu[\\mhdsq + \\mhusq - (\\Alam)M_2 - \\mu' M_2 + 2M_2^2] \n+ \\lambda[2\\xi_F[(\\Alam) - M_2] + \\xi_S] \\big\\}\\,.\n\\end{align}\n\n\\subsection{Additional Parameters}\nHere we list the $\\lambda$ and $\\kappa$ contributions to the RGEs for the scalar masses $\\mtrisq \\equiv B\\mu$ and $\\msprsq \\equiv B'\\mu'$, and the evolution of the Higgs VEVs $v_{1,2,s}$.  For the former, we get at one-loop\n%\n\\begin{equation}\n\\left.\\beta_{\\mtrisq}^{(1)}\\right|_\\lambda = 2\\lambda(3\\lambda\\mtrisq + 2\\mu a_\\lambda) + 2\\lambda\\kappa\\msprsq\\,.\n\\end{equation}\n%\nAt two-loop we have\n%\n\\begin{align}\n\\left.\\beta_{\\mtrisq}^{(2)}\\right|_\\lambda &= -2\\lambda^4(7\\mtrisq + 16\\mu a_\\lambda/\\lambda) -3\\lamsq\\big\\{ 5\\mtrisq\\tr( Y_u Y_u^\\dagger) \n+ 2\\mu[3\\tr( U_A Y_u^\\dagger) + (a_\\lambda/\\lambda)\\tr( Y_u Y_u^\\dagger)] \\big\\} \\notag \\\\\n%\n&-3\\lamsq\\big\\{ 5\\mtrisq\\tr( Y_d Y_d^\\dagger) + 2\\mu[3\\tr( D_A Y_d^\\dagger) \n+ (a_\\lambda/\\lambda)\\tr( Y_d Y_d^\\dagger) \\big\\} \\notag \\\\\n%\n&-\\lamsq\\big\\{5\\mtrisq\\tr( Y_e Y_e^\\dagger) \n+ 2\\mu[3\\tr( E_A Y_e^\\dagger) + (a_\\lambda/\\lambda)\\tr( Y_e Y_e^\\dagger)] \\big\\} \\notag \\\\\n%\n&-4\\lamsq\\kapsq\\big\\{ \\mtrisq + 2\\mu[(a_\\lambda/\\lambda) + (a_\\kappa/\\kappa)] \\big\\} \n-8\\lambda^3\\kappa\\big\\{ m_S'^2 + \\mu'(a_\\lambda/\\lambda)\\big\\} - 8\\lambda\\kappa^3\\big\\{m_S'^2 + \\mu'(a_\\kappa/\\kappa)\\big\\} \\notag \\\\\n%\n&+\\tfrac{12}{5}g_1^2\\lamsq(\\mtrisq - \\mu M_1) + 12g_2^2\\lamsq(\\mtrisq -\\mu M_2) \\,.\n\\end{align}\n\nFor $\\msprsq$, the one-loop $\\beta$ function reads\n%\n\\begin{equation}\n\\beta_{\\msprsq}^{(1)} = 4\\lambda(\\lambda\\msprsq + 2\\mu' a_\\lambda) + 8\\kappa(\\kappa\\msprsq + \\mu' a_\\kappa) + 8\\lambda\\kappa\\mtrisq \\,.\n\\end{equation}\n%\n%\nAt two-loop we have\n\\begin{align}\n\\beta_{\\msprsq}^{(2)} =& -8\\lambda^4\\big\\{\\msprsq + 4\\mu'(a_\\lambda/\\lambda)\\big\\} - 16\\kappa^4\\big\\{ 2\\msprsq + 5\\mu'(a_\\kappa/\\kappa) \\big\\} \n- 16\\lamsq\\kapsq\\big\\{ 2\\msprsq + \\mu'[3(a_\\lambda/\\lambda) + 2(a_\\kappa/\\kappa)] \\big\\} \\notag \\\\\n%\n&-12\\lamsq\\big\\{ \\msprsq\\tr( Y_u Y_u^\\dagger) + 2\\mu'[(\\Alam)\\tr( Y_u Y_u^\\dagger) + \\tr( U_A Y_u^\\dagger)] \\big\\} \\notag \\\\\n%\n&-12\\lamsq\\big\\{\\msprsq\\tr( Y_d Y_d^\\dagger) + 2\\mu'[(\\Alam)\\tr( Y_d Y_d^\\dagger) + \\tr( D_A Y_d^\\dagger)] \\big\\} \\notag \\\\\n%\n&-4\\lamsq\\big\\{\\msprsq\\tr( Y_e Y_e^\\dagger) + 2\\mu'[(\\Alam)\\tr( Y_e Y_e^\\dagger) + \\tr( E_A Y_e^\\dagger)] \\big\\} \n-16\\lambda^3\\kappa\\big\\{ \\mtrisq + \\mu(\\Alam)\\big \\} \\notag \\\\\n%\n&-24\\lambda\\kappa\\big\\{ \\mtrisq\\tr( Y_u Y_u^\\dagger) + \\mu\\tr( U_A Y_u^\\dagger)\\big\\} \n-24\\lambda\\kappa\\big\\{ \\mtrisq\\tr( Y_d Y_d^\\dagger) + \\mu\\tr( D_A Y_d^\\dagger)\\big\\} \\notag \\\\\n%\n&-8\\lambda\\kappa\\big\\{ \\mtrisq\\tr( Y_e Y_e^\\dagger) + \\mu\\tr( E_A Y_e^\\dagger)\\big\\} \n+\\tfrac{24}{5}\\lambda\\kappa g_1^2\\big\\{\\mtrisq - \\mu M_1\\big\\} + 24\\lambda\\kappa g_2^2\\big\\{\\mtrisq - \\mu M_2 \\big\\} \\notag \\\\\n%\n&+\\tfrac{12}{5}\\lamsq g_1^2\\big\\{\\msprsq + 2\\mu'[(\\Alam) - M_1]\\big\\} \n+12\\lamsq g_2^2 \\big\\{\\msprsq + 2\\mu'[(\\Alam) - M_2] \\big\\}\\,.\n\\end{align}\n\nAt one-loop, the up- and down-type Higgs VEVs $v_{u,d}$ receive additional contributions solely from $\\lambda$ \\cite{Sper13},\n%\n\\be\n\\left.\\beta^{(1)}_{v_\\alpha}\\right|_\\lambda = -v_\\alpha\\lamsq\\,, \\qquad \\alpha=1,2\\,,\n\\ee\n%\nwhile the $\\beta$ function for the singlet VEV $s$ is given by\n%\n\\be \n\\beta^{(1)}_s = -2s(\\lamsq + \\kapsq)\\,.\n\\ee\n%\nAt two-loop, the $\\beta$ functions are given by \\cite{Sper13,Sper13-2}\n%\n\\begin{align}\n\\beta^{(2)}_{v_1} &= v_1\\Bigg\\{\\gamma^{(2)H_1}_{H_1} - \\Big(\\tfrac{3}{10}g_1^2 + \\tfrac{3}{2}g_2^2\\Big)\\Big[3\\tr(Y_DY_D^\\dagger) + \\tr(Y_EY_E^\\dagger) + \\lamsq\\Big] + \\tfrac{9}{2}g_2^4\\Bigg\\}\\,, \\\\\n%\n\\beta^{(2)}_{v_2} &= v_2\\Bigg\\{\\gamma^{(2)H_2}_{H_2} - \n\\Big(\\tfrac{3}{10}g_1^2 + \\tfrac{3}{2}g_2^2\\Big)\n\\Big[3\\tr(Y_UY_U^\\dagger) + \\lamsq\\Big] + \\tfrac{9}{2}g_2^4\\Bigg\\}\\,, \\\\\n%\n\\beta^{(2)}_s &= s\\gamma^{(2)S}_S\\,.\n\\end{align}\n\nThe one-loop $\\beta$ function for $\\tan\\beta$ is the same in the NMSSM as the MSSM.  At two-loop, one has\n%\n\\be\n\\beta^{(2)}_{t_\\beta} = \\tan\\beta\\Bigg\\{\\gamma^{(2)H_2}_{H_2} - \n\\gamma^{(2)H_1}_{H_1} + \\Big(\\tfrac{3}{10}g_1^2 + \\tfrac{3}{2}g_2^2\\Big)\n\\frac{\\beta^{(1)}_{t_\\beta}}{\\tan\\beta}\\Bigg\\}\\,.\n\\ee\n\n\n\\begin{thebibliography}{10}\n\\bibitem{Aad:2013wta}\n  G.~Aad {\\it et al.}  [ATLAS Collaboration],\n  %``Search for new phenomena in final states with large jet multiplicities and missing transverse momentum at $\\sqrt{s}=8$ TeV proton-proton collisions using the ATLAS experiment,''\n  JHEP {\\bf 1310} (2013) 130\n  [arXiv:1308.1841 [hep-ex]].\n  %%CITATION = ARXIV:1308.1841;%%\n  %10 citations counted in INSPIRE as of 06 Nov 2013\n%\\cite{Aad:2012tfa}\n\\bibitem{CMSspart}\nS.~Chatrchyan {\\it et al.} [CMS Collaboration], (2013) CMS-PAS-SUS-13-012\n    %\\cite{Allanach:2008zn}\n\\bibitem{Allanach:2008zn}\n  B.~C.~Allanach,\n  %``SUSY Predictions and SUSY Tools at the LHC,''\n  Eur.\\ Phys.\\ J.\\ C {\\bf 59} (2009) 427\n  [arXiv:0805.2088 [hep-ph]].\n  %%CITATION = ARXIV:0805.2088;%%\n  %13 citations counted in INSPIRE as of 06 Nov 2013\n\n  \\bibitem{Baer:1993ae}\nH.~Baer, F.~E. Paige, S.~D. Protopopescu and X.~Tata, \n%{\\it {Simulating\n%  Supersymmetry with ISAJET 7.0 / ISASUSY 1.0}},\n[hep-ph/9305342].\n%%CITATION = HEP-PH/9305342;%%\n%\\cite{Allanach:2001kg}\n\\bibitem{Allanach:2001kg} \n  B.~C.~Allanach,\n  %``SOFTSUSY: a program for calculating supersymmetric spectra,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 143}, 305 (2002)\n  [hep-ph/0104145].\n  %%CITATION = HEP-PH/0104145;%%\n  %716 citations counted in INSPIRE as of 20 Sep 2013\n\n\\bibitem{Porod:2003um}\nW.~Porod, \n%{\\it {SPheno, a program for calculating supersymmetric spectra, SUSY\n%  particle decays and SUSY particle production at e+ e- colliders}},  \n  Comput.\\ Phys.\\ Commun. {\\bf 153} (2003) 275--315\n  [hep-ph/0301101].\n%%CITATION = HEP-PH/0301101;%%\n\\bibitem{Chowdhury:2011zr}\nD.~Chowdhury, R.~Garani and S.~K. Vempati, \n%{\\it {SUSEFLAV: Program for\n%  supersymmetric mass spectra with seesaw mechanism and rare lepton flavor\n%  violating decays}},  \nComput.\\ Phys.\\ Commun. {\\bf 184} (2013) 899--918\n  [arXiv:1109.3551 [hep-ph]].\n%%CITATION = ARXIV:1109.3551;%%\n\n\\bibitem{Djouadi:2002ze}\nA.~Djouadi, J.-L. Kneur and G.~Moultaka, \n%{\\it {SuSpect: A Fortran code for the\n%  supersymmetric and Higgs particle spectrum in the MSSM}},  \n  Comput.\\ Phys.\\ Commun. {\\bf 176} (2007) 426--455\n  [hep-ph/0211331].\n%%CITATION = HEP-PH/0211331;%%\n%\\cite{Djouadi:2013lra}\n\n%\\cite{Skands:2003cj}\n\\bibitem{Skands:2003cj}\n  P.~Z.~Skands, B.~C.~Allanach, H.~Baer, C.~Balazs, G.~Belanger, F.~Boudjema, A.~Djouadi and R.~Godbole {\\it et al.},\n  %``SUSY Les Houches accord: Interfacing SUSY spectrum calculators, decay packages, and event generators,''\n  JHEP {\\bf 0407} (2004) 036\n  [hep-ph/0311123].\n  %%CITATION = HEP-PH/0311123;%%\n  %380 citations counted in INSPIRE as of 07 Nov 2013\n\\bibitem{Aad:2012tfa}\n  G.~Aad {\\it et al.}  [ATLAS Collaboration],\n  %``Observation of a new particle in the search for the Standard Model Higgs boson with the ATLAS detector at the LHC,''\n  Phys.\\ Lett.\\ B {\\bf 716} (2012) 1\n  [arXiv:1207.7214 [hep-ex]].\n  %%CITATION = ARXIV:1207.7214;%%\n  %1868 citations counted in INSPIRE as of 06 Nov 2013\n%\\cite{Chatrchyan:2012ufa}\n\\bibitem{Chatrchyan:2012ufa}\n  S.~Chatrchyan {\\it et al.}  [CMS Collaboration],\n  %``Observation of a new boson at a mass of 125 GeV with the CMS experiment at the LHC,''\n  Phys.\\ Lett.\\ B {\\bf 716} (2012) 30\n  [arXiv:1207.7235 [hep-ex]].\n  %%CITATION = ARXIV:1207.7235;%%\n  %1848 citations counted in INSPIRE as of 06 Nov 2013\n\n\\bibitem{ATLAS-CONF-2013-014}\nG.~Aad {\\it et al.}  [ATLAS Collaboration],\nATLAS-CONF-2013-014, talk delivered at 48th Rencontres de Moriond on Electroweak Interactions and Unified Theories, La Thuile, Italy, 2 - 9 Mar 2013.\n\n\n\\bibitem{Djouadi:2013lra}\n  A.~Djouadi,\n  %``Implications of the Higgs discovery for the MSSM,''\n  arXiv:1311.0720 [hep-ph].\n  %%CITATION = ARXIV:1311.0720;%%\n\n\\bibitem{Barbieri:1998uv}\n  R.~Barbieri and A.~Strumia,\n  %``About the fine tuning price of LEP,''\n  Phys.\\ Lett.\\ B {\\bf 433} (1998) 63\n  [hep-ph/9801353].\n  %%CITATION = HEP-PH/9801353;%%\n  %94 citations counted in INSPIRE as of 07 Nov 2013\n\n%\\cite{Arbey:2011ab}\n\\bibitem{Arbey:2011ab}\n  A.~Arbey, M.~Battaglia, A.~Djouadi, F.~Mahmoudi and J.~Quevillon,\n  %``Implications of a 125 GeV Higgs for supersymmetric models,''\n  Phys.\\ Lett.\\ B {\\bf 708} (2012) 162\n  [arXiv:1112.3028 [hep-ph]].\n  %%CITATION = ARXIV:1112.3028;%%\n  %188 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Delgado:2010uj}\n\\bibitem{Delgado:2010uj}\n  A.~Delgado, C.~Kolda, J.~P.~Olson and A.~de la Puente,\n  %``Solving the Little Hierarchy Problem with a Singlet and Explicit $\\mu$ Terms,''\n  Phys.\\ Rev.\\ Lett.\\  {\\bf 105} (2010) 091802\n  [arXiv:1005.1282 [hep-ph]].\n  %%CITATION = ARXIV:1005.1282;%%\n  %38 citations counted in INSPIRE as of 07 Nov 2013\n\\bibitem{Ellwanger:2011mu}\n  U.~Ellwanger, G.~Espitalier-Noel and C.~Hugonie,\n  %``Naturalness and Fine Tuning in the NMSSM: Implications of Early LHC Results,''\n  JHEP {\\bf 1109} (2011) 105\n  [arXiv:1107.2472 [hep-ph]].\n  %%CITATION = ARXIV:1107.2472;%%\n  %42 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{King:2012tr}\n\\bibitem{King:2012tr}\n  S.~F.~King, M.~MÃ¼hlleitner, R.~Nevzorov and K.~Walz,\n  %``Natural NMSSM Higgs Bosons,''\n  Nucl.\\ Phys.\\ B {\\bf 870} (2013) 323\n  [arXiv:1211.5074 [hep-ph]].\n  %%CITATION = ARXIV:1211.5074;%%\n  %36 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Perelstein:2012qg}\n\\bibitem{Perelstein:2012qg}\n  M.~Perelstein and B.~Shakya,\n  %``XENON100 Implications for Naturalness in the MSSM, NMSSM and lambda-SUSY,''\n  Phys.\\ Rev.\\ D {\\bf 88} (2013) 075003\n  [arXiv:1208.0833 [hep-ph]].\n  %%CITATION = ARXIV:1208.0833;%%\n  %29 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Ross:2011xv}\n%\\cite{Gherghetta:2012gb}\n\\bibitem{Gherghetta:2012gb} \n  T.~Gherghetta, B.~von Harling, A.~D.~Medina and M.~A.~Schmidt,\n  %``The Scale-Invariant NMSSM and the 126 GeV Higgs Boson,''\n  JHEP {\\bf 02}, 032 (2013)\n  [arXiv:1212.5243 [hep-ph]].\n  %%CITATION = ARXIV:1212.5243;%%\n  %33 citations counted in INSPIRE as of 29 Nov 2013\n%\\cite{BasteroGil:2000bw}\n\\bibitem{BasteroGil:2000bw}\n  M.~Bastero-Gil, C.~Hugonie, S.~F.~King, D.~P.~Roy and S.~Vempati,\n  %``Does LEP prefer the NMSSM?,''\n  Phys.\\ Lett.\\ B {\\bf 489} (2000) 359\n  [hep-ph/0006198].\n  %%CITATION = HEP-PH/0006198;%%\n  %141 citations counted in INSPIRE as of 07 Nov 2013\n\n%\\cite{Ellwanger:2009dp}\n\\bibitem{Ellwanger:2009dp}\n  U.~Ellwanger, C.~Hugonie and A.~M.~Teixeira,\n  %``The Next-to-Minimal Supersymmetric Standard Model,''\n  Phys.\\ Rept.\\  {\\bf 496} (2010) 1\n  [arXiv:0910.1785 [hep-ph]].\n  %%CITATION = ARXIV:0910.1785;%%\n  %344 citations counted in INSPIRE as of 07 Nov 2013\n\n%\\cite{Maniatis:2009re}\n\\bibitem{Maniatis:2009re} \n  M.~Maniatis,\n  %``The Next-to-Minimal Supersymmetric extension of the Standard Model reviewed,''\n  Int.\\ J.\\ Mod.\\ Phys.\\ A {\\bf 25}, 3505 (2010)\n  [arXiv:0906.0777 [hep-ph]].\n  %%CITATION = ARXIV:0906.0777;%%\n  %137 citations counted in INSPIRE as of 29 Nov 2013\n\n\n\\bibitem{NMSSM} P. Fayet, Nucl. Phys. B \\textbf{90} (1975) 104; Phys. Lett.\nB \\textbf{64} (1976) 159; Phys. Lett. B \\textbf{69} (1977) 489 and Phys. Lett. B\n\\textbf{84} (1979) 416; H.P. Nilles, M. Srednicki and D. Wyler, Phys. Lett. B\n\\textbf{120} (1983) 346; J.M. Frere, D.R. Jones and S. Raby, Nucl. Phys. B\n\\textbf{222} (1983) 11; J.P. Derendinger and C.A. Savoy, Nucl. Phys. B\n\\textbf{237} (1984) 307;  A.I. Veselov, M.I. Vysotsky and K.A. Ter-Martirosian,\nSov. Phys. JETP \\textbf{63} (1986) 489; J.R. Ellis, J.F. Gunion, H.E. Haber, L.\nRoszkowski and F. Zwirner, Phys. Rev. D \\textbf{39}  (1989) 844; M. Drees, Int.\nJ. Mod. Phys. A \\textbf{4}  (1989) 3635; U. Ellwanger, M. Rausch de\nTraubenberg and C.A. Savoy, Phys. \nLett. B \\textbf{315} (1993) 331, Z. Phys. C {\\bf 67} (1995) 665 and Nucl. Phys.\nB \\textbf{492} (1997) 307; U.~Ellwanger, Phys.\\ Lett.\\  B {\\bf 303} (1993) 271; P.\nPandita, Z. Phys. C \\textbf{59} (1993) 575; T. Elliott, S.F. King and P.L.\nWhite, Phys. Rev. D {\\bf 49} (1994) 2435; S.F. King and P.L. White, Phys. Rev. D\n\\textbf{52} (1995) 4183;  F.~Franke and H.~Fraas, Int.\\ J.\\ Mod.\\ Phys.\\  A {\\bf\n12} (1997) 479.   D.~J.~Miller, R.~Nevzorov and P.~M.~Zerwas,  Nucl.\\ Phys.\\ B {\\bf 681}, 3 (2004) [hep-ph/0304049].\n\n%\\cite{Ell08}\n\\bibitem{Ell08} \n  U.~Ellwanger, C.~-C.~Jean-Louis and A.~M.~Teixeira,\n  %``Phenomenology of the General NMSSM with Gauge Mediated Supersymmetry Breaking,''\n  JHEP {\\bf 0805}, 044 (2008)\n  [arXiv:0803.2962 [hep-ph]].\n  %%CITATION = ARXIV:0803.2962;%%\n  %28 citations counted in INSPIRE as of 24 Sep 2013\n\n\n\\bibitem{Ross:2011xv}\n  G.~G.~Ross and K.~Schmidt-Hoberg,\n  %``The Fine-Tuning of the Generalised NMSSM,''\n  Nucl.\\ Phys.\\ B {\\bf 862} (2012) 710\n  [arXiv:1108.1284 [hep-ph]].\n  %%CITATION = ARXIV:1108.1284;%%\n  %54 citations counted in INSPIRE as of 07 Nov 2013\n\\bibitem{Ross:2012nr}\n  G.~G.~Ross, K.~Schmidt-Hoberg and F.~Staub,\n  %``The Generalised NMSSM at One Loop: Fine Tuning and Phenomenology,''\n  JHEP {\\bf 1208} (2012) 074\n  [arXiv:1205.1509 [hep-ph]].\n  %%CITATION = ARXIV:1205.1509;%%\n  %37 citations counted in INSPIRE as of 07 Nov 2013\n\n%\\cite{King:2012is}\n\\bibitem{King:2012is}\n  S.~F.~King, M.~Muhlleitner and R.~Nevzorov,\n  %``NMSSM Higgs Benchmarks Near 125 GeV,''\n  Nucl.\\ Phys.\\ B {\\bf 860} (2012) 207\n  [arXiv:1201.2671 [hep-ph]].\n  %%CITATION = ARXIV:1201.2671;%%\n  %106 citations counted in INSPIRE as of 29 Nov 2013\n\n%\\cite{Ellwanger:2006rn}\n\\bibitem{Ellwanger:2006rn}\n  U.~Ellwanger and C.~Hugonie,\n  %``NMSPEC: A Fortran code for the sparticle and Higgs masses in the NMSSM with GUT scale boundary conditions,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 177} (2007) 399\n  [hep-ph/0612134].\n  %%CITATION = HEP-PH/0612134;%%\n  %81 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Staub:2009bi}\n\\bibitem{Staub:2009bi} \n  F.~Staub,\n  %``From Superpotential to Model Files for FeynArts and CalcHep/CompHep,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 181}, 1077 (2010)\n  [arXiv:0909.2863 [hep-ph]].\n  %%CITATION = ARXIV:0909.2863;%%\n  %64 citations counted in INSPIRE as of 12 Oct 2013\n\n%\\cite{Staub:2010jh}\n\\bibitem{Staub:2010jh} \n  F.~Staub,\n  %``Automatic Calculation of supersymmetric Renormalization Group Equations and Self Energies,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 182}, 808 (2011)\n  [arXiv:1002.0840 [hep-ph]].\n  %%CITATION = ARXIV:1002.0840;%%\n  %60 citations counted in INSPIRE as of 12 Oct 2013\n\n%\\cite{Staub:2012pb}\n\\bibitem{Staub:2012pb} \n  F.~Staub,\n  %``SARAH 3.2: Dirac Gauginos, UFO output, and more,''\n  Computer Physics Communications {\\bf 184}, pp. 1792 (2013)\n  [Comput.\\ Phys.\\ Commun.\\  {\\bf 184}, 1792 (2013)]\n  [arXiv:1207.0906 [hep-ph]].\n  %%CITATION = ARXIV:1207.0906;%%\n  %19 citations counted in INSPIRE as of 12 Oct 2013\n\n%\\cite{Staub:2013tta}\n\\bibitem{Staub:2013tta} \n  F.~Staub,\n  %``SARAH 4: A tool for (not only SUSY) model builders,''\n  arXiv:1309.7223 [hep-ph].\n  %%CITATION = ARXIV:1309.7223;%%\n  %2 citations counted in INSPIRE as of 12 Oct 2013\n\n%\\cite{Bharucha:2013ela}\n\\bibitem{Bharucha:2013ela}\n  A.~Bharucha, A.~Goudelis and M.~McGarrie,\n  %``En-gauging Naturalness,''\n  arXiv:1310.4500 [hep-ph].\n  %%CITATION = ARXIV:1310.4500;%%\n  %2 citations counted in INSPIRE as of 04 Dec 2013\n\n%\\cite{Allanach:2008qq}\n\\bibitem{Allanach:2008qq} \n  B.~C.~Allanach, C.~Balazs, G.~Belanger, M.~Bernhardt, F.~Boudjema, D.~Choudhury, K.~Desch and U.~Ellwanger {\\it et al.},\n  %``SUSY Les Houches Accord 2,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 180}, 8 (2009)\n  [arXiv:0801.0045 [hep-ph]].\n  %%CITATION = ARXIV:0801.0045;%%\n  %177 citations counted in INSPIRE as of 21 Sep 2013\n%\\cite{Ellwanger:2005dv}\n\\bibitem{Ellwanger:2005dv}\n  U.~Ellwanger and C.~Hugonie,\n  %``NMHDECAY 2.0: An Updated program for sparticle masses, Higgs masses, couplings and decay widths in the NMSSM,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 175} (2006) 290\n  [hep-ph/0508022].\n  %%CITATION = HEP-PH/0508022;%%\n  %193 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Muhlleitner:2003vg}\n\\bibitem{Muhlleitner:2003vg}\n  M.~Muhlleitner, A.~Djouadi and Y.~Mambrini,\n  %``SDECAY: A Fortran code for the decays of the supersymmetric particles in the MSSM,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 168} (2005) 46\n  [hep-ph/0311167].\n  %%CITATION = HEP-PH/0311167;%%\n  %204 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Das:2011dg}\n\\bibitem{Das:2011dg}\n  D.~Das, U.~Ellwanger and A.~M.~Teixeira,\n  %``NMSDECAY: A Fortran Code for Supersymmetric Particle Decays in the Next-to-Minimal Supersymmetric Standard Model,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 183} (2012) 774\n  [arXiv:1106.5633 [hep-ph]].\n  %%CITATION = ARXIV:1106.5633;%%\n  %14 citations counted in INSPIRE as of 07 Nov 2013\n\n%\\cite{Sjostrand:2007gs}\n\\bibitem{Sjostrand:2007gs}\n  T.~Sjostrand, S.~Mrenna and P.~Z.~Skands,\n  %``A Brief Introduction to PYTHIA 8.1,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 178} (2008) 852\n  [arXiv:0710.3820 [hep-ph]].\n  %%CITATION = ARXIV:0710.3820;%%\n  %914 citations counted in INSPIRE as of 06 Nov 2013\n%\\cite{Belanger:2008sj}\n\\bibitem{Belanger:2008sj}\n  G.~Belanger, F.~Boudjema, A.~Pukhov and A.~Semenov,\n  %``Dark matter direct detection rate in a generic model with micrOMEGAs 2.2,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 180} (2009) 747\n  [arXiv:0803.2360 [hep-ph]].\n  %%CITATION = ARXIV:0803.2360;%%\n  %349 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Allanach:2009bv}\n\\bibitem{Allanach:2009bv}\n  B.~C.~Allanach and M.~A.~Bernhardt,\n  %``Including R-parity violation in the numerical computation of the spectrum of the minimal supersymmetric standard model: SOFTSUSY,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 181} (2010) 232\n  [arXiv:0903.1805 [hep-ph]].\n  %%CITATION = ARXIV:0903.1805;%%\n  %22 citations counted in INSPIRE as of 07 Nov 2013\n%\\cite{Allanach:2011de}\n\\bibitem{Allanach:2011de}\n  B.~C.~Allanach, C.~H.~Kom and M.~Hanussek,\n  %``Computation of Neutrino Masses in R-parity Violating Supersymmetry: SOFTSUSY3.2,''\n  Comput.\\ Phys.\\ Commun.\\  {\\bf 183} (2012) 785\n  [arXiv:1109.3735 [hep-ph]].\n  %%CITATION = ARXIV:1109.3735;%%\n  %4 citations counted in INSPIRE as of 07 Nov 2013\n\\bibitem{Degrassi:2009yq} \n  G.~Degrassi and P.~Slavich,\n  %``On the radiative corrections to the neutral Higgs boson masses in the NMSSM,''\n  Nucl.\\ Phys.\\ B {\\bf 825}, 119 (2010)\n  [arXiv:0907.4682 [hep-ph]].\n  %%CITATION = ARXIV:0907.4682;%%\n  %35 citations counted in INSPIRE as of 21 Sep 2013\n%\\cite{MV94}\n\\bibitem{MV94} \n  S.~P.~Martin and M.~T.~Vaughn,\n  %``Two loop renormalization group equations for soft supersymmetry breaking couplings,''\n  Phys.\\ Rev.\\ D {\\bf 50}, 2282 (1994)\n  [Erratum-ibid.\\ D {\\bf 78}, 039903 (2008)]\n  [hep-ph/9311340].\n  %%CITATION = HEP-PH/9311340;%%\n  %568 citations counted in INSPIRE as of 24 Sep 2013\n\n%\\cite{Yam94}\n\\bibitem{Yam94} \n  Y.~Yamada,\n  %``Two loop renormalization group equations for soft SUSY breaking scalar interactions: Supergraph method,''\n  Phys.\\ Rev.\\ D {\\bf 50}, 3537 (1994)\n  [hep-ph/9401241].\n  %%CITATION = HEP-PH/9401241;%%\n  %225 citations counted in INSPIRE as of 24 Sep 2013\n\\bibitem{Sper13} \n  M.~Sperling, D.~St\\\"ockinger and A.~Voigt,\n  %``Renormalization of vacuum expectation values in spontaneously broken gauge theories,''\n  JHEP {\\bf 1307}, 132 (2013)\n  [arXiv:1305.1548 [hep-ph]].\n  %%CITATION = ARXIV:1305.1548;%%\n  %4 citations counted in INSPIRE as of 14 Oct 2013\n\n\\bibitem{Sper13-2} \n  M.~Sperling, D.~St\\\"ockinger and A.~Voigt,\n  %``Renormalization of vacuum expectation values in spontaneously broken gauge theories: Two-loop results,''\n  arXiv:1310.7629 [hep-ph].\n  %%CITATION = ARXIV:1310.7629;%%\n\\bibitem{Pierce:1997zz}\nD.~M. Pierce, J.~A. Bagger, K.~Matchev, and R.~jie Zhang, {\\it Precision\n  corrections in the minimal supersymmetric standard model},  {\\em Nucl. Phys.}\n  {\\bf B491} (1997) 3--67, \n[{\\tt hep-ph/9606211}].\n  %\\cite{Staub:2010ty}\n\\bibitem{Staub:2010ty} \n  F.~Staub, W.~Porod and B.~Herrmann,\n  %``The Electroweak sector of the NMSSM at the one-loop level,''\n  JHEP {\\bf 1010}, 040 (2010)\n  [arXiv:1007.4049 [hep-ph]].\n  %%CITATION = ARXIV:1007.4049;%%\n  %28 citations counted in INSPIRE as of 12 Oct 2013\n\\bibitem{flexi-susy} \nP.~Athron, Jae-hyeon Park, D.~Stockinger and A.~Voigt, {\\it Flexible Supersymmetry}, In development, \\\\\nhttps://github.com/Expander/FlexibleSUSY\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n%\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "471632ff1d70ecb4817c9e2095ae42101534d491", "size": 99843, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "contrib/MassSpectra/MSSM-SoftSUSY/softsusy-3.5.1/doc/nmssmManual.tex", "max_stars_repo_name": "aaronvincent/gambit_aaron", "max_stars_repo_head_hexsha": "a38bd6fc10d781e71f2adafd401c76e1e3476b05", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-08T20:05:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-26T07:57:56.000Z", "max_issues_repo_path": "contrib/MassSpectra/MSSM-SoftSUSY/softsusy-3.5.1/doc/nmssmManual.tex", "max_issues_repo_name": "aaronvincent/gambit_aaron", "max_issues_repo_head_hexsha": "a38bd6fc10d781e71f2adafd401c76e1e3476b05", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-10-19T09:56:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-28T06:12:03.000Z", "max_forks_repo_path": "contrib/MassSpectra/MSSM-SoftSUSY/softsusy-3.5.1/doc/nmssmManual.tex", "max_forks_repo_name": "aaronvincent/gambit_aaron", "max_forks_repo_head_hexsha": "a38bd6fc10d781e71f2adafd401c76e1e3476b05", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2020-09-08T02:23:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-23T08:48:04.000Z", "avg_line_length": 43.4856271777, "max_line_length": 396, "alphanum_fraction": 0.6883106477, "num_tokens": 38009, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4311466808746271}}
{"text": "\\documentclass{article}\n%\\usepackage{arxiv}\n%\\usepackage[T1,T2A]{fontenc}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsfonts}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{lipsum}\n\\usepackage{graphicx}\n\\usepackage{doi}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}[theorem]{Lemma}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\n\\usepackage{babel,csquotes,newcent,textcomp}\n\\usepackage[backend=biber,sortcites]{biblatex}\n\n\\usepackage{capt-of}\n\n\n\\usepackage{lipsum}\n\\title{Stochastic Newton with Arbitrary Sampling}\n\n\\author{ Igor ~Melnikov\t\\\\\n\tMoscow Institute of Physics and Technology\\\\\n\tDolgoprudny, Russia \\\\\n\t\\texttt{melnikov.ia@phystech.edu} \\\\\n\t%% examples of more authors\n\t\\and\n\tRustem Islamov \\\\\n\tInstitut Polytechnique de Paris\\\\\n\tPalaiseau, France \\\\\n\t\\texttt{rustem.islamov@ip-paris.fr} \\\\\n}\n\n\\addbibresource{mybib.bib}\n\\begin{document}\n\\nocite{*}\n\\maketitle\n\n\\begin{abstract}\nWe analyse stochastic Newton-type methods for solving Empirical Risk Minimization problem. We prove fast local convergence rates independent of the condition number. Unlike most other stochastic variants of second order methods, which require the evaluation of a large number of gradients and/or Hessians in each iteration to guarantee convergence, the method do not have this shortcoming. We investigate the performance of the method by applying existing sampling strategies.\n\\end{abstract}\n\n\\section{Introduction}\n\\begin{equation}\\label{eq:problem}\n    \\min\\limits_{x\\in \\mathbb{R}^d} \\left[f\\left(x\\right):=\\cfrac{1}{n}\\sum\\limits_{i=1}^{n}f_i\\left(x\\right)\\right].\n\\end{equation}\nHere $n$ is the number of data points that is typically extremely large in real problems; $d$ is the number of model parameters. Ususally, $f_i$ denotes the value of a loss function on $i$-th data point $(a_i, b_i)$. One of the examples of the problem that has the form of \\eqref{eq:problem} is Logistic Regression problem where\n\\begin{equation}\n    f_i(x) = \\log\\left(1+\\exp(-b_i a_i^\\top x )\\right),\n\\end{equation}\nwhere $a_i \\in \\mathbb{R}^d$ and $b_i \\in \\{-1,1\\}.$\n\nAs $n$ is large the problem~\\eqref{eq:problem} is typically solved by First-order methods that uses only one data point per iteration. These methods are extensively studied \\cite{litlink1} and there are a wide variety of variations of such techniques. In particular, the Stochastic Gradient Descent(SGD) is often used, the distinguishing feature of which is cheap iterations independent of $n$. Nevertheless, SGD with constant-stepsize has a number of disadvantages, the main of which is that it converges only up to the neighbourhood of the solution, not the exact solution. This problem arises since stochastic gradient estimator has non-zero variance. Radius of this convergence area is proportional to the variance of the stochastic gradient. The so-called variance-reduced methods \\cite{svrg, saga} are used to solve this problem. They have the same iteration cost as SGD, but now the algorithm converges to the exact solution. However, all first-order methods known to us are characterized by the dependence of the required number of iterations on the condition number\\footnote{For a continuously Differentiable function $f$ condition number is defined as $\\lim\\limits_{\\varepsilon \\rightarrow 0} \\sup\\limits_{\\left\\|\\partial x\\right\\| \\leq \\varepsilon} \\frac{\\left\\|\\partial f\\left(x\\right)\\right\\|}{\\left\\|\\partial x\\right\\|}$,\\\\ for $L$-smooth and $\\mu$-convex function the condition number is $\\frac{L}{\\mu}$}. This makes impossible using SGD and its variants for ill-conditioned problems.\n\nIn classic optimization one of the solutions is to use second-order information about the objective. Classic Newton's method adapts to the curvature of the problem and thereby decrease the dependence on the condition number. The step of Newton's method has the following form\n\n\\begin{equation}\n    x^{k+1} = x^k - \\left(\\nabla^2f\\left(x^k\\right)\\right)^{-1}\\nabla f\\left(x^k\\right)\n\\end{equation}\n\nIn the case of ERM we need to compute $n$ Hessians per iteration which is extremely costly in practice. Our desire is to use only a few Hessians in each iteration. One of the most popular directions is so called Subsampled Stochastic Newton's methods \\cite{litlink7}. Despite first-order methods, these methods are poorly understood, and the theory usually requires a large batch sizes. To the best of our knowledge there are just a few works that provable work with arbitrary batch sizes \\cite{litlink3, litlink5, litlink6}.\n\nIn this work we focus on the Algorith 1 of  \\cite{litlink4}. They presentes the following algorithm:\n\n\\begin{algorithm}\\label{eq:algorithm}\n\\caption{Stochastic Newton (SN)}\\label{alg:cap}\n\\begin{algorithmic}\n\\State {$\\textbf{Initialize:}$ Choose starting iterates $w_1^0, w_2a^0, \\dots, w_n^0 \\in \\mathbb{R}^d$ and minibatch size $\\tau \\in \\{1, 2, \\dots, n\\}$}\n\\For {$k = 1, \\dots$}\n    \\State {$x^{k+1} = \\left(\\sum\\limits_{i=1}^n\\nabla^2f_i\\left(w_i^k\\right)\\right)^{-1}\\sum\\limits_{i=1}^n \\left(\\nabla^2f_i\\left(x^k\\right)w_i^k - \\nabla f_i\\left(w_i^k\\right)\\right)$}\n    \\State {Choose a subset $k \\subseteq \\{1,\\dots, n\\}$ of size $\\tau$ uniformly at random}\n    \\State {\n        $w_i^{t+1}= \n    \\begin{cases}\n        w_i^{t} &i \\not\\in S^t\\\\\n        x^{t + 1} &i \\in S^t\\\\\n     \\end{cases}$\n}\n\\EndFor\n\\end{algorithmic}\n\\end{algorithm}\n\n\n% \\begin{equation*}\n% \\begin{multlined}\n% w^0_i = x^0 \\text{, for } i \\in \\overline{1, n}. \\\\\n% w_i^{t+1}= \n%  \\begin{cases}\n%   w_i^{t} &i \\not\\in S^t\\\\\n%   x^{t + 1} &i \\in S^t\\\\\n%  \\end{cases}\n%  \\end{multlined}\n% \\end{equation*}\n% $S^k$ is uniformly chosen random subset of $\\{1, \\dots, n\\}$ with size $\\tau$. \\\\\n\n% The algorithms looks the following way:\n\n% \\begin{equation}\n% \\begin{multlined}\n%     x^{k+1} = \\left(\\sum\\limits_{i=1}^n\\nabla^2f_i\\left(w_i^k\\right)\\right)^{-1}\\sum\\limits_{i=1}^n \\left(\\nabla^2f_i\\left(x^k\\right)w_i^k - \\nabla f_i\\left(w_i^k\\right)\\right)\n% \\end{multlined}\n% \\end{equation}\n\nWe investigate how the sampling strategies affect the performance of Algorithm \\eqref{eq:algorithm}. In practice, the uniform sampling is not the best choice, and we need to use another strategies how to choose a set $S^t$. \n\n\\section{Problem Statement}\n\nAssume we have $n$ training points $\\left(a_i, b_i\\right)$ for $i \\in \\overline{1, n}$. We also assume $n$ to be large. Let $f_i\\left(x\\right)$ be a loss function on $i$-th training point . We analyze second order methods solving Empirical Risk Minimization problem of the form.\n\nOne of the examples of the problem that has the form of \\eqref{eq:problem} is Logistic Regression problem where\n\\begin{equation}\n    f_i(x) = \\log\\left(1+\\exp(-b_i a_i^\\top x )\\right),\n\\end{equation}\nwhere $a_i \\in \\mathbb{R}^d$ and $b_i \\in \\{-1,1\\}.$\n\n\n\\begin{equation}\n    \\min\\limits_{x\\in R} \\left[f\\left(x\\right):=\\cfrac{1}{n}\\sum\\limits_{i=1}^{n}f_i\\left(x\\right)\\right].\n\\end{equation}\n\n\\section{Experiment Plan}\n\nThe experiment applies Algorithm 1 to minimize the logistic regression risk function with $l_2$ regularization.\n\n\\begin{equation}\n    f_i(x) = \\log\\left(1+\\exp(-b_i a_i^\\top x )\\right) + \\frac{\\lambda}{2}\\|x\\|,\n\\end{equation}\n\nThe main experiment is to establish the dependence of convergence accuracy on the size of the batch. The goal is to establish that conditional number does not significantly affect convergence. To do this, it is sufficient to establish that the curves are not very different. \n\nWe generate the synthetic data by the make classification function of the scikit-learn library, where n = 500 and d = 5. Each row of the data matrix is normalized such that $\\|a_i\\| = 1$. We run experiments for $\\lambda = \\{10^{-1}, 10^{-3}, 10^{-4}\\}$, which leads to conditional number differ more than in 10 times.\nInitial point $x^0$ is taken as the result of GD in 30 iteration.\n\n\\section{Preliminary report}\nConvergence has been established. For lambdas 0.001 and 0.0001 the difference in accuracy at 100th iteration is less than in 1.2 times for all butch sizes. However for lambda 0.1 accuracy is much higher - that is a fact to investigate in more detail.\n\n\\begin{figure}\n    \\includegraphics[width=120mm]{convergence_0-1.png}\n    \\captionof{figure}{$\\lambda = 0.1$}\n\\end{figure}\n\n\\begin{figure}\n    \\includegraphics[width=120mm]{convergence_0-001.png}\n    \\captionof{figure}{$\\lambda = 0.001$}\n\\end{figure}\n\n\n\\begin{figure}\n    \\includegraphics[width=120mm]{convergence_0-0001.png}\n    \\captionof{figure}{$\\lambda = 0.0001$}\n\\end{figure}\n\n\n\\section{Run Basic Code}\nWe have implemented algorithm 1. \n\nCompetitive models for our algorithm were described in Introduction section with links on description. These models are  Gradient Descent, Stochastic Gradient Descent, variance-reduced methods, classical Newton's method.\n\nA description of the algorithm in the form of pseudocode is given in the introduction.\n\\section{Theoretical part}\n\nThe proof was based on the proof in the article 1.\n\n\\begin{theorem} Assume that every $f_i$ is $µ$-strongly convex and has $H$-Lipschitz Hessian and consider\nthe following Lyapunov function:\n\\begin{equation}\n    W^k \\overset{def}{=} \\frac{1}{n}\\sum\\limits_{i=1}^{n}\\|w_i^k - x^\\star\\|.\n\\end{equation}\n\nThen for the random iterates of NS Algorithm we have the recursion:\n\\begin{equation}\n    \\mathbf{E}_k W^{k + 1} \\leq \\left(1 - \\frac{\\tau}{n} +\n    \\frac{\\tau}{n}\\left(\\frac{H}{2\\mu}\\right)^2W^k\\right)W^k.\n\\end{equation}\n\nFurthermore if $\\|w_i^0 - x^\\star\\| \\leq \\frac{\\mu}{H}$, for $i \\in \\{1, \\dots, n\\}$ and $\\min_{i \\in \\{1, \\dots, n\\}}{p_i} \\geq \\frac{\\tau}{4n}$, then for some $\\lambda < 1$\n\\begin{equation}\n    \\mathbf{E}_k W^{k + 1} \\leq \\lambda W^k.\n\\end{equation}\n\\end{theorem}\n\nThis theorem implies at least linear convergence rate for all $\\tau$ in our algorithm.\nLet's denote by $p_i$ probability of i be in $S$. $|sum|limits_{i=1}^n p_i = \\tau$\n\n\\begin{lemma} (taken from article 1.).\nLet $f_i$ be $\\mu$-strongly convex and have $H$-Lipschitz Hessian for all $i = 1, \\dots, n$. Then\nthe iterates of the Algorithm satisfy:\n\\begin{equation}\n    \\|x^k - x^\\star\\| \\leq \\frac{H}{2\\mu}W^k.\n\\end{equation}\n\\end{lemma}\n\n\\begin{lemma}\nIf $\\|w_i^0 - x^\\star\\| \\leq \\frac{\\mu}{H}$, for $i \\in \\{1, \\dots, n\\}$, then for all $k$, for $i \\in \\{1, \\dots, n\\}$\n\\begin{equation}\n    \\|w_i^k - x^\\star\\|^2 \\leq \\left(\\frac{\\mu}{H}\\right)^2\n\\end{equation}\n\\end{lemma}\n\n\\begin{lemma} The random iterates of the Algorithms satisfy the identity\n\\end{lemma}\nProof:\n\\begin{equation*}\n\\begin{split}\n    \\mathbf{E}_k W^{k + 1} = \\frac{1}{n}\\sum\\limits_{i=1}^{n}\\mathbf{E}_k\\|w_i^{k + 1} - x^\\star\\| =\n     \\frac{1}{n}\\sum\\limits_{i=1}^{n}p_i\\|x^k - x^\\star\\| + \\frac{1}{n}\\sum\\limits_{i=1}^{n}(1 - p_i)\\|w_i^k - x^\\star\\| = \\\\\n     \\frac{\\tau}{n}\\|x^k - x^\\star\\| + \\frac{1}{n}\\sum\\limits_{i=1}^{n}(1 - p_i)\\|w_i^k - x^\\star\\| \\leq\n     \\frac{\\tau}{n}\\left(\\frac{H}{2\\mu}\\right)^2\\left(W^k\\right)^2 + \\frac{1}{n}\\sum\\limits_{i=1}^{n}(1 - p_i)\\|w_i^k - x^\\star\\| \\leq \\\\\n     \\frac{1}{4}\\frac{\\tau}{n}W^k + \\frac{1}{n}\\sum\\limits_{i=1}^{n}(1 - p_i)\\|w_i^k - x^\\star\\| \\leq \\frac{1}{4}\\frac{\\tau}{n}W^k + \\frac{1}{n}(1 - \\min_{i \\in \\{1, \\dots, n\\}}{p_i})\\sum\\limits_{i=1}^{n}\\|w_i^k - x^\\star\\|  = \\\\ \\frac{1}{4}\\frac{\\tau}{n}W^k + (1 - \\min_{i \\in \\{1, \\dots, n\\}}{p_i})W^k =  \\left(\\frac{1}{4}\\frac{\\tau}{n} + 1 - \\min_{i \\in \\{1, \\dots, n\\}}{p_i}\\right)W^k.\n\\end{split}\n\\end{equation*}\n\n\\section{Analysing error}\n\nWe measure speed up of improved sample strategy. So we measures first $n$ satisfying condition $A_n/A_0 < r$.\nWhere $r$ is maximum of minimal ratio for each algorithms.\n\n\\includegraphics[width=90mm]{speed_lambda.png}\n\n\\includegraphics[width=90mm]{speed_batch_size.png}\n\n\nIn the table below you can find average speed up for given batch size ($\\lambda$ was taken on as linear grid on interval from 0 to 0.1).\n\n\\begin{tabular}{ |c|c|c|c|c| }\n \\hline\n Batch size & 1 & 2 & 4 & 8 \\\\\n \\hline\n Speed up & 2.42 & 1.78 & 1.62 & 1.39 \\\\\n \\hline\n\\end{tabular}\n\n\n\\newpage\n\\addcontentsline{toc}{section}{Список используемой литературы}\n\n%далее сам список используевой литературы\n\n\n\\printbibliography\n\n\\end{document}\n\n\n", "meta": {"hexsha": "0a83fb637ebc3f8757679ea6d9a9135b159b235a", "size": 12208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/Melnikov2022StochasticNewtonWithArbitrarySampling.tex", "max_stars_repo_name": "Intelligent-Systems-Phystech/2022-Project-101", "max_stars_repo_head_hexsha": "8e5504776c93d7037a2a30bf49d24dc5f2d216b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/Melnikov2022StochasticNewtonWithArbitrarySampling.tex", "max_issues_repo_name": "Intelligent-Systems-Phystech/2022-Project-101", "max_issues_repo_head_hexsha": "8e5504776c93d7037a2a30bf49d24dc5f2d216b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/Melnikov2022StochasticNewtonWithArbitrarySampling.tex", "max_forks_repo_name": "Intelligent-Systems-Phystech/2022-Project-101", "max_forks_repo_head_hexsha": "8e5504776c93d7037a2a30bf49d24dc5f2d216b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-01T22:50:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T22:50:39.000Z", "avg_line_length": 47.5019455253, "max_line_length": 1499, "alphanum_fraction": 0.7089613368, "num_tokens": 3997, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4311414792356753}}
{"text": "\\chapter{Alphabet (Sigma) and \\acro{other}/\\acro{unknown} Characters}\n\n\\label{app:other}\n\nKleene automatically keeps track of the set of symbols that are ``known''\nto each network, and this set is known traditionally as the alphabet or \\emph{sigma}.\nEach Kleene network carries its own private sigma.\\footnote{The OpenFst\nlibrary does not maintain a private sigma for each network; this\nfunctionality is added at the Java level of Kleene.} In the simple case \n\n\\begin{Verbatim}[fontsize=\\small]\n$v = abc ;\n\\end{Verbatim}\n\n\\noindent\nthe sigma of network \\$v will contain the symbols \\emph{a}, \\emph{b},\n\\emph{c} and no other symbols.  The Kleene programmer never has to\ndeclare sigmas manually.\n\nIn Kleene regular expressions, the . (dot) special syntactic symbol\nsemantically represents \\emph{any} symbol, and has a non-trivial\nsemantics.  Intuitively, the notion of \\emph{any} symbol properly\nincludes all known symbols in the sigma, plus the infinite set of\n\\acro{other}, also known as \\acro{unknown}, symbols.  We will use the\nterm \\acro{other} herein. \n\nKleene transducers must also distinguish between the \\emph{identity\nmapping} of \\acro{other} symbols vs.\\@ the \\emph{non-identity mapping} of\n\\acro{other} symbols.  The identity mapping maps any \\acro{other} symbol\nto itself, while the non-identity mapping maps any \\acro{other} symbol to\nany \\acro{other} symbol \\emph{except} itself.  The difference is best\nseen in concrete examples.\n\n\nWhen . (dot) appears in a regular expression like\n\n\\begin{Verbatim}[fontsize=\\small]\n$w = . ;\n\\end{Verbatim}\n\n\\noindent\nit is interpreted to produce the arc label\n\\acro{other\\_id}:\\acro{other\\_id}, which represents the \\emph{identity\nmapping} of \\acro{other} symbols, i.e.\\@ the mapping of any \\acro{other}\nsymbol to itself.  As the sigma of ``known'' symbols in \\$w is empty, the\nresulting network maps \\emph{a} to \\emph{a}, \\emph{b} to \\emph{b},\n\\emph{c} to \\emph{c}, and similarly for all possible symbols---but not\n\\emph{a} to \\emph{b} because this would be a non-identity mapping.\n\nTo denote the mapping of any symbol to any symbol, including itself, the\nKleene syntax .:. is used in regular expressions, e.g.\n\n\\begin{Verbatim}[fontsize=\\small]\n$y = .:. ;\n\\end{Verbatim}\n\n\\noindent\nThe resulting network for \\$y contains a start state and a final state,\nlinked by two arcs labeled \\acro{other\\_id}:\\acro{other\\_id} and\n\\acro{other\\_nonid}:\\acro{other\\_nonid}, respectively.  As the name\nimplies, \\acro{other\\_nonid}:\\acro{other\\_nonid} represents the\nnon-identity mapping of \\acro{other} symbols.  The two arcs therefore\nhandle the cases of identity mapping and non-identity mapping.\n\nIn Kleene networks, the symbol coverage of \\acro{other\\_id} and\n\\acro{other\\_nonid} are identical; it can be thought of as \\acro{other},\ni.e.\\@ the set of all possible symbols not in the sigma of the network;\nthe labels \\acro{other\\_id}:\\acro{other\\_id} and\n\\acro{other\\_nonid}:\\acro{other\\_nonid} differ only in their mapping\nbehavior: identity mapping vs.\\@ non-identity mapping.\n\nWhen two networks are combined, via operations like union, concatenation\nand composition, the result is a new network with its own sigma.  Where\none or both networks to be combined ``contain \\acro{other}'', the\noperation, and the calculation of the new sigma, can be quite\ncomplicated, but the programmer never needs to worry about it.\n\nThe notion of \\emph{any symbol}, denoted . (for ``map any other symbol to\nitself'') or .:. (``map any other symbol to any other symbol, including\nitself'') are syntactic notions that appear in regular expressions.  The\nnotions of identity mapping, non-identity mapping and the labels\n\\acro{other\\_id}:\\acro{other\\_id} and\n\\acro{other\\_nonid}:\\acro{other\\_nonid} belong to underlying networks.  \n\nThe arc labels \\acro{other\\_id} and \\acro{other\\_nonid} are special, and\nthese two special symbols should not appear in regular expressions.\n\n\n", "meta": {"hexsha": "19752abc95d4af877b56bb79e702340d014ac7d2", "size": 3895, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user/kleene/app1.tex", "max_stars_repo_name": "cscott/kleene-lang", "max_stars_repo_head_hexsha": "938beb074bcf3706852630881da15e5badb730d5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2015-01-13T05:56:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-08T04:23:09.000Z", "max_issues_repo_path": "doc/user/kleene/app1.tex", "max_issues_repo_name": "cscott/kleene-lang", "max_issues_repo_head_hexsha": "938beb074bcf3706852630881da15e5badb730d5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/user/kleene/app1.tex", "max_forks_repo_name": "cscott/kleene-lang", "max_forks_repo_head_hexsha": "938beb074bcf3706852630881da15e5badb730d5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-06-20T03:29:18.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-24T12:16:26.000Z", "avg_line_length": 43.7640449438, "max_line_length": 85, "alphanum_fraction": 0.7581514763, "num_tokens": 1075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4311414655843741}}
{"text": "\\newpage\n\\section{Entropy Source: Rationale and Discussion}\n\\label{sec:entropy-appendix}\n\n    The security of cryptographic systems is based on secret bits and keys.\n    To prevent guessing, these bits need to be random, so they come from\n    True Random Number Generators (TRNGs).\n\n    As a fundamental security function, the generation of random numbers is\n    governed by numerous standards and technical requirements.\n\n\\subsection{Standards and Terminology}\n\n    A driving design goal for our architecture was for it to be easy to\n    implement, yet compatible with current versions of FIPS 140-3\n    \\cite{NI19} and NIST SP 800-90B \\cite{TuBaKe+18}, significantly\n    updated standards that are only coming into use in 2020. Naturally,\n    the architecture should also support other RNG frameworks such as\n    German AIS 20 / 31 \\cite{KiSc01,KiSc11} which is widely used\n    in Common Criteria evaluations.\n\n    These standards set many of the technical requirements for the design,\n    and we use their terminology if possible. Note that FIPS 140-3 /\n    SP 800-90B (our main target) imposes requirements on min-entropy, while\n    AIS-31 discusses Shannon entropy as well.\n\n    These standards set many of the technical requirements for the design,\n    and we use their terminology if possible.\n    The delineation of various components is illustrated in Figure\n    \\ref{fig:rng_tikz}.\n\n\n    \\subsubsection{Entropy Source (ES)}\n    \\label{sec:intro-es}\n    Physical sources of true randomness are called Entropy Sources (ES)\n    \\cite{TuBaKe+18}. They are built by sampling and processing data\n    from a noise source (Section \\ref{sec:noise-sources}). Since these\n    are directly based on natural phenomena and are subject to\n    environmental conditions (which may be adversarial), they require\n    features and sensors that monitor the ``health'' and quality of those\n    sources. See Section \\ref{sec:security-controls} for a discussion about\n    such security controls.\n\n    \\subsubsection{Conditioning}\n    \\label{sec:intro-cond}\n    Raw physical randomness (noise) sources are rarely statistically\n    perfect and some generate very large amounts of bits, which need to be\n    ``debiased'' and reduced to a smaller number of bits. This process is\n    called conditioning. A secure hash function is an example of a\n    cryptographic conditioner. It is important to note that even though\n    hashing may make the output look more random, it does not increase its\n    entropy content.\n\n    Non-cryptographic conditioners and extractors such as von Neumann's\n    ``debiased coin tossing'' \\cite{Ne51} are easier to implement\n    efficiently but may reduce entropy content (in individual bits removed)\n    more than cryptographic hashes which mix the input entropy very efficiently.\n    However, they are not based on computational hardness assumptions and\n    are therefore inherently more future proof. See Section\n    \\ref{sec:noncrypto} for a more detailed discussion.\n\n    \\subsubsection{Pseudorandom Number Generator (PRNG)}\n    \\label{sec:intro-prng}\n    Pseudorandom Number Generators (PRNGs) use deterministic mathematical\n    formulas to create a large amount of random numbers from a smaller\n    amount of ``seed'' randomness. PRNGs are divided into cryptographic and\n    non-cryptographic ones.\n\n    Non-cryptographic PRNGs, such as the linear-congruential generators\n    found in many programming libraries, may generate statistically\n    satisfactory random numbers but must never be used for cryptographic\n    keying. This is because they are not designed to resist\n    \\emph{cryptanalysis}; it is usually possible to take some output and\n    mathematically derive the ``seed'' or the internal state  of the PRNG\n    from it. This is a security problem since knowledge of the state\n    allows the attacker to compute future or past outputs.\n\n    \\subsubsection{Deterministic Random Bit Generator (DRBG)}\n    \\label{sec:intro-drbg}\n    Cryptographic PRNGs are also known as Deterministic Random Bit\n    Generators (DRBGs), a term used by SP 800-90A \\cite{BaKe15}. A strong\n    cryptographic algorithm such as AES \\cite{NI01} or SHA-2/3\n    \\cite{NI15,NI15A} is used to produce random bits from a seed. The secret\n    seed material is like a cryptographic key; determining the seed\n    from the DRBG output is as hard as breaking AES or a strong hash function.\n    This also illustrates that the seed/key needs to be long enough and\n    come from a trusted Entropy Source. The DRBG should still be frequently\n    refreshed (reseeded) for forward and backward security.\n\n\\begin{figure}[tb]\n    \\centering\n    \\input{../diagrams/rng_tikz.tex}\n    \\caption{PollEntropy provides an Entropy Source (ES) only, not a stateful\n        random number generator. As a result, it can support arbitrary\n        security levels. Cryptographic (AES, SHA-2/3) ISA Extension\n        instructions can be used to construct high-speed DRBGs that are\n        seeded from the entropy source.}\n%   \\Description{Illustration of PollEntropy at the ISA Boundary.}\n    \\label{fig:rng_tikz}\n\\end{figure}\n\n\\subsection{Specific Rationale and Considerations}\n\n    \\paragraph{(Sect. \\ref{sec:es-pollentropy}) PollEntropy:}\n    An entropy source does not require a high-bandwidth interface;\n    a single DRBG source initialization only requires 512 bits\n    (256 bits of entropy) and the DRBG state can be shared by any number of\n    callers. Once initiated, a DRBG requires new randomness only for the\n    purposes of forward security.\n\n    Without a polling-style mechanism the entropy source could hang for\n    thousands of cycles under some circumstances. The \\mnemonic{wfi} mechanism\n    (at least potentially) allows energy-saving sleep on MCUs and context\n    switching on a higher-end CPUs.\n\n    The reason for the particular \\verb|OPST| two-bit mechanism is to\n    provide redundancy. The ``fault'' bit combinations 11 (and 00) are more\n    likely for electrical reasons if feature discovery fails and the entropy\n    source is actually not available (this has happened to AMD \\cite{Sa19}).\n\n    The 16-bit bandwidth was a compromise motivated by the desire to\n    provide redundancy in the return value, some protection against\n    potential Power/EM leakage (further alleviated by the 2:1 cryptographic\n    conditioning discussed in Section \\ref{sec:req-entropy}), and the desire\n    to have all of the bits ``in the same place'' on both RV32 and RV64\n    architectures for programming convenience.\n\n    \\paragraph{(Sect. \\ref{sec:req-es}) \\S E1, Entropy Requirement:}\n    Rather than attempting to mathematically define the properties that the\n    entropy source output must satisfy, we define that it should\n    pass SP 800-90B evaluation and certification when conditioned\n    cryptographically (``perfectly'') in ratio 2:1. This is our ``safety\n    margin'' for non-cryptographic conditioners.\n\n    Note that the min-entropy assessment methodology in SP 800-90B\n    \\cite{TuBaKe+18} also has a safety margin in its confidence intervals,\n    and therefore there must be consistently \\emph{more than} 8 bits of\n    entropy per 16-bit word. In practice, we recommend the\n    distribution to be significantly closer to uniform to satisfy\n    possible additional use cases and AIS 20 / 31 \\cite{KiSc11}\n    requirements (if those can't be met with a software conditioner).\n\n    Note that the usage of a vetted conditioner (such as SHA-2/3) was\n    specified for technical reasons related to SP 800-90B itself;\n    non-vetted conditioners may offer similar security.\n\n    The 128-bit output block size was selected because that is the output\n    size of the CBC-MAC conditioner specified in \\cite{TuBaKe+18} and also\n    the smallest key size we expect to see in applications.\n\n    \\paragraph{(Sect. \\ref{sec:req-es}) \\S E2, IID Requirement:}\n    IID is an optional requirement in SP 800-90B \\cite{TuBaKe+18} but it\n    is needed to prevent information leakage between different entities that\n    possibly share the same entropy source. It also significantly\n    simplifies certification and vendor-independent driver development.\n    The \\mnemonic{pollentropy} instruction itself can be later expanded\n    to support non-IID sources (e.g., via a different immediate constant).\n\n    \\paragraph{(Sect. \\ref{sec:req-es}) \\S E3, Secret State Requirement:}\n    DRBGs can be used to feed other (virtual) DRBGs but that does not\n    increase the absolute amount of entropy in the system.\n    The entropy source must be able to support current and future security\n    standards and applications. The 256-bit requirement maps to\n    ``Category 5'' of NIST Post-Quantum Cryptography (4.A.5\n    ``Security Strength Categories'' in \\cite{NI16}) and TOP SECRET schemes\n    in Suite B and the newer U.S. Government CNSA Suite \\cite{NS15}.\n\n    {\\em Source anonymization.}\n    In some cases, an entropy source (or the circuit that interfaces it)\n    may have a uniquely identifiable hardware ``signature.'' This can be\n    harmless or even useful in some applications (as random sources may\n    exhibit PUF-like features) but highly undesirable in others (anonymized\n    virtualized environments and enclaves). A DRBG masks such\n    statistical features.\n\n    \\paragraph{(Sect. \\ref{sec:security-controls}) Security Controls:}\n    Our approach is informed by the experience of designing and implementing\n    cryptographic protocols. Some of the most devastating practical attacks\n    against real-life cryptosystems have used inconsequential-looking\n    additional information, such as padding error messages \\cite{BaFoKa+12}\n    or timing information \\cite{MoSuEi+20}. In cryptography, such\n    out-of-band information sources  are called ``oracles.''\n\n    This also applies to the raw noise source. The raw source interface has\n    been delegated to an optional vendor-specific test interface.\n    Importantly the test interface and the main interface should not be\n    operational at the same time.\n\n    \\begin{quote}\n    {\\it ``The noise source state shall be protected from adversarial\n        knowledge or influence to the greatest extent possible. The methods\n        used for this shall be documented, including a description of the\n        (conceptual) security boundary’s role in protecting the noise source\n        from adversarial observation or influence.''}\n    \\flushright --Noise Source Requirements, NIST SP 800-90B \\cite{TuBaKe+18}.\n    \\end{quote}\n\n    The role of the RISC-V ISA implementation is to try to ensure that the\n    hardware-software interface minimizes avenues for adversarial information\n    flow; all status information that is unnecessary in normal operation\n    should be eliminated. We specifically urge implementers against creating\n    unnecessary information flows (``status oracles'') via the custom bits\n    or to allow the instruction to disable or affect the TRNG output in any\n    significant way. All information flows and interaction mechanisms must\n    be considered from an adversarial viewpoint and implemented only if they\n    are truly necessary and their security impact can be fully understood.\n\n    For example, the entropy polling interface may not be ``constant time.''\n    The polling mechanism can be modeled as a rejection sampler; such a\n    timing oracle can reveal information about the noise source and the\n    rejection criteria, but usually not the random output itself.\n    If these are correlated, additional countermeasures are necessary.\n\n    \\paragraph{(Sect. \\ref{sec:security-controls}) \\S T1, On-demand testing:}\n    Interaction with hardware self-test mechanisms\n    from the software side should be minimal; the term ``on-demand'' does not\n    mean that the end-user or application program should be able to invoke\n    them in the field (the term is a throwback to an age of discrete,\n    non-autonomous crypto devices with human operators.)\n\n    \\paragraph{(Sect. \\ref{sec:security-controls}) \\S T2, Continuous checks:}\n    Physical attacks can occur while the device is running. The design\n    should avoid guiding such active attacks by revealing detailed\n    status information. Upon detection of an attack the default action\n    should be aimed at damage control -- to prevent weak crypto keys from\n    being generated.\n\n    The statistical nature of some tests makes ``type-1'' false\n    positives a possibility. There may also be requirements for signaling\n    of non-fatal alarms; AIS 31 specifies ``noise alarms'' that can go off\n    with non-negligible probability even if the device is functioning\n    correctly; these can be signaled with \\verb|BIST|.\n    There rarely is anything that can or should be done about a non-fatal\n    alarm condition in an operator-free, autonomous system.\n\n    The state of statistical runtime health checks (such as counters)\n    is potentially correlated with some secret keying material, hence\n    the zeroization requirement.\n\n    \\paragraph{(Sect. \\ref{sec:security-controls}) \\S T3, Fatal error states:}\n    These tests can complement other integrity and tamper resistance\n    mechanisms (See Chapter 18 of \\cite{An20} for examples).\n\n    Some hardware random generators are, by their physical construction,\n    exposed to relatively non-adversarial environmental and manufacturing\n    issues. However, even such  ``innocent'' failure modes may indicate\n    a  \\emph{fault attack} \\cite{KaScVe13} and therefore should be addressed\n    as a system integrity failure rather than as a diagnostic issue.\n\n    Security architects will understand to use\n    permanent or hard-to-recover ``security-fuse'' lockdowns only if the\n    threshold of a test is such that the probability of false-positive is\n    negligible over the entire device lifetime.\n\n\n\\subsection{Implementation Strategies}\n\n    When considering implementation options and trade-offs one must look\n    at the entire information flow since each step is interconnected.\n\n    \\begin{enumerate}\n    \\item   {\\bf A Noise Source} generates private, unpredictable signals\n            from stable and well-understood physical random events.\n    \\item   {\\bf Sampling} digitizes the noise signal into a raw stream of\n            bits. This raw data also needs to be protected by the design.\n    \\item   {\\bf Continuous health tests} ensure that the noise source\n            and its environment meet their operational parameters.\n    \\item   {\\bf Non-cryptographic conditioners} remove much of the bias\n            and correlation in input noise: Output entropy $\\gg 4$ bits/byte.\n    \\item   {\\bf Cryptographic conditioners} produce nearly full entropy\n            output, completely indistinguishable from ideal random.\n    \\item   {\\bf DRBG} takes in $\\geq 256$ bits of seed entropy as keying\n            material and uses a ``one way'' cryptographic process to rapidly\n            generate bits on demand (without revealing the seed/state).\n    \\end{enumerate}\n    Steps 1-4 (possibly 5) are considered to be part of the Entropy\n    Source (ES) and provided by the \\mnemonic{pollentropy} instruction.\n    Adding the software-side cryptographic steps 5-6 and control logic\n    complements it into a True Random Number Generator (TRNG).\n%   This information flow is illustrated by Figure \\ref{fig:rng_tikz}.\n\n    As a general rule, RISC-V specifies the ISA only. We provide some\n    additional requirements so that portable, vendor-independent middleware\n    and kernel components can be created. The actual hardware\n    implementation and certification is left to vendors and circuit designers;\n    the discussion in this section is purely informational.\n\n    While we do not require entropy source implementations to be\n    certified designs, we do expect that they behave in a compatible manner\n    and do not create unnecessary security risks to users. Self-evaluation\n    and testing following appropriate security standards is usually needed\n    to achieve this. NIST has made its SP 800-90B\\cite{TuBaKe+18} min-entropy\n    estimation package freely available\\footnote{EntropyAssessment:\n    \\url{https://github.com/usnistgov/SP800-90B_EntropyAssessment}} and\n    similar free tools are also available\\footnote{(In German)\n    AIS 31-Implementierung in JAVA:\n    \\url{https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Zertifizierung/Interpretationen/AIS_31_testsuit_zip}}\n    for AIS 31 \\cite{KiSc11}.\n\n\\subsubsection{Noise Sources}\n\\label{sec:noise-sources}\n\n    The theory of random signals and electrical noise became well\n    established in the post-World War II period \\cite{Ri44,Ri45,DaRo58}.\n    We will give some examples of common noise sources that can be\n    implemented in the processor itself (using standard cells).\n\n    \\paragraph{Ring Oscillators.}\n    The most common entropy source type in production use today is\n    based on ``free running'' ring oscillators and their timing jitter.\n    Here, an odd number of inverters is connected into a loop from which\n    noise source bits are sampled in relation to a reference clock\n    \\cite{BaLuMi+11}. The sampled bit sequence may be expected to be\n    relatively uncorrelated (close to IID) if the sample rate is suitably low\n    \\cite{KiSc11}. However further processing is usually required.\n\n    AMD \\cite{AM17}, ARM \\cite{AR17}, and IBM \\cite{LiBaBo+13} are\n    examples of ring oscillator TRNGs intended for high-security\n    applications.\n\n    There are related metastability-based generator designs such as\n    Transition Effect Ring Oscillator (TERO) \\cite{VaDr10}.\n    The differential/feedback Intel construction \\cite{HaKoMa12} is slightly\n    different but also falls into the same general metastable\n    oscillator-based category.\n\n    The main benefits of ring oscillators are: (1) They can be implemented\n    with standard cell libraries without external components --\n    and even on FPGAs \\cite{VaFiAu+10}, (2) there is an established theory\n    for their behavior \\cite{HaLe98,HaLiLe99,BaLuMi+11}, and (3) ample\n    precedent exists for testing and certifying them at the highest security\n    levels.\n\n    Ring oscillators also have well-known implementation pitfalls.\n    Their output is sometimes highly dependent on temperature,\n    which must be taken into account in testing and modeling.\n    If the ring oscillator construction is parallelized, it is important\n    that the number of stages and/or inverters in each chain is coprime to\n    avoid entropy reduction due to harmonic ``Huyghens synchronization''\n    \\cite{Ba86}.\n    Such harmonics can also be inserted maliciously in a frequency\n    injection attack, which can have devastating results \\cite{MaMo09}.\n    Countermeasures are related to circuit design; environmental sensors,\n    electrical filters, and usage of a differential oscillator may help.\n\n    \\paragraph{Shot Noise.}\n    A category of random sources consisting of discrete events\n    and modeled as a Poisson process is called ``shot noise.''\n    There's a long-established precedent of certifying them; the\n    AIS 31 document \\cite{KiSc11} itself offers reference designs based on\n    noisy diodes. Shot noise sources are often more resistant to\n    temperature changes than ring oscillators.\n    Some of these generators can also be fully implemented with standard\n    cells (The Rambus / Inside Secure generic TRNG IP \\cite{Ra20} is\n    described as a Shot Noise generator).\n\n    \\paragraph{Other types of noise.}\n    It may be possible to certify more exotic noise sources and designs,\n    although their stochastic model needs to be equally well understood\n    and their CPU interfaces must be secure.\n    See Section \\ref{sec:quantum} for a discussion of Quantum entropy\n    sources.\n\n\n\\subsubsection{Samplers and GetNoise}\n\n    It is necessary to verify that the noise source and sampler output\n    matches with their stochastic models. This is usually\n    done in a laboratory setting since NIST SP 800-90B \\cite{TuBaKe+18}\n    requires that the noise source in protected in production devices.\n    We are leaving access as a vendor-specific matter but we urge them to\n    protect the raw source and to make it unavailable to casual users.\n\n    \\underline{Rationale:}\n    Samplers can generate vast amounts of data. NIST SP 800-90B\n    \\cite{TuBaKe+18} defines a conceptual interface \\verb|GetNoise()|\n    for the raw output and also anticipates that the actual\n    interfaces ``will depend on the entropy source deployed.''\n\n    Building data paths to make the raw noise available through the ISA\n    would be problematic as it is unclear how to ``sample''\n    possibly up to several gigabits of information per second in a way\n    that is appropriately representative of its properties.\n\n    \\begin{quote}\n    \\emph{``The vendor may use special methods (or devices, such as an\n    oscilloscope) that require detailed knowledge of the source to\n    collect raw data. The testing laboratory is required [...] to\n    present a rationale why the data collections methods will not alter\n    the statistical properties\n    of the noise source or explain how to account for any change\n    in the source’s statistical characteristics [...]''}\n    \\flushright -- FIPS 140 Implementation Guidance, 2020 \\cite{NICC20}\n    \\end{quote}\n\n\n\n\\subsubsection{Continuous Health Tests}\n\\label{sec:cont-tests}\n\n    If NIST SP 800-90B certification is required, the hardware\n    should implement at least the health tests defined in Section\n    4.4 of \\cite{TuBaKe+18}: repetition count test and adaptive\n    proportion test.\n\n    Health monitoring requires some state information related\n    to the noise source to be maintained. The tests should be designed\n    in a way that a specific number of samples guarantees a state\n    flush (no hung states). We suggest flush size $W \\leq 1024$ to\n    match with the NIST SP 800-90B required tests (See Section 4.4 in\n    \\cite{TuBaKe+18}). The state is also fully zeroized in a system reset.\n\n    \\underline{Rationale:}\n    The two mandatory tests can be built with minimal circuitry.\n    Full histograms are not required, only simple counter registers:\n    repetition count, window count, and sample count.\n    Repetition count is reset every time the output sample value\n    changes; if the count reaches a certain cutoff limit, a noise alarm\n    (\\verb|BIST|) or failure (\\verb|DEAD|) is signaled. Window counter is\n    used to save every $W$'th output (typically $W \\in { 512, 1024 }$.)\n    The frequency of this reference sample in the following window is\n    counted; cutoff values are defined in the standard. We see that the\n    structure of the mandatory tests is such that, if well implemented,\n    no information is carried beyond a limit of $W$ samples.\n\n    Section 4.5 of \\cite{TuBaKe+18} explicitly permits additional\n    developer-defined tests and several more were defined in early\n    versions of FIPS 140-1 before being ``crossed out.'' The choice\n    of additional tests depends on the nature and implementation of the\n    physical source.\n\n    Especially if a non-cryptographic conditioner is used in hardware,\n    it is possible that the AIS 31 \\cite{KiSc11} online tests are\n    implemented by driver software. They can also be implemented in hardware.\n    For some security profiles AIS 31 mandates that their tolerances are\n    set in a way that the probability of an alarm is at least $10^{-6}$\n    yearly under ``normal usage.'' Such requirements are problematic\n    in modern applications since their probability is too high for\n    critical systems\\footnote{Currently (2020) about $10^{10}$ secure\n    elements are shipped yearly, many in critical applications and with\n    TRNGs, according to \\url{https://www.eurosmart.com}.}.\n    There rarely is anything that can or should be done about a non-fatal\n    alarm condition in an operator-free, autonomous system. However,\n    AIS 31 allows the DRBG component to keep running despite a failure in\n    its Entropy Source, so we suggest re-entering temporary \\verb|BIST|\n    state (Section \\ref{sec:security-controls}) to signal a non-fatal\n    statistical error if such (non-actionable) signaling is necessary.\n    Drivers and applications can react to this appropriately (or simply\n    log it) but it will not directly affect the availability of the TRNG.\n    A permanent error condition should result in \\verb|DEAD| state.\n\n\\subsubsection{Non-cryptographic Conditioners}\n\\label{sec:noncrypto}\n\n    As noted in Section \\ref{sec:intro-cond}, physical randomness sources\n    generally require a post-processing step called \\emph{conditioning} to\n    meet the desired quality requirements, which  are outlined in Section\n    \\ref{sec:req-es}.\n\n    The approach taken in this interface is to allow a combination of\n    non-cryptographic and cryptographic filtering to take place. The\n    first stage (hardware) merely needs to be able to distill the entropy\n    comfortably above 4 bits per byte (Sect. \\ref{sec:req-entropy},\n    Entropy) and to guarantee that the samples are independent\n    (Sect. \\ref{sec:req-iid}, IID).\n\n    \\begin{itemize}\n    \\item   One may take a set of bits from a noise source and XOR them\n            together to produce a less biased (and more independent) bit.\n            If the source model is well understood, such a construction\n            lends itself well to analysis and entropy estimation \\cite{Da02}.\n    \\item   The von Neumann extractor \\cite{Ne51} looks at consecutive\n            pairs of bits, rejects 00 and 11, and outputs 0 or 1 for\n            01 and 10, respectively. It will reduce the number of bits to\n            less than 25\\% of original but the output is provably unbiased\n            (assuming independence).\n    \\item   Blum's extractor \\cite{Bl86} can be used on sources\n            whose behavior resembles $n$-state Markov chains. If its\n            assumptions hold, it also removes dependencies, creating an IID\n            source.\n    \\item   Other linear and non-linear correctors such as those\n            discussed by Dichtl and Lacharme \\cite{La08}.\n    \\end{itemize}\n\n    Note that the hardware may\n    also implement a full cryptographic conditioner to in the entropy\n    source, even though the software driver still needs\n    a cryptographic conditioner too (Sect. \\ref{sec:req-state}).\n\n    \\underline{Rationale:}\n    The main advantage of non-cryptographic filters is in their\n    energy efficiency, relative simplicity, and amenability to mathematical\n    analysis. If well designed, they can be evaluated in\n    conjunction with a stochastic model of the noise source itself.\n    They do not require computational hardness assumptions.\n\n    In some cases, an entropy source (and the circuit that implements it)\n    may have a uniquely identifiable hardware ``signature.'' This can be\n    harmless or even useful in some applications (as random sources may\n    exhibit PUF-like features) but highly undesirable in others (anonymized\n    virtualized environments and enclaves).\n\n    Such virtualized environments are probably better off just using\n    \\verb|/dev/urandom| of the host rather than sharing the host's\n    hardware-backed Entropy Source to the guest environment. Also note the\n    source entropy requirement (Sect. \\ref{sec:req-es}, Secret State)\n    when sharing such generators.\n\n\\subsubsection{Cryptographic Conditioners}\n\\label{sec:crypto-cond}\n\n    Cryptographic conditioners are always required on the software side of\n    the PollEntropy ISA boundary. They may be also implemented on the\n    hardware side if necessary. In any case, the PollEntropy output must\n    always be compressed 2:1 (or more) before being used as keying material\n    or considered ``full entropy.''\n\n    Examples of cryptographic conditioners include the random pool\n    of the Linux operating system, secure hash functions (SHA-2/3,\n    SHAKE \\cite{NI15,NI15A} ),\n    and the AES-based CBC-MAC construction of SP 800-90B \\cite{TuBaKe+18}.\n\n    In some constructions, such as the Linux RNG and SHA-3/SHAKE \\cite{NI15}\n    based generators the cryptographic conditioning and output (DRBG)\n    generation is provided by the same component.\n\n    \\underline{Rationale:}\n    For many low-power targets constructions such as Intel's\n    \\cite{Me18} and AMD's \\cite{AM17} hardware AES CBC-MAC conditioner\n    would be too complex and expensive to implement solely to serve\n    \\mnemonic{pollentropy}. On the other hand, simpler non-cryptographic\n    conditioners may be too wasteful on input entropy if very high-quality\n    random output is required -- ARM TrustZone TRBG \\cite{AR17} outputs\n    only 10Kbit/sec at 200 MHz. Hence a resource-saving compromise is\n    made between hardware and software generation that allows an\n    implementation to use the RISC-V cryptographic ISA.\n\n%   Even if a DRBG seed obtains a sufficient amount of entropy in total,\n%   some bits may be more important than others. For example, the IV values\n%   of a counter-mode DRBG are less important than the key bits;\n%   if an adversary knows the key bits then the IV (counter value) is\n%   easy to determine. The inverse is not true. Cryptographic\n%   conditioning is required to spread the entropy across all bits.\n\n\n\\subsubsection{The Final Random: DRBGs}\n\\label{sec:drbgs}\n\n    All random bits reaching end users and applications must come from a\n    cryptographic DRBG. These are generally implemented by the driver\n    component in software. The RISC-V AES and SHA instruction set extensions\n    should be used if available, since they offer additional\n    security features such as timing attack resistance.\n\n    Currently recommended DRBGs are defined in NIST SP 800-90A (Rev 1)\n    \\cite{BaKe15}: \\verb|CTR_DRBG|, \\verb|Hash_DRBG|, and \\verb|HMAC_DRBG|.\n    Certification often requires known answer tests (KATs) for the symmetric\n    components and the DRBG as a whole. These are significantly easier to\n    implement in software than in hardware. In addition to the directly\n    certifiable SP 800-90A DRBGs, a Linux-style random pool construction\n    based on ChaCha20 \\cite{Mu20} can be used, or an appropriate construction\n    based on SHAKE256 \\cite{NI15}.\n\n    These are just recommendations; programmers can adjust the usage of the\n    CPU Entropy Source to meet future requirements.\n\n\n\\subsection{Quantum vs Classical Random}\n\\label{sec:quantum}\n\n    \\begin{quote}\n        {\\it ``The NCSC believes that classical RNGs will continue to\n        meet our needs for government and military applications for the\n        foreseeable future.''}\n        \\flushright -- U.K. QRNG Guidance, March 2020 \\cite{NC20}.\n    \\end{quote}\n\n    A Quantum Random Number Generator (QRNG) is a TRNG whose source of\n    randomness can be unambiguously identified to be a \\emph{specific}\n    quantum phenomenon such as quantum state superposition, quantum state\n    entanglement, Heisenberg uncertainty, quantum tunneling, spontaneous\n    emission, or radioactive decay \\cite{IT19}.\n\n    Direct quantum entropy is theoretically the best possible kind of\n    entropy. A typical TRNG based on electronic noise is also largely\n    based on quantum phenomena and is equally unpredictable - the difference\n    is that the relative amount of quantum and classical physics involved is\n    difficult to quantify for a classical TRNG.\n\n    QRNGs are designed in a way that allows the amount of quantum-origin\n    entropy to be modeled and estimated. This distinction is important in\n    the security model used by QKD (Quantum Key Distribution) security\n    mechanisms which can be used to protect the physical layer (such as\n    fiber optic cables) against interception by using quantum mechanical\n    effects directly.\n\n    This security model means that many of the available\n    QRNG devices do not use cryptographic conditioning and may fail\n    cryptographic statistical requirements \\cite{HuHe20}. Many implementers\n    may consider them to be entropy sources instead.\n\n    Relatively little research has gone into QRNG implementation security,\n    but many QRNG designs are arguably more susceptible to leakage than\n    classical generators (such as ring oscillators) as they tend to employ\n    external components and mixed materials.\n\n    \\paragraph{Post-Quantum Cryptography.}\n    The classical/quantum origin of randomness is not important in NIST\n    Post-Quantum Cryptography (PQC) \\cite{NI16}. Recall that cryptography\n    aims to protect the confidentiality and integrity of data itself\n    and does not place any requirements on the physical communication\n    channel (like QKD). Classical good-quality TRNGs are perfectly suitable\n    for generating the secret keys for PQC protocols that are hard for\n    quantum computers to break, but implementable on classical computers.\n    What matters in cryptography is that the secret keys have enough true\n    randomness (entropy) and that they are generated and stored securely.\n\n    Of course one must avoid DRBGs that are based on problems that are\n    easily solvable with quantum computers, such as factoring \\cite{Sh94}\n    in the case of Blum-Blum-Shub generator \\cite{BlBlSh86}. However\n    most symmetric algorithms are less affected as the best quantum\n    attacks are still exponential to key size \\cite{Gr96}.\n\n    As an example, the original Intel RNG \\cite{Me18}, whose output\n    generation is based on AES-128 can be attacked using Grover's algorithm\n    with approximately square-root effort \\cite{JaNaRo+20}.\n    While even ``64-bit'' quantum security is extremely difficult to\n    break, many applications specify a higher security requirement.\n    NIST \\cite{NI16} defines AES-128 to be ``Category 1'' equivalent\n    post-quantum security, while AES-256 is ``Category 5'' (highest).\n    We avoid this possible future issue by exposing a more direct access\n    to the entropy source, which can derive its security from\n    information-theoretic assumptions only.\n\n\n", "meta": {"hexsha": "47f559126cfcb010e613ba199d14d03f8ac3a550", "size": 33866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/old-tex/tex/appx-entropy.tex", "max_stars_repo_name": "dingiso/riscv-crypto", "max_stars_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 199, "max_stars_repo_stars_event_min_datetime": "2020-08-13T15:48:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T13:57:34.000Z", "max_issues_repo_path": "doc/old-tex/tex/appx-entropy.tex", "max_issues_repo_name": "dingiso/riscv-crypto", "max_issues_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 118, "max_issues_repo_issues_event_min_datetime": "2020-08-13T16:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T20:00:35.000Z", "max_forks_repo_path": "doc/old-tex/tex/appx-entropy.tex", "max_forks_repo_name": "dingiso/riscv-crypto", "max_forks_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 56, "max_forks_repo_forks_event_min_datetime": "2020-08-28T16:09:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T10:10:58.000Z", "avg_line_length": 53.248427673, "max_line_length": 114, "alphanum_fraction": 0.7506939113, "num_tokens": 7686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4311414655843741}}
{"text": "\\chapter{Methodology}\n\\label{ch:methodology}\n\nThe objective of this work is to develop a method that, like CADIS and FW-CADIS,\nautomatically generates variance reduction parameters for fixed-source,\ndeep-penetration radiation transport problems. In general, the variance reduction\nparameters generated by CADIS and FW-CADIS are not sufficient for\nproblems that are strongly\nanisotropic with respect to the flux. This method will extend existing\nmethods to generate importance maps--that in turn generate variance reduction\nparameters--that are informed by angle to remedy this issue. The first section\nin this chapter describes\nthe mathematical foundation of this new method. A discussion on how\nthe method's performance will be quantified follows. Finally, a description of\nthe software being used and how the method is added to this software\nconcludes this chapter.\n\n\\input{./chapters/methodology/theory.tex}\n\\input{./chapters/methodology/success_metrics.tex}\n\\input{./chapters/methodology/software.tex}\n\\input{./chapters/methodology/summary.tex}\n", "meta": {"hexsha": "ee0b39917be24674143a7ae649825dd8a6dcc7dd", "size": 1049, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/methodology/methodology.tex", "max_stars_repo_name": "rachelslaybaugh/munk-disseration", "max_stars_repo_head_hexsha": "e6dc6d6a8d5613cb30bca7dc4a2d419ad1b36e65", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/methodology/methodology.tex", "max_issues_repo_name": "rachelslaybaugh/munk-disseration", "max_issues_repo_head_hexsha": "e6dc6d6a8d5613cb30bca7dc4a2d419ad1b36e65", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/methodology/methodology.tex", "max_forks_repo_name": "rachelslaybaugh/munk-disseration", "max_forks_repo_head_hexsha": "e6dc6d6a8d5613cb30bca7dc4a2d419ad1b36e65", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.6818181818, "max_line_length": 81, "alphanum_fraction": 0.8217349857, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812552, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.431092518374887}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\degrees}{^{\\circ}}\n\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 104, HW4}\n\\maketitle\n\\newpage\n\n\n\\section{Q1}\n\\subsection{a}\nLet $x$ be an arbitrary point in $E = (0,1)$. Choose $r = \\min \\{(1-x)/2, x/2\\}$.\n\\newline\nConsider $S = \\{d(s,x)<r\\}$. Since $0<x<1$, $(1-x)/2$ and $x/2$ are both positive. Therefore $r>0$, and since $x-x/2 > 0, x+(1-x)/2<1$, we have $S \\subseteq E$\n\\newline\nTherefore $E$ is open.\n\\newline\nConsider the complement of $E: E' = \\R \\setminus E$\n\\newline\nLet $x'=1, r'>0$. Since $E'$ is the complement of $E$, it is the union of $(-\\infty, 0], [1, +\\infty)$. If $r \\geq 1$, we can see that $S' = \\{d(s',x')<r'\\}$ contains the point $1/2$ for instance, and $1/2 \\notin E'$. Otherwise, let $a = x'-r'$, since $x'=1, 0<r'<1, a \\in S, a \\notin E$. Therefore its complement is not open.\n\\newline\nThus we have shown that $(0,1)$ is open and not closed.\n\n\\subsection{b}\nLet $x=1, r>0, E=[0,1]$. Consider $S = \\{d(s,x)<r\\}$. Since $r>0, \\exists s \\in S s.t. s>x$. However since the interval only goes from 0 to 1, $s \\notin E$. Therefore this interval is not open.\n\\newline\nConsider $E' = \\R \\setminus E$.\n\\newline\nSince $E'$ is the complement of $E$, it is the union of $(-\\infty, 0), (1, +\\infty)$. If $x$ is in the former, then pick $r' = -x/2$. Since $x<0, -x > 0$, and $x+(-x/2)<0$, so $S = \\{d(s',x')<r'\\} \\subseteq E$.\n\\newline\nIf it is in the latter, pick $r' = (x-1)/2$. Since $x>1$, and $x-(x-1)/2>1$, so $S = \\{d(s',x')<r'\\} \\subseteq E$. Therefore its complement is open.\n\\newline\nThus we have shown that $[0,1]$ is closed and not open.\n\n\\subsection{c}\nConsider $x = 1$, let $r > 0$, we can consider this set to be a non-increasing series from 1 to 0. Let $S = \\{d(s,x)<r\\}$, now since $r > 0, \\exists s' \\in S s.t. 1/2<s'<1$, since this series is non-increasing, $s' \\notin E$. Therefore the set is not open.\n\\newline\nConsider the complement $E'$. Consider $x'$. If $x'>1 or x'<0$, we can choose $r'$ exactly the same as part (b) of this question. We can see that the set with radius $r'$ is a subset of $E'$.\n\\newline\nIf $0<x'<1$, we need to show that we can pick an $r'$ small enough to have not let the \"other\" set in.\n\\newline\nSince $x' \\notin E$, and $0<x'<1$, then it must be \"sanwiched\" between two elements of $E$. Let the two around $x'$ be $1/(n+1)<x'<1/n$. Now we can apply the denseness of rationals theorem to show that $\\exists q_1, q_2 s.t. 1/(n+1)<q_1<x', x'<q_2<1/n$. Now let $r' = \\min \\{ q_1, q_2 \\}$. We can see that all of the elements in this radius are in the set $E'$. Therefore its complement is open.\n\\newline\nThus we have shown that this set is closed and not open.\n\n\\subsection{d}\nLet $x \\in \\Q, r>0$, and $S = \\{d(s,x)<r\\}$. By the denseness of irrationals we know that $\\exists a \\notin \\Q s.t. x < a < x+r$. Therefore $\\Q$ is not open.\n\\newline\nWe can repeat the same argument but with irrationals. Let $y$ be irrational$, r>0$, and $S = \\{d(s,y)<r\\}$. By the denseness of ratioanls we know that $\\exists b \\in \\Q s.t. y < b < y+r$. Therefore $\\Q$'s complement is not open.\n\\newline\nTherefore $\\Q$ is neither open nor closed.\n\n\\subsection{e}\nLet this set be $E$. Let $e \\in E$ be an arbitrary point, and we choose $r = 1-d(e,(0,0))$. So we have our set $S = \\{d(e,s)<r\\}$.\nBy the triangle inequality we have $d(s, (0,0)) < 1 - r +r = 1$, so $s \\in E \\forall s \\in S$. Therefore the set is open.\n\\newline\nLet $E$'s complement be called $E'$, and let $x \\in E'$ be a point such that $d(x, (0,0)) = 1$. Let $r' > 0$, then consider the set $S' = \\{d(x,s')<r'\\}$. $\\exists t \\in S s.t. d(t, (0,0))<1$. Then $t \\in E$. Therefore its complement is not open.\n\\newline\nTherefore this set is open and not closed.\n\\newpage\n\n\n\\section{Q2}\n\\subsection{a}\nLet $a \\in U$ be an arbitrary point. Since $U$ is a union of a collection of open sets, then it must belong to at least one element of this collection. Let that element be $U_0$.\n\\newline\nSince $U_0$ is open, $\\exists r>0 s.t. S=\\{s \\in S | d(a,s)<r\\} \\subseteq U_0$. Therefore we have found an $r$ that works for an arbitrary point in $U$. Thus $U$ is open. Q.E.D.\n\n\\subsection{b}\nConsider $V_0 = U_1 \\cap U_2$.\n\\newline\nFrom the intersection, we conclude that for all $v \\in V_0, v \\in U_1, v \\in U_2$. Now consider an arbitrary point $w \\in V$. Since it is in open sets $U_1, U_2$, $\\exists r_1, r_2 s.t. \\{d(w,v)<r_1\\} \\subset U_1, \\{d(w,v)<r_2\\} \\subset U_2$\n\\newline\nNow let $r = \\min \\{r_1, r_2\\}$. Since r is the smaller of the two, $A = \\{d(w, a)<r \\} \\subset V_0, \\subset V_1$. Therefore $A \\subset V_0$. Thus we have shown that $V_0$ is open.\n\\newline\nWe can then repeat this process finitely many times, taking the minimum of the radius each time. Finally we have that $V$ is open. Q.E.D.\n\n\\subsection{c}\nConsider $W = \\cap ^\\infty _{n=0} (1/n, -1/n)$. Since $1/n \\to 0$ and $-1/n \\to 0$, $W = \\{0\\}$. This set has only 1 element and is therefore closed. Q.E.D.\n\\newpage\n\n\n\\section{Q3}\nLet $\\epsilon > 0$, since $s_n \\to s$, we have $\\exists N s.t. \\forall n>N, d(s_n,s)<\\epsilon$. Now let $r = \\epsilon$, we can see that $\\exists n s.t. d(s_n, s)<r$.\n\\newline\nConsider the complement of $E: F$. Consider the point $s$, since $s \\notin E$, we have $s \\in F$. Let $r' > 0$, define $Q = d(s,q)<r'$. Since we have shown above that $\\exists n s.t. d(s_n, s)<r$ for $r>0$, we know that $Q$ will always overlap with $E$. Therefore we cannot find a radius small enough, and $F$ is not open. Thus $E$ is not closed. Q.E.D.\n\\newpage\n\n\n\\section{Q4}\nSince $E$ is not closed, its complement $F$ is not open. Let $s$ be a boundary point in $F$: $s \\in F s.t. \\{p|d(s,p)<r \\} \\not\\subset F \\forall r > 0$\n\\newline\nNow let $e$ be an arbitrary point in $E$. Consider the sequence $s_n \\in \\{s \\mid a\\in E, d(a,s)<\\frac{1}{n}\\}$. We are attempting to draw \"smaller and smaller\" circles. Since we have shown above that $\\exists p \\in E s.t. d(s,p)<r \\forall r>0$, so we know that we can always pick an $s_n$ that is closer to $f$. Now, since $1/n \\to 0$, we know that $d(s_n, s)\\to 0$, and therefore $s_n \\to s, s \\notin E$. Q.E.D.\n\\newpage\n\n\n\\section{Q5}\nAssume that there exists a sequence $s_n$ that converges to $s \\notin F$.\n\\newline\nFirst, $s$ must be in $E$. Since $F \\subseteq E, \\forall f \\in F, f \\in E$. Furthermore, $E$ is sequentially compact, so every subsequence converges to an element in $E$. Therefore $s_n$ cannot converge to an element outside of $F$, so for the sake of contradiction we assume that it converges to $s \\in E$.\n\\newline\nLet $\\epsilon > 0$, then by our assumption there exists $N$ such that $\\forall n>N, d(s_n, s)<\\epsilon$. Now since $F$ is closed, we know that its complement is open. Let $F' = S \\setminus F$. Since $F$ is open, for any point $a \\in F, \\exists r>0 s.t. \\{b \\mid d(a,b)<r\\} \\subseteq F'$.\n\\newline\nNow we let the region surrounding our convergent point $s$ have value $r = k$, and we choose $\\epsilon = k/2$. Since $r>0, k/2>0$. Now for all $d(p,s)<k$, $p \\in F'$. This is a contradiction since if our sequence converges to $s$, it must be able to get arbitrarily close, but we have just created a space where $s_n$ cannot approach $s$. \\lightning\n\\newline\nTherefore our assumption is incorrect and $s_n \\to s$ must have $s \\in F$.\n\\newpage\n\n\n\\section{Q6}\nBy the definition of $\\lim \\sup$ we have $$\\lim _{N \\to \\infty}\\{\\sup \\{\\frac{a_{n+1}}{a_n}\\mid n>N\\}< C$$\n\\newline\nAssume that the statement is not correct, so we have: for all $N \\in \\N, a_n \\geq c^{n-N}a_N$\n\\newline\nLet $k \\in \\N$, between $n \\leq k \\leq N$, there must be at least 1 value such that $(a_{k+1}/a_k) \\geq C$ because otherwise, $a_n < c^{n-N}a_N$, and we have assumed that to be false. Now since we can show that there is at least 1 instance where $(a_{k+1}/a_k) \\geq C$ for all possible intervals of $n,N \\in N$, the limit superior cannot be less than $C$. \\lightning\n\\newline\nWe have found a contradiction, therefore our assumption is not correct and there must exist some $N \\in \\N$ that satisfies $a_n < c^{n-N}a_N \\forall n>N$. Q.E.D.\n\\newpage\n\n\n\\section{Q7}\n\\subsection{a}\nLemma: $\\lim \\sup a+b \\leq \\lim \\sup a + \\lim \\sup b$\n\\newline\nSince $k^2 \\neq 0 \\forall k>0$, $a_k \\neq 0$. Consider $a_{k+1}/a_k$ :\n$$\\frac{(k+1)^2}{3^{k+1}}\\times \\frac{3^k}{k^2} = \\frac{(k+1)^2}{3k^2}$$\n$(k+1)^2 < 2k^2$ for all $k>3$, we have\n$$\\lim \\sup \\frac{(k+1)^2}{3k^2} < \\lim \\sup \\frac{2k^2}{3k^2} = \\frac{2}{3}$$\nTherefore the ratio of the limit superior is less than 1, the sequence converges absolutely. Q.E.D.\n\n\\subsection{b}\n$a_k = k^2/3^k$, define $b_k = 3^k/3^k$. Since $k^2<3^k$ for all $k>2$, we have $a_k<b_k \\forall k>2$.\n\\newline\nNow consider the nth root: taking the nth root does not change the order when both numbers are positive, so we have $\\lim \\sup a_k^{1/k} < \\lim \\sup b_k^{1/k} = 1$ since $b_k$ is constant.\n\\newline\nThus we have $\\lim \\sup a_n < 1$. The sequence converges by root test. Q.E.D.\n\n\\subsection{c}\nConsider $c_k = 2^k/3^k$. $2^k \\geq k^2 \\forall k\\geq 2$. Furthermore, our sequence $a_k = k^2/3^k$ is positive. So we have $|a_k|\\leq c_k$. $c_k$ converges by geometric series with $r = 2/3<1$. Therefore $a_k$ converges by limit comparison test.\n\n\\end{document}\n", "meta": {"hexsha": "c7147d97c741f07a557594c1613171426bb44542", "size": 9688, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw4/main.tex", "max_stars_repo_name": "TianshuangQiu/Math104-Homework", "max_stars_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw4/main.tex", "max_issues_repo_name": "TianshuangQiu/Math104-Homework", "max_issues_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw4/main.tex", "max_forks_repo_name": "TianshuangQiu/Math104-Homework", "max_forks_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.55, "max_line_length": 413, "alphanum_fraction": 0.6527663088, "num_tokens": 3521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.8056321843145405, "lm_q1q2_score": 0.4310925158777353}}
{"text": "\\section{Noise effects}\nTo conclude our analysis, in the end we studied the behaviours of the sub-pixel filters varying the noise in the image. As we mentioned in Section \\ref{sec:laser-peaks}, the presence of electrical noise in the frames \\cite{1334612}, can affect heavily the quality of the peak detection, thus it is a good practice to apply some filters that reduce the weight of this noise during the laser location phase \\cite{Naidu1991}. For example, industry experts know that such operations are necessary if you use the \\textit{center of mass}: the presence of spikes influences the evaluation of the weighted average. An example of this, is shown in Figure \\ref{fig:noise-es}. \\\\\n  \\begin{figure}[t!]\n    \\centering\n    \\includegraphics[width=\\textwidth]{./images/analysis/noise/electrical.jpg}\n    \\caption{Effects of noise in peak detection. On the left there is a noise free Gaussian, and the \\acs{COM} correctly detect the peak. On the right, the noise moves the location (-.) with respect to the correct one (- -).}\n    \\label{fig:noise-es}\n  \\end{figure}\n  \nAs far as we are concerned, we have noticed these problems during the test shown in Section \\ref{sec:exp2}. Before reaching the discussed results, we tried to apply different image preprocessing algorithms to increase the precision of the peak localizion. So we saw that when we changed the preprocessing, the final results changed too. In Figure \\ref{fig:prep-dima} we reported the model trends for each sub-pixel filter used, varying the image preprocessing algorithms. As we can see, not all algorithms improve the results, on the contrary, sometimes they get worse the final error. In addition, we can see that the trend is different between mobile average and derivatives filters. These observations suggested us that not all filters have the same behaviour. Anyway, these results were obtained from a single system, thus we decided to perform some theoretical tests, in order to control the sources of noise. \\\\\n\nIn the second set of tests, we introduced some noise to the Gaussian, varying its \\acs{SNR}. In this way we were able to see how much strong are the sub-pixel algorithms with respect to the noise, and thus to the variations in image conditions. To do that, we varied the \\acs{SNR} in the range $\\left( 0, 30 \\right)$ with step $1$, and repeated the test five times per \\acs{SNR} step. The averages of the results are shown in Figures \\ref{fig:prep1} and \\ref{fig:prep2}. We had to split the trends in two graphics to see better what happens. \n\nThe first thing that caught our attention was the fact that, for high values of \\acs{SNR}, the initial hypothesis that $\\hat{\\delta} \\in \\left( -\\frac{1}{2}, \\frac{1}{2} \\right)$ with respect to the pixel, is false. The only model that always guarantees the hypothesis, is the \\textit{FIR}. Unfortunately, we are not able to model this result mathematically. As we said in the previous chapters, the algorithm used to detects the peak, finds the pixel with the greater value along a row, and then applies on it the sub-pixel filters. If we think of a moment, this is a reasonable hypothesis: so we considered the possibility to go out from the pixel as an error due to the noise in the image.\n\nThe second important thing to underline, is the effect of the size of the window. As we have said several times, the window has to be comparable with the width of the Gaussian, however, in presence of noise, the bigger the window is, the bigger is the weight of the noise in the measure. We can see this for both \\textit{center of mass} and \\textit{B\\&R}. Furthermore, in the same point we can notice that the \\textit{FIR} filter, that is more robust than the others in presence of noise, becomes the worst. \\\\\n\nThus, we can conclude that, from a global point of view, the \\textit{FIR} filter is the more robust in presence of noise, and it is the more stable, because of its small variance along noise variation. However, for low noise images \\textit{center of mass} and \\textit{B\\&R} models, allow to reach better results. The \\textit{B\\&R} is the less stable filter, but as shown in Figure \\ref{fig:prep-dima}, it is the less sensible (with the \\textit{FIR} filter) to image preprocessing. Finally, as far as the window size is concerned, the rule on Gaussian dimension continues to apply. So, there isn't a filter better than the others: their behaviours strictly depends from the scenario we are working on, and from the preprocess applied to the image. Since these considerations are empirical, we suggest to perform some tests in real conditions before choosing what algorithm use in your application.\n  \\begin{figure}[b!]\n    \\centering\n    \\includegraphics[width=0.95\\textwidth]{./images/analysis/noise/preprocessing_dima.png}\n    \\caption{Variation in the model output changing the image preprocessing.}\n    \\label{fig:prep-dima}\n  \\end{figure}\n\\vfill\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{./images/analysis/noise/prep1.png}\n    \\caption{Filters' trends for \\acs{SNR} in range $\\left( 0, 10 \\right)$}\n    \\label{fig:prep1}\n  \\end{figure}\n\\vfill\n  \\begin{figure}[t!]\n    \\centering\n    \\includegraphics[width=\\textwidth]{./images/analysis/noise/prep2.png}\n    \\caption{Filters' trends for \\acs{SNR} in range $\\left( 10, 30 \\right)$}\n    \\label{fig:prep2}\n  \\end{figure}\n", "meta": {"hexsha": "9891c334df24aa9fc0347702d999a0cc86b7d157", "size": 5346, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/src/chapters/ch5-Analysis/noise.tex", "max_stars_repo_name": "extoxesses/LaserMat", "max_stars_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-12T08:53:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T06:36:55.000Z", "max_issues_repo_path": "report/thesis/src/chapters/ch5-Analysis/noise.tex", "max_issues_repo_name": "extoxesses/LaserMat", "max_issues_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/src/chapters/ch5-Analysis/noise.tex", "max_forks_repo_name": "extoxesses/LaserMat", "max_forks_repo_head_hexsha": "4e893cd56ecea8497918ecafb642b2fbf9a085a2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 137.0769230769, "max_line_length": 917, "alphanum_fraction": 0.7633744856, "num_tokens": 1316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.43105179180821673}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\hyphenation{SINTOP}\n\\begmath 13.2 Numerical Evaluation of Integrals Over Several Dimensions\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThis collection of subprograms estimates the value of the integral $I_n$,\nwhere%\n\\begin{gather*}\n\\{I_0\\}_f=\\emptyset \\vspace{2pt} \\\\\nI_k=\\int \\rule[-15pt]{0pt}{34pt}_{\\displaystyle\n\\hspace{-9pt}a_k(x_{k+1},...,x_n,\n\\{I_{k^{\\prime}}\\}_{a_k})}^%\n{\\displaystyle \\hspace{-2pt}b_k(x_{k+1},...,x_n,\\{I_{k^{\\prime}}\\}_{b_k})}\n\\hspace{-1.3in}f_k(x_k,...,x_n,\\{I_{k-1}\\}_{f_k})\\,dx_k,\\ \\\n1\\leq k\\leq n-1\\\\\nI_n=\\int_{\\displaystyle a_n}^{\\displaystyle b_n}f_n(x_n,\n\\{I_{n-1}\\}_{f_n})\\,dx_n,\n\\end{gather*}\n$a_n$ and $b_n$ are constants, $a_1$, ..., $a_{n-1}$, $b_1$, ..., $b_{n-1}$\nand $f_1$, ..., $f_n$ are functions provided by the user. The notation\n$\\{I_{k-1}\\}_g$ means a set of zero or more integrals of dimension less\nthan $k$, used in the calculation of $g$, and $k^{\\prime }$ is less than\nthe dimensionality of the integral enclosing $I_k(k^{\\prime }$ may be\ngreater than $k)$. Usually, $f_k$ is $I_{k-1}$ for $k>1$, and\n$\\{I_{k^{\\prime}}\\}_{a_k}$ and $\\{I_{k^{\\prime}}\\}_{b_k}$ are empty.\n\nUsing $n=2$ for illustration, this formulation of the multiple integration\nproblem includes the simple case of%\n\\begin{equation*}\nI_2=\\int_{\\displaystyle a_2}^{\\displaystyle b_2}\\int_{\\displaystyle %\na_1(x_2)}^{\\displaystyle b_1(x_2)}f_1(x_1,x_2)\\,dx_1\\,dx_2,\n\\end{equation*}\nbut it also allows for improved computational efficiency if the integrand\ncan be factored as%\n\\begin{equation*}\nI_2=\\int_{\\displaystyle a_2}^{\\displaystyle b_2}f_2(x_2)\\int_{\\displaystyle %\na_1(x_2)}^{\\displaystyle b_1(x_2)}f_1(x_1,x_2)\\,dx_1\\,dx_2,\n\\end{equation*}\nand in addition it allows for the more general case of%\n\\begin{equation*}\nI_2=\\int_{\\displaystyle a_2}^{\\displaystyle %\nb_2}f_2(x_2,I_1^{(a)}(x_2),I_1^{(b)}(x_2),...)\\,dx_1\\,dx_2,\n\\end{equation*}\nwhere $I_1^{(a)}(x_2)$, $I_1^{(b)}(x_2)$, ... are integrals over one\ndimension. This includes the case in which, for example, $I_1^{(a)}(x_2)$ is\na limit for $I_1^{(b)}(x_2).$\n\n\\subsection{Usage}\n\nDescribed below under B.1 through B.5 are:\n\n\\begin{tabular*}{3.3in}{@{}l@{~~}l}\nB.1 & \\hspace{-20pt} Program Prototype, Single Precision\\dotfill\n\\pageref{PPSP}\\\\\n\\quad B.1.a & The Calling Routine\\dotfill \\pageref{Calling}\\\\\n\\quad B.1.b & Argument Definitions\\dotfill \\pageref{ArgDef}\\\\\n\\quad B.1.c & The User-supplied Subroutine SINTF to\\rule{.34in}{0pt}\\\\\n & Calculate Limits and Integrands\\dotfill \\pageref{SINTF}\\\\\n\\quad B.1.d & Argument Definitions for SINTF\\dotfill \\pageref{ArgSINTF}\\\\\n\\quad B.1.e & Actions to be Accomplished by SINTF\\dotfill \\pageref{ActSINTF}\\\\\n\\quad B.1.f & Passing Extra Information into SINTF\\dotfill \\pageref{ExtSINTF}\\\\\n\\end{tabular*}\n\n\\begin{tabular*}{3.3in}{@{}l@{~~}l}\nB.2 & \\hspace{-20pt} Program Prototype, Single Precision,\\\\\n & \\hspace{-20pt} Reverse Communication\\dotfill \\pageref{PPRC}\\\\\n\\quad B.2.a & The Calling Routine\\dotfill \\pageref{CallingRC}\\\\\n\\quad B.2.b & Argument Definitions\\dotfill \\pageref{ArgDefRC}\\\\\nB.3 & \\hspace{-20pt} Methods to Request Unusual Usage\nThrough\\rule{.3in}{0pt}\\\\\n & \\hspace{-20pt} the Arguments IOPT and WORK\\dotfill \\pageref{UnusualUse}\\\\\nB.4 & \\hspace{-20pt} Changing the Selection of Some Options\\\\\n & \\hspace{-20pt} During the Computation\\dotfill \\pageref{ChangeSel}\\\\\nB.5 & \\hspace{-20pt} Modifications for Double Precision\nUsage\\dotfill \\pageref{DPuse}\\\\\n\\end{tabular*}\n\n\\subsubsection{Program Prototype, Single Precision.\\label{PPSP}}\n\n\\paragraph{The Calling Routine\\label{Calling}}\n\n\\begin{description}\n\\item[INTEGER]  \\ {\\bf NDIMI, NWORK, IOPT}$(\\geq k)$\\newline\n[$k$ depends on options used ($\\geq 2$).]\n\n\\item[REAL]  \\ {\\bf ANSWER, WORK}(NWORK)\n\\end{description}\n\nAssign values to NDIMI and NWORK.\n\nAssign values to IOPT() and elements of WORK() referenced by options (see\nSection B.3). For simplest usage, set\n\n\\hspace{.2in}IOPT$(2)=0$\n\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nCALL SINTM (NDIMI, ANSWER,\\\\\nWORK, NWORK, IOPT)\\\\\n\\end{tabular}}\n\\end{center}\n\nIf the computation is successful (see the description of values of IOPT(1)\nbelow) the result is in ANSWER and the estimate of the error in the result\nis in WORK(1).\n\n\\paragraph{Argument Definitions\\label{ArgDef}}\n\n\\begin{description}\n\\item[NDIMI] \\  [in] Number of dimensions of integration, $n$ in Section A.\n\n\\item[ANSWER] \\  [out] Estimate of the integral.\n\n\\item[WORK()] \\  [inout] On completion, WORK(1) contains an estimate of the\nupper bound of the magnitude of the difference between ANSWER and the true\nvalue of the integral. During the integration, WORK(1:NDIMI)\ncontains the abscissas $x_1$ through $x_{NDIMI}$, WORK(NDIMI+1:2$\\times $NDIMI)\ncontains the lower limits $a_1$ through $a_{NDIMI}$,\nand WORK(2$\\times $NDIMI+1:3$\\times $NDIMI) contains the\nupper limits $b_1$ through $b_{NDIMI}$.\nWORK(NDIMI+1:NWORK) may be referenced by the option vector IOPT() as\ndescribed below and in Section B.3, and to pass parameters to SINTF as\ndescribed in Section B.1.f.\n\n\\item[NWORK] \\  [in] Specifies the amount of space allocated for the array\nWORK(). NWORK must be $\\geq 220\\times \\text{NDIMI} - 217.$\n\n\\pagebreak\n\\centerline{{\\bf Table of Options for SINTM}\\hspace{.5in}}\n\\ {\\bf Option}\\newline\n{\\bf Number\\hspace{.3in}Brief Description}\\vspace{-3pt}\n\\begin{itemize}\n\\item[0]  No more options.\n\n\\item[1]  No effect. Reserved for future use. Do not use option~1.\n\n\\item[2]  Select level of diagnostic output.\n\n\\item[3]  Specify error tolerances.\n\n\\item[4]  Specify an a posteriori estimate of the absolute error in the\ncalculated value of the integrand.\n\n\\item[5]  Specify an a priori estimate of the relative error expected in the\ncalculated values of integrands.\n\n\\item[6]  Use reverse communication.\n\n\\item[7]  Specify minimum index of quadrature formula.\n\n\\item[8]  No effect. The parameter may provide information to SINTF.\n\n\\item[9]  Specify maximum number of integrand evaluations allowed.\n\n\\item[10]  Return number of integrand evaluations used.\n\n\\item[11]  Specify location of singularity or discontinuity in integrand.\n\n\\item[12]  Specify absolute errors in the limits.\n\n\\item[13]  Specify location in IOPT of notification of nonstandard dimension\nchanges.\n\\end{itemize}\\vspace{-3pt}\n\n\\rule{2.9 in}{1 pt}\\vspace{3pt}\n\n\\item[IOPT()] \\  [inout] Used to return status information to the user, to\nallow the selection of options, and to pass parameters to SINTF as described\nin Section B.1.f. IOPT(1) returns a status indicator with the possible\nvalues:\n\n\\begin{description}\n\\item[\\rm $-$NDIMI] \\  Normal termination with either the absolute or relative\nerror tolerance criteria satisfied (see option~3 below and in Section\nB.3).\n\n\\item[\\rm $-$NDIMI$-1$] \\  Normal termination with neither the absolute nor\nrelative error tolerance criteria satisfied, but the tolerance relative to\nthe locally achievable precision is satisfied. This is the normal status\nvalue when no tolerances are specified. (See option~3 below and in\nSection B.3).\n\n\\item[\\rm $-$NDIMI$-2$] \\  Normal termination with none of the error tolerance\ncriteria satisfied. (See option~3 below and in Section B.3).\n\n\\item[\\rm $-$NDIMI$-3$] \\  Error termination, NWORK is too small.\n\n\\item[\\rm $-$NDIMI$-4$] \\  Bad value for an element of IOPT().\n\n\\item[\\rm $-$NDIMI$-5$] \\  Too many function values needed (see option~9 below and\nin Section B.3).\n\n\\item[\\rm $-$NDIMI$-$k$-5$] \\  Error termination. The $k^{th}$ integrand\napparently contains a non-integrable singularity. The approximate abscissa\nof the singularity in the $k^{th}$ dimension is in ANSWER, and the abscissas\nof exterior dimensions are in WORK$(k$+1:NDIMI). WORK(1)\ncontains a large number.\n\n\\item[\\rm $-$NDIMI$-$NDIMI$-$k$-5$] \\  When applying the usage that allows\nchanging the dimensionality of the next integral to be computed in a\nnonstandard way (Section B.1.e), the specified dimensionality $k$ of an\ninner integral is not less than the dimensionality of the outer integral.\n\\end{description}\n\nThe remainder of IOPT() may be used to select options and to pass parameters\nto SINTF. If no options are selected, set IOPT$(2)=0.$\n\\end{description}\n\nSee Section B.3 for a detailed description of options and the table\non the left for an overview.\n\n\\paragraph{The User-Supplied Subroutine SINTF to Calculate Integrands and\nLimits\\label{SINTF}}\n\nSINTM requires that the user provide values of the integrand and values of\nthe lower and upper limits, and allows the user to make functional\ntransformations of inner integrals before they are used as integrands of\nouter integrals. In the case of simple usage these values are provided by a\nuser-supplied subroutine of the form:\n\n{\\tt \\begin{tabbing}\nSUBROUTINE SINTF(ANSWER, WORK, IFLAG)\\\\\nREAL \\ ANSWER, WORK(*)\\\\\nINTEGER \\ IFLAG\\\\\n\\rm .\\ .\\ .\n\\end{tabbing}}\n\n\\paragraph{Argument Definitions for SINTF\\label{ArgSINTF}}\n\n\\begin{description}\n\\item[ANSWER] \\  [inout] Usage depends on IFLAG.\n\n\\item[WORK({\\rm 1:NDIMI})]  \\ [inout] Storage for the currently needed\nvalues of $x_1$,\\ ..., $x_{NDIMI}$. When IFLAG $\\neq 0$, $x_1$ is not\nneeded and WORK(1) has a different usage described below.\n\n\\item[WORK({\\rm NDIMI+1:2$\\times $NDIMI})]  \\ [inout] Storage for\nlower integration limits, $a_1$, ..., $a_{NDIMI}.$\n\n\\item[WORK({\\rm 2$\\times $NDIMI+1:3$\\times $NDIMI)}]  \\ [inout]\nStorage for upper integration limits, $b_1$, ..., $b_{NDIMI}.$\n\n\\item[WORK({\\rm $220\\times \\text{NDIMI}-216:\\text{NWORK}$})] \\ [inout]\nMay be used to pass extra information into SINTF, See Section~B.1.f.\n\n\\item[IFLAG] \\ [inout] On input, IFLAG indicates the action to be taken by\nSINTF.  The value of IFLAG may be changed by SINTF.  IFLAG may be used to\npass extra information into SINTF, See Section~B.1.f.\n\n\\end{description}\n\nMost mathematical software that requires user defined function\ninformation allows the user to pass in the name of a subprogram for\nevaluating the function.  The approach used here has the advantage of not\nrequiring the user to declare his subprogram in an external statement\n(It's not unusual for this to be forgotten.), and of giving a meaningful\ndiagnostic when no such routine is provided.  If one is solving different\nproblems with different programs, one can use different file names for the\ndifferent function subprograms, all of which would use the same entry\nname.  The linker must then be told which of these function subprograms\nshould be used in forming the executable file.  If one wants to solve\nseveral different problems in the same program, one should code the\nseparate cases in one subprogram and select the one desired by passing a\n``case'' variable into the routine.  This can either be done as part of\nIFLAG as mentioned above, or can be done through the use of named\ncommon.  One can also use reverse communication and call subprograms with\ndifferent names for the different cases.\n\n\\paragraph{Actions to be Accomplished by SINTF\\label{ActSINTF}}\n\n{\\bf IFLAG} = 0\\ \\ The Inner Integrand\\newline\nWhen IFLAG\\ $= 0$, SINTF must compute the inner integrand, $f_1$, as a\nfunction of $x_1$, ..., $x_{NDIMI}$, and return the result in ANSWER.\n\n{\\bf IFLAG} $< 0$\\ \\ After Computing $I_{-IFLAG}$\\newline\nWhen IFLAG $< 0$, say IFLAG\\ $= -i$, the current value of the integral\n$I_i$ is provided in ANSWER, and the estimated error $E_i$ in this value\nis provided in WORK(1). Frequently, one will have $f_{i+1} = I_i$, and\n$a_i$ and $b_i$ will not depend on integrals, in which case\n$\\varepsilon_{i+1} = E_i = $ WORK(1), and SINTF can simply RETURN, taking\nno action.\n\nIn more complicated cases, SINTF must compute the integrand $f_{i+1}$ as a\nfunction of $x_{i+1}$, ..., $x_{NDIMI}$, $I_i$, and perhaps other\nintegrals as described in the next paragraph. The value of $f_{i+1}$ must\nbe in ANSWER on return, and the error $\\varepsilon _{i+1}$ in $f_{i+1}$\nmust be in WORK(1).\n\nIf $f_{i+1}$ depends on integral(s) not yet computed then SINTF must\nremember $I_i$ and $E_i$ for subsequent use, and set IFLAG to the number of\ndimensions of the next integral to be evaluated; IFLAG must be less than the\nnumber of dimensions of the enclosing integral. If option~13 is selected\nthen K13 is used for this communication instead of IFLAG. IFLAG is the first\nelement of the IOPT vector passed to SINTM (see Section B.1.f). It is the\nresponsibility of SINTF to remember the state of computation of the several\nintegrals upon which $f_{i+1}$ depends. That is, to know when to change\nIFLAG (or K13), when not to change it, and when to evaluate $f_{i+1}.$\n\nTo estimate errors and control the selection of evaluation points during\ncalculation of $I_{i+1}$, SINTM needs an estimate of the error in\n$f_{i+1}$. In the simple case when $f_{i+1}=I_i$, and $a_i$ and $b_i$ do\nnot depend on integrals, one has $\\varepsilon _{i+1}=E_i=$ WORK(1) and no\nspecial action is required. In general, however, one must compute%\n\\begin{equation*}\n\\text{WORK(1) }=\\sum_{\\{\\,j\\mid I_i^{(j)}\\in \\{I_i\\}_f\\,\\}}|\\partial\nf_{i+1}/\\partial I_i^{(j)}|\\ E_i^{(j)}\n\\end{equation*}\nWhere $E_i^{(j)}$ is the error in $I_i^{(j)}$. If some arguments of\n$f_{i+1}$, say $y_j$, cannot be precisely calculated and represented, then\none must add $\\Sigma \\ |\\partial f_{i+1}/\\partial y_j|\\ E(y_j)$, where\nE($y_j)$ is the error in the calculation of $y_j$, onto the above sum.\n\n{\\bf IFLAG} $> 0$\\ \\ Before Computing $I_{IFLAG}$\\newline\nWhen IFLAG $>0$, say IFLAG $=i$, SINTF must compute $a_i$ and $b_i$ as\nfunctions of $x_{i+1}$, ..., $x_{NDIMI}$, storing $a_i$ in WORK(NDIMI +\nIFLAG) and $b_i$ in WORK(2$\\times $NDIMI + IFLAG). SINTF will be called\nonly once with IFLAG = NDIMI, since the outer limits $a_{NDIMI}$ and\n$b_{NDIMI}$ must be constants, and thus need to be set only once. These\nmay be stored into WORK() either by the user's main program before the\ninitial call to SINTM or else by SINTF when it is called with IFLAG =\nNDIMI. Similarly, if the limits $a_k$ and $b_k$ of $I_k$ are constant,\nthey may be stored into WORK() by the user's main program before the\ninitial call to SINTM, or on any call to SINTF for which IFLAG $\\geq k.$\n\nSuppose a limit $a_i$ or $b_i$ depends on variables of integration $\\{x_m |\\\ni < k \\leq m \\leq $ NDIMI$\\}$. Then $a_i$ or $b_i$ may be calculated any\ntime that $i \\leq $ IFLAG\\ $< k$, but for maximum efficiency should be\ncalculated when IFLAG\\ $= k-1$. Similarly a subexpression of $f_i$ that\ndepends on $\\{x_m |\\ i < k \\leq m \\leq $ NDIMI$\\}$ should be calculated when\nIFLAG $= k$, and used when IFLAG $= -i.$\n\nFor $1 \\leq i <$ NDIMI the integral $I_i$, having the limits $a_i $ and $b_i$,\nmay subsequently be used as an argument in computing $f_{i+1}$.  Let $q$ be\nthe maximum of $|\\partial f_{i+1}/\\partial I_i|$ over all integrals on which\n$f_{i+1}$ depends. If $q \\neq 1$, then during an entry at which $a_i$ and\n$b_i$ are being computed, SINTF must also compute $q$, or an upper bound for\n$q$, and store this value in WORK(1).  This value is used internally to decide\nhow much accuracy is needed for the coming integration.  Note that if\n$f_{i+1}$ is of the form $q(x_{i+1},\\ \\ldots,\\ x_{NDIMI}) I_i$, then the $q$\ncomputed here can be saved and reused for computing the values of ANSWER and\nWORK(1) when IFLAG = $-(i+1)$.\n\nIf it is known that the integrand, $f_i$, has a single singularity\naffecting integration from $a_i$ to $b_i$, SINTF should transmit\ninformation on the type and location of this singularity to SINTM\nduring each entry that computes $a_i$ and $b_i$. To do this, SINTF\nshould store the location (on the $x_i$ axis) of the singularity into\nWORK($|$K11$|$), where K11 is transmitted to SINTM, either by a call\nto SINTOP with Option~11, or by storing K11 into IFLAG.  If the\nsingularity is at one of the limits, then $\\text{NDIMI}< |\\text{K11}|\n\\leq 3\\times \\text{NDIMI}$ is allowed.  Otherwise, one should have\n$|\\text{K11}| > 220\\times \\text{NDIMI}-217$. The sign of K11 affects\nthe internal transformations made to cope with the singularity as\ndescribed in Section~B.3 of Chapter~13.1.  If singularities are\npresent in more than one dimension of the multiple integration, one\nmust use a different value of $|$K11$|$ for each different\nsingularity location.\n\nSINTM provides for the case that $f_{i+1}$ might depend on several\nintegrals, some of which have fewer than $i$ dimensions. When it is\nnecessary to evaluate an integral of dimension less than $i$, set IFLAG (or\nK13 if option~13 has been selected) to the number of dimensions of the\nintegral to be evaluated, and set the appropriate limits into WORK() as\ndescribed above.\n\nTo illustrate nonstandard changes in dimensionality, suppose that the\nintegrand of a three dimensional integral depends on a function of several\none- and two-dimensional integrals, and suppose one chooses to evaluate the\none-dimensional integrals first. When SINTM first requests SINTF to provide\nthe limits of the inner (two-dimensional) integral (IFLAG $= 2)$, change\nIFLAG to~1. Upon completion of each but the last of the one dimensional\nintegrals (IFLAG $= -1)$, set IFLAG to~1. Upon completion of the last of the\none-dimensional integrals, and upon completion of all but the last\ntwo-dimensional integral, set IFLAG to~2. SINTF must keep track of it's\nstate using SAVE variables. That is, SINTF is responsible for knowing which\nintegrand to evaluate when IFLAG $= 0$, which transformation to apply when\nIFLAG $< 0$, and which limits to supply when IFLAG $> 0$. For this\nexample, an error will be signaled with IOPT$(1)=-14=-\\text{NDIMI}-\n\\text{NDIMI}-3-5$ if one sets IFLAG~$\\geq $~3.\n\nIf either of the limits $a_i$ or $b_i$ are imprecisely known or imprecisely\nrepresentable $(e.g.$, they depend on integrals, or there is significant\ncancellation in their evaluation), then for maximum reliability the errors\nin the limits should be made known to SINTM by invoking SINTOP and selecting\noption~12. See Section~B.3.\n\n\\paragraph{Passing Extra Information into SINTF\\label{ExtSINTF}}\n\nThe argument WORK of SINTF is the vector WORK passed from the user's calling\nroutine to SINTM.  WORK() may be used to provide information for options as\ndescribed in Section B.3, and to pass floating point information from the\nuser's calling routine into SINTF.\n\nThe argument IFLAG of SINTF is the first element of the IOPT() vector\npassed from the user's calling routine to SINTM. Elements of IOPT()\n(after the first) that are not used for options as described in\nSection B.3 may be used to pass integer valued information into\nSINTF. In addition, the parameter of option~8 described in Section\nB.3 may be examined by SINTF. If IFLAG is used in this way, it must\nbe declared\n\n{\\bf INTEGER} \\ {\\bf IFLAG}(*)\n\nand IFLAG(1) must be examined to determine the action.\n\n\\subsubsection{Program Prototype, Single Precision, Reverse Communication.\n\\label{PPRC}}\n\n\\paragraph{The Calling Routine\\label{CallingRC}}\n\n\\begin{description}\n\\item[INTEGER] \\  {\\bf NDIMI, NWORK, IOPT}$(\\geq 3)$\n\n\\item[REAL] \\  {\\bf ANSWER, WORK}(NWORK)\n\\end{description}\n\nAssign values to NDIMI, NWORK and IOPT() and elements of WORK() referenced\nby options. Constant limits may be stored in the appropriate positions in\nWORK() as described in Section~B.1.b. Option~6 must be selected (see\nSection~B.3). For simple usage\n\\begin{tabbing}\n\\hspace{.2in}\\=IOPT$(2) = 6$\\\\\n\\>IOPT$(3) = 0$\n\\end{tabbing}\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nCALL SINTM (NDIMI, ANSWER,\\\\\nWORK, NWORK, IOPT) \\\\\n\\end{tabular}}\n\\end{center}\n\\hspace{.2in}DO\n$$\n\\fbox{{\\bf CALL SINTMA (ANSWER, WORK, IOPT)}}\n$$\n\\begin{tabbing}\n\\hspace{.2in}\\=\\ \\ \\ \\ \\=IF (IOPT(1) .GT.\\ 0) THEN\\\\\n\n\\>\\>\\ \\ \\ \\ \\=$\\{$Calculate the limits as described in\\\\\n\\>\\>\\>\\ \\ \\ \\ \\=Section B.1.d when IFLAG $>0.\\}$\\\\\n\n\\>\\>ELSE IF (IOPT(1) .LT. 0) THEN\\\\\n\n\\>\\>\\>IF (IOPT(1) + NDIMI .LE. 0) EXIT\\\\\n\n\\>\\>\\>$\\{$Transform the integral as described in\\\\\n\\>\\>\\>\\>Section B.1.d when IFLAG $<0.\\}$\\\\\n\n\\>\\>ELSE\\\\\n\n\\>\\>\\>ANSWER = value of innermost integrand,\\\\\n\\>\\>\\>\\ \\ \\ \\ $f_1$, at (WORK(1), ..., WORK\\ (NDIMI)).\\\\\n\n\\>\\>END IF\\\\\n\n\\>END DO\\\\\n\n\\>$\\{$Integration is complete$.\\}$\n\\end{tabbing}\n\nMulti-dimensional quadrature can use significant amounts of computer time.\\\nThe usage described above can be modified to reduce the execution time\nslightly at a cost of the user's code becoming more complicated. To do\nthis, replace the single line\n\n\\hspace{.2in}ANSWER $= ...$\\newline\nby\n\\begin{tabbing}\n\\hspace{.2in}\\=IOPT$(1) = 0$\\\\\n\n\\>DO WHILE (IOPT(1) .EQ.\\ 0)\\\\\n\n\\>\\ \\ \\ \\ \\=ANSWER = Value of the innermost\\\\\n\\>\\>\\ \\ \\ \\ \\=integrand, $f_1$, at (WORK(1), ...,\\\\\n\\>\\>\\>WORK(NDIMI))\n\\end{tabbing}\n$$\n\\quad \\quad \\fbox{{\\bf CALL SINTA (ANSWER, WORK, IOPT)}}\n$$\n\\begin{tabbing}\n\\hspace{.2in}\\=END DO\\\\\n\n\\>IF (IOPT(1) .GT.\\ 0) THEN\\\\\n\n\\>\\ \\ \\ \\ \\=$\\{$Values of IOPT(1) produced by SINTMA and\\\\\n\\>\\>\\ \\ \\ \\ \\=SINTA have different meanings. Calculate\\\\\n\\>\\>\\>IOPT(1) as described in Section B.1.b.$\\}$\\\\\n\n\\>\\>IOPT$(1) = -$(IOPT(1) + NDIMI)\\\\\n\n\\>\\>EXIT\\ \\  \\=(from DO --- END DO in which this\\\\\n\\>\\>\\>\\ code is embedded)\\\\\n\n\\>END IF\n\\end{tabbing}\n\nThis modification reduces by one the number of subroutine calls for every\nevaluation of the innermost integrand.\n\n\\paragraph{Argument Definitions\\label{ArgDefRC}}\n\n\\begin{description}\n\\item[NDIMI, WORK(), NWORK, IOPT()]  \\ Used as described in Section\nB.1.b, except if $-$NDIMI $<$ IOPT(1) $\\leq $ NDIMI, IOPT(1) is used as\ndescribed for IFLAG in Section B.1.e.\n\n\\item[ANSWER]  \\ [inout] On completion, ANSWER contains an estimate of the\nintegral. During integration, ANSWER provides a value of the integrand to\nSINTMA.\n\\end{description}\n\n\\subsubsection{Methods to Request Unusual Usage Through the Arguments IOPT\nand WORK\\label{UnusualUse}}\n\nAll options other than option~13 have the same qualitative effect as when\ncalculating an integral over one dimension, as described in Section B.3\nof Chapter~13.1, but some options have separate effects in separate\ndimensions.  Direct calls to SINTOP should be made as described in\nSection~B.4 of Chapter~13.1. Options different from those in 13.1 are:\n\n\\begin{itemize}\n\\item[2]  (Argument K2) K2 is an NDIMI decimal digit integer, where the\nlow order digit selects the level of diagnostic output during integration\nover $x_1$, the next digit selects the level of diagnostic output during\nintegration over $x_2$, etc. The meaning of each digit is the same as the\nmeaning of K2 described in Section~B.3 of Chapter~13.1.\n\n\\item[9]  (Argument K9) K9 specifies only the maximum number of evaluations\nof the inner integrand $(f_1).$\n\n\\item[11] (Argument K11) WORK($|$K11$|$) specifies the location of a\nsingularity or discontinuity in the outer dimension.  Singularities or\ndiscontinuities in inner dimensions may be specified as described in\nSection~B.1.e.  In either case, a different value of K11 must be used for\neach different abscissa of a singularity or discontinuity.  However if\nseveral dimensions happen to have singularities or discontinuities at the\nsame abscissa, the same value of K11 can be used for all of them.  The\nsign of K11 affects the internal transformations made to cope with the\nsingularity as described in Section~B.3 of Chapter~13.1.\n\n\\item[12] (Argument K12) The errors in the lower and upper limits are\nstored in WORK(K12) and WORK(K12+1) respectively prior to a\ncall to SINTOP.  The error in the lower limit $a_i$ is defined by $ \\Sigma\n\\ |\\partial a_i/\\partial x_j|\\ \\epsilon \\ x_j+\\Sigma \\ |\\partial\na_i/\\partial y_j|\\ E(y_j)+\\Sigma \\|\\partial a_i/\\partial I_j|\\ E_j$, where\n$ x_j$ are variables of integration of outer integrals, $\\epsilon $ is the\nround-off level for the appropriate precision, $y_j$ are arguments of\n$a_i$ that are neither variables of integration of outer integrals nor\nintegrals, E($y_j)$ is the error in $y_j$, $I_j$ are integrals that are\narguments of $ a_i$, and $E_j$ is the error in $I_j$.  The error in the\nintegral due to error in the limit is the error in the limit times the\nintegrand evaluated near the limit.  The error in the upper limit is\ncalculated similarly.  If this option is not selected, or K12 $=0$, then\nthe limits will be assumed to be exact.\n\n\\item[13]  (Argument K13) In the IOPT vector passed to SINTM, K13 may be\nused to notify SINTM of nonstandard changes in the dimensionality of\nintegration. If option~13 is not selected, IOPT(1) may be used for this\npurpose. But notice that reporting singularities might also use IOPT(1).\n\\end{itemize}\n\n\\subsubsection{Changing the Selection of Some Options During the Computation\n\\label{ChangeSel}}\n\nThe method of changing the selection of options 1, 2, 6, 7, 9, 12 and~13\nduring the integration is described in Chapter~13.1, Section~B.4.\n\n\\subsubsection{Modifications for Double Precision Usage\\label{DPuse}}\n\nFor double precision usage, change all REAL type statements to DOUBLE\nPRECISION and change the prefix of all subroutine names from SINT to DINT.\n\n\\subsection{Examples and Remarks}\n\nSee DRSINTMF and ODSINTMF, or DRSINTMR and ODSINTMR for an example of the\nuse of SINTM to compute%\n\\begin{equation*}\n\\int_0^\\pi \\int_0^y\\frac{x\\cos y}{x^2+y^2}\\,dx\\,dy=0.\n\\end{equation*}\nThe difference between DRSINTMF and DRSINTMR is that DRSINTMF uses forward\ncommunication, while DRSINTMR uses reverse communication.\n\nDRSINTMF and DRSINTMR demonstrate the use of functional transformation of\nthe inner integrand to reduce the cost of calculating the integral. The\nfactor $\\cos y$ in the integrand does not depend on the inner variable of\nintegration. In this context, $f_1 = x\\ / (x^2 + y^2)$, and $f_2 = I_1 \\cos\n\\ y$. Special care is taken when $y$ is near zero, as the denominator of\n$f_1 $ might underflow.\n\nThe above integral is really the product of two one-dimensional integrals\n(let $z = x/y)$. This situation is not uncommon. Since the cost of\nestimating multi-dimensional integrals by nested estimation over one\ndimension is exponential in the number of dimensions, the possibility of\nthis situation should always be considered.\n\n\\subsection{Functional Description}\n\nThe integral over several dimensions is computed by repeated integration\nover one dimension, as shown in Section~A. The integral over one dimension\nis estimated using the subprograms described in Chapter~13.1. See Section~D\nof Chapter~13.1 for a functional description.\n\nExtensive test results are given in \\cite{Krogh:1978:PTR}.  Since there\nare no other multi-dimensional quadrature subprograms extant that provide\nthe functionality of SINTM and DINTM, it is not practical to carry out\nextensive comparative tests.  Since SINT1 and DINT1 are, however, more\nreliable and require fewer function values than other one-dimensional\nquadrature routines, it is to be expected that SINTM and DINTM are more\nreliable and require fewer function values than other subprograms that\nevaluate multi-dimensional integrals by repeated integration over one\ndimension.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nError messages are printed using the extended error message processor\ndescribed in Chapter~19.3. If an error does not result in a ``stop,'' error\nsignals are returned to the user by values of the status flag in IOPT(1).\\\nPrinting, when enabled by Option~2, is executed in subroutines SINTO for\nsingle precision and DINTO for double precision. Both of these programs also\nuse the message processor described in Chapter~19.3. One can change the\naction on errors and parameters affecting the output of messages, by calling\nthe message/error routine MESS before calling this routine.\n\n\\subsection{Supporting Information}\n\nThe source language for these subroutines is ANSI Fortran 77.\n\nCommon blocks referenced: SINTC and SINTEC in the single precision\nversions, and DINTC and DINTEC in the double precision versions.\nSINTC and DINTC are written using several COMMON statements, for\nmaintenance purposes. This usage conforms to the ANSI Fortran-77\nstandard, but at least one compiler interprets it improperly. If you\nexperience inscrutable errors, try re-writing the COMMON statements\nfor SINTC (or DINTC) into a single statement.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDINTM & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DCOPY, DINTA, DINTDL, DINTDU, DINTF, DINTM, DINTMA, DINTNS,\nDINTO, DINTOP, DINTSM, DMESS, MESS\\rule[-5pt]{0pt}{8pt}}\\\\\nDINTMA & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DCOPY, DINTA, DINTDL, DINTDU, DINTF, DINTMA, DINTNS, DINTO,\nDINTSM, DMESS, MESS\\rule[-5pt]{0pt}{8pt}}\\\\\nSINTM & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, MESS, SCOPY, SINTA, SINTDL, SINTDU, SINTF, SINTM, SINTMA,\nSINTNS, SINTO, SINTOP, SINTSM, SMESS\\rule[-5pt]{0pt}{8pt}}\\\\\nSINTMA & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, MESS, SCOPY, SINTA, SINTDL, SINTDU, SINTF, SINTMA, SINTNS,\nSINTO, SINTSM, SMESS}\\\\\n\\end{tabular}\n\nDesigned by Fred T.\\ Krogh and W.\\ Van Snyder, JPL, 1977. Programmed by W.\\\nVan Snyder, 1977. Revised by W. Van Snyder, 1986, 1988.\n\nError/Message handling revised by F. T. Krogh, March~1992.\n\n\nTwo demonstration drivers are shown below, with the output they produced\nwhen run on an IBM PC/AT with an 80287 floating point coprocessor. The first\ndemonstrates forward communication usage; the second demonstrates reverse\ncommunication usage.\n\n\\begcodenp\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSINTMF}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sintmf}}\n\n\\vspace{20pt}\\centerline{\\bf \\large ODSINTMF}\\vspace{-5pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sintmf}}\n\\bigskip\\\n\n\\centerline{\\bf \\large DRSINTMR}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sintmr}}\n\n\\vspace{30pt}\\centerline{\\bf \\large ODSINTMR}\\vspace{-5pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sintmr}}\n\\end{document}\n", "meta": {"hexsha": "6ce063c382246573ebe4f9e62456516cd08a4d64", "size": 29853, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch13-02.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch13-02.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch13-02.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 43.2652173913, "max_line_length": 98, "alphanum_fraction": 0.7370113556, "num_tokens": 9278, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.4310517875099657}}
{"text": "%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[twoside,english]{paper}\n\\usepackage{lmodern}\n\\renewcommand{\\ttdefault}{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage[a4paper]{geometry}\n\\geometry{verbose,tmargin=3cm,bmargin=2.5cm,lmargin=2cm,rmargin=2cm}\n\\usepackage{color}\n\\usepackage{babel}\n\\usepackage{float}\n\\usepackage{bm}\n\\usepackage{amsthm}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{esint}\n\\usepackage[unicode=true,pdfusetitle,\n bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,\n breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]\n {hyperref}\n\\usepackage{breakurl}\n\\usepackage{mathrsfs}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n%% Because html converters don't know tabularnewline\n\\providecommand{\\tabularnewline}{\\\\}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{babel}\n\n\\@ifundefined{showcaptionsetup}{}{%\n \\PassOptionsToPackage{caption=false}{subfig}}\n\\usepackage{subfig}\n\\makeatother\n\n\\begin{document}\n\n\\title{Transversity Distributions}\n\n\\maketitle\n\n\\section{Perturbative evolution}\n\nIn this section we discuss the structure of the DGLAP evolution\nequations for the transversity distributions. The same structure holds\nfor both PDFs and FFs. Therefore we first discuss the structure of the\nevolution equations in terms of distributions in the so-called\n``evolution'' basis and then report the splitting functions up to\n$\\mathcal{O}(\\alpha_s^2)$, \\textit{i.e.} next-to-leading order (NLO),\nseparately for PDFs and FFs. Contrary to unpolarised and\nlongitudinally polarised collinear distributions, no transversely\npolarised gluon distribution exists. This simplifies the structure of\nthe evolution equations that, when written in the evolution basis, are\ncompletely decoupled. \n\nAs a first step we define the evolution basis. Given a set of quark\ndistributions in the more familiar ``physical'' basis, \\textit{i.e.}\n$\\{\\overline{t},\\overline{b},\\overline{c},\\overline{s},\\overline{u},\\overline{d},d,u,s,c,b,t\\}$,\nand defining $q^{\\pm}\\equiv q\\pm \\overline{q}$, the ``evolution''\nbasis is defined as follows:\n\\begin{equation}\n\\begin{array}{rcl}\n\\Sigma&=& \\sum_{q}q^+\\,,\\\\\nV &=& \\sum_{q}q^-\\,,\\\\\nT_3&=& u^+-d^+\\,,\\\\\nV_3&=& u^--d^-\\,,\\\\\nT_8&=& u^++d^+-2s^+\\,, \\\\\nV_8&=& u^-+d^- -2s^-\\,, \\\\\nT_{15}&=& u^++d^++s^+-3c^{+}\\,, \\\\\nV_{15}&=& u^-+d^- +s^--3c^{-}\\,, \\\\\nT_{24}&=& u^++d^++s^++c^{+}-4b^+\\,, \\\\\nV_{24}&=& u^-+d^- +s^-+c^{-}-4b^-\\,, \\\\\nT_{35}&=& u^++d^++s^++c^{+}+b^+-5t^{+}\\,, \\\\\nV_{35}&=& u^-+d^- +s^-+c^{-}+b^--5t^{-}\\,.\n\\end{array}\n\\end{equation}\nIt is possible to show that in this basis the general form of the\nDGLAP evolution equations for the transversity distribution reduces to\nthe following set of \\textit{decoupled} integro-differential equation:\n\\begin{equation}\\label{eq:evoleqs}\n\\begin{array}{rcl}\n\\displaystyle \\mu^2\\frac{d\\Sigma}{d\\mu^2} &=& \\displaystyle P_{qq}\\otimes \\Sigma\\,,\\\\\n\\\\\n\\displaystyle \\mu^2\\frac{dV}{d\\mu^2} &=& \\displaystyle P^{V}\\otimes V\\,,\\\\\n\\\\\n\\displaystyle \\mu^2\\frac{dT_i}{d\\mu^2} &=& \\displaystyle P^+\\otimes T_i\\,,\\\\\n\\\\\n\\displaystyle \\mu^2\\frac{dV_i}{d\\mu^2} &=& \\displaystyle P^-\\otimes V_i\\,,\\\\\n\\\\\n\\end{array}\n\\end{equation}\nwith $i=3,8,15,24,35$ and where the Mellin convolution symbol\n$\\otimes$ is defined as:\n\\begin{equation}\nf(x)\\otimes g(x)\\equiv \\int_x^1\\frac{dy}{y}f(y)g\\left(\\frac{x}{y}\\right)=\\int_x^1\\frac{dy}{y}f\\left(\\frac{x}{y}\\right)g(y)\\,.\n\\end{equation}\nThe splitting functions $P_{qq}$, $P^V$, $P^+$, and $P^-$ are usually\ndecomposed as follows:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle P^\\pm \\equiv P_{qq}^V \\pm P_{q\\overline{q}}^V\\,, \\\\\n\\\\\n\\displaystyle P_{qq} \\equiv P^+ + n_f (P_{qq}^S + P_{q\\overline{q}}^S)\\,,\\\\\n\\\\\n\\displaystyle P^V \\equiv P^- + n_f (P_{qq}^S - P_{q\\overline{q}}^S)\\,,\n\\end{array}\\,,\n\\end{equation}\nwhere $n_f$ is the number of active flavours at a given scale $\\mu$\nand the splitting functions $P_{qq}^V$, $P_{q\\overline{q}}^V$,\n$P_{qq}^S$, $P_{q\\overline{q}}^S$ have the usual perturbative\nexpansion:\n\\begin{equation}\nP(x,\\mu)=\\sum_{n=0}\\left(\\frac{\\alpha_s(\\mu)}{4\\pi}\\right)^{n+1}P^{(n)}(x)\\,.\n\\end{equation}\nGiven the expansion above, one can show that at\n$\\mathcal{O}(\\alpha_s)$, \\textit{i.e.} leading order, all coefficients\nbut $P_{qq}^{V,(0)}$ vanish. It is then easy to see that:\n\\begin{equation}\nP_{qq}^{(0)} = P^{V,(0)} = P ^{+,(0)}= P^{-,(0)}=P_{qq}^{V,(0)}\\,.\n\\end{equation}\nThis means that the evolution equations in Eq.~(\\ref{eq:evoleqs}) have\nall the same evolution kernel.\n\nIf one wants to include NLO corrections, one finds that the\n$\\mathcal{O}(\\alpha_s^2)$ coefficients $P_{qq}^{V,(1)}$ and\n$P_{q\\overline{q}}^{V,(1)}$ are different from zero while\n$P_{qq}^{S,(1)}$ and $P_{q\\overline{q}}^{S,(1)}$ vanish. This\nimmediately implies that $P_{qq} = P^+$ and $P^V = P^-$. Therefore, at\nNLO, the evolution equations are fully determined by the functions\n$P_{qq}^{V,(0)}$, $P_{qq}^{V,(1)}$, and\n$P_{q\\overline{q}}^{V,(1)}$. We are now in the position to discuss the\nspecific expressions of these functions for both PDFs and FFs. A\nfurther simplification is given by the fact that the function\n$P_{qq}^{V,(0)}$ is the same for both PDFs and FFs. However, this is\nno longer the case for $P_{qq}^{V,(1)}$ and\n$P_{q\\overline{q}}^{V,(1)}$ whose form differs between PDFs and FFs.\n\nIn order to carry out the implementation of the splitting functions in\n{\\tt APFEL}, it is necessary to make sure that the expressions of the\nsingle coefficients of the perturbative expansions have the following\nstructure:\n\\begin{equation}\\label{eq:splittingfuncs}\nP(y) = R(y) + S \\left(\\frac1{1-x}\\right)_++ L\\delta(1-y)\\,,\n\\end{equation}\nwhere $R$ is a regular function in $x=1$, and $S$ and $L$ are\nnumerical coefficients. The plus prescription used above has the\nfollowing definition upon integration with a test function $f$:\n\\begin{equation}\n\\int_0^1dy\\left(\\frac1{1-y}\\right)_+f(y)\\equiv \\int_0^1dy\\frac{f(y)-f(1)}{1-y}\\,.\n\\end{equation}\nAn important detail to notice is that the definition above is strictly\ntrue only if the lower integration bound is equal to zero. In actual\nfacts, this is never the case because Mellin convolutions involving\nplus-prescripted functions have the following structure:\n\\begin{equation}\n\\int_x^1dy\\left(\\frac1{1-y}\\right)_+f(y)\\,.\n\\end{equation}\nwith $0<x<1$. This integral can be manipulated as follows:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle \\int_x^1dy\\left(\\frac1{1-y}\\right)_+f(y) &=&\n                                                           \\displaystyle\n                                                           \\int_0^1dy\\left(\\frac1{1-y}\\right)_+f(y)\n                                                           -\n                                                           \\displaystyle\n                                                           \\int_0^xdy\\left(\\frac1{1-y}\\right)_+f(y)\\\\\n\\\\\n&=& \n                                                           \\displaystyle\n                                                           \\int_0^1dy \\frac{f(y)-f(1)}{1-y}\n                                                           -\n                                                           \\displaystyle\n                                                           \\int_0^xdy\\frac{f(y)}{1-y}\\\\\n\\\\\n&=& \n                                                           \\displaystyle\n                                                           \\int_x^1dy \\frac{f(y)-f(1)}{1-y}\n                                                           -\n                                                           \\displaystyle\n                                                           f(0)\\int_0^x\\frac{dy}{1-y}\\\\\n\\\\\n&=& \n                                                           \\displaystyle\n                                                           \\int_x^1dy \\left(\\frac{1}{1-y}\\right)_{\\oplus}f(y)\n                                                           +f(0)\\ln(1-x)\\\\\n\\\\\n&=& \n                                                           \\displaystyle\n                                                           \\int_x^1dy \\left[\\left(\\frac{1}{1-y}\\right)_{\\oplus}+\\ln(1-x)\\delta(1-y)\\right]f(y)\\,,\n\\end{array}\n\\end{equation}\nwhere we have defined a ``generalised'' plus prescription that holds\nin its form regardless of the lower integration bound:\n\\begin{equation}\n\\int_x^1dy\\left(\\frac1{1-y}\\right)_\\oplus f(y)\\equiv \\int_x^1dy\\frac{f(y)-f(1)}{1-y}\\,.\n\\end{equation}\nTherefore, a Mellin-like convolution of the splitting function in\nEq.~(\\ref{eq:splittingfuncs}) with the test function $f$ will take the\nform:\n\\begin{equation}\n\\int_x^1 dy P(y) f(y) = \\int_x^1 dy \\left[ R(x)\n  +S\\left(\\frac1{1-y}\\right)_\\oplus + \\left(L+S\\ln(1-x)\\right)\\delta(1-y)\\right] f(y)\\,.\n\\end{equation}\nThis provides a suitable expression for the implementation in {\\tt\n  APFEL}. Therefore, one just needs to manipulate the expressions\ngiven in the literature to reduce them to the form of\nEq.~(\\ref{eq:splittingfuncs}). This is typically an easy task.\n\nLet us start with $P_{qq}^{V,(0)}$ that we take from Eq.~(38) of\nRef.~\\cite{Vogelsang:1997ak}.\\footnote{A factor 2 is introduced to\n  account for the different expansion parameter, here $\\alpha_s/4\\pi$\n  rather than $\\alpha_s/2\\pi$} After a simple manipulation,\nit takes the form:\n\\begin{equation}\\label{eq:LOsplitting}\nP_{qq}^{V,(0)}(y) = 2C_F\\left[-2+2\\left(\\frac{1}{1-y}\\right)_++\\frac32\\delta(1-y)\\right]\\,.\n\\end{equation}\nIn this form it is easy to identify the elements introduced in\nEq.~(\\ref{eq:splittingfuncs}). In particular, we find that\n$R(x)=-4C_F$, $S=4C_F$, and $L=3C_F$. As mentioned above,\n$P_{qq}^{V,(0)}$ is the same for PDFs and FFs, therefore the\nexpression in Eq.~(\\ref{eq:LOsplitting}) is all one needs to implement\nthe LO evolution of both transversity PDFs and FFs\n\nWe now consider the NLO corrections. In order to distinguish between\nPDFs and FF we will use the symbols $\\mathcal{P}$ and $\\mathbb{P}$,\nrespectively, for the splitting functions. We first consider the PDF\nsplitting functions that we again take from\nRef.~\\cite{Vogelsang:1997ak}. We observe that\n$\\mathcal{P}_{q\\overline{q}}^{V,(1)}$, taken from Eq.~(44) of this\npaper, is a purely regular functions with no plus-prescripted and\n$\\delta$-function terms. Therefore, it needs no manipulation:\n\\begin{equation}\\label{eq:PDFLOsplittingqqb}\n\\mathcal{P}_{q\\overline{q}}^{V,(1)} (y) =\n4C_F\\left(C_F-\\frac12C_A\\right)\\left[ - 1 + y -\\frac{4S_2(y)}{1+y}\\right]\\,,\n\\end{equation}\nwith:\n\\begin{equation}\nS_2(y) = -2\\mbox{Li}_2(-y) - 2\\ln y\\ln(1+y)+\\frac12\\ln^2y-\\frac{\\pi^2}{6}\\,.\n\\end{equation}\n\nThe function $\\mathcal{P}_{qq}^{V,(1)}$ from Eq.~(43) of\nRef.~\\cite{Vogelsang:1997ak} is instead more complicated but can be\nrecasted in the form of Eq.~(\\ref{eq:LOsplitting}) as:\n\\begin{equation}\\label{eq:PDFLOsplittingqq}\n\\begin{array}{rcl} \n  \\mathcal{P}_{qq}^{V,(1)} (y) &=& \\Bigg\\{\\displaystyle 4C_F^2 \\left[ 1-y -\\left( \\frac{3}{2} + \n                                   2 \\ln (1-y) \\right) \\frac{2y\\ln\n                                   y}{1-y}\\right]\\\\\n  \\\\\n                               &+& \\displaystyle 2C_F C_A\\left[\n                                   - \\frac{143}{9} +\n                                   \\frac{2\\pi^2}{3} +y + \\left( \\frac{11}{3} \n                                   + \\ln y  \\right) \\frac{2y\\ln\n                                   y}{1-y}\\right] + \\displaystyle \\frac{8}{3} n_f C_F\n                                   T_R  \\left[ - \\frac{2y\\ln y}{1-y}+ \\frac{10}{3} \\right]\\Bigg\\}\\\\\n  \\\\\n                               &+& \\displaystyle \\Bigg\\{2C_F C_A\\left(\\frac{134}{9} -\n                                   \\frac{2\\pi^2}{3} \\right) - \\frac{80}{9} n_f C_F\n                                   T_R  \\Bigg\\}\\left(\\frac{1}{1-y}\\right)_+\\\\\n  \\\\\n                               &+& \\displaystyle\\Bigg\\{ 4C_F^2 \\left( \\frac{3}{8} -\\frac{\\pi^2}{2} + 6\\zeta (3) \n                                   \\right) + 2C_FC_A \\left( \\frac{17}{12} + \\frac{11 \\pi^2}{9} -\n                                   6 \\zeta (3) \\right) - \\frac{8}{3} n_f C_F\n                                   T_R\\left( \\frac{1}{4} + \\frac{\\pi^2}{3} \\right)\\Bigg\\} \\delta(1-y)\\,,\n\\end{array}\n\\end{equation}\nwhere the regular, plus-prescripted, and $\\delta$-function terms are\nenclosed between curly brackets.\n\nWe can now turn to consider the splitting functions for FFs. In this\ncase we take the expressions from Ref.~\\cite{Stratmann:2001pt}. From\nEq.~(17) of this paper we immediately see that:\n\\begin{equation}\n\\mathbb{P}_{q\\overline{q}}^{V,(1)} (y)=\\mathcal{P}_{q\\overline{q}}^{V,(1)} (y)\\,,\n\\end{equation}\nwhere $\\mathcal{P}_{q\\overline{q}}^{V,(1)}$ is given in\nEq.~(\\ref{eq:PDFLOsplittingqqb}). For $\\mathbb{P}_{qq}^{V,(1)}$ we\ninstead find:\n\\begin{equation}\n\\begin{array}{rcl} \n  \\mathbb{P}_{qq}^{V,(1)} (y) &=& \\Bigg\\{\\displaystyle 4C_F^2 \\left[ 1-y +\\left( \\frac{3}{2} + \n                                   2 \\ln (1-y) -2\\ln y\\right) \\frac{2y\\ln\n                                   y}{1-y}\\right]\\\\\n  \\\\\n                               &+& \\displaystyle 2C_F C_A\\left[\n                                   - \\frac{143}{9} +\n                                   \\frac{2\\pi^2}{3} +y + \\left( \\frac{11}{3} \n                                   + \\ln y  \\right) \\frac{2y\\ln\n                                   y}{1-y}\\right] + \\displaystyle \\frac{8}{3} n_f C_F\n                                   T_R  \\left[ - \\frac{2y\\ln y}{1-y}+ \\frac{10}{3} \\right]\\Bigg\\}\\\\\n  \\\\\n                               &+& \\displaystyle \\Bigg\\{2C_F C_A\\left(\\frac{134}{9} -\n                                   \\frac{2\\pi^2}{3} \\right) - \\frac{80}{9} n_f C_F\n                                   T_R  \\Bigg\\}\\left(\\frac{1}{1-y}\\right)_+\\\\\n  \\\\\n                               &+& \\displaystyle\\Bigg\\{ 4C_F^2 \\left( \\frac{3}{8} -\\frac{\\pi^2}{2} + 6\\zeta (3) \n                                   \\right) + 2C_FC_A \\left( \\frac{17}{12} + \\frac{11 \\pi^2}{9} -\n                                   6 \\zeta (3) \\right) - \\frac{8}{3} n_f C_F\n                                   T_R\\left( \\frac{1}{4} + \\frac{\\pi^2}{3} \\right)\\Bigg\\} \\delta(1-y)\\,,\n\\end{array}\n\\end{equation}\nthat is just a small difference in the regular term as compared to\n$\\mathcal{P}_{qq}^{V,(1)}$ in Eq.~(\\ref{eq:PDFLOsplittingqq}).\n\n\\begin{thebibliography}{alp}\n\n%\\cite{Vogelsang:1997ak}\n\\bibitem{Vogelsang:1997ak}\n  W.~Vogelsang,\n  %``Next-to-leading order evolution of transversity distributions and Soffer's inequality,''\n  Phys.\\ Rev.\\ D {\\bf 57} (1998) 1886\n  doi:10.1103/PhysRevD.57.1886\n  [hep-ph/9706511].\n  %%CITATION = doi:10.1103/PhysRevD.57.1886;%%\n  %144 citations counted in INSPIRE as of 07 Feb 2018\n\n%\\cite{Stratmann:2001pt}\n\\bibitem{Stratmann:2001pt}\n  M.~Stratmann and W.~Vogelsang,\n  %``Next-to-leading order QCD evolution of transversity fragmentation functions,''\n  Phys.\\ Rev.\\ D {\\bf 65} (2002) 057502\n  doi:10.1103/PhysRevD.65.057502\n  [hep-ph/0108241].\n  %%CITATION = doi:10.1103/PhysRevD.65.057502;%%\n  %15 citations counted in INSPIRE as of 07 Feb 2018\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "cd0c2e967e884f50671fbd613382a1a209ecdc18", "size": 15242, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/Transversity.tex", "max_stars_repo_name": "intrepid42/apfelxx", "max_stars_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/Transversity.tex", "max_issues_repo_name": "intrepid42/apfelxx", "max_issues_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/Transversity.tex", "max_forks_repo_name": "intrepid42/apfelxx", "max_forks_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.0946745562, "max_line_length": 145, "alphanum_fraction": 0.5789922582, "num_tokens": 4990, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.43105177461521216}}
{"text": "\\section{Abstract}\n\\frame{\\tableofcontents[currentsection, hideothersubsections]}\n\n\\begin{frame}\n\\frametitle{Abstract}\n\nProblem:\n\\begin{itemize}\n    \\item for natural gradients, there is still NO way to \\textbf{efficiently compute}\n        the inverse of Fisher info matrix $F^{-1}$ (or its product with a vector)\n\\end{itemize}\n\nIdea:\n\\begin{itemize}\n    \\item approximate $F^{-1}$ as block diagonal or block tridiagonal matrices\n\\end{itemize}\n\nResult:\n\\begin{itemize}\n    \\item has cheap iterations like SGD\n    \\item needs fewer iterations than well-tuned SGD with momentum \\\\\n        (not as few as Hessian-Free optimization (HFO))\n\\end{itemize}\n\n\\vspace{10mm}\n{\\footnotesize\nRecall: briefly, a momentum is a moving average of the gradients that\nthat helps accelerate SGD in the relevant direction and dampens oscillations.\n}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Abstract}\n{\\footnotesize\nLeft to right: \\\\\n$\\tilde{F}^{-1}$, its approximations $\\breve{F}^{-1}$ (top) and $\\hat{F}^{-1}$ (bottom), their absolute difference\n}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.2]{kfac_12}\n\\end{figure}\n(plotting absolute values of entries, dark means small)\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Abstract}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.25]{mnist_autoencoder}\n\\end{figure}\n(Baseline: well-tuned SGD with momentum)\n\\end{frame}\n", "meta": {"hexsha": "14136f69608e87b17498bef6978bbd3bdae2862d", "size": 1365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "talk/tor/kfac-20180824/abstract.tex", "max_stars_repo_name": "tttor/robot-foundation", "max_stars_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "talk/tor/kfac-20180824/abstract.tex", "max_issues_repo_name": "tttor/robot-foundation", "max_issues_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "talk/tor/kfac-20180824/abstract.tex", "max_forks_repo_name": "tttor/robot-foundation", "max_forks_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7547169811, "max_line_length": 114, "alphanum_fraction": 0.7296703297, "num_tokens": 389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764746, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.43105176556620195}}
{"text": "\\section{Recap}\nThe reservoir is not going to get colder.\nIt's a technique used in arts and sciences.\nYou want to heat something up,\nyou have a pan,\nfill it with water,\nput a smaller pan inside the water.\nWhat's called called?\nDouble boiling?\nI don't know.\n\nThe temperature is very constant,\nso you don't burn your food.\n\nSame thing here,\nthis thing stays at a very constant temperature.\n\nWhat I was trying to do was the following.\n\nI'm going to apply the ergodic principle.\nAll microscopic states are equally probable,\nassuming fixed temperature.\nIf not then it's crazy.\n\n\nThe probability density is $ \\rho_T (q, p, Q, P)$\nwhere $q,p$ refers to the system and $Q,P$ referred to the reservoir.\nThis is not one variable,\nbut an enormous number of variables,\nall the particles in the system.\nI realise this is a better notation.\n\\begin{align}\n    \\rho_T (q, p, Q, P) &\\sim\n    \\delta_\\Delta(E_t - H_T(q,p,Q,P))\n\\end{align}\nwhere the $\\delta_\\Delta$ is a finite-width delta function.\n\nNow what is the probability of finding my subsystem here in a particular\nmicroscopic state regardless of the reservoir state.\nWell I just have to integrate over all coordinates of the reservoir\n\\begin{align}\n    \\rho(q, p) &=\n    \\int dQ\\, dP\\,\n    \\rho_T(q, p, Q, P)\\\\\n    &=\n    \\int dQ\\, dP\\,\n    \\delta_\\Delta\\left( E_T - H_T(q, p, Q, P) \\right)\n\\end{align}\nThe bulk is bigger than the surface for big systems,\nbecause the bulk is cubed,\nbut the surface is squared,\nso it is negligible,\nso write the Hamiltonian as\n\\begin{align}\n    H(q, p) - H_R(Q,P)\n\\end{align}\n\\begin{align}\n    \\rho(q, p) &=\n    \\int dQ\\, dP\\,\n    \\rho_T(q, p, Q, P)\\\\\n    &=\n    \\int dQ\\, dP\\,\n    \\delta_\\Delta\\left( E_T - H(q, p) - H_R(Q, P)\\right)\\\\\n    &= \\Gamma_R \\left( E_T - H(q, p) \\right)\n\\end{align}\nwhere $\\Gamma_R$ is the number of microstates in the reservoir in the\nmicrocanonical ensemble.\n\\begin{align}\n    \\int dQ\\, dP\\, \\delta_\\Delta\\left( E_T - H - H_R \\right)\n    &= \\Gamma_R \\left( E_T - H(q, p) \\right)\n\\end{align}\nIn general,\nyou have to sum the microstates of the system minus the Hamiltonian of the\nsystem.\nYou want to get the energy minus the energy of the subsystem.\n\nBecause now,\nthis is going to be related to the entropy of the system.\nThe number of microscopic states is the exponential of the entropy of the\nreservoir.\n\n\\begin{align}\n    \\rho(q, p) &=\n    \\exp\\left[ \\frac{S_R}{k_B} \\left( E_T - H(q, p) \\right) \\right]\n\\end{align}\nand remember that $H$ is the energy of the subsystem,\nmuch smaller than $E_T$ the energy of the huge reservoir,\nso I can expand this as a Taylor series.\n\\begin{align}\n    \\rho(q, p) &=\n    \\exp\\left\\{ \n    \\frac{1}{k_B}\\left[ \n    S_R(E_T) - H(q, p) \\frac{\\partial S_R(E_T)}{\\partial E_T}\n    + \\cdots\n    \\right]\n    \\right\\}\n\\end{align}\nNow note\n\\begin{align}\n    \\frac{\\partial S_R(E_T)}{\\partial E_T} = \\frac{1}{T_R}\n\\end{align}\nby definition,\nand this energy is defined in the microcanonical ensemble.\nWhen you put two systems together they exchange energy,\nand because of that you get this relation.\nThen we are looking for a function of $q$ and $p$,\nand that dependence is in $H(q,p)$,\nand everything else is just a big fat constant.\nWhat I find is\n\\begin{align}\n    \\rho(q, p) &\\sim\n    \\exp\\left[ -\\frac{H(q, p)}{k_B T} \\right]\n\\end{align}\nwhere there are big overall constants I don't care about.\nSo when I look ta the microcanonical ensemble of the subsystem,\nit is a canonical ensemble.\nI just take that function and normalize it,\nthen I get the canonical ensemble.\nThe whole system is in a microcanonical ensemble,\nthen by the ergodic hypothesis,\nthe subsystem is in a canonical ensemble.\n\nAre they completely isolated?\nNot really.\nIn the thermodynamic limit,\nyou get the same answer anyway.\nYou can take htis as a motivation for cnaoniacal ensemble.\n\nIt's motivation,\nbut you get the same answer anyway.\nThis ensemble and that ensemble are idfferent.\nThey look completely different but they are not.\nThe reason is thata of states with large energy,\nand there are few states with low energies.\nOnly microscopic states iwth that energy actually matter.\nIt's usually easier to do calculatioss over all energies over all states\nthan to do integrals iwth this constraint.\nThe $e^{-H/k_BT}$ is better.\n\nIt is true that in some large systems,\nyou are couled to a large reservoir.\n\nA chemical reaction in abucket.\nThe room is a thermal reservoir.\nEverything is going to go back to 72 degrees,\nbecause the room is big and the air conditioner is going to turn on.\n\nThe justitication for whole of statical mechanics fromes from the microcanonical\nensemble and the ergodic hypotheiss.\nMost mportantly,\ntHe canonical and microcanonical give the same answer anywa.\n\nI want to continue the argument\nwith an important comment.\nWhat we showed with  this,\nifwe look at the parittion function of the canonical ensemble,\nI could write it as as sum over the enrgy,\nthe numbero f states of the energy\n\\begin{align}\n    Z &=\n    \\int dE\\,\n    e^{\\frac{S(E)}{k_B T} - \\frac{E}{k_B T}}\n\\end{align}\nand I say that\n\\begin{align}\n    \\Gamma(E) &= e^{\\frac{S(E)}{k_B T}}\n\\end{align}\nis a constant\nand hte only quantity that matters is\nthe area around $E^*$,\nbecause this $\\Gamma(E)$ is strongly peaked around there,\nso the integral becomes approximately\n\\begin{align}\n    Z &=\n    \\int dE\\,\n    e^{\\frac{S(E)}{k_B T} - \\frac{E}{k_B T}}\n    \\approx\n    \\left. e^{-\\beta\\left( E - TS \\right)}\\right|_{E=E^*}\n\\end{align}\nIt is the quantity that minimizes $E-TS$.\nWhat is it that minimizes $E-TS$?\nJust find\n\\begin{align}\n    0 &=\n    \\left.\\frac{d}{dE}\\left( E - TS(E) \\right)\\right|_{E=E^*}\\\\\n    &=\n    \\left.\n    1 - T \\frac{\\partial S}{\\partial E} \\right|_{E=E^*}\n\\end{align}\nand you have seen this before.\nChoose the value of the derivative that gives $1/T$.\nDo you recognize the Legendre transform here?\nThis is a common mathematical construction.\nIt has a geometric meaning.\nIt was presented to you without motivation,\nbut I will tell you.\n\nTake a mental picture of this,\nand I'm going to go back,\nand tell you,\nsee it's the same thing.\nSo take a picture of this.\nThis piece of mathematics\nI'm not going to explain why,\nactually comes from studies from the Renaissance\nfrom presecive drawing.\n\nDistant things dhould be smaller.\nLines that are parallel in the real world seem to converge to a point.\nCompletely obvious to us,\nbut not obvious 500 years ago.\nGoogle Byzantine art,\nthey have an opposite idea.\nClose things are big,\nbut far away things are big.\nYou look and it looks naturla,\nbut it doens't loko realisatic,\nbuthten you realise it's all wrong,\nit's hte other way around.\nThen people started figuring out the mathematics of persepctive,\nand 200 years later they come up with something that has nothing to do with\npersepcive.\nI'm going to tell you taht.\n\n\nSuppose we have af unction $f(x)$.\nI need to specify what value of $f$ for each value of $x$.\nThat's what you learnt in 5th grade.\nSo the height is the $f(x)$ for each value of $x$ on the horziontal axis,\nlike sliced bread.\n\nBut there's another way.\nLook at the slope of this function,\nlook at this tangent.\nWhat if I want to specify this function\nnot in terms of $x$,\nbut in terms of the slope $\\frac{df}{dx}$.\nEvery point has a unique slope,\nso maybe I can specify the function in terms of the slope in\nterms of the $x$ coordainte.\nSo If I defined the slope to be\n\\begin{align}\n    p &= \\frac{df(x)}{dx}\n\\end{align}\nthen what is $f(p)$ supposed to be?\n\nFor example,\nsuppose $f(x)=x^2$,\nthen $p=2x$ which implies $x=p/2$ and so\nthen $f(p) = (p/2)^2$.\n\nSo the question is,\nhow high does it have to be to get a given tangent.\n\nThe same slope same height,\ndraw everything to the right,\nand say that's my curve.\nIf I specify my function in terms of the slope,\nthe curve is not unique\nif I shift myfunction to the right.\n\nIt does matter,\nbecause there is a constant\nthat is a function of the other variables,\nand it's not a constant anymore.\nSuppose you have $f(x - c)$ instead,\nthen you have many possible heights.\nThe non-uniqueness in enormous.\n\nSo someone invented something smarter than that.\n\nBy the way,\nyou see perspective here,\ndrawing tangents on curves?\nI dno't.\nIt's historical.\n\nInstead of specifying theheight as a function so the slope.\nInstead,\ngive me a slope,\nand I will give you where the tangent hits the vertical axis.\nI'm not giving you the $f(x)$ hieght,\nbut I'm giving you where the tangent intersects the $y$ axis.\nAnd so for a given tangent,\nI'm going to give you the $y$ intercept of the tangent.\n\nSo let's draw a picture.\nLet $p=dp/dx$ be the slope.\nThen let the $y$-axis intersection of the tangent be $\\tilde{f}(p)$.\nJust by looking at this picture,\nI can tell you the slope is going to be figured out by looking at\n$f - \\tilde{f}$.\nTake the ratio  of similar triangles\n\\begin{align}\n    p &= \\frac{f - \\tilde{f}}{x}\n\\end{align}\nIf that's true,\nthen I can isolate $\\tilde{f}$ as a function of $p$.\nAnd I can get\n\\begin{align}\n    \\tilde{f}(p) &=\n    \\left .f(x) - px\\right|_{x\\text{ such that } \\frac{df}{dx}=p}\n\\end{align}\nNow of course,\nthis condition is the same as saying that the\n$x$ you're using is minimal.\nBut this is the same condition you get if you took $f(x) - px$\nand minimize it in relation to $x$.\nSo it's the same thing.\n\nThe lesson is this.\nI can give all the information about this curvei n two wasy.\nI eigher specify the height $f(x)$ for every point $x$.\nOr I specify this intercept point $\\tilde{f}(p)$ for every possible slope $p$.\nNow there is no freedom to move this around,\nbecause the point specified is now unique.\n\nThat's the geometry I wanted you to know.\n\nSo either give me the height for every point,\nor give me the intercept of the tangent for every slope,\nand they contain the same information.\n\nSo let's do an example.\nSuppose\n\\begin{align}\n    f(x) &= x^2 + c\n\\end{align}\nThen\n\\begin{align}\n    p = \\frac{df}{dx} = 2x\n\\end{align}\nwhich means $x=p/2$ and so\n\\begin{align}\n    \\tilde{f}(p) &=\n    \\left. f - px\\right|_{\\frac{df}{dx}=p}\\\\\n    &=\n    \\left.\n    x^2 + a - pa\n    \\right_{x=p/2}\\\\\n    &=\n    \\frac{p^2}{4} + a - \\frac{p^2}{2}\\\\\n    &= -\\frac{p^2}{4} + a\n\\end{align}\nIf you have nothing better to do,\nyou can try to draw these tangents and points.\nBut,\nwe're not going to have to think about this geometry anymore.\n\nNow what does this have to do with thermodynamics.\nSo remember that the partition function was\n\\begin{align}\n    Z &=\n    \\left.\n    \\exp\\left[ -\\beta\\left( E - TS \\right) \\right]\n    \\right|_{E = E^*}\\\\\n    &=\n    \\left.\n    \\exp\\left[ -\\beta\\left( E - TS \\right) \\right]\n    \\right|_{\\left.\\frac{\\partial S}{\\partial E}\\right|_{E=E^*} =\n    \\frac{1}{T}}\n\\end{align}\nSo I want to write $Z$ as a function of $T=\\frac{\\partial E}{\\partial S}$,\nbut I lose information,\nso instead of playing with $E$,\nI play with $E-TS$.\nThis allows me to get rid of the $S$,\nin the same way the Legendre transform $\\tilde{f} = f - px$\nallows me to get rid of the $x$.\nAnd htis has a name,\ni'ts the Helmholtz free energy.\n\\begin{align}\n    Z \\sim\n    e^{-\\beta F(T, U, N)}\n\\end{align}\n\nI want to talk about 3 things:\nWhy is this an energy?\nWhat's free about it?\nAnd some examples.\n\nWhy is it free? There is an explaatintio sort of I'll explain later.\n\nWho is Helmholtz?\nA physicist of course.\nBut actually he wasn not,\nhe was a professor of medicine.\nHelmholtz free energy,\nHelmholtz coil,\nbut that's not what he's famous for.\nHis main thing was to understand how to understand the ear works.\nPsychoacoustics.\nthat's hwy Helmholtz appears in PDEs,\nsolving the wave eqution.\nHow does that interact iwth the ears.\nHis famous book is the sound of tones.\nI learnt a huge amount of this as an amateur musician,\nand I could tlka and talk.\n\nThe story is this:\nThere's a trandition in the academic route,\nmore theroetical than expeirmenta,\nmore in math than physics.\nYour advisor is an important person in your life,\nmore important than your mother, your spouse.\nIt's old-fashinoed,\nso there's a tradition of following your academic advisor.\n\nThere's a websitte that keeps track of those things.\nOne interesting happens,\nthose things converge on a few peple.\nThe world of physics was smaller 100 years ago.\nThe rason is because,\nthere are people productive in terms of students,\nand others who are not.\nWe all had a common mother,\nbut same thing hapens in phycis.\n\nMy advisor,\nwas a student of some guy yo don't know,\nwho was studyent of some guy yo udont't kno,w\na student of some guy you don't know,\nwho was a sutdent of some guy you don't know,\nwho was a student of Helmholtz!\n\nThere are few schools fof physics.\nIn the US,\neveryt student was a student of Schwinger.\nOppenheimer was not,\nbut he shared with Schwinger.\n\nSommerfeld had good students.\nHeisenberg, Pauli,\nand those had many others.\nSo Sommerfield.\n\nEinstine has 0 zeros.\nThere was one guy who claimed to be,\nbut he was an epximerntalist and he signed his papapers.\n\nAt some point we're in the middle ages,\nthe only people who are scientsits are people who read and write,\nand they are from the Church.\nSo basically it's who was the head of hte Monastary.\nThe Church kept records,\nand then you can find themenotor of that person.\nThere's no PhD,\nbut there were records.\nAnd then they go down to Jesus.\nSo I'm a direct line from Jesus.\nDoes that mean I should take more stdents because of that?\n\nBut Jesus was baptized by John the Baptist,\nso that's his advisor.\n\nA new continent has been discovered.\nThey want ot colonie the place.\nThey say you hvae land,\nyou can start your own farm.\nHowm uch land?\n\nI'm going to give you some amount of fence.\nA mile.\nWhatever land you can enclose in the fence,\nyou have it for life.\nPeople go there and the question is what shape is best?\nYou're a farmer and you want as much land as possible.\nBut the perimeter is fixed.\nWhat's the shape?\nI'ts a circle.\nCan anyone prove that?\nI'm not goin to prove it but its' corect.\n\n\nThen there's ano hte continent.\nFencing is very expensive.\nThe government fixes a certain amount of area and land they can claim.\nThey can surround byfence.\nSo for a fixed area they want otm imize the amount of fencing.\nA circle too!\n\nSo if you arrive ina contentn and see all the farms are circles,\nthe govenremnt must hvae given them a fixed amount of frncnig each.\n\nWe play this game where we play the system,\nand you have walls.\nWhen you can change the walls,\nand it's isolated from everything else.\nThe total energy is fixed.\n$E = E_1 + E_2 + \\cdots$.\n\nBut to find the final state.\nThe entropy is\n$S=S_1+S_2+\\cdots$.\n\nHow can I divide energy among the systems to maximise the energy?\nThere's ano hte quantit y fixed,\nthat's the total volume\n$V=V_1+V_2+\\cdots$.\n\nWe want to do this maxmiiation over a certain substate of all macroscopic\nstates.\nThe walls can move,\nbut I cannot change the sum of them.\nI maximize the entropy under some constraints.\nThe constratins are the total energy $E$,\nthe total vomelume $V$, the totla number $N$.\n\nCircles are the ones with largest area for a fixedp erimeter.\n\nBut hter'es naother way to characerise the same state.\nYou can say circles are the minimial perimeter for a given area.\nFor us,\nyou minimize the energy $E=E_1+E_2+\\cdots$\nassuming the energy is fixed,\nthat is $S,V,N$ are fixed.\n\nAfter the final state,\nit doesn't matter how you got there.\nThe same satate is characterized by thet minmimal energy\nf o a fixed tempreatuer.\nEven though in pracitse,\nit's not mimimze the enrgy and fix the tempratuere,\ntheres no way ot fix the entorpy in the real world,\nbut it doesn't matter because mathematically it's the same thing.c\nThis requires a proof,\nand the proof is done by a very good drawing,\nbecause that's the best way to prove things.\n\nYou want a good drawing?\nLook at my lecture notes.\nIt sucks to draw good on the board.\n\nThink.\n\nI'm going to have an axis $S$.\nThe energy starts out as $E_1,E_2,\\ldots$,\nthen it's going to become\n$E_1',E_2',\\ldots$.\nSo let's have another axis $E_1'$.\nI plot $S$ as a function of $E_1'$.\nIt looks like a curve with some maximum.\nThen I have another axis,\nthe total energy $E$.\nSuppose I did the same problem,\nbut with a total energy that was larger.\nMy claim is that the drawing would look like the following.\nI have a surface $S(E,E_1')$.\nDo you sense a 3D thing here?\nDoes that help?\nPretty good.\n\n[picture]\n\nNow,\nthe entropy goes as a the total energy gorws.\nThat's a feature.\nThe more energy,\nthe more microstates.\n\nWhat this principle says is to ask what are the surfaces of fixed energy.\n\nI take a surface of fixed energy $E$\nand I draw this plane.\nThe intersection.\n\nIf you fix the energy $E$,\nand look for the maximum $S$.\n\nNow I'm going to do an identical drawing.\n\nNow I'm going to think about this other principle here.\nConstant total energy means this plane here.\n\nNow I look for a macroscopic state with fixed entropy.\nthat minimizes the energy.\n\nI screwed up the drawing,\nbut they should be the same point.\n\nThat's my picture proof of this principle.\n\nThis principle is called the maximum entropy principle,\nwhich follows from the ergodic hypothesis.\nThis macroscopic state corresponds to the maximum number of microscopic states.\n\nThis one here is called the minimum energy principle,\nand is justified because the maximum entropy principle.\nI have never used the minimum energy principle,\nbut I am only using it as a steping stone to prove something else.\n\n\nConsider the Helmholtz free energy of two systems\n\\begin{align}\n    F = F_1 + F_2\n\\end{align}\nand the problem is to minmize $F=F_1+F_2$ subject\nto the constraint of fixed $T,V,N$.\nTHe idea is this.\n\nYou have some subsystem immersed in a thermal reservoir of temperature\n$T$.\n\nThink of this as two subsystems $A$ and $B$.\nThen we maximize the total energy.\nAltenratively,\nconsdier entropy fixed and minimize the energy.\n\nThe energy is fixed,\nit can vary,\nbut states vary and you fix the entropy.\nTHep roblem is that you have to look at 3 different systems,\nand if one if the systmes is a thermal reservoir,\nit's a special system that doesn't change temperature and that simplifies\nthings.\nSo rather than apply maximal energy,\nyou just minimal free energy,\nand I'm going toshow tat.\n\nWe want to minimze free eneergy\n\\begin{align}\n    F &= E - TS\n\\end{align}\nfor fixed temperature $T$.\nLet's start assuming that minimal energy is correct.\nWe want to minimize $E_T$ at fixed $S$.\nWhat's the chnage in the energy of the whole thing?\n\nThe change in total energy is $E_T=E+E_R$,\nso\n\\begin{align}\n    dE_T &= dE + dE_R\n\\end{align}\nand I want to set $dE_R$.\nThe energy doesn't change because it does work,\nit doesn't change because particles corss the wall,\nit changes only because heat energy isexchanged.\nHow is that related to the changing entropy?\nRemember that\n\\begin{align}\n    \\left.\\frac{dS}{dE}\\right|_{V,N} &= \\frac{1}{T}\n\\end{align}\nand rememver $dE_R = T_R \\,dS_R$.\n\nThe reservoir gains some energy when this looses some entroy,\nso\n\\begin{align}\n    T_R dS &= - T_R dS\n\\end{align}\nso we get\n\\begin{align}\n    0 &= dE - TdS = d(E - TS) = dF\n\\end{align}\nBottom line,\nfix the energy,\nfind the maximmum entropy.\nAltenratively,\nfix the entropy\nand minmiaze the energy.\n\nBut you can forget about he reservoir completely.\nThen you only need to minimize the free energy.\nForget the reservoir.\nThen that gives you the state.\n\n\\begin{question}\n    The assumption is,\n    the bath is holding the subsystme at a fixed tempeature.\n\\end{question}\nYes, they're in thermal equilibrim by definition.\n\nAt this point,\nyou might be confused by many little observations made here and there.\nBut that's okay.\nI'm going to bring everything together.\nThe goal is to organize everything you learn about physics.\n\nI actually did write this on my lecture notes.\nIt's not just a colletion of formluae to mmmorize.\nIt's the logical relation between them that mattersl\nI'm going to write how you do things in the microcanonical ensemble.\nAnd on this other board,\nhow to do things in the canonicla ensembler.\n\n\\subsection{Microcanonical Ensemble}\nThe probability of getting a particular state is\n\\begin{align}\n    \\rho(q, p) &=\n    \\frac{\\delta_\\Delta\\left( E - H(q, p) \\right)}{%\n        \\int \\frac{d^Nq\\, d^N}{h^N} \\delta_\\Delta\\left( E - H(q, p) \\right)\n    }\n\\end{align}\nThe $h$ constant does not matter.\nIn the classical limit,\nthis gets left out here if I compute things.\nBut if you don't write $h$,\nlike when they first invented statistical mechanics,\nthey still got everything right.\nAnd this denomianotr is the number o states,\nwhich we call\n\\begin{align}\n    \\Gamma(E,V,N) &=\n    \\int \\frac{d^Nq\\, d^N}{h^N} \\delta_\\Delta\\left( E - H(q, p) \\right)\n\\end{align}\nThen the average of an observable is a weighted average\n\\begin{align}\n    \\overline{\\mathcal{O}}\n    &=\n    \\int \\frac{d^Nq \\, d^Np}{h^N}\n    \\rho(q, p) \\mathcal{O}(q, p)\n\\end{align}\nand that's in principle all you need.\nBut there are ways around,\nwhich is thermodynamics.\nThe entropy is\n\\begin{align}\n    S(E,V,N) &=\n    k_B \\ln \\Gamma(E, V, N)\n\\end{align}\nIf yo uwant to find s attae,\nyou should always maximize $S$ at fixed $E,V,N$.\nThis confused the hell out of me as a student.\nI was stupid.\nHow can I maximize $S$?\nThe total $E,V,N$ cannot change,\nbut the distribution of $E,V,N$ can change!\n\nFinally, a very good thing to remember is that\n\\begin{align}\n    \\left.\\frac{\\partial S}{\\partial E}\\right|_{V,N} &= \\frac{1}{T}\n\\end{align}\nhas to be the same for any two systems in equilibrium.\nAnd another thing equal for systems in equilibirum is this quantity\n\\begin{align}\n    \\left.\\frac{\\partial S}{\\partial V}\\right|_{E,N} &= \\frac{P}{T}\n\\end{align}\nand another hting is also the chemical potneital\n\\begin{align}\n    \\left.\\frac{\\partial S}{\\partial N}\\right|_{E,N} &=\n    -\\frac{\\mu}{T}\n\\end{align}\nWe rarely do things in the microcanonical ensemble because yo uhave to compute\nthese crazy integrals with constraints.\n\n\n\\subsection{Canonical ensemble}\nThis is easier to work with.\nThe partition function is\n\\begin{align}\n    Z(T,V,N) &=\n    \\int \\frac{d^Nq\\, d^Np}{h^N} e^{-\\beta H(q,p)}\n\\end{align}\nand the probability distribution is\n\\begin{align}\n    \\rho(q, p) &=\n    \\frac{e^{-\\beta H(q, p)}}{%\n    \\int \\frac{d^Nq\\, d^Np}{h^N} e^{-\\beta H(q,p)}\n    }\n    =\n    \\frac{e^{-\\beta H(q, p)}}{%\n    Z\n    }\n\\end{align}\nand the average of an observable is likewise\n\\begin{align}\n    \\overline{\\mathcal{O}}\n    &=\n    \\int \\frac{d^Nq \\, d^Np}{h^N}\n    \\rho(q, p) \\mathcal{O}(q, p)\n\\end{align}\nAnd then I consider the free energy which is the Legendre transform of the\nenergy\n\\begin{align}\n    F(T,V,N) &= E - TS = -k_B T \\ln Z(T, V, N).\n\\end{align}\nIt contains the same information as the entropy.\n\nYou could compute the $\\rho$,\nbut it's easier to compute the denominator $Z(T,V,N)$,\nthen I compute the free energy from $Z$.\n\nOne thing is that\n\\begin{align}\n    \\left. \\frac{\\partial F}{\\partial T}\\right|_{V,N} &= -S\\\\\n    \\left. \\frac{\\partial F}{\\partial U}\\right|_{T,N} &= -P\\\\\n    \\left. \\frac{\\partial S}{\\partial N}\\right|_{T,V} &= N\\\\\n\\end{align}\n\nNote\n\\begin{align}\n    \\left.\\frac{\\partial E}{\\partial S}\\right|_{V,N}\n    =\n    \\left.\\frac{\\partial E}{\\partial U}\\right|_{S,N}\n    = -P\n\\end{align}\nand\n\\begin{align}\n    \\left.\\frac{\\partial E}{\\partial N}\\right|_{S,V} &= \\mu\n\\end{align}\nThe sign comes from the fact that if you compress a system,\nyou increase the energy of a system.\n\nAlso,\nyou can take other kinds of Legrendre transforms with respect to other\nvariables,\nenthalpy,\nonly chemists use it,\nit's bad.\nThere's Gibb's free energy.\nAnd also with respect to $N$,\nyou get the grand canonical potential.\n\nSo there's a family of thermodynamic potentials.\nI'm not going to work out the details,\nbut it's very straightforward.\nI'll have a different ensemble.\n\nThe point is not to memorize the relations,\nthe point is to remember what's varying with what.\n\n\\begin{question}\n    Is there a quantum version of $E+PV$?\n\\end{question}\nThink of $v$ as the size of the box,\nso it's just a parameter in the Hamltonian.\nBut it's not an operator.\nImagine you have a system,\ntherei s a quanutm satte where particles are spread\nand another one concentrated here.\nThere will be an operator that measures the volume distribution though.\n\n\\subsection{Quantum Version}\nThe density matrix,\nnow an opeator is\n\\begin{align}\n    \\hat{\\rho} &=\n    \\frac{e^{-\\beta \\hat{H}}}{\\Tr e^{-\\beta\\hat{H}}}\n\\end{align}\nwhere the bottom is the partition function\n\\begin{align}\n    Z(T,V,N) &= \\Tr e^{-\\beta\\hat{H}}\n\\end{align}\nThe moment you hi thermodynamics,\nthose macrosconpic quantites are the same for classical and quantum.\nThat's weird.\nWhen relativity awas discovered,\nclasical physics had to change.\nWhen QM was discovered,\nclassical physics, EM had ot change.\nButwhen stat mech was dicovered,\nnothing had to change.\nIt's true in this universe,\ntrue in proably many other universes we cna imagine.\n\nThere's antoher point of view.\nThermodynamics has to be true even in different worlds.\n\nCna I write the equivalent quantum mechnical formula for these other equations?\nYes, but it's ugly.\n\\begin{align}\n    \\bar{\\mathcal{O}} &=\n    \\Tr(\\hat{\\rho}\\hat{\\mathcal{O}})\n\\end{align}\nand\n\\begin{align}\n    \\hat{\\rho} &=\n    \\frac{\\displaystyle \\sum_{n:E<E_n<E+\\Delta} \\ket{n}\\bra{n}}{%\n    \\displaystyle\\sum_{n: E<E_n<E+\\Delta} 1}.\n\\end{align}\nNot nice to compute.\nDo not waste a microsecond thinking about this.\n", "meta": {"hexsha": "5adbf4c5b2685cde6bb577df518127c5acf633a1", "size": 25264, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phys612/lecture17.tex", "max_stars_repo_name": "ehua7365/umdphysnotes", "max_stars_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-11T12:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-11T12:53:46.000Z", "max_issues_repo_path": "phys612/lecture17.tex", "max_issues_repo_name": "ehua7365/umdphysnotes", "max_issues_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phys612/lecture17.tex", "max_forks_repo_name": "ehua7365/umdphysnotes", "max_forks_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9724770642, "max_line_length": 80, "alphanum_fraction": 0.721461368, "num_tokens": 7211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.4310517651136937}}
{"text": "\\documentclass[11pt]{amsbook}\n\n\\usepackage{../HBSuerDemir}\t% ------------------------\n \n\\newtheorem*{theorem}{\\underline{Theorem}}\n\\newtheorem*{prf}{\\underline{Proof}}\n\\newcommand\\tab[1][2cm]{\\hspace*{#1}}\n\n\\newcommand\\tad[1][1cm]{\\hspace*{#1}}\n\\usepackage{framed}\n\\newcommand\\tal[1][0.5cm]{\\hspace*{#1}}\n\\usepackage{enumitem}\n\\usepackage{amssymb}\n\\usepackage{mhchem}\n\\usepackage{graphicx}\n\\usepackage{multienum}\n\\usepackage{amsmath}\n\\renewcommand\\thesubsection{\\alph{subsection}}\n\\usepackage[parfill]{parskip}\n\\usepackage{fancyhdr}\n\\newtheorem{definition}{Definition}\n\\usepackage{tikz}  % I use tikz package to draw function. Thanks to tikz package,I can draw these functions without using and putting any images.I merely write codes to constitute them.\n\\fancypagestyle{plain}{\n\\fancyhf{}\n\\renewcommand{\\headrulewidth}{0pt}\n\\fancyhead[C]{\\thepage}\n}\n\\pagestyle{fancy}\n\\usepackage{mathabx}\n\\usepackage{graphbox}\n\\usepackage{mdframed}\n\\newmdenv[bottomline=false]{notbottom}\n\n\\DeclareMathOperator{\\Sh}{Sh}\n\\DeclareMathOperator{\\Ch}{Ch}\n\\DeclareMathOperator{\\Th}{Th}\n\\DeclareMathOperator{\\Sech}{Sech}\n\n\n\\begin{document}\n% +++++++++++++++++\n\\hPage{b1p2/236}\n% +++++++++++++++++\n    \\renewcommand{\\labelenumi}{\\alph{enumi})}\n    \\begin{enumerate}\n    \\setcounter{enumi}{3}\n        \\item What is the element of the place 1 2?\n        \\item What is the sum of the diagonal elements?\n    \\end{enumerate}\n    \n    \\underline{Answer}.\n\n    \\begin{multienumerate}\n      \\setcounter{enumi}{0}\n      \\renewcommand{\\labelenumi}\n      {\\addtocounter{enumi}{1}\\alph{enumi})}\n    \\mitemxxxxx{3 x 3, 3}{4, 3, 1}{3 2,}{2,}{4.}\n    \\end{multienumerate}\n\n    \n    A determinant is \\emph{symmetric} if $a_{ij} = a_{ji}$, and \\emph{skew symmetric} if $a_{ij} = -a_{ji}$ for all places. Certainly the (main) diagonal  elements in a skew symmetric determinant are zero ($a_{ii} = -a_{ii} \\implies a_{ii} = 0$) and such a determinant is \\emph{zero axial}.\n    \n    \\underline{Example 2}. Complete the real determinant\n\n    \\[\n    \\begin{vmatrix} \n        0 & 3 & . & . \\\\ \n        . & t & -2 & . \\\\ \n        1 & . & 0 & 4 \\\\ \n        -5 & 0 & . & 2t  \n    \\end{vmatrix}\n    \\]\n\n    \\begin{multienumerate}\n      \\setcounter{enumi}{0}\n      \\renewcommand{\\labelenumi}\n      {\\addtocounter{enumi}{1}\\alph{enumi})}\n    \\mitemxx{if it is symmetric,}{if skew symmetric}\n    \\end{multienumerate}\n    \n    \\underline{Answer}.\n    \n    \\begin{multienumerate}\n      \\setcounter{enumi}{0}\n      \\renewcommand{\\labelenumi}\n      {\\addtocounter{enumi}{1}\\alph{enumi})}\n    \\mitemxx{\\[\n    \\begin{vmatrix} \n        0 & 3 & 1 & -5 \\\\ \n        3 & t & -2 & 0 \\\\ \n        1 & -2 & 0 & 4 \\\\ \n        -5 & 0 & 4 & 2t  \n    \\end{vmatrix}\n    \\]}{\\[\n    \\begin{vmatrix}\n        0 & 3 & -1 & 5 \\\\ \n        -3 & 0 & -2 & 0 \\\\ \n        1 & 2 & 0 & 4 \\\\ \n        -5 & 0 & 4 & 0  \n    \\end{vmatrix}\n    \\](t = 0)}\n    \\end{multienumerate}\n\n    \\underline{Minor and cofactor}: \n    \\paragraph{} In a determinant D of order n, by the \\emph{minor} $M_{ij}$ of  the place i j (or of the element $a_{ij}$) is meant the determinant  of order n-1 obtained by removing from D the ith row and jth column. The \\emph{cofactor} $C_{ij}$ of the same place is ($-1^{i+j} M_{ij}$).\n\n    \\underline{Example 3}. Find the minors and cofactors of the elements 5 and 4 in the determinant of Example 1.\n    %%%%%%%%%%%%%%%%%%%%\n    \\hPage{b1p2/238}\n    %%%%%%%%%%%%%%%%%%%\n\\begin{equation} \\label{eq:b2p1_238_firstEquation}\n\\begin{aligned}\nD = \\begin{vmatrix}\n    a_{11} & a_{12} & a_{13} & \\dots  & a_{1n} \\\\\n    a_{21} & a_{22} & a_{23} & \\dots  & a_{2n} \\\\\n    \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n    a_{n1} & a_{n2} & a_{n3} & \\dots  & a_{nn} \n\\end{vmatrix} &= a_{11}C_{11} +  ... + a_{1j}C_{1j} + ... + a_{1n}c_{1n} \\\\ &= \\sum_{j=1}^n  a_{1j}C_{1j}\n\\end{aligned}\n\\end{equation}\nwhere $C_{1j} = (-1)^{1+j} M_{1j} \\quad (j = 1 , ... , n)$ are cofactors so that\nthe evaluation of $D$ is reduced to the evaluation of determinants\nof order $n - 1$, which in turn are reduced to the evaluation of\ndeterminants of order $n - 2$, and so on. Thus\n$$\n\\begin{vmatrix}\n\ta_{11} & a_{12} \\\\\n\ta_{21} & a_{22}\n\\end{vmatrix} = a_{11}C_{11} + a_{12}C_{12} = a_{11}a_{22} - a_{12}a_{21}\n$$\nThe value given by \\refeq{eq:b2p1_238_firstEquation} is the \\textit{Laplace expansion} of $D$ with respect\nto the first row.\n\\par The same determinant $D$ has Laplace expansions with\nrespect to any other row or any column. It is proved in Linear\nAlgebra that all these expansions have the same value, hence\neach one can be used for the evaluation of $D$.\n\\par Thus we have\n\\begin{equation}\nD = a_{i1}C_{i1} + a_{i2}C_{i2} + ... + a_{in}C_{in} = \\sum_{j=1}^n a_{ij}C_{ij}\n\\end{equation}\nas Laplace expansion with respect to the $i$th row, and\n\\begin{equation}\nD = a_{1j}C_{1j} + a_{2j}C_{2j} + ... + a_{nj}C_{nj} = \\sum_{i=1}^n a_{ij}C_{ij}\n\\end{equation}\nas Laplace expansion with respect to the $j$th column.\n\\begin{exmp}\nEvaluate\n$$\n\\begin{vmatrix}\n\t8 & 1 & 6 \\\\\n\t3 & 5 & 7 \\\\\n\t4 & 9 & 2\n\\end{vmatrix}\n$$\nby expanding it with respect to the 3rd column, and 2nd row.\n\\end{exmp}\n%%%%%%%%%%%%%%+++++++\n\\hPage{b1p2/239}\n%+++++++++++++++++++++++\n\\begin{hSolution}\n\\begin{align*}\nD&=6\\cdot(-1)^{1+3}\n\\begin{vmatrix}\n  3 & 5 \\\\\n  4 & 9\n\\end{vmatrix}\n+7\\cdot(-1)^{2+3}\n\\begin{vmatrix}\n  8 & 1 \\\\\n  4 & 9\n\\end{vmatrix}\n+2\\cdot(-1)^{3+3}\n\\begin{vmatrix}\n  8 & 1 \\\\\n  3 & 5\n\\end{vmatrix}\\\\\n&=6(27-20)-7(72-4)+2(40-3)\\\\\n&=42-476+74=116-476=-360.\n\\end{align*} \\footnote{There was a redundant and wrong operation.}\n\\begin{align*}\nD&=3\\cdot(-1)^{2+1}\n\\begin{vmatrix}\n  1 & 6 \\\\\n  9 & 2\n\\end{vmatrix}\n+5\\cdot(-1)^{2+2}\n\\begin{vmatrix}\n  8 & 6 \\\\\n  4 & 2\n\\end{vmatrix}\n+7\\cdot(-1)^{2+3}\n\\begin{vmatrix}\n  8 & 1 \\\\\n  4 & 9\n\\end{vmatrix}\\\\\n&=-3(2-54)+5(16-24)-7(72-4)\\\\\n&=156-40-476=-360.\n\\end{align*}\n\\end{hSolution}\n\\par Any determinant can be evaluated this way vy expanding it with respect to any row (column), but as the order gets higher, calculations become laborious. The following theorems on determinants are helpful in simplifying the computations.\\\\\n\\begin{enumerate}[label=(\\Alph*)]\n\\setcounter{enumi}{2}\n\\item  THEOREMS ON DETERMINANTS\n\\end{enumerate}\n\\begin{theorem}\nIf D is a determinant and $D^{\\top}$ is its transpose, then $D^{\\top} = D$.\\\\\n\\end{theorem}\n \n\\par This is a consequence of evaluation of determinant by (2) and (3).\\\\\n\\begin{theorem}\nIf two rows (columns) of a determinant are interchanged, the determinant is changed in sign only.\\\\\n\\end{theorem}\n\\par When the given determinant is\\\\\n\\begin{align*}\nD=\n\\begin{vmatrix}\n \\cdots & a_{1k} & \\cdots & a_{1r} & \\cdots \\\\\\\\\\\\\n \\cdots & a_{nk} & \\cdots & a_{nr} & \\cdots \n\\end{vmatrix}\n,then\\quad D'=\n\\begin{vmatrix}\n \\cdots & a_{1r} & \\cdots & a_{1k} & \\cdots \\\\\\\\\\\\\n \\cdots & a_{nr} & \\cdots & a_{nk} & \\cdots\n\\end{vmatrix}\n = -D.\n\\end{align*}\\\\\n\\par This can be proved by induction.\n \\hPage{b1p2/245}\n\n    \\begin{hEnumerateArabic}\n    \\item[]\n    \\begin{hSolution}\\footnote{Solution starts above and item is added to avoid errors, both should be removed.}\n    \\par Selecting the second column tor expansion. multiplying the last row by 2 and adding to the second one. we get another zero element on that column:\n    \\begin{align*}\n        D &= \n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=3mm {\n                 2 &  3 & -4 & 5 \\\\\n                 4 &  4 &  2 & 1 \\\\\n                 3 &  0 &  6 & 4 \\\\\n                 3 & -2 &  4 & 1 \n            }\n        \\end{vmatrix}\n        \\begin{matrix}\n            \\xymatrix @R=5mm {\n                \\\\ \\\\ \\\\ \\ar@/_/[uu]_<2\n            }\n        \\end{matrix}\n        =\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=3mm {\n                 2 &  3 & -4 &  5 \\\\\n                10 &  0 & 10 &  3 \\\\\n                 3 &  0 &  6 &  4 \\\\\n                 3 & -2 &  4 &  1\n            }\n        \\end{vmatrix}\n        \\\\%=-=-=-=-=-=-=-=-=-=-=-=-=\n        &= -3\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=5mm {\n                10 & 10 &  3 \\\\\n                 3 &  6 &  4 \\\\\n                 3 \\ar@/_/[r]_<{-1} &  4 &  1\n            }\n        \\end{vmatrix}\n        -(-2)\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=5mm {\n                 2 & -4 &  5 \\\\\n                10 & 10 &  3 \\\\\n                 3 \\ar@/_/[r]_<{-1} &  4 &  1\n            }\n        \\end{vmatrix}\n        \\\\%=-=-=-=-=-=-=-=-=-=-=-=-=\n        &= -3\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=3mm {\n                10 &  0 &  3 \\\\\n                 3 &  3 &  4 \\\\\n                 3 &  1 &  1\n            }\n        \\end{vmatrix}\n        +2\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=3mm {\n                 2 & -6 &  5 \\\\\n                10 &  0 &  3 \\\\\n                 3 &  1 &  1\n            }\n        \\end{vmatrix}\n        = 84 + 100 = 184 \\text{\\footnotemark}\n    \\end{align*}\n    \\footnotetext{Sign error. Calculation error. Coefficient changed to +2, original was -2. result changed to 84 + 100 = 184, original was 84 - 100 = -16}\n    \\end{hSolution}\n    \n    \\setcounter{enumi}{5}\n    \\item Show that $x-5$ and $x+6$ are factors of\n    \\begin{align*}\n        P(x) =\n        \\begin{vmatrix}\n            \\xymatrix @R=3mm @C=3mm {\n                 x &  2 & -3 \\\\\n                 3 &  4 & -x \\\\\n                 5 &  2 & -3\n            }\n        \\end{vmatrix}\n    \\end{align*}\n    \n    \\begin{hSolution}\n    \\par $P(5) = 0$, since two rows are identical; $P(-6) = 0$\\footnote{To check whether x+6 is a factor we check P(-6)=0. Original was P(6)=0}, since two columns are identical.\n    \\end{hSolution}\n    \n    \\item Show that a skew symmetric determinant of order 3 is zero and that of order 4 is a perfect square of a polynomial.\n    \\-\n    \\begin{hSolution}\n        \\begin{align*}\n            \\begin{vmatrix}\n                \\xymatrix @R=3mm @C=3mm {\n                     0   & a_1  & a_2   \\\\\n                    -a_1 & 0    & a_3   \\\\\n                    -a_2 & -a_3 & 0\n                }\n            \\end{vmatrix}\n            = -a_1\n            \\begin{vmatrix}\n                \\xymatrix @R=3mm @C=3mm {\n                    -a_1 & a_3  \\\\\n                    -a_2 & 0\n                }\n            \\end{vmatrix}\n            + a_2\n            \\begin{vmatrix}\n                \\xymatrix @R=3mm @C=3mm {\n                    -a_1 & 0    \\\\\n                    -a_2 & -a_3\n                }\n            \\end{vmatrix}\n            = 0\n        \\end{align*}\n        \\par The property is true for all odd ordered skew symmetric determinants. The proof will be given on Matrices in Book II.\n    \\end{hSolution}\n    \\end{hEnumerateArabic}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/249}\n% ++++++++++++++++++++++++++++++++++++++\n\t\\begin{enumerate}\n\t\t\\item[11.]\n\t\tSame question for :\n\t\t\\[ \\left|\n\t     \\begin{array}{cccc}\n\t        0 & a & b & c\\\\\n\t        a & 0 & c & b\\\\\n\t        b & c & 0 & a\\\\\n\t        c & b & a & 0\n\t\t\\end{array}\n    \t\\right| \\]\n\n    \t\\item[12.]\n    \tProve the equality :\n    \t\\[ \\left| \\begin{array}{llll}\n\t        0 & a^2 & b^2 & c^2\\\\\n\t        a^2 & 0 & f^2 & e^2\\\\  \n\t        b^2 & f^2 & 0 & d^2\\\\\n\t        c^2 & e^2 & d^2 & 0\n    \t\\end{array} \\right|\n    \t=\n    \t\\left| \\begin{array}{cccc}\n\t        0 & 1 & 1 & 1\\\\\n\t        1 & 0 & c^2f^2 & b^2e^2\\\\\n\t        1 & c^2f^2 & 0 & a^2d^2\\\\\n\t        1 & b^2c^2 & a^2d^2 & 0\n    \t\\end{array} \\right| \\] \n\n    \t\\item[13.]\n    \tProve\n    \t\\[ \\left| \\begin{array}{llll}\n\t        0 & 1 & 1 & 1\\\\\n\t        1 & 0 & c^2 & b^2\\\\  \n\t        1 & c^2 & 0 & a^2\\\\\n\t        1 & b^2 & a^2 & 0\n\t    \\end{array} \\right|\n\t    =\n\t    \\left| \\begin{array}{cccc}\n\t        0 & a & b & c\\\\\n\t        a & 0 & c & b\\\\  \n\t        b & c & 0 & a\\\\\n\t        c & b & a & 0\n    \t\\end{array} \\right|\n    \t=\n    \t-16\\Delta^2,\n\t\t\\]\n    \t\n\t\t\\item[14.]\n\t\tIf\n\t\t\\[ \\left| \\begin{array}{cccc}\n\t        1 & a & a^2 & a^3\\\\\n\t        1 & b & b^2 & b^3\\\\  \n\t        1 & c^2 & 0 & a^2\\\\\n\t        1 & b^2 & a^2 & 0\n   \t\t \\end{array} \\right|\n    \t\t=\n    \t\t0 \n    \t\\] \n     \tshow that at least two of the numbers a, b, c, d must be equal to each other.\n\n    \t\\item[15.]\n    \tShow that the determinant\n    \t$\\begin{vmatrix}\n\t\ta_{ij} & + & x \n\t\t\\end{vmatrix}$\n\t\tof order n is of the form E + Fx where E, F are independent of x.\n\n\t\t\\item[16.]\n\t\tShow that one root of the equation\n\t\\end{enumerate}\n\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/252}\n% ++++++++++++++++++++++++++++++++++++++\n\nin \\(R^{n}\\), whose coordinates satisfy the equation. Therefore\n\n\\[a_{1}s_{1}+a_{2}s_{2}+\\dots+a_{n}s_{n}=b\\]\n\\\\\nIf a point is a solution of every equation of the system (2) it is a solution point of the system.\n\\\\\nAs we shall see, some systems have no solution, some have a unique solution and some others have infinitely many solutions. The system having no solution is said to be \\textit{inconsistent}, otherwise \\textit{consistent}.\n\\\\\nEvery HLS has the zero solution point, called the \\textit{trivial} solution.\n\\\\\n\\subsection{Solution by Determinants\\(^{(*)}\\)}\n\\label{subsec:SolutionbyDeterminants}\n\\footnote{(*) Solution matrices will be given in Book II.}\n\\\\\n\n\\subsubsection{Square NHLS}:\n\\label{subsubsec:SquareNHLS}\n\\\\\n\nLet  \\[a_{11}x_{1}+\\dots+a_{ij}x_{j}+\\dots+a_{1n}x_{n}=b_{1}\\]\n\\[\\quad\\quad\\quad\\quad\\quad\\quad\\quad\\quad\n\\vdots\\quad\\quad\\quad\\quad\\quad\\quad\n\\vdots\\quad\\quad\\quad\\quad\\quad\\\n\\vdots\\quad\\quad\\quad\\vdots\n\\quad(m*n)\n\\quad\\quad\\quad(1)\n\\]\n\\[a_{n1}x_{1}+\\dots+a_{nj}x_{j}+\\dots+a_{nn}x_{n}=b_{1}\\]\n\nbe a square NHLS. The determinant of the coefficients is\n\n\\[\nD=D_{coeff}= \\begin{vmatrix} \n    a_{11} &        & \\dots  & a_{1j} &  \\dots & a_{1n} \\\\\n    \\vdots &        &        & \\vdots &        & \\vdots \\\\\n    a_{n1} &        & \\dots  & a_{nj} &  \\dots & a_{nn} \\\\\n    \\end{vmatrix}\n\\]\n\n\\begin{thm}[CRAMES's Rule]\n\tThe square system (1) has the unique solution point.\n\n\t\\[\n\t\t\\left(\n\t\t\tx_1 = \\frac{D_1}{D} , \\dots ,\n\t\t\tx_j = \\frac{D_j}{D} , \\dots ,\n\t\t\tx_n = \\frac{D_n}{D}\n\t\t\\right)\n\t\\]\n\n\tif D \\(\\neq\\) 0, and has no solution or infinitely many solution points\n\t\\\\\n\tif D = 0, where D\\(_j\\) is the determinant obtained from D replacing its jth column by the column of constants.\n\\end{thm}\n%%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2-263}\n%%%%%%%%%%%%%%%%%%%%%5\n\\centerline{ANSWERS TO EVEN NUMBERED EXERCISES} \n\\begin{flushleft}\n22. (0, -3, -1)\\\\\n24. a $\\neq$ 1, b $\\neq$ 1, a $\\neq$ b \\ \\ \\ \\ consistency\\\\\n26. ($\\lambda$a, \\ $\\lambda$b, \\ $\\lambda$c)\\\\\n30. a) No solution, \\ \\ \\ \\ b) (2 - 7t/2, \\ -1 + 3t/2, \\ t)\\\\\n32. a) ($\\pm2$, $\\pm1$, $\\pm3$) (all combinations of signs) b) (2, -1, 3) \\\\\n34. 5a + 6b = 17, \\ \\ c = 11/7 \\\\\n\\end{flushleft}\n\n\\centerline{A SUMMARY}\n\\centerline{(CHAPTER 3)}\n\\begin{framed}\n\\begin{flushleft}\nExpansion of a determinant of order n:\n\\end{flushleft}\n\\begin{align*}\nD = \\hAbs{a_{ij}}_{n}\n& = \\sum_{i = 1}^n \\ a_{ij} \\ c_{ij} \\ \\ \\ \\ \\text{by the jth column} \\\\\n& = \\sum_{j = 1}^n \\ a_{ij} \\ c_{ij} \\ \\ \\ \\ \\text{by the ith row} \\\\\n\\end{align*}\nCRAMER's Rule: For a SNHLS,\n\\begin{align*}\n    x_{j} = \\frac{D_{j}}{D} \\ \\text{if} \\ D \\neq 0,\\ where\n\\end{align*}\nD is the determinant of coefficients, $D_{j}$ is the determinant obtained from D replacing its jth column by the column of constants.\\\\\nFor SHLS,\\\\\n\\centerline{when D = 0 system may have non trivial solution.}\n\\end{framed}\n\\centerline{MISCELLANEOUS EXERCISES}\n\\begin{flushleft}\n36. Show that x+1 is a factor of\n\\end{flushleft}\n\n\\centerline{$\\begin{vmatrix}\n &x+1 &2 &3 \\\\\n &1 &x+1 &3 \\\\\n &3 &-6 &x+1 \n\\end{vmatrix}$}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n \t\t\t\t\\hPage{b1p2/266}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    \n    \\begin{hEnumerateArabic}\n        \\setcounter{enumi}{46}\n        \\item Prove that the system\n            \\begin{align*}\n                x - y + z &= 0\\\\\n                2x + y - z &= 0\\\\\n                x + 5y - 5z &= 0\n            \\end{align*}\n        \n        \\noindent is consistent and solve it.\\\\\n     \n        \\item Solve\n            \\begin{align*}\n                3x + 5y - 7z &= 13\\\\\n                4x + y - 12z &= 6\\\\\n                2x + 9y - 3z &= 20\\\\\n            \\end{align*}\n        \n        \\item Solve\n            \\begin{align*}\n                x_{1} + 2x_{2} + 3x_{3}+ 4x_{4} &= 5\\\\\n                2x_{1} + x_{2} + 4x_{3}+ x_{4} &= 2\\\\\n                3x_{1} + 4x_{2} + x_{3}+ 5x_{4} &= 6\\\\\n                2x_{1} + 3x_{2} + 5x_{3}+ 2x_{4} &= 3\\\\\n            \\end{align*}\n        \n        \\item Solve\n            \\begin{align*}\n                x_{1} + x_{2} + x_{3}+ x_{4}+ x_{5} &= 1\\\\\n                x_{1} - x_{2} + x_{3}+ x_{4}+ x_{5} &= 1\\\\\n                2x_{1} + 3x_{2} + x_{3}- x_{4}+ 2x_{5} &= -4\\\\\n                x_{1} + 3x_{3}+ x_{5} &= 6\\\\\n                x_{2} + 2x_{3}+ 3x_{4}- x_{5} &= 10\\\\\n            \\end{align*}\n    \n    \\end{hEnumerateArabic}\n    \n    \\begin{center}\n        \\section*{ANSWERS TO EVEN NUMBERED EXERCISES} \n    \\end{center}\n    \n    \\begin{hEnumerateArabic}\n        \\item[36.] \\hPairingParan{x+1}\\hPairingParan{x^2+2x+8}\n        \\item[46.]\n            D = \\hPairingParan{a+b+c+d}\\hPairingParan{a-b+c-d} \\hPairingBraket{\\hPairingParan{a-c}^2+         \\hPairingParan{b-d}^2} = 0\\\\\n            a + c = b + d   (circumscibed);   a=c, b=d (parallelogram)\n        \\item[48.]\\hPairingParan{1, 2, 0}\n        \\item[50.]\\hPairingParan{-2, 0, 3, 1, -1}\n    \\end{hEnumerateArabic}\n\n\t% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/271}\n% ++++++++++++++++++++++++++++++++++++++\n\n\\begin{exmp}\n\t Given the points $A(t, 3)$, $B(4, 5)$ and $C(4.8)$ \n\t\\begin{hEnumerateAlpha}\n\t\t\\item Find t if $A$, $B$, $C$ are collinear (Points of the same line) \n\n\t\t\\item Setting $t=-2$ find the equations of the lines $AB$ and $BC$. \n\n\t\t\\item Find the equation of the line through B and P(l, -1) \n\n\t\t\\item $d(P, BC)$, $d(P, AB)$ \n\t\\end{hEnumerateAlpha}\n\n\t\\begin{hSolution}\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\item Setting the coordinates of point in $Ax + By + C = 0$  we have the HLS \n\t\t\t$$tA + 3B + C = 0$$ $$4A + 5B + C = 0$$ $$4A + 8B + C = 0$$ \n\t\t\tTo have a non trivial solution we get\n\t\t%\\[\n\t\t \\begin{align*}\n\t\t\t\\begin{vmatrix}\n\t\t\tt & 3 & 1 \\\\ \n\t\t\t4 & 5 & 1 \\\\\n\t\t\t4 & 8 & 1 \n\t\t\t\\end{vmatrix}\n\t\t\t=0   \n\t\t\t\\hspace{1cm}  \\text{giving  $t = 4$.} \n\t\t\\end{align*}\n\t\n\t\t%\\] \n   \n   \t       This is one of the ways of solution. The others are:\n\t       \\begin{hEnumerateArabic}\n\t\t\t\\item  By the use of distance: For the collinearity, one of $\\mid AB \\mid$,$\\mid BC \\mid$ and $\\mid CA \\mid$ must be the sum of the \t\t\t\tother two.\n\t\t\t\\item By the use of slope: For the collinearity. the slopes of $AB$ and $BC$ must be equal. \n\t\t\t\\item By the use of equation: For the collinearity, the coordinate of one of the points, say of $A$, must satisfy the equation of the line \t\t\t\t\tthrough the other two points $B$, $C$. (This mean that $d(A, BC) = 0$ )\n\t\t\\end{hEnumerateArabic}\n\t\n\t\t \\item \\( \\frac{x - x_1}{x_2 - x_1} \\) \\( \\frac{y - y_1}{y_2 - y_1} \\) $\\Rightarrow$ \\\\\n   \t\t  \n\t\t  $AB$: \\( \\frac{x + 2}{y + 2} \\) \\( \\frac{y - 3}{y - 3} \\) $\\Rightarrow$ $x - 3y + 11 = 0$, \\\\\t\n   \n       \t\t  $BC$: $x_1 = x_2 = 4$ $\\Rightarrow$ $x = 4$\n\t\t\n\t\t\\end{hEnumerateAlpha}\n\t\\end{hSolution}\n\\end{exmp}\n%+++++++++++++++\n\\hPage{b1p1/278}\n%+++++++++++++++++\n\n\\begin{enumerate}\n\t\\item [7.] Show that the points\n    \t\\begin{enumerate}\n    \t\t\\item [a)] $(3, 0)$, $(6, 4)$, $(-1, 3)$ are the vertices of a right\n    \t\ttriangle (1) by means of slope, by the use of Pythagorean theorem,\n    \n    \t\t\\item [b)] $(2, 2)$, $(-2, -2)$, (2$\\sqrt{3}$, -2$\\sqrt{3}$) are the vertices\n    \t\tof an equilateral triangle.\n    \t\\end{enumerate}\n\t\n\t\\item [8.] Prove by means of slope that the points $(10, 0)$, $(5, 5)$, $(5, -5)$ and\n\t    $(-5, 5)$ are the vertices of a trapezoid.\n\t\n\t\\item [9.] Show that the points\n\t    \\begin{enumerate}\n    \t\t\\item [a)] $(2, 3)$, $(1, -3)$, $(3, 9)$ are collinear: \n    \t\t(1) by means of slope, \n    \t\t(2) by means of distance, \n    \t\t(3) by the use of equations,\n    \t\t(4) by determinants.\n\n\t\t    \\item [b)] $(1, -2)$, $(2, 3)$ and $(-2, -17)$ are collinear.\n\t    \\end{enumerate}\n\t\n\t\\item [10.] If the points $(a, 3)$, $(3, -6)$ and $(4, 7)$ are collinear, find $a$.\n\t\n\t\\item [11.] Show that the line\n\t    \\begin{equation*}\n\t         t(2x - y - 9) + k(x - 3y - 17) = 0\n\t    \\end{equation*}\n\t    \n\t    \\noindent passes through a fixed point for all values of $t$ and $k$. \n\t    What is the fixed point?\n\t\n\t\\item [12.] Show that\n    \t\\begin{equation*}\n    \t    \\begin{vmatrix}\n                x & y & \\ 1 \\\\ \n                -1 & 3 & \\ 1 \\\\ \n                3 & 5 & \\ 1\n            \\end{vmatrix}\n            \\ =\\ 0\n    \t\\end{equation*}\n    \tis the equation of the line through $(-1, 3)$ and $(3. 5)$.\n    \n    \\item [13.] If the vertices of a triangle are $A(2, 3)$, $B(5, 7)$, $C(3, 9)$, show\n    that the area of the triangle is\n\n\n%+++++++++++++++\n\\hPage{b1p2/279}\n%+++++++++++++++\n\\begin{align*}\n\tA = \\frac{1}{2} \n\t\\begin{vmatrix} 2 & 3 & 1 \\\\ 5 & 7 & 1 \\\\ 3 & 9 & 1 \\end{vmatrix}\\\\\n\\end{align*}\n\\end{enumerate}\n\\begin{hEnumerateArabic}\n\\setcounter{enumi}{13}\n\t\\item Prove that points (6, 6), (7, -1), (0, -2), (-2, 2) lie on a circle whose center is (3, 2).\\\\\n\t\\item Find the centers and radii of the following circles:\n\t\t\\begin{hEnumerateAlpha} \n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item $x^2+2y - 3x + y^2=0$\n\t\t\t\\columnbreak\n\t\t\t\t\\item $x^2 + y^2 + 4y =5$\n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\t\\item Write the equation of the circle whose center and radius are:\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item (2, 5), \\: r = 7\n\t\t\t\\columnbreak\n\t\t\t\t\\item (3, -4), \\:  r = 3\n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\t\\item Classify the following curves:\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item $x^2 -2x +y^2 + 4y +1 =0$\n\t\t\t\t\\item $x^2 +2x +y^2 -2y +2=0$\n\t\t\t\\columnbreak\n\t\t\t\t\\item $x^2 +y^2 - 4y +5 =0$\n\t\t\t\t\\item $(x-2y) \\cdot (2x+3y -5)=0$\n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\t\\item Write the standard equation of the parabola whose vertex A and directrix D are:\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item A(2, 5), \\: D: y = 3\n\t\t\t\\columnbreak\n\t\t\t\t\\item A(3, -4), \\: D: y = -2\n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\t\\item Write the standard equation of the exlipse whose center, eccentricity and a are:\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item (1, -2), \\: e = 2/3, \\: a = 6\n\t\t\t\\columnbreak\n\t\t\t\t\\item (-3, 0), \\: e = 4/5, \\: a = 5\n\t\t\t\\end{multicols}\t\n\t\t\\end{hEnumerateAlpha}\n\t\\item Same question if the given curve is a hyperbola:\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item (2, 3), \\: e = 5/3, \\: a = 3\n\t\t\t\\columnbreak\n\t\t\t\t\\item (-2, 1), \\: e = 5/4, \\: a = 8\\\\  \n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\\end{hEnumerateArabic}\n\n\\centerline{\\textbf{ANSWERS TO EVEN NUMBERED EXERCISES}\\footnote{I used setcounter to provide orders into the book(2,4,10,16)}} \n\n\n\\begin{hEnumerateArabic}\n\t\\setcounter{enumi}{1}\n\t\\item\n\t\t\\begin{hEnumerateAlpha}\n\t\t\t\\begin{multicols}{2}\n\t\t\t\t\\item (a, d),\n\t\t\t\\columnbreak\n\t\t\t\t\\item (-1, 5)\n\t\t\t\\end{multicols}\n\t\t\\end{hEnumerateAlpha}\n\t\\setcounter{enumi}{3}\n\t\\item x - 5y + 3 = 0\\\\\n\t\\setcounter{enumi}{9}\n\t\\item 4\n\t\\setcounter{enumi}{15}\n\t\\item\n\t\\begin{hEnumerateAlpha}\n\t\t\\begin{multicols}{2}\n\t\t\t\\item  $(x-2)^2 \\cdot (y-5)^2 = 49$,\n\t\t\\columnbreak\n\t\t\t\\item $(x - 3)^2 \\cdot (y + 4)^2 = 9$\\\\\n\t\t\\end{multicols}\n\t\\end{hEnumerateAlpha}\n\\end{hEnumerateArabic}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/280}\n% ++++++++++++++++++++++++++++++++++++++\n\n$18. \\ a) \\ 8(y-5) = (x-2)^2, \\qquad\\qquad\\qquad b) \\ 8(y+4) = (x-3)^2.$\n\n$20. \\ a) \\ 16(x-2)^2 \\ - \\ 9(y-3)^2 = 144, \\qquad \\ b) \\ 36(x+2) \\ - \\ 64(y-1)^2 = 2324.$\n    \n\\subsection{SECOND DEGREE CURVES (SDC)}\n\\label{sec:SECOND DEGREE CURVES (SDC)}\n\n\\subsubsection{DEFINITIONS AND CLASSIFICATION}\n\n\\ \n\nThe equation of a conic C in the general case is obtained by taking the directrix D and focus F arbitrarily in the analytic plane as\n\n  \\begin{equation}\n  D: f(x,y) = ax + by + c = 0, \\ (a^2 + b^2 = 1), \\ F(x_0,y_0) \\qquad \n  \\includegraphics[width=0.15\\textwidth]{images/b1p2-280-fig01} \n  \\end{equation}\n  From\n\n  \\begin{equation}\n  C = \\{P(x,y):d(P,F)/d(P,D) = e\\}\n  \\end{equation}\n\nwe have\n\n  \\begin{equation}\n  \\left( (x-x_0)^2 + (y-y_0)^2 )\\right/ |ax+by+c|^2 = e^2\n  \\end{equation}\n  \nwhich when expanded and arranged gives the general second degree equation (SDE):\n\n\t\\begin{equation}\n    \\label{eq:SDC}\n\tAx^2 + Bxy + Cy^2 + Dx + Ey + F = 0, \\ (A^2 + B^2 + C^2 \\neq 0)\n\t\\end{equation}\n\nas the equation of C where the coefficient A, B, ... , F are functions of constants $a, b, c, x_0, y_0$ and $e$. It follows that the equation of any conic is of second degree, since $A^2 + B^2 + C^2 \\neq 0$ But the equation \\eqref{eq:SDC} may represent curves other than the conics (ellipse, hyperbola, parabola) as seen from\n\n  \\begin{center}\n  $(2x - y + l)(x + y - 3) = 0$ %I could not understand which sign is that between x and y (x + y - 3) please check it from book.\n  \\end{center}\n\nwhich is of second degree and represents two intersecting lines (0 degenerate conic). % Also not sure is that 0\n\nA curve represented by second degree equation \\eqref{eq:SDC} in the variables $x, y$ is called a \\textit{second degree curve}. %Is there an \"a\" exist between \"by second\"? More than usual space exists there.\n\nThe following are, second degree curves: \n%++++++++++++++++\n\\hPage{b1p2/310}\n%+++++++++++++++\n    \\begin{flushleft}\n    side of $\\ell$.\n    \\end{flushleft}\n\n    \\subsection*{D. CURVES} \\hfill\\\\\n    \n    Circle and line are some curves having polar equations\n    \n    \\begin{equation*}\n         r=a,\\ r=a\\ cos\\theta,\\ r^2 -2r_{0}r cos(\\theta-\\theta_{0}) + r_{0}^2 -a^2=0\n    \\end{equation*}\n    \n    \\begin{equation*}\n        \\theta = \\theta_{0},\\ r=a\\ sec\\theta,\\ r(Acos\\theta + Bsin\\theta) + C =0\n    \\end{equation*}\n    \n    \\hfill\n    \n    \\begin{flushleft}\n    which are in the form $r=f(\\theta)$, or $F(\\theta,r)=0$.\n    \\end{flushleft}\n    \n    \\hfill\n    \n    An equation $r=f(\\theta)$, $\\theta=g(r)$ or $F(\\theta,\\ r)=0$ represents a curve in general, where $f$ may be a periodic function. \\\\\n    \n    \\underline{Sketching:} \\\\\n    \n    A general procedure may be outlined as follows: \\\\\n    \n    1) \\emph{Determination of the domain D} of $r=f(\\theta)$ or of $F(\\theta,r)=0$ \\\\\n    \n    If f is not periodic, vary $\\theta$ in D.If f has period T, vary $\\theta$ in $(0, T)$ and complete the curve by rotations through multiples of T about 0. \\\\\n    \n    2) \\emph{Determination of symmetries} with respect to PA, CPA and the pole. \\\\\n    \n    If a symmetry exists the domain is reduced. Conditions for symmetries with respect to polar, copolar axes and the pole are given in following table:\n    \n    \\begin{table}[ht]\n        \\begin{tabular}{c c c}\n             \\noindent\\underline{\\makebox[1.4in][l]{\\hspace{13mm}PA}} & \\noindent\\underline{\\makebox[1.4in][l]{\\hspace{13mm}CPA}}  & \\noindent\\underline{\\makebox[1.4in][l]{\\hspace{13mm}Pole}} \\\\\n             $F(-\\theta,r)=F(\\theta,r)$ & $F(-\\theta,-r)=F(\\theta,r)$ & $F(\\theta,-r)=F(\\theta,r)$ \\\\\n             or & or &  or \\\\\n             $F(\\pi-\\theta,-r)=F(\\theta,r)$ & $F(\\pi-\\theta,r)=F(\\theta,r)$ & $F(\\theta+\\pi,r)=F(\\theta,r)$ \\\\\n             \\includegraphics[width=1.4in]{images/b1p2-310-fig01.png} &\n             \\includegraphics[width=1.4in]{images/b1p2-310-fig02.png} &\n             \\includegraphics[width=1.4in]{images/b1p2-310-fig03.png}\n        \\end{tabular}\n    \\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5\n\t\\hPage{b1p2/326}\n%++++++++++++++++++++++++++++++\t\n\tconjugate diameters $\\left(e>1\\right)$. \\underline{Hint}: Recall that the asymptotes of\t\n\t$$b^2 (x - h)^2 - a^2 (y - k)^2 = a^2 b^2 \\quad \\text{are}$$\n\t$$b^2 (x - h)^2 - a^2 (y - k)^2 =0$$\n\n\t57. Plot and discuss the following curves. Find e, p and draw the conics:\n\t\\begin{align*}\n\t\t a)\\ r = \\frac{5}{2 - 2 \\cos{\\Theta}}&& b)\\ r = \\frac{3}{3 - \\cos{\\Theta}}\n\t\\end{align*}\n\t\n\t58. Same question for:\n\t\\begin{align*}\n\t\ta)\\ r = \\frac{6}{2 - 3 \\cos{\\Theta}}&& b)\\ r = \\frac{12}{3 - 4\\cos{\\Theta}}\n\t\\end{align*}\n\t\n\t59. Same question for:\n\t\\begin{align*}\n\t\ta)\\ r = \\frac{6}{1 - \\sin{\\Theta}},&& b)\\ r = \\frac{5}{3 - \\sin{\\Theta}}\n\t\\end{align*}\n\t\n\t60. Plot the conics:\n\t\\begin{align*}\n\t\t&a)\\ r = \\frac{5}{2 - 2 \\cos{\\Theta}} &&  b)\\ r = \\frac{3}{3 - \\cos{\\Theta}}\\\\\n\t\t&c)\\ r\\left(3-2\\sin{\\Theta}\\right) = 2  && d)\\ r = \\frac{5}{2-3\\sin{\\Theta}}\n\t\\end{align*}\n\t\n\t61. A chord $\\left(OP_1\\right)$ of the circle $r = 2a \\cos{\\Theta}$ is extended a distance $|P_1P| = 2a$. Find the locus of P.\n\t\n\t62. Plot the cardioids:\n\t\\begin{align*}\n\t\ta)\\ r = 2 \\cos^2{\\frac{\\Theta}{2}} && b)\\ r = 2 \\sin^2{\\frac{\\Theta}{2}}\n\t\\end{align*}\n\t\n\t63. Find the intersection of the curves: $r = \\sin{\\Theta}+1,\\quad r = \\cos{\\Theta} - 1$\n\t\n\t64. Sketch and find the points of intersection:\n\t\\begin{equation*}\n\t\tr = 3 \\sin{3 \\Theta},\\quad   r \\cos{\\left(\\Theta - \\pi / 6\\right)} - 3 = 0\n\t\\end{equation*}\n\t\n\t65. Same question for: $r = 2 \\cos{2 \\Theta},\\quad r = 2 \\cos{\\Theta}$\n\t\n%%%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2/328}\n%%%%%%%%%%%%%%%%\n 62. \\hspace{2mm} a) \n \n\\hspace{72mm} b)\n\n\n\\begin{tikzpicture}[>=latex]\n\\hspace{10mm}\n \\draw[thick,->,>=latex] (-1,0)--(2.5,0) node[above] {$PA$};\n \\draw[thick,->,>=latex][dashed] (0,-2)--(0,2) node[left] {$$};\n\\draw[domain=0:3*pi,scale=1.5,samples=500,smooth] plot (xy polar cs:angle=\\x r,radius= {(-2+2*cos(\\x r))/3});\n\\node at (0.1,-0.1) {\\scriptsize 0 };\n\\node at (2.1,-0.1) {\\scriptsize 2 };\n\n\\hspace{70mm}\n \\draw[thick,->,>=latex] (-2,0)--(1.5,0) node[above] {$PA$};\n \\draw[thick,->,>=latex][dashed] (0,-2)--(0,2) node[left] {$$};\n\\draw[domain=0:3*pi,scale=1.5,samples=500,smooth] plot (xy polar cs:angle=\\x r,radius= {(2-2*cos(\\x r))/3});\n\\node at (-0.1,-0.1) {\\scriptsize 0 };\n\\node at (-2.1,-0.1) {\\scriptsize -2 };\n\\end{tikzpicture} \n \n64. \\\\ \\\\\n\\begin{tikzpicture}\n\\hspace{26mm}\n \\draw[thick,->,>=latex] (-1,-0.05)--(2.5,-0.05) node[above] {$PA$};\n \\draw[thick,->,>=latex][dashed] (0,-2)--(0,2) node[left] {$$};\n \\draw[domain=0:3*pi,scale=1.5,samples=500,smooth] plot (xy polar cs:angle=\\x r,radius= {(0.5-0.5*cos(90+3*\\x r))});\n\\draw[thick,->,>=latex](2,-2)--(1,2) node[left] {$$};\n\\node at (2.7,1) {\\scriptsize ($\\pi$ / 6 , 3)};\n\\end{tikzpicture} \n \\\\ \n\\section{4. 4. COMPLEX NUMBERS (Polar form)}\n\\begin{definition}\nA complex number$ z = x + iy$, when denoted by the ordered pair (x, y), represents a point  in the analytic plane. Then the equality \n\\begin{equation}\nz = x + iy = (x, y) \n\\end{equation}\nestablishes  a one to one correspondance between complex numbers and points of ${\\mathbb{R}^2}$. \\\\\nThe analytic plane in which complex numbers are represented is called the \\textbf{complex plane} (ARGAND plane or $z -$ plane). The $x -$ axis contains the real numbers $x+ oi = (x,$ 0), while $y -$ axis contains only zero and only pure imaginary  numbers      \n$0 + iy = (0, y)$ and accordingly are called \\textbf{real axis} and \\textbf{imaginary axis} respectively. \\\\\n\\end{definition}\n\\begin{tikzpicture}\n\\draw[thick,->,>=latex] (-2,-1)--(4.5,-1) node[above] {$x$};\n\\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};\n\\draw[thick,>=latex](0,-1)--(2,1) node[]{$ $};\n\\draw[thick,>=latex][dashed](2,1)--(2,-1) node[]{$$};\n\\draw[thick,>=latex][dashed](2,1)--(0,1) node[]{$$}; \n\\draw[thick,>=latex][dashed](-1.8,1.6)--(-1.8,-1) node[]{$$};\n\\draw[thick,>=latex][dashed](-1.8,1.6)--(0,1.6) node[]{$$};\n\\node at (2.3,-1.3) {\\scriptsize x};\n\\node at (2.3,1.3) {\\scriptsize $z = (x, y) = (\\theta, r)$};\n\\node at (-0.2,1.1) {\\scriptsize iy};\n\\node at (0.2,1.6) {\\scriptsize 3i};\n\\node at (-2,2) {\\scriptsize $-2 + 3i$};\n\\end{tikzpicture}\n\nThe distance $\\sqrt{{x^2}+{y^2}} >$ 0 of the point $z= x + iy$ from the origin is defined to be the \\textbf{modulus} (or  the \\textbf{absolute value} of z , written \n\\begin{equation}\nmod z =  |z| = r\n\\end{equation}\nwhich becomes the absolute values of real number when $y = 0 $ . Introducing the angle $\\theta$ as in polar coordinates (see Fig.)\n%%%%%%%%%%\n\\hPage{b1p2/329}\n%%%%%%%%%%%\nwe obtain\n\n\t\t\\[\n\t\t\tx = r \\cos \\theta, y = r \\sin \\theta (r \\geq 0)\n\t\t\\]\n\nwhich when substituted in $x + iy$ gives\n\t\t\n\t\t\\[\n\t\t\tr(\\cos \\theta + i \\sin \\theta),\n\t\t\\]\n\ncalled the \\textit{polar form} of z.\n\\par The angle $\\theta$ such that $0 \\leq \\theta \\leq 2\\pi$ is called the \\textit{principal argument} of z, written Arg z. Any other argument of z is given by Arg  z + 2k$\\pi$, and\n\t\t\n\t\t\\[\n\t\t\t\\theta = \\arctan{\\frac{y}{x}}\n\t\t\\]\n\nwhich is satisfied by two principal values of argument, one of which corresponds to z.\n\n\\begin{exmp} {Transform \\\\a) z = $\\sqrt{3}$ - i, b) z = - 1 + i \\\\ into polar form.}\n\\end{exmp}\n\n\\begin{hSolution}\n\na) r = $\\mid z\\mid$ = 2, $\\theta = \\arctan{\\frac{-1}{\\sqrt{3}}}$. The solution for $\\theta$ as principal values are $\\theta_1 = 5\\pi / 6$ and $\\theta_2 = 11\\pi / 6$. Then Arg z = 11$\\pi$/6 since z lies in the fourth quadrant. Hence\n\t\t\n\t\t\\[\n\t\t\tz = 2(\\cos{\\frac{11\\pi}{6}} + i \\sin{\\frac{11\\pi}{6}}).\n\t\t\\]\n\nb) r = $\\sqrt{2}$, $\\theta = \\arctan{(-1)} \\implies \\theta_1 = 3\\pi/4, \\theta_2 = 7\\pi/4$. \\\\\nArg z = 3$\\pi$/4 since z lies in the second quadrant, and we have\n\t\t\n\t\t\\[\n\t\t \tz = \\sqrt{2}(\\cos{\\frac{3\\pi}{4}} + i\\sin{\\frac{3\\pi}{4}})\n\t\t\\] \n\n\\end{hSolution}\n\n\\begin{exmp}{Write the cartesian form of the complex number with modulus 3 and principal argument 4$\\pi$/3.}\n\\end{exmp}\n\n\\begin{hSolution}\n\nFrom r = 3 and $\\theta = 4\\pi/3$, we have\n\t\t\n\t\t\\[\n\t\t\tz = 3(\\cos{\\frac{4\\pi}{3}} + i \\sin{\\frac{4\\pi}{3}}) = - \\frac{3}{2} - i \\frac{3\\sqrt{3}}{2}\n\t\t\\]\n\n\\end{hSolution}\n\n\\hPage{b1p2/331}\n\n\\centerline{$\\frac{a}{b} = c $  or  $a=bc$}\nin view of(1), one gets\n\\[\n\\hAbs{a}=\\hAbs{b}\\hAbs{c}, arg a = arg b+ arg c\\label{2}\n\\]\nor\n\n\\[\n\\hAbs{\\frac{a}{b}} = \\frac{{}\\hAbs{a}}{\\hAbs{b}} \\qquad \\text{and} \\qquad \\text{arg } \\frac{a}{b} = \\text{arg } a - \\text{arg } b \\tag{2}\\label{myeq}\n\\] \n\n\\tad In words, \\textit{the modulus of the ratio of two complex numbers is the ratio of their moduli, and argument is the difference of their arguments.}\n\n\\textbf{\\underline{Example}.} Given the complex numbers\t\n\n\\tab\tu= 6+2i,  v= 4+2i\n\nfind the polar form of their product.\n\n\\begin{enumerate}[label=(\\alph*)]\n\t\\item by the property (1) \n\t\\item first finding the cartesian product, and then transforming to polar form.\n\\end{enumerate}\n\n\\textbf{\\underline{Solution}.}\n\na) \\hAbs{uv} = \\hAbs{u}\\hAbs{v}  \\tad   \\hAbs{uv} = $\\sqrt{40}\\sqrt{20} = 20\\sqrt{2}$,\n\n\n\\tal arg (uv) = arg u + arg v = $ arctan\\frac{1}{3} + arctan\\frac{1}{2}. $ \n\n\\tal tan(=$ arctan\\frac{1}{3} + arctan\\frac{1}{2}. $) = $ \\frac{1/3 + 1/2}{1 - 1/6}\t$ = 1\n\n\\tal $\\Rightarrow$ arg (uv) = $\\frac{\\pi}{4} +  k\\pi$\n\n\\tal $\\Rightarrow$ Arg (uv) = $\\pi/4$, since Im (uv) $>$\t 0.\n\n\\tal $\\Rightarrow$ uv = $20\\sqrt{2}(cos \\frac{\\pi}{4} + i sin \\frac{\\pi}{4})$.\n\nb) uv = 20 + 20i $\\Rightarrow  \\hAbs{uv} = 20\\sqrt{2}$,\n\n\\tal arg (uv) = arctan 1\n\n$\\Rightarrow arg (uv) = \\frac{\\pi}{4} + k\\pi = \\frac{\\pi}{4}$, since Re (uv) $>$ 0, Im (uv)$>0$.\n\n\\tab \\tad $\\Rightarrow uv = 20\\sqrt{2}(cos\\frac{\\pi}{4}+ isin\\frac{\\pi}{4})$\n\n\\textbf{\\underline{Example}.} Given the complex numbers\t\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/333}\n% ++++++++++++++++++++++++++++++++++++++\n\n\n\n\n% =======================================\n\\[\n    \\xi = \\rho(\\cos\\psi+ i\\: \\sin\\psi)\n\\]\nis an nth root of the complex number\n\\[\n    z = r (\\cos\\theta + i\\: \\sin\\theta),\n\\]\nit satisfies the equation \\:\\:  $\\xi^n = z$  \\:\\: which, by the use of\n\\\\De Moivre's formula, gives \n\\[\n    \\rho^n(\\cos\\:n\\psi+i\\:\\sin\\:n\\psi=\\:r\\:\\cos(\\theta\\:+\\:2k\\pi)\\:+\\:i\\:\\sin(\\theta\\:+\\:2k\\pi)   \n\\]\nand there\n\n\\[\n    \\rho^n\\:=\\:r,\\enspace  n\\psi\\:\\theta\\:+\\:2k\\pi\n\\]\n\\[\n    \\rho=\\sqrt[n]{r},\\enspace \\psi = \\frac{\\theta}{n} \\:+\\:k\\frac{2\\pi}{n}\\:,\\enspace k\\in  \\mathbb{Z}.\n\\]\n\\\\Hence z has n distinct roots given by\n\\[\n    z_{k} = \\sqrt[n]{r} \\Big( \\cos(\\frac{\\theta}{n} \\:+\\:k\\:\\frac{2\\pi}{n})\\:+\\:i\\:\\sin(\\frac{\\theta}{n} \\:+\\:k\\:\\frac{2\\pi}{n}) \\Big) , \\:k=1,\\:2,\\:\\dots \\: ,\\:n.\n\\]\n\n    Since $\\: \\mid z_{k} \\mid \\:=\\:\\sqrt[n]{r},\\:$ all these roots $\\:\\:z_{1},\\:z_{2},\\:\\dots\\:z_{n},\\:$ lie\n\\\\on the circle with center at the origin and radius  $\\sqrt[n]{r}$  as \\\\vertices of a regular n-gon.\n\nIn particular, the nth roots of l (unity) are \n\\[\n    \\varepsilon_{k} \\: = \\: \\cos\\:k\\:\\frac{2\\pi}{n} \\:+\\:i\\:\\sin\\: k\\:\\frac{2\\pi}{n} \\:,\\: \\:k=1,\\:2,\\:\\dots \\: ,\\:n.\n\\]\none of which, namely $\\varepsilon_{n}$,  is the\n\\\\number l (Note that  $\\varepsilon_{n}\\:=\\:\\varepsilon_{0}$).\n\nIf one of the nth roots is of z is $z_{1}$, then all the nth \n\\\\roots of z are obtained multipling $z_{1}$ by $\\varepsilon_{1}\\:,\\:\\dots\\:,\\:\\varepsilon_{n}.$\n\nThe roots of the polynomial equation $z^n\\:-\\:1\\:=\\:0$ being\n\\\\$\\varepsilon_{1}\\:,\\:\\dots\\:,\\:\\varepsilon_{n}$, the following properties are the consequences of\n\\\\the relations between the roots and coefficients:\n\n\n\\begin{align*}\n    \\sigma_{1} \n        &= \\sum \\varepsilon_{k}\n         = \\varepsilon_{1} + \\dots +\\varepsilon{n}\n         =0\\\\\n    \\sigma_{2} \n        &= \\sum_{k<l}\\varepsilon_{k}\\varepsilon_{l}\n         =\\:\\varepsilon_{1}\\varepsilon_{2}\\:+\\dots+\\varepsilon_{1}\\varepsilon_{n}\\:+\\dots+\\varepsilon_{n-1}\\varepsilon_{n}\n         =\\:0\\\\\n    \\sigma_{3} \n        &=\\:\\sum_{k<l<m}\\varepsilon_{k}\\varepsilon_{l}\\varepsilon_{m}\\:\n         =\\:0\\\\\n    &\\vdots\\\\\n    \\sigma_{n-1}\n        &=\\:0.\n\\end{align*}\n\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/334}\n% ++++++++++++++++++++++++++++++++++++++\n$$\\sigma_{n} = \\epsilon_{1} \\dotsc \\epsilon_{n} = 1 . $$\n\\begin{exmp}\nProves the nth roots of unity can be represented as powers of $\\epsilon\\left(=\\epsilon_1\\right)$ as$$\\epsilon,\\epsilon^2,\\dotsc,\\epsilon^n$$\n\\end{exmp}\n\\begin{proof}\nSince $\\epsilon_k=\\cos\\ k  \\frac{2\\pi}{n}+i\\ \\sin\\ k  \\frac{2\\pi}{n}$ and $\\epsilon=\\cos\\ \\frac{2\\pi}{n}+i\\ \\sin\\ \\frac{2\\pi}{n}$,\nfrom De Moivre's formula, we have\n$$\\epsilon_k=\\ \\left(\\cos\\ \\frac{2\\pi}{n}+i\\ \\sin\\ \\frac{2\\pi}{n}\\ \\right)^k=\\epsilon^k,\\quad k=1,\\dotsc,n.$$\n\\end{proof}\n\\section{EXERCISES (4.4)}\n\n\\begin{enumerate}\n    \\item[66.] Find $\\hAbs{z}$ and Arg z for the following complex numbers : \\\\\n    a) $-3+i$ \\qquad b) \\ $1-\\sqrt{3}i$\\qquad c) \\ $-3i$\\qquad\\ \\qquad  d)\\ $7$\n    \\item[67.]Show that $i^n=i^r$ if $n=r$ \\quad $\\left(mod 4\\right)$\n    \\item[68.]Write the polar form of: \\\\\n    a) \\ $3-3i$ \\qquad b) $2+2\\sqrt{3}i$\\qquad c)\\ $3\\sqrt{3}-3i$\\qquad d)\\ $-5$\n    \\item[69.]Find the polar form of the product of the complex numbers \\\\\n    $z_1=2+i$ and $z_2=3+i$ without finding their product.\n    \\item[70.]Find the polar form of the ratio $\\left(3-i\\right)/\\left(1-3i\\right)$ of two complex numbers without performing the division.\n    \\item[71.]Sketch the following loci of points: \\\\\n    a)$\\left\\{z: \\hAbs{z}=2,\\quad  z \\in \\epsilon \\right\\}$, \\qquad\n    b)$\\left\\{z: \\frac{\\hAbs{z-1}}{\\hAbs{z-2i}}=1,\\quad  z \\in \\epsilon \\right\\}$\n    \\item[72.]Same question for: \\\\\n    a)$\\left\\{z: \\hAbs{z}>3,\\quad  z \\in \\epsilon \\right\\}$, \\qquad\n    b)$\\left\\{z: \\frac{\\hAbs{z-1}}{\\hAbs{z-2}}=\\frac{1}{2},\\quad  z \\in \\epsilon \\right\\}$\n    \\item[73.]Sketch the following sets in Arg and plane: \\\\\n    a)$\\left\\{z: 1<\\hAbs{z}<4, z \\in \\epsilon \\right\\}$, \\qquad \n    b)$\\left\\{z: \\hAbs{z-1}+\\hAbs{z+1}=3, z \\in \\epsilon \\right\\}$\n\\end{enumerate}\n%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2/349}\n%%%%%%%%%%%%%\n \t\\quad a)$ \\int \\frac{1}{x}  . (-\\frac{1}{x^2})dx $    \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad b) $ \\int \\tan x \\sec ^2x dx $ \\\\\n\n \t\\quad c)$ \\arcsin x . (\\frac{1}{\\sqrt{1-x^2}}) dx $     \\quad \\quad \\quad \\quad \\quad \\enskip  d)$ \\int \\frac{1+x}{1-x} . \\frac{-2x}{(1-x)^2} dx $ \\\\\n\n\t11. Integrate by substitution: \\\\\n\n\t \\quad a)$ \\int 6(x^2 + 3x)^3 (2x+3)dx $  \\quad  \\quad  \\quad   b)$ \\int \\frac{\\cos \\sqrt x }{\\sqrt x} dx $ \\\\\n\n\t \\quad c)$ \\int \\frac{1}{x^2} \\sin \\frac{1}{x} dx $  \\quad  \\quad  \\quad  \\quad  \\quad  \\quad  \\quad  \\quad \\enskip  d) $ \\int (3x+1) \\cos {(3x^2 + 2x)} dx $ \\\\\n\t\n\t12. Integrate by parts  \\\\\n\n\t \\quad a)$ \\int x \\sin \\frac{x}{2}dx $   \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad b)$ \\int x \\sin x^2 dx $ \\\\\n\n\t \\quad c)$ \\int x \\cos ^2x dx $   \\quad  \\quad  \\quad  \\quad  \\quad  \\quad  \\quad  \\quad  \\enskip d) $ \\int x^2 \\cos x dx $ \\\\\n\n\t13. Verify \\\\\n\n\t{\\centering $ \\int \\sin x \\cos x dx = $   $\\begin{cases}\n\n\t\\frac{\\sin^2 x}{2}+ c \\\\\n\n\t-\\frac{\\cos 2x}{2}+c \\\\\n\n\t\\end{cases} $ \\\\}\n\n\t\\medskip\n\n\twithout integrating, and explain distinct appearance of results. \\\\\n\n\t14. Given$ F(x) = \\int G(x)dx,G(x) = \\int H(x)dx, and H(x) =\\int F(x)dx$ find a relation between one of these functions and its derivatives.  \\\\\n\n\t15. Find a condition between $ f(x), g(x), f'(x), g'(x), f''(x), g''(x)$ such that \\\\\n\n\t{\\centering  $ \\int f(x) g(x) dx = \\int f(x) dx . \\int g(x)dx $ \\\\\n\n\t\\medskip \\medskip\n\n\tANSWERS TO EVEN NUMBERED EXERCISES \\\\ }\n\n\t\\medskip\n\n\t4. \\quad a)$ (\\tan^{22} x) / 22 +c,$   \\quad  \\quad  \\quad  \\quad    b) $ -\\cos x +(\\sin^2 x)/2 +c $ \\\\ \n\n\t \\quad \\quad  c)$ \\frac{1}{2} (f'(u))^2 +c,$  \\quad  \\quad  \\quad  \\quad \\quad \\enskip    d)$ \\frac{1}{2} \\arctan^2x+c$ \\\\\n\n\t6. \\quad a)$ 3x^2 + 10x - 7,$ \\quad \\quad \\quad \\quad \\quad    b)$2x-\\tan x +1/(2\\sqrt x) $ \\quad \\quad c)$ 2/(1-x)^2$ \\\\\n\n\t\\quad \\quad d)$\\cos 2x$\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/351}\n% ++++++++++++++++++++++++++++++++++++++\n\nLet \n$$ \\Delta x_i=x_i-x_{i-1}, \\hspace{1cm} t_i \\in\n\\Big( x_i, x_{i-1}  \\Big), \\hspace{1cm} i=1,......, n\n$$\nand consider the sum \n$$ I_n= \\sum_{i=1}^{n} \\hspace{.3cm} f(t_i)\\Delta x_i $$\ncalled the \\underline{RIEMANN Sum} (\\underline{DARBOUX Sum})\\\\\n\nLet $m_i=min \\hspace{.15cm}f(x),\\hspace{.2cm} M_i= max \\hspace{.15cm}f(x)\\hspace{.2cm} on \\hspace{.2cm}\\Big( x_{i-1}, x_i \\Big)$ \n\\hspace{.2cm}so that\\newline we have \n$$ \nm_i \\leq f(x) \\leq M_i \\hspace{1cm}for\\hspace{1cm}x \\in \\Big( x_{i-1}, x_i \\Big)\n$$\n\nand \n$$\n\\sum_{i=1}^{n} \\hspace{.2cm} m_i\\Delta x_i \\hspace{.1cm}\\leq\\hspace{.1cm} I_n\\hspace{.1cm} \\leq \\hspace{.1cm} \\sum_{i=1}^{n} \\hspace{.2cm} M_i\\Delta x_i\n$$\\\\\n\nwhere we call the left hand  and right hand summations \\emph{the lover sum} and \\emph{the upper sum} respectively for the given partition P, that we denote by $L_n$ and $U_n$: \n$$\nL_n \\leq I_n \\leq U_n\n$$\\\\\nIf $L_n$ and $U_n$ have the same limit for all partitions as $n\\rightarrow\\infty$ and $m\\geq x \\hspace{.3cm}\\Delta x_i \\rightarrow 0 $, then $I_n$ tends  to this common limit, and this common limit is denoted by\\\\\n\\paragraph{\\hspace{1cm}$\\int\\limits_a^b \\hspace{.1cm} f(x)dx$ \\hspace{.5cm} (Read: integral from a to b of f(x)dx)\\newline}\n\n\\paragraph{As to existence of limit we have the following theorem whose proof is given in Advanced Calculus:}\n\n\n\\paragraph{\\underline{Theorem}. $f(x) \\in C(a,b) \\implies \\int\\limits_a^b \\hspace{.1cm} f(x)dx$ exists.}\n\n\n\\paragraph{This definite integral is the \\emph{RIEMANN integral} of $f(x)$ over the closed interval $(a, b)$, and $f(x)$ is said to be \\emph{RIEMANN integrable} function, where a and b are the \\emph{lover limit} and \\emph{upper limit} of the integral, respectively.}\n\n\\paragraph{\\underline{Example 1}. Evaluate \\hspace{.2cm}$\\int\\limits_a^b \\hspace{.1cm} dx$}\n\n\n\\hPage{b1p2/352}\n\\begin{hSolution}\n\tThe integrand is f(x)=1. For any partition, having\n    \n    $I_{n}=\\sum_{i=1}^{n}f(t_{i})(x_{i}-x_{i-1})=\\sum_{i=1}^{n}(x_{i}-x_{i-1})$\n    \n    $\\quad=(x_{1}-x_{0})+(x_{2}-x_{1})+...+(x_{n}-x_{n-1})$\n    \n    $\\quad=x_{n}-x_{0}=b-a,$\n    \n    and\n    \n    $$\\int_{a}^{b}dx=\\lim_{\\substack{n\\to\\infty\\\\max\\Delta x_{i}\\to 0}}(b-a)=b-a \\qquad (for\\quad any\\quad partition)$$\n    \n    is the area of the-rectangle with boundaries   \n    \n    \\qquad \\qquad y=f(x)=1, y=0, x=a, x=b, since f(x)=1$>$0.\n    \n    \\qquad This and some other simple properties of definite integral are listed below whose proofs can be done by the use of the definition of definite integral and some properties of limits:\n\t\\end{hSolution}\n    %I wrote Property instead of properties to be able to use hProperty environment.\n    \\begin{hProperty}\n    f(x), $g(x) \\in C(a, b) \\Longrightarrow$\n    \n    $1.\\quad \\int_{a}^{b}dx=b-a\\qquad \\qquad 2.\\quad \\int_{a}^{a}f(x)dx=0$\n    \n    $3.\\quad \\int_{a}^{b}f(x)dx=\\int_{a}^{b}f(t)dt$\n    \n    $4.\\quad m(b-a)\\leq \\int_{a}^{b}f(x)dx\\leq M(b-a), \n    \\begin{cases}\n    m=minf(x) \\\\ M=maxf(x)\n    \\end{cases}$\n    in (a, b)\n    \n    $5.\\quad \\int_{a}^{b}\\hPairingParan{f(x)+g(x)}dx=\\int_{a}^{b}f(x)dx+\\int_{a}^{b}g(x)dx$\n    \n    $6.\\quad \\int_{a}^{b}\\lambda f(x)dx=\\lambda \\int_{a}^{b}f(x)dx\\qquad (\\lambda \\quad is \\quad constant)$\n    \n    $7. \\quad\\int_{a}^{b}f(x)dx=-\\int_{b}^{a}f(x)dx$\n    \n    $8.\\quad \\int_{\\alpha}^{\\beta}f(x)dx+\\int_{\\beta}^{\\gamma}f(x)dx=\\int_{\\alpha}^{\\gamma}f(x)dx$\n    \n    $for \\quad any \\quad \\alpha,\\quad \\beta,\\quad \\gamma \\quad in\\quad (a,\\quad b).$\n    \n    $9.\\quad \\int_{a}^{b}f(x)dx\\leq \\left|\\int_{a}^{b}f(x)dx\\right|\\leq \\int_{a}^{b}\\left|f(x)\\right|dx$\n    \\end{hProperty}\n\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/353}\n% ++++++++++++++++++++++++++++++++++++++\n\n\t\\begin{hEnumerateArabic}\n\t\t\\item\n\t\t$ \n\t\t\\int_{a}^{b} \\! f(x) \\, \\hDif x\n\t\t\\leq\n\t\t\\int_{a}^{b} \\! g(x) \\, \\hDif x\n\t\t\\quad \\text{if} \\quad\n\t\tf(x) \\leq g(x)\n\t\t$\n\n\t\t\\item\n\t\t$\n\t\t\\int_{a}^{b} \\! f(x) \\, \\hDif x\n\t\t\\quad \\text{is the area bounded by the curves of} \\quad\n\t\ty = f(x), y = 0\n\t\t\\quad \\text{and} \\hNewLine\n\t\tx = a, x = b\n\t\t\\quad \\text{if} \\quad\n\t\tf(x) > 0\n\t\t\\quad \\text{on} \\quad\n\t\t(a,b)\n\t\t$\n\t\\end{hEnumerateArabic}\n\n\n\\begin{exmp}\n\\label{exmp:b1p2_353_firstExample} \n\tFind the volume of the solid with circular base of radius 5 m,\n\tand each cross section perpendicular to a definite diameter is a square.\n\t\n\t\\begin{hSolution}\n\t\tLet us take the definite diameter as\n\t\t$ x $-axis\n\t\tand the one perpendicular to it as \n\t\t$ y $-axis.\n\t\tThen the equation of the circle is\n\t\t$ x^{2} + y^{2} = 25 $.\n\t\tFrom the symmetry of the solid with respect to the cross section through y-axis\n\t\tthe volume\n\t\t$ V $\n\t\twill be twice as that for\n\t\t$ 0 \\leq x \\leq 5 $\n\t\t.\n\n\t\t\\begin{figure}[h]\n\t\t  \\begin{center}\n\t\t    \\includegraphics[scale=0.4]{images/b1p2-353-fig01.png}\n\t\t  \\end{center}\n\t\t  \\caption{Circular base and some square cross sections of the solid in Example \\ref{exmp:b1p2_353_firstExample}}\n\t\t\\end{figure}\n\n\t\tFor a regular partition of\n\t\t$ (0; 5) $\n\t\twe have congruent subintervals of lengths\n\t\t$ 5/n $.\n\t\tThe area of the cross section through the point\n\t\t$ (x_{k}, y_{k}) $\n\t\tbeing\n\t\t$ (2y_{k})^{2} $\n\t\tthe volume\n\t\t$ V_{k} $\n\t\tof the slice with thickness\n\t\t$ 5/n $\n\t\tis\n\t\t$ 4y_{k}^{2} \\cdot 5/n $:\n\n\t\t\\begin{equation}\n\t\t\tV_{k} \n\t\t\t= \\frac{20}{n} y_{k}^{2} \n\t\t\t= \\frac{20}{n} (25 - x_{k}^{2}) \n\t\t\t= \\frac{20}{n} ( 25 - \\left( k \\frac{5}{n} \\right) ^{2} ) \n\t\t\t= \\frac{500}{n} \\left( 1 - \\frac{ k^{2} }{ n^{2} } \\right)\n\t\t\\end{equation}\n\n\t\t\\begin{equation}\n\t\t\t\\begin{split}\n\t\t\t\\sum_{k=1}^{n} V_{k}\n\t\t\t& = \\frac{500}{n} \\sum_{k=1}^{n} \\left( 1 - \\frac{ k^{2} }{ n^{2} } \\right) \n\t\t\t  = \\frac{500}{n} \\left( n - \\frac{ \\sum k^{2} }{ n^{2} } \\right)\n\t\t\t  \\hNewLine\n\t\t\t& = 500 \\left( 1 - \\frac{n(n + 1)(2n + 1)}{6n^{3}} \\right)\n\t\t\t\\end{split}\n\t\t\\end{equation}\n\n\t\t\\begin{equation}\n\t\t\t\\begin{split}\n\t\t\tv\n\t\t\t& = 2 \\lim_{n \\to \\infty} \\sum_{k=1}^{n} V_{k} \n\t\t\t= 1000 \\left( 1 - lim \\frac{ n(n + 1)(2n + 1) }{ 6n^{3} } \\right)\n\t\t\t\\hNewLine\n\t\t\t& = 1000 \\left( 1 - \\frac{1}{3} \\right) = ( 2000/3 ) m^{3}.\n\t\t\t\\end{split}\n\t\t\\end{equation}\n\t\\end{hSolution}\n\\end{exmp}   \n\\hPage{b1p2/354}\n\n\\begin{enumerate}\n\t\\item[B.] THE FUNDAMENTAL THEOREMS\n\\end{enumerate}\n\nWe state two fundamental theorems (F.T.) the proofs of which are based on the following mean value theorem for integrals:\n\n\\begin{theorem}[MVT for integrals]\nIf $f(x)\\in C(a,b)$, then there exists an interior point $c\\in (a,b)$ such that $$\\int\\limits_{a}^{b} f(x)dx = (b-a)f(c)$$\n\\end{theorem}\n\n\\begin{prf}\nIf the function is constant, say $f(x)=y_0$, then $$\\int\\limits_{a}^{b} f(x)dx=\\int\\limits_{a}^{b} y_0 dx=y_0 \\int\\limits_{a}^{b} dx=(b-a)y_0 =(b-a)f(c)$$ for any $c\\in (a,b)$.\n\nLet then $f(x)$ be a non constant function. By its continuty it attains $m=min \\ f(x), \\ M=max \\ f(x)$ on $(a,b)$ so that $$\\int\\limits_a^b mdx \\leq \\int\\limits_a^b f(x)dx \\leq \\int\\limits_a^b Mdx$$ \n\n$$m(b-a) \\leq \\int\\limits_a^b f(x)dx \\leq M(b-a)$$\n\n$$m \\leq \\frac{\\int\\limits_a^b f(x)dx}{b-a} \\leq M.$$ Again from continuity of $f(x)$ the intermediate value $$\\overline{y}=\\frac{\\int\\limits_a^b f(x)dx}{b-a}$$ is attained at a point c which is certainly between a and b, so that \n\\[\n \\overline{y}=\\frac{\\int\\limits_a^b f(x)dx}{b-a}=f(c) \\tag{a}\n\\]\n\n\\par The value $\\overline{y}$ defined by (a) or by $$\\overline{y}=\\frac{\\int\\limits_a^b f(x)dx}{\\int\\limits_a^b dx}$$\n\\end{prf}\n\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/368}\n% ++++++++++++++++++++++++++++++++++++++\n\nObserve that the shaded region is not normal. If it is split up into $R_{xy}$ normal regions we get (at least) two such regions (AODB, ABEC). If it is split up into $R_{yx}$ normal regions we get (at least) three such regions (AODC, DBEC, BFE).\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.4\\columnwidth]{images/b1p2-368-fig01}\n\\end{figure}\n\nIt is reasonable to use the first splitting for this problem since the number of subregions is less than that of the other case. But in some problems such a selection may arise difficulty in integration.\n\nThen our regions AODB, and ABEC are respectively:\n\\begin{align*}\n\tR_{xy}^{1} &= \n\t\t\\{ (x, y): \n\t\t0 \\leq x \\leq 2,\n\t\t\\ -2\\sqrt{x} < y < 2\\sqrt{x} \\} \n\t\t= (0,\\ 2;\n\t\t\\ -2\\sqrt{x},\\ 2\\sqrt{x})  \\\\\n\tR_{xy}^{2} &= \n\t\t\\{ (x, y): \n\t\t2 \\leq x \\leq 3+2\\sqrt{2},\n\t\t\\ -\\sqrt{6x-x^{2}} \\leq y \\leq -x+2(1+\\sqrt{2})\\} \\\\\n\t\t& = (2,\\ 3+2\\sqrt{2};\n\t\t\\ -\\sqrt{6x-x^{2}},\\ -x+2(1+\\sqrt{2})) \\\\\n\t\\hAbs{A} & = \n\t\t\\hAbs{R_{xy}^{1}}+\\hAbs{R_{xy}^{2}} \\\\\n\t& = \\int_{0}^{2} \n\t\t(2\\sqrt{x}-(-2\\sqrt{x})) \\, \\hDif x \n\t\t+\\int_{2}^{3+2\\sqrt{2}} \n\t\t\t\\!\\!\\! -x+2(1+\\sqrt{2})-(-\\sqrt{6x-x^{2}})) \\, \\hDif x \\\\\n\t& = \\frac{16}{3} \\sqrt{2} \n\t\t+ \\frac{7}{2} \n\t\t+ \\int_{2}^{3+2\\sqrt{2}} \n\t\t\t\\sqrt{6x-x^{2}} \\, \\hDif x\n\\end{align*}\nWriting $6x-x^{2}=9-(x-3)^{2}$ and setting $x-3=3\\sin t$ we have\n\\begin{align*}\n\t\\int \\sqrt{6x-x^{2}} \\, \\hDif x \n\t&= \\int \n\t\t\\sqrt{9-9 \\sin^{2} t} \\cdot 3 \\cos t \\, \\hDif t \\\\\n\t& = 9 \\int \n\t\t\\cos^{2} t \\, \\hDif t \n\t= \\frac{9}{2} (t+ \\frac{\\sin 2t}{2}) + c \\\\\n\t\\alpha = \n\t\t\\int_{2}^{3+2\\sqrt{2}} \n\t\t\t\\sqrt{6x-x^{2}} \\, \\hDif x\n\t&= \\frac{9}{2} \\arcsin \\frac{2 \\sqrt{2}}{3} \n\t\t+ \\arcsin \\frac{1}{3} + \\frac{4 \\sqrt{2}}{9}\\\\\n\tA = \\frac{16}{3} \\sqrt{2} + \\frac{7}{2} + \\alpha .\n\\end{align*}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/371}\n% ++++++++++++++++++++++++++++++++++++++\n\\begin{thm}\n\t\\footnote{proof of theorem continues from the previous page, 'THEOREM' and 'PROOF' words are not undesirable in my page.}\n\t\\begin{proof}\n\t\twill be $-h,\\:h$ so that\n\t\t\\begin{align*}\n\t\t\tA &= \\int_{-h}^{h} \\! (\\alpha x^{2} + \\beta x + \\gamma)\\, \\hDif x = (\\frac{\\alpha}{3}x^{3} + \\frac{\\beta}{2}x^{2} + \\gamma x)_{-h}^{h} \\\\\n\t\t\t&= \\frac{2}{3} \\alpha h^{3} + 2 \\gamma h = \\frac{h}{3} (2 \\alpha h^{2} + 6\\gamma)\n\t\t\\end{align*}\n\t\tSince,\n\t\t\\begin{align*}\n\t\t\ty_{0} &= \\alpha h^{2} - \\beta h + \\gamma \\\\\n\t\t\t4y_{1} &= \\qquad\\qquad\\quad 4\\gamma \\\\\n\t\t\ty_{2} &= \\alpha h^{2} + \\beta h + \\gamma \\\\\n\t\t\t\\cline{1-2}\n\t\t\ty_{0}+4y_{1}+y_{2} &= 2\\alpha h^{2} \\qquad +6\\gamma\n\t\t\\end{align*}\n\t\twe have our result.\n\t\t\\par Now partitioning $\\hPairingParan{a,b}$ regularly for an even number $n$ and applying the above lemma for consecutive pairs of strips and adding the results of each pair, we have\n\t\t\\begin{align*}\n\t\t\t\\frac{h}{3} ((y_{0}+4y_{1}+y_{2})+(y_{2}+4y_{3}+y_{4})+\\cdots +(y_{n-2}+4y_{n-1}+y_{n}))\n\t\t\\end{align*}\n\t\tand\n\t\t\\begin{align*}\n\t\t\t\\int_{a}^{b} \\! f(x)\\, \\hDif x = \\frac{h}{3}(y_{0}+4y_{1}+2y_{2}+4y_{3}+\\cdots +2y_{n-2}+4y_{n-1}+y_{n})\n\t\t\\end{align*}\n\t\twhere $h=(b-a)/n$ and $n$ is an even number.\n\t\t\\par Observe that coefficients of $y_{1}$ are $1$ for $i=0$ and $i=n$; for others, $4$ for odd $i$ and $2$ for even $i$.\n\t\\end{proof}\n\\end{thm}\n\n\\begin{exmp}\n\tEvaluate the definite integral\n\t\\begin{align*}\n\t\tA = \\int_{1}^{3}\\frac{\\hDif x}{x}\n\t\\end{align*}\n\tapproximately (numerically) using the three rules, taking $n=6$.\n\t\\begin{hSolution}\n\t\t\\footnote{solution of the example continues to the next page. In order not to get errors while compiling, I closed my tags here.}\n\t\tWe have $h=\\frac{3-1}{6}=\\frac{1}{3}$ and\n\t\t\\begin{align*}\n\t\t\t\\begin{tabular}{c|cccccccc|}\n\t\t\t\t$x_{i}$ & $1$ & $\\frac{4}{3}$ & $\\frac{5}{3}$ & $2$ & $\\frac{7}{3}$ & $\\frac{8}{3}$ & $3$ \\\\\n\t\t\t\t\\hline\n\t\t\t\t$y_{i}$ & $1$ & $\\frac{3}{4}$ & $\\frac{3}{5}$ & $\\frac{1}{2}$ & $\\frac{3}{7}$ & $\\frac{3}{8}$ & $\\frac{1}{3}$\n\t\t\t\\end{tabular}\n\t\t\\end{align*}\n\t\\end{hSolution}\n\\end{exmp}\n\n\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/402}\n% ++++++++++++++++++++++++++++++++++++++\n\n\n% =====================================\n\n\\begin{exmp} \\footnote{The example's solution starts in the previous page. \n\t\t\t        Begin tags should be removed.}\n\n\t\\begin{hSolution}\n\t\t\\begin{hEnumerateAlpha} \n\t\t\t\\item \\footnote{This is the b part, a part is in the previous page. \n\t\t\t\t\t     Begin tag should be removed.}\n   \t\t\t\\begin{align*}\n\t\t\t\t\ty = \n\t\t\t\t\t\t(1 + \\frac{1}{x})^x \n\t\t\t\t\t\t\\Rightarrow \n\t\t\t\t\t\t\\ln y =\\:x\\ln&(1 + \\frac{1}{x})\\\\\n\t  \t\t\\ln (\\lim_{x\\to\\infty} y) = \n\t\t\t\t\t\t\t         &\\lim_{x\\to\\infty} \n\t\t\t\t\t\t\t\t\t\t\t\\left( x\\ln(1 +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\frac\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{1}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{x}\n\t\t\t\t\t\t\t\t\t      \t\t\t      )\\right) = \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\\infty,0)\\\\\n\t\t\t\t   \t       \t                = &\\lim_{x\\to\\infty} \n\t\t\t\t\t\t\t\t\t\t\\frac\n\t\t\t\t\t\t\t\t\t\t\t{\\ln(1+\\frac{1}{x})}\n\t\t\t\t\t\t\t\t\t\t\t{1/x} \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t= \\lim_{x\\to\\infty}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\frac\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\\frac\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{-1/x^2}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{1 + 1/x}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{-1/x^2} \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t= 1 = \\ln e\\\\\n\t\t   \t \t\t           \\Rightarrow &\\lim_{x\\to\\infty} y = e\n\t\t\t\\end{align*}\n\t\t\\end{hEnumerateAlpha}\n\t\\end{hSolution}\n\n\\end{exmp}\n\n% =====================================\n\n\\begin{exmp}\n\n\tEvaluate $\\lim_{x\\to 0} (\\cos 2x)^{1/x^2}$\n\n\t\\begin{hSolution}\n\t\t\\begin{alignat*}{2}\n\t\t\ty = (\\cos 2x)^{1/x^2} \n\t\t\t\t&\\Rightarrow \\ln y &&= \\frac{1}{x^2}\n\t\t\t\t\t\t\t\t\t\t\\ln \\cos 2x\\\\\n\t \\ln(\\lim_{x\\to 0} y) &= \\lim_{x\\to 0}    &&\\frac\n\t\t\t\t\t\t\t\t{\\ln \\cos 2x}\n\t\t\t\t\t\t\t\t{x^2} \n\t\t\t\t\t\t\t\t\t\t= \\left( \\frac{0}{0} \\right) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t= \\lim_{x\\to 0} \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\frac\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\\frac\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{-2 \\sin 2x}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\\cos 2x}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{2x} \\\\\n\t\t\t\t&= -2                     &&\\lim_{x\\to 0} \n\t\t\t\t\t\t\t\t\t(\\frac\n\t\t\t\t\t\t\t\t\t\t{\\sin 2x}\n\t\t\t\t\t\t\t\t\t\t{2x} \n\t\t\t\t\t\t\t\t\t \\frac\n\t\t\t\t\t\t\t\t\t\t{1}\n\t\t\t\t\t\t\t\t\t\t{\\cos 2x}\n\t\t\t\t\t\t\t\t\t) = -2 = \\ln e^{-2}\\\\\n\t\t\t\t&\\Rightarrow         &&\\lim_{x\\to 0} y = e^{-2}\n\t\t\\end{alignat*}\n\t\\end{hSolution}\n\n\\end{exmp}\n\n% =====================================\n\n\\textbf{Sketching.} The procedure for sketching the curve of \n$y = u(x)^{v(x)}$ is the same as that given for the case $u(x)$ is a constant function. \nOne determines first the domain, and makes a table of variation for $u(x)$ and $v(x)$ \nand get the values or limits of $y$ corresponding to the specific values obtained for x in the table.\\\\\n\n% =====================================\n\n\\begin{exmp}\n\n\tSketch the curves of\n\n\t\\begin{multicols}{2}\n\t\ta) $y = f(x) = x^x$\n\t\n\t\tb) $f(x) = (1+x)^{1/x}$\n\t\\end{multicols}\n\n\t\\begin{hSolution}\n\n\t\ta) $\\textrm{D}_f = (0,\\infty)$\n\t\n\n\t\t$y^\\prime = x^x(1+\\ln x) = 0 \\Rightarrow x = 1/e$\n\n\t\\end{hSolution}\n\n\\end{exmp}\n%++++++++++++++++\n \\hPage{b1p2/417}\n%++++++++++++++++++++\n    \\begin{center}\n        \\includegraphics{images/b1p2-417-fig01.png}\n    \\end{center}\n    \n    We are going to show that $\\Theta$ as arc $(angle)$ on the unit\n    circle represents the area of the shaded segment of circle bounded by the line segment $(OP),$ $(OP^\\prime)$ and the arc $P^\\prime AP$, and $\\Theta$ as argument in hyperbolic functions represents the area of the shaded region bounded by $(OP),$ $(OP^\\prime)$ and the arc of hyperbola $P^\\prime AP$.\n    \n    \\begin{hEnumerateAlpha}\n        \\item $|OP^\\prime AP \\vert = \\frac{2\\Theta}{2\\Pi} $ $ \\Pi r^2 $ $(r = 1) = \\Theta$\n        \\item $|OP^\\prime AP \\vert = 2 |POH \\vert -2|PAH \\vert = \\operatorname{Ch}\\Theta \\operatorname{Sh}\\Theta - 2 \\int_A^P y \\,dx$\n    \\end{hEnumerateAlpha}\n    \n    $ $\\\\\n    \\noindent\n    where, having \n    \n    \\begin{align*}\n        2 \\int_A^P y \\,dx &= 2 \\int_0^\\Theta \\operatorname{Sh}t \\,d\\operatorname{Ch}t = 2 \\int_0^\\Theta \\operatorname{Sh}t^2 \\,dt\n        \\\\\n        &= 2 \\int_0^\\Theta (\\operatorname{Ch}2t - 1) \\,dt = \\frac{1}{2} \\operatorname{Sh}2\\Theta - \\Theta ,\n    \\end{align*}\n    \n    \\noindent\n    we get \n    \n    \\[\n        |OP^\\prime AP \\vert = \\operatorname{Ch}\\Theta \\operatorname{Sh}\\Theta - \\frac{1}{2} \\operatorname{Sh}2\\Theta + \\Theta = \\Theta\n    \\]\n    \n    \\section{INVERSE HYPERBOLIC FUNCTIONS.}\n    \n    Observing from the graphs of hyperbolic functions the all these, except $\\operatorname{Ch}x$ and $\\operatorname{Sech} x$ are monotone increasing or monotone decreasing on their domain, while\\footnote{Since $\\operatorname{Ch} x$ ($\\operatorname{Sech} x$) is monotone decreasing (increasing) ($-\\infty , 0$) also inverse in that interval and the graphs is symmetric of the given one w.r. to x-axis.} $\\operatorname{Ch}x$ $\\operatorname{Sech} x$\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2/423} \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\footnote{Package used: mdframed for the box without bottom part}\n\\footnote{Package used: mathbx to get $\\rightbarharpoon$ (instead we can use $\\Rightarrow$ )}\n\\footnote{Package used: graphbox to align the images}\n\\footnote{Set the mdframe option:newmdenv[bottomline=false]\\{notbottom\\}}\n\n\\begin{hEnumerateArabic}\n    \\item[]\n        \\begin{hEnumerateAlpha}\n            \\item \\( { ( Ch x + Sh x )}^{- Argch x} = { ( ch x - Sh x )}^{- Argsh (x-2)}  \\)\n            \\item \\( Ch 7x + Ch 5x + Ch 3x = Ch 6x + Ch 4x + Ch 2x \\)\n        \\end{hEnumerateAlpha}\n\\end{hEnumerateArabic}\n\\section*{ANSWERS TO EVEN NUMBERED EXERCISES}\n\\begin{hEnumerateArabic}\n    \\setcounter{enumi}{5}\n    \\item 24/7, 25/7, 24/25 , 7/25, 7/24, 25/24.\n    \\setcounter{enumi}{47}\n    \\item \n        \\begin{hEnumerateAlpha}\n            \\item R, $(2x + 2) Ch(x^2 + 2)$,\n            \\item R, $-(2x - 2) Sech(x^2 - 2x) Th(x^2 - 2x)$\n        \\end{hEnumerateAlpha}\n    \\setcounter{enumi}{51}\n    \\item \n        \\begin{hEnumerateAlpha}\n            \\begin{multicols}{2}\n                \\item $-\\csc x$,\n                \\columnbreak\n                \\item $\\csc x$\n            \\end{multicols}\n        \\end{hEnumerateAlpha}\n    \\setcounter{enumi}{53}\n    \\item\n        \\begin{hEnumerateAlpha}\n            \\begin{multicols}{2}\n                \\item \\includegraphics[align=t,scale=0.75]{images/b1p2-423-fig01.png}\n                \\columnbreak\n                \\item \\includegraphics[align=t,scale=0.75]{images/b1p2-423-fig02.png}\n            \\end{multicols}\n        \\end{hEnumerateAlpha}\n    \\setcounter{enumi}{57}\n    \\item\n        \\begin{hEnumerateAlpha}\n            \\begin{multicols}{2}\n                \\item \\( \\ln \\sqrt{3}\\)  \n                \\columnbreak\n                \\item 0\n            \\end{multicols}\n        \\end{hEnumerateAlpha}\n    \\setcounter{enumi}{59}\n    \\item\n        \\begin{hEnumerateAlpha}\n            \\begin{multicols}{2}\n                \\item 5/4  \n                \\columnbreak\n                \\item 0\n            \\end{multicols}\n        \\end{hEnumerateAlpha}\n\\end{hEnumerateArabic}\n\\section*{A SUMMARY}\n\\begin{notbottom}\n    \\begin{hEnumerateArabic}\n        \\item[6.1]\n            \\begin{hEnumerateAlpha}{}\n                \\item[] \\(\\ln x = \\int_{1}^{x} \\frac{dt}{t} (x > 0), \\ln 1 = 0, \\ln e = 1 \\)\n                \\item[] \\(\\ln ab = \\ln a + \\ln b, \\ln \\frac{a}{b} = \\ln a - \\ln b\\)\n                \\item[] \\(\\log_b x = \\log_a x \\cdot \\log_b a\\) (change of base)\n                \\item[] \\(\\frac{d}{dx} a^{u(x)} = a^u \\frac{du}{dx} \\ln u, \\frac{d}{dx} \\log_a u(x) = \\frac{1}{u} \\frac{du}{dx} \\log e  \\)\n                \\item[] \\(\\frac{d}{dx} u(x)^{v(x)} = u^v \\big(\\frac{dv}{dx} \\ln u +  \\frac{v}{u} \\frac{du}{dx} \\big)  \\)\n                \\item[] \\( y = uv \\ldots w \\rightbarharpoon \\frac{y^\\prime}{y} = \\frac{u^\\prime}{u} + \\frac{v^\\prime}{v} + \\ldots + \\frac{w^\\prime}{w} \\text{(logarithmic derivative)} \\)\n            \\end{hEnumerateAlpha}\n    \\end{hEnumerateArabic}\n\\end{notbottom}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/435}\n% ++++++++++++++++++++++++++++++++++++++\n\\[\n\t+(\\frac{C_1x + D_1}{x^2+px+q} + ... + \\frac{C_{\\lambda}x + D_\\lambda}{(x^2+px+q)^\\lambda})+(\\frac{E_1x+F_1}{x^2+rx+s}+...+\\frac{E_\\mu x+ F_\\mu}{(x^2+rx+s)^\\mu})+...\n\\]\nof finite number of partial fractions with $A_\\alpha \\neq 0,  B_\\beta \\neq 0, ... ,C_\\lambda x + D_\\lambda \\neq 0,\\hspace{3mm}  E_\\mu x + F_\\mu \\neq 0.$\n\n\\begin{proof}\n\tSee Appendix at the end of the book.\n\\end{proof}\n\nBy this theorem, in the decomposition, to a real root of multiplicity $\\nu$ correspond $\\nu$ partial fractions (some of which may be zero), and to a pair of conjugate imaginary roots of common multiplicity $\\nu$ correspond $\\nu$ partial fractions (some of which may be zero).\n\nFor instance\n\\begin{enumerate}\n\n\t\\item[1.]\n \t$\\frac{x^6-2x+5}{(x-1)x^3(x^2+1)^2} = \\frac{A}{x-1} + (\\frac{B_1}{x}+\\frac{B_2}{x^2}+\\frac{B_3}{x^3})+(\\frac{C_1x+D_1}{x^2+1}+\\frac{C_2x+D_2}{(x^2+1)^2})$\n\n\t\\item[2.] \n\t$\\frac{3}{(x-1)^2}= \\frac{A}{(x-1)^2} \\quad (\\Rightarrow A=3, why?)$\n\t\n\t\\item [3.] \n\t$\\frac{2x^2-7}{(x^2-x+1)^3}=\\frac{A_1x+B_1}{x^2-x+1}+\\frac{A_2x+B_2}{(x^2-x+1)^2}+\\frac{A_3x+B_3}{(x^2-x+1)^3}$\n\n\\end{enumerate}\n\nWe remark that as in (2) above, the decomposition of a partial fraction consists of a single term which is the given fraction.\n\n\\begin{exmp}\n\tDecompose the proper rational function\n\t\\[\n\t\t\\frac{x^2+15}{(x-3)(x^2-2x-3)}\n\t\\]\n\tinto partial fractions.\n\\end{exmp}\n\n\\textbf{Solution}. Since $x^2-2x-3$ has positive discriminant, it can be factored:  $x^2-2x-3 = (x-3)(x+1)$.\n\nThus the given fraction is to be written as\n\n%%%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2/438}\n reducible to integrals of the form\n    \n    $$A = \\int_{}^{} {{1}\\over{{(x-a)}^n}} dx, B = \\int_{}^{} {{ax+b}\\over{({x^2+px+q})^n}} dx$$\n    \n    of which the (A) is easily integrable by the substitu-\\\\\n    tion $u=x-a$, $du=dx$\\\\.\n    \\paragraph{} The second one (B) is reducible to (A) if \\\\\n    $$ax+b=D(x^2+px+q)=2x+p;$$\n    otherwise, writing $ax+b$ as\n    $$ax+b={{a}\\over{2}}(2x+p) + (b- {{ap}\\over{2}})$$\n    we have\n    $$B={{a}\\over{2}}\\int_{}^{} {{2x+p}\\over{(x^2+px+q)^n}}dx+(b-{{ap}\\over{2}})\\int_{}^{}{1\\over{(x^2+px+q)^n}}dx$$\n    $$={{{a}\\over{2}}\\int_{}^{}{{du}\\over{u^n}}+c\\int_{}^{}{1\\over{(x^2+px+q)^n}}dx}$$\n    \n    where $u=x^2+px+q$ in the first integral. In the second integ-\\\\\n    ral, writing\n    $$x^2+px+q=(x+{{p}\\over{2}})^2+(x-{{p}\\over{2}})^2.$$\n    $$={{(x+{{p}\\over{2}})^2}+{({{\\sqrt{-(p^2-4q)}}\\over{2}})^2}}, (\\Delta=p^2-4q<0)$$\n    \n    and setting\n    \n    $$x+{{p}\\over{2}}={{{\\sqrt{-\\Delta}}\\over{2}}u}, dx={{{\\sqrt{-\\Delta}}\\over{2}}du}$$\n    \n    we have\n    \n    $$x^2+px+q={({{{\\sqrt{-\\Delta}}\\over{2}}u})^2+({{{\\sqrt{-\\Delta}}\\over{2}}})^2}={{{-\\Delta}\\over{4}}(u^2+1)}$$\n    \n    and the integral reduces to\n    \n    $$k\\int_{}{}{{1}\\over{(u^2+1)^n}}du$$\n    \n    which, omitting k and replacing u by x, becomes\n    \n    $$ {I_{n}} = {\\int_{}{}{{dx}\\over{(x^2+1)^n}}}$$\n    \n%%%%%%%%%%%%%%%%%%%%%%%%%%%55 \n\\hPage{b1p2/444}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{hEnumerateAlpha}\n\\setcounter{enumi}{4}\n\\item $\\begin{aligned}\\frac{Ax+B}{x^{2}+x+1} + \\frac{Cx+D}{x^{2}-x+1}\\end{aligned}$\n\\item $\\begin{aligned}\\sum_{i=1}^4 \\frac{A_{i}}{(x-1)^{i}} + \\sum_{i=1}^4 \\frac{B_{i}}{(x+1)^{i}} + \\sum_{i=1}^3 \\frac{C_{i}}{(x-\\sqrt{2})^{i}} + \\sum_{i=1}^3 \\frac{D_{i}}{(x+\\sqrt{2})^{i}}\\end{aligned}$\n\\item $\\begin{aligned}\\frac{A}{x} + \\frac{B}{x^{2}} + \\frac{C}{x^{3}} + \\frac{D}{x+1} + \\frac{E}{(x+1)^{2}} + \\frac{F}{x-2}\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\begin{hEnumerateArabic}\n\n\\setcounter{enumi}{3}\n\\item $\\begin{aligned} I_{n} = \\frac{x^{n-1}}{n-1} - I_{n-2}\\end{aligned}$\n\n\\stepcounter{enumi}\n\\item $\\begin{aligned}-\\frac{2}{x} + \\frac{1}{x^{2}} + \\frac{1}{x^{3}} + \\frac{2x-1}{x^{2}+1} + \\frac{x-1}{(x^{2}+1)^{2}} + C\\end{aligned}$\n\n\\stepcounter{enumi}\n\\item\n\\begin{hEnumerateAlpha}\n\\item $\\begin{aligned}\\frac{1}{3}\\ln\\frac{(x+1)^{2}(x-2)}{(x-1)(x+2)^{2}} + C\\end{aligned}$\n\\item $\\begin{aligned}\\frac{1}{6}\\ln\\frac{x-1}{x+1} + \\frac{\\sqrt{2}}{3}\\arctan\\frac{x}{\\sqrt{2}} + C\\end{aligned}$\n\\item $\\begin{aligned}\\frac{3}{4}\\ln\\frac{x^{2}+1}{(x-1)^{2}} - \\arctan{x} - \\frac{3x-4}{2(x-1)^2} + C\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\stepcounter{enumi}\n\\item $\\begin{aligned}-\\frac{3x^{3}+2x^{2}+2x+1}{2x^{2}(x^{2}+1)} + \\ln\\frac{x^{2}+1}{x^{2}} - \\frac{3}{2}\\arctan{x} + C\\end{aligned}$\n\n\\stepcounter{enumi}\n\\item\n\\begin{hEnumerateAlpha}\n\\item $\\begin{aligned}\\ln\\frac{x}{x-1} - \\frac{1}{6}\\ln{(x^{2}+1)} - \\frac{1}{3}\\arctan{x} - \\frac{x+1}{x^{2}+1} + C\\end{aligned}$\n\\item $\\begin{aligned}\\frac{1}{\\sqrt{11}}\\arctan\\frac{4x+1}{\\sqrt{11}} + C\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\stepcounter{enumi}\n\\item\n\\begin{hEnumerateAlpha}\n\\item $\\begin{aligned}\\ln{(x-2)^{2}}|x+2|^{3} + 6\\end{aligned}$\n\\item $\\begin{aligned}\\frac{5}{9}\\ln{|x-1|} + \\frac{4}{9}\\ln{|x+2|} - \\frac{1}{3(x-1)} + C\\end{aligned}$\n\\item $\\begin{aligned}\\ln{(x-1)^{4}} + \\frac{1}{3}\\ln{|x+1|} + \\frac{5}{3}(x-2) + C\\end{aligned}$\n\\item $\\begin{aligned}\\ln{|x|} - \\frac{3}{x+1} + C\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\stepcounter{enumi}\n\\item\n\\begin{hEnumerateAlpha}\n\\item $\\begin{aligned}\\frac{1}{2}\\ln|2x+1| - 3\\arctan{x} + C\\end{aligned}$\n\\item $\\begin{aligned}\\frac{1}{12}\\ln{\\left|\\frac{2x-3}{2x+3}\\right|} + C\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\stepcounter{enumi}\n\\item\n\\begin{hEnumerateAlpha}\n\\item $\\begin{aligned}\\ln\\frac{9}{8}\\end{aligned}$\n\\item $\\begin{aligned}\\frac{3}{28} + \\ln{16}\\end{aligned}$\n\\end{hEnumerateAlpha}\n\n\\stepcounter{enumi}\n\\item $\\begin{aligned}\\ln\\frac{9}{2}\\end{aligned}$\n\n\\end{hEnumerateArabic}\n%%%%%%%%%%%%%%+++++++\n\\hPage{b1p2/447}\n%+++++++++++++++++++++++\n\\begin{exmp}\n\n\nEvaluate B = $\\int \\! \\frac{1}{2Sh\\theta - 3Ch\\theta +1} \\, \\hDif \\theta $\\\\\n\\begin{hSolution}\nTh$\\frac{\\theta}{2}=t\\quad\\Longrightarrow\n\\quad\\theta =2Argtht\\quad\\Longrightarrow\n\\quad\\hDif \\theta =\\frac{2\\hDif t}{1-t^{2}}$ , and\\\\\n\\begin{align*}\nSh\\theta=\\frac{2t}{1-t^{2}}\\quad , \\quad Ch\\theta=\\frac{1+t^{2}}{1-t^{2}}\\\\\n\\end{align*}\n\\begin{align*}\nB\n&=\\int \\! \\frac{1}{\\frac{-4t}{1-t^{2}}-3\\frac{1+t^{2}}{1-t^{2}}+1}\\frac{2\\hDif t}{1-t^{2}}=-2 \\int \\! \\frac{\\hDif t}{4t^{2}-4t+2}\\\\\n&=\\int \\! \\frac{\\hDif (2t)}{(2t)^{2}-2(2t)+2}=-\\int \\! \\frac{\\hDif u}{u^{2}-2u+2} \\qquad (u=2t)\\\\\n&=-\\int \\! \\frac{\\hDif (u-1)}{(u-1)^{2}+1}=-arctan(u-1)+C\\\\\n&=-arctan(2t-1)+C=-arctan(2Th\\frac{\\theta}{2}-1)+C.\\\\\n\\end{align*}\n\\end{hSolution}\n\\end{exmp}\n\\par The half-angle (half-argument) substitutions works always for the rational integrands in trigonometric (or hyperbolic) functions.\\\\\n\\par In some cases as the following ones the use of these substitutions not necessary:\\\\\n\\par \\underline{Integrals reducible to $\\int \\! \\hDif  u /u$}:\\\\\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item\n$\n\\!\n\\begin{aligned}[t]\n a)&\\int \\! tan\\theta \\hDif \\theta\\\\\n&\\int \\! tan\\theta \\hDif \\theta =\\int \\! \\frac{sin\\theta}{cos\\theta}\\hDif \\theta\\\\\n=& \\int \\! \\frac{-\\hDif cos\\theta}{cos\\theta}=-ln\\hAbs{cos\\theta}+c\\\\\n\\end{aligned}\n$ \n\\begin{align*}\nb)&\\int \\! cot\\theta \\hDif \\theta = \\int \\! \\frac{\\hDif sin\\theta}{sin\\theta}\\\\\n=&ln\\hAbs{sin\\theta}+c\\\\\n\\end{align*}\n\\begin{align*}\na')&\\int \\! Th\\theta \\hDif \\theta\\\\\n&\\int \\! Th\\theta \\hDif \\theta = \\int \\! \\frac{Sh\\theta}{Ch\\theta} \\hDif \\theta\\\\\n=&\\int \\! \\frac{\\hDif ch\\theta}{ch\\theta}=ln\\quad ch\\theta+c.\\\\\n\\end{align*}\n\\begin{align*}\nb')&\\int \\! Coth\\theta \\hDif \\theta = \\int \\! \\frac{\\hDif Sh\\theta}{Sh\\theta}\\\\\n=&ln\\hAbs{Sh\\theta}+c.\\\\\n\\end{align*}\n\\end{enumerate}\n\\end{multicols}\n%+++++++++++++++++++++++++++++\n\\hPage{b1p2/460\\footnote{Following functions were declared as math operators above to keep function style and syntax: $\\Sh{x}$, $\\Ch{x}$, $\\Sech{x}$, $\\Th{x}$}}\n%+++++++++++++++++++++++++++\nWe transform A${x}^2$ + Bx + C as follows:\n\\begin{align*}\n    A{x}^2 + Bx + C &= A\\left({x}^2 + \\frac{B}{A}x + \\frac{C}{A}\\right) \\\\\n    &= A\\left({(x + \\frac{B}{2A})}^2 - \\frac{{B}^2}{4{A}^2} + \\frac{C}{A}\\right) \\\\\n    &= A\\left({(x + \\frac{B}{2A})}^2 - \\frac{{B}^2 - 4AC}{4{A}^2}\\right)\n\\end{align*}\n\\\\\nSetting\n\\begin{align*}\n    x + \\frac{B}{2A} &= u\n\\end{align*}\n\nwe have\n\\begin{align*}\n    A{x}^2 + BX + C &=\n    A\\left({u}^2 - \\frac{\\Delta}{4{A}^2}\\right) \\cdot (\\Delta = {B}^2 - 4AC)\n\\end{align*}\n\n\\par If A $>$ 0, then\n\\begin{align*}\n    A{x^2} + Bx + C \\text{ involves }\n    \\left(\n    \\begin{array}{lll}\n         {u}^2 - {a}^2 & when & \\Delta > 0 \\\\\n         {u}^2 + {a}^2 & when & \\Delta < 0\n    \\end{array}\n    \\right.,\n\\end{align*}\nand if A $<$ 0, it involves ${a}^2 - {u}^2$.\n\n\\begin{table}[h]\n    \\centering\n    \\caption{}\n    \\begin{tabular}{cccc}\n            Integrand involved &\n            Substitution &\n            New integrand involves &\n            ${du}$\n            \\\\ \\hline%------------\n            ${u}^2 + {a}^2$\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    u = a \\tan{t}\\\\\n                       or\\\\\n                    u = a \\Sh{t}\n                \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left( \n            \\begin{array}{c}\n                     {a}^2 \\sec^2{t}\\\\\n                        or\\\\\n                     {a}^2 \\Ch^2{t}\n                \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {a} \\sec^2{t} {dt} \\\\\n                        or \\\\\n                    {a} \\Ch{t} {dt}\n                \\end{array}\n            \\right.\n            $\n            \\\\[8mm]%------------\n            ${u}^2 - {a}^2$\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    u = a \\sec{t} \\\\\n                        or\\\\\n                    u = a \\Ch{t}\n                \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {a}^2 \\tan^2{t} \\\\\n                        or \\\\\n                    {a}^2 \\Sh^2{t}\n                 \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {a} \\sec{t} \\tan{t} {dt} \\\\\n                        or \\\\\n                    {a} \\Sh{t} {dt}\n                \\end{array}\n            \\right.\n            $\n            \\\\[8mm]%-=-=-=-=-=-=-=-=-=\n            ${a}^2 - {u}^2$\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {u} = {a} \\sin{t}\\text{\\footnotemark} \\\\\n                        or \\\\\n                    {u} = {a} \\Th{t}\n                \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {a}^2 \\cos^2{t} \\\\\n                        or \\\\\n                    {a}^2 \\Sech^2{t}\n                \\end{array}\n            \\right.\n            $\n            &\n            $\n            \\left(\n                \\begin{array}{c}\n                    {a} \\cos{t} {dt} \\\\\n                        or \\\\\n                    {a} \\Sech^2{t} {dt}\n                \\end{array}\n            \\right.\n            $\n    \\end{tabular}\n\\end{table}\n\\footnotetext{The substitution ${u}={a}$ cost works also, but ${u}={a} \\sin{t}$ is preferred}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/469}\n% ++++++++++++++++++++++++++++++++++++++\n\t\n\ta) $\\int x \\sqrt{\\frac{1+x}{1-x}}dx$ \\quad\n    \tb) $\\int^2_0 {\\frac{\\sqrt{x+1}-1}{\\sqrt{x+1}+1}}dx$\t\n\t\n\t\\begin{enumerate}\n\t\t\n\n    \t\\item[81.]\n    \tEvaluate $\\int^b_a \\frac{dx} {\\sqrt{(x-a)(b-x)}}$\n\n    \t\\item[82.]\n    \tIf R(x, $\\sqrt{ax^2 + bx + c}$ is a rational function of its arguments, show that it becomes a rational function of t upon the substitution: \\\\\n    \ta) $ t = \\sqrt{a}x+\\sqrt{ax^2 + bx + c}$ when $a > 0,$\\\\\n    \tb) $ t = \\sqrt{(-a).\\frac{x - x_1}{x_2 - x}}$ when $a < 0$, where $x_1, x_2$ are the (real) roots of $ax^2+bx+c=0 (x_1 < x_2)$\n\n    \t\\item[83.]\n    \tApply the substitution given in Exercise 82 to transform\\\\\n   \ta)$\\int\\frac{3-\\sqrt{4x^2+x-1}}{x+\\sqrt{4x^2+x-1}}dx$\n    \tb)$\\int\\frac{\\sqrt{x - x^2}}{1 + \\sqrt{x - x^2}}dx$ \\\\\n    \tinto ones with integrand as rational function of t.\n\n    \t\\item[84.]\n    \tEvaluate $\\int \\frac{1-\\sqrt[3]{x}}{\\sqrt{x}}dx$\n\n    \t\\item[85.]\n    \tShow that $\\int^\\pi_0 \\frac{x \\sin x}{1+\\cos ^2x}dx = \\frac{\\pi^2}{4}$\n\n    \t\\item[86.]\n    \tFind the area of the region bounded by the x-axis, the curve $y=xe^{-x}$ and the vertical line through the maximum point.\n\n    \t\\item[87.]\n    \tEvaluate $\\int x e^x \\cos x dx$\n\n    \t\\item[88.]\n    \tFind the area between the two curves:\\\\\n    \ta)$y=\\ln x, y = \\ln \\frac{1}{x}, 1 < x < e $ \\\\\n    \tb)$y=\\sin ^2x,y = \\sec x, \\frac{2\\pi}{4} < x < \\frac{5\\pi}{4}$\n\n    \t\\item[89.]\n    \tGiven $I_n = \\int \\cos (n \\arctan x)dx$, show that $I_{n+2} + 2I_n + I_{n-2} = \\frac{4}{n} \\sin (n \\arctan x)+c$ \n\n    \t\\item[90.]\n    \tDetermine the convergence or divergence, and find the value\n\n\t\\end{enumerate}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/482}\n% ++++++++++++++++++++++++++++++++++++++\n\n\\subsection{Volume of a Solid of Revolution}:\n\\label{subsec:VolumeofaSolidofRevolution}\n\\\\\nA \\hDefined{solid of revolution} is the solid generated by revolving a plane region about a (straight) line. This line is called the symmetry axis of the solid. The boundary of a surface of revolution is certainly a surface of revolution.\n\\\\\nConsider first a region under the curve of a continuous positive function \\(y=f(x)\\) bounded by the lines \\(x=a, x=b.\\)\n\\\\\nWhen this region is revolved about the x-axis (or the y-axis), it generates a solid of revolution whose volume is denoted by \\(V_{ox}\\) (or \\(V_{oy}\\)).\n\\begin{figure}[htb]\n\t\\centering\n    \\includegraphics[width=.4\\textwidth]{images/b1p2-482-fig01}\n\\end{figure}\n\\\\\nFor this region, for convenience \\(V_{ox}\\) will be evaluated by what we call \\hDefined{disc method}, while \\(V_{oy}\\) by \\hDefined{shell method} as explained below.\n\\\\\nConsider an element of area as a vertical strip in the region R. When R is rotated about x-axis (y-axis) the strip generates an element of volume in the form of a \\hDefined{disc} (a \\hDefined{shell})\n\\begin{figure}[htb]\n\t\\begin{minipage}{0.45\\textwidth}\n\t\t\\centering\n    \t\\includegraphics[width=\\textwidth]{images/b1p2-482-fig02}\n\t\t\\caption{Disc of radius y and thickness dx}\n\t\\end{minipage}\n\t\\begin{minipage}{0.45\\textwidth}\n\t\t\\centering\n    \t\\includegraphics[width=\\textwidth]{images/b1p2-482-fig03}\n\t\t\\caption{Shell of inner radius x, thickness dx and height y.}\n\t\\end{minipage}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%\n\\hPage{b1p2-497}\n%%%%%%%%%%%%%%%%%%%%%%\n\t\\paragraph{}$M_{ox} = \n\t\\begin{cases}\t\\int_{a}^{b} \\  f(x) \\ \\delta{x} \\ \\sqrt{1 + f^{'^{2}}(x)}\\hDif {x} \\\\ \\int_{c}^{d} \\  y \\ \\delta{y} \\ \\sqrt{1 + g^{'^{2}}(y)}\\hDif {y}, \\\\ \\end{cases}$ \\\\ \n\t\\paragraph{}$M_{oy} = \\begin{cases} \\int_{a}^{b} \\ x \\ \\delta{x} \\ \\sqrt{1 + f^{'^{2}}(x)}\\hDif {x} \\\\ \\int_{c}^{d} \\ g(y) \\ \\delta{y} \\ \\sqrt{1 + g^{'^{2}}(y)}\\hDif {y}. \\\\ \n\t\\end{cases}$\n\t\\paragraph{}We define the \\textit{center of mass (center of gravity)} of the arc with mass as the point G($\\overline{x}$, $\\overline{y}$) such that the moments m$\\overline{y}$, m$\\overline{x}$ of the particle G(m) are the same as the moments $M_{ox}$, $M_{oy}$ of the arc where m is the total mass of the arc:\n\t\\begin{align*}\n\t\tm \\overline{x} &= M_{oy} \\ ,  &m\\overline{y}= M_{ox}\n\t\\end{align*}\n\tThese defined equalities give\n\t\\begin{align*}\n\t\t  \\overline{x} &= \\frac{M_{oy}}{m}  \\text{,}   &\\overline{y} = \\frac{M_{ox}}{m}\n\t\\end{align*}\n\tas coordinates of the center of mass G. \n\t\\paragraph{}$\\underline{Example}$. Find the center of mass of a wire bent in the shape of semi circle $x^{2}$ + $y^{2}$ = $a^{2}$ if the density is $\\delta{}$ = 2y. \\paragraph{}$\\underline{Solution}$. Since the arc and the density function are symmetric with respect to y-axis, it follows that G lies on y, axis, and $\\overline{x}$ = 0.\n\t\\paragraph{}To find $\\overline{y}$, we evaluate first the total mass m of the wire:\\\\\n\t\\begin{minipage}{0.55\\textwidth}\n\t\\begin{align*}\n\t    m = 2\\int_{0}^{a} 2y\\sqrt{1 + \\frac{y^2}{x^2}} \\ \\hDif{y} = 4a^2 \n\t\\end{align*}\n\tThen\n\t\\end{minipage}\n\t\\begin{minipage}{0.45\\textwidth}\n\t\\includegraphics[width=\\textwidth]{images/b1p2-497-fig01}\n\t\\end{minipage}\n\t\n%++++++++++++++++++++++++++++++++++\n    \\hPage{b1p2/504}\n%+++++++++++++++++++++++++++++++\n    \\begin{hEnumerateAlpha}\n        \\item to the top of the tank, \n        \\item to a level k ft above the top of the tank.\n    \\end{hEnumerateAlpha}\n    \n    \\begin{hEnumerateArabic}\n        \\setcounter{enumi}{42}\n    \n        \\item A trough 20 ft long has a cross section in the shape of an isoceles trapezoid with a lower base 4 ft long, an upper base 10 ft long and an altitude of 4 ft. How much work is done in filling the trough with water if the bottom of the trough is located 20 ft above the pump and the water is pumped in through a valve in the bottom of the trough?\n     \n        \\item A force of 20 kg is required to compress a spring 20 cm long to 19 cm. What is the work done in stretching the spring from a length of 24 cm to 30 cm?\n        \n        \\item A vertical cylindrical tank 6 dm in diameter and 10 dm height is half full of water. Find the amount of work done in pumping all the water to the top of the tank.\n        \n        \\item According to NEWTON's law of universal gravitation two objects of weights $w_{1}$, $w_{2} $ kg are attracted to each other by a force of\n              $$k \\frac{w_{1}w_{2}}{x^2}  kg,$$\n\n        \\noindent where x is the distance between the objects and k is a\n        constant. Find the work done in separating the objects from a distance of \"a meters\" to a distance of \"b meters\" apart.\n        \n        \\item Find the amount of work done in stretching a spring from its natural length of 8 cm to triple that length if a force of 15 kg is needed to triple it natural length.\n        \n        \\item Find moments of the following arc with respect to x- and y- axes, and find also the centroid of the arc if $\\delta$ = 1. \n    \n    \\end{hEnumerateArabic}\n% ++++++++++++++++++++++++++++++++++++++\n\\hPage{b1p2/506}\n% ++++++++++++++++++++++++++++++++++++++\n\n\t\\begin{hEnumerateAlpha}\n\t\t\\item $3(2, 2)$, $4(2, -2)$, $5(-2, 2)$, $2(-2, -2)$\n\n\t\t\\item $6(0, 0)$, $6(8, 0)$, $6(8, 8)$, $3(4, 4)$\n\n\t\t\\item $2(1, 3)$, $7(4, 2)$, $6(3, -3)$, $8(-4, 2)$, $5(-3, -4)$.\n\t\t\n \n\t\\end{hEnumerateAlpha}\t\n    \n   \t \\begin{hEnumerateArabic}\n \t\t \\setcounter{enumi}{58}\n  \t\t \\item Use PAPPUS' Theorem to  find the centroid of the region of a semicircle \n         \t of radius a.\n         \t \\item Use PAPPUS' Theorem to find the volume of the torus generated by \n        \t revolving the area of a circle of radius a, about an axis b($>$a) units \n         \t from the center of the circle. \\\\\n\t\\end{hEnumerateArabic}\n    \n    \t ANSWERS TO EVEN NUMBERED EXERCISES\n    \t\\begin{hEnumerateArabic}\n    \t\t\\setcounter{enumi}{35}\n    \t\t\\item \\( \\frac{500}{3} \\) $\\pi$ ($12,25$ + $\\sqrt[]{35}$ + 100)\n    \t\t\\setcounter{enumi}{37}\n   \t\t\t\\item 1000 g gr-cm.  \n    \t\t\\setcounter{enumi}{39}\n   \t\t\t\\item 60 kg-cm.\n    \t\t\\setcounter{enumi}{41}\n                \\item\n    \t\t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $11$$\\pi$$\\delta$ $r^2$$h^2$ $/ 492$   \n        \t\t\t\\item $\\pi$$\\delta$$r^2$$h(11h/492 + 7k/24)$\n   \t\t\t\\end{enumerate}\t\n    \t\t\\setcounter{enumi}{43}\n   \t\t\\item 840 kg-cm.\n    \t\t\\setcounter{enumi}{45}\n    \t\t\\item $kw_1w_2(1/a -1/b)$ kg-m\n           \t\\setcounter{enumi}{47}\n           \t\\item\n\t\t\t \\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $M_{ox}$ = $-8 \\sqrt[]{2}$ , $M_{oy}$ = $8 \\sqrt[]{2}$ , $G(2, -2)$\n       \t\t\t \t\\item $M_{0x}$ = $12\\pi$ , $M_{0y}$ = $8\\pi$ , $G(2, 3)$.\n   \t\t\t \\end{enumerate}\t\n    \t\t\\setcounter{enumi}{49}\n                \\item\n    \t\t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $(1/2, -3/2)$\n        \t\t\t\\item $(10, 192/205)$\n    \t\t\t\\end{enumerate}\n    \t\t\\setcounter{enumi}{51}\n                \\item\n    \t\t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $459/20$, $27/4$, $(3/2, 51/10)$\n        \t\t\t\\item $243/10$, $27/4$, $(3/2, 27/6)$\n    \t\t\t\\end{enumerate}\n                \\setcounter{enumi}{53}\n                \\item\n            \t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $M_{ox} = M_{oy} = 3/20$, $G(9/20, 9/20)$\n       \t\t\t        \\item $M_{ox} = 1/4$ , $M_{oy} = (\\pi/2 \\sqrt[]{2})-1$ , $G(1/4(\\sqrt[]{2}-1), (\\pi-2 \\sqrt[]{2})/2 \\sqrt[]{2}( \t\t\t\t\t\t\t\t\t\t\t\\sqrt[]{2}-1)$\n    \t\t\t\\end{enumerate}\t\n               \\setcounter{enumi}{55}\n               \\item\n            \t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $(12/5 , 3/4)$\n                        \t\\item $(8/5 , 16/7)$\n    \t\t\t\\end{enumerate}\n               \\setcounter{enumi}{57}\n               \\item \n            \t\t\\begin{enumerate}[label=\\alph*)]\n\t\t\t\t\\item $(0 , 2/7)$\n                  \t        \\item $(4 , 4)$\n                   \t        \\item $(1/28 , -1/14)$\n    \t\t\t\\end{enumerate}\n              \\setcounter{enumi}{59}\n              \\item $2\\pi^2a^2b$. \n    \\end{hEnumerateArabic}\n\n\\end{document}  \n\n", "meta": {"hexsha": "cbedc7f7339156733c88f0045882c19d5f422dd0", "size": 80826, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "books/pages/b1p2.tex", "max_stars_repo_name": "yildirimyigit/cmpe220_2016_3", "max_stars_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-05-15T22:03:34.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-15T22:03:34.000Z", "max_issues_repo_path": "books/pages/b1p2.tex", "max_issues_repo_name": "yildirimyigit/cmpe220_2016_3", "max_issues_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "books/pages/b1p2.tex", "max_forks_repo_name": "yildirimyigit/cmpe220_2016_3", "max_forks_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6743886744, "max_line_length": 446, "alphanum_fraction": 0.5370301636, "num_tokens": 31242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704796847396, "lm_q2_score": 0.7772998714925403, "lm_q1q2_score": 0.4309898326053553}}
{"text": "% !TeX root = ../thuthesis-example.tex\n\n% Input your chapter title here\n\\chapter{DEEP REINFORCEMENT LEARNING}\n\\label{sec:drl}\n\nThis chapter first gives a brief overview of the theory behind reinforcement learning and then introduces the three deep learning algorithms used during the experiments carried out in this thesis work, namely DQN \\cite{mnih2013playing}, A2C \\cite{mnih2016asynchronous} and PPO \\cite{schulman2017proximal}.\n\n\\section{Deep reinforcement learning}\nDeep reinforcement learning (DRL) usually involves one or more agents interacting with an environment following a policy \\(\\pi\\), like in a Markov Decision Process (MDP), where their goal is to improve their policy such to maximize their earned reward. More specifically, during training, the agent is provided with an observation \\(s_t\\) of the environment for each timestep \\(t=0,1,2,...\\), and it has to respond with an action \\(a_{t}\\). Afterwards, the environment provides a reward \\(r(a_t,s_t)\\), the next state \\(s_{t+1}\\), and a discount factor \\(\\gamma_t\\). As regards to the selection of actions, they are selected according to a policy \\(\\pi\\), modeled by a neural network with weights \\(\\theta\\) that defines a probability distribution over the actions for each state. So, starting from state \\(s_t\\) encountered at time \\textit{t}, we can define the discounted cumulative reward \\(R_t\\) as\n\\begin{equation}\nR_t=\\sum_{i=0}^{\\infty}\\gamma^{i}r_{t+i+1}.\n\\end{equation}\nThus, considering an episode starting at time \\(t=0\\) and terminating at time \\(T\\), the expected discounted reward of a policy \\(\\pi\\) is defined as\n\\begin{equation}\nR_0=\\sum_{i=0}^{T-1}\\mathbb{E}_{a_i\\sim \\pi(s_i)}[\\gamma^i r(a_i,s_i)].\n\\end{equation}\nFollowing, we are going to review in more details the three algorithms that have been employed to conduct this thesis work.\n\n\n\\section{Deep Q-Network}\nDeep Q-network (DQN) \\cite{mnih2013playing} is a neural network used to implement the Q-learning algorithm. More specifically, it learns an estimate of the Q-value \\(Q(s,a,\\theta)\\) parameterized by the parameters \\(\\theta\\) of the network (online network). The Q-value, which measures the value of choosing a particular action when in a particular state, can be defined according to the following recursive formula:\n\\begin{equation} \\label{equation:Qvalue}\nQ_{\\theta_t}(s_{t},a_{t})=r_{t}+\\gamma Q_{\\theta_{t}} ((s_{t+1},a_{t+1})|s_{t},a_{t},\\theta_{t}).\n\\end{equation}\nIts architecture is composed of a first convolutional neural network (CNN) that takes as input a state \\(s_t\\) and learns to detect increasingly abstract features from it. Subsequently, a dense classifier maps the high-level extracted features to an output layer with one neuron per action in order to approximate the corresponding action value. The parameters of the network are trained by gradient descent to minimize the following loss function:\n\\begin{equation} \\label{equation:DQN}\nL_t(\\theta_t)=(r_{t+1}+\\gamma_{t+1}\\max_{a'}Q_{\\theta^{-}}(s_{t+1},a')-Q_{\\theta_t}(s_t,a_t))^2.\n\\end{equation}\nDuring training, a batch of experiences is randomly picked from the replay memory which is a sort of dataset storing the agent’s past experiences defined as the tuple \\((s_t, a_t, r(a_t,s_t), s_{t+1})\\). The experience replay technique prevents the network from learning from strongly correlated experiences that break the i.i.d. assumption of many popular stochastic gradient-based algorithms, as well as avoiding the rapid forgetting of possibly rare experiences that would be useful later on. Because of the experience replay, DQN is an off-policy algorithm since some sampled experiences might be explored with an older version of the online policy. The gradient of the loss is then back-propagated only into the parameters \\(\\theta\\) of the online network which is used to select actions. The term \\(\\theta^-\\) represents the parameters of a target network, a periodic copy of the online network which is not directly optimized and is used to estimate the maximum expected reward in equation (\\ref{equation:DQN}). During training, the parameters of the online network are periodically copied into the ones of the target network so to update its weights. The advantage introduced by having an independent target network is to make the target Q-value independent with respect to the predicted Q-value when computing the loss so as to increase training stability. Overall, the Q-value calculated by the target network has more accuracy since it has access to at least the first reward term to calculate it. In order to encourage exploration, in particular during the early stage of training, greedy actions are taken with probability 1-\\(\\epsilon\\) otherwise are performed random actions so to discover new policies that may lead to higher rewards.\n\n\\section{Advantage actor-critic}\nAdvantage Actor-Critic (A2C) \\cite{mnih2016asynchronous} is formed by a neural network parameterized by \\(\\theta\\) with 2 output layers: the first one is a softmax layer with weights \\(\\theta_\\pi\\) and outputs a policy \\(\\pi(a_t|s_t; \\theta_\\pi)\\) (actor), the second one consists of a linear output for the value function \\(V(s_t; \\theta_v)\\) (critic) parameterized by \\(\\theta_v\\). Both the policy and the value function are periodically updated by gradient descent computing the gradient as\n\\begin{equation} \\label{equation:A2C}\n\\nabla_\\theta=\\log \\pi(a_t|s_t;\\theta_\\pi)A(a_t,s_t;\\theta_v),\n\\end{equation}\n\\begin{equation} \\label{equation:advantage}\nA(a_t,s_t;\\theta_v)=R_t-V(s_t;\\theta_v),\n\\end{equation}\nwhere \\(A(a_t,s_t;\\theta_v)\\) is an estimate of the advantage function which measures the relative importance of each action respect to the state \\(s_t\\). The formula to compute the gradient derives from the loss function which is simply the negative log likelihood of the predicted action multiplied by the advantage. It also exists an asynchronous version called A3C which relies on several asynchronous agents, each of them interacting with its own copy of the environment, that accumulate gradients and periodically send them to the global network to perform updates. Agents running in parallel, possibly using different exploration policies, are likely to explore different parts of the environment, thus increasing samples' diversity and decreasing their correlation. Other benefits brought by using asynchronous agents consist of a linear reduction of training time based on the number of parallel agents, and the absence of an experience replay. This method is on-policy since it sequentially learns over its observed states. Note that Actor-Critic doesn't have an explicit hyper-parameter to regulate its grade of exploration since it trains a stochastic policy where exploration is done by sampling actions according to the actions probabilities defined by the actor network. Over the course of training, the policy will learn to become progressively less random.\n\n\\section{Proximal Policy Optimization}\nProximal Policy Optimization (PPO) \\cite{schulman2017proximal} is a model-free on-policy algorithm that aims to balance among ease of implementation, sample complexity, and ease of tuning. PPO tries to compute an update at each step that minimizes the cost function while ensuring that the deviation from the previous policy is relatively small:\n\\begin{equation} \\label{equation:PPO}\nL^{CLIP}(\\theta)=\\mathbb{E}_t[\\min(\\frac{\\pi_\\theta(a_t|s_t)}{\\pi_{\\theta_{old}}(a_t|s_t)}A_t,clip(\\frac{\\pi_\\theta(a_t|s_t)}{\\pi_{\\theta_{old}}(a_t|s_t)},1-\\epsilon,1+\\epsilon)A_t)],\n\\end{equation}\nwhere the clipping operator prevents the maximization of the objective to lead to an excessively large policy update by constraining it in the interval \\([1-\\epsilon,1+\\epsilon]\\) and \\(A_t\\) is the advantage function computed as in equation (\\ref{equation:advantage}). The architecture of the network involved in this algorithm is similar to A2C giving as output a distribution over actions and a value function used to compute the value of the advantage. Both functions are periodically updated after collecting a certain amount of trajectories. Moreover, PPO can run \\(N\\) parallel actors to collect the data, and then sample mini-batches of \\(T\\) timesteps to optimize the loss for \\(K\\) epochs using SGD.", "meta": {"hexsha": "99ea75323a67fe08e30162bc45f1607244380289", "size": 8227, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "data/chap02.tex", "max_stars_repo_name": "davide97l/master-thesis", "max_stars_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-02T05:46:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-02T05:46:48.000Z", "max_issues_repo_path": "data/chap02.tex", "max_issues_repo_name": "davide97l/master-thesis", "max_issues_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "data/chap02.tex", "max_forks_repo_name": "davide97l/master-thesis", "max_forks_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 175.0425531915, "max_line_length": 1750, "alphanum_fraction": 0.7838823386, "num_tokens": 1943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.43098980971826373}}
{"text": "\\chapter{Survival Data and the Kaplan-Meier Curve \\label{chapter:km}}\n\nWe have already investigated supervised learning models and hypothesis tests in cases where the outcome of interest is a category or number. But what if the outcome is a \\emph{time duration}? For example, what if we're comparing the effects of two treatments and our outcome is the time between treatment administration and disease progression?\n\nData where the outcome is a time duration are very common in clinical data science and are called \\textbf{time-to-event} data or \\textbf{survival data}. The field of \\textbf{survival analysis} develops methods to analyze and interpret such data. We will examine one such method today and many more in subsequent chapters.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Example: Ovarian Cancer Survival Dataset \\label{section:ovarian}}\n\nToday we'll examine some data from a study of ovarian cancer\\footnote{The dataset comes from the \\texttt{survival} package in R and is labeled \\texttt{ovarian}. The original study is Edmonson JH \\emph{et al}, ``Different chemotherapeutic sensitivities and host factors affecting prognosis in advanced ovarian carcinoma versus minimal residual disease'', \\emph{Cancer Treatment Reports}, 63(2): 241-247; 1979.}. The dataset contains information on $26$~women. The variables are:\n\n{\\small\n\\begin{itemize}\n\\item \\texttt{futime}: The number of days from enrollment in the study until death or censoring, whichever came first\n\\item \\texttt{fustat}: An indicator of death (1) or censoring (0)\n\\item \\texttt{age}: The patient's age in years at the time of treatment administration\n\\item \\texttt{resid.ds}: Residual disease present at the time of treatment administration (1 = no, 2 = yes)\n\\item \\texttt{rx}: Treatment group (1 = cyclophosphamide, 2 = cyclophosphamide + adriamycin)\n\\item \\texttt{ecog.ps}: A measure of performance score or functional status at the time of treatment administration, using the Eastern Cooperative Oncology Group's (ECOG) scale. It ranges from 0 (fully functional) to 4 (completely disabled). Level 4 subjects are usually considered too ill to enter a randomized trial such as this. The patients in this dataset are all at Levels 1 and 2. \n\\end{itemize}\n}\n\n\\noindent Here is a histogram of the follow-up times (\\texttt{futime}) in days, colored according to whether the patient died or was censored (\\texttt{fustat}):\n\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{img/cs-ovarian-futime.png}\n\\end{center}\n\n\\noindent And here is the same graph colored by treatment group (\\texttt{rx}):\n\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{img/cs-ovarian-futime2.png}\n\\end{center}\n\nNow, imagine that we want to study the effect of the treatment group (\\texttt{rx}) on the outcome of death or no death (1 = death, 0 = no death). We could think of this as a classification problem with only a single feature: treatment group. Unfortunately, this method of analyzing time-dependent data is fraught with problems:\n\n\\begin{enumerate}\n\\item How do you choose the time horizon at which to evaluate mortality?\n\\item How do you handle people who dropped out of the study before that time?\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Definitions}\n\n\\textbf{Censoring} occurs when the event of interest in a time-to-event analysis is not observed. It is a form of missing data problem (see Chapter~\\ref{chapter:missingdata}) and can be caused by a variety of factors, including inconsistencies in follow-up, the study's ending before all subjects have experienced the event, or a lack of knowledge about when, exactly, the event occurred. The type of censoring represented in the \\texttt{ovarian} dataset is called \\textbf{right-censoring}. We will focus on right-censoring today and investigate other types later.\n\\begin{quote}\n\\textbf{Right censoring:} A situation that arises when the event of interest has not occurred by the end of the follow-up period. This may be because (a) the study itself ends, (b) a patient is lost to follow-up during the study period, or (c) a patient experiences a different event that makes further follow-up impossible\\footnote{For more information, please see Clark TG \\emph{et al}, ``Survival Analysis Part I: Basic Concepts and First Analyses'', \\emph{British Journal of Cancer}, 89, 232--238; 2003.}.\n\\end{quote}\n\nSurvival data are generally described using two probabilities, called the survival and hazard. \n\\begin{quote}\n\\textbf{Survival:} Also called the \\textbf{survival function} or \\textbf{survival probability} and abbreviated $S(t)$, this is the probability that an individual survives to time $t$ (i.e., does not experience the event by time $t$).\\\\[5mm]\n\\textbf{Hazard:} Usually denoted by $h(t)$ or $\\lambda(t)$, this is the probability that an individual who has not yet experienced the event at time $t$ experiences it at that exact time. In other words, it is the instantaneous event rate for an individual who has already survived to time $t$. \n\\end{quote}\n\nWe will focus on the survival function now and learn more about the hazard later. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{The Kaplan-Meier Estimator}\n\nThe \\textbf{Kaplan-Meier estimator} is a nonparametric estimate of the survival function, usually represented graphically by a \\textbf{Kaplan-Meier curve}\\footnote{It can be shown mathematically that the Kaplan-Meier estimator is the maximum likelihood estimator (see Chapter~\\ref{chapter:mlebasics}) of the survival function in the case of censoring.}. The Kaplan-Meier estimator looks like this:\n$$ \\hat{S}(t) = \\prod_{j|t_j \\leq t} \\frac{n_j - d_j}{n_j} $$\nwhere $d_j$ is the number of subjects who fail at time $t_j$ and $n_j$ is the number of subjects at risk just prior to $t_j$. Here is a Kaplan-Meier curve for the \\texttt{ovarian} dataset. The little ``+'' signs correspond to censoring events.\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{img/ovarian-km-curve.png}\n\\end{center}\nAnd here are Kaplan-Meier curves for the two treatment groups separately:\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{img/ovarian-km-curve-rx.png}\n\\end{center}\n\\vspace{5mm}\n\n\\begin{question}{question:kmo1}\nHere are the raw data from treatment group $1$ of the \\texttt{ovarian} dataset. Using these data, fill in the remaining cells of the table below.\n{\\small\n\\begin{center}\n\\begin{tabular}{rlrr}\n  \\toprule\n & rx & futime & fustat \\\\ \n  \\midrule\n  1 & 1 & 59 & 1 \\\\ \n  2 & 1 & 115 & 1 \\\\ \n  3 & 1 & 156 & 1 \\\\ \n  4 & 1 & 268 & 1 \\\\ \n  5 & 1 & 329 & 1 \\\\ \n  6 & 1 & 431 & 1 \\\\ \n  7 & 1 & 448 & 0 \\\\ \n  8 & 1 & 477 & 0 \\\\ \n  9 & 1 & 638 & 1 \\\\ \n  10 & 1 & 803 & 0 \\\\ \n  11 & 1 & 855 & 0 \\\\ \n  12 & 1 & 1040 & 0 \\\\ \n  13 & 1 & 1106 & 0 \\\\ \n  \\bottomrule\n\\end{tabular}\n\\end{center}\n}\n\\vspace{-5mm}\n{\\small\n\\begin{center}\n\\begin{tabular}{rrrrll}\n  \\toprule\n$j$ & $t_j$ & $n_j$ & $d_j$ & $\\hat{S}(t_j)$ & Calculation \\\\ \n  \\midrule\n  0 & 0 & 13 & 0 & $1.000$ & $\\frac{13-0}{13}$ \\\\\n  1 & 59 & 13 & 1 & $0.923$ & $\\hat{S}(t_0) \\left(\\frac{13-1}{13}\\right)$ \\\\\n  2 & 115 & 12 & 1 & $0.846$ & $\\hat{S}(t_1) \\left(\\frac{12-1}{12}\\right)$ \\\\[2mm]\n  3 & 156 & \\\\[2mm] % 11 & 1 & $0.769$ & $\\hat{S}(t_2) \\left(\\frac{11-1}{11}\\right)$ \\\\\n  4 & 268 & \\\\[2mm] % 10 & 1 & $0.692$ & $\\hat{S}(t_3) \\left(\\frac{10-1}{10}\\right)$ \\\\\n  5 & 329 & 9 & 1 & $0.615$ & $\\hat{S}(t_4) \\left(\\frac{9-1}{9}\\right)$ \\\\\n  6 & 431 & 8 & 1 & $0.538$ & $\\hat{S}(t_5) \\left(\\frac{8-1}{8}\\right)$ \\\\\n  7 & 448 & 7 & 0 & $0.538$ & $\\hat{S}(t_6) \\left(\\frac{7-0}{7}\\right)$ \\\\\n  8 & 477 & 6 & 0 & $0.538$ & $\\hat{S}(t_7) \\left(\\frac{6-0}{6}\\right)$\\\\\n  9 & 638 & 5 & 1 & $0.431$ & $\\hat{S}(t_8) \\left(\\frac{5-1}{5}\\right)$\\\\[2mm]\n  10 & 803 & 4 & 0 & \\\\[2mm] % $0.431$ & $\\hat{S}(t_9) \\left(\\frac{4-0}{4}\\right)$ \\\\\n  11 & 855 & 3 & 0 & \\\\[2mm] % $0.431$ & $\\hat{S}(t_10) \\left(\\frac{3-0}{3}\\right)$ \\\\\n  12 & 1040 & 2 & 0 & \\\\[2mm] % $0.431$ & $\\hat{S}(t_11) \\left(\\frac{2-0}{2}\\right)$ \\\\\n  13 & 1106 & 1 & 0 & \\\\[2mm] % $0.431$ & $\\hat{S}(t_12) \\left(\\frac{1-0}{1}\\right)$ \\\\\n  \\bottomrule\n\\end{tabular}\n\\end{center}\n}\n\\end{question}\n\n\\begin{question}{}\nBased solely on the Kaplan-Meier curves for the two treatment groups, which treatment appears to prolong survival more effectively?\n\\end{question}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Assumptions of the Kaplan-Meier Estimator}\n\nThe Kaplan-Meier estimator makes three important assumptions:\n\\begin{enumerate}\n\\item The probability of censoring is unrelated to the outcome of interest.\n\\item The survival probabilities are the same for participants recruited at different times during the study (e.g., circumstances that could alter the survival, such as treatments, do not change over calendar time).\n\\item The events occurred at exactly the times specified. \n\\end{enumerate}\n\n\\begin{question}{}\nWhat is one way each of these assumptions could be violated?\n\\end{question}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Comparing Kaplan-Meier Curves}\n\nOf course, now the question arises: How do we formally compare two Kaplan-Meier curves? There is a nonparametric hypothesis test for comparing Kaplan-Meier curves called the log-rank test; we will see it in Chapter~\\ref{chapter:hypothesisii}. There is also an entire family of linear models, called Cox proportional hazards models, that use the Kaplan-Meier curve as their backbone and model the effects of different covariates on this curve. We will see them in Chapter~\\ref{chapter:cox}.\n\\vspace{5mm}\n\n\\begin{question}{}\nHere are the data for treatment group $2$ of the \\texttt{ovarian} dataset. Perform the calculations of $\\hat{S}(t_j)$ for $j = 0, \\dots, 13$, starting with $t_0 = 0$. Draw the Kaplan-Meier curve, adding symbols for the censoring events.\n{\\small\n\\begin{center}\n\\begin{tabular}{rlrr}\n  \\toprule\n & rx & futime & fustat \\\\ \n  \\midrule\n  1 & 2 & 353 & 1 \\\\ \n  2 & 2 & 365 & 1 \\\\ \n  3 & 2 & 377 & 0 \\\\ \n  4 & 2 & 421 & 0 \\\\ \n  5 & 2 & 464 & 1 \\\\ \n  6 & 2 & 475 & 1 \\\\ \n  7 & 2 & 563 & 1 \\\\ \n  8 & 2 & 744 & 0 \\\\ \n  9 & 2 & 769 & 0 \\\\ \n  10 & 2 & 770 & 0 \\\\ \n  11 & 2 & 1129 & 0 \\\\ \n  12 & 2 & 1206 & 0 \\\\ \n  13 & 2 & 1227 & 0 \\\\ \n  \\bottomrule\n\\end{tabular}\n\\end{center}\n}\n\\begin{center}\n\\includegraphics[width=\\textwidth]{img/km-curve-sample-rx2.png}\n\\end{center}\n\\end{question}\n\n", "meta": {"hexsha": "b96075a69aa9ed7d36de1351d6688fd2ab32e1ca", "size": 10478, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/mcds-kaplan-meier.tex", "max_stars_repo_name": "blpercha/mcds-notes", "max_stars_repo_head_hexsha": "33531a443afb154b5c415299276a2ad215463896", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-12-10T16:51:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T01:31:23.000Z", "max_issues_repo_path": "tex/mcds-kaplan-meier.tex", "max_issues_repo_name": "blpercha/mcds-notes", "max_issues_repo_head_hexsha": "33531a443afb154b5c415299276a2ad215463896", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/mcds-kaplan-meier.tex", "max_forks_repo_name": "blpercha/mcds-notes", "max_forks_repo_head_hexsha": "33531a443afb154b5c415299276a2ad215463896", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-14T17:16:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-14T17:16:44.000Z", "avg_line_length": 56.9456521739, "max_line_length": 564, "alphanum_fraction": 0.6786600496, "num_tokens": 3190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.43094105183116455}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\section*{NYU Physics I---Problem Set 8}\n\nDue Thursday 2018 November 01 at the beginning of lecture.\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nYou walk at a stride rate that is set, in part, by the natural period of\noscillation of your leg, treated as a pendulum.  Estimate this\nperiod by treating your leg as a massless rod with its entire mass in a point mass at\nthe end. That is an absurd approximation! But it is okay at the order-of-magnitude\nlevel. Or is it: Is your answer reasonable?\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nA very thin ladder of length $L$ and mass $M$ leans against a vertical\nwall, on a horizontal floor, making an angle of $\\theta$ with respect\nto the wall.  Imagine that there is a large coefficient of friction\n$\\mu$ at the floor so that the ladder is in static\nequilibrium, but assume that the wall is effectively frictionless.\n\n\\textsl{(a)} Draw a free-body diagram for the ladder, showing all\nforces acting.\n\n\\textsl{(b)} Using the bottom of the ladder as the axis of rotation or\norigin, compute all the forces and torques on the ladder such that it\nis in equilibrium.\n\n\\textsl{(c)} Why did I make the wall ``effectively frictionless''?\n\n\\textsl{(d)} Re-solve the problem using the \\emph{top} of the ladder\nas the axis of rotation or origin.  What is different in the end?\n\n\\textsl{(e)} At what angles $\\theta$ would the ladder start to slip?\nIf $\\mu=0.8$ (not unreasonable for a ladder with hard rubber feet on a wood\nfloor), what is the maximum angle at which you could lean the ladder?\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nA long, thin rod of length $L$ and cross-sectional area $A$ and\nelastic (Young's) modulus $E$ has mass $M$.\n\n\\textsl{(a)} Think of the rod as being like a Hooke's Law spring; it\ncan be stretched by applying a force.  What is the spring constant $k$\nfor this spring?\n\n\\textsl{(b)} By dimensional analysis, can you combine $L$, $A$, $E$,\nand $M$ into a frequency $\\omega$?  Do you have more than one choice?  If so,\nwhich of the choices makes most sense? That is, think about how your\nanswer should scale with changes to the problem.\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nIn lecture, you saw something like the damped harmonic oscillator\ndifferential equation\n\\begin{equation}\nm\\,\\frac{\\dd^2 x}{\\dd t^2} + c\\,\\frac{\\dd x}{\\dd t} + k\\,x = 0 \\quad ,\n\\end{equation}\nwhere $m$ is the mass, $c$ is a damping coefficient, and $k$ is a\nrestoring constant (a spring constant).  Here we are going to show\nthat\n\\begin{equation}\nx(t) = A\\,\\e^{-\\frac{\\gamma}{2}\\,t}\\,\\cos (\\omega\\,t + \\phi)\n\\end{equation}\ncan be a solution to the differential equation.\n\n\\textsl{(a)} What are the units of $c$, $A$, $\\gamma$, and $\\phi$?\n\n\\textsl{(b)} Take a derivative of $x(t)$ to get $v(t)$. Take another\nto get $a(t)$.\n\n\\textsl{(c)} Now plug your derivatives into the differential equation,\nand see if there is a setting of the parameters $\\gamma$ and $\\omega$\nsuch that the differential equation can be satisfied? \\emph{Hint:}\nGroup sine and cosine terms separately; both sets of terms must sum to\nzero for the differential equation to be satisfied. This is related to\nthe concept of \\emph{detailed balance}.\n\n\\textsl{(d)} Did you have to assume things about $m, c, k$ to make\nyour answer work? What things?\n\n\\paragraph{Extra Problem (will not be graded for credit):}%\nRe-do the previous problem using complex exponentials. That is, assume\n\\begin{equation}\nx(t) = Z\\,\\e^{\\alpha\\,t}\n\\end{equation}\nwhere $Z$ and $\\alpha$ are complex numbers. What's different, and\nwhat's the same?\n\n\\paragraph{Extra Problem (will not be graded for credit):}%\nShow that these two descriptions of a simple harmonic oscillator\n\\begin{equation}\nx(t) = A\\,\\cos(\\omega_0\\,t) + B\\,\\sin(\\omega_0\\,t)\n\\end{equation}\n\\begin{equation}\nx(t) = X\\,\\cos (\\omega_0\\,t+\\phi)\n\\end{equation}\nare completely equivalent by finding the relationship between $A, B$\nand $X, \\phi$ that makes them identical.\n\n\\end{document}\n", "meta": {"hexsha": "8d046517b503aa6b52e96495674831c730279524", "size": 4064, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/physics1_ps08.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/physics1_ps08.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/physics1_ps08.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2376237624, "max_line_length": 85, "alphanum_fraction": 0.7342519685, "num_tokens": 1155, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369904, "lm_q2_score": 0.7718434978390746, "lm_q1q2_score": 0.4309410489009404}}
{"text": "\\vsssub\n\\subsubsection{~$S_{in} + S_{ds}$: Rogers et al. 2012 \\& Zieger et al. 2015} \\label{sec:ST6}\n\\vsssub\n\n\\opthead{ST6}{AUSWEX, Lake George}{A. Babanin, I. Young, M. Donelan, E. Rogers, S. Zieger, Q. Liu}\n\n\\noindent\nThis version implements observation-based physics for deep-water source/sink terms. These include wind input\nsource term, and sink terms due to negative wind input, whitecapping\ndissipation and wave-turbulence interactions (swell dissipation).\nThe wind input and whitecapping dissipation source terms are based on\nmeasurements taken at Lake George, Australia; wave-turbulence dissipation\non laboratory experiments and field observations of swell decay; negative\ninput on laboratory testing. Constraint is imposed on the total wind\nenergy input through the wind stress, known independently.\n\n\\paragraph{Wind input.} Apart from first direct field measurements\nof the wind input under strong wind forcing,  the Lake George experiment\nrevealed a number of new physical features for wind-wave exchange,\npreviously not accounted for:\n(i) full air-flow separation that leads to a relative reduction of\nwind input for conditions of strong winds/steep waves;\n(ii) dependence of the wave growth rate on wave steepness,\nwhich signifies nonlinear behavior of the wind-input source function;\n(iii) enhancement of input in the presence of wave breaking\n\\citep{art:Dea06,art:Bea07} (the last feature was not implemented in here).\nFollowing \\citet{art:RBW12}, this input source term is formulated as\n\\begin{eqnarray}\n\\cS_{in}(k,\\theta) & = & \\frac{\\rho_a}{\\rho_w}\\, \\sigma\\,\\gamma(k,\\theta)\\,N(k,\\theta)  ,\n\\label{eq:ST601} \\\\ \\gamma(k,\\theta) &=& G\\,\\sqrt{B_n}\\,W  ,\n\\label{eq:ST602} \\\\\nG                &=& 2.8-\\Bigl (1+\\tanh (10\\sqrt{B_n}W-11) \\Bigr)  ,\n\\label{eq:ST603} \\\\\nB_n              &=& A(k)\\,N(k)\\sigma\\,k^3  ,\n\\label{eq:ST604} \\\\\nW                &=& \\left (\\frac{U_s}{c}\\,-\\,1 \\right )^2  .\n\\label{eq:ST605}\n\\end{eqnarray}\n\n\\noindent\nIn (\\ref{eq:ST601})$-$(\\ref{eq:ST605}) $\\rho_a$ and $\\rho_w$ are densities\nof air and water, respectively, $U_s$ is the scaling wind speed, $c$ refers to\nwave phase speed, $\\sigma$ is radian frequency and $k$\nis wavenumber. The spectral saturation (\\ref{eq:ST604}), introduced\nby \\citet{art:Phi84}, is a spectral measure of steepness $ak$.  The\nomni-directional action density is obtained by integration over all directions:\n$N(k)=\\int N(k,\\theta)d\\theta$.\\linebreak\nThe inverse of the directional spectral narrowness $A(k)$ is defined as\\linebreak\n$A^{-1}(k) =$ $\\int_{0}^{2\\pi} [{N(k,\\theta)}/{N_{\\max}(k)}] d\\theta$,\nwhere $N_{\\max}(k)=\\max\\bigl \\{N(k,\\theta)\\bigr \\}$, for all\ndirections $\\theta\\in[0,2\\pi]$ \\citep{art:BS87}.\n\n\\citet{art:Dea06} parameterized the growth rate (\\ref{eq:ST602}) in terms\nof winds 10\\,m above the mean surface. Wave models, however, typically employ friction\nvelocity $u_\\star=\\tau/\\rho_a$ to assure a consistent fetch law across\ndifferent wind speeds \\citep[][p. 253]{bk:WAM94}. Therefore, \\citet{art:RBW12}\nadvocated using an approximation\n\\begin{equation}\nU_s = U_{10} \\simeq \\Upsilon u_{\\ast},\\ \\mathrm{and}\\ \\Upsilon = 28\n\\label{eq:Upsilon}\n\\end{equation}\nby following \\citet{art:KHH84}.\n\n\\begin{eqnarray}\nW_1 & = & \\mathrm{max}^2 \\left \\{ 0,\\frac{U}{c}\\ \\cos(\\theta-\\theta_w)-1\n\\right \\}  , \\label{eq:ST606-1} \\\\\nW_2 & = & \\mathrm{min}^2 \\left \\{ 0,\\frac{U}{c}\\ \\cos(\\theta-\\theta_w)-1\n\\right \\} .\\label{eq:ST606-2}\n\\end{eqnarray}\n\n\\noindent\nThe directional distribution of $W$ is implemented as the sum of favorable\nwinds (\\ref{eq:ST606-1}) and adverse winds (\\ref{eq:ST606-2}), so that they\ncomplement one another (i.e. $W=\\{W_1\\cup W_2$\\}, see {\\it Negative Input}\nlater this section):\n\\begin{equation}\\label{eq:ST606}\nW=W_1-a_0\\,W_2  .\n\\end{equation}\n\n\\paragraph{Wind input constraint.} One important part of the input is the\ncalculation of the momentum flux from the atmosphere to the ocean,\nwhich must agree with the flux received by the waves. At the surface,\nthe stress $\\vec{\\tau}$ can be written as the sum of the viscous and\nwave-supported stress: $\\vec{\\tau} = \\vec{\\tau}_{v} + \\vec{\\tau}_{w}$.\nThe wave-supported stress $ \\vec{\\tau}_{w}$ is used as the principal\nconstraint for the wind input and cannot exceed the total stress\n$\\vec{\\tau} \\le \\vec{\\tau}_{tot}$.  Here the total stress is determined\nby the flux parameterization: $\\vec{\\tau}_{tot}=\\rho_a u_\\star|u_\\star|$.\nThe wave-supported stress $\\tau_w$ can be calculated by integration over\nthe wind-momentum-input function:\n\n\\begin{equation}\\label{eq:ST609}\n   \\vec{\\tau}_w = \\rho_w g \\int_{0}^{2\\pi} \\int_{0}^{k_{max}}\n   \\frac{S_{in}(k^\\prime,\\theta)}{c} \\Bigl (\\cos\\theta,\\sin\\theta \\Bigr )\n   dk^\\prime d\\theta  .\n\\end{equation}\n\n\\noindent\nComputation of the wave-supported stress (\\ref{eq:ST609}) includes the\nresolved part of the spectrum up to the highest discrete wavenumber $k_{max}$,\nas well as the stress supported by short waves. To account for the latter,\nan $f^{-5}$ diagnostic tail is assumed beyond the highest frequency in the\nenergy density spectrum. In order to satisfy the constraint and in the case\nof $\\vec{\\tau} > \\vec{\\tau}_{tot}$, a wavenumber dependent factor $L$ is\napplied to reduce energy from the high frequency part of the spectrum:\n$S_{in}(k^\\prime)=L(k^\\prime)\\,S_{in}(k^\\prime)$ with\n\n\\begin{equation}\\label{eq:ST610}\nL(k^\\prime) = \\min \\Bigl \\{ 1, \\exp \\bigl ( \\mu\\,[1- U/c] \\bigr ) \\Bigr\n\\}  .\n\\end{equation}\n\n\\noindent\nThe reduction (\\ref{eq:ST610}) is a function of wind speed and phase speed and\nfollows an exponential form designed to reduce energy from the discrete part\nof the spectrum. The strength of reduction is controlled by coefficient $\\mu$,\nwhich has a greater impact at high frequencies and only little impact on the\nenergy-dominant part of the spectrum. The value of $\\mu$ is dynamically\ncalculated by iteration at each integration time step \\citep{art:Tea10}.\n\nThe drag coefficient is given by\n\\begin{equation}\\label{eq:ST607}\nC_d \\times 10^4 = 8.058 + 0.967 U_{10} - 0.016 U_{10}^2 ,\n\\end{equation}\nwhich was selected and\nimplemented as switch {\\code FLX4}. The parameterization was proposed by\n\\citet{art:Hwa11} and accounts for saturation, and further decline\nfor extreme winds, of the sea drag at wind speeds in excess of 30\\,m~s$^{-1}$.\nTo prevent $u_\\star$ from dropping to zero at very strong winds\n($U_{10}\\ge50.33$m~s$^{-1}$) expression (\\ref{eq:ST607}) was modified to yield\n$u_\\star=2.026$m~s $^{-1}$. {\\it Important!} In {\\code ST6}, bulk adjustment to any\nuniform bias in the wind input field is done in terms of the wind stress\nparameter $u_\\star$ rather than $U_{10}$. In order to achieve that, the\nfactor in expression $C_d \\times 10^4$ on the left hand side of\n(\\ref{eq:ST607}) was substituted with $C_d \\times \\mathrm{FAC}$ and added\nas the {\\F FLX4} namelist parameter {\\code CDFAC} (see {\\it Bulk Adjustment}\nat the end of this section).\nThe viscous drag coefficient,\n\\begin{equation}\\label{eq:ST608}\n  C_v \\times 10^3 = 1.1 - 0.05 U_{10} ,\n\\end{equation}\nwas parameterized by \\citet{art:Tea10} as a function of wind speed using\ndata from \\citet{art:BP98}.\n\n\\paragraph{Negative Input.} Apart from the positive input, {\\code ST6} also has a\nnegative input term in order to attenuate the growth of waves in those parts\nof the wave spectrum where an adverse component of the wind stress is present\n(\\ref{eq:ST606-1}--\\ref{eq:ST606-2}). The growth rate for adverse winds\nis negative \\citep{pro:Don99} and is applied after the constraint of\nthe wave-supported stress $\\tau_w$ is met. The value of $a_0$\n(in \\ref{eq:ST606}) is a tuning parameter in the parameterization of the\ninput and is adjustable through the {\\F SIN6} namelist parameter {\\code  SINA0}.\n\n\n\\noindent\n\\paragraph{Whitecapping Dissipation.} For dissipation due to wave breaking,\nthe Lake George field study revealed a number of new features: (i) the\nthreshold behavior of wave breaking \\citep{art:BBY01}. The waves do not\nbreak unless they exceed a generic steepness in which case the wave breaking\nprobability depends on the level of excedence above this threshold steepness.\nFor waves below the critical threshold, whitecapping dissipation is zero.\n(ii) the cumulative dissipative effect due to breaking and dissipation of\nshort waves affected by longer waves\n\\citep{pro:Don01,pro:BY05,art:Mea06,art:YB06,art:Bea10},\n(iii) nonlinear dissipation function at strong winds\n(\\citeauthor{art:Mea06}, \\citeyear{art:Mea06};\\linebreak\n \\citeauthor{art:Bea07}, \\citeyear{art:Bea07}),\n(iv) bimodal distribution of the directional spreading of the dissipation\n\\citep{art:YB06,art:Bea10} (the last feature was not implemented in {\\code ST6}).\nFollowing \\citet{art:RBW12}, the whitecapping dissipation term is\nimplemented as:\n\\begin{equation}\\label{eq:ST620}\n  \\cS_{ds}(k,\\theta) = \\Bigl [ T_1(k,\\theta) + T_2(k,\\theta) \\Bigr ]\\ N(k,\\theta) ,\n\\end{equation}\n\n\\noindent\nwhere $T_1$ is the inherent breaking term, expressed as the traditional function\nof the wave spectrum, and $T_2$, expressed as an integral of the wave spectrum below\nwavenumber $k$, accounts for the cumulative effect of short-wave breaking or\ndissipation due to longer waves at each frequency/wavenumber. The inherent breaking\nterm $T_1$ is the only breaking-dissipation term if this frequency is at or below\nthe spectral peak. Once the peak moves below this particular frequency, $T_2$\nbecomes active and progressively more important as the peak downshifts further.\n\nThe threshold spectral density $F_{\\mathrm{T}}$ is calculated as\n\\begin{equation}\\label{eq:ST621}\n  F_{\\mathrm{T}}(k)=\\frac{\\varepsilon_{\\mathrm{T}}}{A(k)\\,k^3}  ,\n\\end{equation}\nwhere $k$ is the wavenumber and with\n$\\varepsilon_{\\mathrm{T}}=0.035^2$ being an empirical constant\n\\citep{art:Bea07,bk:Bab11}. Let the level of exceedence above the critical\nthreshold spectral density (at which stage wave breaking is predominant) be\ndefined as $\\Delta(k)=F(k)-F_{\\mathrm{T}}(k)$. Furthermore, let\n$\\mathcal{F}(k)$ be a generic spectral density used for normalization,\nthen the inherent breaking component can be calculated as\n\\begin{equation}\\label{eq:ST622}\nT_1(k)=a_1 A(k)\\frac{\\sigma}{2\\pi} \\left [ \\frac{\\Delta(k)}{\\mathcal{F}(k)}\n\\right ]^{p_1}  .\n\\end{equation}\n\n\\noindent\nThe cumulative dissipation term is not local in frequency space and is\nbased on an integral that grows towards higher frequencies, dominating at\nsmaller scales:\n\n\\begin{equation}\\label{eq:ST623}\nT_2(k)=a_2 \\int\\limits_0^k A(k) \\frac{c_g}{2\\pi} \\left [\n\\frac{\\Delta(k)}{\\mathcal{F}(k)} \\right ]^{p_2}\\!\\!dk .\n\\end{equation}\n\n\\noindent\nThe dissipation terms (\\ref{eq:ST622})$-$(\\ref{eq:ST623}) depend on five\nparameters: a generic spectral density $\\mathcal{F}(k)$ used for\nnormalization, and four coefficients $a_1$, $a_2$, $p_1$, and $p_2$.  The\ncoefficients $p_1$ and $p_2$ control the strength of the normalized threshold\nspectral density $\\Delta(k)/\\mathcal{F}(k)$ of the dissipation terms.\nNamelist parameter {\\code SDSET} changes between the spectral density\n$F(k)$ and threshold spectral density $F_{\\mathrm{T}}(k)$ for\nnormalization in (\\ref{eq:ST622})--(\\ref{eq:ST623}).\nAccording to \\citet{art:Bea07} and \\citet{art:Bab09}, the directional\nnarrowness parameter is set to unity $A(k)\\approx 1$ in Eqs.\n(\\ref{eq:ST621})$-$(\\ref{eq:ST623}).\n\n% -------------------------------------------------------------------\n\\begin{table} \\begin{center}\n\\footnotesize\n\\begin{threeparttable}\n\\begin{tabular}{|l|c|c|c|c|c|} \\hline \\hline\nParameter          &  WWATCH var. & namelist &  vers.\\,4.18 & vers.\\,5.16 & vers.\\,\\WWver \\\\\n\\hline\n  $F_{\\mathrm{T}}$ &  SDSET       & SDS6     &  T       &  T         & T          \\\\\n  $a_1$            &  SDSA1       & SDS6     & 6.24E-7  & 3.74E-7    & 4.75E-6    \\\\\n  $p_1$            &  SDSP1       & SDS6     &  4       &  4         & 4          \\\\\n  $a_2$            &  SDSA2       & SDS6     & 8.74E-6  & 5.24E-6    & 7.00E-5    \\\\\n  $p_2$            &  SDSP2       & SDS6     &  4       &  4         & 4          \\\\\n\\hline\n  $\\Upsilon$\\tnote{\\textdagger}       &  SINWS       & SIN6     & n/a      & n/a        & 32.0       \\\\\n  $N_{hf}$\\tnote{\\textdagger}         &  SINFC       & SIN6     & n/a      & n/a        & 6.0        \\\\\n  $a_0$            &  SINA0       & SIN6     & 0.04     & 0.09       & 0.09       \\\\\n  $b_1$ is constant&  CSTB1       & SWL6     & n/a      &  F         & F          \\\\\n  $b_1$, $B_1$     &  SWLB1       & SWL6     & 0.25E-3  & 0.0032     & 0.0041     \\\\\n  $\\mathrm{FAC}$   &  CDFAC       & FLX4     & 1.00E-4  & 1.00E-4    & 1.0        \\\\\n\\hline\n  $C$              &  NLPROP      & SNL1     & 3.00E7   &  3.00E7    & 3.00E7    \\\\\n \\hline \\hline\n\\end{tabular}\n\\begin{tablenotes}\n\t\\item[\\textdagger] In WW3 version 4.18 and 5.16, $\\Upsilon = 28.0$\n            and $N_{hf} = 6.0$ were hard-coded in {\\code ST6} module.\n\\end{tablenotes}\n\\end{threeparttable} \\end{center}\n\\caption{Summary of calibration parameters for {\\code ST6} when it is applied with\n         the {\\code DIA} nonlinear solver (section~\\ref{sec:NL1}). Values tabulated represent default model settings.\n         Abbreviation ``n/a'' indicates that the variable is not applicable\n         in that release of the code.}\n\\label{tab:ST601} \\botline \\end{table}\n% -------------------------------------------------------------------\n\n\\citet{art:RBW12} calibrated the dissipation terms based on duration-limited\nacademic tests. Calibration coefficients used in {\\code ST6} and listed in\nTable~\\ref{tab:ST601} differ somewhat from those of \\citet{art:RBW12}\nmainly due to the fact that the wave-supported stress $\\vec{\\tau}_w$\nis implemented in the form of vector components and the non-breaking swell\ndissipation (\\ref{eq:ST624}) was previously not accounted for in\n\\citet{art:RBW12}.\n\n\\paragraph{Swell Dissipation.} In the absence of wave breaking,\nother mechanisms of wave attenuation are present. Here, they are\nreferred to as swell dissipation and parameterized in terms of\nthe interaction of waves with oceanic turbulence \\citep{bk:Bab11}.\nThis mechanism, however, remains active for the wind-generated\nwaves too. Its contribution across the spectrum is small, if the\nspectrum is above the wave-breaking threshold, but it is dominant\nat the front face of the spectrum, or even at the peak in case of\nthe full Pierson-Moscowitz development.\n\n\\begin{equation}\\label{eq:ST624}\n  \\cS_{swl}(k,\\theta) = -\\frac{2}{3}b_1 \\sigma\\ \\sqrt{B_n}\\ N(k,\\theta).\n\\end{equation}\n\n\\noindent\nBy making coefficient $b_1$ in Eq. (\\ref{eq:ST624}) dependent\non steepness the large gradient in the spatial bias in wave height\ncan be reduced:\n\n\\begin{equation}\\label{eq:ST625}\n   b_1 = B_1 \\, 2\\sqrt{E}\\,k_p .\n\\end{equation}\n\nIn Eq. (\\ref{eq:ST625}), $B_1$ is a scaling coefficient,\n$E$  is the total sea surface variance Eq. (\\ref{eq:etot}) and $k_p$\nis the peak wavenumber.  Eq. (\\ref{eq:ST625}) can be\nflagged through the {\\F SWL6} namelist parameter {\\code CSTB1}.The value for the\ncoefficient $B_1$ in Eq. (\\ref{eq:ST625}) and/or $b_1$ in Eq. (\\ref{eq:ST624})\nis customizable through the {\\F SWL6} namelist parameter {\\code SWLB1}\n(see Table~\\ref{tab:ST601}).\n\n\\noindent\n\\paragraph{Updates since vers.\\,\\WWver} Following \\citet{art:RBW12}, the\nscaling wind speed $U_s = 28u_{\\ast}$ (\\ref{eq:Upsilon}) were adopted in\nvers. 4.18 and vers. 5.16 (Table~\\ref{tab:ST601}). Such configurations of {\\code ST6} have been proven\nskillful for different spatial scales and under different weather\nconditions \\citep[e.g.][]{art:ZBRY15, liu2017}. \\citet[][their Fig. 5]{art:ZBRY15},\nhowever, also suggested {\\code ST6} (vers. 4.18 and vers. 5.16) was inclined to\noverestimate the energy level of the high-frequency tail of the spectrum,\nindicating an inaccurate balance of different source terms in this\nspecific frequency range.\n\nRogers (2014, unpublished work) found that using $U_s = 32u_{\\ast}$ (i.e.,\n$\\Upsilon = 32$) could improve model skills in estimating tail level in\nthe {\\code ST6} implementation in SWAN [see also \\citet{Rogers2017}]. Following\nthis, \\citet{Liu2019} carried out a thorough recalibration of {\\code ST6} with WW3,\nand the new set of parameters (i.e., $a_0,\\ a_1,\\ a_2,\\ B_1$) is summarized\nin the last column of Table~\\ref{tab:ST601}. The updated {\\code ST6} package not\nonly performs well in predicting commonly-used bulk wave parameters (e.g.,\nsignificant wave height and wave period) but also yields a clearly-improved\nestimation of high-frequency energy level (in terms of saturation spectrum\nand mean square slope). In the duration-limited test, the omnidirectional\nfrequency spectrum $E(f)$ from the recalibrated {\\code ST6} shows a clear transition\nbehavior from the power law of approximately $f^{-4}$ to the power law of\nabout $f^{-5}$, comparable to previous field studies \\citep{Forristall1981}.\n\n% -------------------------------------------------------------------\n\\begin{table}[htbp]\n\t\\footnotesize\n\t\\begin{center}\n\t\\begin{tabular}{|l|c|c|c|c|} \\hline \\hline\n            {\\code ST6} & $a_0$ & $a_1$ & $a_2$ & $B_1$\\\\\n                        & 0.05 & $4.75 \\times 10^{-6}$ & $7.00 \\times 10^{-5}$ & $6.00 \\times 10^{-3}$  \\\\\n            \\hline\n            {\\code GMD} & $\\lambda$ & $\\mu$ & $\\theta_{12}\\ (^{\\circ})$ & $C_{deep}$  \\\\\n                        & $0.127$ & $0.000$ & $\\ 3.0$ & $4.88 \\times 10^7$            \\\\\n\t\t        & $0.127$ & $0.097$ & $21.0$ & $1.26 \\times 10^8$             \\\\\n\t\t        & $0.233$ & $0.098$ & $26.5$ & $6.20 \\times 10^7$             \\\\\n\t\t        & $0.283$ & $0.237$ & $24.7$ & $2.83 \\times 10^7$             \\\\\n\t\t        & $0.355$ & $0.183$ & $-$ & $1.17 \\times 10^7$                \\\\\n            \\hline \\hline\n\t\\end{tabular}\n\t\\end{center}\n        \\caption{Summary of calibration parameters for {\\code ST6} when it is applied with the {\\code GMD} nonlinear solver (or specifically, {\\code G35})}\n\t\\label{tab:ST602}\n\t\\botline\n\\end{table}\n% -------------------------------------------------------------------\n\nApart from applying {\\code ST6} with the {\\code DIA} (section~\\ref{sec:NL1}) nonlinear solver, \\citet{Liu2019}\nalso made an attempt to run {\\code ST6} with the {\\code GMD} parameterization of $S_{nl}$\n(section~\\ref{sec:NL3}). As a first step, only the {\\code GMD} configuration with\n5 quadruplets and a three-parameter quadruplet definition\n\\citep[i.e., {\\code G35} in][]{tol:OMOD13d} was adopted. The tunable parameters\nof the {\\code GMD} which were specifically optimized for {\\code ST6} by using the holistic\ngenetic optimization technique designed by \\citet{tol:OMOD13e}, and the\ncorresponding tunable parameters of {\\code ST6} are summarized in\nTable~\\ref{tab:ST602}\\footnote{For the fifth quadruplet layout of {\\code GMD} shown\nin Table~\\ref{tab:ST602}, the three-parameter $(\\lambda,\\ \\mu,\\ \\theta_{12})$\nquadruplet definition degrades to a two-parameter $(\\lambda,\\ \\mu)$ form, and\n$\\theta_{12}$ is implied by the value of $\\mu$ \\citep{tol:OMOD13d}. Accordingly,\na combination of {\\code ST6+GMD} and the conservative nonlinear high-frequency\nfilter of \\citet{tol:OMOD11} [see also section~\\ref{sec:NLS}] might be\nnecessary to stabilize the model integration, particularly for high-resolution\nspectral grid (say, $\\Delta \\theta < 5^{\\circ}$).},\\footnote{Unlike\nTable~\\ref{tab:ST601}, here we only show important parameters of {\\code ST6} and\n{\\code GMD}. The reader is refered to {\\code bin/README.UoM} for the detailed\nset up of namelist variables for this specific model configuration.}.\n\\citet{Liu2019} demonstrated that in the duration-limited test, the\n{\\code GMD}-simulated $E(f)$ is in excellent agreement with that from the exact\n solutions of $S_{nl}$(e.g., {\\code WRT}; section~\\ref{sec:NL2}) \\citep[see also][]{tol:OMOD13d}]. In a 1-yr global\nhindcast, the {\\code DIA}-based model overestimates the low-frequency wave energy\n(wave period $T > 16$ s) by 90\\%. Such model errors are reduced significantly\nby the {\\code GMD} to $\\sim$20\\%. It is noteworthy that the computational expense\nof the {\\code GMD} approach presented in Table~\\ref{tab:ST602}, however, is about\n5 times larger than that of the {\\code DIA}.\n\nTo flexibly control the high-frequency extent of the prognostic frequency\nregion, we introduced\n\\begin{equation}\nf_{hf} = N_{hf}/T_{m0, -1}\n\\end{equation}\nin vers.\\,\\WWver, where $f_{hf}$ is the cut-off high-frequency limit\n(\\ref{eq:tail_E_f}), $T_{m0,-1}$ is the mean wave period defined in\n(\\ref{eq:Tm0m1}). $N_{hf}$ is set through a namelist parameter SINFC\n(Table~\\ref{tab:ST601}), and a negative $N_{hf}$ (say, $N_{hf} = -1$)\nmeans \\emph{the high-frequency spectral tail evolves freely without any\nprescribed slope.}\n\n\\noindent\n\\paragraph{Dominant Wave Breaking Probability}\nFollowing \\citet[][their Fig.~12]{art:BBY01}, the dominant wave breaking probability $b_T$ can be estimated from the wave spectrum $F(f, \\theta)$ according to the following parametric form\n\\begin{equation}\nb_T = 85.1 \\Big[ (\\epsilon_p - 0.055) (1 + H_s / d) \\Big]^{2.33},\n\\label{eq:bt}\n\\end{equation}\nwhere $H_s$ is the significant wave height, $d$ is the water depth, $\\epsilon_p$ is the significant steepness of the spectral peak, given by\n\\begin{equation}\n%\\left \\lbrace\n\\begin{array}{rcl}\n\\epsilon_p &=& H_p k_p / 2\\\\\nH_p &=& 4 \\Big[\\int_{0}^{2\\pi} \\int_{0.7f_p}^{1.3f_p} F(f, \\theta) \\mathrm{d}f \\mathrm{d}\\theta \\Big]^{1/2}\n\\label{eq:steepness}\n\\end{array}\n%\\right.\n\\end{equation}\nwhere $k_p$ and $f_p$ are the peak wavenumber and frequency, respectively. Note that only the contribution from wind seas is considered when we calculate $H_s$, $H_p$ and $f_p$ ($k_p$) from $F(f, \\theta)$ (Eqs. \\ref{eq:bt} and \\ref{eq:steepness}). Following \\citet{Janssen1989} and \\citet{Bidlot2001}, we consider spectral components as wind seas when\n\\begin{equation}\n\\frac{c(k)}{U_{10} \\cos (\\theta - \\theta_u)}  < \\beta_w,\n\\label{eq:beta}\n\\end{equation}\nwhere $c(k)$ is the phase velocity, $U_{10}$ is the wind speed at 10 m above the sea surface, $\\theta_u$ is the wind direction and $\\beta_w$ is the constant wind forcing parameter. We implemented $\\beta_w$ as a tunable parameter (the {\\F MISC} namelist parameter {\\code BTBET}), and used $\\beta_w=1.2$ by default.\n\n\\noindent\n\\paragraph{Bulk Adjustments.} The source term\n{\\code ST6} has been calibrated with flux parameterization {\\code FLX4}.\nBulk adjustment to the wind filed can be achieved by re-scaling the drag\nparameterization {\\code FLX4} through the {\\F FLX4} namelist parameter {\\code\n CDFAC=1.0E-4}\\footnote{This was changed to {\\code CDFAC=1.0} since vers.\\,\\WWver\\ as the magnitude $10^{-4}$ was hard-coded\nin {\\code FLX4} module. (Table~\\ref{tab:ST601})}. This has a similar effect to tuning variable\n$\\beta_{max}$ in {\\code ST4} source term package, equations\n(\\ref{eq:SinWAM4}) and (\\ref{eq:tauhfint}), which is customizable\nthrough namelist parameter {\\code BETAMAX} (see section\n\\ref{sec:ST3}--\\ref{sec:ST4}). \\citet{pro:Aea11} and \\citet{art:RA13}\nlisted different sets of values that allow us to adjust to different\nwind fields. When optimizing the wave model, it is recommended to\nonly re-tune parameters $a_0$, $b_1$ and $\\mathrm{FAC}$. Again, $\\mathrm{FAC}$\ncan potentially eliminate a bias in the wind field, which typically changes\nwith the selection of the reanalysis product. This reduction was tested\nfor extreme wind conditions such as hurricanes \\citep{art:ZBRY15}.  In\na global hindcast, the coefficient for the negative input can be used to tune\nthe bulk of the wave heights in scatter comparisons, whereas the scaling\ncoefficient for swell dissipation primarily affects large sea states.\nWhen the discrete interaction approximation ({\\code DIA}) is used to compute the four-wave\ninteraction, the default value for the proportionality constant changes to\n$C=3.00\\times10^7$.\n\n\\textrm{\\textit{\\underline{Limitations of the code:}}} For vers. 4.18 and\nvers. 5.16, in cases where the minimum time step for the dynamical source term\nintegration is much smaller than the overall time step (i.e. less than\n1/15th), the model becomes unstable. The issue has been solved since vers.\\,\\WWver.\n", "meta": {"hexsha": "161c988524b0655d7013959eb22a21842ab3a8bd", "size": 23954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/eqs/ST6.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/eqs/ST6.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/eqs/ST6.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 54.6894977169, "max_line_length": 351, "alphanum_fraction": 0.6965851215, "num_tokens": 7478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4309397256395574}}
{"text": "%add\n\\section{Hydraulic structures}\n\\label{sec-structures}\nThe term {\\em hydraulic structures} refers to control structures such as tidally-operated gates, \nbarriers, weirs and culverts as well as to coupled boundary conditions \nrepresenting direct transfers of water from an outflow to an inflow boundary due to mechanisms like low head pumps. \nThere are numerous gates and control structures in the San Francisco Bay-Delta. Here we describe the way structures are modeled and the formulas used to calculate flow through them. \n\nHydraulic structures are represented in SCHISM as paired boundary condition (Figure \\ref{fig:structmesh}). Flow is calculated based on head differences at two {\\em reference nodes}, one on the nominal upstream and downstream sides of the structure (but not necessarily adjoining the structure). Once the flow is calculated, it is disaggregated as a homogenous flux boundary condition over the breadth of the structure. The boundaries are enforced using a relaxation formulation, which provides some natural ramping of flow when gates that are suddenly opened or closed. Transport is coupled between the side that is an outflow and the side that is an inflow.\n\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=1]{image/struct}\n\t\\caption{Hydraulic structure definition imposed on horizontal grid.}\n\t\\label{fig:structmesh}\n\\end{figure}\n\nA number of pre-defined flow structures are already in place covering all the cases we encountered in the Bay-Delta; with a little programming the system can easily be expanded to accommodate new structures.  \nThe structures we have already implemented are listed below. All of the structures admit control of key (indicated) parameters using time series. \n\nStructures can also be removed in SCHISM by adding \nan appropriate entry in a time series. When a structure is removed, the region between the paired boundaries reverts to the ordinary equations of motion -- ie, it is if the structure did not exist.\n\n\\subsection{Flow transfers}\n\\label{sec-transfer}\nA flow transfer is a simple coupled boundary condition wherein a fixed flow $Q_s$ is stipulated. This flow\nis imposed as an outflow boundary on one the paired boundaries and and inflow on the other. Constituent mass \nis conserved.\n\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=1]{image/weir}\n\t\\caption{Free flowing (a) and submerged (b) weir flow cases.}\n\t\\label{fig:weir}\n\\end{figure}\n\n\\subsection{Weirs}\nA weir may be dry, submerged or free flowing (see Figure \\ref{fig:weir}) depending on the position of the upstream\nand downstream water surfaces $z_{u}$, $z_{d}$ compared to the weir invert elevation $z_{inv}$. Note that in the formulas\nbelow, \n\nFor the free flowing case:\n$$\nQ_s^f=\\sgn{(z_{u} - z_{d})} C_{op} C_{f} A \\sqrt{2g H}\n$$\nwhere \n\\begin{align*}\n&Q_s^f  &\\text{free flow flow through structure (cms)} &\\\\\n&\\sgn        &\\text{sign function (to induce up/downstream directionality)}  &\\\\\n&z_u         &\\text{upstream reference elevation  (m)}  &\\\\\n&z_d         &\\text{downstream reference elevation (m)}  &\\\\\n&z_{inv}     &\\text{invert elevation of the weir (m)}  &\\\\\n&H = \\max(z_u,z_d) - z_{inv}  &\\text{is the energy head above the weir} &\\\\\n&A                            &\\text{area of flow (m\\textsuperscript{2}) }&\\\\\n&C_op               &\\text{(directionally varying) operating coefficient (unitless)} &\\\\\n&C_f                &\\text{flow/gate coefficient (unitless)}  &\\\\\n&g                  & \\text{gravity (m/s\\textsuperscript{2})} & \\\\\n\\end{align*}\nFor commentary on coefficients, see \\cite{Rantz82}. Note that in the formulation above, the $\\sqrt{2g}$\nterm has been kept separate and the area calculation uses water surface height. \nFurthermore, note that $z_u$ and $z_d$ are pre-assigned upstream and downstream orientations,\nwhereas $H$ is the energy head in the direction that is upstream of the weir in terms of actual flow.\n\nThe submerged case is derived from the free flowing case using the correction given by \\citet{Villemonte47}:\n\\begin{align*}\nQ_s^s = Q_s^f(1 - S^{1.5})^{0.385} \\\\\nS = \\frac{\\min(z_u,z_d) - z_{inv}}{\\max(z_u,z_d) - z_{inv}}\n\\end{align*}\nin terms of the {\\em submergence ratio} $S$.\n\nIf both sides are dry, of course $Q_s=0$ for the structure. Note that this refers to being dry with respect to the invert elevation.\nThe nodes may not go dry in the ordinary sense with respect to the bed -- this is the same restriction as at other SCHISM boundaries. \n\n\\subsection{Radial gates} \n\\label{sec:radial}\nA radial gate is parametrized as shown in Figure \\ref{fig:radial}, although at the moment we have ignored the kinetic \nenergy component of upstream head (so that $H_1 = y_1$). For the case where the radial gate is completely out\nof the water or the tailwater elevation is not sufficiently high to affect the upstream (submergence ratio described in the previous\nsection is less than $S_p=0.66$),\nthe gate reverts to a modified weir equation described momentarily. For the case where the radial gate is completely submerged \n(submergence ratio greater than $S_f=0.80$),\nthe gate is treated as an orifice as given in Section \\ref{sec-orifice}.\n\n            %diff = max_elev - min_elev\n            %coef_matching_factor = sqrt(1.d0/(1.d0-PART_SUBMERGE))\n            %flow = signed_coef*area*sqrt2g*sqrt(diff)\n            %! now weigh the two so that the flow makes a linear transition\n            %subfrac = (submerge_ratio-PART_SUBMERGE)/(FULL_SUBMERGE - PART_SUBMERGE)\n            %flow = ((1.d0 - subfrac)*coef_matching_factor + subfrac)*flow\nFor free flow:\n$$\nQ_s^f = \\sgn{(z_{u} - z_{d})} C_{op} C_{f} A \\sqrt{2g H}\n$$\nand for partially submerged flow ($S_p < S \\le S_f$):\n$$\nQ_s^p = \\sgn{(z_{u} - z_{d})} C_{op} C_{f} A \\sqrt{2g \\left|\\D z\\right|}[(1-\\hat{S})m+\\hat{S}]\n$$\nwhere\n\\begin{align*}\n&\\hat{S}=\\frac{S-S_p}{S_f-S_p} & \\text{is the submergence fraction} \\\\\n&m = \\sqrt{\\frac{1}{1-S_p}} & \\text{is a coefficient matching factor to create a smooth transition}. \\\\\n\\end{align*}\n\nFor fully submerged flow $S>S_f$, the orifice equation is used. This is equivalent to the submerged equation with\n$\\hat{S}=1$.\n\n\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=1]{image/radial_gate}\n\t\\caption{Radial gate.}\n\t\\label{fig:radial}\n\\end{figure}\n\n\\subsection{Radial gates with linear coefficient} \nThis is an alternative radial gate formula modified from a suggestion by Tony Wahl of the USBR (personal communication) \nthat was incorporated because it matches Clifton Court well. \nThe rating formula is a little simpler, but the flow coefficient is a linear function of gate height:\n\n$$\nQ_s = \\sgn{(z_{u} - z_{d})} C_{op} C_{f} A \\sqrt{2g \\left|\\D z\\right|}\n$$\nwhere\n$$C_f = d + sR$$\nis the gate coefficient linearly dependent on the ratio of gate opening to upstream head:\n$$R = \\min(\\frac{H_{gate}}{H_1},1.0)$$\nwith constant and linear parameters $d$ and $s$ respectively.\nSome special cases surround the term $A$, given that the top of the radial gate\nmay be dry or submerged.\n\n\\subsection{Orifice}\n\\label{sec-orifice}\nThe orifice option is used to model a sluice gate or flashboard or other devices that  \npresents a (rectangular) apertures to flow. Flow in this case is given by:\n\n$$\nQ_{s} = \\sgn{(z_{u} - z_{d})} C_{op} C_{f} A \\sqrt{2g \\left|\\D z \\right|}\n$$\n\nSome special cases surround the term $A$, given that the orifice may be dry, partially submerged or completely\nsubmerged. Typically, the orifice equation is most useful when flow is fully submerged.\n\n\\subsection{Culverts}\nA culvert is currently modeled as a circular orifice. In other words, it is the same as the orifice case\nbut with a different formula for $A$. This treatment neglects some of the nuances of head and tailwater control \nas described by \\cite{Bodhaine68}\n", "meta": {"hexsha": "abc80e15c8e848a0e39220663c646bf5c994e3b3", "size": 7722, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/structs.tex", "max_stars_repo_name": "water-e/BayDeltaSCHISM", "max_stars_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-15T20:59:16.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-15T20:59:16.000Z", "max_issues_repo_path": "documents/structs.tex", "max_issues_repo_name": "water-e/BayDeltaSCHISM", "max_issues_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2018-06-05T16:01:48.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-20T18:52:48.000Z", "max_forks_repo_path": "documents/structs.tex", "max_forks_repo_name": "water-e/BayDeltaSCHISM", "max_forks_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-06-04T16:45:56.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-29T23:01:47.000Z", "avg_line_length": 52.5306122449, "max_line_length": 658, "alphanum_fraction": 0.7337477337, "num_tokens": 2096, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.43090946546869086}}
{"text": "\\section{Empirical analysis}\r\n    \\begin{frame}{Empirical analysis}\r\nIn previous sections, the series were shown in levels and individually. The variables in their logarithmic transformations are shown below:\\par\r\nAs observed in the previous series, their seasonality is highlighted and with the help of dichotomous variables, the impact of this problem is reduced. The seasonally adjusted  \r\nseries are shown below:\\par\r\nIn these series, the Unit Root test was applied using the Dickey-Fuller method, in which the hypotheses are as follows:\\par\r\n\\begin{center}\r\n\\textbf{H0} = Has unit root.\r\n\\textbf{HA} = The series is stationary.\r\n\\end{center}\r\nIn the first place, the test was applied to Remittances, the results obtained \\textbf{(-1.446)} refer to the fact that the test adding the trend is not rejected H0 \\textbf{(-4.051 at 1 percent, -3.455 at 5 percent and -3.153 at 10 percent)} and the form of change in levels \\textbf{(-1.826)} is not rejected H0 \\textbf{(-2.367 at 1 percent, -1.661 at 5 percent and -1.291 at 10 percent)}. \\par\r\nSecond, the test was applied to Mexico's GDP where the results \\textbf{(-3.656 in trend and -1,349 in change in levels)} do not reject H0 in its 1 percent trend form \\textbf{(-4.051 at 1 percent, -3.455 at 5 percent and -3.153 at 10 percent)} and its change in levels at 5 percent \\textbf{(-2.367 at 1percent, -1.661 at 5 percent and -1.291 at 10 percent)}.\\par\r\nThird, the test was applied to the United States GDP where the results \\textbf{(-2.914 in trend and -1.164 in change in levels)} do not reject H0 in its trending form \\textbf{(-4.051 at 1 percent, -3.455 at 5 percent and -3.153 at 10 percent)} and in its change in levels \\textbf{(-2.367 at 1 percent, -1.661 at 5 percent and -1.291 at 10 percent)}.\\par \r\nFinally, the test was performed at the Real Exchange Rate where the results \\textbf{(-3.492 in trend and -2.701 in change in levels)} do not reject H0 in its form with a trend of 1 percent \\textbf{(-4.051 at 1 percent, -3.455 at 5 percent and -3.153 at 10 percent)} and in its change in levels if it rejects H0 \\textbf{(-2.367 at 1 percent, -1.661 at 5 percent and -1.291 at 10 percent)}.\\par\r\nSince the series has structural changes, the Zivot and Andrews test is carried out considering the same hypotheses as the previous test. For Remittances in the first instance, the results for the form with change in the intercept and trend \\textbf{(-4.783)} are not rejected H0 \\textbf{(-5.57 at 1 percent, -5.08 at 5 percent and -4.82 at 10 percent)} and in the same way , in the way of minimizing lags \\textbf{(-3.208)}, H0 is not rejected \\textbf{(-5.34 at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent)}.\\par\r\nSecond, the test was performed on the Mexican GDP series where the results \\textbf{(-4.250)} show that the test does not reject H0 with the change in the intercept and trend \\textbf{(-5.57 at 1 percent, -5.08 at 5 percent and -4.82 at 10 percent)}, in the same way \\textbf{(-4.689)} H0 at 5 percent is not rejected in its way of minimizing lags \\textbf{(-5.34 at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent)}.\\par\r\nThird, the test was performed on the US GDP series where the results \\textbf{(-4.856)} show that the test does not reject H0 with the change in the intercept and trend to 5 percent \\textbf{(-5.57 to 1 percent, -5.08 at 5 percent and -4.82 at 10 percent)}, but if it rejects \\textbf{(-6.059)} H0 in its way of minimizing lags \\textbf{(-5.34 at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent)}.\\par\r\nFinally, the test was carried out on the Real Exchange Rate series where the results \\textbf{(-4.003)} show that the test does not reject H0 with the change in the intercept and trend \\textbf{(-5.57 at 1 percent, -5.08 at 5 percent and -4.82 at 10 percent)}, in the same way \\textbf{(-3.672)} H0 is not rejected in its way of minimizing lags \\textbf{(-5.34 at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent)}.\\par\r\nIn conclusion, it can be seen that the previous series in their seasonally adjusted form are non-stationary because they do not reject H0 in most cases. So we proceed to analyze the growth of each variable by differentiating them. The series in first differences are shown below:\\par\r\nSimilarly, in each of the series, the Unit Root test was applied using the Dickey-Fuller and Zivot and Andrews method, however, the trend is not taken into account since it is not observed in the previous graphs, the hypotheses are the following:\\par\r\n\\begin{center}\r\n\\textbf{H0} = Has unit root.\\par\r\n\\textbf{HA} = The series is stationary.\r\n\\end{center}\r\nIn the first place, the series of Remittances in first differences shows in the results \\textbf{(-11.851 in the DF test and -5.274 in the ZA test)} that reject H0 in both tests \\textbf{(-3.518 at 1 percent, -2.895 at 5 percent and - 2.582 at 10 percent in DF and -5.34 percent at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent in ZA)} affirming that said integrated series of order I is stationary.\\par\r\nSecondly, the series of the Gross Domestic Product of Mexico in first differences shows in the results \\textbf{(-23.585 in the DF test and -4.698 in the ZA test)} that rejects H0 in both tests \\textbf{(-3.518 at 1 percent, -2.895 at 5 percent and -2.582 at 10 percent in DF and -5.34 percent at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent in ZA)} affirming that said integrated series of order I is stationary.\\par\r\nThird, the series of the Gross Domestic Product of the United States in first differences shows in the results \\textbf{(-5.997 in the DF test and -6,914 in the ZA test)} that reject H0 in both tests \\textbf{(-3.518 at 1 percent, -2.895 at 5 percent and -2.582 at 10 percent in DF and -5.34 percent at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent in ZA)} affirming that said integrated series of order I is stationary.\\par\r\nFinally, the series of the Real Exchange Rate in first differences shows in the results \\textbf{(-8.578 in the DF test and -9.5 in the ZA test)} that reject H0 in both tests \\textbf{(-3.518 at 1 percent, -2.895 at 5 percent and -2.582 at 10 percent in DF and -5.34 percent at 1 percent, -4.80 at 5 percent and -4.58 at 10 percent in ZA)} affirming that said integrated series of order I is stationary.\\par\r\nIn conclusion, in all integrated series of order I H0 is rejected and, therefore, they are stationary; so, a cointegration analysis will be carried out. In the first place, the optimal lags will be determined using a VAR model; in turn, the dichotomous variables that were mentioned in previous sections as exogenous variables are added.\\par\r\nThe results show that according to the Bayesian Information Criterion the order one \\textbf{(-16.5164)} is determined, the Hannan-Quinn Criterion stipulates an order of four \\textbf{(-17.9533)} and the Akaike Information Criterion determines the order twelve \\textbf{(-19.4033)}; so we proceed to work with both equations.\\par\r\nFor the first equation with one lag, the number of cointegration equations is calculated using the \\textit{“Johansen method”} (Morán, Bucybaruta, Rivera, 2013). According to the Information Criteria \\textbf{(-17.11302 in SBIC and -17.41945 in HQIC)} it can be noted that there are three cointegration equations that will help us to create the Error Correction Model (VEC) by adding the lags of the equation that we are elaborating.\\par\r\nIn the second equation with four lags, the cointegration equations were calculated where the Information Criteria \\textbf{(-17.0929 in SBIC and -18.19574 in HQIC)} indicate that there are three cointegration equations that will help us to develop the Error Correction Model.\\par\r\nIn the last equation with twelve lags, the cointegration equations were calculated where the Information Criteria \\textbf{(-16.74103 in HQIC)} indicate that there are three cointegration equations that will help us to develop the Error Correction Model.\r\nAfter analyzing the previous results, we proceed to develop the impulse response analysis which will help us to know the growth in the short and long term according to the dependent variable and the independent variables. \\par\r\nAccording to the results obtained, the impact of remittances on the economy that receives them is interesting, however, the behavior of the variables of the country that issued the remittances is strengthened or weakened depending on the currency of said country, the results they will be explained in the next section.\\par\r\n\\end{frame}", "meta": {"hexsha": "dabb4c4bb5dfd90ce534173ffcef11591414ef8b", "size": 8455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "EMPIRICAL ANALYSIS.tex", "max_stars_repo_name": "luisevillarrealgtz/remittances-R", "max_stars_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "EMPIRICAL ANALYSIS.tex", "max_issues_repo_name": "luisevillarrealgtz/remittances-R", "max_issues_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EMPIRICAL ANALYSIS.tex", "max_forks_repo_name": "luisevillarrealgtz/remittances-R", "max_forks_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 234.8611111111, "max_line_length": 521, "alphanum_fraction": 0.7584861029, "num_tokens": 2335, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.43090946546869086}}
{"text": "\r\n\r\n\\subsection{Downscale energy cascade of waves}\r\n\\label{subsection_cascade}\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=8cm]{../Figs/fig_spect_energy_budg_c=100_N=3840}}\r\n\\caption{Spectral energy fluxes averaged over a long simulation for $c\r\n= 100$ and $n = 3840$.  The fluxes are nondimensionalized by $\\eps$\r\nand plotted versus $k/k_f$.  }\r\n\\label{fig_seb}\r\n\\end{figure}\r\n\r\n\r\nThe spectral energy fluxes of total energy, KE and APE are plotted in\r\nfigure~\\ref{fig_seb} as functions of $k/k_f$.\r\n%\r\nThe fluxes are approximately zero at the wave numbers smaller than the\r\nforced wave numbers.  They increase sharply at the forced wave numbers\r\nto values close to $\\eps$ for the total energy flux and to $0.5\\eps$\r\nfor the KE and APE fluxes.  The fluxes then decrease to zero over the\r\ndissipation range.\r\n%\r\nThe energy is transferred from the forced wave numbers to the\r\ndissipation wave numbers with a constant flux equal to the mean\r\nforcing and dissipation rates.\r\n%\r\nThere is an inertial range where the flux is constant and\r\nequipartitioned between equal KE and APE fluxes.\r\n%\r\nHowever, at wave numbers $k \\simeq 2 k_f$, the flux is not exactly\r\nequal to $\\eps$.  This is very likely related to the energy injection\r\nat wave numbers for which the force is zero, which is due to the\r\nnon-quadraticity of the kinetic energy (see appendix~\\ref{app_comp}).\r\n%\r\nNevertheless this effect is non-negligible only for wave number of the\r\norder of $k\\simeq 2 k_f$, i.e.\\ at the first harmonics of the forced\r\nwave numbers, such that there is a clear and wide inertial range\r\nbetween $k\\gtrsim 3 k_f$ to the dissipation range starting at wave\r\nnumber of the order of $k \\sim 70 k_f$.\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\\includegraphics[width=8cm]{../Figs/fig_Kolmo_c=20_N=3840}}\r\n\\caption{\r\nThird order structure functions involved in the exact Kolmogorov law (\\ref{eq_Kolmo}) \r\naveraged over a long simulation for $c = 20$ and $n = 3840$.\r\n%\r\nThe structure functions are normalized by $4 \\eps r$.\r\n%\r\nBlack thick line, $\\mean{ \\delta J_L|\\delta \\uu|^2 } \r\n+ c^2\\mean{\\delta u_L(\\delta h)^2}$;\r\nlight thin line, $c^2\\mean{\\delta u_L (\\delta h)^2}$;\r\ndark thin line, $\\mean{\\delta J_L |\\delta \\uu|^2}$.\r\n%\r\nThe dotted straight line shows $4 \\eps_q r$, \r\nwhere $\\eps_q$ is the quadratic energy dissipation rate.\r\n}\r\n\\label{fig_Kolmo}\r\n\\end{figure}\r\n\r\n\r\nFigure~\\ref{fig_Kolmo} shows the quantity $\\mean{\\delta J_L|\\delta\r\n\\uu|^2 } + c^2\\mean{\\delta u_L(\\delta h)^2 }$ (black thick line)\r\nnormalized by $4 \\eps r$ for $c = 20$ and $n = 1920$.\r\n%\r\nIn this section, the brackets $\\mean{}$ denote the average over space\r\nand time.\r\n%\r\nThe dotted straight line shows the quantity $4 \\eps_q r$, where\r\n$\\eps_q$ is the quadratic energy dissipation rate (see\r\nappendix~\\ref{app_comp}) which takes place at small scales.\r\n%\r\nWe see that the Kolmogorov law (\\ref{eq_Kolmo}) is well satisfied\r\nbetween \\Add{$r \\simeq 0.02L_f$ and $r \\simeq 0.1 L_f$}.  The dark and\r\nlight thin continuous lines correspond to the quantities $\\mean{\\delta\r\nJ_L|\\delta \\uu|^2 }$ and $c^2\\mean{\\delta u_L(\\delta h)^2}$,\r\nrespectively.\r\n%\r\nThese two quantities are nearly equal over the inertial and\r\ndissipation ranges, which is consistent with a wave cascade when\r\n$f=0$.\r\n%\r\nThe agreement with the Kolmogorov law and the equality between\r\n$\\mean{\\delta J_L|\\delta \\uu|^2 }$ and $c^2\\mean{\\delta u_L(\\delta\r\nh)^2}$ are the equivalents in the separation space of the plateau in\r\nthe total energy flux and the equality between $\\Pi_K$ and $\\Pi_A$,\r\nrespectively.\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=8cm]{../Figs/fig_spatiotempspectra_c=20_Nh=3840}}\r\n\\caption{Spatio-temporal spectra of KE (dark lines) and APE (light\r\nlines) for $c = 20$ and $n = 3840$ versus $\\omega/\\omega_l$, where\r\n$\\omega_l = c k$.  From the larger to the smaller spectra, $k/\\delta k\r\n= 12$, 27, 62, 143, 327, and 746.  }\r\n\\label{fig_spatiotemp_spectra}\r\n\\end{figure}\r\n\r\nFigure~\\ref{fig_spatiotemp_spectra} presents the spatio-temporal\r\nspectra plotted as a function of the normalized frequency\r\n$\\omega/\\omega_l$.\r\n%\\PA{Explain how these spectra have been calculated.}  \r\nIn order to calculate these spectra, we have saved well-resolved time\r\nseries of $\\hat d(\\kk)$ and $\\hat a(\\kk)$ for wave numbers inside\r\nparticular shells such as $k\\leqslant \\kk<k+\\delta k$, computed the\r\ntemporal spectrum of each signal and averaged over the wave numbers\r\ninside each shell.\r\n%\r\nThe spectra are strongly dominated by large peaks at $\\omega =\r\n\\omega_l$ indicating that the characteristic frequency for each wave\r\nnumber is the linear frequency.  However, the widening of the peaks\r\ncan be explained only by nonlinear effects.  \\Add{The equipartition\r\nbetween kinetic and potential energies is expected since the flow only\r\nconsists of gravity waves and the total energy is nearly equal to the\r\nquadratic energy which is equal to the sum over all waves of their\r\nequipartitioned quadratic energy.}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\subsection{Time- and space-averaged energy as a function of $c$}\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_Emean_c}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_Emean_resol}\r\n}\r\n\\caption{Time- and space-averaged energy \r\n$\\langle h|\\uu|^2 + c^2 h^2 \\rangle/2$ \r\nof the statistically stationary flows.\r\n%\r\nIn (\\textit{a}), the energy is divided by \r\n$\\sqrt{\\eps}$ and plotted versus $c$ for 3 resolutions:\r\n$n = 960$, dotted lines; \r\n$n = 1920$, continuous lines and \r\n$n = 3840$, dashed lines. \r\nThe cyan curves show the law $C_n \\sqrt{\\eps L_f c}$, \r\nwith $C_n$ a fit coefficient.\r\n%\r\nIn (\\textit{b}), the energy is divided by \r\n$\\sqrt{\\eps L_f c}$ and plotted versus $n$\r\nfor six values of $c$ as indicated in the legend.\r\n}\r\n\\label{fig_Evsc}\r\n\\end{figure}\r\n\r\n\r\nFigure~\\ref{fig_Evsc}(\\textit{a}) shows the time- and space-averaged\r\nenergy for the statistically stationary flows divided by the square\r\nroot of the mean energy dissipation rate as a function of $c$ and for\r\nthree resolutions: $n = 960$, dotted lines; $n = 1920$, continuous\r\nlines and $n = 3840$, dashed lines.\r\n%\r\nFor all resolutions, the energy increases with $c$.  More precisely,\r\nthe curves can be well fitted to a law $E = C_n \\sqrt{\\eps L_f c}$\r\n(blue lines).  However, the coefficient $C_n$ varies with the\r\nresolution, i.e.\\ with the effective Reynolds number.\r\n%\r\nThis is very different from the case of isotropic turbulence where the\r\nenergy scales as $E \\sim (\\eps L_f)^{2/3}$ and does not vary with the\r\nReynolds number in the limit of very large Reynolds number.\r\n%\r\nWeak wave turbulence theory predicts an energy-flux law of the form $E\r\n\\propto \\eps^{1/(N-1)}$, where $N$ is the number of waves involved\r\nin the nonlinear interactions \\cite[]{Nazarenko2011}.  Therefore, the\r\nscaling $E = C_n \\sqrt{\\eps L_f c}$ would correspond to interactions\r\ninvolving three waves.\r\n%\r\nHowever, the hypothesis needed for applying the weak wave turbulence\r\nformulation are not fulfilled.\r\n\r\n\r\nThis effect of the increase of the energy with the resolution is\r\ninvestigated in figure~\\ref{fig_Evsc}(\\textit{b}) where the quantity\r\n$C_n = E/\\sqrt{\\eps L_f c}$ is plotted as a function of the\r\nresolution.\r\n%\r\nFor $c = 10$ (dotted line), the waves are not very fast and the\r\nvariation with the resolution is weak.\r\n%\r\nHowever, in the limit of very fast waves ($c>100$), the curves for the\r\ndifferent wave speeds nearly collapse and increase at least up to $n =\r\n5760$.  The increase tends to saturate but it is difficult to know\r\nfrom our results what is the scaling of $C_n$ as a function of the\r\nresolution and if it really saturates for very large $n$ and $c$.\r\n%\r\nIn order to decide on this issue, we would need to run simulations in\r\nthe very-fast-wave regime, $c>100$, and at very large resolutions $n >\r\n5760$.  In this regime the energy fluctuations are large so\r\nthat the simulations would have to be carried out for very long time\r\nin order to get a good convergence for the mean energy.  Since the\r\ntime step has to be extremely small in this regime, such simulations\r\nwould be too costly.\r\n\r\n\r\n\r\n\r\n\r\n\\subsection{Energy spectra}\r\n\r\n\r\nWe now turn to the study of the energy spectra.  A dimensional\r\nanalysis based on the assumption that the spectra only depend on\r\n$\\eps$, $c$ and $k_f$ gives the following general expression\r\n\\begin{equation}\r\nE_{\\alpha, \\beta}(k) = k^{-\\alpha} \\eps^\\beta   c^{2- 3\\beta} \r\n{k_f}^{\\alpha -1 - \\beta}, \\label{eq_E_alpha_beta}\r\n\\end{equation}\r\nwhere $\\alpha$ and $\\beta$ are two free parameters.\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_c_Nx=1920_k32}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_c_Nx=3840_k32}\r\n}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_c_Nx=1920_k2}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_c_Nx=3840_k2}\r\n}\r\n\\caption{\r\nCompensated energy spectra versus $k/k_f$ for different wave speeds $c$.\r\n%\r\nThe spectra are compensated by $k^{-3/2}\\sqrt{\\varepsilon c} $ \r\nin (\\textit{a,b})\r\nand by $k^{-2}c^{1/3} \\eps^{5/9} k_f^{4/9} $ \r\nin (\\textit{c,d}).\r\n%\r\nThe resolution is \r\n$n = 1920$ in (\\textit{a,c}) and \r\n$n = 3840$ in (\\textit{b,d}).\r\n%\r\nIn (\\textit{a,c}), the wave speed goes from 10 to 1000\r\nand \r\nin (\\textit{b,d}) from 10 to 200 \r\n(for the precise values, see figure~\\ref{fig_Evstime}).\r\n}\r\n\\label{fig_spectra_c}\r\n\\end{figure}\r\n\r\n\r\nThe scaling of the energy as $\\sqrt{\\eps L_f c}$ suggests that the\r\nspectra should scale like the Zakharov-Sagdeev spectrum, $E(k) \\sim\r\nk^{-3/2}\\sqrt{\\eps c}$, which is the prediction of weak wave\r\nturbulence theory for three-dimensional acoustic turbulence\r\n\\cite[]{Nazarenko2011}.\r\n%\r\nThe compensated spectra $E(k) / ( k^{-3/2}\\sqrt{\\eps c})$ are plotted\r\nin figure~\\ref{fig_spectra_c}(\\textit{a}) for $n = 1920$ and in\r\nfigure~\\ref{fig_spectra_c}(\\textit{b}) for $n = 3840$.  The different\r\ncurves correspond to different wave speeds, going from $c=10$ to\r\n$c=1000$ for $n = 1920$ and from $c=10$ to $c=200$ for $n = 3840$.\r\n%\r\nFor both resolutions, the compensated spectra collapse at the\r\nenergy-dominating small wave numbers.\r\n%\r\nHowever, these compensated spectra are not flat in the inertial range\r\nand do not collapse in the inertial and dissipation ranges, i.e. for\r\n$k\\gtrsim 2k_f$.  In the inertial range, they follow a clear $k^{-2}$\r\nscaling law and there is a bottleneck in the dissipation range where\r\nthe slope is close to $-3/2$.\r\n%\r\n\\cite{Kuznetsov2004} showed that $k^{-2}$ spectra can be explained by\r\nsingularities and this scaling has already been observed in\r\ntwo-dimensional acoustic turbulence \\cite[]{FalkovichMeyer1996}.\r\n%\r\n\r\nInserting $\\alpha = 2$ in the spectrum (\\ref{eq_E_alpha_beta}) gives\r\n\\begin{equation}\r\nE_\\beta(k) = k^{-2} {k_f}^{1-\\beta} c^{2-3\\beta} \\eps^\\beta  \r\n\\end{equation}\r\nand we have found that the numerical spectra are very close to the\r\nspectrum $E_\\beta(k)$ with $\\beta = 5/9$.\r\n%\r\nThe compensated spectra $E(k) / ( k^{-2} c^{1/3} \\eps^{5/9} k_f^{4/9}\r\n)$ are plotted in figure~\\ref{fig_spectra_c}(\\textit{c}) for $n =\r\n1920$ and in figure~\\ref{fig_spectra_c}(\\textit{d}) for $n = 3840$.\r\nThe collapse is very good in the inertial range but we stress that we\r\nare not aware of any theory predicting the empirical spectrum $k^{-2}\r\nc^{1/3} \\eps^{5/9} k_f^{4/9}$.\r\n\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\\includegraphics[width=8cm]{../Figs/fig_spectra_c=40_nh=7680}}\r\n\\caption{Compensated spectra\r\nof total energy (thick black line)\r\nkinetic energy (thin dark line) and\r\navailable potential energy (thin light line)\r\nfor $c = 40$ and $n = 7680$.}\r\n\\label{fig_spectra_c40}\r\n\\end{figure}\r\n\r\nFigure~\\ref{fig_spectra_c40} shows the compensated spectra $E(k) / (\r\nk^{-2} c^{1/3} \\eps^{5/9} k_f^{4/9} )$ of total energy (black line),\r\nKE (red line) and APE (blue line) for $c = 40$ and $n = 7680$.  For\r\nall wave numbers, we have $E(k) = 2E_K(k) = 2E_A(k)$ since the flow\r\nonly consists of \\Add{gravity} waves.\r\n%\r\nThe spectra are very close to $k^{-2}$ in the inertial range over more\r\nthan one decade and the shallowing to a slope close to $-3/2$ is\r\nclearly confined to the dissipation range.  This confirms that this\r\nbump is due to a dissipation effect and that there is no wide\r\n$k^{-3/2}$ spectrum even at very large resolutions.\r\n\r\n\r\n% \\begin{figure}\r\n% \\centerline{\r\n% \\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_resol_c=10}\r\n% \\includegraphics[width=\\halfwidth]{../Figs/fig_spectra_resol_c=40}\r\n% }\r\n% \\caption{Compensated energy spectra $E(k) / ( k^{-3/2}\\sqrt{\\eps c})$\r\n% for different resolutions.  In (\\textit{a}), $c = 10$ and in\r\n% (\\textit{a}), $c = 40$.}\r\n% \\label{fig_spectra_resol}\r\n% \\end{figure}\r\n\r\n% The compensated spectra $E(k) / ( k^{-3/2}\\sqrt{\\eps c})$ are plotted\r\n% for different resolutions %\r\n% in figure~\\ref{fig_spectra_resol}(\\textit{a}) for $c=10$ and \r\n% in figure~\\ref{fig_spectra_resol}(\\textit{b}) for $c=40$.\r\n% %\r\n% We see that an inertial range with a $k^{-2}$ scaling starts to appear\r\n% for $n\\gtrsim 960$.\r\n% %\r\n% As seen in figure~\\ref{fig_Evsc}, the ratio $E/\\sqrt{\\eps L_f c}$ only\r\n% weakly varies for $c=10$ but increases in the fast-waves regime for\r\n% $c=40$.  This effect can be seen here at the energy-containing wave\r\n% numbers $k<2 k_f$.  However, the variation with the resolution is much\r\n% weaker in the inertial range at $k>2 k_f$.\r\n\r\n\r\n\r\n\r\nIn subsection~\\ref{subsection_cascade}, we have shown that third-order\r\nstructure functions scale like $r$ since there is a downscale energy\r\ncascade.\r\n%\r\nThe Kolmogorov method predicts $k^{-5/3}$-spectra but the numerical\r\nspectra are much steeper in the inertial range, with a slope equal to\r\n-2.  The fact that third-order and second-order quantities can not be\r\nsimply related by the Kolmogorov scaling implies that the cascade is\r\nvery intermittent.\r\n\r\n\r\n\r\n\r\n\\subsection{Effect of the shocks and intermittency}\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\setlength{\\halfwidth}{69mm}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_2Dh_c20}\r\n\\hspace{-4mm}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_2Dh_c200}\r\n}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_2Duy_c20}\r\n\\hspace{-4mm}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_2Duy_c200}\r\n}\r\n\\caption{\r\nSnapshots for $n = 1920$ and two values of the wave speed \r\n$c= 20$ (\\textit{a,c}) and $c= 200$ (\\textit{b,d}).\r\nThe colors represent the thickness in (\\textit{a,b}) and\r\nthe $y$-component of the velocity in (\\textit{c,d}).\r\nThe arrows represent the velocity field.\r\n%\r\nThe coordinates are nondimensionalized by the characteristic scale of\r\nthe forcing $L_f = 3.57$.  }\r\n\\label{fig_phys}\r\n\\end{figure}\r\n\r\nFigure~\\ref{fig_phys} shows %\r\nthe normalized thickness $h$ %\r\n(figures~\\ref{fig_phys}\\textit{a,b}) %\r\nand the $y$-component of the velocity $u_y$ %\r\n(figures~\\ref{fig_phys}\\textit{c,d}) %\r\nfor $c = 20$ (figures~\\ref{fig_phys}\\textit{a,c}) and %\r\n$c = 200$ (figures~\\ref{fig_phys}\\textit{b,d}).\r\n%\r\nThese wave speeds correspond %\r\nto a moderate forcing Froude number $F_f \\sim 0.05$ and %\r\nto a very small forcing Froude number $F_f \\sim 0.005$, respectively.\r\nThe normalized surface displacement $\\eta = h - 1$ is of order 0.3 for\r\n$c = 20$ and one order of magnitude smaller, 0.03, for $c = 200$.\r\n%\r\nThe typical velocity is also much smaller than the wave speed, %\r\nwith $u_y/c \\sim 0.2$ for $c = 20$ %\r\nand $u_y/c \\sim 0.03$ for $c = 200$. %\r\nThis confirms that the flows are in a fast-wave regime, especially for\r\n$c = 200$.\r\n%\r\nHowever, many discontinuities can be seen in both fields $h$ and\r\n$u_y$.  These discontinuities are hydraulic jumps, which are the\r\nequivalent to shocks in a compressible flows.\r\n%\r\n\\Add{Baines (1998) provides a theoretical prediction for the velocity\r\nof the hydraulic jumps is one-layer shallow-water flow:\r\n\\begin{equation}\r\nc_s = c \\sqrt{\\frac{h_+}{h_-} \\frac{h_+ + h_-}{2}},\r\n\\end{equation}\r\nwhere $h_+$ and $h_-$ are the dimensionless thickness before and after\r\nthe jump.\r\n%\r\nWe have verified that the velocity of the discontinuities in the\r\nsimulations is consistent with this theoretical prediction, implying\r\nthat the associated Froude number (or Mach number) is of the order\r\nunity.}\r\n\r\n\\nocite{Baines1998}\r\n\r\n% We have verified that these shocks are very fast and travel at a\r\n% velocity of the order of the wave speed \\Add{(more precisely, Baines 1998)}\r\n% , implying\r\n% that their associated Froude number (or Mach number) is of the order\r\n% unity.\r\n%el (This is not necessarily true...)\r\n% The existence of shocks implies that there is a strong coherence\r\n% between small and large wave numbers and indicates nonlocal\r\n% interactions between wave numbers.\r\n%\r\nIn between the shocks, the flow is very smooth for $c=20$ and slightly\r\nmore irregular for $c = 200$.\r\n\r\nFigures~\\ref{fig_phys}(\\textit{c,d}) display the $y$-component of the\r\nvelocity.  There are less discontinuities in this quantity than in the\r\nthickness. More precisely, the $h$-discontinuity lines that are along\r\nthe $y$-axis are not associated with corresponding discontinuities of\r\nthe $y$-component of the velocity. This can be seen for example for\r\nthe shock at $x/L_f\\simeq 0.4$ and $y/L_f\\simeq 2.1$ in\r\nfigures~\\ref{fig_phys}(\\textit{a}) and \\ref{fig_phys}(\\textit{c}).\r\n%\r\nThis illustrates that the singularity in the velocity is in the\r\ncomponent perpendicular to the shock line, which is the assumption on\r\nthe structure of the velocity discontinuities used in the model\r\npresented in \\S~\\ref{subsection_shock_model}.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_interm_strfct_ux}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_interm_strfct_uy}\r\n}\r\n\\caption{\r\nCompensated fifth-order structure functions $\\mean{|\\delta u_L|^5}/r$ \r\nof (\\textit{a}) the longitudinal increments and (\\textit{b}) the\r\ntransverse increments. %\r\nThe crosses indicate the range of separation $r$ where the exponent\r\n$\\zeta_p$ is computed. %\r\nThe dashed lines correspond to the Kolmogorov scaling laws $r^{p/3}$\r\nand $\\zeta_p = p/3$.  The wave speed and the resolution are $c = 40$\r\nand $n = 7680$.  }\r\n\\label{fig_strfct5}\r\n\\end{figure}\r\n\r\n\r\nThe shock model derived in subsection~\\ref{subsection_shock_model}\r\npredicts that structure functions of all orders should scale linearly\r\nwith $r$.\r\n%\r\nFigure~\\ref{fig_strfct5} presents fifth-order structure functions\r\ncompensated by $r$.\r\n%\r\nFigures~\\ref{fig_strfct5}(\\textit{a}) and\r\n\\ref{fig_strfct5}(\\textit{b}) correspond to the structure functions\r\ncomputed from the longitudinal increments and the transverse\r\nincrements, respectively.  The structure functions compensated by $r$\r\nare nearly flat between $r \\simeq 0.012 L_f$ and $r \\simeq 0.06 L_f$,\r\nshowing that they scale like $r$ on this relatively narrow range of\r\nscale compared to the inertial range.\r\n%\r\nThe $r$-scaling is very different from the slope of the fifth-order\r\nstructure functions calculated from the Kolmogorov scaling $\\zeta_5 =\r\np/3 \\simeq 1.66$ (dashed straight line).  This shows that the wave\r\ncascade is strongly intermittent and that this intermittency can be\r\nexplained by the presence of discontinuities related to the shocks.\r\n\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_interm_ux}\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_interm_uy}\r\n}\r\n\\caption{\r\nExponents $\\zeta_p$ of the structure functions \r\nof (\\textit{a}) the longitudinal increments \r\nand (\\textit{b}) the transverse increments versus the order $p$.\r\n%\r\nThe dashed lines correspond to \r\nthe Kolmogorov scaling laws $r^{p/3}$ and $\\zeta_p = p/3$.\r\nThe wave speed and the resolution are $c = 40$ and $n = 7680$.\r\n}\r\n\\label{fig_interm}\r\n\\end{figure}\r\n\r\n\r\n\r\n\r\n\r\n\r\nThe slope of the structure functions of order $p$ over the range\r\n$0.012 L_f\\leqslant r \\leqslant 0.06 L_f$, $\\zeta_p$, are plotted in\r\nfigure~\\ref{fig_interm}(\\textit{a}) for the longitudinal increments\r\nand in figure~\\ref{fig_interm}(\\textit{b}) for the transverse\r\nincrements.\r\n%\r\nThe exponent are very far from the Kolmogorov scaling $\\zeta_p = p/3$.\r\nThey increase as $p$ for $p\\ll1$, saturate to a value close to 1 for\r\n$p>2$ and tend to decrease for $p>3$.\r\n%\r\nA similar shape of the $\\zeta_p$ function has been predicted for\r\nBurger turbulence \\cite[]{BouchaudMezardParisi1995}.\r\n%\r\nThe shape of $\\zeta_p$ at very small $p$ is determined by the\r\nscaling of the smallest velocity increments and the $p^1$-variation\r\nshows that these smallest increments scales like $\\delta u \\sim r^p$.\r\n%\r\nThe plateau at $p > 2$ is a consequence of the dominance by shocks of\r\nthe largest increments.\r\n%\r\nNote that these results are obtained for a relatively small forcing\r\nFroude number $F_f \\simeq 0.03$ corresponding to $c=40$.  The function\r\n$\\zeta_p$ has approximately the same extreme shape for a larger Froude\r\nnumber $F_f \\simeq 0.01$, corresponding to $c=10$.  Note also that the\r\ndecrease of $\\zeta_p$ for $p>3$ is anomalous, which could be due to\r\nthe relatively narrow width of the range over which $\\zeta_p$ is\r\ncomputed.\r\n\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_ratio_strfct}\r\n}\r\n\\caption{\r\nRatio of the structure functions of the velocity increments \r\n$R_p(r) \\equiv \\mean{|\\delta u_L|^p} / \\mean{|\\delta u_T|^p}$\r\nfor $p = 2,$ 3 and 4.\r\nThe dotted straight lines indicate the values computed by the shock model:\r\n$R_2 = 2$, $R_3 = 6\\pi/8$ and $R_4 = 8/3$.\r\n%\r\nThe wave speed and the resolution are $c = 10$ and $n = 7680$.  }\r\n\\label{fig_ratio}\r\n\\end{figure}\r\n\r\n\r\nThe functions $R_p = \\mean{|\\delta u_L|^p}/\\mean{|\\delta u_T|^p}$ are\r\nplotted in figure~\\ref{fig_ratio} for $p =2$ to 4.  The predictions of\r\nthe shock model, $R_2 = 2$, $R_3 = 6\\pi/8$ and $R_4 = 8/3$, are also\r\nplotted in dotted lines for comparison.  We see that the numerical\r\nresults are reasonably close to these predictions.  However, the\r\nagreement is less good for smaller Froude number (not shown).  The\r\nstructure functions are fully determined by shocks only for Froude\r\nnumbers that are not too small, which is consistent with the snapshots\r\nin figure~\\ref{fig_phys} showing that the fields between the shocks\r\nare more irregular for the smallest Froude number.\r\n\r\n\r\n\\begin{figure}\r\n\\centerline{\r\n\\includegraphics[width=\\halfwidth]{../Figs/fig_flatness}\r\n}\r\n\\caption{ Flatness of the longitudinal and transverse increments for\r\n$c = 10$ and $n = 7680$. The straight continuous lines indicate the\r\n$r^{-1}$-scaling and the straight dashed line the $r^{-3/2}$-scaling.\r\nThe inset shows the ratio $F_T/F_L$ and the corresponding value\r\ncomputed by the shock model, $F_T/F_L = 1.5$.  }\r\n\\label{fig_flatness}\r\n\\end{figure}\r\n%\r\nFigure~\\ref{fig_flatness} shows the flatness of the longitudinal and\r\ntransverse increments, computed from a numerical simulation for $c =\r\n10$ and $n = 7680$.\r\n%\r\nFor a Gaussian probability distribution the flatness factor is equal\r\nto 3 whereas the shock model predict flatness factors scaling like\r\n$r^{-1}$.\r\n%\r\nWe see that here the flatness factors are much larger than 3, of the\r\norder of $10^3$.\r\n%\r\nRemarkably, they scale approximately as $r^{-1}$ as predicted by the\r\nshock model and the ratio $F_T/F_L$ is very close to the predicted\r\nvalue 1.5.\r\n\r\n\r\n\r\n% Figure~\\ref{fig_flatness}(\\textit{b}) shows the same quantities\r\n% computed from atmospheric data measured by commercial aircraft.\r\n% %\r\n% The flatness curves have been taken from \\cite{Lindborg1999}.\r\n% Surprisingly, the atmospheric results are quite similar to the\r\n% numerical ones. The flatness factors are very large and strongly\r\n% decrease at scales smaller than 100 km.  Interestingly, the ratio\r\n% $F_T/F_L$ is also very close to the value 1.5 predicted by the shock\r\n% model.\r\n% %\r\n% We stress that even though these similarities are striking, the\r\n% underlying dynamics are very different.\r\n% %\r\n% While there is no energy in the quasi-geostrophic modes in the\r\n% numerical simulations, the atmospheric flows are usually close to be\r\n% quasi-geostrophic at horizontal scales larger than 500 km and the\r\n% vertical vorticity is in average of the same order of magnitude than\r\n% the horizontal divergence at the mesoscales, i.e. at horizontal scales\r\n% between 10 and 500 km \\cite[]{Lindborg2007jas}.\r\n% %\r\n% Therefore, it is not surprising to also see differences between the\r\n% atmospheric and the numerical results. The flatness factors in\r\n% figure~\\ref{fig_flatness}(\\textit{b}) vary approximately as $r^{-3/2}$\r\n% (dashed line), which is significantly faster than for the numerical\r\n% simulations of the shallow-water model. Moreover, the second-order\r\n% structure functions in the atmosphere scale as $r^{2/3}$\r\n% \\cite[]{Lindborg1999, ChoLindborg2001,\r\n% FrehlichSharman2010}. Considering the scaling for the flatness\r\n% factors, this implies that the variation with scale of the\r\n% fourth-order structure functions is actually very weak, which is\r\n% not in agreement with the prediction of the shock model.\r\n% %\r\n% Nevertheless, we do not know other explanations of such very large\r\n% flatness factors with a ratio $F_T/F_L=1.5$ observed in the atmosphere.\r\n% %\r\n% Thus, we think that these results raise interesting questions\r\n% regarding the interpretation of structure functions measured in the\r\n% atmosphere.  How important are the discontinuities on horizontal\r\n% cross-sections in these cases?\r\n% %\r\n% It is well known that the fronts separating cold and warm regions \r\n% explain many meteorological phenomena.\r\n% %\r\n% The curves in figure~\\ref{fig_flatness} seem to indicate that \r\n% they could also have strong effects on the statistics of the atmosphere\r\n% over a quite large range of scales.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "3f278b113290740204c54778a8014adb0f03a709", "size": 25652, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Old/section_wave_cascade_f=0.tex", "max_stars_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_stars_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-23T11:06:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-23T11:06:53.000Z", "max_issues_repo_path": "Old/section_wave_cascade_f=0.tex", "max_issues_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_issues_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-08-23T13:00:31.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-23T13:00:31.000Z", "max_forks_repo_path": "Old/section_wave_cascade_f=0.tex", "max_forks_repo_name": "ashwinvis/augieretal_jfm_2019_shallow_water", "max_forks_repo_head_hexsha": "88d97c2bd5df0795ca636306c1d795ef1d3a8949", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.059347181, "max_line_length": 87, "alphanum_fraction": 0.7223608296, "num_tokens": 7400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4309094527118699}}
{"text": "\\section{Overview}\n\n%%%%%%%%%%%%%%%\n\\begin{frame}{Contents of Tutorials}\n  Overview:\n  \\begin{enumerate}\n    \\item Graph Decomposition {\\scriptsize (vs. Graph Traversal)}\n    \\item MST \\& Path $\\Rightarrow$ Greedy Algorithm\n    \\item DP: Dynamic Programming\n  \\end{enumerate}\n\\end{frame}\n%%%%%%%%%%%%%%%\n\\begin{frame}{Graph Decomposition}\n  Graph decomposition vs. Graph traversal\n  \\begin{itemize}\n    \\item objects: integer vs. graph\n    \\item graph traversal as basis\n    \\item structure matters\n      \\begin{itemize}\n\t\\item states of vertices\n\t  \\begin{itemize}\n\t    \\item undiscovered $\\to$ discovered $\\to$ finished\n\t    \\item white $\\to$ gray $\\to$ black\n\t  \\end{itemize}\n\t\\item types of edges\n\t  \\begin{itemize}\n\t    \\item tree edge, back edge, forward edge, cross edge\n\t  \\end{itemize}\n\t\\item DFS: lifetime of vertices\n\t  \\begin{itemize}\n\t    \\item $v: \\text{d}[v], \\text{f}[v]$\n\t    \\item $\\text{f}[v]$: DAG, SCC\n\t    \\item $\\text{d}[v]$: biconnectivity\n\t  \\end{itemize}\n      \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "a99fa7cdafcd7a684c401b04dab6e54c9d191860", "size": 1045, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg-ta-by-years/alg-ta-2016/algorithm-tutorial-graph-decomposition-2016-05-19/sections/overview.tex", "max_stars_repo_name": "hengxin/algorithm-ta-tutorial", "max_stars_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2017-03-29T08:22:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-02T15:12:15.000Z", "max_issues_repo_path": "alg-ta-by-years/alg-ta-2016/algorithm-tutorial-graph-decomposition-2016-05-19/sections/overview.tex", "max_issues_repo_name": "courses-at-nju-by-hfwei/algorithm-ta-tutorial", "max_issues_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg-ta-by-years/alg-ta-2016/algorithm-tutorial-graph-decomposition-2016-05-19/sections/overview.tex", "max_forks_repo_name": "courses-at-nju-by-hfwei/algorithm-ta-tutorial", "max_forks_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-10-10T08:47:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-18T07:58:43.000Z", "avg_line_length": 26.7948717949, "max_line_length": 65, "alphanum_fraction": 0.633492823, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863695, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.43090945271186987}}
{"text": "% !TEX root = ../../main.tex\n% !TEX spellcheck = en_GB\n\n\\section{Analysis}\nIn contrast to the pure sine, the C-major consists of several frequencies, as shown in \\cref{fig:fftc4}.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.7\\linewidth]{gfx/fft_C4.png}\n\t\\caption{Frequency spectrum of C$_4$ played on a piano \\cite{fft_c4}.}\n\t\\label{fig:fftc4}\n\\end{figure}\n\nThese frequencies are evenly spaced, and the solutions presented in \\cref{sec:simpleanal} are still valid to use.\nHere the solution of changing the sampling frequency is still not valid due to limitations on the Blackfin, and the primary target of the analysis is if it is possible to use the same approach as in the pure sine implementation: Creating a new tone at the target frequency.\n\nThe approach again focuses on the steps\n\\begin{enumerate}\n\t\\item Find the input tone.\n\t\\item Create new tone at target frequency.\n\t\\item Play output tone.\n\\end{enumerate}\n\n\\paragraph{Finding the input tone}\nIn the sine part, the frequency was found using Instantaneous Frequency.\nThis approach may still be valid, but would require the ratio between the fundamental and every harmonic frequency to be exactly the same each time.\nShould the ratios for the fundamental and the first to harmonics be e.g. 3, 2 and 1, the output of the Instantaneous Frequency would be as shown in \\cref{tab:CmajorIF}.\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{l c}\n\t\t\\toprule\n\t\tNote & IF \\\\\n\t\t\\midrule\n\t\tC$_4$ & \\num{436.043} \\\\\n\t\tD$_4$ & \\num{489.442} \\\\\n\t\tE$_4$ & \\num{549.380} \\\\\n\t\tF$_4$ & \\num{582.047} \\\\\n\t\tG$_4$ & \\num{653.325} \\\\\n\t\tA$_4$ & \\num{733.333} \\\\\n\t\tB$_4$ & \\num{823.138} \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\caption{IF values if including the first two harmonic frequencies.}\n\t\\label{tab:CmajorIF}\n\\end{table}\n\nAnother approach could be to use FFT to determine the tallest peak, leading to a not very accurate measurement, approximately \\SI{\\pm50}{\\hertz}, bandpass filter this frequency bin, removing everything else, and the calculate the Instantaneous Frequency.\nThe found frequency can then be compared to a table of the C-major frequencies and their harmonics, allowing the tone to be determined.\nThen the new pitch shifted tone can be created with a number of harmonics.", "meta": {"hexsha": "fe04dcde397e51a1f7d2995f975308aff8e127a7", "size": 2229, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/Report/Cmajor/analysis.tex", "max_stars_repo_name": "lsangild/ETISB", "max_stars_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/Report/Cmajor/analysis.tex", "max_issues_repo_name": "lsangild/ETISB", "max_issues_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/Report/Cmajor/analysis.tex", "max_forks_repo_name": "lsangild/ETISB", "max_forks_repo_head_hexsha": "7ed401e1a9d7b34120f953d1afe5266d57f9e7a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.58, "max_line_length": 273, "alphanum_fraction": 0.7474203679, "num_tokens": 610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250376, "lm_q2_score": 0.6688802669716106, "lm_q1q2_score": 0.4309094520786218}}
{"text": "\\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size\n\n\\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs\n\\usepackage{fourier} % Use the Adobe Utopia font for the document - comment this line to return to the LaTeX default\n\\usepackage[english]{babel} % English language/hyphenation\n\\usepackage{amsmath,amsfonts,amsthm,amssymb} % Math packages\n\n\\usepackage{caption}\n\\usepackage{graphicx, subfig}\n\n\\usepackage{algorithm, algorithmic}\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}} %Use Input in the format of Algorithm  \n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}} %UseOutput in the format of Algorithm  \n\n\\usepackage{listings}\n\\lstset{language=Matlab}\n\n\\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template\n\n\\usepackage{sectsty} % Allows customizing section commands\n\\allsectionsfont{\\centering \\normalfont\\scshape} % Make all sections centered, the default font and small caps\n\n\\usepackage{fancyhdr} % Custom headers and footers\n\\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers\n\\fancyhead{} % No page header - if you want one, create it in the same way as the footers below\n\\fancyfoot[L]{} % Empty left footer\n\\fancyfoot[C]{} % Empty center footer\n\\fancyfoot[R]{\\thepage} % Page numbering for right footer\n\\renewcommand{\\headrulewidth}{0pt} % Remove header underlines\n\\renewcommand{\\footrulewidth}{0pt} % Remove footer underlines\n\\setlength{\\headheight}{13.6pt} % Customize the height of the header\n\n\\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\n\\setlength\\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text\n\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} % Create horizontal rule command with 1 argument of height\n\n\\title{\t\n\\normalfont \\normalsize \n\\textsc{Shanghai Jiao Tong University, UM-SJTU JOINT INSTITUTE} \\\\ [25pt] % Your university, school and/or department name(s)\n\\horrule{0.5pt} \\\\[0.4cm] % Thin top horizontal rule\n\\huge Turbulence \\\\ HW2 \\\\ % The assignment title\n\\horrule{2pt} \\\\[0.5cm] % Thick bottom horizontal rule\n}\n\n\\author{Yu Cang \\\\ 018370210001}\n\n\\date{\\normalsize \\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Exercise1}\n\tConsider the N-S equation\n\t\\begin{equation}\n\t\t\\frac{\\partial u_j}{\\partial t} + u_k \\frac{\\partial u_j}{\\partial x_k} = -\\frac{1}{\\rho}\\frac{\\partial p}{\\partial x_j} + \\nu \\frac{\\partial^2 u_j}{\\partial x_k \\partial x_k} + f_j\n\t\\end{equation}\n\t\n\tWith the ensemble average, each quantity can be decomposed into mean and fluctuation. Namely\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tu_j & = U_j + u_j'\\\\\n\t\t\tp & = P + p'\\\\\n\t\t\tf_j &= F_j + f_j'\n\t\t\\end{aligned}\n\t\\end{equation}\n\tThus, the N-S equation can be expanded as\n\t\\begin{equation}\n\t\t\\Bigg(\\frac{\\partial U_j}{\\partial t} + \\frac{\\partial u_j'}{\\partial t}\\Bigg) + \\Bigg(U_k\\frac{\\partial U_j}{\\partial x_k} + u_k'\\frac{\\partial U_j}{\\partial x_k} + U_k \\frac{\\partial u_j'}{\\partial x_k} + u_k'\\frac{\\partial u_j'}{\\partial x_k}\\Bigg) = -\\frac{1}{\\rho}\\Bigg(\\frac{\\partial P}{\\partial x_j} + \\frac{\\partial p'}{\\partial x_j}\\Bigg) + \\nu \\Bigg(\\frac{\\partial^2 U_j}{\\partial x_k \\partial x_k} + \\frac{\\partial^2 u_j'}{\\partial x_k \\partial x_k}\\Bigg) + (F_j + f_j')\n\t\\end{equation}\n\t\n\tTaking ensemble average on the equation above yiels the so called Reynolds equation\n\t\\begin{equation}\n\t\t\\frac{\\partial U_j}{\\partial t} + U_k \\frac{\\partial U_j}{\\partial x_k} + \\overline{u_k'\\frac{\\partial u_j'}{\\partial x_k}} = -\\frac{1}{\\rho}\\frac{\\partial P}{\\partial x_j} + \\nu \\frac{\\partial^2 U_j}{\\partial x_k \\partial x_k} + F_j\n\t\\end{equation}\n\t\n\tSubstract the Reynolds equation by N-S equation that has been expaneded yields\n\t\\begin{equation}\n\t\t\\frac{\\partial u_j'}{\\partial t} + u_k'\\frac{\\partial U_j}{\\partial x_k} + U_k \\frac{\\partial u_j'}{\\partial x_k} + u_k'\\frac{\\partial u_j'}{\\partial x_k} - \\overline{u_k'\\frac{\\partial u_i'}{\\partial x_k}} = -\\frac{1}{\\rho}\\frac{\\partial p'}{\\partial x_j} + \\nu \\frac{\\partial^2 u_j'}{\\partial x_k \\partial x_k} + f_j'\n\t\\end{equation}\n\t\n\tWith the continuity equation for incompressible flow\n\t\\begin{equation}\n\t\t\\frac{\\partial u_k'}{\\partial x_k} = 0 \n\t\\end{equation}\n\tthe substracted equation can be re-written as\n\t\\begin{equation}\n\t\tN_j\\{\\vec{x}, t\\} \\triangleq \\frac{\\partial u_j'}{\\partial t} + u_k' \\frac{\\partial \\overline{u_j}}{x_k} + \\overline{u_k}\\frac{\\partial u_j'}{\\partial x_k} + \\frac{\\partial [u_j' u_k']}{\\partial x_k} - \\frac{\\partial \\overline{u_j' u_k'}}{\\partial x_k} + \\frac{1}{\\rho} \\frac{\\partial p'}{\\partial x_j}-\\nu \\frac{\\partial^2 u_j'}{\\partial x_k \\partial x_k} - f_j' = 0\n\t\t\\label{eq:sns}\n\t\\end{equation}\n\n\tAlso, an identity is frequently used within the exercise\n\t\\begin{equation}\n\t\t\\frac{d u(t+s)}{dt} = \\frac{d u(t+s)}{d(t+s)} = \\frac{d u(t+s)}{ds} \n\t\\end{equation}\n\t\n\tSince the two-point correlation function is defined as\n\t\\begin{equation}\n\t\tR_{ij} = \\overline{u_i'(\\vec{x}, t) u_j'(\\vec{x}+\\vec{r}, t + \\tau)}\n\t\\end{equation}\n\n\tThus, for $D^{(i)}\\{R_{ij}\\} = \\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) N_i\\{\\vec{x}, t\\}}$, components in the expansion are calculated as\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial t}}  \n\t\t\t& = \\overline{\\frac{\\partial (u_i'(\\vec{x}, t)u_j'(\\vec{x} + \\vec{r}, t+\\tau))}{\\partial t} - u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial t}}\\\\\n\t\t\t& = \\frac{\\partial \\overline{u_i'(\\vec{x}, t)u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial t} - \\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial \\tau}}\\\\\n\t\t\t& = \\frac{\\partial R_{ij}}{\\partial t} - \\frac{\\partial \\overline{u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial \\tau}\\\\\n\t\t\t& = \\frac{\\partial R_{ij}}{\\partial t} - \\frac{\\partial R_{ij}}{\\partial \\tau}\n\t\t\\end{aligned}\n\t\\end{equation} \n\t\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\overline{u_k}\\frac{\\partial u_i'}{\\partial x_k}} \n\t\t\t& = \\overline{u_k(\\vec{x}, t)} \\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}}\\\\\n\t\t\t& = \\overline{u_k(\\vec{x}, t)} \\Bigg[\\frac{\\partial \\overline{u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_k}- \\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial (x_k + r_k)}}\\Bigg]\\\\\n\t\t\t& = \\overline{u_k(\\vec{x}, t)} \\Bigg[\\frac{\\partial R_{ij}}{\\partial x_k}- \\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial r_k}}\\Bigg]\\\\\n\t\t\t& = \\overline{u_k(\\vec{x}, t)} \\Bigg[\\frac{\\partial R_{ij}}{\\partial x_k}- \\frac{\\partial \\overline{u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial r_k}\\Bigg]\\\\\n\t\t\t& = \\overline{u_k(\\vec{x}, t)} \\Bigg[\\frac{\\partial R_{ij}}{\\partial x_k}- \\frac{\\partial R_{ij}}{\\partial r_k}\\Bigg]\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\t\\begin{equation}\n\t\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) u_k'(\\vec{x}, t) \\frac{\\partial \\overline{u_i(\\vec{x}, t)}}{\\partial x_k}} = \\overline{u_k'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)} \\frac{\\partial \\overline{u_i(\\vec{x}, t)}}{\\partial x_k} = R_{kj}\\frac{\\partial \\overline{u_i(\\vec{x}, t)}}{\\partial x_k}\n\t\\end{equation}\n\t\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\frac{\\partial [u_i'(\\vec{x}, t)u_k'(\\vec{x}, t)]}{\\partial x_k}} \n\t\t\t& = \\overline{\\frac{\\partial [u_i'(\\vec{x}, t)u_k'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)]}{\\partial x_k}} - \\overline{u_i'(\\vec{x}, t)u_k'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial x_k}}\\\\\n\t\t\t& = \\frac{\\partial R_{(ik)j}}{\\partial x_k} - \\overline{u_i'(\\vec{x}, t)u_k'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial r_k}}\\\\\n\t\t\t& = \\frac{\\partial R_{(ik)j}}{\\partial x_k} - \\overline{\\frac{\\partial [u_i'(\\vec{x}, t)u_k'(\\vec{x}, t)u_j'(\\vec{x} + \\vec{r}, t+\\tau)]}{\\partial r_k}}\\\\\n\t\t\t& = \\frac{\\partial R_{(ik)j}}{\\partial x_k} - \\frac{\\partial R_{(ik)j}}{\\partial r_k}\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\t\\begin{equation}\n\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\frac{\\partial \\overline{u_i'(\\vec{x}, t)u_k'(\\vec{x}, t)}}{\\partial x_k}} = \\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau)} \\frac{\\partial \\overline{u_i'(\\vec{x}, t)u_k'(\\vec{x}, t)}}{\\partial x_k} = 0\n\t\\end{equation}\n\t\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) \\frac{\\partial p'(\\vec{x}, t)}{\\partial x_i}} \n\t\t\t& = \\overline{\\frac{\\partial p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial x_i}} - \\overline{p'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial x_i}}\\\\\n\t\t\t& = \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\overline{p'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial (x_i + r_i)}}\\\\\n\t\t\t& = \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\overline{p'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial r_i}}\\\\\n\t\t\t& = \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\overline{\\frac{\\partial p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}{\\partial r_i}}\\\\\n\t\t\t& = \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial r_i}\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t& \\overline{u_j'(\\vec{x} + \\vec{r}, t + \\tau) \\frac{\\partial^2 u_i'(\\vec{x}, t)}{\\partial x_k \\partial x_k}} \n\t\t\t= \\overline{u_j'(\\vec{x} + \\vec{r}, t + \\tau) \\frac{\\partial}{\\partial x_k}\\Bigg(\\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}\\Bigg)}\\\\\n\t\t\t = & \\overline{\\frac{\\partial}{\\partial x_k} \\Bigg(u_j'(\\vec{x} + \\vec{r}, t + \\tau) \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}\\Bigg)} - \\overline{\\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial x_k} \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}}\\\\\n\t\t= \t& \\overline{\\frac{\\partial}{\\partial x_k} \\Bigg(\\frac{\\partial [u_j'(\\vec{x} + \\vec{r}, t + \\tau) u_i'(\\vec{x}, t)]}{\\partial x_k} - u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial x_k}\\Bigg)} - \\overline{\\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial x_k} \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}}\\\\\n\t\t\t = &\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - \\overline{\\frac{\\partial}{\\partial x_k} \\Bigg(u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k}\\Bigg)} - \\overline{\\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial x_k} \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}}\\\\\n\t\t\t =& \\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - \\overline{\\frac{\\partial}{\\partial x_k} \\frac{\\partial [u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k}} - \\overline{\\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k} \\frac{\\partial u_i'(\\vec{x}, t)}{\\partial x_k}}\\\\\n\t\t =\t& \\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - \\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} - \\overline{\\Bigg(\\frac{\\partial}{\\partial x_k}\\Bigg(u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k} \\Bigg) - u_i'(\\vec{x}, t) \\frac{\\partial^2 u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial x_k \\partial r_k}\\Bigg)}\\\\\n\t\t = \t&\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - \\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} - \\overline{\\Bigg(\\frac{\\partial}{\\partial x_k}\\Bigg(\\frac{\\partial [u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k} \\Bigg) - u_i'(\\vec{x}, t) \\frac{\\partial^2 u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k \\partial r_k}\\Bigg)}\\\\\n\t\t\t = &\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - 2\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} + \\overline{\\frac{\\partial^2 [u_i'(\\vec{x}, t)u_j'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k \\partial r_k}}\\\\\n\t\t\t =& \\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - 2\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} + \\frac{\\partial^2 R_{ij}}{\\partial r_k \\partial r_k}\\\\\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\tthen, detailed expression for  $D^{(i)}\\{R_{ij}\\}$ is given as\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tD^{(i)}\\{R_{ij}\\} = \\frac{\\partial R_{ij}}{\\partial t} - \\frac{\\partial R_{ij}}{\\partial \\tau} + \\overline{u_k(\\vec{x}, t)} \\Bigg[\\frac{\\partial R_{ij}}{\\partial x_k}- \\frac{\\partial R_{ij}}{\\partial r_k}\\Bigg] + R_{kj}\\frac{\\partial \\overline{u_i(\\vec{x}, t)}}{\\partial x_k} \\\\ + \\frac{\\partial R_{(ik)j}}{\\partial x_k} - \\frac{\\partial R_{(ik)j}}{\\partial r_k} + \\frac{1}{\\rho} \\Bigg(\\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial r_i}\\Bigg) \\\\ - \\nu \\Bigg(\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - 2\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} + \\frac{\\partial^2 R_{ij}}{\\partial r_k \\partial r_k}\\Bigg) - \\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) f_i'(\\vec{x}, t)} = 0\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\t For $D^{(j)}\\{R_{ij}\\} = \\overline{u_i'(\\vec{x}, t) N_j\\{\\vec{x} + \\vec{r}, t + \\tau\\}}$, components in the expansion are calculated as\n\t \\begin{equation}\n\t \t\\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial (t + \\tau)}} = \\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial \\tau}} = \\overline{ \\frac{\\partial u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial \\tau}} = \\frac{\\partial R_{ij}}{\\partial \\tau}\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\begin{aligned}\n\t \t\t\\overline{u_i'(\\vec{x}, t) \\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)}\\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial (x_k + r_k)}} \n\t \t\t = \\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)} \\overline{u_i'(\\vec{x}, t) \\frac{\\partial u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k}}\\\\\n\t \t\t = \\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)} \\overline{\\frac{\\partial [u_i'(\\vec{x}, t)u_j'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k}} = \\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)} \\frac{\\partial R_{ij}}{\\partial r_k}\n\t \t\\end{aligned}\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\overline{u_i'(\\vec{x}, t)u_k'(\\vec{x} + \\vec{r}, t + \\tau)\\frac{\\partial \\overline{u_j(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial (x_k+r_k)}} = R_{ik} \\frac{\\partial \\overline{u_j(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial r_k}\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\begin{aligned}\n\t \t\t\\overline{u_i'(\\vec{x}, t) \\frac{\\partial [u_j'(\\vec{x} + \\vec{r}, t + \\tau)u_k'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial  (x_k+r_k)}} = \\overline{u_i'(\\vec{x}, t) \\frac{\\partial [u_j'(\\vec{x} + \\vec{r}, t + \\tau)u_k'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k}}\\\\\n\t \t\t= \\overline{\\frac{\\partial [u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t + \\tau)u_k'(\\vec{x} + \\vec{r}, t + \\tau)]}{\\partial r_k}} = \\frac{\\partial R_{i(jk)}}{\\partial r_k}\n\t \t\\end{aligned}\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\overline{u_i'(\\vec{x}, t) \\frac{\\partial \\overline{u_j'(\\vec{x} + \\vec{r}, t + \\tau)u_k'(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial (x_k+r_k)}} = \\overline{u_i'(\\vec{x}, t)} \\frac{\\partial \\overline{u_j'(\\vec{x} + \\vec{r}, t + \\tau)u_k'(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial r_k} = 0\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\overline{u_i'(\\vec{x}, t) \\frac{\\partial p'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial (x_j + r_j)}} = \\overline{u_i'(\\vec{x}, t) \\frac{\\partial p'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_j}} = \\overline{\\frac{\\partial p'(\\vec{x} + \\vec{r}, t + \\tau)u_i'(\\vec{x}, t)}{\\partial r_j}}\n\t \\end{equation}\n\t \n\t \\begin{equation}\n\t \t\\begin{aligned}\n\t \t\t\\overline{u_i'(\\vec{x}, t) \\frac{\\partial^2 u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial (x_k+r_k) \\partial (x_k+r_k)}}\n\t \t\t&= \\overline{u_i'(\\vec{x}, t) \\frac{\\partial^2 u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k \\partial r_k}} \\\\\n\t \t\t& = \\overline{ \\frac{\\partial^2 u_i'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t + \\tau)}{\\partial r_k \\partial r_k}} = \\frac{\\partial R_{ij}}{\\partial r_k \\partial r_k}\n\t \t\\end{aligned}\n\t \\end{equation}\n\t \n\t then, detailed expression for  $D^{(j)}\\{R_{ij}\\}$ is given as\n\t \\begin{equation}\n\t\t \\begin{aligned}\n\t\t \tD^{(j)}\\{R_{ij}\\} = \\frac{\\partial R_{ij}}{\\partial \\tau} + \\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)} \\frac{\\partial R_{ij}}{\\partial r_k} + R_{ik} \\frac{\\partial \\overline{u_j(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial r_k} + \\frac{\\partial R_{i(jk)}}{\\partial r_k} \\\\\n\t\t \t+ \\frac{1}{\\rho}\\frac{\\partial \\overline{p'(\\vec{x} + \\vec{r}, t + \\tau)u_i'(\\vec{x}, t)}}{\\partial r_j} - \\nu \\frac{\\partial R_{ij}}{\\partial r_k \\partial r_k} - \\overline{u_i'(\\vec{x}, t) f_j'(\\vec{x} + \\vec{r}, t + \\tau)} = 0\n\t\t \\end{aligned}\n\t \\end{equation}\n\t \n\t Therefore, the two-point correlation equation is calculated as\n\t \\begin{equation}\n\t \t\\begin{aligned}\n\t \t\tD^{(i)}\\{R_{ij}\\} + D^{(j)}\\{R_{ij}\\}\n\t \t\t= \\frac{\\partial R_{ij}}{\\partial t}\n\t \t\t+ \\overline{u_k(\\vec{x}, t)} \\frac{\\partial R_{ij}}{\\partial x_k}\n\t \t\t+ \\Big[\\overline{u_k(\\vec{x} + \\vec{r}, t + \\tau)} - \\overline{u_k(\\vec{x}, t)}\\Big]\\frac{\\partial R_{ij}}{\\partial r_k}\\\\\n\t \t\t+ R_{kj}\\frac{\\partial \\overline{u_i(\\vec{x}, t)}}{\\partial x_k} + R_{ik} \\frac{\\partial \\overline{u_j(\\vec{x} + \\vec{r}, t + \\tau)}}{\\partial r_k} \n\t \t\t + \\frac{\\partial R_{(ik)j}}{\\partial x_k} - \\frac{\\partial [R_{(ik)j}-R_{i(jk)}]}{\\partial r_k}\\\\\n\t \t\t + \\frac{1}{\\rho} \\Bigg(\\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial x_i} - \\frac{\\partial \\overline{p'(\\vec{x}, t) u_j'(\\vec{x} + \\vec{r}, t+\\tau)}}{\\partial r_i} + \\frac{\\partial \\overline{p'(\\vec{x} + \\vec{r}, t + \\tau)u_i'(\\vec{x}, t)}}{\\partial r_j}\\Bigg) \\\\ \n\t \t\t - \\nu \\Bigg(\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial x_k} - 2\\frac{\\partial^2 R_{ij}}{\\partial x_k \\partial r_k} + 2\\frac{\\partial^2 R_{ij}}{\\partial r_k \\partial r_k}\\Bigg) - \\overline{u_j'(\\vec{x} + \\vec{r}, t+\\tau) f_i'(\\vec{x}, t)}\n\t \t\t - \\overline{u_i'(\\vec{x}, t) f_j'(\\vec{x} + \\vec{r}, t + \\tau)} = 0\n\t \t\\end{aligned}\n\t \\end{equation}\n\t \n\\section{Exercise 2}\n\tRefer to (\\ref{eq:sns}), kinetic energy equation of each velocity component is given as\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tu_1'N_1 & = 0\\\\\n\t\t\tu_2'N_2 & = 0\\\\\n\t\t\tu_3'N_3 & = 0\\\\\n\t\t\\end{aligned}\n\t\t\\label{eq:kc}\n\t\\end{equation}\n\tIn the pure shear flow case, assumptions can be made as\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\frac{\\partial}{\\partial x_1} & = \\frac{\\partial}{\\partial x_3} = 0\\\\\n\t\t\tU_2 & = U_3 = 0\\\\\n\t\t\tU_1 & = f(x_2)\n\t\t\\end{aligned}\n\t\\end{equation}\n\tHence, (\\ref{eq:kc}) can be simplified as\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\frac{\\overline{D}}{\\overline{D} t}\\Big(\\frac{u_1'^2}{2}\\Big) & = -u_2' u_1'\\frac{\\partial U_1}{\\partial x_2} - u_1'\\frac{\\partial [u_1'u_2']}{\\partial x_2} + u_1'\\frac{\\partial \\overline{u_1' u_2'}}{\\partial x_2} + u_1'\\nu \\frac{\\partial^2 u_1'}{\\partial x_2 \\partial x_2}\\\\\n\t\t\t\\frac{\\overline{D}}{\\overline{D} t}\\Big(\\frac{u_2'^2}{2}\\Big) & = -u_2'\\frac{\\partial [u_2'u_2']}{\\partial x_2} + u_2'\\frac{\\partial \\overline{u_2' u_2'}}{\\partial x_2} - \\frac{u_2'}{\\rho}\\frac{\\partial p'}{\\partial x_2}+ u_2'\\nu \\frac{\\partial^2 u_2'}{\\partial x_2 \\partial x_2}\\\\\n\t\t\t\\frac{\\overline{D}}{\\overline{D} t}\\Big(\\frac{u_3'^2}{2}\\Big) & = -u_3'\\frac{\\partial [u_3'u_2']}{\\partial x_2} + u_3'\\frac{\\partial \\overline{u_3' u_2'}}{\\partial x_2} + u_3'\\nu \\frac{\\partial^2 u_3'}{\\partial x_2 \\partial x_2}\\\\\n\t\t\\end{aligned}\n\t\t\\label{eq:kt}\n\t\\end{equation}\n\twhere\n\t\\begin{equation}\n\t\t\\frac{\\overline{D}}{\\overline{D} t} = \\frac{\\partial}{\\partial t} + U_k \\frac{\\partial}{\\partial x_k}\n\t\\end{equation}\n\tand it should be noted that the $U_k \\frac{\\partial}{\\partial x_k}$ term vanishes in (\\ref{eq:kt}).\\\\\n\tEstimations on each term can be made respectively.\\\\\n\tFor the first equation in (\\ref{eq:kt})\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tu_2' u_1'\\frac{\\partial U_1}{\\partial x_2} & \\sim \\frac{u'^2 U}{L}\\\\\n\t\t\tu_1'\\frac{\\partial [u_1'u_2']}{\\partial x_2} & \\sim \\frac{u'^3}{L}\\\\\n\t\t\tu_1'\\frac{\\partial \\overline{u_1' u_2'}}{\\partial x_2} & \\sim u'\\nu \\frac{\\partial U_1}{\\partial x_2} \\sim \\nu \\frac{u' U}{L}\\\\\n\t\t\tu_1'\\nu \\frac{\\partial^2 u_1'}{\\partial x_2 \\partial x_2} & \\sim \\nu \\frac{u'^2}{L^2}\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\tFor the second equation in (\\ref{eq:kt})\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tu_2'\\frac{\\partial [u_2'u_2']}{\\partial x_2} & \\sim \\frac{u'^3}{L}\\\\\n\t\t\tu_2'\\frac{\\partial \\overline{u_2' u_2'}}{\\partial x_2} & \\sim \\frac{u'^3}{L}\\\\\n\t\t\t\\frac{u_2'}{\\rho}\\frac{\\partial p'}{\\partial x_2} & \\sim \\frac{u'}{\\rho} \\rho \\\\\n\t\t\tu_2'\\nu \\frac{\\partial^2 u_2'}{\\partial x_2 \\partial x_2} & \\sim \\nu \\frac{u'^2}{L^2}\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\tFor the third equation in (\\ref{eq:kt})\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\tu_3'\\frac{\\partial [u_3'u_2']}{\\partial x_2} & \\sim \\frac{u'^3}{L}\\\\\n\t\t\tu_3'\\frac{\\partial \\overline{u_3' u_2'}}{\\partial x_2} & \\sim \\frac{u'^3}{L}\\\\\n\t\t\tu_3'\\nu \\frac{\\partial^2 u_3'}{\\partial x_2 \\partial x_2} & \\sim \\nu \\frac{u'^2}{L^2}\n\t\t\\end{aligned}\n\t\\end{equation}\n\t\n\\end{document}", "meta": {"hexsha": "8cfc0b93bd1424ba37668c3dd6ab0c2f8612d2f1", "size": 21335, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "VM524/HW2/submission.tex", "max_stars_repo_name": "cangyu/lambdaflow", "max_stars_repo_head_hexsha": "407a952bdf98f6ca161291fe50c5c903c72efb28", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-22T14:24:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-22T14:24:06.000Z", "max_issues_repo_path": "VM524/HW2/submission.tex", "max_issues_repo_name": "cangyu/lambdaflow", "max_issues_repo_head_hexsha": "407a952bdf98f6ca161291fe50c5c903c72efb28", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "VM524/HW2/submission.tex", "max_forks_repo_name": "cangyu/lambdaflow", "max_forks_repo_head_hexsha": "407a952bdf98f6ca161291fe50c5c903c72efb28", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-10-27T08:35:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-27T08:35:24.000Z", "avg_line_length": 70.1809210526, "max_line_length": 820, "alphanum_fraction": 0.6115303492, "num_tokens": 8698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.4308918167796186}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 2.1 Inverse Hyperbolic Functions\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese subprograms compute the inverse hyperbolic functions.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype, Single Precision}\n\n\\begin{description}\n\\item[REAL]  \\ {\\bf X, U, SASINH, SACOSH, SATANH, SACTNH, SASECH, SACSCH}\n\\end{description}\n\nAssign a value to X and obtain the desired value of an inverse hyperbolic\nfunction using one of the following:\n\\begin{center}\n\\begin{tabular}{l@{\\hspace{.3in}}l}\n\\fbox{\\bf U = SASINH(X)} & \\fbox{\\bf U = SACOSH(X)}\\\\\\\\\n\\fbox{\\bf U = SATANH(X)} & \\fbox{\\bf U = SACSCH(X)}\\\\\\\\\n\\fbox{\\bf U = SASECH(X)} & \\fbox{\\bf U = SACTNH(X)}\n\\end{tabular}\n\\end{center}\nwhere the functions SASINH, ..., SACTNH compute respectively, the inverse\nhyperbolic: sine, cosine, tangent, cosecant, secant, and cotangent.\n\n\\subsubsection{Program Prototype, Double Precision}\n\nFor double precision computation use the function names DASINH, DACOSH,\nDATANH, DACSCH, DASECH, and DACTNH and type the argument, function name and\nresult double precision.\n\n\\subsection{Example and Remarks}\n\nSee DRSASINH and ODSASINH for an example of the usage of these subprograms.\n\n\\subsection{Functional Description}\n\n\\subsubsection{Method}\n\nThe basic formulas and valid argument domains are\n\\begin{equation*}\n\\hspace{-15pt}\\begin{array}{ll}\n\\asinh(x) = \\sgn (x) \\ln (|x| + \\sqrt {x^2+1})& \\text{all }x\\\\\n\\acosh(x) = \\ln (x + \\sqrt {x^2-1})& x \\geq 1\\\\\n\\atanh(x) = \\frac{1}{2} \\sgn (x) \\ln ((1+|x|)/(1-|x|))& |x| < 1\\\\\n\\acsch(x) = \\asinh(1/x)& x \\neq 0\\\\\n\\asech(x) = \\acosh(1/x)& 0 < x \\leq 1\\\\\n\\actnh(x) = \\atanh(1/x)& |x| > 1\n\\end{array}\n\\end{equation*}\nTo avoid unnecessary loss of relative accuracy as function values approach\nzero, a different method is used whenever the argument of the logarithm\nfunction would be in the range [1.0,~2.718]. In this range the argument for\nacosh or atanh is converted to an argument for asinh, and asinh is computed\nby argument reduction to the interval [0.0,~0.125326] followed by evaluation\nof its Taylor series. The number of terms needed in this series is\ndetermined by use of the System Parameters subprogram, Chapter~19.1. The\nprestored coefficients will support accuracy to about 25 significant decimal\ndigits.\n\nFor large arguments the formulas involving $x^2$ are reformulated to avoid\nunnecessary overflow. Specifically, when $x > 10^{16}$ it is presumed that $%\nx^2 \\pm 1$ will not be distinguishable from $x^2$, and thus the formulas\ngiven above for asinh and acosh are replaced by\n\\begin{align*}\n\\asinh(x) &= \\sgn (x) [\\ln (2) + \\ln (|x|)], \\quad \\text{and}\\\\\n\\acosh(x) &= \\ln (2) + \\ln (x)\n\\end{align*}\nLet $\\Omega $ denote the machine overflow limit and $\\rho $ denote\nthe difference between $1.0$ and the next smaller machine number. Define $a\n= \\frac{1}{2} \\ln (2/\\rho )$ and $b = \\ln (2\\Omega )$. Then the\nranges of the computed function values are\n\\begin{equation*}\n\\begin{array}{l@{\\qquad }l}\n|\\asinh(x)\\,| < b & 0 \\leq \\acosh(x) < b\\\\\n|\\atanh(x)\\,| \\leq a & 0 < |\\acsch(x)\\,| < b\\\\\n0 \\leq \\asech(x) < b & 0 < |\\actnh(x)\\,| \\leq a\n\\end{array}\n\\end{equation*}\n\\subsubsection{Accuracy Tests}\n\nThe single precision subprograms were tested on an IBM compatible PC\nby comparison with the double precision subprograms at 300,000 to\n800,000 points in the domain of each function.\nUsing $\\rho = 2^{-23} \\approx 0.119 \\times 10^{-6}$, which is the relative\nprecision of IEEE single precision arithmetic, these tests may be\nsummarized as follows:\n\\begin{center}\n\\begin{tabular}{lcr}\n& \\multicolumn{1}{c}{\\bf Argument} & \\multicolumn{1}{c}{\\bf Max. Rel.}\\\\\n\\multicolumn{1}{c}{\\bf Function} & \\multicolumn{1}{c}{\\bf Range} &\n\\multicolumn{1}{c}{\\bf Error}\\\\\nSASINH & All $x$ & 0.9 $\\rho $\\rule[-7pt]{0pt}{8pt}\\phantom{~el.}\\\\\nSACOSH & [1.00, 1.21] & 1.6 $\\rho $\\phantom{~el.}\\\\\n & $x \\geq 1.21$ & 0.5 $\\rho $\\rule[-7pt]{0pt}{8pt}\\phantom{~el.}\\\\\nSATANH & [$-$0.44, 0.44] & 1.3 $\\rho $\\phantom{~el.}\\\\\n & [0.44, 0.92] & 1.3 $\\rho $\\phantom{~el.}\\\\\n & [0.92, 1.0] & 0.5 $\\rho $\\rule[-7pt]{0pt}{8pt}\\phantom{~el.}\\\\\nSACSCH & $x \\neq 0$  & 0.9 $\\rho $\\rule[-7pt]{0pt}{8pt}\\phantom{~el.}\\\\\nSASECH & [0.0, 0.24]  & 0.8 $\\rho $\\phantom{~el.}\\\\\n & [0.24, 0.68] & 1.2 $\\rho $\\phantom{~el.}\\\\\n & [0.68, 0.88] & 3.2 $\\rho $\\phantom{~el.}\\\\\n & [0.88, 1.] & 989.1 $\\rho $\\rule[-7pt]{0pt}{8pt}\\phantom{~el.}\\\\\nSACTNH & [1.0, 1.16] & 153.5 $\\rho $\\phantom{~el.}\\\\\n & [1.16, 2.2] & 1.7 $\\rho $\\phantom{~el.}\\\\\n & $x \\geq 2.2$ & 1.6 $\\rho $\\phantom{~el.}\n\\end{tabular}\n\\end{center}\nThe instances of very large relative errors in this table are in regions\nwhere the slope of the graph of the function is becoming vertical.\nNote that relative errors may be significantly larger on machines\nthat do not have proplerly rounded arithmetic.\n\nThe functions were tested using identities of the form $x - \\sinh(\\asinh(x)) =\n0$.  When scaled by the precision of the arithmetic used, the double precision\nand single precision functions had similar perfomance.\n\n\\subsection{Error Procedures and Restrictions}\n\nIf an argument is outside the valid domain, an error message will be\nissued, and the value zero will be returned.  Error messages are\nprocessed using the subroutines of Chapter~19.2 with an error level of zero.\n\n\\subsection{Supporting Information}\n\nThe source language for these subroutines is ANSI Fortran 77.\n\nAll double precision entries are in the file DASINH, which also needs\nfiles: AMACH, DERM1, DERV1, ERFIN, and ERMSG.\n\nAll single precision entries are in the file SASINH, which also needs\nfiles: AMACH, ERFIN, ERMSG, SERM1, and SERV1.\n\nDesigned and programmed by C. Lawson and S. Chiu, JPL, 1983. Modified Nov.,\n1988 to use R1MACH and D1MACH.\n\n\n\\begin{tabular}{ll@{\\hspace{.3in}}ll}\n\\multicolumn{4}{c}{\\bf Entries\\rule[-6pt]{0pt}{8pt}}\\\\\nDACOSH & DACSCH & SACOSH & SACSCH\\\\\nDACTNH & DASECH & SACTNH & SASECH\\\\\nDASINH & DATANH & SASINH & SATANH\\\\\n\\end{tabular}\n\n\\begcodenp\n\n\\medskip\\\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSASINH}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sasinh}}\n\n\\vspace{30pt}\\centerline{\\bf \\large ODSASINH}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sasinh}}\n\\end{document}\n", "meta": {"hexsha": "13b931b4f439fb1f411174ffcc146212df3e231f", "size": 6394, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch02-01.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch02-01.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch02-01.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 38.7515151515, "max_line_length": 98, "alphanum_fraction": 0.6973725368, "num_tokens": 2238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.43089181025966744}}
{"text": "\\documentclass{article}\n\n\\usepackage{arxiv}\n\n\\usepackage[utf8]{inputenc} % allow utf-8 input\n\\usepackage[T1]{fontenc}    % use 8-bit T1 fonts\n\\usepackage{hyperref}       % hyperlinks\n\\usepackage{url}            % simple URL typesetting\n\\usepackage{booktabs}       % professional-quality tables\n\\usepackage{amsfonts}       % blackboard math symbols\n\\usepackage{nicefrac}       % compact symbols for 1/2, etc.\n\\usepackage{microtype}      % microtypography\n\\usepackage{lipsum}\t\t% Can be removed after putting your text content\n\\usepackage{amssymb,amsmath,amsthm}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\\usepackage{subfig}\n\\usepackage{apacite}\n\n\\newtheorem{theorem}{Theorem}\n\n\\title{Sampling from the Bayesian poster of an agent-based model given partial observations}\n\n%\\date{September 9, 1985}\t% Here you can change the date presented in the paper title\n%\\date{} \t\t\t\t\t% Or removing it\n\n\\author{\n  Daniel Tang\\\\\n  Leeds Institute for Data Analytics\\thanks{This project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No. 757455)}\\\\\n  University of Leeds\\\\\n  Leeds, UK\\\\\n  \\texttt{D.Tang@leeds.ac.uk} \\\\\n  %% examples of more authors\n  %% \\AND\n  %% Coauthor \\\\\n  %% Affiliation \\\\\n  %% Address \\\\\n}\n\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nabstract\n\\end{abstract}\n\n% keywords can be removed\n\\keywords{Data assimilation, Bayesian inference, Agent based model, Integer linear programming, predator prey model}\n\n\\section{Introduction}\n%##########################################\n\nSuppose we have a closed, convex polyhedron defined as\n\\begin{equation}\nAX = B\n\\label{polyhedron}\n\\end{equation}\nsubject to\n\\[\nx_i \\in \\mathbb{Z}_{\\ge 0}\n\\]\nfor all $i$, where $X = x_1...x_n$. And a probability distribution over the space of X\n\\begin{equation}\nP(X) = \\prod_i \\omega_i^{x_i}\n\\label{probability}\n\\end{equation}\nOur aim is to sample from valid points (i.e. those that satisfy the constraints) with the given probability distribution.\n\n\\section{Pivot sampling}\n\n\\begin{theorem}\nFor any two extreme positive, integer solutions of $AX_a = B$ and $AX_b = B$ there exists a sequence of positive solutions $X_0...X_N$ such that $X_0 = X_a$, $X_N = X_b$ and there exists a sequence of pivots $\\pi_1...\\pi_N$ such that pivoting at these points produces the sequence of solutions $X_0...X_N$.\n\\end{theorem}\n\n\\begin{proof}\nStart with a full pivot with $X_a$ as a solution. Now let $C$ be the set of events/columns in $X_b$ that are not currently pivoted-in and let $R$ be the set of rows whose currently pivoted columns are not in $X_a \\cup X_b$. While there exists a column $j \\in C$ and a row $i \\in R$ such that $A_{ij} = \\pm 1$ pivot on $(i,j)$. Since all rows with pivoted columns not in $X_a$ have $B_i = 0$ then, $i \\in R \\implies B_i = 0$ so the pivot does not alter the solution.\n\nAll remaining events/columns in $C$ must have all rows in $R$ either $0$, $>1$ or $<-1$.\n\nIf there is an event/column with all rows in $R$ equal to $0$, then we have found a loop in $X_b-X_a$ which must be positive [proof? no subset of $X_b - X_a$ can, when added to $X_a$ result in a negative number], so we can pivot it in.\n\nSo, we need to show that it is impossible that we end up with all multiple occupation numbers outside of $X_a \\cup X_b$ for all columns/events left in $C$. For Fermionic ABMs this is necessarily true [proof?].\n\nIf we choose a currently pivoted-in event at random and fan out along currently pivoted-in events according to the original constraint matrix for those events, then each row has a \"distance\" from that point. If we pivot as soon as we reach a row that contains a pivot of an event in $C$, then ...? \n\nMultiple occupation can only occur for interactions (disregarding predicates) so there must remain only interactions in $C$. Also, if interactions must have only singleton states in the original constraint matrix, there must exist singleton events in the pivoted equivalent. So all these singleton events must be in $X_a \\cup X_b$ if all events in $R$ are multiply occupied.\n\nAt any point during pivoting, there must exist events in $C$ that \n\nIf a column has multiple occupation on all rows in $R$, there must be at least one member of $C$ which replaces at least some of these multiple occupations, since in the final pivot, these will all be zero. But maybe this too has all multiple occupations in $R$. This can't go on forever though...at some point the event must join to $X_a$ in at least one point.\n\nConsider a branch that has multiple occupation in a column\n\n\\end{proof}\n\n(Assume partially observed start/end conditions)\n\nStart with the agent conservation equations.\n\nFind the nearest positive corner points to $X_a$ and $X_b$ (call them $X_a'$ and $X_b'$) and make those the first and last transitions.\n\nForm the tree from sources to sinks where nodes are agent-state/timestep pairs and parents are events in $X_a$ that have the node state as a consequence. Since $X_a$ is an extreme point, this tree must exist. Now add agent-state/timestep nodes in $X_b$ that aren't in $X_a$. Now add events in $X_b$ that join sources from separate trees. The remaining events in $X_b$ are pivots. [we can add one more loop for the root of the tree...but which one?]. \n\n[Better to think in terms of loops rather than trees?]\n\n%Form the bipartite graph with rows-id's on the left and column-id's on the right with edges where there is a non-zero element in (row,column) in $A$. Add only columns with non-zero values in $X_a'$ of $X_b'$. Find a maximal one-one mapping $\\mu$ that contains all non-zero columns in $X_a'$ as a subset (this must exist since $X_a'$ is a corner).\n\nEach edge represents a pivot point. Pivot on each edge in the one-one mapping. The remaining edges $\\pi_1...\\pi_N$ are pivot points in the sequence.\n\nSince $X_a'$ and $X_b'$ are trees, each $\\pi_i$ must be a point where the b-tree joins the a-tree.\n\nEach pivot has the effect of clipping off a subtree and adding the root of the subtree to the children of another node. If all edges are positive edges, then the solution is positive.\n\nEach new branch may \"require\" other agents to be present at certain space-time points. Since the requirements of an event may only contain events in a previous timestep, there cannot be cycles of requirements. So, if we take the pivot with the earliest time, all its requirements must be fulfilled (otherwise $X_b$ would not be a solution), so we arrange the pivots in chronological order and there's the answer!\n\n\n%\\bibliographystyle{unsrtnat}\n%\\bibliographystyle{apalike} \n\\bibliographystyle{apacite}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "60179430819b8c5a0b8bf10b5df9700e0579d6b3", "size": 6673, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/PivotSampling.tex", "max_stars_repo_name": "nickmalleson/AgentBasedMCMC", "max_stars_repo_head_hexsha": "c31cc5e04e9da28373f402bd0bf61cd39e9183c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/PivotSampling.tex", "max_issues_repo_name": "nickmalleson/AgentBasedMCMC", "max_issues_repo_head_hexsha": "c31cc5e04e9da28373f402bd0bf61cd39e9183c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/PivotSampling.tex", "max_forks_repo_name": "nickmalleson/AgentBasedMCMC", "max_forks_repo_head_hexsha": "c31cc5e04e9da28373f402bd0bf61cd39e9183c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.814516129, "max_line_length": 465, "alphanum_fraction": 0.7426944403, "num_tokens": 1747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4308448281196143}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\n\\section{Operations, Primitives and Algorithms}\nThe following sections introduce, define and explain Operations, Primitives and Algorithms generally using the Terminology presented below. Operations are the building blocks of Primitives whereas Primitives are the building blocks of Algorithms. The definitions which follow are flexible enough to support implementation across programing languages but have been inspired by the core concepts found within Lisp and Z. The focus of these sections is to define the properties of and interactions between Operations, Primitives and Algorithms in a general way which doesn't place unnecessary bounds on their range of possible functionality with respect to processing xAPI data.\n\n\\subsection{Terminology}\n\nWithin this document, (s) indicates one or more.\n\n\\subsubsection{Scalar}\nWhen working with xAPI data, Statements are written using \\href{https://www.json.org/}{JavaScript Object Notation} (JSON).\nThis data model supports a few fundamental types as described by \\href{https://json-schema.org/understanding-json-schema/reference/type.html}{JSON Schema}.\nIn order to speak about a singular valid JSON value (string, number, boolean, null) generically, the term Scalar is used.\nTo talk about a scalar within a Z Schema, the following free and basic types are introduced.\n\\begin{zed}\n  [STRING, NULL] \\\\\n  Boolean :== true ~| ~false \\\\\n  Scalar :== Boolean ~| ~STRING ~| ~NULL ~| ~\\num\n\\end{zed}\nArrays and Objects are also valid JSON values but will be referenced using the terms Collection and Map $\\lor$ KV respectively.\n\n\\subsubsection{Collection}\na sequence $\\langle ... \\rangle$ of items $c$ such that each $c : \\nat \\cross V \\implies (\\nat, V) \\implies \\nat \\mapsto V$\n\\begin{axdef}\n  C : Collection\n  \\where\n  C = \\langle c_{i}..c_{n}..c_{j} \\rangle \\implies \\{~i \\mapsto c_{i}, n \\mapsto c_{n}, j \\mapsto c_{j} \\} @\n  i \\leq n \\leq j \\implies i \\prec n \\prec j \\iff i \\not= n \\not= j\n\\end{axdef}\nAnd the following free type is introduced for collections\n\\begin{argue}\n  Collection :== emptyColl ~| ~append \\ldata Collection \\cross Scalar ~\\lor Collection ~\\lor KV \\cross \\nat \\rdata \\\\\n  \\t1 emptyColl & the empty Collection $\\langle  \\rangle$ \\\\\n  \\t1 append & is a constructor and is inferred to be an injection \\\\\n  \\t1 KV & a free type introduced bellow \\\\\n  append(emptyColl, c?, 0) = \\langle c_{0} \\rangle \\implies \\{~0 \\mapsto c?\\} & $append$ adds $c?$ to $\\langle  \\rangle$ at $\\nat$\n\\end{argue}\n\n\\subsubsection{Key}\n\nAn identifier $k$ paired with some value $v$ to create an ordered pair $(k, v)$. $k$ can take on any valid JSON value (Scalar, Collection, KV)\nexcept for the Scalar null. The following free type is introduced for keys.\n\\begin{zed}\n  K ::= (Scalar \\hide NULL) ~| ~Collection ~| ~KV\n\\end{zed}\n\n\\subsubsection{Value}\n\nA value $v$ is paired with an identifier $k$ to create an ordered pair $(k, v)$. $v$ can be any valid JSON value (Scalar, Collection, KV)\nThe following free type is introduced for values.\n\n\\begin{zed}\n  V ::= Scalar ~| ~Collection ~| ~KV\n\\end{zed}\n\n\\subsubsection{Map}\nWithin the Z Notation Introduction section, Maps are introduced using the free type $KV$.\n\\begin{zed}\n  KV ::= base ~| ~associate \\ldata~KV \\cross X \\cross Y \\rdata\n\\end{zed}\nThis definition is more accurately\n\\begin{zed}\n  KV ::= base ~| ~associate \\ldata~KV \\cross K \\cross V \\rdata\n\\end{zed}\nwhich indicates the usage of Key $k$ and Value $v$ within $associate$. Using this updated definition,\n\\begin{zed}\n  associate(base, k, v) = \\ldata (k, v) \\rdata\n\\end{zed}\nsuch that a Map is a Collection of ordered pairs $(k_{n}, v_{n})$ and thus a Collection of mappings\n\\begin{zed}\n  (k_{n}, v_{n}) \\implies k_{n} \\mapsto v_{n}\n\\end{zed}\nbut Maps are special cases of Collections as $k_{n}$ is the unique identifier of $v_{n}$ within a Map\nbut the opposite is not true. In fact, keys are their own identifiers\n\\begin{zed}\n  \\id v_{n} = k_{n} \\\\\n  \\id k_{n} \\not= v_{n} \\\\\n  \\id k_{n} = k_{n}\n\\end{zed}\nGiven a Map $M = \\ldata (k_{i}, v_{i})~..~(k_{n}, v_{n})~..~(k_{j}, v_{j}) \\rdata$ the following demonstrates the uniqueness of Keys\nbut the same is not true for all $v$ within $M$\n\\begin{zed}\n  k_{i} \\not= k_{n} \\not= k_{j} \\\\\n  v_{i} = v_{n} \\lor v_{i} \\not= v_{n} \\\n  v_{i} = v_{j} \\lor v_{i} \\not= v_{j} \\\n  v_{j} = v_{n} \\lor v_{j} \\not= v_{n}\n\\end{zed}\nwhich can all be stated formally as\n\\begin{gendef}[K, V]\n  Map : K \\cross V \\bij KV\n  \\where\n  Map = \\ldata (k_{i}, v_{i})~..~(k_{n}, v_{n})~..~(k_{j}, v_{j}) \\rdata @ \\\\\n  \\t1 \\dom Map = \\{~ k_{i}~..~k_{n}~..~k_{j}\\} \\\\\n  \\t1 \\ran Map = \\{~v_{i}~..~v_{n}~..~v_{j}\\} \\\\\n  \\t1 first(k_{i}, v_{i}) \\not= first(k_{n}, v_{n}) \\not= first (k_{j}, v_{j}) ~\\land \\\\\n  \\t1 v_{i} = v_{n} \\lor v_{i} \\not= v_{n} \\ v_{i} = v_{j} \\lor v_{i} \\not= v_{j} \\ v_{j} = v_{n} \\lor v_{j} \\not= v_{n} ~\\land \\\\\n  \\t1 \\id ~v_{i} = k_{i} ~\\land \\id ~v_{n} = k_{n} ~\\land \\id ~v_{j} = k_{j} ~\\land \\\\\n  \\t1 \\id ~k_{i} = k_{i} ~\\land \\id ~k_{n} = k_{n} ~\\land \\id k_{j} = k_{j}\n\\end{gendef}\nGiven that $v$ can be a Map $M$, or a Collection $C$, Arbitrary nesting is allowed within Maps but the properties of a Map hold at any depth.\n$$M = \\ldata (k_{i}, v_{i})~..~(k_{n}, \\ldata (k_{ni}, v_{ni}) \\rdata)~..(k_{j}, \\langle v_{ji}~..~\\ldata (k_{jn}, v_{jn}) \\rdata~..~\\langle v_{jji}~..~v_{jjn}~..~v_{jjj}\\rangle\\rangle) \\rdata$$\nsuch that $\\ldata (k_{ni}, v_{ni}) \\rdata$ and $\\ldata (k_{nj}, v_{nj}) \\rdata$ are both Maps and adhere to the constraints enumerated above.\n\n\\subsubsection{Statement}\n\nImmutable Map conforming to the \\href{https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#24-statement-properties}{xAPI Specification} as described in the xAPI Formal Definition section of this document. The immutability of a Statement $s$ is demonstrated by the following\nwhich indicates that $s$ was not altered when passed to $associate$.\n\\begin{axdef}\n  s!, s? : STATEMENT \\\\\n  k? : K \\\\\n  v? : V \\\\\n  \\where\n  s! = associate(s?, k?, v?) = s? \\implies (k?, v?) \\not \\in s! \\implies s! = s? \\\\\n\\end{axdef}\n Additionally, given the schema $Statements$ the following is true for all $Statement$(s)\n\\begin{axdef}\n  Statements \\\\\n  Keys : STRING \\\\\n  S : Collection\n  \\where\n  Keys = \\{~id, actor, verb, object, result, context, attachments, timestamp, stored\\} \\\\\n  \\dom statement = K \\dres Keys \\\\\n  S = \\langle ~statement_{i}~..~statement_{n}~..~statement_{j} \\rangle @ \\\\\n  \\t1 atKey(statement_{i}, id) \\not= atKey(statement_{n}, id) \\not= atKey(statement_{j}, id) \\implies \\\\\n  \\t1 id_{i} \\not= id_{n} \\not= id_{j} \\iff statement_{i} \\not= statement_{n} \\not= statement_{j}\n\\end{axdef}\nWhich confirms the constraints found in the schema $Statement$ and adds an additional constraint\nto $Statements$ such that every unique $Statement$ in a $Collection$ of $Statements$ has a unique $id$.\n\n\\subsubsection{Algorithm State}\n\nMutable Map $state$ without any domain restriction such that\n\\begin{axdef}\n  state?, state! : KV \\\\\n  k? : K \\\\\n  v? : V\n  \\where\n  associate(state?, k?, v?) = state! @ (k, v) \\in state! \\implies state? \\not= state!\n\\end{axdef}\n\n\\subsubsection{Option}\n\nMutable Map $opt$ which is used to alter the result of an Algorithm. The effect of $opt$ on an Algorithm will be discussed in the Algorithm Result section bellow.\n\n\\section{Operation}\n\nAn Operation is a function of arbitrary arguments and is defined using Z. For example, Operations pulled directly from \"The Z Notation: A Reference Manual\" include\n\\begin{itemize}\n\\item $first$\n\\item $second$\n\\item $succ$\n\\item $\\min$\n\\item $\\max$\n\\item $count \\equiv \\#$\n\\item $\\cat$\n\\item $rev$\n\\item $head$\n\\item $last$\n\\item $tail$\n\\item $front$\n\\item $\\extract$\n\\item $\\filter$\n\\item $\\dcat$\n\\item $\\disjoint$\n\\item $\\partition$\n\\item $\\otimes$\n\\item $\\uplus$\n\\item $\\uminus$\n\\item $items$\n\\end{itemize}\n\n\\subsection{Domain}\nThe arguments passed to an Operation can be any of the following but the definition of an Operation may limit the domain to a subset of the following\n\\begin{itemize}\n\\item Key(s)\n\\item Value(s)\n\\item Set(s)\n\\item Collection(s)\n\\item Bag(s)\n\\item KV(s)\n\\item Statement(s)\n\\item Algorithm State\n\\end{itemize}\n\n\\subsection{Range}\nThe result of an Operation can be any of the following but the definition of an Operation may limit this range to a subset of the following\n\n\\begin{itemize}\n\\item Key(s)\n\\item Value(s)\n\\item Set(s)\n\\item Collection(s)\n\\item Bag(s)\n\\item KV(s)\n\\item Statement(s)\n\\item Algorithm State\n\\end{itemize}\n\n\\section{Primitive}\nPrimitives break the processing of xAPI data down into discrete units that can be composed to create new analytical functions.\nPrimitives allow users to address the methodology of answering research questions as a sequence of generic algorithmic steps\nwhich establish the necessary data transformations, aggregations and calculations required to reach the solution in an implementation agnostic way.\n\nWithin this document, they will be defined as a Collection of Operations and/or Primitives where the output is piped from member to member.\nIn this section, $o_{n}$ and $p_{n}$ can be used as to describe Primitive members but for simplicity, only $o_{n}$ will be used.\n\\begin{zed}\n  p_{\\langle i~..~n~..~j \\rangle} = o_{i} ~\\pipe ~o_{n} ~\\pipe ~o_{j}\n\\end{zed}\nWithin any given Primitive $p$, variables local to $p$ and any global variables may be passed as arguments to any member of $p$\nand there is no restriction on the ordering of arguments with respect to the piping.\nIn the following, $q?$ is a global variable whereas the rest are local.\n\\begin{axdef}\n  x?, y?, z?, i!, n!, j!, p! : Value \\\\\n  o_{i} : Value \\pfun Value \\\\\n  o_{n} : Value \\cross Value \\pfun Value \\\\\n  o_{j}, p : Value \\cross Value \\cross Value \\pfun Value \\\\\n  \\where\n  i! = o_{i}(x?) \\\\\n  n! = o_{n}(i!, y?) \\\\\n  j! = o_{j}(z?, n!, q?) \\\\\n  p! = j! \\implies o_{j}(z?, o_{n}(o_{i}(x?), y?), q?)\n\\end{axdef}\nIn the rest of this document, the following notation is used to distinguish between\nthe functionality of a Primitive and its composition. This notation should be used when defining Primitives.\n\\begin{axdef}\n  primitiveName~\\_ : ~\\_~\\pfun~\\_\n  \\where\n  primitiveName = \\langle primitiveName_{i}~\\_~..~primitiveName_{n}~\\_~..~primitiveName_{j}~\\_~ \\rangle\n\\end{axdef}\n\\begin{itemize}\n\\item The top line indicates the Primitive\n  \\begin{itemize}\n  \\item should be written using postfix notation within other schemas\n  \\item is at least a partial function from some input to some output\n  \\end{itemize}\n\\item The bottom line is an enumeration of the composing Operations and/or Primitives and their order of execution\n\\end{itemize}\nThis means the definition of $p$ from above can be updated as follows.\n\\begin{axdef}\n  p~\\_ : Value \\cross Value \\cross Value \\pfun Value\n  \\where\n  p = \\langle ~o_{i}, ~o_{n}, ~o_{j} \\rangle \\\\\n  p(x?, y?, z?) = o_{j}(z?, o_{n}(o_{i}(x?), y?), q?)\n\\end{axdef}\nAdditionally, this notation supports declaration of recursive iteration via the presence of $recur~\\_$ within a Primitive chain\n\\begin{axdef}\n  primitiveName_{i} = \\langle \\langle  primitiveName_{ii}~\\_~, primitiveName_{in}~\\_ ~\\rangle, ~ recur~\\_ ~ \\rangle \\bsup \\#~\\_ \\esup\n  \\where\n  \\langle \\langle primitiveName_{ii}~\\_~, primitiveName_{in}~\\_ ~\\rangle, ~ recur~\\_ ~ \\rangle \\bsup \\#~\\_ \\esup \\implies \\\\\n  \\t2 (primtiveName_{ii} ~\\pipe ~primitiveName_{in}) \\bsup \\#~\\_ \\esup @ \\\\\n  \\t3 \\forall ~n : i~..~j @ j = \\#~\\_ ~ \\land ~i ~\\leq ~n ~\\leq j ~|~ \\exists_1 p_{n} : ~\\_~\\pfun \\_\\_ \\pfun~\\_ @ \\\\\n  \\t4 let ~~ \\ \\ p_{i} == primtiveName_{ii} ~\\pipe ~primitiveName_{in} \\implies \\\\\n  \\t6 p_{i}~\\_ = primitiveName_{in}(primitiveName_{ii}~\\_)  \\\\\n  \\t5 p_{n} == p_{i} ~\\pipe ~ primtiveName_{ii} ~\\pipe ~primitiveName_{in} \\implies\\\\\n  \\t6 p_{n}~\\_ = primitiveName_{in}(primitiveName_{ii}(p_{i}~\\_)) \\\\\n  \\t5 p_{j} == p_{n} ~\\pipe ~ primtiveName_{ii} ~\\pipe ~primitiveName_{in} \\implies\\\\\n  \\t6 p_{j}~\\_ = primitiveName_{in}(primitiveName_{ii}(p_{n}~\\_)) \\\\\n  \\t3 p_{j} = (primtiveName_{ii} ~\\pipe ~primitiveName_{in}) \\bsup \\#~\\_ \\esup @ j = 3 \\implies \\\\\n  \\t5 ~ (primtiveName_{ii} ~\\pipe ~primitiveName_{in}) ~ \\pipe \\\\\n  \\t5 ~ (primtiveName_{ii} ~\\pipe ~primitiveName_{in}) ~ \\pipe \\\\\n  \\t5 ~ (primtiveName_{ii} ~\\pipe ~primitiveName_{in}) \\implies \\\\\n  \\t6 primitiveName_{in}( \\\\\n  \\t7 primitiveName_{ii}( \\\\\n  \\t8 primitiveName_{in}( \\\\\n  \\t9 primitiveName_{ii}(p_{i}~\\_))))\n\\end{axdef}\nHere, $p_{i}$ was chosen to only be two primitives $primtiveName_{ii} ~ \\land ~ primitiveName_{in}$ for simplicity sake.\nThe Primitive chain can be of arbitrary length. The number of iterations is described using the count operation $\\#~\\_$.\nAbove $j = 3$ was used to demonstrate the piping between iterations but $j$ is not exclusively $= 3$. Given above,\nthe term Primitive Chain can be defined as:\n\\begin{zed}\n  (primtiveName_{i} ~\\pipe ~primitiveName_{n} ~ \\pipe ~ primitiveName_{j})\\bsup \\#~\\_ \\esup @ \\\\\n  \\t1 \\#~\\_ = 0 \\implies primtiveName_{i} ~\\pipe ~primitiveName_{n} ~ \\pipe ~ primitiveName_{j}\n\\end{zed}\nwhere a Primitive chain iterated to the 0 is just the chain itself hence recursion is not a requirement of, but is supported within, the definition of Primitives.\n\n\\subsection{Domain}\nAny of the following dependent upon the Operations which compose the Primitive\n\n\\begin{itemize}\n\\item Key(s)\n\\item Value(s)\n\\item Set(s)\n\\item Collection(s)\n\\item Bag(s)\n\\item KV(s)\n\\item Statement(s)\n\\item Algorithm State\n\\end{itemize}\n\n\\subsection{Range}\nAny of the following dependent upon the Domain and Functionality of the Primitive\n\n\\begin{itemize}\n\\item Key(s)\n\\item Value(s)\n\\item Set(s)\n\\item Collection(s)\n\\item Bag(s)\n\\item KV(s)\n\\item Statement(s)\n\\item Algorithm State\n\\end{itemize}\n\n\\section{Algorithm}\nGiven a Collection of statement(s) $S_{\\langle a..b..c \\rangle}$ and potentially option(s) $opt$ and potentially an existing Algorithm State $state$ an Algorithm $A$ executes as follows\n\n\\begin{enumerate}\n\\item call $init$\n\\item for each $stmt \\in S_{\\langle a..b..c \\rangle}$\n  \\begin{enumerate}\n  \\item $relevant?$\n  \\item $accept?$\n  \\item $step$\n  \\end{enumerate}\n\\item return $result$\n\\end{enumerate}\nwith each process within $A$ is enumerated as\n\n\\begin{lstlisting}[frame=single]\n  (init [state] body)\n   - init state\n\n  (relevant? [state statement] body)\n   - is the statement valid for use in algorithm?\n\n  (accept? [state statement] body)\n   - can the algorithm consider the current statement?\n\n  (step [state statement] body)\n   - processing per statement\n   - can result in a modified state\n\n  (result [state] body)\n   - return without option(s) provided\n   - possibly sets default option(s)\n\n  (result [state opt] body)\n   - return with consideration to option(s)\n\\end{lstlisting}\n\\begin{itemize}\n\\item $body$ is a collection of Primitive(s) which establishes the processing of inputs $\\to$ outputs\n\\item $state$ is a mutable Map of type $KV$ and synonymous with Algorithm State\n\\item $statement$ is a single statement within the collection of statements passed as input data to the Algorithm $A$\n\\item $opt$ are additional arguments passed to the algorithm $A$ which impact the return value of the algorithm and synonymous with Option\n\\end{itemize}\nAn Algorithm must be passed an Algorithm State and a Collection of Statement(s). Option is optional.\n\\begin{itemize}\n\\item Statement(s)\n\\item Algorithm State\n\\item Option(s)\n\\end{itemize}\nAn Algorithm will return an Algorithm State.\n\\begin{itemize}\n\\item Algorithm State\n\\end{itemize}\nAn Algorithm can be described via its components. A formal definition for an Algorithm\nis presented at the end of this section. The following subsections go into more detail about the components of an Algorithm.\n\\begin{zed}\n  Algorithm ::= Init ~\\pipe ~Relevant? ~\\pipe ~Accept? ~\\pipe ~Step ~\\pipe Result\n\\end{zed}\n\\subsection{Initialization}\n\nFirst process to run within an Algorithm which returns the Algorithm State for the current iteration.\n\n\\begin{schema}{Init[KV]}\n  state?, state! : KV \\\\\n  init~\\_: KV \\surj KV\n  \\where\n  init = \\langle body \\rangle \\\\\n  state! = init(state?) @ state! = state? ~\\lor ~state! \\not = state?\n\\end{schema}\nsuch that some $state!$ does not need to be related to its arguments $state?$\nbut $state!$ could be derived from some seed $state?$.\nThis functionality is dependent upon the composition of $body$ within $init$.\n\\subsubsection{Domain}\n\n\\begin{itemize}\n\\item Algorithm State\n\\end{itemize}\n\n\\subsubsection{Range}\n\n\\begin{itemize}\n\\item Algorithm State\n\\end{itemize}\n\n\\subsection{Relevant?}\n\nFirst process that each $stmt$ passes through $\\implies relevant? \\prec accept? \\prec step$\n\\begin{schema}{Relevant?[KV, STATEMENT]}\n  state? : KV \\\\\n  stmt? : STATEMENT \\\\\n  relevant?~\\_ : KV \\cross STATEMENT \\fun Boolean\n  \\where\n  relevant? = \\langle body \\rangle \\\\\n  relevant?(state?, stmt?) = true ~\\lor false\n\\end{schema}\nresulting in an indication of whether the $stmt$ is valid within algorithm $A$.\nThe criteria which determines validity of $stmt$ within $A$ is defined by the $body$ of $relevant?$\n\n\\subsubsection{Domain}\n\n\\begin{itemize}\n\\item Statement\n\\item Algorithm State\n\\end{itemize}\n\n\\subsubsection{Range}\n\n\\begin{itemize}\n\\item Boolean\n\\end{itemize}\n\n\\subsection{Accept?}\n\nSecond process that each $stmt$ passes through $\\implies relevant? \\prec accept? \\prec step$\n\\begin{schema}{Accept?[KV, STATEMENT]}\n  state? : KV \\\\\n  stmt? : STATEMENT \\\\\n  accept?~\\_ : KV \\cross STATEMENT \\fun Boolean\n  \\where\n  accept? = \\langle body \\rangle \\\\\n  accept?(state?, stmt?) = true ~\\lor false\n\\end{schema}\nresulting in an indication of whether the $stmt$ can be sent to $step$ given the current $state$.\nThe criteria which determines usability of $stmt$ given $state$ is defined by the $body$ of $accept?$\n\n\n\\subsubsection{Domain}\n\n\\begin{itemize}\n\\item Statement\n\\item Algorithm State\n\\end{itemize}\n\n\\subsubsection{Range}\n\n\\begin{itemize}\n\\item Scalar\n\\end{itemize}\n\n\\subsection{Step}\n\nAn Algorithm Step consists of a sequential composition of Primitive(s)\nwhere the output of some function is passed as an argument to the next function both within and across Primitives in $body$.\n$$body = p_{i} ~\\pipe ~p_{n} ~\\pipe ~p_{j} \\implies o_{ii} ~\\pipe ~o_{in} ~\\pipe ~o_{ij} ~\\pipe ~o_{ni} ~\\pipe ~o_{nn} ~\\pipe ~o_{nj} ~\\pipe ~o_{ji} ~\\pipe ~o_{jn} ~\\pipe ~o_{jj}$$\nThe selection and ordering of Operation(s) and Primitive(s) into an Algorithmic Step determines how the Algorithm State changes during iteration through Statement(s) passed as input to the Algorithm.\n\\begin{axdef}\n  P = \\langle p_{i}~..~p_{n}~..~p_{j} \\rangle @ i \\leq n \\leq j \\implies i \\prec n \\prec j \\iff i \\not= n \\not= j @ p_{i} ~\\pipe ~p_{n} ~\\pipe ~p_{j} \\\\\n  P' = \\langle p_{i'}~..~p_{n'}~..~p_{j'} \\rangle @ i' \\leq n' \\leq j' \\implies i' \\prec n' \\prec j' \\iff i' \\not= n' \\not= j' @ p_{i'} ~\\pipe ~p_{n'} ~\\pipe ~p_{j'} \\\\\n  P'' = \\langle p_{x}~..~p_{y}~..~p_{z}\\rangle @ x \\leq y \\leq z \\implies x \\prec y \\prec z \\iff x \\not= y \\not= z @ p_{x} ~\\pipe ~p_{y} ~\\pipe ~p_{z}\n  \\where\n  P = P' \\iff i \\mapsto i' ~\\land ~n \\mapsto n' ~\\land ~j \\mapsto j' \\\\\n  P = P'' \\iff (i \\mapsto x ~\\land n \\mapsto y ~\\land j \\mapsto z) ~\\land (p_{i} \\equiv p_{x} ~\\land p_{n} \\equiv p_{y} ~\\land p_{j} \\equiv p_{z})\n\\end{axdef}\n$step$ may or may not update the input Algorithm State given the current Statement from the Collection of Statement(s).\n\\begin{axdef}\n  S : Collection \\\\\n  stmt_{a}, stmt_{b}, stmt_{c} : STATEMENT \\\\\n  state?, step_{a}!, step_{b}!, step_{c}! : KV \\\\\n  step~\\_ : KV \\cross STATEMENT \\surj KV\n  \\where\n  S = \\langle stmt_{a}..stmt_{b}..stmt_{c} \\rangle @ a \\leq b \\leq c \\implies a \\prec b \\prec c \\iff a \\not= b \\not= c \\\\\n  step_{a}! = step(state?, stmt_{a}) @ step_{a}! = state? ~\\lor ~step_{a}! \\not= state? \\\\\n  step_{b}! = step(step_{a}!, stmt_{b}) @ step_{b}! = step_{a}! ~\\lor ~step_{b}! \\not= step_{a}! \\\\\n  step_{c}! = step(step_{b}!, stmt_{c}) @ step_{c}! = step_{b}! ~\\lor ~step_{c}! \\not= step_{b}!\n\\end{axdef}\nIn general, this allows $step$ to be defined as\n\\begin{schema}{Step[KV, STATEMENT]}\n  state?, state! : KV \\\\\n  stmt? : STATEMENT \\\\\n  step~\\_ : KV \\cross STATEMENT \\surj KV\n  \\where\n  step = \\langle body \\rangle \\\\\n  state! = step~(state?, stmt?) = state? ~\\lor ~state! \\not= state?\n\\end{schema}\nA change of $state? \\to state! @ state! \\not= state?$ can be predicted to occur given\n\\begin{itemize}\n\\item The definition of individual Operations which constitute a Primitive\n\\item The ordering of Operations within a Primitive\n\\item The Primitive(s) chosen for inclusion within the body of $step$\n\\item The ordering of Primitive(s) within the body of $step$\n\\item The key value pair(s) in both Algorithm State and the current Statement\n\\item The ordering of Statement(s)\n\\end{itemize}\n\n\\subsubsection{Domain}\n\n\\begin{itemize}\n\\item Statement\n\\item Algorithm State\n\\end{itemize}\n\n\\subsubsection{Range}\n\n\\begin{itemize}\n\\item Algorithm State\n\\end{itemize}\n\n\\subsection{Result}\n\nLast process to run within an Algorithm which returns the Algorithm State $state$\nwhen all $s \\in S$ have been processed by $step$\n\n\\begin{zed}\n  relevant? \\prec accept? \\prec step \\prec result \\prec relevant? \\iff S \\not= \\emptyset \\\\\n  relevant? \\prec accept? \\prec step \\prec result \\iff S = \\emptyset\n\\end{zed}\nand does so without preventing subsequent calls of $A$\n\\begin{schema}{Result[KV, KV]}\n  result!, state?, opt? : KV \\\\\n  result~\\_ : KV \\cross KV \\surj KV\n  \\where\n  result = \\langle body \\rangle \\\\\n  result! = result(state?, opt?) = state? ~\\lor ~state! \\not= state?\n\\end{schema}\nsuch that if at some future point $j$ within the timeline $i~..~n~..~j$\n\\begin{argue}\n  S(t_{n}) = \\emptyset & S is empty at $t_{n}$ \\\\\n  S(t_{j}) \\not= \\emptyset & S is not empty at $t_{j}$ \\\\\n  S(t_{n - i}) & stmts(s) added to $S$ between $t_{i}$  and $t_{n}$ \\\\\n  S(t_{j - n}) & stmts(s) added to $S$ between $t_{n}$  and $t_{j}$ \\\\\n  S(t_{j - i}) = S(t_{n - i}) \\ \\cup \\ S(t_{j - n}) & stmts(s) added to $S$ between $t_{i}$ and $t_{j}$\n\\end{argue}\nAlgorithm $A$ can pick up from a previous $state_{n}$ without losing track of its own history.\n\\begin{axdef}\n  state_{n-i} = A(state_{i},\\ S(t_{n - i})) \\\\\n  state_{n-1} = A(state_{n-2}, \\ S(t_{n - 1})) \\\\\n  state_{n} = A(state_{n-1},\\ S(t_{n})) \\\\\n  state_{j-n} = A(state_{n}, \\ S(t_{j-n})) \\\\\n  state_{j} = A(state_{i},\\ S(t_{j - i}))\n  \\where\n  state_{n} = state_{n-1} \\iff S(t_{n}) = \\emptyset ~\\land S(t_{n-1}) \\not = \\emptyset \\\\\n  state_{j} = state_{j-n} \\iff state_{n-i} = state_{n} = state_{n-1}\n\\end{axdef}\nWhich makes $A$ capable of taking in some $S_{\\langle i..n..j..\\infty \\rangle}$ as not all $s \\in S_{\\langle i..\\infty \\rangle}$ have to be considered at once. In other words, the input data does not need to persist across the history of $A$, only the effect of $s$ on $state$ must be persisted.\nAdditionally, the effect of $opt$ is determined by the $body$ within $result$ such that\n\\begin{zed}\n  A(state_{n}, \\ S(t_{j-n}), \\ opt) \\\\\n  \\t1 \\equiv A(state_{i}\\ S(t_{j - i})) \\\\\n  \\t1 \\equiv A(state_{i},\\ S(t_{j - i}), \\ opt) \\\\\n  \\t1 \\equiv A(state_{n}, \\ S(t_{j-n}))\n\\end{zed}\nimplying that the effect of $opt$ doesn't prevent backwards compatibility of $state$.\n\n\\subsubsection{Domain}\n\n\\begin{itemize}\n\\item Algorithm State\n\\item Option(s)\n\\end{itemize}\n\n\\subsubsection{Range}\n\n\\begin{itemize}\n\\item Algorithm State\n\\end{itemize}\n\n\\subsection{Algorithm Formal Definition}\\label{AFD_ref}\nIn previous sections, $A~\\_$ was used to indicate calling an Algorithm.\nIn the rest of this document, that notation will be replaced with $algorithm~\\_$.\nThis new notation is defined using the definitions of Algorithm Components presented above.\nThe previous definition of an Algorithm\n\\begin{zed}\n  Algorithm ::= Init ~\\pipe ~Relevant? ~\\pipe ~Accept? ~\\pipe ~Step ~\\pipe Result\n\\end{zed}\ncan be refined using the Operation $recur$ and Primitive $algorithmIter$ (defined in following subsections)\nto illustrate how an Algorithm processes a Collection of Statement(s).\n\\begin{schema}{Algorithm[KV, Collection, KV]}\n  Algorithm ~Iter, ~Recur, ~Init, ~Result \\\\\n  opt?, state?, state! : KV \\\\\n  S? : Collection @ \\forall s? \\in S? ~| ~s? : STATEMENT \\\\\n  algorithm~\\_ : KV \\cross Collection \\cross KV \\surj KV\n  \\where\n  algorithm = \\langle ~init~\\_~, \\langle ~algorithmIter~\\_~, ~recur~\\_~\\rangle \\bsup \\#~S? \\esup, ~result~\\_~\\rangle \\\\\n  state! = algorithm(state?, S?, opt?) @ \\\\\n  \\t1 let \\ \\ ~ init! == init(state?) @ \\\\\n  \\t1 \\forall s_{n} \\in S? ~|~ s_{n} : STATEMENT, n : \\nat @ i \\leq n \\leq j ~@ \\\\\n  \\t2 \\exists_1 state_{n} ~|~ state_{n} : KV @ \\\\\n  \\t3 let \\ \\ ~ S?_{n} = tail(S?)\\bsup n-i \\esup \\\\\n  \\t4 state_{i} = algorithmIter(init!, ~S?_{n}) \\implies ~S?_{n} = S? \\iff n = i \\\\\n  \\t4 state_{n} = recur(state_{i}, ~S?_{n}, ~\\_~algorithmIter~\\_)\\bsup j-1 \\esup \\iff n \\not = i ~\\land n \\not = j\\\\\n  \\t4 state_{j} = recur(state_{n}, (\\{j-1, j\\} \\extract S?), ~\\_~algorithmIter~\\_) \\iff n = j \\\\\n  \\t4 state_{j+1}  = state_{j} \\implies recur(state_{j}, (j \\extract S?), ~\\_~algorithmIter~\\_) \\iff n = j+1\\\\\n  \\t1 \\ \\ = result(state_{j}, opt?)\n\\end{schema}\nWithin the schema above, the following notation is intended to show that $algorithm$ is a Primitive $\\implies$ Collection of Primitives and/or Operations.\n$$\\langle ~init~\\_~, \\langle ~algorithmIter~\\_~, ~recur~\\_~\\rangle \\bsup \\#~S? \\esup, ~result~\\_~\\rangle$$\nWithin that notation, the following notation is intended to represent the iteration through the Statement(s) via tail recursion.\n$$\\langle ~algorithmIter~\\_~, ~recur~\\_~\\rangle \\bsup \\#~S? \\esup$$\nwhich implies that each Statement is passed to $algorithmIter~\\_$ and\nthe result is then passed on to the next iteration of the loop.\nThe completion of this loop is the prerequisites of $result~\\_$\n\n\\subsubsection{Recur}\nThe following schema introduces the Operation $recur$ which expects an accumulator ($KV$),\na $Collection$ of Value(s) ($V$) being iterated over and\na function ($\\_~\\pfun~\\_$) which will be called as the result of $recur$.\nThis Operation has been written to be as general purpose as possible and represents\nthe ability to perform \\href{https://cs.stackexchange.com/questions/6230/what-is-tail-recursion}{tail recursion}.\nGiven this intention, $recur$ must only ever be the last Operation within a Primitive\n\\begin{axdef}\n  p_{i~..~j} : \\seq_1 @ \\forall o \\in p ~|~ o : \\_~\\pfun~\\_\n  \\where\n  p_{i~..~j} = \\langle ~\\forall ~n : \\nat ~|~ i \\leq n \\leq j ~\\land~ o_{n} \\in p_{i~..~j} @ \\\\\n  \\t2 \\exists_1 o_{n} @ o_{n} \\not = recur ~\\lor ~o_{n}= recur \\iff n = j \\rangle ~ \\implies \\\\\n  \\t3 front(p_{i~..~j}) \\filter recur = \\langle  \\rangle\n\\end{axdef}\nand results in a call to the passed in function where the\naccumulator $ack?$ and the Collection (minus the first member)\nare passed as arguments to $fn?$. If this would result in the empty Collection ($\\langle  \\rangle$)\nbeing passed to $fn?$, instead the accumulator $ack?$ is returned.\n\\begin{schema}{Recur[KV, Collection, (\\_~\\pfun~\\_)]}\n  ack? : KV \\\\\n  S? : Collection \\\\\n  fn? : (\\_~\\pfun~\\_) \\\\\n  recur~\\_ : KV \\cross Collection \\cross (\\_~\\pfun~\\_) \\rel (KV \\cross Collection ~\\pfun~\\_)\n  \\where\n  recur(ack?, S?, fn?) = fn?(ack?, tail(S?)) \\iff tail(S?) \\not = \\langle  \\rangle \\\\\n  recur(ack?, S?, fn?) = first(ack?, tail(S?)) \\iff tail(S?) = \\langle  \\rangle\n\\end{schema}\nIn the context of Algorithms,\n\\begin{zed}\n  ack? = Algorithm State \\\\\n  S? = Collection of Statement(s) \\\\\n  fn? = algorithmIter\n\\end{zed}\n\\subsubsection{Algorithm Iter}\nThe following schema introduce the Primitive $algorithmIter$ which\ndemonstrates the life cycle of a single statement as its passed through the components of an Algorithm.\n\\begin{schema}{Algorithm Iter[KV, Collection]}\n  Relevant?, ~Accept?, ~Step \\\\\n  state?, state! : KV \\\\\n  S? : Collection \\\\\n  s? : STATEMENT \\\\\n  algorithmIter~\\_ : KV \\cross STATEMENT \\surj KV\n  \\where\n  algorithmIter = \\langle ~relevant?~\\_~, ~accept?~\\_~, ~step~\\_ ~\\rangle \\\\\n  s? = head(S?) \\\\\n  state! = algorithmIter(state?, s?) @ \\\\\n  \\t1 let \\ \\ ~ relevant! == relevant?(state?, s?) \\\\\n  \\t2 accept! == accept?(state?, s?) \\\\\n  \\t2 step! == step(state?, s?)\\\\\n  \\t1 \\ ~ = (state? \\iff relevant! = false ~ \\lor ~ accept! = false) ~\\lor \\\\\n  \\t1 \\ \\ \\ \\ ~ (step! \\iff relevant! = true ~ \\land ~ accept! = true)\n\\end{schema}\nIf a statement if both relevant and acceptable, $state!$ will be the result of $step$. Otherwise,\nthe passed in state is returned $\\implies step! = state?$.\n\\end{document}\n", "meta": {"hexsha": "fae5177dfc221bdb7b6d57e5ae55aded4049ec29", "size": 28342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/algorithms/introduction.tex", "max_stars_repo_name": "yetanalytics/dave", "max_stars_repo_head_hexsha": "7a71c2017889862b2fb567edc8196b4382d01beb", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2018-08-17T00:38:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-09T02:32:37.000Z", "max_issues_repo_path": "docs/algorithms/introduction.tex", "max_issues_repo_name": "adlnet/dave", "max_issues_repo_head_hexsha": "9339713fac747118e462e4fc7e1ecd54e5d916e3", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 95, "max_issues_repo_issues_event_min_datetime": "2018-08-31T18:57:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-15T16:40:01.000Z", "max_forks_repo_path": "docs/algorithms/introduction.tex", "max_forks_repo_name": "yetanalytics/dave", "max_forks_repo_head_hexsha": "7a71c2017889862b2fb567edc8196b4382d01beb", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-09-28T06:48:47.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-31T16:20:47.000Z", "avg_line_length": 43.4027565084, "max_line_length": 675, "alphanum_fraction": 0.6796274081, "num_tokens": 8986, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.43084481430802074}}
{"text": "\\documentclass[]{article}\n\\usepackage{amsmath}\n\\usepackage[a4paper]{geometry}\n\\usepackage{graphicx}\n\\usepackage{microtype}\n\\usepackage{siunitx}\n\\usepackage{booktabs}\n\\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}\n\\usepackage{cleveref}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\n\\begin{document}\n\n\\title{Auto-Regression}\n\\author{Dun Wang}\n\\maketitle\n\n\\section{Auto-Regression}\n In additional to predicting the Kepler data point from the pixel values of other stars, we can also make the pixel values of the same stars but from different time as predictors, the auto-regression:\n\n\\begin{align*}\n  I_{mn}^{*}=\\sum_{m' \\in M_{m}} a_{mnm'}I_{m'n} + \\sum_{n' \\in N_{n'}} a_{mnn'}I_{mn'}\n\\end{align*}\n\\\\\n$N_{n'}$ is the time window we used as predictors from target pixel, $a_{mnn'}$ is the corresponding auto-regression coeffecient\n\n\n\\section{Auto-Regression Window and Edge Effects}\n\nWe want to make use of the data points both before and after the target data point at time t and also leave N data points around the target data point tobe untouched , where $\\left|  t-t_N \\right|>\\Delta t$, $\\Delta t$ is the transit duration, to make sure that the auto-regression will not fit out the transit signal. So basically, we use a window $[-\\Delta, -N] \\cup [N, \\Delta]$ as the data set in auto-regression, where $\\Delta$ is the largest time shifts, which should be decided by optimizing our objective\n\\\\\nOn the edge of the data sets, to overcome the edge effects, we may only use the data points before or after the target data points, that is either window $[-\\Delta, -N]$ or $[N, \\Delta]$ as the auto-regression data set\n\n\n\n\\end{document}\n", "meta": {"hexsha": "18c05e77482f2af27eb4b9f56dc451ce915e59cb", "size": 1666, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/notes/notes/Auto-Regression.tex", "max_stars_repo_name": "jvc2688/cpm", "max_stars_repo_head_hexsha": "409e9ada39fc6238a63a75fb8474a3af70410347", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-08-13T19:26:23.000Z", "max_stars_repo_stars_event_max_datetime": "2015-08-13T19:26:23.000Z", "max_issues_repo_path": "documents/notes/notes/Auto-Regression.tex", "max_issues_repo_name": "jvc2688/cpm", "max_issues_repo_head_hexsha": "409e9ada39fc6238a63a75fb8474a3af70410347", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/notes/notes/Auto-Regression.tex", "max_forks_repo_name": "jvc2688/cpm", "max_forks_repo_head_hexsha": "409e9ada39fc6238a63a75fb8474a3af70410347", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.7179487179, "max_line_length": 512, "alphanum_fraction": 0.7460984394, "num_tokens": 469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4308448105717752}}
{"text": "\\newcommand{\\TeamNo}{31}\n\n\\newcommand{\\HWno}{05}\n\n\\newcommand{\\AuthorOneName}{Merve Nur Öztürk}\n\\newcommand{\\AuthorOneID}{2311322}\n\n\\newcommand{\\AuthorTwoName}{Atakan Süslü}\n\\newcommand{\\AuthorTwoID}{2311371}\n\n\\newcommand{\\AuthorThreeName}{Betül Rana Kuran}\n\\newcommand{\\AuthorThreeID}{2311173}\n\n\n\\documentclass[letterpaper,12pt]{article}\n\\usepackage{tabularx} % extra features for tabular environment\n\\usepackage{amsmath}  % improve math presentation\n\\usepackage{amssymb}\n\\usepackage{xcolor}\n\\usepackage{float}\n\\usepackage[export]{adjustbox}\n\\usepackage{graphicx} % takes care of graphic including machinery\n\\usepackage[margin=1in,letterpaper]{geometry} % decreases margins\n\\usepackage{cite} % takes care of citations\n\n\\begin{document}\n\\begin{center}\nAE 305, 2020-21 Fall \\hfill \\textbf{HW \\HWno} \\hfill \\textbf{Team \\TeamNo} \\\\\n\\noindent\\rule{\\textwidth}{0.4pt}\n\\begin{tabular}{p{0.33\\textwidth} | p{0.33\\textwidth} | p{0.33\\textwidth} }\n\t\\AuthorOneName&\\AuthorTwoName&\\AuthorThreeName\\\\\n\t\\textit{\\AuthorOneID}&\\textit{\\AuthorTwoID}&\\textit{\\AuthorThreeID}\n\\end{tabular}\n\\noindent\\rule{\\textwidth}{0.4pt}\n\\end{center}\n\n%Report start\n\n\\section{Introduction}\nElliptic partial differential equations can be solved by using finite difference equations,\nand the most common FDE for the solution of an elliptic PDE is obtained by second-order\ncentral difference approximations of the derivatives. Afterwards, the FDE can\nbe solved either by direct solution methods or iterative methods. In this homework, a 2D\nheat equation is given:\n\n\\begin{equation}\n\t\\frac{\\partial^2T}{\\partial x^2} + \\frac{\\partial^2T}{\\partial y^2} = 0\n\t\\label{eqn:heateqn}\n\\end{equation}\n\nIt is requested to compute the steady state temperature distribution on a given 2D model\nof a room having a width of 10m and a height of 6m by solving the above equation for \ntwo different cases, one is with a radiator and the other is without a radiator. First,\nthe iterative methods are used; Point Jacobi, Gauss-Seidel, SOR and Line Gauss-Seidel\nmethods, then the solution is obtained by the direct solution methods. For the final\nsolution, it is asked to plot the heat flux distribution in the room, and the heat flux\nvector is given as follows:\n\n\\begin{equation}\n\t\\vec{q} = -k \\nabla T\n\t\\label{eqn:heatflux}\n\\end{equation}\n\nIt is also asked to compare the convergence rates of the iterative methods.\n\\section{Method}\nFDE of the governing equation of this homework (Equation \\ref{eqn:heateqn}) is an elliptic partial differential\nequation,and it is obtained by second-order central difference approximations of the derivatives.\n\\begin{equation}\n\t\\frac{T_{i+1,j}-2T_{i,j}+T_{i-1,j}}{\\Delta x^2}+\\frac{T_{i,j+1}-2T_{i,j}+T_{i,j-1}}{\\Delta y^2}\n\t\\label{eqn:fde}\n\\end{equation}\nWhen $i$ and $j$ coincide with the boundries of the room or the radiator, they are excluded\nfrom the solution of the heat equation since at these points the temperatures are equal to\ntemperatures of the boundries.\\\\\nWhen $\\beta = \\frac{\\Delta x}{\\Delta y}$ substituted into Equation \\ref{eqn:fde}, equation becomes:\n\\begin{eqnarray}\n\tT_{i+1,j}-2T_{i,j}+T_{i-1,j}+\\beta ^2(T_{i,j+1}-2T_{i,j}+T_{i,j-1})&=&0 \\nonumber \\\\\n\t\\beta^2T_{i,j-1}+T_{i-1,j}-2(1+\\beta^2)T_{i,j}+T_{i+1,j}+\\beta ^2T_{i,j+1}&=&0 \n\t\\label{eqn:basic}\n\\end{eqnarray}\nThis five-point formula gives the system of linear algebraic equations, which can be solved by two methods,\nnamely direct solution methods and iterative solution methods.\n\\subsection{Direct Solution Method}\n\\subsubsection{Gauss Elimination}\nIn this homework, Gauss elimination method is used as direct solution method. The system of linear\nequations formed by five-point formula (Equation \\ref{eqn:basic}).\n\\begin{equation}\n\taT_{i-1,j}+bT_{i,j}+cT_{i+1,j}+dT_{i,j-1}+eT_{i,j+1}=0\n\\end{equation}\nwith Neumann type BC for insulated wall and Dirichlet type BCs for other walls,\nthe system of equations can be writen in $\\underline{A}\\mbox{ }\\underline{T}=\\underline{f}$ form\nwhere $\\underline{A}$ is coefficient matrix.\nThis equation is solved by Gauss elimination method.\n\n\\subsection{Iterative Solution Methods}\n\\label{subsec:iterative}\n\\subsubsection{Point Iterative Methods}\n\\paragraph{Point Jacobi Iteration}\nIn this method, every terms in Equation \\ref{eqn:basic} are kept at $k$\nwhere $k$ is denoted as iteration level except $T_{i,j}$. $T_{i,j}$ which is kept\nat new iteration level $k+1$. Then equation becomes:\n\\begin{equation}\n\tT_{i,j}^{k+1}=\\frac{1}{2(1+\\beta^2)}[T_{i-1,j}^{k}+T_{i+1,j}^{k}+\\beta ^2(T_{i,j-1}^{k}+T_{i,j+1}^{k})]\n\\label{eqn:jacobi}\n\\end{equation}\nwhere $k$ corresponds previous calculated values or initial guess at the start\nof iteration process of $T$ values over the room except boundary conditions.\n\\paragraph{Gauss-Seidel Iteration}\nDifferently from Point Jacobi method, in Gauss-Seidel method, the unknown dependent\nvariable values of Equation \\ref{eqn:basic} are used as soon as they become available\nat the $k+1$ iteration level.\n\\begin{equation}\n\tT_{i,j}^{k+1}=\\frac{1}{2(1+\\beta^2)}[T_{i-1,j}^{k+1}+T_{i+1,j}^{k}+\\beta ^2(T_{i,j-1}^{k+1}+T_{i,j+1}^{k})]\n\\label{eqn:gs}\n\\end{equation}\n\\paragraph{Successive Over-Relaxation Method}\nIn this method, the convergence of solution is can be accelerated by multiplying the relaxation\nparameter, $\\omega$, with the amount of the change in each step. First, $T_{i,j}^k$ is substracted\nfrom the Gauss-Seidel iteration method to obtain $\\Delta T$.\n\\begin{equation}\n\tT_{i,j}^{k+1}\\vert_{GS}-T_{i,j}^{k}=\\Delta T\\vert{GS}=\\frac{1}{2(1+\\beta^2)}[T_{i-1,j}^{k+1}+T_{i+1,j}^{k}+\\beta ^2(T_{i,j-1}^{k+1}+T_{i,j+1}^{k})]-T_{i,j}^{k}\n\\label{eqn:sor1}\n\\end{equation}\nThen, $\\Delta T$ is multiplied by $\\omega$\n\\begin{eqnarray}\n\tT_{i,j}^{k+1}\\vert_{SOR}&=&T_{i,j}^{k}+\\omega\\Delta T\\vert{GS} \\nonumber \\\\\n\t&=&(1-\\omega)T_{i,j}^{k}+\\frac{\\omega}{2(1+\\beta^2)}[T_{i-1,j}^{k+1}+T_{i+1,j}^{k}+\\beta^2(T_{i,j-1}^{k+1}+T_{i,j+1}^{k})]\n\t\\label{eqn:sor}\n\\end{eqnarray}\nTo obtain convergent solutions, relaxatation parameter,$\\omega$, is chosen in (0,2) interval.\nThe optimum value of $\\omega$ can be determined by numerical experimentations. If $\\omega$ is chosen in\n(0,1) interval, under-relaxation occurs, which prevents the divegence by slowing the convergence for the solution of\ncertain non-linear partial derivative equations.\n\\subsubsection{Line Iterations}\n\\paragraph{Line Gauss-Seidel Method} In this method, iterations are made line by line, in one direction. One more term of Equation\n\\ref{eqn:gs} is expressed at $k+1$ iteration level. Then, equation becomes:\n\\begin{equation}\n\tT_{i,j}^{k+1}=\\frac{1}{2(1+\\beta^2)}[T_{i-1,j}^{k+1}+T_{i+1,j}^{k+1}+\\beta ^2(T_{i,j-1}^{k+1}+T_{i,j+1}^{k})]\n\\end{equation}\nTo make iteration line by line, j is kept constant. Therefore, every $T_{ ,j}$ term should be in left\nhand side of the equation.\n\\begin{equation}\n\tT_{i-1,j}^{k+1}-2(1+\\beta^2)T_{i,j}^{k+1}+T_{i+1,j}^{k+1}=-\\beta^2(T_{i,j+1}^{k}+T_{i,j-1}^{k+1})]\n\\label{eqn:lgs}\n\\end{equation}\nFor constant j grid lines, Equation \\ref{eqn:lgs} is applied to all i's. The\nsystem of linear equations which includes tridiagonal coefficient matrix is formed. Its\nconvergence rate is higher than the Gauss-Seidel method. On the other hand, a system of equations\nis solved every iterations;hence, in each iteration, it requires more computations.\nThe effect of BCs at i=0 and i=imax is instantly visible in the solution.\n\\newpage\n\\section{Results and Discussion}\n\n\\subsection{Solution of the Heat Equation in the Absence of a Radiator}\nFigures \\ref{fig:pointnorad}, \\ref{fig:gaussnorad}, \\ref{fig:sornorad}, \\ref{fig:linegaussnorad}, and \\ref{fig:directnorad}\nillustrates the solution of the heat equation by using Point Jacobi, Gauss-Seidel,\nSOR, Line Gauss-Seidel, and Direct methods, respectively. As can be seen from these figures, all the solutions\nwith different methods converged to approximately the same heat flux distributions.\nIn all solutions, flux vectors have the same directions, which are from the walls\nwith higher temperature to the wall with the lower temperature perpendicularly.\nMoreover, near the insulated wall, these flux vectors are parallel and the temperature\ncontours are perpendicular to the wall since the temperature gradient is zero at the\ninsulated wall. Therefore, there is no heat transfer across the insulated wall. \n\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/point_norad/point_norad.png}\n\t\\caption{Solution of the heat equation by Point Jacobi method.}\n \t\\label{fig:pointnorad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/gauss_norad/gauss_norad.png}\n\t\\caption{Solution of the heat equation by Gauss-Seidel method.}\n \t\\label{fig:gaussnorad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/SOR_O19_norad/SOR_O19_norad.png}\n\t\\caption{Solution of the heat equation by SOR method.}\n \t\\label{fig:sornorad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/linegauss_norad/linegauss_norad.png}\n\t\\caption{Solution of the heat equation by Line Gauss-Seidel method.}\n \t\\label{fig:linegaussnorad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/linegauss_norad/linegauss_norad.png}\n\t\\caption{Solution of the heat equation by Direct method.}\n \t\\label{fig:directnorad}\n\\end{figure}\n\n\n\\subsubsection{Temperature Distributions along x=5m and y=3m}\nFigures \\ref{fig:x5norad} and \\ref{fig:y3norad} shows the temperature distributions along\nx=5 and y=3 lines respectively. It can be oberved that all methods gave the same result with\na negligible difference among them although their convergence rates differ.  \n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/x5_SOR19_norad.eps}\n\t\\caption{Temperature distributions along x=5m}\n \t\\label{fig:x5norad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/y3_SOR19_norad.eps}\n\t\\caption{Temperature distributions along y=3m}\n \t\\label{fig:y3norad}\n\\end{figure}\n\n\\subsection{Solution of the Heat Equation with Existence of a Radiator}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/point_rad_default/point_rad_default.png}\n\t\\caption{Solution of the heat equation by Point Jacobi method.}\n \t\\label{fig:pointrad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/gauss_rad_default/gauss_rad_default.png}\n\t\\caption{Solution of the heat equation by Gauss-Seidel method.}\n \t\\label{fig:gaussrad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/SOR_O19_rad_default/SOR_O19_rad_default.png}\n\t\\caption{Solution of the heat equation by SOR method.}\n \t\\label{fig:sorrad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/linegauss_rad_default/linegauss_rad_default.png}\n\t\\caption{Solution of the heat equation by Line Gauss-Seidel method.}\n \t\\label{fig:linegaussrad}\n\\end{figure}\nFigures \\ref{fig:pointrad}, \\ref{fig:gaussrad}, \\ref{fig:sorrad}, and \\ref{fig:linegaussrad}\ndemonstrates the solution of the heat equation by using Point Jacobi, Gauss-Seidel,\n SOR,and Line Gauss-Seidel methods, respectively.From these figures, it can be observed that all the solutions\nwith different methods converged to nearly the same heat flux distributions.\nIn all solutions, the directions of the flux vectors are from the highest temperature surface\n,which is the radiator, to the lower temperature surfaces, which is the walls of the room,\nperpendicularly, except the insulated wall. Since the wall is insulated, the temperature\ngradient across the wall is zero; hence the flux vectors are parallel near the surface.\nAlso, from the figures, it can be seen that all temperature contours which are intersect\nwith the insulated wall are perpendicular to the wall. Thus, it can said that heat transfer\ndoes not occur from the room to the wall or reverse of it.\n\n\\subsubsection{Temperature Distributions along x=5m and y=3m}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/x5_SOR19_defaultrad.eps}\n\t\\caption{Temperature distributions along x=5m}\n \t\\label{fig:x5rad}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/y3_SOR19_defaultrad.eps}\n\t\\caption{Temperature distributions along y=3m}\n \t\\label{fig:y3rad}\n\\end{figure}\nFigures \\ref{fig:x5rad} and \\ref{fig:y3rad} illustrates the temperature distributions with the\nexistence of radiator along x=5m and y=3m lines, respectively. In Figure \\ref{fig:x5rad}, sudden\nchange is observed near the y = 6m. The reason for this is that there is radiator between y = 5.6m\nand 5.8m. Therefore, a sudden rise in temperature is seen before y=5.8 meters. This causes distortion\nin both figures. However, in Figure \\ref{fig:y3rad}, due to the the length of the radiator is \nlonger in x-axis, its effect along y = 3m is less sudden.\n\n\\subsection{Comparison of the Convergence Rates}\nFigures \\ref{fig:convnorad} and \\ref{fig:convrad} demonstrate the convergence rates of Point\nJacobi, Gauss-Seidel,SOR, and Line Gauss-Seidel methods for the solutions of the heat equation without and with\nthe radiator, respectively. As can be observed from these figure, the responses of Point Jacobi\nmethod are the slowest. On the other hand, Gauss-Seidel method converges faster for both.\nThis is because it uses newly computed values of the unknowns as they become available as \nmentioned in Subsection \\ref{subsec:iterative}. Furthermore, Line Gauss-Seidel method gives the faster convergence\nrate than Gauss-Seidel method. Because as mentioned in Subsection \\ref{subsec:iterative}, in Line-Gauss Seidel method,\nsystem of equations are solved simultaneously and it includes one more unknown variable than Gaus-Seidel method.\n.However, among all methods, SOR method computed the solutions with minimum number\nof iterations which is a result of the use of the relaxation parameter. This is also mentioned\nin Subsection \\ref{subsec:iterative}. The relaxation parameter is taken 1.9 for both since this is its largest\npossible value which is found experimentally. For higher relaxation parameter values, the\nsolutions did not converge.\n\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/residual_SOR19_norad.eps}\n\t\\caption{Convergence rates of Point Jacobi, Gauss-Seidel and SOR methods in the absence of the radiator.}\n \t\\label{fig:convnorad}\n\\end{figure}\n\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=9cm]{graphs/residual_SOR19_defaultrad.eps}\n\t\\caption{Convergence rates of Point Jacobi, Gauss-Seidel and SOR methods in the presence of the radiator.}\n \t\\label{fig:convrad}\n\\end{figure}\n\\subsection{Temperature Distribution on a 2D Model of a Room with Radiator with SOR Method}\n\\subsubsection{Comparison of Different values of $\\Delta$x and $\\Delta$y}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/imax75jmax40_default/imax75jmax40_default.png}\n\t\\caption{Temperature distribution in the room with $\\Delta x=0.135$ and $\\Delta y = 0.154$}\n \t\\label{fig:7540}\n\\end{figure}\n\nFigure \\ref{fig:sorrad}, \\ref{fig:7540}, and \\ref{fig:402242} illustrates temperature\ndistribution in the room with SOR method with different $\\Delta x$ and $\\Delta y$ values. \nIt can be seen that although low $\\Delta x$ and $\\Delta y$ values give a more precise result, \nif $\\Delta x$ and $\\Delta y$ values are reasonably seleced, differences in the result would \nbe negligible. On the other hand, when $\\Delta x$ and $\\Delta y$ values are lower, convergence rate \nof the solution is slower, which can be seen from Figure \\ref{fig:converratedelta}. It can be concluded that, \ntoo low values of $\\Delta x$ and $\\Delta y$ should be avoided because they would increase solution time and they \nwould not increase the accuracy of result significantly.\n\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/imax402jmax242_default/imax402jmax242_default.png}\n\t\\caption{Temperature distribution on the room with $\\Delta x=0.025$ and $\\Delta y = 0.025$}\n \t\\label{fig:402242}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=8cm]{graphs/residual_deltax.eps}\n\t\\caption{Convergence rates of SOR method with different $\\Delta x$ and $\\Delta y$ values.}\n \t\\label{fig:converratedelta}\n\\end{figure}\n\\subsubsection{Comparison of Different Sizes and Locations of the Radiator}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/radiator_middle_long/radiator_middle_long.png}\n\t\\caption{Temperature distribution on the room with radiator at middle of the room}\n \t\\label{fig:middle}\n\\end{figure}\n\\begin{figure}[H] \n\t\\centering \n\t\\includegraphics[max height=12cm]{graphs/radiator_middle/radiator_middle.png}\n\t\\caption{Temperature distribution on the room with radiator at middle of the room with different size}\n \t\\label{fig:middlelong}\n\\end{figure}\nFigure \\ref{fig:sorrad} demonstrates the temperature distribution\non the room with radiator with size $6m\\times0.2m$, which is\nneighbor to the wall with $0^\\circ C$. Figure \\ref{fig:middlelong} illustrates the\ntemperature distribution on the room with radiator with the same size but at\nthe middle of the room. Figure \\ref{fig:middle} shows the temperature\ndistribution with radiator at the middle of the room with size $2m\\times2m$.\nIt can be obtained from Figure \\ref{fig:sorrad} and \\ref{fig:middlelong},\nchanging the location of the radiator from the coldest wall to the middle\nof the room causes inefficiency to evenly heat the entire room. Since all walls do not have\nthe same temperature, putting the source of heat at the middle of the room\nis not reasonable to heat everywhere evenly. Moreover, from Figure \\ref{fig:middlelong}\nand \\ref{fig:middle}, it can be observed that  changing the size of the radiator is\nnot logical. Since horizontal length of the radiator is shortened, it can not be\nsufficient to heat area near to the edges of the coldest wall. But, vertical length\nof the raditor is extended, it is more effective to heat the middle of the coldest\nwall than in Figure \\ref{fig:middlelong}. Overall, its effectiveness less than the other radiator\nwhich is longer in horizontal direction.\n\n\n\n\\section{Conclusion}\nGiven a 2D model of a room, with a size of 10m x 6m, it is requested to solve heat conduction equation for\nthe room. For this purpose, various numerical methods for the solution of an elliptic partial differential\nequation are used. First, Point Jacobi, Gauss-Seidel, Line Gauss-Seidel and SOR methods are used for two cases,\none in the existence of a radiator and the other is in the absence of a radiator. It was concluded that Point Jacobi method is the slowest responding method since it does not uses the newly computed values of unknowns in the k+1 iteration\nlevel as they become available whereas Gauss-Seidel, Line Gauss-Seidel and SOR methods use them. As a result of this, Gauss-Seidel,\nLine Gauss-Seidel and SOR methods converged faster than Point Jacobi method. Comparing Gauss-Seidel and Line Gauss-Seidel methods,\nLine Gauss-Seidel method converges faster as one more unknown variable is expressed at the k + 1 iteration level and the influence\nof the BC at $i = 1$ and $i = imax$ are reflected into the solution immediately. Furthermore, it was obvious\nfrom Figures \\ref{fig:convnorad} and \\ref{fig:convrad}, convergence of SOR method occurs earlier then\nthat of all methods. This is because SOR method makes use of the amount of change in each step to \nestimate the unknown variable at the new iteration level to accelerate the convergence of the solution, and\nit multiplies the change by the relaxation parameter.\n\nAccording to the experimentations made, the value of $\\Delta x$ and $\\Delta y$ had an impact on the solution. \nFor the calculations mentioned above, $\\Delta x = 0.05$ and $\\Delta y = 0.05$ . Then the calculations are \nrepeated for higher and smaller values of $\\Delta x$ and $\\Delta y$ such that for the former $\\Delta x = 0.135$\nand $\\Delta y = 0.154$ and for the latter $\\Delta x = 0.025$ and $\\Delta y = 0.025$. It was observed that the\nmedium and higher values yield to more accurate results whereas smaller values lead to distortions in the\ntemperature distribution.\n\nThe location and the size of the radiator also changed the solution. For the first calculations, the radiator\nwas placed near the upper wall and its size was 6m x 0.2m. When it is moved to the middle of the room, the upper\nwall is less heated. While it is still in the middle of the room, but changed in size (2m x 2m), the middle of\nthe upper wall is more heated since the radiator is longer vertically, but the edges of the upper wall is less\nheated since the radiator is shorter horizontally.\n\\end{document}", "meta": {"hexsha": "30012f88895f2cc9ce14ba64c8683ef40c972e19", "size": 20710, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Homework5/hw_05_team_31.tex", "max_stars_repo_name": "Atknssl/AE305-Homeworks", "max_stars_repo_head_hexsha": "5a2d5abb7b8837f72b94faecc2fe3180fd65f96a", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-06T18:42:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T13:27:27.000Z", "max_issues_repo_path": "Homework5/hw_05_team_31.tex", "max_issues_repo_name": "Atknssl/AE305-Homeworks", "max_issues_repo_head_hexsha": "5a2d5abb7b8837f72b94faecc2fe3180fd65f96a", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Homework5/hw_05_team_31.tex", "max_forks_repo_name": "Atknssl/AE305-Homeworks", "max_forks_repo_head_hexsha": "5a2d5abb7b8837f72b94faecc2fe3180fd65f96a", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.3762886598, "max_line_length": 238, "alphanum_fraction": 0.7685176243, "num_tokens": 5967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555714, "lm_q2_score": 0.7879311931529758, "lm_q1q2_score": 0.430792056073988}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tkz-euclide, tikz, xcolor, pgfplots, array}\n\\usetkzobj{all}\n\\pgfplotsset{compat = 1.16}\n\\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}\n\\pgfplotsset{every axis/.append style = {axis lines = middle, axis line style = {<->}}}\n\\pgfplotsset{every tick label/.append style={font=\\tiny}}\n\\everymath{\\displaystyle}\n\n\\title{Law of Sines and Law of Cosines}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\maketitle\n\\end{frame}\n\n\\section{Solve triangles using the Law of Sines}\n\n\\begin{frame}{Law of Sines}\n    An \\alert{oblique triangle} is one that does not contain a right angle. \\newline\\\\\n    \n    To solve oblique, as well as right triangles, you can use either the Law of Sines or the Law of Cosines.\n\\end{frame}\n\n\n\\begin{frame}{Derivation of Law of Sines}\n\\begin{center}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 4/0/B, 2/2/C, 2/0/D}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelSegment(A,C){b}\n\\tkzLabelSegment(B,C){a}\n\\tkzLabelSegment[below](A,B){c}\n\\onslide<2->{\\tkzDrawSegment[red](C,D)}\n\\onslide<2->{\\tkzLabelSegment[right,red](C,D){$y$}}\n\\end{tikzpicture}\n\\end{center}\n\\vspace{11pt}\n\\onslide<3->{\n\\begin{tabular}{p{0.6\\textwidth}p{0.3\\textwidth}}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 2/0/D/, 2/2/C}\n    \\tkzDrawPolygon(A,D,C)\n    \\tkzDrawSegment[color=red](C,D)\n    \\tkzLabelSegment[red,right](C,D){$y$}\n    \\tkzLabelSegment(A,C){b}\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelPoints[above](C)\n    \\tkzLabelPoints[right](D)\n    \\end{tikzpicture} \n    &\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/D, 2/0/B, 0/2/C}\n    \\tkzDrawPolygon(B,D,C)\n    \\tkzDrawSegment[color=red](C,D)\n    \\tkzLabelSegment[red,left](C,D){$y$}\n    \\tkzLabelSegment(B,C){a}\n    \\tkzLabelPoints[right](B)\n    \\tkzLabelPoints[above](C)\n    \\tkzLabelPoints[left](D)\n    \\end{tikzpicture}\n\\end{tabular}}\n\\end{frame}\n\n\\begin{frame}{Derivation of Law of Sines}\n\\begin{tabular}{p{0.6\\textwidth}p{0.3\\textwidth}}\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/A, 2/0/D/, 2/2/C}\n    \\tkzDrawPolygon(A,D,C)\n    \\tkzDrawSegment[color=red](C,D)\n    \\tkzLabelSegment[red,right](C,D){$y$}\n    \\tkzLabelSegment(A,C){b}\n    \\tkzLabelPoints[left](A)\n    \\tkzLabelPoints[above](C)\n    \\tkzLabelPoints[right](D)\n    \\end{tikzpicture} \n    &\n    \\begin{tikzpicture}\n    \\tkzDefPoints{0/0/D, 2/0/B, 0/2/C}\n    \\tkzDrawPolygon(B,D,C)\n    \\tkzDrawSegment[color=red](C,D)\n    \\tkzLabelSegment[red,left](C,D){$y$}\n    \\tkzLabelSegment(B,C){a}\n    \\tkzLabelPoints[right](B)\n    \\tkzLabelPoints[above](C)\n    \\tkzLabelPoints[left](D)\n    \\end{tikzpicture}\n    \\\\[10pt]\n    \\onslide<2->{$\\sin A = \\frac{y}{b}$}  &   \\onslide<4->{$\\sin B = \\frac{y}{a}$} \\\\\n    \\onslide<3->{$b\\sin A = y$}           &   \\onslide<5->{$a\\sin B = y$}   \\\\\n\\end{tabular}\n\\begin{align*}\n    \\onslide<6->{b\\sin A &= a\\sin B}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Derivation of Law of Sines}\n    \\begin{align*}\n        b\\sin A &= a\\sin B \\\\[10pt]\n        \\onslide<2->{\\frac{b\\sin A}{ab} &= \\frac{a\\sin B}{ab}} \\\\[10pt]\n        \\onslide<3->{\\frac{\\sin A}{a} &= \\frac{\\sin B}{b}}\n    \\end{align*}\n    \\onslide<4->{{\\color{red}\\[\\frac{\\sin A}{a} = \\frac{\\sin B}{b} = \\frac{\\sin C}{c}\\]}}\n\\end{frame}\n\n\\begin{frame}{Example 1}\nSolve the triangle given $m\\angle A = 120^\\circ, \\, a = 7, \\, m\\angle B = 45^\\circ$. Round your answers to 1 decimal place.   \\newline\\\\\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}[scale=0.95]\n\\tkzDefPoints{0/0/B, 2/2/A, 4/0/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[above](A)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[right](C)\n\\tkzLabelAngle[pos=0.7](C,B,A){$45^\\circ$}\n\\tkzLabelAngle[pos=0.5](C,A,B){$120^\\circ$}\n\\tkzLabelSegment[below](B,C){7}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<2->{$m\\angle C = 180^\\circ - 120^\\circ - 45^\\circ$}  \\\\[15pt]\n\\onslide<3->{$m\\angle C = 15^\\circ$}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}[scale=0.95]\n\\tkzDefPoints{0/0/B, 2/2/A, 4/0/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[above](A)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[right](C)\n\\tkzLabelAngle[pos=0.7](C,B,A){$45^\\circ$}\n\\tkzLabelAngle[pos=0.5](C,A,B){$120^\\circ$}\n\\tkzLabelAngle[pos=0.7, color=red](B,C,A){$15^\\circ$}\n\\tkzLabelSegment[below](B,C){7}\n\\end{tikzpicture}\n\\end{minipage}    \n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\frac{\\sin 120^\\circ}{7} &= \\frac{\\sin 45^\\circ}{b}} \\\\[12pt]\n    \\onslide<3->{b\\sin 120^\\circ &= 7\\sin 45^\\circ} \\\\[12pt]\n    \\onslide<4->{b &= \\frac{7\\sin 45^\\circ}{\\sin 120^\\circ}} \\\\[12pt]\n    \\onslide<5->{b &\\approx 5.7}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}[scale=0.95]\n\\tkzDefPoints{0/0/B, 2/2/A, 4/0/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[above](A)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[right](C)\n\\tkzLabelAngle[pos=0.7](C,B,A){$45^\\circ$}\n\\tkzLabelAngle[pos=0.5](C,A,B){$120^\\circ$}\n\\tkzLabelAngle[pos=0.7, color=red](B,C,A){$15^\\circ$}\n\\tkzLabelSegment[color=red,above right](A,C){$5.7$}\n\\tkzLabelSegment[below](B,C){7}\n\\onslide<6->{\\tkzLabelSegment[color=red,above left](A,B){$2.1$}}\n\\end{tikzpicture}\n\\end{minipage}    \n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\frac{\\sin 120^\\circ}{7} &= \\frac{\\sin 15^\\circ}{c}} \\\\[12pt]\n    \\onslide<3->{c\\sin 120^\\circ &= 7\\sin 15^\\circ} \\\\[12pt]\n    \\onslide<4->{c &= \\frac{7\\sin 15^\\circ}{\\sin 120^\\circ}} \\\\[12pt]\n    \\onslide<5->{c &\\approx 2.1}\n\\end{align*}\n\\end{minipage}\n\\vspace{11pt}\n\\[\\onslide<7->{m\\angle C = 15^\\circ, \\quad b \\approx 5.7, \\quad c \\approx 2.1}\\]\n\\end{frame}\n\n\\begin{frame}{Example 2}\nSolve the triangle given $m\\angle A = 85^\\circ, \\, m\\angle B = 30^\\circ, \\, c = 5.25$   \\newline\\\\  \n\\begin{minipage}{0.5\\textwidth}\n\\onslide<2->{\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/B, 4/0/C, 2.5/2/A}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[right](C)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[above](A)\n\\tkzLabelSegment[above left](B,A){5.25}\n\\tkzLabelAngle[pos=0.5](B,A,C){$85^\\circ$}\n\\tkzLabelAngle[pos=0.85](C,B,A){$30^\\circ$}\n\\end{tikzpicture}}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<3->{$m\\angle C = 180^\\circ - 30^\\circ - 85^\\circ$} \\\\[12pt]\n\\onslide<4->{$m\\angle C = 65^\\circ$}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/B, 4/0/C, 2.5/2/A}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[right](C)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[above](A)\n\\tkzLabelSegment[above left](B,A){5.25}\n\\tkzLabelAngle[pos=0.5](B,A,C){$85^\\circ$}\n\\tkzLabelAngle[pos=0.85](C,B,A){$30^\\circ$}\n\\tkzLabelAngle[pos=0.7,color=red](A,C,B){$65^\\circ$}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\frac{\\sin 65^\\circ}{5.25} &= \\frac{\\sin 85^\\circ}{a}} \\\\[12pt]\n    \\onslide<3->{a\\cdot \\sin65^\\circ &= 5.25\\sin 85^\\circ} \\\\[12pt]\n    \\onslide<4->{a &= \\frac{5.25\\sin 85^\\circ}{\\sin 65^\\circ}} \\\\[12pt]\n    \\onslide<5->{a &\\approx 5.8}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/B, 4/0/C, 2.5/2/A}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[right](C)\n\\tkzLabelPoints[left](B)\n\\tkzLabelPoints[above](A)\n\\tkzLabelSegment[above left](B,A){5.25}\n\\tkzLabelAngle[pos=0.5](B,A,C){$85^\\circ$}\n\\tkzLabelAngle[pos=0.85](C,B,A){$30^\\circ$}\n\\tkzLabelAngle[pos=0.7,color=red](A,C,B){$65^\\circ$}\n\\tkzLabelSegment[below,red](B,C){5.8}\n\\onslide<6->{\\tkzLabelSegment[red, above right](A,C){2.9}}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\frac{\\sin 65^\\circ}{5.25} &= \\frac{\\sin 30^\\circ}{b}} \\\\[12pt]\n    \\onslide<3->{b\\cdot \\sin65^\\circ &= 5.25\\sin 30^\\circ} \\\\[12pt]\n    \\onslide<4->{b &= \\frac{5.25\\sin 30^\\circ}{\\sin 65^\\circ}} \\\\[12pt]\n    \\onslide<5->{b &\\approx 2.9}\n\\end{align*}\n\\end{minipage}  \\vspace{11pt}\n\\[\n\\onslide<7->{m\\angle C = 65^\\circ, \\quad a \\approx 5.8, \\quad b \\approx 2.9}\n\\]\n\\end{frame}\n\n\\section{Solve triangles using the Law of Cosines}\n\n\\begin{frame}{Derivation of the Law of Cosines}\n\\begin{center}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 4/0/B, 2/2/C, 2/0/D}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelSegment[above left](A,C){$b$}\n\\tkzLabelSegment[above right](C,B){$a$}\n\\onslide<2->{\\tkzDrawSegment[red](C,D)\n\\tkzLabelSegment[red,right](C,D){$y$}\n\\tkzLabelSegment[below](A,D){$x$}\n\\tkzLabelSegment[below](B,D){$c-x$}\n}\n\\end{tikzpicture}\n\\end{center}\n\\begin{align*}\n    \\onslide<3->{x^2 + {\\color{red}y}^2 &= b^2 & (c-x)^2 + {\\color{red}y}^2 = a^2} \\\\[6pt]\n    \\onslide<4->{{\\color{red}y}^2 &= b^2 - x^2 & c^2 - 2cx + x^2 + {\\color{red}y}^2 &= a^2}\n\\end{align*}\n\\begin{align*}\n    \\onslide<5->{c^2 - 2cx + x^2 + {\\color{red}b^2 - x^2} &= a^2} \\\\\n    \\onslide<6->{b^2 + c^2 - 2cx &= a^2}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Derivation of Law of Cosines}\n\\begin{center}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 4/0/B, 2/2/C, 2/0/D}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelSegment[above left](A,C){$b$}\n\\tkzLabelSegment[above right](C,B){$a$}\n\\tkzDrawSegment[red](C,D)\n\\tkzLabelSegment[red,right](C,D){$y$}\n\\tkzLabelSegment[below](A,D){$x$}\n\\tkzLabelSegment[below](B,D){$c-x$}\n\\end{tikzpicture}\n\\end{center}\n\\begin{align*}\n    \\onslide<2->{a^2 &= b^2 + c^2 - 2cx} \\\\\n    \\onslide<3->{\\cos A &= \\frac{x}{b}} \\\\[6pt]\n    \\onslide<4->{x &= b\\cos A} \\\\[6pt]\n    \\onslide<5->{a^2 &= b^2 + c^2 - 2c(b\\cos A)}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Law of Cosines}\n    \\begin{align*}\n        a^2 &= b^2 + c^2 - 2bc(\\cos A) \\\\[12pt]\n        b^2 &= a^2 + c^2 - 2ac(\\cos B) \\\\[12pt]\n        c^2 &= a^2 + b^2 - 2ab(\\cos C)\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}{Law of Cosines}\nBy solving each of the previous equations for the cosine of the angle, we get the following:\n\\begin{align*}\n    \\cos A &= \\frac{b^2+c^2-a^2}{2bc}   \\\\[12pt]\n    \\cos B &= \\frac{a^2+c^2-b^2}{2ac}   \\\\[12pt]\n    \\cos C &= \\frac{a^2+b^2-c^2}{2ab}   \\\\[12pt]\n\\end{align*}\nThen take the inverse cosine to get the angle measure.\n\\end{frame}\n\n\\begin{frame}{Example 3}\nSolve each. Round your answers to one decimal place.    \\newline\\\\\n$m\\angle A = 60^\\circ, \\, b = 20, \\, c = 30$    \\newline\\\\\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/B/, 1.5/2/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelAngle[pos=0.7](B,A,C){$60^\\circ$}\n\\tkzLabelSegment[below](A,B){30}\n\\tkzLabelSegment[above left](A,C){20}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{-0.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{a^2 &= 20^2 + 30^2 - 2(20)(30)\\cos60^\\circ} \\\\[12pt]\n    \\onslide<3->{a^2 &= 700} \\\\[12pt]\n    \\onslide<4->{a &\\approx 26.5}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/B/, 1.5/2/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelAngle[pos=0.7](B,A,C){$60^\\circ$}\n\\tkzLabelSegment[below](A,B){30}\n\\tkzLabelSegment[above left](A,C){20}\n\\tkzLabelSegment[above right, red](B,C){26.5}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{-0.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{\\cos B &= \\frac{26.5^2 + 30^2 - 20^2}{2(26.5)(30)}} \\\\[12pt]\n    \\onslide<3->{\\cos B &\\approx 0.7561} \\\\[12pt]\n    \\onslide<4->{B &\\approx 40.9^\\circ} \n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 3}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/B/, 1.5/2/C}\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](C)\n\\tkzLabelPoints[right](B)\n\\tkzLabelAngle[pos=0.7](B,A,C){$60^\\circ$}\n\\tkzLabelSegment[below](A,B){30}\n\\tkzLabelSegment[above left](A,C){20}\n\\tkzLabelSegment[above right, red](B,C){26.5}\n\\onslide<4->{\\tkzLabelAngle[color=red,pos=0.7](B,C,A){$79.1^\\circ$}}\n\\tkzLabelAngle[color=red,pos=0.85](C,B,A){$40.9^\\circ$}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{-0.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n    \\onslide<2->{m\\angle C &\\approx 180^\\circ - 60^\\circ - 40.9^\\circ} \\\\[12pt]\n    \\onslide<3->{m\\angle C &\\approx 79.1^\\circ}\n\\end{align*}\n\\end{minipage}\n\\onslide<5->{\\[a \\approx 26.5, \\quad m\\angle B \\approx 40.9^\\circ, \\quad m\\angle C \\approx 79.1^\\circ \\]}\n\\end{frame}\n\n\\begin{frame}{Example 4}\nSolve the triangle. Round your answers to 1 decimal place.  \\newline\\\\\n$a = 6, \\, b = 9, \\, c = 4$ \\newline\\\\\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/C, 1/1.75/B}\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](B)\n\\tkzLabelPoints[right](C)\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelSegment[below](A,C){9}\n\\tkzLabelSegment[above left](A,B){4}\n\\tkzLabelSegment[above right](B,C){6}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n\\onslide<2->{\\cos A &= \\frac{9^2 + 4^2 - 6^2}{2(9)(4)}} \\\\[12pt]\n\\onslide<3->{\\cos A &= \\frac{61}{72}} \\\\[12pt]\n\\onslide<4->{A &\\approx 32.1^\\circ}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 4}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/C, 1/1.75/B}\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](B)\n\\tkzLabelPoints[right](C)\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelSegment[below](A,C){9}\n\\tkzLabelSegment[above left](A,B){4}\n\\tkzLabelSegment[above right](B,C){6}\n\\tkzLabelAngle[pos=0.75,color=red, yshift=-0.1cm](C,A,B){$32.1^\\circ$}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n\\onslide<2->{\\cos B &= \\frac{6^2 + 4^2 - 9^2}{2(6)(4)}} \\\\[12pt]\n\\onslide<3->{\\cos B &= -\\frac{29}{48}} \\\\[12pt]\n\\onslide<4->{B &\\approx 127.2^\\circ}\n\\end{align*}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 4}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\tkzDefPoints{0/0/A, 3/0/C, 1/1.75/B}\n\\tkzLabelPoints[left](A)\n\\tkzLabelPoints[above](B)\n\\tkzLabelPoints[right](C)\n\\tkzDrawPolygon(A,B,C)\n\\tkzLabelSegment[below](A,C){9}\n\\tkzLabelSegment[above left](A,B){4}\n\\tkzLabelSegment[above right](B,C){6}\n\\tkzLabelAngle[pos=0.75,color=red, yshift=-0.1cm](C,A,B){$32.1^\\circ$}\n\\tkzLabelAngle[pos=0.6,color=red](C,B,A){\\scriptsize $127.2^\\circ$}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\begin{align*}\n\\onslide<2->{m\\angle C &\\approx 180^\\circ - 127.2^\\circ - 32.1^\\circ}   \\\\[12pt]\n\\onslide<3->{m\\angle C &\\approx 20.7^\\circ}\n\\end{align*}\n\\end{minipage}\n\\onslide<4->{\\[m\\angle A \\approx 32.1^\\circ, \\quad m\\angle B \\approx 127.2^\\circ, \\quad m\\angle C \\approx 20.7^\\circ\\]}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "2b23014fc65dfe9736c535ac81cb41c3dd072caa", "size": 14996, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Law_of_Sines_and_Law_of_Cosines(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Law_of_Sines_and_Law_of_Cosines(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Law_of_Sines_and_Law_of_Cosines(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 30.5417515275, "max_line_length": 136, "alphanum_fraction": 0.6476393705, "num_tokens": 6422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7879311956428946, "lm_q1q2_score": 0.4307920457968234}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\setcounter{section}{0}\n\n\\begin{document}\n\n\\title{Model Theory}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Langauges and structures}\n\n\\begin{defi} (1.1)\nA language $L$ consists of:\\\\\n$\\bullet$(i) a set $\\mathcal{F}$ of function symbols, and for each $f \\in \\mathcal{F}$, a positive integer $n_f$, the arity of $f$;\\\\\n$\\bullet$(ii) a set $\\mathcal{R}$ of relation symbols, and for each $R \\in \\mathcal{R}$, a positive integer $n_R$, the arity of $R$;\\\\\n$\\bullet$(iii) a set $\\mathcal{C}$ of constant symbols.\\\\\nNote that each of the above three sets can be empty.\n\\end{defi}\n\n\\begin{eg}\n$L=\\{\\{\\cdot,-1\\},\\{1\\}\\}$ where $\\cdot$ is a binary function, $-1$ is a unary function, and $1$ is a constant. We call this $L_{gp}$ (language of groups);\\\\\n$L_{lo} = \\{<\\}$, where $<$ is a binary relation (linear order).\n\\end{eg}\n\n\\begin{defi} (1.2)\\\\\nGiven a language $L$, say, an $L$-structure consists of:\\\\\n(i) a set $M$, the \\emph{domain};\\\\\n(ii) for each $f \\in \\mathcal{F}$, a function $f^M:M^{n_f} \\to M$;\\\\\n(iii) for each $R \\in \\mathcal{R}$, a relation $R^M \\subseteq M^{n_R}$;\\\\\n(iv) for each $c \\in \\mathcal{C}$, an element $c^M \\in M$.\n\n$f^M,R^M,c^M$ are called the \\emph{interpretation} of $f,R,c$ respectively.\n\\end{defi}\n\n\\begin{notation} (1.3)\\\\\nWe often fail to distinguish between the symbols in the language $L$ and their interpretations in a $L$-structure, if the context allows.\n\nWe may write $\\mathcal{M} = \\bra M,\\mathcal{F},\\mathcal{R},\\mathcal{C}\\ket$.\n\\end{notation}\n\n\\begin{eg} (1.4)\\\\\n(a) $\\mathcal{R} = \\bra\\R^+,\\{\\cdot,-1\\},1\\ket$ is an $L_{gp}$-structure.\\\\\n$\\mathcal{Z} = \\bra\\Z,\\{+,-\\},0\\ket$ is also an $L_{gp}$-structure (here $+$ is a binary and $-$ is the unary negation function).\\\\\n$\\mathcal{Q} = \\bra\\Q,<\\ket$ is an $L_{lo}$ structure ($<$ is the interpretation of relation).\n\\end{eg}\n\n\\begin{defi} (1.5)\\\\\nLet $L$ be a language, let $\\mathcal{M}$ and $\\mathcal{N}$ be $L$-structures.\\\\\nAn \\emph{embedding} of $\\mathcal{M}$ into $\\mathcal{N}$ is an injection $\\alpha:M \\to N$ that preserves the structure:\\\\\n(i) For all $f \\in \\mathcal{F}$, and $a_1,...,a_{n_f} \\in M$,\n\\begin{equation*}\n\\begin{aligned}\n\\alpha(f^M(a_1,...,a_{n_f})) = f^N(\\alpha(a_1),...,\\alpha(a_{n_f}))\n\\end{aligned}\n\\end{equation*}\n(ii) For all $R \\in \\mathcal{R}$, and $a_1,...,a_{n_R} \\in M$,\n\\begin{equation*}\n\\begin{aligned}\n(a_1,...,a_{n_R}) \\in R^M \\iff (\\alpha(a_1),...,\\alpha(a_{n_R})) \\in R^N\n\\end{aligned}\n\\end{equation*}\nNote that this is an if and only if.\\\\\n(iii) For all $c \\in \\mathcal{C}$, we need \n\\begin{equation*}\n\\begin{aligned}\n\\alpha(c^M) = c^N\n\\end{aligned}\n\\end{equation*}\nAs anyone could expect, a surjective embedding $\\mathcal{M} \\to \\mathcal{N}$ is also called an \\emph{isomorphism} of $\\mathcal{M}$ onto $\\mathcal{N}$.\n\\end{defi}\n\n(1.6) Exercise. Let $G_1,G_2$ be groups, regarded as $L_{gp}$-structures.\\\\\nCheck that $G_1 \\cong G_2$ in the usual algebra sense, if and only if there is an isomprhism $\\alpha:G_1\\ \\to G_2$ in the sense of above definition 1.5.\n\n\\newpage\n\n\\section{Terms, formulae, and their interpretations}\nIn addition to the symbols of $L$, we also have:\\\\\n(i) infinitely many variables, $\\{x_i\\}_{i \\in I}$;\\\\\n(ii) logical connectives, $\\wedge,\\neg$ (also express $\\vee, \\to, \\leftrightarrow$);\\\\\n(iii) quantifier $\\exists$ (also express $\\forall$);\\\\\n(iv) punctuations $(,)$.\n\n\\begin{defi} (2.1) \\\\\n\\emph{$L$-terms} are defined recursively as follows:\\\\\n$\\bullet$ any variable $x_i$ is a term;\\\\\n$\\bullet$ any constant symbol is a term;\\\\\n$\\bullet$ for any $f \\in \\mathcal{F}$, \n\\begin{equation*}\n\\begin{aligned}\nf(t_1,...,t_{n_f})\n\\end{aligned}\n\\end{equation*}\nfor any terms $t_1,...,t_{n_f}$ is a term;\\\\\n$\\bullet$ nothing else is a term.\n\\end{defi}\n\nNotation: we write $t(x_1,...,x_n)$ to mean that the variables appearing in $t$ are among $x_1,..,x_n$.\n\n\\begin{eg}\nIn $\\mathcal{R} = <\\R,\\cdot,-1,1>$,\\\\\n$\\bullet$ $(\\cdot (x_1,x_2),x_3)$ is a term ($x_1 \\cdot x_2) \\cdot x_3$);\\\\\n$\\bullet$ $(\\cdot (1,x_1))^{-1}$ is a term ($1 \\cdot x)^{-1}$.\n\\end{eg}\n\n\\begin{defi} (2.2)\\\\\nIf $\\mathcal{M}$ is an $L$-structure, to each $L$-term $t(x_1,...,x_k)$ we assign a function\n\\begin{equation*}\n\\begin{aligned}\nt^M: M^k \\to M\n\\end{aligned}\n\\end{equation*}\ndefined as follows:\\\\\n(i) If $t = x_i, t^M [a_1,...,a_k] = a_i$;\\\\\n(ii) If $t=c$ is a constant, $t^M [a_1,...,a_k] = c^m$;\\\\\n(iii) If $t=f(t_1(x_1,...,x_k),...,t_{n_f}(x_1,...,x_k))$, \n\\begin{equation*}\n\\begin{aligned}\nt^M (a_1,...,a_k) = f^M(t_1^M(a_1,...,a_k),...,t_{n_f}^M(a_1,...,a_k))\n\\end{aligned}\n\\end{equation*}\n\\end{defi} \n\n---Lecture 2---\n\nNo lecture this friday (12th Oct)! Will have an extra one on Monday 22 Oct at 12 (MR12).\n\nFirst example class: Monday 29th Oct at 12.\n\nInfo on course and notes on $http:\\\\users.mct.open.ac.uk/sb27627/MT.html$ (it seems that it only comes after lecture, and is hand-written, so this notes still continues), or google \\emph{Silvia Barbina MCT} and follow link \\emph{Part III Model Theory} on lecturer's homepage.\n\n\\begin{rem}\n    (The lecturer forgot about this last time) Any language $L$ includes an equality symbol $=$.\n\\end{rem}\n\nLast time we assigned a function $t^m$. In $L_{gp}$, the term $x_2 \\cdot x_3$ can be described as, say $t_1(x_1,x_2,x_3),t_2(x_1,x_2,x_3,x_4),...$.\\\\\nThen the term $x_2 \\cdot x_3$ can be assigned to functions $t_1^M:M^3\\to M:(a_1,a_2,a_3) \\to (a_2 \\cdot a_3)$, or $t_2^M: M^4 \\to M: (a_1,a_2,a_3,a_4) \\to (a_2 \\cdot a_3)$. These syntactic things are not really important -- we just have to know that there is a corresponding action for each term.\n\nWe now define the \\emph{complexity} of a term $t$ to be the number of symbols of $L$ occuring in $t$.\n\nFact (2.3): Let $\\mathcal{M}$ and $\\mathcal{N}$ be $L$-structures, and let $\\alpha:\\mathcal{M} \\to \\mathcal{N}$ be an embedding. For any $L$-term $t(x_1,...,x_k)$ and $a_1,...,a_k \\in M$, we have\n\\begin{equation*}\n    \\begin{aligned}\n        \\alpha(t^M(a_1,...,a_k)) = t^N(\\alpha(a_1),...,\\alpha(a_k))\n    \\end{aligned}\n\\end{equation*}\n\\begin{proof}\nProve by induction on complexity of $t$.\\\\\nLet $\\bar{a} = (a_1,...,a_k)$ and $\\bar{x} = (x_1,...,x_l)$. Then:\\\\\n(i) if $t=x_i$ is a variable, then $t^M(\\bar{a}) = a_i$, and $t^N(\\alpha(a_1),...,\\alpha(a_k)) = \\alpha(a_i)$, so the conclusion holds;\\\\\n(ii) if $t=c$ is a constant, then $t^M(\\bar{a}) = c^M$, and $t^N(\\alpha(\\bar{a})) = c^N$ by definition of a term. The key here is that, since $\\alpha$ is an embedding we have $\\alpha(c^M) = c^N$;\\\\\n(iii) if $t = f(t_1(\\bar{x},...,t_{n_f}(\\bar{x})))$, then\n\\begin{equation*}\n    \\begin{aligned}\n    \\alpha(f^M(t_1^M(\\bar{a}),...,t_{n_f}(\\bar{a}))) &= f^N(\\alpha (t_1^M(\\bar{a})),...,\\alpha(t_{n_f}^M(\\bar{a})))\n    \\end{aligned}\n\\end{equation*}\nas $\\alpha$ is an embedding. But $t_1(\\bar{x}),...,t_{n_f}(\\bar{x})$ have lower complexity than $t$, so the inductive hypothesis applies.\n\\end{proof}\n\nExercise (2.4): conclude the proof of the above fact.\\\\\n(Actually is it not done?)\n\n\\begin{defi} (2.5)\\\\\n    The set of \\emph{atomic formulas} of $L$ is defined as follows:\\\\\n    (i) if $t_1,t_2$ are $L$-terms, then $t_1 = t_2$ is an atomic formula;\\\\\n    (ii) if $R$ is a relation symbol, and $t_1,...,t_{n_R}$ are $L$-terms, then $R(t_1,...,t_{n_R})$ is an atomic formula;\\\\\n    (iii) nothing else is an atomic formula.\n\\end{defi}\n\n\\begin{defi} (2.6)\\\\\n    The set of $L$-formulas is defined as follows:\\\\\n    (i) any atomic formula is an $L$-formula;\\\\\n    (ii) if $\\phi$ is an $L$-formula, then so is $\\neg \\phi$;\\\\\n    (iii) if $\\phi$ and $\\psi$ are $L$-formulas, then so is $\\phi \\wedge \\psi$;\\\\\n    (iv) if $\\phi$ is an $L$-formula, for any $i \\geq 1$, $\\exists x_i \\phi$ is a formula;\\\\\n    (v) nothing else is a formula (note that $\\forall$ can be constructed by $\\neg$ and $\\exists$).\n\\end{defi}\n\n\\begin{eg}\n    In $L_{gp}$, $x_1\\cdot x_1 = x_2$, or $x_1\\cdot x_2=1$ are both atomic formulas;\\\\\n    $\\exists x_1(x_1 \\cdot x_2) = 1$ is an $L$-formula, but (obviously) not atomic.\n\\end{eg}\n\nA variable occurs \\emph{freely} in a formula if it does not occur within the scope of a quantifier $\\exists$. We sometimes also say that the variable is \\emph{free} (from Part II Logic and Sets). Otherwise we say the variable is \\emph{bound}.\n\nWe'll use the convention that no variable occurs both freely and as a bound variable in the same formula.\n\nA \\emph{sentence} is a formula with no free variables. For example, $\\exists x_1\\exists x_2 (x_1\\cdot x_2=1)$ is an $L_{gp}$-sentence.\n\nNotation: $\\phi(x_1,...,x_k)$ means that the free variables in $\\phi$ are among $x_1,...,x_k$.\n\nNow we introduce a long and inductive (and also in logic and sets) definition for which sentences are \\emph{true}:\n\\begin{defi} (2.7)\\\\\n    Let $\\phi(x_1,...,x_k)$ be an $L$-formula, let $\\mathcal{M}$ be an $L$-structure, and let $\\bar{a} = a_1,...,a_k$ be elements of $\\mathcal{M}$.\\\\\n    We define $\\mathcal{M} \\vDash \\phi(\\bar{a})$ (syntactic implication, read as \\emph{M models $\\phi(\\bar{a})$}) as follows:\\\\\n    (i) if $\\phi$ is $t_1=t_2$, then $\\mathcal{M} \\vDash \\phi(\\bar{a}) \\iff t_1^M(\\bar{a}) = t_2^M(\\bar{a})$;\\\\\n    (ii) if $\\phi$ is $R(t_1,...,t_{n_R})$, then $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff\n    \\begin{equation*}\n        \\begin{aligned}\n            \\left(t_1^M(\\bar{a}),...,t_{n_R}^M(\\bar{a})\\right) \\in R^M\n        \\end{aligned}\n    \\end{equation*}\n    (iii) if $\\phi$ is a conjunction, say $\\psi \\wedge \\chi$, then $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff $\\mathcal{M} \\vDash \\psi(\\bar{a})$ and $\\mathcal{M} \\vDash \\chi(\\bar{a})$;\\\\\n    (iv) if $\\phi$ is $\\exists x_j \\chi(x_1,...,x_k,x_j)$ (where we'll assume that $x_j$ is not one of the free variables $x_1,...,x_k$), then $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff there exists $b \\in \\mathcal{M}$ s.t. $\\mathcal{M} \\vDash \\chi(a_1,...,a_k,b)$;\\\\\n    (v) (lecture forgets this, this should probably be more in front rather than in the end) if $\\phi$ is $\\neg \\psi$, then $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff $\\mathcal{M} \\not\\vDash \\psi(\\bar{a})$.\n\\end{defi}\n\n\\begin{eg}\n    Consider $\\mathcal{R} = \\bra \\R^*,\\cdot ,-1,1\\ket$, the multiplicative group of non-negative reals, and suppose we have $\\phi(x_1) = \\exists x_2 (x_2 \\cdot x_2 = x_1)$, then $\\mathcal{R} \\vDash \\phi(1)$, but $\\mathcal{R} \\not\\vDash \\phi(-1)$.\n\\end{eg}\n\nNotation (2.8) (useful abbreviations, closer to real life. The precise formulas are not that important -- the abbreviations mean what we expect in real life):\\\\\n$\\bullet$ $\\phi \\vee \\psi$ for $\\neg(\\neg\\phi \\wedge \\neg \\psi)$;\\\\\n$\\bullet$ $\\phi \\to \\psi$ for $\\neg \\phi \\vee \\psi$;\\\\\n$\\bullet$ $\\phi \\leftrightarrow \\psi$ for $(\\phi \\to \\psi) \\wedge (\\psi \\to \\phi)$;\\\\\n$\\bullet$ $\\forall x_i \\phi$ for $\\neg \\exists x_i (\\neg \\phi)$.\n\n\\begin{prop} (2.9)\\\\\n    Let $\\mathcal{M}$ and $\\mathcal{N}$ be $L$-structures, and let $\\alpha: \\mathcal{M} \\to \\mathcal{N}$ be an embedding.\\\\\n    Let $\\phi(\\bar{x})$ be an atomic(!) formula, and $\\bar{a} \\in M^{|\\bar{x}|}$, here $|\\bar{x}|$ means the length of the tuple $\\bar{x}$ (from now on, when we write a tuple like $\\bar{a}$, we will assume that it has the correct length without explicitly stating that), then\n    \\begin{equation*}\n        \\begin{aligned}\n            \\mathcal{M} \\vDash \\phi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(\\alpha(\\bar{a}))\n        \\end{aligned}\n    \\end{equation*}\n\\end{prop}\n\nQuestion: if $\\phi$ is an $L$-formula, not necessarily atomic, does (2.9) still hold? (the answer is no!)\n\n---Lecture 3---\n\nLecturer wants to reiterate that her email address is $silvia.barbina@open.ac.uk$.\\\\\nJust bring the work along. Unfortunately lecturer doesn't have an office here, so no pigeonhole.\\\\\nCheck website for example sheet 1!\n\nAdditional assumption: assume the set of variables in a language are indexed by a linearly ordered set.\\\\\nIn definition 2.7 we defined what it means for $\\mathcal{M} \\vDash\\phi(\\bar{a})$, in particular we defined: if $\\phi \\equiv \\neg \\chi$, then $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff $\\mathcal{M} \\not\\vDash \\chi(\\bar{a})$. Here by $\\mathcal{M} \\vDash \\phi(\\bar{a})$ we mean $\\mathcal{M} \\vDash \\neg\\chi(\\bar{a})$, and $\\chi(\\bar{a})$ is \\emph{shorter} than $\\phi(\\bar{a})$, so this definition by induction works.\n\nNow let's go back to a sketch proof of (2.9).\n\\begin{proof}\n    There are two cases:\\\\\n    $\\bullet$ $\\phi(\\bar{x})$ is of the form $t_1(\\bar{x}) = t_2(\\bar{x})$ where $t_1,t_2$ are terms. Use Fact (2.3). (exercise on example sheet)\\\\\n    $\\bullet$ $\\phi(\\bar{x})$ is of the form $R(t_1(\\bar{x}),...,t_{n_R} (\\bar{x}))$. Then $\\mathcal{M} \\vDash R(t_1(\\bar{a}),...,t_{n_R}(\\bar{a}))$ if and only if ... (lecturer says work this out by yourself. Basically the induction step).\n\\end{proof}\n\n\\begin{prop} (2.10)\\\\\n    Exercise: show that prop (2.9) holds if $\\phi(\\bar{x})$ is a formula without quantifiers (a quantifier-free formula).\\\\\n    (I guess that also suggests when does it not hold for general formulas -- see below).\n\\end{prop}\n\n\\begin{eg} (2.11, Do embeddings preserve all formulas? No.)\\\\\nLet $\\mathcal{Z} = (\\Z,<)$ an $L_{lo}-$structure, $\\mathcal{Q}=(\\Q,<)$ also an $L_{lo}-$structure. Then\n\\begin{equation*}\n    \\begin{aligned}\n        \\alpha: &\\Z \\to \\Q\\\\\n        &n \\to n\n    \\end{aligned}\n\\end{equation*}\nis an embedding (check). But:\n\\begin{equation*}\n    \\begin{aligned}\n        \\phi(x_1,x_2) \\equiv \\exists x_3(x_1<x_3 \\wedge x_3 < x_2)\n    \\end{aligned}\n\\end{equation*}\nNow $\\mathcal{Q} \\vDash \\phi(1,2)$ but $\\mathcal{Z} \\not\\vDash \\phi(1,2)$.\n\\end{eg}\n\nFact (2.12) (From now on we'll stop saying that $\\mathcal{M},\\mathcal{N}$ are $L$-structures etc to save time) Let $\\alpha: \\mathcal{M} \\to \\mathcal{N}$ be an isomorphism. Then if $\\phi(\\bar{x})$ is an $L$-formula, and $\\bar{a} \\in M^{|\\bar{x}|}$, then\n\\begin{equation*}\n    \\begin{aligned}\n        \\mathcal{M} \\vDash \\phi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(\\alpha(\\bar{a}))\n    \\end{aligned}\n\\end{equation*}\nThe proof is left as an exercise (another one).\n\n\\newpage\n\n\\section{Theories and Elementarity}\n\nThis is where the core materials begin.\n\nThroughout this chapter, let $L$ be a language, $\\mathcal{M},\\mathcal{N}$ be $L$-structures.\n\n\\begin{defi} (3.1)\\\\\n    An \\emph{$L$-theory} $T$ is a set of $L$-sentences.\\\\\n    $\\mathcal{M}$ is a \\emph{model} of $T$ if $\\mathcal{M} \\vDash \\sigma$ for all $\\sigma \\in T$. We write $\\mathcal{M} \\vDash T$.\\\\\n    The class of all the models of $T$ is written $Mod(T)$.\\\\\n    The \\emph{theory of $\\mathcal{M}$} is the set \n    \\begin{equation*}\n        \\begin{aligned}\n            Th(\\mathcal{M}) = \\{\\sigma:\\sigma \\text{ is an } L-\\text{sentence and } \\mathcal{M} \\vDash \\sigma\\}\n        \\end{aligned}\n    \\end{equation*}\n\\end{defi}\n\n\\begin{eg} (3.2)\\\\\n    Let $T_{gp}$ be the set of $L_{gp}$-sentences:\\\\\n    (i) $\\forall x_1x_2x_3 (x_1 \\cdot (x_2 \\cdot x_3) = (x_1\\cdot x_2) \\cdot x_3)$;\\\\\n    (ii) $\\forall x_1 (x_1 \\cdot 1 = 1 \\cdot x_1 = x_1)$;\\\\\n    (iii) $\\forall x_1 (x_1 \\cdot x_1^{-1} = x_1^{-1} \\cdot x_1 = 1)$.\\\\\n    Clearly, for a group $G$, $G \\vDash T_{gp}$ (as they are just the group axioms). However, for a specific group $G$, clearly the theory of it, $Th(G)$ is lartger than $T_{gp}$.\n\\end{eg}\n\n\\begin{defi} (3.3)\\\\\n    $\\mathcal{M}$ and $\\mathcal{N}$ are \\emph{elementarily equivalent} if $Th(\\mathcal{M}) = Th(\\mathcal{N})$.\\\\\n    We write $\\mathcal{M} \\equiv \\mathcal{N}$.\\\\\n    Clearly, if $\\mathcal{M} \\simeq \\mathcal{N}$ ($\\simeq$ means isomorphism), then $\\mathcal{M} \\equiv \\mathcal{N}$.\\\\\n    But if $\\mathcal{M}$ and $\\mathcal{N}$ are not isomorphic, establishing whether $\\mathcal{M} \\equiv \\mathcal{N}$ can be highly non-trivial!\\\\\n    We'll see $(\\Q,<) \\equiv (\\R,<)$ as $L_{lo}-$structures(!).\n\\end{defi}\n\n\\begin{defi} (3.4)\\\\\n    (i) An embedding $\\beta: \\mathcal{M} \\to \\mathcal{N}$ is \\emph{elementary} if for all formulas $\\phi(\\bar{x})$ and $\\bar{a} \\in M^{|\\bar{x}|}$,\n    \\begin{equation*}\n        \\begin{aligned}\n            \\mathcal{M} \\vDash \\phi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(\\beta(\\bar{a}))\n        \\end{aligned}\n    \\end{equation*}\n    (ii) If $M \\subseteq N$, and $id:\\mathcal{M} \\to \\mathcal{N}$ is an embedding, then $\\mathcal{M}$ is a \\emph{substructure} of $\\mathcal{N}$.\\\\\n    (iii) If $M \\subseteq N$ and $id:\\mathcal{M} \\to \\mathcal{N}$ is an \\emph{elementary embedding}, then $\\mathcal{M}$ is said to be an \\emph{elementary substructure} of $\\mathcal{N}$, written as $\\mathcal{M} \\preccurlyeq \\mathcal{N}$.\n\\end{defi}\n\n\\begin{eg} (3.5)\\\\\n    Let $\\mathcal{M} = [0,1] \\subseteq \\R$, an $L_{lo}-$structure where $<$ is the usual order;\\\\\n    Let $\\mathcal{N} = [0,2] \\subseteq \\R$, also an $L_{lo}-$structure with the same $<$.\\\\\n    Then $\\mathcal{M} \\simeq \\mathcal{N}$ as $L_{lo}-$structures. So $\\mathcal{M} \\equiv \\mathcal{N}$ (since they are isomoprhic).\\\\\n    Also, $\\mathcal{M} \\subseteq \\mathcal{N}$ (read as \\emph{is a substructure of}), since the ordering $<$ coincides on $\\mathcal{M}$ and $\\mathcal{N}$. \\emph{However}, $\\mathcal{M} \\not\\preccurlyeq \\mathcal{N}$, since if we pick the formula $\\phi(x) \\equiv \\exists y (x<y)$, then $\\mathcal{N} \\vDash \\phi(1)$, but $\\mathcal{M} \\not\\vDash \\phi(1)$.\n\\end{eg}\n\n\\begin{defi} (3.6)\\\\\n    Let $\\mathcal{M}$ be an $L$-structure, $A \\subseteq M$, then\n    \\begin{equation*}\n        \\begin{aligned}\n            L(A) = L \\cup \\{c_a:a \\in A\\}\n        \\end{aligned}\n    \\end{equation*}\n    (where $c_a$ are constant symbols). An interpretation of $\\mathcal{M}$ as an $L$-structure extends to an interpretation of $\\mathcal{M}$ as an $L(A)$-structure in the obvious way, i.e. $c_a^M = a$.\\\\\n    In this context, the elements of $A$ are called \\emph{parameters}.\\\\\n    If $\\mathcal{M}$ and $\\mathcal{N}$ are two structures, and $A \\subseteq M \\cap N$, then\n    \\begin{equation*}\n        \\begin{aligned}\n            \\mathcal{M} \\equiv_A \\mathcal{N}\n        \\end{aligned}\n    \\end{equation*}\n    where we mean $\\mathcal{M},\\mathcal{N}$ satisfy exactly the same $L(A)$ sentences.\n\\end{defi}\n\n---Lecture 4---\n\nReminder: we have a lecture next Monday (22nd Oct)!\n\n\\begin{prop}\n    It turns out that, $\\mathcal{M} \\preccurlyeq \\mathcal{N} \\iff \\mathcal{M} \\equiv_M \\mathcal{N}$ (where $M$ is the domain of $\\mathcal{M}$).\n\\end{prop}\n\n\\begin{lemma} (3.8, Tarski-Vaught test)\\\\\n    Let $\\mathcal{N}$ be an $L$-structure, let $A \\subseteq N$. The follwing are equivalent:\\\\\n    (i) $A$ is the domain of a structure $\\mathcal{M}$ s.t. $\\mathcal{M} \\preccurlyeq \\mathcal{N}$;\\\\\n    (ii) if $\\phi(x) \\in L(A)$ (with an abuse of notations $\\phi(x,c_{a_1},...,c_{a_n}) = \\phi(x,a_1,...,a_n)$), if $\\mathcal{N} \\vDash \\exists x \\phi(x)$, then $\\mathcal{N} \\vDash \\phi(b)$ for some $b \\in A$.\n    \\begin{proof}\n        (i) $\\implies$ (ii): Suppose $\\mathcal{N} \\vDash \\exists x \\phi(x)$. Then by elementarity, $\\mathcal{M} \\vDash \\exists x \\phi(x)$, and so $\\mathcal{M} \\vDash \\phi(b)$ for $b \\in \\mathcal{M}$. So (again by elementarity), $\\mathcal{N} \\vDash \\phi(b)$.\\\\\n        (ii) $\\implies$ (i): This is the harder direction. First we prove that $A$ is the domain of a substructure $\\mathcal{M} \\subseteq \\mathcal{N}$.\\\\\n        By Sheet 1 Q4, it suffices to check:\\\\\n        (a) For each constant $c$, $c^N \\in A$;\\\\\n        (b) For each function symbol $f$, $f^N(\\bar{a}) \\in A$ (for all $\\bar{a} \\in A^{n_R}$);\\\\\n        For (a), use property (ii) with $\\exists x (x=c)$.\\\\\n        For (b), use property (ii) with the formula $\\exists x (f(\\bar{a}) = x)$.\\\\\n        So we now have $\\mathcal{M} \\subseteq \\mathcal{N}$, and domain of $\\mathcal{M}$ is $A$. But we actually want to prove that $\\mathcal{M} \\preccurlyeq \\mathcal{N}$. Now let $\\chi(\\bar{x})$ be an $L$-formula.\\\\\n        We want to show that for $\\bar{a} \\in A^{|\\bar{x}|}$ $\\mathcal{M} \\vDash \\chi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\chi(\\bar{a})$ (*).\\\\\n        By induction on the complexity of $\\chi(\\bar{x})$:\\\\\n        $\\bullet$ if $\\chi(\\bar{x})$ is atomic, (*) follows from $\\mathcal{M} \\subseteq \\mathcal{N}$ (since $\\mathcal{M}$ is a substructure!);\\\\\n        $\\bullet$ if $\\chi(\\bar{x})$ is $\\neg \\psi(\\bar{x})$ or $\\chi(\\bar{x})$ is $\\psi(\\bar{x})\\wedge \\xi(\\bar{x})$, it's a straightforward induction;\\\\\n        $\\bullet$ (interesting case) if $\\chi(\\bar{x}) = \\exists y \\psi(\\bar{x},y)$ where $\\psi(\\bar{x},y)$ is an $L$-formula, suppose that $\\mathcal{M} \\vDash \\chi(\\bar{a})$, then $\\mathcal{M} \\vDash \\exists y \\psi(\\bar{a},y)$, hence $\\mathcal{M} \\vDash \\psi(\\bar{a},b)$ for some $b \\in A = \\dom (\\mathcal{M})$ (this is the definition of truth).\\\\\n        But then $\\mathcal{N} \\vDash \\psi(\\bar{a},b)$ by inductive hypothesis, so $\\mathcal{N} \\vDash \\chi(\\bar{a})$.\\\\\n        Now let $\\mathcal{N} \\vDash \\chi(\\bar{a})$, i.e. $\\mathcal{N} \\vDash \\exists y \\psi (\\bar{a},y)$ (we find a \\emph{witness} for it). By property (ii), $\\mathcal{N} \\vDash \\psi(\\bar{a},b)$ for some $b \\in A = \\dom(\\mathcal{M})$.\\\\\n        Again by inductive hypothesis, we have $\\mathcal{M} \\vDash \\psi(\\bar{a},b)$, and so in particular, $\\mathcal{M} \\vDash \\chi(\\bar{a})$ as it has got a witness there.\n    \\end{proof}\n\\end{lemma}\n\n\\begin{rem} (3.9)\\\\\n    Even more assumptions: let's assume that the set of variables is countably infinite. Then:\\\\\n    $\\bullet$ the cardinality of the set of $L$-formulas is $|L|+\\omega$ (where by $|L|$ we mean the number of symbols. For example, $|L_{gp}| = 3$, $|L_{lo}| = 1$), where we abuse another notation that we use $\\omega$ as cardinals (rather than ordinals) (note that the formulas are just strings of finite length);\\\\\n    $\\bullet$ if $A$ is a set of parameters in some structure, the cardinality of the set $L(A)$ is $|A|+|L|+\\omega$, where by $+$ here we merely mean $\\max\\{|L|,|A|,\\omega\\}$ (instead of addition), and same for the $+$ above.\n\\end{rem}\n\n\\begin{defi} (3.10)\\\\\n    Let $\\lambda$ be an ordinal. Then \\emph{a chain of length} $\\lambda$ of sets is a sequence $\\bra M_i : i < \\lambda \\ket$, where $M_i \\subseteq M_j$ for all $i \\leq j < \\lambda$.\\\\\n    A chain of $L$-structures is a sequence: $\\bra \\mathcal{M}_i: i < \\lambda \\ket$ s.t. $\\mathcal{M}_i \\subseteq \\mathcal{M}_j$ (note that it's substructure here) for $i \\leq j < \\lambda$.\\\\\n    The \\emph{union} of this chain is the $L$-structure $\\mathcal{M}$ defined as follows:\\\\\n    $\\bullet$ the domain is $\\bigcup_{i<\\lambda} M_i$ (when you think of this, you can always start with the case $\\lambda = \\omega$);\\\\\n    $\\bullet$ for constants $c$, $c^M = c^{M_i}$ for any $i<\\lambda$ (this is well defined, because of the substructure condition above);\\\\\n    $\\bullet$ if $f$ is a function symbol, $\\bar{a} \\in M^{|n_f|}$ (why the mod sign here), $f^M \\bar{a} = f^{M_i} \\bar{a}$ where $i$ is s.t. $\\bar{a} \\in M_i^{|n_f|}$;\\\\\n    $\\bullet$ if $R$ is a relation symbol, then $R^M = \\bigcup_{i < \\lambda} R^{M_i}$.\n\\end{defi}\n\n\\begin{thm} (3.11, Downward L$\\ddot{o}$wenheim-Skolem theorem)\\\\\n    (Recall that in part II Logic and Set Theory we had the countable version of this)\\\\\n    Let $\\mathcal{N}$ be an $L$-structure, and $|\\mathcal{N}| \\geq |L| + \\omega$. Let $A \\subseteq N$. Then for every cardinal $\\lambda$ s.t. $|L|+|A|+\\omega \\leq \\lambda \\leq |\\mathcal{N}|$, there is $\\mathcal{M} \\preccurlyeq \\mathcal{N}$ s.t.\\\\\n    (i) $A \\subseteq M$;\\\\\n    (ii) $|\\mathcal{M}| = \\lambda$.\n\n    \\includegraphics[scale=0.5]{image/Model_01.png}\n\n    (It helps to think about the case $|A| = \\omega$ and $|N|$ is uncountable.)\\\\\n    A quick example how this could be useful (we'll go very sloppy here): think of $(\\C,+,\\cdot,-,\\cdot^{-1},0,1)$ as a field. Consider $\\Q \\subseteq \\C$ (both as subset and substructure). Note that algebraic closeness is a property of $\\C$. By downward L$\\ddot{o}$wenheim-Skolem, there is a substructure in $\\C$ that contains $\\Q$ that is als algebraically closed (apparently, the set of algebraic numbers).\n    \\begin{proof}\n        We build a chain $\\bra A_i : i < \\lambda \\ket$, with $A_i \\subseteq N$, s.t. $|A_i| = \\lambda$.\\\\\n        (our goal: define an elementary substructure with domain $M=\\bigcup_{i < \\omega} A_i$).\\\\\n        Base case: Let $A_0 \\subseteq N$ be such that $A \\subseteq A_0$ and $|A_0| = \\lambda$.\\\\\n        Successors: At stage $i+1$, assume $A_i$ has been built, with $|A_i| = \\lambda$.\\\\\n        Let $\\bra \\phi_k(x): k < \\lambda \\ket$ be an enumeration of those $L(A_i)$-formulas such that $\\mathcal{N} \\vDash \\exists x \\phi_k(x)$. Let $a_k$ be such that $\\mathcal{N} \\vDash \\phi_k(a_k)$, and let $A_{i+1} = A_i \\cup \\{a_k: k < \\lambda\\}$ (basically, with those witnesses added). Then $|A_{i+1}| = \\lambda$ (note that we haven't increased the size).\\\\\n        Now let $M = \\bigcup_{i < \\omega} A_i$ (note the subscript range). We use lemma (3.8) to show that $M$ is the domain of $\\mathcal{M} \\preccurlyeq \\mathcal{N}$, and $|M| = \\lambda$.\n        We're running out of time, so we'll continue next Monday.\\\\\n        \n        ---Lecture 5---\\\\\n        Solutions to worksheet 1: either take along to lecture on Friday, or email them to $silvia.barbina@open.ac.uk$.\n\n        Let's continue with the proof:\n\n        \\includegraphics[scale=0.5]{image/Model_02.png}\n\n        Start with $A_0 \\subset N$, $A \\subseteq A_0$, $|A_0| = l$. The idea is to define $\\bra A_i: i <\\omega \\ket$ so that $M = \\cup_{i < \\omega}A_i$ satisfies (ii) via the TV test (3.8).\\\\\n        List all formulas $\\phi(x,\\bar{a})$ ($\\bar{a}$ is a tuple in $A_0$), and $\\mathcal{N} \\vDash \\phi(b,\\bar{a})$ for some $b$.\\\\\n        Add each such $b$ to $A_0$ (one for each such $\\phi$).\\\\\n        Let $A_1 =A_0 \\cup \\{$ all thes $b$'s$\\}$.\\\\\n        Repeat for formulas $\\phi(x,\\bar{a})$ where $\\bar{a}$ is in $A_1$,...\\\\\n        Eventually, $\\bra A_i: i<\\omega\\ket$ is such that $M = \\cup_{i < \\omega} A_i$ is as required (i.e. $M$ is the domain of some elementary substrucutre of $\\mathcal{N}$ that we need).\\\\\n        We claim that $M$ satisfies condition (ii) in Lemma (3.8): Let $\\mathcal{N} \\vDash \\exists x \\psi(x,\\bar{a})$, where $\\bar{a}$ is a tuple in $M$. Then $\\bar{a}$ is a \\emph{finite} tuple, so there is an $i$ s.t. $\\bar{a}$ is in $A_i$.\\\\\n        Then $A_{i+1}$, by construction, contains $b$ s.t. $\\mathcal{N} \\vDash \\phi(b,\\bar{a})$. But $A_{i+1} \\subseteq M, b \\in M$.\\\\\n        Then apply (3.8) we're done.\n    \\end{proof}\n\\end{thm}\n\n\\newpage\n\n\\section{Two relational structures}\n\n\\begin{defi} (4.1, dense linear orders)\\\\\n    A \\emph{linear order} is an $L_{lo} = \\{<\\}$-structure such that:\\\\\n    (i) $\\forall x \\neg (x<x)$;\\\\\n    (ii) $\\forall xyz ((x<y \\wedge y<z) \\to x<z)$;\\\\\n    (iii) $\\forall xy((x<y) \\vee (y<x) \\vee x=y)$ (total).\\\\\n    A linear order is \\emph{dense} if, in addition, it also satisfies:\\\\\n    (iv) $\\exists xy (x<y)$;\\\\\n    (v) $\\forall xy, (x<y \\to \\exists z (x<z \\wedge z<y))$ (density).\\\\\n    A linear order has no endpoints if, in addition, \\\\\n    (vi) $\\forall x (\\exists y(x<y) \\wedge \\exists z(z<x))$.\\\\\n    We use $T_{dlo}$ to denote the theory that includes all axioms (i) to (vi), and $T_{lo}$ is the theory that includes axioms (i) to (iii) only.\n\\end{defi}\n\n\\begin{rem}\n    (iv) and (v) imply that if $\\mathcal{M} \\vDash T_{dlo}$, then $|\\mathcal{M}| \\geq \\omega$.\n\\end{rem}\n\n\\begin{defi} (4.2)\\\\\n    If $\\mathcal{M},\\mathcal{N} \\vDash T_{lo}$, then an \\emph{injective} map $p:A \\subseteq M \\to N$ is a \\emph{partial embedding} if $\\mathcal{M} \\vDash a<b \\implies \\mathcal{N} \\vDash p(a) < p(b)$.\\\\\n    In particular, if $|\\dom(p)| < \\omega$, then $p$ is a \\emph{finite} partial embedding.\n\\end{defi}\n\n\\begin{lemma} (4.3, extension lemma)\\\\\n    Take a linear order $\\mathcal{M} \\vDash T_{lo}$, and a dense linear endpoints $\\mathcal{N} \\vDash T_{dlo}$, and let $p: M \\to N$ be a finite partial embedding. Then if $c \\in \\mathcal{M}$, there is a finite partial embedding $\\hat{p}$ s.t. $p \\subseteq \\hat{p}$ and $c \\in \\dom(\\hat{p})$.\\\\\n    (\\emph{we can always add one extra element in our embedding}.)\n    \\begin{proof}\n        \\includegraphics[scale=0.5]{image/Model_03.png}\n\n        Case 1: $c$ is greater than all elements in $\\dom(p)$. In that case, pick an element $d \\in \\mathcal{N}$ s.t. $d>b$ for all $b \\in img(p)$;\\\\\n        Case 2: $a_i<c<a_{i+1}$ where $a_i,a_{i+1} \\in \\dom(p)$. Then we choose $\\mathcal{N} \\vDash p(a_i) < d < p(a_{i+1})$, where $d$ is chosen appropriately by density (here's the case why we need $\\mathcal{N}$ to be dense;\\\\\n        Case 3: $c$ is less than all elements in $\\dom(p)$. This is similar to case 1.\n\n        Note that the ability to extend by one point allows us to embed any finite linear order into a dense linear order without endpoints.\n    \\end{proof}\n\\end{lemma}\n\n\\begin{thm} (4.4)\\\\\n    Let $\\mathcal{M},\\mathcal{N} \\vDash T_{dlo}$ s.t. $|\\mathcal{M}| = |\\mathcal{N}| = \\omega$. Let $p:A \\subseteq M \\to N$ be a finite partial embedding.\\\\\n    Then there is an isomorphism $\\pi:\\mathcal{M} \\to \\mathcal{N}$ s.t. $p \\subseteq \\pi$.\n    \\begin{proof}\n        Enumerate $M,N$, say $M=\\bra a_i:i < \\omega\\ket$, $N=\\bra b_i:i < \\omega\\ket$ (sequences of elements).\\\\\n        We define, inductively, a chain of finite partial embedding $\\bra p_i:i<\\omega\\ket$ (idea: $\\pi = \\cup_{i<\\omega} p_i$).\\\\\n        Let's start with $p_0 = p$. At stage $i+1$, suppose we are given $p_i$. We want to include $a_i$ in $\\dom p_{i+1}$, and $b_i$ in the $img(p_{i+1})$.\\\\\n        (Lecturer calls this a \\emph{back and forth} method) Forth step: By lemma 4.3, we can extend $p_i$ to $p_{i+\\frac{1}{2}}$ such that $a_i \\in \\dom(p_{i+\\frac{1}{2}})$;\\\\\n        Back step: By lemma 4.3 again applied to $(p_{i+\\frac{1}{2}})^{-1}$ to include $b_i \\in \\dom (p_{i+1}^{-1})$ (i.e. in the range of $p_{i+1}$).\\\\\n        We claim that $p_{i+1}$ extends $p_i$ as required.\\\\\n        Let $\\pi = \\cup_{i < \\omega} p_i$. Then (check) $\\pi$ is an isomorphism (i.e. order-preserving bijection).\n    \\end{proof}\n\\end{thm}\n\n\\begin{defi} (4.5)\\\\\n    An $L$-theory is \\emph{consistent} if there is $L$-structure $\\mathcal{M}$ s.t. $\\mathcal{M} \\vDash T$.\\\\\n    If $T$ is a theory in $L$ and $\\phi$ is an $L$-sentence, then $T \\vdash \\phi$ (read as \\emph{$T$ entails $\\phi$}, note that this has nothing to do with syntactic implication) if for all $\\mathcal{M}$ such that $\\mathcal{M} \\vDash T$, we have $\\mathcal{M} \\vDash \\phi$; basically, $\\phi$ holds in any model of $T$.\\\\\n    Finally, an $L$-theory $T$ is \\emph{complete} if for all $L$-sentences $\\phi$, either $T \\vdash \\phi$ or $T \\vdash \\neg\\phi$ (see part II Logic and Set Theory); so no $L$-sentence is true in only some models of $T$ but false in the others.\\\\\n    For example, $T_{dlo}$ is complete.\n\\end{defi}\n\n---Lecture 6---\n\n\\begin{defi} (4.6)\\\\\n    A theory $T$ in a countable language with a (infinitely) countable model is \\emph{$\\omega$-categorical} if any two countable models of $T$ are isomorphic.\n\\end{defi}\n\n\\begin{coro} (4.7 of theorem (4.4))\\\\\n    $T_{dlo}$ is $\\omega$-categorical.\n    \\begin{proof}\n        If $\\mathcal{M}, \\mathcal{N} \\vDash T_{dlo}$, $|\\mathcal{M}| = |\\mathcal{N}| = \\omega$, then $\\phi$ (the empty map) is a finite partial embedding. But by theorem (4.4) we get $\\mathcal{M} \\simeq \\mathcal{N}$.\\\\\n        (We can also use any $\\{\\bra a,b\\ket\\}$ where $a \\in \\mathcal{M}$ and $b \\in \\mathcal{M}$ as initial finite partial embedding).\n    \\end{proof}\n\\end{coro}\n\n\\begin{thm} (4.8)\\\\\n    (erratum 26th Oct 2018: lecturer wants to add a condition \\emph{$T$ has no finite models}. Then the problem with (4.11) is fixed.)\\\\\n    If $T$ is an $\\omega$-categorical theory in a countable language, then $T$ is complete.\n    \\begin{proof}\n        Let $\\mathcal{M} \\vDash T$ and $\\phi$ be an $L$-sentence.\\\\\n        If $\\mathcal{M} \\vDash \\phi$, suppose $\\mathcal{N} \\vDash T$. Then by theorem (3.11) (Downward Lowenheim-Skolem), there are $\\mathcal{M}' \\preccurlyeq \\mathcal{M}$, $\\mathcal{N}' \\preccurlyeq\\mathcal{N}$ s.t. $|\\mathcal{M}'| = |\\mathcal{N}'| = \\omega$.\\\\\n        But $\\mathcal{M}' \\simeq \\mathcal{N}'$ (by $\\omega$-categoricity), so in particular $\\mathcal{M}' \\equiv \\mathcal{N}'$, and so $\\mathcal{N}' \\vDash \\phi$. By elementarity, $\\mathcal{N} \\vDash \\phi$.\\\\\n        The case $\\mathcal{M} \\vDash \\neg\\phi$ is similar.\\\\\n        (Think about if $T$ could have a finite model.)\n    \\end{proof}\n\\end{thm}\n\n\\begin{coro} (4.9)\\\\\n    $T_{dlo}$ is complete.\n\\end{coro}\n\n\\begin{defi} (4.10)\\\\\n    If $\\mathcal{M}$, $\\mathcal{N}$ are $L$-structures, a map $f$ such that $\\dom (f) \\subseteq M$ (the domain of $\\mathcal{M}$), and $img(f) \\subseteq N$ is a (partial) \\emph{elementary map} if for all $L$-formulas $\\phi(\\bar{x})$ and $\\bar{a} \\in (\\dom(f))^{|\\bar{x}|}$, then\n    $$\\mathcal{M} \\vDash \\phi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(f(\\bar{a}))$$\n\\end{defi}\n\n\\begin{rem} (4.11)\\\\\n    A map $f$ is elementary iff every finite restriction of $f$ is elementary.\\\\\n    (Why? For forward, if $f_0 \\subseteq f$ is a finite restriction that is not elementary, then for some formula $\\phi(\\bar{x})$, $\\bar{a} \\in \\dom (f_0)$, the above equivalence doesn't hold; but then that equivalence doesn't hold for $f$ either; contradiction; for backward, if $f$ is not elementary, then the above equivalence fails on a finite tuple, so the above equivalence fails on some finite restriction.)\n\\end{rem}\n\n\\begin{prop} (4.12)\\\\\n    Let $\\mathcal{M},\\mathcal{N} \\vDash T_{dlo}$, and let $p: A \\subseteq M \\to N$ be a partial embedding. Then $p$ is elementary.\\\\\n    \\begin{proof}\n        By remark (4.11), it suffices to consider $p$ finite.\\\\\n        By Downward L-S theoem (3.11), we choose $\\mathcal{M}',\\mathcal{N}'$ such that\\\\\n        (i) $|\\mathcal{M}'| = |\\mathcal{N}'| = \\omega$;\\\\\n        (ii) $\\mathcal{M}' \\preccurlyeq\\mathcal{M}$, $\\mathcal{N}' \\preccurlyeq\\mathcal{N}$;\\\\\n        (iii) $\\dom (p) \\subseteq M', img(p) \\subseteq N'$.\n\n        \\includegraphics[scale=0.5]{image/Model_04.png}\n\n        Now $p$ is a finite partial embedding between countable models, so $p$ extends to an isomorphism $\\pi:\\mathcal{M}' \\to \\mathcal{N}'$.\\\\\n        In particular, $\\pi$ is an elemntary map between $\\mathcal{M}$ and $\\mathcal{N}$.\n    \\end{proof}\n\\end{prop}\n\n\\begin{coro} (4.13)\\\\\n    $(\\Q,<) \\preccurlyeq (\\R,<)$.\\\\\n    \\begin{proof}\n        Use proposition (4.12) with $id:\\Q \\to \\R$.\n    \\end{proof}\n\\end{coro}\n\n\\begin{defi} (4.14)\\\\\n    (See Part II Logic and Set Theory)\\\\\n    Let $L_{gph} = \\{R\\}$, where $R$ is a binary relation symbol.\\\\\n    An $L_{gph}$-structure is a graph if\\\\\n    (i) $\\forall x$ $\\neg R(x,x)$;\\\\\n    (ii) $\\forall xy (R(x,y) \\leftrightarrow R(y,x))$.\n\n    An $L_{gph}$-structure is a \\href{http://modeltheory.wikia.com/wiki/Random_graph}{random graph} if it is a graph such that the following axiom-schema $(r_n)$ hold:\n\n    \\includegraphics[scale=0.5]{image/Model_05.png}\n\n    $$\\forall x_0...x_n,y_0...y_n, (\\bigwedge_{i,j=0}^n x_i \\neq y_j \\to \\exists z(\\bigwedge_{i = 0}^n (z \\neq x_i) \\wedge (z \\neq y_i) \\wedge R(z,x_i) \\wedge \\neg R(z,y_i)))$$\n\n    (iii) $\\exists xy (x\\neq y)$.\n\\end{defi}\n\n\\begin{rem} (similar to what is mentioned in the link above)\\\\\n    A random graph is infinite. Given a finite subset, we can always find a vertex that is connected to every vertex in the subset (likewise for not connected).\n\\end{rem}\n\n\\begin{fact} (4.15)\\\\\n    There is a random graph.\n    \\begin{proof}\n        Let the domain be $\\omega$, let $i,j \\in \\omega$ such that $i < j$. Write $j$ as a sum of distinct powers of $2$. Then $\\{i,j\\}$ is an edge iff $2^i$ appears in the sum.\\\\\n        As an exercise, prove that $\\omega$ with this definition of $R$ is indeed a random graph.\n    \\end{proof}\n\\end{fact}\n\n\\begin{defi} (4.16, or more precisely just notations)\\\\\n    $T_{gph} = \\{$axioms (i), (ii)$\\}$, $T_{rg} = T_{gph} \\cup \\{$(iii), ($r_n$) $:n \\in \\omega\\}$.\\\\\n    If $\\mathcal{M},\\mathcal{N} \\vDash T_{gph}$, a partial embedding is an injection $p: A \\subseteq M \\to N$ s.t. $\\mathcal{M} \\vDash R(p(a),p(b)) \\iff \\mathcal{N} \\vDash R(a,b)$ for all $a,b$ in the domain.\n\\end{defi}\n\n\\begin{lemma} (4.17)\\\\\n    Let $\\mathcal{M} \\vDash T_{gph},\\mathcal{N} \\vDash T_{rg}$, let $p:A \\subseteq M \\to N$ be a finite partial embedding, and let $c \\in M$.\\\\\n    Then there is a map $\\hat{p}:\\hat{A} \\subseteq M \\to N$ such that $\\hat{p}$ is a partial embedding, $c \\in \\dom \\hat{p}$, $p\\subseteq \\hat{p}$.\\\\\n    (This is like another extension lemma.)\\\\\n    We'll prove this next time.\n    \n    ---Lecture 7---\n\n    Last time we defined what a random graph is (in this course). We also defined what is a partial embedding in this theory (just preserves all edges).\\\\\n    Let's continue with the proof of the lemma now. Let $c \\in M$, $c \\not\\in \\dom(p)$.\n\n    \\includegraphics[scale=0.5]{image/Model_06.png}\n\n    Find $d \\in N$ such that $\\mathcal{N} \\vDash R(d,p(a)) \\iff \\mathcal{M} \\vDash R(c,a)$.\n\\end{lemma}\n\n\\begin{thm} (4.18)\\\\\n    Let $\\mathcal{M},\\mathcal{N} \\vDash T_{rg}$ and $|\\mathcal{M}| = |\\mathcal{N}| = \\omega$, and $P:A \\subseteq M \\to N$ is a finite partial embedding.\\\\\n    Then $\\mathcal{M} \\simeq \\mathcal{N}$, by an isomorphism that extends $p$.\n    \\begin{proof}\n        Same as proof of Theorem (4.4) (there is only one model of $T_{dlo}$ up to isomorphism), but with lemma (4.17) instead of lemma (4.3).\n    \\end{proof}\n\\end{thm}\n\n\\begin{coro} (4.19)\\\\\n    $T_{rg}$ is $\\omega$-categorical (see definition (4.6) -- this is just a restatement of the theorem above) and complete.\\\\\n    In particular, every finite partial embedding between models of $T_{rg}$ is an elementary map.\n\\end{coro}\n\n\\begin{rem}\n    The unique (up to isomorphism) model of $T_{rg}$ is \\emph{the} countable random graph, or the \\emph{Rado} graph.\\\\\n    It is universal w.r.t. finite and countable graphs (i.e. it embeds all).\\\\\n    Another nice property (which you are not required to see this immediately -- it is far from trivial) \\emph{ultrahomogeneous}, i.e. every isomorphism between finite substructures extends to an automorphism of the whole graph.\\\\\n    Google \\emph{David Marker's} book, or \\emph{Tent-Ziegler}. Warning: both of them contain a lot of typos.\n\\end{rem}\n\n\\newpage\n\n\\section{Compactness}\n\n\\begin{defi} (5.1)\\\\\n    Suppose we have a $L$-theory $T$.\\\\\n    (i) $T$ is \\emph{finitely satisfiable} if every finite subset of sentences in $T$ has a model.\\\\\n    (ii) $T$ is \\emph{maximal} if for all $L$-sentences $\\sigma$, either $\\sigma \\in T$ or $\\neg\\sigma \\in T$.\\\\\n    (iii) $T$ has the \\emph{witness property} (WP): if for all $\\phi(x)$ ($L$-formula with $1$ free variable), there is a constant $c \\in \\mathcal{C}$ s.t.\n    $$(\\exists x \\phi(x) \\to \\phi(c)) \\in T$$\n\\end{defi}\n\n\\begin{lemma} (5.2)\\\\\n    If $T$ is maximal and finitely satisfiable (we'll sometimes use \\emph{f.s.} from now onwards), and $\\phi$ is an $L$-sentence, and $\\triangle \\stackrel{fin}{\\subseteq} T$ and $\\triangle \\vdash \\phi$, then $\\phi \\in T$.\\\\\n    (Prove it by yourself)\n\\end{lemma}\n\n\\begin{lemma} (5.3)\\\\\n    Let $T$ be a maximal, f.s. theory with WP. Then $T$ has a model.\\\\\n    Moreover, if $\\lambda$ is a cardinal and $|\\mathcal{C}| \\leq \\lambda$ ($\\mathcal{C}$ is the set of constants in $L$), then $T$ has a model of size at most $\\lambda$.\n    \\begin{proof}\n        Let $\\mathcal{C}$ be the constants of $L$. Let $c,d \\in \\mathcal{C}$, define $c \\sim d$ iff $c=d \\in T$.\\\\\n        We claim that $\\sim$ is an equivalence relation: reflexivity and symmetry are trivial; for transitivity, let $c \\sim d$ and $d \\sim e$. Then $c=d \\in T$ and $d=e \\in T$. Then by the lemma $c=e\\in T$ as it is implied by the two sentences. So $c \\sim e$.\\\\\n        Notation: we'll use $c/\\sim = c^*$ to denote the equivalence class of $c$.\\\\\n        Now define a structure $\\mathcal{M}$ whose domain is $\\mathcal{C}/\\sim = M$. Clearly, $|M| \\leq \\lambda$ if $|\\mathcal{C}| \\leq \\lambda$.\\\\\n        We must define interpretations in $\\mathcal{M}$ for symbols for $L$:\\\\\n        $\\bullet$ If $c \\in \\mathcal{C}$, then $c^m = c^* (=c/\\sim$);\\\\\n        $\\bullet$ If $R \\in \\mathcal{R}$ is a relation symbol, we define $R^{\\mathcal{M}} = \\{(c_1^*,...,c_{n_R}^*):R(c_1,...,c_{n_R}) \\in T\\}$.\\\\\n        We have to check that $R^{\\mathcal{M}}$ is well-defined: suppose $\\bar{c},\\bar{d} \\in \\mathcal{C}^{n_R}$ and suppose $c_i \\sim d_i$ for each $i$, i.e. $c_i = d_i \\in T$ for every $i=1,...,n_R$. However, now\n        $$R(\\bar{c}) \\in T \\iff R(\\bar{d}) \\in T$$\n        by maximality of $T$ and the previous lemma. So that $R^{\\mathcal{M}}$ is well defined.\\\\\n        $\\bullet$ If $f \\in \\mathcal{F}$ is a function symbol, then $f(\\bar{c}) = d \\in T$ for some $d \\in \\mathcal{C}$: this is because $\\exists x(f(\\bar{c})=x) \\in T$ by maximality and f.s..\\\\\n        Then define $f^{\\mathcal{M}}(\\bar{c}^*) = \\bar{d}^*$ (obvious notation).\\\\\n        We also have to check this is well-defined. Lecturer decides to left this to us.\\\\\n        Now we claim that the terms behave nicely as what the theory says, i.e. if $t(x_1,...,x_n)$ is an $L$-term and $c_1,...,c_n,d \\in \\mathcal{C}$, then $t(c_1,...,c_n) = d \\in T \\iff t^{\\mathcal{M}} (c_1^*,...,c_n^*) = d^*$.\\\\\n        $\\bullet$ $\\implies$: by induction on the complexity of $T$ (lecturer decided to leave this as another exercise).\\\\\n        $\\bullet$ $\\Leftarrow$: Assume $t^{\\mathcal{M}} (c_1^*,...,c_n^*) = d^*$. Then $t(c_1,...,c_n) = e \\in T$ for some constant $e$ (why? As our theory is maximal, it has to say what the result is when we apply $t$ to these terms). We then use $\\implies$ to get that $t^{\\mathcal{M}}(c_1^*,...,c_n^*) = e^*$.\\\\\n        But then $d^* = e^*$, i.e. $d = e \\in T$. So by lemma (5.2), the sentence implied by these two sentences, $t(c_1,...,c_n) = d \\in T$.\\\\\n        The last massive claim: for all $L$-formulas $\\phi(\\bar{x})$ and $\\bar{c} \\in \\mathcal{C}^{|\\bar{x}|}$, we have\n        $$\\mathcal{M} \\vDash \\phi(\\bar{c}) \\iff \\phi(\\bar{c}) \\in T$$\n        The proof is by induction on complexity of $\\phi(\\bar{x})$ (The lecturer decided to leave yet another proof to us -- lots of work to be done here. Lecturer is speeding up!).\n    \\end{proof}\n\\end{lemma}\n\n---Lecture 8---\n\n\\begin{lemma} (5.4)\\\\\n    Let $T$ be a f.s. $L$-theory. Then there are $L^* \\supseteq L$ and a f.s. $T^* \\supseteq T$ such that:\\\\\n    (i) $|L^*| = |L| + \\omega$;\\\\\n    (ii) any $L^*$-theory extending $T^*$ has WP.\n    \\begin{proof}\n        Define $\\bra L_i: i < \\omega \\ket$ a chain of languages containing $L$ and s.t. $|L_i| = |L|+\\omega$, and $\\bra T_i: i < \\omega \\ket$ of f.s. theories s.t. $\\forall i$ $T_i$ is an $L_i$-theory, and $T_i \\supseteq T$.\\\\\n        $\\bullet$ Base step: $L_0=L$ and $T_0=T$.\\\\\n        $\\bullet$ At stage $i+1$, $L_i$ and $T_i$ are given. List all $L_i$-formulas $\\phi(x)$ (one free variable $x$) and let $L_{i+1} = L_i \\cup \\{c_\\phi:\\phi(x)$ is an $L_i$-formula$\\}$.\\\\\n        For all $\\phi(x)$ ($L_i$-formula), let $\\Phi_\\phi$ be the $L_{i+1}$-sentence $\\exists x\\phi(x) \\to \\phi(c_\\phi)$.\\\\\n        Then $T_{i+1}:= T_i \\cup \\{\\Phi_\\phi: \\phi(x)$ is $L_i$-formula$\\}$.\\\\\n        Claim: $T_{i+1}$ is f.s.. Why is that? Let's take a finite subset $\\triangle \\stackrel{fin}{\\subseteq} T_{i+1}$. Then $\\triangle = \\triangle_0 \\cup \\{\\Phi_{\\phi_2},...,\\Phi_{\\phi_n}\\}$ where $\\triangle_0 \\subseteq T_i$.\\\\\n        Let $\\mathcal{M} \\vDash \\triangle_0$ ($\\mathcal{M}$ is an $L_i$-structure; it exists because $T_i$ is f.s.).\\\\\n        We define an $L_{i+1}$-structure $\\mathcal{M'}$ with domain $M$ (of $\\mathcal{M}$). Define the integration of new constants as follows: if $\\mathcal{M} \\vDash \\exists x \\phi(x)$, then $c_\\phi^{\\mathcal{M}'} = a$ for any $a \\in \\mathcal{M}$ s.t. $\\mathcal{M} \\vDash \\phi(a)$.\\\\\n        Otherwise, $c_\\phi^{\\mathcal{M}'}$ is arbitrary.\\\\\n        Then $\\mathcal{M}' \\vDash \\triangle$.\\\\\n        Now let $L^* = \\cup_{i < \\omega} L_i$, $T^* = \\cup_{i<\\omega} T_i$.\\\\\n        By our construction, any extension of $T^*$ has WP (check), and $T^*$ is f.s. ($\\triangle \\stackrel{fin}{\\subseteq} T^*$, then $\\triangle \\subseteq T_i$ for some $i$). \n    \\end{proof}\n\\end{lemma}\n\n\\begin{lemma} (5.5)\\\\\n    If $T$ is f.s., there exists a maximal f.s. $T' \\supseteq T$ (of underlying language $L$).\n    \\begin{proof}\n        Let $I:= \\{ S: S$ is a f.s. $L$-theory s.t. $T \\subseteq S\\}$.\\\\\n        $I$ is partially ordered by inclusion.\\\\\n        If $\\bra C_i: i < \\lambda\\ket$ is a chain in $I$, then $\\cup_{i < \\lambda} C_i$ is an upper bound for the chain: it is f.s. ($\\triangle \\subseteq \\cup C_i$ is s.t. $\\triangle \\subseteq C_i$).\\\\\n        Then by Zorn's lemma, $I$ has a maximal element (w.r.t. $\\subseteq$).\\\\\n        We claim that the maximal element $T'$ of $I$ is the required extension of $T$ (check that $\\forall$ $L$-sentences $\\sigma$, $\\sigma \\in T'$ or $\\neg \\sigma \\in T'$).\n    \\end{proof}\n\\end{lemma}\n\n\\begin{thm} (5.6, Compactness)\\\\\n    If $T$ is a f.s. $L$-theory, and $\\lambda \\geq |L|+\\omega$, then there is $\\mathcal{M} \\vDash T$ s.t. $|\\mathcal{M}| \\leq \\lambda$.\\\\\n    (See part II Logic and Set Theory for the finite case).\\\\\n    \\begin{proof} (sketch)\\\\\n        Extend $T$ to $T^*$, an $L^*$-theory that is f.s., and s.t. any $S \\supseteq T^*$ has WP (by lemma (5.4)).\\\\\n        By lemma (5.5), we can extend this $T^*$ to a maximal f.s. theory $T'$; and by the lemma $T'$ would have WP since it is an extension of $T^*$.\\\\\n        Now $T'$ is maximal and f.s., so we can use lemma (5.3) to show that there is a model $\\mathcal{M} \\vDash T'$. Then in particular, $\\mathcal{M} \\vDash T$ (check $\\mathcal{M} \\leq \\lambda$).\n    \\end{proof}\n\\end{thm}\n\n\\begin{defi} (5.7)\\\\\n    Let $L$ be a language. Then an $L$-type $p(\\bar{x})$ is a set of $L$-formulas whose free variables are in $\\bar{x}$ (and $\\bar{x} = \\bra x_i : i < \\lambda \\ket $).\\\\\n    $\\bullet$ An $L$-type is \\emph{satisfiable} if there is an $L$-structure $\\mathcal{M}$ and an assignment $\\bar{a} \\in \\mathcal{M}^{|\\bar{x}|}$ s.t. $\\mathcal{M} \\vDash \\phi(\\bar{a})$ for all $\\phi(\\bar{x}) \\in p(\\bar{x})$ (we also say $p(\\bar{x})$ is \\emph{consistent}, and $\\bar{a}$ \\emph{realizes} $p(\\bar{x})$ in $\\mathcal{M}$).\\\\\n    We write $\\mathcal{M} \\vDash p(\\bar{a})$, or $\\mathcal{M},\\bar{a} \\vDash p(\\bar{x})$.\\\\\n    We also say that $p(\\bar{x})$ is \\emph{satisfied in $\\mathcal{M}$}.\\\\\n    $\\bullet$ A type $p(\\bar{x})$ is finitely satisfiable if every finite subset of $p(x)$ is satisfiable (we may say $p(x)$ is finitely consistent).\n\\end{defi}\n\n\\begin{rem}\n    An $L$-type may be finitely satisfiable in a model $\\mathcal{M}$ (by this we mean every finite subset is satisfiable in $\\mathcal{M}$), but not satisfiable in $\\mathcal{M}$.\n\\end{rem}\n\n\\begin{eg}\n    Let $\\mathcal{M} = (\\N,<)$. Let $\\phi_n(x)$ say \\emph{there are at least $n$ elements less than $x$}, and $p(x):=\\{\\phi_n(x):n < \\omega\\}$.\\\\\n    Is $p(x)$ finitely satisfiable in $\\mathcal{M}$? Yes; but obviously $p(x)$ is not satisfiable in $\\mathcal{M}$.\n\\end{eg}\n\n\\begin{thm} (5.8)\\\\\n    Every finitely satisfiable $L$-type $p(\\bar{x})$ is satisfiable (not necessarily in the original model, of course).\n    \\begin{proof}\n        Let $\\bar{x} = \\bra x_i : i<\\lambda\\ket$, let $\\bra c_i:i<\\lambda\\ket$ be new constants (not in $L$).\\\\\n        Expand $L$ to $L' = L \\cup \\{c_i:i<\\lambda\\}$. Then $p(\\bar{c})$ is an $L'$-theory, and theorem (5.6) applied to $p(\\bar{c})$ gives the desired conclusion (think).\n    \\end{proof}\n\\end{thm}\n\n---Lecture 9---\n\nExample class 2: 19th November, Monday.\n\n\\begin{lemma} (5.9)\\\\\n    Let $\\mathcal{M}$ be a structure, let $\\bar{a} = \\bra a_i:i<\\lambda \\ket$ enumerate $\\mathcal{M}$. Let\n    $$q(\\bar{x}) = \\{\\phi(\\bar{x}): \\mathcal{M} \\vDash \\phi(\\bar{a})\\}$$\n    where $|\\bar{x}| = \\lambda$.\\\\\n    Then $q(\\bar{x})$ is satisfiable in $\\mathcal{N}$ iff there is $\\beta:\\mathcal{M} \\to \\mathcal{N}$ that is an elementary embedding.\n    \\begin{proof}\n        If $q(\\bar{x})$ is satisfiable in $\\mathcal{N}$, there is $\\bar{b} \\in N^{|\\bar{x}|}$ s.t. $\\mathcal{N} \\vDash \\phi(\\bar{b})$ for all $\\phi(\\bar{x}) \\in q(\\bar{x})$.\\\\\n        Then $\\beta:a_i \\to b_i$ ($i < \\lambda$) is an elementary embedding ($\\beta$ preserves, for example, atomic formulas of the form $f(a_{i_1},...,a_{i_n}) = a_{i_{n+1}}$, so it is an embedding.)\\\\\n        More generally, for any $\\phi(\\bar{x})$ ($L$-formula),\\\\\n        $\\mathcal{M} \\vDash \\phi(\\bar{a})$ iff $\\mathcal{N} \\vDash \\phi(\\bar{b})$, but $\\beta(\\bar{a}) = \\bar{b}$.\\\\\n        Conversely, if $\\beta:\\mathcal{M} \\to \\mathcal{N}$ is elementary, then $\\beta(\\bar{a})$ satisfies $q(\\bar{x})$ in $\\mathcal{N}$.\n    \\end{proof}\n\\end{lemma}\n\n\\begin{rem}\n    The above is usually stated as (diagram lemma): Let $Th(\\mathcal{M}_M)$ be a theory in $L(M)$, $\\mathcal{N} \\vDash Th(\\mathcal{M}_M)$, then $\\mathcal{M}$ embeds elementarily in $\\mathcal{N}$.\n\\end{rem}\n\n\\begin{rem} (5.10)\\\\\n    We can consider types in $L(A)$, where $A \\subseteq \\mathcal{M}$.\\\\\n    In particular, we can consider $A=M$ the whole domain of $\\mathcal{M}$.\\\\\n    Types of this kind are said to \\emph{have parameters in $A$} (or to be \\emph{over $A$}).\\\\\n    If $p(\\bar{x})$ is a type over $M$, then there is a $\\bar{a}$, an enumeration of $M$, and a type $p'(\\bar{x},\\bar{z})$ where the $\\bar{z}$ are \\emph{new constants}, $|\\bar{z}| = |\\bar{a}|$, and $p(\\bar{x}) = p'(\\bar{x},\\bar{a})$.\n\\end{rem}\n\n\\begin{thm} (5.11)\\\\\n    If $\\mathcal{M}$ is a structure, and $p(x)$ is a type in $L(M)$ that is finitely satisfiable in $\\mathcal{M}$, then $p(\\bar{x})$ is satisfiable in some $\\mathcal{N}$ such that $\\mathcal{M} \\preccurlyeq \\mathcal{N}$.\n\\end{thm}\n\n\\begin{eg}\n    Consider $\\mathcal{M} = (\\Q,<)$, and let $\\bra a_i:i < \\omega\\ket$ a sequence in $\\Q$ that converges to $\\sqrt{2}$ from below, and let $\\bra b_i:i < \\omega\\ket \\subseteq \\Q$ tend to $\\sqrt{2}$ from above.\\\\\n    Let $\\phi_m(x) \\equiv a_n < x < b_n$. Then let $p(x) = \\{\\phi_n(x)$ s.t. $n<\\omega\\}$.\\\\\n    Then $p(x)$ is an $L(\\Q)$-type which is finitely satisfiable in $\\Q$. But $p(x)$ is \\emph{not} satisfiable in $\\mathcal{M}$.\\\\\n    It is, however, satisfiable in $(\\R,<)$ which contains $(\\Q,<)$ as an elementary substructure.\\\\\n    (we can actually also use the example about natural numbers in last lecture -- just need to add an $\\infty$.)\n\\end{eg}\n\n\\begin{proof} (of 5.11)\\\\\n    Let $\\bra a_i:i<\\lambda \\ket$ enumerate $\\mathcal{M}$, and let $q(\\bar{z}) := \\{\\phi(\\bar{z}): \\mathcal{M} \\vDash \\phi(\\bar{a})\\}$, where $|\\bar{z}| = \\lambda$ and the $z_i$ are new variables (so not among the $\\bar{x}$).\\\\\n    Write $p(\\bar{x})$ as $p'(\\bar{x},\\bar{a})$ for some $p'(\\bar{x},\\bar{z})$ (an $L$-type).\\\\\n    We claim that $p'(\\bar{x},\\bar{z}) \\cup q(\\bar{z})$ is finitely satisfiable in $\\mathcal{M}$: this is because $p'(\\bar{x},\\bar{a})$ is finitely satisfiable by hypothesis and $q(\\bar{z})$ is realized by $\\bar{a}$.\\\\\n    Then, by theorem (5.8) (compactness for types), $p'(\\bar{x},\\bar{z}) \\cup q(\\bar{z})$ is satifsiable.\\\\\n    That is, there is $\\mathcal{N}$ and $\\bar{b} \\in \\mathcal{N}^{|\\bar{z}|}$ and $\\bar{c} \\in \\mathcal{N}^{|\\bar{x}|}$ such that $\\mathcal{N} \\vDash p'(\\bar{c},\\bar{b}) \\cup q(\\bar{b})$.\\\\\n    In particular, $\\mathcal{N} \\vDash q(\\bar{b})$. Then by lemma (5.9), $\\beta: \\mathcal{M} \\to \\mathcal{N}$ by $a_i \\to b_i$ is an elementary embedding.\n\n    \\includegraphics[scale=0.5]{image/Model_07.png}\n\n    (Get $\\mathcal{N}' \\simeq \\mathcal{N}$ s.t. $\\mathcal{M} \\preccurlyeq \\mathcal{N}'$, $\\mathcal{M} \\simeq \\beta(\\mathcal{M})$.)\n\\end{proof}\n\n\\begin{thm} (5.12, Upward L$\\ddot{o}$wenheim-Skolem theorem)\\\\\n    (See part II Logic and Set theory for the (countable?) case)\\\\\n    Let $\\mathcal{M}$ be s.t. $|\\mathcal{M}| \\geq \\omega$. Then for any $\\lambda \\geq |\\mathcal{M}| + |L|$, there is $\\mathcal{N}$ s.t. $\\mathcal{M} \\preccurlyeq \\mathcal{N}$ with $|\\mathcal{N}| = \\lambda$.\n    \\begin{proof}\n        Let $\\bar{x} = \\bra x_i: i < \\lambda \\ket$ a tuple of distinct variables.\\\\\n        Let $p(\\bar{x}) = \\{x_i \\neq x_j: i < j < \\lambda\\}$. Then $p(\\bar{x})$ is finitely consistent in $\\mathcal{M}$. So by theorem (5.11), $p(\\bar{x})$ is realized in some $\\mathcal{N}$ that is an elementary extension of $\\mathcal{M}$, and $|\\mathcal{N}| \\geq \\lambda$.\\\\\n        Then by downward L-S theorem (3.11) we could have $|\\mathcal{N}| = \\lambda$.\n    \\end{proof}\n\\end{thm}\n\n\\newpage\n\n\\section{Saturation}\n\n\\begin{defi} (6.1)\\\\\n    Let $\\lambda$ be an infinite cardinal, let $|\\mathcal{M}| \\geq \\omega$. Then $\\mathcal{M}$ is \\emph{$\\lambda$-saturated} if $\\mathcal{M}$ realizes every type $p(x)$ (with one free variable) such that:\\\\\n    (i) $p(x)$ has parameters in $A \\subseteq \\mathcal{M}$ and $|A| < \\lambda$;\\\\\n    (ii) $p(x)$ is finitely consistent in $\\mathcal{M}$.\\\\\n    We say $\\mathcal{M}$ is \\emph{saturated} if it is $|\\mathcal{M}|$-saturated.\n\\end{defi}\n\nQuestion: can $\\mathcal{M}$ be $\\lambda$-saturated if $\\lambda > |\\mathcal{M}|$? If so, $\\mathcal{M}$ would satisfy f.s. types in $L(M)$.\\\\\n(Hint: we could use $p(x) = \\{x \\neq a_i: i < |\\mathcal{M}|\\}$ where $\\bra a_i: i<|\\mathcal{M}| \\ket$ enumerates $\\mathcal{M}$. This could not be satisfiable.)\n\n---Lecture 10---\n\n\\begin{defi} (6.2)\\\\\n    Let $\\mathcal{M}$ be an $L$-structure, $A \\subseteq M$, $\\bar{b}$ a tuple of in $M$, possibly infinite.\\\\\n    The type of $\\bar{b}$ over $A$ is the following $L(A)$-type:\n    $$tp_\\mathcal{M}(\\bar{b}/A) = \\{\\phi(\\bar{x}) \\in L(A): \\mathcal{M} \\vDash \\phi(\\bar{b})\\}$$\n    (i.e. all the $L(A)$-formulas that, when plugged in $\\bar{b}$, can be implied by $\\mathcal{M}$).\\\\\n    $\\mathcal{M}$ is often omitted if it's clear from the context.\n\\end{defi}\n\n\\begin{rem} (6.3)\\\\\n    (i) $tp_{\\mathcal{M}} (\\bar{b}/A)$ is complete, i.e. for every $L(A)$ formula $\\phi(\\bar{x})$, either $\\phi(\\bar{x}) \\in tp(\\bar{b}/A)$ or $\\neg\\phi(x) \\in tp(\\bar{b}/A)$ (clear).\\\\\n    (ii) If $\\mathcal{M} \\preccurlyeq\\mathcal{N}$, then for $A \\subseteq M$, and $\\bar{b}$ a tuple,\n    $$tp_\\mathcal{M}(\\bar{b}/A) = tp_\\mathcal{N}(\\bar{b}/A)$$\n    (elementary embeddings preserve truth of formulas.)\n\\end{rem}\n\n\\begin{fact} (6.4, elementary maps and types)\\\\\n    Recall definition (4.10):\\\\\n    (i) If $f:A \\subseteq \\mathcal{M} \\to \\mathcal{N}$ is a (partial) elementary map, then in particular, $f$ preserves $L$-sentences, so $\\mathcal{M} \\equiv \\mathcal{N}$.\\\\\n    (ii) If $\\mathcal{M} \\equiv \\mathcal{N}$, then $\\phi$, the empty map, \\emph{is} an elementary map (only required to preserve sentences).\\\\\n    (iii) If $f:A \\subseteq \\mathcal{M} \\to \\mathcal{N}$ is elementary, and $\\bar{a}$ is an enumeration of $A=\\dom(f)$, then (obviously, $\\phi$ denotes the empty set here)\n    $$tp(\\bar{a}/\\phi) = tp(f(\\bar{a})/\\phi)$$\n    More generally: if $f:\\mathcal{M} \\to \\mathcal{N}$ (we'll stop writing $f:A \\subseteq \\mathcal{M} \\to \\mathcal{N}$ for elementary maps now) is elementary and there is $A\\subseteq M \\cap N$ s.t. $A \\subseteq \\dom(f)$, $f|_A = id$ ($f$ fixes $A$ pointwise), then for every tuple $\\bar{b}$ in $\\dom(f)$,\n    $$tp_\\mathcal{M} (\\bar{b}/A) = tp_\\mathcal{N} (f(\\bar{b}),A)$$\n\n    \\includegraphics[scale=0.5]{image/Model_08.png}\n\n    (iv) Let $\\bar{a}$ enumerate $A \\subseteq M$, $A=\\dom(f)$ where $f:\\mathcal{M} \\to \\mathcal{N}$ is elementary.\\\\\n    Let $p(\\bar{x},\\bar{a})$ be a type in $L(A)$ that is finitely satisfiable in $\\mathcal{M}$.\\\\\n    Then $p(\\bar{x},f(\\bar{a}))$ is finitely satisfiable in $\\mathcal{N}$: with massive abuse of notations, let $\\{\\phi_1(\\bar{x},\\bar{a}),...,\\phi_n(\\bar{x},\\bar{a})\\} \\subseteq p(\\bar{x},\\bar{a})$.\\\\\n    By f.s. of $p(\\bar{x},\\bar{a})$, $\\mathcal{M} \\vDash \\exists \\bar{x} \\bigwedge_{i=1}^n \\phi_i(\\bar{x},\\bar{a})$.\\\\\n    Then $\\mathcal{N} \\vDash \\exists \\bar{X} \\bigwedge_{i=1}^n \\phi_i(\\bar{x},f(\\bar{a}))$ by elmentarity of $f$.\\\\\n    (Does $p(\\bar{x},\\bar{a})$ satisfiable in $\\mathcal{M}$ imply $p(\\bar{x},f(\\bar{a}))$ satisfiable in $\\mathcal{N}$? The answer is no -- this doesn't hold in the infinite case.)\n\\end{fact}\n\n(Note that we haven't really discussed about the existence of saturated models. The general result is that given any model with size $\\lambda$ we could extend it elementarily to a model that is $\\lambda^+$ saturated, but we'll have no control over the size of the extended model unless we assume some more subtle things (Lecturer was unsure of that)).\n\n\\begin{thm} (6.5)\\\\\n    Let $\\mathcal{N}$ be s.t. $|\\mathcal{N}| \\geq \\lambda \\geq |L|+\\omega$. The following are equivalent:\\\\\n    (i) $\\mathcal{N}$ is $\\lambda$-saturated;\\\\\n    (ii) if $\\mathcal{M} \\equiv \\mathcal{N}$, $b \\in M$ and $f:\\mathcal{M} \\to \\mathcal{N}$ partial elementary s.t. $|\\dom f| < \\lambda$, then there is partial elementary $\\bar{f} \\supseteq f$ such that $b \\in \\dom(\\bar{f})$;\\\\\n    (iii) If $p(\\bar{z})$ is an $L(A)$-type where $|\\bar{z}| \\leq \\lambda$, and $|A| < \\lambda$ and $p(\\bar{z})$ is finitely satifiable in $\\mathcal{N}$, then $p(\\bar{z})$ is satisfiable in $\\mathcal{N}$.\n    \\begin{proof}\n        (i) $\\implies$ (ii): Let $f:\\mathcal{M} \\to \\mathcal{N}$ be as in (ii), and let $b \\in M$. The idea is the following: look at the type of $b$ over $M$, and then prove that the corresponding type in $\\mathcal{N}$ is realized in $\\mathcal{N}$.\\\\\n        Let $\\bar{a}$ be an enumeration of $\\dom(f)$, so $|\\bar{a}|<\\lambda$. Let $p(x/\\bar{a}) = tp_\\mathcal{M} (b/\\bar{a})$.\n\n        \\includegraphics[scale=0.5]{image/Model_09.png}\n\n        Then $p(x/\\bar{a})$ is finitely satisfiable in $\\mathcal{M}$, hence $tp(x/f(\\bar{a}))$ is f.s. in $\\mathcal{N}$ (6.4 (iv)).\\\\\n        Since $|f(\\bar{a})| < \\lambda$ and $\\mathcal{N}$ is $\\lambda$-saturated, $tp(x/f(\\bar{a}))$ is realized in $\\mathcal{N}$ by some $c$.\\\\\n        Then $f \\cup \\{\\bra b,c\\ket \\}$ is the required extension.\\\\\n        ($\\mathcal{M} \\vDash \\phi(b,\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(c,f(\\bar{a}))$, so $f$ preserves the truth).\\\\\n        (ii) $\\implies$ (iii): (idea?: Let $p(\\bar{z})$ be as in (iii), $p(\\bar{z})$ is f.s. in $\\mathcal{N}$. Then by (5.11), $p(\\bar{z})$ is realized in some elementary extension $\\mathcal{M}'$ of $\\mathcal{N}$, by some tuple $\\bar{a}$ (where $|\\bar{a}| = |\\bar{z}|$).\\\\\n        But now we can shrink $|\\mathcal{M}'|$ by downward L-S theorem: there is $\\mathcal{M} \\preccurlyeq\\mathcal{M}'$ such that $A \\cup \\bar{a} \\subseteq M$, where $A$ is the parameter set of the type.)\n\n        \\includegraphics[scale=0.5]{image/Model_10.png}\n        \n        ---Lecture 11---\n\n        Let $p(\\bar{z})$ be as in (iii), $\\mathcal{M}$ is s.t. $\\mathcal{N} \\preccurlyeq\\mathcal{M}$ and $\\mathcal{M} \\vDash p(\\bar{b})$. The identity map $id_A:\\mathcal{M} \\to \\mathcal{N}$ is partial elementary.\\\\\n        Idea: build $\\bra f_i:i < |\\bar{b}| \\ket$ of $p$ elementary maps. Then $\\cup f_i$ is partial elementary, and $\\bar{b} \\in \\dom \\cup_{i < |\\bar{a}|} f_i$.\\\\\n        Let $f_0 = id_A$. At stage $i+1$, use (ii) to put $b_i$ in $\\dom (f_{i+1})$.\\\\\n        At limit stages $\\mu < \\lambda$, let $f_\\mu = \\cup_{i < \\mu} f_i$.\\\\\n        Then $f(\\bar{b})$ satisfies $p(\\bar{z})$ in $\\mathcal{N}$.\n\n        (iii) $\\implies$ (i) is trivial.\n    \\end{proof}\n\\end{thm}\n\n\\begin{coro} (6.6)\\\\\n    If $\\mathcal{M}$ and $\\mathcal{N}$ are saturated, and $\\mathcal{M} \\equiv \\mathcal{N}$, and $|\\mathcal{M}| = |\\mathcal{N}|$, then every elmentary map $f:\\mathcal{M} \\to \\mathcal{N}$ extends to an isomorphism.\\\\\n    In particular, these two structures are isomorphic (since the empty map $\\phi$ is an elementary map).\n    \\begin{proof}\n        Use theorem 6.5(ii) to extend $f:\\mathcal{M} \\to \\mathcal{N}$ to an isomorphism by back-and-forth (similar to that in random graphs), taking unions at limit stages.\n    \\end{proof}\n\\end{coro}\n\n\\begin{coro} (6.7)\\\\\n    Models of $T_{dlo}$ and $T_{rg}$ are $\\omega$-saturated.\n    \\begin{proof}\n        In chapter 4 we proved that we can do one point extensions for partial elmentary maps for both of the cases (4.3 and 4.17).\\\\\n        So $(\\Q,<)$ $\\omega$-saturated.\\\\\n        Is $(\\R,<)$ $\\omega_1$-saturated? No -- for example, the type $p(x):= \\{x>q: q \\in \\Q\\}$ is not realized).\n    \\end{proof}\n\\end{coro}\n\n\\begin{defi} (6.8)\\\\\n    An isomorphism $\\alpha:\\mathcal{N} \\to \\mathcal{N}$ is called an \\emph{automorphism}.\\\\\n    The automorphism of $\\mathcal{N}$ form a group denoted by $\\Aut(\\mathcal{N})$.\\\\\n    If $A \\subseteq N$, then we write $\\Aut(\\mathcal{N}/A)$ for the subgroup of $\\Aut(\\mathcal{N})$ that fixes $A$ pointwise, i.e. $\\{\\alpha \\in \\Aut(\\mathcal{N}):\\alpha|_A = id\\}$.\n\\end{defi}\n\n\\begin{defi} (6.9\\footnote{In some texts the definition of this is a bit different -- sometimes they use $\\lambda^+$-universality for our $\\lambda$-universality here. Homogeneity is sometimes called \\emph{strong homogeneity}. \\emph{Ultrahomogeneity} concerns partial embeddings instead of (partial) elementary maps.})\\\\\n    (i) An $L$-structure $\\mathcal{N}$ is $\\lambda$-universal if for every $\\mathcal{M} \\equiv \\mathcal{N}$ s.t. $|\\mathcal{M}| \\leq \\lambda$, there is elementary embedding $\\beta:\\mathcal{M} \\to \\mathcal{N}$.\\\\\n    In particular, $\\beta$ would be an isomorphism between $\\mathcal{M}$ and its image in $\\mathcal{N}$, i.e. $\\mathcal{N}$ contains a copy of $\\mathcal{M}$.\\\\\n    $\\mathcal{N}$ is \\emph{universal} if it is $|\\mathcal{N}|$-universal.\\\\\n    (ii) $\\mathcal{N}$ is \\emph{$\\lambda$-homogeneous} if every elementary map $f:\\mathcal{N} \\to \\mathcal{N}$ s.t. $|f|<\\lambda$ extends to an automorphism of $\\mathcal{N}$.\n\\end{defi}\n\n\\begin{thm} (6.10)\\\\\n    Let $\\mathcal{N}$ be s.t. $|\\mathcal{N}| \\geq |L|+\\omega$. The following are equivalent:\\\\\n    (i) $\\mathcal{N}$ is saturated;\\\\\n    (ii) $\\mathcal{N}$ is universal and homogeneous.\n    \\begin{proof}\n        (i) $\\implies$ (ii): Assume $\\mathcal{N}$ is saturated, let $\\mathcal{M} \\equiv \\mathcal{N}$ and s.t. $|\\mathcal{M}| \\leq |\\mathcal{N}|$.\\\\\n        Then let $\\bar{a}$ enumerate $M$, let $p(\\bar{x}) = tp(\\bar{a}/\\phi)$. Then $p(\\bar{x})$ is f.s. in $\\mathcal{M}$.\\\\\n        We claim that $p(\\bar{x})$ is also f.s. in $\\mathcal{N}$: let $\\{\\phi_1(\\bar{x}),...,\\phi_m(\\bar{x})\\}$, so $\\mathcal{M} \\exists \\bar{x} \\bigwedge_{i=1}^n \\phi_i(\\bar{x})$; but note that this is a sentence, so $\\mathcal{N} \\vDash \\exists \\bar{x} \\bigwedge \\phi_i(\\bar{x})$ as well.\\\\\n        Now since $|\\bar{x}| \\leq |\\mathcal{N}|$, $n$ realizes $p(\\bar{x})$ since it's saturated (6.5 (iii)). Homoegeneity follows from (6.6).\n\n        Conversely, we show that if $\\mathcal{M} \\equiv \\mathcal{N}, b \\in M$, $f:\\mathcal{M} \\to \\mathcal{N}$ elementary s.t. $|f| < |\\mathcal{N}|$, then there is $\\hat{f} \\supseteq f$ elementary and contains $b$ in its domain (i.e. we can extend $f$ to be defined on $b$).\n\n        \\includegraphics[scale=0.5]{image/Model_11.png}\n\n        (Find?) $\\alpha \\in \\Aut(\\mathcal{N})$ extending $\\beta(\\dom(f)) \\to img(f)$.\n\n        (see lecturer's scanned notes for more details -- tbd.)\n    \\end{proof}\n\\end{thm}\n\n\\begin{defi} (6.11)\\\\\n    Let $\\bar{a}$ be a tuple in $\\mathcal{N}$ and $A \\subseteq N$. The \\emph{orbit of $\\bar{a}$} over $A$ is the set\n    $$O_\\mathcal{N} (\\bar{a}/A) = \\{\\alpha(\\bar{a}):\\alpha \\in \\Aut(\\mathcal{N}/A)\\}$$\n    If $\\phi(\\bar{x})$ is an $L(A)$-formula, then\n    $$\\phi(\\mathcal{N}) := \\{\\bar{a} \\in N^{|\\bar{x}|}:\\mathcal{N} \\vDash \\phi(\\bar{a})\\}$$\n    (called the set defined by $\\phi(\\bar{x})$).\\\\\n    A set is definable over $A$ if it is defined by some $L(A)$-formula.\n\\end{defi}\n\nThere are analogous notions of a type defining a set, and a set being type-definable -- lecturer will say more about this next time.\n\n---Lecture 12---\n\n\\begin{rem} (6.12)\\\\\n    If $\\bar{a}$ and $\\bar{b}$ are tuples in $\\mathcal{N}$ and $|\\bar{a}| = |\\bar{b}|$, and $A \\subseteq N$, then the following are equivalent:\\\\\n    (i) $tp_\\mathcal{N}(\\bar{a}/A) = tp_\\mathcal{N}(\\bar{b})/A$;\\\\\n    (ii) $\\{\\bra a_i,b_i\\ket : i<|\\bar{a}|\\} \\cup id_A$ is an elementary map.\n\\end{rem}\n\n\\begin{prop} (6.13)\\\\\n    Let $\\mathcal{N}$ be $\\lambda$-homogeneous, $A \\subseteq \\mathcal{N}$ s.t. $|A| < \\lambda$. Let $\\bar{a}$ be a tuple in $\\mathcal{N}$ s.t. $|\\bar{a}| < \\lambda$. Then\n    $$O_\\mathcal{N} (\\bar{a}/A) = p(\\mathcal{N})$$\n    where $p(\\bar{x}) = tp_\\mathcal{N}(\\bar{a}/A)$.\n    \\begin{proof}\n        If $\\alpha(\\bar{a}) = \\bar{b}$ where $\\alpha \\in \\Aut(\\mathcal{N} /A)$, then $tp_\\mathcal{N}(\\bar{A}/A) = tp_\\mathcal{N}(\\bar{b}/A)$.\\\\\n        If $tp_\\mathcal{N}(\\bar{b}/A) = tp_\\mathcal{N}(\\bar{a}/A)$, then $\\{\\bra a_i,b_i:i < |\\bar{a}| \\} \\cup id_A$ is elementary, and by homogeneigy it extends to $\\alpha \\in \\Aut(\\mathcal{N})$, and in particular, $\\alpha \\in \\Aut (\\mathcal{N} / A)$.\n    \\end{proof}\n\\end{prop}\n\n\\newpage\n\n\\section{The Monster Model}\n\nGiven a complete theory $T$ with an infinite model, we work in a saturated structure $U(\\mathbb{M})$ that is a model of $T$ and is sufficiently large that any other model of $T$ we might be interested in is an elementary substructure of $U$.\\\\\n($I$ is an expository device -- see Tent/Ziegler fo details -- also Marker(v?)).\n\n\\begin{defi} (7.1, terminologies and conventions)\\\\\n    When working in $U$, \\\\\n    $\\bullet$ \\emph{$\\phi(\\bar{x})$ holds} means $U \\vDash \\forall \\bar{x} \\phi(\\bar{x})$;\\\\\n    $\\bullet$ \\emph{$\\phi(\\bar{x})$ is consistent} means $U\\vDash \\exists \\bar{x} \\phi(\\bar{x})$;\\\\\n    $\\bullet$ \\emph{the type $p(\\bar{x})$ is consistent/satisfiable} if $U \\vDash \\exists \\bar{x} p(\\bar{x})$;\\\\\n    $\\bullet$ a cardinality $\\lambda$ is \\emph{small} if $\\lambda < |U|$ (we usually denote $|U|$ by $\\kappa$).\\\\\n    $\\bullet$ a \\emph{model} is $\\mathcal{M} \\preccurlyeq U$ s.t. $|\\mathcal{M}|$ is small.\n\n    Conventions:\\\\\n    $\\bullet$ tuples have small lengths (unless otherwise specified);\\\\\n    $\\bullet$ formulas have parameters in $U$;\\\\\n    $\\bullet$ types have parameters in small sets;\\\\\n    $\\bullet$ definable sets have the form $\\phi(U)$ for some formula $\\phi(\\bar{x})$ in $L(U)$;\\\\\n    $\\bullet$ type definable sets have form $p(U)$ for some type $p(\\bar{x},A)$ where $|A| < \\kappa$;\\\\\n    $\\bullet$ Orbits and types of tuples are within $U$, so $tp(\\bar{a}/A)$ means $tp_U(\\bar{a}/A)$; $O(a/A)$ means $O_U(a/A)$;\\\\\n    $\\bullet$ if $p(\\bar{x}),q(\\bar{x})$ are types, we write, for example, $p(x) \\to q(x)$ to mean $p(\\mathcal{N}) \\subseteq q(\\mathcal{N})$ (think of $p(x)$ as \\emph{infinite conjunction of formulas}).\n\\end{defi}\n\n\\begin{fact} (7.2)\\\\\n    Let $p(\\bar{x})$ be a satisfiable $L(A)$-type, $q(\\bar{x})$ be a satisfiable $L(B)$-type such that $p(\\bar{x}) \\to \\neg q(\\bar{x})$, that is, $p(\\bar{x})$ and $q(\\bar{x})$ have no realizations in common.\\\\\n    Then there are $\\bigwedge_{i=1}^n \\phi_i(\\bar{x})$ where $\\phi_i(\\bar{x}) \\in p(\\bar{x})$, and $\\bigwedge_{i=1}^m \\psi_i(\\bar{x})$ where $\\psi_i(\\bar{x}) \\in q(\\bar{x})$ s.t.\n    $$\\bigwedge_{i=1}^n \\phi_i(\\bar{x}) \\to \\neg (\\bigwedge_{i=1}^m \\psi_i(\\bar{x}))$$\n    \\begin{proof}\n        We know $p(\\bar{x}) \\cup q(\\bar{x})$ is not realized in $U$. By saturation of $U$, this cannot be finitely satisfiable, i.e. there are $\\{\\phi_i(\\bar{x}),...,\\phi_n(\\bar{x})\\} \\subseteq p(\\bar{x})$, $\\{\\psi_1(\\bar{x}),...,\\psi_m(\\bar{x})\\} \\subseteq q(\\bar{x})$ such that the union is not satisfiable. Then \n        $$\\bigwedge \\phi_i(\\bar{x}) \\to \\neg \\bigwedge (\\psi_i(\\bar{x}))$$\n    \\end{proof}\n\\end{fact}\n\n\\begin{rem} (7.3)\\\\\n    Let $\\phi(U,\\bar{b})$ (note that this notation defines a set, i.e. the set of $\\bar{a}$ s.t. $\\phi(\\bar{a},\\bar{b})$ holds, where $\\bar{a}$ is of correct length with each component in $U$) be s.t. $\\phi(\\bar{x},\\bar{z})$ is an $L$-formula, $\\bar{b} \\in U^{|\\bar{z}|}$.\\\\\n    If $\\alpha \\in \\Aut(U)$, then\n    \\begin{equation*}\n        \\begin{aligned}\n            \\alpha[\\phi(U,\\bar{b})] &= \\{\\alpha(\\bar{a}): \\phi(\\bar{a},\\bar{b}),\\bar{a} \\in U^{|\\bar{x}|}\\}\\\\\n            &= \\{\\alpha(\\bar{a}):\\phi(\\alpha(\\bar{a}),\\alpha(\\bar{b})),...\\}\\\\\n            &= \\phi(U,\\alpha(\\bar{b}))\n        \\end{aligned}\n    \\end{equation*}\n    So $\\Aut(U)$ acts on the definable sets in a natural way (similarly for type-definable sets).\n\\end{rem}\n\n\\begin{defi} (7.4)\\\\\n    A set $D \\subseteq U^\\lambda$ is invariant under $\\Aut(U/A)$ (\\emph{invariant over} $A$) if $\\alpha(D) = D$ for every $\\alpha \\in \\Aut(U/A)$.\\\\\n    Equivalently, for all $\\bar{a} \\in D$, $O(a/A) \\subseteq D$.\\\\\n    If $\\bar{a} \\in D$, $q(\\bar{x}) = tp(a/A)$ and $\\bar{b} \\vDash q(\\bar{x})$, then $b \\in D$.\\\\\n    ($tp(\\bar{b}/A) = tp(\\bar{a}/A)$ and $\\bar{b} \\vDash q(\\bar{x})$, so there's $\\alpha \\in \\Aut(U/A)$ s.t. $\\alpha(\\bar{a}) = \\bar{b}$ by homogeneity of $U$).\\\\\n    Hence another equivalent formulation of invariance over $A$ is: for all $\\bar{a} \\in D$, if $\\bar{b} \\equiv_A \\bar{a}$, then $\\bar{b} \\in D$.\n\\end{defi}\n\n\\begin{prop} (7.5)\\\\\n    Let $\\phi(\\bar{x})$ be an $L(U)$-formula. The following are equivalent:\\\\\n    (i) $\\phi(\\bar{x})$ is equivalent to some $L(A)$-formula $\\psi(\\bar{x})$;\\\\\n    (ii) $\\phi(U)$ is invariant over $A$.\n    \\begin{proof}\n        (i) $\\implies$ (ii) is clear (set-wise invariance);\\\\\n        (ii) $\\implies$ (i) This is the more interesting direction. Let $\\phi(\\bar{x},\\bar{z})$ be an $L$-formula s.t. $\\phi(U,\\bar{b})$ is invariant over $A$ (for $\\bar{b} \\in U^{|z|}$).\\\\\n        Let $q(\\bar{z}) = tp(\\bar{b}/A)$. If $\\bar{c} \\vDash q(\\bar{z})$, then there is (by homogeneity), $\\alpha \\in \\Aut (U/A)$ s.t. $\\alpha(\\bar{b}) = \\bar{c}$. Then \n        $$\\phi(U,\\bar{b}) = \\alpha(\\phi(U,\\bar{b})) = \\phi(U,\\bar{c})$$\n        by invariance and (7.3) respectively. Hence $q(\\bar{z}) \\to \\forall \\bar{x} [\\phi(\\bar{x},\\bar{z}) \\leftrightarrow \\phi(\\bar{x},\\bar{b})]$. By (an argument similar to 7.2) there is $\\theta(\\bar{z}) \\in q(\\bar{z})$ s.t. $\\theta(\\bar{z}) \\to \\forall \\bar{x}[\\phi(\\bar{x},\\bar{z}) \\leftrightarrow \\phi(\\bar{x},\\bar{z})]$.\\\\\n        Then $\\theta(\\bar{z})$ is an $L(A)$-formula, and $\\exists z [\\theta(\\bar{z}) \\wedge \\phi(\\bar{x},\\bar{z})]$ defines $\\phi(U,\\bar{b})$.\n    \\end{proof}\n\\end{prop}\n\n---Lecture 13---\n\n\\begin{defi} (7.6)\\\\\n    An injective map $\\rho:A \\subset \\mathcal{M} \\to \\mathcal{N}$ is a \\emph{partial embedding} if for all tuples in $A=\\dom\\rho$, $\\rho$ satisfies conditions (i)-(iii) in definition (1.5) (i.e. $\\rho$ is an embedding $\\dom \\rho \\to \\im \\rho$).\n\\end{defi}\n\n\\begin{prop} (7.7)\\\\\n    Let $\\phi(\\bar{x})$ be an $L$-formula. The following are equivalent:\\\\\n    (i) $\\exists \\psi(\\bar{x})$, a quantifier free $L$-formula, s.t. $U \\vDash \\forall \\bar{x}(\\phi(\\bar{x}) \\iff \\psi(\\bar{x}))$;\\\\\n    (ii) $\\forall \\rho$ a partial embedding $U \\to U$, $\\forall \\bar{a} \\in \\dom \\rho$, $\\phi(\\bar{a}) \\iff \\phi(\\rho(\\bar{a}))$.\n    \\begin{proof}\n        (i) $\\implies$ (ii) because embeddings preserve quantifier free formulas.\\\\\n        (ii) $\\implies$ (i): For $\\bar{a} \\in U$, write $qftp(\\bar{a}) = \\{\\psi(\\bar{x}):\\psi(\\bar{a})$, and $\\psi(\\bar{x}$ is q.f.$)\\}$, called the quantifier-free type.\\\\\n        Let $D = \\{q(\\bar{x}): q(\\bar{x}) = qftp(\\bar{a})$ for some $\\bar{a} \\in \\phi(U)\\}$ (so $D$ is a collection of types).\\\\\n        We claim $\\phi(U) = \\cup_{q(x) \\in D} q(U)$: LHS is a subset of RHS by construction of $D$. For the other direction, we need to prove for each $q(\\bar{x}) \\in D$ we have $q(U) \\subseteq \\phi(U)$. Let $q(\\bar{x}) = qftp(\\bar{a})$, and suppose $\\bar{b} \\in q(U)$. The map $\\{\\bra a_i,b_i \\ket: i \\leq |\\bar{a}|\\}$ is a partial embedding, so by (ii) we know $\\phi(\\bar{b})$ holds, so done.\\\\\n        Now by an argument similar to (7.2), there exists a finite conjunction of formulas $\\psi_q(\\bar{x})$ in $q(\\bar{x})$ s.t. $\\psi_q(\\bar{x}) \\implies \\phi(\\bar{x})$, i.e. $\\phi(\\bar{x}) \\iff \\vee_{q(\\bar{x}) \\in D} \\{\\psi_q(\\bar{x})\\}$. By (7.2), $\\exists \\psi_{q_1}(\\bar{x}),... \\psi_{q_m}(\\bar{x})$ s.t. $\\psi(\\bar{x}) \\iff \\vee_{i=1}^n \\psi_{q_i}(\\bar{x})$, so RHS is the required quantified free formula.\\\\\n        (I think there might be something unnecessary here)\n    \\end{proof}\n\\end{prop}\n\n\\begin{defi} (7.8)\\\\\n    An $L$-theory $T$ ahs q.e. (quantifier elimination) if for every $L$-formula $\\phi(\\bar{x})$, there exists a quantifier free formula $\\psi(\\bar{x})$ s.t. $T \\vdash \\forall \\bar{x} (\\phi(\\bar{x}) \\iff \\psi(\\bar{x}))$.\n\\end{defi}\n\n\\begin{thm} (7.9)\\\\\n    Let $T$ be a complete theory, with an infinite model. The following are equivalent:\\\\\n    (i) $T$ has quantifier elimination;\\\\\n    (ii) Every partial embedding $\\rho:U \\to U$  is elementary;\\\\\n    (iii) If $\\rho:U \\to U$ is partial embedding, $|\\rho| < |U|$ and $b \\in U$, then there exists partial embedding $\\hat{\\rho}\\supseteq \\rho$ s.t. $b \\in \\dom(\\hat{\\rho})$ (i.e. we can do one point extensions).\n    \\begin{proof}\n        (i) $\\iff$ (ii) is (7.7). We'll prove (ii) and (iii) are equivalent:\\\\\n        (ii) $\\implies$ (iii): Suppose $\\rho:U \\to U$ is partial embedding. So it's elementary. By homogeneity of $U$, it extends to an automorphism $\\alpha$ of $U$, and so $\\rho \\cup \\{\\bra b,\\alpha(b)\\ket\\}$ is the required extension;\\\\\n        (iii) $\\implies$ (ii): Suppose $\\rho:U \\to U$ is partial embedding. We'll prove that any finite restriction $\\rho_0$ of $\\rho$ is elementary: let $\\mathcal{M} \\supseteq \\dom(\\rho_0)$, $\\mathcal{N} \\supseteq \\im(\\rho_0)$ s.t. $|\\mathcal{M}| = |\\mathcal{N}|$. Extend $\\rho_0$ to an isomorphism $\\beta:\\mathcal{M} \\to \\mathcal{N}$ by back-and-forth (using saturation of $U$).\n    \\end{proof}\n\\end{thm}\n\n\\begin{rem}\n    (1) There's a fourth condition equivalent to the above:\\\\\n    (iv) For every \\emph{finite} partial embedding $\\rho:U \\to U$, $b \\in U$, there exists $\\hat{\\rho} \\supseteq \\rho$ a partial embedding s.t. $b \\in \\dom(\\hat{\\rho})$, i.e. we can do one point extension for finite partial embeddings.\\\\\n    (2) If $T$ has q.e. and $\\mathcal{M} \\vDash T$, then any substructure of $\\mathcal{M}$ is an elementary substructure (we say $T$ is \\emph{model-complete}).\n\\end{rem}\n\n\\begin{defi} (7.10)\\\\\n    An element $a \\in U$ is \\emph{definable over $A \\subset U$} if $\\exists \\phi(x)$ an $L(A)$-formula s.t. $\\phi(U) = \\{a\\}$.\\\\\n    In particular, any element of $A$ is definable over $A$.\\\\\n    An element $a \\in U$ is \\emph{algebraic over $A \\subseteq U$} if $\\exists \\phi(x)$ an $L(A)$-formula s.t. $|\\phi(U)| < \\omega$, and $a \\in \\phi(U)$ (inspired by algebraic element in fields).\\\\\n    The \\emph{definable closure} of $A$ is $dcl(A) = \\{a \\in U$ s.t. $a$ is definable over $A\\}$. The algebraic closure of $A$, $acl(A)$, is defined similarly.\n\\end{defi}\n\n\\begin{prop} (7.11)\\\\\n    For $a \\in U$, $A \\subseteq U$, the following are equivalent:\\\\\n    (i) $a \\in dcl(A)$;\\\\\n    (ii) $O(a/A) = \\{a\\}$.\n    \\begin{proof}\n        $a \\in dcl(A) \\iff \\exists \\phi(x) \\in L(A)$ s.t. $\\phi(U) = \\{a\\}$. By (7.5), this is equivalent to invariance under $\\Aut(U/A)$.\n    \\end{proof}\n\\end{prop}\n\n\\begin{thm} (7.12)\\\\\n    Let $A \\subseteq U$, $a \\in U$. The following are equivalent:\\\\\n    (i) $a \\in acl(A)$;\\\\\n    (ii) $|O(a/A)| < \\omega$ (orbit of $a$ under automorphisms of $U$ fixing $A$ is finite);\\\\\n    (iii) $a \\in \\mathcal{M}$ for any model $\\mathcal{M}$ which contains $A$.\n\n---Lecture 14---\n\n    Possible erratum to theorem (7.9) (iii) $\\implies$ (ii): \n    \\begin{proof}\n        Let $p:U \\to U$ be a partial embedding. Consider $p_0 \\subseteq p$, $p_0$ finite or small. Use property (iii) and saturation to extend $p_0$ to $\\alpha \\in \\Aut(U)$ by back and forth.\n    \\end{proof}\n\n    \\begin{proof}\n        (i) $\\implies$ (ii): If $a \\in acl(A)$, then there is $L(A)$-formula $\\phi(x)$ s.t. $\\phi(a)$ and $|\\phi(U)| < \\omega$. But $\\phi(U)$ is invariant over $A$, and so $O(a/A) \\subseteq \\phi(U)$, and so $|O(a/A)| < \\omega$.\\\\\n        (ii) $\\implies$ (i): If $|O(a/A)| < \\omega$, then $O(a/A)$ is definable, by $\\vee_{i=1}^n x=a_i$ where $P(a/A) = \\{a_1,...,a_n\\}$. Also $O(a/A)$ is invariant over $A$. So by (7.5), there is an $L(A)$-formula $\\phi(x)$ that defines $O(a/A)$.\\\\\n        (i) $\\implies$ (iii): Suppose $a \\in acl(A)$, so there is $\\phi(x)$, an $L(A)$-formula, s.t. there is $n \\in \\omega \\setminus \\{0\\}$ that\n        $$ (U\\vDash) \\phi(a) \\wedge \\exists^{\\leq n} x \\phi(x)$$\n        (where the notation means \\emph{there are at most $n$ solutions to}). Then by elementarity, $\\exists^{\\leq n} x \\phi(x)$ holds in every $\\mathcal{M} \\supseteq A$, and the $n$ realizations of $\\phi(x)$ in $U$ must coincide with the realizations in $\\mathcal{M}$. Therefore $a \\in \\mathcal{M}$ (?).\\\\\n        (iii) $\\implies$ (i): Suppose $a \\not\\in acl(A)$, let $p(x) = tp(a/A)$. Then for $\\phi(x) \\in p(x)$, $|\\phi(U)| \\geq \\omega$. Then by Sheet 2 Q8, $|p(U)| \\geq \\omega$. By an argument similar to the on in Q7, $|p(U)| = |U|$.\n\n        \\includegraphics[scale=0.5]{image/Model_12.png}\n\n        Let $\\mathcal{M} \\supset A$, Then $p(U) \\setminus \\mathcal{M} \\neq \\phi$. So there is $b \\in p(U) \\setminus \\mathcal{M}$ Since $tp(a/A) = tp(b/A)$, there is $\\alpha \\in \\Aut(U/A)$ s.t. $\\alpha(b) = a$. But then $\\alpha[\\mathcal{M}]$ is a model that contains $A$, but it cannot contain $a$ as $a = \\alpha(b)$ and $b \\not\\in \\mathcal{M}$.\n    \\end{proof}\n\\end{thm}\n\n\\begin{prop} (7.13)\\\\\n    Let $a \\in U$, $A \\subseteq U$. Then \\\\\n    (i) if $a \\in acl(A)$, then there is finite $A_0 \\subseteq A$ s.t. $a \\in acl(A_0)$;\\\\\n    (ii) if $A \\subseteq B$, then $acl(A) \\subseteq acl(B)$;\\\\\n    (iii) $acl(A) = acl(acl(A))$;\\\\\n    (iv) $A \\subseteq acl(A)$;\\\\\n    (v) $acl(A) =\\cap_{A \\subseteq \\mathcal{M}} \\mathcal{M}$ (where $\\mathcal{M}$ is any small elemntary substructure of $U$).\n    \\begin{proof}\n        (iv) $a \\in A$ is definable over $A$, hence algebraic.\\\\\n        (iii) $acl(A) \\subseteq acl(acl(A))$ by monotonicity (iv). For $\\supseteq$, let $a \\in acl(acl(A))$. By theorem (7.12), $a \\in \\mathcal{M}$ for every $\\mathcal{M} \\supseteq acl(A)$. But $acl(A) \\subseteq \\mathcal{M} \\iff A \\subseteq \\mathcal{M}$, so in fact $a \\in \\mathcal{M}$ for every $\\mathcal{M} \\supseteq A$, i.e. $a \\in acl(A)$.\\\\\n        (v) follows directly from (7.12) (i) $\\iff$ (iii).\n    \\end{proof}\n\\end{prop}\n\n\\begin{prop} (7.14)\\\\\n    If $\\beta \\in \\Aut(U)$, $A \\subseteq U$, then \n    $$\\beta[acl(A)] = acl(\\beta[A])$$\n    (Slogan (to make this more astounding): The operator $acl$ is a \\emph{natural transformation} on $\\Aut(U)$).\n    \\begin{proof}\n        $\\subseteq$: Let $a \\in acl(A)$, let $\\phi(x,\\bar{z})$ be an $L$-formula s.t. $\\phi(a,\\bar{b})$ holds for $\\bar{b}$ in $A$, and $|\\phi(U,\\bar{b})| < \\omega$. Then $\\phi(\\beta(a),\\beta(\\bar{b}))$ holds, $|\\phi(U,\\beta(\\bar{b}))| < \\omega$, and so $\\beta(a)$ is algebraic over $\\beta[\\bar{b}]$.\\\\\n        The same proof with $\\beta^{-1}$ in place of $\\beta$ and $\\beta[A]$ in place of $A$ show $\\supseteq$.\n    \\end{proof}\n\\end{prop}\n\n\\newpage\n\n\\section{Strongly minimal theories}\n\n\\begin{defi} (8.1)\\\\\n    Let $\\mathcal{M}$ be a structure. $A\\subseteq M$ is \\emph{cofinite} if $M \\setminus A$ is finite.\n\\end{defi}\n\n\\begin{rem} (8.2)\\\\\n    Finite and cofinite sets are definable (from now on we always mean definable with parameters) in every structure.\\\\\n    In this chapter, we'll look at structures where these are the only definable sets.\n\\end{rem}\n\n\\begin{defi} (8.3)\\\\\n    A structure $\\mathcal{M}$ is \\emph{minimal} if all its definable subsets are finite or cofinite.\\\\\n    Unfortunately (as we could expect), this is not definable in first-order logic. So we'll introduce a stronger notion: $\\mathcal{M}$ is \\emph{strongly minimal} if it is minimal and all its elementary extensions are minimal.\\\\\n    If $T$ is a consistent theory without finite models, $T$ is \\emph{strongly minimal} if for every formula $\\phi(x,\\bar{z})$, there is $n \\in \\omega \\setminus 0$ s.t.\n    $$T \\vdash \\forall \\bar{z} [\\exists^{\\leq n} x \\phi(x,\\bar{z}) \\vee \\exists^{\\leq n} x \\neq \\phi(x,\\bar{z})]$$\n\\end{defi}\n\n\\begin{eg}\n    $L=\\{E\\}$ where $E$ is binary, let $\\mathcal{M}$ be the $L$-structure where $E$ is an equivalence relation with exactly one class of size $n$ for all $n \\in \\omega$, and no infinite classes.\\\\\n    We can show $\\mathcal{M}$ is minimal (can only say $\\wedge$ of things like $x$ is in the same class as $a$).\\\\\n    There is $\\mathcal{N} \\succcurlyeq \\mathcal{M}$ where $\\mathcal{N}$ has an infinite class. Then if the equivalence class of $a \\in \\mathcal{N}$ is infinite, the set defined by $E(x,a)$ is infinite/coinfinite.\n\\end{eg}\n\n\\begin{rem}\n    Strongly minimal theories have monster models.\n\\end{rem}\n\nFrom now on, we'll assume by default $T$ is strongly minimal, complete, and has an infinite model.\n\n\\begin{defi} (8.4)\\\\\n    Let $a \\in U$ a monster model of $T$, $B \\subseteq U$. Then $a$ is \\emph{independent from $B$} if $a \\not\\in acl(B)$.\\\\\n    The set $B$ is \\emph{independent} if for all $a \\in B$, $a \\not\\in acl(B\\setminus\\{a\\})$.\n\\end{defi}\n\n---Lecture 15---\n\nReminder: optional non-examinable lecture on Monday 26 (on saturated models).\n\nThursday 17 January: third example class (2-3 pm).\n\n\\begin{eg}\n    Consider \\emph{Vector spaces}: Fix an infinite field $K$; $L_K = \\{+,-,\\mathbf{0},\\{\\lambda\\}_{\\lambda \\in K}\\}$ where $\\lambda$ are unary functions (for scalar multiplications).\\\\\n    Let $T_{VSK}$ be the theory of vector spaces over $K$, which includes:\\\\\n    $\\bullet$ axioms in $\\{+,-,\\mathbf{0}\\}$ for abelian group;\\\\\n    $\\bullet$ axiom schemata for scalar multiplication: $\\forall xy[\\lambda(x+y)=\\lambda x+\\lambda y]$ for each $\\lambda \\in K$, where by $\\lambda x$ means $\\lambda(x)$;\n    $\\bullet$ $\\forall x [1x = x]$ where $1$ is in scalar in $K$;\\\\\n    $\\bullet$ $\\exists x[x \\neq \\mathbf{0}]$.\n\n    Fact: $T{VSK}$ is complete and has q.e..\\\\\n    Atomic formulas: equality of linear combinations;\\\\\n    Atomic formula in one variable and with parameters is equivalent to something of the form $\\lambda x = a$, so atomic formulas in one variable define singletons.\\\\\n    Quantifier-free formulas in one variable and with parameters define sets that are either finite or cofinite.\\\\\n    By q.e., $T_{VSK}$ is strongly minimal.\\\\\n    Also: $acl(A) = \\bra A \\ket$ the linear span of $A$, so $a$ is independent from $A$ if it is not a linear combination of elements in $A$, and a set $A$ is independent if it is linearly independent (that probably explains the name).\n\n    Now consider \\emph{Fields}: In the language $L_{ring} =\\{+,\\cdot,-,0,1\\}$, we use ACF (algebraic closed field) to denote the theory that includes:\\\\\n    $\\bullet$ axioms for abelian group in $\\{+,-,0\\}$;\\\\\n    $\\bullet$ axioms for multiplicative monoid $\\{\\cdot,1\\}$;\\\\\n    $\\bullet$ distributivity: $\\forall xyz [x \\cdot (y+z) = x \\cdot y + x \\cdot z]$;\\\\\n    $\\bullet$ multiplicative inverse: $\\forall x [x = 0 \\vee \\exists y ( x \\cdot y) = 1]$;\\\\\n    $\\bullet$ $0 \\neq 1$;\\\\\n    The above characterizes a field; for algebraic closedness, we further add\\\\\n    $\\bullet$ axioms for algebraic closure: for all $n$, $\\forall x_0,...,x_n \\exists y [x_n y^n + ... + x_0 = 0]$.\n\n    It can be proved that ACF is q.e., but is not complete (because it doesn't determine the characteristic of the field). If $\\chi_p \\equiv \\underbrace{1+1+...+1}{p \\text{ times}} = 0$, then ACF + $\\{\\chi_p\\}$ = $ACF_p$, which is complete and has q.e..\\\\\n    By adding $\\{\\neg \\chi_n: n \\in \\omega\\}$ to ACF, we get a theory $ACF_0$ which is also complete and q.e..\\\\\n    Atomic formulas with parameters are polynomial equations; an atmoic formula with one variable (and parameters in $A$) is equivalent to $p(x) = 0$ where $p(x)$ is a polynomial in the subfield generated by $A$. So such atomic formulas define finite sets (solution sets), and q.f. formulas define finite or cofinite sets, and so by q.e., $ACF_p$ ($ACF_0$) is strongly minimal.\\\\\n    If $a \\in \\mathcal{M} \\vDash ACF_p$, $A \\subseteq \\mathcal{M}$, $a \\in acl(A)$ is algebraic over the field generated by $A$.\n\\end{eg}\n\nIf $a \\in U$, $A \\subseteq U$, remember that $a$ is independent from $A$ if $a \\not\\in acl(A)$.\\\\\nNotation: we write $acl(a,B)$ for $acl(\\{a\\} \\cup B)$, and $acl(B \\setminus a)$ for $acl(B \\setminus \\{a\\})$.\n\n\\begin{thm} (8.5)\\\\\n    Let $B \\subseteq U$, and $a,b \\not\\in acl(B)$ ($a,b \\in U \\setminus acl(B)$).\\\\\n    Then $b \\in acl(a,B) \\iff a \\in acl(b,B)$.\n    \\begin{proof}\n        Let $a,b \\not\\in acl(B)$. Assume $b \\not\\in acl(a,B)$ and $a \\in acl(b,B)$.\\\\\n        Then we have some $\\phi(x,y)$, an $L(B)$-formula, s.t. for some $n$, $\\phi(a,b) \\wedge \\exists^{\\leq n} x \\phi(x,b)$.\\\\\n        Since $b \\not\\in acl(a,B)$, the formula $\\psi(a,y) \\equiv \\phi(a,y) \\wedge \\exists^{\\leq n} x \\phi(x,y)$ is s.t. $|\\psi(a,U)| \\geq \\omega$.\\\\\n        Hence $|\\psi(a,U)| = |U|$. By strong minimality, $|\\neg \\psi(a,U)| < \\omega$. By cardinality consideration, if $\\mathcal{M} \\supseteq B$, then $\\mathcal{M}$ contains $c$ s.t. $\\psi(a,c)$. But then $a \\in acl(c,B)$, so $a \\in \\mathcal{M}$. Therefore $a$ is in all models containing $B$; so $a \\in acl(B)$, contradiction by (7.12).\n    \\end{proof}\n\\end{thm}\n\n\\begin{defi} (8.6)\\\\\n    Let $B \\subseteq C \\subseteq U$. Then $B$ is a \\emph{basis} of $C$ if\\\\\n    (i) $B$ is independent;\\\\\n    (i) $C \\subseteq acl(B)$ (or equivalently, $acl(B) = acl(C)$).\n\\end{defi}\n\n\\begin{lemma} (8.7)\\\\\n    If $B$ is indenepdent and $a \\not\\in acl(B)$, then $\\{a\\} \\cup B$ is independent.\\\\\n    \\begin{proof}\n        Let $A \\not\\in acl(B)$, and suppose (for contradiction) that $\\{a\\} \\cup B$ is not independent. Then there is $b \\in B$ s.t. $b \\in acl(a,B \\setminus b)$. But then $b \\not\\in acl(B \\setminus b)$; since $a \\not\\in acl(B)$, we have $a \\in acl(b,B\\setminus b) = acl(B)$. Contradiction.\n    \\end{proof}\n\\end{lemma}\n\n\\begin{coro} (8.8)\\\\\n    If $B \\subseteq C$, the following are equivalent:\\\\\n    (i) $B$ is a basis of $C$;\\\\\n    (ii) if $B \\subseteq B' \\subset C$ and $B'$ is independent, then $B=B'$.\n    \\begin{proof}\n        By lemma 8.7.\n    \\end{proof}\n\\end{coro}\n\n\\begin{thm} (8.9)\\\\\n    Let $C \\subseteq U$. Then \\\\\n    (i) every independent subset $B \\subseteq C$ can be extended to a basis;\\\\\n    (ii) if $A,B$ are bases of $C$, then $|A| = |B|$.\n    \\begin{proof}\n        (i) If $\\bra B_i \\subseteq B:i < \\lambda \\ket$ is a chain of independent sets containing $B$, then $\\cup_{i < \\lambda} B_i$ is indepnedent by using 7.13(i). So by Zorn's lemma, there is a maximal independent subset of $C$ that contains $B$. But then by maximality it must be a basis (8.8).\\\\\n        We'll leave (ii) to next time.\n    \\end{proof}\n\\end{thm}\n\n\\subsection{Interlude: existence of saturated model (non-examinable)}\n\nIf $\\mathcal{M}$ is saturated, then:\n$\\bullet$ $\\mathcal{M}$ is homogeneous;\\\\\n$\\bullet$ $\\mathcal{M}$ is universal.\n\nIf $\\mathcal{M}$ is $\\lambda$-saturated, then:\n$\\bullet$ $\\mathcal{M}$ is \\emph{weakly $\\lambda$-homogeneous}, i.e. for all $f:\\mathcal{M} \\to \\mathcal{M}$ (partial) elementary s.t. $|f| < \\lambda$, for every $b \\in \\mathcal{M}$, we have $\\exists \\hat{f} \\supseteq f$ elementary and s.t. $b \\in \\dom(f)$ (we can do one point extention).\n\nWe can prove: $\\lambda$-homogeneity is equivalent to homogeneity when $|\\mathcal{M}| = \\lambda$.\n\n\\begin{defi}\n    If $\\alpha$ is a limit cardinal $\\geq \\omega$, $cof(\\alpha)$ (cofinality of $\\alpha$) is the least $\\lambda$ s.t. there is $f:\\lambda \\to \\alpha$ s.t. the range of $f$ is unbounded in $\\alpha$.\n\\end{defi}\n\nWe have $cof(\\omega) = \\aleph_0$; $cof(\\omega_\\omega) = \\aleph_0$.\\\\\nA cardinal $\\kappa$ is regular if $cof(\\kappa) = \\kappa$. So $\\aleph_0$ is regular.\\\\\nAlso, every successor cardinal is regular. Are there any limit cardinals that are regular, other than $\\aleph_0$? This is still open.\\\\\nThis turns out to be important, because we have saturated models assuming the existence of limit cardinals.\n\nIf $\\mathcal{M} \\vDash T$, $A \\subseteq \\mathcal{M}$, then $S_1^\\mathcal{M}(A) = \\{p(x):p(x)$ is a complete type in a single variable with parameters in $A\\}$.\n\n\\begin{lemma}\n    If $\\mathcal{M}$ is s.t. $|\\mathcal{M}| \\geq |L|+\\omega$.\\\\\n    Let $\\kappa > \\aleph_0$. Then there is $\\mathcal{M}' \\succcurlyeq \\mathcal{M}$ s.t. for all $A \\subseteq \\mathcal{M}$ with $|A| < \\kappa$, if $p(x) \\in S_1^\\mathcal{M}(A)$, then $p(x)$ is realized in $\\mathcal{M}'$, $|\\mathcal{M}'| \\leq |\\mathcal{M}|^\\kappa$.\n    \\begin{proof}\n        First, note $|\\{A \\subseteq \\mathcal{M}: |A| \\leq \\kappa\\}| \\leq |\\mathcal{M}|^\\kappa$.\\\\\n        Also, $|S_1^\\mathcal{M}(A)| \\leq 2^\\kappa$ (types are infinite sets of formulas, and each formula is some finite string of symbols in $L(A)$?)\\\\\n        Enumerate $S_1^\\mathcal{M}(A)$ as $\\bra p_\\alpha:\\alpha<|\\mathcal{M}|^\\kappa\\ket$.\\\\\n        Build $\\bra \\mathcal{M}_\\alpha:\\alpha<|\\mathcal{M}|^\\kappa\\ket$ as follows:\n        $\\bullet$ $\\mathcal{M}_0 = \\mathcal{M}$;\\\\\n        $\\bullet$ $\\mathcal{M}_\\alpha =\\cup_{\\beta < \\alpha} \\mathcal{M}_\\beta$ when $\\alpha$ is a limit;\\\\\n        $\\bullet$ $\\mathcal{M}_\\alpha \\preccurlyeq \\mathcal{M}_{\\alpha+1}$ s.t. $\\mathcal{M}_{\\alpha+1}$ realizes $p_\\alpha(x)$ and $|\\mathcal{M}_{\\alpha+1}| = |\\mathcal{M}_\\alpha|$ (We can use downward L-S theorem to keep the size constant in this step).\\\\\n        Then $\\cup_{\\alpha<|\\mathcal{M}|^kappa}$ realizes all types in $S_1^\\mathcal{M}(A)$ and $|\\cup_{\\alpha<|\\mathcal{M}|^\\kappa} \\mathcal{M}_\\alpha| \\leq |\\mathcal{M}|^\\kappa$.\n    \\end{proof}\n\\end{lemma}\n\n\\begin{thm}\n    Let $\\kappa > \\aleph_0$. Let $\\mathcal{M} \\vDash T$ (a complete theory without finite models). Then there is a $\\kappa^+$-saturated $\\mathcal{N} \\succcurlyeq \\mathcal{M}$ s.t. $|\\mathcal{N}| \\leq |\\mathcal{M}|^\\kappa$.\n    \\begin{proof}\n        Build an elmentary chain $\\bra \\mathcal{N}_\\alpha:\\alpha<|\\kappa^+\\ket$ s.t.:\\\\\n        $\\bullet$ $\\mathcal{N}_0 = \\mathcal{M}$;\\\\\n        $\\bullet$ take unions at limit stages;\\\\\n        $\\bullet$ Given $\\mathcal{N}_\\alpha$, find $\\mathcal{N}_{\\alpha+1} \\succcurlyeq \\mathcal{N}_\\alpha$ s.t. all types in $S_1^{\\mathcal{N}_\\alpha}(A)$ with $|A| \\leq \\kappa$ are realized.\\\\\n        Moreover, $|\\mathcal{N}_\\alpha| \\leq |\\mathcal{M}|^\\kappa$ (follows from previous lemma).\\\\\n        Now take the union, $\\mathcal{N} = \\cup_{\\alpha < \\kappa^+} \\mathcal{N}_\\alpha$. Since $\\kappa^+ \\leq |\\mathcal{M}|^\\kappa$, $\\mathcal{N}$ is the union of at most $|\\mathcal{M}|^\\kappa$ sets, each of size at most $|\\mathcal{M}|^\\kappa$, hence $|\\mathcal{N}| \\leq |\\mathcal{M}|^\\kappa$.\\\\\n        To see that $\\mathcal{N}$ is $\\kappa^+$-saturated, pick $A \\subseteq \\mathcal{N}$ s.t. $|A|\\leq \\kappa$. Now we need regularity of $\\kappa$: if $\\kappa$ is regular, there is $\\alpha$ s.t. $A \\subseteq \\mathcal{N}_\\alpha$, hence all types over $A$ with one free-variable are realized in $\\mathcal{N}$.\n    \\end{proof}\n\\end{thm}\n\nRecap: for arbitrarily large $\\kappa$, there is a $\\kappa^+$-saturated $\\mathcal{N} \\succcurlyeq \\mathcal{N}$ with $|\\mathcal{N}| \\leq |\\mathcal{M}|^\\kappa$. If $\\kappa, |\\mathcal{M}|$ are s.t. $|\\mathcal{M}| \\leq 2^\\kappa$, then $|\\mathcal{M}|^\\kappa = 2^\\kappa$.\\\\\nSo we get a $\\kappa^+$ saturated extension $\\mathcal{N} \\succcurlyeq \\mathcal{M}$ s.t. $|\\mathcal{N}| = 2^\\kappa$. So if we assume GCH, we see that saturated models exist.\n\nThis is one way to deduce the existence of saturated models (by GCH). Alternatively, suppose there are arbitrarily large cardinals $\\kappa$ s.t. $\\kappa^{<\\kappa} =\\cup\\{\\kappa^\\alpha:\\alpha<\\kappa\\} = \\kappa$ (strongly inaccessible cardinals).\n\n\\begin{defi}\n    Suppose $T$ is a complete theory (in countable language $L$), $\\kappa \\geq \\aleph_0$ a cadrinal. Then $T$ is $\\kappa$-stable if for all $\\mathcal{M} \\vDash T$, $A \\subseteq \\mathcal{M}$, $|A| \\leq \\kappa$, $\\forall n < \\omega$ $|S_n^\\mathcal{M}(A)| \\leq \\kappa$ (the set of complete types with $n$ variables and parameters in $A$).\n\\end{defi}\n\n\\begin{thm}\n    Let $\\kappa$ be a regular cardinal, $T$ a $\\kappa$-stable theory. Then there is $\\mathcal{M} \\vDash T$, $|\\mathcal{M}| = \\kappa$, $\\mathcal{M}$ saturated.\n    \\begin{proof}\n        We build an elementary chain $\\bra \\mathcal{M}_\\alpha: \\alpha < \\kappa \\ket$ where $|\\mathcal{M}_\\alpha| = \\kappa$ as follows:\\\\\n        $\\bullet$ $\\mathcal{M}_0 \\vDash T$ (of size $\\kappa$);\\\\\n        $\\bullet$ unions at limit stages;\\\\\n        $\\bullet$ given $\\mathcal{M}_\\alpha$, $|\\mathcal{M}_\\alpha| \\implies S_1^{\\mathcal{M}_\\alpha}(\\mathcal{M}_\\alpha) = \\kappa$.\\\\\n        There is $\\mathcal{M}_{\\alpha+1} \\succcurlyeq \\mathcal{M}_\\alpha$ that realizes all $1$-types in $S_1^{\\mathcal{M}_\\alpha}(\\mathcal{M}_\\alpha)$, and $|\\mathcal{M}_{\\alpha+1}| = |\\mathcal{M}_\\alpha|$.\\\\\n        Let $\\cup_{\\alpha<\\kappa} \\mathcal{M}_\\alpha$, then $|\\cup \\mathcal{M}_\\alpha| = \\kappa$, and $\\cup \\mathcal{M}_\\alpha$ is $\\kappa$-saturated by construction.\n    \\end{proof}\n\\end{thm}\n\n\n\\newpage\n\n\\section{Example class 1}\n\n\\subsection{Question 3}\n(i) if $\\phi(\\bar{x})$ is universal (i.e. $\\forall \\bar{y} \\psi(\\bar{x},\\bar{y})$ where $\\psi(\\bar{x},\\bar{y})$ is quantifier-free), then $\\mathcal{N} \\vDash \\phi(\\beta(\\bar{a})) \\implies \\mathcal{M} \\vDash \\phi(\\bar{a})$.\\\\\n(ii) Consider $\\mathcal{N} = (\\{\\frac{n}{2} : n \\in \\Z \\},+)$. Assume for a $X$ that $\\phi(x)$ exists. Then $\\mathcal{M} \\vDash \\phi(1)$ as $1$ is odd. Now consider $\\beta:M \\to N$ defined by $n \\to \\frac{n}{2}$; it's an isomorphism between $\\mathcal{M}$ and $\\mathcal{N}$; Also, $id:\\mathcal{M} \\to \\mathcal{N}$ is an embedding. In particular, if $\\mathcal{M} \\vDash \\phi(1)$, then $\\mathcal{N} \\vDash \\phi(1)$; but $\\mathcal{M} \\equiv \\mathcal{N}$ by the isomorphism, so $\\mathcal{N} \\vDash \\forall x (\\phi(x) \\leftrightarrow \\forall y (y +y \\neq x))$, however that is not true in $\\mathcal{N}$.\n\n\\subsection{Question 4}\n(i) $\\implies$ (ii): $id: A \\to N$ is an embedding.\\\\\n(ii) $\\implies$ (i): Define structure on $A$: $c^{\\mathcal{M}} = c^{\\mathcal{N}}$, $R^{\\mathcal{M}} = R^{\\mathcal{N}} \\cap A^{n^R}$, and similar for functions.\n\n\\subsection{Question 5}\nProve that $\\mathcal{M} \\preccurlyeq \\mathcal{N} \\iff \\mathcal{M} \\equiv_M \\mathcal{N}$, where $L(M) = L \\cup \\{c_a: a \\in M\\}$.\\\\\nIt should be clear that everything follows from the fact that, $\\mathcal{M} \\vDash \\phi(\\bar{a})$ as an $L$-structure iff $\\mathcal{M} \\vDash \\phi(c_{a_1},...,c_{a_n})$ as an $L(M)-$structure.\n\n\\subsection{Question 6}\nWe have $[0,1] \\equiv [0,2]$ (seen in lectures, as they are isomorphic as $L_{lo}$-structures. However, $[0,1] \\not\\preccurlyeq [0,2]$ as $1$ has a property in LHS which it doesn't have in RHS.\\\\\nInstead, $(0,1) \\preccurlyeq (0,2)$. It's best to use part (i): If $\\mathcal{M},\\mathcal{N}$ are s.t. $A \\subseteq M \\cap N$, then $\\mathcal{M} \\equiv_A \\mathcal{N} \\iff \\mathcal{M} \\equiv_B \\mathcal{N}$ for every $B \\stackrel{fin}{\\subseteq} A$.\\\\\nSelect finite $B \\subseteq (0,1) \\cap (0,2)$, and show $(0,1) \\equiv_B (0,2)$.\\\\\nInduction on complexity of formulas are not strictly necessary; instead if we can find an isomorphism that fixes the elements of $B$ then we're done.\\\\\nSay $B =\\{b_0,...,b_n\\}$, where $b_m \\geq b_i \\forall b_i \\in B$. We can just send every $x \\leq b_n$ in $(0,1)$ to the same $x$ in $(0,2)$, and rescale the interval $(x,1)$ to match $(x,2)$, which gives an isomorphism.\\\\\n\n\\subsection{Question 7}\nLet $\\phi(\\bar{x})$ be a formula and $\\bar{a} \\in M_i^{|\\bar{x}|}$.\\\\\nIt's required to prove that $\\mathcal{M}_i = \\phi(\\bar{a}) \\iff \\mathcal{N} \\vDash \\phi(\\bar{a})$. By induction on $\\phi(\\bar{x})$: if $\\phi(\\bar{x})$ is atomic, claim follows from $\\mathcal{M}_i \\subseteq \\mathcal{N}$ (substructure); $\\wedge$ and $\\neg$ are also easy induction;\\\\\nFor existential formula $\\phi(\\bar{x}) \\equiv \\exists sy \\psi(\\bar{x},y)$, if $\\mathcal{M} \\vDash \\exists y \\psi(\\bar{a},y)$, then $\\mathcal{M} \\vDash \\psi(\\bar{a},b)$ for $b$ in some $\\mathcal{M}_i$, so $\\mathcal{N} \\vDash \\psi(\\bar{a},b)$;\\\\\nConversely, if $\\mathcal{N} \\vDash \\exists y \\psi(\\bar{a},y)$, then $\\mathcal{N} \\vDash \\psi(\\bar{a},b)$ for $b \\in \\mathcal{N}$. But then $\\bar{a},b$ are in some $\\mathcal{M}_j$ for some finite $j$; as a result, by inductive hypothesi $\\mathcal{M}_j \\vDash \\exists y \\psi (\\bar{a},y)$.\\\\\nBut then $\\mathcal{M}_i \\vDash \\exists y \\psi(\\bar{a},y)$ by elementarity.\\\\\nAlternatively, use T-V test.\n\n\\subsection{Question 8}\n(Lecturer is assuming CH here............)\\\\\nFirst show that $(\\Q+\\R) \\not\\cong (\\R,<)$. Then for any $U \\vDash T_{dlo}$ with $|U| = \\lambda > 2^{\\aleph_0}$. Then prove $(\\Q+\\R+U) \\not\\cong \\R+U$.\n\n\\newpage\n\n\\section{Example Class 2}\n\n\\subsection{Question 1}\nIdea: build a chain $\\bra \\mathcal{K}_i:i < \\omega\\ket$ of countable $\\mathcal{K}_i \\preccurlyeq \\mathcal{N}$ and $\\bra \\mathcal{M}_i : i < \\omega \\ket$ coutnable s.t. \\\\\n(i) $A \\cap \\mathcal{M} \\subseteq \\mathcal{M}_i$;\\\\\n(ii) $A \\subseteq \\mathcal{K}_i \\forall i$;\\\\\n(iii) $A \\cup \\mathcal{M}_i \\subseteq \\mathcal{K}_{i+1}$, $i < \\omega$.\\\\\nBy downward L-S, let $\\mathcal{K}_0 \\preccurlyeq \\mathcal{N}$ s.t. $A \\subseteq \\mathcal{K}_0$.\\\\\nAt stage $i+1$, let $\\mathcal{M} \\cap \\mathcal{K}_i \\subseteq \\mathcal{M}_i \\preccurlyeq\\mathcal{M}$, and $\\mathcal{K}_i \\cup \\mathcal{M}_i \\subseteq \\mathcal{K}_{i+1} \\preccurlyeq \\mathcal{N}$ (and let all of these to be countable).\nLet $\\mathcal{K} = \\cup_{i < \\omega} \\mathcal{K}_i$, and $\\mathcal{M}' = \\cup_{i < \\omega} \\mathcal{M}_i$, $K \\cap \\mathcal{M} = \\mathcal{M}'$ (check this) $\\preccurlyeq \\mathcal{M}$, hence $\\mathcal{M}' \\preccurlyeq \\mathcal{N}$.\\\\\nNote that this only works if $|\\mathcal{N}|$ is more than countable. But if it is countable then we can just use $\\mathcal{K} = \\mathcal{N}$.\n\n\\subsection{Question 2}\nWe just have to prove that the new graph is still a random graph. Suppose we've removed $a_1,...,a_k$ and their neighbours. For any set of $x_1,...,x_n,y_1,...,y_m$ in the axiom, just add the $a_i$'s as additional $y_i$'s and consider in the original graph.\n\n\\subsection{Question 3}\n$\\mathcal{N}$ is not connected so it's not a random graph.\\\\\nFor the second part use $\\psi(x,y) = \\exists z(R(z,x) \\wedge R(z,y))$.\n\n\\subsection{Question 4}\nTrivial\n\n\\subsection{Question 5}\n$T_1$ includes $T_0$ plus axioms for no endpoints plus axioms that say that there are infinitely many equivalent classes, plus the following axiom (density):\n$$\\forall x,y,v[x < y \\to \\exists z[x < z < y \\wedge E(v,z)]]$$\nThe rest is straight-forward.\n\n\\subsection{Question 6}\nSimilar back-and-forth with one-point extensions.\n\n\\subsection{Question 7}\nOnly need to prove (i) $\\implies$ (ii). If $\\omega \\leq |\\phi(x)| < |\\mathcal{N}|$, consider \n$$p(x) = \\{\\phi(x)\\} \\cup \\{x \\neq a : a \\in \\phi(\\mathcal{N})\\}$$\nClearly $p(x)$ is f.s. in $\\mathcal{N}$ (because $|\\phi(\\mathcal{N})| \\geq \\omega$); by saturation it is satisfiable, but that is impossible.\n\n\\subsection{Question 8}\n(ii) $\\implies$ (i) is trivial. Conversely, suppose $p(\\mathcal{N}) = \\{a_1,...,a_n\\}$, and let $p'(x) = p(x) \\cup \\{x \\neq a_i:i=1,...,n\\}$. Then $p'(x)$ is not f.s. in $\\mathcal{N}$, so there is $\\phi(x) \\in p(x)$ s.t. $\\{\\phi(x)\\} \\cup \\{x \\neq a_i: i<n\\}$ is not consistent. So $\\phi(x) \\to \\vee_{i=1}^n x=a_i$ (so $\\phi(x)$ has finite realizations).\n\n\\subsection{Question 9}\nBy symmetry let's only do (ii) $\\implies$ (i): there is an infinite descending sequence, so the type $p(\\bar{x}) = \\{x_i<x_{i+1}, i < \\omega\\}$ is f.s.. So by saturation we're done.\n\n\\newpage\n\n\\section{Revision class}\n\nQuestion on exam info sheet: apply Sheet 3 Q6 repeatedly to get $V \\preccurlyeq U$ s.t. $A \\subseteq V$, $\\bar{c} \\cap V = \\emptyset$.\n\nLet $\\bar{b}$ enumerate $B$, $p(\\bar{x}) = tp(\\bar{b}/A)$, then there is $\\bar{b}' \\Vdash p(\\bar{x})$ in $V$.\n\nSo $tp(\\bar{b}/A) = tp(\\bar{b}'/A)$, hence there is a $\\alpha \\in Aut(U/A)$ s.t. $\\alpha(\\bar{b}) = \\bar{b}'$.\n\nLet $B' = \\{\\bar{b}'\\}$. Then $B' \\subseteq V$, hence $B' \\cap \\bar{c} = \\phi$, so $\\alpha(b) \\cap \\bar{c} = \\phi$, i.e. $B \\cap \\alpha^{-1}(\\bar{c}) = \\phi$.\n\nLook at sheet 3.\n\nWhen we say something without mentioning model, assume in a monster model $U$.\n\nExercise 1: For forward, say $E$ has $n$ equivalence classes, then\n\\[\nU \\vDash \\exists y_1...y_n [\\bigwedge_{i<j} \\neg \\varphi(y_i,y_j)]\n\\]\nand let $M$ be a model, then $M \\vDash $ above as well, so $E$ has at least that many equivalence classes in $M$; but those are all.\n\nFor backward, suppose $|E| \\geq \\omega$, then the type\n\\[\np(\\bar{x}) = \\{\\neg \\varphi(x_i,x_j): i,j < |U|\\}\n\\]\nis finitely consistent, hence realized in $U$ by some $\\bar{b}$ ($U$ is saturated). So there are $|U|$ classes. But any model $M$ does not have that many elements.\n\nExercise 2: Backward: suppose there are two non-isomorphic countable models of $T$, say $M$ and $N$. Then $M$ and $N$ has different dimensions. So say $dim(M) < \\omega$. So a basis $B$ for $M$ is finite, but $acl(B) = M$ is infinite; contradiction.\n\nForward: suppose there's a finite set $A$ whose acl is infinite. Then $acl(A)$ must be just countable since $L$ is a countable language. Sheet 3 Q9 says that any infinite set that is algebraically closed is a model. Then add any element in $U \\setminus acl(A)$, say $b$, then $b$ is independent from $A$. Then $acl(A\\cup\\{b\\})$ has different dimension than $A$, so the models generated are not isomorphic.\n\nExercise 3: Let $N \\vDash T$. Then it's required to prove that if $f:N \\to N$ is a partial elementary map s.t. $|f| < |U|$, then $f$ extends to an automorphism of $U$.\n\nWhen trying to proof homogeneity, always try to see if one-point extension is enough. In this case it is (back and forth method). Idea: build chain $\\bra f_i: i < |N| \\ket$ of partial elementary maps s.t. every element of $N$ appears at some point in both the domain and range. This is because for any $a \\in N$ there is $b \\in N$ s.t. $f \\cup \\{(a,b)\\}$ is elementary: pick $a \\in N \\setminus dom (f)$. If $a \\in acl(dom (f))$, extend $f$ to an isomorphism $\\alpha$ of $U$, then $\\alpha(acl(dom (f))) = acl(\\alpha(dom (f)))$. Then $\\alpha(a) \\in N$. So extend $f$ to $f \\cup \\{(a,\\alpha(a))\\}$. If $a$ is not algebraic over $dom (f)$, there is a single type for all of those non-algebraic elements. Idea: pick $b \\in N \\setminus acl(range(f))$ and extend. So we want to prove that $acl(range(f))$ is not the entire $N$. Let $B$ be a basis for $dom(f)$ (then $f(B)$ is a basis for range of $f$. If $|B| < \\omega$, prove by dimension that $acl(range(f)) = N$ is impossible.\n\n\n\\end{document}\n", "meta": {"hexsha": "9c5d1605297db34aeab4bf309bfdd999020505b5", "size": 101487, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Model Theory.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Model Theory.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Model Theory.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.4165526676, "max_line_length": 972, "alphanum_fraction": 0.6140293831, "num_tokens": 37346, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4307197970457809}}
{"text": "% Created 2016-05-02 mån 18:07\n% Intended LaTeX compiler: pdflatex\n\\documentclass{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\newcommand{\\tustin}{\\frac{2}{h}\\frac{z-1}{z+1}}\n\\author{Kjartan Halvorsen}\n\\date{2016-04-29}\n\\title{Computerized control - final exam (dummy)}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Computerized control - final exam (dummy)},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 24.5.1 (Org mode 8.3.4)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section*{Problem 1}\n\\label{sec:orgheadline1}\nThe figure below shows the poles of a continuous-time transfer function representing the dynamics of a system.\n\\begin{center}\n\\includegraphics[width=0.3\\linewidth]{imaginary-plane-ct-poles}\n\\end{center}\nChoose a reasonable sampling period \\(h\\), and plot the poles of the discrete-time system obtained by zero-order-hold sampling\n\\begin{center}\n\\includegraphics[width=0.3\\linewidth]{imaginary-plane-empty}\n\\end{center}\n\n\\section*{Problem 2}\n\\label{sec:orgheadline5}\nCircle the correct answer to each question. Motivate your answer briefly with 1-2 sentences.\n\n\\subsection*{(a)}\n\\label{sec:orgheadline2}\n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{../../homework/2dof-block-complete}\n\\end{center}\nThe figure above shows a block-diagram of two-degrees-of-freedom control system. Which of the following pulse transfer operators describes the \\textbf{closed-loop response}, \\(y(kh)\\), to the measurement noise sequence, \\(n(kh)\\).    \n\\begin{enumerate}\n\\item \\(H_n(q) = \\frac{1}{1 + G(q)F_b(q)}\\)\n\\item \\(H_n(q) = -\\frac{G(q)F_f(q)}{1 + G(q)F_f(q)}\\)\n\\item \\(H_n(q) = -\\frac{G(q)F_b(q)}{1 + G(q)F_b(q)}\\)\n\\item \\(H_n(q) = \\frac{G(q)F_b(q)}{1 + G(q)F_b(q)}\\)\n\\end{enumerate}\n\n\\subsection*{(b)}\n\\label{sec:orgheadline3}\nThe continuous-time harmonic oscillator has transfer function\n\\[ G(s) = \\frac{\\omega^2}{s^2 + \\omega^2}. \\]\nZero-order hold sampling of the system gives the pulse transfer function\n\\begin{enumerate}\n\\item \\(H(z) = \\frac{(1-\\cos\\omega h)(z+1)}{(z-\\cos \\omega h)^2 + \\sin^2 \\omega h}\\)\n\\item \\(H(z) = \\frac{(1-\\cos\\omega h)(z+1)}{(z-1)^2 + \\sin^2 \\omega h}\\)\n\\item \\(H(z) = \\frac{(1-\\cos\\omega h)(z+1)}{(z+\\cos \\omega h)^2 + \\sin^2 \\omega h}\\)\n\\end{enumerate}\n\n\\subsection*{(c)}\n\\label{sec:orgheadline4}\nThe figure below shows the step-response of a closed-loop system with a discretized PID controller for some values of the controller parameters. In continuous-time the controller has the form\n \\[ F(s) = K\\Big(1 + \\frac{1}{T_i s} + \\frac{T_ds}{1 + T_ds/N}\\Big). \\]\n\\begin{center}\n\\includegraphics[width=0.4\\linewidth]{tuned-response}\n\\end{center}\nHow should the controller be modified if we want the response of the closed-loop system to be \\textbf{faster with less overshoot}?\n\\begin{enumerate}\n\\item Increase \\(N\\) and decrease \\(T_i\\).\n\\item Increase \\(K\\) and \\(T_d\\).\n\\item Decrease \\(K\\) and increase \\(T_d\\).\n\\item Increase \\(K\\) and decrease \\(T_i\\).\n\\end{enumerate}\n\n\n\\section*{Problem 3}\n\\label{sec:orgheadline8}\nConsider the discrete-time double integrator\n\\[ H(z) = \\frac{h^2(z+1)}{2(z-1)^2}. \\]\n\\subsection*{(a)}\n\\label{sec:orgheadline6}\nWrite the system on state-space form, using the controllable canonical form\n\\begin{equation*}\n  \\begin{split}\n  x(k+1) &= \\underbrace{\\bbm -a_1 & -a_2 & \\cdots & - a_{n-1} & -a_n\\\\\n                  1  &   0   &  \\cdots & 0        &   0\\\\\n                  0  &   1   &  \\cdots & 0        &   0\\\\\n                  \\vdots &\\vdots & \\ddots & \\vdots&   \\vdots\\\\\n                  0  &   0   &  \\cdots & 1        &   0\n             \\ebm}_{\\Phi}\n\t     x(k) + \\underbrace{\\bbm 1\\\\0\\\\0\\\\\\vdots\\0\\ebm}_{\\Gamma} u(k), \\\\\n  y(k) &= \\bbm b_1 & b_2 & \\cdots & b_n \\ebm x(k)\n  \\end{split}\n \\end{equation*}\nwhere\n\\[ H(z) = \\frac{b_1z^{n-1} + b_2z^{n-2} + \\cdots + b_n}{z^n + a_1z^{n-1} + \\cdots + a_n}. \\]\n\n\\subsection*{(b)}\n\\label{sec:orgheadline7}\nDetermine a linear state feedback\n\\[ u(k) = -Lx(k) + u_c(k) \\]\nsuch that the closed-loop system has poles in \\(\\pm i0.4\\)\n\n\\section*{Solutions}\n\\label{sec:orgheadline17}\n\\subsection*{Problem 1}\n\\label{sec:orgheadline9}\nThe system has two stable, complex-conjugated poles with distance \\(\\omega_0 = \\sqrt{2}\\) from the origin, and one unstable pole in \\(s=0.5\\). The two stable poles are faster than the unstable pole, since they are farther from the origin. We can use the rule-of-thumb\n\\[ \\omega_0 h \\approx 0.2 - 0.6, \\]\nbut we should be cautious and choose a sampling period in the shorter end of the range. The reason is that zero-order-hold implies a time-delay of approximately \\(h/2\\), and time-delays in unstable systems are problematic.\n\nWith \\(\\omega_0h=0.2\\) we get the discrete time poles\n\\begin{center}\n\\includegraphics[width=0.3\\linewidth]{imaginary-plane-dt-poles}\n\\end{center}\n\n\\subsection*{Problem 2}\n\\label{sec:orgheadline13}\n\n\\subsubsection*{(a)}\n\\label{sec:orgheadline10}\nThe correct answer is: 3. \\(H_n(q) = -\\frac{G(q)F_b(q)}{1 + G(q)F_b(q)}\\). We can calculate the transfer function to find this answer, or argue as follows. There is a minus sign (negation) in the path from \\(n\\) to \\(y\\), so the pulse transfer operator must be negative. Only alternatives 2 and 3 are negative. Of these two, alternative 2 includes the pulse transfer operator \\(F_f(q)\\), but \\(F_f(q)\\) is outside the signal path from \\(n\\) to \\(y\\).\n\n\\subsubsection*{(b)}\n\\label{sec:orgheadline11}\nThe correct answer is: 1. \\(H(z) = \\frac{(1-\\cos\\omega h)(z+1)}{(z-\\cos \\omega h)^2 + \\sin^2 \\omega h}.\\)\nThe harmonic oscillator has poles on the imaginary axis in the continuous-time case, and on the unit circle in the discrete-time case. Both alternative 1 and 3 have poles on the unit circle. However, the discrete-time poles are obtained from the continuous-time poles \\(\\pm i\\omega\\) according to the mapping\n\\[ p = \\mexp{\\pm i\\omega h} = \\cos\\omega h \\pm i\\sin\\omega h, \\]\nwhere the last equality is the famous Euler's formula. Alternative 1 has indeed poles in \n\\[ \\cos\\omega h \\pm i \\sin\\omega h, \\]\nwhereas Alternative 3 has poles in \n\\[ -\\cos\\omega h \\pm i \\sin\\omega h. \\]\n\n\\subsubsection*{(c)}\n\\label{sec:orgheadline12}\nThe correct answer is:  2. Increase \\(K\\) and \\(T_d\\). To make the response faster, we must increase the gain of the controller \\(K\\). Only alternative 2 and 4 suggest this. To make the overshoot smaller, we must increase the damping. This is done by increasing \\(T_d\\). \n\n\\subsection*{Problem 3}\n\\label{sec:orgheadline16}\n\n\\subsubsection*{(a)}\n\\label{sec:orgheadline14}\nThe harmonic oscillator can be written\n\\[ H(z) = \\frac{h^2(z+1)}{2(z-1)^2} = \\frac{h^2/2(z+1)}{z^2-2z + 1}, \\]\nwhich  on controllable canonical form is \n   \\begin{equation*}\n \\begin{split}\n  x(k+1) &= \\bbm 2 & -1\\\\1 & 0 \\ebm x(k) + \\bbm 1\\\\0\\ebm u(k)\\\\\n  y(k) &= \\bbm h^2/2 & h^2/2 \\ebm .\n \\end{split}\n\\end{equation*}\n\n\\subsubsection*{(b)}\n\\label{sec:orgheadline15}\nLinear feedback control of a system on controllable canonical form is particularly easy, since the resulting system is also on controllable canonical form. The closed loop system with\n\\[ u(k) = -Lx(k) + u_c(k) \\]\nhas pulse transfer function\n\\[ H_c(z) = \\frac{h^2/2(z+1)}{z^2 (-2+l_1)z + 1+l_2} \\]\nand the desired denominator is\n\\[ (z-i0.4)(z+i0.4) = z^2 + 0.4^2, \\]\nEquating the coefficients gives the feedback gains\n\\begin{align*}\n-2+l_1 &= 0 \\quad \\Rightarrow \\quad l_1 = 2\\\\\n1+l_2 &= 0.16 \\quad \\Rightarrow \\quad l_2 = -0.84\n\\end{align*}\n\nA step-response with \\(h=1\\) and a step in \\(u_c\\) occurring at \\(t=1\\) is shown below.\n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{problem3_dummy_step_response-crop}\n\\end{center}\n\\end{document}", "meta": {"hexsha": "5a225b779ea434b614b737e3cb2f58ccfbd01cd0", "size": 7850, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/final-exam/final-dummy.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "exams/final-exam/final-dummy.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "exams/final-exam/final-dummy.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 42.8961748634, "max_line_length": 450, "alphanum_fraction": 0.6844585987, "num_tokens": 2631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398982, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4307197886335854}}
{"text": "\\section{Introduction}\n\\label{sec:introduction}\n\n\\begin{figure}[t]\n\t\\centering\n\t\\vspace*{-0.2cm}\n\t\\hspace*{-0.25cm}\n\t\\includegraphics[width=0.5\\textwidth]{plots_contributions_arxiv}\n\t\\vspace*{-18px}\n\t\\caption{\\textbf{Robust Generalization and Flatness:} Robust loss (\\RCE, lower is more robust, y-axis), \\ie, cross-entropy loss on PGD adversarial examples \\cite{MadryICLR2018}, against our \\emph{average-case flatness} measure of \\RCE in weight space (lower is ``flatter'', x-axis).\n\tPopular AT variants improving adversarial robustness on \\CifarT, \\eg, TRADES \\cite{ZhangICML2019}, AT-AWP \\cite{WuNIPS2020}, MART \\cite{WangICLR2020} or AT with self-supervision \\cite{HendrycksNIPS2019}/unlabeled examples \\cite{CarmonNIPS2019}, also correspond to flatter minima. Vice-versa, regularization explicitly improving flatness, \\eg, Entropy-SGD \\cite{ChaudhariICLR2017}, weight decay or weight clipping \\cite{StutzMLSYS2021}, also improve robustness.\n\tAcross all models, there is a \\textbf{clear relationship between good robust generalization and flatness in \\RCE.}\n\t{\\LARGE$\\bullet$},\\raisebox{0.5mm}{$\\mathbin{\\blacklozenge}$} Our models, \\underline{w/o} early stopping.\n\t{\\large$\\blacktriangle$} RobustBench \\cite{CroceARXIV2020b} models \\emph{w/} early stopping.}\n\t\\label{fig:introduction}\n\t\\vspace*{-6px} \n\\end{figure}\n\nIn order to obtain robustness against adversarial examples \\cite{SzegedyICLR2014}, \\emph{adversarial training (AT)} \\cite{MadryICLR2018} augments training with adversarial examples that are generated on-the-fly. While many different variants have been proposed, AT is known to require more training data \\cite{KhouryARXIV2018,SchmidtNIPS2018}, generally leading to generalization problems \\cite{FarniaICLR2019}. In fact, \\emph{robust overfitting} \\cite{RiceICML2020} has been identified as the main problem in AT:  adversarial robustness on test examples eventually starts to decrease, while robustness on training examples continues to increase (\\cf \\figref{fig:main-overfitting}). This is typically observed as increasing \\emph{robust loss (\\RCE)} or \\emph{robust test error (\\RTE)}, \\ie, (cross-entropy) loss and test error on adversarial examples. As a result, the \\emph{robust generalization gap}, \\ie, the difference between test and training robustness, tends to be very large. In \\cite{RiceICML2020}, early stopping is used as a simple and effective strategy to avoid robust overfitting. However, despite recent work tackling robust overfitting \\cite{SinglaARXIV2021,WuNIPS2020,HwangARXIV2020}, it remains an open and poorly understood problem.\n\nIn \\emph{``clean''} generalization (\\ie, on natural examples), overfitting is well-studied and commonly tied to flatness of the loss landscape in weight space, both visually \\cite{LiNIPS2018} and empirically \\cite{NeyshaburNIPS2017,KeskarICLR2017,JiangICLR2020}.\nIn general, the optimal weights on test examples do not coincide with the minimum found on training examples. Flatness ensures that the loss does \\emph{not} increase significantly in a neighborhood around the found minimum. Therefore, flatness leads to good generalization because the loss on test examples does not increase significantly (\\ie, small generalization gap, \\cf \\figref{fig:main-illustration}, right).\n\\cite{LiNIPS2018} showed that \\emph{visually} flatter minima correspond to better generalization. \\cite{NeyshaburNIPS2017} and \\cite{KeskarICLR2017} formalize this idea by measuring the change in loss within a local neighborhood around the minimum considering random \\cite{NeyshaburNIPS2017} or ``adversarial'' weight perturbations \\cite{KeskarICLR2017}.\nThese measures are shown to be effective in predicting generalization in a recent large-scale empirical study \\cite{JiangICLR2020} and explicitly encouraging flatness during training has been shown to be successful in practice \\cite{ZhengARXIV2020c,CicekICCVWOR2019,TinICLR2020,ChaudhariICLR2017,IzmailovUAI2018}.\n\nRecently, \\cite{WuNIPS2020} applied the idea of flat minima to AT: through \\emph{adversarial weight perturbations}, AT is regularized to find flatter minima of the \\emph{robust} loss landscape. This reduces the impact of robust overfitting and improves robust generalization, but does not \\emph{avoid} robust overfitting. As result, early stopping is still necessary. Furthermore, flatness is only assessed \\emph{visually} and it remains unclear whether flatness does actually improve in these adversarial weight directions.\nSimilarly, \\cite{GowalARXIV2020} shows that weight averaging \\cite{IzmailovUAI2018} can improve robust generalization, indicating that flatness might be beneficial in general. This raises the question whether other ``tricks'' \\cite{PangARXIV2020b,GowalARXIV2020}, \\eg, different activation functions \\cite{SinglaARXIV2021} or label smoothing \\cite{SzegedyCVPR2016}, or approaches such as AT with self-supervision \\cite{HendrycksNIPS2019}/unlabeled examples \\cite{CarmonNIPS2019} are successful \\emph{because of} finding flatter minima.\n\n\\begin{figure}[t]\n\t\\centering\n\t\\vspace*{-0.2cm}\n\t\\includegraphics[width=0.225\\textwidth]{plots_short_introduction_overfitting1}\n\t\\includegraphics[width=0.225\\textwidth]{plots_short_introduction_overfitting2}\n\t\\vspace*{-8px}\n\t\\caption{\\textbf{Robust Overfitting:} Robust (cross-entropy) loss (\\RCE) and robust error (\\RTE) over epochs (normalized by $150$ epochs) for AT, \\red{using a ResNet-18 on \\CifarT (\\cf \\secref{sec:experiments})}, to illustrate \\emph{robust} overfitting. \\textbf{Left:} Training \\RCE ({\\color{plot0}light blue}) reduces continuously throughout training, while test \\RCE ({\\color{plot1}dark blue}) eventually increases again.\n\tWe also highlight that robust overfitting is \\emph{not} limited to incorrectly classified examples ({\\color{plot4}green}), but also affects correctly classified ones ({\\color{plot2}rose}). \\textbf{Right:} Similar behavior, but less pronounced, can be observed considering \\RTE. We also show \\RTE obtained through early stopping ({\\color{plot5}red}).}\n\t\\label{fig:main-overfitting}\n\t\\vspace*{-6px}\n\\end{figure}\n\n\\textbf{Contributions:} In this paper, we study \\textbf{whether flatness of the robust loss (\\RCE) in weight space improves robust generalization}. To this end,\nwe propose both average- and worst-case flatness measures for the \\emph{robust} case, \\red{thereby addressing challenges such as scale-invariance \\cite{DinhICML2017}, estimation of \\RCE on top or jointly with weight perturbations, and the discrepancy between \\RCE and \\RTE}. We show that \\textbf{robust generalization generally improves alongside flatness} and vice-versa: \\figref{fig:introduction} plots \\RCE (lower is more robust, y-axis) against our average-case flatness in \\RCE (lower is flatter, x-axis), showing a clear relationship. \n\\red{In contrast to \\cite{WuNIPS2020}, not providing empirical flatness measures, our results show that this relationship is stronger for average-case flatness.}\nThis trend covers a wide range of AT variants on \\CifarT, \\eg,  AT-AWP \\cite{WuNIPS2020}, TRADES \\cite{ZhangICML2019}, MART \\cite{WangICLR2020}, AT with self-supervision \\cite{HendrycksNIPS2019} or additional unlabeled examples \\cite{CarmonNIPS2019,UesatoNIPS2019}, as well as various regularization schemes, including AutoAugment \\cite{CubukARXIV2018}, label smoothing \\cite{SzegedyCVPR2016} and noise or weight clipping \\cite{StutzMLSYS2021}. Furthermore, we consider hyper-parameters, \\eg, learning rate schedule, weight decay, batch size, or different activation functions \\cite{ElfwingNN2018,MisraBMVC2020,HendrycksARXIV2016}, and methods explicitly improving flatness, \\eg, Entropy-SGD \\cite{ChaudhariICLR2017} or weight averaging \\cite{IzmailovUAI2018}.", "meta": {"hexsha": "35e4d17d2dae4b70a64fff991bff28dc00c6f946", "size": 7670, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/sec_introduction.tex", "max_stars_repo_name": "davidstutz/iccv2021-robust-flatness", "max_stars_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-11-08T21:27:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-10T19:09:04.000Z", "max_issues_repo_path": "paper/sec_introduction.tex", "max_issues_repo_name": "davidstutz/iccv2021-robust-flatness", "max_issues_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/sec_introduction.tex", "max_forks_repo_name": "davidstutz/iccv2021-robust-flatness", "max_forks_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 174.3181818182, "max_line_length": 1252, "alphanum_fraction": 0.8011734029, "num_tokens": 2168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4307197886335853}}
{"text": "\\label{aqft}\n\\begin{chapterbox}\n\\vspace{-60pt}\n\\chapter{Advanced Quantum Field Theory}\n\\vspace{-30pt}\n\\centering\\normalsize\\textit{Lent Term 2018 - Dr D. Skinner}\n\\end{chapterbox}\n\\vspace{20pt}\n%\\begin{multicols*}{2}\n\\minitoc\n\\newpage\n\\section{Introduction}\nWhat is a quantum field theory (QFT)? Simply it's the quantum version of a field theory, but it's also a mathematical tool useful for studying ideas outside the direct scope.\\footnote{For example knot invariants, Calabi-Yau manifolds etc.} What do we have to do to design a QFT?\n\\begin{enumerate}\n\\item First we have to choose the space on which it lives. Often this is a (pseudo)-Riemannian manifold, $(\\mM, g)$, but this may depend on the scenario;\n\\begin{itemize}\n\\item Particle physics: $(\\mM, g) = (\\RR^4, \\delta) \\,\\,\\text{or}\\,\\,(\\RR^{3,1}, \\eta)$\n\\item Condensed matter: $(\\mM, g) = (\\RR^3, \\delta)$\n\\item Cosmology: $(\\mM, g) = (\\RR^{3,1}, g_{\\text{FRW}})$\n\\item String Theory: $(\\mM, g) = \\left(\\Sigma, [g] = \\set{g \\sim e^{2\\phi(x)}g}\\right)$ where $\\Sigma$ is a Riemann surface.\n\\end{itemize}\n\\item Next we have to choose the fields. In the simplest case these are just scalar fields\\index{field!scalar}, which are functions $\\phi : \\mM \\rightarrow \\RR, \\CC$. However, there are lots of other options;\n\\begin{itemize}\n\\item Consider $\\phi^a : \\mM \\rightarrow \\mathcal{N}$, where $(\\mathcal{N}, g)$ is another Riemannian manifold e.g. $\\phi : \\RR^4 \\rightarrow G / H$ which is the case for pions\\index{pions} in the SM.\n\\item Gauge theories: fields are $A_{\\mu}$, or connections on $P \\rightarrow \\mM$\n\\item Charged matter: sections of a vector bundle $E \\rightarrow \\mM$\n\\item Spinor fields, $\\psi$\n\\end{itemize}\nIn general we let $\\mC$ denote the space of all field configurations on $\\mM$ so $\\phi \\in \\mC$ represents a picture of what the field looks like.\n\\item Finally, we need to choose an action $S\\left[\\phi\\right]$, where $S : \\mC \\rightarrow \\RR$, a function on the space of fields. The \\emph{critical points}\\index{critical point} of this action\\footnote{$\\phi_0 \\in \\mC$ such that $\\delta S\\left[\\phi_0\\right] = 0$} correspond to field configurations that satisfy the classical equations of motion. We usually choose the action to be local. This means it involves only one integral over the underlying space $\\mM$.\\footnotemark\n\\begin{equation}\nS\\left[\\phi\\right] = \\int_{\\mM}{\\mL(\\phi, \\del_\\mu \\phi)\\sqrt{-g}\\upd{^d x}}\n\\end{equation}\n\\end{enumerate}\n\\footnotetext{\nThis is actually a very strong condition on the action. Even a monomial on $\\mC$ looks like;\n\\begin{equation*}\n\\Lambda\\left[\\phi\\right] = \\int_{\\mM^{\\otimes n}}{\\ud^d x_1\\cdots \\upd{^d x_n}\\phi(x_1)\\cdots\\phi(x_n)\\Lambda(x_1, \\ldots x_n)}\n\\end{equation*}\nLocality ensures we take $\\Lambda(x_1, \\ldots, x_n) = \\lambda(x_1)\\delta(x_1 - x_2)\\cdots\\delta(x_{n-1} - x_n)$, so that;\n\\begin{equation*}\n\\Lambda\\left[\\phi\\right] = \\int_{\\mM}{\\upd{^d x}\\lambda(x)\\phi^n(x)}\n\\end{equation*}\nWe often take $\\lambda(x)$ to be constant, a \\emph{coupling constant}\\index{coupling constant}, but we will see that QFT forces us to consider the more general case.\n}\nSo having made these choices, what do we actually measure? The main interest is the path integral\\index{path integral};\n\\begin{equation}\n\\int_{\\mC}{\\mD \\phi \\,\\, e^{-\\tfrac{S\\left[\\phi\\right]}{\\hbar}}} \\qquad \\text{or} \\qquad \\int_{\\mC}{\\mD \\phi \\,\\, e^{i\\tfrac{S\\left[\\phi\\right]}{\\hbar}}} \\text{ if} \\mM \\text{ is Lorentzian}\n\\end{equation}\nWe start to evaluate this qualitatively. It is an integral over an infinite dimensional space with weighting functions $\\exp(-S[\\phi]/\\hbar)$, which tries to suppress wild field configurations.\\footnote{For example, $\\del \\phi$ is large when $\\phi$ oscillates rapidly, or $\\phi$ large if the field value is large leading to large $S[\\phi]$ and small $\\exp(-S[\\phi]/\\hbar)$.} But, as in statistical mechanics, there is an energy vs entropy competition between suppressing wild configurations, and the fact that there are simply many more of them compared to `sensible' field profiles. There is a very delicate balance between the two as to whether the path integral will converge. The partition function\\index{partition function} for $\\mM$ compact and without boundary;\n\\begin{equation}\n\\mathcal{Z} = \\int_{\\mC[\\mM]}{\\mD \\phi e^{-\\tfrac{S[\\phi]}{\\hbar}}} = \\mathcal{Z}_{(\\mM, g)}(\\lambda, \\ldots)\n\\end{equation}\nWe also want to compute correlation functions\\index{correlation function}. This involves picking other functions $\\mO^i[\\phi]$, known as operators\\index{operator} or operator insertions\\index{operator!insertions} and define;\n\\begin{equation}\n\\left< \\prod_i {\\mO^i[\\phi]} \\right> = \\frac{1}{\\mathcal{Z}}\\int_{\\mC}{\\mD \\phi \\,\\, e^{-S[\\phi]/\\hbar}\\prod_i{\\mO^i[\\phi]}}\n\\end{equation}\nOperator insertions can live at points $x_i \\in \\mM$ or integrated over some subspace of $\\mM$ e.g. a Wilson loop. These correlation functions depend on all the choices we made for our QFT as well as the $\\mO[\\phi]$. But they don't depend on the fields; these were integrated out.\n\n\\paraskip\nCorrelation functions\\index{correlation functions} are also closely related to the partition function. Suppose $S[\\phi]$ contains a term $\\lambda \\int_{\\mM}{\\ud^d x\\sqrt{-g}\\phi^4}$, then (assuming we can move the derivative through $\\mathcal{D} \\phi$);\n\\begin{align*}\n-\\hbar \\frac{\\del}{\\del \\lambda}\\mZ &= -\\hbar \\int{\\mD\\phi \\,\\,\\frac{\\del}{\\del \\lambda}e^{-S[\\phi]/\\hbar}} \\\\\n&=\\int{\\mD\\phi \\,\\, e^{-S[\\phi]/\\hbar}\\int_{\\mM}{\\upd{^d x}\\sqrt{-g}\\phi^4}} \\\\\n\\Rightarrow -\\frac{\\hbar}{\\mZ}\\frac{\\del \\mZ}{\\del \\lambda} &= \\left< \\int_{\\mM}{\\sqrt{-g}\\upd{^d x}\\phi^4} \\right>\n\\end{align*}\nSo we see knowing $Z_{(\\mM, g)}(\\lambda, \\ldots)$ is equivalent to knowing the correlation functions of terms in the action. Let's extend this to correlators of operators that depend on $\\phi$ only at a point, e.g. $\\phi(x)^2$. Now we modify the action to allow it to contain sources for these operators;\\footnote{Compare the $J_i(x)$ in this expression to the most general $\\lambda(x)$ we obtained by imposing locality.}\n\\begin{equation}\nS[\\phi] \\mapsto S[\\phi] + \\sum_{i}{\\int_{\\mM}{\\upd{^d x} J_i(x)\\mO_i(x)}}\n\\end{equation}\nThen we find, using $\\delta J(y)/\\delta J(x) = \\delta(x - y)$;\n\\begin{align*}\n\\left.-\\hbar\\frac{\\delta \\mZ}{\\delta J(x)}\\right|_{J = 0} &= \\left.-\\hbar\\int{\\mD\\phi\\,\\,\\frac{\\delta}{\\delta J(x)}\\exp\\left[\\left(-S[\\phi] - \\int{\\upd{^d y}J(y)\\mO(y)}\\right)/\\hbar\\right]}\\right|_{J = 0} \\\\\n&= \\int{\\mD\\phi e^{-S[\\phi]/\\hbar}\\int{\\upd{^d y}\\frac{\\delta J(y)}{\\delta J(x)}\\mO(y)}} \\\\\n\\Rightarrow \\left.-\\frac{\\hbar}{\\mZ}\\frac{\\delta \\mZ}{\\delta J(x)}\\right|_{J=0} &= \\int{\\mD\\phi e^{-S[\\phi]/\\hbar}\\mO(x)} = \\left< \\mO(x) \\right>\n\\end{align*}\nMore generally;\n\\begin{equation}\n-\\left.\\frac{\\hbar}{\\mZ}\\frac{\\delta^n \\mZ[J_i]}{\\delta J_1(x_1)\\cdots \\delta J_n(x_n)}\\right|_{J_i = 0} = \\left< \\mO_1(x_1)\\cdots\\mO_n(x_n) \\right>\n\\end{equation}\nThe standard example of this is for $\\mO(x) = \\phi(x)$ so that the source term is $\\int_{\\mM}{\\upd{^d x}J(x)\\phi(x)}$. \n\\subsection{Boundaries and Hilbert Spaces}\nSuppose now that $\\mM$ has a boundary $\\bigcup_i B_i$. Then to compute a path integral with $\\del \\mM \\neq \\varnothing$, we have to specify boundary conditions on the fields. These are associated with a Hilbert space\\index{Hilbert space} of the QFT. Then;\n\\begin{equation}\n\\int_{\\left.\\phi\\right|_{B_i} = \\phi_i}{\\mD\\phi\\,\\, e^{-S[\\phi]/\\hbar}}\n\\end{equation}\nmust depend on $\\phi_i$ on each component of the boundary. The standard example to choose is $\\mM = \\mathcal{N}\\times I$ where $\\mathcal{N}$ is a $(d-1)$-dimensional manifold and $I = \\left[0, T\\right]$. We have a Hilbert space, $\\mathfrak{H}$ on $\\mathcal{N}_{t = 0}$ and $\\mathcal{N}_{t = T}$, as well as an associated outward normal vector, $n^\\mu_{0, 1}$. By construction, these naturally have opposite orientations on the space. Then the path integral can be thought of as a map;\n\\begin{equation}\nU(T) : \\mathfrak{H} \\rightarrow \\mathfrak{H}\n\\end{equation}\nor in other words;\n\\begin{equation}\n\\bra{\\phi_{1}}U(T)\\ket{\\phi_0} = \\int_{\\left.\\phi\\right|_{\\mathcal{N}_0} = \\phi_0}^{\\left.\\phi\\right|_{\\mathcal{N}_1} = \\phi_1}{\\mD\\phi \\,\\,e^{-S[\\phi]/\\hbar}}\n\\end{equation}\nSo why do we get a Hilbert space? Note that in classical field theory, varying the action;\n\\begin{equation}\n\\delta S[\\phi] = \\int_{\\mM}{(\\text{bulk e.o.m})\\delta \\phi} + \\sum_{i}{\\int_{B_i}{n^\\mu_i \\frac{\\delta \\mL}{\\delta(\\del^\\mu \\phi)}\\delta \\phi \\sqrt{g}\\,\\,\\ud^{d-1} x}}\n\\end{equation}\nThen we can define the field momentum\\index{field!momentum} on $B_i$ as;\n\\begin{equation}\n\\pi_i = n^\\mu_i \\frac{\\delta \\mL}{\\delta(\\del^\\mu \\phi)}\\sqrt{g}\n\\end{equation}\nNow we can make contact with our previous experience and note that if we just take $B$ to be a constant time slice of $\\RR^{3, 1}$, then we recover $\\pi = \\delta \\mL/\\delta\\del^0 \\phi = \\delta \\mL/\\delta \\dot{\\phi}$. The variation $\\delta$ is really an exterior derivative\\index{exterior derivative} on the space of fields $\\mC$. So $\\delta^2 = 0$, then we use $\\delta^2 S = 0$ in particular when the equations of motion hold to see;\n\\begin{equation*}\n0 = \\left.\\delta^2 S\\right|_{\\text{e.o.m}} = \\sum_{i}{\\int{\\delta \\pi \\delta \\phi \\,\\,\\ud^{d-1}x}}\n\\end{equation*}\nIn the case we have considered with $\\mM = \\mathcal{N} \\times I$, this simply gives;\n\\begin{equation}\n\\int_{\\mathcal{N}_0}{\\delta \\pi \\delta \\phi \\,\\,\\ud^{d-1}x} = \\int_{\\mathcal{N}_T}{\\delta \\pi \\delta \\phi \\,\\,\\ud^{d-1}x}\n\\end{equation}\nso it is a constant of the motion provided the equations of motion hold. In classical mechanics this is the statement that Liouville's theorem holds; i.e. Hamilton's equations preserve the symplectic form $\\ud^3 p \\ud^3 x$. Thus;\n\\begin{equation}\n\\Omega = \\int_{\\mathcal{N}}{\\delta \\pi \\delta \\phi \\,\\, \\ud^{d-1} x}\n\\end{equation}\nis the symplectic form\\index{symplectic form} that we wish to quantise in QFT. As a further note, observe that $\\Omega$ only lives \\emph{on} the boundary, not in the whole of $\\mM$. This informs the fact that the expression for a scalar field is only a $3$-dimensional Fourier transform, as well as the fact that $\\phi(x)$ solved the equation of motion of the classical theory $(\\Box + m^2)\\phi = 0$. Indeed, in the second order case, specifying a solution to the classical equation of motion is equivalent to specifying initial values for $\\phi, \\pi$ on the boundary. Finally, we only considered \\emph{equal time} commutation relations. This is because the symplectic form $\\Omega$ which generates the Poisson bracket\\index{Poisson bracket} in classical mechanics is only defined on the boundary. In analogy to quantum mechanics, just as we can have a wavefunction for a general state $\\ket{\\psi}$;\n\\begin{equation*}\n\\ket{\\psi} = \\int{\\upd{^3 x} \\psi(\\vec x) \\ket{\\vec x}}\n\\end{equation*}\nin QFT, we can write;\\footnotemark\n\\begin{equation}\n\\ket{\\Psi} = \\int_{\\mC[B]}{\\mD \\phi \\,\\, \\Psi[\\phi] \\ket{\\phi}}\n\\end{equation}\nwhere the integral is taken over all possible boundary field configurations $\\ket{\\phi}$. The difficulties of defining what we mean by the infinite-dimensional path integral are reflected in the canonical quantisation approach to QFT in the diffculties of defining what is meant by the `Hilbert space' $L_2(\\mC[B], \\ud \\mu)$ for functions on the infinite-dimensional space of boundary field configurations $\\mC[B]$.\n\\footnotetext{\nWe have also seen this before, if $\\Psi[\\phi]$ is a polynomial;\n\\begin{equation*}\n\\Psi[\\phi] = \\int{\\ud^3 x_1 \\cdots \\upd{^3 x_n} \\psi(x_1, \\ldots, x_n) \\phi(x_1)\\cdots \\phi(x_n)}\n\\end{equation*}\nthen we interpret $\\psi(x_1,\\ldots, x_n)$ as $n$-particle wavefunctions.\n}\n\\newpage\n\\section{QFT in Zero Dimensions}\nIn zero dimensions, writing down the choices discussed in the first section is easy. We must have $\\mM = \\set{\\text{pt.}}$ if it's to be connected, and we will choose our field to map from $\\phi : \\mM \\rightarrow \\RR$. Hence we just have $\\phi \\in \\RR$ and $\\mC = \\RR$. So the path integral is just a normal integral;\n\\begin{equation}\n\\mZ(m^2, \\lambda, \\ldots) = \\int_{\\RR}{\\upd{\\phi} e^{-S(\\phi)/\\hbar}}\n\\end{equation}\nWe should also choose $S(\\phi)$ such that the integral converges\\footnote{We will often just choose $S(\\phi)$ to be a polynomial with even highest power (so the integral converges at large negative $\\phi$.}, and there can be no derivative terms, since there is no direction to differentiate along. Then we have the correlation functions;\n\\begin{equation}\n\\left< f(\\phi) \\right> = \\frac{1}{\\mZ}\\int_{\\RR}{\\upd{\\phi} e^{-S(\\phi)/\\hbar}f(\\phi)}\n\\end{equation}\n\\subsection{Free Field Theory}\nSuppose $\\phi \\in \\RR^n$ then we have fields $\\phi^a$ with $a = 1, \\ldots, n$. We take our action to be;\n\\begin{equation}\nS(\\phi) = \\tfrac{1}{2}M_{ab}\\phi^a \\phi^b\n\\end{equation}\nwhere $M$ is a real, positive definite, symmetric matrix.\\footnote{Positive definiteness ensures the integral converges, and the symmetric property follows since $\\phi$ is bosonic. This means $M$ can be diagonalised by an orthogonal transformation. This ensures $\\ud^n \\phi = \\ud^n \\chi$} Then, letting $m^a$ be the eigenvalues, and $\\chi^a$ the eigenvectors under the orthogonal transformation;\n\\begin{align}\n\\mZ(M) &= \\int_{\\RR^n}{\\upd{^n \\phi}e^{-S(\\phi)/\\hbar}} = \\int_{\\RR^n}{\\upd{^n \\chi}\\prod_{a = 1}^{n}e^{-m_a (\\chi^a)^2/2\\hbar}} \\nonumber \\\\\n\\Rightarrow \\mZ(M) &= \\prod_{a = 1}^n{\\sqrt{\\frac{2\\pi \\hbar}{m_a}}} = \\sqrt{\\frac{(2\\pi \\hbar)^n}{\\det M}}\n\\end{align}\nNow we include a source term in the action $J_a \\phi^a$ so that;\n\\begin{equation*}\n\\mZ(M, J) = \\int{\\upd{^n\\phi}e^{-\\left(S(\\phi) + J\\cdot \\phi\\right)/\\hbar}}\n\\end{equation*}\nWe redefine $\\tilde{\\phi}^a = \\phi^a + (M^{-1})^{ab} J_b$, then $\\ud^n \\phi \\mapsto \\ud^n \\tilde{\\phi}$ so that;\n\\begin{align*}\n\\mZ(J) &= \\int{\\upd{^n\\tilde{\\phi}}e^{-\\tfrac{1}{2}M(\\tilde{\\phi}, \\tilde{\\phi})/\\hbar}e^{\\tfrac{1}{2\\hbar}M^{-1}(J, J)}} \\\\\n&= \\exp\\left(\\frac{1}{2\\hbar}M^{-1}(J, J)\\right) \\frac{(2\\pi\\hbar)^{n/2}}{\\sqrt{\\det M}} \\\\\n&= \\exp\\left(\\frac{1}{2\\hbar}M^{-1}(J, J)\\right)\\mZ(0)\n\\end{align*}\nBy the linearity of the integral, this allows us to compute the correlators of polynomials since it reduces to calculating the correlators of factors that look like $\\prod_{i = 1}^{p}{l_a^{(i)}\\phi^a}$. If $p$ is odd, we can take $\\phi^a \\mapsto -\\phi^a$ and the integral vanishes. So we let $p = 2k$ to see that; (n.b. $l(\\phi) = l_a \\phi^a$)\n\\begin{align*}\n\\left< l_1(\\phi)\\cdots l_{2k}(\\phi) \\right> &= \\left.\\frac{1}{\\mZ(0)}\\int_{\\RR^n}{\\upd{^n \\phi}e^{-\\tfrac{M}{2\\hbar}(\\phi, \\phi) - J(\\phi)/\\hbar}\\prod_{i = 1}^{2k}{l^i(\\phi)}}\\right|_{J = 0} \\\\\n&= \\left.(-\\hbar)^{2k}\\frac{1}{\\mZ(0)}\\int_{\\RR^n}{\\upd{^n \\phi}\\prod_{i = 1}^{2k}{l^i\\left(\\frac{\\del}{\\del J}\\right) e^{-\\tfrac{1}{2\\hbar}M(\\phi, \\phi)-J(\\phi)/\\hbar}}}\\right|_{J = 0} \\\\\n&= \\left.(-\\hbar)^{2k}\\frac{1}{\\mZ(0)}\\prod_{i = 1}^{2k}{l^i\\left(\\frac{\\del}{\\del J}\\right)} \\left(\\mZ(J)\\right)\\right|_{J = 0} \\\\\n&= \\left.(-\\hbar)^{2k}\\left(\\prod_{i = 1}^{2k}{l^i\\left(\\frac{\\del}{\\del J}\\right)}\\right)\\exp\\left(\\tfrac{1}{2\\hbar}M^{-1}(J, J)\\right)\\right|_{J = 0}\n\\end{align*}\nWe can apply this to the two-point function to find;\\footnotemark\n\\footnotetext{\nNote that $M^{-1}$ is the inverse of the quadratic term in the action. In analogy to this, we have seen the Green's function\\index{Green's function} of the Klein-Gordon equation\\index{equation!Klein-Gordon} etc. So $M^{-1}$ plays the role of the propagator.\n}\n\\begin{equation}\n\\left< \\phi^a \\phi^b \\right> = \\hbar(M^{-1})^{ab}. \n\\end{equation}\n\\begin{definitionbox}\nFor $2k > 2$ it must be the case that half the derivatives act on the exponent and the remaining half act on the the prefactors $\\tfrac{1}{\\hbar}M^{-1}(J, \\text{-})$. If we let $\\sigma$ denote a pairing of the set $\\set{1, \\ldots 2k}$ and let $\\Pi_{2k}$ be the set of all these pairings, then we recover \\emph{Wick's Theorem}\\index{theorem!Wick's};\n\\begin{equation}\n\\left< l^1 (\\phi)\\cdots l^{2k}(\\phi) \\right> = \\hbar^{k}\\sum_{\\sigma \\in \\Pi_{2k}}{\\prod_{i = 1}^{2k}{M^{-1}(l^i, l^{\\sigma(i)})}}\n\\end{equation}\nIn the case where all the $l^i$ are the same, using $\\abs{\\Pi_{2k}} = \\tfrac{(2k)!}{2^k k!}$ we recover;\n\\begin{equation}\n\\left< \\left(l(\\phi)\\right)^{2k} \\right> = \\frac{(2k)!}{2^k k!} \\left(\\hbar M^{-1}(l,l)\\right)^k\n\\end{equation}\nWe could apply this to \n\\begin{multline}\n\\left< \\phi^a \\phi^b \\phi^c \\phi^d \\right> = \\hbar^2 \\left((M^{-1})^{ab}(M^{-1})^{cd}\\right. \\\\ \\left.+ (M^{-1})^{ac}(M^{-1})^{bd} + (M^{-1})^{ad}(M^{-1})^{bc}\\right)\n\\end{multline}\nwhich is represented diagrammatically\\index{Feynman diagram} in \\autoref{fig:firstfd}\n\\end{definitionbox}\n\\begin{mygraphic}{aqft/firstfd}{0.8}{The three diagrams contributing to $\\left< \\phi^a \\phi^b \\phi^c \\phi^d \\right>$.}{firstfd}\\end{mygraphic}\n\\subsection{Perturbation Theory}\nInteresting theories occur when we include non-zero couplings $\\set{\\lambda_i}$ into the action (and hence the partition function, $\\mZ(\\lambda_i)$). In general these are transcendental functions; we don't know how to do the integral. We would instead like to obtain a series approximation in $\\hbar$. Note that $\\mZ(\\hbar)$ clearly diverges for $\\hbar < 0$, so any series cannot possibly converge. If this were the case, it would converge in some disc around $\\hbar = 0$. Hence at best, we can obtain an asymptotic series approximation to $\\mZ(\\hbar)$.\\footnotemark\n\\footnotetext{\nIf we define $I_N(\\hbar) = \\sum_{n = 0}^N{a_n \\hbar^n}$, then $I_N(\\hbar)$ is asymptotic to $I(\\hbar)$ as $\\hbar \\rightarrow 0$, $I(\\hbar) \\sim I_N(\\hbar)$, if;\n\\begin{equation*}\n\\lim_{\\hbar \\rightarrow 0}\\frac{1}{\\hbar^N}\\abs{I(\\hbar) - I_N(\\hbar)} = 0 \\quad \\forall N\n\\end{equation*}\n}\n\\begin{thm}\nWe claim that for any action $S(\\phi)$ and any function $f(\\phi)$, let $S(\\phi)$ have a global minimum at a unique $\\phi \\in \\RR^n$, then;\n\\begin{multline}\n\\int_{\\RR^n}{\\upd{^n \\phi}e^{-S(\\phi)/\\hbar}} \\overset{\\hbar \\rightarrow 0}{\\sim} \\frac{(2\\pi \\hbar)^{n/2}}{\\sqrt{\\left.\\det(\\del_a \\del_b S)\\right|_{\\phi_0}}}e^{-S(\\phi_0)/\\hbar}f(\\phi_0) \\\\ \\times \\set{1 + A_1 \\hbar + A_2 \\hbar^2 + \\cdots}\n\\end{multline}\nThe overall factor is know as the \\emph{semi-classical part} or the \\emph{1-loop correction}. The series in $\\hbar$ represents higher order quantum effects.\n\\end{thm}\nWe will now apply this to an example. We take $S(\\phi) = \\tfrac{m^2}{2}\\phi^2 + \\tfrac{\\lambda}{4!}\\phi^4, \\lambda > 0$. This has a minimum at $\\phi_0 = 0, S(\\phi_0) = 0, \\del^2 S(\\phi_0) = m^2$. Then we expect an asymptotic series;\n\\begin{equation}\n\\mZ(m^2, \\lambda) = \\int{\\upd{\\phi} e^{-S(\\phi)/\\hbar}} \\sim \\sqrt{\\frac{2\\pi\\hbar}{m^2}}\\left(1 + A_1 \\hbar + \\cdots\\right)\n\\end{equation}\nExpanding the exponential $e^{-\\lambda \\phi^4 / 4!\\hbar}$, we find;\n\\begin{align*}\n\\mZ(m^2, \\lambda) &= \\int_{\\RR}{\\upd{\\phi}e^{-m^2 \\phi^2/2\\hbar}\\sum_{n = 0}^{\\infty}{\\frac{1}{n!}\\left(-\\frac{\\lambda}{4!\\hbar}\\right)^n \\phi^{4n}}} \\\\\n&= \\frac{\\sqrt{2\\hbar}}{m}\\int_{0}^{\\infty}{\\upd{x}e^{-x}\\sum_{n=0}^{\\infty}{\\frac{1}{n!}\\left(-\\frac{\\hbar \\lambda}{3! m^4}\\right)^{n}x^{(2n + \\tfrac{1}{2}) - 1}}}\n\\end{align*}\nwhere we have substituted $x = \\tfrac{m^2 \\phi^2}{2\\hbar}$. We can only pull the sum outside if the integral is absolutely convergent. This can't be the case as discussed above, so we truncate the sum to $N$ terms and instead consider the asymptotic series;\n\\begin{align}\n\\mZ(m^2, \\lambda) &\\sim \\frac{\\sqrt{2\\hbar}}{m}\\sum_{n=0}^{N}{\\frac{1}{n!}\\left(-\\frac{\\hbar\\lambda}{3!m^4}\\right)^n \\int_{0}^{\\infty}{\\upd{x}e^{-x}x^{(2n + \\tfrac{1}{2}) - 1}}} \\nonumber \\\\\n&= \\frac{\\sqrt{2\\hbar}}{m}\\sum_{n=0}^{N}{\\frac{1}{n!}\\left(-\\frac{\\hbar\\lambda}{3!m^4}\\right)^n \\Gamma(2n + \\tfrac{1}{2})} \\nonumber \\\\\n&= \\frac{\\sqrt{2\\pi \\hbar}}{m}\\sum_{n=0}^{N}{\\frac{(-1)^n}{n!}\\frac{1}{(4!)^n}}\\frac{(4n)!}{4^n (2n)!}\\left(\\frac{\\hbar\\lambda}{m^4}\\right)^n \\nonumber \\\\\n&= \\mZ_0\\left(1 - \\frac{\\hbar \\lambda}{8m^4} + \\frac{35 \\hbar^2\\lambda^2}{384 m^8} + \\cdots \\right)\n\\end{align}\nwhere we have used that $\\Gamma(2n + \\tfrac{1}{2}) = \\sqrt{\\pi}\\tfrac{(4n)!}{4^{2n}(2n)!}$. At this point, note that;\n\\begin{equation}\n\\frac{(4n)!}{4^n (2n)!}\n\\end{equation}\nis the number of ways of joining up $4n$ elements into pairs.\\footnote{Since $\\hbar \\lambda/m^4$ appears in every term, we can equivalently consider it to be a series in $\\lambda$.}\\footnotemark\n\\footnotetext{\nAlso note that by Stirling's formula\\index{formula!Stirling's}, $n! \\sim e^{n\\log n}$, for large $n$ we have;\n\\begin{equation*}\n\\frac{1}{(4!)^n n!}\\frac{(4n)!}{(2n)!4^n} \\sim e^{n\\log n}\n\\end{equation*}\nso the coefficients grow faster than exponentially implying that the radius of convergence is zero. \n}\n\\subsubsection{Feynman Diagrams}\nContinuing with the example above, we have the Feynman rules as illustrated in \\autoref{fig:fdrules}. Feynman tells us to draw all the graphs with no external edges, know as \\emph{vacuum graphs}\\index{vacuum graphs}, and sum them to compute this partition function with the associated Feynman rules\\index{Feynman!rules}. \n\\begin{mygraphic}{aqft/fdrules}{0.6}{The Feynman rules for our 0-d theory. The propagator contributes a factor $-\\hbar/m^2$ whilst a vertex contributes $-\\lambda/\\hbar$}{fdrules}\\end{mygraphic}\nLet $D_n = \\set{\\text{all labelled graphs on }n\\text{ vertices, both connected and disconnected}}$. Here labelled means each vertex and line has been identified. Let $\\abs{D_n}$ be the size of this set.\n\\begin{definitionbox}[Vacuum Graphs in $\\phi^4$ theory]\nIn a vacuum graph, every end of every edge must be attached to a vertex. Our theory has $4$-valent vertices so we must have $2n$ edges for $n$ vertices. To visualise this, consider the $4n$-vertices side by side and join up all the fields pairwise. Then there must be $2n$ pairs, each of which corresponds to one edge. So every graph in $D_n$ has a factor $(-\\lambda/\\hbar)^n (\\hbar/m^2)^{2n} = (-\\lambda\\hbar/m^4)^n$.\n\\end{definitionbox}\nNow we have introduced over-counting due to our labelling as shown in \\autoref{fig:d1}. There, all three graphs are topologically equivalent as non-labelled graphs.\n\\begin{mygraphic}{aqft/d1}{0.6}{The three labelled graphs in $D_1$. Whilst they represent different possibilities as labelled graphs, they are topologically equivalent and hence contribute equally to the expansion.}{d1}\\end{mygraphic}\nWe explain this by noting that $D_n$ is acted on by a permutation group;\n\\begin{equation*}\nG_n = \\underbrace{\\left(S_4\\right)^n}_{\\text{\\tiny{permutes the four fields at each vertex}}} \\times \\underbrace{S_n}_{\\text{\\tiny{permutes the vertices}}}\n\\end{equation*}\nThis allows to write the series as;\n\\begin{equation}\n\\frac{\\mZ}{\\mZ_0} \\sim \\sum_{n = 0}^{\\infty}{\\left(-\\frac{\\lambda \\hbar}{m^4}\\right)^n \\frac{\\abs{D_n}}{\\abs{G_n}}}\n\\end{equation}\nPutting in the numerical factors gives the same expansion as before. There is another way to view this however; an orbit, $\\Gamma$, of $G_n$ in $D_n$ is a topological graph\\index{topological graph}.\\footnote{A topological graph is an equivalence class of labelled graphs under the equivalence operation of action by an element of the symmetry group permuting fields and vertices.} Then, let $\\mO_n$ be the set of orbits i.e. $\\mO_n$ is the set of topologically distinct vacuum graphs with $n$ vertices. Then, the Orbit-Stablizer Theorem\\index{theorem!Orbit-Stabilizer} gives;\\footnotemark\n\\footnotetext{\nTo be more precise, the orbit-stabilizer theorem gives us the relation;\n\\begin{equation*}\n\\abs{\\Gamma}\\abs{\\text{Aut}\\Gamma} = \\abs{G_n}\n\\end{equation*}\nwhere $\\abs{\\Gamma}$ is the size of the orbit. Now we know that the group $D_n$ is a disjoint union of the orbits;\n\\begin{equation*}\nD_n = \\bigcup_{\\Gamma \\in \\mO_n} \\Gamma \\Rightarrow \\abs{D_n} = \\sum_{\\Gamma \\in \\mO_n}{\\abs{\\Gamma}}\n\\end{equation*}\nSubstituting in the relation noted above gives the result as in \\eqref{eq:aut}.\n}\n\\begin{equation}\n\\label{eq:aut}\n\\frac{\\abs{D_n}}{\\abs{G_n}} = \\sum_{\\Gamma \\in \\mO_n}{\\frac{1}{\\abs{\\text{Aut}\\Gamma}}}\n\\end{equation}\nwhere $\\text{Aut}\\Gamma$\\index{automorphism} are the set of permutations that preserve the labelled graphs, i.e. the stabilizer under the group action. The factor $\\abs{\\text{Aut}\\Gamma}$ is called the \\emph{symmetry factor}\\index{symmetry factor} of the graph. So we find that;\n\\begin{equation}\n\\frac{\\mZ}{\\mZ_0} \\sim \\sum_{n = 0}^{\\infty}\\left(-\\frac{\\hbar \\lambda}{m^4}\\right)^n \\sum_{\\Gamma \\in \\mO_n}{\\frac{1}{\\abs{\\text{Aut}\\Gamma}}}\n\\end{equation}\nAs a concrete example, we use this form of the expansion to calculate the first two terms, the vacuum graphs are shown in \\autoref{fig:auteg1}. We can explain the symmetry factors by considering the graphs from left to right (excluding the trivial graph\\index{graph!trivial});\n\\begin{enumerate}\n\\item We could swap the top two fields ($2$), the bottom two fields ($2$), or finally the top and bottom pairs ($2$). Thus $\\abs{\\text{Aut}\\Gamma} = 2\\times 2 \\times 2 = 8$.\n\\item We could swap the vertices ($2$), and considering each field out of the left vertex; the first can be joined to $4$ others, the second to $3$ etc. $\\Rightarrow 4!$. So $\\abs{\\text{Aut}\\Gamma} = 2 \\times 4! = 48$.\n\\item We can swap any pair of fields ($2\\times 2\\times 2$), as well as the vertices ($2$). So $\\abs{\\text{Aut}\\Gamma} = 2^4 = 16$.\n\\item Finally, we can perform the symmetry operations as in the first graph ($8^2$), or we could swap the two loops ($2$). So $\\abs{\\text{Aut}\\Gamma} = 8^2 \\times 2 = 128$.\n\\end{enumerate}\n\\begin{mygraphic}{aqft/auteg1}{1.0}{The expansion in terms of vacuum graphs and the symmetry factors. The ``trivial'' graph (the empty graph) is assigned a value of 1, not zero.}{auteg1}\\end{mygraphic}\nMore generally, suppose we have several types of field, $\\phi^a$, which interact via propagators $\\hbar/P_a$ and vertices $-\\lambda_\\alpha / \\hbar$. Then we will find the perturbative expansion is given by;\n\\begin{equation}\n\\frac{\\mZ}{\\mZ_0} \\sim \\sum_{\\Gamma}{\\frac{\\hbar^{b(\\Gamma)}}{\\abs{\\text{Aut}\\Gamma}}F(\\Gamma)}, \\quad F(\\Gamma) = \\prod_{a, \\alpha}{\\frac{(-\\lambda_\\alpha)^{\\abs{v_{\\alpha}(\\Gamma)}}}{P_a^{\\abs{e_a(\\Gamma)}}}}\n\\end{equation}\nwhere $b(\\Gamma) = \\abs{e(\\Gamma)} - \\abs{v(\\Gamma)}$.\n\\subsection{Effective Actions}\nIn computing $\\mZ / \\mZ_0$ we had to include all Feynman graphs, disconnected as well as connected. We now aim to show that; $\\mW = - \\hbar \\log \\mZ$ only involves connected graphs. $\\mW$ is known as the \\emph{Wilsonian effective action}\\index{effective action}\\index{effective action!Wilsonian}. \n\n\\paraskip\nNow suppose that $\\set{\\Gamma_j}$ is the set of all connected Feynman graphs. We define the product $\\Gamma_1 \\Gamma_2$ as the disconnected graph consisting of one copy of $\\Gamma_1$ and one of $\\Gamma_2$. Then, any disconnected (or indeed connected) is defined by a set $\\set{n_j}$ where $n_j \\in \\mathbb{N}$. The symmetry factor of an arbitrary graph is;\n\\begin{equation*}\n\\abs{\\text{Aut}(\\Gamma_1)^{n_1}\\cdots(\\Gamma_k)^{n_k}} = \\prod_{j = 1}^{k}{\\abs{\\text{Aut}\\Gamma_j}^{n_j}(n_j)!}\n\\end{equation*}\nwhere the factor of $(n_j)!$ arises from the ability to switch round the $\\Gamma_j$. It also follows from the definition that;\n\\begin{equation*}\nF(\\Gamma_1^{n_1}\\cdots\\Gamma_k^{n_k}) = \\prod_{j}{F(\\Gamma_j)^{n_j}}, b(\\Gamma_1^{n_1}\\cdots\\Gamma_k^{n_k}) = \\sum_{j}{n_j b(\\Gamma_j)}\n\\end{equation*}\nPutting this together we let $\\abs{\\Gamma}$ denote the size of the set of connected graphs (the sum is truncated so this is always finite), then we find the following;\n\\begin{align*}\n\\frac{\\mZ}{\\mZ_0} &\\sim \\sum_{\\text{all graphs}}{\\frac{\\hbar^{b(\\Gamma)}}{\\abs{\\text{Aut}\\Gamma}}F(\\Gamma)} \\\\\n&= \\sum_{\\set{n_j}}{\\frac{\\hbar^{b\\left(\\prod_{j}{\\Gamma_j^{n_j}}\\right)}}{\\abs{\\text{Aut}\\left(\\prod_{j}{\\Gamma_j^{n_j}}\\right)}}F\\left(\\prod_{j}{\\Gamma_j^{n_j}}\\right)} \\\\\n&= \\sum_{\\set{n_j}}{\\prod_{j}{\\frac{1}{(n_j)!}\\frac{\\hbar^{n_j b(\\Gamma_j)}}{\\abs{\\text{Aut}\\Gamma_j}^{n_j}}F(\\Gamma_j)^{n_j}}} \\\\\n&= \\sum_{n_1 = 0}^{\\infty}{\\cdots\\sum_{n_{\\abs{\\Gamma}}}{\\prod_{j = 1}^{\\abs{\\Gamma}}{\\frac{1}{(n_j)!}\\left(\\frac{\\hbar^{b(\\Gamma_j)}F(\\Gamma_j)}{\\abs{\\text{Aut}\\Gamma_j}}\\right)^{n_j}}}} \\\\\n&= \\sum_{n_1 = 0}^{\\infty}{\\frac{1}{(n_1)!}\\left(\\frac{\\hbar^{b(\\Gamma_1)}F(\\Gamma_1)}{\\text{Aut}\\Gamma_1}\\right)^{n_1}}\\cdots\\sum_{n_{\\abs{\\Gamma}}}^{\\infty}{\\frac{1}{(n_{\\abs{\\Gamma}})!}\\left(\\frac{\\hbar^{b(\\Gamma_{\\abs{\\Gamma}})}F(\\Gamma_{\\abs{\\Gamma}})}{\\text{Aut}\\Gamma_{\\abs{\\Gamma}}}\\right)^{n_{\\abs{\\Gamma}}}} \\\\\n&= \\prod_{j = 1}^{\\abs{\\Gamma}}{\\exp\\left(\\frac{\\hbar^{b(\\Gamma_j)}F(\\Gamma_j)}{\\abs{\\text{Aut}\\Gamma_j}}\\right)} = \\exp\\left(\\sum_{\\Gamma\\,\\,\\text{conn.}}{\\frac{\\hbar^{b(\\Gamma)}F(\\Gamma)}{\\abs{\\text{Aut}\\Gamma}}}\\right)\n\\end{align*}\nSo we see that;\n\\begin{equation}\n\\mW = \\mW_0 - \\hbar\\sum_{\\Gamma\\,\\,\\text{conn.}}{\\frac{\\hbar^{b(\\Gamma)}F(\\Gamma)}{\\text{Aut}\\Gamma}}\n\\end{equation}\n\\begin{thm}[Euler's Theorem]\n\\emph{Euler's Theorem}\\index{theorem!Euler} states that for a connected graph;\n\\begin{equation}\nb(\\Gamma) = \\abs{e(\\Gamma)} - \\abs{v(\\Gamma)} = l(\\Gamma) - 1\n\\end{equation}\nwhere $l(\\Gamma)$ is the number of loops, so $\\hbar\\hbar^{b(\\Gamma)} = \\hbar^{l(\\Gamma)}$. Then we see;\n\\begin{equation*}\n\\mW = \\mW_0 - \\sum_{\\Gamma\\,\\,\\text{conn.}}{\\frac{\\hbar^{l(\\Gamma)}F(\\Gamma)}{\\abs{\\text{Aut}\\Gamma}}}\n\\end{equation*}\ni.e. the asymptotic expansion really is a loop expansion.\n\\end{thm}\nFor vacuum graphs\\index{vacuum graph} all edges end on vertices so;\n\\begin{equation*}\n2\\abs{e_a} = \\sum_{\\alpha}{n_{a, \\alpha}\\abs{v_{\\alpha}}}\n\\end{equation*} \ni.e. if there are $\\abs{v_\\alpha}$ vertices of type $\\alpha$ with each vertex $\\alpha$ absorbing $n_{a, \\alpha}$ fields of type $a$. If the vertices really are genuine interactions, then $\\sum_{a}{n_{a\\alpha}} > 2$ so;\n\\begin{align*}\nl(\\Gamma) &= 1 + \\sum_{a}{\\abs{e_{a}}} - \\sum_{\\alpha}{\\abs{v_{\\alpha}}} \\\\\n&= 1 + \\sum_{\\alpha}{\\left(\\sum_{a}{\\tfrac{1}{2}n_{a, \\alpha} - 1}\\right)\\abs{v_{\\alpha}}} > 1\n\\end{align*}\nso all graphs must have at least two loops. From the asymptotic form of the series for $\\mZ$ we find that;\n\\begin{equation}\n\\mW \\sim S(\\phi_0) + \\frac{\\hbar}{2}\\det\\left.\\del_a \\del_b S\\right|_{\\phi_0} - \\sum_{\\Gamma\\,\\,\\text{conn.}}{\\frac{\\hbar^{l(\\Gamma)}}{\\text{Aut}\\Gamma}F(\\Gamma)}\n\\end{equation}\nThe first term represents the tree level\\index{tree level diagram}, classical part of the free energy, whilst the second term comes from the $1$-loop correction due to the quadratic part of the action. The sum over graphs are then higher loop corrections.\n\\subsection{Integrating out Fields} \nSuppose we only have two fields, $\\phi, \\chi \\in \\RR$ with an action;\n\\begin{equation}\n\\label{eq:effectact}\nS(\\phi, \\chi) = \\tfrac{1}{2}m^2 \\phi^2 + \\tfrac{1}{2}M^2 \\chi^2 + \\tfrac{\\lambda}{4}\\phi^2\\chi^2\n\\end{equation}\n\\begin{mygraphic}{aqft/effactfr}{0.6}{The Feynman rules for the action in \\eqref{eq:effectact}}{effactfr}\\end{mygraphic}\nWe could use these rules to do the standard perturbation theory, for example those shown in Figures \\ref{fig:effectvac} and \\ref{fig:effectvac2};\n\\begin{mygraphic}{aqft/effectvac}{0.8}{The sum over vacuum graphs giving the contribution to the free energy}{effectvac}\\end{mygraphic}\n\\begin{mygraphic}{aqft/effectvac2}{0.8}{Calculation of the two point function; the blue dot represent the insertion of each power of $\\phi$}{effectvac2}\\end{mygraphic}\nWe want to take a different approach however. Suppose that $M \\gg m$, then there is no way to directly `produce' $\\chi$ particles. We imagine inferring its existence via its effect on $\\phi$. With this in mind, we consider the intermediate action where we have `integrated out'/averaged over the $\\chi$ field. We define the \\emph{effective action}\\index{effective action} via;\n\\begin{equation*}\ne^{-W(\\phi)/\\hbar} = \\int{\\upd{\\chi}e^{-S(\\phi, \\chi)/\\hbar}}\n\\end{equation*}\nIn this integral, $\\phi$ plays the role of a source for the $\\chi$ field. We find that;\n\\begin{align*}\ne^{-W(\\phi)/\\hbar} &= e^{-S(\\phi, 0)/\\hbar}\\sqrt{\\frac{2\\pi\\hbar}{M^2 + \\frac{\\lambda\\phi^2}{2}}}, \\quad S(\\phi, 0) = \\tfrac{1}{2}m^2 \\phi^2 \\\\\n\\Rightarrow W(\\phi) &= \\frac{1}{2}m^2 \\phi^2 + \\frac{\\hbar}{2}\\log\\left(1 + \\frac{\\lambda}{2M^2}\\phi^2\\right) + \\frac{\\hbar}{2}\\log\\left(\\frac{M^2}{2\\pi\\hbar}\\right)\n\\end{align*}\nwhich we see as the classical solution plus a one loop correction, along with a field independent component that we neglect. We can then expand the logarithm;\n\\begin{align*}\nW(\\phi) &= \\frac{1}{2}m^2\\phi^2 + \\frac{\\hbar \\lambda}{4M^2}\\phi^2 - \\frac{\\hbar\\lambda^2}{16M^4}\\phi^4 + \\frac{\\hbar\\lambda^3\\phi^6}{48M^6} + \\cdots \\\\\n&= \\frac{1}{2}m^2_{\\text{eff}}\\phi^2 + \\frac{\\lambda_4}{4!}\\phi^4 + \\frac{\\lambda_6}{6!}\\phi^6 + \\cdots\n\\end{align*}\nwhere $m^2_{\\text{eff}} = m^2 + \\tfrac{\\hbar\\lambda}{4M^2}$ etc. $W(\\phi)$ plays the role of the effective action including \\emph{all} the quantum effects of the $\\chi$ field. This introduces an infinite set of new vertices in the theory. Importantly, we can carry this calculation out in another fashion. For a constant $\\phi$ field, we have the following Feynman rules;\n\\begin{mygraphic}{aqft/chifeyn}{0.5}{The Feynman rules for the constant $\\phi$ action.}{chifeyn}\\end{mygraphic} \nThen $W(\\phi)$ is simply a sum over all connected diagrams;\n\\begin{mygraphic}{aqft/wconn}{0.8}{$W(\\phi)$ is a sum over connected diagrams with the amended Feynman rules. The symmetry factors are $2, 4, 3!, \\ldots$ etc.}{wconn}\\end{mygraphic}\nExpanding the prefactors, we see that this agrees exactly with the previous calculation. It also shows that the new vertices in the $\\phi$ theory comes from the ($1$)-loop diagrams of the $\\chi$ field. Now, using $W(\\phi)$ we can compute;\n\\begin{mygraphic}{aqft/wconnp}{0.8}{It is much simpler to calculate the correlation functions with this new effective action, and is always more efficient than going via the full theory}{wconnp}\\end{mygraphic}\n\\subsection{The $1$PI/Quantum Effective Action}\nWilson?s effective action is motivated by the idea of averaging over quantum fluctuations of high energy fields that are beyond the reach of our experimental observations, and provides us with a new action for the remaining, low energy degrees of freedom. The quantum effects of the remaining fields still need to be computed. We?d now like to construct a new type of effective action that takes account of the quantum fluctuations of the whole system.\n\n\\paraskip\nYou might think that this should just be $\\mW(J)$ itself: we couple our fields to sources, integrate out all the quantum fields to obtain $\\mW(J)$ and then differentiate with respect to $J$ to obtain correlation functions. This point of view is indeed useful if our quantum system is immersed in some background (the choice of sources) that we are able to vary. However, for an isolated quantum system (such as the whole Universe, or a scattering experiment performed in CERN) there is no obvious background. We thus proceed differently and define;\n\\begin{equation}\ne^{-W(J)/\\hbar} = \\int{\\upd{\\phi}e^{-\\left(S(\\phi) + J\\phi\\right)/\\hbar}}\n\\end{equation}\nwhere importantly we have coupled a source to just \\emph{one} power of the field. Now let $\\Phi = \\del W/ \\del J$ so;\n\\begin{align*}\n\\Phi &= -\\frac{\\hbar}{\\mZ(J)}\\frac{\\del}{\\del J}\\left[\\int{\\upd{\\phi}e^{-\\left(S(\\phi) + J\\phi\\right)/\\hbar}}\\right] \\\\\n&= -\\frac{\\hbar}{\\mZ(J)}\\int{\\upd{\\phi}\\phi e^{-\\left(S(\\phi) + J\\phi\\right)/\\hbar}} = \\left< \\phi \\right>_J\n\\end{align*}\ni.e. $\\Phi$ is the average value of the original field taking into account all the quantum effects in the presence of the source $J$. We now define the \\emph{quantum effect action}, $\\Gamma(\\Phi)$;\n\\begin{equation}\n\\Gamma(\\Phi) = W(J) - J\\Phi\n\\end{equation}\nNote then that $W(J)$ and $\\Gamma(\\Phi)$ are related by a Legendre transform\\index{Legendre transform};\n\\begin{align*}\n\\frac{\\del \\Gamma}{\\del \\Phi} &= \\frac{\\del W}{\\del J}\\frac{\\del J}{\\del \\Phi} - \\frac{\\del J}{\\del \\Phi} - J \\\\\n&= \\Phi\\frac{\\del J}{\\del \\Phi} - \\frac{\\del J}{\\del \\Phi}\\Phi - J = -J\n\\end{align*}\nImportantly in the absence of a source;\n\\begin{equation*}\n\\left.\\frac{\\del \\Gamma}{\\del \\Phi}\\right|_{J = 0} = 0\n\\end{equation*}\nso the extrema of $\\Gamma(\\Phi)$ correspond to possible configurations of the averaged quantum corrected field. What if we consider an additional effective action defined by;\n\\begin{equation*}\ne^{-W_{\\Gamma}(J)/g} = \\int{\\upd{\\Phi}e^{-\\left(\\Gamma(\\Phi) + \\Phi J\\right)/g}}\n\\end{equation*}\nthen as before $W_{\\Gamma}(J)$ can be represented as the sum of connected Feynman diagrams built from the vertices and propagators in $\\Gamma(\\Phi)$. An $l$-loop factor will come with a factor of $g^{l}$, so;\n\\begin{equation}\nW_{\\Gamma}(J) = \\sum_{l = 0}^{\\infty}{g^{l}W_{\\Gamma}^{(l)}(J)}\n\\end{equation}\nwhere $W_{\\Gamma}^{(l)}(J)$ is the sum of $l$-loop connected graphs. In particular $W_{\\Gamma}^{(0)}(J)$ is the sum of all tree graphs and corresponds to the value of $\\left(\\Gamma(\\Phi) + J\\Phi\\right)$ at an extrema. But at an extrema;\n\\begin{equation*}\n\\frac{\\del \\Gamma}{\\del \\Phi} = - J \\Rightarrow \\left.\\left(\\Gamma(\\Phi) + \\Phi J\\right)\\right|_{\\text{extr.}} = W_{\\Gamma}^{(0)}(J)\n\\end{equation*}\nSo to leading order we have that;\n\\begin{equation*}\n\\Gamma(\\Phi) = W_{\\Gamma}^{(0)}(J) - J\\Phi\n\\end{equation*}\nBut comparing with $\\Gamma(\\Phi) = W(J) - J\\Phi$ we see that;\n\\begin{equation}\nW(J) = W_{\\Gamma}^{(0)}(J)\n\\end{equation}\nSo we see that we can interpret $W(J)$ in two ways;\n\\begin{enumerate}\n\\item The sum of all connected graphs of the original classical action $S(\\phi) + J\\phi$\n\\item The sum of all connected \\emph{tree graphs} from $\\Gamma(\\Phi) + J\\Phi$\n\\end{enumerate}\nThe only way that this is possible is if $\\Gamma(\\Phi)$ has vertices that correspond to all possible $1$-particle irreducible graphs\\index{1-particle irreducible graphs}. A 1PI graph is a connected graph that cannot be disconnected by cutting a single internal edge. An illustration of how this might work is shown in \\autoref{fig:1pi}.\n\\begin{mygraphic}{aqft/1pi}{0.9}{Any connected graph can be viewed as a tree whose vertices are 1PI graphs.}{1pi}\\end{mygraphic}\n\\subsection{Fermions}\nIn $d = 0$ there is no notion of spin, so fermionic fields\\index{field!fermionic} are just elements $\\theta^a$ of a \\emph{Grassman Algebra}\\index{Grassman algebra}, satisfying $\\set{\\theta^a, \\theta^b} = \\theta^a \\theta^b + \\theta^b \\theta^a = 0$. In particular for any given field $(\\theta^a)^2 = 0$, so we can expand any function $f(\\theta)$ as a finite series in the number of fields;\n\\begin{equation}\nf(\\theta) = f_0 + \\rho_a\\theta^a + \\frac{1}{2!}g_{ab}\\theta^a\\theta^b + \\cdots + \\frac{1}{n!}h_{a_1 \\cdots a_n}\\theta^{a_1}\\cdots\\theta^{a_n}\n\\end{equation}\nwhere all the co-efficients are totally antisymmetric. We define differentiation by;\n\\begin{equation}\n\\frac{\\del}{\\del \\theta^a}\\theta^b + \\theta^b \\frac{\\del}{\\del \\theta^a} = \\delta\\indices{^{b}_{a}}\n\\end{equation}\nFurthermore, note that for a single variable $\\theta$, the most general function is $f + g\\theta$. So it is sufficient just to define the two integrals $\\int{\\upd{\\theta}}$ and $\\int{\\upd{\\theta}\\theta}$. We want our integral to be translationally invariant under $\\theta \\rightarrow \\theta + \\eta$, i.e.\n\\begin{equation}\n\\int{\\upd{\\theta}\\theta + \\eta} = \\int{\\upd{\\theta}\\theta} \\Rightarrow \\int{\\upd{\\theta}} = 0\n\\end{equation}\nWe then choose to normalise our integration measure by;\n\\begin{equation}\n\\int{\\upd{\\theta}\\theta} = 1\n\\end{equation}\nThese two rules define \\emph{Berezin integration}, and ensure that;\n\\begin{equation*}\n\\int{\\upd{\\theta}\\frac{\\del}{\\del\\theta}F(\\theta)} = 0\n\\end{equation*}\nsince $F$ can only depend on one power of $theta$. More generally, for $n$ Grassman variables;\n\\begin{equation*}\n\\int{\\ud \\theta^n \\cdots \\upd{\\theta^1} \\theta^1 \\cdots \\theta^n} = 1 \\Rightarrow \\int{\\ud \\theta^n \\cdots \\upd{\\theta^1}\\theta^{a_1}\\cdots\\theta^{a_n}} = \\epsilon^{a_1 \\cdots a_n}\n\\end{equation*}\nNow suppose that $\\theta^{a\\prime} = N\\indices{^{a}_{b}}\\theta^{b}$ for some $N \\in \\text{GL}(n, \\CC)$, then;\n\\begin{align*}\n\\int{\\upd{^{n}\\theta}\\theta^{\\prime a_1}\\cdots \\theta^{\\prime a_n}} &= \\int{\\upd{^n \\theta} N\\indices{^{a_1}_{b_1}}\\theta^{b_1}\\cdots N\\indices{^{a_n}_{b_n}}\\theta^{b_n}} \\\\\n&= N\\indices{^{a_1}_{b_1}}\\cdots N\\indices{^{a_n}_{b_n}}\\epsilon^{b_1 \\cdots b_n} \\\\\n&= \\det N \\epsilon^{a_1 \\cdots a_n} = \\det N \\int{\\upd{^n \\theta} \\theta^{a_1}\\cdots\\theta^{a_n}}\n\\end{align*} \nSo we find that;\n\\begin{enumerate}\n\\item Fermions: $\\theta^{a\\prime} = N\\indices{^{a}_{b}}\\theta^{b} \\Rightarrow \\ud^n \\theta = \\det N \\ud^n \\theta\\pr$\n\\item Bosons:  $\\phi^{a\\prime} = N\\indices{^{a}_{b}}\\phi^{b} \\Rightarrow \\ud^n \\phi = \\abs{\\det N}^{-1} \\ud^n \\phi\\pr$\n\\end{enumerate}\n\\subsubsection{Free fermionic field theory}\nSuppose we have two fermions $\\theta^1, \\theta^2$ and $S(\\theta) = \\tfrac{1}{2}A\\theta^1 \\theta^2$ for some constant $A \\in \\RR_{\\geq 0}$.\\footnote{Note that this is the most general action since $(\\theta^{i})^2 = 0$} The partition function is then;\n\\begin{align*}\n\\mZ_0 &= \\int{\\upd{^2 \\theta}\\exp\\left(-S(\\theta)/\\hbar\\right)} \\\\\n&= \\int{\\upd{^2 \\theta}\\left(1 - \\frac{A}{2\\hbar}\\theta^1 \\theta^2\\right)} \\\\\n&= -\\frac{A}{2\\hbar}\n\\end{align*}\nusing our rules of Berezin integration\\index{Berezin integration}. Note that the expansion of the exponential is exact in this fermionic case as noted above. More generally, if we have $n = 2m$ fermionic variables. Then the most general free action is;\n\\begin{equation}\nS(\\theta) = \\frac{1}{2}A_{ab}\\theta^{a}\\theta^{b}\n\\end{equation}\nwhere $A$ is an antisymmetric matrix, then;\n\\begin{align*}\n\\mZ_0 &= \\int{\\upd{^{2m}\\theta} \\exp\\left(-\\frac{A(\\theta, \\theta)}{\\hbar}\\right)} \\\\\n&= \\int{\\upd{^{2m}\\theta}\\sum_{k = 0}^{m}{\\frac{(-1)^{k}}{(2\\hbar)^k k!}\\left(A_{ab}\\theta^{a}\\theta^{b}\\right)^k}} \\\\\n&= \\frac{(-1)^{m}}{(2\\hbar)^{m}m!}\\int{\\upd{^{2m}\\theta}A_{a_1 a_2}\\theta^{a_1}\\theta^{a_2}\\cdots A_{a_{2m - 1}a_{2m}}\\theta^{a_{2m - 1}}\\theta^{a_{2m}}} \\\\\n\\end{align*}\nwhere we have noted that the only term that can contribute on integration is the highest order else there would be some $k$ such that the integral would be $\\int{\\ud \\theta^{k}} = 0$. So we see that;\n\\begin{equation}\n\\mZ_0 = \\frac{(-1)^{m}}{(2\\hbar)^{m}m!}\\epsilon^{a_1 \\cdots a_{2m}}A_{a_1 a_2}\\cdots A_{a_{2m - 1}a_{2m}} \\coloneqq \\frac{(-1)^m}{\\hbar^{m}}\\text{Pfaff}(A)\n\\end{equation}\nWe will show that $\\text{Pfaff}(A) = \\sqrt{\\det A}$, then the free partition function is;\n\\begin{equation}\n\\mZ_0 = \\pm \\sqrt{\\frac{\\det A}{\\hbar^{n}}}\n\\end{equation}\nIn the presence of a source, we write;\n\\begin{align*}\nS(\\theta, \\eta) &= \\tfrac{1}{2}A_{ab}\\theta^{a}\\theta^{b} + \\eta_a \\theta^{a} \\\\\n&= \\tfrac{1}{2}\\left(\\theta^a + \\eta_c \\left(A^{-1}\\right)^{ca}\\right)A_{ab}\\left(\\theta^b + \\eta_d \\left(A^{-1}\\right)^{db}\\right) + \\tfrac{1}{2}\\eta_a\\left(A^{-1}\\right)^{ab} \\eta_b\n\\end{align*}\nNow we are in a position to use the translation invariance of the measure to find;\n\\begin{equation}\n\\mZ_0(\\eta) = \\exp\\left(-\\frac{1}{2\\hbar}A^{-1}(\\eta, \\eta)\\right)\\mZ_0(0)\n\\end{equation}\nThis in turn implies that;\n\\begin{equation*}\n\\left< \\theta^a \\theta^b \\right> = \\frac{\\hbar^2}{\\mZ_0(0)}\\left.\\frac{\\del^2 \\mZ_0(\\eta)}{\\del \\eta_a \\del \\eta_b}\\right|_{\\eta = 0}\n\\end{equation*}\nA Grassman algebra\\index{algebra!Grassman} is an exterior algebra, and in the same way that the exterior derivative acts on a wedge product, we have the following differentiation rule;\n\\begin{equation*}\n\\frac{\\del}{\\del \\eta_b}\\left(\\eta_c \\eta_d\\right) = \\delta\\indices{^{b}_{c}}\\eta_d - \\eta_c\\delta\\indices{^{b}_{d}}\n\\end{equation*}\nThis ensures that;\n\\begin{align*}\n\\frac{\\del}{\\del \\eta_b}\\mZ_0(\\eta) &= -\\frac{1}{2\\hbar}(A^{-1})^{cd}\\left(\\delta\\indices{^{b}_{c}}\\eta_d - \\eta_c\\delta\\indices{^{b}_{d}}\\right)\\mZ_0(\\eta) \\\\\n&= -\\frac{1}{\\hbar}(A^{-1})^{bc}\\eta_c \\mZ_0(\\eta) \\\\\n\\Rightarrow \\left.\\frac{\\del^2}{\\del \\eta_a \\del \\eta_b}\\mZ_0(\\eta)\\right|_{\\eta = 0} &= -\\frac{1}{\\hbar}(A^{-1})^{ba} = \\frac{1}{\\hbar}(A^{-1})^{ab} \\\\\n\\Rightarrow \\left< \\theta^a \\theta^b \\right> &= \\hbar (A^{-1})^{ab}\n\\end{align*}\n\\subsubsection{Supersymmetric\\index{supersymmetry} Localisation}\nSuppose we have a theory of a boson, $\\phi$, and two fermions, $\\psi_1, \\psi_2$. Then let;\n\\begin{equation}\nS(\\phi, \\psi_1, \\psi_2) = \\tfrac{1}{2}(\\del h)^2 - \\psi_1 \\psi_2 \\del^2 h\n\\end{equation}\nwhere $h(\\phi)$ is some polynomial and $\\del h = \\del_\\phi h$ etc. Note also that we can only have the single term in $\\psi_1, \\psi_2$ as any other functional form would vanish either on integration or via an antisymmetric product. Thus this is a very general action, albeit with a relation between the coefficients. The action is invariant under the \\emph{supersymmetric}\\index{supersymmetric transformations} transformations;\n\\begin{equation}\n\\delta\\phi = \\epsilon_1 \\psi_1  + \\epsilon_2 \\psi_2, \\quad \\delta \\psi_1 = \\epsilon_2 \\del h, \\quad \\delta \\psi_2 = - \\epsilon_1 \\del h\n\\end{equation}\nwhere the $\\epsilon_i$ are fermionic parameters to ensure the action is bosonic overall. Under these transformations;\n\\begin{align*}\nS &\\mapsto \\tfrac{1}{2}\\left(\\del h + \\del^2 h \\delta \\phi\\right)^2 - (\\psi_1 + \\delta \\psi_1)(\\psi_2 + \\delta \\psi_2)(\\del^2 h + \\del^3 h \\delta\\phi) \\\\\n&= \\tfrac{1}{2}(\\del h)^2 + \\del^2 h (\\epsilon_1 \\psi_1 + \\epsilon_2 \\psi_2) \\del h \\\\\n&\\qquad\\qquad- (\\psi_1 + \\epsilon_2 \\del h)(\\psi_2 - \\epsilon_1 \\del h)\\left(\\del^2 h + \\del^3 h (\\epsilon_1 \\psi_1 + \\epsilon_2 \\psi_2) \\right)\n\\end{align*}\nNow note that the variation with prefactor $\\del^3 h$ when multiplied out, always carries either two of the $\\epsilon$ parameters, or two of the $\\psi_i$ fields. Hence it vanishes by the antisymmetric product. So;\n\\begin{align*}\nS &\\mapsto \\tfrac{1}{2}(\\del h)^2 + \\del h (\\epsilon_1 \\psi_1 + \\epsilon_2 \\psi_2)\\del^2 h - \\psi_1 \\psi_2 \\del^2 h \\\\\n&\\qquad \\qquad- \\epsilon_2 \\del h \\psi_2 \\del^2 h + \\psi_1 \\epsilon_1 \\del h \\del^2 h \\\\\n\\Rightarrow \\delta S &= \\del h (\\epsilon_1 \\psi_1 + \\epsilon_2 \\psi_2)\\del^2 h - \\del h \\epsilon_2 \\psi_2 \\del^2 h + \\del h \\psi_1 \\epsilon_1 \\del^2 h\n\\end{align*}\nBut the $\\epsilon_i$ are fermionic, so $\\epsilon_1 \\psi_1 = - \\psi_1 \\epsilon_1$ and we see that $\\delta S = 0$. The measure $\\ud \\phi \\ud \\psi_1 \\ud \\psi_2$ is also invariant.\\footnotemark Now consider some SUSY\\index{SUSY} operator $\\mO(\\phi, \\psi_1, \\psi_2)$. Then;\n\\begin{align*}\n\\left< \\delta \\mO \\right> &= \\frac{1}{\\mZ_0}\\int{\\ud \\phi \\ud \\psi_1 \\upd{\\psi_2} e^{-S/\\hbar} \\delta \\mO} \\\\\n&= \\frac{1}{\\mZ_0}\\int{\\ud \\phi \\ud \\psi_1 \\upd{\\psi_2}\\delta\\left(e^{-S/\\hbar} \\mO\\right)}\n\\end{align*}\nwhere we have used that $\\delta S = 0$. Now consider the following cases in the expansion inside the variation;\n\\begin{itemize}\n\\item Since the $\\psi_i$ are fermionic, they can only appear at most at linear order. Taking the $\\delta \\psi_i$ leads to no $\\psi_i$ dependence and hence it vanishes on Berezin integration. \n\\item If instead the SUSY variation acts on $\\phi$ then in general;\n\\begin{equation*}\n\\delta f(\\phi) = f\\pr(\\phi)\\delta \\phi = f\\pr(\\phi)\\cdot(\\epsilon_1 \\psi_1 + \\epsilon_2 \\psi_2)\n\\end{equation*}\nSo we see that the result is a total derivative in $\\phi$ multiplied by a fermionic part that may or may not survive the Berezin integration. Nonetheless, provided the function $f(\\phi)$ decays sufficiently, it will vanish as a boundary term on the integration of the total derivative. \n\\end{itemize}\nThus we find that $\\left< \\delta \\mO \\right> = 0$. In particular let $\\epsilon_1 = - \\epsilon_2 = \\epsilon$ so $\\delta \\phi = \\epsilon \\psi_1 - \\epsilon \\psi_2$ $\\delta \\psi_1 = - \\epsilon \\del h$ and define the operator;\n\\begin{equation}\n\\mO_g = \\del g \\psi_1\n\\end{equation}\nfor some $g(\\phi)$. Then we have the variation;\n\\begin{align*}\n\\delta \\mO_g &= \\del^2 g \\delta \\phi \\psi_1 + \\del g \\delta \\psi_1 \\\\\n&= -\\epsilon \\del^2 g \\psi_2 \\psi_1 - \\epsilon \\del g \\del h \\\\\n&= \\epsilon \\del^2 g \\psi_1 \\psi_2 - \\epsilon \\del g \\del h\n\\end{align*}\nThen $\\left< \\delta \\mO_g \\right> = 0 \\iff \\epsilon \\left< \\del g \\del h - \\del^2 g \\psi_1 \\psi_2 \\right> = 0$. Now we make the important observation that the averaged expression is the first order change in $S(\\phi)$ under a change $h \\mapsto h + g$. So we see that the partition function is invariant of the choice of polynomial, up to its total degree. In other words, we can make the rescaling $h \\mapsto (1 + \\lambda)h$ and iterate the procedure, to scale $h \\mapsto \\Lambda h$ for arbitrarily large $\\Lambda$. In the limit of large $\\Lambda$, the action suppresses the contribution from everything except the critical point of $h$ where $\\del h = 0$. Near such a critical point $\\phi = \\phi_\\star$ we have;\n\\begin{equation*}\nh(\\phi) = h(\\phi_\\star) + \\frac{c_\\star}{2}(\\phi - \\phi_\\star)^2 + \\cdots\n\\end{equation*}\nwhere $c_\\star = \\left.\\del^2 h\\right|_{\\phi_\\star}$. Thus we find that;\n\\begin{equation*}\nS(\\phi, \\psi_1, \\psi_2) \\sim \\frac{c_\\star}{2}(\\phi - \\phi_\\star)^2 + c_\\star \\psi_1 \\psi_2 + \\cdots\n\\end{equation*}\nThe higher order terms in this expansion are negligible since we can simply rescale $h$ to look closer and closer to the critical point and make them arbitrarily small. After expanding the exponential with the Grassman variables, the path integral has the form;\n\\begin{align*}\n\\frac{1}{\\sqrt{2\\pi}}\\int{\\ud \\phi \\upd{^2 \\psi}e^{-c_\\star(\\phi - \\phi_\\star)^2/2}(1 - c_\\star\\psi_1 \\psi_2)} &= \\frac{c_\\star}{\\sqrt{2\\pi}}\\int{\\upd{\\phi}e^{-c_\\star(\\phi - \\phi_\\star)^2/2}} \\\\\n&= \\frac{c_\\star}{\\sqrt{c_\\star^2}} = \\text{sgn}\\left(\\left.\\del^2 h\\right|_{\\phi_\\star}\\right)\n\\end{align*}\nSo we find that;\n\\begin{equation}\n\\mZ[h] = \\sum_{\\phi_\\star \\,\\,\\text{crit.}}{\\text{sgn}\\left(\\left.\\del^2 h\\right|_{\\phi_\\star}\\right)} = \\begin{cases}0&\\text{if degree of }h\\text{ is odd}\\\\ \\pm1&\\text{if degree of }h\\text{ is even}\\end{cases}\n\\end{equation}\n\\newpage\n\\section{QFT in One Dimension}\nWhen $d = 1$, there are only two compact manifolds\\index{compact manifold}, $\\mM$; the circle $\\mathcal{S}^1$ and the interval $I = [0, T]$. The most important type of field in this theory is a map $x : \\mM \\rightarrow \\mathcal{N}$ where $\\mathcal{N}$ is a Riemannian manifold with a metric $g$. We can then think of the fields $x^{a}(t)$ as local co-ordinates on $\\mathcal{N}$. Then the standard action is;\n\\begin{equation}\nS[x] = \\int_{\\mM}{\\upd{t}\\left(\\frac{1}{2}g_{ab}(x)\\dot{x}^{a}\\dot{x}^{b} + V(x)\\right)}\n\\end{equation}\nNote that here we've implicitly assumed that we have the trivial Euclidean metric $\\delta_{tt} = 1$ on $\\mM$. Under small variations $x \\mapsto x + \\delta x$ we find the usual geodesic form with a potential term;\n\\begin{align*}\n\\delta S[x] &= \\int{\\upd{t}\\delta x\\left(-\\frac{\\ud}{\\ud t}(g_{ac}\\dot{x}^{a}) + \\frac{1}{2}\\del_c g_{ab}\\dot{x}^{a}\\dot{x}^{b} + \\del_c V\\right)} \\\\\n&\\qquad\\qquad + \\left.g_{ab}(x)\\dot{x}^{a}\\delta x_b\\right|_{\\del \\mM}\n\\end{align*}\nAsking that the bulk term vanishes gives us the equations of motion;\n\\begin{equation}\n\\frac{\\ud^2 x^{a}}{\\ud t^2} + \\Gamma\\indices{^{a}_{bc}}\\dot{x}^{a}\\dot{x}^{b} = g^{ab}(x)\\frac{\\del V}{\\del x^{b}}\n\\end{equation}\nwhere $\\Gamma\\indices{^{a}_{bc}}$ is the usual Levi-Civita connection\\index{Levi-Civita connection}. The standard interpretation of this is that $\\vec{x}(t)$ describes a possible trajectory of a particle moving in $\\mathcal{N}$ under $V(x)$ with a metric $g$.\\footnote{Note that we will normally set $\\delta x^{b} = 0$ on $\\del\\mM$ if $\\mM$ is not $S^{1}$} $\\mathcal{N}$ is known as the \\emph{target space}\\index{target space} and $\\mM$ is the \\emph{worldline}\\index{worldline}.\n\\subsection{Worldline Quantum Mechanics}\nUsually in order to do QM we pick a Hilbert space\\index{Hilbert space}, $\\mathfrak{H}$ together with a (Euclidean) time evolution operator $U(t) = e^{-Ht}$ where for motion on $(\\mathcal{N}, g)$ we have;\n\\begin{equation*}\nH = \\frac{1}{2}\\bigtriangleup + V, \\quad \\bigtriangleup = \\frac{1}{\\sqrt{g}}\\frac{\\del}{\\del x^a}\\left(\\sqrt{g}g^{ab}\\frac{\\del}{\\del x^b}\\right)\n\\end{equation*}\nwhere $\\bigtriangleup$ is the Laplacian\\index{Laplacian} on $\\mathcal{N}$. Then the amplitude for a particle initially at $y_0 \\in \\mathcal{N}$ to be found at $y_1 \\in \\mathcal{N}$ a time $T$ later is;\n\\begin{equation}\nK_{T}(y_0, y_1) = \\bra{y_1}e^{-HT}\\ket{y_0}\n\\end{equation}\nwhere $K_T(y_0, y_1)$ is the \\emph{heat kernel}\\index{heat kernel}. This is a function $K : I \\times \\mathcal{N}\\times \\mathcal{N} \\rightarrow \\CC$ satisfying;\n\\begin{enumerate}\n\\item $\\del_t K_t(x, y) + HK_t(x, y) = 0$\n\\item $K_0(x, y) = \\delta(x - y)$\n\\end{enumerate}\nIf we rotate the time $t \\mapsto it$, we recover the Schr{\\\"o}dinger equation. If $(\\mathcal{N}, g) = (\\RR^{n}, \\delta)$ and $V = 0$ then we have;\n\\begin{equation}\nK_t(x, y) = \\frac{1}{(2\\pi t)^{n/2}}\\exp\\left(-\\frac{(x - y)^2}{2t}\\right)\n\\end{equation}\nMore generally on $(\\mathcal{N}, g)$ we have the asymptotic relation as $t \\rightarrow 0$;\n\\begin{equation}\nK_t(x, y) \\sim \\frac{1}{(2 \\pi t)^{n/2}}\\exp\\left(-\\frac{d(x, y)^2}{2t}\\right)\\times\\left(\\sqrt{g(x)} + b\\cdot\\sqrt{g}\\text{Ricc}_g(x) + \\cdots\\right)\n\\end{equation}\nwhere $d(x, y)$ is the geodesic distance joining $x$ and $y$. Now consider breaking our interval $[0, T]$ into $N$ parts of size $\\Delta T = T / N$. Then;\n\\begin{align*}\n\\bra{y_1}e^{-HT}\\ket{y_0} &= \\bra{y_1}e^{-H\\Delta T}\\cdots e^{-H\\Delta T}\\ket{y_0} \\\\\n&= \\int{\\ud^n x_1 \\cdots \\upd{^n x_{N - 1}}\\bra{y_1}e^{-H\\Delta T}\\ket{x_{N - 1}}} \\\\\n&\\qquad \\qquad \\times \\bra{x_{N - 1}}e^{-H\\Delta T}\\ket{x_{N - 2}}\\cdots \\bra{x_1}e^{-H\\Delta T}\\ket{y_0} \\\\\n&= \\int{\\prod_{i = 1}^{N - 1}{\\upd{^n x_i}}K_{\\Delta T}(y_1, x_{N - 1})\\cdots K_{\\Delta T}(x_1, y_0)}\n\\end{align*}\nWe can then use our asymptotic expansion;\n\\begin{multline*}\n\\bra{y_1}e^{--HT}\\ket{y_0} \\\\ = \\lim_{N \\rightarrow \\infty} \\left(\\frac{1}{2\\pi \\Delta t}\\right)^{n/2}\\int{\\prod_{i = 1}^{N - 1}{\\sqrt{g(x_i)}\\upd{^n x_i}}\\exp\\left(-\\frac{\\Delta t}{2}\\left(\\frac{d(x_{i + 1}, x_{i})^2}{\\Delta t}\\right)\\right)}\n\\end{multline*}\nProvided that it makes sense (this is not said lightly, it will turn out \\emph{not} to be the case) to say that we have the path integral measure;\n\\begin{equation*}\n\\mD x = \\lim_{N \\rightarrow \\infty}\\prod_{i = 1}^{N - 1}{\\frac{\\ud^n x_i \\sqrt{g(x_i)}}{(2\\pi \\Delta t)^{n/2}}} \n\\end{equation*}\nand the action;\n\\begin{equation*}\nS[x] = \\lim_{N \\rightarrow \\infty}\\sum_{i = 1}^{N - 1}{\\tfrac{1}{2}\\Delta t \\frac{d(x_{i + 1}, x_{i})^2}{(\\Delta t)^2}} = \\int_0^{T}{\\upd{t}\\tfrac{1}{2}g_{ab}(x)\\dot{x}^{a}\\dot{x}^{b}}\n\\end{equation*}\nThen we would be left with the path integral;\n\\begin{equation}\n\\bra{y_1}e^{-HT}\\ket{y_0} = \\int{\\mD x e^{-S[x]}}\n\\end{equation}\nwhere the integral is taken over all maps $I \\mapsto \\mathcal{N}$ such that $x(0) = y_0, x(T) = y_1$. \n\\subsection{The Partition Function}\nIn QM, the partition function is given by the trace over the Hilbert space, $\\mathfrak{H}$;\n\\begin{equation}\n\\mZ(T) = \\tr_{\\mathfrak{H}}e^{-HT} = \\int{\\upd{^n y} \\bra{y}e^{-HT}\\ket{y}}\n\\end{equation}\nSo with our path integral formalism;\n\\begin{equation*}\n\\mZ(T) = \\int{\\upd{^n y}\\int{\\mD x e^{-S[x]}}}\n\\end{equation*}\nwhere now the integral is taken over paths which start and end at the same place; $x(0) = x(T) = y$. This is just the set of maps from a circle of circumference $T$. This coincides with how we defined a partition function, as an integral over a manifold without boundary, so in this $1$D case we have;\n\\begin{align*}\n\\mZ(T, g, V) &= \\int_{\\text{maps }\\mathcal{S}^1 \\rightarrow \\mathcal{N}}{\\mD x e^{-S[x]}} \\\\\nS &= \\int_{\\mathcal{S}^1}{\\upd{t}\\tfrac{1}{2}g_{ab}\\dot{x}^{a}\\dot{x}^{b} + V(x)}\n\\end{align*}\n\\subsection{Operators and Correlation Functions}\nWe also have the concept of \\emph{local operators}\\index{local operator} which depend on the value of the field at only one point on the worldline. Let $\\mO : \\mathcal{N} \\rightarrow \\RR$ be a function on $\\mathcal{N}$ and let the corresponding operator be $\\hat{\\mO}$. Then for any fixed time $t \\in (0, T)$ we have;\\footnotemark\n\\footnotetext{\nTo understand the following expression, we should consider the first statement as having the states in the Schr{\\\"o}dinger picture, $\\bra{y_1, T}, \\ket{y_0, 0}$. In the form written it is not clear what picture the operator in, this is clarified in the first equality. Now $\\mO(t) = e^{Ht}\\mO(x) e^{-Ht}$ and $\\ket{y_i, t_i} = e^{Ht_i}\\ket{y_0}$. We understand this as starting in a state $\\ket{y_0}$ which evolves for a time $t$ at which point it is acted on by an operator at $x$. Then the resulting state evolves for a time $(T - t)$.\n}\n\\begin{equation*}\n\\bra{y_1}\\hat{\\mO}(t)\\ket{y_0} = \\bra{y_1}e^{-H(T - t)}\\hat{\\mO}(x)e^{-Ht}\\ket{y_0}\n\\end{equation*}\nNow $\\hat{\\mO}(x)$ has eigenstates $\\set{\\ket{x}}$ with eigenvalues $\\mO(x)$. Inserting a complete set of states we find;\n\\begin{align*}\n\\bra{y_1}\\hat{\\mO}(t)\\ket{y_0} &= \\int{\\upd{^n x}\\bra{y_1}e^{-H(T - t)}\\hat{\\mO}(x)\\ket{x}\\bra{x}e^{-Ht}\\ket{y_0}} \\\\\n&= \\int{\\upd{^n x}K_{T - t}(x, y_1)\\mO(x)K_t(y_0, x)} \\\\\n&= \\int{\\upd{^n x_t}\\int{\\mD x e^{-S[x]}\\mO(x_t)\\int{\\mD x e^{-S[x]}}}}\n\\end{align*}\nwhere the first path integral is taken over maps on $[t, T] \\mapsto \\mathcal{N}$ with $x(t) = x_t$ and $x(T) = y_1$, and the second is over maps on $[0, t] \\mapsto \\mathcal{N}$ such that $x(0) = y_0$ and $x(t) = x_t$. But this is the same as integrating over all maps $x(t)$ so we have;\n\\begin{equation}\n\\bra{y_1}\\hat{\\mO}(t)\\ket{y_0} = \\int{\\mD x e^{-S[x]}\\mO\\left(x(t)\\right)}\n\\end{equation}\nWe can consider inserting more operators, we would find that;\n\\begin{multline}\n\\bra{y_1}e^{-H(T - t_n)}\\mO_n(\\hat{x})e^{-H(t_{n} - t_{n - 1})}\\mO_{n - 1}(\\hat{x}) \\cdots e^{-H(t_2 - t_1)}\\mO_1(\\hat{x})e^{-Ht_1}\\ket{y_0} \\\\ = \\int{\\mD x\\,\\,e^{-S[x]}\\mO_1\\left(x(t_1)\\right)\\cdots\\mO_n\\left(x(t_n)\\right)}\n\\end{multline}\nAt this point note the importance of the kinetic terms in the discretised action, $(x_{i + 1} - x_{i})^2$. In the absence of these, correlation functions of operators at different times would factorise;\n\\begin{equation*}\n\\bra{y_1}\\mO_1(t_1)\\cdots\\mO_n(t_n)\\ket{y_0} = \\left< \\mO_{1}(x_1) \\right>\\cdots \\left< \\mO_{n}(x_n) \\right>\n\\end{equation*}\nIn other words, the kinetic terms link the points on our worldline\\index{worldline}. Else, events at different points in $\\mM = [0, T]$ are uncorrelated. \n\\subsubsection{Non-commutativity\\index{non-commutativity}}\nFor our action, we have the conjugate momentum\\footnote{If $(\\mathcal{N}, g) = (\\RR^n, \\delta)$} $p_a = \\delta \\mL/ \\delta \\dot{x}^a = \\delta_{ab}\\dot{x}^{b}$. By the time we get to the path integral, $x(t)$ and $\\dot{x}(t)$ are just integration variables, so commutativity is automatic at this level. But we know $[x^a, p_b] = \\delta\\indices{^{a}_{b}}$. So what has happened? We really need to understand the measure\\index{measure} better, in particular exactly what happened when we tried to take the limit. It is a fact that actually none of the limits of $\\mD x$ and $S[x]$ alone exist. Indeed, this is the reason we need renormalisation in QFT\\index{renormalisation}. We assume that our path integral is a good description, and hope it provides correct answers under some form of perturbation theory. In actuality though, this is doomed from the start, and thus it is no surprise that we require a method to compensate for the inevitable behaviour of the partition functions. \n\\begin{definitionbox}[The Lebesgue Measure\\index{measure!Lebesgue}]\nA \\emph{Lebesgue measure} on $\\RR^{d}$ is a measure $\\ud \\mu$ such that;\n\\begin{enumerate}\n\\item $\\text{vol}(U) = \\int_U{\\ud \\mu} > 0$ for all non-empty open sets $U \\subset \\RR^{d}$\n\\item $\\text{vol}(U\\pr) = \\text{vol}(U)$ if $U\\pr$ is a translation of $U$\n\\item For every $x \\in \\RR^{d}$ there exists at least one $U$ containing $x$ with $\\text{vol}(U) < \\infty$\n\\end{enumerate}\n\\end{definitionbox}\nNow we will try and find a Lebesgue measure on the infinite dimensional vector space of maps. Let $C_x(L)$ be a hypercube of side length $L$ centred at $x\\in\\RR^d$. So $C_x(L)$ contains $2^d$ smaller hypercubes of side length $L/2$. By the positivity and translational invariance of the measure;\n\\begin{equation*}\n\\text{vol}\\left(C_x(L)\\right) \\geq \\sum_{n = 1}^{2^d}{\\text{vol}\\left(C_x(L/2)\\right)} = 2^d \\text{vol}\\left(C_x(L/2)\\right)\n\\end{equation*}\nAs $D \\rightarrow \\infty$, the volume in any finite sized hypercube has to tend to zero if this is to not diverge. Hence there does not exist a Lebesgue measure on an infinite dimensional vector space. With this being said however, it turns out that the limit;\n\\begin{equation}\n\\ud \\mu_W = \\lim_{N \\rightarrow \\infty}\\left[\\prod_{i = 1}^{N}\\frac{\\ud^n x_i}{\\left(2\\pi(t_{i + 1} - t_{i})\\right)^{n/2}}\\exp\\left(-\\sum_{i = 1}^{N}{\\Delta t\\left(\\frac{x_{i + 1} - x_{i}}{\\Delta t}\\right)}\\right)^2\\right]\n\\end{equation}\ndoes exist. This is called the \\emph{Wiener measure}\\index{measure!Wiener}.\\footnote{Note that this isn't translationally invariant due to the exponential. It also plays a role in Brownian motion/stochastic calculus.\\index{Brownian motion}} It's actually what we've been using all along to do perturbation theory. More importantly, it is a measure on the space of \\emph{continuous} maps $\\mathcal{C}^{0}$, not simply differentiable ones, $\\mathcal{C}^{1}$. This will be the key to non-commutativity. Consider, for $t_+ > t$;\n\\begin{dmath*}\n\\bra{y_1}e^{-H(T - t_+)}\\hat{p}e^{-H(t_+ - t)}\\hat{x}e^{-Ht}\\ket{y_0} = \\int{\\mD x\\,\\,e^{-S[x]}\\dot{x}(t_+)x(t)}\n\\end{dmath*}\nBut on the other hand, for $t > t_-$;\n\\begin{dmath*}\n\\bra{y_1}e^{-H(T - t)}\\hat{x}e^{-H(t - t_-)}\\hat{p}e^{-Ht_-}\\ket{y_0} = \\int{\\mD x\\,\\,e^{-S[x]}\\dot{x}(t_-)x(t)}\n\\end{dmath*}\nAs $t_+ \\rightarrow t$ from above and $t_-\\rightarrow t$ from below (which will be the case in the rest of this section), the difference on the LHS is just;\n\\begin{equation}\n\\bra{y_0}e^{-H(T - t)}[\\hat{p}, \\hat{x}]e^{-Ht}\\ket{y_0} = -\\bra{y_1}e^{-Ht}\\ket{y_0} = -\\int{\\mD x\\,\\,e^{-S[x]}}\n\\end{equation}\nBut if we worked instead with the discretised RHS, we have;\n\\begin{equation*}\n\\frac{(x_{t + \\Delta t} - x_t)}{\\Delta t}x_t - x_t\\frac{(x_t - x_{t - \\Delta t})}{\\Delta t} = \\lim_{t_+ \\rightarrow t}\\dot{x}(t_+)x(t) - \\lim_{t_-\\rightarrow t}\\dot{x}(t_-)x(t)\n\\end{equation*}\nThus, in the discretised path integral we have;\n\\begin{dmath*}\n\\int{\\upd{x_t}K_{\\Delta t}\\left(x_{t + \\Delta t}, x_t\\right)\\left(\\frac{(x_{t + \\Delta t} - x_t)}{\\Delta t}x_t - x_t\\frac{(x_t - x_{t - \\Delta t})}{\\Delta t}\\right)K_{\\Delta t}\\left(x_t, x_{t - \\Delta t}\\right)}\n\\end{dmath*}\nRecalling that $K_{\\Delta t}(x, y) = (2 \\pi t)^{-1/2}\\exp\\left(-(x - y)^2/2\\Delta t\\right)$, this becomes;\n\\begin{multline*}\n\\int{\\upd{x_t}\\left(x_t\\frac{\\del}{\\del x_t}\\left[K_{\\Delta t}\\left(x_{t + \\Delta t}, x_t\\right)\\right]K_{\\Delta t}\\left(x_t, x_{t - \\Delta t}\\right)\\right.} \\\\ \\left.+ x_t K_{\\Delta t}\\left(x_{t + \\Delta t}, x_t\\right)\\frac{\\del}{\\del x_t}\\left[K_{\\Delta t}\\left(x_t, x_{t - \\Delta t}\\right)\\right]\\right)\n\\end{multline*}\nwhich we can recognise as a total derivative multiplying $x_t$;\n\\begin{equation*}\n\\int{\\upd{x_t}x_t\\frac{\\del}{\\del x_t}\\left[K_{\\Delta t}\\left(x_{t + \\Delta t}, x_t\\right)K_{\\Delta t}\\left(x_{t}, x_{t - \\Delta t}\\right)\\right]}\n\\end{equation*}\nIntegrating by parts and using the concatenation relation for the heat kernel, we find that the result is;\n\\begin{equation*}\n-\\int{\\upd{x_t}K_{\\Delta t}\\left(x_{t + \\Delta t}, x_t\\right)K_{\\Delta t}\\left(x_t, x_{t - \\Delta t}\\right)} = -K_{2\\Delta t}\\left(x_{t + \\Delta t}, x_{t - \\Delta t}\\right)\n\\end{equation*}\nPutting this insertion back into the full path integral, we just find,\n\\begin{equation*}\n-\\int{\\mD x\\,\\, e^{-S[x]}}\n\\end{equation*}\nagreeing with the result derived above using the canonical quantisation approach.\n\\subsection{Effective Quantum Mechanics}\nWhen we regularise\\index{regularisation} our path integral e.g. by discretising our spacetime or imposing a cutoff on the Fourier modes, then the path integral is finite dimensional and the factor $e^{-S}$ will plausibly cause it to converge. However, the answer we will get will ultimately depend on the regularisation procedure. Renormalisation\\index{renormalisation} is about understanding which properties of a low energy theory are insensitive to the cut off of the regularisation procedure. We want to get the idea in $d = 1$. Let $x, y : S^{1} \\rightarrow \\RR$, then define the action\\footnote{Note that on $S^{1}$ we can always integrate by parts trivially.}\n\\begin{equation*}\nS[x, y] = \\int_{S^1}{\\upd{t}\\frac{1}{2}\\dot{x}^2 + \\frac{1}{2}\\dot{y}^2 + \\frac{1}{2}m^2 x^2 + \\frac{1}{2}M^2 y^2 + \\frac{\\lambda}{4}x^2 y^2}\n\\end{equation*}\nin a similar way to our $d = 0$ discussion we have the momentum space propagators as shown in \\autoref{fig:1df};\n\\begin{mygraphic}{aqft/1df}{0.6}{The momentum space propagators for our $d = 1$ theory. Note that because we now have kinetic terms, we can propagate from one place to another.}{1df}\\end{mygraphic}\nIf we're only interested in the correlation functions for $x$ say, then we can construct an effective action\\index{effective action};\n\\begin{equation*}\ne^{-S_{\\text{eff}}[x]} = \\int{\\mD y \\,\\, e^{-S[x, y]}}\n\\end{equation*}\nThen holding $x$ fixed, the path integral for $y$ has the action;\n\\begin{equation*}\nS[y] = \\frac{1}{2}\\int{\\upd{t}y\\left(-\\frac{\\ud^2}{\\ud t^2} + M^2 + \\frac{\\lambda x^2(t)}{2}\\right)}\n\\end{equation*}\nThen we see, at least formally that;\n\\begin{multline}\nS_{\\text{eff}}[x] = \\int_{S^1}{\\upd{t}\\frac{1}{2}\\dot{x}^2 + \\frac{1}{2}m^2 x^2} + \\frac{1}{2}\\log \\det \\left(-\\frac{\\ud^2}{\\ud t} + M^2 + \\frac{\\lambda x^2(t)}{2}\\right)\n\\end{multline}\nWe make use of the following identity;\n\\begin{equation*}\n\\log \\det AB = \\tr \\log AB = \\tr \\log A + \\tr \\log B\n\\end{equation*}\n\\begin{equation*}\nA = -\\frac{\\ud^2}{\\ud t^2} + M^2, \\qquad B = 1 - \\lambda \\left(\\frac{\\ud^2}{\\ud t^2} - M^2\\right)^{-1}x^2\n\\end{equation*}\nSo the new correction term is;\n\\begin{equation*}\n\\underbrace{\\frac{1}{2}\\tr\\log\\left(-\\frac{\\ud^2}{\\ud t^2} + M^2\\right)}_{\\text{field indep. so drop}} + \\frac{1}{2}\\tr \\log\\left(1 - \\lambda \\left(\\frac{\\ud^2}{\\ud t^2} - M^2\\right)^{-1}x^2\\right)\n\\end{equation*}\nNow, the inverse differential operator should be understood as the Green's function\\index{Green's function}, $G(t, t\\pr)$ i.e.\n\\begin{equation*}\n\\left(\\frac{\\ud^2}{\\ud t^2} - M^2\\right)G(t, t\\pr) = \\delta(t - t\\pr)\n\\end{equation*}\nOn $S^{1}$ with circumference $T$ this is just given by;\n\\begin{equation}\nG(t, t\\pr) = \\frac{1}{2M}\\sum_{k \\in \\ZZ}{\\exp\\left(-M\\abs{t - t\\pr + kT}\\right)}\n\\end{equation}\nthen we just have;\n\\begin{equation*}\n\\left(\\frac{\\ud^2}{\\ud T^2} - M^2\\right)^{-1}x^2(t) = \\int_{S^1}{\\upd{t\\pr}G(t, t\\pr)x^2(t\\pr)}\n\\end{equation*}\nThus, the field dependent part of the new term in $S_{\\text{eff}}[x]$ can be expanded as;\\footnote{Note that the trace aspect is accounted for by evaluating the first argument of the first Green's function and the second argument of the last Green's function at the same time.}\n\\begin{align*}\n&\\tr\\log\\left(1 - \\frac{\\lambda}{2}\\left(\\frac{\\ud^2}{\\ud t^2} - M^2\\right)^{-1}x^2\\right) \\\\\n&= -\\sum_{n = 1}^{\\infty}{\\frac{1}{n}\\left(\\frac{\\lambda}{2}\\right)^n}\\int_{(S^1)^{n}}{\\ud t_1 \\cdots \\upd{t_n} G(t_1, t_2)x^2(t_2)\\cdots G(t_n, t_1)x^2(t_1)} \\\\\n&= -\\frac{\\lambda}{2}\\int{\\upd{t_1}G(t_1, t_1)x^2(t_1)} - \\frac{\\lambda}{8}\\int{\\ud t_1 \\upd{t_2}G(t_1, t_2)x^2(t_2)G(t_2, t_1)x^(t_1)} + \\cdots\n\\end{align*}\nWe see that we have a new contribution to the quadratic term together with an infinite series of new self-interactions. Importantly, these terms are now \\emph{non-local}. This non-locality is easy to understand from the Feynman diagrams in \\autoref{fig:eff}\n\\begin{mygraphic}{aqft/eff}{0.6}{The self-interactions of the field $x$ that describe how the field can propagate via the interaction with the $y$ field.}{eff}\\end{mygraphic}\nWith this being said, it's still in conflict with what we expect classically. How strong an effect is it? We see that $G(t, t\\pr)$ decays exponentially with a scale set by the inverse mass for $t \\neq t\\pr$ on $S^{1}$. As an example consider the second order term;\n\\begin{equation*}\n\\int{\\ud t \\upd{t\\pr} G\\left(t, t\\pr\\right)x^2(t\\pr) G(t\\pr, t)x^{2}(t)}\n\\end{equation*}\nthen expand $x^{2}(t\\pr)$ around $x(t)$.\\footnote{This is fine since we have regularised the integral} Then we have, using the fact that $G$ is symmetric in $t, t\\pr$;\n\\begin{multline*}\n\\int{\\ud t\\upd{t\\pr} G(t, t\\pr)x^2(t\\pr)G(t, t\\pr)x^{2}(t)} \\\\ = \\int{\\ud t \\upd{t\\pr} G(t, t\\pr)^2 x^{2}(t)}  \\left\\{x^2(t) + 2x(t)\\dot{x}(t)(t - t\\pr)\\right.  \\\\ \\left.+ \\left(\\dot{x}^2 + x(t)\\ddot{x}(t)\\right)(t - t\\pr)^2 + \\cdots\\right\\}\n\\end{multline*}\nNow note that $G(t, t\\pr)$ only depends on $t\\pr$ via $M(t - t\\pr)$ so we can make the substitution $u = M(t - t\\pr)$ i.e. $\\ud t\\pr \\propto M^{-1}\\ud u$. Making this substitution and noticing that whilst we do not know the value, the integrals just give dimensionless numbers;\n\\begin{equation*}\n= \\int{\\upd{t}\\frac{\\alpha}{M}x^{4} + \\frac{\\beta}{M^3}\\left(\\dot{x}^2 x^2 + \\frac{1}{2}x^3 \\ddot{x}\\right) + \\frac{\\gamma}{M^5}\\left(\\cdots\\right) + \\cdots}\n\\end{equation*}\nwhere $\\alpha, \\beta, \\gamma, \\ldots$ are dimensionless. So in the expansion, terms with higher derivatives of $x$ are suppressed with higher powers of $M^{-1}$. This suggests that provided we restrict to Fourier modes of $x$ whose energy is much less that $M$, these higher terms can be neglected. This being said, truncating at a given order leads to a non-unitary approximation; there are other possibilities that we simply haven't considered. \n\\subsection{Quantum Gravity in One Dimension}\nSo far we've fixed the metric $g = \\delta$, but it's interesting to see what happens for a general metric $g$ on $\\mM$. We can rewrite our original action in a way that is manifestly diffeomorphism invariant;\\footnotemark\n\\footnotetext{\nUnder a general diffeomorphism, $t \\mapsto t\\pr(t)$ we have \n$$\\sqrt{g}\\ud t \\mapsto \\sqrt{g\\pr}(\\ud t\\pr/\\ud t)(\\ud t/\\ud t\\pr) \\ud t\\pr = \\sqrt{g\\pr}\\ud t\\pr$$\nSimilarly,\n$$g^{tt}\\del_t x^{a}\\del_t x^{b} \\mapsto g^{t\\pr t\\pr}\\left(\\frac{\\ud t\\pr}{\\ud t}\\right)^2 \\left(\\frac{\\ud t}{\\ud t\\pr}\\right)^2 \\del_{t\\pr}x^{a}\\del_{t\\pr}x^{b}$$\n}\n\\begin{equation}\nS[g, x] = \\int_{\\mM}{\\upd{t}\\sqrt{g}\\left[\\frac{1}{2}G_{ab}(x)g^{tt}(t)\\del_t x^{a}\\del_{t}x^{b} + \\frac{1}{2}V(x)\\right]}\n\\end{equation}\nNow $g_{tt}$ is specified simply by a single positive function $e^{2}:\\mM \\rightarrow \\RR_{>0}$. Then $\\sqrt{g} = \\abs{e}$ and $g^{tt}= e^{-2}$. There's also no notion of curvature as we only have one direction i.e. $\\left[\\nabla_t, \\nabla_t\\right] = 0$, so the Einstein equation is just $T_{tt} = 0$. Now;\n\\begin{equation*}\nT_{tt} \\coloneqq \\frac{2}{\\sqrt{g}}\\frac{\\delta\\left(\\sqrt{g}\\mL\\right)}{\\delta g^{tt}} = \\frac{1}{2}G_{ab}(x)\\dot{x}^{a}\\dot{x}^{b} - \\frac{1}{2}g_{tt}V(x)\n\\end{equation*}\nwhich follows by directly varying $g^{tt} \\mapsto g^{tt} + \\delta g^{tt}$, so that $\\sqrt{g} \\mapsto \\sqrt{g}(1 + \\tfrac{1}{2}g_{tt}\\delta g^{tt})$ etc. Then we see that $T^{tt} = 0$ implies that;\n\\begin{equation}\ng_{tt}(t) = e^{2}(t) = \\frac{1}{V(x)}G_{ab}(x)\\dot{x}^{a}\\dot{x}^{b}\n\\end{equation}\nIn the special case that $V(x) = V_0$ is a constant we find that;\n\\begin{equation*}\nS[x] = \\sqrt{V_0}\\int_{\\mM}{\\upd{t}\\sqrt{G_{ab}(x)\\dot{x}^{a}\\dot{x}^{b}}}\n\\end{equation*}\nwhich is just the proper length of an image curve $x(\\mM) \\subset \\mathcal{N}$. Now the momentum conjugate to $x^{a}$ in the original action is just;\n\\begin{equation*}\np_a = \\frac{\\delta \\mL}{\\delta \\dot{x}^{a}} = \\frac{1}{\\abs{e}}G_{ab}(x)\\dot{x}^{b}\n\\end{equation*}\nwhich means the Einstein equation\\index{equation!Einstein} becomes;\n\\begin{equation*}\nG^{ab}p_a p_b - V(x) = 0 \\Rightarrow G^{ab}p_a p_b - m^2 = 0\n\\end{equation*}\nif the potential is $V(x) = m^2$. Under canonical quantisation\\index{canonical quantisation} we take $p_a \\mapsto -\\del/\\del x^{a}$ so that, for all states $\\Psi \\in \\hamilt$;\n\\begin{equation*}\n\\left(\\eta^{ab}\\del_a \\del_b - m^2\\right)\\Psi = 0\n\\end{equation*}\nNow consider the case $(\\mathcal{N}, G) = (\\RR^{n-1,1}, \\eta)$ with $V(x) = m^2$. Then, consider inserting complete sets of momentum states in the matter path integral;\n\\begin{equation*}\n\\bra{y}e^{-HT}\\ket{x} = \\int{\\ud^n p \\upd{^{n} q}\\braket{y}{p}\\bra{p}e^{-HT}\\ket{q}\\braket{q}{x}}\n\\end{equation*}\nUsing the canonical relation $\\braket{p}{x} = e^{ip\\cdot x}$ as well as the fact that $\\bra{p}e^{-HT}\\ket{q}$ is simply the Fourier transform of the heat kernel, we find;\n\\begin{equation*}\n\\bra{y}e^{-HT}\\ket{x} = \\int_{C_I[x, y]}{\\mD x\\,\\, e^{-S[x]}} = \\int{\\frac{\\ud^n p}{(2\\pi)^{n}}e^{ip\\cdot(x - y)}e^{-T(p^2 + m^2)/2}}\n\\end{equation*}\nIn quantum gravity\\index{quantum gravity} we should now integrate this over all possible metrics, up to diffeomorphism on $\\mM$. In one dimension, since we only have one positive function, we can always choose a diffeomorphism to reduce to $g = \\delta$ locally. We cannot quite remove all the freedom however, and are obligated only to integrate over all possible volumes, since these are diffeomorphism invariant;\n\\begin{equation*}\nT = \\int_I{\\upd{t}\\sqrt{g_{tt}}}\n\\end{equation*}\nHence the space $\\text{Met}(I)/\\text{Diff}(I)$ of metrics up to diffeomorphism is simply the space of possible total lengths of our worldline. This is known as the \\emph{moduli space}\\index{moduli space} of Riemannian metrics on $I$. Then the matter path integral over this moduli space is;\n\\begin{equation*}\n\\int_0^{\\infty}{\\upd{T}\\int{\\frac{\\ud^n p}{(2\\pi)^{n}}e^{ip\\cdot(x - y)}e^{-T(p^2 + m^2)/2}}} = \\int{\\frac{\\ud^n p}{(2\\pi)^{n}}\\frac{e^{ip\\cdot(x - y)}}{p^2 + m^2}}\n\\end{equation*}\nwhich we recognise as the the Euclidean space propagator for a scalar field of mass $m$ \\emph{on the space} $\\RR^{n}$. In other words we can write;\n\\begin{equation*}\nD(x, y) = \\int_{\\text{Met}(I)/\\text{Diff}(I)}{\\mD g\\int_{C_I[x,y]}{\\mD x\\,\\, e^{-S[x,g]}}}\n\\end{equation*}\nChoosing more complicated matter content e.g. fermions for our worldline QFT leads to propagators of different spin in the target space $(\\mathcal{N}, G)$. Feynman took this further, he realised that one could describe several such particles interacting with one another by replacing the worldline, $I$, by a worldgraph\\index{worldgraph} $\\Gamma$. As an example, let $\\Gamma$ be the following graph;\n\\begin{mygraphic}{aqft/wgraph}{0.6}{The edges of $\\Gamma$ are labelled by proper time $T_1$, $T_2$ and $T_3$}{wgraph}\\end{mygraphic}\nThen the path integral becomes;\n\\begin{align*}\n&\\int_0^{\\infty}{\\ud T_1}\\int_{C_{T_1}[x,z]}{\\mD x \\,\\,e^{-S}}\\times \\int_0^{\\infty}{\\ud T_2}\\int_{C_{T_2}[y,z]}{\\mD x\\,\\, e^{-S}} \\\\ \n&\\qquad \\qquad\\qquad\\qquad\\times\\int_{0}^{\\infty}{\\ud T_3}\\int_{C_{T_3}[z,z]}{\\mD x \\,\\, e^{-S}} \\\\\n&\\qquad = \\int{\\ud^n z\\frac{\\ud^n p}{(2\\pi)^{n}}\\frac{\\ud^n q}{(2\\pi)^{n}}\\frac{\\ud^n l}{(2\\pi)^{n}}\\frac{e^{ip\\cdot(x - z)}}{p^2 + m^2}\\frac{e^{iq\\cdot(y - z)}}{q^2 + m^2}\\frac{1}{l^2 + m2}} \\\\\n&\\qquad = \\int{\\frac{\\ud^n p}{(2\\pi)^n}\\frac{\\ud^n l}{(2\\pi)^n}\\frac{e^{ip\\cdot(x - y)}}{(p^2 + m^2)^2 (l^2 + m^2)}}\n\\end{align*}\nBut this is exactly the loop integral for $\\Phi^4$ theory on $\\mathcal{N}$, except now the graph is considered to be in $\\RR^n$. We can extend this; to obtain the full perturbative expansion of $\\left< \\Phi(x_1) \\Phi(x_2)\\cdots\\Phi(x_n) \\right>$ we should now sum over all graph topologies that are appropriate to our $4$-valent vertex interaction. In doing this, we are allowing our graphs to have singularities of the one-dimensional Riemannian manifold, in this case it is not even Hausdorff\\index{Hausdorff}. The matter aspect to the QFT is the integral over some fixed background space $\\Gamma$, quantum gravity then sums over these topologies. \n\n\\paraskip\nAs a final note, this idea is very close to perturbative String theory; the worldgraph $\\Gamma$ is replaces by a two-dimensional Riemann surface $\\Sigma$, and the $d = 1$ worldline QFT is replaced by a $d = 2$ worldsheet CFT. The integral is over the moduli space of Riemann surfaces and the sum is over the topologies of these surfaces.\n\\newpage\n\\section{The Renormalisation Group\\index{renormalisation group}}\nWe need to understand the details of how our theory depends on the particular regularisation we choose. In particular, we need an understanding of the reason why we can actually do low energy physics at all.\n\\subsection{Integrating out Degrees of Freedom}\nSuppose our QFT is governed by the action;\n\\begin{equation}\nS_{\\Lambda_0}[\\phi] = \\int{\\upd{^d x}\\left(\\frac{1}{2}\\del_\\mu \\phi \\del^\\mu \\phi + \\sum_{i}{\\Lambda_0^{d - \\delta_i}g_{i,0}\\mO_i(x)}\\right)}\n\\end{equation}\nwhere $[\\mO_i] = \\delta_i$. Then we can define a regularised path integral over the space of maps $\\mC^{\\infty}(\\mM)_{\\leq \\Lambda_0}$. This explicitly introduces a cut off $\\Lambda_0$ so there can't be UV divergences\\index{UV divergence}.\\footnote{In theory there could be IR divergences, but not if we work on a compact manifold.} Consider integrating out modes with energy in $[\\Lambda, \\Lambda_0]$. We can write a general field as;\n\\begin{equation*}\n\\psi(x) = \\int_{\\abs{p} \\leq \\Lambda}{\\frac{\\ud^d p}{(2\\pi)^d}e^{ip\\cdot x}\\tilde{\\psi}(p)} +  \\int_{\\Lambda \\leq \\abs{p} \\leq \\Lambda_0}{\\frac{\\ud^d p}{(2\\pi)^d}e^{ip\\cdot x}\\tilde{\\psi}(p)} \\coloneqq \\phi(x) + \\chi(x)\n\\end{equation*}\nPath integral measure factorises: $\\mD \\psi = \\mD \\phi \\mD \\chi$ so we can define an effective action\\index{effective action};\n\\begin{equation}\ne^{-S^{\\Lambda}_{\\text{eff}}} = \\int_{(\\Lambda, \\Lambda_0)}{\\mD \\chi e^{-S^{\\Lambda_0}[\\phi, \\chi]}}\n\\end{equation}\nWe can iterate this process at still lower energies, giving us the renormalisation group equation. Now, we can write;\n\\begin{equation}\nS^{\\Lambda_0}[\\phi + \\chi] = S^{0}[\\phi] + S^{0}[\\chi] + S_{\\Lambda_0}^{\\text{int.}}[\\phi, \\chi]\n\\end{equation}\nwhere $S^{0}[\\phi] = \\int{\\upd{^d x}\\left(\\tfrac{1}{2}(\\del \\phi)^2 + \\tfrac{1}{2}m^2 \\phi^2\\right)}$, and;\n\\begin{equation*}\nS_{\\Lambda}^{\\text{int.}}[\\phi] = -\\log\\left(\\int_{\\mC^{\\infty}(\\mM)_{(\\Lambda, \\Lambda_0)}}{\\mD \\chi \\exp\\left(-S^{0}[\\chi] - S_{\\Lambda_0}^{\\text{int.}}[\\phi, \\chi]\\right)}\\right)\n\\end{equation*}\nIntegrating out fields shifts the couplings, but we started with a generic action, so $S_{\\text{eff.}}^{\\Lambda}[\\phi]$ must look like;\n\\begin{equation*}\nS_{\\text{eff.}}^{\\Lambda}[\\phi] = \\int_{\\mM}{\\upd{^d x}\\left(\\frac{Z_\\Lambda}{2}(\\del \\phi)^2 + \\sum_{i}{\\Lambda^{d - \\delta_i}g_i\\pr(\\Lambda)\\mO_i}\\right)}\n\\end{equation*}\nWe have allowed for a \\emph{wavefunction renormalisation}\\index{wavefunction renormalisation} factor $Z_{\\Lambda}$ to account for the possibility that the kinetic term may have shifted. We can always absorb this by defining a renormalised field;\n\\begin{equation*}\n\\psi = Z_{\\Lambda}^{\\tfrac{1}{2}}\\phi\n\\end{equation*}\nat the expense of changing $g_i\\pr(\\Lambda) \\mapsto g_i(\\Lambda) = g_i\\pr(\\Lambda)Z_{\\Lambda}^{-n_i/2}$, where $n_i$ is the number of fields in $\\mO_i$. Then, if $\\mO_i$ received no quantum corrections, we would have;\n\\begin{equation*}\ng_{i}(\\Lambda) = Z_{\\Lambda}^{\\tfrac{1}{2}}\\left(\\frac{\\Lambda_0}{\\Lambda}\\right)^{d - \\delta_i}g_i(\\Lambda_0)\n\\end{equation*}\nwhich is really simply a change of units. Most operators do receive quantum corrections however, so we define the $\\beta$-function\\index{beta function};\n\\begin{equation}\n\\beta_i \\coloneqq \\Lambda \\frac{\\del g_i}{\\del \\Lambda} \\Rightarrow \\beta_i\\left(g_j(\\Lambda)\\right) = (\\delta_i - d)g_i + \\beta_i^{\\text{quantum}}\n\\end{equation}\n\\subsubsection{Anomalous Dimensions\\index{anomalous dimension}}\nWe can also define the \\emph{anomalous dimension} of $\\phi$:\n\\begin{equation}\n\\gamma_{\\phi} = -\\frac{1}{2}\\Lambda\\frac{\\del}{\\del \\Lambda}\\log Z_{\\Lambda}\n\\end{equation}\nwhich tells us how the coefficient of the kinetic term changes with scale. Now consider the $n$-point correlator;\n\\begin{multline*}\n\\left< \\phi(x_1)\\cdots \\phi(x_n) \\right> = \\\\ \\frac{1}{\\mZ}\\int_{\\mC^{\\infty}(\\mM)_{\\leq \\Lambda}}{\\mD\\phi \\exp\\left(-S_{\\Lambda}^{\\text{eff.}}[Z_n^{\\tfrac{1}{2}}\\phi; g_{i}(\\Lambda_0)]\\right)\\phi(x_1)\\cdots \\phi(x_n)}\n\\end{multline*}\nWe can canonically renormalise the field as above and define:\n\\begin{equation*}\n\\left< \\Phi(x_1)\\cdots\\Phi(x_n) \\right> \\coloneqq \\Gamma_{\\Lambda}^{n}(x_1, \\ldots, x_n; g_j)\n\\end{equation*}\nSo that;\n\\begin{equation*}\n\\left< \\phi(x_1)\\cdots \\phi(x_n) \\right> = Z_{\\Lambda}^{-n/2}\\Gamma_{\\Lambda}^{n}(x_1, \\ldots, x_n; g_j)\n\\end{equation*}\nIf we have field insertions at an energy much below $\\Lambda$ we should be able to use a lower energy theory to calculate the correlator. Integrating out modes in $(s\\Lambda, \\Lambda]$ we find;\n\\begin{equation*}\nZ_{s\\Lambda}^{-n/2}\\Gamma_{s\\Lambda}^{n}\\left(x_1, \\ldots, x_n; g_j(s\\Lambda)\\right) = Z_{\\Lambda}^{-n/2}\\Gamma_{\\Lambda}^{n}\\left(x_1, \\ldots, x_n; g_j(\\Lambda) \\right)\n\\end{equation*}\nRescaling $x^{\\mu} \\mapsto sx^{\\mu}$ we see that the kinetic term is invariant provided $\\phi(sx) = s^{2 - d/2}\\phi(x)$. The remaining terms are invariant if we take $\\Lambda \\mapsto \\Lambda / s$. Ten;\n\\begin{align*}\n\\Gamma_{\\Lambda}^{n}\\left(x_1, \\ldots, x_n; g_j(\\Lambda)\\right) &= \\left(\\frac{Z_{s\\Lambda}}{Z_\\Lambda}\\right)^{-n/2}\\Gamma^{n}_{s\\Lambda}\\left(x_1, \\ldots, x_n; g_j(s\\Lambda)\\right) \\\\\n&= \\left(s^{d - 2}\\frac{Z_{s\\Lambda}}{Z_\\Lambda}\\right)^{-n/2}\\Gamma_{\\Lambda}^{n}\\left(sx_1, \\ldots, sx_n ; g_j(s\\Lambda)\\right)\n\\end{align*}\nLetting $y_i = sx_i$ we have;\n\\begin{equation*}\n\\Gamma_{\\Lambda}^{n}\\left(\\frac{y_1}{s}, \\ldots, \\frac{y_n}{s}; g_i(\\Lambda)\\right) = \\left(s^{d - 2}\\frac{Z_{s\\Lambda}}{Z_\\Lambda}\\right)^{-n/2}\\Gamma_{\\Lambda}^{n}\\left(y_1, \\ldots, y_n ; g_j(s\\Lambda)\\right)\n\\end{equation*}\nThis says that we can either compute the IR behaviour of the correlator in terms of the couplings of the original theory, whilst letting the separations change, or we can keep the separations fixed and let the couplings run. Letting $s = 1 - \\delta s$ we find that the prefactor;\n\\begin{equation*}\n\\left(s^{d - 2}\\frac{Z_{s\\Lambda}}{Z_\\Lambda}\\right)^{-1/2} = 1 - \\left(\\frac{2 - d}{2} - \\gamma_\\phi \\right) + \\cdots\n\\end{equation*}\nSo we see that the correlator behaves as if the field scales with mass dimension;\n\\begin{equation}\n\\frac{d - 2}{2} + \\gamma_\\phi \\coloneqq \\Delta_{\\phi}\n\\end{equation}\n\\subsection{Renormalisation Group Flow\\index{renormalisation group!flow}}\nTheories with couplings $g_i^{\\star}$ such that $\\beta_i(g_j^{\\star}) = 0$ are known as critical theories, with the most obvious being the Gaussian theory. At a critical point, the \\emph{Callan-Symanjik}\\index{equation!Callan-Symanjik} equation for $\\Gamma_\\Lambda^{2}$ is;\n\\begin{equation*}\n\\Lambda \\frac{\\del \\Gamma^{2}_{\\Lambda}(x, y)}{\\del \\Lambda} = -2\\gamma_\\phi (g_j^{\\star}) \\Gamma_\\Lambda^{2}(x, y)\n\\end{equation*}\nwhich implies that $\\Gamma_{\\Lambda}^{2}$ is a homogeneous function of $\\Lambda$ of degree $-2\\gamma_\\phi$. IN a translationally and rotationally invariant theory $\\Gamma_\\Lambda^{2}$ can only be a function of $\\abs{x - y}$, so since it must also have mass dimension $d - 2$, we have;\n\\begin{equation}\n\\Gamma_{\\Lambda}^{2}(x, y) = \\Lambda^{d - 2}f(\\Lambda\\abs{x - y})\n\\end{equation}\nThen the homogeneity fixes;\n\\begin{equation*}\n\\Gamma_{\\Lambda}^{2}(x, y) = \\frac{\\Lambda^{d - 2}c(g_j)}{\\Lambda^{2 \\Delta_\\phi}\\abs{x - y}^{2\\Delta_\\phi}} = \\frac{c(g_j)}{\\abs{x - y}^{2\\Delta_\\phi}}\n\\end{equation*}\nUnder a change of metric in a critical theory we have that;\n\\begin{equation*}\n-\\delta g^{\\mu\\nu}(x)\\frac{\\delta}{\\delta g^{\\mu\\nu}(x)}\\log \\mZ = \\delta g^{\\mu\\nu}\\left< \\frac{\\delta S}{\\delta g^{\\mu\\nu}(x)} \\right> = -\\frac{\\sqrt{g}}{2}\\delta g^{\\mu\\nu}\\left< T_{\\mu\\nu}(x) \\right>\n\\end{equation*}\nA scale transformation simply corresponds to $\\delta g^{\\mu\\nu} = e^{2\\Omega}g^{\\mu\\nu}$ so a scale invariant theory has;\n\\begin{equation*}\ng^{\\mu\\nu}\\left< T_{\\mu\\nu}(x) \\right> = \\left< T\\indices{^{\\mu}_{\\mu}} \\right> = 0\n\\end{equation*}\nTheories that are scale invariant are believed to always be conformally invariant as well. Now, starting near a critical point with couplings $g_i = g_i^{\\star} + \\delta g_i$ we have;\n\\begin{equation*}\n\\beta(g_j^{\\star} + \\delta g_j) = B_{ij}(g_k^{\\star}) \\delta g_j + \\mO(\\delta g^2)\n\\end{equation*}\nwhich tells us how fast a coupling to an operator $\\mO_i$ is generated starting from a theory with a small coupling to $\\mO_j$. Eigenvalues of $B_{ij}$ correspond to turning on a particular combination of monomial operators. The eigenvalues satisfy;\n\\begin{equation*}\n\\sigma_i(\\Lambda) = \\left(\\frac{\\Lambda}{\\Lambda_0}\\right)^{\\Delta_i - d}\\sigma_i(\\Lambda_0)\n\\end{equation*}\nso that we can classify them as follows;\n\\begin{enumerate}\n\\item An \\emph{irrelevant operator}\\index{operator!irrelevant} has $\\Delta_i > d$. $\\sigma_i$ decreases as $\\Lambda \\rightarrow 0$ and we flow back to the critical point. Adding derivatives or fields to an operator always increases $\\Delta_i$ so we have infinitely many of these.\n\\item \\emph{Relevant operators}\\index{operator!relevant} have $\\Delta_i < d$. These operators become more important as we lower the scale. The \\emph{critical trajectory}\\index{critical trajectory} is the RG flow corresponding to turning on some relevant operators.\n\\item \\emph{Marginal operators}\\index{operator!marginal} have $\\Delta_i = d$. We usually have to look at higher orders in $\\delta g$ to determine their behaviour. These couplings can persist for a large range of energies, typically running only logarithmically.\n\\end{enumerate}\nA generic QFT perturbed around a critical point will flow along a trajectory that focusses in the IR on the renormalised/critical trajectory. This is illustrated in \\autoref{fig:crittraj}\n\\begin{mygraphic}{aqft/crittraj}{0.6}{Theories on the critical surface flow (dashed lines) to a critical point in the IR. Turning on relevant operators drives the theory away from the critical surface (solid lines), with flow lines focussing on the (red) trajectory emanating from the critical point.}{crittraj}\\end{mygraphic}\n\\subsection{Continuum QFT}\nIn condensed matter, we have a natural UV cut off, but this is not the case in high-energy physics. There we are interested in knowing whether the interactions we require in our Lagrangian at an experimental energy scale $\\Lambda$ can be consistent to arbitrarily high energies. Suppose first that our initial couplings $g_{i,0}$ are irrelevant, so they lie on the critical surface $\\mC$. Then taking $\\Lambda_0 \\rightarrow \\infty$ is the same as taking $\\Lambda \\rightarrow 0$ at a fixed $\\Lambda_0$. We just end up at the critical point. \n\n\\paraskip\nBut, theories like QCD and SM contain relevant and marginally relevant interactions. If we start with an initial set of couplings $\\set{g_{i, 0}}$ that include such relevant operators, then as we send $\\Lambda_0 \\rightarrow \\infty$ we will be driven arbitrarily far along the renormalised trajectory as we flow to the IR. To obtain a theory with finite values of the relevant couplings at a finite energy scale, $\\Lambda$ we must tune our initial theory. Now, if we start with $\\set{g_{i, 0}}$ that are close to, but not on the critical surface, then as $\\Lambda_0$ is raised, we flow closer to the critical point for a while, but then move away along the renormalised trajectory. Let $\\mu$ be the energy scale at which our RG flow passes closest to the critical point. On dimensional grounds;\n\\begin{equation}\n\\mu = \\Lambda_0 f(g_{i, 0})\n\\end{equation}\nWe now want to tune our starting point such that $\\mu$ is finite as $\\Lambda_0 \\rightarrow \\infty$. If $\\text{codim}(\\mC) = r$ then this is equivalent to placing one condition on the relevant/marginal couplings. So the theory we end up with will depend on $(r - 1)$ dimensionless couplings called the \\emph{renormalised couplings}\\index{renormalised couplings} together with an energy scale $\\mu$. This process is called \\emph{dimensional transmutation}\\index{dimensional transmutation}.\n\\subsubsection{Counterterms}\nThis is achieved by introducing counterterms $\\set{\\delta g_i, \\delta Z}$ which modify the action at $\\Lambda_0$ to;\n\\begin{equation*}\nS_{\\Lambda_0}[\\phi] \\mapsto S_{\\Lambda_0}[\\phi] + \\hbar S_{\\text{CT}}[\\phi, \\Lambda_0]\n\\end{equation*}\nwhere;\n\\begin{equation}\nS_{\\text{CT}}[\\phi, \\Lambda_0] = \\int_{\\mM}{\\frac{\\delta Z}{2}(\\delta \\phi)^2 + \\sum_{i}{\\delta g_i(\\Lambda_0)\\Lambda_0^{d - \\delta_i}\\mO_i}}\n\\end{equation}\nThis allows us to vary $g_{i, 0} \\mapsto g_{i, 0} + \\hbar \\delta g_{i, 0}(\\Lambda_0)$. The reason for this is not evident until we consider this perturbatively when we look to evaluate;\n\\begin{equation*}\ne^{-S_{\\text{eff}}[\\phi]/\\hbar} = \\int_{\\mC^{\\infty}(\\mM)_{(\\Lambda, \\Lambda_0)}}{\\mD\\chi e^{-S_{\\Lambda_0}[\\phi + \\chi] - \\hbar S_{\\text{CT}}[\\phi + \\chi, \\Lambda_0]/\\hbar}}\n\\end{equation*}\nPerturbatively, at $1$-loop, the $\\mO(\\hbar)$ contributions to $S_{\\text{eff.}}$ come from $1$-loop diagrams using the original vertices in $S_{\\Lambda_0}[\\phi + \\chi]$ together with \\emph{tree level} diagrams from $S_{\\text{CT}}$. The $1$-loop diagrams will depend on $g_{i, 0}$ and $\\Lambda_0$ and typically diverge as $\\Lambda_0 \\rightarrow \\infty$. We then tune the $\\delta g_i$ so that this divergence is balanced by the tree contributions from $S_{\\text{CT}}$. If these are to cancel a UV divergence, they themselves must diverge as $\\Lambda_0 \\rightarrow \\infty$. Indeed, taken separately each term has no meaning in the limit $\\Lambda_0 \\rightarrow \\infty$, however, the careful tuning ensures that the following limit exists;\n\\begin{equation*}\n\\lim_{\\Lambda_0 \\rightarrow \\infty}\\left[\\int{\\mD \\chi e^{-S_{\\Lambda_0}[\\phi + \\chi] - \\hbar S_{\\text{CT}}[\\phi + \\chi, \\Lambda_0]/\\hbar}}\\right]\n\\end{equation*}\n\\subsection{One-loop Renormalisation of $\\lambda \\phi^4$}\nStart with a theory at $\\Lambda_0$:\n\\begin{equation*}\nS_{\\Lambda_0}[\\phi] = \\int{\\upd{^4 x}\\frac{1}{2}(\\del \\phi)^2 + \\frac{1}{2}m^2 \\phi^2 + \\frac{\\lambda}{4!}\\phi^4}\n\\end{equation*}\nNear the Gaussian fixed point we have $[\\phi] = (d - 2)/2 = 1$ in $d = 4$, so that $[m^2] = 2$ and is relevant whilst $[\\lambda] = 0$ is marginal. We want to consider the quantum corrections to the quadratic part of the action. This is essentially trying to calculate an effective action so we just sum over connected diagrams. These can be calculated by considering;\n\\begin{equation*}\n\\Delta(k^2) = \\int{\\upd{^4 x} e^{ik\\cdot x}\\left< \\phi(x)\\phi(0) \\right>_{\\text{conn.}}}\n\\end{equation*}\nLetting $\\Pi(k^2)$ denote the sum of all $1$PI Feynmann graphs with two external $\\phi$'s we have the following, illustrated in \\autoref{fig:phi4one};\n\\begin{mygraphic}{aqft/phi4one}{0.7}{The fully connected two point diagram can be written as an infinite sum of connected $1$PI diagrams.}{phi4one}\\end{mygraphic}\n\\begin{multline*}\n\\left< \\phi(x)\\phi(0) \\right>_{\\text{conn.}} = \\frac{1}{k^2 + m^2} + \\frac{1}{k^2 + m^2}\\Pi(k^2)\\frac{1}{k^2 + m^2} \\\\ + \\frac{1}{k^2 + m^2}\\Pi(k^2)\\frac{1}{k^2 + m^2}\\Pi(k^2)\\frac{1}{k^2 + m^2} + \\cdots\n\\end{multline*}\nSumming this as a geometric series we see that;\n\\begin{equation}\n\\left< \\phi(x)\\phi(0) \\right>_{\\text{conn.}} = \\frac{1}{k^2 + m^2 - \\Pi(k^2)}\n\\end{equation}\nBut the $1$PI diagrams can themselves be expanded as in \\autoref{fig:phi4two};\n\\begin{mygraphic}{aqft/phi4two}{0.7}{Expansion of $1$PI diagram in terms of all $1$PI graphs}{phi4two}\\end{mygraphic}\nWe will just look to one-loop accuracy so only the first diagram contributes with a value;\n\\begin{equation}\n-\\frac{\\lambda}{2}\\int_{\\abs{p}\\leq\\Lambda_0}{\\frac{\\ud^4 p}{(2\\pi)^4}\\frac{1}{p^2 + m^2}} = -\\frac{\\lambda \\text{Vol}(S^{3})}{2(2\\pi)^4}\\int_0^{\\Lambda_0}{\\frac{p^3 \\ud p}{p^2 + m^2}}\n\\end{equation}\nWe use the fact that $\\text{Vol}(S^3) = 2\\pi^2$ and seet $u = p^2/m^2$ so that;\n\\begin{equation}\n\\frac{-\\lambda m^2}{32\\pi^2} \\int_{0}^{\\Lambda_0^2/m^2}{\\frac{u\\ud u}{1 + u}} = - \\frac{\\lambda}{32\\pi^2}\\left(\\Lambda_0^2 - m^2 \\log\\left(1 + \\frac{\\Lambda_0^2}{m^2}\\right)\\right)\n\\end{equation}\nAs we expected, this diverges if we take the continuum limit $\\Lambda_0 \\rightarrow \\infty$. We need to tune our starting point to obtain a finite continuum limit. Using counterterms, we do this by starting with the action $S_{\\Lambda_0}[\\phi] + \\hbar S_{\\text{CT}}[\\phi;\\Lambda_0]$ where;\n\\begin{equation}\nS_{\\text{CT}}[\\phi;\\Lambda_0] = \\int{\\upd{^4 x}\\frac{\\delta Z}{2}(\\del \\phi)^2 + \\frac{\\delta m^2}{2}\\phi^2 + \\frac{\\delta \\lambda}{4!}\\phi^4}\n\\end{equation}\nwhere $\\delta Z, \\ldots$ all depend on $\\Lambda_0$. Due to the factor of $\\hbar$ tree level diagrams including the counterterms contribute at the same order as $1$-loop diagrams using the original vertices. As such we get $\\mO(\\hbar)$ contributions from the diagrams in \\autoref{fig:phi4three}. At two loops, we would have to include counterterm diagrams with loops.\n\\begin{mygraphic}{aqft/phi4three}{0.6}{Two contributing graphs at $\\mO(\\hbar)$ from the counterterm action}{phi4three}\n\\end{mygraphic}\nHence we find, to $1$-loop accuracy that;\n\\begin{equation}\n\\label{eq:phi4one}\n\\Pi_{\\text{\\footnotesize{1-loop}}}(k^2) = -\\delta m^2 - k^2 \\delta Z - \\frac{\\lambda}{32\\pi^2}\\left(\\Lambda_0^2 - m^2 \\log\\left(1+ \\frac{\\Lambda_0^2}{m^2}\\right)\\right)\n\\end{equation}\n\\subsubsection{Renormalisation Schemes\\index{renormalisation!scheme}}\nWe, by hand, adjust the counterterms so that $\\Pi(k^2)$ stays finite as $\\Lambda_0 \\rightarrow \\infty$. But there is a lot of freedom as to exactly how to do this; we can always choose how much of the finite term we want to include in the counterterm. Any such choice is called a \\emph{renormalisation scheme}.\n\n\\paraskip\nA common choice is the \\emph{on-shell} renormalisation scheme. Note that the classical propagator has a unit residue pole at $k^2 = -m^2$. This isn't necessarily the location of the physical mass, $m^2_p$, however due to quantum corrections. In the full theory, the propagator is;\n\\begin{equation*}\n\\frac{1}{k^2 + m^2 - \\Pi(k^2)}\n\\end{equation*}\nSo in the on-shell scheme we choose our counterterms such that;\n\\begin{enumerate}\n\\item $\\Pi(k^2 = -m^2_p) = -m^2_p+ m^2$\n\\item We have a unit residue at $k^2 = -m^2_p$;\n\\begin{equation*}\n\\Rightarrow \\left.\\frac{\\del \\Pi(k^2)}{\\del k^2}\\right|_{k^2 = -m^2_p} = 0\n\\end{equation*}\n\\end{enumerate}\nIt's usually convenient to choose the parameter $m^2$ in $S_{\\Lambda_0}$ to be the physical mass so that $\\left.\\Pi(-k^2)\\right|_{k^2 = m^2_p} = 0$. Note that from the expression in \\eqref{eq:phi4one}, the residue condition gives;\n\\begin{equation}\n\\delta Z = 0\n\\end{equation}\nto $1$-loop order. This is a coincidence of $\\lambda \\phi^4$ in the the external momentum does not flow round the loop in the $1$-loop diagram. If we had a $g\\phi^3$ vertex for example, this would not have been the case. At two loops, we do get a contribution to $\\delta Z$ from the last diagram in \\autoref{fig:phi4two}. Now, the remaining condition fixes (with $m^2 = m^2_p$);\n\\begin{equation}\n\\delta m^2 = -\\frac{\\lambda}{32\\pi^2}\\left(\\Lambda_0^2 - m^2_p \\log \\left(1 + \\frac{\\Lambda_0^2}{m^2_p}\\right)\\right)\n\\end{equation}\nThus, at $1$-loop we find that we have $\\Pi_{\\text{\\footnotesize{1-loop}}}(k^2) = 0$ in this scheme. In particular this is finite as $\\Lambda_0 \\rightarrow \\infty$. So we have a well-defined quantum effective action at $1$-loop order, at least for the quadratic terms.\n\\subsubsection{Quartic Coupling Renormalisation}\nTo one loop order, the quartic coupling in $\\Gamma$ (the quantum effective action) receives contributions from all $1$PI diagrams with $4$ external legs.\n\\begin{center}\\includegraphics[width=0.9\\textwidth]{graphics/aqft/quart1.png}\\label{fig:quart1}\\end{center}\nThe loop diagrams in momentum space then have a contribution given by, for example;\n\\begin{center}\\includegraphics[width=0.7\\textwidth]{graphics/aqft/quart2.png}\\label{fig:quart2}\\end{center}\nThe fact that these loop integrals depend on the $k_i$ mean that they generate an infinite series of derivative interactions in $\\Gamma$ such as $\\del_\\mu \\phi \\del^{\\mu} \\phi \\phi^2$. The contribution to the pure $\\phi^4$ vertex is independent of the $k_i$ so it is given by;\n\\begin{equation*}\n3 \\frac{\\lambda^2}{2} \\int^{\\Lambda_0}{\\frac{\\ud^4 p}{(2\\pi)^4}\\frac{1}{(p^2 + m^2)^2}}\n\\end{equation*}\nsince each of the three channels contributes equally. This loop integral is logarithmically divergent as $\\Lambda_0 \\rightarrow \\infty$;\n\\begin{align*}\n\\frac{3\\lambda^2}{2} \\int^{\\Lambda_0}{\\frac{\\ud^4 p}{(2\\pi)^4}\\frac{1}{(p^2 + m^2)^2}} &= \\frac{3 \\lambda^2}{32 \\pi^4}\\text{vol}(\\mS^{3})\\int_0^{\\Lambda_0}{\\frac{p^3 \\ud p}{(p^2 + m^2)^2}} \\\\\n&= \\frac{3\\lambda^2}{32\\pi^4}\\text{vol}(\\mS^3)\\int_0^{\\Lambda_0^2 / m^2}{\\frac{u \\ud u}{(1 + u)^2}} \\\\\n&= \\frac{3\\lambda^2}{32\\pi^2}\\left(\\log\\left(1 + \\frac{\\Lambda_0^2}{m^2}\\right) - \\frac{\\Lambda_0^2}{\\Lambda_0^2 + m^2}\\right)\n\\end{align*}\nTo get a finite result for $\\lambda_{\\text{eff.}}$ we tune our initial $\\lambda$ using $\\delta \\lambda$. We might choose;\n\\begin{equation}\n\\delta \\lambda = \\frac{3\\lambda^2}{32\\pi^2}\\left(\\log\\left(\\frac{\\Lambda_0^2}{m^2}\\right) - 1\\right)\n\\end{equation}\nin which case we find that;\n\\begin{equation}\n\\lambda_{\\text{eff.}} = \\lambda - \\frac{3\\hbar \\lambda^2}{32 \\pi^2}\\left(\\log\\left(1 + \\frac{m^2}{\\Lambda_0^2}\\right) + \\frac{m^2}{m^2 + \\Lambda_0^2}\\right) + \\mO(\\hbar^2)\n\\end{equation}\n\\subsubsection{The Role of Irrelevant Couplings}\nWe neglected derivative terms in $\\Gamma$ during this calculations. In general though, these are generated and contribute to four particle scattering processes. Using $\\Gamma$ we should use all terms with exactly $4$ $\\phi$'s. To calculate these we need to actually evaluate the loop integrals at non-zero external momenta. We make use of Feynman's trick;\n\\begin{equation*}\n\\frac{1}{AB} = \\frac{1}{B - A}\\left.\\left(\\frac{1}{xA + (1 - x)B}\\right)\\right|_{0}^{1} = \\int_0^{1}{\\frac{\\ud x}{\\left(Ax + (1 - x)B\\right)^2}}\n\\end{equation*}\nto rewrite;\n\\begin{align*}\n&\\frac{1}{(p^2 + m^2)}\\frac{1}{\\left((p + k_{12})^2 + m^2\\right)} \\\\\n& \\quad = \\int_0^{1}{\\frac{\\ud x}{\\left(x\\left((p + k_{12})^2 + m^2\\right) + (1 - x)(p^2 + m^2)\\right)^2}} \\\\\n& \\quad = \\int_{0}^{1}{\\frac{\\ud x}{(p^2 + m^2 + 2x k_{12}\\cdot p + xk_{12}^2)^2}} \\\\\n& \\quad = \\int_{0}^{1}{\\frac{\\ud x}{\\left[(p - xk_{12})^2 + m^2 + x(1 - x)k_{12}\\right]^2}}\n\\end{align*}\nSo that if $l = p - xk_{12}$ the loop integral becomes;\n\\begin{equation*}\n\\frac{\\lambda^2}{2}\\int_0^{1}{\\upd{x}\\int{\\frac{\\ud^4 l}{(2\\pi)^4}\\frac{1}{\\left(l^2 + m^2 + x(1 - x)k_{12}\\right)^2}}}\n\\end{equation*}\nWe're supposed to integrate this over $\\abs{p} \\leq \\Lambda_0$, however as $\\Lambda_0 \\rightarrow \\infty$ this only differs from the region $\\abs{l} \\leq \\Lambda_0$ by terms of order $k_{12} / \\Lambda_0$ which become negligible. In this regime, the loop integral is;\n\\begin{align*}\n&\\frac{\\lambda^2}{32\\pi^4}\\text{vol}(\\mS^3)\\int_0^{1}{\\upd{x}\\int{\\frac{l^3 \\ud l}{\\left(l^2 + m^2 + x(1 - x)k_{12}^2\\right)^2}}} \\\\\n&\\quad = \\frac{\\lambda^2}{32\\pi^2}\\int_0^{1}{\\upd{x}\\left(\\log\\left(\\frac{\\Lambda_0^2}{m^2 + x(1 - x)k_{12}^{2}}\\right) - 1\\right)} + \\underbrace{\\mO\\left(\\frac{m}{\\Lambda_0}, \\frac{\\abs{k_{12}}}{\\Lambda_0}\\right)}_{\\text{vanishes as }\\Lambda_0 \\rightarrow \\infty}\n\\end{align*}\nThen the total contribution to the $4$-scalar amplitude is;\n\\begin{align*}\n&\\mathcal{A}(k_i) = \\lambda + \\hbar \\delta \\lambda - \\frac{\\lambda^2 \\hbar}{32 \\pi^2}\\int_0^{1}{\\upd{x}}\\left[ \\log \\frac{\\Lambda_0^2}{m^2 + x(1 - x)k_{12}^2} \\right.\\\\\n&\\qquad \\left. + \\log \\frac{\\Lambda_0^2}{m^2 + x(1 - x)k_{23}^2} + \\log \\frac{\\Lambda_0^2}{m^2 + x(1 - x)k_{13}^2} - 3\\right]  \\\\\n& \\qquad + \\mO(\\hbar^2, m/\\Lambda_0, \\abs{k_i}/\\Lambda_0)\n\\end{align*}\nUsing our earlier choice for $\\delta \\lambda$ this becomes;\n\\begin{align*}\n&\\mathcal{A}(k_i) = \\lambda - \\frac{\\lambda^2 \\hbar}{32\\pi^2} \\int_0^{1}{\\upd{x}}\\left[ \\log\\frac{m^2}{m^2 + x(1 - x)k_{12}^2} + \\log\\frac{m^2}{m^2 + x(1 - x)k_{23}^2}\\right. \\\\\n& \\qquad \\left. + \\log\\frac{m^2}{m^2 + x(1 - x)k_{13}^2}\\right] + \\mO(\\hbar^2)\n\\end{align*}\nAt this order in $\\hbar$, we have $\\lambda = \\lambda_{\\text{eff}}$ so that whilst we have generated infinitely many derivative interactions in $\\Gamma$, however, they are all finite and completely determined by the values of $(m_p, \\lambda_{\\text{eff}})$. Now consider starting from a more general classical action at a scale $\\Lambda_0$;\n\\begin{equation*}\nS_{\\Lambda_0}[\\phi] = \\int{\\upd{^4 x}\\frac{1}{2}(\\del \\phi)^2 + \\frac{m^2}{2}\\phi^2 + V(\\phi)}, \\quad V(\\phi) = \\sum_{k \\geq 2}{g_{2k}\\Lambda_0^{4 - 2k}\\phi^{2k}}\n\\end{equation*}\nAt one-loop we now get new contributions to the coefficient of $\\phi^{2m}$ in $\\Gamma$ coming from the $1$PI e.g. those in \\autoref{fig:quart3}. \n\\begin{mygraphic}{aqft/quart3}{0.8}{The $1$PI diagrams contributing to the coefficient of $\\phi^{2m}$. Each graph has $2m$ external legs in total.}{quart3}\\end{mygraphic}\nNote that the coefficient of $\\phi^{2m}$ is just that coming from the expansion of;\n\\begin{equation*}\n\\frac{1}{2}\\log \\det \\left(-\\del^2 + m^2 + V^{\\prime\\prime}(\\phi)\\right)\n\\end{equation*}\nNow, a loop graph with $e$ propagators contributes an amount proportional to;\n\\begin{equation*}\n\\int^{\\Lambda_0}{\\upd{^4 p }\\prod_{j = 1}^{e}{\\frac{1}{(p + k_j)^2 + m^2}}}\n\\end{equation*}\nfor some $k_j$. As $\\Lambda_0 \\rightarrow \\infty$, this is UV finite unless $e = 1$ ($\\Lambda_0^2$ divergent) or $e = 2$ ($\\log \\Lambda_0$ divergent). Also every time we include a $g_{2k + 2}$ vertex we introduce a power $\\Lambda_0^{2 - 2k}$ which a suppression if $k > 1$. In other words, for six or more particles at the vertex. Hence we only get contributions in the continuum limit to $\\Gamma$ from graphs built solely from a $\\phi^4$ vertex together with a finite correction from the graph with $4$ external legs meeting at a point of a loop $\\propto g_6$. We can this latter contribution in our renormalisation scheme.\n\\subsection{Dimensional Regularisation}\\index{dimensional regularisation}\nThis is qualitatively different to the previous methods of regularisation. It is not a way of regularising the path integral measure, instead we are looking for a way to regularise the asymptotic series that results from the loop integrals. First, make the observation that for any given coupling, it's status as marginal, relevant etc. is dependent on the dimension $d = \\dim \\mM$. As an example, consider the mass correction at one loop in $\\phi^4$ theory. Again we only consider the first diagram in \\autoref{fig:phi4two} which contributes;\n\\begin{equation*}\n-\\frac{\\lambda}{2(2\\pi)^4}\\int{\\frac{\\ud^4 p}{p^2 + m^2}} \\overset{d \\in \\mathbb{N}}{\\longrightarrow} - \\frac{1}{2}\\frac{g(\\mu) \\mu^{4 - d}}{(2\\pi)^d} \\int{\\frac{\\ud^d p}{p^2 + m^2}}\n\\end{equation*}\nwhere we have introduced the dimensionless coupling $g(\\mu) = \\lambda \\mu^{d - 4}$. Now $\\mu$ is just some arbitrary scale (e.g. the energy scale of our experiment). Importantly it is \\emph{not} a cut off, and so does not take values up to infinity. Then;\n\\begin{equation*}\n-\\frac{1}{2}\\frac{g(\\mu)\\mu^{4 - d}}{(2\\pi)^{d}}\\int{\\frac{\\ud^d p}{p^2 + m^2}} = -\\frac{g(\\mu) \\mu^{4 - d}}{2(2\\pi)^{d}}\\text{vol}(\\mS^{d - 1})\\int_0^{\\infty}{\\upd{p}\\frac{p^{d - 1}}{p^2 + m^2}}\n\\end{equation*}\nTo compute the volume (read volume of the manifold not of the $d$-ball), we note that;\n\\begin{equation*}\n\\pi^{d/2} = \\int_{\\RR^{d}}{\\prod_{i = 1}^{d}{e^{-x_i^2}}\\,\\,\\ud x_i} = \\text{vol}(\\mS^{d - 1})\\int_0^{\\infty}{\\upd{r}r^{d - 1}e^{-r^2}} = \\text{vol}(\\mS^{d - 1})\\frac{1}{2}\\Gamma\\left(\\frac{d}{2}\\right)\n\\end{equation*}\nSo we find that whenever $d \\in \\mathbb{N}$;\n\\begin{equation}\n\\text{vol}(\\mS^{d - 1}) = \\frac{2\\pi^{d/2}}{\\Gamma\\left(\\frac{d}{2}\\right)}\n\\end{equation}\nWe now define this expression to be $\\text{vol}(\\mS^{d - 1})$ for $d \\in \\CC$. The rest of the integral is then;\n\\begin{align*}\n\\mu^{4 - d}\\int_0^{\\infty}{\\frac{p^{d - 1}\\ud p}{p^2 + m^2}} &= \\frac{1}{2}\\mu^{d - 4}\\int_0^{\\infty}{\\frac{(p^2)^{(d/2) - 1}\\ud (p^2)}{p^2 + m^2}} \\\\\n&= \\frac{m^2}{2}\\left(\\frac{\\mu}{m}\\right)^{4 - d} \\underbrace{\\int_0^{1}{(1 - u)^{(d/2) - 1}u^{-d/2}\\ud u}}_{\\text{beta function}} \\\\\n&= \\frac{m^2}{2}\\left(\\frac{\\mu}{m}\\right)^{4 - d} \\frac{\\Gamma(d/2) \\Gamma(1 - d/2)}{\\Gamma(1)}\n\\end{align*}\nThus we find that in dimensional regularisation the one loop contribution to $\\Pi(k^2)$ is;\n\\begin{equation*}\n\\Pi(k^2) = - \\frac{g(\\mu)m^2}{2(4\\pi)^{d/2}}\\left(\\frac{\\mu}{m}\\right)^{4 - d} \\Gamma(1 - d/2)\n\\end{equation*}\nWe should analytically continue this to $d = 4$ by setting $d = 4 - \\epsilon$ and using the result;\n\\begin{equation*}\n\\Gamma(\\epsilon) \\sim \\frac{1}{\\epsilon} - \\gamma + \\mO(\\epsilon)\n\\end{equation*}\nwhere $\\gamma$ is the Euler-Mascheroni constant\\index{constant!Euler-Mascheroni}, then we have;\n\\begin{equation*}\n\\Pi_{\\text{\\footnotesize{1-loop}}}(k^2) \\sim \\frac{g(\\mu)m^2}{32\\pi^2} \\left(\\frac{2}{\\epsilon} - \\gamma + \\log\\left(\\frac{4\\pi\\mu^2}{m^2}\\right)\\right) + \\mO(\\epsilon)\n\\end{equation*}\nThe divergence in the $1$-loop $\\Pi(k^2)$ as $\\Lambda_0 \\rightarrow \\infty$ has become the pole $1/\\epsilon$. In particular note that the logarithm is perfectly finite since $\\mu$ is not a cut off.\n\\subsubsection{The $\\bar{\\text{\\textbf{MS}}}$ Renormalisation Scheme}\nWe fix the counterterm $\\delta m^2$ by requiring a finite result in $d = 4$ so we have to remove the $1/\\epsilon$ term. Just doing this is minimal substitution (MS). Often it is convenient to also remove the $\\gamma$ and $4\\pi$ terms. This is modified minimal subtraction. So we choose;\n\\begin{equation*}\n\\delta m^2 = - \\frac{g(\\mu)m^2}{32\\pi^2}\\left(\\frac{2}{\\epsilon} - \\gamma + \\log 4\\pi\\right)\n\\end{equation*}\nin the $\\bar{\\text{MS}}$ scheme. Thus we have;\n\\begin{equation*}\n\\Pi(k^2) = \\frac{g(\\mu)m^2}{32\\pi^2}\\log\\left(\\frac{\\mu^2}{m^2}\\right)\n\\end{equation*}\nwhich is now finite as $d \\rightarrow 4$. For the $\\phi^4$ term, the loop corrections come from the same integrals computed above in the renormalisation of the quartic coupling;\n\\begin{equation*}\n\\frac{g^{2}(\\mu)\\mu^{4 - d}}{2}\\int{\\frac{\\ud^{d}p}{(2\\pi)^{d}}\\frac{1}{p^2 + m^2}\\frac{1}{(p + k_{12})^2 + m^2}}\n\\end{equation*}\nalong with other channels. Again if we are just interested in the pure quartic coupling then we can set $k_{ij} = 0$ and find the contribution;\n\\begin{align*}\n\\frac{3g^{2}(\\mu)\\mu^{4 - d}}{32\\pi^4}\\text{vol}(\\mS^{d - 1})\\int_0^{\\infty}{\\frac{p^{d - 1}\\ud p}{(p^2 + m^2)^2}} &= \\frac{3g^2}{2(4 \\pi)^{d/2}}\\left(\\frac{\\mu}{m}\\right)^{4 - d}\\Gamma(2 - d/2) \\\\\n&\\sim \\frac{3g^2}{32\\pi^2}\\left(\\frac{2}{\\epsilon} - \\gamma + \\log\\frac{4\\pi \\mu^2}{m^2}\\right) + \\mO(\\epsilon) \n\\end{align*}\nThen we choose out counterterm to remove this pole;\n\\begin{equation}\n\\delta g = \\frac{3g^2}{32\\pi^2}\\left(\\frac{2}{\\epsilon} - \\gamma + \\log 4\\pi\\right)\n\\end{equation}\nagain in the $\\bar{\\text{MS}}$ scheme. So we find a $\\phi^{4}$ coupling in the $1$PI effective action of;\n\\begin{equation*}\ng_{\\text{eff}}(\\mu) = g(\\mu) - \\frac{3\\hbar g^{2}(\\mu)}{32\\pi^2}\\log\\left(\\frac{\\mu^2}{m^2}\\right) + \\mO(\\hbar^2)\n\\end{equation*}\nThe scale $\\mu$ was merely a choice of units and we are now in exactly $d = 4$ so $g_{\\text{eff}}$ can't depend on $\\mu$. This is compatible with our result if;\n\\begin{align*}\n\\mu\\frac{\\del g_{\\text{eff}}}{\\del \\mu} &= 0 = \\mu\\frac{\\del}{\\del \\mu}\\left(g(\\mu) - \\frac{3\\hbar g^2(\\mu)}{16\\pi^2}\\log\\left(\\frac{\\mu}{m}\\right) + \\mO(\\hbar^2)\\right) \\\\\n\\Rightarrow \\beta(g) &= \\mu \\frac{\\del g}{\\del \\mu} = \\frac{3\\hbar g^2}{16\\pi^2} + \\mO(\\hbar^2)\n\\end{align*}\ni.e. $g(\\mu)$ is marginally irrelevant. Solving this for the coupling we see that;\n\\begin{equation}\n\\frac{1}{g(\\mu\\pr)} = \\frac{1}{g(\\mu)} + \\frac{3\\hbar}{16\\pi^2}\\log\\left(\\frac{\\mu}{\\mu\\pr}\\right) + \\mO(\\hbar^2)\n\\end{equation}\nNow, if we just solved the original path integral exactly, we would find of course that $\\Gamma(\\phi)$ is independent of $\\mu$. But since we are working perturbatively, it is ambiguous as to whether we should do perturbation theory in $g(\\mu)$ or $g(\\mu\\pr)$. In fact we actually have no choice; there is a scale inherent in $\\phi^4$ theory, $\\mu\\pr = \\Lambda_{\\phi^4}$ where $g(\\mu\\pr)^{-1} = 0$. In other words we find;\n\\begin{equation*}\ng(\\mu) = \\frac{16\\pi^2}{3\\hbar}\\frac{1}{\\log(\\Lambda_{\\phi^4}/\\mu)}\n\\end{equation*}\n\\subsection{One-loop Renormalisation of QED}\\index{QED}\nWe start with the action;\n\\begin{equation}\nS_{\\text{QED}} = \\int{\\upd{^4 x}\\frac{1}{4e^2}F_{\\mu\\nu}F^{\\mu\\nu} + \\bar{\\psi}(\\slashed{D} + m)\\psi}\n\\end{equation}\nwhere $D_\\mu = \\del_\\mu + i A_\\mu$ and $(\\gamma^{\\mu})\\dagg = - \\gamma^{\\mu}$ in the Euclidean signature. THis means that the $\\text{SO}(4)$ generators $S^{\\mu\\nu} = \\tfrac{1}{4}[\\gamma^{\\mu}, \\gamma^{\\nu}]$ are all hermitian and $\\bar{\\psi} = \\psi\\dagg$. We rescale the photon field; $A^{\\text{new}} = A^{\\text{old}}/e$ so that;\n\\begin{equation*}\nS_{\\text{QED}}[A^{\\text{new}}, \\psi] = \\int{\\upd{^4 x}\\frac{1}{4}F^2 + \\bar{\\psi}(\\slashed{\\del} + m)\\psi + ie\\bar{\\psi}\\slashed{A}\\psi}\n\\end{equation*}\nIn momentum space, the Maxwell term becomes;\n\\begin{equation*}\n\\frac{1}{4}\\int{\\upd{^4 x}F_{\\mu\\nu}F^{\\mu\\nu}} = \\frac{1}{2}\\int{\\upd{^4 k}k^2 \\left(\\delta^{\\mu\\nu} - \\frac{k^{\\mu}k^{\\nu}}{k^2}\\right)A_{\\mu}(-k)A_{\\nu}(k)}\n\\end{equation*}\nfrom which we can read off the free photon propagator;\n\\begin{equation*}\n\\Delta^{(0)}_{\\mu\\nu}(k) = \\frac{1}{k^2}\\left(\\delta^{\\mu\\nu} - \\frac{k^{\\mu}k^{\\nu}}{k^2}\\right)\n\\end{equation*}\nIn the Lorenz gauge\\index{gauge!Lorenz}, $\\del^{\\mu}A_\\mu = 0$ which gives the gauge condition $k^{\\mu}\\Delta^{(0)}_{\\mu\\nu}(k) = 0$. This implies that only transverse polarisations propagate.\n\\subsubsection{Vacuum Polarisation}\\index{polarisation!vacuum}\nIn the quantum theory, the exact photon propagator receives corrections as the photon interacts with the electron;\n\\begin{align*}\n\\Delta_{\\mu\\nu}(k) &= \\int{\\upd{^4 x}e^{ik\\cdot x}\\left< A_{\\mu}(x)A_{\\nu}(0) \\right>} \\\\\n&= \\Delta_{\\mu\\nu}^{(0)}(k) + \\Delta^{(0)}_{\\mu \\rho}(k)\\Pi^{\\rho\\sigma}(k)\\Delta^{(0)}_{\\sigma \\nu}(k) + \\cdots\n\\end{align*}\nwhere $\\Pi_{\\rho \\sigma}(k)$ is the sum of all $1$PI diagrams with $2$ external photons. This takes the form;\n\\begin{equation*}\n\\Pi_{\\rho \\sigma} = k^2\\left(\\delta_{\\rho \\sigma} - \\frac{k_\\rho k_\\sigma}{k^2}\\right)\\pi(k^2)\n\\end{equation*}\nfor some function $\\pi(k^2)$. Then the factor in brackets is a projection operator $P\\indices{^{\\rho}_{\\sigma}}$ satisfying $P\\indices{^{\\rho}_{\\kappa}}P\\indices{^{\\kappa}_{\\sigma}} = P\\indices{^{\\rho}_{\\sigma}}$. Then we see that;\n\\begin{equation*}\n\\Delta_{\\mu\\nu}(k) = \\Delta_{\\mu\\nu}^{(0)}(k)\\left(1 + \\pi(k^2) + \\pi^2(k^2) + \\cdots\\right). = \\frac{\\Delta_{\\mu\\nu}^{(0)}(k)}{1 - \\pi(k^2)}\n\\end{equation*}\nJust as in the scalar case where the classical propagator was the inverse of the kinetic term in the effective action, here we have;\n\\begin{equation*}\n\\Gamma_{\\text{eff}}[A] = \\frac{1}{2}\\int{\\upd{^4 k} \\left(1 - \\pi(k^2)\\right)A_\\mu(-k)k^2 \\left(\\delta^{\\mu\\nu} - \\frac{k^{\\mu}k^{\\nu}}{k^2}\\right)A_\\nu(k)}\n\\end{equation*}\nIn particular expanding $\\pi(k^2) = \\pi(0) + \\cdots$ the leading piece gives;\n\\begin{equation*}\n\\Gamma_{\\text{eff}}^{(2)}[A] = \\int{\\upd{^4 x}\\frac{1 - \\pi(0)}{4}F_{\\mu\\nu}F^{\\mu\\nu}}\n\\end{equation*}\nWhich governs the leading order wavefunction renormalisation.\\index{renormalisation!wavefunction} We compute this via dimensional regularisation, and introduce a dimensionless coupling $g^2(\\mu) = e^2 \\mu^{d - 4}$ for some experimental scale $\\mu$. The vertex is then;\n\\begin{equation*}\nig(\\mu)\\mu^{(4 - d)/2}\\int{\\upd{^d x}\\bar{\\psi}\\slashed{A}\\psi}\n\\end{equation*} \nThe leading order correction is then governed by the diagram;\n\\begin{mygraphic}{aqft/vacpol}{0.8}{The leading order correction to the photon propagator.}{vacpol}\\end{mygraphic}\nBefore writing down the correction, we should understand that a loop in a fermion diagram introduces an overall minus sign. This is really a statement of Wick's theorem and the fact that the components of $\\psi$ are Grassman variables. Expanding $\\exp\\left(- S_{\\text{QED}}[A, \\psi]/\\hbar\\right)$ in powers of the vertex we have contributions of the form;\n\\begin{equation*}\n\\left< \\bar{\\psi} \\gamma^{\\mu}\\psi(x_1) \\bar{\\psi} \\cdots \\psi(x) \\bar{\\psi}\\gamma^{\\rho}\\psi(x_n) \\right>\n\\end{equation*}\nJoining up $\\psi \\bar{\\psi}$ contributions we find that the first and last are in the opposite order. To get a propagator we need to bring the $\\psi$ past the $\\bar{\\psi}$ which introduces an extra minus sign. Then we find;\n\\begin{align*}\n\\Pi^{\\rho \\sigma}_{\\text{1-loop}}(k) &= -(-ig)^2 \\mu^{4 - d}\\int{\\frac{\\ud^d p}{(2\\pi)^d}\\tr\\left(\\frac{1}{i\\slashed{p} + m}\\gamma^{\\rho}\\frac{1}{i(\\slashed{p} - \\slashed{k}) + m}\\gamma^{\\sigma}\\right)} \\\\\n&= \\frac{g^2(\\mu)\\mu^{4 - d}}{(2\\pi)^d}\\int{\\upd{^d p}\\frac{\\tr \\left((-i \\slashed{p} + m)\\gamma^{\\rho}(-i \\slashed{p} - i\\slashed{k} + m)\\gamma^{\\sigma}\\right)}{(p^2 + m^2)\\left((p - k)^2 + m^2\\right)}}\n\\end{align*}\nThis integral can be done (apparently) and we find;\n\\begin{equation}\n\\Pi_{\\text{1-loop}}^{\\rho\\sigma}(k^2) = (k^2 \\delta^{\\rho\\sigma} - k^{\\rho}k^{\\sigma})\\pi_{\\text{1-loop}}(k^2)\n\\end{equation}\nwhere;\n\\begin{equation}\n\\pi_{\\text{1-loop}}(k^2) = \\frac{-8 g^{2}(\\mu)\\Gamma(2 - d/2)}{(4\\pi)^{d/2}}\\int_0^{1}{\\upd{x} x(1 - x)\\left(\\frac{\\mu^2}{\\Delta}\\right)^{2 - d/2}}\n\\end{equation}\nwhere $\\Delta = m^2 + k^2 x(1 - x)$. This expression diverges in $d = 4$ as we would expect, so we need to tune using a couterterm;\n\\begin{equation*}\n\\int{\\frac{\\delta Z_3}{4}F_{\\mu\\nu}F^{\\mu\\nu}}\n\\end{equation*}\nWriting $d = 4 - \\epsilon$ we have;\n\\begin{equation*}\n\\pi_{\\text{1-loop}}(k^2) \\sim -\\frac{g^2(\\mu)}{2\\pi^2}\\int_0^{1}{\\upd{x}x(1 - x)\\left(\\frac{2}{\\epsilon} - \\gamma + \\log \\frac{4\\pi \\mu^2}{\\Delta} + \\mO(\\epsilon)\\right)}\n\\end{equation*}\nIn the $\\bar{\\text{MS}}$ scheme then, we take $\\delta Z_3$ to absorb the divergent parts of the above;\n\\begin{equation}\n\\delta Z_3 = -\\frac{g^2(\\mu)}{12\\pi^2}\\left(\\frac{2}{\\epsilon} - \\gamma + \\log 4\\pi\\right)\n\\end{equation}\nSo we find that $\\Pi^{\\rho\\sigma}(k^2) = k^2 P^{\\rho\\sigma}\\pi(k^2)$ with;\n\\begin{equation}\n\\pi(k^2) = \\frac{g^2}{2\\pi^2}\\int{\\upd{x}x(1 - x)\\log\\left(\\frac{m^2 + x(1 - x)k^2}{\\mu^2}\\right)} + \\mO(\\hbar, \\epsilon)\n\\end{equation}\n\\subsubsection{The $\\beta$-function of QED}\nWe have;\n\\begin{align*}\n\\Gamma_{\\text{eff}}[A^{\\text{old}}] &= \\frac{1}{4g_{\\text{eff}}^2}\\int{\\upd{^4 x}F_{\\mu\\nu}F^{\\mu\\nu}} + \\cdots \\\\\n&= \\frac{1 - \\pi(0)}{4g^2(\\mu)}\\int{\\upd{^4 x} F^2 + \\cdots} \\\\\n&= \\frac{1}{4}\\left(\\frac{1}{g^2(\\mu)} - \\frac{\\hbar}{12\\pi^2}\\log\\left(\\frac{m^2}{\\mu^2}\\right) + \\mO(\\hbar^2)\\right)\\int{\\upd{^4 x}F^2}\n\\end{align*}\nSo our vacuum polarisation result also tells us the $\\beta$-function of QED. Since the physically measured coupling $g_{\\text{eff}}(\\mu)$ cannot depend on $\\mu$ we have;\n\\begin{equation*}\n0 = \\mu\\frac{\\del}{\\del \\mu}\\left(\\frac{1}{g^2} - \\frac{\\hbar}{12\\pi^2} \\log\\frac{m^2}{\\mu^2} + \\mO(\\hbar^2)\\right)\n\\end{equation*}\nSo we find that;\n\\begin{align*}\n-\\frac{2}{g^3(\\mu)}\\beta(g) + \\frac{\\hbar}{6\\pi^2} + \\mO(\\hbar^2) &= 0 \\Rightarrow \\beta(g) = \\frac{\\hbar g^3}{12\\pi^2} + \\mO(\\hbar^2)\n\\end{align*}\nThus we find that;\n\\begin{equation}\n\\frac{1}{g^{\\prime 2}(\\mu\\pr)} = \\frac{1}{g^2(\\mu)} + \\frac{\\hbar}{6\\pi^2}\\log\\left(\\frac{\\mu}{\\mu\\pr}\\right)\n\\end{equation}\nFrom experiment we know that at $\\mu \\sim m_e \\sim 511 \\,\\,\\text{keV}$, we have $\\alpha \\sim 1/137$, which gives;\n\\begin{equation*}\ng^2(\\mu) = \\frac{6\\pi^2}{\\hbar} (\\log\\frac{\\Lambda_{\\text{QED}}}{\\mu})^{-1}\n\\end{equation*}\nwhere $\\Lambda_{\\text{QED}} \\sim 10^{236}\\,\\,\\text{GeV}$. So again as in the case of $\\phi^4$, there is no continuum theory of QED, it is only valid up to the scale determined by $\\Lambda_{\\text{QED}}$. This is of no practical consequence as QED ultimately merges with the weak force at an energy scale far below $\\Lambda_{\\text{QED}}$.\n\\newpage\n\\section{Symmetries in QFT}\nSuppose we have a change of variables $\\phi^a \\mapsto \\phi^{\\prime a} = \\phi^a + \\epsilon^{r}f^{a}_r(\\phi, \\del_\\mu \\phi)$, such that the Lagrangian transforms as $\\mL \\mapsto \\mL + \\del^\\mu(K_{\\mu r} \\epsilon^r)$, then the equations of motion will be unaffected and we say that the transformation is symmetry of the classical theory. Noether's theorem further tells us that the current;\n\\begin{equation*}\nJ_{\\mu r} = \\frac{\\delta \\mL}{\\delta(\\del^\\mu \\phi^a)}f_r^a(\\phi, \\del_\\mu \\phi) - K_{\\mu r}\n\\end{equation*}\nis conserved if the equations of motion hold. We need to re-examine this in the quantum theory. We have two options;\n\\begin{itemize}\n\\item Look at general correlation functions\n\\item Look at the quantum effective action\\index{action!quantum effective}\n\\end{itemize}\nWe will begin with the second point of view.\n\\subsection{Symmetries of the Effective Action}\nFormally, under $\\phi^a \\mapsto \\phi^{\\prime a}$ we would expect $\\mD \\phi \\mapsto \\mD \\phi\\pr$ where;\n\\begin{equation*}\n\\mD \\phi\\pr = \\mD \\phi \\det\\left(\\frac{\\delta \\phi^{\\prime a}(x)}{\\delta \\phi^b(y)}\\right)\n\\end{equation*} \nwhere;\n\\begin{equation*}\n\\frac{\\delta \\phi^{\\prime a}(x)}{\\delta \\phi^b(y)} = \\delta\\indices{^{a}_{b}}\\delta(x - y) + \\epsilon^{r}\\frac{\\delta f_r^a(\\phi, \\del \\phi)}{\\delta \\phi^b(y)} + \\mO(\\epsilon^2)\n\\end{equation*}\nSo we find that;\n\\begin{equation*}\n\\det\\left(\\frac{\\delta \\phi^{\\prime a}(x)}{\\delta \\phi^b(y)}\\right) = 1 + \\tr \\epsilon^r \\frac{\\delta f_r^a(\\phi, \\del \\phi)}{\\delta \\phi^b(y)} + \\mO(\\epsilon^2)\n\\end{equation*}\nwhich is a trace over the flavour indices $a, b$ as well as a functional trace over $x, y$. We'll be interested in transformations for which $\\mD \\phi = \\mD \\phi\\pr$. In this case consider the partition function;\n\\begin{equation*}\n\\mZ[\\vec{J}] = \\int{\\mD \\phi\\pr \\,\\,\\exp\\left(-\\frac{1}{\\hbar}\\left(S[\\phi] + \\int{\\upd{^d x}J_a(x)\\phi^{\\prime a}(x)}\\right)\\right)}\n\\end{equation*}\nUsing the fact that we have a symmetry;\n\\begin{align*}\n\\mZ[\\vec{J}] &= \\int{\\mD \\phi \\,\\,\\exp\\left(-\\frac{1}{\\hbar}\\left(S[\\phi] + \\int{\\upd{^d x}J_a(x)\\phi^a(x)} + \\int{\\upd{^d x}J_a \\epsilon^r f^a_r}\\right)\\right)} \\\\\n&= \\int{\\mD \\phi \\,\\, \\exp\\left(- \\frac{1}{\\hbar}\\left(S[\\phi] + \\int{\\upd{^d x}J\\phi}\\right)\\right)} \\\\ \n&\\qquad \\qquad \\qquad \\qquad \\times \\left\\{1 - \\frac{\\epsilon^r}{\\hbar}\\int{\\upd{^d x}J_a f_r^a(\\phi, \\del \\phi)} + \\mO(\\epsilon^2)\\right\\} \\\\\n&= \\mZ[\\vec{J}] - \\frac{\\epsilon^r}{\\hbar}\\mZ[\\vec{J}] \\left< \\int{\\upd{^d x}J_a f^a_r(\\phi, \\del\\phi)} \\right>_{\\vec{J}} + \\mO(\\epsilon^2)\n\\end{align*}\nSo we see that this implies;\n\\begin{equation}\n\\int{\\upd{^d x}J_a(x)\\left< f^a_r(\\phi, \\del \\phi) \\right>_{\\vec{J}}} = 0\n\\end{equation}\nWe want to write this in terms of the quantum effective action, $\\Gamma[\\Phi]$. Recall that $\\Gamma[\\Phi]$ is the Legendre transform of $W[\\vec{J}]$ where $\\vec{J}$ is evaluated at the extremum;\n\\begin{equation*}\nJ_\\phi^a = -\\frac{\\delta \\Gamma[\\Phi]}{\\delta \\Phi^a}\n\\end{equation*}\nsuch that $\\left< \\phi^a \\right>_{\\vec{J}_\\phi} = \\Phi^a$, where $\\Phi^a$ is the field in the $1$PI effective action. At this value, our condition becomes;\n\\begin{equation*}\n\\int{\\upd{^d x}\\frac{\\delta \\Gamma[\\Phi]}{\\delta \\Phi^a} \\left< f_r^a(\\phi, \\del \\phi) \\right>_{\\vec{J}_\\phi}} = 0\n\\end{equation*}\nIn other words, the quantum effective action is invariant under;\n\\begin{equation*}\n\\Phi^a \\mapsto \\Phi^{\\prime a} = \\Phi^a + \\epsilon^r \\left< f^a_r(\\phi, \\del \\phi) \\right>_{\\vec{J}_\\phi}\n\\end{equation*}\nAs a special case (and an important one), suppose that $f$ is actually linear in $\\phi$ i.e.\n\\begin{equation*}\nf^a_r(\\phi, \\del\\phi) = c_r^a(x) + \\int{\\upd{^d x}d_{rb}(x, y)\\phi^b(y)}\n\\end{equation*}\nThen we have the following (note that this \\emph{only} holds in the case that $f$ is linear);\n\\begin{equation}\n\\left< f^a_r(\\phi, \\del \\phi) \\right>_{\\vec{J}_\\phi} = f_r^a\\left(\\left< \\phi \\right>_{\\vec{J}_\\phi}, \\left< \\del \\phi \\right>_{\\vec{J}_\\phi}\\right) = f_r^a(\\Phi, \\del \\Phi)\n\\end{equation}\nThus, in this case, $\\Gamma[\\Phi]$ is invariant under $\\Phi^a \\mapsto \\Phi^a + \\epsilon^r f_r^a(\\Phi, \\del \\Phi)$, and so has th same symmetry as the classical action, $S[\\phi]$. So if we can find a classical action with a symmetry at linear order under which the path integral measure is invariant, then it will be a symmetry of the full quantum theory. As an example consider;\n\\begin{equation*}\nS[\\phi] = \\int{\\upd{^d x}\\frac{1}{2}(\\del\\phi)^2 + \\frac{1}{2}m^2 \\phi^2 + \\lambda \\phi^4}\n\\end{equation*}\nthen $S[\\phi] = S[-\\phi]$. Now, \\emph{provided we regularise} in a way that is compatible with this $\\ZZ_2$ symmetry, we will also have $\\Gamma[\\Phi] = \\Gamma[-\\Phi]$ i.e. we can't generate terms like $\\Phi^3, \\Phi^7$ etc. As another example suppose we have the action;\n\\begin{equation*}\nS[\\phi^a] = \\int{\\upd{^d x}\\frac{1}{2}\\delta_{ab}\\del \\phi^a \\del \\phi^b + \\frac{m^2}{2}\\delta_{ab}\\phi^a \\phi^b + \\frac{\\lambda}{4}(\\phi^a \\phi^b \\delta_{ab})^2}\n\\end{equation*}\nthen this is invariant under $\\text{SO}(n)$ rotations $\\phi^a \\rightarrow \\phi^a + \\omega\\indices{^{a}_{b}}\\phi^b$ so that;\n\\begin{equation*}\n\\frac{\\delta f^a(\\phi, \\del \\phi)}{\\delta \\phi^b(y)} = \\omega\\indices{^{a}_{b}}\\delta(x - y)\n\\end{equation*}\nwhich is field independent. So provided we treat all components of the field the same when we regularise, the effective action will also be $\\text{SO}(n)$ invariant.\n\n\\paraskip\nAs a final example, suppose we have an $\\text{SO}(d)$ transformation of the co-ordinate system $x^{\\mu}\\mapsto L\\indices{^{\\mu}_{\\nu}}x^{\\nu}$ with $L \\in \\text{SO}(d)$. This induces a transformation on the fields;\n\\begin{equation*}\nA_\\mu(x) \\mapsto (L^{-1})\\indices{_{\\mu}^{\\nu}}A_\\nu(L^{-1}x) , \\quad \\psi^\\alpha \\mapsto S\\indices{^{\\alpha}_{\\beta}}(L)\\psi^\\beta(L^{-1}x)\n\\end{equation*}\nwhere $S\\indices{^{\\alpha}_{\\beta}}(L) = \\exp(\\tfrac{i}{4}L_{\\mu\\nu}[\\gamma^\\mu, \\gamma^\\nu])\\indices{^{\\alpha}_{\\beta}}$ are the $\\text{SO}(d)$ generators in the Dirac spinor representation. Then, $S_{\\text{QED}}[A, \\psi]$ is $\\text{SO}(d)$ invariant, and so to will $\\Gamma_{\\text{QED}}[A, \\psi]$ provided we regularise in an $\\text{SO}(d)$ invariant way.\\footnote{This might be by imposing a cut off on the eigenvalues of $-\\Box$, or working with $d \\in \\CC$, but it will \\emph{not} be by working on a lattice $\\Lambda \\subset \\RR^{d}$, which will not respect the full $\\text{SO}$(d) invariance.} In general, there are three possibilities;\n\\begin{enumerate}\n\\item There exists a symmetry compatible regularisation which we go ahead and use. Then the regularised quantum theory will also have this symmetry manifest at every stage.\n\\item There exists a symmetry compatible regularisation which we do not use. In this case the regularised theory and counterterms will not respect the symmetry. However, the symmetry will be restored in the continuum limit.\n\\item There does not exist any symmetry compatible regularisation. The symmetry is then absent in the quantum theory despite being present at the classical level, and is said to be an \\emph{anomaly}\\index{anomaly}. \n\\end{enumerate}\nAs an explicit example of this last point, consider;\n\\begin{equation*}\nS[\\phi] = \\int{\\upd{^4 x}\\frac{1}{2}(\\del \\phi)^2 + \\frac{\\lambda}{4!}\\phi^4}\n\\end{equation*}\nThis is invariant under conformal transformations\\index{conformal transformation}, $\\delta \\mapsto e^{2\\sigma}\\delta$, $\\phi \\mapsto e^{-\\sigma}\\phi$ where $\\sigma \\in \\RR$. Since $\\mC = \\set{\\phi : \\RR^4 \\rightarrow \\RR}$ is a vector space, we could give it a metric;\n\\begin{equation*}\n\\ud s^2_{\\mC} = \\int_{\\RR^4}{\\upd{^4 x}\\abs{\\delta \\phi}^2}\n\\end{equation*}\nand take the path integral measure to be the Riemannian measure associated to this metric. But this measure is \\emph{not} conformally invariant. We thus do not expect our quantum theory to be conformal, and indeed this is confirmed in the beta functions.\n\\subsection{Ward-Takahashi Identities}\\index{Ward-Takahashi identity}\nSymmetries also place constraints on the correlation functions. Suppose $\\mO_i(\\phi)$ vary under a symmetry transformation $\\phi \\mapsto \\phi\\pr$ as $\\mO_i(\\phi) \\mapsto \\mO_i(\\phi\\pr)$ (i.e. they have no spin indices etc.), then;\n\\begin{equation*}\n\\int{\\mD \\phi\\pr\\,\\,e^{-S[\\phi\\pr]/\\hbar}\\mO_1\\left(\\phi\\pr(x_1)\\right)\\cdots\\mO_n\\left(\\phi\\pr(x_n)\\right)} = \\int{\\mD \\phi\\,\\,e^{-S[\\phi]/\\hbar}\\prod_{i = 1}^{n}{\\mO_i\\left(\\phi\\pr(x_i)\\right)}}\n\\end{equation*}\nSo we see that this implies;\n\\begin{equation}\n\\left< \\mO_1\\left(\\phi(x_1)\\right)\\cdots\\mO_n\\left(\\phi(x_n)\\right) \\right> = \\left< \\mO_1\\left(\\phi\\pr(x_1)\\right) \\cdots \\mO_n\\left(\\phi\\pr(x_n)\\right)\\right>\n\\end{equation}\nThis is the (global) Ward-Takahashi identity. As an example consider the action for a complex scalar field;\n\\begin{equation*}\nS[\\phi] = \\int{\\upd{^d x}\\frac{1}{2}\\del^{\\mu} \\bar{\\phi}\\del_\\mu\\phi + V\\left(\\abs{\\phi}^2\\right)}\n\\end{equation*}\nThen this is invariant under $\\phi \\mapsto e^{i\\alpha}\\phi$ and $\\bar{\\phi} \\mapsto e^{-i\\alpha}\\bar{\\phi}$, $\\alpha \\in \\RR$. Then suppose we insert operators of the form $\\mO_i(x) = \\phi^{r_i}(x)\\bar{\\phi}^{s_i}(x)$. The Ward-Takahashi identity gives;\n\\begin{equation*}\n\\left< \\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right> = \\exp\\left(i\\alpha \\sum_{i = 1}^{n}(r_i - s_i)\\right)\\left< \\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right>\n\\end{equation*}\nand so we deduce that the correlator vanishes unless $\\sum{r_i} = \\sum{s_i}$ since the above holds for all $\\alpha \\in \\RR$. This is known as a \\emph{selection rule}\\index{selection rule}.\n\n\\paraskip\nSimilarly, consider spacetime translations $x \\mapsto x\\pr = x - a$ where $a \\in \\RR^{d}$. Then $\\phi\\pr(x) = \\phi(x - a)$ for a scalar field. If this is a symmetry then inserting operators that only depend on $x$ through their dependence on the fields implies that;\n\\begin{equation*}\n\\left< \\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right> = \\left< \\prod_{i = 1}^{n}{\\mO_{i}(x_i - a)} \\right>\n\\end{equation*}\nwhich allows us to deduce that the correlator can only be a function of the differences $\\left(x_i - x_j\\right)$. Suppose further that our theory was $\\text{SO}(d)$ invariant, then the correlators of scalar operators could only depend on the $\\text{SO}(d)$ invariant separations $(x_i - x_j)^2$.\n\\subsection{Current Conservation in QFT}\nSuppose that our transformation $\\phi^a \\mapsto \\phi^a + \\epsilon^r f_r^a(\\phi, \\del \\phi)$ leaves the Lagrangian, $\\mL(\\phi)$, invariant not just the action, and also preserves the path integral measure $\\mD \\phi$. Then we have a local conservation law for constant $\\epsilon$. Just as in Noether's theorem, if we allow $\\epsilon^r \\mapsto \\epsilon^r(x)$, the action can only vary by terms $\\del_\\mu \\epsilon^r(x)$. So our partition function becomes;\n\\begin{equation*}\n\\mZ = \\int{\\mD \\phi\\pr \\,\\, e^{-S[\\phi\\pr]/\\hbar}} = \\int{\\mD \\phi e^{-S[\\phi]/\\hbar}\\left(1 - \\int_{\\mM}{\\upd{^d x}j^\\mu(x)\\del_\\mu \\epsilon^r(x)} + \\mO(\\epsilon^2)\\right)}\n\\end{equation*}\nwhere now $j^{\\mu}(x)$ may contain contributions from the path integral measure as well as just the field transformation. To first order in $\\epsilon^r$ we see that this is simply;\n\\begin{equation*}\n\\int_{\\mM}{\\upd{^d x}\\left< j^{\\mu}_r(x) \\right>\\del_\\mu \\epsilon^r(x)} = 0\n\\end{equation*}\nIntegrating by parts, this simply says that the expectation of $\\left< j^{\\mu}_r(x) \\right>$ is conserved;\\footnote{With the standard set of assumptions that $\\mM$ is compact/there are no boundary terms etc.}\n\\begin{equation}\n\\del_\\mu \\left< j^{\\mu}_r(x) \\right> = 0\n\\end{equation}\nIn the presence of operators, this doesn't hold as is, instead the operators themselves change infinitesimally under the transformation $\\phi \\mapsto \\phi\\pr$, \n\\begin{equation*}\n\\mO_i \\mapsto \\mO_i + \\epsilon^r (\\delta_r \\mO_i)\n\\end{equation*}\nThen carrying out a similar procedure to the one above we find;\n\\begin{multline*}\n\\int{\\mD\\phi\\pr\\,\\,e^{-S[\\phi\\pr]/\\hbar}\\prod_{i = 1}^{n}{\\mO\\pr_i(x_i)}} \\\\ = \\int{\\mD \\phi\\,\\,e^{-S[\\phi]/\\hbar}\\left(1 - \\int_{\\mM}{\\upd{^d x}j^\\mu_r(x)\\del_\\mu \\epsilon^r(x)} + \\mO(\\epsilon)\\right)} \\\\ \\times \\left(\\prod_{i = 1}^{n}{\\mO_i(x_i)} + \\sum_{i = 1}^{n}\\epsilon^r(x_i)(\\delta_r\\mO_i)\\prod_{j \\neq i}{\\mO_j(x_j)}\\right)\n\\end{multline*}\nAfter performing a completely analogous integration by parts and equating the first term with the left hand side, we see that;\n\\begin{align*}\n\\int_{\\mM}{\\upd{^d x}\\epsilon^r(x)\\del_\\mu\\left< j_r^{\\mu}(x)\\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right>} &= -\\sum_{i = 1}^{n}{\\epsilon^r(x_i)\\left< \\left(\\delta_r \\mO_i(x_i)\\right)\\prod_{j \\neq i}{\\mO_j(x_j)} \\right>} \\\\\n&\\hspace{-100pt}= -\\sum_{i = 1}^{n}\\int{\\upd{^d x}\\delta^{(d)}(x - x_i)\\epsilon^r(x)\\left< \\delta_r \\mO_i(x_i)\\prod_{j \\neq i}{\\mO_j(x_j)} \\right>}\n\\end{align*}\nThus we find the local form of the Ward-Takahashi identity;\n\\begin{equation}\n\\del_\\mu\\left< j^\\mu_r(x)\\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right> = -\\sum_{i = 1}^{n}{\\delta^{(d)}(x - x_i)\\left< \\delta_r\\mO_i(x_i)\\prod_{j \\neq i}{\\mO_j(x_j)} \\right>}\n\\end{equation}\nThis generalises current conservation in the classical theory and says that the correlator is conserved except at the operator insertion points, integrating over all of $\\mM$ we find;\n\\begin{equation*}\n0 = \\sum_{i = 1}^{n}{\\left< \\delta_r(x_i)\\prod_{j \\neq i}{\\mO(x_j)} \\right>} = \\delta_r\\left< \\prod_{i = 1}^{n}{\\mO_i(x_i)} \\right>\n\\end{equation*}\nwhich reproduces the global identity for $\\phi \\mapsto \\phi + \\delta \\phi$.\n\\subsection{Ward-Takahashi Identity in QED}\nThe QED action;\n\\begin{equation*}\nS[A, \\psi] = \\int{\\upd{^d x}\\frac{1}{4e^2}F_{\\mu\\nu}F^{\\mu\\nu} + \\bar{\\psi}(\\slashed{D} + m)\\psi}\n\\end{equation*}\nis invariant under the global transformation $\\psi \\mapsto e^{i\\alpha}\\psi$, $\\bar{\\psi} \\mapsto e^{-i\\alpha}\\bar{\\psi}$, $A_\\mu \\mapsto A_\\mu$ (so this is not a gauge transformation), where $\\alpha \\in \\RR$. As in our earlier discussion, this is a symmetry of the quantum theory providing our regularised path integral measure integrates over as many $\\psi$ modes as $\\bar{\\psi}$ modes. Now, promoting $\\alpha \\rightarrow \\alpha(x)$ we generate a Noether current $j^{\\mu} = i \\bar{\\psi}\\gamma^{\\mu}\\psi$, assuming that the path integral measure stays invariant. For infinitesimal $\\alpha$ we have;\n\\begin{equation*}\n\\delta \\psi = i \\alpha \\psi, \\qquad \\delta \\bar{\\psi} = -i \\alpha \\bar{\\psi}\n\\end{equation*}\nso that the local Ward-Takahashi identity for $\\left< \\psi(x_1)\\bar{\\psi}(x_2) \\right>$ is;\n\\begin{multline*}\n\\del_\\mu\\left< j^{\\mu}(x)\\psi(x_1)\\bar{\\psi}(x_2) \\right> \\\\ = -i\\delta^{(4)}(x - x_1)\\left< \\psi(x_1)\\bar{\\psi}(x_2) \\right> + \\delta^{(4)}(x - x_2)\\left< \\psi(x_1)\\bar{\\psi}(x_2) \\right>\n\\end{multline*}\nIn momentum space we see that;\n\\begin{align*}\n&\\int{\\ud^4 x_1\\upd{^4 x_2}e^{ik_1 \\cdot x_1}e^{-ik_2\\cdot x_2}\\left< \\psi(x_1)\\bar{\\psi}(x_2) \\right>} \\\\\n&\\hspace{50pt}= \\int{\\ud^4 x_1 \\upd{^4 x_2} e^{ik_1\\cdot x_1}e^{-ik_2\\cdot x_2}\\left< \\psi(x_1 - x_2)\\bar{\\psi}(0) \\right>} \\\\\n&\\hspace{50pt}= (2\\pi)^4 \\delta^{(4)}(k_1 - k_2)S(k_1)\n\\end{align*}\nwhere $S(k)$ is the exact electron propagator, so as before we have;\n\\begin{align*}\nS(k) &= \\frac{1}{i\\slashed{k} + m} + \\frac{1}{i\\slashed{k} + m}\\Sigma(\\slashed{k}) \\frac{1}{i\\slashed{k} + m} + \\cdots \\\\\n&= \\frac{1}{i\\slashed{k} + m - \\Sigma(\\slashed{k})}\n\\end{align*}\nwhere $\\Sigma(\\slashed{k})$ is the electron self-energy. We can also define the exact electromagnetic vertex $\\Gamma_\\mu(k_1, k_2)$ as follows;\n\\begin{align*}\n&\\int{\\ud^4 x\\ud^4 x_1 \\upd{^4 x_2}e^{ip\\cdot x}e^{ik_1\\cdot x_1}e^{-ik_2\\cdot x_2}\\left< j_\\mu(x)\\psi(x_1)\\bar{\\psi}(x_2) \\right>} \\\\\n&\\qquad= \\int{\\ud^4 x\\ud^4 x_1 \\upd{^4 x_2}e^{ip\\cdot(x - x_2)}e^{ik_1\\cdot(x_1 - x_2)}e^{-i(p + k_1 - k_2)\\cdot x_2}} \\\\\n&\\qquad \\qquad \\times \\left< j_\\mu(x - x_2) \\psi(x_1 - x_2) \\bar{\\psi}(0)\\right> \\\\\n&\\qquad = (2\\pi)^4 \\delta^{(4)}(p + k_1 - k_2)S(k_1) \\Gamma_\\mu(k_1, k_2)S(k_2)\n\\end{align*}\nTo motivate this last line, note that $j^{\\mu} = i\\bar{\\psi}\\gamma^{\\mu}\\bar{\\psi}(x)$ so that in the correlator, $\\left< j_\\mu(x - x_2) \\psi(x_1 - x_2) \\bar{\\psi}(0)\\right>$ we have the term;\n\\begin{mygraphic}{aqft/emvertex}{0.7}{Illustration of the corrections to the exact EM vertex $\\Gamma_\\mu(k_1, k_2)$ which cannot be seen as corrections to the propagator.}{emvertex}\\end{mygraphic}\nSo we see that to leading order $\\Gamma_\\mu = \\gamma_\\mu + \\text{quantum corrections}$, at next leading order, we have the $1$PI part of the exact vertex that look like;\n\\begin{mygraphic}{aqft/emvertex2}{0.5}{$1$PI corrections to the exact vertex.}{emvertex2}\\end{mygraphic}\nIn momentum space then, the Ward-Takahashi identity becomes;\n\\begin{align*}\n(k_1 - k_2)_{\\mu}S(k_1)\\Gamma^{\\mu}(k_1, k_2)S(k_2) &= i S(k_1) - iS(k_2) \\\\\n\\Rightarrow (k_1 - k_2)_\\mu \\Gamma^{\\mu}(k_1, k_2) &= iS^{-1}(k_2) - iS^{-1}(k_1)\n\\end{align*}\nWe can differentiate this with respect to $k_1$ and set $k_1 = k_2 = k$, so that;\n\\begin{align*}\n\\Gamma_\\mu(k_1, k_2) &= -i\\frac{\\del}{\\del k^{\\mu}}S^{-1}(k) = -i\\frac{\\del}{\\del k^{\\mu}}\\left(i \\slashed{k} + m + \\Sigma(\\slashed{k})\\right) \\\\\n\\Rightarrow \\Gamma_{\\mu}(k, k) &= \\gamma^{\\mu} - i\\frac{\\del}{\\del k^{\\mu}}\\Sigma(\\slashed{k})\n\\end{align*}\nThis is important in the sense that it shows that the \\emph{whole} covariant derivative gets renormalised as one bit, not the kinetic terms and the vertex separately. \n\\newpage\n\\section{Yang-Mills Theory}\\index{Yang-Mills theory}\nThe Yang-Mills action is given by;\n\\begin{equation}\nS[A] = \\int{\\upd{^d x}\\frac{1}{2g^2}\\tr(F_{\\mu\\nu}F^{\\mu\\nu})} = \\frac{1}{4g^2}\\int{\\upd{^d x}(F_{\\mu\\nu})^{a}(F^{\\mu\\nu})^a}\n\\end{equation}\nwhere $F_{\\mu\\nu} = (F_{\\mu\\nu})^{a} t_a$ in a basis $\\set{t_a} \\in \\alge$, the Lie algebra of the gauge group $\\group$. We also have the normalisation $[t_a, t_b] = \\tfrac{1}{2}\\delta_{ab}$. Then the curvature\\index{curvature}/field strength tensor\\index{tensor!field strength} is;\n\\begin{align*}\n(F_{\\mu\\nu})^{a} &= \\del_\\mu A_\\nu^a - \\del_\\nu A_\\mu^a + i[A_\\mu, A_\\nu]^a \\\\\n&= \\del_\\mu A_\\nu^a - \\del_\\nu A_\\mu^a + \\frac{1}{2}if\\indices{^{a}_{bc}}A^b_{[\\mu}A^c_{\\nu]}\n\\end{align*}\nwhere the $f\\indices{^{a}_{bc}}$ are the structure constants of the Lie algebra, $\\alge$. For a non-Abelian gauge group $\\group$, the Yang-Mills equation that arise from varying the gauge field in the action are;\n\\begin{equation}\n(D^\\mu F_{\\mu\\nu})^a = 0, \\qquad D_{[\\mu}(F_{\\nu\\alpha]})^a = 0\n\\end{equation}\nwhere;\n\\begin{equation}\nD^\\mu F_{\\mu \\nu} = \\del^\\mu F_{\\mu\\nu} + [A^\\mu, F_{\\mu\\nu}]\n\\end{equation}\nwhere the form of the last term arises since the field strength tensor transforms in the adjoint representation. Note that these are non-linear PDEs so we do not have a superposition of solutions. Pauli first noticed that gauge invariance forbids a term of the form;\n\\begin{equation*}\n\\int{\\upd{^d x}m^2 A_\\mu A^\\mu}\n\\end{equation*}\nin the action. Hence we can deduce that the gauge field $A^\\mu$ is massless and should be responsible for a long range force. Skipping forward somewhat presciently, we will find the discrepancy in this long range interaction is due to the mass-gap in Yang-Mills. At low energies, Yang-Mills is inherently strongly coupled, and perturbation theory of the classical action is a poor guide to the physics\\footnote{$g^2$ is marginally relevant in $d = 4$}. This aside, the bonus is that YM is \\emph{asymptotically free}\\index{asymptotic freedom} - it approaches a theory of $\\dim \\alge$ free gluons\\index{gluons} in the UV regime.\n\\subsection{The Yang-Mills Path Integral}\nNaively we might try to define the path integral as;\n\\begin{equation*}\n\\mZ_{YM} \\coloneqq \\int_{\\mathcal{A}}{\\mD A\\,\\,e^{-S_{YM}[A]}}\n\\end{equation*}\nwhere $\\mathcal{A}$ is some sort of  ``space of all connections''. Now, given any two connections, $\\nabla, \\nabla\\pr$ where $\\nabla = d + A$, the object $\\tau \\nabla + (1- \\tau)\\nabla\\pr$ is also a connection $\\forall \\,\\, \\tau \\in [0,1]$. In other words, we can continuously and smoothly connect all points in $\\mathcal{A}$. Thus $\\mathcal{A}$ is connected (and affine\\index{affine}) with a metric;\n\\begin{equation}\n\\ud s^2_{\\mathcal{A}} = \\int{\\upd{^d x}\\tr(\\delta A_\\mu \\delta A^\\mu)}\n\\end{equation}\nwhich is a flat metric on the space. However, things are not quite so simple. Note that the action is invariant under gauge transformation;\n\\begin{equation*}\nA \\mapsto A^g = g^{-1}Ag + g^{-1}\\del g, \\quad g : \\RR^d \\rightarrow \\alge\n\\end{equation*}\nNow, the difference of two connections transforms in the adjoint representation, the trace structure of $\\ud s^2_{\\mathcal{A}}$ ensures it is also gauge invariant. Thus, so is the infinite dimensional Riemannian measure built from $\\ud s^2_{\\mathcal{A}}$, leading to a huge redundancy in our description. This ensures that $\\mZ_{YM}$ will diverge; we will have a factor $\\text{vol}(\\group)$ for each $x \\in \\mM$. We need to remove this redundancy.\n\\subsection{Ghosts}\\index{ghost}\nTo understand what is going on, consider the zero dimensional quantum field theory;\n\\begin{equation*}\n\\mZ = \\int_{\\RR^2}{\\ud x \\upd{y}e^{-S[x,y]/\\hbar}}\n\\end{equation*}\nwhere $S$ is rotationally invariant. Changing variables $\\ud x \\ud y \\mapsto r \\ud r \\ud \\theta$, we see that;\n\\begin{equation*}\n\\mZ = (2\\pi)\\int_0^{\\infty}{\\ud r \\cdot r\\,\\,3^{-S(r)/\\hbar}}\n\\end{equation*}\nThe key idea here is that the measure has changed, we now have a new non-trivial measure on the space $\\RR^2 - \\set{0}/\\Uni{1}$. Also note that $(2\\pi) = \\text{vol}(\\Uni{1})$. Breaking this down; naively we thought that we had two fields, but we really only have one on the space of gauge-fixed fields, $\\RR^2 - \\set{0}/\\Uni{1}$, the half-line. In Yang-Mills, we would like to do something similar and integrate over the set of gauge fixed connections $\\mathcal{A}/\\group$ with some transformed measure $\\ud \\mu$. Coming back to our $d = 0$ theory, suppose $f(x) = 0$ is some curve $\\mC \\subset \\RR^2$ which intersects each orbit of the gauge group exactly once.\n\\begin{mygraphic}{aqft/f(x)}{0.5}{The curve, $\\mC$, intersects the gauge orbits of the rotation group only once.}{f(x)}\\end{mygraphic}\nAnother way of stating this requirement is that given $\\vec{x} \\in \\RR^2$ there exists a unique $R \\in \\text{SO}(2)$ such that $f(R\\vec{x}) = 0$. This implies $f(R\\vec{x}) = f(\\vec{x}) = 0$ if and only if $R = \\text{id} \\in \\text{SO}(2)$. We want to rewrite the action to encode the fact we only want one representative from each gauge orbit. First, let's try;\n\\begin{equation*}\n\\int_{\\RR^2}{\\ud x \\upd{y} \\delta\\left(f(\\vec{x})\\right) e^{-S[x, y]/\\hbar}}\n\\end{equation*}\nBut this depends on not just $\\RR^2 - \\set{0}/\\Uni{1}$, but also the specific embedding of $\\mC$ via $f$. We can see this by noting that if we change $f \\mapsto cf$, then $\\delta(f) \\mapsto \\abs{c}^{-1}\\delta(f)$. So the value of the integral will change. Instead then we let;\n\\begin{equation*}\n\\Delta_f = \\left.\\frac{\\del}{\\del \\theta}f\\left(R(\\theta)\\vec{x}\\right)\\right|_{\\theta = 0}\n\\end{equation*}\nand consider the modified integral;\n\\begin{equation*}\n\\int_{\\RR^2}{\\ud x \\upd{y}\\abs{\\Delta_f}\\delta\\left(f(\\vec{x})\\right)e^{-S[x, y]/\\hbar}}\n\\end{equation*}\nThis is now independent of the choice of $f$. Again, we note that it is clearly invariant under local rescaling $f(\\vec{x}) \\mapsto c(r)f(\\vec{x})$ where $c(r) > 0$. It is also independent of the choice of curve $\\mC$. Suppose we have two such curves $\\mC_1, \\mC_2$ defined by $f_j(\\vec{x}) = 0$ for $j = 1,2$. Then given $\\vec{x} \\in \\mC_1$ there exists a unique $R(r)$ such that $f_2\\left(R(r)\\vec{x}\\right) = f_1(\\vec{x}) = 0$. Now, suppose $\\mC$ is just the $x$-axis, $y = 0$, so that $f(x, y) = y$.\\footnote{Note that this intersects the gauge orbits \\emph{twice}, this will become explicit later.} Then;\n\\begin{equation*}\nf\\left(R(\\theta)\\vec{x}\\right) = y\\cos\\theta - x\\sin \\theta \\Rightarrow \\Delta_f = -x\n\\end{equation*}\nSo our integral becomes;\n\\begin{align*}\n\\int_{\\RR^2}{\\ud x \\upd{y}\\abs{x}\\delta(y) e^{-S[x, y]/\\hbar}} &= \\int_{-\\infty}^{\\infty}{\\upd{x}\\abs{x}e^{-S[x,0]/\\hbar}} \\\\\n&= 2\\int_0^{\\infty}{r\\upd{r}e^{-S[r]/\\hbar}}\n\\end{align*}\nHere we see that the $2$ arises explicitly due to the fact that the $x$-axis intersects the gauge orbits twice. In YM theory we take $f(\\vec{x}) \\mapsto f[A]$ as the gauge fixing condition. This itself cannot be gauge invariant, it literally fixes the gauge, so we include a measure factor;\n\\begin{equation}\n\\Delta_f = \\left.\\frac{\\delta f[g^{-1}Ag + g^{-1}\\del g]}{\\delta g}\\right|_{g = \\text{id}}\n\\end{equation}\nThis is known as the \\emph{Fade'ev-Popov determinant}.\\index{Fade'ev-Popov determinant} The fact that many apparent choices of gauge slice still lead to a finite overcounting is known as the Gribov ambiguity. But this won't matter in perturbation theory around a general classical Yang-Mills solution. Inserting these factors, we have;\n\\begin{equation}\n\\int_{\\mathcal{A}/\\group}{\\mD \\mu \\,\\, \\exp(-S_{YM}[A]/\\hbar)} = \\int_{\\mathcal{A}}{\\mD A \\,\\, \\delta[f] \\abs{\\Delta_f}e^{-S_{YM}[A]/\\hbar} }\n\\end{equation}\nNote again that $f[A]$ is \\emph{not} gauge invariant. Now we would like to rewrite the $\\delta[f]\\abs{\\Delta_f}$ temrs in a way amenable to Feynman diagrams. Let $c^a$ and $\\bar{c}^a$ be fermionic scalars on $\\mM$ taking values in $\\alge$. Then;\n\\begin{equation}\n\\Delta_f = \\int{\\mD c \\mD \\bar{c} \\exp\\left(-S_{gh}[c, \\bar{c}, \\nabla]/\\hbar\\right)}\n\\end{equation}\nwhere we have defined the \\emph{ghost action}\\index{ghost action}\\index{ghost}\\index{anti-ghost};\n\\begin{equation}\nS_{gh}[c, \\bar{c}, \\nabla] = \\int_{\\mM \\times \\mM}{\\ud^d x \\upd{^d y}\\bar{c}^a (x) \\frac{\\delta f^a[A(x)]}{\\delta \\lambda^b(y)}c^b(y)}\n\\end{equation}\nWe can also write;\\footnote{We can think of this somewhat like an infinite dimensional Fourier transform, where our momentum is the Nakanishi-Lautrup\\index{Nakanishi-Lautrup field}, $h$}\n\\begin{equation}\n\\delta[f] = \\int{\\mD h \\,\\, \\exp\\left(-S_{gf}[h, A]/\\hbar \\right)}\n\\end{equation}\nwhere;\n\\begin{equation}\nS_{gf}[h, A] = i\\int{\\upd{^d x}h^a(x)f^a[A(x)]}\n\\end{equation}\nis the \\emph{gauge-fixing action}\\index{gauge-fixing action}, and $h^a$ is the Nakanishi-Lautrup field; a bosonic scalar taking values in $\\mL(\\group)$. Then we have;\n\\begin{equation*}\n\\int_{\\mathcal{A}/\\group}{\\mD\\mu\\,\\,e^{-S_{YM}[A]/\\hbar}} = \\int{\\mD A \\mD c \\mD \\bar{c} \\mD h \\,\\, e^{-(S_{YM}[A] + S_{gf}[h, A] + S_{gh}[c, \\bar{c}, A])/\\hbar}}\n\\end{equation*} \nTo illustrate this, we turn to a concrete example, with $f^a = \\del^\\mu A_\\mu^a$, so that;\n\\begin{equation*}\n\\Delta_f = \\frac{\\delta\\left(\\del^\\mu(A_\\mu^a + \\del_\\mu \\lambda^a + [A, \\lambda]^a)\\right)}{\\delta \\lambda^b(y)} = \\delta\\indices{^{a}_{b}}\\del^\\mu \\nabla_\\mu \\delta^{(d)}(x - y)\n\\end{equation*}\nThen we find that the ghost action is;\n\\begin{align*}\nS_{gh} &= \\int{\\ud^d x \\upd{^d y}\\bar{c}^a(x)\\left(\\del^\\mu \\nabla_\\mu \\delta\\indices{^{a}_{b}}\\delta^{(d)}(x - y)\\right)c^b(y)} \\\\ \n&= \\int{\\upd{^d x}\\bar{c}^a(x)\\del^\\mu(\\nabla_\\mu c^a)(x)} \\\\\n&= -\\int_{\\mM}{\\upd{^d x}(\\del^\\mu \\bar{c}^a)(\\nabla_\\mu c^a)}\n\\end{align*}\nLikewise we find that the gauge fixing action is;\n\\begin{equation*}\nS_{gf}[h, A] = \\int{\\upd{^d x}i h^a(x)\\del^\\mu A_\\mu^a}\n\\end{equation*}\n\\subsection{BRST Transformations}\\index{BRST transformation}\nWe observe that the gauge fixed action has two strange properties;\n\\begin{enumerate}\n\\item It is not gauge-invariant, so we have to work harder to be sure that it doesn't generate other non-gauge invariant terms (e.g. a mass term $\\tr(A^a_\\mu A^{\\mu a})$) in the quantum effective action, $\\Gamma[A]$.\n\\item From the point of view of canonical quantisation\\index{canonical quantisation} we would like to consider a Hilbert space ``$L^2\\left(\\mathcal{A}[N]\\right)$'' for some boundary $N$. Then $\\mathcal{A}[N]$ is the space of gauge fields on $N$. But we have introduced new fields; the ghosts and the NL field, so this doesn't seem to be included in the Hilbert space. \n\\end{enumerate}\nThe resolution of these issues is to appeal to a new symmetry, related to BRST transformations;\n\\begin{equation}\n\\delta A_\\mu = \\epsilon \\nabla_\\mu c, \\quad \\delta c = -\\frac{\\epsilon}{2}[c, c], \\quad \\delta \\bar{c} = i\\epsilon h, \\quad \\delta h = 0\n\\end{equation}\nwhere $\\epsilon$ is a constant Grassman parameter. Also note that $[c, c] = -f\\indices{^{a}_{bc}}c^b c^c t_a$ is symmetric because the $c^a$ are Grassman. Now for some $\\psi^i \\in \\set{A, c, \\bar{c}, h}$ we will write this transformation as;\n\\begin{equation*}\n\\delta \\psi^i = \\epsilon (Q\\psi^i)\n\\end{equation*}\nso that for example $\\delta \\psi^i$ and $Q \\psi^i$ have opposite statistics. Now, the BRST transformations form an Abelian group;\n$[\\delta_1, \\delta_2]\\psi^i = 0$\nwhere $\\delta_i$ is the BRST transformations with parameter $\\epsilon_i$. This is equivalent to the statement that $Q$ is nilpotent\\index{nilpotent}; $Q^2 = 0$. We show this for each field in turn;\n\\begin{enumerate}\n\\item We see immediately that $Q^2 h = 0$ since $Qh = 0$\n\\item Also $Q^2 \\bar{c} \\propto Qh = 0$\n\\item Less trivially we find that;\n\\begin{align*}\nQ^2 A_\\mu &= Q\\left(\\nabla_\\mu c\\right) = \\left[(Q A_\\mu), c\\right] + \\nabla_\\mu\\left(Q c\\right) \\\\\n&= \\left[(\\nabla_\\mu c), c\\right] - \\frac{1}{2}\\nabla_\\mu\\left([c,c]\\right) \\\\\n&= [\\nabla_\\mu c, c] - [\\nabla_\\mu c, c] = 0\n\\end{align*}\n\\item Finally we have;\n\\begin{equation*}\nQ^2 c = -\\frac{1}{2}Q[c,c] = \\frac{1}{2}\\left[[c,c],c\\right]  = 0\n\\end{equation*}\nby the Jacobi identity.\n\\end{enumerate}\nSo we see that indeed $Q^2 = 0$ acting on any singlet $\\psi^i \\in \\set{A, c, \\bar{c}, h}$. For a general operator, we have;\n\\begin{align*}\nQ^2\\left(\\mO(\\psi^i)\\right) &= Q\\left[(Q\\psi^i)\\frac{\\delta \\mO}{\\delta \\psi^i}\\right] \\\\\n&= Q^2( \\psi^i )\\frac{\\delta \\mO}{\\delta \\psi^i} \\pm (Q\\psi^i)(Q\\psi^j)\\frac{\\delta^2 \\mO}{\\delta \\psi^i \\delta \\psi^j} \\\\\n&= \\pm (Q\\psi^i)(Q\\psi^j)\\frac{\\delta^2 \\mO}{\\delta \\psi^i \\delta \\psi^j}\n\\end{align*}\nAs we argued earlier, $Q\\psi^j$ has the opposite statistics to $\\psi^j$ so this actually vanishes by antisymmetry. This observation will let us see why the full action is invariant under BRST transformations. Firstly note that when acting on a function of the gauge field $A$, BRST is just a gauge transformation with parameter $\\lambda = \\epsilon c$. For the other terms note that;\n\\begin{align*}\nQ\\int_{\\mM}{\\upd{^d x}\\bar{c}^a f^a[A]} &= \\int{\\upd{^d x}ih^a f^a[A] - \\bar{c}^a \\frac{\\delta f^a[A]}{\\delta \\lambda^b}c^b} \\\\\n&= S_{gf} + S_{gh}\n\\end{align*}\nwhere we have introduced the minus sign bringing $Q$ through $\\bar{c}^a$. So we deduce that;\n\\begin{equation*}\nS_{gh} + S_{gf} = Q(\\cdots) \\Rightarrow Q\\left(S_{gh} + S_{gf}\\right) = 0\n\\end{equation*}\n\\subsubsection{Ward-Takahashi Identity for BRST}\nThe $\\epsilon$ are constant parameters so we can derive a global Ward identity;\n\\begin{equation}\n\\sum_{i}{\\left< \\delta \\mO_i \\prod_{j \\neq i}{\\mO_j} \\right>} = 0\n\\end{equation}\nfor any operators $\\mO_i$. In particular, if all but one operator is BRST invariant, we have;\n\\begin{equation}\n\\left< Q\\mO \\prod_{j}\\mO_j^{\\text{inv}} \\right> = 0\n\\end{equation}\nSo that the correlator of BRST closed operators ($Q\\mO = 0$) with BRST-exact operators (in the image of $Q$) vanishes. We can use this to see that the correlation function of BRST invariant operators are independent of the gauge fixing functional $f^a[A]$. Let $S_1$ and $S_2$ be actions built from $f_1[A]$ and $f_2[A]$ respectively. The we have;\n\\begin{equation*}\nS_1 - S_2 = Q\\left(\\int{\\upd{^d x}\\bar{c}^a (f_1^a - f_2^a)}\\right)\n\\end{equation*}\nThus, suppose $\\mO_i$ are all BRST invariant operators;\n\\begin{align*}\n\\left< \\prod_{i}\\mO_{i} \\right>_1 &= \\int{\\mD A \\cdots e^{-S_1[A, c, \\bar{c}, h]/\\hbar}\\prod_{i}\\mO_i} \\\\\n&= \\int{\\mD A \\cdots \\exp\\left(-S_2 + Q\\underbrace{\\int{\\upd{^d x}\\bar{c}(f_1 - f_2)}}_{V_{12}}\\right)\\prod_{i}\\mO_i} \\\\\n&= \\int{\\mD A \\cdots \\exp\\left(-S_2[A, c, \\bar{c}, h]/\\hbar\\right)\\left(1 + QR_{12}\\right)\\prod_{i}\\mO_i}\n\\end{align*}\nwhere;\n\\begin{equation*}\nR_{12} = -\\frac{V_{12}}{\\hbar} + \\frac{1}{2\\hbar^2}V_{12}Q V_{12} + \\cdots\n\\end{equation*}\nBut now we make the observation that $QR_{12}$ is a BRST exact operator, so $\\left< QR_{12}\\prod \\mO_i \\right> = 0$ from the Ward identity above. Thus we deduce that;\n\\begin{equation*}\n\\left< \\prod_{i}\\mO_i \\right>_1 = \\int{\\mD A \\cdots \\exp\\left(-S_2\\right)\\prod_i{\\mO_i}} = \\left< \\prod_{i}{\\mO_{i}} \\right>_2\n\\end{equation*}\n\\subsection{BRST Cohomology}\\index{BRST Cohomology}\nFrom the point of view of canonical quantisation, the ghosts have given us a larger space of fields. Usually varying $S_{YM}[\\nabla]$ on a manifold with boundary gives a boundary term;\n\\begin{equation*}\n\\Theta = \\frac{1}{g^2_{YM}}\\int{\\upd{^{d - 1} x}\\sqrt{g}\\tr\\left(n^\\mu F_{\\mu\\nu}\\delta A^\\nu\\right)}\n\\end{equation*}\nwhich is a \\emph{symplectic potential} on the space of solutions to the YM equations.\\footnotemark For YM, if $\\del \\mM$ is a constant time slice, we have;\n\\footnotetext{\nIn analogy, consider;\n\\begin{equation*}\nS = \\int{\\upd{t}\\frac{1}{2}m\\dot{x}^2 + V(x)} \\Rightarrow \\Theta = m\\dot{x}\\delta x = p\\delta x\n\\end{equation*}\n}\n\\begin{equation*}\n\\Theta = \\frac{1}{g^2_{YM}}\\int_{\\RR^{d - 1}}{\\upd{^{d - 1} x}\\tr\\left(F_{0i}\\delta A^i\\right)} = \\frac{1}{g^2_{YM}}\\int{\\upd{^{d - 1} x}\\tr\\left(E_i \\delta A^i\\right)}\n\\end{equation*}\nSo we see that the ``chromo''-electric field is the momentum conjugate to the spatial components of the gauge field. Under canonical quantisation, we will have commutation relations;\n\\begin{equation*}\n[A_i^a(\\vec{x}), E_j^b(\\vec{y})] = i\\delta_{ij}\\delta^{ab}\\delta^{(d - 1)}(\\vec{x} - \\vec{y})g_{YM}^2\n\\end{equation*}\nAgain, in analogy with the Abelian case, we can represent;\n\\begin{equation*}\nE^a(\\vec{x}) \\sim -ig^2_{YM}\\frac{\\delta}{\\delta A^a(\\vec{x})}\n\\end{equation*}\nwhich gives the Hamiltonian;\n\\begin{multline}\nH = \\frac{1}{g^2_{YM}}\\int{\\upd{^{d - 1}x}\\tr\\left( -g_{YM}^2\\frac{\\delta^2}{\\delta A(\\vec{x})^2} + \\left(\\del_i A_j - \\del_j A_i + [A_i, A_j]\\right)^2\\right)} \\\\ \\equiv \\frac{1}{g^2_{YM}}\\int{\\upd{^{d - 1}x}\\tr\\left(\\vec{E}^2 + \\vec{B}^2\\right)}\n\\end{multline}\nThe ghosts modify this however. To see equivalence we work in the \\emph{axial gauge}\\index{axial gauge}; $n^\\mu A_\\mu = 0$. Then the ghost and gauge-fixing actions are;\n\\begin{align*}\nS_{gh} + S_{gf} &= Q\\left(\\int_{\\mM}{\\upd{^d x}\\tr(\\bar{c}n^{\\mu}A_\\mu)}\\right) \\\\\n&= i\\int_{\\mM}{\\upd{^d x}\\tr(h n^\\mu A_\\mu)} - \\int_{\\mM}{\\upd{^d x}\\tr(\\bar{c}n^{\\mu}\\nabla_\\mu c)}\n\\end{align*}\nWe see that integrating out $h$ sets $n^{\\mu}A_\\mu = 0$ which ensures that the gauge fields and ghosts decouple since $n^{\\mu}\\nabla_\\mu = n^{\\mu}\\del_\\mu$, so that;\n\\begin{equation*}\nS_{gh} = -\\int{\\upd{^d x}\\tr(\\bar{c}n^\\mu \\del_\\mu c)}\n\\end{equation*}\nNow we are free to vary $S_{YM} + S_{gh}$ on a manifold with boundary which gives;\n\\begin{equation}\n\\Theta = \\frac{1}{g^2_{YM}}\\int_{\\del \\mM}{\\upd{^{d - 1}x}\\tr(n^\\mu F_{\\mu\\nu}\\delta A^{\\nu})} - \\int{\\upd{^{d - 1}x}\\tr(\\bar{c} \\delta c)}\n\\end{equation}\nUnder canonical quantisation then, we find the relations;\\footnote{We see that the anti-ghost is like the momentum for the ghost.}\n\\begin{align*}\n[A_i^a(\\vec{x}), E_j^{b}(\\vec{y})] &= ig_{YM}^2\\delta_{ij}\\delta^{ab}\\delta^{(d - 1)}(\\vec{x} - \\vec{y}) \\\\\n\\set{c^a(\\vec{x}), \\bar{c}^{b}(\\vec{y})} &= i\\delta^{ab}\\delta^{(d - 1)}(\\vec{x} - \\vec{y})\n\\end{align*}\nThis means that the wavefunctions are $\\Psi[A_i, c]$, they do not depend on the anti-ghosts in the position representation. The part of this that is independent of $c$ as well as gauge invariant, is the same as the space of states that we had before. Originally, we didn't have any ghosts, we were working directly on the space of gauge fields modulo gauge transformations. The space would have been gauge invariant.  But because this is the part independent of the ghost, the statement that this is gauge invariant is just the statement that it is BRST invariant, since BRST transformations act just like gauge transformations on the gauge field $A_\\mu$. So;\n\\begin{equation*}\n\\hamilt_{\\text{phys}} = H_Q^0 = \\left.\\text{ker}(Q)/\\text{im}(Q)\\right|_{c = 0}\n\\end{equation*}\nwhere $H_Q^{0}$ is the BRST cohomology.\n\\subsection{Feynman Rules in $R_{\\xi}$ Gauge}\nThe Yang-Mills action can be expanded in the gauge field;\n\\begin{multline}\nS_{YM}[g_{YM}A] = \\int{}\\frac{1}{4}(\\del_\\mu A_\\nu^a - \\del_\\nu A_\\mu^a)(\\del^\\mu A^{\\nu a} - \\del^\\nu A^{\\mu a}) \\\\ + \\frac{1}{2}g_{YM}f\\indices{^{a}_{bc}}A_\\mu^b A_\\nu^c (\\del^\\mu A^{\\nu a} - \\del^\\nu A^{\\mu a}) \\\\ + \\frac{1}{4}g_{YM}^2 f\\indices{^{a}_{bc}}f\\indices{^{a}_{de}}A_\\mu^b A_\\nu^c A^{\\mu d} A^{\\nu e}\n\\end{multline}\nWhich introduces $3$-valent and $4$-valent vertices for the gauge field. Now, without picking a gauge we can't invert the kinetic term. In Lorenz gauge, we also have;\n\\begin{equation*}\ni\\int{h^a \\del_\\mu A^{\\mu a}}\n\\end{equation*}\nBut this is difficult to deal with. Instead we add a further term which is BRST exact, and so does not affect any physical correlation function or gauge invariant term;\n\\begin{equation*}\n-\\frac{i}{4}Q\\left(\\xi \\int{\\upd{^d x}\\bar{c}h}\\right) = \\frac{\\xi}{4}\\int{\\upd{^d x}h^a h^a}\n\\end{equation*}\nThe $h$ path integral then becomes;\n\\begin{multline*}\n\\int{\\mD h\\,\\,\\exp\\left(-\\frac{1}{\\hbar}\\left(i\\int{\\upd{^d x}\\tr(h \\del^\\mu A_\\mu) + \\frac{\\xi}{4}\\tr(hh)}\\right)\\right)} \\\\ = \\exp\\left(-\\frac{1}{\\hbar \\xi} \\int{\\upd{^d x}\\tr(\\del^\\mu A_\\mu \\del^\\nu A_\\nu)}\\right)\n\\end{multline*}\nwhich we have been able to compute exactly by completing the square since it is just Gaussian. Now, this terms breaks the gauge invariance explicitly, which ensures we can invert the propagator. Thus, the quadratic part of the gauge field action is;\n\\begin{align*}\n&\\int{\\frac{1}{4}(\\del_\\mu A_\\nu^a - \\del_\\nu A_\\mu^a)(\\del^\\mu A^{\\nu a} - \\del^\\nu A^{\\mu a}) + \\frac{1}{2\\xi}\\del^\\mu A_\\mu^a \\del^\\nu A_\\nu^a} \\\\\n&\\qquad = \\frac{1}{2}\\int{\\del_\\mu A_\\nu^a \\del^\\mu A^{\\nu a} - \\del_\\mu A_\\nu^a \\del^\\nu A^{\\mu a} + \\frac{1}{\\xi}\\del^\\mu A_\\mu^a \\del^\\nu A_\\nu^a} \\\\\n&\\qquad = -\\frac{1}{2}\\int{A_\\nu^a \\left(\\delta\\indices{^{\\nu}_{\\mu}}\\del^2 - \\left(1 - \\frac{1}{\\xi}\\right)\\del_\\mu \\del^\\nu\\right)A_\\mu^b \\delta^{ab}}\n\\end{align*}\nSo we see that we have the Lorenz gauge propagator;\n\\begin{equation}\n\\frac{\\delta^{ab}}{p^2}\\left(\\delta_{\\mu\\nu} - (1 - \\xi)\\frac{p_\\mu p_\\nu}{p^2}\\right)\n\\end{equation}\nwhich we note does not change the colour index of the gauge field. Now, common choices of gauge are $\\xi = 0$ (Landau gauge)\\index{Landau gauge}, $\\xi = 1$ (Feynman gauge)\\index{Feynman gauge}, $\\xi = 3$ (Rennie gauge) etc. We work in the simplest gauge, $\\xi = 1$, so that the propagator is;\n\\begin{equation}\nD^{ab}(p) = \\frac{\\delta_{\\mu\\nu}\\delta^{ab}}{p^2}\n\\end{equation}\nWe also of course have vertices, which in momentum space are shown in \\autoref{fig:3gluon} and \\autoref{fig:4gluon}.\n\\begin{mygraphic}{aqft/3gluon}{0.9}{The three gluon vertex}{3gluon}\\end{mygraphic}\n\\begin{mygraphic}{aqft/4gluon}{0.9}{The four gluon vertex}{4gluon}\\end{mygraphic}\nNow, we are in a bit of a mess. Any calculation with these vertices will lead to hundreds of terms even at one-loop etc. This has ultimately happened because we have done something very unnatural and split up the gauge invariant $F_{\\mu\\nu}$ into the kinetic part $\\del_{[\\mu}A_{\\nu]}$ and the interaction part $[A_\\mu, A_\\nu]$. This ultimately breaks the underlying geometry, and was purely for the sake of being able to do perturbation theory. We could instead try;\n\\begin{itemize}\n\\item To find a different expansion parameter that is not $g_{YM}$. For example 't Hooft uses the rank of the gauge group $1/N$ which we hope is good for $N = 3$.\n\\item We could reformulate the theory as a string theory cf. IIB String Theory.\n\\item Work non-perturbatively/numerically on a lattice with lattice QCD\\index{lattice QCD}.\n\\item Look for ways to reorganise the standard perturbation expansion e.g. on shell methods cf. spinor-helicity formalism/twistor theory.\\index{spinor-helicity formalism}\\index{twistor theory}\n\\end{itemize}\n\\subsection{Vacuum Polarisation}\nWe will compute the $\\beta$-function as in QED by considering the exact gluon propagator. Then by rescaling, we can view this as a change in the kinetic coupling $g_{YM}$. So at $\\mO(\\hbar)$ we need to consider all $1$PI one-loop diagrams with exactly two external $A_\\mu$'s (gluons). Now, note that we have the ghost action;\n\\begin{equation*}\nS_{gh} = \\int{\\tr \\del^\\mu \\bar{c}\\left(\\del_\\mu c + [A_\\mu, c]\\right)}\n\\end{equation*}\nwhich contains the normal kinetic term, as well as the interaction with $A_\\mu$. Thus in pure Yang-Mills we have the diagrams;\n\\begin{mygraphic}{aqft/gluonprop}{0.9}{The one-loop corrections to the gluon propagator in pure Yang-Mills theory}{gluonprop}\\end{mygraphic}\nImportantly, note that since the ghost is a fermion, the last diagram comes with a minus sign after the running of the particle round the loop. This term will ultimately exactly cancel the terms that are independent of the external momentum in the other two diagrams that would otherwise lead to a non-zero mass being generated. Hence, the ghost diagram enforces gauge invariance and ensures such terms cannot be produced (at least in this perturbative setting).\n\\subsection{The Yang-Mills $\\beta$-function}\nThe simplest way to obtain the $\\beta$-function is to separate the connection into a background part and fluctuations, $\\nabla = \\nabla_0 + a$, where $\\nabla_0 = d + A$ satisfies the classical Yang-Mills equations. NOw,\n\\begin{equation*}\nF_{\\nabla} = F_{\\nabla_0} + \\nabla_0 a + [a,a]\n\\end{equation*}\nSo we find that;\n\\begin{multline*}\nS_{YM}[\\nabla] = S_{YM}[\\nabla_0] + \\frac{1}{2g^2_{YM}}\\int{\\tr\\left(F_0^{\\mu\\nu}[a_\\mu, a_\\nu]\\right)} \\\\ + \\int{\\tr\\left(\\nabla_0 a + [a, a]\\right)^{\\mu\\nu}\\left(\\nabla_0 + [a,a]\\right)_{\\mu\\nu}}\n\\end{multline*}\nwhich is invariant under the gauge transformation $\\nabla \\mapsto g^{-1}\\nabla g$ (it has to be), but we can split this up as either a background transformation or a fluctuation transformation;\n\\begin{align}\n\\nabla_0 \\mapsto g^{-1}\\nabla_0 g , &\\qquad a \\mapsto g^{-1}a g \\\\\n\\nabla_0 \\mapsto \\nabla_0, &\\qquad a \\mapsto g^{-1}\\nabla_0 g + g^{-1}ag\n\\end{align}\nNow we will integrate out the fluctuations so we have to impose a gauge. If we choose the gauge condition $f[a] = \\nabla_0^\\mu a_\\mu = \\del^{\\mu}a_\\mu + A^\\mu a_\\mu$, then we automatically preserve background gauge invariance. This will guarantee that $\\Gamma[\\nabla_0]$ will be background gauge invariant; our gauge choice has not broken this. Hence it is sufficient to consider just the coefficient of $A_\\mu A_\\nu$ in $\\Gamma[\\nabla_0]$ as background gauge invariance necessarily completes this to $F_{\\mu\\nu}^{0}F^{0\\mu\\nu}$. With this $f[a]$ we have the ghost action;\n\\begin{equation*}\nS_{gh} = - \\int{\\tr \\bar{c} \\nabla_0^{\\mu}\\left(\\nabla_{0 \\mu}c + [a_\\mu, c]\\right)}\n\\end{equation*}\nAnd, again working in the $R_\\xi$ gauge, integrating out the $h$ action gives a contribution;\n\\begin{equation*}\n\\int{\\left(-ihf[a] + \\frac{\\xi}{4}h^2\\right)} \\mapsto -\\frac{1}{\\xi}\\int{\\tr(\\nabla_0^{\\mu}a_\\mu)(\\nabla_0^{\\nu}a_\\nu)}\n\\end{equation*}\nTo one-loop accuracy, we only need the terms quadratic in $a, c, \\bar{c}$. Then the relevant parts of the action are;\n\\begin{align*}\nS_{gh}^{(2)} &= -\\int{\\tr \\bar{c}\\nabla_0^\\mu \\nabla_{0\\mu}c} \\\\\nS_{YM}^{(2)} &= \\int{\\tr \\left(-a_\\nu \\nabla_0^2 a^\\nu + 2a_\\nu[F^{\\mu\\nu}, a_\\mu]\\right)}\n\\end{align*}\nIntegrating out the quantum fluctuations gives;\n\\begin{equation}\n\\Gamma[\\nabla_0] = S_{YM}[\\nabla_0] - \\log \\det (-\\nabla_0^2) + \\frac{1}{2}\\log \\det \\bigtriangleup\n\\end{equation}\nWhere the signs and factors of the two terms arise due to the fact that $c$ is a fermion field (so the determinant is on the top) and $a_\\mu$ is a real bosonic field (so the determinant comes with a square root on the bottom). We have defined;\n\\begin{equation*}\n(\\bigtriangleup_{\\mu\\nu})\\indices{^{a}_{c}} = -\\delta\\indices{^{a}_{c}}\\delta\\indices{^{\\mu}_{\\nu}} \\nabla_0^2 - 2f\\indices{^{a}_{bc}}((F_0)\\indices{^{\\mu}_{\\nu}})^{b}\n\\end{equation*}\nWe start with the ghost determinant;\n\\begin{align*}\n-\\nabla_0^2 &= -(\\del + A)^2 = -\\del^2 + i(\\del^\\mu A_\\mu^a + A_\\mu^a \\del^\\mu)t_a + A^{\\mu a}A^b_\\mu t_a t_b \\\\\n&\\coloneqq -\\del^2 + \\bigtriangleup^{(1)} + \\bigtriangleup^{(2)}\n\\end{align*}\nSo we see that;\n\\begin{align*}\n\\log \\det \\nabla_0^2 &= \\log \\det(-\\del^2) + \\log \\det \\left(1 + (-\\del^2)^{-1}\\left(\\bigtriangleup^{(1)} + \\bigtriangleup^{(2)}\\right)\\right) \\\\\n&= \\log \\det (-\\del^2) + \\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)}\\right) + \\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(2)}\\right) \\\\\n&\\qquad \\qquad- \\frac{1}{2}\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)}(-\\del^2)^{-1}\\bigtriangleup^{(1)}\\right) + \\mO(A^3)\n\\end{align*}\nIt is a fact that for any semi-simple gauge group, $\\tr t_a = 0$ so that $\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)})\\right) = 0$. Also we have that $\\log \\det(-\\del^2)$ is field independent, hence the non-trivial contributions are;\n\\begin{equation*}\n\\log \\det \\nabla_0^2 = \\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(2)}\\right) - \\frac{1}{2}\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)}(-\\del^2)^{-1}\\bigtriangleup^{(1)}\\right)\n\\end{equation*}\nwhich we can interpret as the sum of two diagrams with external gauge fields. In momentum space we have;\n\\begin{equation*}\n\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(2)}\\right) = \\mu^{4 - d}\\int{\\frac{\\ud^d k \\ud^d p}{(2\\pi)^d (2\\pi)^d}\\tilde{A}_\\mu^a(k)\\tilde{A}_\\nu^b(-k)\\frac{\\delta^{\\mu\\nu}\\tr(t_a t_b)}{p^2}}\n\\end{equation*}\nand likewise for the other diagram;\n\\begin{equation*}\n\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)}(-\\del^2)^{-1}\\bigtriangleup^{(1)}\\right) = \\frac{\\mu^{4 - d}}{2}\\int{\\frac{\\ud^d k \\ud^d p}{(2\\pi)^d (2\\pi)^d}\\frac{\\tr\\left((2p + k)^{\\mu}t_a(2p + k)_\\nu t_b\\right)}{p^2 (p + k)^2}}\n\\end{equation*}\nIndividually the diagrams don't mean anything but they combine to give;\n\\begin{multline*}\n\\log \\det\\left(-\\nabla_0^2\\right) = \\frac{C_2(\\group)}{3(4\\pi)^{d/2}}\\Gamma\\left(2 - \\frac{d}{2}\\right) \\\\ \\times\\frac{1}{2}\\int{\\frac{\\ud^d k}{(2\\pi)^d}\\tilde{A}^a_\\mu(k)\\left(k^2 \\delta^{\\mu\\nu} - k^{\\mu}k^{\\nu}\\right)\\left(\\frac{k^2}{\\mu^2}\\right)^{(d/2) - 2}\\tilde{A}_\\nu^a(-k)}\n\\end{multline*}\nwhere $C_2(\\group)$ is the quadratic Casimir. Similarly for $\\bigtriangleup = (-\\nabla_0)^2 - 2[F_0, \\cdot]$, we have;\n\\begin{multline*}\n\\log\\det\\bigtriangleup = \\log \\det (-\\del^2) + \\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(2)}\\right) \\\\ + \\frac{1}{2}\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{(1)}(-\\del^2)^{-1}\\bigtriangleup^{(1)}\\right) - \\frac{1}{2}\\tr\\left((-\\del^2)^{-1}\\bigtriangleup^{F}(-\\del^2)^{-1}\\bigtriangleup^{F}\\right)\n\\end{multline*}\nThis new term corresponds to a diagram with one loop with new vertices;\n\\begin{equation*}\n-4 C_2(\\group) \\mu^{4 - d}\\int{\\frac{\\ud^d k \\ud^d p}{(2\\pi)^d (2\\pi)^d}\\tr \\tilde{A}_\\mu(k)\\tilde{A}_\\nu(-k)\\frac{k^2 \\delta^{\\mu\\nu} - k^{\\mu}k^{\\nu}}{p^2(p + k)^2}}\n\\end{equation*}\nCombining the two pieces, we have the effective action;\n\\begin{multline}\n\\Gamma[\\nabla_0] = S_{YM}[\\nabla_0] - \\frac{\\Gamma(2 - d/2)}{(4\\pi)^{d/2}}\\frac{11}{3}C_2(\\group)\\frac{1}{2} \\\\ \\times \\int{\\upd{^d x}\\left(-\\frac{\\del^2}{\\mu^2}\\right)^{d/2 - 2}\\tr F_0^{\\mu\\nu}F_{0 \\mu\\nu}}\n\\end{multline}\nNow the $\\Gamma$-function has a pole in $d = 4$ which we can remove using a counterterm. Altogether we have an effective coupling in momentum space;\n\\begin{equation*}\n\\Gamma[A] = \\int{\\frac{1}{2g^2_{\\text{eff}}(k)}\\tr\\left(\\tilde{F}^{\\mu\\nu}(k)\\tilde{F}_{\\mu\\nu}(-k)\\right)}\n\\end{equation*}\nwhere we have;\n\\begin{equation}\n\\frac{1}{g^2_{\\text{eff}}(k)} = \\frac{1}{g^2(\\mu)} - \\frac{1}{2}\\frac{11}{16\\pi^2}C_2(\\group)\\log\\left(\\frac{\\mu^2}{k^2}\\right) \n\\end{equation}\nAs usual, this should be independent of the renormalisation scale $\\mu$, so we must have;\n\\begin{equation*}\n\\mu\\frac{\\del}{\\del \\mu}\\left(\\frac{1}{g^2(\\mu)} - \\frac{11}{3}\\frac{C_2(\\group)}{(4\\pi)^2}\\log\\left(\\frac{\\mu^2}{k^2}\\right)\\right) = 0\n\\end{equation*}\nSo we see that;\n\\begin{equation*}\n-\\frac{2}{g^3(\\mu)} \\beta(g) - \\frac{2 \\cdot 11}{3}\\frac{C_2(\\group)}{(4\\pi)^2} = 0 \\Rightarrow \\beta(g) = - \\frac{g^2(\\mu)}{(4\\pi)^2}\\frac{11}{3}C_2(\\group)\n\\end{equation*}\nIf we added in quarks (fermions) and/or scalars (bosons) we find that;\n\\begin{equation*}\n\\beta(g) = -\\frac{g^2(\\mu)}{(4\\pi)^2}\\set{\\frac{11}{3}C_2(\\group) - \\frac{4}{3}C_2(R) - \\frac{1}{3}C_2(R\\pr)}\n\\end{equation*}\nwhere the fermions live in a rep. $R$ and the bosons are in a different rep. $R\\pr$. Thus, provided we don't have too much matter $\\beta(g) < 0$ so the YM coupling is marginally relevant. Thus, heading into the UV, YM approaches a free theory to arbitrary accuracy, whilst it becomes strongly coupled in the IR. A calculation done shortly after the $\\beta$-function was computed showed that the only possible continuum QFT in $d = 4$ is actually non-Abelian gauge theory.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n%\\end{multicols*}", "meta": {"hexsha": "1b52ad0cd2cd8fb4cbf953f436d5ee2570797718", "size": 163663, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Part III/Revision Notes/aqft.tex", "max_stars_repo_name": "james-alvey-42/LectureNotes", "max_stars_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Part III/Revision Notes/aqft.tex", "max_issues_repo_name": "james-alvey-42/LectureNotes", "max_issues_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Part III/Revision Notes/aqft.tex", "max_forks_repo_name": "james-alvey-42/LectureNotes", "max_forks_repo_head_hexsha": "2e2c9c8082633379c26be5c06df06aa7a016fa96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-10-26T17:48:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-26T17:48:29.000Z", "avg_line_length": 86.0026274304, "max_line_length": 981, "alphanum_fraction": 0.677819666, "num_tokens": 59301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.43071978442748743}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\n\\title{Marlin Diagram}\n\\date{July 2020}\n\n\\usepackage[x11names]{xcolor}\n\\usepackage[b4paper,margin=1.2in]{geometry}\n\\usepackage{tikz}\n\\usepackage{afterpage}\n\n\\newenvironment{rcases}\n  {\\left.\\begin{aligned}}\n  {\\end{aligned}\\right\\rbrace}\n\n\\begin{document}\n\n\\newcommand{\\cm}[1]{\\ensuremath{\\mathsf{cm}_{#1}}}\n\\newcommand{\\vcm}[1]{\\ensuremath{\\mathsf{vcm}_{#1}}}\n\\newcommand{\\s}{\\ensuremath{\\hat{s}}}\n\\newcommand{\\w}{\\ensuremath{\\hat{w}}}\n\\newcommand{\\x}{\\ensuremath{\\hat{x}}}\n\\newcommand{\\z}{\\ensuremath{\\hat{z}}}\n\\newcommand{\\za}{\\ensuremath{\\hat{z}_A}}\n\\newcommand{\\zb}{\\ensuremath{\\hat{z}_B}}\n\\newcommand{\\zc}{\\ensuremath{\\hat{z}_C\n}}\n\\newcommand{\\zm}{\\ensuremath{\\hat{z}_M}}\n\n\\newcommand{\\val}{\\ensuremath{\\mathsf{val}}}\n\\newcommand{\\row}{\\ensuremath{\\mathsf{row}}}\n\\newcommand{\\col}{\\ensuremath{\\mathsf{col}}}\n\\newcommand{\\rowcol}{\\ensuremath{\\mathsf{rowcol}}}\n\n\\newcommand{\\hval}{\\ensuremath{\\hat{\\val}}}\n\\newcommand{\\hrow}{\\ensuremath{\\hat{\\row}}}\n\\newcommand{\\hcol}{\\ensuremath{\\hat{\\col}}}\n\\newcommand{\\hrowcol}{\\ensuremath{\\hat{\\rowcol}}}\n\n\\newcommand{\\bb}{\\ensuremath{\\mathsf{b}}}\n\\newcommand{\\denom}{\\ensuremath{\\mathsf{denom}}}\n\n\\newcommand{\\sumcheckinner}{\\mathsf{sumcheck}\n_{\\mathsf{inner}}}\n\\newcommand{\\sumcheckouter}{\\mathsf{sumcheck}_{\\mathsf{outer}}}\n\n\\newcommand{\\Prover}{\\mathcal{P}}\n\\newcommand{\\Verifier}{\\mathcal{V}}\n\n\\newcommand{\\F}{\\mathbb{F}}\n\n\\newcommand{\\DomainA}{H}\n\\newcommand{\\DomainB}{K}\n\n\\newcommand{\\vPoly}[1]{\\ensuremath{v_{#1}}}\n\n\nThis diagram (on the following page) shows the interaction of the Marlin prover and verifier. It is similar to the diagrams in the paper (Figure 5 in Section 5 and Figure 7 in Appendix E, in the latest ePrint version), but with two changes: it shows not just the AHP but also the use of the polynomial commitments (the cryptography layer); and it aims to be fully up-to-date with the recent optimizations to the codebase. This diagram, together with the diagrams in the paper, can act as a ``bridge\" between the codebase and the theory that the paper describes.\n\n\\section{Glossary of notation}\n\\begin{table*}[htbp]\n  \\centering\n  \\begin{tabular}{c|c}\n    $\\F$ & the finite field over which the R1CS instance is defined \\\\\n     \\hline\n    $x$ & public input \\\\\n     \\hline\n    $w$ & secret witness \\\\\n     \\hline\n    $\\DomainA$ & variable domain \\\\\n     \\hline\n    $\\DomainB$ & matrix domain \\\\\n     \\hline\n    $X$ & domain sized for input (not including witness) \\\\\n     \\hline\n    $v_D(X)$ & vanishing polynomial over domain $D$ \\\\\n     \\hline\n    $A, B, C$ & R1CS instance matrices \\\\\n    \\hline\n    $A^*, B^*, C^*$ &\n    \\begin{tabular}{@{}c@{}}shifted transpose of $A,B,C$ matries given by $M^*_{a,b} := M_{b,a} \\cdot u_\\DomainA(b,b) \\; \\forall a,b \\in \\DomainA$ \\\\ (optimization from Fractal, explained in Claim 6.7 of that paper) \\end{tabular} \\\\\n     \\hline\n    $\\{\\hval, \\hrow, \\hcol\\}_{\\{A^*,B^*,C^*\\}}$ &\n    \t\\begin{tabular}{@{}c@{}} preprocessed polynomials from $A^*, B^*, C^*$ matrices containing LDEs of (respectively) \\\\ row positions, column positions, and values of non-zero matrix elements \\end{tabular} \\\\\n    \\hline\n    $\\hrowcol_{\\{A^*, B^*, C^*\\}}$ &\n        \t\\begin{tabular}{@{}c@{}} the product polynomial of $\\hrow$ and $\\hcol$, given separately for efficiency (namely \\\\ to allow this product to be part of a \\textit{linear} combination) \\end{tabular} \\\\\n     \\hline\n    $\\Prover$ & prover \\\\\n     \\hline\n    $\\Verifier$ & verifier \\\\\n     \\hline\n    $\\Verifier^{p}$ &\n    \t\\begin{tabular}{@{}c@{}} $\\Verifier$ with ``oracle\" access to polynomial $p$ (via commitments provided \\\\ by the indexer, later opened as necessary by $\\Prover$) \\end{tabular}\n  \\end{tabular}\n\\end{table*}\n\n\\afterpage{%\n\\newgeometry{margin=0.5in}\n\n\\section{Diagram}\n\n\\centering\n\\begin{tikzpicture}[scale=0.9, every node/.style={scale=0.9}]\n\n\\tikzstyle{lalign} = [minimum width=3cm,align=left,anchor=west]\n\\tikzstyle{ralign} = [minimum width=3cm,align=right,anchor=east]\n\n\\node[lalign] (prover) at (-3,27.3) {%\n$\\Prover(\\F, \\DomainA, \\DomainB, A, B, C, x, w)$\n};\n\n\\node[ralign] (verifier) at (16.2,27.3) {%\n$\\Verifier^{\\{\\hval, \\hrow, \\hcol, \\hrowcol\\}_{\\{A^*, B^*, C^*\\}}}(\\F, \\DomainA, \\DomainB, x)$\n};\n\n\\draw [line width=1.0pt] (-3,27.0) -- (16,27.0);\n\n\\node[lalign] (prover1) at (-3,26.1) {%\n$z := (x, w), \\za := Az, \\zb := Bz$ \\\\\nsample $\\w(X) \\in \\F^{<|w|+\\bb}[X]$ and $\\za(X), \\zb(X) \\in \\F^{<|\\DomainA|+\\bb}[X]$ \\\\\nsample mask poly $\\s(X) \\in \\F^{<3|\\DomainA|+2\\bb-2}[X]$ such that $\\sum_{\\kappa \\in \\DomainA}\\s(\\kappa) = 0$\n};\n\n\\draw [->] (-2,24.8) -- node[midway,fill=white] {commitments $\\cm{\\w}, \\cm{\\za}, \\cm{\\zb}, \\cm{\\s}$} (15,24.8);\n\n\\node[ralign] (verifier1) at (16,24.0) {%\n$\\eta_A, \\eta_B, \\eta_C \\gets \\F$ \\\\\n$\\alpha \\gets \\F \\setminus \\DomainA$\n};\n\n\\draw [->] (15,23.3) -- node[midway,fill=white] {$\\eta_A, \\eta_B, \\eta_C, \\alpha \\in \\F$} (-2,23.3);\n\n\\node[lalign] (prover2) at (-3,22.5) {%\ncompute $t(X) := \\sum_M \\eta_M r_M(\\alpha, X)$\n};\n\n\\draw (-2.4,22.0) rectangle (15.4,4.8);\n\n\\node (sc1label) at (6.5,21.7) {%\n\\textbf{sumcheck for} $\\s(X) + r(\\alpha, X) \\left(\\sum_M \\eta_M \\zm(X)\\right) - t(X)\\z(X)$ \\textbf{ over } $\\DomainA$\n};\n\n\\node[lalign] (prover3) at (-2,20.7) {%\nlet $\\zc(X) := \\za(X) \\cdot \\zb(X)$ \\\\\nfind $g_1(X) \\in \\F^{|\\DomainA|-1}[X]$ and $h_1(X)$ such that \\\\\n$s(X)+r(\\alpha, X)(\\sum_M \\eta_M \\zm(X)) - t(X)\\z(X) = h_1(X)\\vPoly{\\DomainA}(X) + Xg_1(X)$ \\hspace{0.3cm} $(*)$\n};\n\n\\draw [->] (-1,19.5) -- node[midway,fill=white] {commitments $\\cm{t}, \\cm{g_1}, \\cm{h_1}$} (14,19.5);\n\n\\node[ralign] (verifier2) at (15.4,19.1) {%\n$\\beta \\gets \\F \\setminus \\DomainA$\n};\n\n\\draw [->] (14,18.7) -- node[midway,fill=white] {$\\beta \\in \\F$} (-1,18.7);\n\n\\draw (-0.85,18.2) rectangle (13.85,8.4);\n\n\\node (sc2label) at (6.5,17.6) {%\n\\textbf{sumcheck for } $\\sum\\limits_{M \\in \\{A, B, C\\}} \\eta_M \\frac{\\vPoly{\\DomainA}(\\beta) \\vPoly{\\DomainA}(\\alpha)\\hval_{M^*}(X)}{\\color{purple}(\\beta-\\hrow_{M^*}(X))(\\alpha-\\hcol_{M^*}(X))} $ \\textbf{ over } $\\DomainB$\n};\n\n\\node[align=center] (mid1) at (6.5, 16.3) {%\n$\\begin{aligned} \n\\text{for } M \\in \\{A, B, C\\} \\text{, let } {\\color{purple} M_\\denom(X)} &:= (\\beta - \\hrow_{M^*}(X)) (\\alpha - \\hcol_{M^*}(X)) \\\\\n&= {\\color{gray}\\alpha\\beta} - {\\color{gray}\\alpha}\\hrow_{M^*}(X) - {\\color{gray}\\beta}\\hcol_{M^*}(X) + \\hrowcol_{M^*}(X)\n\\end{aligned}$\n};\n\n\\node[align=center] (mid2) at (6.5, 15.0) {%\nlet ${\\color{orange} a(X)} := \\sum\\limits_{M \\in \\{A, B, C\\}} {\\color{gray} \\eta_M \\vPoly{\\DomainA}(\\beta) \\vPoly{\\DomainA}(\\alpha)} \\hval_{M^*}(X) \\prod_{N \\neq M} {\\color{purple} N_\\denom(X)}$\n};\n\n\\node[align=center] (mid3) at (6.5, 14.1) {%\nlet ${\\color{Green4} b(X)} := \\sum\\limits_{M \\in \\{A, B, C\\}} {\\color{purple} M_\\denom(X)}$\n};\n\n\\node[lalign] (prover4) at (-0.75,13.2) {%\nfind $g_2(X) \\in \\F^{|\\DomainB|-1}[X]$ and $h_2(X)$ s.t. \\\\\n$h_2(X)\\vPoly{\\DomainB}(X) = {\\color{orange} a(X)} - {\\color{Green4} b(X)} (Xg_2(X)+t(\\beta)/|\\DomainB|)$ \\hspace{0.3cm} $(**)$\n};\n\n\\draw [->] (0,12.2) -- node[midway,fill=white] {commitments $\\cm{g_2}, \\cm{h_2}$} (13,12.2);\n\n\\draw [->] (13,11.5) -- node[midway,fill=white] {$\\gamma \\in \\F$} (0,11.5);\n\n\\node[ralign] (verifier3) at (14.5, 11.9) {%\n$\\gamma \\gets \\F$\n};\n\n\\draw[dashed] (1.5,11.0) rectangle (11.5,8.8);\n\n\\node[align=center] (mid4) at (6.5, 9.9) {%\nTo verify $(**)$, $\\Verifier$ will need to check the following: \\\\[10pt]\n$ \\underbrace{{\\color{orange} a({\\color{black} \\gamma})} - {\\color{Green4} b({\\color{black} \\gamma})} {\\color{gray} (\\gamma g_2(\\gamma) + t(\\beta) / |\\DomainB|) - \\vPoly{\\DomainB}(\\gamma)} h_2(\\gamma)}_{\\sumcheckinner(\\gamma)} \\stackrel{?}{=} 0 $\n};\n\n\\node[ralign] (verifier3) at (15.4, 7.9) {%\nCompute $\\x(X) \\in \\F^{<|x|}[X]$\n};\n\n\\draw[dashed] (-2.2,7.4) rectangle (15.2,5.2);\n\n\\node[align=center] (mid5) at (6.5, 6.3) {%\nTo verify $(*)$, $\\Verifier$ will need to check the following: \\\\[10pt]\n$ \\underbrace{s(\\beta) + {\\color{gray} r(\\alpha, \\beta)} ({\\color{gray} \\eta_A} \\za(\\beta) + {\\color{gray} \\eta_C\\zb(\\beta)} \\za(\\beta) + {\\color{gray} \\eta_B\\zb(\\beta)}) - {\\color{gray} t(\\beta) \\vPoly{X}(\\beta)} \\w(\\beta) - {\\color{gray} t(\\beta) \\x(\\beta)} - {\\color{gray} \\vPoly{\\DomainA}(\\beta)} h_1(\\beta) - {\\color{gray} \\beta g_1(\\beta)}}_{\\sumcheckouter(\\beta)} \\stackrel{?}{=} 0 $\n};\n\n\\node[lalign] (prover5) at (-3,3.9) {%\n$v_{g_2} := g_2(\\gamma), v_{A_\\denom} := A_\\denom(\\gamma), v_{B_\\denom} := B_\\denom(\\gamma), v_{C_\\denom} := C_\\denom(\\gamma)$ \\\\[3pt]\n$v_{g_1} := g_1(\\beta), v_{\\zb} := \\zb(\\beta), v_{t} := t(\\beta)$\n};\n\n\\draw [->] (-2,2.9) -- node[midway,fill=white] {$v_{g_2}, v_{A_\\denom}, v_{B_\\denom}, v_{C_\\denom}, v_{g_1}, v_{\\zb}, v_{t}$} (15,2.9);\n\n\\node[align=center] (mid6) at (6.5,1.9) {%\nuse index commitments $\\hrow, \\hcol, \\hrowcol$ to construct virtual commitments $\\vcm{\\{A_\\denom, B_\\denom, C_\\denom\\}}$\n};\n\n\\node[align=center] (mid7) at (6.5,0.8) {%\nuse index commitments $\\hval$, commitments $\\vcm{A_\\denom}$, $\\vcm{B_\\denom}, \\vcm{C_\\denom}, \\cm{h_2}$, {\\color{gray} and evaluations $g_2(\\gamma),t(\\beta)$} \\\\\nto construct virtual commitment $\\vcm{\\sumcheckinner}$\n};\n\n\\node[align=center] (mid8) at (6.5,-0.5) {%\nuse commitments $\\cm{\\s}, \\cm{\\za}, \\cm{\\w}, \\cm{h_1}$ {\\color{gray} and evaluations $\\zb(\\beta), t(\\beta), g_1(\\beta)$} \\\\\nto construct virtual commitment $\\vcm{\\sumcheckouter}$\n};\n\n\\node[ralign] (verifier4) at (16,-1.5) {%\n$\\xi_1, \\dots, \\xi_5 \\gets \\F$\n};\n\n\\draw [->] (15,-2.1) -- node[midway,fill=white] {$\\xi_1, \\dots, \\xi_5$} (-2,-2.1);\n\n\\node[lalign] (prover6) at (-3,-3.6) {%\nuse $\\mathsf{PC}.\\mathsf{Prove}$ with randomness $\\xi_1, \\dots, \\xi_5$ to \\\\\nconstruct a batch opening proof $\\pi$ of the following: \\\\\n$(\\cm{g_2}, \\cm{A_\\denom}, \\cm{B_\\denom}, \\cm{C_\\denom}, {\\color{red} \\vcm{\\sumcheckinner}})$ at $\\gamma$ evaluate to $(v_{g_2}, v_{A_\\denom}, v_{B_\\denom}, v_{C_\\denom}, {\\color{red} 0})$ \\hspace{0.3cm} ${\\color{red} (**)}$ \\\\\n$(\\cm{g_1}, \\cm{\\zb}, \\cm{t}, {\\color{red} \\vcm{\\sumcheckouter}})$ at $\\beta$ evaluate to $(v_{g_1}, v_{\\zb}, v_{t}, {\\color{red} 0})$ \\hspace{0.3cm} ${\\color{red} (*)}$ \\\\\n};\n\n\\draw [->] (-2,-4.7) -- node[midway,fill=white] {$\\pi$} (15,-4.7);\n\n\\node[ralign] (verifier5) at (16,-6.0) {%\nverify $\\pi$ with $\\mathsf{PC}.\\mathsf{Verify}$, using randomness $\\xi_1, \\dots, \\xi_5$, \\\\\nevaluations $v_{g_2}, v_{A_\\denom}, v_{B_\\denom}, v_{C_\\denom}, v_{g_1}, v_{\\zb}, v_{t}$, and \\\\\ncommitments $\\cm{g_2}, \\cm{A_\\denom}, \\cm{B_\\denom}, \\cm{C_\\denom},$ \\\\\n$\\vcm{\\sumcheckinner}, \\cm{g_1}, \\cm{\\zb}, \\cm{t}, \\vcm{\\sumcheckinner}$\n};\n\n\\end{tikzpicture}\n\n\\clearpage\n\\restoregeometry\n}\n\n\n\\end{document}\n", "meta": {"hexsha": "6e7af425cfb4b1ff48fb8354bdf2ce1a6a600462", "size": 10597, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diagram/diagram.tex", "max_stars_repo_name": "huyuncong/marlin", "max_stars_repo_head_hexsha": "9a52103b66b532596ac58955e2f78898da6e088c", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-05-05T20:37:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-02T12:53:56.000Z", "max_issues_repo_path": "diagram/diagram.tex", "max_issues_repo_name": "huyuncong/marlin", "max_issues_repo_head_hexsha": "9a52103b66b532596ac58955e2f78898da6e088c", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-06-23T11:17:30.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-25T08:28:33.000Z", "max_forks_repo_path": "diagram/diagram.tex", "max_forks_repo_name": "huyuncong/marlin", "max_forks_repo_head_hexsha": "9a52103b66b532596ac58955e2f78898da6e088c", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-17T07:21:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-17T07:21:26.000Z", "avg_line_length": 40.2927756654, "max_line_length": 561, "alphanum_fraction": 0.6081909975, "num_tokens": 4305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4306453981339848}}
{"text": "\\section{Results}\n\\label{sec:results}\n\\begin{table}\n\t\\begin{center}\n\t\t\\begin{tabular}{|p{0.2\\linewidth}|p{0.2\\linewidth}|p{0.2\\linewidth}|} \\hline\n\t\t\tMethod & Mean Version & Standard Deviation \\\\ \\hline\n\t\t\tTwo Planes & 8.9\\degree & 4.7\\degree \\\\\n\t\t\tCorrected Friedman & 8.4\\degree & 6.5\\degree \\\\\n\t\t\tFriedman & 9.4\\degree & 7.4\\degree \\\\\n\t\t\tVault & 12.3\\degree & 7.7\\degree \\\\\n\t\t\tCommercial software & 9.9\\degree & 6.1\\degree \\\\\n                        \\hline\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{\\label{tab:results}A comparison of the results of each method tested \n\ton 10 retrospective patients}\n\\end{table}\n\nTable \\ref{tab:results} presents the results of using \\sksglenoid on 10 patients.\nThe version measured using the planes method has a mean glenoid\nversion of 8.9\\degree (SD, 4.7\\degree; range, 5\\degree to 20.9\\degree), \nwhile mean glenoid version \nfor the 3D corrected Friedman method \nwas 8.4\\degree (SD, 6.5\\degree; range, -4.0\\degree to 16.9\\degree). \nFor the 2D methods, the mean glenoid version for the \nFriedman method was 9.4\\degree (SD, 7.4\\degree; range, -0.7\\degree to 24\\degree) \nand for the vault model was 12.3\\degree (SD, 7.7\\degree; range, 4\\degree to 26\\degree).\nIn this \ncase a positive value indicates retroversion while a negative value indicates anteversion of the \nglenoid. Overall, the 3D methods resulted in both lower mean version values as well as lower\nvariability, while the 2D methods revealed a slightly higher variability.\n\nThe measurements using these methods were also compared with version measurements on the same\n10 patients using a commercial software\\cite{djosurgical}. \nThe planes method (r = 0.90, p = 0.0004), \ncorrected Friedman method (r = 0.83, p = 0.0034), \nand conventional Friedman method (r = 0.79, p = 0.0064) \nall showed significant correlation with the commercial software. \nThe vault method did not show significant correlation (r = 0.59, p = 0.074).  \nThe mean difference between the methods were overall not significant ($\\rm{p} > 0.05$), \nexcept for the vault method (p = 0.03). Correlation plots are shown in Figure \\ref{fig:correl}.\n\n\\begin{figure}\n\t\\begin{center}\n\t\t\\begin{subfigure}[b]{0.30\\linewidth}\n\t\t\t\\includegraphics[width=\\linewidth]{figures/planes.png}\n\t\t\t\\caption{Two Planes Method}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.30\\linewidth}\n\t\t\t\\includegraphics[width=\\linewidth]{figures/correctedfried.png}\n\t\t\t\\caption{Corrected Friedman Method}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.30\\linewidth}\n\t\t\t\\includegraphics[width=\\linewidth]{figures/friedman.png}\n\t\t\t\\caption{Friedman Method}\n\t\t\\end{subfigure}\n\t\t\\caption{\\label{fig:correl}The Pearson correlation between the commercial software and the 3 methods that gave a statistically significant result.}\n\t\\end{center}\n\\end{figure}\n", "meta": {"hexsha": "72896e24b3dd71abc2914c872758067121206ec7", "size": 2765, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "results.tex", "max_stars_repo_name": "SciKit-Surgery/scikit-surgeryglenoid-paper", "max_stars_repo_head_hexsha": "db1bad319d23c85c9560fae1d9fb72dad2ae82d1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "results.tex", "max_issues_repo_name": "SciKit-Surgery/scikit-surgeryglenoid-paper", "max_issues_repo_head_hexsha": "db1bad319d23c85c9560fae1d9fb72dad2ae82d1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-26T16:33:59.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T16:33:59.000Z", "max_forks_repo_path": "results.tex", "max_forks_repo_name": "SciKit-Surgery/scikit-surgeryglenoid-paper", "max_forks_repo_head_hexsha": "db1bad319d23c85c9560fae1d9fb72dad2ae82d1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0833333333, "max_line_length": 149, "alphanum_fraction": 0.7330922242, "num_tokens": 867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.43064538642755973}}
{"text": "\\chapter{{\\tt Cartography} Module}\\label{ch:cartography-module}\n\n[{\\em Note: The documentation for this chapter is not yet complete... }]\n$$\n$$ \nThe earliest robots in space were not planetary rovers -- they were\nunmanned probes that studied the planetary bodies in our solar system\nfrom afar.  Today there are roughly twenty extraterrestrial spacecraft\nin active communication with earth (and only two planetary rovers), so\nthe bulk of the extraterrestrial data that we receive consists of\nimagery that originated on round(ish) surfaces.  The natural thing to\ndo with this data is to merge it together into a map, but when doing\nso we are faced with the same problem that has plagued cartographers\nfor hundreds of years: how does one flatten the globe?  This is the job\nof the Vision Workbench Cartography module: to make maps.\n\nBefore diving into an introduction on planetary cartography, we will\npoint out another problem that is relatively new to Cartography.  The\namount of map data that we have collected about Earth and the other\nbodies in our solar system is {\\em immense}.  It is often impossible\nto store an entire mapping data set in memory all at once, so\nintelligent paging, caching, and storage strategies must be used in\norder to make working with this data tractable.  For this reason, the\nCartography module is particularly powerful when used in conjunction\nwith Mosaic module (see Chapter \\ref{ch:mosaic-module}), which is\ndesigned to efficiently process and combine extremely large data sets.\n\nWe will begin this chapter with a quick summary of the third party\nlibraries that are needed to compile the Vision Workbench.  We will\nthen describe the \\verb#GeoRefence# class, which creates a\nrelationship between pixel coordinates in an image and coordinates on\na globe.  Next, we will discuss the \\verb#GeoTransform# class, which\nprovides a simple means of re-projecting map data.  We finish this\nsection with methods for reading and writing image files with embedded\ngeospatial metadata.\n\n\\section{Software Dependencies}\n\nThe Cartography module is currently built on top of two third party\nlibraries:\n\n\\begin{itemize}\n\\item GDAL   [ {\\tt http://www.remotesensing.org/gdal/ } ]\n\\item Proj.4 [ {\\tt http://proj.maptools.org/ }]\n\\end{itemize}\n\nIn order to enable the Cartography module, you must have these\nlibraries installed on your system before you configure and build the\nVision Workbench.  You may need to use the \\verb#PKG_PATHS# directive\nin the \\verb#config.options# file if you install them in a\nnon-standard location as discussed in Chapter \\ref{ch:gettingstarted}.\n\nOnce the library for the Cartography module has been built, the header\nfiles for GDAL and Proj.4 are no longer needed, so you can rely solely\non linking in libraries when building your own application.\n\n\\section{The {\\tt GeoReference} Class}\n\nWhen you point at a location on a map, you probably want to know where\nthat location can be found in the real world.  This relationship\ndepends first and foremost on the familiar notion of a map's scale.\nHowever, this relationship is also affected by a subtle, but extremely\nimportant dependence on how the map is {\\em projected}.  That is, the\nimage depicts a scene that sits on the surface of a spheroid.\nHowever, the image is flat, so at best it represents a very slightly\ndistorted view of the surface.  \n\nOne can imagine all sorts of different ways that the surface can be\nwarped or projected onto a flat plane (or, at the very least,\nprojecting onto a manifold that can be unfolded into a plane without\ndistorting distances and areas -- a sphere cannot be unfolded in this\nway).  Generations of cartographers have struggled with this\ntopological challenge, and as a result they have developed many\ndifferent ways to ``un-fold'' the globe so that it can be represented\nas a flat image.  Rather than attempt a description of these many\ntechniques here, we suggest you look at this excellent web site\ndescribing all aspects of map projections.\n\n\\begin{verbatim}\n  http://www.progonos.com/furuti/MapProj/CartIndex/cartIndex.html\n\\end{verbatim}\n\nThe Proj.4 manual is also recommended as a reference for the specific\nmap projections supported by the Vision Workbench.\n\nNow would be a good time to take a break from reading this section of\nthe documentation to look over these references.  When you return, we\nwill dive into some code examples.  \n\n\\subsection{The Datum}\n\nA Vision Workbench \\verb#GeoReference# object is composed of three items:\n\n\\begin{itemize}\n\\item {\\bf The Projection}: As discussed above, this is the technique\n  used to represent the round globe in a flat image.\n\\item {\\bf The Affine Transform}: This is the geometric transformation\n  between pixel coordinates in the image to coordinates in the map\n  projection space.\n\\item {\\bf The Datum}: Describes the approximate shape of the\n  planetary body, as either a sphere or an ellipsoid.\n\\end{itemize}\n\n\\subsection{The Affine Transform}\n\nLet's start by being explicit about the coordinate systems we will be\nworking with.  For images, we adopt the usual Vision Workbench\ncoordinate system wherein the upper left corner of the image is the\norigin, the $u$ coordinate increases as you move right along the\ncolumns of the image, and the $v$ coordinate increases as you move\ndown the rows.  \n\nFor a planetary body, the coordinate of a point on the surface is\ntypically measured in latitude, longitude, and radius ($\\phi, \\theta,\nr$).  Lines of latitude are perpendicular to the axis of rotation and\nare measured from the center line, the {\\em equator} (+/-90 degrees).\nLines of Longitude are vertical, passing through both the North and\nSouth poles of the planet.  It is measured from a vertical arc on the\nsurface called the {\\em meridian}.  We will generally adopt an East\npositive frame of reference (latitude increases to the east of the\nmeridian 0-360 degrees).  Finally, the radius is measured from the\npoint to the planet's center of mass.  Note that this coordinate\nsystem is similar but not identical to spherical coordinates in a\nmathematical sense, where ``latitude'' would be measured from the\nNorth pole rather than the equator.\n\nUnder this set of assumptions, if we have a point $P_{img} = (u,v)$ in\nthe image, and we want to relate it to some planetary coordinates\n\n\\subsection{Putting Things Together}\n%% - The GeoReference Object\n%%   - Creating \n%%     - proj4str\n%%     - datum and transform\n%%   - << streaming\n%%   - Setting projections\n\n\\begin{table}[t]\\begin{centering}\n\\begin{tabular}{|l|l|l|} \\hline\nMethod & Description \\\\ \\hline \\hline\n\\verb#set_sinusoidal()# & Sinusoidal Projection \\\\ \\hline\n\\verb#set_mercator()# & Mercator Projection \\\\ \\hline\n\\verb#set_orthographic()# & Orthographic Projection \\\\ \\hline\n\\verb#set_stereographic()# & Stereographic Projection \\\\ \\hline\n\\verb#set_UTM()# & Universal Transverse Mercator (UTM) Projection (Earth only) \\\\ \\hline\n\\end{tabular}\n\\caption{Currently supported {\\tt GeoReference} map projections.}\n\\label{tbl:georeference-map-projections}\n\\end{centering}\\end{table}\n\n\n\\section{Geospatial Image Processing}\n\\subsection{The {\\tt GeoTransform} Functor}\n%%     - Use to reproject maps \n%%     - Formulate a source and destination \\verb#GeoReference# object\n%%     - \n%%   - \\verb#xyz_to_latlon()#\n\n\\section{Georeferenced File I/O}\n\\subsection{{\\tt DiskImageResourceGDAL}}\n", "meta": {"hexsha": "a5cb1137e960ae4ce0f3201eb5c5573d46bda254", "size": 7342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/workbook/cartography_module.tex", "max_stars_repo_name": "digimatronics/ComputerVision", "max_stars_repo_head_hexsha": "2af5da17dfd277f0cb3f19a97e3d49ba19cc9d24", "max_stars_repo_licenses": ["NASA-1.3"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-02T04:06:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-02T04:06:43.000Z", "max_issues_repo_path": "docs/workbook/cartography_module.tex", "max_issues_repo_name": "tkeemon/visionworkbench", "max_issues_repo_head_hexsha": "df59fcb31191e1fc4fecfe1901963da1614a52b1", "max_issues_repo_licenses": ["NASA-1.3"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/workbook/cartography_module.tex", "max_forks_repo_name": "tkeemon/visionworkbench", "max_forks_repo_head_hexsha": "df59fcb31191e1fc4fecfe1901963da1614a52b1", "max_forks_repo_licenses": ["NASA-1.3"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-18T04:06:32.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-17T10:34:39.000Z", "avg_line_length": 45.602484472, "max_line_length": 88, "alphanum_fraction": 0.7769000272, "num_tokens": 1746, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.43064538642755973}}
{"text": "\\documentclass[11pt]{article}\n\n%% WRY has commented out some unused packages %%\n%% If needed, activate these by uncommenting\n\\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.\n%\\geometry{letterpaper}                   % ... or a4paper or a5paper or ... \n\\geometry{a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}\n%\\geometry{landscape}                % Activate for rotated page geometry\n%\\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent\n\n\\usepackage{natbib}\n\n%for figures\n%\\usepackage{graphicx}\n\n\\usepackage{color}\n\\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue\n\\definecolor{mylilas}{RGB}{170,55,241}\n%% for graphics this one is also OK:\n\\usepackage{epsfig}\n\n%% AMS mathsymbols are enabled with\n\\usepackage{amssymb,amsmath}\n\n%% more options in enumerate\n\\usepackage{enumerate}\n%\\usepackage{enumitem}\n\n%% insert code\n\\usepackage{listings}\n\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{hyperref}\n\n%% To make really wide whats that cover everything:\n\\usepackage{scalerel}\n\\usepackage{stackengine}\n\\stackMath\n\\def\\hatgap{2pt}\n\\def\\subdown{-2pt}\n\\newcommand\\what[2][]{%\n\\renewcommand\\stackalignment{l}%\n\\stackon[\\hatgap]{#2}{%\n\\stretchto{%\n    \\scalerel*[\\widthof{$#2$}]{\\kern-.6pt\\bigwedge\\kern-.6pt}%\n    {\\rule[-\\textheight/2]{1ex}{\\textheight}}%WIDTH-LIMITED BIG WEDGE\n}{0.5ex}% THIS SQUEEZES THE WEDGE TO 0.5ex HEIGHT\n_{\\smash{\\belowbaseline[\\subdown]{\\scriptstyle#1}}}%\n}}\n\n% Default fixed font does not support bold face\n\\DeclareFixedFont{\\ttb}{T1}{txtt}{bx}{n}{12} % for bold\n\\DeclareFixedFont{\\ttm}{T1}{txtt}{m}{n}{12}  % for normal\n\n% Custom colors\n\\usepackage{color}\n\\definecolor{deepblue}{rgb}{0,0,0.5}\n\\definecolor{deepred}{rgb}{0.6,0,0}\n\\definecolor{deepgreen}{rgb}{0,0.5,0}\n\n% colors\n\\usepackage{graphicx,xcolor,lipsum}\n\n\n\\usepackage{mathtools}\n\n\\usepackage{graphicx}\n\\newcommand*{\\matminus}{%\n  \\leavevmode\n  \\hphantom{0}%\n  \\llap{%\n    \\settowidth{\\dimen0 }{$0$}%\n    \\resizebox{1.1\\dimen0 }{\\height}{$-$}%\n  }%\n}\n\n% commmand for this doc\n\\newcommand{\\So}{\\mathcal{S}}\n\\newcommand{\\bvth}{\\bar{\\vth}}\n\\newcommand{\\kappat}{\\kappa_{tot}}\n\\newcommand{\\kappae}{\\kappa_{e}}\n\\newcommand{\\kappaN}{\\kappa_{n}}\n\\newcommand{\\kappaoc}{\\kappa_{oc}}\n\n\n\\title{Notes on Modal Projection and non-zero vertical shear at the boundary, etc.}\n\\author{Cesar \\& Bill}\n\\date{\\today}\n\n\\begin{document}\n\n\\include{symbols}\n\n\n\\maketitle\n\n%\\section{}\n\nWe want to calculate the mean quasigeostrophic potential vorticity gradients:\n\\beq\n    \\label{meanQGPV}\n    Q_y = \\beta - \\sL V(z)\\com \\qquad \\text{and} \\qquad Q_x = \\sL U(z) \\com\n\\eeq\nwhere $\\sL \\defn \\p_z (f_0/N)^2 \\p_z $ is the stretching operator. Calculation of $\\sL U$ and $\\sL V$\nfrom data is typically noisy. To reduce the noise, we want to project the basic state velocity onto\nthe familiar vertical modes $\\sp_n$ that satisfy\n\\beq\n\\label{modes}\n\\sL \\sp_n = - \\kappa_n^2 \\sp_n\\com\n\\eeq\nwith $\\sp_n' = 0\\com~ z = -h, 0$. However, with nonzero vertical shear at the boundaries we cannot differentiate the series for $U(z)$ and $V(z) $. So, instead of the tradition series, we write\n\\beq\n\\label{decomp}\nU(z) \\approx U_s(z) + U_i(z)\\com\n\\eeq\nwhere $U_i(z)$ is an ``interior'', boundary shearless, velocity component:\n\\beq\n\\label{Uint}\nU_i(z) = \\sum_{n=0}^{\\nmax} \\breve{U}_n \\sp_n\\com \\qquad \\breve{U}_n = \\tfrac{1}{h}\\int_{-h}^{0}\\!\\! \\sp_n \\, [U(z)-U_s(z)]  \\dd z\\com\n\\eeq\nand $U_s(z)$ satisfies $U'(\\zm) = U_s'(\\zm)$ and  $U'(\\zp) = U_s'(\\zp)$. Also in \\eqref{decomp} the approximate sign stems from the truncated nature of the series \\eqref{Uint}. A simple choice is\n\\beq\n\\label{dUsurf}\n\\frac{\\dd U_s}{\\dd z} = \\frac{N^2(z)}{N^2(0)} \\frac{z + h}{h} U'(0) - \\frac{N^2(z)}{N^2(-h)} \\frac{z}{h} U'(-h)\\per\n\\eeq\nThe reason we include the $N^2$ factors above, e.g. $N^2(z)/N^2(0)$ is that we want to calculate $\\sL U_s$ as smoothly as possible, and hence independently of derivatives of $N^2(z)$. With this choice we have\n\\beq\n\\label{Usurf}\nU_s(z) = \\frac{U'(0)}{N^2(0) h}\\int_{0}^{z} N^2(z') (z' + h) \\dd z' -  \\frac{U'(-h)}{N^2(-h) h}\\int_{0}^{z} N^2(z') z'  \\dd z  + A \\com \n\\eeq\nwhere $A$ is determined by imposing a no net transport condition\n\\beq\n\\int_{-h}^{0} U_s'(z) \\dd z = 0\\per\n\\eeq\nWe obtain\n\\beq\n\\label{A}\nA =  -\\frac{U'(0)}{N^2(0) h^2}\\int_{-h}^0 \\dd z \\int_{0}^{z} N^2(z') (z' + h) \\dd z' +  \\frac{U'(-h)}{N^2(-h) h^2} \\int_{-h}^0 \\dd z  \\int_{0}^{z} N^2(z') z'  \\dd z\n\\eeq\nThe integrals above are calculated numerically for an arbitrary buoyancy profile $N^2(z)$. \n\n% for constant N(z) we calculate the integrals analytically\n%\\beq\n%\\label{A}\n%A = \\frac{1}{3 h }\\left( \\frac{U'(-h)}{2} - U'(0) \\right) \\per\n%\\eeq\n%Thus\n%\\beq\n%\\label{Usurf2}\n%U_s(z) = \\frac{U'(0)}{h}\\left( \\frac{z^2}{2} + z h - \\frac{1}{3}\\right) - \\frac{U'(-h)}{h} \\left(\\frac{z^2}{2} + \\frac{1}{6} \\right) \\per\n%\\eeq\n\n\nIn summary, knowledge of the shear at the boundaries determines the ``surface'' velocity component $U_s(z)$ that\ncan be then be subtracted from the total velocity to obtain a ``interior'' velocity component $U_i(z)$. Because $U_i(z)$ is shearless at the boundaries, we can accurately calculate $\\sL U$\n\\beq\n\\sL U \\approx \\sL U_s + \\sL U_i  = \\frac{f_0^2}{N^2(0)} \\frac{U'(0)}{h}\n- \\frac{f_0^2}{N^2(-h)} \\frac{U'(-h)}{h} - \\sum_{n=1}^{\\nmax} \\kappa_n^2 \\breve{U}_n \\sp_n \\per\n\\eeq\n\n\\end{document}\n", "meta": {"hexsha": "3cbd937e91cce3ac84eb8df4da4d0a88b4233179", "size": 5369, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "stability/tex/NotesModalProjection.tex", "max_stars_repo_name": "cesar-rocha/dp_spectra", "max_stars_repo_head_hexsha": "7909d07febccb4d227c8ddf5053bb1dba7b08350", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-04-26T12:05:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-01T09:12:13.000Z", "max_issues_repo_path": "stability/tex/NotesModalProjection.tex", "max_issues_repo_name": "crocha700/dp_spectra", "max_issues_repo_head_hexsha": "7909d07febccb4d227c8ddf5053bb1dba7b08350", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "stability/tex/NotesModalProjection.tex", "max_forks_repo_name": "crocha700/dp_spectra", "max_forks_repo_head_hexsha": "7909d07febccb4d227c8ddf5053bb1dba7b08350", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-11-07T20:55:01.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-20T22:20:59.000Z", "avg_line_length": 32.9386503067, "max_line_length": 208, "alphanum_fraction": 0.664928292, "num_tokens": 2050, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.43064538642755973}}
{"text": "\n\\chapter{\\projmr3 Catalog Analysis by the Two--Point Correlation Funciton}\n\n\\section{Definition}\n\\subsection{Introduction}\nThe two--point correlation function $\\xi(r)$ has been the primary tool\nfor quantifying large--scale cosmic structure\\cite{cf:peebles80}.\nAssuming that the galaxy distribution in the Universe is a realization\nof a stationary random process of density $\\rho$, the two--point\ncorrelation function can be defined from the probability $P$ to find\nan object within a volume element $\\delta v$ at distance $r$ from a\nrandomly chosen object or position inside the volume: \n\\begin{equation} \n\\delta P = n(1 + \\xi(r))\\delta v,\n\\end{equation} \nwhere $n$ is the mean density of objects.  The $\\xi(r)$ function\nmeasures the clustering properties of objects in a given volume. It is\nzero for a uniform random distribution, positive (resp.  negative) for\na more (resp. less) concentrated distribution. For a hierarchical\ngravitational clustering or fractal processus, $\\xi(r)$ has a power\nlaw behavior \n\\begin{equation} \n\\xi(r) \\sim r^{-\\gamma}.\n\\end{equation}\n\nIn an unbounded volume embedded in a three-dimensional Euclidean\nspace, we can compute $\\xi(r)$ by considering a large number of points\n$N$ and calculate the average\n\\begin{equation} \n1 + \\xi(r) = {N(r) \\over N_{p}(r)}\n\\end{equation} \nwhere $N(r)$ is the number of pairs of points with a separation in the\ninterval $[r-\\Delta r, r+\\Delta r]$, and $N_{p}(r)$ is the number of\npairs for a Poisson distribution in the same volume. As $N_{p}(r) =\n4\\pi r^2 n dr$, we have\n\\begin{equation} \n1 + \\xi(r) = {1 \\over N} \\sum_{i=1}^N {N_i(r) \\over 4\\pi r^2 n dr} \n\\end{equation} \nwhere $N_i(r)$ is the number of points lying in a shell of thickness\n$dr$, with radius $r$, and centered at the point labeled $i$.\nHowever, when the calculation has to be performed on a finite volume,\nthe effect of the edges has to be seriously considered.  For this\nreason, other estimators have been proposed, which consider the\nestimation of the volume around each data point by means of Monte\nCarlo random catalog generations. We present in this report a\ndescription of the most used estimators, and show the results obtained\nfor some samples with well-known or well-studied clustering\nproperties.\n\n\n \n\\subsection{The 2-points correlation function determination}\n\\subsubsection*{Standard method}\nGiven a catalogue containing $N_d$ points, we introduce a random\ncatalog with $N_R$ points, and note\n\\begin{itemize}\n\\item $DD(r)$ = number of pairs in the interval $(r \\pm dr/2)$ in the\n  data catalog.\n\\item $RR(r)$ = number of pairs in the interval $(r \\pm dr/2)$ in the\n  random catalog.\n\\end{itemize}\nThe two--point correlation function $\\xi(r)$ is derived from\n\\begin{equation}\n\\tilde \\xi(r) =  {N_R(N_R-1) \\over N_D(N_D-1)} {DD(r) \\over RR(r)} -1,\n\\label{std_method}\n\\end{equation}\nwhere $N_R(N_R-1)/2$ and $ N_D(N_D-1)/2$ are the number of pairs in\nthe random and data catalog. The ratio of this two values is a\nnormalization term.\n\n\\subsubsection*{Davis-Peebles method}\nDavis and Peebles \\cite{cf:davis83} have proposed a more robust\nestimator, by introducing $DR$, the number of pairs between the data\nand the random sample within the same interval.\n\\begin{equation}\n\\tilde \\xi_{DP}(r) =  2{N_R \\over N_D-1} {DD(r) \\over DR(r)} -1\n\\label{dp_method}\n\\end{equation}\n\n\\subsubsection*{Hamilton method}\nAnother possibility is to use Hamilton approach \\cite{cf:hamilton93},\nwhich corrects for a presence in the data of large-scale artificial\ncorrelation due to some periodicity caused by the volume boundaries or \nby some selection effects.\n\n\\begin{equation}\n\\tilde \\xi_{HAM}(r) =   {DD(r) RR(r) \\over [DR(r)]^2} -1\n\\label{ham_method}\n\\end{equation}\n\n\\subsubsection*{Landy-Szalay method}\nLandy-Szalay estimator \\cite{cf:landy93} was introduced with the goal\nto produce a minimum variance estimator and also like Hamilton\nestimator is not affected by large-scale correlations:\n\\begin{equation}\n\\tilde \\xi_{LS}(r) =  c_1 {  DD(r) \\over  RR(r)}  -  c_2 { DR(r) \\over \nRR(r)}\n\\label{ls_method}\n\\end{equation}\nwith\n\\begin{eqnarray}\nc_1 & = & {N_R(N_R-1)\\over   N_D(N_D-1)} \\nonumber \\\\  \nc_2 & = &  {2 N_R(N_R-1) \\over N_D N_R}\n\\end{eqnarray}\n\n\n\n\\subsection{Error analysis}\n\nAssuming the errors in the correlation function are distributed\nnormally (which is not completely true having in mind the\ncross-correlation in the different separation bins) we can estimate the\nuncertainty as a Poisson statistics for the corresponding errors in\nbins:\n\\begin{equation}\n\\Delta_{P} \\tilde \\xi(r) = {1 + \\tilde  \\xi(r) \\over \\sqrt{DD(r)}}\n\\label{eq_pois}\n\\end{equation}\n\nIf $C$ random catalogs $R_1, ..., R_C$ are created instead of one,\nthen $\\tilde \\xi(r)$ can be estimated $C$ times, and our final\nestimate is:\n\\begin{equation}\n\\tilde \\xi(r) = {1 \\over C }\\sum_{i=1}^C \\tilde \\xi_i(r)\n\\end{equation}\nand the error is obtained by\n\\begin{equation} \n\\Delta_{STD} \\tilde \\xi(r) = \\sqrt{ (\\tilde \\xi_i(r) -\n  \\tilde \\xi(r))^2 \\over C-1} \n\\label{eq_std}\n\\end{equation}\n\nFinally, a third approach is also popular, and consists in using a\nbootstrap method \\cite{cf:efron86}. $C$ bootstrap samples $B_1,..,B_C$\nare created by taking randomly with replacement the same number of\npoints that form the original sample. Then the bias-corrected 68\\%\nbootstrap confidence interval is\n$[\\xi_{boot}(0.16),\\xi_{boot}(0.84)]$, where\n\\begin{equation} \\xi_{boot}(t) = G^{-1}\\left\\{\\Phi\\left[\\Phi^{-1}(t) +\n      2\\Phi^{-1}\\left[G(\\xi_0)\\right]\\right]\\right\\}.  \n\\label{eq_boot}\n\\end{equation} \n\nHere $G$ is the cumulative distribution function (CDF) of the $\\xi(r)$\nvalues, for a given bin $r \\pm \\Delta r$, for all bootstrap\nresamplings, $\\Phi$ is the CDF of the normal distribution, $\\Phi^{-1}$\nis its inverse function and $\\xi_0$ is the estimated $\\xi(r)$ taken\nfrom other than the bootstrap resampling results (e.g. from random\ncatalog generations). Note that $\\Phi(0.16) = -1.0$ and $\\Phi(0.84) =\n1.0$.\n\nThis confidence estimator, as the authors \\cite{cf:efron86} claim, is\nvalid when $G$ is not Gaussian. However, this method requires a large\nnumber of bootstrap resamplings (usually more than 100) and for large\ndatasets with tens of thousands of points it becomes quite time\nconsuming.\n\nNote that we can take also the $\\Delta^{boot}_{STD}$ for the bootstrap\nresamplings and then it can be simply written --\n$[\\xi_{boot}(0.16),\\xi_{boot}(0.84)] = \\xi_0 \\pm \\sigma_{\\xi}$,\nwhere\n\\begin{equation} \n\\sigma_{\\xi} = \\sqrt{ (\\xi^{i}_{boot}(r) - \\xi_{0}(r))^2 \\over B-1}.\n\\end{equation} \n\n\n\\subsection{Correlation length determination}\n\nThe two-point correlation function for the gravitational clustering or \nfractal distribution can be given as a power low:\n\\begin{eqnarray}\n \\xi(r) = A r^{-\\gamma}\n\\end{eqnarray}\nWhere $A$ is the amplitude and $\\gamma$ is the power low index.\n\nThe correlation length $r_c$ is defined by\n\\begin{eqnarray}\n \\xi(r) = ({r\\over r_c}) ^{-\\gamma},\n\\end{eqnarray}\nand it is the separation at which the correlation is 1. This scale in\nprinciple divides the regime of strong, non-linear clustering ($\\xi >> \n1$) from linear clustering.\n\nIt is easy to connect $r_c$ with $A$ and $\\gamma$ by:\n\\begin{eqnarray}\nr_c = \\exp^{-{A \\over \\gamma}}\n\\end{eqnarray}\n\n\n\n\\section{Application}\n\\subsection{Simulation of Cox process}\n\nThe segment Cox point process \\cite{cf:pons99} is a clustering process\nfor which an analytical expression of its 2--point correlation\nfunction is known and therefore can be used as a test to check the\naccuracy of the $\\xi$--estimators.  segments of length $l$ are\nrandomly scattered inside a cube $W$ and on these segments points are\nrandomly distributed.  Let $L_V$ be the length density of the system\nof segments, $L_V=\\lambda_{\\rm{s}}l$, where $\\lambda_{\\rm{s}}$ is the\nmean number of segments per unit volume. If $\\lambda_l$ is the mean\nnumber of points on a segment per unit length, then the intensity\n$\\lambda$ of the resulting point process is\n\n\\begin{equation}\n\\lambda=\\lambda_lL_V=\\lambda_l\\lambda_{\\rm{s}}l\\,.\n\\end{equation}\n\nFor this point field the correlation function can be easily calculated\ntaking into account that the point field has a driving random measure\nequal to the random length measure of the system of segments. It has\nbeen shown \\cite{cf:stoyan95} that\n  \\begin{equation}\n\\xi_{\\rm {Cox}}(r)=\\frac{1}{2\\pi r^2L_V}-\\frac{1}{2\\pi rlL_V} \\label{skm}\n\\end{equation}\nfor $r \\le l$ and vanishes for larger $r$. The expression is\nindependent of the intensity $\\lambda_l$.  Figure~\\ref{fig_cox_cube}\nshow the simulation of a Cox process with 6000 points.\nFigure~\\ref{fig_cox_curve} shows the analytical $\\xi_{\\rm {Cox}}(r)$\ncurve (continuous line), and the estimated two--point correlation\nfunction overplotted. The Landy-Szalay method has been used with 10000\nrandom points. The errors are the results from 20 random Cox process\nrealizations.\n \n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_cox.ps,bbllx=2.5cm,bblly=13.5cm,bburx=18.5cm,bbury=25cm,width=14cm,height=14cm,clip=}\n}}\n\\caption{Simulation of a Cox process with 6000 points.}\n\\label{fig_cox_cube}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_coxcurve.ps,bbllx=2.cm,bblly=1cm,bburx=18cm,bbury=17cm,width=10cm,height=8cm,clip=}\n}}\n\\caption{Analytical $\\xi_{\\rm {Cox}}(r)$ curve (continuous line), and\n  two--point correlation function of the Cox process with 6000 points\n  overplotted, using the Landy-Szalay method.  The error bars are\n  obtained from the minimum and maximum of twenty realizations.}\n\\label{fig_cox_curve}\n\\end{figure}\n\n\n% \\section{Limitation}\n% \\begin{itemize}\n% \\item the evaluation of ${\\cal \\epsilon}$ depends on the size of the\n%   sampled volume.\n% \\end{itemize}\n \n\\subsection{Two--point correlation of astronomical catalogues}\n\n\\subsubsection{Introduction}\nUsually the catalogues of the extragalactic objects contain the\nangular coordinates of the objects (galaxies, groups, clusters,\nsuperclusters, voids) on the sky -- in equatorial coordinate system\nthey are right ascension ($\\alpha$) and declination ($\\delta$),\ngalactic longitude ($l$) and galactic latitude ($b$) in galactic\ncoordinates and supergalactic longitude ($SL$) and supergalactic\nlatitude ($SB$) in supergalactic coordinates. The recent\nextragalactic catalogues could contain many objects with their\nrespective redshift $z$ so in principle it is possible to transform\nthe angular coordinates + redshift to a rectangular coordinates\nsystem. To do this one has to assume a cosmological model ($H_0,\\ \nq_0$) in order to transform the redshift to the distance in Mpc and\nalso to choose which distance measure to use (e.g. ``luminosity\ndistance'', ``angular diameter distance'', ``comoving distance'').\n\nThe choice for the angular coordinate system depends on the problem\nand it is convenient to use that system for which the catalogue\nboundaries could be most easily defined. For the distance, the\nsituation in the literature is quite confused with various authors\nusing various distance measures. \n\nAlso all the methods for estimation of the correlation function could\nwork also for the particular case of having only angular positions on\nthe sky. This is the case for example in catalogs from radio\nobservations where there is no information for the distance. Then\nusually the correlation function, denoted $w(\\theta)$ is a function on \nthe angular separation $\\theta$.\n\n\n\\subsubsection{Creation of random catalogs}\nOne of the crucial steps in estimation of the correlation function is\nthe random catalogue creation. The catalogues contain data which is\nsubject to various selection effects and incompleteness. Not taking\nthem into account could lead to false correlation. The major effects\nare the distance selection function -- the number of objects as a\nfunction of the distance, and the galactic latitude\nselection function. \n\nThe first effect is caused by the geometry of space-time and the\ndetection of only the strongest objects at a great distances. For\nuniform distribution of points in 3D Euclidean space $N(R) \\sim\nR^{-3}$.  \n\nThe second effect is caused by light absorption from our Galaxy and it \ndepends on the galactic latitude. Usually it is modeled as a cosec \nfunction and in terms of probability density function it could be\ngiven:\n\\begin{equation}\nP(b) = 10^{\\alpha(1-cosec|b|)}.\n\\end{equation}\n\nThese two effects after their correct treatment from the data\ncatalogue must be included in the random catalogue generation.\n\nAs the different catalogs of objects are subject to different\nselections, it is not possible to make one single procedure for random\ncatalog generations. We have supplied however versions for some\ninteresting particular cases.\n\n\n\n\n\\subsubsection{Application to IRAS data}\n\nWe present in this section the two points correlation function\nanalysis of the IRAS 1.2 Jy Redshift Survey \\cite{cf:fisher95} for a\nvolume limited subsample.\n\nIn order to create a volume limited subsample from the IRAS catalog,\nwe applied the following steps:\n\n\\begin{itemize}\n\\item Extract from the catalog the Right Ascension $\\alpha$ (hh,mm,ss,1950), \nthe declination $\\delta$ (sign,dg,mm,ss,1950), and the velocity $Hvel$ (km/s).\n\\item Convert $\\alpha,\\ \\delta$ to galactic coordinates $l,b$ (in radians)\n  because the catalog boundaries ($|b| > 5 \\deg$) are most easily\n  defined in this system.\n\\item Convert velocity to redshift ($z= Hvel/c$).\n\\item Assuming $H_0=100$ and $\\Omega=1$, calculate the distance $d$ by the\nluminosity distance formulae proposed by Ue-Li Pen (astro-ph/9904172):\n\\begin{eqnarray}\nd_L & = & {c \\over H_0}(1+z) [ F(1,\\Omega_0) - F({1 \\over 1 + z}, \\Omega_0)] \\nonumber  \\\\\nF(a,\\Omega_0) & = & 2 \\sqrt{s^3+1} \n[ {1 \\over a^4} - 0.1540 {s \\over a^3} + 0.4302 {s^2 \\over  a^2} +  \n        0.19097*{s^3 \\over a} + 0.066941 s^4 ]^{-{1\\over 8}}  \\nonumber  \\\\\n s^3 & = & {1 - \\Omega_0 \\over \\Omega_0 }\n\\end{eqnarray}\n\\item Select galaxies (statusflag in [O,H,Z,F,B,D,L]) with \ndistance $ d < 100$ Mpc, and flux $F_{60\\mu m} > 1.2$ Jy in the galaxy rest\nframe. So the luminosity of a galaxy is given by:\n\\begin{eqnarray}\n  L = 4\\pi d^2 F_{60\\mu m} \n  \\end{eqnarray}\n  and the luminosity of a galaxy at the limiting distance (100 Mpc)\n  with the limiting flux (1.2 Jy) is\n  \\begin{eqnarray}\n  L_{limit} = 4\\pi 100^2 1.2 \n  \\end{eqnarray}\n  We select all the galaxies with $L$ larger than $L_{limit}$.\n\\item Calculate the coordinates in a cube:\n\\begin{eqnarray}\n X  & = & d \\cos(b) \\cos(l) \\nonumber \\\\\n Y  & = & d \\cos(b) \\sin(l) \\nonumber \\\\\n Z  & = & d \\sin(b)\n\\end{eqnarray}\n\\item Creates the catolog IRAS in the correct format (see program section).\n\\end{itemize}\n\n\nFigure~\\ref{fig_iras} shows the galaxies positions.\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_iras.ps,bbllx=4.5cm,bblly=2.5cm,bburx=19cm,bbury=10cm,width=15cm,height=8cm,clip=}\n}}\n\\caption{Aitoff equal-area projection in galactic coordinates of \n  IRAS galaxies with $F_{60\\mu m} > 1.2$ Jy and distance $<$\n  100 Mpc. Their total number is 710.}\n\\label{fig_iras}\n\\end{figure}\n\nThe result for the redshift space correlation function for the\ncombined north+south IRAS catalog is presented on\nfig.~\\ref{fig_iras2}. The result is quite consistent with published\nresults for this catalog \\cite{cf:fisher95}:\n\\begin{eqnarray}\nr_0 = 4.27^{+0.66}_{-0.81} \\mbox{ and } \\gamma = 1.68^{+0.36}_{-0.29}\n\\end{eqnarray}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_iras_lin.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{Correlation function of the IRAS galaxies in linear bins with \n  the corresponding linear least square fit for the data in separation\n  range 1 -- 20 Mpc.}\n\\label{fig_iras2}\n% \\end{figure}\n\n% \\begin{figure}[hb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_iras_log.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{Correlation function of the IRAS galaxies in logarithmic bins with \n  the corresponding linear least square fit for the data in separation \n  range 1 -- 20 Mpc.}\n\\label{fig_iras3}\n\\end{figure}\nFor comparison we present the correlation function for the same data\ncatalog but in logarithmic separation bins. As it is clear from\nfig.~\\ref{fig_iras3}, the strong fluctuations for the correlation\nfunction for large separations is quite smoothed.\n\n\n\\subsubsection{Application to numerical simulations -- $\\Lambda$CDM\n  model}\n\nFor cosmological studies it is very important to test the predictions\nof various cosmological models for the clustering properties of the\nmatter and to put constraints on various parameters by analyzing the\nresults from numerical simulations and their correspondence to what is\nobserved. Because in simulations we have all the parameter space of\nthe objects (coordinates, velocities, masses ...) it is a natural to\nexamine the clustering properties by means of various statistical\ntools used in the analysis of the observational data: correlation\nfunctions, power spectrum analysis, ...\n\nWe will present here the results for the correlation function for one\ncosmological model ($\\Lambda CDM,\\ h = 0.7,\\ \\Omega_0 = 0.3,\\\n\\Omega_\\Lambda = 0.7$) from a Hubble volume simulation. The data\nare available at the following address: \\\\\nhttp://www.physics.lsa.umich.edu/hubble-volume \\\\\n\nWe have extracted a\nvolume limited slice with objects with redshift less than 0.4 (for the\ncosmological model this corresponds to 1550 Mpc). The view of the data\nis presented on fig.~\\ref{fig_lcdm1} for XY plane and on\nfig.~\\ref{fig_lcdm2} for XZ plane. All the points represent groups or\nclusters of galaxies with masses greater than $\\sim 6.6 \\times 10^{13}\nM_{*}$.\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_lcdm_xy.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{The XY plane view of the $\\Lambda CDM$ slice used for the\n  correlation function analysis. The opening angle is 45 deg. and the\n  total number of objects is 6002.}\n\\label{fig_lcdm1}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_lcdm_xz.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{The XZ plane view of the $\\Lambda CDM$ slice.}\n\\label{fig_lcdm2}\n\\end{figure}\n\nThe results with the corresponding linear least squares fit are\npresented on fig.~\\ref{lcdm_fig3} for linear separation bins and on\nfig.~\\ref{lcdm_fig4} for logarithmic.\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_lcdm_lin.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{The correlation function of $\\Lambda CDM$ model for linear\n  separation bins. The fit is done in 1--50 Mpc separations and the\n  error bars are the standard deviations of 5 random catalog\n  generations (the second method for estimating the uncertainty of the \n  correlation function -- $\\Delta_R$).}\n\\label{lcdm_fig3}\n\\end{figure}\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_lcdm_log.ps,bbllx=2cm,bblly=1cm,bburx=18cm,bbury=17cm,width=8cm,height=8cm,clip=}\n}}\n\\caption{Same as fig.~\\ref{lcdm_fig3} but for logarithmic separation bins.}\n\\label{lcdm_fig4}\n\\end{figure}\n\nThe results are consistent with the normalization used in the\nsimulations -- the clustering properties of the simulation should\ncorrespond to the observed clustering for redshift of 0 ($r_0 \\approx\n15,\\ \\gamma \\approx 1.8$).\n\n\\clearpage\n\\newpage\n\n\\section{Program}\n\n\\subsection{Catalogue format}\nThe catalogue format is the following:\n\\begin{itemize}\n\\item the first line must contain the number of points $N$, the\n  dimension $D$ (1,2, or 3), and the coordinate system $S$ ($S$ = 1 or\n  2).  The recognized coordinate systems are:\n  \\begin{enumerate}\n  \\item $X$ and/or $Y$ and/or $Z$ Euclidien system.\n  \\item Angular coordinate system (longitude, latitude and/or\n    distance; that could be the equatorial system -- right ascension\n    $\\alpha$, declination $\\delta$, the galactic coordinate system\n    with galactic longitude $l$, galactic latitude $b$, the\n    supergalactic coordinate system with $SL$ and $SB$ etc.).\n  \\end{enumerate}\n\\item the $D$ following lines must contains three values: the range of\n  variation of the $i-th$ coordinate (min,max) and a flag indicating\n  the generation model for the corresponding coordinate: 0 -- uniform\n  between [min,max], 1 -- bootstrapping the coordinate and 2 -- uniform\n  on sphere between [min,max] in degrees. When the user have supplied\n  its own generated random catalogs, then those three lines are\n  ignored.\n\\item the $N$ following lines contains the coordinates of the points.\n\\end{itemize}\n\nAn example of a 3D catalogue, with 10 points in the Euclidien system,\neach coordinate being defined in the interval $[0,100]$ and random\ncatalog coordinates uniform in [0,100] for each axis, is:\n\\begin{verbatim}\n       10       3           1\n       0      100.000       0\n       0      100.000       0\n       0      100.000       0\n      42.1782      13.4610      73.7444\n      41.6855      9.82727      75.3605\n      42.3580      14.7867      73.1548\n      42.0255      12.3347      74.2453\n      42.7474      17.6581      71.8777\n      41.9410      11.7113      74.5226\n      65.5637      9.84036      71.3585\n      65.7140      12.6019      70.5645\n      65.5843      10.2196      71.2495\n      65.4521      7.79074      71.9479\n\\end{verbatim}\n\n\n\\subsection{Random catalogue simulations}\n\nThere is one random catalog simulation incorporated inside the main\nprocedure and it is using the header information from the data\ncatalog. In that case the user must supply the min, max and type of\nthe corresponding coordinate generation, e.g. uniform from min,max\netc. as described in the previous section.\n\nHowever, this simple case is not applicable for the real observed\ncatalogs, which in all cases are subject to selections and occupy\ndifferent volumes with complicated geometry. That's why it is quite\nimpossible to implement a dedicated procedure for this task. We have\nimplemented however a possibility for user to create his own set of\nrandom catalogs and to feed them to the correlation analysis\nprocedure. The only required information for the random catalogs\n(aside from the coordinates of the random points) should be given on\nthe first line: number of random points, number of dimensions and the\ntype of the coordinate system.\n\nWe givem as an examplem in the IDL routine section two such procedures \nfor the data presented in the report:\n\n\n\\subsection{two--point correlation function: cf\\_ana}\nProgram {\\em cf\\_ana} estimates the two--point correlation function of\na 1D,2D, or a 3D data set between two points separations, {\\em SepMin} and\n{\\em SepMax}, and with a given step (separation bin width). \\\\\n\nThe output file (fits format) contains a 2D array $T$, with:\n\\begin{itemize}\n\\item $T(*,0) = $ distance\n\\item $T(*,1) = $ two--point correlation function using the standard\n  method.\n\\item $T(*,2) = $ Poisson error (eq.~\\ref{eq_pois}).\n\\item $T(*,3) = $ standard deviation error (eq.~\\ref{eq_std}).\n\\item $T(*,4) = $ bootstrap error (eq.~\\ref{eq_boot}).\n\\end{itemize}\nThe bootstrap catalogs are created and bootstrap errors are calculated\nonly if the number of realization is larger or equal than 20.  If the\n\"-A\" option is set, all estimators are used and the second dimension\nof $T$ is 17 instead of 5. Data from $T(*,1)$ to $T(*,4)$ concern the\nfirst method (standard one), $T(*,5)$ to $T(*,8)$ the second\n(Davis-Peebles one), $T(*,9)$ to $T(*,12)$ the third, and $T(*,13)$ to\n$T(*,16)$ the last one (Landy-Szalay).\n\nBy default, random catalogues are calculated, but they can be read\nfrom the disk using the \"-r {\\em Prefix\\_FileName}\" option.  In this\ncase, files must have the correct names, {\\em PREFIX\\_rnd\\_i.dat},\nwhere is $i$ the simulation number.  This option has the advantage to\nallows the user to use its own random catalog simulations.\n\n\\begin{center}\n  USAGE: cf\\_ana options catalog.dat cf.fits\n\\end{center}\nwhere options are \n\\begin{itemize}\n\\item {\\bf [-I InitRandomVal]} \\\\\n  Value used for random value generator initialization. \\\\\n  Default is 100.\n\\item {\\bf [-n NbrRnd]} \\\\\n  Number of random points used in the random realization.  Default is\n  the number of data points.\n\\item {\\bf [-g NbrSimu]} \\\\\n  Number of realizations used to calculate the random error\n  and the bootstrap error. \\\\\n  Default is 20.\n\\item {\\bf [-L]} \\\\\n  Use logarithmic steps. Default is no.\n\\item {\\bf [-s Step]} \\\\\n  Pair separations bin size. Default is 1.\n\\item {\\bf [-m SepMin]}  \\\\\n  Pair separations min. Must be set.\n\\item {\\bf [-M SepMax]}  \\\\\n  Pair separations max. Must be set.\n\\item {\\bf [-C CF\\_Method]} \\\\\n  Two-points correlation function calculation method\n\\begin{enumerate}\n\\item Standard method (eq.\\ref{std_method})\n\\item Davis-Peebles method (eq.\\ref{dp_method})\n\\item Hamilton method (eq.\\ref{ham_method}) \n\\item Landy-Szalay method (eq.\\ref{ls_method})  \n\\end{enumerate}             \nDefault is Landy-Szalay method.\n\\item {\\bf  [-r Prefix\\_FileName]} \\\\\n Read from the disk the simulated random catalogue files.\n Default is no. \n\\item {\\bf [-w prefix\\_file\\_name]} \\\\\n  Write to the disk intermediate files. It is mainly for\n  cross-checking and debugging. In addition to the random and\n  bootstrap catalogues, five files are written:\n\\begin{enumerate}\n\\item prefix\\_cf\\_data\\_data.fits: contains the 1D $DD$ data set, the number\n  of pairs in the data catalog in each bin.\n\\item prefix\\_cf\\_rnd\\_rnd.fits: contains the 2D $RR$ data set, the number of\n  pairs for each realization in the random catalogue.\n\\item prefix\\_cf\\_data\\_rnd.fits: contains the 2D $DR$ data set, the number of\n  pairs for each realization of the random catalogue between the data\n  and random points.\n\\item prefix\\_cf\\_boot\\_boot.fits: contains the 2D $DD$ data set, the number\n  of pairs for each realization in the bootstrap catalogue.\n\\item prefix\\_cf\\_boot\\_rnd.fits: contains the 2D $DR$ data set, the number\n  of pairs for each realization of the random catalogue between the\n  bootstrap and the random catalogue.\n\\end{enumerate}\nDefault is no writing. \n\\item {\\bf [-A]} \\\\\nApply all methods. The two point--correlation function is calculated\nfor all four methods.  \n \\item {\\bf [-v]} \\\\\nVerbose\n\\end{itemize}\nExamples:\n\\begin{itemize}\n\\item {\\tt cf\\_ana -v -g 5 -s 0.5 -m 0 -M 10 -n 10000 -C 2 input.dat\n    result.fits}\\\\ Calculates the two--point correlation function of\n  the input data, with number of random points equal to $10^4$ using\n  Davis-Peebles estimator, for distance between 0 and 10, with a bin\n  size equal to 0.5 and 5 generations of random catalogs generated by\n  the supplied model for each coordinate generation in the input.dat 4\n  header lines.\n\\item {\\tt cf\\_ana -g 5 -v -s 0.5 -m 0 -M 10 -n 10000 -A -r random\n    input.dat result.fits}\\\\ Ditto, but all estimators are calculated\n  and the random catalogs named random\\_rnd\\_0.fits \\dots\n  random\\_rnd\\_5.fits (generated by the user) are read from disk.\n\\end{itemize}\n\n\\subsection{IDL routines}\n\n\\subsubsection{IDL Cox Process routine: cox\\_data}\nProgram {\\em cox\\_data} creates a Cox process. \n\\begin{center}\n     USAGE:  COX\\_DATA, length=length, np=np, nseg=nseg, lcube=lcube,x, y, z, \nrandval=rndval, file=file\n\\end{center}\nwhere\n\\begin{itemize}\n\\item {\\em length} = length of the segments. Default is 10.\n\\item {\\em np } = number of points per segment. Default is 6.\n\\item {\\em nseg} = number of segments. Default is 1000.\n\\item {\\em lcube } = the length of the cube volume. Default is 100.\n\\item {\\em file } = file name. If set, the data are printed in a ascii\n  file\n\\item {\\em randval } = parameter for the random value generator.\n\\item {\\em X,Y,Z} = output 1D vector of the same size containing the\n  coqordinate values of the points.\n\\end{itemize}\n\n\\subsubsection{IDL Cox plot routine: plot\\_cox}\nProgram {\\em plot\\_cox} plots the result of the two point correlation\nfunction analysis of a Cox process. If input parameter is not given,\nthis routine just plots the COX process.\n\\begin{center}\nPLOT\\_COX, Result, method=method, err=err\n\\end{center}\nwhere\n\\begin{itemize}\n\\item {\\em method }= int: if the -A option was used when running cf\\_ana,\nseveral methods are available for estimation the two points correlation function:\n\\begin{enumerate}\n\\item Standard method ($DD/RR-1$)  \n\\item Davis-Peebles method ($DD/DR-1$) \n\\item Hamilton method ($DD*RR/(DR^2) - 1$) \n\\item Landy-Szalay method ($DD/RR - DR/(2RR)$)  \n\\end{enumerate}\nDefault is 1.\n\n\\item {\\em err }= int: For each method the error is calculated by different\nways:\n\\begin{enumerate}\n\\item Poisson error.\n\\item From the standard deviation.\n\\item From the bootstrap bias-corrected interval.\n\\end{enumerate}\nDefault is 1.\n\\end{itemize}\n\n\n\\subsubsection{IDL 3D plot routine: plot\\_xyz}\nProgram {\\em plot\\_xyz} plots a set of points in a cube.  If the\nfilename keyword is specified, the data are plotted in a postcript\nfile.z=0 is at the bottom of the cube.\n\\begin{center}\n  USAGE: PLOT\\_XYZ, X,Y,Z, col=col, filename=filename, land=lan\n\\end{center}\nwhere\n\\begin{itemize}\n\\item {\\em X,Y,Z} = input 1D vector of the same size containing the\n  coordinate values of the points.\n\\item {\\em  col } =  color value of the axes. Default is no color.\n\\item {\\em filename} = if set, the plot is printed in a postcript\n  file.\n\\item {\\em land }= int: if set, and filename is set, the lanscape\n  mode is activated.\n\\end{itemize}\n\n\\subsubsection{IDL correlation function plot routine: plot\\_cf}\n\nProgram {\\em plot\\_cf} plots the result of the two point correlation \nfunction analysis (see program {em cf\\_ana}).\n\n\\begin{center}\nPLOT\\_CF, Result, method=method, err=err, last=last, XR=XR, YR=YR\n\\end{center}\nwhere\n\\begin{itemize}\n\\item {\\em method }= int: if the -A option was used when running cf\\_ana,\nseveral methods are available for estimation the two points correlation function:\n\\begin{enumerate}\n\\item Standard method ($DD/RR-1$)  \n\\item Davis-Peebles method ($DD/DR-1$) \n\\item Hamilton method ($DD*RR/(DR^2) - 1$) \n\\item Landy-Szalay method ($DD/RR - DR/(2RR)$)  \n\\end{enumerate}\nDefault is 1.\n\n\\item {\\em err }= int: For each method the error is calculated by different\nways:\n\\begin{enumerate}\n\\item Poisson error\n\\item From the standard deviation.\n\\item From the bootstrap bias-corrected interval.\n\\end{enumerate}\nDefault is 1.\n\\item {\\em last }= int: Do not plot the last N points.\n\\item {\\em XR }= int[2]: Xrange. Default is  $[0.1, 100]$\n\\item {\\em YR }= int[2]: Yrange. Default is  $[0.01, 100]$\n\\end{itemize}\n\n\\subsubsection{IDL luminosity distance calculation routine: ldist}\nProgram {\\em ldist}  calculates the luminosity distance \nfrom any given redshift for any \ncosmological model with $H_0$ and  $\\Omega_0$\n(Source: Ue-Li Pen, astro-ph/9904172).\n\\begin{center}\n    Result = LDIST(z, omega0=omega0, h0=h0)\n\\end{center}\nwhere\n\\begin{itemize}\n\\item {\\em  omega0 }= float: $\\Omega_0$ value. Default is 1.\n\\item {\\em  h0}= float: $H_0$ value  Default is 100.\n\\end{itemize}\n\n\n\\subsubsection{IRAS random catalog creation}\nProgram {\\em iras\\_random} creates random \ncatalogs for the IRAS 1.2 Jy survey. It creates in the current directory \n{\\em ngen} number of files named \"prfx\\_rnd\\_\\#\\.dat\", each one containing \none random realization with one header line describing the number of points,\nthe dimensions and the coordinate system type.\n\\begin{center}\n    iras\\_random,input\\_catalog,nran=nran,ngen=ngen,ver=ver,prfx=prfx,seed=seed,boot=boot\n\\end{center}\n\\begin{itemize}\n\\item {\\em  input\\_catalog }= string: the name of the IRAS 1.2Jy catalog with the\n                       required 4 header lines. The last 3 ignored for \n                       this particular case. \n\\item {\\em  nran }= int: the number of random points. If not set, then it is\n              equal to the number of data points in the input catalog.\n\\item {\\em  ngen }= int: the number of random catalog generations. Default to\n              10.\n\\item {\\em  ver}= int: which version of random catalog creation: \n\\begin{itemize}\n\\item {ver=1} - IRAS 1.2 Jy north\n\\item {ver=2} - IRAS 1.2 Jy south\n\\item {ver=3} - IRAS 1.2 Jy north+south.\n\\end{itemize}\nThe default is ver=3.\n\\item {\\em  prfx}= string: the prefix of the files created. The full name \nwill be \"prfx\\_rnd\\_\\#\\.dat\", where \\# is the generation number. The\ndefault prefix is \"random\".\n\\item {\\em  seed }= int:  the random seed.\n\\end{itemize}\n\n\\subsubsection{$\\Lambda$CDM random catalog creation}\nProgram {\\em lcdm\\_random} creates random catalogs \nfor the LCDM numerical simulation.\nIt creates in the current directory \n{\\em ngen} number of files named \"prfx\\_rnd\\_\\#\\.dat\", each one containing \none random realization with one header line describing the number of points,\nthe dimensions and the coordinate system type.\n  \n\\begin{center}\n    lcdm\\_random,input\\_catalog,nran=nran,ngen=ngen,prfx=prfx,seed=seed\n\\end{center}\n\\begin{itemize}\n\\item {\\em  input\\_catalog }= string: the name of the LCDM simulation data \n                       with the required 4 header lines. The last 3 ignored \n\t\t       for this particular case. \n\\item {\\em  nran }= int: the number of random points. If not set, then it is\n              equal to the number of data points in the input catalog.\n\\item {\\em  ngen }= int: the number of random catalog generations. Default to\n              10.\n \\item {\\em  prfx}= string: the prefix of the files created. The full name \nwill be \"prfx\\_rnd\\_\\#\\.dat\", where \\# is the generation number. The\ndefault prefix is \"random\".\n\\item {\\em  seed }= int:  the random seed.\n\\end{itemize}\n \n \n\n", "meta": {"hexsha": "f8e7234bc7a95159182d29ddd84e66f70b17c594", "size": 33390, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr3/ch_cf.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr3/ch_cf.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr3/ch_cf.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.75, "max_line_length": 103, "alphanum_fraction": 0.7321353699, "num_tokens": 9792, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.4306453805443802}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{./resources/pdf/logo.pdf}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 02/08/21\n\n\\chapter{Hausdorff and Packing Measures and Dimensions}\n\\label{cha:hausdorff_and_packing_measures_and_dimensions}\n\n\\begin{defn}\n\tLet \\(F\\) be a subset of \\(\\R^{n}\\) and \\(s\\geq 0\\). For each \\(\\delta>0\\), define\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s}_{\\delta}(F) = \\inf \\left\\{\\sum_{i=1}^{\\infty} \\left| U_i \\right|^{s} \\mid \\left\\{ U_i \\right\\} \\text{ is a \\(\\delta\\)-cover of \\(F\\)} \\right\\} .\n\t\\end{align*}\nThe Hausdorff dimension looks at all covers of \\(F\\) of a certain dimension, and minimizes the \\(s\\)-th power of the diameters of the covering set. Notice that as \\(\\delta\\) decreases, the class of permissible covers in \\(F\\) is reduced, and so the infimum increases. This gives us\n\\begin{align*}\n\t\\mathcal{H}^{s}(F) = \\lim_{\\delta \\to 0} \\mathcal{H}^{s}_{\\delta}(F)\n\\end{align*}\nwhich we define the \\textbf{\\(s\\)-dimensional Hausdorff measure of \\(F\\)}. This limit exists for any subset \\(F\\), but it can and will usually be \\(0\\) or \\(\\infty\\).\n\\end{defn}\nIn fact, \\(\\mathcal{H}^{s}\\) is a measure. Hausdorff measure generlizes the typical ideas of length, area, volumne, and in fact for subsets of \\(\\R^{n}\\), \\(n\\)-dimensional Hausdorff measure is within a constant multiple of \\(n\\)-dimensional Lebesgue measure. In particular, if \\(F\\) is a Borel subset of \\(\\R^{n}\\), then\n\\begin{align*}\n\t\\mathcal{H}^{n}(F) = c^{-1}_n \\textrm{vol}^{n}(F)\n\\end{align*}\nwhere \\(c_n\\) is the volume of an \\(n\\)-dimensional ball of diameter \\(1\\).\n\n\\begin{prop}\n\tLet \\(F\\subset \\R^{n}\\) and \\(f:F\\to \\R^{m}\\) be a Holder mapping-- that is, it satisfies\n\t\\begin{align*}\n\t\t\\left| f(x) - f(y) \\right| \\leq c \\left| x-y \\right|^{\\alpha} \\quad \\forall x,y \\in F\n\t\\end{align*}\n\tfor constants \\(\\alpha > 0\\) and \\(c > 0\\). Then for each \\(s\\),\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s / \\alpha}(f(F)) \\leq c^{s / a}\\mathcal{H}^{s}(F).\n\t\\end{align*}\n\tIn particular, if \\(f\\) is a Lipschitz mapping, then\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s}(f(F)) \\leq c^{s}\\mathcal{H}^{s}(F).\n\t\\end{align*}\n\\end{prop}\n\n\\begin{prop}[Scaling Property]\n\tLet \\(f:\\R^{n}\\to \\R^{n}\\) be a similarity transformation of scale factor \\(\\lambda>0\\). If \\(F\\subset \\R^{n}\\), then\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s}(f(F)) = \\lambda^{s}\\mathcal{H}^{s}(F).\n\t\\end{align*}\n\\end{prop}\n\n\\section{Hausdorff Dimension}\n\\label{sec:hausdorff_dimension}\n\nUsing the robustness of the Hausdorff dimension, we can better construct a definition of dimension.\\\\\n\nObserve that for \\(\\delta<1\\), \\(\\mathcal{H}^{s}_{\\delta}(F)\\) is non-increasing with \\(s\\). In particular, for \\(t>s\\)\n \\begin{align*}\n\t \\mathcal{H}^{t}_\\delta(F) \\leq \\delta^{t-s}\\mathcal{H}^{s}_{\\delta}(F).\n\\end{align*}\nThis seems to imply that there is some critical value of \\(s\\) at which \\(\\mathcal{H}^{s}(F)\\) jumps from \\(\\infty\\) to \\(0\\). This critical value is what we call the Hausdorff dimension.\n\n\\begin{defn}\n\tLet \\(F \\subset \\R^{n}\\). Then the \\textbf{Hausdorff dimension} of \\(F\\) is\n\t\\begin{align*}\n\t\t\\textrm{dim}_H F := \\inf \\left\\{s \\geq 0 \\mid \\mathcal{H}^{s}(F) = 0 \\right\\} = \\sup \\left\\{s \\mid \\mathcal{H}^{s}(F) = \\infty \\right\\} .\n\t\\end{align*}\n\\end{defn}\nThis immediately gives\n\\begin{align*}\n\t\\mathcal{H}^{s}(F) = \\begin{cases}\n\t\t\\infty & 0\\leq s< \\textrm{dim}_H F\\\\\n\t\t0 & s> \\textrm{dim}_H F\n\t\\end{cases}\n\\end{align*}\nNote that for \\(s =  \\textrm{dim}_H F\\), \\(\\mathcal{H}^{s}(F)\\) can be zero, infinite, or finite. A Borel set that \\(\\mathcal{H}^{s}\\) as finite is called an \\(s\\)-set.\\\\\n\nFortunately, \\(\\mathcal{H}^{s}\\) satisfies many of the same properties as the box-counting dimension. Furthermore, it satisfies the Holder condition exactly as expected:\n\\begin{prop}\n\tLet \\(F\\subset \\R^{n}\\) and suppose that \\(f:F\\to \\R^{m}\\) satisfies the Holder condition\n\t\\begin{align*}\n\t\t\\left| f(x)-f(y) \\right| \\leq c \\left| x-y \\right|^{\\alpha} \\quad \\forall x,y \\in F.\n\t\\end{align*}\n\tThen \\( \\textrm{dim}_H f(F) \\leq (1 / \\alpha) \\textrm{dim}_H F\\). If \\(f\\) is instead bi-Lipschitz, then we have equality instead.\n\\end{prop}\n\nThere is also a clear relationship between Hausdorff dimension and box-counting dimension.\n\\begin{prop}\n\tFor every non-empty bounded \\(F\\subset \\R^{n}\\),\n\t\\begin{align*}\n\t\t\\textrm{dim}_H F \\leq \\underline{ \\textrm{dim}}_B F \\leq \\overline{ \\textrm{dim}}_B F.\n\t\\end{align*}\n\\end{prop}\nNote that so far, bi-Lipschitz mappings preserve all our notions of dimension. So similar to homeomorphisms, one can regard two sets as equivalent if there is a bi-Lipschitz mapping between them. This allows us to begin distinguishing topological properties from dimension.\n\\begin{prop}\n\tEvery set \\(F\\subset \\R^{n}\\) with \\( \\textrm{dim}_H F < 1\\) is totally disconnected.\n\\end{prop}\n\\begin{proof}\n\tLet \\(x\\) and \\(y\\) be distinct points of \\(F\\). We define a mapping \\(f(z) = \\left| z-x \\right| \\). The reverse triangle inequality gives us\n\t\\begin{align*}\n\t\t\\left| f(z) - f(w) \\right| \\leq \\left| z-w \\right| ,\n\t\\end{align*}\n\tso that \\(f\\) is Lipschitz and so \\( \\textrm{dim}_H f(F) < 1\\). This implies that \\(f(F)\\) is a subset of \\(\\R\\) of \\(\\mathcal{H}^{1}\\)-measure zero-- which implies it has a dense complement. Choosing \\(r\\) with \\(r \\not\\in f(F)\\) and \\(0<r<f(y)\\), it follows that\n\t\\begin{align*}\n\t\tF = \\left\\{z \\in F \\mid \\left| z-x \\right| <r \\right\\} \\cup \\left\\{z \\in F \\mid \\left| z-x \\right| >r \\right\\} .\n\t\\end{align*}\n\tThat is, \\(F\\) is contained in two disjoint open sets with \\(x\\) in one set and \\(y\\) in the other-- and so \\(x,y\\) lie in different connected components of \\(F\\).\n\\end{proof}\n\n%% Section on computing examples\n\n\\begin{exmp}[Middle third Cantor set]\n\tThe Cantor set \\(F\\) splits into a left part \\(F_L=F \\cap \\left[ 0,\\frac{1}{3} \\right] \\) and a right part \\(F_R = F \\cap \\left[ \\frac{2}{3},1 \\right] \\). Both parts are geometrically similar to \\(F\\) but simply scaled by a ratio of \\(\\frac{1}{3}\\). Furthermore, \\(F = F_L \\sqcup F_R\\). Thus, for any \\(s\\),\n\t\\begin{align*}\n\t\t\\mathcal{H}^{s}(F) = \\mathcal{H}^{s}(F_L) + \\mathcal{H}^{s}(F_R) = \\left( \\frac{1}{3} \\right)^{s}\\mathcal{H}^{s}(F) + \\left( \\frac{1}{3} \\right)^{s}\\mathcal{H}^{s}(F)\n\t\\end{align*}\n\tby the scaling property of Hausdorff measures. Assuming that at the critical value \\(s = \\textrm{dim}_H F\\), we have that the Hausdorff measure is finite (a nontrivial assumption), then we can divide both sides by \\(\\mathcal{H}^{s}(F)\\) to get \\(1 = 2\\left( \\frac{1}{3} \\right)^{s}\\) which then gives \\(s = \\log 2 / \\log 3\\).\n\\end{exmp}\nA more rigorous approach can be shown to calculate this value, but this heuristic is particularly useful for self-similar sets.\n\n%% Section on ball measures, net measure, that are equivalent\n\n\\section{Equivalent definitions of Hausdorff dimension}\n\\label{sec:equivalent_definitions_of_hausdorff_dimension}\n\nIt is useful to have equivalent definitions, as some definitions will be easier to compute for certain classes of sets. One simple variation is done via covering by spherical balls: let\n\\begin{align*}\n\t\\mathcal{B}^{s}_{\\delta}(F) = \\inf \\left\\{\\sum_{i} \\left| B_i \\right|^{s} \\mid \\left\\{ B_i \\right\\} \\text{ is a \\(\\delta\\)-cover of \\(F\\) by balls} \\right\\} \n\\end{align*}\nand consider the measure \\(\\mathcal{B}^{s}(F) = \\lim_{\\delta \\to 0} \\mathcal{B}^{s}_\\delta(F)\\). Once again, we obtain a dimension when \\(\\mathcal{B}^{s}(F)\\) jumps from \\(\\infty\\) to zero. One can verify that this bounds the Hausdorff measure on both sides by a constant, and so the value of \\(s\\) where the jumps occur must be the same.\\\\\n\nOf course, we can further restrict by using covers by only open sets, or closed sets. If \\(F\\) is compact, we can even consider finite subcovers of open covers.\\\\\n\nOne important variant is the net measure. For now, consider the cases when \\(F\\) is a subset of \\([0,1]\\). Recall that a binary interval is an interval of the form \\([r_2^{-k},(r+1)2^{-k}]\\) where \\(k = 0,1,\\ldots\\) and \\(r = 0,1,\\ldots,2^{k}-1\\). Then\n\\begin{align*}\n\t\\mathcal{M}^{s}_{\\delta}(F) = \\inf \\left\\{ \\sum \\left| U_i \\right|^{s} \\mid \\left\\{ U_i \\right\\} \\text{ is a \\(\\delta\\)-cover of \\(F\\) by binary intervals} \\right\\} \n\\end{align*}\nwhich leads to the net measures\n\\begin{align*}\n\t\\mathcal{M}^{s}(F) = \\lim_{\\delta \\to 0} \\mathcal{M}^{s}_\\delta (F).\n\\end{align*}\nThis form can be more convenient, as two binary intervals are either disjoint or contained in one another, allowing any cover of a set by binary intervals to become a cover by disjoint binary intervals.n\n\n%% Section on packing measure, which is a measure correlated with the modified upper box-counting dimension\n\n\\section{Packing Measure}\n\\label{sec:packing_measure}\n\nFor \\(s\\geq \\) and \\(\\delta>0\\), we define\n\\begin{align*}\n\t\\mathcal{P}^{s}_\\delta(F) = \\sup \\left\\{\\sum_{i=1}^{\\infty} \\left| B_i \\right|^{s} \\mid \\left\\{ B_i \\right\\} \\text{ is a collection of disjoint balls of radii at most \\(\\delta\\) with centers in \\(F\\)} \\right\\} .\n\\end{align*}\nThe limit\n\\begin{align*}\n\t\\mathcal{P}^{s}_0(F) = \\lim_{\\delta \\to 0} \\mathcal{P}^{s}_\\delta(F)\n\\end{align*}\nexists. However, it is not a measure-- so we modify the definition by decomposing \\(F\\) into a countable collection of sets and define\n\\begin{align*}\n\t\\mathcal{P}^{s}(F) = \\inf \\left\\{\\sum_{i=1}^{\\infty} \\mathcal{P}^{s}_0(F_i) \\mid F\\subset \\bigcup_{i=1}^{\\infty}F_i \\right\\} \n\\end{align*}\nThis is now a measure on \\(\\R^{n}\\) known as the \\(s\\)-dimensional packing measure. Similarly, the packing dimension is the jump value given by\n\\begin{align*}\n\t\\textrm{dim}_P F = \\sup \\left\\{s\\geq 0 \\mid \\mathcal{P}^{s}(F) = \\infty \\right\\} = \\inf \\left\\{s \\mid \\mathcal{P}^{s}(F) = 0 \\right\\} .\n\\end{align*}\nIn fact, this definition is the same as the modified upper box dimension.\n\n\\begin{lemma}\n\tFor \\(F\\) a non-empty bounded subset of \\(\\R^{n}\\),\n\t\\begin{align*}\n\t\t\\textrm{dim}_P F \\leq \\overline{ \\textrm{dim}_B}F.\n\t\\end{align*}\n\\end{lemma}\nAnd hence\n\\begin{prop}\n\tIf \\(F\\subset \\R^{n}\\), then \\(\\textrm{dim}_PF = \\overline{\\textrm{dim}_{MB}}F\\).\n\\end{prop}\nThis gives us the relations\n\\begin{align*}\n\t\\textrm{dim}_H F \\leq \\underline{\\textrm{dim}_{MB}}F \\leq \\overline{\\textrm{dim}}_{MB}F = \\textrm{dim}_P F \\leq \\overline{\\textrm{dim}}_B F\n\\end{align*}\nThis connection greatly opens the options in computing the geometry of fractals, however it is difficult to calculate. The following corollary strengthens the connection between the modified box dimension and the packing dimension.\n\n\\begin{cor}\n\tLet \\(F\\subset \\R^{n}\\) be compact and assume that\n\t\\begin{align*}\n\t\t\\overline{\\textrm{dim}}_B(F\\cap V) = \\overline{\\textrm{dim}}_B F\n\t\\end{align*}\n\tfor all open sets \\(V\\) that intersect \\(F\\). Then \\(\\textrm{dim}_P F = \\overline{\\textrm{dim}}_BF\\).\\\\\n\n\tIf \\(F\\subset \\R^{n}\\) is of second category, then \\(\\textrm{dim}_P F = n\\). That is, this holds if \\(F\\) is or contains a dense \\(G_\\delta\\) set.\n\\end{cor}\n\n%% Gauge function\n\n%% Dimension prints??\n\n%% Porosity\n\n\n\\end{document}\n", "meta": {"hexsha": "f615285d192a3e8fe46fb5eb1690a3918edc7d7a", "size": 11208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Geometric Measure Theory/Notes/source/Chapter3.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Geometric Measure Theory/Notes/source/Chapter3.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Geometric Measure Theory/Notes/source/Chapter3.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.8679245283, "max_line_length": 340, "alphanum_fraction": 0.6672019986, "num_tokens": 3967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.542863297964157, "lm_q2_score": 0.7931059462938815, "lm_q1q2_score": 0.4305481096400801}}
{"text": "Constituents are referred to any chemical compound or a group of chemical compounds with assumed effective transport parameters that can present in aqueous phase or be sorbed to soil matrix or particles. In addition some biological agents such as bacteria or algae can also be treated as constituents. There is no pre-defined constituents in GIFMod and the user should introduce them and assign transformation processes to them. In this section the governing equations and different processes that can be assigned to constituents in GIFMod will be described. The general mass balance equation for fate and transport of constituents in GIFMod is:\n\\begin{equation}\n\\label{eq:26}\n\\begin{split}\n\\frac{d\\Gamma_{i,p,l} C_{p,l,i,k}}{dt} =\\\\ \\beta_{p,l} \\sum_{j=1}^{nj} pos \\big(Q_{ij}+(v_{s,p,ij}+v_{c,k,ij})A_{ij}\\big)\\tilde G_{p,l,j}C_{p,l,j,k} \\\\ -\\beta_{p,l} \\sum_{j=1}^{nj} pos \\big(-Q_{ij}-(v_{s,p,ij}+v_{c,p,ij})A_{ij}\\big)\\tilde G_{p,l,j}C_{p,l,j,k}\\bigg]\\\\\n-S_i \\big(\\sum_{l'=1}^{nl_p}\\textbf{K}_{p,l,l'}\\tilde G_{p,l,i}C_{p,l,i,k}-\\sum_{l'=1}^{nl_p}\\textbf{K}_{p,l,l'}\\tilde G_{p,l',i}C_{p,l',i,k}\\big)\\\\\n+ \\beta_{p,l} \\sum_{j=1}^{nj} A_{ij}\\frac{D_{p,ij,k}}{d_{ij}}(\\tilde G_{p,l,j}C_{p,l,j,k}-\\tilde G_{p,l,i}C_{p,l,i,k}) \\\\\n+ S_i \\sum_{p=-1}^{np} \\sum_{l'=1}^{nl_p}\\kappa_{k,p,p'}\\bigg(\\frac{C_{p',l',i,k}}{\\phi_{k,p'}}-\\frac{C_{p,l,i,k}}{\\phi_{k,p}}\\bigg)  \\\\ +S_i \\sum_{r=1}^{nr} \\psi_{r,k}R_r + S_i \\xi_{p,l,i,k} \\\\\n+ \\sum_j^{ns} pos(Q_{s,j} \\tilde G_{p,l,j,in} C_{p,l,j,k,in}) - \\sum_j^{ns} pos(-\\omega_{p,l,j} Q_{s,j} \\tilde G_{p,l,j,in} C_{p,l,j,k,in}) + \\dot{m}_{i,p,l,k}\n\\end{split}\n\\end{equation}\nIn Eq. \\ref{eq:26}, the first two terms of the right hand side represent dissolved and particle-bound advective transport due to flux and settling, the third term is the mass exchange of constituents between phases due to exchange of particles, the forth term is dispersion due to the dispersion due to both dispersion of particle-bound and dissolved constituents, the fifth term is the mass exchange through adsorption and desroption, the six term represents biogeochemical transformation, the seventh term is external flux (such as aeration), and eight and night terms are respectively sources or sinks due to inflow and outflow or plant uptake. Subscript $p=-1$ represent the solid matrix and $p=0$ represent the aqueous phase while a $p>0$ refer to the particle class. $\\tilde G_{p,l,j}$ is the same as $G_{p,l,j}$ in Eq. \\ref{eq:20} for $p>0$, is equal to $1$ for $p=0$ (dissolved species) and equal to bulk density, $\\rho_i$ for $p=-1$ (soil matrix). Subscript $in$ indicate the values in the inflow. Also in this equation $D_{p,ij,k}$ is the dispersion/diffusion coefficient for particles when $p>0$ (particles) and constituent's dispersion/diffusion coefficient when $p=0$ (dissolved species). Also Sorption capacity, $\\phi_{k,p}$, is equal to partitioning coefficient $K_D$ for soil and particles ($p=-1$ and $p>0$ respectively) and equal to 1 for dissolved species ($p=0$).  \n\n\\subsection{Constituent properties}\nIn this section the properties of constituents are described. To  add a new constituent right-click on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Constituents} and click on \\textbf{Add Constituent}. \\\\\nBelow the properties of constituents are described.\n\\begin{itemize}\n\\item \\textbf{Name: } This is the name of the constituent. Names of constituents should be unique. Constituent names will be used in producing outputs and also when entering the reaction network. \n\\item \\textbf{Diffusion coefficient: } This specifies the molecular diffusion coefficient of the constituent. When calculating the mechanical dispersion, this value will be added to the dispersion coefficient calculated based on the dispersivity value entered for each connector. \n\\item \\textbf{Exchange rate factor: } This bring a window where the user can enter the solid-aqueous phase rate $\\kappa_{k,p,p'}$ in Eq. \\ref{eq:26} and partitioning coefficient $K_D$ with respect to soil matrix and each particle class. \n\\item \\textbf{Partitioning coefficient: } This bring a window where the user can enter the solid-aqueous phase rate $\\kappa_{k,p,p'}$ in Eq. \\ref{eq:26} and partitioning coefficient $K_D$ with respect to soil matrix and each particle class. \n\\item \\textbf{Settling velocity: } The settling velocity of the constituent, $v_c$. \n\\end{itemize}\n\n\\subsection{Reactions}\nIn order to define reactions two steps are needed. First some reaction parameters will be defined that can represent reaction rate constants, half-saturation coefficients, stoichiometric constants and other parameters needed in defining the reaction process. It shoule be noted that a user can define reactions by explicitly entering parameter values into reaction expressions however this approach is not advised. The second step is to enter reaction rate expressions and stoichiometric constants into a Petersen matrix \\citep{russell2006}. \n\n\\textit{Reactions Parameters: }\\\\\nTo add a reaction parameter right-click on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Reactions}$\\rightarrow$\\textbf{Reaction Parameters} and click on \\textbf{Add Reaction Parameter} from the drop down menu. Select the reaction parameter that was added to change its properties.\n\\begin{itemize}\n\\item \\textbf{Name: } Name of the reaction parameter to be used in defining reaction expressions. \n\\item \\textbf{Temperature correction factor: } Specifies the dependency of the value of the reaction rate parameter to temperature. Under variable temperature condition the value of the reaction parameter entered in the \\textbf{Value} field represent the value of the parameter in $20^oC$. The value at other temperatures is calculated as: \n\\begin{equation}\n\\label{eq:27}\nk_T = k_{20} \\Theta^{T-20}\n\\end{equation}\n\\item \\textbf{Value: } The value of the parameter. Please note that the unit used for the parameter value should be consistent with other units used in the model. The time dimension of the value is always days. \n\\end{itemize}\n\\textit{Reactions: }\\\\\nIn order to enter reaction rate expressions and stoichiometric constants right-click on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Reactions}$\\rightarrow$\\textbf{Reaction Parameters} and click on \\textbf{Open Reaction Network Window} from the drop down menu. A window as shown in Figure \\ref{fig:20}. The headings of this table consists of a process name, a process rate and columns each representing the stoichiometric constants for each of the constituents defined in the model. Additional processes (reactions) can be added using the \\textbf{Add Processes} at the bottom of the window and existing processes can be removed using the \\textbf{Remove Process} bottom. \\textbf{Process Name} is were the user-assigned name of the process is entered. In the process rate column the user can enter the rate expression of the process. The rate expression can include concentrations of constituents, reaction parameters and also physical parameters such as light, temperature or even velocity. The values entered under the columns identified by name of constituents indicate how much of a constituent is produced or consumed as a result of a unit progress in the reaction. A negative stoichiometric constant is indicative of consumption of the constituent as a result of the reaction while a positive value results in production of the constituent. The following example shows how to set up a simple reaction in GIFMod. \n\\begin{figure}[!ht]\\label{fig:20}\n\\begin{center}\n\\includegraphics[width=8cm]{Images/Figure20.png} \\\\\n\\caption{Reaction window} \n\\end{center}\n\\end{figure}\n\n\\input{ASM_ex.tex}", "meta": {"hexsha": "782e6762168b6a253bd4153acf11ca9fe4768565", "size": 7723, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GIFMod User's Manual/Constituents.tex", "max_stars_repo_name": "ArashMassoudieh/GIFMod_", "max_stars_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-11-20T19:32:27.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-28T06:08:45.000Z", "max_issues_repo_path": "GIFMod User's Manual/Constituents.tex", "max_issues_repo_name": "ArashMassoudieh/GIFMod_", "max_issues_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-07-04T05:40:30.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-04T05:43:37.000Z", "max_forks_repo_path": "GIFMod User's Manual/Constituents.tex", "max_forks_repo_name": "ArashMassoudieh/GIFMod_", "max_forks_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-11-09T22:00:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-30T10:56:08.000Z", "avg_line_length": 160.8958333333, "max_line_length": 1452, "alphanum_fraction": 0.7661530493, "num_tokens": 2049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789040926008, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.4305339907756792}}
{"text": "\\documentclass{article}\n\\usepackage[margin=8em]{geometry}\n\\usepackage{algorithm}\n\\usepackage{algorithmicx}\n\\usepackage{algpseudocode}\n\\usepackage{tikz}\n\\usepackage{tikz-qtree}\n\\usepackage{hyperref}\n\\setlength{\\parskip}{\\baselineskip}\n\\title{The Knapsack Problem \\\\ \\small \\textit{A Survey of Solution Approaches}}\n\\date{\\small \\today}\n\\author{Sayak Biswas \\\\ \\small UNIVERSITY \\textit{of} \\textbf{FLORIDA} \\\\ \\small UFID: 54584911}\n\\begin{document}\n\\pagenumbering{gobble}\n\\maketitle\n\\begin{abstract}\nThis paper surveys existing literature for different approaches to solve the knapsack problem. The Knapsack Problem is a combinatorial optimization problem in which one has to maximize the profits gained by packing a set of objects in a knapsack without exceeding its capacity. The problem is $\\mathcal{NP}$-hard, thus there is no known polynomial time algorithm for a large input.\n\nSpecifically, we take a look at the \\textit{0-1 Knapsack Problem} and provide a qualitative comparison between the two well-known approaches towards solving the problem: dynamic programming and backtracking algorithms.\n\\end{abstract}\n\\newpage\n\n\\pagenumbering{arabic}\n\n\\section{Introduction}\nThe \\textit{Knapsack Problem} is an optimization problem, which at a high level is to choose the most profitable subset from a collection of available items without overloading the knapsack. The problem is formally defined as follows:\n\nGiven a knapsack of maximum capacity \\textit{C} and \\textit{n} items each weighing \\textit{$w_{i}$} and with an associated profit of \\textit{$p_{i}$}, the \\textit{Knapsack Problem} is to choose a subset of the items such to maximize $\\sum_{i=1}^{n}\\textit{$p_{i}x_{i}$}$ on the condition $\\sum_{i=1}^{n}\\textit{$w_{i}x_{i}$} \\leq \\textit{C}, \\textit{i} = 1,...,\\textit{n}$ where \\textit{$x_{i}$} is the number of copies of each item.\n\n%\\iffalse\nThe \\textit{fractional} knapsack problem allows placing a fraction \\textit{$x_{i}$} of object \\textit{i} into the knapsack \\textit{i.e.} $0 \\le \\textit{$x_{i}$} \\le 1$.\n\nThe \\textit{bounded} knapsack problem restricts each item type to an integer amount of copies \\textit{i.e.} \\textit{$x_{i}$} $\\in \\{0,...,m_{i}\\}$\n\nThe \\textit{unbounded} knapsack problem removes any restriction from the number of copies of each object type \\textit{i.e.} \\textit{$x_{i}$} $\\ge$ 0.\n%\\fi\n\nThe \\textit{0-1} knapsack problem restricts the copy count to either zero or one, meaning the object is either included in the knapsack or not, \\textit{i.e.} \\textit{$x_{i}$} $\\in$ \\{0, 1\\}.\n\n\\section{Algorithms}\nA na\\\"{\\i}ve brute force approach would be to consider all $2^{n}$ possible combinations of items for the knapsack and choose the one that yields te maximum profit. Such an approach would lead to exponential complexity and hence is not desirable.\n\\subsection{Dynamic Programming}\nDynamic programming solves optimization problems by breaking it into smaller subproblems and then solving those subproblems to find the overall solution. To solve a problem using dynamic programming, it should have two important characteristics:\n\\begin{itemize}\n\t\\item \\textit{Optimal Substructure}: This means that the overall optimal solution to a problem comprises optimal solutions to the subproblems.\n\t\\item \\textit{Overlapping Subproblems}: This means that any algorithm used to solve the problem should be solving a subset of the subproblems over and over again instead of generating new subproblems. Dynamic programming stores the results of these subproblems and uses them whenever the subproblem is encountered again. This is called \\textit{memoization}.\n\\end{itemize}\nIn this approach, we first define a function \\textit{knap(1, n, C)} which finds the optimal solution, $f_{n}(C)$ for a knapsack of capacity \\textit{C} using objects from \\textit{1} to \\textit{n}. We divide this into subproblems denoted by \\textit{knap(1, j, y)} which finds the optimal solution for a knapsack of capacity \\textit{y} using objects from \\textit{1} to \\textit{j}. Let the solution to this be defined by $f_{j}(y)$.\n\nAt any point in the problem state, the solution depends on making a decision on whether to use the current object or not. So, we obtain the top-down recurrence relation\n\n\\begin{equation} \\label{eq:knapeq1}\n\tf_{j}(y) = max \\quad \\{f_{j-1}(y), f_{j-1}(y-w_{j}) + p_{j}\\}, {y \\ge w_{j}}\n\\end{equation}\n\nLet us consider an example with a knapsack of capacity $C = 6$, three given objects with weights 2,3,4 and profits 1,2,5 respectively. Using the relation \\ref{eq:knapeq1} we calculate all possible values and store them in a table as follows\n\\begin{center}\n\t\\begin{tabular}{*8c}\n\t\t& 0 &1 &2 &3 &4 &5 &6 \\\\\\cline{2-8}\n\t\t$f_{1}(y)$ &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{1} \\\\\\cline{2-8}\n\t\t$f_{2}(y)$ &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{2} &\\multicolumn{1}{|c|}{2} &\\multicolumn{1}{|c|}{3} &\\multicolumn{1}{|c|}{3} \\\\\\cline{2-8}\n\t\t$f_{3}(y)$ &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{0} &\\multicolumn{1}{|c|}{1} &\\multicolumn{1}{|c|}{2} &\\multicolumn{1}{|c|}{5} &\\multicolumn{1}{|c|}{5} &\\multicolumn{1}{|c|}{6} \\\\\\cline{2-8}\n\t\\end{tabular}\n\\end{center}\nSo, we have a matrix of size \\textit{n} x \\textit{C} which we fill in row-wise manner as values in a row depend on the previous row values. The running time is \\textit{O(nC)} and the space requirement is \\textit{O(C)}. Below is the pseudo-code:\n\n\\begin{algorithm}\n\t\\caption{DynamicKnapsack(\\textit{p, w, n, C})}\\label{dynamicKnapsack}\n\t\\begin{algorithmic}[1]\n\t\t\\For{$j$ from 0 to $C$}\n\t\t\t\\State $result[0, j]\\gets 0$\n\t\t\\EndFor\n\t\t\n\t\t\\For{$i$ from 1 to $n$}\n\t\t\t\\For{$j$ from 0 to $C$}\n\t\t\t\t\\If{$w[i-1] > j$}\n\t\t\t\t\t\\State $result[i, j]\\gets result[i-1, j]$\n\t\t\t\t\\Else\n\t\t\t\t\t\\State $result[i, j]\\gets max(result[i-1, j], result[i-1, j-w[i-1]] + p[i-1])$\n\t\t\t\t\\EndIf\n\t\t\t\\EndFor\n\t\t\\EndFor\n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Backtracking}\nA backtracking algorithm builds a set of possible solution all the while discarding any partial solution candidates which it determines to be not feasible. As discussed earlier the solution space for \\textit{0-1} Knapsack problem consists of $2^{n}$ ways of assigning 0 or 1 to $x_{i}$. Below is a possible solution space when $n=3$.\n\n\\begin{center}\n\t\\begin{tikzpicture}[every tree node/.style={draw,circle},\n\t\tlevel distance=1.25cm, sibling distance=0.5cm, minimum size = 0.5cm,\n\t\tedge from parent path={(\\tikzparentnode) -- (\\tikzchildnode)}]\n\t\\Tree\n\t[.{}\n\t\t\\edge node[auto=right] {$x_{1} = 0$};\n\t\t[.{}\n\t\t\t\\edge node[midway, left] {$x_{2} = 0$};\n\t\t\t[.{}\n\t\t\t\t\\edge node[midway, left] {$x_{3} = 0$};\n\t\t\t\t[.{} ]\n\t\t\t\t\\edge node[midway, right] {$x_{3} = 1$};\n\t\t\t\t[.{} ]\n\t\t\t]\n\t\t\t\\edge node[midway, right] {$x_{2} = 1$};\n\t\t\t[.{}\n\t\t\t\t\\edge node[midway, left] {$x_{3} = 0$};\n\t\t\t\t[.{} ]\n\t\t\t\t\\edge node[midway, right] {$x_{3} = 1$};\n\t\t\t\t[.{} ]\n\t\t\t]\n\t\t]\n\t\t\\edge node[auto=left] {$x_{1} = 1$};\n\t\t[.{}\n\t\t\t\\edge node[midway, left] {$x_{2} = 0$};\n\t\t\t[.{}\n\t\t\t\t\\edge node[midway, left] {$x_{3} = 0$};\n\t\t\t\t[.{} ]\n\t\t\t\t\\edge node[midway, right] {$x_{3} = 1$};\n\t\t\t\t[.{} ]\n\t\t\t]\n\t\t\t\\edge node[midway, right] {$x_{2} = 1$};\n\t\t\t[.{}\n\t\t\t\t\\edge node[midway, left] {$x_{3} = 0$};\n\t\t\t\t[.{} ]\n\t\t\t\t\\edge node[midway, right] {$x_{3} = 1$};\n\t\t\t\t[.{} ]\n\t\t\t]\n\t\t]\n\t]\n\t\\end{tikzpicture}\n\\end{center}\nThis space is searched in depth-first manner from the start node. From each E-node we check if the next node will result in a feasible solution. If yes, the next node becomes the E-node. If no, we backtrack to the previous node and kill the E-node. To do this, we use an upper bound on the best solution that can be achieved from this node. We obtain this bound by relaxing the constraint from \\textit{$x_{i}$} $\\in$ \\{0, 1\\} to $0 \\le \\textit{$x_{i}$} \\le 1$ and using the greedy algorithm (of sorting the items in non-decreasing order of profit per unit weight and adding to the knapsack) for the rest of the problem. The pseudo-code for the bounding algorithm and the backtracking solution is given below.\n\\begin{algorithm}\n\t\\caption{GreedyBound(\\textit{p, w, n, C, k, $p_{c}$, $w_{c}$})}\\label{greedyBound}\n\t\\begin{algorithmic}[1]\n\t\t\\For{$i$ from $k+1$ to $n$}\n\t\t\t\\State $w_{c} \\gets w_{c} + w_{i}$\n\t\t\t\\If{$w_{c} < C$}\n\t\t\t\t\\State $p_{c} \\gets p_{c} + p_{i}$\n\t\t\t\\Else\n\t\t\t\t\\State \\Return $p_{c} + (1 - (w_{c} - C)/w_{i}) * p_{i}$\n\t\t\t\\EndIf\n\t\t\\EndFor\n\t\t\\State \\Return $p_{c}$\n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{algorithm}\n\t\\caption{BacktrackingKnapsack(\\textit{p, w, n, C, k, $p_{c}$, $w_{c}$})}\\label{backtrackingKnapsack}\n\t\\begin{algorithmic}[1]\n\t\t\\If{$w_{c} + w_{k} \\le C$}\n\t\t\t\\State $y_{k} \\gets 1$\n\t\t\t\\If{$k < n$}\n\t\t\t\t\\State \\Call{BacktrackingKnapsack}{\\textit{p, w, n, C, k+1, $p_{c} + p_{k}$, $w_{c} + w_{k}$}}\n\t\t\t\\EndIf\n\t\t\t\\If{$p_{c} + p_{k} > p_{t}$ \\textbf{and} $k=n$}\n\t\t\t\t\\State $p_{t} \\gets p_{c} + p_{k}$\n\t\t\t\t\\State $w_{t} \\gets w_{c} + w_{k}$\n\t\t\t\t\\For{$j$ from 1 to $k$}\n\t\t\t\t\t\\State $x_{j} \\gets y_{j}$\n\t\t\t\t\\EndFor\n\t\t\t\\EndIf\n\t\t\\EndIf\n\t\t\\If{$\\Call{GreedyBound}{\\textit{p, w, n, C, k, $p_{c}$, $w_{c}$}} \\ge p_{t}$}\n\t\t\t\\State $y_{k} \\gets 0$\n\t\t\t\\If{$k < n$}\n\t\t\t\t\\State \\Call{BacktrackingKnapsack}{\\textit{p, w, n, C, k+1, $p_{c}$, $w_{c}$}}\n\t\t\t\\EndIf\n\t\t\t\\If{$p_{c} > p_{t}$ \\textbf{and} $k=n$}\n\t\t\t\t\\State $p_{t} \\gets p_{c}$\n\t\t\t\t\\State $w_{t} \\gets w_{c}$\n\t\t\t\t\\For{$j$ from 1 to $k$}\n\t\t\t\t\t\\State $x_{j} \\gets y_{j}$\n\t\t\t\t\\EndFor\n\t\t\t\\EndIf\n\t\t\\EndIf\n\t\t\n\t\\end{algorithmic}\t\t\n\\end{algorithm}\n\n\\section{Qualitative Comparison}\nAs we saw above, the brute force approach has a complexity of \\textit{O(n$2^{n}$)}. Although it is quite simple to code, it can be used only for very small input due to its exponential complexity. \n\nThe dynamic programming approach performs much better with a running time of \\textit{O(nC)}. It also has a space complexity of \\textit{O(C)}. This stems from the fact that in a dynamic programming approach we need to store two rows of a \\textit{C}-column array as values in the current row are calculated using those from the previous row. From the perspective of coding complexity, it is also quite easy to implement.\n\nThe backtracking algorithm will create the complete state space tree with $2^{n-1}-1$ nodes in the worst case. In theory it is hard to say how much of the search tree is pruned out by the bounding heuristics however in practice it does not generate all the possible nodes, so there is a substantial speed increase. The implementation in code is a bit more difficult in this case compared to the dynamic programming method as we need to maintain a separate data structure to store and manipulate the values per unit weight for the E-nodes.\n\n\\section{Conclusion}\nIn this paper we looked at two approaches to solve the \\textit{0-1} Knapsack problem. We saw that runtimes for both the approaches have different characteristics. As such it cannot be explicitly defined which algorithm is a better choice. This needs to be determined by implementing both algorithms and executing the code by varying the input number of items and the maximum capacity of the knapsack.\n\n\\section{References}\n1. Horowitz, Ellis and Sahni, Sartaj and Rajasekaran, Sanguthevar, 2007, \\textit{Computer Algorithms}, Silicon Pr., 773p \\\\\n2. Knapsack Problem, Wikipedia, \\url{https://en.wikipedia.org/wiki/Knapsack_problem}\n\\end{document}", "meta": {"hexsha": "0c2f706639420947ab1d5a13789f29ddf51e04fb", "size": 11353, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "knapsack-problem-paper.tex", "max_stars_repo_name": "sayakbiswas/knapsack-problem-paper", "max_stars_repo_head_hexsha": "9576c60099cd96462e6bd131481f9545762ff22b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "knapsack-problem-paper.tex", "max_issues_repo_name": "sayakbiswas/knapsack-problem-paper", "max_issues_repo_head_hexsha": "9576c60099cd96462e6bd131481f9545762ff22b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "knapsack-problem-paper.tex", "max_forks_repo_name": "sayakbiswas/knapsack-problem-paper", "max_forks_repo_head_hexsha": "9576c60099cd96462e6bd131481f9545762ff22b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.5206185567, "max_line_length": 708, "alphanum_fraction": 0.6910948648, "num_tokens": 3815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.43051246490970924}}
{"text": "This chapter summarizes previous efforts in numerical simulations of prismatic HTGRs.\nThe simulation of prismatic HTGRs require the coupled modeling of the neutronics and thermal-fluid phenomena.\nThis chapter comprises the following sections: Section \\ref{sec:litreview-neut} addresses diffusion methods for solving the neutronics, Section \\ref{sec:litrev-thermalf} focuses on the thermal-fluids, and Section \\ref{sec:litreview-multi} studies the coupled simulations.\n\n\\section{Prismatic HTGR Diffusion Solvers}\n\\label{sec:litreview-neut}\n\nCurrently, several software programs solve the neutronics of prismatic \\glspl{HTGR}.\nMost of these programs rely on one of the following methods: stochastic transport (Monte Carlo), deterministic transport, or deterministic diffusion.\nThis section focuses on the last class.\n% If time permits work on a brief description of the Monte Carlo and deterministic transport maybe.\n% Why? Deterministic diffusion solvers have lower computational requirements than other methods reference ??\n% The utilization of the Monte Carlo codes is unattractive because of the tremendous problem size and the need for a large number of neutron histories \\cite{lee_status_2006}.\n% It is one of the simplest means to solve neutron transport problems \\cite{leppanen_development_2007}.\n% Here I say the following\n% Deterministic diffusion methods are computationally cheaper than the other methods.\n% This characteristic makes it a good candidate for coupled calculations.\n\nThe history of deterministic diffusion solvers began in the late 1950s with the \\gls{FDM} application to the analysis of \\glspl{LWR}.\nIn \\gls{FDM}, mesh spacings are usually of the order of the diffusion length.\nWhile solving large multi-dimensional problems, this feature causes the mesh points to reach intractable numbers \\cite{lewis_finite_1986}.\nThe computational expense of these calculations motivated the generation of more computationally efficient techniques \\cite{lawrence_progress_1986}.\nAlthough substantial overlaps exist, the most common techniques fall into two broad categories: nodal methods and \\gls{FEM}.\n\n% NODAL\nFLARE \\cite{delp_flare_1964} is a three-dimensional \\gls{BWR} simulator, and it is representative of the first generation of nodal methods.\nThis approach used adjusted parameters to match actual operating data or the results of more accurate calculations.\nMost of these methods were implementations of the so-called \"1.5 group theory\" \\cite{gupta_nodal_1981}.\nThe second generation of nodal methods derived spatial coupling relationships by applying the \\gls{TIP}.\nThis procedure obtains equivalent one-dimensional equations by integrating the multi-dimensional diffusion equation over directions transverse to each coordinate axis \\cite{lawrence_progress_1986}.\nThis approach proved to be highly efficient and accurate in Cartesian geometries.\n\nIn 1981, a formulation based on the \\gls{NEM} first demonstrated the feasibility of nodal methods in hexagonal geometries \\cite{duracz_nodal_1981}.\nHowever, this method would introduce non-physical singular terms that required the utilization of discontinuous polynomials.\nThis drawback motivated the development of more effective formulations.\nHEXNOD, introduced in 1988 by Wagner \\cite{wagner_three-dimensional_1989}, is an example of such formulations.\nThis algorithm uses the \\gls{TIP} and, in contrast to the \\gls{NEM}, solves the resulting differential equation analytically.\nWagner's article demonstrated the method's good accuracy by comparing to \\gls{FDM} and Monte Carlo calculations for a few benchmark problems.\n\nHEXPEDITE \\cite{fitzpatrick_hexpedite_1992} introduced a new method that is another example of more effective formulations.\nHEXPEDITE uses the \\gls{TIP} formulation to derive a pseudo-one-dimensional equation.\nThe resulting differential equation is solved analytically.\nThe difference from HEXNOD is that HEXPEDITE uses a simpler and more efficient coupling scheme.\nDifferent works \\cite{fitzpatrick_hexpedite_1992}\\cite{fitzpatrick_developments_1995} on the HEXPEDITE methodology tested the approach against the \\gls{NEM} and the \\gls{FDM}.\nThese studies established HEXPEDITE’s superiority in terms of accuracy and runtime.\nHEXPEDITE's use prevailed in the analysis of \\glspl{HTGR} until recently.\nIn 2010, \\gls{INL} conducted a study \\cite{ortensi_deterministic_2010-1} in which they compared HEXPEDITE's results against several diffusion solvers, as well as the Monte Carlo solvers MCNP5 \\cite{x-5_monte_carlo_team_mcnp_2003} and Serpent \\cite{leppanen_serpent_2015}.\n\nDIF3D \\cite{lawrence_dif3d_1983} and PARCS \\cite{downar_parcs_2004} are other examples of prevalent nodal diffusion tools.\nDIF3D has several solution options, such as the diffusion \\gls{FDM}, diffusion \\gls{NEM} based on \\gls{TIP}, and the VARIANT nodal transport method.\n% VARIANT: variational nodal \\cite{palmiotti_variant_1995}\nPARCS has several solution options as well, such as a diffusion \\gls{FDM}, diffusion \\gls{NEM} based on \\gls{TIP}, and the multi-group transport simplified P$_3$ with \\gls{FDM} and \\gls{NEM} discretizations.\n\n% from ortensi_deterministic_2010-1 and wang_modified_2018\nNodal methods solve relatively coarse meshes for approximate solutions.\nThis characteristic makes the process efficient.\nOn the other hand, the method does not provide detailed point-wise accurate solutions without flux reconstruction methods \\cite{kang_finite_1973} \\cite{boeer_fast_1992}.\nAdditionally, the derivation of nodal methods happens in a specific coordinate system for a particular node shape.\nThe application to complex problems is not flexible as different geometries require customized configurations.\nThis lack of flexibility limits the applications of nodal methods to regular geometries only.\n\n% FEM\n% Moltres is a diffusion FEM application.\nThe FEM is a well-established method in applied mathematics and engineering.\nFEM is a numerical technique for finding approximate solutions to partial differential equations by deriving their weak or variational form.\nMost applications make \\gls{FEM} preferable due to its flexibility in the treatment of curved or irregular geometries.\nAlso, the use of high order elements attains higher rates of convergence \\cite{cavdar_finite_2004}.\nThe first engineering application of \\gls{FEM} was in the field of structural engineering, dating back to 1956.\nIn successive years, \\gls{FEM} became the most extensively used technique in almost every branch of engineering.\n\\glspl{FEM} have several advantages over the nodal methods.\nIt provides flexibility in the geometry definition, a firm mathematical basis, ease in extension to the multi-group application, and detailed point-wise accurate solutions \\cite{lee_development_2008}.\n\nIn 1973, Kang et al. \\cite{kang_finite_1973} described the first application of \\gls{FEM} to neutron diffusion theory.\nThe fundamental motivation for this development was the impractical application of the \\gls{FDM} to three-dimensional problems.\nIn this early work, the author compared different \\gls{FEM} approaches to the \\gls{FDM} in one-dimensional and two-dimensional problems.\nThe studies showed a higher order of convergence achieved by the \\gls{FEM}.\nThroughout the last four decades, many software programs utilized the \\gls{FEM} to solve the diffusion equation.\nSome of the most recent software for diffusion simulations are CRONOS2 \\cite{lautard_cronos_1990}, \\gls{CAPP} \\cite{lee_development_2011}, and Rattlesnake \\cite{wang_rattlesnake_2019}.\nThe list of \\gls{FEM} diffusion solvers is more extensive, but this thesis focuses on the best-documented software in the open literature.\n\n% CRONOS\n\\gls{CEA} developed CRONOS2 \\cite{lautard_cronos_1990} as part of the SAPHYR system.\nCRONOS2 conducts steady-state and transient multi-group calculations, based on the diffusion equation or the transport equation using the S$_N$ method and an FDM or a FEM discretization.\nIn 2008, Damian et al. \\cite{damian_vhtr_2008} presented the code suite NEPTHIS\\cite{cavalier_presentation_2005}/CAST3M\\cite{studer_cast3marcturus_2007}, software that relied on CRONOS2.\nSection \\ref{sec:litreview-multi} describes further the coupling scheme.\n\n% CAPP\nIn 2008, the \\gls{KAERI} published an article \\cite{lee_development_2008} that presented CAPP.\nIts purposes are to conduct steady-state core physics analysis, core depletion analysis, and core transient analysis.\nThe article validated the software with two benchmark problems: the IAEA PWR benchmark problem, and Phase I Exercise 1 of the OECD/NEA PBMR-400 Benchmark \\cite{reitsma_oecd-neansc_2008}.\nIn 2011, Lee et al. published an article \\cite{lee_development_2011} that extended CAPP's functionalities to prismatic HTGRs.\nTo validate CAPP, they had to integrate a simplified thermal-fluids tool into the software.\nSection \\ref{sec:litreview-multi} describes the thermal-fluids tool and the coupling scheme.\n\n% Proghorn and Rattlesnake\nRattleSnake \\cite{wang_rattlesnake_2019} is the MOOSE \\cite{gaston_moose_2009} based application for simulating the transport equation.\n\\gls{INL} had initially developed Pronghorn \\cite{novak_pronghorn_2018} to model \\glspl{PBMR} \\cite{strydom_inl_2013}.\nThe MOOSE neutronics kernel library Yak incorporated the neutron diffusion models initially in Pronghorn.\nCurrently, RattleSnake is the primary tool for solving the linearized Boltzmann neutron transport equation within MOOSE and relies heavily on Yak.\nVarious solvers are available under RattleSnake, including low-order multi-group diffusion, spherical harmonics transport, and discrete ordinates transport, all solved with the \\gls{FEM}.\n% Both RattleSnake and Pronghorn yielded the same exact results when using the continuous \\gls{FEM} multigroup diffusion option in RattleSnake.\n\n% strydom_inl_2013\nIn 2013, \\gls{INL} conducted the OECD/NEA MHTGR-350 Benchmark \\cite{oecd_nea_benchmark_2017}\\cite{strydom_inl_2013} without further simplifications.\nThe \\gls{INL} team solved Phase I Exercise 1 using INSTANT-P1 \\cite{wang_krylov_2011}, Pronghorn, and RattleSnake.\nINSTANT-P1 is a transport solver that relies on the spherical harmonics discretization of angles.\nThe results for Pronghorn and RattleSnake were identical, and all presented results exhibited good agreement with the benchmark results.\n\n\\subsection{Energy group structure analysis}\n\\label{sec:energy-struct}\n\n% Number of energy groups impact over the calculations\nIn the context of this thesis, Moltres uses homogenized group constants previously generated by neutron transport solvers.\nThe choice of the energy group structure for the group constant homogenization affects the diffusion calculation accuracy.\nThe longer neutron mean free path in \\glspl{HTGR} compared to \\gls{LWR} increases the spectral interactions between elements.\nFor this reason, HTGR analyses require more energy groups than conventional \\gls{LWR} analyses.\nThis section summarizes previous studies on the impact of the energy group structure over the diffusion calculations.\n\n\\gls{ANL} directed a study \\cite{lee_status_2006} to compare the accuracy of nodal diffusion calculations employing different energy group structures.\nThe group constant homogenization used the DRAGON neutron transport solver, and the diffusion calculations utilized the application DIF3D.\nFor the study, the ANL team implemented a one-dimensional fuel-reflector model in which they compared the solution accuracy using 4, 7, 8, 14, and 23 energy groups.\nThey also used alternative energy group structures for the same number of groups.\nFor simplicity, the authors used the homogenized fuel compact model and generated all the group constant at 300 K.\nOne of their conclusions was that the number of energy groups should be more than four, and more than six would be sufficient for uranium fueled HTGRs.\nAnother finding was that the accuracy of the diffusion calculation is sensitive to the energy group boundaries.\n% Mention something about the metrics of the study? To asses the accuracy, they compared the multiplication factor.\n\n% \\begin{figure}[htbp!]\n% \t\\centering\n% \t\\includegraphics[width=0.40\\linewidth]{figures/spectrum}\n% \t\\caption{Comparison of neutron energy spectra of different reactor designs. PWR=Pressurized Water Reactor, VHTR=Very High-Temperature Gas-Cooled Reactor, SCWR=Supercritical Water Reactor, SFR=Sodium Fast Reactor, GFR=Gas Fast Reactor, LFR=Lead Fast Reactor. Image reproduced from \\cite{taiwo_summary_2005}.}\n% \t\\label{fig:spectrum}\n% \\end{figure}\n\n% han_sensitivity_2008\nHan's MS thesis \\cite{han_sensitivity_2008} focused on selecting energy groups for the reactor analysis of the \\gls{PBMR}.\nThe author used COMBINE6 \\cite{grimesey_combinepc-portable_1990} for group constant generation and the Penn State nodal diffusion tool NEM \\cite{bandini_three-dimensional_1990} for the reactor analysis.\nThe author compared the results against MCNP5 reference results.\nTo simplify the setup, the model used uniformly distributed isotopes in the fuel.\nThe study performed the calculations at 300 and 1000 K.\nTo arrive at an optimal group structure, the author compared many combinations of group structures using a trial and error strategy.\nOne conclusion of this work agrees with the previous bibliography \\cite{merrill_nuclear_1973} \\cite{duderstadt_nuclear_1976} in that the energy spectrum is critical to yield an accurate description of a nuclear reactor using a few groups.\n\nANL's study helps set up proper nodal diffusion calculations for an \\gls{HTGR}.\nANL's team conducted the study at 300 K --- not in the operational range of any \\glspl{HTGR}.\nOn the contrary, Han's thesis included an analysis at 1000 K, and his results showed that the temperature changes have a non-negligible impact.\nAdditionally, ANL's study used the simplified model of the homogenized fuel compact.\nHan highlighted that homogenized fuel models of the \\gls{PBMR} underestimate criticality calculations.\nIn 2015, \\gls{INL} presented their results \\cite{strydom_results_2015} for an \\gls{IAEA} coordinated research project \\cite{tyobeka_htgr_2011} and showed that the homogenization of the compact material notably underestimates the multiplication factor.\nOn the other hand, the open literature has not widely investigated the impact of such simplification over the homogenized group constants.\n\n\\subsection{Summary of Prismatic HTGR Diffusion Solvers}\n\nSection \\ref{sec:litreview-neut} introduced several deterministic diffusion classes, including FDM, nodal methods, and FEM.\nThe fundamental motivation for the development of nodal methods and FEM was the impractical application of the \\gls{FDM} to three-dimensional problems.\nSection \\ref{sec:litreview-neut} also discussed the main characteristics of these methods, directing the reader's attention to the advantages of the FEM.\nAlthough nodal methods are efficient, most applications make FEMs preferable due to their flexibility in the treatment of irregular geometries.\nAdditionally, FEMs have a firm mathematical basis, and its formulation eases the extension to multi-group applications.\nMoltres relies on the FEM, counting with all the advantages of the method.\n\nSection \\ref{sec:litreview-neut} summarized previous efforts in deterministic diffusion solvers of prismatic HTGRs.\nThis thesis draws two main conclusions from those earlier efforts.\nThe first conclusion is that several authors validated their solvers by comparison to other tools.\nIn the context of this thesis, Chapter \\ref{ch:neutronics} describes two exercises: first, a comparison between Moltres and Serpent-derived results, and second, a comparison between Phase I Exercise 1 of the OECD/NEA MHTGR-350 Benchmark results calculated by Moltres and the benchmark's published results.\nThe second conclusion is that several prismatic HTGR simulators integrate thermal-fluids solvers.\nDue to strong thermal feedback, modeling prismatic HTGRs with Moltres requires incorporating a thermal-fluids solver.\nSection \\ref{sec:litrev-thermalf} discusses previous work in the thermal-fluids modeling of prismatic HTGRs.\n\n% energy group study\nSection \\ref{sec:energy-struct} outlined the importance of the right choice of energy group structure for group constant homogenization.\nDiffusion calculations use homogenized group constants previously generated by neutron transport solvers.\nPrevious studies focused on nodal diffusion calculations of HTGRs.\n% Although further analyses can extrapolate those studies' conclusions to FEM diffusion calculations, such an analysis might be valuable to this thesis.\n% Although further analyses can extrapolate those studies' conclusions to FEM diffusion calculations, such an analysis might be valuable to this thesis.\nAlthough these previous studies' conclusions can be extrapolated to FEM diffusion calculations, this type of analysis might be valuable to this thesis.\nChapter \\ref{ch:neutronics} studies the accuracy of Moltres diffusion calculations for multiple energy group structures.\n\n\\section{Prismatic HTGR Thermal-fluids}\n\\label{sec:litrev-thermalf}\n\n% sort of motivation\nThis section of the literature review summarizes previous work on the thermal-fluids modeling of prismatic HTGRs.\nThermal-fluid calculations enable the correct design of \\glspl{HTGR}.\nPredicting the maximum fuel temperature at steady-state is of paramount importance to succeed in that task.\nI emphasize this statement in the case that hydrogen production is desirable, as that process requires higher coolant temperatures, leading to high fuel and reactor vessel temperatures.\nThis literature review analyzed several approaches that helped to choose a thermal-fluids model to implement in Moltres simulations.\n\n% sort of intro to simplified models\nThe complex geometry of the hexagonal fuel assembly requires numerical calculations for obtaining accurate evaluations \\cite{tak_numerical_2008}.\nThermal-fluids studies for early \\glspl{HTGR} consisted mainly of support calculations for \\gls{NRC} safety analysis reports.\nThe analyses employed sets of independent solvers that relied on simplified approximations.\nSimplified models help understand some fundamental aspects of prismatic HTGRs and have the advantage of reducing the computational expense of the calculations.\n\n% shenoy_htgr_1974\nGeneral Atomics \\cite{shenoy_htgr_1974} developed the first set of software libraries that relied on simplified approximations.\nThe following list introduces and summarizes some of these and their features:\n\n\\begin{itemize}\n\\item FLAC: It determines the coolant flow distribution in the coolant channels and gaps.\nIt solves the one-dimensional momentum equation for incompressible flow and the continuity equations for mass and energy.\n\n\\item POKE: It determines the coolant mass flow, coolant temperature, and fuel temperature distribution.\nIt solves the steady-state mass and momentum conservation equations for parallel channels.\n\n\\item DEMISE: It determines the steady-state three-dimensional temperature distribution in a standard element.\nIt solves the temperature in a network model.\n\n\\item TAC2D: It is a general-purpose thermal analysis software.\nIt solves the two-dimensional heat conduction equation.\n\\end{itemize}\n\nSeveral studies have used these software programs.\n% macdonald_ngnp_2003\nFor example, \\gls{INL} conducted in 2003 a design study \\cite{macdonald_ngnp_2003} in support of the \\gls{NGNP} project.\nThe authors conducted several parametric studies on the GT-MHR \\cite{poiter_gas_1996}, with the objective of increasing the coolant temperature.\nUsing POKE and TAC2D, they evaluated three major design modifications: reducing the bypass flow, controlling the inlet coolant flow distribution, and increasing the reactor's height.\n\nThis thesis differentiates the \\textit{flow network}, \\textit{equivalent cylindrical}, and \\textit{unit cell} models among the simplified approaches.\nThe flow network model treats the coolant flow paths in the core as a cross-connected flow network \\cite{shenoy_htgr_1974}.\nConstant pressure nodes connected to flow branches make up the network.\nThe model uses the one-dimensional conservation equations to solve the pressure loss and coolant temperature in each network node.\nThe equivalent cylinder model uses a geometrically simpler one-dimensional or two-dimensional design model \\cite{shenoy_htgr_1974}\\cite{tak_numerical_2008}.\nThe unit cell model divides the fuel blocks into triangular-shaped unit cells.\nThe model assumes that the coolant removes all the heat generated in the cell \\cite{tak_numerical_2008}.\n\n% flow network model\n% reza_design_2006\nUsing the flow network analysis tool RELAP5-3D/ATHENA \\cite{riemke_relap5-3d_2005}, Reza et al. \\cite{reza_design_2006} conducted a thermal-fluids study of the GT-MHR.\nReza et al. increased the reactor outlet temperature to enable hydrogen production.\nAdditionally, they evaluated alternative inlet coolant flow configurations in an attempt to reduce the reactor vessel temperatures.\nAfter finding an optimal configuration, they assessed the fuel and the reactor vessel's maximum temperatures during the \\gls{LPCC} and the \\gls{HPCC} events.\n\n% equivalent cylindrical model\n% no_multi-component_2007\nAn example of an application using the equivalent cylindrical approach is GAMMA \\cite{lim_gamma_2006}\\cite{no_multi-component_2007}, a system thermal-fluids analysis tool.\nGAMMA's primary motivation is simulating the air ingress event following a LOCA.\nFollowing the depressurization of helium in the core, air could enter the core through the break and oxidize the in-core graphite structure.\nGraphite oxidation is an exothermic chemical reaction and, thus, it is a significant concern.\nGAMMA solves heat conduction, fluid flow, chemical reactions, and multi-component molecular diffusion.\nTogether with a multi-dimensional analysis feature, GAMMA has a one-dimensional analysis capability for  modeling a flow network.\n\n% takada_core_2004\nTakada et al. \\cite{takada_core_2004} carried out another study using the flow network and the equivalent cylindrical model.\nThey developed a thermal-fluids design tool for modeling the \\gls{HTTR}.\nThis tool used the flow network analysis software FLOWNET \\cite{maruyama_verification_1989} for calculating the coolant flow and temperature distributions.\nTEMDIM \\cite{maruyama_verification_1989} solved the fuel temperatures using the equivalent cylindrical model.\nFinally, the authors validated the calculation scheme by comparing its results with the experimental data from the \\gls{HTTR}.\n\n% unit cell model\n% nakano_conceptual_2008\nNakano et al. \\cite{nakano_conceptual_2008} studied different fuel assembly configurations using several simplified approximations.\nThe authors used FLOWNET and TAC2D for determining the flow distribution and fuel temperature.\nThe fuel temperature calculation used the equivalent cylindrical model of a unit cell.\nHowever, the unit cell's asymmetry makes the temperature distribution asymmetric in the graphite block, behavior that the equivalent cylindrical model fails to capture.\n\n% in_three-dimensional_2006\nIn 2006, In et al. \\cite{in_three-dimensional_2006} conducted a more detailed analysis using a three-dimensional model of the unit cell in the hot-spot of the GT-MHR 600, spot in the core with the largest power density.\nThe study predicted the maximum fuel temperature at steady-state at the end of the equilibrium cycle.\nThe \\gls{CFD} software CFX 10 \\cite{ansys_cfx_2005} calculated the three-dimensional temperature profile.\nThe results showed that the maximum fuel temperature surpassed the design limits, so the authors proposed decreasing the power density or the axial power peak as countermeasures.\n\n% more detailed calculations\nPrevious work used simplified approaches to evaluate different aspects of prismatic HTGRs.\nSome of those evaluations include thermal-fluids design, analysis of alternative coolant flow configurations, and accident analysis.\nSuch simplified approaches are helpful to understand essential aspects of prismatic HTGRs but may yield inaccurate temperature distributions \\cite{tak_numerical_2008}.\nMore detailed thermal-fluids evaluations were rare in the open literature until the last 15 years.\nThis thesis summarizes some of those evaluations down below.\n\n% tak_numerical_2008\nIn 2008, an article by Tak et al. \\cite{tak_numerical_2008} conducted a three-dimensional CFD analysis of a fuel column of the PMR600, a pre-conceptual reactor designed by \\gls{KAERI} whose reference design is the GT-MHR.\nThe commercial software CFX 11 \\cite{ansys_cfx_2006} performed the calculations.\nThe study considered a $1/12^{th}$ section of the fuel due to its symmetry.\nUsing the one-dimensional thermal-fluid equations, the model determined the coolant distribution, which served as input to CFX.\nHowever, the friction in the channels is dependent on the viscosity, which is highly dependent on the temperature.\nTherefore, obtaining the mass flow rates from a separate solver may introduce errors \\cite{sato_computational_2010}.\n\n% sato_computational_2010\nAnother article \\cite{sato_computational_2010} studied a $1/12^{th}$ section of the fuel column of the GT-MHR with the commercial tool FLUENT \\cite{fluent_fluent_2006}.\nThe authors conducted parametric studies of several factors, such as bypass-gap width, turbulence model, axial heat generation profile, and geometry changes due to irradiation.\nIn this study, FLUENT obtained the coolant distribution as part of the solution.\nTheir most relevant results showed that the bypass flow caused a large lateral temperature gradient in the block.\nLarge temperature gradients cause excessive thermal stresses, which raise potential structural issues.\n\n% travis_thermalhydraulics_2013\nDespite the recent developments in CFD tools, a detailed full-core analysis of prismatic HTGRs still requires a tremendous computational expense.\nThis requirement is mostly due to the three-dimensional CFD modeling of the coolant flow.\nThis drawback motivated the implementation of simplified methods that reduce the computational time and memory requirements while maintaining accurate results.\nSuch methods combine the accuracy from CFD tools and the light computational expense of system analysis approaches.\n\n% cioni_3d_2005\nCioni et al. \\cite{cioni_3d_2005} presented an article in 2005 in which they conducted three-dimensional simulations of HTGR fuel assemblies.\nThe study's objective was to investigate the blockage of cooling channels in the core.\nThey used the thermal-fluids tool Trio\\_U \\cite{bieder_priceles_2000} to carry out the calculations.\nThe numerical scheme solved the three-dimensional conduction equation in the solid coupled to the coolant's one-dimensional thermal-fluid equations.\nThe one-dimensional thermal-fluid approximation does not resolve the boundary layer avoiding finer meshes near the walls as well as turbulence conservation equations \\cite{tak_development_2014}.\nTheir results showed that the blockage increased the blocked fuel assembly's temperature only and did not affect the surrounding elements due to the bypass flow.\nThis study proves the importance of the modeling of the bypass flow.\n\nTravis et al. \\cite{travis_thermalhydraulics_2013} presented a comparison between a simplified method and detailed CFD simulations.\nTheir method solved the three-dimensional heat conduction equation in the solid and the one-dimensional thermal-fluid equations in the coolant channels.\nThe method's validation analyzed a fuel column and compared the results to those of a three-dimensional CFD simulation using the commercial software STAR-CCM+ \\cite{cd-adapco_star-ccm_2012}.\nTheir simplified scheme reduced the computation time to 2.5\\% of the CFD simulation time.\nOverall, the method showed good accuracy and less than a 2\\% difference to the CFD simulation.\n\n% simoneau_three-dimensional_2007\nSimoneau et al. \\cite{simoneau_three-dimensional_2007} analyzed the transient behavior of an \\gls{HTGR} during the \\gls{DCC} and \\gls{HPCC} event.\nThe CFD tool STAR-CD \\cite{cd-adapco_star-cd_2004} performed the calculations using the porous media model \\cite{nield_convection_1999} to accommodate the different spatial scales.\nSTAR-CD solved the conductive, convective, and radiation heat transfer in a $1/12^{th}$-section of the core and reactor vessel.\n\n% tak_practical_2012 / tak_development_2014\nTak et al. \\cite{tak_practical_2012} \\cite{tak_development_2014} developed the thermal-fluids tool CORONA.\nCORONA solves the three-dimensional heat conduction equation in the solid and the one-dimensional thermal-fluid equations in the coolant.\nTo validate CORONA, the authors analyzed a fuel column and compared their results against the CFD tool CFX and experimental results.\nThe validation results showed that CORONA provided reasonably accurate results.\n\n\\subsection{Summary of Prismatic HTGR Thermal-fluids}\n\nSection \\ref{sec:litrev-thermalf} summarizes previous work on the thermal-fluids modeling of prismatic HTGRs.\nEarly studies relied on simplified approximations to carry out the simulations.\nThese approaches may yield inaccurate temperature distributions requiring more accurate methods, such as CFD techniques.\nAlthough CFD techniques compute detailed temperature profiles, their fine mesh requirement restricts the use of such methods to studies of the local behavior of a single fuel column.\nHowever, a whole-core thermal analysis has many advantages over local models.\nIn general, the problem setup includes more accurate boundary conditions.\nFor example, without whole-core modeling, the local models' mass flow distributions are average values of the core flow rate instead of their exact value \\cite{huning_novel_2016}.\nThis simplification leads to under-predicted fuel temperatures for the assemblies with a lower flow rate than the average.\nAdditionally, a coupled analysis with a reactor physics tool requires a full-core model \\cite{tak_practical_2012}.\nAn alternative for an explicit whole-core analysis are approaches that combine the accuracy from CFD tools and the light computational expense of system analysis applications.\n\nCFD analyses' high computational expense is mostly due to the three-dimensional CFD simulation of the coolant flow \\cite{travis_thermalhydraulics_2013}.\nSection \\ref{sec:litrev-thermalf} presents two alternatives: the porous media model or the combination of the three-dimensional heat conduction equation for the solid structures to the one-dimensional thermal-fluid conservation equations for the coolant.\nDue to the more extensive use of the second alternative in the open literature, this thesis focuses on it.\nChapter \\ref{ch:thermalfluids} studies the implementation of this alternative in Moltres for studying the thermal-fluids of prismatic HTGRs.\n\n\\section{Prismatic HTGR Multi-physics}\n\\label{sec:litreview-multi}\n\n% sort of intro\nHistorically, stand-alone simulations have solved the neutronics and thermal-fluids of HTGRs separately.\nNonetheless, these physical phenomena rely heavily on one another.\nHence, a coupled analysis is necessary to consider the interaction between the neutronics and thermal-fluids behavior \\cite{tak_cappgamma_2016}.\n\n% damian_vhtr_2008\nIn 2008, Damian et al. \\cite{damian_vhtr_2008} studied the passive safety features of a prismatic HTGR using the coupled software NEPTHIS/CAST3M\\cite{cavalier_presentation_2005}\\cite{studer_cast3marcturus_2007}.\nThe study analyzed a three-dimensional core model using the software libraries NEPTHIS and CAST3M/Arcturus for calculating the neutronics and the thermal-fluids, respectively.\nNEPHTIS used a transport-diffusion calculation scheme that relied on the transport application APOLLO2 \\cite{loubiere_apollo2_1999} and the diffusion application CRONOS2.\nCAST3M/Arcturus solved the thermal-fluids using the porous media model.\nThe authors conducted several parametric studies, including the variation of the bypass flow, the average power density, the core geometry, and fuel loading strategy.\n\n% CAPP\nIn 2011, Lee et al. published an article \\cite{lee_development_2011} in which they extended the functionalities of CAPP to prismatic HTGRs.\nTo consider the thermal feedback, the authors integrated into CAPP a simplified thermal-fluids tool based on Stainsby's approach \\cite{stainsby_investigation_2008}.\nThis approach uses different length scale models to solve the temperature distribution.\nThe model divided a fuel column into six triangular prisms, each of them hosting a representative coolant channel, to calculate the axial coolant temperature distribution.\nThe coolant temperature served as input to a two-dimensional conduction model that solved the moderator and fuel compact temperatures.\nThrough a TRISO particle conduction model, the model obtained the fuel temperature.\nFinally, a three-dimensional conduction model based on the \\gls{FDM} calculated the reflector temperature.\nTo validate this model, the authors solved a two-dimensional model of the PMR-200 and compared the results against HELIOS \\cite{casal_helios_1998}.\n\n% tak_cappgamma_2016\nTak et al. \\cite{tak_cappgamma_2016} coupled CAPP and GAMMA+.\nGAMMA uses the one-dimensional form of the mass, momentum, energy, and species conservation equations to solve the fluid's flow and temperature distribution.\nFor solids, it uses three different models: (1) heat conduction model of a TRISO particle, (2) implicit coupling to consider the heat exchange between a fuel compact and TRISO particle, and (3) multi-dimensional heat conduction model of the hexagonal fuel and reflector blocks.\nIn this study, the authors applied the coupled software to study the steady-state performance of the PMR-200.\nSome of their most relevant results revealed that neglecting the bypass flow decreased the active core temperatures; consequently, the multiplication factor increased by approximately 300 pcm.\nThese results prove the importance of the right modeling of the thermal-fluids in coupled simulations of prismatic HTGRs.\n\n% yuk_time-dependent_2020\nA recent article by Yuk et al. \\cite{yuk_time-dependent_2020} added to CAPP the capability to conduct transient analyses.\nThis capability solved the time-dependent neutron diffusion equation with the \\gls{FEM}.\nThe primary motivation behind this feature was to perform reactivity insertion accident simulations.\nTo take into account the thermal feedback, the authors developed a simplified thermal-fluids analysis tool based on Stainsby's approach.\nTo test the new transient capabilities, they analyzed two control rod ejection scenarios and compared the results to those of CAPP/GAMMA+.\n\n% Benchmarks Intro\nThe prismatic HTGR simulation tools available have lagged behind tools and methods developed for \\glspl{LWR}.\nThe evolution of HTGR technology demands the development of more accurate and efficient simulation tools.\nAdditionally, the definition of appropriate benchmarks is essential to compare various tools' capabilities.\n% oecd_nea_coupled_2020\nIn 2012, the \\gls{OECD}/\\gls{NEA} defined a benchmark for the \\gls{MHTGR}-350 MW reactor \\cite{oecd_nea_benchmark_2017}.\nThe purpose of this benchmarking exercise is to compare various reactor physics and thermal-fluid analysis methods.\nThe MHTGR-350 design serves as a basis for this benchmark.\nThe scope of the benchmark is twofold: (1) to establish a well-defined problem, based on a common given data set, to compare methods and tools in core simulation and thermal-fluid analysis, and (2) to test the depletion capabilities of various lattice physics tools available for prismatic HTGRs.\nSection \\ref{sec:ch3-bench} describes the benchmark in more detail.\n\n% j_ortensi_relap-7_2012 j_ortensi_initial_2012\nIn 2012, \\gls{INL} published a study \\cite{j_ortensi_initial_2012} that coupled Pronghorn and RELAP-7 \\cite{andrs_relap-7_2012}.\nPronghorn solved the coupled equations defining the neutron diffusion, fluid flow, and heat transfer in a three-dimensional model of the core.\nRELAP-7 is a MOOSE-based system application and simulated the plant system layout, including the hot and cold ducts, the helium circulator, and the steam generator.\nIt solved the one-dimensional continuity, momentum, and energy equations for a compressible fluid.\nTo test the coupling, INL's team carried out the OECD/NEA MHTGR-350 Benchmark \\cite{oecd_nea_coupled_2020}.\nThe original benchmark provides a set of 26 neutron energy group and temperature-dependent cross-sections.\nTo simplify the debugging, the authors collapsed the 26 groups into two groups.\nAlthough using two groups reduces the model's accuracy, the lower number of groups decreases the calculation time by at least a factor of ten.\nIn their study, a two-dimensional cylindrical model replaced the three-dimensional geometry defined by the benchmark.\nThe integrated system testing included two stages: (1) both stand-alone tools underwent several convergence studies, and (2) the integrated system solved the steady-state problem in an integrated manner.\nThe authors concluded that the coupling between Pronghorn and RELAP-7 was successful.\n\n% tak_coupled_2016\nTak et al. \\cite{tak_coupled_2016} developed a neutronics/thermal-fluids coupled software using DeCART \\cite{kaeri_decart_2007} and CORONA.\nDeCART is a whole-core neutron transport tool, and it was responsible for calculating the power distribution and the fast neutron fluence.\nCORONA calculated the temperature distribution.\nThe authors conducted the OECD/NEA MHTGR-350 benchmark to validate their software and identify technical challenges for future development.\nThe authors presented an interesting analysis in which they compared the coupled simulation results and the stand-alone simulations.\nThe difference in the multiplication factor was as high as 2597 pcm.\nThe axial offset and maximum fuel temperature exhibited significant differences as well.\nThis study highlights the importance of the integration of neutronics and thermal-fluid solvers for simulating prismatic HTGRs.\n\n% tyobeka_htgr_2011 / strydom_results_2015\nSensitivity analysis and uncertainty analysis methods assess the predictive capabilities of coupled neutronics/thermal-fluids simulations.\nIn 2013, the IAEA launched a coordinated research project \\cite{tyobeka_htgr_2011} on the HTGR Uncertainty Analysis in Modeling.\nThe coordinated research project's objective was to determine the uncertainty in HTGR calculations at all stages of coupled reactor physics/thermal-fluids and depletion calculations.\nThis coordinated research project is a natural continuation of the previous IAEA and OECD/NEA international activities \\cite{iaea_evaluation_2003}\\cite{reitsma_oecd-neansc_2008} on Verification and Validation of available HTGR simulator capabilities.\nThe technical approach is to establish and utilize a benchmark for uncertainty analysis.\nThe benchmark defines a series of well-defined problems with complete sets of input specifications and reference experimental data.\nThe coordinated research project adopted the MHTGR-350 as the reference design using the OECD/NEA MHTGR-350 Benchmark \\cite{oecd_nea_benchmark_2017} design specifications.\n\n\\subsection{Summary of Prismatic HTGR Multi-physics}\n\nSection \\ref{sec:litreview-multi} introduced several prior studies of prismatic HTGR multi-physics.\nThese studies highlight the importance of the proper integration of the neutronics and thermal-fluids in HTGR modeling.\nThe neutronics and thermal-fluids physical phenomena rely heavily on each other.\nHence, a coupled analysis is necessary to capture the interaction between the neutronics and the thermal-fluids.\nIn the context of this thesis, Chapter \\ref{ch:thermalfluids} discusses a coupling strategy for the neutronics and thermal-fluids phenomena in Moltres.\n\nSection \\ref{sec:litreview-multi} also summarized different articles focusing on Phase I Exercise 3 of the OECD/NEA MHTGR-350 Benchmark.\nTo validate their software and identify technical challenges for future development, the authors of the different articles conducted the benchmark exercise with and without further simplifications.\nFor studying the coupling strategy in Moltres, Section \\ref{sec:coupled-average} follows a simplified version of the benchmark exercise.\n", "meta": {"hexsha": "6374d27d35f797ab0a8a0de6a02a15c94f0f4cc5", "size": 40173, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "litreview.tex", "max_stars_repo_name": "robfairh/ms-thesis", "max_stars_repo_head_hexsha": "87bc9d4f93d083b08d82c8576b9491f85d0a6457", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-27T15:39:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-27T15:39:36.000Z", "max_issues_repo_path": "litreview.tex", "max_issues_repo_name": "robfairh/ms-thesis", "max_issues_repo_head_hexsha": "87bc9d4f93d083b08d82c8576b9491f85d0a6457", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2020-07-10T18:40:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-02T22:37:02.000Z", "max_forks_repo_path": "litreview.tex", "max_forks_repo_name": "robfairh/ms-thesis", "max_forks_repo_head_hexsha": "87bc9d4f93d083b08d82c8576b9491f85d0a6457", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 93.8621495327, "max_line_length": 310, "alphanum_fraction": 0.8271973714, "num_tokens": 8913, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.43051245090979035}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\title{BOOLEAN: Computing with boolean expressions}\n\\date{}\n\\author{\nH. Melenk\\\\[0.05in]\nKonrad--Zuse--Zentrum f\\\"ur Informationstechnik Berlin \\\\\nTakustra\\\"se 7 \\\\\nD--14195 Berlin -- Dahlem \\\\\nFederal Republic of Germany \\\\[0.05in]\nE--mail: melenk@zib.de \\\\[0.05in]\n}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\n\nThe package {\\bf Boolean} supports the computation with\nboolean expressions in the propositional calculus.\nThe data objects are composed from algebraic expressions (``atomic parts'', ``leafs'')\nconnected by the infix boolean operators {\\bf and}, {\\bf or}, \n{\\bf implies}, {\\bf equiv}, and the unary prefix operator\n{\\bf not}. {\\bf Boolean} allows you to simplify expressions\nbuilt from these operators, and to test properties like\nequivalence, subset property etc. Also the reduction of\na boolean expression by a partial evaluation and combination\nof its atomic parts is supported.\n\n\\section{Entering boolean expressions}\n\nIn order to distinguish boolean data expressions from \nboolean expressions in the \\REDUCE programming\nlanguage (e.g. in an {\\bf if} statement), each expression\nmust be tagged explicitly by an operator {\\bf boolean}.\nOtherwise the boolean operators are not accepted in the\n\\REDUCE  algebraic mode input.\nThe first argument of {\\bf boolean} can be any boolean expression,\nwhich may contain references to other boolean values.\n\\begin{verbatim}\n    boolean (a and b or c);\n    q := boolean(a and b implies c);\n    boolean(q or not c);\n\\end{verbatim}\nBrackets are used to override the operator precedence as usual.\nThe leafs or atoms of a boolean expression are those parts which\ndo not contain a leading boolean operator. These are\nconsidered as constants during the boolean evaluation. There\nare two pre-defined values:\n\\begin{itemize}\n\\item {\\bf true}, {\\bf t} or {\\bf 1}\n\\item {\\bf false}, {\\bf nil} or {\\bf 0}\n\\end{itemize}\nThese represent the boolean constants. In a result\nform they are used only as {\\bf 1} and {\\bf 0}.\n\nBy default, a {\\bf boolean} expression is converted  to a\ndisjunctive normal form, that is a form where terms are connected\nby {\\bf or} on the top level and each term is set of leaf\nexpressions, eventually preceded by {\\bf not} and connected\nby  {\\bf and}. An operators {\\bf or} or {\\bf and} is omitted\nif it would have only one single operand. The result of\nthe transformation is again an expression with leading \noperator {\\bf boolean} such that the boolean expressions\nremain separated from other algebraic data. Only the boolean\nconstants {\\bf 0} and {\\bf 1} are returned untagged.\n\nOn output, the\noperators {\\bf and} and {\\bf or} are represented as\n\\verb+/\\+ and \\verb+\\/+, respectively.\n\\begin{verbatim}\nboolean(true and false);    ->   0\nboolean(a or not(b and c)); -> boolean(not(b) \\/ not(c) \\/ a)\nboolean(a equiv not c);     -> boolean(not(a)/\\c \\/ a/\\not(c))\n\\end{verbatim}\n\n\\section{Normal forms}\n\nThe {\\bf disjunctive} normal form is used by default. It\nrepresents the ``natural'' view and allows us to represent\nany form free or parentheses.\nAlternatively a {\\bf conjunctive} normal form can be\nselected as simplification target, which is a form with\nleading operator {\\bf and}. To produce that form add the keyword  {\\bf and}\nas an additional argument to a call of {\\bf boolean}.\n\\begin{verbatim}\nboolean (a or b implies c); \n                    -> \n     boolean(not(a)/\\not(b) \\/ c)\n\nboolean (a or b implies c, and); \n                    ->\n     boolean((not(a) \\/ c)/\\(not(b) \\/ c))\n\\end{verbatim}\n\nUsually the result is a fully reduced disjunctive or conjuntive normal\nform, where all redundant elements have been eliminated following the\nrules\n\n$ a \\wedge b \\vee \\neg a \\wedge b \\longleftrightarrow b$\n\n$ a \\vee b \\wedge \\neg a \\vee b \\longleftrightarrow b$\n \n\nInternally the full normal forms are computed\nas intermediate result; in these forms each term contains\nall leaf expressions, each one exactly once. This unreduced form is returned \nwhen you set the additional keyword {\\bf full}:\n\\begin{verbatim}\nboolean (a or b implies c, full);\n                   ->\nboolean(a/\\b/\\c \\/ a/\\not(b)/\\c \\/ not(a)/\\b/\\c \\/ not(a)/\\not(b)/\\c\n\n         \\/ not(a)/\\not(b)/\\not(c))\n\\end{verbatim}\n\nThe keywords {\\bf full} and {\\bf and} may be combined.\n\n\\section{Evaluation of a boolean expression}\n\nIf the leafs of the boolean expression are algebraic expressions\nwhich may evaluate to logical values because the environment\nhas changed (e.g. variables have been bound), you can re--investigate\nthe expression using the operator {\\tt testbool} with the boolean\nexpression as argument. This operator tries to evaluate all\nleaf expressions in \\REDUCE boolean style. As many\nterms as possible are replaced by their boolean values; the others\nremain unchanged. The resulting expression is contracted to a\nminimal form. The result {\\bf 1} (= true) or {\\bf 0} (=false)\nsignals that the complete expression could be evaluated. \n\nIn the following example the leafs are built as numeric greater test.\nFor using ${\\bf >}$ in the expressions the greater sign must\nbe declared operator first. The error messages are meaningless.\n\\begin{verbatim}\noperator >;\nfm:=boolean(x>v or not (u>v));\n        ->\n    fm := boolean(not(u>v) \\/ x>v)\n\nv:=10$\n\ntestbool fm;\n\n   ***** u - 10 invalid as number\n   ***** x - 10 invalid as number\n\n        ->\n   boolean(not(u>10) \\/ x>10)\n\nx:=3$\ntestbool fm;\n\n   ***** u - 10 invalid as number\n\n        ->\n   boolean(not(u>10))\n\nx:=17$\n\ntestbool fm;\n\n   ***** u - 10 invalid as number\n      \n        ->\n    1\n \n\\end{verbatim}\n\\end{document}\n\n", "meta": {"hexsha": "cd3ce880b0a7de5db69f18f0f7a0b4f5b7155a36", "size": 5574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/misc/boolean.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/misc/boolean.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/misc/boolean.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7882352941, "max_line_length": 86, "alphanum_fraction": 0.7134912092, "num_tokens": 1415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300048, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4305124509097903}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\\usepackage{verbatim}\n\n\\title{Linear programming notes}\n\\author{Marco Marini}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\begin{abstract}\nThis document contains notes about Linear programming.\n\\end{abstract}\n\n\\section{Supply chain model}\n\nWe define a simplified supply chain model as a system\nthat produces products with a chain of product transformations performed by suppliers.\n\nLet it be\n\\begin{description}\n\t\\item [$ A = a_1 \\dots a_n $]\n\t\tthe set of supplier types\n\t\\item [$ B = b_1 \\dots b_m $]\n\t\tthe set of product types.\n\\end{description}\n\nThe supplier can perform only a single transformation for the its duration.\nEach product can be produced by a single supplier type.\n\nLet it be\n\\begin{description}\n\t\\item [$ S = s_i \\in A $]\n\t\tthe supplier of product $ i \\in B $\n\t\\item [$ N = n_i $]\n\t\tthe number of suppliers of type $ i \\in A $.\n\t\\item[ $ V = v_{i} $ ]\n\t\tthe value of product $ i \\in B $\n\t\\item[ $ Q = q_{i} $ ]\n\t\tthe quantity of produced product $ i \\in B  $l\n\t\\item[ $ T = t_{i} $ ]\n\t\tthe production interval for product $ i \\in B  $\n\t\\item[$ D = d_{ij} $ ]\n\t\tthe quantity of product $ j \\in B $ consumed to produce the product $ i \\in B $.\n\\end{description}\n\n\n\\subsection{Production}\n\nBy now we do not consider the constraint on the availability of consuming products. It will be considered later.\n\nLet be\n\\begin{description}\n\t\\item [$ \\theta_{ij} $]\n\t\tThe matrix that map product $ j \\in B $ to the supplier $ i \\in A $\n\t\\item [$ \\nu i $]\n\tThe number of supplier of product $ i \\in B $\n\\end{description}\nsuch that\n\\[\n\\begin{array}{l}\n\t\\theta_{ij} = 1, s_j = i \\\\\n\t\\theta_{ij} = 0, s_j \\ne i \\\\\n\t\\nu _i = n_{s_j}\n\\end{array}\n\\]\n\nWhen a supplier of type $ i \\in A $ is ready to produce we assign a production slot for the product $ j \\in B $ such that $ s_j = i $ and the production time is $ t_j w_j $ where\n\\begin{description}\n\t\\item[ $ W = w_i $ ] is the slot weight for product $ i \\in B $\n\\end{description}\nsuch that\n\\begin{equation}\n\\label{equ:YConstraints}\n\tw_i \\ge 0\n\\end{equation}\n\nMoreover we may put the supplier $ i \\in A $ in idle state for a while\n\\begin{description}\n\t\\item[$ Z = z_i $]\n\t\tis the idle time during a whole production cycle\n\\end{description}\nsuch that\n\\begin{equation}\n\\label{equ:ZConstraints}\n\tz_i \\ge 0\n\\end{equation}\n\nThe total time of production cycle for supplier $ i $ is\n\\[\n\\begin{array}{l}\n\tU_i(w_j, z_i) = \\sum_{j \\in B | s_j = i} t_j w_j + z_i \\\\\n\t\t= \\sum_{j \\in B} \\theta_{ij} t_j  w_j + z_i \\\\\n\t\t= \\sum_{j, k \\in B} \\theta_{ik} T_{kj} w_j + z_i \\\\\n\t\t= U W + Z\n\\end{array}\n\\]\nsuch that\n\\[\n\tU = u_{ij} = \\sum_{k \\in B} \\theta_{ik} T_{kj} = \\Theta T\n\\]\n\nLet normalize the total time production to 1\n\\begin{equation}\n\\label{equ:normalInterval}\n\tU_i(w_j, z_i) = 1\n\\end{equation}\n\nDuring this interval the suppliers produce the product $ i \\in A $ at a slot rate\n\\begin{equation}\n\\label{equ:prodFreq}\n\tR_i(w_i) = n_{s_i} \\frac{w_i}{y_{s_i}} = n_{s_i} w_i\n\t= \\sum{j \\in B} N_{ij} w_j = N W\n\\end{equation}\n\nThe production rate of product $ i \\in B $ is\n\\begin{equation}\n\\label{equ:prodRate}\n\tP_i(w_j) = R_i(w_j) q_i\n\t\t= Q_{ik} R_k(w_j)\n\t\t= Q N W\n\t\t= P W\n\\end{equation}\nsuch that\n\\[\n\tP = Q N\n\\]\n\n\\subsection{Consumption}\n\nThe (\\ref{equ:prodFreq}) expresses the slot rate of a product for specific suppliers.\nTherefore we can calculate the consumption rate of a product $ i \\in B$ as the sum of consumptions among to produced products\n\\begin{equation}\n\\label{equ:consumRate}\n\tC_i(w_j) = \\sum_{k \\in B} R_k(w_j) d_{ki}\n\t\t\t= \\sum_{k \\in B} d'_{ik} R_k(w_j)\n\t\t\t= D' N W\n\t\t\t= C W\n\\end{equation}\nsuch that\n\\[\n\tC = D' N\n\\]\n\nThe effective production rate is\n\\[\n\tF_i(w_j) = P_i(w_j) - C_i(w_j) = (P - C) W = F W\n\\]\nsuch that\n\\[\n\tF = f_{ij} = P - C = (Q - D') N\n\\]\n\nIf\n\t\\[ F_i(w_j) \\ge 0 \\]\nthe product is produced at a higher rate then it is consumped creating a surplus that can be sold.\n\nOn the other hane we cannot have \n\t\\[ F_i(w_j) < 0 \\]\nbecause it cannot consume more product than the produced.\n\nSo the system must satisfy the constraint\n\\begin{equation}\n\\label{equ:consumptionConstraint}\n\tF_i(w_j) \\ge 0\n\\end{equation}\n\t\n\\subsection{Profit rate}\n\nThe profit rate for the whole supply chain are\n\\begin{equation}\n\\label{equ:valueRate}\n\tG(w_i) =  \\sum_{j \\in B} v_j F_j(w_i)\n\t= V' F W\n\t= G' W\n\\end{equation}\nsuch that\n\\[\n\tG = g_i = (V' F)' ) F' V = N' (Q'-D) V\n\\]\n\nThe problem is to find the optimal production configuration given by the\nvalues of $ w_i $ and $ z_i $ that maximize the value rate $ G(w_i) $.\nThis is defined by the linear system composed by\n(\\ref{equ:YConstraints})\n(\\ref{equ:ZConstraints}),\n(\\ref{equ:normalInterval}),\n(\\ref{equ:consumptionConstraint}),\n(\\ref{equ:valueRate})\n\\begin{equation}\n\\label{equ:linsist}\n\\left\\{\n\\begin{array}{ll}\n\\max_{(w_i, z_j)} G(w_i) & , i \\in B, j \\in A \\\\\nU_i(w_j, z_i) = 1 &  , i \\in A, j \\in B \\\\\nF_i \\ge 0 & , i \\in B \\\\\nw_i \\ge 0 & , i \\in B \\\\\nz_i \\ge 0 & , i \\in A\n\\end{array}\n\\right.\n\\end{equation}\n\n\n\\subsection{Supplier configuration}\n\nOnce resolved the system (\\ ref {equ: linsist}) we have the distributions of the suppliers production slots.\nWe have to transform them into a concrete production configuration assigning for each supplier the producing product or inactivity.\n\nThe numbers of suppliers that are producing the product $ i \\in B $  are given by the total production times of the suppliers for each product rated by the total production times $ U_i(w_i, z_j) = 1 $.\n\\[\n\\begin{array}{l}\n\t\\pi_i = n_{s_i} w_i t_i \\\\\n\t\\Pi = N T W\n\\end{array}\n\\]\n\nThe integer parts of $ \\Pi $ give the number of constant producers by product\n\\[\n\tF = floor(\\Pi)\n\\]\n\nThe remainder fractional parts determine the variable distributions of remainder suppliers by product.\n\\[\n\tR = \\Pi - F\n\\]\n\nThe real configuration may be determined by stocastic selection process based on such distribution.\n\nThe total numbers of random suppliers are\n\\[\n\tR' = ceil(\\Theta R)\n\\]\n\nTo generalize the computation of the probability of a product for each random supplier let the total numbers of suppliers be  \\[\n\tR\" = max(R', 1) \\ge 1\n\\]\n\nThe total numbers of random suppliers by product are\n\\[\n\tS = \\Theta^T R\"\n\\]\n\nThe probabilities of products to be produced by the suppliers are then\n\\[\n\tP = diag(S)^{-1} R\n\\]\n\nTo generate a random configurationi with the given distribution $ P $ we need to compute the probabilities of each product$ j \\in B $ for each supplier $ i \\in A $:\n\\[\n\tP' = p'_{ij} = \\Theta \\, diag(P)\n\\]\n\n\\end{document}", "meta": {"hexsha": "efb27b650f210f14d12f54e611282c48b02b0aaf", "size": 6524, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/supplychain.tex", "max_stars_repo_name": "m-marini/linprog", "max_stars_repo_head_hexsha": "236bddb06b1b26bdbe3a54e7f725c3e67dfaca48", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-20T16:54:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-20T16:54:23.000Z", "max_issues_repo_path": "documents/supplychain.tex", "max_issues_repo_name": "m-marini/linprog", "max_issues_repo_head_hexsha": "236bddb06b1b26bdbe3a54e7f725c3e67dfaca48", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/supplychain.tex", "max_forks_repo_name": "m-marini/linprog", "max_forks_repo_head_hexsha": "236bddb06b1b26bdbe3a54e7f725c3e67dfaca48", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3852140078, "max_line_length": 201, "alphanum_fraction": 0.6790312692, "num_tokens": 2100, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891307678319, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.4305124474591989}}
{"text": "%\n%\n\n\\chapter{Model checking algorithms} \\label{SEC:ModelChecking}\n\n\\section{Temporal logic and model checking}\n\nTemporal logic is concerned with properties of discrete-state models and\ntheir evolution in time. It requires that the model define a set of states\n$\\sset$, a binary relation $\\goesto{~}$ on states (the temporal order),\nand a function that evaluates the truth value of any atomic proposition in\neach state. Starting from a set of atomic predicates, it is then possible\nto express more complex assertions. Let $\\goesto{*}$ be the transitive and\nreflexive closure of $\\goesto{~}$.\nGiven a predicate~$p$ and a state $\\vi$,\nwe can discuss basic questions of the type :\n\n\\begin{itemize}\n\\item\n(in the future) $\\opF{}p$ holds in~$\\vi$ if and only if there exists a state $\\vj$\nsuch that $\\vi \\goesto{*} \\vj$ and $p$ holds in~$\\vj$.\n\\item\n(in the past) $\\opP{}p$ holds in~$\\vi$ if and only if there exists a state $\\vj$\nsuch that $\\vj \\goesto{*} \\vi$ and $p$ holds in~$\\vj$.\n\\item\n(globally) $\\opG{}p$ holds in~$\\vi $ if and only if~$p$ always holds in\nthe future states, equivalent to~$\\neg\\opF{}\\neg p$.\n\\item\n(historically) $\\opH{}p$ holds in $\\vi$ if and only if~$p$ has always held in\nthe past prior to $\\vi$, equivalent to~$\\neg\\opP{}\\neg p$.\n\\end{itemize}\n\nThe adjective ``temporal'' simply refers to the succession of events\nleading from a state to another, not to the actual time of their\noccurrence. In the literature, both \\emph{linear} time logic (LTL) and\n\\emph{branching} time logic (CTL) have received much attention\n\\cite{Clarke1999book,McMillan1992thesis};\n{\\smart} implements the latter. In CTL, operators\noccur only in pairs.  The first operator, the path quantifier, is\neither~$A$ (on all paths), or~$E$ (there exists a path), while the second\none, the tense operator, is chosen from among~$X$ (next),~$F$ (future, or\nfinally),~$G$ (globally, or generally), and~$U$ (until). \nFig.~\\ref{FIG:CTLops} illustrates the meaning of each of the eight operator\ncombinations in CTL.\nNote that {\\smart} also allows the possiblity to talk about the past:\n$\\opY$ is time-reversed $\\opX$,\n$\\opP$ is time-reversed $\\opF$,\n$\\opH$ is time-reversed $\\opG$,\nand \n$\\opS$ is time-reversed $\\opH$.\n\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=0.8]{figures/CTL.pdf}\n  \\caption{Examples of CTL formulae. The root node satisfies the\n  corresponding formula.}\n  \\label{FIG:CTLops}\n\\end{figure}\n\nGiven a discrete-state model, a CTL formula uniquely identifies a set of\nstates that satisfy it. Thus the model checking activity can be thought of\nas the identification of the set of states satisfying the formula.\n{\\smart} uses the type \\Code{stateset} to refer to a set of states\nof a particular model, e.g., those states satisfying a CTL state formula.\n{\\smart} supports both \\emph{explicit} and \\emph{symbolic} model checking.\nAs discussed in Sec.~\\ref{SEC:SSGen},\nthe state space $\\sset$ can be generated and stored explicitly or symbolically;\nif $\\sset$ is stored explicitly, then all \\Code{stateset}s for that model\nwill also be stored explicitly,\nand explicit model checking algorithms will be used\n(options allow selection between different algorithms).\nOtherwise, if $\\sset$ is stored as a decision diagram using Meddly,\nthen so will all \\Code{stateset}s for that model,\nand symbolic model checking algorithms will be used.\n\n\n\n\\section{Model checking in {\\smart}}\n\nThe set of atomic propositions in {\\smart} is represented by boolean\nexpressions inductively constructed over a set of terms. For Petri net\nmodels, the set of terms includes objects of type \\Code{proc bool} and\n\\Code{proc int}, plus the formalism-dependent types \\Code{place} and\n\\Code{trans}. These terms can be combined using boolean operators\n(negation, conjuction, disjunction) between boolean subterms, relational\n(equal, less than, etc.) and arithmetic (addition, multiplication, etc.)\noperators between arithmetic subterms, and the following\nformalism-dependent functions: \n\\begin{itemize} \n  \\item \\Code{proc int tk(place p)}, which returns the number of tokens in place \\Code{p}. \n  \\item \\Code{proc bool enabled(trans t)}, which returns \\Code{true} if transition\n        \\Code{t} is enabled, \\Code{false} otherwise. \n\\end{itemize}\n\n{\\smart} provides the type \\Code{stateset} to define sets of states in a model. \nAny set of states defined for a model is a subset of the ``universe'', \nwhich for explicit storage is the set of reachable states $\\sset$,\nwhile for symbolic storage is the set of potential states $\\potsset = \\sset_K \\times \\cdots \\times \\sset_1$\n(see Sec.~\\ref{SEC:SSGen}).\nHence, it is possible to define sets containing both reachable and unreachable states. \nIf desired, the\nunreachable states can be eliminated from a set by intersecting it with\nthe state space $\\sset$, which is specified in {\\smart} as\n\\Code{reachable}.\n\\TBD{Do we want to make these consistent, i.e., make a stateset always be a subset\nof the reachable states?}\n\nInside a model block, \na \\Code{stateset} for an atomic proposition may be constructed using function\n\\begin{lstlisting}\n    stateset potential(proc bool p)\n\\end{lstlisting}\nwhere $p$ is a boolean expression that depends on the model state,\nand the resulting \\Code{stateset} contains the states in which $p$\nevaluates to true.\nThe eight CTL pairs shown in Fig.~\\ref{FIG:CTLops},\nand their time-reversed counterparts,\ncorrespond to functions in {\\smart} with the same name,\nthat must also be called within a model block.\nFor example,\n\\begin{lstlisting}\n    stateset EU(stateset p, stateset q)\n\\end{lstlisting}\nreturns the \\Code{stateset} containing states\nsatisfying $\\opE\\,p\\,\\opU\\,q$.\nAdditionally,\noperators \\Code{!} (negation / complement), \\Code{\\&} (conjunction / intersection), \n\\Code{|} (disjunction / union), \\verb|\\| (set difference), and \\Code{->} (implication)\nmay be applied to \\Code{stateset}s,\nand are not required to be used within a model block,\nalthough\nit is an error to use \\Code{stateset}s from different models\n(in fact, from different state spaces)\nas operands to the same operator.\nThe cardinality of a \\Code{stateset} may be obtained with\n\\begin{lstlisting}\n    bigint card(stateset p)\n\\end{lstlisting}\nwhich, in the case of symbolic model checking,\nmay return a \\emph{huge} value.\nIf instead we only care if a set is empty or not,\nit is much more efficient to use\n\\begin{lstlisting}\n    bool empty(stateset p)\n\\end{lstlisting}\nwhich is (mathematically, but not computationally)\nequivalent to $0==card(p)$.\nFinally,\nthe elements of a \\Code{stateset} may be printed\nusing the \\Code{print} function;\noption \\Code{StatesetPrintIndexes}\ndictates whether the set is displayed as a list of state indexes\nor a list of states.\n\n\n\\begin{developer}\n\\section{Counterexamples and witnesses}\n\n\\TBD{NOT IMPLEMENTED YET; UPDATE AFTER THAT}\n\nOne of the most attractive features of model checking is its ability to provide\ncounter-examples and witnesses for the properties that are checked. The\ntwo notions are dual. Whenever a formula prefixed with the universal path\nquantifier,~$A$, is not verified, the model checker provides the user with\nan execution trace that proves the negation of the formula (a\n\\emph{counter-example}). Similarly, for a valid formula prefixed with the\nexistential path quantifier,~$E$, the model checker delivers a\n\\emph{witness} to that.\n\nIn both cases, the execution traces are in fact proofs for\nexistentially quantified formulae: $EX p$, $EF p$, $E[p~U~q]$, or $EG p$,\nwhere $p$ is an arbitrary CTL formula.\nAmong these, only the last three cases are interesting,\nsince $EX p$ is trivially computed in one step.\n$EF p$ and $E[q~U~p]$ witnesses are single finite paths that ``show'' how the\ntarget set of states (satisfying formula $p$ in this case) can be reached\nfrom the initial set of states through a sequence of valid transitions.\nIn addition, for the $EU$ witness, $q$ must hold along the entire path until\nthe last state, where $p$ holds.\nFinally, an $EG p$ witness is a strongly connected component (SCC) in the\nreachability graph where formula $p$ holds on all states.\nA typical (non-trivial) SCC is a cycle, with or without chords.\nIn our model checker, the computation of $EG$ traces is reduced to the\nequivalent problem of finding and concatenating two $EU$ traces\nforming a cycle plus possibly a third trace leading to that cycle.\nThus, we can limit our discussion to the traces for $EF$ and $EU$.\n\nSince a trace is usually meant to be examined by a human, it is desirable\nto compute a minimal-length one.\nHowever, finding such a trace for an\narbitrary formula is an NP-complete problem, thus a sub-optimal trace is\nsought in most cases, usually the one that is found first. Due to the\nheavy computation price to be paid, our model checker does not compute the\nexecution traces automatically for each CTL formula that is verified, but\nonly upon request, by calling one of the three functions:\n\n\\begin{itemize}\n\\item \n\\LIGHTGREY{\n\\Code{bool EFtrace(stateset p, stateset q)}\\\\\n  Finds and prints a witness for $EFq$, of shortest length, starting from\n  \\Code{p}.\n  Returns \\Code{true} if such a trace exists, \\Code{false} otherwise. \n}\n\\item \n\\LIGHTGREY{\n\\Code{bool EUtrace(stateset p, stateset q, stateset r)}\\\\\n  Finds and prints a minimal length witness for $E[q~ U~ r]$ that starts at\n  \\Code{p}.\n  Returns \\Code{true} if such a trace exists, \\Code{false} otherwise. \n}\n\\item \\Code{mdd EGtrace(mdd p)}\\\\\n  Finds and prints a shortest witness for $EGq$, starting from the initial state.\n  %Returns \\Code{true} is such a strace exists, \\Code{false} otherwise. \n  \\DEVELOPER{{\\smart} computes this trace by concatenating two traces.}\n\\end{itemize}\n\n\\LIGHTGREY{\nThe output of the above functions is the sequence of states in the\nexecution trace along with the identity of the event fired at each step.\nSee Fig.~\\ref{FIG:TraceOutput} for details on the output format. \nIn addition to these three functions, we provide a distance function:\n}\n\\begin{itemize}\n\\item \n\\LIGHTGREY{\n\\Code{int} \\Code{dist(stateset p, stateset q)} \\\\\n  Returns the length of a shortest path from any state in \\Code{p}\n  to any state in \\Code{q}.\n  If no such path exists, it returns \\Code{infinity}.\n}\n\\end{itemize}\n\n\\LIGHTGREY{\nThe above functions restrict the origin of the trace to a set of states\n\\Code{p}.\nThis is more general than assuming that the execution trace always starts\nwith the initial state.\nOur format is more flexible in that it would eventually enable the\nconcatenation of traces, as required when verifying nested CTL formulae.\nThe original semantics of the traces is simply obtained by setting the argument\n\\Code{p} of the functions to the atomic proposition \\Code{initialstate}.\n}\n\nThe computation of traces in {\\smart} is implemented by means of symbolic\ndata structures.\nThe complete set of traces and the distance function can\nbe computed with a standard approach that uses a forests of MDDs (with\nshared nodes, for efficiency) in conjunction with breadth-first exploration.\nA second approach using edge-valued decision diagrams (a generalized form\nof EVBDDs \\cite{Lai1996EVBDDs}) is also available;\nthis is much more efficient due to its ability to apply the saturation\nstrategy, not just breadth-first exploration, but it can only be used to\ncompute the distance function \\Code{dist}, or $EF$ traces.\nA third approach uses Algebraic Decision Diagrams (ADDs \\cite{Bahar1997ADDs}),\nand it, also, can use either a saturation or a breadth-first approach.\nThe option \\Code{TraceStorage}, with possible\nvalues \\Code{SHMDD\\_BFS}, \\Code{ADD\\_SAT}, \\Code{ADD\\_BFS},\n\\Code{EVMDD\\_BFS}, \\Code{EVMDD\\_SAT} (default) sets the data structure and\niteration strategy used for these two functions\n(see \\cite{2002FMCAD-EVMDD} for a more detailed description).\n\nMoreover, when shared MDDs are used, the type of BFS exploration is\ngoverned by the option \\Code{BFSTrace}, with possible values\n\\Code{FORWARD}, \\Code{BACKWARD}, and \\Code{JOIN} (default).\nFor the first two values, the behavior is symmetric.\nA \\Code{FORWARD} ($EF$ or $EU$) trace starts at the source and reaches the\ntarget by using a forward BFS exploration, which therefore yields the\nshortest length for the generated trace.\nA \\Code{BACKWARD} trace starts at the target and backtracks to the source.\nThe \\Code{JOIN} strategy uses a divide-and-conquer handshaking algorithm\nwhich starts the BFS exploration at both ends and meets in the middle.\nThe trace generation continues recursively on the two segments\ndelimited by the junction point.\n\nWe give here a very simplistic guideline to the complexity analysis of the\nthree variants of trace construction. If~$d$ is the distance from the\nsource to the target set of states (the length of the shortest path\nbetween them), then \\Code{FORWARD} and \\Code{BACKWARD} algorithms store\n$O(d)$ intermediate sets of states, and take $O(d)$ steps to complete,\nwhile the \\Code{JOIN} algorithm stores only two sets of states at all\ntimes, but takes $O(d\\log d)$ steps to compute the trace.\nThe user should adjust the settings according to the desired time/space\ntradeoffs.\nNote that symbolic data structures may be\ncounter-intuitive when it comes to representing sets, as the necessary\nspace is determined by the number of MDD nodes, and not the number of\nencoded states (it is often the case that smaller sets take much more\nmemory than larger sets).\n\\end{developer}\n\n\\section{Examples}\n\n\\begin{figure}\n  \\lstinputlisting[firstline=3]{examples/phils_dead.sm}\n\\caption{Printing the deadlocked states in the dining philosophers model.}\n\\label{FIG:PhilsDeadlock}\n\\end{figure}\n\n\nThe code in Fig.~\\ref{FIG:PhilsDeadlock} generates and prints\nthe deadlocked states (if any exist) in the dining philosophers model. \nThe \\Code{stateset} \\Code{NotAbsorb} contains all potential states that have a\nsome successor, thus all non absorbing states. The \\Code{stateset}\n\\Code{Deadlocked} contains exactly the reachable states not in \\Code{NotAbsorb}, \nthat is, all reachable states with no successor.\nOutside the model,\nwe check if set \\Code{Deadlocked} is empty, and if not, \nwe print the deadlocked states.\nNote we could have simply printed the set;\n{\\smart} will display an empty set if asked to print an empty \\Code{stateset}.\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=0.64]{figures/kripke1.pdf}\n  \\lstinputlisting[firstline=3]{examples/kripke1.sm}\n\\caption{Illustrating temporal operators on a small example.}\n  \\label{FIG:kripke1}\n\\end{figure}\n\nThe code in Fig.~\\ref{FIG:kripke1} illustrates the difference between\nvarious temporal logic operators.\nThe model is partitioned into two submodels, each containing a cycle.\nThe inhibitor arcs in the {\\smart} input file are added to ensure the correct\nsize of the local spaces, they are needed only for methods that pre-generate\nthe local state spaces in isolation.\n\n\\begin{itemize}\n\\item\nThe potential state space is $\\sset_2 \\times \\sset_1$,\nwith $\\sset_2 = \\{a, b, c, \\epsilon\\}$ and $\\sset_1 = \\{\\epsilon, d, e\\}$,\nthus it contains $12$ states\n(by  $\\epsilon$ we mean the local marking where all places are empty,\nby ``$a$'' we mean the local marking where place $a$ contains one token\nand places $b$ and $c$ are empty, and so on).\n\\item\nThe state space contains five states, corresponding to the token being in\nexactly one of the five places.  \n\\item\nThree potential states have a token in $a$,\n$\\{(a,\\epsilon),(a,d),(a,e)\\}$, but only one, $(a,\\epsilon)$, is reachable.\n\\item\nThe reachable states that can reach a state with a token in $a$ are\n$\\{(a,\\epsilon), (b,\\epsilon), (c,\\epsilon)\\}$.\nIf we included the non-reachable states, this set would\ncontain nine states (same reasoning as in the previous item).\n\\item\nIf we search for states that have an outgoing infinite path (i.e., states\nincluded in a strongly connected component) where $a$ always contains a token,\nthe set $\\{(a,d), (a,e)\\}$ is found, but these states are non-reachable,\nso they are not printed when we show the set \\Code{ex.rEGa}.\n\n\\item\nInstead, if we search for a reachable strongly connected component of states\nwhere $a$, or $b$, or $c$ always contain a token,\nwe again find nine potential states or three actual states.\n\\item\nThe $\\opE[c~U~d]$ query finds states $(c,\\epsilon)$ and $(d,\\epsilon)$,\nwhile $\\opA[c~U~d]$ finds only state $(d,\\epsilon)$.\n\n\n\\item\nThe query $\\opE[(a \\vee b \\vee c)~\\opU~d]$ \nfinds the set of four states\n$\\{(a,\\epsilon), (b,\\epsilon), (c,\\epsilon), (d,\\epsilon)\\}$,\nwhile the query $\\opA[(a \\vee b \\vee c)~\\opU~d]$\nfinds only state $(d, \\epsilon)$;\nthis is because it is possible for the token to circulate\namong places $a$, $b$, and $c$ indefinitely.\nIf we instead use a \\emph{stochastic} Petri net model,\nwhere transitions have firing rates,\nthen the underlying structure becomes a continuous-time Markov chain\n(rather than a kripke structure),\nand since any path where the token remains indefinitely in places\n$a$, $b$, and $c$ has probability measure zero,\nin this case the query $\\opA[(a \\vee b \\vee c)~\\opU~d]$\nwill return the same four states as\n$\\opE[(a \\vee b \\vee c)~\\opU~d]$.\n\n\\end{itemize}\n\n\n\n\n\\begin{developer}\n\\TBD{Need to implement execution traces!}\n\n\n\\begin{figure}\n\\begin{lstlisting}\nspn k(int n) := {\n  place pm1, pback1, pkan1, pout1,    pm2, pback2, pkan2, pout2,\n        pm3, pback3, pkan3, pout3,    pm4, pback4, pkan4, pout4;\n  trans tin1, tredo1, tok1, tback1,   tin2, tredo2, tok2, tback2, tout2,\n        tredo3, tok3, tback3,         tredo4, tok4, tback4, tout4;\n  partition(pm1:pback1:pkan1:pout1,   pm2:pback2:pkan2:pout2, \n\t    pm3:pback3:pkan3:pout3,   pm4:pback4:pkan4:pout4);\n  firing(tin1:expo(1.0), tredo1:expo(0.36), tok1:expo(0.84), \n\t tback1:expo(0.3), tin2: expo(0.4), tredo2:expo(0.42), \n\t tok2: expo(0.98), tback2:expo(0.3), tout2: expo(0.5), \n\t tredo3:expo(0.39), tok3:expo(0.91), tback3:expo(0.3), \n\t tredo4:expo(0.33), tok4:expo(0.77), tback4:expo(0.3), tout4:expo(0.9)\n\t); \n  arcs(pkan1:tin1, tin1:pm1, pm1:tredo1, pm1:tok1, tredo1:pback1,\n       tok1:pout1, pback1:tback1, tback1:pm1, pout1:tin2, tin2:pkan1,\n       pkan2:tin2, tin2:pm2, pm2:tredo2, pm2:tok2, tredo2:pback2,\n       tok2:pout2, pback2:tback2, tback2:pm2, pout2:tout2, tout2:pkan2,\n       pkan3:tin2, tin2:pm3, pm3:tredo3, pm3:tok3, tredo3:pback3,\n       tok3:pout3, pback3:tback3, tback3:pm3, pout3:tout2, tout2:pkan3,\n       pkan4:tout2, tout2:pm4, pm4:tredo4, pm4:tok4, tredo4:pback4,\n       tok4:pout4, pback4:tback4, tback4:pm4, pout4:tout4, tout4:pkan4);\n  init(pkan1:n, pkan2:n, pkan3:n, pkan4:n); \n  stateset F := intersection(reachable,\n           potential(tk(pout4)==n & tk(pout1)==n & tk(pout2)==n & tk(pout3)==n));\n  int  D := dist(initialstate, F);\n  bool T := EFtrace(initialstate, F);\n};\n# StateStorage  MDD_SATURATION\n# BFSTrace FORWARD\nint N := read_int(\"N\");\nprint(\"Distance to the farthest state: \", k(N).D, \".\\n\");\nprint(\"Execution trace:\"); compute(k(N).T);\n\\end{lstlisting}\n\\caption{Generating CTL execution traces in {\\smart}.}\n\\label{FIG:KanbanTraces}\n\\end{figure}\n\n\nThe code in Fig.~\\ref{FIG:KanbanTraces} illustrates the use of execution\ntraces on a kanban manufacturing system example (see Fig.~\\ref{FIG:kanban}\nfor the graphical model).\nIn this case, the computation of the witness is influenced by the value of the\n\\Code{BFSTrace} option.\nFigure \\ref{FIG:TraceOutput} shows the two different shortest-length witnesses\nobtained when this option is set to either \\Code{FORWARD} or \\Code{BACKWARD}.\n\n\\begin{figure}\nWhen option \\Code{BFSTrace} is set to \\Code{FORWARD}:\n\\begin{lstlisting}\nEF Trace of length 14\n* Starting from state \t=>  { pkan1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 1: fire event tin1\t=>  { pm1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 2: fire event tok1\t=>  { pout1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 3: fire event tin2\t=>  { pkan1:1 pm2:1 pm3:1 pkan4:1 }\n* Step 4: fire event tin1\t=>  { pm1:1 pm2:1 pm3:1 pkan4:1 }\n* Step 5: fire event tok1\t=>  { pout1:1 pm2:1 pm3:1 pkan4:1 }\n* Step 6: fire event tok2\t=>  { pout1:1 pout2:1 pm3:1 pkan4:1 }\n* Step 7: fire event tok3\t=>  { pout1:1 pout2:1 pout3:1 pkan4:1 }\n* Step 8: fire event tout2\t=>  { pout1:1 pkan2:1 pkan3:1 pm4:1 }\n* Step 9: fire event tin2\t=>  { pkan1:1 pm2:1 pm3:1 pm4:1 }\n* Step 10: fire event tin1\t=>  { pm1:1 pm2:1 pm3:1 pm4:1 }\n* Step 11: fire event tok1\t=>  { pout1:1 pm2:1 pm3:1 pm4:1 }\n* Step 12: fire event tok2\t=>  { pout1:1 pout2:1 pm3:1 pm4:1 }\n* Step 13: fire event tok3\t=>  { pout1:1 pout2:1 pout3:1 pm4:1 }\n* Step 14: fire event tok4\t=>  { pout1:1 pout2:1 pout3:1 pout4:1 }\n\\end{lstlisting}\n\nWhen option \\Code{BFSTrace} is set to \\Code{BACKWARD}:\n\\begin{lstlisting}\nEF Trace of length 14\n* Starting from state \t=>  { pkan1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 1: fire event tin1\t=>  { pm1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 2: fire event tok1\t=>  { pout1:1 pkan2:1 pkan3:1 pkan4:1 }\n* Step 3: fire event tin2\t=>  { pkan1:1 pm2:1 pm3:1 pkan4:1 }\n* Step 4: fire event tok3\t=>  { pkan1:1 pm2:1 pout3:1 pkan4:1 }\n* Step 5: fire event tok2\t=>  { pkan1:1 pout2:1 pout3:1 pkan4:1 }\n* Step 6: fire event tout2\t=>  { pkan1:1 pkan2:1 pkan3:1 pm4:1 }\n* Step 7: fire event tok4\t=>  { pkan1:1 pkan2:1 pkan3:1 pout4:1 }\n* Step 8: fire event tin1\t=>  { pm1:1 pkan2:1 pkan3:1 pout4:1 }\n* Step 9: fire event tok1\t=>  { pout1:1 pkan2:1 pkan3:1 pout4:1 }\n* Step 10: fire event tin2\t=>  { pkan1:1 pm2:1 pm3:1 pout4:1 }\n* Step 11: fire event tok3\t=>  { pkan1:1 pm2:1 pout3:1 pout4:1 }\n* Step 12: fire event tok2\t=>  { pkan1:1 pout2:1 pout3:1 pout4:1 }\n* Step 13: fire event tin1\t=>  { pm1:1 pout2:1 pout3:1 pout4:1 }\n* Step 14: fire event tok1\t=>  { pout1:1 pout2:1 pout3:1 pout4:1 }\n\\end{lstlisting}\n\\caption{The output of $EF$ witnesses, depending on the setting of the\n\\Code{BFSTrace} option.}\n\\label{FIG:TraceOutput}\n\\end{figure}\n\n\\end{developer}\n", "meta": {"hexsha": "ec75b9888ba735901c3234326d7b2e6180d949af", "size": 21682, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/modelchecking.tex", "max_stars_repo_name": "asminer/smart", "max_stars_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2018-05-30T23:02:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-19T07:30:46.000Z", "max_issues_repo_path": "manual/modelchecking.tex", "max_issues_repo_name": "asminer/smart", "max_issues_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/modelchecking.tex", "max_forks_repo_name": "asminer/smart", "max_forks_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-07-13T18:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-12T17:54:02.000Z", "avg_line_length": 44.7975206612, "max_line_length": 107, "alphanum_fraction": 0.7367862743, "num_tokens": 6576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.43048286998222923}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{headerfooter}\n\\usepackage{epsfig}\n\\usepackage{verbatimfiles}\n\\usepackage{fullpage}\n\\usepackage{amsmath}\n\n\\newcommand{\\HRule}{\\rule{\\linewidth}{.3mm}}\n\n\\bibliographystyle{plain}\n\\begin{document}\n\n\\newcommand{\\pd}[2]{\\frac{\\partial{#1}}{\\partial{#2}}}\n\n\\begin{center}\n{\\bf \\Large The OpenSees Truss Element}\n\n{\\bf August 22, 2001} \n\n{\\bf Michael H. Scott} \n\n{\\bf PEER, University of California, Berkeley}\n\\end{center}\n\nThis document provides a brief description of the interaction between a truss\nelement and the UniaxialMaterial class in OpenSees.\nMaterial nonlinearity is abstracted, or separated, from the\nelement formulation by using the UniaxialMaterial class.\nFigure~\\ref{fig:TrussClass} shows the class interaction between a truss\nelement and the UniaxialMaterial class. A truss element can use any one of\nElasticMaterial or HardeningMaterial models. When a new uniaxial material class\nis added to the framework, the truss can use the new class without modification.\n\n\\begin{figure}[htpb]\n\\begin{center}\n\\leavevmode\n\\hbox{%\n\\epsffile{./fig_files/TrussClass.eps}}\n\\end{center}\n\\caption{Truss class diagram}\n\\label{fig:TrussClass}\n\\end{figure}\n\nThe formulation of a linear geometry, material nonlinear truss element is covered\nin the remainder of this document. First, the linear transformation is described,\nfollowed by the truss element formulation.\n\n\\section{Geometric Transformation}\nA linear transformation of displacements and forces between the global and basic\nframes of reference is assumed. The transformation of global displacements,{\\bf u},\nto a single axial displacement, $v_1$, is given by the linear relation,\n\n\\begin{equation}\n\\label{eq:v=Tu}\n{\\bf v} = \\left[ \\begin{array}{c} v_1 \\end{array} \\right] = {\\bf T}{\\bf u}.\n\\end{equation}\n\n\\noindent Based on force equilibrium, the transformation of axial force in the\nbasic system to global forces is also linear,\n\n\\begin{equation}\n\\label{eq:p=Tq}\n{\\bf p} = {\\bf T}^T{\\bf q} = {\\bf T}^T \\left[ \\begin{array}{c} q_1 \\end{array} \\right].\n\\end{equation}\n\nThe transformation between global and basic systems is shown schematically in\nfigure~\\ref{fig:TrussTransf}. The transformation matrix, {\\bf T}, is given in terms\nof the element orientation, $\\theta$, in the global system,\n\n\\begin{equation}\n{\\bf T} = \\left[ \\begin{array}{cccc} -\\cos\\theta & -\\sin\\theta & \\cos\\theta & \\sin\\theta\n\\end{array} \\right].\n\\end{equation}\n\n\\begin{figure}[htpb]\n\\begin{center}\n\\leavevmode\n\\hbox{%\n\\epsfxsize=6.0in\n\\epsffile{./fig_files/TrussTransf.eps}}\n\\end{center}\n\\caption{Linear geometric transformation}\n\\label{fig:TrussTransf}\n\\end{figure}\n\n\\section{Truss Element Formulation}\nThis section describes the formulation of a displacement based truss element.\nThe governing compatibility and equilibrium equations are covered along with the consistent\nelement stiffness. Axial deformations are assumed to be small.\n\n\\subsection{Compatibility}\nFor the truss element, there is a strong form of compatibility between\nbasic displacements, {\\bf v}, and section deformations {\\bf e}, satisfied\npointwise along the element length,\n\n\\begin{equation}\n\\label{eq:e=av}\n{\\bf e}(x) =\n\\left[ \\begin{array}{c} \\varepsilon(x) \\end{array} \\right] =\n{\\bf a}(x) \\: v_1,\n\\end{equation}\n\n\\noindent where {\\bf a} is the strain-displacement matrix and $v_1$ is computed\nfrom equation~\\ref{eq:v=Tu}. There is one section deformation,\nthe axial strain, $\\varepsilon$. Assuming linear axial\ndisplacement the shape function in the basic system is\n\n\\begin{equation}\n\\label{eq:N}\n{\\bf N}(x) =\n\\left[ \\begin{array}{c} N_1(x) \\end{array} \\right] =\n\\left[ \\begin{array}{c} \\frac{x}{L} \\end{array}\n\\right].\n\\end{equation}\n\n\\noindent The strain-displacement matrix contains the shape function derivative.\nAxial strain is the first derivative of the axial displacement,\n\n\\begin{equation}\n{\\bf a}(x) = \\left[ \\begin{array}{c}\nN_{1,x} \\end{array}\n\\right].\n\\end{equation}\n\n\\noindent Using the shape function defined in equation~\\ref{eq:N}, the\nstrain-displacement matrix is then,\n\n\\begin{equation}\n{\\bf a}(x) = \\left[ \\begin{array}{c} \\frac{1}{L}\n\\end{array}\n\\right].\n\\end{equation}\n\n\\noindent Thus, the axial strain, $\\varepsilon$, is constant along the element\nlength and equation~\\ref{eq:e=av} reduces to\n\n\\begin{equation}\n\\varepsilon(x) = \\frac{v_1}{L}.\n\\end{equation}\n\nAfter computing the axial strain, the method {\\em setTrialStrain()} should be invoked\nwith the updated strain.\n\n\\subsection{Equilibrium}\nUsing the principle of virtual displacements (virtual work),\nequilibrium between element end force, {\\bf q}, and section stress\nresultant, {\\bf s},\nis satisfied weakly, or in an average sense, along the element length,\n\n\\begin{equation}\n\\label{eq:q}\n{\\bf q} =  \\left[ \\begin{array}{c} q_1 \\end{array} \\right] =\n\\int_0^L {\\bf a}(x)^T {\\bf s}(x) \\: dx,\n\\end{equation}\n\n\\noindent where the section stress resultant is the axial force, $P$.\nFor the truss element, the stress resultant is computed by integrating\nconstant material stress, $\\sigma$, over the cross-section area, $A$,\n\n\\begin{equation}\n{\\bf s}(x) =\n\\left[ \\begin{array}{c} P(x) \\end{array} \\right] =\n\\left[ \\begin{array}{c} \\sigma A \\end{array} \\right],\n\\end{equation}\n\n\\noindent where $\\sigma$ is constant since the axial strain does\nnot vary along the element length. The integral in equation~\\ref{eq:q}\nreduces to\n\n\\begin{equation}\nq_1 = \\sigma A,\n\\end{equation}\n\n\\noindent since ${\\bf a}(x) = \\frac{1}{L}$.\nTo obtain the current value of material stress, $\\sigma$, the method\n{\\em getStress()} must be invoked. Then the truss force can be transformed\nto the global system via equation~\\ref{eq:p=Tq}, i.e.,\n\n\\begin{equation}\n{\\bf p} = {\\bf T}^T q_1.\n\\end{equation}\n\n\\subsection{Element Stiffness}\nTo solve the structural system of equations, the element stiffness must be assembled\nalong with the resisting force. The element stiffness is obtained by taking the\npartial derivative of equation~\\ref{eq:p=Tq} with respect to displacements,\n{\\bf u}.\n\n\\begin{align}\n{\\bf k} &= \\pd{\\bf p}{\\bf u}\\\\\n&= \\pd{\\bf p}{\\bf q} \\pd{\\bf q}{\\bf v} \\pd{\\bf v}{\\bf u} \\\\\n{\\bf k} &= \\label{eq:k} {\\bf T}^T {\\bf k}_b {\\bf T}\n\\end{align}\n\n\\noindent The basic element stiffness, ${\\bf k}_b$, is the partial derivative\nof the basic forces, {\\bf q}, with respect to the basic displacements, ${\\bf v}$.\nDifferentiating equation~\\ref{eq:q} gives,\n\n\\begin{align}\n{\\bf k}_b &= \\pd{\\bf q}{\\bf v} \\\\\n&= \\int_0^L {\\bf a}(x)^T \\pd{\\bf s}{\\bf v} \\: dx \\\\\n&= \\int_0^L {\\bf a}(x)^T \\pd{\\bf s}{\\bf e} \\pd{\\bf e}{\\bf v} \\: dx \\\\\n{\\bf k}_b &= \\int_0^L {\\bf a}(x)^T {\\bf k}_s(x) {\\bf a}(x) \\: dx \\\\\n\\end{align}\n\n\\noindent Recalling that ${\\bf a}(x) = \\frac{1}{L}$, integration along the\nelement length gives,\n\n\\begin{equation}\n{\\bf k}_b = \\label{eq:kb} \\frac{{\\bf k}_s}{L},\n\\end{equation}\n\n\\noindent for a prismatic element where ${\\bf k}_s$ is constant.\n\nThe section tangent stiffness matrix can be manipulated further and put\nin terms of the material tangent. Recalling that ${\\bf s} = \\sigma A$ and\n${\\bf e} = \\varepsilon$,\n\n\\begin{align}\n{\\bf k}_s &= \\pd{\\bf s}{\\bf e} \\\\\n&= \\pd{\\bf s}{\\varepsilon}\\pd{\\varepsilon}{\\bf e} \\\\\n&= \\pd{\\sigma}{\\varepsilon} A \\\\\n{\\bf k}_s &= \\label{eq:ks} D_t A,\n\\end{align}\n\n\\noindent where $D_t$ is the material tangent, which is returned upon invoking\nthe method {\\em getTangent()}. Combining equations~\\ref{eq:k},~\\ref{eq:kb},\nand~\\ref{eq:ks}, the familiar truss stiffness equation is recovered,\n\n\\begin{equation}\n{\\bf k} = {\\bf T}^T \\frac{D_t A}{L} {\\bf T}.\n\\end{equation}\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "b3da1df8a3a5d1ebfcae85ff58c383131553a0d3", "size": 7513, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "OpenSees/SRC/doc/TrussTheory.tex", "max_stars_repo_name": "kuanshi/ductile-fracture", "max_stars_repo_head_hexsha": "ccb350564df54f5c5ec3a079100effe261b46650", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2019-03-05T16:25:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-17T14:12:03.000Z", "max_issues_repo_path": "SRC/doc/TrussTheory.tex", "max_issues_repo_name": "steva44/OpenSees", "max_issues_repo_head_hexsha": "417c3be117992a108c6bbbcf5c9b63806b9362ab", "max_issues_repo_licenses": ["TCL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SRC/doc/TrussTheory.tex", "max_forks_repo_name": "steva44/OpenSees", "max_forks_repo_head_hexsha": "417c3be117992a108c6bbbcf5c9b63806b9362ab", "max_forks_repo_licenses": ["TCL"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-09-21T03:11:11.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-19T07:29:37.000Z", "avg_line_length": 31.4351464435, "max_line_length": 91, "alphanum_fraction": 0.7166245175, "num_tokens": 2328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.43048286582248707}}
{"text": "\\documentclass[conference]{IEEEtran}\n\\usepackage{cite}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{algorithmic}\n\\usepackage{graphicx}\n\\usepackage{textcomp}\n\\usepackage{array}\n\\usepackage{mathrsfs}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\n\\begin{document}\n\n\\title{Deep Quaternion Networks}\n\n\\author{\\IEEEauthorblockN{Chase J. Gaudet}\n\\IEEEauthorblockA{\\textit{School of Computing \\& Informatics} \\\\\n\\textit{University of Lousiana at Lafayette}\\\\\nLafayette, USA \\\\\ncjg7182@louisiana.edu}\n\\and\n\\IEEEauthorblockN{Anthony S. Maida}\n\\IEEEauthorblockA{\\textit{School of Computing \\& Informatics} \\\\\n\\textit{University of Lousiana at Lafayette}\\\\\nLafayette, USA \\\\\nmaida@louisiana.edu}\n}\n\n\\maketitle\n\n\\begin{abstract}\nThe field of deep learning has seen significant advancement in recent years.\nHowever, much of the existing work has been focused on real-valued numbers.\nRecent work has shown that a deep learning system using the complex numbers can be deeper for a fixed parameter budget compared to its real-valued counterpart.\nIn this work, we explore the benefits of generalizing one step further into the hyper-complex numbers, quaternions specifically, and provide the architecture components needed to build deep quaternion networks.\nWe develop the theoretical basis by reviewing quaternion convolutions, developing a novel quaternion weight initialization scheme, and developing novel algorithms for quaternion batch-normalization.\nThese pieces are tested in a classification model by end-to-end training on the CIFAR-10 and CIFAR-100 data sets and a segmentation model by end-to-end training on the KITTI Road Segmentation data set. \nThese quaternion networks show improved convergence compared to real-valued and complex-valued networks, especially on the segmentation task, while having fewer parameters.\n\\end{abstract}\n\n\\begin{IEEEkeywords}\nquaternion, complex, neural networks, deep learning\n\\end{IEEEkeywords}\n\n\\section{Introduction}\nThere have been many advances in deep neural network architectures in the past few years.\nOne such improvement is a normalization technique called batch normalization \\cite{ioffe2015batch} that standardizes the activations of layers inside a network using minibatch statistics.\nIt has been shown to regularize the network as well as provide faster and more stable training.\nAnother improvement comes from architectures that add so called shortcut paths to the network.\nThese shortcut paths connect later layers to earlier layers typically, which allows for the stronger gradients to propagate to the earlier layers.\nThis method can be seen in Highway Networks \\cite{srivastava2015training} and Residual Networks  \\cite{he2016deep}.\nOther work has been done to find new activation functions with more desirable properties.\nOne example is the exponential linear unit (ELU) \\cite{clevert2015fast}, which attempts to keep activations standardized.\nAll of the above methods are combating the vanishing gradient problem \\cite{hochreiter1991untersuchungen} that plagues deep architectures.\nWith solutions to this problem appearing it is only natural to move to a system that will allow one to construct deeper architectures with as low a parameter cost as possible.\n\nOther work in this area has explored the use of complex and hyper-complex numbers, which are a generalization of the complex, such as quaternions.\nUsing complex numbers in recurrent neural networks (RNNs) has been shown to increase learning speed and provide a more noise robust memory retrieval mechanism \\cite{arjovsky2016unitary, danihelka2016associative, wisdom2016full}.\nThe first formulation of complex batch normalization and complex weight initialization is presented by \\cite{trabelsi2017deep} where they achieve some state of the art results on the MusicNet data set.\nHyper-complex numbers are less explored in neural networks, but have seen use in manual image and signal processing techniques \\cite{bulow1999hypercomplex, sangwine2000colour, bulow2001hypercomplex}.\nExamples of using quaternion values in networks is mostly limited to architectures that take in quaternion inputs or predict quaternion outputs, but do not have quaternion weight values \\cite{rishiyur2006neural, kendall2015posenet}. \nThere are some more recent examples of building models that use quaternions represented as real-values. \nIn \\cite{parcollet2016quaternion} they used a quaternion multi-layer perceptron (QMLP) for document understanding and \\cite{minemoto2017feed} uses a similar approach in processing multi-dimensional signals. \n\nBuilding on \\cite{trabelsi2017deep} our contribution in this paper is to formulate and implement quaternion convolution, batch normalization, and weight initialization \\footnote{Source code located at https://github.com/gaudetcj/DeepQuaternionNetworks}.\nThere arises some difficulty over complex batch normalization that we had to overcome as their is no analytic form for our inverse square root matrix.\n\n\\section{Motivation and Related Work}\nThe ability of quaternions to effectively represent spatial transformations and analyze multi-dimensional signals makes them promising for applications in artificial intelligence.\n\nOne common use of quaternions is for representing rotation into a more compact form. \nPoseNet \\cite{kendall2015posenet} used a quaternion as the target output in their model where the goal was to recover the $6-$DOF camera pose from a single RGB image.\nThe ability to encode rotations may make a quaternion network more robust to rotational variance.\n\nQuaternion representation has also been used in signal processing.  \nThe amount of information in the phase of an image has been shown to be sufficient to recover the majority of information encoded in its magnitude by Oppenheim and Lin \\cite{oppenheim1981importance}.\nThe phase also encodes information such as shapes, edges, and orientations.\nQuaternions can be represented as a 2~x~2 matrix of complex numbers, which gives them a group of phases potentially holding more information compared to a single phase.\n\nBulow and Sommer \\cite{bulow2001hypercomplex} used the higher complexity representation of quaternions by extending Gabor's complex signal to a quaternion one which was then used for texture segmentation.\nAnother use of quaternion filters is shown in \\cite{sangwine2000colour} where they introduce a new class of filter based on convolution with hyper-complex masks, and present three color edge detecting filters. \nThese filters rely on a three-space rotation about the grey line of RGB space and when applied to a color image produce an almost greyscale image with color edges where the original image had a sharp change of color.\nMore quaternion filter use is shown in \\cite{shi2007quaternion} where they show that it is effective in the context of segmenting color images into regions of similar color texture. \nThey state the advantage of using quaternion arithmetic is that a color can be represented and analyzed as a single entity (by assigning each color channel to an imaginary axis), which we will see holds for quaternion convolution in a convolutional neural network architecture as well in Section \\ref{s:qc}.\n\nA quaternionic extension of a feed forward neural network, for processing multi-dimensional signals, is shown in \\cite{minemoto2017feed}.\nThey expect that quaternion neurons operate on multi-dimensional signals as single entities, rather than real-valued neurons that deal with each element of signals independently.\nA convolutional neural network (CNN) should be able to learn a powerful set of quaternion filters for more impressive tasks.\n\nAnother large motivation is discussed in \\cite{trabelsi2017deep}, which is that complex numbers are more efficient and provide more robust memory mechanisms compared to the reals \\cite{bulow1999hypercomplex, sangwine2000colour, bulow2001hypercomplex}.\nThey continue that residual networks have a similar architecture to associative memories since the residual shortcut paths compute their residual and then sum it into the memory provided by the identity connection.\nAgain, given that quaternions can be represented as a complex group, they may provide an even more efficient and robust memory mechanisms.\n\n\n\\section{Quaternion Network Components}\nThis section will include the work done to obtain a working deep quaternion network. \nSome of the longer derivations are given in the Appendix.\n\n\\subsection{Quaternion Representation}\nIn 1833 Hamilton proposed complex numbers $\\mathbb{C}$ be defined as the set $\\mathbb{R}^2$ of ordered pairs $(a, b)$ of real numbers.\nHe then began working to see if triplets $(a,b,c)$ could extend multiplication of complex numbers.\nIn 1843 he discovered a way to multiply in four dimensions instead of three, but the multiplication lost commutativity.\nThis construction is now known as quaternions.\nQuaternions are composed of four components, one real part, and three imaginary parts.\nTypically denoted as\n\\begin{equation}\n\\mathbb{H} = \\{a + b\\textit{i} + c\\textit{j} + d\\textit{k}~:~a,b,c,d \\in \\mathbb{R}\\}\n\\label{eq:quaternion1}\n\\end{equation}\nwhere $a$ is the real part, $(i,j,k)$ denotes the three imaginary axis, and $(b,c,d)$ denotes the three imaginary components.\nQuaternions are governed by the following arithmetic:\n\\begin{equation}\ni^2=j^2=k^2=ijk=-1\n\\label{eq:quarternion2}\n\\end{equation}\nwhich, by enforcing distributivity, leads to the noncommutative multiplication rules\n\\begin{equation}\nij=k,~jk=i,~ki=j,~ji=-k,~kj=-i,~ik=-j\n\\label{eq:quarternion3}\n\\end{equation}\n\nSince we will be performing quaternion arithmetic using reals it is useful to embed $\\mathbb{H}$ into a real-valued representation.\nThere exists an injective homomorphism from $\\mathbb{H}$ to the matrix ring $M(4,\\mathbb{R})$ where $M(4,\\mathbb{R})$ is a 4x4 real matrix.\nThe 4~x~4 matrix can be written as\n\\begin{align}\n\\begin{bmatrix}\n a & -b & -c & -d \\\\ \n b & a & -d & c \\\\\n c & d & a & -b \\\\\n d & -c & b & a \n\\end{bmatrix}= &~~a\n\\begin{bmatrix}\n 1 & 0 & 0 & 0 \\\\ \n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \n\\end{bmatrix}\n\\nonumber \\\\ &+ b \n\\begin{bmatrix}\n 0 & -1 & 0 & 0 \\\\ \n 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & -1 \\\\\n 0 & 0 & 1 & 0 \n\\end{bmatrix}\n\\nonumber \\\\ &+ c\n\\begin{bmatrix}\n 0 & 0 & -1 & 0 \\\\ \n 0 & 0 & 0 & 1 \\\\\n 1 & 0 & 0 & 0 \\\\\n 0 & -1 & 0 & 0 \n\\end{bmatrix}\n\\nonumber \\\\ &+ d\n\\begin{bmatrix}\n 0 & 0 & 0 & -1 \\\\ \n 0 & 0 & -1 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 1 & 0 & 0 & 0 \n\\end{bmatrix}.\n\\label{eq:m4r}\n\\end{align}\nThis representation of quaternions is not unique, but we will stick to the above in this paper.\nIt is also possible to represent $\\mathbb{H}$ as $M(2,\\mathbb{C})$ where $M(2,\\mathbb{C})$ is a 2~x~2 complex matrix.\n\nWith our real-valued representation a quaternion real-valued $2D$ convolution layer can be expressed as follows. \nSay that the layer has $N$ feature maps such that $N$ is divisible by 4.\nWe let the first $N/4$ feature maps represent the real components, the second $N/4$ represent the $i$ imaginary components, the third $N/4$ represent the $j$ imaginary components, and the last $N/4$ represent the $k$ imaginary components.\n\n\n\\subsection{Quaternion Differentiability}\nIn order for the network to perform backpropagation the cost function and activation functions used must be differentiable with respect to the real, $i$, $j$, and $k$ components of each quaternion parameter of the network.\nAs the complex chain rule is shown in \\cite{trabelsi2017deep}, we provide the quaternion chain rule which is given in the Appendix section \\ref{a:diff}.\n\n\n\\subsection{Quaternion Convolution}\\label{s:qc}\nConvolution in the quaternion domain is done by convolving a quaternion filter matrix $\\textbf{W}=\\textbf{A}+\\textit{i}~\\textbf{B}+\\textit{j}~\\textbf{C}+\\textit{k}~\\textbf{D}$ by a quaternion vector $\\textbf{h}=\\textbf{w}+\\textit{i}~\\textbf{x}+\\textit{j}~\\textbf{y}+\\textit{k}~\\textbf{z}$.\nHere $\\textbf{A}$, $\\textbf{B}$, $\\textbf{C}$, and $\\textbf{D}$ are real-valued matrices and $\\textbf{w}$, $\\textbf{x}$, $\\textbf{y}$, and $\\textbf{z}$ are real-valued vectors.\nPerforming the convolution by using the distributive property and grouping terms one gets\n\\begin{align}\n\\textbf{W}\\ast \\textbf{h} = &~(\\textbf{A}\\ast\\textbf{w}-\\textbf{B}\\ast\\textbf{x}-\\textbf{C}\\ast\\textbf{y}-\\textbf{D}\\ast\\textbf{z}) + \\nonumber \\\\ \n&\\textit{i}(\\textbf{A}\\ast\\textbf{x}+\\textbf{B}\\ast\\textbf{w}+\\textbf{C}\\ast\\textbf{z}-\\textbf{D}\\ast\\textbf{y}) + \\nonumber \\\\\n&\\textit{j}(\\textbf{A}\\ast\\textbf{y}-\\textbf{B}\\ast\\textbf{z}+\\textbf{C}\\ast\\textbf{w}+\\textbf{D}\\ast\\textbf{x}) + \\nonumber \\\\\n&\\textit{k}(\\textbf{A}\\ast\\textbf{z}+\\textbf{B}\\ast\\textbf{y}-\\textbf{C}\\ast\\textbf{x}+\\textbf{D}\\ast\\textbf{w}).\n\\end{align}\nUsing a matrix to represent the components of the convolution we have:\n\\begin{equation}\n\\begin{bmatrix}\n \\mathscr{R}(\\textbf{W}\\ast \\textbf{h}) \\\\ \n \\mathscr{I}(\\textbf{W}\\ast \\textbf{h}) \\\\\n \\mathscr{J}(\\textbf{W}\\ast \\textbf{h}) \\\\\n \\mathscr{K}(\\textbf{W}\\ast \\textbf{h}) \n\\end{bmatrix}\n=\n\\begin{bmatrix}\n \\textbf{A} & -\\textbf{B} & -\\textbf{C} & -\\textbf{D}\\\\\n \\textbf{B} & \\textbf{A} & -\\textbf{D} & \\textbf{C} \\\\\n \\textbf{C} & \\textbf{D} & \\textbf{A} & -\\textbf{B} \\\\\n \\textbf{D} & -\\textbf{C} & \\textbf{B} & \\textbf{A} \\\\\n\\end{bmatrix}\n\\ast\n\\begin{bmatrix}\n \\textbf{w} \\\\ \n \\textbf{x} \\\\\n \\textbf{y} \\\\\n \\textbf{z}\n\\end{bmatrix}\n\\label{eq:qconvolve2}\n\\end{equation}\n\nAn example is shown in Fig.~\\ref{f:quatconv}, which is useful to visualize one of the main motivational factors of quaternions for CNNs.\nNotice that the result of the quaternion convolution produces a unique linear combination of each axis per the result of a single axis.\nThis comes from the structure of quaternion multiplication and is forcing each axis of the kernel to interact with each axis of the image.\nReal-valued convolution simply multiplies each channel of the kernel with the corresponding channel of the image.\nThe quaternion convolution is similar to a mixture of standard convolution and depthwise separable convolution from \\cite{chollet2016xception}. \nDepthwise separable convolution is where first a flat convolution kernel (no depth to match the depth of the feature image) is applied separately to each feature map.\nThis is only giving spatial context on each feature map individually.\nThen a $1\\times1$ convolution is applied to the results of the previous operation to get a linear interaction of the feature maps, projecting them into a new feature map space.\n\nThe quaternion network's reuse of filters on every axis and combination may help extract texture information across channels as seen in \\cite{shi2007quaternion}.\nOne can think in terms of a RGB image where the greyscale of the image can be the real axis and the RGB channels individually can be the $i, j, k$ axes.\nThen a quaternion kernel convolved against this quaternion image will view the colors as a single entity, unlike standard real-valued convolution.\nSince a quaternion can be thought of as a vector, the quaternion kernels and feature maps can be thought of as vectors as well.\n\n\\begin{figure*}\n\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{quatconv.png}\n\t\\caption{An illustration of quaternion convolution.}\n\t\\label{f:quatconv}\n\\end{figure*}\n\n\n\\subsection{Quaternion Batch-Normalization}\nBatch-normalization \\cite{ioffe2015batch} is used by the vast majority of all deep networks to stabilize and speed up training.\nIt works by keeping the activations of the network at zero mean and unit variance.\nThe original formulation of batch-normalization only works for real-values. \nApplying batch normalization to complex or hyper-complex numbers is more difficult, one can not simply translate and scale them such that their mean is 0 and their variance is 1.\nThis would not give equal variance in the multiple components of a complex or hyper-complex number.\nTo overcome this for complex numbers a whitening approach is used \\cite{trabelsi2017deep}, which scales the data by the square root of their variances along each of the two principle components.\nWe use the same approach, but must whiten 4D vectors.\n\nHowever, an issue arises in that there is no nice way to calculate the inverse square root of a 4~x~4 matrix.\nIt turns out that the square root is not necessary and we can instead use the Cholesky decomposition on our covariance matrix.\nThe details of why this works for whitening given in the Appendix section \\ref{a:whitening}.\nNow our whitening is accomplished by multiplying the \\textbf{0}-centered data ($\\textbf{x} - \\mathbb{E}[\\textbf{x}]$) by \\textbf{W}:\n\\begin{equation}\n\\tilde{x} = \\textbf{W}(\\textbf{x} - \\mathbb{E}[\\textbf{x}])\n\\label{eq:white4d}\n\\end{equation}\nwhere \\textbf{W} is one of the matrices from the Cholesky decomposition of $\\textbf{V}^{-1}$ where \\textbf{V} is the covariance matrix given by:\n\\begin{align*}\n\\textbf{V}\n=&\n\\begin{bmatrix}\n V_{rr} & V_{ri} & V_{rj} & V_{rk} \\\\\n V_{ir} & V_{ii} & V_{ij} & V_{ik} \\\\\n V_{jr} & V_{ji} & V_{jj} & V_{jk} \\\\\n V_{kr} & V_{ki} & V_{kj} & V_{kk}\n\\end{bmatrix}\n\\label{eq:V4d}\n\\end{align*}\nwhere each $V$ is the covariance between its two subscripts which represent the real, $i$, $j$, and $k$ components of $\\textbf{x}$ respectively.\n\nReal-valued batch normalization also uses two learned parameters, $\\beta$ and $\\gamma$. \nOur shift parameter {\\boldmath$\\beta$} must shift a quaternion value so it is a quaternion value itself with real, $i$, $j$, and $k$ as learnable components. \nThe scaling parameter {\\boldmath$\\gamma$} is a symmetric matrix of size matching $\\textbf{V}$ given by:\n\\begin{equation}\n\\mathbf{\\gamma}\n=\n\\left( \n\\begin{array}{cccc}\n\\gamma_{rr} & \\gamma_{ri} & \\gamma_{rj} & \\gamma_{rk} \\\\\n\\gamma_{ri} & \\gamma_{ii} & \\gamma_{ij} & \\gamma_{ik} \\\\\n\\gamma_{rj} & \\gamma_{ij} & \\gamma_{jj} & \\gamma_{jk} \\\\\n\\gamma_{rk} & \\gamma_{ik} & \\gamma_{jk} & \\gamma_{kk}\n\\end{array}\n\\right)\n\\label{eq:gamma}\n\\end{equation}\nBecause of its symmetry it has only ten learnable parameters. \nThe variance of the components of input $\\tilde{\\textbf{x}}$ are variance 1 so the diagonal of {\\boldmath$\\gamma$} is initialized to $1/\\sqrt{4}$ in order to obtain a modulus of 1 for the variance of the normalized value. \nThe off diagonal terms of {\\boldmath$\\gamma$} and all components of {\\boldmath$\\beta$} are initialized to 0.\nThe quaternion batch normalization is defined as:\n\\begin{equation}\n\\mbox{BN}(\\tilde{\\textbf{x}}) = \\mathbf{\\gamma}\\tilde{\\textbf{x}} + \\mathbf{\\beta}\n\\label{eq:qbn}\n\\end{equation}\n\n\n\\subsection{Quaternion Weight Initialization}\nThe proper initialization of weights is vital to convergence of deep networks. \nIn this work we derive our quaternion weight initialization using the same procedure as Glorot and Bengio \\cite{glorot2010understanding} and He et al. \\cite{he2015delving}.\n\nTo begin we find the variance of a quaternion weight:\n\\begin{align}\nW = &~|W|e^{(\\mbox{cos}\\phi_1 \\textit{i} + \\mbox{cos}\\phi_2 \\textit{j} + \\mbox{cos}\\phi_3 \\textit{k})\\theta} \\nonumber \\\\\n= &~\\mathscr{R}\\{W\\} + \\mathscr{I}\\{W\\} + \\mathscr{J}\\{W\\} + \\mathscr{K}\\{W\\}.\n\\label{eq:quaternion_weight}\n\\end{align}\nwhere $|W|$ is the magnitude, $\\theta$ and $\\phi$ are angle arguments, and $\\mbox{cos}^2\\phi_1 + \\mbox{cos}^2\\phi_2 + \\mbox{cos}^2\\phi_3 = 1$ \\cite{turner2002}.\n\nVariance is defined as\n\\begin{equation}\n\\mbox{Var}(W) = \\mathbb{E}[|W|^2] - (\\mathbb{E}[W])^2,\n\\label{eq:variance}\n\\end{equation}\nbut since $W$ is symmetric around 0 the term $(\\mathbb{E}[W])^2$ is 0. \nWe do not have a way to calculate $\\mbox{Var}(W) = \\mathbb{E}[|W|^2]$ so we make use of the magnitude of quaternion normal values $|W|$, which follows an independent normal distribution with four degrees of freedom (DOFs).\nWe can then calculate the expected value of $|W|^2$ to find our variance\n\\begin{equation}\n\\mathbb{E}[|W|^2] = \\int_{-\\infty}^\\infty x^2 f(x) ~dx = 4\\sigma^2\n\\label{eq:expected}\n\\end{equation}\nwhere $f(x)$ is the four DOF distribution given in the Appendix.\n\nAnd since $\\mbox{Var}(W) = \\mathbb{E}[|W|^2]$, we now have the variance of $W$ expressed in terms of a single parameter $\\sigma$:\n\\begin{equation}\n\\mbox{Var}(W) = 4\\sigma^2.\n\\label{eq:variance_sigma}\n\\end{equation}\n\nTo follow the Glorot and Bengio \\cite{glorot2010understanding} initialization we have $\\mbox{Var}(W) = 2/(n_{in}+n_{out})$, where $n_{in}$ and $n_{out}$ are the number of input and output units respectivly. \nSetting this equal to \\eqref{eq:variance_sigma} and solving for $\\sigma$ gives $\\sigma = 1/\\sqrt{2(n_{in}+n_{out})}$.\nTo follow He et al. \\cite{he2015delving} initialization that is specialized for rectified linear units (ReLUs) \\cite{nair2010rectified}, then we have $\\mbox{Var}(W) = 2/n_{in}$, which again setting equal to \\eqref{eq:variance_sigma} and solving for $\\sigma$ gives $\\sigma = 1/\\sqrt{2n_{in}}$.\n\nAs shown in \\eqref{eq:quaternion_weight} the weight has components $|W|$, $\\theta$, and $\\phi$. \nWe can initialize the magnitude $|W|$ using our four DOF distribution defined with the appropriate $\\sigma$ based on which initialization scheme we are following. \nThe angle components are initialized using the uniform distribution between $-\\pi$ and $\\pi$ where we ensure the constraint on $\\phi$.\n\n\n\\section{Experimental Results}\nOur experiments covered image classification using both the CIFAR-10 and CIFAR-100 benchmarks \\cite{krizhevsky2009learning} and image segmentation using the KITTI Road Estimation benchmark \\cite{Fritsch2013ITSC}. \nThe CIFAR datasets are $32\\times32$ color images of 10 and 100 classes receptively.\nEach image only contains one class and labels are provided.\nThe KITTI dataset is large color images of varying sizes depicting roads as seen from a driver's perspective.\nEach image has a corresponding label image in which each pixel is an integer value relating to a class of road or not road.\nWe chose CIFAR because it is a extremely common benchmark task making it a good sanity check.\nThe KITTI dataset was chosen because it is a fairly common, color segmentation benchmark and has binary classes which made it a simple test.\nAll training was done on a single Nvidia 980Ti.\n\n\\subsection{Classification}\nWe use the same architecture as the large model in \\cite{trabelsi2017deep}, which is a 110 layer Residual model similar to the one in \\cite{he2016deep}.\nThere is one difference between the real-valued network and the ones used for both the complex and hyper-complex valued networks.\nBecause the datasets are all real-valued the network must learn the imaginary or quaternion components.\nWe use the same technique as \\cite{trabelsi2017deep} where there is an additional residual block immediately after the input which will learn the hyper-complex components\n\\begin{equation*}\nBN \\rightarrow ReLU \\rightarrow Conv \\rightarrow BN \\rightarrow ReLU \\rightarrow Conv.\n\\end{equation*}\nOne of these blocks exist per imaginary component and are concatenated with the original input image.\nAnother possible choice if using color images is to use the gray scale image as the real axis and then use the red, green, and blue channels as the $i, j,$ and $k$ axis respectively.\nWith this choice it is not necessary to use the above block after input to learn the imaginary components.\n\nTo maintain the same parameter budget among the three network types we divided the number of filters per layer of the real network by a factor of two for the complex, and by a factor of four for the quaternion.\n\nThe architecture for all models consists of 3 stages of repeating residual blocks,\n\\begin{equation*}\nBN \\rightarrow ReLU \\rightarrow Conv \\rightarrow BN \\rightarrow ReLU \\rightarrow Conv,\n\\end{equation*}\nwhere at the end of each stage the images are downsized by a strided convolution.\nFor these classification experiments we ran a shallow network where the stages contained 2, 1, and 1 residual blocks respectively and a deep network where the stages contained 10, 9, and 9 residual blocks respectively.\nEach stage also doubles the previous stage's number of convolution kernels.\nFor example the real model has 32 kernels in the first stage, 64 in the second, and finally 124 in the last.\nThe last two layers are a global average pooling layer followed by a single fully connected layer with a softmax function used to classify the input as either one of the 10 classes in CIFAR-10 or one of the 100 classes in CIFAR-100.\n\nWe also followed their training procedure of using the backpropagation algorithm with Stochastic Gradient Descent with Nesterov momentum \\cite{nesterov1983method} set at 0.9.\nThe norm of the gradients were clipped to 1 and a custom learning rate scheduler was used.\nThe learning scheduler was the same used in \\cite{trabelsi2017deep} for a direct comparison in performance.\nThe learning rate was initially set to 0.01 for the first 10 epochs and then set to 0.1 from epoch 11-100 and then cut by a factor of 10 at epochs 120 and 150.\nTable~\\ref{t:results1} presents our results alongside the real and complex valued networks.\nOur quaternion models outperform the real and complex networks on both datasets with a smaller parameter count.\nThe quaternion models do take roughly 50\\% longer to train due to the computationally intense operations of quaternion batch normalization.\n\n\\begin{table}[h]\n\t\\centering\n\t\t\\begin{tabular}{l c c c c}\n\t\t\t\\hline\n\t\t\tArchitecture & Params & CIFAR-10 & CIFAR-100 \\\\\n\t\t\t\\hline\n\t\t\tShallow Real & 508,932 & 6.82 & 32.02 \\\\\n\t\t\tShallow Complex & 257,412 & 6.91 & 31.65 \\\\\n\t\t\tShallow Quaternion & 133,560 & \\textbf{6.77} & \\textbf{30.59} \\\\\n\t\t\t\\hline\n\t\t\tDeep Real & 3,619,844 & 6.37 & 28.07 \\\\\n\t\t\tDeep Complex & 1,823,620 & 5.60 & 27.09 \\\\\n\t\t\tDeep Quaternion & 932,792 & \\textbf{5.44} & \\textbf{26.01} \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t\\caption{Classification error on CIFAR-10 and CIFAR-100. Params is the total number of parameters.}\n\t\\label{t:results1}\n\\end{table}\n\n\\subsection{Segmentation}\nFor this experiment we used the same model as the above, but cut the number of residual blocks out of the model for memory reasons given that the KITTI data is large color images about $1200 \\times 375$ pixels in size.\nWe only use one model due to resource limitations for this experiment.\nIt is the same as the small model from the classification experiments which has 2, 1, and 1 blocks at the three stages, but it does not perform any strided convolutions.\nIt also does not have the global average pooling layer or the fully connected layer.\n\nThe last layer is a $1 \\times 1$ convolution with a sigmoid output so we are getting a heatmap prediction the same size as the input.\nThe training procedure is also as above, but the learning rate is scheduled differently.\nHere we begin at 0.01 for the first 10 epochs and then set it to 0.1 from epoch 11-50 and then cut by a factor of 10 at 100 and 150.\nTable~\\ref{t:results2} presents our results along side the real and complex valued networks where we used Intersection over Union (IOU) for performance measure.\nQuaternion outperformed the other two by a larger margin compared to the classification tasks and again, with a smaller parameter count.\n\n\\begin{table}[h]\n\t\\centering\n\t\t\\begin{tabular}{l c c}\n\t\t\t\\hline\n\t\t\tArchitecture & Params & KITTI \\\\\n\t\t\t\\hline\n\t\t\tReal & 507,029 & 0.747 \\\\\n\t\t\tComplex & 254,037 & 0.769 \\\\\n\t\t\tQuaternion & 128,701 & \\textbf{0.827}\n\t\t\\end{tabular}\n\t\\caption{IOU on KITTI Road Estimation benchmark.}\n\t\\label{t:results2}\n\\end{table}\n\n\\section{Conclusions}\nWe have extended upon work looking into complex valued networks by exploring quaternion values.\nWe presented the building blocks required to build and train deep quaternion networks and used them to test residual architectures on two common image classification benchmarks.\nWe show that they have competitive performance by beating both the real and complex valued networks with less parameters.\nFuture work will be needed to test quaternion networks for more segmentation datasets and for audio processing tasks.\n\n\n\\section{Acknowledgment}\nWe would like to thank James Dent of the University of Louisiana at Lafayette Physics Department for helpful discussions.\nWe also thank Fugro for research time on this project.\n\n\\bibliography{bib}{}\n\\bibliographystyle{ieeetr}\n\n\\section{Appendix}\n\\subsection{The Generalized Quaternion Chain Rule for a Real-Valued Function}\\label{a:diff}\nWe start by specifying the Jacobian.\nLet $L$ be a real valued loss function and $q$ be a quaternion variable such that $q = a+\\textit{i}~b+\\textit{j}~c+\\textit{k}~d$ where $a,b,c,d \\in \\mathbb{R}$ then,\n\\begin{align}\n\\nabla_L(q) &= \\frac{\\partial L}{\\partial q} = \\frac{\\partial L}{\\partial a} + \\textit{i}~\\frac{\\partial L}{\\partial b} + \\textit{j}~\\frac{\\partial L}{\\partial c} + \\textit{k}~\\frac{\\partial L}{\\partial d} \\\\ \\nonumber\n&= \\frac{\\partial L}{\\partial \\mathbb{R}(q)} + \\textit{i}~\\frac{\\partial L}{\\partial \\mathbb{I}(q)} + \\textit{j}~\\frac{\\partial L}{\\partial \\mathbb{J}(q)} + \\textit{k}~\\frac{\\partial L}{\\partial \\mathbb{K}(q)} \\\\ \\nonumber\n&= \\mathbb{R}(\\nabla_L(q)) + i~\\mathbb{I}(\\nabla_L(q)) + j~\\mathbb{J}(\\nabla_L(q)) + k~\\mathbb{K}(\\nabla_L(q)) \n\\label{eq:diff1}\n\\end{align}\nNow let $g = m+\\textit{i}~n+\\textit{j}~o+\\textit{k}~p$ be another quaternion variable where $q$ can be expressed in terms of $g$ and $m,n,o,p \\in \\mathbb{R}$ we then have,\n\\begin{align}\n\\nabla_L(q) &= \\frac{\\partial L}{\\partial g} = \\frac{\\partial L}{\\partial m} + \\textit{i}~\\frac{\\partial L}{\\partial n} + \\textit{j}~\\frac{\\partial L}{\\partial o} + \\textit{k}~\\frac{\\partial L}{\\partial p} \\\\ \\nonumber\n&= \\frac{\\partial L}{\\partial a}\\frac{\\partial a}{\\partial m} + \\frac{\\partial L}{\\partial b}\\frac{\\partial b}{\\partial m} + \\frac{\\partial L}{\\partial c}\\frac{\\partial c}{\\partial m} + \\frac{\\partial L}{\\partial d}\\frac{\\partial d}{\\partial m} \\\\ \\nonumber\n&~~+ \\textit{i}~\\left( \\frac{\\partial L}{\\partial a}\\frac{\\partial a}{\\partial n} + \\frac{\\partial L}{\\partial b}\\frac{\\partial b}{\\partial n} + \\frac{\\partial L}{\\partial c}\\frac{\\partial c}{\\partial n} + \\frac{\\partial L}{\\partial d}\\frac{\\partial d}{\\partial n} \\right) \\\\ \\nonumber\n&~~+ \\textit{j}~\\left( \\frac{\\partial L}{\\partial a}\\frac{\\partial a}{\\partial o} + \\frac{\\partial L}{\\partial b}\\frac{\\partial b}{\\partial o} + \\frac{\\partial L}{\\partial c}\\frac{\\partial c}{\\partial o} + \\frac{\\partial L}{\\partial d}\\frac{\\partial d}{\\partial o} \\right) \\\\ \\nonumber\n&~~+ \\textit{k}~\\left( \\frac{\\partial L}{\\partial a}\\frac{\\partial a}{\\partial p} + \\frac{\\partial L}{\\partial b}\\frac{\\partial b}{\\partial p} + \\frac{\\partial L}{\\partial c}\\frac{\\partial c}{\\partial p} + \\frac{\\partial L}{\\partial d}\\frac{\\partial d}{\\partial p} \\right) \\\\ \\nonumber\n&= \\frac{\\partial L}{\\partial a} \\left( \\frac{\\partial a}{\\partial m} + \\textit{i}~\\frac{\\partial a}{\\partial n} + \\textit{j}~\\frac{\\partial a}{\\partial o} + \\textit{k}~\\frac{\\partial a}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial b} \\left( \\frac{\\partial b}{\\partial m} + \\textit{i}~\\frac{\\partial b}{\\partial n} + \\textit{j}~\\frac{\\partial b}{\\partial o} + \\textit{k}~\\frac{\\partial b}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial c} \\left( \\frac{\\partial c}{\\partial m} + \\textit{i}~\\frac{\\partial c}{\\partial n} + \\textit{j}~\\frac{\\partial c}{\\partial o} + \\textit{k}~\\frac{\\partial c}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial d} \\left( \\frac{\\partial d}{\\partial m} + \\textit{i}~\\frac{\\partial d}{\\partial n} + \\textit{j}~\\frac{\\partial d}{\\partial o} + \\textit{k}~\\frac{\\partial d}{\\partial p} \\right) \\\\ \\nonumber\n&= \\frac{\\partial L}{\\partial \\mathbb{R}(q)} \\left( \\frac{\\partial a}{\\partial m} + \\textit{i}~\\frac{\\partial a}{\\partial n} + \\textit{j}~\\frac{\\partial a}{\\partial o} + \\textit{k}~\\frac{\\partial a}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial \\mathbb{I}(q)} \\left( \\frac{\\partial b}{\\partial m} + \\textit{i}~\\frac{\\partial b}{\\partial n} + \\textit{j}~\\frac{\\partial b}{\\partial o} + \\textit{k}~\\frac{\\partial b}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial \\mathbb{J}(q)} \\left( \\frac{\\partial c}{\\partial m} + \\textit{i}~\\frac{\\partial c}{\\partial n} + \\textit{j}~\\frac{\\partial c}{\\partial o} + \\textit{k}~\\frac{\\partial c}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\frac{\\partial L}{\\partial \\mathbb{K}(q)} \\left( \\frac{\\partial d}{\\partial m} + \\textit{i}~\\frac{\\partial d}{\\partial n} + \\textit{j}~\\frac{\\partial d}{\\partial o} + \\textit{k}~\\frac{\\partial d}{\\partial p} \\right) \\\\ \\nonumber\n&= \\mathbb{R}(\\nabla_L(q)) \\left( \\frac{\\partial a}{\\partial m} + \\textit{i}~\\frac{\\partial a}{\\partial n} + \\textit{j}~\\frac{\\partial a}{\\partial o} + \\textit{k}~\\frac{\\partial a}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\mathbb{I}(\\nabla_L(q)) \\left( \\frac{\\partial b}{\\partial m} + \\textit{i}~\\frac{\\partial b}{\\partial n} + \\textit{j}~\\frac{\\partial b}{\\partial o} + \\textit{k}~\\frac{\\partial b}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\mathbb{J}(\\nabla_L(q)) \\left( \\frac{\\partial c}{\\partial m} + \\textit{i}~\\frac{\\partial c}{\\partial n} + \\textit{j}~\\frac{\\partial c}{\\partial o} + \\textit{k}~\\frac{\\partial c}{\\partial p} \\right) \\\\ \\nonumber\n&~~+ \\mathbb{K}(\\nabla_L(q)) \\left( \\frac{\\partial d}{\\partial m} + \\textit{i}~\\frac{\\partial d}{\\partial n} + \\textit{j}~\\frac{\\partial d}{\\partial o} + \\textit{k}~\\frac{\\partial d}{\\partial p} \\right)\n\\label{eq:diff2}\n\\end{align}\n\n\n\\subsection{Whitening a Matrix}\\label{a:whitening}\nLet $\\textbf{X}$ be an $n$~x~$n$ matrix and $\\mbox{cov}(\\textbf{X}) = \\mathbf{\\Sigma}$ is the symmetric covariance matrix of the same size.\nWhitening a matrix linearly decorrelates the input dimensions, meaning that whitening transforms $\\textbf{X}$ into $\\textbf{Z}$ such that $\\mbox{cov}(\\textbf{Z}) = \\textbf{I}$ where $\\textbf{I}$ is the identity matrix \\cite{kessy2017optimal}. \nThe matrix $\\textbf{Z}$ can be written as:\n\\begin{equation}\n\\textbf{Z} = \\textbf{W}(\\textbf{X} - \\mu)\n\\label{eq:white1}\n\\end{equation}\nwhere $\\textbf{W}$ is an $n$~x~$n$ `whitening' matrix. Since $\\mbox{cov}(\\textbf{Z}) = \\textbf{I}$ it follows that:\n\\begin{align}\n&\\mathbb{E}[\\mathbf{Z}\\mathbf{Z}^T] = \\mathbf{I} \\nonumber \\\\\n&\\mathbb{E}[\\mathbf{W}(\\mathbf{X - \\mu})(\\mathbf{W}(\\mathbf{X} - \\mu))^T] = \\mathbf{I} \\nonumber \\\\\n&\\mathbb{E}[\\mathbf{W}(\\mathbf{X - \\mu})(\\mathbf{X} - \\mu)^T\\mathbf{W}^T] = \\mathbf{I} \\nonumber \\\\\n&\\mathbf{W}\\Sigma\\mathbf{W}^T = \\mathbf{I} \\nonumber \\\\\n&\\mathbf{W}\\Sigma\\mathbf{W}^T\\mathbf{W} = \\mathbf{W} \\nonumber \\\\\n&\\mathbf{W}^T \\mathbf{W} = \\mathbf{\\Sigma}^{-1} \\label{eq:white2}\n\\end{align}\nFrom \\eqref{eq:white2} it is clear that the Cholesky decomposition provides a suitable (but not unique) method of finding $\\textbf{W}$.\n\n\\subsection{Cholesky Decomposition}\nCholesky decomposition is an efficient way to implement LU decomposition for symmetric matrices, which allows us to find the square root.\nConsider $\\textbf{A}\\textbf{X} = \\textbf{b}$, $\\textbf{A}=[a_{ij}]_{n\\times n}$, and $a_{ij} = a_{ji}$, then the Cholesky decomposition of $\\textbf{A}$ is given by $\\textbf{A} = \\textbf{L}\\textbf{L}'$ where\n\\begin{equation}\n\\textbf{L}=\n\\begin{bmatrix}\n l_{11} & 0 & \\ldots & 0 \\\\\n l_{21} & l_{22} & \\ldots & \\vdots \\\\\n \\vdots & \\vdots & \\ddots & 0 \\\\\n l_{n1} & l_{n2} & ... & l_{nn} \\\\\n\\end{bmatrix}\n\\label{eq:cholesky1}\n\\end{equation}\nLet $l_{ki}$ be the $k^{th}$ row and $i^{th}$ column entry of $\\textbf{L}$, then\n\n\\[ \n   l_{ki} = \n\t \\begin{cases} \n      0, & k < i \\\\\n      \\sqrt{a_{ii} - \\sum_{j=1}^{i-1}l^2_{kj}}, & k=i \\\\\n      \\frac{1}{l_{ii}} (a_{ki} - \\sum_{j=1}^{i-1}l_{ij}l_{kj}), & i < k \n   \\end{cases}\n\\]\n\n\\subsection{4 DOF Independent Normal Distribution}\nConsider the four-dimensional vector $\\textbf{Y} = (S,T,U,V)$ which has components that are normally distributed, centered at zero, and independent. \nThen $S$, $T$, $U$, and $V$ all have density functions\n\\begin{equation}\nf_S(x;\\sigma) = f_T(x;\\sigma) = f_U(x;\\sigma) = f_V(x;\\sigma) = \\frac{e^{-x^2/(2\\sigma^2)}}{\\sqrt{2\\pi\\sigma^2}}.\n\\label{eq:single_dists}\n\\end{equation}\nLet $\\textbf{X}$ be the length of $\\textbf{Y}$, which means $\\textbf{X} = \\sqrt{S^2+T^2+U^2+V^2}$.\nThen $\\textbf{X}$ has the cumulative distribution function\n\\begin{equation}\nF_X(x;\\sigma) = \\int \\!\\!\\!\\int \\!\\!\\!\\int \\!\\!\\!\\int_{H_x} \\!\\!f_S(\\mu;\\sigma)f_T(\\mu;\\sigma)f_U(\\mu;\\sigma)f_V(\\mu;\\sigma) ~dA,\n\\label{eq:cumdist}\n\\end{equation}\nwhere $H_x$ is the four-dimensional sphere\n\\begin{equation}\nH_x = \\left\\{(s,t,u,v)~:~\\sqrt{s^2+t^2+u^2+v^2} < x \\right\\}.\n\\label{eq:4dsphere}\n\\end{equation}\nWe then can write the integral in polar representation\n\\begin{align}\nF_X(x;\\sigma) = & ~\\frac{1}{4\\pi^2\\sigma^4} \\!\\int_0^\\pi \\!\\!\\!\\!\\int_0^\\pi \\!\\!\\!\\!\\int_0^{2\\pi} \\!\\!\\!\\!\\!\\int_0^x \\!r^3e^{\\frac{-r^2}{2\\sigma^2}} \\mbox{sin}(\\theta) \\mbox{sin}(\\phi) \\mbox{cos}(\\psi) ~dr d\\theta d\\phi d\\psi \\nonumber \\\\\n= & ~\\frac{1}{2\\sigma^4} \\int_0^x r^3e^{-r^2/(2\\sigma^2)} ~dr.\n\\label{eq:polarint}\n\\end{align}\nThe probability density function of $\\textbf{X}$ is the derivative of its cumulative distribution function so we use the funamental theorem of calculus on \\eqref{eq:polarint} to finally arrive at\n\\begin{equation}\nf_X(x;\\sigma) = \\frac{d}{dx}F_X(x;\\sigma) =  ~\\frac{1}{2\\sigma^4} x^3e^{-x^2/(2\\sigma^2)}.\n\\label{eq:finaldist}\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "6220ab68e29b61c3a152b1be5a8e2e7acdc4a22e", "size": 37179, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/ieee_version/DeepQuaternionNets.tex", "max_stars_repo_name": "asbharath/DeepQuaternionNetworks", "max_stars_repo_head_hexsha": "475834c39b17229e288f81fdafd3f8175bd64a7c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2017-10-31T20:06:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T14:12:42.000Z", "max_issues_repo_path": "paper/ieee_version/DeepQuaternionNets.tex", "max_issues_repo_name": "asbharath/DeepQuaternionNetworks", "max_issues_repo_head_hexsha": "475834c39b17229e288f81fdafd3f8175bd64a7c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2018-03-20T00:07:26.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T18:58:53.000Z", "max_forks_repo_path": "paper/ieee_version/DeepQuaternionNets.tex", "max_forks_repo_name": "heheqianqian/DeepQuaternionNetworks", "max_forks_repo_head_hexsha": "199d261f080896c9408e771f980b8a98e159f847", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2017-10-31T20:06:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T08:56:43.000Z", "avg_line_length": 69.1059479554, "max_line_length": 307, "alphanum_fraction": 0.7353613599, "num_tokens": 11034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4304828606688831}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage{preamble}\n\n\\title{Machine Learning Course\\\\\\large{Notebook}}\n\\author{Mariana Jó}\n\\date{\\today}\n\n\\begin{document}\n  \\maketitle\n  \\thispagestyle{fancy}\n\n\n  \\section{What is Machine Learning?}\n  \\begin{itemize}\n    \\item Definitions of ML \\\\\n    \\textit{\"A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.\"}\n    \\item Kinds of ML algorithms\n  \\end{itemize}\n\n  \\section{Supervised learning}\n  Some definitions:\n  \\begin{itemize}\n    \\item Supervised Learning: We give the dataset the \"right answers\"\n    \\item Regression: predict continous valued output\n    \\item Classification: discrete valued output\n    \\item Support Vector Machines: an algorithm that can deal with an infinite number of features\n  \\end{itemize}\n  \\section{Unsupervised learning}\n  \\textit{\"Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don't necessarily know the effect of the variables. With unsupervised learning there is no feedback based on the prediction results.\"}\n  \\begin{itemize}\n    \\item Clustering: groups things that are somehow similar and/or related\n    \\item Non-clustering: finds structure. Ex.: cocktail party algorithm.\n  \\end{itemize}\n\n  \\section{Model representation}\n  \\textbf{Notation:}\n  \\begin{itemize}\n    \\item $m=$ Number of training examples\n    \\item $x=$ \"input\" variable / features\n    \\item $y=$ \"output\" variable / \"target\" variable\n    \\item $(x,y)=$ one training example\n    \\item $\\theta=$parameter\n  \\end{itemize}\n  About hypothesis $h$:\n  \\begin{itemize}\n    \\item Hypothesis $h$: takes the input $x$ and outputs the estimated value $y$, i.e., $h$ maps from $x$'s to $y$'s.\n    \\item How do we represent $h$? \\\\\n    We choose an initial choice\n    \\begin{equation}\n    h_\\theta (x)=\\theta_0 +\\theta_1 x  ,\n    \\label{eq:hypothesis}\n    \\end{equation}\n    which is a linear function.\n    \\item Linear Regression with one variable $=$ Univariate Linar Regression\n  \\end{itemize}\n  Cost function:\n  \\begin{itemize}\n    \\item We try to minimize $\\theta_0 \\theta_1$\n    \\item So we try to minimize\n    \\begin{equation}\n    J(\\theta_0, \\theta_1)=\\frac{1}{2m}\\sum_{i=1}^m \\left(h_\\theta (x^i) - y^i\\right)^2\n  \\end{equation}\n  where $h_\\theta (x)$ is given by \\ref{eq:hypothesis} and $J(\\theta_0, \\theta_1)$ is called the \\textbf{cost function}. This function is also called \\textbf{Squared error function} or \\textbf{Mean Squared Error (MSE)}.\n  \\item The mean is halved $(\\frac{1}{2})$ as a convenience for the computation of the gradient descent, as the derivative term of the square function will cancel out the $\\frac{1}{2}$ term.\n  \\end{itemize}\n\n  \\section{Parameter Learning}\n  Gradient descent\n  \\begin{itemize}\n    \\item Given $J(\\theta_0, \\theta_1)$, we want to minimize it.\n    \\item Start with some $\\theta_0, \\theta_1$\n    \\item Keep changing $\\theta_0, \\theta_1$ to reduce $J(\\theta_0, \\theta_1)$\n    \\item Gradient descent algorithm: \\\\\n    Repeat until convergence:\n    \\begin{equation}\n      \\theta_j := \\theta_j - \\alpha \\frac{\\partial}{\\partial \\theta_j}\n      J(\\theta_0, \\theta_1), \\quad (\\text{for} \\ j=0 \\ \\text{and} \\ j=1)\n      \\label{eq:gradient_descent}\n    \\end{equation}\n    where $\\alpha$ is the \\textbf{learning rate} and $\\alpha \\geqslant   0$.\n    \\item It is importante to make the simultaneous update of $\\theta_0$ and $\\theta_1$.\n    \\item \"Batch\" Gradient descent means that each step of gradient descent uses all the training examples, i.e., all the $m$ examples.\n  \\end{itemize}\n  For Linear Regression:\n  \\begin{itemize}\n    \\item $J(\\theta_0, \\theta_1)$ will always be a Convex Function, i.e., a \"bowl-shaped function\"\n    \\item This implies that it does not have any local optima, only the global one.\n  \\end{itemize}\n\n  \\section{Prediction and Inference}\n\n  \\begin{itemize}\n    \\item Prediction: you use variables to predict \\textbf{values}\n    \\item Inference: you use variables to understand behaviors, find structures, etc\n  \\end{itemize}\n\n  \\subsection*{Prediction accuracy vs. Model interpretability}\n\n  Usually, when you want to \\textit{predict}, you don't care very much about \\textbf{interpretability}, because what matters is the accuracy and not how variables are correlated, and then you can have more \\textbf{flexibility}. On the other hand, when you want to make an \\textit{inference}, you also want to \\textbf{interpret} the algorithm's outcomes, therefore you will end up using less \\textbf{flexible} methods.\n\n  \\begin{quotation}\n    \\textit{\"In general, as the flexibility of a method increases, its interpretability decreases.\"} - ISLR-Gareth \\cite{gareth}.\n  \\end{quotation}\n\n\\begin{figure}[h]\n  \\includegraphics[width=0.75\\textwidth]{trade-off_garneth}\n  \\caption{How the learning algorithms are classified in terms of flexibility vs. interpretability, from ISLR-Gareth \\cite{gareth}.}\n  \\label{}\n\\end{figure}\n\n\\section{Multivariate Linear Regression}\n\nLet\n\\begin{equation}\n  \\mathbf{x}=\n  \\begin{bmatrix}\n    x_0 \\\\ x_1 \\\\ x_2 \\\\ \\vdots \\\\ x_n\n  \\end{bmatrix} \\in \\mathbb{R}^{n+1}\n  \\quad \\text{and} \\quad\n  \\theta=\n  \\begin{bmatrix}\n    x_0 \\\\ x_1 \\\\ x_2 \\\\ \\vdots \\\\ x_n\n  \\end{bmatrix} \\in \\mathbb{R}^{n+1}\n\\end{equation}\n\nthen the Multivariate Linear Regression is defined by\n\\begin{equation}\n  h_\\theta(x)=\\theta_0 x_0 + \\theta_1 x_1 + \\dots + \\theta_n x_n = \\theta^T \\mathbf{x}\n\\end{equation}\n\n\\subsection*{Gradient descent}\nIn the case $n\\geq 1$ case, you should repeat:\n\\begin{equation}\n  \\theta_j := \\theta_j - \\alpha\\frac{1}{m}\\sum_{i=1}^m (h_\\theta (x^{(i)})-y^{(i)})x_{j}^{(i)}\n\\end{equation}\n\nThere are some tricks to help the Gradient Descent converge more quickly:\n\\begin{itemize}\n  \\item Feature scaling\n    \\subitem get every feature into approximately a $-1 \\leq x \\leq 1$ range\n    \\subitem mean normalization: $\\frac{x_i-\\mu_i}{s_i}$ where $\\mu_i$ is the mean of the $x_i$ and $s_i$ is the range.\n  \\item Debugging: your $J(\\theta)$ should descrease at every iteration. If it's increasing, or if it shows an \"weird\" behavior (like descreasing and increasing over and over) maybe you should use a smaller $\\alpha$. But if $alpha$ is too small, gradient descent can be slow to converge.\n\\end{itemize}\n\n\\subsection*{Normal equation}\nIt is a method to solve for $\\theta$ \"analytically\". In this case, you don't need to use feature scaling.\n\n\\begin{equation}\n  \\theta=(X^T X)^{-1}X^T y\n\\end{equation}\n\nGradient descent\n\\begin{itemize}\n  \\item Need choose $\\alpha$\n  \\item Needs many itrations\n  \\item Works well even when $n$ is large\n\\end{itemize}\n\nNormal equation\n\\begin{itemize}\n  \\item No need to chosse $\\alpha$\n  \\item Don't need to iterate\n  \\item Need to compute $(X^TX)^{-1}$\n  \\item Slow if $n$ is very large (usually for $n\\geq 10000$)\n\\end{itemize}\n\n$X^TX$ could be non-invertible if\n\\begin{itemize}\n  \\item The features are linear dependente\n  \\item You have too many features. You should delete some features or use regulatization.\n\\end{itemize}\n\n\\clearpage\n\\begin{thebibliography}{99}\n  \\bibitem{gareth}\n  Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani,\n  \\textit{Introduction to Statistical Learning with Applications in R},\n  Springer,\n  2017.\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "32fd4170e56e17b0a377d5cd72138d8d557c5461", "size": 7405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/notes.tex", "max_stars_repo_name": "marianajo/ml-stanford", "max_stars_repo_head_hexsha": "5f8caeb0c1357c1d7be4e0b64ae9270ef8ead9df", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/notes.tex", "max_issues_repo_name": "marianajo/ml-stanford", "max_issues_repo_head_hexsha": "5f8caeb0c1357c1d7be4e0b64ae9270ef8ead9df", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/notes.tex", "max_forks_repo_name": "marianajo/ml-stanford", "max_forks_repo_head_hexsha": "5f8caeb0c1357c1d7be4e0b64ae9270ef8ead9df", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2445652174, "max_line_length": 417, "alphanum_fraction": 0.7123565159, "num_tokens": 2204, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4304828606688831}}
{"text": "\\chapter{\\texttt{Mesh} class}\n\n\\section{Motivation}\nTo understand, the design behind the Mesh class, we would like to begin by discussing one of the key problems currently faced in \\texttt{dgswem}. The issue comes from Steven Brus' dissertation \\cite{brusDiss}. Brus goes on to show that the addition of curvilinear elements plays a significant role in obtaining high-order accuracy for real world problems. Simultaneously, these curvilinear elements incur a significantly higher computational cost. Thus in the interior of the finite element domain, where the solution doesn't exhibit mesh geometry to more computationally effient standard affine elements suffice. While computationally straight forward, this approach provides a software engineering challenge. Namely, something like the volume kernel now needs to be split up into two loops, i.e.\n\\begin{lstlisting}[language=c++, caption={Na\\\"ive implementation of curved and linear finite element kernel}, label=lst:badloops]\nfor ( auto& elt : linear_elements ) {\n  //Evaluate volume kernel for each linear element\n}\n\nfor ( auto& elt : curved_elements ) {\n  //Evaluate volume kernel for each curved element\n}\n\\end{lstlisting}\nThis can quickly provide a software engineering headache. For instance, the addition of quadrilateral elements, would suddenly require that each time step cover 4 loops. The addition of more features will lead to more code bloat ultimately resulting in maintainable code. The main goal of the Mesh class is to address specifically the problem, mentioned above.\n\n\\section{The Element Class}\nThe object-oriented solution approach is based on the fact that the discontinuous Galerkin algorithm ultimately, simply applies integrals over the elements, remaining mathematically agnostic to the actually implementation of the approximation. This lends itself to a polymorphic implementation. The idea behind polymorphism being that functionally all elements should behave identically. Thus, if we can agree to an interface that we would like to expose. We should be able to accomplish everything in one loop over the elements without having to worry about what's happening under the hood.\n\nRegardless of the type of element, we assume that for any given element, the approximated solution $u^h$ is given in the form\n\\begin{equation*}\nu^h(x,t) = \\sum_{i=0}^{N} u_n(t) \\phi_n(x),\n\\end{equation*}\nwhere $\\phi_n$ is some basis. The approximated solution is determined by the evolution of the functions $u_n(t)$. For the Galerkin Method, this evolution is ultimately determined by ensuring that the residuals of the approximate solution is orthogonal to the space spanned by $\\{\\phi_n\\}$. Thus the key functionality that every element must possess is that ability to compute integrals of the form \n\\begin{equation*}\n\\int_{\\Omega} f \\phi_n \\d x\n\\end{equation*}\nfor an arbitrary function $f$. In practice these integrations are approximated by quadrature rules. However, this provides the basis for the interface, we would like to expose from a generic element class.\n\\begin{lstlisting}[language=c++, caption={Generic Element API}]\nclass Element {\n\n  //Compute the value of F at the Gauss-points\n  template <typename F>\n  void ComputeFgp(const F& f, std::vector<double>& f_gp);\n\n  //Compute the value of  a function u given by\n  // basis coefficients u at the Gauss-Points\t    \n  void ComputeUgp(const std::vector<double>& u,\n                  std::vector<double>& u_gp);\n\n  //Compute the gradient of a function given by\n  // basis coefficients u at the Gauss Points    \n  void ComputeDUgp(const uint dir,\n                   const std::vector<double>& u,\n                   std::vector<double>& du_gp);\n\t\n  //Compute the integral of u\n  double Integration(const std::vector<double>& u_gp);\n\t\n  //Test u against basis function dof\n  double IntegrationPhi(const uint dof,\n                        const std::vector<double>& u_gp);\n    \n  //Test u against the derivative in direction dir\n  // of basis function dof\n  double IntegrationDPhi(const uint dir,\n                         const uint dof,\n                         const std::vector<double>& u_gp);\n\n  //...\n};\n\\end{lstlisting}\nThat is to say if every element satisfied this API, we would be able to write the discontinuous Galerkin kernel with only one loop regardless of the element.\n\n\\subsection{Strong Typing}\nC++ is a strongly typed language. Thus, in exposing any kind of polymorphism there are two options. (1) Dynamic polymorphism and (2) Static polymorphism. Dynamic polymorphism is typically achieved through the use of the  \\lstinline[language=c++]{virtual} keyword. This approach is typically considered the most readable, and typically be preferred in a first attempt at an implementation. However, virtual objects typically can't be resolved by the compiler at runtime. This means that when the executable is running, the compiler maintains a virtual look-up table, which it uses to determine which implementation to call, when provided one of these virtual calls. The cost of this is that there is a virtual overhead associated with each of these calls. Additionally, the compiler may have trouble inlining and optimizing virtual function calls. Typically, when the function execution is large enough this overhead may be treated as negligible. But for our applications, these function calls are expensive enough that virtualization would seriously degrade performance. \n\nThe other typical approach is the use of static polymorphism. The idea being that we still maintain a unified API exposed by the class. However, now we specify the order in which we loop through the elements. That way the compiler is able to determine each of the function calls. Although ultimately, we will be able to get away with still only having one loop. The binary code generated should be equivalent to the code in Listing \\ref{lst:badloops}. Thus, static polymorphism provides us with the usage of dynamic polymorphism without the additional overhead. The downsides include a code base that is more difficult to maintain. However, given the performance critical nature of these function calls, this is a downside we've decided to accept.\n\n\\subsection{Class Hierachy of Element}\n\\begin{figure}\n\\centering\n\\begin{tikzpicture}[edge from parent/.style={draw,<-,>=latex}, sibling distance=10em,\n  every node/.style = {shape=rectangle, rounded corners,\n    draw, align=center,\n    top color=white, bottom color=blue!20}]]\n  \\node {Element}\n    child { node {Shape} }\n    child { node {Master}\n      child { node {Integration} }\n      child { node {Basis} } };\n\\end{tikzpicture}\n\\caption{Composition of the Element classes.}\n\\label{fig:eltcomp}\n\\end{figure}\nThe last subsection describes the exact decomposition of the element. In designing \\texttt{dgswem-v2}, we attempted to think of all possible features that one might want to implement and provide encapsulation to allow for adding of new features without having to be familiar with the entire code base. Figure \\ref{fig:eltcomp} describes the major constituents of the element class.\n\\begin{itemize}\n\\item \\textbf{Shape}: The shape class deals with deformations from the master element to the actual orientation within the mesh. Here features such as curvature of the mesh (e.g. solving in spherical coordinates) or the element (e.g. isoparametric or isogeometric) should be implemented.\n\\item \\textbf{Master}: The master element is rather similar to the generic element class. It exposes integration hooks over the master element.\n\\item \\textbf{Basis}: This class encapsulates all basis information. Potentially additional choices of basis include Bernstein, modal, and bases on quadrilateral elements.\n\\item \\textbf{Quadrature}: This class contains all information required to approximate an integral over the master element. \n\\end{itemize}\nIn addition to adding features by providing new instances of these classes. There also still remains the ability to add classes through template specialization and SFINAE. These techniques allow for special implementations to be written in certain element compositions. For example, one of the large advantages of a Bernstein basis is the fast matrix inversion formula. Since this formula drastically deviates from linear elements, one might want to write a specific implementation for linear triangles using the Bernstein basis. \n\\section{\\texttt{Mesh} Class}\nWith the decision to strongly type the elements in the Mesh class, the next task is to develop a container, which represents the mesh. This requires the ability to iterate over interfaces, boundaries, elements, and distributed boundaries. The key object in allowing this to are the heterogeneous containers in the \\textbf{Utilities} namespace. To explain, what in particular is happening in these containers assume we have three types of elements in our mesh: \\lstinline{EltA, EltB, EltC}.\nMorally, the heterogeneous vector can be written out as:\n\\begin{lstlisting}[language=c++]\nusing HeterogeneousVector<EltA,EltB,EltC> = tuple<vector<EltA>,\n                                                  vector<EltB>,\n                                                  vector<EltC>>;\n\\end{lstlisting}\nNow assuming, we have a function we would like to execute on each element regardless of type. We emulate the \\lstinline[language=c++]{std::for_each} API. So we will define a hook in the Mesh class, which will execute that function for every element in the HeterogeneousVector. We have demonstrated what specifically we would like in Listing \\ref{lst:foreach}.\n\\begin{lstlisting}[language=c++,\n                   caption={Moral implementation of iterating over HeterogeneousVector},\n                   label=lst:foreach]\ntemplate<typename Element>\nvoid SomeKernel(Element& e);                   \n                   \ntemplate<typename F>\nvoid ForEachImpl( HeterogeneousVector<EltA,EltB,EltC>& v,\n                   const F& f ) {\n\n  vector<EltA>& vA = get<0>(v);\n  for_each(vA.begin(),vA.end(), f);\n  \n  vector<EltB>& vB = get<1>(v);\n  for_each(vB.begin(), vB.end(), f);\n  \n  vector<EltC>& vC = get<2>(v);\n  for_each(vC.begin(), vC.end(), f);\n}\n\n//Apply SomeKernel to every element in v\nMoralForImpl(v, SomeKernel);\n\\end{lstlisting}\nIn \\texttt{dgswem-v2}, this type of implementation can be generalized to arbitrary Hetereogeneous vectors through the use of template metaprogramming. However, ultimately, the code is effectively executing the above code. Allowing the compiler to generate these loops is precisely the issue we wanted to address. The definition of the kernels to be passed into the mesh class are problem specific and will be addressed in the next chapter. This mechanism is used for boundaries, internal interfaces, and distributed interfaces, in addition to elements. In understanding, this key concept the Mesh class becomes nothing more than a container. Detailed API descriptions are provided in the doxygen documentation.", "meta": {"hexsha": "5a1e130fc01c86c368414c819f7f8c64e183c9a0", "size": 10900, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/users-guide/chapters/mesh-class.tex", "max_stars_repo_name": "elenabac/dgswemv2", "max_stars_repo_head_hexsha": "ecc776811de304cbae7bfa696b3d22c513e7d4de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-05-30T08:43:10.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-14T18:33:10.000Z", "max_issues_repo_path": "documentation/users-guide/chapters/mesh-class.tex", "max_issues_repo_name": "elenabac/dgswemv2", "max_issues_repo_head_hexsha": "ecc776811de304cbae7bfa696b3d22c513e7d4de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 57, "max_issues_repo_issues_event_min_datetime": "2018-05-08T21:44:14.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-07T17:13:30.000Z", "max_forks_repo_path": "documentation/users-guide/chapters/mesh-class.tex", "max_forks_repo_name": "elenabac/dgswemv2", "max_forks_repo_head_hexsha": "ecc776811de304cbae7bfa696b3d22c513e7d4de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-05-07T21:50:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-30T14:02:02.000Z", "avg_line_length": 87.2, "max_line_length": 1071, "alphanum_fraction": 0.7633027523, "num_tokens": 2355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4304828513555367}}
{"text": "\\title{Computer Architecture - CS 301} % You may change the title if you want.\r\n\r\n\\author{Rishit Saiya - 180010027, Assignment - 12}\r\n\r\n\\date{\\today}\r\n\r\n\\documentclass[12pt]{article}\r\n\\usepackage{fullpage}\r\n\\usepackage{enumitem}\r\n\\usepackage{amsmath,mathtools}\r\n\\usepackage{amssymb}\r\n\\usepackage[super]{nth}\r\n\\usepackage{textcomp}\r\n\\usepackage{hyperref}\r\n\\hypersetup{\r\n    colorlinks=true,\r\n    linkcolor=blue,\r\n    filecolor=magenta,      \r\n    urlcolor=cyan,\r\n}\r\n\\begin{document}\r\n\\maketitle\r\n\r\n%----------------------------------------------------------------\r\n\r\n\\section{}\r\nThis is a direct application to find the CPI as mentioned in the video lecture. Figure 1 shows the formula we will be using which is given in lecture.\r\n\r\n\\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width = 13cm, height = 2cm]{Assignment-12/Formula1.png}\r\n    \\caption{CPI Calculation}\r\n    % \\label{fig:my_label}\r\n\\end{figure}\r\nIn here, 1 is the $L1_{Hit \\, Time}$. So, formula might change accordingly. \\\\\r\nTo get an overview, we will try to list down all the given values to us. They are as follows: \\\\\r\nBaseline IPC = 0.8 \\\\\r\nFraction of Memory Operations = 30 \\% \\\\\r\nL1 Cache Hit Rate = 100 \\% \\\\\r\nL1 Cache Hit Time = 1 Cycle \\\\\r\nL1 Data Cache Miss Rate = 5 \\% \\\\\r\nL2 Cache Miss Rate = 50 \\% \\\\\r\nL2 Cache Hit Time = 10 cycles \\\\\r\nL2 Miss Penalty = 100 cycles \\\\\r\n\r\n\\begin{equation*}\r\n    CPI_{ideal} = \\frac{1}{IPC_{baseline}}\r\n\\end{equation*}\r\n\\begin{equation*}\r\n    CPI_{ideal} = \\frac{1}{0.8} = 10/8 = 1.25\r\n\\end{equation*}\r\nWe are given the $f_{mem}$ as follows: \\\\\r\n\\begin{equation*}\r\n    f_{mem} = 30 \\% = 0.3\r\n\\end{equation*}\r\nSo, we calculate the AMAT variable value. We are given in the lecture that AMAT value is as given in Figure 2. With that reference, we will calculate AMAT here.\r\n\\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width = 15cm, height = 2cm]{Assignment-12/Formula2.png}\r\n    \\caption{AMAT Calculation}\r\n\\end{figure}\r\n\\begin{equation*}\r\n    AMAT = L1_{Hit \\, Time} + L1_{Miss \\, Rate} \\times (L2_{Hit \\, Time} + (L2_{Miss \\, Rate} \\times L2_{Miss \\, Penalty}))\r\n\\end{equation*}\r\n\\begin{equation*}\r\n    AMAT = 1 + 0.05 \\times (10 + (0.5 \\times 100)) = 4\r\n\\end{equation*}\r\nSo, finally we calculate CPI.\r\n\\begin{equation*}\r\n    CPI = 1.25 + 0.3 \\times (4 - 1) = 2.15\r\n\\end{equation*}\r\nSo, final IPC will be as follows: \r\n\\begin{equation*}\r\n    IPC = \\frac{1}{CPI}\r\n\\end{equation*}\r\n\\begin{equation*}\r\n    IPC = \\frac{1}{2.15} = 0.4651162790\r\n\\end{equation*}\r\n%----------------------------------------------------------------\r\n\r\n\\section{}\r\n\r\nBefore we attempt to understand the motivation of Prefetching, we need to understand the aspect and environment where it will prove to be effective. As mentioned in the lecture, we have following types of misses: \r\n\\begin{itemize}\r\n    \\item \\textbf{Compulsory Miss:}\r\n    These misses occur when a data stream is read first time. Since it is read first time, it compulsory has to miss and hence the name. The following are some of the suggested mitigation techniques to decrease number of Compulsory Misses:\r\n    \\begin{enumerate}\r\n        \\item As mentioned in the lecture, we can increase the Block Size, in order to store more data blocks at single read and further more this will lead to usage of spatial locality. With this the number of Compulsory Misses will reduce.\r\n        \\item Another proposed mitigation is prefetching the memory locations that are to be used in the near future. This is done by generating an algorithm which can wisely and effectively guess upcoming cache locations based on usage history.\r\n    \\end{enumerate}\r\n    \\item \\textbf{Conflict Miss:} \r\n    These misses occur when there is limited amount of associativity in a direct mapped cache or set associative cache. The following are some of the suggested mitigation techniques to decrease number of Conflict  Misses: \r\n    \\begin{enumerate}\r\n        \\item A simple way to mitigate is to write algorithms/codes which have cache involvement. Basically, trying to put together code which is cache independent to maximum possible extent.\r\n        \\item Another way is to use a smaller fully associative cache which is meant to store the line which is thrown out of main cache so as to use immediately next time instead of fetching. This is generally called as Victim Cache.\r\n        \\item We can also increase the associativity of the cache. As mentioned in lecture, this comes with a trade off cost of high consumption of power and latency also increases resulting in slower computation time.\r\n    \\end{enumerate}\r\n    \\item \\textbf{Capacity Miss:}\r\n    These misses occur due to limited size of Cache blocks. The following are some of the suggested mitigation techniques to decrease number of Capacity  Misses: \r\n    \\begin{enumerate}\r\n        \\item A simple fix would be straight away increase the size of Cache blocks.\r\n        \\item Another mitigation technique would be produce a novel and wise technique for prefetching in order to accommodate more such misses.\r\n    \\end{enumerate}\r\n\\end{itemize}\r\n\r\nAs clearly mentioned above, we see that two of the misses' mitigation involves Prefetching and making a novel and wise algorithm to predict the memory locations that will be used in the near future would help us to mitigate Compulsory and Capacity Misses. This would increase the overall efficiency output of the Cache and lead to increase in more hits than before. This constitutes the motivation to integrate \\textbf{\\textit{Prefetching}} in modern caches. \\\\\r\n\r\nIn the following sections, we will explain different types of Prefetching and its processes.\r\n\\begin{itemize}\r\n    \\item \\textbf{Hardware Prefetching:} A hardware prefetcher is a dedicated hardware unit that predicts the memory accesses in the near future, and fetches them from the lower levels of the memory system. \\\\\r\n    \r\n    In the Figure 3, we can see the basic look of Hardware Prefetcher as mentioned in the video.\r\n    \\begin{figure}\r\n        \\centering\r\n        \\includegraphics[width=10cm , height=8cm]{Assignment-12/Hardware_Prefetch.png}\r\n        \\caption{Hardware Prefetcher}\r\n    \\end{figure}\r\nIn here, the prefetcher checks the hits/misses at the L1 cache. Based on results from L1 cache, now it decides whether the lists of addresses are likely to be accessed in the near future or not. It then sends the data to L2 cache to get in those lines to L1 cache in a such a way that when there is a call for those data, there is a hit in L1 cache and it can easily fetch there onwards.\r\n    \\item \\textbf{Software Prefetching:} A software prefetcher uses the compiler and predicts future cache misses and inserts a prefetch instruction based on the miss penalty and execution time of the instructions. \\\\\r\nBelow we will consider 2 different code snippets taken from the lecture to explain software Prefetching. Let us consider following Code\\_Snippet-1:\r\n\\begin{verbatim}\r\nint addAll(int data[], int vals[]) {\r\n      int i, sum = 0;\r\n      for (i = 0; i < N; i++) {\r\n         sum += data[vals[i]];\r\n      }\r\n      return sum;\r\n}\r\n\\end{verbatim}\r\nLet us consider following Code\\_Snippet-2:\r\n\\begin{verbatim}\r\nint addAllP(int data[], int vals[]) {\r\n      int i, sum = 0;\r\n      for (i = 0; i < N; i++) {\r\n         __builtin_prefetch(& data[vals[i + 100]]);\r\n         sum += data[vals[i]];\r\n      }\r\n    return sum;\r\n}\r\n\\end{verbatim}\r\nSince \\textit{vals} array can have discrete values and can be stored in the sequence, \\textit{vals} array possess spatial locality whereas \\textit{data} array doesn't has any spatial locality. In such case, we integrate the above function in Code\\_Snippet-1 with \\textit{\\_\\_builtin\\_prefetch} function which helps us to prefetch the address of data which are to be accessed after such 100 iterations. This helps us to increase the Memory Fetch efficiency of cache and also to reduce the MA time.\r\n\\end{itemize}\r\n\r\nAs much as Prefetching techniques are helping us to mitigate compulsory and capacity misses, there also exists some disadvantages of using it. Some of which are as follows: \r\n\\begin{itemize}\r\n    \\item Addition of Extra Complexity to the Code Execution\r\n    \\item Addition of Risk of displacing useful/frequently used data from the caches.\r\n\\end{itemize}\r\nSource used: Reference Book, Video Lecture,  \\href{https://en.wikipedia.org/wiki/Cache_prefetching}{Wiki Page}\r\n%----------------------------------------------------------------\r\n\\end{document}", "meta": {"hexsha": "c7a49195863fd8a949e839043ea5b1257bbd9327", "size": 8428, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment-12/180010027_RishitSaiya.tex", "max_stars_repo_name": "rishitsaiya/Computer-Architecture-Theory", "max_stars_repo_head_hexsha": "1e73e590e88664dcc4ca652a599cdc2cde07a41a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-25T17:20:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-25T17:20:42.000Z", "max_issues_repo_path": "Assignment-12/180010027_RishitSaiya.tex", "max_issues_repo_name": "rishitsaiya/Computer-Architecture-Theory", "max_issues_repo_head_hexsha": "1e73e590e88664dcc4ca652a599cdc2cde07a41a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment-12/180010027_RishitSaiya.tex", "max_forks_repo_name": "rishitsaiya/Computer-Architecture-Theory", "max_forks_repo_head_hexsha": "1e73e590e88664dcc4ca652a599cdc2cde07a41a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.8145695364, "max_line_length": 497, "alphanum_fraction": 0.7047935453, "num_tokens": 2106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.43047157846673695}}
{"text": "\\documentclass[a4paper,10pt]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{theorem}\n\\usepackage{listings}\n\\usepackage{url}\n\\usepackage{pdfsync}\n\n%%% Settings for listings\n\\lstset{basicstyle=\\ttfamily\\small,xleftmargin=\\parindent,language=Haskell}\n\n\\newcommand{\\cc}[1]{\\lstinline{#1}}\n\n%%% Theorems\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\n{\\theorembodyfont{\\rmfamily}\n  \\newtheorem{exercise}[theorem]{Exercise}\n  \\newtheorem{definition}[theorem]{Definition}\n}\n\n\\newenvironment{proof}{\\par\\noindent\\textit{Proof.}}{\\hfill$\\Box$\\par\\medskip}\n\n%%% Macros\n\n\\newcommand{\\RR}{\\mathbb{R}}\n\n\\newcommand{\\set}[1]{\\{#1\\}}\n\\newcommand{\\such}{\\mid}\n\\newcommand{\\tpl}[1]{\\mathcal{O}(#1)}\n\\newcommand{\\cont}[1]{\\mathcal{C}(#1)}\n\\newcommand{\\scr}[1]{\\mathcal{#1}}\n\\newcommand{\\two}{\\mathsf{2}}\n\\newcommand{\\Bool}{\\mathtt{Bool}}\n\n\\newcommand{\\R}[1]{\\mathtt{#1}}\n\\newcommand{\\rz}{\\Vdash}\n\n\\newcommand{\\bind}{\\mathbin{\\text{\\texttt{\\char62\\char62\\char61}}}}\n\n%%% Quantifiers\n\n%%% quantifiers\n\\newcommand{\\all}[3]{\\forall\\, #1 \\,{\\in}\\, #2\\,.\\left(#3\\right)}\n\\newcommand{\\some}[3]{\\exists\\, #1 \\,{\\in}\\, #2\\,.\\left(#3\\right)}\n\\newcommand{\\exactlyone}[3]{\\exists!\\, #1 \\,{\\in}\\, #2\\,.\\left(#3\\right)}\n\\newcommand{\\lam}[3]{\\lambda #1 \\,{\\in}\\, #2\\,.\\left(#3\\right)}\n\\newcommand{\\uall}[2]{\\forall\\, #1\\,.\\left(#2\\right)}\n\\newcommand{\\usome}[2]{\\exists\\, #1\\,.\\left(#2\\right)}\n\\newcommand{\\uexactlyone}[3]{\\exists!\\, #1\\,.\\left(#2\\right)}\n\\newcommand{\\ulam}[2]{\\lambda #1 .\\left(#2\\right)}\n\\newcommand{\\xall}[3]{\\forall\\, #1 \\,{\\in}\\, #2\\,.\\,#3}\n\\newcommand{\\xsome}[3]{\\exists\\, #1 \\,{\\in}\\, #2\\,.\\,#3}\n\\newcommand{\\xexactlyone}[3]{\\exists!\\, #1 \\,{\\in}\\, #2\\,.\\,#3}\n\\newcommand{\\xuall}[2]{\\forall\\, #1\\,.\\,#2}\n\\newcommand{\\xusome}[2]{\\exists\\, #1\\,.\\,#2}\n\\newcommand{\\xuexactlyone}[2]{\\exists!\\, #1,.\\,#2}\n\\newcommand{\\xlam}[3]{\\lambda #1 \\,{\\in}\\, #2\\,.\\,#3}\n\\newcommand{\\xulam}[2]{\\lambda #1 .\\,#2}\n\\newcommand{\\tlam}[3]{\\lambda #1 \\,{:}\\, #2\\,.\\,\\left(#3\\right)}\n\\newcommand{\\xtlam}[3]{\\lambda #1 \\,{:}\\, #2\\,.\\,#3}\n\n\n\\begin{document}\n\n\\title{Computation over compact and overt spaces}\n\\author{Andrej Bauer}\n\n\\maketitle\n\n\\begin{abstract}\n    These are lecture notes for the graduate course ``Topology in computer\n    science'' which I gave with Neža Mramor-Kosta in the Fall of~2009 at the\n    Faculty of computer science, University of Ljubljana.\n\\end{abstract}\n\n\\section{Introduction}\n\\label{sec:introduction}\n\nWhen students first see the definition of compact spaces it usually looks very\nmysterious to them. Where does the Heine-Borel property come from? Why would\nanyone consider finite subcovers of arbitrary open covers? In these notes we\nreview the basic definitions and try to motivate them from the point of view\nof computation.\n\nWe assume basic familiarity with topology and a certain degree of programming\nskill. The code examples are written in Haskell, but could be translated to\nany other programming language that supports higher-order functions.\n\nThese notes do not contain any original material. All is ``standard''\nknowledge in topology and computation, although some parts are not well known.\nA good starting point for background reading are Martín Escardó's\nnotes~\\cite{escardo04:_synth}.\n\n\\section{Open sets as semidecidable properties}\n\\label{sec:opens-semidecidable}\n\nAn open subset of a topological space may be thought of as a property that can\nbe verified in finite time. To illustrate this, suppose we a real number $a$\nis given to us in a physically realistic way. That is, $a$ is not given with\ninfinite precision all at once, but rather as a sequence of rational\napproximations with error bounds. The approximations and the error bounds\nmight come from a sequence of ever more precise (and ever more expensive)\nmeasurements, or from a computer program that computes~$a$ to any desired\nprecision.\n\nWe may want to know whether $a$ has a given property, or equivalently\nwhether it is an element of a given set $S \\subseteq \\RR$. We\ndistinguish between\n% \n\\begin{itemize}\n\\item \\emph{deciding} whether $a \\in S$: we do not know whether $a \\in\n  S$ or $a \\not\\in S$ and would like to know which is the case.\n\\item \\emph{verifying} that $a \\in S$: we seek evidence that $a \\in S$\n  (and if $a \\not\\in S$ then we do not care what happens, and in\n  particular we do not have to provide evidence that $a \\not\\in S$).\n\\end{itemize}\n% \nDeciding whether $a \\in S$ provides one bit of information: we find out either\n$a \\in S$ or $a \\not\\in S$. Verifying that $a \\in S$ provides \\emph{less} than\nthat: if $a \\in S$ we eventually get the evidence, but if $a \\not\\in S$ we\njust wait forever hoping that perhaps the evidence of $a \\in S$ will appear.\n\nCan we decide whether $a > 0$? No, not for all $a$. The problematic case is $a\n= 0$ because we will never be able to tell that $a > 0$ does not hold just by\nlooking at an approximation $a'$ with a positive error bound $\\epsilon > 0$.\n\nCan we verify that $a > 0$? Yes. If it is the case that $a > 0$ then\neventually we will see an approximation $a'$ with a good enough error bound\n$\\epsilon > 0$ such that $0 < a' - \\epsilon < a$. If $a < 0$ then we do not\ncare what happens. (If you are thinking that we can decide whether $a > 0$ in\nall cases but $a = 0$ then you are right. Of course, we are now talking about\na different topological space $\\RR \\setminus \\set{0}$.)\n\nA moment's thought shows that we can verify $a \\in S$ when $S$ has the\nfollowing property: if $b \\in S$ then also all points close enough to~$b$ are\nin $S$. But that's precisely the definition of open sets. So we adopt the\nslogan\n% \n\\begin{quote}\n  \\emph{``Verifiable properties correspond to open sets.''}\n\\end{quote}\n% \nThe word ``verifiable'' should be understood either as ``evidence can be\ncomputed in finite time'' or ``an experiment confirming it can be performed''.\n\nNow suppose $f : X \\to Y$ is a map between topological spaces and $U \\subseteq\nY$ is open (verifiable). Imagine we can implement $f$ on a computer or as a\nphysical process. For every $x \\in X$, $x \\in f^{-1}(U)$ is equivalent to\n$f(x) \\in U$. This means that $x \\in f^{-1}(U)$ is verifiable: just verify\n$f(x) \\in U$ instead. In other words, the inverse image $f^{-1}(U)$ is open if\n$U$ is open, which is the definition of continuity of~$f$. This is summarized\nby our second slogan\n% \n\\begin{quote}\n  \\emph{``Computable functions are continuous.''}\n\\end{quote}\n\n\\begin{exercise}\n  Show that verifiable properties are closed under finite intersections. Are\n  they closed under infinite unions?\n\\end{exercise}\n\n\\section{Compactness}\n\\label{sec:compactness}\n\nThe standard definition of compactness is as follows.\n\n\\begin{definition}\n  A topological space~$X$ is \\emph{compact} when every open cover of~$X$ has a\n  finite subcover.\n\\end{definition}\n\nOur aim is to give the concept of compactness a computational interpretation,\njust like we did for open sets and continuous maps above. We first rephrase\nthis definition in terms of directed open covers. A family $\\mathcal{S} =\n\\set{S_i \\such i \\in I}$ of sets is \\emph{directed} when $I$ is non-empty and\nfor all $i, j \\in I$ there is $k \\in I$ such that $S_i \\subseteq S_k$ and $S_j\n\\subseteq S_k$.\n\n\\begin{exercise}\n  Suppose $\\mathcal{S} = \\set{S_i \\such i \\in I}$ is a directed family of\n  sets. Show that for any finite number of members $S_{i_1}, \\ldots, S_{i_n}\n  \\in \\mathcal{S}$, there is some $S_j \\in \\mathcal{S}$ which contains them\n  all.\n\\end{exercise}\n\n\\begin{exercise} Suppose $\\mathcal{S} = \\set{S_i \\such i \\in I}$ is an\n  arbitrary family of sets. Show that the family formed by taking all finite\n  unions of the $S_i$'s, including the empty one,\n  % \n  \\begin{equation*}\n    \\mathcal{T} =\n    \\set{U_{i_1} \\cup \\cdots \\cup U_{i_n} \\such n \\geq 0 \\land i_1, \\ldots, i_n \\in I}\n  \\end{equation*}\n  % \n  is directed and that $\\bigcup \\mathcal{S} = \\bigcup \\mathcal{T}$.\n\\end{exercise}\n\n\n\\begin{proposition}\n  \\label{proposition:compact-directed-cover} A topological space~$X$ is\n  \\emph{compact} if, and only if, every directed open cover of~$X$ contains\n  $X$ as a member.\n\\end{proposition}\n\n\\begin{proof} Suppose $X$ is compact and let $\\set{U_i \\such i \\in I}$ is a\n  directed open cover. There exist $i_1, \\ldots, i_n \\in I$ such that\n  $\\set{U_{i_1}, \\ldots, U_{i_n}}$ already cover~$X$. By directedness there\n  exists $j \\in I$ such that $U_j$ contains $U_{i_1}, \\ldots, U_{i_n}$, but\n  then $U_j = X$.\n\n  Conversely, suppose every directed open cover of~$X$ contains $X$ as a\n  member, and let $\\set{U_i \\such i \\in U}$ be any open cover of~$X$. We form\n  a new cover which consists of all finite unions of $U_i$'s, including the\n  empty union:\n  % \n  \\begin{equation*}\n    \\set{U_{i_1} \\cup \\cdots \\cup U_{i_n} \\such n \\geq 0 \\land i_1, \\ldots, i_n \\in I}.\n  \\end{equation*}\n  % \n  This is a directed open cover of~$X$, hence it has a member $U_{i_1} \\cup\n  \\cdots \\cup U_{i_n}$ which is equal to~$X$. Thus the original open cover has\n  the finite subcover $\\set{U_{i_1}, \\ldots, U_{i_n}}$.\n\\end{proof}\n\nLet $X$ be a topological space and $\\tpl{X} = \\set{U \\subseteq X \\such\n  \\text{$U$ is open}}$ its topology. The set $\\tpl{X}$ can be considered as a\ntopological space, too! Say that $\\scr{U} \\subseteq \\tpl{X}$ is \\emph{Scott\n  open} when\n% \n\\begin{enumerate}\n\\item it is an \\emph{upper set:} if $U \\in \\scr{U}$ and $U \\subseteq V \\in\n  \\tpl{X}$ then $V \\in \\scr{U}$,\n\\item it is \\emph{inaccessible by directed families}: if $\\set{U_i \\such i \\in\n    I}$ is a directed family of open sets in~$X$ and $\\bigcup_{i \\in I} U_i\n  \\in \\scr{U}$ then there is $i \\in I$ such that $U_i \\in \\scr{U}$.\n\\end{enumerate}\n\n\\begin{exercise}\n  Verify that the family of all Scott open sets forms a topology on $\\tpl{X}$.\n\\end{exercise}\n\nWe call the family of all Scott open subsets of~$\\tpl{X}$ the \\emph{Scott\n  topology}. Henceforth, whenever $\\tpl{X}$ is viewed as a topological space\nwe mean the Scott topology.\n\n\\begin{proposition}\n  \\label{proposition:compact-top-open}\n  A topological space~$X$ is compact if, and only if, $\\set{X}$ is a Scott\n  open subset of $\\tpl{X}$.\n\\end{proposition}\n\n\\begin{proof}\n  This is just Proposition~\\ref{proposition:compact-directed-cover} rephrased\n  in terms of Scott open sets.\n\\end{proof}\n\n\\begin{exercise}\n  Write down enough details of the proof of\n  Proposition~\\ref{proposition:compact-top-open} to convince yourself that it\n  holds.\n\\end{exercise}\n\nThe last proposition allows us to rephrase compactness in terms of verifiable\nproperties: a space is compact when ``holds for all $x \\in X$'' is a\nverifiable property of verifiable properties. Admittedly, is a bit confusing,\nso we seek another characterization.\n\nA third way to characterize compact spaces involves the \\emph{Sierpinski\n  space} $\\Sigma = \\set{\\bot, \\top}$ which has two points and the open sets\n$\\emptyset$, $\\set{\\top}$ and $\\set{\\bot, \\top}$.\n\n\\begin{exercise}\n  Find all the ways to equip the set $\\set{\\bot, \\top}$ with a topology. How\n  many non-homeomorphic ones are there?\n\\end{exercise}\n\n\\begin{exercise}\n  Show that $\\Sigma$ is homeomorphic to the topological space\n  $\\tpl{\\set{\\star}}$, where $\\set{\\star}$ is a singleton space.\n\\end{exercise}\n\n\\begin{exercise}\n  How many maps $\\Sigma \\to \\Sigma$ are there? How many are continuous?\n\\end{exercise}\n\n\\begin{proposition}\n  \\label{proposition:map-sigma-continuous}\n  A map $f : X \\to \\Sigma$ is continuous if, and only if, $f^{-1}(\\set{\\top})$\n  is open in~$X$.\n\\end{proposition}\n\n\\begin{proof}\n  $\\Sigma$ only has three open sets. The inverse images $f^{-1}(\\emptyset) =\n  \\emptyset$ and $f^{-1}(\\Sigma) = X$ of two of them are always open, which\n  leaves us with checking just the third one, $f^{-1}(\\set{\\top})$.\n\\end{proof}\n\nThe previous proposition tells us that there is a bijection between $\\tpl{X}$\nand continuous maps $X \\to \\Sigma$. In one direction the bijection maps an\nopen subset $U \\subseteq X$ to its \\emph{characteristic map} $\\chi_U : X \\to\n\\Sigma$, defined by\n% \n\\begin{equation*} \\chi_U(x) =\n  \\begin{cases} \\top & \\text{if $x \\in U$,}\\\\ \\bot & \\text{otherwise.}\n  \\end{cases}\n\\end{equation*}\n% \nIn the other direction a continuous map $f : X \\to \\Sigma$ corresponds to the\nopen subset $f^{-1}(\\set{\\top})$.\n\n\\begin{proposition}\n  \\label{proposition:compact-iff-forall-continuous}\n  A topological space $X$ is compact if, and only if, the map $\\forall_X :\n  \\tpl{X} \\to \\Sigma$, defined by\n  % \n  \\begin{equation*} \\forall_X(U) =\n    \\begin{cases} \\top & \\text{if $U = X$,}\\\\ \\bot & \\text{otherwise}\n    \\end{cases}\n  \\end{equation*}\n  % \n  is continuous.\n\\end{proposition}\n\n\\begin{proof} By Proposition~\\ref{proposition:map-sigma-continuous} continuity\nof~$\\forall_X$ is equivalent to $\\forall_X^{-1}(\\set{\\top}) = \\set{X}$ being\nopen, which in turn is equivalent to~$X$ being compact by\nProposition~\\ref{proposition:compact-top-open}.\n\\end{proof}\n\nIf we turn around the second slogan for a moment,\nProposition~\\ref{proposition:compact-iff-forall-continuous} suggests that we\nshould be able to compute the map $\\forall_X$ when $X$ is compact. To explain\nwhat that means precisely, we need to say a few words about how topological\nspaces are represented in a programming language.\n\n\\section{Representations of spaces}\n\\label{sec:representations}\n\nA topological space $X$ is an abstract set. In a programming language\nit is represented by a suitable datatype $\\mathtt{X}$ whose values\nrepresent points of $X$. The relationship between $X$ and $\\mathtt{X}$\nis expressed as a \\emph{realizability} relation $\\rz_X$ which relates\nvalues of type~$\\mathtt{X}$ to point of $X$. For $\\R{r} : \\mathtt{X}$\nand $a \\in X$ we read $\\R{r} \\rz_X a$ as ``the value $\\R{r}$ realizes,\nor represents, the point $a$''. We require that each point have at\nleast one realizer. The triple $(X, \\mathtt{X}, {\\rz_X})$ is called an\n\\emph{assembly}. Note that some values of type $\\mathtt{X}$ may\nrepresent nothing, and that a point of~$X$ may have many\nrepresentations.\n\nA map $f : X \\to Y$ is \\emph{realized} or represented by a value $\\R{f}$ of\ntype $\\mathtt{X} \\to \\mathtt{Y}$ which \\emph{tracks}~$f$:\n% \n\\begin{equation*}\n  \\text{if $\\R{a} \\rz_X a$ then $\\R{f}\\;\\R{a} \\rz_Y f(a)$.}\n\\end{equation*}\n%\nThis is just a formal definition of the informal idea of what it means\nto ``implement'' an abstract function between two sets.\n \nWe adopt the notational convention that datatypes and realizers are written in\ntypewriter font. For example, if $X$ is the underlying set of an assembly, $a\n\\in X$, and $f : X \\to Y$ a realized map, the corresponding datatype and\nrealizers are $\\mathtt{X}$, $\\R{a}$, and $\\R{f}$, respectively.\n\nIn these notes we want to focus on topology and programming, so we\nshall keep assemblies and realized maps in the background as much as\npossible. However, it is useful to know that there is a precise\nmathematical connection bewtween topology and programming.\\footnote{To\n  be honest we should point out that realizability is not the only one\n  way of relating topology with programming.}\n\n\n\\section{Searchable spaces}\n\\label{sec:searchable-spaces}\n\nTo sensibly talk about computability of the operator $\\forall_X : \\tpl{X} \\to\n\\Sigma$, we should represent $X$ by a datatype $\\mathtt{X}$ (and a\ncorresponding realizability relation $\\rz_X$), and similarly represent\n$\\Sigma$ by a suitably chosen datatype $\\mathtt{S}$. The topology $\\tpl{X}$ is\nrepresented by the type $\\mathtt{X} \\to \\mathtt{S}$ because $\\tpl{X}$ is in\nbijective correspondence with continuous maps $X \\to \\Sigma$. Hence,\n$\\forall_X$ is computable if there is a value\n% \n\\begin{equation*} \\R{forall} : (\\mathtt{X} \\to \\mathtt{S}) \\to \\mathtt{S},\n\\end{equation*}\n% \nwhich tracks it, i.e., for all $\\R{p}$ of type $\\mathtt{X} \\to \\mathtt{S}$ and\nall continuous maps $p : X \\to \\Sigma$,\n% \n\\begin{equation*} \\text{if $\\R{p} \\rz_{X \\to \\Sigma} p$ then\n$\\R{forall}\\;\\R{p} \\rz_\\Sigma \\forall_X(p)$.}\n\\end{equation*}\n% \nThere are several ways of representing $\\Sigma$ by a datatype $\\mathtt{S}$.\nBecause all of them are a bit unusual, we first focus on a related but simpler\ncase\n% \n\\begin{equation}\n  \\label{eq:forall-bool} \\mathtt{forall} : (\\mathtt{X} \\to \\Bool) \\to \\Bool.\n\\end{equation}\n% \nThe datatype $\\Bool$ does \\emph{not} represent~$\\Sigma$ but the discrete\ntopological space $\\two = \\set{0, 1}$. Values of type $\\mathtt{X} \\to \\Bool$\ntrack continuous maps $X \\to \\two$. Because a map $f : X \\to \\two$ is\ncontinuous if, and only if, $f^{-1}(\\set{1})$ is clopen (closed and open), the\ndecidable properties correspond to clopen subsets.\n\n\\begin{exercise} Show that a map $f : X \\to \\two$ is continuous if, and only\nif, $f^{-1}(\\set{1})$ clopen.\n\\end{exercise}\n\n\\begin{exercise} Which properties of $\\RR$ are decidable?\n\\end{exercise}\n% \nHow could we implement the universal quantifier $\\mathtt{forall}$? When $X$ is\nfinite, say $X = \\set{a_1, \\ldots, a_n}$ we can simply define\n% \n\\begin{equation*} \\forall_X(p) = p(a_1) \\land p(a_2) \\land \\cdots \\land\np(a_n),\n\\end{equation*}\n% \nwhich is easily implemented.\n% \nHowever, this would not work for infinite sets, where all the fun is. Instead,\nwe are going to use the notion of a \\emph{searchable} space.\n\n\\begin{definition} A space $X$ is \\emph{searchable} if there is a realized map\n$\\epsilon : (X \\to \\two) \\to \\two$ such that, for all $p : X \\to \\two$,\n  % \n  \\begin{equation*} p (\\epsilon(p)) \\iff \\xsome{x}{X}{p(x)}.\n  \\end{equation*}\n\\end{definition}\n\nThe operator $\\epsilon$ takes as input a decidable property $p$ and returns a\ncandidate $\\epsilon(p) \\in X$ such that $p(\\epsilon(p))$ holds. If there is no\n$x \\in X$ for which $p(x)$ holds, then $\\epsilon(p)$ may be any element of\n$X$. We emphasize that $\\epsilon(p)$ \\emph{must} return a candidate and is not\nallowed to diverge. The operator $\\epsilon$ is known as \\emph{Hilbert's\noperator}.\n\nFor a searchable space~$X$ the existential quantifer\n% \n\\begin{equation*} \\exists_X(p) = \\begin{cases} 1, &\\text{if\n$\\xsome{x}{X}{p(x)}$,}\\\\ 0, &\\text{ otherwise.}\n  \\end{cases}\n\\end{equation*}\n% \nis easily implemented as\n\\begin{equation*} \\exists_X(p) = p (\\epsilon(p)).\n\\end{equation*}\n% \nAs an added bonus, because $\\xall{x}{X}{p(x)}$ is equivalent to\n$\\lnot\\xsome{x}{X}{\\lnot p(x)}$, we also get the universal quantifier\n% \n\\begin{equation*} \\forall_X(p) = \\lnot \\exists_X(\\lnot p).\n\\end{equation*}\n% \nWe should give a name to datatypes which have the existential quantifier.\n\n\\section{Overt spaces}\n\\label{sec:overt-spaces}\n\nBy symmetry there should be a topological notion that is dual to compactness,\nas follows.\n\n\\begin{definition} A topological space $X$ is \\emph{overt}\\footnote{The term\n``overt space'' was coined by Paul Taylor.} if the map $\\exists_X : \\tpl{X}\n\\to \\Sigma$, defined by\n  % \n  \\begin{equation*} \\exists_X (U) =\n    \\begin{cases} \\bot & \\text{if $U = \\emptyset$,}\\\\ \\top & \\text{otherwise.}\n    \\end{cases}\n  \\end{equation*}\n  % \n  is continuous.\n\\end{definition}\n\nThe following proposition is rather disappointing.\n\n\\begin{proposition} Every topological space is overt.\n\\end{proposition}\n\n\\begin{proof} By Proposition~\\ref{proposition:map-sigma-continuous} we only\nneed to check that $\\exists_X^{-1}(\\set{\\top}) = \\tpl{X} \\setminus\n\\set{\\emptyset}$ is Scott open, which is easy. Clearly $\\tpl{X} \\setminus\n\\set{\\emptyset}$ is an upper set, and if $\\bigcup_{i \\in I} U_i$ is non-empty\nthen at least one member $U_i$ must be non-empty.\n\\end{proof}\n\nIt would be \\emph{wrong} to dismiss the notion of overtness just because it is\ntrivial in classical topology. As we shall see later, in computable topology\novertness is not only interesting but just as fundamental as compactness. We\nnow return to searchable spaces and their implementation.\n\n\\section{Implementation of searchable spaces}\n\\label{sec:implementation-searchable}\n\nThe code from this section is based on that of Martín Escardó's blog\npost~\\cite{escardo08:blog}. A searchable space is represented by a datatype\n$\\mathtt{X}$ and the $\\epsilon$ operator, which we shall call $\\R{epsilon}$ in\ncode. In Haskell we would define it like this:\n% \n\\begin{lstlisting}\ndata Searchable a = Finder ((a -> Bool) -> a)\n\\end{lstlisting}\n% \nThe first line defines a datatype $\\mathtt{Searchable}\\;\\alpha$, where\n$\\alpha$ is a type parameter. An element of this datatype is of the\nform $\\mathtt{Finder}\\;\\epsilon$, where $\\epsilon$ is a search\noperator. Think of an element $\\R{s}$ of type\n$\\mathtt{Searachable}\\;\\alpha$ as a searchable subspace of the\ndatatype~$\\alpha$. The subspace is given in terms of its search\noperator.\n\nWe define an auxiliary function $\\mathtt{find}$, so that we can\nconveniently write $\\R{find}\\;\\R{s}\\R{p}$ and read it ``search in\nspace $\\R{s}$ for a candidate satisfying $\\R{p}$'':\n%\n\\begin{lstlisting}\nfind :: Searchable a -> (a -> Bool) -> a\nfind (Finder epsilon) p = epsilon p\n\\end{lstlisting}\n%\nThe function $\\mathtt{find}$ always finds a candidate, which may or\nmay not satisfy the given condition. It is convenient have another\nfunction $\\mathtt{search}$ which returns $\\mathtt{Nothing}$ or\n$\\mathtt{Just}\\;x$ depending on whether there is an $x$ satisfying the\ngiven condition:\n% \n\\begin{lstlisting}\nsearch :: Searchable a -> (a -> Bool) -> Maybe a\nsearch s p =\n    let x = find s p\n    in if p x then Just x else Nothing\n\\end{lstlisting}\n% \nAnd here are the quantifiers:\n% \n\\begin{lstlisting}\nexists s p = p (find s p)\nforall s p = not (exists s (not . p))\n\\end{lstlisting}\n% \nNow we actually define some searchable spaces. The easiest is the singleton\nspace $\\set{x}$ where the only candidate is $x$:\n% \n\\begin{lstlisting}\nsingleton x = Finder (\\p -> x)\n\\end{lstlisting}\n% \nIn Haskell the notation \\texttt{\\char92 x -> e} means ``the function which\nmaps $x$ to $e$''. Thus we read the definition above as ``the constant\nfunction which maps every $p$ to $x$''.\n% \nFor a space with two points $\\set{x, y}$ the $\\epsilon$ operator needs to\ncheck first whether $p(x)$ holds:\n% \n\\begin{lstlisting}\ndoubleton x y = Finder (\\p -> if p x then x else y)\n\\end{lstlisting}\n% \nThe generalization of singletons and doubletons are finite sets. Given a list\nof elements $[x_1, \\ldots, x_n]$, we construct the searchable space $\\set{x_1,\n  \\ldots, x_n}$:\n% \n\\begin{lstlisting}\nfinite_set :: [a] -> Searchable a\n\nfinite_set lst = Finder (\\p ->\n    let loop []     = undefined\n        loop [x]    = x\n        loop (x:xs) = if p x then x else loop xs\n    in loop lst)\n\\end{lstlisting}\n% \nNote that \\texttt{finite\\_set\\;[]} is undefined because the empty set is not\nsearchable.\n% \nThere are many other constructions of searchable spaces, such as the disjoint\nsum:\\footnote{In Haskell the disjoint sum $X + Y$ is the datatype\n  $\\mathtt{Either}\\;X\\;Y$, and the canonical inclusions are called\n  $\\mathtt{Left}$ and $\\mathtt{Right}$, respectively.}\n% \n\\begin{lstlisting}\nsum s t = Finder (\\p -> let x = Left (find s (p . Left))\n                            y = Right (find t (p . Right))\n                        in if p x then x else y)\n\\end{lstlisting}\n% \nA more complicated operation is a union of a searchable family of\nsearchable (sub)spaces. Suppose $I$ is a searchable space and\n${S_i}_{i \\in I}$ a family of searchable subspaces, $S_i \\subseteq X$.\nThen their union $S = \\bigcup_{i \\in I} S_i$ is also searchable, with\nthe search operator defined as follows:\n%\n\\begin{equation*}\n  \\epsilon_S(p) = \\text[not finished]\n\\end{equation*}\n%\nTo get things organized, we shall define a \\emph{search monad} which\nwill significantly simplify the code we have to write.\\footnote{If you\n  are not familiar with Haskell monads, you should now read\n  Appendix~\\ref{app:monads}.}\n\n\n% BIBLIOGRAPHY (fold)\n\n\\bibliographystyle{plain}\n\\bibliography{../realizability,../cca,../notes}\n\n% bibliogprahy (end)\n\\appendix\n    \n\\section{Haskell monads by examples} % (fold)\n\\label{app:monads}\n\nThere are any number of introductions on monads written by Haskell bloggers\naround the internet. You may want to look at some of them for further insight.\nWe shall introduce monads by examples.\n\nHaskell is a purely functional language. In particular, it does not allow\ndirect invocation of any operations that would allow us to detect the order of\nevaluation. This rules out mutable variables, exceptions, I/O, and many other\nuseful programming concepts. All these can be put back into Haskell with a\nclever way of programming known as \\emph{monadic style}.\n\nOur first example is a very simple kind of exception which is sometimes known\nas \\emph{abort}. It is an operation which aborts whatever is being computed\nand cannot be intercepted. To have something like that in Haskell, we need to\nbe explicit about values which may trigger abort. So we define a datatype\n$\\mathtt{Abortable}\\;t$ which means ``either an ordinary value of type $t$, or\na special value $\\mathtt{Aborted}$ indicating that abort\nhappened'':\\footnote{the $\\mathtt{deriving}$ clause is of no concern right\n  now, it means Haskell will automatically derive a way of showing abortable\n  values on screen}\n\n\\begin{lstlisting}\ndata Abortable t = Value t | Aborted\n                   deriving Show  \n\\end{lstlisting}\n% \nThe constant $\\mathtt{Aborted}$ signifies a value whose computation was\naborted. The other possibility is a value of the form $\\mathtt{Value}\\;v$,\nwhich signifies a successfully computed value $v$ (abort did not happen).\nHaskell insists that we write $\\mathtt{Value}\\;v$ rather than just $v$. This\nway it can tell the difference between ordinary values and values that could\nhave been aborted but were not.\n\nAn ordinary value $v$ of type $t$ may always be converted to an abortable\nvalue $\\mathtt{Value}\\;v$ of type $\\mathtt{Abortable}\\;t$. The operation that\ndoes this is called $\\mathtt{return}$ in Haskell and is the first half of a\nmonad. The second half of a monad is an operation \\cc{>>=}, called\n\\emph{bind}, which combines an abortable value\n% \n\\begin{lstlisting}\nx :: Abortable\n\\end{lstlisting}\n% \nand a function\n\\begin{lstlisting}\nf :: a -> Abortable b  \n\\end{lstlisting}\n% \nwhich expects an ordinary value and outputs an abortable one. This is written\nas\n% \n\\begin{lstlisting}\nx >>= f\n\\end{lstlisting}\n% \nWhat should \\cc{x >>= f be}? Well, if \\cc{x} is \\cc{Aborted} then \\cc{x >>=} f\nmust also be \\cc{Aborted} (we want \\cc{Aborted} to act as an uncatchable\nexception). If \\cc{x} is of the form \\cc{Value v} then \\cc{x >>= f} should be\n\\cc{f v}. This brings us to the official monad definition:\n% \n\\begin{lstlisting}\ninstance Monad Abortable where\n   return v        = Value v\n   Aborted >>= f   = Aborted\n   (Value v) >>= f = f v\n\\end{lstlisting}\n% \nIn principle we can use \\cc{return} and \\cc{>>=} to compute with abortable\nvalues, but it is very cumbersome. For example, suppose we have a division\noperation whose result is an abortable integer,\n% \n\\begin{lstlisting}\ndivide :: Int -> Int -> Abortable Int\ndivide x 0 = Aborted\ndivide x y = Value (x `div` y)  \n\\end{lstlisting}\n% \nIn order to compute the function which maps $x$ and $y$ to $x/y + y/x$ we have\nto write\n% \n\\begin{lstlisting}\nf :: Int -> Int -> Abortable Int\nf x y = (divide x y) >>= (\\u -> (divide y x) >>= (\\v -> return (u + v)))\n\\end{lstlisting}\n% \nWith good indentation it is possible to improve the code a bit:\n% \n\\begin{lstlisting}\ng :: Int -> Int -> Abortable Int\ng x y = (divide x y) >>= (\\u ->\n        (divide y x) >>= (\\v ->\n        return (u + v)))\n\\end{lstlisting}\n% \nThis we can read as: feed the abortable value \\cc{divide x y} into \\cc{u},\nfeed the abortable value \\cc{divide y x} into \\cc{v}, then \\cc{return} the\nabortable value \\cc{u+v}. The operator \\cc{>>=} makes sure that the whole\nresult is \\cc{Aborted} if either \\cc{u} or \\cc{v} is. Haskell has special\nnotation which significantly improves the code:\n% \n\\begin{lstlisting}\nh :: Int -> Int -> Abortable Int\nh x y = do u <- divide x y\n           v <- divide y x\n           return (u + v)\n\\end{lstlisting}\n% \nThe functions \\cc{g} and \\cc{h} are the exact same thing written in different\nnotations.\n\nThe \\cc{Abortable} monad is already built into Haskell, except it is called\nthe \\cc{Maybe} monad. Instead of \\cc{Value v} and \\cc{Aborted} it has \\cc{Just\n  v} and \\cc{Nothing}. To give an example of its use, suppose we have an\nassociation list\n% \n\\begin{lstlisting}\nlst = [(\"apple\", 3), (\"orange\", 10), (\"banana\", 2), (\"stone\", 6)]\n\\end{lstlisting}\n% \nand would like to find the value corresponding to \\cc{\"orange\"}. We can do\nthis by writing\n% \n\\begin{lstlisting}\ny = lookup \"orange\" lst -- y equals Just 10\n\\end{lstlisting}\n% \nThe answer is \\cc{Just 10}. If we lookup something that is not in the list we\nget \\cc{Nothing}:\n% \n\\begin{lstlisting}\n  z = lookup \"cow\" lst -- z equals Nothing\n\\end{lstlisting}\n% \nThe monad and do notation come in handy if we have a piece of code that does\nseveral lookups and we want it to fail as soon as one of the lookups fails,\ne.g.\n% \n\\begin{lstlisting}\nsum = do u <- lookup \"banana\" lst\n         v <- lookup \"apple\" lst\n         w <- lookup \"cherry\" lst\n         return (u + v + w)\n\\end{lstlisting}\n% \nThe value of \\cc{sum} is \\cc{Nothing} because the third lookup fails. Had it\nsucceeded, we would get \\cc{Just i} for some integer \\cc{i}. Here is one way\nof writing the same code without the do notation:\n% \n\\begin{lstlisting}\nsum' = case (lookup \"banana\" lst, lookup \"apple\" lst, lookup \"cherry\" lst) of\n          (Just u, Just v, Just w) -> Just (u + v + w)\n          (_, _, _) -> Nothing\n\\end{lstlisting}\n% \nYou may judge for yourself which one is more readable.\n\nThe next example of a monad is non-deterministic choice operator. Suppose in a\ncomputation we have choice points, at which we can choose any value from a\ngiven list. Such a situation occurs when we perform a search over a tree, and\nat each node we can choose one of the branches. We would like a convenient way\nof programming choice points so that when we evaluate an expression with\nchoice points all possible combinations of choices are taken, and the possible\nresults are stored in a list.\n\nFirst we define a datatype \\cc{Choose t} which holds possible results of a\ncomputation of type \\cc{t} with choice points:\n% \n\\begin{lstlisting}\ndata Choose t = Choices [t]\n                deriving Show\n\\end{lstlisting}\n% \nFor example, the value \\cc{Choices [1,2,3]} means that the possible outcomes\nare $1$, $2$, and $3$. To get a monad, we must define return, which converts\nan ordinary value \\cc{v} of type \\cc{t} to one of type \\cc{Choose t}. This\npart is more or less obvious as we simply return \\cc{Choices [v]}.\n% \nTo define \\cc{>>=} we have to think about how to combine a value\n$\\mathtt{Choices}\\;[v, \\ldots, v_n]$ with a function $f$ which accepts an\nordinary value v and returns some choices. It is not hard to see that we\nshould loop over $v_1, ..., v_n$, get all the different choices produced by\n$f$ and combine them into a single choice. The end result is the following\nmonad\n% \n\\begin{lstlisting}\ninstance Monad Choose where\n     return v = Choices [v]\n     (Choices lst) >>= f = Choices (combine f lst [])\n         where combine f [] ws     = ws\n               combine f (v:vs) ws = let Choices us = f v\n                                     in combine f vs (ws ++ us)\n\\end{lstlisting}\n% \nNow we can use the do notation to write programs like this:\n% \n\\begin{lstlisting}\n-- all sums of the form x+y where x is 1,...,10 and y is 1,...,x.\nc = do x <- [1..10]\n       y <- [1..x]\n       return (x + y)\n-- c is Choices [2,3,4,4,5, ..., 18,19,20] (55 elements)\n\\end{lstlisting}\n% \nWithout the do notation we would have to have a double loop of some kind. The\nmonad we just considered is also built into Haskell, and is known as the\n\\emph{list monad}. Possible choices are represented as a list, so we can write\n$[x_1, \\ldots, x_n]$ rather than $\\mathtt{Choices}\\; [x_1, \\ldots, x_n]$:\n% \n\\begin{lstlisting}\n-- all sums of the form x+y where x is 1,...,10 and y is 1,...,x.\nd = do x <- [1..10]\n       y <- [1..x]\n       return (x + y)\n-- d is [2,3,4,4,5, ..., 18,19,20] (55 elements)\n\\end{lstlisting}\n\nOur last example is the state monad. In procedural programming languages we\nhave variables that can be updated, i.e., their values change as computation\nprogresses. We say that the computation is \\emph{stateful} because it depends\non the state of the variables, and it may change the state of the variable.\n\nIn general, stateful computation is a function which accepts the current state\nand returns a result together with the new state. That is, in Haskell a\nstateful computation computing a result of type \\cc{t} and having access to\nstate of type \\cc{s} is a function \\cc{s -> (t, s)} which accepts the current\nstate \\cc{m}, and returns a pair \\cc{(x,m')} representing the computed value\n\\cc{x} and the new state \\cc{m'}.\n% \nWe define a Haskell type of such stateful computations:\n% \n\\begin{lstlisting}\ndata State s t = Stateful (s -> (t, s))  \n\\end{lstlisting}\n% \nHere is an example of a stateful computation:\n% \n\\begin{lstlisting}\nincr = Stateful $ \\m -> (m, m+1)  \n\\end{lstlisting}\n% $\nBy the way, the mysterious \\$ does nothing, except it allows us to write fewer\nparenthesis. The meaning of \\cc{f \\$ x} is the same as \\cc{f x}, except that\n\\cc{\\$} is an infix operator with low precedence. If we wrote \\cc{incr}\nwithout \\$, we would have to write \\cc{Stateful (\\m -> (m, m+1))}.\n\nThe definition of \\cc{incr} is read as follows: \\cc{incr} is a stateful\ncomputation which takes a memory location \\cc{m} and returns the current value\nof \\cc{m}. It also increases the memory location by \\cc{1}. In other words,\nthis would be written as \\cc{m++} in C.\n\nBut how do we actually execute \\cc{incr}? We give it the initial value of the\nmemory location and out comes the result together with updated memory:\n% \n\\begin{lstlisting}\n(r1,m1) = let Stateful v = incr in v 42 -- r1 is 42, m1 is 44\n\\end{lstlisting}\n% \nThis is quite ugly, so we define an auxiliary function\n% \n\\begin{lstlisting}\nrun m (Stateful v) = v m\n\\end{lstlisting}\n% \nNow we can write\n% \n\\begin{lstlisting}\n(r2, m2) = run 42 incr -- r2 is 42, m2 is 44\n\\end{lstlisting}\n% \nand read it as ``run \\cc{incr} with initial state 42''. Let us also define the state monad:\n% \n\\begin{lstlisting}\ninstance Monad (State s) where\n     return x = Stateful $ \\m -> (x, m)\n     v >>= f  = Stateful $ \\m -> let (x, m') = run m v in run m' (f x)\n\\end{lstlisting}\n% $\nReturn converts a pure (non-stateful) value to a stateful one that doesn't change the state:\nThe operation \\cc{>>=} chains together stateful computations:\n% \nTo compute \\c{v >>= f} in state \\c{m} we first run \\c{v} in state \\c{m} to\nobtain a result \\c{x} and the new state \\c{m'}. We then compute \\c{f x} in\nstate \\c{m'}. This is all good and well, but the do notation does not allow us\nto manipulate the state, so we also need basic operations that\ndo:\\footnote{The Haskell value \\cc{()} is the empty tuple, the equivalent of\n  \\cc{void} in C++ and Java.}\n% \n\\begin{lstlisting}\nget = Stateful $ \\m -> (m, m)        -- get the current value of state\nupdate n = Stateful $ \\m -> ((), n)  -- update state to n, give () as result\n\\end{lstlisting}\n% \nWith this we may write procedural program:\n% \n\\begin{lstlisting}\na = run 42 (do x <- get        -- let x be current value of memory (42)\n               update (x+1)    -- update memory to x+1 (43)\n               y <- get        -- let y be current value of memory (43)\n               update 7        -- update memory to 7\n               return (x + y)) -- return x+y (42+43 = 85)\n-- a is (85, 7)  \n\\end{lstlisting}\n% \nLet us conclude this short introduction by giving the official equations that\n\\cc{return} and \\cc{>>=} must satisfy in order to deserve the name\n\\emph{monad}:\n% \n\\begin{align*}\n  \\mathtt{return}\\; a \\bind k &= k\\; a \\\\\n  m \\bind \\mathtt{return}              &=   m \\\\\n  m \\bind (\\backslash x -> k x \\bind h)   &=   (m \\bind k) \\bind h\n\\end{align*}\n% \nFurther reading:\n% \n\\begin{enumerate}\n\\item  \\url{http://www.haskell.org/tutorial/monads.html}:\n  ``A Gentle Introduction to Haskell'', Chapter 9: About Monads\n\\item \\url{http://www.haskell.org/all_about_monads/html/index.html}\n  ``All about Monads: \n  A comprehensive guide to the theory and practice of monadic programming in Haskell''\n\\item \\url{http://blog.sigfpe.com/}\n  ``A neighborhood of infinity''.\n  Dan Piponi's blog has many clever and mind boggling examples of monads.\n\\end{enumerate}\n% section haskell_monads_by_examples (end)\n\\end{document}\n", "meta": {"hexsha": "81b676f3f357ebf999319d59a8ffd5936b8af036", "size": 36388, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "etc/haskell/notes.tex", "max_stars_repo_name": "bmsherman/marshall", "max_stars_repo_head_hexsha": "3d7fab1919422c3c2dac60f7bfefe1f8f25e4f0f", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 78, "max_stars_repo_stars_event_min_datetime": "2015-03-14T19:40:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T11:52:29.000Z", "max_issues_repo_path": "etc/haskell/notes.tex", "max_issues_repo_name": "psg-mit/marshall-lics", "max_issues_repo_head_hexsha": "fa78a71a2a2f33be49ee343f5fda267f12ee25a4", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2015-10-21T06:02:33.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-13T16:35:41.000Z", "max_forks_repo_path": "etc/haskell/notes.tex", "max_forks_repo_name": "psg-mit/marshall-lics", "max_forks_repo_head_hexsha": "fa78a71a2a2f33be49ee343f5fda267f12ee25a4", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2015-06-16T23:33:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-30T19:57:22.000Z", "avg_line_length": 38.2226890756, "max_line_length": 92, "alphanum_fraction": 0.6961635704, "num_tokens": 11117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.430471574896966}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage{cdblatex}\n\\usepackage{hyperref}\n\\usepackage{geometry}\n\\usepackage{summary}\n\\usepackage{config}\n\n\\geometry{a4paper,landscape,margin=2cm}\n% \\geometry{a4paper,portrait,margin=2cm}\n\\hypersetup{colorlinks=true}% use false for journals and paper\n\\numberwithin{equation}{section}% requires amsmath\n\n\\begin{document}\n\n% =================================================================================================\n\\section*{Notes}\n\nThe convention for the curvature used in these notes conforms to that of Misner-Thorne-Wheeler\n(MTW, eq. 11.12) , namely\n\\begin{align*}\n   V^{a}{}_{;bc} - V^{a}{}_{;cb} = - R^{a}{}_{dbc} V^{d}\n\\end{align*}\n\nAlso, note the following shorthand for mixed covariant derivatives\n\\begin{align*}\n   \\nabla_a\\left(\\nabla_b\\right) &= \\nabla_{ab}\\\\\n   \\nabla_a\\left(\\nabla_b\\left(\\nabla_c\\right)\\right) &= \\nabla_{abc}\\\\\n   \\nabla_a\\left(\\nabla_b\\left(\\nabla_c\\left(\\nabla_d\\right)\\right)\\right) &= \\nabla_{abcd}\n\\end{align*}\nand so on.\n\nSee for example the Python function {\\tts combine_nabla} in {\\tts cadabra/dRabcd.tex}.\n\nIn terms of $\\nabla$ the above MTW definition of $R^{a}{}_{bcd}$ can written as\n\\begin{align*}\n   \\left(\\nabla_{cb}-\\nabla_{bc}\\right) V^{a} = - R^{a}{}_{dbc} V^{d}\n\\end{align*}\n\n% -------------------------------------------------------------------------------------------------\n\\subsection*{Symmetrisation}\n\\input{lib/dGamma.cdbtex}\n\nIn the following pages there will be frequent constructions of the form\n\\begin{dgroup*}\n   \\begin{dmath*}  3 A^b A^c\\Gamma^a{}_{d(b,c)} = \\cdb{scaled1.002} \\end{dmath*}\n   \\begin{dmath*}  6 A^b A^c A^e \\Gamma^a{}_{d(b,ce)} = \\cdb{scaled2.002} \\end{dmath*}\n   \\begin{dmath*} 15 A^b A^c A^e A^f \\Gamma^a{}_{d(b,cef)} = \\cdb{scaled3.002} \\end{dmath*}\n\\end{dgroup*}\nThe vector $A^{a}$ has no special meaning. Its purpose is to indicate that the\nassociciated tensor is symmetric over a selection of its indices. If the $A^{a}$ were not included\nthen the right hand side would either need to be spelt out in full or some other device would\nbe needed to denote the symmetries. The symmetrisation brackets are included on the left hand\nside though they are redundant (in the presence of the $A^{a}$).\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The metric in RNC}\n\\input{lib/metric.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*} g_{a b}(x) = \\cdb{Metric.601}+\\BigO{\\eps^6} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Curvature expansion of the metric}\n\\begin{align*}\n     g_{a b}(x) =\n     \\ngab{0}_{a b}\n   + \\ngab{2}_{a b}\n   + \\ngab{3}_{a b}\n   + \\ngab{4}_{a b}\n   + \\ngab{5}_{a b}+\\BigO{\\eps^6}\n\\end{align*}\n\\begin{dgroup*}\n   \\begin{dmath*}     \\ngab{0}_{a b} = \\cdb{scaled0.601} \\end{dmath*}\n   \\begin{dmath*}   3 \\ngab{2}_{a b} = \\cdb{scaled2.601} \\end{dmath*}\n   \\begin{dmath*}   6 \\ngab{3}_{a b} = \\cdb{scaled3.601} \\end{dmath*}\n   \\begin{dmath*} 180 \\ngab{4}_{a b} = \\cdb{scaled4.601} \\end{dmath*}\n   \\begin{dmath*}  90 \\ngab{5}_{a b} = \\cdb{scaled5.601} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The inverse metric in RNC}\n\\input{lib/metric-inv.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*} g^{a b}(x) = \\cdb{Metric.601}+\\BigO{\\eps^6} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Curvature expansion of the inverse metric}\n\\begin{align*}\n     g^{a b}(x) =\n     \\ngab{0}^{a b}\n   + \\ngab{2}^{a b}\n   + \\ngab{3}^{a b}\n   + \\ngab{4}^{a b}\n   + \\ngab{5}^{a b}+\\BigO{\\eps^6}\n\\end{align*}\n\\begin{dgroup*}\n   \\begin{dmath*}    \\ngab{0}^{a b} = \\cdb{scaled0.601} \\end{dmath*}\n   \\begin{dmath*}  3 \\ngab{2}^{a b} = \\cdb{scaled2.601} \\end{dmath*}\n   \\begin{dmath*}  6 \\ngab{3}^{a b} = \\cdb{scaled3.601} \\end{dmath*}\n   \\begin{dmath*} 60 \\ngab{4}^{a b} = \\cdb{scaled4.601} \\end{dmath*}\n   \\begin{dmath*} 90 \\ngab{5}^{a b} = \\cdb{scaled5.601} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The metric determinant in RNC}\n\\input{lib/detg2.cdbtex}\n\n\\begin{dgroup*}\n   \\Dmath*{-\\det g(x) = \\cdb{Ndetg.701}+\\BigO{\\eps^6}}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{The metric Jacobian in RNC}\n\n\\begin{dgroup*}\n   \\Dmath*{\\sqrt{-\\det g(x)} = \\cdb{sqrtNdetg.801}+\\BigO{\\eps^6}}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{The log of detg in RNC}\n\n\\begin{dgroup*}\n   \\Dmath*{\\log\\left(-\\det g(x)\\right) = \\cdb{logNdetg.901}+\\BigO{\\eps^6}}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The connection in RNC}\n\\input{lib/connection.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*} A^a A^b \\Gamma^{d}_{a b} = \\cdb{Gamma.301} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} 360 A^a A^b \\Gamma^{d}_{a b} = \\cdb{Scaled.301} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Curvature expansion of the connection}\n\\begin{align*}\n     A^a A^b \\Gamma^{d}_{a b} =\n     A^a A^b \\nGamma{2}^{d}{}_{a b}\n   + A^a A^b \\nGamma{3}^{d}{}_{a b}\n   + A^a A^b \\nGamma{4}^{d}{}_{a b}\n   + A^a A^b \\nGamma{5}^{d}{}_{a b}+\\BigO{\\eps^6}\n\\end{align*}\n\\begin{dgroup*}\n   \\begin{dmath*}   3 A^a A^b \\nGamma{2}^{d}_{a b} = \\cdb{scaled2.301} \\end{dmath*}\n   \\begin{dmath*}  12 A^a A^b \\nGamma{3}^{d}_{a b} = \\cdb{scaled3.301} \\end{dmath*}\n   \\begin{dmath*} 360 A^a A^b \\nGamma{4}^{d}_{a b} = \\cdb{scaled4.301} \\end{dmath*}\n   \\begin{dmath*} 180 A^a A^b \\nGamma{5}^{d}_{a b} = \\cdb{scaled5.301} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Symmetrised partial derivatives of the connection}\n\\input{lib/dGamma.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*}   3 A^b A^c\\Gamma^a{}_{d(b,c)} = \\cdb{scaled1.002} \\end{dmath*}\n   \\begin{dmath*}   6 A^b A^c A^e \\Gamma^a{}_{d(b,ce)} = \\cdb{scaled2.002} \\end{dmath*}\n   \\begin{dmath*}  15 A^b A^c A^e A^f \\Gamma^a{}_{d(b,cef)} = \\cdb{scaled3.002} \\end{dmath*}\n   \\begin{dmath*}   9 A^b A^c A^e A^f A^g \\Gamma^a{}_{d(b,cefg)} = \\cdb{scaled4.002} \\end{dmath*}\n   \\begin{dmath*} 252 A^b A^c A^e A^f A^g A^h\\Gamma^a{}_{d(b,cefgh)} = \\cdb{scaled5.002} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Symmetrised partial derivatives of $R^a{}_{bcd}$}\n\\input{lib/dRabcd.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*}    A^c A^d A^e R^a{}_{cdb,e} = \\cdb{scaled1.601} \\end{dmath*}\n   \\begin{dmath*}    A^c A^d A^e A^{f} R^a{}_{cdb,ef} = \\cdb{scaled2.601} \\end{dmath*}\n   \\begin{dmath*} -2 A^c A^d A^e A^{f} A^{g} R^a{}_{cdb,efg} = \\cdb{scaled3.601} \\end{dmath*}\n   \\begin{dmath*} -5 A^c A^d A^e A^{f} A^{g} A^{h} R^a{}_{cdb,efgh} = \\cdb{scaled4.601} \\end{dmath*}\n   \\begin{dmath*} -3 A^c A^d A^e A^{f} A^{g} A^{h} A^{i}R^a{}_{cdb,efghi} = \\cdb{scaled5.601} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The generalised connection in RNC}\n\\input{lib/genGamma.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*} A^b A^c \\Gamma^{a}_{b c} = \\cdb{genGamma0.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d \\Gamma^{a}_{b c d} = \\cdb{genGamma1.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d A^e \\Gamma^{a}_{b c d e} = \\cdb{genGamma2.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d A^e A^f \\Gamma^{a}_{b c d e f} = \\cdb{genGamma3.000} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The generalised connection in RNC}\n\nThis is the same as the previous page but with a small change in the format to avoid fractions.\n\n\\begin{dgroup*}\n   \\begin{dmath*} 360 A^b A^c \\Gamma^{a}_{b c} = \\cdb{scaledGamma0.001} \\end{dmath*}\n   \\begin{dmath*} 360 A^b A^c A^d \\Gamma^{a}_{b c d} = \\cdb{scaledGamma1.001} \\end{dmath*}\n   \\begin{dmath*}  90 A^b A^c A^d A^e \\Gamma^{a}_{b c d e} = \\cdb{scaledGamma2.001} \\end{dmath*}\n   \\begin{dmath*}   3 A^b A^c A^d A^e A^f \\Gamma^{a}_{b c d e f} = \\cdb{scaledGamma3.001} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Convert from generic (x) to local RNC coords (y)}\n\\input{lib/gen2rnc.cdbtex}\n\n\\begin{align*}\n   y^a = \\ny{0}^{a} + \\ny{1}^{a} + \\ny{2}^{a} + \\ny{3}^{a} + \\ny{4}^{a}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*}     \\ny{0}^{a} = \\cdb{scaled1.002} \\end{dmath*}\n   \\begin{dmath*}   2 \\ny{1}^{a} = \\cdb{scaled2.002} \\end{dmath*}\n   \\begin{dmath*}   6 \\ny{2}^{a} = \\cdb{scaled3.002} \\end{dmath*}\n   \\begin{dmath*}  24 \\ny{3}^{a} = \\cdb{scaled4.002} \\end{dmath*}\n   \\begin{dmath*} 360 \\ny{4}^{a} = \\cdb{scaled5.002} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The geodesic ivp}\n\\input{lib/geodesic-ivp.cdbtex}\n\n\\begin{align*}\n   x^{a}(s) = x^{a}\n            + s {\\dot{x}^a}\n            + \\frac{s^2}{2!} {\\dot{x}^b} {\\dot{x}^c} A^{a}_{bc}\n            + \\frac{s^3}{3!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} A^{a}_{bcd}\n            + \\frac{s^4}{4!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} {\\dot{x}^e} A^{a}_{bcde}\n            + \\frac{s^5}{5!} {\\dot{x}^b} {\\dot{x}^c} {\\dot{x}^d} {\\dot{x}^e} {\\dot{x}^f} A^{a}_{bcdef}\n            + \\dotsb\n\\end{align*}\n\\begin{dgroup*}\n   \\begin{dmath*} 360 A^{a}_{bc} = \\cdb{sterm2.002} \\end{dmath*}\n   \\begin{dmath*} 360 A^{a}_{bcd} = \\cdb{sterm3.002} \\end{dmath*}\n   \\begin{dmath*}  90 A^{a}_{bcde} = \\cdb{sterm4.002} \\end{dmath*}\n   \\begin{dmath*}   3 A^{a}_{bcdef} = \\cdb{sterm5.002} \\end{dmath*}\n\\end{dgroup*}\n\\clearpage\n\n% =================================================================================================\n\\section*{Geodesic boundary value problem to terms linear in $R$}\n\\input{lib/geodesic-bvp.cdbtex}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}(s) = \\cdb{bvp.601} + \\BigO{s^3,\\eps^3} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{align*}\n   x^{a}(s) &= x^{a} + s Dx^{a}\n                     + (s-s^2) x^{a}_2\n                     + \\BigO{s^3,\\eps^3}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_2 = \\nx{2}^{a}_2 + \\BigO{\\eps^3} \\end{dmath*}\n   \\begin{dmath*} -3 \\nx{2}^{a}_2 = \\cdb{Rterm22.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Geodesic boundary value problem to terms linear in $\\nabla R$}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}(s) = \\cdb{bvp.602} + \\BigO{s^4,\\eps^4} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{align*}\n   x^{a}(s) &= x^{a} + s Dx^{a}\n                     + (s-s^2) x^{a}_2\n                     + (s-s^3) x^{a}_3\n                     + \\BigO{s^4,\\eps^4}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_2 = \\nx{2}^{a}_2 + \\nx{3}^{a}_2 + \\BigO{\\eps^4} \\end{dmath*}\n   \\begin{dmath*}   -3 \\nx{2}^{a}_2 = \\cdb{Rterm22.102} \\end{dmath*}\n   \\begin{dmath*}  -24 \\nx{3}^{a}_2 = \\cdb{Rterm23.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_3 = \\nx{3}^{a}_3 + \\BigO{\\eps^4} \\end{dmath*}\n   \\begin{dmath*}   -12 \\nx{3}^{a}_3 = \\cdb{Rterm33.102} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n\\section*{Geodesic boundary value problem to terms linear in $\\nabla^2 R$}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}(s) = \\cdb{bvp.603} + \\BigO{s^5,\\eps^5} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{align*}\n   x^{a}(s) &= x^{a} + s Dx^{a}\n                     + (s-s^2) x^{a}_2\n                     + (s-s^3) x^{a}_3\n                     + (s-s^4) x^{a}_4\n                     + \\BigO{s^5,\\eps^5}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_2 = \\nx{2}^{a}_2 + \\nx{3}^{a}_2 + \\nx{4}^{a}_2 + \\BigO{\\eps^5} \\end{dmath*}\n   \\begin{dmath*}   -3 \\nx{2}^{a}_2 = \\cdb{Rterm22.102} \\end{dmath*}\n   \\begin{dmath*}  -24 \\nx{3}^{a}_2 = \\cdb{Rterm23.102} \\end{dmath*}\n   \\begin{dmath*} -720 \\nx{4}^{a}_2 = \\cdb{Rterm24.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_3 = \\nx{3}^{a}_3 + \\nx{4}^{a}_3 + \\BigO{\\eps^5} \\end{dmath*}\n   \\begin{dmath*}   -12 \\nx{3}^{a}_3 = \\cdb{Rterm33.102} \\end{dmath*}\n   \\begin{dmath*}  -720 \\nx{4}^{a}_3 = \\cdb{Rterm34.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_4 = \\nx{4}^{a}_4 + \\BigO{\\eps^5} \\end{dmath*}\n   \\begin{dmath*}  -180 \\nx{4}^{a}_4 = \\cdb{Rterm44.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Geodesic boundary value problem to terms linear in $\\nabla^3 R$}\n\nThe geodesic that connects the points with RNC coordinates $x^a$ and $x^a+Dx^a$ is described, for $0\\le s\\le 1$, by\n%\n% \\begin{dgroup*}\n%    \\begin{dmath*} x^{a}(s) = \\cdb{bvp.604} + \\BigO{s^6,\\eps^6} \\end{dmath*} % too big for pdfLaTeX\n% \\end{dgroup*}\n%\n\\begin{align*}\n   x^{a}(s) &= x^{a} + s Dx^{a}\n                     + (s-s^2) x^{a}_2\n                     + (s-s^3) x^{a}_3\n                     + (s-s^4) x^{a}_4\n                     + (s-s^5) x^{a}_5\n                     + \\BigO{s^6,\\eps^6}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_2 = \\nx{2}^{a}_2 + \\nx{3}^{a}_2 + \\nx{4}^{a}_2 + \\nx{5}^{a}_2 + \\BigO{\\eps^6} \\end{dmath*}\n   \\begin{dmath*}   -3 \\nx{2}^{a}_2 = \\cdb{Rterm22.102} \\end{dmath*}\n   \\begin{dmath*}  -24 \\nx{3}^{a}_2 = \\cdb{Rterm23.102} \\end{dmath*}\n   \\begin{dmath*} -720 \\nx{4}^{a}_2 = \\cdb{Rterm24.102} \\end{dmath*}\n   \\begin{dmath*} -360 \\nx{5}^{a}_2 = \\cdb{Rterm25.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_3 = \\nx{3}^{a}_3 + \\nx{4}^{a}_3 + \\nx{5}^{a}_3 + \\BigO{\\eps^6} \\end{dmath*}\n   \\begin{dmath*}   -12 \\nx{3}^{a}_3 = \\cdb{Rterm33.102} \\end{dmath*}\n   \\begin{dmath*}  -720 \\nx{4}^{a}_3 = \\cdb{Rterm34.102} \\end{dmath*}\n   \\begin{dmath*} -1080 \\nx{5}^{a}_3 = \\cdb{Rterm35.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_4 = \\nx{4}^{a}_4 + \\nx{5}^{a}_4 + \\BigO{\\eps^6} \\end{dmath*}\n   \\begin{dmath*}  -180 \\nx{4}^{a}_4 = \\cdb{Rterm44.102} \\end{dmath*}\n   \\begin{dmath*} -2160 \\nx{5}^{a}_4 = \\cdb{Rterm45.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} x^{a}_5 = \\nx{5}^{a}_5 + \\BigO{\\eps^6} \\end{dmath*}\n   \\begin{dmath*} -360 \\nx{5}^{a}_5 = \\cdb{Rterm55.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Geodesic arc-length}\n\\input{lib/geodesic-lsq.cdbtex}\n\n\\begin{dgroup*}[spread=5pt]\n   % LCB: which of these is correct?\n   % \\begin{dmath*} \\left(\\Delta s\\right)^2 = \\cdb{lsq.301} + \\BigO{\\eps^6,Dx^6} \\end{dmath*}\n   % \\begin{dmath*} \\left(\\Delta s\\right)^2 = \\cdb{lsq.301} + \\BigO{\\eps^6,Dx^7} \\end{dmath*}\n   \\begin{dmath*} \\left(\\Delta s\\right)^2 = \\cdb{lsq.301} + \\BigO{\\eps^6} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Geodesic arc-length curvature expansion}\n\n\\begin{align*}\n   % LCB: which of these is correct?\n   % \\left(\\Delta s\\right)^2 = \\nD{0} + \\nD{2} + \\nD{3} + \\nD{4} + \\nD{5} + \\BigO{\\eps^6,Dx^6}\n   % \\left(\\Delta s\\right)^2 = \\nD{0} + \\nD{2} + \\nD{3} + \\nD{4} + \\nD{5} + \\BigO{\\eps^6,Dx^7}\n   \\left(\\Delta s\\right)^2 = \\nD{0} + \\nD{2} + \\nD{3} + \\nD{4} + \\nD{5} + \\BigO{\\eps^6}\n\\end{align*}\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}      \\nD{0} = \\cdb{scaled0.301} \\end{dmath*}\n   \\begin{dmath*}    3 \\nD{2} = \\cdb{scaled2.301} \\end{dmath*}\n   \\begin{dmath*}   12 \\nD{3} = \\cdb{scaled3.301} \\end{dmath*}\n   \\begin{dmath*}  360 \\nD{4} = \\cdb{scaled4.301} \\end{dmath*}\n   \\begin{dmath*} 1080 \\nD{5} = \\cdb{scaled5.301} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Tranformation between two RNC frames}\n\\input{lib/rnc2rnc.cdbtex}\n\n\\begin{align*}\n   y^{a} = \\ny{0}^{a} + \\ny{2}^{a} + \\ny{3}^{a} + \\ny{4}^{a} + \\ny{5}^{a} + \\BigO{\\eps^6}\n\\end{align*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{0}^{a} = Dx^{a} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{2}^{a} = \\ny{2}^{a}_1 \\end{dmath*}\n   \\begin{dmath*}   3 \\ny{2}^{a}_1 = \\cdb{xDxterm12.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{3}^{a} = \\ny{3}^{a}_1 + \\ny{3}^{a}_2 \\end{dmath*}\n   \\begin{dmath*} -12 \\ny{3}^{a}_1 = \\cdb{xDxterm13.102} \\end{dmath*}\n   \\begin{dmath*} -24 \\ny{3}^{a}_2 = \\cdb{xDxterm22.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{4}^{a} = \\ny{4}^{a}_1 + \\ny{4}^{a}_2 + \\ny{4}^{a}_3 \\end{dmath*}\n   \\begin{dmath*} -180 \\ny{4}^{a}_1 = \\cdb{xDxterm14.102} \\end{dmath*}\n   \\begin{dmath*} -720 \\ny{4}^{a}_2 = \\cdb{xDxterm23.102} \\end{dmath*}\n   \\begin{dmath*} -720 \\ny{4}^{a}_3 = \\cdb{xDxterm32.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\ny{5}^{a} = \\ny{5}^{a}_1 + \\ny{5}^{a}_2 + \\ny{5}^{a}_3 + \\ny{5}^{a}_4 \\end{dmath*}\n   \\begin{dmath*}  -360 \\ny{5}^{a}_1 = \\cdb{xDxterm15.102} \\end{dmath*}\n   \\begin{dmath*} -2160 \\ny{5}^{a}_2 = \\cdb{xDxterm24.102} \\end{dmath*}\n   \\begin{dmath*} -1080 \\ny{5}^{a}_3 = \\cdb{xDxterm33.102} \\end{dmath*}\n   \\begin{dmath*}  -360 \\ny{5}^{a}_4 = \\cdb{xDxterm42.102} \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "27194071935608bb07d05ebef7121aa0c2f61b44", "size": 17867, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/summary.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/summary.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/summary.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5064655172, "max_line_length": 115, "alphanum_fraction": 0.5028264398, "num_tokens": 7349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.43047157132719494}}
{"text": "\\begin{intro}\n  In this section, we develop error estimates of the following type\n  \\begin{verse}\n    If the size of mesh cells converges to zero, then the difference\n    between the true solution and the finite element solution\n    converges to zero with a certain order.\n  \\end{verse}\n  They are thus a prediction, that the solutions actually converge,\n  and they measure the asymptotic convergence rate. They do contain\n  unknown constants, such that they are no prediction of the error on\n  a given mesh.\n\n  The theory in this chapter is about bilinear forms which are bounded\n  and elliptic on a subspace $V \\subset H^1(\\domain)$ determined by\n  boundary conditions. We will choose $V = H^1_0(\\domain)$, even if\n  more general boundary conditions are possible. It is a good approach\n  to think of the Dirichlet problem for the Laplacian, even if we\n  allow for somewhat more general equations.\n\\end{intro}\n\n\\subsection{Approximation of Sobolev spaces by finite elements}\n\n\\begin{Lemma*}{poincare}{Poincaré inequality}\n  Let $\\domain$ be a bounded Lipschitz domain. For any function\n  $u\\in H^1(\\domain)$ define\n  \\begin{gather}\n    \\overline u = \\frac1{\\abs{\\domain}} \\int_\\domain u(\\vx) \\dvx,\n  \\end{gather}\n  where $\\abs{\\domain}$ denotes the measure of $\\domain$. There exists\n  a constant $c$ depending on the domain only, such that each of the\n  following inequalities hold:\n  \\begin{align}\n    \\norm{u-\\overline u}_{L^2(\\domain)} &\\le c \\norm{\\nabla u}_{L^2(\\domain)}\\\\\n    \\norm{u}_{L^2(\\domain)}^2 &\\le c \\Bigl(\\norm{\\nabla u}_{L^2(\\domain)}^2 + \\overline u^2\\Bigr)\n  \\end{align}\n\\end{Lemma*}\n\n\\begin{proof}\n  The proof exceeds the tools we have developed in this class. The\n  proof in \\cite[Section 7.8]{GilbargTrudinger98} seems elementary and\n  direct, but is technical and requires star-shaped domains. The proof\n  in \\cite[Section 5.8.1]{Evans98} is more elegant, but it uses\n  compact embedding and is indirect, such that the constant cannot be\n  determined.\n\\end{proof}\n\n\\begin{Lemma*}{bramble-hilbert}{Bramble-Hilbert}\n  Let $\\cell\\subset \\R^d$ be a domain with Lipschitz boundary and let\n  $s(.)$ be a bounded sublinear functional on $H^{k+1}(\\cell)$ with\n  the property\n  \\begin{gather}\n    s(p) = 0 \\qquad\\forall p\\in \\P_k.\n  \\end{gather}\n  Then, there exists a constant $c$ only dependent on $\\cell$ such that\n  \\begin{gather}\n    \\abs{s(v)} \\le c \\snorm{v}_{k+1,\\cell}.\n  \\end{gather}\n\\end{Lemma*}\n\n\\begin{proof}\n  Since $s(\\cdot)$ is sublinear and vanishes on $\\P_k$, we have for\n  $v\\in H^{k+1}(\\cell)$:\n  \\begin{gather}\n    \\label{eq:bramble-hilbert-1}\n    \\abs{s(v)} \\le \\abs{s(v+p)} + \\abs{s(p)} = \\abs{s(v+p)}\n    \\qquad\\forall p\\in\\P_k.\n  \\end{gather}\n  We will construct a polynomial, such that\n  \\begin{gather}\n    \\label{eq:bramble-hilbert-2}\n    \\overline{\\d^\\alpha(v+p)}\n    = \\frac1{\\abs{\\cell}}\\int_\\cell \\d^\\alpha (v+p) \\dx = 0\n    \\qquad\\forall \\abs{\\alpha} \\le k,\n  \\end{gather}\n  that is, the sum $v+p$ and all its derivatives up to order $k$ are\n  mean-value free. Thus, by recursive application of Poincaré\n  inequality, we get for $\\abs{\\alpha}\\le k$\n  \\begin{alignat*}2\n    \\norm{v+p}_{L^2(\\cell)}^2\n    &\\le c \\left[ \\norm{\\nabla(v+p)}_{L^2(\\cell)}^2 + \\overline{v+p}^2\\right]\n      && \\le c \\snorm{v+p}_{1;\\cell}^2\\\\\n    \\norm{\\d^\\alpha(v+p)}_{L^2(\\cell)}^2,\n    &\\le c \\left[ \\norm{\\nabla\\d^\\alpha(v+p)}_{L^2(\\cell)}^2\n      + \\overline{\\d^\\alpha(v+p)}^2\\right]\n      && \\le c \\snorm{v+p}_{\\abs{\\alpha}+1;\\cell}^2,\n  \\end{alignat*}\n  such that $\\norm{v+p}_{k+1;\\cell} \\le \\snorm{v+p}_{k+1;\\cell}$.\n  Furthermore, since $p\\in\\P_k$\n  \\begin{gather*}\n    \\norm{\\d^\\alpha(v+p)}_{L^2(\\cell)} = \\norm{\\d^\\alpha v}_{L^2(\\cell)}\n    \\qquad\\forall \\abs{\\alpha} = k+1.\n  \\end{gather*}\n  Combining with~\\eqref{eq:bramble-hilbert-1}, we obtain\n  \\begin{gather*}\n    \\abs{s(v)} \\le c \\snorm{v+p}_{k+1;\\cell} \\le c \\snorm{v}_{k+1;\\cell}.\n  \\end{gather*}\n  It remains to construct the polynomial $p$ with the desired\n  properties. To this end, we note that for two multi-indices $\\alpha$\n  and $\\beta$ holds that $\\d^\\alpha \\vx^\\beta =0$ as soon as\n  $\\alpha_i>\\beta_i$ for some index $i$. Let\n  \\begin{gather*}\n    p(\\vx) = \\sum_{\\abs{\\beta}\\le k} a_\\beta \\vx^\\beta.\n  \\end{gather*}\n  Then, for any $\\abs{\\alpha} = k$ we get\n  \\begin{gather*}\n    \\d^\\alpha p(\\vx) = \\alpha! \\,\\delta_{\\alpha\\beta},\n  \\end{gather*}\n  where $\\alpha! = \\alpha_1!\\alpha_2!\\dots\\alpha_d!$. Thus, we can use\n  condition~\\eqref{eq:bramble-hilbert-2} to fix the coefficients\n  $a_\\beta$ to\n  \\begin{gather*}\n    a_\\beta = \\frac1{\\beta!\\,\\abs{\\cell}} \\int_\\cell \\d^\\beta v\\dx\n    \\qquad \\abs{\\beta} = k.\n  \\end{gather*}\n  Thus, we have decomposed $p = \\tilde p_k + p_{k-1}$, where\n  $\\tilde p_k$ is known and $p_{k-1}\\in \\P_{k-1}$. Thus, we can repeat\n  the process determining the coefficients of highest order in\n  $p_{k-1}$,\n  \\begin{gather*}\n    a_\\beta = \\frac1{\\beta!\\,\\abs{\\cell}} \\int_\\cell \\d^\\beta (v-\\tilde p_k)\\dx\n    \\qquad \\abs{\\beta} = k-1.\n  \\end{gather*}\n  Recursion down to $k=0$ yields the polynomial $p$ with the desired property.\n\\end{proof}\n\n\\begin{Corollary}{b-h-projector}\n  Let $\\Pi\\colon H^{k+1}(\\cell) \\to \\P_k$ be a continuous, linear\n  projector. For any $m\\le k$ there exists a constant $c$ such that\n  \\begin{gather}\n    \\norm{u-\\Pi u}_{m,\\cell} \\le c \\snorm{u}_{k+1,\\cell}.\n  \\end{gather}\n\\end{Corollary}\n\n\\begin{Definition}{mesh-family}\n  Let $\\{\\mesh_h\\}$ for $h>0$ be a family of meshes parametrized by\n  the parameter\n  \\begin{gather}\n    h = \\max_{\\cell\\in\\mesh_h} h_\\cell,\n  \\end{gather}\n  where $h_\\cell$ is the characteristic length from the discussion of\n  mappings, for instance the diameter of $\\cell$. Such a family is\n  called \\define{shape regular}, if the constants $M_\\cell$,\n  $m_\\cell$, $d_\\cell$, and $D_\\cell$ in the scaling lemma\n  can be chosen independent of the cell $\\cell\\in\\mesh_h$ and of\n  $h>0$. The family is called \\define{quasi-uniform}, if in addition\n  there is a positive constant independent of $h$ such that\n  \\begin{gather}\n    h \\le c \\min_{\\cell\\in\\mesh_h} h_\\cell.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Definition}{nodal-interpolation}\n  Let $V$ be a function space on $\\domain$, and let\n  $V_h = V_{\\mesh_h}$ be a finite element space on the mesh $\\mesh_h$\n  on $\\domain$ with node functionals $\\nodal_i$ and dual basis $p_i$,\n  where $i=1,\\dots,n_h$. We define the \\define{nodal interpolation}\n  operator by\n  \\begin{gather}\n    \\begin{split}\n      I_h\\colon V&\\to V_h\\\\\n      v &\\mapsto \\sum \\nodal_i(v)p_i.\n    \\end{split}\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma}{nodal-interpolation}\n  The nodal interpolation operator $I_h$ is a projector. It is\n  continuous on $H^2(\\domain)$ if the dimension is $d=2,3$ and the\n  node functionals are defined as Lagrange interpolation.\n\\end{Lemma}\n\n\\begin{Definition}{broken-sobolev-norm}\n  On a mesh $\\mesh_h$, we define the \\define{broken Sobolev norm} and\n  seminorm by\n  \\begin{gather}\n    \\begin{split}\n      \\norm{u}_{k;h}^2 &= \\sum_{\\cell\\in\\mesh_h} \\norm{u}_{k;\\cell}^2\\\\\n      \\snorm{u}_{k;h}^2 &= \\sum_{\\cell\\in\\mesh_h} \\snorm{u}_{k;\\cell}^2\n    \\end{split}\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Theorem}{fe-interpolation}\n  Let $\\{\\mesh_h\\}$ be a shape regular family of meshes.\n  Let the finite element spaces $V_h = V_{\\mesh_h}$. Let the nodal\n  interpolation operator $I_h$ be surjective onto $\\P_k$ on every cell\n  $\\cell\\in\\mesh_h$ and continuous on $H^{k+1}(\\domain)$. Then, there\n  is a constant $c$ such that for any $u\\in H^{k+1}(\\domain)$ and\n  $m\\le k+1$ there holds\n  \\begin{gather}\n    \\label{eq:fe-interpolation}\n    \\norm{u-I_h u}_{m;h} \\le c h^{k+1-m} \\snorm{u}_{k+1;h}.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  We have by definition\n  \\begin{gather*}\n    \\snorm{u-I_h u}_{m;h} = \\sum_{\\cell\\in\\mesh_h} \\snorm{u-I_h u}_{m;\\cell}.\n  \\end{gather*}\n  Using the scaling lemma, we get\n  \\begin{gather*}\n    \\snorm{u-I_h u}_{m;\\cell}\n    \\le c h_\\cell^{\\nicefrac d2-m} \\snorm{\\refu - \\widehat{I_hu}}.\n  \\end{gather*}\n  On the reference cell, we use the Bramble-Hilbert lemma, more\n  precisely, \\slideref{Corollary}{b-h-projector} to obtain\n  \\begin{gather*}\n    \\snorm{\\refu - \\widehat{I_hu}} \\le c \\snorm{\\refu}_{k+1;\\refcell}.\n  \\end{gather*}\n  Scaling back yields\n  \\begin{gather*}\n    \\snorm{\\refu}_{k+1;\\refcell}\n    \\le c h_\\cell^{k+1-\\nicefrac d2} \\snorm{u}_{k+1;\\cell}.\n  \\end{gather*}\n  Combining, we obtain\n  \\begin{gather*}\n    \\snorm{u-I_h u}_{m;\\cell} \\le c h_\\cell^{k+1-\\nicefrac d2 - m +\n      \\nicefrac d2}\\snorm{u}_{k+1;\\cell}.\n  \\end{gather*}\n  Summing up and pulling the maximum of $h_\\cell^{k+1-m}$ out of the\n  sum yields the result for $h_\\cell \\le 1$.\n\\end{proof}\n\n\\begin{remark}\n  Strictly speaking, we have only proven the result for $h_T \\le\n  1$.\n  But then, if $\\diam\\domain = 1$, this condition is always\n  true. Therefore, by rescaling the domain before computing, the\n  estimate holds in general.\n\\end{remark}\n\n\\begin{Corollary}{fe-approximation}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $V = H^1_0(\\domain)$ and let the finite element space $V_h$ be\n  defined on a shape-regular family of meshes $\\{\\mesh_h\\}$, such that\n  the interpolation estimate~\\eqref{eq:fe-interpolation} holds. If\n  furthermore the solution $u\\in H^{k+1}(\\domain)$, the error of the\n  finite element solution $u_h\\in V_h \\subset V$ admits the estimate\n  \\begin{gather}\n    \\norm{u-u_h}_{1;h} \\le c h^{k} \\snorm{u}_{k+1;h}.\n  \\end{gather}  \n\\end{Corollary}\n\n\\begin{intro}\n  For 2nd order elliptic problems, we have now derived estimates of\n  the $H^1$-norm of the error under the assumption that the solution\n  exhibits further regularity. Now, let us drop this assumptionfor an\n  assumption on the boundary condition only, to obtain a qualitative\n  convergence result.\n\\end{intro}\n\n\\begin{Theorem}{fe-convergence}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $V = H^1_0(\\domain)$ and let the finite element space $V_h$ be\n  defined on a shape-regular family of meshes $\\{\\mesh_h\\}$, such that\n  the interpolation estimate~\\eqref{eq:fe-interpolation} holds. Let\n  $u\\in V$ and $u_h\\in V_h$ be solutions to the exact and the finite\n  element versions of a 2nd order boundary value problem. Then,\n  \\begin{gather}\n    \\lim_{h\\searrow 0} \\norm{u-u_h}_{1;\\domain} = 0.\n  \\end{gather}\n\\end{Theorem}\n\n\\subsection{Estimates of stronger norms}\n\n\\begin{intro}\n  So far, we have seen error estimates in a ``natural norm'' defined\n  as a norm such that the Lax-Milgram lemma holds for a given bilinear\n  form $a(.,.)$. In this subsection, we now consider the question of\n  estimates in stronger norms, such that the bilinear form is not\n  elliptic with respect to this norm.\n\\end{intro}\n\n\\begin{Definition}{stronger-norm}\n  Let $\\norm{\\cdot}_X$ and $\\norm{\\cdot}_Y$ be norms on a vector space\n  $V$. We call $\\norm{\\cdot}_X$ a \\define{stronger norm} than\n  $\\norm{\\cdot}_Y$, if there is a constant $c$ such that for all\n  $v\\in V$:\n  \\begin{gather}\n    \\norm{v}_Y \\le c \\norm{v}_X.\n  \\end{gather}\n  In this case, $\\norm{\\cdot}_Y$ is called the \\define{weaker\n    norm}. If a converse inequality holds, the norms are called\n  \\define{equivalent}.\n\\end{Definition}\n\n\\begin{example}\n  For a bounded domain $\\domain$, the norms $\\norm{\\cdot}_{k+1}$ and\n  $\\norm{\\cdot}_{k}$ are both defined on $V = H^1_0(\\domain)$. By the\n  Sobolev embedding theorem, there is a constant $c$ such that for any\n  $v\\in V$\n  \\begin{gather*}\n    \\norm{v}_{k} \\le c \\norm{v}_{k+1}\n  \\end{gather*}\n\\end{example}\n\n\\begin{Lemma*}{inverse-estimate}{Inverse estimate}\n  Let $\\cell$ be a mesh cell of size $h_\\cell$. Then, there is a\n  constant only depending on $k$ and the constants of the scaling\n  lemma, such that for every $u\\in \\P_k$ there holds\n  \\begin{gather}\n    \\norm{u}_{1;\\cell} \\le c h_T^{-1} \\norm{u}_{0;\\cell}.\n  \\end{gather}\n\\end{Lemma*}\n\n\\begin{Theorem}{h2-error}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $V\\subset H^1(\\domain)$ and let $\\{\\mesh_h\\}$ be a family of\n  quasi-uniform meshes with finite element spaces $V_h \\subset V$\n  containing the space $\\P_k$ with $k\\ge 2$ on each mesh cell. If\n  furthermore the solution $u\\in H^{k+1}(\\domain)$, the error between\n  the exact and the finite element solution to a uniquely solvable\n  elliptic boundary value problem, admits the estimate\n  \\begin{gather}\n    \\norm{u-u_h}_{2;h} \\le c h^{k-1} \\snorm{u}_{k+1;h}.\n  \\end{gather}  \n\\end{Theorem}\n\n\\begin{proof}\n  We cannot apply Céa's lemma directly, since the bilinear form is not\n  elliptic with respect to the broken $H^2$-inner product on the space\n  $H^1(\\domain)$. On the other hand, the error is not polynomial, such\n  that we cannot apply the inverse estimate to it. Instead, we use\n  triangle inequality\n  \\begin{gather*}\n    \\norm{u-u_h}_{2;h} \\le \\norm{u-I_h u}_{2;h} + \\norm{I_h u-u_h}_{2;h},\n  \\end{gather*}\n  and observe, that we already have the desired estimate for the first\n  term. For the second, we estimate by inverse estimate on each cell\n  \\begin{gather*}\n    \\min_{\\cell\\in\\mesh_h} h_T \\norm{I_h u-u_h}_{2;h}\n    \\norm{I_hu-u_h}_{1} \\le c \\norm{I_h u-u_h}_{1}^2,\n  \\end{gather*}\n  and\n  \\begin{align*}\n    \\norm{I_h u-u_h}_{1}^2\n    & \\le \\frac c\\gamma a(I_h u-u_h, I_h u-u_h)\n    \\\\& = \\frac c\\gamma a(I_h u-u, I_h u-u_h)\n    \\\\& \\le \\frac{cM}{\\gamma}\\norm{I_h u-u}_{1} \\norm{I_h u-u_h}_{1}\n    \\\\& \\le C h^{k} \\snorm{u}_{k+1;h} \\norm{I_h u-u_h}_{1},\n  \\end{align*}\n  where we have used Galerkin orthogonality and the interpolation\n  estimate. Combining the two and using the quasi-uniformity, we\n  obtain the result of the theorem.\n\\end{proof}\n\n\\subsection{Estimates of weaker norms and linear functionals}\n\n\\begin{intro}\n  Deriving optimal error estimates in the $L^2$-norm cannot be\n  achieved by the same technique as used for the $H^2$-norm, as the\n  following simple argument shows: using triangle inequality, we obtain\n  \\begin{gather*}\n    \\norm{u-u_h}_{L^2} \\le \\norm{u-I_h u}_{L^2} + \\norm{I_h u-u_h}_{L^2},\n  \\end{gather*}\n  we obtain that the first term is of order $h^{k+1}$. Thus, for an\n  optimal error estimate, we require that the second term be of order\n  $h^{k+1}$ as well. We need a replacement of the inverse estimate,\n  which gains an order of $h$ instead of loosing it. This is Poincaré\n  inequality, but it requires an almost mean-value free function. And\n  since $I_h u$ is not the interpolant of $u_h$, we cannot guarantee a\n  small mean value of the difference on each mesh cell.\n\n  To the rescue comes a ``duality argument'' known as Aubin-Nitsche\n  trick, which we introduce now.\n\\end{intro}\n\n\\begin{Definition}{dual-problem}\n  Let the weak form of a boundary value problem on the domain\n  $\\domain$ be defined as: find $u\\in V$ such that\n  \\begin{gather*}\n    a(u,v) = f(v) \\qquad\\forall v\\in V.\n  \\end{gather*}\n  Then, the \\define{dual problem}, also called \\define{adjoint\n    problem}, with right hand side $g\\in V^*$ is: find $u^* \\in V$ such\n  that\n  \\begin{gather*}\n    a(v,u^*) = g(v) \\qquad\\forall v\\in V.\n  \\end{gather*}\n\\end{Definition}\n\n\\begin{Lemma}{poisson-dual}\n  The adjoint problem of the Dirichlet boundary value problem for\n  Poisson's equation is equal to the dual problem, that is, for\n  $u\\in H^1_0(\\domain)$, the two statements\n  \\begin{xalignat*}2\n    a(u,v) &= f(v) &\\forall v&\\in V,\\\\\n    a(v,u) &= f(v) &\\forall v&\\in V,\n  \\end{xalignat*}\n  are equivalent.\n\\end{Lemma}\n\n\\begin{Assumption*}{elliptic-regularity}{Elliptic regularity}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $H^1_0(\\domain)$. We say that a boundary value problem has\n  \\define{elliptic regularity}, if for any $g\\in L^2(\\domain)$ the\n  solution $u$ is in $H^2(\\domain)$. In other words, there is a\n  constant $c$ independent of $g$, such that\n  \\begin{gather}\n    \\norm{u}_{2;\\domain} \\le c \\norm{g}_{0;\\domain}.\n  \\end{gather}\n\\end{Assumption*}\n\n\\begin{example}\n  By \\slideref{Remark}{classical-convex}, a second order PDE with\n  coefficients $a_{ij}\\in C^{0,1}(\\overline\\domain)$ and\n  $b_i, c\\in L^\\infty(\\domain)$ has elliptic regularity. The same\n  holds by integration by parts for ints adjoint.\n\n  The same boundary value problem does not have elliptic regularity,\n  if the domain has a nonconvex corner, since we have corner\n  singularity functions which are not in $H^2(\\domain)$, and we can\n  construct a right hand side $g\\in L^2(\\domain)$, which produces such\n  singularities.\n\\end{example}\n\n\\begin{Theorem}{fe-l2}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $V = H^1_0(\\domain)$ and let the finite element space $V_h$ be\n  defined on a shape-regular family of meshes $\\{\\mesh_h\\}$, such that\n  the interpolation estimate~\\eqref{eq:fe-interpolation} holds. If\n  furthermore the solution $u\\in H^{k+1}(\\domain)$ and the dual\n  problem has \\putindex{elliptic regularity}, the error of the finite\n  element solution $u_h\\in V_h \\subset V$ admits the estimate\n  \\begin{gather}\n    \\norm{u-u_h}_{0} \\le c h^{k+1} \\snorm{u}_{k+1;h}.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{Corollary}{fe-functional}\n  Under the assumptions of \\slideref{Theorem}{fe-l2}, let $J(.)$ be a\n  bounded linear functional on $L^2(\\domain)$. Then,\n  \\begin{gather}\n    \\abs{J(u)-J(u_h)}_{0} \\le c h^{k+1} \\snorm{u}_{k+1;h}.\n  \\end{gather}\n\\end{Corollary}\n\n\\subsection{Green's function and maximum norm estimates}\n\n\\begin{intro}\n  In this section, we will introduce the basic concepts needed for\n  pointwise error estimation. They heavily rely on Green's function,\n  which is useful for a general understanding of the solution\n  structure as well.\n\\end{intro}\n\n\\begin{Definition}{greens-function}\n  For a differential equation $Lu = f$ in $\\domain$ with boundary\n  conditions $u=0$ on the boundary $\\d\\domain$, we define\n  \\define{Green's function} $G(\\vy,\\vx)$ associated to the point\n  $\\vy\\in\\domain$ as solution to the problem\n  \\begin{gather}\n    \\begin{aligned}\n      L G(\\vy,\\vx) &= \\delta(\\vx-\\vy)&\\qquad\\forall \\vx&\\in\\domain,\\\\\n      G(\\vy,\\vx) &= 0&\\qquad\\forall \\vx&\\in\\d\\domain.\n    \\end{aligned}\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Theorem}{greens-function-rd}\n  Green's function for Poisson's equation on the whole space\n  $\\domain=\\R^d$ is\n  \\begin{gather}\n    G(\\vy,\\vx) =\n    \\begin{cases}\n      - \\frac1{2\\pi} \\log \\abs{\\vx-\\vy} & d=2\\\\\n      \\frac1{d(d-2)\\abs{B_1(0)}} \\frac1{\\abs{\\vx-\\vy}^{d-2}} & d\\ge3.\n    \\end{cases}\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  See~\\cite[Section 2.2]{Evans98}.\n\\end{proof}\n\n\\begin{Lemma}{greens-function-domain}\n  Let $\\domain\\subset \\R^d$ be a bounded domain. Then, Green's\n  function associated to a point $\\vy\\in\\domain$ for a linear\n  differential operator $L$ on $\\domain$ is obtained as the sum\n  \\begin{gather}\n    G(\\vy,\\vx) = G_\\infty(\\vy,\\vx) - G_0(\\vy,\\vx),\n  \\end{gather}\n  where $G_\\infty(\\vy,\\vx)$ is Green's function for the whole space\n  and $G_0(\\vy,\\vx)$ solves $LG_0(\\vy,\\vx)=0$ with boundary values\n  $G_\\infty(\\vy,\\vx)$. If the domain is convex, then,\n  $G_0(\\vy,.)\\in H^2(\\domain)$ for any interior point $\\vy$.\n\\end{Lemma}\n\n\\begin{Theorem}{greens-function-representation}\n  Let $f\\in C(\\overline\\domain)$ and let $\\domain$ be such that the\n  solution to\n  \\begin{gather}\n    \\begin{aligned}\n      Lu &= f &\\qquad\\text{in }&\\domain,\\\\\n      u &= 0 &\\text{on }&\\d\\domain,\n    \\end{aligned}\n  \\end{gather}\n  is in $C^2(\\overline\\domain)$. Then,\n  \\begin{gather}\n    u(\\vx) = \\int_\\domain f(\\vy)G(\\vy,\\vx)\\dvy.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  See \\cite[Section 2.2]{Evans98}\n\\end{proof}\n\n\\begin{Theorem}{linfty-error}\n  Let $a(.,.)$ be a bounded and elliptic bilinear form on\n  $V = H^1_0(\\domain)$ on a bounded, convex domain $\\domain\\subset \\R^2$. Let the\n  finite element space $V_h$ be defined on a quasi-uniform family of\n  meshes $\\{\\mesh_h\\}$ with local spaces $\\P_1$ or $\\Q_1$. If\n  furthermore the solution $u\\in W^{2,\\infty}(\\domain)$, the error of\n  the finite element solution $u_h\\in V_h \\subset V$ admits the\n  estimate\n  \\begin{gather}\n    \\norm{u-u_h}_{\\infty} \\le c h^{2} (1+\\abs{\\log h}) \\snorm{u}_{2,\\infty}.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  The proof relies on solving a dual problem for the error in a single\n  point. The solution is Green's function for the adjoint equation,\n  which is very irregular at the point of interest. Then, complicated\n  analysis is needed to generate useful approximation estimates in\n  spite of the singularity. Details can be found\n  in~\\cite{SchatzWahlbin77,RannacherScott82}.\n\\end{proof}\n\n\n\\begin{remark}\n  This estimate extends to $\\domain\\in\\R^d$ for $d\\ge 3$ and to higher\n  polynomial degrees \\emph{without} the logarithmic factor. The\n  regularity assumptions are quite high then.\n\\end{remark}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End: \n", "meta": {"hexsha": "a5f2ccacc9cf27d94e4762a2a6d047e7268246ab", "size": 20687, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fem/fem-apriori.tex", "max_stars_repo_name": "ahumanita/notes", "max_stars_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "fem/fem-apriori.tex", "max_issues_repo_name": "ahumanita/notes", "max_issues_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fem/fem-apriori.tex", "max_forks_repo_name": "ahumanita/notes", "max_forks_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.167896679, "max_line_length": 97, "alphanum_fraction": 0.6746749166, "num_tokens": 7043, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7401743620390162, "lm_q1q2_score": 0.430265644268963}}
{"text": "% $Id: 785a41386b8ef8716fb66a73bb45d2dfa3eaee4f $\n\n\\section{Equational Reasoning with Rigid Unit Superposition}\n\\label{sec:super}\n\nThere are many ways of integrating equational reasoning in tableau\nmethods~\\cite{DB75,LS02,BR15,DV96}. Because our prover does not rely on clausal\nforms, but on arbitrary formulas with quantifiers occurring deep inside\nbranches, we deal with rigid variables, i.e. variables that can be instantiated\nonly once. The problem we want to solve, rigid E-unification modulo rewrite\nrules, is the following. Assume a set of equations $E$, containing rigid\nvariables, a rewrite system $\\mathcal{RE}$, and target terms $s$ and $t$. We\nwant a substitution $\\sigma$ such that\n$\\bigwedge_{e \\in E} e\\sigma \\vdash s\\sigma =_\\mathcal{E} t\\sigma$. Such a\nsubstitution is a solution to the rigid E-unification problem.\n\nWe propose here an approach based on superposition with rigid variables, as in\nprevious work by Degtyarev and Voronkov~\\cite{DV96} and earlier work on rigid\nparamodulation~\\cite{DAP00}, but with significant differences. First, in order\nto avoid constraint solving, we do not use basic superposition nor\nconstraints. Second, we introduce a merging rule, which factors together\nintermediate (dis)equations that are alpha-equivalent: with multiple instances\nof some of the quantified formulas (amplification), it becomes important not to\nduplicate work. In this aspect, our calculus is quite close to labeled unit\nsuperposition~\\cite{KS10} when using sets as labels. Third, unlike rigid\nparamodulation, we use a term ordering to orient the equations.\n\n\\subsection{Preliminary Definitions}\n\nWe write $ \\clauseWithSubst{ s \\approx t }{ \\Sigma}$ (resp.\n$\\clauseWithSubst{ s \\not\\approx t }{ \\Sigma}$), the unit clause that contains\nexactly one equation (resp.~disequation) under hypothesis $\\Sigma$ (which is a\nset of substitutions). We write $\\clauseWithSubst{\\emptyset}{\\Sigma}$ for the\nempty clause under hypothesis $\\Sigma$. We define $\\renameVars{e}$, where $e$\nis a (dis)equation, as follows: let $\\sigma$ map every rigid variable of $e$ to\na fresh non-rigid variable, then\n$\\renameVars{e} = \\clauseWithSubst{ e\\sigma }{ \\{ \\sigma \\} }$. For example,\n$\\renameVars{p(X)\\approx a}$ is $\\clauseWithSubst{ p(Y)\\approx a}{ \\{ X\\mapsto\nY\\} }$. The E-unification problem $E \\vdash s\\approx t$ can be solved by proving\n$\\clauseWithSubst{\\emptyset }{ \\Sigma}$ from\n$\\{ \\renameVars{e} \\}_{ e \\in E } \\cup \\{ \\renameVars{ s \\not\\approx t } \\}$,\nwhere $\\Sigma$ contains the solutions. The meaning of $s \\approx t | \\Sigma$ is\nthat for every $\\sigma \\in \\Sigma$, $s \\approx t$ is provable using the\nsubstitution $\\sigma$ for the metavariables.\n\nAs can be noticed, we keep a set of substitutions, rather than unit clauses\npaired with individual substitutions, in order to avoid duplicating the work for\nalpha-equivalent clauses. Indeed, because of amplification, many instances of a\ngiven (dis)equation might be present in a branch of the tableau. It would be\ninefficient to repeat the same inference steps with each variant of the axioms.\nBecause we apply $\\renameVars{e}$ on every initial $e$, clauses do not share any\nvariable, except in their attached sets of substitutions.\n\nTo perform an inference step between two unit (dis)equations, we merge their\nsets of substitutions. Merging $\\Sigma$ and $\\Sigma'$, intuitively, means\ncomputing $\\{ \\textsf{merge}(\\sigma,\\sigma') ~|~ \\sigma \\in \\Sigma, \\sigma'\\in\n\\Sigma' \\}$ for every pair $(\\sigma,\\sigma')$ of compatible substitutions. For\nexample, the resolution step between $p(x,x)| \\{ X \\mapsto a \\}$ and\n$\\lnot p(y,b)| \\{ X \\mapsto y \\}$ is not possible, because the result would need\nto map $X$ to $a$ and $b$, which is impossible because $X$ is rigid.\nCompatibility relies on a partial ordering $\\leq$, such that\n$\\sigma \\leq \\sigma'$ means that $\\sigma$ is less general than $\\sigma'$.\n\nConsidering a substitution as a function from variables to terms, we define the\ndomain of a substitution $\\sigma$ as the set of variables that have a\nnon-trivial binding in $\\sigma$.\\footnote{A trivial binding maps a variable to\nitself.} The co-domain of a substitution is the set of variables occurring in\nterms in the image of the domain of the substitution. In the following, we will\nconsider idempotent substitutions, i.e. substitutions for which the domain and\nco-domain have an empty intersection.\n\nThe composition of two substitutions $\\sigma$ and $\\sigma'$, denoted by\n$\\sigma \\circ \\sigma'$, is said to be well-defined if and only if the domains of\n$\\sigma$ and $\\sigma'$ have no intersection. In this case,\n$\\sigma \\circ \\sigma' \\triangleq \\left\\{ x \\mapsto (x\\sigma)\\sigma' | x \\in\n\\text{domain}(\\sigma) \\right\\}$. This definition extends to sets of\nsubstitutions: $\\Sigma \\circ \\sigma' \\triangleq \\left\\{ \\sigma \\circ \\sigma' |\n\\sigma \\in \\Sigma \\right\\}$. We then have $\\sigma \\leq \\sigma'$ if and only if\n$\\exists \\sigma''.~ \\sigma \\circ \\sigma'' = \\sigma'$. This notion also extends\nto sets of substitutions: $\\smash{ \\Sigma \\leq \\Sigma' }$ if and only if\n$\\smash{ \\forall \\sigma' \\in \\Sigma'.~ \\exists \\sigma \\in \\Sigma. \\sigma \\leq\n\\sigma' }$. The merging of two substitutions $\\sigma \\uparrow \\sigma'$ is the\nsupremum of $\\{\\sigma,\\sigma'\\}$ for the order $\\leq$, if it exists, or $\\bot$\notherwise. The merging of sets of substitutions is\n$\\Sigma \\uparrow \\Sigma' \\triangleq \\left\\{ \\sigma \\uparrow \\sigma' ~|~ \\sigma\n\\in \\Sigma, \\sigma' \\in \\Sigma' \\right., \\sigma \\uparrow \\sigma' \\not= \\bot\n\\}$. An inference rule is said to be successful if the merging of the premises'\nsubstitution sets is non-empty.\n\n\\subsection{Inference System}\n\nIn Fig.~\\ref{fig:unit-sup-rules}, we present the rules for unit superposition\nwith rigid variables. We adopt notations and names from Schulz's paper on\nE~\\cite{SS02}. A single bar denotes an inference, i.e. we add the result to the\nsaturation set, whereas a double bar is a simplification in which the premises\nare replaced by the conclusion(s). The relation $\\prec$ is a reduction ordering,\nused to orient equations and restrict inferences, thus pruning the search space.\nTypically, $\\prec$ is one of RPO or KBO. The rules of\nFig.~\\ref{fig:unit-sup-rules} work as described below:\n\n\\begin{description}\n\\item[ER] is equality resolution, where a disequation\n$\\clauseWithSubst{s \\not\\approx t}\\Sigma$ is solved by syntactically unifying\n$s$ and $t$ with $\\sigma$, if $\\sigma$ is compatible with $\\Sigma$.\n\\item[SN] is superposition into negative literals. A subterm of $u$ is rewritten\nusing $s \\approx t$ after unifying it with $s$ by $\\sigma$. The rewriting is\ndone only if $s\\sigma \\not\\preceq t\\sigma$, a sufficient (but not necessary)\ncondition for a ground instance of $s\\sigma \\approx t\\sigma$ to be oriented\nleft-to-right.\n\\item[SP] is similar to SN, but superposes into a positive literal.\n\\item[TD1] deletes trivial equations that will never contribute to a proof.\n\\item[TD2] deletes clauses with an empty set of substitutions. In practice, we\nonly apply a rule if the conclusion is labeled with a non-empty set of\nsubstitutions.\n\\item[ME] merges two alpha-equivalent clauses into a single clause, by merging\nthe sets of substitutions. This rule is very important in practice, to prevent\nthe search space from exploding due to the duplicates of most formulas.\nSuperposition deals with this explosion by removing duplicates using\nsubsumption, but in our context subsumption is not complete because rigid\nvariables are only proxy for ground terms: even if $C\\sigma \\subseteq D$, the\none ground instance of $C$ might not be compatible with the ground instance of\n$D$.\n\\item[ES] is a restricted form of equality subsumption. The active equation\n$\\clauseWithSubst{ s\\approx t}\\Sigma $ can be used to delete another clause, as\nin E~\\cite{SS02}. However, ES only works if $s$ and $t$ are syntactically equal\nto the corresponding subterms in the subsumed clause $C$. Otherwise, there is no\nguarantee that further instantiations will not make $s\\approx t$ incompatible\nwith $C$. Moreover, $C$ needs not be entirely removed. Only its substitutions\nthat are compatible with $\\Sigma$ are subsumed.\n\\item[RP] is rewriting of positive clauses, which only works for syntactical\nequality, not matching.\n\\item[RN] is the same as RP but for rewriting negative clauses.\n\\end{description}\n\nRule \\textbf{SN} (resp. \\textbf{SP}) generates as many equations (resp.\ndisequations) as there are in the set\n$(\\Sigma \\circ \\sigma'') \\uparrow (\\Sigma' \\circ \\sigma'')$ because all\nsubstitutions may not always be merged. For instance, given\n$f(x) = t | \\{ \\{ X_1 \\mapsto x \\}, \\{ X_2 \\mapsto x \\} \\}$ and\n$f(a) = v | \\{ \\{ X_1 \\mapsto a \\} \\} \\}$, we have to derive two distinct\nnon-mergeable equations $(t = v)\\{ x \\mapsto a \\} | \\{ \\{ X_1 \\mapsto a \\} \\}$\nand $(t = v)\\{ x \\mapsto a \\} | \\{ \\{ X_1 \\mapsto a; X_2 \\mapsto a \\} \\}$.\n\n\\begin{figure}[htb]\n\\begin{center}\n% ER\n\\AXC{$s \\not\\approx t |\\Sigma$}\n\\LL{ER}\n\\RL{if $\\sigma = \\text{mgu}(s, t)$}\n\\UIC{$\\emptyset | \\Sigma \\circ \\sigma $}\\DP\\\\[12pt]\n\n% SN\n\\AXC{$s \\approx t | \\Sigma$}\n\\AXC{$u \\not\\approx v | \\Sigma'$}\n\\LL{SN}\n\\BIC{$\\sigma''(u[p \\leftarrow t] \\not\\approx v) | \\sigma'''$}\\DP\n$\\text{if} \\left\\{ \\begin{array}{l@{\\quad}l}\n\\sigma'' = \\text{mgu}(u_{|p}, s) & u_{|p} \\not\\in V\\\\\n\\sigma''(s) \\not\\preceq \\sigma''(t) & \\sigma''(u) \\not\\preceq \\sigma''(v)\\\\\n\\multicolumn{2}{l}{\n\\sigma''' \\in (\\Sigma \\circ \\sigma'') \\uparrow (\\Sigma' \\circ \\sigma'')}\n\\end{array}\\right.$\\\\[12pt]\n\n% SP\n\\AXC{$s \\approx t | \\Sigma$}\n\\AXC{$u \\approx v | \\Sigma'$}\n\\LL{SP}\n\\BIC{$\\sigma''(u[p \\leftarrow t] \\approx v) | \\sigma'''$}\\DP\n$\\text{if} \\left\\{ \\begin{array}{l@{\\quad}l}\n\\sigma'' = \\text{mgu}(u_{|p}, s) & u_{|p} \\not\\in V\\\\\n\\sigma''(s) \\not\\preceq \\sigma''(t) & \\sigma''(u) \\not\\preceq \\sigma''(v)\\\\\n\\multicolumn{2}{l}{\n\\sigma''' \\in (\\Sigma \\circ \\sigma'') \\uparrow (\\Sigma' \\circ \\sigma'')}\n\\end{array}\\right.$\\\\[12pt]\n\n\\mbox{\n% TD1\n\\AXC{$s \\approx s | \\Sigma $}\n\\LL{TD1}\n\\doubleLine{}\n\\UIC{$\\top$}\\DP\n\n% TD2\n\\AXC{$s \\mathrel{R} t | \\emptyset$}\n\\LL{TD2}\n\\RL{$ R \\in \\{ \\approx, \\not\\approx \\} $}\n\\doubleLine{}\n\\UIC{$\\top$}\n\\DP}\\\\[12pt]\n\n% ME\n\\AXC{$\\rho(u) \\approx \\rho(v) | \\Sigma$}\n\\AXC{$u \\approx v | \\Sigma'$}\n\\LL{ME}\n\\RL{$\\rho \\text{ is a variable renaming}$}\n\\doubleLine{}\n\\BIC{$\\rho(u) \\approx \\rho(v) | \\Sigma \\cup (\\Sigma' \\circ \\rho)$}\\DP\\\\[12pt]\n\n% ES\n\\AXC{$s \\approx t | \\Sigma$}\n\\AXC{$u[p \\leftarrow s] \\approx u[p \\leftarrow t] | \\Sigma' \\cup \\Sigma''$}\n\\LL{ES}\n\\RL{$\n\\text{if} \\left\\{ \\begin{array}{l}\n\\Sigma'' \\not= \\emptyset\\\\\n\\Sigma \\leq \\Sigma''\n\\end{array}\\right.$}\n\\doubleLine{}\n\\BIC{$s\\approx t | \\Sigma \\qquad u[p\\leftarrow s] \\approx u[p \\leftarrow t] |\n\\Sigma'$}\\DP\\\\[12pt]\n\n% RP\n\\AXC{$s \\approx t | \\Sigma$}\n\\AXC{$u \\approx v | \\Sigma'$}\n\\LL{RP}\n\\doubleLine{}\n\\BIC{$s \\approx t | \\Sigma$ \\qquad $u[p \\leftarrow t] \\approx v | \\Sigma'$}\\DP\n$\\text{if} \\left\\{\\begin{array}{l}\nu_{|p} = s\\\\\ns \\succ t\\\\\n\\Sigma \\leq \\Sigma'\\\\\nu \\not\\succeq v ~ \\text{or} ~ p \\neq \\lambda\\\\\n\\end{array}\\right.$\\\\[12pt]\n\n% RN\n\\AXC{$s \\approx t | \\Sigma$}\n\\AXC{$u \\not\\approx v | \\Sigma'$}\n\\LL{RN}\n\\doubleLine{}\n\\BIC{$s \\approx t | \\Sigma$ \\qquad $u[p \\leftarrow t] \\not\\approx v |\n\\Sigma'$}\\DP\n$\\text{if} \\left\\{\\begin{array}{l}\nu_{|p} = s\\\\\ns \\succ t\\\\\n\\Sigma \\leq \\Sigma'\\\\\n\\end{array}\\right.$\n\\caption{The Set of Rules for Unit Rigid Superposition}\n\\label{fig:unit-sup-rules}\n\\end{center}\n\\end{figure}\n\n\\subsection{Rewriting}\n\nRewrite rules can be integrated to the rigid unit superposition easily. In fact,\na rewrite rule $l\\rew{}r$ can be expressed as an equality with a hypothesis set\nconsisting of a single trivial substitution\n$s\\approx{}t|\\{\\text{identity}\\}$. Since the trivial substitution is compatible\nwith every substitution, it will never prevent any inference, thus allowing us\nto use the unit clause as many times as needed to rewrite terms without\naccumulating constraints, particularly using the rules RP and RN, whose side\nconditions are always verified by rewrite rules. Rigid unit superposition\ntherefore provides an algorithm for rigid E-unification modulo rewrite rules.\n\n\\subsection{Main Loop}\n\nOur objective with rigid E-unification is to attempt to close a branch of the\ntableau prover (i.e. a set of Boolean literals set to true). To do so, all\nequational or atomic literals are added to a set of unit clauses to process,\nwith a label $\\Sigma \\triangleq \\{ \\emptyset \\}$. Then, the given-clause\nalgorithm is applied to try and saturate the set. Assuming a fair strategy, this\nwill eventually find a solution (i.e. derive\n$\\clauseWithSubst{\\emptyset}{\\Sigma}$) if there exists one. We refer the\ninterested reader to~\\cite{SS02} for more details.\n\nBecause the whole branch is managed by a single given-clause saturation loop, we\nlook for all solutions susceptible to close the branch at the same time.\nMoreover, this technique is amenable to incrementality, i.e. every time a\n(dis)equation is decided by the SAT solver, we could add it to the saturation\nset and perform a (limited) number of steps of the given-clause algorithm.\n\n\\subsection{Example}\n\nTo illustrate the calculus, we detail a refutation of the following set of\nclauses stemming from set theory, where pair, fst, and snd are the constructor\nand destructors of tuples, $f$ a function on tuples, and $X$ a rigid variable:\n\n\\[\\begin{array}{rcl}\n\\text{pair}(\\text{fst}(x), \\text{snd}(x))) &\\rew& x\\\\\n\\text{fst}(a) &\\approx& \\text{fst}(b)\\\\\np(a) &\\not\\approx& p(\\text{pair}(\\text{fst}(b), X))\\\\\n\\end{array}\\]\n\nBecause the problem is purely equational, the tableau structure is trivial, and\nall the work is done by the rigid superposition procedure as shown in\nFig.~\\ref{fig:unit-sup-proof-example}.\n\n\\begin{figure}[t]\n\\begin{center}\n\\begin{tabular}{clc}\n1 & axiom & $\\text{pair}(\\text{fst}(x), \\text{snd}(x))) \\rew x$\\\\\n\n2 & axiom & $\\text{fst}(a) = \\text{fst}(b)$\\\\\n\n3 & axiom & $p(a) \\not= p(\\text{pair}(\\text{fst}(b), X))$\\\\\n\n4 & \\renameVarsSymb(1) &\n$\\clauseWithSubst\n{ \\text{pair}(\\text{fst}(x), \\text{snd}(x)) \\approx x }\n{ \\{ \\} }$\\\\\n\n5 & \\renameVarsSymb(2) &\n$\\clauseWithSubst\n{ \\text{fst}(a) \\approx \\text{fst}(b) }\n{ \\{ \\} }$\\\\\n\n6 & \\renameVarsSymb(3) &\n$\\clauseWithSubst\n{ f(a) \\not\\approx f(\\text{pair}(\\text{fst}(b), y)) }\n{ \\{ \\mapVar{X}y \\} }$\\\\\n\n\\midrule\n\n7 & RN(5,6) &\n$\\clauseWithSubst\n{ f(a) \\not\\approx f(\\text{pair}(\\text{fst}(a), y)) }\n{ \\{ \\mapVar{X}y \\} }$\\\\\n\n8 & SN(4,7) &\n$\\clauseWithSubst\n{ f(a) \\not\\approx f(a) }\n{ \\{ \\mapVar{X}{\\text{snd}(a)} \\} }$\\\\\n\n9 & ER(8) &\n$\\clauseWithSubst\n{ \\emptyset }\n{ \\{ \\mapVar{X}{\\text{snd}(a)} \\} }$\n\\end{tabular}\n\\caption{Proof of a Set Theory Problem}\n\\label{fig:unit-sup-proof-example}\n\\end{center}\n\\end{figure}\n", "meta": {"hexsha": "785a41386b8ef8716fb66a73bb45d2dfa3eaee4f", "size": 14615, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/ijcar18/super.tex", "max_stars_repo_name": "Gbury/archsat", "max_stars_repo_head_hexsha": "322fbefa4a58023ddafb3fa1a51f8199c25cde3d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2018-08-19T14:41:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-14T14:07:03.000Z", "max_issues_repo_path": "papers/ijcar18/super.tex", "max_issues_repo_name": "Gbury/archsat", "max_issues_repo_head_hexsha": "322fbefa4a58023ddafb3fa1a51f8199c25cde3d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-04-10T02:05:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-07T15:41:36.000Z", "max_forks_repo_path": "papers/ijcar18/super.tex", "max_forks_repo_name": "Gbury/archsat", "max_forks_repo_head_hexsha": "322fbefa4a58023ddafb3fa1a51f8199c25cde3d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-02-12T14:25:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-14T11:12:52.000Z", "avg_line_length": 44.0210843373, "max_line_length": 80, "alphanum_fraction": 0.7060554225, "num_tokens": 4565, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4302656376055186}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry} \n\\usepackage{color}\n\\usepackage[usenames,dvipsnames]{xcolor}\n\\usepackage{amsmath,amssymb,amsthm,algorithm,algorithmic,graphicx,yhmath,url,enumitem,lscape,mathtools}\n\\usepackage{wrapfig,subfigure}\n\n\\newcounter{problem}\n\\newenvironment{problem}{\\refstepcounter{problem} \\noindent {\\bf Problem \\arabic{problem}}}{\\newpage}\n\\newenvironment{solution}{\\vspace{0.3cm} \\par \\noindent {\\bf Solution}}{}\n\\newenvironment{verification}{\\vspace{0.3cm} \\par \\noindent {\\bf Verification}}{}\n\\newenvironment{hint}{\\vspace{0.3cm} \\par {\\bf Hint:}}{}\n\n\\newcounter{remark}\n\\newenvironment{remark}{\\refstepcounter{remark} \\vspace{0.3cm} \\par \\noindent {\\bf Remark \\arabic{remark}}}{\\vspace{0.3cm}}\n\\newcounter{lesson}\n\\newenvironment{lesson}{\\refstepcounter{lesson} \\vspace{0.3cm} \\par \\noindent {\\bf Lesson \\arabic{lesson}}}{\\vspace{0.3cm}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Rn}{\\mathbb{R}^n}\n\\newcommand{\\Rnn}{\\mathbb{R}^{n \\times n}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\fl}{\\text{fl}}\n\n\\begin{document}\n\n\\title{5DV005, Fall 2018, Lab session 5}\n\\author{Carl Christian Kjelgaard Mikkelsen}\n\n\\maketitle\n\\tableofcontents\n\n\\section{The time and the place}\nThe lab session will take place on\n\\begin{center}\nWednesday, December 5th, 2018, (kl. 13.00-16.00), Room MA416-426.\n\\end{center}\n\n\n\\section{Introduction}\n\nThis week's problems do not require much in terms of programming. However, however careful inspection and analysis of the output is required. Use any excess time to complete problems from previous weeks.\n\n\\section{The problems}\n\n\\begin{problem} Consider the problem of computing the derivative $f'(x)$ using the finite difference approximation\n  \\bes\n  D_1(f,x,h) = \\frac{f(x+h)-f(x)}{h}\n  \\ees\n  Execute the script {\\tt rdifmwe1} and examine output in detail:\n  \\begin{enumerate}\n  \\item Determine the value of $k$ where the computed value of Richardson's fraction has executed an illegal jump.\n  \\item Determine the range of $k$ values for which the computed value of Richardson's fraction convergences monotonically to $2^p$ for a suitable value of $p$.\n  \\item Determine the range of $k$ values for which the computed value of Richardson's fraction converges to $2^p$ at the correct rate.\n  \\item Determine the range of $k$ values where the error estimates become more and more accurate.\n  \\item How is the behavior of Richardson's fraction related to the quality of Richardson's error estimate?\n    \\end{enumerate}\n  \\end{problem}\n\n  \\begin{problem} Copy {\\tt rdifmwe1.m} into {\\tt /work/l5p2.m} and adapt it to the problem of computing $f'(2)$ where\n    \\bes\n    f(x) = e^x \\sin(x)\n    \\ees\n    Do \\textit{not} include the derivative when you call {\\tt rdif}.\n    \\begin{enumerate}\n    \\item Verify that the computed value of Richardson's fraction appears to converge towards $2^p$ for a suitable value of $p$ as $h$ tends to zero. \n    \\item Find the last value of $k$, where the computed value of Richardson's fraction behaved exactly as predicted for the exact value of Richardson's fraction.\n    \\item Include the exact derivative when you call {\\tt rdif}. Find the value of $k$ where the accuracy of Richardson's error estimate is maximal.\n    \\item How is the behavior of Richardson's fraction related to the quality of Richardson's error estimate?\n      \\end{enumerate}\n \\end{problem}\n   \n\\begin{problem} Consider the problem of computing the derivative $f'(x)$ using the finite difference approximation\n  \\bes\n  D_2(f,x,h) = \\frac{f(x+h)-f(x-h)}{2h}\n  \\ees\n  Execute the script {\\tt rdifmwe2} and examine output in detail:\n  \\begin{enumerate}\n  \\item Determine the value of $k$ where the computed value of Richardson's fraction has executed an illegal jump.\n  \\item Determine the range of $k$ values for which the computed value of Richardson's fraction convergences monotonically to $2^p$ for a suitable value of $p$.\n  \\item Determine the range of $k$ values for which the computed value of RichRichardson's fraction converges to $2^p$ at the correct rate.\n  \\item Determine the range of $k$ values where the error estimates become more and more accurate.\n  \\item Is the behavior of Richardson's fraction related to the quality of Richardson's error estimate?\n    \\end{enumerate}\n\\end{problem}\n\n \\begin{problem} Copy {\\tt rdifmwe2.m} into {\\tt /work/l5p4.m} and adapt it to the problem of computing $f'(2)$ where\n    \\bes\n    f(x) = e^x \\sin(x).\n    \\ees\n    Do \\textit{not} include the derivative when you call {\\tt rdif} initially.\n    \\begin{enumerate}\n    \\item Verify that the computed value of Richardson's fraction appears to converge towards $2^p$ for a suitable value of $p$ as $h$ tends to zero. \n    \\item Find the last value of $k$, where the computed value of Richardson's fraction behaved exactly as predicted for the exact value of Richardson's fraction.\n    \\item Include the exact derivative when you call {\\tt rdif}. Find the value of $k$ where the accuracy of Richardson's error estimate is maximal.\n    \\item Is the behavior of Richardson's fraction related to the quality of Richardson's error estimate?\n    \\end{enumerate}\n \\end{problem}\n\n\\bibliographystyle{plain}\n  \\bibliography{../../../lecture-notes/refs}\n  \n\\end{document}\n\n\n\n\n\n\n", "meta": {"hexsha": "50918ee38828d910988d2c3927cccc7ddb2d4fda", "size": 5449, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Courses/Numerical Analysis/lab exercises/lab5/specification/lab5.tex", "max_stars_repo_name": "itismesam/Courses-1", "max_stars_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2020-09-30T13:45:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T10:22:19.000Z", "max_issues_repo_path": "Courses/Numerical Analysis/lab exercises/lab5/specification/lab5.tex", "max_issues_repo_name": "itismesam/Courses-1", "max_issues_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Courses/Numerical Analysis/lab exercises/lab5/specification/lab5.tex", "max_forks_repo_name": "itismesam/Courses-1", "max_forks_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2020-10-06T07:05:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T10:23:29.000Z", "avg_line_length": 47.798245614, "max_line_length": 203, "alphanum_fraction": 0.7379335658, "num_tokens": 1535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.7981867873410141, "lm_q1q2_score": 0.4302092853514154}}
{"text": "% !TeX root = ../smc-report.tex\n% !TeX encoding = UTF-8\n% !TeX spellcheck = en_GB\n\n\\section*{LINFA: Smart drugs restocking}\n\n  \\subsection*{Smart drugs restocking}\n\n    The pharmaceutical logistic chain is a very complex system, as it includes several actors and critical points (such as elevated drug costs, need for transport at monitored temperature, chance of expiration of goods, stock management, irregularity of demands, several possible logistic approaches, etc), which render the problem hard to optimize without the proper tools for decision support. In this context, possible unavailability could lead to critical situations, sometime even catastrophic, as it wouldn't be possible any more to guarantee the correct execution of one or more healthcare protocol, thus affecting the patients' health. Furthermore, orders are typically carried out on a daily basis and in a manual fashion, without the support of any decision support system. All these reasons makes restocking schedule hard, thus leading to unproductive stocks and higher stocking costs.\n    \n    In this scenario fits the project \\textit{LINFA} (i.e. \\textit{Logistica INtelligent del FArmaco}, or \\textit{Smart Drug Logistic}, from Italian), that aims to develop an IT system for support to processes of drugs logistic management, in the context of healthcare or local companies. LINFA aims to increase efficiency, effectiveness and predictability of the process of drugs and medical devices restocking, within healthcare structures, through methods of predictive analysis and optimization, advanced logistic techniques and tracking features through the use of RFID technologies or the integration of healthcare and administrative information stream.\n    \n    For sake of simplicity, the following assumptions will be made in order to build a model:\n    \n    \\begin{itemize}\n      \\item a single ward is present;\n      \\item the ward has a fixed number of beds (40) and a fixed maximum storage capacity (40);\n      \\item patients are indistinguishable;\n      \\item there is only one type of drug;\n      \\item patients can arrive through emergencies (i.e. according to a random variable) or scheduled examinations (i.e. according to a fixed constant);\n      \\item each day, patients can leave the ward with a certain probability;\n      \\item each day, patients can consume up to 3 units of drug;\n      \\item for each missing drug, an urgent order is issued, which arrives immediately;\n      \\item restock orders are issued at the end of each day and arrive immediately;\n      \\item the drug can be restocked in quantities of 0 (i.e. no order), 10, 20, 30 or 40.\n    \\end{itemize}\n    \n    The model in Code \\ref{lst:ward} models a generic ward with the above specifications and three days of lookahead. The model is intended to characterise the evolution of the ward for the three subsequent days in order to support decision to the restock order of the current day, so it starts at the end of the current day (i.e. after patients arrival/discharge and drug consumption, but before the restock order). The arrival of patients and the consumption of drugs have been modelled through binomial distributions, as well as drug restock order choices, with different success probabilities. Sojourn time inside the ward for each patient is instead modelled through a geometric distribution.\n    \n    \\begin{center}\n      \\lstinputlisting[language=prism, caption={PRISM code of the probabilistic model of a hospital ward.}, label={lst:ward}]{code/ward_dtmc.sm}\n    \\end{center}\n    \n    \\question{Look at the model in Code \\ref{lst:ward} and describe how it works.\\\\}\n    \\answer{\n      The first thing that can be notice about the model is that it is defined as a DTMC. This is due the fact that the model is fully probabilistic (i.e. there is no non-determinism) and that the time is divided into discrete steps.\n      \n      In the first part of the code, before the beginning of the main module (lines 3-19), constants and probabilities are defined. Distributions for patients arrival through emergency, drug consumption and drug restock are defined as binomial distribution with different success probabilities (lines 8-11). Upper bounds of such distributions are defined as $4$ for emergency arrivals (\\prism{maxER}), $3$ for drug consumption (\\prism{maxConsume}) and $4$ for drug reorder choices. Arrivals of scheduled patients for the three subsequent days of lookahead are defined as fixed variables (lines 17-19). Also, cost weights are defined for the order cost of a single drug unit, the cost for urgent drug reorders and the stocking cost for keeping each drug unit in stock in the right conditions each day (lines 13-15).\n      \n      The main module \\prism{hospitalWard} firstly defines several internal variables (lines 37-42), such as the number of hospitalised patients \\prism{n}, the number of current drugs in stock \\prism{stockDrugs}, the current day \\prism{day}, or support variables, such as \\prism{s}, \\prism{tmp} or \\prism{tmp2}. In particular \\prism{s} is used to describe the internal state for each day of the ward.\n      \n      States from \\prism{s=0} to \\prism{s=3} (lines 31-46) are used to model the drug order for the current day and for the first and second following days. The module starts at the end of the current day (i.e. after patients arrival/discharge and drug consumption, but before the restock order) in order to include as much real information as possible from the real ward when deciding how to reorder. Lines 34-37 are used to chose probabilistically which kind of order to issue, according to the probability \\prism{probOrder} defined. Lines 39-43 are then used to execute the corresponding order, effectively increasing the stocked drugs. Also, each order has a label associated, that will be used in the cost reward computation. After the order choice has been made, the \\prism{day} variable is incremented and the \\prism{tmp} support variable is set to the number of patients currently hospitalised, \\prism{n}.\n      \n      States from \\prism{s=10} to \\prism{s=12} are used to model the arrival and discharge of patients in the ward. State \\prism{s=10} (lines 49-52) of the ward is used to cycle through all the currently hospitalised patients to decide which of them will leave the ward, with probability \\prism{probExit}. In this scenario the \\prism{tmp} variable is used to cycle through all the patients. State \\prism{s=11} (lines 55-57) is used to model the arrival of scheduled patients, the exact number of which is indicated by three constants. State \\prism{s=12} (lines 60-63) instead is used to model the arrival of new patients through emergencies, modelled through a binomial distribution with success probability \\prism{probER} defined.\n      \n      State \\prism{s=20} is used to model drug consumption by the currently hospitalised patients. A binomial distribution with success probability \\prism{probConsume} is used and a cycle is implemented through the use of the \\prism{tmp} (lines 66-69). On top of that, for each patient, if after the drug consumption some drugs result to be missing (i.e. some drug was needed but there wasn't enough in stock), then the special action with label \\prism{missingDrugs} is executed (line 71), which is needed to compute the correct cost reward. When drugs have been administered to all the patients (line 73) the module will then either start again (line 76) or stop definitely (line 77) in case the three following days have been completely modelled.\n      \n      Lastly, the only reward defined, \\prism{totalCost}, is used to cumulate the total cost coming from different sources (lines 85-95). In particular, every time the consumption of drug is finished for a certain day, the remaining drugs in stock produce a cost determined by the weight \\prism{costStorage} (line 86). Each time one or more drugs result missing during administration, and therefore an urgent order has to be issued, each missing drug produce a cost defined by the weight \\prism{costUrgentOrder} (line 88). Regular orders also produce a cost, in particular a cost of $1$ for each drug ordered (lines 90-94).\n    }\n    \n    \\question{\n      Add the following property, representing the expected \\prism{totalCost} at the end of the three subsequent days:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/totalCost.pctl}\n      \n      Then, create a new experiment to evaluate the best reorder strategy for wards that have different probabilities of drug consumption. For this experiment, set the probability constants \\prism{probExit} and \\prism{probER} to $0.5$ and $0.3$ respectively.\n    }\n    \\answer{\n      The results of the experiment, that plots the expected \\prism{totalCost} after the three days for different consumption and reorder probabilities, are shown in Figure \\ref{fig:totalCost_probOrder_probConsume_plot}.\n    \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{totalCost_probOrder_probConsume_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the expected total cost after the three subsequent days as \\prism{probOrder} varies for different values of \\prism{probConsume}.}\n    \t\t\\label{fig:totalCost_probOrder_probConsume_plot}\n    \t\\end{figure}\n      \n      As expected, lower values of \\prism{probOrder} result in a higher expected \\prism{totalCost} after three days for higher probabilities of consumption. This is clearly due the fact that higher consumption probabilities means a higher demand of drugs, which otherwise will deplete soon, therefore policies that tend to restock big quantities of drugs are advised in these situations. These curves, however, are not monotone, as they seem to cross around $0.6$, which seems to be also the minimum for most curves. After this point, which seems to be the best policy to be taken on average, the situation changes, meaning that higher probabilities of reordering are favoured in scenarios with higher probabilities of consumption. It is also worth noticing that the curve relative to \\prism{probConsume}$=0$ is the only strictly increasing, due to the fact that if no drugs are ever consumed (i.e. never required), then reordering drugs is always just a cost and never an investment. So, as expected, low values of \\prism{probConsume} requires also low values of \\prism{probOrder} and viceversa. A good strategy, on average, would be to reorder with probability between $0.5$ and $0.6$.\n    }\n    \n    \\question{Perform now an experiment similar to the previous one, this time studying the best reorder strategy for wards that have different average sojourn times (i.e. probability of patient discharge). Set instead the value of \\prism{probConsume} to $0.2$}\n    \\answer{\n      The results of the experiment are shown in Figure \\ref{fig:totalCost_probOrder_probExit_probConsume-0-2_plot}.\n    \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{totalCost_probOrder_probExit_probConsume-0-2_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the expected total cost after the three subsequent days as \\prism{probOrder} varies for different values of \\prism{probExit}, with \\prism{probConsume}$=0.2$.}\n    \t\t\\label{fig:totalCost_probOrder_probExit_probConsume-0-2_plot}\n    \t\\end{figure}\n      \n      The results show that, as expected, lower values of \\prism{probExit} (i.e. patients stay longer, on average, in the ward) require higher values of \\prism{probOrder}, while higher values of the discharge probability require a smaller reorder probability. As seen in the previous experiment, the curves cross, this time between $0.3$ and $0.35$. In this scenario, if the probability of patients discharge is unknown, the safest strategy would be with a value of \\prism{probOrder} between $0.25$ and $0.3$.\n    }\n    \n    \\question{Repeat the previous experiment, this time with \\prism{probConsume}$=0.8$. Which conclusions can you draw comparing the results of the two experiments?}\n    \\answer{\n      The results of the experiment are shown in Figure \\ref{fig:totalCost_probOrder_probExit_probConsume-0-8_plot}.\n    \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{totalCost_probOrder_probExit_probConsume-0-8_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the expected total cost after the three subsequent days as \\prism{probOrder} varies for different values of \\prism{probExit}, with \\prism{probConsume}$=0.8$.}\n    \t\t\\label{fig:totalCost_probOrder_probExit_probConsume-0-8_plot}\n    \t\\end{figure}\n      \n      The results of this last experiment are very similar to the results of the previous one, meaning that lower values of \\prism{probExit} favour higher values of \\prism{probOrder} and viceversa. This time, instead, the inversion point of the curves results shifted to the right, around $0.6$. This shift is due the fact that when drugs are consumed more frequently, ordering more drugs keeps being the optimal choice even if patients leave the hospital quickly, because even in the short time they spend in the ward, they are expected to consume high quantities of drugs. Also, the range of the expected \\prism{totalCost} varies greatly between the two experiments: in the previous one the maximum was $636$, while for this was is $2543$. This can simply be explained by the fact that if more drugs are consumed on average, the simple cost of having to restock more drug units makes the total cost skyrocket.\n    }\n    \n  \\dashedrule\n  \n  \\subsection*{Adding non-determinism}\n    One of the most useful features of PRISM is the optimal strategy extraction of an MDP model. \\textit{MDPs} (\\textit{Markov Decision Process}) are probabilistic models that also include non-deterministic choices, in order to model transitions between states with no probabilistic information attached to them. A strategy, for an MDP, is a set of specific actions for all the non-deterministic choices that resolve the non-determinism of the model, turning it into a fully probabilistic model. Among all the possible strategies, the optimal one is the strategy that minimises/maximises a certain reward function.\n    \n    \\question{Modify the model in Code \\ref{lst:ward} in order to make the drug reorder choice non-deterministic.}\n    \\answer{\n      Changing the reorder choice in Code \\ref{lst:ward} from a probabilistic choice to a non-deterministic one is quite straightforward. The first thing do is, clearly, to change the keyword \\prism{dtmc} in line 1 to \\prism{mdp}, so that the model is correctly built as an MDP. Then, it's simply necessary to replace the lines 31-46 in Code \\ref{lst:ward} with the following code:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/ward_mdp_update.sm}\n      \n      The above code allows all the reorder choices to be enabled at the same time with no probability information attached to them, thus making the reorder choice non-deterministic. Also, the constant \\prism{probOrder} (line 11) and the variable \\prism{drugsToOrder} (line 28) can be removed from the code, as they are not used any more.\n    }\n    \n    \\question{\n      Save the new MDP model as \\bash{ward\\_mdp.sm}, setting \\prism{probExit}, \\prism{probER} and \\prism{probConsume} to be $0.5$, $0.3$ and $0.6$ respectively. Then execute the following command to \\href{http://www.prismmodelchecker.org/manual/RunningPRISM/Adversaries}{extract the optimal adversary}, states and labels:\n      \n      \\lstinputlisting[numbers=none]{code/extractadv.bat}\n      \n      Following the PRISM manual, determine which is the optimal strategy for the current day reorder with the initial setting of \\prism{stockDrugs}$=10$ and \\prism{n}$=10$.\n    }\n    \\answer{\n      According to the manual, once the suggested command have been executed, the file \\bash{adv.lab} indicates which is the ID of the initial state, in this case $370$. By exploring, then, the \\bash{adv.tra} file, the following line can be found:\n      \n      \\lstinputlisting[numbers=none]{code/adv_tra_example.tra}\n      \n      The above line indicates that, when in the state with ID $370$ (i.e. the initial state, which in this case represents the scenario with 10 patients and 10 stocked drugs), the best strategy to follow, in order to minimise on average the total cost after three days, is to order 10 units, as indicated by the label of the action \\prism{order10}. The above line indicates also that, by taking this action, the model will move to the state with ID $2191$, which, according to the file \\bash{adv.sta}, corresponds to the scenario with 10 patients, 20 stocked drugs and variable \\prism{s}$=1$, as expected.\n    }\n    \n    \\question{Perform now an experiment, either manually or through a custom script, varying the initial state for both \\prism{n} and \\prism{stockDrugs}. Show and comment the results.}\n    \\answer{\n      The results of the experiment are shown in Figure \\ref{fig:sd_n_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=1]{sd_n_plot.pdf}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the optimal reorder strategy as \\prism{stockDrugs} varies for different values of \\prism{n}.}\n    \t\t\\label{fig:sd_n_plot}\n    \t\\end{figure}\n    \t\n    \tFrom Figure \\ref{fig:sd_n_plot} it can be seen that, as the value of \\prism{stockDrugs} increases, the suggested optimal reorder amount decreases, as with higher amounts of drugs already in stock, the need for even more drugs gets weaker and weaker. When the number of hospitalised patients \\prism{n}, instead, is increased, the suggested optimal amount results also increased, because, as expected, with more patients in the hospital more drug consumptions are expected, thus requiring a fuller stock. In Figure \\ref{fig:sd_n_plot} the curves \\prism{n}$=30$ and \\prism{n}$=40$ overlaps.\n    \t\n    \tThe experiment have been conducted through a simple custom script, used to speed up the experimentation\\footnote{The script source code can be found at the following link:\\\\ \\url{https://github.com/oddlord/uni/tree/master/phd/courses/smc/experiments}.}.\n    }\n    \n    \\question{Perform a similar experiment, this time varying \\prism{stockDrugs} and \\prism{costStorage}, while keeping the initial value of \\prism{n} fixed to $20$.}\n    \\answer{\n      The results of the experiment are shown in Figure \\ref{fig:sd_costStorage_0-40_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=1]{sd_costStorage_0-40_plot.pdf}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the optimal reorder strategy as \\prism{stockDrugs} varies for different values of \\prism{costStorage}.}\n    \t\t\\label{fig:sd_costStorage_0-40_plot}\n    \t\\end{figure}\n      \n      The results in Figure \\ref{fig:sd_costStorage_0-40_plot} show that, similarly to the results of the previous experiment, the suggested optimal reorder amount decreases as the amount of drugs in stock increases. Also, it can be observed how, with the increase of the storage cost for each drug for each day, the suggested amount decreases: this is due the fact that, when the cost is low (or even zero) the system tends to suggest to completely refill the storage, in order to cope even with extreme emergency situation; on the other hand, if the storage cost weights more, PRISM is forced to find a more suitable trade-off between the storage cost and the actual need for drugs. An interesting detail is also that the gap between two subsequent curves seems to get smaller and smaller as \\prism{costStorage} increases: this remarks the fact that, as \\prism{costStorage} increases, the suggested optimal reorder amount tends to a limit, representing the best trade-off between the need to store as less drugs as possible (due to the high storage cost) and the need to also store as much drugs as possible (in order to avoid urgent orders).\n    }\n", "meta": {"hexsha": "f3c783d18e56d5723a9a35d915491d38885f43e5", "size": 19883, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd/courses/smc/body/linfa.tex", "max_stars_repo_name": "oddlord/uni", "max_stars_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "phd/courses/smc/body/linfa.tex", "max_issues_repo_name": "oddlord/uni", "max_issues_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd/courses/smc/body/linfa.tex", "max_forks_repo_name": "oddlord/uni", "max_forks_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.7345679012, "max_line_length": 1187, "alphanum_fraction": 0.7605492129, "num_tokens": 4718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6791786991753931, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.4301987683290951}}
{"text": "\\documentclass[letterpaper]{article}\n\\usepackage{amsmath} \n\\usepackage{fullpage}\n\\usepackage{natbib}\n\\usepackage{textcomp}\n\\usepackage{color}\n\\definecolor{darkblue}{rgb}{0.0,0.0,0.9}\n\\usepackage[colorlinks=true,urlcolor=darkblue,linkcolor=black,citecolor=darkblue]{hyperref}\n\n\\newcommand{\\deriv}[2]{\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}}\n\n\\begin{document}\n\\newpage\n\\pagestyle{plain}\n\\setcounter{page}{1}\n\n\\begin{center}\n\\huge{DJLES: Dubreil-Jacotin-Long Equation Solver}\\\\[1em]\n\\large{Feb 8, 2019}\\\\\nMichael Dunphy\n\\end{center}\n\n\\section{Introduction}\nDJLES is a MATLAB/Octave package that finds a mode-one solution to the DJL equation. \\cite{StastnaLamb2002} describe the problem setup, weakly nonlinear theory, fully nonlinear theory, and iterative solution procedure. DJLES was inspired by \\verb+soliw+, a DJL solving C package resulting from the work of~\\cite{StastnaLamb2002}.\n\nDJLES differs from \\verb+soliw+ by being MATLAB based, which avoids the need to compile C code and manage the resulting raw binary files. When used with MATLAB, it also takes advantage of the built in parallelisation of FFTs which accelerates solution on multi-core computers. Lastly, it easily employs the resolution refinement approach of~\\cite{DunphySubichStastna2011}, a feature not available in \\verb+soliw+.\n\nIf you find this code useful, please cite~\\cite{DunphySubichStastna2011} as it will encourage the author to maintain/improve DJLES. Bug reports, fixes/improvements and additional case files are welcome; please contact \\href{mailto:mdunphy@uwaterloo.ca}{mdunphy@uwaterloo.ca} for inclusion in a future version.\n\nDJLES has benefited from contributions from Marek Stastna, Kevin Lamb, Chris Subich, Derek Steinmoeller, Jorge Magalh\\~aes and Jos\\'e da Silva.\n\nThe remainder of this document is a user guide for the code.\n\n\\section{Quickstart}\nDownload the code and run one of the case files in either MATLAB or Octave. The case files take less than one minute to run on a recent desktop computer, and may need 2-3 minutes on an older system. Upon completion the code will produce a plot of the wave.\n\n\\section{Usage}\nTypical usage is to set problem parameters, then call \\verb+djles_refine_solution+ to solve the DJL equation, which returns the isopycnal displacement field $\\eta$ and wave speed $c$ in MATLAB variables \\verb+eta+ and \\verb+c+, respectively. The required problem parameters are:\n\\begin{itemize}\n \\item $L$ and $H$ -- Domain length and depth (m)\n \\item $N_x$ and $N_z$ -- Number of grid points in $x$ and $z$\n \\item $\\bar{\\rho}(z)$ and $\\deriv{}{z} \\bar{\\rho}(z)$\n       -- Background density profile and first derivative\n       \\begin{itemize}\n        \\item If using full density, also provide reference density parameter \\verb+rho0+.\n        \\item If using non-dimensional density, DJLES will assume \\verb+rho0=1+.\n       \\end{itemize}\n \\item $A$ -- Target available potential energy (per unit in $y$)\n       \\begin{itemize}\n        \\item If using full density, units are kg m/s$^2$.\n        \\item If using non-dimensional density, units are m$^4$/s$^2$.\n       \\end{itemize}\n \\item $U_{bg}(z)$, $\\deriv{}{z} U_{bg}(z)$, and $\\deriv{^2}{z^2} U_{bg}(z)$\n       -- Background velocity profile (m/s) and first two derivatives\n\\end{itemize}\nIf a background velocity is not desired, set it to zero (see test cases). \nOnce the solution is complete, \\verb+djles_diagnostics+ computes the associated velocity fields, vorticity, etc., \\verb+djles_pressure+ computes the pressure, and \\verb+djles_plot+ produces a simple plot of these fields.\n\nDuring the first call to \\verb+djles_refine_solution+, we use weakly nonlinear theory to find an initial guess for the solution, which is then iterated to convergence. Subsequent calls to \\verb+djles_refine_solution+ use the previous fully nonlinear solution as the initial guess. This allows for the strategy of successively adjusting parameters (resolution, wave APE, etc) to ease/accelerate finding a solution. The various test cases demonstrate several solution scenarios.\n\n\\subsection{Tuning knobs}\nThere are a few tuning knobs. Set them in the case file to override the default.\n\\begin{itemize}\n \\item \\verb+min_iterate+ specifies the minimum number of iterations that the solver will take, default is 10.\n \\item \\verb+max_iterate+ specifies the maximum number of iterations that the solver will take, default is 2000. If you use a very small \\verb+epsilon+ or \\verb+relax+ you may need to increase this. \n \\item \\verb+NL+ is the number of Legendre points to use for the Gauss quadrature used for the APE integral. Values below 5 are probably too small, values in 15--25 are quite good, and values higher than 25 are likely unnecessary. Default is 20.\n \\item \\verb+relax+ is the underrelaxation factor, $0 < \\verb+relax+ <= 1$.\n        The value is the fraction of the new iteration, $\\eta^{k*}$ to retain\n        after performing an iteration, that is,\n        $\\eta^k = \\eta^{k-1} + \\verb+relax+(\\eta^{k*} - \\eta^{k-1})$.\n        The default of 0.5 works well in most cases, and a value of 1 disables underrelaxation.\n        Using a small value can help stabilise the solver at the expense of needing more iterations.\n \\item \\verb+g+ is the gravitational acceleration constant, default value is 9.81 m/s$^2$.\n \\item \\verb+verbose+ controls the verbosity of status updates. A value of 0 disables printing, a value $\\ge 1$ enables printing updates after each iteration, and a value $\\ge 2$ enables printing of timing data upon completion. Default is 1.\n\\item \\verb+epsilon+ controls the stop condition, which is the relative difference between successive iterations. Default $1\\times10^{-4}$. Smaller values will require more solver iterations.\n\\end{itemize}\n\n\\subsection{Miscellaneous}\n\nA successful solve will have a relative error of roughly \\verb+epsilon+/\\verb+relax+ decimal places in $\\eta$. Using a small value of \\verb+relax+ should be accompanied with a reduction in \\verb+epsilon+.\n\nIf the solver fails to converge, \n\\begin{enumerate}\n \\item Ensure that your density profile $\\rho(z)$ is stably stratified.\n \\item Run the solver with a smaller underrelaxation factor. A value of 0.1 or even 0.01 may suppress oscillations and stabilise the solver. \n \\item Ensure that your density profile (and first derivative) is smooth.\n \\item Ensure that the domain width $L$ is wide enough to contain the wave. The boundary conditions for the problem are $\\eta=0$ on all boundaries; if your domain is too narrow it will be enforcing that condition at the wrong location.\n\\end{enumerate}\n\n\\subsection{Compatibility notes}\n\\begin{itemize}\n \\item Tested with MATLAB R2013a (Linux 64-bit and Windows), R2012a (OSX 10.6.8).\n \\item Tested with Octave v3.8.1, v4.0.1 and v4.4.1 (Linux 64-bit).\n \\item The initial guess part uses \\verb+polyeig.m+, and Octave added it in v3.8.0, so it's unlikely to work with Octave older than v3.8.0.\n \\item MATLAB R2014a prints warnings about deprecating \\verb+ppval+, you can suppress the warnings with \\\\ \\verb+warning('off','MATLAB:interp1:ppGriddedInterpolant');+\n\\end{itemize}\n\n\\subsection{Numerical Grid}\nThe domain is the rectangular region $[0,L] \\times [-H,0]$ and is discretized into $N_x\\times N_z$ grid boxes. The boundary conditions for the problem are zero, and we use the cell centres for the coordinates, that is,\n\\begin{align}\nx_i^c &= \\frac{\\Delta x}{2} + i \\Delta x, \\quad i \\in 0,1,2,\\ldots,N_x-1,\\\\\nz_j^c &= -H + \\frac{\\Delta z}{2} + j \\Delta z, \\quad j \\in 0,1,2,\\ldots,N_z-1,\n\\end{align}\nwhere $(\\Delta x, \\Delta z) = (L/N_x, H/N_z)$. The grid shifting routine \\verb+djles_shift_grid.m+ shifts the data from the cell centres to cell edges, \n\\begin{align}\nx_i^e &= i \\Delta x, \\quad i \\in 0,1,2,\\ldots,N_x\\\\\nz_j^e &= -H + j \\Delta z, \\quad j  \\in 0,1,2,\\ldots,N_z.\n\\end{align}\nThe array sizes are $N_x+1 \\times N_z+1$ on the cell edges grid.\n\n\\section{Description of M-files}\nThe code consists of a handful of functions, scripts, and test cases.\n\n\\subsection{Scripts}\nThe scripts are\n\\begin{verbatim}\nFilename                  - Description\n-----------------------------------------------------------------------------------------\ndjles_common.m            - Sets default parameters and generates grid and wavenumbers.\ndjles_diagnostics.m       - Computes wave velocities, vorticity, etc from eta and c.\ndjles_initial_guess.m     - Used by djles_refine_solution.m to get an initial guess for\n                            eta & c from WNL theory if an initial guess is not provided.\ndjles_plot.m              - Plots the solution and some diagnostics.\ndjles_pressure.m          - Computes the non-hydrostatic pressure and residuals in the\n                            governing equations. Uses results from djles_diagnostics.m.\ndjles_refine_solution.m   - This is the main m-file that each case files calls. It\n                            performs the iterative procedure to find a wave solution.\n\\end{verbatim}\n\n\\subsection{Helper Functions}\nThe helper functions are\n\\begin{verbatim}\ndjles_change_resolution.m - Changes the resolution of the solution.\ndjles_compute_apedens.m   - Computes the available potential energy density.\ndjles_diffmatrix.m        - Generates a finite difference differentiation matrix for use\n                            in the initial guess procedure.\ndjles_extend.m            - Extends the input data using specified symmetry.\ndjles_gradient.m          - Computes the gradient of input data.\ndjles_quadweights.m       - Returns the 1-dimensional interior grid quadrature weights.\ndjles_residual.m          - Computes the residual in the DJL equation.\ndjles_shift_grid.m        - Shifts the input data from cell centres to cell endpoints.\ndjles_sinequadrature.m    - Computes the interior grid sine quadrature weights for\n                            area integrals.\ndjles_wavelength.m        - Computes an estimate of the wavelength.\n\\end{verbatim}\n\n\\subsection{Test cases}\nIncluded are eight test cases that demonstrate how to use DJLES. A brief description of each follows.\n\n\\subsubsection{Small APE}\nTest case: \\verb\"case_small_ape.m\" \\\\\\\\\nThis test case demonstrates the parameter regime of no background current, a smooth pycnocline, and small wave APE.\nThe initial guess obtained from weakly nonlinear theory will be ``close'' to the fully nonlinear DJL solution, so the solver readily converges.\nOnce we find the low resolution wave (32$\\times$32), we increase the resolution to 512$\\times$256 and iterate to convergence.\nThe low resolution solution is a very good initial guess for the high resolution problem, so the high resolution wave is also readily solved.\n\n\\subsubsection{Large APE}\nTest case: \\verb\"case_large_ape.m\" \\\\\\\\\nThis test case demonstrates the parameter regime of no background current, a smooth pycnocline, and large wave APE.\nThe initial guess from weakly nonlinear theory will be rather poor. \nThe solution strategy we use is to find a wave with a small APE, and supply that wave as the initial guess to find a wave with a larger APE.\nApplying this several times yields the final wave with a large APE.\nIn this case we start at one percent of the target APE and raise the APE in five steps.\nLastly, we increase the resolution once we reach the target APE.\nThe result is a broad flat crested wave.\n\n\\subsubsection{Background current}\nTest case: \\verb\"case_ubg.m\" \\\\\\\\\nWe use the same successive solution strategy here by solving without a background current first,\nand then raise the background current strength in increments until we reach the full background current.\nWe increase epsilon for the intermediate solutions to accelerate the process as we only need them to be of ``initial guess'' quality.\nLastly, we reduce epsilon, and increase the resolution in two increments.\n\n\\subsubsection{Sharp pycnocline}\nTest case: \\verb\"case_sharp_pycnocline.m\" \\\\\\\\\nObtaining a solution with a sharp pycnocline can be difficult for the solver to find directly, and the successive solution strategy works here as well.\nWe begin with a low-resolution wide-pycnocline that is readily solved and begin successively reducing the pycnocline thickness.\nAs we sharpen the pycnocline, we also increase the resolution such that the pycnocline is not under-resolved.\n\n\\subsubsection{Synthetic data}\nTest case: \\verb\"case_synthetic_data.m\" \\\\\\\\\nThis case matches the parameters of the background current case, except that we use synthetic mooring data as the background profiles.\nWe sample the analytic functions at 25 evenly spaced points and construct continuous profiles using linear interpolating polynomials.\nSecond order differentiation provides the gradients, which are linearly interpolated in the same fashion.\nThe \\verb+linear+ and \\verb+pchip+ interpolation methods preserve monotonocity which is important to ensure the interpolated density profile is stable.\nThe \\verb+spline+ method does not preserve monotonicity so be careful if you use it.\nAs in \\verb\"case_ubg.m\", we raise the background velocity in four successive steps, followed by three resolution refinements.\n\n\\subsubsection{Lake Erie data}\nTest case: \\verb\"case_lakeerie.m\" \\&  \\verb\"case_lakeerie.txt\" \\\\\\\\\nHere we use time-averaged temperature profile data collected from Lake Erie (K.~Lamb 2014, pers.~comm.).\nThe text file contains two columns, depth (m) and temperature (\\textdegree C), and we convert the temperature to density with a linear equation of state.\nThere is no surface value so we extrapolate to find a value for $z=0$.\nWe construct the density and density gradient in the same fashion as in the synthetic data case, and use no background current.\nWe solve the wave at low resolution and then raise the resolution in two steps.\n\n\\subsubsection{Pineda et al. (2015)}\nTest case: \\verb\"case_pineda.m\" \\&  \\verb\"case_pineda_cast1.txt\" \\\\\\\\\nThis case is intended as a typical shallow continental shelf case where we reproduce the DJL solutions shown in~\\cite{PinedaEtAl2015}.\nThe text file contains two columns, depth (m) and density (kg/m$^3$), and is an approximate reproduction (courtesy Jorge Magalh\\~aes and Jos\\'e da Silva) of the smoothed curve of Fig 9a.\nWe use the full density and set the reference density \\verb+rho0+ as the maximum value, and construct the density and first derivative functions as in the synthetic data case.\n\nThe first part of the script finds the wave showcased in Figure 11.\nAfter raising the target APE in a few steps at low resolution and large epsilon, we apply several steps of resolution refinement with epsilon reductions.\nThe relative residual of the final wave is order $4\\times 10^{-7}$, and matches~\\cite{PinedaEtAl2015} to three significant figures in wave height ($-14.1176$ m vs. $-14.1$ m) and two significant figures in phase speed (0.585978 m/s vs. 0.585 m/s).\n\nThe second part of the script reproduces the solid curves of Figure 10.\nWe sweep over a range of target APE values and record the wave height, phase speed, and velocity and pressure one metre above the bottom.\nEach wave is reused as the initial guess for the next APE value as the sweep progresses. \n\nLastly, we note there is a difference in amplitude between the pressure reported in~\\cite{PinedaEtAl2015} and that computed by DJLES (Figures 10c and 11c).\nWe compute residuals by substituting the wave fields into the Boussinesq equations moving with the wave (see bottom part of \\verb+djles_pressure.m+), and find that the residuals are appropriately small, which indicates that the pressure computed by DJLES is correct.\n\n\\subsubsection{Amazon River mouth data}\nTest case: \\verb\"case_amazon.m\" \\&  \\verb\"case_amazon.txt\" \\\\\\\\\nThis case is intended to find the maximum wave amplitude for internal solitary waves on the continental shelf near the mouth of the Amazon River.\nThe included text file contains three columns: depth (m), density (kg/m$^3$) and velocity (m/s) projected along the wave direction of propagation (data courtesy of Jorge Magalh\\~aes and Jos\\'e da Silva).\n\nThe density profile has inversions, so we make ad-hoc adjustments to ensure that the first derivative is always negative (and thus $N^2(z)$ is always positive).\nMuch like the other cases, we start with a small amplitude at low resolution, and incrementally raise the values until we reach a high resolution wave of 35.3 m amplitude.\nThis wave is near its amplitude limit; further increases to the APE will expand the wave as a broad flat crested wave and a larger domain is needed to calculate such a wave.\n\n% References\n\\bibliographystyle{kbib}\n\\bibliography{djles}\n\n\\end{document}\n", "meta": {"hexsha": "36bf5e5a5cf38c5969c992400a6c623c21a8d0b4", "size": 16493, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "userguide/djles.tex", "max_stars_repo_name": "mdunphy/DJLES", "max_stars_repo_head_hexsha": "3433803438748a60e88021a3a7fcd3f11640a3a4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2015-05-19T12:53:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-15T13:08:45.000Z", "max_issues_repo_path": "userguide/djles.tex", "max_issues_repo_name": "mdunphy/DJLES", "max_issues_repo_head_hexsha": "3433803438748a60e88021a3a7fcd3f11640a3a4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-10-21T01:53:58.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-21T01:53:58.000Z", "max_forks_repo_path": "userguide/djles.tex", "max_forks_repo_name": "mdunphy/DJLES", "max_forks_repo_head_hexsha": "3433803438748a60e88021a3a7fcd3f11640a3a4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-04-08T09:05:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T04:42:40.000Z", "avg_line_length": 72.3377192982, "max_line_length": 476, "alphanum_fraction": 0.7565633905, "num_tokens": 4122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.43019875775547073}}
{"text": "\\section{Description of datasets}\n\\label{sec:datasets}\n\nMost of the VQA datasets have strong biases. This allow models to learn strategies without reasoning about the visual input~\\cite{Santoro2017ASN}.\nThe CLEVR dataset~\\cite{johnson2017clevr} was developed to address those issues and come back to the core challenge of visual QA which is testing reasoning abilities.\nCLEVR contains images of 3D-rendered objects; each image comes with a number of highly compositional questions that fall into different categories.\nThose categories fall into 5 classes of tasks: Exist, Count, Compare Integer, Query Attribute and Compare Attribute. \nThe CLEVR dataset consists of:\n\\begin{itemize}\n\\item \tA training set of 70k images and 700k questions,\n\\item\tA validation set of 15k images and 150k questions,\n\\item\tA test  set of 15k images and 150k questions about objects,\n\\item\tAnswers, scene graphs and functional programs for all train and val images and questions.\n\\end{itemize}\nEach object present in the scene, aside of position, is characterized by a set of four attributes:\n\\begin{itemize}\n\\item 2 sizes: large, small,\n\\item 3 shapes: square, cylinder, sphere,\n\\item 2 material types: rubber, metal,\n\\item 8 color types: gray, blue, brown, yellow, red, green, purple, cyan,\n\\end{itemize}\nresulting in 96 unique combinations.\n\nAlong with CLEVR, the authors~\\cite{johnson2017clevr} introduced  CLEVR-CoGenT (Compositional Generalization Test, CoGenT in short), with a goal of evaluating how well the models can generalize, learn relations and compositional concepts.\nThis dataset is generated in the same way as CLEVR with two additional conditions.\nAs shown in \\tableref{tab:cogent_conditions}, in Condition A all cubes are gray, blue, brown, or yellow, whereas all cylinders are red, green, purple, or cyan; in Condition B cubes and cylinders swap color palettes.\nFor both conditions spheres can be any colors.\n\n\n\\begin{table}[b!]\n\t\\centering\n\t\\begin{tabular}{cccc}\n\t\t\\toprule\n\t\tDataset        & Cubes              & Cylinders &  Spheres         \\\\\n\t\t\\midrule\n\t\tCLEVR   &  any color &  any color        &    any color    \\\\\n\t\t%\\midrule\n\t\tCLEVR CoGenT A & gray / blue / brown / yellow  & red / green / purple / cyan       &    any color  \\\\\n\t\tCLEVR CoGenT B  & red / green / purple / cyan &   gray / blue / brown / yellow       &      any color  \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\caption{Colors/shapes combinations present in CLEVR, CoGenT-A and CoGenT-B datasets.}\n\t\\label{tab:cogent_conditions}\n\\end{table}\n\nThe CoGenT dataset contains:\n\\begin{itemize}\n\\item\tTraining set of 70,000 images and 699,960 questions in Condition A,\n\\item\tValidation set of 15,000 images and 149,991 questions in Condition A,\n\\item\tTest set of 15,000 images and 149,980 questions in Condition A (without answers),\n\\item\tValidation set of 15,000 images and 150,000 questions in Condition B,\n\\item\tTest set of 15,000 images and 149,992 questions in Condition B (without answers),\n\\item\tScene graphs and functional programs for all training/validation images/questions.\n\\end{itemize}\n\n", "meta": {"hexsha": "a541afaef2cede3445b5004e5449bf518de08b5e", "size": 3057, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MAC_publications/arxiv/datasets.tex", "max_stars_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_stars_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MAC_publications/arxiv/datasets.tex", "max_issues_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_issues_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MAC_publications/arxiv/datasets.tex", "max_forks_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_forks_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-30T10:13:26.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-30T10:13:26.000Z", "avg_line_length": 54.5892857143, "max_line_length": 238, "alphanum_fraction": 0.7549885509, "num_tokens": 805, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341026367784, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.43019875481583314}}
{"text": "\\chapter{Cart-Pole \\& Mountain-Car}\n\\section{Cart-Pole}\nThe cart-pole environment, which is an implementation of the famous cart-pole problem [7], is a popular AI benchmark that simulates a pole that needs to be balanced on the flat rectangle (cart) that it's attached to. The observation object of this environment includes the velocity and position of the cart, the velocity at the tip of the pole, and the angle of the pole. Initially, these parameters are assigned a random value in the range $[-0.05, 0.05]$, which results in the pole standing almost upright with a slight tilt. The environment only allows two discrete actions (left and right) which the agent uses to balance the pole before it falls over, by pushing the cart without causing it to go off-screen. The environment terminates if the agent fails in either of those tasks, or after the maximum number of time-steps (200) is reached. The agent receives $1$ reward on every time-step until one of these termination criteria is met. Finally, this environment is considered to be solved if the agent achieves an average reward of greater than or equal to $195.0$ over 100 consecutive trials. More details about the various environmental parameters can be found in the environment’s official GitHub Wiki page\\footnote{\\url{https://github.com/openai/gym/wiki/CartPole-v0}}.\n\n\\subsection{Experiment 1: Binary Programs}\nThe goal of the first experiment was to implement the simplest GP algorithm that performs better than a random agent. The simplest language that can encode the actions allowed in this environment is one of 0’s and 1’s, where 0’s represent ‘left’ and 1’s represent ‘right’. The program structure, therefore, included the terminal set \\verb+T = {0, 1}+ and an empty function set. The intuition for this structure was that, in principle, there has to exist a string of left-right actions that manages to balance the pole on the cart most of the time. \n\nThis GP agent did not managed to achieve better-than-random performance: a random agent achieves an average reward of $\\approx22.0$ and the best programs the GP algorithm generated achieved an average reward of $16.76$. The most likely reason for this is that these programs are static, which means they don’t use information about the state of the environment to compute the next action to take. This limitation would not be a problem if the initial state of the environment was always the same, because that would make the state transitions deterministic and, therefore, there would exist a static program that would reliably balance the pole. However, the initial state of the environment is randomised each time the environment starts running and the range of possible values for the various parameters of the environment is sufficiently large, such that no static strategy can perform well.\n\n\\subsection{Experiment 2: Known Strategy}\nThe main goal of the second experiment was to enable the agent to utilise the environment state to choose actions dynamically. At the same time, I wanted to test the capabilities of the GP algorithm, since it would be used to find increasingly complex programs as the environments proved to be more difficult to solve. To achieve both of these goals, a manual strategy was discovered that performed well by utilising the environment state. The program structure of the GP algorithm was also adjusted to allow it to discover the strategy automatically. The chosen strategy can be described as follows:\n\n\\begin{verbatim}\n    if pole_angle <= 0 then push_left() else push_right()\n\\end{verbatim}\n\nIntuitively, this strategy describes the behaviour \"if the pole is leaning to the left, push the cart to the left; if the pole is leaning to the right, push the cart to the right\". This should keep the pole balanced at all times. To test this intuition, I implemented an agent that follows this strategy and tested it on the environment. The agent achieved an average score of $42.0$, a major improvement over the previous agent. Then, I introduced a simple environment-specific language to replace the binary language of the previous experiment, which included variables to represent the environment state and the actions the agent can take, flow-control (if-statements) and comparison operators to allow the agent to make decisions dynamically, and constants for calculations. The function and terminal set used for this experiment were \\verb+F = {IFLTE}+ and \\verb+T = {pa, 0, L, R}+ respectively.\n\nThe function set included a single function, \\verb+IFLTE+ (if-less-than-or-equal), which accepts 4 inputs; if the first input is less than or equal to the second input, it outputs the third input; otherwise, it outputs the fourth input. This functionality seemed sufficient to encode the strategy described above. The terminal set included four elements: the pole angle (\\verb+pa+) used to encode the corresponding environment observation, the numerical constant \\verb+0+ which was required for the comparison performed in the strategy, and the actions \\verb+L+ and \\verb+R+, left and right respectively. The program structure was quite restricted in this first version of the algorithm to make it easier to evaluate and troubleshoot before applying it to more difficult environments that would require a more complex program structure. Specifically, each program was restricted to consist of a single \\verb+IFLTE+ function, which could only accept \\verb+pa+ and \\verb+0+ as its first two arguments, and \\verb+L+ and \\verb+R+ as its third and fourth arguments (figure \\ref{fig:iflte_tree}). It was important to restrict the third and fourth arguments to actions since the output of the program had to be the action the agent would perform in the environment. Therefore, a simple type system was implemented to perform this check. Using this simple functional language, the manually-discovered strategy could be encoded as \\verb+IFLTE(pa, 0, L, R)+.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/simple_iflte_program.png}\n    \\caption{Tree representation of the program structure of the Known Strategy agent}\n    \\label{fig:iflte_tree}\n\\end{figure}\n\nWith these structural restrictions, it was easy for the GP algorithm to converge to the intended strategy (it only required a single generation, and mutation was not needed) because the program space was very small. The exact parameters used for the experiment are summarised in table \\ref{tab:cartpole_exp2_params}.\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameters} & \\textbf{Values} \\\\\n        \\hline\n        Population size     & 10  \\\\\n        Max generations     & 5   \\\\\n        Max program depth   & 1  \\\\\n        Terminal fitness & 195.0 \\\\\n        Number of runs      & 1   \\\\\n        Number of episodes  & 100 \\\\\n        Episode length      & 200  \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Experiment parameters (cart-pole experiment 2)}\n    \\label{tab:cartpole_exp2_params}\n\\end{table}\n\n\\subsection{Experiment 3: Exploration}\n\\subsubsection{Setup and Motivation}\nThe goal of the final experiment was to expand the program space to encourage exploration and allow the algorithm to discover better strategies than the one found manually. The terminal set was extended to include the second observation of the environment, pole velocity (\\verb+pv+), to allow the algorithm to incorporate it in the solution. Additionally, I experimented with constants other than \\verb+0+ and it turned out that the performance was very sensitive to even very small deviations from \\verb+0+. Specifically, I discovered that including the constant \\verb+0.025+ in the terminal set increased the performance of the discovered solutions significantly. Finally, the program structure was adapted to allow for the generation of programs that utilised higher-order functions (i.e. functions that accept functions as arguments) which can be represented as a trees of varying depth (see figure \\ref{fig:deep_iflte_tree} for an example). The extended terminal set was \\verb+T = {pa, pv, 0, 0.025, L, R}+. The parameters used for this experiment are summarised in table \\ref{tab:cartpole_exp3_params}.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/complex_iflte_program.png}\n    \\caption{Tree representation of the program structure of the Exploration agent}\n    \\label{fig:deep_iflte_tree}\n\\end{figure}\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameters} & \\textbf{Values} \\\\\n        \\hline\n        Population size     & 100  \\\\\n        Max generations     & 5  \\\\\n        Max program depth   & 2  \\\\\n        Terminal fitness & 195.0 \\\\\n        Number of runs      & 1   \\\\\n        Number of episodes  & 100 \\\\\n        Episode length      & 200  \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Experiment parameters (cart-pole experiment 3)}\n    \\label{tab:cartpole_exp3_params}\n\\end{table}\n\n\\subsubsection{Results and Discussion}\nThe initial results of this experiment showed that the second observation, pole velocity, was more useful than the pole angle, so programs using \\verb+pv+ instead of \\verb+pa+ tended to dominate the population during the first few generations. The first run of GP converged on the program \\verb+IFLTE(pv, 0, L, R)+, which achieved an average reward of $181.78$. This improvement could be attributed to the fact that the velocity of the pole provided the agent with more useful information than its angle. Using the first strategy (\\verb+IFLTE(pa, 0, L, R)+), if the pole leaned towards, say, the right at the beginning of the run, the agent would begin to push the cart to the right to cause the pole to lean towards the left, bringing it back to the center. The problem with this strategy was that by the time the pole angle became negative (meaning the pole leaned towards the left) it had accumulated too much momentum for the agent to manage to push left to balance it on time. The agent was essentially over-correcting. Using the new strategy, the agent detected which direction the pole was accelerating towards (using the sign of its velocity) and pushed the cart towards that direction for just long enough to prevent the pole from falling over, without over-correcting. However, this strategy was still problematic (as is evident from the imperfect score it achieved) because the agent stopped pushing the cart as soon as the sign of the pole velocity was flipped, so the pole didn't have enough momentum to lean towards the other side, thereby letting it fall towards the same side again. The result of this was that the agent was now under-correcting, balancing the pole perfectly, but at an angle, causing the cart to move until it eventually exited the screen and the environment terminated. It was evident at this point that a solution would involve information about both the pole angle and its velocity.\n\nIncreasing the maximum number of generations from 5 to 10 allowed for more complex solutions to arise. Eventually, the algorithm consistently produced solutions that achieved the reward specified as the solution criterion for the environment. These solutions included programs using nested if statements and combining both observation variables. An example of such a program is:\n\\begin{verbatim}IFLTE(0.025, pa, IFLTE(pv, pv, R, L), IFLTE(0.025, pv, R, L))\\end{verbatim}\nThis program achieves an average reward of $198.74$ over 100 consecutive trials. The following is an equivalent, but more readable, version of the strategy described by this program:\n\n\\begin{verbatim}\nif pa > 0.025 then R else (if pv > 0.025 then R else L)\n\\end{verbatim}\n\nFollowing this strategy, the agent pushed the cart to the right to balance the pole if it was leaning at a right angle greater than some threshold ($0.025$). If the pole was leaning at a left angle or a small right angle, the agent checked the pole's velocity to make its decision: if the pole was accelerating towards the right (\\verb+pv > 0.025+) then the agent pushed right to counteract it; otherwise it pushed left for the same reason.\n\nThis extended version of the program structure allowed the agent to achieve the goal of utilising exploration to find new and better solutions by exploring a larger program space. At this stage, the GP algorithm can incorporate new language extensions as well as additional genetic operators, both of which will be required in the following environments. So, Cart Pole was a useful starting point in showcasing the potential of this approach and establishing a framework for applying it to other RL environments.\n\n\\section{Mountain-Car}\nThe second RL environment attempted, was mountain-car. This environment simulates a car that attempts to climb a steep hill (figure \\ref{fig:mountain-car}). There are two versions of this environment, one in which the actions the agent can take are discrete (similar to cart-pole) and one in which they are continuous (the action is a number that represents the magnitude of the force the agent applies to the car). The former is, in principle, easier to solve because there are fewer possible actions and, therefore, fewer strategies to explore before discovering a solution. The discrete version of the environment was attempted first with the hope that a solution to the simpler environment could be used as a basis for the more complex one.\n\n\\subsection{Experiment 1: Discrete Actions}\nFor the discrete version of this environment, I used the same parameters as in cart-pole experiment 3, and a similar program structure, adapted to the details of this environment:\n\n\\begin{verbatim}\nF = {IFLTE}\nT = {position, velocity, 0.0, 0, 1, 2}\n\\end{verbatim}\nThe terminals \\verb+position+ and \\verb+velocity+ represent the corresponding environment observations, \\verb+0.0+ is a numerical constant used for comparisons (similar to cart-pole), and \\verb+0+, \\verb+1+, and \\verb+2+ encode the discrete action space of the environment (push left, no action, and push right respectively).\n\nIn fewer than $10$ generations, the GP algorithm found the simple and intuitive program \\\\\\verb+IFLTE(0.0, velocity, 2, 0)+, which achieves a fitness score of approximately $-120$, which is very close to the requirement for a solution, $-110$. This program encodes the strategy “if the velocity of the car is positive, push the car to the right (i.e. increase its velocity), otherwise push it to the left (i.e. decrease its velocity).” The agent effectively swings the car back and forth, maximising its momentum, until it can reach a high enough velocity to climb the hill and reach the goal. \n\n\\subsection{Experiment 2: Continuous Actions}\nThe interpretable nature of the strategy found for the discrete version of this environment makes it reasonable to hypothesise that the same strategy should perform well on the continuous version of this environment. The same principle of applying a force proportional to the car’s velocity can be used, so the only required modification is changing the value of this applied force to a continuous value in the range $[0.0, 1.0]$, which defines the action space of this environment. \n\nThe problem then becomes a simple numerical optimisation problem with one variable. Evaluating the program using all values in $[0.0, 1.0]$ with a $0.001$ increment, reveals that the optimal force is $0.180$, which produces an average fitness score of $98.80$, which is greater than the requirement for a solution ($90$). The complete set of results is visualised in figure \\ref{fig:mountain_car_cont}, which shows that values between $0.0$ and $0.179$ produce negative fitness scores (the car is unable to reach the goal), and values after $0.180$ linearly decrease performance. The reason for the negative values at the beginning of the range is that the force applied to the car is not great enough to eventually allow it to climb the hill, so it only receives negative rewards from the environment on every time step. The optimal value is the smallest amount of force necessary to eventually allow the car to climb the hill, which satisfies the requirement of the environment (reaching the goal with the minimum amount of effort). Every value greater than the optimal increases the amount of effort beyond what is necessary for the goal to be achieved and, therefore, reduces the overall fitness score.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=12cm]{images/mountaincarcont.png}\n    \\caption{The x-axis represents the magnitude of the for applied to the car (multiplied by 1000) and the y-axis represents the average reward achieved using that magnitude.}\n    \\label{fig:mountain_car_cont}\n\\end{figure}\n\nThe simple and intuitive nature of this solution is further confirmation that GP is a suitable approach for solving (at least simple) RL environments. Another interesting feature of this program is its similarity to the solution for cart-pole, despite the differences between the environments. This is an indication that environments that share common characteristics (e.g. classic control environments) might be solvable using similar solutions.\n", "meta": {"hexsha": "038e418c36538c1bfb47ea9de210d88ba6be49dc", "size": 17126, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/cartpole_mountaincar.tex", "max_stars_repo_name": "alexgeorgousis/gp-for-interpretable-rl", "max_stars_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-31T10:12:58.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-31T10:12:58.000Z", "max_issues_repo_path": "report/cartpole_mountaincar.tex", "max_issues_repo_name": "alexgeorgousis/GP-for-interpretable-RL", "max_issues_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/cartpole_mountaincar.tex", "max_forks_repo_name": "alexgeorgousis/GP-for-interpretable-RL", "max_forks_repo_head_hexsha": "d02f97d10c5fcf13151ea3390a46830a17294e18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-12T14:41:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-12T14:41:42.000Z", "avg_line_length": 141.5371900826, "max_line_length": 1919, "alphanum_fraction": 0.7785238818, "num_tokens": 3738, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4301987460025898}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Initial Data Problem}\n\n\\marginpar{Tuesday\\\\ 2021-6-1, \\\\ compiled \\\\ \\today}\n\nIt is perhaps the most difficult problem currently. \n\nThe problem is stated as \n%\n\\begin{align}\nC_0 &= R + K^2 - K_{ij} K^{ij} - 16 \\pi E = 0  \\\\\nC_i &= D_j K^{j}_{i} - D_i K - 8 \\pi P_i = 0\n\\,,\n\\end{align}\n%\nand we want to calculate \\(\\gamma_{ij}\\) and \\(K_{ij} \\) on \\(\\Sigma _0\\) such that \n\\begin{enumerate}\n    \\item the constraints are satisfied;\n    \\item the solution is physically meaningful: it really describes a BH, BBH, \\(n\\)-BH, NS spacetime.\n\\end{enumerate}\n\nWe will assume for today that the matter fields are given or zero --- in general one would have to solve the hydrodynamic equations for them as well.\n\nWe have 4 equations for 12 unknowns!\nWe will need to prescribe 8 quantities.\n\nThe problem is split in two: a problem of constrained data (4)\nand one of free data (8). \n\nThe choice of free data is guided by a few principles: \n\\begin{enumerate}\n    \\item we need to define our (astro)physical expectations for \\(\\Sigma_0 \\) and verify that they are matched;\n    \\item we need some heuristic or intuition for the various fields;\n    \\item mathematical (/ computational?) necessity: the equations \\(C_\\alpha = 0\\) should be as nice as possible --- linearity, decoupling, well-posedness are all desirable. \n\\end{enumerate}\n\nThe \\textbf{Conformal Decomposition} allows us to implement these. \nWithin it, there are two main formalisms: one is the ``conformal/transverse traceless'' formalism (CTT), due to York in 1973; the other is the ``conformal/thin sandwich'' (CTS), also due to York in 1999.\nBoth are based off of early work by Lichnerowicz. \n\nThe CTS formalism is often used to generate binary systems --- it makes it easier to implement the quasi-symmetries there. \n\nWe start from the Lichnerowicz equation (the Hamiltonian constraint): \n%\n\\begin{align}\nC_0 &= \\widetilde{D}_i \\widetilde{D}^{i} \\psi \n- \\frac{1}{8} \\hat{A}_{ij} \\hat{A}^{ij} \\psi^{-7} +\n\\qty(- \\frac{K^2}{12} + 2 \\pi E) \\psi^{5} &= 0\n\\,,\n\\end{align}\n%\nwith \\(p = -10\\). \nLet us solve it as a standalone equation: it is a Poisson-like one, since \\(\\widetilde{D}_i \\widetilde{D}^{i}\\) is similar to a Laplacian. \nThen, this is some sort of elliptic operator applied to \\(\\psi \\) equated to some powers of \\(\\psi \\). \n\nIf \\(K^2= 0\\) the equation simplifies, and the BVP can be studied: there are several known results about the well-posedness of this equation under the hypothesis \\(K = \\const\\).\n\nThese are known as Constant Mean Curvature (CMC) spacetimes. \n\nIf we take an Asymptotically Flat, CMC spacetime with \\(K = 0\\), and with \\(E = 0\\), then the BVP with the Lichnerowicz equation is \\emph{solvable} for a ``large'' class of metrics \\(\\widetilde{\\gamma}_{ij}\\) (a ``positive Yamabi class''). \n\nThere is a ``prototype equation'' for the Lichnerowicz one if we set \\(K = 0\\): \n%\n\\begin{align}\n\\triangle u = f^2 u^{p}\n\\,,\n\\end{align}\n%\nin flat spacetime, for some function \\(f\\).\n\nThese theorems are found in somewhat specialized PDE literature.\nIn the linear case \\(p = 1\\), and we take \\(\\eval{u}_{\\partial \\Omega } = 0\\), then the solution, identically zero, is unique. \n\nIn the nonlinear case, the solution is unique iff \\(p > 0\\) (or specifically, the same sign of the coefficient of the \\(f^2 u^{p}\\) term). \n\nSo, what about the Lichnerowicz equation? \nThe easiest thing to do is to linearize the equation: we write it as \n%\n\\begin{align}\n\\widetilde{\\triangle} \\psi + H (\\psi ) = 0\n\\,.\n\\end{align}\n\nWe write \\(\\psi = \\psi_0 + \\epsilon \\), and expand \n%\n\\begin{align}\nH(\\psi ) = H(\\psi_0 ) + \\eval{\\pdv{H}{\\epsilon }}_{0} \\epsilon + \\order{\\epsilon^2}\n\\,,\n\\end{align}\n%\nso we find an equation in the form \\(\\widetilde{\\triangle} \\epsilon = f \\epsilon \\) with: \n%\n\\begin{align}\nf = \\frac{1}{8 } \\widetilde{R} + \\frac{7}{8} \\hat{A}_{ij} \\hat{A}^{ij} \\psi_0^{-8} - 10 \\pi E \\psi_0^{4}\n\\,.\n\\end{align}\n\nThis immediately shows us the problem: if \\(K =0 \\) then \\(\\widetilde{R} > 0\\), but we can check that \\(f\\) is not positive, because of the ``matter term''! \n\nHowever, we insist on solving this equation, and we can do so as long as we \\emph{rescale} the matter term. \n\nIf we define \\(\\widetilde{E} = \\psi^{s} E\\), then, the term becomes \n%\n\\begin{align}\n- 5 \\times 2 \\pi E \\psi_0^{4} \\to - (s \\times 5) 2 \\pi \\widetilde{E} \\psi^{4-s}\n\\,,\n\\end{align}\n%\nso this is \\(> 0\\) for any \\(s > 5\\). \nThis is \\emph{not} a trick: in practice, these elliptic equations are solved by iteration --- specifying a guess, and then iterating. \n\nSpecifying the ``correct'' RHS therefore is key if we want to find a solution. \nSo, what do we use? \nThe best answer turns out to be 8: if we do this, we can express the dominant energy condition in conformal variables: if\n%\n\\begin{align}\n\\widetilde{E} = \\psi^{8} E\n\\qquad \\text{and} \\qquad\n\\widetilde{P}^{i} = \\psi^{10} P^{i}\n\\,,\n\\end{align}\n%\nthen \\(\\widetilde{E}^2 \\geq \\widetilde{P}^2\\) implies \\(E^2 \\geq P^2\\). In general this would read \n%\n\\begin{align}\n\\psi^{2s} E^2 \\geq \\psi^{-4} \\psi^{10} \\psi^{10} P^2\n\\,.\n\\end{align}\n\n\\subsection{Maximal Slicing}\n\nWhat does it mean to impose \\(K = 0\\)? \nAs we will see shortly, this is a gauge condition which extremizes the volume of \\(\\Sigma _t\\). \n\nWe just need to remember the definition of the trace: it is an identity that\n%\n\\begin{align}\nK = \\gamma^{ab} K_{ab} = - \\frac{1}{2 \\alpha } \\gamma^{ij} \\mathscr{L}_m \\gamma_{ij} = - \\frac{1}{2 \\alpha } \\mathscr{L}_m \\log \\gamma \n\\,,\n\\end{align}\n%\nwhich can be nicely written as \n%\n\\begin{align}\nK = - \\frac{1}{\\alpha } \\mathscr{L}_m \\log \\sqrt{\\gamma } \n\\,,\n\\end{align}\n%\nso we recover the volume element on \\(\\Sigma _t\\), \\(\\sqrt{\\gamma }\\)! \n\nThe volume in a certain region is \\(V = \\int \\sqrt{\\gamma } \\dd[3]{x}\\), so if we perform a variation \\(v^{a} = \\delta t \\qty(\\alpha n^a + \\beta^{a})\\), so that \\(\\eval{v^{a}}_{S} = 0\\) (the deformation is zero at the boundary), the volume changes as such: \n%\n\\begin{align}\n\\fdv{V}{t} &= \\int \\partial_{t} \\sqrt{\\gamma } \\dd[3]{x}\n= \\int \\qty(- \\alpha K + D_i \\beta^{i}) \\dd[3]{x}\n\\marginnote{Using the kinematic equation.}  \\\\\n&= - \\int_V \\alpha K \\sqrt{\\gamma } \\dd[3]{x} + \\underbrace{\\oint_S \\beta^{i} S_i}_{= 0}\n= - \\int \\alpha K \\sqrt{\\gamma } \\dd[3]{x}\n\\,,\n\\end{align}\n%\ntherefore \\(K = 0\\) yields \\(\\delta V = 0\\): this is a maximum.\n\nIt is the exact same geometric problem as a film of soap. \nIf the soap is held at a ring, it stays flat. \n\nThe only difference from that case is that here we are in a Lorentzian geometry: in the Euclidean case we have a minimum, here we have a maximum. \n\nThis is an example of a singularity-avoiding gauge, used by many works. \n\n\\subsection{The Conformal Transverse Traceless formalism}\n\nWe use the \\(p = -10\\) scaling of \\(K_{ij}\\), and on top of the Lichnerowicz equation we derive an equation from the momentum constraint \\(C_i = 0\\), for a vector \\(x^{i}\\) which is obtained with a further decomposition of \\(\\hat{A}^{ij}\\): \n%\n\\begin{align}\n\\hat{A}^{ij} = \\hat{A}^{ij}_L + \\hat{A}^{ij}_{TT}\n\\,,\n\\end{align}\n%\nwhere the TT part is transverse and traceless: \\(\\widetilde{\\gamma}_{ij} \\hat{A}^{ij}_{TT} = 0\\) and \\(\\widetilde{D}_j \\hat{A}^{ij}_{TT} = 0\\).\n\nThe longitudinal part on the other hand is expressed as follows: \n%\n\\begin{align}\n\\qty(\\widetilde{L} x)^{ij} = \\widetilde{D}^{i} x^{j} + \\widetilde{D}^{j} x^{i} - \\frac{2}{3} \\widetilde{D}_k x^{k} \\widetilde{\\gamma}^{ij}\n\\,.\n\\end{align}\n\nThis seems like a rather strange expression: \\(\\widetilde{L}\\) is called the \\textbf{Conformal Killing operator} on \\(x^{i}\\). \nIt is determined as follows: \n%\n\\begin{align}\n\\widetilde{D}_j  \\hat{A}^{ij} = \n\\widetilde{D}_j  \\qty(\\widetilde{L} x)^{ij} \n= \\widetilde{D}_j  \\widetilde{D}^{j} x^{i} \n+ \\frac{1}{3} \\widetilde{D}^{i} \\widetilde{D}_j x^{i} + \\widetilde{R}^{i}{}_j x^{i} = \\widetilde{\\triangle}_L x^{i} \n\\,,\n\\end{align}\n%\nwhere \\(\\widetilde{\\triangle}_L x^{i}\\) is the \\textbf{conformal vector Laplacian operator}. \n\nThere exists a unique L + TT decomposition of \\(\\hat{A}^{ij}\\) iff there exists a unique solution of the conformal Laplacian equation: \n%\n\\begin{align}\n\\widetilde{\\triangle}_L x^{i} = \\widetilde{D}_j \\hat{A}^{ij}\n\\,.\n\\end{align}\n\nThis is useful because there is a theorem by Cantor in 1979 which tells us that if \\(\\Sigma \\) is asymptotically flat and we have \\(\\partial_{k} \\partial_{l} \\widetilde{\\gamma}_{ij} = \\order{r^{-3}}\\), \nthen existence and uniqueness are guaranteed. \n\nWith this decomposition, we obtain \n%\n\\begin{align}\n\\widetilde{\\triangle}_L x^{i} - \\frac{2}{3} \\widetilde{D}^{i} K \\psi^{6} - 8 \\pi \\widetilde{P}^{i} = 0\n\\,,\n\\end{align}\n%\nwhich can be solved together with the Lichnerowicz equation. \nThis allows us to constrain \\(\\psi\\) and \\(x^{i}\\), as long as we determine the free data: \\(\\widetilde{\\gamma}_{ij}\\), \\(\\hat{A}^{ij}_{TT}\\) and \\(K\\). \n\nUnder maximal slicing, \\(K = 0\\), the two equations decouple! \nThey also partially decouple if we take \\(K = \\const\\), since we can solve one and then the other.\n\nAlso, it is nice that the free data are the conformal metric: \\(\\widetilde{\\gamma}_{ij}\\) and \\(\\hat{A}_{TT}^{ij}\\) are useful in heuristically determining the GW content of \\(\\Sigma \\). \n\nLet us give an example of CTT data under the four hypotheses of conformal flatness, asymptotic flatness, and maximal slicing. \n\nAsymptotic flatness is chosen because we want the solution to exist.\nThis is the simplest choice of free data: we take \\(\\hat{\\gamma}_{ij} = f_{ij}\\) (conformal flatness) and \\(K = 0\\) (maximal slicing).\n\nFurther, we consider \\(E = 0 = P^{i}\\) (vacuum). \n\nWithout justification we also assume that \\(\\hat{A}^{ij}_{TT} = 0\\). \n\nUnder all these assumptions we have \n%\n\\begin{align}\n\\widetilde{D}_i = D_i \n\\,,\n\\end{align}\n%\ntherefore \n%\n\\begin{align}\n\\widetilde{D}_i \\widetilde{D}^{i} = D_i D^{i} = \\triangle\n\\,\n\\end{align}\n%\nis simply the flat elliptic operator, also \\(\\widetilde{R} = 0\\) and \\(\\widetilde{L} = L\\) is the one calculated in the flat case. \n\nSo, the CTT equations become: \n%\n\\begin{align}\n\\triangle \\psi + \\frac{1}{8} \\qty(Lx )_{ij} \\qty(Lx)^{ij} \\psi^{-7} &= 0  \\\\\n\\triangle_L x^{i} = \\triangle x^{i} + \\frac{1}{3} D_j D^{i} x^{j} &= 0\n\\,,\n\\end{align}\n%\nwhich are decoupled, so they can be solved independently of one another. \nThey are ``easy'', since they use the flat Euclidean operators. \nIf we want a boundary value problem we also need to specify the boundaries: we specify asymptotic flatness: \\(\\psi = 1\\) and \\(x^{i} = 0\\) at \\(\\iota_0\\). \n\nOptionally we can impose strong-field inner boundary conditions: for example we can fix the topology. \n\nOur \\textbf{case 1} is to take \\(\\Sigma_0 = \\mathbb{R}^{3}\\) (no inner boundary condition): then, the solution of the second CTT equation is \\(x^{i}= 0\\), and the first one reads \\(\\triangle \\psi = 0\\) together with \\(\\psi = 1\\) at \\(\\iota_0 \\): this implies \\(\\psi \\equiv 1\\).\nAs expected, we recover flat spacetime. \n\nCan we also get a nontrivial solution? \nFor that, we need an inner boundary. \n\n\\end{document}\n", "meta": {"hexsha": "002478fae3c481405053b2063e80cd5f54cd7d71", "size": 11010, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd_courses/numerical_relativity/jun01.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "phd_courses/numerical_relativity/jun01.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd_courses/numerical_relativity/jun01.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 40.0363636364, "max_line_length": 277, "alphanum_fraction": 0.6715712988, "num_tokens": 3695, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.63341024983754, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.4301987413025714}}
{"text": "% BReviewofLinearAlgebra.tex\n% Fund Science! & Help Ernest finish his Physics Research! : quantum super-A-polynomials - a thesis by Ernest Yeung\n%                                               \n% http://igg.me/at/ernestyalumni2014                                                                             \n%                                                              \n% Facebook     : ernestyalumni  \n% github       : ernestyalumni                                                                     \n% gmail        : ernestyalumni                                                                     \n% google       : ernestyalumni                                                                                   \n% linkedin     : ernestyalumni                                                                             \n% tumblr       : ernestyalumni                                                               \n% twitter      : ernestyalumni                                                             \n% youtube      : ernestyalumni                                                                \n% indiegogo    : ernestyalumni                                                                        \n%\n% Ernest Yeung was supported by Mr. and Mrs. C.W. Yeung, Prof. Robert A. Rosenstone, Michael Drown, Arvid Kingl, Mr. and Mrs. Valerie Cheng, and the Foundation for Polish Sciences, Warsaw University.                  \n\n\n\n\\section{Review of Linear Algebra }\n\n\\subsection{Linear Maps}\n\n\\exercisehead{B.1}\n\\begin{enumerate}\n  \\item[(a)]\n\\item[(b)]\n\\item[(c)]\n\\item[(d)] \\textbf{Want}: if $(v_1 \\dots v_k)$ linearly dependent $k$-tuple in $V$, $v_1 \\neq 0$, \\\\\nthen some $v_i = \\sum_{j=1}^{i-1} c^j v_j$ \\\\\n\\begin{proof}\n$(v_1 \\dots v_k)$ linearly dependent, so if $\\sum_{i=1}^k a^i v_i = 0$, $a^i$ not all equal to $0$.  \\\\\n\nSuppose for fixed $i$, $2\\leq i \\leq k$, $a^{i+1} = \\dots =a^k=0$. \\\\\n\\quad Indeed, suppose for $\\sum_{i=1}^k a^i v_i = 0$, $a^2 = \\dots = a^k = 0$.  $a^1 v_1 =0$, $v_1 \\neq 0$, $a^1 =0$.  Then $(v_1 \\dots v_k)$ linearly independent.  Contradiction.  \n\nif $i=2$, \\\\\n\\phantom{\\quad} $a^1 v_1 + a^2 v_2 =0$ \\\\\n\\phantom{\\quad \\,} $\\Longrightarrow v_2  = \\frac{-a^1}{a^2} v_1$ \\\\\n\nif $i=k$, $v_k = \\frac{ -\\sum_{i=1}^{k-1} a^i v_i }{ a^k}$  \\\\\n\nSo in general, $v_i = \\frac{ -\\sum_{j=1}^{i-1} a^j v_j }{ a^i}$\n\\end{proof}\n\\end{enumerate}\n\n\\exercisehead{B.9}\ngiven $(E_1 \\dots E_n)$ basis for $V$ \\\\\n\\phantom{ \\quad } $\\exists \\, \\lbrace i_1 \\dots i_k \\rbrace \\subset \\lbrace 1 \\dots n \\rbrace$ s.t. \\\\\n\\phantom{ \\quad \\, } $ \\text{span}(E_{i_1} \\dots E_{i_k} )$ is complement to $S$ \\\\\n\nHence $\\forall \\, $ subspace $S \\subseteq V$, $\\exists \\, $ complementary subspace $T$ in $V$, so $V = S \\oplus T$\n\n\\begin{proof}\n$\\forall \\, $ subspace $S$ is itself a vector space, closed under addition and multiplication. \\\\\n\\phantom{ \\quad } Hence $S$ has basis $(F_1 \\dots F_m)$ with $\\text{dim}S = m$ \\\\\n\nConsider ordered $(m+n)$-tuple \n\\[\n(F_1 \\dots F_m, E_1 \\dots E_n)\n\\]\n\n$(F_1 \\dots F_m, E_1 \\dots E_n)$ linearly dependent in $V$, by linear algebra. \n\nFor $j_1 \\in \\lbrace 1 \\dots n \\rbrace$, $E_{j_1}$ linear combination of previous vectors (cf. Exercise B.1(d)) \\\\\n\\phantom{ \\quad } eliminate $E_{j_1}$ : $(F_1 \\dots F_m, E_1 \\dots \\widehat{E}_{j_1} \\dots E_n )$. \\\\\n\nRepeat, until there are $n-m$ $E$ basis vectors left, labeled $i_1 \\dots i_{n-m}$ (hence \\textbf{use Exercise B.1(d)} many and enough times, $m$ times)\n\\[\n\\Longrightarrow (F_1 \\dots F_m, E_{i_1} \\dots E_{i_{n-m}} )\n\\]\nBy linear algebra, $(F_1 \\dots F_m, E_{i_1} \\dots E_{i_{n-m}})$ a basis for $V$, linearly independent. The procedure wouldn't have ``overshot'' by a Thm. (see Apostol's \\textbf{Calculus} Vol. 2, first few chapters, linear algebra part) \\\\\n\n$\\forall \\, v\\in V$, $v= a^iF_i  + b^{i_j} E_{i_j}$ with $a^i F_i \\in S$.  Then $b^{i_j} E_{i_j} \\in T$.  \\\\\n\\phantom{ \\quad } since $V = S\\oplus T$, $T$ complement to $S$\n\n$\\Longrightarrow $ given fixed basis of $V$, $(E_1 \\dots E_n)$, subspace $S \\subseteq V$, $S$ having basis $(F_1 \\dots F_m)$, $S$ has complementary subspace in $V$, $T$, \\\\\n\\phantom{ \\quad } s.t. basis of $T$ is $(E_{i_1} \\dots E_{i_{n-m}})$ and $V = S\\oplus T$\n\n\\end{proof}\n\n\n\\exercisehead{B.13}  Suppose $\\exists \\, $ linear $T: V \\to W $ s.t. $T(E_i) = w_i$, \\quad \\, $i = 1 \\dots n$ \\\\\nSuppose $\\exists \\, $ linear $T':V \\to W$ s.t. $T'(E_i)= w_i$, \\quad \\, $i = 1 \\dots n$\n\nLet $x\\in V$, so $x  = x^i E_i$ (the key idea is that with a basis, the vector space is completely determined, vectors in the vector space are spanned by the basis elements)\n\\[\n(T-T')(x) \\equiv T(x) - T'(x)  = x^i w_i - x^i w_i = 0\n\\]\n$T(x) = T'(x)$\\quad \\, $\\forall \\, x \\in V$ \\\\\nso $T=T'$.  $T$ unique.  \n\n$T$ exists by construction.\n\\hrulefill\n\n\n\\textbf{ affine subspace } of $V$ parallel to $S$, linear subspace $S \\subseteq V$, $v + S = \\lbrace v + w | w \\in S \\rbrace$, some fixed $v \\in V$ \\\\\n\n\\textbf{affine map } $F: V \\to W$ if $F(v) = w + Tv$ for some $T: V \\to W$, some fixed $w\\in W$ \\\\\n\n\\exercisehead{B.16}\n\nLet $a,b \\in \\mathbb{C}$, $x, y \\in F(V)$ \\\\\n\nNow \n\\[\nF(V) = \\lbrace y | y = w + Tv = F(v), \\, v \\in V, \\text{ fixed } w \\in W , \\text{ some } T \\rbrace\n\\]\n\n\\subsubsection{Change of Basis}\n\n\n\n\n\\exercisehead{B.22} Suppose $V,W, X$ finite-dim. vector spaces \\\\\n$S:V\\to W$, \\, $T:W \\to X$\n\n\\begin{enumerate}\n\\item[(a)] $\\text{rank}S \\leq \\text{dim}V$ \\quad \\, $\\text{rank}S = \\text{dim}V$ iff $S$ injective\n\\item[(b)] $\\text{rank}S \\leq \\text{dim}W$ \\quad \\, $\\text{rank}S = \\text{dim}W$ iff $S$ surjective\n\\item[(c)] if $\\text{dim}V = \\text{dim}W$ and $S$ either injective or surjective, then $S$ isomorphism \n\\item[(d)] $\\text{rank}TS \\leq \\text{rank}S$ \\quad \\, $\\text{rank}TS = \\text{rank}S$ iff $\\text{im}S \\bigcap \\text{ker}T = 0$ \n\\item[(e)] $\\text{rank}TS \\leq \\text{rank}T$ \\quad \\, $\\text{rank}TS = \\text{rank}T$ iff $\\text{im}S + \\text{ker}T = W$\n\\item[(f)] if $S$ isomorphism, then $\\text{rank}TS = \\text{rank}T$\n\\item[(g)] if $T$ isomorphism, then $\\text{rank}TS = \\text{rank}S$\n\\end{enumerate}\n\nEY : Exercise B.22(d) is useful for showing the chart and atlas of a Grassmannian manifold, found in the More examples, for smooth manifolds.  \n\n\\begin{proof}\n\\begin{enumerate}\n\\item[(a)]\n\\item[(b)]\n\\item[(c)]\n\\item[(d)] Now \n\\[\n\\begin{aligned}\n  & \\text{dim}V = \\text{rank}TS + \\text{nullity}TS \\\\ \n  &  \\text{dim}V = \\text{rank}S + \\text{nullity}S\n\\end{aligned}\n\\]\n$\\text{ker}S \\subseteq \\text{ker}TS$, clearly, so $\\text{nullity}S \\leq \\text{nullity}TS$ \n\\[\n\\Longrightarrow \\boxed{ \\text{rank}TS \\leq \\text{rank}S } \n\\]\n\nIf $\\text{rank}TS = \\text{rank}S$, \\\\\n\\phantom{ \\quad } then $\\text{nullity}S = \\text{nullity}TS$ \\\\\n\\phantom{ \\, } Suppose $w \\in \\text{Im}S \\bigcap \\text{ker}T$, $w \\neq 0$ \\\\\n\\phantom{ \\quad } Then $\\exists \\,  v\\in S$, s.t. $w = S(v)$ and $T(w)=0$ \\\\\n\\phantom{ \\quad \\, } Then $T(w) = TS(v) =0$.  So $v\\in \\text{ker}TS$ \\\\\n\\phantom{ \\quad \\quad \\, } $v\\notin \\text{ker}S$ since $w = S(v) \\neq 0$ \\\\\n\\phantom{ \\quad \\quad \\, } This implies $\\text{nullity}TS > \\text{nullity}S$.  Contradiction. \\\\\n$\\Longrightarrow \\text{Im}S \\bigcap \\text{ker}T =0$ \\\\\n\nIf $\\text{Im}S \\bigcap \\text{ker}T =0$, \\\\\n\\phantom{ \\quad } Consider $v \\in \\text{ker}TS$.  Then $TS(v)=0$.  \\\\\n\\phantom{ \\quad  Consider $v \\in \\text{ker}TS$}.  Then $S(v)  \\in \\text{ker}T$ \\\\\n\\phantom{ \\quad  } $S(v) =0$; otherwise, $S(v) \\in \\text{Im}S$, contradicting given $\\text{Im}S \\bigcap \\text{ker}T =0$ \\\\\n\\phantom{ \\quad \\quad } $v\\in \\text{ker}S$ \\\\\n\n$\\text{ker}TS \\subseteq \\text{ker}S$\\\\\n$\\Longrightarrow \\text{ker}TS = \\text{ker}S$ \\\\\nSo $\\text{nullity}TS = \\text{nullity}S$  \\\\\n$\\Longrightarrow \\text{rank}TS = \\text{rank}S$ \n\n\\item[(e)]\n\\item[(f)]\n\\item[(g)]\n\\end{enumerate}\n\\end{proof}\n\n\n\n\\subsection*{Inner Products and Norms}\n\n\n\\subsubsection*{Norms}\n\nIf $V$ real vector space, \\\\\n\\phantom{\\quad } norm on $V$, $v \\mapsto |v| \\in \\mathbb{R}$ s.t.\n\\begin{enumerate}\n\\item[(i)] \\textsc{Positivity} $|v| \\geq 0$, \\, $\\forall \\, v \\in V$, $|v| =0$ iff $v=0$ \n\\item[(ii)] \\textsc{Homogeneity} $|cv| = |c| |v|$ \\quad \\, $\\forall \\, c \\in \\mathbb{R}$, $v\\in V$\n\\item[(iii)] \\textsc{Triangle Inequality} $|v+w | \\leq |v| + |w|$, \\, $\\forall \\, v,w \\in V$\n\\end{enumerate}\n\n2 norms $| \\, \\cdot \\, |_1$, $| \\, \\cdot \\, |_2$ on vector space $V$ equivalent if $\\exists \\, $ constants $c,C >0$ s.t. \n\\[\nc|v|_1 \\leq |v|_2 \\leq C|v|_1 \\quad \\quad \\, \\forall \\, v \\in V\n\\]\n\n\\exercisehead{B.49} $\\forall \\, x \\in V$, \\\\\nConsider $B_r(x) = \\{ y \\in V | |y-x|_2 < r \\}$ \\\\\n\\phantom{ \\quad } Note $y-x \\in V$ as $V$ is a vector space\n\n\\[\n\\begin{gathered}\n  c|y-x|_1 \\leq |y-x|_2 \\leq C |y-x|_1 \\\\ \n c|y-x|_1 \\leq |y-x_2| < r \\\\\n |y-x|_1 < \\frac{r}{c}\n\\end{gathered}\n\\]\nNow suppose $S \\subseteq V$ open in $| \\, \\cdot \\, |_2$ \\\\\n\\phantom{ \\quad } But $S$ also open in $| \\, \\cdot \\, |_1$ as $\\exists \\, \\frac{r}{c'} >0$ s.t. $B_{\\frac{r}{c'}}(x) \\subseteq S$ for the exact same pts. as $S$ \\\\\nso $| \\, \\cdot \\, |_1, | \\, \\cdot \\, |_2$ equivalent norms yield the same metric topology.  \n\nEY : 20141220\n\n\n\n\\subsection*{Direct Products and Direct Sums}\n\n\n\n", "meta": {"hexsha": "b85a7214feaf2887138c27af54013e698ca4ef01", "size": 9069, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LeeJM/BReviewofLinearAlgebra.tex", "max_stars_repo_name": "mhaaab/mathphysics", "max_stars_repo_head_hexsha": "0ebaec62df78d2c9fa5a143aef9d3fc96af5e72e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-21T22:12:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-21T22:12:05.000Z", "max_issues_repo_path": "LeeJM/BReviewofLinearAlgebra.tex", "max_issues_repo_name": "mhaaab/mathphysics", "max_issues_repo_head_hexsha": "0ebaec62df78d2c9fa5a143aef9d3fc96af5e72e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LeeJM/BReviewofLinearAlgebra.tex", "max_forks_repo_name": "mhaaab/mathphysics", "max_forks_repo_head_hexsha": "0ebaec62df78d2c9fa5a143aef9d3fc96af5e72e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.9861111111, "max_line_length": 238, "alphanum_fraction": 0.5498952475, "num_tokens": 3380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.4301903037166475}}
{"text": "\\section{Introduction}\n\tThe aim of this project is to familiarize with different methods to solve an Asymmetric Travelling Salesman Problem.\n\t\\begin{itemize}\n\t\t\\item Exact method that gives the optimal solution. This is implemented with the CPLEX API.\n\t\t\\item Meta heuristic methods: local search and tabu search.\n\t\\end{itemize}\n\n\t\\subsection{Problem}\n\t\tThe combinatorial optimization problem was:\n\t\t\\begin{quote}\n\t\t\t\tA company produces boards with holes used to build electric frames.  Boards are positioned over a machines and a drill moves over the board, stops at the desired positions and makes the holes.  Once a board is drilled, a new board is positioned and the process is iterated many times.  Given the position of the holes on the board, the company asks us to determine the hole sequence that minimizes the total drilling time, taking into account that the time needed for making an hole is the same and constant for all the holes.\n\t\t\\end{quote}\n\t\n\t\tThis problem can be modelled as an Asymmetric Travelling Salesman Problem. The salesman is represent by the drill and cities by the holes in the board.\n\t\t\n\t\\subsection{Attachments}\n\t\tI attach to this report the folders:\n\t\t\\begin{itemize}\n\t\t\t\\item \\verb|RealInstances|: it contains the \\verb|.dat| and the information pdf of the real instances tested;\n\t\t\t\\item \\verb|Results|: it contains the pdf of all results taken, the most interesting data is included in this report. It should not be necessary to consult it, I attached them for completeness;\n\t\t\t\\item \\verb|Programs|: it contains the source code and executables of the two programs require by the assignment.\n\t\t\\end{itemize}\n\t\n\t\\subsection{System of testing}\n\t\tAll the computation are be made on the following system:\n\t\t\\begin{itemize}\n\t\t\t\\item OS: Ubuntu 16.04 LTS (64 bit);\n\t\t\t\\item Hardware: RAM 8 GB, CPU Intel Core i5-7500 3.40 GHz.\n\t\t\\end{itemize}\n\t\n\t\\subsection{Document structure}\n\t\tThe first part of reports show how the exact method, the local search and the tabu search were been implemented with C++ code. In the second part it describes the test done and it shows the results obtained. There are two test sections, one with instances originated from random generator and one with real instances generated from real gerber (the standard format for represent PBCs) files.", "meta": {"hexsha": "ccca510b5d38a2ba87bc726a15987342f8cdfb6f", "size": 2301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/intro.tex", "max_stars_repo_name": "EduBic/TSP-MetaheuristicSolvers-Documentation", "max_stars_repo_head_hexsha": "2c6952f5ad5afbd5469b4223311be5781073c953", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-02-15T13:53:04.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-12T14:10:08.000Z", "max_issues_repo_path": "sections/intro.tex", "max_issues_repo_name": "EduBic/TSP-MetaheuristicSolvers-Documentation", "max_issues_repo_head_hexsha": "2c6952f5ad5afbd5469b4223311be5781073c953", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/intro.tex", "max_forks_repo_name": "EduBic/TSP-MetaheuristicSolvers-Documentation", "max_forks_repo_head_hexsha": "2c6952f5ad5afbd5469b4223311be5781073c953", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.90625, "max_line_length": 530, "alphanum_fraction": 0.7753150804, "num_tokens": 548, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.7549149868676284, "lm_q1q2_score": 0.430190295829247}}
{"text": "\\section{Evaluation}\\label{sec:evaluation:krap}\n\nEvaluating \\krap{} requires an understanding of how well it classifies the \\spec{} of an \\isol{}.\nThere are a few areas of focus that we have when interpreting the results of \\krap{}:\n\\begin{itemize}\n\\item What size $k$ achieves the best results?\n\\item What size $\\alpha$ achieves the best results?\n\\item Which metric resolution algorithm achieves the best results?\n\\end{itemize}\nIndeed we can define ``best'' in many ways, but we choose to look at two metrics, recall and precision, and a combination of the two, the $F$-measure. The metrics look at the accuracy of the classification on the object and the object on the classification respectively, while \\fmeasure{} hopes to represent a balance between the two. \nWe test \\krap{} by performing cross validation with holdout.\n\n\\subsection{Cross Validation with Holdout}\n\\index{cross validation with holdout}\nTo gauge the effectiveness of \\krap{} at classifying the \\spec{} of an \\isol{}, we cross-validated against the library by separately holding out each \\isol{} in CPLOP from CPLOP, classifying it against CPLOP, and verifying whether it is correct. \nSince each \\isol{} in CPLOP has the correct \\spec{}, we know whether a classification is correct or not.\n\n\\subsection{Recall}\nIn our study, recall tracks how well we are able to discover all isolates from a given category, i.e. with a given host species.\nGiven a category (\\spec{} name), the recall for that host species is the percentage of isolates taken from this host species that have been properly identified.\nFor example, if our database had 100 cat isolates, and 74 of them were classified by our method as having come from a cat, the recall would be 74\\%.\nIn this study, we compute both overall recall (what percentage of \\isols{} were classified as their proper \\spec{} label) as well as \\spec{}-level recall (what percentage of isolates that came from dogs/humans/sheep/etc. were classified\nas their proper label).\n\n\\subsection{Precision}\nPrecision tracks how well our method avoids misclassification errors. \nGiven a category and a list of isolates our method classified as belonging to it, the precision of the method on the\ncategory is the percent of isolates from the list that has the correct label.\nFor example, if our method returned 100 isolates labelled ``Dog'' of which 77 isolates really did come from dogs, the precision of the method is 77\\%. As with recall, we compute both overall precision, as well as the precision for each category/species label.\n\n\\subsection{\\textit{F}-Measure}\nThe \\fmeasure{}, $F_1$, is the \\textit{harmonic mean} of the precision, $P$ and the recall, $R$:\n\\begin{equation*}\n    F_1 \n    =\n    \\frac{2}{\\frac{1}{P}\n    +\n    \\frac{1}{R}}\n    = 2\\cdot\n    \\frac{P\\cdot R}\n    {P + R}\n\\end{equation*}\nWhile we prefer maximizing this value, a value near 0.5 means we are doing well.\n", "meta": {"hexsha": "107c46c3525f7027c905752429a133883683c137", "size": 2884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/krap/evaluation.tex", "max_stars_repo_name": "jmcgover/thesis", "max_stars_repo_head_hexsha": "25664684158d00864dbe697276d2691ba84461cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/krap/evaluation.tex", "max_issues_repo_name": "jmcgover/thesis", "max_issues_repo_head_hexsha": "25664684158d00864dbe697276d2691ba84461cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/krap/evaluation.tex", "max_forks_repo_name": "jmcgover/thesis", "max_forks_repo_head_hexsha": "25664684158d00864dbe697276d2691ba84461cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.5454545455, "max_line_length": 335, "alphanum_fraction": 0.7597087379, "num_tokens": 712, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.43013968168818734}}
{"text": "%-----------------------------------------------------------------------------%\n%                                                                             %\n%    K A P I T E L   3                                                      %\n%                                                                             %\n%-----------------------------------------------------------------------------%\n\n\\chapter{Contact Stability Constrained DDP}\\label{c3}\nThis chapter presents a generic method for integrating contact stability constraints into DDP-like solvers. The key idea is to define inequality constraints for unilaterality, friction and the \\gls{CoP} of each contact surface with the goal of generating inherently balanced motions.\n\n\\section{The Idea}\\label{sec:StabilityIdea}\nStability of the contacts is an essential objective of motion planning since prevents the robot from sliding and falling down. In \\cref{sec:TheoryStability} we have explored two different criteria for ensuring contact stability for dynamic systems, namely the \\gls{ZMP} and \\gls{CoP}. As outlined, the application of the \\gls{ZMP} is limited due to the assumptions of sufficiently high friction and the existence of one planar contact surface. Since we want to provide a \\textit{generic} method that can also be used for e.g. walking up stairs, these simplifying assumptions do not hold anymore. \n\nConsequently, we decide to model a 6D surface contact, as introduced in \\cref{eqn:EoMLeggedRobotSurfaceContact} with dedicated constraints for (i) unilaterality of the contact forces (ii) Coulomb friction on the resultant force, and (iii) \\gls{CoP} inside the support area. For the sake of simplicity, we model a rectangular contact area. Nevertheless, this concept can be extended  to arbitrary feet designs. This approach can be compared to the concept of contact wrench cone \\cite{caron2015stability}, without additionally enforcing the yaw torque constraint. These inequality constraints for surface contacts can compactly be summarized as\n\\begin{subequations}\\label{eqn:contractWrenchConeReduced}\n\\begin{align}\nf_i^z &> 0 \\label{subeqn:stabilityUnilaterality},\\\\\n\\mid f_i^x\\mid &\\leq \\mu f_i^z \\label{subeqn:stabilityFrictionX},\\\\\n\\mid f_i^y\\mid &\\leq \\mu f_i^z \\label{subeqn:stabilityFrictionY},\\\\\n\\mid X\\mid & \\geq C_x \\label{subeqn:stabilityCoPPitch},\\\\\n\\mid Y\\mid & \\geq C_y \\label{subeqn:stabilityCoPRoll}.\n\\end{align}\n\\end{subequations}\n%Original CoP constraints from Caron paper for horizontal floor\n%\\mid \\tau_i^x\\mid & \\leq Yf_i^z \\label{subeqn:stabilityCoPPitch},\\\\\n%\\mid \\tau_i^y\\mid & \\leq Xf_i^z \\label{subeqn:stabilityCoPRoll}.\n\nLet us now detail each line of the approach. \nThe first inequality \\cref{subeqn:stabilityUnilaterality} accounts for the unilaterality of the contact force. By nature, contact forces always have to be positive since the robot can only \\textit{push} from the ground, not \\textit{pull} to the ground (\\cref{img:simple_contact}). \nInequality \\cref{subeqn:stabilityFrictionX,subeqn:stabilityFrictionY} corresponds to the Coulomb friction, where $\\mu$ denotes the static coefficient of friction. From a modeling perspective, this can be interpreted via the concept of spatial friction cones \\cite{kao2016contact}. If, and only if the distributed contact forces lie inside their respective friction cones, these constraints are satisfied. \nFinally, inequality \\cref{subeqn:stabilityCoPPitch,subeqn:stabilityCoPRoll} constrain the \\gls{CoP} to lie inside the rectangular contact area of each foot (see \\cref{img:contact_surface}). $C_x$ and $C_y$ denote the x and y position of $\\bp_{CoP}$, respectively. These \\gls{CoP} constraints prevent the robot from tilting around the edges of the rectangular surface contact. In particular, \\cref{subeqn:stabilityCoPPitch} corresponds to a constraint of tilting around the pitch axis and \\cref{subeqn:stabilityCoPRoll} prevents tilting around the roll axis.\n\nBoth, the unilaterality of the contact forces and the friction cone constraints, are already implemented inside Crocoddyl. However, the central component, bounding the \\gls{CoP} to lie inside the support area of each contact foot, is missing. Therefore, the rest of this chapter deals with the derivation of a set of implementable \\gls{CoP} constraints and describes the integration of these constraints as a cost function into the Crocoddyl framework.\n\\begin{figure}[t]\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=.95\\linewidth]{img/simple_contact}\n\t\t\\caption{}\n\t\t\\label{img:simple_contact}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=.77\\linewidth]{img/contact_surface}\n\t\t\\caption{}\n\t\t\\label{img:contact_surface}\n\t\\end{subfigure}\n\t\\caption[Simplified contact situation and CoP notation]{(a) Visualization of acting forces on a simple rigid body and (b) notation used for the \\gls{CoP} definition in the contact surface plane \\cite{caron2015stability}.}\n\t\\label{fig:natural2robot}\n\\end{figure}\n\n\n\\section{Center of Pressure (CoP) Constraints}\\label{sec:StabilityCoP}\nIn this section we will derive a universal set of implementable constraints that bound the \\gls{CoP} to lie inside the rectangular contact area of each foot.\n\n\\subsection{CoP Stability Conditions}\nRecapitulate the constraints from inequality \\crefrange{subeqn:stabilityCoPPitch}{subeqn:stabilityCoPRoll}. Instead of using the absolute value of $X$ and $Y$, one can also formulate the constraints as\n\\begin{align}\n\\begin{split}\n-X &\\leq C_x \\leq X,\\\\\n-Y &\\leq C_y \\leq Y.\n\\end{split}\n\\end{align}\nBased on this formulation it becomes evident that the \\gls{CoP} is constrained to lie inside the foot geometry visualized in \\cref{img:contact_surface}. In fact, these conditions can be represented via four single inequality equations as\n\\begin{align}\\label{eqn:CoPInequalities}\n\\begin{split}\nX + C_x \\geq 0, \\\\\nX - C_x \\geq 0, \\\\\nY + C_y \\geq 0, \\\\\nY - C_y \\geq 0. \\\\\n\\end{split}\n\\end{align}\nThese four inequality equations will be used in the following to formulate the \\gls{CoP} constraints.   \n\n\\subsection{CoP Computation}\nOur goal is to determine explicit expressions for $C_x$ and $C_y$ for arbitrary floor orientations, including inclined ground. To this end, consider the computation routine for the \\gls{CoP} from \\cref{eqn:CoPComputation}\n\\begin{equation*} \n\\bp_{CoP}=\\dfrac{\\bn\\times\\myM{\\btau_O^c}}{\\bfun^c\\cdot\\bn}.\n\\end{equation*}\nFor arbitrary orientations of the contact normal vector $\\bn$, we obtain\n\\begin{equation}\\label{eqn:CoPComputationDetailed}\n\\bp_{CoP}=\\dfrac{\\bn\\times\\myM{\\btau_O^c}}{\\bfun^c\\cdot\\bn} = \\dfrac{\\begin{bmatrix} n_x \\\\ n_y \\\\ n_z \\end{bmatrix} \\times \\begin{bmatrix} t_x \\\\ t_y \\\\ t_z \\end{bmatrix}}{\\begin{bmatrix} f_x \\\\ f_y \\\\ f_z \\end{bmatrix} \\cdot \\begin{bmatrix} n_x \\\\ n_y \\\\ n_z \\end{bmatrix}} = \n\\begin{bmatrix} n_yt_z - n_zt_y \\\\ n_zt_x-n_xt_z \\\\ n_xt_y-n_yt_x \\end{bmatrix}\\cdot \\dfrac{1}{f_xn_x+f_yn_y+f_zn_y},\n\\end{equation}\nand solve for the desired position $C_x$ and $C_y$ of the \\gls{CoP} as\n\\begin{subequations}\n\\begin{align}\nC_x&=\\dfrac{n_yt_z - n_zt_y}{f_xn_x+f_yn_y+f_zn_y}, \\label{subeqn:Cx}\\\\\nC_y&=\\dfrac{n_zt_x-n_xt_z}{f_xn_x+f_yn_y+f_zn_y} \\label{subeqn:Cy}.\n\\end{align}\n\\end{subequations}\n\n\\subsection{CoP Inequality Constraints}\nNow that we have found explicit expressions for computing the \\gls{CoP} (\\crefrange{subeqn:Cx}{subeqn:Cy}), we can insert them into \\cref{eqn:CoPInequalities}, which gives a set of four \\gls{CoP} constraints as \n\\begin{align}\\label{eqn:CoPInequalityEqs}\n\\begin{split}\nX + \\dfrac{n_yt_z - n_zt_y}{f_xn_x+f_yn_y+f_zn_y} \\geq 0, \\\\\nX - \\dfrac{n_yt_z - n_zt_y}{f_xn_x+f_yn_y+f_zn_y} \\geq 0, \\\\\nY + \\dfrac{n_zt_x-n_xt_z}{f_xn_x+f_yn_y+f_zn_y} \\geq 0, \\\\\nY - \\dfrac{n_zt_x-n_xt_z}{f_xn_x+f_yn_y+f_zn_y} \\geq 0. \\\\\n\\end{split}\n\\end{align}\nThese conditions can be written in matrix form as:  \n\\begin{equation}\\label{eqn:CoPInequalityMatrix}\n\\begin{bmatrix}  \nXn_0 & Xn_1 & Xn_2 & 0 & -n_2 & n_1 \\\\\nXn_0 & Xn_1 & Xn_2 & 0 & n_2 & -n_1 \\\\\nYn_0 & Yn_1 & Yn_2 & n_2 & 0 & -n_0 \\\\\nYn_0 & Yn_1 & Yn_2 & -n_2 & 0 & n_0 \\\\ \\end{bmatrix}\n\\begin{bmatrix} f^x \\\\ f^y \\\\ f^z \\\\ \\tau^x \\\\ \\tau^y \\\\ \\tau^z \\end{bmatrix} \\geq\n\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix},\n\\end{equation}\nand finally yield an implementable set of inequality equations for constraining the \\gls{CoP} to lie inside the rectangular contact area of each foot. \n\n\n\\section{Integration Into the Crocoddyl Framework}\\label{sec:StabilityIntegration}\nThis section presents the integration of the derived CoP inequality constraints from \\cref{eqn:CoPInequalityMatrix} into the Crocoddyl framework. \n\n\\subsection{Inequality Constraints by Penalization}\nIn \\cref{sec:TheoryConstrainedDDP} we have discussed possible ways of incorporating inequality constraints into DDP-like solvers. Crocoddyl handles inequality constraints, such as joint limits or friction cone, via penalization. \nIn numerical optimization, the goal is to minimize a given cost function. In Crocoddyl, an \\textit{action model} combines dynamics and cost model for each knot of the discretized \\gls{OC} problem from \\cref{eqn:totalCost}. The cost function for an action model at knot $n$ can be written as: \n\\begin{equation}\\label{eqn:costSum}\nl_n=\\sum_{c=1}^{C}\\alpha_c\\Phi_c(\\bq,\\dot{\\bq}, \\btau), \n\\end{equation}\nwhere $C$ different costs $\\Phi_c$ are weighted by a respective coefficient $\\alpha_c\\in R$. The goal of the following two parts is to demonstrate how the inequality \\cref{eqn:CoPInequalityMatrix} is implemented inside a novel cost function into the framework.\n\n\\subsection{Computation of Residual and Cost}\n%\\subsection{Computation of the Residual}\nIn numerical analysis, the term \\textit{residual} corresponds to the error of a result \\cite{shewchuk1994introduction}. For the sake of compactness, we abbreviate \\cref{eqn:CoPInequalityMatrix} as \n\\begin{equation} \\label{eqn:costPositive}\n\\myM{A} \\myM{w} \\geq \\myM{0},\n\\end{equation}\nwhere $\\myM{A}$ corresponds to a matrix of \\gls{CoP} inequality constraints and $\\myM{w}$ is the contact wrench acting on the according foot. The residual $\\myM{r}\\in \\myM{R}_{4\\times 1}$ of the cost is retrieved by a simple matrix-vector multiplication:\n\\begin{equation}\\label{eqn:costResidual}\n\\myM{r} = \\myM{A} \\myM{w}.\n\\end{equation} \n\n%\\subsection{Computation of the Cost}\nThe residual vector depicted in \\cref{eqn:costResidual} typically contains non-zero numbers. The resulting scalar \\gls{CoP} cost value $\\Phi_{CoP}$ is computed via a bounded quadratic activation as\n\\begin{equation}\\label{eqn:CoPCostComputation}\n\\Phi_{CoP}=\n\\begin{cases}\n\\quad\\dfrac{1}{2}\\myM{r}^T\\myM{r} &\\mid \\text{lb} > \\myM{r} > \\text{ub} \\\\[10pt]\n\\quad 0 &\\mid \\text{lb} \\leq \\myM{r} \\leq \\text{ub}.\n\\end{cases}\n\\end{equation}\n\nIn order to account for the positiveness of $\\myM{r}$ (see \\cref{eqn:costPositive}), the bounds are set to $\\text{lb}=\\myM{0}$ and $\\text{ub}=\\infty$, respectively. Finally, this bounded quadratic activation of the residual vector has the following implications:\n\\begin{itemize}\n\\item The \\gls{CoP} cost is zero, whenever $\\bp_{CoP}$ lies inside or on the border of the foot area spanned by $X$ and $Y$.\n\\item The \\gls{CoP} cost increases in a quadratic manner, when $\\bp_{CoP}$ exceeds the foot area spanned by $X$ and $Y$.\n\\end{itemize}  \nBesides this formulation of the cost function also other designs are conceivable for the future. For example, the Euclidean distance from the CoP to the coordinate origin could be considered when computing the residual (see  \\cref{eqn:CoPCostComputation}).\n\n\\subsection{Basic Usage and Contributions}\n%\\subsection{Basic Usage of the CoP Cost}\nThe cost function is implemented in C++, but can be accessed via Python bindings for versatile and fast prototyping. In the following, a basic example is provided to demonstrate the interface of the \\gls{CoP} cost function to the interested reader.\n\\begin{verbatim}\n# 1. Creating the cost model container\ncostModel = crocoddyl.CostModelSum(state, actuation.nu)\n# 2. Defining the CoP cost\nfootGeometry = np.array([0.2, 0.08]) # dim [m] of the foot area\nCoPCost = crocoddyl.CostModelContactCoPPosition(state, \ncrocoddyl.FrameCoPSupport(footId, footGeometry), actuation.nu)\n# 3. Adding the CoP cost term with assigned weight to the cost model\ncostModel.addCost(\"LF_CoPCost\", CoPCost, 1e3)\n\\end{verbatim}\n\n%\\subsection{List of Contributions}\nThe contributions of this thesis to the open-source framework Crocoddyl are summarized in two main pull requests. The first one, \\href{https://github.com/loco-3d/crocoddyl/pull/792}{\\#792} contains the basic formulation of the \\gls{CoP} cost function for contact dynamics action models (see \\cref{app:ContactCoP}). With \\href{https://github.com/loco-3d/crocoddyl/pull/830}{\\#830}, an additional version of the cost function is implemented for impulse dynamics action models (see \\cref{app:ImpulseCoP}).\nA functional unit test that checks the cost against numerical differentiation as well as accessible python bindings can be found in the according directory of \\cite{crocoddylweb}.\n\n\n%\\subsection{Backup: Friction Cone constraints}\n%\\begin{align}\n%\\begin{split}\n%\\mid\\mid f^x\\mid\\mid &\\leq \\mu f^z \\\\\n%\\mid\\mid f^y\\mid\\mid &\\leq \\mu f^z \\\\\n%f^z &> 0\n%\\end{split}\n%\\end{align}\n%For the case of four edges of the linear approximation of the friction cone, the equations become:\n%\\begin{equation}\n%\\begin{bmatrix} 1 & 0 & -\\mu \\\\\n%-1 & 0 & -\\mu \\\\\n%0 & 1 & -\\mu \\\\\n%0 & -1 & -\\mu \\\\\n%0 & 0 & -\\mu \\\\ \\end{bmatrix} \\cdot\n%\\begin{bmatrix} f^x \\\\ f^y \\\\ f^z \\end{bmatrix} \\leq\n%\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}\n%\\end{equation}\n\n%\\subsection{CoP Constraints: Horizontal Floor}\n%For the special case of horizontal floor, with the according normal vector $\\myM{n}=[0,0,1]$, the \\gls{CoP} can be computed with the help of \\cref{eqn:CoPComputationDetailed} to \n%\\begin{equation}\n%\\myM{p}_{CoP} = \\begin{bmatrix} -t_y/f_z \\\\ t_x/f_z \\\\ 0 \\end{bmatrix},\n%\\end{equation}\n%which in turn can be represented by four inequality conditions:\n%\\begin{align}\n%\\begin{split}\n%X-\\dfrac{\\tau_y}{f_z} &\\geq 0, \\\\\n%X+\\dfrac{\\tau_y}{f_z} &\\geq 0, \\\\\n%Y+\\dfrac{\\tau_x}{f_z} &\\geq 0, \\\\\n%Y-\\dfrac{\\tau_x}{f_z} &\\geq 0. \\\\\n%\\end{split}\n%\\end{align}\n%These conditions can be transformed into matrix form for the purpose of implementation as\n%\\begin{equation}\n%\\begin{bmatrix} \n%0 & 0 & X & 0 & -1 & 0 \\\\\n%0 & 0 & X & 0 & 1 & 0 \\\\\n%0 & 0 & Y & 1 & 0 & 0 \\\\\n%0 & 0 & Y & -1 & 0 & 0 \\end{bmatrix} \\cdot\n%\\begin{bmatrix} f^x \\\\ f^y \\\\ f^z \\\\ \\tau^x \\\\ \\tau^y \\\\ \\tau^z \\end{bmatrix} \\geq\n%\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}.\n%\\end{equation}\n\n\n\n\n", "meta": {"hexsha": "c5b80d977feee6f4dd76117ef33bb8864663fb9b", "size": 14600, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/chapter3.tex", "max_stars_repo_name": "julesser/ma-thesis", "max_stars_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-28T08:48:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-28T08:48:54.000Z", "max_issues_repo_path": "tex/chapter3.tex", "max_issues_repo_name": "julesser/ma-thesis", "max_issues_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2020-04-18T12:28:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-18T12:43:52.000Z", "max_forks_repo_path": "tex/chapter3.tex", "max_forks_repo_name": "julesser/ma-thesis", "max_forks_repo_head_hexsha": "29d00b315f5d502fd1378457be2f64cf74049ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:30:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-26T14:30:37.000Z", "avg_line_length": 66.6666666667, "max_line_length": 643, "alphanum_fraction": 0.731369863, "num_tokens": 4488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.43013968168818734}}
{"text": "\\documentclass[11pt]{article}\n\\newcommand\\tab[1][1cm]{\\hspace*{#1}}\n\\usepackage{graphicx}\n\\graphicspath{ {C:/Users/yedkk/Desktop/CS465/hw4} }\n\\begin{document}\n\\section{Homework 9}\nName: Kangdong Yuan\n\t\n\\subsection{problem1}\na).I did not work in a group.\n\\\\b).I did not consult without anyone my group members\n\\\\c).I did not consult any non-class materials.\n\n\\subsection{problem2}\nWe prove by contradiction.\\\\\nGiven $e^*$ is the heaviest edge in some cycle C of undirected graph G.\\\\\nWe assume the claim is Flase, so T is a minimal spanning forest and $e^* \\in T$. Let $S, \\ V-S$ be the two connected components in $T \\setminus \\{e\\}$. Since C is a cycle, there are two edges in C that cut $S, \\ V-S$. We define another edge is r. The $e^*$ has more cost than edge r, which is $w(e)>w(r)$. So, the new minimal spanning forest with edge r cost less than minimal spanning forest with edge $e^*$. It is a contradiction to the minimal cost principle of minimal spanning forest.\\\\\nSo, $e^*$ cannot in minimal spanning forest, which cannot appear in any MST of G.\n\n\n\\subsection{problem3}\na). $f_a>f_b \\ and \\ f_a>f_c$, so $f_a=10, f_b=5, f_c=5$\\\\\nb). This encoding is not possible, because the code for $a$ is $(0)$, is a prefix of the code for $c$ is $(00)$. \\\\\nc). This encoding is not optimal, because the $\\{0,10,11\\}$ cost less space. And, the Huffman tree of this encoding is not complete, which is not optimal. \n\n\\subsection{problem4}\nwe can construct Huffman tree to find prefix-free encoding of minimal total cost.\nAs a common convention, bit '0' represents following the left child and bit '1' represents following the right child.\\\\\n\\\\\nFirst, using a priority queue $Q$ to store all the words as key and $f_i*c_i$ as value. In Q, lowest value is given highest priority. \\\\\n\\\\\n1. Create a leaf node for each symbol and add it to the\tQ.\\\\\n2. While there is more than one node in the queue:\\\\\n\\tab Remove the two nodes from Q (lowest $f_i*c_i$)\\\\\n\\tab Create a new internal node with these two nodes as children and with value ($f_i*c_i$) equal to the sum of the two nodes' value ($f_i*c_i$).\\\\\n\\tab Add the new node to the queue.\\\\\n3. The remaining node is the root node and the tree is complete.\\\\\n\nThen the prefix-free encoding of each word is path of each node. for example\\\\\n\\includegraphics[scale=0.7]{huff}\\\\\nTime complexity: $O(nlogn)$, because each iteration requires $O(logn)$ time to determine the lowest frequencies and insert the new word in priority queue. There are $O(n)$ iterations.\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "acaa54dc8ad46538e73f633330f3d9119bc1138a", "size": 2520, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "9. greedy algorithm/hw9.tex", "max_stars_repo_name": "yedkk/algorithm-design", "max_stars_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-06-01T02:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T02:39:45.000Z", "max_issues_repo_path": "9. greedy algorithm/hw9.tex", "max_issues_repo_name": "yedkk/algorithm-design", "max_issues_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "9. greedy algorithm/hw9.tex", "max_forks_repo_name": "yedkk/algorithm-design", "max_forks_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.6170212766, "max_line_length": 491, "alphanum_fraction": 0.7222222222, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.43010290616413677}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{geometry}\n\\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}\n%\\usepackage{color}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{mathabx}\n\\usepackage{commath}\n\n\\geometry{textwidth=6.5in, textheight=9.0in,\n    marginparsep=7pt, marginparwidth=.6in}\n\\setlength{\\parindent}{0in}\n\\setlength{\\parskip}{0.08in}\n\n\\newcommand{\\red}[1]{\\textcolor{red}{#1}}\n\\newcommand{\\blue}[1]{\\textcolor{blue}{#1}}\n\\newcommand*{\\annot}[1]{\\tag*{\\footnotesize{\\textcolor{gray}{#1}}}}\n\n\\let\\Re\\undefined\n\\DeclareMathOperator{\\Re}{Re}\n\\let\\Im\\undefined\n\\DeclareMathOperator{\\Im}{Im}\n\n\\title{Color Gradients Notes}\n\\author{Josh Meyers}\n\\date{October 2015}\n\n\\begin{document}\n\n\\section{Introduction}\n\nThe goal is to create a \\textsc{GalSim} ChromaticObject with realistic color gradients using high\nresolution multiband images (most likely from HST) as input.  This is done by modeling the\npreconvolution chromatic surface brightness profile $f(\\vec{x}, \\lambda)$ as a sum of two or more\nseparable chromatic surface brightness profiles, each with a particular asserted SED.  I.e.,\n\n\\begin{equation}\n    \\label{eqn:sbprof}\n    f(\\vec{x}, \\lambda) = \\sum_j S_j(\\lambda) a_j(\\vec{x}),\n\\end{equation}\n\nwhere $S_j(\\lambda)$ is the $j$th SED asserted as part of the decomposition, and $a_j(\\vec{x})$ is\nthe spatial component of the $j$th separable chromatic profile.\n\nThe required set of inputs is:\n\n\\begin{itemize}\n\n\\item Two or more HST images of the same galaxy in different filters, $I_i(\\vec{x})$, where $i$\nlabels the different filters.\n\n\\item The 2D noise covariance function for each image, $\\xi_i(\\Delta\\vec{x})$.  If the noise is\nuncorrelated, then this could be simply the noise variance ($\\xi_i(\\Delta\\vec{x}=0) = \\sigma^2_i$, $\\xi_i(\\Delta\\vec{x}\\ne0)=0$).\n\n\\item The chromatic HST PSF, $\\Pi(\\vec{x}, \\lambda)$.\n\n\\item The HST throughput for each image filter, $T_i(\\lambda)$.\n\n\\item Two or more SEDs, $S_j(\\lambda)$, to use in the decomposition in Equation \\ref{eqn:sbprof}.\n\n\\end{itemize}\n\nThe model for the observed images is:\n\n\\begin{align}\n    I_i(\\vec{x})\n    &= \\int T_i(\\lambda) \\left[\\Pi(\\vec{x}, \\lambda) \\Asterisk f(\\vec{x}, \\lambda)\\right] \\dif{\\lambda} + \\eta_i(\\vec{x}) \\\\\n    &= \\int T_i(\\lambda) \\sum_j S_j(\\lambda) \\left[\\Pi(\\vec{x}, \\lambda) \\Asterisk a_j(\\vec{x})\\right] \\dif{\\lambda} + \\eta_i(\\vec{x})\n\\end{align}\n\nwhere $\\eta_i(\\vec{x})$ indicates (potentially spatially correlated) Gaussian noise in image $i$ and\nthe $\\Asterisk$ symbol indicates (spatial) convolution.  The noise $\\eta_i(\\vec{x})$ is related to\nthe noise covariance function via $\\langle\\eta_i(\\vec{x}_l) \\eta_i(\\vec{x}_m)\\rangle =\n\\xi_i(\\vec{x}_l - \\vec{x}_m)$, where angle brackets indicate averaging over realizations of the\nnoise.  Note that we also assume that $\\xi_i$ is even: $\\xi_i(\\Delta\\vec{x}) =\n\\xi_i(-\\Delta\\vec{x})$.\n\nThe convolution is easier to work with in Fourier space where it becomes a mode-by-mode product.\nIndicating the Fourier transform of the real-space quantity $g(\\vec{x})$ with $\\tilde{g}(\\vec{k})$,\nthe model in Fourier space is\n\n\\begin{align}\n    \\tilde{I}_i(\\vec{k})\n    &= \\int T_i(\\lambda) \\sum_j S_j(\\lambda) \\tilde{\\Pi}(\\vec{k}, \\lambda) \\tilde{a}_j(\\vec{k}) \\dif{\\lambda} + \\tilde{\\eta}(\\vec{k}) \\\\\n    &= \\sum_j \\left[\\int T_i(\\lambda) S_j(\\lambda) \\tilde{\\Pi}(\\vec{k}, \\lambda) \\dif{\\lambda}\\right] \\tilde{a}_j(\\vec{k}) + \\tilde{\\eta}(\\vec{k}) \\\\\n    \\label{eqn:solveme}\n    &=  \\sum_j \\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) \\tilde{a}_j(\\vec{k}) + \\tilde{\\eta}(\\vec{k}),\n\\end{align}\n\nwhere the effective PSF for the $i$th filter and $j$th SED is\n\n\\begin{equation}\n  \\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) = \\int T_i(\\lambda) S_j(\\lambda) \\tilde{\\Pi}(\\vec{k}, \\lambda) \\dif{\\lambda}.\n\\end{equation}\n\nThe crux of the problem is to solve for the (complex-valued) $\\tilde{a}_j(\\vec{k})$ and to propagate\nthe statistics of the noise.\n\n\\section{Solving for $\\tilde{a}_j(\\vec{k})$}\n\nThere are several possible ways to estimate the required $\\tilde{a}_j(\\vec{k})$.\n\n\\subsection{No noise}\n\nWe'll look first at the case where one ignores noise entirely ($\\eta(\\vec{x}) =\n\\tilde{\\eta}(\\vec{k})= 0$).\n\nIf the number of asserted SEDs $N_j$ is larger than the number of input images $N_i$, then the\nsystem of equations represented by Equation \\ref{eqn:solveme} is underdetermined.  While in\nprinciple this could still be solvable using some prior constraints, for now, we'll just ignore this\npossibility.\n\nIf $N_j = N_i$, then we can exactly solve Equation \\ref{eqn:solveme} using matrix inversion for each\nFourier mode $\\vec{k}$:\n\n\\begin{equation}\n  \\tilde{a}_j(\\vec{k}) = \\sum_i [(\\tilde{\\Pi}^\\mathrm{eff}(\\vec{k}))^{-1}]_{ij} \\tilde{I}_i(\\vec{k}).\n\\end{equation}\n\nIf there are more images than spectra ($N_i > N_j$), then the system of equations is overdetermined\nand no longer has an exact solution.  Instead, there is a (usually) unique ``least-squares''\nsolution for each $\\vec{k}$ obtained by minimizing\n\n\\begin{equation}\n  \\label{eqn:lstsq}\n  \\sum_i\\left|\\tilde{I}_i(\\vec{k}) - \\sum_j \\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) \\tilde{a}_j(\\vec{k})\\right|^2.\n\\end{equation}\n\n\\subsection{Uncorrelated noise}\n\nStationary, uncorrelated Gaussian pixel noise in the $i$th image is completely described by its\nvariance $\\sigma^2_i$.  In Fourier space, the variance of each mode is independent of $\\vec{k}$ and\nproportional to $\\sigma^2_i$, where the constant of proportionality depends on the particular\nFourier conventions employed.  We can therefore write down a likelihood for $\\tilde{a}_j(\\vec{k})$\nas\n\n\\begin{equation}\n    \\label{eqn:like}\n    \\chi^2(\\vec{k}) = -2 \\log \\mathcal{L}(\\vec{k}) = \\sum_i\\frac{1}{\\sigma_i^2}\\left|\\tilde{I}_i(\\vec{k}) - \\sum_j \\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) \\tilde{a}_j(\\vec{k})\\right|^2.\n\\end{equation}\n\nThis is a \\textit{weighted} least-squares problem.  Note that the weights only matter for\ndetermining the Fourier coefficients $\\tilde{a}_j(\\vec{k})$ if the number of input images is greater\nthan the number of asserted spectra.  When these quantities are equal, it is always possible to find\n$\\tilde{a}_j(\\vec{k})$ such that $\\tilde{I}_i(\\vec{k}) = \\sum_j\n\\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) \\tilde{a}_j(\\vec{k})$.  The weights do still matter in this\ncase if we're interested in propagating the noise, however.\n\n\n\\subsection{Correlated noise}\n\nIf the noise covariance function for a particular image $\\xi_i(\\vec{\\Delta x})$ is non-zero away\nfrom the origin, then the variance of different Fourier modes is not constant, but proportional to\nthe noise power spectrum, which is the Fourier transform of the noise covariance function:\n\n\\begin{equation}\n  P_i(\\vec{k}) = \\int \\xi_i(\\Delta \\vec{x}) e^{-2 \\pi i \\vec{k}\\cdot\\Delta\\vec{x}}.\n\\end{equation}\n\nDue to assumed translation invariance of the noise (though note that we do not assume isotropy), the\ncovariance of different Fourier modes vanishes.  More explicitly, if the noise in image $i$ and mode\n$\\vec{k_l}$ is $\\tilde\\eta_i(\\vec{k_l})$, then\n\n\\begin{equation}\n  \\langle\\tilde\\eta_i^*(\\vec{k_l})\\tilde\\eta_i(\\vec{k_m})\\rangle = \\delta(\\vec{k_l} - \\vec{k_m})P_i(\\vec{k_l}).\n\\end{equation}\n\nOnce the noise power spectrum has been computed, therefore, the only change to the likelihood in\nEquation \\ref{eqn:like} is that the mode variance now depends on the particular Fourier mode in\nquestion:\n\n\\begin{equation}\n    \\label{eqn:likecorr}\n    -2 \\log \\mathcal{L}(\\vec{k}) = \\sum_i\\frac{1}{P_i(\\vec{k})}\\left|\\tilde{I}_i(\\vec{k}) - \\sum_j \\tilde{\\Pi}^\\mathrm{eff}_{ij}(\\vec{k}) \\tilde{a}_j(\\vec{k})\\right|^2.\n\\end{equation}\n\nThis is essentially the same weighted least squares problem as in the uncorrelated noise case -- the\nonly difference being that the weights now depend on $\\vec{k}$.  Written in matrix notation, the\nsolution for a particular $\\vec{k}$ mode is:\n\n\\begin{equation}\n    \\tilde{a} = \\left(\\tilde{\\Pi}^{\\mathrm{eff}, \\dagger} W \\tilde{\\Pi}^\\mathrm{eff} \\right)^{-1} \\tilde{\\Pi}^{\\mathrm{eff}, \\dagger} W \\tilde{I}\n\\end{equation}\n\nwhere\n\\begin{equation}\n    W_{ij} = \\delta_{ij}/\\sqrt{P_i}.\n\\end{equation}\n\nThe covariance matrix for the elements of $\\tilde{a}$ is given by\n\\begin{equation}\n    \\Sigma = \\left(\\tilde{\\Pi}^{\\mathrm{eff}, \\dagger} W \\tilde{\\Pi}^\\mathrm{eff} \\right)^{-1}.\n\\end{equation}\n\n\\section{Propagating the noise covariance}\n\nAt this point, we have the $\\tilde{a}_j(\\vec{k})$ necessary to represent a chromatic surface\nbrightness profile in Fourier space as\n\n\\begin{equation}\n  \\tilde{f}(\\vec{k}, \\lambda) = \\sum_j S_j(\\lambda) \\tilde{a}_j(\\vec{k}).\n\\end{equation}\n\nThe uncertainty in each $\\tilde{a}_j(\\vec{k})$ is uncorrelated from one $\\vec{k}$ to the next (since\nwe defined independent likelihoods for each $\\vec{k}$), but does, in general, possess correlations\nbetween the different SED components $j$ and $j^\\prime$ for a given $\\vec{k}$.  Using\n$\\Sigma_{jj^\\prime}(\\vec{k})$ to represent these covariances, we have\n\n\\begin{equation}\n    \\langle\\delta\\tilde{a}^*_j(\\vec{k}_l)\\delta\\tilde{a}_{j^\\prime}(\\vec{k}_m)\\rangle = \\delta(\\vec{k}_l - \\vec{k}_m)\\Sigma_{jj^\\prime}(\\vec{k_l}).\n\\end{equation}\n\nFortunately, $\\Sigma_{jj^\\prime}(\\vec{k})$ is analytically computable for weighted least squares\nproblems.\n\nThis $\\Sigma_{jj^\\prime}(\\vec{k})$ can then be transformed alongside the $\\tilde{a}_j(\\vec{k})$ to\neffect shears, rotations, dilations, etc., the same way that noise is transformed in existing\n\\textsc{GalSim} routines.\n\nFinally, the model for creating a (Fourier-domain) output image $\\tilde{I}^\\mathrm{out}(\\vec{k})$,\nconvolving by an output chromatic PSF $\\tilde{\\Pi}^\\mathrm{out}(\\vec{k}, \\lambda)$ and drawing\nthrough an output filter with transmission $T^\\mathrm{out}(\\lambda)$, is\n\n\\begin{align}\n    \\tilde{I}^\\mathrm{out}(\\vec{k})\n    &= \\int T^\\mathrm{out}(\\lambda) \\tilde{\\Pi}^\\mathrm{out}(\\vec{k}, \\lambda) \\tilde{f}(\\vec{k}, \\lambda) \\dif{\\lambda} \\\\\n    &= \\int T^\\mathrm{out}(\\lambda) \\tilde{\\Pi}^\\mathrm{out}(\\vec{k}, \\lambda) \\sum_j S_j(\\lambda) \\tilde{a}_j(\\vec{k}) \\dif{\\lambda} \\\\\n    &= \\sum_j \\tilde{\\Pi}_j^\\mathrm{out, eff}(\\vec{k}) \\tilde{a}_j(\\vec{k})\n\\end{align}\n\nwhere the effective PSF for the $j$th component of the output image is\n\n\\begin{equation}\n  \\tilde{\\Pi}_j^\\mathrm{out, eff}(\\vec{k}) = \\int \\tilde{\\Pi}^\\mathrm{out}(\\vec{k}, \\lambda) T^\\mathrm{out}(\\lambda) S_j(\\lambda)\\dif{\\lambda}.\n\\end{equation}\n\nPropagating the (potentially transformed) covariance spectrum $\\Sigma_{jj^\\prime}(\\vec{k})$ into the\nfinal output noise power spectrum $P^\\mathrm{out}(\\vec{k})$ then follows the normal propagation of\nerrors formula:\n\n\\begin{equation}\n  P^\\mathrm{out}(\\vec{k}) = \\sum_{jj^\\prime} \\tilde{\\Pi}_j^\\mathrm{out, eff, *}(\\vec{k}) \\Sigma_{jj^\\prime}(\\vec{k}) \\tilde{\\Pi}_{j^\\prime}^\\mathrm{out, eff}(\\vec{k}).\n\\end{equation}\n\nThis power spectrum can then be used in the existing correlated noise whitening and symmetrizing\nGalSim routines.\n\n\\section{Implementation notes}\n\n\\textsc{GalSim} uses the methodology developed by Bernstein \\& Gruen (2013) to interpolate\ndiscretely sampled surface brightness profiles in real and Fourier space.  Here we investigate the\nimpact of this interpolation on the Wiener-Khinchin theorem, which relates the real-space\nautocorrelation function to the Fourier-space power spectrum.\n\nThe discrete version of the Wiener-Khinchin theorem is derived as follows.  We are interested in\nthe (co)-variance of the Discrete Fourier Transform amplitudes of some discrete real space samples\nwith discrete auto-covariance function $\\xi\\left[r\\right]$ (we follow the convention of\nRowe++14 in using square brackets to indicate the arguments of a discretly sampled function, and\nreserve parentheses to indicate arguments of continuous objects).  Note that since we're using DFTs,\n$\\xi$ is implicitly periodic: $\\xi\\left[r\\right] = \\xi\\left[r+N\\right]$.\n\nThe 1D DFT of an N-point sampled function is:\n\n\\begin{equation}\n    \\tilde{b}_k = \\sum_{j=-N/2}^{N/2-1} b_j e^{-2 \\pi i j k / N}.\n\\end{equation}\n\n% with inverse transform\n%\n% \\begin{equation}\n%     b_j = \\frac{1}{N}\\sum_{k=-N/2}^{N/2-1} \\tilde{b}_k e^{2 \\pi i j k / N}.\n% \\end{equation}\n\nWe are interested in the quantity $\\left\\langle\\tilde{b}^*_k \\tilde{b}_{k^\\prime}\\right\\rangle$\nwhere the angle brackets indicate averaging over noise realizations.\n\n\\begin{align}\n    \\left\\langle\\tilde{b}^*_k \\tilde{b}_{k^\\prime}\\right\\rangle\n    \\annot{Sub in FT definition}\n    &= \\left\\langle\\sum_{j=-N/2}^{N/2-1} b_j e^{+2 \\pi i j k / N} \\sum_{j^\\prime=-N/2}^{N/2-1} b_{j^\\prime} e^{-2 \\pi i j^\\prime k^\\prime / N}\\right\\rangle \\\\\n    \\annot{Interchange expectation and summation}\n    &= \\sum_{j=-N/2}^{N/2-1} \\sum_{j^\\prime=-N/2}^{N/2-1} \\left\\langle b_j b_{j^\\prime} \\right\\rangle e^{2 \\pi i (jk - j^\\prime k^\\prime)/N} \\\\\n    \\annot{$\\xi\\left[r\\right]$ definition}\n    &= \\sum_{j=-N/2}^{N/2-1} \\sum_{j^\\prime=-N/2}^{N/2-1} \\xi\\left[j-j^\\prime\\right] e^{2 \\pi i (jk - j^\\prime k^\\prime)/N} \\\\\n    \\annot{change variables $r=j^\\prime-j$}\n    &= \\sum_{j=-N/2}^{N/2-1} \\sum_{r=-N/2-j}^{N/2-1-j} \\xi\\left[r\\right] e^{2 \\pi i (jk - (r+j) k^\\prime)/N} \\\\\n    \\annot{simplify using periodicty of $\\xi$ and $\\exp$}\n    &= \\sum_{j=-N/2}^{N/2-1} \\sum_{r=-N/2}^{N/2-1} \\xi\\left[r\\right] e^{-2 \\pi i r k^\\prime/N} e^{2 \\pi i j (k-k^\\prime)/N} \\\\\n    \\annot{definition of $P\\left[k\\right]$}\n    &= P[k^\\prime] \\sum_{j=-N/2}^{N/2-1} e^{2 \\pi i j (k-k^\\prime)/N} \\\\\n    \\annot{$e^{2 \\pi i j (k-k^\\prime)/N}$ evenly samples unit circle unless $k-k^\\prime \\in N\\mathbb{Z}$...}\n    &= N P[k^\\prime] \\sum_{N=0}^\\infty\\delta^{k+N}_{k^\\prime} \\\\\n    \\annot{...but we really only care about $k \\in \\left[-N/2, N/2-1 \\right]$ }\n    &= N P[k^\\prime] \\delta^{k}_{k^\\prime}.\n\\end{align}\n\nNow we try the same thing using the Bernstein \\& Gruen continuously interpolated Fourier transform.\nRecall their result:\n\n\\begin{align}\n    \\tilde{F}(u)\n    &= \\int{F(x) e^{-2 \\pi i u x} \\dif{x}} \\\\\n    &\\approx \\tilde{K}_x(u) \\sum_{k=-N/2}^{N/2-1}\\tilde{b}_k K_u(u-k/N)\n\\end{align}\n\nwhere $K_x$ is an asserted real-space interpolant, $\\tilde{K}_x$ is its Fourier transform,\nand $K_u$ is an asserted Fourier-space interpolant.  Note that the final equality is exact if and\nonly if\n\n\\begin{equation}\n    K_u(v) = e^{i \\pi v} \\frac{\\mathrm{sinc}\\, N v}{\\mathrm{sinc}\\, v}.\n\\end{equation}\n\nWe are interested in the (co)-variance of Fourier amplitudes:\n\n\\begin{align}\n    \\left\\langle \\tilde{F}^*(u) \\tilde{F}(u^\\prime)\\right\\rangle\n    \\annot{Sub in GalSim approximate FT definition}\n    &= \\left\\langle \\tilde{K}_x^*(u) \\sum_{k=-N/2}^{N/2-1}\\tilde{b}_k^* K_u^*(u-k/N) \\tilde{K}_x(u^\\prime) \\sum_{k^\\prime=-N/2}^{N/2-1}\\tilde{b}_{k^\\prime} K_u(u^\\prime-k^\\prime/N)  \\right\\rangle \\\\\n    \\annot{Rearrange}\n    &= \\tilde{K}_x^*(u) \\tilde{K}_x(u^\\prime) \\sum_{k=-N/2}^{N/2-1} \\sum_{k^\\prime=-N/2}^{N/2-1} K_u^*(u-k/N) K_u(u^\\prime-k^\\prime/N) \\left\\langle \\tilde{b}_k^* \\tilde{b}_{k^\\prime} \\right\\rangle \\\\\n    \\annot{definition of $P\\left[k\\right]$}\n    &= \\tilde{K}_x^*(u) \\tilde{K}_x(u^\\prime) \\sum_{k=-N/2}^{N/2-1} \\sum_{k^\\prime=-N/2}^{N/2-1} K_u^*(u-k/N) K_u(u^\\prime-k^\\prime/N) N P[k^\\prime]\\delta_{k^\\prime}^k \\\\\n    \\annot{sum over Kronecker $\\delta$}\n    &= N \\tilde{K}_x^*(u) \\tilde{K}_x(u^\\prime) \\sum_{k=-N/2}^{N/2-1} K_u^*(u-k/N) K_u(u^\\prime-k/N) P[k]\n\\end{align}\n\nThis is as far as I've been able to push (ran out of $\\delta$ functions!).  Assuming there are no\nfurther simplifications, one implication is that Fourier amplitudes of an interpolated noise image\nare not uncorrelated.  Equivalently, the continuous auto-covariance function of interpolated\ndiscretely stationary noise is not itself stationary.  This makes some intuitive sense, I think.\nFor example, the variance of interpolated points seems like it should always be less than the\nvariance of the input samples, implying that the continuously regarded noise is not stationary.\n\n\\end{document}\n", "meta": {"hexsha": "e1e7295f581cb981e154c010b8f9b9aa7effde77", "size": 15865, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CGNotes.tex", "max_stars_repo_name": "jmeyers314/CGNotes", "max_stars_repo_head_hexsha": "4c51124834bbeb0c90415e8592e122008b454390", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CGNotes.tex", "max_issues_repo_name": "jmeyers314/CGNotes", "max_issues_repo_head_hexsha": "4c51124834bbeb0c90415e8592e122008b454390", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CGNotes.tex", "max_forks_repo_name": "jmeyers314/CGNotes", "max_forks_repo_head_hexsha": "4c51124834bbeb0c90415e8592e122008b454390", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.9378698225, "max_line_length": 199, "alphanum_fraction": 0.6875512134, "num_tokens": 5336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.43010290230916043}}
{"text": "\\chapter{Creating Spacecraft}\r\n\r\nEpoch, State, Ballistic and Mass Properties, Input Coordinate\r\nSystem,\r\n\r\n\r\n\\noindent\\begin{ScriptType} \\noindent\r\nCreate Spacecraft Sat1\\\\\r\nSat1.Epoch.TAIGregorian  = 01 Jan 2000\\\\\r\n12:00:00.000; \\\\\r\nSat1.SMA        = 8000; \\\\\r\nSat1.ECC        = .01;\\\\\r\nSat1.INC        = 28.5;\\\\\r\nSat1.AOP        = 0;\\\\\r\nSat1.RAAN = 90;\\\\\r\nSat1.TA         = 180;\\\\     %  Use M for mean anomaly, and E for eccentric anomaly\r\nSat1.Cd         = 2.0;\\\\\r\nSat1.Cr         = 1.4;\\\\\r\nSat1.DragArea   = 1;\\\\\r\nSat1.SRPArea    = 1;\\\\\r\nSat1.DryMass    = 100; \r\n\\end{ScriptType}\r\n\r\n\r\n\\section{Spacecraft Epoch}\r\n\r\nAlternative ways of Defining a Spacecraft's Epoch\r\n\r\nAssuming a reference reference epoch for modified JD as MJD = JD -\r\n2430000, the following epochs are all equivalent.\r\n\r\n\\noindent \\% TAI in Modified Julian Date Format\\\\\r\n \\begin{ScriptType}\r\nSat1.Epoch.TAIModJulian = 21545.0003703704 \\end{ScriptType}\r\n\r\n\\noindent \\% TAI in Gregorian Date Format\\\\\r\n\\begin{ScriptType} Sat1.Epoch.TAIGregorian  = 01 Jan\r\n2000 12:00:32.0000;\\end{ScriptType}\r\n\r\n\\noindent \\% UTC in Modified Julian Date Format\\\\\r\n  \\begin{ScriptType}\r\n Sat1.Epoch.UTCModJulian  =\r\n21545.00000; \\end{ScriptType}\r\n\r\n\\noindent \\% UTC in Gregorian Date Format\\\\\r\n\\begin{ScriptType} Sat1.Epoch.UTCGregorian  = 01 Jan\r\n2000 12:00:00.000;  \\end{ScriptType}\r\n\r\n\\section{Spacecraft Orbit State}\r\n\r\n\\%  Example: Creating a spacecraft using  the\r\nCartesian State\\\\\r\n\\begin{ScriptType}\r\nCreate Spacecraft Sat1;\\\\\\\r\nSat1.X = 7082.960306079;\\\\\r\nSat1.Y = 7.052885901083;\\\\\r\nSat1.Z = -48.94363747128;\\\\\r\nSat1.VX = 0.05237087208446;\\\\\r\nSat1.VY = -1.069925309259;\\\\\r\nSat1.VZ = 7.424767278548;\r\n\\end{ScriptType}\r\n\r\n\\%  Example: Cartesian State: Method 2 \\\\\r\n\\begin{ScriptType}\r\nCreate Spacecraft Sat1;\\\\\r\nSat1.StateType = Cartesian;\\\\\r\nSat1.Element1 = 7000; \\\\   % X\r\nSat1.Element2 = 0.0;  \\\\  % Y\r\nSat1.Element3 = 0.0;  \\\\   % Z\r\nSat1.Element4 = 0.0;  \\\\   % VX\r\nSat1.Element5 = 8.0;  \\\\   % VY\r\nSat1.Element6 = 0.0;  \\\\   % VZ\r\n\\end{ScriptType}\r\n\r\n\\noindent \\%  Example: Creating a spacecraft using  the\r\nKeplerian Elements\\\\\r\n\\begin{ScriptType}\r\nCreate Spacecraft Sat1;\\\\\r\nSat1.SMA        = 8000;\\\\\r\nSat1.ECC        = .01;\\\\\r\nSat1.INC        = 28.5;\\\\\r\nSat1.AOP = 0; \\\\\r\nSat1.RAAN = 90;\\\\\r\nSat1.TA         = 180; \\\\    %  Use M for mean anomaly, and E for eccentric anomaly\r\n\\end{ScriptType}\r\n\r\n\\noindent \\%  Keplerian Elements: Method 2\\\\\r\n\\begin{ScriptType}\r\nCreate Spacecraft Sat1;\\\\\r\nSat1.StateType   = Keplerian;\\\\\r\nSat1.AnomalyType = TA; \\\\   %  Alternatives:  MA, EA\r\nSat1.Element1 = 8000;   \\\\  % SMA\r\nSat1.Element2 = .01;   \\\\  % ECC\r\nSat1.Element3 = 28.5;  \\\\   % INC\r\nSat1.Element4 = 0;     \\\\   % RAAN\r\nSat1.Element5 = 90;    \\\\   % AOP\r\nSat1.Element6 = 180;   \\\\   % Anomaly\r\n\\end{ScriptType}\r\n", "meta": {"hexsha": "d55b65effd976cc563a416e6dab86ec68ce57186", "size": 2779, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/SystemDocs/MathematicalSpecification/Spacecraft.tex", "max_stars_repo_name": "Randl/GMAT", "max_stars_repo_head_hexsha": "d6a5b1fed68c33b0c4b1cfbd1e25a71cdfb8f8f5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-01T13:14:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-09T07:05:07.000Z", "max_issues_repo_path": "doc/SystemDocs/MathematicalSpecification/Spacecraft.tex", "max_issues_repo_name": "ddj116/gmat", "max_issues_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_issues_repo_licenses": ["NASA-1.3"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-03-15T08:58:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-20T20:11:26.000Z", "max_forks_repo_path": "doc/SystemDocs/MathematicalSpecification/Spacecraft.tex", "max_forks_repo_name": "ddj116/gmat", "max_forks_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_forks_repo_licenses": ["NASA-1.3"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-13T10:26:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-09T07:06:55.000Z", "avg_line_length": 28.0707070707, "max_line_length": 84, "alphanum_fraction": 0.6369197553, "num_tokens": 1005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.43010290230916043}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage[utf8]{inputenc}\t% Para caracteres en español\n\\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}\n\\usepackage{multirow,booktabs}\n\\usepackage[table]{xcolor}\n\\usepackage{fullpage}\n\\usepackage{lastpage}\n\\usepackage{enumitem}\n\\usepackage{fancyhdr}\n\\usepackage{mathrsfs}\n\\usepackage{wrapfig}\n\\usepackage{setspace}\n\\usepackage{url}\n\\usepackage{calc}\n\\usepackage{multicol}\n\\usepackage{cancel}\n\\usepackage[retainorgcmds]{IEEEtrantools}\n\\usepackage[margin=3cm]{geometry}\n\\usepackage{amsmath}\n\\newlength{\\tabcont}\n\\setlength{\\parindent}{0.0in}\n\\setlength{\\parskip}{0.05in}\n\\usepackage{empheq}\n\\usepackage{framed}\n\\usepackage[most]{tcolorbox}\n\\usepackage{xcolor}\n\\colorlet{shadecolor}{orange!15}\n\\parindent 0in\n\\parskip 12pt\n\\geometry{margin=1in, headsep=0.25in}\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}\n\\newtheorem{reg}{Rule}\n\\newtheorem{exer}{Exercise}\n\\newtheorem{note}{Note}\n\n%\\newif\\ifnotes\n%\\newcommand{\\h}[1]{\\ifnotes{\\textcolor{red}{#1}}\\fi}\n\\newcommand{\\h}[1]{\\textcolor{red}{#1}}\n\n\\begin{document}\n\\setcounter{section}{8}\n\\title{Chapter 9 Review Notes}\n\n\\thispagestyle{empty}\n\n\\begin{center}\n{\\LARGE \\bf Convexity of Differentiable Function Approximations}\\\\\n\\end{center}\n\\section{Convexity Reference}\n\n\\subsection{Definitions}\n\nThere are several definitions and properties of convexity which are useful for determining where functions are convex.\n\n\\textbf{Definition.} A function $f(x)$ is \\textit{convex} on interval $I$ if $\\forall x_1, x_2 \\in I, \\forall \\in [0, 1]: f(t x_1 + (1-t)x_2) \\leq tf(x_1) + (1-t)f(x_2)$. \n\n\\textbf{First Derivative} Using the first derivative this becomes: $\\forall x_1, x_2 \\in I: f(x_1) \\geq f(x_2) + f'(x_2)*(x_1 - x_2)$. In other words, the derivative cannot decrease on $I$. \n\n\\textbf{Second Derivative} This also means that $\\forall x \\in I: f''(x) \\geq 0$\n\n\\subsection{Compositions}\n\n\\textbf{Summation and Multiplication} Sums of convex functions are convex. Multiplication by a constant is convex, provided the constant is greater than 0.\n\n\\textbf{Composition} If $f$ and $g$ are convex, $g \\circ f$ is convex on intervals where $g' \\geq 0$, (ie where $g$ is monotonically increasing).\n\n\\begin{figure}[h!]\n  \\centering\n  %\\includegraphics[width=\\linewidth]{figs/mlp2.png}\n  %\\includegraphics[height=6cm]{figs/mlp2.png}\n  \\includegraphics[width=\\linewidth]{figs/convex_examples.png}\n  \\caption{Some examples of convex and concave functions. (from \\protect\\url{http://www.math.cmu.edu/~lohp/docs/math/mop2013/convexity-soln.pdf})}\n  %\\label{fig:mlp2}\n\\end{figure}\n\n\\section{Convexity of Integer Operations}\n\\subsection{Arithmetic Operations}\n\n\\textbf{Addition}. \n\\begin{enumerate}\n\\item \\textbf{Function:} $g(x) = x + c$ is trivially convex, since $g'(x) = 1$. , \n\\item \\textbf{Composition:}  $g \\circ f$ is also convex given convex $f$, since $\\forall x: g'(x) \\geq 1$.\n\\item \\textbf{Binary Composition:} For addition given two convex input functions $f_1$ and $f_2$: $g(f_1(x), f_2(x)) = f_1(x) + f_2(x)$. This is still convex, since $\\frac{dg}{df_1} = \\frac{dg}{df_2} = 1$. \n\\item \\textbf{Step size:} Step size does not affect convexity for additon ($Ax + b$ is an affine tranformation).\n\\end{enumerate}\n\n\\textbf{Subtraction}. \n\\begin{enumerate}\n\\item \\textbf{Function:} $g(x) = x - c$ is both trivially convex, since $g'(x) = 1$. , \n\\item \\textbf{Composition:}  $g \\circ f$ is also convex given convex $f$, since $\\forall x: g'(x) \\geq 1$.\n\\item \\textbf{Binary Composition:} This is still convex, since $\\frac{dg}{df_1} = \\frac{dg}{df_2} = 1$. For subtraction $g(f_1(x), f_2(x)) = f_1(x) - f_2(x)$, $g''(f_1(x), f_2(x)) = f_1''(x) - f_2''(x)$, this will be convex where $f_1''(x) \\geq f_2''(x)$. For example, for $f_1(x) = x^2$, $f_2(x) = x^3$, $g(x)$ will be convex where the 2nd derivative $2 - 6x \\geq 0$, ($x \\leq \\frac{1}{3}$).\n\\item \\textbf{Binary Composition with bounds:} Given a particular interval $x \\in I$ in which $f_1''(x) \\in [d_{1low}, d_{1high}]$ and $f_2''(x) \\in [d_{2low}, d_{2high}]$, $g(x)$ will be convex if $d_{1low} - d_{2high} \\geq 0$, since this means $g''(x) \\geq 0$ for $x \\in I$.\n\\item \\textbf{Step size:} Does not effect single function composition, for multiple function composition $x$ becomes $\\frac{x}{s}$ (for step size $s$), which may effect the regions where $g(x)$ is convex depending on the input functions.\n\\end{enumerate}\n\n\\textbf{Multiplication}\n\\begin{enumerate}\n\\item \\textbf{Function:} $g(x) = cx$  is trivially convex, since $g''(x) = 0$. , \n\\item \\textbf{Composition:}  $g \\circ f$ is convex for convex $f$ when $c \\geq 0$, since $g'(x) = c$. For concave $f$, the inverse holds. If $f''(x)$ is bounded, this simply means the lower bound must greater than 0 if $c>0$, or the upper bound must be less than 0 if $c<0$.\n\\item \\textbf{Binary Composition:} For multiplication given two convex input functions $f_1$ and $f_2$: $g(f_1(x), f_2(x)) = f_1(x) * f_2(x)$. This is not convex in general, counterexample $g(-x, x) = -x^2$, but can be convex or convex in regions.\n\\item \\textbf{Binary Composition with Bounds:} \\h{Bounds don't seem to help much here, it seems you need more information about the functions. Example $g(x^2, -(x-2))$ is convex for $x<\\frac{2}{3}$, how do you predict that from bounds on derivatives?}\n\n\\item \\textbf{Step size:} $x = \\frac{x}{s}$, does not effect single function composition.\n\\end{enumerate}\n\n\n\\textbf{Division}\n\\begin{enumerate}\n\\item \\textbf{Function:} $g(x) = x/c$  is trivially convex, since $g''(x) = 0$. For $g(x) = c/x$, $g''(x) = 2cx^{-3}$, this is convex for $x \\in [0, \\inf), c \\geq 0$, and $x \\in (-\\inf, 0), c < 0$. (note, may need to adjust this for integer division)\n\\item \\textbf{Composition:} For $g(x) = x/c$, $g \\circ f$ is convex when $c \\geq 0$, since $g'(x) = c^{-1}$.  For $g(x) = c/x$, $g'(x) = -cx^{-2}$, then $\\forall c < 0: g'(x) \\geq 0$, and it is convex under composition for all $f(x)<0$. \n\\item \\textbf{Binary Composition:} Given two convex input functions $f_1$ and $f_2$: $g(f_1(x), f_2(x)) = f_1(x) / f_2(x)$. This is not convex in general, counterexample $g(x, x^2) = 1/x$, inputs are convex but output is concave, however it can still be convex or convex in regions.\n\\item \\textbf{Binary Composition with Bounds:} \\h{Similar issues to multiplication here.}\n\\item \\textbf{Step size:} $x = \\frac{x}{s}$, does not effect single function composition.\n\\end{enumerate}\n\n\\textbf{Exponentiation}\n\\begin{enumerate}\n\\item \\textbf{Function:} $g(x) = x^c$  is convex if $c \\mod 2 = 0$, since $g''(x) = (c-1)(c-2)x^{c-2} \\geq 0$ if $c$ is even. If $c$ is odd, $g''(x) \\geq 0$ for $x > 0$, so the function will be convex for $x>0$. ($x^1$ is the exception is convex everywhere).  For $g(x) = c^x$, it is convex for $c>0$ since $g''(x) = c^x \\log^2(x)$. For $c<0$, the sign alternates so the function is convex over every interval $(x, x+2)$.\n\n\\item \\textbf{Composition:} For $g(x) = x^c$, $g \\circ f$ has second derivative $g''(x) = c(c-1) (f(x))^{c-2}f'(x) + cf(x)^{c-1}f''(x)'$. \n\\item \\textbf{Binary Composition:} For given two convex input functions $f_1$ and $f_2$: $g(f_1(x), f_2(x)) = f_1(x) ^ f_2(x)$. This does not preserve convexity in general, counterexample $g(-x, x) = -x^2$, inputs are convex but output is concave. \n\\item \\textbf{Step size:}  $x = \\frac{x}{s}$, does not effect single function composition, where $g(x) = f(x)^c$, but renders analysis for $g(x) = c^{f(x)}$ invalid.\n\\end{enumerate}\n\n\\subsection{Bitwise Operations}\n\n%\\textbf{And}\n\\subsubsection*{And}\n\\begin{enumerate}\n\\item \\textbf{Function:} For $g(x) = x \\& c$, $g(x)$ will be convex in the following regions: let $k$ denote the number of contiguous leading bits in $c$ that share the same value, either 0 or 1. Then $g(x)$ will be convex where $x \\in [x_k, x_k + 2^k - 1], x_k \\mod 2^k = 0$. \n\n{\\it Proof.} \n\n{\\it Lemma 1} Only the first $k$ bits of $x$ change in the region $x \\in [x_k, x_k + 2^k - 1] x_k \\mod 2^k = 0$. Pf. The first $k$ bits of $x_k$ are 0 b/c $x_k \\mod 2^k = 0$. Since the maximum in the region $x \\in [x_k, x_k + 2^k - 1] x_k \\mod 2^k = 0$ from $x_k$ is $2^k-1$, which is also represented in $k$ 1s, all changes in the region from $x_k$ only effect the first $k$ bits.\n\nThere are two cases, either the first $k$ bits are 0s or they are 1s. If they are 0s, then $g(x)$ will not change in the region $[x_k, x_k = 2^k-1]$ because from \\textbf{lemma 1} only the first $k$ bits will change and the first $k$ bits are being bitwise $\\&$ with $k$ 0s. Then $g(x) = g(x_k)$ in the region, and the definition of convexity applies. If the first $k$ bits are 1s, then from \\textbf{lemma 1} any change in $x$ is anded with 1s, and $g(x) = g(x_k) + x - x_k$, which is linear and therefore a convex function.\n\nAlso note that for leading 1s, in some places the convexity region can be extended to include $x_k-1$: $x \\in [x_k - 1, x_k + 2^k - 1] x_k \\mod 2^k = 0$, while for the leading 0s, in some places the upper bound could be extended to $x_k + 2^k$. However these cases do not apply to all regions.\n\n\\item \\textbf{Composition:} For $g \\circ f$, the previous analysis holds when the leading bits are 0s for $f(x) \\in [f(x)_k, f(x)_k + 2^k - 1] f(x)_k \\mod 2^k = 0$, since $g(x)$ will still be constant in those regions. If the leading bits are 1s, then $g(x)$ is equivalent to multiplication by $1$ of $-1$, and convexity will be preserved if $f''(x) > 0$, or inverted if $f''(x) < 0$.\n\\item \\textbf{Output bounds:} For leading 1s, bounds are limited to bounds in the convex region defined by the bitwise operation, or could remain the same if evaluating the input 2nd derivative in the region for tighter bounds is not feasible. For leading 0s, the 2nd derivative is set to 0 within the flat (convex) intervals.\n\\item \\textbf{Step size:} If $s < 2^k$, then step size shrinks the convexity bounds to $\\frac{2^k}{s}$, for $s > 2^k$, the input will jump between convex regions on changes in $x$. \n\\end{enumerate}\n\n\\textbf{Composition} If $f$ and $g$ are convex, $g \\circ f$ is convex on intervals where $g' \\geq 0$, (ie where $g$ is monotonically increasing).\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{figs/and.png}\n  \\caption{Convex regions for bitwise \\textbf{and}}\n\\end{figure}\n\n%\\textbf{Or}\n\\subsubsection*{Or}\n\\begin{enumerate}\n\\item \\textbf{Function:}  For $g(x) = x | c$, $g(x)$ will be convex in the following regions: let $k$ denote the number of contiguous leading bits in $c$ that share the same value, either 0 or 1. Then $g(x)$ will be convex where $x \\in [x_k, x_k + 2^k - 1], x_k \\mod 2^k = 0$. \n\n{\\it Proof.} There are two cases, either the first $k$ bits are 0s or they are 1s. If they are 1s, then $g(x)$ will not change in the region $[x_k, x_k = 2^k-1]$ because from \\textbf{lemma 1} only the first $k$ bits will change and the first $k$ bits are being bitwise $|$ with $k$ 1s, setting them all to 1. Then $g(x) = g(x_k)$ in the region, and the definition of convexity applies. If the first $k$ bits are 0s, then from \\textbf{lemma 1} any change in $x$ is bitwise \\textbf{or}ed with 1s, and $g(x) = g(x_k) + x - x_k$, which is linear and therefore a convex function. \n\n\\item \\textbf{Composition:} For $g \\circ f$, the previous analysis holds when the leading bits are 1s for $f(x) \\in [f(x)_k, f(x)_k + 2^k - 1] f(x)_k \\mod 2^k = 0$, since $g(x)$ will still be constant in those regions. If the leading bits are 0s, then $g(x)$ is equivalent to multiplication by $1$ of $-1$, and convexity will be preserved if $c > 0$, or inverted if $c < 0$. \n\\item \\textbf{Step size:} If $s < 2^k$, then step size shrinks the convexity bounds to $\\frac{2^k}{s}$, for $s > 2^k$, the input will jump between convex regions on changes in $x$. \n\\item \\textbf{Output bounds:} For leading 0s, bounds are limited to bounds in the convex region defined by the bitwise operation, or could remain the same if evaluating the input 2nd derivative in the region for tighter bounds is not feasible. For leading 1s, the 2nd derivative is set to 0 within the flat (convex) intervals.\n\\end{enumerate}\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{figs/or.png}\n  \\caption{Convex regions for bitwise \\textbf{or}}\n\\end{figure}\n\n\n%\\textbf{Not}\n\\subsubsection*{Not}\n\\begin{enumerate}\n\\item \\textbf{Function:} For $g(x) = ~x$, this is equivalent to $g(x) = -x - 1$, and as a linear function is convex. \n\\item \\textbf{Composition:} For $g \\circ f$, $f$ will be inverted so that concave regions become convex. \n\\end{enumerate}\n\n%\\textbf{Xor}\n\\subsubsection*{Xor}\n\\begin{enumerate}\n\\item \\textbf{Function:} For $g(x) = x \\oplus c$, $g(x)$ will be convex in the following regions: let $k$ denote the number of contiguous leading bits in $c$ that share the same value, either 0 or 1. Then $g(x)$ will be convex where $x \\in [x_k, x_k + 2^k - 1], x_k \\mod 2^k = 0$. \n\n{\\it Proof.} There are two cases, either the first $k$ bits are 0s or they are 1s. If they are 0s, then $g(x) = g(x_k) + x - x_k$  in the region $[x_k, x_k = 2^k-1]$ because from \\textbf{lemma 1} only the first $k$ bits will change and the first $k$ bits are being bitwise $\\oplus$ with $k$ 0s, leaving them unchanged, and the definition of convexity applies. If the first $k$ bits are 1s, then from \\textbf{lemma 1} any change in $x$ is bitwise $\\oplus$ed with 1s, and $g(x) = g(x_k) - x + x_k$, which is also linear and therefore a convex function. \n\\item \\textbf{Composition:} For $g \\circ f$, $f$ will be unchanged in the convex regions if there are leading 0s, preserving convexity in these regions, or inverted if there are leading 1s, making any concave parts of the function convex.\n\\item \\textbf{Step size:} If $s < 2^k$, then step size shrinks the convexity bounds to $\\frac{2^k}{s}$, for $s > 2^k$, the input will jump between convex regions on changes in $x$. \n\\item \\textbf{Output bounds:} For leading 1s, bounds are inverted in the convex region defined by the bitwise operation. For leading 1s, bounds remain the same, or could be tightened to the range within the convex region of the xor.\n\\end{enumerate}\n\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{figs/xor.png}\n  \\caption{Convex regions for bitwise \\textbf{xor}}\n\\end{figure}\n%\\begin{figure}\n  %\\centering\n%\\begin{subfigure}{.5\\textwidth}\n  %\\centering\n  %%\\includegraphics[width=\\linewidth]{figs/mlp2.png}\n  %\\includegraphics[height=6cm]{figs/mlp2.png}\n  %\\caption{Multilayer Perceptron with 2 hidden layers.}\n%\\end{subfigure}%\n%\\begin{subfigure}{.5\\textwidth}\n  %\\centering\n  %\\includegraphics[height=6.5cm]{figs/mlp3.png}\n  %\\caption{Multilayer Perceptron with 2 hidden layers and residual connections.}\n%\\end{subfigure}\n  %\\caption{Two Layer MLPs.}\n  %\\label{fig:mlp2}\n%\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "9fcba71d4c39e54abca7f5f163a2fab634c0359f", "size": 14686, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exps/standalone/convex_analysis/convex_analysis.tex", "max_stars_repo_name": "sillywalk/grazz", "max_stars_repo_head_hexsha": "a0adb1a90d41ff9006d8c1476546263f728b3c83", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exps/standalone/convex_analysis/convex_analysis.tex", "max_issues_repo_name": "sillywalk/grazz", "max_issues_repo_head_hexsha": "a0adb1a90d41ff9006d8c1476546263f728b3c83", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exps/standalone/convex_analysis/convex_analysis.tex", "max_forks_repo_name": "sillywalk/grazz", "max_forks_repo_head_hexsha": "a0adb1a90d41ff9006d8c1476546263f728b3c83", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.3069767442, "max_line_length": 575, "alphanum_fraction": 0.692564347, "num_tokens": 5058, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.4298676191666047}}
{"text": "\\documentclass[../thesis.tex]{subfiles}\n\n%!TeX spellcheck = en-GB\n\n% chktex-file 18\n\n\\begin{document}\n\n\\chapter{Results}\n\\label{chap:results}\n\nFor all values of the control parameter,\\(B\\), we observed that the\nnearest neighbour distributions deviate from both the Poisson and Wigner distributions.\nWe propose the following hypothesis: the obtained nearest neighbour distributions\ncan be seen as a linear superposition of the\nPoisson and Wigner distributions:\n\\[\n  P(s) = \\alpha P_P(s) + (1-\\alpha) P_W(s).\n\\]\n\nThis hypothesis is rooted in the fact that the classical counterpart of our system\nhas an interplay between regular and chaotic motion clearly illustrated by the Poincaré\nsections in figures~\\ref{fig:ponicare-sections}~\\cite{Baran1998}.\nIn this way we consider that for a range of energies of the classical system,\nthe phase space ratio of the volumes of chaotic and regular trajectories is\nreflected in the the superposition of Wigner and Poisson distributions.\n\nThus, a system with an integrable classical counterpart will have \\({\\alpha=1}\\),\ncorresponding to the Poisson distribution, while a fully chaotic\nsystem will have \\(\\alpha=0\\) corresponding to the Wigner distribution. For\na system which has balanced contributions to the phase space volume both from\nthe regular and chaotic trajectories, we expect the Poisson and Wigner distributions\nto equally contribute to \\(P(s)\\).\n\nFor the fixed value of the non-integrability parameter of \\(B=0.55\\) we observe that\nwith the increase of energy, the phase space fills with tori up to a energy of\naround \\(E=600\\) (in units of harmonic oscillator energy) and after that the chaotic trajectories begin to fill\nthe phase space. We can say that globally, for an energy range \\(\\Delta E \\leq 600\\),\nthe phase space is characterised by an increase of regular trajectories as the\nenergy increases. If we now consider the quantum counterpart of the system, we\ncan use \\(\\alpha \\) as a measure of the closeness to the Poisson distribution.\nAs we can see in figures~\\ref{fig:fit-b0.55n260-me100-120} and~\\ref{fig:fit-b0.55n260-me150-180.3}\nwith the increase of the energy interval \\(\\alpha \\) increases from \\(0.493\\) at\n\\(\\Delta E \\approx 100 \\) to \\(0.876\\) at \\(\\Delta E \\approx 180 \\).\n\nThus, at least for a fixed value of $B$, we can observe a correlation between\nthe tori volume in phase space and \\(\\alpha \\), the superposition coefficient.\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_30}  % chktex 36\n\\label{fig:ponicare-sections-e_30}\n\\end{subfigure}\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_120}  % chktex 36\n\\label{fig:ponicare-sections-e_120}\n\\end{subfigure}\n\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_240}  % chktex 36\n\\label{fig:ponicare-sections-e_240}\n\\end{subfigure}\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_400}  % chktex 36\n\\label{fig:ponicare-sections-e_400}\n\\end{subfigure}\n\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_600}  % chktex 36\n\\label{fig:ponicare-sections-e_600}\n\\end{subfigure}\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics{ponicare-sections-e_1000}  % chktex 36\n\\label{fig:ponicare-sections-e_1000}\n\\end{subfigure}\n\\caption{Poincaré sections for \\(B=0.55\\) and \\(E=30A (\\text{MeV})\\) (b), \\({E=120A (\\text{MeV})}\\) (c),\n\\(E=240A (\\text{MeV})\\) (d), \\(E=400A (\\text{MeV})\\) (e), \\(E=600A (\\text{MeV})\\) (f), \\({E=1000A (\\text{MeV})}\\) (g).}\n\\label{fig:ponicare-sections}  % chktex 24\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.55 D0.4 N260\"/{P(s)_fit_1e-09_eps_1e-08_max_e_100.0}.pdf}  % chktex 36\n\\label{fig:P(s)-fit-b0.55n260-me100}\n\\end{subfigure}\n\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.55 D0.4 N260\"/{P(s)_fit_1e-09_eps_1e-08_max_e_120.0}.pdf}  % chktex 36\n\\label{fig:P(s)-fit-b0.55n260-me120}\n\\end{subfigure}\n\\caption{\\(P(s)\\) for \\(B=0.55, D=0.4, N=260\\) and \\(\\Delta E_{max}=100, 120\\)}\n\\label{fig:fit-b0.55n260-me100-120}  % chktex 24\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.55 D0.4 N260\"/{P(s)_fit_1e-09_eps_1e-08_max_e_150.0}.pdf}  % chktex 36\n\\label{fig:P(s)-fit-b0.55n260-me150}\n\\end{subfigure}\n\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.55 D0.4 N260\"/P(s)_fit_1e-09_eps_1e-08}  % chktex 36\n  \\label{fig:P(s)-fit-b0.55n260}  % chktex 24\n\\end{subfigure}\n\\caption{\\(P(s)\\) for \\(B=0.55, D=0.4, N=260\\) and \\(\\Delta E_{max}=150, 180.3\\)}\n\\label{fig:fit-b0.55n260-me150-180.3}  % chktex 24\n\\end{figure}\n\n\\clearpage\n\nLooking at other values for \\(B\\) such as \\(B=0.2\\) and \\(B=0.63\\), we observe\nthat \\(P(s)\\) gets closer to a Poisson distribution with the increase of energy\n(see~\\cref{fig:fit-b0.2n260,fig:fit-b0.63n260,fig:fit-b0.2n260-me100,fig:fit-b0.63n260-me100}).\nThis global feature of the system can be observed on the entire interval from\n\\(B=0.01\\) to \\(B=0.63\\). In order to emphasise this, we plot \\(\\alpha \\)\nas a function of \\(\\Delta E\\)\n(see~\\cref{fig:alpha-e-b0.1-0.15-0.2,fig:alpha-e-b0.25-0.3-0.35,fig:alpha-e-b0.4-0.45-0.5,fig:alpha-e-b0.55-0.6-0.63}).\n\nThis remarkable behaviour can be viewed as consequence of the interplay of the\nthird and fourth order terms in the Hamiltonian. The third order terms, which\nconsist in the non-integrable part of the Hamiltonian and can be considered as\ncontributing to the apparition of chaotic trajectories.\n\n\\begin{figure}\n\\centering\n  \\begin{subfigure}{\\textwidth}\n    \\includegraphics{\"B0.2 D0.4 N260\"/P(s)_fit_1e-09_eps_1e-08}  % chktex 36\n    \\label{fig:P(s)-fit-b0.2n260}  % chktex 24\n  \\end{subfigure}\n\n  \\begin{subfigure}{\\textwidth}\n    \\includegraphics{\"B0.2 D0.4 N260\"/I(s)_fit}  % chktex 36\n  \\label{fig:I(s)-fit-b0.2n260}  % chktex 24\n  \\end{subfigure}\n  \\caption{\\(P(s), I(s)\\) for \\(B=0.2, D=0.4, N=260\\)}\n  \\label{fig:fit-b0.2n260}  % chktex 24\n\\end{figure}\n\n\\begin{figure}\n\\centering\n  \\begin{subfigure}{\\textwidth}\n    \\includegraphics{\"B0.63 D0.4 N260\"/P(s)_fit_1e-09_eps_1e-08}  % chktex 36\n    \\label{fig:P(s)-fit-b0.63n260}  % chktex 24\n  \\end{subfigure}\n\n  \\begin{subfigure}{\\textwidth}\n    \\includegraphics{\"B0.63 D0.4 N260\"/I(s)_fit}  % chktex 36\n  \\label{fig:I(s)-fit-b0.63n260}  % chktex 24\n  \\end{subfigure}\n  \\caption{\\(P(s), I(s)\\) for \\(B=0.63, D=0.4, N=260\\)}\n  \\label{fig:fit-b0.63n260}  % chktex 24\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.2 D0.4 N260\"/{P(s)_fit_1e-09_eps_1e-08_max_e_100.0}.pdf}  % chktex 36\n\\label{fig:P(s)-fit-b0.2n260-me100}\n\\end{subfigure}\n\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.2 D0.4 N260\"/{I(s)_fit_max_e_100.0}.pdf}  % chktex 36\n  \\label{fig:I(s)-fit-b0.2n260-me100}  % chktex 24\n\\end{subfigure}\n\\caption{\\(B=0.2, D=0.4, N=260, \\Delta E_{max}=100\\)}\n\\label{fig:fit-b0.2n260-me100}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.63 D0.4 N260\"/{P(s)_fit_1e-09_eps_1e-08_max_e_100.0}.pdf}  % chktex 36\n\\label{fig:P(s)-fit-b0.63n260-me100}\n\\end{subfigure}\n\n\\begin{subfigure}{\\textwidth}\n  \\includegraphics{\"B0.63 D0.4 N260\"/{I(s)_fit_max_e_100.0}.pdf}  % chktex 36\n  \\label{fig:I(s)-fit-b0.63n260-me100}  % chktex 24\n\\end{subfigure}\n\\caption{\\(B=0.63, D=0.4, N=260, \\Delta E_{max}=100\\)}\n\\label{fig:fit-b0.63n260-me100}\n\\end{figure}\n\n% alpha(deltaE)\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_e_B[0.1, 0.15, 0.2]\"_N[260]}.pdf}  % chktex 36\n  \\caption{\\(B=0.1, 0.15, 0.2,\\; N=260\\)}\n\\label{fig:alpha-e-b0.1-0.15-0.2}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_e_B[0.25, 0.3, 0.35]\"_N[260]}.pdf}  % chktex 36\n  \\caption{\\(B=0.25, 0.3, 0.35,\\; N=260\\)}  % replace\n\\label{fig:alpha-e-b0.25-0.3-0.35}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_e_B[0.4, 0.45, 0.5]\"_N[260]}.pdf}  % chktex 36\n  \\caption{\\(B=0.4, 0.45, 0.5,\\; N=260\\)}  % replace\n\\label{fig:alpha-e-b0.4-0.45-0.5}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_e_B[0.55, 0.6, 0.63]\"_N[260]}.pdf}  % chktex 36\n  \\caption{\\(B=0.55, 0.6, 0.63,\\; N=260\\)}   % replace\n\\label{fig:alpha-e-b0.55-0.6-0.63}\n\\end{figure}\n\nAn other global characteristic of the system can be revealed by studying the\ndependence of \\(\\alpha \\) on the non-integrability parameter $B$.\nIn figure~\\ref{fig:alpha-n220-240-260} \\(\\alpha(B)\\) is plotted for\ndifferent values of $N$. The value of $N$ determines both the stability\nof the values and the maximum energy interval. Indeed, since our method implies the\ntruncation of the Hilbert space, we restrict the number of considered energy\nlevels with the stability criterion.\n\nAs with the above case of \\(\\alpha(\\Delta E)\\), we can reduce the energy interval\nby considering only the energy levels up to a given value. In figures~\\ref{fig:alpha-n260-me100-120-140}\nand~\\ref{fig:alpha-n260-me140-160-0} we can see that the shape of \\(\\alpha(B)\\)\nfor \\(N=260\\) remains qualitatively the same when we consider different\nvalues for the maximum energy interval. We can observe that as we increase\nthe energy the values of \\(\\alpha \\) globally rise, as expected from the\nprevious plots.\n\nAn other qualitative test of our data implies checking how the values of\n\\(\\alpha \\) change when we consider different values for \\(N\\), in this\ncase \\(N=220, 240, 260\\) and different energy intervals. By considering\nmultiple values for $N$ we can check the stability of the energy levels\nwithin a given interval provided that the respective interval is less than\nthe maximum energy interval for all $N$.\nIn~\\cref{fig:alpha-n220-240-260-me100,fig:alpha-n220-240-260-me120,fig:alpha-n220-240-260-me140}\nwe can see that indeed the energy levels\nare stable as the values of \\(\\alpha \\) barely change.\n\n% alpha(B)\n\n\\begin{figure}\n  \\includegraphics{\"alpha_N[220, 240, 260]\".pdf}  % chktex 36\n  \\caption{\\(N=220, 240, 260\\)}\n\\label{fig:alpha-n220-240-260}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{alpha_N[260]_max_e_\"[100.0, 120.0, 140.0]\"}.pdf}  % chktex 36\n  \\caption{\\(N=260,\\; \\Delta E_{max} \\approx 100, 120, 140\\)}\n\\label{fig:alpha-n260-me100-120-140}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{alpha_N[260]_max_e_\"[140.0, 160.0, 0.0]\"}.pdf}  % chktex 36\n  \\caption{\\(N=260,\\; \\Delta E_{max} \\approx 140, 160, 190.305\\)}\n\\label{fig:alpha-n260-me140-160-0}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_N[220, 240, 260]\"_max_e_[100.0]}.pdf}  % chktex 36\n  \\caption{\\(N=220, 240, 260,\\; \\Delta E_{max} \\approx 100\\)}\n\\label{fig:alpha-n220-240-260-me100}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_N[220, 240, 260]\"_max_e_[120.0]}.pdf}  % chktex 36\n  \\caption{\\(N=220, 240, 260,\\; \\Delta E_{max} \\approx 120\\)}\n\\label{fig:alpha-n220-240-260-me120}\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{{\"alpha_N[220, 240, 260]\"_max_e_[140.0]}.pdf}  % chktex 36\n  \\caption{\\(N=220, 240, 260,\\; \\Delta E_{max} \\approx 140\\)}\n\\label{fig:alpha-n220-240-260-me140}\n\\end{figure}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "89c40ca4ceb7194a77a3eda9604f3ea8d4d43359", "size": 10951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/Results/results.tex", "max_stars_repo_name": "SebastianM-C/Bachelor-Thesis", "max_stars_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-19T23:15:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T23:15:42.000Z", "max_issues_repo_path": "Manuscript/Results/results.tex", "max_issues_repo_name": "SebastianM-C/Bachelor-Thesis", "max_issues_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manuscript/Results/results.tex", "max_forks_repo_name": "SebastianM-C/Bachelor-Thesis", "max_forks_repo_head_hexsha": "30ced37a8638e71ff5fc53d2dd4b608f0f9f8d02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-19T23:15:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-19T23:15:46.000Z", "avg_line_length": 39.1107142857, "max_line_length": 119, "alphanum_fraction": 0.7132681947, "num_tokens": 4067, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6825737344123243, "lm_q1q2_score": 0.4298676056140858}}
{"text": "\\documentclass[twoside,11pt]{article}\n\n% Any additional packages needed should be included after jmlr2e.\n% Note that jmlr2e.sty includes epsfig, amssymb, natbib and graphicx,\n% and defines many common macros, such as 'proof' and 'example'.\n%\n% It also sets the bibliographystyle to plainnat; for more information on\n% natbib citation styles, see the natbib documentation, a copy of which\n% is archived at http://www.jmlr.org/format/natbib.pdf\n\n\\usepackage{jmlr2e}\n\\usepackage{amsmath}\n\\usepackage{algorithm}\n\\usepackage{bm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{wrapfig}\n\\usepackage{float}\n\n% Definitions of handy macros can go here\n\n\\newcommand{\\dataset}{{\\cal D}}\n\\newcommand{\\fracpartial}[2]{\\frac{\\partial #1}{\\partial  #2}}\n\n% Heading arguments are {volume}{year}{pages}{submitted}{published}{author-full-names}\n\n% \\jmlrheading{1}{2017}{1-48}{4/00}{10/00}{Taylor G. Smith and Jason M. White}\n\n% Short headings should be running head and authors last names\n\n\\ShortHeadings{Correcting Class Imbalance with Variational Auto-Encoders}{Smith and White}\n\\firstpageno{1}\n\n\\begin{document}\n\n\\title{On the Synthetic Generation of Minority Class Observations Using Variational Auto-Encoders}\n\n\\author{\\name Taylor G.\\ Smith \\email taylor.smith@alkaline-ml.com\n       \\AND\n       \\name Jason M.\\ White \\email jason.m.white5@gmail.com}\n\n\\editor{Michael Bernico}\n\\maketitle\n\n\\begin{abstract}%   <- trailing '%' for backward compatibility of .sty file\nThis document describes a methodology by which to remedy imbalanced datasets for the purpose of classification. A dataset may be considered imbalanced if its classification labels are disproportionately represented across classes. In many real-world domains, class imbalance---or the presence of extremely rare events which may be costly to misclassify---is quite prevalent. Commonly cited problem domains include fraud detection, medical imaging, anomaly detection and countless more.  Our procedure augments the Synthetic Minority Over-sampling Technique \\citep*{chawla2002smote}---or SMOTE---by training generative variational auto-encoders on the minority class(es) for the purpose of creating synthetic examples. This ensures a set of synthetic observations that are more true to the most archetypal observed points in the minority class.\n\\end{abstract}\n\n\\begin{keywords}\n  classification, class-imbalance, cost-sensitive learning, SMOTE, variational auto-encoders, skewed distributions\n\\end{keywords}\n\n\\section{Introduction}\n\nA dataset may be considered imbalanced if its classification labels are disproportionately represented across classes. While class imbalance is very common and manifests itself in varying degrees, of particular interest are the cases in which one class---the majority class---is significantly more present than one or more minority classes, which are represented at a much smaller ratio. This can detrimentally impact a learning algorithm's ability to estimate a generalizable decision boundary. Consider, for instance, a medical test to determine whether a patient suffers a rare disease. The dataset may be 99.8\\% composed of negative observations with only 0.2\\% positive examples. Even the most na\\\"ive classifier can achieve 99.8\\% classification accuracy in this case by simply learning to always predict the negative class \\citep{lewis1994heterogeneous}. However, the utility of this test is completely absent, since it will never accurately predict the condition of value. This is by no means an isolated case, either; many machine learning domains---such as fraud detection, network security, spam filtration---frequently face some level of class imbalance. This paper presents some of the pitfalls of training machine learning models on such dataset, and presents a remedying class-balancing technique.\n\nThroughout this paper, we focus on inducing classification algorithms on a given training set, $X \\in \\mathbb{R}^{m \\times n}$, with a corresponding set of class labels, $y \\in \\{0, 1, ..., c\\}$ in which one or more of the minority class labels is/are represented at a significantly smaller proportion than that of one or more majority class labels. As noted by countless studies and the aforementioned medical test example, classifier efficacy often cannot meaningfully be measured via conventional, cost-insensitive metrics such as accuracy (or the percentage of testing observations properly identified by the learner). This greatly complicates the classification task since such metrics will offer misleadingly optimistic scores on an otherwise ineffective classifier. Therefore, what makes class imbalance a particularly interesting and relevant problem is the frequent tangible cost with which misclassification of rare events is typically associated. The real-world impact of such errors can be especially perilous in the medical domain, where diagnostic datasets are especially susceptible to class disparity, as high risk examples of interest (e.g., instances of rare diseases) tend to constitute the minority class \\citep{rahman2013addressing}.\n\nSection 2 presents previous work to which our approach may be compared. Section 3 introduces generative models, and more specifically, variational auto-encoders. Section 4 outlines the details of our technique. Section 5 details the specifics of our experiments and the performance of our technique compared with other common class imbalance solutions. \\\\\n\n\\section{Previous Work}\n\nThe problem of class imbalance is not a new one; for a long time, the machine learning community has attempted to address the problem of class imbalance in several ways: class weighting---such as the development of cost-sensitive classification metrics like the ROC convex hull \\citep{provost2001robust} or the F-measure \\citep{lewis1994training}---which assigns a heavier cost to misclassified events in the positive class, and data preparation tasks that either resample or manipulate the input data before building a model. Our approach can be considered one of the latter, and seeks to synthetically augment the training set irrespective of the selected scoring metric. We present existing research for each of the strategies in the following subsections.\n\n\\subsection{Over-sampling minority class samples}\n\nResearch on the efficacy of resampling as a preprocessing technique for imbalanced datasets has been extensively conducted. One common approach for resampling a training set is over-sampling the minority class examples with replacement \\citep{japkowicz2000class}. She proposed several variants of over-sampling, with varying degrees of success. Her random resampling approach drew minority samples with replacement until the minority class was represented at the same magnitude as the majority class. She also proposed ``focused resampling,\" which only drew minority samples from along the decision boundary between the majority and minority classes. \n\nOf note is the fact that she observed no clear advantage between generalized over-sampling and her ``focused\" over-sampling \\citep{japkowicz2000class}. Using a decision tree classifier, \\citet{chawla2002smote} showed that duplicating minority observations actually further narrowed the (theoretically, already very small) decision region, causing more splits in the tree and leading to overfitting.\n\n\n\\subsection{Under-sampling majority class samples}\n\nIn conjunction with her research on over-sampling methods, \\citet*{japkowicz2000learning} showed that under-sampling the majority class can be effective---especially in tasks where $c > 2$---presenting the added benefit of reducing the training set size, and consequently the complexity of the training task. However, in cases of extreme class disparity, the amount of down-sampling required to balance the class labels may so significantly diminish the size of the dataset that it could become unusable.\n\n\\citet*{kubat1997addressing} proposed a more sophisticated form of under-sampling by which the majority class samples are segmented into one of four categories: those suffering \\emph{class-label noise}, unreliable \\emph{borderline} samples that sit near the decision surface, \\emph{redundant} examples, and \\emph{safe} examples (archetypal to the majority class representation, and necessary for training). They showed that the noisy and border-point majority class examples could easily be recognized in the training set by identifying and removing majority class samples that form \\emph{Tomek links} \\citep{tomek1976two} with minority class samples.\n\n\\subsection{Synthesizing minority class samples}\n\nRather than simply sampling the minority class with replacement, \\cite{chawla2002smote} proposed the over-sampling of synthetic minority class observations.  As previously mentioned, they implemented the SMOTE algorithm which uses randomly sampled minority class observations' \\emph{k}-nearest neighbors to generalize minority class decision region neighborhoods: for each of $p$ randomly sampled minority observations, $\\mathbf{x}^{(i)} \\in \\mathbb{R}^{n}$, compute the \\emph{k}-nearest neighbors to $\\mathbf{x}^{(i)}$, denoted as $\\mathbf{J} \\in \\mathbb{R}^{k \\times n}$, and generate a synthetic example, $\\mathbf{x}^{(i)\\prime}$, between $\\mathbf{x}^{(i)}$ and each nearest neighbor, $\\mathbf{j}^{(l)}$:\n\\[\n    \\mathbf{x}^{(i)\\prime} = \\mathbf{x}^{(i)} + gap * (\\mathbf{j}^{(l)} - \\mathbf{x}^{(i)})\n\\]\nwhere $gap$ is a random scalar between 0 and 1. The application of SMOTE has been shown to effectively aid in generalizing the decision region for the minority class(es) by synthetically creating minority class observations \\citep*{chawla2002smote}. However, it runs the risk of ``\\emph{over}-generalized'' minority decision regions in cases of significant class overlap.\n\nFigure 1 shows an unbalanced dataset with significant overlap between classes. The decision regions for the minority class are narrow with respect to the total decision space, and classification performance is poor. Figure 2 shows the same dataset after being balanced by SMOTE. The decision region for the minority class, though significantly generalized, has bled so far into the majority class space as to diminish the utility of the classifier.\n\n%\\newpage\n%\\centerline{\n%  \\includegraphics[scale=.6]{no-balance.png}\n%}\n\n%\\newpage\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=.5]{no-balance.png}\n    \\caption[width=40mm]{An SVM classifier exhibits poor performance on a highly unbalanced dataset with significant class overlap \\& a narrow decision region for the positive class.}\n    \\label{fig:label}\n\\end{figure}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=.5]{smote-balance.png}\n    \\caption[width=40mm]{The same dataset, after being balanced with SMOTE. The decision region has been over-generalized to the point of bleeding so far into the positive decision space that the usefulness of the classifier is diminished.}\n    \\label{fig:label}\n\\end{figure}\n\n\n\n\\section{Generative Models}\n\nAt a high level, generative methods are a family of unsupervised learning techniques that can be trained to generate synthetic data. Easy to conceptualize is the case of image datasets, where a model can be thought of as not simply memorizing input samples for some classification task, but learning features that can be used to create a stylistically canonical image that is completely fake, yet resembles a sample that \\emph{could} have been presented to the inducer for training. Thus, the advent of generative algorithms is that they do not simply learn the classification boundaries between classes---as do discriminative algorithms---but model the distribution by which the data itself was generated.\n\n\\subsection{Variational Auto-Encoders}\n\nSMRT is built atop variational auto-encoders. An auto-encoder is a special case of unsupervised multilayer perceptron (MLP) that estimates its own input vector as its output. In a more formal sense, the auto-encoder takes some input vector $\\mathbf{x} \\in  \\mathbb{R}^{n}$ and maps it deterministically to some hidden representation (typically a compressed space) $\\mathbf{y} \\in  \\mathbb{R}^{h}$ via $\\mathbf{y} = f_{\\theta}(\\mathbf{x}) = g(\\mathbf{Wx} + b)$, where $\\mathbf{W}$ is a $n \\times h$ matrix of weights parameterized by $\\theta = \\{\\mathbf{W, b}\\}$ \\citep{meyer2015introduction}. $b \\in \\mathbb{R}^{h}$ is a vector of biases generally initialized as $\\vec{1}$, and $g$ is the activation function---commonly either the \\emph{sigmoid} or \\emph{relu}:\n\\[\n    \\mathrm{sigmoid(x)} = \\frac{1}{1 + e^{-x}}\n\\]\n\\[\n    \\mathrm{relu(x)} = \\mathrm{max}(0,x)\n\\]\nThe goal, then, is that the mapping of $\\mathbf{x} \\rightarrow \\mathbf{y}$ reveals some non-linear  transformation of $\\mathbf{x}$, thus extracting new features derived by otherwise unobvious relationships between input features. This offers the ability to effectively reconstruct inputs with minimal error, while identifying high-reconstruction-error examples as anomalous, or non-conformant to the underlying learned distribution. The general architecture of an auto-encoder is dual: the encoding task either compresses or expands the input signal into the hidden layer space, while the decode task projects the hidden layer-transformed values back to the input space.\n\nWhereas general auto-encoders are deterministic MLPs, the \\emph{variational} auto-encoder (VAE) is a generative adaptation that consists of two parts: a \\emph{probabilistic} encoder, $q_{\\phi}(\\mathbf{z}|\\mathbf{x}^{(i)})$, that approximates the (intractable) posterior distribution, $p(\\mathbf{z}|\\mathbf{x}^{(i)})$; and a \\emph{generative} decoder, $p_{\\theta}(\\mathbf{x}^{(i)}|\\mathbf{z})$ which does not depend on any input \\citep{shiffman2016}. VAEs learn latent vectors, which approximate a unit Gaussian posterior, $\\mathbf{z}$, with a diagonal covariance structure \\citep{kingma2013auto}:\n\\[\n    \\log q_{\\phi}(\\mathbf{z}|\\mathbf{x}^{(i)}) = \\log \\mathcal{N}(\\mathbf{z}; \\bm{\\mu}^{(i)}, \\bm{\\sigma}^{2(i)}\\mathbf{I})\n\\]\nwhere the mean and standard deviation of $\\mathbf{z}$ (the approximate posterior), $\\bm{\\mu}^{(i)}$ and $\\bm{\\sigma}^{(i)}$, are the output of the auto-encoder's encode task \\citep{kingma2013auto}.\n\nThe VAE parameters are found by minimizing a dual loss-function: the combination of the reconstructive loss---the MSE of the input vector and the reconstructed vector---and the latent loss---the Kullback-Leibler (KL) divergence---which measures how well the latent vectors approximate the unit Gaussian:\n\\[\n    D_{KL}(q_{\\phi}(\\mathbf{z}|\\mathbf{x}^{(i)})\\parallel p_{\\theta}(\\mathbf{z}))\n\\]\nIn the decode stage, synthetic examples are generated by sampling the posterior:\n\\[\n    \\mathbf{z}^{(i,l)} \\sim q_{\\phi}(\\mathbf{z}|\\mathbf{x}^{(i)})\n\\]\nand finally decoding $\\mathbf{z}^{(i,l)}$ with either a Bernoulli or Gaussian multilayer perceptron \\citep{kingma2013auto}. The utility of using VAEs for class balancing is that the approximated posterior distribution will generate synthetic examples that are more probabilistically archetypal to the minority class samples, in similar fashion to the idea of ``safe examples'' proposed by \\citet{kubat1997addressing}.\n\n\n\\section{SMRT}\n\nWe present a generative over-sampling approach similar to SMOTE, by which the observations in each minority class are used to fit a variational auto-encoder, and synthetic examples are generated until the class is represented at the user-specified ratio. \\\\\n\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\begin{algorithm}\n\\caption{SMRT}\\label{smrt}\n  \\begin{algorithmic}[1]\n    \\Procedure{Balance}{$X, y, ratio$}\\Comment{Balance $X, y$ subject to $ratio$}\n      \\State $labels \\gets \\text{distinct } \\textit{y}$\n      \\State $majority \\gets argmax(count(y))$\n      \\State $nlabels \\gets \\text{length of } labels$\n      \\State $nreq \\gets int(ratio \\times \\text{number of majority samples in } \\textit{y})$\n      \\BState \\emph{loop}:\n      \\For{i := 1 to \\textit{nlabels}}\n        \\State $label \\gets labels[i]$\n        \\If {$label \\neq majority$}\\Comment{Skip the majority class}\n          \\State $Xsub \\gets X \\text{where } y = label$\n          \\State $p \\gets nreq - \\text{length of } Xsub$\\Comment{\\textit{n} needed for this class}\n          \\State \\text{Fit a variational auto-encoder with $Xsub$, call it $vae$}\n          \\State \\text{Generate $p$ synthetic examples from $vae$, update $X, y$}\n        \\EndIf\n      \\EndFor\n      \\Return{$X, y$}\\Comment{Optionally shuffle}\n    \\EndProcedure\n  \\end{algorithmic}\n\\end{algorithm}\n\n\n\\section{Experiments}\n\nWe used induced three different learners on each dataset: TODO\n\n\\subsection{Datasets}\n\n\n\\newpage\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "72fc263b07f4f5fe85872f9ef81100430553e1a4", "size": 16672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/smrt.tex", "max_stars_repo_name": "tgsmith61591/smite", "max_stars_repo_head_hexsha": "0863b0b94897ad8d8d9184b792cdb275627e1ac4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 113, "max_stars_repo_stars_event_min_datetime": "2017-03-09T18:02:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T23:07:14.000Z", "max_issues_repo_path": "doc/smrt.tex", "max_issues_repo_name": "tgsmith61591/smite", "max_issues_repo_head_hexsha": "0863b0b94897ad8d8d9184b792cdb275627e1ac4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-03-04T17:45:36.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-26T14:00:43.000Z", "max_forks_repo_path": "doc/smrt.tex", "max_forks_repo_name": "tgsmith61591/smite", "max_forks_repo_head_hexsha": "0863b0b94897ad8d8d9184b792cdb275627e1ac4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 31, "max_forks_repo_forks_event_min_datetime": "2017-04-18T10:09:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-26T21:24:26.000Z", "avg_line_length": 91.1038251366, "max_line_length": 1312, "alphanum_fraction": 0.7757917466, "num_tokens": 3989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4298676042612606}}
{"text": "A type classes are often compared to interfaces. It contains the function declarations. A type becomes an instance of a type class when it defines all required functions of the type class. When a type is an instance of a type class, we can make certain assumptions about behavior of the type. In contrary to interfaces, type classes aren't types. A value can have the type of an interface but not of a type class. Another difference to interfaces is that type classes describe functions and the instance types are part of the function signature. The instance type can be the return type. Interfaces define methods of the instance type.\n\nThe concept of a type class is explained by example with the function \\verb|show| from the \\verb|Prelude|-Library (\\verb|Prelude| is a module and part of the standard). \\verb|show| converts a given value of a type \\verb|a| into a character string. The type of \\verb|show| is\n\n\\begin{verbatim}\nshow :: Show a => a -> String\n\\end{verbatim}\n\nThe \\verb|Show a| before the \\verb|=>| is a type class constraint. \\verb|a| is a type variable. A type that has one more type variables is called polymorphic \\cite{hutton}. The signature means that \\verb|show| takes something that implements the type class \\verb|Show| and returns a string. \\verb|Show| is a type class. It's possible to call \\verb|show| with different types (e.g \\verb|show 1|, \\verb|show \"hello\"|). The compiler will look up the correct definition for us as long the type of the first parameter is an instance of the type class \\verb|Show|.  \nAny type that implements \\verb|Show| can be converted to a character string. Types in this class are \\verb|Bool|, \\verb|Char|, \\verb|Int|, \\verb|Float|, \\verb|Double| etc.\n\nThe type class \\verb|Show| is defined as follows:\n\\begin{verbatim}\nclass Show a where\n    show :: a -> String\n\\end{verbatim}\nThe keyword \\verb|class| defines a new type class. \\verb|a| is the type variable. It represents the type that implements the type class (e.g. \\verb|Int| or \\verb|Bool|).\n\nOnce we have a type class we are able to create instances of that class. The following listing defines a type \\verb|Person|. It has fields for name and email address. \\todo{loesung fuer schoene listings mit labels und caption finden und ueberall gleich machen}\n\\begin{verbatim}\ndata Person = Person { name :: String\n                       email :: String\n                     }\n\\end{verbatim}\n\nTo make \\verb|Person| an instance of \\verb|Show| we provide a function with the following type:\n\\begin{verbatim}\nshow :: Person -> String|\n\\end{verbatim}\n\n\\begin{verbatim}\ninstance Show Person where\n    show (Person name _) = name\n\\end{verbatim}\n\nThere many other useful type classes in the standard library.\n\n\\begin{description}\n\\item[Ord] Types with an order relation implement \\verb|Ord|.\n\\item[Eq] For types that can be equated.\n\\item[Read] Types that can be converted from a string.\n\\end{description}\n\nIt will explain the relation to polymorphism and describe type classes \\verb|Functor|, \\verb|Applicative| and \\verb|Monoid| in more detail as these type classes are important for the example in section \\ref{sec:example}.\n\nType classes allow programmers to write general definitions in a typesafe manner by use constrain the paramaters.\n\nPolymorphic functions can be applied to values with different types. \n\nIf a type can be converted to a string, it can be given the type class \\verb|Show|. The type \\verb|Person| has to provide an implementation for the function \\verb|show|. Applying \\verb|show| to \\verb|Person| results in a different behavior then applying \\verb|show| to an \\verb|Int|.\n\n\\subsection{Monoid}\n\nSome types, let's say \\verb|a|, have a binary function with the type declaration. \n\\begin{verbatim}\nf :: a -> a -> a\n\\end{verbatim}\n\nThe type \\verb|a| has a value that serves as identity for the given function. For example the number 1 is the identity for the multiplication. Multiplication of the identity and any other number $x$ results always in $x$.\n\nSeveral value of type \\verb|a| can always be reduces to a single value. It doesn't matter in which order we apply the function, the result is always the same. This is called associativity.\n\nIf type \\verb|a| has this behavior, it's a monoid and it can be an instance of the \\verb|Monoid| type class.\n\n\nThe \\verb|Monoid| type class is define as follows \\cite{monoid}:\n\\begin{verbatim}\nclass Monoid m where\n    mempty :: m\n    mappend :: m -> m -> m\n    mconcat :: [m] -> m\n    mconcat = foldr mappend mempty\n\\end{verbatim}\n\\verb|mconcat| takes a list of monoids and reduces them \\verb|mappend| to a single value, applying mappend. It has a default implementation.\n\nand \\verb|mappend| must be associative. There are three monoid laws \\cite{monoid}. This article deals only with the first law:\n\n\\begin{enumerate}\n\\item \\verb|mappend mempty x = x|\n\\item \\verb|mappend x mempty = x|\n\\item \\verb|(x `mappend y) `mappend z = x `mappend (y `mappend z)|\n\\end{enumerate}\n\nThe following Haskell types are \\verb|Monoid| instances\n\\begin{description}\n\\item[List] The empty list \\verb|[]| and \\verb|++| (concatenation) form a monoid.\n\\item[Product and Sum] Numbers can be monoid with respect to multiplication or addition. There are two monoid instances for \\verb|Num|. One for multiplication an the other for addition.\n\\item[Maybe] Can also be an instance of \\verb|Monoid|. \\todo{instance beschreiben}\n\\end{description}\n\nSome types, let's say \\verb|a|, have a binary function with the type declaration. \n\\begin{verbatim}\nf :: a -> a -> a\n\\end{verbatim}\n\nThe type \\verb|a| has a value that serves as identity for the given function. For example the number 1 is the identity for the multiplication. Multiplication of the identity and any other number $x$ results always in $x$.\n\nSeveral value of type \\verb|a| can always be reduces to a single value. It doesn't matter in which order we apply the function, the result is always the same. This is called associativity.\n\nIf type \\verb|a| has this behavior, it's a monoid and it can be an instance of the \\verb|Monoid| type class.\n\n\nThe \\verb|Monoid| type class is define as follows \\cite{monoid}:\n\\begin{verbatim}\nclass Monoid m where\n    mempty :: m\n    mappend :: m -> m -> m\n    mconcat :: [m] -> m\n    mconcat = foldr mappend mempty\n\\end{verbatim}\n\\verb|mconcat| takes a list of monoids and reduces them \\verb|mappend| to a single value, applying mappend. It has a default implementation.\n\nand \\verb|mappend| must be associative. There are three monoid laws \\cite{monoid}. This article deals only with the first law:\n\n\\begin{enumerate}\n\\item \\verb|mappend mempty x = x|\n\\item \\verb|mappend x mempty = x|\n\\item \\verb|(x `mappend y) `mappend z = x `mappend (y `mappend z)|\n\\end{enumerate}\n\nThe following Haskell types are \\verb|Monoid| instances\n\\begin{description}\n\\item[List] The empty list \\verb|[]| and \\verb|++| (concatenation) form a monoid.\n\\item[Product and Sum] Numbers can be monoid with respect to multiplication or addition. There are two monoid instances for \\verb|Num|. One for multiplication an the other for addition.\n\\item[Maybe] Can also be an instance of \\verb|Monoid|. \\todo{instance beschreiben}\n\\end{description}\n\nAll members of the collection  with the property that certain functions are defined over the type.\n\n With equational reasoning we are able to show that certain algebraic properties hold.\n\n\nThis article will only describe proofs with programs, which halts. An evaluation can go on forever.\n\\begin{verbatim}\nf x = 1 + f x\n\\end{verbatim}\n\nThe value of the expression is undefined. The proofs in this article hold only for defined expressions and finite lists..\n\nEquational reasoning is use-full because\n\\begin{itemize}\n\\item it allows to verify properties of a program.\n\\item it can be used to eliminate expensive function call while preserving behavior\n\\end{itemize}\n\n\n\n\\subsection{Pipes: A real world example}\n\\label{sec:pipes}\n\\todo{Abschnitt neu formulieren oder wegglassen}\nPipes is a streaming library for Haskell. It was build with the following requirements \\cite{gonzales13}.\n\\begin{description}\n\\item[Effects] Streams has to be effectful\n\\item[Streaming] Processing in constant memory\n\\item[Composability] Modules have to be composable\n\\end{description}\n\nPipes uses the type class \\verb|Category| too keep the API simple and easy to use.\n\nThis article will descipe a part of the library with an example.\n\nFirst we need a input stream, that emits values. Input streams are have the type \n\\verb|Producer a m ()|.\nListing \\ref{lst:simpleproducer} show a simple Producer. It emits the integers 1,2 and 3. It is also possible to create producers for effectful streams. We use the simple producer from Listing \\ref{lst:simpleproducer} for simplicity reasons.\n\n\\begin{program}\n\\begin{verbatim}\nproduceints123 :: Producer Int IO ()\nproduceints123 = each [1,2,3]\n\\end{verbatim}\n\\caption{Simple Producer}\n\\label{lst:simpleproducer}\n\\end{program}\n\nPipes provide the function \\verb|for| to consume a producer. \n\\verb|for| \\verb|producer| \\verb|body| loops over the \\verb|producer| and applies a the transformation defined in \\verb|body| to every element yielded by the producer. If the body is of type \\verb|Effect| it return an \\verb|Effect|. If body is of type \\verb|Producer| a \\verb|Producer| is returned. The type declaration of \\verb|for| \n\\begin{program}\n\\begin{verbatim}\nfor::Monad m=>\nProducer b m r\n-> (b -> Producer c m ())\n-> Producer c m r\n\\end{verbatim}\n\\caption{type of for}\n\\end{program}\n\nA value for the body, could be function, that takes \\verb|Int| and returns producer \\verb|Producer a IO ()|. Hence the type declarion is \\verb|Int -> Producer a IO ()|. We implement a body, that prints the integers to the standard input (strictly speaking this value is an effect of type \\verb|Effect Int ()|. But \\verb|Effect Int ()| is of type \\verb|Producer Int IO () |).\n\n\\begin{program}\n\\begin{verbatim}\nprint2stdout:: Int -> Effect IO ()\nprint2stdout x = (lift . putStrLn . show ) x\n\\end{verbatim}\n\\caption{Definition of an effect, that prints to stdout}\n\\label{lst:stdouteffect}\n\\end{program}\n\nWith the producer and the body we can define a \\verb|Effect IO ()|\n\\begin{verbatim}\neffect :: Effect IO ()\neffect = for produceints123 print2stdout\n\\end{verbatim}\n\nBecause the \\verb|body| and of \\verb|for| can be of type \\verb|a -> Producer|, and the type of the return value is \\verb|Producer|, it's possible to interleave several Producers.\n\nIf we want to duplicate all element we write another body\n\\begin{verbatim}\nduplicate :: Int -> Producer Int IO ()\nduplicate x = yield x >> yield x \n\\end{verbatim}\n\nWe use \\verb|for| to create a another producer. \\verb|composed_producer| is a composition of \\verb|produceints123| and \\verb|duplicate|.\n\\begin{verbatim}\ncomposed_producer :: Producer Int IO ()\ncomposed_producer = for produceints123 duplicate\n\\end{verbatim}\n\nTo compose \\verb|composed_producer| with our \\verb|print2stdout| effect, we apply the \\verb|for| function\n\n\\begin{verbatim}\neffect2 :: Effect IO ()\neffect2 = for composed_producer print2stdout\n\\end{verbatim}\n\nIn order to compose producers, the pipe library provides the \\verb|~>| function. \\verb|~>| is defined as follows:\n\\begin{verbatim}\n(f ~> g) x = for (f x) g\n\\end{verbatim}\n\nHence we can write compose a body for \\verb|for| like this:\n\\begin{verbatim}\ncomposed_with_yield :: Int -> Effect IO ()\ncomposed_with_yield = duplicate ~> print2stdout\n\\end{verbatim}\n\nGabriel Gonzales proved that the \\verb|~>| operator is associativ. It has the associativity property.\n\n\\begin{verbatim}\n -- Associativity\n (f ~> g) ~> h = f ~> (g ~> h)\n\\end{verbatim}\n\nBecause the \\verb|~>| operator is associativ, it doesnt matter in witch order the body is composed. The expected behavior is defined in term of cateory laws. It's possible to prove that the specified laws hold.\n\n\n\\subsection{Function composition}\n\n\\label{sec:functioncomposition}\n\nFunction composition in mathematics is defined as\n\n\\begin{equation}\n  \\label{eq:functioncomposition}\n  (f \\circ g)(x) = f(g(x))\n\\end{equation}\n\nHaskell functions can be compose with the \\verb|.| function.\n\n\\begin{figure}\n  \\centering\n\\begin{verbatim}\n(.) :: (b -> c) -> (a -> b) -> a -> c\nf . g = \\x -> f (g x)\n\\end{verbatim}\n  \\caption{. function}\n  \\label{fig:compositionfunction}\n\\end{figure}\n\nFunction composition allows us to create a function by composing it with many small functions. \n\nFunctions in Haskell form a category in category theory. They satisfy the category laws.\n\n\n\\subsection{garbage}\n There are several methods to verify software.\nbeing able to replace equals by equals.\nIn this article we will look at technique of equational reasoning to prove type class laws. If we can rely on known properties of your program, we minimize unexpected behavior.\n\n\n In addition, they exhibit certain properties. These properties are called laws. \n\n\nFor example the type class \\verb|Functor| makes sure that we can apply the function \\verb|fmap| with a type that is part of the \\verb|Functor| type class. The type class dictates the behavior. All functors are expected to exhibit certain kinds of properties. These properties guarantee that the function \\verb|fmap| only applies a function to all values inside the functor and doesn't change the structure or the context. The expression\n\\begin{verbatim}\ndontchangecontext = do line <- fmap reverse getLine\n                       putStrLn $ \" \"\n\\end{verbatim}\napplies \\verb|reverse| to the result of the IO function \\verb|getLine| without changing the the input stream. \n\nType class instances from the standard library obey the type class laws. If we write new instances, it's our responsibility to check if the type class laws hold.\nIt's in the responsibility of the programmer to check if the program behaves correctly. For most programmers it's hard to write a correct program at the first attempt. This leaves us with the question of how to verify the type class laws. \n\nProperties are specified in form of equations. The source code must satisfy this equations. \n\n\nThe monoid laws are specified by the type class monoid.\n\n\n\\begin{figure}\n  \\centering\n\\begin{verbatim}\nfmap id = id\nfmap (g . h) = fmap g . fmap h\n\\end{verbatim}\n  \\caption{The Functor laws}\n  \\label{fig:functorlaws}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n     \\includegraphics[width=0.9\\textwidth]{functor_applicative}\n  \\caption{Interrelationship of Functor and Applicative }\n  \\label{fig:functor_applicative}\n\\end{figure}\n\n\n\n\\subsubsection{Applicative function definition}\n The applicative instance is defined as follows:\n\\begin{verbatim}\ninstance Monoid b => Monoid (a -> b) where\n    mempty = pure mempty\n\n    mappend = liftA2 mappend\n\\end{verbatim}\n\n\\begin{description}\n\\item[Associativity law] \n\\item[Left/Right Identity law] \n\\end{description}\n\nIn comparison to testing equational reasoning covers not just one possible case of input but all cases.\n\n\nOf course listing \\ref{lst:compose} only works if \\verb|mappend| is implemented for the type \\verb|IO ( Char -> IO ())|. Hence we have to provide a monoid instance implementation for the type \\verb|IO ( Char -> IO ())|.\n\n\n\n requirements:\n\\begin{itemize}\n\\item We want to be able to add an arbitrary number of plugins.\n\\item The plugins should be composable.\n\\item The order we add the plugins must not matter.\n\\end{itemize}\n\n. We could use the \\verb|mappend| operator to compose several plugins. \n\nThe following listing shows the use of a plugin. The \\verb|logto| function is a plugin. The program will read a character \\verb|c| from the command line and apply the given plugin to \\verb|c|.\n\n\\begin{lstlisting}\n\n\\end{lstlisting}\n\nTo append additional plugins, e.g. \\verb|print2stdout|, we compose a new monoid with the \\verb|mappend| function.\n\\begin{verbatim}\nhandleChar <- mappend logto print2stdout\n\\end{verbatim}\nThe definition of \\verb|logTo| is shown in the following listing: \n\n\\begin{verbatim}\nlogTo :: IO ( Char -> IO ())\nlogTo = do\n    handle <- openFile \"log.txt\" WriteMode\n    return (hPutChar handle)\n\\end{verbatim}\n\n\nThe Haskell type \\verb|IO|, used for I/O actions, is part of the \\verb|Applicative| type class. Listing \\ref{lst:monoidinstance1} shows the implementation of a \\verb|Monoid| instance for the the type \\verb|IO m| where the type variable \\verb|m| is a \\verb|Monoid|. \n\\bibitem{gonzales}\nGabriel Gonzales,\nEquational reasoning at scale, \n\\url{http://www.haskellforall.com/2014/07/equational-reasoning-at-scale.html},\n2014.\n\n\\begin{verbatim}\ny = f x\ng = h y\n\\end{verbatim}\nWe can replace the definition of \\verb|g| with\n\\begin{verbatim}\ng = h (f x)\n\\end{verbatim}\nand get the same result.\n\nWe can replace the definition of \\verb|g| with\n\\begin{verbatim}\ng = h (f x)\n\\end{verbatim}\nand get the same result.\n\n\\begin{frame}\n \\frametitle{Why are functional programming languages great for equational reasoning?}\nReferential transparancy\n\\end{frame}\n\n\\begin{frame}[fragile]\n\n  \\begin{description}\n  \\item[Testing] Code is compiled and executed. Can expose error. Cannot proof absence of errors. \n\n\n  \\end{description}\n\\end{frame}\n\n\n\n\n\\begin{frame}\n\n\n\\begin{Verbatim}\n\n\\end{Verbatim}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n\\frametitle{Associativity}\nThe order of evaluation must not matter.\n\n\\end{frame}\n", "meta": {"hexsha": "c1a302e76bbc4d786c8629db7afefe52c76c411b", "size": 17157, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "garbage.tex", "max_stars_repo_name": "Hofmaier/robertson", "max_stars_repo_head_hexsha": "a9659af0af3c5780230e8fe3cb64350f57fc8226", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "garbage.tex", "max_issues_repo_name": "Hofmaier/robertson", "max_issues_repo_head_hexsha": "a9659af0af3c5780230e8fe3cb64350f57fc8226", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "garbage.tex", "max_forks_repo_name": "Hofmaier/robertson", "max_forks_repo_head_hexsha": "a9659af0af3c5780230e8fe3cb64350f57fc8226", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5602836879, "max_line_length": 635, "alphanum_fraction": 0.7497814303, "num_tokens": 4404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.42986760019469605}}
{"text": "%        File: ml-notes.tex\n%     Created: Mon Jan 14 08:00 PM 2019 E\n% Last Change: Mon Jan 14 08:00 PM 2019\n\n% Documentclass\n\\documentclass[12pt]{article}\n% margin\n\\setlength{\\topmargin}{0mm} \\setlength{\\oddsidemargin}{0mm}\n\\setlength{\\textwidth}{160mm} \\setlength{\\textheight}{220mm}\n\\font\\bbc=msbm10 scaled 1200\n\n% amsmath:\\text{} inside math mode; amssymb:\\lesssim, amsthm:\\newtheorem; amsfonts:\\mathbb{}\n\\usepackage{amsmath, amssymb, amsthm, amsfonts}\n%to use color\n\\usepackage{color}\n\\usepackage{hyperref}\n\n\n\n% User defined fun\n\\newcommand{\\F}{\\mathcal{F}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\br}[1]{\\color{red} (#1) \\color{black}}\n\\newcommand{\\bb}[1]{\\color{blue} (#1) \\color{black}}\n\\newcommand{\\what}{\\bb{??}}\n\\newcommand{\\half}{\\frac{1}{2}}\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\\newcommand{\\abs}[1]{\\left\\lvert#1\\right\\rvert}\n\\newcommand{\\jap}[1]{\\left\\langle #1 \\right\\rangle}\n\\newcommand{\\inn}[1]{\\left\\langle #1 \\right\\rangle}\n\\newtheorem{thm}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{cor}{Corollary}\n\\newtheorem{defn}{Definition}\n\\newtheorem{rem}{Remark}\n\\newtheorem{result}{Result}\n\\newtheorem*{notation}{Notation}\n\\newtheorem{prob}{Problem}\n\\newtheorem{propn}{Proposition}\n% newtheorem{proof}{Proof} is not needed, already available with \\begin{proof} .. \\end{proof} with nice italic fonts\n\n\n\\begin{document}\n\\title{Notes on Machine learning}\n\\author{Debdeep Bhattacharya}\n\\maketitle \n\n\\section{Documentaion}\n\\begin{itemize}\n  \\item \\href{https://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.html}{scikit-learn tutorial}\n\\end{itemize}\n\n\\section{numpy matrix operations}\nimport numpy as np\nCreate a new vector with np.array([1, 2, 3])\nCreate a new matrix with np.c\\_[1, 2, 3]\nTranspose with .T\nCreate a random matrix with entries from a normal distribution with size 2x1 using np.random.normal(size = (2,1))\n\n\\section{p}<++>\n\n\\section{k-Nearest Neighbor (k-NN)}\nIf the number of features (dependent variables) is $p$ and the maximum distance of any two points in a cluster is less than $d$, then the required data points (sample size) need to be $n \\sim \\frac{1}{d^p}$.\n\n\\section{Python}\nInstall scikit-learn on linux using pip3 (not pip) and run with python3, not python.\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "5f1ba21982f2b20d54609dbd2ef47275ccf86161", "size": 2345, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ml-notes.tex", "max_stars_repo_name": "debdeepbh/ml", "max_stars_repo_head_hexsha": "e26352406df6630301efd8880560aab58977be5c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ml-notes.tex", "max_issues_repo_name": "debdeepbh/ml", "max_issues_repo_head_hexsha": "e26352406df6630301efd8880560aab58977be5c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ml-notes.tex", "max_forks_repo_name": "debdeepbh/ml", "max_forks_repo_head_hexsha": "e26352406df6630301efd8880560aab58977be5c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.2666666667, "max_line_length": 207, "alphanum_fraction": 0.7292110874, "num_tokens": 773, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.42986759748095626}}
{"text": "\\documentclass[a4paper, 12pt]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{indentfirst}\n\\usepackage{amsmath}\n\\usepackage{bm}\n\\usepackage{esvect}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\n\\newcommand{\\veca}{\\[ \\vv{a} \\]}\n\\setlength{\\parindent}{1cm}\n\\DeclareMathOperator{\\MyFunction}{Fun}\n\n\n\\title{Tutorial}\n\\author{Gustave Li}\n\\date{July 2021}\n\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Change text sizes} \\label{sec: text size}\n\nI want to try out different font sizes in this paragraph, this is {\\scriptsize smaller than} the original text, this one is {\\Large larger}, this one is {\\huge even larger}.\n\n\\section{Font styles}\n\n\\setlength{\\parindent}{1cm} \n\\noindent This is a normal paragraph.\n\n\\noindent \\textbf{This is a paragraph with bold texts}\n\n\\noindent \\textit{This is a paragraph with italics texts}\n\n\\noindent \\underline{This is a paragraph with underlined texts}\n\n\\section{Text emphasis}\nText emphasis in {\\LaTeX} is \\emph{context driven}, \\textbf{which means that the font choice for emphasis text is based on the \\emph{current font}}.\n\n\\section{Font families}\nThe default font for {\\LaTeX} is Roman, but we can change to \\textsf{the sans serif font}.\n\nWhen typing codes, we may choose typewriter font:\n\\begin{center}\n    \\texttt{print('Hello world!')}\n    \n    \\texttt{a = 2}\n\\end{center}\n\n\\section{The tabular environment}\n\\begin{center}\n    \\begin{tabular}{|c|c|c|}\n    \\hline\n    text & text & text \\\\\n    \\hline\n    1    &    2 & 3 \\\\\n    4 & 5 & 6 \\\\\n    \\hline\n    \\end{tabular}\n\\end{center}\n\n\n\\section{The math environment}\nYou can enter math formulae in math mode\n\\[\nF = m \\times a\n\\]\n\\subsection{Display style math}\nThe formulae are independent from the texts in this style, they are centered separately.\n\nTo align several formulae:\n\\begin{align*}\n    f(x) & = a_2 x^2 + a_1 x + a_0 \\\\\n         & = x^2 + 4x -5\n\\end{align*}\n\nThe formulae can also be numbered:\n\\begin{align}\n    f(x) & = a_2 x^2 + a_1 x + a_0 \\\\\n         & = x^2 + 4x -5\n\\end{align}\n\nOr can only number the last formula:\n\\begin{align}\n    f(x) & = a_2 x^2 + a_1 x + a_0 \\nonumber \\\\\n         & = x^2 + 4x -5 \n\\end{align}\n\n\\subsection{Inline style math}\nThe equation \\( F = m a\\) is called Newton's Second Law.\n\n\\section{Basic math notations}\n\n\\subsection{Arithmetic}\nMultiplication and division signs can by typed in math mode: \\(a \\cdot b\\), \\(a \\times b\\), \\(a \\div b\\).\n\\subsection{Parentheses}\nBy specifying the parentheses pairs, {\\LaTeX} can automatically adjust the size of parentheses:\n\\[\n\\left( \\sum_{n=0}^N \\left( \\frac{1}{a + b } \\right)^2 \\right)^2\n\\]\n\n\\subsection{Greek letters}\n\\noindent You can type Greek letters under math mode: \\( \\alpha \\beta \\gamma \\delta\\) etc. \\\\\n\n\\noindent The complete alphabet with the commands are shown below\n\n\\includegraphics[width=\\linewidth]{Greek_letters.png}\n\n\\subsection{Array}\n\\noindent \\textbf{Warning: arrays must be generated in math mode}\n\\[\n\\begin{array}{ccc}\n    \\label{array: example}\n    a_{11} & a_{12} & a_{13}  \\\\\n    a_{21} & a_{22} & a_{23}  \\\\\n    a_{31} & a_{32} & a_{33}\n\\end{array}\n\\]\nThe '\\&' tells Latex where to align, while the slash tells where to start a new row.\n\n\\subsection{Calculus}\n\\begin{itemize}\n    \\item Limit\n    \\[\n    \\lim_{x \\to \\infty} \\, \\frac{1}{x}\n    \\]\n    \\item Sum\n    \\[\n    \\sum_{x=0}^{\\infty} \\, x^2\n    \\]\n    \\item Integral\n    \\[\n    \\int_{- \\infty}^\\infty x^2\n    \\]\n    \\begin{itemize}\n        \\item Double integral\n        \\[\n        \\iint_{- \\infty}^\\infty x^2\n        \\]\n        \\item Vertical bar for integral evaluation\n        \\[\n        \\int_0^4 x^2 \\, = \\frac{x^3}{3} \\, \\bigg\\vert_0^4\n        \\]\n    \\end{itemize}\n    \\item Derivative\n    \\begin{itemize}\n        \\item Prime notation\n        \\[\n        f'(x), f''(x), f'''(x), \\ldots, f^{(n)}(x)\n        \\]\n        \\item Dot notation\n        \\[\n        \\dot{x}(t), \\ddot{x}(t)\n        \\]\n    \\end{itemize}\n    \\item Vector\n    \\begin{itemize}\n        \\item Bold notation\n        \\[\n        \\bm{a}, \\bm {b}, \\bm{a} \\cdot \\bm {b}\n        \\]\n        \\item Arrow notation\n        \\[\n        \\vv{a}, \\vv{b}, \\vv{a} \\times \\vv{b}\n        \\]\n    \\end{itemize}\n\\end{itemize}\n\\subsection{Others}\n\\begin{itemize}\n    \\item Fraction\n    \\[\n    \\frac{3}{5}, \\; \\frac{x^2}{x+1}\n    \\]\n    \\item Square root\n    \\[ \\sqrt{5} \\]\n    Can also specify the order:\n    \\[ \\sqrt[3]{5} \\]\n    \\item Comparison symbols\n    Greater than or equal to: \\( a \\geq b\\)\n    \n    Less than or equal to: \\( a \\leq b\\)\n    \n    Approximately equal to: \\(a \\approx b\\)\n\\end{itemize}\n\n\\section{Customization}\n\\subsection{Page breaks}\n\\begin{itemize}\n    \\item Soft break\n    The 'pagebreak' command tries to extend the line spacing so that the text can occupy the whole page\n    \\item Hard break\n    The 'newpage' command just starts a new page\n\\end{itemize}\n\\subsection{User defined commands}\n\\noindent \\textbf{(Should be defined in preamble)} \\\\\nFirst define a new command: I want the command 'veca' be the arrow-formed vector a.\n\nThen try it out: \\veca\n\n\\subsection{User defined functions}\n\\noindent \\textbf{(Should be defined in preamble)}\n\n\\noindent I want to define 'myfunction' as a Fun. (It should be displayed without italics in math mode)\n\n\\noindent Try it out:\n\n\\[\\MyFunction(x)\\]\n\n\\subsection{Labels and references}\nWe have discussed how to change the text size in Section~\\ref{sec: text size}, if you are unclear, please check them out.\n\nThe demonstration for generating an array is located in Section~\\ref{array: example}, feel free to check them out.\n\n\\section{Ending remarks}\nThis is basically all for this tutorial, for more detailed information, please reference \\href{https://www.youtube.com/watch?v=fCzF5gDy60g&list=WL&index=1}{this Youtube video}\n\n\\end{document}\n", "meta": {"hexsha": "a4cf0a123f7fea45ff61051c66bdc73ece26ad2b", "size": 5705, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/Gustave_Li/Learning_materials/Latex.tex", "max_stars_repo_name": "dominikusbrian/durf_hq", "max_stars_repo_head_hexsha": "ed1dded4aae34e1e5987170ec1aebba390d4c1e6", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-15T06:12:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-15T06:12:31.000Z", "max_issues_repo_path": "projects/Gustave_Li/Learning_materials/Latex.tex", "max_issues_repo_name": "dominikusbrian/durf_hq", "max_issues_repo_head_hexsha": "ed1dded4aae34e1e5987170ec1aebba390d4c1e6", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 15, "max_issues_repo_issues_event_min_datetime": "2021-06-15T06:22:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-05T01:57:59.000Z", "max_forks_repo_path": "projects/Gustave_Li/Learning_materials/Latex.tex", "max_forks_repo_name": "dominikusbrian/durf_hq", "max_forks_repo_head_hexsha": "ed1dded4aae34e1e5987170ec1aebba390d4c1e6", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-06-15T02:59:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-21T02:35:10.000Z", "avg_line_length": 25.814479638, "max_line_length": 175, "alphanum_fraction": 0.6457493427, "num_tokens": 1791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984137988772, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.42977702191438083}}
{"text": "\\documentclass[Physics.tex]{subfiles}\r\n\\begin{document}\r\n\\chapter{Gravitational Field}\r\nNewton's \\sldef{law of universal gravitation} states that every particle in the universe attracts every other particle with a force directly proportional to the product of their masses and inversely proportional to the square of the distance between them i.e. \\begin{equation}\\left|\\mathbf{F}\\right| = G\\frac{m_{1}m_{2}}{r^{2}}\\end{equation} where \\(G\\) is the gravitational constant.\r\n\r\nThe law of gravitation is an inverse-square law i.e. the magnitude of force is inversely proportional to the square of something -- in this case the square of the separation between the particles.\r\n\r\nThis equation holds only for point masses, but large masses at a large distance can be assumed, without losing too much accuracy, to be a point mass, so this equation is still reasonably valid.\r\n\r\nThe region in space where an object exerts a gravitational force on another object is the \\sldef{gravitational field} of the first object. A gravitational field can be represented by field lines representing the resultant direction of gravitational force acting on a mass placed at any point in the field. Where the field lines are closer, the field is stronger, and vice versa.\r\n\r\nThe \\sldef{gravitational field strength} \\textbf{g} at a point in a gravitational field is the gravitational force per unit mass acting on a body placed at that point. \\begin{equation}\\left|\\mathbf{g}\\right| = G\\frac{Mm}{mr^{2}} = G\\frac{M}{r^{2}}\\end{equation}\r\n\r\nNear the surface of the Earth, \\(\\mathbf{g}\\) is approximately constant, as \\(r\\) does not vary very appreciably. However, \\(\\mathbf{g}\\) varies over different points on Earth's surface, as the Earth is not a perfect sphere -- it bulges at the equator, the density of the Earth is not uniform, and the Earth is rotating about an axis through its poles -- so for an object not at the poles, gravity also has to provide for centripetal acceleration.\r\n\r\nAn object is only truly weightless when it experiences no gravitational force at all. Otherwise, it experiences apparent weightlessness -- it simply does not feel its weight as it experiences no normal force.\r\n\r\nThe \\sldef{gravitational potential energy} \\(U\\) of a mass at a point in a gravitational field is the work done by an external force in bringing the mass from infinity to that point without acceleration. \\begin{equation}U = -G\\frac{Mm}{r}\\end{equation} At infinity, \\(U = 0\\). The negative sign arises from the fact that the gravitational force is attractive in nature.\r\n\r\nThe \\sldef{gravitational potential} \\(\\Phi\\) at a point in a gravitational field is the work done per unit mass by an external force in bringing a test mass from infinity to that point without acceleration.\\begin{equation}\\Phi = -G\\frac{M}{r}\\end{equation}\r\n\r\nThe \\sldef{escape speed} is the minimum speed with which a mass should be launched from a planet's surface to escape the planet's gravitational field. It is simply the speed that gives the mass kinetic energy that makes the mass's total energy exactly equal what its total energy would be if it were stationary at infinity.\r\n\r\nAn \\sldef{equipotential} line or surface is formed by all the points that have the same potential. Objects moving along an equipotential do not lose or gain any energy.\r\n\r\n\\sldef{Kepler's 3rd law} states that the square of an object's orbit period is proportional to the cube of its orbit radius.\r\n\r\nA \\sldef{geostationary satellite} of a planet is a satellite that orbits the planet such that it will always be above the same point on the planet. This means that the satellite must be orbiting the planet's equator in the direction of the planet's axial rotation, and the period of the orbit must be equal to the period of the rotation.\r\n\r\nGeostationary satellites are often used for communication. They are useful because they always stay over the same point, so there is no need to adjust satellite dishes; they are also high above the Earth and so can see large areas of the Earth. However, also due to their high altitude, images taken tend to be of low spatial resolution, and because they must be over the equator, they are of limited use for latitudes more than about \\SI{70}{\\degree} N or S.\r\n\\end{document}", "meta": {"hexsha": "96feefd9d2726e5f00032cb24f6ef83396ea8558", "size": 4259, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX/Physics/ch12_g.tex", "max_stars_repo_name": "oliverli/A-Level-Notes", "max_stars_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-05T11:44:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-05T11:44:33.000Z", "max_issues_repo_path": "TeX/Physics/ch12_g.tex", "max_issues_repo_name": "oliverli/A-Level-Notes", "max_issues_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX/Physics/ch12_g.tex", "max_forks_repo_name": "oliverli/A-Level-Notes", "max_forks_repo_head_hexsha": "5afdc9a71c37736aacf3ae1db9d0384cdb6a0348", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 137.3870967742, "max_line_length": 460, "alphanum_fraction": 0.7785865227, "num_tokens": 976, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.42973515946269564}}
{"text": "\\chapter{Proofs in Quantified Logic}\n\\markright{Chap \\ref{chap:proofsinQL}: Proofs in QL}\n\\label{chap:proofsinQL}\n\\setlength{\\parindent}{1em}\n\n% ******************************************\n%  *                       6.1 Rules for Quantifiers             *\n%******************************************\n\n\\section{Rules for Quantifiers}\n\nFor proofs in QL, we use all of the basic rules of SL plus four new basic rules: both introduction and elimination rules for each of the quantifiers.\n\nSince all of the derived rules of SL are derived from the basic rules, they will also hold in QL. We will add another derived rule, a replacement rule called quantifier negation.\n\n\\subsection{Universal elimination}\n\nIf you have $\\forall x Ax$, it is legitimate to infer that anything is an $A$. You can infer $Aa$, $Ab$, $Ac$, $Ad_3$--- in short, you can infer $A\\script{c}$ for any constant \\script{c}. This is the general form of the universal elimination rule ($\\forall$E):\n\n\\begin{proof}\n\t\\have[m]{a}{\\forall \\script{x}\\script{A}}\n\t\\have[\\ ]{c}{\\script{A}[\\script{c}|\\script{x}]} \\Ae{a}\n\\end{proof}\n\n$\\script{A}[\\script{c}|\\script{x}]$ is a substitution instance of $\\forall\\script{x}\\script{A}$. The symbols for a substitution instance are not symbols of QL, so you cannot write them in a proof. Instead, you write the subsituted sentence with the constant \\script{c} replacing all occurrences of the variable \\script{x} in \\script{A}. For example:\n\n\\begin{proof}\n\t\\hypo{a}{\\forall x(Mx \\eif Rxd)}\n\t\\have{c}{Ma \\eif Rad} \\Ae{a}\n\t\\have{d}{Md \\eif Rdd} \\Ae{a}\n\\end{proof}\n\n\n\\subsection{Existential introduction}\n\nWhen is it legitimate to infer $\\exists x Ax$? If you know that something is an $A$--- for instance, if you have $Aa$ available in the proof.\n\nThis is the existential introduction rule ($\\exists$I):\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{c}{\\exists \\script{x}\\script{A}[\\script{x}||\\script{c}]} \\Ei{a}\n\\end{proof}\n\nIt is important to notice that $\\script{A}[\\script{x}||\\script{c}]$ is not the same as a substitution instance. We write it with two bars to show that the variable \\script{x} does not need to replace all occurrences of the constant \\script{c}. You can decide which occurrences to replace and which to leave in place. For example:\n\n\\begin{proof}\n\t\\hypo{a}{Ma \\eif Rad}\n\t\\have{b}{\\exists x(Ma \\eif Rax)} \\Ei{a}\n\t\\have{c}{\\exists x(Mx \\eif Rxd)} \\Ei{a}\n\t\\have{d}{\\exists x(Mx \\eif Rad)} \\Ei{a}\n\t\\have{e}{\\exists y\\exists x(Mx \\eif Ryd)} \\Ei{d}\n\t\\have{f}{\\exists z\\exists y\\exists x(Mx \\eif Ryz)} \\Ei{e}\n\\end{proof}\n\n\n\\subsection{Universal introduction}\nA universal claim like $\\forall x Px$ would be proven if {every} substitution instance of it had been proven, if every sentence $Pa$, $Pb$, $\\ldots$ were available in a proof. Alas, there is no hope of proving \\emph{every} substitution instance. That would require proving $Pa$, $Pb$, $\\ldots$, $Pj_2$, $\\ldots$, $Ps_7$, $\\ldots$, and so on to infinity. There are infinitely many constants in QL, and so this process would never come to an end.\n\nConsider a simple argument: $\\forall x Mx$, \\therefore\\ $\\forall y My$\n\nIt makes no difference to the meaning of the sentence whether we use the variable $x$ or the variable $y$, so this argument is obviously valid. Suppose we begin in this way:\n\n\\begin{proof}\n\t\\hypo{x}{\\forall x Mx} \\by{want $\\forall y My$}{}\n\t\\have{a}{Ma} \\Ae{x}\n\\end{proof}\n\nWe have derived $Ma$. Nothing stops us from using the same justification to derive $Mb$, $\\ldots$, $Mj_2$, $\\ldots$, $Ms_7$, $\\ldots$, and so on until we run out of space or patience. We have effectively shown the way to prove $M\\script{c}$ for any constant \\script{c}. From this, $\\forall x Mx$ follows.\n\n\\begin{proof}\n\t\\hypo{x}{\\forall x Mx}\n\t\\have{a}{Ma} \\Ae{x}\n\t\\have{y}{\\forall y My} \\Ai{a}\n\\end{proof}\n\nIt is important here that $a$ was just some arbitrary constant. We had not made any special assumptions about it. If $Ma$ were a premise of the argument, then this would not show anything about \\emph{all} $y$. For example:\n\n\\begin{proof}\n\t\\hypo{x}{\\forall x Rxa}\n\t\\have{a}{Raa} \\Ae{x}\n\t\\have{y}{\\forall y Ryy} \\by{not allowed!}{}\n\\end{proof}\n\n\nThis is the schematic form of the universal introduction rule ($\\forall$I):\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{c}{\\forall \\script{x}\\script{A}[\\script{x}|\\script{c}]^\\ast} \\Ai{a}\n\\end{proof}\n$^\\ast$ \\script{c} must not occur in any undischarged assumptions.\n\nNote that we can do this for any constant that does not occur in an undischarged assumption and for any variable.\n\nNote also that the constant may not occur in any \\emph{undischarged} assumption, but it may occur as the assumption of a subproof that we have already closed. For example, we can prove $\\forall z(Dz \\eif Dz)$ without any premises.\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo{f1}{Df}\\by{want $Df$}{}\n\t\t\\have{f2}{Df}\\by{R}{f1}\n\t\\close\n\t\\have{ff}{Df \\eif Df}\\ci{f1-f2}\n\t\\have{zz}{\\forall z(Dz \\eif Dz)}\\Ai{ff}\n\\end{proof}\n\n\n\\subsection{Existential elimination}\nA sentence with an existential quantifier tells us that there is \\emph{some} member of the UD that satisfies a formula. For example, $\\exists x Sx$ tells us (roughly) that there is at least one $S$. It does not tell us \\emph{which} member of the UD satisfies $S$, however. We cannot immediately conclude $Sa$, $Sf_{23}$, or any other substitution instance of the sentence. What can we do?\n\nSuppose that we knew both $\\exists x Sx$ and $\\forall x(Sx \\eif Tx)$. We could reason in this way:\n\\begin{quote}\nSince $\\exists x Sx$, there is something that is an $S$. We do not know which constants refer to this thing, if any do, so call this thing $\\Omega$. From $\\forall x(Sx \\eif Tx)$, it follows that if $\\Omega$ is an $S$, then it is a $T$. Therefore $\\Omega$ is a $T$.  Because $\\Omega$ is a $T$, we know that $\\exists x Tx$.\n\\end{quote}\nIn this paragraph, we introduced a name for the thing that is an $S$. We called it $\\Omega$, so that we could reason about it and derive some consequences from there being an $S$. Since $\\Omega$ is just a bogus name introduced for the purpose of the proof and not a genuine constant, we could not mention it in the conclusion. Yet we could derive a sentence that does not mention $\\Omega$; namely, $\\exists x Tx$. This sentence does follow from the two premises.\n\nWe want the existential elimination rule to work in a similar way. Yet since Greek letters like $\\Omega$ are not symbols of QL, we cannot use them in formal proofs. Instead, we will use constants of QL which do not otherwise appear in the proof. A constant that is used to stand in for whatever it is that satisfies an existential claim is called a \\define{proxy}. Reasoning with the proxy must all occur inside a subproof, and the proxy cannot be a constant that is doing work elsewhere in the proof.\n\nThis is the schematic form of the existential elimination rule ($\\exists$E): \n\n\\begin{proof}\n\t\\have[m]{a}{\\exists \\script{x}\\script{A}}\n\t\\open\t\n\t\t\\hypo[n]{b}{\\script{A}[\\script{c}|\\script{x}]^\\ast}\n\t\t\\have[p]{c}{\\script{B}}\n\t\\close\n\t\\have[\\ ]{d}{\\script{B}} \\Ee{a,b-c}\n\\end{proof}\n$^\\ast$ The constant \\script{c} must not appear in $\\exists\\script{x}\\script{A}$, in \\script{B}, or in any undischarged assumption.\n\nWith this rule, we can give a formal proof that $\\exists x Sx$ and $\\forall x(Sx \\eif Tx)$ together entail $\\exists x Tx$. The structure of the proof is effectively the same as the English-language argument with which we began, except that the subproof uses the constant ``$a$'' rather than the bogus name $\\Omega$.\n\n\\begin{proof}\n\t\\hypo{es}{\\exists x Sx}\n\t\\hypo{ast}{\\forall x(Sx \\eif Tx)}\\by{want $\\exists x Tx$}{}\n\t\\open\n\t\t\\hypo{s}{Sa}\n\t\t\\have{st}{Sa \\eif Ta}\\Ae{ast}\n\t\t\\have{t}{Ta} \\ce{s,st}\n\t\t\\have{et1}{\\exists x Tx}\\Ei{t}\n\t\\close\n\t\\have{et2}{\\exists x Tx}\\Ee{es,s-et1}\n\\end{proof}\n\n\\subsection{Quantifier negation}\n\nWhen translating from English to QL, we noted that $\\enot\\exists x\\enot\\script{A}$ is logically equivalent to $\\forall x\\script{A}$. In QL, they are provably equivalent. We can prove one half of the equivalence with a rather gruesome proof:\n\n\\begin{proof}\n\t\\hypo{Aa}{\\forall x Ax} \\by{want $\\enot\\exists x\\enot Ax$}{}\n\t\\open\n\t\t\\hypo{Ena}{\\exists x \\enot Ax}\\by{for reductio}{}\n\t\t\\open\n\t\t\t\\hypo{nc}{\\enot Ac}\\by{for $\\exists$E}{}\n\t\t\t\\open\n\t\t\t\t\\hypo{Aa2}{\\forall x Ax}\\by{for reductio}{}\n\t\t\t\t\\have{c2}{Ac}\\Ae{Aa}\n\t\t\t\t\\have{nc2}{\\enot Ac}\\by{R}{nc}\n\t\t\t\\close\n\t\t\t\\have{nAa}{\\enot\\forall x Ax}\\ni{Aa2-nc2}\n\t\t\\close\n\t\t\\have{nAa3}{\\enot\\forall x Ax}\\Ee{nc-nAa}\n\t\t\\have{Aa3}{\\forall x Ax}\\by{R}{Aa}\n\t\\close\n\t\\have{nEna}{\\enot\\exists x \\enot Ax}\\ni{Ena-nAa3}\n\\end{proof}\n\nIn order to show that the two sentences are genuinely equivalent, we need a second proof that assumes $\\enot\\exists x\\enot\\script{A}$ and derives $\\forall x\\script{A}$. We leave that proof as an exercise for the reader.\n\nIt will often be useful to translate between quantifiers by adding or subtracting negations in this way, so we add two derived rules for this purpose. These rules are called quantifier negation (QN):\n\\begin{center}\n\\begin{tabular}{rl}\n$\\enot\\forall\\script{x}\\script{A} \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\exists\\script{x}\\enot\\script{A}$\\\\\n$\\enot\\exists\\script{x}\\script{A} \\nsststile{}{}  \\hspace{.5em} \\sststile{}{} \\forall\\script{x}\\enot\\script{A}$\n& QN\n\\end{tabular}\n\\end{center}\nSince QN is a replacement rule, it can be used on whole sentences or on subformulae.\n\n%%%%%%%%%   \t\tPractice problems for Section 6.1                %%%%\n\n% rob: I put all the quantification problems from the original chapter 6 that don't involve identity or models in this section. \n\n\\practiceproblems\n\n\\setlength{\\parindent}{0pt}\n\n\\problempart\n\\label{pr.justifyQLproof}\nProvide a justification (rule and line numbers) for each line of proof that requires one.\n\n\\begin{enumerate}[label=\\arabic*)]\n\\begin{multicols}{2}\n\\begin{minipage}{\\linewidth}\n\\item \\textcolor{white}{.} \\\\  %$\\vdash \\exists x Mx \\eor \\forall x\\enot Mx$\n\\vspace{-24pt}\n\\begin{proof}\n\t\\open\n\t\t\\hypo{p1}{\\enot (\\exists x Mx \\eor \\forall x\\enot Mx)}\n\t\t\\have{p2}{\\enot \\exists x Mx \\eand \\enot \\forall x\\enot Mx}{}\n\t\t\\have{p3}{\\enot \\exists x Mx}{}\n\t\t\\have{p4}{\\forall x\\enot Mx}{}\n\t\t\\have{p5}{\\enot \\forall x\\enot Mx}{}\n\t\\close\n\\have{n}{\\exists x Mx \\eor \\forall x\\enot Mx} {}\n\\end{proof}\n\\end{minipage}\n\n\\pagebreak[4]\n\\item \\textcolor{white}{.} \\\\ %$\\{\\forall x(\\exists y)(Rxy \\eor Ryx),\\forall x\\enot Rmx\\}\\vdash\\exists xRxm$\n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{p1}{\\forall x\\exists y(Rxy \\eor Ryx)}\n\\hypo{p2}{\\forall x\\enot Rmx}\n\\have{3}{\\exists y(Rmy \\eor Rym)}{}\n\t\\open\n\t\t\\hypo{a1}{Rma \\eor Ram}\n\t\t\\have{a2}{\\enot Rma}{}\n\t\t\\have{a3}{Ram}{}\n\t\t\\have{a4}{\\exists x Rxm}{}\n\t\\close\n\\have{n}{\\exists x Rxm} {}\n\\end{proof}\n\n\\vspace{2ex}\n\n\\item \\textcolor{white}{.} \\\\ %$\\{\\forall x(\\exists yLxy \\eif \\forall zLzx), Lab\\} \\vdash \\forall xLxx$\n\\vspace{-16pt}\n\\begin{proof} \n\\hypo{1}{\\forall x(\\exists yLxy \\eif \\forall zLzx)}\n\\hypo{2}{Lab}\n\\have{3}{\\exists y Lay \\eif \\forall zLza}{}\n\\have{4}{\\exists y Lay} {}\n\\have{5}{\\forall z Lza} {}\n\\have{6}{Lca}{}\n\\have{7}{\\exists y Lcy \\eif \\forall zLzc}{}\n\\have{8}{\\exists y Lcy}{}\n\\have{9}{\\forall z Lzc}{}\n\\have{10}{Lcc}{}\n\\have{11}{\\forall x Lxx}{}\n\\end{proof}\n\n\n\n\\item \\textcolor{white}{.} \\\\ % $\\{\\forall x(Jx \\eif Kx), \\exists x\\forall y Lxy, \\forall x Jx\\} \\vdash \\exists x(Kx \\eand Lxx)$\n\\vspace{-16pt}\n\\begin{proof}\n\\hypo{a}{\\forall x(Jx \\eif Kx)}\n\\hypo{b}{\\exists x\\forall y Lxy}\n\\hypo{c}{\\forall x Jx}\n\\have{d}{Ja}{}\n\\have{e}{Ja \\eif Ka}{}\n\\have{f}{Ka}{}\n\\open\n\t\\hypo{2}{\\forall y Lay}\n\t\\have{3}{Laa}{}\n\t\\have{4}{Ka \\eand Laa}{}\n\t\\have{5}{\\exists x(Kx \\eand Lxx)}{}\n\\close\n\\have{j}{\\exists x(Kx \\eand Lxx)}{}\n\\end{proof}\n\\end{multicols}\n\\end{enumerate}\n\n\\problempart Without using the QN rule, prove $\\enot\\exists x\\enot\\script{A} \\sststile{}{} \\forall x\\script{A}$\n\n\\problempart\n\\label{pr.someQLproofs}\nProvide a proof of each claim.\n\\begin{earg}\n\\item $\\sststile{}{}  \\forall x Fx \\eor \\enot \\forall x Fx$\n\\item $\\{\\forall x(Mx \\eiff Nx), Ma\\eand\\exists x Rxa\\}\\sststile{}{}  \\exists x Nx$\n\\item $\\{\\forall x(\\enot Mx \\eor Ljx), \\forall x(Bx\\eif Ljx), \\forall x(Mx\\eor Bx)\\}\\sststile{}{}  \\forall xLjx$\n\\item $\\forall x(Cx \\eand Dt)\\sststile{}{}  \\forall xCx \\eand Dt$\n\\item $\\exists x(Cx \\eor Dt)\\sststile{}{}  \\exists x Cx \\eor Dt$\n\\end{earg}\n\n\\problempart\n%Provide a proof of the argument about Billy on p.~\\pageref{surgeon2}.\n\nIn the previous chapter (p.~\\pageref{surgeon2}), we gave the following example\n\n\t\\begin{quote}\n\t\n\t\n\tThe hospital will only hire a skilled surgeon. All surgeons are greedy. Billy is a surgeon, but is not skilled. Therefore, Billy is greedy, but the hospital will not hire him.\n\t\n\t\\begin{ekey}\n\t\\item[UD:] people\n\t\\item[Gx:] $x$ is greedy.\n\t\\item[Hx:] The hospital will hire $x$.\n\t\\item[Rx:] $x$ is a surgeon.\n\t\\item[Kx:] $x$ is skilled.\n\t\\item[b:] Billy\n\t\\end{ekey}\n\t\n\t\\begin{earg}\n\t\\label{surgeon2}\n\t\\item[] $\\forall x\\bigl[\\enot (Rx \\eand Kx) \\eif \\enot Hx\\bigr]$\n\t\\item[] $\\forall x(Rx \\eif Gx)$\n\t\\item[] $Rb \\eand \\enot Kb$\n\t\\item[\\therefore] $Gb \\eand \\enot Hb$\n\t\\end{earg}\n\t\n\t\\end{quote}\n\nProve the symbolized argument. \n\n\\problempart \\label{pr.BarbaraEtc.proof1} \\iflabelexists{chap:catstatements}{On page \\pageref{table:full_twentyfour} you were introduced to the twenty-four valid Aristotelian syllogisms, and on page \\pageref{venn_proofs} you were able to show 15 of these valid using Venn diagrams.  Now that we have translated them into QL (see page \\pageref{pr.BarbaraEtc}) we can actually prove all of them valid. In this section, you will prove the unconditional forms. I have omitted Datisi and Ferio because their proofs are trivial variations on Darii and Ferison.}{On page \\pageref{pr.BarbaraEtc} you translated the basic categorical syllogisms studied by Aristotle and his followers into QL. Now you need to provide derivations for some of them.}\n\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item \\textbf{Barbara:} All $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  All $A$s are $C$s.\n\\item \\textbf{Baroco:} All $C$s are $B$s. Some $A$ is not $B$.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item \\textbf{Bocardo:} Some $B$ is not $C$. All $B$s are $A$s.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Celantes:} No $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  No $C$s are $A$s.\n\\item\\textbf{Celarent:} No $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  No $A$s are $C$s.\n\\item\\textbf{Campestres:} All $C$s are $B$s. No $A$s are $B$s.\n\t\\therefore\\  No $A$s are $C$s.\n\\item\\textbf{Cesare:} No $C$s are $B$s. All $A$s are $B$s.\n\t\\therefore\\  No $A$s are $C$s.\n\\item\\textbf{Dabitis:} All $B$s are $C$s. Some $A$ is $B$.\n\t\\therefore\\  Some $C$ is $A$.\n\\item\\textbf{Darii:} All $B$s are $C$s. Some $A$ is $B$.\n\t\\therefore\\  Some $A$ is $C$.\n\\item\\textbf{Disamis:} Some $B$ is $C$. All $B$s are $A$s.\n\t\\therefore\\  Some $A$ is $C$.\n\\item\\textbf{Ferison:} No $B$s are $C$s. Some $B$ is $A$.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Festino:} No $C$s are $B$s. Some $A$ is $B$.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Frisesomorum:} Some $B$ is $C$. No $A$s are $B$s.\n\t\\therefore\\  Some $C$ is not $A$.\n\\end{enumerate}\n\n\n\\problempart\n\\label{pr.BarbaraEtc.proof2}\nNow prove the conditionally valid syllogisms using QL. Symbolize each of the following and add the additional assumptions ``There is an $A$'' and ``There is a $B$.'' Then prove that the supplemented arguments forms are valid in QL. Calemos and Cesaro have been skipped because they are trivial variations of Camestros and Celaront. \n\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\n\\item\\textbf{Barbari:} All $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  Some $A$ is $C$.\n\\item\\textbf{Celaront:} No $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Camestros:} All $C$s are $B$s. No $A$s are $B$s.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Darapti:} All $A$s are $B$s. All $A$s are $C$s.\n\t\\therefore\\  Some $B$ is $C$.\n\\item\\textbf{Felapton:} No $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  Some $A$ is not $C$.\n\\item\\textbf{Baralipton:} All $B$s are $C$s. All $A$s are $B$s.\n\t\\therefore\\  Some $C$ is $A$.\n\\item\\textbf{Fapesmo:} All $B$s are $C$s. No $A$s are $B$s.\n\t\\therefore\\  Some $C$ is not $A$.\n\\end{enumerate}\n\n\n\n\\problempart\nProvide a proof of each claim.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item $\\forall x \\forall y Gxy \\sststile{}{} \\exists x Gxx$\n\\item $\\forall x \\forall y (Gxy \\eif Gyx) \\sststile{}{} \\forall x\\forall y (Gxy \\eiff Gyx)$\n\\item $\\{\\forall x(Ax\\eif Bx), \\exists x Ax\\} \\sststile{}{} \\exists x Bx$\n\\item $\\{Na \\eif \\forall x(Mx \\eiff Ma), Ma, \\enot Mb\\}\\sststile{}{} \\enot Na$\n\\item $\\sststile{}{}\\forall z (Pz \\eor \\enot Pz)$\n\\item $\\sststile{}{}\\forall x Rxx\\eif \\exists x \\exists y Rxy$\n\\item $\\sststile{}{}\\forall y \\exists x (Qy \\eif Qx)$\n\\end{enumerate}\n\n\\problempart\nShow that each pair of sentences is provably equivalent.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item $\\forall x (Ax\\eif \\enot Bx) \\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\enot\\exists x(Ax \\eand Bx)$\n\\item $\\forall x (\\enot Ax\\eif Bd) \\nsststile{}{} \\hspace{.5em} \\sststile{}{} \\forall x Ax \\eor Bd$\n\\item $\\exists x Px \\eif Qc \\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall x (Px \\eif Qc)$\n%\\item $Rca \\eiff \\forall x Rxa$, $\\forall x(Rca \\eiff Rxa)$  rob: I'm embarassed to say I can't solve this one. \n\\end{enumerate}\n\n\n\n\\problempart\nShow that each of the following is provably inconsistent.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item \\{$Sa\\eif Tm$, $Tm \\eif Sa$, $Tm \\eand \\enot Sa$\\}\n\\item \\{$\\enot\\exists x \\exists y Lxy$, $Laa$\\}\n\\item \\{$\\forall x(Px \\eif Qx)$, $\\forall z(Pz \\eif Rz)$, $\\forall y Py$, $\\enot Qa \\eand \\enot Rb$\\}\n\\end{enumerate}\n\n\n\n\n\\problempart\n\\label{pr.likes}\nWrite a symbolization key for the following argument, translate it, and prove it:\n\\begin{quote}\nThere is someone who likes everyone who likes everyone that he likes. Therefore, there is someone who likes himself.\n\\end{quote}\n\n\n\n%\\problempart\n%Look back at Part \\ref{pr.QLarguments} on p.~\\pageref{pr.QLarguments}. For each argument: If it is valid in QL, give a proof. If it is invalid, construct a model to show that it is invalid.\n\n\n\\problempart\n\\label{pr.QLequivornot}\nFor each of the following pairs of sentences: If they are logically equivalent in QL, give proofs to show this. If they are not, construct a model to show this.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item $\\forall x Px \\eif Qc \\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall x (Px \\eif Qc)$\n\\item $\\forall x Px \\eand Qc\\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall x (Px \\eand Qc)$\n\\item $Qc \\eor \\exists x Qx\\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\exists x (Qc \\eor Qx)$\n\\item $\\forall x\\forall y \\forall z Bxyz\\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall x Bxxx$\n\\item $\\forall x\\forall y Dxy\\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall y\\forall x Dxy$\n\\item $\\exists x\\forall y Dxy\\nsststile{}{} \\hspace{.5em} \\sststile{}{}\\forall y\\exists x Dxy$\n\\end{enumerate}\n\n\\problempart\n\\label{pr.QLvalidornot}\nFor each of the following arguments: If it is valid in QL, give a proof. If it is invalid, construct a model to show that it is invalid.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt]\n\\item $\\forall x\\exists y Rxy \\sststile{}{} \\exists y\\forall x Rxy$\n\\item $\\exists y\\forall x Rxy \\sststile{}{} \\forall x\\exists y Rxy$\n\\item $\\exists x(Px \\eand \\enot Qx) \\sststile{}{} \\forall x(Px \\eif \\enot Qx)$\n\\item $\\{\\forall x(Sx \\eif Ta)$, $Sd\\} \\sststile{}{}Ta$\n\\item $\\{\\forall x(Ax\\eif Bx)$, $\\forall x(Bx \\eif Cx)\\} \\sststile{}{} \\forall x(Ax \\eif Cx)$\n\\item $\\{\\exists x(Dx \\eor Ex)$, $\\forall x(Dx \\eif Fx)\\} \\sststile{}{} \\exists x(Dx \\eand Fx)$\n\\item $\\forall x\\forall y(Rxy \\eor Ryx)\\sststile{}{} Rjj$\n\\item $\\exists x\\exists y(Rxy \\eor Ryx)\\sststile{}{}Rjj$\n\\item $\\{\\forall x Px \\eif \\forall x Qx$, $\\exists x \\enot Px\\}\\sststile{}{}\\exists x \\enot Qx$\n\\item $\\{\\exists x Mx \\eif \\exists x Nx$, $\\enot \\exists x Nx\\}\\sststile{}{} \\forall x \\enot Mx$\n\\end{enumerate}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                         6.2 Rules for Identity %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Rules for Identity}\nThe identity predicate is not part of QL, but we add it when we need to symbolize certain sentences. For proofs involving identity, we add two rules of proof.\n\nSuppose you know that many things that are true of $a$ are also true of $b$. For example: $Aa\\eand Ab$, $Ba\\eand Bb$, $\\enot Ca\\eand\\enot Cb$, $Da\\eand Db$, $\\enot Ea\\eand\\enot Eb$, and so on. This would not be enough to justify the conclusion $a=b$. (See p.~\\pageref{model.nonidentity}.) In general, there are no sentences that do not already contain the identity predicate that could justify the conclusion $a=b$. This means that the identity introduction rule will not justify $a=b$ or any other identity claim containing two different constants.\n\nHowever, it is always true that $a=a$. In general, no premises are required in order to conclude that something is identical to itself. So this will be the identity introduction rule, abbreviated {=}I:\n\n\\begin{proof}\n\t\\have[\\ \\,\\,\\,]{x}{\\script{c}=\\script{c}} \\by{=I}{}\n\\end{proof}\n\nNotice that the {=}I rule does not require referring to any prior lines of the proof. For any constant \\script{c}, you can write $\\script{c}=\\script{c}$ on any point with only the {=}I rule as justification.\n\nIf you have shown that $a=b$, then anything that is true of $a$ must also be true of $b$. For any sentence with $a$ in it, you can replace some or all of the occurrences of $a$ with $b$ and produce an equivalent sentence. For example, if you already know $Raa$, then you are justified in concluding $Rab$, $Rba$, $Rbb$. Recall that $\\script{A}[\\script{a}||\\script{b}]$ is the sentence produced by replacing \\script{a} in \\script{A} with \\script{b}. This is not the same as a substitution instance, because \\script{b} may replace some or all occurrences of \\script{a}. The identity elimination rule ({=}E) justifies replacing terms with other terms that are identical to it:\n\\begin{proof}\n\t\\have[m]{e}{\\script{a}=\\script{b}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{ea1}{\\script{A}[\\script{a}||\\script{b}]} \\by{=E}{e,a}\n\t\\have[\\ ]{ea2}{\\script{A}[\\script{b}||\\script{a}]} \\by{=E}{e,a}\n\\end{proof}\n\n%The basic rules for conjunction can be valuable in a proof even if there are no conjunctions in any of the assumptions; the basic rules for disjunction can be used even if there are no disjunctions in any assumptions; and similarly for the other basic rules. The rules for identity are different, in that there must be an identity claim in some assumption in order for the rules to do any work. Other than the trivial identity that we can introduce with the {=}I rule\n\n\n%do not apply we can now prove that identity is \\emph{transitive}: If $a=b$ and $b=c$, then $a=c$. The proof proceeds in this way:\n%\\begin{proof}\n%\t\\open\n%\t\t\\hypo{p}{a=b \\eand b=c}\\by{want $a=c$}{}\n%\t\t\\have{ab}{a=b}\\ae{p}\n%\t\t\\have{bc}{b=c}\\ae{p}\n%\t\t\\have{ac}{a=c}\\by{{=}E}{ab,bc}\n%\t\\close\n%\t\\have{conc}{(a=b \\eand b=c)\\eif a=c} \\ci{p-ac}\n%\\end{proof}\n\n\n%As an example, consider this argument:\n%\\begin{quote}\n%There is only one button in my pocket. There is a blue button in my pocket. Therefore, there is no button in my pocket that is not blue.\n%\\end{quote}\n%We begin by defining a symbolization key:\n%\\begin{ekey}\n%\\item{UD:} buttons in my pocket\n%\\item{Bx:} $x$ is blue.\n%\\end{ekey}\n%\\begin{proof}\n%\t\\hypo{one}{\\forall x\\forall y\\ x=y}\n%\t\\hypo{eb}{\\exists x Bx} \\by{want $\\enot\\exists x \\enot Bx$}{}\n%\t\\open\n%\t\t\\hypo{be1}{Be}\n%\t\t\\have{ef1}{e=f}\\Ae{one}\n%\t\t\\have{bf1}{Bf}\\by{{=}E}{ef1,be1}\n%\t\\close\n%\t\\have{bf}{Bf}\\Ee{eb,be1-bf1}\n%\t\\have{ab}{\\forall x Bx}\\Ai{bf}\n%\t\\have{nnab}{\\enot\\enot\\forall x Bx}\\by{DN}{ab}\n%\t\\have{nenb}{\\enot\\exists x\\enot Bx}\\by{QN}{nnab}\n%\\end{proof}\n\nTo see the rules in action, consider this proof:\n\\begin{proof}\n\t\\hypo{one}{\\forall x\\forall y\\ x=y}\n\t\\hypo{eb}{\\exists x Bx}\n\t\\hypo{Abnc}{\\forall x(Bx \\eif \\enot Cx)}\n\t\t\\by{want $\\enot\\exists x Cx$}{}\n\t\\open\n\t\t\\hypo{be1}{Be}\n\t\t\\have{ef1}{\\forall y\\ e=y}\\Ae{one}\n\t\t\\have{ef2}{e=f}\\Ae{ef1}\n\t\t\\have{bf1}{Bf}\\by{{=}E}{ef2,be1}\n\t\t\\have{bnc1}{Bf\\eif\\enot Cf}\\Ae{Abnc}\n\t\t\\have{ncf1}{\\enot Cf}\\ce{bnc1,bf1}\n\t\\close\n\t\\have{cf}{\\enot Cf}\\Ee{eb,be1-ncf1}\n\t\\have{Anc}{\\forall x \\enot Cx}\\Ai{cf}\n\t\\have{nEc}{\\enot\\exists x Cx}\\by{QN}{Anc}\n\\end{proof}\n\n%\\section*{Summary of definitions}\n%\\begin{itemize}\n%\\item A sentence \\script{A} is a \\define{theorem} if and only if $\\vdash\\script{A}$.\n%\n%\\item Two sentences \\script{A} and \\script{B} are \\define{provably equivalent} if and only if $\\script{A}\\vdash\\script{B}$ and $\\script{B}\\vdash\\script{A}$.\n%\n%\\item $\\{\\script{A}_1,\\script{A}_2,\\ldots\\}$ is \\define{provably inconsistent} if and only if, for some sentence \\script{B}, $\\{\\script{A}_1,\\script{A}_2,\\ldots\\}\\vdash(\\script{B} \\eand \\enot \\script{B})$.\n%\\end{itemize}\n\n\\practiceproblems\n\n\n\\problempart\n\\label{pr.identity}\nProvide a proof of each claim.\n\\begin{enumerate}[label=\\arabic*), topsep=0pt, parsep=0pt, itemsep=3pt] \n\\item $\\{Pa \\eor Qb, Qb \\eif b=c, \\enot Pa\\}\\sststile{}{} Qc$\n\\item $\\{m=n \\eor n=o, An\\}\\sststile{}{} Am \\eor Ao$\n\\item $\\{\\forall x x=m, Rma\\}\\sststile{}{} \\exists x Rxx$\n\\item $\\enot \\exists x x \\neq m \\sststile{}{} \\forall x\\forall y (Px \\eif Py)$\n\\item $\\forall x\\forall y(Rxy \\eif x=y)\\sststile{}{} Rab \\eif Rba$\n\\item $\\{\\exists x Jx, \\exists x \\enot Jx\\}\\sststile{}{} \\exists x \\exists y x\\neq y$\n%\\item $\\{\\forall x(x=n \\eiff Mx), \\forall x(Ox \\eand \\eor Mx)\\}\\sststile{}{} On$\n\\item $\\{\\exists x Dx, \\forall x(x=p \\eiff Dx)\\}\\sststile{}{} Dp$\n\\item $\\{\\exists x [(Kx \\eand Bx) \\eand \\forall y(Ky \\eif x=y)], Kd\\}\\sststile{}{} Bd$\n\\item $\\sststile{}{} Pa \\eif \\forall x(Px \\eor x \\neq a)$\n\\end{enumerate}\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "df66f1fac448946c578f52a8895d119256ee4619", "size": 25861, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/ch11-proofsinql.tex", "max_stars_repo_name": "robinson-philo/openintroduction", "max_stars_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/ch11-proofsinql.tex", "max_issues_repo_name": "robinson-philo/openintroduction", "max_issues_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/ch11-proofsinql.tex", "max_forks_repo_name": "robinson-philo/openintroduction", "max_forks_repo_head_hexsha": "042c4e6e993d235cf9f2b04879d2171e517acc54", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.4290843806, "max_line_length": 738, "alphanum_fraction": 0.6765786319, "num_tokens": 9132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.42973515624922903}}
{"text": "\\documentclass[]{aiaa-tc}% insert '[draft]' option to show overfull boxes\r\n\\usepackage{amsmath}\r\n\r\n \\title{A Rigorous Specification for a Medium Scale Sequential Quadratic Programming (SQP) Algorithm\\\\DRAFT}\r\n\r\n \\author{\r\n  Steven P. Hughes\r\n }\r\n\r\n\r\n\\newcommand{\\st}[1]{\\begin{ttfamily}#1\\end{ttfamily}}\r\n % Define commands to assure consistent treatment throughout document\r\n \\newcommand{\\eqnref}[1]{(\\ref{#1})}\r\n \\newcommand{\\class}[1]{\\texttt{#1}}\r\n \\newcommand{\\package}[1]{\\texttt{#1}}\r\n \\newcommand{\\file}[1]{\\texttt{#1}}\r\n\r\n \\renewcommand{\\thefigure}{\\arabic{figure}}\r\n\\begin{document}\r\n\r\n\\maketitle\r\n\r\n\\begin{abstract}\r\n   This document contains a rigorous mathematical and algorithmic specification for\r\n   a medium scale SQP code.  The Quadratic Programming (QP) subproblem is solved using\r\n   an active set method and the KKT system is solved using the null space method.  Matrix\r\n   factorizations are performed using QR factorization.\r\n\\end{abstract}\r\n\r\n\\section{Quadratic Programming Subproblem}\r\n\r\n\\begin{eqnarray}\r\n   \\mbox{min} & & \\frac{1}{2}\\mathbf{x}^T\\mathbf{G}\\mathbf{x} + \\mathbf{d}^T \\mathbf{x}\\\\\r\n   \\mbox{subject to} & & a_i \\geq b_i \\hspace{.05 in} (i \\in \\mathcal{I})\\\\\r\n     & & a_i = b_i \\hspace{.05 in} (i \\in \\mathcal{E})\r\n\\end{eqnarray}\r\n\r\n\r\n\\begin{equation}\r\n    \\nabla_x f - \\sum_i \\lambda_i a_i = 0\r\n\\end{equation}\r\n\r\n\\section{Line Search Algorithm}\r\n\r\nThe merit function is given by\r\n%\r\n\\begin{equation}\r\n     \\mathcal{L}(\\mathbf{x},\\boldsymbol{\\lambda},\\mathbf{s},\\boldsymbol{\\rho}) = f(\\mathbf{x}) - \\boldsymbol{\\lambda}^T\\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s}\\right)\r\n      + \\frac{1}{2} \\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s}\\right)^T \\mathbf{D}(\\boldsymbol{\\rho}) \\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s}\\right)\r\n\\end{equation}\r\n%\r\nwhere\r\n%\r\n\\begin{equation}\r\n     \\mathbf{D}(\\boldsymbol{\\rho}) = \\mbox{diag}(\\boldsymbol{\\rho})\r\n\\end{equation}\r\n%\r\nand\r\n%\r\n\\begin{equation}\r\n s_i = \\left\\{\r\n    \\begin{array}{llcc}\r\n        0                               & \\mbox{if $i \\in \\mathcal{E}$}\\\\\r\n        \\mbox{max(0,$c_i(\\mathbf{x})$)} & \\mbox{if $i \\in \\mathcal{I}$ and $\\rho = 0$}\\\\\r\n        \\mbox{max(0,$c_i(\\mathbf{x}) - \\lambda_i/\\rho$)} & \\mbox{otherwise}\\\\\r\n    \\end{array}\r\n \\right.\r\n\\end{equation}\r\n%\r\nDefine the search direction for the slack variables to be $q$ where\r\n%\r\n\\begin{equation}\r\n     q_k \\equiv J_k p_k + c_k - s_k\r\n\\end{equation}\r\n%\r\nand the search direction for the Lagrange multiplier estimates to be\r\n%\r\n\\begin{equation}\r\n     \\xi_k = \\mu_k - \\lambda_k\r\n\\end{equation}\r\n%\r\nThe step in terms of $\\alpha$ is then,\r\n%\r\n\\begin{equation}\r\n   \\left(\r\n   \\begin{array}{ccc}\r\n       x_{k+1}\\\\\r\n       s_{k+1}\\\\\r\n       \\lambda_{k+1}\r\n   \\end{array}\r\n   \\right) =\r\n   %\r\n    \\left(\r\n    \\begin{array}{ccc}\r\n       x_{k}\\\\\r\n       s_{k}\\\\\r\n       \\lambda_{k}\r\n   \\end{array}\r\n   \\right) +\r\n      %\r\n    \\alpha  \\left(\r\n    \\begin{array}{ccc}\r\n       p_{k}\\\\\r\n       q_{k}\\\\\r\n       xi_{k}\r\n   \\end{array}\r\n   \\right)\r\n\\end{equation}\r\n%\r\n\\begin{equation}\r\n     \\nabla \\mathcal{L}\\left( \\mathbf{x}, \\boldsymbol{\\lambda}, \\mathbf{s} \\right) = \\left(\r\n     \\begin{array}{c}\r\n          \\mathbf{g}  -  \\mathbf{J}(\\mathbf{x})^T \\boldsymbol{\\lambda} + \\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s} \\right)^T \\mathbf{D}(\\boldsymbol{\\rho}) \\mathbf{J}(\\mathbf{x})\\\\\r\n           -\\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s} \\right) \\\\\r\n           \\boldsymbol{\\lambda} - \\left(\\mathbf{c}(\\mathbf{x}) - \\mathbf{s} \\right)\\mathbf{D}(\\boldsymbol{\\rho})\r\n     \\end{array}\r\n     \\right)\r\n\\end{equation}\r\n%\r\n\\begin{equation}\r\n     \\phi'(\\alpha) = \\left[\\mathbf{p}^T  \\hspace{.05 in} \\boldsymbol{\\xi}^T \\hspace{.05 in} \\mathbf{q}^T \\right]\r\n      \\nabla \\mathcal{L}\\left( \\mathbf{x}+\\alpha \\mathbf{p}, \\boldsymbol{\\lambda}+\\alpha \\mathbf{q}, \\mathbf{s} +\\alpha \\boldsymbol{\\xi}\\right)\r\n\\end{equation}\r\n%\r\nDefine $\\mathbf{r}$ such that $ \\mathbf{r} \\equiv \\left( r_1,\r\nr_2,...,r_m\\right)$ where $r_i = (c_i - s_i)^2$.  We chan choose the\r\npenalty parameters to minimize ...\r\n%\r\n\\begin{equation}\r\n    \\boldsymbol{\\rho}* = \\frac{\\theta}{\\mathbf{r}^T \\mathbf{r}} \\mathbf{r}\r\n\\end{equation}\r\n%\r\n\\begin{equation}\r\n    \\theta = \\mathbf{g}^T\\mathbf{p} + (2 \\boldsymbol{\\lambda} - \\boldsymbol{\\mu})^T(\\mathbf{c} - \\mathbf{s}) +\r\n    \\displaystyle\\frac{1}{2}\\mathbf{p}^T\\mathbf{H}\\mathbf{p}\r\n\\end{equation}\r\n%\r\n\\begin{equation}\r\n    \\Delta_\\rho\r\n\\end{equation}\r\n%\r\n\\begin{equation}\r\n \\bar{\\rho}_i = \\mbox{max}(\\rho^*_i, \\hat{\\rho_i} ),  \\hspace{.1 in} \\mbox{where} \\hspace{.1 in} \\hat{\\rho_i} = \\left\\{\r\n    \\begin{array}{llcc}\r\n        \\rho_i                                & \\rho_i < 4(\\rho_i^* + \\Delta_\\rho)  \\\\\r\n        (\\rho_i(\\rho_i^* + \\Delta \\rho)^{1/2} & \\mbox{otherwise}  \\\\\r\n    \\end{array}\r\n \\right.\r\n\\end{equation}\r\n%\r\nThe sufficient decrease conditions are\r\n%\r\n\\begin{eqnarray}\r\n    \\phi(\\alpha) - \\phi(0) &\\leq& \\sigma \\alpha \\phi'(0)\\\\\r\n    %\r\n    | \\phi'(\\alpha) | & \\leq & -\\eta \\phi'(0)\r\n\\end{eqnarray}\r\n%\r\nwhere $0 \\leq \\sigma \\leq \\eta \\leq \\frac{1}{2}$.\r\n\r\n\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "1368ccb8b549203f8840649ab279d671e10d2992", "size": 5023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "prototype/NuMin/doc/miNLPSpec.tex", "max_stars_repo_name": "Randl/GMAT", "max_stars_repo_head_hexsha": "d6a5b1fed68c33b0c4b1cfbd1e25a71cdfb8f8f5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-01T13:14:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-09T07:05:07.000Z", "max_issues_repo_path": "prototype/NuMin/doc/miNLPSpec.tex", "max_issues_repo_name": "ddj116/gmat", "max_issues_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_issues_repo_licenses": ["NASA-1.3"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-03-15T08:58:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-20T20:11:26.000Z", "max_forks_repo_path": "prototype/NuMin/doc/miNLPSpec.tex", "max_forks_repo_name": "ddj116/gmat", "max_forks_repo_head_hexsha": "39673be967d856f14616462fb6473b27b21b149f", "max_forks_repo_licenses": ["NASA-1.3"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-13T10:26:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-09T07:06:55.000Z", "avg_line_length": 30.6280487805, "max_line_length": 180, "alphanum_fraction": 0.5888911009, "num_tokens": 1817, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.4297351530357624}}
{"text": "%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Problem Set/Assignment Template to be used by the\n%% Food and Resource Economics Department - IFAS\n%% University of Florida's graduates.\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Version 1.0 - November 2019\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Ariel Soto-Caro\n%%  - asotocaro@ufl.edu\n%%  - arielsotocaro@gmail.com\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass[12pt]{article}\n\\usepackage{design_ASC}\n\n\\theoremstyle{definition}\n\\usepackage{longtable}\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{slo}{Definition}[section]\n\\newcommand*{\\Perm}[2]{{}^{#1}\\!P_{#2}}%\n\\newcommand*{\\Comb}[2]{{}^{#1}C_{#2}}%\n\\setlength\\parindent{0pt} %% Do not touch this\n\\usepackage{amsmath}% http://ctan.org/pkg/amsmath\n%% -----------------------------\n%% TITLE\n%% -----------------------------\n\\title{\\textbf{Discrete Random variable}} %% Assignment Title\n\n\\author{\\textbf{Ibrahim Abou Elenein}}\n\n\\date{\\today} %% Change \"\\today\" by another date manually\n%% -----------------------------\n%% -----------------------------\n\n%% %%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\setlength{\\droptitle}{-5em}    \n%% %%%%%%%%%%%%%%%%%%%%%%%%%\n\\maketitle\n\n% --------------------------\n% Start here\n% --------------------------\n\n% %%%%%%%%%%%%%%%%%%%\n\\section{Random Variable}\n A random variable is a quantity “X ” resulting from an experiment, by chance,\n that can assume different values.\\\\\n\n A random variable is a variable “X” that\n has a single numerical value determined by chance, for each outcome of a\n procedure.\\\\\n\n If a sample space S is discrete, then every R.V.  defined on S is\n also discrete, i.e., its range is countable (think of random counts for\n examples).\n\\section{Discrete Random Variable}\n A Discrete Random Variable is a variable that can assume only certain clearly\n separated values. \\\\\n\n A Discrete Random Variable has either a finite or countable\n number of values, where “countable” refers to the fact that there might be\n infinitely many values, but they can be associated with a counting process.\n \\subsection{Examples of Discrete Random Variables}\n \\begin{itemize}\n     \\item The outcome of rolling a single die.\n     \\item The number of boys in a family with three children.\n     \\item The number of heads that appear when a coin is flipped nine times.\n     \\item The sum of the numbers on the dice, when k dice are rolled.\n     \\item The number of bits received in error when n bits are received.\n     \\item The number of bits received until the r-th error.\n \\end{itemize}\n \\section{Discrete Probability Distributions}\nA discrete probability distribution is a listing of \nall possible values of a random variable along \nwith their probabilities. \\\\\n\\begin{equation}\n    \\displaystyle \\frac{X}{P(X)} \\frac{|x_1|}{|p_1|} \\frac{|x_2|}{|p_2|} \\frac{|x_2|}{|p_2|} \n    \\frac{|\\dots|}{|\\dots|} \\frac{|x_k|}{|p_k|}; \\  \\ \\  \\sum _{k \\geq 1} p_k = 1.\n\\end{equation}    \n\\begin{enumerate}\n    \\item The sum of all probabilities must be 1in any probability distribution\n    \\item All probability values must be in [0,1]\n\\end{enumerate}\n\\begin{exmp}\n    x $\\Rightarrow$ The number of heads appearing when a coin is flipped three times.\n\n\\end{exmp}\n    \n% Please add the following required packages to your document preamble:\n% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly\n\\begin{longtable}[c]{lllll}\nX    & 0   & 1   & 2   & 3   \\\\\n\\endfirsthead\n%\n\\endhead\n%\nP(X) & 1/8 & 3/8 & 3/8 & 1/8\n\\end{longtable}\n\n\\subsection{Bernoulli}\nA Bernoulli trail is an experiment with only two outcomes Success and Failure \n\\begin{enumerate}\n    \\item $P(S) = p = $ Probability of a success\n    \\item $P(F) = q = 1 - p = $ Probability of a failure\n\\end{enumerate}\nIf a Bernoulli random variable, X, denotes No. of successes, then\n\\begin{enumerate}\n    \\item $ X = 1$ if the outcome is success\n    \\item $ X = 0$ if the outcome is failure\n\\end{enumerate}\n\\begin{exmp}\nA bit is transmitted, it is received in error with probability “0.1”.\\\\\nAssume that 8 bits are transmitted independently.\n\\begin{enumerate}\n    \\item How many bits can be received in error?\n        \\begin{center}\n            $\\Perm{8}{2}$\n        \\end{center}   \n    \\item What is the probability that 2 bits are received in error\n        \\begin{center}\n            $P(X=2) = \\Perm{8}{2} \\times (0.1)^2 (0.9)^6  $  \n        \\end{center}   \n\\end{enumerate}\n\\end{exmp}    \n\\subsection{Binomial Distribution}\nIn general, let X stand for the number of bits received in error, when $n$ bits are transmitted,\nwith the probability of a single bit in error being $p$\n\\begin{equation}\n    P (X = k) = \\Comb{n}{k} \\times p^k \\times (1-p)^{n - k} \n\\end{equation}    \n\n\\begin{equation}\n    \\sum_{k = 0}^{n} p_k  = \\Comb{n}{k} \\times p^k \\times (1-p)^{n - k} = [(p)+(1-p)]^n = 1 ^ n = 1\n\\end{equation}    \n\\begin{exmp}\nA fair coin is tossed 10 times, what is the probability of getting:\n\\begin{enumerate}\n    \\item  Exactly 6 heads.\n        \\begin{center}\n            $ n = 10; \\ \\ p = 0.5; q = 0.5 $ \n        \\end{center}   \n        \\begin{center}\n            $P(X = 6) = \\Comb{10}{6} \\times (0.5)^6 \\times (0.5)^4   $ \n        \\end{center}   \n    \\item  At least 6 heads.\n        \\begin{center}\n            $P(X \\geq 6) = P(X = 6) + P(X = 7) + P(X = 8) + P(X = 9) + P(X = 10)  $\n        \\end{center}   \n\\end{enumerate}\n\\end{exmp}    \n\n\\subsection{Geometric Distribution}\n\nA bit is transmitted, it is received in error with probability “0.1”.\n\nAssume that bits are transmitted independently, until the first bit is received\nin error.\n\\begin{enumerate}\n\n    \\item How many bits can be received?\n        \\begin{center}\n            Infinity many many\n        \\end{center}\n    \\item What is the probability that the 5-th bit is received in error?\n        \\begin{center}\n            $  P(X = 5) = 0.1 \\times 0.9^4 $\n        \\end{center}\n    \\item What is the probability that at least 5 (i.e. 5 or more) bits are received until the first error\n        \\begin{center}\n            $  P(X \\geq 5) = P(X = 5) + P(X = 6) + \\dots $  =\n        \\end{center}\n        \\begin{center}\n            $  \\displaystyle \\sum_{k = 5}^{\\infty} P(X = K) = \\sum_{k = 5}^{\\infty}(0.1)(0.9)^{k-1} = 0.656$\n        \\end{center}\n\n\\end{enumerate}\nSo The General case is \n\\begin{equation}\n    P(X = k) = p \\times (1 - p)^{k-1} ; \\ \\ \\ k \\geq 1\n\\end{equation}    \n\n\\begin{equation}\n    \\displaystyle \\sum_{k = 1}^{\\infty}   P(X = k) = \\sum_{k = 1}^{\\infty}p \\times (1 - p)^{k-1}\n    = p\\sum_{k = 1}^{\\infty}(1 - p)^{k-1} = p \\times \\frac{1}{p} = 1\n\\end{equation}    \n\\begin{exmp}\n    Given that the first $k$ trials were Failures. Find the probability that $(k+1)$-th trial will be a Success. \\\\\n\n    we need to find that $P(X = k + 1 | X > k)$\n    \\begin{center}\n        $ \\displaystyle  P(X = k + 1 | X > k) = \\frac{P(X=k+1 \\cap X>k)}{P(X>k)}\n        = \\frac{p \\times (1-p)^k}{(1-p)^k} = p = p(X = 1)$  this called lack of memory where the probability\n        of k + 1 is the same as the first\n\\end{center}\n\\end{exmp}    \n\\subsection{Negative Binomial}\nWhen a bit is transmitted, it is received in error with probability “0.1”.\nAssume that bits are transmitted independently, until FOUR bits are received in error.\n\\begin{enumerate}\n    \\item At least, how many bits can be received ?\n        \\begin{center}\n            at least 4 bits.\n        \\end{center}   \n    \\item What is the probability that exactly 10 bits will be received\n        \\begin{center}\n            $  P(X= 10) = (0.1)^9 \\times \\Comb{9}{3} \\times (0.9)^6 \\times (0.1)^3 $\n        \\end{center}   \n        In General, $P(X = k) = \\Comb{k-1}{3} \\times (1-p)^{k-4} \\times p^4$\n\n\\end{enumerate}   \n\\begin{slo}\n In general, let X stand for the number of bits\nreceived until r bits are received in error, with\nthe probability of a single bit in error being p.\n\\end{slo}   \n\\begin{equation}\n    P(X = k) =  \\underbrace{p^r}_{\\text{last trial}} \n    \\ \\ \\underbrace{\\Comb{k-1}{r-1} (1-p)^{k-r}}_{\\text{$(r - 1)$success in$(k - 1)$trial}}; \\ \\ k \\geq r. \n\\end{equation}\n\\begin{equation}\n    \\displaystyle \\sum_{k=r}^{\\infty} \\Comb{k-1}{r-1} p^r(1-p)^{k-r} =\n    \\sum_{k' = 0}^{\\infty} \\Comb{k' + r -1}{k'} \\ p^r (1-p)^{k'}\n\\end{equation}\ngiven that $ \\displaystyle \\Comb{n}{k} = \\Comb{n}{n- k}$\n\n\\begin{equation}\n    \\displaystyle \\sum_{k' = 0}^{\\infty} \\Comb{k' + r -1}{k'} \\ p^r (1-p)^{k'} =\n    p^r \\sum_{k'= 0}^{\\infty}  \\Comb{k' + r-1}{r-1}(1-p)^{k'}\n\\end{equation}\ngiven that $ \\displaystyle \\frac{1}{(1-x)^r} = \\sum_{k=0}^{\\infty} \\Comb{k+r-1}{r-1}x^r $\n\\begin{equation}\n    \\displaystyle p^r \\sum_{k'= 0}^{\\infty}  \\Comb{k' + r-1}{r-1}(1-p)^{k'} = p^r * \\frac{1}{(1-(1-p))^r} = 1 \n\\end{equation}\n\\section{Notes}\n\\begin{enumerate}\n    \\item Recall that a binomial random variable is a count of the number\n    of successes in n Bernoulli trials. That is, the number of trials n is\n    predetermined, and the number of successes represents the random variable X.\n    \\item  A negative binomial random variable is a count of the number of\ntrials required to obtain r successes. That is, the number of\nsuccesses r is predetermined, and the number of trials (n or k)\nrepresents the random variable X.\n\\end{enumerate}    \n\\end{document}\n", "meta": {"hexsha": "43252ba31292a7466c108568b6d4b585e650424f", "size": 9265, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture6/main.tex", "max_stars_repo_name": "AhmedNasserG/math401-notes", "max_stars_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture6/main.tex", "max_issues_repo_name": "AhmedNasserG/math401-notes", "max_issues_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture6/main.tex", "max_forks_repo_name": "AhmedNasserG/math401-notes", "max_forks_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.662601626, "max_line_length": 115, "alphanum_fraction": 0.6049649217, "num_tokens": 2942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736783928749127, "lm_q2_score": 0.7490872131147276, "lm_q1q2_score": 0.4297351485428042}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage[\\graphtype]{mfpic}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\opengraphsfile{pl02-05}\n\\hyphenation{ODSBESJN}\n\\begmath 2.5 Bessel Functions of General Orders $J_\\nu $ and $Y_\\nu $\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese subroutines compute a sequence of values $J_\\nu (x)$ or $Y_\\nu (x)$\nfor $\\nu = \\alpha $, $\\alpha + 1$, ..., $\\alpha +\\text{NUM} - 1$. $J_\\nu $\nand $Y_\\nu $ are Bessel functions of the first and second kinds,\nrespectively, as described in \\cite{ams55:bes}. $J_\\nu $ and $Y_\\nu $ are a\npair of linearly independent solutions of the differential equation\n\\begin{equation*}\nx^2\\frac{d^2w}{dx^2} + x\\frac{dw}{dx} + (x^2 - \\nu ^2)w = 0\n\\end{equation*}\n$Y_\\nu $ is also sometimes called the Neumann function and denoted by $N_\\nu\n.$\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype, Single Precision}\n\n\\begin{description}\n\\item[REAL]  \\ {\\bf X, ALPHA, BJ}($\\geq $NUM){\\bf ,BY}($\\geq $NUM)\n\n\\item[INTEGER]  \\ {\\bf NUM}\n\\end{description}\n\nAssign values to X, ALPHA, and NUM. To evaluate J Bessel functions:\n$$\n\\fbox{{\\bf CALL SBESJN (X, ALPHA, NUM, BJ)}}\n$$\nTo evaluate Y Bessel functions:\n$$\n\\fbox{{\\bf CALL SBESYN (X, ALPHA, NUM, BY)}}\n$$\nThe results are stored in BJ() or BY(), respectively.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\\item[X]  \\ [in] Argument for function evaluation. Require X $\\geq 0$ for\nthe J function and X $>0$ for the Y function. Require X $<(16\\rho\n)^{-1}$ for both functions, where $\\rho $ denotes the machine\nprecision.\n\n\\item[ALPHA]  \\ [in] Lowest order, $\\nu $, for which $J_\\nu (x)$ or $Y_\\nu\n(x)$ is to be computed. Require ALPHA $\\geq 0$. For sufficiently large $\\nu $%\n, depending on $x$, positive values of $J_\\nu (x)$ will be smaller than the\ncomputer's underflow limit and the magnitude of $Y_\\nu (x)$ will exceed the\noverflow limit. SBESYN issues an error message before overflow occurs.\n\n\\item[NUM]  \\ [in] Number of values of $\\nu $ for which $J_\\nu (x)$ or $%\nY_\\nu (x)$ is to be computed. Require NUM $\\geq 1.$\n\n\\item[BJ()]  \\ [out] Array in which SBESJN will store results. BJ($%\ni)=J_{\\alpha +i-1}(x)$ for $i=1$, 2, ..., NUM.\n\n\\item[BY()]  \\ [out] Array in which SBESYN will store results. BY($%\ni)=Y_{\\alpha +i-1}(x)$ for $i=1$, 2, ..., NUM.\n\\end{description}\n\n\\subsubsection{Modifications for Double Precision}\n\nFor double precision usage, change the REAL statement to DOUBLE PRECISION\nand change the subroutine names to DBESJN and DBESYN, respectively.\n\n\\subsection{Examples and Remarks}\n\nThese Bessel functions satisfy the Wronskian identity (\\cite{ams55:bes},\nEq.\\,9.1.16)\n\\begin{equation*}\nz(\\nu ,x) = \\frac{x\\pi }{2} \\left[J_{\\nu +1}(x) Y_\\nu (x) - J_\\nu (x) Y_{\\nu\n+1}(x)\\right] - 1 = 0\n\\end{equation*}\nThe program DRSBESJN evaluates this expression for a few values of $\\nu $\nand $x$. The results are shown in ODSBESJN.\n\n\\subsection{Functional Description}\n\n\\subsubsection{Properties of J and Y}\n\nIn the region $x \\geq \\nu $, both J and Y are oscillatory and are bounded in\nmagnitude by one. For fixed $\\nu \\geq 0$ and increasing $x$ these functions\nhave asymptotic behavior described by (\\cite{ams55:bes}, Eqs.\\,9.2.1~--~9.2.2)\n\\begin{align}\n\\label{O1}J_\\nu (x) &\\sim [2/(\\pi x)]^{1/2} \\cos (x-(\\nu + 0.5)\\pi /2)\n\\hspace{-1in}\\\\\n\\label{O2}Y_\\nu (x) &\\sim [2/(\\pi x)]^{1/2} \\sin (x - (\\nu + 0.5)\\pi /2)\n\\hspace{-1in}\n\\end{align}\nIn the region $\\nu \\geq x$, $J_\\nu (x)$ is positive and bounded and\napproaches zero as $\\nu $ increases with fixed $x > 0$, while $Y_\\nu (x)$ is\nnegative and unbounded and approaches $-\\infty $ as $\\nu $ increases with\nfixed $x > 0$. For fixed $x > 0$ and increasing $\\nu $, these functions have\nasymptotic behavior described by (\\cite{ams55:bes}, Eqs.\\,9.3.1~--~9.3.2).\n\\begin{align}\n\\label{O3}J_\\nu (x) &\\sim (2\\pi \\nu )^{-1/2}(ex/(2\\nu ))^\\nu\\\\\n\\label{O4}Y_\\nu (x) &\\sim -(2/(\\pi \\nu ))^{\\frac{1}{2}}(ex/(2\\nu))^{-\\nu}\n\\end{align}\nwhere $e = 2.718\\cdots .$\n\nBoth J and Y satisfy the recursion (\\cite{ams55:bes}, Eq.\\,9.1.27)\n\\begin{equation}\n\\label{O5}f_{\\nu +1}(x) - (2\\nu /x) f_\\nu (x) + f_{\\nu - 1}(x) = 0\n\\end{equation}\nFor $\\nu > x$ this recursion is stable in the forward direction for Y and in\nthe backward direction for J. For $x > \\nu $ the recursion is stable in\neither direction for both J and Y.\n\n%\\vspace{10pt}\n% \\hspace{.3in}\\mbox{\\input pl02-05a }\\vspace{12pt}\n%\\centerline{$x$}\n%\\centerline{Figure 1. ~ $J_{\\nu}(x)$}\n%\\vspace{15pt}\n\n%\\vspace{10pt}\n\n% \\hspace{.3in}\\mbox{\\input pl02-05b }\\vspace{12pt}\n%\\centerline{$x$}\n%\\centerline{Figure 2. ~ $Y_{\\nu}(x)$}\\vspace{10pt}\n%\n\\subsubsection{Machine dependent quantities}\n\nLet $\\rho $ denote the machine precision, $i.e.$, R1MACH(3) or\nD1MACH(3) of Chapter~19.1. Let $\\Omega $ denote the overflow limit, $i.e.$,\nR1MACH(2) or D1MACH(2). Define\n\\begin{equation*}\n\\mathit{XPQ} = 1.1293(-\\log _{10}(\\rho /4)) - 0.59\n\\end{equation*}\nThe asymptotic series used in these subroutines is valid for $x \\geq\n\\mathit{XPQ}$ and $0 \\leq \\nu \\leq 2.$\n\nLet $\\nu ^*(x)$ denote the value of $\\nu $ for which Eq.\\,(4) reaches the overflow\nlimit, $\\Omega $, for a given value of $x$. It happens that $\\nu ^*(x)$ is very\nclose to the value of $\\nu $ for which Eq.\\,(3) reaches the underflow limit on the\nsame machine. The figure below shows plots of $\\nu ^*(x)$ for some\ncomputer systems currently in use at JPL.\n\\vspace{5pt}\n\n\\mbox{\\input pl02-05c }\n\n%\\centerline{$x$}\n%\\centerline{Figure 3. ~Underflow limit for $J_{\\nu}$; overflow limit\n%for $Y_{\\nu}$}\\vspace{5pt}\n\n\\subsubsection{Computation of $J_\\nu (x)$}\n\nGiven $x$, $\\alpha $, and NUM, define $\\beta = \\alpha +\\text{NUM} - 1$.\nThus, $\\beta $ is the largest requested order.\n\nFor $x = 0$ the result is 1 if $\\nu = 0$, and 0 if $\\nu > 0.$\n\nFor $0 < x \\leq 0.1$ the Taylor series in $x$ is used\n(\\cite{ams55:bes},Eq.\\,9.1.10).  For $0.1 < x \\leq \\max (\\beta ,\n\\mathit{XPQ})$ forward recursion on $\\nu $ is used to determine a starting\npoint for backward recursion.  The execution time in this region increases\nlinearly with $\\beta $ and can be substantial for large $\\beta .$\n\nFor $\\max (\\beta , \\mathit{XPQ}) < x < (16\\rho )^{-1}$ the subroutine\nevaluates the asymptotic series in $x$ (\\cite{ams55:bes}, Eqs.\\,9.2.5,\n9.2.9, and~9.2.10) for two values of $\\nu $ in the range [0,~2], and then\nuses forward recursion.  The execution time in this region increases\nlinearly with $\\beta $ and decreases with increasing $x.$\n\nIf $x > (16\\rho )^{-1}$ an error message is issued\nbecause the phase of the sine and cosine functions will not be known with\nany accuracy.\n\n\\subsubsection{Computation of $Y_\\nu (x)$}\n\nIf $x = 0$ an error message is issued since the result would be $-\\infty $.\nThe output values are set to $-\\Omega /2.$\n\nFor $0 < x \\leq \\rho $ and $\\nu = 0$, the result is $(2/\\pi ) (\\gamma +\\ln\n(x/2))$ (\\cite{ams55:bes}, Eq.\\,9.1.13), where $\\gamma $ denotes Euler's\nconstant, $0.57721\\cdots$.  For $0 < x \\leq \\rho $ and $\\nu > 0$, the result is\n$-\\pi ^{-1} \\Gamma (\\nu ) (x/2)^{-\\nu }$ (\\cite{ams55:bes}, Eq.\\,9.1.9).\n\nFor $\\rho < x < \\mathit{XPQ}$ the subroutine first computes values of J. From\nthese values it computes Y for two values of $\\nu $ in [0,~2], and then uses\nforward recursion on $\\nu $ to obtain the requested values.\n\nFor $\\mathit{XPQ} \\leq x \\leq (16\\rho )^{-1}$ the subroutine evaluates the\nasymptotic series in $x$ for two values of $\\nu $ in [0,~2], and then uses\nforward recursion.\n\nIf $x > (16\\rho )^{-1}$ an error message is issued as noted\npreviously for J.\n\n\\subsubsection{Accuracy tests}\n\nThe subroutines SBESJN and SBESYN were tested on an\nIBM compatible PC using IEEE arithmetic by comparison with\nthe corresponding double precision subroutines.  Tables 1 and\n2 give a summary of the errors found in these tests.  Each\nnumber in a rectangular cell is the maximum value of the\nerror observed at 2592 points tested in the indicated range.\nEach number in a triangular cell is the maximum over 1296\npoints.  The underflow limit for $J_{\\nu}$, and the overflow\nlimit for $Y_{\\nu}$, actually extend down the $\\nu $ axis\n(see Figure~3).  Where the function underflows or overflows,\nfewer samples are used.\n\n\\begin{quote}Table 1. Maximum errors found in indicated regions for SBESJN.\nRelative error is shown above the diagonal and absolute error below. Error\nis shown as a multiple of the machine precision, $\\approx 1.19\n\\times 10^{-7}$ for these tests.\n\\end{quote}\\vspace{10pt}\n\n\\setlength{\\unitlength}{1pt}\n\\begin{picture}(218, 160)(-36, -20)\n\\put(-30, 75){$\\nu$}\n\\multiput(0, 0)(0, 25){7}{\\line(1, 0){180}}\n\\put(0, 0){\\line(0, 1){150}}\n\\put(30, 0){\\line(0, 1){125}}\n\\multiput(60, 0)(30, 0){5}{\\line(0, 1){150}}\n\\put(-2, -10){0}\n\\put(28, -10){2}\n\\put(58, -10){5}\n\\put(85, -10){10}\n\\put(115, -10){20}\n\\put(144, -10){50}\n\\put(170, -10){100}\n\\put(-24, -10){\\makebox(20, 20)[r]{0}}\n\\put(-24, 15){\\makebox(20, 20)[r]{2}}\n\\put(-24, 40){\\makebox(20, 20)[r]{5}}\n\\put(-24, 65){\\makebox(20, 20)[r]{10}}\n\\put(-24, 90){\\makebox(20, 20)[r]{20}}\n\\put(-24, 115){\\makebox(20, 20)[r]{50}}\n\\put(-24, 140){\\makebox(20, 20)[r]{100}}\n\\put(0, 0){\\line (6, 5){180}}\n\\put(90, -20){$x$}\n\\put(0, 125){\\makebox(60, 25){\\small OVERFLOW}}\n\\put(0, 100){\\makebox(30, 25){17}}\n\\put(0, 75){\\makebox(30, 25){27}}\n\\put(0, 50) {\\makebox(30, 25){10}}\n\\put(0, 25) {\\makebox(30, 25){4}}\n\\put(0, 0)    {\\makebox(30, 25){~\\raisebox{5pt}{2} \\hfill\n\\raisebox{-5pt}{1}~}}\n\\put(30, 100){\\makebox(30, 25){17}}\n\\put(30, 75){\\makebox(30, 25){10}}\n\\put(30, 50) {\\makebox(30, 25){7}}\n\\put(30, 25) {\\makebox(30, 25){~\\raisebox{5pt}{3} \\hfill\n\\raisebox{-5pt}{1}~}}\n\\put(30, 0)    {\\makebox(30, 25){1}}\n\\put(60, 125){\\makebox(30, 25){18}}\n\\put(60, 100){\\makebox(30, 25){24}}\n\\put(60, 75){\\makebox(30, 25){10}}\n\\put(60, 50){\\makebox(30, 25){~\\raisebox{5pt}{5} \\hfill\n\\raisebox{-5pt}{2}~}}\n\\put(60, 25) {\\makebox(30, 25){1}}\n\\put(60, 0) {\\makebox(30, 25){1}}\n\\put(90, 125){\\makebox(30, 25){30}}\n\\put(90, 100){\\makebox(30, 25){26}}\n\\put(90, 75){\\makebox(30, 25){~\\raisebox{5pt}{9} \\hfill\n\\raisebox{-5pt}{4}~}}\n\\put(90, 50){\\makebox(30, 25){2}}\n\\put(90, 25) {\\makebox(30, 25){1}}\n\\put(90, 0) {\\makebox(30, 25){1}}\n\\put(120, 125){\\makebox(30, 25){44}}\n\\put(120, 100){\\makebox(30, 25){~\\raisebox{5pt}{21} \\hfill\n\\raisebox{-5pt}{27}~}}\n\\put(120, 75){\\makebox(30, 25){4}}\n\\put(120, 50){\\makebox(30, 25){2}}\n\\put(120, 25) {\\makebox(30, 25){2}}\n\\put(120, 0) {\\makebox(30, 25){2}}\n\\put(150, 125){\\makebox(30, 25){~\\raisebox{5pt}{39} \\hfill\n\\raisebox{-5pt}{96}~}}\n\\put(150, 100){\\makebox(30, 25){16}}\n\\put(150, 75){\\makebox(30, 25){3}}\n\\put(150, 50){\\makebox(30, 25){3}}\n\\put(150, 25) {\\makebox(30, 25){3}}\n\\put(150, 0) {\\makebox(30, 25){3}}\n\\end{picture}\n\nAs a test of the double precision subroutines, and an additional test of the\nsingle precision subroutines, the expression $z(\\nu ,x)$ defined in Section\nC was evaluated at 40 points. Nine values are shown in Table 3 from these\ntests of SBESJN and SBESYN and in Table 4 from the tests of DBESJN and\nDBESYN.\n\nThese subroutines are designed for use with arithmetic precision to about $%\n10^{-20}$. The auxiliary subroutine DBESPQ has no inherent accuracy\nlimitations.\n\n\\begin{quote}Table 2. Maximum errors found in indicated regions for SBESYN.\nRelative error is shown above the diagonal and absolute error below. Error\nis shown as a multiple of the machine precision, $\\approx 1.19\n\\times 10^{-7}$ for these tests.\n\\end{quote}\\vspace{10pt}\n\n\\begin{picture}(208, 160)(-36, -20)\n\\put(-30, 75){$\\nu$}\n\\multiput(0, 0)(0, 25){7}{\\line(1, 0){180}}\n\\put(0, 0){\\line(0, 1){150}}\n\\put(30, 0){\\line(0, 1){125}}\n\\multiput(60, 0)(30, 0){5}{\\line(0, 1){150}}\n\\put(-2, -10){0}\n\\put(28, -10){2}\n\\put(58, -10){5}\n\\put(85, -10){10}\n\\put(115, -10){20}\n\\put(144, -10){50}\n\\put(170, -10){100}\n\\put(-24, -10){\\makebox(20, 20)[r]{0}}\n\\put(-24, 15){\\makebox(20, 20)[r]{2}}\n\\put(-24, 40){\\makebox(20, 20)[r]{5}}\n\\put(-24, 65){\\makebox(20, 20)[r]{10}}\n\\put(-24, 90){\\makebox(20, 20)[r]{20}}\n\\put(-24, 115){\\makebox(20, 20)[r]{50}}\n\\put(-24, 140){\\makebox(20, 20)[r]{100}}\n\\put(0, 0){\\line (6, 5){180}}\n\\put(90, -20){$x$}\n\\put(0, 125){\\makebox(60, 25){\\small OVERFLOW}}\n\\put(0, 100){\\makebox(30, 25){44}}\n\\put(0, 75){\\makebox(30, 25){24}}\n\\put(0, 50) {\\makebox(30, 25){8}}\n\\put(0, 25) {\\makebox(30, 25){9}}\n\\put(0, 0)    {\\makebox(30, 25){~\\raisebox{5pt}{12} \\hfill\n\\raisebox{-5pt}{28}~}}\n\\put(30, 100){\\makebox(30, 25){84}}\n\\put(30, 75){\\makebox(30, 25){25}}\n\\put(30, 50) {\\makebox(30, 25){9}}\n\\put(30, 25) {\\makebox(30, 25){~\\raisebox{5pt}{9} \\hfill\n\\raisebox{-5pt}{14}~}}\n\\put(30, 0)    {\\makebox(30, 25){15}}\n\\put(60, 125){\\makebox(30, 25){162}}\n\\put(60, 100){\\makebox(30, 25){128}}\n\\put(60, 75){\\makebox(30, 25){27}}\n\\put(60, 50){\\makebox(30, 25){~\\raisebox{5pt}{9} \\hfill\n\\raisebox{-5pt}{9}~}}\n\\put(60, 25) {\\makebox(30, 25){15}}\n\\put(60, 0) {\\makebox(30, 25){10}}\n\\put(90, 125){\\makebox(30, 25){286}}\n\\put(90, 100){\\makebox(30, 25){143}}\n\\put(90, 75){\\makebox(30, 25){~\\raisebox{5pt}{29} \\hfill\n\\raisebox{-5pt}{4}~}}\n\\put(90, 50){\\makebox(30, 25){2}}\n\\put(90, 25) {\\makebox(30, 25){1}}\n\\put(90, 0) {\\makebox(30, 25){1}}\n\\put(120, 125){\\makebox(30, 25){585}}\n\\put(120, 100){\\makebox(30, 25){~\\raisebox{7pt}{153}\n\\hspace{-4pt}\\raisebox{-5pt}{19}\\hspace{2pt}~}}\n\\put(120, 75){\\makebox(30, 25){3}}\n\\put(120, 50){\\makebox(30, 25){2}}\n\\put(120, 25) {\\makebox(30, 25){2}}\n\\put(120, 0) {\\makebox(30, 25){2}}\n\\put(150, 125){\\makebox(30, 25){~\\raisebox{7pt}{659}\n\\hspace{-4pt}\\raisebox{-5pt}{68}\\hspace{2pt}~}}\n\\put(150, 100){\\makebox(30, 25){21}}\n\\put(150, 75){\\makebox(30, 25){3}}\n\\put(150, 50){\\makebox(30, 25){3}}\n\\put(150, 25) {\\makebox(30, 25){3}}\n\\put(150, 0) {\\makebox(30, 25){3}}\n\\end{picture}\n\n\\begin{center}\n\\centerline{Table 3. Single precision Wronskian test.}\n\\centerline{Tabulated value is $z(\\nu ,x)/\\text{R1MACH}(3)$}\n\\centerline{where R1MACH(3) $\\approx 5.96 \\times 10^{-8}.$}\\vspace{-5pt}\n\\begin{tabular}{r|rrr}\n\\multicolumn{1}{c}{$\\nu $} & $x \\Rightarrow $ 5.1 & 15.3 & 30.6\\\\\\hline\n30.6 & 6.2 & 24.6 & 3.5\\\\\n15.3 & 5.9 & 5.9 & 0.2\\\\\n5.1 & 1.3 & 0.7 & 3.5\\\\\n\\end{tabular}\\vspace{10pt}\n\n\\centerline{Table 4. Double precision Wronskian test.}\n\\centerline{Tabulated value is $z(\\nu ,x)/\\text{D1MACH}(3)$}\n\\centerline{where D1MACH(3) $\\approx 1.11 \\times 10^{-16}.$}\\vspace{-5pt}\n\\begin{tabular}{r|rrr}\n\\multicolumn{1}{c}{$\\nu $} & $x \\Rightarrow $ 5.1 & 15.3 & 30.6\\\\\\hline\n30.6 & 32.2 & 17.2 & 16.0\\\\\n15.3 & 3.9 & 5.8 & 0.4\\\\\n5.1 & 1.0 & 1.8 & 0.1\n\\end{tabular}\n\\end{center}\n\\nocite{Olver:1972}\n\\nocite{Amos:1977:CSI}\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nThese subroutines require $x \\geq 0$, ALPHA $\\geq 0$, and NUM $\\geq 1$.\nViolation of any of these conditions causes an error message and an\nimmediate return.\n\nThe subroutines attempt to anticipate and avoid overflow conditions.\nIntermediate overflows are avoided by dynamic rescaling. If a final value of\nY would be beyond the overflow limit the value is set to $-\\Omega /2$ and\nan error message is issued. It is assumed that the host\nsystem will set underflows to zero. No messages are issued for underflow.\n\nIf $x > (16\\rho )^{-1}$ an error message is issued\nsince no accuracy can be obtained.\n\nSubroutines SBESYN and DBESYN each contain an internal array AJ() to hold\nvalues of $J_\\nu (x)$ needed to compute $Y_\\nu (x)$. The size requirement of\nthis array varies with the machine precision and is about $3(-\\log _{10}\n\\rho ) + 3$. For example, for precisions of $10^{-10}$, $10^{-20}$,\nand $10^{-30}$ the required size is 33, 63, and~95. The array is nominally\ndimensioned~95 to handle all anticipated computers. An error message will be\nissued in the unlikely event that a larger dimension is needed.\n\nError messages are issued by the error message processor of\nChapter~19.2.\n\nThe user should be aware that these subroutines require a substantial amount\nof execution time, generally increasing linearly with the sum, ALPHA$+\\text{%\nNUM}.$\n\n\\subsection{Supporting Information}\n\nThe source language for these subroutines is ANSI Fortran 77.\n\nOriginal subroutines SBJNU, SBYNU, DBJNU, DBYNU, BESJ, and BESY were\ndesigned and programmed by W. V. Snyder and E. W. Ng, JPL, 1973, with\nmodifications by S.\\ Singletary in 1974. The present subroutines are\nmodifications of the earlier subroutines to improve portability and\naccuracy, avoid overflows, and conform to Fortran~77. These\nsubroutines were produced in 1984 by C. L. Lawson and S. Y. Chiu in\nconsultation with Snyder and Ng.\n\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDBESJN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESJN, DBESPQ, DERM1, DERV1, DGAMMA, ERFIN, ERMSG,\n IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\nDBESYN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESPQ, DBESYN, DERM1, DERV1, DGAMMA, DLGAMA, ERFIN,\nERMOR, ERMSG, IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\nSBESJN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMSG, IERV1, SBESJN, SBESPQ, SERM1, SERV1,\nSGAMMA\\rule[-5pt]{0pt}{8pt}}\\\\\nSBESYN & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMOR, ERMSG, IERV1, SBESPQ, SBESYN, SERM1,\nSERV1, SGAMMA, SLGAMA\\rule[-5pt]{0pt}{8pt}}\\\\\n\\end{tabular}\n\n\\begcodenp\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSBESJN}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sbesjn}}\n\n\\vspace{30pt}\\centerline{\\bf \\large ODSBESJN}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sbesjn}}\n\\closegraphsfile\n\\end{document}\n", "meta": {"hexsha": "dd7067146f258610990f475a3453ed70b9080e81", "size": 17567, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch02-05.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch02-05.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch02-05.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 38.1062906725, "max_line_length": 98, "alphanum_fraction": 0.6647122445, "num_tokens": 6910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.4296064090346056}}
{"text": "\\documentclass[]{article}\n\\usepackage[left=2cm,top=2cm,right=2cm]{geometry}\n\\usepackage{url}\n\\begin{document}\n\n\\title{Theory used by libgfshare}\n\\author{Simon McVittie}\n\\date{23rd April 2006}\n\\maketitle\n\n\\section{Introduction}\n\nlibgfshare implements Shamir secret sharing [SHAMIR] over the field $GF(2^8)$,\ninstead of $GF(p)$ for a prime $p$ as suggested by Shamir's paper.\nThis document aims to prove the security and integrity of this scheme.\n\nNote that while I believe this document to be correct, I accept no\nresponsibility for loss or damage caused by relying on the correctness\nof my proof.\n\n\\section{Definitions}\n\nLet $F$ be a field with multiplicative identity 1 and additive identity 0.\n\nIf $A = \\{(a_1, b_1), \\cdots, (a_n, b_n)\\}$, with the $a_i$ distinct nonzero\nelements of F and the $b_i$ elements of $F$, indexed by $I = \\{1,\\cdots,n\\}$,\nthen define\n\n\\[\n        P_A(x) = \\sum_{j\\in I} {b_j \\prod_{k\\in I, k\\neq j} {(x-a_k)(a_j-a_k)^{-1}}}\n\\]\n\na polynomial of degree at most $n-1$. (By distinctness of the $a_i$, the\ninverses required exist.) This is the Lagrange interpolating polynomial\nfor the points in $A$.\n\n\\section{Lemma 1}\n\nLet $a_1,\\cdots,a_t\\in F$ be distinct and nonzero; let\n$b_1,\\cdots,b_{t-1},c\\in F$ be arbitrary. Then there exists $b_t\\in F$\nsuch that if $A = \\{(a_1, b_1), \\cdots, (a_t, b_t)\\}$ then $P_A(0) = c$.\n\n\\subsection{Proof}\n\nLet $I = \\{1, \\cdots, t\\}$. We have\n\n\\[\nP_A(0) = \\sum_{j\\in I} {b_j \\prod_{k\\in I, k\\neq j}{-a_k(a_j-a_k)^{-1}}}\n= \\sum_{j\\in I} {y_j \\prod_{k\\in I, k\\neq j}{a_k(a_k-a_j)^{-1}}}\n\\]\n\nLet\n\n\\[\nb_t = \\left[c + \\sum_{j\\in I, j\\neq t}{b_j\\prod_{k\\in I,k\\neq j}{a_k(a_j-a_k)^{-1}}}\\right]\n        \\left[\\prod_{k\\in I,k\\neq t}{a_k^{-1}(a_k-a_t)}\\right]\n\\]\n\nThen\n\n\\[\nP_A(0) = \\sum_{j\\in I, j\\neq t} {b_j \\prod_{k\\in I, k\\neq j}{a_k(a_k-a_j)^{-1}}} + b_t \\prod_{k\\in I, k\\neq t}{a_k(a_k-a_t)^{-1}}\n\\]\\[\n= \\sum_{j\\in I, j\\neq t} {b_j \\prod_{k\\in I, k\\neq j}{a_k(a_k-a_j)^{-1}}} - \\sum_{j\\in I, j\\neq t} {b_j \\prod_{k\\in I, k\\neq j}{a_k(a_k-a_j)^{-1}}} + c\n\\]\\[\n= c\n\\]\n\nas required.\n\n\\section{Lemma 2}\n\nFor any $x_1,\\cdots,x_t$ distinct and nonzero elements of $F$, and any\n$y_1,\\cdots,y_t,u$ arbitrary elements of $F$, let\n\n\\[X = \\left\\{(x_1,y_1),\\cdots,(x_t,y_t)\\right\\}\\]\n\nand\n\n\\[U = \\left\\{(x_1,y_1),\\cdots,(x_{t-1},y_{t-1}),(u,P_X(u))\\right\\}\\]\n\nThen $P_X = P_U, i.e. P_X(x) = P_U(x)$ for all $x\\in F$.\n\n\\subsection{Proof}\n\nLet $S_{a,b} = \\left\\{(x_1,y_1),\\cdots,(x_{t-1},y_{t-1}),(a,b)\\right\\}$.\nThen\n\n\\[\nP_{S_{a,b}}(x) = \\sum_{j<t} y_j (x-a)(x_j-a)^{-1}\n        \\prod_{k\\ne j,k<t}(x-x_k)(x_j-x_k)^{-1}\n        + b\\prod_{k<t}(x-x_k)(a-x_k)^{-1}\n\\]\n\nHence if we let $d_{i,j} = x_i - x_j$ and $e_i = u - x_i$ (both of which\nare necessarily nonzero, by distinctness of the $x_i$ and $u$) we have\n\n\\[\nP_X(u) = \\sum_{j<t} y_j e_t d_{j,t}^{-1}\n        \\prod_{k\\ne j,k<t}e_kd_{j,k}^{-1}\n        + y_t\\prod_{k<t}e_kd_{t,k}^{-1}\n\\]\n\nand if we also let $f_i = x - x_i$,\n\n\\[\nP_U(x) = \\sum_{j<t} y_j (u-x)e_j^{-1} \\prod_{k\\ne j,k<t}f_k d_{j,k}^{-1}\n    + P_X(u)\\prod_{k<t} f_k e_k^{-1}\n\\]\\[\nP_U(x) = \\sum_{j<t} y_j (u-x)e_j^{-1} \\prod_{k\\ne j,k<t}f_k d_{j,k}^{-1}\n    + \\left\\{\\prod_{k<t} f_k e_k^{-1}\\right\\}\\left\\{\n        \\sum_{j<t} y_j e_t d_{j,t}^{-1}\\prod_{l\\ne j,l<t}e_kd_{j,l}^{-1}\n        + y_t\\prod_{l<t}e_ld_{t,l}^{-1}\n    \\right\\}\n\\]\n\nExpanding,\n\n\\[\n\\begin{array}{rcl}\nP_U(x) & = & \\sum_{j<t}y_j(u-x)e_j^{-1}\\left\\{\\prod_{k\\ne j,k<t}f_kd_{j,k}^{-1}\\right\\} \\\\\n& & + \\sum_{j<t}y_je_td_{j,t}^{-1}\n        \\left\\{\\prod_{l\\ne j,l<t}e_kd_{j,l}^{-1}\\right\\}\n        \\left\\{\\prod_{k<t}f_ke_k^{-1}\\right\\} \\\\\n& & + y_t\\left\\{\\prod_{k<t}e_kd_{t,k}^{-1}f_ke_k^{-1}\\right\\}\n\\end{array}\n\\]\n\n\\[\nP_U(x) = \\sum_{j<t}y_j\\left[\n        (u-x)e_j^{-1}\\left\\{\\prod_{k\\ne j,k<t}f_kd_{j,k}^{-1}\\right\\}\n        + e_td_{j,t}^{-1}f_je_j^{-1}\\left\\{\n            \\prod_{k\\ne j,k<t}e_kd_{j,k}^{-1}f_ke_k^{-1}\n        \\right\\}\n    \\right]\n    + y_t\\prod_{k<t}d_{t,k}^{-1}f_k\n\\]\\[\n= \\sum_{j<t} \\left[y_j \\prod_{k\\ne j,k<t}f_kd_{j,k}^{-1}\\right]\n        \\left[(u-x)e_j^{-1} + e_te_j^{-1}d_{j,t}^{-1}f_j\\right]\n        + y_t\\prod_{k<t}d_{t,k}^{-1}f_k\n\\]\n\nNow\n\n\\[\n(u-x)e_j^{-1} + e_te_j^{-1}d_{j,t}^{-1}f_j\n    = (e_j^{-1}d_{j,t}^{-1})\\left[(u-x)d_{j,t} + e_tf_j\\right]\n\\]\\[\n    = (e_j^{-1}d_{j,t}^{-1})\\left[(u-x)(x_j-x_t) + (u-x_t)(x-x_j)\\right]\n\\]\\[\n    = (e_j^{-1}d_{j,t}^{-1})(x - x_t)(u - x_j)\n\\]\\[\n    = d_{j,t}^{-1}f_t\n\\]\n\nHence\n\n\\[\nP_U(x)\n= \\sum_{j<t} \\left[y_j \\prod_{k\\ne j,k<t}f_kd_{j,k}^{-1}\\right]\n        \\left[f_td_{j,t}^{-1}\\right]\n        + y_t\\prod_{k<t}d_{t,k}^{-1}f_k = P_X(x)\n\\]\n\nas required.\n\n\\section{Construction}\n\nLet $s$ be the number of ``shares'' and $t$ be the required threshold\nto recover the shared secret (i.e. we construct a ``$t$ of $s$'' share).\n\nGiven a secret $f\\in F$ we may construct a Lagrange interpolating\npolynomial $P_X$ of degree no more than $t-1$, with $P_X(0) = f$, as\nfollows:\n\n- choose distinct nonzero $x_1,\\cdots,x_s \\in F$\n\n- choose arbitrary (and unpredictable) $y_1,\\cdots,y_{t-1} \\in F$\n\n- use Lemma 1 to select $y_t$ such that $X = \\{(x_1,y_1),\\cdots,(x_t,y_t)\\}$\n  has the desired intercept $f$\n\nTo obtain additional shares, calculate\n$y_{t+1} = P_X(x_{t+1}),\\cdots,y_s=P_X(x_s)$.\n\n\\section{Alternate construction, as used in libgfshare}\n\nIn libgfshare the construction used is as follows:\n\n- construct a polynomial $P$ by choosing arbitrary and unpredictable\n  coefficients of $x,\\cdots,x^{t-1}$ from $F$, and setting the coefficient\n  of $x^0$ to $f$: this therefore has the desired intercept $f$\n\n- choose distinct nonzero $x_1,\\cdots,x_s \\in F$ and evaluate\n  $y_1 = P(x_1),\\cdots,y_s = P(x_s)$\n\n\\subsection{Proof of equivalence in a finite field $F$}\n\nSuppose $F$ is finite, as is the case in libgfshare, and that in each\nconstruction, arbitrary choices are made from among all possible\nvalues in $F$.\n\nIn the alternate construction, given $x_1,\\cdots,x_t,f$ we choose a\npolynomial $P(x) = f+m_1x+\\cdots+m_{t-1}x^{t-1}$\nby choosing arbitrary coefficients $m_1,\\cdots,m_{t-1}\\in F$, i.e.\nchoosing arbitrarily from among the $\\left|F\\right|^{t-1}$ distinct\npolynomials of degree no more than $t-1$ with intercept $f$.\n\nIn the first construction, given $x_1,\\cdots,x_t,f$ we obtain a polynomial\nby choosing arbitrary $y_1,\\cdots,y_{t-1}\\in F$. The polynomials chosen\nare necessarily distinct since no polynomial can pass through both $(x_i, p)$\nand $(x_i, q)$ for any $p \\ne q$, so by choosing each $y_i$ from among the\n$\\left|F\\right|$ elements of $F$, we choose arbitrarily from a set of\n$\\left|F\\right|^{t-1}$ distinct polynomials whose intercepts are all $f$.\n\nSince there are only $\\left|F\\right|^{t-1}$ such polynomials, each\nconstruction chooses arbitrarily from among the same set, and by the\npigeonhole principle there exists a bijective mapping between sets of\narbitrary $y$ values in the first construction and sets of arbitrary\ncoefficients in the second.\n\n\\section{Theorem: With at least $t$ pieces the secret is recoverable}\n\nLet $B \\subset\\left\\{(x_1,y_1),\\cdots,(x_s,y_s)\\right\\}$ with $|B| = t$.\nThen $P_B(0) = c$.\n\nFurther, if $B^\\prime \\subset\\left\\{(x_1,y_1),\\cdots,(x_s,y_s)\\right\\}$\nwith $|B^\\prime| > t$, then for every subset $B$ of $B^\\prime$ with\n$|B| = t$, $P_B(0) = f$.\n\n\\subsection{Proof}\n\nThe second part is trivially implied by the first.\n\nRecall that $X = \\left\\{(x_1,y_1),\\cdots,(x_t,y_t)\\right\\}$ and that\n$P_X(0) = f$. If $B = X$ the result is true. If not, repeatedly apply\nLemma 2 to replace an element of $X$ not in $B$ with an element of $B$ not\nin $X$, preserving the value of $P(0)$.\n\n\\section{Theorem: With fewer than $t$ pieces no information is gained}\n\nLet $C \\subset\\left\\{(x_1,y_1),\\cdots,(x_s,y_s)\\right\\}$ with $|C|< t$.\nThen for each $d\\in F$, there exists $D\\supset C$, $|D| = t$, such that\n$d = P_D(0)$.\n\n(In other words, any $d\\in F$ remains a possible value for the secret, so\nan attacker with fewer than $t$ shares has gained no information.)\n\n\\subsection{Proof}\n\nLet $a_i$, $b_i$ be such that $C = \\left\\{(a_1,b_1),\\cdots,(a_n,b_n)\\right\\}$,\nsome $n < t$. Choose arbitrary $a_{n+1},\\cdots,a_{t}$ and arbitrary\n$b_{n+1},\\cdots,b_{t-1}$. Let $b_t$ be chosen by applying Lemma 1\nwith $c := d$. Then by choice of $b_t$, $P_C(0) = d$ as required.\n\n\\section{Implementation in $GF(2^8)$}\n\nThe program \\texttt{test\\_gfshare\\_isfield}, compiled and run by\n\\texttt{make check}, demonstrates that the calculations done by\nlibgfshare are indeed performed in a field.\n\n\\section{Attacks not addressed}\n\nThis document has not addressed the following:\n\n- Attacks based on the use of a predictable or partially predictable\n  pseudorandom number generator might be possible.\n\n- In the implementation used in libgfshare, the field $F$ is the field\n  of byte values, with addition being bitwise exclusive-or, and multiplication\n  as usual; each byte of the secret is shared separately by applying this\n  algorithm separately. This means that when a secret file is shared,\n  the length in bytes of each share equals the length in bytes of the\n  secret. If the length of the secret is itself secret, it should be\n  padded to some standard length before sharing.\n\n\\section{References}\n\n[SHAMIR] Adi Shamir, \"How to share a secret\", Communications of the ACM, 22(1), pp612--613, 1979. Available at \\url{http://www.cs.tau.ac.il/~bchor/Shamir.html}\n\n\\section{Copyright and disclaimer}\n\nCopyright 2006 Simon McVittie, \\url{http://smcv.pseudorandom.co.uk/}\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n\\end{document}\n", "meta": {"hexsha": "83b7f8dd47a165394940480a222f6299ae147f72", "size": 10415, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/theory.tex", "max_stars_repo_name": "CodeGnome/libgfshare", "max_stars_repo_head_hexsha": "da0566422af4e0ad5c9e17cfe21f563e4274338d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2015-02-04T18:03:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-10T06:45:28.000Z", "max_issues_repo_path": "doc/theory.tex", "max_issues_repo_name": "kamalmostafa/libgfshare", "max_issues_repo_head_hexsha": "49207273ca80c279205bb002b6eff1f843eaf437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2015-06-30T21:17:00.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-14T22:31:51.000Z", "max_forks_repo_path": "doc/theory.tex", "max_forks_repo_name": "kamalmostafa/libgfshare", "max_forks_repo_head_hexsha": "49207273ca80c279205bb002b6eff1f843eaf437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2015-10-29T14:21:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T07:33:14.000Z", "avg_line_length": 34.2598684211, "max_line_length": 159, "alphanum_fraction": 0.6600096015, "num_tokens": 3766, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4296064019894863}}
{"text": "\\vsssub\n\\subsubsection{~$S_{\\mathrm{in}} + S_{\\mathrm{ds}}$: Saturation-based dissipation} \\label{sec:ST4}\n\\vsssub\n\n\\opthead{ST4}{\\ws}{F. Ardhuin, J.-F. Filipot \\& L. Romero}\n\n\\noindent \nThis family of parameterizations uses a positive part of the wind input taken\nfrom WAM cycle 4 with an ad hoc reduction of $u_\\star$, implemented in\norder to allow a balance with a saturation-based dissipation that uses different options for \na cumulative term. There are three main options for defining the saturation and the cumulative term. Chosing one or the other is done with the  {\\F SDSBCHOICE} parameter, with  {\\F SDSBCHOICE=1} for \\cite{art:Aea10},  {\\F SDSBCHOICE=2} for \\cite{Filipot&Ardhuin2012}, and {\\F SDSBCHOICE=3} for \\cite{Romero2019}. That last options uses a saturation that is defined from the local spectral density, and thus gives zero dissipation for directions where the threshold is not reached, leading to much broader directional spectra. Also the stronger bimodality is achieved by having a strong modulation effect as a cumulative term. \n\nMany other adjustments can be made by changing the namelist parameters. A few successful combinations \nare given by tables \\ref{tab:ST4_parSIN} and \\ref{tab:ST4_parSDS}, with results described by \\citep{art:RA13,art:SAG16}. \nFurther calibration to any particular wind field should be done for best performance. Guidance for this is given by \\cite{Stopa2018}. \n%We also note that the particular \n%set of parameters T400 corresponds to setting IPHYS=1 in the ECWAM code cycle 45R2, with a few differences \n%related to the fact that precomputed stress tables have now been removed from ECWAM. \n\n\\vsssub\n\\textbf{Wind input and swell dissipation} \n\\vsssub\n\n\nThe reduction of $u_\\star$ in\neq. (\\ref{eq:SinWAM4}) is obtained by replacing it with $u_\\star '(k)$ defined for each\nfrequency as\n\n\\begin{equation}\n\\left(u_\\star '\\right)^2=\\left|u_\\star^2 \\left(\\cos \\theta_u, \\sin\n\\theta_u \\right) - \\left|s_u\\right| \\int_0^k \\int_0^{2 \\pi}\n\\frac{S_{in}\\left(k',\\theta \\right)}{C}  \\left(\\cos \\theta, \\sin\n\\theta \\right)  {\\mathrm d} k' \\mathrm d\n\\theta,\\label{ustarp}\\right|\n\\end{equation}\n\n\\noindent \nwhere the sheltering coefficient $\\left|s_u\\right|\\sim 1$ can be used to tune\nthe stresses at high winds, which would be largely overestimated for\n$s_u=0$. For $s_u > 0$ this sheltering is also applied within the diagnostic\ntail in eq. (\\ref{eq:tauhfint}), which requires the estimation of a\n3-dimensional look-up table for the high frequency stress, the third parameter\nbeing the energy level of the tail.\n\nThe {\\code STAB3} switch, described above for use with {\\code ST3}, may also be used with {\\code ST4}. If {\\code STAB3} is used, the air-sea  temperature differences should be provided by the user, e.g. using {\\file ww3\\_prep}.\n\nThe swell dissipation parameterization of \\cite{art:ACC09} is activated by\nsetting $s_1$ to a non-zero integer value, and is given by a combination of\nthe viscous boundary layer value,\n\n\\begin{equation}\n\\cS_{\\mathrm{out,vis}}\\left(k,\\theta\\right) = - s_5 \\frac{\\rho_a}{\\rho_w}\\left\\{ 2 k \\sqrt{2\n\\nu \\sigma}\\right\\}  N \\left(k,\\theta\\right) , \\label{eq:Dore}\n\\end{equation}\n\n\\noindent\nwith the turbulent boundary layer expression \n\\begin{equation}\n\\cS_{\\mathrm{out,tur}} \\left(k,\\theta\\right) = - \\frac{\\rho_a}{\\rho_w}\\left\\{  16 f_e\n\\sigma^2 u_{\\mathrm{orb},s} / g \\right\\}\n N\\left(k,\\theta\\right),  \\label{eq:swell_turb}\n\\end{equation}\n\n\\noindent\ngiving the full term \n\\begin{equation}\n\\cS_{\\mathrm{out}} \\left(k,\\theta\\right) = r_{vis} \\cS_{\\mathrm{out,vis}}\\left(k,\\theta\\right)  + \n r_{tur} \\cS_{\\mathrm{out,tur}}\\left(k,\\theta\\right),  \n \\label{eq:swell_comb}\n\\end{equation}\n\n\\noindent\nwhere the two weights $ r_{\\mathrm{vis}} $ and $r_{\\mathrm{tur}}$ are defined from \na modified  air-sea boundary layer significant Reynolds number $\\mathrm{Re} = 2\nu_{\\mathrm{orb},s} H_s / \\nu_{a}$ \n\n\\begin{eqnarray}\n r_{\\mathrm{vis}} &=& 0.5 (1- \\tanh((\\mathrm{Re}-\\mathrm{Re}_{c})/s_7), \\\\\n r_{\\mathrm{tur}}&=& 0.5 (1+ \\tanh((\\mathrm{Re}-\\mathrm{Re}_{c})/s_7) .\n\\end{eqnarray}\nThe significant surface orbital velocity is defined by\n\\begin{equation} u_{\\mathrm{orb},s} = 2 \\left [  \\int \\!\\!\\!\\! \\int\n      \\sigma^3 \\: N(k,\\theta) \\: dk d\\theta \\right ] ^{1/2}\n      \\: . \\label{eq:ub_orbs} \\end{equation}\n\n\\noindent \nThe first equation (\\ref{eq:Dore}) is the linear viscous decay by\n\\cite{art:Dore78}, with $\\nu_a$ the air viscosity and $s_5$ is an $O(1)$\ntuning parameter. A few tests have indicated that a threshold Re$_{c}=2 \\times\n10^5 \\times (4~\\mathrm{m}/H_s)^{(1-s_6)}$ provides reasonable result with\n$s_6=0$, although it may also be a function of the wind speed, and we have no\nexplanation for the dependence on $H_s$.  With $s_6=1$, a constant threshold\nclose to $2 \\times 10^5$ provides similar -- but less accurate -- results.\n\n\n\\begin{landscape}\n\\begin{table} \n\\begin{center} \n%\\begin{tabular}{|l|c|c|c|c|c|c|c|c|} \\hline \\hline\n%Par.         &  WWATCH var.       & namelist & T471    & T471f       & T400/$I_{\\mathrm{phys}}=1$    & T405          & T500         & T601     \\\\\n%\\hline\n%  $z_u$ &  ZWND                       & SIN4 & 10.0    & 10.0        & 10.0           & 10.0          & 10.0         & 10.0        \\\\\n%  $\\alpha_0$ &  ALPHA0                & SIN4 & 0.0095  & 0.0095      & \\textbf{0.0062}& 0.0095        &  0.0095      & 0.0095      \\\\\n%  $\\beta_{\\mathrm{max}}$ & BETAMAX    & SIN4 & 1.43    &\\textbf{1.33}&\\textbf{1.42}   & \\textbf{1.55} &\\textbf{1.52} & \\textbf{2.0}\\\\\n%  $p_{\\mathrm{in}}$ &  SINTHP         & SIN4 & 2       & 2           & 2              & 2             &  2           & \\textbf{1}  \\\\\n%  $z_\\alpha$ &  ZALP                  & SIN4 & 0.006   & 0.006       & 0.008          & 0.006         &0.006         & 0.006       \\\\\n%  $s_u$ &  TAUWSHELTER                & SIN4 & 0.3     & 0.3         & \\textbf{0.25}  & \\textbf{0.0}  &\\textbf{1.0}  & \\textbf{0.5}\\\\\n%  $s_1$ &  SWELLF                     & SIN4 & 0.66    & 0.66        & 0.66           & 0.8           &  0.8         & 0.66        \\\\\n%  $s_2$ &  SWELLF2                    & SIN4 & -0.018  & -0.018      &-0.018          & -0.018        &  -0.018      &  -0.018     \\\\\n%  $s_3$ &  SWELLF3                    & SIN4 &  0.022  &  0.022      & 0.022          &\\textbf{0.015} &\\textbf{0.015}&  0.022      \\\\\n%  $\\mathrm{Re}_c$ &  SWELLF4          & SIN4 &$1.5\\X^5$& $1.5\\X^5$   & $1.5\\X^5$      &$\\mathbf{10^5}$&$\\mathbf{10^5}$&  $1.5\\X^5$ \\\\\n%  $s_5$ &  SWELLF5                    & SIN4 & 1.2     & 1.2         & 1.2            & 1.2           &  1.2         & 1.2         \\\\\n%  $s_6$ &  SWELLF6                    & SIN4 & 0.      & 0.          & \\textbf{1.0}   & 0.            & 0.           & 0.          \\\\\n%  $s_7$ &  SWELLF7                    & SIN4 &3.6$\\X^5$&3.6$\\X^5$    & 3.6$\\X^5$      &\\textbf{0.0}   &\\textbf{0.0}  & 3.6$\\X^5$   \\\\\n%  $z_r$ &  Z0RAT                      & SIN4 & 0.04    & 0.04        & 0.04           & 0.04          &  0.04        &   0.04      \\\\\n%  $z_{0,\\max}$ &  Z0MAX               & SIN4 & 1.002   & 1.002       & 1.002          &\\textbf{0.002} &  1.002       &  1.002      \\\\\n%\\hline\n%\\end{tabular}  \n\\begin{tabular}{|l|c|c|c|c|c|c|c|} \\hline \\hline\nPar.         &  WWATCH var.       & namelist & T471    & T471f       & T405          & T500         & T601     \\\\\n\\hline\n  $z_u$ &  ZWND                       & SIN4 & 10.0    & 10.0        & 10.0          & 10.0         & 10.0        \\\\\n  $\\alpha_0$ &  ALPHA0                & SIN4 & 0.0095  & 0.0095      & 0.0095        &  0.0095      & 0.0095      \\\\\n  $\\beta_{\\mathrm{max}}$ & BETAMAX    & SIN4 & 1.43    &\\textbf{1.33}& \\textbf{1.55} &\\textbf{1.52} & \\textbf{2.0}\\\\\n  $p_{\\mathrm{in}}$ &  SINTHP         & SIN4 & 2       & 2           & 2             &  2           & \\textbf{1}  \\\\\n  $z_\\alpha$ &  ZALP                  & SIN4 & 0.006   & 0.006       & 0.006         &0.006         & 0.006       \\\\\n  $s_u$ &  TAUWSHELTER                & SIN4 & 0.3     & 0.3         & \\textbf{0.0}  &\\textbf{1.0}  & \\textbf{0.5}\\\\\n  $s_1$ &  SWELLF                     & SIN4 & 0.66    & 0.66        & 0.8           &  0.8         & 0.66        \\\\\n  $s_2$ &  SWELLF2                    & SIN4 & -0.018  & -0.018      & -0.018        &  -0.018      &  -0.018     \\\\\n  $s_3$ &  SWELLF3                    & SIN4 &  0.022  &  0.022      &\\textbf{0.015} &\\textbf{0.015}&  0.022      \\\\\n  $\\mathrm{Re}_c$ &  SWELLF4          & SIN4 &$1.5\\X^5$& $1.5\\X^5$   &$\\mathbf{10^5}$&$\\mathbf{10^5}$&  $1.5\\X^5$ \\\\\n  $s_5$ &  SWELLF5                    & SIN4 & 1.2     & 1.2         & 1.2           &  1.2         & 1.2         \\\\\n  $s_6$ &  SWELLF6                    & SIN4 & 0.      & 0.          & 0.            & 0.           & 0.          \\\\\n  $s_7$ &  SWELLF7                    & SIN4 &3.6$\\X^5$&3.6$\\X^5$    &\\textbf{0.0}   &\\textbf{0.0}  & 3.6$\\X^5$   \\\\\n  $z_r$ &  Z0RAT                      & SIN4 & 0.04    & 0.04        & 0.04          &  0.04        &   0.04      \\\\\n  $z_{0,\\max}$ &  Z0MAX               & SIN4 & 1.002   & 1.002       &\\textbf{0.002} &  1.002       &  1.002      \\\\\n\\hline\n\\end{tabular}\n\n\n\n \\end{center}\n\\caption{Parameter values for T471, T471f, T405, T500, and T601 source \nterm parameterizations that can be reset via the {\\F SIN4} namelist. \nPlease note that the names of the variables only apply to the namelists. In the\nsource term module the names are slightly different, with a doubled first\nletter, in order to differentiate the variables from the pointers to these\nvariables, and the SWELLFx are combined in one array SSWELLF. Values highlighted in bold are\ndifferent from the default values set by ww3\\_grid.} \\label{tab:ST4_parSIN}\n\\end{table}\n\\end{landscape}\n\nTEST471 generally provides the best results at global scale when using ECMWF winds,\nwith the only serious problem being a low bias for $H_s > 8$~m.  TEST451f\ncorresponds to a retuning for CSFR wind reanalysis from NCEP/NCAR\n\\citep{art:CFSRR10}, and has almost no bias all the way to $H_s =\n15$~m. Simulations and papers prepared before March 2012, used slightly\ndifferent values, {\\it e.g.} TEST441 and TEST441f can be recovered by setting SWELLF7 to 0, and \nTEST471 also used $s_u=1$ and a few other adjustements (see manual of version 4.18).\nTEST405 is slightly superior for short fetches, and TEST500 is intermediate in\nterms of quality but it also includes depth-induced breaking in the same\nformulation, and thus may be more appropriate for depth-limited conditions.\n\n\nEq. (\\ref{eq:swell_turb}) is a parameterization for the\nnonlinear turbulent decay. When comparing model results to observations, it\nwas found that the model tended to underestimate large swells and overestimate\nsmall swells, with regional biases. This defect is likely due, in part, to\nerrors in the generation or non-linear evolution of theses swells. However, it\nwas chosen to adjust $f_e$ as a function of the wind speed and direction,\n\n\\begin{equation}\nf_e = s_1 f_{e,GM} + \\left[\\left|s_3\\right| + s_2 \\cos\n(\\theta-\\theta_u)\\right]u_\\star / u_{\\mathrm{orb}},\\label{fevar}\n\\end{equation}\n\n\\noindent \nwhere $f_{e,GM}$ is the friction factor given by Grant and Madsen's\n(1979)\\nocite{art:GM79} theory for rough oscillatory boundary layers without a\nmean flow, using a roughness length adjusted to $r_z$ times the roughness for\nthe wind $z_1$. The coefficient $s_1$ is an $O(1)$ tuning parameter, and the\ncoefficients $s_2$ and $s_3$ are two other adjustable parameters for the\neffect of the wind on the oscillatory air-sea boundary layer. When $s_2 < 0$,\nwind opposing swells are more dissipated than following swells. Further, if\n$s_3 > 0$, $\\cS_{out}$ is applied to the entire spectrum and not just the\nswell.\n\n\n\\vsssub\n\\textbf{Wave breaking and ocean turbulence effects} \n\\vsssub\n\n\nThe dissipation term is parameterized from the wave spectrum saturation, following the general ideas of \\cite{art:Phi85}.\n%which were initially explored in a numerical modeling framework by \\cite{art:AB03}. \nThe saturation spectrum is \n\\begin{equation}\nB\\left(k,\\theta\\right)= \\sigma k^3  N(k,\\theta) \\label{defB},\n\\end{equation}\nand corresponds to a dimensionless form of the surface elevation spectrum. In general, going from the spectral space to the physical space requires \nintegrating the saturation over a finite spectral band in wavenumber and direction to compute the breaking probability \nand then deconvolve this integral to obtain a spectral dissipation rate. Because such operations would be too time consuming we have \nimplemented three approaches. One uses on integration over directions only \\citep{art:Aea10}, while the second uses an integration  over frequency \nbands \\citep{Filipot&Ardhuin2012}, and the last actually uses the local value of $B$ without integration at all. Using one or the other version activated by the namelist parameter {\\F  SDSBCHOICE  }.\n\nBecause the directional wave spectra were too narrow when using a\nsaturation spectrum integrated over the full circle \\citep{art:AL06},\n\\citet{art:Aea10} restricted over a sector of half-width $\\Delta_\\theta$,\n\\begin{equation}\nB'\\left(k,\\theta\\right)=\n\\int_{\\theta-\\Delta_\\theta}^{\\theta+\\Delta_\\theta} \\sigma k^3 cos^{\\mathrm{sB}}\\left(\\theta-\n\\theta^{\\prime}\\right) N(k,\\theta^{\\prime}) \\mathrm d\n\\theta^{\\prime} \\label{defBofkprime}.\n\\end{equation}\nAs a result, a sea state with two systems of same energy but opposite\ndirection will typically produce less dissipation than a sea state with all\nthe energy radiated in the same direction.\n\nBased on recent analysis by \\cite{Guimaraes2018} and \\cite{Peureux&al.2019}, this saturation is enhanced by a factor $M_L$ that represents \nthe effect of long waves on short waves \n\\begin{equation}\nM_l(k,\\theta)=1+M_\\theta \\sqrt{\\mathrm{mss}(k,\\theta)} + N_\\theta \\sqrt{\\mathrm{nss}(k,\\theta)} \\label{defFACSAT}.\n\\end{equation}\nwhere $M_\\theta$ is twice the modulation transfer function for short wave steepness, with \n$M_\\theta=8$ when following the simplified theory by \\cite{art:LHS60} and using the root mean square enhancement of $B$ over a \nlong wave cycle. $N_\\theta$ is an additional straining factor due to the instability of the wave action envelope of short waves \npropagating in the direction close to that of the long wave \\citep{Peureux&al.2019}. The squared slopes $\\mathrm{mss}(k,\\theta)$ is \nthe mean square slope in direction $\\theta$, wheras $\\mathrm{nss}(k,\\theta)$ is a slope of long waves propagating in a narrow window $\\pm \\delta_\\theta$, \naround the short wave direction $\\theta$.\n\nWe finally define our dissipation term as the sum of the saturation-based term\nand a cumulative breaking term $S_{\\mathrm{bk,cu}}$,\n\\begin{eqnarray}\n\\cS_{ds}(k,\\theta)& =&  \\sigma\n \\frac{C_{\\mathrm{ds}}^{\\mathrm{sat}}}{B^2_r} \\left[ \\delta_d\n\\max\\left\\{ M_l(k,\\theta) B\\left(k\\right) -\nB_r,0\\right\\}^2 \\right.\n\\nonumber \\\\\n  & & +  \\left(1-\\delta_d \\right) \\left. \\max\\left\\{ M_L(k,\\theta) B'\\left(k,\\theta \\right)- B_r\n ,0\\right\\}^2\\right]N(k,\\theta)  \\nonumber \\\\\n & & + \\cS_{\\mathrm{bk,cu}}(k,\\theta) + \\cS_{\\mathrm{turb}}(k,\\theta) \\label{Sds_all}.\n\\end{eqnarray}\nwhere\n\\begin{equation}\nB\\left(k \\right)=\\max\\left\\{B'(k,\\theta), \\theta \\in [0,2\n\\pi[\\right\\} \\label{defBof}.\n\\end{equation}\nThe combination of an isotropic part (the term that multiplies $ \\delta_d$)\nand a direction-dependent part (the term with $1-\\delta_d$) was intended to\nallow some control of the directional spread in resulting spectra.\n\nThe cumulative breaking term $\\cS_{\\mathrm{bk,cu}}$ represents the smoothing\nof the surface by big breakers with celerity $C'$ that wipe out smaller waves\nof phase speed $C$. Due to uncertainties in the estimation of this effect in\nvarious observations, we use the theoretical model of\n\\cite{art:Aea09}. Briefly, the relative velocity of the crests is the norm of\nthe vector difference, $\\Delta_C =\\left|\\mathbf{C}-\\mathbf{C}'\\right|$, and\nthe dissipation rate of short wave is simply the rate of passage of the large\nbreaker over short waves, i.e. the integral of $\\Delta_C \\Lambda(\\mathbf{C})\nd\\mathbf{C}$, where $\\Lambda (\\mathbf{C}) d\\mathbf{C}$ is the length of\nbreaking crests per unit surface that have velocity components between $C_x$\nand $C_x+dC_x$, and between $C_y$ and $C_y+dC_y$ \\citep{art:Phi85}.  Here\n$\\Lambda$ is inferred from breaking probabilities. Based on Banner et\nal. (2000, figure 6, $b_T=22\n\\left(\\varepsilon-0.055\\right)^2$)\\nocite{art:BBY00}, and taking their\nsaturation parameter $\\varepsilon$ to be of the order of $1.6\n\\sqrt{B'(k,\\theta)}$, the breaking probability of dominant waves is\napproximately\n\\begin{equation}\nP=56.8\\left(\\max\\{\\sqrt{B'(k,\\theta)}-\\sqrt{B'_r},0\\}\\right)^2.\\label{PBanner}\n\\end{equation}\nHowever, because they used a zero-crossing analysis, for a given wave scale,\nthere are many times when waves are not counted because the record is\ndominated by another scale: in their analysis there is only one wave at any\ngiven time.  This tends to overestimate the breaking probability by a factor\nof 2 \\citep{art:FAB10}, compared to the present approach in which it is \nconsidered that several waves (of different scales) may be present at the same place and\ntime. This effect is corrected simply dividing $P$ by 2.\n\n\nWith this approach the spectral density of crest length (breaking or not) per\nunit surface $l(\\mathbf{k})$ such that $\\int l(\\mathbf{k}) \\mathrm{d}k_x\n\\mathrm{d}k_y$, we take\n\\begin{equation}\nl(\\mathbf{k})= 1/(2\\pi^2 k),\n\\end{equation}\nand the spectral density of breaking crest length per unit surface is\n$\\Lambda(\\mathbf{k})=l(\\mathbf{k})P(\\mathbf{k})$.  \n\n\nFinally the last option for the ST4 implementation of a saturation-based dissipation is as generalization \nof the parameterization by \\citet{Romero2019}, giving some flexibility in the definition of the modulation \nterm, this is activated by setting  {\\F  SDSBCHOICE  = 3}. In this case the  breaking crest density for wavenumber vector  \n$\\mathbf{k}$ is a function of the saturation only for the same wavenumber, $B(\\mathbf{k})$, with no integration in direction \nor frequency (which would be problematic if applied ot monochromatic wave spectra), but a strong modulation $M_L$  by long waves\nand a wind-dependent correction $M_W$\n\\begin{equation}\n\\Lambda (\\mathbf{k}) = \\frac{1}{k} \\exp \\left(-\\frac{B_{\\mathbf{r}}}{M_l(\\mathbf{k})  B(\\mathbf{k})}\\right) M_L(\\mathbf{k}) M_W(k).\n\\end{equation}\nwhere the wind factor is, \n\\begin{equation}\n M_W(k)=\\left( 1+ D_W  \\max(1,k/k_0) \\right) / (1+D_W),\n\\end{equation}\nwhere $k_0=g (3/ 28 u_\\star)^2$, and $D_W$ was adjusted to 0.9 when using the DIA, and $D_W=2$ for the exact nonlinear interaction.\nThe long wave modulation is either applied to $B$ (if $N_\\theta > 0$) and takes the form $ M_l(k,\\theta)$ given above, \nor, as done in \\cite{Romero2019} the modulation is applied to  $\\Lambda$ and takes the form, \n\\begin{equation}\n M_L(k,\\theta)=\\left( 1+ M_\\Lambda \\sqrt{\\mathrm{mss}'(k,\\theta)}  \\right)^{1.5}.\n\\end{equation}\nIn that expression, the cumulated slope $\\mathrm{mss}'$ is either $\\mathrm{mss}(k,\\theta)$ or, if $N_\\theta=0$, it is forced to have a $\\cos^2 (\\theta-\\theta_w)$ variation, \nwith $\\theta_w$ the direction of the mean dominant waves (which is independant of $k$). In \\cite{Romero2019} this strong $\\cos^2$ directional dependency of $\\Lambda$ is key for producing \nstrong bimodal spectra, and it may be a compensation for the isotropic dissipation rate. Indeed, the full source term for {\\F  SDSBCHOICE  = 3} reads \n\\begin{eqnarray}\n\\cS_{ds}(k,\\theta)=  \\frac{C_{\\mathrm{ds}}^{\\mathrm{sat}} (\\sqrt{B(k)}-\\sqrt{B_T} )^2.5}{g^2} \\Lambda (k,\\theta) c^5 + \\cS_{\\mathrm{bk,cu}}(k,\\theta) + \\cS_{\\mathrm{turb}}(k,\\theta) \\label{Sds_all}. \\nonumber \\\\\n\\end{eqnarray}\nwhere it should be noted that the saturation used in the dissipation rate $b=C_{\\mathrm{ds}}^{\\mathrm{sat}} (\\sqrt{B(k)}-\\sqrt{B_T} )^2.5/{g^2}$ is integrated over direcitons. and uses a true threshold $B_T$ that is different from the $B_r$ in the expression of $\\Lambda$. \nAlso, the generalization of \\cite{Romero2019} allows to use a modulation of $B$ or $\\Lambda$ and offers different options for the directional distribution of this modulation. Also, this breaking term can be combined with the cumulative term of \\cite{art:Aea10} and the wave-turbulence interaction term of \\citet{art:AJ06}. \n\nFor all three choices of {\\F SDSBCHOICE}, the additional cumulative and wave-turbulence interaction terms are computed in the same way. \nAssuming that any breaking\nwave instantly dissipates all the energy of all waves with frequencies higher\nthan a factor $r_{\\mathrm{cu}}$ or more, the cumulative dissipation rate is\nsimply given by the rate at which these shorter waves are taken over by larger\nbreaking waves, times the spectral density, namely \n\\begin{equation}\n\\cS_{\\mathrm{bk,cu}}(k,\\theta) = -C_{\\mathrm{cu}}  N \\left(k,\\theta\\right) \\int_{f' < r_{\\mathrm{cu}} f } \\Delta_C \\Lambda(\\mathbf{k'}) \\mathrm{d\\mathbf{k'}},\n\\label{Sds_cu1}\n\\end{equation}\nwhere $r_{\\mathrm{cu}}$ defines the maximum ratio of the frequencies of long\nwaves that will wipe out short waves.  This gives the source term,\n\\begin{eqnarray}\n\\cS_{\\mathrm{bk,cu}}(k,\\theta) &=&  \\frac{-14.2 C_{\\mathrm{cu}}}{\\pi^2}  N \\left(k,\\theta\\right)\n \\nonumber \\\\\n& &\\int_0^{ r^2_{\\mathrm{cu}} k }\\int_0^{2\\pi}\n\\max \\left\\{\\sqrt{B(f',\\theta')}-\\sqrt{B_r},0\\right\\}^2\n\\mathrm{d}\\theta' \\mathrm{d}k'.\n\\label{Sds_sat_isotropic}\n\\end{eqnarray}\nWe shall take $r_{\\mathrm{cu}}=0.5$, and $C_{\\mathrm{cu}}$ is a tuning\ncoefficient expected to be of order 1, which also corrects for errors in the\nestimation of $l$.\n\n\nFinally, the wave-turbulence interaction term of \\cite{art:TB02} and \\cite{art:AJ06},\nis given by\n\n\\begin{equation}\n\\cS_{\\mathrm{ds}}^{\\mathrm{TURB}}\\left(k,\\theta\\right) = - 2\nC_{\\mathrm{turb}} \\sigma \\cos(\\theta_u - \\theta) k \\frac{\\rho_a\nu_\\star^2}{g \\rho_w}  N\\left(k,\\theta\\right) .\n\\end{equation}\n\n\\noindent\nThe coefficient $C_{\\mathrm{turb}}$ is of order 1 and can be used to adjust for\nocean stratification and wave groupiness.\n\nAll relevant source term parameters can be set via the namelists {\\F SIN4} and {\\F SDS4}\nto yield parameterizations TEST441b, TEST405, both described by\n\\cite{art:Aea10} or TEST500 described by \\cite{art:FA12} (see Tables \\ref{tab:ST4_parSIN} and \\ref{tab:ST4_parSDS}). Please note that the\nDIA constant $C$ has been slightly adjusted in TEST441b, $C=2.5\\times\n10^7$. TEST441f corresponds to a re-tuned wind input formulation when using\nNCEP/NCAR winds.\n\n\\begin{landscape}\n\\begin{table} \\begin{center} \n%\\begin{tabular}{|l|c|c|c|c|c|c|c|c|} \\hline \\hline\n%Par.                               &  WWATCH var.  & namelist  & T471        & T400/$I_{\\mathrm{phys}}=1$& T405             & T500         & T601        &  T700      \\\\\n%\\hline\n% \t\t\t\t    & SDSBCHOICE    & SDS4      &  1          &     1                     &   1              & \\textbf{2}   & 1           & \\textbf{3} \\\\  \n%%  $p$                             &  WNMEANP      & SDS4      & 0.5         & 0.5                       & 0.5              &  0.5    \\\\\n%%  $p_{\\mathrm{tail}}$             &  WNMEANPTAIL  & SDS4      & 0.5         & 0.5                   & 0.5 &  0.5 \\\\\n%  $f_{\\mathrm{FM}}$                &  FXFM3        & SDS4      & 2.5         & 2.5                       & 2.5              &\\textbf{9.9}  & 5           &  \\textbf{20} \\\\\n%                                   & SDSC1         & SDS4      & 0           & 0                         & 0                &\\textbf{1.0}  & 0           &              \\\\\n%  $C_{\\mathrm{ds}}^{\\mathrm{sat}}$ & SDSC2         & SDS4      &$-2.2\\X^{-5}$&$-2.2\\X^{-5}$              &$-2.2\\X^{-5}$     &\\textbf{0.0}  &$-2.2\\X^{-5}$& \\textbf{-3.8}   \\\\\n%  $C_{\\mathrm{ds}}^{\\mathrm{BCK}}$ & SDSBCK        & SDS4      & 0           & 0                         & 0                &\\textbf{0.185}& 0           &   \\\\\n%  $C_{\\mathrm{ds}}^{\\mathrm{HCK}}$ & SDSHCK        & SDS4      & 0           & 0                         & 0                &\\textbf{1.5}  & 0           & \\\\\n%  $\\Delta_\\theta$                  & SDSDTH        & SDS4      & 80          & 80                        & 80               & 80           &  80         & \\\\\n%  $\\delta_\\theta$                  & SDSSTRAINA    & SDS4      & 0           & 0                         & 0                & 0            & \\textbf{15} &    \\\\\n%  $M_\\theta$                       & SDSSTRAIN     & SDS4      & 0           & 0                         & 0                & 0            & \\textbf{10} &    \\\\\n%  $N_\\theta$                       & SDSSTRAIN2    & SDS4      & 0           & 0                         & 0                & 0            & \\textbf{20} & \\textbf{0}    \\\\\n%  $B_r$                            & SDSBR         & SDS4      & 0.0009      & 0.0009                    &\\textbf{0.00085}  & 0.0009       & 0.0009      & \\\\\n%  $C_{\\mathrm{cu}}$                & SDSCUM        & SDS4      & -0.40344    & \\textbf{0.0}              & \\textbf{0.0}     &-0.40344      &-0.40344     & \\\\\n%  ${\\mathrm{s_B}}$                 & SDSCOS        &SDS4       & 2.0         &  2.0                      & \\textbf{0.0}     & 2.0          & 2.0         & \\\\\n%  $B_0$                           & SDSC4         & SDS4      & 1.0         & 1.0                       & 1.0              & 1.0          & 1.0          & \\\\\n%  $p^{\\mathrm{sat}}$               & SDSP          & SDS4      & 2.0         & 2.0                       & 2.0              & 2.0          & 2.0         & \\\\\n%  $C_{\\mathrm{turb}}$              & SDSC5         & SDS4      & 0.0         & 0.0                       &  0.0             & 0.0          & \\textbf{1.0}&  \\\\\n%  $\\delta_d$                       & SDSC6         & SDS4      & 0.3         & 0.3                       &  0.3             & 0.3          &0.3          & \\\\\n%  $C$                              & NLPROP        & SNL1      & $2.5\\X^7$   & $\\mathbf{2.7\\X^7}$        &$\\mathbf{2.7\\X^7}$& $2.5\\X^7$    & $2.5\\X^7$   & \\\\\n% \\hline \\hline\n%\\end{tabular}  \n\\begin{tabular}{|l|c|c|c|c|c|c|c|} \\hline \\hline\nPar.                               &  WWATCH var.  & namelist  & T471        & T405             & T500         & T601        & T700  \\\\\n\\hline\n \t\t\t\t   & SDSBCHOICE    & SDS4      &  1          &     1            & \\textbf{2}   & 1           & \\textbf{3}  \\\\  \n  $f_{\\mathrm{FM}}$                &  FXFM3        & SDS4      & 2.5         & 2.5              &\\textbf{9.9}  & 5           & \\textbf{20} \\\\\n%                                   & SDSC1         & SDS4      & 0           & 0                &\\textbf{1.0}  & 0           &    \\\\\n  $C_{\\mathrm{ds}}^{\\mathrm{sat}}$ & SDSC2         & SDS4      &$-2.2\\X^{-5}$&$-2.2\\X^{-5}$     &\\textbf{0.0}  &$-2.2\\X^{-5}$&  \\textbf{-3.8}  \\\\\n  $C_{\\mathrm{ds}}^{\\mathrm{BCK}}$ & SDSBCK        & SDS4      &            &                   & 0.185        &             & \\\\\n  $C_{\\mathrm{ds}}^{\\mathrm{HCK}}$ & SDSHCK        & SDS4      &            &                   &  1.5         &             & \\\\\n  $\\Delta_\\theta$                  & SDSDTH        & SDS4      & 80          & 80               & 80           &  80         & \\\\\n  $\\delta_\\theta$                  & SDSSTRAINA    & SDS4      & 0           & 0                & 0            & \\textbf{15} &  0  \\\\\n  $M_\\theta$                       & SDSSTRAIN     & SDS4      & 0           & 0                & 0            & \\textbf{10} &  0  \\\\\n  $N_\\theta$                       & SDSSTRAIN2    & SDS4      & 0           & 0                & 0            & \\textbf{20} &  \\textbf{0}   \\\\\n  $B_r$                            & SDSBR         & SDS4      & 0.0009      &\\textbf{0.00085}  & 0.0009       & 0.0009      &  \\textbf{0.005}  \\\\\n  $B_r$                            & SDSBT         & SDS4      &             &                  &              &             &    0.0011     \\\\\n  $C_{\\mathrm{cu}}$                & SDSCUM        & SDS4      & -0.40344    & \\textbf{0.0}     &-0.40344      &-0.40344     & \\textbf{0.0} \\\\\n  ${\\mathrm{s_B}}$                 & SDSCOS        &SDS4       & 2.0         & \\textbf{0.0}     & 2.0          & 2.0         &     \\\\\n  $p^{\\mathrm{sat}}$               & SDSP          & SDS4      & 2.0         & 2.0              & 2.0          & 2.0         &     \\\\\n  $C_{\\mathrm{turb}}$              & SDSC5         & SDS4      & 0.0         &  0.0             & 0.0          & \\textbf{1.0}& 0.0 \\\\\n  $\\delta_d$                       & SDSC6         & SDS4      & 0.3         &  0.3             & 0.3          &0.3          & \\\\\n  $ M_W$\t\t\t   & SDSMWD\t   & SDS4      &            &                   &              &             & 0.9 \\\\\n  $ M_\\Lambda$\t\t\t   & SDSFACMTF\t   & SDS4      &            &                   &              &             & 400 \\\\\n  $C$                              & NLPROP        & SNL1      & $2.5\\X^7$   &$\\mathbf{2.7\\X^7}$& $2.5\\X^7$    & $2.5\\X^7$   & $2.5\\X^7$ \\\\\n % $p_{\\mathrm{mss}}$              &  SPMSS         & SDS4      &            &                   &             &             &  0.5 \\\\\n \\hline \\hline\n\\end{tabular}  \n\\end{center}\n\n\\caption{Same as Table \\ref{tab:ST4_parSIN}, for the {\\F SDS4} and {\\F SNL1}\nnamelists. Bold values are different from the default values set by \n ww3\\_grid. Values are omitted when the SDSBCHOICE makes them not used. Note that \\cite{Romero2019} suggests using  $ M_W=2$ when NL2 is used.\t } \\label{tab:ST4_parSDS}\n%\\botline\n\\end{table}\n\\end{landscape}\n", "meta": {"hexsha": "624ac6af8d671183fba6211cd25a67396720b91e", "size": 29260, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/eqs/ST4.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/eqs/ST4.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "WW3/manual/eqs/ST4.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.8470588235, "max_line_length": 626, "alphanum_fraction": 0.5722829802, "num_tokens": 9786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4296064019894863}}
{"text": "%!TEX program = xelatex\n% 完整编译: xelatex(cn) -> bibtex(cn) -> xelatex(cn) -> xelatex(cn) -> xelatex(en)\n\\documentclass[lang=en,11pt,a4paper,cite=numbers]{elegantpaper}\n\\usepackage{xfp}\n\\usepackage{tikz}\n\n\\title{Manifold}\n\\author{Hui Zheng}\n% \\institute{}\n\n% \\version{0.09}\n\\date{\\today}\n\n% 本文档命令\n\\usepackage{array}\n\\newcommand{\\ccr}[1]{\\makecell{{\\color{#1}\\rule{1cm}{1cm}}}}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n  The definition of Manifold.\n\\keywords{Manifold}\n\\end{abstract}\n\n\\section{Manifold\\cite{manifold}}\n  A manifold is a topological space\\ref{terms:topological-space} that is locally Euclidean (i.e., around every point, there is a neighborhood that is topologically the same as the open\\ref{terms:open-set} unit ball in $\\mathbb{R}^{n}$). To illustrate this idea, consider the ancient belief that the Earth was flat as contrasted with the modern evidence that it is round. The discrepancy arises essentially from the fact that on the small scales that we see, the Earth does indeed look flat. In general, any object that is nearly \"flat\" on small scales is a manifold, and so manifolds constitute a generalization of objects we could live on in which we would encounter the round/flat Earth problem, as first codified by Poincar$\\rm{\\acute{e}}$.\n\n  More concisely, any object that can be \"charted\" is a manifold.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.4\\textwidth]{figs/manifold.png}\n  \\caption{figs:manifold}\n  \\label{figs:manifold}\n\\end{figure}\n\n  One of the goals of topology is to find ways of distinguishing manifolds. For instance, a circle is topologically the same as any closed loop, no matter how different these two manifolds may appear. Similarly, the surface of a coffee mug with a handle is topologically the same as the surface of the donut, and this type of surface is called a (one-handled) torus\\ref{terms:torus}.\n\n  As a topological space, a manifold can be compact or noncompact, and connected or disconnected. Commonly, the unqualified term \"manifold\"is used to mean \"manifold with boundary.\" This is the usage followed in this work. However, an author will sometimes be more precise and use the term open manifold for a noncompact manifold without boundary or closed manifold for a compact manifold with boundary.\n\n  If a manifold contains its own boundary, it is called, not surprisingly, a \"manifold with boundary.\" The closed unit ball in $\\mathbb{R}^n$ is a manifold with boundary, and its boundary is the unit sphere. The concept can be generalized to manifolds with corners. By definition, every point on a manifold has a neighborhood together with a homeomorphism of that neighborhood with an open ball in $\\mathbb{R}^n$. In addition, a manifold must have a second countable topology. Unless otherwise indicated, a manifold is assumed to have finite dimension $n$, for $n$ a positive integer.\n\n  Smooth manifolds (also called differentiable manifolds) are manifolds for which overlapping charts \"relate smoothly\" to each other, meaning that the inverse of one followed by the other is an infinitely differentiable map from Euclidean space to itself. Manifolds arise naturally in a variety of mathematical and physical applications as \"global objects.\" For example, in order to precisely describe all the configurations of a robot arm or all the possible positions and momenta of a rocket, an object is needed to store all of these parameters. The objects that crop up are manifolds. From the geometric perspective, manifolds represent the profound idea having to do with global versus local properties.\n\n  The basic example of a manifold is Euclidean space, and many of its properties carry over to manifolds. In addition, any smooth boundary of a subset of Euclidean space, like the circle or the sphere, is a manifold. Manifolds are therefore of interest in the study of geometry, topology, and analysis.\n\n  A submanifold is a subset of a manifold that is itself a manifold, but has smaller dimension. For example, the equator of a sphere is a submanifold. Many common examples of manifolds are submanifolds of Euclidean space. In fact, Whitney showed in the 1930s that any manifold can be embedded in $\\mathbb{R}^N$, where $N=2n+1$.\n\n  A manifold may be endowed with more structure than a locally Euclidean topology. For example, it could be smooth, complex, or even algebraic (in order of specificity). A smooth manifold with a metric is called a Riemannian manifold, and one with a symplectic structure is called a symplectic manifold. Finally, a complex manifold with a Kähler structure is called a Kähler manifold.\n\n\\section{Topological Space\\cite{topological-space}}\n\\label{terms:topological-space}\n  A topological space, also called an abstract topological space, is a set $X$ together with a collection of open subsets $T$ that satisfies the four conditions:\n\\begin{enumerate}\n  \\item The empty set $\\emptyset$ is in $T$.\n  \\item $X$ is in $T$.\n  \\item The intersection of a finite number of sets in $T$ is also in $T$.\n  \\item The union of an arbitrary number of sets in $T$ is also in $T$.\n\\end{enumerate}\nAlternatively, $T$ may be defined to be the closed sets rather than the open sets, in which case conditions 3 and 4 become:\n\\newcounter{counter}\n\\setcounter{counter}{2}\n\\begin{enumerate}[\\thecounter.]\n  \\stepcounter{counter}\n  \\item The intersection of an arbitrary number of sets in $T$ is also in $T$.\n  \\stepcounter{counter}\n  \\item The union of a finite number of sets in $T$ is also in $T$.\n\\end{enumerate}\nThese axioms are designed so that the traditional definitions of open and closed intervals of the real line continue to be true. For example, the restriction in (3) can be seen to be necessary by considering  $\\cap_{(n=1)}^{\\infty}(-\\frac{1}{n},\\frac{1}{n})=\\{0\\}$, where an infinite intersection of open intervals is a closed set.\n\n  In the chapter \"Point Sets in General Spaces\" Hausdorff (1914) defined his concept of a topological space based on the four Hausdorff axioms (which in modern times are not considered necessary in the definition of a topological space).\n\n\\section{Open Set\\cite{open-set}}\n\\label{terms:open-set}\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.4\\textwidth]{figs/open-set.png}\n  \\caption{figs:open-set}\n  \\label{figs:open-set}\n\\end{figure}\n  Let $S$ be a subset of a metric space. Then the set $S$ is open if every point in $S$ has a neighborhood lying in the set. An open set of radius $r$ and center $\\textbf{x}_{0}$ is the set of all points $\\textbf{x}$ such that $\\left|\\textbf{x}-\\textbf{x}_{0}\\right|{\\le}r$, and is denoted $D_{r}(\\textbf{x}_{0})$. In one-space, the open set is an open interval. In two-space, the open set is a disk. In three-space, the open set is a ball.\n\n  More generally, given a topology(consisting of a set $X$ and a collection of subsets $T$), a set is said to open if it is in $T$. Therefore, while it is not possible for a set to be both finite and open in the topology of the real line(a single point is a closed set), it is possible for a more general topological set to be both finite and open.\n\n  The complement of an open set is closed set. It is possible for a set to be neither open nor closed, e.g., the half-closed interval$(0,1]$.\n\n\\section{Torus\\cite{torus}}\n\\label{terms:torus}\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figs/torus.png}\n  \\caption{figs:torus}\n  \\label{figs:torus}\n\\end{figure}\n  An (ordinary) torus is a surface having genus\\ref{terms:torus-genus} one, and therefore possessing a single \"hole\" (left figure). The single-holed \"ring\" torus is known in older literature as an \"anchor ring.\" It can be constructed from a rectangle by gluing both pairs of opposite edges together with no twists (right figure; Gardner 1971, pp. 15-17; Gray 1997, pp. 323-324). The usual torus embedded in three-dimensional space is shaped like a donut, but the concept of the torus is extremely useful in higher dimensional space as well.\n\n  In general, tori can also have multiple holes, with the term n-torus used for a torus with $n$ holes. The special case of a 2-torus is sometimes called the double torus, the 3-torus is called the triple torus, and the usual single-holed torus is then simple called \"the\" or \"a\" torus.\n\n  A second definition for $n$-tori relates to dimensionality. In one dimension, a line bends into circle, giving the 1-torus. In two dimensions, a rectangle wraps to a usual torus, also called the 2-torus. In three dimensions, the cube wraps to form a 3-manifold, or 3-torus. In each case, the $n$-torus is an object that exists in dimension $n+1$. One of the more common uses of $n$-dimensional tori is in dynamical systems\\ref{terms:torus-dynamical-systems}. A fundamental result states that the phase space trajectories of a Hamiltonian system with $n$ degrees of freedom and possessing $n$ integrals of motion lie on an $n$-dimensional manifold which is topologically equivalent to an $n$-torus (Tabor 1989).\n\n  Torus coloring of an ordinary (one-holed) torus requires 7 colors, consistent with the Heawood conjecture.\n\n  Let the radius from the center of the hole to the center of the torus tube be $c$, and the radius of the tube be $a$. Then the equation in Cartesian coordinates for a torus azimuthally symmetric about the z-axis is\n\\begin{equation}\n   \\left(c-\\sqrt{(x^{2}+y^{2})}\\right)^{2}+z^{2}=a^{2} \n\\end{equation}\nand the parametric equations are\n\\begin{equation}\n  \\begin{aligned}\n    x&=(c+a\\rm{cos}v)\\rm{cos}u\\\\\n    y&=(c+a\\rm{cos}v)\\rm{sin}u\\\\\n    z&=a\\rm{sin}v\n  \\end{aligned}\n\\end{equation}\nfor $u,v \\in [0,2pi)$. Three types of torus, known as the standard tori, are possible, depending on the relative sizes of $a$ and $c$. $c>a$ corresponds to the ring torus (shown above), $c=a$ corresponds to a horn torus which is tangent to itself at the point (0, 0, 0), and $c<a$ corresponds to a self-intersecting spindle torus (Pinkall 1986).\n\n  If no specification is made, \"torus\" is taken to mean ring torus. The three standard tori are illustrated below, where the first image shows the full torus, the second a cut-away of the bottom half, and the third a cross section of a plane passing through the z-axis.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figs/torus-types.png}\n  \\caption{figs:torus-types}\n  \\label{figs:torus-types}\n\\end{figure}\n\n  The standard tori and their inversions are cyclides. If the coefficient of $\\rm{sin}v$ in the formula for $z$ is changed to $b{\\neq}a$, an elliptic torus results.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figs/elliptic-torus.png}\n  \\caption{figs:elliptic-torus}\n  \\label{figs:elliptic-torus}\n\\end{figure}\nTo compute the metric properties of the ring torus, define the inner and outer radii by\n\\begin{equation}\n  \\begin{aligned}\n    r&{\\equiv}c-a\\\\\n    R&{\\equiv}c+a\n  \\end{aligned}\n\\end{equation}\nSolving for a and c gives\n\\begin{equation}\n  \\begin{aligned}\n    a&=\\frac{1}{2}(R-r)\\\\\n    c&=\\frac{1}{2}(R+r)\n  \\end{aligned}\n\\end{equation}\nThen the surface area of this torus is\n\\begin{equation}\n  \\begin{aligned}\n    S&=(2{\\pi}a)(2{\\pi}c)\\\\\n     &=4{\\pi}^{2}ac\\\\\n     &={\\pi}^{2}(R+r)(R-r)^{2}\n  \\end{aligned}\n\\end{equation}\nThe volume can also be found by integrating the Jacobian computed from the parametric equations of the solid,\n\\begin{equation}\n  \\begin{aligned}\n    x&=(c+r'\\rm{cos}v)\\rm{cos}u\\\\\n    y&=(c+r'\\rm{cos}v)\\rm{sin}u\\\\\n    z&=r'\\rm{sin}v\n  \\end{aligned}\n\\end{equation}\nwhich simplifies to\n\\begin{equation}\n  \\begin{aligned}\n    J&=\\left|\\frac{{\\partial}(x,y,z)}{{\\partial}(u,v,r')}\\right|=r'(c+r'\\rm{cos}v)\n  \\end{aligned}\n\\end{equation}\ngiving\n\\begin{equation}\n  \\begin{aligned}\n    V&=\\int^{2\\pi}_{0}\\int^{2\\pi}_{0}\\int^{a}_{0}r'(c+r'\\rm{cos}v)dr'dudv\\\\\n     &=2{\\pi}^{2}a^{2}c\n  \\end{aligned}\n\\end{equation}\nas before.\n\n  The moment of inertia tensor of a solid torus with mass $M$ is given by\n\\begin{equation}\n  \\begin{aligned}\n    V&=\\begin{bmatrix}\n      (\\frac{5}{8}a^{2}+\\frac{1}{2}c^{2})M & 0 & 0 \\\\\n      0 & (\\frac{5}{8}a^{2}+\\frac{1}{2}c^{2})M & 0 \\\\\n      0 & 0 & (\\frac{3}{4}a^{2}+c^{2})M\n    \\end{bmatrix}\n  \\end{aligned}\n\\end{equation}\nThe coefficients of the first fundamental form are\n\\begin{equation}\n  \\begin{aligned}\n    E&=(c+a\\rm{cos}v)^{2}\\\\\n    F&=0\\\\\n    G&=a^{2}\n  \\end{aligned}\n\\end{equation}\nand the coefficients of the second fundamental form are\n\\begin{equation}\n  \\begin{aligned}\n    e&=-(c+a\\rm{cos}v)\\rm{cos}v\\\\\n    f&=0\\\\\n    G&=-a\n  \\end{aligned}\n\\end{equation}\ngiving Riemannian metric\n\\begin{equation}\n  \\begin{aligned}\n    ds^{2}&=(c+a\\rm{cos}v)^{2}du^{2}+a^{2}dv^{2}\n  \\end{aligned}\n\\end{equation}\narea element\n\\begin{equation}\n  \\begin{aligned}\n    dA&=a(c+a\\rm{cos}v)du{\\land}dv\n  \\end{aligned}\n\\end{equation}\n(where $du{\\land}dv$ is a wedge product), and Gaussian and mean curvatures as\n\\begin{equation}\n  \\begin{aligned}\n    K&=\\frac{\\rm{cos}v}{a(c+a\\rm{cos}v)}\\\\\n    H&=-\\frac{c+2a\\rm{cos}v}{2a(c+a\\rm{cos}v)}\n  \\end{aligned}\n\\end{equation}\n(Gray 1997, pp. 384-386).\n\n  A torus with a hole in its surface can be turned inside out to yield an identical torus. A torus can be knotted externally or internally, but not both. These two cases are ambient isotopies, but not regular isotopies. There are therefore three possible ways of embedding a torus with zero or one knot.\n\\begin{figure}[!htb]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figs/ambient-isotopies.png}\n  \\caption{figs:ambient-isotopies}\n  \\label{figs:ambient-isotopies}\n\\end{figure}\n\n  An arbitrary point P on a torus (not lying in the xy-plane) can have four circles drawn through it. The first circle is in the plane of the torus and the second is perpendicular to it. The third and fourth circles are called Villarceau circles (Villarceau 1848, Schmidt 1950, Coxeter 1969, Melnick 1983).\n\n\\subsection{Genus\\cite{genus}}\n\\label{terms:torus-genus}\n  A topologically invariant property of a surface defined as the largest number of nonintersecting simple closed curves that can be drawn on the surface without separating it. Roughly speaking, it is the number of holes in a surface.\n\n  The genus of a surface, also called the geometric genus, is related to the Euler characteristic\\ref{terms:torus-euler-characteristic} $\\chi$. For a orientable surface such as a sphere (genus 0) or torus (genus 1), the relationship is\n\\begin{equation}\n  {\\chi}=2-2g\n\\end{equation}\n\n  For a nonorientable surface such as a real projective plane (genus 1) or Klein bottle (genus 2), the relationship is\n\\begin{equation}\n  {\\chi}=2-g\n\\end{equation}\n(Massey 2003).\n\n\\subsection{Euler Characteristic\\cite{euler-characteristic}}\n\\label{terms:torus-euler-characteristic}\n  Let a closed surface have genus g. Then the polyhedral formula generalizes to the Poincar$\\rm{\\acute{e}}$ formula\n\\begin{equation}\n  {\\chi}(g){\\equiv}V-E+F,\n\\end{equation}\nwhere\n\\begin{equation}\n  {\\chi}(g)=2-2g\n\\end{equation}\nis the Euler characteristic, sometimes also known as the Euler-Poincar$\\rm{\\acute{e}}$ characteristic. The polyhedral formula corresponds to the special case $g=0$.\n\n  The only compact closed surfaces with Euler characteristic 0 are the Klein bottle and torus (Dodson and Parker 1997, p. 125). The following table gives the Euler characteristics for some common surfaces (Henle 1994, pp. 167 and 295; Alexandroff 1998, p. 99).\n\\begin{table}[htbp]\n  \\centering\n  \\begin{tabular}{c|c}\n    \\hline\n    surface & $\\chi$ \\\\\n    \\hline\n    cylinder & 0 \\\\\n    double torus & -2 \\\\\n    Klein bottle & 0 \\\\\n    M$\\rm{\\ddot{o}}$bius strip & 0 \\\\\n    projective plane & 1 \\\\\n    sphere & 2 \\\\\n    torus & 0 \\\\\n    \\hline\n  \\end{tabular}\n\\end{table}\n\n  In terms of the integral curvature of the surface $K$,\n\\begin{equation}\n  {\\iint}Kda=2{\\pi}{\\chi}\n\\end{equation}\nThe Euler characteristic is sometimes also called the Euler number. It can also be expressed as\n\\begin{equation}\n  {\\chi}=p_{0}-p_{1}+p_{2}\n\\end{equation}\nwhere $p_i$ is the ith Betti number of the space.\n\n\\subsection{Dynamical Systems\\cite{dynamical-systems}}\n\\label{terms:torus-dynamical-systems}\n  A means of describing how one state develops into another state over the course of time. Technically, a dynamical system is a smooth action of the reals or the integers on another object (usually a manifold). When the reals are acting, the system is called a continuous dynamical system, and when the integers are acting, the system is called a discrete dynamical system. If $f$ is any continuous function, then the evolution of a variable $x$ can be given by the formula\n\\begin{equation}\n  x_{n+1}=f(x_{n})\n\\end{equation}\nThis equation can also be viewed as a difference equation\n\\begin{equation}\n  x_{n+1}-x_{n}=f(x_{n})-x_{n}\n\\end{equation}\nso defining\n\\begin{equation}\n  g(x){\\equiv}f(x)-x\n\\end{equation}\ngives\n\\begin{equation}\n  x_{n+1}-x_{n}=g(x_{n})*1\n\\end{equation}\nwhich can be read \"as $n$ changes by 1 unit, $x$ changes by $g(x)$.\" This is the discrete analog of the differential equation\n\\begin{equation}\n  x'(n)=g(x(n))\n\\end{equation}\n\n%\\nocite{*}\n\\bibliography{ref/refs}\n\n\\end{document}\n", "meta": {"hexsha": "29d783c079f1c8ffdc78a29ef66ccfc3d66bf6e3", "size": 17046, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/study-report/manifold/report.tex", "max_stars_repo_name": "Fassial/pku-intern", "max_stars_repo_head_hexsha": "4463e7d5a5844c8002f7e3d01b4fadc3a20e2038", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/study-report/manifold/report.tex", "max_issues_repo_name": "Fassial/pku-intern", "max_issues_repo_head_hexsha": "4463e7d5a5844c8002f7e3d01b4fadc3a20e2038", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/study-report/manifold/report.tex", "max_forks_repo_name": "Fassial/pku-intern", "max_forks_repo_head_hexsha": "4463e7d5a5844c8002f7e3d01b4fadc3a20e2038", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.7728706625, "max_line_length": 743, "alphanum_fraction": 0.7332512026, "num_tokens": 5087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4295341965383307}}
{"text": "% !TeX root = ../main.tex\n\\section{Basic Narrowing}\nWe now study a restricted form or narrowing, called basic narrowing. It was introduced by Hullot on his famous paper \\textit{Canonical Forms and Unification} (\\cite{hullot:cfunif}). Intuitively, basic narrowing makes a restriction on the possible positions a redex can be contracted. The idea is that one can not narrow positions that were introduced by some other narrowing substitution. Hullot shows in \\cite{hullot:cfunif} that basic narrowing is still complete for $E$-unification problems such that $E$ can be represented by a convergent term rewrite system $\\trs$.\n\nThis restriction was motivated by the very large search space of standard narrowing. The search space for narrowing is quite large in applications and this is a step back when solving equations on \\textit{resolutions steps}\\footnote{We study some applications of narrowing in solving SLD-resolution later in the report.} (based on narrowing) and automated reasoning. For example, in Example \\ref{example:app-concat-standard-narrowing} the search space is a infinite set.\n\nTo ease the exposition and focusing the attention only on solving equations making clear the role of TRS in reductions, we temporally abandon the transformation rules approach. We return to this approach later when considering improvements of basic narrowing.\n\nWe do this by assuming that $\\trs$ contain the additional rewrite rule $eq(x,x) \\contr true$ and consider terms of the following form:\n\\begin{itemize}\n\t\\item terms that do not contain any occurrences of $eq$ and $true$\n\t\\item terms $eq(s,t)$ with $s,t$ satisfying the previous condition\n\t\\item the constant $true$\n\\end{itemize}\nTerms of the second form are called goals. It should be noted that confluence, completeness and semi-completeness are retained under the addition of the rule $eq(x,x) \\contr true$.\n\n\\begin{definition}\n\t\\begin{enumerate}\n\t\t\\item Let $t_1 \\narrow_{[p_1, l_1 \\contr r_1, \\sigma_1]} t_2 \\narrow_{[p_2, l_2 \\contr r_2, \\sigma_2]} \\cdots \\narrow_{[p_{n-1}, l_{n-1} \\contr r_{n-1}, \\sigma_{n-1}]} t_n$ be a narrowing derivation. Define sets of positions $B_1, \\cdots, B_n$ inductively as follows:\n\t\t      \\begin{align*}\n\t\t\t      B_1     & = \\basicPos{t_1}                                            \\\\\n\t\t\t      B_{i+1} & = \\mathbb{B}(B_i, p_i, r_i) \\qquad \\text{for } 1 \\leq i < n\n\t\t      \\end{align*}\n\t\t      Where $\\mathbb{B}(B_i, p_i, r_i) := (B_i \\setminus \\{ q \\in B_i \\mid p_i \\leq q \\}) \\cup \\{ p_iq \\mid q \\in \\basicPos{r_i} \\}$. Positions in $B_i$ are referred to as basic positions and positions in $\\basicPos{t_i} \\setminus B_i$ are called non-basic positions. Call the above narrowing derivation basic if $p_i \\in B_i$ for $1 \\leq i < n$.\n\t\t\\item A rewrite sequence\n\t\t      $$t_1 \\contr_{[p_1, l_1 \\contr r_1, \\sigma_1]} t_2 \\contr_{[p_2, l_2 \\contr r_2, \\sigma_2]} \\cdots \\contr_{[p_{n-1}, l_{n-1} \\contr r_{n-1}, \\sigma_{n-1}]} t_n$$\n\t\t      is based on a set of positions $B_1 \\subseteq \\basicPos{t_1}$ if $p_i \\in B_i$ for $1 \\leq i < n$ with $B_2, \\dots, B_n$ defined as above.\n\t\\end{enumerate}\n\\end{definition}\n\nNow the problem is to prove the completeness of $E$-unification based on basic narrowing. The strategy is still the same: lift basic $\\contr$-derivations to basic $narrow$-derivations by using the lifting lemma. To complete this task one needs to prove $\\contr$-derivations are basic before they are lifted by lifting lemma. To complete this task, Hullot asserts in \\cite{hullot:cfunif} the following Lemma, (Lemma 3 in his paper).\n\n\\begin{lemma}[Hullot, Lemma 3]\n\tLet $t = s\\sigma$ with some normalised substitution $\\sigma$. Every $\\contr$-reduction from $t$ is based on $\\basicPos{s}$.\n\\end{lemma}\n\n\\begin{example}[\\cite{10.1007/3-540-51564-X_51} Example 3]\\label{example:hullot-counter-ex}\n\tLet $\\trs = \\{ f(x,b) \\contr g(x), a \\contr b \\}$. We can see that a reduction sequence\n\t$$f(a,b) \\contr f(b,b) \\contr g(b)$$\n\tis based on $\\basicPos{t}$, but\n\t$$f(a,b) \\contr g(a) \\contr g(b)$$\n\tis not.\n\\end{example}\n\nHowever, the second sequence in Example \\ref{example:hullot-counter-ex} does not satisfy the Hullot assertion. Therefore, his proof for completeness of basic narrowing does not work.\n\nIn the first sequence of Example \\ref{example:hullot-counter-ex}, only innermost redexes are contracted. On the other hand, in the second one $f(a,b)$ is selected and it is not an innermost redex since it contains the redex $a$ as subterm. This selection makes a counterexample for Lemma 3 in Hullot paper.\n\nIn general, when ones construct a basic reduction sequence from a term $t$ to $\\trsNF{t}$, the terms introduced by the substitution at each reduction need to be in normal form because they may not be selected as redexes. From these considerations, Yamamoto (\\cite{10.1007/3-540-51564-X_51}) made the suggestion that the innermost occurrence should essentially owe to the completeness of basic narrowing.\n\n\\begin{definition}\n\tAn innermost redex does not contain (as a subterm) any other redexes. In an innermost reduction sequence, only innermost redexes are contracted.\n\\end{definition}\n\nNow, with the innermost selection of redexes we can guarantee that reductions sequence is basic.\n\n\\begin{proposition}\\label{proposition:innermost-based-on-t}\n\tLet $\\trs$ be a TRS and $\\sigma$ a normalised substitution. Every innermost reduction sequence starting from $t\\sigma$ is based on $\\basicPos{t}$.\n\t\\begin{proof}\n\t\tThe proof is by induction on the length of the reduction. For the base case suppose we have a sequence\n\t\t$$ t\\sigma = t_1 \\contr_{[p_1, l_1 \\contr r_1, \\sigma_1]} t_2 $$\n\t\tWe need to show that $p_1 \\in B_1 = \\basicPos{t_1}$. It follows that any redex of $t_1$ must be in $\\basicPos{t_1}$ since $\\sigma$ is a normalised substitution.\n\t\tNow consider the reduction of length $n$ starting from $t_1$, that is,\n\t\t$$t \\sigma = t_1 \\contr_{[p_1, l_1 \\contr r_1, \\sigma_1]} t_2 \\contr_{[p_2, l_2 \\contr r_2, \\sigma_2]} \\cdots \\contr_{[p_{n-1}, l_{n-1} \\contr r_{n-1}, \\sigma_{n-1}]} t_n$$\n\t\tBy induction on $i$ we must show that $\\restr{p_i}{p}$ is a normal form for all $p$ in $\\pos{t_i}\\setminus B_i$ for $1 \\leq i \\leq n$. Suppose the statement holds for $i = 1, \\dots, m$ and let $p \\in \\pos{t_{m+1}} \\setminus B_{m+1}$. There are two possible cases: $\\parPos{p}{p_m}$ or $p_m \\leq p$. Note that the case $p < p_m$ is impossible since this would imply $p \\in B_{m+1}$, because $B_m$ is closed under prefix and $p_m \\in B_m$.\n\t\t\\begin{enumerate}\n\t\t\t\\item If $\\parPos{p}{p_m}$ then $p \\notin B_m$ by construction. So $p \\in \\pos{t_m} \\setminus B_m$ and $\\restr{t_{m+1}}{p} = \\restr{t_m}{p}$ and the induction hypothesis give us the result.\n\t\t\t\\item Suppose $p_m \\leq p$, then there exists positions $q \\in \\varPos{r_m}$ and $q'$ such that $p = p_m q q'$ (otherwise, $p \\in B_{m+1})$. Hence\n\t\t\t      $$\\restr{t_{m+1}}{p} = \\restr{r_m\\sigma_m}{qq'} = \\restr{x\\sigma_m}{q'}$$\n\t\t\t      where $x$ is a variable in $r_m$ at position $q$. So $\\restr{t_{m+1}}{p}$ is a proper subterm of $l_m\\sigma_m$ and since $t_m \\contr_{[p_m, l_m \\contr r_m, \\sigma_m]}t_{m+1}$ is a innermost reduction step $\\restr{t_{m+1}}{p}$ is a normal form.\n\t\t\\end{enumerate}\n\t\\end{proof}\n\\end{proposition}\n\nIf $\\trs$ is convergent, then $\\trs$ has the property that there exists an innermost reduction sequence from every term $t$ to its normal form $\\trsNF{t}$. However, this is not true in general. In what follows we work under the hypothesis that $\\trs$ satisfy this property.\n\n\\begin{definition}\n\tA TRS $\\trs$ is \\textit{normalising with innermost reductions} if for every term there exists an innermost reduction sequence to its normal form.\n\\end{definition}\n\n\\begin{theorem}\n\tIf $\\trs$ is confluent and \\textit{normalising with innermost reductions} then basic narrowing is complete for $\\trs$-unification problems.\n\t\\begin{proof}\n\t\tSuppose that $s\\sigma \\eqUnif{\\trs} t\\sigma$. Let $\\trsNF{\\sigma}$ be the normal form of $\\sigma$. Notice that $\\sigma \\eqUnif{\\trs} \\trsNF{\\sigma}$ and $\\trsNF{\\sigma} \\eqUnif{\\trs} t\\trsNF{\\sigma}$. Confluence of $\\trs$ yields the joinability of $s\\trsNF{\\sigma}$ and $t \\trsNF{\\sigma}$. Hence there exists a rewrite sequence $eq(s,t)\\trsNF{\\sigma} \\stc true$. We may assume that this reduction is innermost, since $\\trs$ is normalising with innermost reduction.\n\n\t\tBy the above proposition, this reduction is based on $\\basicPos{eq(s,t)}$. Now by the lifting lemma we can lift this $\\contr$-derivation to a narrowing derivation $eq(s,t) \\narrow_{\\gamma}^{*} true$ (considering $V = \\vars{s,t}$) such that in each step we use the same rewrite rules at the same positions. It follows that the narrowing derivation $eq(s,t) \\narrow_\\gamma^* true$ is basic and based on $B_1 = \\basicPos{eq(s,t)}$.\n\n\t\tIt remains to show that $\\gamma \\leq^V \\trsNF{\\sigma}$. In fact, the lifting lemma give us a substitution $\\eta$ such that $\\gamma \\eta \\eqUnif{E}^V \\trsNF{\\sigma}$. So, the result follows.\n\t\\end{proof}\n\\end{theorem}\n\n\\begin{remark}\n\tIt is still possible to extend the left (right) narrowing rules from tables \\ref{table:unify_inf_rules} and \\ref{table:narrowing_inf_rules} by making only basic narrowing steps. The completeness proof for this extension is exactly as in Theorem \\ref{theorem:narrowing-completeness} with minor changes about innermost reductions.\n\\end{remark}\n\nWe can run some tests to see how basic narrowing cut-down the search space of solving equations modulo an equational theory $E$. In fact, remember from Example \\ref{example:app-concat-standard-narrowing} that the equation $eq(\\appFunc{\\appFunc{x}{y}}{z}, \\nilList)$ have an infinite search space with standard narrowing. Compare this with the figure below.\n\n\\begin{landscape}\n\t\\thispagestyle{empty}\n\t\\hrule\n\t\\begin{figure}[!ht]\n\t\t\\begin{displaymath}\n\t\t\t\\xymatrix{\n\t\t\t\t& eq(\\appFunc{\\appFunc{x}{y}}{z}, \\nilList) \\ar@{~>}[dr] \\ar@{~>}[dl] \\\\\n\t\t\t\teq(\\appFunc{x_1}{z},\\nilList) \\ar@{~>}[d] & & eq(\\appFunc{w_1 \\cdot \\appFunc{y_1}{u_1}}{z}, \\nilList) \\ar@{~>}[d]\\\\\n\t\t\t\teq(x_2,\\nilList) \\ar@{~>}[d] & & eq(\\appFunc{w_1 \\cdot x_5}{z}, \\nilList) \\ar@{~>}[d]\\\\\n\t\t\t\teq(\\nilList, \\nilList) \\ar@{~>}[d]& & eq(w_1 \\cdot \\appFunc{x_1}{z}, \\nilList) \\ar@{~>}[d]\\\\\n\t\t\t\ttrue & & eq(x_6, \\nilList) \\ar@{~>}[d]\\\\\n\t\t\t\t& & eq(\\nilList, \\nilList) \\ar@{~>}[d]\\\\\n\t\t\t\t& & true\n\t\t\t}\n\t\t\\end{displaymath}\n\t\t\\caption{Derivation tree for the objective $eq(\\appFunc{\\appFunc{x}{y}}{z}, \\nilList)$}\n\t\t\\label{figure:example:app:derivation-tree-basic-narrowing}\n\t\\end{figure}\n\t\\hrule\n\t\\vspace{1cm}\n\tNote that now the derivation tree is even finite.\n\\end{landscape}\n\nThe reader may ask himself when such problems have finite search spaces. Hullot, \\cite{hullot:cfunif} gives a beautiful result in this matter.\n\n\\begin{proposition}[Hullot, \\cite{hullot:cfunif} Proposition 1]\\label{proposition:narrowing-as-E-unification}\n\tLet $\\trs = \\{ l_1 \\contr r_i \\}$, $1 \\leq i \\leq n$ be a convergent term rewrite system such that any $\\narrow$-derivation issue from any of the $r_i$'s terminates. Then any $\\narrow$-derivation issue from any term terminates.\n\\end{proposition}\n\nIf the proposition above holds for $\\trs$ then the rules (1)-(8) from tables \\ref{table:unify_inf_rules} and \\ref{table:narrowing_inf_rules} give a complete finite $\\trs$-unification algorithm.\n\nIn the next section, we give a better formulation of basic narrowing by means of transformation rules on sets of equations. We also study some efficiency rules for the performance of basic narrowing. For now, let us focus on completeness results.\n\nIn \\cite{10.1007/3-540-51564-X_51} Yamamoto made the following conjecture:\n\\begin{center}\n    \\textit{Basic narrowing is complete for semi-convergent TRSs}.\n\\end{center}\nThis was conjectured to be true by many other authors. However, in 1994 Middeldorp and Hamoen in \\cite{Middeldorp1994} gave a counterexample for this conjecture.\n\nConsider the TRS\n\\begin{displaymath}\n    \\trs =\n\t\\begin{cases}\n\t\tf(x) & \\contr g(x,x)                               \\\\\n        a & \\contr b \\\\\n        g(a,b) & \\contr c \\\\\n        g(b,b) & \\contr f(a)\n\t\\end{cases}\n\\end{displaymath}\n\nIt follows that $\\trs$ is confluent and weakly normalising, hence semi-convergent. However, the goal $eq(f(a),c)$ cannot be solved by basic narrowing. The figure below shows all narrowing derivations starting from this goal. Recall that non-basic positions are marked by underline. Since the goal $eq(f(a),c)$ is variable-free, all narrowing steps are also rewrite steps. The steps marked by a star are non-basic because each of them narrows an occurrence of the term $a$ introduced by the narrowing substitution $[x / a]$.\n\\begin{figure}[!ht]\n    \\begin{displaymath}\n        \\xymatrix{\n            & eq(f(a),c)\\ar@{~>}[dr] \\ar@{~>}[dl] &  &  &  \\\\\n            eq(f(b),c) &  & eq(g(\\underline{a},\\underline{a}), c) \\ar@{~>}[dl]^{\\star} \\ar@{~>}[dr]_{\\star} &  & \\\\\n            & eq(g(b,\\underline{a}),c) \\ar@{~>}[dr]^{\\star} & & eq(g(\\underline{a},b),c) \\ar@{~>}[dl]_{\\star} \\ar@{~>}[dr] &\\\\\n            & & eq(g(b,b),c) \\ar@{~>}@/^10pc/[lluuur] & & eq(c,c) \\ar@{~>}[d]\\\\\n            & &  & & true\n        }\n    \\end{displaymath}\n    \\caption{Derivation tree for the objective $eq(f(a),c)$}\n    \\label{figure:counterexample}\n\\end{figure}\n\nNote that (from figure above) all successful derivation step passes through a marked derivation step, basic narrowing is unable to solve the normalised goal $eq(g(x,x),c)$ since the only basic narrowing step starting from $eq(g(x,x),c)$ produces the goal $eq(f(a),c)$, this follows from  $eq(g(x,x),c) \\narrow_{[x/a]} eq(f(a),c)$. In particular, basic narrowing is not complete for confluent TRS with respect to normalise substitutions, contrary to what was generally believed.\n", "meta": {"hexsha": "a3d89201ac277fb1dac67fc926f74708cb984020", "size": 13666, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/basic_narrowing.tex", "max_stars_repo_name": "deividrvale/report-narrowing", "max_stars_repo_head_hexsha": "1e3ce34a1afb5268b4307fcc9af9374d2e121a27", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/basic_narrowing.tex", "max_issues_repo_name": "deividrvale/report-narrowing", "max_issues_repo_head_hexsha": "1e3ce34a1afb5268b4307fcc9af9374d2e121a27", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/basic_narrowing.tex", "max_forks_repo_name": "deividrvale/report-narrowing", "max_forks_repo_head_hexsha": "1e3ce34a1afb5268b4307fcc9af9374d2e121a27", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.3292682927, "max_line_length": 570, "alphanum_fraction": 0.7051807405, "num_tokens": 4210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.42953418591599396}}
{"text": "\\chapter{Feasibility study using Model Observer}\n\\label{chap:model_observer}\n\nhuman and model observer performance ~\\cite{Abbey2001}\nWhen evaluating an imaging system, it is often useful to first use a model observer to compute the performance of the system.  One can optimize the imaging system by calculating its performance using the model observer for a particular task with multiple input parameters.  The best observer that can be used is the ideal observer or Bayesian observer, and its defined as the observer that utilizes all statistical information available regarding the task to maximize task performance as measured by Bayes risk or some other related measure of performance \\citep{Barrett2004}.  However this method requires us to know the exact statistical properties about our imaging system, which is next to impossible.  A much simpler observer is the Hotelling observer that only requires us to know the mean and variance of our images.  Although this sounds simple, even the Hotelling observer is extremely computationally intensive and very impractical.  So we opted to use the next best thing, the channelized Hotellinng observer,  to measure the system performance.  \nThe channels essentially approximate the Hotelling observer by a number of channels, or mathematical functions.  Different channels can be selected depending on the tasks at hand.  An advantage to use the channelized Hotelling observer is that they require less computation to calculate the covariance matrix of the observer.\n\n\\comment{\nWhat is model observers?\\\\\nwhat is it used for?\\\\\nwhat makes them special?\\\\\nwhat is an ideal observer?\\\\\nmathematical format and significance \\\\\nwhat's hotelling observer\\\\\nwhat's channelized hotelling observer\\\\\ntypes of channels\\\\ \nwhat makes them special\\\\\n}\n~\\cite{Fan2010}\n\\citep{Barrett2004}\n\n\\section{Background}\n\nprovide equation of Hotelling observer, channelized hotelling observer, channels\\\\\nwhy do I use this type of channels\\\\\nobject model\\\\\ndetector model\\\\\n\nIn x-ray imaging, the x-ray photons are exponentially attenuated when they pass through a material.  For a monochromatic incident x-ray beam, the attenuation of the x-ray depends on the attenuation coefficient of the material.  This can be expressed by \\citep{Barrett2004}\n\n\\begin{equation}\\label{eq:xrayattenutation}\n\\bar{N}_{m} = \\bar{N}_{0} \\; \\mathrm{exp} \\left[ -\\int_{0}^{\\infty} dl \\; \\mu( \\mathbf{r_{m}} - \\mathbf{ \\hat{s}_{m}} \\; l) \\right], \n\\end{equation}\nwhere $\\bar{N}_{0}$ is the mean number of x-ray photons that would strike the detector element m with no object present, $\\bf{r}_{m}$ is the 3D vector specifying the location of the detector element m, $\\bf{\\hat{s}_{m}}$ is a unit vector from the source to detector element m, and $\\mu(\\bf{r})$ is the attenuation function of the object.  This assumes all rays from the x-ray point source to the detector subtends small angles ($cos(\\theta) \\approx  1$), so $\\bar{N_{0}}$ is the same for all m.  The attenuation function of the object used for the simulation is:\n\n\\begin{equation}\\label{eq:xraymu}\n\\mu(\\mathbf{r}) = \\mu_{H_{2}O} \\; sph(\\mathbf{r} / D) + \\Delta \\mu(\\mathbf{r})\n\\end{equation}\nwhere $\\mu_{H_{2}O}$ is the attenuation coefficient of water, $\\mathbf{r}$ is a 3D vector in Cartesian coordinate, $sph(\\mathbf{r}/D)$ is a spherical function of diameter D, where $sph(\\mathbf{r}/D) = 1$ for $| \\mathbf{r} | < D/2$, and 0 otherwise.  $\\Delta \\mu(\\mathbf{r})$ is the lumpy background model used by Rolland \\citep{Rolland1992}.  The lumpy background model is essentially sum of randomly distributed yet equally sized Gaussian blobs and is given by :\n\\todo[inline]{include special properties of lumpy background?}\n\n\\begin{equation}\\label{eq:lumpybg}\n\\Delta \\mu(r) = \\sum_{j = 1}^{K} \\Delta\\mu_0 \\; \n\t\t\t\t\\mathrm{exp}( - \\frac{|\\mathbf{r} - \\mathbf{r_j}|^2}{2r_b^2})\n\\end{equation}\nwhere $\\mathbf{r_j}$ is a random vector confined to a spherical diameter $d$, $K$ is the number of Gaussian lumps in the background, $\\Delta \\mu_0$ is the amplitude of the lump, and $r_b$ is the rms radius of the Gaussian lumps.  Note that $K$ is taken from a Poisson distrubtion with mean $\\bar{K}$ and $\\mathbf{r_j}$ is taken from a uniform distribution. \n\\todo[inline]{Should I explain why, look it up, I have no idea right now?} \nThe values $\\bar{K}$ and $\\Delta \\mu_{0}$ are chosen so the mean of the lumpy background is equal to the attenuation of water ($\\mathrm{0.02 \\; cm^{-1}}$).  Using \\eqref{eq:xrayattenutation} the mean number of x-ray photons incident on the detector when $\\Delta \\mu(r) \\ll d$ is\n\n\\begin{equation}\\label{eq:xrayatten-approx}\n\\bar{N}_{m} \\approx \\bar{N}_{0m} \\{ 1 - \\int_{0}^{\\infty} dl \\;\n\\Delta \\mu (\\mathbf{r_m} - \\hat{\\mathbf{s}}_m l)\\} \\equiv\n\\bar{N}_{0m} [ 1 - \\Delta p_m  ],\n\\end{equation}\nwhere \n$\\bar{N}_{0m} \\equiv \\bar{N}_0 \\mathrm{exp} \\{ -\\mu_{H_20} \\int_{0}^{\\infty} dl \\; \n\\mathrm{sph} [(\\mathbf{r}_m - \\mathbf{s}_m)/D] \\}$ and \n$\\Delta p_m \\equiv \\int_{0}^{\\infty} dl \\; \\Delta \\mu(\\mathbf{r}_m - \\mathbf{\\hat{s}}_m l )$. Because the read noise has zero mean, we can write the projected value of the object on the detector element m in electron units as\n\n\\begin{equation}\\label{eq:g_ElectronUnit}\n\\bar{g}_{m0} = \\eta \\bar{k}\\bar{N}_{0m}[1 - \\Delta p_m].\n\\end{equation}\nThis is the conditional mean for a single realization of the lumpy background, with the data averaged over the Poisson fluctuation of the number of x-ray photons, over the photoelectron generation process, and over read noise.  \n\\section{Simulation Model}\n\n\nHow does the math works for x-ray\\\\\nthe channels used, include pictures\\\\\nwhy were these channels used\\\\\nshow geometry\\\\\nprovide the actual numbers that went into the models\\\\\n\n\n\\section{Results}\n\npictures of contrast v detail curve\\\\\nwhat do they mean?\\\\\nwhat are not accounted for in the simulation?\\\\\nprobably certain types of noise, x-ray scatter, etc\\\\", "meta": {"hexsha": "ea0e70143a7c42691b42ca948bf453b13c57a338", "size": 5888, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/chap-ModelObserver.tex", "max_stars_repo_name": "hfan36/dissertation", "max_stars_repo_head_hexsha": "5d755c96cf6cbece2c382789015e9db9ceb02da7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/chap-ModelObserver.tex", "max_issues_repo_name": "hfan36/dissertation", "max_issues_repo_head_hexsha": "5d755c96cf6cbece2c382789015e9db9ceb02da7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/chap-ModelObserver.tex", "max_forks_repo_name": "hfan36/dissertation", "max_forks_repo_head_hexsha": "5d755c96cf6cbece2c382789015e9db9ceb02da7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.5316455696, "max_line_length": 1058, "alphanum_fraction": 0.742357337, "num_tokens": 1642, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.42953418251242714}}
{"text": "% \\paragraph{Summary}\n\n\nWe have developed a novel Bayesian nonparametric model for spike sorting, and a novel faster than real-time  inference algorithm called \\smug.  \n%Our model and inference procedure incorporate certain features that previous approaches---be they nonparametric or not---lacked.  \n%Most importantly, we developed a variational Bayesian online inference scheme, that enabled faster than real-time posterior inference.  \n%Such computational efficiency is crucial for sequential experimental design \\cite{}.  \nAlthough we only provided our algorithm with streaming data, our fully Bayesian model \\smug\\ outperformed all competitor \\emph{batch} algorithms \n%(that is, algorithms that consume all the data at once). \nOur improved sensitivity and specificity seem to arise from multiple sources including (i) improved detection, (ii) accounting for correlated noise, \n(iii) capturing overlapping spikes, (iv) tracking waveform dynamics, and (v) utilizing multiple channels.  \nWhile others have developed closely related Bayesian models for clustering \\cite{WoodBla2008,wood2009}, deconvolution based techniques \\cite{Pillow2013}, time-varying waveforms \\cite{calabrese2011kalman},  \\emph{or} online methods \\cite{OSORT, Franke2010}, we are the first to our knowledge to incorporate \\emph{all} of these.\n\nAn interesting implication of our work is that it seems that our errors may be irreconcilable using merely first order methods (that \nonly consider the mean waveform to detect and cluster).  Supp.\\ Fig.\\ \\ref{fig:IC-PCA}a shows the mean waveform \n%for the true positives, missed positives, and false positives.  The means \nof the true and false positives are essentially identical, suggesting that even in the full 30-dimensional space excluding those waveforms from being \nestimates spikes would be difficult.  \nProjecting each waveform into the first two PCs is similarly suggestive,\nas the missed positives do not seem to be in the cluster of the true positives (Supp.\\ Fig. \\ref{fig:IC-PCA}b). \nThus, in future work, we will explore dynamic and multiscale dictionaries \\cite{ChenMaggioni12}, \nas well as incorporate a more rich history and stimulus dependence.  \nMoreover, although our algorithm is linear in time, the slope depends on the number of channels (see Supp.\\ Fig. \\ref{fig:timing}).  \nFortunately, embarrassingly parallel implementations of this method, using one node per multitrode, is straightforward.  \nThe addition of these features to \\smug\\ will hopefully create an enabling technology to  simultaneously measure neural activity from many thousands of neurons---while adapting the stimulus optimally---to further unlock the mysteries of the brain.\n", "meta": {"hexsha": "3e1151bbc6f9e911d5074c38c04363181fe4d70d", "size": 2689, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/discussion.tex", "max_stars_repo_name": "jovo/online-spike-sorting", "max_stars_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/discussion.tex", "max_issues_repo_name": "jovo/online-spike-sorting", "max_issues_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/discussion.tex", "max_forks_repo_name": "jovo/online-spike-sorting", "max_forks_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 103.4230769231, "max_line_length": 326, "alphanum_fraction": 0.8010412793, "num_tokens": 579, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.42953418251242714}}
{"text": "\\chapter{Statistics - Bayesian}\n\nSpectroscopy is a great starting point for Bayesian statistics to those who're interested in astronomy. This is because it has plenty of data points along the $ x $-axis (e.g., wavelength) with error-bars, and we usually fit a simple analytic function to the dataset. \n\nIn this chapter, I will show an example from a previously published data (\\href{https://ui.adsabs.harvard.edu/abs/2018ApJ...866..112G/abstract}{Greco+2018ApJ}). Another good example of this kind, with a comprehensive discussions on the prior selection, is given in Gregory P. (2005) ``Bayesian Logical Data Analysis for the Physical Sciences'' section 3.6 to 3.8.\n\nConsider you have the 1-D spectrum as in \\cref{fig:greco2018f2-rep}. The big question is this: \\textbf{How likely is that the peak is an actual line(s), not due to random noise?}\n\\begin{figure}[ht!]\n  \\centering\n  \\includegraphics[width=0.6\\linewidth]{figs/Greco2018F2-rep}\n  \\caption{The data extracted from \\href{https://ui.adsabs.harvard.edu/abs/2018ApJ...866..112G/abstract}{Greco+2018ApJ}, without Gaussian fit. Note that $ 1 \\,\\mathrm{erg/s/cm^2/\\AA} = 1 \\, \\mathrm{mW/m^2/\\AA} $. See the notebook \\texttt{Spectroscopy\\_Simulation} for the codes I used in this chapter.}\n  \\label{fig:greco2018f2-rep}\n\\end{figure}\n\n\nTo test this, let's set up hypotheses: The null hypothesis ($H_0$) is that there is no line, while the alternative hypothesis ($H_1$) is that there \\textit{is} a line\\footnote{Reminder: \\textit{the null hypothesis is what we want to reject}.}. Note that we haven't specified the properties of the line (amplitude, width, etc) yet. Then our strategy must be\n\\begin{enumerate}\n\\item We have to check which hypothesis is more likely (assuming there're only two possibilities, $ H_0 $ and $ H_1 $).\n\\item If $H_0$ is more likely, we accept the null hypothesis, i.e., ``we argue the non-existence of line in this data with certainty of xxx''.\n\\item If $H_1$ is more likely, we have to find the line properties (amplitude, width, etc) in the form of $ x \\pm dx $.\n\\end{enumerate}\nThe first is called the \\textbf{Model Selection} and the third is called the \\textbf{Parameter Estimation}. If the second is the case, things are simple: no line! That's all. Model selection is \\textit{discrete} (finite number of different hypotheses), while parameter estimation is usually \\textit{continuous}.\n\n\\section{Bayes Theorem}\n\\begin{thm}[Bayes' Theorem]\nIf $H$, $D$, and $I$ are the hypothesis, data, and prior information, respectively, Bayes' theorem states \n\\begin{equation}\\label{eq: bayes thm}\n  P(H | D, I) = \\frac{P(H|I) \\times P(D|H, I)}{P(D|I)} ~.\n\\end{equation}\nUsually it is simply put as \n\\begin{equation}\\label{eq: bayes thm propto}\n  P(H | D, I) \\propto P(H|I) \\times P(D|H, I) ~.\n\\end{equation}\n\\end{thm}\nThe \\textbf{posterior} $P(H|D, I)$ is understood as ``the probability that the hypothesis is true, given the data equals to $D$ and we have prior information $I$.'' The \\textbf{prior} $P(H|I)$ can be quite subjective, since it means ``the probability that the hypothesis is true.'' In most cases, we take either uniform prior or Jeffrey's prior (see below). The denominator, $P(D | I)  := \\int P(D | H, I) P(H|I) dH$ is understood as the normalization constant for the posterior. \n\nThe term $P(D|H, I)$ is called the \\textbf{likelihood}, and this is what we have calculated during our high school course works: \n\n\\begin{ex}[High school exam problem: calculating liklihood]\nGiven the hypothesis that a person has possibility 0.5 to win a game, what is the probability for her to win 3 games in a row?\n\nIn this case, the hypothesis is $H = (p=0.5)$, and the data $D = (\\mathrm{win~3~in~a~row})$. The prior knowledge is that ``the game rule does not change'', ``the person doesn't use faul measures to make the possibility to change over time'', etc, which are just trivial assumptions. Most importantly, we have to assume that the results of each game should be \\textit{independent}, so that we can use the multiplication law. Therefore,\n\\begin{equation*}\n  P(D|H, I) = (1/2)^3 = 1/8 ~.\n\\end{equation*}\n\nIn real scientific problems, $I$ can be something like ``the fundamental physical laws do not change over time'', ``this galaxy is spiral for sure (if you're working on rotational curves of S galaxies, you may assume your samples are definitely S, not E or Irr)'', etc.\n\\end{ex}\n\nWhen you are finding the mean of the data, it is a single parameter case, and therefore, $ H $ just means the mean value, so you can write something like this: $ P(H|D, I) = P(m|D, I) $. When you have multiple parameters, usually people denote the set of paramers as $ \\vec{\\theta} $, so $ P(H|D, I) = P(\\vec{\\theta}|D, I) $. If we're fitting the data with, say, a 3rd order polynomial with 4 parameters, we can understand that $ I $ includes ``the data is described by a 3rd order polynomial with 4 parameters''. \n\n\\section{Towards the Model Selection}\n\\subsection{Model Selection Concept}\nThe term ``odd'' is used for $ \\frac{\\mathrm{probability}}{1 - \\mathrm{probability}} $. In this case the $ P(H_1|I) / P(H_0|I) $ is called the prior odds because $ P(H_1|I) + P(H_0|I) = 1$, as there is no other possibility other than $ H_0 $ and $ H_1 $. Similarly, since $ P(D|H_0, I) + P(D|H_1, I) = 1$, the LHS is also called the posterior odds.\n\nNow come back to the original question: model selection. The model selection is done based on the \\textbf{odds ratio}:\n\\begin{equation}\\label{eq: odds ratio}\n  R := \\frac{P(H_1 | D, I)}{P(H_0 | D, I)}\n    = \\frac{P(H_1|I)}{P(H_0|I)} \\times \\frac{P(D|H_1, I)}{P(D|H_0, I)} \n    = \\mathrm{odds}(\\mathrm{prior}) \\times B_{10}~.\n\\end{equation}\nHere $ B_{10} $ is called the \\textbf{Bayes' factor}. \n\nIf $ R > 1 $, we select $H_1$ over $H_0$ and vice versa. If $R=1$, we can't give any conclusion. Equivalently, we can use $\\ln R $ and compare it with 0. This is because we frequently get extremely large or small $R$ values (e.g., $10^{-40}$), which is inappropriate for some computer programming.\n\n\n\\subsection{Prior Selection}\nThere are two major priors: uniform and Jeffreys' prior.\n\\begin{itemize}\n\\item \\textbf{Uniform prior} assumes uniform probability for the model within reasonable range. \n\\item \\textbf{Jeffreys' prior} assumes the probability proportional to the determinant of the Fisher information matrix. Simply put, for the parameters like standard deviation, if the value is small (has more information), we give more weight to it.\n\\end{itemize}\nAnother possibility is that iteratively updated prior based on the accumulated data, as sometimes used in artificial intelligence.\n\n\\begin{ex} [Uniform prior]\nConsider an emission line fitting to the 1-D spectrum. If you are sure that the line must be Gaussian with center $ \\lambda_c \\in [650, 655]\\,\\mathrm{nm} $, the uniform prior of the line center will be $ \\lambda_c \\sim \\mathcal{U}(650, 655) $, which has the pdf of $ p(\\lambda_c) = 1/5 $ for $ \\lambda_c \\in [650, 655]\\,\\mathrm{nm} $ and 0 otherwise. That is, uniform prior regards it is equally likely to have any value within the bound specified by the user.\n\\end{ex}\n\n%\\begin{ex} [Jeffereys' prior]\n%Jeffereys' prior is suitable for parameters like scatter of the data. For instance, for a set of $ N $ samples which show a Gaussian distribution of the single-valued population. An example is like this: You make multiple measurements of the standard star's magnitude, which must be a constant over the time, to understand how accurately your instrument can measure the stellar magnitude, i.e., the stability of the instrument.\n%\\end{ex}\n%That is, if the parameter is small, we give more weight to it; this is similar to the information theory which gives higher weight if a data is \"unlikely\". For this reason, we usually use Jeffrey's prior for standard deviation estimation. Quantitatively, it is $ P(A|I) = \\frac{1}{A \\log_e(75/25)}$. This is understood as the uniform prior of the log of $A$: $P(\\log_e A| I) d(\\log_e A) = \\frac{d(\\log_e A)}{\\log_e A_{max} - \\log_e A_{min}} $ $\\rightarrow P(\\log_e A| I) = \\frac{1}{A \\log_e (A_{max}/A_{min})}$ .\n\n%Since Jeffrey's prior is non-sensical when we include model of $A=0$, a **modified Jeffrey's prior** is also used: $ P(A|I) = \\frac{1}{A+A_0} \\times \\frac{1}{\\log_e \\frac{A_0+A_{max}}{A_0+A_{min}}} $. This is nothing but a parallel shift of parameters by a certain constant $A_0$. $A_0$ can be taken as a noise level, such as readout noise in our case.\n\n\n\\subsection{Likelihood Calculation}\nAssume all data values, e.g., the $ f_\\lambda $ values, are independent\\footnote{A strange thing happens on CCD sometimes maybe? If this is true, then nothing is independent. See \\href{https://ui.adsabs.harvard.edu/abs/2018PASP..130f4504B/abstract}{BooneK+18 PASP} (\\texttt{2018PASP..130f4504B}) ``A Binary Offset Effect in CCD Readout and Its Impact on Astronomical Data\n''.}. Denoting the $ i $-th pixel's value as $ D_i $, %. Applying the product rule to independent measurements,\n\\begin{equation*}\n  P(D|H, I) = P(D_1, \\cdots , D_N | H, I) = P(D_1 | H, I) \\times \\cdots \\times P(D_N | H, I) ~.\n\\end{equation*}\n\nUnder $H_0$ (no emission line), $P(D_i | H_0, I) $ is the probability to measure $D_i$ electrons when there is only the pixel noise $\\sigma_i$ (no actual line). Each pixel we have Poissonian noise which is nearly Gaussian, and sky estimation noise term, which is difficult to quantify but we usually assume it is Gaussian, and the Gaussian readout noise in standard CCD. Therefore, each pixel is assumed to have a Gaussian noise. Thus,\n\\begin{equation*}\n  P(D_i | H_0, I) = \\frac{1}{\\sqrt{2 \\pi} \\sigma_i} \\exp{ \\left ( -\\frac{(D_i - 0)^2}{2 \\sigma_r^2} \\right )} \n  \\quad\\rightarrow\\quad\n  P(D|H_0, I) =  \\prod_{i=1}^{N} P(D_i | H_0, I)\n\\end{equation*}\nThen the \\textbf{log-liklihood} is\n\\begin{equation}\\label{eq: log-l H0}\n  \\ln P(D|H_0, I)\n    = C_\\sigma\n      - \\sum_{i=1}^{N} \\frac{D_i^2}{2 \\sigma_i^2} ~,\n\\end{equation}\nwhere $ C_\\sigma := \\sum \\ln (\\sqrt{2 \\pi} \\sigma_i)^{-1} $ is a constant. Note that even the second term is a calculable constant once the data is given.\n\nFor $H_1$, we can just change the zero mean to the Gaussian line profile. Consider the best-fit line profile is described as $ g(x| \\vec{\\theta}_0) $ for $ \\vec{\\theta}_0 = (A, w, \\lambda_c) $ (amplitude, width sigma, central wavelength). Then\n\\begin{equation}\\label{eq: log-l H1}\n  \\ln P(D|H_1, I)\n    = C_\\sigma\n      - \\sum_{i=1}^{N} \\frac{(D_i - g(x_i|\\vec{\\theta}_0))^2}{2 \\sigma_i^2} \n    \\equiv C_\\sigma - \\frac{1}{2}\\chi^2\n      ~.\n\\end{equation}\nHere, $ \\chi^2 $ is the usual chi-square statistic from the data and model, because in our case, the error-bars are independent and normally distributed. Finding the best-fit parameter set, $ \\vec{\\theta}_0 $, is done by the least-square fitting (also called the $ \\chi^2 $-minimization). \n\nAlthough it is mathematically too trivial, let me put another theorem to emphasize.\n\\begin{thm}\nMaximizing (log-)likelihood is identical to minimizing $ \\chi^2 $, when the error-bars are independent and follows Gaussian.\n\\end{thm}\n\n\\subsection{Model Selection Calculation}\nNow let's do the real calculation to compare $H_0$ and $H_1$. Because I want to use amplitude rather than flux as a free paramter, the gaussian function will be $ g(x|\\vec{\\theta}_0) = A e^{-(\\lambda - \\lambda_c)^2/2w^2} $. The best fit Gaussian function to the data shown in \\cref{fig:greco2018f2-rep} is found to have the following parameters:\n\\begin{equation}\n  \\mathrm{amplitude} = 3.213 \\times 10^{-20}\n  \\quad;\\quad\n  \\lambda_c = 5039.4 \\,\\mathrm{\\AA}\n  \\quad;\\quad\n  w = 2.33 \\,\\mathrm{\\AA}\n\\end{equation}\nwith the integrated flux $ \\lg (F_\\mathrm{O_{III}} / \\mathrm{mW\\, m^{-2}}) = -15.73 $, because $ F = A \\sqrt{2\\pi w^2} $. This matches well with the original publication $ -15.7 \\pm 0.1 $. \n\nFrom the data, $ C_\\sigma = 2739.234 $. The log-likelihood of $ H_0 $ and $ H_1 $ are\n\\begin{align*}\n  \\ln P(D|H_0, I)\n    &= C_\\sigma\n      - \\sum_{i=1}^{N} \\frac{D_i^2}{2 \\sigma_i^2}\n    &&= 2720.810 \\\\\n  \\ln P(D|H_1, I)\n    &= C_\\sigma\n      - \\sum_{i=1}^{N} \\frac{(D_i - g(x_i|\\mathrm{amplitude}, \\lambda_c, w))^2}{2 \\sigma_i^2} \n    &&= 2730.136 ~.\n\\end{align*}\n\nAssume the probability of $ H_0 $ being true is the same as that of $ H_1 $ being true. The  Bayes' ratio in \\cref{eq: odds ratio} therefore becomes just a Bayes' factor:\n\\begin{equation}\n  R = B_{10} = \\frac{e^{2730.136}}{e^{2720.810}} = 1.12 \\times 10^{4} \\gg 1 ~,\n\\end{equation}\nwhich means $ H_1 $ is extremely more likely. Thus, we now believe there must be an emission line, and have to find the CI of the parameters (e.g., flux value). \n\n\n\\subsection{Model Selection with AIC, BIC}\nBut wait, is this all? No.\n\nThe pitfall of this na\\\"{i}ve approach using Bayes' ratio is that, you can minimize $ \\chi^2 $ to 0, by increasing the number of fitting parameters. When the number of free parameters is equal to the number of data points, you must be able to make a function $ f $ such that $ D_i - f(\\lambda_i) $ is always 0. Does the $ N $-parameter model a better choice than 1-parameter case, for example, if just the ratio is large? It can't be.\n\nThe ``number of paramter'' problem is not an easy thing to solve, but we have simple rule-of-thumbs: The Akaike Information Criteria, AIC, and the Bayesian Information Criteria, BIC. The derivations are not shown here, because it can become a bit lengthy while that derivation itself is not at the heart of the understanding.\n\n\\begin{thm}[Bayesian Information Criterion; BIC]\nFor the $ N (\\rightarrow \\infty) $ data points, the BIC for the model with $ n $ free parameters denoted as $ \\vec{\\theta} $ is given as\n\\begin{equation}\\label{eq: bic}\n  \\mathrm{BIC} := n \\ln N - 2 \\ln P(D|\\vec{\\theta}_0, I) = n \\ln N + \\chi^2_\\mathrm{min} - 2C_\\sigma ~,\n\\end{equation}\nwhere $ \\vec{\\theta}_0 $ is the best-fit parameter which results in the minimum $ \\chi^2 $, or maximum likelihood ($ P(D|H, I) $).\nFor the same data, comparing with two different models, the difference in the BICs is used:\n\\begin{equation}\\label{eq: dbic}\n  \\Delta \\mathrm{BIC} \n    = (n_1 - n_2) \\ln N \n      - 2 \\ln \\frac{P(D|\\vec{\\theta}_{0, 1}, I)}{P(D|\\vec{\\theta}_{0, 2}, I)}\n    = (n_1 - n_2) \\ln N \n      + (\\chi^2_\\mathrm{min, 1} - \\chi^2_\\mathrm{min, 2}) ~.\n\\end{equation}\nThe second equalities above including $ \\chi^2 $ hold only if the error-bars are independent and normally distributed.\n\nSome people prefer to define in the opposite sign and/or half of this value to remove the factor 2 in front of the log-likelihood.\n\\end{thm}\nNote that BIC is usable only if $ N \\gg n $. Also the prior distribution only affects when you find $ \\vec{\\theta} $, not when calculating the BIC. \n\nSince RafteryAE's work\\footnote{RafteryAE (1995) ``Bayesian Model Selection in Social Research'', Sociological Methodology, 25, 111}, the following criteria for choosing models are widely used:\n\n\\begin{table}[ht!]\n\\centering\n\\label{tab: bic}\n\\begin{tabular}{|c|c|c|c|c|}\n  \\hline \n  $ |\\Delta\\mathrm{BIC}| \\in $ & [0, 2] & [2, 6] & [6, 10] & 10+ \\\\ \n  \\hline \n  Evidence & Not worth more than a bare mention & Positive & Strong & Very Strong \\\\ \n  \\hline \n\\end{tabular}  \n\\end{table}\n\n\n\\begin{thm}[Akaike Information Criterion; AIC]\nFor the $ N (\\rightarrow \\infty) $ data points, the BIC for the model with $ n $ free parameters denoted as $ \\vec{\\theta} $ is given as\n\\begin{equation}\\label{eq: aic}\n  \\mathrm{AIC} := 2n - 2 \\ln P(D|\\vec{\\theta}_0, I) = 2n + \\chi^2_\\mathrm{min} - 2C_\\sigma ~,\n\\end{equation}\nwhere $ \\vec{\\theta}_0 $ is the best-fit parameter which results in the minimum $ \\chi^2 $, or maximum likelihood ($ P(D|H, I) $). \nFor the same data, comparing with two different models, the difference in AICs is used:\n\\begin{equation}\\label{eq: daic}\n  \\Delta \\mathrm{AIC} \n  = 2(n_1 - n_2) - 2 \\ln \\frac{P(D|\\vec{\\theta}_{0, 1}, I)}{P(D|\\vec{\\theta}_{0, 2}, I)}\n  = 2(n_1 - n_2) + (\\chi^2_\\mathrm{min, 1} - \\chi^2_\\mathrm{min, 2}) ~.\n\\end{equation}\nThe second equalities above including $ \\chi^2 $ hold only if the error-bars are independent and normally distributed.\n\\end{thm}\n\nAlthough I am not so familiar with hard-core statistics, it seems like there are debates about which should be preferred (BIC or AIC). BIC is known to prefer the ``true model'', if it is in our set of alternative hypotheses, with probability 1 when $ N \\rightarrow \\infty $, while AIC doesn't. On the other hand, if the data is too few (note that the difference in BIC and AIC is the $ \\ln N $ term), BIC tend to seek for the model which explains that small dataset, so it can prefer worse model which tries to explain the bad data points than AIC. \n\nNow let's calculate $ \\Delta \\mathrm{BIC} $ and $ \\Delta \\mathrm{AIC} $ for our sample data to test $ H_0 $ VS $ H_1 $. As before, $ C_\\sigma = 2739.234 $, and log-likelihoods are 2720.810 and 2730.136. Then because $ H_0 $ has no parameter and $ H_1 $ has three paramters, and $ N = 61 $,\n\\begin{align*}\n  \\Delta \\mathrm{BIC}\n    &= (0 - 3) \\ln 61 - 2 (2720.810 - 2730.136)\n    &&= 6.32 \\\\\n  \\Delta \\mathrm{AIC}\n    &= 2 (0 - 3) - 2 (2720.810 - 2730.136)\n    &&= 12.65\n\\end{align*}\nThe fact that these are positive means we should prefer the $ H_1 $, but not as strong as what we've seen from the odd's ratio.\n\n\n\\section{Towards the Parameter Estimation}\n\n\\subsection{Brute-Force}\nFrom the last section, we learned we have a clear evidence that there is a line. Then how can we estimate the line properties with uncertainties? This is the same as we did in the statistics chapter. First is the \\textbf{brute-force} fixed-grid search scheme\n\nIn the chi-square sense, what we have to do are\n\\begin{enumerate}\n\\item Calculate the chi-square statistic at each parameter space position. \n\\item Keep only those with $\\chi^2 < \\chi^2_\\mathrm{min} + \\Delta(n_\\theta, \\alpha)$ \n  \\begin{enumerate}\n  \\item [-] $\\Delta$: inverse cdf (cumulative distribution function) of $\\chi^2$ distribution.\n  \\item [-] $\\alpha$: significance level ($\\alpha = 0.6827$ for 1-sigma)\n  \\item [-] $ n_\\theta $: number of free parameters.\n  \\item [-] In python, you can do \\pyth{delta = scipy.stats.chi2.ppf(0.6827, n_param)}\n  \\end{enumerate}\n\\item These are the models ``within 1-sigma level confidence interval.''\n\\item Get the min/max of each of the parameters and set these as lower/upper limit of the parameters.\n\\item The \\textit{center} of the parameters can be obtained by simple maximum likelihood estimation, such as least-square fitting.\n\\end{enumerate}\n\nFor the 1-sigma contour of 2 parameters, $ \\chi^2 < \\chi^2_\\mathrm{min} + 2.30 $. The marginalized pdfs is usually drawn together to grasp the distribution of the parameters. If you have used chi-square statistic, you can use the fact that $ P \\propto e^{-\\chi^2/2} $. Define $ \\bar{P} =  e^{-\\chi^2/2}$. Then the normalization constant will be $ A = \\sum_{parameters} \\bar{P} $, i.e., you can use $ P = \\bar{P}/A $ as the normalized probability values.\n\nIn this example, because the authors mentioned that the $ w $ parameter is obtained from the $ \\mathrm{H\\alpha} $ fitting, I just fixed the $ w $ value as the best fit value. From zooming in the oringinal paper, I couldn't find any difference from theirs to ours. \n\n\\begin{figure}[ht!]\n  \\centering\n  \\includegraphics[width=0.7\\linewidth]{figs/Greco2018-fit}\n  \\caption{Our fitting of Gaussian curve to the emission line. The 2-D contour shows the $ \\chi^2 $ map in the 2-D parameter space. The 1-D plots show marginalized pdf from $ P = e^{-\\chi^2/2} / \\bar{P} $.}\n  \\label{fig:greco2018-fit}\n\\end{figure}\n\nIn the figure, the green vertical lines:\n\\begin{itemize}\n  \\item dashed = our best fit central wavelength\n  \\item dotted = the uncertainty range from the paper's redshift uncertainty measured from $ \\mathrm{H\\alpha} $ line ($ 1742 \\pm 19 \\,\\mathrm{km/s} $)\n  \\item Because their uncertainty is from $ \\mathrm{H\\alpha} $, which has signal much better than $ \\mathrm{O^{2+}} $, the error-bar is much smaller than ours.\n\\end{itemize}\nand the blue horizontal lines:\n\\begin{itemize}\n\\item dashed = paper's flux ($ 10^{-15.7} \\,\\mathrm{mW/m^2} $) converted to amplitude\n\\item dotted = paper's uncertainty around the paper's value.\n\\item The difference between our fit and paper's value is only 0.03 dex (maybe the authors obtained the identical value but just dropped the significance numbers)\n\\item Error bars seem slightly understimated, but in reality if we use error bar of 0.14 dex in log scale, it's similar to ours. Maybe the authors just did not care about such detailed numbers, which is understandable.\n\\end{itemize}\n\n\\subsubsection*{Notes}\nThe original paper argue that they used gaussian with flat spectrum\\footnote{From the paper: ``When fitting the [O III] $ \\lambda $5007 line, we assume a flat continuum plus a single Gaussian line profile with standard deviation given by the $ \\mathrm{H\\alpha} $ fit.''}. When I tried this, however, the best fit constant is \\texttt{-1.36e-21} , which must be a marginally visible negative shift to the fitted Gaussian, but I cannot find this by zooming in the paper's plot. Thus, I guess they may have just ignored this flat offset or set a bound that this constant must be positive, so that the best fit value is just 0.\n\n\n\\subsection{Markov Chain Monte Carlo (MCMC)}\nMarkov chain is a fancy name of ``memoryless'':\n\\begin{equation}\\label{eq: markov chain}\n  p(x_5|x_4, x_3, x_2, x_1) = p(x_5|x_4)\n\\end{equation}\nThe Monte Carlo (MC)\\footnote{Historical background adopted from \\href{https://events.mpifr-bonn.mpg.de/indico/event/30/material/slides/12.pdf}{KalinovaV's lecture note 2017 Feb}.} came from the casino ``Monte Carlo'' in Monaco. Stanislaw Ulam and John von Neumann, in 1940, wanted to find best-fit parameters to make a better nuclear weapon at the Los Alamos National Laboratory. They arrived at the idea of (now-called) Monte Carlo, but wanted it to be secret to enemies, so they chose the secret name MC, where Ulam's uncle used to play gamble. \n\nWhen you have, e.g., 7 parameters to fit 100 data points, and if the model is too complicated, the usual grid searching in the previous section is computationally impossible. Therefore, the ``hopping'' in the N-dimensional parameter space is suggested and that's MC. Currently I don't have complete plan to cover MCMC in AO class, but you may refer to many available packages from websites\\footnote{A great compilation is available \\href{https://gabriel-p.github.io/pythonMCMC/?fbclid=IwAR2hxgATmm1w-QFAjsjcrTbpOHeGV3aJKCCpSnnSuimEXLk9xtC3lpzXgo0}{here}}. I recommend you to try \\texttt{emcee} (although I used \\texttt{pymc3}, but I feel \\texttt{emcee} is more standard and safe as it's classical. \\texttt{pymc3} is too much a black box to my eyes, and my friends kind of agreed).\n\n\n% Let me assume uniform prior to all three paramters with domains $A \\in [0.1, 10]$, $\\lambda_c \\in [5030, 5050]$, and $w \\in [0.1, 5]$, and thus $P(A|I) = (1/9.9) (^\\forall A \\in [0.1, 10])$, etc. Assuming all paramters are independent, we can use product rule and\n%\\begin{equation}\n%  P(D|H_1, I) = \\int_{0.1}^{5} \\int_{5030}^{5050} \\int_{0.1}^{10} \n%                P(D | A, \\lambda_0, w, I) P(A|I) P(\\lambda_0|I) P(w|I)  dA d\\lambda_0 dw ~,\n%\\end{equation}\n%\n%or\n%$$ \\log_e P(D|H_1, I) = - \\log_e (10000) + \\log_e \\left [ \\int_{5}^{15} \\int_{590}^{610} \\int_{25}^{75} \n %               P(D | A, \\lambda_0, w, I) ~dA~d\\lambda_0~dw \\right ] ~, $$\n%with \n%$$ P(D|A, \\lambda_0, w, I) = \\left ( \\frac{1}{\\sqrt{2 \\pi} \\sigma_r} \\right )^N \n%                \\times \\exp \\left [ -\\sum_{i=1}^{N} \\frac{(D_i - E_i(A, \\lambda_0, w))^2}{2 \\sigma_r^2} \\right ] ~. $$\n%Since $H_0$ has no more parameters, we just use the previous $\\log_e P(D|H_0, I)$ formula.", "meta": {"hexsha": "d54dde9f12498c1181fe7587d86b33dc7e0f47f7", "size": 23672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Books/chaps/05_stats_spec.tex", "max_stars_repo_name": "ysBach/SNU_AOclass", "max_stars_repo_head_hexsha": "e2e364b08c2e6e129c267db9cbd76cfd0ab77527", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-03-23T06:14:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-14T01:49:51.000Z", "max_issues_repo_path": "Books/chaps/05_stats_spec.tex", "max_issues_repo_name": "ysBach/SNU_AOclass", "max_issues_repo_head_hexsha": "e2e364b08c2e6e129c267db9cbd76cfd0ab77527", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-05-04T17:21:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-24T11:41:55.000Z", "max_forks_repo_path": "Books/chaps/05_stats_spec.tex", "max_forks_repo_name": "ysBach/SNU_AOclass", "max_forks_repo_head_hexsha": "e2e364b08c2e6e129c267db9cbd76cfd0ab77527", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2020-05-10T14:19:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-14T09:18:08.000Z", "avg_line_length": 80.2440677966, "max_line_length": 780, "alphanum_fraction": 0.7084741467, "num_tokens": 7291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.585101154203231, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.4295341825124271}}
{"text": "\\pagenumbering{arabic}\n\\setcounter{page}{1}\n\n\\chapter{Introduction}\n\nThe primary topic of this thesis is to develop and numerically test a large scale implementation of an incompressible magnetohydrodynamics model. In this introductory chapter, we will first  present a description of the model problem studied. We then give a brief overview of finite element methods and Krylov subspace methods for this problem. Finally, we outline the objectives, contributions and structure of the thesis.\n\n\\section{A model problem in incompressible magnetohydrodynamics}\n\nThe area of incompressible magnetohydrodynamics (MHD)  describes the behaviour of electrically conductive incompressible fluids (liquid metals, plasma, salt water, etc) in an electromagnetic field \\cite{davidson2001introduction,le2006mathematical,muller2001magnetofluiddynamics}. MHD models couple electromagnetism and fluid dynamics. The coupling effects are due to two fundamental physical properties. Firstly, through the movement of the conductive material that induces a magnetic field which then modifies any existing electromagnetic field. Secondly, the magnetic and electric fields generate a mechanical force on the fluid known as the Lorentz force. The Lorentz force accelerates the fluid particles in the direction normal to both the electric and magnetic fields.\n\nIncompressible MHD has a number of important applications within technology and industry as well as Geophysical and Astrophysical applications. Some such applications are: electromagnetic pumping, aluminium electrolysis, the Earth's molten core and solar flares. For more applications see \\cite{muller2001magnetofluiddynamics}.\n\nIn this thesis, we are principally interested in an incompressible MHD model. This means that the electrically conductive fluid is incompressible, i.e., the mass of the fluid is conserved, and the electric resistivity of the fluid cannot be ignored. The MHD model we consider consist of two coupled fundamental equations: the incompressible Navier-Stokes equations and Maxwell's equations. We will outline the derivation of a formulation of an incompressible MHD model for a homogeneous and isotropic medium to ensure that all material parameters are constant; for full details see \\cite{armero1996long}.\n\nThe transient incompressible Navier-Stokes equations that govern incompressible fluid flow are given by:\n\\begin{subequations}\n\\label{eq:ns}\n\\begin{alignat}2\n\\rho_f\\bigg(\\frac{\\partial \\uu{u}}{\\partial t}+ (\\uu{u} \\cdot \\nabla)\\uu{u}\\bigg)- \\mu  \\, \\Delta\\uu{u} +\\nabla p &= \\uu{f}+\\uu{f}_L & \\qquad &\\mbox{in $\\Omega\\times(0,T)$},\\\\[.1cm]\n\\nabla\\cdot\\uu{u} &= 0 & \\qquad &\\mbox{in $\\Omega\\times(0,T)$}.\n\\end{alignat}\n\\end{subequations}\nHere $\\uu{u}$ and $p$ are the velocity and pressure of the fluid, $\\uu{f}$ denotes the body forces acting on the fluid and $\\uu{f}_L$ is the Lorentz force, which will be specified later. The parameters $\\mu>0$  and $\\rho_f>0$ denote the dynamic viscosity and density of the fluid, respectively. The spatial domain is given by $\\Omega$ and the end time is denoted by $T$. Mass conservation is given by (\\ref{eq:ns}b), see  \\cite[Chapter 0]{elman2005finite} for the derivation of the incompressible Navier-Stokes equations.\n\n\nMaxwell's equations that govern electromagnetic effects are given by:\n\\begin{subequations}\n\\label{eq:maxwell2}\n    \\begin{alignat}2\n        &\\mbox{Faraday's law:}\\quad \\quad & \\partialt{\\uu{b}} +\\curl \\uu{e} &= \\uu{0}, \\\\\n        &\\mbox{Coulomb's law:}\\quad \\quad & \\div \\uu{d} &= \\hat{\\rho_{e}}, \\\\\n        &\\mbox{Amp\\`{e}re's law:}\\quad \\quad & -\\partialt{\\uu{d}} + \\curl \\uu{h} &= {\\uu{j}},\\\\\n        &\\mbox{Gauss's law:}\\quad \\quad & \\div \\uu{b} &= 0.\n    \\end{alignat}\n\\end{subequations}\nThe fields in \\eqref{eq:maxwell2} are given by: $\\uu{h}$ the magnetic field, $\\uu{e}$ the electric field, $\\uu{d}$ the electric displacement, $\\uu{b}$ the magnetic induction and ${\\uu{j}}$ the electric current density. The parameter $\\hat{\\rho_{e}}$ \\RE{is} the electric charge density. In a homogeneous and isotropic medium, the following linear relations hold:\n\\begin{equation} \\label{eq:assumpt}\n    \\uu{d} = \\delta \\uu{e}, \\quad \\uu{b} = \\mu \\uu{h},\n\\end{equation}\nwhere the constant $\\delta>0$ denotes the electric permittivity and the constant $\\mu>0$ the magnetic permeability. Using \\eqref{eq:maxwell2} together with \\eqref{eq:assumpt} yields the form of Maxwell's equations considered in this thesis:\n\\begin{subequations}\n\\label{eq:maxwell}\n    \\begin{alignat}2\n        &\\mbox{Faraday's law:}\\quad \\quad & \\partialt{\\uu{b}} +\\curl \\uu{e} &= \\uu{0}, \\\\\n        &\\mbox{Coulomb's law:}\\quad \\quad & \\div \\uu{e} &= \\rho_{e}, \\\\\n        &\\mbox{Amp\\`{e}re's law:}\\quad \\quad & -\\partialt{(\\delta\\uu{ e})} + \\curl (\\frac{1}{\\mu}\\uu{b}) &= \\uu{j},\\\\\n        &\\mbox{Gauss's law:}\\quad \\quad & \\div \\uu{b} &= 0,\n    \\end{alignat}\n\\end{subequations}\nwhere $\\rho_{e}=\\frac{\\hat{\\rho_{e}}}{\\delta}$; see \\cite[Chapter 1]{monk2003finite} for more details on Maxwell's equations.\n\n\nThe physical assumptions we consider to form a MHD model are the same as in \\cite[Section 2.1]{armero1996long}. More precisely we assume:\n\\begin{itemize}\n    \\item Non-relativistic motion: The characteristic fluid velocity is assumed to be orders of magnitude smaller than the speed of light.\n    \\item Low-frequency approximation: Phenomena involving high frequencies are omitted. That is, the term $\\partialt{(\\delta\\uu{ e})}$ involving the  displacement current is neglected in Maxwell's equations. Therefore, Amp\\`{e}re's law~(\\ref{eq:maxwell}c) simplifies to\n    \\begin{equation} \\label{eq:AmpereModified}\n        \\curl \\left(\\frac{1}{\\mu}\\uu{b}\\right) = \\uu{j}.\n    \\end{equation}\n    \\item Quasi-neutrality assumption:  Positive and negative charges are equal in any given region. The convection current is omitted and Ohm's law now reads\n    \\begin{equation} \\label{eq:QNassumpt}\n        \\uu{j} = \\theta (\\uu{e}+\\uu{u}\\times\\uu{b}),\n    \\end{equation}\n    where positive parameter $\\theta$ defines the electric conductivity of the fluid and $\\uu{u}\\times\\uu{b}$ corresponds to the charge density induced by the fluid motion. The electrical resistivity is given by $\\nicefrac{1}{\\theta}$ and causes dissipative effects in Maxwell's equations but is not to be neglected in this model.\n    \\item Non-magnetisation and non-polarisation: The assumptions of homogeneity and isotropy also imply that the medium is non-magnetisable and non-polarisable.\n\\end{itemize}\nThe Lorentz force $\\uu{f}_L$ in (\\ref{eq:ns}a) can now be expressed as:\n\\begin{equation} \\label{eq:lorentz}\n    \\uu{f}_L = \\frac{1}{\\rho_{f}\\,\\mu} (\\curl \\uu{b})\\times \\uu{b}.\n\\end{equation}\nThe electromotive term in \\eqref{eq:QNassumpt} now enters Faraday's law (\\ref{eq:maxwell}a) by combining \\eqref{eq:QNassumpt} and \\eqref{eq:AmpereModified} into the following expression for $\\uu{e}$:\n\\begin{equation} \\nonumber\n    \\uu{e} = \\frac{1}{\\theta}\\left(\\curl \\left(\\frac{1}{\\mu}\\uu{b}\\right)-\\uu{u}\\times\\uu{b}\\right).\n\\end{equation}\n\n% \\begin{itemize}\n%     \\item Non-relativistic motion:~\\\\ In general,  Maxwell's equations are invariant under transformations of the Lorentz group. In this thesis, we assume non-relativistic motion, i.e., the fluid velocity is orders of magnitude smaller than the speed of light. Hence, we assume the Galilean invariant approximation of the electromagnetic field transformations. Defining $\\uu{e}'$ and $\\uu{b}'$ as the electric field and  magnetic induction at rest in the reference frame  moving at velocity $\\uu{u}$ with respect to spatial system, then we suppose that\n%     $$\\uu{e}'= \\uu{e}+\\uu{u}\\times \\uu{b}, \\quad \\uu{b}'=\\uu{b},$$\n%     where $\\uu{e}$ and $\\uu{b}$ are the spatial electric field and spatial magnetic induction.\n%     \\item High frequencies: ~\\\\ Phenomena involving high frequencies are not considered, hence, displacement current $\\partialt{(\\delta\\uu{ e})}$ can be neglected. Therefore, Amp\\`{e}re's law~(\\ref{eq:maxwell}c) simplifies to\n%     \\begin{equation} \\label{eq:AmpereModified}\n%         \\curl (\\frac{1}{\\mu}\\uu{b}) = \\uu{j}.\n%     \\end{equation}\n%     \\item Quasi-neutrality: ~\\\\ Positive and negative charges are equal in any given region. Hence, the convection current can be omitted and Ohm's law becomes\n%     $$\\uu{j} = \\theta \\uu{e}'=  \\theta (\\uu{e}+\\uu{u}\\times\\uu{b}).$$\n%     The positive parameter $\\theta$ defines the electric conductivity of the fluid and $\\uu{u}\\times\\uu{b}$ describes the flow of the fluid that has been induced by the electric field.  The electrical resistivity is given by $\\nicefrac{1}{\\theta}$ and causes dissipative effects in Maxwell's equations but is not neglected.\n%     \\item Non-magnetisable and non-polarised medium: ~\\\\ This assumption implies that the relations \\eqref{eq:assumpt} hold for all values of the electric permeability and magnetic permittivity. Therefore, the Lorentz force $\\uu{f}_L$ in (\\ref{eq:ns}a) is now given by:\n%     $$\\uu{f}_L = \\frac{1}{\\rho_{f}} \\uu{j}\\times \\uu{b}.$$\n%     Substituting Amp\\`{e}re's law \\eqref{eq:AmpereModified} (under the low frequency assumption) into the Lorentz force gives the following relationship:\n%     $$\\uu{f}_L = \\frac{1}{\\rho_{f}\\,\\mu} (\\curl \\uu{b})\\times \\uu{b}.$$\n% \\end{itemize}\n\n{Using the assumptions above, elimination of the electric field $\\uu{e}$ and non-dimensionalisation, the systems in \\eqref{eq:ns} and \\eqref{eq:maxwell} are coupled into the following set of partial differential equations:}\n\\begin{subequations}\n\\label{eq:mhdnon}\n\\begin{alignat}2\n \\frac{\\partial \\uu{u}}{\\partial t}- \\nu  \\, \\Delta \\uu{u} + (\\uu{u} \\cdot \\nabla) \\uu{u}+\\nabla p - \\kappa\\, (\\nabla\\times\\uu{b})\\times\\uu{b} &= \\uu{f}, \\\\\n\\nabla\\cdot\\uu{u} &= 0, \\\\\n\\frac{\\partial \\uu{b}}{\\partial t}+\\nu_m  \\, \\nabla\\times( \\nabla\\times \\uu{b})\n-  \\, \\nabla\\times(\\uu{u}\\times \\uu{b}) &= \\uu{0}, \\\\\n\\nabla\\cdot\\uu{b} &= 0,\n\\end{alignat}\n\\end{subequations}\n with suitable initial conditions and boundary conditions; see \\cite[Section 2]{armero1996long}. The unknowns $\\uu{u}$, $p$ and $\\uu{b}$ are the fluid velocity, the fluid pressure and the magnetic field, respectively.\n % The first coupling term $\\kappa\\, (\\nabla\\times\\uu{b})\\times\\uu{b}$ in (\\ref{eq:mhdnon}a) represents to the Lorentz force $f_L$ in \\eqref{eq:lorentz}, whereas the second coupling term $\\nabla\\times(\\uu{u}\\times \\uu{b})$ in (\\ref{eq:mhdnon}c) corresponds to the electromotive force modifying the magnetic field, due to the motion of the conductive fluid.\n\n\nThe solution to \\eqref{eq:mhdnon} depends on three non-dimensional parameters $\\nu = \\nicefrac{1}{\\rm Re}$, $\\nu_m = \\nicefrac{1}{\\rm Rm}$ and $\\kappa$. The first parameter Re is the hydrodynamic Reynolds number, which indicates the balance between the inertial forces and the viscous forces. The parameter Rm is the magnetic Reynolds number, which measures the effect by which the magnetic field induces flow motion. The final parameter, the coupling number, $\\kappa$, represents the influence of the electromagnetic field on the flow. It is sometimes defined in terms of the Hartmann number denoted by Ha, as\n\\begin{equation}\n    \\nonumber\n    \\mbox{Ha} = \\sqrt{\\kappa \\, \\mbox{Re\\,Rm}}.\n    % \\kappa = \\frac{\\mbox{Ha}^2}{\\mbox{Re\\,Rm}}.\n\\end{equation}\nTo find typical physical values for these parameters, we refer to \\cite{armero1996long,le2006mathematical,roberts1967introduction}. We refer to $\\nu$ as the viscosity for the rest of this thesis.\n\nIn this thesis, we are interested in the steady-state ($\\frac{\\partial}{\\partial t} = 0$) version of~\\eqref{eq:mhdnon}:\n\\begin{subequations}\n\\label{eq:steadystate}\n\\begin{alignat}2\n - \\nu  \\, \\Delta \\uu{u} + (\\uu{u} \\cdot \\nabla) \\uu{u}+\\nabla p - \\kappa\\, (\\nabla\\times\\uu{b})\\times\\uu{b} &= \\uu{f}, \\\\\n\\nabla\\cdot\\uu{u} &= 0, \\\\\n\\label{eq:curlcurl}\n\\kappa\\nu_m  \\, \\nabla\\times( \\nabla\\times \\uu{b})\n- \\kappa \\, \\nabla\\times(\\uu{u}\\times \\uu{b}) &= \\uu{0}, \\\\\n\\nabla\\cdot\\uu{b} &= 0.\n\\end{alignat}\n\\end{subequations}\nNote we have multiplied (\\ref{eq:steadystate}c) by $\\kappa$ to enforce skew-symmetry of the coupling terms. We will consider both two- and three-dimensional solutions to \\eqref{eq:steadystate}. \\RE{See Appendix~\\ref{Curl} for curl definitions.}\n\n% The curl operator is well defined in three-dimensions and the two-dimensional curl may be defined as follows: given 2D vector fields $\\uu{b}(x,y) = (b_1,b_2)$, $\\uu{u}(x,y) = (u_1,u_2)$ and the scalar function $r(x,y)$ then the curl and cross products are\n% \\begin{subequations}\n% \\nonumber\n% \\begin{alignat}2\n% \\curl \\uu{b} &=& \\frac{\\partial b_2}{\\partial x} - \\frac{\\partial b_1}{\\partial y}, \\\\\n% \\curl r &=& \\Big(\\frac{\\partial r}{\\partial y}, -\\frac{\\partial r}{\\partial x}\\Big),\\\\\n% \\uu{u} \\times \\uu{b} &=& u_1b_2-u_2b_1.\n% \\end{alignat}\n% \\end{subequations}\n% Note that taking the curl of a 2D vector field results in a scalar function which is the component in the normal direction to the 2D field ($z$-component).\n\n\\section{Numerical solution}\n\nThe partial differential equation (PDE) system given in \\eqref{eq:steadystate} requires a numerical approximation as in general an analytical solution is not possible. There are two main components in computing a numerical solution of a PDE:\n\\begin{itemize}\n    \\item[1.] Discretisation: take a continuous model and transfer it into a discrete model;\n    \\item[2.] Solve: take the discretised model and solve for the unknowns.\n\\end{itemize}\nIn this thesis, we use mixed finite element methods for discretising an MHD model problem, and solve it using preconditioned Krylov subspace methods.\nIn the sequel, we briefly describe these components in the context of the approach we take.\n\n\n\\subsection{Finite element methods for incompressible MHD problems}\n\nThere are several finite element methods for discretising MHD problems as in \\eqref{eq:steadystate}. A common approach in the literature is to approximate the magnetic field using standard nodal $H^1$-conforming elements \\cite{phillips2014block,armero1996long,gerbeau2000stabilized,gunzburger1991existence}. Such a formulation enables one to use the following vector calculus identity\n\\begin{equation} \\label{eq:CurlIdentity}\n-\\Delta \\uu{b} = \\curl (\\curl \\uu{b}) - \\nabla(\\div \\uu{b}).\n\\end{equation}\nSince $\\uu{b}$ is divergences-free it is then possible to apply an augmentation technique to replace the curl-curl operator with a vector Laplacian. This then reduces one of the principal  computational difficulties, namely the large null-space of the curl-curl operator in \\eqref{eq:curlcurl}. However, one of the main problems using $H^1$-conforming elements for the magnetic field is that for non-convex domains (such as the 2D L-shaped domain with a reentrant corner, or the 3D Fichera corner domain with reentrant edges and corners) the magnetic field will converge to a solution that is not correct around the singular point, see \\cite{codina2006stabilized,costabel2000singularities}. Therefore, we consider a mixed discretisation that captures singular solutions correctly. One such family of elements are $H({\\rm curl})$ conforming \\nedelec elements \\cite{nedelec1980mixed}.\n\nTo enable the use of \\nedelec elements for the magnetic field we use the mixed formulation in \\cite{schotzau2004mixed,GreifLiSchotzauWei2010}. This leads to the following governing equations in a domain $\\Omega$:\n\\begin{subequations}\n\\label{eq:mhd}\n\\begin{alignat}2\n\\label{eq:mhd1} - \\nu  \\, \\Delta\\uu{u} + (\\uu{u} \\cdot \\nabla)\n\\uu{u}+\\nabla p - \\kappa\\,\n(\\nabla\\times\\uu{b})\\times\\uu{b} &= \\uu{f} & \\qquad &\\mbox{in $\\Omega$},\\\\[.1cm]\n\\label{eq:mhd2}\n\\nabla\\cdot\\uu{u} &= 0 & \\qquad &\\mbox{in $\\Omega$},\\\\[.1cm]\n\\label{eq:mhd3}\n\\kappa\\nu_m  \\, \\nabla\\times( \\nabla\\times \\uu{b})\n+ \\nabla r\n- \\kappa \\, \\nabla\\times(\\uu{u}\\times \\uu{b}) &= \\uu{g} & \\qquad &\\mbox{in $\\Omega$},\\\\[.1cm]\n\\label{eq:mhd4} \\nabla\\cdot\\uu{b} &= 0 & \\qquad &\\mbox{in $\\Omega$},\n\\end{alignat}\n\\end{subequations}\nwhere we have introduced the Lagrange multiplier, $r$, in the form of $\\nabla r$ in \\eqref{eq:mhd3}. Again, $\\uu{u}$ and $p$ are the velocity and pressure of the fluids and $\\uu{b}$ is the magnetic field. The introduction of the Lagrange multiplier, $r$, corresponds to the divergence-free constraint \\eqref{eq:mhd4} of the magnetic field. With the addition of the Lagrange multiplier, $r$, we may also introduce a generic forcing term $\\uu{g}$ associated with the Maxwell part of \\eqref{eq:mhd}.\n\nThe numerical tests that we will consider will have inhomogeneous Dirichlet boundary conditions for the fluid and magnetic fields and homogeneous Dirichlet boundary condition for the multiplier, $r$, of the form:\n\\begin{subequations}\n\\label{eq:bc}\n\\begin{alignat}2\n\\label{eq:bc1} \\uu{u} &= \\uu{u_D} & \\qquad &\\mbox{on $\\partial\\Omega$},\\\\[.1cm]\n\\label{eq:bc2}\n   \\uu{n}\\times\\uu{b} &= \\uu{n} \\times \\uu{b_D} & \\qquad &\\mbox{on $\\partial\\Omega$},\\\\[.1cm]\n\\label{eq:bc3}      r &=0 &\\qquad &\\mbox{on $\\partial\\Omega$},\n\\end{alignat}\n\\end{subequations}\nwhere $\\uu{u_D}$ and $\\uu{b_D}$ are given functions, and $\\uu{n}$ is the unit outward normal to the boundary $\\partial \\Omega$. Notice, by taking the divergence of equation \\eqref{eq:mhd3} we obtain Poisson's equation (as $\\div \\curl \\uu{b} = 0$):\n$$\\Delta r = \\div \\uu{g} \\quad \\mbox{in } \\Omega, \\quad r = 0 \\quad \\mbox{on } \\partial \\Omega.$$\nIn many physical applications $\\uu{g}$ is divergence-free, which implies that the multiplier, $r$, is zero. In general, the main purpose of the magnetic multiplier is to provide stability, see~\\cite{demkowicz1998modeling}.\n\n\n\n\n\\subsection{Preconditioning incompressible MHD problems}\n\nIncompressible  MHD problems have been extensively studied in the context of various discretisation and formulations. However, the development of preconditioned iterative solutions to MHD problems is limited. \\RE{We refer the reader to the Appendix for a review of Krylov subspace solvers for linear systems. In this thesis our focus will be on the implementation of preconditioners which are tailored to MHD model problem.}\n\n% there does not seem to have been much study of preconditioned iterative solutions.\n\nIn the literature there have not been too many approaches to precoditioning the MHD equations given in either the non-multiplier form \\eqref{eq:steadystate} or with the multiplier form \\eqref{eq:mhd}. In the very recent work \\cite{phillips2014block}, an operator-based preconditioner for the non-multiplier MHD equations \\eqref{eq:steadystate} has been proposed in the context of $H^1$-conforming elements for the magnetic field. To form their preconditioner the authors use the identity \\eqref{eq:CurlIdentity} and a discrete commutator idea to form approximations to the Schur complements. This is based on an approach for a preconditioner to the  Navier-Stokes system as in \\cite[Chapter 8]{elman2005finite}. The preconditioners  we employ are based on similar Navier-Stokes preconditioners but rely on the Maxwell preconditioner in \\cite{greif2007preconditioners} for $H({\\rm curl})$ elements.\n\n\n\\section{Objectives and contributions}\n\nThe aim of this thesis is to develop and test fully scalable iterative solution methods for the incompressible MHD model \\eqref{eq:mhd}, \\eqref{eq:bc} using natural Taylor-Hood elements \\cite{taylor1973numerical} for the fluid variables and \\nedelec mixed element  \\cite{nedelec1980mixed} pair for the magnetic variables.  Our numerical results show good scalability with respect to the mesh size. We provide  several tests  to study the performance of the preconditioners with respect to the relevant non-dimensional parameters. We also present two- and three-dimensional results.\n\nTo enable large scale preconditioned tests of the MHD model we use the finite element software \\fenics \\cite{wells2012automated} together with the linear algebra software from {\\tt PETSc} \\cite{petsc-web-page,petsc-user-ref}. Using these two principal software packages, experiments were run in excess of 20 million degrees of freedom. As well, it provides an example of how significant physical problems described by partial differential equations can be solved by combining state of the art numerical software packages. The aim is to release the code for public use.\n\nAs stated above,  little has been done in terms of preconditioned iterations for the MHD model other than the works of  \\cite{phillips2014block} for the non-multiplier form \\eqref{eq:steadystate}. Our approach is based on $H({\\rm curl})$ elements for the magnetic field \\cite{schotzau2004mixed}, and motivated by the preliminary results of \\cite{li2010numerical} in the context of exactly divergence-free elements for the velocity field. It combines preconditioners for the incompressible Navier-Stokes and Maxwell's equations in \\cite{elman2005finite,greif2007preconditioners,MR2911387}.\n\n\n% The scalable solvers considered in this thesis may now enable more investigation of the physical problems they describe.\nThe availability of our large-scale solvers and code will hopefully allow more development and research into such MHD models.\n\n\\section{Outline}\n\nThis thesis is made up of five chapters and is structured as follows. In Chapter 2, we introduce a mixed finite element approximation to the MHD system \\eqref{eq:mhd}-\\eqref{eq:bc}. The mixed approximation is based on a standard nodal Taylor-Hood finite element approximation for the velocity field and the pressure, together with a mixed \\nedelec element approximation for the magnetic field and the multiplier. Using this approximation, we introduce three possible non-linear iteration schemes.\n\nIn Chapter 3, we present an overview of the preconditioning approaches for the individual subproblems separately, namely the incompressible Navier-Stokes and Maxwell's equations. We then apply these preconditioning techniques to propose preconditoning strategies for the linearisations which arise from the three non-linear iteration schemes from Chapter~2. In particular, for the coupled linearised Picard scheme we propose an inner-outer preconditioning approach.\n\nIn Chapter 4, to perform numerical experiments in both two and three spatial dimensions we use the following two main software packages \\fenics \\cite{wells2012automated} and {\\tt PETSc} \\cite{petsc-web-page,petsc-user-ref}. We show convergence results for the linearised MHD system along with the incompressible Navier-Stokes and Maxwell subproblems in isolation. Along with the convergence results we numerically test the preconditioning approaches for the three non-linear iteration schemes, providing heuristic tests with respect to the dimensionless parameters ($\\nu$,~$\\nu_m$~and~$\\kappa$;~see~\\eqref{eq:mhd}) and mesh size. These tests examine the robustness of both the preconditioners and the iteration schemes.\n\nChapter 5 provides conclusions and outlines possible extensions for future work.\n", "meta": {"hexsha": "8ed1b4397186fae046ced9e50aa0ab8189f2e8b4", "size": 22773, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MHD/THESIS/Intro/Intro.tex", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/THESIS/Intro/Intro.tex", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/THESIS/Intro/Intro.tex", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 100.7654867257, "max_line_length": 897, "alphanum_fraction": 0.7478153954, "num_tokens": 6478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.42953417910886027}}
{"text": "%% LyX 2.3.6.2 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[12pt,a4paper,fleqn,american,parskip=half-,svgnames]{scrartcl}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n\\pdfpageheight\\paperheight\n\\pdfpagewidth\\paperwidth\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\newcommand{\\velo}{\\upsilon}\n\\newcommand{\\cheat}{C}\n\n\n\\usepackage{lastpage}\n\\usepackage{textgreek}\n\\usepackage{fixltx2e}\n\\usepackage{hyperref} %ermöglicht \\href{}\n\\usepackage{tabularx}\n\\usepackage{url}\n\\usepackage{microtype}\n\\usepackage[nomessages]{fp}\n\\usepackage{pdfpages}\n\n%colors\n\\definecolor{link_color}{HTML}{00406E} % dark blue\n\\definecolor{cite_color}{HTML}{590000} % dark red\n\\definecolor{dark-violet}{HTML}{9400d3} \n\\definecolor{forest-green}{HTML}{228b22} \n\\definecolor{dark-red}{HTML}{8b0000} \n\\definecolor{dark-blue}{HTML}{00008b} \n\\definecolor{dark-pink}{HTML}{ff1493}\n\\definecolor{dark-salmon}{HTML}{e9967a}\n\\definecolor{midnight-blue}{HTML}{191970}\n\n\\hypersetup{hidelinks = true}\n\\hypersetup{\n    colorlinks   = true, %Colours links instead of ugly boxes\n    urlcolor     = link_color, %Colour for external hyperlinks\n    linkcolor    = black, %Colour of internal links\n    frenchlinks  = true, %small caps\n    citecolor    = cite_color %Colour of citations\n}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\n\\section{Phase field modeling}\n\nGiven is the following energy functional \n\\begin{align*}\nF\\left[\\phi(x,y,t)\\right] & =\\int_{-\\infty}^{\\infty}\\underbrace{\\left(\\frac{U}{2}\\left[a^{2}\\left((\\partial_{x}\\phi)^{2}+(\\partial_{y}\\phi)^{2}\\right)+g(\\phi)\\right]+\\mu_{0}h(\\phi)\\right)}_{f(\\phi,\\partial_{x}\\phi,\\partial_{y}\\phi)}dx,\n\\end{align*}\nwhere $a$ and $U$ are constants of the dimension length and energy\nrespectively. $f(\\phi,\\partial_{x}\\phi,\\partial_{y}\\phi)$\\footnote{$\\partial_{x}$ is an abbreviation for the partial derivative with\nrespect to $x$, i.e.~$\\partial_{x}\\equiv\\partial/\\partial x$} denotes the local free energy density and $\\mu$ the bulk free energy\ndensity difference between the two phases. Depending on the sign of\n$\\mu$, this can either favor the growth of the one or the other phase.\n$g(\\phi)=\\phi^{2}(1-\\phi)^{2}$ is the double well potential and $h(\\phi)=\\phi^{2}(3-2\\phi)$\nis the interpolation function. Please note, that for the reason of\nphase-stability we have to demand $|\\mu|<U/6$.  \n\nVariational principles provide the phase field equation\n\\begin{align}\n\\frac{1}{M_{\\phi}}\\frac{\\partial\\phi}{\\partial t} & =-\\frac{\\delta F}{\\delta\\phi}\\nonumber \\\\\n & =\\partial_{x}\\frac{\\partial f}{\\partial\\left(\\partial_{x}\\phi\\right)}+\\partial_{y}\\frac{\\partial f}{\\partial\\left(\\partial_{y}\\phi\\right)}-\\frac{\\partial f}{\\partial\\phi}\\nonumber \\\\\n & =U\\left(a^{2}(\\partial_{x}^{2}\\phi+\\partial_{y}^{2}\\phi)-\\frac{1}{2}\\frac{\\partial g(\\phi)}{\\partial\\phi}\\right)-\\mu\\frac{\\partial h(\\phi)}{\\partial\\phi}.\\label{eq:Kinetische-Gl}\n\\end{align}\n\n\n\\subsection{Stability of the homogenous and time independent solutions}\n\nWe look for constant solutions of Eq.~\\ref{eq:Kinetische-Gl} \n\\begin{align*}\n0= & \\frac{U}{2}\\frac{\\partial g(\\phi)}{\\partial\\phi}+\\mu\\frac{\\partial h(\\phi)}{\\partial\\phi}\n\\end{align*}\nCalculation of the partial derivatives of the polynomial functions\nleads to \n\\begin{align*}\n\\frac{\\partial g(\\phi)}{\\partial\\phi} & =2\\phi(1-\\phi)(1-2\\phi)\\\\\n\\frac{\\partial h(\\phi)}{\\partial\\phi} & =6\\phi(1-\\phi)\n\\end{align*}\n Inserting in the equation above yields\n\\begin{align*}\n0 & =U\\phi(1-\\phi)(1-2\\phi)+\\mu6\\phi(1-\\phi)\\\\\n0 & =\\phi(1-\\phi)(1-2\\phi)+\\frac{6\\mu}{U}\\phi(1-\\phi)\\\\\n0 & =\\phi(1-\\phi)\\left(1-2\\phi+\\frac{6\\mu}{U}\\right)\\\\\n\\Rightarrow & \\phi_{1}=0;\\phi_{2}=1;\\phi_{3}=\\frac{1}{2}+\\frac{3\\mu}{U};\n\\end{align*}\nStability of the solutions: \n\\begin{itemize}\n\\item $\\phi_{1}=0$ is a global (local) minimum if $\\mu_{0}>0$ ($\\mu_{0}<0$),\ni.e.~stabile (meta stabile)\n\\item $\\phi_{2}=1$ is local (global) minimum if $\\mu_{0}>0$ ($\\mu_{0}<0$),\nd.h.~meta stabile (stabile)\n\\item $\\phi_{3}=\\frac{1}{2}+3\\mu_{0}/U$ is for positive and negative $\\mu$\nunstable ( $|\\mu|<U/6$)\n\\end{itemize}\n\n\\subsection{Phase-field profile function}\n\nWe show that \n\\begin{align}\n\\phi_{0}(x,t)= & \\frac{1}{2}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\label{eq:1DPhasenfeldloesung}\n\\end{align}\nis a heterogeneous solution of the phase field equation (\\ref{eq:Kinetische-Gl})\nif $v=6M_{\\phi}a\\mu$. Note that from $\\partial_{x}\\left(\\tanh(x)\\right)=1-\\tanh^{2}(x)$\nwe can deduct the following property of this solution $\\partial_{x}\\phi_{0}=\\phi_{0}\\left(1-\\phi_{0}\\right)/a$. \n\nCalculation of the derivatives:\n\\begin{align}\n\\frac{\\partial\\phi_{0}}{\\partial x} & =\\frac{1}{2}\\frac{\\partial}{\\partial x}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)=\\frac{1}{4a}\\left(1-\\tanh^{2}\\frac{(x-vt)}{2a}\\right)\\nonumber \\\\\n & =\\frac{1}{4a}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\left(1+1-1-\\tanh\\frac{(x-vt)}{2a}\\right)\\nonumber \\\\\n & =\\frac{1}{4a}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\left(2-\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\right)\\nonumber \\\\\n & =\\frac{1}{a}\\frac{1}{2}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\left(1-\\frac{1}{2}\\left(1+\\tanh\\frac{(x-vt)}{2a}\\right)\\right)\\nonumber \\\\\n & =\\frac{1}{a}\\phi_{0}\\left(1-\\phi_{0}\\right)\\label{eq:Intro-Phasefield-stat-1d-profil-first-deriv}\\\\\n\\frac{\\partial^{2}\\phi_{0}}{\\partial x^{2}} & =\\frac{1}{a}\\frac{\\partial}{\\partial x}\\left[\\phi_{0}\\left(1-\\phi_{0}\\right)\\right]=\\frac{1}{a}\\frac{\\partial}{\\partial\\phi_{0}}\\left[\\phi_{0}\\left(1-\\phi_{0}\\right)\\right]\\frac{\\partial\\phi_{0}}{\\partial x}\\nonumber \\\\\n & =\\frac{1}{a^{2}}\\phi_{0}\\left(1-\\phi_{0}\\right)\\left(1-2\\phi_{0}\\right),\\label{eq:Intro-Phasefield-stat-1d-profil-sec-deriv}\\\\\n\\frac{\\partial\\phi_{0}}{\\partial t} & =-v\\frac{\\partial\\phi_{0}}{\\partial x}=-\\frac{v}{a}\\phi_{0}\\left(1-\\phi_{0}\\right).\n\\end{align}\nWhere the second derivative has been calculated using the chain rule\n$\\frac{\\partial f(\\varphi(x))}{\\partial x}=\\frac{\\partial f}{\\partial\\varphi}\\frac{\\partial\\varphi}{\\partial x}$.\nInserting in the nonlinear partial differential equation \n\\begin{align*}\n-\\frac{v}{a}\\phi_{0}\\left(1-\\phi_{0}\\right) & =M_{\\phi}U\\underbrace{\\left[a^{2}\\frac{1}{a^{2}}\\phi_{0}\\left(1-\\phi_{0}\\right)\\left(1-2\\phi_{0}\\right)-\\phi(1-\\phi)(1-2\\phi)\\right]}_{=0}\\\\\n & \\hspace*{1em}-M_{\\phi}\\mu6\\phi_{0}\\left(1-\\phi_{0}\\right)\\\\\n\\Leftrightarrow\\quad-v & =-6M_{\\phi}a\\mu.\n\\end{align*}\n\n\n\\subsection{Interface energy density}\n\nThe interface energy density $\\gamma$ in the phase-field model corresponds\nto the total free energy of the heterogeneous solution $\\gamma=F[\\phi_{0}(x,t)]$: \n\n\\begin{align*}\nF & =\\frac{U}{2}\\int_{-\\infty}^{\\infty}\\left(a^{2}\\left(\\frac{\\partial\\phi_{0}}{\\partial x}\\right)^{2}+\\phi_{0}^{2}(1-\\phi_{0})^{2}\\right)dx\\\\\n & =\\frac{U}{2}\\int_{-\\infty}^{\\infty}\\left(a^{2}\\left(\\frac{1}{a}\\phi_{0}\\left(1-\\phi_{0}\\right)\\right)^{2}+\\phi_{0}^{2}(1-\\phi_{0})^{2}\\right)dx\\\\\n\\left[dx=\\frac{a}{\\phi_{0}(1-\\phi_{0})}d\\phi_{0}\\right] & =aU\\int_{0}^{1}\\frac{\\phi_{0}^{2}(1-\\phi_{0})^{2}}{\\phi_{0}(1-\\phi_{0})}d\\phi_{0}\\\\\n & =aU\\int_{0}^{1}\\phi_{0}(1-\\phi_{0})d\\phi_{0}\\\\\n & =aU\\left(\\frac{1}{2}\\phi_{0}^{2}-\\frac{1}{3}\\phi_{0}^{3}\\right)|_{0}^{1}=\\frac{aU}{6}\n\\end{align*}\n\n\n\\subsection{Calibration of the field model}\n\nWe calibrate the phase field model according to the 1D considerations\nabove, i.e. we switch from the parameters $a,U,M_{\\phi}$ to the parameters\n$\\xi=2a$ for the phase-field width, $\\Gamma=aU/6$ for interface\nenergy density and $M=M_{\\phi}a^{2}U$ for the kinetic coefficient\n$M[\\mathrm{m}^{2}/\\mathrm{s}]$. The calibrated phase-field model\nprovide the following relation between the driving force $\\mu$ and\nthe resulting stationary interface velocity $v$\n\\begin{align*}\nv & =\\frac{M}{\\Gamma}\\mu_{0}=K\\mu_{0}.\n\\end{align*}\nWith these parameters we obtain the following phase-field equation\n\n\\begin{align*}\n\\frac{1}{M}\\partial_{t}\\phi & =\\underbrace{\\partial_{x}^{2}\\phi+\\partial_{y}^{2}\\phi}_{\\mathrm{Laplace-Operator}}-\\frac{2}{\\xi^{2}}\\partial_{\\phi}g(\\phi)-\\frac{\\mu}{3\\Gamma\\xi}\\partial_{\\phi}h(\\phi).\n\\end{align*}\n\n\\end{document}\n", "meta": {"hexsha": "068bf187c4faf589aa380439f15febeb1fc38a5b", "size": 8146, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/Phase_field_modeling_exercise.tex", "max_stars_repo_name": "pzimbrod/ML-for-PhaseField", "max_stars_repo_head_hexsha": "22f7d8ac292f6f02e520f75c61078449453ed244", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-24T05:36:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-24T05:36:14.000Z", "max_issues_repo_path": "reports/Phase_field_modeling_exercise.tex", "max_issues_repo_name": "pzimbrod/ML-for-PhaseField", "max_issues_repo_head_hexsha": "22f7d8ac292f6f02e520f75c61078449453ed244", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-09-07T08:39:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-24T09:29:43.000Z", "max_forks_repo_path": "reports/Phase_field_modeling_exercise.tex", "max_forks_repo_name": "pzimbrod/ML-for-PhaseField", "max_forks_repo_head_hexsha": "22f7d8ac292f6f02e520f75c61078449453ed244", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-15T16:49:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-15T16:49:01.000Z", "avg_line_length": 47.6374269006, "max_line_length": 265, "alphanum_fraction": 0.6748097226, "num_tokens": 2993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.42953416848652365}}
{"text": "% -*-LaTeX-*-\n\n% $Log: convolution.tex,v $\n% Revision 1.6  2007/12/11 02:32:54  stiber\n% Small edits for start of Winter 2008.\n%\n% Revision 1.5  2007/03/20 23:53:12  stiber\n% Updated LaTeX.\n%\n% Revision 1.4  2007/03/20 01:25:56  stiber\n% Modifications made to make this a standalone text.\n%\n% Revision 1.3  2006/03/27 23:36:42  stiber\n% Fixed error in formula.\n%\n% Revision 1.2  2004/03/29 19:51:48  stiber\n% Updated for Spring 2004 and new textbook (DSP First).\n%\n% Revision 1.1  2004/02/19 00:26:01  stiber\n% Initial revision\n%\n\n\\chapter{The Z-Transform and Convolution}\n\\label{ch:convolution}\n\nTwo signal processing tools --- the \\emph{z transform} and\n\\emph{convolution} --- are introduced in this chapter.  These\noperations play important roles in the analysis of discrete-time\nsignals (which is what we do in the computer). We shall see that they\nare related --- the convolution of two time-domain signals (which is\nwhat we do when we filter a signal) is equivalent to multiplication of\ntheir corresponding z-transforms. This is one example of how these\nrepresentations can greatly simplify computation.\n\nAfter studying this chapter, you should be able to understand what the\nz-transform and convolution are, and how to implement them. You should\nunderstand the differences between them and the other transforms:\nFourier series, Fourier transform, and discrete Fourier transform. You\nwill enrich your knowledge of filter transfer functions with its time\ndomain representation: its \\emph{impulse response}.\n\n\\section{Domains}\n\nUp to this point, we have covered the Fourier series representation of\na signal as a weighted sum of sinusoids. In effect, the Fourier series\n\\emph{transforms} a finite and periodic, continuous signal in the time\n\\emph{domain} into an infinite, discrete spectrum in the frequency\n\\emph{domain}.\n\\index{domains}\n\\index{time domain}\n\\index{frequency domain}\n\\index{domain!time}\n\\index{domain!frequency}\nWhen we use the term \\emph{domain}, we merely mean a particular way of\nlooking at a signal. In this case, we have two different ways of\nthinking about our signals: as functions of time or as functions of\nfrequency. These are equivalent, in the sense that we can convert the\nsignal's representation back and forth between the two domains without\nloss of information (neglecting matters such as roundoff error).\n\nIn future chapters, we will cover two other transforms:\n\\begin{description}\n\\item[Fourier transform] transforms an infinite, continuous signal in\nthe time domain into an infinite, continuous spectrum in the frequency\ndomain.\n\n\\item[Discrete Fourier transform] transforms a finite, discrete signal\nin the time domain into a finite, discrete spectrum in the frequency\ndomain.\n\\end{description}\n\nHere, however, we will learn about the\n\\emph{z-transform}, which converts an infinite, discrete signal in the\ntime domain into a finite, continuous spectrum in the frequency\ndomain. The z-transform fills the last combination among ``finite vs.\ninfinite; continuous vs. discrete''. Table~\\ref{tb:zt-transforms}\nsummarizes all four transforms.  As you can see, continuous versus\ndiscrete in the time domain transforms to infinite versus finite in\nthe frequency domain, while finite versus infinite in the time domain\ntransforms to discrete versus continuous in the frequency domain.\n\n\\begin{table}\n\\caption{Summary of frequency transforms.\n\\label{tb:zt-transforms}}\n\\begin{center}\n\\begin{tabular}{|l|l|l|} \\hline\nTransform & Time Domain & Frequency Domain\\\\ \\hline\\hline\nFourier Series & Finite, Continuous & Infinite, Discrete \\\\ \nFourier Transform & Infinite, Continuous & Infinite, Continuous \\\\ \nDiscrete Fourier Transform & Finite, Discrete & Finite, Discrete \\\\ \nZ-Transform & Infinite, Discrete & Finite, Continuous \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\n\\section{The z-transform}\nThe \\emph{z-transform} of a discrete time signal $x[n]$, $n=0, \\pm 1,\n\\pm 2, \\ldots, \\pm\\infty$ is defined as the power series\n\\begin{equation}\nX(z) \\equiv \\sum_{k=-\\infty}^{\\infty} x[k] z^{-k}\n\\label{eq:zt}\n\\end{equation}\nwhere $z$ is a continuous complex variable. It transforms the time\ndomain, infinite, discrete sequence into its complex plane\nrepresentation $X(z)$. Since the z-transform is an infinite power\nseries, it exists only for those values of $z$ for which this series\nconverges. The \\emph{region of convergence} (ROC) of $X(z)$ is the set\nof all values of $z$ for which $X(z)$ has a finite value. We consider\nthe z-transform to be a transform between the time domain and the\nfrequency domain because we can substitute $z=e^{j\\hat{\\omega}}$ into\nequation~(\\ref{eq:zt}) to get the signal's (finite and continuous)\nfrequency content $\\mathcal{X}(\\hat{\\omega})$ --- just as we\npreviously made the same substitution to derive a feedforward filter's\nfrequency response from its transfer function.\n\nThe relationship between $x[n]$ and $X(z)$ can be indicated\nby the \\emph{transform pair}\n\\begin{equation}\n\\underbrace{x[n]}_{\\stackrel{\\text{function of}}{_\\text{sample \\#}}}\n   \\stackrel{\\mathbf{Z}}{\\longleftrightarrow} \n   \\underbrace{X(z)}_{\\stackrel{\\text{function of}}{_\\text{complex $z$}}}\n\\end{equation}\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex1}--\\ref{it:ch6ex2} for answers.\n\n\\begin{enumerate}\n\\item Determine the z-transform for the sequence\n  $x[n]=\\{1,2,5,7,0,1\\}$, $n=0,1,2,3,4,5$\n\n\\item Determine the z-transform of the sequence\n  $x[n]=\\{1,2,5,7,0,1\\}$, $n=-2,-1,0,1,2,3$\n\\end{enumerate}}\n\n\\subsection{Example: z-transform of an impulse}\n\\label{sc:zx-impulse}\n\n\\index{z-transform!of an impulse}\n\\index{unit impulse}\nThe \\emph{unit impulse} or \\emph{unit sample} signal is the $\\delta$\nfunction,\n\\begin{equation}\n\\delta[n] = \\left\\{\\begin{array}{ll}\n                        1 & n=0 \\\\\n                        0 & n \\neq 0\n          \\end{array}\\right.\n\\end{equation}\nIt has value of zero for every sample except $n=0$, for which it has a\nvalue of one. Substituting this signal into~(\\ref{eq:zt}) to get its\nz-transform, we have\n\\begin{align}\n\\Delta(z) &= \\sum_{k=-\\infty}^{\\infty} \\delta[k] z^{-k} \\notag\\\\\n     &= 1z^{-0}=1\n\\end{align}\nthat is \n\\begin{equation}\n\\delta[n]\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} 1\n\\end{equation}\n\nSince the frequency content of the signal is the magnitude of its\nz-transform on the unit circle in the z-plane, \n\\begin{equation}\n|\\mathcal{D}(\\hat{\\omega})|=|\\Delta(e^{j\\hat{\\omega}})|=1\n\\label{eq:zt-delta}\n\\end{equation}\nThis tells us that the frequency content is the same for all\nfrequencies: an impulse has a \\emph{flat spectrum}.\n\nWhat about time shifted impulses,\n\\begin{align}\n\\delta[n-n_0] &= \\left\\{\\begin{array}{ll}\n                        1 & n=n_0 \\\\\n                        0 & n \\neq n_0\n          \\end{array}\\right., \\quad n_0>0 \\\\\n\\delta[n+n_0] &= \\left\\{\\begin{array}{ll}\n                        1 & n=-n_0 \\\\\n                        0 & n \\neq -n_0\n          \\end{array}\\right., \\quad n_0>0\n\\end{align}\nIn these cases the nonzero value is not at sample zero, but at samples\n$n_0$ or $-n_0$.  We can compute the z-transform as before,\n\\begin{align}\n\\Delta(z) &= \\sum_{k=-\\infty}^{\\infty} \\delta[k-n_0] z^{-k} \\notag\\\\\n          &= 1z^{-n_0}=z^{-n_0}=\\frac{1}{z^{n_0}}\n\\end{align}\nfor $\\delta[n-n_0]$.  The z-transform for this shifted unit impulse\nhas one value, $z^{-n_0}$, for any $z \\neq 0$.\n\\begin{equation}\n\\delta[n-n_0] \\stackrel{\\mathbf{Z}}{\\longleftrightarrow} \\frac{1}{z^{n_0}},\n\\quad n_0>0\n\\end{equation}\n\nIts frequency content is also one, just like $\\delta[n]$ (remember\nthat we compute the spectrum for values of $z$ on the unit circle),\n\\begin{equation}\n|\\mathcal{D}(\\hat{\\omega})|=|\\Delta(e^{j\\hat{\\omega}})|=|e^{-jn_0\\hat{\\omega}}|=1\n\\end{equation}\nThis is not surprising at all, because it is, after all, just a\ntime-shifted version of $\\delta[n]$. The signal $\\delta[n+n_0]$ is\nleft as a self-test exercise.\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex3}--\\ref{it:ch6ex4} for answers.\n\n\\begin{enumerate}\n\\item Sketch equation~(\\ref{eq:zt-delta}).\n\\item Compute the z-transform and frequency content for the signal\n  $\\delta[n+n_0]$.\n\\end{enumerate}}\n\n\\subsection{Example: z-transform of exponential signal}\n\\label{sc:zx-exp}\n\n\\index{z-transform!of an exponential}\nAn exponential signal is defined as \n\\begin{equation}\nx[n] = \\left\\{\\begin{array}{ll}\n                        \\alpha^n & \\quad  n \\ge 0 \\\\\n                        0        & \\quad n < 0\n          \\end{array}\\right.\n\\label{eq:zt-expof}\n\\end{equation}\nwhere $\\alpha$ can be any real or complex value less than one. The\nsignal consists of an infinite number of samples. The z-transform of\nthis signal is\n\\begin{align}\nX(z) &= \\sum_{k=-\\infty}^{\\infty} x[k] z^{-k} \\notag\\\\\n     &= \\sum_{k=0}^{\\infty}\\alpha^k  z^{-k} \\notag\\\\\n     &= \\sum_{k=0}^{\\infty}(\\alpha z^{-1})^k\n\\label{eq:exp-zt}\n\\end{align}\n\nThis is an infinite \\emph{geometric series}: a sum in which each\nsuccessive term is the previous term times some (unchanging)\nexpression (i.e., the ratio of successive terms is constant).\n\\index{geometric series} The ratio of two successive terms in a\ngeometric series like \\index{geometric series!common ratio}\nequation~(\\ref{eq:exp-zt}) is called its \\emph{common ratio}, which in\nthis case is $\\alpha z^{-1}$. We can show this by rewriting\nequation~(\\ref{eq:exp-zt}) as $X(z) = 1 + \\alpha z^{-1} + \\alpha^{2}\nz^{-2} + \\cdots$. Rewriting the \\spscript{$i+1$}{st} element of this\nseries as a recurrence relation (in terms of the \\spscript{$i$}{th}),\n\\index{recurrence relation}\nwe get $X(z)_{i+1} = X(z)_i \\alpha z^{-1}$, which shows the common ratio.\n  \nIf we have a geometric series in which successive terms $b_i$ and\n$b_{i+1}$ have the common ratio $r$ (i.e., $b_{i+1}/b_i = r$), then\nany term in the series can be expressed in terms of the first term as\n\\index{geometric series!as function of first term}\n\\begin{equation*}\nb_i = b_0 r^i\n\\end{equation*}\nSo, a geometric series can be expressed as a sum of these, $b_0 + b_0r\n+ b_0r^2 + \\cdots$. We can factor out the zeroth term, leaving us with\nthe task of simplifying $1 + r + r^2 + \\cdots$. Multiplying this sum\nby $(1-r)/(1-r)$, we obtain\n\\begin{align}\n(1 + r + r^2 + \\cdots)\\frac{1-r}{1-r}\n  & = \\frac{1 + r + \\cdots - r - r^2 - \\cdots}{1-r} \\notag\\\\\n  & = \\frac{1-r^N}{1-r}\n\\end{align}\n\nIn this case, $|r|<1$ so $r^N \\rightarrow 0$ as $N \\rightarrow \\infty$:\n\\begin{equation}\n1+r+r^2+r^3+\\ldots = \\frac{1}{1-r}, \\quad\\text{if } |r|<1\n\\end{equation}\nConsequently, for $|r|=|\\alpha z^{-1}|<1$ or $|z|>|\\alpha|$,\n$X(z)$ converges to\n\\begin{equation}\nX(z)=\\frac{1}{1-\\alpha z^{-1}}, \\quad |z|>|\\alpha|\n\\label{eq:zt-expoF}\n\\end{equation}\n\nIn the z-plane, $|z|>|\\alpha|$ refers to any $z$ that is outside of\nthe radius $|\\alpha|$ circle. We see that in this case, the\nz-transform provides a compact alternative representation of the\nsignal $x[n]$.\n\nLet's check out some special cases:\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=3.5in]{ch-conv/zt_expo_rf}}\n\\caption{The exponential signal $x[n]=(1/2)^n, n=0,1,2,\\ldots$.\n\\label{fig:zt-expo-r0.5f}}\n\\end{figure}\n\n\\paragraph*{When $\\alpha$ is a real number, say $\\alpha=1/2$:}\nThe discrete signal in this case is \n\\begin{equation}\nx[n] = \\left\\{\\begin{array}{ll}\n                        \\left(\\frac{1}{2}\\right)^n & \\quad  n \\ge 0 \\\\\n                        0             & \\quad n < 0\n          \\end{array}\\right.\n\\end{equation}\nor\n\\begin{equation}\nx[n] = \\left\\{1, \\frac{1}{2}, \\left(\\frac{1}{2}\\right)^2,\n        \\left(\\frac{1}{2}\\right)^3, \\ldots, \\right\\}\n\\end{equation}\nFigure~\\ref{fig:zt-expo-r0.5f} shows the graph of the signal $x[n]$.\n\nReplacing $\\alpha$ with $1/2$ in~(\\ref{eq:zt-expoF}), its\nz-transform is expressed as\n\\begin{equation}\nX(z)=\\frac{1}{1-\\frac{1}{2}z^{-1}}, \\quad |z|>\\frac{1}{2}\n\\end{equation}\n\nAs you should be familiar with now, the frequency content of this\nsignal is the magnitude of its z-transform on the unit circle\n$z=e^{j\\hat{\\omega}}$ in the z-plane, which is\n\\begin{equation}\n|\\mathcal{X}(\\hat{\\omega})|=|X(e^{j\\hat{\\omega}})|\n           =\\left|\\frac{1}{1-\\frac{1}{2}e^{-j\\hat{\\omega}}}\\right|\n\\end{equation}\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=2.5in]{ch-conv/zt_expo_r0-5F}}\n\\caption{Frequency content of the signal shown\nin figure~\\protect\\ref{fig:zt-expo-r0.5f}.\n\\label{fig:zt-expo-r0.5F}}\n\\end{figure}\n\nFigure~\\ref{fig:zt-expo-r0.5F} is the plot of\n$|\\mathcal{X}(\\hat{\\omega})|$ versus frequency $\\omega$.  The\namplitude decreases along increasing frequency. Its peak is at zero\nfrequency, which is called \\emph{DC} (which literally means ``direct\ncurrent,'' implying the constant --- actually mean --- component of\nthe signal).\n\n\\paragraph*{When $\\alpha=1$:}\n\nFor $\\alpha=1$, the sequence becomes\n\\begin{equation}\nx[n] = u[n] = \\left\\{\\begin{array}{ll}\n                        1 & n \\ge 0 \\\\\n                        0 & n < 0\n          \\end{array}\\right.\n\\end{equation}\nor\n\\begin{equation}\nu[n] = \\{1, 1, 1, \\ldots\\}, \\quad n \\ge 0\n\\end{equation}\n\n\\index{unit step}\nThis is a discrete time, infinite duration \\emph{unit step}\nsignal. Notice the difference between the unit step signal and the\nunit impulse signal. The latter only has one nonzero value at one\nparticular time, the former has value one for all time after some\nparticular time. By analogy with $\\delta[n]$ , a unit step occurring at\nsample $k$ is called $u[n-k]$.  Substituting $\\alpha=1$\ninto~(\\ref{eq:zt-expoF}) we have\n\\index{z-transform!of a unit step}\n\\begin{equation}\nU(z)=\\frac{1}{1-z^{-1}}, \\quad |z|>1\n\\end{equation}\nWe can see that the pole (a zero in the denominator; you'll learn more\nabout this in Chapter~\\ref{ch:fb-filters}) is at $z=1$, where the\nz-transform has an infinite value.\n\nLet's evaluate the frequency content of the unit step signal. If we\nevaluate $\\mathcal{U}(\\hat{\\omega})$ on the unit circle (except at\n$z=1$), we obtain\n\\begin{align}\n\\mathcal{U}(\\hat{\\omega})\n&= U(e^{j\\hat{\\omega}})\n  =\\frac{1}{1-e^{-j\\hat{\\omega}}}\\frac{e^{j\\hat{\\omega}/2}}{e^{j\\hat{\\omega}/2}}\n\\notag\\\\\n&= \\frac{e^{j\\hat{\\omega}/2}}{e^{j\\hat{\\omega}/2}-e^{-j\\hat{\\omega}/2}} \\notag\\\\\n&= \\frac{e^{j\\hat{\\omega}/2}}{2j\\sin\\hat{\\omega}/2} \\notag\\\\\n&= \\frac{e^{j(\\hat{\\omega}/2-\\pi/2)}}{2\\sin\\hat{\\omega}/2}, \\quad \\hat{\\omega}\\ne\n2\\pi k, k=0,1,\\ldots\n\\end{align}\nbecause $-j=e^{-j\\pi/2}$ (see the self-test exercises).  Hence, the\npresence of a pole (a zero in the denominator) at $z=1$ (that is, at\n$\\hat{\\omega}=0$) creates a problem only when we want to compute\n$|\\mathcal{U}(\\hat{\\omega})|$ at $\\hat{\\omega}=0$, because\n$|\\mathcal{U}(\\hat{\\omega})|\\rightarrow \\infty$ as\n$\\hat{\\omega}\\rightarrow 0$. For any other value of $\\hat{\\omega}$,\n$|\\mathcal{U}(\\hat{\\omega})|$ is finite.\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=3.5in]{ch-conv/zt_expo_r1F}}\n\\caption{Frequency content of the unit step signal.\n\\label{fig:zt-expo-r1F}}\n\\end{figure}\n\nFigure~\\ref{fig:zt-expo-r1F} shows a plot of\n$|\\mathcal{U}(\\hat{\\omega})|$ vs.  $\\hat{\\omega}$.  Since the signal\nis a unit step, and so has a constant value from zero onwards, we\nmight expect the signal to have zero frequency components at all\nfrequencies except at $\\hat{\\omega}=0$, but that is not the case. The\nreason is that the signal is not a constant for all $-\\infty <n<\n\\infty$. Instead, it is turned on at $n=0$. This \\emph{abrupt jump}\ncreates all the frequency components existing in the range\n$0<\\hat{\\omega}\\le\\pi$. Generally, \\emph{all} signals which start at a\nfinite time will have nonzero frequency components everywhere in the\nfrequency axis from zero up to the Nyquist frequency. All such signals\ncan be considered to be the product of some infinite signal with a\nunit step; we will see the effect of this on their spectrum when we\nexplore convolution in section~\\ref{sc:convolution}.\n\n\\paragraph*{\\textsc{Optional:} When $\\alpha$ is a complex number, $\\alpha=Re^{j\\theta}$:}\n\nWhen $\\alpha=Re^{j\\theta}$, equations~(\\ref{eq:zt-expof})\nand~(\\ref{eq:zt-expoF}) become\n\\begin{equation}\nx[n] = \\left\\{\\begin{array}{ll}\n                        R^ke^{jn\\theta} & \\quad  n \\ge 0 \\\\\n                        0             & \\quad n < 0\n          \\end{array}\\right.\n\\end{equation}\n\n\\begin{equation}\nX(z)=\\frac{1}{1-Re^{j\\theta}z^{-1}}, \\quad |z|>|R|\n\\label{eq:zt-expo-cF}\n\\end{equation}\n\nWhen $z=Re^{j\\theta}$ we have what we call a \\emph{pole} (a zero in the\ndenominator; you'll learn more about this in\nChapter~\\ref{ch:fb-filters}). Equation~(\\ref{eq:zt-expo-cF}) can be\nbroken into real and imaginary parts using Euler's formula:\n\\begin{align}\nX(z) &= \\frac{1}{1-Re^{j\\theta}z^{-1}} \\notag\\\\\n     &= \\frac{1}{1-R(\\cos\\theta+j \\sin\\theta )z^{-1}} \\notag\\\\\n     &= \\frac{1}{1-R\\cos\\theta z^{-1}-j R\\sin\\theta z^{-1}} \\notag\\\\\n     &= \\frac{1-R\\cos\\theta z^{-1}+j R\\sin\\theta z^{-1}}\n     {[1-R\\cos\\theta z^{-1}]^2 - [jR\\sin\\theta z^{-1}]^2} \\notag\\\\\n     &= \\frac{1-R\\cos\\theta z^{-1}+j R\\sin\\theta z^{-1}}\n     {1-2R\\cos\\theta z^{-1} + R^2 z^{-2}} \\notag\\\\\n     &= \\frac{1-R\\cos\\theta z^{-1}}\n     {1-2R\\cos\\theta z^{-1} + R^2 z^{-2}}\n     +j\\frac{R\\sin\\theta z^{-1}}\n     {1-2R\\cos\\theta z^{-1} + R^2 z^{-2}}\n\\end{align}\n\nWe break the signal into two parts, too:\n\\begin{align}\n\\Real\\{x[n]\\} &= R^n\\cos(k\\theta), \\quad n\\ge 0\\\\\n\\Imag\\{x[n]\\} &= R^n\\sin(k\\theta), \\quad n\\ge 0\n\\end{align}\nFrom real part we get\n\\begin{equation}\nR^n\\cos(n\\theta)\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} \\\n\\frac{1-R\\cos\\theta z^{-1}}\n{1-2R\\cos\\theta z^{-1} + R^2 z^{-2}}\n\\end{equation}\nand from imaginary parts we have\n\\begin{equation}\nR^n\\sin(n\\theta)\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} \\\n\\frac{R\\sin\\theta z^{-1}}\n{1-2R\\cos\\theta z^{-1} + R^2 z^{-2}}\n\\end{equation}\n\nWhen $R<1$, $R^n\\cos(n\\theta)$ and $R^n\\sin(n\\theta)$ are damped\ncosine and sine waves.\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex5}--\\ref{it:ch6ex7} for answers.\n\n\\begin{enumerate}\n\\item What is the derivative of $u[n-k]$ (the unit step at time step\n  $k$)?\n\\item Show that $e^{j\\hat{\\omega}/2}-e^{-j\\hat{\\omega}/2} =\n  2j\\sin\\hat{\\omega}/2$.\n\\item Prove that $e^{-j\\pi/2}=-j$.\n\\end{enumerate}}\n\n\\section{Convolution}\n\\label{sc:convolution}\n\n\\index{convolution!discrete!definition} Convolution is an important\noperation for implementing digital filters.  Let's first define what\nconvolution is. For two infinite, discrete signals $x[n]$ and $h[n]$,\nthe \\emph{convolution} $y[n]$ of them at sample $n$ is defined as\n\\begin{equation}\ny[n] = \\sum_{k=-\\infty}^{\\infty} h[k] x[n-k]\n\\label{eq:convolution}\n\\end{equation}\nThe notation for convolution is ``$\\ast$'', so this can be written as \n\\begin{equation}\nY = X \\ast H\n\\end{equation}\nwhere $Y$, $X$, and $H$ are the signals with samples at $n$ being\n$y[n]$, $x[n]$, and $h[n]$.\n\nLet's consider the case when both $x$ and $h$ both start at zero. This\nis equivalent to saying that both have values of zero before that\nsample. So, $h[k] = 0$ when $k<0$ and $x[n-k]=0$ when\n$n-k<0$. Equation~(\\ref{eq:convolution}) becomes\n\\begin{equation}\ny[n] = \\sum_{k=0}^{n} h[k] x[n-k]\n\\label{eq:zt-conv}\n\\end{equation}\nActually, this is a more realistic situation than $k$'s summation\nfrom $-\\infty$ to $\\infty$.\n\nWe expand the summation in~(\\ref{eq:zt-conv}) as\n\\begin{multline}\ny[n] = h[0] x[n] + h[1] x[n-1] + h[2] x[n-2] + \\ldots + h[k] x[n-k]\n       + \\ldots \\\\\n       {}+ h[n-2] x[2] + h[n-1] x[1] + h[n] x[0]\n\\label{eq:zt-conv-exp}\n\\end{multline}\nUsing this formulation, you may show that the convolution $X \\ast H$ has the\nfollowing properties:\n\\begin{enumerate}\n\\item Commutative: $X \\ast H=H \\ast X$\n\\index{convolution!commutative property}\n\\item Distributive :  $X \\ast (H_1 + H_2)=X \\ast H_1 + X \\ast H_2$\n\\index{convolution!distributive property}\n\\item Associative : $(X \\ast H) \\ast G = X \\ast (H \\ast G)$\n\\index{convolution!associative property}\n\\end{enumerate}\nYou should be able to convince yourself that $x \\ast \\vec{0} = \\vec{0}\n\\ast x = 0$ (where $\\vec{0}$ is a vector of all zeros). How about\n$\\vec{1} \\ast \\vec{1}$ (where $\\vec{1}$ is a vector of all ones, in\nthis case $\\vec{1}=u[n]$; see the self-test exercise)?\n\n\\subsection{Example of Convolution}\n\nDetermine the convolution $e^n \\ast e^n$, $n=0,1,2,\\ldots,\n$. Using~(\\ref{eq:zt-conv}),\n\\begin{align}\ne^n \\ast e^n &= \\sum_{k=0}^{n}e^ke^{n-k} \\notag\\\\\n             &= \\sum_{k=0}^{n}e^n=e^n\\sum_{k=0}^{n}1=ne^n\n\\end{align}\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex8}--\\ref{it:ch6ex9} for answers.\n\n\\begin{enumerate}\n\\item Determine if $u[n] \\ast H \\ne H$ is true, where $h[n] = n$,\n$n=0,1,2,\\ldots$ (a \\emph{ramp}).\n\\item Compute $u[n] \\ast u[n]$.\n\\end{enumerate}}\n\n\\subsection{Implementing Convolution}\n\n\\index{convolution!discrete!implementation}\nFrom observation of equation~(\\ref{eq:zt-conv-exp}), we know that for\na fixed sample $n$, $y[n]$ can be computed by the term-by-term\nmultiplication of the sequence\n\\begin{equation}\n\\{h[0], h[1], h[2], \\ldots, h[k], \\ldots, h[n-2], h[n-1], h[n]\\}\n\\end{equation}\nand the time-reversed sequence\n\\begin{equation}\n\\{x[n], x[n-1], x[n-2], \\ldots, x[n-k] , \\ldots, x[2], x[1], x[0]\\}\n\\end{equation}\nWe just multiply the corresponding terms (for example, $h[k]x[n-k]$),\nthen add these products. This produces the convolution for one sample\n$n$.  Remember, however, that the output $y[n]$ is also a sequence,\n$n=0,1,2,\\ldots$. We need to repeat this process for all $\\{n\\}$ to\nget the full sequence, as shown in algorithm~\\ref{alg:convolution}.\n \n\\begin{algorithm}\n\\caption{Discrete convolution.\\label{alg:convolution}}\n\\begin{algorithmic}\n\\REQUIRE $h[n]$ is a finite, discrete signal, $n = 0, 1, 2, \\ldots$\n\\REQUIRE $x[n]$ is a finite, discrete signal, $n = 0, 1, 2, \\ldots$\n\\ENSURE $y[n]$ is the convolution $X * H$, $n = 0, 1, 2, \\ldots$\n\\FOR{$n=0, 1, 2, \\ldots$}\n   \\STATE Reverse $x[k]$ to produce $x'[k] = x[n-k]$, $k = 0, 1, 2,\n          \\ldots, n$\n   \\STATE $s[k] = h[k] x'[k]$\n   \\STATE $y[n] = \\sum_{k=0}^n s[k]$\n\\ENDFOR\n\\end{algorithmic}\n\\end{algorithm}\n\nA more-or-less direct implementation of this algorithm in C is:\n\n\\index{C code!convolution|(}\n\\begin{small}\n\\begin{verbatim}\n/* Convolution of two vectors\n\n   Input: vectors x and h of lengths nx and nh (nh < nx)\n   Output: vector y of length nx + nh - 1 (storage already allocated)\n */\nvoid convolve(int x[], unsigned nx, int h[], unsigned nh, int y[])\n{\n   for (unsigned n=0; n<nx+nh-1; n++) {\n      y[n] = 0;\n      for (unsigned k=max(0,n-nh+1); k<=min(nx-1,n); k++)\n         y[n] += x[k] * h[n-k];\n   }\n}\n\\end{verbatim}\n\\end{small}\n\\index{C code!convolution|)}\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=\\textwidth]{ch-conv/fig6-5}}\n\\caption{Example of convolution function execution for $n_x=5$ and\n$n_h=2$.\\label{fg:convex}}\n\\end{figure}\n\nYou'll notice something nasty was done here: the identities of\n$x$ and $h$ were reversed! Of course, this is perfectly OK, given the commutative\nproperty of convolution. This was done because we generally assume that $h$\n(the shorter vector) is a property of the filter (we will see about\nthis later) and it is easier to think about reversing\nit than reversing the signal $x$. If for no other reason, this makes\nsense because $h$ has a shorter length.\n\nThe implementation is for finite-length signals, rather than the\ninfinite ones we've been discussing. It assumes that $h$ is shorter\nthan $x$ ($n_h < n_x$). This $h$ input is often called the convolution\n\\emph{kernel} because, as we shall see, $h$ represents the\n\\index{convolution!kernel}\naction of our signal processing system while $x$ is the actual input\nsignal.  Notice that, for small $n<n_h-1$, not all of $h$ is\nused. This is equivalent to multiplying the unused elements of $h$\nagainst the zero values of $x[k]$, $k<0$. Similarly, for large\n$n>nx-1$, part of $h$ is also unused --- multiplied against the zero\nvalues of $x[k]$, $k>n_x-1$. Figure~\\ref{fg:convex} illustrates\nfunction execution for a signal $X$ of length 5 and a kernel $H$ of\nlength 2. This is one way to deal with the \\emph{boundary conditions}\n\\index{convolution!boundary conditions}\nassociated with the convolution: what to do at the ends of the\nsignal $X$.  In general, there are three ways of dealing with these\nboundary conditions:\n\\begin{enumerate}\n\\item ``Pad'' $X$ with zeros past its ends. In effect, this is what\nwas done in the code above.\n\\item ``Reflect'' $X$ by copying element $k$ to index $-k$. This is\nsometimes done in image processing operations.\n\\item ``Truncate'' the convolution at the ends of $X$. This means that\n$n$ would cover the range $n_h-1 \\leq n \\leq n_x$ and $Y$ would be\nshorter than $X$.\n\\end{enumerate}\n\n\\index{MATLAB code!convolution}\nMATLAB has the built-in convolution function \\verb|conv|, which takes\ntwo vectors as inputs and outputs the convolution result with length\nequal to one less than the sum of the two input vector lengths. You\ncan use ``\\verb|help conv|'' to get more information (how does\n\\verb|conv| deal with boundary conditions [answer in~\\ref{sc:ch6ex}\n\\#\\ref{it:ch6ex10}]?)\n\n\\begin{figure}\n\\centerline{\\includegraphics[width=4in]{ch-conv/zt_conv_etet}}\n\\caption[Convolution of $e^n \\ast e^n$]{Convolution of $e^n \\ast\n  e^n$. Top blue line is $e^n$, top red line is time reversed version\n  of $e^n$, the bottom plot is the result of convolution.\n  \\label{fig:zt-conv-etet}}\n\\end{figure}\n\nLet's look at the convolution of $X \\ast H =e^n \\ast e^n$ again. In\nthis case, $X$ and $H$ are the same function. In\nfigure~\\ref{fig:zt-conv-etet} (top), $X$ is shown as a blue curve and\nthe time-reversed $H$ is shown as a red curve. The convolution result\nis in the bottom graph.\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex11} for the answer.\n\n\\begin{enumerate}\n\\item Use MATLAB to compute the convolution $e^{-n}*e^{-n}$ and plot\nthe result.\n\\end{enumerate}}\n\n\\section{Properties of the Z-Transform}\n\n\\index{z-transform!properties of}\n\\begin{table}\n\\caption{Some properties of the z-transform.\\label{tb:zt-property}}\n\\begin{center}\n\\begin{tabular}{|l|c|c|} \\hline\nProperty      & Time Domain, $Z^{-1}\\{\\cdot\\}$ & z-Domain, $Z\\{\\cdot\\}$ \\\\ \\hline\\hline\nLinearity     & $a_1x[n]+a_2y[n]$ & $a_1X(z)+a_2Y(z)$\\\\ \nTime shift    & $x[n-k]$       & $z^{-k}X(z)$\\\\ \nScaling in the z-domain \n              & $a^nx[n]$        & $X(a^{-1}z)$ \\\\ \nTime reversal & $x[-n]$        & $X(z^{-1})$\\\\ \nDifferentiation in the z-domain \n              & $nx[n]$          & $-z \\deriv{X(z)}{z}$ \\\\ \nConvolution   & $x[n] \\ast y[n]$       & $X(z)Y(z)$ \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\nThe z-transform is a very powerful signal processing tool because it\nhas some very important properties. Some of these properties are\nlisted in\ntable~\\ref{tb:zt-property}, where the time-domain signals $x[k]$\nand $y[k]$ have z-transforms of $X(z)$ and $Y(z)$.\n\nKnowing these properties can be very convenient. For example, the\nz-transform of a signal shifted (delayed) by $k$ samples, $x[n-k]$,\nis $z^{-k}X(z)$; this is our familiar $z$ (delay) operator. You can\n\\index{z-transform!relation to $z$ operator}\n\\index{z-transform!and delay}\nalso see that the convolution property of the z-transform means that\nconvolution in the time domain is multiplication in the z-domain. So,\nif we have the z-transform of two signals, it is much easier to\nperform convolution.  Later on, you will find out that this is very\nimportant in filtering. Let's prove this property:\n\nFrom~(\\ref{eq:zt-conv}) a convolution of $x[n]$ and $h[n]$ is defined as:\n\\begin{equation}\ny[n] = x[n] \\ast h[n] = \\sum_{k=-\\infty}^{\\infty} h[k] x[n-k]\n\\end{equation}\nThe z-transform of $y[n]$ is \n\\begin{align}\nY(z) &= \\sum_{n=-\\infty}^{\\infty} y[n]z^{-n} \\notag\\\\\n     &= \\sum_{n=-\\infty}^{\\infty}\n     \\left( \\sum_{k=-\\infty}^{\\infty} h[k] x[n-k] \\right)z^{-n}\n\\end{align}\nInterchanging the order of the summations (which is equivalent to\nfactoring out the $h[k]$ and distributing the $z^{-n}$ over the inner\nsummation),\n\\begin{equation}\nY(z) = \\sum_{k=-\\infty}^{\\infty} h[k]\n             \\left( \\sum_{n=-\\infty}^{\\infty} x[n-k] z^{-n} \\right)\n\\end{equation}\nThe inner summation is merely the z-transform of $x[n]$ shifted by $k$\nsamples.  Applying the time shift property of the z-transform, we\nobtain\n\\begin{align}\nY(z) &= \\sum_{k=-\\infty}^{\\infty} h[k] X(z) z^{-k} \\notag\\\\\n     &= X(z)\\sum_{k=-\\infty}^{\\infty} h[k] z^{-k} \n     = X(z) H(z)\n\\end{align}\nWhich is the product of the two z-transforms. I'll present a couple\nexamples of using these properties.\n\n\\subsection{Example: Time Shifting}\n\n\\index{z-transform!of a time-shifted impulse}\nRemember that the z-transform of the unit impulse\n$\\delta[n]$ was discussed in section~\\ref{sc:zx-impulse}\n\\begin{equation}\n\\delta[n] = \\left\\{\\begin{array}{ll}\n                        1 & n=0 \\\\\n                        0 & n \\neq 0\n          \\end{array}\\right.\n\\end{equation}\nas being 1 and that the z-transform of the shifted unit impulse\n$\\delta[n-k]$ is $z^{-k}$? Using the time-shifting property of the\nz-transform, this is easy to determine:\n\\begin{equation}\n\\delta[n]\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} 1\n\\end{equation}\nthen \n\\begin{equation}\n\\delta[n-k]\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} 1 \\times z^{-k}=z^{-k}\n\\end{equation}\n\n\\subsection{Example: Convolution}\n\n\\index{z-transform!computing convolution with}\nGiven the signals \n\\begin{equation}\nx[n] = \\{1, -3, 2, 1\\}, \\quad n = 0,1,2,3\n\\end{equation}\nand \n\\begin{equation}\nh[n] = \\left\\{\\begin{array}{ll}\n                        1 &  n=0,1\\\\\n                        0 &  n=2,3\n          \\end{array}\\right.\n\\end{equation}\nuse the z-transform to compute their convolution $Y = X \\ast H$.\n\nAccording to~(\\ref{eq:zt}),\n\\begin{align}\nX(z) &= 1-3z^{-1}+2z^{-2}+z^{-3}\\\\\nH(z) &= 1+z^{-1}\n\\end{align}\nThen using the convolution property of the z-transform, we have \n\\begin{align}\nY(z)=X(z)H(z)\n&= (1-3z^{-1}+2z^{-2}+z^{-3})(1+z^{-1}) \\notag\\\\\n&= 1-2z^{-1}-z^{-2}+3z^{-3}+z^{-4}\n\\end{align}\nNow we can easily get the inverse z-transform $y[n]=x[n] \\ast h[n]$ from the\nresult $Y(z)$. Again from the z-transform\ndefinition~(\\ref{eq:zt}),\n\\begin{equation}\ny[n] = x[n] \\ast h[n] = \\{1,-2, -1, 3, 1\\}\n\\end{equation}\n\nWe can also compute the convolution directly, according to the\nconvolution definition~(\\ref{eq:zt-conv}). There are only 4 nonzero\nterms in $x[n]$ and 2 in $h[n]$. For a fixed sample $n$, the\nconvolution is given by\n\\begin{align}\ny[n] &= \\sum_{k=0}^{n} x[k] h[n-k] \\notag\\\\\n     &= x[0] h[n] + x[1] h[n-1] + x[2] h[n-2] + x[3] h[n-3]\n\\end{align}\nChanging $n$ gives the sequence of the convolution output as a\nfunction of time. In the following computation, $h[n-k]=0$ is used,\nif $n-k<0$ and $x[k]=0$ and $h[k]=0$ if $k>3$:\n\\begin{align*}\ny[0] &= x[0] h[0] = 1\\\\\ny[1] &= x[0] h[1] + x[1] h[0] = 1-3 = -2\\\\\ny[2] &= x[0] h[2] + x[1] h[1] + x[2] h[0] = 0-3+2 = -1\\\\\ny[3] &= x[0] h[3] + x[1] h[2] + x[2] h[1] +x[3] h[0] = 0+0+2+1 = 3\\\\\ny[4] &= x[1] h[3] + x[2] h[2] + x[3] h[1] = 0+0+1 = 1\\\\\ny[n] &= 0, \\quad n>4\n\\end{align*}\nTherefore, this also gives the result\n\\begin{equation}\ny[n] = x[n] \\ast h[n] = \\{1,-2, -1, 3, 1\\}\n\\end{equation}\n\n\\problemset{\n\\subsubsection{Self-Test Exercises}\n\nSee~\\ref{sc:ch6ex} \\#\\ref{it:ch6ex12} for the answer.\n\n\\begin{enumerate}\n\\item Prove the scaling property of the z-transform; that is, if \n  \\begin{equation*}\n    x[n]\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} X(z)\n  \\end{equation*}\n  then \n  \\begin{equation*}\n    a^n x[n]\\stackrel{\\mathbf{Z}}{\\longleftrightarrow} X(a^{-1}z)\n  \\end{equation*}\n\\end{enumerate}}\n\n\\section{Impulse Response and the Transfer Function}\n\nRecall the a filter's input/output relationship is summarized by the\ntransfer function discussed in chapter~\\ref{ch:filt-intro} (and which\nyou'll see again in chapter~\\ref{ch:fb-filters}). Let's denote the\ninput signal as $x[n]$ and output as $y[n]$ in the time domain. You\nlearned that the the transfer function in the z domain is $H(z)$. What\nis its time domain representation? We will answer this shortly; first\nlet's give a name to the time domain transfer function,\n$h[n]$: the filter's\n\\emph{impulse response}. The filter's input/output relationship can be\n\\index{filter!impulse response}\nwritten using $h[n]$ as:\n\\begin{equation}\ny[n] = x[n] \\ast h[n]\n\\label{eq:zt-hx}\n\\end{equation}\nThis says that the output of filter results from the convolution\nbetween input signal $x[n]$ and filter's impulse response $h[n]$. From\nearlier in this chapter, you now know that convolution of two signals\nin the time domain is equivalent to multiplying their z-transforms in\nthe $z$ domain. So, we obtain the input/output relationship via the\ntransfer function in the $z$ domain as\n\\begin{equation}\nY(z) =X(z)H(z)\n\\label{eq:zt-HX}\n\\end{equation}\nwhere $X(z)$ and $Y(z)$ are the z-transforms of $x[n]$ and $y[n]$ and\n$H(z)$ is the z-transform of $h[n]$.  Actually, this $H(z)$ is just\nthe transfer function we talked about in chapter~\\ref{ch:filt-intro}.\nIn other words, a filter's transfer function is the z-transform of its\nimpulse response!\n\\index{z-transform!relationship to filter transfer function}\n\\index{filter!transfer function!relationship to its z-transform}\n\n\\index{filter!transfer function!determining with z-transform}\nAs a simple example of how to use the z-transform to determine a\nfilter's transfer function from its defining equation, consider the\nfeedforward filter:\n\\begin{equation}\ny[n] = b_0x[n] + b_1x[n-k]\n\\end{equation}\n\nApplying the z-transform to both sides, \n\\begin{equation}\nY(z) = b_0X(z) + b_1z^{-k}X(z)\n\\end{equation}\nbecause of the time shift property of the z-transform. This can be\nrearranged to be\n\\begin{equation}\nY(z) = (b_0 + b_1z^{-k})X(z)\n\\end{equation}\nSo the transfer function is \n\\begin{equation}\nH(z) = b_0 + b_1z^{-k}\n\\end{equation}\nand therefore, we have\n\\begin{equation}\nY(z)=H(z)X(z)\n\\end{equation} \n\nApplying the inverse z-transform, we can get the time domain\nrepresentation of $H(z)$, or the impulse response $h[n]$. In a similar\nmanner, we can get the output $y[n]$ from $Y(z)$.  In fact,\nusing~(\\ref{eq:zt-HX}), we found an easy way to compute a filter's\nresponse to a signal if we have already know the signal's z-transform\nand the filter's transfer function.\n\nLet's see why $h[n]$ is called the impulse response.  Remember the unit\nimpulse, which is a signal that has the value one at $n=0$ and zero\notherwise, and which can be expressed as\n\\begin{equation}\n\\delta[n] = \\left\\{\\begin{array}{ll}\n                        1 & n=0 \\\\\n                        0 & n \\neq 0\n          \\end{array}\\right.\n\\end{equation}\n\nThe impulse response of a filter is its output when a unit impulse is\napplied. Now we compute these two functions' convolution,\n\\begin{equation}\ny[n]=\\sum_{k=0}^{n}\\delta[k] h[n-k] = h[n]\n\\end{equation}\nbecause all of the terms except $k=0$ drop out (since $\\delta[k]=0$\nfor all $k \\ne 0$).  This tell us that the filter response $y[n]$ to a\nunit impulse is $h[n]$. This is why $h[n]$ is called the impulse\nresponse.\n\nApplying the z-transform to both side of the above equation, we get\n\\begin{equation}\nY(z)= H(z)\n\\end{equation}\nTherefore, the \\emph{transfer function} can be viewed as the\nz-transform of the filter's \\emph{impulse response}, or its impulse\nresponse in the $z$ domain.\n\nIf we restrict $z$ to lie on the unit circle, $z=e^{j\\hat{\\omega}}$,\nfrom~(\\ref{eq:zt-HX}) we obtain\n\\begin{equation}\n\\mathcal{Y}(\\hat{\\omega})=\\mathcal{H}(\\hat{\\omega})\\mathcal{X}(\\hat{\\omega})\n\\end{equation} \nwhere $\\mathcal{X}(\\hat{\\omega})$ is the signal's frequency content,\n$\\mathcal{Y}(\\hat{\\omega})$ is the frequency content of the filter\noutput and $\\mathcal{H}(\\hat{\\omega})$ is the filter's frequency\nresponse.\n\n\n\\section{Problems}\n\n\\begin{enumerate}\n\\item Compute the z-transform of \n\\begin{equation}\nx[n] = \\left\\{\\begin{array}{ll}\n                        (-1)^n & n \\ge 0 \\\\\n                        0 & n < 0\n          \\end{array}\\right.\n\\end{equation}\nand determine its frequency content. \n\n\\item Determine the z-transform of the signal \n\\begin{equation}\nx[n] = \\left\\{\\begin{array}{ll}\n                        \\cos\\hat{\\omega}_0 n & n \\ge 0 \\\\\n                        0 & n < 0\n          \\end{array}\\right.\n\\end{equation}\n\n\\item Find the z-transform of the signal\n\\[x[n] = \\left\\{\\begin{array}{ll} 1/n! & n \\geq 0 \\\\\n                0 & n < 0 \\end{array} \\right. \\]\nRecall that $0!=1$.\n\n\\item The impulse response of a system is $h[n]=\\{1,2,1,-1\\}$, $n=-1,\n0,1,2$. Determine the response of the system to the input signal\n$x[n]=\\{1,2,3,1\\}$, $n=0, 1,2,3$.\n\n\\end{enumerate}\n\n\n\\section{Further Reading}\n\n\\begin{itemize}\n\\item James H McClellan, Ronald W. Schafer, and Mark A. Yoder,\n  \\textit{DSP First: A Multimedia Approach}, Prentice Hall, 1998,\n  chapter 7 (\\S 7.1--7.6.3).\n\\end{itemize}\n\n% LocalWords:  DTFT signal's feedforward\n", "meta": {"hexsha": "ebadc18899da0916fd0869f7111843c6299d5da4", "size": 36665, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-conv/convolution.tex", "max_stars_repo_name": "stiber/Signal-Computing", "max_stars_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-09-10T16:54:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T15:48:26.000Z", "max_issues_repo_path": "ch-conv/convolution.tex", "max_issues_repo_name": "stiber/Signal-Computing", "max_issues_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2015-08-18T18:16:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-29T17:19:16.000Z", "max_forks_repo_path": "ch-conv/convolution.tex", "max_forks_repo_name": "stiber/Signal-Computing", "max_forks_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2990844354, "max_line_length": 89, "alphanum_fraction": 0.6724123824, "num_tokens": 12214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.42951422040427434}}
{"text": "\\section{Joint inversion}\\label{sec:joint}\nThe term joint inversion denotes the simultaneous inversion of a number of different data types.\nWe can classify different types according to the relation of the associated parameters:\n\\begin{enumerate}\n\t\\item Identical parameters is historical the classical joint inversion, e.g. both DC and EM aim at $\\rho$.\n\t\\item Parameters are indirectly connected by petrophysical relations, e.g. ERT and GPR both aiming at water content.\n\t\\item Independent parameters. In this case only the structures can be linked to each other. For simple models this can involve the inversion of the geometry. For fixed models structural information is exchanged\\footnote{Note that this type is formally a structurally coupled cooperative inversion.}.\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Classical joint inversion of DC and EM soundings}\\label{sec:jointdcem}\nFile \\file{doc/tutorial/code/joint/dcem1dinv.cpp}\\\\\nFirst, let us consider to jointly invert different electromagnetic methods, e.g. direct current (DC) and Frequency Domain Electromagnetic (FDEM).\nFor the latter we assume a two-coil system in horizontal coplanar model with 10 frequencies between 110\\,Hz and 56\\,kHz.\nWhereas DC resistivity yields apparent resistivities, the FDEM data are expressed as ratio between secondary and primary field in per cent.\n\nThe two ready methods \\lstinline|DC1dModelling| and \\lstinline|FDEM1dModelling| are very easily combined since they use the same block model.\nIn the response function the two vectors are combined.\nWe create a new modelling class that derives from the base modelling class\\footnote{In order to use the classes, \\file{dc1dmodelling.h} and \\file{em1dmodelling.h} have to be included.} and has two members of the individual classes, which must be initialized in the constructor.\nAlternatively we could derive from one of the two classes and use only a member of the other.\n\n\\begin{lstlisting}[language=C++,morekeywords={RVector,RMatrix}]\nclass DCEM1dModelling : public ModellingBase {\npublic:\n    DCEM1dModelling( size_t nlay, RVector & ab2, RVector & mn2, \n                     RVector & freq, double coilspacing, bool verbose ) : \n    \tModellingBase( verbose ), // base constructor\n    \tfDC_( nlay, ab2, mn2, verbose ), // FDEM constructor\n    \tfEM_( nlay, freq, coilspacing, verbose ) { // DC constructor \n          setMesh( createMesh1DBlock( nlay ) ); // create mesh\n    }\n    RVector response( const RVector & model ){ // paste together responses\n        return cat( fDC_.response( model ), fEM_.response( model ) ); \n    }\nprotected:\n    DC1dModelling fDC_;\n    FDEM1dModelling fEM_;\n};\n\\end{lstlisting}\n\nIn the response function both response functions are called and combined using the cat command.\nWe set the usual transformation (log for apparent resistivity and logLU for the resistivity) and inversion (Marquardt scheme) options as above.\nIn case of identical responses (e.g. apparent resistivities) this would be the whole thing.\nHere we have to care about the different data types (cf. section \\ref{sec:mt1d}), i.e. always positive, log-distributed $\\rho_a$ from DC and possibly negative, linearly distributed, relative magnetic fields.\nThe transformations are again combined using \\lstinline|CumulativeTrans|\n\\begin{lstlisting}[language=C++,morekeywords={RVector,RMatrix}]\n    RTransLog transRhoa;\n    RTrans transEM;\n    CumulativeTrans< RVector > transData;\n    transData.push_back( transRhoa, ab2.size() );\n    transData.push_back( transEM, freq.size() * 2 );\n\\end{lstlisting}\n\nIn the code we create a synthetic model \\lstinline|synthModel|, calculate the forward response and noisify it by given noise levels.\n\n\\begin{lstlisting}[language=C++,morekeywords={RVector,RMatrix}]\n    /*! compute synthetic model (created before) by calling f */\n    RVector synthData( f( synthModel ) );   \n    /*! error models: relative percentage for DC, absolute for EM */\n    RVector errorDC = synthData( 0, ab2.size() ) * errDC / 100.0;\n    RVector errorEM( freq.size() * 2, errEM );\n    RVector errorAbs( cat( errorDC, errorEM ) );    \n    /*! noisify synthetic data using the determined error model */\n    RVector rand( synthData.size() );\n    randn( rand );\n    synthData = synthData + rand * errorAbs;\n\\end{lstlisting}\n\nThe inversion is converging to a $\\chi^2$ value of about 1, i.e. we fit the data within error bounds.\nFinally a resolution analysis is done to determine how well the individual parameters (2 thickness and 3 resistivitiy values) are determined.\nWe can compare it with single inversions by drastically increasing the error level for one of the methods by a factor of 10.\nTable \\ref{tab:dcemresolution} shows the resulting diagonal values of the resolution matrix for a three-layer model.\nThe first layer is well resolved in all variants except the first layer resistivity for EM.\nConsidering the values for the other resistivities we can clearly see that EM is detecting the good conductor and DC describes the resistor as expected from the theory.\n\n\\begin{table}[h]%\n\\centering\n\\begin{tabular}{r|ccccc}\nMethod & $d_1$=20\\,m & $d_2$=20\\,m & $\\rho_1$=200\\,$\\Omega$m & $\\rho_2$=10\\,$\\Omega$m & $\\rho_3$=50\\,$\\Omega$m \\\\ \\hline\nJoint inversion: & 0.98 & 0.46 & 0.98 & 0.67 & 0.57 \\\\\nEM dominated:    & 0.97 & 0.36 & 0.71 & 0.66 & 0.20 \\\\\nDC dominated:    & 0.96 & 0.21 & 0.97 & 0.32 & 0.62  \n\\end{tabular}\n\\caption{Resolution measures for Joint inversion and quasi-single inversions using an error model increased by a factor of 10.}\\label{tab:dcemresolution}\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Block joint inversion of DC/MRS data}\\label{sec:blockjoint}\n%File \\file{doc/tutorial/code/joint/dc\\_mt\\_block1d.cpp}\\\\\nIf the underlying parameters of the jointed inversion are independent, a combination can only be achieved via the geometry.\nFor the case of a block 1d discretization both methods are affected by the layer thicknesses.\n%We use the same methods as before \\sperre\n\nSimilar to the above example, we create a combined modelling class that is derived from one method, in this case \\lstinline|MRS1DBlockModelling|.\nThis one is a block model (water content and thickness) variant of the magnetic resonance sounding (MRS) modelling \\lstinline|MRSModelling|.\nThe class has a DC resistivity forward modelling and holds the number of layers \\lstinline|nlay|.\n\nThe model is created in the constructor using \\lstinline|createMesh1DBlock( nlay, 2 )| that is able to hold, additionally to the thickness (region 0), multiple properties, here water content (region 1) and resistivity (region 2).\nFrom the model vector the thickness, water content (or their combination) and resistivity has to be extracted and the result of the two forward calls are combined using the cat command.\nThe Jacobian is by default brute force, which is quite cheap for block models.\n\n\\begin{lstlisting}[language=C++,morekeywords={RVector,RMatrix}]\nclass DC_MRS_BlockModelling : public MRS1dBlockModelling{\npublic:\n    DC_MRS_BlockModelling( size_t nlay, DataContainer & data, RMatrix & KR,\n                           RMatrix & KI, RVector & zvec, bool verbose ) :\n        MRS1dBlockModelling( nlay, KR, KI, zvec, verbose ), nl_( nlay ) { \n            setMesh( createMesh1DBlock( nlay, 2 ) ); //two-properties\n            Mesh mymesh = createMesh1DBlock( nlay ); //single block mesh\n            fDC_ = new DC1dModelling( mymesh, data, nlay, verbose );\n        }\n    virtual ~DC_MRS_BlockModelling( ){ delete fDC_; }\n    \n    RVector response( const RVector & model ){\n        //! extract resistivity, watercontent & thickness from model vec\n        RVector thk( model, 0 , nl_ - 1 );\n        RVector wcthk( model, 0 , nl_ * 2 - 1 );\n        RVector res( model, nl_ * 2 - 1 , nl_ * 3 - 1 );\n        return cat( MRS1dBlockModelling::response( wcthk ), \n                    fDC_->rhoa( res, thk ) );\n    }\nprotected:\n    DC1dModelling *fDC_;\n    int nl_;\n};\n\\end{lstlisting}\n\nIn order to use the class, we have to build a cumulative data transform as in subsection \\ref{sec:mt1d}.\nModel transformations are logarithmic to ensure positive values, additionally an upper bound of 0.4 is defined for the water content.\n\\begin{lstlisting}[language=C++,morekeywords={RVector,RMatrix}]\n    RTrans transVolt;    // linear voltages\n    RTransLog transRhoa; // logarithmic apparent resistivities\n    CumulativeTrans< RVector > transData;\n    transData.push_back( transVolt, errorMRS.size() );\n    transData.push_back( transRhoa, dataDC.size() );\n    RTransLog transRes;\n    RTransLogLU transWC(0.0, 0.4);\n    RTransLog transThk;\n\\end{lstlisting}\n\nIn order to achieve a Marquardt inversion scheme, the constraint type is set to zero for all regions:\n\\begin{lstlisting}\n    f.regionManager().setConstraintType( 0 );\n\\end{lstlisting}\nAppropriately, the transformations and starting values are set.\n\\begin{lstlisting}\n    f.region( 0 )->setTransModel( transThk );\n    f.region( 0 )->setStartValue( 5.1 );\n    f.region( 1 )->setTransModel( transWC );\n    f.region( 1 )->setStartValue( 0.1 );\n    f.region( 2 )->setTransModel( transRes );\n    f.region( 2 )->setStartValue( median( dataDC.rhoa() ) );\n\\end{lstlisting}\n\nWe use a synthetic model of three layers representing a vadoze zone ($\\rho=500\\Omega$m, 0.1\\% water, 4m thick), a saturated zone ($\\rho=100\\Omega$m, 40\\% water content, 10m thick) and a bedrock ($\\rho=2000\\Omega$m, no water).\n3\\,\\% and 20\\,nV Gaussian noise are added to the DC and MRS data, respectively.\nFigure~\\ref{fig:blockjoint} shows the result of the combined inversion, which is very close to the synthetic model due to the improved information content from two models.\n\n\\begin{figure}[htb]\n\\centering\\includegraphics[width=0.9\\textwidth]{dc_mrs_blockjoint}\n\\caption{Joint inversion result of block-coupled DC resistivity (left) and MRS (right) sounding.}\\label{fig:blockjoint}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Structurally coupled cooperative inversion of DC and MRS soundings}\\label{sec:structjoint}\nFile \\file{doc/tutorial/code/joint/dc\\_mrs\\_joint1d.cpp}\\\\\nIn many cases it is not clear whether the model boundaries observed by different methods are identical or how many of them are existing.\nNevertheless we expect a similarity of the structure, i.e. the gradients.\nOn smooth model discretizations of any dimension the exchange of geometrical information can be achieved using the constraint control function \\citep{guerue06nearsurface}.\nMain idea is to decrease the weight for the roughness operator of one method depending on the partial derivative of the other.\nA large roughness as a possible interface should enable the interface on the other side by a low weight.\nThere are different possible functions for doing so.\nOriginally, a iteratively re-weighted least squares scheme was proposed that incorporates the whole distribution.\nHere we use a simple function\n\\begin{equation}\n    w_c(r) = \\frac{a}{|r|+a}+a\n\\end{equation}\nwhere $w_c$ is the weight, $r$ is the roughness value and $a$ is a small quantity.\nFor $r\\rightarrow 0$ the weight $w_c=1+a$ lies slightly above 1, for $r\\rightarrow\\infty$ it becomes $a$.\n\nIn this case we apply it to DC resistivity and MRS sounding for a smooth 1d model.\nThe latter operator is linear and thus realized by a simple matrix vector multiplication of the kernel function and the water content vector.\nWe initialise the two independent inversions and run one iteration step each.\nIn the iteration loop we calculate the function of one roughness and set it as constraint weight for the other before running another inversion step.\n\\begin{lstlisting}\n    invMRS.setMaxIter( 1 );\n    invDC.setMaxIter( 1 );\n    invMRS.run(); //! init and run 1 step\n    invDC.run(); //! init and run 1 step\n    double a = 0.1;\n    RVector cWeight( nlay - 1 );\n    for ( int iter = 1; iter < maxIter; iter++ ) {\n        cWeight = a / ( abs( invDC.roughness() ) + a ) + a;\n        invMRS.setCWeight( cWeight );\n        cWeight = a / ( abs( invMRS.roughness() ) + a ) + a;\n        invDC.setCWeight( cWeight );\n        invDC.oneStep();\n        invMRS.oneStep();\n    }\n\\end{lstlisting}\n\nFigure \\ref{fig:dcmrsstruct} shows the inversion result for the above mentioned three-layer case.\nWithout coupling (a) the transitions between the layers are quite smooth.\nMuch more significant jumps in both parameters occur when structural coupling is applied (b) and make the interpretation of both layer thickness and representative parameters less ambiguous.\n\n\\begin{figure}[htb]\n\\includegraphics[width=0.5\\textwidth]{DC-MRS-uncoupled}\n\\hfill\n\\includegraphics[width=0.5\\textwidth]{DC-MRS-coupled}\\\\\n\\vskip -2ex \na\\hfill b%\\\\[1ex]\n\\caption{Synthetic model (red) and inversion results (blue) for DC (left) and MRS (right) 1D inversion without (a) and with (b) structural coupling}\\label{fig:dcmrsstruct}\n\\end{figure} \n\nOf course the coupling does not have to affect the whole model.\nThe constraint weight vector can as well be set for an individual region such as the aquifer.\nSee inversion templates on how to do structural coupled inversion more easily and flexibly.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Petrophysical joint inversion}\\label{sec:petrojoint}\nTarget: water content in a soil column using GPR (CRIM equation) and DC (Archie equation)\n\n\\sperre{TO BE IMPLEMENTED}\n\n\\begin{figure}[htb]\n\\includegraphics[width=0.5\\textwidth]{petro1}\n\\hfill\n\\includegraphics[width=0.5\\textwidth]{petroji}\\\\\n\\vskip -8ex \na\\hfill b%\\\\[1ex]\n\\caption{Scheme for separate inversion (a) and petrophysical joint inversion (b) of GPR and ERT data to obtain an image of porosity or water content}\\label{fig:petroji}\n\\end{figure} \n", "meta": {"hexsha": "b0258a865987c42ac75b9c523def2a3b36912bcc", "size": 13822, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tutorial/jointinversion.tex", "max_stars_repo_name": "mjziebarth/gimli", "max_stars_repo_head_hexsha": "196ac4d6dd67e0326cccc44a87b367f64051e490", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-07-10T00:56:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-17T12:43:38.000Z", "max_issues_repo_path": "doc/tutorial/jointinversion.tex", "max_issues_repo_name": "ivek1312/gimli", "max_issues_repo_head_hexsha": "5fafebb7c96dd0e04e2616df402fa27a01609d63", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/tutorial/jointinversion.tex", "max_forks_repo_name": "ivek1312/gimli", "max_forks_repo_head_hexsha": "5fafebb7c96dd0e04e2616df402fa27a01609d63", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-29T04:28:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T04:28:40.000Z", "avg_line_length": 59.0683760684, "max_line_length": 300, "alphanum_fraction": 0.7273911156, "num_tokens": 3568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.42951422040427434}}
{"text": "\\chapter{Proof of \\texorpdfstring{\\cref*{thm:aggregate-queries:sec}}{Theorem~\\ref{thm:aggregate-queries:sec}}}%\n\\label{app:aggregate-queries}\n\nWe start by proving the security of the privacy-preserving authentication protocols on multiset operations. Note that the proofs of $sub(\\cdot, \\cdot)$ and $empty(\\cdot)$ are similar to those on set operations in~\\cite{10.1007/978-3-642-22792-9_6} and are hence omitted.\n\n\\section{Security of \\texorpdfstring{$sum(\\cdot)$}{sum(\\textcdot)} Operation}\n\n\\begin{lemma}[Security of $sum(\\cdot)$ operation]\\label{lem:aggregate-queries:sum}\n  Under the bilinear $q$-strong Diffie-Hellman assumption, if the accumulative value returned by $sum(\\{X_1,\\dots,X_n\\})$ passes the client's verification, then the probability of $sum(\\{X_1,\\dots,X_n\\}) \\neq acc(\\uplus_{i=1}^n X_i)$ is negligible for any PPT adversary.\n\\end{lemma}\n\n\\begin{proof}\n  First, we prove that this lemma holds for $n=2$ by contradiction. Support there is a PPT algorithm that computs such a multiset $S = \\{y_1, \\dots, y_{\\ell}\\}$, whereas $y_j \\notin X_1 \\uplus X_2$ for some $1 \\le j \\le \\ell$. This means that\n  \\begin{align*}\n    e(acc(X_1), acc(X_2)) &= e(g^{\\prod_{y \\in S} (y+s)}, g) \\Rightarrow \\\\\n    {e(g, g)}^{\\prod_{x \\in X_1 \\uplus X_2} (x+s) } &= {e(g, g)}^{\\prod_{y \\in S} (y+s)}\n  \\end{align*}\n  Note that $(y_j + s)  \\nmid \\prod_{x \\in X_1 \\uplus X_2} (x+s)$. Therefore, there exists a polynomial $Q(s)$ (computable in polynomial time) of degree $n-1$ and constant $\\lambda \\neq 0$, such that $\\prod_{x \\in X_1 \\uplus X_2} (x+s) = Q(s)(y_j + s) + \\lambda$. Thus, we have\n  \\begin{align*}\n& {e(g, g)}^{(y_j + s)\\prod_{1 \\le i \\neq j \\le \\ell} (y_i+s)} = {e(g,g)}^{Q(s)(y_j + s) + \\lambda} \\Rightarrow \\\\\n& {e(g, g)}^{1/(y_j + s)} = {\\left[ {e(g,g)}^{\\prod_{1 \\le i \\neq j \\le \\ell} (y_i+s)} {e(g,g)}^{-Q(s)} \\right]}^{\\lambda^{-1}}.\n  \\end{align*}\n  Thus, this algorithm can break the bilinear $q$-strong Diffie-Hellman assumption. This proves that our lemma holds for $n=2$.\n\n  Supposing our lemma is true for any $n=k$, where $k\\ge 2$, in the following we prove it is also true for $n=k+1$. Let $\\varepsilon_k$ denote the event that \\textsf{Adv} returns incorrect accumulative value $sum(\\uplus_{i=1}^{k} X_i)$ and passes the client's verification. By law of probability, we have:\n  \\begin{align*}\n    \\Pr[\\varepsilon_{k+1}] &=  \\Pr[\\varepsilon_{k}]\\Pr[\\varepsilon_{k+1} | \\varepsilon_{k}] +\n    \\Pr[\\varepsilon_{k}']\\Pr[\\varepsilon_{k+1} | \\varepsilon_{k}']\\\\\n                           &\\leq \\Pr[\\varepsilon_{k}] + \\Pr[\\varepsilon_{k+1}|\\varepsilon_{k}'] \\\\\n                           &= \\Pr[\\varepsilon_{k}] + \\Pr[\\varepsilon_{2}],\n  \\end{align*}\n  where $\\varepsilon'$ denotes the complement of an event. Finally, we have:\n  \\begin{align*}\n    \\Pr[\\varepsilon_n] \\leq (n-1) \\Pr[\\varepsilon_2]\n  \\end{align*}\n  Since $\\Pr[\\varepsilon_2]$ is negligible according to our proof for $n=2$, we can conclude that $\\Pr[\\varepsilon_{n}]$ is negligible as $p\\gg n$ in a cyclic multiplicative group $\\mathbb{G}$. Hence, this lemma is proved.\n\\end{proof}\n\n\\section{Security of \\texorpdfstring{$union(\\cdot)$}{union(\\textcdot)} Operation}\n\n\\begin{lemma}[Security of $union(\\cdot)$ operation]\\label{lem:aggregate-queries:union}\n  Under the bilinear $q$-strong Diffie-Hellman assumption, if the accumulative value returned by $union(\\{X_1,\\dots,X_n\\})$ passes the client's verification, then the probability of $union(\\{X_1,\\dots,X_n\\}) \\neq acc(\\cup_{i=1}^n X_i)$ is negligible for any PPT adversary.\n\\end{lemma}\n\\begin{proof}\n  Let $U = \\cup_{i=1}^n X_i$. The $union(\\cdot)$ protocol consists of three modules\n  \\begin{inlineenum}\n  \\item $sub(\\widehat{X}_1, U)$, $sub(\\widehat{X}_2, U)$, $\\dots$, $sub(\\widehat{X}_n, U)$;%\n    \\label{enum:aggregate-queries:union-proof:mod1}\n  \\item $empty(\\{U-\\widehat{X}_1, U-\\widehat{X}_2, \\dots, U -\\widehat{X}_n\\})$; and%\n    \\label{enum:aggregate-queries:union-proof:mod2}\n  \\item SP sends the ECRH hash value ${h_e(U)}^*$ for $U$.%\n    \\label{enum:aggregate-queries:union-proof:mod3}\n  \\end{inlineenum}\n  Due to the composition property and the security of~\\ref{enum:aggregate-queries:union-proof:mod1} and~\\ref{enum:aggregate-queries:union-proof:mod2}, we only need to prove the security of~\\ref{enum:aggregate-queries:union-proof:mod3}, that is, ${acc(U)}^*$ cannot be forged if ${h_e(U)}^*$ passes the client's verification. Denote $acc^{-1}({acc(U)}^*)$ as the set who has accumulator value ${acc(U)}^*$.\n\n  First, we prove $acc^{-1}({acc(U)}^*)\\subseteq U$, i.e., the returned value ${acc(U)}^*=g^{{P(U)}^*}$=$g^{P(U) \\cdot Q_U(s)}$, where $Q_U(s)$ is some polynomial. We prove this by contradiction.\n  We assume there exists an element $x_j \\in \\widehat{X}_i$ such that $(x_j + s) \\nmid {P(U)}^*$, i.e., ${P(U)}^* = (x_i + s) \\cdot Q_i(s) + \\lambda_i$, where $Q_i(s)$ is some polynomial and $\\lambda_i$ is a constant value. During the execution of protocol $sub(\\widehat{X}_i, U)$, by expanding $e(acc(\\widehat{X}_i), W_i^*) = e({acc(U)}^*, g)$, the adversary can get:\n  \\begin{align*}\n    e(g^{\\prod_{k=1}^{|\\widehat{X}_i|}(x_k+s) }, W_i^*)  = {e(g, g)}^{(x_j+s) \\cdot Q_i(s) + \\lambda_i}.\n  \\end{align*}\n  By dividing $(x_j+s)$ on the exponents of both sides, the adversary can get:\n  \\begin{align*}\n    {e(g, W_i^*)}^{\\prod_{k=1}^{j-1}{(x_k+s)} \\cdot \\prod_{k=j+1}^{|\\widehat{X}_i|}{(x_k+s)}} = {e (g, g)}^{Q_i(s) + \\lambda_i/(x_j+s)}.\n  \\end{align*}\n  Finally, the adversary can get:\n  \\begin{align}\n&{e(g, g)}^{1/(x_j + s)}  \\nonumber \\\\\n    = &{({e(g, W_i^*)}^{\\prod_{k=1}^{j-1}(x_k+s) \\cdot \\prod_{k=j+1}^{|\\widehat{X}_i|}{(x_k+s)}} \\cdot {e(g, g)}^{-Q_i(s)})}^{1/\\lambda_i},\\nonumber\n  \\end{align}\n  which violates the bilinear $q$-strong Diffie-Hellman assumption mention in \\cref{sec:aggregate-queries:prelim}. Hence, by contradiction, ${P(U)}^*$ must be in the form of $P(U) \\cdot Q_U(s)$.\n\n  Next, we prove $U \\subseteq acc^{-1}({acc(U)}^*)$, i.e., $Q_U(s)$ can only be a constant value. We prove this by contradiction. For each set $\\widehat{X}_i$, ${acc(U - \\widehat{X}_i)}^* = g^{P(U-\\widehat{X}_i) \\cdot Q_U(s)}$. During the execution of $empty(\\cdot)$, by expanding $\\prod_{i=1}^n e({acc(U-\\widehat{X}_i)}^*, F_i^*)=e(g, g)$, the adversary can get:\n  \\begin{align*}\n    \\prod_{i=1}^n e(g^{P(U-\\widehat{X}_i)}, g^{Q_i(s)}) = e(g, g),\n  \\end{align*}\n  and then\n  \\begin{align*}\n    {e(g,g)}^{Q_U(s)(\\prod_{i=1}^n P(U-\\widehat{X}_i)\\cdot Q_i(s))}=e(g,g).\n  \\end{align*}\n  Finally, the adversary can get:\n  \\begin{align*}\n    {e(g, g)}^{1/Q_U(s)} = {e(g, g)}^{P(U-\\widehat{X}_i \\cdot Q_i(s))}.\n  \\end{align*}\n  Since $Q_U(s)$ is a polynomial whose order is larger than $1$, the adversary violates the bilinear $q$-strong Diffie-Hellman assumption. Thus, by contradiction, $Q_U(s)$ must be a constant value.\n\n  By the above two arguments, we prove that the accumulative value ${acc(U)}^*$ cannot be forged if it passes the client's verification.\n\\end{proof}\n\n\\section{Security of \\texorpdfstring{$times(\\cdot, \\cdot)$}{times(\\textcdot, \\textcdot)} Operation}\n\n\\begin{lemma}[Security of $times(\\cdot,\\cdot)$ operation]\\label{lem:aggregate-queries:times}\n  Under the bilinear $q$-strong Diffie-Hellman assumption, if the accumulative value returned by $times(X,t)$ passes the client's verification, then the probability of $times(X,t) \\neq acc(\\uplus_{i=1}^t X)$ is negligible for any PPT adversary.\n\\end{lemma}\n\\begin{proof}\n  The $times(\\cdot, \\cdot)$ operation relies only on the $sum(\\cdot)$ operation, and therefore the proof is similar to that of \\cref{lem:aggregate-queries:sum}.\n\\end{proof}\n\n\\section{Security of PA\\texorpdfstring{$^2$}{\\^{}2} Algorithms}\n\nFollowing the above lemmas, we now show that the query results returned by the PA$^2$ algorithms cannot be forged.\n\\aggregatesecuritytheorem*\n\n\\begin{proof}\n  According to the lemmas on the security of operations $sub(\\cdot,\\cdot)$, $empty(\\cdot)$, $sum(\\cdot)$, $union(\\cdot)$, $times(\\cdot,\\cdot)$, the theorem is trivially true due to the composition property.\n\\end{proof}\n\n", "meta": {"hexsha": "7cbb36c40df5dce93ace52c1b4df01091e9ed012", "size": 8013, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aggregate-queries-appendix.tex", "max_stars_repo_name": "xu-cheng/thesis", "max_stars_repo_head_hexsha": "1bb4dd9311c5559d1b31ae79413dd2e303d449a9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-12-26T14:11:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-08T10:55:39.000Z", "max_issues_repo_path": "aggregate-queries-appendix.tex", "max_issues_repo_name": "xu-cheng/thesis", "max_issues_repo_head_hexsha": "1bb4dd9311c5559d1b31ae79413dd2e303d449a9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aggregate-queries-appendix.tex", "max_forks_repo_name": "xu-cheng/thesis", "max_forks_repo_head_hexsha": "1bb4dd9311c5559d1b31ae79413dd2e303d449a9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.8878504673, "max_line_length": 405, "alphanum_fraction": 0.6593036316, "num_tokens": 2814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4295142204042742}}
{"text": "\\documentclass[10pt,letterpaper]{article}\n\n\\usepackage{outlines}\n\\usepackage{amsmath}\n\\usepackage{tikz}\n\\usepackage{hyperref}\n\\usepackage{enumitem}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\DeclareCaptionOptionNoValue{centering}{\\centering} % Make sure everything is centered in subs\n\\captionsetup[sub]{centering}\n\n\\usepackage{multirow}\n\\usepackage{cancel}\n\\usepackage{float}\n\n\\usepackage{parskip}\n\n\\usepackage{slantsc,lmodern}\n\n\\usepackage{pgfplotstable,booktabs}\n\\usepackage{textcomp}\n\\usepackage{gensymb}\n\n\\usepackage{paralist}\n\n\\usepackage{amsmath}\n\\usepackage{tikz}\n\\usepackage{hyperref}\n\n\\usepackage{pst-node}\n\\usepackage{auto-pst-pdf}\n\n\\usepackage[paper=a4paper,margin=1.25in]{geometry}\n\n\\makeatletter\n\\g@addto@macro\\@floatboxreset\\centering\n\\makeatother\n\n\\newcommand{\\volume}{{\\ooalign{\\hfil$V$\\hfil\\cr\\kern0.08em--\\hfil\\cr}}}\n\n\n\n\n\\author{Thaddeus Hughes \\\\ hughes.thad@gmail.com \\\\ thaddeus-maximus.github.io}\n\\date{\\today}\n\\title{Documentation and Validation of EveryCalc's Beam Tool}\n\n\\begin{document}\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\tBeams are common structures for structural analysis. As such many analytical formulas for specific use cases exist. Complex cases can also be computed by use of static superposition, or the utilization of a finite-element (FE) model. I created a web interface for a rudimentary beam FE model.\n\t\\end{abstract}\n\n\t\\section{How does FE work?}\n\n\tA finite-element model works generally by solving a matrix equation of the form\n\n\t\\begin{align}\n\t\t\\{F\\} = [K]\\{q\\} .\n\t\\end{align}\n\n\tWhere ${F}$ is the \\textit{load vector}, $[K]$ is the \\textit{stiffness matrix}, and ${q}$ is the \\textit{displacement vector}. This may be recognized as simply a matrix form of a spring equation $F = k \\delta$, which it is! The FE model works by splitting a large component into several small springs (\\textit{elements}) with endpoints (\\textit{nodes}).\n\n\tThere are a few methods to solve this equation. One simple one is to multiply both sides by the matrix inverse (since there is no direct equivalent of division with matrices). This method does not scale well- but it works with the few elements we will need for this calculator.\n\n\t\\begin{align}\n\t\t[K]^{-1} \\{F\\} = [K]^{-1} [K]\\{q\\} = \\{q\\}\n\t\\end{align}\n\n\tThere are many different forms of stiffness, depending on the exact element used.\n\n\tWe will use a 2D beam element derived from \\textit{Euler-Bernoulli beam theory}. This element has four degrees of freedom: vertical deflection $v$ and rotation $\\psi$ at each end node.\n\n\t\\begin{figure}[H]\n\t\\begin{tikzpicture}[x=0.8in,y=0.8in]\n\t\t\\draw[darkgray, ultra thick] (-2,-.5) -- (-2,.5) -- (2,.5) -- (2,-.5) -- cycle;\n\t\t\\draw[black, ultra thick, ->] (-2.6,-0.6) -- (-2.6,0.6) node[pos=0.5, left]{$v_1$};\n\t\t\\draw[black, ultra thick, ->] (+2.6,-0.6) -- (+2.6,0.6) node[pos=0.5, right]{$v_2$};\n\t\t\\draw[black, ultra thick, ->] (-1.7,0) arc(0:230:0.3) node[pos=0.2, right]{$\\psi_1$};\n\t\t\\draw[black, ultra thick, ->] (2.3,0) arc(0:230:0.3) node[pos=0.2, right]{$\\psi_2$};\n\t\t\\fill[black] (2,0) circle (0.05);\n\t\t\\fill[black] (-2,0) circle (0.05);\n\t\\end{tikzpicture}\n\t\\caption{A beam with a fixed support, a pinned support, and a force load.}\n\t\\end{figure}\n\n\tIt can be found that the equation derived from euler-bernoulli beam theory is\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\tF_1 \\\\\n\t\t\tM_1 \\\\\n\t\t\tF_2 \\\\\n\t\t\tM_2 \n\t\t\\end{Bmatrix} = \n\t\t\\begin{bmatrix}\n\t\t\t12  & 6L   & -12 & 6L   \\\\\n\t\t\t6L  & 4L^2 & -6L & 2L^2 \\\\\n\t\t\t-12 & -6L  & 12  & -6L  \\\\\n\t\t\t6L  & 2L^2 & -6L & 4L^2 \n\t\t\\end{bmatrix}\n\t\t\\begin{Bmatrix}\n\t\t\tv_1 \\\\\n\t\t\t\\psi_1 \\\\\n\t\t\tv_2 \\\\\n\t\t\t\\psi_2 \n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tThis is just one element though! How do we link the elements together?\n\n\t\\section{Direct Assembly}\n\n\tOne simple way is by \\textit{direct assembly}. It can be noticed that (roughly) the matrix looks something like\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\tF_1 \\\\\n\t\t\tF_2 \n\t\t\\end{Bmatrix} = \n\t\t\\begin{bmatrix}\n\t\t\tK & -K \\\\\n\t\t\t-K & K \n\t\t\\end{bmatrix}\n\t\t\\begin{Bmatrix}\n\t\t\tu_1 \\\\\n\t\t\tu_2 \n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tIf we had two elements linked together like so:\n\n\t\\begin{figure}[H]\n\t\\begin{tikzpicture}[x=0.4in,y=0.4in]\n\t\t\\draw[darkgray, ultra thick] (-2,-.5) -- (-2,.5) -- (2,.5) -- (2,-.5) -- cycle;\n\t\t\\draw[darkgray, ultra thick] (2,-.5) -- (2,.5) -- (6,.5) -- (6,-.5) -- cycle;\n\t\t\\node[black] at (0,0) {A} ;\n\t\t\\node[black] at (4,0) {B} ;\n\t\t\\fill[black] (-2,0) circle (0.1) node[left]{1};\n\t\t\\fill[black] (2,0)  circle (0.1) node[left]{2};\n\t\t\\fill[black] (6,0)  circle (0.1) node[left]{3};\n\t\\end{tikzpicture}\n\t\\caption{Two connected beams.}\n\t\\end{figure}\n\n\tThese two beams share node 2. That is to say, they both see the forces from node 2, and the deflection at node 2. This leads us to combine the equations for each element as so:\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\tF_1 \\\\\n\t\t\tF_2 \\\\\n\t\t\tF_3 \n\t\t\\end{Bmatrix} = \n\t\t\\begin{bmatrix}\n\t\t\tK_A  & -K_A    & 0    \\\\\n\t\t\t-K_A & K_A+K_B & -K_B \\\\\n\t\t\t0    & -K_B    & K_B\n\t\t\\end{bmatrix}\n\t\t\\begin{Bmatrix}\n\t\t\tu_1 \\\\\n\t\t\tu_2 \\\\\n\t\t\tu_3 \n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tWe've linked the nodes together, but we now need to constrain them. These beams are currently floating in space- we need to anchor them otherwise our displacements are meaningless (furthermore, the matrix $[K]$ would be singular and unsolvable). For example, let's apply the constraint that node 1 is fixed; that is, $u_1$ = 0. As a result, the associated column in $[K]$ (the first column) does not matter. Any loads applied to the node also do not matter since they would be absorbed by the fixed constraint. This allows us to remove columns and rows 1 of the stiffness matrix, degrees of freedom 1, and load 1, changing our equation to:\n\n\t\\[\n\t\\begin{pspicture} \n\t\t\\begin{Bmatrix}\n\t\t\t\\rnode{A}{F_1} \\\\\n\t\t\tF_2 \\\\\n\t\t\tF_3 \n\t\t\\end{Bmatrix} = \n\t\t\\begin{bmatrix}\n\t\t\t\\rnode{C}{K_A}  & -K_A    & 0    \\\\\n\t\t\t-K_A & K_A+K_B & -K_B \\\\\n\t\t\t\\rnode{D}{0}    & -K_B    & K_B\n\t\t\\end{bmatrix}\n\t\t\\begin{Bmatrix}\n\t\t\t\\rnode{B}{u_1} \\\\\n\t\t\tu_2 \\\\\n\t\t\tu_3 \n\t\t\\end{Bmatrix}\n\t\t\\ncline{A}{B}\n\t\t\\ncline{C}{D}\n\t\\end{pspicture}\n\t\\]\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\tF_2 \\\\\n\t\t\tF_3 \n\t\t\\end{Bmatrix} = \n\t\t\\begin{bmatrix}\n\t\t\tK_A+K_B & -K_B \\\\\n\t\t\t-K_B    & K_B\n\t\t\\end{bmatrix}\n\t\t\\begin{Bmatrix}\n\t\t\tu_2 \\\\\n\t\t\tu_3 \n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tAt this point we could plug in values $F_2$ and $F_3$, and solve with the matrix inverse method.\n\n\t\\section{Application to Beams}\n\n\tLet's show how this would work with a beam. Consider the following example:\n\t\n\t\\begin{figure}[H]\n\t\\begin{tikzpicture}[x=1.2in,y=1.2in]\n\t\t\\draw[gray] (0, 0.05) -- (0, 0.3) node[pos=1, above]{$0$};\n\t\t\\draw[gray] (1, 0.05) -- (1, 0.3) node[pos=1, above]{$L$};\n\t\t\\draw[gray] (2, 0.05) -- (2, 0.3) node[pos=1, above]{$2L$};\n\t\t\\draw[gray] (3, 0.05) -- (3, 0.3) node[pos=1, above]{$3L$};\n\t\t\\draw[gray] (4, 0.05) -- (4, 0.3) node[pos=1, above]{$4L$};\n\t\t\\draw[darkgray, ultra thick] (0,0) -- (4,0);\n\t\t\\draw[blue, ultra thick, ->] (3,-0.05) -- (3,-0.3) node[pos=0.5, right]{W};\n\t\t\\fill[black, ultra thick] (0.9,0) -- (1.1,0) -- (1.1,-0.2) -- (0.9,-0.2) -- cycle;\n\t\t\\fill[black, ultra thick] (2,0) -- (2.1,-0.2) -- (1.9,-0.2) -- cycle;\n\t\\end{tikzpicture}\n\t\\caption{A beam with a fixed support, a pinned support, and a force load.}\n\t\\end{figure}\n\n\tWe can start by creating a general stiffness matrix with the general assembly method:\n\n\t\\begin{align}\n\t\t[K] = \n\t\t\\begin{bmatrix}\n12 & 6L & -12 & 6L & & & & & & \\\\\n6L & 4L^2 & -6L & 2L^2 & & & & & & \\\\\n-12 & -6L & 24 & 12L & -12 & 6L & & & & \\\\\n6L & 2L^2 & 12L & 8L^2 & -6L & 2L^2 & & & & \\\\\n & & -12 & -6L & 24 & 12L & -12 & 6L & & \\\\\n & & 6L & 2L^2 & 12L & 8L^2 & -6L & 2L^2 & & \\\\\n & & & & -12 & -6L & 24 & 12L & -12 & 6L \\\\\n & & & & 6L & 2L^2 & 12L & 8L^2 & -6L & 2L^2 \\\\\n & & & & & & -12 & -6L & 12 & -6L \\\\\n & & & & & & 6L & 2L^2 & -6L & 4L^2\n\t\t\\end{bmatrix}\n\t\\end{align}\n\n\tZeroes have been omitted from matrix to aid in readability.\n\n\tThe load vector is simply\n\n\t\\begin{align}\n\t\t{F} = \n\t\t\\begin{Bmatrix}\n\t\t\tF_1 \\\\\n\t\t\tM_1 \\\\\n\t\t\tF_2 \\\\\n\t\t\tM_2 \\\\\n\t\t\tF_3 \\\\\n\t\t\tM_3 \\\\\n\t\t\tF_4 \\\\\n\t\t\tM_4 \\\\\n\t\t\tF_5 \\\\\n\t\t\tM_5\n\t\t\\end{Bmatrix} = \n\t\t\\begin{Bmatrix}\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t-W \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0\n\t\t\\end{Bmatrix} .\n\t\\end{align}\n\n\tCombining this yields the full, unconstrained equation\n\n\t\\begin{align} \n\t\t\\begin{Bmatrix}\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t-W \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0\n\t\t\\end{Bmatrix} = \\begin{bmatrix}\n12 & 6L & -12 & 6L & & & & & & \\\\\n6L & 4L^2 & -6L & 2L^2 & & & & & & \\\\\n-12 & -6L & 24 & 0 & -12 & 6L & & & & \\\\\n6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 & & & & \\\\\n & & -12 & -6L & 24 & 0 & -12 & 6L & & \\\\\n & & 6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 & & \\\\\n & & & & -12 & -6L & 24 & 0 & -12 & 6L \\\\\n & & & & 6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 \\\\\n & & & & & & -12 & -6L & 12 & -6L \\\\\n & & & & & & 6L & 2L^2 & -6L & 4L^2\n\t\t\\end{bmatrix} \\begin{Bmatrix}\n\t\t\tv_1 \\\\\n\t\t\t\\psi_1 \\\\\n\t\t\tv_2 \\\\\n\t\t\t\\psi_2 \\\\\n\t\t\tv_3 \\\\\n\t\t\t\\psi_3 \\\\\n\t\t\tv_4 \\\\\n\t\t\t\\psi_4 \\\\\n\t\t\tv_5 \\\\\n\t\t\t\\psi_5\n\t\t\\end{Bmatrix} .\n\t\\end{align}\n\n\tThe fixed support at node 2 removes degrees of freedom $v_2$, $\\psi_2$. The pinned support at node 3 removes only $v_3$ (pin still permits rotation).\n\n\t\\[\n\t\\begin{pspicture} \n\t\t\\begin{Bmatrix}\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t\\rnode{A}{0} \\\\\n\t\t\t\\rnode{C}{0} \\\\\n\t\t\t\\rnode{E}{0} \\\\\n\t\t\t0 \\\\\n\t\t\t-W \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0\n\t\t\\end{Bmatrix} = \\begin{bmatrix}\n12 & 6L & \\rnode{G}{-12} & \\rnode{I}{6L} & \\rnode{K}{} & & & & & \\\\\n6L & 4L^2 & -6L & 2L^2 & & & & & & \\\\\n-12 & -6L & 24 & 0 & -12 & 6L & & & & \\\\\n6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 & & & & \\\\\n & & -12 & -6L & 24 & 0 & -12 & 6L & & \\\\\n & & 6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 & & \\\\\n & & & & -12 & -6L & 24 & 0 & -12 & 6L \\\\\n & & & & 6L & 2L^2 & 0 & 8L^2 & -6L & 2L^2 \\\\\n & & & & & & -12 & -6L & 12 & -6L \\\\\n & & \\rnode{H}{} & \\rnode{J}{} & \\rnode{L}{} & & 6L & 2L^2 & -6L & 4L^2\n\t\t\\end{bmatrix} \\begin{Bmatrix}\n\t\t\tv_1 \\\\\n\t\t\t\\psi_1 \\\\\n\t\t\t\\rnode{B}{v_2} \\\\\n\t\t\t\\rnode{D}{\\psi_2} \\\\\n\t\t\t\\rnode{F}{v_3} \\\\\n\t\t\t\\psi_3 \\\\\n\t\t\tv_4 \\\\\n\t\t\t\\psi_4 \\\\\n\t\t\tv_5 \\\\\n\t\t\t\\psi_5\n\t\t\\end{Bmatrix}\n\t\t\\psset{nodesep=-1.5ex, linewidth=0.4pt}\n\t\t\\ncline{A}{B}\n\t\t\\ncline{C}{D}\n\t\t\\ncline{E}{F}\n\t\t\\ncline{G}{H}\n\t\t\\ncline{I}{J}\n\t\t\\ncline{K}{L}\n\t\\end{pspicture}\n\t\\]\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t-W \\\\\n\t\t\t0 \\\\\n\t\t\t0 \\\\\n\t\t\t0\n\t\t\\end{Bmatrix} = \\begin{bmatrix}\n12 & 6L & & & & & \\\\\n6L & 4L^2 & & & & & \\\\\n & & 8L^2 & -6L & 2L^2 & & \\\\\n & & -6L & 24 & 0 & -12 & 6L \\\\\n & & 2L^2 & 0 & 8L^2 & -6L & 2L^2 \\\\\n & & & -12 & -6L & 12 & -6L \\\\\n & & & 6L & 2L^2 & -6L & 4L^2 \n \t\t\\end{bmatrix} \\begin{Bmatrix}\n\t\t\tv_1 \\\\\n\t\t\t\\psi_1 \\\\\n\t\t\t\\psi_3 \\\\\n\t\t\tv_4 \\\\\n\t\t\t\\psi_4 \\\\\n\t\t\tv_5 \\\\\n\t\t\t\\psi_5\n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tAt this point, the matrix equation could be solved to achieve the nodal displacement vector. Afterwards, the resulting displacement matrix could be used with the unconstrained stiffness matrix to determine the loads at the constraints.\n\n\t\\section{Prescribing Displacements}\n\n\tBut, what if instead, we wanted to prescribe a displacement rather than a force? This throws a wrench in this whole process... or at least would mean we'd have to go back to the drawing board, and try \\textit{matrix partitioning}. Let's consider a different setup, of the form\n\n\t\\begin{align}\n\t\t\\begin{Bmatrix}\n\t\t\t\\{F_u\\} \\\\\n\t\t\t\\{F_p\\} \n\t\t\\end{Bmatrix} = \\begin{bmatrix}\n\t\t\t[K_{u,u}] & [K_{u,p}] \\\\\n\t\t\t[K_{p,u}] & [K_{p,p}] \n \t\t\\end{bmatrix} \\begin{Bmatrix}\n\t\t\t\\{q_{u}\\} \\\\\n\t\t\t\\{q_{p}\\} \n\t\t\\end{Bmatrix},\n\t\\end{align}\n\n\twhere $\\{F_u\\}$ and $\\{F_p\\}$ are the portions of the load vector corresponding to the unprescribed and prescribed-displacement portions, respectively. The same holds for $\\{q_u\\}$ and $\\{q_p\\}$. There's no \\textit{true} sub-vectoring going on here, the brackets are just to denote that these are bits of matrices inside the larger matrices, not just scalar values.\n\n\tWe can expand out first row of the matrix equation to find that \n\n\t\\begin{align}\n\t\t\\{F_u\\} = [K_{u,u}] \\{q_{u}\\} + [K_{u,p}] \\{q_{p}\\}\n\t\\end{align}\n\n\tSolving this yields\n\n\t\\begin{align}\n\t\t[K_{u,u}] \\{q_{u}\\} = \\{F_u\\} - [K_{u,p}] \\{q_{p}\\}\n\t\\end{align}\n\n\twhich is of the form $[M] \\{x\\} = \\{b\\}$ (since $\\{q_{p}\\}$ is the prescribed displacements), so can be solved.\n\n\tAfter finding the non-prescribed displacements, the second row of the matrix equation can be expanded to\n\t\\begin{align}\n\t\t\\{F_p\\} = [K_{p,u}] \\{q_{u}\\} + [K_{p,p}] \\{q_{p}\\}\n\t\\end{align}\n\n\twhich can be used to compute the forces required to produce the prescribed displacements.\n\n\tWe would then simply need to re-build the force and displacement vectors, and then we can proceed to post-processing.\n\n\t\\section{Post Processing and Shape Functions}\n\n\tUsually, a displacement \\textit{field} is desired rather than merely the nodal values. Getting deflection at arbitrary points requires the use of \\textit{shape functions}. In the derivation of the beam stiffness matrix (which this paper does not cover), particular \\textit{shape functions} were used: the Hermite shape functions. These are nondimensional equations that represent the contribution of one \\textit{nodal} degree of freedom to the displacement \\textit{field} in an element. By combining these displacement fields, we can determine the total displacement field.\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.7\\textwidth]{hermite.png}\n\t\t\\caption{Hermite shape functions}\n\t\\end{figure}\n\n\tThese hermite shape functions can be represented as:\n\n\t\\begin{align}\n\t\tN = \\begin{Bmatrix}\n\t\t\t\t1/4 (1-\\zeta^2 (2+\\zeta) \\\\\n\t\t\t\tL/8 (1-\\zeta)^2 (\\zeta+1) \\\\\n\t\t\t\t1/4 (1+\\zeta)^2 (2-\\zeta) \\\\\n\t\t\t\tL/8 (1+\\zeta)^2 (\\zeta-1) \n\t\t\\end{Bmatrix}^T\n\t\\end{align}\n\n\tWhere $L$ is the element length and $\\zeta$ is a nondimensional parameter that is -1 at the left of the element, +1 at the right, and 0 in the center.\n\n\t\\begin{align}\n\t\t\\zeta = 2 \\frac{x}{L} - 1\n\t\\end{align}\n\n\tWhere $x$ is the distance from the left of the element.\n\n\tThe functions can be used to find the displacement field $v$:\n\n\t\\begin{align}\n\t\tv = \\{N\\} \\{q\\} =\n\t\t\\begin{Bmatrix}\n\t\t\t\t1/4 (1-\\zeta^2 (2+\\zeta) \\\\\n\t\t\t\tL/8 (1-\\zeta)^2 (\\zeta+1) \\\\\n\t\t\t\t1/4 (1+\\zeta)^2 (2-\\zeta) \\\\\n\t\t\t\tL/8 (1+\\zeta)^2 (\\zeta-1) \n\t\t\\end{Bmatrix}^T \n\t\t\\begin{Bmatrix}\n\t\t\tv_1 \\\\\n\t\t\t\\psi_1 \\\\\n\t\t\tv_2 \\\\\n\t\t\t\\psi_2 \n\t\t\\end{Bmatrix}\n\t\\end{align}\n\n\tThis helps us plot the displacement field, but what about the slope, bending moment, and shear force?\n\n\tThe slope $\\theta$ is simply the derivative of the displacement field $v$ with respect to position $x$. The bending moment $M$ and shear force $V$ can also be found from Euler-Bernoulli beam theory.\n\n\t\\begin{align}\n\t\t\\theta &= \\frac{d v}{d x} \\\\\n\t\tM      &= E I \\frac{d^2 v}{d x^2} \\\\\n\t\tV      &= \\frac{d}{d x} (E I \\frac{d^2 v}{d x^2}) = E I \\frac{d^3 v}{d x^3}\n\t\\end{align}\n\n\tAssuming elastic modulus $E$ and second moment of area $I$ are constant over the element.\n\n\tTo find these derivatives of $v$, we can use the shape functions, ignoring the nodal displacements since they do not vary with $x$.\n\n\t\\begin{align}\n\t\t\\frac{dv}{dx} = \\frac{d}{dx} [\\{N\\} \\{q\\}] = \\frac{d \\{N\\}}{dx} \\{q\\}\n\t\\end{align}\n\n\tThe chain rule can be used to help find these derivatives.\n\n\t\\begin{align}\n\t\t\\frac{d \\{N\\}}{d x} &= \\frac{d \\{N\\}}{d \\zeta} \\frac{d \\zeta}{d x} \\\\\n\t\t\\frac{d^2 \\{N\\}}{d x^2} &= \\frac{d^2 \\{N\\}}{d \\zeta^2} (\\frac{d \\zeta}{d x})^2 + \\frac{d \\{N\\}}{d \\zeta} \\frac{d^2 \\zeta}{d x^2} \\\\\n\t\t\\frac{d^3 \\{N\\}}{d x^3} &= \\frac{d^3 \\{N\\}}{d \\zeta^3} (\\frac{d \\zeta}{d x})^3 + 3 \\frac{d^2 \\{N\\}}{d \\zeta^2} \\frac{d \\zeta}{d x}\\frac{d^2 \\zeta}{d x^2} + \\frac{d \\{N\\}}{d \\zeta}\\frac{d^3 \\zeta}{d x^3}\n\t\\end{align}\n\n\tLooks ugly! But luckily, the higher order derivatives of $\\zeta$ are zero.\n\n\t\\begin{align}\n\t\t\\frac{d \\zeta}{d x} &= \\frac{2}{L} \\\\\n\t\t\\frac{d^2 \\zeta}{d x^2} = \\frac{d^3 \\zeta}{d x^3} &= 0\n\t\\end{align}\n\n\t\\begin{align}\n\t\t\\frac{d \\{N\\}}{d x} &= \\frac{d \\{N\\}}{d \\zeta} \\frac{2}{L} \\\\\n\t\t\\frac{d^2 \\{N\\}}{d x^2} &= \\frac{d^2 \\{N\\}}{d \\zeta^2} (\\frac{2}{L})^2 \\\\\n\t\t\\frac{d^3 \\{N\\}}{d x^3} &= \\frac{d^3 \\{N\\}}{d \\zeta^3} (\\frac{2}{L})^3\n\t\\end{align}\n\n\tThe shape function derivatives are\n\n\t\\begin{align}\n\t\t\\frac{d \\{N\\}}{d x}     =\n\t\t\\begin{Bmatrix}\n\t\t\t\t3/4 (\\zeta^2-1) 2/L \\\\\n\t\t\t\tL/8 (3 \\zeta^2-2 \\zeta - 1) 2/L \\\\\n\t\t\t    3/4 (\\zeta^2-1) 2/L \\\\\n\t\t\t\tL/8 (3 \\zeta^2+2 \\zeta -1) 2/L\n\t\t\\end{Bmatrix}^T &\n\t\t\\frac{d^2 \\{N\\}}{d x^2} =\n\t\t\\begin{Bmatrix}\n\t\t\t\t(6 \\zeta)/L^2 \\\\\n\t\t\t\t(3 \\zeta-1)/L \\\\\n\t\t\t   -(6 \\zeta)/L^2 \\\\\n\t\t\t\t(3 \\zeta+1)/L\n\t\t\\end{Bmatrix}^T &\n\t\t\\frac{d^3 \\{N\\}}{d x^3} =\n\t\t\\begin{Bmatrix}\n\t\t\t\t12/L^3 \\\\\n\t\t\t\t6/L^2 \\\\\n\t\t\t   -12/L^3 \\\\\n\t\t\t\t6/L^2\n\t\t\\end{Bmatrix}^T \n\t\\end{align}\n\n\t\\section{Generalization}\n\tHow does this get generalized to different, arbitrary, and variable scenarios?\n\n\t\\begin{asparaitem}\n\t\t\\item All of the loads and constraints are gathered and binned by type. Each load is given a node id.\n\t\t\\item The position along the beam for each load or constraint is stored by node id.\n\t\t\\item The node ids are sorted by the order of positions.\n\t\t\\item Close nodes (those that are within 1/100 of the beam length) are merged so that the corresponding load/constraints share the same node id. The old node id and position is deleted.\n\t\t\\item Beam elements are produced between the first and second node, second and third, and so forth.\n\t\t\\item The force matrix is populated with forces\n\t\t\\item Direct assembly is performed on the beam elements\n\t\t\\item Degrees of freedom corresponding to the node ids where pinned/fixed nodes exist are struck and removed from the stiffness and force matrices.\n\t\t\\item The matrix system of equations is solved\n\t\t\\item The resulting nodal displacements are used in conjunction with the shape functions to interpolate a displacement field.\n\t\\end{asparaitem}\n\n\t\\section{Sanity Check: are the Shape Functions Appropriate?}\n\n\tUsually finite element methods are used as approximations by employing the use of many, many elements to approximate the true displacement field. Beam elements, though, are somewhat unique in that \\textit{under certain circumstances} they will model the underlying diplacement field exactly. Let's return to Euler-Bernoulli beam theory. This theory states that the displacement field $q$ can be represented as \n\n\t\\begin{align}\n\t\t\\frac{d^2}{d x^2} E I \\frac{d^2 v}{d x^2} = q ,\n\t\\end{align}\n\n\twhere $q$ is a distributed load (i.e. with dimensions of force per unit length). Euler-Bernoulli beam theory has several assumptions wrapped up in it, such as the requirement that plane sections remain plane, and no large deflections.\n\n\tMy calculator does not model distributed loads, so $q$ is always zero. Additionally, the cross-section and elastic modulus remain constant, so $E$ and $I$ can be moved outside of the derivative, leaving\n\n\t\\begin{align}\n\t\tE I \\frac{d^4 v}{d x^4} &= 0 \\\\\n\t\t\\frac{d^4 v}{d x^4} &= 0 \n\t\\end{align}\n\n\tIf we integrate both sides repeatedly, we can get the form of $v$.\n\n\t\\begin{align}\n\t\t\\int \\frac{d^4 v}{d x^4} dx &= \\int 0 dx \\\\\n\t\t\\int \\frac{d^3 v}{d x^3} dx &= \\int c_1 dx \\\\\n\t\t\\int \\frac{d^2 v}{d x^2} dx &= \\int c_1 x + c_2 dx \\\\\n\t\t\\int \\frac{d v}{d x} dx     &= \\int c_1 x^2 + c_2 x + c_3 dx \\\\\n\t\tv &= c_1 x^3 + c_2 x^2 + c_3 x + c_4 \n\t\\end{align}\n\n\tThe shape of $v$ under the assumptions of constant $E$ and $I$ with only point loads is a cubic polynomial, a function with four degrees of freedom. What else has four degrees of freedom? Our elements! Using beam elements provides a sufficient quantity of degrees of freedom to provide exact analytical solutions to problems where Euler-Bernoulli beam theory is appropriate, and require point loads and constant cross sections. This may sound restrictive, but encompasses nearly all applications of beams, which is why they are such a powerful modeling tool even in full-blown FE applications.\n\n\t\\section{Validation Examples}\n\n\tComparison to analytical solutions is a necessary component when validating any FE model. \\href{https://mechanicalc.com/reference/beam-deflection-tables}{\\underline{MechaniCalc}} has some good analytical solutions I will compare to.\n\n\t\\newpage\n\t\\subsection{Cantilevered, Intermediate Load}\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.5\\textwidth]{beam_case1_schematic.png}\n\t\\end{figure}\n\n\tLet $E = 69 GPa$ (aluminum), $L = 100 mm$, round bar with $d = 5 mm$, $F = 200 N$, $a = 60mm$.\n\n\t\\begin{align}\n\t\tI = \\frac{\\pi}{64} d^4 = \\frac{\\pi}{64} (0.100 m)^4 = 3.06796 \\times 10^{-11} m^4\n\t\\end{align}\n\t\\begin{align}\n\t\t\\delta_{a} &= - \\frac{F a^2}{6 E I} (3 L - a) = - \\frac{200 N \\times (0.06 m)^2}{6 \\times 69 GPa \\times 30.6796 mm^4} (3 \\times 0.06 m - 0.06 m) = 6.802 mm\\\\\n\t\t\\delta_{end} &= - \\frac{F a^2}{6 E I} (3 L - a) = - \\frac{200 N \\times (0.06 m)^2}{6 \\times 69 GPa \\times 30.6796 mm^4} (3 \\times 0.1 m - 0.06 m) = 13.6048 mm\\\\\n\t\t\\theta_{a/2} &= - \\frac{F (a/2)^2}{2 E I} (2 L - a/2) = \\frac{200 N \\times .03 m}{2 \\times 69 GPa \\times 30.6796 mm^4} (2 \\times 0.1m - .03m) = 7.305 \\ deg\\\\\n\t\tV_{0 \\rightarrow a} &= F = 200 \\ N \\\\\n\t\tM_{x=0} &= -F \\times a = - 200 N \\times .06 m = - 12\\ Nm\n\t\\end{align}\n\n\tYou can plug in the values to the calculator and verify this load case for yourself. I found all of the above numbers to be accurate.\n\n\t\\newpage\n\t\\subsection{Simply Supported, Center Moment}\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.5\\textwidth]{beam_case2_schematic.png}\n\t\\end{figure}\n\n\tLet $E = 27557 ksi$ (steel), $L = 6 in$, box bar with $w = 0.5 in$, $h = 2in$, $M = 1200 ft-lbf$.\n\n\t\\begin{align}\n\t\tI = \\frac{1}{12} b h^3 = 1/3 \\ in^4\n\t\\end{align}\n\t\\begin{align}\n\t\t\\delta_{x = 1.25 in} &= \\frac{ - M x}{24 L E I}(L^2 - 4*x^2) = \\frac{-12\\ ft\\ lbf\\ 1.25 \\ in}{24 \\times \\ 6 \\ in \\ 27557 \\ ksi \\ 1/3 \\ in^4} ((6 in)^2 - 4 (1.25 in)^2) = -.4048 \\ thou \\\\\n\t\t\\theta_{1} &= \\frac{- M L}{24 E I} = \\frac{-1200\\ ft\\ lbf\\ 6 \\ in}{24 \\times \\ 27557 \\ ksi \\ 1/3 \\ in^4} = -.02246 \\ deg \\\\\n\t\tV &= M / L = 1200 ft-lbf / 6 in = 2400 lbf \\\\\n\t\tM_{x=L/2} &= M / 2 = 1200 ft-lbf / 2 = 600 ft-lbf\n\t\\end{align}\n\n\tYou can plug in the values to the calculator and verify this load case for yourself. I found all of the above numbers to be accurate.\n\n\\end{document}", "meta": {"hexsha": "5d9f6c29b0d753ac4d43f53d3b707e9f88f4d41e", "size": 21852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/beamcalc.tex", "max_stars_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_stars_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-04-27T03:38:12.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T22:52:39.000Z", "max_issues_repo_path": "docs/beamcalc.tex", "max_issues_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_issues_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 50, "max_issues_repo_issues_event_min_datetime": "2020-03-22T15:43:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-10T01:40:08.000Z", "max_forks_repo_path": "docs/beamcalc.tex", "max_forks_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_forks_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.14375, "max_line_length": 640, "alphanum_fraction": 0.6172890353, "num_tokens": 8514, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.42951421659650413}}
{"text": "\\section{Characterization of CUDA Kernels}\\label{sec:characterization}\nThe current architectures of GPUs have a hierarchical memory management, where cores make data requests in their registers, these requests pass through caches that in some cases may be shared caches, and so on until to arrive to its global memory. When a request data of a thread increases of level in the memory hierarchy, it increases increases the communication latency. On the contrary, while higher memory level, higher  capacity of storage, see Figure~\\ref{fig:PyrLatency}. \n\n\\begin{figure}[htpb]\n\\centering\n\\includegraphics[scale=.75]{./images/memhierarchy.png}\n\\caption{Variance of the latency and capacity of storage in the memory systems}\n\\label{fig:PyrLatency}\n\\end{figure}\n\nThe performance of a function executed over a GPU depends greatly on the optimizations made in the accesses to data in the memory hierarchy. The bandwidth of the memory is optimized by grouping a set of threads, so, the threads in the group are benefited in the communication. This effect is called coalesced accesses~\\citep{Wu:2013:Coalesced, Che:2011}. In Tesla architectures, the first GPGPU architecture, these coalesced accesses were by threads of a half warp, i.e. 16 threads can be coalesced to one transaction for word of size 8-bit, 16-bit, 32 bit, 64-bit or 128-bit. On Fermi, Kepler and newer architectures coalesced accesses can be done by all threads of a warp.\n\nSince the early generations of GPUs for general purpose, GPUs have had different types of memories, which are differentiated by the type and visibility in the data. In Table~\\ref{tab:memories} are presented the different types of memories existing in current GPUs. This table shows the type of operation that each memory can do. \nThe constant memory is an off-chip and it can be read by all threads in a kernel, however the CPU is the only which can write on it. \nThe On Chip memories are those that are inside each multiprocessors and consequently the communication latency is lower. Global memory is the main memory of the GPU, local and constant memory are just different addressing modes of the global memory. Global Memory is DRAM, on the contrary, all on-chip memory (shared memory, registers, and caches) are SRAM. \n\n\\begin{table}[htpb]\n\\centering\n\\begin{tabular}{| l | c | c | c  |  c |} \n\\hline \\hline%inserts double horizontal lines\n\\textbf{Type} & \\textit{\\textbf{On Chip}}&\\textbf{Cacheable}&\\textbf{Operations}&\\textbf{Visibility} \\\\ \\hline\nRegisters&Yes&No&Read/Write&\\textit{Thread}\\\\ \\hline\nLocal&Not&Yes&Read/Write&\\textit{Thread}\\\\ \\hline\nShared&Yes&No&Read/Write&Block\\\\ \\hline\nGlobal&No&Yes&Read/Write&\\textit{Kernels}\\\\ \\hline\nConstant&No&Yes&Read&\\textit{Kernels}\\\\ \\hline\nTexture&No&Yes&Read/Write&\\textit{Kernels}\\\\ \\hline\n\\hline\n\\end{tabular}\n\\caption{Memory types of the GPUs manufactured by Nvidia}\n\\label{tab:memories} % is used to refer this table in the text\n\\end{table}\n\nWe analyzed different kernels, aiming to show which are the different optimizations that impact the performance of a GPU application. Figure~\\ref{fig:BlockTunning} shows the running times of the kernel of matrix multiplication using only global memory without coalesced accesses, i.e. the kernel $MMGU$. The experiments are done varying the number of threads per block, with dimensions of $8\\times{}8$, $16\\times{}16$, or $32\\times{}32$. Figure~\\ref{fig:BlockTunning}A shows the running times, Figure~\\ref{fig:BlockTunning}B the number of load transactions per request in the global memory and Figure~\\ref{fig:BlockTunning}C the number of store transactions per request in the global memory. This kernel has a bad access in the global memory, for this reason it reach higher performance when the dimension of the blocks is lower.\n\n\\begin{figure}[htpb]\n\t\\centering\n    \\includegraphics[scale=.5]{images/plotBlock.pdf}\n    \\caption{Tuning of threads per Block in MMGU on the GPU GTX-970}\n    \\label{fig:BlockTunning}\n\\end{figure}\n\nFigure~\\ref{fig:Coalesced} show the performance of two application in two different versions each one, the applications are matrix multiplication and matrix addiction, the versions  of these applications are $MMGC$ and $MMGU$; and, $MAC$ and $MAU$; respectively. The selected dimensions of threads per block in each kernel was $8\\times{}8$. Each kernel change communication pattern in the global memory. Figure~\\ref{fig:Coalesced}A shows the running time of the kernels $MMGC$ and $MMGU$ and Figure~\\ref{fig:Coalesced}B the number of load transactions per request in the global memory. Figure~\\ref{fig:Coalesced}C shows the running time of the kernels $MAC$ and $MAU$ and Figure~\\ref{fig:Coalesced}D the number of load transactions per request in the global memory of two different version of the matrix addition. It is easy to perceive that when the number of transaction per request in the global memory is smaller the running time of the application improve and consequently the arithmetic throughput of the application.\n\n\\begin{figure}[htpb]\n\t\\centering\n    \\includegraphics[scale=.5]{images/plotCoalesced.pdf}\n    \\caption{Coalesced accesses impact in 2 different kernels of Matrix Multiplication and Matrix Addition on the GPU GTX-970}\n    \\label{fig:Coalesced}\n\\end{figure}\n\nFigure~\\ref{fig:Shared} shows the impact of the shared memory and coalesced accesses in the 4 versions of matrix multiplication. Figure~\\ref{fig:Shared}A shows the running time of the kernels $MMGU$, $MMGC$, $MMSU$ and $MMSC$; Figure~\\ref{fig:Shared}B shows the throughput in the global memory and Figure~\\ref{fig:Shared}C shows the number of load transactions per request in the global memory of the 4 kernels. The worst throughput in the load memory is done for the kernel $MMSU$, it means that using shared memory does not improve the throughput  in the load memory, coalesced accesses are necessary for this goal.\n\n\n\\begin{figure}[htpb]\n\t\\centering\n    \\includegraphics[scale=.5]{images/plotCoalescedShared.pdf}\n    \\caption{Shared memory optimizations in kernels of Matrix Multiplication on the GPU GTX-970}\n    \\label{fig:Shared}\n\\end{figure}\n\nIn ont of the work indirectly relate with this thesis, we implemented an autotuner for the CUDA compiler using the use the OpenTuner \nframework~\\cite{ansel2014opentuner} and used it to search for the compilation parameters  that optimize the performance of different GPU applications.\n\nFigure~\\ref{fig:autotuning} shows the results of an implemented autotuner for the CUDA compiler using the use the OpenTuner framework~\\citep{ansel2014opentuner} and used it to search for the compilation parameters that optimize the performance of GPU applications. The main result is this research was to show that it is possible to optimize code written for GPUs by automatically tuning just the parameters of the CUDA compiler.\n\n\\paragraph{The Search Space}\\label{sec:parameters}\n\n% \\newcommand{\\specialcell}[1]{\\begin{minipage}[m]{0.52\\columnwidth}\\centering#1\\end{minipage}}\n\n\\begin{table}[htpb]\n    \\centering\n    \\footnotesize\n        \\begin{tabular}{cc} \n        \\toprule\n        \\textbf{Flag}&\\textbf{Description} \\\\\\midrule\n        \\texttt{no-align-double} & \\specialcell{Specifies that \\texttt{malign-double} should not be passed as a compiler argument on 32-bit platforms. \\textbf{Step}: NVCC} \\\\ \\midrule\n        \\texttt{use\\_fast\\_math} & \\specialcell{Uses the fast math library, implies \\texttt{ftz=true}, \\texttt{prec-div=false}, \\texttt{prec-sqrt=false} and \\texttt{fmad=true}. \\textbf{Step}: NVCC} \\\\\\midrule\n        \\texttt{gpu-architecture} & \\specialcell{Specifies the NVIDIA virtual GPU architecture for which the CUDA input files must be compiled. \\textbf{Step}: NVCC \\textbf{Values}: \\texttt{sm\\_20}, \\texttt{sm\\_21}, \\texttt{sm\\_30}, \\texttt{sm\\_32}, \\texttt{sm\\_35}, \\texttt{sm\\_50}, \\texttt{sm\\_52}} \\\\\\midrule\n        \\texttt{relocatable-device-code} & \\specialcell{Enables the generation of relocatable device code. If disabled, executable device code is generated. Relocatable device code must be linked before it can be executed. \\textbf{Step}: NVCC} \\\\\\midrule\n        \\texttt{ftz} & \\specialcell{Controls single-precision denormals support. \\texttt{ftz=true} flushes denormal values to zero and \\texttt{ftz=false} preserves denormal values. \\textbf{Step}: NVCC} \\\\\\midrule\n        \\texttt{prec-div} & \\specialcell{Controls single-precision floating-point division and reciprocals. \\texttt{prec-div=true} enables the IEEE round-to-nearest mode and \\texttt{prec-div=false} enables the fast approximation mode. \\textbf{Step}: NVCC} \\\\\\midrule\n        \\texttt{prec-sqrt} & \\specialcell{Controls single-precision floating-point squre root. \\texttt{prec-sqrt=true} enables the IEEE round-to-nearest mode and \\texttt{prec-sqrt=false} enables the fast approximation mode. \\textbf{Step}: NVCC} \\\\\\midrule\n        \\texttt{def-load-cache} & \\specialcell{Default cache modifier on global/generic load. \\textbf{Step}: PTX \\textbf{Values}: \\texttt{ca}, \\texttt{cg}, \\texttt{cv}, \\texttt{cs}} \\\\\\midrule\n        \\texttt{opt-level} & \\specialcell{Specifies high-level optimizations. \\textbf{Step}: PTX \\textbf{Values}: \\texttt{0 - 3}} \\\\\\midrule\n        \\texttt{fmad} & \\specialcell{Enables the contraction of floating-point multiplies and adds/subtracts into floating-point multiply-add operations (FMAD, FFMA, or DFMA). \\textbf{Step}: PTX} \\\\\\midrule\n        \\texttt{allow-expensive-optimizations} & \\specialcell{Enables the compiler to perform expensive optimizations using maximum available resources (memory and compile-time). If unspecified, default behavior is to enable this feature for optimization level $\\geqslant$O2. \\textbf{Step}: PTX} \\\\\\midrule\n        \\texttt{maxrregcount} & \\specialcell{Specifies the maximum number of registers that GPU functions can use. \\textbf{Step}: PTX \\textbf{Values}: \\texttt{16 - 64}} \\\\\\midrule\n        \\texttt{preserve-relocs} & \\specialcell{Makes the \\texttt{PTX} assembler generate relocatable references for variables and preserve relocations generated for them in the linked executable. \\textbf{Step}: NVLINK} \\\\\\midrule\n        \\end{tabular}\n    \\caption{Description of flags in the search space}\n    \\label{tab:flags} \n\\end{table}\n\nTable~\\ref{tab:flags} details the subset of the CUDA configuration\nparameters used in the experiments~\\footnote{Adapted from: http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc [Accessed on 20 February 2018]}.\nThe parameters target different compilation steps: the \\emph{PTX} optimizing assembler;\nthe \\emph{NVLINK} linker; and the \\emph{NVCC} compiler.  We compared the\nperformance of programs generated by tuned parameters with the\nstandard compiler optimizations, namely \\texttt{--opt-level=0,1,2,3}. \nDifferent \\texttt{--opt-level}s could also be selected during tuning. \nWe did not use compiler options that target the host linker or the library manager \nsince they do not affect performance.\nThe size of the search space defined by all possible combinations\nof the flags in Table~\\ref{tab:flags} is in the order of $10^{6}$ making\nhand-optimization or exhaustive searches very time consuming.\n\nFigure~\\ref{fig:autotuning} show the results of the application matrix multiplication with the 4 different version used in this work. We can see that optimizations can be done by compiler parameters, and these compiler parameters can impact the speedup of GPU application in up $4x$, this work has been done by~\\cite{bruel:2017:CCPE}.\n\n\\begin{figure}[htpb]\n\t\\centering\n    \\includegraphics[scale=.2]{images/MatrixSummary.eps}\n    \\caption{Summary of the speedups achieved versus \\emph{-O2} in matrix multiplication versions}\n    \\label{fig:autotuning}\n\\end{figure}", "meta": {"hexsha": "ed87f161938b1cc10e6dbdeb9ea58cd743fc9bb8", "size": 11649, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/thesis/sections/characterization.tex", "max_stars_repo_name": "marcosamaris/svm-gpuperf", "max_stars_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-06-03T18:32:48.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-03T18:32:48.000Z", "max_issues_repo_path": "docs/thesis/sections/characterization.tex", "max_issues_repo_name": "marcosamaris/svm-gpuperf", "max_issues_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/thesis/sections/characterization.tex", "max_forks_repo_name": "marcosamaris/svm-gpuperf", "max_forks_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.2956521739, "max_line_length": 1023, "alphanum_fraction": 0.7721692849, "num_tokens": 3052, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.42951421659650413}}
{"text": "% To build, install TeX-Live, then in this directory,\n% pdflatex spark-inequality-impact.tex\n% bibtex spark-inequality-impact.aux\n% pdflatex spark-inequality-impact.tex\n% pdflatex spark-inequality-impact.tex\n\n\\documentclass[11pt, oneside]{article}  % use \"amsart\" instead of \"article\" for AMSLaTeX format\n\\usepackage{geometry}\n\\geometry{letterpaper}                  % ... or a4paper or a5paper or ...\n%\\geometry{landscape}                   % Activate for for rotated page geometry\n\\usepackage[parfill]{parskip}           % Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}                   % Use pdf, png, jpg, or eps with pdflatex; use eps in DVI mode\n                                        % TeX will automatically convert eps --> pdf in pdflatex\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\usepackage{breakurl}\n\\usepackage{mathtools}\n\\usepackage{listings}\n\n\\lstset{basicstyle=\\small}\n\n\\DeclareMathOperator{\\Atkinson}{A}\n\\DeclareMathOperator{\\round}{round}\n\n\\title{spark-inequality-impact Background}\n\\author{Stuart Ambler, Guillaume Saint Jacques, Amir Sepehri}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\nThe spark-inequality-impact software provides a way for economists and others to compute the Atkinson index, a measure of economic inequality, from any Apache Spark DataFrame with a non-negative ``value'' column of double type (not necessarily monetary amounts), using a scala UDAF (user-defined aggregation function) that also gives a ``theoretical'' (asymptotic) variance for the index.  This will scale to large amounts of data.  The software also allows inference on the Atkinson index, including functions to calculate approximate confidence intervals for the index, confidence intervals for the difference of indices from two populations, p-values for the hypothesis that two samples come from populations with the same Atkinson index, and given an Atkinson index value and its $\\epsilon$ parameter, an Atkinson-equivalent population of ``haves'' and ``have-nots'', usable as a representative population for that value.\n\nPlease see also \\cite{SaintJacques} for broader background, more connections and detail.  In particular it gives the asymptotic distribution of the index, which this software uses to calculate an approximate variance.  For background in spark, \\cite{Spark} is the documentation for the version of Spark the software has been tested with.  There are many online tutorials.  There are many online references on statistical inference; one that emphasizes the normal approximations we use, which are suitable for large samples, is \\cite{Matloff} (see chapter 15 for confidence intervals and section 16.4 for p-values).\n\n\\section{The Atkinson inequality index and its $\\epsilon$ parameter}\n\nThe British economist Anthony B. Atkinson wrote a paper ``On the Measurement of Inequality'' \\cite{Atkinson} in 1970 that discusses measures of inequality including the one now named after him, that can be derived from mathematical assumptions about social utility functions and inequality measures.  The Atkinson index summarizes in one number between $0$ and $1$, the inequality of incomes of a group of people.  The value $0$ is attained when everyone has the same income.  Higher values indicate more inequality, and $1$ is an upper bound.\n\nThere is an adjustable parameter $\\epsilon$, used to indicate how averse to inequality the index will be.  In the spark-inequality-impact software, we assume $0 \\le \\epsilon < 1$.  It is a choice, with $0$ indicating no aversion to inequality and $1$ indicating considerable aversion; see \\cite{SaintJacques} for more on this choice.  \\cite{AtkinsonWiki} gives summary information on the Atkinson index and an interpretation of $\\epsilon$.\n\nThe Atkinson index of inequality with inequality aversion parameter \\(\\epsilon \\) on a sample \\(x_1, \\ldots, x_n\\) is defined by the formula\n\\[ \\Atkinson_\\epsilon (x_1, \\ldots, x_n) = 1 - \\frac{(\\frac{1}{n}\\sum_{i=1}^n x_i^{1-\\epsilon})^\\frac{1}{1-\\epsilon}}{\\frac{1}{n}\\sum_{i=1}^n x_i}.\\]\n\nAn important feature of the Atkinson index method is the fact that it is agnostic to the underlying factors driving inequality, and only measures the inequality in the distribution.\n\n\\section{A simple interpretation of the Atkinson index}\n\nHere is a simple way to get a sense of meaning of the actual values of Atkinson indices. The basic idea is to pick, from the infinity of populations with the same Atkinson index (given $\\epsilon$), an especially easy to understand representative.\n\n\\subsection{Haves and have-nots}\n\nConsider taking the total income for a group of people and dividing it equally among a fraction of them, the ``haves'', leaving the others with no income, the ``have-nots''.  If the fraction is $0$ (no ``haves'') or $1$ (no ``have-nots''), the Atkinson index is $0$ for perfect equality.  Otherwise, if there are relatively few haves, the Atkinson index is large, indicating a lot of inequality, or if relatively many, the index is smaller.  This allows a conversion from the Atkinson index of a group of people (and $\\epsilon$), to a representative group with only ``haves'' and ``have-nots'' but with the same Atkinson index.  Below are graphs of the conversion for three values of $\\epsilon$.\n\nMore technically, let the population size be $N$.  Since the Atkinson index is invariant when all incomes are multiplied by the same positive number, we may as well say that all the ``haves'', whose number is $m$, get $1$ unit of income, and the ``have-nots'', $0$.  Thus we can take the list $x$ of incomes with $m$ equal to $1$ and $N - m$ equal to $0$.  Then the Atkinson index is\n\\begin{align}\n  \\Atkinson_{\\epsilon)}(x) &= 1 - \\frac{(\\frac{m}{N})^{\\frac{1}{1 - \\epsilon}}}{\\frac{m}{N}} = 1 - \\left(\\frac{m}{N}\\right)^{\\frac{\\epsilon}{1 - \\epsilon}} \\notag\n\\end{align}\nConversely, if we know the Atkinson index $a$, we can get the fraction $f$ of ``haves'', and obtain their number $m$ to a pretty good approximation since $N$ is fairly large for us, by $m = \\round(f N)$.  If $a$ is $1$ we set $f$ to something tiny and $m$ to $1$.  Otherwise,\n\\begin{align}\n  f &= (1 - a) ^ \\frac{1 - \\epsilon}{\\epsilon} \\notag\n\\end{align}\n\n\\includegraphics[scale=0.5]{../R/atkinson-to-haves.pdf}\n\n\\subsection{Comparison of pairs of Atkinson indices using haves}\nIt may be important to compare Atkinson indices for pairs of groups, such as from A/B tests.  Each of the Atkinson indices can be converted to a fraction, and then the fractions subtracted.  The interpretation, for example of ``the Atkinson-equivalent fraction of haves increased by 0.1'' would be that splitting up the income equally among a group of haves of the size that corresponds to the Atkinson index, both before and after an intervention, the fraction of haves increased by $0.1$.\n\n\\subsection{Variance of number and fraction of haves in a random sample}\nSuppose that we sample $r$ elements at random from a population of size $N$ that actually has $h$ haves. Then following \\cite{Feller} pages 232-233, the number of haves in the sample has a hypergeometric distribution with expected value $r h / N$ and variance $r h (N - h) (N - r) / (N^2 (N - 1))$.  Letting $f = h / N$ denote the fraction of haves in the population,\n\\begin{align}\n  \\text{Expected fraction of haves in sample} &= f \\notag \\\\\n  \\text{Variance of fraction of haves in sample} &= f (1 - f) \\frac{N - r}{N - 1} \\notag\n\\end{align}\n(The factor $(N - r) / (N - 1)$ would be omitted if the sampling were with replacement.)  To compute confidence intervals for the haves fraction, one can use R package hypersamplan, or e.g. the online calculator at \\url{https://epitools.ausvet.com.au/ciproportion}.\n\nIn a simulation drawing samples of size $2$K from a population of size $20$K with $20$\\% $1$s and the rest $0$s, the actual and calculated variances agreed within $1.4$\\%.  For a gamma distribution with shape parameter 0.114 (sharply peaked) the agreement was within $13$\\%.  For lognormal data, the ratio of actual to calculated was $15$ in one run; the numbers varied from run to run.\n\n\\section{A way to think  of  Atkinson index differences in terms of CDFs}\n\nHere is theoretical background giving a way to think of the difference of two Atkinson indices, in terms of the distributions of the populations.  The population value of the Atkinson index is\n\n\\[ \\Atkinson_\\epsilon(F) = 1 - \\frac{\\left(\\int x^{1-\\epsilon} dF(x) \\right)^{\\frac{1}{1-\\epsilon}}}{\\int x dF(x)} \\]\n\nSince the Atkinson index is scale invariant, we can assume \\(\\int x dF(x) = 1\\). Then, we can compare the Atkinson index for two populations with CDFs \\(F\\) and \\(G\\) using the following heuristic:\n\n\\[\\Atkinson_\\epsilon(F)  - \\Atkinson_\\epsilon(G)  \\approx \\left(\\int x^{1-\\epsilon} dG(x) \\right)^{\\frac{\\epsilon}{1-\\epsilon}}  \\left(\\int x^{-\\epsilon} (G(x)- F(x)) d x \\right)\\].\n\nWhat this means is that the difference between the distribution at \\(x\\) is weighted by \\(x^{-\\epsilon}\\). This weights the difference at the lower part of the population more heavily than the upper part. The difference in the weighting depends on \\(\\epsilon\\). The following derivation justifies the approximation.\n\nFor two populations with CDFs \\(F\\) and \\(G\\) we have\n\n\\[  \\Atkinson_\\epsilon(F)  - \\Atkinson_\\epsilon(G) = \\left(\\int x^{1-\\epsilon} dG(x) \\right)^{\\frac{1}{1-\\epsilon}} - \\left(\\int x^{1-\\epsilon} dF(x) \\right)^{\\frac{1}{1-\\epsilon}} \\]\n\nA Taylor expansion of the function \\(f(x) = x^{\\frac{1}{1-\\epsilon}} \\) yields\n\n\\[\\Atkinson_\\epsilon(F)  - \\Atkinson_\\epsilon(G)  \\approx \\frac{1}{1-\\epsilon} \\left(\\int x^{1-\\epsilon} dG(x) \\right)^{\\frac{\\epsilon}{1-\\epsilon}}  \\left(\\int x^{1-\\epsilon} dG(x) - \\int x^{1-\\epsilon} dF(x) \\right) \\]\n\nUsing integration by parts we get the result.\n\n\\medskip\n\n\\addcontentsline{toc}{section}{References}\n\\bibliography{spark-inequality-impact}{}\n\\bibliographystyle{alpha}\n\n\\end{document}\n", "meta": {"hexsha": "7e82e09f705246035092fc24d17c3506574065a7", "size": 9931, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "spark-inequality-impact/src/main/tex/spark-inequality-impact.tex", "max_stars_repo_name": "linkedin/spark-inequality-impact", "max_stars_repo_head_hexsha": "3115ea1bba54d82cdfeade4e6285cf8c8115e34c", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2020-05-27T20:23:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-02T13:34:45.000Z", "max_issues_repo_path": "spark-inequality-impact/src/main/tex/spark-inequality-impact.tex", "max_issues_repo_name": "linkedin/spark-inequality-impact", "max_issues_repo_head_hexsha": "3115ea1bba54d82cdfeade4e6285cf8c8115e34c", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spark-inequality-impact/src/main/tex/spark-inequality-impact.tex", "max_forks_repo_name": "linkedin/spark-inequality-impact", "max_forks_repo_head_hexsha": "3115ea1bba54d82cdfeade4e6285cf8c8115e34c", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-05-30T06:01:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T16:24:42.000Z", "avg_line_length": 90.2818181818, "max_line_length": 925, "alphanum_fraction": 0.737387977, "num_tokens": 2631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.42951421278873386}}
{"text": "\\chapter{Magnetic Field in Matter}\n\\section{Magnetization}\n\\begin{wrapfigure}{r}{0.3\\textwidth}\n\t\\begin{center}\n\t\t\\includegraphics[width=0.28\\textwidth]{magnetic moment}\n\t\\end{center}\n\t\\caption{magnetic dipole moment}\n\\end{wrapfigure}\n\nIn  electrostatics, we had seen that the electrical polarization of the medium  influences the electrical behavior of substances. In the same way we have internal currents within a material because there are moving charges in atoms and molecules which can create their own magnetic field.Any current loop has a magnetic field and thus has a magnetic dipole moment.There are two types effects here, the first is due to the orbital motion of the electrons and the second is due to the intrinsic spin magnetic moment of the electrons. The second effect is purely quantum mechanical in origin .Like in the electrostatic case, the magnetic moment could be intrinsic to an atom or molecule or it could be induced by an externally applied magnetic field. \\par\nOrdinarily, the current loops inside an object cancel each other out because of the random orientation of the atoms. But when a magnetic field is applied, a net alignment of these magnetic dipoles occurs, and the medium becomes magnetically polarized, or magnetized.\n\\\\\nLet ${m_{i}}$ be the magnetic moment of the $\\mathrm{i}$ -th atom inside a matter. We define magnetization as the net magnetic moment per unit volume\n$$\n\\vec{M}=\\lim _{\\Delta V \\rightarrow 0} \\frac{\\sum_{i} {m_{i}}}{\\Delta V}\n$$\nThe magnetization  plays a role analogous to the polarization ${P}$ in electrostatics.  The magnetization  could be paramagnetism, diamagnetism, or even ferromagnetism. We'll discuss it later.\n\\subsection{Surface and Volume current}\nSuppose we have a piece of magnetized material the magnetic dipole moment per unit volume, ${M}$, is given.The vector potential of a single dipole ${m}$ is given by, (We don't do derivation here).\n\\begin{align*}\n\\vec{\\mathrm{A}}(\\mathrm{r})&=\\frac{\\mu_{0}}{4 \\pi} \\int \\frac{1}{r}\\left[\\nabla^{\\prime} \\times \\mathrm{M}\\left(\\mathrm{r}^{\\prime}\\right)\\right] \\mathrm{d} \\tau^{\\prime}+\\frac{\\mu_{0}}{4 \\pi} \\oint \\frac{1}{\\mathrm{r}}\\left[\\vec{\\mathrm{M}}\\left(\\mathrm{r}^{\\prime}\\right) \\times \\vec{\\mathrm{d}} \\mathrm{a}^{\\prime}\\right]\n\\intertext{The first term looks like the potential of a volume current density,}\n{J}_{M}&=\\nabla \\times {M},\n\\intertext{While the second term looks like the potential of a surface current density,}\n{K}_{M}&={M} \\times \\hat{n}\n\\intertext{Where $\\hat{n}$ is the normal unit vector. With these definitions,}\n\\vec{A}({r})&=\\frac{\\mu_{0}}{4 \\pi}\\left\\{\\int \\frac{{J}_{M}\\left({r}^{\\prime}\\right)}{r} d\\tau^{\\prime}+\\oint \\frac{{K}_{M}\\left({r}^{\\prime}\\right)}{r} \\vec{d a^{\\prime}}\\right\\}\n\\end{align*}\n\\subsection{Auxiliary Field}\nThere are both free and bound current in a magnetic material. So the total current ${J}$ could be written as\n\\begin{align*}\n\\vec{J}&=\\mathrm{J}_{\\mathrm{b}}+\\mathrm{J}_{\\mathrm{f}}\n\\intertext{Where ${J}_{b}$ is bound and ${J}_{f}$ is the free current.}\n\\intertext{According to Ampere's law,}\n\\oint \\vec{\\mathrm{B}} \\cdot \\mathrm{d} \\vec{l}&=\\mu_{0} \\mathrm{I}_{\\mathrm{enc}} \\\\\n\\vec{\\nabla} \\times \\vec{\\mathrm{B}}&=\\mu_{0} \\vec{\\mathrm{J}}\n\\intertext{ Let us substitute the value of $J_b$}\n\\vec{\\mathrm{J}}_{\\mathrm{b}}&=\\vec{\\nabla} \\times \\vec{\\mathrm{M}} \\\\\n\\frac{1}{\\mu_{0}}(\\vec{\\nabla} \\times \\vec{\\mathrm{B}})&=\\vec{\\mathrm{J}}\\\\&=\\vec{\\mathrm{J}}_{\\mathrm{f}}+\\vec{\\mathrm{J}}_{\\mathrm{b}}\\\\&=\\vec{\\mathrm{J}}_{\\mathrm{f}}+(\\vec{\\nabla} \\times \\vec{\\mathrm{M}}) \\\\\n\\vec{\\nabla} \\times\\left(\\frac{1}{\\mu_{0}} \\vec{\\mathrm{B}}-\\vec{\\mathrm{M}}\\right)&=\\vec{\\mathrm{J}_{\\mathrm{f}}}\n\\intertext{Now, define the quantity inside the curl as ${H}$}\n\\vec{\\mathrm{H}} &\\equiv \\frac{1}{\\mu_{0}} \\vec{\\mathrm{B}}-\\vec{\\mathrm{M}}\n\\intertext{So now the equation becomes}\n\\vec{\\nabla} \\times \\overrightarrow{\\mathrm{H}}&=\\overrightarrow{\\mathrm{J}}_{\\mathrm{f}}\n\\intertext{Or in integral terms,}\n\\phi \\overrightarrow{\\mathrm{H}} \\cdot \\mathrm{d} \\vec{l}&=\\mathrm{I}_{\\mathrm{fenc}}\n\\intertext{Where $I_{\\text {fenc }}$ is the total free current passing through the Amperian loop. These are the forms of Ampere's law inside matter. $  H $ plays a role in magnetostatics analogous to $D$ in electrostatics:}\n\\end{align*}\n\\section{Linear and Non linear medium}\nTo complete the description of macroscopic magnetostatics, there must be a constitutive relation between ${H}$ and ${B}$.\n\\begin{align}\n\\notag {M}&\\propto{H}\\\\\n{M}&=\\chi_{m} {H}\\label{magnetic susceptibility}\n\\end{align}\n The constant $\\chi_{m}$ is called the magnetic susceptibility. It is dimensionless quantity it's typical values are around $10^{-5}$.\n Materials that obey equation.\\ref{magnetic susceptibility} are called linear media. For linear media\n \\begin{align*}\n {B}&=\\mu_{0}({H}+{M})=\\mu_{0}\\left(1+\\chi_{m}\\right) {H}\n \\intertext{ Thus ${B}$ is also proportional to ${H}$ :}\n {B}&=\\mu {H}\n  \\intertext{Where $\\mu=\\mu_{0}\\left(1+\\chi_{m}\\right)$ is the permeability of the material.}\n\\end{align*}\n \\section{Diamagnetism, Paramagnetism, Ferromagnetism}\nBased on the magnetic response, materials can be classified into the following three major groups:  Diamagnetism,  Paramagnetism,  and Ferromagnetism.\n\\subsection{Diamagnetism} \nDiamagnetism, a very weak fundamental property of all matter, arises due to the non-cooperative behavior of orbiting electrons when exposed to an externally applied magnetic field. \n\\begin{itemize}\n\t\\item  Very weak; exists ONLY in presence of an external field, non-permanent.\n\t\\item  Applied external field acts on atoms of a material, slightly unbalancing their orbiting electrons, and creates small magnetic dipoles within atoms which oppose the applied field. This action produces a negative magnetic effect known as diamagnetism.\n\t\\item  The induced magnetic moment is small, and the magnetization $(M)$ direction is opposite to the direction of applied field $(H)$.\n\t\\item  Thus the relative permeability is less than unity i.e. magnetic susceptibility $(\\chi_{m})$ is negative, and is in order of $-10^{-5}$.\n\t\\item  Materials such as $\\mathrm{Cu}, \\mathrm{Ag}, \\mathrm{Si}$, Ag and alumina are diamagnetic at room temperature.\n\\end{itemize}\n\\subsection{Paramagnetism} \nMaterials which exhibit a small positive magnetic susceptibility in the presence of a magnetic field are called para-magnetic, and the effect is termed as para-magnetism.\nThis class of the materials has a net magnetic moment due to the existence of unpaired electrons in partially filled orbitals. However, the individual magnetic moments do not interact magnetically and hence the magnetization is zero when there is no external applied field or when the externally applied field is removed.\n\\begin{itemize}\n\t\\item  Slightly stronger than Diamagnetism. When an external field is applied dipoles line-up with the field, resulting in a positive magnetization. However, the dipoles do not interact.\n\t \n\t\\item In the absence of an external field, the orientations of atomic magnetic moments are random leading to no net magnetization.\n\t\\item  When an external field is applied dipoles line-up with the field, resulting in a positive magnetization.\n\t- However, because the dipoles do not interact, extremely large magnetic fields are required to align all of the dipoles.\n\t\\item  In addition, the effect is lost as soon as the magnetic field is removed.\n\t\\item  Since thermal agitation randomizes the directions of the magnetic dipoles, an increase in temperature decreases the paramagnetic effect.\n\t\\item Magnetic susceptibility $(\\chi_{m})$  of these materials is slightly positive, and lies in the range $+10^{-5}$ to $+10^{-2}$\n\t\\item  Para-magnetism is produced in many materials like aluminium, calcium, titanium, alloys of copper.\n\\end{itemize}\n\n\\subsection{Ferromagnetism} \nCertain materials possess permanent magnetic moments even in the absence of an external field, These are called Ferromagnetic materials.\nThe atomic moments in these materials exhibit very strong interactions. These interactions are produced by electronic exchange forces and result in either a parallel or an antiparallel alignment of atomic moments \n\\begin{itemize}\n\t\\item  Both dia- and para- magnetic materials are considered as non-magnetic because they exhibit magnetization only in presence of an external field.\n\n\\item  The permennat dipoles can easily line-up with the imposed magnetic field due to the exchange interaction or mutual reinforcement of the dipoles. These are chrematistics of ferromagnetism.\n\\item  Materials with ferro-magnetism (Examples: Fe, Co, Ni, Gd) possess magnetic susceptibilities approaching $10^{6}$.\n\t\\item  Above a specific temperature called Curie temperature, ferro-magnetic materials behave as para-magnetic materials and their susceptibility is given by the Curie-Weiss law, defined as\n\t$$\n\t\\chi_{m}=\\frac{C}{T-T_{c}}\n\t$$\n\t Where $C$ - material constant, $T-$ temperature, $T_{c}-$ Curie temperature.\n\t\\item  Ferro Magnets are very strong; dipoles line-up permanently upon application of external field. Has two sub-classes:-\n\t\\begin{itemize}\n\t\t\\item Anti-ferro-magnetism.\n\t\t\\item  Ferri-magnetism\n\t\\end{itemize}\n\t\n\\end{itemize}\n \\section{Magnetostatic Boundary Conditions}\nJust as the electric field suffers a discontinuity at a surface charge, so the magnetic field is discontinuous at a surface current. Only this time it is the tangential component that changes.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=4cm,width=6.5cm]{3-crop}\n\t\\caption{Wafer thin pillbox}\n\t\\label{Wafer thin pillbox}\n\\end{figure}\n Indeed, if we apply $\\nabla \\cdot {B}=0$ in the integral form\n$\\oint_{S} {B} \\cdot  d a=0$\\ \nto a thin gaussian pillbox straddling the surface Figure. \\ref{Wafer thin pillbox} , we obtain,\n\\begin{equation}\\label{boundary condition}\nB_{above}^{\\perp}-B_{below}^{\\perp}=0.\n\\end{equation}\nWhere $B^{\\perp}$ is the component of the magnetic field ${B}$ perpendicular to the surface. Equation.\\ref*{boundary condition} tells us that\n$B^{\\perp}$ is continuous at the interface. \n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=4cm,width=6.5cm]{3-crop}\n\t\\caption{Amperian loop}\n\t\\label{Amperian loop}\n\\end{figure}\n\\begin{align}\n\\intertext{As for the tangential components, from Ampere's law $\\nabla \\times {B}=\\mu_{0}{I_{enc}}$ an amperian loop running perpendicular to the current figure.\\ref{Amperian loop} yields}\n\\notag \\oint {B} \\cdot d {l}&=\\left(B_{above}^{\\|}-B_{below}^{\\|}\\right) l\\\\\\oint {B} \\cdot d {l}&=\\mu_{0}K l .\\\\\n\\text{or} \\quad B_{above}^{\\|}-B_{below}^{\\|}&=\\mu_{0}K\n\\intertext{Thus the component of ${B}$ that is parallel to the surface but perpendicular to the current is discontinuous in the amount $\\mu_{0}K$.These results can be summarized in a single formula: }\n\\vec{\\mathrm{B}}_{\\text {above }}-\\vec{\\mathrm{B}}_{\\text {below }}&=\\mu_{0}(\\mathrm{~K} \\times \\hat{\\mathrm{n}})\n\\intertext{Where $\\hat{n}$ is a unit vector perpendicular to the surface, pointing \"upward\". Like the scalar potential of electrostatics the magnetic vector potential is also continuous}\nA_{\\text {above }}&=A_{\\text {below }}\n\\intertext{But the derivative of vector potential has a discontinuity}\n\\frac{\\partial \\mathrm{A}_{\\mathrm{above}}}{\\partial \\mathrm{n}}-\\frac{\\partial \\mathrm{A}_{\\text {below }}}{\\partial \\mathrm{n}}&=-\\mu_{0} \\mathrm{~K}\n\\end{align}\n\\begin{center}\n\t\\framebox{\n\t\t\\parbox[t][6cm]{7cm}{\n\t\t\t\n\t\t\t\\addvspace{0.2cm} \\centering \n\t\t\t\\begin{align*}\n\t\t\tB_{above}^{\\perp}-B_{below}^{\\perp}&=0\\\\\\\\\n\t\t\tB_{above}^{\\|}-B_{below}^{\\|}&=\\mu_{0}K\\\\\\\\\n\t\t\tA_{\\text {above }}&=A_{\\text {below }}\\\\\\\\ \\frac{\\partial \\mathrm{A}_{\\mathrm{above}}}{\\partial \\mathrm{n}}-\\frac{\\partial \\mathrm{A}_{\\text {below }}}{\\partial \\mathrm{n}}&=-\\mu_{0} \\mathrm{~K}\n\t\t\t\\end{align*}\n\t\t\t} }\n\\end{center}\n\\newpage\n\\begin{abox}\n\tPrevious year question\n\t\\end{abox}\n\\begin{enumerate}\n\t\\begin{minipage}{\\textwidth}\n\t\t\\item At a surface current, which one of the magnetostatic boundary condition is $\\underline{\\text { NOT }}$ CORRECT?\n\t\t\\exyear{GATE 2013}\n\t\\end{minipage}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}]Normal component of the magnetic field is continuous.\n\t\t\\task[\\textbf{B.}]Normal component of the magnetic vector potential is continuous.\n\t\t\\task[\\textbf{C.}]Tangential component of the magnetic vector potential is continuous.\n\t\t\\task[\\textbf{D.}]Tangential component of the magnetic vector potential is not continuous.\n\t\\end{tasks}\n\t\\begin{answer}\n\t\tThe correct option is \\textbf{(d)}\n\t\\end{answer}\n\n\\end{enumerate}\n\n", "meta": {"hexsha": "1809d8b3dd37f97b265421d7c9aad92f20b77ca3", "size": 12516, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Electrodynamics- CSIR/chapter/magnetic field in matter.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Electrodynamics- CSIR/chapter/magnetic field in matter.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Electrodynamics- CSIR/chapter/magnetic field in matter.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.52, "max_line_length": 752, "alphanum_fraction": 0.7362575903, "num_tokens": 3623, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.4295142089809636}}
{"text": "\\documentclass{book}\n \n\\usepackage{latexsym, graphics}\n\\usepackage{graphicx}\n\\usepackage{amsmath} \n \n\\DeclareMathOperator{\\Div}{div}\n\\DeclareMathOperator{\\Rot}{rot}\n\\newcommand{\\parder}[2]{\\frac{\\partial {#1}}{\\partial {#2}}}\n \n\\setlength{\\oddsidemargin}{0.0in}\n\\setlength{\\evensidemargin}{0.0in}\n\\setlength{\\topmargin}{-0.30in}\n \n\\setlength{\\textheight}{9in}\n\\setlength{\\textwidth}{6in}\n \n\\renewcommand{\\baselinestretch}{2.0}\n \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n \n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{definition}{Definition}[section]\n\\newtheorem{observation}{Observation}[section]\n\\newtheorem{proposition}{Proposition}[section]\n\\newtheorem{property}{Property}[section]\n\\newtheorem{problem}{Problem}[section]\n\\newtheorem{formulation}{Formulation}[chapter]\n \n\\newenvironment{proof}{{\\bf Proof:}\\ \\ }{\\begin{flushright} \\ \\\\\n                       {$\\Box$} \\end{flushright}}\n\\title{The Power Distribution Network Atlas:\\\\ \n  An Overview of PDN Design Fundaments }\n\\author{Ryan Coutts, Eric Zhang, C.K. Cheng}\n\\date{ }\n  \n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\chapter{Preface}\n\nThis book is not targeted at the engineer who works with modern power distribution networks (PDN) every day.  This book is targeted at the engineer who handles some of the adjacent systems and should know some of the basic considerations that go into PDN design.  \n\n\\subsection*{Organization}\nThis book is organized into ... sections.\n\nPDN Atlas Outline (add low level)\n1.\tIntroduction \n\n a.\tIntroduction to the PDN \n\n2.\tMathematics Fundamentals\n\na.\tRLC Models (Eric)\n\nb.\tScattering Parameters (Ryan)\n\nc.\tExtraction Fundamentals (Ryan)\n\nd.\tSimulation Backbones (Eric)\n\n3.\tArchitecture\n\na.\tVoltage Budgeting and the relationship to timing (Ryan)\n\nb.\tShared vs. Split rail Designs (Eric)\n\nc.\tSerial, Differential and Logic Rails and their important parameters (Ryan)\n\n4.\tComponents\n\na.\tVoltage Regulators (Eric)\n\nb.\tPrinted Circuit Boards (Eric)\n\nc.\tDecoupling Capacitors (Eric)\n\nd.\tSubstrate and Semiconductor Packaging (Eric)\n\ne.\tDie Level Design\n\ni.\tWire resistance at the nm level (Ryan)\n\nii.\tLayout dependent effects (Ryan)\n\niii.\tStatistical analysis (Ryan)\n\niv.\tPower Gating (Ryan)\n\nv.\tLDO (Ryan)\n\n5.\tAdvanced\n\na.\t3D IC and Advanced Packaging Effects (Eric)\n\nb.\tAdvanced Capacitors (Eric)\n\nc.\tCapacitor Optimization (Eric)\n\nd.\tTemperature dependent budget effects (Ryan)\n\ne.\tIntegrated Voltage Regulators (Ryan)\n \n\\chapter{Mathematics Fundamentals}\n\\section{The RLC Model}\n\\section{Scattering Parameters}\n\n\\textbf{Introduction}\n\nAlthough most PDN discussion start with a parametric evaluation of resistance, inductance and capacitance these three factors alone are not sufficient to describe the physics at work in a PDN system.  In reality, these systems are too large to be described by lumped elements.  \n\nFor example, resistance is the real component of loss through the network.  An ideal resistor has the same amount of loss at all frequencies, however because of the specific field distribution in wire there are eddy currents which prevent the flow of current down the middle of the wire at high frequencies.  As a result, the current must them flow exclusively on the outer layer of metal forcing the same amount of current through less metal making the loss component of a wire increase with frequency.  The depth at which the current flows is called the skin depth and denoted as $\\delta$.\n\nDue to the inability of the RLC model to describe and predict these effects, engineers have started to rely on full field solvers and scattering parameters.  A field solver is a software program which takes geometry, materials and boundary conditions as inputs and solves the electric and magnetic fields within a structure.  \n\nThere are a variety of field solvers available with different algorithms which usually trade-off accuracy and runtime. The most notable algorithms are the Finite Element Method (FEM) and Finite Difference Time Domain (FDTD). \n\n( More on Algorithms )\n\nWhatever algorithm is chosen to solve the structure the fundamental formulas they are solving are always Maxwell's Equations\\cite{maxwells}.  Maxwell's equations are four equations together that describe how electric and magnetics fields behave.  Although these equations are solved the by fields solver, understanding them is an important aspect of using the field solver.  \n\n\\textbf{Divergence}\n\n( Add Divergence )\n\n\\textbf{Curl}\n\n( Add Curl )\n\n\\textbf{Electric and Magnetic Fields}\n\n( Add description of magnetic and electric fields)\n\n\\textbf{Gauss's Law}\n\nGauss's law deals with the connection between the electric field and the electric charge stored within the volume.  The law says that the divergence of the electric field through any closed volume is equal to the amount of charge stored within the volume divided by the electric permeability of that volume.  This is written as equation \\ref{eq:Gauss}.\n\n\\begin{equation} \\label{eq:Gauss}\n\\nabla \\cdot \\vec{E}=\\frac{\\rho}{\\epsilon_{0}} \n\\end{equation}\n\nWhat this means is that electric charge is created by a spatial difference of electric field.  We can relate the electric field to voltage and say that a voltage difference then must contain charge.  This equation then directly relates to the capacitor equation $Q=CV$ which relates the voltage difference to charge. \n\n\\textbf{Gauss's Law for Magnetism}\n\nGauss's law relates the magnetic field to the magnetic charge stored in a volume.  The law says that the divergence of a magnetic field through any closed volume is equal to zero.  This is written as equation \\ref{eq:GaussMagnetism}.\n\n\\begin{equation} \\label{eq:GaussMagnetism}\n\\nabla \\cdot \\vec{B}=0\n\\end{equation}\n\n\nFundamentally, this means that magnetic charge does not exist in nature.  This implies that if you have a closed surface with a magnetic field, and charge does not exist, then any magnetic field lines entering the surface must also leave the surface with equal magnitude.  This in effect means that magnetic field lines are always drawn as ellipses that begin and end at the same location.  \n\n\\textbf{Faraday's Law of Induction}\n\nFaraday's Law of Induction relates to how a changing magnetic field can create an electric field.  The law states that the curl of the electric field is equal to  the negative time derivative of the changing magnetic field. This is written as equation \\ref{eq:FaradayLaw}.\n\n\\begin{equation} \\label{eq:FaradayLaw}\n\\nabla \\times \\vec{E} = - \\frac{\\delta \\vec{B}}{\\delta t}\n\\end{equation}\n\n\nThis means that when theres an enclosing magnetic flux which is changing a voltage potential will be generated.\n\n\\textbf{Ampere's Circuital Law}\n\nAmpere's Circuital Law relates the time varying electric field and current to the magnetic flux.  It says that current or a changing electric field will create a magnetic field .  This is written as equation \\ref{eq:AmperesLaw}\n\n\\begin{equation} \\label{eq:AmperesLaw}\n\\nabla \\times \\vec{B} = \\mu_{0} \\left(J + \\epsilon_{0} \\frac{\\delta  \\vec{E}}{\\delta t} \\right) \n\\end{equation}\n\n( Say something about this...)\n\n\\textbf{Impulse Response Abstraction}\n\nThe geometry and meshing that the field solvers do to obtain great accuracy can be abstracted to better leverage the technology.  The way that we leverage this is that we recognize that the system can be described by a linear time invariant (LTI) formulation.  This means that the system can be characterized at specific locations completely by an impulse response and re-used in future simulations without the field solver at almost no-accuracy loss and a huge speed increase.  This is done typically by leveraging scattering parameters.\n\n\\textbf{Scattering Parameters} \n\nScattering parameters were developed to describe the frequency profile of a linear time-invariant system.  The concept is to take a voltage wave and inject it into a system at a port. Then measure the voltage wave at that port and another port.  This means that S-parameters are essentially formulated with only two ports.  In fact, S-paremeters are always characterized with two ports at a time, but can be extended to any number of ports.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.7\\linewidth]{./Images/SParamaterBlackBox}\n\\caption{}\n\\label{fig:SParamaterBlackBox}\n\\end{figure}\n\nThe picture \\ref{fig:SParamaterBlackBox} shows a typical 2-Port network.  In order to characterize port 1, $V_{1}^{+}$ is excited with a specific frequency with a port impedance of $R_{p}$ which is usually $50 \\Omega $.  The return waves, $V_{x}^{-}$, are then measured in both phase and magnitude and recorded and the s-parameters are then generated for $S_{1x}$. This process is then repeated for the second port. Once complete the system can then be described by the s-parmaeter matrix equation \\ref{eq:spar_mtx}.\n\n\\begin{equation} \\label{eq:spar_mtx}\n\\begin{bmatrix} \nV_{1}^{-} \\\\  V_{2}^{-}\n\\end{bmatrix}\n=\n\\begin{bmatrix} \nS_{11} & S_{12} \\\\ \nS_{21} & S_{22} \n\\end{bmatrix}\n\\cdot\n\\begin{bmatrix} \nV_{1}^{+} \\\\  V_{2}^{+}\n\\end{bmatrix}\n\\end{equation}\n\n\\begin{equation} \nS_{11} = \\frac{V_{1}^{-}}{V_{1}^{+}}, \nS_{12} = \\frac{V_{1}^{-}}{V_{1}^{+}},\nS_{21} = \\frac{V_{1}^{-}}{V_{2}^{+}},\nS_{22} = \\frac{V_{2}^{-}}{V_{2}^{+}},\n\\end{equation}\n\nIn this formulation, all of the parameters contain a phase and magnitude and are on the imaginary plane.  \n\n\\textbf{Frequency to Time Domain Conversion}\n\nOnce the frequency domain is characterized we can convert to the time domain.  Because the time domain contains all frequency points and the frequency points in the s-parameter are explicitly characterized, we must design the frequency points in the characterization to contain the important frequency content we care about.  If we take too little frequency points to characterize the time domain waveform and ask another tool to use the limited s-parameter information then this can introduce error.  The tools typically have some way of trying to handle the missing information, but none of them are as good as the real data.\n\nWhen converting from frequency to time domain there are two rules that we must enforce: causality and passivity. \n\nCausality is the concept that the system will not respond until acted on.  This is to say that when computing the impulse response we expect all outputs to have no response before time=0s.  When there is frequency content missing in the s-parameter, the frequency error shows up at all frequencies including before the impulse.  This can cause stability issues in the simulation and as such simulators typically truncate the impulse response to prevent this phenomenon from effecting the results at the expense of accuracy.\n\nPassivity is \n\n\n\n\n\\textbf{Impedance Parameters}\n\nIn PDN designs we typically have a current load and we want to evaluate the voltage response.  This \n\n\n\n\n\\section{Extraction Fundamentals}\n\\section{Simulation Backbones}\n\n\\chapter{Architecture}\n\\section{Voltage Budget and Timing}\n\\section{Shared vs. Split Rail Designs}\n\\section{Serial, Differential, and Logic Rails and their Important Parameters}\n\n\n\\chapter{Components}\n\\section{Voltage Regulators}\n\\section{Printed Circuit Boards (PCB)}\n\\section{Decoupling Capacitors}\n\\section{Substrate and Semiconductor Packaging}\n\\section{Die Level Design}\n\\subsection{Wire Resistance at the nm Level}\n\\subsection{Layout Dependent Effects}\n\\subsection{Statistical Analysis}\n\\subsection{Power Gating}\n\\subsection{LDO}\n\n\\chapter{Advanced}\n\\section{3D IC and Advanced Packaging Effects}\n\\section{Advanced Capacitors}\n\\section{Capacitor Optimization}\n\\section{Temperature Dependent Budgeting}\n\\section{Integrated Voltage Regulators}\n\n\\begin{thebibliography}{99}\n\\bibitem{maxwells}\nMaxwell's equations - Cite\n\\end{thebibliography}\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "9d213acc89fba82a6ed7757542afcf697fc9d9c6", "size": 11750, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PDNA_PREFACE.tex", "max_stars_repo_name": "zxkidd/PDN_BOOK", "max_stars_repo_head_hexsha": "791195d572b2cc24c5f1282fb363584da0e88bfd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PDNA_PREFACE.tex", "max_issues_repo_name": "zxkidd/PDN_BOOK", "max_issues_repo_head_hexsha": "791195d572b2cc24c5f1282fb363584da0e88bfd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PDNA_PREFACE.tex", "max_forks_repo_name": "zxkidd/PDN_BOOK", "max_forks_repo_head_hexsha": "791195d572b2cc24c5f1282fb363584da0e88bfd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.5724637681, "max_line_length": 627, "alphanum_fraction": 0.7711489362, "num_tokens": 2878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4295142051731933}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{multicol}\n\\usepackage[formats]{listings}\n\\lstloadaspects{formats}\n\\usepackage{verbatim}\n\\usepackage{color}\n\\usepackage{geometry}\n\\usepackage{float}\n\\usepackage{amsmath}\n\\usepackage{caption}\n\\usepackage{pdflscape}\n\n\\usepackage{hyperref}\n\\setlength{\\belowcaptionskip}{-10pt}\n\\setlength{\\abovecaptionskip}{-30pt}\n\\floatstyle{boxed} \n\\restylefloat{figure}\n\\usepackage{graphicx}\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.92}\n\\lstdefinestyle{mystyle}{\n\tbackgroundcolor=\\color{backcolour},   \n\tcommentstyle=\\color{codegreen},\n\tkeywordstyle=\\color{blue},\n\tnumberstyle=\\tiny\\color{codegray},\n\tstringstyle=\\color{codepurple},\n\tbasicstyle=\\footnotesize,\n\tbreakatwhitespace=false,         \n\tbreaklines=true,                 \n\tcaptionpos=b,                    \n\tkeepspaces=true,                 \n\tnumbers=left,                    \n\tnumbersep=5pt,                  \n\tshowspaces=false,                \n\tshowstringspaces=false,\n\tshowtabs=false,                  \n\ttabsize=2\n}\n\\lstset{style=mystyle}\n\\title{Data Mining\\\\\n\t\tHome work 10\\\\Machine Learning III Regression Analysis }\n\\author{Aqeel Labash\\\\ \\textbf{Lecturer:} Jaak Vilo}\n\\date{13 April 2016}\n\\geometry{\n\ta4paper,\n\ttotal={170mm,257mm},\t\n\tleft=10mm,\n\ttop=5mm,\n}\n\\begin{document}\n\t\\maketitle\n\\section*{First Question}\nFor this task I used python and here is the code : \n\\begin{lstlisting}[language=Python]\n# #Question 1\nimport numpy as np\nget_ipython().magic(u'matplotlib inline')\nimport matplotlib.pyplot as plt\npoints = [(9,3,1),(2,4,1),(3,3,1),(4,1,1),(1,6,1),(3,9,0),(5,6,0),(6,4,0),(6,2,0),(3,7,0)]\n#Draw the figure\nplt.figure('points.jpg')\nplt.plot([x[0] for x in points],[x[1] for x in points],'bo')\nplt.plot([3,4],[5,6],'rv')\nplt.ylabel('Y')\nplt.xlabel('X')\nplt.title('Points')\nplt.savefig('points.jpg')\n\n#Print Probabilities for classes\ndef GetClosePoints(centerpoint,k=1):\n    indx =0\n    distances={}\n    for point in points:\n        \n        #Calculate Eucludean distance\n        distance = np.linalg.norm(np.array(centerpoint)-np.array((point[0],point[1])))\n        \n        #Store all points with the same distance under the same \n        if distance in distances.keys():\n            distances[distance].append(indx)\n        else:\n            distances[distance] = []\n            distances[distance].append(indx)\n        indx+=1\n        \n    #Sort list by distance\n    keys = distances.keys()\n    keys.sort(key = lambda x:x,reverse=False)\n    #print the list \n    #for key in keys:\n    #    print key , distances[key]\n        \n    #Get Points in K distance\n    pointindx=[]\n    for i in range (0,k):\n        for index in distances[keys[i]]:\n            pointindx.append(index)\n\n    #Print Selected Points indexs \n    #print pointindx\n    \n    #Calculate Probabilities\n    Totalpoints = len(pointindx)\n    Class0=0\n    Class1=0\n    for i in pointindx:\n        if points[i][2]:\n            Class1+=1\n        else:\n            Class0+=1\n    print 'For Point ({},{}) with K={},Probabilities is Class 0:{},Class 1:{}'.format(centerpoint[0],centerpoint[1],k,\n    Class0/float(Totalpoints),Class1/float(Totalpoints))\np1 = (3,5)\np2 = (4,6)\nGetClosePoints(p1,1)\nGetClosePoints(p1,2)\nGetClosePoints(p1,3)\nGetClosePoints(p2,1)\nGetClosePoints(p2,2)\nGetClosePoints(p2,3)\n\\end{lstlisting}\nWhat  I did in the previous code is:\n\\begin{enumerate}\n\t\\item Store the indexes of points with same distance from our point under same hash label.\n\t\\item Select the indexes depending on K\n\t\\item Count total points,points in class0 , points in class1\n\t\\item Print the probabilities\n\\end{enumerate}\nHere is an image showing how the points look like :\n\\begin{figure}[H]\n\\includegraphics[scale=1]{points.jpg}\n\\caption{Points in the plane.}\n\\end{figure}\nAnd here I report the output of the previous code :\\\\\nFor Point (3,5) with K=1,Probabilities is Class0=0.0,Class1=1.0\\\\\nFor Point (3,5) with K=2,Probabilities is Class0=0.333333333333,Class1=0.666666666667\\\\\nFor Point (3,5) with K=3,Probabilities is Class0=0.4,Class1=0.6\\\\\nFor Point (4,6) with K=1,Probabilities is Class0=1.0,Class1=0.0\\\\\nFor Point (4,6) with K=2,Probabilities is Class0=1.0,Class1=0.0\\\\\nFor Point (4,6) with K=3,Probabilities is Class0=0.75,Class1=0.25\n\\section*{Second Question}\nFor this question I build my own function to calculate the measurements from confusion matrix , here is the code:\n\\begin{lstlisting}[language=R]\nmeasuresprint<-function(cm)\n{\n  Accuracy<-(cm[2,2]+cm[1,1])/sum(cm)\n  Precision<-(cm[2,2])/(cm[2,2]+cm[1,2])\n  Recall<-cm[2,2]/(cm[2,2]+cm[2,1])\n  F1<-2*(Precision*Recall)/(Precision+Recall)\n  print(c(Accuracy,Precision,Recall,F1))\n}\n###### Second Question ########\ndiabetes <- read.csv('pima-indians-diabetes.data',header = FALSE)\ncolnames(diabetes)<-c('PregnantTimes','glucos_constr','Blood_pressure','Triceps','insulin','BMI','diabts_pedigree','Age','Class')\n#Shuffle The list so we pick randomly \ndiabetes<- diabetes[sample(nrow(diabetes)),]\ntraindata<-diabetes[seq(1,floor(nrow(diabetes)*0.8),1),]\ntest<-diabetes[seq(floor(nrow(diabetes)*0.8)+1,nrow(diabetes)),]\nmodule <- glm(Class~.,data = traindata)\nsummary(module)\npng('correlationhm.png')\nheatmap(cor(diabetes),symm = TRUE, Colv=NA, Rowv=NA,col=colorRampPalette(c(\"red\", \"yellow\", \"green\"))(n = 299))\ndev.off()\n\n#prediction_prop<-\nprediction_bin<-ifelse(predict(module, test)<=0.5,0,1)\nmeasuresprint(table(real=test$Class, predictions=prediction_bin))\n\\end{lstlisting}\nThe summary of the module output was :\n\\begin{lstlisting}\nCoefficients:\n                  Estimate Std. Error t value Pr(>|t|)    \n(Intercept)     -0.8270580  0.0952931  -8.679  < 2e-16 ***\nPregnantTimes    0.0227378  0.0055950   4.064 5.46e-05 ***\nglucos_constr    0.0058791  0.0005769  10.192  < 2e-16 ***\nBlood_pressure  -0.0027814  0.0009006  -3.088  0.00211 ** \nTriceps         -0.0001970  0.0012530  -0.157  0.87511    \ninsulin         -0.0002141  0.0001702  -1.258  0.20893    \nBMI              0.0135468  0.0022537   6.011 3.19e-09 ***\ndiabts_pedigree  0.1493781  0.0511308   2.921  0.00361 ** \nAge              0.0024483  0.0017115   1.430  0.15310    \n---\n\\end{lstlisting}\nFrom the summary we can notice that \"Plasma glucose concentration\" which equals to \"glucos\\_constr\" in table , that it's high significant to predict the class. Also we can see that it's highly correlated with the class.\n\\begin{figure}[H]\n\\includegraphics[scale=0.9]{correlationhm.png}\n\\caption{Heatmap for correlation}\n\\end{figure}\nFrom the previous figure we can see that plasma glucos is the most correlated to the class.\\\\\nFor \"diabetes pedigree\" we can see from the table that it's 2 stars significant, and from the correlation picture we can see it's less correlated than plasma glucos.\\\\\nTo do the calcuation I printed out the confusion matrix \\\\\n\\begin{tabular}{|c|c|c|}\n\\hline\nreal\\_ predic&0&1\\\\ \\hline\n0& 84 & 15 \\\\ \\hline\n   1 &22 &33\\\\ \\hline\n\\end{tabular}\nThe rules for the measurements :\n\\[Accuracy = \\frac{TP+TN}{Total} \\]\n\\[Precision = \\frac{TP}{TP+FP}\\]\n\\[Recall = \\frac{TP}{TP+FN} \\]\nF1 \"is the harmonic mean of precision and sensitivity\" \\cite{1}\n\\[F1 =\\frac{2TP}{2TP+FP+FN}\\]\nAnother way to calculate it\n\\[F1 =2.\\frac{precision*recall}{precision+recall}\\]\nThe measurements :\\[ Accuracy=0.7597403,Precision= 0.6875000,Recall= 0.6000000,F1= 0.6407767\\]\n\\section*{Third Question}\nFor this question I used the function knn in R and here is the code : \n\\begin{lstlisting}[language=R]\n####### Third Question#####\nlibrary(class)\nknn1prediction<-knn(traindata,test = test,cl=traindata$Class)\nmeasuresprint(table(real=test$Class, predictions=knn1prediction))\nknn3prediction<-knn(traindata,test = test,cl=traindata$Class,k = 3)\nmeasuresprint(table(real=test$Class, predictions=knn3prediction))\n\\end{lstlisting}\nFrom the previous code we get the measurements for k1 and k3 and in the following table I put all the measurements for k1,k3 and glm to compare them\\\\\n\\begin{tabular}{|l|*{5}{c|}}\n\\hline\nMethod&Accuracy&Precision&Recall&F1\\\\ \\hline\nglm&0.7597403&0.6875000&0.6000000&0.6407767\\\\ \\hline\nK1&0.6948052&0.5769231&0.5454545&0.5607477\\\\ \\hline\nK3&0.7272727&0.6181818&0.6181818&0.6181818\\\\ \\hline\n\\end{tabular}\\\\\nFrom the previous table we can see that logit regression got the best Accuracy and the highest F1 score.\n\\section*{Fourth Question}\nFor this question I used the following code : \n\\begin{lstlisting}[language=R]\n########## Fourth Question ###########\nrm(list=ls())\nsetwd('/home/aqeel/Study/DM/HW10/')\nlibrary(ggplot2)\ndata(\"diamonds\")\ndiamonds<- diamonds[sample(nrow(diamonds)),]\ntrainset<-diamonds[seq(1,floor(0.8*nrow(diamonds))),]\ntestset<-diamonds[seq(floor(0.8*nrow(diamonds))+1,nrow(diamonds)),]\nmodule1<-lm(price~.,data = trainset)\nmodule2<-lm(price~.+poly(carat,2)+poly(depth,2)-carat-depth,data = trainset)\nmodule3<-lm(price~.+poly(carat,3)+poly(depth,3)-carat-depth,data = trainset)\nmodule4<-lm(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,data = trainset)\nmodule1predtrn<-predict(module1, trainset)\nmodule2predtrn<-predict(module2, trainset)\nmodule3predtrn<-predict(module3, trainset)\nmodule4predtrn<-predict(module4, trainset)\nmodule1predtst<-predict(module1, testset)\nmodule2predtst<-predict(module2, testset)\nmodule3predtst<-predict(module3, testset)\nmodule4predtst<-predict(module4, testset)\n#install.packages(\"qpcR\")\nlibrary(qpcR)\ntrainRMSE<-c(sqrt(sum((module1predtrn-trainset$price)^2)/length(trainset$price)),\nsqrt(sum((module2predtrn-trainset$price)^2)/length(trainset$price)),\nsqrt(sum((module3predtrn-trainset$price)^2)/length(trainset$price)),\nsqrt(sum((module4predtrn-trainset$price)^2)/length(trainset$price)))\n\ntestRMSE<-c(sqrt(sum((module1predtst-testset$price)^2)/length(testset$price)),\nsqrt(sum((module2predtst-testset$price)^2)/length(testset$price)),\nsqrt(sum((module3predtst-testset$price)^2)/length(testset$price)),\nsqrt(sum((module4predtst-testset$price)^2)/length(testset$price)))\nnumbers<-seq(1,4,1)\npng('train_test.png')\nggplot(data.frame(cbind(numbers,trainRMSE)),aes(numbers, trainRMSE))+geom_line(col=\"red\") +\n  geom_line(aes(numbers,testRMSE),data =data.frame(cbind(numbers,testRMSE)),col=\"blue\" )+ xlab(\"Module\")+\n  ylab(\"RSME\")\n\\end{lstlisting}\n\nThe previous code will output the following picture which represent the Train vs Test RMSE value.\n\\begin{figure}[H]\n\\includegraphics[scale=1]{train_test.png}\n\\caption{Train RMSE in Red , Test in blue}\n\\end{figure}\nI would detect overfiting when the training RMSE keep decreasing while the testing RMSE start increasing. I believe we can see that from the plot after doing many iteration for the same module.With only one iteration it's hard to decide if we have overfiting mmmm maybe we can if the RMSE was pretty low for training and pretty high for testing.\\\\\nAlso I would notice from the plot that module 4 performed the best :).\n\\section*{Fifth Question}\nFor this question I used straight forward solution and here is the code :\n\\begin{lstlisting}[language=R]\nrm(list=ls())\nsetwd('/home/aqeel/Study/DM/HW10/')\ntrain <- read.csv('train.csv',header = TRUE)\nmodule<-lm(data = train,target~.)\nsummary(train)\ntest<-read.csv('test.csv',header = TRUE)\nhead(test[,c(1,2)])\nresult<-predict(module,test)\noutput<-cbind(result)\ncolnames(output)<-c('ID','target')\n\nwrite.csv(output,file='submit 001')\n\\end{lstlisting}\nI got  \tscore 1.95523 for this code :) \n\n\n\n\n\n\\section*{Sixth Question}\n\\section*{Seventh Question} \n\nThe code for this question :\n\\begin{lstlisting}[language=R]\n################ Seventh Question ############\nlibrary(MASS)\nmodule4ridge<- lm.ridge(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,data = trainset)\nmodule4ridge.trn.prd = as.matrix(model.matrix(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,trainset))%*% coef(module4ridge)\nmodule4ridge.tst.prd = as.matrix(model.matrix(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,testset))%*% coef(module4ridge)\n\n\n#install.packages(\"lars\")\nlibrary(lars)\nmodule4lasso <- lars(\n  model.matrix(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,trainset),\n  trainset$price, type=\"lasso\",trace = TRUE, max.steps=20)\nmodule4lasso.trn.prd <- predict(module4lasso,\n                        model.matrix(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,trainset),\n                        s=module4lasso$df[which.min(module4lasso$RSS)], type=\"fit\")$fit\n\n\nmodule4lasso.tst.prd <- predict(module4lasso,\n                                model.matrix(price~.+poly(carat,3)+poly(depth,3)+poly(x,2)+poly(y,2)+poly(z,2)-carat-depth-x-y-z,testset),\n                                s=module4lasso$df[which.min(module4lasso$RSS)], type=\"fit\")$fit\n\ntrainRMSE<-c(sqrt(sum((module1predtrn-trainset$price)^2)/length(trainset$price)),\n             sqrt(sum((module2predtrn-trainset$price)^2)/length(trainset$price)),\n             sqrt(sum((module3predtrn-trainset$price)^2)/length(trainset$price)),\n             sqrt(sum((module4predtrn-trainset$price)^2)/length(trainset$price)),\n             sqrt(sum(( module4lasso.trn.prd- trainset$price)^2)/length(trainset$price)),\n             sqrt(sum((module4ridge.trn.prd- trainset$price)^2)/length(trainset$price)))\n\ntestRMSE<-c(sqrt(sum((module1predtst-testset$price)^2)/length(testset$price)),\n            sqrt(sum((module2predtst-testset$price)^2)/length(testset$price)),\n            sqrt(sum((module3predtst-testset$price)^2)/length(testset$price)),\n            sqrt(sum((module4predtst-testset$price)^2)/length(testset$price)),\n            sqrt(sum(( module4lasso.tst.prd- testset$price)^2)/length(testset$price)),\n            sqrt(sum((module4ridge.tst.prd- testset$price)^2)/length(testset$price)))\nnumbers<-seq(1,6,1)\npng('all_modules.png')\nggplot(data.frame(cbind(numbers,trainRMSE)),aes(numbers, trainRMSE))+geom_line(col=\"red\") +\n  geom_line(aes(numbers,testRMSE),data =data.frame(cbind(numbers,testRMSE)),col=\"blue\" )+ xlab(\"Module\")+\n  ylab(\"RSME\")\ndev.off()\n\\end{lstlisting}\nThe RMSE for lasso and ridge was quite high so it won't be much clear in the graph but here is the graph : \\\\\n\\begin{figure}[H]\n\\includegraphics[scale=1]{all_modules.png}\n\\caption{Last two values are lasso and ridge}\n\\end{figure}\n\n\\textbf{Please note:}Faiz helped a lot in this question.\n\\textbf{Note: }All code , ipython , images , etc.. exist on \\href{https://github.com/aqeel13932/DM/tree/master/HW10}{github}\n\\begin{center}\n\\textbf{E.O.F}\n\\end{center}\n\\begin{thebibliography}{9}\n\t\\bibitem{1}\n\t\\href{https://en.wikipedia.org/wiki/Precision_and_recall}{Precision and Recall}\n\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "65443cb97f92b64008351f4f052eb828f8eae04c", "size": 14732, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW10/HW10 report.tex", "max_stars_repo_name": "aqeel13932/DM", "max_stars_repo_head_hexsha": "acf47c79d43ded6eb58d03f325c6d660d572ae6e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW10/HW10 report.tex", "max_issues_repo_name": "aqeel13932/DM", "max_issues_repo_head_hexsha": "acf47c79d43ded6eb58d03f325c6d660d572ae6e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW10/HW10 report.tex", "max_forks_repo_name": "aqeel13932/DM", "max_forks_repo_head_hexsha": "acf47c79d43ded6eb58d03f325c6d660d572ae6e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.9222222222, "max_line_length": 347, "alphanum_fraction": 0.7027559055, "num_tokens": 4628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4295142028397073}}
{"text": "\\chapter{Boosted Variational Bayesian Monte Carlo}\n\nIn this chapter, it is presented a modification of the Variational Bayesian Monte Carlo approach presented in Section \\ref{vbmc_section}, using ideas of boosting presented in \\ref{boostedvi_section}, along with some other minor modifications of the previous approach.\n\n\\section{Boosting Variational Bayesian Monte Carlo}\n\nThe idea underlying this approach is rather simple: instead of using a GP surrogate model for doing variational inference with mixtures of Gaussians as in \\ref{vbmc_section}, use it for variational inference with the gradient boosting approach discussed in section \\ref{boostedvi_section}.\n\nTo expand on this, consider again the algorithm in Figure \\ref{vbalgorithm}. In line 5, the objective \\eqref{relbogaussian} (here called \\textit{$f$-step}) consists of three terms\n\\begin{displaymath}\n \\begin{split}\n \\text{RELBO}(\\mu_i,\\Sigma_i) = & \\int \\log(\\gu(\\theta)) \\mathcal{N}(\\theta|\\mu,\\Sigma) d\\theta \\\\\n & - \\int \\log(q_{i-1}(\\theta)) \\mathcal{N}(\\theta|\\mu,\\Sigma) d\\theta \\\\\n & + \\frac{\\lambda}{4} \\log |\\Sigma|,\n \\end{split}\n\\end{displaymath}\nwhile in line 6, for the objective \\eqref{boosting_objective_alpha} (here called \\textit{$w$-step}), the gradient $\\mathcal{L}'_i(w_i)$ consists of\n\\begin{displaymath}\n\\begin{split}\n \\mathcal{L}'_i(w_i) = & \\int \\log (\\gu(\\theta)) f_{i}(\\theta) \\\\ \n & -\\int \\log(\\gu(\\theta)) q_{i-1}(\\theta)\\\\\n & + \\int \\log((1-w_{i}) q_{i-1}(\\theta) + w_{i} f_{i}(\\theta)) (f_i(\\theta) - q_{i-1}(\\theta)) d\\theta\n\\end{split}\n\\end{displaymath}\n\nThen, in the same vein of the VBMC method, set a $GP(m,k)$ prior for $\\log \\gu$, and given evaluations $\\mathcal{D}_0 = \\{(x_i,f(x_i))\\}_{i=1}^N$, substitute $\\log \\gu$ for $\\Ev \\log \\gu_\\mathcal{D}$. Since all the terms involving $\\log \\gu$ are expectations of either Gaussian distributions or mixture of Gaussian distributions, then one can approximate those by Bayesian Monte Carlo, as seen in \\eqref{evvarbmcgaussian} and \\eqref{bmcmixgaussians}, resulting in the maximization objective for the $f$-step:\n\\begin{equation}\\label{relbo_vbmc}\n\\begin{split}\n\\text{RELBO}_\\mathcal{D}(\\mu_i,\\Sigma_i) = & \\int \\Ev[\\log \\gu_\\mathcal{D}(\\theta)] \\mathcal{N}(\\theta|\\mu_i,\\Sigma_i) d\\theta - \\\\ &\\int \\log(q_{i-1}(\\theta)) \\mathcal{N}(\\theta|\\mu_i,\\Sigma_i) d\\theta\n+ \\frac{\\lambda}{4} \\log |\\Sigma_i|,\n\\end{split}\n\\end{equation}\nand the maximization objective for the $w$-step\n\\begin{equation}\\label{lalpha_vbmc}\n\\begin{split}\n \\mathcal{L}_{i,\\mathcal{D}}(w) = & \\int \\log \\gu_\\mathcal{D}(\\theta)\n ((1-w_{i}) q_{i-1}(\\theta) + w_{i} f_{i}(\\theta)) d\\theta - \\\\\n & \\int \\log ((1-w_{i}) q_{i-1}(\\theta) + w_{i} f_{i}(\\theta)) ((1-w_{i}) q_{i-1}(\\theta) + w_{i} f_{i}(\\theta)) d\\theta \\\\\n\\end{split}\n\\end{equation}\nwith gradient\n\\begin{equation}\n\\begin{split}\n\\mathcal{L}'_{i,\\mathcal{D}}(w) =& \\int \\Ev [\\log \\gu_\\mathcal{D}(\\theta)] f_{i}(\\theta) - \\int \\Ev [\\log \\gu_\\mathcal{D}(\\theta)] q_{i-1}(\\theta) + \\\\\n& \\int \\log((1-w_{i}) q_{i-1}(\\theta) + w_{i} f_{i}(\\theta)) (f_i(\\theta) - q_{i-1}(\\theta)) d\\theta,\n\\end{split}\n\\end{equation}\nwhere\n\\begin{equation}\nf_i(\\theta) = \\mathcal{N}(\\theta|\\mu_i,\\Sigma_i), \\quad q_{i-1}(\\theta) = \\sum_{k=0}^{i-1} w_k \\mathcal{N}(\\theta|\\mu_k,\\Sigma_k)\n\\end{equation}\nThe integrals not involving $\\log \\gu_\\mathcal{D}$ can be easily approximated by the reparameterization trick, while $\\log |\\Sigma|$ is trivial to compute. This readily results in an algorithm for variational inference, given fixed evaluations points $\\{x_n\\}_{n=1}^N$, shown in Figure \\ref{naivebvbmc}. Here it is named \\textit{Naive Boosted Variational Bayesian Monte Carlo} (Naive BVBMC).\n\\begin{Algorithm}\n\\begin{algorithmic}[1]\n\t\\Procedure{NaiveBVBMC}{$\\log \\gu,\\mu_0$,$\\Sigma_0$,$\\{x\\}_{n=1}^N$}\n\t\\LineComment{$\\mu_0,\\Sigma_0$ the are initial boosting values}\n\t\\For{$n=1,...,N$}\n\t\\State $y_n := \\log \\gu(x_n)$\n\t\\EndFor\n\t\\State $\\mathcal{D} := \\{(x_n,y_n)\\}_{i=1}^N$\n\t\\State GPModel := PosteriorGP($m$,$k_{RBF}$,$\\mathcal{D}$)\n\t\\State GPModel.MaximizeLogLikelihood() \\Comment{Using \\eqref{loglikelihoodGP}}\n\t\\State $\\Ev[\\log \\gu_\\mathcal{D}(\\theta)]$ := GPModel.$m_\\mathcal{D}$\n\t\\State $w_0 := 1.0$\n\t\\For{$t=1,...,T$}\n\t\\LineComment{Using BMC and reparameterization}\n\t\\State $\\mu_{t},\\Sigma_{t} := \\argmax RELBO_\\mathcal{D}(\\mu_{t},\\Sigma_{t})$\n\t\\State $w_{t} := \\argmax \\mathcal{L}_{t,\\mathcal{D}}(w_i)$ \\Comment{Using $\\mathcal{L}'_{t,\\mathcal{D}}(w_t)$ for gradient descent}\n\t\\For{$j=0,...,t-1$}\n\t\\State $w_{j} \\gets (1-w_t)w_j$\n\t\\EndFor\n\t\\EndFor\n\t\\State \\Return $\\{(\\mu_t,\\Sigma_t,w_t)\\}_{t=1}^T$\n\t\\EndProcedure\n\\end{algorithmic}\n\\caption{\\label{naivebvbmc} Naive boosted variational bayesian monte carlo}\n\\end{Algorithm}\n\\subsection{Practical issues}\nThe algorithm in Figure \\ref{naivebvbmc} run into some practical issues, described below, that requires fixes of an heuristic nature. Here we present the heuristics that were used to make the algorithm stable. The resulting algorithm in found in \\ref{bvbmcalgorithm}.\n\n\\subsubsection{RELBO stabilization}\nBy letting $r_\\mathcal{D}(\\theta) := \\exp \\Ev \\log_\\mathcal{D}(\\theta)$, consider again the maximization objective \\eqref{relbo_vbmc}, rewritten as\n\\begin{equation}\n \\text{RELBO}_\\mathcal{D}(\\mu_i,\\Sigma_i) = \\int \\log \\left(\\frac{r_\\mathcal{D}(\\theta)}{q_{i-1}(\\theta)} \\right) \\mathcal{N}(\\theta;\\mu_i,\\Sigma_i) d \\theta + \\log |\\Sigma_i|.\n\\end{equation}\nAssume $\\Sigma_i$ fixed for now, so that the only term being optimized is $\\mu_i$. Then, what the maximizer \"wants\" to do is set $\\mu_i$ in a place that $\\mathcal{N}(\\theta;\\mu_i,\\Sigma_i)$ allocates probability mass where $\\log r_\\mathcal{D}(\\theta)/q_{i-1}(\\theta)$ is large. Now, consider the tail behavior of this quantity. We have that $q_{i-1}(\\theta) \\approx C_1 \\exp(-||A_1(\\theta-c_1)||_2^2)$ on the tail, while either $r_\\mathcal{D}(\\theta) \\approx \\exp(-C)$, if $m(\\theta) = -C$, or $r_\\mathcal{D}(\\theta) \\approx \\exp(-||A_2(\\theta-c_2)||_2^2)$, in case of $m(\\theta) = -||A_2(\\theta-c_2)||_2^2$. In the first case, then $\\log r_\\mathcal{D}(\\theta)/q_{i-1}(\\theta) \\to \\infty$ as $\\theta \\to \\infty$, while in the second case, whether this happens depends on the relation between $A_1$ and $A_2$. However, if $\\log r_\\mathcal{D}(\\theta)/q_{i-1}(\\theta) \\to \\infty$ as $\\theta \\to \\infty$, then the maximizer will try to get $\\mu_i$ to $\\infty$, thus resulting in bad proposals, that ends up with negligible weights $w_i$.\n\nOne approach to deal with this problem is to replace the term $\\log r_\\mathcal{D}/q_{i-1}(\\theta)$ by $\\log r_\\mathcal{D}/(q_{i-1}(\\theta)+\\delta_D)$, where $\\delta_D$ is a small positive constant. This approach is similar to the one in \\cite{Guo_2016}, where a regularizer is added to both numerator and denominator, although it is done in the approximate heuristic proposed there. Thus, the $f$-step maximization objective becomes\n\n\\begin{equation}\n\\text{RELBO}^{\\delta_D}_\\mathcal{D}(\\mu_i,\\Sigma_i) = \\int \\log \\left(\\frac{r_\\mathcal{D}(\\theta)}{q_{i-1}(\\theta)+\\delta_D} \\right) \\mathcal{N}(\\theta;\\mu_i,\\Sigma_i) d \\theta + \\log |\\Sigma_i|.\n\\end{equation}\n\nIn the current work, $\\delta_D = e^{-20}$ by default.\n\n\\subsubsection{Output scaling}\\label{outputscaling}\nOne issue that arises with unnormalized log-densities is that one has no control on its scale. Fortunately, scaling the output can be done easily. Given data $\\mathcal{D} = \\{(x_i,y_i)\\}_{i=1}^N$, suppose one makes a linear transformation $\\tilde{y}_i = \\frac{y_i-b}{a}$, and, letting $\\tilde{\\mathcal{D}} = \\{x_i,\\tilde{y}_i\\}$, consider the GP posterior $f_{\\tilde{\\mathcal{D}}} \\sim GP(m_{\\tilde{\\mathcal{D}}},k_{\\tilde{\\mathcal{D}}})$. Then, the random function $a f_{\\tilde{\\mathcal{D}}} + b$ is GP distributed, and\n\\begin{equation}\n\\int (a f_{\\tilde{\\mathcal{D}}} + b)(x) p(x) dx \n\\end{equation}\nis a GP random variable, with\n\\begin{equation}\n\\Ev \\left[\\int (a f_{\\tilde{\\mathcal{D}}} + b)(x) p(x) dx \\right] = a \\Ev \\left[ \\int f_{\\tilde{\\mathcal{D}}}(x) p(x) dx \\right] + b,\n\\end{equation}\nand variance \n\\begin{equation}\n\\Var \\left(\\int (a f_{\\tilde{\\mathcal{D}}} + b)(x) p(x) dx \\right) = a^2 \\Var \\left( \\int f_{\\tilde{\\mathcal{D}}}(x) p(x) dx \\right).\n\\end{equation}\nThis implies that one can do BMC, hence also VBMC and BVBMC using affinely scaled output variables, without difficulty.\n\nTwo heuristic for scaling were implemented, the \\textit{normalize} heuristic, given by\n\\begin{itemize}\n\t\\item Letting $y_i = \\log g(x_i)$, calculating the sample mean $m_y = \\frac{1}{N} \\sum_{i=1}^N y_i$ and the (unbiased) sample standard deviation $\\sigma_y = \\sqrt{\\frac{1}{N-1} \\sum_{i=1}^N (y_i-m_y)}$.\n\t\\item Transforming the output $\\tilde{y}_i = (y_i-m_y)/\\sigma_y$.\n\t\\item Train a GP (along with hyperparameters) on $\\tilde{\\mathcal{D}} = \\{x_i,\\tilde{y}_i\\}_{i=1}^N$.\n\t\\item Substituting, when needed, $\\log g_\\mathcal{D}(x)$ (and their integrals) for $\\sigma_y \\log g_\\mathcal{\\tilde{D}}(x) + \\mu_y$\n\\end{itemize}\nand the \\textit{zeromax} heuristic, where\n\\begin{itemize}\n\t\\item Letting $y_i = \\log g(x_i)$, calculating the sample maximum $m_y = \\max\\{y_i\\}_{i=1}^N$ and making $\\sigma_y = 1$.\n\t\\item Do the other steps as in \\textit{normalize} heuristic.\n\\end{itemize}\nIn toy problems presented in the next section, both heuristics worked well, but for more complex problems the \\textit{zeromax} heuristic was found to be more stable.\n\n\\subsubsection{Component initialization}\nA question that still wasn't addressed is on how to choose the first boosting component. Two options were tested:\n\\begin{itemize}\n\t\\item Initializing the first mixture component with zero mean and a large covariance.\n\t\\item Choosing the first component by maximizing the ELBO between the component and GP surrogate.\n\\end{itemize}\nIn general, the second method was chosen in this work, although performance in both cases was comparable.\n\n\\subsubsection{Component pruning}\nWhen running the BVBMC algorithm, many mixture components may end up with negligible weights. This may both increase the computational cost of the algorithm, and hinder the performance of joint parameter updating (explained in \\ref{jointparameterupdating}). In order to diminish this problem, an weight threshold $\\beta$ may be established, so that, if $(w_1,\\ldots,w_N)$ are the current mixture weights, every $i$-th mixture components with $w_i < \\beta$ is removed, with the remainder weights being renormalized to one. This pruning may be done either every iteration, or only when doing joint parameter updating (for which pruning proved necessary).\n\n\\subsubsection{Mean functions}\\label{meansection}\nAs discussed in Section \\ref{quadmeanfnsection}, one option for the mean function set $m(\\theta) = m_Q(\\theta;l,c)$ as in \\eqref{vbmc_quadratic_mean}. However, one issue that arose in this work is that optimizing $l,c$ by maximizing the log-likelihood often resulted in very large values (in absolute value) for $l$ and $c$, destabilizing the algorithm.\n\nIn this light, a different approach for the mean is proposed, by letting\n\\begin{equation}\nm_F(\\theta) = C\n\\end{equation}\nwhere $C$ is a large negative constant, that is \\textit{fixed before hyperparameter optimization}. Strictly speaking, in this case $\\exp \\Ev[\\log \\gu_\\mathcal{D}(\\theta)]$ is not anymore a probability distribution. However, if $C$ is sufficiently low, it resembles a probability distribution enough so that the algorithm works well in practice.\n\nSince $C$ is not set by optimizing the log-likelihood, one must decide on how to set it. If the data was scaled beforehand using \\textit{zeromax}, some good options that worked well in practice were $C = -10,-20,-30$. For scaling using \\textit{normalize}, the following way to set $C$ is proposed:\n\\begin{equation}\nC = \\tilde{y}_{\\min} - K_{C}(\\tilde{y}_{\\max} - \\tilde{y}_{\\min}),\n\\end{equation}\nwhere $\\tilde{y}_{\\max}$ and $\\tilde{y}_{\\min}$ are the maximum and minimum of the normalized output values, and $K_C > 0$ is a constant. In this work, $K_C = 1$ was found to be a good choice.\n\n\\subsubsection{Periodic joint parameter updating}\\label{jointparameterupdating}\nSometimes, boosting may get \\enquote{stuck}, in the sense that the variational proposal takes too long to improve. In that case, one may desire to periodically update all variational parameters in the sense of the original VBMC algorithm. However, since this optimization is expensive, it should be used sparsely, for example every 10 boosting steps, or every 3 steps when boosting does not show improvement, when checking the ELBO.\n\n\\subsubsection{Other kernel functions}\nAs discussed in Section \\ref{tensorprodbmc}, tensor product of one-dimensional kernels can be easily integrated with Bayesian Monte Carlo with diagonal covariance Gaussian distributions. In this light, by letting $k_{\\text{Matern},\\nu}(|x-x'|;l)$ be the 1-d Matérn kernel, the product of Matérn kernels is defined\n\\begin{equation}\n k_{\\text{PMat},\\nu}(x,x';\\theta,l) = \\theta \\prod_{d=1}^D k_{\\text{Matern},\\nu}(|x_i-x_i'|;l_d).\n\\end{equation}\nIt must be noted that the product of Matérn kernels is \\text{not} the Matérn kernel for $d > 1$, although it is a stationary kernel.\n\nIn experiments, the product of Matérn kernels tended to be more stable than the squared exponential kernel, particularly for $\\nu = 1/2,3/2$, although for $\\nu = 5/2$ the cases where it became unstable were rare. This may be due to the fact that the squared exponential kernels assumes far too much smoothness in its defined GP, hence estimating large oscillations outside the domain of interest, resulting in spurious multimodality.\n\n\\subsection{Other acquisition functions for active evaluation}\nOne problem that may arises in prospective prediction is that the term $\\exp(m_\\mathcal{D}(\\theta_{N+1}))$ may become unstable for high values. Hence, one change proposed in this work is to substitute $\\exp$ for the function $\\text{softplus}(x) = \\log(1+\\exp(x))$, resulting in the \\textit{soft prospective prediction}\n\\begin{equation}\\label{soft_prospective_vbmc}\n\\alpha^\\mathcal{D}_{PP}(\\theta_{N+1}) = k_\\mathcal{D}(\\theta_{N+1},\\theta_{N+1}) \\text{softplus}(m_\\mathcal{D}(\\theta_{N+1}))q_k(\\theta_{N+1};\\lambda)^2.\n\\end{equation}\nAnother option is to disregard the current proposal altogether, and instead noticing that, ideally, the proposal is going to approximate the unnormalized posterior $\\gu = \\exp \\log \\gu$. Hence, one can take as an inspiration the warping approach in Section \\ref{positivebmc} and use the \\textit{moment-matched log transform} objective \n\\begin{equation}\\label{mmlt_vbmc}\n\\alpha^m_{MMLT}(x_{m+1}) = e^{2 m_\\mathcal{D}(x) + k_\\mathcal{D}(x,x)} \\left(e^{k_\\mathcal{D}(x,x')}-1\\right).\n\\end{equation} \nFinally, one can adapt the uncertainty sampling approach to the warped approach, resulting in the \\textit{prospective moment-matched log transform} objective\n\\begin{equation}\\label{mmltprop_vbmc}\n\\alpha^m_{MMLT_P}(x_{m+1}) = e^{2 m_\\mathcal{D}(x) + k_\\mathcal{D}(x,x)} \\left(e^{k_\\mathcal{D}(x,x')}-1\\right)q_k(\\theta_{N+1};\\lambda)^2.\n\\end{equation}\nIn general, the best performing acquisition functions were \\eqref{prospective_vbmc} and \\eqref{mmlt_vbmc}, and best results were obtained alternating between the two, either cyclically or randomly.\n\n\\begin{Algorithm}\n\\begin{algorithmic}[1]\n\t\\Procedure{BoostedVBMC$_0$}{$\\log \\gu,\\mu_0$,$\\Sigma_0$,$\\{x\\}_{n=1}^N$,$\\delta_D$}\n\t\\LineComment{$\\mu_0,\\Sigma_0$ the are initial boosting values}\n\t\\For{$n=1,...,N$}\n\t\\State $y_n := \\log \\gu(x_n)$\n\t\\EndFor\n\t\\State $\\mathcal{D}_0 := \\{(x_n,y_n)\\}_{i=1}^N$\n\t\\State Make $\\tilde{\\mathcal{D}}$ from $\\mathcal{D}$. Hold $m_y$ and $\\sigma_y$. \\Comment{Section \\ref{outputscaling}}\n\t\\State GPModel := PosteriorGP($m$,$k$,$\\mathcal{D}$)\n\t\\State GPModel.MaximizeLogLikelihood() \\Comment{Using \\eqref{loglikelihoodGP}}\n\t\\State $\\Ev[\\log \\gu_\\mathcal{D}(\\theta)]$ := GPModel.$m_\\mathcal{D}$\n\t\\State $\\alpha_0 := 1.0$\n\t\\State $(\\mu_0,\\Sigma_0)\\ \\gets \\argmax \\mathcal{L}_\\mathcal{D}(\\lambda)$ \\Comment{Section \\ref{outputscaling}}\n\t\\For{$t=1,...,T$}\n\t\t\\State $x' := \\argmax \\alpha^m(x)$ \\Comment{Some acquisition function}\n\t\t\\State $y' = \\log \\gu(x')$\n\t\t\\State $\\tilde{y}' = \\frac{y - m_y}{\\sigma_y}$\n\t\t\\State $\\tilde{\\mathcal{D}} \\gets \\tilde{\\mathcal{D}} \\cup \\{(x',\\tilde{y}')\\}$\n\t\t\\LineComment{Using BMC and reparameterization}\n\t\t\\State $\\mu_{t},\\Sigma_{t} := \\argmax RELBO^{\\delta_D}_\\mathcal{D}(\\mu_{t},\\Sigma_{t})$\n\t\t\\State $w_{t} := \\argmax \\mathcal{L}_{t,\\mathcal{D}}(w_i)$ \\Comment{Using $\\mathcal{L}'_{t,\\mathcal{D}}(w_t)$ for gradient descent}\n\t\t\\For{$j=0,...,t-1$}\n\t\t\t\\State $w_{j} \\gets (1-w_t)w_j$\n\t\t\\EndFor\n\t\t\\If{conditions met}\n\t\t\t\\State $\\lambda = \\{(\\mu_j,\\Sigma_j,w_j)\\}_{j=1}^t \\gets \\argmax \\mathcal{L}_\\mathcal{D}(\\lambda)$ \\Comment{Section \\ref{jointparameterupdating}}\n\t\t\\EndIf\n\t\\EndFor\n\t\\State \\Return $\\{(\\mu_t,\\Sigma_t,w_t)\\}_{t=1}^T$\n\t\\EndProcedure\n\t\\caption{\\label{bvbmcalgorithm}Boosted Variational Bayesian Monte Carlo}\n\\end{algorithmic}\n\\end{Algorithm}\n\n\\section{Implementation}\nThe algorithm was implemented in Python, mainly using the PyTorch package \\cite{Paszke_2017}. The reason for using PyTorch is that it combines strong automatic differentiation capabilities, allowing to avoid computing derivatives by hand, with easy usability when compared to other packages with similar strenghts such as TensorFlow. Since derivatives are necessary for the many inner optimization procedures in the algorithm,automatic differentiation greatly facilitated development. \n\nCode can be found in \\url{https://github.com/DFNaiff/BVBMC}. An example usage of the package is shown in Figure \\ref{bvbmcpackexample}, with associated densities shown in \\ref{bvbmcpackfigs}. \\footnote{The author intends to change the package name used in development, \\textit{variational\\_boosting\\_bmc}, to something akin to \\textit{bvbmc}, but the change wasn't made at this document writing.}\n\n\\begin{figure}\\label{bvbmcpackexample}\n\t\\begin{lstlisting}\n\t#Import necessary packages\n\timport torch #PyTorch package\n\tfrom variational_boosting_bmc import VariationalBoosting #BVBMC package\n\t\n\t#Approximating unnormalized 2-d Cauchy\n\tdef logjoint(theta):\n\t\treturn torch.sum(-torch.log(1+theta**2))\n\t\n\t#Set up parameters\n\tdim=2 #Dimension of problem\n\tsamples = torch.randn(20,dim) #Initial samples\n\tmu0 = torch.zeros(dim) #Initial mean\n\tcov0 = 20.0*torch.ones(dim) #Initial covariance\n\tacquisition = \"prospective\" #Acquisition function\n\t\n\t#Initialize algorithm\n\tvb = VariationalBoosting(dim,logjoint,samples,mu0,cov0)\n\tvb.optimize_bmc_model() #Optimize GP model\n\tvb.update_full() #Fit first component\n\t\n\t#Training loop\n\tfor i in range(100):\n\t\t_ = vb.update() #Choose new boosting component\n\t\tvb.update_bmcmodel(acquisition=acquisition) #Choose new evaluation\n\t\tvb.cutweights(1e-3) #Weights prunning\n\t\tif ((i+1)%20) == 0:\n\t\t\tvb.update_full(cutoff=1e-3) #Joint parameter updating\n\t\n\tvb.save_distrib(\"finaldistrib\") #Save distribution\n\t\\end{lstlisting}\n\t\\caption[Usage of the BVBMC Python package.]{\\label{bvbmcpackexample}Usage of the BVBMC Python package, approximating a product of Cauchy distributions.}\n\\end{figure}\n\n\\subsection{Backpropagation}\nUsually, in an algorithm with so many optimization steps, one would either have to worry about carefully keeping control of gradients, or resort to gradient free optimization. However, backpropagation \\cite{Goodfellow_2016}, a technique from the class of automatic differentiation algorithms, allows the computer to provide arbitrary derivatives of functions, provided the forward history of the function is tracked.\n\nA formal discussion on backpropagation is beyond the scope of this work. A good reference can be found in \\cite{Goodfellow_2016}. Greatly simplifying, backpropagation hinges on the fact that almost every function in a computer comes from composition, so the chain rule can be applied. So, if the forward history of the composition is stored in a suitable data structure (a \\textit{computational graph}), then, given the derivatives of those unit compositions, chain rule can be applied to get any derivative, without ever needing for then to being calculated by hand.\n\nBackpropagation is ubiquitous in deep learning , and almost all packages dealing with neural networks implement some form of it. In fact, most of then are backpropagation packages, in which neural networks are build on top of it. Some of the most popular are Theano \\cite{Theano_2016}, TensorFlow \\cite{Abadi_2015} and PyTorch \\cite{Paszke_2017}. Of those, PyTorch is the one with easiest usability, so it was chosen to implement the BVBMC package.\n\nThe usefulness of backpropagation and their related packages in general escapes the community outside deep learning. An important exception is in development of probability programming languages (PPL), whose many are built on top of deep learning packages, as in PyMC3 \\cite{Salvatier_2016}, Edward \\cite{Tran_2016} and Pyro \\cite{Bingham_2018}, built on top of Theano, TensorFlow and PyTorch, respectively.\n\n\\begin{figure}\n\t\\centering\n\t\\subfloat[True density]{\\label{fig11a}\\includegraphics[width=0.4\\linewidth]\n\t\t{figs/examplebvbmctrue.png}}\n\t\\subfloat[Estimated density]{\\label{fig11b}\\includegraphics[width=0.4\\linewidth]\n\t{figs/examplebvbmcestimated.png}}\n\n\t\\caption[\\label{bvbmcpackfigs}True density and estimated density found by running code in Figure \\ref{bvbmcpackexample}]{\\label{bvbmcpackfigs}True density (left) and estimated density (right), found by running code in Figure \\ref{bvbmcpackexample}. Generating code can be found in \\url{https://github.com/DFNaiff/Dissertation/blob/master/illustrations_dissertation/examplebvbmc.py}.}\n\\end{figure}\n", "meta": {"hexsha": "04768254a432e10ee645e24b8615e4d1657a7424", "size": 21537, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex_copy/chapters/capituloE.tex", "max_stars_repo_name": "DFNaiff/Dissertation", "max_stars_repo_head_hexsha": "8db72a0e588042a582053625ec58cde6a661f2a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex_copy/chapters/capituloE.tex", "max_issues_repo_name": "DFNaiff/Dissertation", "max_issues_repo_head_hexsha": "8db72a0e588042a582053625ec58cde6a661f2a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex_copy/chapters/capituloE.tex", "max_forks_repo_name": "DFNaiff/Dissertation", "max_forks_repo_head_hexsha": "8db72a0e588042a582053625ec58cde6a661f2a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.4723247232, "max_line_length": 1033, "alphanum_fraction": 0.7331568928, "num_tokens": 6707, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4294895461767669}}
{"text": "\\documentclass{article}\n\n% math stuff\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{xcolor}\n\n\\usepackage{mathtools}\n\n\\usepackage{float}\n\\usepackage{subcaption}\n\n% to insert images\n\\usepackage{graphicx}\n\n% to correctly insert stressed characters\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{multirow}\n\n% Bibliography\n% \\usepackage[style=alphabetic]{biblatex}\n% \\usepackage[nottoc]{tocbibind}\n% \\usepackage{bibentry}\n% \\setcounter{biburllcpenalty}{9000}\n% \\usepackage{nameref}\n\n% to put links in table of contents\n\\usepackage{hyperref}\n\\hypersetup{colorlinks=false, %set true if you want colored links\n\tlinktoc=all,     %set to all if you\n}\n\n% Add symbols\n% \\usepackage{textcomp}\n\n% Add command for Real and Z sets\n% \\usepackage{dsfont}\n% \\newcommand{\\Rset}{$\\mathds{R}$}\n% \\newcommand{\\Zset}{$\\mathds{Z}$}\n\n% Code highlighting\n% \\usepackage{minted}\n% \\usemintedstyle{perldoc}\n% \\setminted{\n%     frame=single,\n%     breaklines,\n% }\n\n% tikz figures\n\\usepackage{tikz}\n\\usepackage{tikzit}\n\\input{style.tikzstyles}\n\\usetikzlibrary{positioning}\n\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{claim}[theorem]{Claim}\n\n\\begin{document}\n\n\\section*{Hardness of Echo Chamber Problem}%\n\\label{sec:np_hardness_of_echo_chamber_problem}\n\n\\begin{theorem}\n\t\\label{th:hardness}\n\tSolving exactly the Echo Chamber Problem is $\\mathcal{NP}$-hard.\n\\end{theorem}\n\n\\begin{proof}\n\tWe show this by presenting a direct reduction from Maximum Clique, which is\n\twell-known to have the mentioned hardness factor.\n\n\t\\bigskip\n\tLet $G_{1}  = (V_{1} ,E_{1} )$ be an undirected and unweighted graph and\n\t$\\lambda \\geq \\frac{\\alpha }{1 - \\alpha }$, $\\lambda \\in \\mathbb{N}$.\n\tWe construct the \\emph{interaction} graph ${G}_{2}  = (V_{2} , E^{+}_{2} , E\n\t\t\t^{-}_{2} ) $ as follows\n\n\t\\begin{itemize}\n\t\t\\item for each vertex $v_{i}  \\in V_{1} $ we add a vertex in $G_{2} $\n\t\t\\item for each edge $e_{ij}  \\in\n\t\t\t      E_{1} $ add a positive edge between $v_{i} $ and $v_{j} $\n\t\t\\item for each edge $e_{ij} \\in V_{1} \\times V_{1}, e_{ij}  \\not\\in\n\t\t\t      E_{1} $ add $\\lambda n^{2}_{1}  $ negative edges between $v_{i} $ and $v_{j} $.\n\t\t\\item add a vertex $v_x$ and $\\lambda n_{1} $ negative edges between $v_x$\n\t\t      and each other vertex $v_i$ in $G_2$.\n\t\\end{itemize}\n\n\tFurthermore, all the edges in $G_{2} $ are associated to the same content\n\t$C$ and the same thread $T \\in \\mathcal{T}_{C}  $.\n\tAn illustration of the conversion can be found in \\autoref{fig:construction}.\n\n\t\\begin{figure}[hbt]\n\t\t\\begin{center}\n\t\t\t\\begin{subfigure}[b]{0.4\\textwidth}\n\t\t\t\t\\centering\n\t\t\t\t\\caption{$G_{1}$, undirected graph}\n\t\t\t\t\\tikzfig{tikz/hardness1}\n\t\t\t\t\\label{fig:g1_example}\n\t\t\t\\end{subfigure}\n\t\t\t\\begin{subfigure}[b]{0.4\\textwidth}\n\t\t\t\t\\centering\n\t\t\t\t\\tikzfig{tikz/hardness2}\n\t\t\t\t\\caption{$G_{2}$, directed signed graph, for $\\lambda = 1$}\n\t\t\t\t\\label{fig:g2_example}\n\t\t\t\\end{subfigure}\n\t\t\\end{center}\n\t\t\\caption{Example construction of the interaction graph $G_{2} $ from\n\t\t\t$G_{1} $, for $\\alpha = \\frac{1}{2} $}\n\t\t\\label{fig:construction}\n\t\\end{figure}\n\n\t\\begin{claim}\n\t\t\\label{th:claim-controversial}\n\t\tContent $C$ is controversial.\n\t\\end{claim}\n\t\\begin{proof}\n\t\tLet $m_{2}^{+} $ be the number of positive edges in $G_{2} $.\n\n\t\tBy construction $m_{2}^{+} = m _{1} $ and $m_{2}^{-} \\geq\n\t\t\t\\lambda n_{1}^{2}  $ so\n\t\t\\begin{align}\n\t\t\t\\eta(C) = \\frac{m_{2}^{-} }{m_{2}^{-} +\n\t\t\t\tm_{2}^{+} } \\geq \\frac{\\lambda n_{1}^{2}}{\\lambda n_{1}^{2}\n\t\t\t\t+ m_{1} } \\geq \\frac{\\lambda n_{1}^{2}}{\\lambda n_{1}^{2}\n\t\t\t\t+ n_{1}(n _{1} -1 )/2  } \\geq \\frac{\\lambda n_{1}^{2}}{\\lambda n_{1}^{2}\n\t\t\t+ n_{1}^{2} } = \\\\\n\t\t\t= \\frac{\\lambda }{\\lambda + 1} =\n\t\t\t\\frac{ \\frac{\\alpha }{1 - \\alpha }  }{ \\frac{\\alpha }{1 - \\alpha }\n\t\t\t\t+ 1 } \\geq \\alpha\n\t\t\\end{align}\n\t\\end{proof}\n\n\tThis reduces the Echo Chamber Problem on $G_2$ to the maximization of\n\n\t\\begin{equation}\n\t\t\\label{eq:score}\n\t\t\\xi(U) = \\sum^{}_{T \\in S_{C}(U) } | T[U] |\n\t\\end{equation}\n\n\t\\begin{claim}\n\t\t\\label{th:claim-complete}\n\t\tThe solution of the Echo Chamber Problem for $G_2$ is a set of vertices\n\t\t$\\{ v_{ia} \\} _{i \\in I}  \\subseteq V_{2} $ which is a clique\n\t\tin $G_{1} $.\n\t\\end{claim}\n\n\t\\begin{proof}\n\t\tLet $U \\coloneqq \\{ v_{ia} \\} _{i \\in I}  \\subseteq V_{2} $ be the\n\t\tsolution of the Echo Chamber Problem on $G_2$.\n\n\t\tWe can assume $\\xi(U) > 0$ (otherwise the proof is\n\t\ttrivial)\\footnote{In this case any subset of $V_{2} $ maximizes the echo\n\t\t\tchamber score, and this would clearly\n\t\t\tviolate Claim~\\ref{th:claim-complete}. For simplicity we can\n\t\t\tassume that in this case the algorithm returns a\n\t\t\t\\emph{singleton}.}.\n\t\tIt is also easy to see that $U$ does not contain $v_x$\\footnote{Similarly\n\t\t\tto the proof of Claim~\\ref{th:claim-controversial} it can be shown\n\t\t\tthat if $v_x \\in U$ then $T$ becomes controversial}.\n\n\t\tNow suppose that $U$ does not induce a complete subgraph on $G_1$. This\n\t\tmeans that there is at least one missing edge $e_{ij} \\in V_1 \\times\n\t\t\tV_1 $, $x_{ij} \\not\\in E_1$ and consequently at\n\t\tleast $\\lambda n^{2}_{1}  $ negative edges in $T[U]$. Let $n_U\n\t\t\t\\coloneqq |U|$, then\n\n\t\t\\begin{equation}\n\t\t\t\\eta(T) \\geq \\frac{\\lambda n_{1} ^{2} }{\\lambda n_{1} ^{2} + n_U\n\t\t\t\t(n_U -1)/2 }\n\t\t\t\\geq \\frac{\\lambda n_{1} ^{2} }{\\lambda n_{1} ^{2} + n_{1} ^{2}  }\n\t\t\t= \\frac{\\lambda }{\\lambda + 1} \\geq \\alpha\n\t\t\\end{equation}\n\n\t\tTherefore, thread $T$ is controversial and does not\n\t\tcontribute to the score $\\implies \\xi(U) = 0 \\implies$ \\emph{contradiction}.\n\t\\end{proof}\n\n\t\\begin{claim}\n\t\t\\label{th:max-clique}\n\t\tThe solution of the Echo Chamber Problem for $G_2$ is a set of vertices\n\t\t$U$ associated to a \\emph{maximum clique} of $G_1$.\n\t\\end{claim}\n\n\t\\begin{proof}\n\t\tSuppose there is a set of vertices $\\tilde{U} \\neq U, |\\tilde{U}| >\n\t\t\t|U|$ which is a clique for $G_1$. Then by construction it will\n\t\tcontain only positive edge in $G_2$ and will be\n\t\tnon-controversial. Also, being $|T[\\tilde{U}]| > |T[U]| \\implies\n\t\t\t\\xi(\\tilde{U}) > \\xi(U) \\implies contradiction$.\n\t\\end{proof}\n\n\t\\begin{claim}\n\t\tThe set of vertices defining a maximum clique on $G_1$\n\t\t% corresponds to a  of the Echo Chamber Problem on $G_2$.\n\t\tcorresponds to a solution of the Echo Chamber Problem on $G_2$.\n\t\\end{claim}\n\n\t\\begin{proof}\n\t\tLet $U \\subseteq V_1$ be a set of nodes defining a maximum clique on\n\t\t$G_1$ and $n_{U} = |U|$. By construction $T[U]$ will not be controversial and\n\n\t\t\\begin{equation}\n\t\t\t\\xi(U) = |T[U]| = n_{U} (n_{U} -1 )/2\n\t\t\\end{equation}\n\n\t\tNow suppose $\\exists \\tilde{U} \\subseteq V_2 \\; s.t. \\; \\xi(\\tilde{U})\n\t\t\t> \\xi(U)$. Due to Claim~\\ref{th:claim-complete} $U_2$ induces a\n\t\tclique on $G_1$; consequently $T[\\tilde{U}]$ has only positive\n\t\tedges and $\\xi(\\tilde{U}) = |T[\\tilde{U}]| = n_{\\tilde{U}}\n\t\t\t(n_{\\tilde{U}} - 1)/2$.\n\n\t\tAnd since $\\xi(\\tilde{U}) > \\xi({U}) \\implies n_{\\tilde{U}} > n_{U}\n\t\t\t\\implies contradiction$.\n\t\\end{proof}\n\n\tThis concludes the proof of \\autoref{th:hardness}.\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "d99b720d346668c7b3735a7a8c33c1d16c5318d3", "size": 6912, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/hardness.tex", "max_stars_repo_name": "morpheusthewhite/master-thesis", "max_stars_repo_head_hexsha": "2ab4c0509a119d7b5f332b842a4101470a884351", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-15T14:01:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-15T14:01:29.000Z", "max_issues_repo_path": "docs/hardness.tex", "max_issues_repo_name": "morpheusthewhite/master-thesis", "max_issues_repo_head_hexsha": "2ab4c0509a119d7b5f332b842a4101470a884351", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/hardness.tex", "max_forks_repo_name": "morpheusthewhite/master-thesis", "max_forks_repo_head_hexsha": "2ab4c0509a119d7b5f332b842a4101470a884351", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8571428571, "max_line_length": 88, "alphanum_fraction": 0.650318287, "num_tokens": 2594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4294895421569873}}
{"text": "\\chapter{Empirical Analysis}\n\n\\fbox{\n    \\parbox{\\textwidth}\n    {\n        Chapter Overview\n        \\begin{itemize}\n            \\item Applying Bayesian \\acp{cnn} for the task of Image Recognition on MNIST, CIFAR-10, CIFAR-100 and STL-10 datasets.\n            \\item Comparison of results of Bayesian \\acp{cnn} with Normal \\ac{cnn} architectures on similar datasets.\n            \\item Regularization effect of Bayesian Network with dropouts.\n            \\item Distribution of mean and variance in Bayesian \\ac{cnn} over time. \n            \\item Parameters comparison before and after model pruning. \n        \\end{itemize}\n    }\n}\n\n\\pagebreak\n\n\\section{Experimentation Methodology} \\label{experiments}\n\n\\subsubsection{Activation Function}\n\nThe originally chosen activation functions in all architectures are \\textit{ReLU}, but we must introduce another, called \\textit{Softplus}, see \\eqref{softplus}, because of our method to apply two convolutional or fully-connected operations. As aforementioned, one of these is determining the mean $\\mu$, and the other the variance $\\alpha \\mu^2$. Specifically, we apply the \\textit{Softplus} function because we want to ensure that the variance $\\alpha \\mu^2$ never becomes zero. This would be equivalent to merely calculating the MAP, which can be interpreted as equivalent to a maximum likelihood estimation (MLE), which is further equivalent to utilising single point-estimates, hence frequentist inference. The \\textit{Softplus} activation function is a smooth approximation of \\textit{ReLU}. Although it is practically not influential, it has the subtle and analytically important advantage that it never becomes zero for $x \\rightarrow -\\infty$, whereas \\textit{ReLU} becomes zero for $x \\rightarrow -\\infty$.\n\\\\ \n\\begin{equation}\\label{softplus}\n     \\text{Softplus}(x) = \\frac{1}{\\beta} \\cdot \\log \\big ( 1 + \\exp(\\beta \\cdot x) \\big )\n\\end{equation}\n\\\\\nwhere $\\beta$ is by default set to $1$.\n\\newline All experiments are performed with the same hyper-parameters settings as stated in the Appendix.\n\n\\subsubsection{Network Architecture}\n\nFor all conducted experiments, we implement the foregoing description of Bayesian \\acp{cnn} with variational inference in LeNet-5 \\cite{lecun1998gradient} and AlexNet \\cite{krizhevsky2012imagenet}. The exact architecture specifications can be found in the Appendix and in our GitHub repository\\footnote{\\url{https://github.com/kumar-shridhar/PyTorch-BayesianCNN}}.\n\n\\subsubsection{Objective Function}\nTo learn the objective function, we use \\textit{Bayes by Backprop} \\cite{graves2011practical, blundell2015weight}, which is a variational inference method to learn the posterior distribution on the weights $w \\sim q_{\\theta}(w|\\mathcal{D})$ of a neural network from which weights $w$ can be sampled in backpropagation. \nIt regularises the weights by minimising a compression cost, known as the variational free energy or the expected lower bound on the marginal likelihood.\n\n We tackled the problem of intractability in Chapter 2 and consequently, we arrive at the tractable cost function \\eqref{cost} which is aimed to be optimized, i.e. minimised w.r.t. $\\theta$, during training:\n\\begin{equation} \\label{cost}\n    \\mathcal{F}(\\mathcal{D}, \\theta)\\approx \\sum_{i=1}^n \\log q_{\\theta}(w^{(i)}|\\mathcal{D})-\\log p(w^{(i)})-\\log p(\\mathcal{D}|w^{(i)})\n\\end{equation}\n%\nwhere $n$ is the number of draws.\n\nLet's break the Objective Function \\eqref{cost} and discuss in more details. \n\\subsubsection{Variational Posterior }\n\nThe first term in the equation \\eqref{cost} is the variational posterior. The variational posterior is taken as Gaussian distribution centred around mean $\\mu$ and variance as $\\sigma^2$. \n\n\\begin{equation}\n    q_{\\theta}(w^{(i)}|\\mathcal{D})= \\prod_{i} \\mathcal{N}(w_{i} | \\mu,\\sigma^2)\n\\end{equation}\n\nWe will take the log and the log posterior is defined as :\n\n\\begin{equation}\n    log(q_{\\theta}(w^{(i)}|\\mathcal{D}))= \\sum_{i}log \\mathcal{N}(w_{i} | \\mu,\\sigma^2)\n\\end{equation}\n\n\\subsubsection{Prior}\n\nThe second term in the equation \\eqref{cost} is the prior over the weights and we define the prior over the weights as a product of individual Gaussians :\n\n\\begin{equation}\n    p(w^{(i)})= \\prod_{i} \\mathcal{N}(w_{i} | 0,\\sigma_{p}^2)\n\\end{equation}\n\nWe will take the log and the log prior is defined as:\n\n\\begin{equation}\n    log (p(w^{(i)}))= \\sum_{i} log \\mathcal{N}(w_{i} | 0,\\sigma_{p}^2)\n\\end{equation}\n\n\\subsubsection{ Likelihood }\n\nThe final term of the equation \\eqref{cost} $\\log p(\\mathcal{D}|w^{(i)})$ is the likelihood term and is computed using the softmax function.\n\n\\subsubsection{Parameter Initialization}\n\nWe use a Gaussian distribution and we store mean and variance values instead of just one weight. The way mean $\\mu$ and variance $\\sigma$ is computed is defined in the previous chapter. Variance cannot be negative and it is ensured by using \\textit{softplus} as the activation function. We express variance $\\sigma$ as $\\sigma_{i}=softplus(\\rho_{i})$ where $\\rho$ is an unconstrained parameter. \\\\\n\nWe take the Gaussian distribution and initialize mean $\\mu$ as 0 and variance $\\sigma$ (and hence $\\rho$) randomly. We observed mean centred around 0 and a variance starting with a big number and gradually decreasing over time. A good initialization can also be to put a restriction on variance and initialize it small. However, it might be data dependent and a good method for variance initialization is still to be discovered. We perform gradient descent over $\\theta$ = ($\\mu$, $\\rho$), and individual weight $w_{i} \\sim \\mathcal{N} (w_{i} | \\mu_{i}, \\sigma_{i}$).  \n\n\\subsubsection{Optimizer}\n\nFor all our tasks, we take Adam optimizer \\cite{kingma2014adam} to optimize the parameters. We also perform the local reparameterization trick as mentioned in the previous section and take the gradient of the combined loss function with respect to the variational parameters ($\\mu$, $\\rho$).\n\n\\subsubsection{Model Pruning}\n\nWe take the weights of all the layers of the network, apply an L1 norm over it and for all the weights value as zero or below a defined threshold are removed and the model is pruned. \\\\ Also, since the Bayesian \\acp{cnn} has twice the number of parameters ($\\mu$, $\\sigma$) compared to a frequentist network (only 1 weight), we reduce the size of our network to half (AlexNet and LeNet- 5) by reducing the number of filters to half. The architecture used is mentioned in the Appendix.\n\n\\textit{Please note that it can be argued that reducing the number of filters to be half is a method for pruning or not. It can be seen as a method that reduces the number of overall parameters and hence can be thought of a pruning method in some sense. However, it is a subject to argument.} \n\n\\section{Case Study 1: Small Datasets (MNIST, CIFAR-10)}\n\nWe train the networks with the MNIST dataset of handwritten digits \\cite{lecun1998gradient}, and CIFAR-10 dataset \\cite{krizhevsky2009learning} since these datasets serve widely as benchmarks for \\acp{cnn}' performances. \n\n\\subsection{Datasets}\n\\newline\n\\subsubsection{MNIST}\nThe MNIST database \\cite{lecun-mnisthandwrittendigit-2010} of handwritten digits have a training set of 60,000 examples and a test set of 10,000 examples. It is a subset of a larger set available from NIST. The digits have been size-normalized and centred in a fixed-size image of 28 by 28 pixels. Each image is grayscaled and is labelled with its corresponding class that ranges from zero to nine.\n\\newline\n\n\\subsubsection{CIFAR-10}\nThe CIFAR-10 are labelled subsets of the 80 million tiny images dataset \\cite{Torralba:2008:MTI:1444381.1444403}. The CIFAR-10 dataset has a training dataset of 50,000 colour images in 10 classes, with 5,000 training images per class, each image 32 by 32 pixels large. There are 10000 images for testing. \n\\newline\n\n\\subsection{Results}\nFirst, we evaluate the performance of our proposed method, Bayesian \\acp{cnn} with variational inference. Table \\ref{tab:results} shows a comparison of validation accuracies (in percentage) for architectures trained by two disparate Bayesian approaches, namely variational inference, i.e. \\textit{Bayes by Backprop} and Dropout as proposed by Gal and Ghahramani \\cite{gal2015bayesian}.\\\\\n\nWe compare the results of these two approaches to frequentist inference approach for both the datasets. Bayesian \\acp{cnn} trained by variational inference achieve validation accuracies comparable to their counter-architectures trained by frequentist inference. On MNIST, validation accuracies of the two disparate Bayesian approaches are comparable, but a Bayesian LeNet-5 with Dropout achieves a considerable higher validation accuracy on CIFAR-10, although we were not able to reproduce these reported results.\n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  c  c } \n     \\hline\n      \\empty & MNIST & CIFAR-10   \\\\ [0.75ex]\n     \\hline\n     Bayesian AlexNet (with VI) & 99 & 73   \\\\\n     \n     Frequentist AlexNet & 99 & 73   \\\\\n     \\hdashline\n     Bayesian LeNet-5 (with VI) & 98 & 69   \\\\\n     \n     Frequentist LeNet-5 & 98 & 68   \\\\\n     \\hdashline\n     Bayesian LeNet-5 (with Dropout) & 99.5 & 83  \\\\ \n     \\hline \\\\\n    \\end{tabular}}\n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Comparison of validation accuracies (in percentage) for different architectures with variational inference (VI), frequentist inference and Dropout as a Bayesian approximation as proposed by Gal and Ghahramani \\cite{gal2015bayesian} for MNIST, and CIFAR-10.}\n    \\label{tab:results}\n\\end{table}\n\n\\begin{figure}[t!] \n\\begin{center}\n\\includegraphics[width=\\linewidth]{Chapter5/Figs/results_mnist_CIFAR10.png}\n\\caption{Comparison of Validation Accuracies of Bayesian AlexNet and LeNet-5 with frequentist approach on MNIST and CIFAR-10 datasets}\n\\label{fig:MnistCIFAR10reesults}\n\\end{center}\n\\end{figure} \n\n\\newline Figure \\ref{fig:MnistCIFAR10reesults} shows the validation accuracies of Bayesian vs Non-Bayesian \\acp{cnn}. One thing to observe is that in initial epochs, Bayesian \\acp{cnn} trained by variational inference start with a low validation accuracy compared to architectures trained by frequentist inference. This must deduce from the initialization of the variational posterior probability distributions $q_{\\theta}(w|\\mathcal{D})$ as uniform distributions, while initial point-estimates in architectures trained by frequentist inference are randomly drawn from a standard Gaussian distribution. (For uniformity, we changed the initialization of frequentist architectures from Xavier initialization to standard Gaussian). The latter initialization method ensures the initialized weights are neither too small nor too large. In other words, the motivation of the latter initialization is to start with weights such that the activation functions do not let them begin in saturated or dead regions. This is not true in case of uniform distributions and hence, Bayesian \\acp{cnn}' starting validation accuracies can be comparably low.\n\n\\pagebreak\n\\newline Figure \\ref{fig:std_CNN} displays the convergence of the standard deviation $\\sigma$ of the variational posterior probability distribution $q_{\\theta}(w|\\mathcal{D})$ of a random model parameter over epochs. As aforementioned, all prior probability distributions $p(w)$ are initialized as uniform distributions. The variational posterior probability distributions $q_{\\theta}(w|\\mathcal{D})$ are approximated as Gaussian distributions which become more confident as more data is processed - observable by the decreasing standard deviation over epochs in Figure \\ref{fig:std_CNN}. Although the validation accuracy for MNIST on Bayesian LeNet-5 has already reached 99\\%, we can still see a fairly steep decrease in the parameter's standard deviation. In Figure \\ref{fig:distribution}, we plot the actual Gaussian variational posterior probability distributions $q_{\\theta}(w|\\mathcal{D})$ of a random parameter of LeNet-5 trained on CIFAR-10 at some epochs.\n%\n\\begin{figure}[H] \n\\begin{center}\n\\includegraphics[width=\\linewidth]{Chapter5/Figs/std_CNN.png}\n\\caption{Convergence of the standard deviation of the Gaussian variational posterior probability distribution $q_{\\theta}(w|\\mathcal{D})$ of a random model parameter at epochs 1, 5, 20, 50, and 100. MNIST is trained on Bayesian LeNet-5.}\n\\label{fig:std_CNN}\n\\end{center}\n\\end{figure} \n%\n\n\\begin{figure}[H] \n\\begin{center}\n\\includegraphics[width=\\linewidth]{Chapter5/Figs/distribution.png}\n\\caption{Convergence of the Gaussian variational posterior probability distribution $q_{\\theta}(w|\\mathcal{D})$ of a random model parameter at epochs 1, 5, 20, 50, and 100. CIFAR-10 is trained on Bayesian LeNet-5.}\n\\label{fig:distribution}\n\\end{center}\n\\end{figure} \n\n\\newline Figure \\ref{fig:distribution} displays the convergence of the Gaussian variational probability distribution of a weight taken randomly from the first layer of LeNet-5 architecture. The architecture is trained on CIFAR-10 dataset with uniform initialization. \n\n\n\n\\section{Case Study 2: Large Dataset (CIFAR-100)}\n\\subsection{Dataset}\n\n\\subsubsection{CIFAR-100}\nThis dataset is similar to the CIFAR-10 and is a labelled subset of the 80 million tiny images dataset \\cite{Torralba:2008:MTI:1444381.1444403}. The dataset has 100 classes containing 600 images each. There are 500 training images and 100 validation images per class. The images are coloured with a resolution of 32 by 32 pixels.\n\n\\subsection{Results}\n\n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  } \n     \\hline\n      \\empty & CIFAR-100  \\\\ [0.75ex]\n     \\hline\n     Bayesian AlexNet (with VI)  & 36  \\\\\n     \n     Frequentist AlexNet & 38  \\\\\n\n     Bayesian LeNet-5 (with VI) &  31  \\\\\n     \n     Frequentist LeNet-5  & 33  \\\\\n     \\hline \\\\\n    \\end{tabular}}\n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Comparison of validation accuracies (in percentage) for different architectures with variational inference (VI), frequentist inference and Dropout as a Bayesian approximation as proposed by Gal and Ghahramani \\cite{gal2015bayesian} for MNIST, CIFAR-10, and CIFAR-100.}\n    \\label{tab:resultsCIFAR-100}\n\\end{table}\n\nIn Figure \\ref{fig:regularization}, we show how Bayesian networks incorporate naturally effects of regularization, exemplified on AlexNet. While an AlexNet trained by frequentist inference without any regularization overfits greatly on CIFAR-100, an AlexNet trained by Bayesian inference on CIFAR-100 does not. This is evident from the high value of training accuracy for frequentist approach with no dropout or 1 layer dropout. Bayesian CNN performs equivalently to an AlexNet trained by frequentist inference with three layers of Dropout after the first, fourth, and sixth layers in the architecture.\nAnother thing to note here is that the Bayesian CNN with 100 samples overfits slightly lesser compared to Bayesian CNN with 25 samples. However, a higher sampling number on a smaller dataset didn't prove useful and we stuck with 25 as the number of samples for all other experiments.\n\n\n\\begin{figure}[H] \n\\begin{center}\n\\includegraphics[width=\\linewidth]{Chapter5/Figs/results_train_test_cifar100.png}\n\\caption{Comparison of Training and Validation Accuracies of Bayesian AlexNet and LeNet-5 with frequentist approach with and without dropouts on CIFAR-100 datasets}\n\\label{fig:regularization}\n\\end{center}\n\\end{figure} \n\nTable \\ref{tab:tableCIFAR100} shows a comparison of the training and validation accuracies for AlexNet with Bayesian approach and frequentist approach. The low gap between the training and validation accuracies shows the robustness of Bayesian approach towards overfitting and shows how Bayesian approach without being regularized overfits lesser as compared to frequentist architecture with no or one dropout layer. The results are comparable with AlexNet architecture with 3 dropout layers.\n\n\n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  c  c } \n     \\hline\n      \\empty & Training Accuracy & Validation Accuracy   \\\\ [0.75ex]\n     \\hline\n     Frequentist AlexNet (No dropout) & 83 & 38   \\\\\n     \n     Frequentist AlexNet (1 dropout layer) & 72 & 40   \\\\\n     \n      Frequentist AlexNet (3 dropout layer) & 39 & 38   \\\\\n     \\hdashline\n     Bayesian AlexNet (25 num of samples) & 54 & 37   \\\\\n     \n     Bayesian AlexNet (100 num of samples) & 48 & 37   \\\\\n     \\hline \\\\\n    \\end{tabular}}\n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Comparison of training and validation accuracies (in percentage) for AlexNet architecture with variational inference (VI) and frequentist inference for CIFAR-100.}\n    \\label{tab:tableCIFAR100}\n\\end{table}\n\n\\section{Uncertainity Estimation}\n\n\\newline Finally, Table \\ref{tab:uncertainty} compares the means of aleatoric and epistemic uncertainties for a Bayesian LeNet-5 with variational inference on MNIST and CIFAR-10. The aleatoric uncertainty of CIFAR-10 is about twenty times as large as that of MNIST. Considering that the aleatoric uncertainty measures the irreducible variability and depends on the predicted values, a larger aleatoric uncertainty for CIFAR-10 can be directly deduced from its lower validation accuracy and may be further due to the smaller number of training examples. The epistemic uncertainty of CIFAR-10 is about fifteen times larger than that of MNIST, which we anticipated since epistemic uncertainty decreases proportionally to validation accuracy. \n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  c  } \n     \\hline\n      \\empty & Aleatoric uncertainty &  Epistemic uncertainty  \\\\ [0.75ex]\n     \\hline\n     Bayesian LeNet-5 (MNIST) & 0.0096 & 0.0026   \\\\\n     \n     Bayesian LeNet-5 (CIFAR-10) & 0.1920 & 0.0404   \\\\\n     \\hline \\\\\n    \\end{tabular}} \n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Aleatoric and epistemic uncertainty for Bayesian LeNet-5 calculated for MNIST and CIFAR-10, computed as proposed by Kwon et al. \\cite{kwon2018uncertainty}.}\n    \\label{tab:uncertainty}\n\\end{table}\n\n\\section{Model Pruning}\n\n\\subsubsection{Halving the Number of Filters}\n\nFor every parameter for a frequentist inference network, Bayesian \\acp{cnn} has two parameters ($\\mu$, $\\sigma$). Halving the number of parameters of Bayesian AlexNet ensures the number of parameters of it is comparable with a frequentist inference network. The number of filters of ALexNet is halved and a new architecture called AlexNetHalf is defined in Figure 5.4. \n\n\\begin{table}[h!]\n    \\centering\n    \\renewcommand{\\arraystretch}{2}\n    \\begin{tabular}{c c c c c c} \n \\hline\n layer type & width & stride & padding & input shape & nonlinearity \\\\ [0.5ex] \n \\hline\n convolution ($11\\times11$) & 32 & 4 & 5 & $M\\times3\\times32\\times32$ & Softplus \\\\ \n \n max-pooling ($2\\times2$) & \\empty & 2 & 0 & $M\\times32\\times32\\times32$ & \\empty \\\\\n \n convolution ($5\\times5$) & 96 & 1 & 2 & $M\\times32\\times15\\times15$ & Softplus \\\\\n \n max-pooling ($2\\times2$) & \\empty & 2 & 0 & $M\\times96\\times15\\times15$ & \\empty \\\\\n \n convolution ($3\\times3$) & 192 & 1 & 1 & $M\\times96\\times7\\times7$ & Softplus \\\\\n \n convolution ($3\\times3$) & 128 & 1 & 1 & $M\\times192\\times7\\times7$ & Softplus \\\\\n \n convolution ($3\\times3$) & 64 & 1 & 1 & $M\\times128\\times7\\times7$ & Softplus \\\\\n \n max-pooling ($2\\times2$) & \\empty & 2 & 0 & $M\\times64\\times7\\times7$ & \\empty \\\\\n \n fully-connected & 64 & \\empty & \\empty & $M\\times64$ & \\empty \\\\ [1ex] \n \\hline\n\\end{tabular}\n\\renewcommand{\\arraystretch}{1.5}\n\\label{tab:AlexNetHalfArchitecture}\n\\caption{AlexNetHalf with number of filters halved compared to the original architecture.}\n\\end{table}\n\n\nThe AlexNetHalf architecture was trained and validated on the MNIST, CIFAR10 and CIFAR100 dataset and the results are shown in Table \\ref{tab:resultsAlexNetHalf}. The accuracy of pruned AlexNet with only half the number of filters compared to the normal architecture shows an accuracy gain of 6 per cent in case of CIFAR10 and equivalent performance for MNIST and CIFAR100 datasets. A lesser number of filters learn the most important features which proved better at inter-class classification could be one of the explanations for the rise in accuracy. However, upon visualization of the filters, no distinct clarification can be made to prove the previous statement. \\\\ \nAnother possible explanation could be the model is generalizing better after the reduction in the number of filters ensuring the model is not overfitting and validation accuracy is comparatively higher. CIFAR-100 higher validation accuracy on ALexNetHalf and a lower training accuracy than Bayesian AlexNet proves the theory. Using a lesser number of filters further enhances the regularization effect and makes the model more robust against overfitting. Similar results have been achieved by Narang \\cite{DBLP:journals/corr/NarangDSE17} in his work where a pruned model achieved better accuracy compared to the original architecture in a speech recognition task. Suppressing or removing the weights that have lesser or no contribution to the prediction makes the model rely its prediction on the most prominent and unique features and hence improves the prediction accuracy.\n\n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  c  c } \n     \\hline\n      \\empty & MNIST & CIFAR-10 & CIFAR-100 \\\\ [0.75ex]\n     \\hline\n     Bayesian AlexNet (with VI) & 99 & 73 & 36 \\\\\n     \n     Frequentist AlexNet & 99 & 73 & 38  \\\\\n     \n     Bayesian AlexNetHalf (with VI) & 99 & 79 & 38 \\\\\n     \n     \\hline \\\\\n    \\end{tabular}}\n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Comparison of validation accuracies (in percentage) for AlexNet with variational inference (VI), AlexNet with frequentist inference and AlexNet with half number of filters halved for MNIST, CIFAR-10 and CIFAR-100 datasets.}\n    \\label{tab:resultsAlexNetHalf}\n\\end{table}\n\n\\subsubsection{Applying L1 Norm}\n\n\nL1 norm induces sparsity in the trained model parameters and sets some values to zero. We trained a model to some epochs (number of epochs differs across datasets as we applied early stopping when validation accuracy remains unchanged for 5 epochs). We removed the zero-valued parameters of the learned weights and keep the non-zero parameters for a trained Bayesian AlexNet on MNIST and CIFAR-10 datasets. We pruned the model to make the number of parameters in a Bayesian Network comparable to the number of parameters in the point-estimate architecture. \\\\ Table \\ref{tab:resultsL1Norm} shows the comparison of validation accuracies of the applied L1 Norm AlexNet Bayesian architecture with Bayesian AlexNet architecture and with AlexNet frequentist architecture. We got comparable results on MNIST and CIFAR10 with the experiments and the results are shown in Table \\ref{tab:resultsL1Norm}\n\n\\begin{table}[H]\n\\tiny\n    \\centering\n    \\renewcommand{\\arraystretch}{1.5}\n    \\resizebox{\\linewidth}{!}{\n    \\begin{tabular}{ l  c  c  c  } \n     \\hline\n      \\empty & MNIST & CIFAR-10  \\\\ [0.75ex]\n     \\hline\n     Bayesian AlexNet (with VI) & 99 & 73  \\\\\n     \n     Frequentist AlexNet & 99 & 73   \\\\\n     \n     Bayesian AlexNet with L1 Norm (with VI) & 99 & 71  \\\\\n     \n     \\hline \\\\\n    \\end{tabular}}\n    \\renewcommand{\\arraystretch}{1.5}\n    \\caption{Comparison of validation accuracies (in percentage) for AlexNet with variational inference (VI), AlexNet with frequentist inference and BayesianAlexNet with L1 norm applied for MNIST and CIFAR-10 datasets.}\n    \\label{tab:resultsL1Norm}\n\\end{table}\n\nOne thing to note here is that the numbers of parameters of Bayesian Network after applying L1 norm is not necessarily equal to the number of parameters in the frequentist AlexNet architecture. It depends on the data size and the number of classes. However, the number of parameters in the case of MNIST and CIFAR-10 are pretty comparable and there is not much reduction in the accuracy either. Also, the early stopping was applied when there is no change in the validation accuracy for 5 epochs and the model was saved and later pruned with the application of L1 norm.\n\n\\section{Training Time}\n\nTraining time of a Bayesian \\acp{cnn} is twice of a frequentist network with similar architecture when the number of samples is equal to one. In general, the training time of a Bayesian \\acp{cnn}, $T$ is defined as:\n\\begin{align}\nT = 2 * number\\_of\\_samples * t\n\\end{align}\nwhere $t$ is the training time of a frequentist network. \nThe factor of 2 is present due to the double learnable parameters in a Bayesian CNN network i.e. mean and variance for every single point estimate weight in the frequentist network.\n\nHowever, there is no difference in the inference time for both the networks. \n\n\n\\ifpdf\n    \\graphicspath{{Chapter2/Figs/Raster/}{Chapter2/Figs/PDF/}{Chapter2/Figs/}}\n\\else\n    \\graphicspath{{Chapter2/Figs/Vector/}{Chapter2/Figs/}}\n\\fi\n\n\n", "meta": {"hexsha": "19b551d4b26d67e064e1d65e88686efc6006e1e9", "size": 25149, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter5/chapter5.tex", "max_stars_repo_name": "kumar-shridhar/Master-Thesis-BayesCNN", "max_stars_repo_head_hexsha": "c1f3c68b1ca7d03ec79dbfc96f7eb3595a2add38", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 238, "max_stars_repo_stars_event_min_datetime": "2018-12-18T08:58:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T20:45:01.000Z", "max_issues_repo_path": "Chapter5/chapter5.tex", "max_issues_repo_name": "goodrahstar/Master-Thesis-BayesianCNN", "max_issues_repo_head_hexsha": "3ebe37259df566e0bdda1918c1bd2c3d366b6355", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter5/chapter5.tex", "max_forks_repo_name": "goodrahstar/Master-Thesis-BayesianCNN", "max_forks_repo_head_hexsha": "3ebe37259df566e0bdda1918c1bd2c3d366b6355", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 73, "max_forks_repo_forks_event_min_datetime": "2018-12-18T12:46:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-28T14:29:51.000Z", "avg_line_length": 66.7082228117, "max_line_length": 1137, "alphanum_fraction": 0.7543043461, "num_tokens": 6525, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.42948953813720764}}
{"text": "\\section{Overlay Mesh}\n\n\\subsection{Self–Optimisation}\nNodes in the Mitosis network constantly try to improve their own connections. As discussed in \\vref{sec:design-peers}, this should lead to a more stable system in general.\n\nIn this experiment, the positioning of peers in relation to the router is measured. Running a simulation with $n=200$ nodes for $t=1000$ ticks, the distance from each peer to the router is put in relation to the simulated network configuration of the peer. In this scenario, connection latency is configured to a random value in the range of $0.125<l<0.5$ ticks, connection establishment delay falls in the range of $0.1<1.0$ ticks and the drop probability for messages on the unreliable channel \\cref{sec:mit-connections} is set to $0.0<s<5.0$ percent. For simplicity, every peer is assigned values within these ranges at instantiation and those values remain static throughout the simulation.\n\nAs peers strive to acquire connections to peers with a good router link quality and a good connection quality, the hypothesis is that peers with good connection qualities will \\say{bubble} towards the router. For verification, at the end of the scenario, every peer reports its network configuration parameters along with its distance to the router node. Distances are calculated in hops using the Dijkstra algorithm and treating the mesh as an undirected and unweighted graph.\n\\cref{fig:connection-quality-per-distance} shows the histogram of network quality settings binned by router distance. For comparability, the settings are normalised to percentages corresponding to the aforementioned ranges, with higher percentages representing the \\textit{better} end of the range.\n\n\\begin{figure}[htb!]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{graphics/analysis/connection-quality-per-distance.pdf}\n\\caption{Network quality of nodes in relation to their router distance}\n\\label{fig:connection-quality-per-distance}\n\\end{figure}\n\nAs to be expected, establishment delays do not show a dependency on router distance. Nodes only begin metering the quality of a connection after it has been opened. In fact, this is a desirable behaviour, since \\gls{webrtc} connections can take a while to generate \\gls{ice} candidates and to establish. Yet, the grade of the \\gls{webrtc} connection does not relate to how long the establishment took.\n\nThe distribution of average connection latency per router distance is in line with the hypothesis. Nodes with below average latency (circa $l<0.27$) have acquired direct connections to the \\router node, while nodes with only half as responsive connections have been pushed outwards to be leaf nodes.\n\nThe stability for the unreliable channel shows a distribution proximate to the latency, but not as clear. Nodes with low message drop probabilities, accumulate to distance levels one and two, yet the falloff is not as distinctive. This can be explained by looking back at the utilisation of the unreliable channel in \\vref{par:webrtc-data-measure-quality}: The \\gls{tq} of the connection meter is intended to access the duplexity of the connection and the responsiveness of the peer. However, in the simulation, the drop probability is applied to both incoming and outgoing messages.\n\n\\subsection{Ingress Rates}\n\nFor a \\gls{p2p} network to reach its potential scale, not only does it need to retain a high number of peers, it needs to take them in at a high rate. In real–world applications users can join and exit in unpredictable bursts, which can cause queues at the entry point or leaf gaps in the middle of the mesh.\n\nThe Mitosis mesh design envisions a clustered landscape \\cref{par:scaling-cluster}, where peers are associated to a router by a signal server. These router peers are the only way into the mesh and naturally have a maximum rate at which they can absorb new peers and forward them into the mesh. In real–world applications, the ingress rate would depend on the network and computing capabilities of the router peer, as well as the size and structure of its mesh. For the purposes of identifying the ingress rate under optimal conditions, these factors are intentionally left untouched.\n\nA new mesh is created by spawning nodes at a static rate and metering how fast they are connected to at least one peer of the mesh (excluding the signal server). Spawn rates were set to $3.2<r<12.5$, while the maximum node amount was set to $n=100$. \\Vref{fig:ingress-rates} shows three distinct runs of this experiment, where the dotted lines show the number of spawned nodes and the solid line shows the number of successfully absorbed nodes. A clear disparity can be seen between the lines for $r=12.5$. This hints towards multiple nodes queuing up at the entry point. For $r=3.2$, the network's ingress seems to lag only a few nodes behind the spawn rate. These lines run in parallel, indicating that apart from nodes currently in transition, no queue is forming. So, for the default configuration of the \\textit{Mitosis} core library and in a flawless network setting, this would be the optimal value.\n\n\\begin{figure}[htb!]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{graphics/analysis/ingress-final.pdf}\n\\caption{Ingress rates in relation to join rates in nodes per tick}\n\\label{fig:ingress-rates}\n\\end{figure}\n\nThis experiment shows how an important factor of mesh scalability can be measured. The actual numerical outcome, however, is to be taken with a grain of salt. Instead, signal servers would need to detect this rate during runtime and adjust the number of clusters according to demand.\n\n\n\\subsection{Connection Limits}\n\nOne other important facet of the mesh configuration, is the range connection goal and maximum connection limit as introduced by \\vref{sec:design-optimising}. These influence the mesh density and rigidity and help it take on more peers and better recover from connection loss. In this experimental run, the simulation is started goal range configurations from $g_{min}=1$ to $g_{max}=8$ with a range width of $g_{max}-g_{min}=2$. The maximum connection limit is set to $m=(g_{min}+g_{max})/2$. The node join rate is kept at a low value of $r=1$ for $t=500$ ticks and network conditions remain at stable settings.\n\nThe prediction is, that low connection limits will cause the network's connectedness to suffer but higher connection goals will bring proportionally more traffic overhead.\nTo verify this predicted behaviour of the mesh implementation, the total mesh size is measured in peers and the total network traffic per tick is calculated.\nThe mesh size is calculated by finding all \\glspl{scc} in the graph and counting all nodes in the largest component. The network traffic is aggregated per tick across nodes by the simulator's message delivery system.\n\n\\Vref{fig:connection-limits-largest-component} shows the node count of the largest mesh component, when spawning a new cluster with different connection limits. It is easily visible, how a goal of $g\\leq4$ causes the mesh to fail at taking in peers at a stable rate and growing past a size of $n\\approx100$. The $3 \\leq g \\leq 5, m=8$ configuration, also shows one incident of unintentional mesh separation. All higher connection limits are able to gain and maintain their mesh size proportionally to the spawn rate.\n\n\\begin{figure}[htb!]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{graphics/analysis/connection-limit-largest-component.pdf}\n\\caption{Mesh size in nodes in relation to connection limits}\n\\label{fig:connection-limits-largest-component}\n\\end{figure}\n\n\\Vref{fig:connection-limits-total-io} details the growth in traffic the network has to handle collectively per tick in megabytes. This diagram paints the opposite picture, as configurations with lower connection limits cause significantly less traffic overhead. The extra traffic is due to more Ping/Pong and \\peerUpdate messages being sent to keep the network alive and peers informed.\n\nHowever, total traffic is just one indicator, how higher connection limits do not imply a more performant network. With more connections, nodes will take on more neighbours and their routing table will grow exponentially. Routing will therefore become more complex and finding the best path to the router or the best peering candidate more ambiguous.\n\n\\begin{figure}[htb!]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{graphics/analysis/connection-limit-total-io.pdf}\n\\caption{Network–wide traffic per tick in relation to connection limits}\n\\label{fig:connection-limits-total-io}\n\\end{figure}\n", "meta": {"hexsha": "e5c496cfa5f1cc349dc07bffe01d3787b76046a4", "size": 8525, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/6-analysis/3-meshing.tex", "max_stars_repo_name": "auxdotapp/report", "max_stars_repo_head_hexsha": "962809e03db2b91c30301aa8238b09d256d1569a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-21T18:26:56.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-21T18:26:56.000Z", "max_issues_repo_path": "content/6-analysis/3-meshing.tex", "max_issues_repo_name": "auxdotapp/report", "max_issues_repo_head_hexsha": "962809e03db2b91c30301aa8238b09d256d1569a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/6-analysis/3-meshing.tex", "max_forks_repo_name": "auxdotapp/report", "max_forks_repo_head_hexsha": "962809e03db2b91c30301aa8238b09d256d1569a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 123.5507246377, "max_line_length": 906, "alphanum_fraction": 0.802228739, "num_tokens": 1858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4294836091685463}}
{"text": "\\documentclass[12pt, class=report, crop=false]{standalone}\n\\usepackage{msc_thesis}\n\\usepackage{wrapfig}\n\n% !TeX spellcheck = en-GB\n% !TEX bib = reference.bib\n% chktex-file 21 # This command might not be intended.\n\n\\begin{document}\n\n\\chapter{Particle in Cell Method}%\n\\label{chap:pic}\n\nAs we outlined in Chapter~\\ref{chap:physics}, the interaction\nof some charged particles with an electromagnetic field can be viewed as the\naction of the sources on the fields and the action of the fields on the sources.\n\nIn the same manner, simulating the interaction self-consistently requires a\n\\emph{field solver} that computes the structure of the fields considering\nthe sources and a \\emph{particle pusher} that solves the (relativistic)\nequations of motion for the particles.\nIn the particle in cell method, a finite-difference time-domain (FDTD) method\nis used for solving Maxwell's equations and a modified leapfrog method is used\nfor the particle pusher as presented in~\\cite{arber_contemporaryparticleincell_2015}.\n\n\\section{Numerical Methods Introduction}\n\nThe numerical methods mentioned above are based on the idea of discretising the\nderivative operator. There are multiple ways of discretising this operator,\nbut all of them can be derived from the Taylor series expansion.\n\\[\n  f(x_0+h) = f(x_0) + \\frac{f'(x_0)}{1!}h + \\frac{f''(x_0)}{2!}h^2 + \\dotsb + \\frac{f^{(n)}(x_0)}{n!}h^n + \\dots\n\\]\n\nThe main discretisations options are the forward, backward and central differences.\nFor the forward discretisation we consider\n\\[\n  f(x_0+h) = f(x_0) + \\frac{f'(x_0)}{1!}h + \\frac{f''(x_0)}{2!}h^2 + \\dotsb\n\\]\nand we rearrange the terms in the following way\n\\[\n  \\frac{f(x_0+h) - f(x_0)}{h} = f'(x_0) + \\frac{f''(x_0)}{2}h + \\dotsb\n\\]\nand thus, when \\(h \\to 0\\), the derivative in first order is given by\n\\[\n  f'(x_0) = \\frac{f(x_0+h) - f(x_0)}{h} + \\order{h}\\,.\n\\]\n\nThe local truncation error is given by the error of the approximation in one time\nstep. The forward and backward discretisations are both of order one. The\ncentral discretisation is second order accurate and can be derived as follows.\n\nWe first begin with the forward and backward discretisations for half of a\ntime step:\n\\begin{align*}\n  f(x_0+\\frac{h}{2}) &= f(x_0) + f'(x_0)\\frac{h}{2} + \\frac{f''(x_0)}{2}\\frac{h^2}{4}\n    + \\frac{f^{(3)}(x_0)}{3!}\\frac{h^3}{8} + \\dotsb \\\\\n  f(x_0-\\frac{h}{2}) &= f(x_0) - f'(x_0)\\frac{h}{2} + \\frac{f''(x_0)}{2}\\frac{h^2}{4}\n    - \\frac{f^{(3)}(x_0)}{3!}\\frac{h^3}{8} + \\dotsb \\,.\n\\end{align*}\n\nThen we take the difference and obtain\n\\[\n  f(x_0+\\frac{h}{2}) - f(x_0-\\frac{h}{2}) = f'(x_0)h\n    + 2\\frac{f^{(3)}(x_0)}{3!}\\frac{h^3}{8} + \\dotsb\n\\]\nand we can see that indeed the central difference is second order accurate\n\\[\n  f'(x_0) = \\frac{f(x_0+\\frac{h}{2}) - f(x_0-\\frac{h}{2})}{h} + \\order{h^2}\\,.\n\\]\n\nAs an application of the methods discussed above, we will now derive the so called\nleapfrog method for solving second order differential equations\nfollowing~\\textcite[Chapter~4]{hockney_computersimulation_1988}. More concretely,\nwe will take a look at solving the equations of motion for a particle. As a first\nstep, the equations of motion can be written as a system of first order differential\nequations\n\\begin{align*}\n  \\dv{\\vb{x}}{t} &= \\vb{v} \\\\\n  m \\dv{\\vb{v}}{t} &= \\vb{F}\\,,\n\\end{align*}\nwhere \\(\\vb{F}\\) is the total force on the particle. Replacing the derivatives\nwith their finite difference approximations, we obtain\n\\begin{subequations}\n  \\begin{align}\n    \\label{eq:leapfrog}\n    \\frac{\\vb{x}_{n+1} - \\vb{x}_n}{\\Delta t} = \\vb{v}_{n+1/2} \\\\\n    m \\frac{\\vb{v}_{n+1/2} - \\vb{v}_{n-1/2}}{\\Delta t} = \\vb{F}(\\vb{x}_n)\\,.\n  \\end{align}\n\\end{subequations}\nReplacing the velocity, we obtain\n\\begin{equation*}\n  % \\label{eq:leapfrog-no-v}\n  \\frac{\\vb{x}_{n+1}-2\\vb{x}_n+\\vb{x}_{n-1}}{\\Delta t^2} = \\frac{\\vb{F}(\\vb{x}_n)}{m}\\,.\n\\end{equation*}\n\n\\subsection{Accuracy}\n\nThe accuracy of an integration method is given by difference between the true\nsolution and the approximate solution at a given time step, that is the local\nerror. There are two types of local errors: truncation errors and round-off errors.\nTruncation errors are given by the approximations employed in the numerical method.\nOn the other hand, round-off errors are consequence of implementing the numerical\nmethod on a computer with finite precision. In general, for low order methods,\nthe truncation errors are significantly bigger than round-off errors, and thus\nwe can consider that the accuracy is given only by truncation error.\n\nIn order to better illustrate the concept of truncation errors, we will exemplify\nits computation for the leapfrog method. Let us consider the local truncation\nerror at the time step \\(n\\), \\(\\delta^n\\) and \\(\\vb{X}\\) the true solution\n\\[\n  \\frac{\\vb{X}_{n+1}-2\\vb{X}_n+\\vb{X}_{n-1}}{\\Delta t^2} = \\frac{\\vb{F}(\\vb{X}_n)}{m} + \\delta^n\\,.\n\\]\n\nIf we expand \\(\\vb{X}_{n+1}\\) and \\(\\vb{X}_{n-1}\\) in Taylor series around \\(\\vb{X}_n\\)\n\\begin{align*}\n  \\vb{X}_{n+1} &= \\vb{X}_n + \\dv{\\vb{X}_n}{t}\\Delta t + \\frac{1}{2} \\dv[2]{\\vb{X}_n}{t} - \\dotsb \\\\\n  \\vb{X}_{n-1} &= \\vb{X}_n - \\dv{\\vb{X}_n}{t}\\Delta t + \\frac{1}{2} \\dv[2]{\\vb{X}_n}{t} - \\dotsb\\,,\n\\end{align*}\nwe obtain\n\\[\n  \\dv[2]{\\vb{X}_n}{t} + \\frac{\\Delta t^2}{12} \\dv[4]{\\vb{X}}{t} + \\order{\\Delta t^5}\n  = \\frac{\\vb{F}(\\vb{X}_n)}{m} + \\delta^n\\,,\n\\]\nand thus\n\\[\n  \\delta^n \\sim \\order{\\Delta t^2}\n\\]\nwhich shows that the leapfrog algorithm is of order 2.\n\n\\subsection{Stability}\n\nA numerical method is considered asymptotically stable if the solution obtained\nfor a linear problem is asymptotically bounded.\nAs in the previous case we will show an example for the leapfrog method,\nfollowing the ideas exposed in~\\cite{butcher_numericalmethods_2016}\nand in~\\textcite[Section 2.6]{leimkuhler_simulatinghamiltonian_2004}.\n\nA linear problem can be written as\n\\[\n\\dv{t} \\vb{z} = A \\vb{z}\\,,\n\\]\nwhere we used the following notation to denote the dynamical state of the system\n\\[\n\\vb{z} =\n\\begin{pmatrix}\n  \\vb{q} \\\\\n  \\vb{p}\n\\end{pmatrix}\\,.\n\\]\n\nThe solution can be written as\n\\begin{equation*}\n  % \\label{eq:linear-problem-solution}\n  \\vb{z}(t) = R(t) \\vb{z}_0\\,,\n\\end{equation*}\nwhere \\(R(t)\\) is a matrix which can give the solution at any time by evolving\nthe initial conditions.\n\nThe discrete version of the problem is given by\n\\begin{equation}\n  \\label{eq:discrete-linear-problem}\n  \\vb{z}_{n+1} = \\hat{R}(\\Delta t) \\vb{z}_n\\,,\n\\end{equation}\nwhere \\(\\hat{R}(\\Delta t)\\) is called the propagation matrix.\nWith this considerations, asymptotic stability can be expressed as a function\nof the eigenvalues of \\(\\hat{R}(\\Delta t)\\), since the solution is obtained\nwith powers of \\(\\hat{R}\\) from the initial conditions\n\\begin{equation*}\n  % \\label{eq:discrete-linear-solution}\n  \\vb{z}_n = {[\\hat{R}]}^n \\vb{z}_0\\,.\n\\end{equation*}\n\nMore concretely, a method is asymptotically stable if the eigenvalues of\n\\(\\hat{R}\\) are inside the unit disk in the complex plane and simple (not repeated)\nif on the unit circle~\\autocite[28]{leimkuhler_simulatinghamiltonian_2004}.\n\nOne of the most studied linear problems is the harmonic oscillator and we can use\nit as our model linear problem\n\\[\n\\mathcal{H} = \\frac{\\vb{p}^2}{2m} + \\frac{\\omega^2 \\vb{q}^2}{2}\\,.\n\\]\n\nThe equations of motion are given by the corresponding Hamilton equations\n\\begin{align*}\n  \\dot{q}_i &= \\pdv{\\mathcal{H}}{p_i} = \\frac{p_i}{m} \\\\\n  \\dot{p}_i &= -\\pdv{\\mathcal{H}}{q_i} = -\\omega^2 q_i\\,.\n\\end{align*}\n\nTaking \\(m=1\\) and writing the above equations in matrix form yields\n\\[\n\\dot{\\vb{z}} =\n\\begin{pmatrix}\n  p \\\\\n  -\\omega^2 q\n\\end{pmatrix} =\n\\begin{pmatrix}\n  0 & 1 \\\\\n  -\\omega^2 & 0\n\\end{pmatrix}\n\\begin{pmatrix}\n  \\vb{q} \\\\\n  \\vb{p}\n\\end{pmatrix}\n\\]\nand thus we obtain\n\\[\n\\dot{\\vb{z}} = A \\vb{z},\n\\]\nwith\n\\[\nA =\n\\begin{pmatrix}\n  0 & 1 \\\\\n  -\\omega^2 & 0\n\\end{pmatrix}\\,.\n\\]\n\nThe solution is given by\n\\[\n\\vb{z}(t) = R(t) \\vb{z}_0,\n\\]\nwith\n\\[\nR(t) =\n\\begin{pmatrix}\n  \\cos(\\omega t) & \\frac{1}{\\omega} \\sin(\\omega t) \\\\\n  -\\omega \\sin(\\omega t) & \\cos(\\omega t)\n\\end{pmatrix}\\,.\n\\]\n\nIn order to analyse the stability of the leapfrog algorithm, it is convenient to\nexpress the equations in a different form, also called the Störmer–Verlet method\n\\begin{align*}\n  \\vb{q}_{n+1} &= \\vb{q}_n + \\Delta t \\vb{v}_{n+1/2} \\\\\n  M \\vb{v}_{n+1/2} &= M \\vb{v}_n - \\frac{\\Delta t}{2} \\grad{V(\\vb{q}_n)} \\\\\n  M \\vb{v}_{n+1} &= M \\vb{v}_{n+1/2} - \\frac{\\Delta t}{2} \\grad{V(\\vb{q}_{n+1})}\\,.\n\\end{align*}\n\nIn our particular case, the gradient of the potential is given by\n\\(\\omega^2 q\\) and the above reduces to\n\\begin{align*}\n  \\vb{q}_{n+1} &= \\vb{q}_n + \\Delta t (\\vb{v}_n - \\frac{\\Delta t}{2} \\omega^2 \\vb{q}^n) =\n  \\vb{q}_n \\left(1 - \\frac{\\Delta t^2 \\omega^2}{2}\\right) + \\vb{v}_n \\Delta t \\\\\n  \\vb{p}_{n+1} &= \\vb{p}_n - \\frac{\\Delta t^2}{2} \\omega^2 \\vb{q}_n\n  -\\frac{\\Delta t^2}{2} \\omega^2 \\vb{q}_{n+1} =\n  \\vb{p}_n - \\frac{\\Delta t^2}{2} \\omega^2 \\vb{q}_n\n  -\\frac{\\Delta t}{2}\\omega^2 \\left(\\vb{q}_n+\\vb{v}_n-\\frac{\\Delta t}{2}\\omega^2 \\vb{q}_n\\right)\\,,\n\\end{align*}\nor\n\\[\n\\begin{pmatrix}\n  \\vb{q}_{n+1} \\\\\n  \\vb{p}_{n+1}\n\\end{pmatrix} =\n\\begin{pmatrix}\n  1 - \\frac{\\Delta t^2 \\omega^2}{2} & \\Delta t \\\\\n  -\\Delta t \\omega^2 \\left(1 - \\frac{\\Delta t^2 \\omega^2}{4}\\right) &\n  1 - \\frac{\\Delta t^2 \\omega^2}{2}\n\\end{pmatrix}\n\\begin{pmatrix}\n  \\vb{q}_n \\\\\n  \\vb{p}_n\n\\end{pmatrix}\\,.\n\\]\n\nComparing with \\cref{eq:discrete-linear-problem} we obtain\n\\[\n\\hat{R}(\\Delta t) =\n\\begin{pmatrix}\n  1 - \\frac{\\Delta t^2 \\omega^2}{2} & \\Delta t \\\\\n  -\\Delta t \\omega^2 \\left(1 - \\frac{\\Delta t^2 \\omega^2}{4}\\right) &\n  1 - \\frac{\\Delta t^2 \\omega^2}{2}\n\\end{pmatrix}\\,.\n\\]\n\nThe eigenvalues of \\(\\hat{R}\\) are given by the solution of\n\\(\n\\det(\\hat{R} - \\lambda I) = 0\n\\), or more explicitly\n\\[\n\\vmqty{\n1 - \\frac{\\Delta t^2 \\omega^2}{2} & \\Delta t \\\\\n-\\Delta t \\omega^2 \\left(1 - \\frac{\\Delta t^2 \\omega^2}{4}\\right) &\n1 - \\frac{\\Delta t^2 \\omega^2}{2}\n} = 0\\,.\n\\]\n\nThis reduces to\n\\[\n{\\left(1-\\frac{\\Delta t^{2} \\omega^2}{2}-\\lambda\\right)}^{2}+\n\\frac{\\Delta t^{2} \\omega^2}{2}\\left(2-\\frac{\\Delta t^2 \\omega^2}{2}\\right) = 0\\,.\n\\]\nUsing the notation \\(\\frac{\\Delta t^{2} w^{2}}{2}\\equiv\\mu^{2}\\),\nwe obtain\n\\[\n{\\left(1-\\mu^{2}-\\lambda\\right)}^2+\\mu^{2}\\left(2-\\mu^{2}\\right)=0\\,,\n\\]\nwhich can be further expanded to\n\\[\n\\lambda^{2}+{\\left(1-\\mu^{2}\\right)}^{2}-2\\left(1-\\mu^{2}\\right) \\lambda+\\mu^{2}\\left(2-\\mu^{2}\\right)=0\\,,\n\\]\nyielding the solutions\n\\begin{align*}\n  \\lambda_{1,2} &= \\frac{1}{2} \\left\\{2(1-\\mu^2) \\pm\n  \\sqrt{4{(1-\\mu^2)}^2 - 4\\left[{(1-\\mu^2)}^2 + \\mu^2 (2-\\mu^2)\\right]}\\right\\} \\\\\n  &= 1-\\mu^2 \\pm \\sqrt{\\mu^2(\\mu^2-2)}\\,.\n\\end{align*}\n\nWe notice that for \\(\\mu^2 < 2\\) the solutions are complex and\n\\begin{align*}\n  |\\lambda_{1,2}|^2 &= (1-\\mu^2) + \\mu^2 (\\mu^2-2) \\\\\n  &= 1+\\mu^4-2\\mu^2+\\mu^4-2\\mu^2 \\\\\n  &= 1+\\mu^4-4\\mu^2\\,.\n\\end{align*}\n\nThe method will be stable for \\(|\\lambda|^2 < 1\\), or\n\\[\n\\mu^2 (\\mu^2 - 4) < 0 \\implies \\mu < 2, \\text{for } \\mu \\ne 0\\,.\n\\]\n\nFor \\(\\mu^2 > 2\\) the eigenvalues are real and with modulus greater than 1.\nThus the stability condition for the Störmer–Verlet method is given by \\(\\mu < 2\\),\nor\n\\[\n\\Delta t^2 \\omega^2 < 4\\,,\n\\]\nindicating a sampling of at least \\(\\pi\\) points per period, or a step size\n\\(\\Delta t < 2/\\omega\\).\n\nIn the context of ordinary differential equations, a stability region of the method\nis usually defined via a stability function \\(R(z)\\) in the complex\nplane~\\autocite[81]{butcher_numericalmethods_2016}. Such approach cannot be used\nin this case since the stability function is defined for a singe ordinary\ndifferential equation, but in the case of Hamiltonian dynamics we always have\n\\(2n\\) ordinary differential equations, with \\(n>1\\).\n\n\\section{The particle pusher}\n\nHaving (briefly) developed some general aspects of the theory of numerical methods\nfor solving differential equations, we now continue with the more concrete case\nof numerically solving the equations of motion for a charged particle.\nIn the non-relativistic case, the (continuous) equations of motion have the\nfollowing form\n\\begin{align*}\n  \\dv{\\vb{x}}{t} &= \\vb{v} \\\\\n  \\dv{\\vb{v}}{t} &= \\frac{q}{m} \\left(\\vb{E} + \\vb{v}\\cp\\vb{B}\\right)\\,.\n\\end{align*}\n\nSince the above equations are symmetric with respect to time reversal, it is\ndesired that we obtain a discretisation which is also time-reversible.\n\\Textcite{buneman_timereversibledifference_1967} explained that we can\nuse centred differences for this task and in the particular case of the\nLorentz force we can average the velocity in order to represent the\n\\(\\vb{v} \\cp \\vb{B}\\) product symmetrically. Thus we obtain\n\\begin{subequations}\n  \\begin{align}\n    \\label{eq:lorentz-discrete-x}\n    \\frac{\\vb{x}_{n+1}-\\vb{x}_n}{\\Delta t} &= \\vb{v}_{n+1} \\\\\n    \\label{eq:lorentz-discrete-v}\n    \\frac{\\vb{v}_{n+1/2}-\\vb{v}_{n-1/2}}{\\Delta t} &= \\frac{q}{m}\n      \\left(\\vb{E}(\\vb{x}_n) + \\frac{\\vb{v}_{n+1/2}+\\vb{v}_{n-1/2}}{2} \\cp \\vb{B}(\\vb{x}_n)\\right)\\,.\n  \\end{align}\n\\end{subequations}\n\nAs explained in~\\textcite[Chapter 4--3]{birdsall_plasmaphysics_2005}, there are\nseveral methods for solving the above equations, implying a\npartial~\\autocite{buneman_timereversibledifference_1967} or\ncomplete~\\autocite{boris_relativisticplasma_1970} separation of the electric\nand magnetic force contributions. In the following we will detail the second\nmethod, which is also called the Boris push.\n\nLet us introduce the following notation\n\\begin{align*}\n  \\vb{v}^- &= \\vb{v}_{n-1/2} - \\frac{q \\vb{E}}{m} \\frac{\\Delta t}{2} \\\\\n  \\vb{v}^+ &= \\vb{v}_{n+1/2} + \\frac{q \\vb{E}}{m} \\frac{\\Delta t}{2}\\,,\n\\end{align*}\nsuch that\n\\[\n\\frac{\\vb{v}^+ - \\vb{v}^-}{\\Delta t} = \\frac{\\vb{v}_{n+1/2} - \\vb{v}_{n-1/2}}{\\Delta t}\n+ \\frac{q \\vb{E}}{m}\\,.\n\\]\n\nSubstituting in \\cref{eq:lorentz-discrete-v} we obtain\n\\begin{equation}\n  \\label{eq:vp-vm-rotation}\n  \\frac{\\vb{v}^+ - \\vb{v}^-}{\\Delta t} = \\frac{q}{2m} (\\vb{v}^+ + \\vb{v}^-) \\cp \\vb{B}\\,,\n\\end{equation}\nwhich can be seen as a rotation. Indeed, if we take the scalar product with\n\\((\\vb{v}^+ + \\vb{v}^-)\\), we get\n\\[\n(\\vb{v}^+ + \\vb{v}^-) \\vdot \\frac{\\vb{v}^+ - \\vb{v}^-}{\\Delta t} =\n\\frac{q}{2m} \\underbrace{(\\vb{v}^+ + \\vb{v}^-) \\vdot (\\vb{v}^+ + \\vb{v}^-) \\cp \\vb{B}}_{0}\n\\]\nor\n\\[\n|\\vb{v}^+|^2 - |\\vb{v}^-|^2 = 0\\,,\n\\]\nimplying that \\(|\\vb{v}^+| = |\\vb{v}^-|\\).\n\nIf we decompose the \\(\\vb{v}^-\\) into its parallel and perpendicular components\nwith respect to \\(\\vb{B}\\), we can reduce the rotation of \\(\\vb{v}^-\\) to\nthe rotation of its perpendicular component \\(\\vb{v}^-_\\perp\\).\n\n\\begin{wrapfigure}[10]{r}{0.4\\textwidth}\n  \\centering\n  \\subimport{../figures/}{Boris-rotation-angle}%\n  \\caption{Boris rotation angle}\\label{fig:Boris-rotation-angle}%\n\\end{wrapfigure}\n\nThe angle of rotation between \\(\\vb{v}^-_\\perp\\) and \\(\\vb{v}^-_\\perp\\),\ndenoted with \\(\\theta\\) in \\cref{fig:Boris-rotation-angle},\ncan be expressed as\n\\[\n\\tan{\\frac{\\theta}{2}} = \\frac{|\\vb{v}^+_\\perp - \\vb{v}^-_\\perp|}{|\\vb{v}^+_\\perp + \\vb{v}^-_\\perp|}\\,.\n\\]\n\nRewriting \\cref{eq:vp-vm-rotation} we obtain\n\\[\n\\vb{v}^+ - \\vb{v}^- = \\frac{q \\Delta t}{2m} (\\vb{v}^+ + \\vb{v}^-) \\cp \\vb{B}\n\\]\nand if we substitute \\(\\vb{v}^\\pm = \\vb{v}^\\pm_\\perp + \\vb{v}^\\pm_\\parallel\\)\n\\[\n\\vb{v}^+_\\perp - \\vb{v}^-_\\perp = \\frac{q \\Delta t}{2m} (\\vb{v}^+_\\perp + \\vb{v}^-_\\perp) \\cp \\vb{B}\\,.\n\\]\n\nFurthermore, since all the vectors above have the same direction by construction,\nwe can factor out the versors and obtain\n\\[\n\\frac{|\\vb{v}^+_\\perp - \\vb{v}^-_\\perp|}{|\\vb{v}^+_\\perp + \\vb{v}^-_\\perp|} =\n\\frac{q |\\vb{B}|}{m} \\frac{\\Delta t}{2}\n\\]\nand thus\n\\begin{equation}\n  \\label{eq:Boris-rotation-angle}\n  \\tan{\\frac{\\theta}{2}} = \\frac{q B}{m} \\frac{\\Delta t}{2}\\,.\n\\end{equation}\n\nSince for the rotation described above only the components perpendicular to\nthe direction of \\(\\vb{B}\\) matter, we can simplify the notation and use\n\\(\\vb{v}_\\pm\\) instead of \\(\\vb{v}^\\pm_\\perp\\).\nWe will now introduce an additional vector \\(\\vb{v}'\\) given by the addition\nbetween \\(\\vb{v}_-\\) and another vector, such that \\(\\vb{v}'\\) is perpendicular\nto \\(\\vb{v}_+ - \\vb{v}_-\\).\n\nIt is convenient to write \\(\\vb{v}'\\) as \\(\\vb{v}' = \\vb{v}_- + \\vb{v}_- \\cp \\vb{t}\\).\nIn the right triangle formed by \\(\\vb{v}'\\) with \\(\\vb{v}_-\\)\nand \\(\\vb{v}_- \\cp \\vb{t}\\) as seen in \\cref{fig:Boris-rotation-3D},\nwe have\n\\[\n\\tan{\\frac{\\theta}{2}} = \\frac{|\\vb{v}_- \\cp \\vb{t}|}{|\\vb{v}_-|} = |\\vb{t}|\n\\]\nand thus by using \\cref{eq:Boris-rotation-angle} \\(\\vb{t}\\) is given by\n\\begin{equation}\n  \\label{eq:boris-t}\n  \\vb{t} = \\frac{q \\vb{B}}{m} \\frac{\\Delta t}{2}\\,.\n\\end{equation}\n\n\\begin{figure}[H]\n  \\includegraphics[width=\\textwidth]{Boris-rotation-3D}\n  \\caption{Boris rotation construction in 3D}%\n  \\label{fig:Boris-rotation-3D}%\n\\end{figure}\n\nAs can be seen in \\cref{fig:Boris-rotation-3D},\n\\(\\vb{v}_+ - \\vb{v}_- \\parallel \\vb{v}' \\cp \\vb{B}\\). This encourages\nthe following notation: \\(\\vb{v}_+ - \\vb{v}_- \\equiv \\vb{v}' \\cp \\vb{s}\\),\nwhere \\(\\vb{s}\\) can be determined by the condition that\n\\(|\\vb{v}_+|^2 = |\\vb{v}_-|^2\\). Thus, expanding \\(\\vb{v}' \\cp \\vb{s}\\) gives\n\\[\n\\vb{v}' \\cp \\vb{s} = (\\vb{v}_- + \\vb{v}_- \\cp \\vb{t}) \\cp \\vb{s} =\n\\vb{v}_- \\cp \\vb{s} + \\vb{t} \\underbrace{(\\vb{v}_- \\vdot \\vb{s})}_0 - \\vb{v}_- (\\vb{t} \\vdot \\vb{s})\n\\]\n\n\\begin{wrapfigure}[15]{r}{0.4\\textwidth}\n  \\centering\n  \\subimport{../figures/}{Boris-rotation-construction}%\n  \\caption{The velocities projected in the plane perpendicular to \\(\\vb{B}\\)}%\n  \\label{fig:Boris-rotation-construction}%\n\\end{wrapfigure}\n\nand if we consider the definition for \\(\\vb{s}\\)\n\\[\n\\vb{v}_+ = \\vb{v}_- + \\vb{v}' \\cp \\vb{s} =\n\\vb{v}_- + \\vb{v}_- \\cp \\vb{s} - \\vb{v}_- (\\vb{t} \\vdot \\vb{s})\\,.\n\\]\nTaking the scalar product with \\(\\vb{v}_-\\) gives\n\\[\n\\vb{v}_+ \\vdot \\vb{v}_- = |\\vb{v}_-|^2 - |\\vb{v}_-|^2 (\\vb{t} \\vdot \\vb{s})\n\\]\nor\n\\[\n|\\vb{v}_-|^2 \\cos{\\theta} = |\\vb{v}_-|^2 (1 - \\vb{t} \\vdot \\vb{s})\\,.\n\\]\n\nUsing the trigonometry identity\n\\[\n\\cos{\\theta} = \\frac{1-\\tan^2{\\frac{\\theta}{2}}}{1+\\tan^2{\\frac{\\theta}{2}}}\\,,\n\\]\nwe obtain\n\\[\n\\vb{t} \\vdot \\vb{s} = 1 - \\frac{1-\\tan^2{\\frac{\\theta}{2}}}{1+\\tan^2{\\frac{\\theta}{2}}}\\,,\n\\]\nwhich is equivalent to\n\\[\n\\vb{t} \\vdot \\vb{s} = \\frac{2 t^2}{1+t^2}\n\\]\nand thus we obtain that\n\\[\n\\vb{s} = \\frac{2 \\vb{t}}{1+t^2}\\,.\n\\]\n\nAs a summary, the Boris push algorithm solves \\cref{eq:lorentz-discrete-v} with the following steps:\n\\begin{enumerate}\n  \\item \\(\\vb{v}^- = \\vb{v}_{n-1/2} + \\frac{q \\vb{E}}{m} \\frac{\\Delta t}{2}\\)\n  \\item rotate \\(\\vb{v}^-\\) to obtain \\(\\vb{v}^+\\) using\n  \\begin{enumerate}\n    \\item \\(\\vb{v}' = \\vb{v}^- + \\vb{v}^- \\cp \\vb{t}\\), where \\(\\vb{t} = \\frac{q \\vb{B}}{m} \\frac{\\Delta t}{2}\\)\n    \\item \\(\\vb{v}^+ = \\vb{v}^- + \\vb{v}' \\cp \\vb{s}\\), where \\(\\vb{s} = \\frac{2 \\vb{t}}{1+t^2}\\)\n  \\end{enumerate}\n  \\item \\(\\vb{v}_{n+1/2} = \\vb{v}^+ + \\frac{q \\vb{E}}{m} \\frac{\\Delta t}{2}\\)\n\\end{enumerate}\n\n\\subsection{Conservation properties}\n\nWhen solving (continuous) differential equations with (discrete) numerical methods,\nan important aspect is that we want the algorithm to be as close as possible to\nthe original continuous system in terms of symmetries and conserved\nquantities~\\autocite{stuart_dynamicalsystems_1996}.\n\nIn what follows we will look at the conservation properties of the Boris push\nand show why are they important for simulating the dynamics of charged particles\nfollowing the ideas presented in~\\textcite{qin_whyboris_2013}.\n\nMathematically speaking, a Hamiltonian system is given by the phase space (an\neven dimensional manifold\\footnote{A manifold is a topological space that is locally Euclidean.}),\na symplectic structure on it and the Hamiltonian\nfunction~\\autocite[160]{arnold_mathematicalmethods_1989}.\nIn order to explain what the symplectic structure is, we will start with a short\ndiscussion about 2-forms~\\autocite[164]{arnold_mathematicalmethods_1989}.\n\n\\begin{definition*}\n  An exterior form of degree 2 (or a 2-form) is a function of pairs of vectors\n  \\(\\omega^2: \\mathbb{R}^n \\cp \\mathbb{R}^n\\), which is bilinear and skew symmetric:\n  \\begin{align*}\n  \\omega^2(\\lambda_1 \\vb*{\\xi}_1 + \\lambda_2 \\vb*{\\xi}_2, \\vb*{\\xi}_3) &=\n  \\lambda_1 \\omega^2(\\vb*{\\xi}_1, \\vb*{\\xi}_3) + \\lambda_2 \\omega^2(\\vb*{\\xi}_2, \\vb*{\\xi}_3) \\\\\n  \\omega^2(\\vb*{\\xi}_1,\\vb*{\\xi}_2) &= -\\omega^2(\\vb*{\\xi}_2, \\vb*{\\xi}_1)\\,,\n  \\end{align*}\n  \\(\\forall \\lambda_{1,2} \\in \\mathbb{R}, \\vb*{\\xi}_{1,2,3} \\in \\mathbb{R}^n\\).\n\\end{definition*}\n\nAs an example of a 2-form in \\(n=2\\) dimensions is given by the \\emph{oriented area} spanned by 2 vectors\nin the (oriented) euclidean plane \\(\\mathbb{R}^2\\).\nLet us consider\n\\[\n\\vb*{\\xi} = \\mqty(\\xi_1 \\\\ \\xi_2), \\qquad\n\\vb*{\\eta} = \\mqty(\\eta_1 \\\\ \\eta_2)\\,,\n\\]\nthen the oriented are determined by the two vectors is given by\nthe determinant~\\autocite{golomb_proofwords_1985}\n\\[\nS(\\vb*{\\xi},\\vb*{\\eta}) = \\det\\mqty(\\xi_1 & \\eta_1 \\\\ \\xi_2 & \\eta_2)\n= \\xi_1 \\eta_2 - \\xi_2 \\eta_1\\,.\n\\]\n\nLet us consider an \\(2d\\)-dimensional phase space with the coordinates \\(q_i,p_i\\)\nas presented in~\\textcite[183]{leimkuhler_simulatinghamiltonian_2004}.\n\n\\begin{definition}\n  A linear map \\(A: \\mathbb{R}^{2d} \\to \\mathbb{R}^{2d}\\) is called\n  \\emph{symplectic} if there exists a 2-form \\(\\omega\\)\n  such that\n  \\[\n  \\omega(A\\vb*{\\xi}, A\\vb*{\\eta}) = \\omega(\\vb*{\\xi},\\vb*{\\eta})\\,,\\\n  \\forall \\vb*{\\xi}, \\vb*{\\eta} \\in \\mathbb{R}^{2d}\\,.\n  \\]\n\\end{definition}\n\nWe can also express the above in matrix notation\n\\[\nA^T J^{-1} A = J^{-1},\\qquad \\text{where} \\ J = \\mqty(0 & I \\\\ -I & 0)\\,,\n\\]\nwith \\(I\\) the identity matrix in \\(d\\) dimensions.\n\nA useful example that illustrates the concept is given in the case of \\(d=1\\),\nwhere symplecticity implies area conservation under the given\nlinear transformation. In the more general \\(d>1\\) case, it would imply the conservation of the sum\nof the respective projected areas.\n\nAs we have seen from the beginning of this chapter, differentiable\nfunctions are often approximated using linear maps. This provides\nthe motivation for extending the above definition to the non-linear case.\n\n\\begin{definition}%\n  \\label{def:symplecticity-nonlinear}\n  A differentiable map \\(g:U \\to \\mathbb{R}^{2d}\\), with \\(U \\subset \\mathbb{R}^{2d}\\) an open set, is called\n  \\emph{symplectic} if its corresponding Jacobian matrix \\(g'(\\vb{p},\\vb{q})\\) is everywhere symplectic, i.e.\n  \\[\n  \\omega(g'(\\vb{p},\\vb{q})\\vb*{\\xi}, g'(\\vb{p},\\vb{q})\\vb*{\\eta}) =\n  \\omega(\\vb*{\\xi},\\vb*{\\eta})\n  \\]\n  or in matrix notation \\({g'(\\vb{p},\\vb{q})}^T J^{-1} g'(\\vb{p},\\vb{q}) = J^{-1}\\).\n\\end{definition}\n\nHaving defined symplecticity, we will now try to check if the Boris\npush algorithm is symplectic. For this task we begin with rewriting\n\\cref{eq:lorentz-discrete-v} in a more convenient form\n\\[\n\\vb{v}_{n+1/2} - \\frac{q \\Delta t}{2m} \\vb{v}_{n+1/2} \\cp \\vb{B}_n =\n\\vb{v}_{n-1/2} + \\frac{q \\Delta t}{2m} \\vb{v}_{n-1/2} \\cp \\vb{B}_n\n+ \\frac{q \\Delta t}{m} \\vb{E}_n\\,,\n\\]\nwhere \\(\\vb{B}_n \\equiv \\vb{B}(\\vb{x}_n)\\) and\n\\(\\vb{E}_n \\equiv \\vb{E}(\\vb{x}_n)\\).\n\nIn order to manipulate the above more easily, it is useful to introduce some\nfundamental group theory notions~\\autocite[118]{hairer_geometricnumerical_2006}\nand the hat map~\\autocite[289]{marsden_introductionmechanics_1999}.\n\n\\begin{definition}\n  A \\emph{Lie group} \\(G\\) is a group that is also a differentiable\n  manifold and for which the product is given by the differentiable\n  mapping \\(G \\cp G \\to G\\).\n\\end{definition}\n\nThe tangent space \\(\\mathfrak{g} = T_I G\\) at the identity \\(I\\)\nof a matrix Lie group \\(G\\) is closed under forming commutators\nof its elements and defines the \\emph{Lie algebra} of \\(G\\).\n\n\\begin{definition}\n  The \\emph{hat map} \\(\\hat{}: \\mathbb{R}^3 \\to \\mathfrak{so}(3)\\) is a\n  vector space isomorphism that identifies the Lie algebra \\(\\mathfrak{so}(3)\\)\n  of \\(SO(3)\\) with \\(\\mathbb{R}^3\\). If we consider\n  \\(\\vb{v} = (v_1,v_2,v_3) \\in \\mathbb{R}^3\\), then the hat map\n  is given by\n  \\[\n    \\hat{\\vb{v}} =\n    \\begin{pmatrix}\n      \\phantom{-}0\\phantom{_1} & -v_3           & \\phantom{-}v_2 \\\\\n      \\phantom{-}v_3 & \\phantom{-}0\\phantom{_1} &           -v_1 \\\\\n            -v_2     & \\phantom{-}v_1 &\\phantom{-}0\\phantom{_1}\n    \\end{pmatrix}\\,.\n  \\]\n\\end{definition}\n\nWe can observe that\n\\[\n\\hat{\\vb{v}} \\vb{w} = \\vb{v} \\cp \\vb{w}\n\\]\ncharacterizes the isomorphism. Comparing\n\\[\n\\hat{\\vb{v}} \\vb{w} =\n\\begin{pmatrix}\n  \\phantom{-}0\\phantom{_1} & -v_3           & \\phantom{-}v_2 \\\\\n  \\phantom{-}v_3 & \\phantom{-}0\\phantom{_1} &           -v_1 \\\\\n        -v_2     & \\phantom{-}v_1 &\\phantom{-}0\\phantom{_1}\n\\end{pmatrix}\n\\begin{pmatrix}\n  w_1 \\\\\n  w_2 \\\\\n  w_3\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n            -v_3 w_2 + v_2 w_3 \\\\\n  \\phantom{-}v_3 w_1 - v_1 w_3 \\\\\n            -v_2 w_1 + v_1 w_2\n\\end{pmatrix}\n\\]\nwith\n\\[\n(\\vb{v} \\cp \\vb{w}) = \\vb{e}_i \\epsilon_{ijk} v_j w_k =\n\\vb{e}_1 (v_2 w_3 - v_3 w_2) + \\vb{e}_2 (v_3 w_1 - v_1 w_3) +\n\\vb{e}_3 (v_1 w_2 - v_2 w_1)\n\\]\nwe can see that this is indeed true.\n\nThus, if we consider \\(\\mathbb{R}^3\\) together with the cross product,\nthe hat map \\(\\hat{}\\)\\ becomes a Lie algebra isomorphism and we\ncan identify \\(\\mathfrak{so}(3)\\) with \\(\\mathbb{R}^3\\) having the\ncross product as Lie bracket\\footnote{A bilinear, skew symmetric operation \\(\\mathfrak{g}\\cp\\mathfrak{g}\\to\\mathfrak{g}\\) that\nsatisfies the Jacobi identity.}.\n\nWe can now resume rewriting \\cref{eq:lorentz-discrete-v} and we obtain\n\\begin{equation}\n\\label{eq:lorentz-v-hat-map}\n\\left(I - \\hat{\\Omega}_{n}\\right)\n\\begin{pmatrix}\n  v_{n+1/2}^1 \\\\\n  v_{n+1/2}^2 \\\\\n  v_{n+1/2}^3\n\\end{pmatrix}\n=\n\\left(I + \\hat{\\Omega}_{n}\\right)\n\\begin{pmatrix}\n  v_{n-1/2}^1 \\\\\n  v_{n-1/2}^2 \\\\\n  v_{n-1/2}^3\n\\end{pmatrix}\n+ \\frac{q \\Delta t}{m}\n\\begin{pmatrix}\n  E_n^1 \\\\\n  E_n^2 \\\\\n  E_n^3\n\\end{pmatrix}\\,,\n\\end{equation}\nwhere\n\\[\n\\hat{\\Omega}_n =\n\\frac{q \\Delta t}{2m}\n\\begin{pmatrix}\n  \\phantom{-}0\\phantom{_1} & -B^3_n & \\phantom{-}B^2_n \\\\\n  \\phantom{-}B^3_n & \\phantom{-}0\\phantom{_1} & -B^1_n \\\\\n  -B^2_n & \\phantom{-}B^1_n & \\phantom{-}0\\phantom{_1}\n\\end{pmatrix}\\,.\n\\]\n\nMultiplying on the left of \\cref{eq:lorentz-v-hat-map} with\n\\(\\left(I - \\hat{\\Omega}_{n}\\right)\\) yields\n\\[\n\\begin{pmatrix}\n  v_{n+1/2}^1 \\\\\n  v_{n+1/2}^2 \\\\\n  v_{n+1/2}^3\n\\end{pmatrix}\n=\n{\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1} \\left(I + \\hat{\\Omega}_{n}\\right)\n\\begin{pmatrix}\n  v_{n-1/2}^1 \\\\\n  v_{n-1/2}^2 \\\\\n  v_{n-1/2}^3\n\\end{pmatrix}\n+ \\frac{q \\Delta t}{m} {\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1}\n\\begin{pmatrix}\n  E_n^1 \\\\\n  E_n^2 \\\\\n  E_n^3\n\\end{pmatrix}\\,.\n\\]\n\nIn order to further simplify the notation, we can use the following notation:\n\\(\\vb{x}_n \\equiv \\vb{x}_k\\) and \\(\\vb{v}_{n-1/2} \\equiv \\vb{v}_k\\)\nand use the Cayley transform\nfor the first term on the right hand side.\nFor a quadratic Lie group\\footnote{Lie groups of the form\n\\(G = \\set{Y ; Y^T P Y = P}\\), where \\(P\\) is a constant\nmatrix.}, the \\emph{Cayley transform}\n\\[\n\\cay{\\Omega} = {(I-\\Omega)}^{-1} (I+\\Omega)\n\\]\nmaps elements of \\(\\mathfrak{g}\\) into \\(G\\)~\\autocite[128]{hairer_geometricnumerical_2006}.\n\nIn our particular case\n\\[\n{\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1} \\left(I + \\hat{\\Omega}_{n}\\right) = \\cay{\\hat{\\Omega}_{n}} \\equiv R\n\\]\nand we obtain\n\\[\n\\vb{v}_{k+1} = R \\vb{v}_k + \\frac{q \\Delta t}{m} {\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1} \\vb{E}_k\\,.\n\\]\n\nThus \\cref{eq:lorentz-discrete-x,eq:lorentz-discrete-v} form a\none step map \\(\\Psi_B\\) which maps \\(\\vb{z}_k \\equiv (\\vb{x}_k, \\vb{v}_k)\\)\nto \\(\\vb{z}_{k+1} \\equiv (\\vb{x}_{k+1}, \\vb{v}_{k+1})\\)\n\\begin{equation*}\n  \\Psi_B: \\left\\{\n  \\begin{aligned}\n    \\vb{x}_{k+1} &= \\vb{x}_k + R \\Delta t\\vb{v}_k + \\frac{q \\Delta t}{m} {\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1} \\vb{E}_k \\\\\n    \\vb{v}_{k+1} &= R \\vb{v}_k + \\frac{q \\Delta t^2}{m} {\\left(I - \\hat{\\Omega}_{n}\\right)}^{-1} \\vb{E}_k\n  \\end{aligned}\n\\right.\\,.\n\\end{equation*}\n\nAs \\(\\Psi_B\\) is a function \\(\\Psi_B(\\vb{z}_k)\\), we can compute\nits Jacobian an check the condition for symplecticity\n\\[\n\\pdv{\\Psi_B}{\\vb{z}_k} =\n\\begin{pmatrix}\n  \\pdv{\\vb{x}_{k+1}}{\\vb{x}_k} & \\pdv{\\vb{x}_{k+1}}{\\vb{v}_k} \\\\\n  \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & \\pdv{\\vb{v}_{k+1}}{\\vb{v}_k}\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n  I + \\Delta t \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & R \\Delta t \\\\\n  \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & R\n\\end{pmatrix}\\,.\n\\]\n\nAs we mentioned in \\cref{def:symplecticity-nonlinear}, for the map to be symplectic\nit has to satisfy\n\\[\n{\\left(\\pdv{\\Psi_B}{\\vb{z}_k}\\right)}^T J^{-1} \\left(\\pdv{\\Psi_B}{\\vb{z}_k}\\right) = J^{-1}\\,.\n\\]\n\nConsidering\n\\[\n\\pdv{\\Psi_B}{\\vb{z}_k} =\n\\begin{pmatrix}\n  S_1 & S_2 \\\\\n  S_3 & S_4\n\\end{pmatrix}\\,,\n\\]\nthe symplecticity condition can be written as\n\\begin{align*}\n  \\begin{pmatrix}\n    S_1^T & S_3^T \\\\\n    S_2^T & S_4^T\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    0 & -I \\\\\n    I &  0\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    S_1 & S_2 \\\\\n    S_3 & S_4\n  \\end{pmatrix}\n  &=\n  \\begin{pmatrix}\n    S_3^T & -S_1^T \\\\\n    S_4^T & -S_2^T\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    S_1 & S_2 \\\\\n    S_3 & S_4\n  \\end{pmatrix} \\\\\n  &=\n  \\begin{pmatrix}\n    S_3^T S_1 - S_1^T S_3 & S_3^T S_2 - S_1^T S_4 \\\\\n    S_4^T S_1 - S_2^T S_3 & S_4^T S_2 - S_2^T S_4\n  \\end{pmatrix} \\\\\n  &=\n  \\begin{pmatrix}\n    0 & -I \\\\\n    I &  0\n  \\end{pmatrix}\\,.\n\\end{align*}\n\nThus, we will have the following set of conditions\n\\begin{subequations}\n  \\begin{align}\n    &S_3^T S_1 = S_1^T S_3 \\label{eq:simplecticity-condition-1} \\\\\n    &S_1^T S_4 - S_3^T S_2 = I \\label{eq:simplecticity-condition-2} \\\\\n    &S_4^T S_1 - S_2^T S_3 = I \\label{eq:simplecticity-condition-3} \\\\\n    &S_4^T S_2 = S_2^T S_4 \\label{eq:simplecticity-condition-4}\\,.\n  \\end{align}\n\\end{subequations}\n\nIf we consider the simplified case of homogeneous electric and magnetic fields,\nthen\n\\[\n\\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} = \\pdv{\\vb{x}_k} (R \\vb{v}_k) +\n\\frac{q \\Delta t}{m} \\pdv{\\vb{x}_k} \\left[{\\left(I-\\hat{\\Omega}_k\\right)}^{-1}\\vb{E}_k\\right]\n=0\n\\]\nand\n\\begin{align*}\n  S_1 = I &\\quad S_2 = R \\Delta t \\\\\n  S_3 = 0 &\\quad S_4 = R\\,.\n\\end{align*}\n\nIf we consider the condition in \\cref{eq:simplecticity-condition-2}, we obtain\n\\[\nS_1^T S_4 - S_3^T S_2 = R \\neq I\n\\]\nand thus the Boris push algorithm is not symplectic. In spite of that, the algorithm\npresents desirable properties such as near-conservation of energy when the\nmagnetic field is constant or the electric potential is quadratic and for more\ngeneral cases it has a linear energy error~\\autocite{hairer_energybehaviour_2018}.\nThis properties encourage a more detailed analysis of the properties of the Boris\npush method.\n\nOne of the properties of a symplectic algorithm is that it conserves the phase space\nvolume. This can be understood as a generalization of the are conservation example\nin \\(2d, d=1\\) to higher dimensions. For a map to be volume preserving, the\ndeterminant of its Jacobian must be one\n\\[\n\\det \\pdv{\\Psi_B}{\\vb{z}_k} = 1\\,.\n\\]\n\nIn our case this becomes\n\\[\n\\mdet{\\pdv{\\Psi_B}{\\vb{z}_k}} =\n\\mdet{I + \\Delta t \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & R \\Delta t \\\\\n      \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & R}\n=\n\\mdet{I & 0 \\\\\n      \\pdv{\\vb{v}_{k+1}}{\\vb{x}_k} & R}\n= \\mdet{R}\\,,\n\\]\nwhere we have subtracted the second row multiplied by \\(\\Delta t\\) from the first\none. Since \\(R \\in SO(3)\\), as a property of the Cayley transform,\n\\[\n\\mdet{R} = 1\n\\]\nand thus the Boris push is volume preserving.\n\n% \\subsection{Shape functions}\n\n\\subsection{The relativistic case}\n\nThe Boris push algorithm also has a relativistic variant, which takes into account\nthe \\(\\gamma\\) factor.\nIn the relativistic case, the equation of motion is given by\n\\cref{eq:relativistic-lorentz}\n\\[\n\\dv{t}(\\gamma \\vb{v}) = \\frac{q}{m} (\\vb{E} + \\vb{v}\\cp\\vb{B})\n\\]\nand for its discretisation we follow \\textcite[Section 15-4]{birdsall_plasmaphysics_2005} and by using the\n\\(\\vb{u}\\equiv\\gamma\\vb{v}\\) notation, we obtain\n\\[\n\\frac{\\vb{u}_{n+1/2} -\\vb{u}_{n-1/2}}{\\Delta t} =\n\\frac{q}{m}\\left(\\vb{E}_n + \\frac{\\vb{u}_{n+1/2}+\\vb{u}_{n-1/2}}{2\\gamma_n} \\cp \\vb{B}_n \\right)\\,,\n\\]\nwhere \\(\\gamma^2=1+u^2/c^2\\). The update for \\(\\vb{u}\\) is\ncomputed similarly to the non-relativistic case, by separating\nthe contributions of the electric and magnetic fields.\nFor the electric field, the relations are formally the same,\nwith the observation that \\(vb{v}\\) is replaced by \\(\\vb{u}\\)\n\\[\n\\begin{aligned}\n  \\vb{u}_{n-1/2} &= \\vb{u}^- - \\frac{q\\vb{E}_n \\Delta t}{2m} \\\\\n  \\vb{u}_{n+1/2} &= \\vb{u}^+ + \\frac{q\\vb{E}_n \\Delta t}{2m}\\,.\n\\end{aligned}\n\\]\n\nFor the magnetic field we have a rotation about an axis parallel to \\(\\vb{B}\\)\nas we have seen in the non-relativistic case, but in this case\nthe angle is reduced by a factor of \\(\\gamma\\) and thus\n\\[\n\\tan{\\frac{\\theta}{2}} = \\frac{q B \\Delta t}{2\\gamma m}\n\\]\nwith the rotation of \\(\\vb{u}^-\\) being given by\n\\[\n\\frac{\\vb{u}^+ - \\vb{u}^-}{\\Delta t} = \\frac{q}{2\\gamma_n m}\n\\left(\\vb{u}^+ + \\vb{u}^-\\right)\\cp\\vb{B}_n\\,.\n\\]\n\nWith these considerations, in the implementation of the rotation \\cref{eq:boris-t} becomes\n\\[\n\\vb{t} = \\frac{q \\vb{B} \\Delta t}{2 \\gamma_n m}\\,,\n\\]\nwith \\(\\gamma\\) given by the relativistic velocity after adding the half-acceleration due to the electric field\n\\[\n\\gamma_n = \\sqrt{1+{\\left(\\frac{u^-}{c}\\right)}^2}\\,.\n\\]\n\nSince the magnetic field only produces a rotation, and thus\n\\(\\vb{u}^+\\) and \\(\\vb{u}^-\\) have the same length, we also\nhave\n\\[\n\\gamma_n = \\sqrt{1+{\\left(\\frac{u^+}{c}\\right)}^2}\n\\]\nand thus the scheme is time reversible.\nAs in the non-relativistic case, the rotation can be implemented using\n\\[\n\\begin{aligned}\n  \\vb{u}' &= \\vb{u}^- + \\vb{u}^-\\cp\\vb{t} \\\\\n  \\vb{u}^+ &= \\vb{u}^- + \\vb{u}'\\cp\\vb{s}\\,.\n\\end{aligned}\n\\]\n\nThe equation for the position update remains unchanged\n\\[\n\\vb{x}_{n+1} = \\vb{x}_n + \\vb{v}_{n+1/2}\\Delta t =\n\\vb{x}_n + \\frac{\\vb{u}_{n+1/2}\\Delta t}{\\gamma_{n+1/2}}\\,,\n\\]\nwith \\(\\gamma^2 = 1 + {\\left(u_{n+1/2}/c\\right)}^2\\).\n\nThe relativistic version is also volume\npreserving~\\autocite{higuera_structurepreservingsecondorder_2017}.\n\n\\section{The field solver}\n\nWe now turn our attention to the electromagnetic field equations. In order to\ncompute the time evolution of the fields, we will use the equations containing\ntheir time derivatives, namely\n\\begin{align}\n  \\pdv{\\vb{B}}{t} & = - \\curl{\\vb{E}} \\label{eq:faraday-law-for-yee} \\\\\n  \\pdv{\\vb{E}}{t} & = c^2 \\curl{\\vb{B}} - \\frac{1}{\\varepsilon_0} \\vb{j} \\label{eq:ampere-law-for-yee}\\,.\n\\end{align}\n\n\\Textcite{kaneyee_numericalsolution_1966} proposed a method for solving Maxwell's\nequations in isotropic media involving a leapfrog-like algorithm, but with\nstaggering also in space. In order to illustrate this more easily, we will begin\nwith the one dimensional case\n\\begin{align*}\n  \\pdv{B_y}{t} & = - \\pdv{E_x}{z} \\\\\n  \\pdv{E_x}{t} & = -c^2 \\pdv{B_y}{z} - \\frac{1}{\\varepsilon_0} j_x \\,,\n\\end{align*}\nin which the equations are discretised as follows:\n\\begin{subequations}%\n\\label{eq:yee-1d}\n\\begin{align}\n    &\\frac{B_y^{n+1/2}(k+\\frac{1}{2}) - B_y^{n-1/2}(k+\\frac{1}{2})}{\\Delta t} =\n    - \\frac{E_x^n(k+1) - E_x^n(k)}{\\Delta z} \\label{eq:yee-1d-faraday} \\\\\n    &\\frac{E_x^{n+1}(k) - E_x^{n}(k)}{\\Delta t} =\n    -c^2 \\frac{B_y^{n+1/2}(k+\\frac{1}{2}) - B_y^{n+1/2}(k-\\frac{1}{2})}{\\Delta z}\n    -\\frac{1}{\\varepsilon_0} j_x^{n+1/2}(k) \\label{eq:yee-1d-ampere} \\,.\n\\end{align}\n\\end{subequations}\n\nLet us now take a closer look at these discretisations by comparing with the typical form of the leapfrog\nalgorithm~\\eqref{eq:leapfrog}.\nFor the magnetic field in \\cref{eq:yee-1d-faraday}, the time derivatives of the fields are\ncomputed using the \\(B^{n+1/2} - B^{n-1/2}\\) difference with the source term at step \\(n\\).\nAt the same time, for the electric field, the \\(E(k+1)-E(k)\\) difference is used and the source\nterm is at \\(k+\\frac{1}{2}\\). Thus, the values for the electric\nfield are taken at integer \\(k\\) and \\(n\\), but for the magnetic\nfield, we use the values at half-integer \\(k\\) and \\(n\\), creating\nthus a staggering in both space and time. Moving on to  \\cref{eq:yee-1d-ampere},\nthe time derivative for the electric field uses the \\(E^{n+1}-E^n\\)\ndifference with the source term at \\(n+\\frac{1}{2}\\) and similarly\nthe magnetic field has the spatial derivative using the \\(B(k+\\frac{1}{2}) - B(k-\\frac{1}{2})\\) difference with the source\nterm at \\(k\\). This swap in the steps used by the derivatives can\nbe explained by the fact that in both equations we are observing\nthe field at the same (space-time) points.\n\nWe can now generalize equations~\\eqref{eq:yee-1d} to the 3-dimensional case.\nIn this case Faraday's law in \\cref{eq:faraday-law-for-yee} becomes\n% \\begin{align*}\n%   \\pdv{B_x}{t} &= -\\pdv{E_z}{y} + \\pdv{E_y}{z} \\\\\n%   \\mathcolor{green}{\\pdv{B_y}{t}} &= -\\mathcolor{blue}{\\pdv{E_x}{z}} + \\mathcolor{magenta}{\\pdv{E_z}{x}} \\\\\n%   \\pdv{B_z}{t} &= -\\pdv{E_y}{x} + \\pdv{E_x}{y} \\,.\n% \\end{align*}\n\\begin{align*}\n  \\pdv{B_x}{t} &= -\\pdv{E_z}{y} + \\pdv{E_y}{z} \\\\\n  \\pdv{B_y}{t} &= -\\pdv{E_x}{z} + \\pdv{E_z}{x} \\\\\n  \\pdv{B_z}{t} &= -\\pdv{E_y}{x} + \\pdv{E_x}{y} \\,.\n\\end{align*}\n\nTo better emphasize the differences from \\cref{eq:yee-1d-faraday}, we will focus on the\n\\(O_y\\) components. Thus the discrete form will be given by\n% \\begin{equation}\n%   \\label{eq:yee-3d-faraday-y}\n%   \\begin{aligned}\n%     &\\frac{\\mathcolor{green}{B_y^{n+1/2}}(\\mathcolor{magenta}{i+\\frac{1}{2}},j,\\mathcolor{blue}{k+\\frac{1}{2}})\n%     - \\mathcolor{green}{B_y^{n-1/2}}(\\mathcolor{magenta}{i+\\frac{1}{2}},j,\\mathcolor{blue}{k+\\frac{1}{2}})}{\\mathcolor{green}{\\Delta t}} = \\\\\n%     &- \\frac{\\mathcolor{blue}{E_x}^{\\mathcolor{green}{n}}(\\mathcolor{magenta}{i+\\frac{1}{2}},j,\\mathcolor{blue}{k+1}) -\n%       \\mathcolor{blue}{E_x}^{\\mathcolor{green}{n}}(\\mathcolor{magenta}{i+\\frac{1}{2}},j,\\mathcolor{blue}{k})}{\\mathcolor{blue}{\\Delta z}}\n%     + \\frac{\\mathcolor{magenta}{E_z}^{\\mathcolor{green}{n}}(\\mathcolor{magenta}{i+1},j,\\mathcolor{blue}{k+\\frac{1}{2}}) -\n%       \\mathcolor{magenta}{E_z}^{\\mathcolor{green}{n}}(\\mathcolor{magenta}{i},j,\\mathcolor{blue}{k+\\frac{1}{2}})}{\\mathcolor{magenta}{\\Delta x}}\\,.\n%   \\end{aligned}\n% \\end{equation}\n\\begin{equation}\n  \\label{eq:yee-3d-faraday-y}\n  \\begin{aligned}\n    &\\frac{B_y^{n+1/2}(i+\\frac{1}{2},j,k+\\frac{1}{2})\n    - B_y^{n-1/2}(i+\\frac{1}{2},j,k+\\frac{1}{2})}{\\Delta t} = \\\\\n    &- \\frac{E_x^{n}(i+\\frac{1}{2},j,k+1) - E_x^{n}(i+\\frac{1}{2},j,k)}{\\Delta z}\n    + \\frac{E_z^{n}(i+1,j,k+\\frac{1}{2}) - E_z^{n}(i,j,k+\\frac{1}{2})}{\\Delta x}\\,.\n  \\end{aligned}\n\\end{equation}\n\nSince it is quite tedious to write everything explicitly, several shorthand\nnotations have been developed. For example, \\textcite{lehe_electromagneticparticleincell_2018}\nuses\n\\[\nF^n_{i,j,k} \\equiv F^n(i,j,k)\n\\]\nand\n\\begin{align*}\n  \\partial_t F \\rvert^n_{i,j,k} &\\equiv \\frac{F^{n+\\frac{1}{2}}_{i,j,k} - F^{n-\\frac{1}{2}}_{i,j,k}}{\\Delta t} \\qquad\\quad\n  \\partial_x F \\rvert^n_{i,j,k} \\equiv \\frac{F^n_{i+\\frac{1}{2},j,k} - F^n_{i-\\frac{1}{2},j,k}}{\\Delta x} \\\\\n  \\partial_y F \\rvert^n_{i,j,k} &\\equiv \\frac{F^n_{i,j+\\frac{1}{2},k} - F^n_{i,j-\\frac{1}{2},k}}{\\Delta y} \\qquad\n  \\partial_z F \\rvert^n_{i,j,k} \\equiv \\frac{F^n_{i,j,k+\\frac{1}{2}} - F^n_{i,j,k-\\frac{1}{2}}}{\\Delta z} \\,.\n\\end{align*}\n\nWith these notations, \\cref{eq:yee-3d-faraday-y} becomes\n\\[\n\\partial_t B_y \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}} =\n  -\\partial_z E_x \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\n  +\\partial_x E_z \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\n\\]\nand by applying the same for the rest of the components we obtain\n\\begin{align*}\n  \\partial_t B_x \\rvert^n_{i,j+\\frac{1}{2},k+\\frac{1}{2}} &=\n  -\\partial_y E_z \\rvert^n_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\n  +\\partial_z E_y \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\\\\n  \\partial_t B_y \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}} &=\n  -\\partial_z E_x \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\n  +\\partial_x E_z \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\\\\n  \\partial_t B_z \\rvert^n_{i+\\frac{1}{2},j,k+\\frac{1}{2}} &=\n  -\\partial_x E_y \\rvert^n_{i+\\frac{1}{2},j+\\frac{1}{2},k}\n  +\\partial_y E_x \\rvert^n_{i+\\frac{1}{2},j+\\frac{1}{2},k} \\,.\n\\end{align*}\n\nIn a similar fashion, Ampère's law in \\cref{eq:ampere-law-for-yee} becomes\n\\begin{align*}\n  \\pdv{E_x}{t} &= -c^2 \\pdv{B_y}{z} + c^2 \\pdv{B_z}{y} - \\frac{1}{\\varepsilon_0} j_x \\\\\n  \\pdv{E_y}{t} &= -c^2 \\pdv{B_z}{x} + c^2 \\pdv{B_x}{z} - \\frac{1}{\\varepsilon_0} j_y \\\\\n  \\pdv{E_z}{t} &= -c^2 \\pdv{B_x}{y} + c^2 \\pdv{B_y}{x} - \\frac{1}{\\varepsilon_0} j_z\n\\end{align*}\nand the analogue of \\cref{eq:yee-1d-ampere} for the \\(Ox\\) axis will be\n\\begin{equation}\n  \\label{eq:yee-3d-ampere-y}\n  \\begin{aligned}\n    \\frac{E_x^{n+1}(i+\\frac{1}{2},j,k)- E_x^n(i+\\frac{1}{2},j,k)}{\\Delta t} =\n    -c^2\\frac{B_y^{n+1/2}(i+\\frac{1}{2},j,k+\\frac{1}{2}) -\n      B_y^{n+1/2}(i+\\frac{1}{2},j,k-\\frac{1}{2})}{\\Delta z} \\\\\n    + c^2\\frac{B_z^{n+1/2}(i+\\frac{1}{2},j+\\frac{1}{2},k) -\n      B_z^{n+1/2}(i+\\frac{1}{2},j-\\frac{1}{2},k)}{\\Delta x}\n    - \\frac{1}{\\varepsilon_0}j_x^{n+1/2}\\,.\n  \\end{aligned}\n\\end{equation}\n\nUsing the compact notation above, we obtain\n\\begin{align*}\n  \\partial_t E_x \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j,k} &=\n  c^2\\partial_y B_z \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j,k}\n  -c^2\\partial_z B_y \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j,k}\n  -\\frac{1}{\\varepsilon_0} j_x \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j,k} \\\\\n  \\partial_t E_y \\rvert^{n+\\frac{1}{2}}_{i,j+\\frac{1}{2},k} &=\n  c^2\\partial_z B_x \\rvert^{n+\\frac{1}{2}}_{i,j+\\frac{1}{2},k}\n  -c^2\\partial_x B_z \\rvert^{n+\\frac{1}{2}}_{i,j+\\frac{1}{2},k}\n  -\\frac{1}{\\varepsilon_0} j_y \\rvert^{n+\\frac{1}{2}}_{i,j+\\frac{1}{2},k} \\\\\n  \\partial_t E_z \\rvert^{n+\\frac{1}{2}}_{i,j,k+\\frac{1}{2}} &=\n  c^2\\partial_x B_y \\rvert^{n+\\frac{1}{2}}_{i,j,k+\\frac{1}{2}}\n  -c^2\\partial_y B_x \\rvert^{n+\\frac{1}{2}}_{i,j,k+\\frac{1}{2}}\n  -\\frac{1}{\\varepsilon_0} j_z \\rvert^{n+\\frac{1}{2}}_{i,j,k+\\frac{1}{2}} \\,.\n\\end{align*}\n\nWe can observe that we have only used tow of the four Maxwell equations to describe\nthe evolution of the fields, so we should check that the other two equations are\nsatisfied.\nLet us begin with the divergence of the magnetic field\n\\[\n\\div{\\vb{B}} = 0 \\,.\n\\]\n\nAssuming that the relation is initially valid and\n\\[\n\\pdv{\\vb{B}}{t} = - \\curl{\\vb{E}}\n\\]\nis satisfied all the time, then\n\\[\n\\pdv{\\div{\\vb{B}}}{t} = \\div{\\pdv{\\vb{B}}{t}} = \\div{\\left(-\\curl{\\vb{E}}\\right)} = 0\\,.\n\\]\n\nThe discretised equations thus satisfy \\(\\div{\\vb{B}} = 0\\) since the above equation\nvanishes by the cancellation of identical derivative terms.\nThe discretised version of this condition can be written as\n\\[\n\\partial_x B_x \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}} +\n\\partial_y B_y \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}} +\n\\partial_z B_z \\rvert^{n+\\frac{1}{2}}_{i+\\frac{1}{2},j+\\frac{1}{2},k+\\frac{1}{2}}\n= 0\\,.\n\\]\n\nWe will now continue with the divergence of the electric field\n\\[\n\\div{\\vb{E}} = \\frac{\\rho}{\\varepsilon_0} \\,.\n\\]\n\nAgain, we suppose that the relation is satisfied initially and that\n\\[\n\\pdv{\\vb{E}}{t} = c^2 \\curl{\\vb{B}} - \\frac{1}{\\varepsilon_0} \\vb{j}\n\\]\nis valid all the time. Then\n\\[\n\\pdv{t} \\left(\\div{\\vb{E}} - \\frac{\\rho}{\\varepsilon_0}\\right) =\n-\\frac{1}{\\varepsilon_0} \\left[\\pdv{\\rho}{t}\n-\\div{\\left(\\frac{1}{\\mu_0} \\curl{\\vb{B}} - \\vb{j}\\right)}\\right] =\n-\\frac{1}{\\varepsilon_0} \\left(\\pdv{\\rho}{t} + \\div{\\vb{j}}\\right)\n\\]\nand we can observe that\n\\(\n\\div{\\vb{E}} = \\rho/\\varepsilon_0\n\\)\nis satisfied \\emph{if} the continuity equation is respected for all time steps.\nIn its discrete form, the continuity equation is given by\n\\[\n\\partial_t \\rho \\rvert^{n+\\frac{1}{2}}_{i,j,k} +\n\\partial_x j_x \\rvert^{n+\\frac{1}{2}}_{i,j,k} +\n\\partial_y j_y \\rvert^{n+\\frac{1}{2}}_{i,j,k} +\n\\partial_z j_z \\rvert^{n+\\frac{1}{2}}_{i,j,k}\n= 0\\,.\n\\]\n\n% \\subsection{Current deposition}\n\n\\subsection{Stability}\n\nIn order to study the stability of the Yee algorithm, we will take a closer look\nat the propagation of an electromagnetic wave in vacuum\nfollowing \\textcite{lehe_electromagneticwave_2018}.\n\nIn order to simplify the calculations, we will begin with the one dimensional\ncase with the electric field on \\(Ox\\) and the magnetic field on \\(Oy\\).\nIn this case, the propagation of electromagnetic waves is described by\nequations~\\eqref{eq:yee-1d}, with the current density term dropped.\nWith a more compact notation, this gives\n\\begin{subequations}%\n\\label{eq:yee-wave-1d}\n  \\begin{align}\n    &\\frac{{B_y}^{n+1/2}_{k+1/2} - {B_y}^{n-1/2}_{k+1/2}}{\\Delta t} =\n    - \\frac{{E_x}^n_{k+1} - {E_x}^n_k}{\\Delta z} \\label{eq:yee-wave-1d-faraday}\\\\\n    &\\frac{{E_x}^{n+1}_k - {E_x}^n_k}{\\Delta t} =\n    -c^2 \\frac{{B_y}^{n+1/2}_{k+1/2} - {B_y}^{n+1/2}_{k-1/2}}{\\Delta z}\n    \\label{eq:yee-wave-1d-ampere}\\,.\n  \\end{align}\n\\end{subequations}\n\nIn order to better motivate the following derivation, let us consider the continuous\n(3D) case first. Equations~\\eqref{eq:yee-wave-1d} are the 1D discretisations\nof\n\\[\n\\begin{aligned}\n  \\pdv{\\vb{B}}{t} &= -\\curl{\\vb{E}} \\\\\n  \\frac{1}{c^2}\\pdv{\\vb{E}}{t} &= \\curl{\\vb{B}} \\,.\n\\end{aligned}\n\\]\nIf we take the time derivative of the second equation, we obtain\n\\[\n\\frac{1}{c^2}\\pdv[2]{\\vb{E}}{t} = \\pdv{t} \\curl{\\vb{B}} = \\curl{\\left(\\pdv{\\vb{B}}{t}\\right)}\n= \\curl{\\left(-\\curl{\\vb{E}}\\right)} = - \\grad{\\underbrace{(\\div{\\vb{E}})}_{0\\text{ in vacuum}}} + \\laplacian{\\vb{E}}\\,,\n\\]\nin which we can recognise the wave equation\n\\[\n\\frac{1}{c^2}\\pdv[2]{\\vb{E}}{t} - \\laplacian{\\vb{E}} = \\dalambert{\\vb{E}} = 0\\,.\n\\]\n\nThus if we divide \\cref{eq:yee-wave-1d-ampere} by \\(c^2\\) and take the time derivative,\nwe should obtain the discretised wave equation. Using centred time differences\nbetween \\cref{eq:yee-wave-1d-ampere} at time step \\(n\\) and \\(n-1\\), we obtain\n\\[\n\\frac{1}{c^2} \\frac{1}{\\Delta t} \\left(\\frac{{E_x}^{n+1}_k - {E_x}^n_k}{\\Delta t}\n- \\frac{{E_x}^{n}_k - {E_x}^{n-1}_k}{\\Delta t}\\right) =\n\\frac{1}{\\Delta t} \\left(-\\frac{{B_y}^{n+1/2}_{k+1/2} - {B_y}^{n+1/2}_{k-1/2}}{\\Delta z}\n+ \\frac{{B_y}^{n-1/2}_{k+1/2} - {B_y}^{n-1/2}_{k-1/2}}{\\Delta z}\\right).\n\\]\nThe time and space derivatives commute, so we can rearrange the terms in the\nright hand side to match a centred time derivative and thus obtain\n\\[\n\\begin{aligned}\n  \\frac{1}{c^2}\\frac{{E_x}^{n+1}_k - {E_x}^n_k}{\\Delta t^2}\n- \\frac{1}{c^2}\\frac{{E_x}^{n}_k - {E_x}^{n-1}_k}{\\Delta t^2} &=\n- \\frac{{B_y}^{n+1/2}_{k+1/2} - {B_y}^{n+1/2}_{k-1/2}}{\\Delta z \\Delta t}\n+ \\frac{{B_y}^{n-1/2}_{k+1/2} - {B_y}^{n-1/2}_{k-1/2}}{\\Delta z \\Delta t} \\\\&=\n- \\frac{{B_y}^{n+1/2}_{k+1/2} - {B_y}^{n-1/2}_{k+1/2}}{\\Delta z \\Delta t}\n+ \\frac{{B_y}^{n+1/2}_{k-1/2} - {B_y}^{n-1/2}_{k-1/2}}{\\Delta z \\Delta t} \\\\&=\n  \\frac{{E_x}^n_{k+1} - {E_x}^n_k}{\\Delta z^2} - \\frac{{E_x}^n_{k} - {E_x}^n_{k-1}}{\\Delta z}\\,,\n\\end{aligned}\n\\]\nwhere in the last step we used \\cref{eq:yee-wave-1d-faraday}. We can observe\nthat the terms can be rearranged such that we obtain second order centred time\nderivatives. Thus we obtain the 1D discrete wave equation\n\\begin{equation}\n\\label{eq:discrete-wave-1d}\n\\frac{1}{c^2} \\frac{{E_x}^{n+1}_k - 2{E_x}^n_k + {E_x}^{n-1}_k}{\\Delta t^2} =\n\\frac{{E_x}^n_{k+1} - 2{E_x}^n_k + {E_x}^n_{k-1}}{\\Delta z^2}\\,.\n\\end{equation}\n\nWe will now take a closer look at the behaviour of the propagating wave solutions\n\\[\n{E_x}^n_l = E_0 \\ee^{\\ii k l \\Delta z - \\ii \\omega n \\Delta t}\\,,\n\\]\nwhere we changed to using the \\(l\\) for indexing as not confuse it with the\nwavenumber \\(k\\). Using this solution in \\cref{eq:discrete-wave-1d} gives\n\\[\n\\begin{aligned}\n  \\frac{E_0\\ee^{\\ii k l \\Delta z}}{c^2}\n  \\frac{\\ee^{-\\ii \\omega (n+1) \\Delta t}\n      -2\\ee^{-\\ii \\omega n \\Delta t}\n      + \\ee^{-\\ii \\omega (n-1) \\Delta t}}{\\Delta t^2} &=\n  E_0\\ee^{-\\ii \\omega n \\Delta t}\n  \\frac{\\ee^{\\ii k (l+1) \\Delta z}\n      -2\\ee^{\\ii k l \\Delta z}\n      + \\ee^{\\ii k (l-1) \\Delta z}}{\\Delta z^2} \\\\\n  \\frac{\\ee^{\\ii k l \\Delta z - \\ii \\omega n \\Delta t}}{c^2}\n  \\frac{\\ee^{-\\ii \\omega \\Delta t}\n      -2\n      + \\ee^{\\ii \\omega \\Delta t}}{\\Delta t^2} &=\n  \\ee^{-\\ii \\omega n \\Delta t + \\ii k l \\Delta z}\n  \\frac{\\ee^{\\ii k \\Delta z}\n      -2\n      + \\ee^{-\\ii k \\Delta z}}{\\Delta z^2} \\\\\n  \\frac{1}{c^2}\n  \\frac{\\ee^{-\\ii \\omega \\Delta t}\n      -2\n      + \\ee^{\\ii \\omega \\Delta t}}{\\Delta t^2} &=\n  \\frac{\\ee^{\\ii k \\Delta z}\n      -2\n      + \\ee^{-\\ii k \\Delta z}}{\\Delta z^2} \\\\\n  \\frac{1}{c^2 \\Delta t^2}\n  {\\left(\\ee^{-\\ii \\omega \\Delta t / 2} - \\ee^{\\ii \\omega \\Delta t / 2}\\right)}^2 &=\n  \\frac{1}{\\Delta z^2}\n  {\\left(\\ee^{-\\ii k \\Delta z / 2} - \\ee^{\\ii k \\Delta z / 2}\\right)}^2\\,.\n\\end{aligned}\n\\]\n\nUsing Euler's formula\n\\[\n\\ee^{\\ii x} = \\cos{x} + \\ii \\sin{x}\\,,\n\\]\nwe obtain\n\\begin{equation}\n  \\label{eq:yee-1d-dispersion}\n  \\frac{1}{c^2 \\Delta t^2} \\sin^2\\left(\\frac{\\omega \\Delta t}{2}\\right) =\n  \\frac{1}{\\Delta z^2} \\sin^2\\left(\\frac{k \\Delta z}{2}\\right).\n\\end{equation}\n\n\\Cref{eq:yee-1d-dispersion} is a dispersion relation for the discrete one dimensional\nwave propagation. In the continuous case the dispersion relation is \\(\\omega^2 = c^2 k^2\\).\n\nIf we take the square root of \\cref{eq:yee-1d-dispersion}\n\\[\n\\begin{aligned}\n  \\sin^2\\left(\\frac{\\omega \\Delta t}{2}\\right) &=\n  \\frac{c^2 \\Delta t^2}{\\Delta z^2} \\sin^2\\left(\\frac{k \\Delta z}{2}\\right) \\\\\n  \\left|\\sin\\left(\\frac{\\omega \\Delta t}{2}\\right)\\right| &=\n  \\left|\\frac{c \\Delta t}{\\Delta z} \\sin\\left(\\frac{k \\Delta z}{2}\\right)\\right|\n\\end{aligned}\n\\]\nwe observe that we obtain real solutions for \\(\\omega\\), for any \\(k\\)\n\\[\n\\omega = \\pm \\frac{2}{\\Delta t} \\arcsin(\\frac{c \\Delta t}{\\Delta z} \\sin(\\frac{k \\Delta z}{2}))\n\\]\nonly if \\(c \\Delta t \\leq \\Delta z\\).\n\nThus the phase velocity of electromagnetic waves \\(v_\\phi = \\omega/k\\) will be given by\n\\[\nv_\\phi = \\pm \\frac{2}{k\\Delta t} \\arcsin(\\frac{c \\Delta t}{\\Delta z} \\sin(\\frac{k \\Delta z}{2}))\\,.\n\\]\n\nThis means that in a 1D PIC code that is using the Yee discretisations, electromagnetic\nwaves in vacuum propagate with a velocity depending on \\(k\\), instead at the\n(constant) speed of light. This phenomena is called \\emph{numerical dispersion}.\nSince the wavenumber is inverse proportional to the wavelength, electromagnetic\nwaves with shorter wavelengths will propagate slower.\n\nFor \\(c \\Delta t \\ge \\Delta z\\), the discrete dispersion relation given by\n\\cref{eq:yee-1d-dispersion} has no real solutions in the limit \\(k \\to \\pi/\\Delta z\\).\nThe solution is imaginary and the corresponding mode is said to be unstable.\nAs a consequence, PIC codes using FDTD methods like presented here are restricted\nto \\(c \\Delta t \\leq \\Delta z\\). This is called the \\emph{Courant limit}.\nThis coupling between \\(\\Delta z\\) and \\(\\Delta t\\) places an upper bound on\nhow fast can a simulation advance.\nMoreover, \\(\\Delta z\\) is tightly coupled with the physics of the simulation,\nsince it must be chose such that it can resolve the smallest features of\nthe given problem.\n\nThis kind of analysis can be extended in a straightforward way to the 3D case.\nIn this case the discrete version of the solution to the wave equation will\nbe given by\n\\[\nE = E_0 \\ee^{\\ii k_x x + \\ii k_y y + \\ii k_z z - \\ii \\omega t}\\,.\n\\]\n\nSimilarly, the 3D dispersion relation will be given by\n\\[\n\\frac{1}{c^2 \\Delta t^2} \\sin^2\\left(\\frac{\\omega \\Delta t}{2}\\right) =\n  \\frac{1}{\\Delta x^2} \\sin^2\\left(\\frac{k_x \\Delta x}{2}\\right) +\n  \\frac{1}{\\Delta y^2} \\sin^2\\left(\\frac{k_y \\Delta y}{2}\\right) +\n  \\frac{1}{\\Delta z^2} \\sin^2\\left(\\frac{k_z \\Delta z}{2}\\right)\n\\]\nand the 3D Courant condition by\n\\[\nc \\Delta t \\leq \\frac{1}{\\sqrt{\\frac{1}{\\Delta x^2} + \\frac{1}{\\Delta y^2} + \\frac{1}{\\Delta z^2}}}\\,.\n\\]\n\nAs we can see from the dispersion relation, in the 3D case, the phase velocity\nwill depend on wavelength and propagation direction.\n\n\\section{Particle in Cell codes in practice}\n\nIn order to actually use the Particle in Cell method, a concrete implementation\nis needed. Since the beginning of the PIC method, several software packages\nwere developed for simulations. Due to the complexity of the physical processes\ninvolved significant computational resources are required for PIC simulations\nand for this reason the performance of the program is very important.\n\n\\subsection{A brief overview of HPC}\n\nWith the advent of exa-scale computing, the performance of the systems and of the\ncodes is mainly given by the scalability.\nThus the ability to fully utilize the resources of a cluster or of a super-computer\nis critical to the usability of PIC codes. Particle in Cell codes thus fall in\nthe category of High Performance Computing (HPC).\n\n\\subsubsection{Theoretical description of scalability}\n\nThe scalability of any code is achieved via efficient parallelisation and task\nscheduling on multiple levels.\nIn order to measure how scalable a code is, we can compare its benchmarks with\ntwo theoretical scalability limits: Amdahl's law~\\autocite{amdahl_validitysingle_1967}\nand Gustafson's law~\\autocite{gustafson_reevaluatingamdahl_1988}.\n\nAmdahl's law considers that a task can be split in a parallelisable part (\\(p\\)) and a\nserial part. If we consider the problem size fixed and we increase parallelisation,\nthen the maximal speedup that can be achieved is limited by the part that cannot\nbe parallelized \\(1-p\\).\n\nIf we consider the theoretical scaling of a program as a function of the number\nof processors \\(n\\), then the speedup is given by\n\\[\nS_A = \\frac{1}{(1-p)+\\frac{p}{n}}\n\\qquad \\text{and} \\qquad\n\\lim_{n\\to\\infty} S_A = \\frac{1}{1-p}\\,.\n\\]\n\n\\begin{figure}[hb!]\n  \\centering\n  \\subimport{../figures/}{theoretical-scaling-Amdahl}%\n  \\caption{The speedup computed with Amdahl's law}\\label{fig:theoretical-scaling-Amdahl}%\n\\end{figure}\n\nGustafson's law considers that with the increase of computational resources we\ncan solve more complicated tasks in the same time. In this case, if \\(s\\) is the\nserial part of the task that does not benefit from parallelisation, then the speedup\nas a function of the number of processors \\(n\\) is\n\\[\nS_G = n + (1-n)s = 1 - p + np\\,.\n\\]\n\n\\begin{figure}[h!]\n  \\centering\n  \\subimport{../figures/}{theoretical-scaling-Gustafson}%\n  \\caption{The speedup computed with Gustafson's law}\\label{fig:theoretical-scaling-Gustafson}%\n\\end{figure}\n\nAs we can see in \\cref{fig:theoretical-scaling-Amdahl}, Amdahl's law shows that\nadding more an more processors yields diminishing returns as we approach the\nlimit. Note that in the above discussion we use the processor term in a generic\nfashion, not an actual processor which may have complicated architectural details.\nThere are also several other assumptions such as the fact that the processors\nor parallel units are identical (of the same type) and that the cost of parallelisation\nis independent of the number of processors, but the most important assumption\nis the fact that the problem size is fixed. This is where Gustafson's law\ncomes into place. As we can see in \\cref{fig:theoretical-scaling-Gustafson},\nits predictions about scaling are not so grim and it doesn't impose a limit on\nscaling. Instead of showing the limitations imposed by the serial parts of the\nprograms, it shows that speedups can be achieved by increasing the problem size.\nAmdahl's law is also called strong scaling and Gustafson's law is also called\nweak scaling~\\autocite{lin_scalabilitystrong_2018}.\nIn \\cref{fig:theoretical-scaling} we can see a comparison\nbetween the two and the perfect scaling (\\(S_p(n)=n\\)).\nScaling efficiency in the case of strong scaling is defined as\n\\[\n\\eta_s = \\frac{t_1}{n t_n}\\,,\n\\]\nwhere \\(t_1\\) is the time for the task with one processor and\n\\(t_n\\) in the time for the task with \\(n\\) processors.\nIn the case of weak scaling\n\\[\n\\eta_w = \\frac{t_1}{t_n'}\\,,\n\\]\nwhere \\(t_1\\) is the time required for the reference problem size,\nwhile \\(t_n'\\) is the time for a problem \\(n\\) times bigger computed with \\(n\\)\nprocessors~\\autocite{sharedhierarchicalacademicresearchcomputingnetwork_measuringparallel_2016}.\n\n\\begin{figure}[h]\n  \\centering\n  \\subimport{../figures/}{theoretical-scaling-all}%\n  \\caption{The theoretical speedup compared with linear axis and small number\n  of processors on the left and log-log scale with a large number of processors\n  on the right}\\label{fig:theoretical-scaling}%\n\\end{figure}\n\n\\subsubsection{Practical aspects}\n\nModern processors not only have multiple cores, but they also have special instruction\nsets that execute vectorized operations, these are generically called SIMD, which\nstands for Single Instruction, Multiple Data. Thus, in order to efficiently utilize\nthe computational power of a single processor, instruction level parallelism must\nbe combined with thread or process based parallelism, while parallelisation in\nitself is important, there are also several other critical factors that must be\nconsidered.\n\nOne important aspect is that of data availability. The processor must load data\nin order to make computations. It doesn't matter how fast is the processor is the\ndata loading is inefficient. Data can be loaded from different sources. The\nfastest is the data already in the CPU caches, followed by the data loaded from RAM\nand other I/O (input/output) sources (hard drives or network for example). In order to have data\navailable more efficiently modern processors use prefetching, that they load more\ndata from the RAM in the processor cache in order to have faster access for subsequent\nqueries. This aspects must be considered when writing simulation programs, since\naccessing data in a way that is not favorised by prefetching may lead to significant\nslowdowns from cache misses. The picture is more complicated with parallelisation,\nas each processor has its own cache and care must be taken such that different\ncores must not race for the same memory region (this is called false sharing).\nMoreover, servers usually have multiple processors, each with several cores.\nThese are just a few aspects that scratch the surface of the complexity involved\nin the parallelisation at the level of a single machine.\n\nMoving on to multiple machines, network access between nodes becomes of critical\nimportance for computing tasks that require frequent communication between\nnodes. In PIC code the simulation domain is split in several parts\nand each machine gets some parts of the domain that is responsible for.\nThis process is called domain decomposition. In this case each machine can\nwork independently to update the interior of its domain and must only communicate\nwith its neighbours in order to update the boundaries. Thus, in PIC codes inter-process\nand inter-machine communication is very important. The important aspect for the\nnetwork layer is low latency. This can be achieved by using technologies such as\nInfiniBand and RDMA.\\@ InfiniBand is a networking standard that provides very high\nthroughput and very low latency and RDMA stands for Remote Direct Memory Access\nand as the name implies allows direct memory access form one machine into another\nwithout the involvement or overhead of the operations managed by the operating system.\nIn order to address the challenge of creating programs that take advantage of such\nfeatures, the MPI standard was developed. MPI stands for Message Passing Interface\nand it is a communication protocol for programming parallel computers.\n\nWhile CPUs definitely play an important role in parallel computing, in the last\ndecade GPUs and more recently other dedicated hardware accelerators, have become\nmore and more important. Compared with CPUs, GPUs have a lot of cores, almost\ntwo to three order of magnitude more than common CPUs. While processors have\nfew tens of cores, with state of the art reaching up to hundreds of\ncores~\\autocite{intelcorporation_intelxeon_2016, ibm_power9servers_2018,\nvazhkudai_designdeployment_2018},\nGPUs can reach over 5000 cores~\\autocite{nvidiacorporation_nvidiatesla_2018}.\nOne important aspect is that GPUs cores have simpler architecture compared with\nprocessors, usually favour single precision computations, and have much less memory.\nWhile CPUs processors can have access to hundreds of Gigabytes of RAM memory,\nGPUs usually have a few tens Gigabytes of memory, state of the art units reaching\nnear one hundred~\\autocite{vazhkudai_designdeployment_2018}.\\@\nThus, loading data efficiently into the GPU memory represents a critical aspect\nthat must be considered. In combination with the networking layer,\nthis yields new performance problems that need to be addressed.\nIn order to address these challenges, technologies such as\nNVIDIA\\textsuperscript{®} NVLink™ have been developed, that allow direct\nGPU to GPU communication~\\autocite{nvidiacorporation_nvidianvlink_2018}.\n\n\\subsection{A survey of available PIC codes}\n\nAs a concrete example of scalability in PIC codes, we will consider\nOsiris~\\autocite{fonseca_osiristhreedimensional_2002}, a three dimensional,\nfully relativistic Particle in Cell code. \\Textcite{fonseca_exploitingmultiscale_2013}\nbenchmarked Osiris on Top 500~\\autocite{strohmaier_top500supercomputer_1993}\nsupercomputers including the Jaguar system at Oak Ridge National Laboratory\nand the Sequoia system at Lawrence Livermore Laboratory in the US.\\@\nThe main result is the very good scaling behaviour of the Osiris code from\n4096 cores to 1572864 cores on the Sequoia system, as can be seen in \\cref{fig:osiris-scaling}.\nNote that in order to compare the results with the theoretical descriptions\nfor strong and weak scaling, one has to adjust the formulae in order to account\nfor the fact that the processor number does not start with 1, \\emph{i.e.} \\(S(4096)=1\\).\nIn order to achieve this performance, the code had to be heavily optimised over\nmultiple levels of parallelism. Besides MPI they used shared memory parallelism\nand instruction level parallelism in order to fully benefit from the available\ncomputing power. Besides advanced implementation techniques such as the SIMD\nvectorised particle pusher, an important role is given by the nature of the algorithms\nand thus using methods that only require local state information is crucial for scalability.\nAs an example, the FDTD method for updating the fields, only requires information\nfrom its neighbours as opposed to classical spectral methods that require the\nglobal state information.\n\nAnother important aspect stressed in the previously mentioned article, is that\nof load balancing. For highly non-linear applications such as Laser Wakefield\nacceleration, regions of very high particle density are of critical importance\nfor the physical phenomena, but they create a very high load imbalance in the\nsimulation. One solution that was investigated was the use of shared memory\nparallelism which offset the imbalance by using more threads on the machines\nthat have to deal with high density regions. Another approach was of algorithmic\nnature, by using dynamical load balancing in order to adjust the domain boundaries.\n\nWhile performance and scaling are important properties of a PIC code, the ability\nto realistically simulate the physics of the phenomena is of paramount importance.\nUsing charge conserving schemes for current deposition and higher order splines\nfor shape functions contributes to better accuracy, and support for ionization,\ncollisions and QED effects gives a better representations of the physics simulations.\nBoth of these aspects are required for solving complex problems such as accelerator\ndesign.\n\nAnother state of the art PIC code is Warp-X~\\autocite{vay_warpxnew_2018}, which\nis a framework for laser plasma simulations in the context of accelerator design.\nIt combines three software components: Warp (a framework for modelling plasma and\nparticle accelerators), AMRex (Adaptive Mesh Refinement library) and\nPICSAR (low level PIC primitives). It is designed for running at exa-scale\nand has advanced features such as ultrahigh-order pseudo-spectral analytical\ntime-domain (PSATD) field solvers~\\autocite{vincenti_ultrahighordermaxwell_2018}\nand multiple ionisation modes.\n\n\\subsubsection{The Extreme Light Infrastructure}\n\nThe Extreme Light Infrastructure (ELI) project is a pan-European research\ninfrastructure dedicated to ultra-intense and ultra-short laser\npulses~\\autocite{gales_introduction_2016}. The ELI facility consists of three\npillars built in The Czech Republic, Hungary and Romania, with the Romanian\npillar being ELI-Nuclear Physics (ELI-NP). One of the proposed experiments is the\nexperimental demonstration of the QED-plasma regime, which involves radiation\ndamping due to the synchrotron radiation~\\autocite{turcu_highfield_2016}.\nOne of the key signatures for this effect is given by the scaling of energetic\nphoton emission with peak laser intensity. Particle in Cell simulations\nusing the EPOCH program~\\autocite{arber_contemporaryparticleincell_2015} were used\nto predict an increase in \\(\\gamma\\)-ray emission at high laser intensities such as\n\\SIrange[range-phrase=--,range-units=single]{e21}{e22}{\\watt\\per\\square\\centi\\metre},\ndue to the additional synchrotron component~\\autocite{brady_synchrotronradiation_2014}.\n\nAnother ELI project concerns the development of the ion sources such that GeV\nprotons could be obtained at the limit of the ELI parameters, \\emph{i.e.} using\nlaser intensities in the range of \\SI{e24}{\\watt\\per\\square\\centi\\metre}.\nParticle in Cell simulations with the Osiris program were used to find the laser\nparameters corresponding to the ion source at the \\SI{100}{\\peta\\watt}\nrange~\\autocite[327]{mourou_eliextreme_2011}.\n\n\\begin{figure}[h]\n  \\includegraphics[width=0.9\\textwidth]{osiris-scaling}\n  \\caption{The scaling behaviour of Osiris at the Sequoia system at Lawrence Livermore Laboratory.\n  Figure 5 reproduced from \\textcite{fonseca_exploitingmultiscale_2013}.}%\n  \\label{fig:osiris-scaling}%\n\\end{figure}\n\n\\subsubsection{Frequently used codes}\n\nA list of frequently used simulation programs is given in \\cref{tab:pic}. This list\nis by no means exhaustive, but it should provide an overview of how different\nfeatures are adopted in PIC codes. The codes are organized\nconsidering their features and implementation features.\nFor the features, the ``Type'' column indicates whether\nthe code is electromagnetic (solves Maxwell's equations)\nor quasi-static (solves Poisson's equation), and available\nsimulation features such as different geometries or special\nfield solvers. The ``Scalability'' column is dedicated to\nimplementation details that are strongly related to how\nscalable the code is. Thus, for inter-node and inter-process communication\nMPI is generally used, for shared memory parallelism OpenMP\nor pthreads are widely used. For GPU specific tasks, the\nCUDA framework is used in conjunction with NVIDIA hardware.\nWhile a significant portion of the codes is written in \\texttt{Fortran}, \\texttt{C} or \\texttt{C++}, there are some\ncodes written in \\texttt{Python}, or with \\texttt{Python} wrappers. In this case NUMBA, an open source JIT (Just In Time) compiler, is usually used to enhance performance by translating a\nsubset of \\texttt{Python} and \\texttt{NumPy} into LLVM code.\n\\texttt{NumPy} is an optimized array library in \\texttt{Python} for working with N-dimensional arrays and\nLLVM stands for Low Level Virtual Machine and it is a compiler infrastructure that can be used to emit optimized\nmachine code.\nA recent trend in HPC is the rise of\nheterogeneous computing, involving mainly CPUs and GPUs, and thus the\n``GPU ready'' column was included to indicate the adoption of this computing\nmodel among various programs.\n\n\\begin{table}\n\\centering\n  \\begin{tabular}{l l l l}\n  \\toprule\n  \\textbf{Name} & \\textbf{Type} & \\textbf{GPU ready} & \\textbf{Scalability}\\\\\n  \\midrule\n  EPOCH & EM 3D & No & MPI\\\\\n  Osiris & EM 3D, RZ\\textsuperscript{F}, RZ\\textsuperscript{FFT} & Yes & MPI, OpenMP, SIMD\\\\\n  Warp-X & EM 3D, PS, RZ\\textsuperscript{F}, RZ\\textsuperscript{FFT} & Yes & MPI, OpenMP, SIMD\\\\\n  PIConGPU & EM 3D & Yes & MPI, CUDA-ALPAKA\\\\\n  VSim & EM 3D & Yes & MPI\\\\\n  FBPIC & EM 3D, RZ\\textsuperscript{H} & Yes & MPI, NUMBA\\\\\n  VPIC & EM 3D & No & MPI, pthreads, SIMD\\\\\n  QuickPIC & QS RZ & No & MPI\\\\\n  PICLS & EM 3D & No & MPI\\\\\n  \\bottomrule\n  \\end{tabular}\n  \\caption{Commonly used simulation programs}%\n  \\label{tab:pic}\n\\end{table}\n\nIn \\cref{tab:pic} we used the following abbreviations\n\\begin{itemize}\n    \\item EM:\\ Electromagnetic PIC\n    \\item QS:\\ Quasi-Static PIC\n    \\item 3D:\\ Cartesian coordinates, up to 3D\n    \\item RZ:\\ Cylindrical geometry with FDTD method in \\(r\\) and \\(z\\) directions\n    \\item RZ\\textsuperscript{F}: Cylindrical geometry with Fourier azimuthal decomposition\n    \\item RZ\\textsuperscript{FFT}: Cylindrical geometry with FDTD method in \\(r\\) direction\n                and FFT-based pseudo-spectral method in \\(z\\) direction\n    \\item RZ\\textsuperscript{H}: Cylindrical geometry with Henkel transform in \\(r\\) direction\n                and FFT-based pseudo-spectral method in \\(z\\) direction\n    \\item PS:\\ Pseudo-spectral Maxwell solver with domain decomposition and local Fourier transform\n\\end{itemize}\n\n% tabel ✓\n% grafic scalabilitate osiris ✓\n% mentiune osiris/grup lisabona in ELI whitebook ✓\n% coduri de tip WARP de la Bella, citare JL Vay & H Vincenti, picsar ref Vincenti ✓\n% referinta tdr eli-np negoita ✓\n\n\\section{EPOCH}\n\nEPOCH~\\autocite{arber_contemporaryparticleincell_2015} is a plasma simulation\ncode using the Particle in Cell method featuring dynamic\nload balancing, parallel I/O based on MPI, and integration\nwith a wide array of visualisation tools.\nThe EPOCH user manual~\\autocite{bennett_usersmanual_2019} provides the required information for installing and\nutilizing the code.\n\nEPOCH uses input files, also called input decks in order to\nconfigure the simulation parameters and the choice of solvers.\nThe input deck contains several blocks, each considering a specific aspect.\nWe will quickly present some of the main blocks\n\\begin{itemize}\n  \\item The ``control'' block: this block contains general information concerning the geometry of the simulation\n  domain, the load balancing method, the initial conditions and the algorithm choice for the\n  field solver.\n  \\item The ``boundaries'' block: this block provides the details regarding boundary condition handling.\n  \\item The ``species'' block: this block is used to specify the particle species to be used in the simulation\n  and their properties.\n  \\item The ``laser'' block: this block provides the information about the laser source.\n  \\item The ``fields'' block: this block contains the specifics of the electromagnetic fields present at the start of the simulation.\n  \\item The ``window'' block: this block can be used in order to create a moving window in which the simulation\n  occurs. This can be useful in cases where the simulation domain is large, but the interesting part is relatively small (and can be followed during the evolution).\n  \\item The ``output'' block: this block is used to specify where and how often to write the output files.\n\\end{itemize}\n\nThe output of EPOCH simulations is given in a custom file format, SDF (Self Describing Format).\nEPOCH provides several reader plugins for \\texttt{ITT},\n\\texttt{IDL}, \\texttt{LLNL VisIt}, \\texttt{Mathworks Matlab} and \\texttt{Python}.\nThe output files written to disk, also called output dumps, can be of several types,\nwith varying degrees of detail. The most detailed one, called\nthe restart dump can be used to restart the simulation at a later time.\nThe quantities to be written can have some filters, called dumpmasks, indicating the output frequency and level of detail.\nThe output information provided by EPOCH can be grouped in\nfour categories: particle variables, grid variables, derived variables and other variables.\n\nParticle variables include\n\\begin{itemize}\n  \\item the position of the particles\n  \\item the momenta and velocities of the particles\n  \\item the charge and mass of the particles\n  \\item the particle weight, representing how much real particles does a pseudo-particle represent\n  \\item the particle energy\n  \\item the work excreted by the fields on the particle\n\\end{itemize}\n\nGrid variables include\n\\begin{itemize}\n  \\item the locations of the grid points\n  \\item the electric and magnetic field values\n  \\item the current density values\n\\end{itemize}\n\nDerived variables include\n\\begin{itemize}\n  \\item the average particle energy\n  \\item the mean energy flux on the grid\n  \\item the mass and charge density\n  \\item the number density\n  \\item the number of particles per cell\n  \\item the average particle weight per cell\n  \\item the average momenta of the particles per cell\n  \\item the temperature on the grid\n  \\item the Poynting vector flux\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "78c20227c93df975dc68d2adfbb60929f98c091a", "size": 72108, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/pic.tex", "max_stars_repo_name": "SebastianM-C/MasterThesis", "max_stars_repo_head_hexsha": "ffbf25e087444644ee73f72a31be969375fa0d10", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manuscript/pic.tex", "max_issues_repo_name": "SebastianM-C/MasterThesis", "max_issues_repo_head_hexsha": "ffbf25e087444644ee73f72a31be969375fa0d10", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manuscript/pic.tex", "max_forks_repo_name": "SebastianM-C/MasterThesis", "max_forks_repo_head_hexsha": "ffbf25e087444644ee73f72a31be969375fa0d10", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4890678941, "max_line_length": 187, "alphanum_fraction": 0.6817135408, "num_tokens": 25301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.42948360628330173}}
{"text": "\\chapter{Methods}\n\\label{sec:methods}\nThe Methods section first introduces one of our main contributions, several new architectures based on supervised autoencoders, which we leveraged for multi-omics integration. Afterward, we overview how we benchmarked our new architectures, including the choice of benchmark datasets, reference models, performance metric, and validation strategy. Lastly, we briefly describe aspects related to the interpretability of our models, in particular the investigation of our models' latent spaces using absolute correlations and the fitting of global surrogate models to transfer our models to clinical settings.\n\n\\section{Architectures}\n\\label{sec:archs}\nWe developed several novel neural architectures based on a combination of \\glsxtrlong{sgl} regularization and supervised autoencoders. Before moving on to the architectures, we begin with some brief notes on notation. Let \\(X\\) denote our input matrix. Further let \\(m_1, ..., m_{|M|}\\) denote our input variable groups (in particular, the different clinical and biological data groups). We then denote the portion of the input matrix belonging to a particular modality \\(m_i\\) as \\(X^{(m_i)}\\). Let \\(\\hat X\\) denote a  reconstruction of \\(X\\) and denote the latent space of an autoencoder taking $X$ as its input as \\(\\tilde X\\). Let \\(\\hat \\varphi_i (\\tilde X)\\) denote the estimated log-partial hazard of patient \\(i\\) based on latent space of an autoencoder taking $X$ as its input. Furthermore, denote the set of all linear layers in each of our architectures as $A$ and denote the linear layer regularized with \\gls{sgl} in each model as $B$.\\footnote{Not all of our models used \\gls{sgl}, in which case $B = \\{\\}$.} For all of our architectures in the following, we regularized all linear layers with L2 regularization, except for the layer which was already regularized with \\gls{sgl} (blue edges in each architecture diagram). By slight abuse of notation, we will use $B$ for both the linear layer, which was regularized using \\gls{sgl}, as well as its weight matrix.\n\n\\subsection{Naive \\glsxtrfull{sae}}\nOur first idea, termed Naive \\glsxtrfull{sae}, was the most simple. We took an autoencoder and added a supervised loss from its latent space to survival $\\hat \\varphi (\\tilde X)$. In addition, we regularized the first layer using \\gls{sgl} (Figure \\ref{fig:arch-sae}; blue edges denote \\gls{sgl}).\n\n\\begin{figure}\n\\centering\n    \\includegraphics[scale=0.75]{./content/figures/fig_arch-sae.pdf} \\caption{Architecture diagram of the Naive \\glsxtrfull{sae}. Grey edges denote L2 regularization, blue edges \\glsxtrlong{sgl} regularization. Let $X^{(m_i)}$ denote the part of $X$ which corresponds to the i-th input variable group, and $\\hat X^{(m_i)}$ a reconstruction of the same. $\\tilde X$ is the latent space of the autoencoder and $\\hat \\varphi(\\tilde X)$ is a predicted log-partial hazard based on this latent space.}\\label{fig:arch-sae}\n\\end{figure}\n\nOur loss function for \\gls{sae} is then (Equation \\ref{eq:sae-loss}): \n\n\\begin{equation} \n  \\begin{split}\n  &L_{\\text{total}}  \\left(\\hat \\varphi, X, \\hat X\\right) \\\\ &=  L_{\\text{cox}}(T, \\delta, \\hat \\varphi)  + \\xi \\cdot \\text{MSE}(X, \\hat X) \\\\&+ \\lambda_1 \\sum_{a \\in A \\setminus B} ||a||_F^2 +\\lambda_2 (1 - \\alpha) \\sum_{m \\in \\{m_1, ..., m_{|M|}\\}} \\sqrt{|m| } ||B^{(m)}||_F  \\\\&+  \\lambda_2  \\alpha || B||_{1,1}\n  \\end{split}\n  \\label{eq:sae-loss}\n\\end{equation}\n\nWhere $\\lambda_1$ is a regularization hyper-parameter controlling the amount of L2 regularization on all linear layers (except the one regularized with \\gls{sgl}), $\\lambda_2$ is a regularization hyper-parameter controlling the amount of \\gls{sgl} regularization, $\\xi$ is a regularization hyper-parameter controlling the weight of the reconstruction loss, and $\\alpha$ is a trade-off hyper-parameter between the Lasso ($\\alpha = 1$) and the Group-Lasso ($\\alpha = 0$). $\\hat \\varphi$ is the predicted log-partial hazard based on the latent space $\\tilde X$. $\\text{MSE}$ is the mean-squared error (Equation \\ref{eq:mse-matrix}) and $L_\\text{cox}$ is the negative partial log-likelihood (Equation \\ref{eq:pl-efron}), that is $L_\\text{cox} = - \\ell(\\beta)$ (\\emph{i.e.,} we used Breslow's approximation). $B^{(m)}$ is a submatrix of $B$ containing only columns corresponding to inputs of modality $m$.\n\nDue to its naiveness, we, unfortunately, found \\emph{SAE} exceedingly challenging to train in that the learning rate required meticulous tuning to not start diverging. For this reason, we did not run our final benchmarks with \\gls{sae} and excluded it from further consideration. Next, we were interested in giving each input modality a separate autoencoder and afterward fusing the individual latent spaces, similar to \\citet{tong2020deep} but using supervised autoencoders. For this, we chose the two most self-evident operations, both of which \\citet{tong2020deep} investigated as well: Mean-pooling and concatenation. We first present our concatenated approach, the \\gls{csae}, followed by the mean-pooling approach, the \\gls{msae}.\n\n\\subsection{\\glsxtrfull{csae}}\nIn the concatenated approach, we fitted one supervised autoencoder for each input modality, after which we concatenated all first-level latent spaces $\\tilde m_1, ..., \\tilde m_{|M|}$ to form $C = [\\tilde m_1, ..., \\tilde m_{|M|}]$. This concatenation was then used to predict a log-partial hazard \\(\\hat \\varphi (C)\\) (Figure \\ref{fig:arch-csae}). In addition, we regularized the last linear layer with \\gls{sgl} (blue edges in Figure \\ref{fig:arch-csae}).\n\n\\begin{figure}\n\\centering\n    \\includegraphics[scale=0.75]{./content/figures/fig_arch-csae.pdf} \\caption{Architecture diagram of the \\glsxtrfull{csae}. Grey edges denote L2 regularization, blue edges \\glsxtrlong{sgl} regularization. Let $X^{(m_i)}$ denote the part of $X$ which corresponds to the i-th input variable group, $\\hat X^{(m_i)}$ a reconstruction of the same. $\\tilde m_i$ is the latent space of an autoencoder taking $X^{(m_i)}$ as its input and $C=[\\tilde m_1, ..., \\tilde m_{|M|}]$ is a concatenation of all first level latent spaces. $\\hat \\phi_1, ..., \\hat \\phi_{m}$ as well as $\\hat \\varphi$ are predicted log-partial hazards based on their respective inputs.}\n    \\label{fig:arch-csae}\n\\end{figure}\n\nSince \\gls{csae} contained individual autoencoders for each input modality, we modified the loss function of \\gls{sae} slightly to include the additional autoencoders (Equation \\ref{eq:csae-loss}):\n\n\\begin{equation} \n  \\begin{split}\n  &L_{\\text{total}}  \\left(\\hat \\varphi, \\hat \\phi_1, ..., \\hat \\phi_{|M|}, X, \\hat X\\right) \\\\ &=  L_{\\text{cox}}(T, \\delta, \\hat \\varphi)  \\\\&+ \\sum_{q = 1}^{|M|}  \\left(L_\\text{cox}(T, \\delta, \\hat \\phi_q) + \\gamma \\cdot \\text{MSE}\\left(X^{\\left(m_q\\right)}, \\hat X^{\\left(m_q\\right)}\\right)\\right) \\\\&+ \\lambda_1 \\sum_{a \\in A \\setminus B} ||a||_F^2 +\\lambda_2 (1 - \\alpha) \\sum_{m \\in \\{m_1, ..., m_{|M|}\\}} \\sqrt{|m| } ||B^{(m)}||_F  \\\\&+  \\lambda_2  \\alpha || B||_{1,1}\n  \\end{split}\n  \\label{eq:csae-loss}\n\\end{equation}\n\nWhere $\\lambda_1, \\lambda_2$ are again regularization hyper-parameters as in Equation \\ref{eq:sae-loss} and $\\alpha$ is again a trade-off hyper-parameter between the Lasso and the Group-Lasso. $\\gamma$ is another regularization hyper-parameter controlling the strength of the reconstruction loss of each first-level autoencoder, and $\\hat \\phi_i$ is the predicted log-partial hazard from each first level supervised autoencoder, while $\\hat \\varphi$ is the predicted log-partial hazard based on $C$. $\\text{MSE}$ is the mean-squared error (Equation \\ref{eq:mse-matrix}) and $L_\\text{cox}$ is the negative partial log-likelihood (Equation \\ref{eq:pl-efron}), that is $L_\\text{cox} = - \\ell(\\beta)$ (\\emph{i.e.,} we used Breslow's approximation). $B^{(m)}$ is a submatrix of $B$ containing only columns corresponding to inputs of modality $m$.\n\n\\subsection{\\glsxtrfull{msae}}\n\\gls{msae} was constructed identical to the concatenated policy, save that instead of concatenation, we mean-pooled the first level latent spaces (Figure \\ref{fig:arch-msae}). In addition, since after mean-pooling, variables cannot be mapped back to their original input group, \\gls{msae} does not use any \\gls{sgl} regularization in its loss function (Equation \\ref{eq:msae-loss}).\n\n\\begin{figure}\n\\centering\n    \\includegraphics[scale=0.75]{./content/figures/fig_arch-msae.pdf} \\caption{Architecture diagram of the \\glsxtrfull{msae}. Grey edges denote L2 regularization. Let $X^{(m_i)}$ denote the part of $X$ which corresponds to the i-th input variable group, $\\hat X^{(m_i)}$ a reconstruction of the same. $\\tilde m_i$ is the latent space of an autoencoder taking $X^{(m_i)}$ as its input and $C=[\\tilde m_1, ..., \\tilde m_{|M|}]$ is a concatenation of all first level latent spaces. $C_{\\text{MP}}$ is a mean-pooled version of $C$, \\emph{i.e.,} it takes the mean across all first level latent spaces for each of the dimensions. $\\hat \\phi_1, ..., \\hat \\phi_{m}$ as well as $\\hat \\varphi$ are predicted log-partial hazards based on their respective inputs.}\\label{fig:arch-msae}\n\\end{figure}\n\n\\begin{equation} \n  \\begin{split}\n  &L_{\\text{total}}  \\left(\\hat \\varphi, \\hat \\phi_1, ..., \\hat \\phi_{|M|}, X, \\hat X\\right) \\\\ &=  L_{\\text{cox}}(T, \\delta, \\hat \\varphi)  \\\\&+ \\sum_{q = 1}^{|M|}  \\left(L_\\text{cox}(T, \\delta, \\hat \\phi_q) + \\gamma \\cdot \\text{MSE}\\left(X^{\\left(m_q\\right)}, \\hat X^{\\left(m_q\\right)}\\right)\\right) \\\\&+ \\lambda_1 \\sum_{a \\in A \\setminus B} ||a||_F^2 \n  \\end{split}\n  \\label{eq:msae-loss}\n\\end{equation}\n\nwhere all notation is as above.\n\n\\subsection{\\glsxtrfull{shae}}\nOur last architecture, termed \\gls{shae} was built on hierarchical supervised multi-modal autoencoders and was partially inspired by \\citet{simidjievski2019variational}, who provided an overview of different possible architectures of \\gls{vae}s for multi-omics integration. \\gls{shae} has two levels of autoencoders. After the first level, which is identical to \\gls{msae} and \\gls{csae}, there is a second level autoencoder that takes the concatenation of all first-level latent spaces as its input (Figure \\ref{fig:arch-shae}). The second level autoencoder once again predicts a log-partial hazard $\\hat \\varphi$ from its latent space $\\tilde C$ and tries to reconstruct $C$ from $\\tilde C$. We again regularized the first layer after the concatenation of the first level latent spaces using \\gls{sgl} (blue edges in Figure \\ref{fig:arch-shae}).\n\nIn effect, \\gls{shae} can be thought of as running \\gls{sae} with the concatenated latent spaces of \\gls{csae} (except that everything is trained jointly). The full loss for \\emph{SHAE} is then (Equation \\ref{eq:loss-shae}):\n\n\\begin{figure}\n\\centering\n    \\includegraphics[scale=0.75]{./content/figures/fig_arch-shae.pdf} \\caption{Architecture diagram of the \\glsxtrfull{shae}. Grey edges denote L2 regularization, blue edges \\glsxtrlong{sgl} regularization. Let $X^{(m_i)}$ denote the part of $X$ which corresponds to the i-th input variable group, $\\hat X^{(m_i)}$ a reconstruction of the same. $\\tilde m_i$ is the latent space of an autoencoder taking $X^{(m_i)}$ as its input and $C=[\\tilde m_1, ..., \\tilde m_{|M|}]$ is a concatenation of all first level latent spaces. $\\hat \\phi_1, ..., \\hat \\phi_{m}$ as well as $\\hat \\varphi$ are predicted log-partial hazards based on their respective inputs. $\\tilde C$ is the latent space of the second-level autoencoder that takes $C$ as its input.}\\label{fig:arch-shae}\n\\end{figure}\n\n\\begin{equation} \n  \\begin{split}\n  &L_{\\text{total}}  \\left(\\hat \\varphi, \\hat \\phi_1, ..., \\hat \\phi_{|M|}, X, \\hat X, C, \\hat C\\right) \\\\ &=  L_{\\text{cox}}(T, \\delta, \\hat \\varphi)  + \\xi \\cdot \\text{MSE}(C, \\hat C) \\\\&+ \\sum_{q = 1}^{|M|}  \\left(L_{\\text{cox}}(T, \\delta, \\hat \\phi_q ) + \\gamma \\cdot \\text{MSE}\\left(X^{\\left(m_q\\right)}, \\hat X^{\\left(m_q\\right)}\\right)\\right) \\\\&+ \\lambda_1 \\sum_{a \\in A \\setminus B} ||a||_F^2 +\\lambda_2 (1 - \\alpha) \\sum_{m \\in \\{m_1, ..., m_{|M|}\\}} \\sqrt{|m| } ||B^{(m)}||_F  \\\\&+  \\lambda_2  \\alpha || B||_{1,1}\n  \\end{split}\n  \\label{eq:loss-shae}\n\\end{equation}\n\nWhere $\\lambda_1, \\lambda_2, \\alpha$ are hyper-parameters as above controlling \\gls{sgl} and L2 regularization. $\\xi$ and $\\gamma$ are once again hyper-parameters controlling the strength of the reconstruction loss. $\\hat C$ is a reconstruction of the concatenation of the first level latent spaces ($C = [\\tilde m_1, ..., \\tilde m_{|M|}]$), $\\hat \\varphi$ is the log-partial hazard prediction from the second level latent space and $\\hat \\phi_1, ..., \\hat \\phi_{|M|}$ are the log-partial hazard predictions from each first level supervised autoencoder. $\\text{MSE}$ is the mean-squared error (Equation \\ref{eq:mse-matrix}) and $L_\\text{cox}$ is the negative partial log-likelihood (Equation \\ref{eq:pl-efron}), that is $L_\\text{cox} = - \\ell(\\beta)$ (\\emph{i.e.,} we used Breslow's approximation). $B^{(m)}$ is a submatrix of $B$ containing only columns corresponding to inputs of modality $m$.\n\n\\subsection{Residual architecture versions}\nWe also explored a residual variant of all of our architectures (see \\emph{Optional residual layer} in Figures \\ref{fig:arch-sae} - \\ref{fig:arch-shae}). In these, we fed the first modality (\\(m_1\\), clinical data in our study) into the autoencoder and also skipped it to the final layer predicting the log-partial hazard $\\hat \\varphi$. Using this skipping, we hoped to achieve two goals: \n\n\\begin{enumerate}\n    \\item The model could still take clinical data into account within the autoencoder(s), which might help other features or whole input groups, both with the reconstruction and for learning a better latent space for survival prediction.\n    \\item This may aid performance since clinical data (in most datasets) contains valuable survival information, as shown by \\citet{herrmann2021large} and \\citet{hornung2019block}.\n\\end{enumerate}\n\nOur residual idea was heavily inspired by the favoring approach of \\gls{bf} \\citep{hornung2019block} and \\emph{resnets} \\citep{he2016deep}. We applied the residual approach to each of our architectures within our benchmarks, choosing to skip clinical data each time. We thus included a total of $6$ of our architectures in the benchmark, each of \\gls{csae}, \\gls{msae}  and \\gls{shae} plus their respective residual version.\n\n\\subsection{Implementation}\n\\label{sec:implementation}\nWe developed all neural nets using \\emph{Pytorch} \\citep{paszke2019pytorch} and \\emph{skorch} \\citep{skorch}. We defaulted to scaling the supervised loss by multiplying it by the batch size (\\emph{i.e.,} $\\xi = \\gamma = \\text{batch size}$) since we found this worked well initially and saved one hyper-parameter. \n\nFor all of our architectures, we performed z-score standardization (Algorithm \\ref{alg:z-score-norm}) of all features using \\emph{sklearn} \\citep{scikit-learn} before fitting the model. Further, we used batch normalization \\citep{ioffe2015batch} and the \\gls{prelu} (\\ref{eq:prelu}) for non-linear activations \\citep{he2015delving}. We used the \\emph{Adam} optimizer \\citep{kingma2014adam} for training our models and trained for $25$ epochs, with a batch size equal to the size of the dataset (\\emph{i.e.,} no batching) and an initial learning rate of $0.01$ (the highest learning rate before the training loss started diverging for most cancers). We tuned the regularization parameters $\\lambda_1$ and $\\lambda_2$ using five fold cross-validation for $\\lambda_1, \\lambda_2 \\in \\{1e-2, 1e-3, 1e-4\\}$. In line with the \\emph{SGL} package \\citep{sgl2019}, we fixed the $\\alpha$ trade-off parameter for \\gls{sgl} to $\\alpha = 0.95$.\\footnote{\\citet{simon2013sparse} suggest using $\\alpha=0.95$ if \"we we expect strong overall sparsity and would like to encourage grouping\" \\citep{simon2013sparse} and $\\alpha=0.05$ \"if we expect strong group-wise sparsity, but only mild sparsity within group\" \\citep{simon2013sparse}. Since we generally expect fairly strong sparsity within groups (although neural networks will never have true zeros for weights anyway) for multi-omics integration, we chose $\\alpha=0.95$.}\n\nSince our models employ batch normalization, the literature suggests that it may be possible to fix the learning rate given the proper weight decay due to their strong interdependence in the presence of batch normalization, even for adaptive methods like \\emph{Adam} \\citep{hoffer2018norm, van2017l2}. Thus, we tuned only the regularization parameters and not the learning rate. All latent space sizes were set to size $64$, and all encoders (and by symmetry decoders) were set to have one hidden layer with $128$ nodes. While all of these architectural hyper-parameters were trainable in our implementation, we did not tune these in order not to complicate the hyper-parameter search space. \n\n\\begin{algorithm}\n\\caption{Z-score normalization algorithm.}\\label{alg:z-score-norm}\n    \\begin{algorithmic}\n    \\Require $X$\n    \\State $X_{\\text{norm}} \\gets X$\n    \\For{$j = 1, ..., p$}\n        \\State $X_{\\text{norm}}[:, p] \\gets (X[:, p] - \\text{mean}(X[:, p])) / \\text{sd}(X[:, p])$\n    \\EndFor\n    \\State \\Return $X_{\\text{norm}}$\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\\begin{equation}\\label{eq:prelu}\n    \\text{\\gls{prelu}}(x) = \\begin{cases}\n        x, &\\text{if $x\\geq 0$}\\\\\n        ax, &\\text{otherwise}\n        \\end{cases}\n\\end{equation}\n\n\\section{Reference models}\nFor reference models, we used the best performing model from the benchmark study of \\citet{herrmann2021large}, \\glsxtrfull{bf},  as well as \\glsxtrfull{rbf}.\\footnote{{\\emph{RandomBlock} is an alternative version of \\glsxtrfull{bf} - \\citet{hornung2019block} showed that it outperformed \\gls{bf} when clinical variables were favored with multi-omics data on \\gls{tcga} in terms of Harrell's concordance.}} Favoring refers to the decision tree base learners always considering all variables from a specific input group in the split-point selection (most often clinical variables), indepdendent of $m$. \\gls{bf} and \\gls{rbf} were implemented using the \\emph{blockForest} package \\citep{blockforestpackage2021}. For \\gls{rbf}, we favored clinical variables.\n\nWe also included a \\glsxtrfull{rsf} and a \\glsxtrfull{lasso} as two benchmark methods that did not use the group structure information present in the multi-omics variables.  Lastly, we included a \\glsxtrfull{cox}, specifically a Ridge regularized Cox PH model using only clinical variables. We opted for a Ridge regularized model since this allowed us to prevent convergence issues sometimes seen with one-hot encoded categorical clinical variables. \\gls{rsf} was implemented using \\emph{ranger} \\citep{ranger} while \\gls{lasso} and \\gls{cox} were both implemented using \\emph{glmnet} \\citep{glmnet, coxnet}. \\gls{lasso} and \\gls{cox} were set to standardize their input matrices, while no further preprocessing was performed for \\gls{rbf}, \\gls{bf} and \\gls{rsf}.\n\n\\section{Datasets}\nWe benchmarked all models on the \\gls{tcga} datasets. We followed the approach of \\citet{herrmann2021large} in selecting cancers with at least 100 samples and an average event ratio $\\geq 5\\%$ to ensure there were enough patients and enough events to calculate meaningful concordance values.\\footnote{We selected only datasets with $100$ samples \\emph{after} preprocessing, while \\citet{herrmann2021large} included all datasets with $100$ samples \\emph{before} preprocessing. This led us to excluding one dataset relative to \\citet{herrmann2021large}, namely \\gls{laml}.} Further, we utilized \\emph{GISTIC 2.0} for \\gls{cnv} \\citep{mermel2011gistic2} and the number of non-silent \\emph{MC3} mutation calls per gene per patient for mutation \\citep{ellrott2018scalable}.\\footnote{Mutation calls were calculated from the \\emph{PANCANATLAS} \\emph{MAF} file using \\emph{Maftools} \\citep{mayakonda2018maftools}.} \\gls{cnv} was taken directly from \\emph{Xenabrowser} \\citep{goldman2020visualizing}, with mutation coming from \\emph{PANCANATLAS} \\citep{chang2013cancer}. In addition, we considered \\gls{mirna}, \\gls{mrna}, \\gls{dna} methylation, \\gls{rppa}, and clinical data, all of which were also taken from \\emph{PANCANATLAS}. We log-transformed both \\gls{mrna} and \\gls{mirna} expression. Otherwise, no further preprocessing of the datasets was performed.\n\nFor comparability, we used the same clinical variables as \\citet{herrmann2021large}, with the caveat that we dropped clinical variables which were missing for more than five patients. Categorical clinical variables were one-hot encoded. We excluded molecular variables if they were missing for more than one patient to preserve as many patients as possible. Table \\ref{tab:tcga-overview} shows an overview of all datasets used in our benchmarks.\n\n\\begin{table}\n\n\\caption{\\label{tab:tcga-overview}Summary information of all $17$ considered \\gls{tcga} datasets used in our study. \\gls{tcga} cancer abbreviations used for space, please refer to https://gdc.cancer.gov/resources-tcga-users/tcga-code-tables/tcga-study-abbreviations for a full overview. n refers to the samples in each cancer, p the number of total variables. The censoring ratio is the percentage of all patients that were censored. All other columns denote the number of variables contained in each input group. Table format inspired by \\citet{herrmann2021large}.}\n\\centering\n\\resizebox{\\linewidth}{!}{\n\\begin{tabular}[t]{c c c c c c c c c c c}\n\\toprule\nCancer & n & p & Censoring ratio & Clinical & mRNA & CNV & DNA methylation & miRNA & Mutation & RPPA\\\\\n\\midrule\nBLCA & 325 & 84380 & 0.56 & 9 & 20225 & 24776 & 22124 & 740 & 16317 & 189\\\\\nBRCA & 765 & 80668 & 0.87 & 9 & 20227 & 24776 & 19371 & 737 & 15358 & 190\\\\\nCOAD & 284 & 82221 & 0.78 & 16 & 17507 & 24776 & 21424 & 740 & 17569 & 189\\\\\nESCA & 118 & 75752 & 0.64 & 17 & 19076 & 24776 & 21941 & 737 & 9012 & 193\\\\\nHNSC & 201 & 79286 & 0.40 & 16 & 20169 & 24776 & 21647 & 735 & 11752 & 191\\\\\n\\addlinespace\nKIRC & 309 & 74652 & 0.72 & 14 & 20230 & 24776 & 19456 & 735 & 9252 & 189\\\\\nKIRP & 199 & 76294 & 0.85 & 5 & 20178 & 24776 & 21921 & 738 & 8486 & 190\\\\\nLGG & 395 & 78254 & 0.78 & 15 & 20209 & 24776 & 21564 & 740 & 10760 & 190\\\\\nLUAD & 338 & 82999 & 0.60 & 11 & 20165 & 24776 & 21059 & 739 & 16060 & 189\\\\\nPAAD & 100 & 76654 & 0.42 & 26 & 19932 & 24776 & 21586 & 732 & 9412 & 190\\\\\n\\addlinespace\nSARC & 190 & 76068 & 0.64 & 45 & 20206 & 24776 & 21724 & 739 & 8385 & 193\\\\\nSKCM & 238 & 85254 & 0.48 & 3 & 20179 & 24776 & 21635 & 741 & 17731 & 189\\\\\nSTAD & 304 & 80860 & 0.58 & 7 & 16765 & 24776 & 21506 & 743 & 16870 & 193\\\\\nUCEC & 392 & 84130 & 0.84 & 24 & 17507 & 24776 & 21692 & 743 & 19199 & 189\\\\\nOV & 161 & 72763 & 0.42 & 17 & 19064 & 24776 & 19639 & 731 & 8347 & 189\\\\\n\\addlinespace\nLIHC & 157 & 76247 & 0.49 & 3 & 20078 & 24776 & 21739 & 742 & 8719 & 190\\\\\nLUSC & 280 & 82125 & 0.59 & 20 & 20232 & 24776 & 20659 & 739 & 15510 & 189\\\\\n\\bottomrule\n\\end{tabular}}\n\\vspace{-5pt}\n\\end{table}\n\n\\section{Performance metric}\nSimilar to other works \\citep{cheerla2019deep, kim2020improved, tong2020deep}, we used Harrell's concordance (Equation \\ref{eq:concordance}) \\citep{harrell1982evaluating} to measure the performance of our models, where \\(\\hat \\phi_i\\) is an estimated score for patient \\(i\\) (where higher score implies higher risk), \\(U_i\\) is the observed time until patient \\(i\\) either experienced the event or was censored, and \\(\\delta=0\\) for censored patients and \\(\\delta=1\\) otherwise \\citep{schmid2016use}. Equivalently, Harrell's concordance is the ratio of concordant pairs and all comparable pairs.\n\n\\begin{equation}\n  C(U, \\delta, \\hat \\phi) = \\frac{\\sum_{i=1}^n \\sum_{j=1}^n \\mathbbm{1}(U_i > U_j) \\mathbbm{1}(\\hat{\\phi}_i < \\hat{\\phi}_j) \\delta_j}{\\sum_{i=1}^n \\sum_{j=1}^n  \\mathbbm{1}(U_i > U_j) \\delta_j}\n  \\label{eq:concordance}\n\\end{equation}\n\nWhere $\\mathbbm{1}$ is the indicator function, and $n$ is the total number of patients.\n\n\\section{Validation}\n\\label{sec:testing}\nWe tuned all models using nested cross-validation with five inner folds or out-of-bag error (for random forest-based methods) to choose the best parameters to refit on the outer fold. We used the \\emph{glmnet} internal \\emph{cv.glmnet} function to optimize the regularization parameter for \\gls{cox} and \\gls{lasso} using five fold cross-validation. \\gls{bf} and \\gls{rbf} were tuned using the \\emph{blockForest::blockfor} function. For \\gls{rsf}, we tuned the \\emph{mtry} parameter (\\emph{mtry} is equivalent to $m$ in Algorithm \\ref{alg:random-forest}) using the \\emph{tuneRanger::tuneMtryFast} function. As mentioned in Chapter \\ref{sec:implementation}, for our supervised autoencoders, we tuned only the regularization parameters $\\lambda_1, \\lambda_2 \\in \\{1e-2, 1e-3, 1e-4\\}$ using five fold cross-validation (for architectures which used \\gls{sgl}), while setting the other parameters to the defaults detailed in Chapter \\ref{sec:implementation}.\n\nFor all cancers in our dataset, we performed outer five-fold cross-validation, twice repeated, giving us a total of ten outer splits per cancer. For statistical significance testing, we tested for an overall difference between our models and all non-group aware baselines (that is, \\gls{lasso}, \\gls{rsf}, and \\gls{cox}) by adopting the same approach as \\citet{hornung2019block}. We calculated the mean concordance per model per cancer ($17$ in total) and treated these mean values as independent between datasets. We then ran a one-sided paired t-test with a null hypothesis of non-inferiority of each non-group aware benchmark model relative to our architectures. The alternative hypothesis was that our model performed better than the respective benchmark method. We thus performed a total of $18$ tests (each of our three architectures and their residual version compared to each of the three reference models), for which we corrected using Bonferroni-Holm \\citep{holm1979simple}. We report both raw p-values and p-values after correction.\n\n\\section{Computation times}\nWe captured the computation times of all models using \\emph{tictoc} \\citep{tictoc2021} for models in \\emph{R} and \\emph{time.perf\\_counter} in \\emph{Python}. All benchmarks were performed on the Euler cluster of ETH Zurich using eight cores with $4096$ MHz per core. Models which offered multi-threading by default (in particular, \\gls{rsf}, \\gls{bf}, \\gls{rbf} and all of our neural architectures) were allowed to use all available CPUs. We did not parallelize models based on \\emph{glmnet} (\\gls{lasso} and \\gls{cox}) since their computation times were very short even without parallelization. We note that we did not use a GPU, even though it would have favored our neural models, to enable optimal comparability of computation times.\n\n\\section{Reproducibility}\nWe fixed the random seeds throughout our scripts to ensure reproducibility. The implementations include reproduction scripts that can be used to reproduce all of our results. The only model used which was not able to use the respective \\emph{R} or \\emph{Python} seed was \\emph{glmnet}. There was no reliable way to make \\emph{glmnet} reproducible without passing the cross-validation splits ourselves. Hence, we assigned the cross-validation splits outside of the \\emph{cv.glmnet} function (using the same logic as \\emph{glmnet} does internally) and then passed the splits to the function such that computation was reproducible across runs \\citep{glmnetreproduce}. \n\nDespite our seeds, rerunning \\gls{bf}, \\gls{rbf} and \\gls{rsf} on a different operating system might result in slightly different result (although overall results are of course are expected to be extremely similar), as all of them are implemented using the \\emph{ranger} package \\citep{wright2015ranger}. \\emph{ranger} may produce different results on different operating systems, even when run with the same seed \\citep{ranger-seed2021}. Similarly, the neural models may produce slightly different results when rerun (even on the same machine) due to non-reproducibility when Pytorch uses multi-threading on CPU \\citep{pytorch-rep-2021}. The surrogate results may also not be fully deterministic, both due to the \\emph{Pytorch} multi-threading issue mentioned above and since the \\emph{glmnet} solver is not fully deterministic according to the documentation of \\emph{python-glmnet} \\citep{python-glmnet-rep}. Nevertheless, any deviations when rerunning are expected to be minor but could unfortunately not be completely excluded.\n\n\\section{Latent space investigation}\nTo better understand the main features learned by our neural models, we investigated the latent space of our best model for a few cancers. Since the latent spaces of our models were non-sparse, we instead analyzed the correlations of each latent space dimension with specific input features. In particular, we considered all features with the highest absolute correlation with at least one latent space dimension.\\footnote{Since some input variables had the highest absolute correlation for more than one dimension, this analysis generally produced less than $64$ features (recall that our latent spaces are fixed to size $64$).}\n\nIn addition, we investigated pathway activity captured by our models' latent space. We calculated the correlation of each gene with each latent space dimension and created a ranked gene list using these correlations. We then ran \\gls{gsea} \\citep{subramanian2005gene} on this ranked gene list for each latent dimension using \\gls{fgsea} \\citep{korotkevich2021fast} and the hallmarks of cancer \\citep{hanahan2000hallmarks} gene sets from \\emph{MSigDB} \\citep{liberzon2011molecular}. We investigated the best split (by test concordance) for the model under consideration for every exemplary cancer considered since overall differences for the worse splits were negligible (data not shown). \n\n\\section{Permutation importance}\nTo get a secondary measure of how important each input group was for our models, we also leveraged group-wise permutation importance (Algorithm \\ref{alg:fi-group}) introduced in Chapter \\ref{alg:fi-group} as appropriate. To be precise, we calculated ten permutations for each input variable group to give us a reasonably robust measure of group feature importance.\\footnote{Since concordance is not an error measurement, we define our error function $e$ as $e = 1 - \\text{Harrell's concordance}$ when analyzing permutation importance.}\n\n\\section{Global surrogate models}\nWe chose to fit global surrogate Lasso regression models to approximate the predictions of our best architecture (recall that global surrogates were introduced in Chapter \\ref{sec:global-surrogates}). In particular, we wanted to investigate whether a global surrogate model could replicate our models predictions well when only having had access to a subset of input variable groups as this would enormously improve clinical applicability while potentially maintaining high performance. We thus fitted our surrogate models on only clinical data and gene expression (the two most commonly available but at the same time among the most predictive input groups) but had them approximate our best full multi-omics models. The hope was that the models would learn some of the multi-omics information even without having had access to all input groups.\n\nWe were then interested in how well surrogate models could perform, both in terms of approximating the multi-omics neural models (measured by \\emph{e.g.,} $R^2$) and absolute performance (that is, concordance on the test set). While these two goals are overlapping, they are not identical. Consider that our multi-omics neural models may have overfitted the training data. The surrogates' test concordance could thus benefit from a less than perfect fit to the multi-omics model by reducing overfitting. Lastly, we were also curious how sparse these surrogate models would be, especially compared to standard non-group aware methods such as the \\gls{lasso}. We implemented our surrogate models using \\emph{python-glmnet} \\citep{py-glmnet}, the \\emph{Python} wrapper of \\emph{glmnet} \\citep{glmnet}. Since clinical variables generally contain much prognostic relevant information \\citep{herrmann2021large}, we penalized only the gene expression variables.\n\nOur approach in predicting the log-partial hazard estimated by an upstream multi-omics model is reminiscent of pseudo-value methods in survival analysis, which replace right-censored survival data with \\emph{jackknife} pseudo-observations, thus enabling a change in model class to perform regression instead of survival analysis \\citep{zhao2020deep, klein2005regression, andersen2010pseudo}. However, we note that our approach does not have any statistical guarantees (as far as we know) that some of the other pseudo-value techniques do. We also emphasize that care must be taken when interpreting the pseudo hazard ratios obtainable by analyzing the coefficients of the surrogate models. In effect, these cannot be directly interpreted as hazard ratios but rather as a prediction of the hazard ratio which would have been predicted by the model the surrogates are approximating.\n\n\\section{Multi-omics integration as feature selection}\n\\label{sec:arch-search}\nLast but not least, we were also interested in establishing whether the sparsity pattern recovered by our surrogate models was sufficient for arbitrary models to achieve similar performance to the surrogate models. Effectively, we were thus interested in whether multi-omics integration could be reduced to a feature selection task.\n\nThis question is somewhat reminiscent of a similar discussion in neural networks. Previous works had claimed that in structured pruning, what matters is not just the sparsity pattern (\\emph{i.e.,} the architecture), but also the weights learned by the initial model, which could then be fine-tuned after pruning \\citep{han2015learning}. \\citet{liu2018rethinking} on the other hand, showed that after structured pruning, they could achieve as good or better results by retraining the sparsified architectures from random initializations. The results from \\citet{liu2018rethinking} thus suggest that structured pruning in neural networks can, in effect, be treated as an \\emph{architecture search} problem, meaning what matters is solely the sparsity pattern.\n\nWe reframed this question slightly to adapt it to our task of hand. For this, we fitted two models only on the subset of variables selected by one of our surrogate models:\n\n\\begin{enumerate}\n    \\item A Ridge penalized Cox PH model\n    \\item An \\gls{rsf} model\n\\end{enumerate}\n\nThe Ridge model was fit and tuned using the \\emph{cv.glmnet} function while the \\gls{rsf} model was tuned and fit using \\emph{tuneRanger::tuneMtryFast}. What we thus wanted to answer was essentially: Are the selected features from the surrogate models sufficient to reproduce their performance, or do the weights learned by our surrogates play a role (presumably because they were trained not on the actual survival data but the \\gls{shae} predictions)?\n\nThis is an interesting question because, if true, it would allow the reframing of multi-omics integration as purely a feature-selection problem. In turn, this would enable researchers to treat multi-omics models merely as a modeling step rather than the final output. Following this reasoning, this hypothesis could greatly improve the clinical applicability of multi-omics models as they could then be replaced by interpretable models trained on the correct subset of variables. If disproven, the hypothesis could still prove interesting. In that case, it would essentially show that training surrogate models on the predictions of multi-omics models is one of the best ways to achieve interpretable models for clinical practice, as other models with the same sparsity pattern cannot match their performance.\n", "meta": {"hexsha": "162f4bb13c412972005440085232cfe83769bdb6", "size": 35756, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/content/chapter-methods.tex", "max_stars_repo_name": "dnwissel/msc_thesis", "max_stars_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/content/chapter-methods.tex", "max_issues_repo_name": "dnwissel/msc_thesis", "max_issues_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/content/chapter-methods.tex", "max_forks_repo_name": "dnwissel/msc_thesis", "max_forks_repo_head_hexsha": "857dd7624ba9e0730be79c8968215699a442c2fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-24T20:41:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-24T20:41:39.000Z", "avg_line_length": 160.3408071749, "max_line_length": 1406, "alphanum_fraction": 0.7574672782, "num_tokens": 9955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541067, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.42946983594510524}}
{"text": "% !TEX encoding = UTF-8 Unicode\n% !TEX spellcheck = en_US\n% !TEX root = ../../../ICMA2020.tex\n\n\\appendices\n\\label{sec:Appendix}\n\\section{Minimal Dynamics Parameter Vector}\n\\label{sec:MinparamVector}\n\nThe used Parameters are the mass $m_j$, the center of mass $\\boldsymbol{r}_j$ in the coordinate system $(CS)_j$, the inertia $_{(j)}\\boldsymbol{J}_j^{(j)}$ in the coordinate system $(CS)_j$ and referring to the frame origin, the motor and gear inertia $J_{Aj}$ as well as the Coulomb and viscous friction $f_{\\mathrm{c}j}$ and $f_{\\mathrm{v}j}$ for the joints $j=1,\\ldots,6$ respectively. \nThe combined masses $m_{123456}$, $m_{23456}$, $m_{3456}$ and $m_{456}$ are defined in \\eqref{eq:MassenSumme}.\nThe notation for $\\boldsymbol{r}_j$ and $_{(j)}J_j^{(j)}$ is defined by\n\n\\begin{equation}\n\\label{eq:Komponentenschreibweise}\n\t\\boldsymbol{r}_j = \n\t\t\\begin{pmatrix}\n\t\tr_{jx} \\\\\n\t\tr_{jy} \\\\\n\t\tr_{jz} \\\\\n\t\t\\end{pmatrix}\n\t\\quad\n\t\\mathrm{and}\n\t\\quad\n\t_{(j)}\\boldsymbol{J}_j^{(j)} = \n\t\t\\begin{pmatrix}\n\t\tJ_{jxx} & J_{jxy} & J_{jxz} \\\\\n\t\tJ_{jxy} & J_{jyy} & J_{jyz} \\\\\n\t\tJ_{jxz} & J_{jyz} & J_{jzz} \\\\\n\t\t\\end{pmatrix}\n\t\t.\n\\end{equation}\n\n\n{\\footnotesize\n\\begin{equation}\n\\label{eq:Parametersatz}\n%\t\\begin{pmatrix}\n%\t    \\theta_1 \\\\\n%\t    \\theta_2 \\\\\n%\t    \\theta_3 \\\\\n%\t    \\theta_4 \\\\\n%\t    \\theta_5 \\\\\n%\t    \\theta_6 \\\\\n%\t    \\theta_7 \\\\\n%\t    \\theta_8 \\\\\n%\t    \\theta_9 \\\\\n%\t    \\theta_{10} \\\\\n%\t    \\theta_{11} \\\\\n%\t    \\theta_{12} \\\\\n%\t    \\theta_{13} \\\\\n%\t    \\theta_{14} \\\\\n%\t    \\theta_{15} \\\\\n%\t    \\theta_{16} \\\\\n%\t    \\theta_{17} \\\\\n%\t    \\theta_{18} \\\\\n%\t    \\theta_{19} \\\\\n%\t    \\theta_{20} \\\\\n%\t    \\theta_{21} \\\\\n%\t    \\theta_{22} \\\\\n%\t    \\theta_{23} \\\\\n%\t    \\theta_{24} \\\\\n%\t    \\vdots \\\\\n%\t    \\theta_{29} \\\\\n%\t    \\theta_{30} \\\\\n%\t    \\vdots \\\\\n%\t    \\theta_{36} \\\\\n%\t\\end{pmatrix\n\t\\boldsymbol{\\theta}= \n\t\t\\begin{pmatrix}\n\t\t\tJ_{1yy} + 2 l_2 m_1 r_{1x} + l_2^2 m_{123456} + J_{\\text{A}1} + J_{2yy} - l_3^2 m_{23456} + J_{3zz} - l_4^2 m_{3456} \\\\\n\t\t\tl_3^2 m_{23456} + J_{2xx} - J_{2yy} \\\\\n\t\t\t- l_3 m_2 r_{2z} + l_3 m_3 r_{3y} + J_{2xy} \\\\\n\t\t\t- l_3^2 m_{23456} + J_{2zz} + J_{\\text{A}2} \\\\\n\t\t\tl_3 m_{23456} + m_2 r_{2x} \\\\\n\t\t\tJ_{3xx} -J_{3zz} + l_4^2 m_3 + J_{4zz} + 2 l_5 m_4 r_{4y} + (l_4^2 +l_5^2) m_{456} \\\\\n\t\t\t-l_4 m_3 r_{3y} + J_{3xy} \\\\\n\t\t\tJ_{3xz} \\\\\n\t\t\tJ_{3yy} - l_4^2 m_{3456} + J_{4zz} + 2l_5 m_4 r_{4y} + l_5^2 m_{456} \\\\\n\t\t\tJ_{3yz} \\\\\n\t\t\tl_4 m_{3456} + m_3 r_{3x} \\\\\n\t\t\tl_5 m_{456} + m_3 r_{3z} + m_4 r_{4y} \\\\\n\t\t\tJ_{\\text{A}3} \\\\\n\t\t\tJ_{4xx} - J_{4zz} + J_{5zz} \\\\\n\t\t\tJ_{4yy} + J_{5zz} \\\\\n\t\t\tJ_{\\text{A}4} \\\\\n\t\t\tl_6^2 m_6 + 2 l_6 m_6 r_{6z} + J_{5xx} - J_{5zz} + J_{6yy} \\\\\n\t\t\tl_6^2 m_6 + 2 l_6 m_6 r_{6z} + J_{5yy} + J_{6yy} \\\\\n\t\t\tl_6 m_6 + m_5 r_{5z} + m_6 r_{6z} \\\\\n\t\t\tJ_{\\text{A}5} \\\\\n\t\t\tJ_{6xx} - J_{6yy} \\\\\n\t\t\tJ_{6zz} \\\\\n\t\t\tJ_{\\text{A}6} \\\\\n\t\t\t\n\t\t\tf_{\\mathrm{c},1} \\\\\n\t\t\t\\vdots \\\\\n\t\t\tf_{\\mathrm{c},6} \\\\\n\t\t\t\n\t\t\tf_{\\mathrm{v},1} \\\\\n            \\vdots \\\\\n\t\t\tf_{\\mathrm{v},6} \\\\\n\t\t\\end{pmatrix}\n\\end{equation}\n}\n\n%\\begin{equation}\n%\\label{eq:MassenSumme}\n%    \\begin{aligned}\n%\tm_{123456} &= m_1 + m_2 + m_3 + m_4 + m_5 + m_6 \\text{ ,}\\\\\n%\tm_{23456} &= m_2 + m_3 + m_4 + m_5 + m_6 \\text{ ,} \\\\\n%\tm_{3456} &= m_3 + m_4 + m_5 + m_6 \\text{ ,} \\\\\n%\tm_{456} &= m_4 + m_5 + m_6 \\\\\n%    \\end{aligned}\n%\\end{equation}\n\n\\begin{equation}\n\\label{eq:MassenSumme}\n    m_{j..6}=\\sum_{i=j}^{6} m_i\n\\end{equation}", "meta": {"hexsha": "4bf640b3053d16433626ac620eeb58713e3f055f", "size": 3322, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/Chapters/Appendix/Parameters/Parameter.tex", "max_stars_repo_name": "SchapplM/robotics-paper_icma2020", "max_stars_repo_head_hexsha": "f81c6599ec7a9341e6a467a4ff9b31091aa50e75", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/Chapters/Appendix/Parameters/Parameter.tex", "max_issues_repo_name": "SchapplM/robotics-paper_icma2020", "max_issues_repo_head_hexsha": "f81c6599ec7a9341e6a467a4ff9b31091aa50e75", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/Chapters/Appendix/Parameters/Parameter.tex", "max_forks_repo_name": "SchapplM/robotics-paper_icma2020", "max_forks_repo_head_hexsha": "f81c6599ec7a9341e6a467a4ff9b31091aa50e75", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9159663866, "max_line_length": 389, "alphanum_fraction": 0.5406381698, "num_tokens": 1533, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4293982512562462}}
{"text": "\\section{A Universe of Inductive Families}\n\\label{sec:indexing-desc}\n\n\\newcommand{\\vtup}[2]{\\bigRedBracket{\\begin{array}{@{}#1@{}}#2\\end{array}}}\n\n\\begin{wstructure}\n!!! Need Help !!!\n<- Motivation\n    <- Desc: expressivity of simply-typed datatypes: inductive types\n        <- Values do not influence types\n    /> Example: Vectors\n        <- Cannot be defined by just induction\n            <- Vectors of all size need to be defined at the *same* time\n            -> Defined as a *family* of types\n                -> Index\n        -> I -> IDesc I: Inductive family\n    ???\n\\end{wstructure}\n\nSo far, we have explored the realm of inductive types, building on\nintuition from ML-like datatypes, using type dependency as a\ndescriptive tool in $\\Desc$ and its interpretation. Let us now make\ndependent types the object as well as the means of our study.\n\nDependent datatypes provide a way to work at higher level of\nprecision \\emph{a priori}, reducing the sources of failure we\nmight otherwise need to manage. For the perennial\nexample, consider \\emph{vectors}---lists indexed by length. By\nmaking length explicit in the type, we can prevent hazardous\noperations (the type of `head' demands vectors of length\n$\\NatSuc{\\V{n}}$) and offer stronger guarantees (pointwise\naddition of $\\V{n}$-vectors yields an $\\V{n}$-vector).\n\nHowever, these datatypes are not \\emph{individually} inductive. For\ninstance, we have to define the whole \\emph{family} of vectors\nmutually, in one go. In dependently typed languages, the basic grammar\nof datatypes is that of inductive families. To capture this grammar,\nwe must account for \\emph{indexing}.\n\n%% \\subsection{Desc, atomically}\n%% \\label{sec:idesc-atomic-desc}\n\n%% \\begin{wstructure}\n%% [Outdated: type former presentation instead]\n%% <- Adding hindx have introduced some duplication\n%%     <- indx == hindx 1\n%%     -> We can factor out commonalities \n%%         /> Obtain an equivalent presentation\n%%         /> Still embeddable (refer to the Agda model)\n%% \\end{wstructure}\n\n%% \\begin{wstructure}\n%% <- Also replacing '1 by 'const  [figure]\n%%     <- For convenience\n%%         <- 'const X equivalent to 'sigma X (\\_ -> '1)\n%%         /> Easier to abstract\n%%             <- Extensionally same\n%%             /> 'const more useful in practice\n%% \\end{wstructure}\n\n%% Before moving on to indexed descriptions, we have to carry out some\n%% maintenance work on descriptions. We presented $\\Desc$ as the grammar\n%% of inductive types. Hence, the codes closely follow this grammar. In\n%% the following, we adopt an alternative presentation. With\n%% $\\DSigma{\\!}{\\!}$, we are actually \\emph{quoting} a standard\n%% type-former, namely\n\n%% $$\\Bhab{\\Sigma}{\\PI{\\V{S}}{\\Set} \\PI{\\V{S}}{\\Set} \\Set}$$\n\n%% In the alternative presentation, we go further and present all our\n%% codes as quotations of standard type-formers. This presentation is\n%% shown in Figure~\\ref{fig:type-former-desc}. The reader will notice\n%% that we replace $\\DUnit$ by a more general $\\DConst{\\!}$ code. Whereas\n%% $\\DUnit$ was interpreted as the unit set, $\\DConst{\\V{X}}$ is\n%% interpreted as $\\V{X}$, for any $\\Bhab{\\V{X}}{\\Set}$. Extensionally,\n%% $\\DConst{\\V{X}}$ and $\\DSigma{\\V{X}}{\\DUnit}$ are equivalent. However,\n%% $\\DConst{\\!}$ is more succinct. More importantly, $\\DConst$ is\n%% \\emph{first-order}, unlike its equivalent encoding. From a\n%% definitional perspective, we are giving more opportunities to the\n%% type-system, hence reducing the burden on the programmer. For the same\n%% reason, we introduce $\\DProd{\\!}{\\!}$ that overlaps with\n%% $\\DSigma{\\!}{\\!}$.\n\n%% This reorganisation is strictly equivalent to the previous one\n%% (Fig.~\\ref{fig:hindx_desc}). Just as the previous version, it is also\n%% self-descriptive. We refer the reader to the companion technical\n%% report for details. In this finer-grained presentation, we can define\n%% $\\DIndx{\\!}$ and $\\DHindx{\\!}{\\!}$ as follow:\n\n%% \\[\\begin{array}{l@{\\:\\mapsto\\:\\:}l}\n%% \\DIndx{\\V{D}}         & \\DProd{\\DId}{\\V{D}}                      \\\\\n%% \\DHindx{\\V{H}}{\\V{D}}     & \\DProd{(\\DPi{\\V{H}}{(\\LAM{\\_} \\DId)})}{\\V{D}}\n%% \\end{array}\n%% \\]\n\n%% Consequently, the examples previously developed can be\n%% straightforwardly translated into this new presentation. For example,\n%% here is the new definition of $\\NatD$:\n\n%% \\[\\stk{\n%% \\NatD : \\Desc \\\\\n%% \\NatD \\mapsto \\DSigma{(\\EnumT{[ \\NatZero, \\NatSuc{\\!} ]})}\n%%                      {[ \\DUnit \\quad \\DId ]}\n%% }\\]\n\n\n%% In the following, we adopt this last version as our de\n%% facto universe of inductive types. In particular, we are going to\n%% evolve this presentation into an indexed one.\n\n%% \\note{Shall we talk about the Type Theory being Desc Zero? or such story?}\n\n%% \\begin{figure}\n\n%% \\[\\stk{\n%% \\begin{array}{ll}\n%% \\stk{\n%% \\data \\Desc : \\Set \\where                                      \\\\\n%% \\;\\;\\begin{array}{@{}l@{\\::\\:\\:}l@{\\quad}l}\n%%     \\DId            & \\Desc                                    \\\\\n%%     \\DConst{\\!}     & \\Set \\To \\Desc                           \\\\\n%%     \\DProd{\\!}{\\!}  & \\PI{\\V{D}, \\V{D'}}{\\Desc} \\Desc          \\\\\n%%     \\DSigma{\\!}{\\!} & \\PI{\\V{S}}{\\Set} \\PIS{\\V{S} \\To \\Desc} \\Desc \\\\\n%%     \\DPi{\\!}{\\!}    & \\PI{\\V{S}}{\\Set} \\PIS{\\V{S} \\To \\Desc} \\Desc \n%% \\end{array}\n%% }\n%% \\vspace{0.2in}\n%% \\\\\n%% \\stk{\n%% \\descop{\\_\\:}{} : \\Desc \\To \\Set \\To \\Set \\\\\n%% \\begin{array}{@{}l@{\\:=\\:\\:}ll}\n%% \\descop{\\DId}{\\V{X}}          &  \\V{X}                                           \\\\\n%% \\descop{\\DConst{\\V{Z}}}{\\V{X}}    &  \\V{Z}                                           \\\\\n%% \\descop{\\DProd{\\V{D}}{\\V{D'}}}{\\V{X}} &  \\TIMES{\\descop{\\V{D}}{\\V{X}}}{\\descop{\\V{D}\\V{'}}{\\V{X}}}       \\\\\n%% \\descop{\\DSigma{\\V{S}}{\\V{D}}}{\\V{X}} &  \\SIGMA{\\V{s}}{\\V{S}} \\descop{\\V{D}\\: \\V{s}}{\\V{X}}          \\\\\n%% \\descop{\\DPi{\\V{S}}{\\V{D}}}{\\V{X}}    &  \\PI{\\V{s}}{\\V{S}} \\descop{\\V{D}\\: \\V{s}}{\\V{X}}            \n%% \\end{array}\n%% }\n%% \\end{array}\n%% }\\]\n\n%% \\caption{Universe of descriptions based on Type-formers}\n%% \\label{fig:type-former-desc}\n\n%% \\end{figure}\n\n\\subsection{The universe of indexed descriptions}\n\n\\begin{wstructure}\n<- Labelling Id\n    <- We had: data Desc : Set -> Set\n    -> We want: data IDesc : (I -> Set) -> Set\n        <- Indexed functor (?)\n        -> It is sufficient to label Id\n            <- Where the functor is built\n\\end{wstructure}\n\n\n\\newcommand{\\DotTo}{\\mathop{\\blue{\\dot{\\rightarrow}}}}\n\nWe presented the $\\Desc$ universe as a\ngrammar of strictly positive endofunctors on $\\Set$ and developed\ninductive types by taking a fixpoint. To describe inductive families\nindexed by some $\\Bhab{\\V{I}}{\\Set}$, we play a similar game with\nendofunctors on the category $\\Set^{\\V{I}}$,\nfamilies of sets \\(\\V{X},\\V{Y}:\\V{I}\\To\\Set\\) for objects, and for morphisms,\nfamilies of functions in \\(\\V{X}\\DotTo\\V{Y}\\), defined pointwise:\n\\[\n\\V{X}\\DotTo\\V{Y} \\mapsto \\PI{\\V{i}}{\\V{I}}\\V{X}\\:\\V{i}\\To\\V{Y}\\:\\V{i}\n\\]\n\nAn \\emph{indexed functor} in $\\Set^{\\V{I}}\\To\\Set^{\\V{J}}$ has the\nflavour of a device driver, characterising `responses' to a given\nrequest in \\(\\V{J}\\) where we may in turn make `subrequests' at indices\nchosen from \\(\\V{I}\\). When we use indexed functors to define inductive\nfamilies of datatypes,\n\\(\\V{I}\\) and \\(\\V{J}\\) coincide: we explain how to make a node fit a given\nindex, including subnodes at chosen indices. E.g., if we are asked for a\nvector of length 3, we choose to ask in turn for a tail of length 2.\n\nTo code up valid notions of response to a given request, we introduce\n$\\SYMBIDesc$ and its interpretation:\n%\n\\[\\stk{\n\\IDesc{(\\Bhab{\\V{I}}{\\Set})} : \\Set \\smallskip \\\\\n\\idescop{\\_}{}{} : _{\\PI{\\V{I}}{\\Set}} \\IDesc{\\V{I}} \\To (\\V{I} \\To \\Set) \\To \\Set    \\\\\n}\\]\n\nAn \\(\\IDesc{\\V{I}}\\) specifies just \\emph{one} response, but a\nrequest-to-response \\emph{function},\n$\\V{R}:\\V{I} \\To \\IDesc{\\V{I}}$, yields a strictly positive endofunctor\n\\[\n  \\LAM{\\V{X}} \\LAM{\\V{i}} \\idescop{\\V{R}\\:\\V{i}}{\\V{I}}{\\V{X}} :\n  \\Set^{\\V{I}} \\To \\Set^{\\V{I}}\n\\]\nwhose fixpoint we then take:\n%\n\\[\\stkl{\n\\Rule{\\Gamma \\vdash \\Bhab{\\V{I}}{\\Set} \\qquad\n      \\Gamma \\vdash \\Bhab{\\V{R}}{\\V{I} \\To \\IDesc{\\V{I}}}}\n     {\\Gamma \\vdash \\Bhab{\\SYMBIMu_{\\V{I}}{\\V{R}}}{\\V{I}\\To\\Set}} \\qquad\n\\\\\n\\Rule{\\begin{array}{l@{\\qquad}l}\n          \\Gamma \\vdash \\Bhab{\\V{I}}{\\Set} &\n          \\Gamma \\vdash \\Bhab{\\V{R}}{\\V{I} \\To \\IDesc{\\V{I}}} \\\\\n          \\Gamma \\vdash \\Bhab{\\V{i}}{\\V{I}} &\n          \\Gamma \\vdash \\Bhab{\\V{x}}{\\idescop{\\V{R}\\:\\V{i}}{\\V{I}}{(\\SYMBIMu_{\\V{I}}{\\V{R}})}}\n      \\end{array}}\n     {\\Gamma \\vdash \\Bhab{\\Con{\\V{x}}}{\\IMu{\\V{I}}{\\V{R}}{\\V{i}}}}\n}\\]\n\n\\newcommand{\\upgrade}{\\F{upgrade}}\n\\newcommand{\\inductionI}{\\F{indI}}\n\\newcommand{\\cataI}{\\F{cataI}}\n\nWe define the $\\SYMBIDesc$ grammar in Figure~\\ref{fig:idesc},\ndelivering only \\emph{strictly positive} families. As well as\nindexing our descriptions, we have refactored a little, adopting\na more compositional algebra of codes, where $\\Desc$ is\nbiased towards the right-nested tuples. We now have\n\\(\\DVar{i}\\) for recursive `subrequests' at a chosen index \\(i\\),\nwith tupling by right-associative\n\\(\\DProd{}{}\\) and higher-order branching\nby \\(\\DPi{\\!}{\\!}\\).  Upgrade your old $\\Desc$\nto a trivially indexed $\\IDesc{\\Unit}$ as follows!\n\\[\\begin{array}{@{}ll}\n\\upgrade :\\Desc & \\To\\IDesc{\\Unit} \\\\\n\\upgrade\\:\\DUnit & \\mapsto \\DConst{\\Unit} \\\\\n\\upgrade\\:(\\DSigma{\\V{S}}{\\V{D}}) &\n   \\mapsto \\DSigma{\\V{S}}{\\LAM{\\V{s}}\\upgrade\\:(\\V{D}\\:\\V{s})} \\\\\n\\upgrade\\:(\\DIndx{\\V{D}}) & \\mapsto\n  \\DProd{\\DVar{\\Void}}{\\upgrade\\:\\V{D}} \\\\\n\\upgrade\\:(\\DHindx{\\V{H}}{\\V{D}}) & \\mapsto\n  \\DProd{(\\DPi{\\V{H}}{\\LAM{\\_}\\DVar{\\Void}})}{\\upgrade\\:\\V{D}} \\\\\n\\end{array}\\]\n\nTo deliver induction for indexed datatypes, we need the `holds everywhere'\nmachinery. We present $\\SYMBAllI$ and $\\SYMBallI$ in\nFigure~\\ref{fig:allI-predicates}, with a twist---where\n$\\Desc$ admits the $\\SYMBall$ construction, $\\SYMBIDesc$ is \\emph{closed}\nunder it! The $\\SYMBAllI$\noperator for a description indexed on \\(\\V{I}\\) is strictly positive in\nturn, and has a description indexed on\n some \\(\\SIGMA{\\V{i}}{\\V{I}}{\\V{X}\\: \\V{i}}\\).\nInduction on indexed descriptions is then hardwired thus:\n%\n\\[\\stk{\n\\begin{array}{@{}ll}\n\\inductionI : & _{\\PI{\\V{I}}{\\Set}}\n                   \\PITEL{\\V{R}}{\\V{I} \\To \\IDesc{\\V{I}}}\n                   \\PI{\\V{P}}{(\\SIGMA{\\V{i}}{\\V{I}}{\\IMu{\\V{I}}{\\V{R}}{\\V{i}}}) \\To \\Set} \\\\\n                 & (      \\PITEL{\\V{i}}{\\V{I}} \n                          \\PI{\\V{xs}}{\\idescop{\\V{R}\\: \\V{i}}{\\V{I}}{(\\SYMBIMu_{\\V{I}}{\\V{R}})}} \\\\\n                 & \\   \\idescop{\\AllI{}\n                                     {(\\V{R}\\: \\V{i})}\n                                     {(\\SYMBIMu_{\\V{I}}{\\V{R}})}\n                                     {\\V{xs}}}\n                               {}\n                               {\\V{P}} \\To\n                       \\V{P}\\: \\pair{\\V{i}}{\\Con{\\V{xs}}}{}) \\To \\\\\n                 & \\PITEL{\\V{i}}{\\V{I}}\n                   \\PI{\\V{x}}{\\IMu{\\V{I}}{\\V{R}}{\\V{i}}}\n                   \\V{P}\\: \\pair{\\V{i}}{\\V{x}}{}\n\\end{array} \\\\\n\\inductionI\\: \\V{R}\\: \\V{P}\\: \\V{m}\\: \\V{i}\\: (\\Con{\\V{xs}}) \\mapsto \n    \\V{m}\\: \\V{i}\\: \\V{xs}\\: (\\allI{}\n                                    {\\V{R}\\: \\V{i}}\n                                    {(\\SYMBIMu_{\\V{I}}{\\V{R}})}\n                                    {\\V{P}}\n                                    {(\\spl{\\LAM{\\V{i}}\\LAM{\\V{xs}} \\inductionI\\: \\V{R}\\: \\V{P}\\: \\V{m}})}\n                                    {\\V{xs}})\n}\\]\n%\nThe generic catamorphism, $\\cataI$, is constructed from $\\inductionI$\nas before. Its type becomes more elaborated, to deal with the\nindexing:\n%\n\\[\n\\begin{array}{@{}l@{}l}\n\\cataI :& \\PITEL{\\V{I}}{\\Set}\n          \\PITEL{\\V{R}}{\\V{I} \\To \\IDesc{\\V{I}}} \\\\\n        & \\PI{\\V{T}}{\\V{I} \\To \\Set}\n          (\\PI{\\V{i}}{\\V{I}}{\\idescop{\\V{R}\\: \\V{i}}{}{\\V{T}} \\To \\V{T}\\: \\V{i}}) \\To\n          \\SYMBIMu_{\\V{I}}{\\V{R}} \\DotTo \\V{T}\n\\end{array}\n\\]\n\n\n\\begin{figure*}\n\n\\[\n\\begin{array}{ll}\n%%\n\\stk{\n\\begin{array}{@{}ll}\n\\SYMBAllI : & _{\\PI{\\V{I}}{\\Set}}\n              \\PITEL{\\V{D}}{\\IDesc{\\V{I}}}\n              \\PI{\\V{X}}{\\V{I} \\To \\Set} \\\\\n            & \\idescop{\\V{D}}{\\V{I}}{\\V{X}} \\To\n              \\IDesc{(\\SIGMA{\\V{i}}{\\V{I}}{\\V{X}\\: \\V{i}})}\n\\end{array} \\\\\n\\begin{array}{@{}l@{}l@{\\:\\mapsto\\:\\:}l}\n\\AllI{\\:}{(\\DVar{\\V{i}})}{& \\V{X}}{\\V{x}} &\n    \\DVar{\\pair{\\V{i}}{\\V{x}}{}} \\\\\n\\AllI{\\:}{(\\DConst{\\V{K}})}{& \\V{X}}{\\V{k}} &\n    \\DConst{\\Unit} \\\\\n\\AllI{\\:}{(\\DProd{\\V{D}}{\\V{D'}})}{& \\V{X}}{\\pair{\\V{d}}{\\V{d'}}{}} &\n    \\DProd{\\AllI{}{\\V{D}}{\\V{X}}{\\V{d}}}{\\AllI{}{\\V{D'}}{\\V{X}}{\\V{d'}}} \\\\\n\\AllI{\\:}{(\\DSigma{\\V{S}}{\\V{D}})}{& \\V{X}}{\\pair{\\V{s}}{\\V{d}}{}} &\n    \\AllI{}{(\\V{D}\\: \\V{s})}{\\V{X}}{\\V{d}} \\\\\n\\AllI{\\:}{(\\DPi{\\V{S}}{\\V{D}})}{& \\V{X}}{\\V{f}} &\n    \\DPi{\\V{S}}{\\LAM{\\V{s}} \\AllI{}{(\\V{D}\\: \\V{s})}{\\V{X}}{(\\V{f}\\: \\V{s})}}\n\\end{array}\n}\n&\n%%\n\\stk{\n\\begin{array}{@{}ll}\n\\SYMBallI : & _{\\PI{\\V{I}}{\\Set}}\n              \\PITEL{\\V{D}}{\\IDesc{\\V{I}}}\n              \\PITEL{\\V{X}}{\\V{I} \\To \\Set} \n              \\PI{\\V{P}}{(\\SIGMA{\\V{i}}{\\V{I}}{\\V{X}\\: \\V{i}}) \\To \\Set} \\\\\n            & (\\PI{\\V{x}}{\\SIGMA{\\V{i}}{\\V{I}}{\\V{X}\\: \\V{i}}} \\V{P}\\: \\V{x}) \\To\n              \\PI{\\V{xs}}{\\idescop{\\V{D}}{\\V{I}}{\\V{X}}} \n              \\idescop{\\AllI{}{\\V{D}}{\\V{X}}{\\V{xs}}}{}{\\V{P}}\n\\end{array} \\\\\n\\begin{array}{@{}l@{}l@{\\:\\mapsto\\:\\:}l}\n\\allI{\\:}{(\\DVar{\\V{i}})}{& \\V{X}}{\\V{P}}{\\V{p}}{\\V{x}} &\n    \\V{p}\\: \\pair{\\V{i}}{\\V{x}}{} \\\\\n\\allI{\\:}{(\\DConst{\\V{K}})}{& \\V{X}}{\\V{P}}{\\V{p}}{\\V{k}} &\n    \\void \\\\\n\\allI{\\:}{(\\DProd{\\V{D}}{\\V{D'}})}{& \\V{X}}{\\V{P}}{\\V{p}}{\\pair{\\V{d}}{\\V{d'}}{}} &\n    \\pair{\\allI{}{\\V{D}}{\\V{X}}{\\V{P}}{\\V{p}}{\\V{d}}}\n         {\\allI{}{\\V{D'}}{\\V{X}}{\\V{P}}{\\V{p}}{\\V{d'}}}{} \\\\\n\\allI{\\:}{(\\DSigma{\\V{S}}{\\V{D}})}{& \\V{X}}{\\V{P}}{\\V{p}}{\\pair{\\V{s}}{\\V{d}}{}} &\n    \\allI{}{(\\V{D}\\: \\V{s})}{\\V{X}}{\\V{P}}{\\V{p}}{\\V{d}} \\\\\n\\allI{\\:}{(\\DPi{\\V{S}}{\\V{D}})}{& \\V{X}}{\\V{P}}{\\V{p}}{\\V{f}} &\n    \\LAM{\\V{a}}\\allI{}{(\\V{D}\\: \\V{a})}{\\V{X}}{\\V{P}}{\\V{p}}{(\\V{f}\\: \\V{a})}\n\\end{array}\n\\end{array}\n}\n\\]\n\n\\caption{Indexed induction predicates}\n\\label{fig:allI-predicates}\n\n\\end{figure*}\n\n\n\\begin{figure}\n\n\\[\\stk{\\begin{array}{@{}ll}\n\\IDesc{(\\Bhab{\\V{I}}{\\Set})} &: \\Set \\\\\n\\DVar{(\\Bhab{\\V{i}}{\\V{I}})} &: \\IDesc{\\V{I}} \\\\\n\\DConst{(\\Bhab{\\V{A}}{\\Set})} &:\\IDesc{\\V{I}}       \\\\\n\\DProd{(\\Bhab{\\V{D}}{\\IDesc{\\V{I}}})}{(\\Bhab{\\V{D}}{\\IDesc{\\V{I}}})}\n  & :\\IDesc{\\V{I}}       \\\\\n\\DSigma{(\\Bhab{\\V{S}}{\\Set})}{(\\Bhab{\\V{D}}{\\V{S}\\To\\IDesc{\\V{I}}})}\n& : \\IDesc{\\V{I}}  \\\\\n\\DPi{(\\Bhab{\\V{S}}{\\Set})}{(\\Bhab{\\V{D}}{\\V{S}\\To\\IDesc{\\V{I}}})}\n& : \\IDesc{\\V{I}}  \\\\\n\\end{array}\\smallskip \\\\\n\\idescop{\\_\\:}{}{} :_{\\PI{\\V{I}}{\\Set}} \\IDesc{\\V{I}} \\To (\\V{\\V{I}} \\To \\Set) \\To \\Set                  \\\\\n\\begin{array}{@{}l@{\\V{X}}@{\\:\\mapsto\\:\\:}ll}\n\\idescop{\\DVar{\\V{i}}}{\\V{I}}{&}      &  \\V{X}\\: \\V{i}                                           \\\\\n\\idescop{\\DConst{\\V{K}}}{\\V{I}}{&}    &  \\V{K}                                                   \\\\\n\\idescop{\\DProd{\\V{D}}{\\V{D'}}}{\\V{I}}{&} &  \\TIMES{\\idescop{\\V{D}}{\\V{I}}{\\V{X}}}{\\idescop{\\V{D'}}{\\V{I}}{\\V{X}}}       \\\\\n\\idescop{\\DSigma{\\V{S}}{\\V{D}}}{\\V{I}}{&} &  \\SIGMA{\\V{s}}{\\V{S}} \\idescop{\\V{D}\\: \\V{s}}{\\V{I}}{\\V{X}}                    \\\\\n\\idescop{\\DPi{\\V{S}}{\\V{D}}}{\\V{I}}{&}    &  \\PI{\\V{s}}{\\V{S}} \\idescop{\\V{D}\\: \\V{s}}{\\V{I}}{\\V{X}}            \n\\end{array}\n}\n\\]\n\n\\caption{Universe of indexed descriptions}\n\\label{fig:idesc}\n\n\\end{figure}\n\n\n\n\\subsection{Examples}\n\\label{sec:idesc-examples}\n\n\\paragraph{Natural numbers:}\n\n\\begin{wstructure}\n<- Nat\n    -> [equation]\n    <- Non-indexed types lives in IDesc 1\n        -> This applies to all previous examples\n\\end{wstructure}\n\nFor basic reassurance, we \\(\\upgrade\\:\\NatD\\):\n%\n\\[\\stk{\n\\upgrade\\:\\NatD : \\IDesc{\\Unit} \\\\\n\\upgrade\\:\\NatD \\mapsto \\DSigma{(\\EnumT{\\sqr{\\NatZero\\: \\SYMBNatSuc}})}\n                     {\\sqr{(\\DConst{\\Unit}) \\; \n                           (\\DProd{\\DVar{\\Void}}{\\DConst{\\Unit}})}}\n}\\]\n%\nNote that trailing \\(\\Unit\\)'s keep our right-nested, \\(\\void\\)-terminated\ntuple structure, and with it our elaboration machinery.\nWe can similarly \\(\\upgrade\\) any inductive type.\nMoreover, \\(\\IDesc{I}\\) can now code a bunch of mutually\ninductive types, if \\(I\\) enumerates the\nbunch~\\cite{paulin:habilitation, yakushev:mutual-def}.\n\n\n\n\\paragraph{Indexed descriptions:}\n\n\\begin{wstructure}\n<- Levitation [figure]\n    <- Following Desc encoding\n        /> Note: simple datatype\n            -> Live in IDesc 1\n    -> Behind the scene, relies on the special purpose switchD\n\\end{wstructure}\n\nNote that $\\IDesc{\\V{I}}$ is a plain inductive type, parametrised\nby \\(\\V{I}\\), but indexed trivially.\n%\n\\[\\stk{\n\\IDescD : \\PI{\\V{I}}{\\Set} \\IDesc{\\Unit} \\\\\n\\IDescD\\: \\V{I} \\mapsto \\SYMBDSigma \\\\\n\\quad\n \\EnumT\\vtup{r}{\\SYMBDVar\\\\\n                \\SYMBDConst\\\\\n                \\DProd{}{}\\\\\n                \\SYMBDSigma\\\\\n                \\SYMBDPi}\n         \\; \\vtup{l@{}l}{\n  (\\DProd{\\DConst{\\V{I}} &}{\\DConst{\\Unit}})                  \\\\\n  (\\DProd{\\DConst{\\Set}  &}{\\DConst{\\Unit}})                  \\\\\n  (\\DProd{\\DVar{\\Void}}{\\DProd{\\DVar{\\Void}&}{\\DConst{\\Unit}}})  \\\\\n  (\\DSigma{\\Set}{\\LAM{\\V{S}}\n     \\DProd{( \\DPi{\\V{S}}{\\LAM{\\_} \\DVar{\\Void}}) &}{\\DConst{\\Unit}}})     \\\\\n  (\\DSigma{\\Set}{\\LAM{\\V{S}}\n     \\DProd{( \\DPi{\\V{S}}{\\LAM{\\_} \\DVar{\\Void}}) &}{\\DConst{\\Unit}}})     \\\\\n                                   }\n}\\]\n\nTherefore, this universe is self-describing and can be\nlevitated. As before, we rely on a special purpose $\\F{switchID}$\noperator to build the finite function $\\bigRedBracket{\\ldots}$\nwithout mentioning \\(\\SYMBIDesc\\).\n\n\\paragraph{Vectors:}\n\n\\newcommand{\\VecD}{\\F{VecD}}\n\\newcommand{\\VecNil}{\\etag{\\CN{vnil}}}\n\\newcommand{\\SYMBVecCons}{\\etag{\\CN{vcons}}\\xspace}\n\\newcommand{\\VecCons}[2]{\\SYMBVecCons\\:#1\\:#2}\n\nSo far, our examples live in $\\IDesc{\\Unit}$, with no interesting\nindexing. Let us at least have vectors. Recall\nthat the constructors $\\VecNil$ and $\\SYMBVecCons$ are defined only for\n$\\NatZero$ and $\\NatSuc$ respectively:\n%\n\\[\n\\stk{\n\\data \\D{Vec}\\: \\PITEL{\\V{X}}{\\Set} : \\PI{\\V{i}}{\\Nat} \\Set \\where \\\\\n\\;\\;\\begin{array}{@{}l@{\\::\\:\\:}l@{\\quad}l}\n    \\VecNil          & \\D{Vec}\\:\\V{X}\\:{\\NatZero}   \\\\\n    \\SYMBVecCons & _{\\PI{\\V{n}}{\\Nat}}\\V{X} \\To \\D{Vec}\\:{\\V{X}}\\:{\\V{n}} \\To \\D{Vec}\\:{\\V{X}}\\:{(\\NatSuc{\\V{n}})}\n\\end{array}\n}\n\\]\n\nOne way to code constrained datatypes is to appeal to a suitable\nnotion of propositional equality \\(\\PropEq\\) on indices. The\nconstraints are expressed as `Henry Ford' equations in the datatype.\nFor vectors:\n%\n\\[\\stk{\n\\VecD : \\Set \\To \\Nat \\To \\IDesc{\\Nat} \\\\\n\\VecD\\: \\V{X}\\: \\V{i} \\mapsto \\SYMBDSigma\\\\\n\\quad\n\\EnumT{\\vtup{r}{\\VecNil\\\\ \\SYMBVecCons}}\n\\; \\vtup{r}{\n                            (\\DConst{(\\NatZero\\PropEq\\V{i})}) \\\\\n ( \\DSigma{\\Nat}{\\LAM{\\V{n}}\n   \\DProd{\\DConst{\\V{X}}}\n     {\\DProd{\\DVar{\\V{n}}}{\\DConst{(\\NatSuc{\\V{n}}\\PropEq\\V{i})}})}}\n                          }\n}\\]\n\nYou may choose $\\VecNil$ for any index you like as long as it is\n$\\NatZero$; in the $\\SYMBVecCons$ case, the length of the tail is\ngiven explicitly, and the index $\\V{i}$ must be one more. Our previous\n\\(\\Unit\\)-terminated tuple types can now be seen as the trivial case\nof constraint-terminated tuple types, with elaboration supplying the\nwitnesses when trivial.\n\nIn this paper, we remain anxiously agnostic about\npropositional equality. Any will do, according to\nconviction; many variations are popular. The\nhomogeneous identity type used in Coq is ill-suited to\ndependent types, but its heterogeneous variant (forming equations\nregardless of type) allows the translation of pattern\nmatching with structural recursion to\n\\(\\F{indI}\\)~\\cite{goguen:pattern-matching}. The\nextensional equality of \\citet{altenkirch:ott} also sustains the translation.\n\n\\begin{wstructure}\n!!! Need Help !!!\n<- Brady optimisation: forcing\n    <- Source to source translation\n    <- Able to remove some constraints\n    -> Example: Fin [figure]\n    ??? More technical detail needed\n\\end{wstructure}\n\nHowever, sometimes, the equations are redundant. \nLooking back at $\\D{Vec}$, we find that the equations constrain\nthe choice of constructor and stored tail index retrospectively.\nBut \\emph{inductive families need not store their\n  indices}~\\cite{brady:index-inductive-families}!  If we\nanalyse the incoming index, we can tidy our description of $\\D{Vec}$\nas follows:\n%\n\\[\\stk{\n\\VecD \\:\\PITEL{\\V{X}}{\\Set} : \\Nat \\To \\IDesc{\\Nat} \\\\\n\\begin{array}{@{}lll}\n\\VecD\\:\\V{X}\\: \\NatZero     & \\mapsto & \\DConst{\\Unit} \\\\\n\\VecD\\:\\V{X}\\: (\\NatSuc{\\V{n}}) & \\mapsto &\n \\DProd{\\DConst{\\V{X}}}{\\DVar{\\V{n}}}\n\\end{array}\n                                       \n}\\]\n%\nThe constructors and equations have simply disappeared. A similar\nexample is $\\SYMBFin$ (bounded numbers), specified by:\n%\n\\[\n\\stk{\n\\data \\SYMBFin : \\PI{\\V{n}}{\\Nat} \\Set \\where \\\\\n\\;\\;\\begin{array}{@{}l@{\\::\\:\\:}l@{\\quad}l}\n    \\FinZero      & _{\\PI{\\V{n}}{\\Nat}}\\Fin{(\\NatSuc{\\V{n}})}   \\\\\n    \\SYMBFinSuc   & _{\\PI{\\V{n}}{\\Nat}}\\Fin{\\V{n}} \\To \\Fin{(\\NatSuc{\\V{n}})}\n\\end{array}\n}\\]\n%\nIn this case, we can eliminate equations but not constructors, since both\n$\\FinZero$ and $\\SYMBFinSuc$ both target $\\SYMBNatSuc$:\n%\n\\[\\stk{\n\\FinD : \\Nat \\To \\IDesc{\\Nat} \\\\\n\\begin{array}{@{}lll}\n\\FinD\\: \\NatZero         & \\mapsto & \\DSigma{\\EnumT{\\Void}}{\\Void} \\\\\n\\FinD\\: (\\NatSuc{\\V{n}}) & \\mapsto & \\DSigma{\\EnumT{\\sqr{\\FinZero\\: \\SYMBFinSuc}}}\n                                            {\\sqr{(\\DConst{\\Unit})\\: (\\DVar{\\V{n}})}}\n\\end{array}\n}\\]\n\nThis technique of extracting information by case analysis on indices\napplies to descriptions exactly where Brady's `forcing' and\n`detagging' optimisations apply in compilation. They eliminate just\nthose constructors, indices and constraints which are redundant even\nin \\emph{open} computation. In \\emph{closed} computation, where proofs\ncan be trusted, all constraints are dropped.\n\n\n\\paragraph{Tagged indexed descriptions:}\n\n\\newcommand{\\SYMBmuide}{\\D{\\({\\mu}^{\\!+}\\)}\\xspace}\n\\newcommand{\\muide}[2]{\\SYMBmuide\\!\\!_{#1}\\:#2}\n\nLet us reflect this index analysis technique.\nWe can divide a description of tagged indexed data in two: first, the\nconstructors that do not depend on the index; then, the constructors\nthat do. The non-dependent part mirrors the definition for non-indexed\ndescriptions. The index-dependent part simply indexes the choice of\nconstructors by $\\V{I}$. Hence, by inspecting the index, it is\npossible to vary the `menu' of constructors.\n%\n\\[\n\\begin{array}{@{}l@{\\:\\mapsto\\:\\:}l}\n \\TagIDesc{\\V{I}}  & \\TIMES{\\ATagIDesc{\\V{I}}}{\\ITagIDesc{\\V{I}}} \\\\\n \\ATagIDesc{\\V{I}} & \\SIGMA{\\V{E}}{\\EnumU} \\PI{\\V{i}}{\\V{I}} \\spi{\\V{E}}{\\LAM{\\_} \\IDesc{\\V{I}}} \\\\\n \\ITagIDesc{\\V{I}} & \n     \\SIGMA{\\V{F}}{\\V{I} \\To \\EnumU} \\PI{\\V{i}}{\\V{I}} \\spi{(\\V{F}\\: \\V{i})}{\\LAM{\\_} \\IDesc{\\V{I}}} \n\\end{array}\n\\]\n\n\\begin{wstructure}\n<- Vectors\n    Do we treat them in the end? \n    What can we say here we haven't with Fin?\n\\end{wstructure}\n\nIn the case of a tagged $\\D{Vec}$, for instance, for the index\n$\\NatZero$, we would only propose the constructor\n$\\ListNil$. Similarly, for $\\NatSuc{n}$, we would only propose the\nconstructor $\\SYMBListCons$.\n\nWe write $\\toIDesc{\\V{D}}\\:\\V{i}$ to denote the $\\IDesc{\\V{I}}$\ncomputed from the tagged indexed description $\\V{D}$ at index\n$\\V{i}$. Its expansion is similar to the definition of \\(\\SYMBtoDesc\\)\nfor tagged descriptions, except that it must also append the two parts.\nWe again write $\\muide{\\V{I}}{\\V{D}}$ for\n$\\IMu{\\V{I}}{(\\toIDesc{\\V{D}})}$.\n\n\\paragraph{Typed expressions:}\n\n\\begin{wstructure}\n<- Hutton's razor\n    <- Types\n        <- 'Nat\n        <- 'Bool\n    <- Term [figure]\n        <- val : Val 'a -> 'a  for Val : Ty -> Set, mapping to Nat and Bool\n        <- cond : 'Bool -> a -> a -> a\n        <- plus : 'Nat -> 'Nat -> 'Nat\n        <- le : 'Nat -> 'Nat -> 'Bool\n\\end{wstructure}\n\n%% Types\n\\newcommand{\\Ty}{\\D{Ty}}\n\\newcommand{\\Ebool}{\\etag{\\CN{bool}}}\n\\newcommand{\\Enat}{\\etag{\\CN{nat}}}\n\n%% Constructors\n\\newcommand{\\SYMBEval}{\\etag{\\CN{val}}\\xspace}\n\\newcommand{\\SYMBEvar}{\\etag{\\CN{var}}\\xspace}\n\\newcommand{\\Eval}[1]{\\SYMBEval\\:#1}\n\\newcommand{\\SYMBEcond}{\\etag{\\CN{cond}}\\xspace}\n\\newcommand{\\Econd}[3]{\\SYMBEcond\\:#1\\:#2\\:#3}\n\\newcommand{\\SYMBEplus}{\\etag{\\CN{plus}}\\xspace}\n\\newcommand{\\Eplus}[2]{\\SYMBEplus\\:#1\\:#2}\n\\newcommand{\\SYMBEle}{\\etag{\\CN{le}}\\xspace}\n\\newcommand{\\Ele}[2]{\\SYMBEle\\:#1\\:#2}\n\n%% Index mapper (terminology?)\n\\newcommand{\\SYMBVal}{\\F{Val}\\xspace}\n\\newcommand{\\Val}[1]{\\SYMBVal\\:#1}\n\\newcommand{\\SYMBVar}{\\F{Var}\\xspace}\n\\newcommand{\\Var}[2]{\\SYMBVar\\: #1\\: #2}\n\n%% Hutton expressions\n\\newcommand{\\HExprD}{\\F{ExprD}}\n\\newcommand{\\HExprAD}{\\F{ExprAD}}\n\\newcommand{\\HExprID}{\\F{ExprID}}\n\\newcommand{\\HExprVarD}[1]{\\C{ExprD}_{\\F{Var},#1}}\n\\newcommand{\\HExprFreeD}{\\C{ExprD}^{\\C{Free}}}\n\\newcommand{\\HExprAFreeD}{\\C{ExprAD}^{\\C{Free}}}\n\nWe are going to define a syntax for a small language with\ntwo types, natural numbers and booleans:\n%\n\\[\n\\Ty \\mapsto \\EnumT{\\sqr{\\Enat\\: \\Ebool}}\n\\]\n\n\\newcommand{\\plusHost}{\\mathop{\\green{+_{\\mathrm{H}}}}}\n\\newcommand{\\leHost}{\\mathop{\\green{\\leq_{\\mathrm{H}}}}}\n\n\nThis language has values, conditional expression, addition and\ncomparison. Informally, their types are:\n%\n\\[\n\\begin{array}{l@{\\::\\:\\:}l}\n\\SYMBEval            & \\Val{\\V{ty}} \\To \\V{ty} \\\\\n\\SYMBEcond           & \\Ebool \\To \\V{ty} \\To \\V{ty} \\To \\V{ty}  \\\\ \n\\end{array}\n\\qquad\n\\begin{array}{l@{\\::\\:\\:}l}\n\\SYMBEplus           & \\Enat \\To \\Enat \\To \\Enat                           \\\\\n\\SYMBEle             & \\Enat \\To \\Enat \\To \\Ebool                          \\\\\n\\end{array}\n\\]\n%\nThe function $\\SYMBVal$ interprets object language types in the\nhost language, so that arguments to $\\SYMBEval$ fit their\nexpected type.\n%\n\\[\\stk{\n\\SYMBVal : \\Ty \\To \\Set \\\\\n\\begin{array}{@{}l@{\\:\\mapsto\\:\\:}l}\n\\Val{\\Enat}   & \\Nat \\\\\n\\Val{\\Ebool}  & \\Bool\n\\end{array}\n}\\]\n%\nWe take $\\Nat$ and $\\Bool$ to represent natural numbers and Booleans\nin the host language, equipped with addition $\\plusHost$ and\ncomparison $\\leHost$.\n\nWe express our syntax as a tagged indexed description, indexing over\nobject language types $\\Ty$. We note that some constructors are always\navailable, namely $\\SYMBEval$ and $\\SYMBEcond$. On the other hand,\n$\\SYMBEplus$ and $\\SYMBEle$ constructors are index-dependent, with\n$\\SYMBEplus$ available just when building a $\\Enat$, $\\SYMBEle$ just\nfor $\\Ebool$. The code, below, reflects this intuition, with the first\ncomponent uniformly offering $\\SYMBEval$ and $\\SYMBEcond$, the second\nselectively offering $\\SYMBEplus$ or $\\SYMBEle$.\n%\n%%% \\begin{figure}\n%\n\\[\\stk{\n\\stk{\n\\HExprD : \\TagIDesc{\\Ty} \\\\\n\\HExprD \\mapsto \\sqr{ \\HExprAD , \\HExprID } \\\\\n} \\smallskip\\\\\n\\stk{\n\\HExprAD : \\ATagIDesc{\\Ty} \\\\\n\\HExprAD \\mapsto \\vtup{l}{\n   {\\vtup{r}{\\SYMBEval\\\\ \\SYMBEcond \\,}} \\red{,} \\;\n      \\LAM{\\V{ty}}\n      \\vtup{l@{\\:}l}{\n      \\DProd{\\DConst{(\\Val{\\V{ty}})}&}{\\DConst{\\Unit}} \\\\\n      \\DProd{\\DProd{\\DVar{\\Ebool}}{\\DProd{\\DVar{\\V{ty}}}{\\DVar{\\V{ty}}}}&}\n        {\\DConst{\\Unit}} \\\\\n     }\n   }\n\\smallskip\\\\\n} \n\\\\\n\\stk{\n\\HExprID : \\ITagIDesc{\\Ty} \\\\\n\\HExprID \\mapsto \\vtup{l}{\n                   \\vtup{r}{\\sqr{\\SYMBEplus} \\\\ \\sqr{\\SYMBEle}} \\red{,} \\;\n  \\LAM{\\_} \\sqr{\\DProd{\\DProd{\\DVar{\\Enat}}{\\DVar{\\Enat}}}{\\DConst{\\Unit}}}\n                   }\n}\n}\\]\n\n%%%\\caption{Syntax of typed expressions}\n%%%\\label{fig:hexpr-full}\n\n%%%\\end{figure}\n\n\\newcommand{\\evalH}{\\F{eval}_{\\green{\\Downarrow}}}\n\\newcommand{\\evalOne}{\\F{eval}_{\\green{\\downarrow}}}\n\nGiven the syntax, let us supply the semantics. We implement an\nevaluator as a catamorphism:\n%\n\\[\\stk{\n\\evalH : \\PI{\\V{ty}}{\\Ty} \n         \\muide{\\Ty}{\\HExprD}\\: \\V{ty} \\To\n         \\Val{\\V{ty}} \\\\\n\\evalH\\: \\V{ty}\\: \\V{term} \\mapsto \\cataI_{\\Ty} \\:\n                                 (\\toIDesc{\\HExprD})\\: \n                                 \\SYMBVal\\: \n                                 \\evalOne\\: \n                                 \\V{ty}\\: \n                                 \\V{term}\n}\\]\n%\nTo finish the job, we must supply the algebra which implements a single\nstep of evaluation, given subexpressions evaluated already.\n%\n\\[\\stk{\n\\evalOne : \\PI{\\V{ty}}{\\Ty}\n \\idescop{(\\toIDesc{\\HExprD})\\:\\V{ty}}{\\Ty}{\\SYMBVal}\n           \\To {\\Val{\\V{ty}}} \\\\\n\\begin{array}{@{}l@{}c@{}l@{\\:\\mapsto\\:\\:}l}\n\\evalOne\\: & \\_\\: & (\\SYMBEval\\;\\V{x})                                            & \\V{x} \\\\\n\\evalOne\\: & \\_\\: & (\\SYMBEcond\\:\\BoolTrue\\:\\V{x}\\:\\_)   & \\V{x} \\\\\n\\evalOne\\: & \\_\\: & (\\SYMBEcond\\:\\BoolFalse\\:\\_\\:\\V{y})  & \\V{y} \\\\\n\\evalOne\\: & \\Enat\\: & (\\SYMBEplus\\:\\V{x}\\:\\V{y})   & \\V{x} \\plusHost \\V{y} \\\\\n\\evalOne\\: & \\Ebool\\: & (\\SYMBEle\\:\\V{x}\\:\\V{y})  & \\V{x} \\leHost \\V{y} \n\\end{array}\n}\\]\n\n\\begin{wstructure}\n    /> Closed term\n        <- only constants and operations on them\n        -> Extend Val with Var : Ty -> Set, mapping to EnumU\n            -> Open term\n            -> Language of well-typed terms\n                <- By construction\n\\end{wstructure}\n\nHence, we have a type-safe syntax and a tagless interpreter for our\nlanguage, in the spirit\nof~\\citet{augustsson.carlsson:dependent.interpreter}, with help from\nthe generic catamorphism. However, so far, we are only able to define\nand manipulate \\emph{closed} terms. Adding variables, it is possible\nto build and manipulate \\emph{open} terms, that is, terms in a\ncontext. We shall get this representation, for free, thanks to the\n\\emph{free indexed monad} construction.\n\n\n\\subsection{Free indexed monad}\n\n\\begin{wstructure}\n<- Variation on a theme: free imonad construction\n    <- Recall existence of generic free monad construction\n    -> Present its generalisation to IDesc [equation]\n        <- \\I -> IDesc I as describing an indexed endofunctor\n        <- Free monad construction\n    -> Still a suitable, generic notion of substitution\n        <- show type signature\n        <- show implementation?? (space! space!)\n\\end{wstructure}\n\nIn Section~\\ref{sec:desc-free-monad}, we have built a free monad\noperation for simple descriptions. The process is similar in the\nindexed world. Namely, given an indexed functor, we derive the indexed\nfunctor coding its free monad: \\note{pwm: Whoa there. Maybe we should\n  say something about IMonads in general before we get to this point?}\n%\n\\[\\stk{\n\\begin{array}{ll}\n\\FreeIMonad{\\_}{} : & _{\\PI{\\V{I}}{\\Set}}\n                     \\PITEL{\\V{R}}{\\TagIDesc{\\V{I}}} \n                     \\PITEL{\\V{X}}{\\V{I} \\To \\Set}\\To \n                      \\TagIDesc{\\V{I}}\n\\end{array} \\\\\n\\FreeIMonad{\\pair{\\V{E}}{\\V{F}}{}}{\\V{I}}{\\V{R}} \\mapsto\n    \\pair{\\pair{\\ListCons{\\SYMBDVar}{(\\fst{\\V{E}})}} \n               {\\LAM{\\V{i}}\n                \\pair{\\DConst{(\\V{R}\\: \\V{i})}}\n                     {(\\snd{\\V{E}})\\: \\V{i}}{}}{}}\n         {\\V{F}}{}\n}\\]\n\n\n\\newcommand{\\substI}{\\F{substI}}\n\n\nJust as in the universe of descriptions, this construction comes with\nan obvious \\return and a substitution operation, the \\bind. Its\ndefinition is the following:\n%\n\\[\\stk{\n\\begin{array}{@{}ll}\n\\substI : & _{\\PI{\\V{I}}{\\Set}}\n            \\PI{\\V{X}, \\V{Y}}{\\V{I} \\To \\Set}\n            \\PITEL{\\V{R}}{\\TagIDesc{\\V{I}}} \\\\\n          & (\\V{X} \\DotTo \n             \\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{Y}})}) \\To \n             \\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{X}})} \\DotTo\n             \\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{Y}})}\n\\end{array} \\\\\n\\substI\\: \\V{X}\\: \\V{Y}\\: \\V{R}\\: \\V{\\sigma}\\: \\V{i}\\: \\V{t} \\mapsto \\\\\n\\qquad    \\cataI_{\\V{I}}\\: (\\toIDesc{\\FreeIMonad{\\V{R}}{}{\\V{X}}})\\:\n                      (\\muide{\\V{Y}}{(\\FreeIMonad{\\V{R}}{}{\\V{Y}})})\\:\n                      (\\F{applyI}\\: \\V{R}\\: \\V{X}\\: \\V{Y}\\: \\V{\\sigma})\\:\n                      \\V{i}\\:\n                      \\V{t} \n}\\]\n% \nwhere  $\\F{applyI}$ is defined as follows:\n%\n\\[\\stk{\n\\begin{array}{@{}ll}\n\\F{applyI} : & _{\\PI{\\V{I}}{\\Set}}\n            \\PITEL{\\V{R}}{\\TagIDesc{\\V{I}}}\n            \\PI{\\V{X}, \\V{Y}}{\\V{I} \\To \\Set} \\\\\n          & (\\V{X} \\DotTo \\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{Y}})}{}) \\To \\\\\n          & \\idescop{\\toIDesc{\\FreeIMonad{\\V{R}}\n                                         {\\V{I}}\n                                         {\\V{X}}}}\n                    {\\V{I}}\n                    {\\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{Y}})}} \\DotTo \n            \\muide{\\V{I}}{(\\FreeIMonad{\\V{R}}{\\V{I}}{\\V{Y}})}{}\n\\end{array} \\\\\n\\begin{array}{@{}l@{\\:\\mapsto\\:\\:}l}\n\\F{applyI}\\: \\V{R}\\: \\V{X}\\: \\V{Y}\\: \\V{\\sigma}\\: \\V{i}\\: \\pair{\\SYMBDVar}{\\V{x}}{}   & \\V{\\sigma}\\: \\V{i}\\: \\V{x}                   \\\\\n\\F{applyI}\\: \\V{R}\\: \\V{X}\\: \\V{Y}\\: \\V{\\sigma}\\: \\V{i}\\: \\pair{\\V{c}}{\\V{ys}}{} & \\Con{\\pair{\\V{c}}{\\V{ys}}{}}\n\\end{array}\n}\\]\n \nThe subscripted types corresponds to implicit arguments that can be\nautomatically inferred, hence do not have to be typed in. Let us now\nconsider two examples of free indexed monads.\n\n\n\\paragraph{Typed expressions:}\n\n\\begin{wstructure}\n    /> Closed term\n        <- only constants and operations on them\n        -> Extend Val with Var : Ty -> Set, mapping to EnumU\n            -> Open term\n            -> Language of well-typed terms\n                <- By construction\n\\end{wstructure}\n\n\\newcommand{\\Ctxt}{\\D{Context}}\n\\newcommand{\\SYMBCtxtEmpty}{\\C{[]}\\xspace}\n\\newcommand{\\CtxtEmpty}{\\SYMBCtxtEmpty}\n\\newcommand{\\SYMBCtxtSnoc}{\\C{snoc}\\xspace}\n\\newcommand{\\CtxtSnoc}[2]{\\SYMBCtxtSnoc\\:#1\\:#2}\n\\newcommand{\\SYMBEnv}{\\F{Env}}\n\\newcommand{\\Env}[1]{\\SYMBEnv\\: #1}\n\\newcommand{\\SYMBlookup}{\\F{lookup}}\n\\newcommand{\\lookup}[4]{\\SYMBlookup\\: #1\\: #2\\: #3\\: #4}\n\nIn the previous section, we presented a language of closed\narithmetic expressions. Using the free monad construction, we are\ngoing to extend this construction to open terms. An open term is\ndefined with respect to a context, represented by a snoc-list of\ntypes:\n%\n\\[\n\\begin{array}{@{}l@{\\::\\:\\:}l@{\\quad}l}\n\\Ctxt           & \\Set \\\\\n\\SYMBCtxtEmpty  & \\Ctxt \\\\\n\\SYMBCtxtSnoc   & \\Ctxt \\To \\Ty \\To \\Ctxt\n\\end{array}\n\\]\n%\nAn environment realises the context, packing a value for each type:\n%\n\\[\n\\stk{\n\\SYMBEnv : \\Ctxt \\To \\Set \\\\\n\\begin{array}{@{}l@{\\:\\:\\mapsto\\:\\:}l}\n\\Env{\\CtxtEmpty}                & \\Unit \\\\\n\\Env{(\\CtxtSnoc{\\V{G}}{\\V{S}})} & \\TIMES{\\Env{\\V{G}}}{\\Val{\\V{S}}}\n\\end{array}\n}\\]\n%\nIn this setting, we define type variables, $\\SYMBVar$ by:\n%\n\\[\\stk{\n\\Var{}{} : \\Ctxt \\To \\Ty \\To \\Set \\\\\n\\begin{array}{@{}ll@{\\:\\:\\mapsto\\:\\:}l}\n\\Var{\\CtxtEmpty}{& \\V{T}}                & \n    \\Void \\\\\n\\Var{(\\CtxtSnoc{\\V{G}}{\\V{S}})}{& \\V{T}} & \n    \\SUM{(\\Var{\\V{G}}{\\V{T}})}{(\\V{S} \\PropEq \\V{T})}\n\\end{array}\n}\\]\n%\nWhile $\\SYMBVal$ maps the type to the corresponding host type,\n$\\SYMBVar$ indexes a value in the context, obtaining a proof that the\ntypes match. The $\\SYMBlookup$ function precisely follow this\nsemantics:\n%\n\\[\\stk{\n\\SYMBlookup : \\PI{\\V{G}}{\\Ctxt} \n          \\Env{\\V{G}} \\To \n          \\PI{\\V{T}}{\\Ty} \n          \\Var{\\V{G}}{\\V{T}} \\To\n          \\Val{\\V{T}} \\\\\n\\begin{array}{@{}l@{}l@{}l@{}l@{}lll}\n\\lookup{& (\\CtxtSnoc{\\V{G}}{.T})}{& \\pair{\\V{g}}{\\V{t}}{}}{& \\V{T}}{& (\\SumRight{\\C{refl}})} & \\mapsto & \\V{t} \\\\\n\\lookup{& (\\CtxtSnoc{\\V{G}}{\\V{S}})}{& \\pair{\\V{g}}{\\V{t}}{}}{& \\V{T}}{& (\\SumLeft{\\V{x}})} & \\mapsto & \\lookup{\\V{G}}{\\V{g}}{\\V{T}}{\\V{x}} \n\\end{array}\n}\\]\n\n\\newcommand{\\SYMBEmpty}{\\F{Empty}\\xspace}\n\\newcommand{\\Empty}[1]{\\SYMBEmpty\\:#1}\n\n\\newcommand{\\SYMBopenTerm}{\\F{openTm}\\xspace}\n\\newcommand{\\openTerm}[1]{\\SYMBopenTerm\\: #1}\n\\newcommand{\\closeTerm}{\\F{closeTm}}\n\n\\newcommand{\\update}{\\F{update}}\n\nConsequently, taking the free monad of \\(\\HExprD\\) by \\(\\SYMBVar\\:\n\\V{G}\\), we obtain the language of open terms in a context \\(\\V{G}\\):\n%\n\\[\n\\openTerm{\\V{G}} \\mapsto \\FreeIMonad{\\HExprD}{\\Ty}{(\\SYMBVar\\:\\V{G})}\n\\]\n%\nIn this setting, the language of closed terms corresponds to the free\nmonad assigning an empty set of values to variables\n%\n\\[\n\\closeTerm \\mapsto \\FreeIMonad{\\HExprD}{\\Ty}{\\SYMBEmpty}\n\\quad\n\\mbox{where}\n\\quad\n\\stk{\n\\SYMBEmpty : \\Ty \\To \\Set \\\\\n\\begin{array}{@{}l@{\\:\\:\\mapsto\\:\\:}l}\n\\Empty{\\_}   & \\Zero \\\\\n\\end{array}\n}\\]\n%\nAllowing variables from an empty set is much like forbidding variables,\nso \\(\\closeTerm\\) and \\(\\HExprD\\) describe isomorphic\ndatatypes. Correspondingly, you can update an old \\(\\HExprD\\) to a shiny\n\\(\\closeTerm\\):\n%\n\\[\\stk{\n\\update : \\muide{\\Ty}{\\HExprD} \\DotTo \\muide{\\Ty}{\\closeTerm} \\\\\n\\begin{array}{@{}l@{}l}\n\\update\\: \\V{ty}\\: \\V{tm} \\mapsto \\cataI_{\\Ty}\\: & (\\toIDesc{\\HExprD})\\:\n                                                  (\\muide{\\Ty}{\\closeTerm})\\: \\\\\n                                                & (\\LAM{\\_} \\LAM{\\pair{\\V{tag}}{\\V{tm}}{}} \\Con{\\pair{\\Su{\\V{tag}}}{\\V{tm}}{}})\\:\n                                                  \\V{ty}\\:\n                                                  \\V{tm}\n\\end{array}\n}\\]\n% \nThe other direction of the isomorphism is straightforward, the\n$\\SYMBDVar$ case being impossible. Therefore, we are entitled to\nreuse the $\\evalH$ function to define the semantics of $\\closeTerm$.\n\n\\newcommand{\\discharge}{\\F{discharge}}\n\nNow we would like to give a semantics to the open term language. We\nproceed in two steps: first, we substitute variables by their value in\nthe context; then, we evaluate the resulting closed term. Thanks to\n$\\evalH$, the second problem is already solved. Let us focus on\nsubstituting variables from the context. Again, we can subdivide this\nproblem: first, discharging a single variable from the context; then,\napplying this $\\discharge$ function on every variables in the term.\n\nThe $\\discharge$ function is relative to the required type and a\ncontext of the right type. Its action is to map values to themselves,\nand variables to their value in context. This corresponds to the\nfollowing function:\n%\n\\[\\stk{\n\\begin{array}{@{}ll}\n\\discharge : & \\PI{\\V{G}}{\\Ctxt}\n               \\Env{\\V{G}} \\To \n               \\Var{\\V{G}}{} \\DotTo\n               \\muide{\\Ty}{\\closeTerm}\n\\end{array} \\\\\n\\begin{array}{@{}l@{\\:\\mapsto\\:\\:}l}\n\\discharge\\: \\V{G}\\: \\V{g}\\: \\V{ty}\\: \\V{v} &\n    \\Con{\\pair{\\SYMBEval}{\\lookup{\\V{G}}{\\V{g}}{\\V{ty}}{\\V{v}}}{}}\n\\end{array}\n}\\]\n\n\\begin{wstructure}\n            /> Then, perform subst everywhere in the term\n                -> Show type [code]\n                /> This is a bind!?\n                -> There is some more structure \n                    -> We should try to get it\n\\end{wstructure}\n\n\\newcommand{\\substH}{\\F{substExpr}}\n\nWe are now left with applying $\\discharge$ over all variables of the\nterm.  We simply have to fill in the right arguments to $\\substI$, the\ntype guiding us:\n%\n\\[\n\\stk{\n\\begin{array}{@{}ll}\n\\substH  : & \\PI{\\V{G}}{\\Ctxt} \\\\\n           & (\\Var{\\V{G}}{} \\DotTo\n              \\muide{\\Ty}{\\closeTerm}) \\DotTo \\\\\n          & \\muide{\\Ty}{(\\openTerm{\\V{G}})} \\DotTo \n            \\muide{\\Ty}{\\closeTerm}\n\\end{array} \\\\\n\\substH\\: \\V{G}\\:\n          \\V{ty}\\:          \n          \\V{g}\\:\n          \\V{\\sigma}\\: \n          \\V{tm} \\mapsto  \n\\substI_{\\Ty}\\:\n               (\\SYMBVar\\: \\V{G})\\: \n               \\SYMBEmpty\\:\n               \\HExprD\\: \n               \\V{\\sigma}\\:\n               \\V{ty}\\:\n               \\V{tm}\n}\\]\n\nHence completing our implementation of the open terms\ninterpreter. Without much effort, we have described the syntax of a\nwell-typed language, together with its semantics.\n\n\n\\paragraph{Indexed descriptions:}\n\nAn interesting instance of free monad is $\\SYMBIDesc$ itself. Indeed,\n$\\SYMBDVar$ is nothing but the \\return. The remaining constructors form\nthe carrier functor, trivially indexed by $\\Unit$. The signature functor\nis described as follow:\n%\n\\[\\stk{\n\\IDescFreeD : \\ATagIDesc{\\Unit} \\\\\n\\begin{array}{@{}ll}\n\\IDescFreeD \\mapsto \\bigRedBracket{\\begin{array}{l}\n                                \\sqr{\\SYMBDConst\\:\\:\n                                     \\DProd\\:\\:\n                                     \\SYMBDSigma\\:\\:\n                                     \\SYMBDPi} \\red{,}\\\\\n                                  \\LAM{\\_}\\bigRedBracket{\\begin{array}{l}\n                                        \\DConst{\\Set}               \\\\\n                                        \\DProd{\\DVar{\\Void}}{\\DVar{\\Void}}  \\\\\n                                        \\DSigma{\\Set}{(\\LAM{\\V{S}} \\DPi{\\V{S}}{(\\LAM{\\_} \\DVar{\\Void})})} \\\\\n                                        \\DSigma{\\Set}{(\\LAM{\\V{S}} \\DPi{\\V{S}}{(\\LAM{\\_} \\DVar{\\Void})})}\n                                    \\end{array}}\\end{array}}\n\\end{array}\n}\\]\n%\nWe get $\\IDesc{\\V{I}}$ by extending the signature with variables from \\(\\V{I}\\):\n%\n\\[\\stk{\n\\IDescD : \\PI{\\V{I}}{\\Set} \\TagIDesc{\\Unit} \\\\\n\\IDescD\\: \\V{I} \\mapsto \\FreeIMonad{\\red{[}\\IDescFreeD\\red{,[}\\LAM{\\_}\\sqr{}\\red{,}\\LAM{\\_}\\red{[]]]}}{\\Unit}\\LAM{\\_}\\V{I}\n}\\]\n\nThe fact that indexed descriptions are closed under substitution\nis potentially of considerable utility, if we can exploit this fact:\n\\[\n\\idescop{\\V{\\sigma} \\V{D}}{\\V{J}}{\\V{X}} \n    \\mapsto \n        \\idescop{\\V{D}}\n                {\\V{I}}\n                {\\LAM{\\V{i}}\n                     {\\idescop{\\V{\\sigma} \\V{i}}\n                              {\\V{J}}\n                              {\\V{X}}}}\n        \\quad \\mbox{where}\\;\\V{\\sigma}:\\V{I}\\To\\IDesc{\\V{J}}\n\\]\nBy observing that a description can be decomposed via substitution, we\nsplit its meaning into a superstructure of substructures, e.g. a\n`database containing salaries', ready for traversal operations\npreserving the former and targeting the latter.\n \n%\\newpage\n", "meta": {"hexsha": "94fabb13da7a3689bc07a540c343631eb0a8198f", "size": 41002, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/icfp-2010-desc/paper_idesc.tex", "max_stars_repo_name": "mietek/epigram", "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_issues_repo_path": "papers/icfp-2010-desc/paper_idesc.tex", "max_issues_repo_name": "mietek/epigram", "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/icfp-2010-desc/paper_idesc.tex", "max_forks_repo_name": "mietek/epigram", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "avg_line_length": 36.6089285714, "max_line_length": 140, "alphanum_fraction": 0.5565582167, "num_tokens": 14387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.429389164437277}}
{"text": "\\subsection{\\texttt{smooth\\_box.py}}\\label{geocode:smooth_box}\n\n\\begin{verbatim}\n# --- geometry setup script for block with smooth sides ---\nfrom gengeo import *\n\n# - input parameters --\n# block dimensions\nxdim=10\nydim=20\nzdim=10\n\n# particle size range\nminRadius = 0.2\nmaxRadius = 1.0\n# ---------------------\n\n# corner points\nminPoint = Vector3(0.0,0.0,0.0)\nmaxPoint = Vector3(xdim,ydim,zdim)\n\n# neighbour table \nmntable = MNTable3D(minPoint,maxPoint,2.5*maxRadius,1)\n\n# block volume\nbox = BoxWithPlanes3D(minPoint,maxPoint)\n\n# boundary planes\nbottomPlane=Plane(minPoint,Vector3(0.0,1.0,0.0))\nleftPlane=Plane(minPoint,Vector3(1.0,0.0,0.0))\nfrontPlane=Plane(minPoint,Vector3(0.0,0.0,1.0))\ntopPlane=Plane(maxPoint,Vector3(0.0,-1.0,0.0))\nrightPlane=Plane(maxPoint,Vector3(-1.0,0.0,0.0))\nbackPlane=Plane(maxPoint,Vector3(0.0,0.0,-1.0))\n\n# add them to the box \nbox.addPlane(bottomPlane)\nbox.addPlane(leftPlane)\nbox.addPlane(frontPlane)\nbox.addPlane(topPlane)\nbox.addPlane(rightPlane)\nbox.addPlane(backPlane)\n\n# -- setup packer --\n# iteration parameters\ninsertFails = 1000\nmaxIter = 1000\ntol = 1.0e-6\n\n# packer\npacker = InsertGenerator3D( minRadius,maxRadius,insertFails,maxIter,tol,False)\n\n# pack particles into volume\npacker.generatePacking(box,mntable,0,1)\n\n# create bonds between neighbouring particles:\nmntable.generateBonds(0,1.0e-5,0)\n\n# calculate and print the porosity:\nvolume = xdim*ydim*zdim\nporosity = (volume - mntable.getSumVolume(groupID=0))/volume\nprint \"Porosity:  \", porosity\n\n# write a geometry file\nmntable.write(\"smooth_box.geo\", 1)\nmntable.write(\"smooth_box.vtu\", 2)\n\\end{verbatim}", "meta": {"hexsha": "6dcf62da7d42d15b55ce1174826d7f452678bc69", "size": 1597, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Doc/Tutorial/examples/smooth_box_compact.py.tex", "max_stars_repo_name": "danielfrascarelli/esys-particle", "max_stars_repo_head_hexsha": "e56638000fd9c4af77e21c75aa35a4f8922fd9f0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Doc/Tutorial/examples/smooth_box_compact.py.tex", "max_issues_repo_name": "danielfrascarelli/esys-particle", "max_issues_repo_head_hexsha": "e56638000fd9c4af77e21c75aa35a4f8922fd9f0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Doc/Tutorial/examples/smooth_box_compact.py.tex", "max_forks_repo_name": "danielfrascarelli/esys-particle", "max_forks_repo_head_hexsha": "e56638000fd9c4af77e21c75aa35a4f8922fd9f0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.8358208955, "max_line_length": 78, "alphanum_fraction": 0.7438948028, "num_tokens": 529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4293891542046626}}
{"text": "\\subsubsection*{Two-dimensional plane strain problem}\n% A two-dimensional rectangular plate made of the compressible hyperelastic neo-Hookean material is considered here in the plane strain case.\n% Unlike for the Saint-Venant-Kirchhoff model, the polyconvexity of the neo-Hookean stored energy function ensures the hyperbolicity of the problem (see section \\ref{sec:constitutive-equations}).\n%Geometry, boundary and loading conditions are given in figure \\ref{fig:2d_heDomain}.\n% \\begin{figure}[h!]\n%   \\centering\n%   \\input{chapter4/pgfFigures/2d_heDomain}\n%   \\caption{Geometry, boundary and loading conditions of the two-dimensional problem in plane strain with a hyperelastic neo-Hookean material.}\n%   \\label{fig:2d_heDomain}\n% \\end{figure}\nThe plane strain problem studied in sections \\ref{subsec:el_planestrain} and \\ref{subsec:ep_planestrain} is now considered in a compressible hyperelastic neo-Hookean material submitted to an imposed velocity $v_1=-1000 \\: m/s$ on the bottom part of its left end.\nThe solid is discretized such that material points are equivalent to $Q1$-finite element nodes.\nThus, the plate is represented with $l \\times h \\equiv 28 \\times 28$ material points, only with the 1ppc configuration.\nThe finite element computation is performed with the software \\textit{Abaqus} \\cite{Abaqus} using an explicit time discretization with no artificial viscosity added.\nThese numerical results are compared to those obtained from MPM and DGMPM using CTU computations.\nThe Courant number is set to unity in DGMPM and to $0.5$ in MPM leading to \\textit{average} time steps $\\Delta t_{CTU}=1.41 \\times 10^{-5}s$ and $\\Delta t_{MPM}=6.13 \\times 10^{-6}s$, whereas the \\textit{constant} time step used in the FEM simulation is $\\Delta t_{FEM}=1.27 \\times 10^{-5} s$.\nFigure \\ref{fig:2dhe_stress} shows numerical results in terms of the Cauchy stress tensor isovalues exported from Abaqus to the software Paraview \\cite{Paraview} with the code developed in \\cite{Export_Abaqus}, particularized to the present two-dimensional plane strain case.\nCauchy stress is plotted on the current configuration in such a way that figure \\ref{fig:2dhe_stress} also enables the comparison of the deformed shape of the body.\n\\begin{figure}[h!]\n  \\centering\n  \\input{chapter4/pgfFigures/2Dhestress}\n  \\caption{Isovalues of Cauchy stress tensor component $\\sigma_{11}$ in a two-dimensional plate made of a neo-Hookean material, submitted to a velocity $\\vect{v}\\cdot\\vect{e}_1=-1000 \\: m/s$ on a part of its left end.}\n  \\label{fig:2dhe_stress}\n\\end{figure}\n\\begin{figure}[h!]\n  \\centering\n  \\input{chapter4/pgfFigures/linePlotshyp_stress}\n  %\\input{chapter4/pgfFigures/linePlotshyp_velo}\n  \\caption{Evolution of longitudinal Cauchy stress $\\sigma_{11}$ along the bottom boundary of the domain.}\n  \\label{fig:he_lineplots_stress}\n\\end{figure}\nAt the beginning of the computation (first row in figure \\ref{fig:2dhe_stress}), stress profiles are quite similar despite slight oscillations visible in FEM and MPM solutions.\nThis can also be seen in figure \\ref{fig:he_lineplots_stress}, in which stress is plotted along the bottom boundary of the domain.\nHowever, the MPM solution exhibits, as for small strain problems, a concentration of stress in the high gradients region on the left boundary.\n%It is worth noticing that the DGMPM shows the same behavior that cannot be seen here due to the attenuation introduced by MPM stress values which are much higher.\nIt is worth noticing that the DGMPM shows the same behavior that cannot be seen here due to the MPM stress values which are much higher.\nThe deformed shapes of the plate resulting from the three numerical approaches hence remain close, except at the junction of the loaded and free zones of the left edge.\nWhen the pressure wave reflects on the fixed boundary at time $t=5.0\\times 10^{-4}\\:s$ (second row in figures \\ref{fig:2dhe_stress} and \\ref{fig:2dhe_velo}), the stress profiles are still similar, though FEM and MPM solutions oscillate even more.\nThese spurious oscillations are more significant in the velocity fields depicted in figure \\ref{fig:2dhe_velo} as well as in figures \\ref{fig:he_lineplots_stress} and \\ref{fig:he_lineplots_velo} which depict the velocity along the bottom boundary.\nFurthermore, one can see in figure \\ref{fig:he_lineplots_velo}\\subref{subfig:he_velo2} that the homogeneous Dirichlet boundary condition is not exactly enforced in DGMPM when the incident wave hits the right end.\n\\begin{figure}[h!]\n  \\centering\n  \\input{chapter4/pgfFigures/2Dhevelo}\n  \\caption{Isovalues of velocity component $v_1$ in a two-dimensional plate made of a neo-Hookean material, submitted to a velocity $\\vect{v}\\cdot\\vect{e}_1=-1000 \\: m/s$ on a part of its left end.}\n  \\label{fig:2dhe_velo}\n\\end{figure}\n\\begin{figure}[h!]\n  \\centering\n  {\\phantomsubcaption \\label{subfig:he_velo1}}\n  {\\phantomsubcaption \\label{subfig:he_velo2}}\n  {\\phantomsubcaption \\label{subfig:he_velo3}}\n  \\input{chapter4/pgfFigures/linePlotshyp_velo}\n  \\caption{Evolution of horizontal velocity $v_1$ along the bottom boundary of the domain.}\n  \\label{fig:he_lineplots_velo}\n\\end{figure}\nThis can be explained by considering a boundary cell of the arbitrary grid (\\textit{i.e. containing one material point that belongs to the right end of the domain}) that is about to be reached by the wave through the upwind interface.\nThe intercell flux on the upwind interface resulting from the discontinuity, and subsequently the conserved quantities vector resulting from the solution of the discrete system on the grid, are non-zero.\nIn particular, the horizontal velocity at upwind nodes of the boundary cell does not vanish while that of the downwind edge satisfies the homogeneous Dirichlet condition. \nHence, the interpolation of the velocity from nodes to the particle yields a non-zero field at the material point level.\nNote that this holds for the MPM as well in which the enforcement of boundary conditions is still a challenging question \\cite{BC_MPM}.\n\nNevertheless, no significant displacements of particles can be seen on the right end in MPM and DGMPM solutions in figures \\ref{fig:2dhe_stress} and \\ref{fig:2dhe_velo}.\nAt last, oscillations remain in FEM and MPM solutions until the end of the simulation. \nSince the velocity field depicted in figures \\ref{fig:2dhe_velo} and \\ref{fig:he_lineplots_velo} is used to update the shape of the solid in FEM, the numerical noise yields final configurations that are slightly different.\nOn the other hand, updating particle positions with the grid velocity within the MPM allows better results than if the oscillating material point velocity is used.\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% ispell-local-dictionary: \"american\"\n%%% TeX-master: \"../mainManuscript\"\n%%% End:", "meta": {"hexsha": "8993d0a44021125b71659df486ba95749744c99b", "size": 6771, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/chapter4/he_plate.tex", "max_stars_repo_name": "adRenaud/research", "max_stars_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-18T14:52:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-18T14:52:03.000Z", "max_issues_repo_path": "manuscript/chapter4/he_plate.tex", "max_issues_repo_name": "adRenaud/research", "max_issues_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-07T13:11:11.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-07T13:11:11.000Z", "max_forks_repo_path": "manuscript/chapter4/he_plate.tex", "max_forks_repo_name": "adRenaud/research", "max_forks_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.0416666667, "max_line_length": 293, "alphanum_fraction": 0.789986708, "num_tokens": 1763, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4293891542046626}}
{"text": "\\chapter{Related work}\n\\label{chapter:related}\n\n\\section{An in-depth look to ``Human-level control through deep reinforcement learning'' paper}\nThis section is dedicated to analyzing the paper which is proposes a method for solving games using deep learning and reinforcement learning. The proposed agent, called Q-Network capable of playing 43 different games and adapting to each one without being modified.\n\n\n\\begin{figure}[h]\n\t\\floatname{algorithm}{Algorithm}\n\t\\begin{center}\n\t\t\\includegraphics[width=334px,height=51px]{src/img/state/ataripic}\n\t\t\\caption{Snapshots with five Atari 2600 Games: Pong, Breakout, Space Invaders, Seaquest, Beam Rider\\cite{nature}} \\label{fig:ataripic}\n    \\end{center}\n\\end{figure}\n\n\n\n\n\\section{Architecture}\nThe article\\cite{nature} proposes a new type of network, Q-network which combines convolutional layers, a representation of the human receptive fields and pooling layers used for dimensionality reduction. The input layer is represented by \\textbf{84x84x4} neurons for the image produced after preprocessing frames from the game and is followed by three convolutional layers(32 filters of 8x8 and stride 4 with ReLU, 64 filters of 4x4 and stride 2 with ReLU, 64 filters of 3x3 and stride 1 with ReLU), two fully connected layers: a hidden layer with 512 units and the output layer which has a number of neurons equal to the number of actions corresponding to each game. Each hidden layer is followed by a rectified linear unit (ReLU).\n\n\n\n\\begin{figure}[h]\n\t\\floatname{algorithm}{Algorithm}\n\t\\begin{center}\n\t\t\\includegraphics[width=442px,height=242px]{src/img/state/schematic-ilustration}\n\t\t\\caption{Q-Network architecture\\cite{nature}} \\label{fig:arch}\n    \\end{center}\n\\end{figure}\n\nThe network is used to approximate the optimal action-value function $Q^{*}$\\cite{nature}:\n\\begin{equation}\n\tQ^{*}(s,a) = \\max_\\pi E[r_t + \\gamma\\cdot r_{t+1} + \\gamma^2\\cdot r_{t+2} + \\dotsc | s_t = s, a_t = a, \\pi]\n\\end{equation}\nThe function Q is also parametrized with the weights and the agent state $e_t = (s_t,a_t,r_t,s_{t+1})$ is saved at each iteration in a set D_t = ${(e_1, e_2, \\dotsc, e_t)}$\nWith all the necessary information here is the computation of the loss function\\cite{nature}:\n\n\\begin{equation}\n\tL_i(\\theta_i)=E_{(s,a,r,s^{\\prime})}[(r + \\gamma\\cdot\\max_{a^{\\prime}}\\cdot Q(s^{\\prime},a^{\\prime};{\\theta_i}^-) - Q(s,a;\\theta_i))^2]\n\\end{equation}\n\nwhere $\\gamma$ represents the discount factor and ${\\theta_i}^-)$ is updated with $\\theta_i$ every x defined steps and here is the gradient\\cite{nature}:\n\n\\begin{equation}\n\\nabla_{\\theta_i}L(\\theta_i) = E_{s,a,r,{s^i}}[(r + \\gamma\\cdot\\max_{a^{\\prime}}Q(s^\\prime, a^\\prime;{\\theta_i}^-)-Q(s,a;\\theta_i))\\nabla_{\\theta_i}Q(s,a;\\theta_i)]\n\\end{equation}\n\nThe Q-learning action-value function can be updates using ${\\theta_i}^-$ = $\\theta_{i-1}$ following the optimal policy with probability 1 - $\\epsilon$ and selecting a random move with probability $\\epsilon$. \n\nFor minimizing the loss function, Stochastic Gradient Descent is used in combination with the experience replay technique for preventing `dead' neurons and also, Q is not updated at each iteration. This avoids the instability of Q caused by the nonlinearity of network.\n\nThe $\\epsilon$-greedy policy was set to 0.05 and the Q-values were scaled because of big range values from rewards.\n\\newpage\n\\section{Algorithm}\n\nOne of the techniques that Q-Network algorithm is using is called experience replay. This implies transitions between states to be stored. A number of N transitions (the previous state, the current state, reward and action) are stored in a pool of transitions. Until the network starts learning, we have to play many episodes. We begin from initializing the pool where we store the experiences and initialize two different networks(action-value network Q and target action-value network $Q^-$) with the same weights. For each episode we start by storing the current transition which at first will be composed by only one state. With probability $\\epsilon$ we choose a random action and with probability $1-\\epsilon$ we choose the best action. After that, we apply the action on the current state of the game and observe reward and new state of the game. We put it in the pool and randomize it. The target value is the reward if game is finished or the sum between the reward observed and maxim-value predicted by target action-value $Q^-$ multiplied with the discount factor. Then we propagate the error as the mean squared error between target value and action-value function Q. Once \\textbf{x} steps had pass we update the weights of $Q^-$ with the weights of Q. The algorithm\\cite{atari} used for training Q-Network is presented as it follows:\n\n\\begin{algorithm}\n\t\\floatname{algorithm}{Algorithm}\n\t\\caption{Q-Network} \\label{sgd-code}\n\t\\begin{algorithmic}[1]\n\t\t\\State create replay memory D for storing N experiences\n\t\t\\State choose $\\epsilon$ between (0,1)\n\t\t\\State init Q model weights with $\\theta$\n\t\t\\State save $Q^-$ model weights to $\\theta^-$\n\t\t\\State init variable episode to 0 and choose MAX_EPISODES\n\t\t\\While{episode < MAX_EPISODES}{\n\t\t\t\\State generate state $s_1$ from frame: $s_1$ = {$image_1$}\n\t\t\t\\While{game not over}\n\t\t\t\t\\State r = random number between (0,1)\n\t\t\t\t\\If{r < $\\epsilon$}\n\t\t\t\t\t\\State $a_t$ = random action\n\t\t\t\t\\Else\n\t\t\t\t\t\\State $a_t$ = $argmax_a$ Q($s_t$, a; $\\theta$)\n\t\t\t\t\\EndIf\n\n\t\t\t\t\\State $s_{t+1}$ = ($s_t$,$a_t$,$image_{t+1}$)\n\n\t\t\t\t\\State D = D + \\{($s_t$, $a_t$, $r_t$, $s_{t+1}$)\\}\n\n\t\t\t\t\\State shuffle D\n\n\t\t\t\t\\State extract ($s_j$, $a_j$, $r_j$, $s_{j+1}$) from D\n\n\t\t\t\t\\If{episode is finished at step j+1}\n\t\t\t\t\t\\State $y_j$ = $r_j$\n\t\t\t\t\\Else\n\t\t\t\t\t\\State $y_j$ = $r_j$ + $\\gamma\\cdot\\max_{a^{\\prime}}\\cdot {Q^-}(s_{j+1},a^{\\prime};\\theta^-)$\n\t\t\t\t\\EndIf\n\t\t\t\t\\State propagate error $(y_j - Q(s_j,a_j;\\theta))^2$\n\t\t\t\t\\State at each \\textbf{x} steps save model weights $\\theta$ to $\\theta^-$\n\t\t\t\\EndWhile\n\t\t}\\EndWhile\n\n\t\t\n\t\\end{algorithmic}\n\\end{algorithm}\n\n\\newpage\n\n\n\\section{Results}\n\nQ-Network is capable of learning the optimal policy. For example, in Breakout what is being learned is to make a tunnel between blocks in order to send the ball into the back. Receiving only the pixel from the frames, rewards and using the same network structure it is capable of playing different games. The Q-Network can achieve 75\\% of a score of a human test at 49 games\\cite{nature}. The games where the algorithm performs poorly are the games where the memory is needed. For example, on Montezuma's Revenge\\footnote{\\url{https://atariage.com/software_page.php?SoftwareID=1158}} we go from room to another rooms so it is very hard for the algorithm taking into account multiple scenarios changing instead of only one changing. Below there are the results for different types of games from Atari compared to the results of a professional human tester.\n\n\n\\begin{figure}[h]\n\t\\floatname{algorithm}{Algorithm}\n\t\\begin{center}\n\t\t\\includegraphics[width=367px,height=435px]{src/img/state/comparision}\n\t\t\\caption{Comparison\\cite{nature}} \\label{fig:comp}\n    \\end{center}\n\\end{figure}\n\n\n\n\n", "meta": {"hexsha": "037042d87a88fd50386cdf5f837804d0bf8284db", "size": 7080, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diploma/src/chapters/related.tex", "max_stars_repo_name": "xriflo/thesis_deep_learning", "max_stars_repo_head_hexsha": "1d5bef42874d2b03762c004a63d0010b93eff8d0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "diploma/src/chapters/related.tex", "max_issues_repo_name": "xriflo/thesis_deep_learning", "max_issues_repo_head_hexsha": "1d5bef42874d2b03762c004a63d0010b93eff8d0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "diploma/src/chapters/related.tex", "max_forks_repo_name": "xriflo/thesis_deep_learning", "max_forks_repo_head_hexsha": "1d5bef42874d2b03762c004a63d0010b93eff8d0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.4957983193, "max_line_length": 1346, "alphanum_fraction": 0.7392655367, "num_tokens": 1963, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4293891542046626}}
{"text": "\\documentclass[11pt,a4paper,british]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{luainputenc}\n\\pagestyle{plain}\n\\setcounter{tocdepth}{2}\n\\usepackage{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{setspace}\n\\usepackage{microtype}\n\\onehalfspacing\n\\usepackage[unicode=true,pdfusetitle,bookmarks=true,bookmarksnumbered=true,bookmarksopen=false,breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=section,colorlinks=false]\n {hyperref}\n\\makeatletter\n\\@ifundefined{pageheight}{\\let\\pageheight\\pdfpageheight}{}\n\\@ifundefined{pagewidth}{\\let\\pagewidth\\pdfpagewidth}{}\n\\pageheight\\paperheight\n\\pagewidth\\paperwidth\n\\let\\SF@@footnote\\footnote\n\\def\\footnote{\\ifx\\protect\\@typeset@protect\n    \\expandafter\\SF@@footnote\n  \\else\n    \\expandafter\\SF@gobble@opt\n  \\fi\n}\n\\expandafter\\def\\csname SF@gobble@opt \\endcsname{\\@ifnextchar[%]\n  \\SF@gobble@twobracket\n  \\@gobble\n}\n\\edef\\SF@gobble@opt{\\noexpand\\protect\n  \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n\\def\\SF@gobble@twobracket[#1]#2{}\n\n\\@ifundefined{date}{}{\\date{}}\n\\AtBeginDocument{\n  \\def\\labelitemi{\\(\\star\\)}\n}\n\n\\makeatother\n\n\\begin{document}\n\\title{\\textbf{\\huge{}RSA KEY GENERATION ALGORITHM}}\n\\author{AGNI DATTA}\n\\maketitle\n\\begin{center}\n\t\\rule[0.5ex]{0.5\\columnwidth}{0.75pt}\n\t\\par\\end{center}\n\n\\medskip{}\n\n\n\\subsection{Select two huge primes numbers,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$p\\:\\text{and}\\:q$\n\n\\subsection{Calculate,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$n=p\\times q$\n\n\\subsection{Calculate Euler's Totient\\protect\\footnote{refer https://en.wikipedia.org/wiki/Euler\\%27s\\_totient\\_function}\n\tFunction,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$\\varphi(n)=(p-1)\\times(q-1)$\n\n\\subsection{Choose the value of e such that,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$d\\equiv e^{-1}\\bmod\\varphi(n)\\rightarrow ed\\bmod\\varphi(n)=1$\n\n\\subsection{Public Key Pair,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$\\{e,n\\}$\n\n\\subsection{Private Key Pair,}\n\n\\quad{}\\quad{}\\quad{}\\quad{}$\\{d,n\\}$\\\\\n\n\\vfill{}\n\n\\end{document}\n", "meta": {"hexsha": "5d8ebacedf6078e4d12150ecc5eb18d1ed93ed19", "size": 1961, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "RSA_Key_Generation_Algorithm_Notes/RSA_Key_Generation_Algorithm_Notes.tex", "max_stars_repo_name": "Yuvvi01/Notes", "max_stars_repo_head_hexsha": "42f22fcb564b8dfab1443b00ec6f75327f86a87e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-12T20:34:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-12T20:34:03.000Z", "max_issues_repo_path": "RSA_Key_Generation_Algorithm_Notes/RSA_Key_Generation_Algorithm_Notes.tex", "max_issues_repo_name": "Yuvvi01/Notes", "max_issues_repo_head_hexsha": "42f22fcb564b8dfab1443b00ec6f75327f86a87e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RSA_Key_Generation_Algorithm_Notes/RSA_Key_Generation_Algorithm_Notes.tex", "max_forks_repo_name": "Yuvvi01/Notes", "max_forks_repo_head_hexsha": "42f22fcb564b8dfab1443b00ec6f75327f86a87e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.5125, "max_line_length": 181, "alphanum_fraction": 0.7287098419, "num_tokens": 681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.4293891542046626}}
{"text": "%!TEX root = ../CombinatoricsNotes.tex\n\n\\section{Tur\\'an type problems} % (fold)\n\\label{sec:turian_type_problems}\n\nThe general problem we've been considering is to find $\\max |\\F|$ given that $\\F\\subset \\P([n])$ has certain properties. For example, Sperner systems, and intersecting $r$-graphs. In these problems, we are forbidding certain sub set systems\\sidenote{In a Sperner system, there is no 2 element sub system $\\{A,B\\}$ with $A\\subset B$. In an intersecting $r$-graph, there is no two element sub system $\\{A,B\\}$ with $A\\cap B= \\emptyset$.}. Here, we will focus on $r$-graphs.  \n\nWe will say $\\F$ and $\\H$ are \\defn{isomorphic} set systems if there exists a bijective map $\\phi: \\bigcup_{F\\in \\F} F \\to \\bigcup_{H\\in \\H}H$ such that $F\\in \\F$ if and only if $\\phi(F)\\in \\H$.\nNow, let forbidden subconfigurations $F_1,\\dotsc,F_k$ be given $r$-graphs\\sidenote{Recall: Set systems with elements which are in $[n]^{(r)}$.}. Define the \\defn{Tur\\'an number}\n\\[\n\\ex (n; F_1,\\dotsc,F_k)\n\\]\nto be the maximum $|\\F|$ such that $\\F$ does not contain a subgraph isomorphic to any of $F_1,F_2,\\dotsc,F_k$.\n\n\n\\begin{remark}\nWe will increasingly refer to $F\\in \\F$ as edges.\n\\end{remark}\n\n\\begin{example}\nIf $M_2$ consists of two disjoint edges of size $r$, then \\erdos-Ko-Rado says that $\\ex(n;M_2) = {n-1\\choose r-1}$ for $n\\geq 2r$.\\marginnote{Not having a subgraph isomorphic to $M_2$ means there must not be two disjoint subsets in $\\F$, i.e., $\\F$ is intersecting.}\n\\end{example}\nLet\n\\[\n\\pi(n;F_1,\\dotsc,F_k) := \\frac{\\ex(n;F_1,\\dotsc,F_k)}{{n\\choose r}}\n\\]\nbe the ratio of the largest valid size of $\\F$ to the size of $[n]^{(r)}$.\nWe define the \\defn{Tur\\'an density} of $F_1,\\dotsc,F_k$ to be\n\\[\n\\pi(F_1,\\dotsc,F_k) := \\lim_{n\\to\\infty} \\pi(n; F_1,\\dotsc,F_k) \\in [0,1].\n\\]\n\n\\begin{example}\n\\[\n\\pi(M_2) = \\lim_{n\\to\\infty} \\frac{{n-1\\choose r-1}}{{n\\choose r}}=0,\n\\]\nusing \\erdos-Ko-Rado. \\marginnote{If you select two $r$-tuples of elments in an $n$ element set for very large $n$, you almost surely get disjoint tuples.}\n\\end{example}\n\\begin{theorem}[\\cite{Katona_Nemetz_Simonovits}]\nIf $r\\leq n_0\\leq n$, then\n\\[\n\\pi(n_0; F_1,\\dotsc,F_k) \\geq \\pi(n; F_1,\\dotsc,F_k).\n\\]\\label{thm:pi_decreasing}\n\\end{theorem}\n\\begin{remark}\nThen $\\pi(n;F_1,\\dotsc,F_k)$ decreases for $n\\geq r$ and is bounded below by zero,  so $\\pi(F_1,\\dotsc,F_k)$ exists.\n\\end{remark}\n\\begin{proof}\t\nLet $\\F\\subset[n]^{(r)}$ be such that $|\\F| = \\ex(n; F_1,\\dotsc,F_k)$ and $\\F$ contains no subgraphs isomorphic to any of $F_1,\\dotsc, F_k$. Let $H_1,H_2,\\dotsc,H_N$ be the restrictions\\sidenote{Note that for $X\\subset [n]$, we define the restriction of $\\F$ as $\\F\\restriction X := \\{A\\in \\F: A\\subset X\\}$.} of $\\F$ to all possible $n_0$ element subsets of $[n]$, where $N = {n\\choose n_0}$.\n It suffices to show that\n% \\begin{align}\t\\label{eq:pi_avg}\n\\[\n\\pi(n; F_1,\\dotsc,F_k) = \\frac{|\\F|}{{n\\choose r}} \\leq \\frac{1}{{n\\choose n_0}} \\sum_{i=1}^N \\frac{|H_i|}{{n_0\\choose r}}\n\\]\n% \\end{align}\nsince $\\frac{|H_i|}{{n_0\\choose r}} \\leq \\pi(n_0; F_1,\\dotsc,F_k)$. \\marginnote{This estimate is the only actual inequality in the proof.}\n\nWe are left to estimate $\\sum_{i=1}^N|H_i|$.\nGiven an edge in $F\\in\\F$, how many $H_i$'s does it appear in? Each $H_i$ whose base set\\sidenote{Meaning the $n_0$-element set $X$ such that $H_i = \\F\\restriction X$.} includes $F$, so we need to choose $n_0-r$ more elements for the base set from the $n-r$ remaining possible elements, i.e.  ${n-r \\choose n_0-r}$.\nThen,\n\\[\n\\frac{1}{{n\\choose n_0}}\\sum_{i=1}^N \\frac{|H_i|}{{n_0\\choose r}} = |\\F| \\frac{{n-r\\choose n_0 -r}}{{n\\choose n_0}{n_0\\choose r}}\\quad \\boxed{=}\\quad \\frac{|\\F|}{{n\\choose r}}.\n\\]\nTo show the boxed equality and finish the proof, we need\n\\begin{equation}\t\\label{eq:binomial_identity_boxes}\n{n\\choose r}{n-r \\choose n_0 -r} = {n\\choose n_0}{n_0 \\choose r}.\n\\end{equation}\n\n\\lect{2}{3}\n% \\marginnote[0\\baselineskip]{Lecture 9: Wednesday, February 3, 2016}\nThis is an identity which we can combinatorially reason as follows. The RHS means we first choose $n_0$ elements out of $n$, then choose $r$ out of those $n_0$. The LHS means we choose $r$ elements from $n$ then $n_0-r$ elements from the remaining $n-r$. This is depicted in \\cref{fig:binomial_identity_boxes}.\n\n\\begin{marginfigure}[0\\baselineskip]\n\\begin{center}\n\\begin{tikzpicture}\n\n\\begin{scope}\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n% \\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n% \\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\n\\node[yshift=-1.7cm] at (0,0) {$\\downarrow$};\n\n\\begin{scope}[yshift=-3.5cm]\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n% \\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n\\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\\node[yshift=-5.2cm] at (0,0) {$\\downarrow$};\n\n\\begin{scope}[yshift=-7cm]\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n\\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n\\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\\end{tikzpicture}\\hfill\n\\begin{tikzpicture}\n\\begin{scope}\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n% \\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n% \\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\n\\node[yshift=-1.7cm] at (0,0) {$\\downarrow$};\n\n\\begin{scope}[yshift=-3.5cm]\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n\\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n% \\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\\node[yshift=-5.2cm] at (0,0) {$\\downarrow$};\n\n\\begin{scope}[yshift=-7cm]\n\\node (rect) at (0,0)[draw,thick,minimum width=2.3cm, minimum height = 2.1cm, label=above:$n$]{};\n\\node  at(.1,-.2)[draw,thick,minimum width=1.6cm, minimum height = 1cm, label=above:$n_0$]{};\n\\node  at(.3,-.3)[draw,thick,minimum width=.7cm, minimum height = .2cm, label=above:$r$]{};\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\\caption{(above) \\emph{Left:} an illustration of the LHS of \\cref{eq:binomial_identity_boxes} and \\emph{right:} the RHS of \\cref{eq:binomial_identity_boxes}. } \\label{fig:binomial_identity_boxes}\n\\end{marginfigure}\n\\end{proof}\n\nLet $H$ be a graph ($2$-graph). Then $\\ex(n,H)=\\max |\\edges (G)|$, where the maximum is taken over graphs $G$ with $|V(G)| = n$ such that $H$ is not a subgraph of $G$.\n\nWe may consider\n\\[\t\n\\pi(n;H) := \\frac{\\ex(n,H)}{{n\\choose 2}}, \\qquad \\pi(H):= \\lim_{n\\to \\infty}\\pi(n,H).\n\\]\nBy \\cref{thm:pi_decreasing}, $\\pi(n,H)$ decreases for $n\\geq 2$ (and fixed $H$), so $\\pi(H)$ exists. Let $K_n$ be the complete graph on $n$ verticies: $K_n = [n]^{(2)}$. Since $K_2$ is just a single edge, $\\ex(n; K_2)=0$.\n\nConsider\n$P_3 =$\\scalebox{1}{\\begin{tikzpicture}[color=DarkBlue]\n\\def\\n{3}\n\\def\\radius{.6}\n\\def\\rotation{-30}\n\n\\def\\deg{360/\\n}\n\\pgfmathsetmacro\\nminusone{\\n-1}\n\n\\foreach \\x in {1,...,\\n}\n{\n\t\\pgfmathsetmacro\\myangle{\\x*\\deg+\\rotation};\n\t\\filldraw (\\myangle:\\radius cm) circle (0.4pt) node(a\\x){};\n}\n\n\n\\foreach \\y in {1,...,\\n}\n{\n\n\t\\foreach \\z in {1,...,\\y}\n\t{\n\t\t\\ifthenelse{\\z < \\nminusone}\n\t\t{\n\t\t\\pgfmathsetmacro\\myangley{\\y*\\deg+\\rotation}\n\t\t\\pgfmathsetmacro\\myanglez{\\z*\\deg+\\rotation}\n\t\t\\draw (\\myangley:\\radius cm) -- (\\myanglez:\\radius cm);\n\t\t}{}\n\n\t}\n}\n\\end{tikzpicture}}. Then $\\ex(n,P_3) = \\floor{n/2}$, and $\\pi(P_3)=0$.\n\nConsider $K_3 =$\\scalebox{1}{\\begin{tikzpicture}[color=DarkBlue]\n\\def\\n{3}\n\\def\\radius{.6}\n\\def\\rotation{-30}\n\n\\def\\deg{360/\\n}\n\\pgfmathsetmacro\\nminusone{\\n-1}\n\n\\foreach \\x in {1,...,\\n}\n{\n\t\\pgfmathsetmacro\\myangle{\\x*\\deg+\\rotation};\n\t\\filldraw (\\myangle:\\radius cm) circle (0.4pt) node(a\\x){};\n}\n\n\n\\foreach \\y in {1,...,\\n}\n{\n\n\t\\foreach \\z in {1,...,\\y}\n\t{\n\t\t\\ifthenelse{\\z < \\n}\n\t\t{\n\t\t\\pgfmathsetmacro\\myangley{\\y*\\deg+\\rotation}\n\t\t\\pgfmathsetmacro\\myanglez{\\z*\\deg+\\rotation}\n\t\t\\draw (\\myangley:\\radius cm) -- (\\myanglez:\\radius cm);\n\t\t}{}\n\n\t}\n}\n\\end{tikzpicture}}.\nLet us bound $\\pi(K_3)$. Consider $n$ even, and the complete bipartite graph on $n$ verticies, shown in \\cref{fig:bipartite}.\n\n\\begin{figure}\n\\begin{center}\n\\begin{tikzpicture}[color=black]\n\n\\node (rect) at (0,0)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt]{};\n\n\\node (rect2) at (0,1.5)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt]{};\n\n\\pgfmathsetseed{3}\n% \\def\\z{rand}\n\\foreach \\x in {1,...,5}\n{\n\\filldraw (rand*1.4,rand*.4) circle (0.4pt) node(a\\x){};\n\\filldraw (rand*1.4,1.5+rand*.4) circle (0.4pt) node(b\\x){};\n\n}\n\n\\foreach \\x in {1,...,5}\n{\n% \\ifthenelse{\\x > 1}{\\draw[dashed] (a\\x) -- (u)}{};\n\\foreach \\y in {1,...,\\x}\n{\n\\draw (a\\x) -- (b\\y);\n}\n}\n\n\\end{tikzpicture}\n\\end{center}\n\\caption[][1cm]{(left) The complete bipartite graph on $n$ verticies. We divide the graph into independent sets of size $n/2$, then connect each vertex in the upper set to each vertex in the lower set. This produces $(n/2)^2$ edges and no triangles. \\label{fig:bipartite}}\n\\end{figure}\n\n\n Then $\\pi(n,K_3) \\geq \\frac{n^2/4}{{n\\choose 2}} \\to \\frac{1}{2}$. On the other hand, $P_3$ achieves \n \\[\t\n \\pi(3,K_3) = \\frac{\\ex(3,K_3)}{3} = \\frac{2}{3},\n \\]\n so by \\cref{thm:pi_decreasing},  $\\pi(K_3)\\leq \\frac{2}{3}$.\nThus, we have\n\\[\t\n\\frac{1}{2}\\leq \\pi(K_3)\\leq \\frac{2}{3}.\n\\]\n\nHow do we make a graph with many edges that does not contain any complete subgraphs on $t$ verticies?\n\nWe look at $t$ groups of size $\\frac{n}{t}$. Then join two verticies if they lie in different groups, but not join them if they lie in the same group.\n\n\n\\begin{figure}\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{scope}\n% \\node[left] at (0,0) {$\\circlearrowleft$};\n\n\n\\foreach \\y in {1,...,6}\n{\n\\foreach \\z in {1,...,\\y}\n{\n\\pgfmathsetmacro\\myangley{-1*\\y*60+90}\n\\pgfmathsetmacro\\myanglez{-1*\\z*60+90}\n\\draw (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=8pt,yshift=2pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n}\n}\n % do a few by hand\n \\pgfmathsetmacro\\myangley{-1*3*60+90}\n \\pgfmathsetmacro\\myanglez{-1*5*60+90}\n% \\draw (\\myangley:3cm) -- (\\myanglez:2.9cm);\n\n\n\n\\foreach \\x in {1,...,6}\n{\n \\pgfmathsetmacro\\myangle{-1*\\x*60+90}\n\n\\ifthenelse{\\x > 1}{\n\\filldraw[white] (\\myangle:3cm) circle (20pt);\n\\draw[black] (\\myangle:3cm) circle (20pt) node{$\\frac{n}{t}$\n};\n}{\n\\filldraw[white] (\\myangle:3cm) circle (10pt);\n\\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n};\n\n}\n\n\n%  \\pgfmathsetmacro\\myangle{-1*60+90}\n% \\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\\caption{The Tur\\'an graph on $n$ verticies, in the case that $n$ is divisible by $t$. We partition the graph into $t$ independent subsets of size $\\frac{n}{t}$. Then we connect each vertex in each independent subset $A$ to all the verticies in $V(G)\\setminus A$.  \\label{fig:turan_graph}}\n\\end{figure}\n% Connect each circle to every other circle, several times.\n\n\nThe \\defn{Tur\\'an graph} $T_t(n)=T$ is a graph with $|V(T)|=n$ such that $V(T)$ is  partitioned into $A_1,\\dotsc,A_{t}$ and $v\\in A_i$ is adjacent to $u\\in A_j$ iff $i\\neq j$, and the sizes obey $||A_i| - |A_j|| \\leq 1$ for all $i,j$.\n\nThen\n\\[\n\\pi(K_t) \\geq \\lim_{n\\to\\infty} \\frac{|\\edges (T_{t-1}(n))|}{{n\\choose 2}} = \\lim_{n\\to\\infty} \\frac{{n\\choose 2} - (t-1){\\frac{n}{t-1} \\choose 2}}{{n\\choose 2}}= 1 - \\frac{1}{t-1} = \\frac{t-2}{t-1}\n\\]\n\n\\begin{theorem}[\\cite{turan1941extremal}] \\label{thm:turan}\nFor every $t\\geq 2$, $\\pi(K_t) = \\frac{t-2}{t-1}$. Moreover,\n\\[\n\\ex(n,K_t)\\leq \\frac{t-2}{t-1} \\frac{n^2}{2}.\n\\]\n\\end{theorem}\n\\begin{proof}[Proof by induction on $n$.] \nNote that when $n$ is divisible by $t-1$,\n\\[\n\\ex(n,K_t)\\geq |\\edges (T_{t-1}(n))| = \\frac{t-2}{t-1}\\frac{n^2}{2}\n\\]\nand equality is acheived.\nBase case: for $n < t-1$, then the maximal number of edges (without restriction) is ${n\\choose 2}  = \\frac{n-1}{n}\\frac{n^2}{2}\\leq \\frac{t-2}{t-1}\\frac{n^2}{2}$.\n\nInduction step. Let $n\\geq t-1$. We may assume that $K_{t-1}$ is a subgraph of our graph $G$ (where $G$ is a graph on verticies with no $K_t$ subgraph and $|\\mathcal{G}| = \\ex(n,K_t)$.\n\nLet $U=\\{v_1,v_2,\\dotsc,v_{t-1}\\}$ be the set of verticies of this $K_{t-1}$ subgraph. Then\n\\[\t\n |\\edges (G) | = \\frac{(t-1)(t-2)}{2} + | \\edges (U,V(G)\\setminus U)| + |\\edges (G\\setminus U)|.\n \\]\n This is the number of edges within $U$, plus the number of edges with exactly one end in $U$, plus the number of edges not connected to $U$, respectively. See \\cref{fig:U_VG-U} for a depiction of this partition.\n\n % \\missingfigure{partition of $G$ into $U$ and $V(G)\\setminus U$. $U$ is a complete graph. Put a point $u$ in the latter.}\n\\begin{marginfigure}\n\\begin{center}\n\\begin{tikzpicture}\n\\node (rect) at (0,0)[draw,thick,minimum width=1cm, minimum height = 2cm, rounded corners=3pt,label=above:$U\\cong K_{t-1}$]{};\n\n\\node (rect2) at (2,0)[draw,thick,minimum width=1cm, minimum height = 2cm, rounded corners=3pt,label=above:$V(G)\\setminus U$]{};\n\n\\pgfmathsetseed{3}\n% \\def\\z{rand}\n\\foreach \\x in {1,...,5}\n{\n\\filldraw[black] (rand*.5,rand*1) circle (0.4pt) node(a\\x){};\n}\n% \\draw (a1) -- (a2);\n\n\\filldraw[black] (2,.5) circle (0.4pt) node[right](u){$u$};\n\n\n\n\\foreach \\x in {1,...,5}\n{\n\\ifthenelse{\\x > 1}{\\draw[dashed] (a\\x) -- (u)}{};\n\\foreach \\y in {1,...,\\x}\n{\n\\draw (a\\x) -- (a\\y);\n}\n}\n\n% \\filldraw at (rect2)[draw, fill=black,circle(.4pt),above,label=above:$u$]{};\n\n\\end{tikzpicture}\n\\end{center}\n\\caption{ Illustation of the partition of $G$ into $V(G)\\setminus U \\ni u$ and $U$. If $u$ were adjacent to more than $t-2$ notes in $U$, then $U\\cup \\{u\\} \\cong K_t$. \\label{fig:U_VG-U}}\n\\end{marginfigure}\n\n\n\n For every $u\\in V(G)\\setminus U$, the vertex $u$ is adjacent to $\\leq t-2$ verticies in $U$ (otherwise $U\\cup\\{u\\}\\cong K_t$). So\n \\[\n \\edges (U,V(G)-U)| \\leq (t-2) |V(G)-U| = (t-2)(n-t-1).\n \\]\n\n Moreover,\n \\[\n |\\edges (G\\setminus U)|  \\leq \\frac{t-2}{t-1}\\frac{(n-t+1)^2}{2},\n \\]\n by the induction hypothesis. Putting it all together,\n \\begin{align*}\n |\\edges (G)| &\\leq \\frac{(t-1)(t-2)}{2} + (t-2)(n-t+1) + \\frac{t-2}{t-1}\\frac{(n-t+1)^2}{2}\\\\\n &= \\frac{t-2}{2(t-1)} \\left( (t-1)^2 + 2(t-1) (n-t+1) + (n-t+1)^2 \\right)\\\\\n &= \\frac{t-2}{2(t-1)} n^2.\\qedhere\n \\end{align*}\n\\end{proof}\n\\lect{2}{8}\n% \\marginnote{Lecture 10: Monday, February 8, 2016.}\nWe'll provide another proof of Tur\\'an's theorem, but first let us introduce some notation. Let \n\\[\nd(G) = \\frac{2|\\edges (G)|}{n^2}\n\\]\nbe the \\defn{density}[density of graph] of $G$; this is the probability that choosing two verticies uniformly at random (with repetition) from $V(G)$ gives an edge. The density $\\lambda$ is called the \\defn{Lagrangian} of $G$.\n\nSuppose $V(G) = [n]$. Let \n\\[\n\\lambda(G) := \\max_{\\substack{x_i\\geq 0,\\\\ \\sum_{i=1}^n x_i=1}} \\sum_{(i,j) \\in \\edges (G)} x_i x_j.\n\\]\nThen $2\\lambda(G)$ is the maximum probability of selecting an edge by independently sampling two verticies taken over all probability distributions on the vertex set. In particular, $2\\lambda(G) \\geq d(G)$, for every $G$.\n\n\\begin{example}\n\\[\n\\lambda(K_2) = \\max_{\\substack{x_1,x_2\\geq 0 \\\\ x_1+x_2=1}} x_1 x_2 =\\max_{x_1\\geq 0} x_1(1-x_1) = \\frac{1}{4},\n\\]\nachieved when $x_1=x_2=\\frac{1}{2}$.\n\n\\[\n\\lambda(P_3) = \\max_{\\substack{x_1,x_2,x_3\\geq 0\\\\ x_1+x_2+x_3}} x_1x_2 + x_2x_3 = \\max_{\\substack{x_1,x_2,x_3\\geq 0\\\\ x_1+x_2+x_3}} x_2(x_1+x_3)\n\\]\nis still a product of two things which sum to one. So we need $x_2=\\frac{1}{2}$ and $x_1+x_3=\\frac{1}{2}$. We could take $x_1=x_3=\\frac{1}{4}$.\n\\end{example}\n\n\\begin{lemma}\n$\\lambda(K_t) = \\frac{t-1}{2 t}$.\n\\end{lemma}\n\\begin{proof}\t\nThe uniform distribution on $|V(K_t)|$ acheives $\\frac{t-1}{2t}$, so it is enough to show\n\\[\n\\sum_{\\substack{1\\leq i<j \\leq t,\\\\ x_i\\geq 0,\\\\ \\sum_{i=1}^n x_i=1.}} x_i x_j \\leq \\frac{t-1}{2t}.\n\\]\nBut\n\\[\n\\sum_{\\substack{1\\leq i<j \\leq t,\\\\ x_i\\geq 0,\\\\ \\sum_{i=1}^n x_i=1.}} 2x_i x_j  = (x_1+x_2+\\dotsm + x_t)^2 - \\sum_{i=1}^t x_i^2 = 1- \\sum_{i=1}^t x_i^2 \\quad\\boxed{\\leq} \\quad 1 - \\frac{1}{t}\n\\]\nwhere we need to show the boxed inequality.\nEquivalently, we need $\\sum_{i=1}^t x_i^2 \\geq \\frac{1}{t}$ for all $x_i$ as above. But this follows from Jensen's inequality (with the uniform distribution): if $f$ is convex, then\n\\[\n\\frac{\\sum_{i=1}^n f(x_i)}{n} \\geq f \\left( \\frac{x_1+\\dotsm + x_n}{n}\\right)\n\\]\nfor all $x_1,\\dotsc,x_n$. \n\nHere, we take $f(x)=x^2$, to obtain\n\\[\n\\frac{\\sum_{i=1}^n x_i^2}{t}\\geq \\left(\\frac{x_1+\\dotsm + x_t}{t}\\right)^2 = \\left( \\frac{1}{t} \\right)^2. \\qedhere\n\\]\n\\end{proof}\n\n\\begin{theorem} \\label{thm:lambda_G}\nIf $G$ has no $K_t$ subgraph, then $\\lambda(G) \\leq \\lambda(K_{t-1}) = \\frac{t-2}{2(t-1)}$.\n\\end{theorem}\n\\begin{proof}\t\nLet $p_G(\\bar x) = \\sum_{\\{i,j\\}\\in \\edges (G)} x_i x_j$. Then\n\\[\n\\lambda(G) = \\max_{\\substack{x_i\\geq 0 \\\\ \\sum_i x_i =1}} p_G(\\bar x).\n\\]\nChoose maximal $\\bar x$ so that $p_G(\\bar x) = \\lambda(G)$, and $\\#\\{i: x_i \\neq 0\\}$ is minimal.\nWe may assume that in fact $x_i>0$ for all $i$, by throwing away verticies with zero weights.\n\\begin{claim}\n$G$ is complete.\n\\end{claim}\n\\begin{remark}\nThis means the probability distribution was concentrated on a complete subgraph.\n\\end{remark}\n\\begin{subproof}[Proof of claim]\nSuppose $G$ is not complete. Then there exists $i,j\\in V(G)$ non-adjacent. We have\n\\begin{align*}\t\np_G(\\bar x) &= x_i \\overbrace{\\sum_{\\substack{k: \\\\ \\{k,i\\} \\in \\mathcal{G}(G)}} x_k}^{C_i} + x_j \\overbrace{ \\sum_{\\substack{k: \\\\ \\{k,j\\} \\in \\mathcal{G}(G)}} x_k}^{C_j} + \\overbrace{\\sum_{\\substack{\\{k,\\ell\\} \\in \\edges (G):\\\\ k,\\ell \\in V(G)\\setminus \\{i,j\\} }} x_k x_\\ell}^{b}.\n\\end{align*}\nAssume wlog that $C_j\\geq C_i$. Let $\\bar x'$ be obtained by setting $x'_i=0$ and $x'+j = x_i + x_j$, and the other $x'_k = x_k$ (for $k\\neq j$ and $k\\neq i$). Then $p_G(\\bar x') = (x_i+x_j) C_j + b \\geq x_i C_i + x_j C_j + b = p_G(\\bar x)$.\n\nThis is a contradiction: $\\bar x'$ has more zero values than $\\bar x$, but still acheives $\\lambda(G)$. But we choose $\\bar x$ to have the minimal number of non-zero values.\n % But since $\\bar x$ is maximal, we must have $C_i = C_j$.\n\\end{subproof}\nThen $G$ is complete, and so must be of size $t-1$.\n\\end{proof}\n\n\\begin{remark}\n \\Cref{thm:lambda_G} proves \\cref{thm:turan}.\n\\end{remark}\n\\begin{proof}\t\n\\[\n\\frac{|\\edges (G)|}{n^2}=p_G(\\frac{1}{n}, \\dotsc, \\frac{1}{n}) \\leq\\lambda(G) \\leq \\frac{t-2}{2(t-1)}.\\qedhere\n\\]\n\\end{proof}\n\\lect{2}{10}\n% \\marginnote{Lecture 11: Wednesday, February 10, 2016.}\n\nLet $K_{1,t}$ be the graph \\scalebox{.5}{\\begin{tikzpicture}[color=DarkBlue]\n\\node (rect) at (0,0)[draw,thick,minimum width=1cm, minimum height = 2cm, rounded corners=3pt,label=above:{$t$ vertices}]{};\n\n% \\node (rect2) at (2,0)[draw,thick,minimum width=1cm, minimum height = 2cm, rounded corners=3pt,label=above:$V(G)\\setminus U$]{};\n\n\\pgfmathsetseed{3}\n% \\def\\z{rand}\n\\foreach \\x in {1,...,5}\n{\n\\filldraw[black] (rand*.5,rand*1) circle (0.8pt) node(a\\x){};\n}\n% \\draw (a1) -- (a2);\n\n\\filldraw[black] (-2,.5) circle (1.2pt) node[left](u){};\n\n\n\n\\foreach \\x in {1,...,5}\n{\n\\draw (a\\x) -- (u);\n}\n\n% \\filldraw at (rect2)[draw, fill=black,circle(.4pt),above,label=above:$u$]{};\n\n\\end{tikzpicture}}.\nThen $\\pi(K_{1,t})= 0$, as follows:\nWe may bound\n\\[\t\n\\ex(n,K_{1,t}) \\leq \\frac{(t-1)n}{2}\n\\]\nbecause every vertex has degree $\\leq t-1$ if there is no $K_{t,1}$ subgraph.\n\n\n\nLet $K_{2,2}$ be the graph \n\\scalebox{.7}{\\begin{tikzpicture}[color=DarkBlue]\n\\filldraw[black] (0,0) circle (1.2pt) node(a1){};\n\n\\filldraw[black] (0,1) circle (1.2pt) node(a2){};\n\n\n\\filldraw[black] (1,0) circle (1.2pt) node(a3){};\n\\filldraw[black] (1,1) circle (1.2pt) node(a4){};\n\\draw (a3) -- (a4);\n\n\\draw (a1) -- (a2);\n\n\\draw (a2) -- (a3);\n\n\\draw (a1) -- (a4);\n\n\n\n% \\foreach \\x in {1,...,4}\n% {\n% \\foreach \\y in {1,...,2}\n% {\n% \\draw (a\\x) -- (a\\y);\n% }\n% }\n\n\\end{tikzpicture}}.\nIf $G$ has no $K_{2,t}$ then it has $\\leq (t-1){n\\choose 2}$ paths $P_3$ as subgraphs, but if $G$ has $\\epsilon {n\\choose 2}$ edges, we ``expect'' $\\geq \\epsilon^2 {n\\choose 3}$ paths $P_3$, so if $\\epsilon>0$ for large $n$, we get a contradiction.\nThus, $\\pi(K_{2,t})=0$.\n\n\n\n\\begin{theorem}\n$\\pi(K_{t,t})=0$ for every $t>1$.\n\\end{theorem}\n\\begin{remark}\nThis implies $\\pi(H)=0$ for every bipartite graph $H$.\n\\end{remark}\n\\begin{proof}\t\nWe need to show that for every $\\epsilon>0$ there exists $n_0$ such that if $G$ has no $K_{t,t}$ subgraph, and $n\\geq n_0$ verticies, then $|\\edges (G)|\\leq \\epsilon{n\\choose 2}$.\n\n\nSuppose that $|\\edges (G)|\\geq \\epsilon {n\\choose 2}$.\n\n\n\n\\begin{figure}\n\\begin{center}\n\\begin{tikzpicture}[color=black]\n\n\\node (rect) at (0,0)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt, label=left:$t$]{};\n\n\\node (rect2) at (0,1.5)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt,label=left:$t$]{};\n\n\\pgfmathsetseed{4}\n% \\def\\z{rand}\n\\foreach \\x in {1,...,5}\n{\n\\filldraw (rand*1.4,rand*.3) circle (0.4pt) node(a\\x){};\n\\filldraw (rand*1.4,1.5+rand*.3) circle (0.4pt) node(b\\x){};\n\n}\n\n\\foreach \\x in {1,...,5}\n{\n% \\ifthenelse{\\x > 1}{\\draw[dashed] (a\\x) -- (u)}{};\n\\foreach \\y in {1,...,\\x}\n{\n\\draw (a\\x) -- (b\\y);\n}\n}\n\n\\end{tikzpicture}\n\\end{center}\n\\caption[][0cm]{Left. The bipartite graph on $n$ verticies. We divide the graph into independent sets of size $n/2$, then connect each vertex in the upper set to each vertex in the lower set. This produces $(n/2)^2$ edges and no triangles. \\label{fig:bipartite2}}\n\\end{figure}\n\nSet\n\\[\nf(G) = \\sum_{\\{v_1,v_2,\\dotsc,v_t\\}\\subset V(G)^{(t)}} | N(v_1)\\cap N(v_2)\\dotsm \\cap N(v_t)| \\leq (t-1){n\\choose t}\n\\]\nwhere $N(v)$ is the set of neighbors of $v$ in $G$: that is, $N(v) = \\{u\\in V(G): \\{u,v\\} \\in \\edges (G) \\}$.\n\n\n\nWe are counting subgraphs of the form\n\\begin{tikzpicture}[color=black]\n\n\\node (rect) at (0,0)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt, label=left:$t$]{};\n\\filldraw (0,1.5) circle (0.4pt) node[above](u){$u$};\n\n% \\node (rect2) at (0,1.5)[draw,thick,minimum width=3cm, minimum height = 1cm, rounded corners=3pt,label=left:$t$]{};\n\n\\pgfmathsetseed{3}\n% \\def\\z{rand}\n\\foreach \\x in {1,...,6}\n{\n\\ifthenelse{\\x>5}{\n\\filldraw (rand*1.4,rand*.3) circle (0.4pt) node(a\\x){$v_t$};\n\t\n}{\n\\ifthenelse{\\x<3}{\n\n\\filldraw (rand*1.4,rand*.3) circle (0.4pt) node(a\\x){$v_\\x$}; }{\n\t\\filldraw (rand*1.4,rand*.3) circle (0.4pt) node(a\\x){};\n};\n\t\n};\n% \\filldraw (rand*1.4,1.5+rand*.3) circle (0.4pt) node(b\\x){};\n\n}\n\n\\foreach \\x in {1,...,6}\n{\n% \\ifthenelse{\\x > 1}{\\draw[dashed] (a\\x) -- (u)}{};\n\\foreach \\y in {1,...,\\x}\n{\n\\draw (a\\x) -- (u);\n}\n}\n\n\\end{tikzpicture}.\n\nFirst, note\n\\[\n{m\\choose t} \\geq \\frac{m^t}{t!} - cm^{t-1}\n\\]\nfor some constant $c$ depending on $t$ only.\n\nThen,\n\\begin{align*}\t\nf(G) &= \\sum_{u\\in V(G)} {\\deg (u) \\choose t} \\geq \\sum_{u\\in V(G)} \\left( \\frac{\\deg^t(u)}{t!}- c \\deg^{t-1}(u) \\right)\\\\\n\\intertext{where we've used Jensen's for $t$th powers. Then,}\n&\\geq \\frac{n}{t!} \\left( \\sum_{u\\in V(G)} \\frac{\\deg(u)}{n} \\right)^t - cn^t\\\\\n&\\geq \\frac{n}{t!} \\left( \\frac{2 \\epsilon {n\\choose 2}}{n} \\right)^t - cn^t\\\\\n\\intertext{Using $2 \\epsilon {n\\choose 2} \\geq \\frac{\\epsilon}{2}n^2$}\n&\\geq \\frac{n}{t!}\\left( \\frac{\\epsilon}{2}n \\right)^t - cn^t\\\\\n& \\boxed{>} (t-1) {n \\choose t}\n\\end{align*}\nwhere the boxed inquality yields a contradiction, and holds for large enough $t$.\n\\end{proof}\n\n\nIf $H$ is not bipartite, is it possible $\\pi(H)=0$? No, there exist large ``dense'' graphs with no $H$ subgraph.\nFor every non-bipartite graph, the Tur\\'an density is at least 1/2, for the same reason as $K_3$: it cannot be embedded in a large complete bipartite graph, so these graphs\\sidenote[][-2cm]{which have density 1/2} witness this.\n\n\nLet us consider graphs which are not subgaphs of the Tur\\'an graph $T_{3}(n)$ (depicted in \\cref{fig:T3}): \nIf $H$ is not a subgraph of $T_3(n)$ for any $n$, then $\\pi(H)\\geq \\frac{2}{3}$. Let us generalize.\n\\begin{marginfigure}[-2cm]\n\\begin{center}\n\\begin{tikzpicture}[scale=.5]\n\\begin{scope}\n% \\node[left] at (0,0) {$\\circlearrowleft$};\n\n\n\\foreach \\y in {1,...,3}\n{\n\\foreach \\z in {1,...,\\y}\n{\n\\pgfmathsetmacro\\myangley{-1*\\y*120+90}\n\\pgfmathsetmacro\\myanglez{-1*\\z*120+90}\n\\draw (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=8pt,yshift=2pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n}\n}\n % do a few by hand\n \\pgfmathsetmacro\\myangley{-1*3*120+90}\n \\pgfmathsetmacro\\myanglez{-1*5*120+90}\n% \\draw (\\myangley:3cm) -- (\\myanglez:2.9cm);\n\n\n\n\\foreach \\x in {1,...,6}\n{\n \\pgfmathsetmacro\\myangle{-1*\\x*120+90}\n\n\\ifthenelse{\\x > 1}{\n\\filldraw[white] (\\myangle:3cm) circle (20pt);\n\\draw[black] (\\myangle:3cm) circle (20pt) node{$\\frac{n}{3}$\n};\n}{\n\\filldraw[white] (\\myangle:3cm) circle (10pt);\n\\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n};\n\n}\n\n\n%  \\pgfmathsetmacro\\myangle{-1*60+90}\n% \\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\\caption{The Tur\\'an graph $T_3(n)$.} \\label{fig:T3}\n\\end{marginfigure}\n\n\n% \\begin{definition}%[$k$-coloring, $\\chi(G)$]\n We say $c\\!\\!: V(G) \\to [k]$ is a \\defn{$k$-coloring} if $c(u)\\neq c(v)$ for every $\\{u,v\\}\\in \\edges (G)$.\n\nWe write $\\chi(G)$ for the minimum $k$ such that $G$ admits a $k$-coloring. With this definition in hand, we may formulate the following result.\n% \\end{definition}\n\\begin{lemma} \\label{lem:min_Tur\\'an_density_2graphs}\nIf $H$ contains an edge,\n\\[\n\\pi(H)\\geq \\frac{\\chi(H)-2}{\\chi(H)-1}.\n\\]\n\\end{lemma}\n\n\\begin{proof}\t\nLet $k = \\chi(H)-1$. As $H$ is not $k$-colorable, $H$ is not a subgraph of any Tur\\'an graph $T_k(n)$ and so $\\pi(H)\\geq \\lim_{n\\to\\infty} \\frac{|\\edges (T_k(n))|}{{n\\choose 2}} = \\frac{k-1}{k}$.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:subgraph_with_min_vertex_degree}\nFor every $r$, $n_0$, and $\\epsilon$, there exists $N$ such that if $G$ is an $r$-graph with $|V(G)| = n\\geq N$ and $|\\edges (G)|\\geq d {n\\choose r}$, then $G$ contains a subgraph (sub $r$-graph) $G'$ such that\n\\[\n|V(G')| =n' \\geq n_0\n\\]\nand every vertex $v\\in V(G')$ belongs to at least $(d - \\epsilon) {n' \\choose r-1}$ edges.\n\\end{lemma}\n\\marginnote{So we can  restrict to a (large) subgraph to obtain a minimal bound on vertex degree, at the cost of $\\epsilon$ density. }\n\\begin{proof}\t\nSuppose not. Then there exists a vertex $v_1\\in V(G)$ such that $v_1$ belongs to at most $(d - \\epsilon) {n \\choose r-1}$ edges. Delete this vertex to obtain a graph $G_1$ which in turn has a vertex $v_2$ in at most $(d- \\epsilon){n-1 \\choose r-1}$ edges. Delete this vertex to obtain $G_2$, and continue in the same manner.\n\nWe eventually arrive at a graph $G_{n-n_0}$ on $n_0$ verticies. Then\n\\begin{fullwidth}\n\\begin{align*}\t\nd {n \\choose r} &\\leq |G| \\\\\n&\\leq (d -\\epsilon){n\\choose r-1} + (d- \\epsilon) {n-1 \\choose r-1} + \\dotsm + (d- \\epsilon){n_0+1 \\choose r-1} + \\underbrace{|G_{n-n-0}|}_{\\leq {n_0\\choose r}}.\n\\end{align*}\nIt remains to show that for $n$ large enough (in terms of $n_0,r,\\epsilon$)\n\\[\nd {n \\choose r} > (d- \\epsilon) \\left[{n\\choose r-1} +  {n-1 \\choose r-1} + \\dotsm + {n_0+1 \\choose r-1}  \\right] + {n_0 \\choose r}.\n\\]\nBut, repeating the Pascal's triangle inequality,\n\\[\n{n\\choose r} = {n-1 \\choose r-1} + {n-2\\choose r-1} + {n-3 \\choose r-1} + \\dotsm + {r-1 \\choose r-1}.\n\\]\nSo,\n\\[\nd {n\\choose r} = (d - \\epsilon) \\left( {n-1 \\choose r-1} + {n-2\\choose r-1} + {n-3 \\choose r-1} + \\dotsm + {r-1 \\choose r-1} \\right) + \\epsilon {n\\choose r}.\n\\]\n\\end{fullwidth}\n\nThis eliminates most terms; we are left with\n\\[\n\\epsilon {n\\choose r} \\overset{?}{>} (d- \\epsilon) {n\\choose r-1} + {n_0 \\choose r}.\n\\]\nBut the polynomial in $n$ on the left has degree $r$, and on the right, degree $r-1$, so for $n\\geq N$ with $N$ large enough, we have strict inequality.\n\n\\end{proof}\n\n\\begin{theorem}[\\cite{erdos-stone}]\n\\[\n\\pi(H) = \\frac{\\chi(H)-2}{\\chi(H)-1}\n\\]\nfor every $2$-graph $H$ with $\\chi(H)\\geq 2$\\marginnote{I.e. $H$ contains an edge.}.\n\\end{theorem}\n\\begin{proof}\t\n\\Cref{lem:min_Tur\\'an_density_2graphs} gives the lower bound. Now, consider $K_{\\underbrace{t,\\dotsc,t}_{k \\text{ times}}}$ the complete $k$-partite graph with parts of size $t$, as depicted in \\cref{fig:Ktttt}.\n\\begin{figure}\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{scope}\n% \\node[left] at (0,0) {$\\circlearrowleft$};\n\n\n\\foreach \\y in {1,...,6}\n{\n\\foreach \\z in {1,...,\\y}\n{\n\\pgfmathsetmacro\\myangley{-1*\\y*60+90}\n\\pgfmathsetmacro\\myanglez{-1*\\z*60+90}\n\\draw (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=8pt,yshift=2pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n}\n}\n % do a few by hand\n \\pgfmathsetmacro\\myangley{-1*3*60+90}\n \\pgfmathsetmacro\\myanglez{-1*5*60+90}\n% \\draw (\\myangley:3cm) -- (\\myanglez:2.9cm);\n\n\n\n\\foreach \\x in {1,...,6}\n{\n \\pgfmathsetmacro\\myangle{-1*\\x*60+90}\n\n\\ifthenelse{\\x > 1}{\n\\filldraw[white] (\\myangle:3cm) circle (20pt);\n\\draw[black] (\\myangle:3cm) circle (20pt) node{$t$\n};\n}{\n\\filldraw[white] (\\myangle:3cm) circle (10pt);\n\\draw (\\myangle:3cm) node[auto]{\\ldots};\n};\n\n}\n\\draw (3,3) node[auto]{$k$ parts};\n\n\n%  \\pgfmathsetmacro\\myangle{-1*60+90}\n% \\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\\caption{An illustration of $K_{tt\\dotsm  t}$, where there are $k$ $t$'s in the subscript. This means we have $k$ independent sets of size $t$, and each vertex of each independent set is connected to all the vertices in all the other sets.  \\label{fig:Ktttt}}\n\\end{figure}\n\n\nFor every $t$,\n\\[\t\n\\pi(K_{t,\\dotsc,t}) \\leq \\frac{k-2}{k-1}\n\\]\nby induction on $k$. Suppose for some $k$, and some $t$,\n\\[\t\n\\pi(K_{\\underbrace{t,\\dotsc,t}_{k \\text{ times}}}) \\geq \\frac{k-2}{k-1} + \\epsilon.\n\\]\nfor $\\epsilon>0$. It is enough to show that for every graph $G$ with $n$ vertices such that\n\\[\t\n|\\edges (G)| \\geq \\left( \\frac{k-2}{k-1}+ \\epsilon \\right) {n\\choose 2},\n\\]\nwe must have that $G$ contains $K_{\\underbrace{t,\\dotsc,t}_{k \\text{ times}}}$.\n\nBy \\cref{lem:subgraph_with_min_vertex_degree} we may assume that every vertex of $G$ has degree\n\\[\t\n\\geq \\left(  \\frac{k-2}{k-1} + \\frac{\\epsilon}{2} \\right)n.\n\\]\nBy the induction hypothesis, $G$ contains $K_{\\underbrace{s,\\dotsc,s}_{k-1 \\text{ times}}}$ for every $s$. We will choose a particular $s$ depending only on $k$ and $\\epsilon$, which we will specify later.\n\nIt suffices to prove that if $n$ is large compared to $s,k, \\epsilon$, and $s$ is large compared to $k, t$ and $\\epsilon$, and $G$ is a graph with $n$ vertices, and each vertex has degree at least $\\left(  \\frac{k-2}{k-1} + \\frac{\\epsilon}{2} \\right)n$ , and $G$ contains a complete $k-1$-partite subgraph with $s$ vertices in each part, then $G$ contains a complete $k$-partite subgraph with $t$ vertices.\n\\lect{2}{15}\n% \\marginnote{Lecture 12: Monday, February 15, 2016.}\n\nLet $A_1,A_2,\\dotsc,A_{k-1} \\subset V(G)$ with $|A_i| = s$ such that every vertex of $A_i$ is adjacent to every vertex of $A_j$ when $i\\neq j$ \\marginnote{Such a group of sets is simply $K_{\\underbrace{s,\\dotsc,s}_{k-1 \\text{ times}}}$ and exists by the induction hypothesis.}\nLet $U = A_1\\cup \\dotsc \\cup A_{k-1}$ and let $W$ be the set of verticies in $V(G)$ which have $\\geq t$ neighbors in each $A_i$.\n\n\\begin{figure}\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{scope}\n% \\node[left] at (0,0) {$\\circlearrowleft$};\n\n\\def\\n{4}\n\\def\\radius{.6}\n\\def\\rotation{90}\n\n\\def\\deg{360/\\n}\n\\pgfmathsetmacro\\nminusone{\\n-1}\n\n \\pgfmathsetmacro\\myangle{-1*.5*\\deg+\\rotation}\n\n\\filldraw[white] (\\myangle:5.5cm) circle (10pt);\n\\draw (\\myangle:5.5cm) node[auto](w){$W$};\n\n\n% do first one\n\\pgfmathsetmacro\\myangley{-1*\\deg+\\rotation}\n\\draw (\\myangley:3cm) -- (w);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (w) node[near end,auto]{$\\geq t$};\n\n% do the rest\n\\foreach \\y in {2,...,\\n}\n{\n\\pgfmathsetmacro\\yminusone{\\y-1}\n\n\\foreach \\z in {1,...,\\yminusone}\n{\n\\pgfmathsetmacro\\myangley{-1*\\y*\\deg+\\rotation}\n\\pgfmathsetmacro\\myanglez{-1*\\z*\\deg+\\rotation}\n\\draw (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (\\myanglez:3cm);\n\\draw[xshift=8pt,yshift=2pt] (\\myangley:3cm) -- (\\myanglez:3cm) node[midway,auto]{$s^2$};\n\n\n\\draw (\\myangley:3cm) -- (w);\n\\draw[xshift=4pt,yshift=-1pt] (\\myangley:3cm) -- (w) node[near end,auto]{$\\geq t$};\n\n}\n}\n % do a few by hand\n % \\pgfmathsetmacro\\myangley{-1*3*120+90}\n % \\pgfmathsetmacro\\myanglez{-1*5*120+90}\n% \\draw (\\myangley:3cm) -- (\\myanglez:2.9cm);\n\n\n\n\\foreach \\x in {1,...,\\n}\n{\n \\pgfmathsetmacro\\myangle{-1*\\x*\\deg+\\rotation}\n\n\\ifthenelse{\\x = \\nminusone}{\n\\filldraw[white] (\\myangle:3cm) circle (10pt);\n\\draw (\\myangle:3cm) node[auto]{$\\ldots$};\n}{\n\\ifthenelse{\\x = \\n}{\n\\filldraw[white] (\\myangle:3cm) circle (20pt);\n\\draw[black] (\\myangle:3cm) circle (20pt) node{$A_{k-1}$};\n}{\n\\filldraw[white] (\\myangle:3cm) circle (20pt);\n\\draw[black] (\\myangle:3cm) circle (20pt) node{$A_\\x$};\n}\n};\n\n}\n\\end{scope}\n\\end{tikzpicture}\n\\end{center}\n\\end{figure}\nNow, we wish to show $w:= |W|$ is large. First,\n\\begin{align*}\t\n\\left( \\frac{k-2}{k-1}+ \\epsilon \\right)n(k-1)s &\\leq  \\sum_{v\\in U}\\deg(v) \\leq \\sum_{v\\in V(G)} |N(v)\\cap U|\\\\\n&\\leq \\underbrace{w s(k-1)}_{\\text{from verticies in }W} + \\underbrace{(n-w) (s(k-2)+t)}_{\\text{from verticies not in }W}\\\\\n% &= wsn - ws + ns - n(k-2) + nt - ws + w(k-2) - wt\\\\\n% &= wsn - ws + ns - nk + 2n + nt -ws +wk - 2w - wt\\\\\n((k-2) + \\epsilon (k-1)) n s &\\leq ns (k-2) + nt + w(s-t)\n\\end{align*}\nIf we choose $s$ such that $\\epsilon (k-1) s -t \\geq 1$, then\n\\[\n% &= nsk - 2ns + nt + ws - wt\nn \\leq n( \\epsilon (k-1)s - t) \\leq w (s-t) \\leq ws.\n\\]\nThen $W\\geq \\frac{n}{s}$. For each $v\\in W$ let $(B_1^v,B_2^v,\\dotsc,B_{k-1}^v)$ be the sets of neighbors of $v$ of size $t$ such that $B_i \\subset A_i$. There are ${s \\choose t}^{k-1}$ choices of these sequences of neighbors, so if $w > \\underbrace{s(k-1)}_{\\text{vertices in }U}+ (t-1) {s \\choose t}^{k-1}$ \\marginnote{So $|W\\setminus U| \\geq |W| - |U| \\geq (t-1) {s \\choose t}^{k-1}$.} then by pigeonhole principle, there exists $t$  entries in $W\\setminus U$ which have the same $t$ neighbors in each of the $A_i$, as desired.\\qedhere\n\n\\marginnote{The entries in $W\\setminus U$ don't need to be independent, because we just need a subgraph, so we can just not include those edges in our subgraph.}\n\n\n\\end{proof}\n% section turian_type_problems (end)", "meta": {"hexsha": "b294b11431be168996dbf2e97656c95c812409fd", "size": 34508, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/ch5_turan.tex", "max_stars_repo_name": "ericphanson/CombinatoricsNotes", "max_stars_repo_head_hexsha": "6b369a77b77cf6f0281b59f227aaa31e6903079c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-04-24T06:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-20T04:27:41.000Z", "max_issues_repo_path": "chapters/ch5_turan.tex", "max_issues_repo_name": "Marathe/CombinatoricsNotes", "max_issues_repo_head_hexsha": "6b369a77b77cf6f0281b59f227aaa31e6903079c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/ch5_turan.tex", "max_forks_repo_name": "Marathe/CombinatoricsNotes", "max_forks_repo_head_hexsha": "6b369a77b77cf6f0281b59f227aaa31e6903079c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-09-19T20:45:49.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-19T20:45:49.000Z", "avg_line_length": 36.78891258, "max_line_length": 538, "alphanum_fraction": 0.6392430741, "num_tokens": 13901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.546738151984614, "lm_q2_score": 0.7853085834000791, "lm_q1q2_score": 0.42935816362581436}}
{"text": "\\documentclass{article}\n\\usepackage[linesnumbered, lined, boxed]{algorithm2e} \n\\usepackage[]{geometry} \n\n\\begin{document}\n\\title{Notes on N-Queens Solutions}\n\\author{Robert Dougherty-Bliss}\n\\date{\\today}\n\\maketitle\n\nThe $n$-queens problem is this: Given an $n \\times n$ chessboard, can $n$\nqueens be placed on it such that no queen can attack another? The answer,\nproved by E.~Pauls in 1874, is yes, for $n = 1$ and $n > 3$\n\\cite{jordanbell07}. We list some notes on the running times of various\nsolutions.\n\n\\section*{Running Times}\n\\label{sec:running_times}\n\nHere we will list various solutions to the $n$-queens problem and compare their\nrunning times. Included with each are pseudocode algorithms.\n\n\\begin{table}[h]\n \\caption{Running Time of $n$-Queens Solutions}\n \\centering\n \\begin{tabular}{lc}\n     \\hline\n     Combinatoric Brute Force & $O(n^2(n^2!))$ \\\\\n     Row-based Brute Force & $O(n^{n+2})$ \\\\\n     Backtracking & $O(n!)$ \\\\\n     Explicit Solution & $O(n)$ \\\\\n     \\hline\n \\end{tabular}\n\\end{table}\n\n\\subsection*{Guarded Check}\n\\label{sub:guarded_check}\n\nSome of the solutions check if a given answer is a solution. Here is an\n$O(n^2)$ algorithm to check if this is true.\n\nFirst, some definitions. The $n \\times n$ chessboard is represented as $[0, n-1]\n\\times [0, n-1]$, indexed by row-column points $(r, c)$. The row $r = 0$ is the\ntop of the board, and the column $c = 0$ is the leftmost column.\n\nThe $k$th sum diagonal on a chess board is the set of points $(r, c)$ on the\nboard such that $r + c = k$. The $k$th difference diagonal is the set of points\n$(r, c)$ on the board such that $r - c = k$. Sum diagonals run from bottom-left\nto top-right, and difference diagonals run from top-left to bottom-right.\n\nQueens on a chessboard guard their rows, columns, and diagonals. That motivates\nthe definition of a \\textit{guarded point}. Given a point $P(r, c)$ and a set\nof queens $Q$, the point $P$ is guarded by $Q$ iff there exists some $R(a, b)\n\\in Q$ such that $R$ and $P$ share a column, row, or diagonal. That is, iff $a\n+ b = r + c$, $a - b = r - c$, $a = r$, or $b = c$. In the worst-case for a set\nof $n$ queens, the running time of checking if a point is guarded is $O(n)$. To\ncheck if an answer is a solution, simply perform this check against all $n$\npoints, which is $O(n)O(n) = O(n^2)$.\n\n\\begin{algorithm}\n    \\caption{Guarded Check}\n    \\KwIn{$P(r, c)$, a point, and $Q$, a set of queens}\n    \\KwOut{True if $P$ is guarded by $Q$, False if not}\n\n    \\ForEach{$(a, b)$ in $Q$}{\n        \\If{$a + b = r + c$ or $a - b = r - c$}{\n            \\Return{True}\\;\n        }\n        \\If{$a = r$ or $b = c$}{\n            \\Return{True}\\;\n        }\n    }\n\n    \\Return{False}\\;\n\\end{algorithm}\n\n\\subsection*{Combinatoric Brute Force}\n\\label{sub:combinatoric_brute_force}\n\nA first attempt to solve the $n$-queens problem might be to try every possible\ncombination of $n$ distinct points from an $n \\times n$ chessboard. This gives\n$${n^2 \\choose n} = \\frac{n^2!}{n!(n^2 - n)!}$$ possible combinations. For all\n$n \\geq 1$, we have that $n^2 - n \\geq 0$, so $n!(n^2 - n)! \\geq 1$. So for all\n$n \\geq 1$, $$\\frac{n^2!}{n!(n^2 - n)!} \\leq n^2!$$ That is, to enumerate every\npossible combination is $O(n^2!)$. But we also need to check if each combination\nis a solution, which is $O(n^2)$. So the total worst-case running time of this\nsolution is $O(n^2!)O(n^2) = O(n^2(n^2!))$.\n\n\\begin{algorithm}\n    \\caption{Combinatoric Brute Force}\n    \\KwIn{$n$, a non-negative integer}\n    \\KwOut{A set of $(r, c)$ points that solve the $n$-queens problem, or an\n              empty set if no solution exists}\n\n    $combinations \\leftarrow$ $[0, n-1] \\times [0, n-1]$\\;\n    \\ForEach{answer in combinations}{\n        solved $\\leftarrow$ True\\;\n        \\ForEach{point in answer}{\n            \\If{point is guarded by rest of answer}{\n                solved $\\leftarrow$ False\\;\n                break\\;\n            }\n        }\n\n        \\If{solved}{\n            \\Return{answer}\\;\n        }\n    }\n\\end{algorithm}\n\n\\subsection*{Row-Based Brute Force}\n\\label{sub:row_based_brute_force}\n\nAn improvement on the previous technique is to note that no solution has two\nqueens placed in the same row. Then, restrict the queens from being placed in\nthe same row. There are $n$ choices for the first row, $n$ for the second, and\nso on until the $n$th row. That gives $$\\underbrace{n \\times n \\times n \\times\n\\cdots \\times n}_{n \\ \\rm times} = n^n$$ combinations to check. To enumerate all\nof these is $O(n^n)$, but we also need to check each, which is $O(n^2)$. Thus the\nworst case running time is $O(n^n)O(n^2) = O(n^{n+2})$. The solution algorithm is\nidentical except for the method of generating combinations.\n\n\\subsection*{Backtracking}\n\\label{sub:backtracking}\n\nAnother improvment is to use backtracking. This method starts by placing a queen\nat $(0, 0)$, then moving to the next row. Once a non-guarded point is found on\nthat row, place a queen there, and move to the next row. Do this until there are\n$n$ queens placed.\n\nIf every point on a row is guarded, then move back one row and delete the queen\nthere. Then attempt to find another non-guarded point in that row. If there are\nnone, move back another row, and attempt to delete and move the queen there. If\nthe queen in the first row is moved past the end of its row, then there is no\nsolution possible.\n\nIn the worst case, this will search roughly $n$ points in the first row, then\n$n - 1$ in the next, and so on, so the worst-case running time is $O(n!)$.\n\n\\begin{algorithm}[H]\n    \\caption{Backtracking}\n    \\KwIn{$n$, a non-negative integer}\n    \\KwOut{A set of $(r, c)$ points that solve the $n$-queens problem, or an\n              empty set if no solution exists}\n\n    place queen at $(0, 0)$\\;\n    (row, col) $\\leftarrow$ (0, 0)\\;\n\n    \\While{number of queens $\\neq n$}{\n        \\If{(row, col) is not guarded}{\n            place a queen at (row, col)\\;\n            (row, col) $\\leftarrow$ (row + 1, 0)\\;\n        } \\Else {\n            \\While{col $= n - 1$}{\n                \\If{row $= 0$}{\n                    \\tcc{End of first row.}\n                    \\Return{no solution}\n                }\n                \\tcc{End of current row; backtrack until we can move the\n                previous queen.}\n                (row, col) $\\leftarrow$ previous queen\\;\n                delete previous queen\\;\n            }\n\n            col $\\leftarrow$ col + 1\\;\n        }\n    }\n\\end{algorithm}\n\n\\subsection*{Explicit Solution}\n\\label{sub:explicit_solution}\n\nThis solution is due to Pauls, discussed in \\cite{jordanbell07}. Pauls breaks\ndown $n > 3$ by congruence classes modulo 6, then offers a solution for each of\nthem. This requires one comparison, and then the creation of a number of sets\nthat are joined together. The number of elements in the sets are linear in $n$,\nand so this solution is $O(n)$. Note that for Pauls the board is $[1, n] \\times\n[1, n]$ instead of $[0, n-1] \\times [0, n-1]$. An outline of Pauls proof is\ngiven by \\cite{jordanbell07}. Another soluion and proof is given by\n\\cite{hoffman69}.\n\n\\begin{algorithm}[H]\n    \\caption{Pauls' Explicit Solution}\n    \\KwIn{$n$, a non-negative integer}\n    \\KwOut{A set of $(r, c)$ points that solve the $n$-queens problem, or an\n              empty set if no solution exists}\n\n    \\If{$n = 1$}{\n        \\Return{$\\{(1, 1)\\}$}\n    }\n\n    \\If{$n = 2, 3$}{\n        \\Return{$\\emptyset$}\\;\n    }\n\n    \\Switch{$n \\bmod 6$}{\n        \\Case{0, 4}{\n            $A1 = \\{(2k, k) : 1 \\leq k \\leq n/2\\}$\\;\n            $A2 = \\{(2k - 1, n/2 + k) : 1 \\leq k \\leq n/2\\}$\\;\n            \\Return{$A1 \\cup A2$}\\;\n        }\n        \\Case{1, 5}{\n            $B1 = \\{(n, 1)\\}$\\;\n            $B2 = \\{(2k, k + 1) : 1 \\leq k \\leq (n-1)/2\\}$\\;\n            $B3 = \\{(2k - 1, (n+1)/2 + k) : 1 \\leq k \\leq (n-1)/2\\}$\\;\n            \\Return{$B1 \\cup B2 \\cup B3$}\\;\n        }\n        \\Case{2}{\n            $C1 = \\{(4, 1)\\}$\\;\n            $C2 = \\{(n, n/2 - 1)\\}$\\;\n            $C3 = \\{(2, n/2)\\}$\\;\n            $C4 = \\{(n-1, n/2 + 1)\\}$\\;\n            $C5 = \\{(1, n/2 + 2)\\}$\\;\n            $C6 = \\{(n - 3, n)\\}$\\;\n            $C7 = \\{(n - 2k, k + 1) : 1 \\leq k \\leq n/2 - 3\\}$\\;\n            $C8 = \\{(n - 2k - 3, n/2 + k + 2) : 1 \\leq k \\leq n/2 - 3\\}$\\;\n            \\Return{$C1 \\cup C2 \\cup C3 \\cup C4 \\cup C5 \\cup C6 \\cup C7 \\cup C8$}\\;\n        }\n        \\Case{3}{\n            \\Return{$\\{(n, n)\\} \\cup  ($solution for $n - 1)$}\\;\n        }\n    }\n\\end{algorithm}\n\n\\pagebreak\n\n\\begin{thebibliography}{9}\n\n\\bibitem{jordanbell07}\n    Bell, Jordan, and Stevens, Brett,\n    2007:\n    A survey of known results and research areas for n-queens,\n    \\emph{Discrete Math},\n    \\textbf{309},\n    1--31.\n\n\\bibitem{hoffman69}\n    E.J. Hoffman, and J.C. Loessi, and R.C. Moore,\n    1969:\n    Constructions for the Solution of the m Queens Problem,\n    \\emph{Math. Mag.},\n    \\textbf{42},\n    66--72\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "04fcbdf9d8f34c83df839d07de1089ed86eb3006", "size": 8886, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes.tex", "max_stars_repo_name": "rwbogl/n-queens", "max_stars_repo_head_hexsha": "848606ef2a89d3a70509b37c6a42d61551ddbf19", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes.tex", "max_issues_repo_name": "rwbogl/n-queens", "max_issues_repo_head_hexsha": "848606ef2a89d3a70509b37c6a42d61551ddbf19", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes.tex", "max_forks_repo_name": "rwbogl/n-queens", "max_forks_repo_head_hexsha": "848606ef2a89d3a70509b37c6a42d61551ddbf19", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.8306451613, "max_line_length": 83, "alphanum_fraction": 0.5988071123, "num_tokens": 2901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.42935816225223244}}
{"text": "\\documentclass[a4paper]{article}\r\n\r\n%% Language and font encodings\r\n\\usepackage[english]{babel}\r\n\\usepackage[utf8x]{inputenc}\r\n\\usepackage[T1]{fontenc}\r\n\r\n%% Sets page size and margins\r\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\r\n\r\n%% Useful packages\r\n\\usepackage{amsmath}\r\n\\usepackage{amsfonts}\r\n\\usepackage{graphicx}\r\n\\usepackage[colorinlistoftodos]{todonotes}\r\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\r\n\r\n\\title{Judson's Abstract Algebra: Chapter 7}\r\n\\date{}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\r\n\\section*{1}\r\n\r\nEncode IXLOVEXMATH using the cryptosystem in Example 66.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLAORYHAPDWK\r\n\r\n\r\n\\section*{2}\r\n\r\nDecode ZLOOA WKLVA EHARQ WKHA ILQDO, which was encoded using the cryptosystem in Example 66.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nWILLXTHISXBEXONTHEXFINAL\r\n\r\n\r\n\\section*{4}\r\n\r\nWhat is the total number of possible monoalphabetic cryptosystems? How secure are such systems?\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nThere are $26! - 1$ possible systems (we subtract one because of the identity permutation). They are relatively insecure because of frequency analysis and other methods.\r\n\r\n\r\n\\section*{5}\r\n\r\nProve that a  $2 \\times 2$ matrix $A$ with entries in $\\mathbb{Z}_{26}$ is invertible if and only if $\\gcd(\\det(A), 26) = 1$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nAssume that $A$ is invertible. This implies that there exists $A^{-1}$ such that $AA^{-1} = I$ which in turn implies\r\n\r\n$$\\det(A) \\det(A^{-1}) = 1.$$\r\n\r\nThis shows that $\\det(A) \\in U(26)$. It is true that all $x \\in U(26)$ are coprime to 26 and hence \r\n\r\n$$\\gcd(\\det(A), 26) = 1.$$\r\n\r\nAssume that $\\gcd(\\det(A), 26) = 1$. There exists integers $r$ and $s$ such that\r\n\r\n\\begin{align*}\r\n\\gcd(\\det(A), 26) &= \\gcd(ad - bc, 26) \\\\\r\n&= r(ad-bc) + 26s \\\\\r\n\\end{align*}\r\n\r\nHence $1 = r(ad-bc) + 26s$ rearranging yields\r\n\r\n$$r(ad - bc) = 1 - 26s.$$\r\n\r\nSince $s$ is an integer the right hand side is non-zero and hence $ad - bc \\neq 0$ which implies that $A$ is invertible.\r\n\r\n\r\n\\section*{6}\r\n\r\nGiven the matrix\r\n\r\n$$A = \\begin{pmatrix}\r\n3 & 4 \\\\\r\n2 & 3\r\n\\end{pmatrix},$$\r\n\r\nuse the encryption function $f(\\mathbf{p}) = A \\mathbf{p} + \\mathbf{b}$ to encode the message CRYPTOLOGY, where $\\mathbf{b} = (2,5)^t$. What is the decoding function?\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nThe ciphertext of the message is YIEULHOKKYPN. The decoding function is $f^{-1}(\\mathbf{p}) = A^{-1} (\\mathbf{p} - \\mathbf{b})$. Where \r\n\r\n$$A^{-1} = \\begin{pmatrix}\r\n3 & 4 \\\\\r\n2 & 3\r\n\\end{pmatrix}.$$\r\n\r\n\r\n\\section*{7}\r\n\r\nEncrypt each of the following RSA messages $x$ so that $x$ is divided into blocks of integers of length 2; that is, if $x = 142528$, encode 14, 25, 28 separately.\r\n\r\n$$n=3551, E=629, x=31$$\r\n\r\n$$y = 31^{629} \\mod 3551 = 2791$$\r\n\r\n$$n=2257, E=47, x=23$$\r\n\r\n$$y = 23^{47} \\mod 2257 = 769$$\r\n\r\n\r\n$$n=120979, E=13251, x=142371$$\r\n\r\n$$y_1= 14^{13251} \\mod 120979 = 112135$$\r\n$$y_2= 23^{13251} \\mod 120979 = 25032$$\r\n$$y_3= 171^{13251} \\mod 120979 = 442$$\r\n\r\n$$n=45629, E=781, x=231561$$\r\n\r\n$$y_1 = 23^{781} \\mod 45629 = 4438$$\r\n$$y_2 = 15^{781} \\mod 45629 = 16332$$\r\n$$y_3 = 61^{781} \\mod 45629 = 31594$$\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "44edb286ebda5f3e8a05d0c4e51199e8942dfddd", "size": 3153, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "judson-solutions/Chapter07.tex", "max_stars_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_stars_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-10-20T22:41:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-12T10:11:45.000Z", "max_issues_repo_path": "judson-solutions/Chapter07.tex", "max_issues_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_issues_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2017-10-19T17:09:07.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-26T03:44:24.000Z", "max_forks_repo_path": "judson-solutions/Chapter07.tex", "max_forks_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_forks_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-12T10:11:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-25T20:25:48.000Z", "avg_line_length": 23.5298507463, "max_line_length": 170, "alphanum_fraction": 0.6447827466, "num_tokens": 1108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.4292126367288826}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\section*{NYU Physics I---Problem Set 6}\n\nDue Thursday 2018 October 18 at the beginning of lecture.\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nIn lecture we dropped a pool ball from a height of about $1\\,\\m$. It\nbounced off of the cement floor. Roughly what was the impulse\ndelivered to the ball from the floor? Make reasonable assumptions! And\nremember that an impulse has a magnitude and a direction. And units!\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}\\label{elastic}%\nFinish the elastic collision problem we didn't finish in lecture on 2018-10-04:\n\n\\textsl{(a)}~Compute the momentum of each block, the kinetic energy of\neach block, and the total momentum and kinetic energy in the lab\nframe, before the collision.\n\n\\textsl{(b)}~Compute the center-of-mass velocity of the system by\ndividing the total momentum by the total mass. Draw the system (that\nis, label the blocks with their velocities and masses) in the\ncenter-of-mass frame, before the collision.\n\n\\textsl{(c)}~Compute the momentum of each block, the kinetic energy of\neach block, and the total momentum and kinetic energy in the\ncenter-of-mass frame, before the collision. The total momentum should\nbe zero; if it isn't, then you have made a misake.\n\n\\textsl{(d)}~In the center-of-mass frame, in an elastic collision, the\nonly option is for the momenta after to have the same magnitudes as\nthe momenta before, but with different directions. Since we are\nworking in one dimension, the only non-trivial option is to make the\nblocks bounce off of each other, and reverse their momenta. Reverse\nthem, and draw the system after the collision in the center-of-mass\nframe.\n\n\\textsl{(e)}~Compute the momentum of each block, the kinetic energy of\neach block, and the total momentum and kinetic energy in the\ncenter-of-mass frame, after the collision. Do your total numbers equal those\nin part \\textsl{(c)} above? They should!\n\n\\textsl{(f)}~Now invert the transformation you made in going from part\n\\textsl{(a)} to part \\textsl{(b)}; that is, transform \\emph{back} to\nthe lab frame. Draw the system in the lab frame, after the collision.\n\n\\textsl{(g)}~Compute the momentum of each block, the kinetic energy of\neach block, and the total momentum and kinetic energy in the lab\nframe, after the collision. Do your total numbers equal those in part\n\\textsl{(a)} above? They should!\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}\\label{blocks}%\nIn Problem Set 3, Problem 3, you computed an acceleration $a$ for the\nhanging block. Now consider the energy and work.\n\n\\textsl{(a)}~If the hanging block falls by a distance $h$, what is\nthe change in the potential energy of the hanging block, and how much\nwork is done by friction on the sliding block?\n\n\\textsl{(b)}~The work done by friction is \\emph{lost} to heat, so if\nthe system is released from rest and slides by a distance $h$, the\nkinetic energy of the system should rise to a value that is related to both the\npotential energy difference and the heat lost. Get that relationship\nright and compute the kinetic energy you expect the system to have\nwhen the hanging mass has dropped by a distance $h$.\n\n\\textsl{(c)}~Now interpret your answer in terms of an acceleration.\nThat is, compute the constant acceleration $a$ that would make the\nresult you computed in part \\textsl{(b)} work out right. You will have\nto use that $h = (1/2)\\,a\\,t^2$ and $v=a\\,t$, which are both relevant\nfor constant acceleration. Does your answer agree with what you got on\nProblem Set 3?\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nIn the static problem below, a beam is held horizontal by a diagonal\nstring (cable or tether), and a sign hangs from that beam. The beam is\nattached to the wall by a pivot that is effectively frictionless, and\nthe strings are (effectively) massless. What is the tension $T_1$ in\nthe upper string, and the force $\\vec{F}$ (give $x$ and $y$\ncomponents) on the beam at the pivot?\n\\\\ \\includegraphics{../mp/hanging_sign.pdf}\n\n\\paragraph{Extra \\problemname\\ (will not be graded for credit):}%\nRe-do \\problemname~\\ref{elastic}, but now for the left-hand block having\nmass $M$ and the right-hand block having mass $m\\ll M$; that is, solve\nthe extreme mass-ratio problem. For initial velocities, use $v$ for\nthe big block and $0$ for the small block. Then draw the before and\nafter pictures in the lab and center-of-mass frames, just as you did\nin \\problemname~\\ref{elastic}.\n\n\\paragraph{Extra \\problemname\\ (will not be graded for credit):}%\nIn \\problemname~\\ref{blocks}, It was useful to think about\nconservation of energy. Why \\emph{wasn't} it useful to think about\nconservation of momentum? What would we have had to take into account\nto think of this problem in terms of momentum?\n\n\\end{document}\n", "meta": {"hexsha": "beff3b20e3d75ba380bba8fefae136803aa14db3", "size": 4848, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/physics1_ps06.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/physics1_ps06.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/physics1_ps06.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.48, "max_line_length": 79, "alphanum_fraction": 0.7677392739, "num_tokens": 1261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621764862150636, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.4292126255280148}}
{"text": "\\definecolor {processblue}{cmyk}{0.96,0,0,0}\n\\clearpage\n\\section{Reaching Definitions Example}\n(Prepared by Namrata Priyadarshini, Shivam Bansal)\n\nWe've been looking at different types of data flow analyses and trying to tie them into a single framework. One of the data flow analysis that we looked at was reaching definitions and recall that a reaching definition basically is defined as follows:\nA definition D of the form x = y + z reaches a point P in the program if there exists a path from the point immediately following D to P such that D is not killed, in other words x is not overwritten along that path. \nSo even if there exists one such path where from the end of D to the beginning of P such that x has not been overwritten on that path then D would be considered to be to reach P. So let's look at this example:\n\n\\begin{figure}[h!]\n\\begin {center}\n\n\\begin{minipage}{.5\\textwidth}\n\\centering\n\\caption{Control Flow Graph}\n\\begin {tikzpicture}[-latex ,auto ,node distance =3.5cm and 5cm ,on grid ,\nsemithick ,\nstate/.style ={ rectangle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , scale = 0.7 ,minimum width =4 cm, minimum height = 4 cm}]\n\\node[state] (A){} node [label = {[label distance = 0.3cm]90:},rectangle split,rectangle split parts=1]{%\n  d1 : b=3\n  };\n\\node[state] (B) [below = of A]{} node [label = {[label distance = 0.3cm]90:}, rectangle split,rectangle split parts=1] [below = of A] {%\n  d2 : c = 3\n  };\n\\node[state] (D) [below =of B]{} node [label = {[label distance = 0.65cm]90:}, rectangle split,rectangle split parts=1] [below = of B] {%\n  d3 : c = 4\n  %\n  };\n\\path[->] (A) edge node [below=0.3cm] {} (B);\n\\path[->] (B) edge node [above=0.3cm] {}  (D); \n\\path[->] (B) edge [out=300,in=72,looseness=3] node[align = right][right] {} (B);\n% \\path[->] (B) edge [loop right] node {} (B) ;\n\\draw[->] (D) --++(0,-2.5cm) node [above left = 0.05cm] {} ;\n\\draw[<-] (A) --++(0,2.5cm) node [above left = 0.05cm] {} ;\n\\end{tikzpicture}\n\\end{minipage}%\n\\begin{minipage}{.5\\textwidth}\n\\centering\n\\caption{Reaching definitions}\n\\begin {tikzpicture}[-latex ,auto ,node distance =3.5cm and 5cm ,on grid ,\nsemithick ,\nstate/.style ={ rectangle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , scale = 0.7 ,minimum width =4 cm, minimum height = 4 cm}]\n\\node[state] (A){} node [label = {[label distance = 0.3cm]90:},rectangle split,rectangle split parts=3]{%\n  $\\Phi$\n  \\nodepart{second}\n  d1 : b=3\n  \\nodepart{third}\n  $\\{d1\\}$\n  };\n\\node[state] (B) [below = of A]{} node [label = {[label distance = 0.3cm]90:}, rectangle split,rectangle split parts=3] [below = of A] {%\n  $\\{d1,d2\\}$\n  \\nodepart{two}\n  d2 : c = 3\n  \\nodepart{three}\n  $\\{d1,d2\\}$\n  };\n\\node[state] (D) [below =of B]{} node [label = {[label distance = 0.65cm]90:}, rectangle split,rectangle split parts=3] [below = of B] {%\n  $\\{d1,d2\\}$\n  \\nodepart{two}\n  d3 : c = 4\n  \\nodepart{three}\n  $\\{d1,d3\\}$\n  %\n  };\n\\path[->] (A) edge node [below=0.3cm] {} (B);\n\\path[->] (B) edge node [above=0.3cm] {}  (D); \n\\path[->] (B) edge [out=300,in=72,looseness=3] node[align = right][right] {} (B);\n% \\path[->] (B) edge [loop right] node {} (B) ;\n\\draw[->] (D) --++(0,-2.5cm) node [above left = 0.05cm] {} ;\n\\draw[<-] (A) --++(0,2.5cm) node [above left = 0.05cm] {} ;\n\\end{tikzpicture}\n\\end{minipage}\n\\end{center}\n\\end{figure}\n\n\nIt has three definitions d1, d2, d3 and the reaching definitions are given in the figure. At the beginning, we initialize the boundary conditions to the empty set. Let us assume there's no reaching definitions in the beginning. Just after d1, it is only \\{d1\\} and just before d2 it's actually \\{d1,d2\\} because there's a path from d1 and then there's a path where d2 also reaches which is the path that takes the cycle.Then if we look at the end of d2 then it's also \\{d1,d2\\} because there are multiple paths that\ncan reach that allow d2 to reach this particular point. Before d3, it's \\{d1,d2\\} because both d1 and d2 can reach here and then at the very end it's \\{d1,d3\\} and d2 cannot reach here because notice that both d2 and d3 are assigning to c and d3 is overwriting the c so d3 is killing d2 and so d2 doesn't exist here. So two important things \n\\begin{itemize}\n    \\item \\{d1,d2\\} are present even before d2 because of the loop\n    \\item d2 is not present at the exit of the program because d3 has killed d2\n\\end{itemize}\n\n\\begin{table}\n\\centering\n\\caption{Reaching Definitions DFA}\n    \\begin{tabular}{ c|c}\n     Domain & Sets of Definitions \\\\\n     \\hline\n     Direction  & Forward  \\\\\n     \\hline\n     Transfer Function  & \\begin{tabular}[x]{@{}c@{}}$Out[B]=(in[B]-kill[B]) \\cup Gen[B]$ \\\\Gen: Locally exposed definition of B \\\\ Kill: Definitions overwritten by B \\end{tabular}  \\\\\n     \\hline\n     Meet Operator  & Set Union $\\cup$  \\\\\n     \\hline\n     Boundary Condition  & $Out[Entry]=\\Phi$  \\\\\n    \\end{tabular}\n\\end{table}\n\n\n\n\nIf we were to look at the data flow analysis for reaching definitions the domain is basically the sets of definitions. For example $\\{d1, d2, d3\\}$. Direction\nis forward. Transfer function $Out[B]=(in[B]-kill[B])$ where kill is defined by\nstatements that are uh overwriting an existing definition and gen is basically the new definition itself. So, kill is definitions over written by B, gen is the locally exposed definitions of B. So if we're talking about a basic block then it's about the locally exposed definitions. So definitions that have been made but have not been killed subsequently. Meet operator is union because we are looking at any such path so if there exists any such path we're going to consider it to reach. Boundary condition is $Out[Entry]=\\Phi$.\n\n\\section{Must Reach Definitions}\nSo now we are going to just change this analysis slightly just to show how the small differences can give you different analysis completely. So let's say we define an analysis called must reach definition which is defined as follows: a\ndefinition of the form x = y + z must reach point program point P if and only if D appears at least once along all paths leading to P and x is not redefined or in other words D is not killed along any path after the last appearance of D and before P. \n\n\nSo, basically on all possible paths D is reaching P and on none of those paths there's another statement that is killing D . So the last definition of x is because of D on all paths that are reaching P. So that's what must reach definitions says.\n\n\\begin{table}\n\\centering\n\\caption{Must Reach Definitions DFA}\n    \\begin{tabular}{ c|c}\n     Domain & Sets of Definitions \\\\\n     \\hline\n     Direction  & Forward  \\\\\n     \\hline\n     Transfer Function  & \\begin{tabular}[x]{@{}c@{}}$Out[B]=(in[B]-kill[B]) \\cup Gen[B]$ \\\\Gen: Locally exposed definition of B \\\\ Kill: Definitions overwritten by B \\end{tabular}  \\\\\n     \\hline\n     Meet Operator  & Set Intersection $\\cap$  \\\\\n     \\hline\n     Boundary Condition  & $Out[Entry]=\\Phi$  \\\\\n    \\end{tabular}\n\\end{table}\n\nData flow analysis of must reach definitions is identical with\nreaching definitions but just the meet operator has changed and instead of set\nunion it becomes set intersection and that's going to capture the fact that we want D to reach on all parts and not just any path and so the transfer function remains the same because once again we are interested in definitions that have not been killed but everything else remains the same. The boundary condition remains the same, the direction remains the same, the domains remain the same. Just the meat operator changes and we get a completely different analysis. So that's the power of this common framework you can just change one parameter and you don't have to rewrite the algorithm, you don't have to change anything else, you can just basically reuse the existing infrastructure.\n\n\\section{Must Reach Definitions Example}\n\n\\begin{figure}[h!]\n\\begin {center}\n\n\\begin{minipage}{.5\\textwidth}\n\\centering\n\\caption{Reaching definitions}\n\\begin {tikzpicture}[-latex ,auto ,node distance =3.5cm and 5cm ,on grid ,\nsemithick ,\nstate/.style ={ rectangle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , scale = 0.7 ,minimum width =4 cm, minimum height = 4 cm}]\n\\node[state] (A){} node [label = {[label distance = 0.3cm]90:},rectangle split,rectangle split parts=3]{%\n  $\\Phi$\n  \\nodepart{second}\n  d1 : b=3\n  \\nodepart{third}\n  $\\{d1\\}$\n  };\n\\node[state] (B) [below = of A]{} node [label = {[label distance = 0.3cm]90:}, rectangle split,rectangle split parts=3] [below = of A] {%\n  $\\{d1,d2\\}$\n  \\nodepart{two}\n  d2 : c = 3\n  \\nodepart{three}\n  $\\{d1,d2\\}$\n  };\n\\node[state] (D) [below =of B]{} node [label = {[label distance = 0.65cm]90:}, rectangle split,rectangle split parts=3] [below = of B] {%\n  $\\{d1,d2\\}$\n  \\nodepart{two}\n  d3 : c = 4\n  \\nodepart{three}\n  $\\{d1,d3\\}$\n  %\n  };\n\\path[->] (A) edge node [below=0.3cm] {} (B);\n\\path[->] (B) edge node [above=0.3cm] {}  (D); \n\\path[->] (B) edge [out=300,in=72,looseness=3] node[align = right][right] {} (B);\n% \\path[->] (B) edge [loop right] node {} (B) ;\n\\draw[->] (D) --++(0,-2.5cm) node [above left = 0.05cm] {} ;\n\\draw[<-] (A) --++(0,2.5cm) node [above left = 0.05cm] {} ;\n\\end{tikzpicture}\n\\end{minipage}%\n\\begin{minipage}{.5\\textwidth}\n\\centering\n\\caption{Must reach definitions}\n\\begin {tikzpicture}[-latex ,auto ,node distance =3.5cm and 5cm ,on grid ,\nsemithick ,\nstate/.style ={ rectangle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , scale = 0.7 ,minimum width =4 cm, minimum height = 4 cm}]\n\\node[state] (A){} node [label = {[label distance = 0.3cm]90:},rectangle split,rectangle split parts=3]{%\n  $\\Phi$\n  \\nodepart{second}\n  d1 : b=3\n  \\nodepart{third}\n  $\\{d1\\}$\n  };\n\\node[state] (B) [below = of A]{} node [label = {[label distance = 0.3cm]90:}, rectangle split,rectangle split parts=3] [below = of A] {%\n  $\\{d1\\}$\n  \\nodepart{two}\n  d2 : c = 3\n  \\nodepart{three}\n  $\\{d1,d2\\}$\n  };\n\\node[state] (D) [below =of B]{} node [label = {[label distance = 0.65cm]90:}, rectangle split,rectangle split parts=3] [below = of B] {%\n  $\\{d1,d2\\}$\n  \\nodepart{two}\n  d3 : c = 4\n  \\nodepart{three}\n  $\\{d1,d3\\}$\n  %\n  };\n\\path[->] (A) edge node [below=0.3cm] {} (B);\n\\path[->] (B) edge node [above=0.3cm] {}  (D); \n\\path[->] (B) edge [out=300,in=72,looseness=3] node[align = right][right] {} (B);\n% \\path[->] (B) edge [loop right] node {} (B) ;\n\\draw[->] (D) --++(0,-2.5cm) node [above left = 0.05cm] {} ;\n\\draw[<-] (A) --++(0,2.5cm) node [above left = 0.05cm] {} ;\n\\end{tikzpicture}\n\\end{minipage}\n\\end{center}\n\\end{figure}\n\nSo just to see an example to understand the difference between reaching definitions and must reach definitions let's take the same example with three definitions d1, d2, d3. d1 is assigning to b and d2 and d3 are assigning to c. Our reaching definitions is basically\nsomething that we have seen before. Reaching definitions and must reach definitions are same at all points but there's a difference just before d2. It's $\\{d1, d2\\}$ in reaching definitions but in must reach definitions it's only $\\{d1\\}$ because there exists a path where d2 doesn't reach this point and that path is the straight line path without the loop and so here it's just d1 but in reaching definitions it becomes $\\{d1, d2\\}$. So once again for all other points actually it has the same answer. We can check this, for example just after d3. So, just before d3, on all possible paths d2 reaches d3 without getting killed so if we just take the straight line path without taking the loop d2 reached. d2 reaches even if we take a loop. We can take any iterations of the loop and d2 would still reach so on all possible paths d2 is reaching. So d2 must reach this program point and similarly d2 gets killed just after d3 and so d1 and d3 are the only definitions that must reach the point just after d3 and the reaching definitions also has the same answer in this case.", "meta": {"hexsha": "dc5ccc3e0d8d341898ade1559adbfa8fa68283f1", "size": 11913, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "module93.tex", "max_stars_repo_name": "arpit-saxena/compiler-notes", "max_stars_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "module93.tex", "max_issues_repo_name": "arpit-saxena/compiler-notes", "max_issues_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module93.tex", "max_forks_repo_name": "arpit-saxena/compiler-notes", "max_forks_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-02-16T08:32:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-12T19:11:33.000Z", "avg_line_length": 54.397260274, "max_line_length": 1075, "alphanum_fraction": 0.687400319, "num_tokens": 3725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.4291760805280773}}
{"text": "\\documentclass[executivepaper]{article}\n\n\\usepackage{mathtools}\n\n\\everymath{\\displaystyle}\n\n\\usepackage{amssymb}\n\n\\usepackage{amsfonts}\n\n\\usepackage{commath}\n\n\\usepackage{kantlipsum,graphicx}\n\n\\usepackage{amsmath}\n\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{sectsty}\n\n\\usepackage{tcolorbox}\n\n\\usepackage{geometry}\n\n\\usepackage{tikz}\n\n\\usetikzlibrary{shapes,snakes}\n\n\\usepackage{float}\n\n\\setlength\\parindent{3pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text\n\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} % Create horizontal rule command with 1 argument of height\n\n\\newtheorem{definition}{Definition}\n\n\\newtheorem{theorem}{Theorem}\n\n\\newtheorem{corollary}{Corollary}[theorem]\n\n\\newtheorem{sidenote}{Side Note}\n\n\\newcommand{\\KP}[1]{%\n  \\begin{tikzpicture}[baseline=-\\dimexpr\\fontdimen22\\textfont2\\relax]\n  #1\n  \\end{tikzpicture}%\n}\n\\newcommand{\\KPA}{%\n  \\KP{\\filldraw[color=gray, fill=none, thick] circle (0.3);}%\n}\n\\newcommand{\\KPB}{%\n  \\KP{\n    \\draw[color=gray,thick] (-0.3,0.3) -- (0.3,-0.3);\n    \\draw[color=gray,thick] (-0.3,-0.3) -- (-0.05,-0.05);\n    \\draw[color=gray,thick] (0.05,0.05) -- (0.3,0.3);\n  }%\n}\n\\newcommand{\\KPC}{%\n  \\KP{%\n    \\draw[color=gray,thick] (-0.3,0.3) .. controls (0,-0.05) .. (0.3,0.3);\n    \\draw[color=gray,thick] (-0.3,-0.3) .. controls (0,0.05) .. (0.3,-0.3);\n  }%\n}\n\\newcommand{\\KPD}{%\n  \\KP{%\n    \\draw[color=gray,thick] (-0.3,-0.3) .. controls (0.05,0) .. (-0.3,0.3);\n    \\draw[color=gray,thick] (0.3,-0.3) .. controls (-0.05,0) .. (0.3,0.3);\n  }%\n}\n\n\\begin{document}\n\n\\title\n{\n\\vspace*{-40mm}\n\\normalfont \\normalsize\n\\horrule{0.5pt} \\\\[0.4cm] % Thin top horizontal rule\n\\huge Topology Final Exam Study Guide\\\\ % The assignment title\n\\horrule{0.5pt} \\\\[0.5cm] % Thick bottom horizontal rule\n}\n\\author{Brendan Busey} % Your name\n\n\\date{\\normalsize\\today} % Today's date or a custom date\n\n\\maketitle\n\n\\begin{center}\n\n\\section*{Chapter 1}\n\n\\end{center}\n\n\\subsection*{1.1 Equivalence Relations}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A binary relation $\\thicksim$ on a set X is an \\textbf{equivalence relation} if and only if $\\forall ~ x, y, z \\in$ X satisfies}\n\n\\begin{enumerate}\n\n\\item x $\\thicksim$ x (reflexivity)\n\n\\item if x $\\thicksim$ y, then y $\\thicksim$ x (symmetry)\n\n\\item if x $\\thicksim$ y and y $\\thicksim$ z,  then x $\\thicksim$ z (transitivity)\n\n\\end{enumerate}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\section*{1.2 Bijections}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A function $f: X \\rightarrow Y$ is an injection (or a \\textbf{one-to-one} function) if and only if for an $x_{1}, x_{2} \\in X$ we have}\n\n\\begin{center}\n\n$f(x{_1})=f(x_{2}) \\implies x_{1}=x_{2}$\n\n\\end{center}\n\n\\textit{The function is a \\textbf{surjection} (or an \\textbf{onto} function) if and only if for every $y \\in Y$, there is $x \\in X$ with $f(x)=y$. The function is a \\textbf{bijection} if and only if it is an injection and a surjection.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{Consider a function $f: X \\rightarrow Y$. Then, f is a bijection if and only if f has an inverse function.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-35mm}\n\n\\section*{1.3 Continuous Functions}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A function $f: X \\rightarrow Y$ is continuous at $x_{0} \\in X$ if and only if for every $\\varepsilon > 0$ there is $\\delta > 0$ such that $\\forall ~ x \\in X$, we have the implication that $d(x, x_{0}) < \\delta \\implies d(f(x), f(x_{0})) < \\varepsilon$. A function is continuous if and only if it is continuous at each point of it s domain.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{Suppose A and B are regions of $\\mathbb{R}^{2}$ that are bounded by polygons. Suppose $f: A \\rightarrow Y$ and $g: B \\rightarrow Y$ are continuous functions such that $f(x)=g(x) ~ \\forall x \\in A \\cap B$. Then, the function $h: A \\cup B \\rightarrow Y$ is defined by}\n\n\\begin{center}\n\n\\[h(x)= \\begin{cases} \n      f(x) & if ~ x \\in A \\\\\n      g(x) & if ~ x \\in B\n   \\end{cases}\n\\]\n\n\\end{center}\n\nis continuous.\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\subsection*{1.4 Topological Equivalance}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{homeomorphism} (or \\textbf{topological equivalence}) is a bijection $h: X \\rightarrow Y$ such that both $h$ and $h^{-1}$ are continuous. The spaces X and Y are \\textbf{homeomorphic} (or \\textbf{topologically equivalent}) if and only if there is a homeomorphism from X to Y.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textit{standard disk} is the set \\{$(x,y) \\in \\mathbb{R}^{2} ~ | ~ x^2+y^2 \\leq 1$\\}. A \\textbf{disk} is any topological space homeomorphic to the standard disk. \\\\[2ex]\nThe \\textbf{standard n-dimensional ball} (or more simply, the \\textbf{the standard n-ball}) is the set $\\{(x_{1}, x_{2}, \\ldots, x_{n}) \\in \\mathbb{R}^{n} ~ | ~ x_{1}^{2} + x_{2}^{2} + \\cdots + x_{n}^{2} \\leq 1\\}$. An \\textbf{n-ball} (or \\textbf{n-cell}) is any topological space homeomorphic to the standard n-ball.\\\\[2ex]\nThe \\textbf{standard} n-\\textbf{dimensional sphere} (or more simply, the \\textbf{standard} n-\\textbf{sphere}) is the set $\\{(x_{1}, x_{2}, \\cdots, x_{n}) \\in \\mathbb{R}^{n} ~ | ~ x_{1}^{2} + x_{2}^{2} + \\ldots + x_{n+1}^{2} = 1\\}$. An n-\\textbf{sphere} is any topological space homeomorphic to the standard n-sphere.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-35mm}\n\n\\subsection*{1.5 Topological Invariants}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{path} in a space X is a continuous function $\\alpha: [0,1] \\rightarrow X$. Consider the equivalence relation between pairs of points in a set of X defined by $x \\thicksim y$ if and only if there is a path $\\alpha : [0,1] \\rightarrow X$ with $\\alpha(0)=x$ and $\\alpha(1)=y$. The equivalence classes under this relation are called \\textbf{path components} of X. A set such that every two points are joined by a path is said to be \\textbf{path-connected}}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{Suppose $\\alpha : [0,1] \\rightarrow A \\cup B ~ is ~ a ~ path ~ \\alpha(0) \\in A$ and $\\alpha(1) \\in B$. Then, there is a sequence of points of A that converges to a point of B or else there is a sequence of points of B that converges to a point in A.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{corollary}\n\n\\textit{A homeomorphism $h: X \\rightarrow Y$ induces a bijection $h_{*}: P(x) \\rightarrow P(Y)$. In particular, the number of path components of a space is topologically invariant.}\n\n\\end{corollary}\n\n\\end{tcolorbox}\n\n\\subsection*{1.6 Isotopy}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{Suppose A and B are two subsets of a space X. An \\textbf{Ambient isotopy} from A to B in X is a continuous function $h : X \\times [0,1] \\rightarrow X$ that satisfies the following three conditions. We denote $h(x,t)$ by $h_{t}(x)$.}\n\n\\begin{center}\n  \n\\begin{enumerate}\n\n\\item $h_{t}: X \\rightarrow X$ is a homeomorphism for every t $\\in$ [0,1]\n\n\\item $h_{0} ~ is ~ the ~ identity ~ function ~ on ~ X$\n\n\\item $h_{1}(A)=B$\n\n\\end{enumerate} \n\n\\end{center}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\begin{center}\n\n\\section*{Chapter 2}\n\n\\end{center}\n\n\\subsection*{2.1 Knots, Links, and Equivalences}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{knot K} is a simple closed curve in $\\mathbb{R}^{3}$ that can be broken into a finite number of straight line segments $e_{1}, e_{2}, \\cdots, e_{n}$ such that the intersection of any segment with $e_{k}$ with the other segments is exactly one endpoint of $e_{k}$ intersecting an endpoint of $e_{k-1}$ (or $e_{n}$ if $k=1$) and the other endpoint of $e_{k}$ intersecting an endpoint of $e_{k+1}$ (or $e_{1}$ if $k=n$).}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{Consider a triangle ABC with side AC matching one of the line segments of a knot K. In the plane determined by the triangle, we require that the region bounded by ABC intersects K only in the edge AC. A \\textbf{triangular detour} involves replacing the edge AC of knot K with the two edges AB and BC to produce a new knot L. With the same notation, a \\textbf{triangular shortcut} involves replacing the two edges AB and BC and L with the single edge of AC to produce knot K. A \\textbf{triangular move} is either a triangular detour or a triangular shortcut. Two knots are \\textbf{equivalent} if and only if there is a finite sequence of triangular moves that changes the first knot into the second.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{Link} is the nonempty union of a finite number of disjoint knots.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\subsection*{2.2 Knot Diagrams}\n\n\\begin{tcolorbox}\n\n\\begin{definition}[General Position Rule of Thumb]\n\n\\textit{Suppose two piecewise-linear objects are embedded in general position in $\\mathbb{R}^{n}$. Suppose A is a vertex, edge, face, or analogous higher-dimensional part of one object and B is a vertex, edge, face, or analogous higher-dimensional part of the other object. If the intersection $A \\cup B$ is nonempty, then.}\n\n\\begin{center}\n\ndim($A \\cap B$)=dim(A)+dim(B)-n\n\n\\end{center}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The orthogonal projection of a knot onto a plane is a \\textbf{regular projection} if and only if no vertex projects to the image of another point of the knot and there are no triple points.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textbf{crossing number} of a knot K is the minimum number of crossing points that occur in the knot diagrams for all knots equivalent K.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textbf{unknotting number} is the minimum number of times the knot must be passed through itself (\\textbf{crossing switch}) to untie it}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{trivial knot} is a knot that is equivalent to a triangle. A \\textbf{trivial link} is a link that is equivalent to the union of disjoint triangles lying in a plane}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A knot is \\textbf{alternating} if and only if it is equivalent to a knot with a diagram in which underpasses alternate with overpasses as you travel around the knot}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\subsection*{2.3 Reidmeister Moves}\n\n\\begin{figure}[H]\n\n\\centering\n\n\\includegraphics[scale=0.5]{Reidemeister_move_1.png}\n\n\\caption{Type 1}\n\n\\end{figure}\n\n\\vspace{2mm}\n\n\\begin{figure}[H]\n\n\\centering\n\n\\includegraphics[scale=0.5]{Reidemeister_move_2.png}\n\n\\caption{Type 2}\n\n\\end{figure}\n\n\\pagebreak\n\n\\vspace*{-40mm}\n\n\\begin{figure}[H]\n\n\\centering\n\n\\includegraphics[scale=0.5]{Reidemeister_move_3.png}\n\n\\caption{Type 3}\n\n\\end{figure}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{If two links are equivalent, then their diagrams, subject to ambient isotopies of the plane, are related by a sequence of Reidemeister moves.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{An \\textbf{orientation} of a link is a choice of direction to travel around each component of the link. Consider a crossing a regular projection of an oriented link. Stand on the overpass and face in the direction of the orientation. The crossing is \\textbf{right-handed} if and only if traffic on the underpass goes from right to left; the crossing is \\textbf{left-handed} if and only if traffic on the underpass goes from left to right. In regular projection of an oriented link of two components, assign +1 to right-handed crossings and -1 to left-handed crossings. Add up the numbers assigned to crossings involving both components. One half this sum is the \\textbf{linking number} of the two oriented components of the link.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\subsection*{2.4 Colorings}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The diagram of a knot is \\textbf{colorable} if and only if each arc can be assigned one of three colors subject to the two conditions:}\n\n\\begin{center}\n\n\\begin{enumerate}\n\n\\item At least two colors appear\n\n\\item At any crossing where two colors appear, all three colors appear\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{The colorability of a knot diagram is an invariant property of the knot type.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-20mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{Let p be an odd number greater than two. A knot is p-colorable if at every crossing:}\n\n\\begin{center}\n\n\\begin{enumerate}\n\n\\item At least two colors appear\n\n\\item you can solve $color1 + color2 \\equiv 2x ~ mod ~ (the ~ number ~ of ~ colors ~ used)$, where color1 and color2 are numbers assigned to the arcs of the knot\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{The colorability of a knot diagram is an invariant property of the knot type.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{The representation of a knot diagram on a wheel with p colors is an invariant property of the knot type.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The determinant of a knot is the absolute value of its Alexander Polynominal evaluated at -1 (simply, plug-in -1 for t)}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{A knot is p-\\textbf{colorable} for prime p greater than two if and only if p divides its determinant}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\subsection*{2.5 The Alexander Polynominal}\n\n\\begin{tcolorbox}\n\n\\textit{Steps in computing the Alexander Polynominal:}\n\n\\begin{center}\n\n\\begin{enumerate}\n\n\\item Label the crossings $x_{1}, x_{2}, \\cdots, x_{n}$\n\n\\item Label the arcs $a_{1}, a_{2}, \\cdots, a_{n}$\n\n\\item Choose an orientation for the knot\n\n\\item As you travel around the knot in the chosen orientation, stand on the overpass of each crossing. Label the overstrand with $1-t$, the left-end of the understrand $t$, and the right-end of the understrand -1\n\n\\item Create the arc/crossing matrix\n\n\\item Compute the determinant of the matrix, which is the Alexander Polynominal\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The projection of an oriented knot divides the plane into a number of regions. The \\textbf{index} of one of these regions is the net number of times the projection winds counterclockwise around any point in the region.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textbf{index} of a crossing of a knot diagram is the common value of the index of two of the regions near the crossing.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{The Alexander Polynominal of an oriented knot is an invariant under Reidemeister moves.}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\subsection*{2.6 Skein Relations}\n\n\\begin{tcolorbox}\n\n\\textit{Calculating the $\\Delta$ polynominal is the same as calculating the Alexander Polynominal}\n\n\\end{tcolorbox}\n\n\\subsection*{2.7 The Jones Polynominal}\n\n\\begin{tcolorbox}\n\n\\textbf{Rules for the Bracket Polynominal} \\textit{The Kauffman \\textbf{Bracket Polynominal} of a regular projection of a link is a polynominal in integer powers of the variable A defined by the following three rules:}\n\n\\begin{center}\n\n\\begin{enumerate}\n%the first rule\n\\item\n  $\\left\\langle\\KPA\\right\\rangle=1$\n\n%the second rule\n\\item\n  $\\left\\langle L \\cup \\KPA\\right\\rangle=(-A^{2}-A^{-2})\\langle L\\rangle$\n\n%the third rule\n\\item\n  $\\left\\langle\\KPB\\right\\rangle=\n  A\\left\\langle\\KPC\\right\\rangle + A^{-1} \\left\\langle \\KPD \\right\\rangle$\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textbf{writhe} w(L) of the regular projection L of a link is the number of right-handed crossings minus the number of left-handed crossings.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The X(L) polynominal is defined as:}\n\n\\begin{center}\n\n$X(L)=(-A)^{-3w(L)} \\big \\langle L \\big \\rangle$, where $\\big \\langle L \\big \\rangle$ is the bracket polynominal for L and $w(L)$ is the writhe of L\n\n\\end{center}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\begin{tcolorbox}\n\n\\textit{Steps in calculating the Jones Polynominal:}\n\n\\begin{center}\n\n\\begin{enumerate}\n\n\\item Calculate the Bracket Polynominal\n\n\\item Calculate the $X-polynominal$\n\n\\item Substitute $t^{-\\frac{1}{4}}$ in for every ``A\" in the $X-polynominal$ and simplify\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{tcolorbox}\n\n\\begin{center}\n\n\\section*{Chapter 3 Surfaces}\n\n\\end{center}\n\n\\subsection*{3.1 Definition and Examples}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{In a space with a way of measuring distances between points, a \\textbf{neighborhood} of a point is a subset that contains all points within some positive distance of the point}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{surface} (or 2 \\textbf{-manifold}) is a space that is homeomorphic to a nonempty subset of finite-dimensional Euclidean space and in which every point has a neighborhood homeomorphic to $\\mathbb{R}^{2}$. We sometimes also wish to admit \\textbf{boundary} points, which have neighborhoods homeomorphic to the half-plane $\\{(x,y) \\in \\mathbb{R}^{2} ~ | ~ y \\geq 0\\}$}.\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\subsection*{3.2 Cut-and-Paste Techniques}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{Let S and T be path-connected surfaces Remove the interior of a disk from each surface by cutting along the boundaries of the disks. Glue the remaining surfaces together along the newly formed boundary components. The result surface is the \\textbf{connected sum} of S and T. It is denoted S\\texttt{\\#}T.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\subsection*{3.3 The Euler Characteristic and Orientability}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A \\textbf{triangulation} of a space is a decomposition of the space into a union of disks, arcs, and points. The disks are called \\textbf{faces}, the arcs are called \\textbf{edges}, and the points are \\textbf{vertices} of the triangulation. A face intersects other components of a triangulation only along its boundary; and the boundary of a face consists of three edges and three vertices. An edge intersects other edges and the vertices only at its endpoints; and both endpoints of an edge are vertices.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{A triangulated space is \\textbf{compact} if and only if it consists of a finite number of faces, edges, and vertices.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{The \\textbf{Euler characteristic} of a compact triangulation space S is the number of vertices minus the number of edges plus the number of faces. The Euler characteristic of S is denoted by $\\chi(S)$.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{Every closed, path-connected surface is homeomorphic to exactly one of:}\n\n\\begin{center}\n\n\\begin{enumerate}\n\n\\item A 2-sphere\n\n\\item A connected sum of Tori\n\n\\item A connected sum of projective planes\n\n\\end{enumerate}\n\n\\end{center}\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{sidenote}\n\n\\textit{Something is orientable if it is 2-colorable or doesn't have a mobius band}\n\n\\end{sidenote}\n\n\\end{tcolorbox}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{Suppose $A$ and $B$ are triangulated so that $A \\cap B$ is also triangulated. Then, $\\chi(A \\cup B)=\\chi(A)+\\chi(B)-\\chi(A \\cap B)$}.\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{theorem}\n\n\\textit{The surface formed by taking the connected sum of g tori and cutting out disks to leave b boundary components has Euler characteristic 2-2g-b. The surface formed by taking the connected sum of n projective plane and cutting out disks to leave b boundary components has Euler characteristic 2-n-b}.\n\n\\end{theorem}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{An \\textbf{orientation} of a polygonal face of a triangulated surface is the choice of one of the two possible orientations of the boundary curve of the face. A surface is \\textbf{orientable} if and only if it is possible to choose orientations of all the faces of a triangulation of the surface so that whenever two faces share a common edge, the orientation of the faces induce opposite orientations on the edge.}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{$\\chi(f_{1}\\texttt{\\#}f_{2})=\\chi(f_{1}) + \\chi(f_{2}) - 2$}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{With the word you come up with for the surface, if every letter does not have an inverse, the surface is not orientable. If every letter does have an inverse, it is orientable}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\vspace{2mm}\n\n\\begin{tcolorbox}\n\n\\begin{definition}\n\n\\textit{Just concatenate the two individual words of each surface to get a word for the connected sum of the two surfaces}\n\n\\end{definition}\n\n\\end{tcolorbox}\n\n\\pagebreak\n\n\\vspace*{-30mm}\n\n\\begin{tcolorbox}\n\n\\begin{sidenote}\n\n\\textit{The table below helps you figure out what surface is being asked for based on \\textbf{Orientability} and the \\textbf{Euler characterisitic}}\n\n\\vspace{2mm}\n\n\\begin{tabular}{||c c c||}\n\n\\hline\n\n\\textit{$\\chi$} & \\textit{$Oreintable$} & \\textit{$Non-orientable$} \\\\ [0.5ex]\n\n\\hline\\hline\n\n2 & Sphere & \\\\ \n\n\\hline\n\n1 & & P \\\\\n\n\\hline\n\n0 & T & P \\texttt{\\#} P \\\\\n\n\\hline\n\n-1 &  & P \\texttt{\\#} P \\texttt{\\#} P \\\\\n\n\\hline\n\n-2 & T \\texttt{\\#} T & P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\#} P  \\\\\n\n\\hline\n\n-3 & & P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\#} P  \\\\\n\n\\hline\n\n-4 & T \\texttt{\\#} T \\texttt{\\#} T & P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\#} P \\texttt{\\# P}  \\\\ [1ex]\n\n\\hline\n\n\\end{tabular}\n\n\\end{sidenote}\n\n\\end{tcolorbox}\n\n\\end{document}", "meta": {"hexsha": "c4604afbfa94c935bd752f5ec8f99e707ebbbc7e", "size": 22706, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Topology/TopologyFinalExamStudyGuide.tex", "max_stars_repo_name": "busebd12/Mathematics", "max_stars_repo_head_hexsha": "53530f5864af952afb4083c79632bb4280fd5c3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Topology/TopologyFinalExamStudyGuide.tex", "max_issues_repo_name": "busebd12/Mathematics", "max_issues_repo_head_hexsha": "53530f5864af952afb4083c79632bb4280fd5c3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Topology/TopologyFinalExamStudyGuide.tex", "max_forks_repo_name": "busebd12/Mathematics", "max_forks_repo_head_hexsha": "53530f5864af952afb4083c79632bb4280fd5c3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.4324045408, "max_line_length": 738, "alphanum_fraction": 0.7201620717, "num_tokens": 7061, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.42917607300502864}}
{"text": "\\documentclass[12pt,letterpaper]{article}\n\\usepackage{fullpage}\n\\usepackage[top=2cm, bottom=4.5cm, left=2.5cm, right=2.5cm]{geometry}\n\\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}\n\\usepackage{lastpage}\n\\usepackage{enumerate}\n\\usepackage{fancyhdr}\n\\usepackage{mathrsfs}\n\\usepackage{xcolor}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\usepackage{hyperref}\n\\usepackage[section]{minted}\n\\usepackage{hyperref}\n\\usepackage{multirow}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\definecolor{mintedbackground}{rgb}{0.95,0.95,0.95}\n\n\\hypersetup{%\n  colorlinks=true,\n  linkcolor=blue,\n  linkbordercolor={0 0 1}\n}\n \n\\renewcommand\\lstlistingname{method}\n\\renewcommand\\lstlistlistingname{Algorithms}\n\\def\\lstlistingautorefname{Alg.}\n\n\\colorlet{mygreen}{green!60!blue}\n\n\\newmintedfile[cppcode]{cpp}{\nbgcolor=mintedbackground,\nfontfamily=tt,\nlinenos=true,\nnumberblanklines=true,\nnumbersep=5pt,\ngobble=0,\nframe=leftline,\nframerule=0.4pt,\nframesep=2mm,\nfuncnamehighlighting=true,\ntabsize=1,\nobeytabs=false,\nmathescape=false\nsamepage=true, %with this setting you can force the list to appear on the same page\nshowspaces=false,\nshowtabs =false,\ntexcl=false,\nfontsize=\\small,\nbreaklines\n}\n\n\\setlength{\\parindent}{0.0in}\n\\setlength{\\parskip}{0.05in}\n\n% Edit these as appropriate\n\\newcommand\\course{EC6301}\n\\newcommand\\name{Numerical Opimization}\n\\newcommand\\hwnumber{3}                  % <-- homework number\n\\newcommand\\NetIDa{20211046}           % <-- NetID of person #1\n\\newcommand\\NetIDb{Hyeonjang An}           % <-- NetID of person #2 (Comment this line out for problem sets)\n\\newcommand\\github{\\url{https://github.com/hyeonjang/numerical-optimization}}\n\n\\pagestyle{fancyplain}\n\\headheight 35pt\n\\lhead{\\github\\\\\\NetIDa\\\\\\NetIDb}                 % <-- Comment this line out for problem sets (make sure you are person #1)\n\\chead{\\textbf{\\Large Homework \\hwnumber}}\n\\rhead{\\course \\\\ \\name \\\\ \\today}\n\\lfoot{}\n\\cfoot{}\n\\rfoot{\\small\\thepage}\n\\headsep 1.5em\n\n\\begin{document}\n\n\\section*{Problem}\n\n\\begin{enumerate}\n  \\item Implement the Nelder-Mead method and the Powell's method to find the minimum of\n  \\begin{enumerate}\n    \\item $f(x, y)=(x+2y)^2 + (2x+y)^2$\n    \\item $(x, y)=50*(y-x^2)^2 + (1-x)^2$\n    \\item $f(x, y)=(1.5-x+xy)^2 + (2.25-x+xy^2)^2 + (2.625 - x+ xy^3)^2$\n  \\end{enumerate}\n  \\item Use your own termination criterion. Compare and discuss their performances. \n  If possible, show how the best point is moving on the contour plot of f(x, y)\n\\end{enumerate}\n\n\\section*{Implementation - methods}\n\n\\begin{enumerate}\n\\item Computation result: convergence points\n\\\\ In the case of the first function, the results are the approximation of the value zero.\n\\\\ In the case of the second function, Powell's method is sometimes stucked to local minima.\n[0.510332, 0.263043] is the failure case to find optimization points.\n\\begin{center}\n  \\begin{tabular}{| c | c | c |} \\hline\n      \\multirow{2}{*}{function $f(x, y)$}   & \\multicolumn{2}{c|}{Convergence Points$(x, y)$} \\\\ \\cline{2-3}\n                                            & Nelder-Mead & Powell's  \\\\ \\hline\n      (a)                                   & [1.17932e-07, -1.85511e-07] & [-7.20495e-23, 5.73423e-23] \\\\ \n      (b)                                   & [1, 1] & [0.510332, 0.264043] / [0.99972, 0.999437]\\\\ \n      (c)                                   & [3, 0.5]  & [2.99989, 0.499973] \\\\\n      \\hline\n  \\end{tabular}\n\\end{center}\n\\item Implementation\n  \\\\ initial points are randomly given. \n  \\begin{enumerate}\n    % ##############################################################\n    % Nelder-Mead\n    % ##############################################################\n    \\item \\textbf{Nelder-Mead method}\n    \\\\ Three control parameters are set as $\\alpha=1$, $\\beta=2$, $\\gamma=0.5$\n    \\\\ The maximum iteration is 10000.\n    \\\\ The termination condition is the \"magnitude of gradient\".\n    \\cppcode[]{../../code/multi/nelder_mead.hpp}\n\n    \\newpage\n\n    % ##############################################################\n    % Powell's\n    % ##############################################################\n    \\item \\textbf{Powell's method}\n    \\\\ For univarite searching, I used the golden section search method.\n    \\\\ The maximum iteration is 10000 as same as Nelder-Mead method.\n    \\\\ When using the termination criterion as the \"magnitude of gradient\", \n    it occurs to be stucked in local minima.\n    So the termination condition is changed to \"consecutive relative difference\". \n    However this does not largely affect to the performance.\n    \\cppcode[]{../../code/multi/powells.hpp}\n\n\\end{enumerate}\n\n\\newpage\n\n\\section*{Implementation - Terminatination criterion}\n\\item Termination criterion\n\\\\ I have implemented all six conditions. \nAlso, to calculate the gradient of functions, \nI used numerical method to derive gradient from function given point $(x, y)$\n\\begin{itemize}\n% ##############################################################\n% Termination criterion: gradient\n% ##############################################################\n\\item Termination criterion\n\\cppcode[]{../../code/multivariate.h}\n\\item Gradient calculation\n\\cppcode[]{../../code/multivariate.cpp}\n\\end{itemize}\n\n\\section*{Performance and Plot}\n\\item Performace\n\\begin{center}\n    \\begin{tabular}{| c | l | c | c |} \\hline\n                  & \\multirow{2}{*}{function $f(x, y)$}               & \\multicolumn{2}{c|}{performance} \\\\ \\cline{3-4}\n                  &                                                   & Nelder-Mead & Powell's  \\\\ \\hline\n        (a) & $(x+2y)^2 + (2x+y)^2$                                   & 872972 ns   & 84036883 ns \\\\ \n        (b) & $50*(y-x^2)^2 + (1-x)^2$                                & 132298767 ns& 526430665 ns \\\\ \n        (c) & $(1.5-x+xy)^2 + (2.25-x+xy^2)^2 + (2.625 - x+ xy^3)^2$  & 214017830 ns& 336396522 ns \\\\\n        \\hline\n    \\end{tabular}\n\\end{center}\n\\begin{itemize}\n  \\item The convergence speed of Powell's method is worse than Nelder-Mead method for every given functions.\n  \\item It is because Powell's method has a dependency on the univarite method.\n  \\item Because I have given the initial points randomly, it happens not to converge. \n  The Figure 2, which shows the result of Powell's method of the second function, is the case which cannot find the global minima.\n\\end{itemize}\n\n% ##############################################################\n% Plotting\n% ##############################################################\n\\newpage\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[b]{0.45\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/NelderMead_0.png}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.45\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/Powells_0.png}\n  \\end{subfigure}\n    \\caption{$f(x, y)=(x+2y)^2 + (2x+y)^2$ }\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[b]{0.4\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/NelderMead_1.png}\n    \\caption{Nelder-Mead}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.29\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/Powells_1_1.png}\n    \\caption{Powell's: global}\n  \\end{subfigure}\n  \\begin{subfigure}[b]{0.29\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/Powells_1_2.png}\n    \\caption{Powell's: local }\n  \\end{subfigure}\n    \\caption{$f(x, y)=50*(y-x^2)^2 + (1-x)^2$}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[b]{0.45\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/NelderMead_2.png}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.45\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/Powells_2.png}\n  \\end{subfigure}\n    \\caption{ $f(x, y)=(1.5-x+xy)^2 + (2.25-x+xy^2)^2 + (2.625 - x+ xy^3)^2$ }\n\\end{figure}\n\n\\end{enumerate}\n\\end{document}", "meta": {"hexsha": "2fb405bd055e02585a3caa49f519c3b55c5834f0", "size": 7835, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/homework3/report.tex", "max_stars_repo_name": "hyeonjang/numerical-optimization", "max_stars_repo_head_hexsha": "39ab4f75056acf5f7c0779bf3330046f29430bd0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/homework3/report.tex", "max_issues_repo_name": "hyeonjang/numerical-optimization", "max_issues_repo_head_hexsha": "39ab4f75056acf5f7c0779bf3330046f29430bd0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/homework3/report.tex", "max_forks_repo_name": "hyeonjang/numerical-optimization", "max_forks_repo_head_hexsha": "39ab4f75056acf5f7c0779bf3330046f29430bd0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8222222222, "max_line_length": 130, "alphanum_fraction": 0.6172303765, "num_tokens": 2354, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.8198933271118221, "lm_q1q2_score": 0.42914885136743347}}
{"text": "% $Header: /cvsroot/latex-beamer/latex-beamer/solutions/conference-talks/conference-ornate-20min.en.tex,v 1.7 2007/01/28 20:48:23 tantau Exp $\n\n\\documentclass[11pt]{beamer}\n\n\\mode<beamer>\n{\n  \\usetheme{default}\n  \\usecolortheme[rgb={0,0,0.8}]{structure}\n  %\\setbeamercolor{normal text}{bg=blue!50}\n  %\\setbeamercolor{normal text}{fg=blue!50}\n  % or ...\n\n  %\\setbeamercovered{transparent}\n  % or whatever (possibly just delete it)\n}\n\n\n\\usepackage[english]{babel}\n% or whatever\n\n\\usepackage[latin1]{inputenc}\n% or whatever\n\n\\usepackage{times}\n\\usepackage[T1]{fontenc}\n% Or whatever. Note that the encoding and the font should match. If T1\n% does not look nice, try deleting the line with the fontenc.\n\n%\\usepackage{newcent}\n%\\usefonttheme{structuresmallcapsserif}\n\n\\usepackage{amssymb,latexsym,amsmath}\n\\usepackage{amsthm}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\usepackage{mathtools}\n\\input xy \n\\xyoption{all}\n\\usepackage[latin1]{inputenc}\n\\usepackage{color}\n\\usepackage{tikz}\n\n\n\\title[On Laplacian Eigenmaps for Dimensionality Reduction] % (optional, use only with long paper titles)\n{On Laplacian Eigenmaps for Dimensionality Reduction}\n\n%\\subtitle\n\n\\author[Dr. Juan Orduz] % (optional, use only with lots of authors)\n{Dr. Juan Orduz}\n% - Give the names in the same order as the appear in the paper.\n% - Use the \\inst{?} command only if the authors have different\n%   affiliation.\n\n\\institute[PyData Berlin 2018] % (optional, but mostly needed)\n{\n\n}\n% - Use the \\inst command only if there are several affiliations.\n% - Keep it simple, no one is interested in your street address.\n\n\\date[ PyData Berlin 2018] % (optional, should be abbreviation of conference name)\n{ PyData Berlin 2018}\n% - Either use conference name or its abbreviation.\n% - Not really informative to the audience, more for people (including\n%   yourself) who are reading the slides online\n\n\\subject{data science}\n% This is only inserted into the PDF information catalog. Can be left\n% out.\n\n\n\n% If you have a file called \"university-logo-filename.xxx\", where xxx\n% is a graphic format that can be processed by latex or pdflatex,\n% resp., then you can add a logo as follows:\n\n\\pgfdeclareimage[height=0.7cm]{university-logo}{logo.jpg}\n\\logo{\\pgfuseimage{university-logo}}\n\n% If you wish to uncover everything in a step-wise fashion, uncomment\n% the following command:\n\n%\\beamerdefaultoverlayspecification{<+->}\n\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n%\\begin{frame}{Contenido}\n%\\tableofcontents\n%\\end{frame}\n\n\\begin{frame}{Overview}\n\\tableofcontents\n\\end{frame}\n\n\\section{Introduction}\n\n\\begin{frame}{Can One Hear the Shape of a Drum?}{\\cite{K66}}\nA  {\\bf differentiable manifold} is a type of manifold that is locally similar enough to a linear space to allow one to do calculus. A (Riemannian) metric $g$ allow us to measure distances. \n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\draw (0,0) ellipse (2.5cm and 1.5cm);\n%\\draw (-0.5,0) arc (175:315:0.5cm and 0.25cm);\n%\\draw (0.2,-0.2) arc (-30:180:0.35cm and 0.15cm);\n\\draw (-1,0.2) arc (175:315:1cm and 0.5cm);\n\\draw (0.5,-0.27) arc (-30:180:0.7cm and 0.3cm);\n\\draw [black,fill=gray!60] (1.5,0.3) ellipse (0.5cm and 0.3cm);\n\\node (a) at (1.5,-0.3) {$U\\subset \\mathbb{R}^n$};\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\pause\nWe can consider the \\textbf{Laplacian} $L:C^\\infty(M)\\longrightarrow C^\\infty(M)$ and its \\textbf{spectrum} \n$\\text{spec}(L)=\\{\\lambda_0, \\lambda_1, \\cdots, \\lambda_k, \\cdots \\longrightarrow \\infty\\}$. \n\\begin{itemize}\n\\pause\n\\item If we are given $\\text{spec}(L)$ we can infer the dimension of $M$, its volume and its total scalar curvature. \n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Spectral Geometry for Dimensionality Reduction?}\nLet us assume we have data points $x_1, \\cdots, x_k\\in\\mathbb{R}^N$ which lie on an \\underline{unknown} submanifold $M\\subset\\mathbb{R}^N$. \n\\begin{block}{Key Observation}\n\\begin{itemize}\n\\item Eigenfunctions  of $L$ on $M$ can be used to define lower dimensional embeddings.\n\\end{itemize}\n\\end{block}\n\n\\begin{block}{Idea (\\cite{BN2003})}\n\\begin{itemize}\n\\item Model $M$ by constructing a graph $G=(V,E)$ where close data points are connected by edges. \n\\pause\n\\item \nConstruct the graph Laplacian $L$ on $G$. \n\\pause\n\\item \nCompute \\text{spec}(L) and the corresponding eigenfunctions. \n\\pause \n\\item Use these eigenfunctions to construct an embedding $F:V\\longrightarrow \\mathbb{R}^m$ for $m<N$. \n\\end{itemize}\n\\end{block}\n\\end{frame}\n\n\\section{Warming Up}\n\n\\subsection{The Spectral Theorem}\n\n\\begin{frame}{The Spectral Theorem}\nLet $A\\in M_{n\\times n}(\\mathbb{R})$ be a symmetric matrix, i.e. $A=A^\\dagger$. \n\\pause\n\\begin{block}{Recall}\n\\begin{itemize}\n\\item $\\lambda\\in\\mathbb{C}$ is an {\\bf eigenvalue} for A with {\\bf eigenvector} $f\\in\\mathbb{R}^n$, $f\\neq 0$, if \n$$Af=\\lambda f.$$\n\\item A set of vectors $\\mathcal{B} = \\{f_1, f_2, \\cdots, f_n\\}$ is a {\\bf basis} for $\\mathbb{R}^n$ if:\n\\begin{itemize}\n\\item They are linearly independent. \n\\item They generate $\\mathbb{R}^n$.\n\\end{itemize}\n\\item $\\mathcal{B}$ is said to be an {\\bf orthonormal} basis if $\\langle f_i, f_j\\rangle = \\delta_{ij}$. \n\\end{itemize}\n\\pause \n\\end{block}\n\\begin{block}{Spectral Theorem}\nThere exists an orthonormal basis of $\\mathbb{R}^n$ consisting of eigenvectors of $A$. Each eigenvalue is real.\n\\end{block}\n\\end{frame}\n\n\\begin{frame}{Min(Max)imizing Properties of Eigenvalues}\nLet $A\\in M_n(\\mathbb{R})$ be a symmetric matrix with spectral decomposition $\\lambda_0 \\leq \\lambda_1 \\leq \\cdots \\leq \\lambda_n$. \\\\\n\\vspace{0.3 cm}\nFor later purposes, we would like to find \n\\begin{align*}\n\\argmax_{||f||=1} \\langle Af, f \\rangle.\n\\end{align*}\n\\begin{itemize}\n\\pause\n\\item Define the associated Lagrange optimization problem\n\\begin{align*}\n\\mathcal{L}(f, \\lambda) = \\langle Af, f \\rangle -\\lambda(||f||^2 - 1).\n\\end{align*}\n\\pause\n\\item Take the derivative with respect to $f$\n\\begin{align*}\n\\frac{\\partial}{\\partial f} \\mathcal{L}(f, \\lambda) = 2(Af - \\lambda f )\\stackrel{!}{=} 0.\n\\end{align*}\n\\pause\n\\item Hence, \n\\begin{align*}\n\\argmax_{||f||=1} \\langle Af, f \\rangle = f_n\n\\quad \\text{and}\\quad\n\\argmin_{||f||=1} \\langle Af, f \\rangle = f_0.\n\\end{align*}\n\\end{itemize}\n\\end{frame}\n\n\\section{Motivation}\n\n\\subsection{Toy Model Example}\n\n\\begin{frame}{Step 0: Understand the Problem}\nConsider the problem of mapping these points to a line so that close points stay as together as possible. \n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\node [draw, circle] (a) at (0,0) {1};\n\\node [draw, circle] (b) at (-0.5,2) {2};\n\\node [draw, circle] (c) at (0,-1.5) {3};\n\\node [draw, circle] (d) at (3,0) {4};\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{Step 1: From Data to Adjacency Graph}\n\\begin{itemize}\n\\item Define a distance function: first nearest neighbour.\n \\pause\n\\item For each node, attach an edge for close points. \n\\end{itemize}\n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\node [draw, circle] (a) at (0,0) {1};\n\\node [draw, circle] (b) at (-0.5,2) {2};\n\\node [draw, circle] (c) at (0,-1.5) {3};\n\\node [draw, circle] (d) at (3,0) {4};\n\\pause\n\\path [-] (a) edge node[left] {} (c);\n\\pause\n\\path [-] (b) edge node[left] {} (a);\n\\pause\n\\path [-] (d) edge node[left] {} (a);\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{Step 2: Construct the Adjacency and Degree Matrices}\n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\node [draw, circle] (a) at (0,0) {1};\n\\node [draw, circle] (b) at (-0.5,2) {2};\n\\node [draw, circle] (c) at (0,-1.5) {3};\n\\node [draw, circle] (d) at (3,0) {4};\n\\path [-] (a) edge node[left] {} (c);\n\\path [-] (b) edge node[left] {} (a);\n\\path [-] (d) edge node[left] {} (a);\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\begin{align*}\nW = \\left(\n\\begin{array}{cccc}\n 0 & 1 & 1 & 1 \\\\\n 1 & 0 & 0 & 0 \\\\\n 1 & 0 & 0 & 0 \\\\\n 1 & 0 & 0 & 0 \n\\end{array}\n\\right)\n\\quad \nD = \\left(\n\\begin{array}{cccc}\n 3 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \n\\end{array}\n\\right)\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Step 3: Spectrum of the Graph Laplacian}\n\\begin{itemize}\n\\item Construct the operator $L$ defined by\n\n\\begin{align*}\nL \\coloneqq D - W  = \\left(\n\\begin{array}{cccc}\n 3 & -1 & -1 & -1 \\\\\n -1 & 1 & 0 & 0 \\\\\n -1 & 0 & 1 & 0 \\\\\n -1 & 0 & 0 & 1 \n\\end{array}\n\\right)\n\\end{align*}\n\n\\item Consider the generalized eigenvalue problem \n$$Lf = \\lambda D f.$$\nEquivalently, $D^{-1}Lf = \\lambda f$. \n\\pause\n\\item Eigenvalues: $\\lambda_0 =0 , \\lambda_1 =1, \\lambda_2 = 1, \\lambda_3 =2$.\n\\pause\n\\item An eigenvector for $\\lambda_1 = 1$ is $y\\coloneqq f_1 = (0,-3,1,2)$. \n\\pause\n\\item The vector $y:V\\longrightarrow\\mathbb{R}$ defines and embedding.\n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\node [draw, circle] (a) at (0,0) {1};\n\\node [draw, circle] (b) at (-3,0) {2};\n\\node [draw, circle] (c) at (1,0) {3};\n\\node [draw, circle] (d) at (2,0) {4};\n\\path [-] (a) edge node[left] {} (b);\n\\path [-] (a) edge node[left] {} (c);\n\\path [-] (c) edge node[left] {} (d);\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\end{itemize}\n\\end{frame}\n\n\\section{The Algorithm}\n\n\\subsection{Description}\n\n\\begin{frame}{The Algorithm}\nLet $x_1, \\cdots, x_k\\in\\mathbb{R}^N$.\n\\begin{enumerate}\n\\item \\textbf{Construct a weighted graph} $G=(V, E)$ with $k$ nodes, one for each point, and a set of edges connecting neighbouring points.\n\\textbf{Select a distance function}:\n\\begin{itemize}\n\\item (Euclidean Distance) Let $\\varepsilon>0$. We connect and edge between $i$ and $j$ if $||x_i-x_j||^2 < \\varepsilon$.\n\\item $n$ nearest neighbours. \n\\end{itemize}\n\\pause\n\\item \\textbf{Choose Weights}. If nodes $i$ and $j$ are connected, put\n\\begin{itemize}\n\\item $W_{ij}=1$.\n\\item (Heat Kernel) $W_{ij}\\coloneqq e^{-\\frac{||x_i-x_j||^2}{t}}$ for some $t > 0$.\n\\end{itemize} \n\\pause\n\\item Assume $G$ is connected. \\textbf{Compute the eigenvalues} of the generalized eigenvector problem $Lf = \\lambda D f$, where\n\\begin{itemize}\n\\item $D$ is the diagonal weight matrix, $D_{ii} = \\sum_{j=1}^k W_{ij}$.\n\\item $L\\coloneqq D - W$ is the graph Laplacian. \n\\end{itemize}\n\\pause\n\\item \\textbf{Construct Embedding}. Let $f_0, f_1, \\cdots, f_{k-1}$ be the corresponding eigenvectors ordered according to their eigenvalues ($\\lambda_0 =0$). For $m<N$, set \n\\begin{align*}\nF(i)\\coloneqq (f_1(i), \\cdots, f_{m}(i)).\n\\end{align*} \n\\end{enumerate}\n\\end{frame}\n\n\n\\subsection{Justification}\n\n\\begin{frame}{Why does it work?}{$m=1$}\nAssume you have constructed the weighted graph $G=(V, E)$. We want to construct an embedding $F: V\\longrightarrow\\mathbb{R}$.\\\\\n\\vspace{0.3cm}\n\\underline{Hint:} Minimize\n\\begin{align*}\nJ(y)\\coloneqq \\sum_{i,j=1}^k (y_i - y_j)^2 W_{ij} \\stackrel{*}{=} 2 y^\\dagger L y.\n\\end{align*}\n\\pause\nThus, the problem reduces to find\n\\begin{align*}\n\\argmin_{\\substack{\ny^\\dagger D y = 1\\\\\ny^\\dagger D 1 = 0}}\ny^\\dagger L y\n=\n\\argmin_{\\substack{\ny^\\dagger D y = 1\\\\\ny^\\dagger D 1 = 0}}\n\\langle Ly, y \\rangle \n\\end{align*}\n\\begin{itemize}\n\\item $y^\\dagger D y = 1$ fixes the scale. \n\\item $y^\\dagger D 1 = 0$ eliminates the trivial solution $y=1$.\n\\end{itemize}\n\\pause\nThis translates to finding the minimum non-zero eigenvalue and eigenvector of \n\\begin{align*}\nLy=\\lambda D y.\n\\end{align*} \n\\end{frame}\n\n\\begin{frame}{Why does it work?}{$m>1$ (Vectorize)}\nAssume you have constructed the weighted graph $G=(V, E)$. We want to construct an embedding $F: V\\longrightarrow\\mathbb{R}^m$.\\\\\n\\vspace{0.3cm}\n\\underline{Hint:} Minimize, for $Y=(y_1 \\cdots y_m)\\in M_{k\\times m}(\\mathbb{R})$, \n\\begin{align*}\nJ(Y)\\coloneqq \\sum_{i,j=1}^k ||Y_i - Y_j||^2 W_{ij} = \\text{tr}(Y^\\dagger L Y).\n\\end{align*}\nThus, the problem reduces to find\n\\begin{align*}\n\\argmin_{\\substack{\n\\text{tr}(Y^\\dagger D Y = I)}}\n\\text{tr}(Y^\\dagger L Y)\n\\end{align*}\nThis translates to finding the minimum non-zero eigenvalues and eigenvectors of \n\\begin{align*}\nLf=\\lambda D y.\n\\end{align*} \n\\end{frame}\n\n\\section{Examples: Scikit-Learn}\n\n\n\\begin{frame}{Examples: Scikit-Learn}\n\nLet us go to a Jupyter notebook to see some examples.\n\n\\end{frame}\n\n\\section{Spectral Geometry*}\n\n\\subsection{The Laplacian}\n\n\\begin{frame}{The Laplacian}\nSecond order differential operator  \n$L:C_c^\\infty(M)\\longrightarrow C_c^\\infty(M)$.\n\\begin{itemize}\n\\item For $M = \\mathbb{R}^n$,  \n\\begin{align*}\nL = -\\sum_{i=1}^n \\frac{\\partial^2}{\\partial x_i^2}\n\\end{align*}\n\\item For $(M, g)$ Riemannian manifold, \n% - \\frac{1}{\\sqrt{|g|}}\\sum_{i=1}^n \\frac{\\partial}{\\partial x_i}\\left(\\sum_{j=1}^n \\sqrt{|g|} g^{ij}\\frac{\\partial}{\\partial x_j}\\right)\n\\begin{align*}\nL = - \\sum_{i=1}^n\\sum_{j=1}^n g^{ij}\\frac{\\partial^2}{\\partial x_i \\partial x_j} + \\text{lower order terms}.\n\\end{align*}\n\\pause\n\\end{itemize}\n\\begin{block}{Spectral Theorem (\\cite{R1997})}\nL is symmetric with respect to the inner product in $C^\\infty_c(M)$,\n\\begin{align*}\n(f,g)_{L^2} = \\int_M f(x)g(x)  dx.\n\\end{align*}\nIf $M$ is compact, there exists an orthonormal basis of $L^2(M)$ consisting of eigenvectors of $L$. Each eigenvalue is real.\n\\end{block}\n\\end{frame}\n\n\\begin{frame}{Embedding trough Eigenmaps}\nLet $(M, g)$ be a compact Riemannian manifold and $f:M\\longrightarrow \\mathbb{R}$. \n\\begin{itemize}\n\\item If $x, z\\in M$ are close, then\n\\begin{align*}\n|f(x)-f(z)| \\leq \\text{dist}_M(x,z) ||\\nabla f||+o(\\text{dist}_M(x,z)).\n\\end{align*}\n\\pause\n\\item We want a map that best preserves locality on average,\n\\begin{align}\\label{Eqn:argmin_f}\n\\argmin_{||f||_{L^2(M)}=1}\\int_M ||\\nabla f||^2 dx.\n\\end{align}\n\\pause\n\\item By Stokes' Theorem\n\\begin{align*}\n\\int_M ||\\nabla f||^2 dx = \\int_M (Lf)f dx = (Lf,f)_{L^2}.\n\\end{align*}\n\\item \\eqref{Eqn:argmin_f} must be an eigenvalue of the Laplacian. \n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{The Graph Laplacian as a Differential Operator}\n\\begin{figure}[h]\n\\begin{center}\n\\begin{tikzpicture}\n\\node [draw, circle] (a) at (0,0) {1};\n\\node [draw, circle] (b) at (-0.5,2) {2};\n\\node [draw, circle] (c) at (0,-1.5) {3};\n\\node [draw, circle] (d) at (3,0) {4};\n\\path [->] (a) edge node[left] {} (c);\n\\path [<-] (b) edge node[left] {} (a);\n\\path [<-] (d) edge node[left] {} (a);\n\\node at (0, 1 ) {$e_1$};\n\\node at (0.3, -0.7 ) {$e_2$};\n\\node at (1.5, 0.3 ) {$e_3$};\n\\end{tikzpicture}\n%\\caption{$2$-Torus $T^2 = S^1\\times S^1$. }\n\\end{center}\n\\end{figure}\n\\begin{align*}\n\\nabla = \\left(\n\\begin{array}{cccc}\n -1 & 1 & 0 & 0 \\\\\n -1 & 0 & 1 & 0 \\\\\n -1 & 0 & 0 & 1\n\\end{array}\n\\right)\n\\quad \n\\Rightarrow\n\\quad \n\\nabla^\\dagger \\nabla = \\left(\n\\begin{array}{cccc}\n 3 & -1 & -1 & -1 \\\\\n -1 & 1 & 0 & 0 \\\\\n -1 & 0 & 1 & 0 \\\\\n -1 & 0 & 0 & 1 \n\\end{array}\n\\right)\n\\end{align*}\nSo we see, \n\\begin{align*}\nL = \\nabla^\\dagger \\nabla. \n\\end{align*}\n\\end{frame}\n\n\\subsection{The Heat Kernel}\n\n\\begin{frame}{The Heat Kernel}\nLet $f:M\\longrightarrow \\mathbb{R}$. Consider the \\textbf{Heat Equation} on $M$, \n\\begin{align*}\n\\left({\\partial_t} + L\\right)u(x,t)  = 0\n\\quad \\text{with intitial condition}\n\\quad\nu(x,0) = f(x).\n\\end{align*}\n\\pause\n\\begin{itemize}\n\\item The solution is given by (\\cite{R1997})\n\\begin{align*}\nu(x,t) = \\int_{M} H_t(x,y)f(y) dy, \n\\end{align*}\nwhere the \\textbf{Heat Kernel} has the form\n\\begin{align*}\nH_t(x,y) = (4\\pi t)^{-\\text{dim}(M)/2} e^{-\\frac{\\text{dist}_M(x,y)^2}{4t}} (\\phi(x,y) + O(t)),\n\\end{align*}\nfor certain $\\phi$ is a smooth function with $\\phi(x,x) = 1$. \n\\pause\n\\item It can be shown that, for $x_1, \\cdots, x_k \\in M$ and $t>0$ small,\n\\begin{align*}\nLf(x_i) \\approx \\frac{1}{t}\\left(f(x_i) - \n\\frac{\n\\sum_{0 < ||x_i - x_j||^2 <\\varepsilon}\ne^{-\\frac{||x_i - x_j||^2}{4t}}f(x_j) \n}\n{\n\\sum_{0 < ||x_i - x_j||^2 <\\varepsilon}\ne^{-\\frac{||x_i - x_j||^2}{4t}}\n}\n\\right)\n\\end{align*}\nwhich justifies $W_{ij}=e^{-\\frac{||x_i - x_j||^2}{4t}}$. \n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{References}{Slides and notebook available at juanitorduz.github.io}\n\\bibliographystyle{alpha}\n\\bibliography{references} \n\\end{frame}\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "e445f182babe40aa966ed1f24533e31564196b9c", "size": 16088, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Presentations/pydata_2018/orduz_pydata_2018.tex", "max_stars_repo_name": "bacoco/website_projects", "max_stars_repo_head_hexsha": "1b72dc4b65aa134cf40880e871377964098acf84", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2020-03-30T19:02:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T09:15:28.000Z", "max_issues_repo_path": "Presentations/pydata_2018/orduz_pydata_2018.tex", "max_issues_repo_name": "bacoco/website_projects", "max_issues_repo_head_hexsha": "1b72dc4b65aa134cf40880e871377964098acf84", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2019-08-12T19:40:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-18T18:07:37.000Z", "max_forks_repo_path": "Presentations/pydata_2018/orduz_pydata_2018.tex", "max_forks_repo_name": "bacoco/website_projects", "max_forks_repo_head_hexsha": "1b72dc4b65aa134cf40880e871377964098acf84", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2019-03-28T09:05:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T09:15:30.000Z", "avg_line_length": 27.3605442177, "max_line_length": 190, "alphanum_fraction": 0.6647190453, "num_tokens": 6015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4290647211637263}}
{"text": "\\documentclass{article}\n\n\\begin{document}\n\t\\author{Dr. Desmond Moru}\n\t\\title{Cardano's Formula for Cubic Equations}\n\t\\maketitle\n\t\n\t\n\t\n\t\\begin{center}\n\t\t\\textbf{Abstract}\n\t\\end{center}\n\tGerolamo Cardano was born in Pavia 1504 as the illegitimate child of a jurist. He attended the University of Padua and became a physician in the town of Sacco, after being rejected by his home Europe, having treated the Pope. He was also an astrologer and an avid gambler, to which he wrote the Book on Games of chance , which was the first serious treatise on the mathematics of probalitity. \\cite{cardano}\n\t\n\t\\section{ Introduction to Cardano's Formula}\n\tCardano's formula for solution of cubic equations for an equation like;\n\t\\begin{equation}\n\t\tx^3 + a1x^2 + a2x + a3 = 0\n\t\\end{equation}\n\tthe parameters Q, R , S and T can be computed thus,\n\t\n\t\\begin{equation}\n\t\tQ= \\frac{3a_{2} - a{1}^2}{a}\n\t\\end{equation}\n\\begin{equation}\n\\frac{R=9a_{1}a_{2}-27a_{3}-2a_{1}^3}{54}\t\n\\end{equation}\n\\begin{equation}\n\tS=3\\sqrt{R +\\sqrt{-Q^3 + R^2}}\n\\end{equation}\n\\begin{equation}\n\tT=\\sqrt{R-\\sqrt{Q^3 + R^2}}\n\\end{equation}\n\nto give the roots\n\\begin{equation}\n\tx_{1}= S + T -\\frac{1}{3}a_{1}\n\\end{equation}\n\\begin{equation}\n\t\tx_{2} =\\frac{-(S +T)}{2} -\\frac{a_{1}}{3} + i\\frac{\\sqrt{3}(s-T)}{2}\n\\end{equation}\n\\begin{equation}\n\tx_{2} =\\frac{-(S +T)}{2} -\\frac{a_{1}}{3} + i\\frac{\\sqrt{3}(s-T)}{2}\n\\end{equation}\n\\subsection{Some examples}\n\n\\begin{itemize}\n\\item\t\\begin{equation}\n\t\tx^3 - 3x^2 + 4 =0\n\t\\end{equation}\n\\item\\begin{equation}\n\t2x^3 + 6x^2 + 1 =0\n\\end{equation}\n\\end{itemize}\n\n\\bibliography{take_away}\n\\bibliographystyle{ieeetr}\n\\end{document}", "meta": {"hexsha": "cbf26eddf26b719dac767c0f874a81266b2705f7", "size": 1626, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "take_away.tex", "max_stars_repo_name": "adaobi15/adaobiCSC101", "max_stars_repo_head_hexsha": "2c5a99694226c11f3c1a0feb885bf5300e7132ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "take_away.tex", "max_issues_repo_name": "adaobi15/adaobiCSC101", "max_issues_repo_head_hexsha": "2c5a99694226c11f3c1a0feb885bf5300e7132ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "take_away.tex", "max_forks_repo_name": "adaobi15/adaobiCSC101", "max_forks_repo_head_hexsha": "2c5a99694226c11f3c1a0feb885bf5300e7132ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0344827586, "max_line_length": 408, "alphanum_fraction": 0.6888068881, "num_tokens": 625, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018545, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.42906470527217466}}
{"text": "%\\documentclass{article}\r\n%\\usepackage[all]{xy}\r\n%\\usepackage{amssymb}\r\n%\\usepackage{amsmath}\r\n%\\usepackage{amsfonts}\r\n%\\usepackage{amsthm}\r\n%\\usepackage{amscd}\r\n%\\usepackage{eucal}\r\n%\\usepackage[dvips]{epsfig}\r\n%\\usepackage{graphicx}\r\n%\\usepackage{ulem}\r\n%\\usepackage{wrapfig}\r\n%\\addtolength{\\hoffset}{-2cm}\r\n%\\addtolength{\\topmargin}{-2.8cm}\r\n%\\addtolength{\\textwidth}{3 cm}\r\n%\\addtolength{\\textheight}{6.2 cm}\r\n%\r\n%\\def\\ii{{\\bf i}}\r\n%\\def\\jj{{\\bf j}}\r\n%\\def\\kk{{\\bf k}}\r\n%\\def\\aa{{\\bf a}}\r\n%\\def\\bb{{\\bf b}}\r\n%\\def\\nn{{\\bf n}}\r\n%\\def\\uu{{\\bf u}}\r\n%\\def\\vv{{\\bf v}}\r\n%\\def\\rr{{\\bf r}}\r\n%\\def\\ff{{\\bf F}}\r\n%\r\n%\\begin{document}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\chapter{DERIVATION OF THE $\\Upsilon$ FUNCTION}%\r\n\\label{appendixB}\r\n\r\n%%\\clearpage %remove this command if your appendix doesn't start with a landscaped page!!!!!\r\n%%\\thispagestyle{plain}\r\n%%\\begin{landscape}\r\n%%\\begin{figure}\r\n\r\n %% \\begin{center}\r\n  %%  \\includegraphics[width=6in]{LaTeX2e_logo.eps}\r\n   %% \\caption{\\LaTeX 2\\ensuremath{\\epsilon.} logo}\\label{biglogo}\r\n  %%\\end{center}\r\n%%\\end{figure}\r\n%%\\end{landscape}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\r\n%ADD LABEL\r\n\r\n\r\nProposition B.3.\r\n\r\nSuppose $\\{\\xi_{1},\\xi_{2},...\\}$ is a sequence of i.i.d. exponential random variables with rate $\\eta>0$, and Z is a normal variable with distribution $N(0,\\sigma^{2})$. Then for every $ n \\geq 1$, we have: (1) The density functions are given by:\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=(\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}Hh_{n-1}(-\\frac{t}{\\sigma}+\\sigma\\eta)$$\r\n\r\n$$f_{Z-\\sum_{i=1}^{n}\\xi_{i}}(t)=(\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}Hh_{n-1}(\\frac{t}{\\sigma}+\\sigma\\eta)$$\r\n\r\n(2) The tail probabilities are given by\r\n\r\n$$P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x) = (\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}I_{n-1}(x;-\\eta,-\\frac{1}{\\sigma},-\\sigma\\eta)$$\r\n\r\n$$P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x) = (\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}I_{n-1}(x;\\eta,\\frac{1}{\\sigma},-\\sigma\\eta)$$\r\n\r\nProof. Case 1. The densities of $Z+\\sum_{i=1}^{n}\\xi_{i}$, and $Z-\\sum_{i=1}^{n}\\xi_{i}$. We have\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=\\int_{-\\infty}^{\\infty}f_{\\sum_{i=1}^{n}\\xi_{i}}(t-x)f_{Z}(x)dx$$\r\n\r\n$$=e^{-t\\eta}(\\eta^{n})\\int_{-\\infty}{t}\\frac{e^{x\\eta}(t-x)^{n-1}}{(n-1)!}\\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-x^{2}/(2\\sigma^{2})}dx$$\r\n\r\n$$=e^{-t\\eta}(\\eta^{n})e^{(\\sigma\\eta)^{2}/(2)}\\int_{-\\infty}{t}\\frac{(t-x)^{n-1}}{(n-1)!}\\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-(x-\\sigma^{2}\\eta)^{2}/(2\\sigma^{2})}dx$$\r\n\r\nLetting $y=(x-\\sigma^{2}\\eta)/\\sigma$ yields\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=e^{-t\\eta}(\\eta^{n})e^{(\\sigma\\eta)^{2}/(2)}\\sigma^{n-1}$$\r\n\r\n$$\\times\\int_{-\\infty}^{t/\\sigma-\\sigma\\eta}\\frac{(t/\\sigma - y -\\sigma\\eta)^{n-1}}{(n-1)!}\\frac{1}{\\sqrt{2\\pi}}e^{-y^{2}/2}dy$$\r\n\r\n$$=\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sqrt{2\\pi}}(\\sigma^{n-1}\\eta^{n})e^{-t\\eta}Hh_{n-1}(-t/\\sigma + \\sigma\\eta)$$\r\n\r\nbecause $(1/(n-1)!)\\int_{-\\infty}{a}(a-y)^{n-1}e^{-y^{2}/2}dy=Hh_{n-1}(a)$. The derivation of $f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)$ is similar.\r\n\r\nCase 2. $P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x)$ and $P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x)$. From (B9), it is clear that\r\n\r\n$$P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x)=\\frac{(\\sigma\\eta)^{n}e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}\\int_{x}^{\\infty}e^{(-i\\eta)}Hh_{n-1}(-\\frac{t}{\\sigma}+\\sigma\\eta)dt$$\r\n\r\n$$=\\frac{(\\sigma\\eta)^{n}e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}I_{n-1}(x;-\\eta,-\\frac{1}{\\sigma},-\\sigma\\eta)dt$$\r\n\r\nby (B6). We can compute\r\n$P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x)$ similarly.\r\n\r\nTheorem B.1. With $\\pi_{n}:= P(N(t)=n)=e^{-\\lambda T}(\\lambda T)^{n}/n!$ and $I_{n}$ in Proposition B.\r\n, we have\r\n\r\n$$P(Z(T)\\geq a)=\\frac{e^{(\\sigma \\eta_{1})^{2} T/2}}{\\sigma \\sqrt{2 \\pi T}} \\sum_{n=1}^{\\infty} \\pi_{n} \\sum_{k=1}^{n} P_{n,k}(\\sigma\\sqrt{T}\\eta_{1})^{k}\\times I_{k-1}(a-\\mu T; -\\eta_{1},-\\frac{1}{\\sigma\\sqrt{T}},-\\sigma\\eta_{1}\\sqrt{T})$$\r\n\r\n$$+\\frac{e^{(\\sigma\\eta_{2})^{2}T/2}}{\\sigma\\sqrt{2\\pi T}}\\sum_{n=1}^{\\infty}\\pi_{n}\\sum_{k=1}^{n}Q_{n,k}(\\sigma\\sqrt{T}\\eta_{2})^{k}$$\r\n\r\n$$\\times I_{k-1}(a-\\mu T; \\eta_{2},\\frac{1}{\\sigma\\sqrt{T}},-\\sigma\\eta_{2}\\sqrt{T})$$\r\n\r\n$$+\\pi_{0}\\phi(-\\frac{a-\\mu T}{\\sigma\\sqrt{T}})$$\r\n\r\nProof by the decomposition (B2)\r\n\r\n\r\n\r\n%\\end{document}\r\n", "meta": {"hexsha": "4d740603bd6838142fafe39729267b13bf60aeb1", "size": 4385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixD.tex", "max_stars_repo_name": "mshahriarinia/neonDSR", "max_stars_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-12-17T17:00:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-28T14:28:35.000Z", "max_issues_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixD.tex", "max_issues_repo_name": "mshahriarinia/neonDSR", "max_issues_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixD.tex", "max_forks_repo_name": "mshahriarinia/neonDSR", "max_forks_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-12-13T13:57:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-28T01:36:28.000Z", "avg_line_length": 39.5045045045, "max_line_length": 248, "alphanum_fraction": 0.5420752566, "num_tokens": 1925, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.4290647035626312}}
{"text": "\\section{Statistical Analysis through RAVEN}\n\\label{sec:SAraven}\nIn order to perform a complete analysis of a system under uncertainties,\nit is crucial to be able to compute all the statistical moments of one or even multiple\nFOMs. In addition, it is essential to identify the correlation\namong different FOMs toward a specific input space.\n\nRAVEN is able to compute the most important statistical moments:\nsuch as:\n\\begin{enumerate}\n  \\item \\textit{Expected Value}\n  \\item \\textit{Standard Deviation}\n  \\item \\textit{Variance}\n  \\item \\textit{variationCoefficient}\n  \\item \\textit{Skewness}\n  \\item \\textit{Kurtosis}\n  \\item \\textit{Median}\n  \\item \\textit{Percentile}.\n\\end{enumerate}\nIn addition, RAVEN fully supports the computation of all of the statistical moments defined to\n``measure'' the correlation among variables/parameters/FOMs:\n\\begin{enumerate}\n  \\item \\textit{Covariance matrix}\n  \\item \\textit{Normalized Sensitivity  matrix}\n  \\item \\textit{Variance Dependent Sensitivity  matrix}\n  \\item \\textit{Sensitivity matrix}\n  \\item \\textit{Pearson matrix}.\n\\end{enumerate}\nThe goals of this section is to show how to:\n \\begin{enumerate}\n   \\item Set up a sampling strategy to perform a final statistical analysis\n   perturbing a driven code\n   \\item Compute all the statistical moments and correlation/covariance\n   metrics.\n\\end{enumerate}\nIn order to accomplish these tasks, the following RAVEN \\textbf{Entities} (XML blocks in the input files) need to be defined:\n\\begin{enumerate}\n   \\item \\textbf{\\textit{RunInfo}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{RunInfo}\n   As shown in the other examples, the \\textit{RunInfo} \\textbf{Entity} is intended  to set up the desired analysis . In this specific case, two steps  (\\xmlNode{Sequence}) are  sequentially run\n   using forty processors (\\xmlNode{batchSize}).\n   \\\\In the first step, the original physical model is sampled. The obtained results are  analyzed with the Statistical Post-Processor.\n   \\item \\textbf{\\textit{Files}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{Files}\n   Since the driven code uses a single input file, in this section the original input is placed. As detailed in the user manual\n   the attribute  \\xmlAttr{name} represents the alias that is going to be\n   used in all the other input blocks in order to refer to this file.\n   \\\\In addition, the output file of the \\textit{PostProcess} \\textbf{Step} is\n   here defined (XML format).\n   \\item \\textbf{\\textit{Models}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{Models}\n The goal of this example is to show how the\n principal statistical FOMs can be computed through RAVEN.\n \\\\Indeed, in addition to the previously explained Code\n model, a Post-Processor model (BasicStatistics) is here specified.\nNote that the post-process step is\nperformed on all the variables with respect to the parameters used in this example ( $A,\\, B,\\, C \\, and \\, D$\nwith respect to $sigma-A,\\,sigma-B,\\, decay-A,$ and $decay-B$).\n   \\item \\textbf{\\textit{Distributions}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{Distributions}\n  In the Distributions XML section, the stochastic models for the\n  uncertainties are reported. In\n  this case 2 distributions are defined:\n  \\begin{itemize}\n    \\item $sigma \\sim \\mathbb{U}(0,1000)$, used to model the uncertainties\n    associated with  the Model \\textit{sigma-A} and \\textit{sigma-B}\n    \\item  $decayConstant \\sim \\mathbb{U}(1e-8,1e-7)$,  used to\n    model the uncertainties\n    associated with  the Model \\textit{decay-A} and \\textit{decay-B}.\n  \\end{itemize}\n   \\item \\textbf{\\textit{Samplers}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{Samplers}\n  In order to obtained the data-set through which the statistical FOMs need to be computed, a \\textit{MonteCarlo} sampling approach is here employed.\n   \\item \\textbf{\\textit{DataObjects}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{DataObjects}\n  Int this block, two \\textit{DataObjects} are defined:\n  1) PointSet named ``samplesMC'' used to collect the final outcomes of\n  the code,\n  2) HistorySet named ``histories'' in which the full time responses of the\n  variables $A,B,C,D$ are going to be stored.\n\n   \\item \\textbf{\\textit{Steps}}:\n     \\xmlExample{framework/user_guide/StatisticalAnalysis/statisticalAnalysis.xml}{Steps}\n\n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n   Finally, all the previously defined \\textbf{Entities} can be combined in\n   the \\xmlNode{Steps} block. As inferable,\n   2 \\xmlNode{Steps} have been inputted:\n   \\begin{itemize}\n     \\item \\xmlNode{MultiRun} named ``sampleMC'', used to run the\n     multiple\n     instances of the driven code and\n     collect the outputs in the two \\textit{DataObjects}. As it can be\n     seen, the \\xmlNode{Sampler} is inputted to communicate to the\n     \\textit{Step} that the driven code needs to\n     be perturbed through the Grid sampling strategy.\n     \\item \\xmlNode{PostProcess} named ``statisticalAnalysisMC'', used\n     compute all the statistical moments and FOMs based on the\n     data obtained through the sampling strategy. As it can be noticed,\n     the \\xmlNode{Output} of the ``sampleMC'' \\textit{Step} is the\n     \\xmlNode{Input} of the ``statisticalAnalysisMC''  \\textit{Step}.\n   \\end{itemize}\n\\end{enumerate}\n\nTables \\ref{ScalarMoments}-\\ref{SensitivityComputed} show all the results of the \\textit{PostProcess}\nstep.\n\n\n\\begin{landscape}\n\\begin{table}[h!]\n\\centering\n\\caption{Computed Moments and Cumulants.}\n\\label{ScalarMoments}\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\n\\hline\n{\\ul \\textit{\\textbf{Computed Quantities}}} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{decay-A} & \\textbf{decay-B} & \\textbf{sigma-A} & \\textbf{sigma-B} \\\\ \\hline\n\\textit{expected value}                     & 5.97E-02   & 3.97E-01   & 9.82E-01   & 1.50E+00   & 5.57E-08         & 5.61E-08         & 5.07E+02         & 4.73E+02         \\\\ \\hline\n\\textit{median}                             & 2.45E-02   & 3.06E-01   & 9.89E-01   & 1.54E+00   & 5.73E-08         & 5.62E-08         & 5.11E+02         & 4.70E+02         \\\\ \\hline\n\\textit{variance}                           & 8.19E-03   & 6.00E-02   & 1.19E-02   & 1.49E-02   & 7.00E-16         & 6.83E-16         & 8.52E+04         & 8.64E+04         \\\\ \\hline\n\\textit{sigma}                              & 9.05E-02   & 2.45E-01   & 1.09E-01   & 1.22E-01   & 2.64E-08         & 2.61E-08         & 2.92E+02         & 2.94E+02         \\\\ \\hline\n\\textit{variation coefficient}              & 1.52E+00   & 6.17E-01   & 1.11E-01   & 8.15E-02   & 4.75E-01         & 4.66E-01         & 5.75E-01         & 6.21E-01         \\\\ \\hline\n\\textit{skewness}                           & 2.91E+00   & 9.88E-01   & -1.49E-01  & -9.64E-01  & -6.25E-02        & -5.75E-02        & -2.18E-02        & 7.62E-02         \\\\ \\hline\n\\textit{kurtosis}                           & 9.56E+00   & -1.12E-01  & -6.98E-01  & -1.50E-01  & -1.24E+00        & -1.21E+00        & -1.21E+00        & -1.20E+00        \\\\ \\hline\n\\textit{percentile 5\\%}                     & 2.87E-03   & 1.48E-01   & 7.89E-01   & 1.24E+00   & 1.42E-08         & 1.45E-08         & 5.08E+01         & 2.97E+01         \\\\ \\hline\n\\textit{percentile 95\\%}                    & 2.51E-01   & 9.19E-01   & 1.16E+00   & 1.63E+00   & 9.54E-08         & 9.48E-08         & 9.59E+02         & 9.49E+02         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\begin{table}[h!]\n\\centering\n\\caption{Covariance matrix.}\n\\label{covarianceComputed}\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\n\\hline\n{\\ul \\textit{\\textbf{Covariance}}} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{decay-A} & \\textbf{decay-B} & \\textbf{sigma-A} & \\textbf{sigma-B} \\\\ \\hline\n\\textbf{A}                         & 8.19E-03   & -1.11E-03  & -3.09E-03  & -1.13E-04  & -1.28E-09        & 5.14E-11         & -1.49E+01        & -3.74E-01        \\\\ \\hline\n\\textbf{B}                         & -1.11E-03  & 6.00E-02   & 2.26E-03   & -2.96E-02  & -7.80E-11        & -6.02E-09        & 7.00E+00         & -1.47E+00        \\\\ \\hline\n\\textbf{C}                         & -3.09E-03  & 2.26E-03   & 1.19E-02   & 7.15E-04   & -1.44E-09        & -4.11E-12        & 2.63E+01         & 3.19E-01         \\\\ \\hline\n\\textbf{D}                         & -1.13E-04  & -2.96E-02  & 7.15E-04   & 1.49E-02   & -1.21E-10        & 3.01E-09         & 1.12E+00         & 8.01E-01         \\\\ \\hline\n\\textbf{decay-A}                   & -1.28E-09  & -7.80E-11  & -1.44E-09  & -1.21E-10  & 7.00E-16         & -1.73E-17        & -1.26E-07        & 2.07E-07         \\\\ \\hline\n\\textbf{decay-B}                   & 5.14E-11   & -6.02E-09  & -4.11E-12  & 3.01E-09   & -1.73E-17        & 6.83E-16         & -1.86E-07        & 3.91E-08         \\\\ \\hline\n\\textbf{sigma-A}                   & -1.49E+01  & 7.00E+00   & 2.63E+01   & 1.12E+00   & -1.26E-07        & -1.86E-07        & 8.52E+04         & 1.79E+03         \\\\ \\hline\n\\textbf{sigma-B}                   & -3.74E-01  & -1.47E+00  & 3.19E-01   & 8.01E-01   & 2.07E-07         & 3.91E-08         & 1.79E+03         & 8.64E+04         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\begin{table}[h!]\n\\centering\n\\caption{Correlation matrix.}\n\\label{pearsonComputed}\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\n\\hline\n{\\ul \\textit{\\textbf{Correlation}}} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{decay-A} & \\textbf{decay-B} & \\textbf{sigma-A} & \\textbf{sigma-B} \\\\ \\hline\n\\textbf{A}                          & 1.00E+00   & -5.02E-02  & -3.13E-01  & -1.03E-02  & -5.35E-01        & 2.17E-02         & -5.63E-01        & -1.40E-02        \\\\ \\hline\n\\textbf{B}                          & -5.02E-02  & 1.00E+00   & 8.47E-02   & -9.90E-01  & -1.20E-02        & -9.41E-01        & 9.80E-02         & -2.04E-02        \\\\ \\hline\n\\textbf{C}                          & -3.13E-01  & 8.47E-02   & 1.00E+00   & 5.37E-02   & -4.98E-01        & -1.44E-03        & 8.25E-01         & 9.96E-03         \\\\ \\hline\n\\textbf{D}                          & -1.03E-02  & -9.90E-01  & 5.37E-02   & 1.00E+00   & -3.75E-02        & 9.43E-01         & 3.14E-02         & 2.23E-02         \\\\ \\hline\n\\textbf{decay-A}                    & -5.35E-01  & -1.20E-02  & -4.98E-01  & -3.75E-02  & 1.00E+00         & -2.50E-02        & -1.64E-02        & 2.67E-02         \\\\ \\hline\n\\textbf{decay-B}                    & 2.17E-02   & -9.41E-01  & -1.44E-03  & 9.43E-01   & -2.50E-02        & 1.00E+00         & -2.44E-02        & 5.08E-03         \\\\ \\hline\n\\textbf{sigma-A}                    & -5.63E-01  & 9.80E-02   & 8.25E-01   & 3.14E-02   & -1.64E-02        & -2.44E-02        & 1.00E+00         & 2.08E-02         \\\\ \\hline\n\\textbf{sigma-B}                    & -1.40E-02  & -2.04E-02  & 9.96E-03   & 2.23E-02   & 2.67E-02         & 5.08E-03         & 2.08E-02         & 1.00E+00         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\begin{table}[h!]\n\\centering\n\\caption{Variance Dependent Sensitivity matrix.}\n\\label{VarDepSensitivityComputed}\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\n\\hline\n{\\ul \\textit{\\textbf{Variance Sensitivity}}} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{decay-A} & \\textbf{decay-B} & \\textbf{sigma-A} & \\textbf{sigma-B} \\\\ \\hline\n\\textbf{A}                                   & 1.00E+00   & -1.36E-01  & -3.77E-01  & -1.38E-02  & -1.56E-07        & 6.27E-09         & -1.82E+03        & -4.56E+01        \\\\ \\hline\n\\textbf{B}                                   & -1.86E-02  & 1.00E+00   & 3.77E-02   & -4.94E-01  & -1.30E-09        & -1.00E-07        & 1.17E+02         & -2.45E+01        \\\\ \\hline\n\\textbf{C}                                   & -2.60E-01  & 1.90E-01   & 1.00E+00   & 6.01E-02   & -1.21E-07        & -3.46E-10        & 2.21E+03         & 2.68E+01         \\\\ \\hline\n\\textbf{D}                                   & -7.60E-03  & -1.99E+00  & 4.80E-02   & 1.00E+00   & -8.11E-09        & 2.02E-07         & 7.51E+01         & 5.37E+01         \\\\ \\hline\n\\textbf{decay-A}                             & -1.83E+06  & -1.11E+05  & -2.05E+06  & -1.73E+05  & 1.00E+00         & -2.47E-02        & -1.81E+08        & 2.96E+08         \\\\ \\hline\n\\textbf{decay-B}                             & 7.52E+04   & -8.82E+06  & -6.02E+03  & 4.40E+06   & -2.53E-02        & 1.00E+00         & -2.72E+08        & 5.72E+07         \\\\ \\hline\n\\textbf{sigma-A}                             & -1.75E-04  & 8.22E-05   & 3.08E-04   & 1.32E-05   & -1.48E-12        & -2.19E-12        & 1.00E+00         & 2.10E-02         \\\\ \\hline\n\\textbf{sigma-B}                             & -4.33E-06  & -1.70E-05  & 3.69E-06   & 9.27E-06   & 2.40E-12         & 4.52E-13         & 2.07E-02         & 1.00E+00         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\begin{table}[h!]\n\\centering\n\\caption{Sensitivity matrix.}\n\\label{SensitivityComputed}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n{\\ul \\textit{\\textbf{Sensitivity (I/O)}}} & \\textbf{decay-A} & \\textbf{decay-B} & \\textbf{sigma-A} & \\textbf{sigma-B} \\\\ \\hline\n\\textbf{A}                                & 3.83E-06         & -1.78E-04        & -2.07E+04        & -1.86E+06        \\\\ \\hline\n\\textbf{B}                                & -1.36E-05        & 6.28E-05         & -8.80E+06        & -3.14E+05        \\\\ \\hline\n\\textbf{C}                                & 2.17E-06         & 3.05E-04         & 2.64E+04         & -2.00E+06        \\\\ \\hline\n\\textbf{D}                                & 6.96E-06         & 2.25E-05         & 4.40E+06         & -6.19E+04        \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\end{landscape}\n\n", "meta": {"hexsha": "44d33208997cf74aee59bca4f0254c6a6c11c055", "size": 13711, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user_guide/statisticalAnalysisExample.tex", "max_stars_repo_name": "milljm/raven", "max_stars_repo_head_hexsha": "5f29fe81b75e2ffbeb54a55aa63647e7b2f6457b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/user_guide/statisticalAnalysisExample.tex", "max_issues_repo_name": "milljm/raven", "max_issues_repo_head_hexsha": "5f29fe81b75e2ffbeb54a55aa63647e7b2f6457b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/user_guide/statisticalAnalysisExample.tex", "max_forks_repo_name": "milljm/raven", "max_forks_repo_head_hexsha": "5f29fe81b75e2ffbeb54a55aa63647e7b2f6457b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.3128205128, "max_line_length": 194, "alphanum_fraction": 0.5511632995, "num_tokens": 5158, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.42892566000872273}}
{"text": "\\documentclass[tiles]{cornellnotes}\r\n\r\n\\title{Data Science}\r\n\\author{Naga Nitish}\r\n\\date{May 2020}\r\n\r\n\\begin{document}\r\n        \\maketitle\r\n        \\section{Probability}\r\n        \\begin{cuenotes}\r\n                \\cue{first cue?}\r\n                \\note{\r\n                        \\subsection*{Introduction}\r\n                        \\begin{itemize}\r\n                                \\item Probability is the liklihood of event occuring\r\n                                \\item Trail -- Observing an event occur and note the outcome\r\n                                \\item Experiment -- Collection of trails\r\n                                \\item Expected value -- The outcome we expect from an experiment\r\n                                \\item Probability frequency distribution --  collection of probabilities of each possible outcome of an event\r\n                                \\item Permutations -- represents the number of different possible ways we can arrange a set of elements -- $n!$\r\n                                \\item Variations -- represents the number of different possible ways we can pick and arrange a number of elements\r\n                                \\begin{itemize}\r\n                                        \\item With repetition -- $n^p$\r\n                                        \\item Without repetition -- $^nP_p=\\frac{n!}{(n-p)!}$\r\n                                \\end{itemize}\r\n                                \\item Combinations -- represents number of different possible ways we can pick elements\r\n                                \\item Baye's theorem -- $P(A|B) = P(B|A)*P(A)/P(B)$\r\n                        \\end{itemize}\r\n                }\r\n                \\cue{second cue?}\r\n                \\note{\r\n                        \\subsection*{Distributions}\r\n                        There are two types of distributions: They are Discrete and Continuous\r\n                }\r\n                \\note{\r\n                        \\subsubsection*{Discrete}\r\n                        \\begin{enumerate}\r\n                                \\item Uniform\r\n                                \\item Bernoulli\r\n                                \\begin{itemize}\r\n                                        \\item one trail -- two possibilities\r\n                                        \\item $E(Y)=p$\r\n                                        \\item $Var(Y)=p(1-p)$\r\n                                \\end{itemize}\r\n                                \\item Binomial\r\n                                \\begin{itemize}\r\n                                        \\item measures the frequencies of occurrence of one of the possible outcomes over n trails\r\n                                        \\item $P(Y=y) = C(y,n)\\times p^y\\times (1-p)^{n-y}$\r\n                                        \\item $E(Y) = n\\times p$\r\n                                        \\item $Var(Y) = n\\times p\\times (1-p)$\r\n                                \\end{itemize}\r\n                                \\item Poisson\r\n                                \\begin{itemize}\r\n                                        \\item measures the frequency over an interval of time or distance\r\n                                        \\item only non-negative values\r\n                                        \\item $P(Y=y) = \\frac{\\lambda^y}{y!e^{-\\lambda}}$\r\n                                        \\item $E(Y) = Var(Y) = \\lambda$\r\n                                \\end{itemize}\r\n                        \\end{enumerate}\r\n                }\r\n                \\cue{third cue?}\r\n                \\note{\r\n                        \\subsubsection*{Continuous}\r\n                        \\begin{enumerate}\r\n                                \\item Normal\r\n                                \\begin{itemize}\r\n                                        \\item bell shaped, symmetric, thin tails\r\n                                        \\item $E(Y) = \\mu$\r\n                                        \\item $Var(Y) = \\sigma^2$\r\n                                \\end{itemize}\r\n                                \\item Students' T\r\n                                \\begin{itemize}\r\n                                        \\item a small sample size approximation of normal distribution\r\n                                        \\item bell shaped, symmetric, flat tails\r\n                                        \\item accounts for extreme values better than normal distribution\r\n                                        \\item $Var(Y) = s^2 \\times \\frac{k}{k-2}$\r\n                                \\end{itemize}\r\n                                \\item Chi squared\r\n                                \\begin{itemize}\r\n                                        \\item asymmetric, skewed to right\r\n                                        \\item it is square of T distribution\r\n                                        \\item $E(Y) = k$\r\n                                        \\item $Var(Y) = 2k$\r\n                                \\end{itemize}\r\n                                \\item Exponential\r\n                                \\begin{itemize}\r\n                                        \\item Both PDF and CDF plateau after certain point\r\n                                        \\item $E(Y) = \\frac{1}{\\lambda}$\r\n                                        \\item $Var(Y) = \\frac{1}{\\lambda^2}$\r\n                                \\end{itemize}\r\n                                \\item Logistic\r\n                                \\begin{itemize}\r\n                                        \\item The smaller the scale parameter, the quicker it reaches 1.0\r\n                                        \\item $E(Y) = \\mu$\r\n                                        \\item $Var(Y) = \\frac{s^2 \\times \\pi^2}{3}$\r\n                                \\end{itemize}\r\n                        \\end{enumerate}\r\n                }\r\n        \\end{cuenotes}\r\n        \\summary{\r\n                \\begin{enumerate}\r\n                        \\item something random\r\n                        \\item something random\r\n                        \\item something random\r\n                \\end{enumerate}\r\n        }\r\n        \\section{Statistics}\r\n        \\begin{cuenotes}\r\n                \\cue\r\n                \\note{\r\n                        \\subsection*{Types of Data}\r\n                        \\subsubsection*{Qualitative data or categorical data}\r\n                        \\begin{itemize}\r\n                                \\item Nominal - values not order\r\n                                \\item Ordinal - there is order or ranking\r\n                        \\end{itemize}\r\n                        \\subsubsection*{Quantitative data}\r\n                        \\begin{itemize}\r\n                                \\item Discrete\r\n                                \\item Continuous\r\n                        \\end{itemize}\r\n                }\r\n                \\cue\r\n                \\note{\r\n                        \\subsection*{Types of statistics}\r\n                }\r\n                \\note{\r\n                        \\subsubsection*{Descriptive}\r\n                        \\begin{itemize}\r\n                                \\item To describe data\r\n                                \\item Measure of central tendencies\r\n                                \\begin{itemize}\r\n                                        \\item \\textbf{Mean or average} -- sum of all values divided by number of values\r\n                                        \\item \\textbf{Median} -- middle term in the sorted list\r\n                                        \\item \\textbf{Mode} -- value with highest frequency\r\n                                        \\item \\textbf{Mid-range} -- average of largest and smallest value\r\n                                \\end{itemize}\r\n                                \\item Measure of dispersion\r\n                                \\begin{itemize}\r\n                                        \\item \\textbf{Range} -- largest minus smallest value\r\n                                        \\item \\textbf{Standard deviation} -- square root of variance\r\n                                        \\item \\textbf{Variance} -- average of squared differences of the mean\r\n                                \\end{itemize}\r\n                                \\item Frequency distributions\r\n                                \\item Histograms\r\n                                \\begin{itemize}\r\n                                        \\item It's a bar graph with equal width\r\n                                        \\item Properties -- symmetric, skewed and uniform or rectangular\r\n                                \\end{itemize}\r\n                        \\end{itemize}\r\n                }\r\n                \\note{\r\n                        \\subsubsection*{Inferential}\r\n                        \\begin{itemize}\r\n                                \\item To make inferences from data\r\n                                \\item Hypothesis testing\r\n                                \\item ANOVA\r\n                                \\item Chi-squared tests\r\n                                \\item Regression\r\n                        \\end{itemize}\r\n                }\r\n                \\cue\r\n                \\note{\r\n                        \\subsubsection*{Some important points}\r\n                        \\begin{itemize}\r\n                                \\item \\textbf{Skewness} -- Left (negative) skewness means that the outliers are to the left\r\n                                \\item \\textbf{Covariance} -- It is joint variability of two variables\r\n                                $$\\sigma_{xy} = \\frac{\\Sigma_{i=1}^N (x_i - \\mu_x) \\times (y_i - \\mu_y)}{n-1}$$\r\n                                \\item \\textbf{Correlation}\r\n                                $$\\rho = \\frac{\\sigma_{xy}}{\\sigma_x \\sigma_y}$$\r\n                        \\end{itemize}\r\n                }\r\n                \\note{\r\n                        \\subsection*{Central Limit Theorem}\r\n                        The Central Limit Theorem (CLT) is one of the greatest statistical insights. It states that no matter the underlying distribution of the dataset, the sampling distribution of the means would approximate a normal distribution. Moreover, the mean of the sampling distribution would be equal to the mean of the original distribution and the variance would be n times smaller, where n is the size of the samples. The CLT applies whenever we have a sum or an average of many variables (e.g. the sum of rolled numbers when rolling dice)\r\n                        \\begin{itemize}\r\n                                \\item \\textbf{Estimator} is a mathematical function that approximates a population parameter depending only on sample information\r\n                                \\item \\textbf{Estimate} is the output that we get from estimator. Point estimate and confidence interval estimate\r\n                        \\end{itemize}\r\n                }\r\n                \\note{\r\n                        \\subsubsection*{Confidance interval estimate}\r\n                        With population variance\r\n                        $$\\bar{x} \\pm z_{\\alpha/2} \\times \\frac{\\sigma}{\\sqrt{n}}$$\r\n                        Without population variance\r\n                        $$\\bar{x} \\pm t_{n-1,\\alpha/2} \\times \\frac{s}{\\sqrt{n}}$$\r\n                        where standard error is $s/\\sqrt{n}$\r\n                }\r\n        \\end{cuenotes}\r\n        \\summary{\r\n                \\begin{enumerate}\r\n                        \\item something random\r\n                        \\item something random\r\n                        \\item something random\r\n                        \\item something random\r\n                        \\item something random\r\n                \\end{enumerate}\r\n        }\r\n\\end{document}", "meta": {"hexsha": "eaf37c8723bc86b35166cd0c1305facb51abf40f", "size": 11550, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "example.tex", "max_stars_repo_name": "ChNagaNitish/cornell-notes-latex", "max_stars_repo_head_hexsha": "91b96c64816f5d38d0298e95c6b566572a0215b2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-14T22:27:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:55:13.000Z", "max_issues_repo_path": "example.tex", "max_issues_repo_name": "ChNagaNitish/cornell-notes-latex", "max_issues_repo_head_hexsha": "91b96c64816f5d38d0298e95c6b566572a0215b2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "example.tex", "max_forks_repo_name": "ChNagaNitish/cornell-notes-latex", "max_forks_repo_head_hexsha": "91b96c64816f5d38d0298e95c6b566572a0215b2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-08-07T11:54:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-11T03:42:54.000Z", "avg_line_length": 58.040201005, "max_line_length": 555, "alphanum_fraction": 0.3915151515, "num_tokens": 1971, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.42888711494931664}}
{"text": "\\documentclass{article}\n\\usepackage{titling}\n\\usepackage{fancyhdr}\n\\usepackage{amsmath,bm}\n\\usepackage{chngcntr}\n\\counterwithin*{equation}{section}\n\\counterwithin*{equation}{subsection}\n\\renewcommand{\\theequation}{\\arabic{equation}}\n\\pretitle{\\begin{flushleft}\\huge}\n\\posttitle{\\par\\end{flushleft}\\vspace{-8mm}}\n\\preauthor{\\begin{flushleft}\n            % \\large \\lineskip 0em%\n            \\begin{tabular}[t]{r}}\n\\postauthor{\\end{tabular}\\par\\end{flushleft}\\vspace{-8mm}}\n\\predate{\\begin{flushleft}\\small}\n\\postdate{\\par\\end{flushleft}}\n\\pagestyle{fancy}\n\\fancyhead[L]{killPRML}\n\\fancyhead[R]{@anlijuncn}\n\\fancyfoot[C]{\\thepage}\n\\renewcommand{\\headrulewidth}{4pt}\n\\title{Chapter 2 Probability Distributions}\n\\author{}\n\\date{}\n%---------------------------------------------------%\n\\begin{document}\n\\maketitle\n\\section{Exercise 2.1}\nBy Bernulli distribution defination, we have\n\\begin{align}\n    \\sum_{x_i=0, 1} p(x_i|\\mu) = \\mu + (1 - \\mu) = 1\n\\end{align}\nBy expectation defination, we have\n\\begin{align}\n    E[x] = \\sum_{x_i=0, 1} x_ip(x_i|\\mu) = 0 * (1 - \\mu) + 1 * \\mu=\\mu\n\\end{align}\nBy variance defination, we have\n\\begin{align}\n    Var[x] & = \\sum_{x_i=0, 1} (x_i - E[x])^2p(x_i|\\mu) \\\\\n    & = \\mu^2 (1 - \\mu) + (1 - \\mu)^2 \\mu \\\\\n    & = \\mu (1 - \\mu)\n\\end{align}\n\\section{Exercise 2.2}\nTO DO \n\\end{document}", "meta": {"hexsha": "0c63bb6c26cb4e3a6c250efd50a87b08cfc5b612", "size": 1314, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Solution/Chapter2/PRMLChapter2.tex", "max_stars_repo_name": "anlijuncn/killPRML", "max_stars_repo_head_hexsha": "cf356bd47f2190991db51eb6516d4081c2a147d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Solution/Chapter2/PRMLChapter2.tex", "max_issues_repo_name": "anlijuncn/killPRML", "max_issues_repo_head_hexsha": "cf356bd47f2190991db51eb6516d4081c2a147d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Solution/Chapter2/PRMLChapter2.tex", "max_forks_repo_name": "anlijuncn/killPRML", "max_forks_repo_head_hexsha": "cf356bd47f2190991db51eb6516d4081c2a147d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2, "max_line_length": 70, "alphanum_fraction": 0.6438356164, "num_tokens": 483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.42888711053823914}}
{"text": "\\chapter{Conclusions and perspectives}\n\nIn this thesis, we studied the swimming of bacteria \\textit{Escherichia coli} (\\textit{E. coli}) near a sinusoidal boundary. We used low-density suspensions of bacteria to measure their accumulation near the curved surfaces. Through image analysis and bacterial tracking, we measured bacteria's density, speed, and residence times in the region close to the curved wall. We also developed a model of bacteria swimming, considering steric interactions with the surface.\n\nWe observed that bacteria movement in the curved surface depends on the parameters of the sinusoidal shape, namely the amplitude $A$ and the wavelength $\\lambda$. Their combined effect can be largely summarized in the wall maximum curvature $\\kappa=4\\pi^2 A /  \\lambda^2$. For lower curvatures, bacteria move along the surface quickly, and when bacteria reach a peak, they may leave the surface. As the curvature increases, bacteria become trapped in the valleys and eventually form clusters that last for several seconds. We called this transition the accumulation transition. To characterize this transition, we measured the mean density of bacteria in a period of the sinusoidal wall, through the intensity of the fluorescence of bacteria. We focused on the intensity in the curved wall, which we normalized by the mean intensity in the flat wall. This normalization ensures experiments are comparable. The accumulation transition was characterized via the Fourier coefficient $c_1$ associated with the shape of the intensity profile. We determined that the accumulation transition occurs near a critical curvature $\\kappa^* =$ \\SI{0.3}{\\per \\micro \\meter}. \n\nThe model considered interactions between bacteria and the wall through the steric alignment intensity $K$ and random reorientations induced by the liquid particles through the rotational diffusion coefficient $D_r$. $K$ and $D_r$ were the only non-fixed parameters of the model. We adjusted the model parameters to replicate the values of $c_1$ resulting in the optimal values $K^*=$ \\SI[per-mode = symbol]{3.0}{\\radian\\per\\second} and $D_r^*=$ \\SI[per-mode = symbol]{0.015}{\\square\\radian\\per\\second}. This values compare well to the reported measurements in the literature. In a flat surface $K=$ \\SI[per-mode = symbol]{4.9}{\\radian\\per\\second} was measured \\cite{Bianchi20193DInterface}, and a lower value of $K$ is to be expected as bacteria align less with the curved surface. Also $D_r=$ \\SI[per-mode = symbol]{0.057}{\\square\\radian\\per\\second} was reported for cells swimming far away from boundaries \\cite{Drescher2011FluidScattering}. In our experiments, bacteria in the focal swim in contact with a frontal surface, so it is reasonable to have a lower value of $D_r$ in our case due to the geometric restrictions that the surfaces imposes on the liquid and the rotation of the bacteria. \n\nThe optimal values of the model parameters were determined only with $c_1$. Nevertheless, the model replicates other quantities such as mean accumulation in the curved wall, speed profiles near the wall, and contact times with it. This is interesting because the model is very simple. The model does not consider the spherocylindrical shape of cells, the friction with the wall, the collision and alignment between cells, and the hydrodynamic effects caused by the flagella movement. There is plenty of physics involved in these experiments, but a model with minimal ingredients predicts the observed accumulation transition and makes reasonable predictions for all the measurements we made in the experiments. This can mean only one thing, the dynamics of cells near sinusoidal walls is dominated by the effects described in the model. We conclude that the steric alignment of cells with the wall and the rotational diffusion are the primary physical mechanisms that govern the dynamics of bacteria when swimming near a curved surface.\n\nRegarding the mean accumulation of bacteria, we discovered that near the critical curvature, a minimum of the average accumulation along the curved wall is found for the values $A=$ \\SI{5.6}{\\micro\\meter}, $\\lambda= $ \\SI{27}{\\micro\\meter}. Nevertheless, an experiment with almost equal curvature but lower amplitude showed a higher accumulation. This is because, for these curvatures, bacteria move around the valley easily, but for higher amplitude, the bacteria leave the wall with a higher inclination and therefore move away from the surface. This is interesting for designing surfaces that reduce biofilm formation because it reveals that curvature is not the only relevant parameter. We believe that semicircular patterns are the best option to reduce accumulation of bacteria, as they are expelled with the highest inclination possible. Nevertheless, our characterization as a function of the curvature is helpful because it is independent of the shape. If we extrapolate the results of this thesis for the semicircular geometery, we can predict an optimal radius $R^*$ around $R^*=(\\kappa^*)^{-1}\\approx$ \\SI{5}{\\micro\\meter} for semicircular patterns.\n\nThanks to the measurments of residence time of bacteria near the walls, we determined that the average contact time in the sinusoidal wall is an order of magnitude lower than in the flat surfaces. This decrease could mean that bacteria do not have time to adhere to the surface. In the future, we believe it is necessary to test this surface in more natural situations to measure its effectiveness in preventing biofilm formation. \n\nThe work done in this thesis still has plenty of room for improvement, as was discussed in the previous chapter. For example, we only have experiments with $A\\approx$ \\SI{9}{\\micro\\meter} in one day. Due to technical problems with the camera, it was impossible to generate more experimental data. We are also lacking resolution in the amplitudes, because for the wavelengths \\SIlist{21;24}{\\micro\\meter} we cannot observe the accumulation transition optimally. Increasing the number of experiments in this range of amplitudes is crucial to elucidate the differences observed in this range. Therefore an increase of the resolution in the  $(\\lambda, \\ A)$ space will better describe the accumulation transition. Moreover, the experiments will benefit from data from lower amplitudes as it is expected that for curvatures near zero the behavior in the curved wall will recover the behavior of the flat surface, implying that $c_1$ and $\\langle I(x) \\rangle$ have a non-monotonic behavior with respect to the curvature. We also believe that a tracking-based bacterial density measure will allow a more direct comparison between experiments and simulations. Finally, the model should consider cell alignment interactions to correctly reproduce the bacteria cluster dynamics in the curved wall. The last two aspects were not considered due to time restrictions, but will be implemented in a future publication.\n\nIn summary, this thesis contributes to understanding how shape alters the accumulation of bacteria near a surface. We observe a transition in the accumulation depending on the curvature in the wall. We explain this phenomenon by a simple model that considers an alignment with the wall and rotational diffusion. By adjusting the model parameters to replicate the transition, the dependence of bacterial speed and mean density with respect to the curvature is replicated, indicating that the system's dynamics are correctly represented. This implies that the steric alignment dominates other effects typically present in experiments but not included in the model. In addition, we have shown that these surfaces reduce the accumulation of bacteria on the wall considerably as the bacteria are in contact for times an order of magnitude shorter than near flat walls. This study promises that control of biofilm formation by optimization of surface curvature is possible.\n", "meta": {"hexsha": "f0909144efaf5f3154297c71d19ef810527b99e1", "size": 7882, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "conclu.tex", "max_stars_repo_name": "bendeta/Memoria-Tesis---FCFM---UChile", "max_stars_repo_head_hexsha": "73704a9d69eb24e198d5ba989924b548df0b2620", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "conclu.tex", "max_issues_repo_name": "bendeta/Memoria-Tesis---FCFM---UChile", "max_issues_repo_head_hexsha": "73704a9d69eb24e198d5ba989924b548df0b2620", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "conclu.tex", "max_forks_repo_name": "bendeta/Memoria-Tesis---FCFM---UChile", "max_forks_repo_head_hexsha": "73704a9d69eb24e198d5ba989924b548df0b2620", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 437.8888888889, "max_line_length": 1405, "alphanum_fraction": 0.8085511292, "num_tokens": 1593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.4288871105382391}}
{"text": "\n%%% Latex preamble\n\\documentclass[11pt]{article}\n\\oddsidemargin 0pt\n\\textwidth 6.5in\n\\topmargin -0.65in\n\\textheight 9.25in\n\n\\usepackage{epsfig}\n\\usepackage{natbib}\n\\usepackage{amssymb}\n%Get the citation punctuation correct\n\\bibpunct{(}{)}{;}{a}{}{,}\n\n%Set the space between paragraphs.\n%Uncomment this for single spacing, comment for double spacing\n\\setlength{\\parskip}{1.0ex plus0.5ex minus0.2ex}\n\n%Allow colour in your output (pdf only?)\n% \\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}\n% \\definecolor{darkgreen}{rgb}{0,.5,0}\t%For example\n%%%End of preamble\n\n\\newcommand{\\Plwr}{\\ensuremath{P_{\\mathrm{lwr}}}}\n\\newcommand{\\Pupr}{\\ensuremath{P_{\\mathrm{upr}}}}\n\n\n\\begin{document}\n\\begin{center}\n\\begin{Huge} Some notes on the Box Least Squared Algorithm \\end{Huge}\n\\end{center}\n\nThis document describes some notes on my implementation of the BLS.\n\n\\section{Choosing the optimal trial periods}\n\nConsider a transit with period $P$ and duration $\\tau$ observed continuously\nfor a timespan $T$. We would expect, on average, to observe $n = T/P$ transits.\nFold this lightcurve on a period $P'$. $P'$ is ``close enough\" to $P$ to find the transit if\nall points in transit are folded on top of each other (i.e have the same phase) in the folded lightcurve. For simplicity, we will assume that two points have the same phase if their phase differs by less than a transit duration.\n\nLet the phase of the 0th transit is $t0$. The worst error will be on the nth transit (assuming for simplicity that $P$ and $P'$ are close enough that no wrapping in phase occurs. The phase of the $n^{\\mathrm{th}}$ transit will be $t0 + n(P-P')$,  where  phase is defined to run from [0..$P$) not, say, [0, 2$\\pi$).\n\nIf we want all the transits to line up, we require\n$$\nn(P-P') < \\tau\n$$\n\nBut $n = T/P$, so our requirement that all transits overlap implies \n$$\n(P-P') < \\tau P/T\n$$\n%dP := (P-P') < tau \\times P/T\n\nFollowing Kovacs, we will call $\\tau/T$ the fractional transit duration, $q$.\nTo do a blind search where at least one trial period is close enough\nto any transit period present, we select periods\n\n\\noindent\n\\Plwr\\\\\n\\Plwr\\ + (P-P') $= \\Plwr + q \\Plwr = \\Plwr \\times (1+q)$\\\\\n\\Plwr\\ $\\times (1+q)^2$\\\\\n...\\\\\n\\Plwr\\ $\\times (1+q)^N$\\\\\n\n\\noindent\n(This is considerably fewer steps than \\Plwr + $Nq$ steps.)\n\nNow, this will ensure that all transit centres lie within one transit\nduration of each other in at least one folded lightcurve. However, this phase difference will still smear out the event quite a bit, making it harder to detect. So we pick an overresolution factor, $R$ to\nensure even better preformance.. Setting $R=2$ ensures\nall transit centres lie within half a transit duration of each other. We redefine $q$ such that\n$q = \\tau/(RT)$\n\nSo how many steps, $N$, do we need to get from some \\Plwr\\ to some other \\Pupr?\n\n\\begin{eqnarray*}\n\\Pupr = \\Plwr(1+q)^N\\\\\n\\Rightarrow \\Pupr/\\Plwr = (1+q)^N\\\\\n\\Rightarrow \\log_{(1+q)} (\\Pupr/\\Plwr) = N\\\\\n\\vspace{1ex}\\\\\n\\Rightarrow N = \\frac{\\ln(\\Pupr/\\Plwr)}{ \\ln(1+q)}\n\\end{eqnarray*}\n\n\n\\section{Computational Cost}\nThe computational cost is driven by the number of periods searched, $N$, and time taken to bin the data. The binning time is O(n), i.e it scales linearly with the number of input points. The number of periods searched depends on the ratio of the longest and shortest period, and the assumed fractional transit duration, $q$ (i.e transit duration divided by orbital period). $N$ doubles for each factor of $e$ the period span increases. It also scales as $10^{1/q}$. For example, if $q= 0.01$, $100 \\times \\ln(\\Pupr/\\Plwr)$ periods are searched. For coding simplicity, $q$ is computed once for the shortest duration and longest period and used for all other periods. This is computationally quite inefficient, but it makes the meaning of the output much simpler. If a faster algorithm is needed, $N$ can be recomputed for each transit duration.\n\n\n\\begin{figure}[bht]\n     \\begin{center}\n    \\includegraphics[angle=0, scale=.4]{qplot}\n    \\caption{Number density of periods searched as a function of assumed fractional transit duration. The actual number of periods searched depends on the ratio between the longest and shortest periods searched.}\n     \\end{center}\n \\end{figure}\n\n\n\\end{document}\n", "meta": {"hexsha": "198fbfc9ec5ab454a0d50ea6f46a80327e822678", "size": 4256, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "blsCode/bls.tex", "max_stars_repo_name": "exoplanetvetting/DAVE", "max_stars_repo_head_hexsha": "aea19a30d987b214fb4c0cf01aa733f127c411b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2019-05-07T02:01:51.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-16T08:09:39.000Z", "max_issues_repo_path": "blsCode/bls.tex", "max_issues_repo_name": "barentsen/dave", "max_issues_repo_head_hexsha": "45ba97b7b535ad26dd555c33c963c6224a9af23c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2015-12-09T22:18:59.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-26T13:11:44.000Z", "max_forks_repo_path": "blsCode/bls.tex", "max_forks_repo_name": "barentsen/dave", "max_forks_repo_head_hexsha": "45ba97b7b535ad26dd555c33c963c6224a9af23c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-03-08T11:42:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-07T00:10:37.000Z", "avg_line_length": 42.9898989899, "max_line_length": 843, "alphanum_fraction": 0.7253289474, "num_tokens": 1242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.42888710612716163}}
{"text": "{\\color{indiagreen}\\subsection{Predpone}}\n\\begin{center}\n\t\\begin{tabular}{|c c|} \n \t\\hline\n \tP(peta) & $10^15$ \\\\\n \tT(tera) & $10^12$ \\\\\n \tG(giga) & $10^9$ \\\\\n \tM & $10^6$ \\\\\n \tk & $10^3$ \\\\\n \th & $10^2$ \\\\\n \tda & $10$ \\\\\n \td & $10^{-1}$ \\\\\n \tc & $10^{-2}$ \\\\\n \tm & $10^{-3}$ \\\\\n \t$\\mu$& $10^{-6}$ \\\\\n \tn & $10^{-9}$ \\\\\n \tp(piko) & $10^{-12}$ \\\\\n \tf(fento) & $10^{-15}$ \\\\\n \t\\hline\n \t\\end{tabular}\n\\end{center}", "meta": {"hexsha": "c201f532dc82524329a6bc9f0eb0ec7a8f19f71d", "size": 410, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "1.Fizikalne_kolicine_in_enote/2.tex", "max_stars_repo_name": "RokKos/Fizika_Gim_Snov", "max_stars_repo_head_hexsha": "4ca16d8d861635ea9c83aa8a9747df18d7c1e3ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-09-13T16:59:14.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-16T14:17:11.000Z", "max_issues_repo_path": "1.Fizikalne_kolicine_in_enote/2.tex", "max_issues_repo_name": "RokKos/Fizika_Gim_Snov", "max_issues_repo_head_hexsha": "4ca16d8d861635ea9c83aa8a9747df18d7c1e3ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "1.Fizikalne_kolicine_in_enote/2.tex", "max_forks_repo_name": "RokKos/Fizika_Gim_Snov", "max_forks_repo_head_hexsha": "4ca16d8d861635ea9c83aa8a9747df18d7c1e3ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5238095238, "max_line_length": 41, "alphanum_fraction": 0.412195122, "num_tokens": 198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.4288870973050066}}
{"text": "\\section{Problem Definitions}\nIn this section, we provide the formal problem definitions on how to choose the \\emph{design parameters} of \nan LSM tree. Before proceeding, we give a brief introduction to our notation.\n\n\\subsection{Notation}\\label{sec:notation}\nAs we discussed above, LSM trees have two types of parameters: the \\emph{design parameters} and the \\emph{system parameters}.  One can think of the design parameters as those that someone who aims to optimize the performance of\nan LSM tree can tune, while the system parameters are given and therefore untunable.\n\n\\Paragraph{Design Parameters}\nThe design parameters we consider in this paper (in accordance with the related\n    work~\\cite{Dayan2017,Dayan2018a,Luo2020b}) are the  size-ratio ({\\sizeratio}),\n    the memory allocated to the Bloom filters ({\\mfilt}), the memory allocated to\n    the write buffer ({\\mbuf}) and the policy ({\\policy}) as shown in Table\n    \\ref{tab:model-design-params}.\nRecall that the policy refers to either leveling or tiering, as discussed in the previous section.\n\n\n\\begin{table}[h]\\centering%\\small\n    %\\vspace{-0.1in}\n\\renewcommand{\\arraystretch}{1.1}\n\\begin{tabular}{cl}\n    \\toprule\n    Term & Definition \\\\\n    \\midrule\n        $\\mfilt$ &  Memory allocated for Bloom filters  \\\\ \n        $\\mbuf$ &  Memory allocated for the write buffer \\\\ \n        $\\sizeratio$ &  Size ratio between consecutive levels   \\\\ \n        \\policy & Compaction policy (\\emph{tiering}/\\emph{leveling}) \\\\ \n    \\bottomrule\n\\end{tabular}\n\\caption{\\emph{Design} parameters of an LSM tree.}\n\t\\label{tab:model-design-params}\t\n\t%\\vspace{-0.35in}\n\\end{table}\n \n\\Paragraph{System Parameters} A complicated data structure like LSM trees also has other various \\emph{system parameters} and other non-tunable as shown in Table \\ref{tab:model-system-params} (e.g., total memory ({\\mtot}), size of data entries $E$, page size $B$, data size $N$). \n\n\\begin{table}[h]\\centering%\\small\n    %\\vspace{-0.1in}\n\\renewcommand{\\arraystretch}{1.1}\n\\resizebox{\\columnwidth}{!}{\n\\begin{tabular}{cl}\n    \\toprule\n    Term & Definition \\\\\n    \\midrule\n    $\\mtot$ & Total memory (Bloom filters+write buffer)    ($\\mtot=\\mbuf+\\mfilt$)\\\\\n        $E$ &  Size of a key-value entry  \\\\ \n        $B$ &  Number of entries that fit in a page   \\\\ \n        $N$ & Total number of entries    \\\\ \t\n    \\bottomrule\n\\end{tabular}\n}\n\\caption{\\emph{System} and untunable parameters of an LSM tree.}\n\t\\label{tab:model-system-params}\t\n%\t\\vspace{-0.05in}\n\\end{table}\n    \n\\Paragraph{LSM Tree Configuration} In terms of notation we use $\\configuration$ to denote the \nLSM tree tuning configuration which essentially describes the values of the\ntunable parameters together  $\\configuration := (\\sizeratio, \\mfilt, \\policy)$. Note that we only\nuse the memory for Bloom filters $\\mfilt$ and not \n$\\mbuf$, because the latter can be derived using the \nformer and the \ntotal available memory: $\\mbuf=\\mtot-\\mfilt$.\n\n\\Paragraph{Workload}  The choice of the parameters in $\\configuration$ \ndepends on the input (expected) workload, i.e., the fraction of\nempty lookups\n    ({\\emptylookup}), non-empty lookups ({\\nonemptylookup}), range lookups\n    ({\\range}), and write ({\\update}) queries, as shown in Table \\ref{tab:workload-params}.\nA workload can therefore be expressed as a vector \n    ${\\workload = (\\emptylookup, \\nonemptylookup, \\range, \\update)^\\intercal \\geq 0}$\n    describing the proportions of the different kinds of queries.\nClearly, $\\emptylookup+\\nonemptylookup+\\range+\\update = 1$ or alternatively:\n$\\workload^\\intercal \\columnvec = 1$ where {\\columnvec} denotes a column vector of\n    ones. %of the same dimension as {\\workload}.\n\n\\begin{table}[h]\\centering%\\small\n    %\\vspace{-0.1in}\n\\renewcommand{\\arraystretch}{1.1}\n\\begin{tabular}{cl}\n    \\toprule\n    Term & Definition \\\\\n    \\midrule\n        $z_0$ & Percentage of zero-result point lookups\\\\ %in the workload \\\\ \n        $z_1$ & Percentage of non-zero-result point lookups\\\\ %in the workload  \\\\ \n        $q$ & Percentage of range queries\\\\ %in the workload  \\\\ \n        $w$ & Percentage of updates\\\\ %in the workload  \\\\ \n    \\bottomrule\n\\end{tabular}\n\\caption{Parameters describing the \\emph{workload}.}\n    \\label{tab:workload-params}\t\n    %\\vspace{-0.35in}\n\\end{table}\n\n\\noindent Each type of query (non-empty lookups, empty lookups, range lookups and writes) has a different cost, denoted as\n$Z_0(\\configuration)$, $Z_1(\\configuration)$, $Q(\\configuration)$, $W(\\configuration)$, as there is a dependency between\nthe cost of each type of query and the design ${\\configuration}$.\nFor easiness of notation, we use \n    $\\costvec(\\configuration) = \\left(Z_0(\\configuration), Z_1(\\configuration), Q(\\configuration), W(\\configuration)\\right)^\\intercal$ \n    to denote the vector of the costs  of executing\n    different types of queries.\nThus, given a specific configuration ({\\configuration}) and a workload ({\\workload}),\n    the expected cost for the workload can be computed as:\n{%\n%\\small\n\\begin{equation}\n    \\label{eq:thecost}\n    \\cost(\\workload, \\configuration) = \\workload^\\intercal\n    \\costvec(\\configuration)=\\nonemptylookup \\cdot\n    Z_0(\\configuration)+\\emptylookup \\cdot Z_1(\\configuration) + \\range\\cdot Q(\\configuration) + \\update \\cdot W(\\configuration).\n\\end{equation}\n}%\n\n\\subsection{The Nominal Tuning Problem}\nTraditionally, the designers have focused on finding the \nconfiguration ${\\configuration}^\\ast$ that minimizes the total cost %$\\cost(\\workload, \\configuration^\\ast;\\varphi)$, \n$\\cost(\\workload, \\configuration^\\ast)$,\n for a given fixed workload $\\workload$.  We call this problem the\n {\\nominal} problem, defined as follows:\n \n \\begin{problem}[{\\nominal}]\\label{problem:nominal}\n Given fixed $\\workload$  find the tuning configuration of the LSM tree $\\configuration_N$ such that\n\\begin{equation}\n\\label{eq:nominal_problem}\n    \\configuration_N = \\argmin_{\\configuration} \\cost(\\workload, \\configuration).\n\\end{equation}\n\\end{problem}\n\n\\noindent The nominal tuning problem described above \ncaptures the classical tuning paradigm. It uses a\ncost-model to find a system configuration that \nminimizes the cost given a specific workload and \nsystem environment. Specifically, prior tuning\napproaches for LSM trees solve the nominal tuning\nproblem when proposing optimal memory allocation,\nand merging policies \\cite{Dayan2017,Dayan2018a,Luo2020a}.\n\n\n\n\\subsection{The Robust Tuning Problem}\n\\label{subsec:robust-tuning}\n\nIn this work, we attempt to compute high-performance configurations that minimize\n    expected cost of operation, as expressed in Equation~\\eqref{eq:thecost}, \n    in the presence of uncertainty with respect to the expected workload.\n\n%\\Paragraph{Uncertain Workload:}\nIn the {\\nominal} problem, the designers assume perfect information about the \n    workload for which to tune the system. For example, they may assume that the\n    input vector $\\workload$ represents the workload for which they have to\n    optimize. While in practice, $\\workload$ is simply an estimate of what the\n    workload will look like.\nHence, the configuration obtained by solving Problem~\\ref{problem:nominal} may\n    result in high variability in the system performance; which will inevitably\n    depend on the actual observed workload upon the deployment of the system. \n    \nWe capture this uncertainty by reformulating Problem~\\ref{problem:nominal} to\n    take into account the variability that can be observed in the input workload. \nGiven expected workload $\\workload$, we introduce the notion of the\n    \\emph{uncertainty region} of $\\workload$, which we denote by\n    $\\mathcal{U}_\\workload$.\n\nWe can define the robust version of Problem~\\ref{problem:nominal}, under the \nassumption that there is uncertainty in the input workload as follows:\n\n\\begin{problem}[{\\robustw}]\\label{problem:robustw} \nGiven $\\workload$ and uncertainty region $\\mathcal{U}_\\workload$ \nfind the tuning configuration of the LSM tree $\\configuration_R$ such that\n\\begin{eqnarray}\n\\label{eq:robust_workload_problem}\n\\configuration_R &=& \\argmin_{\\configuration} \\cost(\\obsworkload,\n    \\configuration) \\nonumber\\\\\n    \\textrm{s.t.,}&& \\obsworkload \\in \\mathcal{U}_{\\workload}.\n\\end{eqnarray}\n\\end{problem}\n\nNote that the above problem definition intuitively states the following: it recognizes that the input workload $\\workload$ won't\nbe observed exactly, and it assumes that any workload in $\\mathcal{U}_\\workload$ is possible.  Then, it searches for the\nconfiguration $\\configuration_\\workload$ that is best for the \\emph{worst-case} scenario among all those in $\\mathcal{U}_\\workload$. \n\nThe challenge in solving {\\robustw}  is that one needs to explore all the workloads in the uncertainty region\nin order to solve the problem.  In the next section, we show that this is not necessary.  In fact, by appropriately rewriting \nthe problem definition we show that we can solve Problem~\\ref{problem:robustw} in polynomial time.\n\n\n%\n%$\\mathcal{U}_{\\workload}$ represents the \\emph{uncertainty region} around\n%    the expected workload {\\workload}; a set of  workloads similar to but\n%    not exactly the same as {\\workload}. \n%In Section~\\ref{sec:robust_lsm_tuning}, we explain in detail the\n%    parameterization of the uncertainty region \n%    based on the number of sample workloads used during the computation of the \n%    expected workload and the confidence of the designer on how relevant the \n%    observed samples are to the future workloads.\n", "meta": {"hexsha": "014ce82f3edc3e0ef362b44adaf77839fac43591", "size": 9455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problem-definition.tex", "max_stars_repo_name": "chdhr-harshal/endure-robust-lsm", "max_stars_repo_head_hexsha": "900dd51e90fcb4507b450a92c39f60eacbe5e1a0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "problem-definition.tex", "max_issues_repo_name": "chdhr-harshal/endure-robust-lsm", "max_issues_repo_head_hexsha": "900dd51e90fcb4507b450a92c39f60eacbe5e1a0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problem-definition.tex", "max_forks_repo_name": "chdhr-harshal/endure-robust-lsm", "max_forks_repo_head_hexsha": "900dd51e90fcb4507b450a92c39f60eacbe5e1a0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.2397959184, "max_line_length": 280, "alphanum_fraction": 0.7353781068, "num_tokens": 2479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.4288795647277235}}
{"text": "\\section{Applications: Judging Wine Quality}\n\nAs a sort of fun application, I found a dataset on UCI's archive from a paper by\nCortez et al. \\cite{2009CCAMR} which charted various physicochemical properties\nof a set of white wine, and had corresponding 'quality' (judged by a committee,\nthe CVRVV) levels for each data point. The reason why I decided to try this\ndataset, is not only because knowing what makes alcohol quality clearly\na very important task, but also because in the original paper, their uncertainty\nregarding the relevancy of all input variables was noted. That is, this is an\ninteresting opportunity to try a feature selection method: my method of choice\nthis time was ridge-regression, the $\\ell^2$ variant of LASSO. See Figures\n\\ref{fig:linearwine} and \\ref{fig:ridgewine} for the linear and ridge regression\nvariants, respectively.\n\\begin{figure}[!htb]\n  \\centering\n  \\begin{subfigure}{.5\\textwidth}\n    \\centering\n    \\includegraphics[width=\\linewidth]{./resources/linear_wine}\n    \\caption{}\\label{fig:linearwine}\n  \\end{subfigure}%\n  \\begin{subfigure}{.5\\textwidth}\n    \\centering\n    \\includegraphics[width=\\linewidth]{./resources/ridge_wine}\n    \\caption{}\\label{fig:ridgewine}\n  \\end{subfigure}\n  \\caption{\n    Both converge in rougly four to eight epochs, but it should be noted\n    that neither converges to the true solution. Regardless of how I chose the\n    learning rate, it appeared that both runs of \\hogwild\\ would get stuck in\n    a noise ball somewhere close to the true solution. This is an important\n    failing of stochastic gradient methods in general, sometimes the noise\n    generated will prevent us from seeing a 'true' solution, and indeed the\n    ridge-regressed version didn't properly feature select, whereas the solution\n    computed via CVX saw the 11th feature to be most weighted (The 11th feature,\n    to my amusement, is alcohol content. Certainly an important part of what\n    makes a good wine...).\n  }\n\\end{figure}\n", "meta": {"hexsha": "e408cb18055defb806cd95dcdced8e4e1324c5b9", "size": 1974, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/TeXsrc/src/winequality.tex", "max_stars_repo_name": "abhijit-c/HOGWILD", "max_stars_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/TeXsrc/src/winequality.tex", "max_issues_repo_name": "abhijit-c/HOGWILD", "max_issues_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/TeXsrc/src/winequality.tex", "max_forks_repo_name": "abhijit-c/HOGWILD", "max_forks_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6153846154, "max_line_length": 80, "alphanum_fraction": 0.7619047619, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.42887956347549366}}
{"text": "\\section{Dynamic Model}\n\nThe Dynamic Model excel file is provided \n\\href{http://ucanr.edu/sites/fruittree/How-to_Guides/Dynamic_Model_-_Chill_Accumulation/}{here} and its use is explained \n\\href{http://ucanr.edu/sites/fruittree/files/49320.pdf}{here}.\n\n\n\\begin{enumerate}\n\\item \\func{Fahrenheit\\_to\\_Celsius(temp\\_cel)} converts Fahrenheit temp. to Celsius. Celsius is the proper form of temp. used in the model. \n\n\\code{Input}:\n\\begin{itemize}\n\\item \\vari{temp\\_cel}  A real valued temp. or a column of a \ndata frame containing the temp in the Celsius format.\n\\end{itemize}\n\n\n\\code{output}\n\\begin{itemize}\n\\item A real valued temp. in Fahrenheit or a column of\ndata frame.\n\\end{itemize}\n\n%%%%%%%%%%%%%%%\n\n\\item \\func{initiate\\_data\\_frame(col\\_names, init\\_temp\\_c, const)} Creates a new data frame \nof size $2 \\times 13$ and fills in the cells which are to be used\nby dynamic model. It corresponds to rows 11 and 12 of the \nmodel given in the excel file.\n\n\\code{Input}:\n\n\\begin{itemize}\n\\item \\vari{col\\_names}  The names of columns of the data frame to be used in the model.\n\n{\\footnotesize {$ \\vari{col\\_names} = [ \\text{date}, \\:\n                                    \\text{ time}, \n                                     \\text{temp\\_c}, \n                                     \\text{temp\\_k}, \n                                     \\text{ftmprt}, \n                                     \\text{sr}, \n                                     \\text{xi}, \n                                     \\text{xs}, \n                                     \\text{ak1}, \n                                     \\text{Inter-S}, \n                                     \\text{Inter-E},\n                                     \\text{delt}, \n                                     \\text{Portions}] $}}\n\n\\item \\vari{init\\_temp\\_c}. Initial temps. corresponding to cells C11 and C12 \nof the excel file. $\\vari{init\\_{temp\\_c}} = (15, 12)$.\n\n\\item \\vari{const} An object of the class \\vari{constants} containing \nconstants of the model. They are given below and in \nthe D1 through D8 cells of the excel\nfile.\n%%%%%%%%%\n\\iffalse\n\\begin{align*}\n\\vari{const} \n&=  \\begin{bmatrix}\n           \\vari{e0} \\\\\n           \\vari{e1} \\\\\n           \\vari{a0}\\\\\n           \\vari{a1}\\\\\n           \\vari{slp}\\\\\n           \\vari{tetmlt}\\\\\n           \\vari{aa}\\\\\n           \\vari{ee}\n         \\end{bmatrix}  =\n      \\begin{bmatrix}\n           4.15E+03 \\\\\n           1.29E+04\\\\\n           1.40E+05 \\\\\n           2.57E+18\\\\\n           1.6\\\\\n           277\\\\\n           \\vari{a0} / \\vari{a1}\\\\\n           \\vari{e1} - \\vari{e0}\n         \\end{bmatrix}\n\\end{align*}\n\\fi\n%%%%%%%%%\n\n\\begin{table}[!htb]\n\\caption{\\vari{const} object}\n\\begin{center}\n    \\begin{tabular}{| l | l | l | l | l | l| l| l| l | l | l | p{1cm} |}\n     \\hline\n    \\scriptsize{\\texttt{e0}} & \\scriptsize{\\texttt{e1}} & \\scriptsize{\\texttt{a0}} & \\scriptsize{\\texttt{a1}} & \\scriptsize{\\texttt{slp}} & \\scriptsize{\\texttt{tetmlt}} & \\scriptsize{\\texttt{aa}} & \\scriptsize{\\texttt{ee}} \\\\ \\hline\n             \\scriptsize{\\texttt{4.15E+03}} & \\scriptsize{\\texttt{1.29E+04}} & \\scriptsize{\\texttt{1.40E+05}} & \\scriptsize{2.57E+18} & \\scriptsize{\\texttt{1.6}} & \\scriptsize{\\texttt{277}} & \\scriptsize{\\texttt{a0 / a1}} & \\scriptsize{\\texttt{e1 - e0}}  \\\\ \\hline\n    \\end{tabular}\n\\end{center}\n \\label{table:None}\n\\end{table}\n\n\\end{itemize}\n\n\\code{output:} A data frame of the following form.\n\n\\begin{table}[!htb]\n\\caption{initial data frame to construct the model with.}\n\\vspace{-.1in}\n\\begin{center}\n    \\begin{tabular}{| l | l | l| l | l | l | l | l | l| l| l| l | p{1cm} |}\n    \\hline\n    \\scriptsize{date}  & \\scriptsize{time} & \\scriptsize{temp\\_c} & \\scriptsize{temp\\_k}  &  \\scriptsize{ftmprt} & \\scriptsize{sr} & \\scriptsize{xi} & \\scriptsize{xs} & \\scriptsize{ak1} & \\scriptsize{Inter-S} & \\scriptsize{Inter-E} & \\scriptsize{delt} & \\scriptsize{Portions} \\\\ \\hline\n     \\scriptsize{\\texttt{None}} & \\scriptsize{\\texttt{None}} & \\scriptsize{\\texttt{15} }& \\scriptsize{\\texttt{288}} & \\scriptsize{\\texttt{16.93}} & \\scriptsize{\\texttt{22471935.51}} & \\scriptsize{\\texttt{1}} & \\scriptsize{v{.81}} & \\scriptsize{\\texttt{.09}} & \\scriptsize{\\texttt{0.00}} & \\scriptsize{\\texttt{.07}} & \\scriptsize{\\texttt{0.00}} & \\scriptsize{0}\\\\ \\hline\n     \\scriptsize{\\texttt{None}}  & \\scriptsize{\\texttt{None}} & \\scriptsize{\\texttt{12}} & \\scriptsize{\\texttt{285}} & \\scriptsize{\\texttt{12.44}} & \\scriptsize{\\texttt{252887.94}} & \\scriptsize{\\texttt{1}} & \\scriptsize{\\texttt{1.11}} & \\scriptsize{\\texttt{.06}} & \\scriptsize{\\texttt{.07}} & \\scriptsize{\\texttt{.13}} & \\scriptsize{\\texttt{0.00}} & \\scriptsize{{0}}  \\\\ \\hline\n    \\end{tabular}\n\\end{center}\n \\label{table:None1}\n\\end{table}\n\n\n\\item \\func{fill\\_in\\_the\\_table(given\\_table, const)}\n This function takes the \\vari{const} object and \\vari{given\\_table} \n as input and runs the model to fill in the \n proper information that we need to compute the Chill Portions \n which is the ultimate goal of the model. \n \n \\code{input:}\n \\begin{itemize}\n \\item \\vari{given\\_table} Is the data frame that contains \n the first two rows, like the one given by \nTable \\ref{table:None1} and the first three \n columns, from row 3 to the end, are provided by \n datalogger and are read off the disk. Anything from the column\n \\code{temp\\_k}  onward is computed and filled by this function.\n\n\\item \\vari{const}: The object containing constants of the model\nmentioned before.\n \\end{itemize}\n \n\\code{output:} A complete table that has the Chill Portions for the \ndata of out orchard.\n\n\\item \\func{dynamic\\_model(path\\_to\\_data, col\\_names, init\\_temp\\_c, const)}\n\nThis function takes the path of the file we wish \nto compute the Chilling portions for, along with \nother inputs that we have already mentioned \nbefore, and produces the Chilling Portions.\n\n\\code{input:}\n\\begin{itemize}\n\\item \\vari{path\\_to\\_data}: the path to the data location on the disk.\n\\item \\vari{col\\_names}: Name of the columns \nof the data frame, like mentioned before. These \nnames has to be exact, because they are used for\ncomputations in the model.\\\\\n\n{\\color{red}{\\textsc{NOTE}}}: These data should have temp. in \nCelsius. And it is assumed the first three columns \nare \\code{date}, \\code{time} and \\code{temp} respectively.\\\\\n\n\\item \\vari{init\\_temp\\_c} Initial temp. as mentioned before.\n\n\\item \\vari{const}: An object containing the constants of the model.\n\\end{itemize}\n\n\\code{output:} A data frame containing all information we need. \n(Shall I change this so that it just gives the \\vari{Portions}?)\n\n\\end{enumerate}\n\n", "meta": {"hexsha": "90cbf3bd4eaf704fd5f9564423edd060e677d65d", "size": 6535, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "codling_moth/code/documentations/dynamic_model.tex", "max_stars_repo_name": "HNoorazar/Kirti", "max_stars_repo_head_hexsha": "fb7108dac1190774bd90a527aaa8a3cb405f127d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "codling_moth/code/documentations/dynamic_model.tex", "max_issues_repo_name": "HNoorazar/Kirti", "max_issues_repo_head_hexsha": "fb7108dac1190774bd90a527aaa8a3cb405f127d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "codling_moth/code/documentations/dynamic_model.tex", "max_forks_repo_name": "HNoorazar/Kirti", "max_forks_repo_head_hexsha": "fb7108dac1190774bd90a527aaa8a3cb405f127d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1317365269, "max_line_length": 378, "alphanum_fraction": 0.6197398623, "num_tokens": 2033, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.42887955971495345}}
{"text": "\n\\section{Dam break involving a dry area}\n\nThe dam break problem involving a dry area was solved analytically by Ritter~\\cite{Ritter1892} as well as Stoker~\\cite{Stoker1948, Stoker1957}. The analytical solution exhibits a rarefaction fan as a parabolic curve. As water moves, it involves wetting process over the dry area.\n\nThe initial condition is\n\\begin{equation} \\label{eq:db_dry_init}\nu(x,0)=0, ~~v(x,y)=0, ~~\\textrm{and}~~\nh(x,0) = \\left\\{ \\begin{array}{ll}\nh_1 & \\textrm{if $x < 0$}\\\\\n0 & \\textrm{if $x > 0$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhere $h_1>0$. The topography is a horizontal flat bed.\n\n\nThe analytical solution~\\cite{Ritter1892, Stoker1948, Stoker1957} at time $t>0$ is\n\\begin{equation}\nh(x) = \\left\\{ \\begin{array}{ll}\nh_1 & \\textrm{if $x \\leq -t \\sqrt{gh_1}$}\\\\\nh_R=\\frac{4}{9g}(\\sqrt{gh_1}-\\frac{x}{2t})^2 & \\textrm{if $-t \\sqrt{gh_1} <x \\leq 2t\\sqrt{gh_1}$}\\\\\n0 & \\textrm{if $x \\geq 2t\\sqrt{gh_1}$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhich is the free surface and\n\\begin{equation}\nu(x) = \\left\\{ \\begin{array}{ll}\n0 & \\textrm{if $x \\leq -t \\sqrt{gh_1}$}\\\\\nu_R=\\frac{2}{3}(\\sqrt{gh_1}+\\frac{x}{t}) & \\textrm{if $-t \\sqrt{gh_1} <x \\leq 2t\\sqrt{gh_1}$}\\\\\n0 & \\textrm{if $x \\geq 2t\\sqrt{gh_1}$}\\\\\n\\end{array} \\right.\n\\end{equation}\nwhich is the velocity.\n\n\n\n\\subsection{Results}\nFor our test, we consider $h_1=10$ in (\\ref{eq:db_dry_init}).\nThe following figures show the stage, $x$-momentum, and $x$-velocity at several instants of time. We should see excellent agreement between the analytical and numerical solutions. The wet/dry interface is difficult to resolve and it usually produces large errors.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{stage_plot.png}\n%\\label{fig:db_dry_stage}\n\\end{center}\n\\caption{Stage results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{xmom_plot.png}\n%\\label{fig:db_dry_xmom}\n\\end{center}\n\\caption{Xmomentum results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{xvel_plot.png}\n%\\label{fig:db_dry_xvel}\n\\end{center}\n\\caption{Xvelocity results}\n\\end{figure}\n\n\n\\endinput\n", "meta": {"hexsha": "a5c0327f9a8fb951a544ea25c721291b3ea3d2c5", "size": 2131, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "validation_tests/analytical_exact/dam_break_dry/results.tex", "max_stars_repo_name": "samcom12/anuga_core", "max_stars_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_stars_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_stars_count": 136, "max_stars_repo_stars_event_min_datetime": "2015-05-07T05:47:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T03:07:40.000Z", "max_issues_repo_path": "validation_tests/analytical_exact/dam_break_dry/results.tex", "max_issues_repo_name": "samcom12/anuga_core", "max_issues_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_issues_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_issues_count": 184, "max_issues_repo_issues_event_min_datetime": "2015-05-03T09:27:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T04:22:48.000Z", "max_forks_repo_path": "validation_tests/analytical_exact/dam_break_dry/results.tex", "max_forks_repo_name": "samcom12/anuga_core", "max_forks_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_forks_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-03-18T07:35:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-01T07:07:29.000Z", "avg_line_length": 30.884057971, "max_line_length": 279, "alphanum_fraction": 0.7095260441, "num_tokens": 794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4288634419721168}}
{"text": "\n%----------------------------------------------------------------------------\n\\chapter{Radio Propagation Models}\n\\label{chap:propagation}\n\nThis chapter describes the radio propagation models implemented in \\ns.\nThese models are used to predict the received signal power of\neach packet. At the physical layer of each wireless node, there is a receiving\nthreshold. When a packet is received, if its signal power is below the receiving\nthreshold, it is marked as error and dropped by the MAC layer.\n\nUp to now there are three propagation models in \\ns, which are the free\nspace model\\footnote{Based on the code contributed to \\ns~from the CMU Monarch\nproject.}, two-ray ground reflection model\\footnote{Contributed to \\ns~from the\nCMU Monarch project.} and the shadowing model\\footnote{Implemented in \\ns~by\nWei Ye at USC/ISI}. Their implementation can be found in \\nsf{propagation.\\{cc,h\\}},\n\\nsf{tworayground.\\{cc,h\\}} and \\nsf{shadowing.\\{cc,h\\}}. This documentation\nreflects the APIs in ns-2.1b7.\n\n%----------------------------------------------------------------------------\n\\section{Free space model}\n\\label{sec:freespace}\n\nThe free space propagation model assumes the ideal propagation condition\nthat there is only one clear line-of-sight path between the transmitter and\nreceiver. H. T. Friis presented the following equation to\ncalculate the received signal power in free space at distance $d$ from the\ntransmitter \\cite{Friis46}.\n\n\\begin{equation}\n  P_r (d) = \\frac{P_t G_t G_r \\lambda^2}{(4\\pi)^2 d^2 L}\n  \\label{eqn:freespace}\n\\end{equation}\n\nwhere $P_t$ is the transmitted signal power. $G_t$ and $G_r$ are the antenna\ngains of the transmitter and the receiver respectively. $L (L\\ge1)$ is the\nsystem loss, and $\\lambda$ is the wavelength. It is common to select\n$G_t = G_r = 1$ and $L = 1$ in \\ns~ simulations.\n\nThe free space model basically represents the communication range as a circle\naround the transmitter. If a receiver is within the circle, it receives all\npackets. Otherwise, it loses all packets\n\nThe OTcl interface for utilizing a propagation model is the \\code{node-config}\ncommand. One way to use it here is\n\n\\begin{program}\n$ns_ node-config -propType Propagation/FreeSpace\n\\end{program}\n\nAnother way is\n\n\\begin{program}\nset prop [new Propagation/FreeSpace]\n$ns_ node-config -propInstance $prop\n\\end{program}\n\n%----------------------------------------------------------------------------\n\\section{Two-ray ground reflection model}\n\\label{sec:tworay}\n\nA single line-of-sight path between two mobile nodes is seldom the only means\nof propation. The two-ray ground reflection model considers both the direct\npath and a ground reflection path. It is shown \\cite{Rappaport96} that this\nmodel gives more accurate prediction at a long distance than the free space\nmodel. The received power at distance $d$ is predicted by\n\n\\begin{equation}\n  P_r (d) = \\frac{P_t G_t G_r {h_t}^2 {h_r}^2}{d^4 L}\n  \\label{eqn:tworay}\n\\end{equation}\n\nwhere $h_t$ and $h_r$ are the heights of the transmit and receive antennas\nrespectively. Note that the original equation in \\cite{Rappaport96} assumes\n$L = 1$. To be consistent with the free space model, $L$ is added here.\n\nThe above equation shows a faster power loss than Eqn. (\\ref{eqn:freespace})\nas distance increases. However, The two-ray model does not give a good result\nfor a short distance due to the oscillation caused by the constructive and\ndestructive combination of the two rays. Instead, the free space model is\nstill used when $d$ is small.\n\nTherefore, a cross-over distance $d_c$ is calculated in this model. When\n$d < d_c$, Eqn. (\\ref{eqn:freespace}) is used. When $d > d_c$, Eqn.\n(\\ref{eqn:tworay}) is used. At the cross-over distance, Eqns. (\\ref{eqn:freespace})\nand (\\ref{eqn:tworay}) give the same result. So $d_c$ can be calculated as\n\n\\begin{equation}\n%  d_c = \\frac{4\\pi h_t h_r}{\\lambda}\n  d_c = \\left( 4\\pi h_t h_r \\right) / \\lambda\n  \\label{eqn:crossover}\n\\end{equation}\n\nSimilarly, the OTcl interface for utilizing the two-ray ground reflection model\nis as follows.\n\n\\begin{program}\n$ns_ node-config -propType Propagation/TwoRayGround\n\\end{program}\n\nAlternatively, the user can use\n\n\\begin{program}\nset prop [new Propagation/TwoRayGround]\n$ns_ node-config -propInstance $prop\n\\end{program}\n\n\n%----------------------------------------------------------------------------\n\\section{Shadowing model}\n\\label{sec:shadowing}\n\n\\subsection{Backgroud}\n\nThe free space model and the two-ray model predict the received power\nas a deterministic function of distance. They both represent the communication\nrange as an ideal circle. In reality, the received power at certain distance\nis a random variable due to multipath propagation effects, which is also\nknown as fading effects. In fact, the above two models predicts the mean\nreceived power at distance $d$. A more general and widely-used model is\ncalled the shadowing model~\\cite{Rappaport96}.\n\nThe shadowing model consists of two parts. The first one is known as path\nloss model, which also predicts the mean received power at distance $d$,\ndenoted by $\\overline{P_r(d)}$. It uses a close-in distance $d_0$ as\na reference. $\\overline{P_r(d)}$ is computed relative to $P_r(d_0)$\nas follows.\n\n\\begin{equation}\n  \\frac{P_r(d_0)}{\\overline{P_r(d)}} = {\\left( \\frac{d}{d_0} \\right)}^\\beta\n  \\label{eqn:pathloss}\n\\end{equation}\n\n$\\beta$ is called the path loss exponent, and is usually empirically\ndetermined by field measurement. From Eqn. (\\ref{eqn:freespace}) we\nknow that $\\beta = 2$ for free space propagation. Table~\\ref{tab:pathlossexp}\ngives some typical values of $\\beta$.\nLarger values correspond to more obstructions and hence faster\ndecrease in average received power as distance becomes larger. $P_r(d_0)$\ncan be computed from Eqn. (\\ref{eqn:freespace}).\n\n\\begin{table}\n\\begin{center}\n  \\centering \\small\n  \\begin{tabular}{|l|l|c|}\n  \\hline \\multicolumn{2}{|c|}{\\bf{Environment}} & $\\beta$ \\\\\n  \\hline Outdoor & Free space & 2 \\\\\n  \\cline{2 - 3}  & Shadowed urban area & 2.7 to 5 \\\\\n  \\hline In building & Line-of-sight & 1.6 to 1.8 \\\\\n  \\cline{2 - 3}  & Obstructed & 4 to 6 \\\\ \\hline\n  \\end{tabular}\n  \\caption{Some typical values of path loss exponent $\\beta$}\n  \\label{tab:pathlossexp}\n\\end{center}\n\\end{table}\n\\begin{table}\n\\begin{center}\n  \\centering \\small\n  \\begin{tabular}{|l|c|}\n  \\hline \\bf{Environment} & $\\sigma_{dB}$ (dB) \\\\\n  \\hline Outdoor & 4 to 12 \\\\\n  \\hline Office, hard partition & 7 \\\\\n  \\hline Office, soft partition & 9.6 \\\\\n  \\hline Factory, line-of-sight & 3 to 6 \\\\\n  \\hline Factory, obstructed & 6.8 \\\\ \\hline\n  \\end{tabular}\n  \\caption{Some typical values of shadowing deviation $\\sigma_{dB}$}\n  \\label{tab:stddb}\n\\end{center}\n\\end{table}\n\nThe path loss is usually measured in dB. So from Eqn. (\\ref{eqn:pathloss})\nwe have\n\n\\begin{equation}\n  {\\left[ \\frac{\\overline{P_r(d)}}{P_r(d_0)} \\right]}_{dB} =\n    -10 \\beta \\log \\left( \\frac{d}{d_0} \\right)\n  \\label{eqn:pathlossdb}\n\\end{equation}\n\nThe second part of the shadowing model reflects the variation of the\nreceived power at certain distance. It is a log-normal random variable,\nthat is, it is of Gaussian distribution if measured in dB. The overall\nshadowing model is represented by\n\n\\begin{equation}\n{\\left[ \\frac{P_r(d)}{P_r(d_0)} \\right]}_{dB} =\n    -10 \\beta \\log \\left( \\frac{d}{d_0} \\right) + X_{dB}\n  \\label{eqn:shadowing}\n\\end{equation}\n\nwhere $X_{dB}$ is a Gaussian random variable with zero mean and\nstandard deviation $\\sigma_{dB}$. $\\sigma_{dB}$ is called the\nshadowing deviation, and is also obtained by measurement. Table\n~\\ref{tab:stddb} shows some typical values of $\\sigma_{dB}$. Eqn.\n(\\ref{eqn:shadowing}) is also known as a log-normal shadowing model.\n\nThe shadowing model extends the ideal circle model to a richer\nstatistic model: nodes can only probabilistically communicate when\nnear the edge of the communication range.\n\n\n\\subsection{Using shadowing model}\n\nBefore using the model, the user should select the values of the path\nloss exponent $\\beta$ and the shadowing deviation $\\sigma_{dB}$\naccording to the simulated environment.\n\nThe OTcl interface is still the \\code{node-config} command. One way to\nuse it is as follows, and the values for these parameters are just examples.\n\n\\begin{program}\n# first set values of shadowing model\nPropagation/Shadowing set pathlossExp_ 2.0  ;# path loss exponent\nPropagation/Shadowing set std_db_ 4.0       ;# shadowing deviation (dB)\nPropagation/Shadowing set dist0_ 1.0        ;# reference distance (m)\nPropagation/Shadowing set seed_ 0           ;# seed for RNG\n\n$ns_ node-config -propType Propagation/Shadowing\n\\end{program}\n\nThe shadowing model creates a random number generator (RNG) object. The RNG has\nthree types of seeds: raw seed, pre-defined seed (a set of known good seeds)\nand the huristic seed (details in Section~\\ref{sec:random}). The\nabove API only uses the pre-defined seed. If a user want different seeding\nmethod, the following API can be used.\n\n\\begin{program}\nset prop [new Propagation/Shadowing]\n$prop set pathlossExp_ 2.0\n$prop set std_db_ 4.0\n$prop set dist0_ 1.0\n$prop seed <seed-type> 0              ;# user can specify seeding method\n\n$ns_ node-config -propInstance $prop\n\\end{program}\n\nThe \\code{<seed-type>} above can be \\code{raw}, \\code{predef} or \\code{heuristic}.\n\n%--------------------------------------------------------------------------------\n\n\\section{Communication range}\n\\label{sec:commrange}\n\nIn some applications, a user may want to specify the communication range of\nwireless nodes. This can be done by set an appropriate value of the receiving\nthreshold in the network interface, \\ie,\n\n\\begin{program}\nPhy/WirelessPhy set RXThresh_ <value>\n\\end{program}\n\nA separate C program is provided at \\nsf{indep-utils/propagation/threshold.cc}\nto compute the receiving threshold. It can be used for all the\npropagation models discussed in this chapter. Assume you have compiled it and get\nthe excutable named as \\code{threshold}. You can use it to compute the threshold\nas follows\n\n\\begin{program}\nthreshold -m <propagation-model> [other-options] distance\n\\end{program}\n\nwhere \\code{<propagation-model>} is either \\code{FreeSpace}, \\code{TwoRayGround}\nor \\code{Shadowing}, and the \\code{distance} is the communication range in meter.\n\n\\code{[other-options]} are used to specify parameters other than their\ndefault values. For the shadowing model there is a necessary parameter,\n\\code{-r <receive-rate>}, which specifies the rate of correct reception at the\n\\code{distance}. Because the communication range in the shadowing model is not\nan ideal circle, an inverse Q-function \\cite{Rappaport96} is used to calculate the\nreceiving threshold. For example, if you want 95\\% of packets can be correctly\nreceived at the distance of 50m, you can compute the threshold by\n\n\\begin{program}\nthreshold -m Shadowing -r 0.95 50\n\\end{program}\n\nOther available values of \\code{[other-options]} are shown below\n\n\\begin{program}\n-pl <path-loss-exponent> -std <shadowing-deviation> -Pt <transmit-power>\n-fr <frequency> -Gt <transmit-antenna-gain> -Gr <receive-antenna-gain>\n-L <system-loss> -ht <transmit-antenna-height> -hr <receive-antenna-height>\n-d0 <reference-distance>\n\\end{program}\n\n%-------------------------------------------------------------------------------\n\n\\section{Commands at a glance}\n\\label{sec:propcommand}\n\nFollowing is a list of commands for propagation models.\n\n\\begin{flushleft}\n\\code{$ns_ node-config -propType <propagation-model>}\\\\\nThis command selects \\code{<propagation-model>} in the simulation. the\n\\code{<propagation model>} can be \\code{Propagation/FreeSpace},\n\\code{Propagation/TwoRayGround} or \\code{Propagation/Shadowing}\n\n\\code{$ns_ node-config -propInstance $prop}\\\\\nThis command is another way to utilize a propagation model. \\code{$prop} is\nan instance of the \\code{<propagation-model>}.\n\n\\code{$sprop_ seed <seed-type> <value>}\\\\\nThis command seeds the RNG. \\code{$sprop_} is an instance of the shadowing model.\n\n\\code{threshold -m <propagation-model> [other-options] distance}\\\\\nThis is a separate program at \\nsf{indep-utils/propagation/threshold.cc}, which\nis used to compute the receiving threshold for a specified communication range.\n\n\\end{flushleft}\n\n\\endinput\n%------------------------------------------------------------------------------\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "3749a233f39fc3afb3a588f1f31f7fde7ee32c81", "size": 12296, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ns-allinone-2.35/ns-2.35/doc/propagation.tex", "max_stars_repo_name": "nitishk017/ns2project", "max_stars_repo_head_hexsha": "f037b796ff10300ffe0422580be5855c37d0b140", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-29T13:04:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-29T13:04:42.000Z", "max_issues_repo_path": "ns-allinone-2.35/ns-2.35/doc/propagation.tex", "max_issues_repo_name": "nitishk017/ns2project", "max_issues_repo_head_hexsha": "f037b796ff10300ffe0422580be5855c37d0b140", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-20T17:35:23.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-22T21:41:38.000Z", "max_forks_repo_path": "ns-allinone-2.35/ns-2.35/doc/propagation.tex", "max_forks_repo_name": "nitishk017/ns2project", "max_forks_repo_head_hexsha": "f037b796ff10300ffe0422580be5855c37d0b140", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-29T16:06:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-29T16:06:57.000Z", "avg_line_length": 37.0361445783, "max_line_length": 84, "alphanum_fraction": 0.716330514, "num_tokens": 3341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.4288634376063075}}
{"text": "\\subsection{Deductive systems}\\label{subsec:deductive_systems}\n\nWithout a clear context, by \\enquote{logical formula} we will mean a \\hyperref[def:formal_language/word]{word} over some \\hyperref[def:formal_language/alphabet]{alphabet}. In practice, these will be either \\hyperref[def:propositional_syntax/formula]{propositional formulas} or \\hyperref[def:first_order_syntax/formula]{first-order formulas}.\n\nIt is challenging to formally define a deductive system in a way that reflects reality. We will do this via some auxiliary definitions that rely heavily on the interaction between the object logic and the \\hyperref[rem:metalogic]{metalogic}.\n\n\\begin{definition}\\label{def:judgment}\\mimprovised\n  A \\term{judgment} is a logical formula of the metalogic, which is usually used for assertion. Using judgments allows us to quantify over metalogical properties. We will be interested in the following kinds of judgments:\n\n  \\begin{thmenum}\n    \\thmitem{def:judgment/sequent} A \\term{sequent} is a judgment with at least two free variables. We denote a sequent \\( \\vdash \\) with free variables \\( \\Gamma \\) and \\( \\Delta \\) by\n    \\begin{equation*}\n      \\Gamma \\vdash \\Delta.\n    \\end{equation*}\n\n    The intended interpretation for both \\( \\Gamma \\) and \\( \\Delta \\) is that of sets of formulas in the object logic, in which case a sequent expresses the metalogical statement that \\enquote{the formulas in \\( \\Gamma \\) collectively entail via \\( \\vdash \\) the any formula in \\( \\Delta \\)}.\n\n    We could have defined a sequent as a predicate, however we may not have appropriate predicate symbols on the metalanguage. This issue is discussed in \\fullref{rem:predicate_formula}.\n\n    \\thmitem{def:judgment/inference_rule} An \\term{inference rule} is a judgment with at least one free variable. We denote an inference rule \\( R \\) with free variables \\( \\psi \\) and \\( \\varphi_1, \\ldots, \\varphi_n \\) by\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\varphi_1 }\n        \\hypo{ \\cdots }\n        \\hypo{ \\varphi_n }\n        \\infer3[R]{ \\psi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    We allow the possibility that \\( n = 0 \\), in which case the rule becomes\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\infer0[R]{ \\psi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    The intended interpretation for the listed variables is that of formulas in the object logic, in which case an inference rule expresses the metalogical statement that \\enquote{the premises \\( \\varphi_1, \\ldots, \\varphi_n \\) collectively entail the consequence \\( \\psi \\), as justified by the rule \\( R \\)}. When building complicated proofs, however, the applicability of the rule may depend on some context, and for this reason \\( \\varphi_1, \\ldots, \\varphi_n \\) are often interpreted as \\hyperref[def:proof_tree]{proof trees} rather than single formulas. See \\fullref{def:first_order_natural_deduction_system/eigenvariables} for such an example.\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{remark}\\label{rem:sequents_inference_rules}\n  Inference rules are both special cases and generalizations of sequents, depending on how we view them. Using an interpretation where \\( \\Gamma = \\varphi_1, \\ldots, \\varphi_n \\) and \\( \\Delta = \\psi \\), inference rules simply allow an alternative syntax for sequents.\n\n  It is sometimes convenient, however, to interpret the formulas \\( \\varphi_1, \\ldots, \\varphi_n \\) as sequents in some auxiliary logic between the object and metalogic, in which case we are able to express more complicated inference rules of the sort\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\varphi, \\Gamma \\vdash \\Delta, \\psi }\n      \\infer1{ \\Gamma \\vdash \\Delta, \\varphi \\to \\psi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  This can be very useful when inductively defining the metalogical relation \\( \\vdash \\).\n\\end{remark}\n\n\\begin{definition}\\label{def:proof_tree}\\mimprovised\n  A \\term{proof tree} is a \\hyperref[def:arborescence/undirected]{rooted tree} of logical formulas. The validity of a proof tree is handled by \\hyperref[def:deductive_system]{deductive system} and is irrelevant for this definition.\n\n  \\begin{thmenum}\n    \\thmitem{def:proof_tree/subproof} A \\term{subproof} is simply a subtree of a proof. If a subproof was obtained using an \\hyperref[def:judgment/inference_rule]{inference rule}, the subproof \\hyperref[def:weighted_set]{labeled} with the name of the rule by the deductive systems.\n\n    \\thmitem{def:proof_tree/premises} The root of the tree is called the \\term{conclusion} of the proof and the \\hyperref[def:arborescence/ancestry]{leaves} are called \\term{premises} or, in the context of \\hyperref[def:natural_deduction_system]{natural deduction}, \\term{assumptions}. We sometimes add a \\term{non-premise} label to a leaf that prevents it from being added to the list of premises.\n\n    \\thmitem{def:proof_tree/drawing} We will draw graphically proof trees with no edges and with the root at the bottom in a style inspired by inference rules. See \\fullref{ex:def:positive_implicational_deductive_system/identity} for an example.\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:deductive_system}\\mimprovised\n  A \\term{deductive system} for a set \\( \\mscrF \\) of formulas in the object logic is a metalogical collection of \\hyperref[def:judgment/inference_rule]{inference rules}, which are used to generate \\hyperref[def:proof_tree]{proof trees} in the object logic.\n\n  We will not attempt to encode inference rules themselves into the object theory and instead regard a deductive system as a pair \\( (\\mscrF, \\mscrP) \\), where \\( \\mscrF \\) is a set of logical formulas and \\( \\mscrP \\) is a set of proofs over \\( \\mscrF \\).\n\n  We define the set \\( \\mscrP \\) of proofs via \\hyperref[thm:structural_recursion]{structural recursion}.\n  \\begin{thmenum}\n    \\thmitem{def:deductive_system/base} For every formula \\( \\varphi \\) in \\( \\mscrF \\), the tree with root \\( \\varphi \\) and no children is a proof \\( \\mscrP \\).\n\n    \\thmitem{def:deductive_system/rule} Let \\( \\varphi_1, \\ldots, \\varphi_n \\) and \\( \\psi \\) be formulas in \\( \\mscrF \\) and \\( P_1, \\ldots, P_n \\) be proofs of \\( \\varphi_1, \\ldots, \\varphi_n \\).\n\n    Suppose that the deductive system has an inference rule\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\Phi_1 }\n        \\hypo{ \\cdots }\n        \\hypo{ \\Phi_n }\n        \\infer3[R]{ \\Psi }\n      \\end{prooftree}\n    \\end{equation*}\n    such that\n    \\begin{equation*}\n      R\\Bracks{ \\Phi_1 \\mapsto P_1, \\ldots, \\Phi_n \\mapsto P_n, \\Psi \\mapsto \\psi } = T\n    \\end{equation*}\n    in the metalogic of the metalogic.\n\n    Then the tree with root \\( \\psi \\), subtrees \\( P_1, \\ldots, P_n \\) of the root, and label \\( R \\), is a proof in \\( \\mscrP \\). In the case of rules with no premises like \\eqref{eq:def:minimal_propositional_natural_deduction_system/top/intro}, we add a \\hyperref[def:proof_tree/premises]{non-premise label} to the proof in order to exclude \\( \\psi \\) from the list of premises of the proof.\n\n    We say that the resulting proof\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ P_1 }\n        \\hypo{ \\cdots }\n        \\hypo{ P_n }\n        \\infer3[r]{ \\psi }\n      \\end{prooftree}\n    \\end{equation*}\n    is an \\term{application} of the rule \\( R \\).\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:proof_derivability}\n  We are often interested not in the proofs of a \\hyperref[def:deductive_system]{deductive system}, but in \\term{provability}, which we express via \\hyperref[def:judgment/sequent]{sequents}.\n\n  Fix a deductive system \\( (\\mscrF, \\mscrP) \\). If \\( \\mscrP \\) contains a proof of \\( \\varphi \\), whose premises are all members of \\( \\Gamma \\), the following sequent is valid:\n  \\begin{equation*}\n    \\Gamma \\vdash \\varphi.\n  \\end{equation*}\n\n  We say that \\( \\varphi \\) is a \\term{theorem} of \\( \\Gamma \\). If \\( \\Gamma \\) is empty, we say that \\( \\varphi \\) is a \\term{logical theorem}.\n\n  Furthermore, \\( \\vdash \\) is a reflexive and transitive relation, which makes \\( (\\pow(\\mscrF), \\vdash) \\) a \\hyperref[def:preordered_set]{preordered set}.\n\\end{definition}\n\n\\begin{definition}\\label{def:axiomatic_deductive_system}\\mimprovised\n  \\term{Axiomatic deductive systems}, also called \\term{Hilbert-style systems}, are \\hyperref[def:deductive_system]{deductive systems} for propositional formulas consist of the single \\hyperref[def:judgment/inference_rule]{inference rule} \\term[en=mode that by affirming affirms]{modus ponens}:\n  \\begin{equation*}\\taglabel[\\textrm{MP}]{eq:def:def:axiomatic_deductive_system/mp}\n    \\begin{prooftree}\n      \\hypo{ \\varphi }\n      \\hypo{ \\varphi \\rightarrow \\psi }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ \\psi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  Fix a set \\( \\mscrF \\) of logical formulas. Let \\( \\mscrA \\subseteq \\mscrF \\) be a predefined subset of formulas, which we will call \\term{logical axioms} of \\( \\mscrF \\). The axiomatic deductive system itself is the pair \\( (\\mscrF, \\mscrA) \\).\n\n  Given a proof of the deductive system, we split its premises into \\term{logical axioms} and \\term{non-logical axioms} depending on whether they belong to \\( \\mscrA \\) or not.\n\n  Note that we cannot have a complete axiomatic deductive system for first-order logic because of the eigenvariable condition in the rules \\eqref{eq:def:first_order_natural_deduction_system/forall/intro} and \\eqref{eq:def:first_order_natural_deduction_system/exists/elim}.\n\\end{definition}\n\n\\begin{proposition}\\label{thm:deductive_system_transitivity}\n  Given a deductive system, if \\( \\Gamma \\vdash \\varphi \\), then \\( \\Gamma, \\Delta \\vdash \\varphi \\) for any formula \\( \\varphi \\) and any sets \\( \\Gamma \\) and \\( \\Delta \\).\n\n  If every formula in \\( \\Delta \\) is derivable from \\( \\Gamma \\), then the converse also holds: \\( \\Gamma, \\Delta \\vdash \\varphi \\) implies \\( \\Gamma \\vdash \\varphi \\).\n\\end{proposition}\n\\begin{proof}\n  If there exists a proof \\( \\varphi \\) from \\( \\Gamma \\), then adding additional axioms does not change anything.\n\n  The second part of the theorem has a tad more complicated proof. Assume that every formula in \\( \\Delta \\) is derivable from \\( \\Gamma \\) and that \\( \\Gamma, \\Delta \\vdash \\varphi \\).\n\n  For every \\( \\delta \\in \\Delta \\), let \\( P_\\delta \\) be a proof of \\( \\delta \\) from members of \\( \\Gamma \\) and let \\( P_\\varphi \\) be a proof of \\( \\varphi \\) from \\( \\Gamma \\cup \\Delta \\).\n\n  Then, for every \\( \\delta \\in \\Delta \\), we can replace the subtree of \\( \\delta \\) with \\( P_\\delta \\) to obtain a proof of \\( \\varphi \\) from \\( \\Gamma \\).\n\n  Therefore, \\( \\Gamma \\vdash \\varphi \\).\n\\end{proof}\n\n\\begin{definition}\\mcite[sec. 1]{Wasilewska2010}\\label{def:positive_implicational_deductive_system}\n  The \\term{positive implicational propositional deductive system} is an extraordinarily simple \\hyperref[def:axiomatic_deductive_system]{axiomatic deductive system}.\n\n  It is based on the \\hyperref[def:propositional_language]{language of propositional logic}, but limited to formulas containing only the \\hyperref[def:propositional_language/connectives/conditional]{conditional connective} \\( \\rightarrow \\), without any \\hyperref[def:propositional_language/constants]{propositional constants} or \\hyperref[def:propositional_language/negation]{negation}. Note that this is only a special case of \\hyperref[def:positive_formula]{positive formulas}.\n\n  The adjective \\enquote{positive} in the name of the system refers to the impossibility to negate a formula. \\enquote{Implicational} refers to the fact that all formulas are \\hyperref[def:material_implication]{material implications} and the \\hyperref[eq:def:def:axiomatic_deductive_system/mp]{sole inference rule} is based on eliminating the connective.\n\n  The system has the following logical axiom schemas:\n  \\begin{thmenum}\n    \\thmitem{def:positive_implicational_deductive_system/intro} For every formula \\( \\varphi \\), we can \\enquote{introduce} an \\hyperref[def:material_implication]{implication} whose consequent is \\( \\varphi \\) and whose antecedent is any other formula \\( \\psi \\):\n    \\begin{equation}\\label{eq:def:positive_implicational_deductive_system/intro}\n      \\varphi \\rightarrow (\\psi \\rightarrow \\varphi) \\tag{\\textrm{AX} \\( \\rightarrow^+ \\)}.\n    \\end{equation}\n\n    \\thmitem{def:positive_implicational_deductive_system/trans} Implication is transitive:\n    \\begin{equation}\\label{eq:def:positive_implicational_deductive_system/trans}\n      \\parens[\\Big]{ \\varphi \\rightarrow (\\psi \\rightarrow \\theta) } \\rightarrow \\parens[\\Big]{ (\\varphi \\rightarrow \\psi) \\rightarrow (\\varphi \\rightarrow \\theta)} \\tag{\\textrm{AX} \\( \\twoheadrightarrow \\)}.\n    \\end{equation}\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{example}\\mcite[ex. 1.1]{Wasilewska2010}\\label{ex:def:positive_implicational_deductive_system/identity}\n  Fix any \\hyperref[def:positive_implicational_deductive_system]{positive implicational formula} \\( \\varphi \\). We will construct a derivation of the implication\n  \\begin{equation}\\label{eq:ex:def:positive_implicational_deductive_system/identity}\n    \\varphi \\rightarrow \\varphi.\n  \\end{equation}\n\n  We derive the proof from the two logical axioms:\n  \\begin{equation}\\label{eq:ex:def:positive_implicational_deductive_system/identity/proof}\n    \\begin{prooftree}[separation=3em]\n      \\hypo\n        {\n          \\eqref{eq:def:positive_implicational_deductive_system/intro}\n        }\n\n      \\ellipsis\n        {\n          \\( \\begin{array}{l}\n            \\psi \\mapsto (\\varphi \\rightarrow \\varphi)\n            \\\\\n            \\mbox{}\n          \\end{array} \\)\n        }\n        {\n          \\eqref{eq:ex:propositional_positive_implicational_logic/dagger}\n        }\n\n      \\hypo\n        {\n          \\eqref{eq:def:positive_implicational_deductive_system/trans}\n        }\n\n      \\ellipsis\n        {\n          \\( \\begin{array}{l}\n            \\psi \\mapsto (\\varphi \\rightarrow \\varphi)\n            \\\\\n            \\theta \\mapsto \\varphi\n          \\end{array} \\)\n        }\n        {\n          \\eqref{eq:ex:propositional_positive_implicational_logic/dagger}\n          \\rightarrow ((\\varphi \\rightarrow (\\varphi \\rightarrow \\varphi)) \\rightarrow (\\varphi \\rightarrow \\varphi))\n        }\n\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{(\\varphi \\rightarrow (\\varphi \\rightarrow \\varphi)) \\rightarrow (\\varphi \\rightarrow \\varphi)}\n\n      \\hypo\n        {\n          \\eqref{eq:def:positive_implicational_deductive_system/intro}\n        }\n\n      \\ellipsis\n        {\n          \\( \\psi \\mapsto \\varphi \\)\n        }\n        {\n          \\varphi \\rightarrow (\\varphi \\rightarrow \\varphi)\n        }\n\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{\\varphi \\rightarrow \\varphi}\n    \\end{prooftree}\n  \\end{equation}\n  where\n  \\begin{equation}\\label{eq:ex:propositional_positive_implicational_logic/dagger}\n    \\varphi \\rightarrow ((\\varphi \\rightarrow \\varphi) \\rightarrow \\varphi).\n  \\end{equation}\n\n  The only assumptions used in the derivation were logical axioms, hence \\eqref{eq:ex:def:positive_implicational_deductive_system/identity} is a logical theorem.\n\\end{example}\n\n\\begin{definition}\\label{def:derivability_and_satisfiability}\n  We introduce two notions connecting \\hyperref[def:proof_derivability]{derivability} and \\hyperref[def:first_order_semantics/satisfiability]{satisfiability}:\n  \\begin{thmenum}\n    \\thmitem{def:derivability_and_satisfiability/soundness} If, for any closed formula \\( \\varphi \\), derivability \\( \\vdash \\varphi \\) implies satisfiability \\( \\vDash \\varphi \\), we say that the deductive system is \\term{sound} with respect to the semantical framework.\n\n    \\thmitem{def:derivability_and_satisfiability/completeness} Dually, if satisfiability \\( \\vDash \\varphi \\) implies derivability \\( \\vdash \\varphi \\) for any closed formula \\( \\varphi \\), we say that the deductive system is \\term{complete} with respect to the semantical framework.\n  \\end{thmenum}\n\n  We restrict our attention to closed formulas because we wish to avoid the problems described in \\fullref{rem:deduction_with_free_variables}. If we have a formula with free variables, we may simply take its \\hyperref[thm:implicit_universal_quantification]{universal closure}.\n\\end{definition}\n\n\\begin{proposition}\\label{thm:soundness_of_positive_implicational_propositional_natural_deduction_system}\\mcite[thm. 1.1]{Wasilewska2010}\n  The \\hyperref[def:positive_implicational_deductive_system]{positive implicational propositional deductive system} is \\hyperref[def:derivability_and_satisfiability/soundness]{sound} with respect to \\hyperref[def:propositional_semantics]{classical semantics}.\n\\end{proposition}\n\n\\begin{theorem}[Syntactic deduction theorem]\\label{thm:syntactic_deduction_theorem}\n  In the \\hyperref[def:positive_implicational_deductive_system]{positive implicational deductive system}, \\( \\Gamma, \\psi \\vdash \\varphi \\) holds if and only if \\( \\Gamma \\vdash \\psi \\rightarrow \\varphi \\) holds.\n\n  This theorem also holds for propositional deductive systems which extend the positive implication system with compatible rules, as in the case of \\fullref{def:minimal_propositional_natural_deduction_system} or \\fullref{def:first_order_natural_deduction_system}.\n\\end{theorem}\n\\begin{proof}\n  \\SufficiencySubProof Suppose that \\( \\Gamma, \\psi \\vdash \\varphi \\) and let \\( P \\) be a proof of \\( \\varphi \\) from \\( \\Gamma \\cup \\set{ \\psi } \\). We will use \\fullref{thm:structural_induction_on_unambiguous_grammars} on \\( \\varphi \\).\n\n  \\begin{itemize}\n    \\item First suppose that \\( \\varphi \\) is either a logical or a nonlogical axiom; in the latter case either \\( \\varphi \\in \\Gamma \\) or \\( \\varphi = \\psi \\). In all three cases, the logical axiom \\eqref{eq:def:positive_implicational_deductive_system/intro} allows us to derive \\( \\psi \\rightarrow \\varphi \\) from \\( \\Gamma \\) using \\eqref{eq:def:def:axiomatic_deductive_system/mp}.\n\n    \\item Otherwise, since the only rule is \\eqref{eq:def:def:axiomatic_deductive_system/mp}, there exists some formula \\( \\theta \\) derivable from \\( \\Gamma \\cup \\set{ \\psi } \\) such that \\( P \\) contains the formulas \\( \\theta \\) and for \\( \\theta \\rightarrow \\varphi \\). The inductive hypothesis holds for both, and hence \\( \\Gamma \\vdash \\psi \\to \\theta \\) and \\( \\Gamma \\vdash \\psi \\to (\\theta \\rightarrow \\varphi) \\). Let \\( P_1 \\) and \\( P_2 \\) be proofs corresponding to these two sequents.\n\n    We can now build the following proof of \\( \\psi \\to \\varphi \\) from \\( \\Gamma \\):\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ P_2 }\n\n        \\hypo{ \\eqref{eq:def:positive_implicational_deductive_system/trans} }\n        \\ellipsis\n          {}\n          {\n            \\parens[\\Big]{ \\psi \\rightarrow (\\theta \\rightarrow \\varphi) } \\rightarrow \\parens[\\Big]{ (\\psi \\rightarrow \\theta) \\rightarrow (\\psi \\rightarrow \\varphi)}\n          }\n\n        \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ (\\psi \\rightarrow \\theta) \\rightarrow (\\psi \\rightarrow \\varphi) }\n\n        \\hypo{ P_1 }\n        \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ \\psi \\rightarrow \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n  \\end{itemize}\n\n  \\NecessitySubProof Now suppose that \\( \\Gamma \\vdash \\psi \\rightarrow \\varphi \\). Then we can apply \\eqref{eq:def:def:axiomatic_deductive_system/mp} to obtain \\( \\varphi \\) from \\( \\Gamma \\cup \\set{ \\psi } \\).\n\\end{proof}\n\n\\begin{definition}\\label{def:minimal_propositional_axiomatic_deductive_system}\\mcite[def. 55.10]{OpenLogicFull}\n  While the \\hyperref[def:positive_implicational_deductive_system]{positive implicational propositional deductive system} is simple, it is of more practical use to have all propositional connectives available. As it turns out, we cannot utilize \\hyperref[ex:thm:posts_completeness_theorem]{complete families of Boolean functions} unless we are dealing with \\hyperref[def:propositional_semantics]{classical semantics} --- see for example \\fullref{ex:heyting_semantics_lem_counterexample} and \\fullref{ex:topological_semantics_lem_counterexample} for how \\fullref{thm:boolean_equivalences/conditional_as_disjunction} fails to hold.\n\n  Our goal is to define the (axiomatic) \\term{minimal propositional axiomatic deductive system}, which would correspond to \\hyperref[def:minimal_logic]{minimal logic}. It is axiomatic in the sense that we do not use new rules to express the rest of the propositional syntax, but instead we need axiom schemas for each connective. The only exception is \\hyperref[def:propositional_language/constants/verum]{\\( \\bot \\)}, the axioms for which tend to change semantics by a lot --- see \\fullref{thm:minimal_propositional_negation_laws}.\n\n  Axioms with \\( + \\) in the superscript are called \\term{introduction axioms} and axioms with \\( - \\) are called \\term{elimination axioms}.\n\n  The following axioms are essential in the sense that they cannot be defined in terms of others:\n  \\begin{thmenum}[series=def:minimal_propositional_axiomatic_deductive_system]\n    \\thmitem{def:minimal_propositional_axiomatic_deductive_system/top} The simplest axiom states that the constant \\hyperref[def:propositional_language/constants/verum]{\\( \\top \\)} is itself an axiom:\n    \\begin{equation}\\label{eq:def:minimal_propositional_axiomatic_deductive_system/top/intro}\n      \\top \\tag{\\textrm{AX} \\( \\top^+ \\)}\n    \\end{equation}\n\n    \\thmitem{def:minimal_propositional_axiomatic_deductive_system/and} Axioms for \\hyperref[def:propositional_language/connectives/conjunction]{conjunction}:\n    \\begin{align}\n      \\mathllap{ (\\varphi \\wedge \\psi) } &\\rightarrow \\mathrlap{ \\psi } \\tag{\\textrm{AX} \\( \\wedge_L^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/and/elim_left} \\\\\n      \\mathllap{ (\\varphi \\wedge \\psi) } &\\rightarrow \\mathrlap{ \\varphi } \\tag{\\textrm{AX} \\( \\wedge_R^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/and/elim_right} \\\\\n      \\mathllap{ \\varphi }               &\\rightarrow \\mathrlap{ \\parens[\\Big]{ \\psi \\rightarrow (\\varphi \\wedge \\psi) } } \\tag{\\textrm{AX} \\( \\wedge^+ \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/and/intro}\n    \\end{align}\n\n    \\thmitem{def:minimal_propositional_axiomatic_deductive_system/or} Axioms for \\hyperref[def:propositional_language/connectives/disjunction]{disjunction}:\n    \\begin{align}\n      \\mathllap{ \\varphi }                      &\\rightarrow \\mathrlap{ (\\varphi \\vee \\psi) } \\tag{\\textrm{AX} \\( \\vee_L^+ \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/or/intro_left} \\\\\n      \\mathllap{ \\psi }                      &\\rightarrow \\mathrlap{ (\\varphi \\vee \\psi) } \\tag{\\textrm{AX} \\( \\vee_R^+ \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/or/intro_right} \\\\\n      \\mathllap{ (\\varphi \\rightarrow \\theta) } &\\rightarrow \\mathrlap{ \\parens[\\Big]{ (\\psi \\rightarrow \\theta) \\rightarrow ((\\varphi \\vee \\psi) \\rightarrow \\theta) } } \\tag{\\textrm{AX} \\( \\vee^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/or/elim}\n    \\end{align}\n  \\end{thmenum}\n\n  The following axioms and are said to be \\enquote{abbreviations} and do not affect semantics:\n  \\begin{thmenum}[resume=def:minimal_propositional_axiomatic_deductive_system]\n    \\thmitem{def:minimal_propositional_axiomatic_deductive_system/iff} The axioms for the biconditional is motivated via \\fullref{thm:boolean_equivalences/biconditional_via_conditionals}:\n    \\begin{align}\n      \\mathllap{ (\\varphi \\rightarrow \\psi)     } &\\rightarrow \\mathrlap{ \\parens[\\Big]{ (\\psi \\rightarrow \\varphi) \\rightarrow (\\varphi \\leftrightarrow \\psi) } } \\tag{\\textrm{AX} \\( \\leftrightarrow^+ \\)} \\label{def:minimal_propositional_axiomatic_deductive_system/iff/intro} \\\\\n      \\mathllap{ (\\varphi \\leftrightarrow \\psi)  }&\\rightarrow \\mathrlap{ (\\varphi \\rightarrow \\psi) } \\tag{\\textrm{AX} \\( \\leftrightarrow_L^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/iff/elim_left} \\\\\n      \\mathllap{ (\\varphi \\leftrightarrow \\psi) } &\\rightarrow \\mathrlap{ (\\psi \\rightarrow \\varphi) } \\tag{\\textrm{AX} \\( \\leftrightarrow_R^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/iff/elim_right}\n    \\end{align}\n\n    \\thmitem{def:minimal_propositional_axiomatic_deductive_system/negation} The axioms for negation is motivated via \\fullref{thm:boolean_equivalences/negation_bottom}:\n    \\begin{align}\n      \\mathllap{ \\neg \\varphi }               &\\rightarrow \\mathrlap{ (\\varphi \\rightarrow \\bot) } \\tag{\\textrm{AX} \\( \\neg^- \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/neg/elim} \\\\\n      \\mathllap{ (\\varphi \\rightarrow \\bot) } &\\rightarrow \\mathrlap{ \\neg \\varphi } \\tag{\\textrm{AX} \\( \\neg^+ \\)} \\label{eq:def:minimal_propositional_axiomatic_deductive_system/neg/intro}\n    \\end{align}\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{definition}\\label{def:natural_deduction_system}\\mimprovised\n  \\term{Natural deductive systems} are \\hyperref[def:deductive_system]{deductive systems} whose set of rules allows \\term{discharging} certain assumptions of the proof tree. These rules correspond to \\enquote{bringing in} the sequent \\( \\varphi \\vdash \\psi \\) as a formula \\( \\varphi \\to \\psi \\), thus eliminating \\( \\varphi \\) as an assumption as justified by \\fullref{thm:syntactic_deduction_theorem}.\n\n  In a natural deduction system, all assumptions in a \\hyperref[def:proof_tree]{proof trees} are labeled differently. When applying a rule that supports discharging assumptions, we add an additional \\hyperref[def:weighted_set]{label} to the subproof that matches the label of the assumption which we discharge.\n\n  This allows us to distinguish between \\term{discharged assumptions} and \\term{undischarged assumptions}. We add a \\hyperref[def:proof_tree/premises]{non-premise label} to every discharged assumption so that it does not affect \\hyperref[def:proof_derivability]{derivability}.\n\\end{definition}\n\n\\begin{proposition}\\label{def:minimal_propositional_natural_deduction_system}\\mcite[sec. 10.2]{OpenLogicFull}\n  We define the \\term{minimal propositional natural deduction system}, which is the \\hyperref[def:natural_deduction_system]{natural deduction} equivalent of the \\hyperref[def:minimal_propositional_axiomatic_deductive_system]{minimal propositional axiomatic deductive system}.\n\n  \\begin{thmenum}\n    \\thmitem{def:minimal_propositional_natural_deduction_system/imp} The following rules corresponds to the conditional axiom schemas in \\fullref{def:positive_implicational_deductive_system}:\n\n    \\begin{minipage}[t]{0.45\\textwidth}\n      This rule is inspired by \\eqref{eq:def:positive_implicational_deductive_system/intro}:\n      \\begin{equation*}\\taglabel[\\( \\rightarrow^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/imp/intro}\n        \\begin{prooftree}\n          \\hypo{ [\\psi]^n }\n          \\ellipsis {} { \\varphi }\n          \\infer[left label=\\( n \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\psi \\rightarrow \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}[t]{0.45\\textwidth}\n      This rule is merely a renaming of \\eqref{eq:def:def:axiomatic_deductive_system/mp}:\n      \\begin{equation*}\\taglabel[\\( \\rightarrow^- \\)]{eq:def:minimal_propositional_natural_deduction_system/imp/elim}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\rightarrow \\psi }\n          \\hypo{ \\varphi }\n          \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}]{ \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    The additional notation in \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro} means that the premise labeled with \\( n \\), if any, can be discharged.\n\n    Note that there is no rule corresponding to \\eqref{eq:def:positive_implicational_deductive_system/trans} because this axiom schema follows from \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro} and \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}. Unlike in the axiomatic deductive system where \\eqref{eq:def:positive_implicational_deductive_system/trans} is used to prove \\fullref{thm:syntactic_deduction_theorem}, here we have a stronger connection between \\( \\rightarrow \\) in the object language and \\( \\vdash \\) in the metalanguage given by \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}.\n\n    \\thmitem{def:minimal_propositional_natural_deduction_system/top} The following rule corresponds to the axiom \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/top/intro}:\n    \\begin{equation*}\\taglabel[\\( \\top^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/top/intro}\n      \\begin{prooftree}\n        \\infer0[\\ref{eq:def:minimal_propositional_natural_deduction_system/top/intro}]{ \\top }\n      \\end{prooftree}\n    \\end{equation*}\n\n    As discussed in \\fullref{def:deductive_system/rule}, applications of this rule have a \\hyperref[def:proof_tree/premises]{non-premise label} in order to prevent \\( \\top \\) as an undischarged assumption.\n\n    \\thmitem{def:minimal_propositional_natural_deduction_system/and} The following rules corresponds to the conjunction axiom schemas in \\fullref{def:minimal_propositional_axiomatic_deductive_system/and}:\n\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\wedge^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/and/intro}\n        \\begin{prooftree}\n          \\hypo{ \\varphi }\n          \\hypo{ \\psi }\n          \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/intro}]{ \\varphi \\wedge \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\wedge_L^- \\)]{eq:def:minimal_propositional_natural_deduction_system/and/elim_left}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\wedge \\psi }\n          \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/elim_left}]{ \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\wedge_R^- \\)]{eq:def:minimal_propositional_natural_deduction_system/and/elim_right}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\wedge \\psi }\n          \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/elim_right}]{ \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    \\thmitem{def:minimal_propositional_natural_deduction_system/or} The following rules corresponds to the disjunction axiom schemas in \\fullref{def:minimal_propositional_axiomatic_deductive_system/or}:\n\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\vee_L^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/or/intro_left}\n        \\begin{prooftree}\n          \\hypo{ \\varphi }\n          \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/or/intro_left}]{ \\varphi \\vee \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\vee_R^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/or/intro_right}\n        \\begin{prooftree}\n          \\hypo{ \\psi }\n          \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/or/intro_right}]{ \\varphi \\vee \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\vee^- \\)]{eq:def:minimal_propositional_natural_deduction_system/or/elim}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\vee \\psi }\n          \\hypo{ [\\varphi]^n }\n          \\ellipsis {} { \\theta }\n          \\hypo{ [\\psi]^n }\n          \\ellipsis {} { \\theta }\n          \\infer[left label=\\( n \\)]3[\\ref{eq:def:minimal_propositional_natural_deduction_system/or/elim}]{ \\theta }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    \\thmitem{def:minimal_propositional_natural_deduction_system/iff} The following rules corresponds to the biconditional axiom schemas in \\fullref{def:minimal_propositional_axiomatic_deductive_system/iff}:\n\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\leftrightarrow^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/iff/intro}\n        \\begin{prooftree}\n          \\hypo{ [\\varphi]^n }\n          \\ellipsis {} { \\psi }\n          \\hypo{ [\\psi]^n }\n          \\ellipsis {} { \\varphi }\n          \\infer[left label=\\( n \\)]2[\\ref{eq:def:minimal_propositional_natural_deduction_system/iff/intro}]{ \\varphi \\leftrightarrow \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\leftrightarrow_L^- \\)]{eq:def:minimal_propositional_natural_deduction_system/iff/elim_left}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\leftrightarrow \\psi }\n          \\hypo{ \\psi }\n          \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/iff/elim_left}]{ \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\leftrightarrow_R^- \\)]{eq:def:minimal_propositional_natural_deduction_system/iff/elim_right}\n        \\begin{prooftree}\n          \\hypo{ \\varphi \\leftrightarrow \\psi }\n          \\hypo{ \\varphi }\n          \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/iff/elim_right}]{ \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    \\thmitem{def:minimal_propositional_natural_deduction_system/negation} The following rules corresponds to the negation axiom schemas in \\fullref{def:minimal_propositional_axiomatic_deductive_system/negation}:\n\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\neg^+ \\)]{eq:def:minimal_propositional_natural_deduction_system/neg/intro}\n        \\begin{prooftree}\n          \\hypo{ [\\varphi]^n }\n          \\ellipsis {} { \\bot }\n          \\infer[left label=\\( n \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/neg/intro}]{ \\neg \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\neg^- \\)]{eq:def:minimal_propositional_natural_deduction_system/neg/elim}\n        \\begin{prooftree}\n          \\hypo{ \\varphi }\n          \\hypo{ \\neg \\varphi }\n          \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n  \\end{thmenum}\n\\end{proposition}\n\\begin{defproof}\n  We will prove that the axiomatic \\hyperref[def:minimal_propositional_axiomatic_deductive_system]{minimal propositional axiomatic deductive system} is equivalent to the rules of natural deduction described in this proposition.\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/imp} Consider first the axiom \\eqref{eq:def:positive_implicational_deductive_system/intro}. Fix two formulas \\( \\varphi \\) and \\( \\psi \\). Then \\( \\varphi \\rightarrow (\\psi \\rightarrow \\varphi) \\) is an instance of \\eqref{eq:def:positive_implicational_deductive_system/intro}. Thus, we obtain \\( \\varphi \\vdash \\psi \\rightarrow \\varphi \\) by applying \\eqref{eq:def:def:axiomatic_deductive_system/mp}, which in turn shows the validity of the rule \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}.\n\n  The labeled assumption here is essential for showing that \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro} implies \\eqref{eq:def:positive_implicational_deductive_system/intro}. Without it we would have the rule\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\psi }\n      \\infer1{ \\varphi \\rightarrow \\psi }\n    \\end{prooftree}\n  \\end{equation*}\n  which would not allow us to discharge the assumption \\( \\varphi \\) when it is in fact immaterial for the validity of \\( \\psi \\).\n\n  Now we will show that \\eqref{eq:def:positive_implicational_deductive_system/trans} can be derived using only the rules \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro} and \\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}:\n  \\begin{equation}\\label{eq:def:minimal_propositional_natural_deduction_system/imp/trans_derivation}\n    \\begin{prooftree}\n      \\hypo{ [\\varphi \\rightarrow (\\psi \\rightarrow \\theta)]^1 }\n      \\hypo{ [\\varphi]^2 }\n      \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}]{ \\psi \\rightarrow \\theta }\n\n      \\hypo{ [\\varphi \\rightarrow \\psi]^3 }\n      \\hypo{ [\\varphi]^2 }\n      \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}]{ \\psi }\n\n      \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}]{ \\theta }\n\n      \\infer[left label=\\( 2 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\varphi \\rightarrow \\theta }\n      \\infer[left label=\\( 3 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ (\\varphi \\rightarrow \\psi) \\rightarrow (\\varphi \\rightarrow \\theta) }\n      \\infer[left label=\\( 1 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\eqref{eq:def:positive_implicational_deductive_system/trans} }\n    \\end{prooftree}\n  \\end{equation}\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/top} Obvious.\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/and} The rule \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/and/intro} is equivalent by more readable than proving \\( \\set{ \\varphi, \\psi } \\vdash \\varphi \\wedge \\psi \\) directly. Indeed, compare it to\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\varphi }\n      \\hypo{ \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/and/intro} }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ \\psi \\rightarrow (\\varphi \\wedge \\psi) }\n\n      \\hypo{ \\psi }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ \\varphi \\wedge \\psi },\n    \\end{prooftree}\n  \\end{equation*}\n  which is a derivation of \\( \\varphi \\wedge \\psi \\) from \\( \\set{ \\varphi, \\psi } \\) using the axiomatic system. The other direction is also simple:\n  \\begin{equation}\\label{eq:def:minimal_propositional_natural_deduction_system/and_intro_axiom_derivation}\n    \\begin{prooftree}\n      \\hypo{ [\\varphi]^1 }\n      \\hypo{ [\\psi]^2 }\n      \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/intro}]{ \\varphi \\wedge \\psi }\n      \\infer[left label=\\( 2 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\psi \\rightarrow (\\varphi \\wedge \\psi) },\n      \\infer[left label=\\( 1 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/and/intro} },\n    \\end{prooftree}\n  \\end{equation}\n\n  The other two rules are trivially connected to the corresponding axioms using a single application of \\eqref{eq:def:def:axiomatic_deductive_system/mp}.\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/or} For a more complicated example, consider \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/or/elim}. We have\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/or/elim} }\n      \\hypo{ \\varphi \\rightarrow \\theta }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ (\\psi \\rightarrow \\theta) \\rightarrow ((\\varphi \\vee \\psi) \\rightarrow \\theta) },\n\n      \\hypo{ \\psi \\rightarrow \\theta }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ (\\varphi \\vee \\psi) \\rightarrow \\theta }.\n\n      \\hypo{ \\varphi \\vee \\psi }\n      \\infer2[\\ref{eq:def:def:axiomatic_deductive_system/mp}]{ \\theta }.\n    \\end{prooftree}\n  \\end{equation*}\n\n  The assumptions of this derivations are \\( \\varphi \\rightarrow \\theta \\), \\( \\psi \\rightarrow \\theta \\) and \\( \\varphi \\vee \\psi \\). Instead of adding them directly as premises of the inference rule \\eqref{eq:def:minimal_propositional_natural_deduction_system/or/elim}, we replace the conditional \\( \\rightarrow \\) with labeled assumptions that correspond to \\( \\varphi \\vdash \\theta \\) and \\( \\psi \\vdash \\theta \\).\n\n  We can prove that \\eqref{eq:def:minimal_propositional_natural_deduction_system/or/elim} implies \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/or/elim} analogously to \\eqref{eq:def:minimal_propositional_natural_deduction_system/and_intro_axiom_derivation}.\n\n  The other two rules are again trivial to obtain from the corresponding axioms and vice versa.\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/iff} Analogous to what we have already shown.\n\n  \\SubProofOf{def:minimal_propositional_natural_deduction_system/negation} \\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/intro} is obtained from \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/neg/intro} by applying \\eqref{eq:def:def:axiomatic_deductive_system/mp} once and \\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/elim} is obtained from \\eqref{eq:def:minimal_propositional_axiomatic_deductive_system/neg/intro} by applying \\eqref{eq:def:def:axiomatic_deductive_system/mp} twice. Using the rules to derive the axioms is similar to \\eqref{eq:def:minimal_propositional_natural_deduction_system/and_intro_axiom_derivation}.\n\\end{defproof}\n\n\\begin{proposition}\\label{thm:conjunction_of_premises}\n  In deductive systems that extend the \\hyperref[def:minimal_propositional_natural_deduction_system]{minimal propositional natural deduction system}, we have \\( \\psi_1, \\psi_1 \\vdash \\varphi \\) if and only if \\( (\\psi_1 \\wedge \\psi_2) \\vdash \\varphi \\).\n\\end{proposition}\n\\begin{proof}\n  \\SufficiencySubProof If \\( \\psi_1, \\psi_2 \\vdash \\varphi \\), then\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\psi_1 \\wedge \\psi_2 }\n      \\infer1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/and/elim_right}]{ \\psi_1 }\n\n      \\hypo{ \\psi_1 \\wedge \\psi_2 }\n      \\infer1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/and/elim_right}]{ \\psi_2 }\n\n      \\infer2{}\n\n      \\ellipsis{}{ \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  \\NecessitySubProof If \\( (\\psi_1 \\wedge \\psi_2) \\vdash \\varphi \\), then\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\psi_1 }\n      \\hypo{ \\psi_2 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/and/intro}]{ \\psi_1 \\wedge \\psi_2 }\n      \\ellipsis{}{ \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\\end{proof}\n\n\\begin{theorem}\\label{thm:minimal_propositional_negation_laws}\n  Consider the following propositional formula schemas:\n  \\begin{thmenum}\n    \\thmitem{thm:minimal_propositional_negation_laws/dne} Double negation elimination:\n    \\begin{equation}\\label{eq:thm:minimal_propositional_negation_laws/dne}\n      \\neg \\neg \\varphi \\rightarrow \\varphi \\tag{AX DNE}.\n    \\end{equation}\n\n    The semantic counterpart to this law is \\fullref{thm:boolean_equivalences/double_negation}.\n\n    \\thmitem{thm:minimal_propositional_negation_laws/efq} \\term[en=from falsity everything follows]{Ex falso quodlibet}, also known as the \\term{principle of explosion}:\n    \\begin{equation}\\label{eq:thm:minimal_propositional_negation_laws/efq}\n      \\bot \\rightarrow \\varphi \\tag{AX EFQ}\n    \\end{equation}\n\n    \\thmitem{thm:minimal_propositional_negation_laws/pierce} \\term{Pierce's law}:\n    \\begin{equation}\\label{eq:thm:minimal_propositional_negation_laws/pierce}\n      ((\\varphi \\rightarrow \\psi) \\rightarrow \\varphi) \\rightarrow \\varphi \\tag{AX Pierce}\n    \\end{equation}\n\n    \\thmitem{thm:minimal_propositional_negation_laws/lem} The \\term{law of the excluded middle}:\n    \\begin{equation}\\label{eq:thm:minimal_propositional_negation_laws/lem}\n      \\varphi \\vee \\neg \\varphi \\tag{AX LEM}\n    \\end{equation}\n\n    \\thmitem{thm:minimal_propositional_negation_laws/lnc} The \\term{law of non-contradiction}:\n    \\begin{equation}\\label{eq:thm:minimal_propositional_negation_laws/lnc}\n      \\neg (\\varphi \\wedge \\neg \\varphi). \\tag{AX LNC}\n    \\end{equation}\n  \\end{thmenum}\n\n  Assuming the \\hyperref[def:minimal_propositional_axiomatic_deductive_system]{minimal propositional axiomatic deductive system}, we have the following derivations:\n  \\begin{center}\n    \\begin{forest}\n      [\n        {\\eqref{eq:thm:minimal_propositional_negation_laws/dne}}\n          [\n            {\\eqref{eq:thm:minimal_propositional_negation_laws/pierce}}\n              [{\\eqref{eq:thm:minimal_propositional_negation_laws/lem}}]\n          ]\n          [\n            {\\eqref{eq:thm:minimal_propositional_negation_laws/efq}}\n              [{\\eqref{eq:thm:minimal_propositional_negation_laws/lnc}}]\n          ]\n      ]\n    \\end{forest}\n  \\end{center}\n\n  As it turns out, \\eqref{eq:thm:minimal_propositional_negation_laws/lnc}, which is often associated with intuitionistic logic, is a theorem of \\hyperref[def:minimal_logic]{minimal logic}.\n\n  Conversely, \\eqref{eq:thm:minimal_propositional_negation_laws/efq} and \\eqref{eq:thm:minimal_propositional_negation_laws/lem} together can be used to derive \\eqref{eq:thm:minimal_propositional_negation_laws/dne}.\n\\end{theorem}\n\\begin{proof}\n  Most proofs are given in \\cite[prop. 3]{DienerMcKubreJordens2016} and \\cite[prop. 13]{DienerMcKubreJordens2016}. We will only show that \\eqref{eq:thm:minimal_propositional_negation_laws/lnc} is strictly weaker than \\eqref{eq:thm:minimal_propositional_negation_laws/efq}.\n\n  For any formula \\( \\varphi \\), we have the \\hyperref[def:minimal_propositional_natural_deduction_system]{natural deduction} proof that \\( \\eqref{eq:thm:minimal_propositional_negation_laws/lnc} \\) is a tautology:\n  \\begin{equation*}\n    \\begin{prooftree}[separation=3em]\n      \\hypo{ [\\varphi \\wedge \\neg \\varphi]^1 }\n      \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/elim_left}]{ \\varphi }\n\n      \\hypo{ [\\varphi \\wedge \\neg \\varphi]^1 }\n      \\infer1[\\ref{eq:def:minimal_propositional_natural_deduction_system/and/elim_right}]{ \\neg \\varphi }\n\n      \\infer2[\\ref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n\n      \\infer[left label=\\( 1 \\)]1[\\ref{eq:def:minimal_propositional_natural_deduction_system/neg/intro}]{ \\neg (\\varphi \\wedge \\neg \\varphi) }\n    \\end{prooftree}\n  \\end{equation*}\n\n  Hence, \\eqref{eq:thm:minimal_propositional_negation_laws/lnc} is a theorem of \\hyperref[def:minimal_logic]{minimal logic}. If it were to imply \\eqref{eq:thm:minimal_propositional_negation_laws/efq}, then minimal and intuitionistic logic would be equivalent, which would contradict \\cite[prop. 3]{DienerMcKubreJordens2016}. Therefore, \\eqref{eq:thm:minimal_propositional_negation_laws/lnc} is indeed strictly weaker than \\eqref{eq:thm:minimal_propositional_negation_laws/efq}.\n\\end{proof}\n\n\\begin{proposition}\\label{thm:syntactic_contraposition}\n  In the \\hyperref[def:minimal_propositional_natural_deduction_system]{minimal propositional natural deduction system}, we have\n  \\begin{align}\n    \\varphi \\rightarrow \\psi &\\vdash \\neg \\psi \\rightarrow \\neg \\varphi \\label{eq:thm:syntactic_contraposition/straight} \\\\\n    \\eqref{eq:thm:minimal_propositional_negation_laws/dne}, \\neg \\varphi \\rightarrow \\neg \\psi &\\vdash \\psi \\rightarrow \\varphi \\label{eq:thm:syntactic_contraposition/reverse}\n  \\end{align}\n\\end{proposition}\n\\begin{proof}\n  We will only prove \\eqref{eq:thm:syntactic_contraposition/straight}. The derivability \\eqref{eq:thm:syntactic_contraposition/reverse} can be proved in the same way except that we would use \\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/intro} rather than \\eqref{eq:def:classical_propositional_deductive_systems/rules/dne}.\n\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\varphi \\rightarrow \\psi }\n      \\hypo{ [\\varphi]^1 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/elim}]{ \\psi }\n\n      \\hypo{ [\\neg \\psi]^2 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n\n      \\infer[left label=\\( 1 \\)]1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/intro}]{ \\neg \\varphi }\n      \\infer[left label=\\( 2 \\)]1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/imp/intro}]{ \\neg \\psi \\rightarrow \\neg \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\\end{proof}\n\n\\begin{definition}\\label{def:intuitionistic_propositional_deductive_systems}\\mcite[def. 55.10]{OpenLogicFull}\n  The \\term{intuitionistic propositional natural deduction system} extends the \\hyperref[def:minimal_propositional_natural_deduction_system]{minimal propositional natural deduction system} with the rule\n  \\begin{equation*}\\taglabel[\\textrm{EFQ}]{eq:def:intuitionistic_propositional_deductive_systems/rules/efq}\n    \\begin{prooftree}\n      \\hypo{ \\bot }\n      \\infer1[\\ref{eq:def:intuitionistic_propositional_deductive_systems/rules/efq}]{ \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  This corresponds to the axiom \\eqref{eq:thm:minimal_propositional_negation_laws/efq}, which we can add to the \\hyperref[def:minimal_propositional_axiomatic_deductive_system]{minimal propositional axiomatic deductive system}.\n\n  The corresponding semantics are defined in \\fullref{def:propositional_heyting_algebra_semantics} and their link with the deductive system is given in \\fullref{thm:intuitionistic_propositional_logic_is_sound_and_complete}.\n\\end{definition}\n\n\\begin{definition}\\label{def:propositional_heyting_algebra_semantics}\\mcite[14]{BezhanishviliHolliday2019}\n  We define \\term{Heyting semantics} for propositional formulas similarly to how it is done with classical Boolean semantics in \\fullref{def:propositional_semantics}, except that instead of using a \\hyperref[def:boolean_algebra]{Boolean algebra} we use a more general \\hyperref[def:heyting_algebra]{Heyting algebra}.\n\n  Logical negations depend on complements in Boolean algebras. Since Heyting algebras do not have complements, we instead use \\hyperref[def:heyting_algebra/pseudocomplement]{pseudocomplements}.\n\n  Fix a Heyting algebra \\( \\mscrH = (H, \\sup, \\inf, T, F, \\rightarrow) \\). \\hyperref[def:propositional_valuation/interpretation]{Propositional interpretations} in Heyting semantics may take any value in \\( X \\), as can \\hyperref[def:propositional_valuation/formula_valuation]{formula valuations}.\n\n  Given an interpretation \\( I \\) and a formula \\( \\varphi \\), we define \\( \\varphi\\Bracks{I} \\) via \\eqref{eq:def:propositional_valuation/formula_interpretation}, the sole difference being that negation valuation is defined via the pseudocomplement:\n  \\begin{equation*}\n    (\\neg \\psi)\\Bracks{I} \\coloneqq \\widetilde{\\varphi\\Bracks{I}}.\n  \\end{equation*}\n\n  We say that \\( I \\) satisfies \\( \\varphi \\) if \\( \\varphi\\Bracks{I} = T \\). Thus, if the valuation of \\( \\varphi \\) takes any value in \\( H \\setminus \\set{ T } \\), then \\( I \\) does not satisfy \\( \\varphi \\), but that does not necessarily mean that \\( I \\) satisfies \\( \\neg \\varphi \\).\n\n  Then \\( \\Gamma \\) entails \\( \\varphi \\) if, for every \\( \\psi \\in \\Gamma \\) and every interpretation \\( I \\) in every Heyting algebra, we have \\( \\varphi\\Bracks{I} = \\psi\\Bracks{I} \\).\n\n  It is important that different Heyting algebras may provide different semantics --- see \\fullref{ex:heyting_semantics_lem_counterexample} for an example of what is impossible in a Boolean algebra.\n\\end{definition}\n\n\\begin{example}\\label{ex:heyting_semantics_lem_counterexample}\n  Let \\( \\mscrX \\) be an extension of the trivial Boolean algebra \\( \\set{ T, F } \\) with the \\enquote{indeterminate} symbol \\( N \\). That is, the domain of \\( \\mscrX \\) is \\( \\set{ F, N, T } \\) and the order is \\( F \\leq N \\leq T \\).\n\n  The pseudocomplement of \\( N \\) is\n  \\begin{equation*}\n    \\widetilde{N}\n    \\reloset {\\eqref{eq:def:heyting_algebra/pseudocomplement}} =\n    \\sup\\set{ a \\in X \\given a \\wedge N = \\bot }\n    =\n    F.\n  \\end{equation*}\n\n  Consider any \\hyperref[def:propositional_valuation]{propositional interpretation} \\( I \\) such that \\( I(P) = N \\).\n\n  Then the valuation of \\eqref{eq:thm:minimal_propositional_negation_laws/lem} is\n  \\begin{equation*}\n    (P \\vee \\neg P)\\Bracks{I}\n    =\n    \\sup\\set{ P\\Bracks{I}, \\widetilde{P\\Bracks{I}} }\n    =\n    \\sup\\set{ N, \\widetilde{N} }\n    =\n    \\sup\\set{ N, F }\n    =\n    N.\n  \\end{equation*}\n\n  Therefore, \\eqref{eq:thm:minimal_propositional_negation_laws/lem} does not hold.\n\\end{example}\n\n\\begin{theorem}\\label{thm:intuitionistic_propositional_logic_is_sound_and_complete}\\mcite[11]{BezhanishviliHolliday2019}\n  The \\hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic propositional deductive system} is \\hyperref[def:derivability_and_satisfiability/soundness]{sound} and \\hyperref[def:derivability_and_satisfiability/completeness]{complete} with respect to \\hyperref[def:propositional_heyting_algebra_semantics]{Heyting semantics}. To elaborate,\n  \\begin{thmenum}\n    \\thmitem{thm:intuitionistic_propositional_logic_is_sound_and_complete/sound} If \\( \\vdash \\varphi \\), then \\( \\vDash \\varphi \\) for every Heyting algebra.\n    \\thmitem{thm:intuitionistic_propositional_logic_is_sound_and_complete/complete} If \\( \\vDash \\varphi \\) in every Heyting algebra, then \\( \\vdash \\varphi \\).\n  \\end{thmenum}\n\\end{theorem}\n\n\\begin{definition}\\label{def:propositional_topological_semantics}\\mcite[15]{BezhanishviliHolliday2019}\n  Since arbitrary \\hyperref[def:heyting_algebra]{Heyting algebras} can be cumbersome to come up with when used for \\hyperref[def:propositional_heyting_algebra_semantics]{propositional Heyting semantics}, we can instead utilize \\fullref{ex:topological_space_is_heyting_algebra} and define \\term{topological semantics} for some nonempty \\hyperref[def:topological_space]{topological space}.\n\n  The truth values of interpretations and valuations are then open sets in some topological space and a formula is said to be valid if its valuation is the whole space.\n\\end{definition}\n\n\\begin{example}\\label{ex:topological_semantics_lem_counterexample}\n  Let \\( U \\) be an open set in the standard topology in \\( \\BbbR \\). We will examine \\eqref{eq:thm:minimal_propositional_negation_laws/lem} with respect to \\hyperref[def:propositional_topological_semantics]{topological semantics} for \\( \\BbbR \\). Due to \\fullref{ex:topological_space_is_heyting_algebra}, given any \\hyperref[def:propositional_valuation]{propositional interpretation} \\( I \\) such that \\( I(P) = U \\), we have\n  \\begin{equation*}\n    (P \\vee \\neg P)\\Bracks{I}\n    =\n    P\\Bracks{I} \\cup \\widetilde{P\\Bracks{I}}\n    =\n    U \\cup \\widetilde{U}\n    =\n    U \\cup \\Int(\\BbbR \\setminus U).\n  \\end{equation*}\n\n  If \\( U = \\varnothing \\), then \\( (P \\vee \\neg P)\\Bracks{I} = \\BbbR \\) and \\eqref{eq:thm:minimal_propositional_negation_laws/lem} holds. If \\( U = (0, 1) \\), then \\( (P \\vee \\neg P)\\Bracks{I} = \\BbbR \\setminus \\set{ 0, 1 } \\) and \\eqref{eq:thm:minimal_propositional_negation_laws/lem} does not hold.\n\n  Compare this result with \\fullref{ex:heyting_semantics_lem_counterexample}.\n\\end{example}\n\n\\begin{definition}\\label{def:brouwer_heyting_kolmogorov_interpretation}\\mcite[sec. 55.3]{OpenLogicFull}\n  Another semantics for the \\hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic propositional deductive system} is the \\term{Brouwer-Heyting-Kolmogorov interpretation}.\n\n  It uses a less formal approach than \\hyperref[def:propositional_heyting_algebra_semantics]{Heyting algebra semantics} that is based on the notion of a \\enquote{construction}, which is also why it is sometimes called \\term{constructive logic}.\n\n  \\begin{thmenum}\n    \\thmitem{def:brouwer_heyting_kolmogorov_interpretation/atomic} We assume that we know what constitutes a construction of propositional variables.\n    \\thmitem{def:brouwer_heyting_kolmogorov_interpretation/constant} There is no construction of \\( \\bot \\) and no construction of \\( \\top \\) is needed.\n    \\thmitem{def:brouwer_heyting_kolmogorov_interpretation/disjunction} A construction of \\( \\psi_1 \\vee \\psi_2 \\) is a pair \\( (k, M) \\), where \\( k = 1, 2 \\) and \\( M \\) is a construction of \\( \\psi_m \\) if and only if \\( k = m \\). The notion of a pair here is informal.\n    \\thmitem{def:brouwer_heyting_kolmogorov_interpretation/conjunction} A construction of \\( \\psi_1 \\wedge \\psi_2 \\) is a pair \\( (M_1, M_2) \\), where \\( M_k \\) is a construction of \\( \\psi_k \\) for \\( k = 1, 2 \\).\n    \\thmitem{def:brouwer_heyting_kolmogorov_interpretation/conditional} A construction of \\( \\psi_1 \\rightarrow \\psi_2 \\) is a function that converts a construction of \\( \\psi_1 \\) into a construction of \\( \\psi_2 \\). The notion of a function here is informal.\n  \\end{thmenum}\n\n  The negation \\( \\neg\\psi \\) that corresponds to pseudocomplements in Heyting algebra semantics corresponds to the metastatement \\enquote{a construction of \\( \\psi \\) is impossible} under the Heyting-Brouwer-Kolmogorov interpretation.\n\n  If the set \\( \\Gamma \\) of formulas does not derive \\( \\varphi \\), we say that \\( \\varphi \\) is non-constructive under the axioms \\( \\Gamma \\).\n\\end{definition}\n\n\\begin{remark}\\label{rem:brouwer_heyting_kolmogorov_interpretation_compatibility}\n  Since the \\hyperref[def:brouwer_heyting_kolmogorov_interpretation]{Heyting-Brouwer-Kolmogorov interpretation} is not very formal, we cannot properly prove its, soundness or completeness with respect to the \\hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic propositional deductive system}.\n\n  Nevertheless, we generally accept the interpretation and conflate \\enquote{constructive} and \\enquote{intuitionistic} statements.\n\\end{remark}\n\n\\begin{example}\\label{ex:def:brouwer_heyting_kolmogorov_interpretation/well_ordering_principle_zfc}\n  \\Fullref{thm:well_ordering_theorem} in \\hyperref[def:set]{\\logic{ZFC}} does not provide a way to well-order an arbitrary set. The theorem relies on the axiom of choice, whose consequence \\fullref{thm:diaconescu_goodman_myhill_theorem} implies the law of the excluded middle (LEM) assuming the nonlogical axioms of \\logic{ZFC}.\n\n  Since LEM may not hold in intuitionistic logic, it follows that both \\fullref{thm:well_ordering_theorem} and the axiom of choice itself should not in general hold under the Heyting-Brouwer-Kolmogorov interpretation, hence by the terminology in \\fullref{def:brouwer_heyting_kolmogorov_interpretation}, \\fullref{thm:well_ordering_theorem} is a non-constructive theorem.\n\\end{example}\n\n\\begin{definition}\\label{def:classical_propositional_deductive_systems}\n  In order to obtain a deductive system that matches \\hyperref[def:propositional_semantics]{classical propositional semantics}, we may extend the \\hyperref[def:minimal_propositional_natural_deduction_system]{minimal propositional natural deduction system} with the rule\n  \\begin{equation*}\\taglabel[\\textrm{DNE}]{eq:def:classical_propositional_deductive_systems/rules/dne}\n    \\begin{prooftree}\n      \\hypo{ [\\neg \\varphi]^n }\n      \\ellipsis {} { \\bot }\n      \\infer[left label=\\( n \\)]1[\\ref{eq:def:classical_propositional_deductive_systems/rules/dne}]{ \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  This corresponds to the axiom \\eqref{eq:thm:minimal_propositional_negation_laws/dne}, which we can add to the \\hyperref[def:minimal_propositional_axiomatic_deductive_system]{minimal propositional axiomatic deductive system}. As per \\fullref{thm:minimal_propositional_negation_laws}, we can instead add \\eqref{eq:thm:minimal_propositional_negation_laws/lem} to the \\hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic propositional axiomatic deductive system}, since\n  \\begin{equation*}\n    \\eqref{eq:thm:minimal_propositional_negation_laws/lem}, \\eqref{eq:thm:minimal_propositional_negation_laws/efq} \\vdash \\eqref{eq:thm:minimal_propositional_negation_laws/dne}\n  \\end{equation*}\n\n  We call this, very simply, the (classical) \\term{propositional deductive system}.\n\\end{definition}\n\n\\begin{theorem}[Glivenko's double negation theorem]\\label{thm:glivenkos_double_negation_theorem}\\mcite{Franks2018}\n  A formula \\( \\varphi \\) is derivable in the \\hyperref[def:classical_propositional_deductive_systems]{classical propositional natural deduction system} if and only if it's double negation \\( \\neg \\neg \\varphi \\) is derivable in the \\hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic propositional natural deduction system}.\n\\end{theorem}\n\n\\begin{theorem}\\label{thm:classical_propositional_logic_is_sound_and_complete}\\mcite[thm. 12.30 \\\\ corr. 13.7]{OpenLogicFull}\n  The \\hyperref[def:classical_propositional_deductive_systems]{classical propositional natural deduction system} is \\hyperref[def:derivability_and_satisfiability/soundness]{sound} and \\hyperref[def:derivability_and_satisfiability/completeness]{complete} with respect to \\hyperref[def:propositional_semantics]{classical semantics}.\n\\end{theorem}\n\n\\medskip\n\n\\begin{definition}\\label{def:first_order_natural_deduction_system}\\mcite{LeanNaturalDeduction}\n  If we wish to work with first-order logic rather than merely propositional logic, we must extend the \\hyperref[def:classical_propositional_deductive_systems]{classical propositional natural deduction system}. We call this, very simply, the (classical) \\term{first-order natural deduction system}.\n\n  \\begin{thmenum}\n    \\thmitem{def:first_order_natural_deduction_system/eigenvariables} We first add the following two \\hyperref[def:judgment/inference_rule]{inference rules} for quantification:\n\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\forall^+ \\)]{eq:def:first_order_natural_deduction_system/forall/intro}\n        \\begin{prooftree}\n          \\hypo{ \\varphi }\n          \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/intro}]{ \\qforall \\xi \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\exists^- \\)]{eq:def:first_order_natural_deduction_system/exists/elim}\n        \\begin{prooftree}\n          \\hypo{ \\qexists \\xi \\varphi }\n          \\hypo{ [\\varphi]^n }\n          \\ellipsis {} { \\psi }\n          \\infer[left label=\\( n \\)]2[\\ref{eq:def:first_order_natural_deduction_system/exists/elim}]{ \\psi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    Here \\( \\xi \\) is a variable that is not free in any undischarged assumption in the proof of \\( \\varphi \\) (it may be free in \\( \\varphi \\) as long as \\( \\varphi \\) is not itself an undischarged assumption). A variable \\( \\xi \\) satisfying these conditions is called an \\term{eigenvariable} of the rule.\n\n    These rules are the primary motivation for inference rules accepting proof trees rather than only formulas --- see \\fullref{def:judgment/inference_rule} and \\fullref{def:deductive_system/rule}. See \\fullref{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_universal} for why this condition is important.\n\n    \\thmitem{def:first_order_natural_deduction_system/terms} We add two \\hyperref[def:judgment/inference_rule]{inference rules}, where \\( \\tau \\) is an arbitrary term:\n\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\forall^- \\)]{eq:def:first_order_natural_deduction_system/forall/elim}\n        \\begin{prooftree}\n          \\hypo{ \\qforall \\xi \\varphi }\n          \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/elim}]{ \\varphi[\\xi \\mapsto \\tau] }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.45\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\exists^+ \\)]{eq:def:first_order_natural_deduction_system/exists/intro}\n        \\begin{prooftree}\n          \\hypo{ \\varphi[\\xi \\mapsto \\tau] }\n          \\infer1[\\ref{eq:def:first_order_natural_deduction_system/exists/intro}]{ \\qexists \\xi \\varphi }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n\n    Compare this to \\fullref{thm:quantifier_satisfiability}.\n\n    \\thmitem{def:first_order_natural_deduction_system/equality} Finally, we also add three rules for formal equality:\n\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\doteq^+ \\)]{eq:def:first_order_natural_deduction_system/equality/intro}\n        \\begin{prooftree}\n          \\infer0[\\ref{eq:def:first_order_natural_deduction_system/equality/intro}]{ \\tau \\doteq \\tau }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\doteq_L^- \\)]{eq:def:first_order_natural_deduction_system/equality/elim_left}\n        \\begin{prooftree}\n          \\hypo{ \\tau \\doteq \\sigma }\n          \\hypo{ \\varphi[\\xi \\mapsto \\tau] }\n          \\infer2[\\ref{eq:def:first_order_natural_deduction_system/equality/elim_left}]{ \\varphi[\\xi \\mapsto \\sigma] }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}{0.3\\textwidth}\n      \\begin{equation*}\\taglabel[\\( \\doteq_L^+ \\)]{eq:def:first_order_natural_deduction_system/equality/elim_right}\n        \\begin{prooftree}\n          \\hypo{ \\tau \\doteq \\sigma }\n          \\hypo{ \\varphi[\\xi \\mapsto \\sigma] }\n          \\infer2[\\ref{eq:def:first_order_natural_deduction_system/equality/elim_right}]{ \\varphi[\\xi \\mapsto \\tau] }\n        \\end{prooftree}\n      \\end{equation*}\n    \\end{minipage}\n  \\end{thmenum}\n\\end{definition}\n\n\\begin{example}\\label{ex:def:first_order_natural_deduction_system/eigenvariables}\n  \\hfill\n  \\begin{thmenum}\n    \\thmitem{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_universal_closure} We explicitly forbid the syntactic equivalent of \\fullref{thm:implicit_universal_quantification} in order to avoid invalid proofs like \\fullref{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_universal}. Consider the proof\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ [\\varphi]^1 }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/intro}]{ \\qforall \\xi \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    The problem here is that \\( \\varphi \\) is itself an undischarged assumption, hence \\eqref{eq:def:first_order_natural_deduction_system/forall/intro} is actually inapplicable here, and the proof is invalid.\n\n    \\thmitem{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_universal}\\mcite[sec. 20.3]{OpenLogicFull} To see why the eigenvariable conditions in \\fullref{def:first_order_natural_deduction_system/eigenvariables} are essential, consider the following proof of \\( \\qforall \\xi \\varphi \\) from \\( \\qexists \\xi \\varphi \\):\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\qexists \\xi \\varphi }\n\n        \\hypo{ [\\varphi]^1 }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/intro}]{ \\qforall \\xi \\varphi }\n\n        \\infer[left label=\\( 1 \\)]2[\\ref{eq:def:first_order_natural_deduction_system/exists/elim}]{ \\qforall \\xi \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    This proof relies on \\fullref{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_universal_closure}, which we have already demonstrated to be invalid.\n\n    \\thmitem{ex:def:first_order_natural_deduction_system/eigenvariables/invalid_existence} Another invalid proof, in case \\( \\xi \\in \\boldop{Free}(\\varphi) \\), is\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\qexists \\xi \\varphi }\n\n        \\hypo{ [\\varphi]^1 }\n        \\infer1{ \\varphi }\n\n        \\infer[left label=\\( 1 \\)]2[\\ref{eq:def:first_order_natural_deduction_system/exists/elim}]{ \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    \\thmitem{ex:def:first_order_natural_deduction_system/eigenvariables/universal_implies_existence} On the other hand, \\( \\qexists \\xi \\varphi \\) can easily be derived from \\( \\qforall \\xi \\varphi \\):\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\qforall \\xi \\varphi }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/elim}]{ \\varphi = \\varphi[\\xi \\mapsto \\xi] }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/exists/intro}]{ \\qexists \\xi \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n\n    \\thmitem{ex:def:first_order_natural_deduction_system/eigenvariables/universal_implies_universal} It is also valid to perform the completely meaningless derivation:\n    \\begin{equation*}\n      \\begin{prooftree}\n        \\hypo{ \\qforall \\xi \\varphi }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/elim}]{ \\varphi = \\varphi[\\xi \\mapsto \\xi] }\n        \\infer1[\\ref{eq:def:first_order_natural_deduction_system/forall/intro}]{ \\qforall \\xi \\varphi }\n      \\end{prooftree}\n    \\end{equation*}\n  \\end{thmenum}\n\\end{example}\n\n\\begin{proposition}\\label{thm:syntactic_first_order_quantifiers_are_dual}\n  For any formula \\( \\varphi \\) and any variable \\( \\xi \\) over \\( \\mscrL \\), we have the following interderivable pairs:\n  \\begin{align}\n    \\neg \\qforall \\xi \\varphi &\\T{and} \\qexists \\xi \\neg \\varphi \\label{thm:syntactic_first_order_quantifiers_are_dual/negation_of_universal} \\\\\n    \\neg \\qexists \\xi \\varphi &\\T{and} \\qforall \\xi \\neg \\varphi \\label{thm:syntactic_first_order_quantifiers_are_dual/negation_of_existential}\n  \\end{align}\n\\end{proposition}\n\\begin{proof}\n  We will only show \\eqref{thm:syntactic_first_order_quantifiers_are_dual/negation_of_universal}. First,\n\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\neg \\qforall \\xi \\varphi }\n      \\hypo{ [\\qforall \\xi \\varphi]^1 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n      \\infer[left label=\\( 1 \\)]1[\\eqref{eq:def:classical_propositional_deductive_systems/rules/dne}]{ \\qforall \\xi \\varphi }\n      \\infer1[\\eqref{eq:def:first_order_natural_deduction_system/forall/elim}]{ \\varphi }\n\n      \\hypo{ [\\neg \\varphi]^2 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n\n      \\infer[left label=\\( 2 \\)]1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/intro}]{ \\neg \\varphi }\n      \\infer1[\\eqref{eq:def:first_order_natural_deduction_system/exists/intro}]{ \\qexists \\xi \\neg \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\n  Conversely,\n  \\begin{equation*}\n    \\begin{prooftree}\n      \\hypo{ \\qexists \\xi \\neg \\varphi }\n\n      \\hypo{ [\\qforall \\xi \\varphi]^1 }\n      \\infer1[\\eqref{eq:def:first_order_natural_deduction_system/forall/elim}]{ \\varphi }\n\n      \\hypo{ [\\neg \\varphi]^2 }\n      \\infer2[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/elim}]{ \\bot }\n      \\infer[left label=\\( 1 \\)]1[\\eqref{eq:def:minimal_propositional_natural_deduction_system/neg/intro}]{ \\neg \\qforall \\xi \\varphi }\n\n      \\infer[left label=\\( 2 \\)]2[\\eqref{eq:def:first_order_natural_deduction_system/exists/elim}]{ \\neg \\qforall \\xi \\varphi }\n    \\end{prooftree}\n  \\end{equation*}\n\\end{proof}\n\n\\begin{theorem}\\label{thm:classical_first_order_logic_is_sound_and_complete}\\mcite[thm. 20.32 \\\\ corr. 23.19]{OpenLogicFull}\n  The \\hyperref[def:first_order_natural_deduction_system]{classical first-order natural deduction system} is \\hyperref[def:derivability_and_satisfiability/soundness]{sound} and \\hyperref[def:derivability_and_satisfiability/completeness]{complete} with respect to \\hyperref[def:first_order_semantics]{classical semantics}.\n\n  The completeness part is known as \\enquote{G\\\"odel's completeness theorem} and requires an elaborate proof.\n\\end{theorem}\n", "meta": {"hexsha": "36df15f07412a8259b28e9f934c07176fd39f001", "size": 71463, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/deductive_systems.tex", "max_stars_repo_name": "v--/anthology", "max_stars_repo_head_hexsha": "89a91b5182f187bc1aa37a2054762dd0078a7b56", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/deductive_systems.tex", "max_issues_repo_name": "v--/anthology", "max_issues_repo_head_hexsha": "89a91b5182f187bc1aa37a2054762dd0078a7b56", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/deductive_systems.tex", "max_forks_repo_name": "v--/anthology", "max_forks_repo_head_hexsha": "89a91b5182f187bc1aa37a2054762dd0078a7b56", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.9129213483, "max_line_length": 678, "alphanum_fraction": 0.7351496579, "num_tokens": 21376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6513548578981939, "lm_q1q2_score": 0.42886343751603906}}
{"text": "%\n% set up May 2013\n%\n\\chapter{SCF Convergence Algorithms}\n\nHow to find a set of MO ($\\varphi_{1}$, $\\varphi_{2}$, $\\cdots$ $\\varphi_{n}$) which optimize\nthe energy functional in the self-consistent field calculation? This chapter discuss all kinds\nof algorithms and techniques related to this question.\n\n\\section{Direct Energy Minimization Method}\n%\n%\n%\nThe direction energy minimization method\\cite{DM_SCF} is an old SCF convergence method. Comparing\nwith many more advanced algorithms like DIIS etc. it's less efficient, however the theory itself\nis instructive and could enlighten other theories like GDM\\cite{gdm}.\n\n\\subsection{Pseudocanonical Transformation}\n\\label{pseudocanonical_dm_scf}\n%\n%\n%\nThe canonical orbitals are the the molecular orbitals which diagonalizes the Fock matrix:\n\\begin{equation}\\label{DM_SCF_eq:1}\n C^{+}FC = I\n\\end{equation}\nwhere $I$ is a diagonal matrix.\nThrough the HF equation\n\\begin{equation}\\label{DM_SCF_eq:2}\n FC = SCE\n\\end{equation}\nit's known that the eigenvector $C$ forms the canonical orbitals because the orthogonality\non the MO: $C^{+}SC = I$.\n\nPseudocanonical orbitals, on the other hand; is to diagonalize the block of Fock matrix\nin terms of $F_{oo}$ and $F_{vv}$:\n\\begin{equation}\\label{DM_SCF_eq:3}\n F^{'} = \n\\begin{pmatrix}\n Q_{1}^{+}  &  0  \\\\\n 0          &  Q_{2}^{+}\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n F_{oo}  &  F_{ov}  \\\\\n F_{vo}  &  F_{vv}  \\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n Q_{1}    &  0  \\\\\n 0        &  Q_{2}\\\\\n\\end{pmatrix}\n\\end{equation}\nBecause the Fock matrix is symmetric, $F_{ov} = F_{vo}^{+}$ hence it has:\n\\begin{equation}\\label{DM_SCF_eq:4}\n F^{'} = \n \\begin{pmatrix}\n \\epsilon_{1}    &  A^{+}    \\\\\n A               &  \\epsilon_{2}\\\\\n\\end{pmatrix}\n\\end{equation}\nwhere $A = Q_{2}^{+}F_{vo}Q_{1}$, $\\epsilon_{1} = Q_{1}^{+}F_{oo}Q_{1}$ etc.\n$Q_{1}$ and $Q_{2}$ are pseudocanonical orbitals, on the other hand; they\nalso form pseudocanonical transformation to the Fock matrix.\n\nThe pseudocanonical transformation on MO is given as:\n\\begin{equation}\\label{DM_SCF_eq:100}\n \\begin{pmatrix}\n  c_{1} & c_{2} & \\cdots  & c_{n}\n \\end{pmatrix}\n= \n \\begin{pmatrix}\n  c_{1} & c_{2} & \\cdots  & c_{n}\n \\end{pmatrix}\n\\begin{pmatrix}\n Q_{1}    &  0  \\\\\n 0        &  Q_{2}\\\\\n\\end{pmatrix}\n\\end{equation}\nThe transformation here, is between oo and vv blocks itself. Therefore it expects\nthat the transformation will not change the energy.\n\nHow to evaluate the pseudocanonical orbitals? As iteratively solving the Fock\nmatrix when the result MO is getting close to the minimum one, it could be \nwell expected that the block $A$ should become very small and the $\\epsilon_{1}$\nand $\\epsilon_{2}$ blocks should approach to the final MO energy. Therefore,\nthe block $A$ could be used as reference to guide the SCF convergence process.\nThis is the starting point for direct energy minimization method.\n\n\\subsection{Direct Minimization Method}\n%\n%\n%\nThe direct minimization method starts with the pseudocanonical form of \nFock matrix:\n\\begin{equation}\\label{DM_SCF_eq:5}\n F^{'} = \n \\begin{pmatrix}\n \\epsilon_{1}    &  0    \\\\\n 0               &  \\epsilon_{2}\\\\\n\\end{pmatrix}\n+\n \\begin{pmatrix}\n 0    &  A^{+}    \\\\\n A    &  0        \\\\\n\\end{pmatrix}\n\\end{equation}\n\nIf we add additional $\\lambda$ to the $F^{'}$ so that\n\\begin{equation}\\label{DM_SCF_eq:6}\n F^{'}(\\lambda) = \n \\begin{pmatrix}\n \\epsilon_{1}    &  0    \\\\\n 0               &  \\epsilon_{2}\\\\\n\\end{pmatrix}\n+ \\lambda\n \\begin{pmatrix}\n 0    &  A^{+}    \\\\\n A    &  0        \\\\\n\\end{pmatrix}\n\\end{equation}\nas $\\lambda = 0$ $F^{'}(\\lambda)$ drops the occupy-virtual blocks, and $\\lambda = 1$\nmakes $F^{'}(\\lambda)$ become $F$ with pseudocanonical transformation. From the discussion\nin \\ref{pseudocanonical_dm_scf}, the SCF convergence procedure could be viewed as a process\nto reduce the occupy-virtual block of $A$. Therefore it's able to view the $A$ as some \nperturbation to the MO, so that we are able to construct some unitary transformation matrix\nbased on $A$. Suggest that the perturbed MO can be expressed as:\n\\begin{equation}\\label{DM_SCF_eq:7}\n \\psi_{i}^{'} = \\psi_{i}^{p} + \\sum^{vir}_{a}\\psi_{a}^{p}D_{ai}\n\\end{equation}\nThe superscript ``p'' on the MO means that these orbitals are with pseudocanonical transformation.\nBecause the pseudocanonical transformation does not alter the energy, it's possible to choose\nthe MO set with pseudocanonical transformation. The reason to choose such specific set will \nbe unveiled in the later content. We use $a$, $b$, $c$ etc. to express the virtual orbitals, \nand $i$, $j$, $k$ etc. to express the occupied orbitals. $D_{ai}$ denotes the perturbation \ncoefficients for the occupied orbitals when the virtual ones is involved. Next we need to\nknow how to choose the form of $D_{ai}$. \n\nIn considering the perturbation theory, the $D_{ai}$ is suggested to be:\n\\begin{equation}\\label{DM_SCF_eq:8}\n D_{ai} = -\\lambda A_{ai}(\\epsilon_{a} - \\epsilon_{i})^{-1}\n\\end{equation}\nTherefore the perturbation to the MO is fixed. Considering the total energy expression for \nSCF:\n\\begin{align}\\label{DM_SCF_eq:9}\n E &= \\sum_{i}\\langle\\psi_{i}^{'}|H_{0}|\\psi_{i}^{'}\\rangle  \n    + \\frac{1}{2}\\sum_{i}\\sum_{j}\n\\biggl(\\langle\\psi_{i}^{'}(1)\\psi_{i}^{'}(1)|1/r_{12}|\\psi_{j}^{'}(2)\\psi_{j}^{'}(2)\\rangle\n\\nonumber \\\\\n   &- \n       \\langle\\psi_{i}^{'}(1)\\psi_{j}^{'}(1)|1/r_{12}|\\psi_{i}^{'}(2)\\psi_{j}^{'}(2)\\rangle\\biggr)\n\\end{align}\n\nIf bringing the \\ref{DM_SCF_eq:7} and \\ref{DM_SCF_eq:8} into the \\ref{DM_SCF_eq:9} and only\ntaking the first order perturbation term; then it's able to see that the energy change is:\n\\begin{equation}\\label{DM_SCF_eq:10}\n \\delta E = \\sum_{i}^{occ}\\sum_{a}^{vir}(A_{ai}^{*}D_{ai} + D_{ai}^{*}A_{ai})\n\\end{equation}\nThis is the expression 30 in the paper \\cite{DM_SCF}. By taking the $D$ as real number,\nthe first order energy change is:\n\\begin{align}\\label{DM_SCF_eq:11}\n \\delta E &= 2\\sum_{i}^{occ}\\sum_{a}^{vir}A_{ai}D_{ai} \\rightarrow     \\nonumber \\\\\n  \\frac{d \\delta E}{d \\lambda}  &=\n  -2\\sum_{i}^{occ}\\sum_{a}A^{2}_{ai}(\\epsilon_{a} - \\epsilon_{i})^{-1}\n\\end{align}\nThe derivatives is always negative, therefore it grantees that when searching the MO change \nin terms of minimum of $\\lambda$, the energy is going down. The \\ref{DM_SCF_eq:11} also \nexplains that why we starts from the MO with pseudocanonical transformation (so that $A_{ai}$ \nappears as square).\n\nIn practical application, paper \\cite{DM_SCF} suggests a more general form considering $D_{ai}$:\n\\begin{equation}\\label{DM_SCF_eq:12}\n D_{ai} = -\\lambda A_{ai}(\\epsilon_{a} - \\epsilon_{i})^{-1}\n (\\epsilon_{a} - \\epsilon_{i})^{q}/\\vartriangle^{q}\n\\end{equation}\nwhere \n\\begin{equation}\\label{DM_SCF_eq:13}\n \\vartriangle^{q} = (M(N-M))^{-1}\\sum^{occ}_{i}\\sum^{vir}_{a}(\\epsilon_{a} - \\epsilon_{i})^{q}\n\\end{equation}\n$M$ is the number of occupied orbitals and $N-M$ is the number of virtual orbitals.\n$\\vartriangle^{q}$ is used as weighted mean energy difference so that to make $D_{ai}$\nas in same dimension as $A_{ai}$ in the form of \\ref{DM_SCF_eq:12}. The value of $q$\nis chosen to optimize the SCF convergence.\n \nBy setting the value of $q$, it's able to derive the perturbation of $D_{ai}$ in expression\n\\ref{DM_SCF_eq:12} as a function of $\\lambda$. Then in turn it's able to derive the total\nenergy $E(\\lambda)$ so that by differentiating:\n\\begin{equation}\n \\frac{\\partial  E(\\lambda)}{\\partial \\lambda} = 0\n\\end{equation}\nit's able to derive the $\\lambda_{min}$ and then fix the perturbation $D_{ai}$.\n\nThe expression for \\ref{DM_SCF_eq:7} and \\ref{DM_SCF_eq:8} are in fact general. It's able to \ndefine $D_{ai}$ independent of $A_{ai}$, and make it into generalized form:\n\\begin{equation}\\label{DM_SCF_eq:14}\n D_{ai} = \\alpha_{ai}X_{ai}\n\\end{equation}\n$X$ represents some general coordinate system(based on $i$ and $a$) and $\\alpha$ is corresponding \ncoefficients.\n\nThe direct minimization method right now is rarely used in popular modern quantum chemistry\npackage. From the derivation of the theory, it could be expected that it's only when $A$ is \nvery small in \\ref{DM_SCF_eq:4}, that the perturbation could be well performed. Therefore\nthe method may only be well applied to when SCF process is close to minimum. On the other \nhand, the convergence is not as efficient as DIIS method etc. However, the derivation here \nmay serve to enlighten the following algorithms which is constructed based on direct \nminimization method.\n\n\\section{Geometric Direct Minimization Method}\n%\n%\n%\nThe GDM(Geometric Direct Minimization) method is described in paper \\cite{gdm,gdm_fock}. The more\nfundamental base for GDM method comes from the geometric study of matrix under orthogonal \nconstraint\\cite{doi:10.1137/S0895479895290954}.\n\n\\subsection{SCF Optimization Based on Unitary Transformation}\n%\n%\n%\nFor the self consistent field function(Hatree-Fock-Roothaan equation):\n\\begin{equation}\\label{gdm_eq:1}\n FC = SCE\n\\end{equation}\nsuggest we have an initial set of mo $C_{0}$, by doing unitary transformation $U$\n\\begin{equation}\\label{gdm_eq:2}\n C^{'} = C_{0}U\n\\end{equation}\nwhere $U^{+}U = I$; it's able to derive a new set of mo and iteratively it's able to derive \nthe result mo which minimizes the energy functional. The transformation of $U$ is unitary \nbecause the mo needs to maintain $C^{+}SC=I$ for any set of mo. Therefore, suggest $C^{'}$ \nis the result mo, it can be expressed as:\n\\begin{equation}\\label{gdm_eq:3}\n C^{'} = C_{0}U_{0}U_{1}U_{2}\\cdots\n\\end{equation}\n\nCan we do energy minimization with respect to $U$? In this sense, the $E(U)$ will be a \nstationary point in terms of $U$. In maintaining the unitary property of $U$, it's able \nto define a Lagrangian:\n\\begin{equation}\\label{gdm_eq:4}\n L(U) = E(U) - Tr[\\epsilon\\cdot (U^{+}U-I)]\n\\end{equation}\nand the stationary equation is given as(see \\cite{doi:10.1137/S0895479895290954}):\n\\begin{align}\\label{gdm_eq:5}\n \\frac{\\partial L(U)}{\\partial U} &= 0 \\rightarrow   \\nonumber \\\\\n \\frac{\\partial E(U)}{\\partial U} & = F(U) = \\epsilon U^{+} \n\\end{align}\n$F$ is just the Fock matrix. Therefore, the \\ref{gdm_eq:5} shows how to derive the matrix\nof $U$.\n\nIt's well known that in DFT and HF the energy is invariant if the occupied orbitals space \ndoes not change. In other words, the energy does not depend on the occupied orbitals\nbut on the space that the occupied orbitals span. Therefore, if the $U$ is expressed as:\n\\begin{equation}\n U = \n \\begin{pmatrix}\n U_{oo}  &  0  \\\\\n 0       &  U_{vv} \\\\\n \\end{pmatrix}\n\\end{equation}\nit's easy to know that the energy is not going to change. Based on this fact, the matrix\n$U$ can be decomposed into two parts:\n\\begin{equation}\n  H = \n \\begin{pmatrix}\n H_{oo}  &  0  \\\\\n 0       &  H_{vv} \\\\\n \\end{pmatrix}\n\\end{equation}\nwhere it does not alter the energy, and \n\\begin{equation}\n  V = \n \\begin{pmatrix}\n 0        &  V_{ov}  \\\\\n V_{vo}   &  0       \\\\\n \\end{pmatrix}\n\\end{equation}\nwhere it changes the energy.\n\nIf an infinitesimal change $U \\rightarrow U + \\delta U$ is applied then through the \nunitary requirement the $\\delta U$ satisfies \n\\begin{equation}\n U^{+}\\delta U + \\delta U^{+} U = 0\n\\end{equation}\nIf we set $U = I$ then it has:\n\\begin{equation}\\label{gdm_eq:6}\n \\delta U =-\\delta U^{+}\n\\end{equation}\nthis implies that V is skew-symmetric:\n\\begin{equation}\\label{gdm_eq:7}\n  V = \n \\begin{pmatrix}\n 0            &  V_{ov}  \\\\\n-V^{+}_{vo}   &  0       \\\\\n \\end{pmatrix}\n\\end{equation}\n\nIn the constraint of $U^{+}U=1$, by a curve path of $U_{0}$, $U_{1}$, $\\cdots$\nwe may able to form the mo which is minimizing the SCF energy functional. However,\nwhat is the form of $U$ that may perform the job? According to the \n\\cite{doi:10.1137/S0895479895290954} the $U$ can be suggested as:\n\\begin{equation}\\label{gdm_eq:8}\n U = e^{V}\n\\end{equation}\nBased on the expansion below\n\\begin{equation}\\label{gdm_eq:9}\n e^{V} = 1 + \\frac{V}{1!} + \\frac{V^{2}}{2!} + \\cdots\n\\end{equation}\nit's able to expand the \\ref{gdm_eq:8}:\n\\begin{equation}\\label{gdm_eq:10}\n U(V) = \n \\begin{pmatrix}\n  \\cos X^{1/2}  & X^{-1/2} \\sin X^{1/2} V_{ov} \\\\\n  V_{vo}X^{-1/2} \\sin X^{1/2}  & \\cos Y^{1/2}  \\\\\n \\end{pmatrix}\n\\end{equation}\nwhere $X = V_{ov}V_{vo}$ and $Y = V_{vo}V_{ov}$. We note that the \\ref{gdm_eq:10}\ngive the expression of $\\dfrac{d U(V)}{d V}$.\n\nwhere $\\gamma$ is the variable used to optimize the SCF energy functional. Therefore,\nas initial step the SCF optimization could be suggested as:\n\\begin{itemize}\n \\item get the initial orthogonal mo $C_{0}$;\n \\item know the form of $V$;\n \\item minimize the $\\gamma$ in form of \\ref{gdm_eq:8} in the energy functional \n \\ref{gdm_eq:4}, suggest the result $\\gamma$ value is $\\gamma^{'}$;\n \\item derive the new set of mo $C_{1} = C_{0}e^{\\gamma_{0} V}$ until the energy\n is minimized\n\\end{itemize}\nIn the above suggested routine, the final mo could be expressed as:\n\\begin{equation}\n C = C_{0}e^{\\gamma \\vartriangle_{1}}e^{\\gamma \\vartriangle_{2}}\\cdots\n\\end{equation}\n\nSo far there are several things missing in the general discussion:\n\\begin{itemize}\n \\item we do not know how to compute the matrix $V$\n \\item how to include the matrix $H$ in the process?\n\\end{itemize}\n\n\\subsection{Towards A Solid GDM minimizer}\n%\n%\n%\n\n\n\n\\section{DIIS Method}\n%\n%\n%\n\\subsection{General Idea about DIIS Method}\n%\n%\n%\nDIIS method(direct inversion in the iterative subspace or direct inversion of the iterative subspace)\n\\cite{Pulay1980393, JCC:JCC540030413} starts from the Newton-Raphson method. This method is used to\nspeed up the optimization procedure used in SCF process and geometry optimization process in quantum\nchemistry. In these practical applications, it's usually hard to get the exact Hessian in the \nequation \\ref{Newton-Raphson_eq:9}. Therefore, the question we have here is that how can we use an \napproximated Hessian matrix to perform Newton-Raphson optimization procedure?\n\nSuggest that we use an approximated Hessian matrix $H_{0}$, according to equation\n\\ref{Newton-Raphson_eq:9}, the approximation solution based on a guess vector $\\mathbf{p_{n-1}}$ \ncould be expressed as:\n\\begin{equation}\n\\label{DIIS_eq:1}\n \\mathbf{p_{n}} = \\mathbf{p_{n-1}} - H_{0}^{-1}G\n\\end{equation}\nHere $G$ is the gradient vector for $\\dfrac{\\partial E}{\\partial \\mathbf{p_{n-1}}}$ and \n$H_{0}$ characterizes its second derivatives matrix.\n\nSuggest that if we have the accurate Hessian matrix, we could express the $G$ as:\n\\begin{equation}\n\\label{DIIS_eq:2}\n G = H(\\mathbf{p_{n-1}} - \\mathbf{p}^{final})\n\\end{equation}\nWhere $\\mathbf{p}^{final}$ corresponds to the exact solution for equation, which is \n$\\dfrac{\\partial E}{\\partial p_{i}} = 0$, $i = 1, 2, \\cdots$. \nTherefore, let's bring the \\ref{DIIS_eq:2} into \\ref{DIIS_eq:1} we can have:\n\\begin{equation}\n \\label{DIIS_eq:3}\n \\mathbf{p_{n}} = \\mathbf{p}^{final} + (1-H_{0}^{-1}H)(\\mathbf{p_{n-1}} - \\mathbf{p}^{final})\n\\end{equation}\n\nNow let's try to modify the \\ref{DIIS_eq:3}:\n\\begin{align}\n \\label{DIIS_eq:4}\n \\mathbf{p_{n}} - \\mathbf{p_{n-1}} &= \\mathbf{p}^{final} - \\mathbf{p_{n-1}} + \n (1-H_{0}^{-1}H)(\\mathbf{p_{n-1}} - \\mathbf{p}^{final}) \\nonumber \\\\\n &= (\\mathbf{p}^{final} - \\mathbf{p_{n-1}})(1-(1-H_{0}^{-1}H)) \\nonumber \\\\\n &= (\\mathbf{p}^{final} - \\mathbf{p_{n-1}})H_{0}^{-1}H\n\\end{align}\nThe expression of \\ref{DIIS_eq:4} has an important meaning. It indicates that\nif the RHS of \\ref{DIIS_eq:4} approaches to zero, since\nthe term of $H_{0}^{-1}H$ is never zero, then the $\\mathbf{p}^{final} - \\mathbf{p_{n-1}}$ \nis zero - which means, we get to the exact solution of the whole equation! \nTherefore, the difference between $\\mathbf{p_{n}} - \\mathbf{p_{n-1}}$ characterizes the \nmeasure for the convergence of the solution, if it's converged; then we get the final\nreal solution. We name the difference between\n$\\mathbf{p_{n}}$ and $\\mathbf{p_{n-1}}$ as residual vector: $\\triangle \\mathbf{p_{n}}$, which\nshould be the norm between the two vectors.\n\nBased on this point, we can suggest an expression that the solution vectors\nof $\\mathbf{p}$ is expressed as a linear combination of its previous iterative \nvectors:\n\\begin{equation}\n \\label{DIIS_eq:5}\n \\mathbf{p_{n}} = \\sum_{i}c_{i}\\mathbf{p_{i}}\n\\end{equation}\nTherefore, the question here is to how can we generate the coefficients of \n$c_{i}$ so that the $\\mathbf{p_{n}}$ could converge to final solution.\n\nFirst of all, we can see that the $c_{i}$ is actually required to meet some\nrestrictions. That is \n\\begin{equation}\n \\label{DIIS_eq:6}\n \\sum_{i}c_{i} = 1\n\\end{equation}\nWhy we have that? Suggest the final solution is $\\mathbf{p}^{final}$,\nand we can express each of approximated solution $\\mathbf{p_{i}}$ as:\n\\begin{equation}\n \\mathbf{p_{i}} = \\mathbf{p}^{final} + \\mathbf{e}_{i}\n\\end{equation}\nwhere $e_{i}$ is the error estimation.Then we have:\n\\begin{align}\n\\label{DIIS_eq:7}\n \\mathbf{p_{n}} &= \\sum_{i}c_{i}(\\mathbf{p}^{final} + \\mathbf{e}_{i}) \\nonumber \\\\\n &= \\mathbf{p}^{final}\\sum_{i}c_{i} + \\sum_{i}c_{i}\\mathbf{e}_{i}\n\\end{align}\nIf we have the requirement shown in \\ref{DIIS_eq:6}, then as the errors of $\\mathbf{e}_{i}$\ngoes to zero, then in the above equation we have $\\mathbf{p_{n}} = \\mathbf{p}^{final}$.\n\nNext, how can we evaluate these $c_{i}$ in \\ref{DIIS_eq:5}? According to the result\nshown in \\ref{DIIS_eq:4}, the residual vector of $\\triangle \\mathbf{p_{n}}$ characterizes\nthe convergence of approximated solutions towards the exact solution, therefore it's \nnatral to imagine that if all of the $\\triangle \\mathbf{p_{i}}$ ($i=1,2,\\cdots$) are small\nenough, then the result $c_{i}$ must be the best approximation. Such idea is similar to the \nleast square problem. Therefore we have:\n\\begin{equation}\n\\label{DIIS_eq:8}\n \\triangle \\mathbf{P} = \\sum_{i}c_{i}\\triangle \\mathbf{p_{i}} \n \\Rightarrow \\min(\\triangle \\mathbf{P})\n\\end{equation}\n\nFor evaluating the minimum of $\\triangle \\mathbf{P}$, we can construct some Lagrangian:\n\\begin{align}\n \\label{DIIS_eq:9}\n L &= \\langle \\triangle \\mathbf{P} |\\triangle \\mathbf{P} \\rangle - \n \\lambda(1-\\sum_{i}c_{i}) \\nonumber \\\\\n   &= \\sum_{i}\\sum_{j}c_{i}c_{j}\\langle\\triangle \\mathbf{p_{i}}|\\triangle\\mathbf{p_{j}}\\rangle - \n   \\lambda(1-\\sum_{i}c_{i})\n\\end{align}\n\nBy requiring that $\\dfrac{\\partial L}{\\partial c_{i}} = 0$ ($i = 1, 2, \\cdots$) \nas well as $\\dfrac{\\partial L}{\\partial \\lambda} = 0$ we can have:\n\\begin{align}\n \\frac{\\partial L}{\\partial c_{i}} &= \n 2\\sum_{j}c_{j}\\langle\\triangle \\mathbf{p_{i}}|\\triangle\\mathbf{p_{j}}\\rangle - \\lambda\n = \\sum_{j}c_{j}\\langle\\triangle \\mathbf{p_{i}}|\\triangle\\mathbf{p_{j}}\\rangle - \\frac{\\lambda}{2}\n \\nonumber \\\\\n \\frac{\\partial L}{\\partial \\lambda} &= \n 1-\\sum_{i}c_{i}\n\\end{align}\nWe note that the factor of 2 is absorbed into the $\\lambda$ in above equation.\n\nBy applying the above derivation into the \\ref{DIIS_eq:9}, then we can have the following \nlinear equation:\n\\begin{align}\n \\label{DIIS_eq:10}\n &\\begin{bmatrix}\n  \\langle\\triangle \\mathbf{p_{1}}|\\triangle\\mathbf{p_{1}}\\rangle  &\n  \\langle\\triangle \\mathbf{p_{1}}|\\triangle\\mathbf{p_{2}}\\rangle  &\n  \\cdots                                                          &\n  \\langle\\triangle \\mathbf{p_{1}}|\\triangle\\mathbf{p_{m}}\\rangle  &\n   -1                                                             \\\\\n  \\langle\\triangle \\mathbf{p_{2}}|\\triangle\\mathbf{p_{1}}\\rangle  &\n  \\langle\\triangle \\mathbf{p_{2}}|\\triangle\\mathbf{p_{2}}\\rangle  &\n  \\cdots                                                          &\n  \\langle\\triangle \\mathbf{p_{2}}|\\triangle\\mathbf{p_{m}}\\rangle  &\n   -1                                                             \\\\\n  \\cdots                                                          &\n  \\cdots                                                          &\n  \\cdots                                                          &\n  \\cdots                                                          &\n  \\cdots                                                          \\\\\n  \\langle\\triangle \\mathbf{p_{m}}|\\triangle\\mathbf{p_{1}}\\rangle  &\n  \\langle\\triangle \\mathbf{p_{m}}|\\triangle\\mathbf{p_{2}}\\rangle  &\n  \\cdots                                                          &\n  \\langle\\triangle \\mathbf{p_{m}}|\\triangle\\mathbf{p_{m}}\\rangle  &\n  -1                                                             \\\\  \n  -1                                                              &\n  -1                                                              &\n  \\cdots                                                          &\n  -1                                                              &\n   0                                                             \\\\\n \\end{bmatrix}\n \\begin{bmatrix}\n  c_{1}  \\\\\n  c_{2}  \\\\\n  \\vdots \\\\\n  c_{m}  \\\\\n  \\lambda\\\\ \n \\end{bmatrix}\n&=  \\begin{bmatrix}\n   0  \\\\\n   0  \\\\\n  \\vdots \\\\\n   0  \\\\\n   1  \\\\ \n \\end{bmatrix}\n\\end{align}\nThe final DIIS step is to obtain a solution to the above linear equation, then \nwe know how to form the new vector of $\\mathbf{p}$.\n\nPhysically, in DIIS procedure the most important expression is the \\ref{DIIS_eq:8}.\nThis expression explains how we can get the coefficients of $c_{i}$. Furthermore,\nwe note that this expression is not unique. We can have multiple way to create the \nresidual vectors of $\\triangle \\mathbf{p}$ so that to have better convergence for the \noptimization process.\n\nAnother thing to note is that the matrix in \\ref{DIIS_eq:10} could be singular when\nthe optimization process is near to the convergence. For example, if the last two\nerror vectors of $\\triangle \\mathbf{p_{m}}$ and $\\triangle \\mathbf{p_{m-1}}$ are \nnearly same, then their corresponding column and rows would be nearly same - causing\nthe matrix to be singular.\n\nAt last, it is interesting to note that DIIS procedure has been mathematically analyzed.\nIt's shown that DIIS procedure is equivalent to the quasi-Newton/Secant method\n\\cite{rohwedder2011analysis}.\n\n\\subsection{DIIS in SCF Procedure}\n%\n%\nThe key in the DIIS procedure, is to find a proper expression of the error vectors \ndefined in \\ref{DIIS_eq:8}. In paper ~\\cite{JCC:JCC540030413} Pulay suggest to use \nthe difference below:\n\\begin{equation}\n \\label{DIIS_SCF_eq:1}\n \\triangle \\mathbf{p} = FPS - SPF\n\\end{equation}\nto represent the errors in SCF convergence. We note, that it coincides our expression \nin \\ref{HF_density_matrix:eq:5} that the converged density matrix is able to commute with\nFock matrix in MO manner.\n\nHow to perform the DIIS procedure in SCF cycles? Generally it could be divided into the \nfollowing steps:\n\\begin{enumerate}\n \\item Building density matrices $P$ and overlap matrix $S$;\n \\item Building Fock matrices according to the number of spin states;\n \\item Construct error vectors $e$ for each spin state according to \\ref{DIIS_SCF_eq:1};\n \\item Transform the error vectors into form of $S^{-\\frac{1}{2}}eS^{-\\frac{1}{2}}$ so that\n to make it orthogonal;\n \\item Estimate the maximum error and root mean square error and compare it with the criteria \n to see whether the convergence has been achieved;\n \\item Extrapolate the error matrix defined in \\ref{DIIS_eq:10}, we note that it's only the \n last column/row we need to re-compute, and the new elements are set to be $ E_{ij} = \n \\langle e_{i}|e_{j}\\rangle$;\n \\item Solve the error matrix and get the coefficients of $c_{i}$;\n \\item Construct the new Fock matrix based on the expression of \\ref{DIIS_eq:5}, where the \n vector of $\\mathbf{p}$ is actually the previous Fock matrix.\n\\end{enumerate}\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "3369293e8b2bf7a0497924701f0903308b1d9a8a", "size": 23301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "algorithm/technic/scfconv.tex", "max_stars_repo_name": "murfreesboro/fenglai-note", "max_stars_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-16T07:23:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T07:23:48.000Z", "max_issues_repo_path": "algorithm/technic/scfconv.tex", "max_issues_repo_name": "murfreesboro/fenglai-note", "max_issues_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "algorithm/technic/scfconv.tex", "max_forks_repo_name": "murfreesboro/fenglai-note", "max_forks_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8073555166, "max_line_length": 101, "alphanum_fraction": 0.6703574954, "num_tokens": 7319, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.4288634332404983}}
{"text": "\\pagebreak\n\\subsection{Power System}\n\n\\subsubsection{Power System Requirements}\n\\begin{centering}\nThe Gondola provided a 28.8 V, 374 Wh or 13 Ah battery with a recommended maximum continuous current draw of 1.8 A . However, more typical values which were given were 196 Wh or 7 Ah \\cite{BexusManual}.The experiment should have been able to run on (gondola) battery for more than two hours before launch during the countdown phase and for the entire flight duration, lasting approximately four hours. As a factor of safety, in case of unexpected delays, the experiment was able to run for an additional four hours. Therefore the experiment could be able to run on (gondala) power for a total of 10 hours. For this reason, all the calculations were done using a 10 hour total time \\cite{BexusManual}.\n\\end{centering}\n\n\n\\input{4-experiment-design/tables/powertable.tex}\n\n\nThe total power consumption 181 Wh, Table \\ref{tab:power-design-table}, was within the limits of the available power. Other calculations for the average, peak, and minimum power values were 24 W, 38 W, and 16 W respectively. In addition the different expected current consumption for the average, peak, and minimum values were 0.64 A, 1.1 A, and 0.22 A respectively.\n\nThe 24 V DC-DC converters had 2.5 A output current and 60 W output power with the efficiency of 93\\%. This fulfilled the peak requirements for both power and current. Moreover, the dissipated power and current across the DC-DCs were calculated as 12.69 Wh and 45 mA respectively and have been added to the total power budget. \n\n\n\n\\raggedbottom\n", "meta": {"hexsha": "d63e7b90f6ed14e592a65d64611a3dd21213b29d", "size": 1581, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "4-experiment-design/4.7-power-design.tex", "max_stars_repo_name": "georgeslabreche/tubular-bexus-sed", "max_stars_repo_head_hexsha": "c0db957167dfc90c25743af64c514fce837c1405", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-01-17T10:38:07.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-17T10:38:07.000Z", "max_issues_repo_path": "4-experiment-design/4.7-power-design.tex", "max_issues_repo_name": "georgeslabreche/tubular-bexus-sed", "max_issues_repo_head_hexsha": "c0db957167dfc90c25743af64c514fce837c1405", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "4-experiment-design/4.7-power-design.tex", "max_forks_repo_name": "georgeslabreche/tubular-bexus-sed", "max_forks_repo_head_hexsha": "c0db957167dfc90c25743af64c514fce837c1405", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.05, "max_line_length": 700, "alphanum_fraction": 0.788741303, "num_tokens": 385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.4288634330599615}}
{"text": "\n\\chapter{Additional Features}\nVarious features of {\\ViennaMath}, which are not necessarily standard features of a symbolic math library, are covered in this chapter.\nAdditional feature requests should be sent to\n\\begin{center}\n\\texttt{viennamath-support$@$lists.sourceforge.net} \n\\end{center}\n\n  \\section{\\LaTeX{} Output}\nSince {\\ViennaMath} encourages a high-level description and manipulation of the underlying mathematical problem formulation in source code, it is natural to\ngenerate \\LaTeX{} code from {\\ViennaMath} expressions for debugging purposes. The generated code can be copy\\&paste'd to LaTeX rendering webpages or used for\nthe automatic generation of program log files in the form of a \\LaTeX{} document.\n\nAll conversion is carried out by a separate converter object of type \\lstinline|rt_latex_translator<InterfaceType>| as defined in\n\\lstinline|viennamath/manipulation/latex.hpp|. A convenience shortcut \\lstinline|latex_translator| is available for the default runtime expression interface.\nConversion is triggered by providing the expression to be converted to the functor:\n\\begin{lstlisting}\n latex_translator  to_latex;\n\n expr f = sqrt( x + y );\n to_latex( f );     //returns the string '\\sqrt{x_{0}+x_{1}}'\n\\end{lstlisting}\nBy default, variables are printed as $x_0$, $x_1$, etc. This and other output routines can be customized by using the \\lstinline|customize()| member function\nof the converter. For example, to print 'x' and 'y' instead of 'x\\_\\{0\\}' and 'x\\_\\{1\\}', the code\n\\begin{lstlisting}\n to_latex.customize(x, \"x\");\n to_latex.customize(y, \"y\");\n\\end{lstlisting}\nis sufficient. Similar customizations can be applied for the output of types and features described in the remainder of this chapter.\n\n\\NOTE{The \\LaTeX{} generator works with runtime expression types only. Thus, compiletime expression types need to be converted to runtime expression types\nfirst.}\n\n  \\section{Differential Operators}\nFor enabling dimension-independent programming, dimension-independent mathematical differential operations are also provided with {\\ViennaMath}.\nIn {\\ViennaMathversion}, the gradient and the divergence operators are provided by the functions \\lstinline|grad()| and \\lstinline|div()| respectively:\n\\begin{lstlisting}\n expr u = grad(x+y);\n expr v = grad(x-y);\n expr w = div(grad(x*x + y*y));\n\\end{lstlisting}\nNote that expression containing differential operators cannot be evaluated directly, since a coordinate system needs to be specified first.\n\nA coordinate system is applied to the previous expressions by using the free function \\lstinline|apply_coordinate_system()|, which is defined in the header file \\lstinline|viennamath/manipulation/apply_coordinate_system.hpp|. The first function argument is a tag identifying the coordinate system (either of type \\lstinline|cartesian<1>|, \\lstinline|cartesian<2>|, or \\lstinline|cartesian<3>| for a Cartesian coordinate system in one, two or three dimensions). The second function argument is the expression to which the coordinate system should be applied:\n\\begin{lstlisting}\n apply_coordinate_system(cartesian<1>(), u); //returns 1 + y\n apply_coordinate_system(cartesian<2>(), v); //returns (1, -1)\n apply_coordinate_system(cartesian<3>(), w); //returns 4\n\\end{lstlisting}\nDifferential operators are very handy in combination with function symbols explained in Sec.~\\ref{sec:function-symbols}.\n\n%%%%%%%%%%%%%%%\n  \\section{Integration Symbols}\nIn certain cases the form of an integral expression is known, but the actual integration domain is determined at some later stage. \nHere, a symbolic integration domain of type \\lstinline|symbolic_interval| identified by an ID can be specified and substituted by the final integration interval later on.\nFor example, the integral $\\int_\\Omega x^2 \\: \\mathrm{d} \\Omega$, where $\\Omega$ is specified at some later point, is specified using {\\ViennaMath} as\n\\begin{lstlisting}\n expr my_integral = integral(symbolic_interval(), x*x);\n\\end{lstlisting}\nThe interface is again such that it can be used with both runtime and compiletime types. For simplicity, the resulting integral expression is here assigned to a runtime expression \\lstinline|my_integral|. An ID can be provided to the constructor of \\lstinline|symbolic_interval| for distinguishing between different symbolic intervals. By default, an ID of $0$ is used.\n\nIn order to substitute the symbolic interval with the actual integration interval, the function \\lstinline|substitute()| as explained in Sec.~\\ref{sec:substitute} is used.\nSince the replacement consists of both the integration interval and the variable over which integration is to be carried out, the replacement argument is packed into a \\lstinline|pair| as defined in the C++ STL. Thus, in order to specify $\\Omega$ as the interval $[0,1]$ with an integration over the $x$-variable, the code\n\\begin{lstlisting}\n expr my_integral2 = substitute( symbolic_interval(),\n                                 std::make_pair(interval(0, 1), x),\n                                 my_integral);\n\\end{lstlisting}\nis sufficient. Note that in the current release of {\\ViennaMath} only the substitution with a one-dimensional integration domain is supported, but no nested integrals are possible yet.\n\n\\TIP{Note that \\lstinline|std::make_pair()| is defined in the header \\lstinline|<utility>|.}\n\n\n%%%%%%%%%%%%%%%\n  \\section{Function Symbols} \\label{sec:function-symbols}\nFor discretization schemes based on weak formulations of partial differential equations it is appropriate to work with abstract functions rather than with concrete expressions.\nFor example, the weak form of the Poisson equation,\n\\begin{align} \\label{eq:weak-poisson}\n \\int_\\Omega \\nabla u \\cdot \\nabla v \\: \\mathrm{d} x = \\int_\\Omega fv \\: \\mathrm{d} x \n\\end{align}\nfor all test functions in a certain test space $\\mathcal{V}$, is formulated for functions $u$ and $v$, which are during the discretization replaced by certain trial and test functions, which finally yields a system of linear equations. \nSuch function labels (\\emph{function symbols}) are modeled in {\\ViennaMath} by the type \\lstinline|rt_function_symbol<InterfaceType>| at runtime (with convenience shortcut \\lstinline|function_symbol| for the default runtime interface type) and by \\lstinline|ct_function_symbol<T>| at compiletime, where \\lstinline|T| is a tag identifying the function symbol.\n\nAs a simple example, the expression $uv$ is considered, where $u$ is then substituted with the expression $(1+x)$ and $v$ is replaced by $(1-x)$:\n\\begin{lstlisting}\n function_symbol u(0);\n function_symbol v(1);\n expr f = u * v;\n expr g = substitute(u, 1.0 + x,\n                     substitute(v, 1.0 - x, f)\n                    );    // g becomes (1+x)*(1-x)\n\\end{lstlisting}\nThe constructor arguments denote the function symbol ID used for distinguishing the individual function symbols.\n\nReconsidering the weak form \\eqref{eq:weak-poisson}, function symbols at compiletime can use any arbitrary tag class for identification.\n{\\ViennaMath} provides the predefined tags \\lstinline|unknown_tag<id>| and \\lstinline|test_tag<id>|, where the integer template parameter \\lstinline|tag| is used for distinguishing between several function symbols of the same tag. The previous code snippet rewritten for compiletime manipulation thus becomes\n\\begin{lstlisting}\n ct_function_symbol< unknown_tag<0> > u;\n ct_function_symbol<    test_tag<0> > v;\n substitute(u, 1.0 + x,\n            substitute(v, 1.0 - x, u*v)\n           );    // returns (1+x)*(1-x)\n\\end{lstlisting}\nNote that the result type of \\lstinline|substitute()| encodes the result \\lstinline|(1+x)*(1-x)|, thus the result is usually directly passed to another function (e.g.~\\lstinline|eval()|) in order to avoid writing the return type explicitly.\n\nAs a final example, the weak form \\eqref{eq:weak-poisson} (with $f \\equiv 1$ for simplicity) is specified directly as a {\\ViennaMath} runtime expression and converted to {\\LaTeX}-code using the functionality presented in this chapter:\n\\begin{lstlisting}\n function_symbol u(0);\n function_symbol v(1);\n equation weak_form = make_equation( integral( symbolic_interval(),\n                                               grad(u) * grad(v) ),\n                                     integral( symbolic_interval(), v ) );\n latex_translator to_latex;\n std::cout << to_latex(weak_form) << std::endl;\n\\end{lstlisting}\n\n\n\\TIP{ Have a look at \\texttt{ViennaFEM}~(\\texttt{http://viennafem.sourceforge.net/}) if you are interested in a software package using {\\ViennaMath} for the finite element method. }\n\n\n\n", "meta": {"hexsha": "0fdf3994ee710231d6ad119c632812fa6ff963f8", "size": 8550, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/manual/additional.tex", "max_stars_repo_name": "viennamath/viennamath-dev", "max_stars_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-09-13T03:51:48.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-20T10:35:43.000Z", "max_issues_repo_path": "doc/manual/additional.tex", "max_issues_repo_name": "viennamath/viennamath-dev", "max_issues_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/manual/additional.tex", "max_forks_repo_name": "viennamath/viennamath-dev", "max_forks_repo_head_hexsha": "e238b40f52b8c3fe7de773625439d5de8d96ad39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.0819672131, "max_line_length": 557, "alphanum_fraction": 0.7535672515, "num_tokens": 2012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4288634287844208}}
{"text": "\\chapter{Introduction}\n\\label{chapter:introduction}\n\\par\nThe Lanczos eigensolver \nfinds selected eigenvalues and eigenvectors of \n% three types of eigenproblems, \n$AX = B X \\Lambda$, where $X$ are eigenvectors\nand $\\Lambda$ is a diagonal matrix whose elements are eigenvalues.\nThree types of eigenproblems are supported.\n\\begin{itemize}\n\\item \nAn ``ordinary'' eigenvalue problem \nwhere $A$ is symmetric and $B = I$.\n\\item \nAn ``vibration'' eigenvalue problem \nwhere $A$ is symmetric and \n$B$ is symmetric positive semidefinite.\n\\item \nA ``buckling'' eigenvalue problem \n$A$ is symmetric positive semidefinite and\n$B$ is symmetric.\n\\end{itemize}\nFor the vibration and buckling problems, there must exist a\n$\\sigma$ that is not an eigenvalue such that\n$A - \\sigma B$ is nonsingular,\ni.e., $A$ and $B$ cannot share the same null space.\n\\par\nDuring the computations, the eigensolver requires the following\nsparse linear algebra computations.\n\\begin{itemize}\n\\item\nSparse factorizations of the form $A - \\sigma B$.\n\\item\nSolves of the form $(A - \\sigma B) Z = Y$.\n\\item\nMultiplies of the form $Z = B Y$ (for the vibration problem)\nor $Z = A Y$ (for the buckling problem).\n\\end{itemize}\nThe Lanczos eigensolver has defined a specific interface with an\nexternal linear algebra package to perform these three operations.\nThe eigensolver currently interfaces with the {\\bf BCSLIB-EXT} linear\nsolver in a serial environment and the {\\bf SPOOLES} linear solver\nin serial, multithreaded and MPI environments.\n\\par\nThis paper documents the {\\bf SPOOLES} objects and functions\nthat interface with the eigensolver.\nThe three following chapters describe the serial, multithreaded and\nMPI objects, their data structures, and their methods.\nThe appendix contains listings of three driver programs to exercise\nthe eigensolver using the {\\bf SPOOLES} library.\n\\par\nSymmetric permutations of the eigensystem do not change the\neigenvalues, and the eigenvectors can be easily constructed\nusing the permutation matrix.\n$$\nA X = B X \\Lambda\n\\longrightarrow\n{\\widehat A} {\\widehat X} \n= {\\widehat B} {\\widehat X} \\Lambda\n\\quad \\mbox{where} \\quad\n{\\widehat A} = PAP^T, \\quad\n{\\widehat B} = PBP^T, \\quad\n\\mbox{and} \\quad \n{\\widehat X} = PX \n$$\nThe linear algebra package is free to use any permutation matrix\n$P$ to most efficiently perform the factorizations and solves\ninvolving ${\\widehat A}$ and ${\\widehat B}$.\nThis permutation matrix $P$ is typically found by ordering the\ngraph of $A + B$ using a variant of minimum degree or nested\ndissection.\nThe ordering is performed prior to any action by the eigensolver.\nThis ``setup phase'' includes more than just finding the\npermutation matrix, e.g., various data structures must be\ninitialized.\nIn a parallel environment, there is even more setup work to do,\nanalyzing the factorization and solves and specifying which threads\nor processors perform what computations and store what data.\nIn a distributed environment, the entries of $A$ and $B$ must \nalso be distributed among the processors in preparation for \nthe factors and multiplies.\n\\par\nFor each of the three environments --- serial, multithreaded and\nMPI --- the {\\bf SPOOLES} solver has constructed a ``bridge''\nobject to span the interface between the linear system solver \nand the eigensolver.\nEach of the {\\tt Bridge}, {\\tt BridgeMT} and {\\tt BridgeMPI}\nobjects have five methods: set-up, factor, solve, matrix-multiply\nand cleanup.\nThe factor, solve and matrix-multiply methods follow the calling\nsequence convention imposed by the eigensolver, and are passed \nto the eigensolver at the beginning of the Lanczos run.\nThe set-up method is called prior to the eigensolver, and the\ncleanup method is called after the eigenvalues and eigenvectors\nhave been determined.\n", "meta": {"hexsha": "31b2d53112e456593d658444229d353a50057609", "size": 3752, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/Eigen/doc/intro.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/Eigen/doc/intro.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/Eigen/doc/intro.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 39.0833333333, "max_line_length": 69, "alphanum_fraction": 0.7729211087, "num_tokens": 956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.42884637056151376}}
{"text": "\n\\subsection{Homework}\n\\begin{enumerate}\n\\item Search the internet for equations containing a Laplace operator\n  and models from science, economics, etc.\n\\item Energy minimization and weak formulation\n\\item Prove Poincare inequality (1D)\n\\end{enumerate}\n\n\\subsection{Classroom topics}\n\\begin{enumerate}\n\\item Model problem: Poisson equation, boundary conditions\n\\item Lack of solution theory\n\\item Weak formulation, natural boundary condition, analogy to linear algebra\n\\item Elementary integration\n\\item Elementary Sobolev spaces, Lax-Milgram\n\\end{enumerate}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End: \n", "meta": {"hexsha": "9dfcad79d69a5f3bb84294d815b3b4ab742e7883", "size": 632, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pde/todo.tex", "max_stars_repo_name": "ahumanita/notes", "max_stars_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pde/todo.tex", "max_issues_repo_name": "ahumanita/notes", "max_issues_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-05-24T07:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-31T12:58:14.000Z", "max_forks_repo_path": "pde/todo.tex", "max_forks_repo_name": "ahumanita/notes", "max_forks_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-05-15T19:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-05T19:07:29.000Z", "avg_line_length": 27.4782608696, "max_line_length": 77, "alphanum_fraction": 0.7816455696, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4287924640786517}}
{"text": "\\documentclass[11pt]{article}\n\\setcounter{secnumdepth}{0}\n\n\\usepackage{relsize}\n\n\\newcommand{\\mono}[1]{{\\smaller\\texttt{#1}}}                    % literal (to be typed): code, program names\n\n\\begin{document}\n\n\\section{Fitting a mixture Dirichlet to counts}\n\n\\mono{esl\\_mixdchlet\\_Fit()} infers a maximum likelihood mixture\nDirichlet distribution for a data set of count vectors. It uses\nconjugate gradient descent from an initial starting point. The result\nis only a local optimum, so we typically run it multiple times with\ndifferent starting points. The partial derivatives of the log\nlikelihood function are persnickety, and the purpose of these notes is\nto enshrine the derivation that corresponds to the implementation.\n\nWe have $N$ count vectors $c_i$, with each vector consisting of $K$\ncounts for individual symbols $c_{ia} \\geq 0$. The mixture Dirichlet\n$\\theta$ consists of $Q$ components $\\alpha_k$, with each parameter\nvector containing $K$ parameters $\\alpha_{ka} > 0$, and $Q$ mixture\ncoefficients $q_k > 0, \\sum_k q_k = 1$.\n\nThe log likelihood of the data is:\n\n\\[\n  L = \\log P(\\mbox{data} \\mid \\theta) = \\sum_i \\log P(c_i \\mid \\theta) = \\sum_i \\log \\sum_k q_k P(c_i \\mid \\alpha_k)\n\\]\n\n\\mono{esl\\_mixdchlet\\_logpdf\\_c()} calculates $\\log P(c_i \\mid\n\\theta)$.\n\n$P(c_i \\mid \\alpha_k)$, the probability of one count vector given one\nDirichlet component, is:\n\n\\[\nP(c_i \\mid \\alpha_k) = \\frac{ |c_i|! }\n                            { \\prod_a c_{ia}! }\n                       \\frac{ \\prod_a \\Gamma \\left( c_{ia} + \\alpha_{ia} \\right) }\n                            { \\Gamma ( |c_i + \\alpha_k| ) }\n                       \\frac{ \\Gamma ( |\\alpha_k| ) }\n                            { \\prod_a \\Gamma \\left( \\alpha_{ka} \\right) }\n\\]\n\n\\mono{esl\\_dirichlet\\_logpdf\\_c()} calculates $\\log P(c_i \\mid \\alpha_k)$.\n\nThe conjugate gradient descent code works with unconstrained\nreal-valued parameters. The Dirichlet parameters $\\alpha_{ka}$ are\nconstrained to $>0$, and mixture coefficients $q_k$ are constrained to\n$>0$ and $\\sum_k q_k = 1$. Define a change of variables in terms of\nunconstrained parameters $\\lambda_k$ for the mixture coefficients and\n$\\beta_{ka}$ for Dirichlet parameters:\n\n\\begin{eqnarray*}\n  q_k          & = & \\frac{ e^{\\lambda_k} } { \\sum_m e^{\\lambda_m} } \\\\\n  \\alpha_{ka}  & = & e^{\\beta_{ka}} \n\\end{eqnarray*}\n\nAfter variable substitution, partial differentiation w.r.t. the\nunconstrained parameters, and substituting back the original\nparameters, we have for the mixture coefficients:\n\n\\[\n  \\frac{\\partial L}{\\partial \\lambda_k} = \\sum_i P(k \\mid \\theta, c_i) - q_k\n\\]\n\ni.e., the difference between the posterior probability of component\n$k$ $P(k \\mid \\theta, c_i)$, calculated by \\mono{mixdchlet\\_postq()},\nand its prior $q_k$.\n\nFor the Dirichlet parameters:\n\n\\[\n\\frac{\\partial L}{\\partial \\beta_{ka}}  =  \\sum_i\n \\alpha_{ka} P(k \\mid \\theta, c_i) \n    \\left( \\Psi \\left( c_{ia} + \\alpha_{ka} \\right)  \n        -  \\Psi \\left( | c_i | + | \\alpha_k | \\right)\n        +  \\Psi \\left( | \\alpha_k | \\right) \n        -  \\Psi \\left( \\alpha_{ka} \\right) \n    \\right) \n\\]\n\n\n$\\Psi(x)$ is the digamma function $\\frac{d}{dx} \\log \\Gamma(x) =\n\\frac{\\Gamma'(x)}{\\Gamma(x)}$, for $x > 0$, implemented by\n\\mono{esl\\_stats\\_Psi()}.\n\nThe Easel conjugate gradient descent optimizer is a minimizer, not a\nmaximizer.  The implementation provides the negative log likelihood\nand the negative gradient to the CG routine.\n\n\n\\end{document}\n\n", "meta": {"hexsha": "8c5ef2849919be0ae116cee1a0fae67385cc608e", "size": 3438, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hmmer-3.3/easel/esl_mixdchlet.tex", "max_stars_repo_name": "WooMichael/Project_Mendel", "max_stars_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hmmer-3.3/easel/esl_mixdchlet.tex", "max_issues_repo_name": "WooMichael/Project_Mendel", "max_issues_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hmmer-3.3/easel/esl_mixdchlet.tex", "max_forks_repo_name": "WooMichael/Project_Mendel", "max_forks_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.4432989691, "max_line_length": 116, "alphanum_fraction": 0.6643397324, "num_tokens": 1029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.42879246371765356}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{3 October 2019}\n\nMarco Peloso, \\url{marco.peloso@pd.infn.it}\n\n\\section{Special relativity}\n\n\\begin{definition}\n    An inertial frame is one in which Newton's laws hold: a free body moves with acceleration \\(a^{i} = 0\\).\n\\end{definition}\n\nNewton's first law establishes the \\emph{existence} of inertial frames.\n\n\\begin{proposition}\n    The frames \\(O\\) and \\(O'\\) are both inertial frames iff \\(O'\\) moves with constant velocity wrt \\(O\\).\n\\end{proposition}\n\n\\begin{proposition}\n    Coordinate transformations between inertial frames are Lorentz boosts, which in some coordinate frame can be written as\n    %\n    \\begin{subequations}\n    \\begin{align}\n      t' &= \\gamma_v \\qty(t - \\frac{vx}{c^2})  \\\\\n      x' &= \\gamma_v \\qty(x - vt)  \\\\\n      y' &= y \\\\\n      z' &= z\\,,\n    \\end{align}\n    \\end{subequations}\n    %\n    where \\(\\gamma_v = 1/ \\sqrt{1 - v^2 / c^2} \\).\n\\end{proposition}\n\nIf \\(v \\ll c\\), so \\(v/c \\sim 0\\), they simplify to the identity for \\(t\\), \\(y\\), \\(z\\) and \\(x' = x -vt\\): these are Galilean transformations.\n\nIf we have two events, \\(x^\\mu\\) and \\(y^\\mu\\), they occur with some time and space separation \\(\\Delta x^\\mu = x^\\mu - y^\\mu\\). We can compute \\(\\Delta s^2 = \\eta_{\\mu\\nu} \\Delta x^\\mu \\Delta x^\\nu \\), where\n%\n\\begin{equation}\n  \\eta_{\\mu \\nu} = \\diag{-c^2, 1, 1, 1} \\,.\n\\end{equation}\n\n\\begin{proposition}\nUnder Lorentz transformations \\(\\Delta s^2\\) is invariant.\n\\end{proposition}\n\nWe can classify separations between events as\n%\n\\begin{itemize}\n    \\item time-like when \\(\\Delta s^2 <0\\);\n    \\item null-like when \\(\\Delta s^2 =0\\);\n    \\item space-like when \\(\\Delta s^2 >0\\).\n\\end{itemize}\n\nWe can draw spacetime diagrams. A light cone is the set of points which are null-like separated from a select point. Things can be only causally related to events inside the light-cone, with \\(\\Delta s^2 \\leq 0\\).\n\n\\subsection{Time dilation}\n\nTake two events which occur at the same location for \\(O'\\). In the primed frame they will have coordinates \\(x^{\\mu} = (t_0, x_0)\\) and \\(y^\\mu = (t_1, x_0)\\).\n\n\\begin{definition}\n    The \\emph{proper time} between these two events is \\(t_1 - t_0 \\defeq \\Delta \\tau\\).\n\\end{definition}\n\nWe now see that \\(\\Delta s'\\,^2 = -c^2 \\Delta \\tau^2\\). Then, any other observer will see the same  \\(\\Delta s^2 = - c^2 \\Delta t^2 + \\Delta x^2 = \\Delta s'\\,^2\\).\n\nThis directly implies that \\(\\Delta \\tau \\leq \\Delta t\\) for any observer, since \\(\\Delta \\tau^2 = \\Delta t^2 - \\Delta x^2 / c^2\\). This effect is called \\emph{time dilation}.\n\nBy how much exacly is time dilated? Of course \\(\\Delta x = v \\Delta t\\), therefore \\(\\Delta t = \\gamma_v \\Delta \\tau\\).\n\nThis effect explains a peculiar phenomenons: certain particles in the upper atmosphere decay into muons, which have a very short half-life. So short, in fact, that if we did not account for special relativity we'd expect to see next to none at the surface, since by the time they got here they would have alredy gone through several halving times. \nHowever, we must apply the rule of relativistic time dilation: the muons are travelling very fast towards the ground, therefore in the ground's frame of reference their time passes slower, allowing them to decay slower. \nSo, a significant fraction of them arrives at the ground. \n\nInverse Lorentz transformation have the same expression as direct ones, but with \\(v \\rightarrow -v\\).\nThis can be proved both mathematically by solving the equations and phisically by reasoning about their meaning. There is no preferential inertial frame.\n\nA Lorentz transformation can be written in matrix form in the \\((ct, x)\\) plane as:\n\n\\begin{equation}\n  \\Lambda = \\begin{bmatrix}\n    \\gamma & -\\gamma \\beta \\\\\n    -\\gamma \\beta & \\gamma\n  \\end{bmatrix}\n  = \\begin{bmatrix}\n  \\cosh \\theta & -\\sinh \\theta \\\\\n    -\\sinh \\theta &  \\cosh \\theta\n  \\end{bmatrix}\n\\end{equation}\n%\nwhere we introduced the notation \\(\\beta = v / c\\).\n\nThe second equation is justified by the fact that there is an angle \\(\\theta\\) such that \\(\\gamma = \\cosh \\theta\\) and \\(\\gamma \\beta = \\sinh \\theta\\): the angle \\(\\theta\\) will be \\(\\theta = \\tanh^{-1} \\qty(v/c)\\). \nThis is true because \\(\\gamma^2 - \\beta^2 \\gamma^2 = 1\\), which is the same law that the hyperbolic functions obey: \\(\\cosh^2 x - \\sinh^2 x =1 \\) holds for any \\(x\\).\n\nAfter a boost the \\(ct'\\) and \\(x'\\) axes are rotated into, respectively, the lines \\(ct=x/\\beta\\) and \\(ct = \\beta x\\): this comes directly from the transformation law. \nThe \\(ct'\\) axis is defined by the equation \\(x' =0\\), which in the transformed coordinates \\(ct\\) and \\(x\\) reads \\(\\gamma (x - \\beta ct) = 0\\), or \\(ct  = x/ \\beta \\).\n\nSimilarly \\(ct' = 0\\) in the new coordinates reads \\(\\gamma (ct - \\beta x)=0\\), or  \\(ct = \\beta x\\). \n\nThe axes are rotated by an angle which can approach \\(\\pi /4\\) but never reach it, since its tangent is defined by \\(\\beta \\), which can never reach 1. \n\n\\end{document}\n", "meta": {"hexsha": "85907d9dca74f75c0ea541d092c460f31b583a66", "size": 4954, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/03oct.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/03oct.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/03oct.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 47.6346153846, "max_line_length": 348, "alphanum_fraction": 0.6717803795, "num_tokens": 1511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.42879246371765356}}
{"text": "\\chapter{Evaluation}\n\nIn this section, we first categorize \\ematching patterns into three categories. Next, we evaluate our prototype of relational \\ematching with two preliminary experiments, choosing patterns from each of the categories, and discussed our progress on evaluating full-system benchmarks. More experiment will be presented in the forthcoming paper.\n\n\nTo investigate the kinds of conjunctive queries an \\ematching pattern would generate and its performance implication on the join algorithms, we categorize the \\ematching patterns into three categories according to the kinds of conjunctive queries they generate:\n\\begin{enumerate}\n    \\item Linear patterns: this is the simplest form of patterns, where no variables occur more than once in the pattern. Examples of this category include $f(\\alpha, \\beta)$ and $f(g(\\alpha),g(\\beta))$).\n    \\item Non-linear acyclic patterns: we define non-linear acyclic patterns to be patterns that are not linear and satisfy that every multi-occurrence of a variable must occur between \\enodes that has ``distance'' $\\leq 1$ with each other. Examples of this category include  $f(\\alpha,g(\\alpha))$ and $f(f(\\alpha,\\beta), \\alpha)$.\n    \\item Cyclic patterns: we define all other patterns to be cyclic patterns. Examples include $f(g(\\alpha), g(\\alpha))$ and $f(f(\\alpha,\\beta), g(\\beta))$). Note that \\ematching patterns of this category are always reduced to cyclic queries.\n\\end{enumerate}\n\nAll three categories of patterns exist in real-world applications like equality saturation. \nFor example, the search patterns for commutative law (e.g., $a+b$) and associative law (e.g., $(a+b)+c$) is linear, and the search patterns for the distributive law (e.g., $a\\times b+a\\times c$) is cyclic, while that for the rule for reciprocal (e.g., $x\\times (1/x)$) is non-linear acyclic.\n\n\nWe choose two benchmarks from the \\egg's test suites, namely the math test suite, which saturates mathematical expressions, and the lambda test suite, which saturates lambda calculus terms. Both of them are representative of a standard application of equality saturation. For example, the math test suite has many overlapping rules with Herbie \\citep{herbie}, an application of equality saturation in the domain of floating-point arithmetic.\n\nWe did two preliminary experiments. The first experiment tries to understand the asymptotic speedup of relational \\ematching. In this experiment, we manually write the implementation for relational \\ematching for three patterns, which are representative of linear patterns, non-linear acyclic patterns, and cyclic patterns. We benchmark against the \\ematching algorithm in \\egg, which implements the backtracking-based \\ematching algorithm described in \\citet{efficient-ematching}\\footnote{In fact, \\egg does not implement all of the instructions of the backtracking virtual machine described in \\citet{efficient-ematching}, since some of the instructions and their compilation are very complicated.}, on different \\egraph sizes.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/egdb.png}\n    \\caption{Speedup of relational \\ematching over backtracking-based \\ematching algorithms}\n    \\label{fig:bench1}\n\\end{figure}\n\nThe result is shown in Figure \\ref{fig:bench1}. On both cyclic and non-linear acyclic case, our relational \\ematching achieves asymptotically better performance, up to 426$\\times$, over backtracking-based \\ematching by taking advantages of the equality constraints. In the linear\ncase, because no variable occurs more than once, relational \\ematching\nachieves similar performance as the backtracking-based \\ematching up to a constant factor.\\footnote{Note that the comparison here is between the handwritten relational \\ematching, which is compiled, and the \\ematching engine in \\egg, which is interpreted, because this experiment is performed for the PLDI SRC, when we have not developed a fully working version of relational \\ematching inside \\egg. Therefore, the comparison is not perfectly apple-to-apple. However, we can still see the asymptotic trends.}\n\n\\begin{figure}\n\\vspace{-4em}\n     \\centering\n     \\begin{subfigure}[b]{0.8\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/bench2-1.png}\n         \\caption{}\n         \\label{bench2-1}\n     \\end{subfigure}\n     \\\\\n     \\begin{subfigure}[b]{0.8\\textwidth}\n         \\centering\n         \\includegraphics[width=\\textwidth]{figures/bench2-0.png}\n         \\caption{}\n         \\label{bench2-0}\n     \\end{subfigure}\n     \\caption{(a) Speedup of relationl \\ematching over backtracking-based \\ematching on microbenchmarks without index building time. (b) Speedup of relationl \\ematching over backtracking-based \\ematching on microbenchmarks with index building time.}\n     \\label{bench2}\n\\end{figure}\n\n\nNext, we compare the performance of relational \\ematching as we implemented in \\egg against \\egg's original \\ematching implementation on several benchmarks. The result is presented with two figures in Figure \\ref{bench2}. Figure~\\ref{bench2-1} only compares the enumeration procedure of backtracking-based \\ematching to that of relational \\ematching, excluding time that may need to build the index before performing generic join, which are shared among different patterns, and Figure~\\ref{bench2-1} makes the same comparison but includes the index building time.\n\nAccording to Figure~\\ref{bench2-1}, relational \\ematching achieves substantial speedups for complex patterns. However, on some simple patterns, relational \\ematching does not achieve a significant speedup compared to backtracking-based \\ematching algorithms, and sometimes relational \\ematching is slower.\nMost of such patterns are linear patterns like \\texttt{(+ (+ ?a ?b) ?c)} and \\texttt{(fix ?v ?e)}. In particular, patterns like \\texttt{(fix ?v ?e)} are equivalent to a simple enumeration of all $f$-application terms for some function symbol $f$, which we call singleton patterns. The relational \\ematching has the most slowdown on several singleton patterns because running singleton patterns is very fast, taking only a few microseconds, so the overhead related to relational \\ematching such as query compilation dominates the run time. Still, because they only take a few microseconds, the run time for matching such patterns are not an issue for real applications. Moreover,  note the relational \\ematching performs order of magnitude  better on pattern \\texttt{(* ?a ?a)}, which is a singleton pattern, as our query optimizer exploits the fact that both children of the *-application node are the same and thus only does a filter over the corresponding relation. In contrast, backtracking-based \\ematching without ad hoc handling can only express this as a backtracking process, which has a larger overhead.\n\nComparing Figure~\\ref{bench2-1} against  Figure~\\ref{bench2-0}, we observe the time taken for building indices to be significant. Many plans where relational \\ematching is faster now becomes slower. This is consistent with the observation made by \\cite{eval-wcoj}, where index building is sometimes the bottleneck of the generic join algorithm. Since our current implementation is only a prototype, we are currently working on improving the index building time so that the performance of relational \\ematching is able to dominate that of the current implemented \\ematching in \\egg.\n \nFinally, our next step of experiment is to evaluate relational \\ematching on full-system applications that use \\egg. We attempted to run Herbie with relational \\ematching as the \\ematching procedure. However, we are unable to observe any significant speedup by using relational \\ematching. We speculate the cause is that the workload of Herbie is running only simple, linear patterns on small \\egraphs, so there are no additional equality constraints that relational \\ematching could exploit. We are working on evaluating relational \\ematching on other applications, such as Tensat \\citep{tensat} and Szalinski \\citep{2020-pldi-szalinski-cad-eqsat}.", "meta": {"hexsha": "d9a3c350dbf0648e2852bd84465bb42d39979f10", "size": 8028, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/6-evaluations.tex", "max_stars_repo_name": "yihozhang/UWThesis", "max_stars_repo_head_hexsha": "286aa777bd528b8da3ec86b717dc1f7f39d89816", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/6-evaluations.tex", "max_issues_repo_name": "yihozhang/UWThesis", "max_issues_repo_head_hexsha": "286aa777bd528b8da3ec86b717dc1f7f39d89816", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/6-evaluations.tex", "max_forks_repo_name": "yihozhang/UWThesis", "max_forks_repo_head_hexsha": "286aa777bd528b8da3ec86b717dc1f7f39d89816", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 133.8, "max_line_length": 1112, "alphanum_fraction": 0.7848779273, "num_tokens": 1782, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.42879245903636354}}
{"text": "\\problemname{Red, Black Cards}\n%\\illustration{.5}{filename}{Image by \\href{url}{Author}}\n\nJohn is playing a fancy card game with Bowen.\n$N$ cards are laid on the table, facing down.\nThe cards are numbered from $1$ to $N$.\nEach card has a color, and is either red or black.\nThe colors of the cards are unknown to John.\nJohn's goal is to correctly identify the colors of all the cards without looking at any card.\nFor that, he asks Bowen $Q$ questions.\nJohn's questions are numbered from $1$ to $Q$.\nEach question may ask about whether a pair of cards have the same color, or what color a particular card has.\nBowen checks the colors of cards for John according to John's questions.\nJohn thus receives a sequence of $Q$ answers, each being one of the following:\n\n\\begin{itemize}\n\\item {\\tt d x y} : Card $x$ and card $y$ have different colors.\n\\item {\\tt s x y} : Card $x$ and card $y$ have a same color.\n\\item {\\tt r x} : Card $x$ has red color.\n\\item {\\tt b x} : Card $x$ has black color.\n\\end{itemize}\n\n\nHowever, since John asks so many questions, Bowen gets tired and sometimes made mistakes in answering the questions.\nFortunately, being a clever player, John can immediately catch Bowen's mistake if there is a contradiction from Bowen's answers.\nWhen that happens, the current answer that results in a contradiction is void and the game proceeds.\nThe game ends immediately as soon as John gets enough information to identify the colors of all the cards.\nThe game also ends after $Q$ questions are all answered, even if John did not successfully identify the colors.\n\nIn this task, you will go over the questions asked by John and the answers to those questions given by Bowen.\nYou are to reproduce John's responses during the game.\n\n\\section*{Input}\nThe first line of the input has an integer $T$, the number of games played.\\\\\nEach case has two integer $N, Q$ on the first line.\\\\\nThe next $Q$ lines describe John's questions and their answers.\nEach line is in one of the four forms given above.\\\\\nThe first letter of each line is `{\\tt d}', `{\\tt s}', `{\\tt r}' or `{\\tt b}'.\nIf the letter is `{\\tt d}' or `{\\tt s}', the question asks about whether a pair of cards have the same color, and has two following integers giving a pair of card numbers.\nIf the letter is `{\\tt r}' or `{\\tt b}', the question asks about the color of a single card, and has one following integer giving the number of that card.\\\\\nDuplicate questions may be asked, but it is possible that Bowen gave different answers to a same question (which results in contradiction).\n\\section*{Output}\n\nThere are two types of outputs, {\\it response} and {\\it result}.\\\\\n\nIf the answer to a question leads to a contradiction or John's success on the game, print a {\\it response}:\n\\begin{itemize}\n\\item If it is a contradiction, output a single question mark ``{\\tt ?}''.\nNote that this answer is then ignored and not used for identifying colors.\n\\item If John can successfully identify the colors of all the cards, output ``{\\tt I know}''.\nThe game then ends immediately and all the following questions are ignored.\n\\end{itemize}\n\nPrint the question number before each {\\it response}.\nRefer to the sample output for formatting details of question numbers.\\\\\n\nAt the end of the game, print the {\\it result} of the game on a new line:\n\\begin{itemize}\n\\item If the game ends with John's success, output a string with $N$ letters.\nThe $i$-th letter is either `{\\tt r}' or `{\\tt b}' to describe the color of card $i$ being red or black.\n\\item If John is not able to identify the colors after all the $Q$ questions, output ``{\\tt I am not sure}''.\n\\end{itemize}\n\n\\section*{Constraints}\n\\begin{itemize}\n\\item $1 \\leq T\\leq 15$\n\\item $1 \\leq N \\leq 10^5$\n\\item $1 \\leq Q \\leq 10^5$\n\\item $1\\leq x, y \\leq N, x \\neq y$ for all the answers to John's questions.\n\\end{itemize}\n\n\\section*{Subtasks}\n\\begin{itemize}\n\\item Original constraints\n\\end{itemize}\n", "meta": {"hexsha": "86b142c15d7979f34f3c179b872a36c2d7c022f5", "size": 3910, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "server/test_root/problem/cards/problem_statement/problem.en.tex", "max_stars_repo_name": "yubowenok/coda", "max_stars_repo_head_hexsha": "29f2fd090c644b9dc1f4fa506da2dee1bd4f4102", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-09-27T04:45:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-12T01:31:40.000Z", "max_issues_repo_path": "server/test_root/problem/cards/problem_statement/problem.en.tex", "max_issues_repo_name": "yubowenok/coda", "max_issues_repo_head_hexsha": "29f2fd090c644b9dc1f4fa506da2dee1bd4f4102", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-07-18T09:28:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T16:03:33.000Z", "max_forks_repo_path": "server/test_root/problem/cards/problem_statement/problem.en.tex", "max_forks_repo_name": "yubowenok/coda", "max_forks_repo_head_hexsha": "29f2fd090c644b9dc1f4fa506da2dee1bd4f4102", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-29T20:59:27.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-29T20:59:27.000Z", "avg_line_length": 51.4473684211, "max_line_length": 171, "alphanum_fraction": 0.737084399, "num_tokens": 1012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.4286968293265634}}
{"text": "\\subsubsection{\\stid{3.14} ALExa}\n\n\n\\paragraph{Overview}\n\nThe ALExa project ({\\sl Accelerated Libraries for Exascale}) focuses on\npreparing the DTK and Tasmanian libraries for exascale platforms and\nintegrating these libraries into ECP applications.  These libraries deliver\ncapabilities identified as needs of ECP applications: (1) the ability to\ntransfer computed solutions between grids with differing layouts on parallel\naccelerated architectures, enabling multiphysics projects to seamlessly\ncombine results from different computational grids to perform their required\nsimulations (DTK); and\n%\n(2) the ability to construct fast and memory efficient surrogates to large\nscale engineering models with multiple inputs and large number of outputs,\nenabling uncertainty quantification (both forward and inverse) as well as\noptimization and efficient multi-physics simulations in projects such as\nExaStar (Tasmanian).\n\nThese capabilities are being developed through ongoing interactions with our\nECP application project collaborators to ensure they will satisfy requirements\nof these customers.  The libraries in turn take advantage of other ECP/SW\ncapabilities currently in development, including Trilinos and ForTrilinos,\nKokkos and SLATE.  The final outcome of the ECP project will be a set of\nlibraries deployed to facilities and also made broadly available as part of\nthe xSDK4ECP project.\n\n\n{\\bf DTK} (Data Transfer Kit)\n\n{\\it Purpose:} Transfers computed solutions between grids with differing\nlayouts on parallel accelerated architectures.\n\n{\\it Significance:} Coupled applications frequently have different grids with\ndifferent parallel distributions; DTK is able to transfer solution values\nbetween these grids efficiently and accurately.\n\n{\\it Mesh and mesh-free interpolation capabilities:} multivariate data\ninterpolation between point clouds and grids; compactly supported radial basis\nfunctions; nearest-neighbor and moving least square implementations; support\nfor standard finite-element shape functions and user-defined interpolants;\ncommon applications include conjugate heat transfer, fluid structure\ninteraction, and mesh deformation.\n\n{\\it Performance portable search capabilities:} shared memory and GPU\nimplementations of spatial tree construction; shared memory and GPU\nimplementations of various spatial tree queries; MPI front-end for\ncoordinating distributed spatial searches between sets of geometric objects\nwith different decompositions; communication plan generation based on spatial\nsearch results.\n\n{\\it URL:} https://github.com/ORNL-CEES/DataTransferKit\n\n\n{\\bf Tasmanian} (Toolkit for Adaptive Stochastic Modeling and Non-Intrusive\nApproximation)\n\n{\\it Purpose:} Constructs efficient surrogate models for high dimensional\nproblems and performs parameter calibration and optimization geared towards\napplications in uncertainty quantification (UQ).\n\n{\\it Significance:} UQ pertains to the statistical properties of the output\nfrom a complex model with respect to variability in multiple model inputs;\nlarge number of simulations are required to compute reliable statistics which\nis prohibitive when dealing with computationally expensive engineering\nmodels. A surrogate model is constructed from a moderate set of simulations\nusing carefully chosen input values; analysis can then be performed on the\nefficient surrogate.\n\n{\\it Sparse grids capabilities:} surrogate modeling and design of experiments\n(adaptive multi-dimensional interpolation); reduced (lossy) representation of\ntabulated scientific data; high dimensional numerical quadrature; data mining\nand manifold learning.\n\n{\\it DiffeRential Evolution Adaptive Metropolis (DREAM) capabilities:}\nBayesian inference; parameter estimation/calibration; model validation.\nglobal optimization and optimization under uncertainty.\n\n{\\it URL:} http://tasmanian.ornl.gov\n\n\\paragraph{Key Challenges}\n\n\\indent\n\n{\\bf DTK:} General data transfer between grids of unrelated applications\nrequires many-to-many communication which is increasingly challenging as\ncommunication to computation ratios are decreasing on successive HPC systems.\nSearch procedures to locate neighboring points and mesh cells require tree\nsearch methods difficult to optimize on modern accelerated architectures due\nto vector lane or thread divergence. Maintaining high accuracy for the\ntransfer requires careful attention to the mathematical properties of the\ninterpolation methods and is highly application-specific.\n\n{\\bf Tasmanian:} Complex models usually have significant variability in\nexecution time for different model inputs, which leads to massive down-time\nwhen employing the standard fork-join adaptive sparse grid algorithms.  After\nthe surrogate has been constructed, collecting the samples for statistical\nanalysis (or multi-physics simulations) requires a massive number of basis\nevaluations and many sparse and dense linear operations.\n\n\\paragraph{Solution Strategy}\n\n\\nobreak\n\n\n\\indent\n\n{\\bf DTK:} State-of-the-art, mathematically rigorous methods are used in DTK\nto preserve accuracy of interpolated solutions.  Algorithms are implemented in\na C++ code base with extensive unit testing on multiple platforms.  Trilinos\npackages are used to support interpolation methods.  Kokkos is used to achieve\nperformance portability across accelerated platforms.\n\n{\\bf Tasmanian:} Implement asynchronous DAG-based sparse grids construction\nmethods that preserve the convergence properties of the fork-join algorithms\nbut are insensitive to fluctuations in model simulation time.  Port the basis\nevaluations and linear algebra to the GPU accelerators, and leverage the\nSLATE/MAGMA capabilities to ensure performance portability across relevant\nplatforms.\n\n\n%----------------------------------------\n\n\\paragraph{Recent Progress}\n\n\\indent\n\n{\\bf DTK:} Extensive optimization work has yielded significant performance\nimprovements on accelerated and heterogeneous architectures. Work with partner\napplication ExaAM (WBS 2.2.1.05) created a preliminary multiphysics driver\ncapability for additive manufacturing simulations.\n\n\\begin{figure}[htb]\n        \\centering\n        \\includegraphics[width=3.0in]{projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/dtk-gpu}\n        \\caption{\\label{fig:dtk-gpu}DTK search performance relative to Boost with Intel Xeon E5-2698 and Nvidia P100. 10M points randomly distributed in a unit cube, 1M queries. The time is in seconds. Speedup in bold.}\n\\end{figure}\n\n{\\bf Tasmanian:} The infrastructure of Tasmanian has been upgraded to support\nthe broader ECP focus of the work.  GPU acceleration of sparse grid surrogates\nhas been implemented.  Tasmanian recently enabled the ExaStar project to\nreduce the size of a large-memory table of neutrino opacities by 100X while\nstill preserving accuracy.\n\n\\begin{figure}[htb]\n        \\centering\n        \\includegraphics[width=1.5in]{projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/tasmanian-gpu}\n        \\caption{\\label{fig:tasmanian-gpu}Tasmanian approximation (right) of neutrino capacities (left).}\n\\end{figure}\n\n%----------------------------------------\n\n\\paragraph{Next Steps}\n\n\\indent\n\n{\\bf DTK:} DTK search and communication capabilities will deployed in a new,\nlightweight library, ArborX, to provide these ECP investments to a broader\nuser base.\n\n{\\bf Tasmanian:} Work will continue with the development of the asynchronous\nconstruction methods that exploit the native sparse grids DAG hierarchy.\n\n%----------------------------------------\n", "meta": {"hexsha": "4174c3f49cd7026fe466445943690cc475c751cf", "size": 7475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_stars_repo_name": "mikiec84/ECP-ST-CAR-PUBLIC", "max_stars_repo_head_hexsha": "b9d6e478ed34830e0ae83693564ced7e044e2b12", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_issues_repo_name": "mikiec84/ECP-ST-CAR-PUBLIC", "max_issues_repo_head_hexsha": "b9d6e478ed34830e0ae83693564ced7e044e2b12", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_forks_repo_name": "mikiec84/ECP-ST-CAR-PUBLIC", "max_forks_repo_head_hexsha": "b9d6e478ed34830e0ae83693564ced7e044e2b12", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.0301204819, "max_line_length": 219, "alphanum_fraction": 0.8061538462, "num_tokens": 1546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.42869682932656333}}
{"text": "\\documentclass[twocolumn]{scrartcl}\n\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{fixltx2e}\n\n% Step environment\n% <https://tex.stackexchange.com/a/12943/13262>\n\\usepackage{amsthm}\n\\newtheorem*{remark}{Remark}\n%\n\\newtheoremstyle{named}{}{}{\\itshape}{}{\\bfseries}{.}{.5em}{\\thmnote{#1 }#3}\n\\theoremstyle{named}\n\\newtheorem*{step}{Step}\n\n\\usepackage{microtype}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{booktabs}\n\\usepackage{tabularx}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=newest}\n\n\\usepackage{siunitx}\n\n\\newcommand\\mytitle{Algorithmic improvements for the CIECAM02 and CAM16 color appearance models}\n\\newcommand\\myauthor{Nico Schlömer}\n\n\\usepackage[\n  pdfencoding=unicode,\n  ]{hyperref}\n\\hypersetup{\n  pdfauthor={\\myauthor},\n  pdftitle={\\mytitle}\n}\n\n% <https://tex.stackexchange.com/a/43009/13262>\n\\DeclarePairedDelimiter\\abs{\\lvert}{\\rvert}%\n\n\\usepackage[T1]{fontenc}\n\\usepackage{newtxtext}\n\\usepackage{newtxmath}\n\n% degree symbol\n\\usepackage{gensymb}\n\n% % <https://tex.stackexchange.com/a/413899/13262>\n% \\usepackage{etoolbox}\n% \\makeatletter\n% \\long\\def\\etb@listitem#1#2{%\n%   \\expandafter\\ifblank\\expandafter{\\@gobble#2}\n%     {}\n%     {\\expandafter\\etb@listitem@i\n%      \\expandafter{\\@secondoftwo#2}{#1}}}\n% \\long\\def\\etb@listitem@i#1#2{#2{#1}}\n% \\makeatother\n\n% Okay. Don't use biblatex/biber for now. There are breaking changes in every\n% revision, and we'd have to stick to the exact version that arxiv.org has,\n% otherwise it's error messages like\n% ```\n% Package biblatex Warning: File 'main.bbl' is wrong format version\n% - expected 2.8.\n% ```\n% \\usepackage[sorting=none]{biblatex}\n% \\bibliography{bib}\n\n\\usepackage{amsmath}\n\\DeclareMathOperator{\\sign}{sign}\n\n\\usepackage{bm}\n\\newcommand\\rgb{\\bm{R}}\n\n\\title{\\mytitle\\footnote{The LaTeX sources of this article are on \\url{https://github.com/nschloe/note-on-cam16}}}\n\\author{\\myauthor}\n\n\\begin{document}\n\n\\maketitle\n\\begin{abstract}\n  This note is concerned with the CIECAM02 color appearance model and its\n  successor, the CAM16 color appearance model. Several algorithmic flaws are\n  pointed out and remedies are suggested. The resulting color model is\n  algebraically equivalent to CIECAM02/CAM16, but shorter, more efficient, and\n  works correctly for all edge cases.\n\\end{abstract}\n\n\\section{Introduction}\n\nThe CIECAM02 color appearance model~\\cite{ciecam02} has attracted much\nattention and was generally thought of as a successor to the ever so popular\nCIELAB color model. However, it was quickly discovered that CIECAM02 breaks\ndown for certain input values. A fair number of research articles suggests\nfixes for this behavior, most of them by modifying the first steps of the\nforward model. Luo and Li give an overview of the suggested\nimprovements~\\cite{ciecam02-recent}; see references therein.  Most recently,\nLi and Luo~\\cite{cam16} gave their own suggestion on how to best\ncircumvent the breakdown~\\cite{cam16}. The updated algorithm differs from the\noriginal CIECAM02 only in the first steps of the forward model.\n\nIt appears that that the rest of the algorithm has not received much attention\nover the years. In both CIECAM02 and its updated version CAM16, some of the\nsteps are more complicated than necessary, and in edge cases lead to break\ndowns once again. The present document describes those flaws and suggests\nimprovements (Section~\\ref{sec:ff}). The resulting model description\n(Section~\\ref{sec:full}) is entirely equivalent to the CIECAM02/CAM16, but is\nsimpler -- hence faster and easier to implement -- and works in all edge\ncases.\n\nAll findings in this article are implemented in the open-source software package\ncolorio~\\cite{colorio}.\n\n\n\\section{Flaws and fixes}\\label{sec:ff}\n\nThis section describes the flaws of CAM16 and suggests fixes for them. Some of\nthem are trivial, others are harder to see. All listed steps also appear in the\nCIECAM02 color appearance model and trivially apply there.\n\n\\subsection{Step 3, forward model}\n\nThe original Step 3 of the forward model reads\n\n\\begin{step}[3]\nCalculate the postadaptation cone response\n(resulting in dynamic range compression).\n\\[\n  R_a = 400 \\frac{\\left(\\frac{F_L R_c}{100}\\right)^{0.42}}{\\left(\\frac{F_L R_c}{100}\\right)^{0.42} + 27.13} + 0.1\n\\]\nIf $R_c$ is negative, then\n\\[\n  R_a = -400 \\frac{\\left(\\frac{-F_L R_c}{100}\\right)^{0.42}}{\\left(\\frac{-F_L R_c}{100}\\right)^{0.42} + 27.13} + 0.1\n\\]\nand similarly for the computations of $G_a$ and $B_a$.\n\\end{step}\n\nIf the $\\sign$ operator is used here as it is used later in step 5 of the\ninverse model, the above description can be shortened.\n\nFurthermore, the term $0.1$ is added here, but in all of the following steps in\nwhich $R_a$ is used -- except the computation of $t$ in Step 9 --, it cancels\nout algebraically.  Unfortunately, said cancellation is not always exact when\ncomputed in floating point arithmetic. Luckily, the adverse effect of such\nrounding errors is rather limited here. The results will only be distorted for\nvery small input values, e.g., $X=Y=Z=0$; see Table~\\ref{tab:zero}. For the\nsake of consistency, it is advisable to include the term $0.1$ only in the\ncomputation of $t$ in Step 9:\n\\[\n  R'_a = 400 \\sign(R_c) \\frac{{\\left(\\frac{F_L \\abs{R_c}}{100}\\right)}^{0.42}}{{\\left(\\frac{F_L \\abs{R_c}}{100}\\right)}^{0.42} + 27.13}.\n\\]\n\n\n\\begin{table}\\centering\n  \\begin{tabularx}{\\linewidth}{XXX}\n  \\toprule\n          & with fixes & without\\\\\n  \\midrule\n    $J$ & \\texttt{0.0} & \\texttt{3.258e-22}\\\\\n    $C$ & \\texttt{0.0} & \\texttt{4.071e-24}\\\\\n    $h$ & \\texttt{0.0} & \\texttt{0.0}\\\\\n    $Q$ & \\texttt{0.0} & \\texttt{2.233e-10}\\\\\n    $M$ & \\texttt{0.0} & \\texttt{2.943e-24}\\\\\n    $s$ & \\texttt{0.0} & \\texttt{1.148e-05}\\\\\n  \\bottomrule\n\\end{tabularx}\n\\caption{CAM16 values upon input $X=Y=Z=0$ with and without the fixes in\n  this article.  The exact solutions are zeros for every\n  entry.}\\label{tab:zero}\n\\end{table}\n\n\\subsection{Linear combinations, forward model}\n\nIn the forward model, four linear combinations of $R'_a$, $G'_a$, and $B'_a$\nhave to be formed. They can conveniently be expressed as the matrix-vector\nmultiplication\n\\[\n  \\begin{pmatrix}\n    p'_2\\\\[0.5ex]\n    a\\\\[0.5ex]\n    b\\\\[0.5ex]\n    u\n  \\end{pmatrix}\n  \\coloneqq\n  \\begin{pmatrix}\n    2 & 1 & \\tfrac{1}{20}\\\\[0.5ex]\n    1 & -\\tfrac{12}{11} & \\tfrac{1}{11}\\\\[0.5ex]\n    \\tfrac{1}{9} & \\tfrac{1}{9} & -\\tfrac{2}{9}\\\\[0.5ex]\n    1 & 1 & \\tfrac{21}{20}\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    R'_a\\\\G'_a\\\\B'_a\n  \\end{pmatrix}\n\\]\nwhich on many platforms can be computed significantly faster than four\nindividual dot-products.\nThe last variable $u$ is used in the computation of $t$ in step 9.\n\n\n\n\\subsection{Step 9, forward model}\n\n\\begin{step}[9]\n  Calculate the correlates of [\\dots] saturation ($s$).\n  \\[\n    s \\coloneqq 100 \\sqrt{M/Q}.\n  \\]\n\\end{step}\nThis expression is not well-defined if $Q=0$, a value occurring if the\ninput values are $X=Y=Z=0$. When making use of the definition of $M$ and $Q$,\none gets to an expression for $s$ that is well-defined in all cases:\n\\begin{align}\n  \\label{eq:alpha}\n  \\alpha&\\coloneqq t^{0.9} {(1.64-0.29^n)}^{0.73},\\\\\n  \\nonumber\n  s &\\coloneqq 50 \\sqrt{\\frac{c\\alpha}{A_w + 4}}.\n\\end{align}\n\n\n\\subsection{Steps 2 and 3, inverse model}\n\n\\begin{step}[2]\nCalculate $t$, $e_t$, $p_1$, $p_2$, and $p_3$.\n\\begin{align*}\n  t &= {\\left(\\frac{C}{\\sqrt{\\frac{J}{100}} {(1.64 - 0.29^n)}^{0.73}}\\right)}^\\frac{1}{0.9},\\\\\n  e_t &= \\frac{1}{4} \\left[\\cos(h'\\pi/180\\degree + 2) + 3.8\\right],\\\\\n  p_1 &= \\frac{50000}{13} N_c N_{cb} e_t \\frac{1}{t},\\\\\n  p_2 &= \\frac{A}{N_{bb}} + 0.305,\\\\\n  p_3 &= \\frac{21}{20}.\n\\end{align*}\n\\end{step}\n\n\\begin{step}[3]\nCalculate $a$ and $b$.\nIf $t=0$, then $a=b=0$ and go to Step 4.\nIn the next computations be sure transform $h$ from degrees to radians before\ncalculating $\\sin(h)$ and $\\cos(h)$: If $\\abs{\\sin(h)} \\ge \\abs{\\cos(h)}$\nthen\n\\begin{align*}\n  p_4 &= \\frac{p_1}{\\sin(h)},\\\\\n  b &= \\frac{p_2 (2+p_3) \\frac{460}{1403}}{p_4 + (2+p_3) \\frac{220}{1403} \\frac{\\cos(h)}{\\sin(h)} - \\frac{27}{1403} + p_3 \\frac{6300}{1403}},\\\\\n  a &= b \\frac{\\cos(h)}{\\sin(h)}.\n\\end{align*}\nIf $\\abs{\\cos(h)} > \\abs{\\sin(h)}$ then\n\\begin{align*}\n  p_5 &= \\frac{p_1}{\\cos(h)},\\\\\n  a &= \\frac{p_2 (2+p_3) \\frac{460}{1403}}{%\n    p_5\n    + (2+p_3) \\frac{220}{1403} -\n    \\left(\\frac{27}{1403}  - p_3 \\frac{6300}{1403}\\right) \\frac{\\sin(h)}{\\cos(h)}\n  },\\\\\n  b &= a \\frac{\\sin(h)}{\\cos(h)}.\n\\end{align*}\n\\end{step}\n\nSome of the complications in this step stem from the fact that the variable $t$\nmight be $0$ in the denominator of $p_1$. Likewise, the distinction of cases in $\\sin(h)$ and $\\cos(h)$ is necessary\nto avoid division by $0$ in $a$ and $b$.\n\nIt turns out that both of these problems can be avoided quite elegantly.\nConsider, in the case $\\abs{\\sin(h)} \\ge \\abs{\\cos(h)}$:\n\\begin{align*}\n  p'_1 &\\coloneqq \\frac{50000}{13} N_c N_{cb} e_t,\\\\\n  b &= \\frac{p_2 (2+p_3) \\frac{460}{1403}}{\\frac{p'_1}{t\\sin(h)} + (2+p_3) \\frac{220}{1403} \\frac{\\cos(h)}{\\sin(h)} - \\frac{27}{1403} + p_3 \\frac{6300}{1403}}\\\\\n   &= \\frac{t \\sin(h) p_2 (2+p_3) \\frac{460}{1403}}{p'_1 + t (2+p_3) \\frac{220}{1403} \\cos(h) + t \\sin(h) \\frac{6588}{1403}}\\\\\n   &= \\frac{23 t \\sin(h) p_2}{23 p'_1 + 11 t \\cos(h) + 108 t \\sin(h)},\n\\end{align*}\nand\n\\[\n  a = \\frac{23 t \\cos(h) p_2}{23 p'_1 + 11 t \\cos(h) + 108 t \\sin(h)}.\n\\]\nConveniently, the exact same expressions are retrieved in the case\n$\\abs{\\cos(h)} > \\abs{\\sin(h)}$. These expressions are always well-defined since\n\\begin{multline*}\n  23 p'_1 + 11 t \\cos(h) + 108 t \\sin(h)\\\\\n  = \\frac{23 p'_1 p_2}{R'_a + G'_a + \\tfrac{21}{20}B'_a + 0.305}\n  > 0.\n\\end{multline*}\n\nIn the algorithm, the value of $t$ can be retrieved via\n$\\alpha$~\\eqref{eq:alpha} from the input variables. Indeed, if the saturation\ncorrelate $s$ is given, one has\n\\[\n  \\alpha \\coloneqq {\\left(\\frac{s}{50}\\right)}^2 \\frac{A_w+4}{c};\n\\]\nif $M$ is given, one can compute $C\\coloneqq M / F_L^{0.25}$ and then\n\\[\n\\alpha\\coloneqq\\begin{dcases*}\n  0 &if $J=0$,\\\\\n  \\frac{C}{\\sqrt{J/100}}&otherwise.\n\\end{dcases*}\n\\]\nIt is mildly unfortunate that one has to introduce a case distinction for\n$J=0$ here, but this is an operation that can still be performed at reasonable\nefficiency.\n\n\\begin{figure}\n\\input{perf.tex}\n  \\caption{Performance comparison of the conversion from CAM16 to XYZ (with\n  $J$, $C$, and $h$), implemented in colorio~\\cite{colorio}. The suggested\n  improvements in the inverse model lead to a speed-up of about 5\\%.}\n\\end{figure}\n\n\\appendix\n\\section{Full model\\label{sec:full}}\n\nFor the convenience of the reader, both forward and inverse steps of the\nimproved CAM16 algorithm are given here. The wording is taken from~\\cite{cam16}\nwhere applicable.\nThe steps that differ from the original model are marked with an asterisk~(*).\n\nAs an abbreviation, the bold letter $\\rgb$ is used whenever the equation applies\nto $R$, $G$, and $B$ alike.\n\n\\paragraph{Illuminants, viewing surrounds set up and background\nparameters}\n(See the note at the end of Part 2 of Appendix B of~\\cite{cam16} for determining\nall parameters.)\n\n\\begin{itemize}\n  \\item Adopted white in test illuminant: $X_w$, $Y_w$, $Z_w$\n  \\item Background in test conditions: $Y_b$\n  \\item Reference white in reference illuminant:\n    $X_{wr}=Y_{wr} = Z_{wr}=100$, fixed in the model\n  \\item Luminance of test adapting field (\\si{\\candela\\per\\meter\\squared}): $L_A$.\n$L_A$ is computed using\n    \\[\n      L_A = \\frac{E_W}{\\pi} \\frac{Y_b}{Y_W} = \\frac{L_W Y_b}{Y_W},\n    \\]\n  where $E_W =\\pi L_W$ is the illuminance of reference white in \\si{\\lux};\n    $L_W$ is the luminance of reference white in\n    \\si{\\candela\\per\\meter\\squared}; $Y_b$ is the luminance factor of the\n    background; and $Y_w$ is the luminance factor of the reference white.\n\n  \\item Surround parameters are given in Table~\\ref{tab:surround}:\nTo determine the surround conditions see the note at the\n    end of Part 1 of Appendix A of~\\cite{cam16}.\n\\item $N_c$ and $F$ are modelled as a function of $c$, and their values\n  can be linearly interpolated, using the data from~\\ref{tab:surround}.\n\\end{itemize}\n\nLet $M_{16}$ be given by\n\\[\n  M_{16} \\coloneqq \\begin{pmatrix}\n    0.401288  & 0.650173 & -0.051461\\\\\n    -0.250268 & 1.204414 & 0.045854\\\\\n    -0.002079 & 0.048952 & 0.953127\n  \\end{pmatrix}.\n\\]\n\n\\subsection{Forward model}\n\n\\begin{step}[0*]\nCalculate all values/parameters which are independent\nof the input sample.\n\\begin{align*}\n  &\\begin{pmatrix}R_w\\\\G_w\\\\B_w\\end{pmatrix}\n    = M_{16}\n  \\begin{pmatrix}X_w\\\\Y_w\\\\Z_w\\end{pmatrix},\\\\\n  &D = F \\left[1 - \\tfrac{1}{3.6} \\exp\\left(\\tfrac{-L_a-42}{92}\\right)\\right].\n\\end{align*}\nIf $D$ is greater than one or less than zero, set it to one or zero,\nrespectively.\n\\begin{align*}\n  &D_{\\rgb} = D\\frac{Y_W}{\\rgb_W} -1 + D,\\\\\n  &k = \\frac{1}{5L_A + 1},\\\\\n  &F_L = k^4 L_A + 0.1 {(1-k^4)}^2 {(5L_A)}^{1/3},\\\\\n  &n = \\frac{Y_b}{Y_W},\\\\\n  &z = 1.58 + \\sqrt{n},\\\\\n  &N_{bb} = \\frac{0.725}{n^{0.2}},\\\\\n  &N_{cb} = N_{bb},\\\\\n  &\\rgb_{wc} = D_{\\rgb} \\rgb_w,\\\\\n  &\\rgb_{aw} = 400\n  \\frac\n  {{\\left(\\frac{F_L \\rgb_{wc}}{100}\\right)}^{0.42}}\n  {{\\left(\\frac{F_L \\rgb_{wc}}{100}\\right)}^{0.42} + 27.13},\\\\\n  &A_w = \\left(2R_{aw} + G_{aw} + \\tfrac{1}{20} B_{aw}\\right) \\cdot N_{bb}.\n\\end{align*}\n\\end{step}\n\n\\begin{table}\\centering\n  \\begin{tabularx}{\\linewidth}{XXXX}\n  \\toprule\n          & $F$ & $c$   & $N_c$\\\\\n  \\midrule\n  Average & 1.0 & 0.69  & 1.0\\\\\n  Dim     & 0.9 & 0.59  & 0.9\\\\\n  Dark    & 0.8 & 0.525 & 0.8\\\\\n  \\bottomrule\n\\end{tabularx}\n  \\caption{Surround parameters.}\\label{tab:surround}\n\\end{table}\n\n\n\\begin{table}\\centering\n  \\begin{tabularx}{\\linewidth}{XXXXXX}\n  \\toprule\n        & Red   & Yellow & Green & Blue   & Red\\\\\n  \\midrule\n  $i$   & 1     & 2     & 3      & 4      & 5\\\\\n  $h_i$ & 20.14 & 90.00 & 164.25 & 237.53 & 380.14\\\\\n  $e_i$ & 0.8   & 0.7   & 1.0    & 1.2    & 0.8\\\\\n  $H_i$ & 0.0   & 100.0 & 200.0  & 300.0  & 400.0\\\\\n  \\bottomrule\n\\end{tabularx}\n  \\caption{Unique hue data for calculation of hue quadrature.}\\label{table:hue}\n\\end{table}\n\n\\begin{step}[1]\nCalculate `cone' responses.\n\\[\n\\begin{pmatrix}R\\\\G\\\\B\\end{pmatrix}\n= M_{16} \\begin{pmatrix}X\\\\Y\\\\Z\\end{pmatrix}\n\\]\n\\end{step}\n\n\\begin{step}[2]\nComplete the color adaptation of the illuminant in\nthe corresponding cone response space (considering various\nluminance levels and surround conditions included in $D$, and\nhence in $D_R$, $D_G$, and $D_B$).\n\\[\n  \\rgb_c = D_{\\rgb} \\cdot \\rgb\n\\]\n\\end{step}\n\n\\begin{step}[3*]\nCalculate the modified postadaptation cone response\n(resulting in dynamic range compression).\n\\[\n  \\rgb'_a = 400 \\sign(\\rgb_c)\n    \\frac\n    {{\\left(\\frac{F_L \\abs{\\rgb_c}}{100}\\right)}^{0.42}}\n    {{\\left(\\frac{F_L \\abs{\\rgb_c}}{100}\\right)}^{0.42} + 27.13}.\n\\]\n\\end{step}\n\n\\begin{step}[4*]\nCalculate Redness--Greenness ($a$), Yellowness--Blueness ($b$) components,\n  hue angle ($h$), and auxiliary variables ($p'_2$, $u$).\n\\begin{align*}\n  \\begin{pmatrix}\n    p'_2\\\\[0.5ex]\n    a\\\\[0.5ex]\n    b\\\\[0.5ex]\n    u\n  \\end{pmatrix}\n  &\\coloneqq\n  \\begin{pmatrix}\n    2 & 1 & \\tfrac{1}{20}\\\\[0.5ex]\n    1 & -\\tfrac{12}{11} & \\tfrac{1}{11}\\\\[0.5ex]\n    \\tfrac{1}{9} & \\tfrac{1}{9} & -\\tfrac{2}{9}\\\\[0.5ex]\n    1 & 1 & \\tfrac{21}{20}\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    R'_a\\\\G'_a\\\\B'_a\n  \\end{pmatrix},\\\\\n  % a&\\coloneqq R'_a - \\tfrac{12}{11} G'_a + \\tfrac{1}{11} B'_a\\\\\n  % b&\\coloneqq \\tfrac{1}{9} R'_a + \\tfrac{1}{9} G'_a - \\tfrac{2}{9} B'_a\\\\\n  h&\\coloneqq \\arctan(b/a).\n\\end{align*}\n(Make sure that $h$ is between $0\\degree$ and $360\\degree$.)\n\\end{step}\n\n\\begin{step}[5]\nCalculate eccentricity [$e_t$, hue quadrature composition\n($H$) and hue composition ($H_c$)].\n\nUsing the following unique hue data in table~\\ref{table:hue}, set\n$h'= h + 360\\degree$ if $h < h_1$, otherwise $h'=h$.\nChoose a proper $i\\in\\{1,2,3,4\\}$ so that $h_i\\le h' < h_{i+1}$.\nCalculate\n\\[\n  e_t = \\tfrac{1}{4}\n  \\left[\n    \\cos(h'\\pi/180\\degree + 2) + 3.8\n  \\right]\n\\]\nwhich is close to, but not exactly the same as, the eccentricity factor given\nin table~\\ref{table:hue}.\n\nHue quadrature is computed using the formula\n\\[\n  H = H_i + \\frac{100 e_{i+1} (h'-h_i)}{e_{i+1}(h'-h_i) + e_i (h_{i+1}-h')}\n\\]\nand hue composition $H_c$ is computed according to $H$.  If $i=3$ and $H =\n241.2116$ for example, then $H$ is between $H_3$ and $H_4$ (see\ntable~\\ref{table:hue} above). Compute $P_L=H_4-H = 58.7884$; $P_R = H – H_3 =\n41.2116$ and round $P_L$ and $P_R$ values to integers $59$ and $41$. Thus,\naccording to table~\\ref{table:hue}, this sample is considered as having 59\\%\nof green and 41\\% of blue, which is the $H$c and can be reported as 59G41B or\n41B59G.\n\\end{step}\n\n\\begin{step}[6*]\nCalculate the achromatic response\n\\[\n  A\\coloneqq p'_2 \\cdot N_{bb}.\n  \\]\n\\end{step}\n\n\\begin{step}[7]\nCalculate the correlate of lightness\n\\[\n  J \\coloneqq 100 {(A / A_w)}^{cz}.\n\\]\n\\end{step}\n\n\\begin{step}[8]\n  Calculate the correlate of brightness\n  \\[\n    Q \\coloneqq \\frac{4}{c} \\sqrt{\\frac{J}{100}} (A_w+4) F_L^{0.25}.\n    \\]\n\\end{step}\n\n\\begin{step}[9*]\nCalculate the correlates of chroma ($C$), colorfulness ($M$), and saturation\n  ($s$).\n\\begin{align*}\n  t&\\coloneqq \\frac{50000/13 N_c N_{cb} e_t \\sqrt{a^2 + b^2}}{u + 0.305},\\\\\n  \\alpha&\\coloneqq t^{0.9} {(1.64 - 0.29^n)}^{0.73},\\\\\n  C&\\coloneqq \\alpha \\sqrt{\\frac{J}{100}},\\\\\n  M&\\coloneqq C\\cdot F_L^{0.25},\\\\\n  s &\\coloneqq 50 \\sqrt{\\frac{\\alpha c}{A_w + 4}}.\n\\end{align*}\n\\end{step}\n\n\\subsection{Inverse model}\n\n\\begin{step}[1]\n  Obtain $J$, $t$, and $h$ from $H$, $Q$, $C$, $M$, $s$.\n\n  The input data can be different combinations of perceived correlates, that\n  is, $J$ or $Q$; $C$, $M$, or $s$; and $H$ or $h$. Hence, the following\n  sub-steps are needed to convert the input parameters to the parameters $J$,\n  $t$, and $h$.\n\\end{step}\n\n\\begin{step}[1--1]\nCompute $J$ from $Q$ (if input is $Q$)\n\\[\n  J\\coloneqq 6.25 \\frac{cQ}{(A_w+4) F_L^{0.25}}.\n\\]\n\\end{step}\n\n\\begin{step}[1--2*]\nCalculate $t$ from $C$, $M$, or $s$.\n\\begin{itemize}\n  \\item If input is $C$ or $M$:\n    \\begin{align*}\n      C &\\coloneqq M / F_L^{0.25} \\:\\text{if input is $M$}\\\\\n      \\alpha &\\coloneqq \\begin{dcases*}\n          0 &if $J=0$,\\\\\n          \\frac{C}{\\sqrt{J/100}}& otherwise.\n      \\end{dcases*}\n    \\end{align*}\n  \\item If input is $s$:\n    \\[\n    \\alpha \\coloneqq {\\left(\\frac{s}{50}\\right)}^2 \\frac{A_w+4}{c}\n    \\]\n\\end{itemize}\nCompute $t$ from $\\alpha$:\n\\[\n  t \\coloneqq {\\left(\\frac{\\alpha}{{(1.64 - 0.29^n)}^{0.73}}\\right)}^{1/0.9}\n\\]\n\\end{step}\n\n\\begin{step}[1--3]\nCalculate $h$ from $H$ (if input is $H$).\nThe correlate of hue ($h$) can be computed by using data in\ntable~\\ref{table:hue} in the forward model.\nChoose a proper $i\\in\\{1,2,3,4\\}$ such that\n$H_i \\le H < H_{i+1}$. Then\n\\[\n  h' = \\frac{(H-H_i)(e_{i+1}h_i - e_i h_{i+1}) - 100 h_i e_{i+1}}{(H-H_i)(e_{i+1}-e_i) - 100 e_{i+1}}.\n\\]\nSet $h = h' - 360\\degree$ if $h' > 360\\degree$, and $h=h'$ otherwise.\n\\end{step}\n\n\\begin{step}[2*]\nCalculate $e_t$, $A$, $p'_1$, and $p'_2$\n\\begin{align*}\n  e_t &= \\tfrac{1}{4} (\\cos(h\\pi/180\\degree + 2) + 3.8),\\\\\n  A &= A_w  {(J/100)}^{1/(cz)},\\\\\n  p'_1 &= e_t \\tfrac{50000}{13} N_c N_{cb},\\\\\n  p'_2 &= A / N_{bb}.\n\\end{align*}\n\\end{step}\n\n\\begin{step}[3*]\nCalculate $a$ and $b$\n  \\begin{align*}\n    \\gamma &\\coloneqq \\frac{23 (p'_2+0.305) t}{23 p'_1 + 11 t \\cos(h) + 108 t \\sin(h)},\\\\\n    a &\\coloneqq \\gamma \\cos(h),\\\\\n    b &\\coloneqq \\gamma \\sin(h).\n  \\end{align*}\n\\end{step}\n\n\\begin{step}[4]\n  Calculate $R'_a$, $G'_a$, and $B'_a$.\n  \\[\n  \\begin{pmatrix}\n    R'_a\\\\G'_a\\\\B'_a\n  \\end{pmatrix}\n  =\n  \\frac{1}{1403}\n  \\begin{pmatrix}\n    460 & 451 & 288\\\\\n    460 & -891 & -261\\\\\n    460 & -220 & -6300\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    p'_2\\\\a\\\\b\n  \\end{pmatrix}.\n  \\]%\n\\end{step}\n\n\\begin{step}[5*]\nCalculate $R_c$, $G_c$, and $B_c$,\n  \\[\n  \\rgb_c = \\sign(\\rgb'_a)\n  \\frac{100}{F_L} {\\left(\n    \\frac{27.13 \\abs{\\rgb'_a}}{400 - \\abs{\\rgb'_a}}\n    \\right)}^{1/0.42}.\n  \\]\n\\end{step}\n\n\\begin{step}[6]\nCalculate $R$, $G$, and $B$ from $R_c$, $G_c$, and $B_c$.\n\\[\n  \\rgb = \\rgb_c / D_{\\rgb}.\n\\]\n\\end{step}\n\n\\begin{step}[7]\nCalculate $X$, $Y$, and $Z$. (For the coefficients of the inverse matrix, see\nthe note at the end of the appendix B of~\\cite{cam16}.)\n\\[\n\\begin{pmatrix}X\\\\Y\\\\Z\\end{pmatrix}\n  = M_{16}^{-1}\n\\begin{pmatrix}R\\\\G\\\\B\\end{pmatrix}.\n\\]\n\\end{step}\n\n% \\printbibliography{}\n\\bibliography{bib}{}\n\\bibliographystyle{plain}\n\n\\end{document}\n", "meta": {"hexsha": "ccb1caff51b417fd2a6cf19dce682b01a1767d63", "size": 20208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "nschloe/note-on-cam16", "max_stars_repo_head_hexsha": "a4fe24585cfa1d0d633aef62d607438c3b26d56f", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2018-02-15T06:46:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-28T07:06:35.000Z", "max_issues_repo_path": "main.tex", "max_issues_repo_name": "nschloe/note-on-cam16", "max_issues_repo_head_hexsha": "a4fe24585cfa1d0d633aef62d607438c3b26d56f", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-01-02T18:27:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-03T20:17:35.000Z", "max_forks_repo_path": "main.tex", "max_forks_repo_name": "nschloe/note-on-cam16", "max_forks_repo_head_hexsha": "a4fe24585cfa1d0d633aef62d607438c3b26d56f", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0892307692, "max_line_length": 160, "alphanum_fraction": 0.6455859066, "num_tokens": 7673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4286741886071296}}
{"text": "\\documentclass[landscape]{article}\n\n\\usepackage{amsmath}\n\\usepackage{booktabs}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=newest}\n\\usepackage{hyperref}\n\n\\title{Statistic Formulas}\n\\author{RobinXSI}\n\\date{Juli 2015}\n\\begin{document}\n   \\maketitle\n   \t\\section{Introduction}\n\n   \t\tWichtig beim aufstellen von Hypothesen ist, dass die Auswertung eine statistische Signifikanz haben.\n\n   \t\tStatistical significance means:\n\t\t\\begin{itemize}\n\t\t\t\\item rected the null hypothesis\n\t\t\t\\item results are not likely due to chance (sampling error)\n\t\t\\end{itemize}\n\n\t\tAls Endresultat der Statistik sollten folgendes Dokument erstellt werden können:\n\t\t\\begin{itemize}\n\t\t\t\\item Desciriptive Statistics\n\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\\item M - Mean\n\t\t\t\t\t\\item Sd - Standard Deviation\n\t\t\t\t\\end{itemize}\n\t\t\t\\item Inferential Statistics\n\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\\item Hypothesis Test \\(\\alpha\\)\n\t\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\t\\item kind of test, bsp: one-sample t-test\n\t\t\t\t\t\t\\item test statistic, bsp: t-value\n\t\t\t\t\t\t\\item df - degrees of freedom\n\t\t\t\t\t\t\\item p-value\n\t\t\t\t\t\t\\item direction of test, bsp: one-tail-test or two-tail-test\n\t\t\t\t\t\\end{itemize}\n\t\t\t\t\t\\item APA style\n\t\t\t\t\t\t  \\\\\\(t(df) = X.XX, p = X.XX,\\) direction\n\t\t\t\t\t\t  \\\\bsp: \\(t(24) = -2.50, p < .05,\\) one-tailed\n\t\t\t\t\t\\item Confidence intervals\n\t\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\t\\item Confidence leve, bsp: 95\\%\n\t\t\t\t\t\t\\item Lower Limit\n\t\t\t\t\t\t\\item Upper Limit\n\t\t\t\t\t\t\\item CI on what?\n\t\t\t\t\t\\end{itemize}\n\t\t\t\t\t\\item APA style - CIs\n\t\t\t\t\t\t  \\\\Confidence interval on the mean difference;\n\t\t\t\t\t\t  \\\\95\\% CI = (4 to 6)\n\t\t\t\t\t\\item Effect size measures\n\t\t\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\t\t\\item \\(d\\)\n\t\t\t\t\t\t\t\\item \\(r^2\\)\n\t\t\t\t\t\t\\end{itemize}\n\t\t\t\t\t\\item APA style - CIs\n\t\t\t\t\t\t  \\\\\\(d = X.XX\\)\n\t\t\t\t\t\t  \\\\\\(r^2 = .XX\\)\n\n\t\t\t\t\\end{itemize}\n\t\t\\end{itemize}\n\n\n\t\\section{Statistical Formulas}\n\t\t\\pgfmathdeclarefunction{gauss}{2}{%\n\t\t  \\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%\n\t\t}\n\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t  no markers, domain=0:10, samples=100,\n\t\t\t  axis lines*=left, xlabel=$x$, ylabel=$y$,\n\t\t\t  every axis y label/.style={at=(current axis.above origin),anchor=south},\n\t\t\t  every axis x label/.style={at=(current axis.right of origin),anchor=west},\n\t\t\t  height=5cm, width=15cm,\n\t\t\t  xtick={4}, ytick=\\empty,\n\t\t\t  enlargelimits=false, clip=false, axis on top,\n\t\t\t  grid = major\n\t\t\t  ]\n\t\t\t  \\addplot [fill=cyan!20, draw=none, domain=0:2.4] {gauss(4,1)} \\closedcycle;\n\t\t\t  \\addplot [fill=cyan!20, draw=none, domain=5.6:10] {gauss(4,1)} \\closedcycle;\n\t\t\t  \\addplot [very thick,cyan!50!black] {gauss(4,1)};\n\t\t\t \n\n\n\t\t\t\\draw [yshift=-0.6cm, latex-latex](axis cs:4,0) -- node [fill=white] {$1.96\\sigma$} (axis cs:5.6,0);\n\t\t\t\\end{axis}\n\n\t\t\\end{tikzpicture}\n\n\t\t\\subsection{Empirical Mean}\n\t\t\\(\\gamma = \\frac{\\sum{x}}{N}\\)\n\n\t\tProperties (for independent random variables X and Y):\n\t\t\\begin{enumerate}\n\t\t\t\\item \\(Mean(X + Y) = Mean(X) + Mean(Y)\\)\n\t\t\t\\item \\(Mean(X \\times Y) = Mean(X) \\times Mean(Y)\\)\n\t\t\\end{enumerate}\n\n\t\t\\subsection{Variance}\n\t\t\\(\\sigma^2 = Var(X)\\newline\n\t\t\t\\sigma^2 = \\frac{\\sum{(x_i - \\gamma)^2}}{N}\\newline\n\t\t\t\\sigma^2 = \\frac{\\sum{X_i^2}}{N} - \\frac{(\\sum{X_i})^2}{N^2}\\newline\n\t\t\t\\sigma^2 = \\frac{\\sum{(x_i - \\gamma)^2}}{N}\\)\\newline\n\t\t\n\t\t\\subsection{Standard Deviation}\n\t\t\\(\\sigma = \\sqrt{Var(X)}\\newline\n\t\t\t\\sigma = \\sqrt{\\frac{\\sum{(X_i - \\gamma)^2}}{N}}\\)\\newline\n\n\t\t\\subsection{Standard Error}\n\t\t\\(Sd = \\frac{\\sigma}{N}\\)\n\n\t\t\\subsection{Z-Score}\n\t\tZ-Score \\(= \\frac{x - \\bar{x}}{Sd}\\)\n\n\t\t\\subsection{Standard Normal Distribution}\n\t\t\\(\\frac{1}{\\sqrt{2 \\cdot \\pi \\cdot \\sigma^2}} \\cdot e^{[-\\frac{1}{2} \\cdot \\frac{(x-\\gamma)^2}{\\sigma^2}]}\\)\n\n\t\t\\subsection{Confidence Interval}\n\t\t\\(CI = 1.96 \\cdot \\sqrt{\\frac{p(1 - p)}{N}}\\newline\n\t\t\tGeneral Form:\\newline\n\t\t\tSize of CI = a \\cdot \\sqrt{\\frac{\\sigma^2}{N}}\\newline\n\t\t\t\\frac{\\sum{X_i \\pm a \\cdot \\sqrt{\\frac{\\sigma^2}{N}}}}{N}\\)\n\n\t\t\t\\textbf{Note}\n\n\t\t\t\\begin{enumerate}\n\t\t\t\\item $a = 1.96 for N \\geq 30$\n\t\t\t\\item $a$ is the t-value computed for $(N - 1)$ degrees of freedom and confidence level $p$.\n\t\t\t\\end{enumerate}\n\n\t\t\\subsection{Additional Formulas}\n\t\t\\begin{tabular}{lllll}\n\t\t\t\\hline\n\t\t\tName & Population Symbol & Sample Symbol & Sample Calculation & Beschreibung \\\\ \\hline\n\t\t\tMean &  & $\\bar{x}$ & $\\bar{x} = \\frac{\\sum{x}}{N}$ & Durchschnitt aller Daten \\\\\n\t\t\tVariance & $\\sigma_x^2$ & $s_x^2$ & $s_x^2 = \\frac{\\sum{(x - \\bar{x})^2}}{N - 1}$ & Abweichung \\\\\n\t\t\tStandard Dev & $\\sigma_x$ & $s_x$ & $s_x = \\sqrt{s_x^2}$ &  \\\\\n\t\t\tCovariance & $\\sigma_xy$ & $s_xy$ & $s_xy = \\frac{\\sum{(x - \\bar{x})(y - \\bar{y})}}{N - 1}$ &  \\\\\n\t\t\tCorrelation & $\\rho_xy$ & $r_xy$ & \\begin{tabular}[c]{@{}l@{}}$r_xy = \\frac{s_xy}{s_x s_y}$\\\\ $r_xy = \\frac{\\sum{(z_x z_y)}}{N - 1}$\\end{tabular} &  \\\\ \\hline\n\t\t\tz-score & $z_x$ & $z_x$ & $z_x = \\frac{x-\\bar{x}}{s_x}; \\bar{z} = 0; s_x^2 = 1$ &  \\\\ \\hline\n\t\t\\end{tabular}\n\n\t\\subsection{T-Test}\n\t\t\\[\n\t\tt = \\frac{\\bar{x_D} - 0}{s_D / \\sqrt{n}}\n\t\t\\]\n\n\t\n\n\n\t\\section{Lesson 10 - Dependent samples}\n\n\t\tDependent samples (repeated measures)\n\t\t\\begin{itemize}\n\t\t\t\\item Two Conditions\n\t\t\t\\item Longitudinal\n\t\t\t\\item Pre-Test, Post-Test\n\t\t\\end{itemize}\n\n\t\t\\subsection{Important formulas}\n\t\t\t\\(x = [ARRAY of VALUES] \\Rightarrow\\) Population Data\n\t\t\t\\(X = [ARRAY of VALUES] \\Rightarrow\\) Sample Data\n\t\t\t\\\\\\(n \\Rightarrow\\) Sample und Population Size\n\t\t\t\\\\\\(\\mu = \\frac{\\sum{x_i}}{n}\\Rightarrow\\) Population Mean\n\t\t\t\\\\\\(\\bar{X} = \\frac{\\sum{X_i}}{n} \\Rightarrow\\) Sample Mean\n\t\t\t\\\\\\(s_D = \\sqrt{\\frac{\\sum{(X_i - \\mu)^2}}{n}} \\Rightarrow\\) Standard Deviation for sample\n\t\t\t\\\\\\(\\alpha \\Rightarrow\\) tail probability on t-table\n\t\t\t\\\\\\(t_{critical} \\Rightarrow\\) from \\href{https://s3.amazonaws.com/udacity-hosted-downloads/t-table.jpg}{t-table}\n\t\t\t\\\\\\(df = n - 1 \\Rightarrow\\) Degrees of Freedom\n\t\t\t\\\\\\(SEM = \\frac{s_D}{\\sqrt{n}} \\Rightarrow\\) Standard Error of the Mean\n\t\t\t\\\\\\(t = \\frac{\\bar{X} - \\mu}{SEM} \\Rightarrow\\) One Sample t-Test\n\t\t\t\\\\margin of error \\(= (t^{critical} \\times SEM)\\)\n\t\t\t\\\\\\(CI = \\bar{X} \\pm \\) margin of error \\(\\Rightarrow\\) Confidence Interval\n\t\t\t\\\\\\(d = \\frac{\\bar{X}-\\mu}{s_D} \\Rightarrow\\) Cohen's d \\(\\Rightarrow\\) Standardized mean difference \n\t\t\t\\\\\\(r^2 = \\frac{t^2}{t^2 + df} \\Rightarrow\\) bestimmt die Stärke des Zusammenhangs zwischen zwei Variablen als Proportion. Beispiel: \\(r^2 gibt\\) an wieviel das Geschlecht einer Person zum Unterschied der beiden Samples beigetragen hat\n\n\t\t\\subsection{Hypothese}\n\t\t\t``US families spent an average of \\$151 per week on food''\n\t\t\t\\\\Beispiel Null Hypothese: ``the program did not change the cost of food''\n\t\t\t\\\\Beispiel Alternative Hypothese: ``the program reduced the cost of food''\n\t\t\t\\\\\n\t\t\t\\\\\\(null \\rightarrow H_0:\\mu_program >= 151\\)\n\t\t\t\\\\\\(alt \\rightarrow H_A:\\mu_program < 151\\)\n\n\t\\section{Lesson 11 - Independent Samples}\n\t\tVoneinander abhängige Daten brauchen nicht so viele Testkandidaten, ist kosteneffektiv und weniger zeitaufwendig. Diese Art an Daten zu kommen hat aber auch Nachteile. Beispielsweise könnten die Probanden beim zweiten Ausfüllen eines Tests die Antworten schon kennen.\n\n\t\tAus diesem Grund braucht es Independent Samples, also je einen Teil des Samples, der das Treatment gemacht hat und einen anderen Teil der es nicht gemacht hat.\n\t\t\\\\\\(s_1 \\sqrt{\\frac{\\sum{(X_i1 - \\mu)^2}}{n - 1}} \\Rightarrow\\) Standard Deviation for sample with\n\t\t \\href{Bessel\\'s correction}{http://www.wikiwand.com/en/Bessel\\%27s\\_correction}\n\t\t\\\\\\(s_2 \\sqrt{\\frac{\\sum{(X_i2 - \\mu)^2}}{n - 1}} \\Rightarrow\\) Standard Deviation for sample with \\href{Bessel\\'s correction}{http://www.wikiwand.com/en/Bessel\\%27s\\_correction}\n\t\t\\\\\\(n_1 \\Rightarrow\\) Size of Sample 1\n\t\t\\\\\\(n_2 \\Rightarrow\\) Size of Sample 2\n\t\t\\\\\\(S_D = \\sqrt{s_1^2 + s_2^2}\\) Standard Deviation for Samples\n\t\t\\\\\\(SEM = \\sqrt{\\frac{s_1^2}{n_1} + \\frac{s_2^2}{n_2}} \\Rightarrow\\) Standard Error for independent samples\n\t\t\\\\\\(df = n_1 + n_2 - 2 \\Rightarrow\\) Degrees of freedom for independent samples\n\t\t\\\\\\(t = \\frac{\\bar{X}_1 - \\bar{X}_2}{SEM} \\Rightarrow\\) Two Sample t-Test\n\t\t\\\\\\(CI = (\\bar{X}_1 - \\bar{X}_2) \\pm \\) margin of error \\(\\Rightarrow\\) Confidence Interval\n\t\t\\\\\\(SS_x = \\sum{(x_i - \\bar{x})^2} \\Rightarrow\\) Sum of Squared Deviations\n\t\t\\\\\\(S_p^2 = \\frac{SS_1 + SS_2}{df_1 + df_2} \\Rightarrow\\) Pooled variance\n\t\t\\\\\\(SEM_{CORRECTED} (S_{\\bar{x_1} - \\bar{x_2}}) = \\sqrt{\\frac{s_p^2}{n_1} + \\frac{s_p^2}{n_2}} \\Rightarrow\\) Corrected Standard Error\n\t\t\\\\\\(t_{CORRECTED} = \\frac{\\bar{x_1} - \\bar{x_2}}{S_{\\bar{x_1}-\\bar{x_2}}} \\Rightarrow\\) t-Statistic Corrected\n\n\t\\section{Lesson 12 - ANOVA (Analysis of Variance)}\n\t\tANOVA for samples with the same size\n\t\t\\\\\\(N \\Rightarrow\\) number of values from all samples\n\t\t\\\\\\(k \\Rightarrow\\) number of samples\n\t\t\\\\\\(\\bar{x}_G = \\frac{\\sum{\\bar{x}_i}}{N}\\Rightarrow\\) Grand Mean\n\t\t\\\\\\(df = N - k \\Rightarrow\\) degrees of freedom\n\t\t\\\\\\(df_1 = k - 1)\\)\n\t\t\\\\\\(df_2 = N - k)\\)\n\t\t\\\\\\(df_{total} = N - 1 \\Rightarrow\\) total degrees of freedom\n\t\t\\\\\\(F = \\frac{n * \\sum{(\\bar{x}_K - \\bar{x}_G)^2 / df_1}}{\\sum{(x_i - \\bar{x}_k)^2 / df_2}} \\Rightarrow\\) between-group variability / within-group variability. \\href{http://www.socr.ucla.edu/applets.dir/f\\_table.html}{F-Table}\n\t\t\n\t\n\n\\end{document}", "meta": {"hexsha": "9d78c09aed1554740b463439692f1dd38d0b1ca8", "size": 9102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "statistics-formulas.tex", "max_stars_repo_name": "RobinXSI/StatisticsFormulas", "max_stars_repo_head_hexsha": "39662f800df0ea228056eb1a06740807f0469ed9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "statistics-formulas.tex", "max_issues_repo_name": "RobinXSI/StatisticsFormulas", "max_issues_repo_head_hexsha": "39662f800df0ea228056eb1a06740807f0469ed9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "statistics-formulas.tex", "max_forks_repo_name": "RobinXSI/StatisticsFormulas", "max_forks_repo_head_hexsha": "39662f800df0ea228056eb1a06740807f0469ed9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.185520362, "max_line_length": 269, "alphanum_fraction": 0.6335970116, "num_tokens": 3273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6442250996557035, "lm_q1q2_score": 0.4286741835206236}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb}\n\\usepackage{mathtools}\n\\usepackage{ulem}\n\\usepackage{url}\n\\usepackage{graphicx}\n \\usepackage{geometry}\n\\geometry{margin=1.0in}\n\n\\usepackage{lmodern}\n\n\\makeatletter\n\n\\makeatother\n\n\\usepackage{etoolbox}\n\n\n%%%%%%%%% STUDENTS CHANGE THIS\n\n\\providetoggle{undergrad}\n\\settoggle{undergrad}{false}     %%% \"true\" if 3395 or \"false\" if 6390\n\n\n\\providetoggle{final}            \n\\settoggle{final}{false}        %%% \"true\" for your final homework submission (removes instructions)\n\n%%%%%%%%%%%%%%%%%%%%% ^^^^^\n\\usepackage[colorlinks=true]{hyperref}\n\n\n\\begin{document}\n\n\\setlength{\\parskip}{0.3cm} \\setlength{\\parindent}{0cm}\n\n\\begin{center}\n\\textbf{{IFT 6390 Fundamentals of Machine Learning \\\\ Vijaya lakshmi Kuruba\\\\ Saadaoui Houda}}\n\\par\\end{center}{\\large \\par}\n\n\\begin{center}\n\\textbf{\\LARGE{{Model Card - SVM Linear Classifier}}}\n\\par\\end{center}{\\LARGE \\par}\n\nOur model is a supervised learning which consists of classifying gender using tweets and users profile description. \nSince it is a supervised learning task we used a dataset consisting of tweets labeled with the gender “male” or “female”.\n\nThe dataset used has 20,000 samples and has many features but to build our model we chose only two features: tweets and description.\n\nBefore building our model, we first cleaned the data using the following steps:\n\\begin{itemize}\n    \\item Choosing only the gender \"female\" and \"male\" (the data has also unknown and brand as genders)\n    \\item Preprocessing the data using the Preprocessor library\n\\end{itemize}\n\nAfter filetring and preprocessing the dataset, we ended up with 12,895 samples which we split into training and testing with 80\\% and 20\\% respectively of the dataset.  \\\\\nWe chose to use the linear classifier Support Vector Machine SVM to make the classification task.\n\nModel parameter is validated with K fold cross validation and classifier metrics has been reported.\n\n\\paragraph{SVM Linear Classifier}: \n\n$$\\includegraphics[scale=.5]{svm.JPG}$$\n\nWe consider labeled data $(\\mathbf{x},y)$, where $\\mathbf{x}$ is a $d$-dimensional input, i.e. $\\mathbf{x} \\in \\mathbb{R}^{d}$ and $y\\in\\{-1,1\\}$. We have a dataset of $n$ such pairs $(\\mathbf{x}_i,y_i)$. We want to train a linear classifier on this dataset. \\\\\n\n\\textbf{Linear Model:}\n\\begin{equation}\n f(x) = \\mathbf{w}^T \\mathbf{x} + b   \n\\end{equation}\nOn Hyper plane :\n\\begin{equation}\nf(x) =\\mathbf{w}^T \\mathbf{x} + b=0    \n\\end{equation}\nConstraints are:\n\\begin{equation}\n \\mathbf{w}^T \\mathbf{x_i} + b\\geq 1 \\quad \\text{if} \\quad y_i=1 \n \\end{equation}\n\\begin{equation}\n \\mathbf{w}^T \\mathbf{x_i} + b\\leq -1 \\quad \\text{if} \\quad y_i=-1   \n\\end{equation}\n\nIn general \n\\begin{equation}\n    y_i(\\mathbf{w}^T \\mathbf{x_i} + b)\\geq 1 \\quad \\forall \\quad i \\in 1...N \n\\end{equation}\n\n\nTo simplify code and notation, we can get rid of the bias term $b$. To do  so, we concatenate $1$ to every $\\mathbf{x}$ vector, so that $\\mathbf{x}' = (\\mathbf{x}, 1) \\in \\mathbb{R}^{d+1}$, and we concatenate $b$ to $\\mathbf{w}$, so that $\\mathbf{w}' = (\\mathbf{w}, b)$. Then $\\mathbf{w}^T \\mathbf{x} + b = \\mathbf{w}'^T \\mathbf{x}'$. We can write everything in terms of linear transformations instead of affine transformations.\n\nWe will omit the bias term from now on, and consider $\\mathbf{x}$ and $\\mathbf{w}$ themselves as $\\mathbf{x}'$ and $\\mathbf{w}'$\n\nNew notation: \n\\begin{align}\n    y_i(\\mathbf{w}^T \\mathbf{x_i} )\\geq 1 \\quad \\forall \\quad i \\in 1...N    \n\\end{align}\n\n\\textbf{Loss Function :} \\\\\n\\\\The hinge loss is used for \"maximum-margin\" classification.\\\\\nLoss function is given by:\n\n\\begin{equation}\n g(w;\\mathbf{x}, y) =\n\\begin{cases}\n0 \\quad \\quad \\quad \\quad\\quad \\text{if}\\quad 1-yf(x) \\geq 1 \\\\ 1-yf(x) \\quad\\text{otherwise.}\n\\end{cases}\n\\end{equation}\n\n\n\\textbf{Objective Function:}\\\\\n \\\\The loss function stated above is called convex surrogate losses. They are convex and have a gradient so we can optimize them with gradient descent.\\\\\n \nThe training objective that we are going to minimize is the average of the losses over each training example plus an $\\ell^2$ regularization with hyperparameter $\\lambda$:\n\\begin{align}\n L(w) = \\frac{1}{n}\\sum_{i=1}^n g(w;\\mathbf{x_i}, y_i)  + \\frac{\\lambda}{2} \\| \\mathbf{w}\\|^2   \n\\end{align}\n\nNote:  Minimising w allows to maximize the margen\n\nwhere the parameter $\\lambda$  determines the trade-off between increasing the margin size and ensuring that the $\\mathbf {x} _{i}$ lie on the correct side of the margin. Thus, for sufficiently small values of $\\lambda$ , the second term in the loss function will become negligible, hence, it will behave similar to the hard-margin SVM, if the input data are linearly classifiable, but will still learn if a classification rule is viable or not.\n\n\\textbf{Gradient Desecent:}  \n\nSVM classifier amounts to minimizing the loss funtion Equation 8 with Gradient descent technique.\nWe want to minimize the loss $L(w)$. It is differentiable, so we can use the gradient descent algorithm: start from any initialization parameter $\\mathbf{w}_0$, and repeat for $t\\in\\{0, \\dots, t_{\\max} \\}$:\n$$\\mathbf{w}_{t+1} = \\mathbf{w}_t - \\eta\\ \\nabla L (\\mathbf{w}_t) \\; .$$\n\nUnder some conditions on the step-size $\\eta$ and the loss $L$, this algorithm is guaranteed to converge to a minimum of $L(w)$.\n\n$$\\nabla L (\\mathbf{w}_t)\n=\n\\begin{cases}\n\\lambda \\| \\mathbf{w}\\| \\quad \\quad \\quad \\quad\\quad \\text{if}\\quad 1-yf(x) \\geq 1 \\\\ \\lambda \\| \\mathbf{w}\\|-y_ix_i \\quad\\text{otherwise.}\n\\end{cases}\n$$\n\nTo choose the $\\lambda $ parameter, we used a Randomized Search to get the best value among the following list [1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3]. The obtained value of $\\lambda $ is 0.001\n\n\\paragraph{K fold Crossvalidation}: \n\nTo evaluate the performance of a model on a dataset, we need to measure how well the predictions made by the model match the observed data. \nWhen data is scarce, we may not be able to afford using a validation set, So we use K fold crossvalidation technique.\\\\\nApproach : split the dataset into K equal partitions.\n\\begin{itemize}\n    \\item 1. Set one partition aside for prediction/validation, and train the model on the remaining K-1 partitions.\\\\\n   \\item 2. Repeat the above step for each partition and report the average prediction error.\n\n\\end{itemize}\n\nIn pratice: common to pick 5-fold or 10-fold cross-validation.\n\nMathematically: \n$$\n        CV({\\hat{f}}) = \\frac{1}{N} \\sum_{i=1}^{N} L(y_{i}, {\\hat{f}}^{(\\kappa(i))}(x_{i})) \\enspace $$\nwhere $\\hat{f}(k)$ denotes the model obtained by removing the k-th partition and training on the\nrest. Furthermore, k(i) is a function which, given a datapoint index, returns the partition to\nwhich it belongs. If the i-th datapoint belongs to the j-th partion, then we want the model\n$f^{(j)}$\n, where the j-th partition has been excluded.\n\n\nFor our model, after cleaning and filtering the data we used K-Folds Cross Validation technique using k = 5 to validate it.\n\n\\paragraph{Classifier Accuracy }: \n\\begin{align*}\n    Accuracy (y, {\\hat{y}})= \\frac{1}{N} \\sum_{i=1}^{N} {1}_{{\\hat{y_{i}}} = y}\n\\end{align*}\nwhere ${1} (x)$  is the indicator function.\n\n\n\\paragraph{Time Complexity}:\n\nN= Number of training examples\\\\\nk=k is the number of iterations (epochs)\\\\ \nd=Dimensions of the features\n\nTime complexity for training is : O(Nkd)\n\nTime complexity for testing is : O(Nd)\n\n\n\\paragraph{Space Complexity}:\n\nN= Number of training examples\\\\\nd=Dimensions of the features\n\nSpace complexity for training is : O(Nd)\n\nSpace complexity for testing is : O(Nd)\n\\end{document}\n", "meta": {"hexsha": "762d68f8805e6ffe0a7b111f95b00e3ded1295d8", "size": 7600, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper.tex", "max_stars_repo_name": "vijayakuruba/Model-Card-Project-IFT6390", "max_stars_repo_head_hexsha": "957525b587d797198db651cb654aadf34d0feb3e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper.tex", "max_issues_repo_name": "vijayakuruba/Model-Card-Project-IFT6390", "max_issues_repo_head_hexsha": "957525b587d797198db651cb654aadf34d0feb3e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper.tex", "max_forks_repo_name": "vijayakuruba/Model-Card-Project-IFT6390", "max_forks_repo_head_hexsha": "957525b587d797198db651cb654aadf34d0feb3e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.5833333333, "max_line_length": 445, "alphanum_fraction": 0.7123684211, "num_tokens": 2272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.42859351756990405}}
{"text": "\\section{Nomenclature}\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{Nomenclature}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n$W \\equiv$ system width\r\n\r\n$L \\equiv$ system length\r\n\r\n$y \\equiv$ perpendicular position, varies between $0$ and $W$\r\n\r\n$z \\equiv$ parallel position, varies between $0$ and $L$\r\n\r\n$\\ell_{tmfp} \\equiv$ transport mean free path\r\n\r\n$k \\equiv$ total wave number\r\n\r\n$k_{\\parallel} \\equiv$ wave number parallel to wave propagation direction (along $z$), see Eq.~\\ref{eq:k_parallel}\r\n\r\n$k_{\\bot} \\equiv$ wave number perpendicular to wave propagation direction (along $y$), see Eq.~\\ref{eq:k_perpendicular}\r\n\r\n$\\kappa \\equiv$ imaginary total wave number, is similarly broken into parallel and perpendicular components\r\n\r\n$n \\equiv$ channel index, varies from $1$ to $\\infty$\r\n\r\n$N_o \\equiv$ number of open channels, also known as $N_{open}$\r\n\r\n$N_{max} \\equiv$ number of open and closed channels (finite)\r\n\r\n$\\omega \\equiv$ frequency\r\n\r\n$E \\equiv$ electric field\r\n\r\n${\\cal H} \\equiv$ magnetic field\r\n\r\n${\\cal E} \\equiv$ energy\r\n\r\n$E^+ \\equiv$ plane wave electric field propagating from left to right\r\n\r\n$E^- \\equiv$ plane wave electric field propagating from right to left\r\n\r\n$E' \\equiv$ first order electric field derivative wrt space\r\n\r\n$\\alpha \\equiv$ scatterer strength (unitless)\r\n\r\n$\\Delta \\equiv$ a small change in the variable\r\n\r\n$c \\equiv$ speed of light\r\n\r\n$\\mu_0 \\equiv$ vacuum permeability\r\n\r\n$\\epsilon_0 \\equiv$ vacuum permittivity\r\n\r\n", "meta": {"hexsha": "d8ba3d7b387f23353f496538366298be95ab4454", "size": 1557, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/appendix_nomenclature.tex", "max_stars_repo_name": "bhpayne/physics_phd_dissertation", "max_stars_repo_head_hexsha": "646123088fdd226e8677e6f3edb8d109be96994e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/appendix_nomenclature.tex", "max_issues_repo_name": "bhpayne/physics_phd_dissertation", "max_issues_repo_head_hexsha": "646123088fdd226e8677e6f3edb8d109be96994e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/appendix_nomenclature.tex", "max_forks_repo_name": "bhpayne/physics_phd_dissertation", "max_forks_repo_head_hexsha": "646123088fdd226e8677e6f3edb8d109be96994e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8035714286, "max_line_length": 120, "alphanum_fraction": 0.631342325, "num_tokens": 378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4285935144491531}}
{"text": "\\documentclass[12pt]{report}\r\n\\usepackage{amsmath,textcomp,amssymb}\r\n\\usepackage{geometry}\r\n\\usepackage{indentfirst}\r\n\\usepackage{graphicx}\r\n\\usepackage{float}\r\n\\usepackage{expdlist}\r\n\\usepackage{xcolor}\r\n\\usepackage{hyperref}\r\n\\usepackage{multicol}\r\n\r\n\\def\\Title{BLOM Quick Start Guide}\r\n\\def\\Name{MPC Lab}\r\n\\def\\contacts{Jason Kong: \\url{jasonjkong@berkeley.edu}\\\\ Tony Kelman: \\url{kelman@berkeley.edu} \\\\ Kyle Chiang: \\url{kylechiang@berkeley.edu}}\r\n\\title{\\Title}\r\n\\author{\\Name \\\\ \\contacts}\r\n\\date{Last updated: \\today}\r\n\\markboth{\\Title}{\\Title}\r\n\\pagestyle{myheadings}\r\n\\setlength\\parindent{0pt}\r\n\\setlength{\\parskip}{12pt}\r\n\\footskip = 0pt\r\n\\textheight = 670pt\r\n\r\n\\newenvironment{itemize*}\r\n  {\\begin{itemize}\r\n    \\setlength{\\itemsep}{1pt}\r\n    \\setlength{\\parskip}{1pt}}\r\n  {\\end{itemize}}\r\n  \r\n\\newcommand{\\textbu}[1]{\\textbf{\\underline{#1}}}\r\n\\newcommand{\\red}[1]{\\textcolor{red}{#1}}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\\tableofcontents\r\n\\setcounter{secnumdepth}{0}\r\n\r\n\\clearpage \\section{What is BLOM?}\r\n\\begin{itemize}\r\n\\item Provides a graphical interface to allow users to create optimization problems using Simulink blocks.\r\n\\item Exports mathematical model to solvers (eg. ipopt)\r\n\\item Great for optimization problems with \"dynamics\" that evolve over time\r\n$$\\min_x f(x)$$\r\n$$g(x) \\leq 0$$\r\n$$h(x) = 0$$\r\n\\vspace{-50pt}\r\n\\end{itemize}•\r\n\r\n\r\n\\section{BLOM Library}\r\n\\begin{figure}[H]\r\n\\center\r\n\\includegraphics[width=100mm]{figures/BLOM_Lib.png}\r\n\\vspace{-40pt}\r\n\\end{figure}•\r\n\r\n\\textbu{Externals:} Labels External Variables that can be changed via script or command line for different calls of the solver \\\\[10pt]\r\n\\textbu{Inputs:} Labels Input Variables to be optimized by solver \\\\[10pt]\r\n\\textbu{Bounds:} Sets upper/lower bounds on a variable\\\\[10pt]\r\n\\textbu{Cost:} Cost variable to be minimized.  \\\\[10pt]\r\n\\textbu{Polyblocks:} BLOM's convenient way to create nonlinear functions\\\\[10pt]\r\n\r\n\\section{Polyblocks}\r\nBLOM's internal representation of blocks.\r\n\r\n$$ y_1=2x^2_1x_2 , \\hspace{3mm} y_2=3x_1+x_2^4 $$\r\n\\[\r\nP = \\begin{bmatrix}\r\n2 & 1 \\\\\r\n1 & 0 \\\\\r\n0 & 4\r\n\\end{bmatrix}\r\n\\hspace{3mm}\r\nK = \\begin{bmatrix}\r\n2 & 0 & 0\\\\\r\n0 & 3 & 1\r\n\\end{bmatrix}\r\n\\]\r\n\r\n$$y_1 = 2x_1+3sin(x_2),  \\hspace{3mm} y_2 = 3x_1^2e^{x_3}+0.2tan(x_2)x_4^3$$\r\n\\[P= \\begin{bmatrix}\r\n1 & 0 & 0 & 0 \\\\\r\n0 & \\text{BLOM\\_FunctionCode(`sin')} & 0 & 0\\\\\r\n2 & 0 & \\text{BLOM\\_FunctionCode(`exp')} & 0 \\\\\r\n0 & \\text{BLOM\\_FunctionCode(`tan')} & 0 & 3\r\n\\end{bmatrix}\r\n\\]\r\n\\section{Setting Up BLOM on Your Computer}\r\n\\begin{enumerate}\r\n\\item \\url{http://mpclab.net/Trac/wiki/SVNsetup} Here are instructions on how to get SVN and how to get BLOM running\r\n\\item in command line, \\texttt{svn checkout http://www.mpclab.net/BLOM/ \\red{desired\\_directory}}\r\n\\item Each time you open up BLOM, make sure to get the latest version by typing \\texttt{svn update} within that folder (or update through TortoiseSVN)\r\n\\item On Mac or Linux machines, you may need to compile IPOPT and then run \\texttt{BLOM\\_Setup} (Instructions for doing so at \\url{http://mpclab.net/Trac/wiki/CompilingIpopt})\r\n\r\n\\end{enumerate}•\r\n\r\n\r\n\\clearpage\r\n\\section{Creating Model Example}\r\n\\vspace{-20pt}$$\\max  f(x)=3x_1+x_2-x_3^2+2x_3$$\r\n$$x_1^2+x_2^2\\leq5$$\r\n$$x_1-x_2\\leq1$$\r\n$$x_3\\geq0$$\r\n\r\n\\begin{figure}[H]\r\n\\textbu{Step 1:} Place Input and External Blocks for input and external variables\r\n\\center\r\n\\includegraphics[width=120mm]{figures/Example_Step1.png}\r\n\\end{figure}\r\n\\begin{figure}[H]\r\n\\textbu{Step 2:} For each bound limitation and cost function, drag and drop math blocks to satisfy equations.  Use subsystems and/or polyblocks as needed\r\n\\center\r\n\\includegraphics[width=50mm]{figures/Example_Step2_1_subsys.png}\r\n\\includegraphics[width=120mm]{figures/Example_Step2_1.png}\r\n\\end{figure}\r\n\\begin{figure}[H]\r\n\\textbu{Step 3:} Attach bound and cost blocks and set limits/time relevances\r\n\\center\r\n\\includegraphics[width=120mm]{figures/Example_Step3_1.png}\r\n\\includegraphics[width=60mm]{figures/Example_Step3_1_bound.png}\r\n\\end{figure}\r\n\\begin{figure}[H]\r\nRepeat steps 2 and 3 as necessary\r\n\\center\r\n\\includegraphics[width=120mm]{figures/Example_Step3_2.png}\r\n\\end{figure}\r\n\\begin{figure}[H]\r\n\\center\r\n\\includegraphics[width=120mm]{figures/Example_final.png}\r\n\\end{figure}\r\n\r\n\\section{Calling BLOM}\r\n\\begin{enumerate}\r\n\\item Always remember to run \\texttt{BLOM\\_addpath} to add all the BLOM related files into your path\r\n\\item Create model in simulink \r\n\\item \\texttt{BLOM\\_SetDataLogging(\\red{`ModelName'})}\r\n\\item \\texttt{ModelSpec = BLOM\\_ExtractModel(\\red{`ModelName'}, \\red{\\#timesteps})}\r\n\\item \\texttt{[RunResults ResultsVec] = BLOM\\_RunModel(ModelSpec)}\r\n\\item \\texttt{[OptGuess ExtVars InitialStates ] = BLOM\\_SplitResults(ModelSpec,RunResults)}\r\n\\item \\texttt{SolverStruct = BLOM\\_ExportToSolver(ModelSpec,\\red{`Solver'})}\r\n\\item \\texttt{SolverStructData =  BLOM\\_SetProblemData(SolverStruct,ModelSpec,OptGuess, ExtVars, InitialStates)}\r\n\\item \\texttt{SolverResult  =  BLOM\\_RunSolver(SolverStructData,ModelSpec)}\r\n\\end{enumerate}•\r\n\\textbu{Using Externals:} Items 7-9 can be run in a loop using outputs from \\texttt{SolverResult} to populate \\texttt{OptGuess} and \\texttt{InitialStates} in subsequent iterations.  \\texttt{OptGuess}, \\texttt{ExtVars}, and \\texttt{InitialStates} can all be filled in from the command line (e.g. \\texttt{ExtVars.x1=5}, and \\texttt{OptGuess=SolverResult})\r\n\r\n\r\n\r\n\\section{Optimizing Your Model}\r\n\\begin{itemize}\r\n\\item Use fewer blocks.  Outputs of blocks (with the exception of subsystems, from/goto tags, mux/demux) represent variables.  Having fewer blocks and therefore fewer variables allows for faster computation.\r\n\\item Switch to polyblocks.  Converting groups of mathematical operations into polyblocks can also reduce the number of variables\r\n\\item For polyblocks with sparse entries, create matrices using Matlab function sparse.  This reduces memory storage and computations are optimized within Matlab.\r\n\\end{itemize}•\r\n\r\n\\clearpage\r\n\\section{Currently Supported Simulink Blocks}\r\n\\begin{multicols}{2}\r\n\\begin{itemize*}\t\r\n\\item Sum, Add, Subtract \r\n\\item Product, Multiply, Divide\r\n\\item Gain\r\n\\item Unary Minus\r\n\\item Bias\r\n\\item Math\r\n\\vspace{-5pt}\r\n\t\\begin{itemize*}\r\n\t\\item square\r\n\t\\item sqrt\r\n\t\\item reciprocal\r\n\t\\item exp\r\n\t\\item 10\\string^u\r\n\t\\item log\r\n\t\\item log10\r\n\t\\item magnitude\\string^2 (Reals only)\r\n\t\\item 1/sqrt, rsqrt\r\n\t\\item hypot\r\n\t\\end{itemize*}•\r\n\\item Trigonometry\r\n\\vspace{-5pt}\r\n\t\\begin{itemize*}\r\n\t\\item sin\r\n\t\\item cos\r\n\t\\item tan\r\n\t\\item asin\r\n\t\\item acos\r\n\t\\item atan\r\n\t\\item sincos\r\n\t\\end{itemize*}•\r\n\\item Polynomial\r\n\\item Constant\r\n\\item Unit Delay\r\n\\item Subsystem\r\n\\item From, Goto\r\n\\item Mux, Demux\r\n\\end{itemize*}•\r\n\r\n\\end{multicols}\r\n\r\n\\end{document}", "meta": {"hexsha": "64e1acb9cb6deb77f23035e5bf4f06abf7bf0816", "size": 6703, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/QuickStartGuide/Quickstart.tex", "max_stars_repo_name": "MPC-Berkeley/BLOM", "max_stars_repo_head_hexsha": "6c307a552e71dcdac155ae08719d15108b1a5c22", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-04-19T07:00:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T12:54:59.000Z", "max_issues_repo_path": "Docs/QuickStartGuide/Quickstart.tex", "max_issues_repo_name": "MPC-Berkeley/BLOM", "max_issues_repo_head_hexsha": "6c307a552e71dcdac155ae08719d15108b1a5c22", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Docs/QuickStartGuide/Quickstart.tex", "max_forks_repo_name": "MPC-Berkeley/BLOM", "max_forks_repo_head_hexsha": "6c307a552e71dcdac155ae08719d15108b1a5c22", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-09-29T05:23:43.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-29T03:19:04.000Z", "avg_line_length": 33.515, "max_line_length": 354, "alphanum_fraction": 0.726689542, "num_tokens": 2195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4285933028274052}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{bssn-eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.67.084023 equation (19)}\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'bssn-constraints.json'\n   cdblib.create (jsonfile)\n\n   # --------------------------------------------------------------------------\n   # Hamiltonian constraint\n\n   Ham := R + K_{a b} g^{a b} K_{c d} g^{c d} - K_{a b} K_{c d} g^{a c} g^{b d}.\n                                                             # cdb(Ham.101,Ham)\n\n   Ham := R + (2/3) (trK)**2 - ABar_{a b} ABar^{a b}.        # cdb(Ham.102,Ham)\n\n\\end{cadabra}\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}\n      {\\cal H}\n         = \\Cdb*{Ham.101}\n         = \\Cdb*{Ham.102}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\section*{PhysRevD.67.084023 equation (20)}\n\n\\begin{cadabra}\n   # --------------------------------------------------------------------------\n   # Momentum constraint\n\n   confMom := 6 ABar^{i a} \\partial_{a}{\\phi}\n              + \\partial_{a}{ABar^{i a}}\n              + ABar^{a b} GammaBar^{i}_{a b}\n              - (2/3) gBar^{i a} \\partial_{a}{trK}.\n\n   defGammaBar := GammaBar^{a}_{b c} ->\n                  (1/2) gBar^{a e} (   \\partial_{b}{gBar_{e c}}\n                                     + \\partial_{c}{gBar_{b e}}\n                                     - \\partial_{e}{gBar_{b c}}).\n\n   substitute (confMom, defGammaBar)                       # cdb(confMom.101,confMom)\n   distribute (confMom)                                    # cdb(confMom.102,confMom)\n\n   confMom = product_sort (confMom)                        # cdb(confMom.103,confMom)\n\n   rename_dummies (confMom)                                # cdb(confMom.104,confMom)\n   canonicalise   (confMom)                                # cdb(confMom.105,confMom)\n\n   foo := \\partial_{a}{ABar^{i a}} -> \\partial_{a}{gBar^{i c} gBar^{a d} ABar_{c d}}.\n\n   substitute   (confMom, foo)                             # cdb(confMom.106,confMom)\n   product_rule (confMom)                                  # cdb(confMom.107,confMom)\n\n   confMom = product_sort (confMom)                        # cdb(confMom.108,confMom)\n\n   rename_dummies (confMom)                                # cdb(confMom.109,confMom)\n   canonicalise   (confMom)                                # cdb(confMom.110,confMom)\n\n   cdblib.put ('Ham',Ham,jsonfile)\n   cdblib.put ('confMom',confMom,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      \\exp(4\\phi) {\\cal D}^{j}\n         = \\Cdb*{confMom.101}\n         = \\Cdb*{confMom.102}\n         = \\Cdb*{confMom.103}\n         = \\Cdb*{confMom.104}\n         = \\Cdb*{confMom.105}\n         = \\Cdb*{confMom.106}\n         = \\Cdb*{confMom.107}\n         = \\Cdb*{confMom.108}\n         = \\Cdb*{confMom.109}\n         = \\Cdb*{confMom.110}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "5dcae384c459783329e5de8bc119cdd7c3ea0bdb", "size": 2824, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bssn/cadabra/bssn-constraints.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-numerical", "max_stars_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-25T11:36:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T11:36:06.000Z", "max_issues_repo_path": "bssn/cadabra/bssn-constraints.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-numerical", "max_issues_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bssn/cadabra/bssn-constraints.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-numerical", "max_forks_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6956521739, "max_line_length": 85, "alphanum_fraction": 0.4645892351, "num_tokens": 874, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4285932989014979}}
{"text": "\\documentclass[11pt,a4paper]{report}\n\\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}\n\\usepackage{enumitem}\n\\usepackage{changepage}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{hyperref}\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem*{cor}{Corollary}\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\\newtheorem{conj}{Conjecture}[section]\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{exercise}{Exercise}[section]\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\\newtheorem*{note}{Note}\n\\def\\changemargin#1#2{\\list{}{\\rightmargin#2\\leftmargin#1}\\item[]}\n\\let\\endchangemargin=\\endlist \n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.92}\n\\hypersetup{\n\tcolorlinks=true,\n\tlinkcolor=blue,\n\tfilecolor=magenta,      \n\turlcolor=cyan,\n}\n\\urlstyle{same}\n\\lstdefinestyle{mystyle}{\n\tbackgroundcolor=\\color{backcolour},   \n\tcommentstyle=\\color{codegreen},\n\tkeywordstyle=\\color{magenta},\n\tnumberstyle=\\tiny\\color{codegray},\n\tstringstyle=\\color{codepurple},\n\tbasicstyle=\\footnotesize,\n\tbreakatwhitespace=false,         \n\tbreaklines=true,                 \n\tcaptionpos=b,                    \n\tkeepspaces=true,                 \n\tnumbers=left,                    \n\tnumbersep=5pt,                  \n\tshowspaces=false,                \n\tshowstringspaces=false,\n\tshowtabs=false,                  \n\ttabsize=2\n}\n\\lstset{style=mystyle}\n\\begin{document}\n\n\\section*{Problem}\nSuppose that you have one thousand single dollar bills and you want to put it into a set of envelopes in such a way that any amount up to \\$1000 can be made by combining the contents of some subset of the envelopes.  What is the smallest number of envelopes that you need and how would you stuff them?\n\\\\\n\\\\\n\\textit{Source:} This problem is from \\href{https://www.cartalk.com}{Car Talk}\n\n\\section*{Solution}\n Use 1, 2, 4, 8, 16, 32, 64, 128, 256 and 489.  To see why this will give all the sums, note that every number has a binary expansion and the expansion of any number up to 511 is a sum of the first nine powers of 2.  To get the rest of the numbers, you can start with 489 and then get the remainder in the same way.  \n \\\\\n \\\\\n What is interesting to prove is that this can't be done with fewer than 10 envelopes and this solution is unique.\n \n\n\\end{document}\n\n", "meta": {"hexsha": "5bd8291e321a119305d5be2cb878117593d930f2", "size": 2517, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sums/sums.tex", "max_stars_repo_name": "psteitz/problems", "max_stars_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sums/sums.tex", "max_issues_repo_name": "psteitz/problems", "max_issues_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-03T21:08:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T21:08:11.000Z", "max_forks_repo_path": "sums/sums.tex", "max_forks_repo_name": "psteitz/problems", "max_forks_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.9583333333, "max_line_length": 317, "alphanum_fraction": 0.7199046484, "num_tokens": 733, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.8438950986284991, "lm_q1q2_score": 0.42853994329062123}}
{"text": "\\lesson{5}{Dec 01 2021 Wed (19:09:04)}{Polynomial Identities and Proofs}{Unit 3}\n\n\\begin{definition}[Algebraic Proofs]\n    \\begin{itemize}\n        \\item \\bf{Polynomial Identities} can be proven to be true by simplifying the identity through application of \\bf{Algebraic Theorems} and \\bf{Principles}.\n        \\item Start with the side of the identity that can be simplified the easiest.\n        \\item Sometimes, following a \\it{“clue”} will lead to a dead-end in your \\bf{Proof}. Do not give up. Just follow a different \\it{“clue”}. The more practice you have with proofs, the more you will be able to predict the dead-ends.\n    \\end{itemize}\n\\end{definition}\n\n\\begin{example}\n\n\\end{example}\n\n\\subsubsection*{Application to Numerical Relationships}\n\nPolynomial identities apply to more than just polynomials. Replacing the variables with numbers can help prove numerical relationships as well.\n\n\\newpage\n", "meta": {"hexsha": "713ec4e54e8b94bf3e225b0d2e479ba355493a8d", "size": 904, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Grade-10/semester-1/hs-algebra-2/unit-3/lesson-5.tex", "max_stars_repo_name": "SingularisArt/notes", "max_stars_repo_head_hexsha": "de33e73ca7df9d3adcb094aa9909ea0337e68fad", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-08-31T12:45:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T07:29:05.000Z", "max_issues_repo_path": "Grade-10/semester-1/hs-algebra-2/unit-3/lesson-5.tex", "max_issues_repo_name": "SingularisArt/notes", "max_issues_repo_head_hexsha": "de33e73ca7df9d3adcb094aa9909ea0337e68fad", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Grade-10/semester-1/hs-algebra-2/unit-3/lesson-5.tex", "max_forks_repo_name": "SingularisArt/notes", "max_forks_repo_head_hexsha": "de33e73ca7df9d3adcb094aa9909ea0337e68fad", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.2, "max_line_length": 237, "alphanum_fraction": 0.7488938053, "num_tokens": 238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526660244838, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.42853637004095424}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%                                                                 %\n%  GEANT manual in LaTeX form                              %\n%                                                                 %\n%  Michel Goossens (for translation into LaTeX)                   %\n%  Version 1.00                                                   %\n%  Last Mod. Jan 24 1991  1300   MG + IB                          %\n%                                                                 %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\Origin{R.Brun, F.Carena}\n\\Submitted{01.06.83}             \\Revised{14.12.93}\n\\Version{Geant 3.16}\\Routid{GEOM200}\n\\Makehead{Rotation matrices}\n\nThe relative position of a volume inside its mother is expressed in\n{\\tt GEANT} by a translation vector and a rotation matrix which are \narguments of the routines \\Rind{GSPOS} and \\Rind{GSPOSP}. The rotation\nmatrix expresses the transformation from the {\\tt M}other {\\tt R}eference\n{\\tt S}ystem to the {\\tt D}aughter {\\tt R}eference {\\tt S}ystem.\n\nA rotation matrix is described to {\\tt GEANT} by giving the polar and\nazimuthal angles of the axes of the {\\tt DRS} ($x', y', z'$) in the\n{\\tt MRS} via the routine \\Rind{GSROTM}.\n\n\\Shubr{GSROTM}{(IROT,THETA1,PHI1,THETA2,PHI2,THETA3,PHI3)}\n\\begin{DLtt}{MMMMMMMM}\n\\item[IROT] ({\\tt INTEGER}) number of the rotation matrix;\n\\item[THETA1] ({\\tt REAL}) polar angle for axis $x'$;\n\\item[PHI1] ({\\tt REAL}) azimuthal angle for axis $x'$;\n\\item[THETA2] ({\\tt REAL}) polar angle for axis $y'$;\n\\item[THI2] ({\\tt REAL}) azimuthal angle for axis $y'$;\n\\item[THETA3] ({\\tt REAL}) polar angle for axis $z'$;\n\\item[PHI3] ({\\tt REAL}) azimuthal angle for axis $z'$.\n\\end{DLtt}\nStores rotation matrix {\\tt IROT} in the data structure {\\tt JROTM}. If the\nmatrix is not orthonormal, it will be corrected by setting $y' \\perp x'$ and\nthen $z' = x' \\times y'$. A warning message is printed in this case.\n\n{\\bf Note:}\nthe angles {\\tt THETA} and {\\tt PHI} must be given in degrees.\n \n\\section*{Examples of use}\nThe unit matrix is defined in the following way:\n\n\\[\n\\left . \\begin{array}{lcl}\nx' & \\| & x \\\\\ny' & \\| & y \\\\\nz' & \\| & z\n\\end{array} \\right \\}\n\\Rightarrow\n\\left \\{\n\\begin{array}{lcr@{\\mbox{\\hspace{3mm};\\hspace{8mm}}}lcr}\n\\theta_1 & = & 90^{\\circ} & \\phi_1 & = & 0^{\\circ} \\\\\n\\theta_2 & = & 90^{\\circ} & \\phi_2 & = & 90^{\\circ} \\\\\n\\theta_3 & = & 0^{\\circ} & \\phi_3 & = & 0^{\\circ} \n\\end{array} \\right .\n\\]\n\nThis is just an example. There is in fact no need to define a unit rotation\nmatrix. Giving the value 0 to the rotation matrix number in the call to\n\\Rind{GSPOS} and \\Rind{GSPOSP} is equivalent to a positioning without \nrotation and it improves tracking performance.\n\nThe result of a $90^{\\circ}$ counterclockwise rotation around $z$, followed\nby a $90^{\\circ}$ counterclockwise rotation around the new $x$ is a cyclic\nshift of the axes: $x \\rightarrow z', \\; y \\rightarrow x', \\; z \\rightarrow  \ny'$. This is expressed by the following rotation matrix:\n\n\\[\n\\left . \\begin{array}{lcl}\nx' & \\| & y \\\\\ny' & \\| & z \\\\\nz' & \\| & x\n\\end{array} \\right \\}\n\\Rightarrow\n\\left \\{\n\\begin{array}{lcr@{\\mbox{\\hspace{3mm};\\hspace{8mm}}}lcr}\n\\theta_1 & = & 90^{\\circ} & \\phi_1 & = & 90^{\\circ} \\\\\n\\theta_2 & = & 0^{\\circ} & \\phi_2 & = & 0^{\\circ} \\\\\n\\theta_3 & = & 90^{\\circ} & \\phi_3 & = & 0^{\\circ} \n\\end{array} \\right .\n\\]\n\nSometimes the rotation matrix is known or it can be constructed. In this case\nthe arguments to the routine \\Rind{GSROTM} can be calculated with the help\nof the routine \\Rind{GFANG} in the following way:\n\n\\begin{verbatim}\n      DIMENSION ROTMAT(3,3), ROWMAT(3), PHI(3), THETA(3)\n      LOGICAL ROTATE\n      .\n      .\n      .\n      DO 10 I=1,3\n         ROWMAT(1) = ROTMAT(I,1)\n         ROWMAT(2) = ROTMAT(I,2)\n         ROWMAT(3) = ROTMAT(I,3)\n         CALL GFANG(ROWMAT,COSTH,SINTH,COSPH,SINPH,ROTATE)\n         THETA(I) = ATAN2(SINTH,COSTH)\n         PHI(I)   = ATAN2(SINPH,COSPH)\n  10  CONTINUE\n      .\n      . {\\sl Transform to degrees}\n      .\n      CALL GSROTM(IROT,THETA(1),PHI(1),THETA(2),PHI(2),THETA(3),PHI(3))\n\\end{verbatim}\n \n\\Shubr{GPROTM}{(IROT)}\nPrints the rotation matrix elements and angles.\n\\begin{DLtt}{MMMMMMMM}\n\\item[IROT]  ({\\tt INTEGER}) rotation matrix number: if {\\tt IROT}=0 all\nrotation matrixes will be printed, if {\\tt IROT}$<$0, matrix number\n{\\tt |IROT|} will be printed without header information.\n\\end{DLtt}\n \n", "meta": {"hexsha": "04ee28acffaf78c20ed959eb355c6f0ee037e4aa", "size": 4442, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant/geom200.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant/geom200.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant/geom200.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9658119658, "max_line_length": 77, "alphanum_fraction": 0.581719946, "num_tokens": 1419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4285363590538048}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Third Chapter **********************************\n%*******************************************************************************\n\\chapter{Complexity Conjectures} \\label{chap:complexity}\n\n% **************************** Define Graphics Path **************************\n\\ifpdf\n    \\graphicspath{{Chapter3/Figs/Raster/}{Chapter3/Figs/PDF/}{Chapter3/Figs/}}\n\\else\n    \\graphicspath{{Chapter3/Figs/Vector/}{Chapter3/Figs/}}\n\\fi\n\n\\section{Exponential Time Hypothesis}\nOf all the algorithms covered in the previous chapter, they all had exponential computational\ntime complexity, with all of the backtracking based algorithms requiring $\\mathcal{O}^*(2^n)$ in the worst case. Slightly better was\nSch\\\"oning's Algorithm \\ref{alg:schoning}, which had a complexity of\n$\\mathcal{O}^*((2 - \\frac{2}{k})^n)$. However, for a general formula in CNF\n$k$ could be arbitrarily large and as $k \\to \\infty$ then we recover the same\ncomplexity as the other algorithms. So even when considering the case where we\nhave a 3SAT instance, we are unable to improve over the\nexponential complexity.\n\n\\nomenclature[x-Ostar]{$\\mathcal{O}^{\\ast}(\\cdot)$}{Big-O ignoring polynomial factors}\n\nWe know that $k$-SAT is NP-COMPLETE for $k \\geq 3$\\cite{schaefer1978complexity},\nso unless $P = NP$ we should not expect to find a polynomial time algorithm.\nHowever, it is still theoretically possible, under the assumption that $P \\neq NP$, for there to exist an algorithm which is superpolynomial but subexponential.\nHere we say that $f(x)$ is subexponential if it is $\\mathcal{O}^{\\ast}(2^{\\epsilon n})$ for all\n$\\epsilon > 0, \\quad \\epsilon \\in \\mathbb{R}$ with $\\mathcal{O}^{\\ast}(g(x))$ meaning $\\mathcal{O}(poly(n) \\cdot g(x))$,\ni.e. ignoring polynomial factors. Such an algorithm\ncould have running time $T(n) = \\mathcal{O}^{\\ast}(2^{\\frac{n}{\\log n}})$ which is \n$\\mathcal{O}^{\\ast}(2^{\\epsilon n}),\\quad \\epsilon > 0$.\nHowever, no such algorithm for SAT has been found.\n\nDue to the seeming difficulty of finding significantly faster $k$-SAT algorithms\nthere have been two conjectures\nput forward by Impagliazzo and Paturi, which\nrelate to the complexity of $k$-SAT. These are the ``Exponential Time Hypothesis'' and the ``Strong\nExponential Time Hypothesis'', abbreviated to ETH and SETH respectively \\cite{impagliazzo2001complexity}.\n\n\\nomenclature[z-ETH]{ETH}{Exponential Time Hypothesis}\n\\nomenclature[z-SETH]{SETH}{Strong Exponential Time Hypothesis}\n\nInformally ETH hypothesises that there does not exist a subexponential time algorithm solving SAT.\nMore formally, consider the set of all $k$-SAT algorithms and\nexpress their time complexities in the form $\\mathcal{O}^{\\ast}(2^{\\delta n})$\nfor some constant $\\delta \\in \\mathbb{R}^{+} \\cup \\{0\\}$.\nThen for $k \\in \\mathbb{N}, \\quad k \\geq 3$ let $s_k$ be the infimum\nof $\\delta$s taken from this set\n\\begin{equation} \\label{eq:ETH}\n    s_k = \\inf \\{\\delta: \\text{$k$-SAT is solvable in time } \\mathcal{O}^{\\ast}(2^{\\delta n})\\}\n\\end{equation}\nThe ETH then states that $s_{3} > 0$ \\cite{impagliazzo2001complexity}.\nIntuitively this means that there must exist some non-zero constant $s_{3}$ such\nthat solving 3-SAT takes time $\\Omega^{\\ast}(2^{s_{3} n})$ which rules out\na subexponential time algorithm for 3-SAT.\nThe statement that $s_3 > 0$ is equivalent to the statement that\nfor all $k \\in \\mathbb{N}$ if $k \\geq 3$ then $s_k > 0$,\ni.e. there then cannot exist a subexponential time\nalgorithm for $k$-SAT with $k \\geq 3$. This is because a 3-CNF can be easily\nreduced to a $k$-CNF for all $k \\geq 3$.\n\nIf we, instead of considering all $k$-SAT algorithms, consider just Sch\\\"oning's\nalgorithm, then we get a new sequence of $s'_k$ where \n$\\forall k \\in \\mathbb{N}: s'_k \\geq s_k$. Rearranging the complexity\nof Sch\\\"oning's algorithm we get that\n\n\\begin{equation} \\label{eq:sk_schoing}\n    s'_k = \\log_2(2 - \\frac{2}{k}), \\quad k \\geq 3\n\\end{equation}\n\nwhich yields the sequence $\\sim 0.415, \\sim 0.585, \\sim 0.678, \\dots$ for\n$k= 3,4,5, \\dots$. It is clear from Equation \\ref{eq:sk_schoing} that\nas $k \\to \\infty$ then $s'_k \\to 1$.\nThere are known algorithms that produce smaller constants \\cite{hofmeister2002probabilistic},\nhowever these algorithms still generate a sequence that tends to 1 as\n$k \\to \\infty$.\n\nThe ``Strong Exponential Time Hypothesis'' (SETH) considers this limit\nas $k$ tends to infinity. SETH states that\n\\begin{equation} \\label{eq:SETH}\n    \\lim_{k \\to \\infty} s_{k} = 1\n\\end{equation}\nIntuitively, if SETH were proven true,\nthis would mean that for general SAT there is no algorithm that is\nasymptotically faster than brute force search and algorithms\nsuch as DP, DPLL and CDCL would be optimal up to subexponential factors.\n% highlight any differences between the formalism and the intuition\n\n\\subsection{Conditional Lower Bounds}\nThe ETH and SETH both imply that $P \\neq NP$, so we should not hope to\nprove either conjecture just yet. However, we can consider the implications\nthat these conjectures would have on other problems if they were proven true.\nThis allows for us to show that many problems have conditional lower bounds\non their complexity and for many problems that current algorithms\nare optimal assuming one of these conjectures.\n\nIf we consider attempting to show lower bounds from an assumption of the ETH,\nthen since the ETH deals with the non-existence of subexponential time algorithms\nfor $k$-SAT, we could hope to reduce $k$-SAT to a number of different problems in\nsuch a way that preserves subexponential time.\n\nSince we are dealing with parameterized complexities for $k$-SAT with parameters\n$n$ and $m$, when considering general problems we will use the mapping\n$\\kappa: \\Sigma^* \\mapsto \\mathbb{N}$ to denote the parameter an instance\nof the problem $x \\in \\Sigma^*$. Where $\\Sigma^*$ is the set of problem instances.\n\n\\begin{definition}\n    A Turing reduction from a problem $(A_1, \\kappa_1)$ to a problem\n    $(A_2, \\kappa_2)$ is considered a SERF-T reduction if\n    \\begin{enumerate}\n        \\item The reduction on an instance $x$ of $A_1$\n        runs in time $\\mathcal{O}(2^{\\epsilon \\kappa_1(x)}|x|^{\\mathcal{O}(1)})$\n        for a choice of $\\epsilon > 0$.\n        \\item For a query to $A_2$ with input $x'$:\n        \\begin{enumerate}\n            \\item $|x'| \\leq |x|^{\\mathcal{O}(1)}$\n            \\item $\\kappa_2(x') \\leq \\alpha \\kappa_1(x)$\n        \\end{enumerate}\n        Where the constants hidden in the $\\mathcal{O}(\\cdot)$ do not\n        depend on the choice of $\\epsilon$.\n        The constant $\\alpha$ may depend on $\\epsilon$\n    \\end{enumerate}\n\\end{definition}\n\nTo see how this works, consider two parameterized problems $(A_1, \\kappa_1)$\nand $(A_2, \\kappa_2)$, where the second problem has a parameterized\nsubexponential time algorithm. We wish to show that if $(A_1, \\kappa_1)$ is\nSERF-T reducible to $(A_2, \\kappa_2)$ then there also exists a parameterized\nsubexponential time algorithm for $(A_1, \\kappa_1)$, i.e. for a choice of\n$\\epsilon > 0$ we need to show that $(A_1, \\kappa_1)$ runs in time\n$\\mathcal{O}(2^{\\epsilon \\kappa_1(x)}|x|^{\\mathcal{O}(1)})$.\n\nDo show this, choose an $\\epsilon > 0$.\nLet $\\epsilon' = \\frac{\\epsilon}{2}$ and run the SERF-T reduction\nwith parameter $\\epsilon'$. Since this reduction runs in time\n$\\mathcal{O}(2^{\\epsilon' \\kappa_1(x)}|x|^{\\mathcal{O}(1)})$ then this bounds\nthe number of calls to $(A_2, \\kappa_2)$ by the same amount.\nEach call to $(A_2, \\kappa_2)$ has an instance $|x'| \\leq |x|^{\\mathcal{O}(1)}$\nand $\\kappa_2(x') \\leq \\alpha \\kappa_1(x)$.\nSince, from our assumption that $(A_2, \\kappa_2)$ runs in parameterized subexponential\ntime we can choose $\\epsilon'' = \\frac{\\epsilon'}{\\alpha}$ and then each call to $(A_2, \\kappa_2)$ can be made to run in time \n\\begin{equation}\n    \\mathcal{O}(2^{\\epsilon' \\kappa_1(x)}|x|^{\\mathcal{O}(1)})\n\\end{equation}\nTherefore, the total time for solving $(A_1, \\kappa_1)$ is given by\n\\begin{equation}\n    \\mathcal{O}(2^{\\epsilon' \\kappa_1(x)}|x|^{\\mathcal{O}(1)}) \\cdot\n    \\mathcal{O}(2^{\\epsilon' \\kappa_1(x)}|x|^{\\mathcal{O}(1)}) =\n    \\mathcal{O}(2^{\\epsilon \\kappa_1(x)}|x|^{\\mathcal{O}(1)})\n\\end{equation}\nwhich is what we wanted to show. \\cite{lokshtanov2013lower}\n\n\\subsubsection{Lower Bounds for 3-colouring}\n\nTo show that ETH implies that there is no subexponential time algorithm for 3-colourability\nwe must show that the standard reduction from 3-SAT to 3-colourability is also\na SERF-T reduction. The first requirement that the reduction runs in time \n$\\mathcal{O}(2^{\\epsilon \\kappa_1(x)}|x|^{\\mathcal{O}(1)})$ for all $\\epsilon > 0$ is trivially\nsatisfied since the reduction runs in polynomial time.\nHence it also follows that the reduced instance $|x'| \\leq |x|^{\\mathcal{O}(1)}$.\n\nThus, the only thing left to show is that $\\kappa_2(x') \\leq \\alpha \\kappa_1(x)$ for\nsome constant $\\alpha$. In this case $\\kappa_2(x')$ would be the number of vertices\nin the reduced instance and $\\kappa_1(x) = n$.\n\nTo do this, recall the the standard reduction reduction from 3-SAT to 3-colourability\n(see Figure \\ref{fig:reduce_3col}).\nWe have a triangle and label the vertices as True, False and Base.\nFor each variable $x_i$ we create vertices labelled $x_i$ and $\\neg x_i$ and\nedges $(x_i, \\neg x_i), (x_i, \\text{Base}), (\\neg x_i, \\text{Base})$. Then\nfor each clause we have two ``or'' gadgets that consist of 3 vertices.\nThus, the total number of vertices in the instance $x'$ is given by\n\\begin{equation}\n    \\kappa_2(x') = 2n + 3m + 3\n\\end{equation}\nThis appears to be an issue, since we are unable to make $\\kappa_2(x')$ linear in $n$\nsince $m$ could be a superlinear function of $n$ for an arbitrary instance of 3-SAT $x$.\nHowever, we can make use of the sparsification lemma \\cite{impagliazzo2001problems} to\nreduce any $k$-SAT instance into a subexponential number of $k$-SAT instances where\n$m$ is linear in $n$ and this takes subexponential time. We will detail the\nsparsification lemma in Chapter \\ref{chap:sparsication}.\n\nHence, to get our SERF-T reduction we first apply the sparsification lemma to\nreduce our original instance $x$ into subexponentially many new $k$-SAT instances\nand apply our standard 3-SAT to 3-colourability reduction to each new instance.\nSince we can now guarantee that $m$ is $\\mathcal{O}(n)$ then $2n + 3m + 3$ is also\n$\\mathcal{O}(n)$. We let $\\alpha$ be the constant hidden in the $\\mathcal{O}(\\cdot)$.\nSince the sparsification lemma produces a subexponential number of instances that\nare no longer than the original instance and since it runs in subexponential time, then\nwe do not violate the time constraints of the SERF-T reduction.\n\nHence we have shown that this reduction satisfies all the requirements of a SERF-T\nrequirement. We can therefore say that if 3-colourability on $|V|$ vertices can\nbe solved in time $\\mathcal{O}^{\\ast}(2^{\\epsilon \\cdot |V|})$ for all $\\epsilon > 0$\nthen 3-SAT could be solved in time $\\mathcal{O}^{\\ast}(2^{\\epsilon \\cdot n})$ \nfor all $\\epsilon > 0$, which would violate the ETH.\n\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture}\n        \\begin{scope}[auto,every node/.style={draw,circle,minimum size=2.5em}]\n        % Pallet\n        \\node (T) at (-1,0) {T};\n        \\node (F) at (1,0) {F};\n        \\node (B) at (0,-1.5) {B};\n        \n        % Variables\n        \\node (x1) at (-2, -4) {$x_1$};\n        \\node (!x1) at (-4, -4) {$\\neg x_1$};\n        \\node (x2) at (-2, -6) {$x_2$};\n        \\node (!x2) at (-4, -6) {$\\neg x_2$};\n        \\node (x3) at (-2, -8) {$x_3$};\n        \\node (!x3) at (-4, -8) {$\\neg x_3$};\n        \n        % Or gadets\n        \\node (or1a) at (1, -4) {};\n        \\node (or1b) at (2.5, -4.75) {};\n        \\node (or1c) at (1, -5.5) {};\n        \n        \\node (or2a) at (5, -4.5) {};\n        \\node (or2b) at (6.5, -5.25) {};\n        \\node (or2c) at (5, -6) {};\n        \n        \\node (or3a) at (1, -8) {};\n        \\node (or3b) at (2.5, -8.75) {};\n        \\node (or3c) at (1, -9.5) {};\n        \n        \\node (or4a) at (5, -8.5) {};\n        \\node (or4b) at (6.5, -9.25) {};\n        \\node (or4c) at (5, -10) {};\n        \\end{scope}\n        \n        \\path (T) edge (F) edge (B)\n              (B) edge (F)\n              (!x1) edge (x1)\n              (!x2) edge (x2)\n              (!x3) edge (x3)\n              (or1a) edge (or1b)\n              (or1b) edge (or1c)\n              (or1c) edge (or1a)\n              (or2a) edge (or2b)\n              (or2b) edge (or2c)\n              (or2c) edge (or2a)\n              (or3a) edge (or3b)\n              (or3b) edge (or3c)\n              (or3c) edge (or3a)\n              (or4a) edge (or4b)\n              (or4b) edge (or4c)\n              (or4c) edge (or4a)\n              (x1) edge (or1a)\n              (x2) edge (or1c)\n              (or1b) edge (or2a)\n              (x3) edge (or2c);\n              \n        \\draw (!x1) -- (-5, -5) -- (-5 , -9) -- (-1, -9) -- (or3a)\n              (!x2) -- (-5.2, -7.2) -- (-5.2, -9.5) -- (or3c)\n              (or3b) -- (or4a)\n              (!x3) -- (-4, -10.5) -- (4, -10.5) -- (or4c)\n              (or2b) -- (7, -4.75) -- (7, -1.5) -- (B)\n              (or2b) -- (7.4, -4.75) -- (7.4, 0) -- (F)\n              (or4b) -- (7.2, -8.75) -- (7.2, -1.4) -- (B)\n              (or4b) -- (7.6, -8.75) -- (7.6, 0.1) -- (F)\n              (B) -- (-0.75, -2.25) -- (-3, -2.25) -- (-3, -7) -- (!x3)\n              (B) -- (-0.75, -2.35) -- (-2.9, -2.35) -- (-2.9, -7) -- (x3)\n              (B) -- (-0.75, -2.15) -- (-3.1, -2.15) -- (-3.1, -5) -- (!x2)\n              (B) -- (-0.75, -2.45) -- (-2.8, -2.45) -- (-2.8, -5) -- (x2)\n              (B) -- (-0.75, -2.05) -- (-3.2, -2.05) -- (-3.2, -3) -- (!x1)\n              (B) -- (-0.75, -2.55) -- (-2.7, -2.55) -- (-2.7, -3) -- (x1);\n        \n    \\end{tikzpicture}\n    \\caption[Reduction to 3-colourability]{Standard reduction of \n    $(x_1 \\lor x_2 \\lor x_3) \\land (\\neg x_1 \\lor \\neg x_2 \\lor \\neg x_3)$ to 3-colourability}\n    \\label{fig:reduce_3col}\n\\end{figure}\n\nUsing similar techniques we can also establish that the ETH implies that\nthere are no subexponential time algorithms for the following \\cite{lokshtanov2013lower}.\n\\begin{itemize}\n    \\item Independent Set\n    \\item Dominating Set\n    \\item Vertex Cover\n    \\item Hamiltonian Path\n\\end{itemize}\n\n\\subsubsection{Lower Bounds for Planar Graph Problems}\nNote that the SERF-T reduction from 3-SAT to 3-colourability depended on the\nfact that the number of vertices in the\n3-colourability instance was linear in the in the number of variables\nin the 3-SAT instance. Typically for planar graph problems, this\nproperty cannot be obtained.\n\nFor instance the reduction from 3-SAT to planar hamiltonian cycle \ncreates a graph $G$ where the number of vertices is $\\mathcal{O}(m^2)$ \\cite{garey1976planar}.\nAs such we cannot establish a SERF-T reduction from 3-SAT to planar hamiltonian cycle \nparameterized by the number of vertices.\nHowever, if we let the parameter be $\\kappa_2(x') = \\sqrt{|V|}$, then it is obvious that\nthis parameter is $\\mathcal{O}(m)$. Then we can use the same techniques as before to\nestablish that the ETH implies that there is no $2^{o(\\sqrt{|V|})}$ algorithm for planar\nhamiltonian cycle.\n\nThe same argument can be made for many planar graph problems. Taken in conjunction\nwith algorithms using the planar separator theorem \\cite{lipton1979separator} this\nthen means that many planar graph algorithms are optimal \\cite{lipton1977applications}.\n\n\\subsection{Further Conditional Lower Bounds for Algorithms in P}\nProofs of conditional lower bounds are not limited to problems that\nhave superpolynomial complexities. Here we will give an example\nof a lower bound for the orthogonal vectors problem based on the assumption\nof the SETH \\cite{williams2004new}.\n\n\\begin{definition}\n    The orthogonal vectors problem is, given two sets $U$ and $V$ of bit vectors of length\n    $d$ where $|U| = |V| = n$ and $d$ is $\\omega(\\log n)$, does there exist $u \\in U$ and\n    $v \\in V$ such that $\\sum_{i = 1}^{d} u_i \\cdot v_i = 0$\n\\end{definition}\n\nBest known algorithms for orthogonal vectors take time $\\mathcal{O}(n^{2 - o(1)})$ and\nit is unknown whether there is any ``strongly subquadratic'' algorithm, i.e. an\nalgorithm taking time $\\mathcal{O}(n^{2 - \\epsilon})$ for some $\\epsilon > 0$. However,\nWilliams et al. show that SETH implies that no such algorithm exists \\cite{williams2004new}.\n\nTo show this we will need the concept a fine grained reduction. Such a reduction\nhas the property that for two problems $A$ and $B$ with best known running times\n$a(n)$ and $b(n)$ respectively, an improvement on $B$ to $\\mathcal{O}(b(n)^{1 - \\epsilon})$\nleads to an improvement on $A$ to $\\mathcal{O}(a(n)^{1 - \\delta})$ for all $\\epsilon > 0$\nand some $\\delta > 0$. Such a reduction is often denoted as a $(a(n), b(n))$-reduction \\cite{vassilevska2015hardness}\n\n\\begin{definition}\n    A fine grained reduction $M$ from problem $A$ to problem $B$ with running times\n    $a(n)$ and $b(n)$ respectively obeys the following:\n    For all $\\epsilon > 0$, there is some $\\delta > 0$ and some constant $d$\n    such that for all $n \\geq 1$ there is some constant $k_n$ and\n    \\begin{itemize}\n        \\item $M$ runs in time $d \\cdot (a(n))^{1 - \\delta}$,\n        \\item $M$ produces at most $k_n$ instances of $B$ adaptively,\n        \\item $\\sum_{i = 1}^{k_n}(b(n'_i)^{1 - \\epsilon}) \\leq d \\cdot (a(n))^{1 - \\delta}$, where $n'_i$ is the\n        $i_{\\text{th}}$ instance of $B$. \n    \\end{itemize}\n    Instance sizes $n'_i$ may depend on $n$ and $\\epsilon$, but $d$ can depend only on $\\epsilon$ and not on $n$.\n\\end{definition}\n\nThe $(2^n, n^2)$-reduction from $k$-SAT to orthogonal vectors is then as follows. Apply the sparsification lemma\nto the $k$-SAT instance, then partition the variables arbitrarily into two sets $D_1, D_2$ such\nthat each set contains $\\frac{n}{2}$ variables. Construct two sets of vectors $U_1, U_2$ as follows:\nFor all $i \\in \\{1,2\\}$ and for all assignments $\\alpha$ to the variables in $D_i$, $v_{i, \\alpha} \\in U_i$\nwhere for all clauses $C$, $v_{i, \\alpha}[C] = 0$ if and only if the clause $C$ is satisfied by the\nassignment $\\alpha$ to the variables in $D_i$, $1$ otherwise. Therefore, if two vectors are orthogonal then\nthere exists an assignment to the variables in $D_1$ and $D_2$ such that for every clause it\nis either satisfied by the assignment to $D_1$ or the assignment to $D_2$ \\cite{williams2004new}.\n\nHence, any $\\mathcal{O}(n^{2 - \\epsilon})$ time algorithm for orthogonal vectors implies that there\nis a $\\mathcal{O}(2^{(1 - \\delta)n})$ algorithm for $k$-SAT for all $k$. Therefore, the SETH\nimplies that there cannot be such an algorithm for orthogonal vectors.\n\nApplying similar techniques, SETH implies\n\\begin{itemize}\n    \\item Fr\\'echet distance cannot be computed in $\\mathcal{O}(n^{2 - \\epsilon})$ \\cite{bringmann2014walking}\n    \\item Edit distance cannot be computed in $\\mathcal{O}(n^{2 - \\epsilon})$ \\cite{backurs2015edit}\n    \\item Dynamic Time Warping distance cannot be computed in $\\mathcal{O}(n^{2 - \\epsilon})$ \\cite{bringmann2015quadratic}\n    \\item Longest Common Subsequence cannot be computed in $\\mathcal{O}(n^{2 - \\epsilon})$ \\cite{bringmann2018multivariate, polak2018hard}\n\\end{itemize}", "meta": {"hexsha": "df8295f6c674b78d6a6cf73e735c8e0bb23791b4", "size": 19248, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "IEavan/scaling-behaviour-of-SAT", "max_stars_repo_head_hexsha": "37327c09ab863cbe5a9e0a527162389b1f1e1bcb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-11T14:20:35.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-11T14:20:35.000Z", "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "IEavan/scaling-behaviour-of-SAT", "max_issues_repo_head_hexsha": "37327c09ab863cbe5a9e0a527162389b1f1e1bcb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "IEavan/scaling-behaviour-of-SAT", "max_forks_repo_head_hexsha": "37327c09ab863cbe5a9e0a527162389b1f1e1bcb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.0247933884, "max_line_length": 160, "alphanum_fraction": 0.6540939318, "num_tokens": 6119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813031051514763, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.4285123222104817}}
{"text": "\n\\section{Catalan characterization}\n\\label{sec:catalan:characterization}\n\nIn this section we tackle a modular characterization for the Catalan array\n$\\mathcal{C}$ using the congruence relation $\\equiv_{2}$ and we use \n\\autoref{fig:catalan-traditional-standard-ignore-negatives-centered-colouring-127-rows-mod2-partitioning-triangle}\nas a driver that allows us to reason \\emph{piece-wise}, studying each region of\n$\\mathcal{C}_{\\equiv_{2}}$ independently.\n\nAn important object that is repeatedly used in the rest of this paper is a\nsubset of elements lying on column $k$ of $\\mathcal{C}$ which is denoted by\n$\\vect{c}_{k}$.  Let $s,f,k\\in\\mathbb{N}$, then a \\emph{segment}\n$\\diagup_{\\lbrace\\alpha_{i}\\rbrace_{i\\in S}}^{k}$ of $\\vect{c}_{k}$ is defined\nas\n\\begin{equation}\n    \\diagup_{(s,f) }^{k}\n        %= \\left(\\vect{c}_{k},\\lbrace k+\\alpha_{i}\\rbrace_{i\\in S}\\right)\n        = \\left\\lbrace d_{k+j,k}\\in\\mathcal{C}:s\\leq j\\leq f\\right\\rbrace\n    \\label{eq:column:segment}\n\\end{equation}\nand the set of the row indices involved in it is denoted by \n$\\displaystyle\n    rows\\left(\\diagup_{(s,f)}^{k}\\right)\n        %= rows\\left(\\left(\\vect{c}_{k},\\lbrace k+\\alpha_{i}\\rbrace_{i\\in S}\\right)\\right)\n        = \\lbrace k+i:s\\leq i\\leq f \\rbrace\n    \\label{eq:column:segment:rows:function}\n$.\n\n\n\\subsection{On the very first column of $\\mathcal{C}_{\\equiv_{2}}$}\n\nThis section characterizes the very first column $\\vect{c}_{0}$ of\n$\\mathcal{C}_{\\equiv_{2}}$ \\textit{which is composed of Catalan numbers only},\nformally $C_{j}=c_{j,0}\\in\\vect{c}_{0}$ for all $j\\in\\mathbb{N}$; as an example,\nin \\autoref{fig:catalan-first-column} the segment $\\diagup_{(0,2^{4})}^{0}$ is\nhighlighted. \n\n\n\\begin{theorem}\n    Let $j,\\alpha\\in\\mathbb{N}$, then $C_{j} \\equiv_{2} 0$ unless $j=2^{\\alpha}-1$,\n    in which case $C_{2^{\\alpha}-1} \\equiv_{2} 1$ holds.\n\\end{theorem}\n\n\\begin{proof}\nThe idea is to apply the congruence relation $\\equiv_{2}$ to \\autoref{eq:catalan:coeff:rewriting}\nand to reason on the representation of $j = (j_{0},j_{1},\\ldots,j_{k})_{2}$ in base $2$.\n\nFor the first value $j=0$ we have $C_{0} \\equiv_{2} 1$ because $0 = 2^{\\alpha}-1$ for $\\alpha=0$. \n\nOn the contrary, for $j>0$ we proceed by cases on $j$'s parity:\n\\begin{itemize}\n    \\item let $j=2k$, for some $k\\in\\mathbb{N}$, so $j_{0}=0$\n        makes the subtrahend of \\autoref{eq:catalan:coeff:rewriting} vanish because\n        \\begin{displaymath}\n            {{2j}\\choose{j+1}}\n            \\equiv_{2} {{0}\\choose{1}}{{0}\\choose{j_{1}}}{{j_{1}}\\choose{j_{2}}}\n                \\ldots{{j_{k-1}}\\choose{j_{k}}}{{j_{k}}\\choose{0}}\\equiv_{2}0,\n        \\end{displaymath}\n        also the minuend vanishes because\n        \\begin{displaymath}\n            {{2j}\\choose{j}}\n            \\equiv_{2} {{0}\\choose{0}}{{0}\\choose{j_{1}}}{{j_{1}}\\choose{j_{2}}}\n                \\ldots{{j_{k-1}}\\choose{j_{k}}}{{j_{k}}\\choose{0}}\\equiv_{2}0;\n        \\end{displaymath}\n\n    \\item let $j=2\\alpha+1$, for some $\\alpha\\in\\mathbb{N}$, so $j_{0}=1$\n        makes the minuend of \\autoref{eq:catalan:coeff:rewriting} vanish because\n        \\begin{displaymath}\n            {{2j}\\choose{j}}\n            \\equiv_{2} {{0}\\choose{1}}{{1}\\choose{j_{1}}}{{j_{1}}\\choose{j_{2}}}\n                \\ldots{{j_{k-1}}\\choose{j_{k}}}{{j_{k}}\\choose{0}}\\equiv_{2}0\n                \\quad\\text{hence}\\quad\n            C_{j}\\equiv_{2}-{{2j}\\choose{j+1}}.\n        \\end{displaymath}\n        The multiplicative inverse of $-1$ modulo $2$ equals $1$ because $(-1)\\cdot 1 \\equiv_{2}1$, \n        formally $(-1)^{-1}~\\mod~2~=~1$, therefore multiplying both members by $1$ yields\n        $\\displaystyle C_{j}\\equiv_{2}{{2j}\\choose{j+1}}$.\n\n        Careful handling is necessary for the term $j+1$ \n        because $j$ is odd by hypothesis and increasing it could yield a chain of carries;\n        in particular, let $\\beta,\\gamma\\in\\mathbb{N}$, such that $\\beta>0$ and $\\beta+\\gamma=k$, in\n        \\begin{displaymath}\n            j=\\left(\\underbrace{1,1,\\ldots,1}_{\\beta},0,j_{\\beta+1},\\ldots,j_{\\beta+\\gamma}\\right)_{2}\\,\n            \\rightarrow\\,\n            j+1=\\left(\\underbrace{0,0,\\ldots,0}_{\\beta},1,j_{\\beta+1},\\ldots,j_{\\beta+\\gamma}%,j_{\\beta+\\gamma+1}\n                \\right)_{2}\n        \\end{displaymath}\n        which entails that the congruence relation\n        \\begin{displaymath}\n            %\\hspace{-2cm}\n            C_{j}\\equiv_{2}{{2j}\\choose{j+1}}\n                \\equiv_{2} \\underbrace{{{0}\\choose{0}}{{1}\\choose{0}}\n                {{1}\\choose{0}}\\ldots{{1}\\choose{0}}}_{\\beta}\n                    {{1}\\choose{1}}{{0}\\choose{j_{\\beta+1}}}{{j_{\\beta+1}}\\choose{j_{\\beta+2}}}\n                    \\ldots{{j_{\\beta+\\gamma-1}}\\choose{j_{\\beta+\\gamma}}}{{j_{\\beta+\\gamma}}\\choose{0}}%{\\beta+\\gamma+1}}\n        \\end{displaymath}\n        simplifies to\n        $\\displaystyle C_{j}\\equiv_{2} {{0}\\choose{j_{\\beta+1}}}\n                {{j_{\\beta+1}}\\choose{j_{\\beta+2}}}\n                    \\ldots{{j_{\\beta+\\gamma-1}}\\choose{j_{\\beta+\\gamma}}}$.\n        At last, $C_{j}\\equiv_{2} 1$ holds if and only if coefficients\n            $j_{\\beta+1}, \\ldots, j_{\\beta+\\gamma-1},j_{\\beta+\\gamma}$\n        are $0$ them all and this implies that\n        $\\displaystyle j=\\left(\\underbrace{1,1,\\ldots,1}_{\\beta},\\underbrace{0,0,\\ldots,0}_{k-\\beta+1}\\right)_{2}, $\n        in other words $j = 2^{\\beta+1}-1$. As boundary case, to handle $C_{1}$ correctly\n        (the argument above doesn't cover it because $\\beta>0$) observe that\n        $\\displaystyle C_{1}\\equiv_{2} {{2}\\choose{2}}\\equiv_{2} {{0}\\choose{0}}{{1}\\choose{1}}\\equiv_{2}1, $\n        as required.\n\\end{itemize}\n\\end{proof}\n\n\\iffalse\nIt is interesting to observe that if we use the ``traditional'' closed formula\nfor a Catalan coefficient $C_{j}$:\n\\begin{displaymath}\n    (j+1)\\,C_{j} = {{2j}\\choose{j}}\n\\end{displaymath}\nwhere $j=2\\alpha+1$, it would have been hard to handle, because:\n\\begin{displaymath}\n    2(\\alpha+1)\\,C_{j}\\equiv_{2} {{0}\\choose{1}}{{1}\\choose{j_{1}}}\n            \\ldots{{j_{k-1}}\\choose{j_{k}}} \\equiv_{2} 0\n\\end{displaymath}\nreduces to $0\\equiv_{2}0$, giving no opportunity to derive any\nproperty about coefficient $C_{j}$.\n\\fi\n\n\\input{catalan/first-column-include-figure.tex}\n\n\\subsection{On rows composed of \\emph{odd} coefficients only}\n\n\\begin{theorem}\n    Every row $\\vect{r}_{2^{\\alpha}-1}$ of $\\mathcal{C}_{\\equiv_{2}}$, with index $2^{\\alpha}-1$,\n    is composed of \\emph{odd} coefficients only, for $\\alpha\\in\\mathbb{N}$.\n    \\label{thm:odd:coeff:only:on:last:but:one:row}\n\\end{theorem}\n\n\\begin{proof}\n    Choose any $\\alpha\\in\\mathbb{N}$. The very first coefficient $d_{2^{\\alpha}-1,0}$\n    lying on row $\\vect{r}_{2^{\\alpha}-1}$ satisfies $d_{2^{\\alpha}-1,0}\\equiv_{2}1$. \n    What about $d_{2^{\\alpha}-1,1}$?  Recall that we can write it according to\n    \\autoref{eq:convolution:expansion:for:generic:element:in:catalan:array} as\n    \\begin{displaymath}\n        d_{2^{\\alpha}-1,1} = \\sum_{i_{1}+ i_{2}=2^{\\alpha}}{ C_{i_{1}-1}\\,C_{i_{2}-1} }\n    \\end{displaymath}\n    hence %indices $i_{1}$ and $i_{2}$ in the summation  \n    $2^{\\alpha}$ divides $i_{1}+i_{2}$ \\emph{exactly}, so\n    $\\displaystyle 1 = \\frac{i_{1}}{2^{\\alpha}}+\\frac{i_{2}}{2^{\\alpha}}$ for \n            $i_{1},i_{2}\\in\\lbrace 0,\\ldots,2^{\\alpha}\\rbrace$;\n    %, which is the same to say that\n    %$\\frac{i_{1}}{2^{\\alpha}}$ and $\\frac{i_{2}}{2^{\\alpha}}$ are both integers.\n    this implies that there exists $\\beta,\\gamma\\in\\mathbb{N}$ both lesser or\n    equal to  $\\alpha$, such that $i_{1}=2^{\\beta}$ and $i_{2}=2^{\\gamma}$,\n    respectively; by this fact, it follows that $C_{i_{1}-1}=C_{2^{\\beta}-1}\\equiv_{2}1$ and\n    $C_{i_{2}-1}=C_{2^{\\gamma}-1}\\equiv_{2}1$, therefore $C_{i_{1}-1}\\,C_{i_{2}-1}\\equiv_{2}1$.\n\n    By construction, if one index in\n    $i_{1}+ i_{2}=2^{\\alpha}$ gets fixed then the other does the same as well;\n    in particular, there are $2^{\\alpha}+1$ available choices for the first index and only \n    $1$ for the second, formally\n    \\begin{displaymath}\n        d_{2^{\\alpha}-1,1} = \\sum_{i_{1}+ i_{2}=2^{\\alpha}}{ C_{i_{1}-1}\\,C_{i_{2}-1} }\n            \\equiv_{2} \\sum_{k=1}^{2^{\\alpha}+1}{1}\\equiv_{2} 2^{\\alpha}+1\\equiv_{2} 1\\,.\n    \\end{displaymath}\n\n    On the other hand, we write an arbitrary coefficient $d_{2^{\\alpha}-1,s}$, where\n    $s\\in\\lbrace{2,\\ldots,2^{\\alpha}-1}\\rbrace$, as\n    \\begin{displaymath}\n        d_{2^{\\alpha}-1,s} = \\sum_{i_{1}+i_{2}+\\ldots+i_{s+1}=2^{\\alpha}}\n            {C_{i_{1}-1}\\,C_{i_{2}-1}\\ldots\\,C_{i_{s+1}-1}}\n    \\end{displaymath}\n    in order to repeat an argument similar to the previous one. In\n    $\\displaystyle 1 = \\frac{i_{1}}{2^{\\alpha}}+\\ldots+\\frac{i_{s+1}}{2^{\\alpha}}$ there exists one\n    index $i_{j}\\in\\lbrace 0,\\ldots,2^{\\alpha}\\rbrace$ such that satisfies\n    $i_{j}=2^{\\alpha_{j}}$, for some $\\alpha_{j}\\leq\\alpha$, which entails\n    $C_{i_{j}-1}\\equiv_{2}1$, for $j\\in\\lbrace1,\\ldots,s+1\\rbrace$. Therefore the congruences\n    \\begin{displaymath}\n        d_{2^{\\alpha}-1,s} \\equiv_{2} \\sum_{i_{1}+i_{2}+\\ldots+i_{s+1}=2^{\\alpha}}{1}\n            \\equiv_{2} {{s+2^{\\alpha}}\\choose{2^{\\alpha}}},\n    \\end{displaymath}\n    hold because the summation over indices $i_{1},\\ldots,i_{s+1}$ asks to count the\n    number of $2^{\\alpha}$-combinations of $s+1$ distinct objects each of\n    which may appear indefinitely often, in particular from $0$ to $2^{\\alpha}$ times,\n    hence the sought number is ${{(s+1)+2^{\\alpha}-1}\\choose{2^{\\alpha}}}$\n    according to \\cite[equation 10 at page 7]{riordan:intro:combinatorial:analysis}.\n\n    Again, we are interested in the parity of such coefficient, therefore\n    write $s=s_{0}+s_{1}\\,2+\\ldots+s_{\\alpha-1}\\,2^{\\alpha-1}$, because $s$ can equal\n    $2^{\\alpha}-1$ at most, and the application of the Lucas theorem yields\n    \\begin{displaymath}\n        {{s+2^{\\alpha}}\\choose{2^{\\alpha}}}\\equiv_{2}\n            {{s_{0}}\\choose{0}}{{s_{1}}\\choose{0}} \\ldots\n                {{s_{\\alpha-1}}\\choose{0}}{{1}\\choose{1}}\\equiv_{2}1\n    \\end{displaymath}\n    which, in turn, entails that each coefficient lying on a row\n    $\\vect{r}_{2^{\\alpha}-1}$ is odd, as required.\n\\end{proof}\n\n\\input{catalan/odd-row-include-figure.tex}\nIn \\autoref{fig:catalan-odd-row} row $\\vect{r}_{2^{4}-1}$ is highlighted.\n\n\\subsection{On rows composed of odd and even coefficients}\n\n\\begin{theorem}\n    Let $\\vect{r}_{2^{\\alpha}}$ be a row of $\\mathcal{C}_{\\equiv_{2}}$,\n    for some $\\alpha\\in\\mathbb{N}$. Then, excluded the very first coefficient\n    $d_{2^{\\alpha},0}$ which is even, $\\vect{r}_{2^{\\alpha}}$ is composed of\n    alternating even and odd coefficients. Formally:\n    \\begin{displaymath}\n        d_{2^{\\alpha},j}\\equiv_{2}0 \\leftrightarrow j = 2k+1\n    \\end{displaymath}\n    for some $k\\in\\mathbb{N}$.\n\\end{theorem}\n\n\\begin{proof}\n    Let $d_{2^{\\alpha},j}$ be a coefficient lying on row $\\vect{r}_{2^{\\alpha}}$,\n    for some $j\\in\\lbrace1,\\ldots,2^{\\alpha}\\rbrace$. Since $\\mathcal{C}$'s $A$-sequence is:\n    \\begin{displaymath}\n        A_{\\mathcal{C}}(t)=\\frac{1}{1-t}=1+t+t^{2}+t^{3}+t^{4}+t^{5}+t^{6}+t^{7}+t^{8}+\n            \\mathcal{O}(t^{9})\n    \\end{displaymath}\n    it follows that $d_{2^{\\alpha},j}$ can be written as the combination of $r+2$\n    coefficients lying on the previous row, namely $\\vect{r}_{2^{\\alpha}-1}$:\n    \\begin{displaymath}\n        d_{2^{\\alpha},j} = d_{2^{\\alpha}-1,j-1} +d_{2^{\\alpha}-1,j} +\\ldots+d_{2^{\\alpha}-1,j+r}\n    \\end{displaymath}\n    where $r$ satisfies $r=2^{\\alpha}-1-j$, so $2^{\\alpha}-j+1$ coefficients are\n    combined.  By \\autoref{thm:odd:coeff:only:on:last:but:one:row},\n    row $\\vect{r}_{2^{\\alpha}-1}$ is composed by \\emph{odd}\n    coefficients only, therefore proceed by cases on the parity of $j$:\n    \\begin{itemize}\n        \\item if $j$ is \\emph{odd}, assume $j=2k+1$ for some $k\\in\\mathbb{N}$, then\n            $2^{\\alpha}-2k$ coefficients are combined, which is an \\emph{even} number.\n            Adding an \\emph{even} number of \\emph{odd} numbers yield an \\emph{even} number;\n        \\item if $j$ is \\emph{even}, assume $j=2k$ for some $k\\in\\mathbb{N}$, then\n            $2^{\\alpha}-2k+1$ coefficients are combined, which is an \\emph{odd} number.\n            Adding an \\emph{odd} number of \\emph{odd} numbers yield an \\emph{odd} number.\n    \\end{itemize}\n\\end{proof}\n\n\\input{catalan/alternating-row-include-figure.tex}\nIn \\autoref{fig:catalan-alternating-row} row $\\vect{r}_{2^{4}}$ is highlighted.\n\n\\subsection{On the \\emph{mirror} segment}\n\nBefore showing new theorems, we introduce the object\n$\\Phi^{(\\alpha)}$ which denotes a particular segment contained\nin the principal cluster $\\mathcal{C}^{(\\alpha+1)}$.\nWe call $\\Phi^{(\\alpha)}$ the \\emph{mirror} segment in\n$\\mathcal{C}^{(\\alpha+1)}$ and it is defined as follows:\n\\begin{displaymath}\n    \\Phi^{(\\alpha)}=\\diagup_{\\lbrace 1,2,\\ldots,2^{\\alpha}-1\\rbrace}^{2^{\\alpha}-1}\n\\end{displaymath}\n\n\\begin{theorem}\n    Choose any $\\alpha\\in\\mathbb{N}$, then $\\Phi^{(\\alpha)}$ satisfies:\n    \\begin{displaymath}\n        d_{s,2^{\\alpha}-1}\\in\\Phi^{(\\alpha)} \\rightarrow d_{s,2^{\\alpha}-1}\\equiv_{2}0\n    \\end{displaymath}\n    where $s\\in rows\\left(\\Phi^{(\\alpha)}\\right)=\\lbrace2^{\\alpha},\\ldots,2^{\\alpha+1}-2\\rbrace$.\n    \\label{thm:mirror:segment:definition}\n\\end{theorem}\n\n\\begin{proof}\nLet $d_{s,2^{\\alpha}-1}$ a coefficient in the segment $\\Phi^{(\\alpha)}$,\naccording to \\autoref{eq:convolution:expansion:for:generic:element:in:catalan:array}\nwrite it as:\n\\begin{displaymath}\n    d_{s, 2^{\\alpha}-1} = \\sum_{i_{1}+i_{2}+\\ldots+i_{2^{\\alpha}}=s+1}\n        {C_{i_{1}-1}\\,C_{i_{2}-1}\\cdots\\,C_{i_{2^{\\alpha}}-1}}\n\\end{displaymath}\nObserve that, for $s\\in\\Phi^{(\\alpha)}$, the number of Catalan\ncoefficients multiplied together in each summand is the same, namely\n$2^{\\alpha}$.  What changes respect to $s$ is the set of values each\nindex $i_{j}$ can take. In the following table we report instantiated sets\nof values, depending on $s$, for both indexes and coefficients:\n\\begin{displaymath}\n    \\begin{array}{c|c|c}\n        s = 2^{\\alpha}\n            & i_{j}\\in\\lbrace0,\\ldots,2^{\\alpha}+1\\rbrace\n            & C_{k}\\in\\lbrace C_{-1},\\ldots,C_{2^{\\alpha}}\\rbrace\\\\\n        s = 2^{\\alpha} +1\n            & i_{j}\\in\\lbrace0,\\ldots,2^{\\alpha}+2\\rbrace\n            & C_{k}\\in\\lbrace C_{-1},\\ldots,C_{2^{\\alpha}+1}\\rbrace\\\\\n        \\vdots & \\vdots&\\vdots \\\\\n        s = 2^{\\alpha+1} -2\n            & i_{j}\\in\\lbrace0,\\ldots,2^{\\alpha+1}-1\\rbrace\n            & C_{k}\\in\\lbrace C_{-1},\\ldots,C_{2^{\\alpha+1}-2}\\rbrace\\\\\n    \\end{array}\n\\end{displaymath}\nSet $\\lbrace C_{-1},\\ldots,C_{2^{\\alpha}}\\rbrace$ and set\n$\\lbrace C_{-1},\\ldots,C_{2^{\\alpha+1}-2}\\rbrace$ are the smaller and the bigger one, respectively, and\nhave the same subset $\\Omega^{(\\alpha)}$ of \\emph{odd} coefficients:\n\\begin{displaymath}\n    \\Omega^{(\\alpha)}=\\lbrace C_{-1}, C_{2^{\\alpha-(\\alpha-1)}-1},C_{2^{\\alpha-(\\alpha-2)}-1},\\ldots,\n        C_{2^{\\alpha-1}-1},C_{2^{\\alpha}-1}\\rbrace\n\\end{displaymath}\nwhere $\\left|\\Omega^{(\\alpha)}\\right|=\\alpha+1$.\nSince each summand term $C_{i_{1}-1}\\,C_{i_{2}-1}\\ldots\\,C_{i_{2^{\\alpha}}-1}$\nhas $2^{\\alpha}$ coefficients, no matter if it contains each coefficient in $\\Omega^{(\\alpha)}$ and,\nmore importantly, one of them cannot belong to $\\Omega^{(\\alpha)}$:\nthe remaining ones make it vanish and $d_{s, 2^{\\alpha}-1} \\equiv_{2} 0$, for any suitable $s$,\nas required.\n\n\\end{proof}\n\n\\input{catalan/mirror-segment-include-figure.tex}\nIn \\autoref{fig:mirror-segment} the \\emph{mirror} segment $\\Phi^{(4)}$ is highlighted.\n\n\\subsection{On the \\emph{dual} segment of the \\emph{mirror} segment}\n\nNext theorem needs a new piece of notation that allows us to identify a\nnew portion within a principal cluster $\\mathcal{C}^{(\\alpha+1)}$.\nLet $\\hat{\\Phi}^{(\\alpha)}$ denote the set $\\left\\lbrace d_{s,s-(2^{\\alpha}-1)}\\right\\rbrace$,\nfor $s\\in rows\\left(\\Phi^{(\\alpha)}\\right)$: we call $\\hat{\\Phi}^{(\\alpha)}$\nthe \\emph{dual} segment of the \\emph{mirror} segment $\\Phi^{(\\alpha)}$.\n\n\\begin{theorem}\n    Let  $\\Phi^{(\\alpha)}=\\diagup_{\\lbrace 1,2,\\ldots,2^{\\alpha}-1\\rbrace}^{2^{\\alpha}-1}$,\n    be a \\emph{mirror} segment in $\\mathcal{C}^{(\\alpha+1)}$, then:\n    \\begin{equation}\n        d_{s,2^{\\alpha}-1}\\in\\Phi^{(\\alpha)}\\rightarrow d_{s,s-(2^{\\alpha}-1)}\\equiv_{2}d_{s,2^{\\alpha}-1}\n    \\end{equation}\n    where $s\\in rows\\left(\\Phi^{(\\alpha)}\\right)=\\lbrace2^{\\alpha},\\ldots,2^{\\alpha+1}-2\\rbrace$.\n\\end{theorem}\n\n\\begin{proof}\n    Use \\autoref{eq:catalan:array:second:identity} on both members:\n    \\begin{displaymath}\n        {{s+2^{\\alpha}-1}\\choose{2^{\\alpha}-1}}- {{s+2^{\\alpha}-1}\\choose{2^{\\alpha}-2}} \\equiv_{2}\n        {{2s-2^{\\alpha}+1}\\choose{s-2^{\\alpha}+1}}- {{2s-2^{\\alpha}+1}\\choose{s-2^{\\alpha}}}\n    \\end{displaymath}\n    by symmetry property of binomial coefficients:\n    \\begin{displaymath}\n        {{s+2^{\\alpha}-1}\\choose{s}}- {{s+2^{\\alpha}-1}\\choose{s+1}} \\equiv_{2}\n        {{2s-2^{\\alpha}+1}\\choose{s}}- {{2s-2^{\\alpha}+1}\\choose{s+1}}\n    \\end{displaymath}\n    by simplification using $(-1)^{-1}\\mod 2=1$:\n    \\begin{displaymath}\n        {{s+2^{\\alpha}-1}\\choose{s}}+ {{s+2^{\\alpha}-1}\\choose{s+1}} \\equiv_{2}\n        {{2s-2^{\\alpha}+1}\\choose{s}}+ {{2s-2^{\\alpha}+1}\\choose{s+1}}\n    \\end{displaymath}\n    by classic recurrence rule of binomial coefficients:\n    \\begin{displaymath}\n        {{s+2^{\\alpha}}\\choose{s+1}} \\equiv_{2} {{2s-2^{\\alpha}+2}\\choose{s+1}}\n    \\end{displaymath}\n    since $s$ can assume $2^{\\alpha}$ at least and $2^{\\alpha+1}-2$ at most,\n    $s$ can be written in base $2$ as follows:\n    \\begin{displaymath}\n        s=s_{0} + s_{1}2 + s_{2}2^{2}+\\ldots+s_{\\alpha-1}2^{\\alpha-1}+2^{\\alpha}\n    \\end{displaymath}\n    and applying Lucas theorem we get:\n    \\begin{displaymath}\n        %\\hspace{-2cm}\n        {{s_{0}}\\choose{s_{0}+1}}\n        {{s_{1}}\\choose{s_{1}}}\n        \\ldots\n        {{s_{\\alpha-1}}\\choose{s_{\\alpha-1}}}\n        {{0}\\choose{1}}\n        {{1}\\choose{0}}\n        \\equiv_{2}\n        {{0}\\choose{s_{0}+1}}\n        {{s_{0}+1}\\choose{s_{1}}}\n        {{s_{1}}\\choose{s_{2}}}\n        \\ldots\n        {{s_{\\alpha-2}}\\choose{s_{\\alpha-1}}}\n        {{s_{\\alpha-1}-1}\\choose{1}}\n        {{1}\\choose{0}}\n    \\end{displaymath}\n    simple algebra:\n    \\begin{displaymath}\n        0\n        \\equiv_{2}\n        {{0}\\choose{s_{0}+1}}\n        {{s_{0}+1}\\choose{s_{1}}}\n        {{s_{1}}\\choose{s_{2}}}\n        \\ldots\n        {{s_{\\alpha-2}}\\choose{s_{\\alpha-1}}}\n        {{s_{\\alpha-1}-1}\\choose{1}}\n    \\end{displaymath}\n    %\\marginpar{in order to finish this proof we have to introduce a lemma about\n    %    the row of alternating odd and even coefficient, which can be proved using\n    %    the $A$-sequence of $\\mathcal{C}$}\n    By cases on the parity of $s$:\n    \\begin{itemize}\n        \\item assume $s$ is \\emph{even}, therefore $s_{0}=0$ and the right hand side vanishes due to ${{0}\\choose{s_{0}+1}}=0$;\n        \\item assume $s$ is \\emph{odd}, therefore $s_{0}=1$, so apply Lucas theorem to ${{0}\\choose{2}}$ again,\n            yielding ${{0}\\choose{2}}\\equiv_{2}{{0}\\choose{0}}{{0}\\choose{1}}\\equiv_{2}0$.\n    \\end{itemize}\n    both cases shows that right hand side is a multiple of $p$, as required.\n\\end{proof}\n\n\\input{catalan/dual-of-mirror-segment-include-figure.tex}\nIn \\autoref{fig:dual-of-mirror-segment} the \\emph{dual} segment $\\hat{\\Phi}^{(4)}$\n    %$\\left\\lbrace d_{s,s-(2^{4}-1)}\\right\\rbrace$,\n    %for $s\\in rows\\left(\\Phi^{(4)}\\right)$,\n    of \\emph{mirror} segment $\\Phi^{(4)}$, within $\\mathcal{C}_{\\equiv_{2}}^{(5)}$, is highlighted.\n\n\\subsection{On the \\emph{upside-down} zero-hole}\n\n\\begin{theorem}\n    Let $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$ be a principal cluster\n    of order $\\alpha+1$ of the Catalan array $\\mathcal{C}$. Then, $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$\n    contains an \\emph{upside-down} zero-hole of order $\\alpha$, denoted by $H_{\\bigtriangleup}^{({\\alpha})}$,\n    such that coefficient $d_{n,k}\\in H_{\\bigtriangleup}^{({\\alpha})}$ if\n    $n\\in\\lbrace 2^{{\\alpha}},\\ldots,2^{{\\alpha}+1}-2\\rbrace$ and\n    $k\\in\\lbrace 0,\\ldots, n-2^{{\\alpha}}\\rbrace$.\n    \\label{thm:upside:down:zero:hole}\n\\end{theorem}\n\n%It is simple to observe that $H_{\\bigtriangleup}^{({\\alpha})}\\subset \\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$.\n\n\\begin{proof}\nWe repeatedly use the approach\nof the proof about the \\emph{mirror} segment, considering the set of columns\n$\\Xi=\\lbrace \\vect{c}_{0},\\ldots, \\vect{c}_{2^{{\\alpha}}-2}\\rbrace$ and\nfor each column $\\vect{c}_{k}\\in\\Xi$, the segment\n    $\\diagup_{\\lbrace 2^{\\alpha},2^{\\alpha}+1,\\ldots,2^{\\alpha+1}-2-k\\rbrace}^{k}$.\n\nIf we start from the column $\\vect{c}_{0}$ on the very left,\nthen the corresponding set of row indices is a segment of Catalan numbers:\n\\begin{displaymath}\n    S_{0}=\\diagup_{\\lbrace 2^{\\alpha},2^{\\alpha}+1,\\ldots,2^{\\alpha+1}-2\\rbrace}^{0}\n        = \\lbrace C_{2^{\\alpha}},C_{2^{\\alpha}+1},\\ldots,C_{2^{\\alpha+1}-2}\\rbrace\n\\end{displaymath}\nsince no coefficient $C_{j}\\in S_{0}$ has the shape $C_{2^{\\alpha}-1}$,\nall coefficients in $S_{0}$ are even.\n\nIn turn, take into account column $\\vect{c}_{1}$, so the corresponding segment is\n%\\begin{displaymath}\n    $S_{1}=\\diagup_{\\lbrace 2^{\\alpha},2^{\\alpha}+1,\\ldots,2^{\\alpha+1}-3\\rbrace}^{1}$\n    %S_{1}=\\lbrace d_{2^{{\\alpha}}+1,1},\\ldots,d_{2^{{\\alpha}+1}-2,1} \\rbrace\n%\\end{displaymath}\nand coefficients in it are defined according to\n$d_{s, 1} = \\sum_{i_{1}+i_{2}=s+1} {C_{i_{1}-1}\\,C_{i_{2}-1}}$,\nwhere $s\\in rows(S_{1})= \\left\\lbrace 2^{\\alpha}+1,2^{\\alpha}+2,\\ldots,2^{\\alpha+1}-2\\right\\rbrace$.\nThis is quite similar to the proof developed for the \\emph{mirror} segment,\nwith the difference that summand term is composed of two coefficients, namely\n$C_{i_{1}-1}\\,C_{i_{2}-1}$ instead of $2^{{\\alpha}}$ coefficients as in the previous proof,\ntherefore the same argument applies,\nsince if multiplying $2^{{\\alpha}}$ coefficients fails to make \\emph{not} vanish\nthe summand term, modulo $2$, the same failure is reached if multiplying only $2$ coefficients.\n\nThe same reasoning holds for remaining columns in $\\Xi$: the last one of them is\n$\\vect{c}_{2^{\\alpha}-2}$ (with only \\emph{one} coefficient, namely $d_{2^{\\alpha}-2,2^{\\alpha}-2}$),\nhence $H_{\\bigtriangleup}^{({\\alpha})}$ is an \\emph{upside-down} zero-holes of order $\\alpha$,\npositioned at the very left in the bottom half of $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$, as required.\n\n\\end{proof}\n\n\\input{catalan/zero-hole-include-figure.tex}\nIn \\autoref{fig:catalan-zero-hole} is reported $H_{\\bigtriangleup}^{(4)}$.\n\n\\subsection{On two \\emph{mirrored} clusters}\n\n\\begin{theorem}\n    Let $\\Phi^{(\\alpha)}=\\diagup_{\\lbrace 2,\\ldots,2^{\\alpha}-1\\rbrace}^{2^{\\alpha}-1}$\n    be a \\emph{mirror} segment and $d_{s,2^{{\\alpha}}-1}$\n    be a coefficient in $\\Phi^{(\\alpha)}$, for some $s\\in rows\\left(\\Phi^{(\\alpha)}\\right)$. Then:\n    \\begin{displaymath}\n        d_{s-e,2^{{\\alpha}}-1-e} \\equiv_{2} d_{s,2^{{\\alpha}}-1+e}\n    \\end{displaymath}\n    for $e\\in\\lbrace1,\\ldots,s-2^{{\\alpha}}\\rbrace$.\n    \\label{thm:two:mirrored:clusters}\n\\end{theorem}\n\n\\begin{proof}\nIn this proof we use \\autoref{eq:catalan:array:second:identity} as\nan identity defining the generic coefficient. It allows to rewrite the left hand side\nof the argument:\n\\begin{displaymath}\n    d_{s-e,2^{{\\alpha}}-1-e}= {{2(s-e)-(2^{{\\alpha}}-1-e)}\\choose{(s-e)-(2^{{\\alpha}}-1-e)}}\n        - {{2(s-e)-(2^{{\\alpha}}-1-e)}\\choose{(s-e)-(2^{{\\alpha}}-1-e)-1}};\n\\end{displaymath}\nin the same spirit, the same can be applied to the right hand side:\n\\begin{displaymath}\n    d_{s,2^{{\\alpha}}-1+e}={{2s-(2^{{\\alpha}}-1+e)}\\choose{s-(2^{{\\alpha}}-1+e)}}\n        - {{2s-(2^{{\\alpha}}-1+e)}\\choose{s-(2^{{\\alpha}}-1+e)-1}},\n\\end{displaymath}\ntherefore:\n\\begin{displaymath}\n    \\begin{split}\n        {{2s-e-2^{{\\alpha}}+1}\\choose{s-2^{{\\alpha}}+1}}\n            - {{2s-e-2^{{\\alpha}}+1}\\choose{s-2^{{\\alpha}}}}\n        &\\equiv_{2}\n        {{2s-2^{{\\alpha}}+1-e}\\choose{s-2^{{\\alpha}}+1-e}}\n            - {{2s-2^{{\\alpha}}+1-e}\\choose{s-2^{{\\alpha}}-e}}\\\\\n        {{2s-e-2^{{\\alpha}}+1}\\choose{s-e}}\n            - {{2s-e-2^{{\\alpha}}+1}\\choose{s-e+1}}\n        &\\equiv_{2}\n        {{2s-2^{{\\alpha}}+1-e}\\choose{s}}\n            - {{2s-2^{{\\alpha}}+1-e}\\choose{s+1}}\\\\\n    \\end{split}\n\\end{displaymath}\n\nSince $e\\in\\lbrace1,\\ldots,s-2^{{\\alpha}}\\rbrace$, proceed by complete induction on $e$:\n\\begin{itemize}\n    \\item base case $e=1$ yield the following congruence:\n        \\begin{displaymath}\n                {{2s-2^{{\\alpha}}}\\choose{s-1}}-{{2s-2^{{\\alpha}}}\\choose{s}}\n                \\equiv_{2}\n                {{2s-2^{{\\alpha}}}\\choose{s}}-{{2s-2^{{\\alpha}}}\\choose{s+1}}\\\\\n        \\end{displaymath}\n        which is the same to say:\n        \\begin{displaymath}\n                {{2s-2^{{\\alpha}}}\\choose{s-1}}+{{2s-2^{{\\alpha}}}\\choose{s+1}} \\equiv_{2} 0.\n        \\end{displaymath}\n        Let $s=s_{0}+s_{1}\\,2+s_{2}\\,2^{2}+\\ldots+s_{{\\alpha}-1}\\,2^{{\\alpha}-1} + 2^{{\\alpha}}$\n        be the generic representation of $s$ in base $2$, since\n        $s\\in\\lbrace 2^{{\\alpha}}+1,\\ldots,2^{{\\alpha}+1}-2 \\rbrace$; also\n        let $2s-2^{{\\alpha}}=s_{0}\\,2+s_{1}\\,2^{2}+s_{2}\\,2^{3}+\\ldots+s_{{\\alpha}-1}^{*}\\,2^{{\\alpha}} + s_{{\\alpha}}^{*}\\,2^{{\\alpha}+1}$,\n        where $(s_{{\\alpha}-1}^{*},s_{{\\alpha}}^{*})$ equals $(0,1)$ if $s_{{\\alpha}-1}=1$, otherwise equals $(1,0)$.\n        By cases on the parity of $s$:\n        \\begin{itemize}\n            \\item assume $s$ even, therefore both $s-1$ and $s+1$ are odd, so\n                let $\\hat{s}=1+\\hat{s}_{1}\\,2+\\hat{s}_{2}\\,2^{2}+\\ldots+\n                    \\hat{s}_{{\\alpha}-1}\\,2^{{\\alpha}-1}+2^{{\\alpha}}$ be one of them, hence:\n                \\begin{displaymath}\n                        {{2s-2^{{\\alpha}}}\\choose{\\hat{s}}}\n                        \\equiv_{2}\n                        {{0}\\choose{1}}\n                        {{0}\\choose{\\hat{s}_{1}}}\n                        {{s_{1}}\\choose{\\hat{s}_{2}}}\n                        \\ldots\n                        {{s_{{\\alpha}-2}}\\choose{\\hat{s}_{{\\alpha}-1}}}\n                        {{s_{{\\alpha}-1}^{*}}\\choose{1}}\n                        {{s_{{\\alpha}}^{*}}\\choose{0}} = 0.\n                \\end{displaymath}\n                Observe $\\hat{s}_{{\\alpha}}=1$ against boundary cases:\n                if $s=2^{{\\alpha}}+1$ then $\\hat{s}=s-1=2^{{\\alpha}}$, on the other\n                hand if $s=2^{{\\alpha}+1}-2$ then $\\hat{s}=s+1=2^{{\\alpha}+1}-1$,\n                therefore in both cases the coefficient of $2^{{\\alpha}}$ is $1$.\n                Eventually we get $0+0 \\equiv_{2}0$, which holds;\n\n            \\item assume $s$ odd, therefore both $s-1$ and $s+1$ are even,\n                let's study the former:\n                \\begin{displaymath}\n                        {{2s-2^{{\\alpha}}}\\choose{s-1}}\n                        \\equiv_{2}\n                        {{0}\\choose{0}}\n                        {{1}\\choose{s_{1}}}\n                        {{s_{1}}\\choose{s_{2}}}\n                        \\ldots\n                        {{s_{{\\alpha}-2}}\\choose{s_{{\\alpha}-1}}}\n                        {{s_{{\\alpha}-1}^{*}}\\choose{1}}\n                        {{s_{{\\alpha}}^{*}}\\choose{0}}\n                \\end{displaymath}\n                in order for the right hand side to not vanish, modulo $2$,\n                it is mandatory for coefficients $\\lbrace s_{i}\\rbrace_{i\\in\\lbrace1,\\ldots,{\\alpha}-2\\rbrace}$\n                to satisfy $s_{i}\\geq s_{i+1}$: if any one of them is $0$, say $s_{j}$, then\n                $s_{j+1},\\ldots,s_{j+k}$, with $j+k={\\alpha}-1$,\n                have to be all $0$ too. In particular, if $s_{{\\alpha}-1}=0$ then\n                $(s_{{\\alpha}-1}^{*},s_{{\\alpha}}^{*})=(1,0)$\n                therefore the right hand side reduces to $1$, modulo $2$.\n                Observe that coefficients $\\lbrace s_{i}\\rbrace_{i\\in\\lbrace1,\\ldots,{\\alpha}-2\\rbrace}$\n                cannot be all $1$ otherwise\n                $s=(\\underbrace{1,1,1,\\ldots,1}_{{\\alpha}+1})_{2}=2^{{\\alpha}+1}-1$ raises a contradiction, because\n                $s$ can assume $2^{{\\alpha}+1}-2$ at most.\n\n                For the latter, namely $s+1$, assume $s$ can be represented as:\n                \\begin{displaymath}\n                    (\\underbrace{1,1,\\ldots,1}_{r},0,s_{r+1},s_{r+2},\\ldots,s_{{\\alpha}-1},1)_{2}\n                \\end{displaymath}\n                for $r\\in\\lbrace1,\\ldots,{\\alpha}-2\\rbrace$. Since a $0$ must occur, otherwise $s=2^{{\\alpha}+1}-1$\n                which cannot be the case as we've already seen, adding $1$ yield the representation:\n                \\begin{displaymath}\n                    (\\underbrace{0,0,\\ldots,0}_{r},1,s_{r+1},s_{r+2},\\ldots,s_{{\\alpha}-1},1)_{2}\n                \\end{displaymath}\n                Therefore we have:\n                \\begin{displaymath}\n                    %\\hspace{-2cm}\n                    {{2s-2^{{\\alpha}}}\\choose{s+1}}\n                    \\equiv_{2}\n                    \\underbrace{\n                        {{0}\\choose{0}}\n                        {{1}\\choose{0}}\n                        {{1}\\choose{0}}\n                        \\ldots\n                        {{1}\\choose{0}}\n                    }_{r}\n                    {{1}\\choose{1}}\n                    {{0}\\choose{s_{r+1}}}\n                    {{s_{r+1}}\\choose{s_{r+2}}}\n                    \\ldots\n                    {{s_{{\\alpha}-2}}\\choose{s_{{\\alpha}-1}}}\n                    {{s_{{\\alpha}-1}^{*}}\\choose{1}}\n                    {{s_{{\\alpha}}^{*}}\\choose{0}}\n                \\end{displaymath}\n                In order to not vanish, modulo $2$,\n                $s_{r+1}$ has to be $0$; eventually, this property propagates among $s_{r+2}, \\ldots, s_{{\\alpha}-1}$.\n                But if they are all $0$, %$s_{{\\alpha}-1}=0$\n                then $(s_{{\\alpha}-1}^{*},s_{{\\alpha}}^{*})=(1,0)$, therefore the right hand side reduces to $1$.\n\n                Combining the above cases for $s$ odd we reach:\n                \\begin{displaymath}\n                        {{2s-2^{{\\alpha}}}\\choose{s-1}}+{{2s-2^{{\\alpha}}}\\choose{s+1}} \\equiv_{2} 1+1\\equiv_{2} 0\n                \\end{displaymath}\n        \\end{itemize}\n\n        \\item assume the argument holds for $k\\leq e$ and prove for $k=e+1$, so we need to show:\n            \\begin{displaymath}\n                \\footnotesize\n                %\\hspace{-3cm}\n                \\begin{split}\n                    {{2s-(e+1)-2^{{\\alpha}}+1}\\choose{s-2^{{\\alpha}}+1}}\n                        - {{2s-(e+1)-2^{{\\alpha}}+1}\\choose{s-2^{{\\alpha}}}}\n                    &\\equiv_{2}\n                    {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s-2^{{\\alpha}}+1-(e+1)}}\n                        - {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s-2^{{\\alpha}}-(e+1)}}\\\\\n                    {{2s-(e+1)-2^{{\\alpha}}+1}\\choose{s-(e+1)}}\n                        - {{2s-(e+1)-2^{{\\alpha}}+1}\\choose{s-(e+1)+1}}\n                    &\\equiv_{2}\n                    {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s}}\n                        - {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s+1}}\\\\\n                    {{2s-e-2^{{\\alpha}}}\\choose{s-e-1}}\n                        - {{2s-e-2^{{\\alpha}}}\\choose{s-e}}\n                    &\\equiv_{2}\n                    {{2s-2^{{\\alpha}}-e}\\choose{s}}\n                        - {{2s-2^{{\\alpha}}-e}\\choose{s+1}}\\\\\n                \\end{split}\n            \\end{displaymath}\n            which follows directly by complete induction hypothesis.\n\\end{itemize}\n\n\\end{proof}\n\n\\input{catalan/mirrored-clusters-include-figure.tex}\nIn \\autoref{fig:catalan-mirrored-clusters} some coefficients in \\emph{mirrored}\ncluster $\\mathcal{C}_{\\equiv_{2}}^{(4)}$ are highlighted.\n\n\\subsection{$\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$\n    contains a copy of $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha)}$}\n\nIn order to fully characterize $\\mathcal{C}$ in a modular context we are\nleft with a last theorem.\n\n\\begin{theorem}\n    $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$\n    contains a copy of $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha)}$,\n    located at the very right of its bottom half. Formally,\n    let $\\Phi^{(\\alpha)}=\\diagup_{\\lbrace 2,\\ldots,2^{\\alpha}-1\\rbrace}^{2^{\\alpha}-1}$\n    be a \\emph{mirror} segment and $d_{s,2^{{\\alpha}}-1}$\n    be a coefficient in $\\Phi^{(\\alpha)}$, for some $s\\in rows\\left(\\Phi^{(\\alpha)}\\right)$. Then:\n    \\begin{displaymath}\n        d_{s,2^{{\\alpha}}-1+e} \\equiv_{2} d_{s-2^{{\\alpha}},e-1}\n    \\end{displaymath}\n    for $e\\in\\lbrace1,\\ldots,s-2^{{\\alpha}}\\rbrace$.\n    \\label{thm:principal:cluster:copy:containment}\n\\end{theorem}\n\n\\begin{proof}\nWe tackle the proof using \\autoref{eq:catalan:array:second:identity}:\n\\begin{displaymath}\n    %\\hspace{-4cm}\n    \\begin{split}\n        {{2s-(2^{{\\alpha}}-1+e)}\\choose{s-(2^{{\\alpha}}-1+e)}} - {{2s-(2^{{\\alpha}}-1+e)}\\choose{s-(2^{{\\alpha}}-1+e)-1}}\n        &\\equiv_{2}\n        {{2(s-2^{{\\alpha}})-(e-1)}\\choose{(s-2^{{\\alpha}})-(e-1)}} - {{2(s-2^{{\\alpha}})-(e-1)}\\choose{(s-2^{{\\alpha}})-(e-1)-1}}\\\\\n        {{2s-2^{{\\alpha}}+1-e}\\choose{s-2^{{\\alpha}}+1-e}} - {{2s-2^{{\\alpha}}+1-e}\\choose{s-2^{{\\alpha}}-e}}\n        &\\equiv_{2}\n        {{2s-2^{{\\alpha}+1}-e+1}\\choose{s-2^{{\\alpha}}-e+1}} - {{2s-2^{{\\alpha}+1}-e+1}\\choose{s-2^{{\\alpha}}-e}}\\\\\n        {{2s-2^{{\\alpha}}+1-e}\\choose{s}} - {{2s-2^{{\\alpha}}+1-e}\\choose{s+1}} &\\equiv_{2}\n        {{2s-2^{{\\alpha}+1}-e+1}\\choose{s-2^{{\\alpha}}}} - {{2s-2^{{\\alpha}+1}-e+1}\\choose{s-2^{{\\alpha}}+1}}\\\\\n    \\end{split}\n\\end{displaymath}\nSince $e\\in\\lbrace1,\\ldots,s-2^{{\\alpha}}\\rbrace$, proceed by complete induction on $e$:\n    \\begin{itemize}\n        \\item for the base case $e=1$ we have:\n            \\begin{displaymath}\n                %\\begin{split}\n                    {{2s-2^{{\\alpha}}}\\choose{s}} - {{2s-2^{{\\alpha}}}\\choose{s+1}} \\equiv_{2}\n                        {{2s-2^{{\\alpha}+1}}\\choose{s-2^{{\\alpha}}}} - {{2s-2^{{\\alpha}+1}}\\choose{s-2^{{\\alpha}}+1}}.\n                %\\end{split}\n            \\end{displaymath}\n            In the previous proof a detailed (and boring) derivation has been performed,\n            here we observe that upper terms of each binomial coefficient, $2s-2^{{\\alpha}}$\n            and $2s-2^{{\\alpha}+1}$ respectively, have $2$ in their prime factorization, therefore\n            expanding each binomial, $2$ can be factored out in turn, making congruent $0$\n            each one of them. However an approach similar to the previous one can be\n            taken as well.\n\n        \\item assume the argument holds for $k\\leq e$ and prove for $k=e+1$, so we need to show:\n            \\begin{displaymath}\n                %\\hspace{-3cm}\n                \\footnotesize\n                \\begin{split}\n                    {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s}} - {{2s-2^{{\\alpha}}+1-(e+1)}\\choose{s+1}}\n                    &\\equiv_{2}\n                    {{2s-2^{{\\alpha}+1}-(e+1)+1}\\choose{s-2^{{\\alpha}}}} - {{2s-2^{{\\alpha}+1}-(e+1)+1}\\choose{s-2^{{\\alpha}}+1}}\\\\\n                    {{2s-2^{{\\alpha}}-e}\\choose{s}} - {{2s-2^{{\\alpha}}-e}\\choose{s+1}}\n                    &\\equiv_{2}\n                    {{2s-2^{{\\alpha}+1}-e}\\choose{s-2^{{\\alpha}}}} - {{2s-2^{{\\alpha}+1}-e}\\choose{s-2^{{\\alpha}}+1}}\\\\\n                \\end{split}\n            \\end{displaymath}\n            which follows directly by complete induction hypothesis.\n    \\end{itemize}\n\\end{proof}\n\n\\input{catalan/principal-cluster-include-figure.tex}\n\nBefore concluding the modular characterization of $\\mathcal{C}$,\nwe would like to observe that the last two\ntheorems do not say anything about the \\emph{value} of remainder for\na coefficient belonging to sub triangles of interest:\nwe have only shown that a \\emph{complete} sub triangle is repeated\nwhen coefficients are taken modulo $2$.\n\n\\subsection{A cheaper procedure to build $\\mathcal{C}_{\\equiv_{2}}$}\n\nWe have used \\autoref{thm:mirror:segment:definition},\n\\autoref{thm:upside:down:zero:hole}, \\autoref{thm:two:mirrored:clusters} and\n\\autoref{thm:principal:cluster:copy:containment} to build an efficient\nprocedure, written using the Python language, that builds $\\mathcal{C}_{\\equiv_{2}}$\ninductively without resorting to the hard-way approach. The latter consists of\ncomputing the matrix expansion of $\\mathcal{C}$ by doing convolutions and\nseries expansion of each column, then taking each coefficient $c_{n,k}\\in\\mathcal{C}$ modulo 2.\nOn the contrary, the former uses theorems to\nassemble $\\mathcal{C}_{\\equiv_{2}}$ block-wise: it builds a principal cluster\n$\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$ consuming a principal cluster\n$\\mathcal{C}_{\\equiv_{2}}^{(\\alpha)}$, treating it as a whole block. For the sake of clarity,\nlet us divide $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha+1)}$ in half obtaining two strips, then the former approach acts as follows:\nfirst, it places $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha)}$ in the top strip -- which is a triangle itself;\nsecond, it places another copy of $\\mathcal{C}_{\\equiv_{2}}^{(\\alpha)}$ on the very right portion in the bottom strip;\nthird, it mirrors last copied block respect to the mirror segment;\nfinally, it fills with zeros the upside-down triangle on the very left portion in the bottom strip.\nSuch procedure is much faster and easier to code that the one that implements definitions explicitly.\n", "meta": {"hexsha": "97c502eb4b78b18c0f3906fd93daa0ecc20cc73f", "size": 36970, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "modular-article/catalan.tex", "max_stars_repo_name": "massimo-nocentini/master-thesis", "max_stars_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modular-article/catalan.tex", "max_issues_repo_name": "massimo-nocentini/master-thesis", "max_issues_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modular-article/catalan.tex", "max_forks_repo_name": "massimo-nocentini/master-thesis", "max_forks_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.8528198074, "max_line_length": 140, "alphanum_fraction": 0.5735190695, "num_tokens": 12945, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.42851231151640823}}
{"text": "\\chapter{Orderings of filters in terms of reloids}\n\nWhilst the other chapters of this book use filters to research funcoids\nand reloids, here the opposite thing is discussed, the theory of reloids\nis used to describe properties of filters.\n\nIn this chapter the word \\emph{filter} is used to denote a filter\non a set (not on an arbitrary poset) only.\n\n\\section{Ordering of filters}\n\nBelow I will define some categories having filters (with possibly\ndifferent bases) as their objects and some relations having two filters\n(with possibly different bases) as arguments induced by these categories\n(defined as existence of a morphism between these two filters).\n\\begin{thm}\n$\\card a=\\card U$ for every ultrafilter $a$ on $U$ if $U$ is infinite.\\end{thm}\n\\begin{proof}\nLet $f(X)=X$ if $X\\in a$ and $f(X)=U\\setminus X$ if $X\\notin a$.\nObviously $f$ is a surjection from $U$ to $a$.\n\nEvery $X\\in a$ appears as a value of $f$ exactly twice, as $f(X)$\nand $f(U\\setminus X)$. So $\\card a=(\\card U)/2=\\card U$.\\end{proof}\n\\begin{cor}\nCardinality of every two ultrafilters on a set $U$ is the same.\\end{cor}\n\\begin{proof}\nFor infinite $U$ it follows from the theorem. For finite case it\nis obvious.\\end{proof}\n\\begin{prop}\n$\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}=\\setcond{C\\in\\subsets(\\Dst f)}{\\rsupfun{f^{-1}}C\\in\\mathcal{A}}$\nfor every $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$.\n(Here a funcoid is considered as a pair of functions $\\mathfrak{F}(\\Base(\\mathcal{A}))\\rightarrow\\mathfrak{F}(\\Base(\\mathcal{B}))$,\n$\\mathfrak{F}(\\Base(\\mathcal{B}))\\rightarrow\\mathfrak{F}(\\Base(\\mathcal{A}))$\nrather than as a pair of functions $\\mathscr{F}(\\Base(\\mathcal{A}))\\rightarrow\\mathscr{F}(\\Base(\\mathcal{B}))$,\n$\\mathscr{F}(\\Base(\\mathcal{B}))\\rightarrow\\mathscr{F}(\\Base(\\mathcal{A}))$.)\\end{prop}\n\\begin{proof}\nFor every set $C\\in\\subsets\\Base(\\mathcal{B})$ we have\n\\begin{align*}\n\\rsupfun{f^{-1}}C\\in\\mathcal{A} & \\Rightarrow\\\\\n\\exists K\\in\\mathcal{A}:\\rsupfun{f^{-1}}C=K & \\Rightarrow\\\\\n\\exists K\\in\\mathcal{A}:\\rsupfun f\\rsupfun{f^{-1}}C=\\rsupfun fK & \\Rightarrow\\\\\n\\exists K\\in\\mathcal{A}:C\\supseteq\\rsupfun fK & \\Leftrightarrow\\\\\n\\exists K\\in\\mathcal{A}:C\\in\\rsupfun{\\uparrow^{\\mathsf{FCD}}f}K & \\Rightarrow\\\\\nC\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}.\n\\end{align*}\nSo $C\\in \\setcond{C\\in\\subsets(\\Dst f)}{\\rsupfun{f^{-1}}C\\in\\mathcal{A}}\\Rightarrow C\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\nLet now $C\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$. Then\n$\\uparrow\\rsupfun{f^{-1}}C\\sqsupseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f^{-1}}\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}\\sqsupseteq\\mathcal{A}$\nand thus $\\rsupfun{f^{-1}}C\\in\\mathcal{A}$.\n\\end{proof}\nBelow I'll define some directed multigraphs. By an abuse of notation,\nI will denote these multigraphs the same as (below defined) categories\nbased on some of these directed multigraphs with added composition\nof morphisms (of directed multigraphs edges). As such I will call\nvertices of these multigraphs objects and edges morphisms.\n\\begin{defn}\nI will denote $\\mathbf{GreFunc}{}_{1}$ the multigraph whose objects\nare filters and whose morphisms between objects $\\mathcal{A}$ and\n$\\mathcal{B}$ are $\\mathbf{Set}$-morphisms from $\\Base(\\mathcal{A})$\nto $\\Base(\\mathcal{B})$ such that $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\\end{defn}\n\n\\begin{defn}\nI will denote $\\mathbf{GreFunc}{}_{2}$ the multigraph whose objects\nare filters and whose morphisms between objects $\\mathcal{A}$ and\n$\\mathcal{B}$ are $\\mathbf{Set}$-morphisms from $\\Base(\\mathcal{A})$\nto $\\Base(\\mathcal{B})$ such that $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\\end{defn}\n\n\\begin{defn}\nLet $\\mathcal{A}$ be a filter on a set $X$ and $\\mathcal{B}$ be\na filter on a set $Y$. $\\mathcal{A}\\ge_{1}\\mathcal{B}$ iff $\\Hom_{\\mathbf{GreFunc}_{1}}(\\mathcal{A},\\mathcal{B})$\nis not empty.\n\\end{defn}\n\n\\begin{defn}\nLet $\\mathcal{A}$ be a filter on a set $X$ and $\\mathcal{B}$ be\na filter on a set $Y$. $\\mathcal{A}\\ge_{2}\\mathcal{B}$ iff $\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})$\nis not empty.\\end{defn}\n\\begin{prop}\n~\n\\begin{enumerate}\n\\item \\label{gre-imp}$f\\in\\Hom_{\\mathbf{GreFunc}_{1}}(\\mathcal{A},\\mathcal{B})$\niff $f$ is a $\\mathbf{Set}$-morphism from $\\Base(\\mathcal{A})$\nto $\\Base(\\mathcal{B})$ such that\n\\[\nC\\in\\mathcal{B}\\Leftarrow\\rsupfun{f^{-1}}C\\in\\mathcal{A}\n\\]\nfor every $C\\in\\subsets\\Base(\\mathcal{B})$.\n\\item \\label{gre-eq}$f\\in\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})$\niff $f$ is a $\\mathbf{Set}$-morphism from $\\Base(\\mathcal{A})$\nto $\\Base(\\mathcal{B})$ such that\n\\[\nC\\in\\mathcal{B}\\Leftrightarrow\\rsupfun{f^{-1}}C\\in\\mathcal{A}\n\\]\nfor every $C\\in\\subsets\\Base(\\mathcal{B})$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\n~\n\\begin{widedisorder}\n\\item [{\\ref{gre-imp}}] ~\n\\begin{multline*}\nf\\in\\Hom_{\\mathbf{GreFunc}_{1}}(\\mathcal{A},\\mathcal{B})\\Leftrightarrow\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}\\Leftrightarrow\\\\\n\\forall C\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}:C\\in\\mathcal{B}\\Leftrightarrow\\forall C\\in\\subsets\\Base(\\mathcal{B}):(\\rsupfun{f^{-1}}C\\in\\mathcal{A}\\Rightarrow C\\in\\mathcal{B}).\n\\end{multline*}\n\n\\item [{\\ref{gre-eq}}] ~\n\\begin{multline*}\nf\\in\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})\\Leftrightarrow\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}\\Leftrightarrow\\forall C:(C\\in\\mathcal{B}\\Leftrightarrow C\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A})\\Leftrightarrow\\\\\n\\forall C\\in\\subsets\\Base(\\mathcal{B}):(C\\in\\mathcal{B}\\Leftrightarrow C\\in\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A})\\Leftrightarrow\\\\\n\\forall C\\in\\subsets\\Base(\\mathcal{B}):(\\rsupfun{f^{-1}}C\\in\\mathcal{A}\\Leftrightarrow C\\in\\mathcal{B}).\n\\end{multline*}\n\n\\end{widedisorder}\n\\end{proof}\n\\begin{defn}\nThe directed multigraph $\\mathbf{FuncBij}$ is the directed multigraph\ngot from $\\mathbf{GreFunc}_{2}$ by restricting to only bijective\nmorphisms.\n\\end{defn}\n\n\\begin{defn}\n\\index{directly isomorphic}A filter $\\mathcal{A}$ is \\emph{directly\nisomorphic} to a filter $\\mathcal{B}$ iff there is a morphism $f\\in\\Hom_{\\mathbf{FuncBij}}(\\mathcal{A},\\mathcal{B})$.\\end{defn}\n\\begin{obvious}\n$f\\in\\Hom_{\\mathbf{GreFunc}_{1}}(\\mathcal{A},\\mathcal{B})\\Leftrightarrow\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nfor every $\\mathbf{Set}$-morphism from $\\Base(\\mathcal{A})$ to $\\Base(\\mathcal{B})$.\n\\end{obvious}\n\n\\begin{obvious}\n$f\\in\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})\\Leftrightarrow\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nfor every $\\mathbf{Set}$-morphism from $\\Base(\\mathcal{A})$ to $\\Base(\\mathcal{B})$.\n\\end{obvious}\n\n\\begin{cor}\n$\\mathcal{A}\\ge_{1}\\mathcal{B}$ iff it exists a $\\mathbf{Set}$-morphism\n$f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$ such that $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\\end{cor}\n\n\\begin{cor}\n$\\mathcal{A}\\ge_{2}\\mathcal{B}$ iff it exists a $\\mathbf{Set}$-morphism\n$f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$ such that $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\\end{cor}\n\\begin{prop}\nFor a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nthe following are equivalent:\n\\begin{enumerate}\n\\item \\label{fbij-star}$\\mathcal{B}=\\setcond{C\\in\\subsets\\Base(\\mathcal{B})}{\\rsupfun{f^{-1}}C\\in\\mathcal{A}}$.\n\\item \\label{fbij-eback}$\\forall C\\in\\Base(\\mathcal{B}):(C\\in\\mathcal{B}\\Leftrightarrow\\rsupfun{f^{-1}}C\\in\\mathcal{A})$.\n\\item \\label{fbij-eforw}$\\forall C\\in\\Base(\\mathcal{A}):(C\\in\\rsupfun f\\mathcal{B}\\Leftrightarrow C\\in\\mathcal{A})$.\n\\item \\label{fbij-rbij}$\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$\nis a bijection from $\\mathcal{A}$ to~$\\mathcal{B}$.\n\\item \\label{fbij-rsurj}$\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$\nis a function onto~$\\mathcal{B}$.\n\\item \\label{fbij-feq}$\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\\item \\label{fbij-gre}$f\\in\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})$.\n\\item \\label{fbij-grp}$f\\in\\Hom_{\\mathbf{FuncBij}}(\\mathcal{A},\\mathcal{B})$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{\\ref{fbij-star}$\\Leftrightarrow$\\ref{fbij-eback}}] ~\n\\[\n\\mathcal{B}=\\setcond{C\\in\\subsets\\Base(\\mathcal{B})}{\\rsupfun{f^{-1}}C\\in\\mathcal{A}}\\Leftrightarrow\\\\\n\\forall C\\in\\subsets\\Base(\\mathcal{B}):(C\\in\\mathcal{B}\\Leftrightarrow\\rsupfun{f^{-1}}C\\in\\mathcal{A}).\n\\]\n\n\\item [{\\ref{fbij-eback}$\\Leftrightarrow$\\ref{fbij-eforw}}] Because\n$f$ is a bijection.\n\\item [{\\ref{fbij-eback}$\\Rightarrow$\\ref{fbij-rsurj}}] For every $C\\in\\mathcal{B}$\nwe have $\\rsupfun{f^{-1}}C\\in\\mathcal{A}$ and thus $\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}\\supfun{\\uparrow^{\\mathsf{FCD}}f^{-1}}C=\\rsupfun f\\rsupfun{f^{-1}}C=C$.\nThus $\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$ is onto $\\mathcal{B}$.\n\\item [{\\ref{fbij-rbij}$\\Rightarrow$\\ref{fbij-rsurj}}] Obvious.\n\\item [{\\ref{fbij-rsurj}$\\Rightarrow$\\ref{fbij-rbij}}] We need to prove\nonly that $\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$ is an\ninjection. But this follows from the fact that $f$ is a bijection.\n\\item [{\\ref{fbij-rbij}$\\Rightarrow$\\ref{fbij-eforw}}] We have $\\forall C\\in\\Base(\\mathcal{A}):((\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}})C\\in\\mathcal{B}\\Leftrightarrow C\\in\\mathcal{A})$\nand consequently $\\forall C\\in\\Base(\\mathcal{A}):(\\rsupfun fC\\in\\mathcal{B}\\Leftrightarrow C\\in\\mathcal{A})$.\n\\item [{\\ref{fbij-feq}$\\Leftrightarrow$\\ref{fbij-star}}] From the last\ncorollary.\n\\item [{\\ref{fbij-star}$\\Leftrightarrow$\\ref{fbij-gre}}] Obvious.\n\\item [{\\ref{fbij-gre}$\\Leftrightarrow$\\ref{fbij-grp}}] Obvious.\n\\end{description}\n\\end{proof}\n\\begin{cor}\nThe following are equivalent for every filters $\\mathcal{A}$ and\n$\\mathcal{B}$:\n\\begin{enumerate}\n\\item $\\mathcal{A}$ is directly isomorphic to $\\mathcal{B}$.\n\\item There is a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that for every $C\\in\\mathscr{P}\\Base(\\mathcal{B})$\n\\[\nC\\in\\mathcal{B}\\Leftrightarrow\\rsupfun{f^{-1}}C\\in\\mathcal{A}.\n\\]\n\n\\item There is a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that for every $C\\in\\mathscr{P}\\Base(\\mathcal{B})$\n\\[\n\\rsupfun fC\\in\\mathcal{B}\\Leftrightarrow C\\in\\mathcal{A}.\n\\]\n\n\\item There is a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$ is a\nbijection from $\\mathcal{A}$ to $\\mathcal{B}$.\n\\item There is a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\supfun{\\uparrow^{\\mathsf{FCD}}f}|_{\\mathcal{A}}$ is a\nfunction onto $\\mathcal{B}$.\n\\item There is a bijective $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\n\\item There is a bijective morphism $f\\in\\Hom_{\\mathbf{GreFunc}_{2}}(\\mathcal{A},\\mathcal{B})$.\n\\item There is a bijective morphism $f\\in\\Hom_{\\mathbf{FuncBij}}(\\mathcal{A},\\mathcal{B})$.\n\\end{enumerate}\n\\end{cor}\n\\begin{prop}\n$\\mathbf{GreFunc}_{1}$ and $\\mathbf{GreFunc}_{2}$ with function\ncomposition are categories.\\end{prop}\n\\begin{proof}\nLet $f:\\mathcal{A}\\rightarrow\\mathcal{B}$ and $g:\\mathcal{B}\\rightarrow\\mathcal{C}$\nbe morphisms of $\\mathbf{GreFunc}_{1}$. Then $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nand $\\mathcal{C}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B}$.\nSo \n\\[\n\\supfun{\\uparrow^{\\mathsf{FCD}}(g\\circ f)}\\mathcal{A}=\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}\\sqsupseteq\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B}\\sqsupseteq\\mathcal{C}.\n\\]\nThus $g\\circ f$ is a morphism of $\\mathbf{GreFunc}_{1}$. Associativity\nlaw is evident. $\\id_{\\Base(\\mathcal{A})}$ is the identity morphism\nof $\\mathbf{GreFunc}_{1}$ for every filter~$\\mathcal{A}$.\n\nLet $f:\\mathcal{A}\\rightarrow\\mathcal{B}$ and $g:\\mathcal{B}\\rightarrow\\mathcal{C}$\nbe morphisms of $\\mathbf{GreFunc}_{2}$. Then $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nand $\\mathcal{C}=\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B}$. So\n\\[\n\\supfun{\\uparrow^{\\mathsf{FCD}}(g\\circ f)}\\mathcal{A}=\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}=\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B}=\\mathcal{C}.\n\\]\nThus $g\\circ f$ is a morphism of $\\mathbf{GreFunc}_{2}$. Associativity\nlaw is evident. $\\id_{\\Base(\\mathcal{A})}$ is the identity morphism\nof $\\mathbf{GreFunc}_{2}$ for every filter~$\\mathcal{A}$.\\end{proof}\n\\begin{cor}\n$\\le_{1}$ and $\\le_{2}$ are preorders. \\end{cor}\n\\begin{thm}\n$\\mathbf{FuncBij}$ is a groupoid.\\end{thm}\n\\begin{proof}\nFirst let's prove it is a category. Let $f:\\mathcal{A}\\rightarrow\\mathcal{B}$\nand $g:\\mathcal{B}\\rightarrow\\mathcal{C}$ be morphisms of $\\mathbf{FuncBij}$.\nThen $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$ and $g:\\Base(\\mathcal{B})\\rightarrow\\Base(\\mathcal{C})$\nare bijections and $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nand $\\mathcal{C}=\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B}$. Thus\n$g\\circ f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{C})$ is a bijection\nand $\\mathcal{C}=\\supfun{\\uparrow^{\\mathsf{FCD}}(g\\circ f)}\\mathcal{A}$.\nThus $g\\circ f$ is a morphism of $\\mathbf{FuncBij}$. $\\id_{\\Base(\\mathcal{A})}$\nis the identity morphism of $\\mathbf{FuncBij}$ for every filter $\\mathcal{A}$.\nThus it is a category.\n\nIt remains to prove only that every morphism $f\\in\\Hom_{\\mathbf{FuncBij}}(\\mathcal{A},\\mathcal{B})$\nhas a reverse (for every filters $\\mathcal{A}$, $\\mathcal{B}$).\nWe have $f$ is a bijection $\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that for every $C\\in\\subsets\\Base(\\mathcal{A})$\n\\[\n\\rsupfun fC\\in\\mathcal{B}\\Leftrightarrow C\\in\\mathcal{A}.\n\\]\nThen $f^{-1}:\\Base(\\mathcal{B})\\rightarrow\\Base(\\mathcal{A})$ is\na bijection such that for every $C\\in\\subsets\\Base(\\mathcal{B})$\n\\[\n\\rsupfun{f^{-1}}C\\in\\mathcal{A}\\Leftrightarrow C\\in\\mathcal{B}.\n\\]\n Thus $f^{-1}\\in\\Hom_{\\mathbf{FuncBij}}(\\mathcal{B},\\mathcal{A})$.\\end{proof}\n\\begin{cor}\nBeing directly isomorphic is an equivalence relation.\n\\end{cor}\n\\index{order!Rudin-Keisler}Rudin-Keisler order of ultrafilters is\nconsidered in such a book as \\cite{comfort-ultra}.\n\\begin{obvious}\nFor the case of ultrafilters being directly isomorphic is the same\nas being Rudin-Keisler equivalent.\\end{obvious}\n\\begin{defn}\n\\index{isomorphic!filters}A filter $\\mathcal{A}$ is \\emph{isomorphic}\nto a filter $\\mathcal{B}$ iff there exist sets $A\\in\\mathcal{A}$\nand $B\\in\\mathcal{B}$ such that $\\mathcal{A}\\div A$ is directly\nisomorphic to $\\mathcal{B}\\div B$.\\end{defn}\n\\begin{obvious}\nEquivalent filters are isomorphic.\\end{obvious}\n\\begin{thm}\nBeing isomorphic (for small filters) is an equivalence relation.\\end{thm}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{Reflexivity}] Because every filter is directly isomorphic to itself.\n\\item [{Symmetry}] If filter $\\mathcal{A}$ is isomorphic to $\\mathcal{B}$\nthen there exist sets $A\\in\\mathcal{A}$ and $B\\in\\mathcal{B}$ such\nthat $\\mathcal{A}\\div A$ is directly isomorphic to $\\mathcal{B}\\div B$\nand thus $\\mathcal{B}\\div B$ is directly isomorphic to $\\mathcal{A}\\div A$.\nSo $\\mathcal{B}$ is isomorphic to $\\mathcal{A}$.\n\\item [{Transitivity}] Let $\\mathcal{A}$ be isomorphic to $\\mathcal{B}$\nand $\\mathcal{B}$ be isomorphic to $\\mathcal{C}$. Then exist $A\\in\\mathcal{A}$,\n$B_{1}\\in\\mathcal{B}$, $B_{2}\\in\\mathcal{B}$, $C\\in\\mathcal{C}$\nsuch that there are bijections $f:A\\rightarrow B_{1}$ and $g:B_{2}\\rightarrow C$\nsuch that\n\\[\n\\forall X\\in\\subsets A:(X\\in\\mathcal{B}\\Leftrightarrow\\rsupfun{f^{-1}}X\\in\\mathcal{A})\\quad\\text{and}\\quad\\forall X\\in\\subsets B_{1}:(X\\in\\mathcal{A}\\Leftrightarrow\\rsupfun fX\\in\\mathcal{B})\n\\]\nand also $\\forall X\\in\\subsets B_{2}:(X\\in\\mathcal{B}\\Leftrightarrow\\rsupfun gX\\in\\mathcal{C})$.\n\n\nSo $g\\circ f$ is a bijection from $\\rsupfun{f^{-1}}(B_{1}\\cap B_{2})\\in\\mathcal{A}$\nto $\\rsupfun g(B_{1}\\cap B_{2})\\in\\mathcal{C}$ such that\n\\[\nX\\in\\mathcal{A}\\Leftrightarrow\\rsupfun fX\\in\\mathcal{B}\\Leftrightarrow\\rsupfun g\\rsupfun fX\\in\\mathcal{C}\\Leftrightarrow\\rsupfun{g\\circ f}X\\in\\mathcal{C}.\n\\]\nThus $g\\circ f$ establishes a bijection which proves that $\\mathcal{A}$\nis isomorphic to~$\\mathcal{C}$.\n\n\\end{description}\n\\end{proof}\n\\begin{lem}\nLet $\\card X=\\card Y$, $u$ be an ultrafilter on $X$ and $v$ be\nan ultrafilter on $Y$; let $A\\in u$ and $B\\in v$. Let $u\\div A$\nand $v\\div B$ be directly isomorphic. Then if $\\card(X\\setminus A)=\\card(Y\\setminus B)$\nwe have $u$ and $v$ directly isomorphic.\\end{lem}\n\\begin{proof}\nArbitrary extend the bijection witnessing being directly isomorphic\nto the sets $X\\setminus A$ and $X\\setminus B$.\\end{proof}\n\\begin{thm}\nIf $\\card X=\\card Y$ then being isomorphic and being directly isomorphic\nare the same for ultrafilters $u$ on $X$ and $v$ on $Y$.\\end{thm}\n\\begin{proof}\nThat if two filters are isomorphic then they are directly isomorphic\nis obvious.\n\nLet ultrafilters $u$ and $v$ be isomorphic that is there is a bijection\n$f:A\\rightarrow B$ where $A\\in u$, $B\\in v$ witnessing isomorphism\nof $u$ and $v$.\n\nIf one of the filters $u$ or $v$ is a trivial ultrafilter then the\nother is also a trivial ultrafilter and as it is easy to show they\nare directly isomorphic. So we can assume $u$ and $v$ are not trivial\nultrafilters.\n\nIf $\\card(X\\setminus A)=\\card(Y\\setminus B)$ our statement follows\nfrom the last lemma.\n\nNow assume without loss of generality $\\card(X\\setminus A)<\\card(Y\\setminus B)$.\n\n$\\card B=\\card Y$ because otherwise $\\card(X\\setminus A)=\\card(Y\\setminus B)$.\n\nIt is easy to show that there exists $B'\\supset B$ such that $\\card(X\\setminus A)=\\card(Y\\setminus B')$\nand $\\card B'=\\card B$.\n\nWe will find a bijection $g$ from $B$ to $B'$ which witnesses direct\nisomorphism of $v$ to $v$ itself. Then the composition $g\\circ f$\nwitnesses a direct isomorphism of $u\\div A$ and $v\\div B'$ and by\nthe lemma $u$ and $v$ are directly isomorphic.\n\nLet $D=B'\\setminus B$. We have $D\\notin v$.\n\nThere exists a set $E\\subseteq B$ such that $\\card E\\ge\\card D$\nand $E\\notin v$.\n\nWe have $\\card E=\\card(D\\cup E)$ and thus there exists a bijection\n$h:E\\rightarrow D\\cup E$.\n\nLet\n\\[\ng(x)=\\begin{cases}\nx & \\text{if }x\\in B\\setminus E;\\\\\nh(x) & \\text{if }x\\in E.\n\\end{cases}\n\\]\n\n\n$g|_{B\\setminus E}$ and $g|_{E}$ are bijections.\n\n$\\im(g|_{B\\setminus E})=B\\setminus E$; $\\im(g|_{E})=\\im h=D\\cup E$;\n\\[\n(D\\cup E)\\cap(B\\setminus E)=(D\\cap(B\\setminus E))\\cup(E\\cap(B\\setminus E))=\\emptyset\\cup\\emptyset=\\emptyset.\n\\]\nThus $g$ is a bijection from $B$ to $(B\\setminus E)\\cup(D\\cup E)=B\\cup D=B'$.\n\nTo finish the proof it's enough to show that $\\rsupfun gv=v$. Indeed\nit follows from $B\\setminus E\\in v$.\\end{proof}\n\\begin{prop}\n~\n\\begin{enumerate}\n\\item \\label{ge2-restr}For every $A\\in\\mathcal{A}$ and $B\\in\\mathcal{B}$\nwe have $\\mathcal{A}\\ge_{2}\\mathcal{B}$ iff $\\mathcal{A}\\div A\\ge_{2}\\mathcal{B}\\div B$.\n\\item \\label{ge1-restr}For every $A\\in\\mathcal{A}$ and $B\\in\\mathcal{B}$\nwe have $\\mathcal{A}\\ge_{1}\\mathcal{B}$ iff $\\mathcal{A}\\div A\\ge_{1}\\mathcal{B}\\div B$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\n~\n\\begin{widedisorder}\n\\item [{\\ref{ge2-restr}}] $\\mathcal{A}\\ge_{2}\\mathcal{B}$ iff there exist\na bijective $\\mathbf{Set}$-morphism $f$ such that $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\nThe equality is obviously preserved replacing $\\mathcal{A}$ with\n$\\mathcal{A}\\div A$ and $\\mathcal{B}$ with $\\mathcal{B}\\div B$.\n\\item [{\\ref{ge1-restr}}] $\\mathcal{A}\\ge_{1}\\mathcal{B}$ iff there exist\na bijective $\\mathbf{Set}$-morphism $f$ such that $\\mathcal{B}\\subseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\nThe equality is obviously preserved replacing $\\mathcal{A}$ with\n$\\mathcal{A}\\div A$ and $\\mathcal{B}$ with $\\mathcal{B}\\div B$.\n\\end{widedisorder}\n\\end{proof}\n\\begin{prop}\nFor ultrafilters $\\ge_{2}$ is the same as Rudin-Keisler ordering\n(as defined in \\cite{comfort-ultra}).\\end{prop}\n\\begin{proof}\n$x\\ge_{2}y$ iff there exist sets $A\\in x$ and $B\\in y$ and a bijective\n$\\mathbf{Set}$-morphism $f:X\\rightarrow Y$ such that\n\\[\ny\\div B=\\setcond{C\\in\\subsets Y}{\\rsupfun{f^{-1}}C\\in x\\div A}\n\\]\n that is when $C\\in y\\div B\\Leftrightarrow\\rsupfun{f^{-1}}C\\in x\\div A$\nwhat is equivalent to~$C\\in y\\Leftrightarrow\\rsupfun{f^{-1}}C\\in x$\nwhat is the definition of Rudin-Keisler ordering.\\end{proof}\n\\begin{rem}\n\\index{Rudin-Keisler equivalence}The relation of being isomorphic\nfor ultrafilters is traditionally called \\emph{Rudin-Keisler equivalence}.\\end{rem}\n\\begin{obvious}\n$(\\ge_{1})\\supseteq(\\ge_{2})$.\\end{obvious}\n\\begin{defn}\nLet $Q$ and $R$ be binary relations on the set of (small) filters. I will\ndenote $\\mathbf{MonRld}_{Q,R}$ the directed multigraph with objects\nbeing filters and morphisms such monovalued reloids $f$ that $(\\dom f)\\mathrel Q\\mathcal{A}$\nand $(\\im f)\\mathrel R\\mathcal{B}$.\n\nI will also denote $\\mathbf{CoMonRld}_{Q,R}$ the directed multigraph\nwith objects being filters and morphisms such injective reloids $f$\nthat $(\\im f)\\mathrel Q\\mathcal{A}$ and $(\\dom f)\\mathrel R\\mathcal{B}$.\nThese are essentially the duals.\n\\end{defn}\nSome of these directed multigraphs are categories with reloid composition\n(see below). By abuse of notation I will denote these categories the\nsame as these directed multigraphs.\n\n\\begin{lem}\n$\\mathbf{CoMonRld}_{Q,R}\\ne\\emptyset \\Leftrightarrow\\mathbf{MonRld}_{Q,R}\\ne\\emptyset$.\n\\end{lem}\n\\begin{proof}\n\\begin{multline*}\nf\\in\\mathbf{CoMonRld}_{Q,R} \\Leftrightarrow\n(\\im f)\\mathrel Q\\mathcal{A} \\land (\\dom f)\\mathrel R\\mathcal{B} \\Leftrightarrow \\\\\n(\\dom f^{-1})\\mathrel Q\\mathcal{A} \\land (\\im f^{-1})\\mathrel R\\mathcal{B} \\Leftrightarrow\nf^{-1}\\in\\mathbf{MonRld}_{Q,R}\n\\end{multline*}\nfor every monovalued reloid~$f$ (or what is the same, injective reloid~$f^{-1}$).\n\\end{proof}\n\n\\begin{thm}\nFor every filters $\\mathcal{A}$ and $\\mathcal{B}$ the following\nare equivalent:\n\\begin{enumerate}\n\\item \\label{ge1-ineq}$\\mathcal{A}\\ge_{1}\\mathcal{B}$.\n\\item \\label{ge1-eq-ge}$\\Hom_{\\mathbf{MonRld}_{=,\\sqsupseteq}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{ge1-le-ge}$\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,\\sqsupseteq}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{ge1-le-eq}$\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,=}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{g1-c-eq-ge}$\\Hom_{\\mathbf{CoMonRld}_{=,\\sqsupseteq}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{g1-c-le-ge}$\\Hom_{\\mathbf{CoMonRld}_{\\sqsubseteq,\\sqsupseteq}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{g1-c-le-eq}$\\Hom_{\\mathbf{CoMonRld}_{\\sqsubseteq,=}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{\\ref{ge1-ineq}$\\Rightarrow$\\ref{ge1-eq-ge}}] There exists a\n$\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\nWe have\n\\[\n\\dom(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\mathcal{A}\\sqcap\\top(\\Base(\\mathcal{A}))=\\mathcal{A}\n\\]\nand\n\\[\n\\im(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\im\\tofcd(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\im(\\uparrow^{\\mathsf{FCD}}f)|_{\\mathcal{A}}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}\\sqsupseteq\\mathcal{B}.\n\\]\nThus $(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}$ is a monovalued\nreloid such that $\\dom(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\mathcal{A}$\nand $\\im(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}\\sqsupseteq\\mathcal{B}$.\n\\item [{\\ref{ge1-eq-ge}$\\Rightarrow$\\ref{ge1-le-ge},~\\ref{ge1-le-eq}$\\Rightarrow$\\ref{ge1-le-ge},~\\ref{g1-c-eq-ge}$\\Rightarrow$\\ref{g1-c-le-ge},~\\ref{g1-c-le-eq}$\\Rightarrow$\\ref{g1-c-le-ge}}] Obvious.\n\\item [{\\ref{ge1-le-ge}$\\Rightarrow$\\ref{ge1-ineq}}] We have $\\mathcal{B}\\sqsubseteq\\supfun{\\tofcd f}\\mathcal{A}$\nfor a monovalued reloid $f\\in\\mathsf{RLD}(\\Base(\\mathcal{A}),\\Base(\\mathcal{B}))$.\nThen there exists a $\\mathbf{Set}$-morphism $F:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}F}\\mathcal{A}$\nthat is $\\mathcal{A}\\ge_{1}\\mathcal{B}$.\n\\item [{\\ref{g1-c-le-ge}$\\Rightarrow$\\ref{g1-c-le-eq}}] Let $f$ be an injective reloid such that\n$\\im f\\sqsubseteq\\mathcal{A}$ and $\\dom f\\sqsupseteq\\mathcal{B}$. Then\n$\\im f|_{\\mathcal{B}}\\sqsubseteq\\mathcal{A}$ and $\\dom f|_{\\mathcal{B}}=\\mathcal{B}$.\nSo $f|_{\\mathcal{B}}\\in\\Hom_{\\mathbf{CoMonRld}_{\\sqsubseteq,=}}(\\mathcal{A},\\mathcal{B})$.\n\\item [{\\ref{ge1-eq-ge}$\\Leftrightarrow$\\ref{g1-c-eq-ge},~\\ref{ge1-le-ge}$\\Leftrightarrow$\\ref{g1-c-le-ge},~\\ref{ge1-le-eq}$\\Leftrightarrow$\\ref{g1-c-le-eq}}] By\nthe lemma.\n\\end{description}\n\\end{proof}\n\\begin{thm}\nFor every filters $\\mathcal{A}$ and $\\mathcal{B}$ the following\nare equivalent:\n\\begin{enumerate}\n\\item \\label{ge2-in}$\\mathcal{A}\\ge_{2}\\mathcal{B}$.\n\\item \\label{ge2-mon}$\\Hom_{\\mathbf{MonRld}_{=,=}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\item \\label{ge2-comon}$\\Hom_{\\mathbf{CoMonRld}_{=,=}}(\\mathcal{A},\\mathcal{B})\\ne\\emptyset$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{\\ref{ge2-in}$\\Rightarrow$\\ref{ge2-mon}}] Let $\\mathcal{A}\\ge_{2}\\mathcal{B}$\nthat is $\\mathcal{B}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nfor some $\\mathbf{Set}$-morphism $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$.\nThen $\\dom(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\mathcal{A}$\nand \n\\[\n\\im(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\im\\tofcd(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}=\\im(\\uparrow^{\\mathsf{FCD}}f)|_{\\mathcal{A}}=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}=\\mathcal{B}.\n\\]\nSo $(\\uparrow^{\\mathsf{RLD}}f)|_{\\mathcal{A}}$ is a sought for reloid.\n\\item [{\\ref{ge2-mon}$\\Rightarrow$\\ref{ge2-in}}] There exists a monovalued reloid~$f$ with domain~$\\mathcal{A}$\nsuch that $\\supfun{\\tofcd f}\\mathcal{A}=\\mathcal{B}$.\nBy corollary \\ref{mv-is-restr}\nbelow, there exists a $\\mathbf{Set}$-morphism $F:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $f=(\\uparrow^{\\mathsf{RLD}}F)|_{\\mathcal{A}}$. Thus\n\\[\n\\supfun{\\uparrow^{\\mathsf{FCD}}F}\\mathcal{A}=\\im(\\uparrow^{\\mathsf{FCD}}F)|_{\\mathcal{A}}=\\im\\tofcd(\\uparrow^{\\mathsf{RLD}}F)|_{\\mathcal{A}}=\\im\\tofcd f=\\im f=\\mathcal{B}.\n\\]\nThus $\\mathcal{A}\\ge_{2}\\mathcal{B}$ is testified by the morphism\n$F$.\n\\item [{\\ref{ge2-mon}$\\Leftrightarrow$\\ref{ge2-comon}}] By the lemma.\n\\end{description}\n\\end{proof}\n\\begin{thm}\nThe following are categories (with reloid composition):\n\\begin{enumerate}\n\\item \\label{monrld-le-ge}$\\mathbf{MonRld}_{\\sqsubseteq,\\sqsupseteq}$;\n\\item \\label{monrld-le-eq}$\\mathbf{MonRld}_{\\sqsubseteq,=}$;\n\\item \\label{monrld-eq-eq}$\\mathbf{MonRld}_{=,=}$;\n\\item $\\mathbf{CoMonRld}_{\\sqsubseteq,\\sqsupseteq}$;\n\\item $\\mathbf{CoMonRld}_{\\sqsubseteq,=}$;\n\\item $\\mathbf{CoMonRld}_{=,=}$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\nWe will prove only the first three. The rest follow from duality.\nWe need to prove only that composition of morphisms is a morphism,\nbecause associativity and existence of identity morphism are evident.\nWe have:\n\\begin{widedisorder}\n\\item [{\\ref{monrld-le-ge}}] Let $f\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,\\sqsupseteq}}(\\mathcal{A},\\mathcal{B})$,\n$g\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,\\sqsupseteq}}(\\mathcal{B},\\mathcal{C})$.\nThen $\\dom f\\sqsubseteq\\mathcal{A}$, $\\im f\\sqsupseteq\\mathcal{B}$,\n$\\dom g\\sqsubseteq\\mathcal{B}$, $\\im g\\sqsupseteq\\mathcal{C}$. So\n$\\dom(g\\circ f)\\sqsubseteq\\mathcal{A}$, $\\im(g\\circ f)\\sqsupseteq\\mathcal{C}$\nthat is $g\\circ f\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,\\sqsupseteq}}(\\mathcal{A},\\mathcal{C})$.\n\\item [{\\ref{monrld-le-eq}}] Let $f\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,=}}(\\mathcal{A},\\mathcal{B})$,\n$g\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,=}}(\\mathcal{B},\\mathcal{C})$.\nThen $\\dom f\\sqsubseteq\\mathcal{A}$, $\\im f=\\mathcal{B}$, $\\dom g\\sqsubseteq\\mathcal{B}$,\n$\\im g=\\mathcal{C}$. So $\\dom(g\\circ f)\\sqsubseteq\\mathcal{A}$,\n$\\im(g\\circ f)=\\mathcal{C}$ that is $g\\circ f\\in\\Hom_{\\mathbf{MonRld}_{\\sqsubseteq,=}}(\\mathcal{A},\\mathcal{C})$.\n\\item [{\\ref{monrld-eq-eq}}] Let $f\\in\\Hom_{\\mathbf{MonRld}_{=,=}}(\\mathcal{A},\\mathcal{B})$,\n$g\\in\\Hom_{\\mathbf{MonRld}_{=,=}}(\\mathcal{B},\\mathcal{C})$. Then\n$\\dom f=\\mathcal{A}$, $\\im f=\\mathcal{B}$, $\\dom g=\\mathcal{B}$,\n$\\im g=\\mathcal{C}$. So $\\dom(g\\circ f)=\\mathcal{A}$, $\\im(g\\circ f)=\\mathcal{C}$\nthat is $g\\circ f\\in\\Hom_{\\mathbf{MonRld}_{=,=}}(\\mathcal{A},\\mathcal{C})$.\n\\end{widedisorder}\n\\end{proof}\n\\begin{defn}\nLet $\\mathbf{BijRld}$ be the groupoid of all bijections of the category\nof reloid triples. Its objects are filters and its morphisms from\na filter $\\mathcal{A}$ to filter $\\mathcal{B}$ are monovalued injective\nreloids $f$ such that $\\dom f=\\mathcal{A}$ and $\\im f=\\mathcal{B}$.\\end{defn}\n\\begin{thm}\nFilters $\\mathcal{A}$ and $\\mathcal{B}$ are isomorphic iff $\\Hom_{\\mathbf{BijRld}}(\\mathcal{A},\\mathcal{B})\\neq\\emptyset$.\\end{thm}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{$\\Rightarrow$}] Let $\\mathcal{A}$ and $\\mathcal{B}$ be isomorphic.\nThen there are sets $A\\in\\mathcal{A}$, $B\\in\\mathcal{B}$ and a bijective\n$\\mathbf{Set}$-morphism $F:A\\rightarrow B$ such that $\\rsupfun F:\\subsets A\\cap\\mathcal{A}\\rightarrow\\subsets B\\cap\\mathcal{B}$\nis a bijection.\n\n\nObviously $f=(\\uparrow^{\\mathsf{RLD}}F)|_{\\mathcal{A}}$ is monovalued\nand injective.\n\\begin{align*}\n\\im f & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\setcond{\\im G}{G\\in\\up(\\uparrow^{\\mathsf{RLD}}F)|_{\\mathcal{A}}} & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\setcond{\\im(H\\cap F|_{X})}{H\\in\\up(\\uparrow^{\\mathsf{RLD}}F)|_{\\mathcal{A}},X\\in\\mathcal{A}} & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\setcond{\\im F|_{P}}{P\\in\\mathcal{A}} & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\setcond{\\rsupfun FP}{P\\in\\mathcal{A}} & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\setcond{\\rsupfun FP}{P\\in\\subsets A\\cap\\mathcal{A}} & =\\\\\n\\bigsqcap^{\\mathfrak{F}}(\\subsets B\\cap\\mathcal{B}) & =\\\\\n\\bigsqcap^{\\mathfrak{F}}\\mathcal{B}=\\mathcal{B}.\n\\end{align*}\nThus $\\dom f=\\mathcal{A}$ and $\\im f=\\mathcal{B}$.\n\n\\item [{$\\Leftarrow$}] Let $f$ be a monovalued injective reloid such\nthat $\\dom f=\\mathcal{A}$ and $\\im f=\\mathcal{B}$. Then there exist\na function $F'$ and an injective binary relation $F''$ such that\n$F',F''\\in f$. Thus $F=F'\\cap F''$ is an injection such that $F\\in f$.\nThe function $F$ is a bijection from $A=\\dom F$ to $B=\\im F$. The\nfunction $\\rsupfun F$ is an injection on $\\subsets A\\cap\\mathcal{A}$\n(and moreover on $\\subsets A$). It's simple to show that $\\forall X\\in\\subsets A\\cap\\mathcal{A}:\\rsupfun FX\\in\\subsets B\\cap\\mathcal{B}$\nand similarly \n\\[\n\\forall Y\\in\\subsets B\\cap\\mathcal{B}:(\\rsupfun F)^{-1}Y=\\rsupfun{F^{-1}}Y\\in\\subsets A\\cap\\mathcal{A}.\n\\]\nThus $\\rsupfun F|_{\\subsets A\\cap\\mathcal{A}}$ is a bijection $\\subsets A\\cap\\mathcal{A}\\rightarrow\\subsets B\\cap\\mathcal{B}$.\nSo filters $\\mathcal{A}$ and $\\mathcal{B}$ are isomorphic.\n\\end{description}\n\\end{proof}\n\\begin{prop}\n$(\\ge_{1})=(\\sqsupseteq)\\circ(\\ge_{2})$ (when we limit to small filters).\\end{prop}\n\\begin{proof}\n$\\mathcal{A}\\ge_{1}\\mathcal{B}$ iff exists a function $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\nBut $\\mathcal{B}\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$\nis equivalent to $\\exists\\mathcal{B}'\\in\\mathscr{F}:(\\mathcal{B}'\\sqsupseteq\\mathcal{B}\\land\\mathcal{B}'=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A})$.\nSo $\\mathcal{A}\\ge_{1}\\mathcal{B}$ is equivalent to existence of\n$\\mathcal{B}'\\in\\mathscr{F}$ such that $\\mathcal{B}'\\sqsupseteq\\mathcal{B}$\nand existence of a function $f:\\Base(\\mathcal{A})\\rightarrow\\Base(\\mathcal{B})$\nsuch that $\\mathcal{B}'=\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A}$.\nThis is equivalent to $\\mathcal{A}\\mathrel{((\\sqsupseteq)\\circ(\\ge_{2}))}\\mathcal{B}$.\\end{proof}\n\\begin{prop}\nIf $a$ and $b$ are ultrafilters then $b\\ge_{1}a\\Leftrightarrow b\\ge_{2}a$.\\end{prop}\n\\begin{proof}\nWe need to prove only $b\\ge_{1}a\\Rightarrow b\\ge_{2}a$. If $b\\ge_{1}a$\nthen there exists a monovalued reloid $f:\\Base(b)\\rightarrow\\Base(a)$\nsuch that $\\dom f=b$ and $\\im f\\sqsupseteq a$. Then $\\im f=\\im\\tofcd f\\in\\{\\bot^{\\mathscr{F}(\\Base(a))}\\}\\cup\\atoms^{\\mathscr{F}(\\Base(a))}$\nbecause $\\tofcd f$ is a monovalued funcoid. So $\\im f=a$ (taken\ninto account $\\im f\\ne\\bot^{\\mathscr{F}(\\Base(a))}$) and thus $b\\ge_{2}a$\\@.\\end{proof}\n\\begin{cor}\nFor atomic filters $\\ge_{1}$ is the same as $\\ge_{2}$.\n\\end{cor}\nThus I will write simply $\\ge$ for atomic filters.\n\n\n\\subsection{Existence of no more than one monovalued injective reloid for a given\npair of ultrafilters}\n\n\n\\subsubsection{The lemmas}\n\nThe lemmas in this section were provided to me by \\noun{Robert Martin Solovay}\nin \\cite{solovay-on-identity}. They are based on \\noun{Wistar Comfort}'s\nwork.\n\nIn this section we will assume $\\mu$ is an ultrafilter on a set $I$\nand function $f:I\\rightarrow I$ has the property $X\\in\\mu\\Leftrightarrow\\rsupfun{f^{-1}}X\\in\\mu$.\n\\begin{lem}\n\\label{lem:one-reloid-first}If $X\\in\\mu$ then $X\\cap\\rsupfun fX\\in\\mu$.\\end{lem}\n\\begin{proof}\nIf $\\rsupfun fX\\notin\\mu$ then $X\\subseteq\\rsupfun{f^{-1}}\\rsupfun fX\\notin\\mu$\nand so $X\\notin\\mu$. Thus $X\\in\\mu\\land\\rsupfun fX\\in\\mu$ and consequently\n$X\\cap\\rsupfun fX\\in\\mu$.\n\\end{proof}\nWe will say that $x$ is \\emph{periodic} when $f^{n}(x)=x$ for some\npositive integer $x$. The least such $n$ is called \\emph{the period}\nof $x$.\n\nLet's define $x\\sim y$ iff there exist $i,j\\in\\mathbb{N}$ such that\n$f^{i}(x)=f^{j}(y)$. Trivially it is an equivalence relation. If\n$x$ and $y$ are periodic, then $x\\sim y$ iff exists $n\\in\\mathbb{N}$\nsuch that $f^{n}(y)=x$.\n\nLet $A=\\setcond{x\\in I}{x\\text{ is periodic with period}>1}$.\n\nWe will show $A\\notin\\mu$. Let's assume $A\\in\\mu$.\n\nLet a set $D\\subseteq A$ contains (by the axiom of choice) exactly\none element from each equivalence class of $A$ defined by the relation\n$\\sim$.\n\nLet $\\alpha$ be a function $A\\rightarrow\\mathbb{N}$ defined as follows.\nLet $x\\in A$. Let $y$ be the unique element of $D$ such that $x\\sim y$.\nLet $\\alpha(x)$ be the least $n\\in\\mathbb{N}$ such that $f^{n}(y)=x$.\n\nLet $B_{0}=\\setcond{x\\in A}{\\alpha(x)\\text{ is even}}$ and $B_{1}=\\setcond{x\\in A}{\\alpha(x)\\text{ is odd}}$.\n\nLet $B_{2}=\\setcond{x\\in A}{\\alpha(x)=0}$.\n\\begin{lem}\n$B_{0}\\cap\\rsupfun fB_{0}\\subseteq B_{2}$.\\end{lem}\n\\begin{proof}\nIf $x\\in B_{0}\\cap\\rsupfun fB_{0}$ then for a minimal even $n$ and\n$x=f(x')$ where $f^{m}(y')=x'$ for a minimal even $m$. Thus $f^{n}(y)=f(x')$\nthus $y$ and $x'$ laying in the same equivalence class and thus\n$y=y'$. So we have $f^{n}(y)=f^{m+1}(y)$. Thus $n\\le m+1$ by minimality.\n\n$x'$ lies on an orbit and thus $x'=f^{-1}(x)$ where by $f^{-1}$\nI mean step backward on our orbit; $f^{m}(y)=f^{-1}(x)$ and thus\n$x'=f^{n-1}(y)$ thus $n-1\\ge m$ by minimality or $n=0$.\n\nThus $n=m+1$ what is impossible for even $n$ and $m$. We have a\ncontradiction what proves $B_{0}\\cap\\rsupfun fB_{0}\\subseteq\\emptyset$.\n\nRemained the case $n=0$, then $x=f^{0}(y)$ and thus $\\alpha(x)=0$.\\end{proof}\n\\begin{lem}\n$B_{1}\\cap\\rsupfun fB_{1}=\\emptyset$.\\end{lem}\n\\begin{proof}\nLet $x\\in B_{1}\\cap\\rsupfun fB_{1}$. Then $f^{n}(y)=x$ for an odd\n$n$ and $x=f(x')$ where $f^{m}(y')=x'$ for an odd $m$. Thus $f^{n}(y)=f(x')$\nthus $y$ and $x'$ laying in the same equivalence class and thus\n$y=y'$. So we have $f^{n}(y)=f^{m+1}(y)$. Thus $n\\le m+1$ by minimality.\n\n$x'$ lies on an orbit and thus $x'=f^{-1}(x)$ where by $f^{-1}$\nI mean step backward on our orbit;\n\n$f^{m}(y)=f^{-1}(x)$ and thus $x'=f^{n-1}(y)$ thus $n-1\\ge m$ by\nminimality ($n=0$ is impossible because $n$ is odd).\n\nThus $n=m+1$ what is impossible for odd $n$ and $m$. We have a\ncontradiction what proves $B_{1}\\cap\\rsupfun fB_{1}=\\emptyset$.\\end{proof}\n\\begin{lem}\n$B_{2}\\cap\\rsupfun fB_{2}=\\emptyset$.\\end{lem}\n\\begin{proof}\nLet $x\\in B_{2}\\cap\\rsupfun fB_{2}$. Then $x=y$ and $x'=y$ where\n$x=f(x')$. Thus $x=f(x)$ and so $x\\notin A$ what is impossible.\\end{proof}\n\\begin{lem}\n$A\\notin\\mu$.\\end{lem}\n\\begin{proof}\nSuppose $A\\in\\mu$.\n\nSince $A\\in\\mu$ we have $B_{0}\\in\\mu$ or $B_{1}\\in\\mu$.\n\nSo either $B_{0}\\cap\\rsupfun fB_{0}\\subseteq B_{2}$ or $B_{1}\\cap\\rsupfun fB_{1}\\subseteq B_{2}$.\nAs such by the lemma \\ref{lem:one-reloid-first} we have $B_{2}\\in\\mu$.\nThis is incompatible with $B_{2}\\cap\\rsupfun fB_{2}=\\emptyset$. So\nwe got a contradiction.\n\\end{proof}\nLet $C$ be the set of points $x$ which are not periodic but $f^{n}(x)$\nis periodic for some positive $n$.\n\\begin{lem}\n$C\\notin\\mu$.\\end{lem}\n\\begin{proof}\nLet $\\beta$ be a function $C\\rightarrow\\mathbb{N}$ such that $\\beta(x)$\nis the least $n\\in\\mathbb{N}$ such that $f^{n}(x)$ is periodic.\n\nLet $C_{0}=\\setcond{x\\in C}{\\beta(x)\\text{ is even}}$ and $C_{1}=\\setcond{x\\in C}{\\beta(x)\\text{ is odd}}$.\n\nObviously $C_{j}\\cap\\rsupfun fC_{j}=\\emptyset$ for $j=0,1$. Hence\nby lemma \\ref{lem:one-reloid-first} we have $C_{0},C_{1}\\notin\\mu$\nand thus $C=C_{0}\\cup C_{1}\\notin\\mu$.\n\\end{proof}\nLet $E$ be the set of $x\\in I$ such that for no $n\\in\\mathbb{N}$\nwe have $f^{n}(x)$ periodic.\n\\begin{lem}\nLet $x,y\\in E$ be such that $f^{i}(x)=f^{j}(y)$ and $f^{i'}(x)=f^{j'}(y)$\nfor some $i,j,i',j'\\in\\mathbb{N}$. Then $i-j=i'-j'$.\\end{lem}\n\\begin{proof}\n$i\\mapsto f^{i}(x)$ is a bijection.\n\nSo $y=f^{i-j}(y)$ and $y=f^{i'-j'}(y)$. Thus $f^{i-j}(y)=f^{i'-j'}(y)$\nand so $i-j=i'-j'$.\\end{proof}\n\\begin{lem}\n$E\\notin\\mu$.\\end{lem}\n\\begin{proof}\nLet $D'\\subseteq E$ be a subset of $E$ with exactly one element\nfrom each equivalence class of the relation $\\sim$ on $E$.\n\nDefine the function $\\gamma:E\\rightarrow\\mathbb{Z}$ as follows. Let\n$x\\in E$. Let $y$ be the unique element of $D'$ such that $x\\sim y$.\nChoose $i,j\\in\\mathbb{N}$ such that $f^{i}(y)=f^{j}(x)$. Let $\\gamma(x)=i-j$.\nBy the last lemma, $\\gamma$ is well-defined.\n\nIt is clear that if $x\\in E$ then $f(x)\\in E$ and moreover $\\gamma(f(x))=\\gamma(x)+1$.\n\nLet $E_{0}=\\setcond{x\\in E}{\\gamma(x)\\text{ is even}}$ and $E_{1}=\\setcond{x\\in E}{\\gamma(x)\\text{ is odd}}$.\n\nWe have $E_{0}\\cap\\rsupfun fE_{0}=\\emptyset\\notin\\mu$ and hence $E_{0}\\notin\\mu$.\n\nSimilarly $E_{1}\\notin\\mu$.\n\nThus $E=E_{0}\\cup E_{1}\\notin\\mu$.\\end{proof}\n\\begin{lem}\n$f$ is the identity function on a set in $\\mu$.\\end{lem}\n\\begin{proof}\nWe have shown $A,C,E\\notin\\mu$. But the points which lie in none\nof these sets are exactly points periodic with period $1$ that is\nfixed points of $f$. Thus the set of fixed points of $f$ belongs\nto the filter $\\mu$.\n\\end{proof}\n\n\\subsubsection{The main theorem and its consequences}\n\\begin{thm}\nFor every ultrafilter $a$ the morphism $(a,a,\\id_{a}^{\\mathsf{FCD}})$\nis the only\n\\begin{enumerate}\n\\item \\label{atom-oneiso}monovalued morphism of the category of reloid\ntriples from $a$ to $a$;\n\\item injective morphism of the category of reloid triples from $a$ to\n$a$;\n\\item bijective morphism of the category of reloid triples from $a$ to\n$a$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\nWe will prove only \\ref{atom-oneiso} because the rest follow from\nit.\n\nLet $f$ be a monovalued morphism of reloid triples from~$a$ to~$a$.\nThen it exists a $\\mathbf{Set}$-morphism $F$ such that $F\\in f$.\nTrivially $\\supfun{\\uparrow^{\\mathsf{FCD}}F}a\\sqsupseteq a$ and thus\n$\\rsupfun FA\\in a$ for every $A\\in a$. Thus by the lemma we have\nthat $F$ is the identity function on a set in $a$ and so obviously\n$f$ is an identity.\\end{proof}\n\\begin{cor}\nFor every two atomic filters (with possibly different bases) $\\mathcal{A}$\nand $\\mathcal{B}$ there exists at most one bijective reloid triple\nfrom $\\mathcal{A}$ to $\\mathcal{B}$.\\end{cor}\n\\begin{proof}\nSuppose that $f$ and $g$ are two different bijective reloids from\n$\\mathcal{A}$ to $\\mathcal{B}$. Then $g^{-1}\\circ f$ is not the\nidentity reloid (otherwise $g^{-1}\\circ f=\\id_{\\dom f}^{\\mathsf{RLD}}$\nand so $f=g$ because $f$ and~$g$ are isomorphisms). But $g^{-1}\\circ f$ is a bijective reloid (as a composition\nof bijective reloids) from $\\mathcal{A}$ to $\\mathcal{A}$ what is\nimpossible.\n\\end{proof}\n\n\\section{Rudin-Keisler equivalence and Rudin-Keisler order}\n\n\\begin{thm}\nAtomic filters $a$ and $b$ (with possibly different bases) are isomorphic\niff $a\\ge b\\land b\\ge a$.\\end{thm}\n\\begin{proof}\nLet $a\\ge b\\land b\\ge a$. Then there are a monovalued reloids $f$\nand $g$ such that $\\dom f=a$ and $\\im f=b$ and $\\dom g=b$ and\n$\\im g=a$. Thus $g\\circ f$ and $f\\circ g$ are monovalued morphisms\nfrom $a$ to $a$ and from $b$ to $b$. By the above we have $g\\circ f=\\id_{a}^{\\mathsf{RLD}}$\nand $f\\circ g=\\id_{b}^{\\mathsf{RLD}}$ so $g=f^{-1}$ and $f^{-1}\\circ f=\\id_{a}^{\\mathsf{RLD}}$\nand $f\\circ f^{-1}=\\id_{b}^{\\mathsf{RLD}}$. Thus $f$ is an injective\nmonovalued reloid from $a$ to $b$ and thus $a$ and $b$ are isomorphic.\n\\end{proof}\nThe last theorem cannot be generalized from atomic filters to arbitrary\nfilters, as it's shown by the following example:\n\\begin{example}\n$\\mathcal{A}\\ge_{1}\\mathcal{B}\\wedge\\mathcal{B}\\ge_{1}\\mathcal{A}$\nbut $\\mathcal{A}$ is not isomorphic to $\\mathcal{B}$ for some filters\n$\\mathcal{A}$ and $\\mathcal{B}$.\\end{example}\n\\begin{proof}\nConsider $\\mathcal{A}=\\uparrow^{\\mathbb{R}}[0;1]$ and $\\mathcal{B}=\\bigsqcap\\setcond{\\uparrow^{\\mathbb{R}}[0;1+\\epsilon[}{\\epsilon>0}$.\nThen the function $f=\\mylambda x{\\mathbb{R}}{x/2}$ witnesses both\ninequalities $\\mathcal{A}\\ge_{1}\\mathcal{B}$ and $\\mathcal{B}\\ge_{1}\\mathcal{A}$.\nBut these filters cannot be isomorphic because only one of them is\nprincipal.\\end{proof}\n\\begin{lem}\nLet $f_{0}$ and $f_{1}$ be $\\mathbf{Set}$-morphisms. Let $f(x,y)=(f_{0}x,f_{1}y)$\nfor a function $f$. Then\n\\[\n\\supfun{\\uparrow^{\\mathsf{FCD}(\\Src f_{0}\\times\\Src f_{1},\\Dst f_{0}\\times\\Dst f_{1})}f}(\\mathcal{A}\\times^{\\mathsf{RLD}}\\mathcal{B})=\\supfun{\\uparrow^{\\mathsf{FCD}}f_{0}}\\mathcal{A}\\times^{\\mathsf{RLD}}\\supfun{\\uparrow^{\\mathsf{FCD}}f_{1}}\\mathcal{B}.\n\\]\n\\end{lem}\n\\begin{proof}\n~\n\\begin{align*}\n\\supfun{\\uparrow^{\\mathsf{FCD}(\\Src f_{0}\\times\\Src f_{1},\\Dst f_{0}\\times\\Dst f_{1})}f}(\\mathcal{A}\\times^{\\mathsf{RLD}}\\mathcal{B}) & =\\\\\n\\supfun{\\uparrow^{\\mathsf{FCD}(\\Src f_{0}\\times\\Src f_{1},\\Dst f_{0}\\times\\Dst f_{1})}f}\\bigsqcap\\setcond{\\uparrow^{\\Src f_{0}\\times\\Src f_{1}}(A\\times B)}{A\\in\\mathcal{A},B\\in\\mathcal{B}} & =\\\\\n\\bigsqcap\\setcond{\\uparrow^{\\Dst f_{0}\\times\\Dst f_{1}}\\rsupfun f(A\\times B)}{A\\in\\mathcal{A},B\\in\\mathcal{B}} & =\\\\\n\\bigsqcap\\setcond{\\uparrow^{\\Dst f_{0}\\times\\Dst f_{1}}(\\rsupfun{f_{0}}A\\times\\rsupfun{f_{1}}B)}{A\\in\\mathcal{A},B\\in\\mathcal{B}} & =\\\\\n\\bigsqcap\\setcond{\\uparrow^{\\Dst f_{0}}\\rsupfun{f_{0}}A\\times\\uparrow^{\\Dst f_{1}}\\rsupfun{f_{1}}B)}{A\\in\\mathcal{A},B\\in\\mathcal{B}} & =\\text{ (theorem \\ref{meet-prod-fcd})}\\\\\n\\bigsqcap\\setcond{\\uparrow^{\\Dst f_{0}}\\rsupfun{f_{0}}A}{A\\in\\mathcal{A}}\\times^{\\mathsf{RLD}}\\bigsqcap\\setcond{\\uparrow^{\\Dst f_{1}}\\rsupfun{f_{1}}B}{B\\in\\mathcal{B}} & =\\\\\n\\supfun{\\uparrow^{\\mathsf{FCD}}f_{0}}\\mathcal{A}\\times^{\\mathsf{RLD}}\\supfun{\\uparrow^{\\mathsf{FCD}}f_{1}}\\mathcal{B}.\n\\end{align*}\n\\end{proof}\n\\begin{thm}\n\\label{inj-iso-dom}Let $f$ be a monovalued reloid. Then $\\GR f$\nis isomorphic to the filter $\\dom f$.\\end{thm}\n\\begin{proof}\nLet $f$ be a monovalued reloid. There exists a function $F\\in\\GR f$.\nConsider the bijective function $p=\\mylambda x{\\dom F}{(x,Fx)}$.\n\n$\\rsupfun p\\dom F=F$ and consequently\n\\begin{align*}\n\\supfun p\\dom f & =\\\\\n\\bigsqcap_{K\\in\\up f}^{\\mathsf{RLD}}\\rsupfun p\\dom K & =\\\\\n\\bigsqcap_{K\\in\\up f}^{\\mathsf{RLD}}\\rsupfun p\\dom(K\\cap F) & =\\\\\n\\bigsqcap_{K\\in\\up f}^{\\mathsf{RLD}}(K\\cap F) & =\\\\\n\\bigsqcap_{K\\in\\up f}^{\\mathsf{RLD}}K & =f.\n\\end{align*}\nThus $p$ witnesses that $f$ is isomorphic to the filter $\\dom f$.\\end{proof}\n\\begin{cor}\nThe graph of a monovalued reloid with atomic domain is atomic.\n\\end{cor}\n\n\\begin{cor}\n$\\id_{\\mathcal{A}}^{\\mathsf{RLD}}$ is isomorphic to $\\mathcal{A}$\nfor every filter $\\mathcal{A}$.\\end{cor}\n\\begin{thm}\nThere are atomic filters incomparable by Rudin-Keisler order. (Elements~$a$\nand~$b$ are \\emph{incomparable} when $a\\nsqsubseteq b\\land b\\nsqsubseteq a$.)\\end{thm}\n\\begin{proof}\nSee \\cite{Gryzlov1997151}.\\end{proof}\n\\begin{thm}\n$\\ge_{1}$ and $\\ge_{2}$ are different relations.\\end{thm}\n\\begin{proof}\nConsider $a$ is an arbitrary non-empty filter. Then $a\\ge_{1}\\bot^{\\mathscr{F}(\\Base(a))}$\nbut not $a\\ge_{2}\\bot^{\\mathscr{F}(\\Base(a))}$.\\end{proof}\n\\begin{prop}\nIf $a\\ge_{2}b$ where $a$ is an ultrafilter then $b$ is also an\nultrafilter.\\end{prop}\n\\begin{proof}\n$b=\\supfun{\\uparrow^{\\mathsf{FCD}}f}a$ for some $f:\\Base(a)\\rightarrow\\Base(b)$.\nSo $b$ is an ultrafilter since $f$ is monovalued.\\end{proof}\n\\begin{cor}\nIf $a\\ge_{1}b$ where $a$ is an ultrafilter then $b$ is also an\nultrafilter or $\\bot^{\\mathscr{F}(\\Base(a))}$.\\end{cor}\n\\begin{proof}\n$b\\sqsubseteq\\supfun{\\uparrow^{\\mathsf{FCD}}f}a$ for some $f:\\Base(a)\\rightarrow\\Base(b)$.\nTherefore $b'=\\supfun{\\uparrow^{\\mathsf{FCD}}f}a$ is an ultrafilter.\nFrom this our statement follows.\\end{proof}\n\\begin{prop}\nPrincipal filters, generated by sets of the same cardinality, are\nisomorphic.\\end{prop}\n\\begin{proof}\nLet $A$ and $B$ be sets of the same cardinality. Then there are\na bijection $f$ from $A$ to $B$. We have $\\rsupfun fA=B$ and thus\n$A$ and $B$ are isomorphic.\\end{proof}\n\\begin{prop}\nIf a filter is isomorphic to a principal filter, then it is also a\nprincipal filter induced by a set with the same cardinality.\\end{prop}\n\\begin{proof}\nLet $A$ be a principal filter and $B$ is a filter isomorphic to\n$A$. Then there are sets $X\\in A$ and $Y\\in B$ such that there\nare a bijection $f:X\\rightarrow Y$ such that $\\rsupfun fA=B$.\n\nSo $\\min B$ exists and $\\min B=\\rsupfun f\\min A$ and thus $B$ is\na principal filter (of the same cardinality as $A$).\\end{proof}\n\\begin{prop}\nA filter isomorphic to a non-trivial ultrafilter is a non-trivial\nultrafilter.\\end{prop}\n\\begin{proof}\nLet $a$ be a non-trivial ultrafilter and $a$ be isomorphic to $b$.\nThen $a\\ge_{2}b$ and thus $b$ is an ultrafilter. The filter $b$\ncannot be trivial because otherwise $a$ would be also trivial.\\end{proof}\n\\begin{thm}\nFor an infinite set $U$ there exist $2^{2^{\\card U}}$ equivalence\nclasses of isomorphic ultrafilters.\\end{thm}\n\\begin{proof}\nThe number of bijections between any two given subsets of $U$ is\nno more than $(\\card U)^{\\card U}=2^{\\card U}$. The number of bijections\nbetween all pairs of subsets of $U$ is no more than $2^{\\card U}\\cdot2^{\\card U}=2^{\\card U}$.\nTherefore each isomorphism class contains at most $2^{\\card U}$ ultrafilters.\nBut there are $2^{2^{\\card U}}$ ultrafilters. So there are $2^{2^{\\card U}}$\nclasses.\\end{proof}\n\\begin{rem}\nOne of the above mentioned equivalence classes contains trivial ultrafilters.\\end{rem}\n\\begin{cor}\nThere exist non-isomorphic nontrivial ultrafilters on any infinite\nset.\n\\end{cor}\n\n\\section{Consequences}\n\\begin{thm}\n\\label{triv-atom-prod}The graph of reloid $\\mathcal{F}\\times^{\\mathsf{RLD}}\\uparrow^{A}\\{a\\}$\nis isomorphic to the filter $\\mathcal{F}$ for every set $A$ and\n$a\\in A$.\\end{thm}\n\\begin{proof}\nFrom \\ref{inj-iso-dom}.\\end{proof}\n\\begin{thm}\nIf $f$, $g$ are reloids, $f\\sqsubseteq g$ and $g$ is monovalued\nthen $g|_{\\dom f}=f$.\\end{thm}\n\\begin{proof}\nIt's simple to show that $f=\\bigsqcup\\setcond{f|_{a}}{a\\in\\atoms^{\\mathscr{F}(\\Src f)}}$\n(use the fact that $k\\sqsubseteq f|_{a}$ for some $a\\in\\atoms^{\\mathscr{F}(\\Src f)}$\nfor every $k\\in\\atoms f$ and the fact that $\\mathsf{RLD}(\\Src f,\\Dst f)$\nis atomistic).\n\nSuppose that $g|_{\\dom f}\\neq f$. Then there exists $a\\in\\atoms\\dom f$\nsuch that $g|_{a}\\neq f|_{a}$.\n\nObviously $g|_{a}\\sqsupseteq f|_{a}$.\n\nIf $g|_{a}\\sqsupset f|_{a}$ then $g|_{a}$ is not atomic (because\n$f|_{a}\\ne\\bot^{\\mathsf{RLD}(\\Src f,\\Dst f)}$) what contradicts to\na theorem above. So $g|_{a}=f|_{a}$ what is a contradiction and thus\n$g|_{\\dom f}=f$.\\end{proof}\n\\begin{cor}\n\\label{mv-is-restr}Every monovalued reloid is a restricted principal\nmonovalued reloid.\\end{cor}\n\\begin{proof}\nLet $f$ be a monovalued reloid. Then there exists a function $F\\in\\GR f$.\nSo we have\n\\[\n(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}F)|_{\\dom f}=f.\n\\]\n\\end{proof}\n\\begin{cor}\nEvery monovalued injective reloid is a restricted injective monovalued\nprincipal reloid.\\end{cor}\n\\begin{proof}\nLet $f$ be a monovalued injective reloid. There exists a function\n$F$ such that $f=(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}F)|_{\\dom f}$.\nAlso there exists an injection $G\\in\\up f$.\n\nThus\n\\begin{multline*}\nf=f\\sqcap(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}G)|_{\\dom f}=\\\\\n(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}F)|_{\\dom f}\\sqcap(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}G)|_{\\dom f}=\\\\\n(\\uparrow^{\\mathsf{RLD}(\\Src f,\\Dst f)}(F\\sqcap G))|_{\\dom f}.\n\\end{multline*}\nObviously $F\\sqcap G$ is an injection.\\end{proof}\n\\begin{thm}\nIf a reloid $f$ is monovalued and $\\dom f$ is an principal filter\nthen $f$ is principal.\\end{thm}\n\\begin{proof}\n$f$ is a restricted principal monovalued reloid. Thus $f=F|_{\\dom f}$\nwhere $F$ is a principal monovalued reloid. Thus $f$ is principal.\\end{proof}\n\\begin{lem}\nIf a filter $\\mathcal{A}$ is isomorphic to a filter $\\mathcal{B}$\nthen if $X$ is a typed set then there exists a typed set~$Y$ such that $\\uparrow^{\\Base(\\mathcal{A})}X\\sqcap\\mathcal{A}$\nis a filter isomorphic to $\\uparrow^{\\Base(\\mathcal{B})}Y\\sqcap\\mathcal{B}$.\\end{lem}\n\\begin{proof}\nLet $f$ be a monovalued injective reloid such that $\\dom f=\\mathcal{A}$,\n$\\im f=\\mathcal{B}$.\n\nBy proposition \\ref{factor-isomor} we have: $\\uparrow^{\\Base(\\mathcal{A})}X\\sqcap\\mathcal{A}=\\mathcal{X}$\nwhere $\\mathcal{X}$ is a filter complementive to $\\mathcal{A}$.\nLet $\\mathcal{Y}=\\mathcal{A}\\setminus\\mathcal{X}$.\n\n$\\supfun{\\tofcd f}\\mathcal{X}\\sqcap\\supfun{\\tofcd f}\\mathcal{Y}=\\supfun{\\tofcd f}(\\mathcal{X}\\sqcap\\mathcal{Y})=\\bot$\nby injectivity of $f$.\n\n$\\supfun{\\tofcd f}\\mathcal{X}\\sqcup\\supfun{\\tofcd f}\\mathcal{Y}=\\supfun{\\tofcd f}(\\mathcal{X}\\sqcup\\mathcal{Y})=\\supfun{\\tofcd f}\\mathcal{A}=\\mathcal{B}$.\nSo $\\supfun{\\tofcd f}\\mathcal{X}$ is a filter complementive to $\\mathcal{B}$.\nSo by proposition \\ref{factor-isomor} there exists a set $Y$ such\nthat $\\supfun{\\tofcd f}\\mathcal{X}=\\uparrow Y\\sqcap\\mathcal{B}$.\n\n$f|_{\\mathcal{X}}$ is obviously a monovalued injective reloid with\n$\\dom(f|_{\\mathcal{X}})=\\uparrow X\\sqcap\\mathcal{A}$\nand $\\im(f|_{\\mathcal{X}})=\\uparrow Y\\sqcap\\mathcal{B}$.\nSo $\\uparrow X\\sqcap\\mathcal{A}$ is isomorphic\nto $\\uparrow Y\\sqcap\\mathcal{B}$.\\end{proof}\n\\begin{example}\n$\\mathcal{A}\\ge_{2}\\mathcal{B}\\wedge\\mathcal{B}\\ge_{2}\\mathcal{A}$\nbut $\\mathcal{A}$ is not isomorphic to $\\mathcal{B}$ for some filters\n$\\mathcal{A}$ and $\\mathcal{B}$.\\end{example}\n\\begin{proof}\n(proof idea by \\noun{Andreas Blass}, rewritten using reloids by me)\n\nLet $u_{n}$, $h_{n}$ with $n$ ranging over the set $\\mathbb{Z}$\nbe sequences of ultrafilters on $\\mathbb{N}$ and functions $\\mathbb{N}\\rightarrow\\mathbb{N}$\nsuch that $\\supfun{\\uparrow^{\\mathsf{FCD}(\\mathbb{N},\\mathbb{N})}h_{n}}u_{n+1}=u_{n}$\nand $u_{n}$ are pairwise non-isomorphic. (See \\cite{kleene-degrees}\nfor a proof that such ultrafilters and functions exist.)\n\n$\\mathcal{A}\\eqdef\\bigsqcup_{n\\in\\mathbb{Z}}(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n+1})$;\n$\\mathcal{B}\\eqdef\\bigsqcup_{n\\in\\mathbb{Z}}(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n})$.\n\nLet the $\\mathbf{Set}$-morphisms $f,g:\\mathbb{Z}\\times\\mathbb{N}\\rightarrow\\mathbb{Z}\\times\\mathbb{N}$\nbe defined by the formulas $f(n,x)=(n,h_{2n}x)$ and $g(n,x)=(n-1,h_{2n-1}x)$.\n\nUsing the fact that every function induces a complete funcoid and\na lemma above we get:\n\\begin{align*}\n\\supfun{\\uparrow^{\\mathsf{FCD}}f}\\mathcal{A} & =\\\\\n\\bigsqcup\\rsupfun{\\supfun{\\uparrow^{\\mathsf{FCD}}f}}\\setcond{\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n+1}}{n\\in\\mathbb{Z}} & =\\\\\n\\bigsqcup\\setcond{\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n}}{n\\in\\mathbb{Z}} & =\\\\\n\\mathcal{B}.\\\\\n\\supfun{\\uparrow^{\\mathsf{FCD}}g}\\mathcal{B} & =\\\\\n\\bigsqcup\\rsupfun{\\supfun{\\uparrow^{\\mathsf{FCD}}g}}\\setcond{\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n}}{n\\in\\mathbb{Z}} & =\\\\\n\\bigsqcup\\setcond{\\uparrow^{\\mathbb{Z}}\\{n-1\\}\\times^{\\mathsf{RLD}} u_{2n-1}}{n\\in\\mathbb{Z}} & =\\\\\n\\bigsqcup\\setcond{\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n+1}}{n\\in\\mathbb{Z}} & =\\\\\n\\mathcal{A}.\n\\end{align*}\n\n\nIt remains to show that $\\mathcal{A}$ and $\\mathcal{B}$ are not\nisomorphic.\n\nLet $X\\in\\up(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}}u_{2n+1})$\nfor some $n\\in\\mathbb{Z}$. Then if $\\uparrow^{\\mathbb{Z}\\times\\mathbb{N}}X\\sqcap\\mathcal{A}$\nis an ultrafilter we have $\\uparrow^{\\mathbb{Z}\\times\\mathbb{N}}X\\sqcap\\mathcal{A}=\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}}u_{2n+1}$\nand thus by the theorem \\ref{triv-atom-prod} is isomorphic to $u_{2n+1}$.\n\nIf $X\\notin\\up(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}}u_{2n+1})$\nfor every $n\\in\\mathbb{Z}$ then $(\\mathbb{Z}\\times\\mathbb{N})\\setminus X\\in\\up(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}}u_{2n+1})$\nand thus $(\\mathbb{Z}\\times\\mathbb{N})\\setminus X\\in\\up\\mathcal{A}$\nand thus $\\uparrow^{\\mathbb{Z}\\times\\mathbb{N}}X\\sqcap\\mathcal{A}=\\bot^{\\mathbb{Z}\\times\\mathbb{N}}$.\n\nWe have also\n\\begin{multline*}\n(\\uparrow^{\\mathbb{Z}}\\{0\\}\\times^{\\mathsf{RLD}}\\mathbb{N})\\sqcap\\mathcal{B}=(\\uparrow^{\\mathbb{Z}}\\{0\\}\\times^{\\mathsf{RLD}}\\mathbb{N})\\sqcap\\bigsqcup\\setcond{\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n}}{n\\in\\mathbb{Z}}=\\\\\n\\bigsqcup\\setcond{(\\uparrow^{\\mathbb{Z}}\\{0\\}\\times^{\\mathsf{RLD}}\\mathbb{N})\\sqcap(\\uparrow^{\\mathbb{Z}}\\{n\\}\\times^{\\mathsf{RLD}} u_{2n})}{n\\in\\mathbb{Z}}=\\uparrow^{\\mathbb{Z}}\\{0\\}\\times^{\\mathsf{RLD}}u_{0}\\text{ (an ultrafilter).}\n\\end{multline*}\n\n\nThus every ultrafilter generated as intersecting $\\mathcal{A}$ with\na principal filter $\\uparrow^{\\mathbb{Z}\\times\\mathbb{N}}X$ is isomorphic\nto some $u_{2n+1}$ and thus is not isomorphic to $u_{0}$. By the\nlemma it follows that $\\mathcal{A}$ and $\\mathcal{B}$ are non-isomorphic.\n\\end{proof}\n\n\\subsection{Metamonovalued reloids}\n\\begin{prop}\n$\\left(\\bigcap G\\right)\\circ f=\\bigcap_{g\\in G}(g\\circ f)$ for every\nfunction $f$ and a set $G$ of binary relations.\\end{prop}\n\\begin{proof}\n~\n\\begin{align*}\n(x,z)\\in\\left(\\bigcap G\\right)\\circ f & \\Leftrightarrow\\\\\n\\exists y:(fx=y\\land(y,z)\\in\\bigcap G) & \\Leftrightarrow\\\\\n(fx,z)\\in\\bigcap G & \\Leftrightarrow\\\\\n\\forall g\\in G:(fx,z)\\in g & \\Leftrightarrow\\\\\n\\forall g\\in G\\exists y:(fx=y\\land(y,z)\\in g) & \\Leftrightarrow\\\\\n\\forall g\\in G:(x,z)\\in g\\circ f & \\Leftrightarrow\\\\\n(x,z)\\in\\bigcap_{g\\in G}(g\\circ f).\n\\end{align*}\n\\end{proof}\n\\begin{lem}\n$\\left(\\bigsqcap G\\right)\\circ f=\\bigsqcap_{g\\in G}(g\\circ f)$ if\n$f$ is a monovalued principal reloid and $G$ is a set of reloids\n(with matching sources and destinations).\\end{lem}\n\\begin{proof}\nLet $f=\\uparrow^{\\mathsf{RLD}}\\varphi$ for some monovalued $\\mathbf{Rel}$-morphism\n$\\varphi$.\n\n$\\left(\\bigsqcap G\\right)\\circ f=\\bigsqcap_{g\\in\\up\\bigsqcap G}^{\\mathsf{RLD}}(g\\circ\\varphi)$;\n\\begin{align*}\n\\up\\bigsqcap_{g\\in G}(g\\circ f) & =\\\\\n\\up\\bigsqcap_{g\\in G}\\bigsqcap_{\\Gamma\\in\\up g}^{\\mathsf{RLD}}(\\Gamma\\circ\\varphi) & =\\\\\n\\up\\bigsqcap\\bigcup_{g\\in G}\\setcond{\\uparrow^{\\mathsf{RLD}}(\\Gamma\\circ\\varphi)}{\\Gamma\\in\\up g} & =\\\\\n\\up\\bigsqcap_{\\Gamma\\in\\up\\bigsqcap G}^{\\mathsf{RLD}}(\\Gamma\\circ\\varphi) & =\\\\\n\\up\\bigsqcap\\setcond{(\\Gamma_{0}\\circ\\varphi)\\sqcap\\dots\\sqcap(\\Gamma_{n}\\circ\\varphi)}{\\Gamma_{i}\\in\\up\\bigsqcap G\\text{ where \\ensuremath{i=0,\\dots,n} for \\ensuremath{n\\in\\mathbb{N}}}} & =\\text{ (proposition above)}\\\\\n\\up\\bigsqcap\\setcond{(\\Gamma_{0}\\sqcap\\dots\\sqcap\\Gamma_{n})\\circ\\varphi}{\\Gamma_{i}\\in\\up\\bigsqcap G\\text{ where \\ensuremath{i=0,\\dots,n} for \\ensuremath{n\\in\\mathbb{N}}}} & =\\\\\n\\up\\bigsqcap\\setcond{\\Gamma\\circ\\varphi}{\\Gamma\\in\\up\\bigsqcap G}.\n\\end{align*}\nThus $\\left(\\bigsqcap G\\right)\\circ f=\\bigsqcap_{g\\in G}(g\\circ f)$.\\end{proof}\n\\begin{thm}\\label{rld-meta}\n~\n\\begin{enumerate}\n\\item Monovalued reloids are metamonovalued.\n\\item Injective reloids are metainjective.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\nWe will prove only the first, as the second is dual.\n\nLet $G$ be a set of reloids and $f$ be a monovalued reloid.\n\nLet $f'$ be a principal monovalued continuation of $f$ (so that\n$f=f'|_{\\dom f}$).\n\nBy the lemma $\\left(\\bigsqcap G\\right)\\circ f'=\\bigsqcap_{g\\in G}(g\\circ f')$.\nRestricting this equality to $\\dom f$ we get: $\\left(\\bigsqcap G\\right)\\circ f=\\bigsqcap_{g\\in G}(g\\circ f)$.\\end{proof}\n\\begin{conjecture}\nEvery metamonovalued reloid is monovalued.\\end{conjecture}\n\n", "meta": {"hexsha": "4f1f15b8639e87dc34dfdc5d4eb2dad44ff84fae", "size": 56058, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-filt-order.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-filt-order.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-filt-order.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.0875656743, "max_line_length": 252, "alphanum_fraction": 0.6843983018, "num_tokens": 22226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.42850869502403777}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROBLEM 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{Problem 2}\n\nFree neutrons undergo $\\beta^{-}$ decay with a half-life of 10.4 minutes. \nDetermine the probability that a neutron will decay before being absorbed in an infinite absorbing material (assume no scattering). \nEstimate this probability for a thermal neutron ($v = 2200$ m/s) in water.\n\n", "meta": {"hexsha": "125796679af16ca5eb0a0e0f8319e9881aadfd23", "size": 386, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/drafts/disc02/disc02_exercise02.tex", "max_stars_repo_name": "mitchnegus/NE150-discussion", "max_stars_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercises/drafts/disc02/disc02_exercise02.tex", "max_issues_repo_name": "mitchnegus/NE150-discussion", "max_issues_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercises/drafts/disc02/disc02_exercise02.tex", "max_forks_repo_name": "mitchnegus/NE150-discussion", "max_forks_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.25, "max_line_length": 132, "alphanum_fraction": 0.6243523316, "num_tokens": 82, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.42850867738831466}}
{"text": "% === CSC165 Winter 2018 ===\n% __authors__ = 'Eric Koehli, Conor Vedova, Jacob Chmura'\n% === Problem Set 1 ===\n\n\\documentclass[12pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage[margin=2.5cm]{geometry}\n\\usepackage{csc}\n\n% Document metadata\n\\title{CSC165H1 Winter 2018: Problem Set 1}\n\\author{By: Eric Koehli, Conor Vedova, Jacob Chmura}\n\\date{January 24, 2018}\n\n\n% Document starts here\n\\begin{document}\n\\maketitle\n\\newpage\n\n\\section{Propositional formulas}\n\\begin{enumerate}\n\\item[(a)] $(p \\IMP q) \\IMP \\NOT q$.\n  \\begin{enumerate}\n  \\item[(i)] Truth table:\n\n  \\vspace{5pt}\n\n  \\begin{tabular}{c c c c c}\n\n  $p$ & $q$ & $(p \\IMP q)$ & $\\NOT q$ & $((p \\IMP q) \\IMP \\NOT q)$ \\\\\n\n  \\hline\n\n  T & T & T & F & F \\\\\n  T & F & F & T & T \\\\\n  F & T & T & F & F \\\\\n  F & F & T & T & T \\\\\n  \\end{tabular}\n\n  \\vspace{15pt}\n  \\item[(ii)] Since:\n\n  \\vspace{5pt}\n\n  \\begin{tabular}{c c c c}\n\n  \\emph{p} & \\emph{q} & (\\emph{p} $\\IMP$ \\emph{q}) & ($\\NOT$\\emph{p} $\\OR$ \\emph{q}) \\\\\n\n  \\hline\n\n  T & T & T & T \\\\\n  T & F & F & F \\\\\n  F & T & T & T \\\\\n  F & F & T & T \\\\\n  \\end{tabular}\n\n  \\vspace{15pt}\n\n  From the truth table above, we can see that $(p \\IMP q)$ is logically equivalent to $(\\NOT p \\AND q)$ since both are \\emph{false} only if $p$ is \\emph{true} and $q$ is \\emph{false}, but are \\emph{true} otherwise. We can therefore use this to change the structure of our original implication:\n\n  \\begin{align*}\n  &(p \\IMP q) \\IMP \\NOT q \\\\\n  &(\\NOT p \\OR q) \\IMP \\NOT q \\\\\n  &\\NOT (\\NOT p \\OR q) \\OR \\NOT q \\\\\n  &(p \\AND \\NOT q) \\OR \\NOT q\n  \\end{align*}\n\n  \\end{enumerate}\n\n\\newpage\n\n\\item[(b)] $(p \\IMP \\NOT r) \\AND (\\NOT p \\IMP q)$.\n\n  \\begin{enumerate}\n  \\item[(i)] Truth table:\n\n  \\vspace{5pt}\n\n  \\begin{tabular}{c c c c c c}\n\n  \\emph{p} & \\emph{q} & \\emph{r} & ((\\emph{p} $\\IMP$ $\\NOT$\\emph{r}) & $\\AND$ & ($\\NOT$\\emph{p} $\\IMP$ \\emph{q})) \\\\\n\n  \\hline\n\n  T & T & T & F & F & T \\\\\n  T & T & F & T & T & T \\\\\n  T & F & T & F & F & T \\\\\n  F & T & T & T & T & T \\\\\n  F & F & T & T & F & F \\\\\n  T & F & F & T & T & T \\\\\n  F & T & F & T & T & T \\\\\n  F & F & F & T & F & F \\\\\n\n  \\vspace{15pt}\n\n  \\end{tabular}\n\n  \\item[(ii)] The strategy will be the same as problem (ii), which is to replace the implications with $(\\NOT p \\AND q)$. Each line is logically equivalent to the line above:\n\n  \\begin{align*}\n  &(\\emph{p} \\IMP \\NOT \\emph{r}) \\AND (\\NOT \\emph{p} \\IMP \\emph{q}) \\\\\n  &(\\NOT \\emph{p} \\OR \\NOT \\emph{r}) \\AND (\\NOT (\\NOT \\emph{p}) \\OR \\emph{q})) \\\\\n  &(\\NOT \\emph{p} \\OR \\NOT \\emph{r}) \\AND (\\emph{p} \\OR \\emph{q})\n  \\end{align*}\n\n  \\end{enumerate}\n\\end{enumerate}\n\n\\newpage\n\n\n\\section{Fixed points}\n\n\\begin{enumerate}\n\\item[(a)] ``\\emph{f} has a fixed point.'': \\\\\n$\\exists x \\IN \\N, f(x) = x$\n\n\\item[(b)] ``\\emph{f} has a \\emph{least} fixed point.'': \\\\\n$\\exists x \\IN \\N, \\forall y \\IN \\N, ((f(x) = x) \\AND (f(y) = y) \\AND (x \\ne y)) \\IMP x < y$\n\n\\item[(c)] ``\\emph{f} has a \\emph{greatest} fixed point.'': \\\\\n$\\exists x \\IN \\N, \\forall y \\IN \\N, ((f(x) = x) \\AND (f(y) = y) \\AND (x \\ne y)) \\IMP x > y$\n\n\\item[(d)]\n\\begin{itemize}\n\\item The fixed points of \\emph{f} are: $\\{x \\IN \\N \\mid 0 \\leqslant x \\leqslant 6 \\}$\n\\item The \\emph{least} fixed point of $f$ is $0$.\n\\item The \\emph{greatest} fixed point of $f$ is $6$.\n\\end{itemize}\n\n\nFor all natural numbers less than seven, we have that a division by seven will always be zero, with the remainder equal to the divisor. Therefore we have that the input and output match. Since the remainders of the division must be strictly less than the dividend, any input larger or equal to seven cannot output itself.\n\n\\end{enumerate}\n\n\\newpage\n\n\n\\section{Partial Orders}\n\n\\begin{enumerate}\n\\item[(a)] An example of a binary predicate $R$ on $\\N$ that is a partial order, but that is not a total order, is the divides operator.\n\nLet $R(x, y)$ be the statement: x divides y, denoted by $x \\mid y$, (where $x, y \\IN \\N$). Then this binary predicate $R$ on $\\N$ is a partial order because it satisfies all three partial order conditions.\n\n\\begin{itemize}\n    \\item Reflexive: All numbers divide themselves to get one.\n    \\item Transitive: Suppose $n_1 \\mid n_2 \\land n_2 \\mid n_3$. Then it must follow that $n_1 \\mid n_3$.\n\n    \\emph{Proof}:\n\n    Assume $n_1 \\mid n_2$. Then by the definition of divisibility,\n\n    $\\exists k_1 \\in \\Z, k_1 \\cdot n_1 = n_2$.\n\n    Assume $n_2 \\mid n_3$. Then by the definition of divisibility,\n\n    $\\exists k_2 \\in \\Z, k_2 \\cdot n_2 = n_3 \\implies \\exists k_2 \\in \\Z, k_2 \\cdot (k_1 \\cdot n_1) = n_3 \\implies  \\exists k_3 \\in \\Z$, that is, $( k_2 \\cdot k_1)$ , such that $k_3 \\cdot n_1 = n_3$\n\n    Therefore transitivity holds.\n\n    \\item Anti-Symmetric: In the realm of natural numbers, divisibility is Anti-Symmetric:\n\n\n    \\emph{Proof}:\n\n    Assume $n_1 \\mid n_2$. Then by the definition of divisibility,\n\n     $\\exists k_1 \\in \\Z, k_1 \\cdot n_1 = n_2$.\n\n     Assume $n_2 \\mid n_1$. Then by the definition of divisibility,\n\n    $\\exists k_2 \\in \\Z, k_2 \\cdot n_2 = n_1$\n\n    Then it must follow that $(n_1 \\cdot k_1) \\cdot k_2 = n_1$, in which case either $n_1$ and $n_2 = 0$ or $k_1 \\cdot k_2 = 1$ and we have that $n_1 = n_2$\n\n    Therefore Anti-Symmetric Property holds.\n\n\n\n\\end{itemize}\n\n\n$R(x, y)$ does not satisfy the total order property:\n$\\forall x, y \\IN \\N, R(x, y) \\OR R(y, x)$. For instance if we choose $x = 3$ and $y = 5$, then this property does not hold over $\\N$.\n\n\\newpage\n\n\\item[(b)] In order for every element to be a maximal, we examine the definition, which tells us that $d$ is a maximal if: $\\forall$ $d'$ in $D$, {\\textbf{$d = d'$}} $\\lor$ $\\neg$$R(d, d')$. Therefore, we can make every element of $D$ a \\emph{maximal}, by defining a partial order such that, $a = b = c = d$.\n\nI define a partial order as follows:\n\n$R(a, b) = R(b, a) = R(b, c) = R(c, b) = R(c, d) = R(d, c) = R(a, a) = R(b, b) = R(c, c) = R(d, d) = True$ and all other values are $False$.\n\nClearly such is reflexive since $R(a, a) = R(b, b) = R(c, c) = R(d, d) = True$\nAlso, since we have that whenever $R(d, d')$ is $True$, we say that $d \\leq d'$;\n\n\\begin{itemize}\n    \\item $a \\leq b$ $\\land$ $b \\leq a$ $\\implies$ $a = b$\n    \\item $b \\leq c$ $\\land$ $c \\leq b$ $\\implies$ $b = c$\n    \\item $c \\leq d$ $\\land$ $d \\leq c$ $\\implies$ $c = d$\n\\end{itemize}\n\nThe above is a direct result of the anti-symmetric property.\nMoreover, transitivity is evident since collectively, $a = b = c = d$\n\nLastly, such a partial order ensures $a$ and $b$ and $c$ and $d$ are all \\emph{maximal}, since all other elements in the set ${a, b, c, d }$ satisfy the first condition on the left of the \\emph{or}. (\\emph{equality}) \\footnote{$d$ is a maximal if: $\\forall$ $d'$ in $D$, {$d = d'$}}\n\n\n\\item[(c)] We need $a \\in D$ to be a \\emph{maximal} but \\textbf{not} a \\emph{greatest element}. In other words, we need that none of $b, c, d$ be larger than $a$ but also that $a$ is not greater than or equal to some element. The way to achieve this is to have elements that are not comparable to $a$. \\footnote{This requires a partial order. Had it have been asked with a total order, a \\emph{maximal} would have necessarily been a \\emph{greatest element.}}\n\n\nI define a partial order as follows:\n\n$R(d, a) = R(d, b) = R(d, c) = R(d, d) = R(c, c) = R(b, b) = R(a, a) = True$ and all other values are $False$.\n\nWhat this says is that:\n\n\\begin{itemize}\n    \\item $d \\leq a$\n    \\item $d \\leq b$\n    \\item $d \\leq c$\n\\end{itemize}\n\nIt does not follow from this that $a$ is greater than or equal to every other element. In fact, $a$ is not even comparable to every other element.\n\n$\\therefore$ The definition of \\emph{greatest element} is not satisfied for $a$.\n\nHowever, it \\emph{does} follow that \\emph{no other element is larger than $a$}, since by definition of $R(d, d')$, it follows from the partial order that $a \\geq d$, and also, neither $b$ nor $c$ nor $d$ can possibly be larger than $a$ since that comparison cannot be made in the first place.\n\n$\\therefore$ The definition of \\emph{maximal} is satisfied for $a$.\n\n\n\n\n\\end{enumerate}\n\n\\newpage\n\n\\section{One-to-one functions}\n\n\\begin{enumerate}\n\\item[(a)] There are $4^3 = 64$ functions from $\\{ 1, 2, 3 \\} \\rightarrow \\{ a, b, c, d \\}$\n\n\\begin{itemize}\n    \\item Every element in domain has 4 possible choices for an output. Therefore to get the total number of possible combinations, we must multiply: $ 4 \\cdot 4 \\cdot 4 = 4^3 = 64$.\n\\end{itemize}\n\n\\item[(b)] There are $24$ one-to-one functions from $\\{ 1, 2, 3 \\} \\rightarrow \\{ a, b, c, d \\}$\n\n\\begin{itemize}\n    \\item One-to-one says that no two distinct inputs are mapped to the same output. This means that input (1) has 4 possible outputs, since none have been exhausted by a different input. Input(2) has only 3 possible outputs: all but the one chosen by input(1). By similar logic, input(3) has only 2 possible outputs. Together, there are $4 \\cdot 3 \\cdot 2 = 24$ one-to-one functions.\n\\end{itemize}\n\n\\item[(c)] There are $36$ onto function from $\\{1, 2, 3, 4\\} \\rightarrow \\{a, b, c\\}$\n\n\\begin{itemize}\n  \\item Lets say $A = \\{ 1, 2, 3, 4 \\}$ and $B = \\{ a, b, c \\}$. Then we know $\\abs A = 4 = n$ and $\\abs B = 3 = m$.\n\n  Lets first suppose $\\abs A = \\abs B = n$, then the first element from $A$ could map to any particular element in $B$. The second element in $A$ could map to any of the remaining $n - 1$ elements of $B$, and so on. Then the number of onto functions from $A$ to $B$ would equal $n!$.\n\n  Since $\\abs A > \\abs B$, we of course can't use the formula above to find the number of \\emph{onto functions} from $A$ to $B$. We want to find the number of \\emph{onto functions} from $A$ to $B$, where $n > m$. So the crux of the idea is this: if we can find all the partitions of $A$ into groups of $m$, then each of those partitions describes an \\emph{onto function} from $A$ to $B$, and we can simply multiply the number of partitions by $m!$. For example, the partitions of $A$ into $six$ groups of $three$ include:\n  $A = \\{ \\{ 1, 2 \\}, 3, 4 \\} = \\{ \\{ 1, 3 \\}, 2, 4 \\} = \\{ \\{ 1, 4 \\}, 2, 3 \\} = \\{ 1, \\{ 2, 3 \\}, 4 \\} = \\{ 1, \\{ 2, 4 \\}, 3 \\} = \\{ 1, 2, \\{ 3, 4 \\} \\}$. In the first partition, this says that elements $1$ and $2$ map to the same arbitrary element in $B$, $3$ maps to an arbitrary element from the remaining $3 - 1$ elements, and similarly, $4$ maps to last remining element in $B$, $3 - 2$. Since we can do this for each of the \\emph{six} functions above, we arrive at our answer of $6 \\cdot 3! = 6 \\cdot 3 \\cdot 2 \\cdot 1 = 36$.\n\\end{itemize}\n\n\\item[(d)] Function(R): $\\forall x, \\exists y_1, R(x, y_1) \\wedge \\forall y_2, R(x, y_2) \\Rightarrow y_1 = y_2,$ where $x \\IN \\N, y_1 \\IN \\N, y_2 \\IN \\N $\n\\item[(e)] Onto(R): Function(R) $\\land$ $\\forall y \\IN \\N, \\exists x \\in \\N, R(x, y)$\n\\item[(f)] One-to-one(R): Function(R) $\\land$ $\\forall x_1, x_2, y \\IN \\N, R(x_1, y) \\land R(x_2, y) \\implies x_1 = x_2$\n\\item[(g)] Inf(R): Function(R) $\\land$ $\\forall x_1, y_1 \\in \\N, R(x_1, y_1), \\exists x_2, y_2 \\in \\N, R(x_2, y_2)$ $\\land$ $y_1 < y_2$\n\\item[(h)] All-but(R): $\\exists$ a set $D = \\{x_1, x_2, ..., x_c \\}, \\forall x_i \\in D, \\forall y \\in \\N, \\neg R(x_i, y) \\land \\forall x_j \\notin D, R(x_j, y) \\land \\exists m \\in \\N, c \\lneq m$\n\n%%% for h this needs to be written better but the idea i have is that there exists some constant that is larger than the amount of x's for which R(x, y) does not happen.\n\n\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "50dacd2270365bf6599a92d97c019a68ab5ba186", "size": 11337, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problem sets/ps1/problem_set1.tex", "max_stars_repo_name": "ericpko/CSC165", "max_stars_repo_head_hexsha": "72e1ffac63c571bf3dabdf86e683ca76385c6555", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "problem sets/ps1/problem_set1.tex", "max_issues_repo_name": "ericpko/CSC165", "max_issues_repo_head_hexsha": "72e1ffac63c571bf3dabdf86e683ca76385c6555", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problem sets/ps1/problem_set1.tex", "max_forks_repo_name": "ericpko/CSC165", "max_forks_repo_head_hexsha": "72e1ffac63c571bf3dabdf86e683ca76385c6555", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.4892857143, "max_line_length": 533, "alphanum_fraction": 0.6192114316, "num_tokens": 4157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8499711699569787, "lm_q1q2_score": 0.4283057173131434}}
{"text": "\\chapter{The Calculus of Inductive Constructions}\n\\label{chap:tech-intro}\n\n\\margintoc\n\nMost of this thesis revolves around \\kl[dependent type]{dependent type systems}.\nDue to their complexity, there is a high number of\npoints subject to slight variations\nwhen one tries to give a precise definition of a system.\nSome of these variations are unimportant, but some introduce subtle albeit large differences\nin the resulting systems. In this chapter we go in details over\nthe definition of what I refer to as the\n\\kl{Calculus of Inductive Constructions} (\\kl{CIC}) in the rest of this\nthesis, where it serves as the base system.\nWhile doing so, I try to give an idea of the trade-offs involved, and of the reasons\nbehind the choices. Quite a few of those vary during the thesis,\nand this is by design: there is no single better choice,\ninstead one has to adapt to the setting.\n\nFor the impatient specialists, let me say now that with \\kl{CIC}, I\nmean an intensional type theory, with Church-style abstractions,\na predicative hierarchy of universes%\n\\sidenote[][14em]{\n  And only those: by default I do \\emph{not} include an impredicative sort of propositions, a feature often associated with the name \\kl{CIC}. I still use that name because of\n  two characteristics that I feel sets apart the tradition around \\kl{CIC} in the dependent type\n  theory literature: the definition of \\kl{conversion} as an \\emph{untyped} relation,\n  and the use of Church-style abstractions. See \\cref{chap:names} for a longer discussion.}\n\\textit{à la} Russell, and any amount of inductive types presented by recursors.\n% – the ones appearing most often in what comes next being the empty and\n% unit types, booleans, natural numbers, dependent sums, lists, vectors and the equality.\nConversion is the reflexive, symmetric, transitive and congruent\nclosure of βι-reduction, and so in particular it is untyped.\n\nFor the others, the present chapter aims at introducing the basic\nsystems and properties which we refer to in the rest of the text.\n\\cref{sec:tech-typing} introduces the basic notions;\n\\cref{sec:tech-ccw} presents a first type system,\nthe \\kl{Calculus of Constructions} (\\kl{CCω}),\nthe purely functional core all our systems rely on;\n\\cref{sec:tech-conversion} defines the main notions of \\kl{conversion} and\n\\kl{reduction} encountered in the rest of the thesis;\n\\cref{sec:tech-properties} introduces the main properties our systems should satisfy;\n\\cref{sec:tech-cic} adds inductive types to \\kl{CCω} to build\n\\kl{CIC}; finally \\cref{sec:tech-pcuic} discusses the extra additions to go from\n\\kl{CIC} to the \\kl{Polymorphic, Cumulative Calculus of Inductive Constructions}\n(\\kl{PCUIC}), a faithful model of the type theory implemented by the\nkernel of \\kl{Coq}.\n\n\\section{Terms and Types}\n\\label{sec:tech-typing}\n\n\\AP Throughout this chapter, type systems are defined by means of a relation\n$\\Gamma \\vdash t \\ty T$, which reads “in the context $\\Gamma$, the term $t$ has type $T$”.\nFrom the logical point of view, this judgement means that $\\Gamma$ is the list of\nhypothesis available to deduce the conclusion $T$ by means of the proof $t$.\nOn the programming side, it means that $t$ is a well-formed program of type $T$,\nwhich uses the variables listed together with their types in $\\Gamma$.\nHence, $\\Gamma$ is a list of declarations, of the form $x : A$.\nWe write $\\intro*\\emptycon$ for the empty context,\n$\\Gamma, x : A$ for the extension of context $\\Gamma$ with the new variable $x : A$,\nand $(x : A) \\in \\Gamma$ to denote that the declaration $x : A$ appears\nin the context $\\Gamma$.\n\n\\begin{marginfigure}\n  \\ContinuedFloat*\n  \\begin{mathpar}\n  \\inferdef{Var}{\\vdash \\Gamma \\\\ (x : A) \\in \\Gamma}{\\Gamma \\vdash x \\ty A}\n  \\label{rule:cic-var}\n  \\end{mathpar}\n  \\caption{Typing rule for a variable}\n  \\label{fig:cic-var}\n\\end{marginfigure}\n\nThis typing relation itself is defined by means of inference rules,\nsuch as \\ruleref{rule:cic-var} opposite. The way to read this rule is that the judgement\nunderneath the line follows from the one above,\n\\ie from $(x : A) \\in \\Gamma$\nand $\\vdash \\Gamma$ –~a judgement that we will soon define asserting that the context\n$\\Gamma$ is well-formed – we can deduce $\\Gamma \\vdash x \\ty A$.\nWhen objects appear in the hypothesis but not the conclusion, they are implicitly\nuniversally quantified.\nOnce a set of such inference rules is fixed,\ntyping is defined as the least relation closed by those\nrules. Equivalently, a judgement such as $\\Gamma \\vdash t \\ty T$\nholds whenever we can build a tree whose nodes are instances of the inference rules,\nand whose root is the judgement in question. A general setting\nfor this kind of definitions of type systems can be found in \\sidetextcite{Bauer2020},\nbut in our case we restrict to this level of informality for the time being.%\n\\sidenote{In \\arefpart{metacoq}, however, such judgements\nare formalized as inductively defined propositions.}\n\n\\AP As we have already introduced variables, a word on those as well. Variables are difficult\nto account for precisely, because of issues like shadowing – a conflict between two variables\nwith the same name – or \\intro{α-equality} $\\mathord{\\intro*\\alpheq}$~–\nthe identification between two terms\nonly differing on variable names. There are multiple techniques to solve these issues\n– see the many solutions to the POPLMark Challenge~\\sidecite{Aydemir2005} –, \nbut we again treat these in an informal way, assuming\nthere is no shadowing whatsoever and identifying α-equal terms when needed.%\n\\sidenote{A precise treatment is again given in \\arefpart{metacoq}, where we\nuse De Bruijn variables.}\n\n\\AP \\phantomintro{\\into}\nA final important building block of all our type theories is \\intro{substitution},\nthat we write $\\intro*\\subs{t}{x}{u}$. This meta-operation replaces every occurrence of $x$\nin $t$ by the term $u$.\nOnce again, we treat this operation informally, assuming it never creates\nshadowing – what is sometimes called “capture-avoiding” substitution.\nIt is sometimes useful to substitute multiple variable at once in parallel,\nwhich we write $\\intro*\\multisubs{t}{x_1 \\into u_1, \\dots, x_n \\into u_n}$.\n\n\\section{Functional Core: \\kl(tit){CCω}}\n\\label{sec:tech-ccw}\n\n\\AP Let us now turn to the core of \\kl{CIC}, namely the\n\\intro{Calculus of Constructions} (\\intro{CCω}). Through the \\kl{Curry-Howard correspondence},\nit is both a typed form of λ-calculus – \\ie a kind of purely functional\nprogramming language – and a minimal form\nof logic – only containing universal quantification and implication.\nSince its introduction by \\sidetextcite{Coquand1988}, it has been the subject of intense\ntheoretical study, modifications, and extensions, so let us fix what we exactly mean\nwith “\\kl{CCω}”.\n\n\\subsection{Functions and applications}\n\nLet us start with the basic terms: functions and applications.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferrule{\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma, x : A \\vdash t \\ty T}\n    {\\Gamma \\vdash \\l x : A .\\ t \\ty A \\to T}\n    \\and\n    \\inferrule{\\Gamma \\vdash f \\ty A \\to T \\\\ \\Gamma \\vdash u \\ty A }{ \\Gamma \\vdash f\\ u \\ty T}\n  \\end{mathpar}\n  \\caption{Typing for non-dependent functions}\n  \\label{fig:cic-nondep-fun}\n\\end{marginfigure}\n\nFunctions, also called λ-abstractions, are written $\\l x : A .\\ t$. This corresponds\nto the mathematical notation $x \\mapsto t$: the body $t$ of the function\nis a term that might contain the variable $x$,\nand the constructor λ abstracts over that variable to build a function.\nConversely, function application is denoted by simple juxtaposition, as in $t\\ u$.\nThe type of functions is written $\\to$, as in ordinary mathematics.\nYou can see those at work in \\cref{fig:cic-nondep-fun}: an abstraction builds a term of arrow\ntype, and application needs its function to be of an arrow type,\nwhose domain must moreover correspond to the type of the argument.\nThe side-condition $\\Gamma \\vdash A \\ty \\uni$ ensures that the annotation is a valid type,\nwe will introduce it shortly.\nLogically, those rules make sense if $\\to$ is read as implication:\nif from a hypothesis $A$ one can deduce $T$, then $A \\to T$ holds; conversely if $A \\to T$\nand $A$ both hold, then $T$ does as well.\n\n\\begin{marginfigure}\n  \\ContinuedFloat*\n  \\begin{mathpar}\n    \\inferdef{Abs}{\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma, x : A \\vdash t \\ty T}\n    {\\Gamma \\vdash \\l x : A .\\ t \\ty \\P x : A.\\ T}\n    \\label{rule:cic-abs}\n    \\and\n    \\inferdef{App}{\\Gamma \\vdash f \\ty \\P x : A.\\ T \\\\ \\Gamma \\vdash u \\ty A}{ \\Gamma \\vdash f\\ u \\ty \\subs{T}{x}{u}}\n    \\label{rule:cic-app}\n  \\end{mathpar}\n  \\caption{Typing for dependent functions}\n  \\label{fig:cic-dep-fun}\n\\end{marginfigure}\nThese arrow types, however, are not as expressive as one could hope for.\nRemember that we are in the realms of dependent types, so not only $t$ might mention $x$,\nbut also $T$. For instance, $T$ might be something like “$x$ is even”. In such a case,\nwe need to record that dependency, which is the point of Π-types\n– or dependent function types –, shown in \\cref{fig:cic-dep-fun}.\nSeen as function types, they record the fact that the codomain\nmight vary depending on the argument. This is reflected in the typing rule for application:\nsince the codomain $T$ might depend on $x$, the type of the application $f\\ u$ is $T$\n\\emph{specialized at the argument $u$}, using substitution.\nSeen on the logical side, Π-types correspond to universal quantification\n$\\operatorname{\\forall} x : A.\\ T(x)$.\nIndeed, if one can show that $T(x)$ holds for an unspecified $x$,\nthen it must hold for all $x: A$ – this is \\ruleref{rule:cic-abs}.\nConversely, if $T$ holds for all $x: A$, then one can deduce $T(u)$ for any specific\n$u \\ty A$ – this is \\ruleref{rule:cic-app}.\nThe rules of \\cref{fig:cic-nondep-fun} are just a special case\nof those, in the case where the codomain $T$ does not depend\non the variable $x$, and we use this convention throughout the thesis:\n$A \\to T$ is shorthand for $\\P x : A.\\ T$ when $T$ does not mention $x$.\n\n\\AP One last thing to note about our functions is that they record the type of their\ndomain – what is called \\intro{Church-style}\nabstraction~\\sidecite[][Section~3]{Barendregt1992}. There is an alternative – \nthe \\intro{Curry-style} abstractions –, that\ndoes not do so, simply using $\\l x.\\ t$ for functions.\nThis difference becomes important as soon as one looks at the bidirectional structure. \nIndeed, the annotation is required if one wants to infer types for functions,\nrather than barely checking them.\nThe \\kl{Curry-style} option is sensible though,\nsee for instance the implementation of the proof assistant \\kl{Agda} \\sidecite[][p.~19]{Norell2007}, \\sidetextcite{Abel2017} or \\sidetextcite{McBride2022}.\nIn the end, this is really a design choice between being able to infer a type for any term,\nor requiring annotations that in a lot of cases are useless. In this\nthesis we stick with the approach used in \\kl{Coq}, and annotate our abstractions.\n\n\\subsection{Universes}\n\nTo be able to express ideas like induction principles or polymorphic functions, it is\nextremely useful to use functions and Π-types quantifying over types.\nThis is what the universe $\\intro*\\uni$ – read “Type” — is for. It is the type… of a type.\nThis also means that the border between types and terms is not a syntactic one, because\n\\eg functions can abstract over a type. Instead, types are simply terms of type $\\uni$.\nDespite this, we still use upper case letters for terms which we want to think of as types.\nSuch a universe is called \\textit{à la} Russell~\\sidecite{Palmgren1998}, by contrast with\nuniverses \\textit{à la} Tarski, which regain the distinction between types and terms at\nthe cost of a somewhat heavier treatment of types.\nSince we have not much use for a presentation \\textit{à la} Tarski in this thesis,\nwe use the simpler one.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{Univ}\n    {\\vdash \\Gamma}\n    {\\Gamma \\vdash \\uni[i] \\ty \\uni[\\unext{i}]}\n    \\label{rule:cic-univ}\n  \\end{mathpar}\n  \\caption{Typing for universes}\n  \\label{fig:cic-univ}\n\\end{marginfigure}\n\n\\AP There is an important caveat regarding universes.\nSince the paradox exhibited by Russell in \\citeauthor{Begriffsschrift}'s\n\\citetitle{Begriffsschrift}~\\sidecite{Begriffsschrift},\nlogicians know that considering a set of all sets is a great\nsource of inconsistencies. Type theory is not devoid of this issue:\nGirard~\\sidecite[][Annex~A]{Girard1972}\nshows how having a type with itself as type is inconsistent.\nThis inconsistency directly applies to the first dependent type system proposed by\nMartin-Löf~\\sidecite{MartinLoef1972}, which has a single universe $\\uni$ and a rule $\\uni \\ty \\uni$.\nA common solution to this issue\nis to stratify universes into an infinite hierarchy, which gives us \\ruleref{rule:cic-univ}.\nNote how $\\uni$ is indexed by the \\intro{universe levels} $i$ and $\\unext{i}$.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{ΠTy}\n    {\\Gamma \\vdash A \\ty \\uni[i] \\\\ \\Gamma, x : A \\vdash B \\ty \\uni[j]}\n    {\\Gamma \\vdash \\P x : A.\\ B \\ty \\uni[\\umax{i}{j}]}\n    \\label{rule:cic-prod}\n  \\end{mathpar}\n  \\caption{Typing for dependent function types}\n  \\label{fig:cic-prod}\n\\end{marginfigure}\n\nUsing those universes, \\ruleref{rule:cic-prod} gives the typing rule for\nΠ-types. We can also now give a definition of the $\\vdash \\Gamma$\njudgement, asserting that a context is well-formed, in \\cref{fig:cic-con}.\nIt simply means that all its types\nare indeed types. Note that in \\ruleref{rule:cic-cons-con}, we did not write down a\n\\kl{level} for the universe, we do so to mean the existence of some unconstrained one in\norder to ease reading.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{Empty}\n    { }{\\vdash \\cdot}\n    \\label{rule:cic-empty-con} \\and\n    \\inferdef{Ext}\n    {\\vdash \\Gamma \\\\ \\Gamma \\vdash A \\ty \\uni}{\\vdash \\Gamma, x : A}\n    \\label{rule:cic-cons-con}\n  \\end{mathpar}\n  \\caption{Context well-formation}\n  \\label{fig:cic-con}\n\\end{marginfigure}\n\n\\AP One last important point regarding universes is the kind of \\kl{levels} used.\nA simple solution is to rely on natural numbers (of the meta-theory),\nwith the $\\intro*\\unextsymb$\nand $\\intro*\\umaxsymb$ operations interpreted by the usual ones.\nThis is however not strictly necessary: we need levels\nto form a (well-founded) pre-order to avoid inconsistency, and operations\nsuch as $\\unextsymb$ and $\\umaxsymb$ to express our typing rules,\nbut levels could very well be something different from natural numbers.\nIn particular, the natural number approach fixes at which exact level a particular construction\nis done, which is usually much more rigid than what one would wish for.\nA more flexible approach, introduced under the name \\intro{typical ambiguity} by\n\\sidetextcite{Harper1991},\nuses level expressions based on level variables, rather than numbers.\nThis way, one can collect exactly the constraints between levels required for a\nterm to type-check, without artificially enforcing a\nrigid interpretation by fixing their value to a precise number once and for all.\nTo simplify the presentation, our default \\kl{CCω} and \\kl{CIC} nonetheless use natural\nnumbers, but \\kl{typical ambiguity} appears at multiple points in this thesis.\n\n\\section{50 Shades of Conversion}\n\\label{sec:tech-conversion}\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n  \\inferdef{Conv}\n    {\\Gamma \\vdash t \\ty T \\\\ \\Gamma \\vdash T \\conv T' \\ty \\uni}\n    {\\Gamma \\vdash t \\ty T'}\n  \\label{rule:cic-conv}\n  \\end{mathpar}\n  \\caption{Conversion rule}\n  \\label{fig:cic-conv}\n\\end{marginfigure}\n\n\\AP There is one big missing part in the picture so far. Remember we are working with\ndependent types, and that those can contain terms, which in turn can be seen as programs.\nIn the case for instance of the vector type we used in the introduction – and that we are\nabout to introduce formally –, what happens if a function expects an argument of type\n$\\Vect(A,3)$, but it is given as argument the output of a concatenation function,\nwhich naturally has type $\\Vect(A,2+1)$?\nSurely we must have a way to relate both, since after all\nthe small program $2+1$ ought to compute $3$! This is exactly what\n\\ruleref{rule:cic-conv}%\n\\sidenote{This wraps up our typing\nrules for \\kl{CCω}, collected in \\cref{fig:ccw-typing}. The rule for non-dependent functions\nis not included, since the one for dependent functions subsumes it.}\nis for: it allows to replace a type $T$ with one that is related to it by\n\\intro{conversion}, written $\\intro*\\conv$.\nAs usual, there are two ways to look at this relation. From the point of view of programs,\nit incorporates a computational aspect directly inside the type system.\nFrom the point of view of logic, it corresponds to types being the same “by definition”\nrather than due to some reasoning\n– which is why conversion is also called definitional equality or judgemental equality.\nIn our vector example, for instance, the two types are the same by virtue of\nthe definition of addition.\n\n\\begin{figure*}[ht]\n  \\LastFloat\n\n  \\begin{mathpar}\n    %\n    \\jform{\\vdash \\Gamma}\n    \\inferdef{Empty}\n      { }{\\vdash \\cdot}\n    \\and\n    \\inferdef{Ext}\n      {\\vdash \\Gamma \\\\ \\Gamma \\vdash A \\ty \\uni}{\\vdash \\Gamma, x : A}\n    \\\\\\\\\n    \\jform{\\Gamma \\vdash t \\ty T}\n    \\inferdef{Var}{(x : A) \\in \\Gamma \\\\ \\vdash \\Gamma}{\\Gamma \\vdash x \\ty A}\n    \\and\n    \\inferdef{Univ}\n      {\\vdash \\Gamma}\n      {\\Gamma \\vdash \\uni[i] \\ty \\uni[\\unext{i}]}\n    \\and\n    \\inferdef{ΠTy}\n      {\\Gamma \\vdash A \\ty \\uni[i] \\\\ \\Gamma, x : A \\vdash B \\ty \\uni[j]}\n      {\\Gamma \\vdash \\P x : A.\\ B \\ty \\uni[\\umax{i}{j}]}\n    \\and\n    \\inferdef{Abs}{\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma, x : A \\vdash t \\ty T}\n    {\\Gamma \\vdash \\l x : A .\\ t \\ty \\P x : A.\\ T}\n    \\and\n    \\inferdef{App}\n      {\\Gamma \\vdash f \\ty \\P x : A.\\ T \\\\ \\Gamma \\vdash u \\ty A }\n      {\\Gamma \\vdash f\\ u \\ty \\subs{T}{x}{u}}\n    \\and\n  \\inferdef{Conv}\n    {\\Gamma \\vdash t \\ty T \\\\ \\Gamma \\vdash T \\conv T' \\ty \\uni}\n    {\\Gamma \\vdash t \\ty T'}\n  \\end{mathpar}\n\n  \\caption{Collected typing rules for \\kl{CCω}}\n  \\label{fig:ccw-typing}\n\\end{figure*}\n\nConversion is a complex relation, arguably the most subtle part of dependent types.\nConsequently, there are quite different ways to present it, which in turn serve different\nneeds.\nFor this reason, we took care to set the typing rules of\n\\cref{fig:ccw-typing} up so that nothing has to\nbe changed in those when one definition of conversion or another is taken. The only\ndifference is in how the relation $\\Gamma \\vdash T \\conv T' \\ty \\uni$ is defined.\nThis way, we can treat conversion as a black box when talking about typing,\nmaking the theory modular.\n\n\\AP A first important divide is between \\intro(conv){typed} and\n\\intro(conv){untyped} conversion.\nOn one side, conversion is seen as an intrinsically typed relation: terms are only convertible\n\\emph{at a given type}. On the other, conversion is a relation between raw terms,\nthat does not presuppose any form of typing. \\Cref{fig:typed-untyped-conv} gives an\nexample of the computation rule for functions in both systems.\nThe “content” of the two rules is the same – they equate $(\\l x : A.\\ t)\\ u$\nand $\\subs{t}{x}{u}$ – only the side-conditions differ substantially.\n\\kl{Typed conversion} goes back to the type theory of\n\\sidetextcite{MartinLoef1972}, and is a recurring feature in its many descendants.\n\\AP \\kl{Untyped conversion} relates strongly to (untyped) λ-calculus%\n\\sidenote{Barendregt\n  for instance uses the name “conversion” for the equational theory of untyped λ-calculus\nin his reference work on the subject\\cite{Barendregt1985}.}%\n\\margincite{Barendregt1985}\nvia the \\intro{Pure Type Systems} (\\kl{PTS}) \\sidecite{Barendregt1991} literature.\nIn this thesis, we mainly consider untyped conversion, as \\kl{Coq}’s meta-theory\nhas been mostly studied in that tradition.\nBut the relation between both in the context of\nbidirectional typing is the main subject of \\cref{chap:bidir-conv}.\n\n\\begin{figure}[ht]\n  \\begin{mathpar}\n    \\inferrule\n      {\\Gamma, x : A \\vdash t \\ty B \\\\ \\Gamma \\vdash u \\ty A}\n      {\\Gamma \\vdash (\\l x : A.\\ t)\\ u \\tdconv \\subs{t}{x}{u} \\ty \\subs{B}{x}{u}}\n    \\and\n    \\inferrule{ }{(\\l x : A.\\ t)\\ u \\dconv \\subs{t}{x}{u}}\n  \\end{mathpar}\n  \\caption{Example: typed and untyped β rule for conversion}\n  \\label{fig:typed-untyped-conv}\n\\end{figure}\n\nA second axis is about how close the conversion relation is to an implementation.\nFor instance, conversion should be an equivalence relation,\nbut there are two approaches to that. The first – and most standard – one\nis to simply \\emph{define} conversion as an equivalence relation, by adding rules \nfor \\eg transitivity, as the one of \\cref{fig:trans-conv}.\n\\begin{marginfigure}\n  \\begin{mathpar}\n    \\inferrule\n      {t \\dconv t' \\\\ t' \\dconv t''}\n      {t \\dconv t''}\n  \\end{mathpar}\n  \\caption{Example: transitivity rule for conversion}\n  \\label{fig:trans-conv}\n\\end{marginfigure}\nThis ensures that conversion has the right properties, but means it does not directly correspond\nto an algorithm, as this transitivity rule cannot be directly implemented,\ndue to the need to “invent” the middle term $t'$.\n% , since its middle term is not recorded in any place.\nThe λ-calculus theorists have known this issue for a long time, and they\nhave a solution: characterizing conversion by means of a \\kl{reduction} relation $\\red$, which\ncorresponds to the idea of program evaluation \\cite{Barendregt1985}.\nIf this reduction is well-behaved,\n%\\sidenote{The main one being confluence.}\nthen two terms are convertible exactly when they reduce to the same third term.\nThis more operational characterization is closer to what can be implemented.\nTurning things around, one can define conversion through reduction,\nand only \\emph{show} in retrospect that it has the good properties\nthat were enforced in the first approach – typically, that it is transitive.\n\\AP Conversion of the first kind we call \\intro{declarative conversion}, while for the second\nwe talk about \\intro{algorithmic conversion}.\n\nIn the rest of this section we give two presentations of \\kl{untyped conversion}.\nFirst, a \\kl(conv){declarative} one, which we use to define \\kl{CCω}, as is standard.\nSecond, an \\kl(conv){algorithmic} one, anticipating the need for it later on\nin Parts \\refname{metacoq} and \\refname{gradual}.\n% in \\arefpart{metacoq} where it is used to show decidability of type-checking, and\n% in \\arefpart{gradual}, where we extend it into a relation that is by design not transitive, so\n% that basing it on declarative conversion would be nonsensical.\n\n\\subsection{Declarative conversion}\n\\phantomintro{\\dconv}\n\n\\begin{marginfigure}\n  \\ContinuedFloat*\n  \\begin{mathpar}\n    \\inferdef{UConv}{\\Gamma \\vdash T' \\ty \\uni \\\\ T \\dconv T'}{\\Gamma \\vdash T \\conv T' \\ty \\uni}\n    \\label{rule:cic-conv-unty}\n  \\end{mathpar}\n  \\caption{Typing constraint on untyped conversion}\n\\end{marginfigure}\n\nTo start our presentation of \\kl{untyped conversion},\nlet us first go back to \\ruleref{rule:cic-conv}.\nEven if we wish to describe conversion as\nan untyped relation, we still enforce a typing constraint in \\ruleref{rule:cic-conv},\nin order to ensure that, whenever $\\Gamma \\vdash t \\ty T$ is derivable,\n$\\Gamma \\vdash T \\ty \\uni$ is as well.\nThis is exactly the content of \\ruleref{rule:cic-conv-unty}, which combines conversion\nwith a check that the target type is indeed a well-formed type.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{βConv}{ }{(\\l x : A.\\ t)\\ u \\dconv \\subs{t}{x}{u}}\n    \\label{rule:cic-uconv-beta}\n  \\end{mathpar}\n  \\caption{Computation rule for functions}\n  \\label{fig:cic-uconv-beta}\n\\end{marginfigure}\n\nRegarding conversion itself, the first rule is \\ruleref{rule:cic-uconv-beta},\nwhich corresponds to the computational behaviour\nof functions: the variable of an applied λ-abstraction is replaced by the argument, using\nsubstitution.\n\nThe rest of the rules ensure conversion has the properties it should. First are the\nones ensuring it forms an equivalence relation: it\nis reflexive (\\nameref{rule:cic-uconv-refl}), symmetric (\\nameref{rule:cic-uconv-sym}),\nand transitive (\\nameref{rule:cic-uconv-trans}).\n\n\\begin{figure}[ht]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{ConvRefl}{ }{t \\dconv t}\n    \\label{rule:cic-uconv-refl} \\and\n    \\inferdef{ConvSym}{t \\dconv t'}{t' \\dconv t}\n    \\label{rule:cic-uconv-sym} \\and\n    \\inferdef{ConvTrans}\n      {t \\dconv t' \\\\ t' \\dconv t''}\n      {t \\dconv t''}\n    \\label{rule:cic-uconv-trans}\n  \\end{mathpar}\n  \\caption{Equivalence rules}\n  \\label{fig:cic-uconv-equiv}\n\\end{figure}\n\nA second set of rules, collected in \\cref{fig:cic-uconv-cong},\nasserts that conversion is a congruence, meaning that it is compatible\nwith all term formers. As for the previous three, these correspond to properties we expect\nfrom the conversion relation, that we simply declare to be true. Note that we include only\ncongruence rules for term formers with sub-terms – we \\eg omit $\\uni$. To be exhaustive,\nwe could have included congruence rules for all term formers, but when they have no\nsub-term congruence is simply a special case of \\ruleref{rule:cic-uconv-refl}.\nConversely, we could omit \\ruleref{rule:cic-uconv-refl}\naltogether and derive it from congruence rules,\nwhich can be seen as a generalized form of reflexivity.\n\n\\begin{figure}[hb]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferrule\n    % \\inferdef{ProdConv}\n      {A \\dconv A' \\\\ B \\dconv B'}\n      {\\P x : A.\\ B \\dconv \\P x : A'.\\ B'}\n    % \\label{rule:cic-uconv-prod}\n    \\and\n    \\inferrule\n    % \\inferdef {AbsConv}\n      {A \\dconv A' \\\\ t \\dconv t'}\n      {\\l x : A .\\ t \\dconv \\l x : A'.\\ t'}\n    % \\label{rule:cic-uconv-abs}\n    \\and\n    % \\inferdef{AppConv}\n    \\inferrule\n      {f \\dconv f' \\\\ u \\dconv u' }\n      {f\\ u \\dconv f'\\ u'}\n    % \\label{rule:cic-uconv-app}\n  \\end{mathpar}\n  \\caption{Congruence rules}\n  \\label{fig:cic-uconv-cong}\n\\end{figure}\n\n\\subsection{Algorithmic conversion}\n\\phantomintro{\\aconv}\n\n\\AP Before we can describe \\kl{algorithmic conversion}, we first need\nto have a look at \\intro{reduction}. Reduction is in some way an operational version of\nconversion. The main difference is that it is oriented, in the direction\ncorresponding to program evaluation. It itself decomposes into three components.\n\n\\AP The first is \\intro{top-level reduction} $\\intro*\\tred$,\n\\begin{marginfigure}[0em]\n  \\ContinuedFloat*\n  \\begin{mathpar}\n    \\inferdef{βRed}{ }{(\\l x : A.\\ t)\\ u \\tred \\subs{t}{x}{u}}\n    \\label{rule:beta-red}\n  \\end{mathpar}\n  \\caption{Top-level reduction}\n  \\label{fig:cic-algo-conv}\n\\end{marginfigure}\nwhich corresponds purely to computation, without any congruence closure properties.\nIn \\kl{CCω} there is only the single \\ruleref{rule:beta-red}.\n\n\\AP The second component is the congruent closure of \\kl{top-level reduction},\n\\intro{one-step reduction} $\\intro*\\ored$. It allows triggering top-level reduction exactly once,\nbut at any position in a term. Its definition is given in \\cref{fig:ccw-ored}.\nNote that while we talk about congruent closure both for\n\\kl(decl){conversion} (\\cref{fig:cic-uconv-cong})\nand \\kl{one-step reduction}, we mean a different form of closure:\nin the case of conversion, we demand the relation to recursively hold in all sub-terms,\nwhile for one-step reduction it is allowed in exactly one sub-term.\n\n\\begin{figure}[ht]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferrule\n    % \\inferdef{TopRed}\n      {t \\tred t'}\n      {t \\ored t'}\n    % \\label{rule:top-red}\n    \\and\n    \\inferrule\n    % \\inferdef{ProdRedDom}\n      {A \\ored A'}\n      {\\P x : A.\\ B \\ored \\P x : A'.\\ B}\n    % \\label{rule:red-prod-dom}\n    \\and\n    \\inferrule\n    % \\inferdef{ProdRedCod}\n      {B \\ored B'}\n      {\\P x : A.\\ B \\ored \\P x : A.\\ B'}\n    % \\label{rule:red-prod-cod}\n    \\and\n    \\inferrule\n    % \\inferdef{AbsRedDom}\n      {A \\ored A'}\n      {\\l x : A .\\ t \\ored \\l x : A'.\\ t}\n    % \\label{rule:red-abs-dom}\n    \\and\n    \\inferrule\n    % \\inferdef{AbsRedBod}\n      {t \\ored t'}\n      {\\l x : A .\\ t \\ored \\l x : A.\\ t'}\n    % \\label{rule:red-abs-bod}\n    \\and\n    \\inferrule\n    % \\inferdef{AppRedFun}\n      {f \\ored f'}\n      {f\\ u \\ored f'\\ u}\n    % \\label{rule:red-app-fun}\n    \\and\n    \\inferrule\n    % \\inferdef{AppRedArg}\n      {u \\ored u'}\n      {f\\ u \\ored f\\ u'}\n    % \\label{rule:red-app-arg}\n  \\end{mathpar}\n  \\caption{One-step reduction}\n  \\label{fig:ccw-ored}\n\\end{figure}\n\n\\AP Finally, we obtain \\kl{reduction} $\\intro*\\fred$ as the reflexive\ntransitive closure of one-step reduction, see \\cref{fig:red}.\n\n\\begin{figure}[ht]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    % \\label{rule:top-red}\n    \\inferrule{ }{t \\fred t}\n    \\and\n    \\inferrule\n      {t \\ored t' \\\\ t' \\fred t''}\n      {t \\fred t''}\n  \\end{mathpar}\n  \\caption{Reduction}\n  \\label{fig:red}\n\\end{figure}\n\nWe can now get to \\kl{algorithmic conversion}: two terms\nare convertible whenever they reduce to terms that are \\kl{α-equal}.\nAs for declarative conversion,\nwe impose a typing condition on the target type. Altogether, this leads to\n\\ruleref{rule:alg-conv}. For once, we make α-equality explicit to anticipate\nits replacement by more complex relations later on.\n\n\\begin{figure}[ht]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{AlgConv}\n    {\\Gamma \\vdash T' \\ty \\uni \\\\ T \\red U \\\\ T' \\red U' \\\\ U \\alpheq U' }\n    {\\Gamma \\vdash T \\aconv T' \\ty \\uni}\n    \\label{rule:alg-conv}\n  \\end{mathpar}\n  \\caption{Algorithmic conversion}\n\\end{figure}\n\nTo wrap up this section, let us backtrack for a moment on the reason why we separated\nthe definition of reduction in three layers. This is because reduction as we defined it\nis somewhat too unconstrained.\\sidenote{In particular, it is non-deterministic.}\nIn what follows, a recurring need is that of a deterministic notion of reduction \nwhich is able to expose a canonical term former,%\n\\sidenote{This notion is formally introduced in \\cref{sec:tech-properties}.}\nif it exists.\n\\AP There is a way to do so, what is called\n\\intro{weak-head reduction} $\\intro\\hred$. It amounts to restricting the place in a term where\n\\kl{top-level reduction} can be used, by removing some congruence rules compared to reduction. More precisely, λ-abstractions, Π-types and universes are not reduced further,\nas they already are canonical forms of their types.\nVariables are not reduced either, since they simply cannot be.\nThus, the only reduction that is allowed is in the function position of an application,\nwith the hope to get a λ-abstraction there that can be further reduced using top-level reduction.\nFollowing these considerations, we arrive at \\cref{fig:wh-red}.\nWhen we want to contrast this \\kl{weak-head reduction} with the\npreviously defined one $\\mathord{\\fred}$, we call the latter \\intro{full reduction}.\n\\begin{figure}[ht]\n  \\AP \\phantomintro{\\hored}\n  \\begin{mathpar}\n    \\inferrule\n    % \\inferdef{TopRed}\n      {t \\tred t'}\n      {t \\hored t'}\n    % \\label{rule:top-red}\n    \\and\n    \\inferrule\n      {f \\hored f'}\n      {f\\ u \\hored f'\\ u}\n    \\and\n    \\inferrule{ }{t \\hred t}\n    \\label{rule:red-refl} \\and\n    \\inferrule\n      {t \\hored t' \\\\ t' \\hred t''}\n      {t \\hred t''}\n    \\label{rule:red-trans}\n  \\end{mathpar}\n  \\caption{Weak-head reduction}\n  \\label{fig:wh-red}\n\\end{figure}\n\n\\section{The Good Properties}\n\\label{sec:tech-properties}\n\nBefore going further into more definitions of type systems, we should stop and consider\nwhat makes these “good”. Designing type systems is a complex endeavour,\nand many things can go wrong. What are the properties we expect from a type\nsystem for it to give a valid notion of programming language or logic? How do we know that\na type system is well-behaved?\nLet us go over some of these properties,\nand some proof techniques that can be employed to establish them.\n\n\\subsection{Stability under basic operations}\n\nThe most essential properties of a type system are its stability\nby basic type theoretic operations.\nThe first is stability under renaming, which states that a context can be replaced by another\none which contains at least the same variables:\n\n\\begin{property}[\\intro{Stability under renaming}]\n  \\label{prop:stab-renaming}\n  Whenever the following conditions are met\n  \\begin{itemize}\n    \\item $x_1 : A_1 \\dots x_n : A_n \\vdash t \\ty T$\n    \\item $\\vdash \\Delta$\n    \\item for all $i$, there is a variable $y_i$ such that $(y_i : \\multisubs{A_i}{x_1 \\into y_1 \\dots x_n \\into y_n}) \\in \\Delta$%\n  \\end{itemize} \n  we have that $\\Delta \\vdash \\multisubs{t}{x_1 \\into y_1 \\dots x_n \\into y_n} \\ty \\multisubs{T}{x_1 \\into y_1 \\dots x_n \\into y_n}$.\n\\end{property}\n\nGiven the first premise, the context $x_1 : A_1 \\dots x_n : A_n$ must be well-formed,%\n\\sidenote{This is a consequence of \\kl{validity}, another property we are about to see.}\n$A_i$ can only depend on variables\n$x_1 \\dots x_{i-1}$, thus we do not actually need to substitute the variables\n$x_{i+1} \\dots x_n$ in it. However, this presentation, where the same substitution is applied\nto all types even if applies to variables which we know are not present in them,\nis easier to work with in practice.\n\nA direct consequence is the \\kl{weakening} property:\n\n\\begin{minipage}{\\textwidth}\n  \\begin{property}[\\intro{Weakening}]\n    \\label{prop:weakening}\n    Whenever $\\Gamma \\vdash t \\ty T$\n    and $\\Gamma \\vdash A \\ty \\uni$, it holds that $\\Gamma, x : A \\vdash t \\ty T$.\n  \\end{property}\n\\end{minipage}\n\nA stronger notion is that of stability under substitution, which allows replacing\nvariables by arbitrary terms.\n\n\\begin{minipage}{\\textwidth}\n\\begin{property}[\\intro{Stability under substitution}]\n  \\label{prop:stab-subst}\n  For any substitution $\\sigma$ (function from variables to terms)\n  such that the following hold\n  \\begin{itemize}\n    \\item $x_1 : A_1 \\dots x_n : A_n \\vdash t \\ty T$\n    \\item for all $x_i$, we have $\\Delta \\vdash \\sigma(x_i) \\ty \\multisubs{A_i}{\\sigma}$\n  \\end{itemize} \n  it is also the case that $\\Delta \\vdash \\multisubs{t}{\\sigma} \\ty \\multisubs{T}{\\sigma}$.\n\\end{property}\n\\end{minipage}\n\nThese two stability properties can be proven by direct induction on the typing derivations,\nreplacing hypotheses on the first context by hypothesis on the second. Of course, we need to\nstate and prove similar stability properties for conversion, again by induction.\n\nThere is, however, a stronger form of stability under renaming. While not as crucial as the\none above, it is still quite useful, especially to prove correctness of term manipulations,\nsuch as those operated by tactics.\n\n\\begin{property}[\\intro{Conditional stability under renaming}]\n  \\label{prop:strong-stab-renaming}\n  Whenever the following conditions are met\n  \\begin{itemize}\n    \\item $x_1 : A_1 \\dots x_n : A_n \\vdash t \\ty T$\n    \\item $\\vdash \\Delta$\n    \\item for all $i$ \\emph{such that $x_i$ appears in $t$}, there is a variable $y_i$ such that $(y_i : \\multisubs{A_i}{x_1 \\into y_1 \\dots x_n \\into y_n}) \\in \\Delta$\n  \\end{itemize} \n  there exists a type $T'$ such that $\\Delta \\vdash \\multisubs{t}{x_1 \\into y_1 \\dots x_n \\into y_n} \\ty T'$.\n\\end{property}\n\nThe difference between the two is that we do not ask for all variables appearing in $\\Gamma$\nto be present in $\\Delta$, only those that are “relevant” for $t$.\nThus, the important consequence is the following, which allows removing unused variables\nfrom a context.\n\n\\begin{property}[\\intro{Strengthening}]\n  \\label{prop:strengthening}\n  If $\\Gamma, x : A \\vdash t \\ty T$ holds and $x$ does not appear in $t$,\n  there exists $T'$ such that $\\Gamma \\vdash t \\ty T'$.\n\\end{property}\n\nStrengthening is not as easy to obtain as \\kl{weakening}, and there are some type theories\nwhere it fails \\sidecite{Haselwarter2021}.\nIn general, even if it holds – this is the case in all type theories \npresented in this thesis – it cannot be proven by a direct induction on the typing\nderivation. This is because of \\ruleref{rule:cic-conv}. Indeed, in that rule the target type\n$T'$ might very well use the variable $x$, so that we do not have in general\n$\\Gamma \\vdash T' \\ty \\uni$. Thus, there is a need for further reasoning to prove that such a\ntype is never actually needed. We show in \\cref{thm:strengthening-bidir}\nhow the bidirectional structure makes proving strengthening straightforward.\n\n\\subsection{Properties of types}\n\nA second set of properties pertain to types themselves. They are less crucial than the\nprevious ones, but assess that the types that can be obtained for a term are well-behaved,\nwhich is often useful to have in proofs of other properties of\nthe system – such as those in the rest of this section.\n\nThe first is \\kl{validity},\nwhich asserts that both types and contexts are well-formed whenever they appear in a typing\nderivation.\n\n\\begin{property}[\\intro{Validity}]\n  \\label{prop:validity}\n  Whenever $\\Gamma \\vdash t \\ty T$, we have $\\vdash \\Gamma$ and $\\Gamma \\vdash T \\ty \\uni$.\n\\end{property}\n\nWe set up \\kl{CCω} so that it satisfies this property, but another approach – which we use\nin the bidirectional setting – is to remove pre-conditions such as $\\vdash \\Gamma$ in\n\\ruleref{rule:cic-var} or $\\Gamma \\vdash T' \\ty \\uni$ in \\ruleref{rule:cic-conv-unty}.\nThis is possible, but in that case a lot of properties have to be prefixed with extra\nhypothesis of context/type well-formation.\n\nThe second property is \\kl{uniqueness of types}, which relates the different types\nof a same term.\n\n\\begin{property}[\\intro{Uniqueness of types}]\n  \\label{prop:uniqueness}\n  A type theory satisfies \\reintro{uniqueness of types up to} a relation $\\preceq$\n  if whenever $t$ is well-typed in $\\Gamma$,%\n  \\sidenote{\\textit{I.e.}\\ whenever there exists $S$ such that $\\Gamma \\vdash t \\ty S$.}\n  there exists a type $T$ such that $\\Gamma \\vdash t \\ty T$\n  and for any $T'$ such that $\\Gamma \\vdash t \\ty T'$, we have $T' \\preceq T$.\n\n  We simply say \\kl{uniqueness of types} for uniqueness up to \\kl{conversion}.\n\\end{property}\n\nNote that in the case where the relation $\\preceq$ is symmetric and transitive,\n–~in particular, \\kl{conversion} –, \\kl{uniqueness of types up to} $\\preceq$ simplifies\nto the fact that whenever $\\Gamma \\vdash t \\ty T$ and $\\Gamma \\vdash t \\ty T'$,\nwe have $T \\preceq T'$. However, in \\kl{PCUIC} we wish to replace \\kl{conversion} with\n\\kl{cumulativity}, which is not symmetric –~it is only a pre-order –,\nso the more involved definition is needed.\n\nThis property is not so easy to establish,\nbut as for \\kl{strengthening} the bidirectional setting gives a straightforward proof approach,\nsee \\cref{thm:unique-undir}.\n\n\\subsection{Subject reduction}\n\nWe already mentioned Milner’s slogan that “\\textit{Well-typed programs cannot go wrong.}”\nIn our context, this means that if a term is well-typed, its reduction –~which corresponds to\nprogram evaluation~–, should be well-behaved. This well-behaviour is separated \ninto multiple properties, the first of which is \\kl{subject reduction},\nwhich asserts that typing is preserved by reduction.\n\n\\begin{property}[\\intro{Subject reduction}]\n  \\label{prop:sr}\n  If $\\Gamma \\vdash t \\ty T$ and $t \\red t'$, then also $\\Gamma \\vdash t' \\ty T$.\n  This property is also called \\reintro{preservation}.\n\\end{property}\n\nTo show that \\kl{reduction} preserves typing, it suffices to show that \\kl{one-step reduction}\ndoes, by a simple induction. Moreover, using \\kl{stability under substitution}, this further\nreduces to \\kl{top-level reduction} preserving typing. But how do we show this?\n\nSuppose we have a β-redex such that $\\Gamma \\vdash (\\l x : A.\\ t)\\ u \\ty T$.\nAnalysing the typing\nderivation, we can conclude there exists $A'$, $B$ and $B'$ such that\n\\begin{itemize}\n  \\item $\\Gamma, x : A \\vdash t \\ty B$\n  \\item $\\P x : A.\\ B \\dconv \\P x : A'.\\ B'$\n  \\item $\\Gamma \\vdash u \\ty A'$\n  \\item $\\subs{B'}{x}{u} \\dconv T$\n\\end{itemize}\nIf we were able to conclude that $A \\dconv A'$ and $B \\dconv B'$, we could\ndeduce $\\Gamma \\vdash u \\ty A$, then using \\kl{stability under\nsubstitution} we would get $\\Gamma \\vdash \\subs{t}{x}{u} \\ty \\subs{B}{x}{u}$,\nwhich would finally lead to $\\Gamma \\vdash \\subs{t}{x}{u} \\ty T$ using stability of\nconversion under substitution and transitivity of conversion.\nThus, the key property is the following:\n\n\\begin{property}[\\intro{Injectivity of function types}]\n  \\label{prop:prod-inj}\n  Whenever $\\P x : A.\\ B \\conv \\P x : A'.\\ B'$, we have $A \\conv A'$ and $B \\conv B'$.\n\\end{property}\n\nIn the more general setting of \\kl{CIC} or \\kl{PCUIC}, we do not have only Π-types.\nThus, we more generally talk about \\reintro{injectivity of type constructors}.\n\nFor \\kl{declarative conversion}, transitivity is trivial, but \\kl{injectivity of function types}\nis not so easy. Indeed, due to transitivity we could have\n\\[\\P x : A.\\ B \\conv T_1 \\conv \\dots T_n \\conv \\P x : A'.\\ B'\\]\nwhere the $T_i$ have no reason to be Π-types,\nand so it is not so easy to relate $A$ and $A'$.\nConversely, for \\kl{algorithmic conversion}, \\kl{injectivity of function types} is rather\nstraightforward by induction on \\kl{reduction} and \\kl{α-equality}, but transitivity is\nhard to show. Thus, in both cases \\kl{subject reduction} is not direct.\nThe main missing property, which allows proving equivalence of both notions\nof \\kl{conversion}, and consequently subject reduction for either one of\nthe corresponding notions of typing, is \\kl{confluence} of reduction.\n\n\\begin{marginfigure}\n  \\[\\begin{tikzcd}\n    & t \\arrow[dl] \\arrow[dr] & \\\\\n    t_1 \\arrow[dr, dashed] && t_2 \\arrow[dl, dashed] \\\\\n    & t'' &\n  \\end{tikzcd}\\]\n  \\caption{Confluence, as a diagram}\n\\end{marginfigure}\n\n\\begin{property}[\\intro{Confluence}]\n  \\label{prop:confluence}\n  If $t \\red t_1$ and $t \\red t_2$ hold, then there exists some $t''$ such that\n  $t_1 \\red t''$ and $t_2 \\red t''$.\n\\end{property}\n\nThis is a very widely studied property in the context of rewriting systems. A nice\nproof technique relies on the definition of a notion of parallel reduction \n\\sidecite{Takahashi1995}.\n\n\\subsection{Progress}\n\n\\begin{marginfigure}\n  \\begin{mathpar}\n    % \\jform{\\nm t}\n    \\inferrule{ }{\\nm \\uni}\n    \\and\n    \\inferrule{\\nm A \\\\ \\nm B}{\\nm \\P x : A.\\ B}\n    \\and\n    \\inferrule{\\nm A \\\\ \\nm t}{\\nm \\l x : A .\\ t} \\and\n    \\inferrule{\\ne t}{\\nm t}\n    \\\\\n    % \\jform{\\ne t}\n    \\inferrule{ }{\\ne x} \\and\n    \\inferrule{\\ne f \\\\ \\nm u}{\\ne f\\ u}\n  \\end{mathpar}\n  \\caption{Normal and neutral forms}\n  \\label{fig:ccw-norm-neu}\n\\end{marginfigure}\n\n\\kl{Subject reduction} ensures that when a term reduces, this reduction is type-preserving.\nThe second important property linked to reduction characterizes which terms reduce.\nTo state it, we first need to define the $\\nm$ and $\\ne$ predicates,\ncharacterizing respectively \\intro{normal forms} and \\intro{neutral forms}.\nThe inductive rules for those are given in \\cref{fig:ccw-norm-neu}.\nThe idea is that neutral forms are those terms which are stuck on a variable, which blocks\nfurther computation because it is not a λ-abstraction. Normal forms are either neutrals\nor \\intro{canonical forms},%\n\\sidenote{Alternatively called values.}\nwhich have finished computing. For instance, a λ-abstraction is\nthe canonical form for a function. What \\kl{progress} says is that these forms accurately\ncharacterize well-typed terms which do not reduce.\n\n\\begin{minipage}{\\textwidth}\n\\begin{property}[\\intro{Progress}]\n  For every well-typed term $t$, either $\\nm t$ holds,\n  or there is some $t'$ such that $t \\ored t'$.\n\\end{property}\n\\end{minipage}\n\nTo prove progress, one can again resort to induction on the typing derivation. The key point\nis to characterize the \\kl{normal forms} at a given type,\nby proving that they are either \\kl{neutral forms}, or \\kl{canonical form}\n\\emph{of the right kind}.\nFor instance, if $f$ is a normal form and has a function type, then it must be\neither a neutral, or a λ-abstraction. Then, if $f$ is applied to $u$, then in the first\ncase $f\\ u$ is a neutral – and thus a normal form –, or it reduces further, by a β step.\n\nOne way to understand \\kl{progress} – and, indeed, the origin of the name – is that well-typed\nterms do not get stuck: either they have finished computing, and thus satisfy $\\nm$, or\nthey should be able to make progress by reducing further.\nPut together with \\kl{preservation}, progress can be iterated. Indeed,\nif a term is well-typed, it is either a normal form, or reduces to a term, which is itself\nwell-typed by \\kl{preservation}, so is either a normal form or reduces, and so on.\nThis decomposition of program safety into progress and preservation\nhas been standard since \\sidetextcite{Wright1994}.\n\n\\begin{property}[\\intro{Safety}]\n  \\kl{Safety} is the combination of \\kl{progress} and \\kl{preservation}.\n  It implies that if $\\vdash t \\ty T$ and $t \\red v \\nored$, then $v$ must be a\n  canonical form.\n\\end{property}\n\n\n\n\\subsection{Normalization}\n\nThe last important property, and one which is rather specific to type systems in the context of\nproof languages, is \\kl{normalization}. It ensures that progress cannot be applied\nforever, but that evaluation always ends up reaching a normal form.\nThe most standard way to phrase this is to say that there is no infinite reduction sequence \nstarting from a well-typed term. This formulation, however, is constructively too weak,\nso we instead use a more adequate – but classically equivalent – definition,\nusing the following accessibility predicate.\n\n\\begin{definition}[\\intro{Accessibility}]\n  Let $R$ be a relation on $A$. An inhabitant $a$ of $A$ is accessible if all $a'$\n  such that $a \\mathrel{R} a'$ are.\n\\end{definition}\n\nIn the intuitionistic setting, this way to phrase well-foundedness\nis much better behaved because it does not appeal to negation. In particular,\nwe can do constructions on all accessible terms of a given relation by means of well-founded\ninduction, something we exploit in \\kl{MetaCoq}, where this is the formulation we use for\nnormalization.\n\n\\begin{property}[\\intro{Normalization}]\n  \\label{prop:normalization}\n  Every well-typed term is \\kl{accessible} for one-step co-reduction $\\ocored$,\n  the inverse relation of \\kl{one-step reduction} $\\ored$.\n\\end{property}\n\nNormalization, combined with \\kl{progress} and \\kl{preservation}, \nentails that any well-typed term\neventually reduces to a normal form – which is moreover unique, by \\kl{confluence}.\nThis gives a naive way to decide conversion. Even if one uses a more complex strategy,\nnormalization is a crucial building block towards decidability of typing.\nThus, it is a property of prime importance if we wish to\nimplement a type-checker for dependent types.\n\nAnother key consequence, of normalization is that,\nthere are some uninhabited types in the empty context,\nfor instance $\\P A : \\uni.\\ A$.\nThis is one way to phrase \\kl{logical consistency},%\n\\sidenote{Thanks to the principle of explosion.}\nwhich has the advantage that it does not put forward one particular “false” type.\n\n\\begin{property}[\\intro{Logical consistency}]\n  \\label{prop:log-cons}\n  There is a type which is not inhabited in the empty context.\n\\end{property}\n\n\\AP\nIndeed, there are no normal forms in the empty context at that type, and since any term\nof that type must reduce to such a normal form, there are none.\nThus, normalization ensures our type systems are meaningful as logics,\nwhich we of course care about!\n\nMore generally, normalization entails the \\kl{canonicity} property for \\intro{closed terms}\n\\sidenote{Terms which are not closed are called \\reintro{open}.}\n– \\eg those that have no free variables, or, equivalently, that are well-typed in the empty\ncontext.\n\n\\begin{property}[\\intro{Canonicity}]\n  \\label{prop:canonicity}\n  Every term $t$ that is well-typed in the empty context reduces to a \\kl{canonical form}.\n\\end{property}\n\nThere is however an issue here: since normalization entails logical consistency, it is a hard\nproperty to prove. In particular, due to Gödel’s incompleteness theorem, we cannot hope\nto prove normalization of a type system in the logic given by that system itself…\nStill, there are multiple approaches to proving normalization, from the venerable\nreducibility method \\sidecite{Tait1967} to the recent normalization by evaluation \ntechniques \\sidecite{Abel2013a}. However, due to their complex character, \nwe do not tackle such proofs of normalization directly in this thesis. Instead, we\neither suppose normalization when it is unavoidable,\nor prove it relatively to that of another, simpler theory.\n\n\\section{Adding Inductive Types: \\kl(tit){CIC}}\n\\label{sec:tech-cic}\n\n\\AP Of course, not everything in mathematics or programming is a function.\nAlthough \\kl{CCω} is powerful enough to encode many constructions,%\n\\sidenote{At least if one extends its universe hierarchy with an impredicative\nuniverse.}\nsuch encodings are not fully satisfactory: \\sidetextcite{Geuvers2001} shows\nthat it is impossible to construct%\n\\sidenote{In a system close to our \\kl{CCω}, but again with an impredicative universe.}\nan encoding of natural numbers satisfying an induction principle,\nwhich is their defining characteristic!\nBecause of such limitations of encodings, and in order to faithfully\nrepresent the use of induction in mathematics and pattern-matching in programming languages,\nthe general class of \\intro{inductive types} has been introduced\nby \\sidetextcite{PaulinMohring1993}.%\n\\sidenote{\n  Earlier type theories, such as \\cite{MartinLoef1972,MartinLoef1984}, presented specific\n  instances of that class, but not a general scheme.\n}%\n\\margincite{MartinLoef1972,MartinLoef1984}\nAdding these to \\kl{CCω} results in \\intro{CIC},\nthe \\intro{Calculus of Inductive Constructions}.\n\n\\subsection{Booleans}\n\\FloatBarrier\n\n\\begin{marginfigure}\n  \\ContinuedFloat*\n  \\begin{mathpar}\n    \\inferdef{BoolTy}{\\vdash \\Gamma}{\\Gamma \\vdash \\Bool \\ty \\uni[0]}\n    \\label{rule:bool-type} \\and\n  \\end{mathpar}\n  \\caption{The type of booleans}\n  \\label{fig:bool-type}\n\\end{marginfigure}\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{False}{\\vdash \\Gamma}{\\Gamma \\vdash \\false \\ty \\Bool}\n    \\label{rule:false} \\and\n    \\inferdef{True}{\\vdash \\Gamma}{\\Gamma \\vdash \\true \\ty \\Bool}\n    \\label{rule:true}\n  \\end{mathpar}\n  \\caption{The boolean constructors}\n  \\label{fig:bool-cons}\n\\end{marginfigure}\n\n\\AP Let us start with a very simple example: \\intro{booleans}.\nTo add those to \\kl{CCω}, we need to specify three new kinds of term formers.\nThe first is the type, that we write $\\intro*\\Bool$ – see \\ruleref{rule:bool-type}.\nNext we need \\intro{constructors}, giving the canonical inhabitants of the type.\nIn the case of booleans, there are two of them: the false boolean $\\intro*\\false$\nand the true one $\\intro*\\true$ – this is Rules~\\nameref{rule:false} and \\nameref{rule:true}.\n\nThe last one is a way to use those canonical inhabitants.\nFor booleans, this corresponds to a conditional,\ntaking one branch or another depending on the value of the term being used,\nwhose typing rule is given in \\ruleref{rule:bool-ind}.\nWe call $s$ the \\intro{scrutinee}, $P$ the \\reintro{predicate}\nand $b_{\\false}$, $b_{\\true}$ the \\reintro{branches}.\nAs was the case for dependent functions, here also there is a generalization with respect to\nusual programming languages: the predicate type itself can depend on the\n\\kl{scrutinee}.\nThe usual if-then-else conditional thus corresponds to the special case\nwhen $P$ does not depend on the variable $z$.\n\\AP We call this $\\intro*\\indop$ term former \\intro{induction principle}, as\none can read $\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}$ as case distinction\non the scrutinee:\nto prove that $P$ holds for an arbitrary boolean $s$, it suffices to show that both\n$\\subs{P}{z}{\\false}$ and $\\subs{P}{z}{\\true}$ do – these are respectively proven by\n$b_{\\false}$ and $b_{\\true}$. The name induction is not really\nsuitable here because we only have base cases and no induction step, but we get those\nas soon as the inductive type itself is recursive.\nWe also use the name \\reintro{recursor} interchangeably with induction principle,\nbut especially when we want to emphasize the programming point of view.\n\n\\begin{figure}[h]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{BoolInd}\n      {\\Gamma \\vdash s \\ty \\Bool \\\\\n      \\Gamma, z : \\Bool \\vdash P \\ty \\uni \\\\\n      \\Gamma \\vdash b_{\\false} \\ty \\subs{P}{z}{\\false} \\\\\n      \\Gamma \\vdash b_{\\true} \\ty \\subs{P}{z}{\\true}}\n      {\\Gamma \\vdash \\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}} \\ty \\subs{P}{z}{s}}\n      \\label{rule:bool-ind}\n  \\end{mathpar}\n  \\caption{Induction principle for booleans}\n  \\label{fig:bool-typ}\n\\end{figure}\n\n\\begin{marginfigure}[1em]\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{ιFalse}\n    { }\n    {\\ind{\\Bool}{\\false}{z.P}{b_{\\false},b_{\\true}} \\tred b_{\\false}} \\and\n    \\inferdef{ιTrue}\n    { }\n    {\\ind{\\Bool}{\\true}{z.P}{b_{\\false},b_{\\true}} \\tred b_{\\true}}\n  \\end{mathpar}\n  \\caption{\\kl{Top-level reduction} for booleans (ι-reduction)}\n  \\label{fig:bool-red}\n\\end{marginfigure}\n\nOne thing is still missing in this picture: computation. The extension of\n\\kl{top-level reduction} is given in \\cref{fig:bool-red} – our first example of\nι-reduction, the reduction of recursors on \\kl{constructors}.\nThese rules pick the branch corresponding to the scrutinee,\nwhich is sensible if $\\indop_{\\Bool}$ is understood as a conditional.\n\\kl{Declarative conversion} can be extended in exactly the same way.\nFinally, to account for the arguments of the newly introduced term former $\\indop_{\\Bool}$,\nwe need to add new congruence rules, see \\cref{fig:bool-cong}.\nFor \\kl{one-step reduction} and \\kl{declarative conversion},\nthere is no subtlety, all positions behave the same. The interesting rule is the\none for \\kl{weak-head reduction}: there is only one congruence rule, which allows for\nreduction of the scrutinee. This is similar to functions, where we allow reduction only in the\nposition in the term that triggers a computation if it is a canonical form – in the case\nof $\\indop$, the scrutinee.\n\n\\begin{figure*}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferrule\n    {s \\dconv s' \\\\ P \\dconv P' \\\\ b_{\\false} \\dconv b'_{\\false} \\\\ b_{\\true} \\dconv b'_{\\true}}\n    {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n      \\dconv \\ind{\\Bool}{s'}{z.P'}{b'_{\\false},b'_{\\true}}} \\and\n    \\inferrule\n    {s \\ored s'}\n      {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n        \\ored \\ind{\\Bool}{s'}{z.P}{b_{\\false},b_{\\true}}} \\and\n    \\inferrule\n    {P \\ored P'}\n      {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n        \\ored \\ind{\\Bool}{s}{z.P'}{b_{\\false},b_{\\true}}} \\and\n    \\inferrule\n    {b_{\\false} \\ored b'_{\\false}}\n      {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n        \\ored \\ind{\\Bool}{s}{z.P}{b'_{\\false},b_{\\true}}} \\and \n    \\inferrule\n    {b_{\\true} \\ored b'_{\\true}}\n      {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n        \\ored \\ind{\\Bool}{s}{z.P}{b_{\\false},b'_{\\true}}} \\and\n    \\inferrule\n    {s \\hored s'}\n      {\\ind{\\Bool}{s}{z.P}{b_{\\false},b_{\\true}}\n        \\hored \\ind{\\Bool}{s'}{z.P}{b_{\\false},b_{\\true}}} \\and\n  \\end{mathpar}\n\n  \\caption{Congruence rules for booleans}\n  \\label{fig:bool-cong}\n\\end{figure*}\n\n\n\\subsection{Recursion}\n\n\\begin{figure}[h]\n  \\AP\n  \\begin{mathpar}\n    \\inferdef{Nat}{\\vdash \\Gamma}{\\Gamma \\vdash \\intro*\\Nat \\ty \\uni[0]}\n    \\label{rule:nat-type} \\and\n    \\inferdef{Zero}{\\vdash \\Gamma}{\\Gamma \\vdash \\intro*\\z \\ty \\Nat}\n    \\label{rule:zero-type} \\and\n    \\inferdef{Succ}{\\Gamma \\vdash n \\ty \\Nat}{\\Gamma \\vdash \\intro*\\S{n} \\ty \\Nat}\n    \\label{rule:succ-type} \\and\n    \\inferdef{NatInd}\n      {\\Gamma \\vdash s \\ty \\Nat \\\\\n      \\Gamma, z : \\Nat \\vdash P \\ty \\uni \\\\\n      \\Gamma \\vdash b_{\\z} \\ty \\subs{P}{z}{\\z} \\\\\n      \\Gamma, y : \\Nat, p_{y} : \\subs{P}{z}{y} \\vdash b_{\\Sop} \\ty \\subs{P}{z}{\\S{y}}}\n      {\\Gamma \\vdash \\ind{\\Nat}{s}{z.P}{b_{\\z},y.p_{y}.b_{\\Sop}} \\ty \\subs{P}{z}{s}}\n    \\label{rule:nat-ind} \\and\n    \\inferdef{ιZero}\n    { }\n    {\\ind{\\Nat}{\\z}{z.P}{b_{\\z},y.p_{y}.b_{\\Sop}} \\tred b_{\\z}} \n    \\label{rule:iota-zero} \\and\n    \\inferdef{ιSucc}\n    { }\n    {\\ind{\\Nat}{\\S{n}}{z.P}{b_{\\z},y.p_{y}.b_{\\Sop}} \\tred\\\\\n      \\multisubs{b_{\\Sop}}{y \\into n, p_{y} \\into \\ind{\\Nat}{n}{z.P}{b_{\\z},y.p_{y}.b_{\\Sop}}}}\n    \\label{rule:iota-succ}\n  \\end{mathpar}\n  \\caption{Natural numbers}\n  \\label{fig:nat}\n\\end{figure}\n\nBooleans are very simple, but we of course want more. The first thing to add is recursion.\nThe simplest example is that of natural numbers, given in \\cref{fig:nat}.\nThe rules are more verbose than those for booleans, but the general idea is very similar:\n\\ruleref{rule:nat-type} introduces a new type, \\ruleref{rule:zero-type}\nand \\ruleref{rule:succ-type} its constructors, and \\ruleref{rule:nat-ind} its induction\nprinciple. This time said induction principle is a real one, as we can see in\nthe second branch, where an induction hypothesis $p_{y}$ on the predecessor $y$ is available.\nSimilarly to booleans, the induction principle reduces when its scrutinee is a constructor.\nBut, again, since we have real recursion,\na recursive call appears in the reduct of \\ruleref{rule:iota-succ}.\nWe do not repeat the congruence rules, as they are similar to those for booleans\n(\\cref{fig:bool-cong}). The only difference is that now there is also a need for congruence\nrules for the term former $\\Sop$, since it has a sub-term.\n\nAt this point, it might be good to add a note on the way we represent \\kl{constructors}:\nwe enforce them to be \\intro{fully applied}, meaning $\\Sop$ does not make sense on its own\nas a term. \\kl{Coq} is slightly more permissive, and allows $\\Sop \\ty \\Nat \\to \\Nat$.\nWe forbid this, but one can always consider $\\l x : \\Nat.\\ \\S{x}$ instead if needed.\nLikewise, inductive types are also enforced to be fully applied.\nWe also avoid using the $\\P$ and $\\l$ term formers to represent binding in the predicate\nand branches of constructors, rather using contexts directly.\nThis allows for a clear separation\nof concerns, by reducing interactions between the functional fragment and\ninductive types. \\kl{Coq}'s kernel used to rely on $\\P$ and $\\l$ abstractions to represent\npredicates and branches, but a version close to our presentation has recently replaced it,%\n\\sidenote{The exact change is documented by pull-request \\coqPR{13563}.}\nin part due to concerns raised while working on this thesis, that are detailed in\n\\cref{sec:bidir-pcuic-inductives}.\n\n\\subsection{Parameters}\n\n\\begin{figure}\n  \\AP\n  \\begin{mathpar}\n    \\inferdef{PairTy}\n      {\\vdash A \\ty \\uni[i] \\\\ \\Gamma, x : A \\vdash B \\ty \\uni[j]}\n      {\\Gamma \\vdash \\Sb x : A.\\ B \\ty \\uni[\\umax{i}{j}]}\n    \\label{rule:sig-type} \\and\n    \\inferdef{Pair}\n    {\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma, x : A \\vdash B \\ty \\uni \\\\\n    \\Gamma \\vdash t \\ty A \\\\ \\Gamma \\vdash u \\ty \\subs{B}{x}{t}}\n    {\\Gamma \\vdash \\intro*\\pair[A][x.B]{t}{u} \\ty \\Sb x : A.\\ B}\n    \\label{rule:pair-type} \\and\n    \\inferdef{PairInd}\n      {\\Gamma \\vdash s \\ty \\Sb x : A.\\ B \\\\\n      \\Gamma, z : \\Sb x : A.\\ B \\vdash P \\ty \\uni \\\\\n      \\Gamma, y_1 : A, y_2 : \\subs{B}{x}{y_1} \\vdash b \\ty \\subs{P}{z}{\\pair[A][x.B]{y_1}{y_2}}}\n      {\\Gamma \\vdash \\ind{\\Sb}{s}{z.P}{y_1.y_2.b} \\ty \\subs{P}{z}{s}}\n      \\label{rule:sig-ind} \\and\n    \\inferdef{ιPair}\n    { }\n    {\\ind{\\Sb}{\\pair[A][x.B]{t}{u}}{z.P}{y_1.y_2.b} \\tred \\multisubs{b}{y_1 \\into t, y_2 \\into u}} \n    \\label{rule:iota-sig}\n  \\end{mathpar}\n  \\caption{Inductive dependent pair type}\n  \\label{fig:sig}\n\\end{figure}\n\n\\AP A second direction for enhancement is the ability to have inductive types with parameters.\nThe main use of this is for type operators, that is types that take other types as\narguments, for instance the pair type $A \\times B$\nof \\cref{chap:intro-en}. As is probably not very surprising by\nnow, this type is a restricted instance of a more general type, the\ndependent pair type $\\intro*\\Sb x : A.\\ B$.\nLogically, its dependency on $A$ means that if we see $B$ as a property,\nthe whole pair type describes a subset of $A$ – those elements\nwhich validate $B$. The rules are given in \\cref{fig:sig}.\nSimilarly to functions, we need an annotation on\nthe pair constructor, for the exact same reason: we want to ensure that any term can\ninfer a type. We also omit congruence rules, as they are again similar to those of\n\\cref{fig:bool-cong}, although now not only the pair constructor but also the type constructor\n$\\Sb$ get their congruence rules, since both have sub-terms.\n\n\\begin{figure}\n\\begin{mathpar}\n  \\inferdef{ListTy}\n    {\\vdash A \\ty \\uni[i]}\n    {\\Gamma \\vdash \\List(A) \\ty \\uni[i]}\n  \\label{rule:list-type} \\and\n  \\inferdef{Nil}\n    {\\Gamma \\vdash A \\ty \\uni}\n    {\\Gamma \\vdash \\intro*\\lnil[A] \\ty \\List(A)}\n  \\label{rule:nil-type} \\and\n  \\inferdef{Cons}\n    {\\Gamma \\vdash A \\ty \\uni \\\\ \n    \\Gamma \\vdash a \\ty A \\\\ \\Gamma \\vdash l \\ty \\List(A)}\n    {\\Gamma \\vdash \\intro*\\lcons[A]{a}{l} \\ty \\List(A)}\n  \\label{rule:cons-type} \\and\n  \\inferdef{ListInd}\n    {\\Gamma \\vdash s \\ty \\List(A) \\\\\n    \\Gamma, z : \\List(A) \\vdash P \\ty \\uni \\\\\n    \\Gamma \\vdash b_{\\lnil} \\ty \\subs{P}{z}{\\lnil} \\\\\n    \\Gamma, y_1 : A, y_2 : \\List(A), p_{y_2} : \\subs{P}{z}{y_2}\n      \\vdash b_{\\lconsop} \\ty \\subs{P}{z}{\\lcons[A]{y_1}{y_2}}}\n    {\\Gamma \\vdash \\ind{\\List}{s}{z.P}{b_{\\lnil},y_1.y_2.p_{y_2}.b_{\\lconsop}}\n      \\ty \\subs{P}{z}{s}}\n  \\label{rule:list-ind} \\and\n  \\inferdef{ιNil}\n    { }\n    {\\ind{\\List}{\\lnil[A]}{z.P}{b_{\\lnil},y_1.y_2.p_{y_2}.b_{\\lconsop}} \\tred b_{\\lnil}} \n  \\label{rule:iota-nil} \\and\n  \\inferdef{ιCons}\n    { }\n    {\\ind{\\List}{\\lcons[A]{a}{l}}{z.P}{b_{\\lnil},y_1.y_2.p_{y_2}.b_{\\lconsop}} \\tred \\\\\n      \\multisubs{b_{\\lconsop}}{y_1 \\into a, y_2 \\into l, p_{y_2} \\into \\ind{\\List}{l}{z.P}{b_{\\lnil},y_1.y_2.p_{y_2}.b_{\\lconsop}}}}\n  \\label{rule:iota-cons}\n\\end{mathpar}\n\\caption{List type}\n\\label{fig:list}\n\\end{figure}\n\n\\AP As an example which combines both recursion and parameters, we have the polymorphic list\ntype $\\intro*\\List$, which mainly combines what\nwe already covered for natural numbers and pairs. The typing and reduction rules are\ngiven in \\cref{fig:list}.\n\n% Inductive types using recursion and parameters we call \\intro{datatypes},\n% as they roughly correspond to what one can find in usual programming languages.\n% For instance, they are closely related to the algebraic types of the \\kl{OCaml} language.\n\n\\subsection{Indices}\n\nThere is one feature missing in the previous inductive types. Indeed, in all of them\nthe return types of constructors are always the same. In some way, they do not exploit\nthe real possibilities of dependent types. What if we wanted constructors\nto specify that they inhabit a type at some specific value? This is exactly the point of\n\\intro{indexed inductive types}.\n\n\\begin{figure}\n  \\AP\n  \\begin{mathpar}\n  \\inferdef{EqType}\n    {\\Gamma \\vdash A \\ty \\uni[i] \\\\ \\Gamma \\vdash a \\ty A \\\\ \\Gamma \\vdash a' \\ty A}\n    {\\Gamma \\vdash \\intro*\\eqty[A]{a}{a'} \\ty \\uni[i]}\n  \\label{rule:eq-type}\n  \\and\n  \\inferdef{EqRefl}\n    {\\Gamma \\vdash A \\ty \\uni[i] \\\\ \\Gamma \\vdash a \\ty A}\n    {\\Gamma \\vdash \\intro*\\refl[A][a] \\ty \\eqty[A]{a}{a}}\n  \\label{rule:eq-refl}\n  \\and\n  \\inferdef{EqInd}\n    {\\Gamma \\vdash s \\ty \\eqty[A]{a}{a'} \\\\\n    \\Gamma, y : A, z : \\eqty[A]{a}{y} \\vdash P \\ty \\uni \\\\\n    \\Gamma \\vdash b \\ty \\multisubs{P}{y \\into a, z \\into \\refl[A][a]}}\n    {\\Gamma \\vdash \\ind{\\eqtyop}{s}{y.z.P}{b} \\ty \\multisubs{P}{y \\into a', z \\into s}}\n  \\label{rule:eq-ind} \\and\n  \\inferdef{ιEq}\n    { }\n    {\\ind{\\eqtyop}{\\refl[A][a]}{y.z.P}{b} \\tred b}\n  \\label{rule:eq-iota}\n  \\end{mathpar}\n  \\caption{Equality type}\n  \\label{fig:eq-type}\n\\end{figure}\n\nThe paradigmatic example here is (propositional) equality, an\ninductive meant to represent equality \\emph{internally} to the logic, \\ie as a notion on\nwhich one can reason – for instance, do proofs by induction –,\nrather than an external one such as \\kl{conversion}.\nRules for equality are given in \\cref{fig:eq-type}. \\ruleref{rule:eq-type} does not depart\nmuch from what we have already seen,\napart from the fact that it takes not only a type as a parameter, but\nalso a term. \\ruleref{rule:eq-refl} is already more interesting. Here we can see that\nthe second argument of type $A$ is fixed to be $a$ by the constructor. This gets\nmore visible in \\ruleref{rule:eq-ind}: in order for the branch $b$\nto be typeable, the predicate needs to be abstracted not only on the scrutinee,\nbut also on that second argument. Such arguments to an inductive type,\nwhose value depends on the constructor and need to be abstracted over in branches,\nare called \\reintro{indices}. By contrast, the other arguments that behave uniformly\nare called parameters.\n\nAs for the logical interpretation, in the simplified case where $P$ only depends on the index,\n\\ruleref{rule:eq-ind} corresponds to the idea that equal terms should be indiscernible:\nwhenever both $\\eqty[A]{a}{a'}$ and $\\subs{P}{y}{a}$ hold, then so does $\\subs{P}{y}{a'}$.\nIn words, every property true of $a$ is also true of $a'$. Paired with the power of\ndependent types this presentation of equality gives rise to a very rich theory, and\nforms the basis for the whole line of research in Homotopy Type Theory \\sidecite{UniFoundationsProgram2013}.\n\nHowever, in the context of bare \\kl{CIC}, this richness is also\na curse, and indexed inductive types can be very tricky to handle. In particular, the\nwork of \\arefpart{gradual} does not extend well to generic indexed inductive types.\nThere is, however, a somewhat simpler kind of indexed inductive types, where the indices are\nnot any term of any arbitrary type – as in the case of equality –,\nbut inhabitants of an inductive type.\nSuch a case is easier to handle, and is often sufficient, especially for\ndependently-typed programming. The prototypical example here is that of vectors, which\nwe have already encountered in \\cref{chap:intro-en}, and is described in\ndetail in \\cref{fig:vect}. They are similar to\nlists, but with a natural number index which records the length of the vector in its type.\nThis allows for finely-grained specification, for instance a head function that takes as input \na vector of length at least one, and is thus ensured to never fail on an empty vector\nby mere virtue of typing.\n\n\\begin{figure*}\n  \\AP\n  \\begin{mathpar}\n    \\inferdef{VectType}\n      {\\vdash A \\ty \\uni[i] \\\\ \\vdash n \\ty \\Nat}\n      {\\Gamma \\vdash \\intro*\\Vect(A,n) \\ty \\uni[i]}\n    \\label{rule:vect-type} \\and\n    \\inferdef{Vnil}\n      {\\Gamma \\vdash A \\ty \\uni}\n      {\\Gamma \\vdash \\intro*\\vnil[A] \\ty \\Vect(A,\\z)}\n    \\label{rule:vnil-type} \\and\n    \\inferdef{Vcons}\n      {\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma \\vdash n \\ty \\Nat \\\\\n      \\Gamma \\vdash a \\ty A \\\\ \\Gamma \\vdash l \\ty \\Vect(A,n)}\n      {\\Gamma \\vdash \\intro*\\vcons[A][n]{a}{l} \\ty \\Vect(A,\\S n)}\n    \\label{rule:vcons-type} \\and\n    \\inferdef{VectInd}\n      {\\Gamma \\vdash s \\ty \\Vect(A,n) \\\\\n      \\Gamma, y : \\Nat, z : \\Vect(A,y) \\vdash P \\ty \\uni \\\\\n      \\Gamma \\vdash b_{\\vnil} \\ty \\multisubs{P}{y \\into \\z, z \\into \\vnil} \\\\\n      \\Gamma, y_1 : \\Nat, y_2 : A, y_3 : \\Vect(A,y_1), p_{y_3} \\ty \\multisubs{P}{y \\into y_1, z \\into y_3} \\vdash\n        b_{\\vconsop} \\ty \\multisubs{P}{y \\into \\S{y_1}, z \\into \\vcons[A][y_1]{y_2}{y_3}}}\n      {\\Gamma \\vdash \\ind{\\Vect}{s}{y.z.P}{b_{\\vnil},y_1.y_2.y_3.p_{y_3}.b_{\\vconsop}}\n        \\ty \\multisubs{P}{y \\into n, z \\into s}}\n    \\label{rule:vect-ind} \\and\n    \\inferdef{ιVnil}\n      { }\n      {\\ind{\\Vect}{\\vnil[A]}{y.z.P}{b_{\\vnil},y_1.y_2.y_3.p_{y_3}.b_{\\vconsop}}\n        \\tred b_{\\lnil}} \n    \\label{rule:iota-vnil} \\and\n    \\inferdef{ιVcons}\n      { }\n      {\\ind{\\Vect}{\\vcons[A][n]{a}{l}}{y.z.P}{b_{\\vnil},y_1.y_2.y_3.p_{y_3}.b_{\\vconsop}} \\tred \\\\\n        \\multisubs{b_{\\vconsop}}{y_1 \\into n, y_2 \\into a, y_3 \\into l, p_{y_3} \\into \\ind{\\Nat}{l}{z.P}{b_{\\lnil},y_1.y_2.y_3.p_{y_3}.b_{\\vconsop}}}}\n    \\label{rule:iota-vcons}\n  \\end{mathpar}\n  \\caption{Vector type}\n  \\label{fig:vect}\n  \\end{figure*}\n\n\\subsection{The \\kl(tit){Calculus of Constructions}}\n\nSo far we only gave examples of the inductive types one could wish for.\nA description of how to generally define inductive types and construct induction principles\nin a way that keeps the good properties of the system would not\nvery enlightening at this point. Let us simply say that the main restriction – barring typing\nconstraints – is to ensure, through a criterion called (strict) positivity,\nthat the recursive structure of the inductive type\nis well-founded, so that positing its existence does not endanger \\kl{normalization} or\n\\kl(log){consistency}.\n\nOn paper, rather than a difficult to read general presentation we reuse the previous\nset of examples to show how our setting adapts to inductive types in their\nthree main complexities – recursion, parameters and indices.\nBut the formalization in \\kl{MetaCoq} handles the general case,\nin the even more complex setting of \\kl{PCUIC} as presented in \\cref{sec:tech-pcuic}.\n\nIn the end, when we talk about \\kl{CIC} we mean the extension of \\kl{CCω} with any number of\ninductive types, valid in the previous sense.\nAs already explained, in \\arefpart{gradual} we need to restrict to\nnon-indexed inductive types. In that setting, our base system is \\intro{CIC-},\nthe restriction of \\kl{CIC} to exclude \\kl{indexed inductive types}.\n\n\\section{Beyond \\kl(tit){CIC}: \\kl(tit){PCUIC}}\n\\label{sec:tech-pcuic}\n\n\\kl{CIC} as described in the previous section is already very expressive and powerful.\nIt is nevertheless\nstill far from a “real-world” type theory such as that implemented in \\kl{Coq} and\nformalized in \\kl{MetaCoq}, the \\intro{Polymorphic, Cumulative Calculus of Inductive Constructions} (\\intro{PCUIC}),\nwhich extends \\kl{CIC} with many features which are crucial for usability. \nAs some additions of \\kl{PCUIC} are discussed throughout this\nthesis, we wish to already give a high level idea of them,\nwhile reserving the technical details for \\arefpart{metacoq}.\n\n\\subsection{Cumulativity}\n\nThe first addition of \\kl{PCUIC} is \\kl{cumulativity}, which allows some extra flexibility\nwith universe levels. \nTo see why this is useful, consider the polymorphic identity function\n$\\l (A : \\uni[i]) (x : A).\\ x$, of type $\\P A : \\uni[i] .\\ A \\to A$.\nIf we want to use it at type $\\Nat$, we must force $i$ to be $\\z$. But this means that we\ncannot use it later on at type $\\uni[0]$! In a concrete system, where a huge number of\nuniverse levels appear under the hood, this would quickly become unhandy.\n\n\\AP Instead, \\intro{cumulativity} – written $\\intro*\\cum$ – is an extension of conversion\nwith a limited form of subtyping,\ngenerated by the inclusion of a universe $\\uni[i]$ in any larger universe $\\uni[j]$.\nThis means that while $\\uni[i] \\conv \\uni[j]$ is true only if $i = j$, cumulativity\nallows for $\\uni[i] \\cum \\uni[j]$ as soon as $i \\leq j$.\nThis subtyping can be extended to function types,\nby allowing $\\P x : A.\\ B \\cum \\P x : A'.\\ B$ whenever $A \\conv A'$ and $B \\cum B'$.\nNote that contrarily to other forms of subtyping, this does not allow for contravariant\nsubtyping on the domain – that would correspond to $A' \\cum A$ –, only for equivariant\none – the domains should be convertible. This is because cumulativity is usually modelled\nusing set inclusion \\sidecite{Lee2011}, which straightforwardly handles equivariant\nsubtyping, but not so easily contravariant subtyping.\n\n\\begin{figure}[h]\n  \\begin{mathpar}\n    \\inferdef{UnivCum}{i \\leq j}{\\uni[i] \\cum \\uni[j]} \\label{rule:univ-cum} \\and\n    \\inferdef{ΠCum}{A \\conv A' \\\\ B \\cum B'}{\\P x : A.\\ B \\cum \\P x : A'.\\ B'}\n      \\label{rule:prod-cum} \\and\n    \\inferdef{ConvCum}{A \\conv A'}{A \\cum A'} \\label{rule:conv-cum} \\and\n    \\inferdef{Refl}{ }{A \\cum A} \\label{rule:cum-refl} \\and\n    \\inferdef{Trans}{A \\cum A' \\\\ A' \\cum A''}{A \\cum A''} \\label{rule:cum-trans} \\and\n    \\inferdef{UCum}{\\Gamma \\vdash T' \\ty \\uni \\\\ T \\cum T'}{\\Gamma \\vdash T \\cum T' \\ty \\uni}\n      \\label{rule:cic-ucum} \\and\n    \\inferdef{Cum}{\\Gamma \\vdash t \\ty T \\\\ \\Gamma \\vdash T \\cum T' \\ty \\uni}\n    {\\Gamma \\vdash t \\ty T'}\n      \\label{rule:cic-cum}\n  \\end{mathpar}\n  \\caption{Rules for declarative cumulativity}\n  \\label{fig:tech-cumul}\n\\end{figure}\n\nTo adapt the definitions of \\kl{declarative conversion} to cumulativity,\nthe three important rules are given in \\cref{fig:tech-cumul}.\nThe first two rules are the ones we already hinted at:\n\\ruleref{rule:univ-cum} is the base case for cumulativity, and \\ruleref{rule:prod-cum}\nis the relaxed congruence rule for Π-types. The next one, \\ruleref{rule:conv-cum}, allows\nto turn any proof of conversion in a cumulativity one, effectively describing how cumulativity\nbehaves outside the fragment formed by Π-types and universes. \nNext come Rules \\nameref{rule:cum-refl} and \\nameref{rule:cum-trans}, which assert that cumulativity\nis a pre-order. Of course there is no rule for symmetry,\nbecause we do not want cumulativity to be an equivalence relation.\nFinally, Rules \\nameref{rule:cic-ucum} and \\nameref{rule:cic-cum} show how\ncumulativity is used: it simply replaces conversion.\n\n\\AP\nAs for \\kl{algorithmic conversion}, the important modification is to replace \\kl{α-equality}\nwith an \\intro{α-pre-order} $\\alphleq$, which extends the former with a rule corresponding to\n\\ruleref{rule:univ-cum}: $t \\alphleq t'$ means that $t$ and $t'$ have the exact\nsame structure, up to variable names and universe levels, that might be lower in $t$ compared\nto $t'$.\n\n\\subsection{The sort of propositions}\n\nA second addition in \\kl{PCUIC}, and one that has been a distinctive feature of \\kl{Coq}\nfor a very long time – it is already present in \\sidetextcite{Coquand1988} –\nis the sort $\\intro*\\Prop$.\nThis is a universe, like $\\uni[i]$, but it is designed to\nbe a type for propositions – hence the name. It has two main distinctive characteristics.\n\n\\begin{marginfigure}\n  \\begin{mathpar}\n    \\inferdef{Prop}{\\vdash \\Gamma}{\\Gamma \\vdash \\Prop \\ty \\uni[0]}\n    \\label{rule:cic-prop} \\and\n    \\inferdef{ΠTyProp}{\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma, x : A \\vdash P \\ty \\Prop}\n    {\\Gamma \\vdash \\P x : A.\\ P \\ty \\Prop}\n    \\label{rule:prop-prod} \\and\n    \\inferdef{ΠPropProp}{\\Gamma \\vdash A \\ty \\Prop \\\\ \\Gamma, x : A \\vdash P \\ty \\Prop}\n    {\\Gamma \\vdash \\P x : A.\\ P \\ty \\Prop}\n    \\label{rule:prop-prop-prod}\n  \\end{mathpar}\n  \\caption{Typing rules for propositions}\n  \\label{fig:cic-prop}\n\\end{marginfigure}\n\n\\AP The first one is its \\intro{impredicativity}, meaning that while $\\Prop$ is at the bottom\nof the universe hierarchy (\\ruleref{rule:cic-prop}), any quantification with a proposition\nas codomain is again a proposition (Rules \\nameref{rule:prop-prod} and \\nameref{rule:prop-prop-prod}).\nThis means that propositions are able to formalize properties of types at any level.\nDue to this impredicative nature, having such a sort of propositions makes the system\nmuch more powerful as a logic, which also makes it much harder to build models of it.\nIndeed, those usually prove consistency of the modelled system,\nsomething which requires having an even higher logical strength than it.\nSince parts of this thesis – especially \\arefpart{gradual} – use such models that do not\nscale to an impredicative sort of proposition,\nwe refrain from including one in our standard \\kl{CIC}. In the other cases, including a sort of\npropositions makes the system more complex but without raising new interesting questions.\n\n\\AP The second defining characteristic of $\\Prop$ is \\intro{proof irrelevance}.\nThis means that \\kl{PCUIC} has a criterion, called singleton elimination, which maintains\na form of segregation between terms inhabiting types in $\\uni$ and\nthose inhabiting types in $\\Prop$, ensuring that terms of the first kind cannot\ndepend in a relevant way on terms of the second.\nFor instance, if $P \\ty \\Prop$, it ensures that it is impossible\nto build a function $f \\ty P \\to \\Bool$ and two terms $p_1 \\ty P$ and $p_2 \\ty P$ such that\n$f\\ p_1 \\conv \\false$ and $f\\ p_2 \\conv \\true$. This segregation aims at allowing separation\nbetween the part of the system that should be seen as programs and that which should be\nseen as proofs, so that it is possible to write programs decorated with\ncomplex correctness proofs, while later on erasing all the\nlogical content to keep only the computational content of the program.\nThis is the erasure procedure we introduced in \\cref{sec:intro-metacoq-en},\nfor which $\\Prop$ is crucial.\n\n\\subsection{Local definitions}\n\nIt is often useful to locally introduce a shorthand to be used repeatedly, and\nthis is what \\kl{PCUIC} allows with a new term former,\n\\intro{local definitions} $\\letin{x}{A}{t}{u}$.\nIn such a local definition, $x$ can be used in the term $u$ as a shorthand for $t$.\n\n\\begin{figure}[ht]\n  \\ContinuedFloat*\n  \\begin{mathpar}\n    \\inferdef{LetIn}{\\Gamma \\vdash A \\ty \\uni \\\\ \\Gamma \\vdash t \\ty A \\\\\n    \\Gamma, x \\coloneqq t \\ty A \\vdash u \\ty B}\n    {\\Gamma \\vdash \\letin{x}{A}{t}{u} \\ty \\letin{x}{A}{t}{B}}\n    \\label{rule:pcuic-letin}\n  \\end{mathpar}\n  \\caption{Typing for local definitions}\n  \\label{fig:local-def}\n\\end{figure}\n\nThe main impact of this addition is its effect on contexts: as \\ruleref{rule:pcuic-letin}\nillustrates, when typing $u$, not only the type of the definition is recorded, but\nalso its value $t$. This is again due to dependency, because the value of the definition,\nand not only its type, might be needed for $u$ to be well-typed.\nAs an example, suppose we have a function\n\\[\\operatorname{head} \\ty \\P (A : \\uni) (x : \\Nat).\\ \\Vect(A,\\S x) \\to A\\]\nand consider\n\\[\\letin{x}{\\Nat}{1}{\\l v : \\Vect(\\Bool,x).\\ \\operatorname{head}\\ \\Bool\\ \\z\\ v} \\]\nThis term is well-typed only if the fact that $x$ has value $1$ is available in the\nright-hand side.\n\n\\begin{marginfigure}\n  \\ContinuedFloat\n  \\begin{mathpar}\n    \\inferdef{ζRed}{ }{\\Gamma \\vdash \\letin{x}{A}{t}{u} \\\\ \\tred \\subs{u}{x}{t}}\n    \\label{rule:zeta-red} \\and\n    \\inferdef{δRed}{(x \\coloneqq t : A) \\in \\Gamma}{\\Gamma \\vdash x \\tred t}\n    \\label{rule:delta-red}\n  \\end{mathpar}\n  \\caption{Top-level reduction for local definitions}\n  \\label{fig:local-def-red}\n\\end{marginfigure}\n\nThis also means that contexts now should be recorded in\n\\kl{conversion} and \\kl{cumulativity}, because those need to access the value of a\nvariable bound by a definition if we want to enable the behaviour just described.\nIn the end, there are two \\kl{top-level reductions} for definitions, given opposite:\nthey can be either simplified right away into a substitution (\\nameref{rule:zeta-red})%\n\\sidenote{The notations are a bit misleading here: the local definition is part\nof the syntax of terms, while substitution is a meta-level operation. While the former\nencodes the latter in the syntax, they are quite different!},\nor recorded into the context and simplified only later on\nusing \\ruleref{rule:delta-red}.\n\n\n\\subsection{Global environments}\n\n\\kl{PCUIC} offers a second way to record definitions, inside a so-called\n\\intro{global environment}.\nThe difference between this and the addition of local definitions in a context we\njust saw is motivated by rather concrete considerations.\nThe (local) context corresponds to definitions and abstractions\nencountered when type-checking a single proof or program, and should thus be relatively shallow\n– the order of magnitude is a dozen variables – but it might change very often, with variable\nbeing both added and abstracted over.\nThe \\kl{environment}, on the contrary, can become huge –\ncorresponding to a whole library with thousands of components — but changes less often, and\nusually in a monotone way – new definitions are added, but not removed.\nTherefore, typing in \\kl{PCUIC} actually has an extra parameter: it is of the form\n$\\Sigma ;;; \\Gamma \\vdash t \\ty T$, with $\\Sigma$ corresponding to the \\kl{environment}.\n\nThis environment is not only used for definitions and assumptions,\nbut also to keep track of inductive types.\nIt thus effectively implements our somewhat vague assumption that\n\\kl{CIC} is extended with “any number of valid inductive types”. Of course, there is a notion\nof environment well-formation, which accounts for the fact that it should\nonly contain objects that are well-typed, together with other constraints, for instance\nthat inductive types respect the strict positivity criterion.\n\nThere is a further use for this environment: it also records the level variables available for\nuniverses, and their constraints. Indeed, in \\kl{PCUIC}, universe levels are expressions\nrather than simple natural numbers,\nand the order between expressions is relative to a given environment $\\Sigma$.\nThere are actually two kinds of those universe variables.\nThe first are global ones, that are recorded in an ever-growing fashion in the environment.\nThis is the older approach, that was introduced in \\kl{Coq} together with \\kl{typical\nambiguity}, following \\sidetextcite{Pollack1992}.\n\nThis approach is however still not flexible enough, which is why a second kind of variables\nwere more recently introduced \\sidecite{Sozeau2014}. These are attached locally to\nan entry in the environment, corresponding to a form of \\intro{universe polymorphism},\nand each time such a definition is used it can be instantiated with new universe levels.%\n\\sidenote{\n  This is somewhat similar to the Hindley-Milner style of type polymorphism\n  \\cite{Hindley1969,Milner1978} widely used in the ML family of languages,\n  albeit with universe levels rather than types.\n}\\margincite{Hindley1969}\\margincite{Milner1978}\nThis is for instance useful to have a single (polymorphic) definition of categories,\nand still be able to define the category – at level $j$ – of all categories\n– at a level $i < j$ –, by instantiating the definition at the two different levels $i$ and $j$.\nIf there was just one global level $k$, then doing this would result in a constraint $k < k$,\nand this definition would not be accepted.\n\n\\subsection{Enhanced inductive types}\n\\label{sec:pcuic-ind}\n\nOf course inductive types in \\kl{PCUIC} are also affected by these extensions.\nNot only can they be polymorphic, as definitions, they also feature a form of \ncumulativity, that makes this polymorphism more seamless – see \\sidetextcite{Timany2018}\nfor a precise description.\nThis for instance prevents issues with $\\lnil[A]$ not being of type $\\List(A)$ because of a\nmismatch between type variables – those do not appear in our presentation of \\kl{CIC},\nbut are present in \\kl{PCUIC} due to the general setting for polymorphic \ninductive types.\n\nMoreover, the strict positivity criterion adopted in \\kl{PCUIC} is\nvery general, as it allows mutually defined and nested inductive types.\nThe former are multiple inductive types defined at the same time,\nwhere a constructor of one type can take a recursive argument of another. For instance,\nan inductive oddness/evenness predicate with constructors\n$\\operatorname{oddS} \\ty \\P x : \\Nat.\\ \\operatorname{even} x \\to \\operatorname{odd} \\S x$ and $\\operatorname{evenS} \\ty \\P x : \\Nat.\\ \\operatorname{odd} x \\to \\operatorname{even} \\S x$.\nThe latter are types where a constructor can take a recursive argument mentioning the type\nbeing defined as a parameter to another inductive type –\nfor instance, a type of tree where a node takes a list of trees as argument.\n\nBut the most significant difference is that the induction principles,\nsuch as the ones we gave for \\kl{CIC},\nare replaced with two new constructions: pattern-matching and fixed-points. The\nfirst corresponds to the non-recursive component of the induction principles, while the\nsecond allows to define a function that calls itself recursively.\nTo avoid paradoxical definitions, not every recursive definition is accepted, however.\n\\AP Instead, there is a restriction called the \\intro{guard condition}\nto how a recursive function\ncan be defined, which amounts to checking that recursive calls are made on\nstructurally smaller sub-terms – by means of pattern-matching. This guard condition\ntheoretically ensures that fixed-points and pattern-matching can always be reduced to\n\\kl{recursors} \\sidecite{Gimenez1995}, which are what proofs of \\kl{normalization} and/or\nconsistency usually consider.\nHowever, in practice the former is much more\nflexible and natural to use than the latter.\n\n\\subsection{Records and co-inductive types}\n\\label{sec:pcuic-records}\n\nThe last ingredient in \\kl{PCUIC} goes beyond inductive types, by adding more primitive types\nto the theory.\n\n\\AP The first kind are \\intro{record types},\na generalization of Σ-types which allows for any number of\nnamed fields. The main addition of record types is the ability to access those fields via\n\\intro{projections} rather than by using pattern-matching. For the Σ-type as presented in\n\\cref{sec:tech-cic}, this would mean accessing the two fields of the pair $p$ with two\nterm formers $p._{1}$ and $p._{1}$. These record types are very useful to package\nobjects together, be it in programming or in mathematics – where such bundles are ubiquitous,\nfor instance when formalizing hierarchies of mathematical structures \\sidecite{Cohen2020}.\n\n\\AP The second kind are \\intro{co-inductive types}.\nThese are somewhat similar to inductive types, but\nwhile the latter correspond to well-founded objects, the former represent\npotentially infinite objects, such as streams of values. Because of this flavour of infinity,\nco-inductive types pose an inherent threat to good properties of the system, in particular\ndecidability of type-checking. At the time of their introduction in \\kl{Coq}\n\\sidecite{Gimenez1995}, they were presented in a so-called “positive” fashion – close\nto the presentation of \\kl{inductive types} –, which\nkept \\kl{normalization} at the cost of \\kl{subject reduction}.\nAnother presentation, inspired by more recent work on\nco-induction, and especially co-patterns \\sidecite{Abel2013}, is the “negative” one –\nsimilar to the projection-based presentation of \\kl{record types} –,\nwhich regains the good properties of the system. While the older positive presentation\nis still present in \\kl{Coq}, in part for compatibility reasons,\nonly the negative one is formalized in \\kl{MetaCoq}.", "meta": {"hexsha": "8ea432ae90ec0b929d9d9df93148714db0a5466d", "size": 85873, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/technical-intro.tex", "max_stars_repo_name": "MevenBertrand/PhD-Thesis", "max_stars_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Manuscript/technical-intro.tex", "max_issues_repo_name": "MevenBertrand/PhD-Thesis", "max_issues_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-22T14:04:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T18:26:29.000Z", "max_forks_repo_path": "Manuscript/technical-intro.tex", "max_forks_repo_name": "MevenBertrand/PhD-Thesis", "max_forks_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7337409672, "max_line_length": 185, "alphanum_fraction": 0.7250590989, "num_tokens": 24888, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4282960048473841}}
{"text": "\\documentclass{article}\n\n% Packages\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{ismir,cite,url}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage[british]{babel}\n\\usepackage{csquotes}\n\\usepackage{microtype}\n\\usepackage{balance}\n\\usepackage{enumitem}\n\\usepackage{amsmath,amsthm,amssymb}\n\\usepackage{newtxmath}\n\\usepackage{nicefrac}\n\\usepackage{upgreek}\n\\usepackage{graphicx}\n\n% Custom commands\n\\newcommand{\\vect}[1]{\\mathrm{\\mathbf{#1}}}\n\\newcommand{\\R}{\\mathbb R}\n\\newcommand{\\E}{\\mathbb E}\n\\newcommand{\\vx}{\\vect x}\n\\newcommand{\\vr}{\\vect r}\n\\newcommand{\\vu}{\\vect u}\n\\newcommand{\\vS}{\\vect S}\n\\newcommand{\\vX}{\\vect X}\n\\newcommand{\\vC}{\\vect C}\n\\newcommand{\\vR}{\\vect R}\n\\newcommand{\\vW}{\\vect W}\n\\newcommand{\\vomega}{\\boldsymbol{\\upomega}}\n\\newcommand{\\Real}{\\text{Re}}\n\\newcommand{\\hvx}{\\hat \\vx}\n\\newcommand{\\hvX}{\\hat \\vX}\n\\DeclareMathOperator{\\proj}{proj}\n\\DeclareMathOperator{\\Cov}{Cov}\n\\newcommand{\\subfiglabel}[1]{\\textbf{\\textsc{#1}}}\n\n% Metadata\n\\title{Cosine Contours:\\\\ A  Multipurpose Representation for Melodies}\n\\oneauthor%\n  {Bas Cornelissen \\hfil Willem Zuidema \\hfil John Ashley Burgoyne}\n  {Institute for Logic, Language and Computation, University of Amsterdam \n  \\\\{\\url{b.j.m.cornelissen@uva.nl}, \\url{zuidema@uva.nl}, \\url{j.a.burgoyne@uva.nl}}\n}\n\\def\\authorname{B.~Cornelissen, W.~Zuidema, and J.A.~Burgoyne}\n\n% Some final\n\\usepackage[bookmarks=false, pdfauthor={\\authorname}, pdfsubject={\\papersubject}, hidelinks]{hyperref}\n\\sloppy\n\\begin{document}\n\n\n%=========\n\\maketitle\n%=========\n\n\n\\begin{abstract}\nMelodic contour is central to our ability to perceive and produce music.\nWe propose to represent melodic contours as a combination of cosine functions, using the discrete cosine transform. \nThe motivation for this approach is twofold: (1) it approximates a maximally informative contour representation (capturing most of the variation in as few dimensions as possible), but (2) it is nevertheless independent of the specifics of the data sets for which it is used. \nWe consider the relation with principal component analysis, which only meets the first of these requirements. \nTheoretically, the principal components of a repertoire of random walks are known to be cosines. \nWe find, empirically, that the principal components of melodies also closely approximate cosines in multiple musical traditions. \nWe demonstrate the usefulness of the proposed representation by analyzing contours at three levels (complete songs, melodic phrases and melodic motifs) across multiple traditions in three small case studies.\n\\end{abstract}\n\n\n%—————————————————————\n\\section{Introduction}\n%—————————————————————\n\n\nHumans are born with a remarkable sensitivity to melodic contour.\nThis is dramatically illustrated when newborns cry: the cries of German babies tend to go down in pitch, but those of French babies go up, even if falling contours are physiologically easier to produce \\cite{Mampe2009}.\nBy imitating the intonation patterns of their mothers' language, babies take the first steps towards a spoken language---helped by exaggerated pitch contours of infant directed speech \\cite{Wermke2021}.\nContour perception remains central to speech, for intonation or even word distinctions, but is also a key ingredient of human musicality \\cite{Honing2015}.\nDowling famously argued that melodies are remembered as two independent parts, a scale and a contour \\cite{Dowling1978}. \nA scale then functions as a ladder ``on which the ups and downs of the contour where hung.''\nIndeed, when listening to novel melodies, contours appear to stand out more than the exact intervals and influence the perceived similarity of melodies \\cite{Schmuckler2016}.\nThat has also motivated studies of contour in \\textsc{mir}, in particular for measuring melodic similarity \\cite{Mullensiefen2004b}. \nAs we briefly review below, many representations of contour have been proposed in answer to the recurring question: how can one best describe melodic contour? \n\n\nWe propose representing melodies as combinations of cosine functions.\nThis is motivated by the need for a concise, maximally informative representation: how can we capture as much of the variability in contour data in as few dimensions as possible?\nThe easiest solution would be to use a \\emph{principal component analysis} (\\textsc{pca}). \nIn section~\\ref{sec:pc}, we show empirically that the principal components of melodies do not take arbitrary shapes, but in fact closely approximate cosines. \nWe then relate this observation to theoretical results showing that the principal components of certain random walks are sinusoidal, as a result of a particular covariance structure.\nThe proposed `cosine contour' space thus closely approximates the optimal solution provided by \\textsc{pca}, but offers several benefits.\nThe key argument for this representation is theoretical and\nwe leave a systematic comparison of contour representations for future work. \nInstead we discuss three case studies that demonstrate the usefulness of cosine contours.\n\n\nCosine contours meet several desiderata for contour representations.\nFirst, a good representation respects the linear structure of melody and is \\emph{invariant to transposition and tempo changes}.\nSecond, the representation should be \\emph{interpretable} and \\emph{intuitive} (and,\nin particular, avoid some of the shortcomings of polynomial coefficients).\nThird, the representation should support \\emph{variable levels of abstraction}, so that one can interpolate between a broad summary of the shape, and the exact pitch curve.\nFourth, we look for a \\emph{broadly applicable} and \\emph{culturally neutral} representation: it should be able to describe contours from different cultures, or even from different domains (e.g.,~speech). It should also be able to handle both audio and symbolic data, although we only analyze symbolic data here.\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig01-cosine-contours.pdf}\n    \\caption{\n        \\textbf{Cosine contours} represent a melodic contour as a combination of cosine functions.\n        %\n        \\subfiglabel{(a)}~%\n        This is illustrated for a short melodic phrase.\n        %\n        \\subfiglabel{(b)}~%\n        A piano roll is interpolated to obtain fixed-length vector of \\textsc{midi} pitches (black curve).\n        This vector is approximated using a discrete cosine transform (coloured curves).\n        Increasing the dimensionality, from, e.g.,~1 (blue) to 3 (green) improves the approximation.\n        %\n        \\subfiglabel{(c)}~%\n        The basis functions correspond to simple shapes.\n        %\n        % \\subfiglabel{(d)}~%\n        This makes the cosine contour space interpretable, as illustrated in \\subfiglabel{(d)} for the first two dimensions. \n        Every point in this space defines a contour shape, varying in what we call the \\emph{descendingness} and \\emph{archedness}. \n        The orange dot represents the orange contour from \\subfiglabel{(b)}.\n    }\n    \\label{fig:representation}\n\\end{figure}\n\n\n%—————————————————————————————————\n\\section{What is melodic contour?}\n%—————————————————————————————————\n\n\nMelodic contour is a general description of a melody's shape that abstracts away from the particular pitches and precise rhythms.\nIt has been characterised in many different ways.\nEthnomusicologists (and composers) have used \\emph{contour typologies}: small sets of contour types \\cite{Adams1976}.\nDavid Huron, for example, distinguished nine types of contours by comparing the initial and final pitches to the average pitch on the middle part of a melody \\cite{Huron1996}.\nWhen, say, the initial is above the middle, which in turn equals the final, the melody has a `descending-horizontal' contour.\nSuch a formal typology can be used in \\textsc{mir} \\cite{Mullensiefen2009}, but typologies have also been defined using verbal descriptions or even drawings \\cite{Adams1976,Kelkar2018}.\nCantoCore, for example, instructs an annotator to look for six types: ascending, descending, arched, U-shaped, undulating and horizontal \\cite{Savage2012}.\nEven though the types are less sharply defined, such typologies have inspired cross-cultural generalizations such as the \\emph{melodic arch hypothesis}: the claim that melodic phrases tend to be arch-shaped or descending \\cite{Huron1996,Savage2015,Tierney2011,Savage2017a}.\n\n\nIn melody extraction from audio, contours are usually represented by sequences of pitches ordered in time.\nVarious contour features derived from this, such as the range or pitch deviation, have been used in classification tasks \\cite{Bittner2017,Panteli2017a,Bittner2015,Salamon2012}.\nContours in symbolic data can be similarly represented as \\emph{step curves} (figure \\ref{fig:representation}B, black line) \\cite{Steinbeck1982,Mullensiefen2012}.\n\\emph{Parsons code} drastically simplifies a step curve \\cite{Parsons1975}.\nIt describes the direction of movement from one note to the next (up, down, or level) and discards interval size and note durations.\nVariants between these two extremes have also been used, by distinguishing various classes of jump sizes \\cite{Mullensiefen2004b}.\nAnother strategy is to focus on salient notes, typically turning points (maxima and minima), and to discard other notes \\cite{Adams1976,Steinbeck1982,Salamon2012}.\nThis often requires special handling of ornaments \\cite{Mullensiefen2012}, possibly tailored to the repertoire.\nYet another approach considers the relative ordering of all pairs of notes in a melody, summarized in a matrix.\nSuch combinatorial models in way expand rather than reduce the representation, break the linearity of the melody and are sensitive to local changes \\cite{Mullensiefen2012}.\n\n\nFinally, one can describe melodies using continuous functions.\nMüllensiefen and Wiggins fit a polynomial function to a step curve and use the coefficients to represent the contour \\cite{Mullensiefen2012}.\nThe degree of the polynomial is chosen per phrase, using the Bayesian information criterion (\\textsc{bic}) to avoid overfitting.\nPolynomial coefficients are quite difficult to interpret, however: they change drastically when the degree changes, and can also be sensitive to changes in the data, especially when the polynomials are not orthogonal and introduce correlations between the coefficients (collinearity).\nInstead of fitting a function to the contour, one can also \\emph{decompose} the contour and express it as a sum of (orthogonal) basis functions.\nVelarde and colleagues have for example used \\emph{Haar wavelets} as basis functions in musical pattern discovery \\cite{Velarde2016}.\nThe step-like shapes of those wavelets are well suited to describe particular melodic patterns, but make them less suited for describing the overall contour.\nAn alternative basis of sinusoidal functions is implicit in Schmuckler's use of a Fourier analyses to represent melodic contour \\cite{Schmuckler1999}.\nThis has been interpreted as measuring the `periodic information' in a melody, and was reported to correlate with perceived similarity.\n\n\n%—————————————\n\\section{Data}\n%—————————————\n\n\nWith the broad applicability in mind, we analyze music from several independent traditions.\nThe choice of traditions was partly motivated by our aim to analyze contours at multiple levels of description: we expect (different) regularities at different levels.\nAt the highest level, complete \\emph{songs} can have characteristic shapes, and those shapes may differ between traditions. \nAt the smaller level \\emph{phrases} may be subject to the melodic arch hypothesis cited above.\nFinally, at the smallest level, \\emph{melodic motifs} could exhibit sequential structure, for example when melodies in a repertoire are formed by stringing together melodic motifs (sometimes called \\emph{centonization} \\cite{Nuttall2019}).\nWe also analyze \\emph{random segments} obtained by slicing a melody at random in approximately phrase-length segments, so that their boundaries usually do not overlap with actual phrase boundaries \\cite{Cornelissen2020DLfM}.\n\n\nOne tradition for which all of these levels are directly available is Gregorian chant, thanks to two recently released corpora: the CantusCorpus and the GregoBaseCorpus \\cite{Cornelissen2020DLfM}.\nGregorian chant has been sung in Roman Catholic churches for well over a thousand years.\nThe close connection between music and text in chant suggests a natural subdivision of the music into motifs corresponding to words or syllables. \nThe notation suggests even smaller motifs: it is based on small figures, called \\emph{neumes}, that represent short groups of notes \\cite{Kelly2018}.\nTo analyse motif contours, we use chants from the CantusCorpus (v0.2) with transcriptions of medieval manuscripts, which include neume boundaries. \nWe focus on the two largest chant genres: \\emph{antiphons} and \\emph{responsories}.\nPhrase boundaries are not available in the CantusCorpus, however, and so for that, we turn to the GregoBaseCorpus (v0.3) of modern chant transcriptions.\nModern chant notation includes explicit breathing marks (\\emph{pausas}), which have been used to extract phrases \\cite{Cornelissen2020DLfM}.\n\n\nPhrase markings are also included in the Essen Folksong Collection \\cite{Schaffrath1995}, from which we analyse phrases from German and Chinese folksongs.\nWe focus on the two largest subsets, `Erk' \\cite{Erk1893} (9782 contours) and `Han' (7601 contours).\\footnote{%\n    %———\n    Much is unclear about the exact (bibliographic) origins of the Chinese subset of \\emph{Essen}.\n    This is problematic given its wide use in computational musicology and deserves further attention from the community.\n    }%———\nAt the level of complete songs, we also add music from the Sioux people made available in the \\emph{Densmore Collection} \\cite{Densmore1918,Shanahan2014}.\nIn the supplementary material, we include some further analyses of several other traditions from the \\emph{Essen} and \\emph{Densmore} collections.\n\n\nWe convert all melodies (be it songs, phrases or motifs) to step contours by extracting note onsets (in quarter notes) and pitches (in \\textsc{midi} semitones).\nWe then interpolate a step function through these points, from which we sample $N=100$ equally spaced pitches.\nThose pitches are collected in vectors $\\vect x = (x_0, \\dots, x_{N-1})$ (black curve in figure \\ref{fig:representation}\\textsc{a}), which are the basic data analysed in this paper.\\footnote{%\n    %——\n    See \\href{https://github.com/bacor/cosine-contours}{github.com/bacor/cosine-contours}\n    for data, code and supplements.\n    }%——\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig02-pca.pdf}\n    \\caption{%\n        \\textbf{Principal components of contours}~%\n        %———————————————————————————————————————\n        (solid lines) are roughly cosine shaped (dashed) across different levels \\textsc{\\textbf{(a)}}.\n        This is a result of the particular structure of the covariance matrix \\textsc{\\textbf{(b)}}: matrices of this type have Fourier basis functions as their eigenvectors.\n        This is clearest for phrases \\textsc{\\textbf{(2)}} or random segments from melodies \\textsc{\\textbf{(3)}}, here of similar length as phrases.\n        Crucially, we see the same effect for simulated, contour-like random walks \\textsc{\\textbf{(4)}}.\n        For complete songs \\subfiglabel{(5)} the effect is less clear, probably due to differences in typical length \\textsc{\\textbf{(c)}} and data size.\n        Contours in \\subfiglabel{1--4} are from Gregorian chant.\n    }\n    \\label{fig:pca}\n\\end{figure}\n\n\nOur starting representation makes several assumptions that seem reasonable (and common: \\cite{Savage2017a,Tierney2011,Velarde2016}) when only interested in contour.\nFirst, we ignored all rests.\nSecond, we normalize the duration of all contours.\nBoth 3-note motifs and 30-note songs are represented by vectors of 100 pitches.\nThe relative durations within that melody are of course retained, so we would still see that contours of short motives are probably simpler than those of long melodies.\nThird, we assume Euclidean distances between melodies.\nThis is usually problematic, but less so when we are only interested in contour similarity.\nOur analyses require that all contours are embedded in a vector space.\nUsing more sophisticated measures such as dynamic time warping distance, would require us to reconstruct a space (e.g., using multidimensional scaling), and make the analyses less transparent.\nFinally, note that we do \\emph{not} center the contours to have mean pitch 0.\nThis is sometimes done to make contours transposition invariant and more directly comparable \\cite{Savage2017a,Velarde2016,Cornelissen2020DLfM}.\nWe will soon see that our proposed representation elegantly resolves this problem without requiring centring.\n\n\n%———————————————————————————————————————————————————————\n\\section{Principal components of contours}\\label{sec:pc}\n%———————————————————————————————————————————————————————\n\n\nIn this section, we explore principal component analysis applied to contours.\nThe goal of \\textsc{pca} is to find a set of orthogonal axes, the \\emph{principal components}, that contain most of the variance in the dataset. Note that the principal components, like the original contours from our data, are $N$-dimensional vectors, such that the contours and components can be interpreted and plotted in the same space.\n\n\nIn figure~\\ref{fig:pca}\\textsc{a}~, we show results from applying \\textsc{pca} on a large dataset of Gregorian chant (similar results with German and Chinese folksongs can be found in supplement S2). We plot the first four principal components of several types of melodies: short motifs (syllables), phrases, random segments of melodies, and complete songs.\nWe show responsory syllables from CantusCorpus for the motifs,\nantiphon phrases from the GregoBaseCorpus \nand finally all song contours from GregoBaseCorpus.\n\n\nSurprisingly, we find that the principal components are highly similar across most of those data sets, and correspond to well-known contour shapes: descending, convex, and—perhaps—undulating. \nThis is clearest for the phrases and random segments.\nFor complete songs the effect is weaker, especially for even smaller datasets (see the supplement S2). \nBesides small data sizes, the fact that songs are\nmuch longer also plays a role (see fig.~\\ref{fig:pca}\\textsc{c}).\nWe also applied the analysis on simulated random walks approximating phrases: we draw the number of notes from a similar length distribution, normalize the duration and then sample $N=100$ pitches as before (see supplement S1 for details).\nInterestingly, the pattern is now even clearer, suggesting there must be a mathematical explanation.\n\n\nTo give that explanation, we need to first describe \\textsc{pca} more formally. We consider a collection of $M$ contour vectors $\\vx_m$ of length $N$.\nDenote the sample mean by $\\bar \\vx = \\frac{1}{M} \\sum_{m} \\vx_m$ and the centered data by $\\hat \\vx_m = \\vx_m - \\bar \\vx$.\nThe first principal component of the dataset is then defined as a normalized vector $\\vu_1 \\in \\R^D$ for which the projected data $\\{\\vu_1^T \\vx_m: 1 \\le m \\le M \\}$ has maximal variance.\nIt can be shown (e.g.,~\\cite{Jolliffe2002}) that this is the case when $\\vu_1$ is an eigenvector corresponding to the largest eigenvalue $\\lambda_1$ of the covariance matrix\n%———\n\\begin{align}\n    \\label{eq:covariance}\n    \\vS = \\frac{1}{M} \\sum_{m=1}^M (\\vx_m- \\bar\\vx)(\\vx_m - \\bar\\vx)^T,\n\\end{align}\n%———\nso that $\\vS \\vu_1 = \\lambda_1 \\vu_1$.\nIt follows that the projected variance is given by $\\lambda_1$, the largest eigenvalue.\nThe other principal components similarly emerge as the other eigenvectors of the covariance matrix.\n\n\nThe covariance matrices (figure \\ref{fig:pca}\\textsc{b}) \nfor both random walks and our empirical data have a particular structure: they \\emph{roughly} resemble \\emph{Toeplitz matrices}, which have fixed values along each of their diagonals.\nSuch covariance structures are frequently encountered in spatial or temporal data, when the covariance decreases with the distance between the points\\cite{Gray2006,Novembre2008,Antognini2018}.\nWith the empirical contours that appears to be the case (and for random walks it is there by design): there is higher correlation between successive pitches and lower correlation between distant pitches.\nAs a result, the higher covariances are concentrated along the diagonal.\nAgain, this clearest for the phrases and random segments.\nFor motifs we see some deviations: two `blocks' in the covariance matrix, and corresponding jumps half way through the principal components.\nThis is easily explained by the fact that motifs often span only two notes.\nIn that case, all pitches in the first half of the contour are then perfectly correlated, as are pitches in the final half.\nCrucially, despite such deviations from a perfect Toeplitz structure, the principal components are still well-approximated by cosines.\n\n\nIf you let a Toeplitz matrix grow in size, it asymptotically tends towards a \\emph{circulant} matrix, preserving properties such as eigenvalues and eigenvectors along the way \\cite{Gray2006}.\nCirculant matrices have exactly the same values in every row, but rotated one step to the right with respect to the previous row.\nThis has the surprising result that all circulant matrices have the same eigenvectors: basis vectors of the discrete Fourier transform.\nFor a real and symmetric matrices, like covariance matrices, this results in cosine-shaped eigenvectors of increasing frequency---exactly what we see in figure \\ref{fig:pca}.\nWe discuss all of this in more detail in the supplement S2.\nIn sum, because of a Toeplitz-like covariance structure, the principal components of melodic contours will tend to look like cosine functions.\n\n\n%————————————————————————\n\\section{Cosine contours}\n%————————————————————————\n\nNext we turn this observation, and its explanation, into a proposal for a new contour representation.\nThe idea is to approximate the principal components by cosine functions and then project the contours on those first few cosines to obtain a low-dimensional representation.\nThis is exactly equivalent to taking a \\emph{discrete cosine transform} (\\textsc{dct}) of the contour \\cite{Ahmed1974}.\n\n\nFormally, consider a collection of contours of length $N$ as before.\nWe approximate the $k$-th principal component $\\vu_k$ by a vector $\\vect v_k = \\bigl(v_k(0), \\dots, v_k(N-1)\\bigr)$ whose entries are given by the cosine function\\footnote{%\n    %———\n    These basis functions correspond to the most popular version of the discrete cosine transform, \\textsc{dct-ii}, for which fast implementations are widely available; others would have been possible \\cite{Strang1999}.\n    }%———\n%———\n\\begin{align}\n    v_k(n) \n        &= \\alpha_k \\cdot \\cos \\frac{\\pi(2n + 1)k}{2N}.\n\\end{align}\n%———\nHere $\\alpha_0 = 1/\\sqrt{N}$ and $\\alpha_k = \\sqrt{2/N}$ for $k \\ge 1$ are normalizing constants ensuring that $\\vect v_k$ has unit norm.\nThe projection of a contour $\\vx = (x_0, \\dots, x_{N-1})$ on $\\vect v_k$ is then given by the inner product $c_k =  \\vect v_k^T \\vx$.\nExpanding this gives the usual definition of the discrete cosine transform (\\textsc{dct-ii}):\n%———\n\\begin{align}\n    c_k \n    = \\sum_{n=0}^{N-1}\n        x_n  \\alpha_k \\cos \\frac{\\pi(2n + 1)k}{2N}.\n\\end{align}\n%———\nConversely, the contour can be reconstructed from the coefficients $c_k$ using the inverse transform $x_n = \\sum_{k=0}^{N-1} c_k v_k(n)$.\nUsing only $D<N$ coefficients, we define our low-dimensional \\emph{cosine contour representation} as $C_D(\\vx) = (c_1, \\dots, c_D)$.\nNote that we deliberately discard $c_0$.\nThis coefficient corresponds to a flat line and describes the overall pitch height of a contour: exactly what we need to get rid of to make the contour transposition invariant.\nIn this way we resolve the centering of contours discussed above.\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig03-evaluation.pdf}\n    \\caption{%\n        \\textbf{\\textsc{dct} approximates \\textsc{pca}},~%\n        %——————————————————————————————————————————————\n        the optimal transform,\n        in terms of the reconstruction error \\subfiglabel{(a)} and the explained variance ratio \\subfiglabel{(b)}.\n        The reconstruction error is the mean squared error between an contour and a lower dimensional reconstruction.\n        Note that data corresponds to figure \\ref{fig:pca}, and that we did \\emph{not} discard the first component $c_0$ of the \\textsc{dct} in this figure.\n    }\n    \\label{fig:evaluation}\n\\end{figure}\n\n\nWhy use this representation instead of principal components?\nIndeed, a principal component projection (also known, in this context, as the \\emph{Karhunen-Loève transform}), is optimal in several ways \\cite{Rao1990,Ahmed1974}.\nNot only does it decorrelate the data, it also packs most variance in the first few transform coefficients (sometimes called \\emph{energy compaction}), and minimizes the reconstruction error when using only a few coefficients.\nHowever, the transformation depends on the data.\nConcretely, the principal components of German phrase contours differ from Chinese ones. \nAny choice for using one of the two is arbitrary. \nIn contrast,  the \\textsc{dct} is a principled, neutral solution---that approximates the optimal transform.\nIn fact, the \\textsc{dct} was originally introduced for similar reasons \\cite{Ahmed1974}, and was then found to empirically approximates \\textsc{pca} well in domains ranging from image to audio \\cite{Rao1990}.\nThe current results suggest that the same applies for melodies.\n\n\n%————————————————————————————————————\n\\section{Evaluation and case studies}\n%————————————————————————————————————\n\n\nWe evaluate proposed contour representation by comparing it to a principal component transformation, to demonstrate that representation is close to the optimum. We further designed three case studies to illustrate its usefulness at the levels of (1) song, (2) phrases and (3) motifs.\nThe case studies show that the representation is musicologically meaningful, as it allows visualization of variation (1), a quantitative evaluation of constraints on variation (2), and accurate classification into traditional categories (3).\nFor simplicity, we only look at two dimensional representations in these case studies, but higher dimensions may be useful in practice.\n\n\n\\subsection{Optimality}\n%----------------------\n\n\nTo empirically verify the claim that the \\textsc{dct} approximates the optimal \\textsc{pca} transform, we compute the reconstruction error and the explained variance ratio using the same data as before.\nThe reconstruction error is measured as the mean square error between a contour and its $D$-dimensional reconstruction, using either the principal components (\\textsc{pca}) or cosines (\\textsc{dct}) as basis functions (so for $D=N$, the reconstruction is guaranteed to be perfect).\nFigure \\ref{fig:evaluation}\\textsc{a} shows that the reconstruction errors of \\textsc{dct} closely approximate that of \\textsc{pca}.\nFor the shorter contours (motifs and phrases), the error very rapidly decreases, indicating that low-dimensional representations are already effective.\nIndeed, to explain 95\\% of the variance using cosine contours, you need 1 dimension for motifs, 9 for phrases and 61 for songs (this is sometimes called the \\emph{effective dimensionality} \\cite{Moore2018}).\\footnote{%\n    %——\n    However, note that Moore et al \\cite{Moore2018} show that high-dimensional random walks can falsely appear to have a low effective dimensionality.%\n    %——\n    }\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig04-songs.pdf}\n    \\caption{\n        \\textbf{Songs of three cultures} represented in the cosine contour space \\subfiglabel{(a)} show substantial variability.\n        The average of all contours in a tradition \\subfiglabel{(b--d)} also illustrates this\n        (thick black lines; dashed lines highlight one contour).\n        }\n    \\label{fig:songs}\n\\end{figure}\n\n\n\\subsection{Case Study 1: Visualizing different traditions}\n%----------------------------------------------------------\n\n\nLow dimensional representations of song contours are not likely to be very informative, yet we find that some traditions can be somewhat distinguished in just two dimensions.\nFigure \\ref{fig:songs} shows song contours from German, Chinese and Sioux songs.\nSioux songs have a striking overall shape (subplot \\textsc{d}), often strongly descending, which is reflected in the distribution of contour shapes.\nSimilarly, German songs appear to be more arch-like than songs from the other traditions.\n\n\n\\subsection{Case Study 2: The melodic arch hypothesis}\n%-----------------------------------------------------\n\n\nIn a second case study, we look at the melodic arch hypothesis, which states that \\emph{phrases} tend to be arch-shaped or descending \\cite{Huron1996} (see figure \\ref{fig:melodic-arch}\\textsc{a, b}) in a way that it becomes much easier to test (cf.~\\cite{Savage2017a}).\nWe observe that the first component $c_1$ of a cosine representation roughly measures the \\emph{descendingness} of the contour, and, similarly, that $-1\\cdot c_2$ measures the \\emph{archedness}.\nThe melodic arch hypothesis can thus be reformulated as stating that $c_1$ and $-c_2$ are larger for phrases than %expected by chance.\nfor random segments of the melodies (cf.~\\cite{Cornelissen2020DLfM}).\nComparing Chinese and German phrases, we find that all are significantly ($p \\ll 0.001$) more descending and arched than the corresponding random segments (see figure \\ref{fig:melodic-arch}\\textsc{c, d}).\nThis demonstrates that the coefficients of the cosine contour representation are musicologically meaningful.\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig05-melodic-arch.pdf}\n    \\caption{\\textbf{Phrases} of German \\subfiglabel{(a)} and Chinese \\subfiglabel{(b)} songs tend to be more descending and arched compared to random segments from the same melodies, as visible from their average contours.\n    This can be quantified by comparing the first \\subfiglabel{(c)} and second \\subfiglabel{(d)} coefficients of their cosine representations.}\n    \\label{fig:melodic-arch}\n\\end{figure}\n\n\n\\subsection{Case Study 3: Mode classification}\n%---------------------------------------------\n\n\nIn the final case study, we evaluate the performance of this contour representation on a task: mode classification in plainchant.\nGregorian chant uses a system of eight \\emph{modes}: Dorian, Phrygian, Lydian and Mixolydian, each in the two flavours plagal and authentic.\nModes differ not only in their scales, but also in their melodic movement.\nPlagal melodies tend to move lower than authentic ones, closer around the tonal center.\nIn a recent paper we suggest that the mode of Gregorian chant can be predicted from contours alone, in that case using a Parsons code contour representation \\cite{Cornelissen2020ISMIR}.\nWe sliced up chants in sequences of motifs corresponding to the notational units (so called \\emph{neumes}) or textual units: all notes set to one \\emph{syllable} of the text would form a unit, and similarly for \\emph{words}.\nNext, we represented chants as vectors of motif or \\emph{term frequencies} (tf), where each entry was weighted by the \\emph{inverse document frequency} (df; the number of chants or documents containing that motif).\nA linear support vector machine was then trained on these \\emph{tf--idf vectors} to predict the mode.\n\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics{figs/fig06-mode-classification.pdf}\n    \\caption{\n        \\textbf{Motifs used for mode classification} in Gregorian chant. \n        \\subfiglabel{(a)}\n        A chant is segmented into motifs derived from the notation (neumes) or lyrics (syllables, words).\n        The blue curves show the two-dimensional cosine contours for those motifs.\n        \\subfiglabel{(b)}\n        We discretize the contour space and represent the chant as a vector of tf--idf weighed motif frequencies (`grid cell frequencies').\n        Dots illustrate the nonzero entries of this vector for the chant shown above.\n        \\subfiglabel{(c)}\n        The chant is now a walk through contour space, but our `bag of motifs` ignores order.\n        \\subfiglabel{(d)}\n        Using these vectors to classify mode, we outperform a previous study using a Parsons code for the smaller motifs neumes and syllables.\n        }\n    \\label{fig:chant}\n\\end{figure}\n\n\nWe repeat these experiments using a two-dimensional cosine representation for the motifs rather than a Parsons code.\nThere is one technical problem: whereas cosine contours are continuous, the tf--idf model requires a discrete vocabulary of motifs.\nWe therefore discretize the cosine contour space to a grid, and effectively treat every chant as a sequence of grid-cells (fig.~\\ref{fig:chant}\\textsc{c}).\nAll in all, this introduces two new parameters to the experiment: the dimensionality of the cosine contour and the resolution of the grid.\nIn this case study, we do not tune these parameters and focus on two dimensional contours, discretized to a grid between $-20$ and $20$ with a grid size of 1.\nFor ease of reading, the figure~\\ref{fig:chant}\\textsc{b} shows the grid only from $-10$ to $10$.\n\n\nThe results are summarized in figure \\ref{fig:chant}\\textsc{d}.\nWe see an interesting pattern: the cosine contours outperform the original results for small motifs such as neumes and syllables, but not for words, which are much longer motifs. \nThis seems to makes sense: two dimensional cosine contours are a fairly crude approximation of those longer contours, but may reasonably approximate short motifs.\n\n\n%———————————————————————————————————\n\\section{Discussion and conclusions}\n%———————————————————————————————————\n\n\nThis paper proposed a novel representation for melodies using the discrete cosine transform.\nObserving that the principal components of melodies tend to be shaped like cosines, this representation approximates the optimal representation in the sense that it packs most variance in a few dimensions.\nFirst, the cosine representation is easily interpretable, since it presents contours as a linear combination of cosine functions with intuitive shapes.\nSecond, by changing the dimensionality, the level of abstraction of the contour can be varied, allowing arbitrary small reconstruction error by including more and more dimensions.\nThird, this representation allows one to map contours at multiple levels, from motifs to songs, to one common space.\nThe cosine representation thus creates a common ground for comparing contours across traditions and levels.\nThat is possible as, fourth, the representation is independent of the data, and in that sense culturally neutral.\n\n\nThe observation that principal components of spatial and temporal data can have sinusoidal shapes is not novel, but does not appear to be widely known.\nIndeed, the sinusoidal shapes have been interpreted as genuine effects, rather than mathematical artefacts.\nFor example, one study interpreted gradients in the principal components of human genetic variation across the world as evidence for certain migration events in human history \\cite{Cavalli-Sforza1993}.\nCloser inspection revealed that those gradients were sinusoidal `artefacts' analogous to those reported in the present paper \\cite{Novembre2008}.\nCloser to \\textsc{mir}, it has been observed that the training trajectories of deep neural networks have sinusoidal principal components \\cite{Lorch2016}, for the same reason.\nAgain, a detailed analysis \\cite{Antognini2018} revealed these were artefacts, but accurately reflecting the behaviour of high-dimensional random walks \\cite{Antognini2018,Moore2018}. \nWe hope this paper helps increasing the awareness of this phenomenon.\n\n\nThe present work only begins to explore this new contour representation and raises many further questions.\nOne particularly promising possibility is the application to audio data.\nWe only explored symbolic data, but the proposed representation lends itself well for applications on acoustic data.\nOne application we hope to explore further is the analysis of speech intonation using the cosine contour representation.\nA possible other avenue would be the analysis of folk song recordings, of which vast collections have been collected.\nFolk song researchers have often used contour in some way to organize repertoires \\cite{Adams1976}, and this representation may contribute to that.\nContour typologies have also be used in cross-cultural comparisons (see e.g.~\\cite{Savage2015}).\nMany typologies have been proposed \\cite{Adams1976,Huron1996,Kelkar2018,Savage2012}, but they have not been systematically evaluated, and we think the proposed representation will be valuable there.\n\n\n%—————————————————————————\n\\section{Acknowledgements}\n%—————————————————————————\n\n\nWe would like to thank Henkjan Honing and Marianne de Heer Kloots for their feedback on the manuscript.\nWe would also like to thank the four anonymous reviewers for their careful reviews; we have tried to address all your comments.\n\n\n%——————————————————————————\n\\bibliography{bibliography}\n%——————————————————————————\n\n\n\\end{document}", "meta": {"hexsha": "fb6d4c72fbc5794105f592da2cc8a5336e9668ce", "size": 37237, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/paper/cosine-contours.tex", "max_stars_repo_name": "bacor/cosine-contours", "max_stars_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-09-07T15:23:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-09T10:13:29.000Z", "max_issues_repo_path": "documents/paper/cosine-contours.tex", "max_issues_repo_name": "bacor/cosine-contours", "max_issues_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/paper/cosine-contours.tex", "max_forks_repo_name": "bacor/cosine-contours", "max_forks_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.6584440228, "max_line_length": 357, "alphanum_fraction": 0.7646158391, "num_tokens": 8633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.42829599648252653}}
{"text": "\\documentclass{beamer}\n\n\\usepackage{verbatim}\n\\usepackage{fancyvrb}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{booktabs}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{calc}\n\\usepackage{color}\n\\usepackage{multicol}\n\\usepackage{wrapfig}\n\\usepackage{natbib}\n\\usepackage[ruled,vlined,linesnumbered]{algorithm2e}\n\\usepackage{animate}\n\\usepackage{mathtools}\n\\usepackage{listings}\n\n\\usepackage{cmbright}\n\\fontencoding{OT1}\\fontfamily{cmbr}\\selectfont %to load ot1cmbr.fd\n\\DeclareFontShape{OT1}{cmbr}{bx}{n}{% change bx definition\n<->cmbrbx10%\n}{}\n\\normalfont % back to normalfont\n\n% two col: two columns\n\\newenvironment{twocol}[4]{\n\\begin{columns}[c]\n\\column{#1\\textwidth}\n#3\n\\column{#2\\textwidth}\n#4\n\\end{columns}\n}\n\n\\makeatletter\n\\setbeamertemplate{theorem begin}\n{%\n\\begin{\\inserttheoremblockenv}\n  {}{\\usebeamerfont*{block title}\\usebeamercolor[fg]{block title}%\n  \\inserttheoremname\n  %\\inserttheoremnumber\n  \\ifx \\inserttheoremaddition \\empty \\else\\ (\\inserttheoremaddition)\\fi\n  \\inserttheorempunctuation}\n  \\normalfont\n  }\n  \\setbeamertemplate{theorem end}{\\end{\\inserttheoremblockenv}}\n\\makeatother\n\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\sd}{\\mathrm{sd}}\n\\newcommand{\\s}{\\mathrm{s}}\n\\newcommand{\\Corr}{\\mathrm{Corr}}\n\\newcommand{\\rank}{\\mathrm{rank}}\n\\newcommand{\\trace}{\\mathrm{trace}}\n\\newcommand{\\nullspace}{\\mathrm{null}}\n\\newcommand{\\myspan}{\\mathrm{span}}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\softmax}{softmax}\n\\DeclareMathOperator{\\diag}{diag}\n\n\\definecolor{darkgreen}{rgb}{0,0.5,0}\n\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{exe}{Exercise}\n\\newtheorem{notation}{Notation}\n\\newtheorem{remark}{Remark}\n\n\\definecolor{darkgreen}{rgb}{0,0.5,0}\n\n\\title{Remedial Measures}\n\\author{Zhenisbek Assylbekov}\n\\institute{Department of Mathematics}\n\\date{Regression Analysis}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\section{Weighted Least Squares}\n\\begin{frame}{Non-homogeneous variance}\n\\begin{columns}\n\\begin{column}{.4\\textwidth}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=.9\\textwidth]{plots/heteroscedastic.pdf}\n\\end{figure}\n\\end{column}\n\\begin{column}{.6\\textwidth}\n\\begin{itemize}\n    \\item Chapters 3 and 6 discuss transformations of $x_1, \\ldots, x_k$ and/or $Y$.\n    \\item<2-> More advanced remedy: \\textbf{weighted least squares} (WLS) regression.\n    \\item<3-> Model is as before\n    $$\n    Y_i = \\beta_00 + \\beta_1\\cdot x_{i1} + \\ldots + \\beta_k\\cdot x_{ik} + \\epsilon_i,\n    $$\n    \\item<4-> Except that\n    $$\n    \\epsilon_i\\,\\,{\\stackrel{\\text{ind}}{\\sim}}\\,\\,\\mathcal{N}(0,\\sigma^2_i)    \n    $$\n\\end{itemize}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}{Weighted least squares}\n\\begin{itemize}\n\\item We have $\\Var[Y_i] = \\sigma_i^2$. \n\\item<2-> Idea: Give observations with higher variance less\nweight in the regression fitting.\n\\item<3-> Let $\\omega_i=\\frac{1}{\\sigma^2_i}$. WLS solves\n$$\n\\min_{\\boldsymbol\\beta}\\sum_{i=1}^n\\omega_i[Y_i-(\\beta_0+\\beta_1 x_{i1}+\\ldots+\\beta_k x_{ik})]^2\n$$\n\\item<4-> Or in matrix notation:\n$$\\min_{\\boldsymbol\\beta}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)^\\top\\mathbf{\\Omega}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)$$\nwhere $\\mathbf{\\Omega}=\\diag[\\omega_1,\\ldots,\\omega_n]\\in\\mathbb{R}^{n\\times n}$.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Solving WLS}\n    Let us rewrite the WLS objective as:\n    \\begin{align*}\n        \\hat{\\boldsymbol{\\beta}}_{\\text{WLS}}&=\\argmin_{\\boldsymbol{\\beta}}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)^\\top\\mathbf{\\Omega}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)\\\\\n        \\onslide<2->{&=\\argmin_{\\boldsymbol{\\beta}}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)^\\top\\mathbf{\\Omega}^{1/2}\\mathbf{\\Omega}^{1/2}(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)\\\\}\n        \\onslide<3->{&=\\argmin_{\\boldsymbol{\\beta}}(\\mathbf{\\Omega}^{1/2}\\mathbf{Y}-\\mathbf{\\Omega}^{1/2}\\mathbf{X}\\boldsymbol\\beta)^\\top(\\mathbf{\\Omega}^{1/2}\\mathbf{Y}-\\mathbf{\\Omega}^{1/2}\\mathbf{X}\\boldsymbol\\beta)\\\\}\n        \\onslide<4->{&=\\argmin_{\\boldsymbol{\\beta}}\\|\\mathbf{\\Omega}^{1/2}\\mathbf{Y}-\\mathbf{\\Omega}^{1/2}\\mathbf{X}\\boldsymbol\\beta\\|^2\\qquad\\text{(This is OLS!)}}\n    \\end{align*}\n    \\onslide<5->{Hence}\n    \\begin{multline*}\n    \\onslide<5->{\\hat{\\boldsymbol\\beta}_\\text{WLS}=\\left((\\mathbf{\\Omega}^{1/2}\\mathbf{X})^\\top(\\mathbf{\\Omega}^{1/2}\\mathbf{X})\\right)^{-1}\\left(\\mathbf{\\Omega}^{1/2}\\mathbf{X}\\right)^\\top\\mathbf{\\Omega}^{1/2}\\mathbf{Y}}\\\\\\onslide<6->{=(\\mathbf{X}^\\top\\mathbf{\\Omega}\\mathbf{X})^{-1}\\mathbf{X}^\\top\\mathbf{\\Omega}\\mathbf{Y}}\n    \\end{multline*}\n\\end{frame}\n\n\\begin{frame}{But $\\sigma_i$'s are unknown!}\n\\begin{itemize}\n    \\item However, $\\sigma_1,\\ldots,\\sigma_n$ are usually unknown!\n    \\item<2-> Notice, that in OLS \n    $$\n    \\E[e_i^2] = \\Var[e_i]+(\\E[e_i])^2=\\Var[Y_i-\\hat{Y}_i]=\\sigma^2(1-h_{ii})\n    $$\n    \\item<3-> So $e_i^2$ in OLS estimates $\\sigma^2$\nand $|e_i|$ estimates $\\sigma$ if $h_{ii} \\approx 0$.\n    \\item<4-> Look at plots of $|e_i|$ from an OLS fit against $x_i$'s and $\\hat{Y}_i$'s to see how $\\sigma$ changes with predictors or fitted values.\n    \\item<5-> For example, if $|ei|$ increases linearly with $\\hat{Y}_i$, then we'll\n    fit \n    $$\n    |e_i| = \\alpha_0 + \\alpha_1\\cdot x_{i1} + \\ldots + \\alpha_k\\cdot x_{ik} + \\delta_i\n    $$ \n    and obtain the fitted values $\\widehat{|e_i|}$.\n    \\item<6-> Or, e.g., if $|\\epsilon_i|$ increases linearly w.r.t. $x_{i4}$ only, then we'll fit $|e_i|=\\alpha_0+\\alpha_1\\cdot x_{i4}+\\delta_i$\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Putting it all together}\n\\begin{enumerate}\n    \\item Regress $Y$ against predictor variable(s) as usual (OLS), and obtain $e_1,\\ldots, e_n$ \\& $\\hat{Y}_1, \\ldots, \\hat{Y}_n$.\n    \\item<2-> Regress $|e_i|$ against (all or some) predictors $x_1, \\ldots, x_k$ or fitted values $\\hat{Y}$.\n    \\item<3-> Let $\\widehat{|e_i|}$ be the fitted values for the regression in 2.\n    \\item<4-> Define $\\omega_i = 1/\\widehat{|e_i|}^2$ and feed them into \\verb|lm| command using the \\verb|weights| parameter.\n\\end{enumerate}    \n\\end{frame}\n\n\\begin{frame}{Example: diastolic blood pressure vs age}\nWe are interested in studying the relationship between diastolic blood pressure and age among healthy adult women 20 to 60 years old.\\\\~\\\\\n\n\\pause Fitting an OLS $\\text{dbp}_i=\\beta_0+\\beta_1\\cdot\\text{age}_i+\\epsilon_i$ gives:\n\\begin{figure}\n    \\includegraphics[width=.49\\textwidth]{plots/res_age.pdf}\\includegraphics[width=.49\\textwidth]{plots/abs_res_age.pdf}\n\\end{figure}    \n\\end{frame}\n\n\\begin{frame}[fragile]{OLS vs WLS}{\\url{https://github.com/zh3nis/MATH440/blob/main/chp11/dbp.R}}\n\\begin{footnotesize}\n\\begin{verbatim}\n> summary(ols)\n\nCoefficients:\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept) 56.15693    3.99367  14.061  < 2e-16 ***\nage          0.58003    0.09695   5.983 2.05e-07 ***\n---\nResidual standard error: 8.146 on 52 degrees of freedom\nMultiple R-squared:  0.4077,\tAdjusted R-squared:  0.3963 \n\\end{verbatim}\n\\pause\\begin{verbatim}\n> summary(wls)\n\nCoefficients:\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept) 55.56577    2.52092  22.042  < 2e-16 ***\nage          0.59634    0.07924   7.526 7.19e-10 ***\n---\nResidual standard error: 1.213 on 52 degrees of freedom\nMultiple R-squared:  0.5214,\tAdjusted R-squared:  0.5122 \n\\end{verbatim}\n\\end{footnotesize}\n\\end{frame}\n\n\\begin{frame}{Comments}\n\\begin{itemize}\n    \\item $\\s[b_1]$ reduced from 0.097 (OLS) to 0.079 (WLS)\n    \\item<2-> $R^2$ is no longer interpreted the same way in terms of amount of total variability explained by model.\n    \\item<3-> In WLS, standard inferences about coefficients may not be valid for small sample sizes when weights are estimated from the data.\n    \\item<4-> If MSE of the WLS regression is near 1, then our estimation of the $\\sigma_i$ function is okay. Here it's 1.21. \n\\end{itemize}\n\\end{frame}\n\n\n\\section{Ridge Regression}\n\\begin{frame}{Ridge Regression}\nIf some predictors are collinear, then columns of $\\mathbf{X}$ become linearly dependent, and $\\mathbf{X}$ loses its rank.\\\\~\\\\\n\\onslide<2->{\\structure{Exercise}: Show that for $\\mathbf{X}\\in\\mathbb{R}^{n\\times d}$ with $n\\ge d$\n$$\n\\mathrm{rank}(\\mathbf{X})<d\\quad\\Rightarrow\\quad\\nexists\\,{(\\mathbf{X}^\\top\\mathbf{X})^{-1}}.\n$$}%\n\\onslide<3->{This is bad for OLS, because $\\mathbf{X}^\\top \\mathbf{X}$ will not be invertible.\\\\~\\\\\n\nSimple solution: add penalty term into the cost function:\n$$\nQ(\\boldsymbol{\\beta})=\\|\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta\\|^2+\\lambda\\|\\boldsymbol{\\beta}\\|^2,\n$$\nwhere $\\lambda$ is a \\textit{hyperparameter}, to be chosen through a criterion like PRESS or training/validation approach.}\n\\end{frame}\n\n\\begin{frame}{Solving Ridge Regression}\n\\begin{theorem} The function $Q(\\boldsymbol{\\beta})=\\|\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta\\|^2+\\lambda\\|\\boldsymbol{\\beta}\\|^2$\nreaches its minimum at\n$$\n\\hat{\\boldsymbol{\\beta}}_{\\text{R}}=(\\mathbf{X}^\\top\\mathbf{X}+\\lambda\\mathbf{I})^{-1}\\mathbf{X}^\\top\\mathbf{Y}\n$$%\n\\end{theorem}\n\\begin{proof}\n\\vspace{-15pt}\n\\begin{align*}\n\\onslide<2->{Q(\\boldsymbol\\beta)&=}\\onslide<3->{(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)^\\top(\\mathbf{Y}-\\mathbf{X}\\boldsymbol\\beta)+\\lambda\\boldsymbol\\beta^\\top\\boldsymbol\\beta\\\\}\n\\onslide<4->{&=\\mathbf{Y}^\\top\\mathbf{Y}-\\boldsymbol\\beta^\\top\\mathbf{X}^\\top\\mathbf{Y}-\\mathbf{Y}^\\top\\mathbf{X}\\boldsymbol\\beta+\\boldsymbol\\beta^\\top\\mathbf{X}^\\top\\mathbf{X}\\boldsymbol\\beta+\\lambda\\boldsymbol\\beta^\\top\\mathbf{I}\\boldsymbol\\beta\\\\}\n\\onslide<5->{\\nabla_{\\boldsymbol\\beta}Q&=-\\mathbf{X}^\\top\\mathbf{Y}-\\mathbf{X}^\\top\\mathbf{Y}+2\\mathbf{X}^\\top\\mathbf{X}\\boldsymbol\\beta+2\\lambda\\mathbf{I}\\boldsymbol\\beta}\\onslide<6->{\\\\&=2(\\mathbf{X}^\\top\\mathbf{X}+\\lambda\\mathbf{I})\\boldsymbol\\beta-2\\mathbf{X}^\\top\\mathbf{Y}}\\onslide<7->{=\\mathbf{0}\\\\}\n\\onslide<8->{&(\\mathbf{X}^\\top\\mathbf{X}+\\lambda\\mathbf{I})\\boldsymbol\\beta=\\mathbf{X}^\\top\\mathbf{Y}\\quad\\Rightarrow\\quad}\\onslide<9->{\\boxed{\\hat{\\boldsymbol\\beta}_\\text{R}=(\\mathbf{X}^\\top\\mathbf{X}+\\lambda\\mathbf{I})^{-1}\\mathbf{X}^\\top\\mathbf{Y}}}\n\\end{align*}\n\\end{proof}\n\n\\onslide<10->{\\structure{Exercise.} Show that $(\\mathbf{X}^\\top\\mathbf{X}+\\lambda\\mathbf{I})$ is \\textit{always} invertible for $\\lambda>0$.}\n\\end{frame}\n\n\\begin{frame}{Chapter 7 example: Body fat}\n$n=20$ healthy females 25--34 years old.\n\\begin{itemize}\n\\item $x_1=$ triceps skinfold thickness (mm)\n\\item $x_2=$ thigh circumference (cm)\n\\item $x_3=$ midarm circumference (cm)\n\\item $Y=$ body fat (\\%)\n\\end{itemize}\n\nObtaining $Y_i$, the percent of the body that is purly fat, requires\nimmersing a person in water. Want to develop model based on simple body measurements that avoids people getting wet.\n\\end{frame}\n\n\\begin{frame}{Scatterplot}\n\\centering\\includegraphics[scale=0.45]{plots/scatterplot}\n\\end{frame}\n\n\\begin{frame}{Correlation coefficients}\n\\begin{center}\n\\includegraphics[scale=0.3]{plots/corr-matrix}\n\\end{center}\n\\pause There is high correlation among the predictors. \\pause For example\n$r = 0.92$ for triceps and thigh. These two variables are \\textit{essentially\ncarrying the same information}. \\pause Maybe only one or the other is really needed.\n\\end{frame}\n\n\\begin{frame}[fragile]{Effects of multicolinearity}\n\\begin{small}\n\\begin{verbatim}\nlm(formula = bodyfat ~ triceps + thigh + midarm, \n   data = bodyfat_data)\n\nCoefficients:\n            Estimate Std. Error t value Pr(>|t|)\n(Intercept)  117.085     99.782   1.173    0.258\ntriceps        4.334      3.016   1.437    0.170\nthigh         -2.857      2.582  -1.106    0.285\nmidarm        -2.186      1.595  -1.370    0.190\n\\end{verbatim}\n\\end{small}\n\n\\begin{itemize}\n    \\item\\pause Two of the three regression effects are {\\it negative}.\n    \\item\\pause Holding midarm\nand triceps constant, increasing the thigh circumference {\\it decreases} bodyfat.\n    \\item\\pause This may not make sense!\n\\end{itemize}  \n\\end{frame}\n\n\\begin{frame}[fragile]{OLS vs Ridge on bodyfat data}{\\url{https://github.com/zh3nis/MATH440/blob/main/chp11/ridge.R}}\n\\begin{columns}\n\\begin{column}{.6\\textwidth}\n\\includegraphics[height=.4\\textheight]{plots/ridge_lambda.pdf}\n\\end{column}\n\\begin{column}{.4\\textwidth}\n\\begin{footnotesize}\n\\begin{verbatim}\n> mean(ols$residuals^2)\n[1] 4.920244\n\n> mean((y-ridge_yhat)^2)\n[1] 5.340952\n\\end{verbatim}\n\\end{footnotesize}\n\\end{column}\n\\end{columns}\n\\begin{footnotesize}\n\\begin{verbatim}\n> coef(ols)\n(Intercept)     triceps       thigh      midarm \n 117.084695    4.334092   -2.856848   -2.186060 \n\n> t(coef(ridge))\n   (Intercept)   triceps     thigh     midarm\ns0   0.6555753 0.8074414 0.1588796 -0.3266744\n\\end{verbatim}\n\\end{footnotesize}\n\\end{frame}\n\n\\section{Robust Regression}\n\\begin{frame}{Back to outliers}\n\\begin{itemize}\n    \\item Leverages $h_{ii}$ and deleted residuals $t_i$ useful for finding outlying $\\mathbf{x}_i$ and $Y_i$ cases.\n    \\item\\pause Cook's $D_i$ and $\\text{DFFIT}_i$ indicate which cases are highly influencing the fit of the model.\n    \\item\\pause What to do with influential and/or outlying cases? Are they transcription errors or somehow (un)representative of the target population?\n    \\item\\pause Outliers are often interesting in their own right and can help in building a better model.\n    \\item\\pause \\textbf{Robust regression} weakens the effect of outlying cases on estimation to provide a better fit to the majority of cases.\n    \\item\\pause Useful in situations when there's no time for ``influence diagnostics'' or a more careful analysis.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{M-estimation}\n\\begin{itemize}\n    \\item Robust regression is effective when the error distribution is not normal, but heavy-tailed.\n    \\item\\pause \\textbf{M-estimation} is a general class of estimation methods. \\pause\n    $$\n    \\min_{\\boldsymbol\\beta}\\sum_{i=1}^n\\rho(Y_i-\\mathbf{x}_i^\\top\\boldsymbol\\beta)\n    $$\n    \\pause where $\\rho(\\cdot)$ is some function.\n    \\item\\pause $\\rho(u)=u^2$ gives OLS\n    \\item\\pause $\\rho(u)=|u|$ gives \\textbf{least absolute residual} (LAR) regression\n    \\item\\pause Huber's method is a compromise between OLS and LAR. \\pause It looks like $u^2$ for $u$ around zero, and like $|u|$ for $u$ further away from zero.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Iteratively reweighted least squares (IRLS)}\n\\begin{small}\nOutlying residuals are (iteratively) given less weight in the estimation process.\\\\~\\\\\n\n\\begin{algorithm}[H]\n\\DontPrintSemicolon\n\\textbf{Input}: $\\{(\\mathbf{x}_i, {y}_i)\\}_{i=1}^n$\\;\nFit OLS. Let $\\mathbf{e}=\\mathbf{y}-\\mathbf{X}\\hat{\\boldsymbol\\beta}_\\text{OLS}$\\;\nInitialize weights: $\\omega_i\\leftarrow\\frac{1}{e_i^2}$, $\\mathbf{\\Omega}=\\diag[\\omega_1,\\ldots,\\omega_n]$\\;\nFit WLS: $\\hat{\\boldsymbol\\beta}_{\\text{WLS}}\\leftarrow(\\mathbf{X}^\\top\\mathbf{\\Omega X})^{-1}\\mathbf{X}^\\top\\mathbf{\\Omega}\\mathbf{Y}$\\;\nEstimate: $\\hat{\\sigma}\\leftarrow\\mathrm{median}_i\\left\\{\\frac{|y_i-\\mathbf{x}_i^\\top\\hat{\\boldsymbol\\beta}_{\\text{WLS}}|}{\\Phi^{-1}(0.75)}\\right\\}$\\;\nUpdate weights: $\\omega_i\\leftarrow w\\left(\\frac{y_i-\\mathbf{x}_i^\\top\\hat{\\boldsymbol\\beta}_{\\text{WLS}}}{\\hat{\\sigma}}\\right)$, where\n$$\nw(u)=\\begin{cases}\n1,\\quad &|u|<1.345\\\\\n\\frac{1.345}{|u|},&|u|>1.345\n\\end{cases}\n$$\\;\\vspace{-10pt}\nRepeat steps 4--6 until $\\hat{\\sigma}$ and $\\hat{\\boldsymbol\\beta}_{\\text{WLS}}$ stabilize.\\;\n\\textbf{Output}: $\\hat{\\boldsymbol\\beta}_{\\text{WLS}}$\n\\caption{IRLS}\n\\end{algorithm}\n\\end{small}\n\\end{frame}\n\n\\begin{frame}[fragile]{IRLS example}{\\url{https://github.com/zh3nis/MATH440/blob/main/chp11/irls.R}}\n\\begin{verbatim}\nrequire(foreign)\nrequire(MASS)\n\ncdata <- read.dta(\n    \"https://stats.idre.ucla.edu/stat/data/crime.dta\")\n\nplot(crime ~ poverty, data=cdata)\nols <- lm(crime ~ poverty, data = cdata)\nabline(ols)\n\nirls <- rlm(crime ~ poverty, data=cdata)\nabline(irls, col='blue')\n\nsummary(ols)\nsummary(irls)\n\\end{verbatim}    \n\\end{frame}\n\n\\begin{frame}{IRLS example}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=.9\\textwidth]{plots/ols_irls.pdf}\n\\end{figure}\n\\end{frame}\n\n\\end{document}", "meta": {"hexsha": "7710e88ce2c77b1fe98a2a9668332d87c3cecf59", "size": 16072, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/11 Remedial Measures/main.tex", "max_stars_repo_name": "zh3nis/MATH440", "max_stars_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/11 Remedial Measures/main.tex", "max_issues_repo_name": "zh3nis/MATH440", "max_issues_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/11 Remedial Measures/main.tex", "max_forks_repo_name": "zh3nis/MATH440", "max_forks_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6346153846, "max_line_length": 325, "alphanum_fraction": 0.694001991, "num_tokens": 5685, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.42829599139892094}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n% \\marginpar{Friday\\\\ 2019-12-13, \\\\ compiled \\\\ \\today}\n% \\section*{Fri Dec 13 2019}\n\n% We discuss the maximum mass of stars. \n\n% We were able to give meaning to the parameter \\(a\\): the pressure is given by \n% %\n% \\begin{align}\n%   P(r) =\n%   \\frac{2 \\pi}{3} G \\rho_c^2 a^2 \\qty(\\exp(- \\frac{r^2}{a^2}) - \\exp(- \\frac{R^2}{a^2}))\n% \\,,\n% \\end{align}\n% %\n% so we can see that \n% %\n% \\begin{align}\n% a = \\qty(\\frac{3M}{4 \\pi \\rho_c \\sqrt{6}})^{1/3}\n% \\,,\n% \\end{align}\n% %\n% and then we got an expression for the central pressure \\(P_c\\): the parameter multiplying it is approximately \\(\\num{.44}\\), while more accurate models give: if \\(\\gamma = 5/3\\) (ideal gas) we get \\(\\num{.48}\\) whiile if \\(\\gamma = 4/3\\) (ultrarelativistic) we get \\(\\num{.36}\\).\n\n% We have the relation \n% %\n% \\begin{align}\n%   P_c = \\frac{\\rho _c }{\\overline{m}} k_B T_c\n% \\,,\n% \\end{align}\n% %\n% which we use to get the last relation from last time. \n\n% This allows us to get some figures for main sequence (hydrogen burning) stars. \n\n% What is the maximum mass for Main Sequence stars? \n\nIn the core of the star, we have both nonrelativistic and relativistic material in equilibrium: electrons and protons are nonrelativistic, while photons are relativistic.\nWe have discussed earlier that if most of the material in a star were relativistic it would become unstable (since, as \\(\\gamma \\to 4/3\\), the binding energy approaches 0); let us then discuss the composition of the star. \n\n% A star becomes unstabel when most of its material becomes ultrarelativistic: then, its total energy goes from a negative value to 0 and the adiabatic index approaches \\(4/3\\). \n\n% Suppose that the central energy is partly given by radiation and partly by matter. \n% We write\nWe can decompose the pressure at the core into the fractions due to nonrelativistic matter and to radiation:\n%\n\\begin{align}\n  P_c = P_m  + P_r = \\beta P_c + (1 - \\beta )P_c\n\\,,\n\\end{align}\n%\nwhere we define \\(\\beta \\in (0,1)\\) as the fraction of the core pressure which is due to matter: \\(\\beta = P_m / P_c\\).\n\n% where the terms of the two sums exactly correspond to each other, and\nThe two contributions can be separately expressed as:\n%\n\\begin{align}\n  \\beta P_c = P_m &= \\frac{\\rho _c k_B T_c}{\\overline{m}} \\\\\n  (1 - \\beta ) P_c = P_r &= \\frac{1}{3} a T^4\n\\,,\n\\end{align}\n%\nwhere \\(a\\) is the radiation constant, related to the Stefan-Boltzmann constant \\(\\sigma \\):\n%\n\\begin{align}\n  a = \\frac{\\pi^2   k_B^2}{15 \\hbar^3 c^3}\n\\,.\n\\end{align}\n\nWe can then relate \\(\\beta \\) to the mass of the star: in order to simplify the core temperature, we start by computing\n%\n\\begin{align}\n  \\frac{\\qty(\\beta P_c )^{4}}{(1 - \\beta ) P_c} &= \\frac{\\rho _c^{4}}{\\overline{m}^{4}} \\qty(k_B T_c)^{4} \\frac{3}{a T_c^{4}}  \\\\\n  \\frac{\\beta^{4}}{1 -\\beta } P_c^3 &= \\frac{3}{a} \\qty(\\frac{k_B \\rho _c}{\\overline{m}})^{4}\n\\,,\n\\end{align}\n%\nwhich we can invert to find an expression for the core pressure \\(P_c \\) in terms of \\(\\beta \\), which we then compare to the expression we found for the core pressure as a result of the Clayton model: \n% %\n% \\begin{align}\n%   \\frac{1 - \\beta }{\\beta^{4}} P_c^{-3} = \\frac{a}{3}\n%   \\qty(\\frac{k_B \\rho _c }{\\overline{m}})^{-4}\n% \\,.\n% \\end{align}\n% Inverting this we can eliminate the temperature dependence: \n%\n\\begin{align}\n  P_c = \\qty(\\frac{3}{a} \\frac{1 - \\beta  }{\\beta^{4}})^{1/3} \\qty(\\frac{k_B \\rho _c }{\\overline{m}})^{4/3}\n  &= \\qty(\\frac{\\pi }{36})^{1/3} G M^{2/3} \\rho _c^{4/3} \\\\\n  \\qty(\\frac{\\pi }{36})^{1/3} G M^{2/3} \n  &= \\qty(\\frac{3}{a} \\frac{(1-\\beta )}{\\beta^{4}})^{1/3}\n  \\qty(\\frac{k_B}{\\overline{m}})^{4/3}\n  \\label{eq:maximum-mass-main-sequence}\n\\,,\n\\end{align}\n%\nthe core density simplifies! \n\nSo, if we compare stars at the same stage of fusion so that \\(\\overline{m}\\) is constant, we have \\(M \\propto f(\\beta ) = (1 - \\beta )^{1/2} / \\beta^2\\).  \n% so as \\(\\beta \\) decreases, \\(M\\) increases. \n\n\\(f(\\beta )\\) decreases as \\(\\beta \\) increases, and it diverges to \\(+ \\infty \\) for \\(\\beta \\to 0\\). \n\nLooking at the plot the other way, the heavier the star, the larger the contribution of radiation to the core pressure, which is what \\(1-\\beta \\) quantifies.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/beta_star_core_pressure.pdf}\n\\caption{A plot of \\(M\\) in terms of \\(\\beta \\).}\n\\label{fig:beta-core-pressure}\n\\end{figure}\n% \\todo[inline]{Figure made quickly, to improve by scaling it correctly, making it vector, setting the text in the right font. The plot is ready, but the units don't seem to work! }\n\nThis makes sense intuitively: heavier stars reach higher temperatures and densities, so they have more radiation in the core. \n\nWe know that for \\(\\beta \\to 0\\) the star is surely unstable, but the instability is actually reached earlier, since even before the gravitational binding energy being exactly zero large parts of the star can be flung out as stellar winds.\nProper considerations about what an appropriate critical value of \\(\\beta \\) should be allow us to bound the stellar mass from above, at around \\(50 M_{\\odot}\\). \n\n% [Plot of \\(1 - \\beta \\) versus \\(M / M_{\\odot} \\), showing this.]\n\n\\subsection{Degenerate electron gas}\n\nNow, we will deal with the degenerate electron gas in stars, and see what is its effect on the minimum and maximum mass of a star.  \n\nThe distribution function of the electrons, which are fermions, is given by \n%\n\\begin{align}\n  f(p) = \\qty[\\exp(\\frac{\\epsilon _p - \\mu }{k_B T})+1]^{-1}\n\\,,\n\\end{align}\n%\nwhere \\(\\epsilon _p = \\sqrt{m^2 c^{4} + p^2 c^2}\\). With it, we can calculate the number density of electrons: \n%\n\\begin{align}\nn_e = \\frac{g_s}{h^3} \\int \\dd[3]{p} f(p)\n\\,,\n\\end{align}\n%\nwhere \\(g_s\\), the number of helicity states of the electron, is equal to 2.\n\nWe want to consider the degenerate case for this distribution, which corresponds to the saturation of all the low-energy configurations in phase space: this is known as a Fermi gas. \nAs the temperature approaches zero, the phase space distribution approaches the configuration \n%\n\\begin{align}\nf(p) = \\lim_{T \\to 0} \\qty[\\exp(\\frac{\\epsilon_p - \\mu }{k_B T})+1]^{-1}= \n\\begin{cases}\n  1 \\qquad \\epsilon _p < \\mu  \\\\\n  0 \\qquad \\epsilon _p > \\mu \n\\,.\n\\end{cases}\n\\end{align}\n\nThe chemical potential yields a critical energy, known as the Fermi energy, \\(\\epsilon _F = \\mu \\), which is also tied to a Fermi momentum:\n%\n% Then, as \\(T \\rightarrow 0\\) we get: \\(f(\\epsilon _p) = 1\\) if \\(\\epsilon _p \\leq \\epsilon _F\\) and \\(f(\\epsilon _p) = 0 \\) if \\(\\epsilon _p > \\epsilon _F\\); we can express this energy in terms of the momentum: \n%\n\\begin{align}\n  \\epsilon_F^2 = c^2p_F^2 + m^2 c^{4}\n\\,.\n\\end{align}\n\nThe number density of electrons in this configuration is given by the integral mentioned before: since the distribution is spherically symmetric we have\n%\n\\begin{align}\n  n_e = 2 \\int_{0}^{p_F} \\dd{p} p^2 4 \\pi \\frac{1}{h^3}\n  = \\frac{8 \\pi }{3} \\qty(\\frac{p_F}{h})^{3}\n\\,,\n\\end{align}\n%\n% where we have a factor of \\(2\\) to account for the spin-\\(1/2\\) nature of the electrons. \n% This means that \nwhich allows us to express the Fermi momentum in terms of the number density of electrons:\n%\n\\begin{align}\n  p_F = \\qty(\\frac{3n_e}{8 \\pi })^{1/3} h\n\\,.\n\\end{align}\n\nIn natural units, this is roughly \\(p_F \\approx \\num{6.6} \\sqrt[3]{n_e}\\).\n\nThe energy density is given by the expression\n%\n\\begin{align}\n  \\rho = \\frac{2}{h^3} \\int_{0}^{p_F} 4 \\pi p^2\\dd{p} \\epsilon _p\n\\,,\n\\end{align}\n%\nwhich we can consider in either the nonrelativistic or the ultrarelativistic limit --- the analytic integral is complicated and not very enlightening. \n\n\\paragraph{Nonrelativistic limit}\n\n% In the nonrelativistic limit we find \nIn this limit the energy is approximately\n%\n\\begin{align}\n  \\epsilon _p = mc^2 + \\frac{p^2}{2m}\n\\,,\n\\end{align}\n%\nso in the computation we need to integrate a polynomial: the result is\n%\n\\begin{align}\n  \\rho = n \\qty(mc^2 + \\frac{3}{10} \\frac{p_F^2}{m})\n\\,,\n\\end{align}\n%\nwhere the first term corresponds to the rest-energy of the electrons, while the second gives their kinetic energy.\nWe have derived earlier the following expression for the pressure of a nonrelativistic gas:\n%\n\\begin{align}\n  P  = \\frac{2}{3} \\frac{E_k}{V}\n\\,,\n\\end{align}\n%\n% where \\(E/V\\) is the kinetic energy density. \nand \\(E_k / V\\) is precisely the kinetic energy density, the second term of the expression for the total energy density \\(\\rho \\); \nso for our nonrelativistic Fermi gas we will have:\n%\n\\begin{align}\n  P = n \\frac{p_F^2}{5m} \n\\,.\n\\end{align}\n\nSince the Fermi momentum \\(p_F\\) can be written as a function of the number density \\(n_e\\), so can the pressure \\(P\\): we find \n%\n\\begin{align}\nP = \\underbrace{\\frac{h^2}{5m} \\qty(\\frac{3}{8 \\pi })^{2/3}}_{K_{NR}} n_e^{5/3}\n\\,.\n\\end{align}\n\n\\paragraph{Ultra relativistic limit}\n\n% In\n% %\n% \\begin{align}\n%   P = k_{NR} n^{5/3}\n% \\,,\n% \\end{align}\n% %\n% where \n% %\n% \\begin{align}\n%   k_{NR} = \\frac{h^2}{5m} \\qty(\\frac{3}{8 \\pi })^{2/3}\n% \\,.\n% \\end{align}\n%\n\nIn the relativistic case, on the other hand, we can approximate the energy as \\(\\epsilon _p \\approx cp\\), so the energy density will be given by \n%\n\\begin{align}\n\\rho = \\frac{3}{4} n \\rho _F c\n\\,.\n\\end{align}\n\nIn this case, we also know that the pressure becomes \n%\n\\begin{align}\n  P = \\frac{1}{3} \\frac{E_k}{V}\n\\,,\n\\end{align}\n%\nso we find \n%\n\\begin{align}\nP = \\underbrace{\\frac{hc}{4} \\qty(\\frac{3}{8 \\pi })^{1/3}}_{K_{UR}} n^{4/3} \n\\,.\n\\end{align}\n\n\\paragraph{Fermion gas classification}\n\nWe have discussed some expressions describing a non-relativistic or ultrarelativistic degenerate fermion gas. \n\nWe have derived our results with the assumption \\(T \\to 0\\), but a gas can behave very similarly with nonzero temperatures as well. \nWhat is the temperature threshold under which the gas behaves in a degenerate-like way?\nWe will not discuss how the transition region looks, but if \\(k_B T \\ll \\epsilon _F\\) then the gas behaves like a degenerate one, while if \\(k_B T \\gg \\epsilon _F\\) then there will be many unfilled gaps in the phase space distribution, so the gas will not be degenerate. \n\nRecall that \\(p_F \\propto n_e^{1/3}\\): therefore, in a log-log plot of temperature \\(T\\) versus density of possible electron densities \\(n_e\\) we can draw a line distinguishing the degenerate and nondegenerate cases, with the critical temperature becoming higher for higher \\(n_e\\).\n\n% \\todo[inline]{Is it really a straight line though? If the criterion is indeed to compare \\(k_B T\\) and \\(\\epsilon _p\\) then I'd expect a curve, since \\(\\epsilon _F\\) is not a polynomial function of \\(p_F\\)\\dots}\n\n% We make a plot: on the \\(x\\) axis we have the number density in \\(\\SI{}{m^{-3}}\\), on the \\(y\\) axis we have the temperature in \\(\\SI{}{K}\\).\nHaving distinguished the degenerate and nondegenerate regions, we can distinguish the relativistic and nonrelativistic ones: for the nondegenerate case, as is usual, we reach the relativistic condition if we increase the temperature. \n\nIn the degenerate case this is not really the case: as long as the gas is degenerate, the temperature does not really matter, and the gas becomes relativistic when the Fermi energy \\(\\epsilon _F\\) becomes larger than the mass of the fermion.\nSince \\(\\epsilon _F\\) is only a function of the number density, this means that the gas can become relativistic at arbitrarily low temperatures as long as it is dense enough.\n\n% \\todo[inline]{Add plot --- maybe we can do a chromatic region plot, integrating numerically the distribution and coloring the region based on the fraction of relativistic particles, and for the degeneracy measure in some way how ``sharp'' the boundary is between the filled and unfilled regions?}\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/relativisticity_degeneracy.pdf}\n\\caption{Regions in which an electron gas is degenerate (red) and/or relativistic (blue), depending on its density \\(n_e\\) and on its temperature \\(T\\). The colors are decided defining ``degenerate'' as having \\(T < T_F = \\epsilon _F - m_e c^2\\) and ``relativistic'' as having the average kinetic energy of an electron (\\(E_k = (\\gamma - 1) m_e c^2\\)), be larger than \\(m_e c^2\\). The transition region for both spans an order of magnitude, symmetrically around the equality condition. \nOrders of magnitude are also given regarding common objects; ``iron core'' refers to the core of a massive star in the Silicon burning phase.}\n\\label{fig:relativisticity_degeneracy}\n\\end{figure}\n\n\n% For more details, see the code at \\url{https://github.com/jacopok/notes/blob/master/ap_first_semester/astrophysics_cosmology/figures/degenerate_relativistic.ipynb}.}\n\n% We divide the plot into: \n% \\begin{enumerate}\n%     \\item Classical UR: \\(P \\propto n k_B T\\);\n%     \\item classical NR (like the Sun);\n%     \\item degenerate NR: \\(P = K_{NR} n^{4/3}\\)\n%     \\item degenerate UR. \n% \\end{enumerate}\n\n% Classical vs degenerate is marked by a line similar to \\(T \\sim n\\), while we have NR for both \\(T\\) and \\(n\\) lower than certain critical values (since a degenerate gas can become ultrarelativistic even at low temperatures! this is the point).\n\n\\paragraph{Application to the Sun}\n\nAs we have discussed earlier, the core temperature, pressure and density of the Sun are related by the following relation:\n%\n\\begin{align}\n  P_c = \\frac{\\rho _c}{\\overline{m}} k_B T_c\n\\,.\n\\end{align}\n\n% and it can be (easily?) shown that \nThe average mass which appears here is a function of the chemical composition of the interior: we can neglect all the metals and only consider the mass fractions of hydrogen (\\(x_1 \\)) and of helium (\\(x_4 \\)): \n%\n\\begin{align}\n  \\overline{m} = 2 m_H \\times \\frac{1}{1 + 3x_1 + 0.5 x_4}\n\\,.\n\\end{align}\n%\n% where \\(x_{1, 4}\\) are the concentrations of hydrogen and helium respectively. \n\n\\todo[inline]{This expression works well in the limits of \\(x_1 =1\\) and \\(x_4 = 1\\), but where does it come from? I would have expected \\(\\overline{m} = (x_1 m_H  + x_4 m_{He} ) /2\\)\\dots}\n\nThe Clayton model gave us an expression for the central pressure \\(P_c\\), which we turned into one for the central temperature \\(T_c\\): \n%\n\\begin{align}\nP_c &=\\approx \\qty(\\frac{\\pi }{36})^{1/3} G M^{2/3} \\rho _c^{4/3} \\\\\n k_B T_c &\\approx \\qty(\\frac{\\pi }{36})^{1/3} G \\overline{m}\n  M^{2/3} \\rho _c^{1/3}\n\\,,\n\\end{align}\n%\nhowever when deriving it we not consider the effect of the fact that the gas there may be at least party degenerate.\n\nLet us consider a different approximation: suppose that the electrons in the core are fully degenerate and nonrelativistic, while the ions (whose density is \\(n_i\\), which by local neutrality is also equal to \\(n_e = \\rho _c / \\overline{m}\\)) are completely classical.\\footnote{In order to see why it makes sense to consider them as classical while the electrons are degenerate, let us look at the fact that in the nonrelativistic approximation the Fermi energy is given by \\(\\epsilon _F = p_F^2 / 2m \\sim m^{-1} n^{2/3}\\), so the critical temperature needed for a Fermi gas to become degenerate depends on the number density as well as the mass of the particle: for a higher-mass particle, the Fermi energy is lower.\n\nThe electrons being degenerate means that the temperature of the core is (roughly speaking) lower than their Fermi energy; the Fermi energy of the ions however is at least three orders of magnitude lower, so it makes sense that it is not as low as the Fermi temperature of the ions.\n\nIn order to have some numbers at hand, with a number density like that of the core of the Sun the Fermi temperature for electrons is \\(\\sim \\SI{11}{MK}\\), while the Fermi temperature for protons is a measly \\(\\sim \\SI{6000}{K}\\). The actual temperature of the core is \\(T_c \\sim \\SI{15}{MK}\\), slightly above the Fermi temperature of electrons. It is close enough that modelling them as degenerate works, while the assumption of the ions being nondegenerate is completely valid.}\nOur estimate for the central pressure will need to account for both electrons and ions:\n% To estimate the maximum achievable central temperature we do: \n%\n\\begin{align}\n  P_c = k_{NR} n_{e}^{5/3} + n_i k_B T_c\n\\,.\n\\end{align}\n%\n\nLet us equate this expression with the one given by the Clayton model for the central pressure: we find\n%\n\\begin{align}\n  \\qty(\\frac{\\pi}{36})^{1/3} G M^{2/3} \\rho_{c}^{4/3}\n  &= k_{NR} \\qty(\\frac{\\rho_c}{m_{H}})^{5/3} + \\frac{\\rho_{c}}{m_H} k_B T_c \\\\\n  k_B T_c &= \\underbrace{\\qty(\\frac{\\pi}{36})^{1/3} G m_{H} M^{2/3}}_{A} \\rho_{c}^{1/3} - \\underbrace{k_{NR} m_H^{-2/3}}_{B} \\rho _c^{2/3}\n\\,.\n\\end{align}\n%\n\nWe can then ask what is the maximum temperature \\(T_c\\) we can reach for a given mass \\(M\\) if we vary the core density \\(\\rho _c\\):\nthis can be calculated to be \n% (((np.pi/36) * ac.G**3 * ac.m_p**3 )/ (2 * ac.h**6 / 5**3 / ac.m_e**3 * (3/8 /np.pi)**2 /ac.m_p**2)).to(u.kg/u.m**3 / u.M_sun**2)\n%\n\\begin{align}\n\\rho_{c}^{\\text{max}} = (A/ 2B)^{3} \\approx \\SI{5e7}{kg/m^3} \\qty( \\frac{M}{M_{\\odot}})^2\n\\,,\n\\end{align}\n%\nwhere we have \n%\n\\begin{align}\n  k_B T_c = \\frac{A^2}{4B} = \\qty(\\frac{\\pi }{36})^{2/3} \\frac{G^2m_H^{8/3}}{4 k_{NR}} M^{4/3}\n  \\approx \\SI{5.7}{keV} \\qty( \\frac{M}{M_{\\odot}})^{4/3}\n\\,.\n\\end{align}\n\n% Now, we can set this temperature to be larger than the ignition temperature for any process we want, to see whether it will happen. \nThis allows us to estimate the minimum mass a star needs to have in order to fuse hydrogen: we just need to set \\(T_c\\) to be equal to the ignition temperature \\(T_c = T _{\\text{ign}} \\approx \\SI{1}{keV}\\) and we find\n%\n\\begin{align}\n  M _{\\text{min}} = \n  \\qty(\\frac{36}{\\pi })^{1/2} \n  \\qty(\\frac{4 k_{NR}}{G^2m_H^{8/3}})^{3/4}\n  \\qty(k_B T _{\\text{ign}})^{3/4}\n  \\approx \\SI{.27}{M_{\\odot}}\n\\,.\n\\end{align}\n\nThis is a much better estimate than the one we found earlier since we are now accounting for the degenerate Fermi gas nature of the electrons in the core (this lowers the estimate, since it means that even at relatively low temperatures there will be electrons with high energy) and since we are computing the core density \\(\\rho _c\\) instead of the average density \\(\\overline{\\rho}\\). \n\n\\todo[inline]{The estimate is\\dots still not great really, right? it is still 3 times larger than the correct value of \\(\\num{.08} M_{\\odot}\\)! How do we account for such a discrepancy?}\n\n\\paragraph{Expressing the result with coupling constants}\n\nThe gravitational potential energy between two hydrogen nuclei separated by a distance equal to their (reduced!) Compton wavelength \\(r = \\hbar / m_H c\\) is \n%\n\\begin{align}\nE_g = - \\frac{G m_H^2}{r} = - \\frac{G m_H^{3}c }{\\hbar}\n\\,.\n\\end{align}\n\nComparing this to the rest energy of an electron, \\(E = m_H c^2\\), is the way to calculate the \\emph{gravitational coupling constant} \\(\\alpha _G\\), a dimensionless parameter quantifying the ``strength'' of the gravitational interaction between hydrogen nuclei:\n%\n\\begin{align}\n  \\alpha_{G} = \\frac{E_g}{E} =  \\frac{G m_H^2}{\\hbar c} \\sim \\num{5.9e-39}\n\\,.\n\\end{align}\n\nIn natural units, \\(\\alpha _G = m_H^2 / m_P^2\\).\n\nBy a similar line of reasoning we find the electromagnetic coupling constant:\n%\n\\begin{align}\n  \\alpha_{EM} = \\frac{e^2}{4 \\pi \\epsilon_{0} \\hbar c} \\approx \\frac{1}{137}\n\\,,\n\\end{align}\n%\nwhich is \\emph{enormously} greater. \n\nIn terms of the gravitational coupling constant the minimum mass we found can be written as \n%\n\\begin{align}\n  M _{\\text{min}} \\approx\n  16 \\qty(\\frac{k_B T _{\\text{ign}}}{m_e c^2})^{3/4}\n  \\alpha_{G}^{-3/2} m_H\n\\,.\n\\end{align}\n\nIf \\(T _{\\text{ign}} \\sim \\SI{1.5e6}{K}\\), one tenth of the temperature of the Sun, we find \n\\todo[inline]{Is \\SI{0.1}{keV} really enough to reach ignition? This seems to contradict what was said earlier\\dots}\n%\n\\begin{align}\n  M _{\\text{min}} \\sim \\num{.03} \\alpha_{G}^{-3/2} m_H\n\\,.\n\\end{align}\n\nWe can apply a similar line of reasoning to the formula we found for the maximum mass: taking equation \\eqref{eq:maximum-mass-main-sequence}  with a critical fraction of nonrelativistic matter of \\(\\beta = \\num{.5}\\) and \\(\\overline{m} = \\num{.61} m_H\\) we get a result which, once again, scales with \\(\\alpha _G^{-3/2} m_H\\):\n%\n\\begin{align}\n  M _{\\text{max}} \\approx 56 \\alpha_{G}^{-3/2} m_H\n\\,.\n\\end{align}\n\nThis hints to the fact that \\(m_{*} = \\alpha_{G}^{-3/2} m_H \\) is an important characteristic mass for all of stellar evolution.\n\nThis is around \\(\\num{1.85} M_{\\odot}\\), and it corresponds to a number of nucleons of\n%\n\\begin{align}\n  N_{*} = \\frac{m_{*}}{m_H} \\approx \\num{2e57}\n\\,.\n\\end{align}\n\n\\section{Stellar remnants}\n\n\\subsection{Full degeneracy and white dwarfs}\n\n% Let us now suppose that the core of a star is held together by the pressure of degenerate electrons alone: we will discuss \\emph{white dwarfs}.\nWhite dwarfs are the remnants of low-mass stars who have exhausted the elements they are able to fuse in their core. They glow, emitting thermal radiation, which causes their temperature to slowly decrease until they become brown dwarfs. \nThey are dim but observable; the closest one to the Solar System is Sirius B, a companion to the brightest star in the night sky.\n\nThey are of interest to us since they allow us to apply the theory of degenerate Fermi gasses once more: they are very dense objects, since there is no fusion-induced pressure gradient inside them to balance gravity, and the electrons inside them form a degenerate gas.\n\n% We define \nThe number density of electrons inside a white dwarf is given by\n%\n\\begin{align}\n  n_e = Y_{e} \\frac{\\rho_{c}}{m_H}\n\\,,\n\\end{align}\n%\nwhere \\(Y_e = (1 + x_1) /2\\) quantifies the number of electrons per baryon (\\(x_1 \\) is the hydrogen mass fraction).\n\n\\todo[inline]{Why would \\(Y_e\\) be given by that expression? hydrogen has one electron per each baryon, but helium also has half an electron per baryon\\dots If the white dwarf was exclusively hydrogen, would we not expect \\(Y_e = 1/2\\)?}\n\nLet us start by assuming that the matter is nonrelativistic: then  \nthe pressure is given by\n%\n\\begin{align}\n  P = k_{NR} n_e^{5/3} = k_{NR} \\qty(\\frac{Y_e \\rho_{c}}{m_H})^{5/3}\n\\,,\n\\end{align}\n%\nwhich as usual we compare to the results of the Clayton model:\n%\n\\begin{align}\n  P_c = \\qty(\\frac{\\pi }{36})^{1/3} G M^{2/3} \\rho_{c}^{4/3}\n\\,.\n\\end{align}\n\nEquating these two we find\n%\n\\begin{align}\n  \\rho_{c} \\approx \\frac{\\num{3.1}}{Y_e^{5}} \\qty(\\frac{M}{m_{*}})^2 \\frac{m_H}{(h / m_e c^2)^{3}}\n\\,.\n\\end{align}\n\n% \\todo[inline]{\n%   Missing square on the \\(M / m_*\\)?\n% }\n\nIf, on the other hand, we were to assume that the matter is ultrarelativistic the pressure would be given by\n%\n\\begin{align}\nP = k_{UR} n_e^{4/3} \n= k_{UR}\\qty(\\frac{Y_e \\rho_{c}}{m_H})^{4/3}\n\\,,\n\\end{align}\n%\nso, instead of getting an expression for the central density \\(\\rho _c\\), we would find\n%\n\\begin{align}\n  k_{UR} \\qty(\\frac{Y_e \\rho_{c}}{m_H})^{4/3} \\approx \n  \\qty(\\frac{\\pi }{36})^{1/3} G M^{2/3} \\rho_{c}^{4/3}\n\\,:\n\\end{align}\n%\nin this limit the expression becomes independent of \\(\\rho_{c}\\)!\n\nThis gives us a limit mass, since as we increase the mass of a white dwarf which is not relativistic we increase its density and thus its temperature, making it closer to being relativistic, and this is the mass we get for the fully relativistic configuration (which is unstable because of the usual binding energy considerations).\n\nThe limit is known as the Chandrasekhar mass, the largest mass at which a fully degenerate white dwarf can support itself:\n%\n\\begin{align}\n  M_{CH} = \n  \\qty(\\frac{36}{\\pi } )^{1/2} \\qty(\\frac{Y_e}{m_H})^2\n  \\qty(\\frac{k_{UR}}{G})^{3/2} \\approx 2.3 Y_e^2 m_{*} \\approx 4.3 Y_e^2 M_{\\odot} \\approx 1.4 M_{\\odot}\n\\,.\n\\end{align}\n\n% This is the maximum mass of a white dwarf to remain stable, held together by the degeneracy pressure of electrons. \n% Above this, it becomes a neutron star.\n\n% \\todo[inline]{Pacciani includes some more detailed considerations about the Chandrasekhar mass.}\n\n% \\todo[inline]{Something peculiar about the Chandrasekhar mass is that its derivation does not address the actual mechanism of the collapse (which is electron capture by nuclei, I think). If I understand correctly, this is because as \\(M \\to M _{\\text{Ch}}\\) the core density diverges, so something or other is \\emph{bound} to happen, be it electron capture, the formation of an event horizon\\dots}\n\n\\end{document}", "meta": {"hexsha": "cbf22423aae1122d37a0455ac51d98bf232d8c99", "size": 24284, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/astrophysics_cosmology/13dec.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/astrophysics_cosmology/13dec.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/astrophysics_cosmology/13dec.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 44.7219152855, "max_line_length": 717, "alphanum_fraction": 0.6941195849, "num_tokens": 7574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.42829597885163484}}
{"text": "\\section{Problem and Approach}\n\\label{sec:description}\n\nHere we will give a specification of the problem, and a detailed approach (i.e. the design of solution).\nIn order to simplify the problem and keep MLPs as simple as possible, one MLP will be used to check only the graphs (models) with a certain number of nodes and certain types of edges.\nIn other words, each type of graph will have its own MLP.\nNotice that all the MLPs will have the same overall architecture.\nThe only difference will be the number of nodes at each layer.\nThat is only the bisimulation between graphs with the same scale will be studied.\nThe problem of the project become that if an MLP is possible to compute the bisimulation equivalence of two same scale models and how well it can do.\nThe basic steps of approach are as follows.\n\\begin{itemize}\n    \\item Generate a standard distinguishing algorithm.\n    \\item Based on the standard algorithm, develop a dataset generator.\n    \\item Construct MLPs that can accept graphs pairs and output judgement.\n    \\item Do experiments on the performance of the MLP with different training sets. \\footnote{N.B. this step will be stated independently in Section \\ref{sec:experiment}}\n\\end{itemize}\n\n\n\\subsection{Standard Bisimulation Algorithm}\nFor the first step, we will directly use the algorithm that solves the \\emph{relational coarsest partition problem} \\cite{Paige1987}, i.e. given the relation $E$ and initial partition $P$ over a set $U$ find the partition $P$ that \\textquotedblleft every other stable partition is a refinement of it \\textquotedblright.\nFrom the perspective of set-theory, it is the same as solving bisimulation equivalence \\cite{Dovier2004}.\nNamely, if each block of the relational coarsest partition of the union of two graphs has nodes from both multi-directed graphs, these two graphs are bisimilar (see the set-perspective definition in Section \\ref{sec:background}).\nMoreover, compared with the algorithm given by Kanellakis and Smolka \\cite{Milner1980}, their algorithm is more efficient in time (see Section \\ref{sec:bac:bis}).\nYet, the algorithm given by Paige and Tarjan is not designed for multi-directed graphs.\nIt only processes the directed graph with only one kind of edges.\nSo by replacing every operation on one relation by a group of operations on each relation (see Step \\ref{each_relation} in Algorithm \\ref{alg:sbs}), the algorithm can be used for multi-directed graphs.\nHere we give the description of the algorithm based on \\cite{Paige1987}.\n\n\\begin{algor}\\label{alg:sbs}\nStandard Bisimulation Algorithm\n\\begin{enumerate}\n    \\item Get the union of two given graphs $U$.\n    \\item Initialise the partition $X$ and block set $C$, where $X=C=\\{U\\}$.\n    \\item Get the initial partition $Q$, by refine the only block $U$ in $Q$ with respect to $U$ itself. In other words, split $U$ on the preimage of itself, i.e. $Q = \\{E^{-1}(U), U-E^{-1}(U)\\}$, where $E$ is the any type of binary relation of nodes (also edges).\n    \\item Loop until block set $C$ is empty.\n    \\begin{enumerate}\n        \\item \\label{loop} Pop the first block $s$ from block set $C$\n        \\item Check first two blocks of partition $Q$, that is contained in block $s$, make block $b$ be the smaller one.\n        \\item In partition $X$ split the block $s$ into block $b$ and block $s'=s-b$. if $s'$ is compound with respect to partition $Q$, add it back to block set $C$\n        \\item \\label{each_relation} For each type of relation $E_i$, i.e. $i=1, i=2$ if there are two types of edges.\n        Refine every blocks in partition $Q$ with respect to block $b$ and block $s'$.\n        \\item Add all blocks $x\\in X$ that are compound with respect to partition $Q$ to block set $C$\n    \\end{enumerate}\n    \\item If there are nodes of both graphs in each block of partition $Q$ return true, else return false.\n\\end{enumerate}\n\n\\end{algor}\n\n% \\begin{defin}\n% Concepts used in the algorithm. \\footnote{All the definition here directly from \\cite{Paige1987}}\n\n% \\begin{itemize}\n%     \\item $U$ is the union of two given graphs.\n%     \\item $S$ is the subset of $U$, i.e. $S \\subseteq U$\n%     \\item $E$ is the links of $U$, which means edge $\\langle x, y \\rangle \\in E $ (also denoted $xEy$).\n%     \\item For any subset $S$, $E(S) = \\{y|\\exists x \\in S \\text{ such that } xEy\\}$ and $E^{-1}(S)=\\{x|\\exists y\\in S \\text{ such that } xEy \\}$\n%     \\item If $B \\subseteq U$, $B$ is \\emph{stable} with respect to $S$ if either $S\\subseteq E^{-1}(S)$ or $B\\cap E^{-1}(S)=\\emptyset$\n%     \\item If $P$ is a partition of $U$, $P$ is \\emph{stable} with the respect to $S$ if all of the blocks belonging to $P$ are stable with respect to $S$.\n%     \\item $P$ is \\emph{stable} if it is stable with respect to each of its own block.\n% \\end{itemize}\n% \\end{defin}\n% This algorithm keep refine the a partition $Q$ (with the initial state that only contain $U$) until it is \\emph{stable}.\n\n\n\\subsection{Test Case Generator}\\label{sec:generator ds}\nAll the data used in this project is self-generated random and abstract without any human participation.\nHere the model (multi-directed graph) generated will be represented as an expend adjacency matrix (see Figure \\ref{fig:exp:model_represent}), where 1 stands for existence.\n\\begin{figure}[h]\n    \\centering\n    \\subfigure[Model]{\n        \\label{fig:example1_model}\n        \\includegraphics[width=2.0cm]{img/graph_example.pdf}}\n    \\subfigure[Adjacency Matrix]{\n        \\label{fig:example1_matrix}\n        \\includegraphics[width=0.6\\textwidth]{img/example1_matrix.pdf}}\n    \\caption{Example model represent}\n    \\label{fig:exp:model_represent}\n\\end{figure}\n\nThere are two generators implemented.\nHowever, only one is used in the final experiments (to be explained in Section \\ref{sec:relisation})\nThe first idea is to randomly generate graphs.\nDepends on the rate given, generate a bisimilar graph of another random non-bisimilar graph.\nThen record them into the appointed file with flags.\nDescription of this algorithm is given as follow.\n\\begin{algor}\n\\label{alg:R_tcg}\nRandom Test Case Generator\n\\begin{enumerate}\n    \\item \\label{item:gen_ran}Generate a random graph with certain scale, using the given density times a random number ($< 1$, $> 0$) as a probability of each possible edge.\n    \\item According given rate of positive cases and negative cases, decide to generate a bisimilar graph (jump to Step \\ref{item:bi}) or non-bisimilar graph (jump to Step \\ref{item:non_bi}).\n    \\item \\label{item:non_bi} Keep generate random graph like Step \\ref{item:gen_ran} and check the bisimulation equivence, until they are not (then jump to Step \\ref{item:convert}).\n    \n    \\item \\label{item:bi}Get the \\emph{relational coarsest partition} $P_\\text{origin}$ of given graph.\n    \\item Randomly divides the nodes of the new graph into the same partition $P_\\text{similar}$, i.e. the partition that has the same number of blocks (N.B. the length of each block not necessary to be same).\n    \\item Assemble the minimum bisimilar graph, where each block of its partition contains only one node. \n    \\item \\label{item:bi_end}For each edge of the minimum graph, generate a random number ($\\geq 1$) of edges between the random nodes from two corresponding blocks of $P_\\text{similar}$ respectively.\n    \n    \\item \\label{item:convert}Convert the new generated graph into adjacency matrix.\n    \\item Write two graphs with flag into file (jump to Step \\ref{item:gen_ran} if there are not enough test cases).\n\\end{enumerate}\n\\end{algor}\n\nHowever, the test cases generated may not actually random, which may have some superficial features that are easy to be caught by the later MLP (to be described in Section \\ref{sec:des:ml}).\nFor example the heuristic algorithm for generate bisimilar graph (see Algorithm \\ref{alg:R_tcg}, Step \\ref{item:bi} to Step \\ref{item:bi_end}) may have some kind of inclination.\nTo get rid of these potential bias, a full case generator is designed.\nThis generator can generate all possible graphs in given scale and record all possible combinations with flags.\nThe basic idea of iteration is that since a graph can be seen as an adjacency matrix, it can be represented as a binary string.\nBy counting in binary, all possible graphs on the same scale can be traversed.\nHere gives the description of this algorithm.\n\\begin{algor}\n\\label{alg:F_tcg}\nFull Test Case Generator\n\\begin{enumerate}\n    \\item For every graph, calculate its minimum bisimilar graph. Meanwhile, construct a dictionary where the key is the minimum bisimilar graph and the value is a set of all graphs that are bisimilar, i.e. have the same minimum bisimilar graph which is their key.\n    \\item According to the dictionary, catalogue all the graph (graphs with the same key will have the same label).\n    \\item Go through all graphs again, generate all combinations with flag base on their label.\n\\end{enumerate}\n\\end{algor}\n\n\\subsection{MLP Structure}\n\\label{sec:des:ml}\nAfter the test case generator produces data, the network should be trained.\nThe structure is designed to be as simple as possible.\nCombine with the process step of the standard algorithm, the network is structured to meet the process (see Figure \\ref{fig:mlp_model}).\nThe first layer is the input layer, which will accept fixed length binary (i.e. adjacency matrix).\nIn order to push the network to get the abstraction, the second layer called re-represent layer has fewer neurons than the input layer. \nAnd the first two layers are divided into two independent parts that share parameters (see Part 1 and Part 2 in Figure \\ref{fig:mlp_model}).\nEach part will accept one graph.\nThe distinguishing part will accept input from two graphs and get the conclusion about bisimulation equivalence, i.e. output the probability of positive and negative.\nThere are three reasons to design a network like that.\nFirst is by sharing the parameters, the overall training will be master.\nThe second reason is that it solves the problem of sequence, i.e. the output will not be affected by the priority of two graphs.\nThe third reason is that this kind of modular design will be much easier for reuse, e.g. used as part of the graph simplify the network.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.65\\textwidth]{img/mlp.pdf}\n    \\caption{MLP model}\n    \\label{fig:mlp_model}\n\\end{figure}\n\n\\subsection{General Structure}\nThe design of the general structure is aimed at developing a reusable tool.\nThus the structure is very simple and highly modularised (see Figure \\ref{fig:general_str}).\nDataset generator and ML-algorithm is packed independently.\nAnd each module can be called in a python program or used as a command line tool directly by the user.\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\textwidth]{img/architecture.pdf}\n    \\caption{General structure}\n    \\label{fig:general_str}\n\\end{figure}\n\n", "meta": {"hexsha": "31e72509d8e6184c42a7afc5aa624ee4811e2449", "size": 10849, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FYP_report/tex/description.tex", "max_stars_repo_name": "SuperElephant/Bisimulation_fyp_2019", "max_stars_repo_head_hexsha": "736f7e64dc9f381450c3539ec254ef23dae65c5b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-29T12:37:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-29T12:37:17.000Z", "max_issues_repo_path": "FYP_report/tex/description.tex", "max_issues_repo_name": "SuperElephant/Bisimulation_fyp_2019", "max_issues_repo_head_hexsha": "736f7e64dc9f381450c3539ec254ef23dae65c5b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2019-03-15T01:56:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T00:06:36.000Z", "max_forks_repo_path": "FYP_report/tex/description.tex", "max_forks_repo_name": "SuperElephant/Bisimulation_fyp_2019", "max_forks_repo_head_hexsha": "736f7e64dc9f381450c3539ec254ef23dae65c5b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.5448717949, "max_line_length": 319, "alphanum_fraction": 0.7494699972, "num_tokens": 2723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4281992293269251}}
{"text": "\\par\n\\section{Data Structure}\n\\par\nThe {\\tt Coords} object has four fields.\n\\begin{itemize}\n\\item {\\tt int type} : coordinate type.\nWhen {\\tt type = 1}, coordinates are stored by tuples,\n$(x_0,y_0,\\ldots)$ first,\n$(x_1,y_1,\\ldots)$ next, etc.\n% \\begin{verbatim}\n% x(icoor, idim) = coors[idim + icoor*ndim]\n% \\end{verbatim}\nWhen {\\tt type = 2}, coordinates are stored by $x$-coordinates\nfirst, $y$-coordinates next, etc.\n% \\begin{verbatim}\n% x(icoor, idim) = coors[icoor + idim*ncoor]\n% \\end{verbatim}\n\\item {\\tt int ndim} : \nnumber of dimensions for the coordinates, \ne.g., for $(x,y)$ coordinates {\\tt ndim = 2},\nfor $(x,y,z)$ coordinates {\\tt ndim = 3}.\n\\item {\\tt int ncoor} : \nnumber of coordinates (i.e., number of grid points).\n\\item {\\tt float *coors} : \npointer to a {\\tt float} vector that holds the coordinates\n\\end{itemize}\nA correctly initialized and nontrivial {\\tt Coords} object \nwill have {\\tt type} be {\\tt 1} or {\\tt 2},\npositive {\\tt ndim} and {\\tt ncoor} values,\nand a non-{\\tt NULL} {\\tt coors} field.\n", "meta": {"hexsha": "8517d3ef538d9c01ed746a5519c878f9d3e2e198", "size": 1023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/Coords/doc/dataStructure.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/Coords/doc/dataStructure.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/Coords/doc/dataStructure.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 33.0, "max_line_length": 62, "alphanum_fraction": 0.6754643206, "num_tokens": 344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.428199225613622}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\title{{\\tt meijerG}, a package for simplification\\\\\nof Meijer's G function}\n\\date{}\n\\author{Victor S. Adamchik\\\\\n\tWolfram Research Inc. \\\\\n\tformer address : \\\\\n\tByelorussian University, Minsk, Byelorussia\\\\\n\\\\\n\\\\\n\tPresent \\REDUCE{} form by \\\\\n\tWinfried Neun \\\\\n\tZIB Berlin \\\\\n        Email: {\\tt Neun@sc.ZIB-Berlin.de}}\n\\begin{document}\n\\maketitle\n\nThis note describes the {\\tt meijerG} package of \\REDUCE{}, which is able\nto do simplification of several cases of Meijer's G function. \nThe simplifications are performed towards polynomials, elementary or\nspecial functions or (generalized) hypergeometric functions.\nTherefore this package should be used together with the \\REDUCE{}\nspecial function and hypergeometric (ghyper) package.\n\n\\section{Introduction}\n\nThe function \n\n\\begin{displaymath}\nG_{p q}^{m n} \\left( z \\  \\Bigg\\vert \\  {(a_p) \\atop (b_q)} \\right)\n\\end{displaymath}\n\nhas been studied by C.~S.~Meijer beginning in 1936 and has been\ncalled Meijer's G function later on. The complete definition of Meijer's\nG function can be found in \\cite{Prudnikov:90}.\nMany well-known functions can be written as G functions,\ne.g. exponentials, logarithms, trigonometric functions, Bessel functions\nand hypergeometric functions.\n\nSeveral hundreds of particular values can be found in \\cite{Prudnikov:90}.\n\n\\section{\\REDUCE{} operator {\\tt meijerg}}\n\nThe operator {\\tt meijerg} expects 3 arguments, namely the \nlist of upper parameters (which may be empty), the list of lower\nparameters (which may be empty too), and the argument.\n\nThe first element of the lists has to be the list of the\nfirst n or m respective parameters, e.g. to describe \n\\begin{displaymath}\nG_{1 1}^{1 0} \\left( x \\  \\Bigg\\vert \\  {1 \\atop 0} \\right)\n\\end{displaymath}\n\none has to write \n\\begin{verbatim}\n\nMeijerG({{},1},{{0}},x); % and the result is:\n\n HEAVISIDE( - X + 1)\n---------------------\n      GAMMA(1)\n\n\\end{verbatim}\nand for\n\\begin{displaymath}\nG_{0 2}^{1 0} \\left( \\frac{x^2}{4} \\  \\Bigg\\vert \\ {} \\atop  {1+ \\frac{1}{4} }\n{1-\\frac{1}{4}} \\right)\n\\end{displaymath}\n\\begin{verbatim}\n\nMeijerG({{}},{{1+1/4},1-1/4},(x^2)/4) * sqrt pi;\n\n\n                   1      2\n SQRT(PI)*BESSELJ(---,X)*X\n                   2\n----------------------------\n             4\n\n\\end{verbatim}\n\nNote: Using the special function package these results will be\nsimplified further.\n\n\\begin{thebibliography}{9}\n\n\\bibitem{Prudnikov:90} A.~P.~Prudnikov, Yu.~A.~Brychkov, O.~I.~Marichev,\n{\\em Integrals and Series, Volume 3: More special functions},\nGordon and Breach Science Publishers (1990).\n\n\\end{thebibliography}\n\\end{document}\n", "meta": {"hexsha": "988898cbf910dced1020dbe487ade097ebf7fc09", "size": 2620, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/specfn/meijerg.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/specfn/meijerg.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/specfn/meijerg.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1720430108, "max_line_length": 78, "alphanum_fraction": 0.6889312977, "num_tokens": 817, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.42819922561362195}}
{"text": "\\documentclass[12pt, oneside]{article}\n\n\\usepackage{float}\n\\usepackage{lineno}\n\\usepackage{color, amssymb, amsmath, amsthm, verbatim, wasysym}\n\\usepackage{natbib}\n\\usepackage{epsfig}\n\\usepackage[mathscr]{eucal}\n\\usepackage{mathrsfs}\n\\usepackage{appendix}\n\\raggedbottom\n\\usepackage[left=0.8in,right=0.8in,top=0.8in,bottom=0.9in,centering]{geometry}      \n\n% Uncomment to show references.\n%\\usepackage[notcite,notref]{showkeys}\n\n% To make really wide hats that cover everything:\n\\usepackage{scalerel}\n\\usepackage{stackengine}\n\\setstackEOL{\\#}\n\\stackMath\n\\def\\hatgap{1pt}\n\\def\\subdown{-0.2pt}\n\\newcommand\\reallywidehat[2][]{%\n\\renewcommand\\stackalignment{l}%\n\\stackon[\\hatgap]{#2}{%\n\\stretchto{%\n    \\scalerel*[\\widthof{$#2$}]{\\kern-.6pt\\bigwedge\\kern-.6pt}%\n    {\\rule[-\\textheight/2]{1ex}{\\textheight}}%WIDTH-LIMITED BIG WEDGE\n}{0.6ex}% THIS SQUEEZES THE WEDGE TO 0.5ex HEIGHT\n_{\\smash{\\belowbaseline[\\subdown]{\\scriptstyle#1}}}%\n}}\n\n% For a 'strut' that creates space above underbraces\n\\newcommand*\\mystrut[1]{\\vrule width0pt height0pt depth#1\\relax}\n\n% Punctuation\n\\newcommand{\\com}{\\, ,}\n\\newcommand{\\per}{\\, .}\n\n% A nice 'definition'\n\\newcommand{\\defn}{\\ensuremath{\\stackrel{\\mathrm{def}}{=}}}\n\n% Use \\bar to over line solo symbols\n\\newcommand{\\av}[1]{\\left \\langle{#1} \\right \\rangle}\n\\newcommand{\\avbg}[1]{\\overline{#1}}\n\\newcommand{\\avbgg}[1]{\\overline{#1}}\n\\newcommand{\\hav}[1]{\\widehat{#1}}\n\n% Begin and end equations\n\\newcommand{\\beq}{\\begin{equation}}\n\\newcommand{\\eeq}{\\end{equation}}\n\n% Vector calculus operators\n\\newcommand{\\p}{\\partial}\n\\newcommand{\\bnabla}{\\boldsymbol \\nabla}\n\\newcommand{\\pnabla}{\\boldsymbol \\nabla_{\\! \\! \\perp}}\n\\newcommand{\\hnabla}{\\bnabla_{\\! \\! h}}\n\\newcommand{\\bnablad}{\\bnabla_{\\! \\! \\alpha}}\n\\newcommand{\\bcdot}{\\boldsymbol \\cdot}\n\\newcommand{\\hlap}{\\triangle_h}\n\\newcommand{\\lap}{\\triangle}\n\\newcommand{\\grad}{\\bnabla}\n\\newcommand{\\curl}{\\bnabla \\!\\times\\!}\n\\newcommand{\\diver}{\\bnabla \\bcdot }\n\\newcommand{\\cross}{\\times}\n\n% Bold symbolds\n\\newcommand{\\bu}{\\boldsymbol u}\n\\newcommand{\\buh}{\\boldsymbol u_h}\n\\newcommand{\\bx}{\\boldsymbol x}\n\\newcommand{\\ba}{\\boldsymbol{a}}\n\\newcommand{\\bk}{\\boldsymbol{k}}\n\\newcommand{\\bh}{\\boldsymbol{h}}\n\\newcommand{\\bm}{\\boldsymbol{m}}\n\\newcommand{\\bn}{\\boldsymbol{\\hat n}}\n\\newcommand{\\bxh}{\\hspace{0.1em} \\boldsymbol{\\hat x}}\n\\newcommand{\\byh}{\\hspace{0.1em}\\boldsymbol{\\hat y}}\n\\newcommand{\\bzh}{\\hspace{0.1em}\\boldsymbol{\\hat z}}\n\\newcommand{\\bnh}{\\hspace{0.1em}\\boldsymbol{\\hat n}}\n\\newcommand{\\bomega}{\\boldsymbol \\omega}\n\\newcommand{\\bOmega}{\\boldsymbol \\Omega}\n\\newcommand{\\bxi}{\\ensuremath {\\boldsymbol {\\xi}}}\n\\newcommand{\\bXi}{\\ensuremath {\\boldsymbol {\\Xi}}}\n\\newcommand{\\bU}{\\boldsymbol{U}}\n\\newcommand{\\bX}{\\boldsymbol{X}}\n\n% Greek abbrevs\n\\newcommand{\\ep}{\\epsilon}\n\\newcommand{\\om}{\\omega}\n\\newcommand{\\kap}{\\kappa}\n\n% Roman characters\n\\newcommand{\\ee}{\\mathrm{e}}\n\\newcommand{\\ii}{\\mathrm{i}}\n\\newcommand{\\cc}{\\mathrm{cc}}\n\\newcommand{\\dd}{{\\rm d}}\n\\newcommand{\\id}{{\\, \\rm d}}\n\\newcommand{\\DD}{{\\rm D}}\n\\newcommand{\\J}{\\mathrm{J}}\n\\renewcommand{\\L}{\\mathrm{L}}\n\n% Non-dimensional numbers \n\\newcommand{\\Ri}{Ri}\n\\newcommand{\\Ro}{Ro}\n\\newcommand{\\Bu}{Bu}\n\\newcommand{\\Pe}{Pe}\n\n% Material derivative\n\\newcommand{\\Dt}[1]{\\mathrm{D}_t #1}\n\n% Small in-line fractions\n\\newcommand{\\half}{\\tfrac{1}{2}}\n\n% Bold 'F' for 'forcing'\n\\newcommand{\\bff}{\\boldsymbol{F}}\n\\newcommand{\\fh}{\\breve f}\n\n% Dissipation operator\n\\newcommand{\\friction}{\\mathrm{F}}\n\\newcommand{\\mixing}{\\mathrm{M}}\n\n\\newcommand{\\mode}{\\phi}\n\n\\begin{document}\n\n\\title{\\vspace{-4ex} 2D reductions of the rotating Boussinesq equations}\n\\author{Greg}\n\\date{} \\maketitle \\vspace{-4ex}\n\n\\section{Preliminaries}\n\nThe rotating Boussinesq equations are\n\\begin{align}\n\\Dt{\\bu} + 2 \\bOmega \\times \\bu - b \\bzh + \\bnabla p &= \\friction \\bu \\com \\label{mom} \\\\\n\\Dt{b} + w N^2 &= \\mixing b \\com \\label{buoy} \\\\\n\\bnabla \\bcdot \\bu &= 0 \\com \\label{cont}\n\\end{align}\nwhere $\\Dt \\defn \\p_t + \\bu \\bcdot \\bnabla$ is the material derivative, \n\\beq\n2 \\bOmega \\defn \\underbrace{2 \\Omega \\cos \\phi}_{\\defn \\fh} \\byh + \\underbrace{2 \\Omega \\sin \\phi}_{\\defn f} \\bzh \\com\n\\eeq\nis the axis around which the Earth rotates, and the $\\friction$ and $\\mixing$ are operators that represent dissipative frictional processes and diffusive mixing processes, respectively. If dissipation and diffusion are due to isotropic molecular processes, then $\\friction = \\nu \\lap$ and $\\mixing = \\kap \\lap$, where $\\lap = \\p_x^2 + \\p_y^2 + \\p_z^2$ is the three-dimensional Laplacian. \n\n\\section{Boussinesq equations non-linearized around two-dimensional flow in $x,z$}\n\nThe Boussinesq equations with $\\p_y = 0$ and non-linearized around the two-dimensional flow \n\\beq\n\\bU = U(z, t) \\bxh + V(x, z, t) \\byh\n\\eeq\nbecome\n\\begin{align}\n\\Dt{u} + w \\left ( \\fh + U_z \\right ) - f v  + p_x &= \\friction u \\com \\\\\n\\Dt{v} + u \\left ( f + V_x \\right ) + w V_z  &= \\friction v \\com \\\\\n\\Dt{w} - \\fh u - b + p_z &= \\friction w \\com \\\\\n\\Dt{b} + w N^2 &= \\mixing b \\com \\\\\n\\bnabla \\bcdot \\bu &= 0 \\com\n\\end{align}\nwhere the material derivative is now\n\\beq\n\\Dt \\defn \\p_t + \\left ( u + U \\right ) \\p_x + w \\p_z \\per\n\\eeq\nIn addition to the terms describing advection by the `mean' background flow, there are three qualitatively new refraction terms $w U_z$, $w V_z$, and $u V_x$ that appear in the momentum equations.\n\n\\section{Hydrostatic Boussinesq equations linearized around two-dimensional flow in $x,y$}\n\nThe traditional hydrostatic Boussinesq equations linearized around a two-dimensional mean flow are formed by using the hydrostatic approximation in the vertical component of \\eqref{mom}, assuming that $\\fh = 0$ and constant $f = f_0$, and using the map $\\bu \\mapsto \\bU(x, y, t) + \\bu(x, y, z, t)$, so that \\eqref{mom}--\\eqref{cont} become\n\\begin{align}\nu_t + \\bU \\bcdot \\bnabla u + \\bu \\bcdot \\bnabla U - f_0 v + p_x &= \\friction_u u \\com \\label{xmomLin} \\\\\nv_t + \\bU \\bcdot \\bnabla v + \\bu \\bcdot \\bnabla V + f_0 u + p_y &= \\friction_u v \\com \\label{ymomLin} \\\\\np_z &= b \\com \\label{zmomLin} \\\\\nb_t + \\bU \\bcdot \\bnabla b + w N^2 &= \\mixing b \\com \\label{buoyLin} \\\\\nu_x + v_y + w_z &= 0 \\label{contLin} \\per\n\\end{align}\nA natural model for the two-dimensional flow\n\\beq\n\\bU(x,y,t) = - \\psi_y \\bxh + \\psi_x \\byh\n\\label{streamfunctionDef}\n\\eeq\nis that is solves the two-dimensional vorticity equation,\n\\beq\n\\hlap \\psi_t + \\J \\left ( \\psi , \\hlap \\psi \\right ) = \\friction_\\psi \\left ( \\hlap \\psi \\right ) \\com\n\\label{vorticity}\n\\eeq\nEquations \\eqref{xmomLin}--\\eqref{contLin} describe the advection and refraction of waves by a two-dimensional flow with $\\bU_{\\! z} = \\psi_z = 0$ and thus no buoyancy field.  The linearization neglects the complications of nonlinear wave dynamics and permits a two-dimensionalization of \\eqref{xmomLin}--\\eqref{contLin} by projection onto vertical modes. \\eqref{xmomLin}--\\eqref{contLin} do not have a cascade to small-scales, in general, and therefore permit inviscid numerical solutions.\n\n\\subsection{The vertical mode decomposition}\n\\label{verticalModeProjection}\n\nWe restrict attention to waves with simple vertical structure by projecting \\eqref{xmomLin}--\\eqref{contLin} onto the hydrostatic vertical modes $\\mode_n(z)$ that solve the eigenproblem\n\\beq\n\\frac{f_0^2}{N^2} \\mode_{nzz} + \\lambda_n^{-2} \\mode_n = 0 \\com \\qquad \\text{with} \\qquad \\mode_n = 0 \\quad \\text{at} \\quad z = -H, 0 \\per\n\\label{modalEigenproblem}\n\\eeq\nNote that the derivative $h_{nz}$ satisfies $h_{nz} = - \\lambda_n^2 \\L h_{nz}$.  The modal amplitudes of the independent variables $A, \\bu, b, p$ are defined by their weighted projection onto $\\mode_n$ or its derivative $\\mode_{nz}$, with\n\\beq\n\\Phi_n \\defn \\int_{-H}^0 \\Phi \\, \\mode_{nz} \\id z  \\qquad \\text{for} \\qquad \\Phi = \\left (A, u, v, p \\right ) \\com\n\\label{modezDef}\n\\eeq\nand\n\\beq\nb_n \\defn \\int_{-H}^0 b \\, \\mode_n \\id z  \\qquad \\text{and} \\qquad w_n \\defn \\int_{-H}^0 \\frac{N^2}{\\lambda_n^2 f_0^2} \\, w \\, \\mode_n \\id z \\per\n\\eeq \nWe assume $A, \\bu, b$, and $p$ satisfy free-slip, rigid-lid homogeneous boundary conditions with $A_z = u_z = v_z = p_z = 0$ and $w= b = 0$ at $z = -H, 0$.\n \nThe linearized Boussinesq equations \\eqref{xmomLin}--\\eqref{contLin} are processed in similar fashion.  We project \\eqref{xmomLin} and \\eqref{ymomLin} onto $\\mode_{nz}$. We assume we can write, approximately\n\\beq\n\\friction_{nu} (u_n) \\approx \\int_{-H}^0 \\phi_{nz} \\friction_u(u) \\id z \\per\n\\label{approximateFriction}\n\\eeq\nThis approximation does not hold for all linear operators $\\friction_u$. Notice that if $\\friction = \\nu \\lap$, then\n\\beq\n\\int_{-H}^0 \\phi_{nz} \\nu \\lap u \\id z = \\nu \\hlap u_n + \\frac{\\kappa_n^2}{f_0^2} \\int_{-H}^0 N^2 \\phi_n u_{z} \\id z \\com\n\\eeq\nand different modes are therefore coupled by the rightmost term. When $N$ is constant, however, this becomes \n\\beq\n\\int_{-H}^0 \\phi_{nz} \\nu \\lap u \\id z = \\nu \\hlap u_n + \\nu \\left ( \\tfrac{n \\pi}{H} \\right )^2 u_n \\com\n\\eeq\nand the modes separate. With the notation in \\eqref{approximateFriction}, the horizontal momentum equations \n\\begin{align}\nu_{nt} - f_0 v_n + p_{nx} &= - \\bU \\bcdot \\bnabla u_n - \\bu_n \\bcdot \\bnabla U + \\friction_{nu} u_n \\com \\label{modeWisexmom} \\\\\nv_{nt} + f_0 u_n + p_{ny} &= - \\bU \\bcdot \\bnabla v_n - \\bu_n \\bcdot \\bnabla V + \\friction_{nu} v_n\\per \\label{modeWiseymom}\n\\end{align}\nWe next combine \\eqref{zmomLin}--\\eqref{contLin} by projecting \\eqref{contLin} onto $\\mode_{nz}$, integrating by parts once, and using \\eqref{modalEigenproblem} to yield $w_n = - u_{nx} - v_{ny}$.  We then use $p_z = b$ to combine \\eqref{zmomLin} and \\eqref{buoyLin} and project the result onto $\\mode_n$. Similar to \\eqref{approximateFriction}, we use the notation \n\\beq\n\\mixing_n p_n \\approx - \\int_{-H}^0 \\phi_n \\mixing p_z \\id z \\per\n\\eeq\nSimilar to \\eqref{approximateFriction}, this is not true when $N$ is not constant. When $N$ is constant we have $\\mixing_n p_n = \\kappa \\hlap p_n + \\kappa \\left ( \\tfrac{n \\pi}{H} \\right )^2 p_n$. Finally, integrating by parts and using $w_n = - u_{nx} - v_{ny}$ transforms \\eqref{buoyLin} into\n\\beq\np_{nt} + \\left ( \\tfrac{f_0}{\\kappa_n} \\right )^{\\! 2} \\left ( u_{nx} + v_{ny} \\right ) = - \\bU \\bcdot \\bnabla p_n + \\mixing_n p_n \\per\n\\label{modeWisebuoy}\n\\eeq\nThe three equations \\eqref{modeWisexmom}--\\eqref{modeWisebuoy} describe the evolution of hydrostatic, vertical mode-$n$ waves in a two-dimensional flow $\\bU = U \\bxh + V \\byh$ with $\\bU_{\\! z} = 0$.  The parameter $f_0 / \\kappa_n$ is the phase speed of a linear wave with mode-$n$ vertical structure.  \n\n\\appendix\n\n\\section{`Wave operator form' of the Boussinesq equations}\n\\label{waveOperatorForm}\n\nThe component-wise rotating inviscid Boussinesq equations are\n\\begin{align}\nu_t - f v + \\fh w + p_x &= - \\bu \\bcdot \\bnabla u \\com \\label{xmom} \\\\\nv_t + f u + p_y &= - \\bu \\bcdot \\bnabla v \\com \\label{ymom} \\\\\nw_t - \\fh u - b + p_z &= - \\bu \\bcdot \\bnabla w \\com \\label{zmom} \\\\\nb_t + w N^2 &= - \\bu \\bcdot \\bnabla b \\com \\label{buoyComp} \\\\\n\\bnabla \\bcdot \\bu &= 0 \\label{contComp} \\per\n\\end{align}\nWe first form the `oscillation equation' with the combination $\\p_t \\eqref{zmom} + \\eqref{buoyComp}$:\n\\beq\n\\left ( \\p_t^2 + N^2 \\right ) w - \\fh u_t + p_{zt} = - \\p_t \\left ( \\bu \\bcdot \\bnabla w \\right ) - \\bu \\bcdot \\bnabla b \\per \n\\label{oscillation}\n\\eeq\nThe 'divergence equation' follows from $- \\p_x \\eqref{xmom}- \\p_y \\eqref{ymom}$ and using $u_x + v_y = - w_z$, \n\\beq\nw_{zt} + f \\omega - u f_y  -  \\fh w_x - \\hlap p =  \\p_x \\big ( \\bu \\bcdot \\bnabla u \\big ) + \\p_y \\left ( \\bu \\bcdot \\bnabla v \\right ) \\per\n\\label{divergence}\n\\eeq\nThe vertical vorticity equation is obtained from $\\p_x \\eqref{ymom} - \\p_y \\eqref{xmom}$, \n\\beq\n\\omega_t - f w_z + v f_y = - \\pnabla \\bcdot \\left ( \\bu \\bcdot \\bnabla \\right ) \\bu \\per\n\\label{vorticity}\n\\eeq\nYes! In the penultimate step we calculate $\\p_z \\p_t \\eqref{divergence} - f \\p_z \\eqref{vorticity}$, yielding\n\\beq\n\\Big [  \\left ( \\p_t^2 + f^2 \\right ) \\p_z^2 - \\fh \\p_x \\p_z \\p_t \\Big ] w - \\hlap p_{zt} = f_y \\p_z \\left ( u_t + f v \\right ) + \\p_z \\left ( \\p_t \\bnabla + f \\pnabla \\right ) \\bcdot \\left ( \\bu \\bcdot \\bnabla \\right ) \\buh \\per\n\\label{divVort}\n\\eeq\nFinally, the combination $\\hlap \\eqref{oscillation} + \\eqref{divVort}$ yields the wave operator form,\n\\beq\n\\begin{split}\n\\Big [&  \\lap \\p_t^2 + f^2 \\p_z + N^2 \\hlap \\Big ] w = \\fh \\p_t \\left ( \\hlap u + w_{xz} \\right ) + u_t \\fh_{yy} + 2 u_{yt} \\fh_{y}  + f_y \\p_z \\left ( u_t + f v \\right ) \\\\\n& \\qquad  + \\p_z \\left ( \\p_t \\bnabla + f \\pnabla \\right ) \\bcdot \\left ( \\bu \\bcdot \\bnabla \\right ) \\bu - \\hlap \\left ( \\bu \\bcdot \\bnabla b \\right ) - \\lap \\p_t \\left ( \\bu \\bcdot \\bnabla w \\right ) \\per\n\\end{split}\n\\label{waveOperatorEqn}\n\\eeq\n\n\\bibliographystyle{jfm}\n\\bibliography{refs}\n\n\\end{document}", "meta": {"hexsha": "3f74cd3150d0b55c0f37e977ae99b3332563fdf3", "size": 12677, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/BoussinesqEquations/BoussinesqEquations.tex", "max_stars_repo_name": "glwagner/doublyPeriodicModels", "max_stars_repo_head_hexsha": "69f4e4bc338f9a60ee3b6d0760605d4ed3281fe8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-03T12:07:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-03T12:07:15.000Z", "max_issues_repo_path": "docs/BoussinesqEquations/BoussinesqEquations.tex", "max_issues_repo_name": "glwagner/doublyPeriodicModels", "max_issues_repo_head_hexsha": "69f4e4bc338f9a60ee3b6d0760605d4ed3281fe8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/BoussinesqEquations/BoussinesqEquations.tex", "max_forks_repo_name": "glwagner/doublyPeriodicModels", "max_forks_repo_head_hexsha": "69f4e4bc338f9a60ee3b6d0760605d4ed3281fe8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-05-13T01:40:00.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-13T01:40:00.000Z", "avg_line_length": 45.275, "max_line_length": 490, "alphanum_fraction": 0.6837579869, "num_tokens": 4751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.428075521431091}}
{"text": "\\part{Lecture 13: Further Contemporary RL Algorithms}\n\\title[RL Lecture 13]{Lecture 13: Further Contemporary RL Algorithms}  \n\\date{}  \n\\frame{\\titlepage} \n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Deep Deterministic Policy Gradient (DDPG)} \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}\n\\frametitle{Table of Contents}\n\\tableofcontents\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Motivation / General Idea %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Motivation / General Idea}\n\\begin{itemize}\n\t\\item The upcoming \\hl{deep deterministic policy gradient (DDPG)} algorithm was very much inspired by the successes of DQNs (cf. \\algoref{algo:DQN} and landmark \\href{https://www.nature.com/articles/nature14236?wm=book_wap_0005}{paper by Mnih et al.}) on discrete action spaces.\\pause\n\t\\item However, \\hl{DQNs are not directly applicable to (quasi-)continuous action spaces}.\\pause\n\t\\item Recall the incremental $Q$-learning  equation using function approximation\n\t\\begin{equation*}\n\t \\bm{w} \\leftarrow \\bm{w} + \\alpha\\left[r+\\gamma \\max_u \\hat{q}(\\bm{x}', u, \\bm{w}) - \\hat{q}(\\bm{x}, u, \\bm{w})\\right]\\nabla_{\\bm{w}} \\hat{q}(\\bm{x}, u, \\bm{w}).\n \\end{equation*}\n\t\\item For every policy inference and updating step we need to find $\\max_u \\hat{q}(\\bm{x}', u, \\bm{w})$.\\pause \n\t\\item If $u\\in\\mathcal{U}\\subset\\mathbb{Z}$ (i.e., using integer-encoded actions) is a sufficiently small discrete set, that is straightforward by an exhaustive search.\\pause\n\t\\item In contrast, if $\\bm{u}\\in\\mathcal{U}\\subset\\mathbb{R}^m$ is a (quasi-)continuous variable solving $\\max_{\\bm{u}} \\hat{q}(\\bm{x}', \\bm{u}, \\bm{w})$  requires an own \\hl{optimization routine} which is computationally expensive if we use nonlinear function approximation. \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% The Deterministic Policy Trick %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{The Deterministic Policy Trick}\n\\begin{itemize}\n\t\\item When using a greedy, deterministic policy $\\bm{\\pi}(\\bm{x}, \\bm{\\theta}) = \\bm{\\mu}(\\bm{x}, \\bm{\\theta})$ we can utilize it to approximate\n\t\\begin{equation}\n\t\t\\max_{\\bm{u}} \\hat{q}(\\bm{x}', \\bm{u}, \\bm{w}) \\approx \\hat{q}(\\bm{x}', \\bm{\\mu}(\\bm{x}', \\bm{\\theta}), \\bm{w}).\n\t\\end{equation}\n\t\\item Hence, we can obtain explicit $Q$-learning targets for continuous actions when using a deterministic policy.\\pause \n\t\\item For improving the policy we reuse the deterministic policy gradient theorem in an off-policy fashion\n\t\\begin{equation}\n\t\\nabla_{\\bm{\\theta}} J(\\bm{\\theta}) = \\El{\\nabla_{\\bm{\\theta}} \\bm{\\mu}(\\bm{X},\\bm{\\theta}) \\nabla_{\\bm{u}} q(\\bm{X},\\bm{U})\\left|\\bm{U}=\\bm{\\mu}(\\bm{X}, \\bm{\\theta})\\right.}{b}\n\\end{equation}\ngiven a behavior policy $b(\\bm{u}|\\bm{x})$.\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% DDPG $\\approx$ DQN + DPG %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{DDPG $\\approx$ DQN + DPG}\n\\begin{itemize}\n\t\\item Hence, we can consider the DDPG approach as a combination of DQN + DPG rendering it an \\hl{actor-critic off-policy approach for continuous state and action spaces}.\\pause\n\t\\item Similarly to DQN we will introduce \\hl{several 'tweaks'} to stabilize and improve the DDPG learning process.\\pause\t\n\\end{itemize}\n\\vspace{0.25cm}\n\\hl{Tweak \\#1}: experience replay buffer\n\\begin{itemize}\n\t\\item We store $\\left\\langle \\bm{x}, \\bm{u}, r, \\bm{x}'\\right\\rangle$ in $\\bm{\\mathcal{D}}$ after each transition step.\\pause\n\t\\item The replay buffer $\\bm{\\mathcal{D}}$ is of limited capacity, i.e., it discards the oldest data sample when updating once it is full (ring memory).\\pause\n\t\\item This allows us to improve the $Q$-learning critic minimizing the mean-squared Bellman error (MSBE):\n\t\\begin{equation}\n\t\\label{eq:MSBE_DDPG}\n\t\t\\mathcal{L}(\\bm{w}) = \\left[\\left(r+ \\gamma q(\\bm{x}',\\bm{\\mu}(\\bm{x}',\\bm{\\theta}),\\bm{w})\\right) - q(\\bm{x},\\bm{u},\\bm{w}) \\right]^2_{\\bm{\\mathcal{D}}} .\n\t\\end{equation}\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Additional DDPG Tweaks (1) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Additional DDPG Tweaks (1)}\n\\hl{Tweak \\#2}: target networks\n\\begin{itemize}\n\t\\item Similar to DQN we introduce a (delayed) target network to estimate the $Q$-learning target $$r+ \\gamma q(\\bm{x}',\\bm{\\mu}(\\bm{x}',\\bm{\\theta}),\\bm{w})$$ since it depends on the same parameters $\\bm{w}$ which we want to update.\\pause\n\t\\item Hence, the target network's purpose it to mimic the generation of i.i.d. data as the ground truth to minimize \\eqref{eq:MSBE_DDPG}.\\pause\n\t\\item Since the policy parameters $\\bm{\\theta}$ are also part of the target calculation it turns out that an additional policy target network is also beneficial to stabilize the $Q$-learning.\\pause\n\t\\item In contrast to the classical DQN implementation, the original DDPG algorithm does not perform periodically hard target network updates but continuous ones using a low-pass filter characteristic\n\t\\begin{equation}\n\t\t\\bm{w}^{-} \\leftarrow (1-\\tau)\\bm{w}^{-}+\\tau\\bm{w}, \\quad \\bm{\\theta}^{-} \\leftarrow (1-\\tau)\\bm{\\theta}^{-}+\\tau\\bm{\\theta}\n\t\\end{equation}\n\twith $\\tau$ representing the equivalent filter constant (hyperparameter).\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Additional DDPG Tweaks (2) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Additional DDPG Tweaks (2)}\n\\hl{Tweak \\#3}: mini-batch sampling\n\\begin{itemize}\n\t\\item Given a sufficiently filled memory $\\bm{\\mathcal{D}}$ and the target networks parametrized by $\\bm{w}^{-}$ and $\\bm{\\theta}^{-}$ we draw uniformly distributed mini-batch samples $\\bm{\\mathcal{D}}_b$ from $\\bm{\\mathcal{D}}$.\\pause\n\t\\item The actual $Q$-learning is then based on the loss\n\t\t\\begin{equation}\n\t\t\\label{eq:Loss_DDPG}\n\t\t\t\t\\mathcal{L}(\\bm{w}) = \\left[\\left(r+ \\gamma q(\\bm{x}',\\bm{\\mu}(\\bm{x}',\\bm{\\theta}^{-}),\\bm{w}^{-})\\right) - q(\\bm{x},\\bm{u},\\bm{w}) \\right]^2_{\\bm{\\mathcal{D}}_b} \\, .\n\t\\end{equation}\n\\end{itemize}\\pause\n\\hl{Tweak \\#4}: batch normalization\n\\begin{itemize}\n\t\\item Minimizing \\eqref{eq:Loss_DDPG} is a supervised learning step within the DDPG.\\pause\n\t\\item The \\href{https://arxiv.org/abs/1509.02971}{original DDPG paper by Lillicrap et al.} back in 2015/16 suggested to use batch normalization, i.e., re-centering and re-scaling the inputs of each layer in an ANN.\\pause\n\t\\item This idea of batch normalization was presented at that time shortly before by Ioffe and Szegedy (cf. \\href{http://proceedings.mlr.press/v37/ioffe15.html}{original paper}).\\pause\n\t\\item Today's perspective: stick to the current state-of-the-art supervised ML algorithms for top-class $Q$-learning stability and speed (which are normally well-covered in popular supervised ML toolboxes). \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Additional DDPG Tweaks (3) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Additional DDPG Tweaks (3)}\n\\setcounter{footnote}{0}\n\\hl{Tweak \\#5}: exploration\n\\begin{itemize}\n\t\\item Since our policy is deterministic we require an exploratory behavior policy.\\pause\n\t\\item Similar to DPG the standard approach is to add noise to the greedy actions, e.g., again from an Ornstein-Uhlenbeck (OU) process\n\t\t\\begin{equation*}\n\t\t\t\\bm{u}_k\\sim\\bm{b}(\\bm{u}|\\bm{x}_k)=\\bm{\\mu}(\\bm{x}_k,\\bm{\\theta}_k)+\\bm{\\nu}_{k},\\quad \\bm{\\nu}_{k}= \\lambda \\bm{\\nu}_{k-1}+ \\sigma \\bm{\\epsilon}_{k-1}.\n\t\t\\end{equation*}\\pause\n\t\t\\item One might also add a schedule for $\\lambda$ and $\\sigma$ along the training procedure, e.g., starting with significant noise levels (increased exploration) while reducing it over time (focusing exploitation)\\footnote{Please note that this 'lambda' is not related to TD($\\lambda$), Sarsa($\\lambda$), etc. Here, it is representing the stiffness of the OU noise process.}.\\pause  \n\t\\item However, many other behavior policies are possible, e.g., using model or expert-based guidance.\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Summary of DQN Working Principle  (2)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Visual Summary of DDPG Working Principle}\n\\begin{figure}\n\\includegraphics[height=5.75cm]{fig/lec13/DDPG.pdf}\n\\caption{DDPG structure from a bird's-eye perspective (derivative work of \\figref{fig:RL_Wiki} and \\href{https://commons.wikimedia.org/wiki/File:Multi-Layer_Neural_Network-Vector.svg?uselang=de}{wikipedia.org}, \\href{https://creativecommons.org/publicdomain/zero/1.0/deed.en}{CC0 1.0})}\n\\label{fig:DDPG}\n\\end{figure}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Algorithmic Implementation: DDPG %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Algo. Implementation: DDPG}\n\\setlength{\\algomargin}{0.5em}\n\\begin{algorithm}[H]\n\\small\n\\SetKwInput{Input}{input} \n\\SetKwInput{Output}{output}\n\\SetKwInput{Init}{init}\n\\SetKwInput{Param}{parameter}\n\\Input{diff. det. policy fct. $\\bm{\\mu}(\\bm{x},\\bm{\\theta})$ and action-value fct. $\\hat{q}(\\bm{x},\\bm{u},\\bm{w})$}\n\\Param{step sizes and filter constant $\\{\\alpha_{w}, \\alpha_{\\theta}, \\tau\\}\\in\\left\\{\\mathbb{R}|0<\\alpha, \\tau<1\\right\\}$}\n\\Init{weights $\\bm{w}=\\bm{w}^{-}\\in\\mathbb{R}^{\\zeta}$ and $\\bm{\\theta}=\\bm{\\theta}^{-}\\in\\mathbb{R}^d$ arbitrarily, memory $\\bm{\\mathcal{D}}$}\\pause\n \\For{$j=1,2,\\ldots,$ episodes}{\n\t\tinitialize $\\bm{x}_0$\\; \n\t\t\\For{$k=0,1,\\ldots, T-1$ time steps}{\n\t\t\t$\\bm{u}_k \\leftarrow$ apply from $\\bm{\\mu}(\\bm{x}_k, \\bm{\\theta})$ w/wo noise or from behavior policy\\;\n\t\t\tobserve $\\bm{x}_{k+1}$ and $r_{k+1}$\\;\n\t\t\tstore tuple $\\left\\langle \\bm{x}_k, \\bm{u}_k, r_{k+1}, \\bm{x}_{k+1}\\right\\rangle$ in $\\bm{\\mathcal{D}}$\\;\\pause\n\t\t\tsample mini-batch $\\bm{\\mathcal{D}}_b$ from $\\bm{\\mathcal{D}}$ (after initial memory warmup)\\;\n\t\t\t\\For(calculate $Q$-targets){$i=1,\\ldots,b$ samples}{\n\t\t\t\t\\lIf{$\\bm{x}_{i+1}$ is terminal}{$y_i=r_{i+1}$}\n\t\t\t\t\\lElse{$y_i= r_{i+1}+ \\gamma \\hat{q}(\\bm{x}_{i+1},\\bm{\\mu}(\\bm{x}_{i+1},\\bm{\\theta}^{-}),\\bm{w}^{-})$}\n\t\t\t}\\pause\n\t\t\tfit $\\bm{w}$ on loss $\\mathcal{L}(\\bm{w})=[y - \\hat{q}(\\bm{x}, \\bm{u}, \\bm{w})]^2_{\\bm{\\mathcal{D}}_b}$ with step size $\\alpha_{w}$\\;\\pause\n\t\t\t$\\bm{\\theta} \\leftarrow \\bm{\\theta} + \\alpha_{\\theta} [\\nabla_{\\bm{\\theta}}\\bm{\\mu}(\\bm{x},\\bm{\\theta})\\nabla_{\\bm{u}}\\hat{q}(\\bm{x}, \\bm{u}, \\bm{w})\\vert_{\\bm{u}=\\bm{\\mu}_{\\bm{\\theta}}(\\bm{x})}]_{\\bm{\\mathcal{D}}_b}$\\;\\pause \n\t\t\tUpdate target net. $\\bm{w}^{-} \\leftarrow (1-\\tau)\\bm{w}^{-}+\\tau\\bm{w}, \\,\\, \\bm{\\theta}^{-} \\leftarrow (1-\\tau)\\bm{\\theta}^{-}+\\tau\\bm{\\theta}$\\;\n\t\t}\n\t}\n\\caption{Deep deterministic policy gradient (output: parameter vectors $\\bm{\\theta}^*$ for $\\bm{\\mu}^*(\\bm{x},\\bm{\\theta}^*)$) and $\\bm{w}^*$ for $\\hat{q}^*(\\bm{x}, \\bm{u}, \\bm{w}^*))$}\n\\label{algo:DDPG}\n\\end{algorithm}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Twin Delayed Deep Deterministic Policy Gradient (TD3)} \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}\n\\frametitle{Table of Contents}\n\\tableofcontents[currentsection]\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Bias %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Overestimation Bias}\n\\begin{itemize}\n\t\\item For $Q$-learning in the tabular case we have already discussed the \\hl{maximization bias} (cf. \\figref{Double_Learning_Example}) issue.\\pause\n\t\\item Recap: Due to the greedy policy targets, $\\hat{q}$ was overestimated when calculated using sampled values of stochastic MDPs.\\pause\n\t\\item Additional problem when applying function approximation: the estimator itself introduces additional variance during the learning process which represents another source of the maximization bias problem.\\pause\n\\end{itemize}\n\\begin{block}{}\nThis issue is already known in the DQN context (cf. \\algoref{algo:DQN}). Similar to the tabular case, \\hl{double DQN} introduces a second $Q$-network counteracting the overestimation issue (cf. \\href{https://arxiv.org/pdf/1509.06461.pdf}{paper by van Hasselt et al.}).\n\\end{block}\\pause\nHowever, we did not address this possible problem in an actor-critic context using function approximation (e.g., DDPG). \n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Bias in Actor-Critic Approaches (1) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Overestimation Bias in Actor-Critic Approaches (1)}\n\\begin{itemize}\n\t\\item It turns out that the overestimation bias is also an issue for actor-critic methods as shown next \\footnote[1]{Source: S. Fujimoto et al., \\textit{Addressing Function Approximation Error in Actor-Critic Methods}, \\href{https://arxiv.org/abs/1802.09477}{https://arxiv.org/abs/1802.09477}, 2018}.\\pause\n\t\\item Consider an actor-critic policy with the current policy parameters $\\bm{\\theta}$.\\pause\n\t\\item Let $\\tilde{\\bm{\\theta}}$ define the parameters from the actor update induced by the maximization of the approximate critic $\\hat{q}_{\\bm{w}}(\\bm{x}, \\bm{u})$. \\pause\n\t\\item Let $\\bm{\\theta}^*$ be the parameters from the hypothetical actor update w.r.t. the true underlying value function $q^{\\bm{\\pi}}(\\bm{x}, \\bm{u})$.\\pause\n\t\\item Then, we perform the policy update\n\t\\begin{equation}\n\\begin{aligned}\n\\tilde{\\bm{\\theta}} &= \\bm{\\theta} + \\frac{\\alpha}{Z_1} \\El{\\nabla_{\\bm{\\theta}} \\pi_{\\bm{\\theta}}(\\bm{X}) \\nabla_{\\bm{u}} \\hat{q}_{\\bm{w}}(\\bm{X},\\bm{U})\\left|\\bm{U}=\\bm{\\pi}_{\\bm{\\theta}}(\\bm{X})\\right.}{\\pi},\\\\\n\\bm{\\theta}^* &= \\bm{\\theta} + \\frac{\\alpha}{Z_2} \\El{\\nabla_{\\bm{\\theta}} \\pi_{\\bm{\\theta}}(\\bm{X}) \\nabla_{\\bm{u}} q^{\\bm{\\pi}}(\\bm{X},\\bm{U})\\left|\\bm{U}=\\bm{\\pi}_{\\bm{\\theta}}(\\bm{X})\\right.}{\\pi},\n\\end{aligned}\n\\end{equation} \nwhere $Z_1$ and $Z_2$ normalize the gradient such that $Z^{-1}||\\El{\\cdot}{}|| = 1$.\n\\end{itemize}\t\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Bias in Actor-Critic Approaches (2) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Overestimation Bias in Actor-Critic Approaches (2)}\n\\begin{itemize}\n\t\\item Lets denote $\\tilde{\\bm{\\pi}}$ and $\\bm{\\pi}^*$ as the policies with updated parameters $\\tilde{\\bm{\\theta}}$ and $\\bm{\\theta}^*$ respectively.\\pause\n\t\\item As the gradient direction is a local maximizer, there exists $\\epsilon_1$ sufficiently small such that if $\\alpha \\leq \\epsilon_1$ then the \\emph{approximate} value of $\\tilde{\\bm{\\pi}}$ will be bounded below by the \\emph{approximate} value of $\\bm{\\pi}^*$:\n\\begin{equation} \\label{eq:approx_q_TD3}\n\\E{\\hat{q}_{\\bm{w}}(\\bm{X}, \\tilde{\\bm{\\pi}}(\\bm{X}))} \\geq \\E{\\hat{q}_{\\bm{w}}(\\bm{X}, \\bm{\\pi}^*(\\bm{X}))}.\n\\end{equation}\\pause\n\\item Conversely, there exists $\\epsilon_2$ sufficiently small such that if $\\alpha \\leq \\epsilon_2$ then the \\emph{true} value of $\\tilde{\\bm{\\pi}}$ will be bounded above by the \\emph{true} value of $\\bm{\\pi}^*$:\n\\begin{equation} \\label{eq:true_q_TD3}\n\\E{q^{\\bm{\\pi}}(\\bm{X}, \\bm{\\pi}^*(\\bm{X}))} \\geq \\E{q^{\\bm{\\pi}}(\\bm{X}, \\tilde{\\bm{\\pi}}(\\bm{X}))}.\n\\end{equation}\\pause\n\\item In other words: if the approximate and true critics differ from each other, the according policy gradient updates cannot lead to better policy updates of the respective other framework.  \n\\end{itemize}\t\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Bias in Actor-Critic Approaches (3) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Overestimation Bias in Actor-Critic Approaches (3)}\n\\begin{itemize}\n\t\\item If the expected, estimated action value will be at least as large as the \\textit{true} action value w.r.t. $\\bm{\\theta}^*$\n\t\\begin{equation}\n  \\E{\\hat{q}_{\\bm{w}}(\\bm{X}, \\bm{\\pi}^*(\\bm{X}))} \\geq \\E{q^{\\bm{\\pi}}(\\bm{X}, \\bm{\\pi}^*(\\bm{X}))}, \n\\end{equation}\\pause\nthen \\eqref{eq:approx_q_TD3} and \\eqref{eq:true_q_TD3} imply \n\t\\begin{equation}\n  \\E{\\hat{q}_{\\bm{w}}(\\bm{X}, \\tilde{\\bm{\\pi}}(\\bm{X}))} \\geq \\E{q^{\\bm{\\pi}}(\\bm{X}, \\tilde{\\bm{\\pi}}(\\bm{X}))}\n\\end{equation}\n\twith a sufficiently small $\\alpha<\\min\\{\\epsilon_1, \\epsilon_2\\}$.\\pause\n\t\\item Hence, the \\hl{maximization bias is also present in actor-critic} updates.\\pause\n\t\\item It can add up over several estimation updates and, therefore, may lead to suboptimal policy updates.\\pause\n\t\\item A proof for unnormalized gradients can be also found in S. Fujimoto et al., \\textit{Addressing Function Approximation Error in Actor-Critic Methods}, 2018.\n\\end{itemize}\t\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Example for DDPG%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Overestimation Example for DDPG}\n\\vspace{0.75cm}\n\\begin{figure}\n\\includegraphics[height=4cm]{fig/lec13/DDPG_Overestimation.pdf}\n\\caption{Comparison of true and estimated values averaged over 10000 states in two robotic examples from \\href{https://gym.openai.com/envs/\\#mujoco}{OpenAI Gym}. Estimated values originate from the approximate DDPG critic while the true values are based on the average discounted return over 1000 episodes following the current policy, starting from states sampled from the replay buffer (source: S. Fujimoto et al., \\textit{Addressing Function Approximation Error in Actor-Critic Methods}, 2018.}\n\\label{fig:DDPG_Overestimation}\n\\end{figure}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Overestimation Example for DDPG%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Increased Variance due to Accumulating TD Errors}\n\\begin{itemize}\n\t\\item Using function approximation, the \\hl{Bellman equation is never exactly satisfied} leaving room for some amount of \\hl{residual TD-error} $\\tilde{\\delta}(\\bm{x}, \\bm{u})$:\n\t\\begin{equation}\n\t\t\\hat{q}_{\\bm{w}}(\\bm{x}, \\bm{u}) = r + \\gamma \\El{\\hat{q}_{\\bm{w}}(\\bm{X}', \\bm{U}')|\\bm{X}'=\\bm{x}', \\bm{U}'=\\bm{u}'}{\\pi} - \\tilde{\\delta}(\\bm{x}, \\bm{u}).\n\t\\end{equation}\\pause\n\t\\item Although this error might be considered small per update step, it may accumulate over future steps if biased:\n\t\\begin{align}\n\t\t\\hat{q}_{\\bm{w}}(\\bm{x}, \\bm{u}) =\\El{\\sum_{k=0}^\\infty\\gamma^{k}\\left(R_k-\\tilde{\\delta}_{k}(\\bm{X}, \\bm{U})\\right)\\left|\\vphantom{\\sum_{k=0}^\\infty}\\bm{X}=\\bm{x}, \\bm{U}=\\bm{u}\\right.}{\\pi}.\n\t\\end{align}\\pause\n\t\\item Observation: the \\hl{variance of $\\hat{q}$ will be proportional to the variance of future reward and residual TD-errors}.\\pause\n\t\\item If $\\gamma$ is large, the estimation variance might increase significantly.\\pause\n\t\\item Mini-batch sampling will contribute to this variance issue. \n\\end{itemize}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% TD3 Extensions and Modifications (1) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{TD3 Extensions and Modifications (1)}\n\\begin{block}{}\n\t In order to reduce both the maximization bias and the learning variance, TD3 introduces mainly three measures on top of the DDPG algorithm. Hence, \\hl{TD3 is a direct successor of DDPG}. \n\\end{block}\\pause\n\\hl{Measure \\#1}: clipped double $Q$-learning for actor-critic\n\\begin{itemize}\n\t\\item Following double $Q$-learning, a pair of critics $\\{\\hat{q}_{\\bm{w}_1}, \\hat{q}_{\\bm{w}_2}\\}$ is introduced.\\pause\n\t\\item In contrast, the clipped target (with target networks $\\{\\bm{w}^{-}_1, \\bm{w}^{-}_2\\}$)\n\t\\begin{equation}\n\t\\label{eq:Q_clipping_TD3}\n\t\ty = r + \\gamma \\min_{i=1,2}\\hat{q}_{\\bm{w}^{-}_i}(\\bm{x}', \\bm{u}')\n\t\\end{equation}\n\tprovides an upper-bound on the estimated action value.\\pause\n\t\\item May introduce some underestimation, which is considered less critical than overestimation, since the value of underestimated actions will not be explicitly propagated through the policy update. \\pause\n\t\\item The $\\min$ operator will also (indirectly) favor actions leading to values with estimation errors of lower variance. \n\\end{itemize}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% TD3 Extensions and Modifications (2) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{TD3 Extensions and Modifications (2)}\n\\hl{Measure \\#2}: target policy smoothing regularization\n\\begin{itemize}\n\t\\item Background: deterministic policies $\\bm{\\mu}$ tend to overfit to narrow peaks in the action-value estimate.\\pause\n\t\\item Counteraction: fit the action value of a small area around the target action (i.e., smoothing $\\hat{q}$ in the action space):\n\t\\begin{equation}\n\t\ty = r + \\gamma \\hat{q}_{\\bm{w}^{-}}(\\bm{x}', \\bm{\\mu}_{\\bm{\\theta}^{-}}(\\bm{x}')+\\bm{\\epsilon}).\n\t\\end{equation}\\pause\n\t\\item Here, $\\bm{\\epsilon}\\sim\\mathrm{clip}\\left(\\mathcal{N}(\\bm{0},\\bm{\\Sigma}), -\\bm{c},\\bm{c}\\right)$ is a mean-free, Gaussian noise with covariance $\\bm{\\Sigma}$, which is clipped at $\\pm \\bm{c}$ while $\\bm{\\theta}^{-}$ are the policy target network parameters.\\pause\n\t\\item To satisfy possible action constraints (denoted by upper and lower box constraints $\\{\\underline{\\bm{u}}, \\overline{\\bm{u}}\\}$), we add an additional clipping:\n\t\\begin{equation}\n\t\t\\bm{u}'=\\mathrm{clip}\\left(\\bm{\\mu}_{\\bm{\\theta}^{-}}(\\bm{x}')+\\bm{\\epsilon}, \\underline{\\bm{u}}, \\overline{\\bm{u}} \\right).\n\t\\end{equation}\\pause\n\t\\item This modified action is then used for the target calculation \\eqref{eq:Q_clipping_TD3}.\n\\end{itemize}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% TD3 Extensions and Modifications (3) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{TD3 Extensions and Modifications (3)}\n\\hl{Measure \\#3}: delayed policy updates\n\\begin{itemize}\n\t\\item Similar to DDPG, TD3 uses policy target networks $\\bm{\\theta}^{-}$ and (two) critic target networks $\\{\\bm{w}^{-}_{1}, \\bm{w}^{-}_{2}\\}$ in order to provide (rather) fixed $Q$-learning targets trying to stabilize the learning of $\\hat{q}$.\\pause\n\t\\item The target networks are also continuously updated using\n\t\\begin{equation*}\n\t\t\\bm{w}_{i}^{-} \\leftarrow (1-\\tau)\\bm{w}_{i}^{-}+\\tau\\bm{w}_{i}, \\quad \\bm{\\theta}^{-} \\leftarrow (1-\\tau)\\bm{\\theta}^{-}+\\tau\\bm{\\theta}.\n\t\\end{equation*}\\pause\n\t\\item However, each policy update will inherently change the (true) $Q$-learning target directly adding variance to the learning process (cf. \\figref{fig:Policy_Update_Frequency_TD3} on next slide).\\pause\n\t\\item Therefore, it is argued that a policy update should not follow after each $Q$-learning update such that the critic can adapt properly to the previous policy update.\\pause\n\t\\item The original TD3 implementation suggests a policy update every second $Q$-learning update, however, we can consider this update rate a hyperparameter.\n\\end{itemize}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% TD3 Extensions and Modifications (4) %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{TD3 Extensions and Modifications (4)}\n\\vspace{0.775cm}\n\\begin{figure}\n\\includegraphics[height=4cm]{fig/lec13/Policy_Update_Frequency_TD3.pdf}\n\t\\caption{Average estimated action value of a randomly selected state on Hopper-v1 environment from \\href{https://gym.openai.com/envs/\\#mujoco}{OpenAI Gym} (source: S. Fujimoto et al., \\textit{Addressing Function Approximation Error in Actor-Critic Methods}, 2018.}\n\t\\label{fig:Policy_Update_Frequency_TD3}\n\\end{figure}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Algorithmic Implementation: TD3 %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{%\\frametitle{Algo. Implementation: TD3}\n\\setlength{\\algomargin}{0.5em}\n\\begin{algorithm}[H]\n\\footnotesize\n\\SetKwInput{Input}{input} \n\\SetKwInput{Output}{output}\n\\SetKwInput{Init}{init}\n\\SetKwInput{Param}{parameter}\n\\Input{diff. det. policy fct. $\\bm{\\mu}(\\bm{x},\\bm{\\theta})$ and action-value fct. $\\hat{q}(\\bm{x},\\bm{u},\\bm{w})$}\n\\Param{step sizes and filter constant $\\{\\alpha_{w}, \\alpha_{\\theta}, \\tau\\}\\in\\left\\{\\mathbb{R}|0<\\alpha, \\tau<1\\right\\}$, policy update rate $k_w\\in\\left\\{\\mathbb{N}|1\\leq k_w\\right\\}$, target noise $\\bm{\\Sigma}\\in\\mathbb{R}^{m \\times m}$ and $\\bm{c}\\in\\mathbb{R}^{m}$}\n\\Init{weights $\\{\\bm{w}_{1}=\\bm{w}_{1}^{-}$, $\\bm{w}_{2}=\\bm{w}_{2}^{-}\\}\\in\\mathbb{R}^{\\zeta}$,  $\\bm{\\theta}=\\bm{\\theta}^{-}\\in\\mathbb{R}^d$ arbitrarily, memory $\\bm{\\mathcal{D}}$}\\pause\n \\For{$j=1,2,\\ldots,$ episodes}{\n\t\tinitialize $\\bm{x}_0$\\; \n\t\t\\For{$k=0,1,\\ldots, T-1$ time steps}{\n\t\t\t$\\bm{u}_k \\leftarrow$ apply from $\\bm{\\mu}(\\bm{x}_k, \\bm{\\theta})$ w/wo noise or from behavior policy\\;\n\t\t\tobserve $\\bm{x}_{k+1}$ and $r_{k+1}$\\;\n\t\t\tstore tuple $\\left\\langle \\bm{x}_k, \\bm{u}_k, r_{k+1}, \\bm{x}_{k+1}\\right\\rangle$ in $\\bm{\\mathcal{D}}$\\;\\pause\n\t\t\tsample mini-batch $\\bm{\\mathcal{D}}_b$ from $\\bm{\\mathcal{D}}$ (after initial memory warmup)\\;\n\t\t\t\\For(calculate $Q$-targets){$i=1,\\ldots,b$ samples}{\n\t\t\t\t\\lIf{$\\bm{x}_{i+1}$ is terminal}{$y_i=r_{i+1}$}\n\t\t\t\t\\Else{\n\t\t\t\t\t\t\t$\\bm{u}'=\\mathrm{clip}\\left(\\bm{\\mu}_{\\bm{\\theta}^{-}}(\\bm{x}_{i+1})+\\mathrm{clip}\\left(\\mathcal{N}(\\bm{0},\\bm{\\Sigma}), -\\bm{c},\\bm{c}\\right), \\underline{\\bm{u}}, \\overline{\\bm{u}} \\right)$\\;\t\n\t\t\t\t\t\t\t$y_i= r_{i+1}+ \\gamma \\min_{l=1,2}\\hat{q}(\\bm{x}_{i+1},\\bm{u}',\\bm{w}_{l}^{-})$\\;\n\t\t\t\t\t\t\t}\n\t\t\t}\\pause\n\t\t\tfit $\\bm{w}_{l}$ on loss $\\mathcal{L}(\\bm{w}_{l})=[y - \\hat{q}(\\bm{x}, \\bm{u}, \\bm{w}_{l})]^2_{\\bm{\\mathcal{D}}_b}$ with step size $\\alpha_{w}$ $\\forall \\, l$\\;\\pause\n\t\t\t\\If{$k \\mod k_w=0$}{\n\t\t\t\t\t$\\bm{\\theta} \\leftarrow \\bm{\\theta} + \\alpha_{\\theta} [\\nabla_{\\bm{\\theta}}\\bm{\\mu}(\\bm{x},\\bm{\\theta})\\nabla_{\\bm{u}}\\hat{q}(\\bm{x}, \\bm{u}, \\bm{w}_1)\\vert_{\\bm{u}=\\bm{\\mu}_{\\bm{\\theta}}(\\bm{x})}]_{\\bm{\\mathcal{D}}_b}$\\; \\pause\n\t\t\t\t\t$\\bm{w}_{l}^{-} \\leftarrow (1-\\tau)\\bm{w}_{l}^{-}+\\tau\\bm{w}_{l}, \\,\\, \\bm{\\theta}^{-} \\leftarrow (1-\\tau)\\bm{\\theta}^{-}+\\tau\\bm{\\theta}$\\;\n\t\t\t}\n\t}\n}\n\\caption{Twin delayed deep deterministic policy gradient (output: parameter vectors $\\bm{\\theta}^*$ for $\\bm{\\mu}^*(\\bm{x},\\bm{\\theta}^*)$) and $\\bm{w}^*$ for $\\hat{q}^*(\\bm{x}, \\bm{u}, \\bm{w}^*))$}\n\\label{algo:TD3}\n\\end{algorithm}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Trust Region Policy Optimization (TRPO)} \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}\n\\frametitle{Table of Contents}\n\\tableofcontents[currentsection]\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Reinterpreting the Policy Gradient for Stochastic Policies (1)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\setcounter{footnote}{0}\n\\frame{\\frametitle{Reinterpreting the Stochastic Policy Gradient (1)}\n\\vspace{-0.2cm}\n\\begin{itemize}\n\t\\item In contrast to the previous two algorithms, we will \\hl{focus on stochastic policies} $\\pi(\\bm{u}|\\bm{x})$ in the following.\\pause\n\t\\item First, we rewrite the performance metric \\eqref{eq:performance_metric_episodic} to obtain\n\t\t\\begin{equation}\n\t\tJ_{\\pi} =\\El{\\sum_{k=0}^\\infty \\gamma^k R_k}{\\pi}.\n\t\\end{equation}\\vspace{-0.5cm}\\pause\n\t\\item Using the advantage $a_\\pi(\\bm{x},\\bm{u})= q_{\\pi}(\\bm{x},\\bm{u})-v_{\\pi}(\\bm{x})$ we can calculate the performance of an updated policy $\\bm{\\pi}\\rightarrow\\tilde{\\bm{\\pi}}$\\footnote{proof from: S. Kakade and J. Langford, \\textit{Approximately optimal approximate reinforcement learning}, ICML, vol. 2, pp 267-274, 2002}:\n\t\t\\begin{equation}\n\t\t\\label{eq:TRPO_perf_change}\n\t\tJ_{\\tilde{\\pi}} =J_{\\pi} + \\int_\\mathcal{X}p^{\\tilde{\\pi}}(\\bm{x})\\int_{\\mathcal{U}} \\tilde{\\pi}(\\bm{u}|\\bm{x})a_\\pi(\\bm{x},\\bm{u}).\n\t\\end{equation}\\vspace{-0.5cm}\\pause\n\t\\item While for finite MDPs, the policy improvement theorem guaranteed  $J_{\\tilde{\\pi}} \\geq J_{\\pi}$ for each policy update, there might be some states where $\\int_{\\mathcal{U}} \\tilde{\\pi}(\\bm{u}|\\bm{x})a_\\pi<0$ for continuous MDPs using function approximation. \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Reinterpreting the Policy Gradient for Stochastic Policies (2)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Reinterpreting the Stochastic Policy Gradient  (2)}\n\\begin{itemize}\n\t\\item For easier calculation, we introduce a local approximation to \\eqref{eq:TRPO_perf_change}\n\t\\begin{equation}\n\t\t\\mathcal{L}_{\\pi}(\\tilde{\\pi}) =J_{\\pi} + \\int_\\mathcal{X}p^{\\pi}(\\bm{x})\\int_{\\mathcal{U}} \\tilde{\\pi}(\\bm{u}|\\bm{x})a_\\pi(\\bm{x},\\bm{u})\n\t\\end{equation}\n\twhere $p^{\\pi}(\\bm{x})$ is used instead of $p^{\\tilde{\\pi}}(\\bm{x})$, i.e., neglecting the state distribution change due to a policy update.\\pause\n\t\\item For any parametrized and differentiable policy $\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})$, it can be shown that\n\t\\begin{equation}\n\t\\begin{split}\n\t\t \\mathcal{L}(\\pi_{\\bm{\\theta}_0}) &= J(\\pi_{\\bm{\\theta}_0}),\\\\\n\t\t\\nabla_{\\bm{\\theta}}\\mathcal{L}_{\\pi_{\\bm{\\theta}_0}}(\\pi_{\\bm{\\theta}})|_{\\bm{\\theta}=\\bm{\\theta}_0} &= \\nabla_{\\bm{\\theta}}J(\\pi_{\\bm{\\theta}})|_{\\bm{\\theta}=\\bm{\\theta}_0}\n\t\\end{split}\t\n\t\\end{equation}\n\tfor any initial parameter set $\\bm{\\theta}_0$.\\pause\n\t \\item For a sufficiently small step size, improving $\\mathcal{L}_{\\pi_{\\bm{\\theta}_0}}$ will also improve $J$. \\pause\n\\end{itemize}\n\\begin{block}{}\nHowever, we do not know how much the actual stochastic policy will change while moving through the parameter space. Hence, we do not have a good decision basis to choose the policy gradient step size.   \n\\end{block}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Adding a Trust Region Constraint (1)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Adding a Trust Region Constraint (1)}\n\\begin{itemize}\n\t\\item From the previous discussion it can be concluded that we want a \\hl{metric describing how much a policy is changed in the action space when updating the policy in the parameter space}. \\pause \n\t\\item Against this background, we make use of the \\hl{Kullback-Leibler divergence} (also called relative entropy)\n\t\\begin{equation}\n\t\tD_{\\mathrm{KL}}(P \\parallel Q) = \\int_{-\\infty}^\\infty p(x) \\log\\left(\\frac{p(x)}{q(x)}\\right)\\, \\mathrm{d}x\n\t\\end{equation}\n\tdefined for continuous distributions $P$ and $Q$ with their probability densities $p$ and $q$. \\pause\n\t\\item Example: for two multivariate Gaussian distributions of equal dimensions $d$, with means $\\bm{\\mu}_0, \\bm{\\mu}_1$ and with (non-singular) covariance matrix $\\bm{\\Sigma}_0, \\bm{\\Sigma}_1$ we receive\n\\end{itemize}\n\t\\small\n\t\\begin{align*}\nD_{\\mathrm{KL}}\\left(\\mathcal{N}_0 \\parallel \\mathcal{N}_1\\right) =  \\frac{1}{2}&\\left(\\mathrm{tr}\\left(\\bm{\\Sigma}_1^{-1}\\bm{\\Sigma}_0\\right) + \\left(\\bm{\\mu}_1 - \\bm{\\mu}_0\\right)\\T \\bm{\\Sigma}_1^{-1}\\left(\\bm{\\mu}_1 - \\bm{\\mu}_0\\right) \\right. \\\\ &\\left.- d + \\ln\\left(\\frac{\\det\\bm{\\Sigma}_1}{\\det\\bm{\\Sigma}_0}\\right) \\right).\t\t\n\t\\end{align*}\n\t\\normalsize\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Adding a Trust Region Constraint (2)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Adding a Trust Region Constraint (2)}\n\\begin{itemize}\n\t\\item The \\hl{trust region policy optimization (TRPO)} updates the policy parameters while constraining the KL divergence between the new and the old policy distribution:\n\t\\begin{equation}\n\t\\label{eq:TRPO_opt_prob}\n\t\\begin{split}\n\t\t &\\max_{\\bm{\\theta}}  \\, \\mathcal{L}_{\\bm{\\theta}_k}(\\bm{\\theta}),\\\\\n\t\t \\mbox{s.t.} \\quad\\quad  & \\overline{D}_{\\mathrm{KL}}(\\bm{\\theta}_k, \\bm{\\theta})\\leq\\kappa\n\t\\end{split}\n\t\\end{equation}\\pause\n\twith \n\\end{itemize}\n\\vspace{0.15cm}\n\t\\begin{equation*}\n\\overline{D}_{\\mathrm{KL}}(\\bm{\\theta}_k, \\bm{\\theta})=\\overline{D}_{\\mathrm{KL}}(\\pi_{\\bm{\\theta}_k}, \\pi_{\\bm{\\theta}})=\\El{D_{\\mathrm{KL}}(\\pi_{\\bm{\\theta}_k}(\\cdot|\\bm{X}) \\parallel \\pi_{\\bm{\\theta}}(\\cdot|\\bm{X}))}{\\pi_{\\bm{\\theta}_k}}.\n\t\\end{equation*}\n\t\\vspace{-0.25cm}\\pause\n\\begin{itemize}\n\t\\item Hence, we want to \\hl{limit the average KL divergence w.r.t. the states visited by the old policy}.\\pause\n\t\\item The constraint $\\kappa$ is a TRPO hyperparameter (typically $\\kappa<<1$). \\pause\n\t\\item Although \\eqref{eq:TRPO_opt_prob}  does not provide any formal convergence guarantee, we at least have a link between changes in the parameter and policy distribution space. Therefore, \\hl{we can use this tool to prevent erratic policy changes}.  \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Sample-Based Estimation of the Objective and Constraint%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Sample-Based Objective and Constraint Estimation (1)}\n\\begin{itemize}\n\t\\item To actually solve \\eqref{eq:TRPO_opt_prob} we will make use of samplings from \\hl{Monte-Carlo rollouts}.\\pause\n\t\\item Expanding the objective yields\n\t\\begin{equation}\n\t\t\\max_{\\bm{\\theta}}  \\, \\mathcal{L}_{\\bm{\\theta}_k}(\\bm{\\theta})= \\max_{\\bm{\\theta}} \\, J_{\\pi_k} + \\int_\\mathcal{X}p^{\\pi_k}(\\bm{x})\\int_{\\mathcal{U}} \\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})a_{\\pi_k}(\\bm{x},\\bm{u}).\n\t\\end{equation}\\pause\n\t\\item The first term $J_{\\pi_k}$ can be dropped, since it is irrelevant for the optimization result (constant).\\pause\n\t\\item Using samples we can approximate $\\int_\\mathcal{X}p^{\\pi_k}(\\bm{x})\\approx\\frac{1}{1-\\gamma}\\El{\\bm{X}}{\\pi_{\\bm{\\theta}_k}}$.\\pause\n\t\\item Moreover, $\\int_{\\mathcal{U}} \\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})a_{\\pi_k}(\\bm{x},\\bm{u})\\approx\\El{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U})}{\\pi_{\\bm{\\theta}_k}}$ is also approximated applying importance sampling based on data from the old policy.\\pause\n\t\\item Hence, the sampled objective is\n\t\\begin{equation}\n\t\t\\max_{\\bm{\\theta}} \\,\\El{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U})}{\\pi_{\\bm{\\theta}_k}}.\n\t\\end{equation}\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Smooth Policy Updates via TRPO %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Smooth Policy Updates via TRPO}\n\\begin{figure}\n\\includegraphics[height=5.75cm]{fig/lec13/TRPO_Style_Updates.pdf}\n\\caption{Simplified representation of the policy evolution for a scalar action given some fixed state. Left: TRPO-style updates finding the optimal action with increasing probability. Right: Unmonitored policy distributions not converging towards an optimal policy ('policy chattering').}\n\\label{fig:TRPO_Style_Updates}\n\\end{figure}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Sample-Based Estimation of the Objective and Constraint%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Sample-Based Objective and Constraint Estimation (2)}\n\\begin{itemize}\n\t\\item Applying the previous sample-based estimation we obtain\n\\end{itemize}\n\\vspace{0.15cm}\n\t\t\\begin{equation}\n\t\\label{eq:TRPO_opt_prob_sample}\n\t\\begin{split}\n\t\t &\\bm{\\theta}_{k+1} = \\argmax_{\\bm{\\theta}} \\,\\El{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U})}{\\pi_{\\bm{\\theta}_k}},\\\\\n\t\t \\mbox{s.t.} \\quad\\quad  & \\El{D_{\\mathrm{KL}}(\\pi_{\\bm{\\theta}_k}(\\cdot|\\bm{X}) \\parallel \\pi_{\\bm{\\theta}}(\\cdot|\\bm{X}))}{{\\pi_{\\bm{\\theta}_k}}}\\leq\\kappa.\n\t\\end{split}\n\t\\end{equation}\n\t\\vspace{-0.25cm}\n\\begin{itemize}\\pause\n\t\\item Hence, we have a \\hl{three-step procedure} for each TRPO update:\\pause\n\\end{itemize}\n\\begin{enumerate}\n\t\\item Use Monte-Carlo simulations based on the old policy to obtain data.\\pause\n\t\\item Use the data to construct \\eqref{eq:TRPO_opt_prob_sample}.\\pause\n\t\\item Solve the constrained optimization problem to update the policy parameter vector. \n\\end{enumerate}\\pause\n\\begin{block}{}\nSolving  \\eqref{eq:TRPO_opt_prob_sample} is generally a nonlinear optimization problem. The original TRPO implementation uses a local objective and constraint approximation together with conjugate gradient and line search algorithms. However, many other constrained-nonlinear solvers are also applicable.\n\\end{block}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Generalized Advantage Estimation %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Generalized Advantage Estimation}\n\\setcounter{footnote}{0}\n\\begin{itemize}\n\t\\item Having data $\\left\\langle \\bm{x}, \\bm{u}, r, \\bm{x}'\\right\\rangle$ in $\\bm{\\mathcal{D}}$ from a Monte Carlo rollout available, an imporant problem is to estimate $a_{\\pi_k}(\\bm{x},\\bm{u})$ in \\eqref{eq:TRPO_opt_prob_sample}.\\pause\n\t\\item A particular suggestion in the TRPO context is to use a \\hl{generalized advantage estimator (GAE)} \\footnote{cf. J. Schulmann et al., \\textit{High Dimensional Continuous Control Using Generalized Advantage Estimation}, \\href{https://arxiv.org/abs/1506.02438}{https://arxiv.org/abs/1506.02438}, 2015} defined as\n\t\\begin{equation}\n\t\\label{eq:GAE}\n\t\t\\hat{a}_k^{(\\gamma, \\lambda)} = \\sum_{i=0}^\\infty (\\gamma\\lambda)^i\\delta_{k+i}.\n\t\\end{equation}\\pause\n\t\\item Here, $\\delta_{k}=r_k+\\gamma v(\\bm{x}_{k+1})-v(\\bm{x}_{k})$ is a single advantage sample.\\pause\n\t\\item Hence, the GAE is the exponentially-weighted average of the discounted advantage samples with an additional weighting $\\lambda$.\\pause\n\t\\item Similar formulation compared to TD$(\\lambda)$ but instead of the state value the estimator's target is the advantage. \\pause\n\t\\item The choice of $(\\gamma\\lambda)$ trade-offs the bias and variance of the estimator. \n\\end{itemize}\t\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Summary %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{TRPO Summary}\n\\vspace{-0.1cm}\nThe TRPO's key facts are:\n\\begin{itemize}\n\t\\item The TRPO constrains policy distribution changes when updating the policy parameters (for stochastic policies and on-policy learning).\\pause\n\t\\item The objective is to enable a monotonically improving learning process.\\pause\n\t\\item Using trust regions, erratic policy updates should be prevented.\\pause\n\\end{itemize}\t\nThe TRPO's main hurdles are:\n\\begin{itemize}\n\t\\item Constructing the objective function and constraint requires Monte Carlo rollouts (time consuming, data inefficient).\\pause\n\t\\item When the sampled optimization problem is set up, a nonlinear and constrained optimization step is required (no simple policy gradient).\\pause\n\t\\item For speedy implementations, only approximate solutions of the TRPO problem are possible.\n\\end{itemize}\\pause\t\n\\begin{block}{}\nWe will not provide any specific TRPO implementation suggestion at this point, since this is rather cumbersome. Instead we will move forward to a similar algorithm which is pursuing the same goal (prevent erratic policy changes) with a much simpler implementation.  \n\\end{block}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Proximal Policy Optimization (PPO)} \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}\n\\frametitle{Table of Contents}\n\\tableofcontents[currentsection]\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Background and Motivation %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Background and Motivation}\n\\begin{itemize}\n\t\\item The upcoming \\hl{proximal policy optimization (PPO)} algorithm tries to mimic the constrained TRPO problem based on related unconstrained problems. \n\\end{itemize}\t\n\\vspace{0.15cm}\n\t\t\\begin{equation*}\n\t\\begin{split}\n\t\t &\\bm{\\theta}_{k+1} = \\argmax_{\\bm{\\theta}} \\,\\El{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U})}{\\pi_{\\bm{\\theta}_k}},\\\\\n\t\t \\mbox{s.t.} \\quad\\quad  & \\El{D_{\\mathrm{KL}}(\\pi_{\\bm{\\theta}_k}(\\cdot|\\bm{X}) \\parallel \\pi_{\\bm{\\theta}}(\\cdot|\\bm{X}))}{{\\pi_{\\bm{\\theta}_k}}}\\leq\\kappa.\n\t\\end{split}\n\t\\end{equation*}\n\\vspace{-0.25cm}\\pause\n\\begin{itemize}\n\t\\item Hence, the objective will be reformulated to incorporate mechanisms preventing excessively large variations of the policy distribution during a parameter update (leading to an updated policy with sufficient proximity to the old one).  \\pause\n\t\\item Moreover, PPO incorporates two variants which we will discuss:\n\t\\begin{enumerate}\n\t\\item Clipping the surrogate objective,\\pause\n\t\\item Adaptive tuning of a KL-associated penalty coefficient.\n\\end{enumerate}\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Clipped Surrogate Objective %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Clipped Surrogate Objective}\n\\begin{itemize}\n\t\\item The first approach is based on the following objective:\n\\end{itemize}\n\\vspace{0.25cm}\n\\small\n\\begin{equation}\n\\label{eq:PPO_CSO}\n\t\t\\hspace{-0.2cm}\\El{\\min\\left\\{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U}), \\mathrm{clip}\\left(\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}, 1-\\epsilon, 1+\\epsilon\\right)a_{\\pi_k}(\\bm{X},\\bm{U})\\right\\}}{\\pi_{\\bm{\\theta}_k}}.\n\\end{equation}\\pause\n\\normalsize\n\\begin{itemize}\n\t\\item Above, $\\epsilon<1$ is a PPO hyperparameter serving as a regularizer.\\pause\n\t\\item The first element of $\\min\\{\\cdot\\}$ is the previous TPRO objective.\\pause\n\t\\item The second element of $\\min\\{\\cdot\\}$ modifies the surrogate objective by clipping the importance sampling ratio $\\pi_{\\bm{\\theta}}/\\pi_{\\bm{\\theta}_k}$.\\pause\n\t\\item The latter should remove the incentive for moving the importance sampling ratio outside of the interval $[1-\\epsilon, 1+\\epsilon]$.\\pause\n\t\\item The modified objective is therefore a lower bound of the unclipped TRPO objective. \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Clipped Surrogate Objective: Positive Advantage %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Clipped Surrogate Objective: Positive Advantage}\n\\begin{itemize}\n\t\\item Consider a single sample $(\\bm{x}, \\bm{u})$ with a \\hl{positive advantage} $a_{\\pi_k}(\\bm{x},\\bm{u})$:\\pause\n\\end{itemize}\n\\vspace{0.1cm}\n\\begin{equation*}\n\t\t\\max_{\\bm{\\theta}}\\,\\min\\left\\{\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})}a_{\\pi_k}(\\bm{x},\\bm{u}), \\mathrm{clip}\\left(\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})}, 1-\\epsilon, 1+\\epsilon\\right)a_{\\pi_k}(\\bm{x}, \\bm{u})\\right\\}.\n\\end{equation*}\\pause\n\\begin{itemize}\n\t\\item Because the advantage is positive, the objective will increase if the action becomes more likely, i.e., if $\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})$ increases.\\pause\n\t\\item If $\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x}) > (1+\\epsilon)\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})$ the clipping becomes active.\\pause\n\t\\item Hence, the objective reduces to\n\t\\begin{equation*}\n\t\t\\max_{\\bm{\\theta}}\\,\\min\\left\\{\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})},  1+\\epsilon\\right\\}a_{\\pi_k}(\\bm{x},\\bm{u}).\n\\end{equation*}\\pause\n\t\\item Due to the $\\min\\{\\cdot\\}$ operator, the entire objective is therefore limited to $(1+\\epsilon)a_{\\pi_k}(\\bm{x},\\bm{u})$.\\pause\n\t\\item Interpretation: the new policy does not benefit from going further away from the old policy.\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Clipped Surrogate Objective: Negative Advantage %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Clipped Surrogate Objective: Negative Advantage}\n\\begin{itemize}\n\t\\item Consider a single sample $(\\bm{x}, \\bm{u})$ with a \\hl{negative advantage} $a_{\\pi_k}(\\bm{x},\\bm{u})$:\\pause\n\\end{itemize}\n\\vspace{0.1cm}\n\\begin{equation*}\n\t\t\\max_{\\bm{\\theta}}\\,\\min\\left\\{\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})}a_{\\pi_k}(\\bm{x},\\bm{u}), \\mathrm{clip}\\left(\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})}, 1-\\epsilon, 1+\\epsilon\\right)a_{\\pi_k}(\\bm{x},\\bm{u})\\right\\}.\n\\end{equation*}\\pause\n\\begin{itemize}\n\t\\item Because the advantage is negative, the objective will increase if the action becomes less likely, i.e., if $\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})$ decreases.\\pause\n\t\\item If $\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x}) < (1-\\epsilon)\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})$ the clipping becomes active.\\pause\n\t\\item Hence, the objective reduces to\n\t\\begin{equation*}\n\t\t\\max_{\\bm{\\theta}}\\,\\max\\left\\{\\frac{\\pi_{\\bm{\\theta}}(\\bm{u}|\\bm{x})}{\\pi_{\\bm{\\theta}_k}(\\bm{u}|\\bm{x})},  1-\\epsilon\\right\\}a_{\\pi_k}(\\bm{x},\\bm{u}).\n\\end{equation*}\\pause\n\t\\item Due to the $\\max\\{\\cdot\\}$ operator, the entire objective is limited to $(1-\\epsilon)a_{\\pi_k}(\\bm{x},\\bm{u})$.\\pause\n\t\\item Interpretation: the new policy does not benefit from going further away from the old policy.\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Adaptive KL Penalty %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Adaptive KL Penalty}\n\\begin{itemize}\n\t\\item The second PPO variant makes use of the following KL-penalized objective\n\\end{itemize}\n\\vspace{0.15cm}\n\\small\n\t\\begin{equation}\n\t\\label{eq:PPO_AKP}\n      \\El{\\frac{\\pi_{\\bm{\\theta}}(\\bm{U}|\\bm{X})}{\\pi_{\\bm{\\theta}_k}(\\bm{U}|\\bm{X})}a_{\\pi_k}(\\bm{X},\\bm{U})-\\beta D_{\\mathrm{KL}}(\\pi_{\\bm{\\theta}_k}(\\cdot|\\bm{X}) \\parallel \\pi_{\\bm{\\theta}}(\\cdot|\\bm{X}))}{\\pi_{\\bm{\\theta}_k}}.\t\t\n\t\\end{equation}\n\t\\normalsize\\pause\n\t\\vspace{-0.25cm}\n\\begin{itemize}\n\t\\item Transfers the KL-based constraint into a penalty for large policy distribution changes.\\pause\n\t\\item The parameter $\\beta$ weights the penalty against the policy improvement.\\pause\n\t\\item The original PPO implementation suggests an adaptive tuning of $\\beta$ w.r.t. the sampled average KL divergence $\\overline{D}_{\\mathrm{KL}}(\\bm{\\theta}_k, \\bm{\\theta})$ estimated from previous experience\n\t\\begin{equation}\n\t\\begin{split}\n\t\t  \\overline{D}_{\\mathrm{KL}}(\\bm{\\theta}_k, \\bm{\\theta}) < \\overline{D}^*_{\\mathrm{KL}}: &\\quad \\beta \\leftarrow \\beta/2,\\\\ \n\t\t\t\\overline{D}_{\\mathrm{KL}}(\\bm{\\theta}_k, \\bm{\\theta}) > \\overline{D}^*_{\\mathrm{KL}}: &\\quad \\beta \\leftarrow \\beta \\cdot 2.\n\t\\end{split}\t\n\t\\end{equation}\n\twith some target value of the KL divergence $\\overline{D}^*_{\\mathrm{KL}}$ (additional hyperparameter). \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Algorithmic Implementation: PPO %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Algo. Implementation: PPO}\n\\setlength{\\algomargin}{0.5em}\n\\begin{algorithm}[H]\n\\small\n\\SetKwInput{Input}{input} \n\\SetKwInput{Output}{output}\n\\SetKwInput{Init}{init}\n\\SetKwInput{Param}{parameter}\n\\Input{diff. stochastic policy fct. $\\pi(\\bm{u}|\\bm{x},\\bm{\\theta})$ and value fct. $\\hat{v}(\\bm{x},\\bm{w})$}\n\\Param{step sizes $\\{\\alpha_{w}, \\alpha_{\\theta}\\}\\in\\left\\{\\mathbb{R}|0<\\alpha\\right\\}$}\n\\Init{weights $\\bm{w}\\in\\mathbb{R}^{\\zeta}$ and $\\bm{\\theta}\\in\\mathbb{R}^d$ arbitrarily, memory $\\bm{\\mathcal{D}}$}\\pause\n \\For{$j=1,2,\\ldots,$ (sub-)episodes}{\n\t\tinitialize $\\bm{x}_0$ (if new episode)\\; \n\t\tcollect a set of tuples $\\left\\langle \\bm{x}_k, \\bm{u}_k, r_{k+1}, \\bm{x}_{k+1}\\right\\rangle$ by running $\\pi(\\bm{u}|\\bm{x},\\bm{\\theta}_j)$\\;\\pause\n\t\tstore them in $\\bm{\\mathcal{D}}$\\;\\pause\n\t\testimate the advantage $\\hat{a}_{\\pi_j}(\\bm{x},\\bm{u})$ based on $\\hat{v}(\\bm{x},\\bm{w}_j)$ and $\\bm{\\mathcal{D}}$ (e.g., GAE)\\;\\pause\n\t\t$\\bm{\\theta}_{j+1}\\leftarrow$ policy gradient update on \\eqref{eq:PPO_CSO} or \\eqref{eq:PPO_AKP}\\;\\pause\n\t\t$\\bm{w}_{j+1}\\leftarrow$ minimizing the mean-squared TD errors using $\\bm{\\mathcal{D}}$\\;\\pause\n\t\tdelete entries in $\\bm{\\mathcal{D}}$\\;\n\t}\n\\caption{Proximal policy optimization (output: parameter vectors $\\bm{\\theta}^*$ for $\\pi^*(\\bm{u}|\\bm{x},\\bm{\\theta}^*)$) and $\\bm{w}^*$ for $\\hat{v}^*(\\bm{x}, \\bm{w}^*))$}\n\\label{algo:PPO}\n\\end{algorithm}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Some PPO Remarks %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Some PPO Remarks}\n\\setcounter{footnote}{0}\n\\begin{itemize}\n\t\\item Clipping the surrogate objective \\eqref{eq:PPO_CSO} was reported to achieve higher performances than the KL penalty \\eqref{eq:PPO_AKP}.\\footnote{cf. original PPO paper results by J. Schulman et al., \\textit{Proximal Policy Optimization Algorithms}, \\href{https://arxiv.org/abs/1707.06347}{https://arxiv.org/abs/1707.06347}, 2017}\\pause\n\t\\item Like TRPO, PPO is an on-policy algorithm. Hence, the memory $\\bm{\\mathcal{D}}$ is not a rolling replay buffer (cf. off-policy algorithms like DQN, DDPG or TD3) but a \\hl{rollout buffer} using one fixed policy.\\pause\n\t\\item These rollouts are likely to result in an increased sample demand either using a simulator or a real experiment.\\pause\n\\end{itemize}\n\\begin{block}{}\nAlthough PPO is derived from a TRPO background pursuing monotonically increasing policy performance, its realization is based on multiple heuristics and approximations. Hence, there is no guarantee on achieving this goal and the specific performance of the PPO algorithm must be evaluated empirically given a certain application.  \n\\end{block}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Exemplary Performance Comparison %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Exemplary Performance Comparison}\n\\begin{figure}\n\\includegraphics[height=5.25cm]{fig/lec13/Algo_Compare.pdf}\n\\caption{Learning curves for \\href{https://gym.openai.com/envs/\\#mujoco}{OpenAI Gym} continuous control tasks. The shaded region represents half a standard deviation of the average evaluation over ten trials (source: S. Fujimoto et al., \\textit{Addressing Function Approximation Error in Actor-Critic Methods}, 2018).}\n\\label{fig:Algo_Compare}\n\\end{figure}\n}\t\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Outlook: Other Contempororay Algorithms (1)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Outlook: Other Contemporary Algorithms (1)}\nThe selection of algorithms appears endless:\n\\begin{itemize}\n\t\\item DQN variants such as\n\t\\begin{itemize}\n\t\t\\item \\href{https://arxiv.org/abs/1511.06581}{(Prioritized) dueling DQN}\n\t\t\\item \\href{https://arxiv.org/abs/1706.10295}{Noisy DQN}\n\t\t\\item \\href{https://arxiv.org/abs/1707.06887}{Distributional DQN}\n\t\\end{itemize}\\pause\n\t\\item \\href{https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/viewFile/17204/16680}{Rainbow} (combining multiple DQN extensions)\\pause\n\t\\item \\href{https://arxiv.org/abs/1801.01290}{Soft actor-critic (SAC)}\\pause\n\t\\item \\href{https://proceedings.neurips.cc/paper/2017/file/361440528766bbaaaa1901845cf4152b-Paper.pdf}{Actor critic using Kronecker-factored trust region (ACKTR)}\\pause\n\t\\item \\href{http://proceedings.mlr.press/v48/mniha16.pdf}{Asynchronous advantage actor-critic (A3C)}\n\t\\item ....\n\\end{itemize}\n\\vspace{0.5cm}\\pause\nRemarks: \n\\begin{itemize}\n\t\\item \\hl{You have already learned the basic building blocks in order to make yourself familiar with any value-/policy-based or hybrid RL approach. \\pause\n\t\\item Use this knowledge! \\pause\n\t\\item Focus on primary scientific literature for self-studying and not on arbitrary blogs or other possible non-reliable sources!} \n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Outlook: Other Contempororay Algorithms (2)%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{Outlook: Other Contemporary Algorithms (2)}\nAlgorithm collections with tutorial-style documentation:\n\\begin{itemize}\n\t\\item \\href{https://nervanasystems.github.io/coach/}{Intel Reinforcement Learning Coach}\n\t\\item \\href{https://spinningup.openai.com/en/latest/index.html}{OpenAI Spinning Up}\n\\end{itemize}\\pause\n\\vspace{0.75cm}\nAlgorithm collections with decent application-oriented documentation:\n\\begin{itemize}\n\t\\item \\href{https://github.com/deepmind/acme}{Acme}\n\t\\item \\href{https://github.com/rlworkgroup/garage}{Garage}\n\t\\item \\href{https://github.com/google/dopamine}{Google Dopamine}\n\t\\item \\href{https://github.com/ray-project/ray}{RLlib (Ray)}\n\t\\item \\href{https://github.com/DLR-RM/stable-baselines3}{Stable Baselines3}\n\t\\item \\href{https://github.com/tensorforce/tensorforce}{Tensorforce}\n\t\\item \\href{https://github.com/tensorflow/agents}{TF-Agents}\n\t\\item ...\n\\end{itemize}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Summary %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{frame}\n\\frametitle{Summary: What You've Learned Today}\n\\begin{itemize}\n\t\\item The deep deterministic policy gradient (DDPG) approach 'transfers' many deep $Q$-network (DQN) ideas to continuous action spaces.\\pause\n\t\\item It mainly combines DQN + deterministic policy gradients + policy and value target networks (plus additional minor tweaks).\\pause\n\t\\item However, the DDPG actor-critic suffers from value overestimation and high variance during learning. Hence, sampled policy gradients might not be optimal (pointing towards overrated action values).\\pause\n\t\\item Twin delayed DDPG (TD3) adds clipped double $Q$-learning, delayed policy updates and target policy smoothing to counteract these issues.\\pause\n\t\\item Trust region policy optimization (TRPO) pursues monotonically increasing policy performance by limiting policy distribution changes.\\pause\n\t\\item This results in a nonlinear constrained optimization problem adding computational complexity (no simple policy gradients).\\pause\n\t\\item Proximal policy optimization (PPO) converts the TRPO idea into an unconstrained optimization problem by a modified objective. Likewise, the PPO's objective is to prevent erratic policy distribution changes. \n\\end{itemize}\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Final Slide %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\\frametitle{The End for Today}\n\\vspace{-0.25cm}\n\\begin{figure}\n\\hspace*{-0.5cm}\n\\includegraphics[width=11cm]{fig/lec13/dilbert.jpg}\n\\end{figure}\n\\vspace{1cm}\n\\centering\nThanks for your attention and have a nice week!\n}", "meta": {"hexsha": "fb090fd5498e20b2f24a28e8d84a96afd02759af", "size": 54187, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_slides/tex/Lecture13.tex", "max_stars_repo_name": "adilsheraz/reinforcement_learning_course_materials", "max_stars_repo_head_hexsha": "e086ae7dcee2a0c1dbb329c2b25cf583c339c75a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 557, "max_stars_repo_stars_event_min_datetime": "2020-07-20T08:38:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T19:30:35.000Z", "max_issues_repo_path": "lecture_slides/tex/Lecture13.tex", "max_issues_repo_name": "BochraCHEMAM/reinforcement_learning_course_materials", "max_issues_repo_head_hexsha": "09a211da5707ba61cd653ab9f2a899b08357d6a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-07-22T07:27:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-12T14:37:08.000Z", "max_forks_repo_path": "lecture_slides/tex/Lecture13.tex", "max_forks_repo_name": "BochraCHEMAM/reinforcement_learning_course_materials", "max_forks_repo_head_hexsha": "09a211da5707ba61cd653ab9f2a899b08357d6a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 115, "max_forks_repo_forks_event_min_datetime": "2020-09-08T17:12:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T18:13:08.000Z", "avg_line_length": 62.9349593496, "max_line_length": 497, "alphanum_fraction": 0.6303172348, "num_tokens": 16641, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4280755136733799}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% CS624: Analysis of Algorithms\n% Copyright 2015 Pejman Ghorbanzade <pejman@ghorbanzade.com>\n% Creative Commons Attribution-ShareAlike 4.0 International License\n% More info: https://github.com/ghorbanzade/beacon\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section*{Question 2}\n\nShow the $d$ and $\\pi$ values that result from running breadth-first search on the undirected graph depicted in Figure \\ref{fig21}, using vertex $u$ as the source.\n\n\\def\\dist{1cm}\n\\begin{figure}[H]\\centering\n\\tikzstyle{vertex}=[circle,draw,minimum size=0.7cm]\n  \\begin{tikzpicture}\n    \\node[vertex] (1) {r};\n    \\node[vertex] (2) [right = \\dist of 1] {s};\n    \\node[vertex] (3) [right = \\dist of 2] {t};\n    \\node[vertex] (4) [right = \\dist of 3] {u};\n    \\node[vertex] (5) [below = \\dist of 1] {v};\n    \\node[vertex] (6) [right = \\dist of 5] {w};\n    \\node[vertex] (7) [right = \\dist of 6] {x};\n    \\node[vertex] (8) [right = \\dist of 7] {y};\n    \\path[draw,thick]\n    (1) edge (2)\n    (1) edge (5)\n    (2) edge (6)\n    (6) edge (3)\n    (6) edge (7)\n    (3) edge (4)\n    (3) edge (7)\n    (7) edge (4)\n    (7) edge (8)\n    (4) edge (8);\n    \\path[draw,ultra thick]\n    ;\n  \\end{tikzpicture}\n\\caption{Connected Undirected Graph $G$}\\label{fig21}\n\\end{figure}\n\n\\subsection*{Solution}\n\nThe running procedure of breadth-first search algorithm on graph $G$ is shown in Figure \\ref{fig22}, where values given for each node describes its distance $d$.\nBased on Figure \\ref{fig22}, Table \\ref{tab21} is given that shows $d$ and $\\pi$ parameters for different nodes of $G$.\n\n\\begin{table}[H]\\centering\n\\begin{tabular}{c c c|c c c}\nnode & ($d$) & ($\\pi$) & node & ($d$) & ($\\pi$)\\\\\n\\hline\nr & 4 & s & v & 5 & r\\\\\ns & 3 & w & w & 2 & t\\\\\nt & 1 & u & x & 1 & u\\\\\nu & 0 & $\\emptyset$ & y & 1 & u\\\\\n\\hline\n\\end{tabular}\n\\caption{Obtained $d$ and $\\pi$ values when using BFS on $G$ starting from node $u$}\n\\end{table}\n\\newpage\n\\begin{figure}[H]\\centering\n\\tikzstyle{vertex}=[circle,draw,minimum size=0.7cm]\n\\tikzstyle{not visited}=[]\n\\tikzstyle{visited}=[fill=gray!50]\n\\tikzstyle{in queue}=[fill=gray!20]\n\\tikzstyle{label}=[]\n\\tikzstyle{ultra thick}=[line width=0.6mm]\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex] (2) [right = \\dist of 1] {$\\infty$};\n      \\node[vertex] (3) [right = \\dist of 2] {$\\infty$};\n      \\node[vertex,in queue] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex] (6) [right = \\dist of 5] {$\\infty$};\n      \\node[vertex] (7) [right = \\dist of 6] {$\\infty$};\n      \\node[vertex] (8) [right = \\dist of 7] {$\\infty$};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (2) edge (6)\n      (6) edge (3)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (4)\n      (7) edge (8)\n      (4) edge (8);\n      \\path[draw,ultra thick]\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig1}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex] (2) [right = \\dist of 1] {$\\infty$};\n      \\node[vertex,in queue] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex] (6) [right = \\dist of 5] {$\\infty$};\n      \\node[vertex,in queue] (7) [right = \\dist of 6] {1};\n      \\node[vertex,in queue] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (2) edge (6)\n      (6) edge (3)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig2}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex] (2) [right = \\dist of 1] {$\\infty$};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex,in queue] (6) [right = \\dist of 5] {2};\n      \\node[vertex,in queue] (7) [right = \\dist of 6] {1};\n      \\node[vertex,in queue] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (2) edge (6)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig3}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex] (2) [right = \\dist of 1] {$\\infty$};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex,in queue] (6) [right = \\dist of 5] {2};\n      \\node[vertex,visited] (7) [right = \\dist of 6] {1};\n      \\node[vertex,in queue] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (2) edge (6)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig4}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex] (2) [right = \\dist of 1] {$\\infty$};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex,in queue] (6) [right = \\dist of 5] {2};\n      \\node[vertex,visited] (7) [right = \\dist of 6] {1};\n      \\node[vertex,visited] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (2) edge (6)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig5}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex] (1) {$\\infty$};\n      \\node[vertex,in queue] (2) [right = \\dist of 1] {3};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex,visited] (6) [right = \\dist of 5] {2};\n      \\node[vertex,visited] (7) [right = \\dist of 6] {1};\n      \\node[vertex,visited] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (2)\n      (1) edge (5)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      (2) edge (6)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig6}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex,in queue] (1) {4};\n      \\node[vertex,visited] (2) [right = \\dist of 1] {3};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex] (5) [below = \\dist of 1] {$\\infty$};\n      \\node[vertex,visited] (6) [right = \\dist of 5] {2};\n      \\node[vertex,visited] (7) [right = \\dist of 6] {1};\n      \\node[vertex,visited] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (1) edge (5)\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      (2) edge (6)\n      (1) edge (2)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig7}\n  \\end{subfigure}\n  \\begin{subfigure}{0.49\\textwidth}\\centering\n    \\begin{tikzpicture}\n      \\node[vertex,visited] (1) {4};\n      \\node[vertex,visited] (2) [right = \\dist of 1] {3};\n      \\node[vertex,visited] (3) [right = \\dist of 2] {1};\n      \\node[vertex,visited] (4) [right = \\dist of 3] {0};\n      \\node[vertex,in queue] (5) [below = \\dist of 1] {5};\n      \\node[vertex,visited] (6) [right = \\dist of 5] {2};\n      \\node[vertex,visited] (7) [right = \\dist of 6] {1};\n      \\node[vertex,visited] (8) [right = \\dist of 7] {1};\n\n      \\node[label]  (9) [above = 0.1cm of 1] {r};\n      \\node[label]  (10) [above = 0.1cm of 2] {s};\n      \\node[label]  (11) [above = 0.1cm of 3] {t};\n      \\node[label]  (12) [above = 0.1cm of 4] {u};\n      \\node[label]  (13) [below = 0.1cm of 5] {v};\n      \\node[label]  (14) [below = 0.1cm of 6] {w};\n      \\node[label]  (15) [below = 0.1cm of 7] {x};\n      \\node[label]  (16) [below = 0.1cm of 8] {y};\n\n      \\path[draw,thick]\n      (6) edge (7)\n      (3) edge (4)\n      (3) edge (7)\n      (7) edge (8)\n      ;\n      \\path[draw,ultra thick]\n      (4) edge (8)\n      (3) edge (4)\n      (7) edge (4)\n      (6) edge (3)\n      (2) edge (6)\n      (1) edge (2)\n      (1) edge (5)\n      ;\n    \\end{tikzpicture}\n    \\caption{}\n    \\label{fig:sfig8}\n  \\end{subfigure}\n  \\caption{Breadth-First Search algorithm on graph $G$ of Figure \\ref{fig21} starting from node $u$}\\label{fig22}\n\\end{figure}\n", "meta": {"hexsha": "521c5bafb00f2aca376667d0cb8a272e510bb1f1", "size": 12548, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "umb-cs624-2015s/src/tex/hw05/hw05q02.tex", "max_stars_repo_name": "ghorbanzade/beacon", "max_stars_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-13T20:00:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-01T11:16:51.000Z", "max_issues_repo_path": "umb-cs624-2015s/src/tex/hw05/hw05q02.tex", "max_issues_repo_name": "ghorbanzade/beacon", "max_issues_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "umb-cs624-2015s/src/tex/hw05/hw05q02.tex", "max_forks_repo_name": "ghorbanzade/beacon", "max_forks_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-20T05:58:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-06T17:18:05.000Z", "avg_line_length": 33.1957671958, "max_line_length": 163, "alphanum_fraction": 0.5027892891, "num_tokens": 5040, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.42804383249852923}}
{"text": "\n\\section{Lake at rest with a steep island}\n\nThis is a test if the method is well-balanced. Furthermore, we test if the wet/dry interface has been correctly treated for a steep island. This test is taken from the work of Mungkasi and Roberts~\\cite{MR2010}.\n\nThe initial condition is a lake at rest with water depth $4.5$. The topography is\n\\begin{equation}\nz(x,y)= \\left\\{ \\begin{array}{ll}\n             -0.01(x-200) + 4& ~\\textrm{if}\\quad 0 \\leq x < 200\\\\\n             -0.02(x-200) + 4& ~\\textrm{if}\\quad 200 \\leq x < 300\\\\\n             -0.01(x-300) + 2& ~\\textrm{if}\\quad 300 \\leq x < 400\\\\\n             (-1/75)(x-400) + 2& ~\\textrm{if}\\quad 400 \\leq x < 550\\\\\n             (1/11250)(x-550)(x-550)& ~\\textrm{if}\\quad 550 \\leq x < 700\\\\\n             0.03(x-700)& ~\\textrm{if}\\quad 700 \\leq x < 800\\\\\n             -0.03(x-800) + 3& ~\\textrm{if}\\quad 800 \\leq x < 900\\\\\n             6& ~\\textrm{if}\\quad 900 \\leq x < 1000\\\\\n             (-1.0/20000)(x-1000)(x-1400)& ~\\textrm{if}\\quad 1000 \\leq x < 1400\\\\\n             0& ~\\textrm{if}\\quad 1400 \\leq x < 1500\\\\\n             3& ~\\textrm{if}\\quad 1500 \\leq x < 1700\\\\\n             -0.03(x-1700) + 3& ~\\textrm{if}\\quad 1700 \\leq x < 1800\\\\\n             (4.5/40000)(x-1800)(x-1800) + 2 & ~\\textrm{otherwise,}\\\\\n\\end{array} \\right.\n\\end{equation} \nThe analytical solution is the lake at rest, that is, $w=4.5$ and $u=v=0$.\n\n\\subsection{Results}\n\n\nOlder versions of \\anuga{} might not handle a discontinuous island well, but newer versions should be exact to numerical precision (including the discontinuous-elevation and tsunami algorithms). The following three figures show the stage, $x$-momentum, and $x$-velocity respectively, after we run the simulation for some time. We should see excellent agreement between the analytical and numerical solutions if the method is well-balanced and if the wet/dry interface has been correctly treated. Note the figure scales - momenta will probably be plotted on a scale varying only a tiny range, since the result is zero to numerical precision.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{stage_plot.png}\n\\end{center}\n\\caption{Stage results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xmom_plot.png}\n\\end{center}\n\\caption{Xmomentum results}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{xvel_plot.png}\n\\end{center}\n\\caption{Xvelocity results}\n\\end{figure}\n\n\n\\endinput\n", "meta": {"hexsha": "d27b9355579e971a27a9372ea953c80f9441bffd", "size": 2457, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "validation_tests/analytical_exact/lake_at_rest_steep_island/results.tex", "max_stars_repo_name": "samcom12/anuga_core", "max_stars_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_stars_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_stars_count": 136, "max_stars_repo_stars_event_min_datetime": "2015-05-07T05:47:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T03:07:40.000Z", "max_issues_repo_path": "validation_tests/analytical_exact/lake_at_rest_steep_island/results.tex", "max_issues_repo_name": "samcom12/anuga_core", "max_issues_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_issues_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_issues_count": 184, "max_issues_repo_issues_event_min_datetime": "2015-05-03T09:27:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T04:22:48.000Z", "max_forks_repo_path": "validation_tests/analytical_exact/lake_at_rest_steep_island/results.tex", "max_forks_repo_name": "samcom12/anuga_core", "max_forks_repo_head_hexsha": "f4378114dbf02d666fe6423de45798add5c42806", "max_forks_repo_licenses": ["Python-2.0", "OLDAP-2.7"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-03-18T07:35:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-01T07:07:29.000Z", "avg_line_length": 43.875, "max_line_length": 640, "alphanum_fraction": 0.6613756614, "num_tokens": 838, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6334102636778403, "lm_q1q2_score": 0.4280362341156254}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Chapter 3: c-proj *********************************\n%*******************************************************************************\n\n\n\n\n\\chapter{Para--$c$--projective compactification of $M$} \\label{chap:c-proj}\nIn \\cite{CG} the concept of $c$--projective compactification was\ndefined. It is based on almost $c$--projective geometry \\cite{c_proj},\nan analogue of projective geometry defined for almost complex\nmanifolds, i.e., even--dimensional manifolds $M$ carrying a smooth endomorphism $J$ of $TM$ which satisfies $J^2=-Id$. In $c$--projective geometry, the equivalence class of torsion--free connections is replaced by an equivalence class of connections which are adapted to the almost complex structure $J$ in a natural way. In this chapter we discuss a notion of compactification which is modified to the {\\it{``para''}} case, i.e. where the endomorphism $J$ squares to $Id$ rather than $-Id$. We show that the natural almost para--complex structure $J$ on any manifold $M$ arising in the projective to Einstein correspondence admits a type of compactification which we call \\textit{para}--$c$--projective. The content of this chapter is based on material appearing in \\cite{DGW}. It was undertaken in collaboration with Maciej Dunajski and Rod Gover.\n\n\\section{Background and definitions}\nThe purpose of this section is to introduce the definitions which are required to state the main results of \\cite{CG}.\n\n\\subsection{Almost (para--)complex geometry}\n\n\\begin{defi}\nThe Nijenhuis tensor of an endomorphism $J$ of $TM$ is defined by\n\\be \\label{eq:Nijenhuis_def}\n\\mathcal{N}(\\xi_1,\\xi_2):=[\\xi_1,\\xi_2] - [J\\xi_1,J\\xi_2] + J([J\\xi_1,\\xi_2] + [\\xi_1,J\\xi_2]),\n\\ee\nwhere $\\xi_1,\\xi_2$ are vector fields on $M$ and $[\\cdot\\,,\\cdot]$ denotes the Lie bracket of vector fields. This is equivalent to\n\\be \\label{eq:Nijenhuis_index_def}\n\\mathcal{N}^a_{bc}=J^d_{\\ [b}\\p_{|d|}J^a_{\\ c]}-J^d_{\\ [b}\\p_{c]}J^a_{\\ d}.\n\\ee\n\\end{defi}\n\nLet $M$ be a complex manifold of (complex) dimension $n$, in the sense of having complex coordinates and complex transition functions. Then multiplication of the coordinates by $i$ defines an endomorphism $J$ of $TM$ which squares to $-Id$, so complex manifolds are a subset of almost complex manifolds. In this case, $J$ has eigenvalues $\\pm i$, and the corresponding splitting of $TM$ into eigen--bundles is Frobenius integrable. The Newlander--Nirenberg theorem describes complex manifolds in terms of the Nijenhuis tensor (\\ref{eq:Nijenhuis_def}) of $J$.\n\n\\begin{theo}[\\cite{NewNir}]\nAn almost complex manifold $(M,J)$ is a complex manifold if and only if the Nijenhuis tensor of $J$ vanishes. In this case, we call the almost complex structure $J$ integrable.\n\\end{theo}\n\n\nAs discussed in Chapter \\ref{chap:intro2}, an endomorphism $J$ which squares to $Id$ defines an analogous splitting of the tangent bundle into sub--bundles with eigenvalues $\\pm 1$, and this splitting is also Frobenius integrable if and only if the Nijenhuis tensor of $J$ vanishes. We thus call an almost para--complex structure $J$ with vanishing Nijenhuis tensor a para--complex structure, and say that in this case $J$ is integrable. In all the definitions below, the word \\textit{almost} can be removed if the (para--)complex structure $J$ is integrable.\n\n\\begin{defi}\nA (para--)Hermitian metric on an almost (para--)complex manifold $(M,J)$ is a metric $g$ satisfying\n\\[\ng(J\\cdot\\,,J\\cdot) = \\pm g(\\cdot\\,,\\cdot),\n\\]\nwhere the minus sign corresponds to the ``para'' case. The triple $(M,J,g)$ then defines an almost (para--)Hermitian manifold.\n\\end{defi}\n\nNote that every (para--)Hermitian manifold has a naturally defined two--form $\\Omega(\\cdot\\,,\\cdot)=g(\\cdot\\,,J\\cdot)$ which is (para--)Hermitian in the sense that\n\\[\n\\Omega(J\\cdot\\,,J\\cdot) = \\pm \\Omega(\\cdot\\,,\\cdot),\n\\]\nand can alternatively be specified as $(M,J,\\Omega)$ or $(M,g,\\Omega)$. An almost (para--)K\\\"ahler manifold $(M,J,g)$ is a (para--)Hermitian manifold whose associated two--form is closed, meaning $M$ carries compatible complex, pseudo--Riemannian and symplectic structures. The manifolds $M$ arising in the projective to Einstein correspondence are almost para--K\\\"ahler, and para--K\\\"ahler when the underlying projective structure is flat \\cite{DM}.\n\n\\subsection{Almost (para--)CR structures and contact distributions}\n\n\\begin{defi}\nAn almost (para--)CR structure $(\\mathcal{Z},\\mathbb{H} ,J)$ on a manifold $\\mathcal{Z}$ is a sub--bundle $\\mathbb{H} \\subset T\\mathcal{Z}$ of the tangent bundle together with a fibre--preserving endomorphism $J:\\mathbb{H} \\rightarrow \\mathbb{H} $ which satisfies $J^2=Id$ or $J^2=-Id$ depending on whether or not we are talking about the ``para'' case.\n\\end{defi}\n\nWe will be interested in the case where $ \\mathbb{H} $ is a hyperplane distribution on $\\mathcal{Z}$; then $(\\mathcal{Z}, \\mathbb{H} ,J)$ is called an almost (para--)CR structure of \\textit{hypersurface type}. An almost (para--)complex structure $(M,J)$ of dimension $2n$ defines an almost (para--)CR structure of hypersurface type on any hypersurface $\\mathcal{Z}\\subset M$ given by the restriction of $J$ to the hyperplane distribution $ \\mathbb{H} :=T\\mathcal{Z}\\cap J(T\\mathcal{Z})$ on $\\mathcal{Z}$. Note that this distribution must have dimension $2n-2$. An almost (para--)CR structure is a (para--)CR structure if and only if the splitting of $ \\mathbb{H} $ into eigen--bundles induced by $J$ is Frobenius integrable.\n\nWe can define the notion of non--degeneracy for an almost (para--)CR structure as follows. The Lie bracket of vector fields induces an antisymmetric $\\R$--bilinear operator $\\Gamma( \\mathbb{H} )\\times\\Gamma( \\mathbb{H} )\\rightarrow\\Gamma(T\\mathcal{Z}/ \\mathbb{H} )$ which in fact is also bilinear over smooth functions on $\\mathcal{Z}$. This means it is induced by a bundle map $\\mathcal{L}: \\mathbb{H} \\times \\mathbb{H} \\rightarrow T\\mathcal{Z}/ \\mathbb{H} $ which is called the \\textit{Levi bracket}. Since it takes values in a line bundle it can be thought of as an antisymmetric bilinear form called the \\textit{Levi form}. Degeneracy (or not) of the almost (para--)CR structure is defined as degeneracy (or not) of the Levi form. Note that the Levi form also defines a \\textit{symmetric} bilinear form $h_\\mathbb{H}(\\cdot\\,,\\cdot)=\\mathcal{L}(\\cdot\\,,J\\cdot)$ as long as $\\mathcal{L}$ is (para--)Hermitian with respect to $J$, and that this symmetric bilinear form is non--degenerate if and only if $\\mathcal{L}$ is.\n\n\\begin{defi}\nA contact structure on a manifold $\\mathcal{Z}$ of dimension $2n-1$ is a hyperplane distribution $ \\mathbb{H} \\subset T\\mathcal{Z}$ specified as the kernel of a one--form $\\beta$ on $\\mathcal{Z}$ which satisfies the complete non--integrability condition\n\\be \\label{eq:non_integrability}\n\\beta\\wedge \\underbrace{(d\\beta \\wedge \\dots\\wedge d\\beta)}_{n-1\\ \\mathrm{times}} \\neq 0.\n\\ee\n\\end{defi}\n\nThe complete non--integrability condition can be thought of as the opposite of Frobenius integrability of the hyperplane distribution, see for example \\cite{arnold}.\n\n\n\\subsection{Connections and (para--)$c$--projective equivalence} \\label{sec:c-proj_geom}\n\n\\begin{defi}\nA connection on an almost (para--)complex manifold $(M,J)$ is called complex if it preserves $J$.\n\\end{defi}\n\nNote that, in contrast to a metric connection, it is not always possible to define a complex connection which is torsion--free. In fact, this is possible if and only if the Nijenhuis tensor (\\ref{eq:Nijenhuis_def}) of $J$ vanishes. However, one can always define a complex connection whose torsion is equal to the Nijenhuis tensor of $J$ up to a constant multiplicative factor \\cite{c_proj}. Such connections are called \\textit{minimal}.\n\n\\begin{defi}\nTwo affine connections $\\nabla$ and $\\ol{\\nabla}$ on an almost (para--)complex manifold $(M,J)$ are called (para--)$c$--projectively equivalent if there is a one--form $\\Upsilon_a$ on $M$ such that their components $\\Gamma^a_{bc}$ and $\\ol{\\Gamma}^a_{bc}$ are related by\n\\be \\label{eq:c-proj_change}\n\\ol{\\Gamma}^a_{bc} - \\Gamma^a_{bc} = \\delta_{b}^{a}\\Upsilon_{c}+\\delta_{c}^{a}\\Upsilon_{b} \\pm (\\Upsilon_d J^d_{\\ b} J^a_{\\ c} + \\Upsilon_d J^d_{\\ c} J^a_{\\ b}),\n\\ee\nwhere the plus corresponds to the case $J^2=Id$ and the minus corresponds to the case $J^2=-Id$.\n\\end{defi}\n\nNote that the para--$c$--projective change of connection differs from the $c$--projective case in the signs of some of the terms, to account for the fact that $J$ squares to the $Id$ rather than $-Id$. It is easy to show that if $\\nabla$ is complex then so is $\\ol{\\nabla}$, and the index symmetry of the right hand side of (\\ref{eq:c-proj_change}) means that if $\\nabla$ is minimal then so is $\\ol{\\nabla}$. An almost (para--)$c$--projective structure on a manifold $M$ comprises an almost (para--)complex structure $J$ and a (para--)$c$--projective equivalence class $[\\nabla]$ of complex minimal connections.\n\nWe note here for later use that $c$--projective geometry in $2n$ dimensions can be expressed as a Cartan geometry. The model Lie group quotient is $G/S$, where\n\\[\nG=\\{g\\in SL(2n+2,\\R)\\,:\\,g\\mathbb{J}=\\mathbb{J}g\\},\n\\]\nand $\\mathbb{J}$ is an endomorphism of $\\R^{2n+2}$ which squares to $-Id$. This can be identified with $SL(n+1,\\mathbb{C})$. The subgroup $S$ is the stabiliser subgroup of a complex line in $\\mathbb{C}^{n+1}$, or equivalently a real plane in $\\R^{2n+2}$. Since a complex line in $\\mathbb{C}^{n+1}$ projects to a point in $\\CP^n$, $\\CP^n$ can be realised as $G/S$. More details can be found in \\cite{c_proj}. Although the para--$c$--projective case has non been studied in detail, we expect the construction to be analogous, with $\\mathbb{J}$ instead squaring to the identity on $\\R^{2n+2}$.\n\n\\subsection{Para--$c$--projective compactification}\n\nWe now specialise to the ``para'' case, where $J^2=Id$. Note that all the corresponding results for $J^2=-Id$ can be found in \\cite{CG}.\n\n\\begin{defi}\n\\label{defi_1}  Let $(M,J)$ be an almost para--complex manifold, and let $\\nabla$ be a complex minimal connection. The structure $(M,J)$ admits a para--$c$--projective compactification to a manifold with boundary $\\ol{M}=M\\cup\\p M$\nif there exists a function $T:\\ol{M}\\rightarrow \\R$ such that the zero locus $\\mathcal{Z}(T)$ is the boundary\n$\\p M\\subset \\ol{M}$, the differential $dT$ does not vanish on $\\p M$, and the connection $\\ol{\\nabla}$, related to $\\nabla$ by (\\ref{eq:c-proj_change}) with $\\Upsilon = dT/(2T)$, extends to $\\ol{M}$.\n\\end{defi}\n\n\n\nIt follows easily from this definition that the endomorphism $J$ on $M$ naturally extends to all of $\\ol{M}$ by parallel transport with respect to $\\ol{\\nabla}$. It thus defines an almost para--CR structure on the hyperplane distribution $ \\mathbb{H} $ defined by $ \\mathbb{H} _m:=T_m\\p M \\cap J(T_m \\p M)$ for all $m\\in\\p M$. It can be shown that this almost para--CR structure is non--degenerate if and only if for any local defining function $T$ the one--form $\\beta=dT\\circ J$, whose restriction to $\\p M$ has kernel $ \\mathbb{H} $, satisfies the complete non--integrability condition (\\ref{eq:non_integrability}) making $ \\mathbb{H} $ a contact distribution on $\\p M$.\n\nTo see this, first note that $\\beta(\\xi)=0\\ \\forall\\ \\xi\\in\\Gamma( \\mathbb{H} )$ implies $d\\beta(\\cdot\\,,\\cdot)=-\\beta([\\cdot\\,,\\cdot])$, so the restriction of $d\\beta$ to $ \\mathbb{H} \\times \\mathbb{H} $ represents the Levi form $\\mathcal{L}$. This means that the almost para--CR structure on $\\p M$ is non--degenerate if and only if the restriction of $d\\beta(\\xi,\\cdot)$ to $ \\mathbb{H} $ is non--zero for all non--zero $\\xi\\in\\Gamma( \\mathbb{H} )$. But this is equivalent to the non--integrability condition (\\ref{eq:non_integrability}).\n\n%Note also the distinction between the integrability (or not) of the ($2n-2$)--dimensional distribution $ H $ and the integrability (or not) of the two ($n-1$)--dimensional distributions given by the eigenvalue decomposition of $ H $ under the action of $J$.\n\nAnother result of lemma 5 of \\cite{CG} is that $d\\beta$ is Hermitian on $\\p M$ if and only if the Nijenhuis tensor (\\ref{eq:Nijenhuis_def}) of $J$ takes so--called \\textit{asymptotically tangential values}. This is equivalent to the following statement in index notation:\n\\be\n\\label{Nijenhuis_condition}\n\\Big({\\mathcal{N}^{a}}_{bc}\\nabla_a T\\Big)\\Big|_{T=0}=0.  \\ee\nNote in particular that Hermiticity of $d\\beta$ on $\\p M$ implies Hermiticity of $d\\beta$ on $ \\mathbb{H} $, and hence the existence of a non--degenerate metric $h_\\mathbb{H}(\\cdot\\,,\\cdot)=d\\beta(\\cdot\\,,J\\cdot)|_ \\mathbb{H} $ on $ \\mathbb{H} $. Both of these facts also apply in the ``para'' case.\n\nAlthough $c$--projective compactification is defined for any almost complex manifold, the definition can be applied to pseudo--Riemannian metrics $g$ which are Hermitian with respect to the almost complex structure so long as there exists a connection which preserves both $g$ and $J$ and has minimal torsion. Such Hermitian metrics are said to be \\textit{admissible}.  Note that such a connection, if it exists, is uniquely defined, since the conditions that it be complex and minimal determine its torsion. It is thus given by the Levi--Civita connection of $g$ plus a constant multiple of the Nijenhuis tensor (\\ref{eq:Nijenhuis_def}) of $J$.\n\nThe first main result of \\cite{CG} is  Theorem 8 in this reference, which gives a local form for an admissible Hermitian metric which is sufficient for the corresponding $c$--projective structure to be $c$--projectively compact. The theorem is stated below, adapted to the para--$c$--projective case. The proof can be obtained by a trivial adaptation of the arguments in\n\\cite{CG}, and so further details may be obtained from that source.\n\\begin{theo}[\\cite{CG}] \\label{CGthm}\nLet $\\ol{M}$ be a smooth manifold with boundary $\\p M$ and interior $M$. Let $J$ be an almost para--complex structure on $\\ol{M}$, such that $\\p M$ is non--degenerate and the Nijenhuis tensor $\\mathcal{N}$ of $J$ has asymptotically tangential values. Let $g$ be an admissible pseudo--Riemannian Hermitian metric on $M$. For a local defining function $T$ for the boundary defined on an open \nsubset ${\\mathcal U}\\subset \\ol{M}$, put $\\beta=dT\\circ J$ and, given a non--zero real \nconstant $C$, define a Hermitian tensor field $h_{T,C}$ on \n${\\mathcal U}\\cap M$ by\n\\[\nh_{T,C}:=Tg+\\frac{C}{T}(dT^2-\\beta^2).\n\\]\nSuppose that for each $x\\in\\p M$ there is an open neighbourhood \n${\\mathcal{U}}$ of $x$ in $\\ol{M}$, a local defining function $T$ defined on \n${\\mathcal{U}}$, and a non--zero constant $C$ such that\n\\begin{itemize}\n\\item $h_{T,C}$ admits a smooth extension to all of $\\mathcal{U}$\n\\item for all vector fields $\\xi_1,\\xi_2$ on $\\mathcal{U}$ with $dT(\\xi_2)=\\beta(\\xi_2)=0$, the function $h_{T,C}(\\xi_1,J\\xi_2)$ approaches $Cd\\beta(\\xi_1,\\xi_2)$ at the boundary.\n\\end{itemize}\nThen $g$ is $c$--projectively compact.\n\\end{theo}\nNote that the statement in  Theorem \\ref{CGthm} does not depend on the choice of $T$. Different choices of $T$ result in rescalings of the one--form $\\beta$ on the boundary by a nowhere vanishing function.\n\n\n\\section{Compactifying the Dunajski--Mettler Class} \n\nIn order to construct the para--$c$--projective compactification of the manifolds $M$ arising in the projective to Einstein correspondence, we will need to understand them from a tractor perspective. This is the goal of the following subsection.\n\n\\subsection{Tractor construction of $M$}\\label{sec:trac_construction_g}\n\nIn Section \\ref{sec:trac_construction} it was shown that the projectivised cotractor bundle of $N$ is stratified by the canonical density $\\tau=V\\hook W$, where $V$ is the pull back of the canonical tractor along $\\pi_\\cT:\\cT^*\\rightarrow N$ and $W$ is the tautological section of $\\pi_\\cT^*(\\cT^*)$. It is easily verified that the zero locus $\\mathcal{Z}(\\tau)$ of $\\tau$ is a smoothly embedded hypersurface in $\\mathcal{M}:=\\PP(\\cT^*)$. %  and from (\\ref{eq:T*N_is_M}) it follows at once that this may be identified with the total space of the fibrewise projectivisation $\\mathbb{P}(T^*N)$ (which is well known to have an almost para--CR structure). \\mynote{Is there a way to justify this \"well known\" fact?}\nIn the following theorem, we show that $\\mathcal{M}\\backslash\\mathcal{Z}(\\tau)$ can be identified with $M$.\n\n\\begin{theo}\\cite{DGW}\\label{metric} \nThere is a metric $g$ and two--form $\\Omega$ on $\\mathcal{M}\\setminus \\mathcal{Z}(\\tau)$ determined by the canonical pairing of the horizontal and vertical subspaces of $T(\\cT^*)$. The pair $(g,\\Omega)$ agrees with (\\ref{eq:coord_form}).\n\\end{theo}\n\\noindent {\\bf Proof.}\n Considering first the total space $\\cT^*$ and then its tangent\n bundle, note that there is an exact sequence\n  \\begin{equation}\\label{TM}\n0\\to \\pi_\\cT^* \\cT^*\\to T(\\cT^*)\\to \\pi_\\cT^*TN\\to 0,\n  \\end{equation}\n  where we have identified $\\pi_\\cT^* \\cT^*$ as the vertical sub-bundle of $T(\\cT^*)$.\nThe tractor connection on the vector bundle $\\cT^*\\to N$ is equivalent to a splitting of this sequence, identifying $\\pi_\\cT^*TN$ with a distinguished  sub--bundle of horizontal subspaces in \n$ T(\\cT^*)$ so that we have \n\\begin{equation}\\label{HV}\nT(\\cT^*)=  \\pi_\\cT^*TN\\oplus \\pi_\\cT^* \\cT^* .\n\\end{equation}\n\n%From the usual Euler sequence of projective space (or see (\\ref{useful}) in the last Section) it follows that\nWe move now to the total space of $\\cM:=\\mathbb{P}( {\\cT^*})$, and we note that again the tractor (equivalently, Cartan) connection determines a splitting of the tangent bundle $T(\\mathbb{P} {\\cT^*})$ in which the second term of the display (\\ref{HV}) is replaced by a quotient of $\\pi_\\cT^* \\cT^*(0,1)$ \\cite{CGH-duke}. Indeed, if we work at a point $m\\in \\mathbb{P}(\\cT^*)$, observe that $\\pi_\\cT^*\\cT^*(0,1)$ has a filtration\n\\begin{equation}\\label{quotient}\n0\\longrightarrow \\cE (0,0)_m\\xrightarrow{W_m}  \\pi_\\cM^* \\cT^*(0,1)|_m \\longrightarrow  \\pi_\\cM^* \\cT^*(0,1)|_m/\\langle W_m \\rangle \\longrightarrow 0\n\\end{equation}\nwhere, as usual, $W$ is the canonical section. \nBut away from $\\mathcal{Z}(\\tau )$, we have that  $W$ canonically splits \nthe appropriately re-weighted pull back of  the sequence (\\ref{eq:T*sequence})\n$$\n0\\longrightarrow \\pi_\\cM^* T^*N(1,1)   \\longrightarrow \\pi_\\cM^* \\cT^*(0,1) \\xrightarrow{V/\\tau} \\cE(0,0) \\longrightarrow 0 .\n$$\nThis identifies the quotient in (\\ref{quotient}), and thus we have canonically\n$$\nT(\\mathbb{P}(\\cT^*)\\setminus \\mathcal{Z}(\\tau))=  \\pi_\\cM^*TN\\oplus \\pi_\\cM^*T^*N(1,1).\n$$\nIt follows that on  $M:=\\mathcal{M}\\backslash\\mathcal{Z}(\\tau)$\nthere is canonically a metric $\\boldsymbol{g}$ and symplectic form $\\boldsymbol{\\Omega}$ taking values in $\\cE(1,1)$, given by\n\\begin{eqnarray*}\n\\boldsymbol{g}(w_1,w_2)&=& \\frac{1}{2}\\Bigl(\n\\Pi_H(w_1)\\hook \\Pi_V(w_2)+\\Pi_H(w_2)\\hook\\Pi_V(w_1)\\Bigl) \\quad \\mbox{and} \\\\\n\\boldsymbol{\\Omega}(w_1,w_2)&=& \\frac{1}{2}\\Bigl(\\Pi_H(w_1)\\hook \\Pi_V(w_2)-\\Pi_H(w_2)\\hook\\Pi_V(w_1)\\Bigl)\n\\end{eqnarray*}\nwhere\n\\[\n\\Pi_H: TM\\rightarrow \\pi_\\cM^*TN \\quad \\mbox{and} \\quad \\Pi_V: TM\\rightarrow \\pi_\\cM^* T^*N(1,1)\n\\]\nare the projections.\nThen we obtain the metric and symplectic form by\n\\be\n\\label{almost_there}\ng:=\\frac{1}{\\tau}\\boldsymbol{g} \\qquad \\mbox{and} \\qquad \\Omega:=\\frac{1}{\\tau}\\boldsymbol{\\Omega} .\n\\ee\nWhat remains to be done, is to show that (\\ref{almost_there}) agrees\nwith the form obtained in \\cite{DM} once a trivialisation of\n$\\cT^*\\rightarrow N$ has been chosen.\n\nLet $x\\in N$ and let ${\\mathcal U}\\subset N$ be an open \nneighbourhood of $x$ with \nlocal coordinates $(x^1, \\dots, x^n)$ such that\n$T_xN=\\mbox{span}(\\p/\\p x^1, \\dots, \\p/\\p x^n)$. The connection \n(\\ref{eq:tractor_connection}) gives a splitting of $T(\\cT^*)$ into the horizontal and\nvertical sub-bundles\n\\[\nT(\\cT^*)=\\mathcal{H}(\\cT^*)\\oplus \\mathcal{V}(\\cT^*),\n\\]\nas in (\\ref{HV}).\nTo obtain the explicit form of this splitting, let $\\sigma_\\alpha,\\ \\alpha=0, 1, \\dots, n$ be components of a local section of $\\cT^*$ in the trivialisation over ${\\mathcal{U}}$.\nThen\n\\[\n\\nabla^{\\cT} \\sigma_\\beta=d \\sigma_\\beta-\\gamma_{\\beta}^{\\alpha} \\sigma_\\alpha,\n\\]\nwhere $\\gamma_{\\alpha}^\\beta= \\gamma_{i\\alpha}^\\beta dx^i$, and the components\nof the co-tractor connection \n$\\gamma_{i\\alpha}^\\beta$  are given in terms of the connection\n$\\nabla$ on $N$, and its Schouten tensor, and \ncan be read--off from (\\ref{eq:tractor_connection}):\n\\[\n\\gamma_{i0}^0=0, \\quad \\gamma_{i0}^j=\\delta_i^j,\\quad\n\\gamma_{ij}^k=\\Gamma_{ij}^k, \\quad \\gamma_{ij}^0=-\\Rho_{ij}.\n\\]\nIn terms of these components we can write\n\\begin{align*}\n\\mathcal{H}(\\cT^*)&=\\mbox{span}\n\\Big( \\frac{\\p}{\\p x^i}+ {\\gamma_{i\\alpha}^\\beta} \\sigma_\\beta\n\\frac{\\p}{\\p \\sigma_{\\alpha}}, i=1, \\dots, n \\Big), \\\\\n \\mathcal{V}(\\cT^*)&=\\mbox{span}\\Big(\\frac{\\p}{\\p \\sigma_{\\alpha}}, \\alpha=0, 1, \n\\dots, n\\Big).\n\\end{align*}\nSetting $\\zeta_i=\\sigma_i/\\sigma_0$, where $\\tau=\\sigma_0\\neq 0$ %\\footnote{Rod @ Maciej: I have added $\\sigma_0=\\tau$. You agree, right!?}\non the complement of \n$\\mathcal{Z}(\\tau)$, \n  we can compute the push forwards\nof these subspaces to $\\mathbb{P}(\\cT^*)\\setminus {\\mathcal{Z}(\\tau)}$:\n\\[\n\\kappa_* \\mathcal{H}(\\cT^*)=\\mbox{span}\\Big(h_i\\equiv\n\\frac{\\p}{\\p x^i}-\n(\\Rho_{ij}+\\zeta_i\\zeta_j  -\\Gamma_{ij}^k\\zeta_k)\\frac{\\p}{\\partial \\zeta_j}\n\\Big), \\quad \\kappa_* \\mathcal{V}(\\cT^*)=\\mbox{span}\\Big(v^i\\equiv\\frac{\\p}{\\p \\zeta_i}\n\\Big).\n\\]\nThe non--zero components of the  metric (\\ref{almost_there}) are given by\n\\[\ng(v^i, h_j)={\\delta^i}_j.\n\\]\nThis is identical to the form appearing in \\cite{DM}.\n\\koniec\n\n\\begin{rmk}\nNote that the shift (\\ref{eq:zeta_change}) in the fibre coordinates $\\zeta_{i}$ corresponding to a change of projective connection can be motivated from the change (\\ref{eq:chi_mu_change}) in the splitting of $\\cT^*$ and the definitions of $\\sigma_i$ and $\\zeta_i$.\n\\end{rmk}\n\n\\begin{rmk} We can also understand $\\mathbb{P}(\\cT^*)\\setminus \\mathcal{Z}(\\tau)$ as an affine bundle modelled on $T^* N$. Given a connection in the projective class and hence a decomposition (\\ref{eq:T*splitting}), there is a smooth fibre bundle isomorphism\n  \\begin{equation}\\label{key-id}\n\\kappa_A : T^* N\\to \\mathbb{P}(\\cT^*)\\setminus \\mathcal{Z}(\\tau).\n    \\end{equation}\n%First, given  $\\nabla$, we can represent an element $U\\in\n%  \\cT^*_p$ ($x\\in N$) by the pair $(\\tau , \\mu) \\in \\cE (1)_p\\oplus\n%  T_p^*N(1)$,  or, if we choose coordinates on $N$, by collection\n%\\be\n%\\label{tractor_U}\n%U=(\\tau, \\mu_i), \\quad i=1, \\dots, n .\n%\\ee\n%  Then, dropping the choice $\\nabla \\in [\\nabla]$, $U\\in\n%  \\cT^*_p$ is an equivalence class of such pairs by the equivalence\n%  relation (\\ref{ttrans}) that covers the\n%  equivalence relation between elements of $[\\nabla]$. \n%\n % Thus, given $\\nabla$, and  from the naturality of all maps, it\n % follows that the total space of $T^*N$ can be identified with $\\mathbb{P}(\\cT^*)\\setminus \\mathcal{Z}(\\tau)$\n % by (for each $x\\in N$)\ngiven by\n\\begin{equation} \\label{eq:T*N_is_M}\nT_x^*N\\ni \\zeta_i  \\mapsto [(1,\\zeta_i)]=[(\\tau,\\tau \\zeta_i)]\\in\n\\mathbb{P}(\\cT_x^*)\\setminus \\mathcal{Z}(\\tau) .\n\\end{equation}\n\\end{rmk}\n\n%\\begin{rmk}\n%A feature of this construction is that in each dimension $n$ (of $N$) either the hypersurface $\\mathcal{Z}(\\tau)$ (if $n$ odd) is not orientable, or $\\mathcal{M}$ (if $n$ even) is not orientable.\n%\\end{rmk} \n\n\\subsection{The compactification theorem}\n\nAs noted in Chapter \\ref{chap:intro2}, in the model case where $N=\\RP^n$ and $[\\nabla]$ is projectively flat, the manifold $M=SL(n+1, \\R)/GL(n, \\R)$ can be identified with the projectivisation of $\\R^{n+1}\\times \\R_{n+1}\\setminus {\\mathcal Z}$, where ${\\mathcal Z}$ denotes the set of incident pairs (point, hyperplane). The compactification procedure described in the Theorem \\ref{our_thm} below will, for the model, attach these incident pairs back to $M$, and more generally (in case of a curved projective structure $(N,[\\nabla])$) will attach the zero locus of $\\tau$ back into $\\mathbb{P}(\\cT^*)$. The boundary $\\p M \\cong \\mathcal{Z}(\\tau)$ from definition \\ref{defi_1} will play the role of a submanifold\nseparating two open sets in $\\mathbb{P}(\\cT^*)$ which have $\\tau>0$ and $\\tau<0$ respectively. The method of the proof will be to show that near\nthe boundary ${\\mathcal{Z}}(\\tau)=0$ of $\\ol{M}$ the metric \n(\\ref{eq:coord_form}) can be put in the local normal form of Theorem \n\\ref{CGthm}.\n\n%Before we state the theorem, we note that the Libermann connection $\\nabla^{L}$ \\cite{Lieb} associated to $(M,g,\\Omega)$ is given by\n%\\be\n%\\label{lib}\n%{\\nabla^L}_a X_b={\\nabla^{\\bf g}}_a X_b-{G^c}_{ab} X_c,\\quad \\mbox{where}\\quad\n%{{G^c}_{ab}}=-{{\\Omega}^{cd}}{\\nabla^{\\bf g}}_d {\\Omega_{ab}}\n%\\ee\n%and $\\nabla^{\\bf g}$ is the Levi--Civita connection of $g$.\n\n%\\mynote{Where do we use this? And is $G^c_{ab}$ Nijenhuis?}\n\n%This connection is metric, has minimal torsion, and preserves the almost para--complex structure $J$. It thus belongs to a para--$c$--projective equivalence class which we will show to be compactifiable in the sense of definition \\ref{defi_1}.\n\n\\begin{theo}\n\\label{our_thm}\nThe Einstein almost para--K\\\"ahler structure $(M, g, \\Omega)$ given by \n(\\ref{eq:coord_form}) admits a para--$c$--projective compactification\n$\\ol{M}$. The\n$(2n-1)$--dimensional boundary $\\p M\\cong \\mathcal{Z}(\\tau)$ of $\\ol{M}$ carries a contact structure together with a conformal structure \nand an almost para--CR structure\ndefined on the contact distribution.\n\\end{theo}\n%\\mynote{Here we stated that $\\p M\\cong \\mathbb{P}(T^* N)$ but unless I can justify why this carries a para--CR structure it might be better to leave this out or put $\\p M\\cong \\mathcal{Z}(\\tau)$.}\n\\noindent\n{\\bf Proof.}\nIn the proof below we shall explicitly construct the boundary $\\p M$ together with the contact structure and the associated conformal structure on the contact distribution. We shall\nfirst deal with the model case (\\ref{eq:intro_model_g}), and then explain how the addition of non--vanishing projective curvature modifies the compactification.\n\nNow consider an open set  ${\\mathcal U}\\subset M$ given\nby  $\\zeta_ix^i>0$, and define the function $T$ on ${\\mathcal U}$ by\n\\be\n\\label{formula_for_T}\nT=\\frac{1}{\\zeta_i x^i}.\n\\ee\nWe shall attach a boundary  $\\p \\mathcal{U}$ to the open set $\\mathcal{U}$ \nsuch that $T$ extends to a function $\\ol{T}$ on $\\mathcal{U}\\cup \\p \\mathcal{U}$, and\n$\\ol{T}$ is  the defining function for this boundary.\nWe then investigate the geometry on $M$ in the limit $T\\rightarrow 0$.\nIt is clear from above that\nthe zero locus of $\\ol{T}$ will be contained in the zero locus $\\mathcal{Z}(\\tau)$ of $\\tau$, and\ntherefore belongs to the boundary of $\\ol{M}$. We will \nuse $\\ol{T}$ as a defining function for $\\ol{M}$ in an open set $\\ol{\\mathcal{U}}\\subset\\ol{M}$.\nThe strategy of the proof is to extend $T$ to a coordinate system on \n$\\mathcal{U}$, such that near the boundary the metric $g$ takes a form\nas in Theorem \\ref{CGthm}.\n\n\nFirst define $\\beta\\in \\Lambda^1(\\ol{M})$ $\\ov{M}$\nby \n\\be\n\\label{def_theta}\n\\xi\\hook \\beta=J(\\xi)\\hook d T, \\quad\\mbox{or equivalently}\\quad \n\\beta_a=\\Omega_{ac}g^{bc}\\,({{^{\\bf g}\\nabla}}_b T), \\quad a, b, c=1, \\dots, 2n\n\\ee\nwhere $J$ is the para--complex structure of $(g,  \\Omega)$ and $\\xi$ is a vector field on $M$. Using (\\ref{eq:intro_model_g}) this  gives\n\\[\n\\beta=2T(1-T)\\zeta_id x^i-dT.\n\\]\nWe need $n$  open sets $\\mathcal{U}_1, \\dots, \\mathcal{U}_n$ such that $\\zeta_k\\neq 0$ on $\\mathcal{U}_k$\nto cover the zero locus of $T$. Here we chose $k=n$, and use\na coordinate system given by\n\\[\n(T, Z_1, \\dots, Z_{n-1}, X^1, \\dots,\n X^{n-1}, Y),\n\\] \nwhere $T$ is\ngiven by (\\ref{formula_for_T}) and\n\\[\nZ_A=\\frac {\\zeta_A}{\\zeta_n}, \\quad X^A=x^A, \\quad Y=x^{n}, \\quad\\mbox{where}\\quad\nA=1, \\dots, n-1.\n\\]\nWe compute\n\\[\n\\beta=2(1-T)\\frac{dY+Z_AdX^A}{K}-dT, \\quad\n\\zeta_n=\\frac{1}{KT}, \\quad \\mbox{where}\\quad K\\equiv Y+Z_AX^A,\n\\]\nand substitute\n\\[\n\\zeta_i dx^i=\\frac{1}{KT}(dY+Z_AdX^A)\n\\]\ninto (\\ref{eq:coord_form}). This gives\n\\be\n\\label{CG_Form}\ng=\\frac{\\beta^2-dT^2}{4T^2}+\\frac{1}{T}h_T,\n\\ee\nwhere \n\\[\nh_T=\\frac{1}{4(1-T)}(\\beta^2-dT^2)+\\frac{1}{K}\\Big(dZ_A\\odot dX^A-\\frac{1}{2(1-T)}X^A dZ_A\\odot(\\beta+dT)\\Big)\n\\]\nis regular at the boundary $T=0$. This is in agreement with the \nasymptotic form in Theorem \\ref{CGthm} (see \\cite{CG} for further details).\n\n%Note that (\\ref{def_theta}) defines the one form $\\beta$ on the boundary $T=0$  only up to a overall multiple of a positive function.\nThe restriction of $h_T$ to $\\p M$ gives a metric on the distribution ${ \\mathbb{H} }=\\mbox{Ker} (\\beta|_{T=0})$\n\\begin{gather}\n\\beta|_{T=0}=2\\frac{dY+Z_A dX^A}{Y+Z_AX^A}, \\nonumber \\\\\nh_T|_{T=0}=\\frac{1}{4}{(\\beta|_{T=0})}^2+\\frac{1}{2(Y+Z_AX^A)}(2dZ_A\\odot dX^A-X^AdZ_A\\odot(\\beta|_{T=0})). \\label{h000}\n\\end{gather}\n Note that $T$ is only defined up to multiplication by a positive function. Changing the defining function in this way results in a conformal rescaling of $\\beta|_{T=0}$, thus the metric on the contact distribution is also defined up to an overall conformal scale. We shall choose the scale so that\nthe contact form is given  by $\\beta_0\\equiv K\\beta|_{T=0}$ on $T(\\p M)$,\nwith the metric on ${ \\mathbb{H} }$ given by\n%\\footnote{The singular denominator $K^{-1}$ may be avoided by adopting the Pfaff %coordinates\n%\\[\n%y=\\ln{(Y+Z_iX^i)}, \\quad z_i=Z_i, \\quad x_i=-\\frac{X^i}{Y+Z_iX^i},\n%\\]\n%which yields\n%\\[\n%\\beta_0=2(dy+x^idz_i), \\quad h_{ H }=-(dx^i+x^idy)\\odot dz_i.\n%\\]\n%}\n\\be\n\\label{on_distri}\nh_{ \\mathbb{H} }=dZ_A\\odot dX^A.\n\\ee\n\nWe now move on to deal with the\ncurved case where the metric on $M$ is given by \n(\\ref{eq:coord_form}).\n%g=\\left(d\\zeta_a-\\left(\\Gamma_{ab}^c \\zeta_c- \\zeta_a\\zeta_b- \\Rho_{ab}\\right)\\d %x^b\\right)\\odot \\d x^a%\nThe coordinate system $(T, Z_A, X^A, Y)$ is as above, and\nthe one--form $\\beta$ in (\\ref{def_theta}) is given by\n\\[\n\\beta=2T(1-T)\\zeta_idx^i-dT+2T^2(\\Rho_{ij}-\\Gamma_{ij}^k\\zeta_k)x^idx^j,\n\\]\nor in the $(T, Z_A, X^A, Y)$ coordinates,\n\\[\n\\begin{split}\n\\beta=\\ 2&(1-T)\\frac{Z_AdX^A+dY}{K} - dT \\\\\n+& 2T^2\\Bigg[\\bigg(\\Rho_{AB}-\\frac{\\Gamma^C_{AB}Z_C+\\Gamma^n_{AB}}{TK}\\bigg)X^AdX^B \n+\\bigg(\\Rho_{nB}-\\frac{\\Gamma^C_{nB}Z_C+\\Gamma^n_{nB}}{TK}\\bigg)YdX^B \\\\\n+& \\bigg(\\Rho_{An}-\\frac{\\Gamma^C_{An}Z_C+\\Gamma^n_{An}}{TK}\\bigg)X^AdY \n+\\bigg(\\Rho_{nn}-\\frac{\\Gamma^C_{nn}Z_C+\\Gamma^n_{nn}}{TK}\\bigg)YdY\\Bigg].\n\\end{split}\n\\]\n%We find that $g$ in these coordinates is given by\n%%\\begin{split}\n%g=\n%\\end{split}\n%\\]\n\nGuided by the formula (\\ref{CG_Form}) we define\n\\[\nh_T=Tg-\\frac{1}{4T}(\\beta^2-dT^2),\n\\]\nwhich we find to be\n\\begin{equation*}\n\\begin{split}\nh_T=&\n\\frac{1}{4(1-T)}(\\beta^2-dT^2)+\\frac{1}{K}\\Big(dZ_A\\odot dX^A-\\frac{1}{2(1-T)}\nX^A dZ_A\\odot (\\beta+dT)\\Big)\\\\\n&-\\frac{1}{K}\\Big(\n(\\Gamma_{AB}^CZ_C+\\Gamma_{AB}^n)dX^A\\odot dX^B+\n(\\Gamma_{nn}^CZ_C+\\Gamma_{nn}^n)dY\\odot dY \\\\\n&\\qquad\\quad + 2(\\Gamma_{An}^CZ_C+\\Gamma_{An}^n)dX^A\\odot dY\\Big)\\\\\n&+T(\\Rho_{AB}dX^A\\odot dX^B+2\\Rho_{An}dX^A\\odot dY+\\Rho_{nn}dY\\odot dY).\n\\end{split}\n\\end{equation*}\nThis is  smooth as $T\\rightarrow 0$.\n\nRestricting $h_T$ to $T=0$ yields a metric which differs from\n(\\ref{h000}) by the curved contribution given by the components of the  connection, but not the Schouten tensor. Substituting $dY=K\\beta|_{T=0}/2-Z_AdX^A$, disregarding the terms involving $\\beta|_{T=0}$ in $h_T$, and conformally rescaling by \n$K$ yields the metric\n\\begin{eqnarray}\n\\label{met_th}\nh_{ \\mathbb{H} }&=&(dZ_A-\\Xi_{AB}dX^B)\\odot dX^A,\\quad\n\\mbox{where}\\\\\n\\Xi_{AB}&=&\\Gamma_{AB}^CZ_C+\\Gamma_{AB}^n+\n(\\Gamma_{nn}^CZ_C+\\Gamma_{nn}^n)Z_AZ_B-\n2(\\Gamma_{An}^CZ_C+\\Gamma_{An}^n)Z_B\\nonumber\n\\end{eqnarray}\ndefined on the contact distribution ${ \\mathbb{H} }=\\mbox{Ker}(\\beta_0)$, \nwhere $\\beta_0=2(dY+Z_AdX^A)$.\n\nWe now invoke Theorem \\ref{CGthm},  verifying\nby explicit computation that the remaining two conditions are satisfied. The first of these conditions is that the metric $h_{T}$ is compatible with the Levi--form of the almost para--CR structure on the boundary. %, i.e.\n%\\be\n%\\label{boundary_compatibility}\n%h_\\mathbb{H}(X, Y)=Cd\\beta_0(JX, Y), \\quad\\mbox{for}\\quad X\\in \\mathbb{H} .\n%\\ee\n%\\mynote{I think this is slightly different but I guess equivalent to the form given in the theorem. Might need a comment?}\n%\\mynote{Okay I'm not sure if $C$ should be negative, i.e. if the statement in the theorem is the better one because $d\\beta$ is like $-\\mathcal{L}$ but the statement in the theorem is the same as in \\cite{CG} i.e. in the case $J^2=-Id$. Would be good to check this.}\n%\\mynote{In fact in the theorem we are not talking about $h$ and $d\\beta$ restricted to $ \\mathbb{H} $, we are talking about $h$ and $d\\beta$ on $\\p M$, so maybe what I showed here is not the full condition?}\nThe second is that the Nijenhuis tensor takes asymptotically tangential values, i.e. that (\\ref{Nijenhuis_condition}) is satisfied.\n\nBoth of these can be checked by computing the almost para--complex structure $J$ in the $(T, Z_A, X^A, Y)$ coordinates. We find\n\\be\n\\begin{split}\n\\label{J_T=0}\n\\mathcal{J}:=J|_{T=0}=\\ &-\\frac{\\p}{\\p X^A}\\otimes dX^A +\\frac{\\p}{\\p Y}\\otimes dY + \\frac{\\p}{\\p Z_A} \\otimes dZ_A + \\frac{\\p}{\\p T}\\otimes dT \\\\\n&-\\frac{Z_B}{K}\\frac{\\p}{\\p T}\\otimes dX^B - \\frac{1}{K}\\frac{\\p}{\\p T}\\otimes dY \\\\\n&-\\big(\\Gamma^D_{AB}Z_D+\\Gamma^n_{AB}\\big)\\frac{\\p}{\\p Z_A} \\otimes dX^B + \\big(\\Gamma^D_{nB}Z_D+\\Gamma^n_{nB}\\big)Z_C\\frac{\\p}{\\p Z_C} \\otimes dX^B \\\\\n&-\\big(\\Gamma^D_{An}Z_D+\\Gamma^n_{An}\\big)\\frac{\\p}{\\p Z_A} \\otimes dY\n+\\big(\\Gamma^D_{nn}Z_D+\\Gamma^n_{nn}\\big)Z_C\\frac{\\p}{\\p Z_C} \\otimes dY.\n\\end{split}\n\\ee\nRestricting to vectors in $ \\mathbb{H} $ amounts to substituting $dY=\\beta_0/2-Z_AdX^A$ and disregarding the terms involving $\\beta_0$ as above, so that\n\\[\n\\begin{split}\nJ|_{ \\mathbb{H} }= &-\\frac{\\p}{\\p X^A}\\otimes dX^A +Z_A\\frac{\\p}{\\p Y}\\otimes dX^A + \\frac{\\p}{\\p Z_A} \\otimes dZ_A + \\frac{\\p}{\\p T}\\otimes dT \\\\\n&-\\frac{2Z_B}{K}\\frac{\\p}{\\p T}\\otimes dX^B -\\Xi_{AB}\\frac{\\p}{\\p Z_A}\\otimes dX^B\n\\end{split}\n\\]\nand the boundary compatibility condition is satisfied.\n\nFor the Nijenhuis condition, note that we need only consider components of $\\mathcal{N}$ with $a=T$ to verify (\\ref{Nijenhuis_condition}). Let us use the notation $J^{(T)}$ for the one--form comprising the $\\p/\\p T$ components of $J$. We find this to be\n\\[\n\\begin{split}\nJ^{(T)}=&\\bigg(-\\frac{Z_B}{K} + \\frac{T[2Z_B + (\\Gamma^D_{AB}Z_D+\\Gamma^n_{AB})X^A + (\\Gamma^D_{nB}Z_D+\\Gamma^n_{nB})Y]}{K} \\\\\n&\\quad - T^2[\\Rho_{AB}X^A+\\Rho_{nB}Y]\\bigg)dX^B \\\\\n&+\\bigg(-\\frac{1}{K} + \\frac{T[2 + (\\Gamma^D_{An}Z_D+\\Gamma^n_{An})X^A + (\\Gamma^D_{nn}Z_D+\\Gamma^n_{nn})Y]}{K} \\\\\n&\\qquad - T^2[\\Rho_{An}X^A+\\Rho_{nn}Y]\\bigg)dY.\n\\end{split}\n\\]\nNote that this agrees with (\\ref{J_T=0}) when $T=0$. Using the formula (\\ref{eq:Nijenhuis_index_def}), we now calculate\n\\[\n{\\mathcal{N}^{a}}_{bc}{^{\\bf g}}\\nabla_a T|_{T=0}=\\Big(\\mathcal{J}^d_{\\ [b}\\p_{|d|}J^{(T)}_{\\ \\ c]}-\\mathcal{J}^d_{\\ [b}\\p_{c]}J^{(T)}_{\\ \\ d}\\Big)\\Big|_{T=0}\n\\]\nto verify (\\ref{Nijenhuis_condition}).\n\n%The only non--vanising components of the torsion of the Libermann connection (\\ref{lib}) on\n%the boundary $\\p M$ are tangential to $\\p M$,\n% i. e.\n%\\[\n%\\Big({G^{a}}_{bc}{\\nabla^{\\bf g}}_a T\\Big)|_{T=0}=0.\n%\\]\n%The statement now follows as for the Liberman connection  (\\ref{lib}) the Nijenhuis tensor is a constant multiple of $G_{ab}^c$.\n\\koniec\n\n\\begin{rmk}\nIn the case if $n=2$ let us use coordinates $(x, y, z)=(X^1,Y,Z_1)$ on $\\p M$,  then (\\ref{met_th}) yields\n\\[\nh_{ \\mathbb{H} }=dz\\odot dx-[\\Gamma_{11}^2+(\\Gamma_{11}^1-2\\Gamma_{12}^2)z+(\\Gamma_{22}^2-2\\Gamma_{12}^2)z^2+\n\\Gamma_{22}^1z^3]dx\\odot dx,\n\\]\nwhich is transparently invariant under the projective changes (\\ref{eq:proj_change}) of $\\nabla$.\nIn the  two-dimensional case the \nprojective\nstructures $(N, [\\nabla])$ are equivalent to second order ordinary differential equations (\\ref{odealice}) whose integral curves $C$ are the unparametrised geodesics of $\\nabla$. The curves $C$ are integral submanifolds\nof a  differential\nideal ${\\mathcal I}=<\\beta_0, \\beta_1>$, where\n\\[\n\\beta_0=dy+zdx, \\quad \\beta_1=dz-\\Big(\\Gamma_{11}^2+(\\Gamma_{11}^1-2\\Gamma_{12}^2)z+(\\Gamma_{22}^2-2\\Gamma_{12}^1)z^2+\n\\Gamma_{22}^1z^3\\Big)dx\n\\]\nare one--forms on a three--dimensional manifold $\\mathcal{Z}=\\PP(T^*N)$ with local coordinates $(x, y, z)$. If $f:C\\rightarrow \\mathcal{Z}$ is an immersion, then $f^*(\\beta_0)=0, f^*(\\beta_1)=0$ is equivalent\nto (\\ref{odealice}) as long as $\\beta_2\\equiv dx$ does not vanish. In terms of these three one--forms\nthe contact structure, and the metric on the contact distribution are given by\n$\n\\beta_0,  h_{ \\mathbb{H} }=\\beta_1\\odot\\beta_2.\n$\n\\end{rmk}\n\n\\section{An alternative approach to Theorem \\ref{our_thm}}\n\nIt would be possible to show that the structures $(M,g,\\Omega)$ arising in the projective to Einstein correspondence are para--$c$--projectively compact using a purely tractor--based approach, without relying on Theorem \\ref{CGthm} and the local form (\\ref{eq:coord_form}). The basis for this alternative method is the \\textit{curved orbit decompositions} appearing in \\cite{CGH-duke}, which arise from \\textit{holonomy reductions} of Cartan geometries.\n\nRecall first that a connection $\\theta$ on a principal $S$--bundle $\\pi:\\mathcal{G}\\rightarrow M$ defines a unique horizontal lift of any smooth curve on $M$, and the we can define the \\textit{holonomy group} of $\\theta$ based at $u\\in \\mathcal{G}$ as\n\\begin{align*}\n\\mathrm{Hol}_u(\\theta)=\\{s\\in S\\ |&\\ u\\mbox{ can be joined to }us\\mbox{ by the}\\\\\n&\\mbox{ horizontal lift of a loop in }M\\mbox{ based at }\\pi(u)\\}.\n\\end{align*}\nThen $\\mathrm{Hol}_u(\\theta)$ is a subgroup of $S$, and if $M$ is connected then holonomy groups at different basepoints are related by conjugation in $S$. We can thus forget about the basepoint $u$ by defining $\\mathrm{Hol}(\\theta)$ as a conjugacy class of subgroups of $S$. Any subgroup ${H}$ such that $\\mathrm{Hol}(\\theta)\\subset \n{H}\\subset S$ defines a reduced bundle $\\mathcal{G}\\times_S G/{H}$ with structure group $H$ on which $\\theta$ induces a connection. %In particular, if some associated vector bundle to $P$ carries some addition structure which is parallel with respect to the associated connection, then the symmetry group of this structure is an example of a possible subgroup $\\tilde{H}$.\n\nAlthough the Cartan connection is not a principal bundle connection in the usual sense, one can still define a notion of holonomy for Cartan connections, and it turns out \\cite{CGH-duke} that a parallel section of an associated tractor bundle defines a Cartan holonomy reduction by a subgroup $H\\subset S$. The subgroup $H$ decomposes the homogeneous model $G/S$ into $H$--orbits, and it turns out that there is a corresponding decomposition of $\\mathcal{G}/S$ in the curved case, with \\textit{reduced Cartan geometries} arising on the orbits. This is the origin of the name \\textit{curved orbit decomposition}. In the $c$--projective case, the model is decomposed into a pair of open orbits separated by a closed submanifold. The open orbits carry almost K\\\"ahler metrics and the closed orbit carries an almost CR structure.\n\nBy our construction above it follows that $\\mathcal{M}$ has a canonical para--$c$--projective geometry. In the following section, we realise the model in terms of an orbit decomposition of a Lie group quotient, which we expect to be the homogeneous model for a para--$c$--projective Cartan bundle. We conjecture that a full description of the corresponding Cartan connection would lead to a proof of Theorem \\ref{our_thm} using the general Cartan holonomy theory in \\cite{CGH-duke}.\n\n\n\\subsection{The model case}\n\nRecall from Section \\ref{sec:intro_model} that the flat projective structure on $N=\\RP^n$ gives rise to \nthe neutral signature para--K\\\"ahler Einstein metric (\\ref{eq:intro_model_g}) on the manifold\n\\begin{align*}\nM=&\\{([P],[L])\\in\\RP^n\\times\\RP_n\\ |\\ P\\cdot L\\neq 0\\} \\\\\n=& \\mathcal{M}\\backslash\\mathcal{Z}(\\tau),\n\\end{align*}\nwhere $\\mathcal{M}$ was the projectivised cotractor bundle $\\PP(\\cT^*)$ of $\\RP^n$ and $\\mathcal{Z}$ was the zero locus of the density $\\tau$, or equivalently the set of incident pairs in $\\RP^n\\times\\RP_n$.\n\nHere we shall instead take $N$ to be the sphere $S^n$ with its standard flat projective structure where the geodesics are great circles, so that $N$ is orientable in all dimensions and the cotractor bundle is trivial. Note that $S^n$ is a double cover of $\\RP^n$ which consists of the set of \\textit{oriented} lines in $\\R^{n+1}$. We obtain it by taking an analogous quotient of $\\R^{n+1}$ where points are considered equivalent only up to multiplication by a \\textit{positive} number. We call this ray projectivisation and denote it $\\PP_+(\\R^{n+1})$.\n\nReplacing $\\RP^n$ with $S^n$ allows us to write the cotractor bundle of $N$ as $\\cT^*=S^n\\times\\R_3$, and if we also projectivise the fibres by ray projectivisation, we obtain a larger manifold\n\\[\n\\widetilde{\\mathcal{M}}=\\PP_+(\\cT^*)=S^n\\times S_n,\n\\]\nwhere $S_n$ is the dual to $S^n$ in the same sense that $\\RP_n$ is dual to $\\RP^n$. Then $\\widetilde{\\mathcal{M}}$ contains two copies of $M$ which are separated by the hypersurface $\\mathcal{Z}(\\tau)$. We now express this decomposition of $\\widetilde{\\mathcal{M}}$ as an orbit decomposition.\n\nConsider first two vector spaces $\\mathbb{V},\\mathbb{W}$ each isomorphic to $\\mathbb{R}^{n+1}$, and view each as a representation space for an $SL(n+1,\\mathbb{R})$ action. Define $G:= SL(\\mathbb{V})\\times SL(\\mathbb{W})$ with its action on $\\mathbb{V}\\times \\mathbb{W}$. We can write \n\\[\n\\mathbb{P}_+(\\mathbb{V}) \\times \\mathbb{P}_+(\\mathbb{W})=G/S=\\big( SL(\\mathbb{V})/P_V \\big)\\times \\big( SL(\\mathbb{W})/P_W \\big)\n\\]\nwhere $P_V$ (respectively\\ $P_W$) is the parabolic subgroup in $SL(\\mathbb{V})$\nthat stabilises a point $[V]$ in $\\mathbb{P}_+(\\mathbb{V})$ (respectively\\ $[W] \\in \\mathbb{P}_+(\\mathbb{W})$), and $S$ is the group product $P_V\\times P_W$ which itself is a\nparabolic subgroup of the semisimple group $G$.\nSince the action of $SL(\\mathbb{V})$ descends to a transitive action on the ray projectivisation $\\mathbb{P}_+(\\mathbb{V})$ and similarly $SL(\\mathbb{W})$ acts\ntransitively on $\\mathbb{P}_+(\\mathbb{W})$, we have that $G:= SL(\\mathbb{V})\\times SL(\\mathbb{W})$ acts transitively on the manifold $\\mathbb{P}_+(\\mathbb{V}) \\times \\mathbb{P}_+(\\mathbb{W})$.\n\nNote that we may consider $\\mathbb{V}$ and $\\mathbb{W}$ as the $\\pm 1$ eigenspaces of the single vector space $\\mathbb{V}\\oplus \\mathbb{W}$ equipped with an endomorphism\n$\\mathbb{J}$ such that $\\mathbb{J}^2=1$. Then the quotient $G/S$ is exactly analogous to the model for $c$--projective geometry discussed in Section \\ref{sec:c-proj_geom}. We can therefore expect $G/S$ to be the model for para--$c$--projective geometry.\n\n\nNow introduce an additional structure which breaks the $G$\nsymmetry. \nNamely we fix an isomorphism\n$$\nI:\\mathbb{W}\\to \\mathbb{V}^*\n$$\nwhere $\\mathbb{V}^*$ denotes the dual space to $\\mathbb{V}$. The subgroup $H\\cong SL(n+1,\\mathbb{R})$ of $G$\nthat fixes this may be identified with $SL(\\mathbb{V})$ which acts on a pair\n$(V,W)\\in \\mathbb{V}\\times \\mathbb{V}^*$ by the defining representation and on the first\nfactor and by the dual representation on the second factor. Note in particular that this action preserves $W(V)$.\n\nGiven this structure we may now (suppress $I$ and) write\n$$\n\\widetilde{\\mathcal{M}}= \\mathbb{P}_+(\\mathbb{V}) \\times \\mathbb{P}_+(\\mathbb{V}^*).\n$$\nThe ${H}$ action on $\\widetilde{\\mathcal{M}}$ has two open orbits and a closed orbit. The last\nis the incidence space \n$$\n\\mathcal{Z}=\\{ ([V],[W])\\in \\mathcal{M} \\mid W(V)=0 \\} \n$$\nwhich sits as smooth orientable separating hypersurface in $\\widetilde{\\mathcal{M}}$. Then there are the open orbits\n$$\nM_+=\\{ ([V],[W])\\in \\mathcal{M} \\mid W(V)>0 \\} \\quad \\mbox{and} \\quad\nM_-=\\{ ([V],[W])\\in \\mathcal{M} \\mid W(V)<0 \\}.\n$$\nWe may think of $\\mathcal{Z}$ as the `boundary' (at infinity) for the open orbits $M_\\pm$, each of which is a copy of our para--K\\\"ahler Einstein manifold $M$.\n\nWe therefore have an orbit decomposition of the homogeneous space $G/S$, where the additional structure $I$ has induced a reduction of the holonomy group by ${H}$. Based on the results of \\cite{CGH-duke} for the analogous $c$--projective case, we expect the closed orbit $\\mathcal{Z}$ to carry a para--CR structure and the open orbits $M_\\pm$ to carry para--K\\\"ahler metrics which are induced by the dual pairing between $\\mathbb{V}$ and $\\mathbb{V}^*$ just as we saw in Section \\ref{sec:trac_construction_g}.\n\n\n\n%We now describe the geometries on the orbits. The claim is that there are Einstein metrics in $M_\\pm$, while $\\mathcal{Z}$ is well known as the model for so-called contact Langrangian (or sometimes called para--CR) geometry, this is a real analogue of hypersurface type CR geometry.\n\n%First observe that $N_V:=\\mathbb{P}_+(V)$ is the flat model of projective geometry. So in particular we have\n%$$\n%0\\to \\ce_V(-1)\\stackrel{X}{\\to}\\cT_V\\to TN_V(-1)\\to 0\n%$$\n%where $\\cT_V$ is the projective tractor bundle on $N_V$ and $X$ is the tautological section of $\\cT(1)$, which coincides with the canonical tractor. Similarly there a sequence on $N^W:= \\mathbb{P}_+(V^*)$\n%\\begin{equation}\\label{useful}\n%0\\to \\ce^W(-1)\\stackrel{U}{\\to}\\cT^W \\to TN^W(-1)\\to 0 .\n%\\end{equation}\n\n%There is a natural tractor bundle $\\mathcal{T}:=\\cT_V\\oplus \\cT^W $ on $M$.  Where $X$ and $U$ are not incident this induces a metric on $M$ as follows. Observe that, at a point $([X],[U])$ where $X\\hook U \\neq 0$, the  tractor field  $U$ splits the first sequence by $\\nu\\in \\Gamma (\\ce(-1,0))$ defined by\n%$$\n%\\nu:=U/\\tau\n%$$\n%with $\\tau:=X\\hook U$ (and where we have used an obvious weight notation). This follows as $X\\hook \\nu=1$. Similarly\n%$$\n%x:=X/\\tau \\in \\Gamma (\\ce(0,-1))\n%$$\n%splits the second short exact sequence because $x \\hook U=1$. Thus we obtain a neutral signature metric on $TN_V\\oplus TN^W$ by these two steps: First, using  these splittings yields a bundle monomorphism\n%$$\n%TN_V(-1,0)\\oplus TN^W(0,-1) \\to \\cT_V\\oplus \\cT^W .\n%$$ Second, this gives a symmetric form $\\boldsymbol{g}$ and symplectic form $\\boldsymbol{\\Omega}$ on $TN_V(-1,0)\\oplus TN^W(0,-1)$ by then using the canonical metric and symplectic form on $\\cT_V\\oplus \\cT^W $ given by the duality of $\\cT_V$ and $ \\cT^W$. Thus $\\boldsymbol{g}\\in \\Gamma (S^2T^*M(1,1))$ and $\\boldsymbol{\\Omega}\\in \\Gamma (\\Lambda^2T^*M(1,1))$. Then set\n%$$ g:=\\frac{1}{\\tau}\\boldsymbol{g} \\qquad \\mbox{and} \\qquad  \\Omega:=\\frac{1}{\\tau}\\boldsymbol{\\Omega}.\n%$$\n%The metric $g$ is easily seen to have neutral signature.  It is Einstein because the tractor metric on $\\mathcal{T}$ is parallel for the tractor connection (see \\cite{CGH-duke} for the analogous c-projective case). The tractor connection arises from the usual parallel transport on the vector space $V\\oplus V^*$ viewed as an affine manifold.\n\n", "meta": {"hexsha": "91be05ee00779194e0516606aacbd0978da72e16", "size": 46802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter6/c-proj.tex", "max_stars_repo_name": "AliceWaterhouse/thesis", "max_stars_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter6/c-proj.tex", "max_issues_repo_name": "AliceWaterhouse/thesis", "max_issues_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter6/c-proj.tex", "max_forks_repo_name": "AliceWaterhouse/thesis", "max_forks_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.1276595745, "max_line_length": 1021, "alphanum_fraction": 0.6989444896, "num_tokens": 15732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.4280362305198169}}
{"text": "All of the main contributions of this thesis are presented in this chapter. Specifically, a variation of eviction policies, other than what have been proposed in~\\cite{park90}, and alternative data structures, that can be used as the container for the numerical database, are discussed.\n\n\\section{Priority}\n\\subsection{Improved WST Priority}\n\\label{sssec:improved_wst}\nThe weighted search tree priority representation, discussed in \\Cref{sec:wst_priority}, has some drawbacks that probably were irrelevant at the time when \\cite{park90} was published. The problem is that keeping the hit counter in only 24 bits (even more, the hit counter multiplied by the base priority) would result in an integer overflow sooner or later.\n\nFor example, imagine the case when the base priority is the maximum possible~-- 255. Binary representation is \\nsnum{000000FF}{16}. After 65793 hits, the priority will have its maximum value~-- \\nsnum{FFFFFFFF}{16}. If another hit counter adjustment is made an overflow occurs, producing the value \\nsnum{000000FE}{16}. Therefore, the maximum priority becomes very low, and even the base priority has been changed.\nThere are at least two possible solutions:\n\\begin{description}\n\\item[Use larger counter]-- store the WST priority in a 64-bit integer. An overflow of a 56-bit counter is unlikely, not to say impossible~-- even with the maximum base priority, an overflow will occur only after the 282578800148737th insertion. It would take days to make so many adjustments, even if the processor performs only these adjustments and nothing else (which is at least impractical). Nevertheless, a certain disadvantage is that the memory overhead per each node is increased by 4 bytes.\n\\item[Perform a saturated addition] when adjusting the hit counter (\\Cref{alg:wst_priority2}). The \\emph{saturated addition} is the addition that yields the expected result if no overflow occurs during the operation and the maximum number for the given operand size otherwise. The drawback of this method is the slightly increased computation time.\n\\end{description}\n\nThe difference between these two methods is the common trade-off between time and space. Since the total count of items that can be stored in a database with the limited memory available is the crucial characteristic of a database, the preference is given to the \\emph{saturated addition} method.\n%\\newfloat{algorithm}{tbp}{lop}\n\\begin{algorithm}[t]\n\\caption{$WST$ priority update with saturation}\\label{alg:wst_priority2}\n\\begin{algorithmic}[1]\n  \\Procedure{UpdateSaturated}{$priority$}\\Comment{4 bytes long unsigned integer}\n    \\State $base\\_priority\\gets priority \\mathrel{\\&} \\nsnum{FF}{16}$\n    \\State $new\\_priority\\gets base\\_priority$\n    \\Comment{8 bytes long unsigned integer}\n    \\State $new\\_priority \\gets new\\_priority \\times \\nsnum{100}{16}$\n    \\State\\Comment{Maximum possible result is \\nsnum{FFFFFFFF00}{16}}\n    \\If{$new\\_priority < \\nsnum{FFFFFFFF}{16}$}\n    \\Comment {Maximum value for 4 bytes}\n      \\State $priority \\gets new\\_priority + base\\_priority$\n    \\Else\n      \\State $priority \\gets \\nsnum{FFFFFF00}{16} + base\\_priority$\n    \\EndIf\n    \\State \\textbf{return} $priority$\n  \\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n%%%%%%%%%%%%Simple priority?\n\n\\subsection{Priority Aging}\n\\label{sssec:priority_aging}\nThe WST priority has one more drawback~-- it is suitable only for static input distributions~-- distributions, which mean remains constant during the execution. However, if the mean is known beforehand it is possible to construct a static optimal BST\\cite[p.~442]{knuth3}, that will be more efficient than any dynamic lookup data structure.\n\nA numerical database with the WST priority performs poorly on the time-varying distribution~-- a distribution which mean changes over time~-- while this type of distributions is more common in the real world applications. The problem arises from the fact that the priority does not reflect when an item was accessed for the last time.\n\nThe worst-case scenario is the following: an item is added to a database, then it is accessed frequently hence its priority rises to the maximum, and then is not used over a long time. During the runtime, several items like this can appear. Even though at some point they are not accessed anymore they are still the most valuable items from the perspective of the database hence they will be kept much longer than other items. This pollutes the database with elements that are stored but not used.\n\nThere are several ways to cope with the problem. First of all, it is possible to use an entirely \\emph{different eviction policy}, the one that is not based on the item priority. Some of these policies are described in \\Cref{sec:aep}.\n\nAnother solution is to adjust a priority not only when the corresponding node is accessed but also when it is visited (during the lookup of another item). For example, when searching in a binary search tree, the priority of the node $N$ that is being searched is increased while priorities of the nodes, lying on the path between the root of the tree and $N$, are degraded.\n\nThis mechanism may not be effective with the AVL tree because in the AVL tree the order of the nodes does not correlate with node priorities. However, it seems very promising in application to the splay tree~-- by applying this mechanism, the nodes near the root can stay there if only they are constantly accessed.\n\n\\section{Alternative Eviction Policies}\n\\label{sec:aep}\nThe canonical weighted search tree always chooses the node with the minimum priority for the deletion. However, it is only one of many possible eviction policy. Some other policies are presented in this section. From general ones, like LRU, to those exploiting the lookup data structure internals to find the least valuable item.\n\n\\subsection{LRU Policy}\n\\label{sssec:lru}\nThe Least-Recently-Used policy tracks every access to the items and sorts them by the access order. Then it evicts the item that was not accessed for the longest time. The common implementation is based on a doubly-linked list. When an item is accessed its corresponding node in the LRU list is moved into the head of the list. Then the least-recently-used node is the one in the tail of the list. When a new item is added, it is inserted in the head of the LRU list.\n\n\\subsection{LFU Policy}\n\\label{sssec:lfu}\nThe Least-Recently-Used item policy fulfills the same purposes as the LRU policy. But when it decides which item should be evicted, the access frequency is also taken in account in addition to the last access time (LRU uses the latter property only).\n\n\\subsection{Splay Policy}\n\\label{sssec:spolicy}\nA splay tree tends to keep the most frequently accessed items near its root. By relying on this property, it is possible to eliminate a separate data structure that manages item priorities. When an eviction is performed, one of the bottom nodes is chosen for eviction. Even though this strategy may not choose the optimal node every time, it is expected to perform effectively on average. Moreover, this approach has the lowest memory overhead per node among all tested data structures.\n\n\n\\section{Alternative Sequential Containers}\n\n\\subsection{Hash Table}\nOne of the data structures that can be used in place of the weighted search tree is the hash table. Hash tables have faster than balanced BSTs lookup time under most workloads. What is more, a node in a hash table has lower memory overhead than a binary tree~-- with open hashing (based on a doubly linked list) every node stores only 2 pointers compared to 3 in a binary tree node and using closed hashing implies that no pointers are stored at all.\n\nHowever closed hashing can not be used because when the hash table is almost full, a lot of unsuccessful probes occur before a suitable index is found. Usually, this problem is solved by rehashing~-- if the count of probes exceeds the certain limit, the hash table is expanded. However, it is impossible in the numerical database since the amount of available memory is preset and cannot be exceeded.\n\nOn the other hand, limited memory is rather an advantage for the open hashing. If the total amount of memory available is known beforehand, then a hash table with open hashing can be preallocated to its maximum size and be never rehashed after. This, in turn, allows a concurrent version of a hash table to be simplified as the concurrent rehashing is one of the hardest problems to cope with.\n\n\\subsection{Splay Tree}\nAnother data structure that looks promising is the splay tree.\nAs it was mentioned in \\Cref{sssec:splay}, usually splay trees tend to be slower than AVL. However, in application to the numerical database, it is possible to exploit the fact that the least valuable nodes are usually gathered in leaves of the tree. Therefore it is is possible to eliminate a binary heap from a numerical database and to use the splay policy, as described in \\Cref{sssec:spolicy}. What is more, it is possible to implement a concurrent numerical database using the concurrent splay tree\\cite{cb_tree}.\n\n\\section{Alternative Concurrent Containers}\n\\label{sec:concurrent_containers}\n\\subsection{Coarse-grained Lock Adapter}\nThe \\numdbname library provides a universal adapter, that wraps a sequential container and adapts it to the concurrent environment by using the coarse-grained locking approach (\\Cref{sec:cgl}). It has the same interface, as a usual numerical database container. All methods follow the same structure:\n\\begin{enumerate}\n\\item the mutex is locked\n\\item the call is forwarded to the underlying container\n\\item the mutex is released\n\\end{enumerate}\n\n\\subsection{Binning Adapter}\nThe binning adapter class realises the binning concept (described in \\Cref{sec:pre_bin}). It is similar to the coarse-grained lock adapter, however, it encapsulates several instances of a container, each with own mutex.\n\nThe number of bins is passed in the class constructor. The mapping is defined as  $\\func{hash}{K}\\bmod bin\\_count$. Every bin is represented by a sequential container, e.g. the weighted search tree. In order to preserve the memory limit, all available memory is equally divided between all bins.\n\n\\subsection{CNDC}\n\\label{sec:cndc}\nFor the purposes of the \\numdbname library, the original concurrent container, called \\emph{Concurrent Numerical Database Container}~-- \\cndcname, has been developed. It defines 3 thread-safe operations~-- \\findop, \\insertop, and \\func{removeMin}{}. Thread-safeness is achieved through the fine-grained locking approach. \\cndcname is based on concurrent versions of the hash table and the binary heap. Sequential benchmarks (\\Cref{sec:secanalysis}) proved that the combination of a hash table and a binary heap outperforms numerical databases, that are based on the LRU and LFU eviction policies.\n\nFine-grained locking hash table implementation is much simpler compared to a similar concurrent BST. A lock is assigned to every hash table bucket (or every $k$ buckets) and every operation inside the bucket locks the corresponding mutex. Since an operation in one bucket never interferes with any other bucket, only one lock is needed per operation, while other threads can operate on other buckets at the same time. Therefore, the overhead added by locking is smaller, than in a concurrent BST, where up to $\\log{\\func{height}{T}}$ mutexes has to be locked on every operation.\n\nThere are several known binary heaps with a fine-grained locking (\\cite{concurrent_heap1}, \\cite{champ} and more). The \\cndcname is based on the \\libname{champ} binary heap, developed by Tamir, Morrison, and Rinetzky \\cite{champ}. Unlike the majority of concurrent binary heaps, \\libname{champ} allows priorities to be updated after the insertion.\n\nIn the following section, two types of locks are distinguished~-- the \\emph{bucket} mutex (the one, that protects a single bucket in a hash table) and the \\emph{heap} mutex (the one, that protects a single item in a binary heap. Every hash table node has a link to the corresponding heap node and vice versa. \\cndcname operations are defined as follows:\n\n\n\\begin{block-description}\n\\item[\\findop] consists of the following steps. At first, calling thread locks the corresponding bucket mutex. The requested item is searched in the bucket.\n\nIf the item is found, its priority is updated.\nBefore updating the priority the corresponding heap mutex must be locked.\nAfter locking the heap mutex the link to the heap node is checked again. If it has changed, the heap lock is released and the operation is repeated. Double check is required, because another thread can change the link even in case it does not hold the bucket mutex.\n\nHowever, the heap mutex is required to be locked prior to the link update. Therefore, when a thread holds a heap mutex it is guaranteed, that no other thread can change the link between the heap node and the hash table node.\n\nWhen the node is locked, the priority is updated and the \\func{bubbleDown}{} operation (as defined in \\cite{champ}) is performed. \\func{bubbleDown}{} internally releases the heap and bucket locks.\n\n\\item[\\insertop] has a structure, similar to \\findop.\nThe corresponding bucket mutex is locked.\nNew item is inserted into the hash table. After that, the item is inserted in the binary heap (at the last index). Before the insertion is performed, the heap lock of the last index is locked.\n\nThe bucket mutex is released. It is possible to do this so early, because the \\emph{heap} lock will be held till the end of the operation. While it is locked, no other thread can execute any operation on the same node.\n\nFinally, \\func{bubbleUp}{}\\cite{champ} is performed. It propagates the node down until the heap invariant is restored.\n\n\\blockitem[\\func{removeMin}{}] evicts the item with the lowest priority. This operation is decomposed into three independent parts.\n\n\\begin{enumerate}\n\\item The item is evicted from the heap.\n\\item The hash table node is marked as \\emph{deleted}. Otherwise, another thread can access the item and start the priority update routine. Since the node does not exist in the heap anymore, the thread will enter into an infinite loop. Marking solves the problem as follows~-- the marked node can still be accessed by other threads, however, they will skip the priority update stage for the node.\n\\item The item is removed from the hash table.\n\\end{enumerate}\n\n\\end{block-description}\n%Search operation can be improved by using some technique, that would allow to release the bucket lock earlier, prior to \\func{BubbleDown}{}. Such technique has not been developed yet.\n\n", "meta": {"hexsha": "916e8a8d6b8142e8a42b2166a4126abbaa47b093", "size": 14596, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Text/tex/3_Numerical_database_variations.tex", "max_stars_repo_name": "metopa/bachelors_thesis", "max_stars_repo_head_hexsha": "7937368e8d34eb68b1e90a6097737d48ca72c174", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Text/tex/3_Numerical_database_variations.tex", "max_issues_repo_name": "metopa/bachelors_thesis", "max_issues_repo_head_hexsha": "7937368e8d34eb68b1e90a6097737d48ca72c174", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Text/tex/3_Numerical_database_variations.tex", "max_forks_repo_name": "metopa/bachelors_thesis", "max_forks_repo_head_hexsha": "7937368e8d34eb68b1e90a6097737d48ca72c174", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 105.768115942, "max_line_length": 596, "alphanum_fraction": 0.7910386407, "num_tokens": 3217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4280362258434245}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage[\\graphtype]{mfpic}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\opengraphsfile{pl02-04}\n\\begmath 2.4 Bessel Functions $J_0$, $J_1$, $Y_0$ and $Y_1$\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese subprograms compute values of the cylindrical Bessel functions\nof the first kind, $J_0$ and $J_{1}$, and of the cylindrical Bessel\nfunctions of the second kind, $Y_0$ and $Y_{1}$.  These functions are\ndiscussed in \\cite{ams55} and \\cite{Hart:1968:CA:bes}.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype, Single Precision}\n\\begin{description}\n\\item[REAL]  \\ {\\bf X,SBESJ0,SBESJ1,SBESY0,SBESY1,W}\n\\end{description}\nAssign a value to X and use one of the following function references.\n\n\\begin{tabular}{ll}\nTo compute $J_0:$ & \\fbox{\\bf W = SBESJ0(X)}\\rule[-15pt]{0pt}{8pt}\\\\\n\nTo compute $J_1:$ & \\fbox{\\bf W = SBESJ1(X)}\\rule[-15pt]{0pt}{8pt}\\\\\n\nTo compute $Y_0$ for $x > 0:$ & \\fbox{\\bf W = SBESY0(X)}\\rule[-15pt]{0pt}{8pt}\\\\\n\nTo compute $Y_1$ for $x > 0:$ & \\fbox{\\bf W = SBESY1(X)}\n\\end{tabular}\n\n\\subsubsection{Argument Definitions}\n\\begin{description}\n\\item[X]  \\ [in] Argument of function. Require X $>0$ for the Y\nfunctions.\n\\end{description}\n\\subsubsection{Modifications for Double Precision}\nFor double precision usage, change the REAL type statement to DOUBLE\nPRECISION, and change the function names to DBESJ0, DBESJ1, DBESY0, and DBESY1,\nrespectively.\n\n\\subsection{Examples and Remarks}\n\nThe listing of DRSBESJ0 and ODSBESJ0 gives an example of using these\nsubprograms to evaluate the Wronskian identity\n\\begin{equation}\nz(x) = (x\\pi /2)[J_1(x)Y_0(x)-J_0(x)Y_1(x)] - 1 = 0\\notag\n\\end{equation}\n\n\\subsection{Functional Description}\n\nThe functions $J_n$ and $Y_n$ are a pair of linearly\nindependent solutions for the differential equation\n\\begin{equation}\nx^2\\frac{d^2w}{dx^2}+x\\frac{dw}{dx}+\\left( x^2-n^2\\right) w=0\\notag\n\\end{equation}\nThe functions $J_0$ and $J_1$ are defined for all real $x$. The function $J_0\n$ is even, and $J_1$ is odd. As $x\\rightarrow \\infty $, $J_0(x)$ and $J_1(x)$\noscillate an infinite number of times about zero with an amplitude that\ndiminishes asymptotically to $[2/(\\pi x)]^{\\frac 12}$, $i.e.$, approximately\n$0.80x^{-\\frac 12}$. The distance between successive zeros approaches $\\pi $\nas $|x|\\rightarrow \\infty .$\n\nThe functions $Y_0$ and $Y_1$ have real values for positive real $x$,\napproach $-\\infty $ as $x\\rightarrow 0^{+}$ and have complex values for\nnegative real $x$. For large positive $x$ the Y functions have oscillatory\nbehavior similar to the J functions, $i.e.$, with amplitude approaching $0.80\nx^{-\\frac 12}$ and zero spacing approaching $\\pi $. As $x\\rightarrow 0^{+}$%\n, $Y_0(x)\\rightarrow (2/\\pi )\\ln (x)$ and $Y_1(x)\\rightarrow -(2/\\pi x).$\n\n\\vspace{10pt}\n\n\\hspace{5pt}\\mbox{\\input pl02-04 }\n\nThe Y subprograms treat $x\\leq 0$ as an error condition. If the complex values\nof $Y_0$ and $Y_1$ for negative $x$ are desired they may be computed from\nthe formulae\n\\begin{equation}\n\\begin{array}{ll}\n\\begin{array}{rcl}\nY_0(x) & = & Y_0(-x)+2iJ_0(-x)\n\\rule[-10pt]{0pt}{8pt} \\\\ Y_1(x) & = & -Y_1(-x)-2iJ_1(-x),\n\\end{array}\n\\quad x<0\n\\end{array}\\notag\n\\end{equation}\nwhere $i$ denotes the imaginary unit. See Equation 9.1.36 in \\cite{ams55}.\n\nThe computer approximations for these functions were developed by L. W.\nFullerton, \\cite{Fullerton:1973:FNLIB} and \\cite{Fullerton:1977:PSF},\nusing functional forms involving sine, cosine, square root, logarithm, and\nChebyshev polynomial approximations.  These subprograms select the\npolynomial degrees to adapt to machine accuracy of up to 30 decimal\nplaces.\n\nThe single precision subprograms for $J_n(x)$ and $Y_n(x)$ were tested on a\nUnivac~1100 by comparison with the corresponding double precision\nsubprograms over various argument ranges. The relative precision of Univac\nsingle precision arithmetic is $\\rho = 2^{-27} \\approx 0.745\\times 10^{-8}$.\n\nThe results show that the relative error can be very large near the zeros\nof any of these functions with the exception that relative accuracy can be,\nand is, maintained for $J_1$ near its zero at $x = 0$. The absolute error\nis large for $Y_0$ and $Y_1$ near the singularity at $x = 0.$\n\nTest results may be summarized as follows.\n\n\\begin{tabular}{lllc}\n &\\multicolumn{1}{c}{\\bf Argument} & \\multicolumn{1}{c}{\\bf Maximum} &\n\\multicolumn {1}{c}{\\bf (Abs. or}\\\\\n\\multicolumn{1}{c}{\\bf Function}  &\\multicolumn{1}{c}{\\bf Interval} &\n\\multicolumn{1}{c}{\\bf Error} & \\multicolumn{1}{c}{\\bf Rel.)}\\\\\nSBESJ0 & [$-$5.6, 5.6] & \\hspace{10pt} $6.5\\rho $ & (Abs.)\\\\\n & [1.0, 1.0E6] & \\hspace{10pt} $2.1\\rho x^{\\frac{1}{2}}$ & (Abs.)\\\\\nSBESJ1 & [$-$7.2, 7.2] & \\hspace{10pt} $3.8\\rho $ & (Abs.)\\\\\n & [1.0, 1.0E6] & \\hspace{10pt} $1.1\\rho x^{\\frac{1}{2}}$ & (Abs.)\\\\\nSBESY0 & [0.00, 0.32] & \\hspace{10pt} $7.6\\rho $ & (Rel.)\\\\\n & [0.32, 1.12] & \\hspace{10pt} $6.0\\rho $ & (Abs.)\\\\\n & [1.12, 4.00] & \\hspace{10pt} $1.9\\rho $ & (Abs.)\\\\\n & [1.0, 1.0E6] & \\hspace{10pt} $2.1\\rho x^{\\frac{1}{2}}$ & (Abs.)\\\\\nSBESY1 & [0.0, 1.1] & \\hspace{10pt} $6.6\\rho $ & (Rel.)\\\\\n & [1.1, 5.5] & \\hspace{10pt} $3.0\\rho $ & (Abs.)\\\\\n & [1.0, 1.0E6] & \\hspace{10pt} $1.3\\rho x^{\\frac{1}{2}}$ & (Abs.)\n\\end{tabular}\n\nFor the functions $J_n(x)$ and $Y_n(x)$ the absolute error is approximated\nby $2|x|^{\\frac{1}{2}}\\rho $ for large $|x|$ while the amplitude of the\nfunction values decreases like $0.8|x|^{-\\frac{1}{2}}$. Thus no accuracy at\nall can be expected when $2|x|^{\\frac{1}{2}}\\rho > 0.8|x|^{-\\frac{1}{2}}$, $i.e.$%\n, when $|x| > 0.4\\rho ^{-1}$. The subprograms assume less than one decimal\ndigit of accuracy could be produced when $x > 0.04\\rho ^{-1}$, and issue an\nerror message.\n\nAs a test of the double precision subprograms and an additional test of\nthe single precision\nsubprograms the test function, $z(x)$, defined above in Section C, was\nevaluated in double precision and in single precision at selected points\nranging from $10^0$ to $10^7$. The machine arithmetic accuracies were $%\n\\rho_1 = 2^{-27} \\approx 0.745\\times 10^{-8}$ for single precision\nand $\\rho _2 = 2^{-60} \\approx 1.15\\times 10^{- 18}$ for double precision.\nThe magnitude of $z(x)$ computed in single precision was bounded\nby $8\\rho _1$ for $10^0 \\leq x \\leq 10^4$ and had the value\n$22\\rho _1$ for $x = 10^5$ and $x = 10^6$. The magnitude of $z(x)$ computed\nin double precision was bounded by $9\\rho _2$ for $10^0 \\leq x \\leq 10^7.$\n\nThis accuracy is much greater than the individual subprograms, SBESJ0, etc.,\ndeliver for large arguments. Thus the very accurate values of $z(x)$ must be\ndue to a functional relation existing between the algorithms implemented in\nthe different cylindrical Bessel function subprograms.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nThese subprograms return a zero result and issue an error message if\n\n\\begin{tabbing}\n\\hspace{.3in}\\=(a)\\quad \\=$x \\leq 0 \\text{ for } Y_0\\text{ or }Y_1,$\\\\\nor\\\\\n\\>(b)\\>$|x| > 0.04\\rho ^{-1}\\text{ for }J_0,\\ J_1,\\ Y_0\\text{ or }Y_1.$\n\\end{tabbing}\n\nThe subprograms use R1MACH(4) or D1MACH(4) for $\\rho $.  The\nsystem-supplied sine and cosine subprograms may also have a cutoff\nvalue close to $\\rho ^{-1}$. If it is less than $0.04\\rho ^{-1}$ then\nthere will be values of $x$ that will pass through the tests and\ntrigger an error message from the sine or cosine subprogram.\n\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDBESJ0 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESJ0, DBMP0, DCSEVL, DERM1, DERV1, DINITS, ERFIN, ERMSG,\nIERM1, IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\nDBESJ1 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESJ1, DBMP1, DCSEVL, DERM1, DERV1, DINITS, ERFIN, ERMSG,\nIERM1, IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\nDBESY0 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESJ0, DBESY0, DBMP0, DCSEVL, DERM1, DERV1, DINITS, ERFIN, ERMSG,\nIERM1, IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\nDBESY1 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DBESJ1, DBESY1, DBMP1, DCSEVL, DERM1, DERV1, DINITS, ERFIN,\nERMSG, IERM1, IERV1\\rule[-5pt]{0pt}{8pt}}\\\\\n% \\end{tabular}\n% \\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n% \\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nSBESJ0 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMSG, IERM1, IERV1, SBESJ0, SBMP0, SCSEVL, SERM1,\nSERV1, SINITS\\rule[-5pt]{0pt}{8pt}}\\\\\nSBESJ1 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMSG, IERM1, IERV1, SBESJ1, SBMP1, SCSEVL, SERM1,\nSERV1, SINITS\\rule[-5pt]{0pt}{8pt}}\\\\\nSBESY0 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMSG, IERM1, IERV1, SBESJ0, SBESY0, SBMP0, SCSEVL,\nSERM1, SERV1, SINITS\\rule[-5pt]{0pt}{8pt}}\\\\\nSBESY1 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, ERFIN, ERMSG, IERM1, IERV1, SBESJ1, SBESY1, SBMP1, SCSEVL,\nSERM1, SERV1, SINITS\\rule[-5pt]{0pt}{8pt}}\\\\\n\\end{tabular}\n\nSubprograms SBESJ0, SBESJ1, SBESY0 and SBESY1 designed and developed by L.\nW. Fullerton, Los Alamos, 1977. Adapted to Fortran~77 and the MATH77\nlibrary by C. L. Lawson and S. Chiu, JPL, 1984.\n\n\n\\begcodenp\n\\enlargethispage*{6pt}\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\\centerline{\\bf \\large DRSBESJ0}\\vspace{-3pt}\n\\lstinputlisting{\\codeloc{sbesj0}}\n\\vspace{4pt}\\centerline{\\bf \\large ODSBESJ0}\\vspace{3pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sbesj0}}\n\\closegraphsfile\n\\end{document}\n", "meta": {"hexsha": "cd014a10acd515b467aa5aa9588cc9142a15be81", "size": 9657, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch02-04.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch02-04.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch02-04.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 42.92, "max_line_length": 98, "alphanum_fraction": 0.7015636326, "num_tokens": 3673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.7772998663336157, "lm_q1q2_score": 0.4279870201688338}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{amsthm}\n\\usepackage{geometry}\n\\geometry{a4paper} \n\\usepackage{fancyhdr}\n\\usepackage{xcolor}\n\\usepackage{amssymb}\n\\usepackage{multicol}\n\\begin{document}\n\\author{\\textbf{Elshimaa Ahmed}}\n\\title{\\textbf{Math 501 \\\\\n\\large Lecture 1\\\\}}\n\\date {\\today}\n\\maketitle\n\\noindent\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\\section{Preposition}\n\\paragraph{}\n  a preposition is a claim or a declerative statement which has a truth value , can be proven to be either $True$ or $False$\n\\paragraph{For Example: }\n\\begin{itemize}\n    \\item \"Shimaa studies discrete mathimatics\" is considered as $Preposition$\n    \\item \"How was your day?\" is considered as $ not-Preposition$\n    \\item $x$ + 1 = 2 is considered as $non$ $declerative$ $statement$ because it is truth value depends on a variable so cannot be proven to be $True$ or $False$ without knowing the value of that variable \n\\end{itemize}\n\\section{Logical Operators}\n     \\begin{definition}[\\textbf{Negation}]\n       let $p$ a preposition the negation of $p$ , denoted by $\\neg$$p$ .The truth value of the negation of $p$ $\\neg$ $p$ is the opposite value of $p$\n       , expressed in English as \"It's not the case that. p\" \n     \\end{definition}\n    \\textbf{For Example:}\n    \\begin{itemize}\n      \\item the negation of \"I have more than 5 friends\" will become \"I have at most 5 friends\"\n    \\end{itemize}\n\n    \\begin{definition}[\\textbf{Conjunction}]\n      let $p$ and $q$ be prepositions , the conjunction of $p$ and $q$ denoted by $p$ $\\wedge$ $q$ is a preposition \"$p$ and $q$\" that become true only if both $p$ and $q$ are both $True$  \n    \\end{definition}\n\n    \\begin{definition}[\\textbf{Disjunction}] \n      let $p$ and $q$ be prepositions .The Disjunction of $p$ and $q$ denoted by $p$ $\\vee$ $q$ is a preposition \"$p$ or $q$\" which is $False$ only if both of $p$ and $q$ are $False$\n\n    \\end{definition}\n    \\begin{definition}[\\textbf{Exclusive Disjunction}]\n      let $p$ and $q$ be prepositions .The esclusive or denoted by $p$ $\\oplus$ $q$ is a preposition that is $True$ if exactly one of $p$ or $q$ are $True$ , and $False$ otherwise\n    \\end{definition}\n\\section{Conditional Statements}\n\\begin{definition}\n  let $p$ and $q$ be prepositions . The Conditional Statements $p$ $\\rightarrow$ $q$ , \"if $p$ then $q$\" is false whenever p is $False$ or q is $True$\n\\end{definition}\nThe meaning of $p$ $\\rightarrow$ $q$ assert that $q$ is true whenever $p$ holds but not vise versa ,when $p$ is $False$ it does not matter what the value of $q$ for implication to be $True$ ,$p$ is called (hypothesis or antecedent or premise ) while $q$ is called conclusion or consequence .\n\\newline\n\\newline\n\\textbf{English Phrases to express conditional statements:}\n\\begin{multicols}{2}\n\\begin{itemize}\n  \\item \"if $p$, then $q$\"\n  \\item \"$p$ implies $q$\"\n  \\item \"$p$ is sufficient of $q$\"\n  \\item \"$p$ only if $q$\"\n  \\item \"$q$ is necessary for $p$\" \n  \\item \"$q$ unless $\\neg$ $p$\"  \\textbf{important}\n  \\item \"$p$ only if $q$\"\n  \\item \"$q$ whenever $p$ \"\n\\end{itemize}\n  \n\\end{multicols}\n$\\newline$ \n\\textbf{Converse, Contrapositive, and Inverse:}\nfor conditional statement $p$ $\\rightarrow$ $q$\n\\begin{itemize}\n  \\item $q$ $\\rightarrow$ $p$ called the converse .\n  \\item $\\neg q$ $\\rightarrow$ $\\neg p$ called the Contrapositive and has the same truth value as the original statement\n  \\item $\\neg p$ $\\rightarrow$ $\\neg q$ called the inverse \n\\end{itemize}\n\\begin{definition}\n  Let $p$ and $q$ be prepositions , the biconditional statement $p$ $\\leftrightarrow$ $q$ is a preposition \"$p$ if and only if $q$\" which is $True$ when $p$ and $q$ have the same truth values and $False$ otherwise \n\\end{definition}\n\\section{Precedence of Logical Operators}\n\\begin{tabular}{|c|c|c|}\n \\hline\n Logical Operator & Precedence \\\\\n \\hline\n $\\neg$ & 1\\\\\n \\hline\n $\\wedge$ & 2\\\\\n $\\vee$ & 3\\\\\n \\hline\n $\\rightarrow$ & 4\\\\\n $\\leftrightarrow $& 5\\\\\n \\hline\n\\end{tabular}\n\\section{Logical Equavilance}\ntwo preposition $p$, $q$ are said to be equavilant if $p\\leftrightarrow q$ is a $tautology$\n\\begin{itemize}\n  \\item $p\\rightarrow q \\equiv \\neg p \\vee q$\n  \\item $p\\leftrightarrow q \\equiv (p\\rightarrow q)\\wedge (q\\rightarrow p)$\n  \\item $p \\wedge T_{0} \\equiv p$ , $p \\vee F_{0} \\equiv p$ (identity law)\n  \\item $p \\wedge F_{0} \\equiv F_{0}$ , $p \\vee T_{0} \\equiv T_{0}$ (domination law)\n  \\item $p \\wedge p\\equiv p$ , $p \\vee p \\equiv p$ (idempotent (okay to apply many times))\n  \\item $\\neg (p \\wedge q) \\equiv \\neg p \\vee \\neg q$ , $\\neg (p \\vee q) \\equiv \\neg p \\wedge \\neg q$ (De morgans law)\n  \\item $ p \\wedge (p \\vee q) \\equiv p$ , $p \\vee (p \\wedge q)\\equiv p$ (apsorption law)\n\\end{itemize}\n\\end{document}", "meta": {"hexsha": "a7affe99c0259d619ea0639dc3290a680ab584a5", "size": 4858, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture1/lecture1.tex", "max_stars_repo_name": "GUC-Notes/discrete-math-", "max_stars_repo_head_hexsha": "f9917c08e9b9706427153a405b03907a26fab2c7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-10-14T03:38:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-01T20:13:25.000Z", "max_issues_repo_path": "Lecture1/lecture1.tex", "max_issues_repo_name": "GUC-Notes/discrete-math-", "max_issues_repo_head_hexsha": "f9917c08e9b9706427153a405b03907a26fab2c7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture1/lecture1.tex", "max_forks_repo_name": "GUC-Notes/discrete-math-", "max_forks_repo_head_hexsha": "f9917c08e9b9706427153a405b03907a26fab2c7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7657657658, "max_line_length": 291, "alphanum_fraction": 0.6807328119, "num_tokens": 1604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.4278424265224881}}
{"text": "\\documentclass[10pt]{article}\n\n% Manage page layout\n\\usepackage[margin=2.5cm, includefoot, footskip=30pt]{geometry}\n\\pagestyle{plain}\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{1em}\n\\renewcommand{\\baselinestretch}{1}\n\n%%%%%%%PACKAGES HERE%%%%%%%\n\\usepackage{tikz}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{mathtools}\n\\usepackage{amsthm}\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{standalone}\n\\usepackage{booktabs}\n\\usepackage{setspace}\n\\usepackage[algoruled,lined]{algorithm2e}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{wrapfig}\n\\usepackage{hyperref}\n\\usepackage{authblk}\n\\usepackage[toc,page]{appendix}\n\\usetikzlibrary{calc, shapes, patterns, decorations.pathreplacing}\n\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\newcommand{\\R}{\\mathbb{R}}\n\\newtheorem{theorem}{Theorem}\n\\usetikzlibrary{decorations.pathmorphing, decorations.pathreplacing, angles,\n                quotes, calc, er, positioning}\n\n\\newtheorem{lemma}[theorem]{Lemma}\n\\def\\arraystretch{1.5}\n\n\\title{Stability of defection, optimisation of strategies and the limits of\n       memory in the Prisoner's Dilemma.}\n\\author[1]{Nikoleta E. Glynatsi}\n\\author[1]{Vincent A. Knight}\n\n\\affil[1]{Cardiff University, School of Mathematics, Cardiff, United Kingdom}\n\\date{}\n\\setcounter{Maxaffil}{0}\n\\renewcommand\\Affilfont{\\itshape\\small}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n    Memory-one strategies are a set of Iterated Prisoner's Dilemma strategies\n    that have been praised for their mathematical tractability and performance\n    against single opponents. This manuscript investigates \\textit{best\n    response} memory-one strategies as a multidimensional\n    optimisation problem. Though extortionate memory-one strategies have gained\n    much attention, we demonstrate that best response memory-one strategies do not\n    behave in an extortionate way, and moreover, for memory one strategies to be\n    evolutionary robust they need to be able to behave in a forgiving way. We\n    also provide evidence that memory-one strategies suffer from their limited\n    memory in multi agent interactions and can be out performed by\n    longer memory strategies.\n\\end{abstract}\n\nThe Prisoner's Dilemma (PD) is a two player game used in understanding the\nevolution of cooperative behaviour, formally introduced in~\\cite{Flood1958}.\nEach player has two options, to cooperate (C) or to defect (D). The decisions\nare made simultaneously and independently. The normal form representation of the\ngame is given by:\n\n\\begin{equation}\\label{equ:pd_definition}\n    S_p =\n    \\begin{pmatrix}\n        R & S  \\\\\n        T & P\n    \\end{pmatrix}\n    \\quad\n    S_q =\n    \\begin{pmatrix}\n        R & T  \\\\\n        S & P\n    \\end{pmatrix}\n\\end{equation}\n\nwhere \\(S_p\\) represents the utilities of the row player and \\(S_q\\) the\nutilities of the column player. The payoffs, \\((R, P, S, T)\\), are constrained\nby \\(T > R > P > S\\) and \\(2R > T + S\\), and the most common values used in the\nliterature are \\((R, P, S, T) = (3, 1, 0, 5)\\)~\\cite{Axelrod1981}.\nThe PD is a one shot game, however, it is commonly studied in a manner where the\nhistory of the interactions matters. The repeated form of the game is called the\nIterated Prisoner's Dilemma (IPD).\n\nMemory-one strategies are a set of IPD strategies that have been\nstudied thoroughly in the literature~\\cite{Nowak1990, Nowak1993}, however, they have gained\nmost of their attention when a certain subset of memory-one strategies was\nintroduced in~\\cite{Press2012}, the zero-determinant strategies (ZDs). In~\\cite{Stewart2012} it\nwas stated that ``Press and Dyson have fundamentally changed the viewpoint on\nthe Prisoner's Dilemma''.\nA special case of ZDs are extortionate strategies that choose their actions so that a linear relationship is forced\nbetween the players' score ensuring that they will always\nreceive at least as much as their opponents. ZDs are\nindeed mathematically unique and are proven to be robust in pairwise\ninteractions, however, their true effectiveness in tournaments and\nevolutionary dynamics has been questioned~\\cite{adami2013, Hilbe2013b,\nHilbe2013, Hilbe2015, Knight2018, Harper2015}.\n\nIn a similar fashion to~\\cite{Press2012} the purpose of this work is to consider\na given memory-one strategy; however, whilst~\\cite{Press2012} found a way for a\nplayer to manipulate a given opponent, this work will consider a\nmultidimensional optimisation approach to identify the best response to a given\ngroup of opponents. The outcomes of our work reinforce known results, namely\nthat memory-one strategies must be forgiving to be evolutionarily stable~\\cite{Stewart2013, Stewart2016}\nand that longer-memory strategies have a certain form of advantage over short memory\nstrategies~\\cite{Hilbe2017, Pan2015}.\n\n\nIn particular, this work presents a compact method of\nidentifying the best response memory-one strategy against a given set of\nopponents, and evaluates whether it behaves in a\nzero-determinant way which in turn indicates whether it can be extortionate. This is also done in evolutionary settings. Moreover, we\nintroduce a well designed framework that allows the comparison of an optimal\nmemory one strategy and a more complex strategy which has a larger memory. This\nis used to identify conditions for which defection is stable; thus identifying\nenvironments where cooperation will not occur.\n\n\\section{Methods and Results}\n\\subsection{Utility}\n\nOne specific advantage of memory-one strategies is their mathematical\ntractability. They can be represented completely as an element of \\(\\R^{4}_{[0, 1]}\\). This\noriginates from~\\cite{Nowak1989} where it is stated that if a strategy is\nconcerned with only the outcome of a single turn then there are four possible\n`states' the strategy could be in; both players cooperated (\\(CC\\)), \nthe first player cooperated whilst the second player defected (\\(CD\\)),\nthe first player defected whilst the second player cooperated (\\(DC\\)) and\nboth players defected (\\(DD\\)).\nTherefore, a memory-one strategy can be denoted by the probability vector of\ncooperating after each of these states; \\(p=(p_1, p_2, p_3, p_4) \\in \\R_{[0,1]}\n^ 4\\).\n\nIn~\\cite{Nowak1989} it was shown that it is not necessary to simulate the play\nof a strategy $p$ against a memory-one opponent $q$. Rather this exact behaviour\ncan be modeled as a stochastic process, and more specifically as a Markov chain\nwhose corresponding transition matrix \\(M\\) is\ngiven by Eq.~\\ref{eq:transition_matrix}. The long run steady state probability\nvector \\(v\\), which is the solution to \\(v M = v\\), can be\ncombined with the payoff matrices of Eq.~\\ref{equ:pd_definition} to give the expected\npayoffs for each player. More specifically, the utility for a memory-one\nstrategy \\(p\\) against an opponent \\(q\\), denoted as \\(u_q(p)\\), is given by\nEq.~\\ref{eq:press_dyson_utility}.\n\n\\begin{equation}\\label{eq:transition_matrix}\n    \\resizebox{.5\\hsize}{!}{$\\input{tex/m_matrix.tex}$}\n\\end{equation}\n\n\n\\begin{equation}\\label{eq:press_dyson_utility}\n    u_q(p) = v \\cdot (R, S, T, P).\n\\end{equation}\n\nThis manuscript has explored the form of \\(u_q(p)\\), to the authors knowledge no\nprevious work has done this, and it proves that \\(u_q(p)\\) is given by a ratio\nof two quadratic forms~\\cite{kepner2011},\n(Theorem~\\ref{theorem_one}):\n\n\\begin{equation}\\label{eq:optimisation_quadratic}\n       u_q(p) = \\frac{\\frac{1}{2}pQp^T + cp + a}\n                   {\\frac{1}{2}p\\bar{Q}p^T + \\bar{c}p + \\bar{a}},\n\\end{equation}\n\nwhere \\(Q=Q(q), \\bar{Q}=\\bar{Q}(q)\\) \\(\\in \\R^{4\\times4}\\), \\(c=c(q) \\text{ and } \\bar{c}=\\bar{c}(q)\\)\n\\(\\in \\R^{4 \\times 1}\\), \\(a=a(q) \\text{ and } \\bar{a}=\\bar{a}(q) \\in \\R.\\)\n\nThis can be extended to consider multiple\nopponents. The IPD is commonly studied in tournaments and/or Moran Processes\nwhere a strategy interacts with a number of opponents. The payoff of a player in\nsuch interactions is given by the average payoff the player received against\neach opponent. More specifically the expected utility of a memory-one strategy\nagainst a \\(N\\) number of opponents is given by:\n\n\\begin{align}\\label{eq:tournament_utility}\n       & \\frac{1}{N} \\sum\\limits_{i=1} ^ {N} {u_q}^{(i)} (p) = \n       \\frac{\\frac{1}{N} \\sum\\limits_{i=1} ^ {N} (\\frac{1}{2} pQ^{(i)} p^T + c^{(i)} p + a^ {(i)})\n       \\prod\\limits_{\\tiny\\begin{array}{l} j=1 \\\\ j \\neq i \\end{array}} ^\n       N (\\frac{1}{2} p\\bar{Q}^{(j)} p^T + \\bar{c}^{(j)} p + \\bar{a}^ {(j)})}\n       {\\prod\\limits_{i=1} ^ N (\\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)})}.\n\\end{align}\n\nEstimating the utility of a memory-one strategy against any number of opponents\nwithout simulating the interactions is the main result used in the rest of this manuscript.\nIt will be used to obtain best response memory-one strategies, in tournaments\nand evolutionary dynamics, and to explore the conditions under which defection\ndominates cooperation.\n\n\\subsection{Stability of defection}\\label{subsection:stability_defection}\n\nAn immediate result from our formulation can be\nobtained by evaluating the sign of Eq. \\ref{eq:tournament_utility}'s derivative\nat \\(p=(0, 0, 0, 0)\\). If at that point the\nderivative is negative, then the utility of a player only decreases if they were\nto change their behaviour, and thus \\textbf{defection at that point is stable}.\n\n\\begin{lemma}\\label{lemma:stability_of_defection}\n    In a tournament of \\(N\\) players \\(\\{q^{(1)}, q^{(2)}, \\dots, q^{(N)} \\}\\)\n    for \\(q^{(i)} \\in \\R_{[0, 1]} ^ 4\\)\n    defection is stable if the transition probabilities of the\n    opponents satisfy conditions Eq. \\ref{eq:defection_condition_one} and Eq. \\ref{eq:defection_condition_two}.\n\n    \\begin{equation}\\label{eq:defection_condition_one}\n        \\sum_{i=1} ^ N (c^{(i)T} \\bar{a}^{(i)} - \\bar{c}^{(i)T} a^{(i)}) \\leq 0\n    \\end{equation}\n\n    while,\n\n    \\begin{equation}\\label{eq:defection_condition_two}\n        \\sum_{i=1} ^ N \\bar{a}^{(i)} \\neq 0\n    \\end{equation}\n\\end{lemma}\n\n\\begin{proof}\n    For defection to be stable the derivative of the utility\n    at the point \\(p = (0, 0, 0, 0)\\) must be negative.\n\n    Substituting \\(p = (0, 0, 0, 0)\\) in\n    Eq. \\ref{eq:mo_tournament_derivative} gives:\n\n    \\begin{equation}\n        \\left.\\frac{d\\sum\\limits_{i=1} ^ {N} {u_q}^{(i)} (p)}{dp} \\right\\rvert_{p=(0,0,0,0)} =\n    \\sum_{i=1} ^ N \\frac{(c^{(i)T} \\bar{a}^{(i)} - \\bar{c}^{(i)T} a^{(i)})}\n    {(\\bar{a}^{(i)})^2}\n    \\end{equation}\n\n    The sign of the numerator \\( \\displaystyle\\sum_{i=1} ^ N (c^{(i)T} \\bar{a}^{(i)} - \\bar{c}^{(i)T} a^{(i)})\\)\n    can vary based on the transition probabilities of the opponents.\n    The denominator can not be negative, and otherwise is always positive.\n    Thus the sign of the derivative is negative if and only if\n    \\( \\displaystyle\\sum_{i=1} ^ N (c^{(i)T} \\bar{a}^{(i)} - \\bar{c}^{(i)T} a^{(i)}) \\leq 0\\).\n\\end{proof}\n\nConsider a population for which defection is known to be stable. In that\npopulation all the members will over time adopt the same behaviour; thus in such\npopulation cooperation will never take over. This is demonstrated in\nFig.~\\ref{fig:stability_of_defection}.\nThese have been simulated using~\\cite{axelrodproject} an open\nsource research framework for the study of the IPD.\n\n\\begin{figure}[!htbp]\n    \\centering\n    \\includegraphics[width=.4\\linewidth]{img/stability_of_defection_plots.pdf}\n    \\caption{A. For \\(q_{1}=(0.22199, 0.87073, 0.20672, 0.91861)\\),\n    $q_{2}=(0.48841, 0.61174, 0.76591, 0.51842)$ and\n    $q_{3}=(0.2968, 0.18772, 0.08074, 0.73844)$, Eq.~\\ref{eq:defection_condition_one} and\n    Eq.~\\ref{eq:defection_condition_two} hold and Defector takes over the\n    population. B. For $q_{1}=(0.96703, 0.54723, 0.97268, 0.71482)$,\n    $q_{2}=(0.69773, 0.21609, 0.97627, 0.0062)$ and\n    $q_{3}=(0.25298, 0.43479, 0.77938, 0.19769)$, Eq.~\\ref{eq:defection_condition_one} fails\n    and Defector does not take over the population.}\\label{fig:stability_of_defection}\n\\end{figure}\n\n\\subsection{Best response memory-one strategies}\\label{section:best_response_memory_one}\n\nAs discussed ZDs have been acclaimed for their robustness\nagainst a single opponent. ZDs are evidence that extortion works\nin pairwise interactions, their behaviour ensures that the strategies will never\nlose a game. However, this paper argues that in multi opponent interactions,\nwhere the payoffs matter, strategies trying to exploit their opponents will\nsuffer.\nCompared to ZDs, best response memory-one strategies, which have a\ntheory of mind of their opponents, utilise their behaviour in order to gain the\nmost from their interactions. The question that arises then is whether best\nresponse strategies are optimal because they behave in an extortionate way.\n\nTo answer this question, we initially define \\textit{memory-one best response}\nstrategies as a multi dimensional optimisation problem given by:\n\n\\begin{equation}\\label{eq:mo_tournament_optimisation}\n    \\begin{aligned}\n    \\max_p: & \\ \\sum_{i=1} ^ {N} {u_q}^{(i)} (p)\n    \\\\\n    \\text{such that}: & \\ p \\in \\R_{[0, 1]}\n    \\end{aligned}\n\\end{equation}\n\nOptimising this particular ratio of quadratic forms is not trivial. It can be\nverified empirically for the case of a single opponent that there exists at\nleast one point for which the definition of concavity does not hold.\nThe non concavity of \\(u(p)\\) indicates multiple local\noptimal points. This is also intuitive. The best response against a cooperator,\n\\(q=(1, 1, 1, 1)\\), is a defector \\(p^*=(0, 0, 0, 0)\\). The strategies\n\\(p=(\\frac{1}{2}, 0, 0, 0)\\) and \\(p=(\\frac{1}{2}, 0, 0, \\frac{1}{2})\\) are also\nbest responses. The approach taken here is to introduce a compact way of\nconstructing the discrete candidate set of all local optimal points, and evaluating\nthe objective function Eq.~\\ref{eq:tournament_utility}. This gives the best\nresponse memory-one strategy. The approach is given in\nTheorem~\\ref{memone_group_best_response}.\n\nFinding best response memory-one strategies is analytically feasible using the\nformulation of Theorem~\\ref{memone_group_best_response} and resultant\ntheory~\\cite{Jonsson2005}. However, for large systems building the resultant\nbecomes intractable. As a result, best responses will be estimated\nheuristically using a numerical method, suitable for problems with local optima,\ncalled Bayesian optimisation~\\cite{Mokus1978}.\n\nThis is extended to evolutionary settings. In these settings\nself interactions are key. Self interactions can be incorporated in the\nformulation that has been used so far. More specifically, the optimisation\nproblem of Eq.~\\ref{eq:mo_tournament_optimisation} is extended to include self\ninteractions:\n\n\\begin{equation}\\label{eq:mo_evolutionary_optimisation}\n\\begin{aligned}\n\\max_p: & \\ \\frac{1}{N} \\sum\\limits_{i=1} ^ {N} {u_q}^{(i)} (p) + u_p(p)\n\\\\\n\\text{such that}: & \\ p \\in \\R_{[0, 1]}\n\\end{aligned}\n\\end{equation}\n\nFor determining the memory-one best response in an evolutionary setting, an\nalgorithmic approach is considered, called \\textit{best response dynamics}. The\nbest response dynamics approach used in this manuscript is given by\nAlgorithm~\\ref{algo:best_response_dynamics}.\n\n\\begin{center}\n\\begin{minipage}{.55\\textwidth}\n\\begin{algorithm}[H]\n       $p^{(t)}\\leftarrow (1, 1, 1, 1)$\\;\n       \\While{$p^{(t)} \\neq p ^{(t -1)}$}{\n       $p^{(t + 1)} =  \\text{argmax} \\frac{1}{N} \\sum\\limits_{i=1} ^ {N} {u_q}^{(i)}\n       (p^{(t + 1)}) + u_p^{(t)}(p^{(t + 1)})$\\;\n       }\n       \\caption{Best response dynamics Algorithm}\n       \\label{algo:best_response_dynamics}\n\\end{algorithm}\n\\end{minipage}\n\\end{center}\n\nThe results of this section use Bayesian optimisation to generate a data set of best response\nmemory-one strategies, in tournaments and evolutionary dynamics whilst \\(N=2\\).\nThe data set is available at~\\cite{glynatsi2019}. It contains a total of 1000 trials\ncorresponding to 1000 different instances of a best response strategy in\ntournaments and evolutionary dynamics. For each trial a set of 2 opponents is\nrandomly generated and the memory-one best responses against them is found.\n\nThe source code for the experiments presented in this manuscript has been written in a sustainable manner~\\cite{Benureau2018}.\nIt is open source (\\url{https://github.com/Nikoleta-v3/Memory-size-in-the-prisoners-dilemma})\nand tested which ensures the validity of the results. It has also been archived\nand can be found at~\\cite{nikoleta_glynatsi_2019}.\n\nIn order to investigate whether best responses\nbehave in an extortionate matter the SSE method~\\cite{Knight2019} is used.\nIn~\\cite{Knight2019} it is proven that\nall extortionate ZDs reside on a triangular plane. For a given \\(p\\), a strategy\n\\(x^*\\) is defined as the nearest ZDs. The distance between\nthe two strategies is explicitly calculated and referred to as the sum of squared\nerrors of prediction (SSE); which corresponds to how far \\(p\\) is from behaving as a ZDs.\nThus, a high SSE implies non ZD, which in turn implies a non extortionate behaviour.\nThe SSE method has been applied to the data set.\nA statistics summary\nof the SSE distribution for the best response in tournaments and evolutionary dynamics is\ngiven in Table~\\ref{table:sserror_stats}.\n\nFor the best response in tournaments the distribution of SSE is skewed to the\nleft, indicating that the best response does exhibit ZDs behaviour and so could\nbe extortionate,\nhowever, the best response is not uniformly a ZDs. A positive measure of\nskewness and kurtosis indicates a heavy tail to the right. Therefore, in several\ncases the strategy is not trying to extort its opponents. Similarly the\nevolutionary best response strategy does not behave uniformly extortionately. A\nlarger value of both the kurtosis and the skewness of the SSE distribution\nindicates that in evolutionary settings a memory-one best response is even more\nadaptable.\n\nThe difference between best responses in tournaments and in evolutionary\nsettings is further explored by Fig.~\\ref{fig:behaviour_violin_plots}.\nThough, no statistically significant differences have been found, from\nFig.~\\ref{fig:behaviour_violin_plots}, it seems that evolutionary best\nresponse has a higher median $p_2$; which corresponds to the probability of cooperating\nafter receiving a defection. Thus, they are more likely to forgive after\nbeing tricked. This is due to the fact that they could be playing against\nthemselves, and they need to be able to forgive so that future cooperation can\noccur.\n\n\\begin{table}\n\\begin{center}\n\\resizebox{.6\\columnwidth}{!}{%\n\\begin{tabular}{lrrrrrrrrrrr}\n    \\toprule\n    & mean & std  & 5\\% & 50\\% &  95\\% & max & median & skew & kurt\\\\\n    \\midrule\n\\textbf{Tournament} & 0.34  & 0.40  & 0.028  & 0.17  &\n1.05  & 2.47  & 0.17  & 1.87 & 3.60 \\\\\n\\textbf{Evolutionary Setting} & 0.17 & 0.23 & 0.01 &\n0.12 & 0.67 & 1.53 & 0.12 & 3.42 & 1.92 \\\\\n    \\bottomrule\n\\end{tabular}}\n\\end{center}\n\\caption{SSE of best response memory-one when \\(N=2\\)}\\label{table:sserror_stats}\n\\end{table}\n\n\\begin{figure}[!htbp]\n    \\centering\n    \\includegraphics[width=.55\\textwidth]{img/behaviour_violin_plots.pdf}\n    \\caption{Distributions of \\(p^*\\) for best responses in tournaments and\n    evolutionary settings. The medians, denoted as \\(\\bar{p}^*\\), for tournaments\n    are \\(\\bar{p}^* = (0, 0, 0, 0)\\), and for evolutionary settings\n    \\(\\bar{p}^* = (0, 0.19, 0, 0)\\).}\n    \\label{fig:behaviour_violin_plots}\n\\end{figure}\n\n\\subsection{Longer memory best responses}\n\nThis section focuses on the memory size of strategies. The effectiveness of\nmemory in the IPD has been previously explored in the literature, however, no one\nhas compared the performance of longer-memory\nstrategies to memory-one best responses.\n\nIn~\\cite{Harper2017}, a strategy called \\textit{Gambler} which makes\nprobabilistic decisions based on the opponent's \\(n_1\\) first moves, the\nopponent's \\(m_1\\) last moves and the player's \\(m_2\\) last moves was\nintroduced. In this manuscript Gambler with parameters: $n_1 = 2, m_1 = 1$ and $m_2 = 1$ is used\nas a longer-memory strategy.\nBy considering the opponent's first two moves, the opponents last move and the\nplayer's last move, there are only 16 $(4 \\times 2 \\times 2)$ possible outcomes\nthat can occur, furthermore, Gambler also makes a probabilistic decision of\ncooperating in the opening move. Thus, Gambler is a function \\(f: \\{\\text{C,\nD}\\} \\rightarrow [0, 1]_{\\R}\\). This can be hard coded as an element\nof \\([0, 1]_{\\R} ^ {16 + 1}\\), one probability for each outcome plus the opening\nmove. Hence, compared to Eq.~\\ref{eq:mo_tournament_optimisation}, finding an\noptimal Gambler is a 17 dimensional problem given by:\n\n\\begin{equation}\\label{eq:gambler_optimisation}\n    \\begin{aligned}\n    \\max_p: & \\ \\sum_{i=1} ^ {N} {U_q}^{(i)} (f)\n    \\\\\n    \\text{such that}: & \\ f \\in \\R_{[0, 1]}^{17}\n    \\end{aligned}\n\\end{equation}\n\nNote that Eq. \\ref{eq:tournament_utility} can not be used here for the utility\nof Gambler, and actual simulated players are used. This is done using~\\cite{axelrodproject}\nwith 500 turns and 200 repetitions, moreover, Eq. \\ref{eq:gambler_optimisation}\nis solved numerically using Bayesian optimisation.\n\nSimilarly to previous sections, a large data set has been generated with\ninstances of an optimal Gambler and a memory-one best response, available\nat~\\cite{glynatsi2019}. Estimating a best response Gambler (17 dimensions) is\ncomputational more expensive compared to a best response memory-one (4\ndimensions). As a result, the analysis of this section is based on a total of\n152 trials. For each trial two random opponents have been selected. The 152 pair\nof opponents are a sub set of the opponents used in section~\\ref{section:best_response_memory_one}.\n\nThe ratio between Gambler's utility and the best response memory-one strategy's utility has been calculated and its distribution in\ngiven in Fig.~\\ref{fig:utilities_gambler_mem_one}.\nIt is evident from Fig.~\\ref{fig:utilities_gambler_mem_one} that\nGambler always performs as well as the best response memory-one strategy and often performs better. There are\nno points where the ratio value is less than 1, thus Gambler never performed less\nthan the best response memory-one strategy and in places outperforms it. This seems to be at odd with the\nresult of~\\cite{Press2012} that against a memory-one opponent having a longer memory\nwill not give a strategy any\nadvantage. However, against two memory-one opponents Gambler's performance is better than\nthe optimal memory-one strategy. This is evidence that in the case of two opponents having a\nshorter memory is limiting.\n\n\\begin{figure}[!htbp]\n    \\centering\n    \\includegraphics[width=.5\\textwidth]{img/gambler_performance_against_mem_one.pdf}\n    \\caption{The ratio between the utilities of Gambler and best response memory-one\n    strategy for 152 different pair of opponents.}\\label{fig:utilities_gambler_mem_one}\n\\end{figure}\n\n\\section{Discussion}\nThis manuscript has considered \\textit{best response} strategies in the IPD game, and\nmore specifically, \\textit{memory-one best responses}. It has proven that there is\na compact way of identifying a memory-one best response to a group of opponents,\nand moreover it obtained a condition for which in an\nenvironment of memory-one opponents defection is the stable choice, based only\non the coefficients of the opponents.\nThe later parts of this paper focused on a series of empirical results, where it\nwas shown that the performance and the evolutionary stability of memory-one\nstrategies rely on adaptability and not on extortion. Finally, it was shown that\nmemory-one strategies' performance is limited by their memory in cases where\nthey interact with multiple opponents.\n\nFollowing the work described in~\\cite{Nowak1989}, where it was shown that the\nutility between two memory-one strategies can be estimated by a Markov\nstationary state, we proved that the utilities can be written as a ration of two\nquadratic forms in $R^4$, Theorem~\\ref{theorem_one}. This was extended to\ninclude multiple opponents, as the IPD is commonly studied in such situations.\nThis formulation allowed us to introduce an approach for identifying memory-one\nbest responses to any number of opponents;\nTheorem~\\ref{memone_group_best_response}. This does not only have game theoretic\nnovelty, but also a mathematical novelty of solving quadratic ratio optimisation\nproblems where the quadratics are non concave. The results were used to\ndefine a condition for which defection is known to be stable.\n\nThis manuscript presented several experimental results. All data for the results\nis archived in~\\cite{glynatsi2019}. These results were mainly to investigate the\nbehaviour of memory-one strategies and their limitations. A large data set which\ncontained best responses in tournaments and in evolutionary settings for $N=2$\nwas generated. This allowed us to investigate their respective behaviours, and\nwhether it was extortionate acts that made them the most favorable strategies.\nHowever, it was shown that it was not extortion but adaptability that allowed\nthe strategies to gain the most from their interactions. In evolutionary settings\nit was shown that the best response strategy was even more adaptable, and there\nis some evidence that it is more likely to forgive after being tricked.\nMoreover, the performance of\nmemory-one strategies was put against the performance of a longer memory\nstrategy called Gambler. There were several cases where Gambler would outperform\nthe memory-one strategy, however, a memory-one strategy never managed to\noutperform a Gambler. This result occurred whilst considering a Gambler with a\nsufficiently larger memory but not a sufficiently larger amount of information\nregarding the game.\n\nAll the empirical results presented in this manuscript have been for the case of\n$N=2$. In future work we would consider larger values of $N$, however, we\nbelieve that for larger values of $N$ the results that have been presented here\nwould only be more evident. In addition, we would investigate potential\ntheoretical results for the evolutionary best responses dynamics algorithm\ndiscussed.\n\nBy specifically exploring the entire memory space-one strategies to identify\nthe optimal strategy for a variety of situations, this work casts doubt\non the effectiveness of ZDs, highlights the importance of adaptability and provides\na framework for the continued understanding of these important questions.\n\n\\section{Acknowledgements}\n\nA variety of software libraries have been used in this work:\n\n\\begin{itemize}\n    \\item The Axelrod library for IPD simulations~\\cite{axelrodproject}.\n    \\item The Scikit-optimize library for an implementation of Bayesian optimisation~\\cite{tim_head_2018_1207017}.\n    \\item The Matplotlib library for visualisation~\\cite{hunter2007matplotlib}.\n    \\item The SymPy library for symbolic mathematics~\\cite{sympy}.\n    \\item The Numpy library for data manipulation~\\cite{walt2011numpy}.\n\\end{itemize}\n\n% Bibliography\n\\bibliographystyle{plain}\n\\bibliography{bibliography.bib}\n\n\\section{Appendix}\n\n\\subsection{Theorem~\\ref{theorem_one}}\n\\begin{theorem}\\label{theorem_one}\n\n    The expected utility of a memory-one strategy \\(p\\in\\mathbb{R}_{[0,1]}^4\\)\n    against a memory-one opponent \\(q\\in\\mathbb{R}_{[0,1]}^4\\), denoted\n    as \\(u_q(p)\\), can be written as a ratio of two quadratic forms:\n\n    \\begin{equation}\\label{eq:optimisation_quadratic}\n    u_q(p) = \\frac{\\frac{1}{2}pQp^T + cp + a}\n                {\\frac{1}{2}p\\bar{Q}p^T + \\bar{c}p + \\bar{a}},\n    \\end{equation}\n    where \\(Q, \\bar{Q}\\) \\(\\in \\R^{4\\times4}\\) are square matrices defined by the\n    transition probabilities of the opponent \\(q_1, q_2, q_3, q_4\\) as follows:\n\n    \\begin{center}\n    \\begin{equation}\n    \\resizebox{.65\\linewidth}{!}{\\arraycolsep=2.5pt%\n    \\boldmath\\(\n    Q = \\input{tex/q_numerator}\\)},\n    \\end{equation}\n    \\begin{equation}\\label{eq:q_bar_matrix}\n    \\resizebox{.65\\linewidth}{!}{\\arraycolsep=2.5pt%\n    \\boldmath\\(\n    \\bar{Q} =  \\input{tex/q_denominator}\\)}.\n    \\end{equation}\n    \\end{center}\n\n    \\(c \\text{ and } \\bar{c}\\) \\(\\in \\R^{4 \\times 1}\\) are similarly defined by:\n\n    \\begin{equation}\\label{eq:q_matrix_numerator}\n    \\resizebox{0.25\\linewidth}{!}{\\arraycolsep=2.5pt%\n    \\boldmath\\(c = \\input{tex/c_numerator}\\),}\n    \\end{equation}\n    \\begin{equation}\\label{eq:q_matrix_denominator}\n    \\resizebox{0.25\\linewidth}{!}{\\arraycolsep=2.5pt%\n    \\boldmath\\(\\bar{c} = \\input{tex/c_denominator}\\),\n    }\n    \\end{equation}\n    and the constant terms \\(a, \\bar{a}\\) are defined as \\(a = \\input{tex/numerator_constant}\\) and\n    \\(\\bar{a} = \\input{tex/denominator_constant}\\).\n\\end{theorem}\n\n\\begin{proof}\n\n    It was discussed that \\(u_q(p)\\) it is the product of the steady states \\(v\\) and\n    the PD payoffs,\n    \n    \\[u_q(p) = v \\cdot (R, S, T, P).\\]\n    \n    More specifically, with \\((R, P, S, T) = (3, 1, 0, 5)\\)\n    \n    \\begingroup\n    \\footnotesize\n    \\begin{equation}\n        u_q(p) =\n        \\left(\n          \\frac\n            {\\parbox{6in}{$\n                p_{1} p_{2} (q_{1} q_{2} - 5 q_{1} q_{4} - q_{1} - q_{2} q_{3} + 5 q_{3} q_{4} + q_{3}) + p_{1} p_{3} (- q_{1} q_{3} + q_{2} q_{3}) + p_{1} p_{4} (5 q_{1} q_{3} - 5 q_{3} q_{4}) + p_{3} p_{4} (- 3 q_{2} q_{3} + 3 q_{3} q_{4}) +$ \\\\\n                \\hspace*{1cm} $ p_{2} p_{3} (- q_{1} q_{2} + q_{1} q_{3} + 3 q_{2} q_{4} + q_{2} - 3 q_{3} q_{4} - q_{3}) + p_{2} p_{4} (- 5 q_{1} q_{3} + 5 q_{1} q_{4} + 3 q_{2} q_{3} - 3 q_{2} q_{4} + 2 q_{3} - 2 q_{4}) + $ \\\\\n                \\hspace*{1cm} $ p_{1} (- q_{1} q_{2} + 5 q_{1} q_{4} + q_{1}) + p_{2} (q_{2} q_{3} - q_{2} - 5 q_{3} q_{4} - q_{3} + 5 q_{4} + 1) + p_{3} (q_{1} q_{2} - q_{2} q_{3} - 3 q_{2} q_{4} - q_{2} + q_{3}) +$ \\\\\n                \\hspace*{4cm} $ p_{4} (- 5 q_{1} q_{4} + 3 q_{2} q_{4} + 5 q_{3} q_{4} - 5 q_{3} + 2 q_{4}) + q_{2} - 5 q_{4} - 1$\n            }}\n            {\\parbox{6in}{$\n            p_{1} p_{2} (q_{1} q_{2} - q_{1} q_{4} - q_{1} - q_{2} q_{3} + q_{3} q_{4} + q_{3}) + p_{1} p_{3} (- q_{1} q_{3} + q_{1} q_{4} + q_{2} q_{3} - q_{2} q_{4}) + p_{1} p_{4} (- q_{1} q_{2} + q_{1} q_{3} + q_{1} + q_{2} q_{4} - q_{3} q_{4} - q_{4}) +$ \\\\\n            $ p_{2} p_{3} (- q_{1} q_{2} + q_{1} q_{3} + q_{2} q_{4} + q_{2} - q_{3} q_{4} - q_{3}) + p_{2} p_{4} (- q_{1} q_{3} + q_{1} q_{4} + q_{2} q_{3} - q_{2} q_{4}) + p_{3} p_{4} (q_{1} q_{2} - q_{1} q_{4} - q_{2} q_{3} - q_{2} + q_{3} q_{4} + q_{4}) + $ \\\\\n            $ p_{1} (- q_{1} q_{2} + q_{1} q_{4} + q_{1}) + p_{2} (q_{2} q_{3} - q_{2} - q_{3} q_{4} - q_{3} + q_{4} + 1) + p_{3} (q_{1} q_{2} - q_{2} q_{3} - q_{2} + q_{3} - q_{4}) + p_{4} (- q_{1} q_{4} + q_{2} + q_{3} q_{4} - q_{3} + q_{4} - 1) + $ \\\\\n            \\hspace*{7cm} $q_{2} - q_{4} - 1$\n          }}\n        \\right).\n    \\end{equation}\n    \\endgroup\n    \n    Let us consider the numerator of \\(u_q(p)\\). The cross product terms \\(p_ip_j\\)\n    are given by,\n    \n    \\begingroup\n    \\footnotesize\n    \\begin{align*}\n    p_{1} p_{2} (q_{1} q_{2} - 5 q_{1} q_{4} - q_{1} - q_{2} q_{3} + 5 q_{3} q_{4}\n    + q_{3}) + p_{1} p_{3} (- q_{1} q_{3} + q_{2} q_{3}) + p_{1} p_{4} (5 q_{1} q_{3} -\n    5 q_{3} q_{4}) + p_{3} p_{4} (- 3 q_{2} q_{3} + 3 q_{3} q_{4}) +  \\\\\n    p_{2} p_{3} (- q_{1} q_{2} + q_{1} q_{3} + 3 q_{2} q_{4} + q_{2} - 3 q_{3} q_{4} - q_{3}) +\n    p_{2} p_{4} (- 5 q_{1} q_{3} + 5 q_{1} q_{4} + 3 q_{2} q_{3} - 3 q_{2} q_{4} +\n    2 q_{3} - 2 q_{4}).\n    \\end{align*}\n    \\endgroup\n    \n    This can be re written in a matrix format given by Eq.~\\ref{eq:cross_product_coeffs}.\n    \n    \\begin{equation}\\label{eq:cross_product_coeffs}\n        \\resizebox{0.8\\linewidth}{!}{\\arraycolsep=2.5pt%\n        \\boldmath\\( \n        (p_1, p_2, p_3, p_4) \\frac{1}{2} \\input{tex/q_numerator} \\begin{pmatrix} \n        p_1 \\\\\n        p_2 \\\\\n        p_3 \\\\\n        p_4 \\end{pmatrix}\n        \\) }\n    \\end{equation}\n    \n    Similarly, the linear terms are given by,\n    \n    \\begingroup\n    \\footnotesize\n    \\begin{align*}\n    p_{1} (- q_{1} q_{2} + 5 q_{1} q_{4} + q_{1}) + p_{2} (q_{2} q_{3} - q_{2} - 5 q_{3} q_{4} - q_{3} + 5 q_{4} + 1) + p_{3} (q_{1} q_{2} - q_{2} q_{3} - 3 q_{2} q_{4} - q_{2} + q_{3}) + \\\\\n    p_{4} (- 5 q_{1} q_{4} + 3 q_{2} q_{4} + 5 q_{3} q_{4} - 5 q_{3} + 2 q_{4}).\n    \\end{align*}\n    \\endgroup\n    \n    and the expression can be written using a matrix format as Eq.~\\ref{eq:linear_coeffs}.\n    \n    \\begin{equation}\\label{eq:linear_coeffs}\n        \\resizebox{0.38\\linewidth}{!}{\\arraycolsep=2.5pt%\n        \\boldmath\\(\n        (p_1, p_2, p_3, p_4) \\input{tex/c_numerator}\\)}\n    \\end{equation}\n    \n    Finally, the constant term of the numerator, which is obtained by substituting\n    $p=(0, 0, 0, 0)$, is given by Eq.~\\ref{eq:constant}.\n    \n    \\begin{equation}\\label{eq:constant}\n    q_{2} - 5 q_{4} - 1\n    \\end{equation}\n    \n    Combining Eq.~\\ref{eq:cross_product_coeffs}, Eq.~\\ref{eq:linear_coeffs} and Eq.~\\ref{eq:constant}\n    gives that the numerator of \\(u_q(p)\\) can be written as,\n    \n    \\begingroup\n    \\tiny\\boldmath\n    \\begin{align*}\n        \\frac{1}{2}p & \\input{tex/q_numerator} p^T +  \\\\\n        & \\input{tex/q_numerator} p + q_{2} - 5 q_{4} - 1\n    \\end{align*}\n    \\endgroup\n    \n    and equivalently as,\n    \n    \\[\\frac{1}{2}pQp^T + cp + a\\]\n    \n    where \\(Q\\) \\(\\in \\R^{4\\times4}\\) is a square matrix defined by the\n    transition probabilities of the opponent \\(q_1, q_2, q_3, q_4\\) as follows:\n    \n    \\begin{equation*}\n        \\resizebox{0.7\\linewidth}{!}{\\arraycolsep=2.5pt%\n        \\boldmath\\(\n        Q = \\input{tex/q_numerator}\\)},\n    \\end{equation*}\n    \n    \\(c\\) \\(\\in \\R^{4 \\times 1}\\) is similarly defined by:\n    \n    \\begin{equation*}\n        \\resizebox{0.3\\linewidth}{!}{\\arraycolsep=2.5pt%\n        \\boldmath\\(c = \\input{tex/c_numerator}\\),}\n    \\end{equation*}\n    \n    and \\(a = \\input{tex/numerator_constant}\\).\n    \n    The same process is done for the denominator.\n\\end{proof}\n\n\\subsection{Theorem~\\ref{memone_group_best_response}}\n\\begin{theorem}\\label{memone_group_best_response}\n\nThe optimal behaviour of a memory-one strategy player\n\\(p^* \\in \\R_{[0, 1]} ^ 4\\)\nagainst a set of \\(N\\) opponents \\(\\{q^{(1)}, q^{(2)}, \\dots, q^{(N)} \\}\\)\nfor \\(q^{(i)} \\in \\R_{[0, 1]} ^ 4\\) is given by:\n\n\\[p^* = \\textnormal{argmax}\\sum\\limits_{i=1} ^ N  u_q(p), \\ p \\in S_q.\\]\n\nThe set \\(S_q\\) is defined as all the possible combinations of:\n\n{\\scriptsize\n\\begin{equation}\\label{eq:s_q_set}\n    S_q =\n    \\left\\{p \\in \\mathbb{R} ^ 4 \\left|\n        \\begin{aligned}\n            \\bullet\\quad p_j \\in \\{0, 1\\} & \\quad \\text{and} \\quad \\frac{d}{dp_k} \n            \\sum\\limits_{i=1} ^ N  u_q^{(i)}(p) = 0 \\\\\n            & \\quad \\text{for all} \\quad j \\in J \\quad \\&  \\quad k \\in K  \\quad \\text{for all} \\quad J, K \\\\\n            & \\quad \\text{where} \\quad J \\cap K = \\O \\quad\n            \\text{and} \\quad J \\cup K = \\{1, 2, 3, 4\\}.\\\\\n            \\bullet\\quad  p \\in \\{0, 1\\} ^ 4\n        \\end{aligned}\\right.\n    \\right\\}.\n\\end{equation}\n}\n\nNote that there is no immediate way to find the zeros of\n\\(\\frac{d}{dp} \\sum\\limits_{i=1} ^ N  u_q(p)\\) where,\n\n{\\scriptsize\n\\begin{align}\\label{eq:mo_tournament_derivative}\n    \\frac{d}{dp} \\sum\\limits_{i=1} ^ {N} {u_q}^{(i)} (p) & = \\displaystyle\\sum\\limits_{i=1} ^ {N}\n    \\frac{\\left(pQ^{(i)} + c^{(i)}\\right) \\left(\\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)}\\right)}\n    {\\left(\\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)}\\right)^ 2}\n    - \\frac{\\left(p\\bar{Q}^{(i)} + \\bar{c}^{(i)}\\right) \\left(\\frac{1}{2} pQ^{(i)} p^T + c^{(i)} p + a^ {(i)}\\right)}\n    {\\left(\\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)}\\right)^ 2}\n\\end{align}\n}\n\nFor \\(\\frac{d}{dp} \\sum\\limits_{i=1} ^ N  u_q(p)\\) to equal zero then:\n\n{\\scriptsize\n\\begin{align}\\label{eq:polynomials_roots}\n    \\displaystyle\\sum\\limits_{i=1} ^ {N}\n    \\left(pQ^{(i)} + c^{(i)}\\right) \\left(\\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)}\\right)\n    - \\left(p\\bar{Q}^{(i)} + \\bar{c}^{(i)}\\right) \\left(\\frac{1}{2} pQ^{(i)} p^T + c^{(i)} p + a^ {(i)}\\right)\n    & = 0, \\quad {while} \\\\\n    \\displaystyle\\sum\\limits_{i=1} ^ {N} \\frac{1}{2} p\\bar{Q}^{(i)} p^T + \\bar{c}^{(i)} p + \\bar{a}^ {(i)} & \\neq 0.\n\\end{align}}\n\n\\end{theorem}\n\n\\begin{proof}\n    The optimal behaviour of a memory-one strategy player\n    \\(p^* \\in \\R_{[0, 1]} ^ 4\\)\n    against a set of \\(N\\) opponents \\(\\{q^{(1)}, q^{(2)}, \\dots, q^{(N)} \\}\\)\n    for \\(q^{(i)} \\in \\R_{[0, 1]} ^ 4\\) is established by:\n    \n    \\[p^* = \\textnormal{argmax}\\left(\\sum\\limits_{i=1} ^ N  u_q(p)\\right), \\ p \\in S_q,\\]\n    \n    where \\(S_q\\) is given by:\n    {\\scriptsize\n    \\begin{equation}\\label{eq:s_q_set}\n        S_q =\n        \\left\\{p \\in \\mathbb{R} ^ 4 \\left|\n            \\begin{aligned}\n                \\bullet\\quad p_j \\in \\{0, 1\\} & \\quad \\text{and} \\quad \\frac{d}{dp_k} \n                \\sum\\limits_{i=1} ^ N  u_q^{(i)}(p) = 0 \\\\\n                & \\quad \\text{for all} \\quad j \\in J \\quad \\&  \\quad k \\in K  \\quad \\text{for all} \\quad J, K \\\\\n                & \\quad \\text{where} \\quad J \\cap K = \\O \\quad\n                \\text{and} \\quad J \\cup K = \\{1, 2, 3, 4\\}.\\\\\n                \\bullet\\quad  p \\in \\{0, 1\\} ^ 4\n            \\end{aligned}\\right.\n        \\right\\}.\n    \\end{equation}}\n\n    The optimisation problem of Eq.~\\ref{eq:mo_tournament_optimisation} \n\n    \\begin{equation}\\label{eq:mo_tournament_optimisation}\n        \\begin{aligned}\n        \\max_p: & \\ \\sum_{i=1} ^ {N} {u_q}^{(i)} (p)\n        \\\\\n        \\text{such that}: & \\ p \\in \\R_{[0, 1]}\n        \\end{aligned}\n    \\end{equation}\n\n    can be written as:\n\n    \\begin{equation}\\label{eq:mo_tournament_optimisation_standard}\n        \\begin{aligned}\n        \\max_p: & \\ \\sum_{i=1} ^ {N} {u_q}^{(i)} (p)\n        \\\\\n        \\text{such that}: p_i & \\leq 1 \\text{ for } \\in \\{1, 2, 3, 4\\} \\\\\n        - p_i & \\leq 0 \\text{ for } \\in \\{1, 2, 3, 4\\} \\\\\n        \\end{aligned}\n    \\end{equation}\n    \n    The optimisation problem has two inequality constraints and regarding the optimality\n    this means that:\n    \n    \\begin{itemize}\n        \\item either the optimum is away from the boundary of the optimization domain, and so the constraints plays no role;\n        \\item or the optimum is on the constraint boundary.\n    \\end{itemize}\n    \n    Thus, the following three cases must be considered:\n    \n    \\textbf{Case 1:} The solution is on the boundary and any of the possible\n    combinations for $p_i \\in \\{0, 1\\}$ for $i \\in \\{1, 2, 3, 4\\}$ are candidate\n    optimal solutions.\n    \n    \\textbf{Case 2:} The optimum is away from the boundary of the optimization domain\n    and the interior solution $p^*$ necessarily satisfies the condition\n    \\(\\frac{d}{dp} \\sum\\limits_{i=1} ^ N  u_q(p^*) = 0\\).\n    \n    \\textbf{Case 3:} The optimum is away from the boundary of the optimization domain\n    but some constraints are equalities. The candidate solutions in this case\n    are any combinations of $p_j \\in \\{0, 1\\} \\quad \\text{and} \\quad \\frac{d}{dp_k} \n    \\sum\\limits_{i=1} ^ N  u_q^{(i)}(p) = 0$ \n    forall $ j \\in J \\text{ \\& } k \\in K \\text{ forall } J, K\n    \\text{ where } J \\cap K = \\O \\text{ and } J \\cup K = \\{1, 2, 3, 4\\}.$\n    \n    Combining cases 1-3 a set of candidate solution is constructed as:\n    {\\scriptsize\n    \\begin{equation*}\n        S_q =\n        \\left\\{p \\in \\mathbb{R} ^ 4 \\left|\n            \\begin{aligned}\n                \\bullet\\quad p_j \\in \\{0, 1\\} & \\quad \\text{and} \\quad \\frac{d}{dp_k} \n                \\sum\\limits_{i=1} ^ N  u_q^{(i)}(p) = 0\n                \\quad \\text{for all} \\quad j \\in J \\quad \\&  \\quad k \\in K  \\quad \\text{for all} \\quad J, K \\\\\n                & \\quad \\text{where} \\quad J \\cap K = \\O \\quad\n                \\text{and} \\quad J \\cup K = \\{1, 2, 3, 4\\}.\\\\\n                \\bullet\\quad  p \\in \\{0, 1\\} ^ 4\n            \\end{aligned}\\right.\n        \\right\\}.\n    \\end{equation*}}\n    \n    This set is denoted as $S_q$ and the optimal solution to\n    Eq.~\\ref{eq:mo_tournament_optimisation} is the point from $S_q$ for which the\n    utility is maximised.\n\\end{proof}\n\n\\end{document}", "meta": {"hexsha": "90b89e57d8947c31297106db50dd369f7570b310", "size": 39920, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "trallard/Memory-size-in-the-prisoners-dilemma", "max_stars_repo_head_hexsha": "d674b3c6950beb3c4e0cc22230a1529c3959afb4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-31T16:34:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-01T14:36:42.000Z", "max_issues_repo_path": "main.tex", "max_issues_repo_name": "trallard/Memory-size-in-the-prisoners-dilemma", "max_issues_repo_head_hexsha": "d674b3c6950beb3c4e0cc22230a1529c3959afb4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "trallard/Memory-size-in-the-prisoners-dilemma", "max_forks_repo_head_hexsha": "d674b3c6950beb3c4e0cc22230a1529c3959afb4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6900584795, "max_line_length": 264, "alphanum_fraction": 0.6774048096, "num_tokens": 12825, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4277530956635736}}
{"text": "% Created 2021-09-21 Tue 11:20\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=169, usenames, dvipsnames]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\usepgfplotslibrary{groupplots}\n\\newcommand*{\\shift}{\\operatorname{q}}\n\\definecolor{ppc}{rgb}{0.1,0.1,0.6}\n\\definecolor{iic}{rgb}{0.6,0.1,0.1}\n\\definecolor{ddc}{rgb}{0.1,0.6,0.1}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{\\today}\n\\title{Design of control systems}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Design of control systems},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section{Course content}\n\\label{sec:orgd1eaf3e}\n\n\\begin{frame}[label={sec:org7b42b0b}]{Feedback control systems are ubiquitous}\n\\begin{center}\n  \\includegraphics[width=.6\\linewidth]{../../figures/PnID-ex.png}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org2eee146}]{Feedback control systems}\nThe problem situation\n\n\\begin{center}\n  \\includegraphics[width=.34\\linewidth]{../../figures/mars-rover-curiosity-vehicle-cosmos.jpg}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:orga50fd22}]{Feedback control system}\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n \\includegraphics[width=1.0\\linewidth]{../../figures/curiosity-wheel.jpg}\n\\end{center}\n\\end{column}\n\n\\begin{column}{0.6\\columnwidth}\n\\pause\n\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/electric-drive-block.png}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\n\n\n\\section{Control systems specifications}\n\\label{sec:org381a6df}\n\n\\begin{frame}[label={sec:org3355b21}]{Performance requirements - time domain}\n\\begin{center}\n  \\includegraphics[width=.8\\linewidth]{../../figures/step-response-specifications}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org4402dc5}]{Performance requirements - time domain}\n\\alert{Activity} Does the system satisfy the requirements?\n\n\\begin{columns}\n\\begin{column}{0.3\\columnwidth}\n\\begin{center}\n\\begin{tabular}{ll}\nRise time & < 1.5s\\\\\nOvershoot & < 18\\%\\\\\n\\end{tabular}\n\\end{center}\n\\end{column}\n\n\n\\begin{column}{0.7\\columnwidth}\n\\begin{center}\n \\includegraphics[width=1.0\\linewidth]{../../figures/second-order-response-example}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}[label={sec:org72943a6}]{Performance requirements - frequency domain}\n\\begin{center}\n  \\includegraphics[width=.8\\linewidth]{../../figures/spec-bode-closed-loop-new}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:orgdebb4b0}]{Performance requirements - frequency domain}\n\\begin{center}\n  \\includegraphics[width=1.0\\linewidth]{../../figures/bode-closed-loop-example-responses}\n\\end{center}\n\n\\pause\n\n\\alert{Activity} What is the gain and phase shift at \\(\\omega = 2\\) rad/s?\n\\end{frame}\n\n\\begin{frame}[label={sec:orgfefd3ae}]{Performance requirements - frequency domain}\n\\begin{center}\n  \\includegraphics[width=.8\\linewidth]{../../figures/spec-bode-closed-loop-new}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org10c4d2c}]{Performance requirements - frequency domain}\n\\alert{Activity} Does the system satisfy the requirements?\n\n\n\\begin{columns}\n\\begin{column}{0.7\\columnwidth}\n\\begin{center}\n \\includegraphics[width=1.0\\linewidth]{../../figures/bode-closed-loop-example}\n\\end{center}\n\\end{column}\n\\begin{column}{0.3\\columnwidth}\n\\begin{center}\n\\begin{tabular}{ll}\nBandwidth & >3 rad/s\\\\\nResonance peak & <9dB\\\\\n\\end{tabular}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\n\n\n\\section{Feedback, sensitivity and complementary sensitivity}\n\\label{sec:org2cd98ba}\n\n\\begin{frame}[label={sec:org205a6a1}]{Block diagram algebra}\n\\begin{center}\n  \\includegraphics[width=.6\\linewidth]{../../figures/block-simple-feedback}\n\\end{center}\n\nTransfer function from \\(r(t)\\) to \\(y(t)\\):\n\\[ \\frac{Y(s)}{R(s)} = \\frac{G(s)}{ 1+ G(s)}\\]\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org99fd74b}]{Block diagram algebra}\n\\alert{Activity} Pair the block-diagram with the correct closed-loop transfer function!\n\n\n\\begin{longtable}{cccc}\n\\textcolor{red}{A} & \\textcolor{red}{B} & \\textcolor{red}{C} & \\textcolor{red}{D}\\\\\n\\includegraphics[width=3cm]{../../figures/block-simple-control-feedback} & \\includegraphics[width=3cm]{../../figures/block-simple-control-feedback2} & \\includegraphics[width=3cm]{../../figures/block-simple-control-feedback3} & \\includegraphics[width=3cm]{../../figures/block-simple-control-feedback4}\\\\\n\\end{longtable}\n\n\n\\begin{longtable}{cccc}\n\\textcolor{blue!80!black}{I} & \\textcolor{blue!80!black}{II} & \\textcolor{blue!80!black}{III} & \\textcolor{blue!80!black}{IV}\\\\\n\\(\\frac{Y(s)}{R(s)}=\\frac{G(s)F(s)}{1 + G(s)}\\) & \\(\\quad \\frac{Y(s)}{R(s)}=\\frac{G(s)}{1 + G(s)F(s)}\\quad\\) & \\(\\frac{Y(s)}{R(s)}=\\frac{1}{1 + G(s)F(s)}\\) & \\(\\frac{Y(s)}{R(s)}=\\frac{G(s)F(s)}{1 + G(s)F(s)}\\)\\\\\n\\end{longtable}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "87ef88af2c93255eaf38e52250a5538b6517ae96", "size": 5143, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "intro/slides/intro-mr2025.tex", "max_stars_repo_name": "kjartan-at-tec/mr2025", "max_stars_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "intro/slides/intro-mr2025.tex", "max_issues_repo_name": "kjartan-at-tec/mr2025", "max_issues_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "intro/slides/intro-mr2025.tex", "max_forks_repo_name": "kjartan-at-tec/mr2025", "max_forks_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9510869565, "max_line_length": 302, "alphanum_fraction": 0.7238965584, "num_tokens": 1683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.42774323558142713}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n\\newcommand{\\Gr}{\\opname{Gr}}\n\n\n\\title{Math 217 -- Geometry and Physics -- Lec11}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{27}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{More on $L$-classes, $\\hat{A}$-classes}\n\nLast time we started talking about the Hirzebruch $L$-classes. For a manifold $M^{2n}$ we the $L$-class is given by\n\\begin{eqn}\nL(TM) = \\prod_{j=1}^n \\frac{x_j}{\\tanh x_j},\n\\end{eqn}\nand we have\n\\begin{eqn}\n\\int_{M^{2n}} L(TM) = \\opname{sgn} M.\n\\end{eqn}\nFor $M^4$ we have \n\\begin{align}\nL(TM) &= 1 + \\frac{1}{3} P_1 (TM), \\\\\n\\hat{A} &= 1 - \\frac{1}{24} P_1(TM).\n\\end{align}\nwhere the $\\hat{A}$-class is given by\n\\begin{align}\n\\hat{A}(TM) &= \\prod_{j=1}^n \\frac{x_j / 2}{\\sinh(x_j/2)}, \\\\\n\\opname{Ind} D &= \\int_{M^{2n}} \\hat{A}(TM) = \\text{$\\hat{A}$-genus},\n\\end{align}\nwhere $D$ is the Dirac operator.\n\nGiven $M^{4k}$ a compact closed manifold,\n\\begin{eqn}\n\\begin{matrix}\nH^{2k}(M, \\R) & \\times & H^{2k}(M, \\R) & \\rightarrow & \\R \\\\\n\\alpha & & \\beta & \\mapsto & \\int_M \\alpha \\wedge \\beta\n\\end{matrix}\n\\end{eqn}\ngives us a quadratic form. We have\n\\begin{eqn}\n\\opname{sgn} M = (\\text{\\# positive eigenvalues}) - (\\text{\\# negative eigenvalues}),\n\\end{eqn}\nand\n\\begin{eqn}\n\\opname{sgn} M = \\int_M L(TM) = \\frac{1}{3} \\int_M P_1(TM) = -8 \\int_M \\hat{A}(TM) = -8 \\opname{Ind} D.\n\\end{eqn}\n[$M$ a spin-manifold [?]]\n\\begin{definition}\nA spin-manifold is an oriented manifold $M$ with structure group of $TM$ given by $SO(n)$ with $n \\geq 2$. It turns out that $\\pi_1 (SO(n)) = \\Z_2$, so we have\n\\begin{eqn}\n1 \\rightarrow \\Z_2 \\rightarrow \\opname{Spin}(n) \\rightarrow SO(n) \\rightarrow 1,\n\\end{eqn}\nwhere $\\opname{Spin}(n)$ is the universal cover of $SO(n)$. %break defn here?\nThen the principle bundle $P_{SO(n)}$ of $SO(n)$ is a frame bundle of $TM$, and we know there exists a principle $\\opname{Spin}(n)$ bundle \n\\begin{eqn}\nP_{\\opname{Spin}(n)} \\overset{2:1}{\\longrightarrow} P_{SO(n)} \\rightarrow M.\n\\end{eqn}\nwhich is where the name comes from. \n\\end{definition}\n[missed some stuff here on what this means in terms of Stiefel-Whitney classes]\n\nSo if $M^4$ is a spin-manifold, we find that \n\\begin{eqn}\n\\opname{sgn} M = o(8) \\text{ [divisible by 8?]} = -8 \\underbrace{\\opname{Ind} D}_\\text{even}.\n\\end{eqn}\n\n\\begin{theorem}[Rochlin Theorem]\nGiven $M^4$ a compact smooth spin manifold, we have $\\opname{sgn} M^4 = o(16)$. \n\\end{theorem}\n\\begin{proof}\nThe index or $\\hat{A}$-genus is even for $8k+4$ dimensional manifold. \n\\end{proof}\n\n\n\\section{K-theory, Chern character}\n\nGiven manifold $M$ with vector bundles $E, F$, denote $[E], [F]$ as their equivalence classes. Then \n\\begin{eqn}\n[E] = [F] \\quad \\iff \\quad E \\oplus \\zeta_1 \\cong F \\oplus \\zeta_2\n\\end{eqn}\nwhere $\\zeta_1, \\zeta_2$ are trivial bundles. Note that it is not true that\n\\begin{eqn}\n0 \\rightarrow F \\rightarrow G \\rightarrow E \\rightarrow 0 \\quad \\implies \\quad G \\cong E \\oplus F.\n\\end{eqn}\nRather if we have\n\\begin{eqn}\n[E] + [F] = [E \\oplus F], \\quad [E] [F] = [E \\otimes F],\n\\end{eqn}\nthen we find\n\\begin{eqn}\n[E] - [F] = [G] \\quad \\implies \\quad [E] = [G] + [F].\n\\end{eqn}\n\n\\begin{definition}\nWe define $K(M)$ as the set of equivalence classes of vector bundles on $M$ with the operations. \n\\end{definition}\n\\begin{remark}\n$K(M)$ is a \\textit{generalized} Cohomology theory. \n\\end{remark}\n\nNow we have a map\n\\begin{eqn}\n\\begin{matrix}\n\\opname{ch} & : & K(M) & \\rightarrow & H^*(M, \\Q) \\\\\n& & [E] & \\mapsto & \\opname{ch} E = \\sum_{j=1}^r e^{x_i}.\n\\end{matrix}\n\\end{eqn}\nLet $\\set{x_i}$ be Chern roots of $E$, i.e. $\\tr \\exp \\frac{i}{2\\pi} \\Omega$. If $E$ is a real vector bundle then \n\\begin{eqn}\n\\opname{ch} E = \\opname{ch} (E \\otimes_\\R \\C).\n\\end{eqn}\nGiven two vector bundles $E, E'$, we have\n\\begin{enumerate}\n\\item $\\opname{ch} (E \\oplus E') = \\opname{ch} E + \\opname{ch} E'$,\n\\item $\\opname{ch} (E \\otimes E') = \\opname{ch} E \\, \\opname{ch} E'$,\n\\item $\\opname{ch} (E - E') = \\opname{ch} E - \\opname{ch} E'$.\n\\end{enumerate}\n\nWe have \n\\begin{eqn}\nK(M) \\overset{f_!}{\\longrightarrow} K(N) \\overset{\\opname{ch}}{\\longrightarrow} H^*(N)\n\\end{eqn}\nand\n\\begin{eqn}\nK(M) \\overset{\\opname{ch}}{\\longrightarrow} H^*(M) \\overset{f_*}{\\longrightarrow} H^*(N).\n\\end{eqn}\nIn general they do not commute. But if we multiply the Chern characters $\\opname{ch}$ by $\\hat{A}(TM)$ then they do commute. \n\nFor $M$ a complex manifold we have $T$-odd class\n\\begin{eqn}\nT \\dif(TM) = \\prod_{j=1}^n \\frac{x_j}{1 - e^{-x_j}}.\n\\end{eqn}\nThis gives us [Top transfer, Riemann of Cohomology theory, Roch, something for holomorphic map between projective manifolds [???]]. Then\n\\begin{eqn}\nK(M \\times S^{2N}) \\cong K(M).\n\\end{eqn}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "a4ce5b7518156272e10885bf265c0661bc0e036e", "size": 4949, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geometry/lec11.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "geometry/lec11.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geometry/lec11.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7748344371, "max_line_length": 159, "alphanum_fraction": 0.6524550414, "num_tokens": 1890, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.42774320414014755}}
{"text": "\\documentclass[13pt,onlymath]{beamer}\n\\usefonttheme{serif}\n\\usepackage{graphicx,amsmath,amssymb,tikz,psfrag,epstopdf,fancyvrb}\n\\usepackage[lighttt]{lmodern}\n%\\usepackage{graphicx,psfrag}\n\n\\input defs.tex\n\n%% formatting\n\n\\mode<presentation>\n{\n\\usetheme{default}\n}\n\\setbeamertemplate{navigation symbols}{}\n\\usecolortheme[rgb={0.13,0.28,0.59}]{structure}\n\\setbeamertemplate{itemize subitem}{--}\n\\setbeamertemplate{frametitle} {\n    \\begin{center}\n      {\\large\\bf \\insertframetitle}\n    \\end{center}\n}\n\n\\newcommand\\footlineon{\n  \\setbeamertemplate{footline} {\n    \\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,leftskip=.8cm,rightskip=.6cm]{structure}\n      \\footnotesize \\insertsection\n      \\hfill\n      {\\insertframenumber}\n    \\end{beamercolorbox}\n    \\vskip 0.45cm\n  }\n}\n\\footlineon\n\n\\AtBeginSection[] \n{ \n    \\begin{frame}<beamer> \n        \\frametitle{Outline} \n        \\tableofcontents[currentsection,currentsubsection] \n    \\end{frame} \n} \n\n%% begin presentation\n\n\\title{\\large \\bfseries Mathematics}\n\n\\author{Jaehyun Park\\\\[3ex]\nCS 97SI\\\\\nStanford University}\n\n\\date{\\today}\n\n\\begin{document}\n\n\\frame{\n\\thispagestyle{empty}\n\\titlepage\n}\n\n\\section{Algebra}\n\n\\begin{frame}{Sum of Powers}\n\\BEAS\n\\sum_{k=1}^n k^2 &=& \\frac{1}{6}n(n+1)(2n+1) \\\\\n\\sum k^3 &=& \\left(\\sum k\\right)^2 = \\left(\\frac{1}{2}n(n+1)\\right)^2\n\\EEAS\n\\BIT\n\\item Pretty useful in many random situations\n\\item Memorize above!\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Fast Exponentiation}\n\\BIT\n\\item Recursive computation of $a^n$:\n\\[\na^n = \\begin{cases}\n1 & n = 0\\\\\na & n = 1\\\\\n(a^{n/2})^2 & n \\mbox{ is even}\\\\\na (a^{(n-1)/2})^2 & n \\mbox{ is odd}\n\\end{cases}\n\\]\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{Implementation (recursive)}\n\\begin{Verbatim}[xleftmargin=25pt]\ndouble pow(double a, int n) {\n    if(n == 0) return 1;\n    if(n == 1) return a;\n    double t = pow(a, n/2);\n    return t * t * pow(a, n%2);\n}\n\\end{Verbatim}\n\\BIT\n\\item Running time: $O(\\log n)$\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{Implementation (non-recursive)}\n\\begin{Verbatim}[xleftmargin=25pt]\ndouble pow(double a, int n) {\n    double ret = 1;\n    while(n) {\n        if(n%2 == 1) ret *= a;\n        a *= a; n /= 2;\n    }\n    return ret;\n}\n\\end{Verbatim}\n\\BIT\n\\item You should understand how it works\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Linear Algebra}\n\\BIT\n\\item Solve a system of linear equations\n\\item Invert a matrix\n\\item Find the rank of a matrix\n\\item Compute the determinant of a matrix\n\\item All of the above can be done with Gaussian elimination\n\\EIT\n\\end{frame}\n\n\\section{Number Theory}\n\n\\begin{frame}{Greatest Common Divisor (GCD)}\n\\BIT\n\\item $\\gcd(a, b)$: greatest integer divides both $a$ and $b$\n\\item Used very frequently in number theoretical problems\n\n\\item Some facts:\n\\BIT\n\\item $\\gcd(a, b) = \\gcd(a, b-a)$\n\\item $\\gcd(a, 0) = a$\n\\item $\\gcd(a, b)$ is the smallest positive number in $\\{ax+by \\,|\\, x, y \\in \\integers\\}$\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Euclidean Algorithm}\n\\BIT\n\\item Repeated use of $\\gcd(a, b) = \\gcd(a, b-a)$\n\\item Example:\n\\BEAS\n\\gcd(1989, 867) &=& \\gcd(1989-2\\times 867, 867) \\\\\n&=& \\gcd(255, 867) \\\\\n&=& \\gcd(255, 867-3\\times 255) \\\\\n&=& \\gcd(255, 102) \\\\\n&=& \\gcd(255-2\\times 102, 102) \\\\\n&=& \\gcd(51, 102) \\\\\n&=& \\gcd(51, 102-2\\times 51) \\\\\n&=& \\gcd(51, 0) \\\\\n&=& 51\n\\EEAS\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{Implementation}\n\\begin{Verbatim}[xleftmargin=25pt]\nint gcd(int a, int b) {\n    while(b){int r = a % b; a = b; b = r;}\n    return a;\n}\n\\end{Verbatim}\n\\BIT\n\\item Running time: $O(\\log(a+b))$\n\\item Be careful: \\verb,a % b, follows the sign of \\verb,a,\n\\BIT\n\\item \\verb,5 % 3 == 2,\n\\item \\verb,-5 % 3 == -2,\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Congruence \\& Modulo Operation}\n\\BIT\n\\item $x \\equiv y \\pmod{n}$ means $x$ and $y$ have the same remainder when divided by $n$\n\\item Multiplicative inverse\n\\BIT\n\\item $x^{-1}$ is the inverse of $x$ modulo $n$ if $x x^{-1} \\equiv 1 \\pmod{n}$\n\\item $5^{-1} \\equiv 3 \\pmod{7}$ because $5 \\cdot 3 \\equiv 15 \\equiv 1 \\pmod{7}$\n\\item May not exist (\\eg, inverse of $2$ mod $4$)\n\\item Exists if and only if $\\gcd(x, n) = 1$\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Multiplicative Inverse}\n\\BIT\n\\item All intermediate numbers computed by Euclidean algorithm are integer combinations of $a$ and $b$\n\\BIT\n\\item Therefore, $\\gcd(a, b) = ax+by$ for some integers $x, y$\n\\item If $\\gcd(a, n) = 1$, then $ax + ny = 1$ for some $x, y$\n\\item Taking modulo $n$ gives $ax \\equiv 1 \\pmod{n}$\n\\EIT\n\\item We will be done if we can find such $x$ and $y$\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Extended Euclidean Algorithm}\n\\BIT\n\\item Main idea: keep the original algorithm, but write all intermediate numbers as integer combinations of $a$ and $b$\n\\item Exercise: implementation!\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Chinese Remainder Theorem}\n\\BIT\n\\item Given $a,b,m,n$ with $\\gcd(m, n) = 1$\n\\item Find $x$ with $x\\equiv a \\pmod{m}$ and $x \\equiv b \\pmod{n}$\n\n\\item Solution:\n\\BIT\n\\item Let $n^{-1}$ be the inverse of $n$ modulo $m$\n\\item Let $m^{-1}$ be the inverse of $m$ modulo $n$\n\\item Set $x = a n n^{-1} + b m m^{-1}$ (check this yourself)\n\\EIT\n\\item Extension: solving for more simultaneous equations\n\\EIT\n\\end{frame}\n\n\\section{Combinatorics}\n\n\\begin{frame}{Binomial Coefficients}\n\\BIT\n\\item $\\dbinom{n}{k}$ is the number of ways to choose $k$ objects out of $n$ distinguishable objects\n\\item same as the coefficient of $x^k y^{n-k}$ in the expansion of $(x+y)^n$\n\\BIT\n\\item Hence the name ``binomial coefficients''\n\\EIT\n\\item Appears everywhere in combinatorics\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Computing Binomial Coefficients}\n\\BIT\n\\item Solution 1: Compute using the following formula:\n\\[\n\\binom{n}{k} = \\frac{n(n-1) \\cdots (n-k+1)}{k!}\n\\]\n\\item Solution 2: Use Pascal's triangle\n\n\\item Can use either if both $n$ and $k$ are small\n\\item Use Solution 1 carefully if $n$ is big, but $k$ or $n-k$ is small\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Fibonacci Sequence}\n\\BIT\n\\item Definition:\n\\BIT\n\\item $F_0 = 0$, $F_1 = 1$\n\\item $F_n = F_{n-1} + F_{n-2}$, where $n \\ge 2$\n\\EIT\n\\item Appears in many different contexts\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Closed Form}\n\\BIT\n\\item $F_n = (1/\\sqrt{5})(\\varphi^n - \\overline{\\varphi}^n)$\n\\BIT\n\\item $\\varphi = (1+\\sqrt{5})/2$\n\\item $\\overline{\\varphi} = (1-\\sqrt{5})/2$\n\\EIT\n\\item Bad because $\\varphi$ and $\\sqrt{5}$ are irrational\n\\item Cannot compute the exact value of $F_n$ for large $n$\n\n\\item There is a more stable way to compute $F_n$\n\\BIT\n\\item ... and any other recurrence of a similar form\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Better ``Closed'' Form}\n\\[\n\\left[\\begin{array}{c}F_{n+1} \\\\ F_n \\end{array} \\right] = \n\\left[\\begin{array}{cc}1&1\\\\1&0 \\end{array} \\right] \\left[\\begin{array}{c}F_n \\\\ F_{n-1} \\end{array} \\right] =\n\\left[\\begin{array}{cc}1&1\\\\1&0 \\end{array} \\right]^n \\left[\\begin{array}{c}F_1 \\\\ F_0 \\end{array} \\right]\n\\]\n\\BIT\n\\item Use fast exponentiation to compute the matrix power\n\\item Can be extended to support any linear recurrence with constant coefficients\n\\EIT\n\\end{frame}\n\n\\section{Geometry}\n\n\\begin{frame}{Geometry}\n\\BIT\n\\item In theory: not that hard\n\\item In programming contests: more difficult than it looks\n\\item Will cover basic stuff today\n\\BIT\n\\item Computational geometry in week 9\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{When Solving Geometry Problems}\n\\BIT\n\\item Precision, precision, precision!\n\\BIT\n\\item If possible, don't use floating-point numbers\n\\item If you have to, always use \\verb,double, and never use \\verb,float,\n\\item Avoid division whenever possible\n\\item Introduce small constant $\\epsilon$ in (in)equality tests\n\\BIT\n\\item e.g., Instead of \\verb,if(x == 0),, write \\verb,if(abs(x) < EPS),\n\\EIT\n\\EIT\n\\item No hacks!\n\\BIT\n\\item In most cases, randomization, probabilistic methods, small perturbations won't help\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{2D Vector Operations}\n\\BIT\n\\item Have a vector $(x, y)$\n\\item Norm (distance from the origin): $\\sqrt{x^2+y^2}$\n\\item Counterclockwise rotation by $\\theta$:\n\\[\n\\left[ \\begin{array}{cc} \\cos \\theta & -\\sin \\theta \\\\ \\sin \\theta & \\cos \\theta \\end{array}\\right]\n\\left[ \\begin{array}{c} x \\\\ y \\end{array}\\right]\n\\]\n\\BIT\n\\item Make sure to use correct units (degrees, radians)\n\\EIT\n\\item Normal vectors: $(y, -x)$ and $(-y, x)$\n\n\\item Memorize all of them!\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Line-Line Intersection}\n\\BIT\n\\item Have two lines: $ax+by+c=0$ and $dx+ey+f=0$\n\\item Write in matrix form:\n\\[\n\\left[ \\begin{array}{cc} a & b \\\\ d & e \\end{array}\\right]\n\\left[ \\begin{array}{c} x \\\\ y \\end{array}\\right]\n=\n-\\left[ \\begin{array}{c} c \\\\ f \\end{array}\\right]\n\\]\n\\item Left-multiply by matrix inverse\n\\[\n\\left[ \\begin{array}{cc} a & b \\\\ d & e \\end{array}\\right]^{-1} =\n\\frac{1}{ae-bd}\\left[ \\begin{array}{cc} e & -b \\\\ -d & a \\end{array}\\right]\n\\]\n\\BIT\n\\item Memorize this!\n\\EIT\n\\item Edge case: $ae=bd$\n\\BIT\n\\item The lines coincide or are parallel\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Circumcircle of a Triangle}\n\\BIT\n\\item Have three points $A, B, C$\n\\item Want to compute $P$ that is equidistance from $A, B, C$\n\n\\item Don't try to solve the system of quadratic equations!\n\\item Instead, do the following:\n\\BIT\n\\item Find the (equations of the) bisectors of $AB$ and $BC$\n\\item Compute their intersection\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Area of a Triangle}\n\\BIT\n\\item Have three points $A, B, C$\n\\item Want to compute the area $S$ of triangle $ABC$\n\\item Use cross product: $2S = |(B-A) \\times (C-A)|$\n\\item Cross product:\n\\[\n(x_1, y_1) \\times (x_2, y_2) = \\left| \\begin{array}{cc} x_1 & x_2 \\\\ y_1 & y_2 \\end{array}\\right| = x_1 y_2 - x_2 y_1\n\\]\n\\BIT\n\\item Very important in computational geometry. Memorize!\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Area of a Simple Polygon}\n\\BIT\n\\item Given vertices $P_1, P_2, \\ldots, P_n$ of polygon $P$\n\\item Want to compute the area $S$ of $P$\n\\item If $P$ is convex, we can decompose $P$ into triangles:\n\\[\n2S = \\left| \\sum_{i=2}^{n-1}(P_{i+1} - P_1) \\times (P_i - P_1) \\right|\n\\]\n\\item It turns out that the formula above works for non-convex polygons too\n\\BIT\n\\item Area is the absolute value of the sum of ``signed area''\n\\EIT\n\\item Alternative formula (with $x_{n+1} = x_1, y_{n+1} = y_1$):\n\\[\n2S = \\left| \\sum_{i=1}^n (x_i y_{i+1} - x_{i+1} y_i) \\right|\n\\]\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Conclusion}\n\\BIT\n\\item No need to look for one-line closed form solutions\n\\item Knowing ``how to compute'' (algorithms) is good enough\n\n\\item Have fun with the exercise problems\n\\BIT\n\\item ... and come to the practice contest if you can!\n\\EIT\n\\EIT\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "2cfc7d4500f925d9be41739aab5c98f52b172e79", "size": 10468, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "97si_slides/mathematics.tex", "max_stars_repo_name": "Charleo85/stanfordacm", "max_stars_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1624, "max_stars_repo_stars_event_min_datetime": "2015-08-11T03:23:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T17:26:03.000Z", "max_issues_repo_path": "97si_slides/mathematics.tex", "max_issues_repo_name": "Charleo85/stanfordacm", "max_issues_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2015-05-03T17:12:19.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-26T01:54:14.000Z", "max_forks_repo_path": "97si_slides/mathematics.tex", "max_forks_repo_name": "Charleo85/stanfordacm", "max_forks_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 598, "max_forks_repo_forks_event_min_datetime": "2015-05-03T10:50:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T20:25:05.000Z", "avg_line_length": 24.4579439252, "max_line_length": 119, "alphanum_fraction": 0.6685135652, "num_tokens": 3723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7879311906630568, "lm_q1q2_score": 0.4277389130773682}}
{"text": "%\n% CMPT 379: Principles of Compiler Design - A Course Overview\n% Section: Lexical Analysis (Scanning)\n%\n% Author: Jeffrey Leung\n%\n\n\\section{Lexical Analysis (Scanning)}\n\t\\label{sec:lexical-analysis}\n\\begin{easylist}\n\n& \\textbf{Lexical analysis (scanning):} Transforming an input program string into tokens\n\t&& Does not validate, simply transforms\n\t&& Challenges:\n\t\t&&& Prove that the implementation captures all tokens specified by the language definition\n\t\t&&& Prove correctness of transformations\n\n& \\textbf{Token:} Symbol which represents a specific composable section of code\n\t&& E.g. Open bracket, number\n\t&& Can be denoted as \\lstinline{T_IDENT}, \\lstinline{T_LPAREN}, etc.\n\t&& \\textbf{Lexeme/token attribute:} Value of a token\n\t\t&&& Not all tokens have values\n\t\t&&& E.g. For \\lstinline{T_INTCONSTANT}, a possible value is 1\n\t&& The same character should only represent a single token (e.g. \\lstinline{-} should be represented by the same token whether it is a unary or binary operator)\n\n& \\textbf{Loop and switch scanner:} Lexical analyzer which loops over each character sequentially and categorizes it based on context\n\n\\end{easylist}\n\\subsection{Regular Expressions}\n\t\\label{subsec:reg-ex}\n\\begin{easylist}\n\n& \\textbf{Formal language:} A valid set of strings from a given alphabet of symbols\n\t&& \\textbf{Symbol:} Single distinct character\n\t\t&&& \\textbf{Alphabet:} The finite set of symbols\n\t\t\t&&&& Denoted by $\\sum$ or $\\{\\textrm{symbol}\\}$\n\t&& \\textbf{String:} Sequence of symbols\n\t\t&&& \\textbf{Empty string:} $\\varepsilon$\n\t\t&&& Set of all strings: $\\sum *$\n\n& \\textbf{Formal grammar:} Concise description of a formal language\n\n& \\textbf{Regular language:} A formal language which can be expressed through specific operations (i.e. any regular expression)\n\t&& For each regular language, there is an equivalent finite-state automaton\n\t&& The set of all regular languages includes:\n\t\t&&& The empty set\n\t\t&&& $\\{a\\}$ for all $a$ in $\\sum \\varepsilon$\n\t\t&&& For $L_1, L_2, L$ which are regular languages:\n\t\t\t&&&& Concatenation of $L_1 \\cdot L_2$ where $\\{xy | x \\in L_1 \\textrm{ and } y \\in L_2\\}$\n\t\t\t&&&& Union of $L_1 \\cup L_2$\n\t\t\t&&&& Kleene closure as $L^* = \\bigcup_{i=0}^{\\infty} L^i$\n\t\t&&& No other regular languages\n\n& \\textbf{Regular expression:} Concise description of a regular language\n\t&& E.g. The set of all strings over the alphabet $\\{a, b\\}$ which end in $abb$ is expressed by $(a|b)*abb$\n\t&& Used to define tokens\n\t&& Core operators:\n\t\t&&& \\textbf{Alternation:} One of several options\n\t\t\t&&&& E.g. $a|b = a \\textrm{ or } b$ is a regular expression where $a, b$ are regular expressions\n\t\t&&& \\textbf{Concatenation:} Combination of multiple regular expressions\n\t\t\t&&&& E.g. $ab$, a concatenation of $a$ and $b$, is a regular expression where $a, b$ are regular expressions\n\t\t&&& \\textbf{Repetition:} An arbitrary amount of a regular expression\n\t\t\t&&&& E.g. $a*$, any number of $a$ regular expressions, is a regular expression\n\t&& Used in lexical analysis to match the largest valid string\n\t&& Can be expressed as a recursive tree structure or as a finite state automaton\n\n\\end{easylist}\n\\subsection{Finite State Automata}\n\\label{subsec:finite-state-automata}\n\\begin{easylist}\n\n& \\textbf{Finite State Automaton:} System consisting of a finite set of states and a transition function between states\n\t&& Notations:\n\t\t&&& Alphabet of symbols: $\\Sigma$\n\t\t&&& Finite set of states: $S$\n\t\t&&& Start state: Outlined\n\t\t&&& Final/accepting state: Double-outlined\n\t\t&&& Transition function: $\\sigma: S \\times \\Sigma = S$\n\t&& Equivalent to a unique regular language\n  \t&& Transition of $\\epsilon$ refers to no input from the string corresponding to a transition in state\n\t\t&&&& Non-deterministic\n\n& \\textbf{Deterministic Finite Automata (DFA):} Finite State Automata where no state has more than one transition per input, and no $\\epsilon$ moves exist\n\t&& For any given string, only one path exists from the start state to the final state\n\t&& Runtime complexity: $O(r^s)$\n& \\textbf{Nondeterministic Finite Automata (NFA):} Finite State Automata where at least one state has more than one transition per input, or an $\\epsilon$ move exists\n\t&& For any given string, multiple paths may exist from the state state to the final state\n\t&& Usually larger than DFA\n\t&& Runtime complexity: $O(2^r)$ where $r$ is the initial cost of creating the automaton\n\t&& \\textbf{Subset Construction:} Process to convert an NFA into a DFA\n\t\t&&& From the set of start states, given any input in the alphabet, output the set of potential resulting states. Repeat until no new sets of states are generated. Use each of the unique potential sets of states as a single DFA state.\n\t\t&&& Runtime complexity: Can convert regex of size $r$ to a $2^r$ state DFA\n\n\\end{easylist}\n\\clearpage\n", "meta": {"hexsha": "25961ad4ab2ad0ad17a11ffa14ea828130521af8", "size": 4771, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cmpt-379-principles-of-compiler-design/tex/lexical-analysis.tex", "max_stars_repo_name": "AmirNaghibi/notes", "max_stars_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2019-08-11T08:45:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:37:39.000Z", "max_issues_repo_path": "cmpt-379-principles-of-compiler-design/tex/lexical-analysis.tex", "max_issues_repo_name": "AmirNaghibi/notes", "max_issues_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cmpt-379-principles-of-compiler-design/tex/lexical-analysis.tex", "max_forks_repo_name": "AmirNaghibi/notes", "max_forks_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-11-18T09:17:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-27T21:44:56.000Z", "avg_line_length": 49.6979166667, "max_line_length": 235, "alphanum_fraction": 0.7235380423, "num_tokens": 1343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.42772949989016373}}
{"text": "\\chapter{Mathematical Documentation}\n\\label{chapter:mdoc}\n\nThe \\faust compiler provides a mechanism to produce a self-describing documentation of the mathematical semantic of a \\faust program, essentially as a pdf file. The corresponding options are \\lstinline!-mdoc! (short) or \\lstinline!--mathdoc! (long).\n\n\\section{Goals of the mathdoc}\n\\label{sec:goals-of-mdoc}\n\nThere are three main goals, or uses, of this mathematical documentation:\n\\begin{enumerate}\n\\item to preserve signal processors, independently from any computer language but only under a mathematical form;\n\\item to bring some help for debugging tasks, by showing the formulas as they are really computed after the compilation stage;\n\\item to give a new teaching support, as a bridge between code and formulas for signal processing.\n\\end{enumerate}\n\n\\section{Installation requirements}\n\\label{sec:inst-requ}\n\n\\begin{itemize}\n\\item \\lstinline!faust!, of course!\n\\item \\lstinline!svg2pdf! (from the Cairo 2D graphics library), to convert block-diagrams, as \\latex doesn't eat \\svg directly yet...\n\\item \\lstinline!breqn!, a \\latex package to handle automatic breaking of long equations,\n\\item \\lstinline!pdflatex!, to compile the \\latex output file.\n\\end{itemize}\n\n\n\\section{Generating the mathdoc}\n\\label{sec:generating-mdoc}\n\nThe easiest way to generate the complete mathematical documentation is to call the \\lstinline!faust2mathdoc! script on a \\faust file, as the \\lstinline!-mdoc! option leave the documentation production unfinished. For example: \n\\begin{lstlisting}\nfaust2mathdoc noise.dsp\n\\end{lstlisting}\n\n\\subsection{Invoking the -mdoc option}\n\\label{sec:invoking-mdoc}\n\nCalling directly \\lstinline!faust -mdoc! does only the first part of the work, generating:\n\\begin{itemize}\n\\item a top-level directory, suffixed with \"\\texttt{-mdoc}\",\n\\item 5 subdirectories (\\lstinline!cpp/!, \\lstinline!pdf/!, \\lstinline!src/!, \\lstinline!svg/!, \\lstinline!tex/!),\n\\item a \\latex file containing the formulas,\n\\item \\svg files for block-diagrams.\n\\end{itemize}\n\nAt this stage:\n\\begin{itemize}\n\\item \\lstinline!cpp/! remains empty,\n\\item \\lstinline!pdf/! remains empty,\n\\item \\lstinline!src/! contains all \\faust sources used (even libraries),\n\\item \\lstinline!svg/! contains \\svg block-diagram files,\n\\item \\lstinline!tex/! contains the generated \\latex file.\n\\end{itemize}\n\n\\subsection{Invoking faust2mathdoc}\n\\label{sec:invok-faust2m}\n\nThe \\lstinline!faust2mathdoc! script calls \\lstinline!faust --mathdoc! first, then it finishes the work:\n\\begin{itemize}\n\\item moving the output C++ file into \\lstinline!cpp/!,\n\\item converting all \\svg files into pdf files (you must have \\lstinline!svg2pdf! installed, from the Cairo 2D graphics library),\n\\item launching \\lstinline!pdflatex! on the \\latex file (you must have both \\lstinline!pdflatex! and the \\lstinline!breqn! package installed),\n\\item moving the resulting pdf file into \\lstinline!pdf/!.\n\\end{itemize}\n\n\\subsection{Online examples}\n\\label{sec:mdoc-examples}\n\nTo get an idea of the results of this mathematical documentation, which captures the mathematical semantic of \\faust programs, you can look at two pdf files online:\n\\begin{itemize}\n\\item \\myurl{http://faust.grame.fr/pdf/karplus.pdf} (automatic documentation),\n\\item \\myurl{http://faust.grame.fr/pdf/noise.pdf} (manual documentation).\n\\end{itemize}\n\nYou can also generate all \\emph{mdoc} pdfs at once, simply invoking the \\lstinline!make mathdoc! command inside the \\lstinline!examples/! directory: \n\\begin{itemize}\n\\item for each \\lstinline!%.dsp! file, a complete \\lstinline!%-mdoc! directory will be generated,\n\\item a single \\lstinline!allmathpdfs/! directory will gather all the generated pdf files.\n\\end{itemize}\n\n\n\\section{Automatic documentation}\n\\label{sec:auto-docum}\n\nBy default, when no \\lstinline!<mdoc>! tag can be found in the input \\faust file, the \\lstinline!-mdoc! option automatically generates a \\latex file with four sections:\n\\begin{enumerate}\n\\item ''\\textbf{Equations of process}'', gathering all formulas needed for \\lstinline!process!,\n\\item ''\\textbf{Block-diagram schema of process}'', showing the top-level block-diagram of \\lstinline!process!,\n\\item ''\\textbf{Notice of this documentation}'', summing up generation and conventions information,\n\\item ''\\textbf{Complete listing of the input code}'', listing all needed input files (including libraries).\n\\end{enumerate}\n\n\n\\section{Manual documentation}\n\\label{sec:manual-mdoc}\n\nYou can specify yourself the documentation instead of using the automatic mode, with five xml-like tags. That permits you to modify the presentation and to add your own comments, not only on \\lstinline!process!, but also about any expression you'd like to. Note that as soon as you declare an \\lstinline!<mdoc>! tag inside your \\faust file, the default structure of the automatic mode is ignored, and all the \\latex stuff becomes up to you!\n\n\\subsection{Six tags}\n\\label{sec:doc-tags}\n\nHere are the six specific tags:\n\\begin{itemize}\n\\item \\lstinline!<mdoc></mdoc>!, to open a documentation field in the \\faust code,\n  \\begin{itemize}\n  \\item \\lstinline!<equation></equation>!, to get equations of a \\faust expression,\n  \\item \\lstinline!<diagram></diagram>!, to get the top-level block-diagram of a \\faust expression,\n  \\item \\lstinline!<metadata></metadata>!, to reference \\faust metadatas (cf. declarations), calling the corresponding keyword,\n  \\item \\lstinline!<notice />!, to insert the \"adaptive'' notice all formulas actually printed,\n  \\item \\lstinline!<listing [attributes] />!, to insert the listing of \\faust files called.\n  \\end{itemize}\n\\end{itemize}\n\nThe \\lstinline!<listing />! tag can have up to three boolean attributes (set to \\lstinline!\"true\"! by default):\n\\begin{itemize}\n\\item \\lstinline'mdoctags' for \\lstinline'<mdoc>' tags;\n\\item \\lstinline'dependencies' for other files dependencies;\n\\item \\lstinline'distributed' for the distribution of interleaved \\faust code between \\lstinline'<mdoc>' sections.\n\\end{itemize}\n\n\n\\subsection{The mdoc top-level tags}\n\\label{sec:mdoc-tag}\n\nThe \\lstinline!<mdoc></mdoc>! tags are the top-level delimiters for \\faust mathematical documentation sections. This means that the four other documentation tags can't be used outside these pairs (see section \\ref{sec:documentation}).\n\nIn addition of the four inner tags, \\lstinline!<mdoc></mdoc>! tags accept free \\latex text, including its standard macros (like \\lstinline!\\section!, \\lstinline!\\emph!, etc.). This allows to manage the presentation of resulting tex file directly from within the input \\faust file. \n\nThe complete list of the \\latex packages included by \\faust can be found in the file \\lstinline!architecture/latexheader.tex!.\n\n\\subsection{An example of manual mathdoc}\n\\label{sec:ex-mathdoc}\n\n\\footnotesize\n\\begin{lstlisting}\n<mdoc>\n\\title{<metadata>name</metadata>}\n\\author{<metadata>author</metadata>}\n\\date{\\today}\n\\maketitle\n\n\\begin{tabular}{ll}\n\t\\hline\n\t\\textbf{name}\t\t& <metadata>name</metadata> \\\\\n\t\\textbf{version} \t& <metadata>version</metadata> \\\\\n\t\\textbf{author} \t& <metadata>author</metadata> \\\\\n\t\\textbf{license} \t& <metadata>license</metadata> \\\\\n\t\\textbf{copyright} \t& <metadata>copyright</metadata> \\\\\n\t\\hline\n\\end{tabular}\n\\bigskip\n</mdoc>\n//-----------------------------------------------------------------\n// Noise generator and demo file for the Faust math documentation\n//-----------------------------------------------------------------\n\ndeclare name \t\t\"Noise\";\ndeclare version \t\"1.1\";\ndeclare author \t\t\"Grame\";\ndeclare author \t\t\"Yghe\";\ndeclare license \t\"BSD\";\ndeclare copyright \t\"(c)GRAME 2009\";\n\n<mdoc>\n\\section{Presentation of the \"noise.dsp\" Faust program}\nThis program describes a white noise generator with an interactive volume, using a random function.\n\n\\subsection{The random function}\n</mdoc>\n\nrandom  = +(12345)~*(1103515245);\n\n<mdoc>\nThe \\texttt{random} function describes a generator of random numbers, which equation follows. You should notice hereby the use of an integer arithmetic on 32 bits, relying on integer wrapping for big numbers.\n<equation>random</equation>\n\n\\subsection{The noise function}\n</mdoc>\n\nnoise   = random/2147483647.0;\n\n<mdoc>\nThe white noise then corresponds to:\n<equation>noise</equation>\n\n\\subsection{Just add a user interface element to play volume!}\n</mdoc>\n\nprocess = noise * vslider(\"Volume[style:knob]\", 0, 0, 1, 0.1);\n\n<mdoc>\nEndly, the sound level of this program is controlled by a user slider, which gives the following equation: \n<equation>process</equation>\n\n\\section{Block-diagram schema of process}\nThis process is illustrated on figure 1.\n<diagram>process</diagram>\n\n\\section{Notice of this documentation}\nYou might be careful of certain information and naming conventions used in this documentation:\n<notice />\n\n\\section{Listing of the input code}\nThe following listing shows the input Faust code, parsed to compile this mathematical documentation.\n<listing mdoctags=\"false\" dependencies=\"false\" distributed=\"true\" />\n</mdoc>\n\\end{lstlisting}\n\\normalsize\n\nThe following page which gathers the four resulting pages of \\lstinline!noise.pdf! in small size. might give you an idea of the produced documentation.\n\n\n\\subsection{The -stripmdoc option}\n\\label{sec:striping-option}\n\nAs you can see on the resulting file \\lstinline!noisemetadata.pdf! on its pages 3 and 4, the listing of the input code (section\\,4) contains all the mathdoc text (here colored in grey). As it may be useless in certain cases (see Goals, section \\ref{sec:goals-of-mdoc}), we provide an option to strip mathdoc contents directly at compilation stage: \\lstinline!-stripmdoc! (short) or \\lstinline!--strip-mdoc-tags! (long).\n\n\n\\section{Localization of mathdoc files}\n\\label{sec:localization-mdoc}\n\nBy default, texts used by the documentator are in English, but you can specify another language (French, German and Italian for the moment), using the \\lstinline!-mdlang! (or \\lstinline!--mathdoc-lang!) option with a two-letters argument (\\lstinline!en!, \\lstinline!fr!, \\lstinline!it!, etc.).\n\nThe \\lstinline!faust2mathdoc! script also supports this option, plus a third short form with \\lstinline!-l!:\n\\begin{lstlisting}\nfaust2mathdoc -l fr myfaustfile.dsp\n\\end{lstlisting}\n\nIf you would like to contribute to the localization effort, feel free to translate the mathdoc texts from any of the \\lstinline!mathdoctexts-*.txt! files, that are in the \\lstinline!architecture! directory (\\lstinline!mathdoctexts-fr.txt!, \\lstinline!mathdoctexts-it.txt!, etc.). As these files are dynamically loaded, just adding a new file with an appropriate name should work.\n\n\\includepdf[pages=-, frame=true, angle=-90, scale=0.75, nup=1x2]{images/noisemetadata}\n\n\n\\section{Summary of the mathdoc generation steps}\n\\label{sec:mdoc-summary}\n\n\\begin{enumerate}\n\\item First, to get the full mathematical documentation done on your faust file, call \\lstinline!faust2mathdoc myfaustfile.dsp!.\n\\item Then, open the pdf file \\lstinline!myfaustfile-mdoc/pdf/myfaustfile.pdf!.\n\\item That's all !\n\\end{enumerate}\n\n\n\n", "meta": {"hexsha": "91994a0c389960cfa750138349e8f1c036174fa4", "size": 10992, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quick-reference/chapters/mathdoc.tex", "max_stars_repo_name": "tinpark/faustdoc", "max_stars_repo_head_hexsha": "31c0492291d1bc71dc5c6f8d4ad6eed04776cf04", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-06-28T14:23:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-12T20:15:37.000Z", "max_issues_repo_path": "quick-reference/chapters/mathdoc.tex", "max_issues_repo_name": "tinpark/faustdoc", "max_issues_repo_head_hexsha": "31c0492291d1bc71dc5c6f8d4ad6eed04776cf04", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-09-22T07:11:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-22T07:32:27.000Z", "max_forks_repo_path": "quick-reference/chapters/mathdoc.tex", "max_forks_repo_name": "tinpark/faustdoc", "max_forks_repo_head_hexsha": "31c0492291d1bc71dc5c6f8d4ad6eed04776cf04", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-12-01T11:34:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-01T14:02:06.000Z", "avg_line_length": 44.8653061224, "max_line_length": 440, "alphanum_fraction": 0.7573689956, "num_tokens": 2899, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070808, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.4277294932814667}}
{"text": "%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Problem Set/Assignment Template to be used by the\n%% Food and Resource Economics Department - IFAS\n%% University of Florida's graduates.\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Version 1.0 - November 2019\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Ariel Soto-Caro\n%%  - asotocaro@ufl.edu\n%%  - arielsotocaro@gmail.com\n%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%Numbered environment\n\n\n\n\n\\documentclass[12pt]{article}\n\\usepackage{design_ASC}\n\\theoremstyle{definition}\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{slo}{Solution}[section]\n\\newcommand*{\\Perm}[2]{{}^{#1}\\!P_{#2}}%\n\\newcommand*{\\Comb}[2]{{}^{#1}C_{#2}}%\n%% -----------------------------\n%% TITLE\n%% -----------------------------\n\\title{\\textbf{Lecture 3}} %% Assignment Title\n\n\\author{\\textbf{Ibrahim} Abou Elenein}\n\n\\date{\\today} %% Change \"\\today\" by another date manually\n%% -----------------------------\n%% -----------------------------\n\n%% %%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\setlength{\\droptitle}{-5em}    \n%% %%%%%%%%%%%%%%%%%%%%%%%%%\n\\maketitle\n% --------------------------\n% Start here\n% --------------------------\n\n% %%%%%%%%%%%%%%%%%%%\n\\section{Sample Spaces}\nThe set of all possible outcomes of a random\nexperiment is called a \\textit{sample space}\n\\section{Events}\nAn event E, is a set of some outcomes of a\nprobability experiment, i.e. a subset of the sample\n\\[\n    E \\subseteq S\n\\]\nIf an event E contains no outcomes, then E is an impossible event.\n\n\\section{Probability}\n\\[\n    P(E) = \\frac{N(E)}{N(S)}\n\\]\n\\[\n    0 \\leq P (E) \\leq 1  ;  \\ P(S) = 1 \n\\]\n\\begin{exmp}\n    A card is drawn from a standard deck.\n    Find the probabilities of the following events.\n    \\begin{itemize}\n        \\item Getting a queen.\n        \\item Getting a club.\n        \\item Getting a number.\n    \\end{itemize}       \n\n\\end{exmp}    \n\\begin{slo}\n    \\[\n        |S| = 52\n    \\]\n    E1 is the event of getting a queen,\n    $\\displaystyle P(E1) = \\frac{|E1|}{|S|} = \\frac{4}{52}=  \\frac{1}{13}$\n    \\\\ \n    E2 is the event of getting a club,\n    $\\displaystyle P(E2) = \\frac{|E2|}{|S|} = \\frac{13}{52}=  \\frac{1}{4}$ \\\\\n    E3 is the event of getting a number,\n    $ \\displaystyle P(E3) = \\frac{|E3|}{|S|} = \\frac{40}{52}=  \\frac{10}{13}$ \\\\\n\n\n\\end{slo}\n\n\\section{Counting Rules}\n\\subsection{Multiplication Rule}\nIn a sequence of two experiments, if the\nfirst experiment can occur in $m$ different\nways and the second one can occur in $n$\ndifferent ways, then the whole sequence\ncan occur in $m \\times n$  different ways.\n\\begin{exmp}\n\n    Consider the manufacturing of:\n    number-plates consisting of two letters followed by four digits\n    \\begin{enumerate}\n        \\item  How many plates are possible?\n            \\[\n                26 \\times 26 \\times 10 \\times 10 \\times 10 \\times 10 = 6760000\n            \\]\n        \\item How many plates are possible, if no letter or digit can be repeated?\n            \\[\n                26 \\times 25 \\times 10 \\times 9 \\times 8 \\times 7 = 3276000 \n            \\]\n    \\end{enumerate}\n\n\\end{exmp}\n\n\\begin{exmp}\n    In a class of 10 students, 6 are to be chosen and seated in a row for a\n    picture.\n    How many different pictures are possible?\n    \\[\n        10 \\times 9 \\times 8 \\times 7 \\times 6 \\times 5 \\ different \\  pictures.\n    \\]\n    \\textbf{Tip} what if they were to sit in a circle?\n\\end{exmp}\n\n\\subsection{Permutaion}\nAn arrangement of $n$ objects \\textsc{ a specific order} using $k$ objects at a time is\ncalled a permutation and it is denoted by $\\Perm{n}{k}$. \nThe number of repetition-free\npermutations (linear arrangements) of size $k$ from a set of $n$ distinct objects\nis given by:\n\\[\n    \\Perm{n}{k} = \\frac{n!}{(n - k)!}; \\ \\ 0 \\leq k \\leq n\n\\]\n\n\\subsection{Combination}\nA selection of $k$ distinct objects \\textsc{without regard to order} out of $n$\nobjects is called a combination and it is denoted by $\\Comb{n}{k} $\nThe number of repetition-free combinations of size k from n distinct objects is given:\n\\[\n    \\Comb{n}{k} = \\frac{\\Perm{n}{k}}{k!} = \\frac{n!}{(n - k)!k!}; \\ \\  0 \\leq k \\leq n\n\\]\n\\subsection{Problems}\n\\begin{exmp}\n\n\\end{exmp}    \n\\begin{exmp}\n    In a class of 10 students, three are to be chosen to represent the class in a\n    competition.  How many selections are possible? \\\\\n\n    Note that, here, the students are not selected in any \n    specific order.\n\n    The number of selections is $\\Comb{10}{3} $\n\n\\end{exmp}    \n\n\\begin{exmp}\n    A student is taking a Math-401 test in which 7 questions out of 10 are to be\n    answered. In how many ways can the student answer the exam if :\n\\end{exmp}    \n\\begin{enumerate}\n    \\item Any 7 questions may be selected.\n        \\begin{center}\n            The student can answer the exam in $\\Comb{10}{7}$\n        \\end{center}\n    \\item The first 2 questions must be selected.\n        \\begin{center}\n            The student can answer the exam in $\\Comb{8}{5}$\n        \\end{center}\n    \\item The student must choose 3 questions from the first 5 and 4 questions from the\n        \\begin{center}\n            The student can answer the exam in $\\Comb{5}{3} \\times \\Comb{5}{4} = 50$\n        \\end{center}\n\\end{enumerate}       \n\n\n\\begin{exmp}\n    What is the number of (possibly meaningless) words that are made up of all the\n    letters in the word \\textbf{chemistry}\n\\end{exmp}    \n\\begin{center}\n    The number of such words id $\\Perm{9}{9}$\n\\end{center}\n\n\\begin{exmp}\n    What is the number of permutations of the letters in the word \\textbf{ball}?\n    \\begin{center}\n        Note that there are repeated letter so it's not 4 distinct objects.\n    \\end{center}    \n    \\begin{center}\n        The number of permutations is $\\displaystyle  \\frac{\\Perm{4}{4}}{2!} = 12$\n    \\end{center}    \n\\end{exmp}    \n\n\\begin{exmp}\n    What is the number of permutations of the letters in the word \\textbf{Pepper}?\n\n    \\begin{center}\n        The number of permutations is $\\displaystyle  \\frac{\\Perm{6}{6}}{2!3!}$\n    \\end{center}   \n\\end{exmp}    \n\n\\begin{exmp}\n    The owner of a pizzeria prepares every pizza by always combining 4 different\n    ingredients. How many ingredients does he need, at least, if he would like to\n    offer 30 different pizzas in the menu?\n    \\begin{center}\n        we need to find $n$ such that $\\Comb{n}{4} = 30$ \n    \\end{center}    \n    \\begin{center}\n        $\\displaystyle \\frac{n!}{(n-4)!4!} = 30$ \\\\\n    \\end{center}    \n    \\begin{center}\n        $\\displaystyle \\frac{n(n-1)(n-2)(n-3)(n-4)!}{(n-4)!} = 30 \\times 4!$\n    \\end{center}    \n    \\begin{center}\n        $\\displaystyle n(n-1)(n-2)(n-3) - 720 = 0$ \\\\\n\n        By solving the equation $n = 6.8 \\Rightarrow $he needs at least 7 ingredients\n    \\end{center}    \n\n\\end{exmp}    \n\n\\begin{exmp}\n    You play a simple card game. You draw 3 cards. If any of them is a King or\n    the three cards are of the same suit, you win otherwise you lose.\n    How many hands are you winning? \n    \\begin{center}\n        A = draw at least one king in a hand of 3 cards \\\\\n        N(A) = One King or Two or Three = \\\\\n        $ (\\Comb{4}{1} \\times \\Comb{48}{2})+ (\\Comb{4}{2} \\times \\Comb{48}{1})\n        + (\\Comb{4}{3} \\times \\Comb{48}{0})\n        $\n    \\end{center}    \n    \\begin{center}\n        B = A hand draw 3 cards with  same suit \\\\\n        $N(B) = \\Perm{4}{1} \\times \\Perm{13}{3}$ \\\\\n    \\end{center}   \n    \\begin{center}\n        $A \\cap B$ = a hand with draw 3 cards with a king and the same suit.\n        $N(A \\cap B) = \\Comb{4}{1} \\times \\Comb{1}{1} \\Comb{12}{2}  $\n    \\end{center}   \n    \\begin{center}\n        $N(A \\cup  B) = N(A) + N(B) - N(A \\cap B) = 5684.$    \n    \\end{center}\n\\end{exmp}    \n\n\\begin{exmp}\n    In how many ways you can arrange the word “ORANGE”, if: \n    \\begin{itemize}\n        \\item 2 vowels and 2 consonants are used to make 4-letter words.  \n            \\begin{center}\n                No.of ways = $\\Comb{3}{2} \\times \\Comb{3}{2} \\times 4! $\n            \\end{center}   \n        \\item 2 vowels and 3 consonants are used to make 5-letter words. \n            \\begin{center}\n                No.of ways = $\\Comb{3}{2} \\times \\Comb{3}{3} \\times 5! $\n            \\end{center}   \n        \\end{itemize}\n\\end{exmp}\n\\begin{exmp}\n    There are 8 men and 9 women on a committee selection pool.\n    A committee consisting of:\n    a president, a vice-president, and 3 coordinators; is to\n    be formed.  \n    In how many ways can exactly three women be on the committee?\n    \\begin{center}\n        $\\displaystyle N = \\Comb{9}{3} \\times \\Comb{8}{2}  \\times [\\frac{5!}{3!}]$  \n    \\end{center}\n\n\\end{exmp}    \n\\end{document}\n", "meta": {"hexsha": "a64f0e9c5153c7205ba9745a2813a74f51ead510", "size": 8594, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture3/main.tex", "max_stars_repo_name": "AhmedNasserG/math401-notes", "max_stars_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture3/main.tex", "max_issues_repo_name": "AhmedNasserG/math401-notes", "max_issues_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture3/main.tex", "max_forks_repo_name": "AhmedNasserG/math401-notes", "max_forks_repo_head_hexsha": "3e3acaaf77384609025d4bc6ccd146f3d06808e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8296296296, "max_line_length": 87, "alphanum_fraction": 0.5814521759, "num_tokens": 2608, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.42761993347792027}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\\usepackage{algorithm, algpseudocode, amsmath, amssymb, caption, csquotes, empheq, geometry, graphicx, hyperref, listings, multirow, physics, siunitx, subcaption, upgreek}\n\\usepackage[section]{placeins}\n\n\\title{Computational Physics\\\\Problem Set 3}\n\\author{Saleh Shamloo Ahmadi\\\\Student Number: 98100872}\n\\date{October 17, 2021}\n\n\\hypersetup{colorlinks=true, urlcolor=cyan}\n\n\\newcommand{\\bdfig}{../fig/ballistic-deposition}\n\\newcommand{\\pfig}{../fig/percolation}\n\n\\begin{document}\n\t\\maketitle\n    \\section{Ballistic Deposition}\n    Ballistic deposition models add particles randomly to a surface and in the case of non-random\n    ballistic deposition models, apply specific rules after each \\enquote{deposition}.\n\n    In general, we can approximately describe the growth of each model with the constants $\\alpha$, $\\beta$,\n    and $z$ (not independent); If there is any interaction between neighboring points, the roughness of the\n    surface (defined as the standard deviation of heights in one-dimensional systems) will approach an upper limit\n    $w_s$ ($w(t)$ is the roughness) at \\emph{time of saturation} $t_s$. Then\n    \\begin{gather}\n        w(t) \\sim t^\\beta (\\text{before saturation}), \\\\\n        t_s \\sim L^z, \\quad w_s \\sim L^\\alpha \\sim t_s^\\beta \\sim L^{z\\beta},\n    \\end{gather}\n    so we should have $\\alpha = z\\beta$. Note that depending on the method used to determine saturation time, $\\beta$\n    before saturation can be different form $\\beta$ obtained from saturation.\n\n    \\subsection{Ballistic Deposition with Relaxation}\n    In this model, after each deposition, the particle is dropped onto a neighboring point if it is at a lower height\n    (less particles have been deposited on that point). If more than one neighbor has a lower height, the particle is\n    dropped onto the point with the lowest height.\n\n    The faint \\enquote{bands} in each plot shows the standard deviation of each data point taken over all runs.\n    \\newgeometry{top=0.1in, bottom=1in}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-vis}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-mean}\n        \\caption{$\\text{slope}=0.005\\pm\\num{6e-20}$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-roughness-200}\n        \\caption{$\\beta=0.224\\pm0.001$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-roughness-100}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-roughness-50}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-roughness-25}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-roughness-12}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-sat-alpha}\n        \\caption{$\\alpha = 0.500\\pm0.003$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-sat-z}\n        \\caption{$z = 3.02\\pm0.04$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-relax-sat-beta}\n        \\caption{$\\beta = 0.165\\pm0.002$}\n    \\end{figure}\n    \\restoregeometry\n    \\begin{table}[htb!]\n        \\centering\n        \\caption{Ballistic Deposition with Relaxation}\n        \\begin{tabular}{|c|c|c|}\n            \\hline\n            $L$ & $t_s$ & $w_s$ \\\\\n            \\hline\n            12 & 108 & 0.759364 \\\\\n            \\hline\n            25 & 837 & 1.07834 \\\\\n            \\hline\n            50 & 8550 & 1.53467 \\\\\n            \\hline\n            100 & 63042 & 2.18055 \\\\\n            \\hline\n            200 & 502161 & 3.08905 \\\\\n            \\hline\n        \\end{tabular}\n    \\end{table}\n    I calculated the time of saturation by fitting a line through the trailing points with constant $w(t)$.\n    This method is not optimal. It would be better to find the intersection of the linear fit and constant fit lines.\n    Due to a lack of time, I am unfortunately stuck with this (this was the first method I tried and there was no time\n    left before the deadline to improve my methodology).\n\n    As you can see, this description of the model is not perfect, since $\\beta$ is not the same as $L$ changes.\n    \\subsection{Ballistic Deposition (regular)}\n    In this model, particles stick to the first point they come in contact with. This means each particle will be stuck\n    at the maximum heigh in its dropping neighborhood\n    ($\\text{max}\\{h_{\\text{left}}, h_{\\text{drop}} + 1, h_{\\text{right}}\\}$).\n\n    Results have similar characteristics to the last model. Notably, $\\beta$ obtained from saturation is equal\n    within the margin of error and $\\beta$ obtained from ftting to data is also very close. $\\alpha$ and $z$ are\n    smaller, since correlation is stronger in this model (height of each point is directly related to the neighboring\n    heights, instead of being indirectly affected by them through the distribution of heights).\n    \\begin{table}[hbt!]\n        \\centering\n        \\caption{Ballistic Deposition (regular)}\n        \\begin{tabular}{|c|c|c|}\n            \\hline\n            $L$ & $t_s$ & $w_s$ \\\\\n            \\hline\n            12 & 107 & 2.42859 \\\\\n            \\hline\n            25 & 406 & 2.84437 \\\\\n            \\hline\n            50 & 2715 & 4.20796 \\\\\n            \\hline\n            100 & 12386 & 4.94841 \\\\\n            \\hline\n            200 & 65003 & 6.75316 \\\\\n            \\hline\n        \\end{tabular}\n    \\end{table}\n    \\newgeometry{top=0.1in, bottom=1in}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-vis}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-mean}\n        \\caption{$\\text{slope}=\\num{1.0698e-2}\\pm\\num{9e-6}$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-roughness-200}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-roughness-100}\n        \\caption{$\\beta=0.254\\pm0.003$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-roughness-50}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-roughness-25}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-roughness-12}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-sat-alpha}\n        \\caption{$\\alpha = 0.37\\pm0.03$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-sat-z}\n        \\caption{$z = 2.31\\pm0.07$}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-sat-beta}\n        \\caption{$\\beta = 0.161\\pm0.008$}\n    \\end{figure}\n    \\restoregeometry\n    \\subsubsection{Correlation Length}\n    In the ballistic deposition model, each point can have long range effect on further points through clustering with\n    its neighbors, which in turn cluster with their own neighbors, and so on. To find the range of interaction, or\n    \\emph{the correlation length}, we can isolate the particles that stem from a single point\n    (the \\enquote{tree} attached to a \\enquote{seed}).\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-iso-vis}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\bdfig/bd-correlation}\n        \\caption{$\\text{slope} = 0.522\\pm0.002$.\\\\The slope is the growth exponent for of the correlation length.}\n    \\end{figure}\n    \\section{Percolation}\n    \\subsection{Depth-First Search}\n    Using a modified version of the depth-first search algorithm (a.k.a. DFS) that is designed and optimized for grids,\n    percolation problems can be solved efficiently (time complexity $\\mathcal{O}(L^d)$, where L is the lenght\n    of the grid and d is the number of dimentions). Algorithm \\ref{alg:dfs} outlines the implementation.\n    \\begin{algorithm}\n        \\caption{DFS for solving a percolation problem}\n        \\label{alg:dfs}\n        \\begin{algorithmic}[1]\n            \\Function{DFS}{$G$} \n            \\parbox[t]{0.75\\linewidth}{\\Comment{G is a boolean graph representing the empty/full states\n            of each cell of the grid}}\n                \\State make stack $S$\n                \\ForAll{vertices $v$ \\textbf{in} the starting row/column of the grid}\n                    \\If{$v$ \\textbf{is} \\textit{true}}\n                        \\State $S.push(v)$\n                        \\While{$S$ is not empty}\n                            \\State v = $S.pop()$\n                            \\If{$v$ is in the final row/column}\n                                \\State \\textbf{return} \\textit{true}\n                            \\ElsIf{$v$ is not already visited}\n                                \\State mark $v$ as visited\n                                \\ForAll{$w$ \\textbf{in} $G.neighbors(v)$}\n                                \\State $S.push(w)$\n                                \\parbox[t]{0.6\\linewidth}{\\Comment{Prioritize the neighbor in the direction of\n                                the percolation's destination to optimize the performance for emptier grids}}\n                                \\EndFor\n                            \\EndIf\n                        \\EndWhile\n                    \\EndIf\n                \\EndFor\n                \\State \\textbf{return} \\textit{false}\n            \\EndFunction\n        \\end{algorithmic}\n    \\end{algorithm}\n    \\newgeometry{left=0in, right=0in}\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/dfs-55}\n        \\end{subfigure}\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/dfs-60}\n        \\end{subfigure}\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/dfs-58}\n        \\end{subfigure}\n    \\end{figure}\n    \\restoregeometry\n    \\subsection{Coloring}\n    We can use (a very inefficient\\footnote{$\\mathcal{O}(L^{2d})$ time complexity}) coloring algorithm, as described in\n    the lecture notes, to label the clusters in the grid. Then, If a cluster connecting the two ends of the grid exists,\n    percolation is possible.\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/color-45}\n        \\end{subfigure}\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/color-50}\n        \\end{subfigure}\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/color-55}\n        \\end{subfigure}\n        \\begin{subfigure}{0.45\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/color-60}\n        \\end{subfigure}\n    \\end{figure}\n    \\subsection{Hoshen--Kopelman}\n    This is a much more efficient $\\mathcal{O}(L^d)$ algorithm for labeling the clusters. You can read more about it\n    on the \\href{https://en.wikipedia.org/wiki/Hoshen%E2%80%93Kopelman_algorithm}{Wikipedia page}.\n    \\newgeometry{top=0.3in, bottom=0.3in, left=1in, right=1in}\n    \\thispagestyle{empty}\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}{\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/hk-50}\n        \\end{subfigure}\n        \\begin{subfigure}{\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/hk-55}\n        \\end{subfigure}\n        \\begin{subfigure}{\\linewidth}\n            \\centering\n            \\includegraphics[width=\\linewidth]{\\pfig/hk-60}\n        \\end{subfigure}\n    \\end{figure}\n    \\restoregeometry\n    \\subsubsection{Percolation Probability}\n    The probablity of there existing a path from the top to the bottom of a lattice (denoted by $Q$) exhibits critical\n    behavior; If $p$ is the probablity of forming bonds (or sites) in the lattice, then is a sudden jump from 0 to 1\n    probablity at a critical probablity $p_c$. In an infinite lattice, the path connecting the top and bottom of\n    the lattice is called the \\emph{infinite open cluster}.\n\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-full-10}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-full-100}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-full-200}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-zoom-10}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-zoom-100}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-zoom-200}\n    \\end{figure}\n\n    As you can see, the transition from 0 to 1 probablity at $p_c$ becomes sharper as the side-length of the lattice\n    increases.\n\n    We use $Q_\\infty$ to denote the probablity of a cell being a part of an open cluster connecting the top and bottom\n    of the lattice. To calculate $Q_\\infty$, we can modify the Hoshen--Kopelman algorithm to record cluster sizes for\n    every label (that is, the \\enquote{root} labels, or the final label that the cluster is connected to, such that\n    $\\mathrm{Label(number) = number}$). Then, $Q_\\infty$ will be the sum of the sizes of the open clusters devided by\n    the surface area of the lattice.\n\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-qinfty-10}\n    \\end{figure}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\linewidth]{\\pfig/percolate-qinfty-100}\n    \\end{figure}\n\n    As you can see, $Q_\\infty$ exhibits the same critical behavior as $Q$.\n\\end{document}\n", "meta": {"hexsha": "5b59d4a128823e0672757e69108d53ac2e82c464", "size": 14501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ps3-ballistic-deposition-percolation/report/ps3-ballistic-deposition-percolation.tex", "max_stars_repo_name": "slhshamloo/comp-phys", "max_stars_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ps3-ballistic-deposition-percolation/report/ps3-ballistic-deposition-percolation.tex", "max_issues_repo_name": "slhshamloo/comp-phys", "max_issues_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ps3-ballistic-deposition-percolation/report/ps3-ballistic-deposition-percolation.tex", "max_forks_repo_name": "slhshamloo/comp-phys", "max_forks_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.031884058, "max_line_length": 171, "alphanum_fraction": 0.6259568306, "num_tokens": 4015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.4275115378789251}}
{"text": "\\input{../../utils/header.tex}\n\n\\begin{document}\n\n\\title{Machine Learning (41204-01)\\\\HW \\#7}\n\\author{Will Clark and Matthew DeLio \\\\\n\\textsf{\\{will.clark,mdelio\\}@chicagobooth.edu} \\\\\nUniversity of Chicago Booth School of Business}\n\\date{\\today}\n\\maketitle\n\n\\section{Zachary's Karate Club}\n\nZachary's Karate Club is a network describing a university karate club from the early 1970's. The network has 34 vertices and 78 edges as depicted in \\cref{fig:karate_network}. The network was observed and described by Wayne W. Zachary during and after it split into two factions (led by John A and Mr. Hi, denoted with blue circles and red squares, respectively). Because we know the features of the network and the factions into which it split, it is an ideal data set on which to test out various community detection algorithms.\n\n\\begin{figure}[!htb]\n\\centering\n\\caption{Zachary's Karate Club and Factions}\n\\includegraphics[scale=.5,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{karate_network.pdf}\n\\label{fig:karate_network}\n\\end{figure}\n\nWe used the algorithms listed below to try and determine the underlying community structure in Zachary's karate club. The results are visualized in \\cref{fig:edge_betweenness}-\\cref{fig:walktrap}. The hierarchical algorithm can be cut into two groups and compared directly to the ground truth of the observed factions, but algorithms with more groups are tougher to evaluate. If an algorithm produces more than two groups, as long as the groups are contained entirely within one faction or the other, we consider there to be no mis-classifications. In the associated figures, members of Mr. H's faction are in squares and members of John A's faction are in circles; the colors are set according to algorithmically-determined groups.\n\\begin{itemize}\n\\item \\textbf{Edge Betweenness}: A hierarchical algorithm that we cut to obtain two groups. The default setting is for the algorithm to consider the network edge weights, but in doing so the algorithm misclassifies two vertices (Actors 3 and 14; see \\cref{fig:edge_betweenness}). By ignoring the edge weights, the algorithm only mis-classifies one vertex (Actor 3). \n\\item \\textbf{Greedy Modularity Optimization (Fast Greedy)}: A hierarchical algorithm that we cut to obtain two groups. It correctly predicts the faction for all vertices (see \\cref{fig:fast_greedy}).\n\\item \\textbf{Infomap}: A non-hierarchical algorithm that splits the data into 3 groups. Two groups are made entirely of members from Mr. Hi's faction (see \\cref{fig:infomap}).\n\\item \\textbf{Propagating Labels}: A non-hierarchical algorithm that splits the data into 3 groups. Two groups are made entirely of members from Mr. Hi's faction. It classifies the networks into the same groups as the Infomap algorithm (see \\cref{fig:label_prop}).  \n\\item \\textbf{Leading Eigenvector}: This is another hierarchical algorithm, although the basic \\textsf{cutat} function produces an error when we attempt to break the network into two communities.\\footnote{\\textsf{Warning message: In cutat(cl, 2) : Cannot have that few communities}} As an alternative, we visualize the network as a dendrogram and use the two largest branches as our estimate of the factions. The restuls are not good; five actors in each group are mis-categorized. The results are in \\cref{fig:leading_eigen}. This is far and away the worst algorithm for this data set, although it may be because of the implementation in \\textsf{igraph}.\n\\item \\textbf{Multi-level Modularity Optimization (Louvain)}: A non-hierarchical algorithm that splits the data into 4 groups. Two groups are made entirely of members from Mr. Hi's faction and two groups are made entirely of members from John A's faction. This algorithm breaks Mr. Hi's faction into the same groups that the Infomap and Propagating Labels algorithms do (see \\cref{fig:louvain}).\n\\item \\textbf{Optimal Structure}: A non-hierarchical algorithm that splits the data into 4 groups. The four groups are identical to those identified by the Multi-Level Modularity Optimization algorithm above (see \\cref{fig:optimal}).\n\\item \\textbf{Statistical Mechanics (Spinglass)}: A non-hierarchical algorithm that splits the data into 4 groups. The groups are nearly the same as those identified in the Optimal Structure and Multi-Level Modularity Optimation algorithms, except Actor 24 has switched groups within John A's faction (see \\cref{fig:spinglass}).\n\\item \\textbf{Short Random Walks (Walktrap)}: A hierarchical algorithm that we cut to obtain two groups. It correctly predicts the faction for all vertices (see \\cref{fig:walktrap}).\n\\end{itemize}\nUltimately, all algorithms besides the Edge Betweenness and Leading Eigenvector algorithm correctly break the network into the correct groups, either the observed factions or subsets of the observed factions.\n\n%%%%%%%%%%%%%%%%%%%% KARATE COMMUNITY GRAPHS %%%%%%%%%%%%%%%%%%%%\n\\begin{figure}\n\\centering\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Edge Betweenness}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{edge_betweenness.pdf}\n\\label{fig:edge_betweenness}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Greedy Optimization}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{fast_greedy.pdf}\n\\label{fig:fast_greedy}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Infomap}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{infomap.pdf}\n\\label{fig:infomap}\n\\end{subfigure}\n\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Propagating Labels}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{label_prop.pdf}\n\\label{fig:label_prop}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Leading Eigenvector}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{leading_eigen.pdf}\n\\label{fig:leading_eigen}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Multi-level Optimization}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{louvain.pdf}\n\\label{fig:louvain}\n\\end{subfigure}\n\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Optimal Structure}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{optimal.pdf}\n\\label{fig:optimal}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Statistical Mechanics}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{spinglass.pdf}\n\\label{fig:spinglass}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[b]{0.32\\textwidth}\n\\caption{Short Random Walks}\n\\includegraphics[width=\\textwidth,trim={0.75in 0.75in 0.75in 0.75in}, clip=True]{walktrap.pdf}\n\\label{fig:walktrap}\n\\end{subfigure}\n\\caption{Community Detection Algorithms for Zachary's Karate Club}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Wikipedia}\n\\subsection{Clustering}\nDue to the size of and the time required to cluster our data-set, we apply only one of the better performing algorithms from the previous section.  Of two that correctly partitioned the Karate data in the previous section (\\textbf{Greedy} and \\textbf{Short Random Walk}) we choose to apply \\textbf{Short Random Walk} here.\n\nBefore looking at the results of the clustering algorithm, we first look at node connectedness to see if we can learn anything we can learn from these data.  \\Cref{fig:wiki_conn} shows that many articles have a few connections and few nodes have many connections with a, roughly, linear decline between these two extremes in log-log space.  Because of the large number of poorly connected articles, we'd expect the clustering algorithm to generate a large number of small clusters as it struggles to find common groups for these articles.  Likewise we expect that the well-connected clusters should be easily identifiable and clustered together.  \\Cref{fig:wiki_size} shows a histogram of the cluster-size; as we predict we do see a large number of small clusters.\n\n\\begin{figure}[!htb]\n  \\centering\n  \\begin{subfigure}[b]{0.49\\textwidth}\n    \\caption{Vertex Connectedness}\n    \\includegraphics[width=\\textwidth]{wiki_edge_hist.pdf}\n    \\label{fig:wiki_conn}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.49\\textwidth}\n    \\caption{Cluster-Size}\n    \\includegraphics[width=\\textwidth]{wiki_cl_hist.pdf}\n    \\label{fig:wiki_size}\n  \\end{subfigure}\n  \\caption{Cluster and Node Histograms}\n\\end{figure}\n\nWe examine the largest 4 clusters to see how well a sample of the topics (see \\cref{tab:wiki_topics}).  Very roughly, it appears that the topics are clusters as follows:\n\\begin{itemize}\n\\item \\textbf{\\#5} Mathematics (Number Theory)\n\\item \\textbf{\\#11} Physics / Politics - This cluster appears to be fairly poorly formed\n\\item \\textbf{\\#19} Chemistry\n\\item \\textbf{\\#20} Telecommunications\n\\end{itemize}\n\nWhile not perfect, it appears as though the random walk clustering algorithm does a decent job finding relationships between articles within the graph network.  While difficult to visualize, \\cref{fig:wiki_clust} attempts to show the largest 8 clusters along with a couple of the most connected-topics selected from each.\\footnote{This was done in an attempt to separate, spatially, the article labels}\n\n\\begin{figure}[!htb]\n  \\centering\n  \\caption{Visual Representation of the Largest 8 Clusters}\n  \\includegraphics[width=\\textwidth]{wiki_clust.pdf}\n  \\label{fig:wiki_clust}\n\\end{figure}\n\n\\input{wiki_topics.tex}\n\n\\begin{appendices}\n\n\\end{appendices}\n\n\\end{document}\n\n% \\input{.tex}\n\n% \\begin{figure}[!htb]\n%   \\centering\n%   \\begin{subfigure}[b]{0.49\\textwidth}\n%     \\caption{}\n%     \\includegraphics[width=\\textwidth]{.pdf}\n%     \\label{fig:}\n%   \\end{subfigure}\n%   \\hfill\n%   \\begin{subfigure}[b]{0.49\\textwidth}\n%     \\caption{}\n%     \\includegraphics[width=\\textwidth]{.pdf}\n%     \\label{fig:}\n%   \\end{subfigure}\n%   \\caption{}\n% \\end{figure}\n\n% \\begin{figure}[!htb]\n%   \\centering\n%   \\caption{}\n%   \\includegraphics[scale=.5]{.pdf}\n%   \\label{fig:}\n% \\end{figure}\n\n", "meta": {"hexsha": "4c73473c91f78fcc1c42d95c7a98316365ba4a35", "size": 10070, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw7/writeup/hw7.tex", "max_stars_repo_name": "wclark3/machine-learning", "max_stars_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw7/writeup/hw7.tex", "max_issues_repo_name": "wclark3/machine-learning", "max_issues_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw7/writeup/hw7.tex", "max_forks_repo_name": "wclark3/machine-learning", "max_forks_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-02-23T00:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-18T13:16:58.000Z", "avg_line_length": 59.5857988166, "max_line_length": 764, "alphanum_fraction": 0.7649453823, "num_tokens": 2757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.600188373563072, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.42747347625764776}}
{"text": "\\newpage{}\n\n\\hypertarget{quality-assurance}{%\n\\section{Quality Assurance}\\label{quality-assurance}}\n\nNow if we create algorithms we need to say how good they are. For that\nwe are using the following methods.\n\n\\hypertarget{the-graphical-approach}{%\n\\subsection{The graphical approach}\\label{the-graphical-approach}}\n\nOne easy way would be to draw a graph which shows the predictions and\nthe real values for time spent, while each task is understood as a\ncategory of its own.\n\nWe sort that graph by actual duration so we should see the distribution\nof durations and around that a hopping range of dots that describes what\nthe algorithm tells us.\n\nA better algorithm should be closer to the real data. Any algorithm\nshould never match perfectly, as then we would have a 1:1 mapping. And\nthat is an over-fit for sure.\n\n\\hypertarget{mean-squared-error}{%\n\\subsection{Mean squared error}\\label{mean-squared-error}}\n\nThe mean squared error is a common approach to calculate a value for the\nquality of an algorithmi. It gets bigger with every estimate we did\nwrong.\n\nThe formula can be described as:\n\nFor every value you predict:\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Calculate the difference between the predicted value and the real\n  value\n\\item\n  Sum the squares of each difference\n\\item\n  Divide all the sum by the count of the data entries you check\n\\end{itemize}\n\nNow, since we want to prevent overfitting we need to prevent\nunderfitting as well. Since we are talking about seconds and most of the\nrecorded tasks have a duration in the range of up to 50000 seconds that\nmeans that most tasks are completed in about 13,89 hours. So what about\nan error margin of about 5 hours. Which means just as something to think\nof, we want the squared error to not exceed squared(5x60x60) =\n324.000.000 .\n\n\\hypertarget{above-and-below}{%\n\\subsection{Above and below}\\label{above-and-below}}\n\nAs a third criteria we have the idea that estimations might even each\nother out. In a prefect scenario this would mean that 50\\% of the\nestimations are too high while the other 50\\% are too low. To find out\nhow good we match we add 1 to a variable for every estimation we find\nabove the real value and then divide it by the number of tasks. The\nresult should be .5 when hitting the target.\n\n\\hypertarget{the-data}{%\n\\subsection{The Data}\\label{the-data}}\n\nFor training and estimating the quality of algorithms I use herein a\ndataset that consists of all the tasks that we at the software\ndevelopment shop at my employer recorded during the time between july\nand december 2020 and january 2021 to august 2021. That means there are\ntwo datasets available.\n\nUnfortunately - since this is confidential information - I cannot\npublish it alongside this material. But the errors and images can be\nshared at it can advance the algorithms - and it is everything that I\nhave right now. So that will do.\n\nI'll call them: swe2020 and swe2021.\n\nNow let us get a glance at the data as well the first algorithm.\n", "meta": {"hexsha": "a515ecf5aba0ea3648c1b4eaea1f41ec941fe0ec", "size": 2972, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/00002-Quality-Assurance/index_fr.tex", "max_stars_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_stars_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-09-12T17:24:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-22T06:43:27.000Z", "max_issues_repo_path": "Documentation/00002-Quality-Assurance/index_fr.tex", "max_issues_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_issues_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 52, "max_issues_repo_issues_event_min_datetime": "2021-08-13T00:24:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-26T10:01:19.000Z", "max_forks_repo_path": "Documentation/00002-Quality-Assurance/index_fr.tex", "max_forks_repo_name": "stho32/Automatically-Estimating-Task-Durations", "max_forks_repo_head_hexsha": "4f63d75dd56f56c05d9a046b98f21cff04971a08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.6913580247, "max_line_length": 72, "alphanum_fraction": 0.7849932705, "num_tokens": 714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.4274734485515707}}
{"text": "\\documentclass[]{article}\n\\usepackage{amsmath}\n\\usepackage{xcolor}\n\\newtheorem{Def}{Definition}\n%opening\n\\title{MTH 343 Numerical Analysis Lecture 2: Review of Computer Arithmetic}\n\\author{Sheikh Abdul Raheem Ali}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Remarks}\n\n\\begin{enumerate}\n\t\\item Numerical Analysis requires such tedious \\& repetitive operations that only a computer can perform quickly \\& without and mistakes.\n\t\\item Computers are dumb and must be given complete instructions of every step. Programs can be written in any language you like. \n\t\\item Writing code is not very important because extensive commercial software packages are available. \n\t\t\\begin{enumerate}\n\t\t\t\\item IMSL: International Mathematics \\& Statistics Library\n\t\t\t\\item NAG: Numerical Algorithm Group\n\t\t\t\\item LAPACK: Linear Algebra package\n\t\t\\end{enumerate}\t\n\t\tAlternatives: Computer Algebra Systems\n\t\t\\begin{enumerate}\n\t\t\t\\item Mathematica\n\t\t\t\\item Maple\n\t\t\t\\item MATLAB\n\t\t\\end{enumerate}\n\t\n\\end{enumerate}\n\n\\section*{Floating-Point Arithmetic}\n\nIn computers, numbers are stored as floating point quantities in the general form: \n\\[ \\pm \\cdot (d_1 d_2 d_3 \\ldots d_p) \\cdot \\beta^e, \\] where\n$ p $ = precision, the number of significant bits (digits), $ e $ = an integer exponent ranging from $ E_{min} $ to $ E_{max} $, $ \\beta $ = the number base, normally 2, 10, 16,\n$ d_i: $ ranges from 0 to $ \\beta - 1 $, and $ d_1 d_2 d_3 \\ldots d_p $ is called the fractional part (mantissa). \n\n\n\nSometimes numbers are normalized: $ 0.023 -> 0.23 \\cdot 10^{-1} $\n\nLet us examine the case $ \\beta = 10 $ (Decimal)\n\n\\begin{eqnarray*}\n\t3216 &=& 3\\cdot10^3 + 2\\cdot10^2 + 1\\cdot10^1 + 6\\cdot10^0\\\\\n\t&=& 10^4(3\\cdot10^{-1} + 2\\cdot10^{-2} + 1\\cdot10^{-3} + 6\\cdot10^{-4}) \\\\\n\t&=& (.3216)\\cdot10^4 \n\\end{eqnarray*}\n\n\n\nNow let us examine the case $ \\beta = 2 $ (Binary)\n\n\\begin{eqnarray*}\n65 &=& 2^6 + 2^0 \\\\\n      &=& 2^7(2^{-1}) + 2^{-7} \\\\\n &=&(.1000001)_2 \\cdot 2^7 \n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n\t23 &=& 2^4 + 2^3 + 2^2 \\\\\n\t&=& 2^5(2^{-1} + 2^{-2} + 2^{-3}) \\\\\n\t&=& (.111)_2 \\cdot 2^5\n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n\t  85 &=& 2^6 + 2^4 + 2^2 + 2^0 \\\\\n\t&=& 2^7(2^{-1} + 2^{-3} + 2^{-6} + 2^{-7}) \\\\\n\t&=& (.1010011)_2 \\cdot 2^7 \n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n\t5.75 &=& 2^2 + 2^0 + 2^{-1} + 2^{-2} \\\\\n\t&=& 2^3(2^{-1} + 2^{-3} + 2^{-4} + 2^{5}) \\\\\n\t&=& (.10111)_2 \\cdot 2^3 \n\\end{eqnarray*}\n\n\n\n\n\\[ 0.6 = (.1001100110011001\\ldots)_2 \\]\n\nThis last example shows us a conversion error: the decimal is recurring, but since the computer only has a finite number of bits, the value is truncated at some point.\n\n\\begin{Def}[Round off error:]\nThe error that is produced when a computer is used to perform real-number calculations is called round-off error.\n\\end{Def}\n\nThere are two ways of truncating the mantissa:\n\n\\begin{enumerate}\n\t\\item Chopping\n\t\\item Rounding \n\\end{enumerate}\n\nEx. $ 13.76573 = .1376 {\\bf{\\color{red} |}} 573 \\cdot 10^2 $\n\n4 digits chopping: $ .1376 \\cdot 10^2 $\n4 digits rounding: $ .1377 \\cdot 10^2 $\n\nNumbers are \\textbf{rounded} when stored in the floating point format.\n\n\\end{document}\n", "meta": {"hexsha": "c094fd91c581d334ad28b3144ec12e791eebc866", "size": 3088, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Numerical/Lecture_2/Lecture2.tex", "max_stars_repo_name": "sheikheddy/aus-files", "max_stars_repo_head_hexsha": "0c38d15d560ccbb8231c8ef210916ea94a0f004b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Numerical/Lecture_2/Lecture2.tex", "max_issues_repo_name": "sheikheddy/aus-files", "max_issues_repo_head_hexsha": "0c38d15d560ccbb8231c8ef210916ea94a0f004b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numerical/Lecture_2/Lecture2.tex", "max_forks_repo_name": "sheikheddy/aus-files", "max_forks_repo_head_hexsha": "0c38d15d560ccbb8231c8ef210916ea94a0f004b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.1320754717, "max_line_length": 177, "alphanum_fraction": 0.6609455959, "num_tokens": 1092, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832058771036, "lm_q2_score": 0.7931059438487663, "lm_q1q2_score": 0.42747078421579415}}
{"text": "%% LyX 1.5.6 created this file.  For more info, see http://www.lyx.org/.\r\n%% Do not edit unless you really know what you are doing.\r\n\\documentclass[english,preprint]{revtex4}\r\n\\usepackage[T1]{fontenc}\r\n\\usepackage[latin9]{inputenc}\r\n\\usepackage{graphicx}\r\n\\usepackage{babel}\r\n\r\n\\begin{document}\r\n\r\n\\title{MATLAB version of the APBS}\r\n\r\n\r\n\\date{\\today}\r\n\r\n\\begin{abstract}\r\nThis is the first version. This solver uses the biconjugate gradient\r\nstabilized method and the inexact LU decomposition to numerically\r\nsolve the linearized PB equation on the finest (target) 3D-grid. This\r\nversion requires the shifted dielectric and the ion accessibility\r\ncoefficient (kappa function) maps as generated by the APBS code as\r\nwell as the corresponding pqr file generated by the pdb2pqr code.\r\nIt uses standard three-linear splines (spl0) to spread the charge\r\ndensity along the nearest grid points if needed. The resulting electrostatic\r\npotential and charge maps are saved in dx format. For visualization\r\npurpose, this code also generates two files (.fig and .tiff) corresponding\r\nto the graphical representation of the electrostatic potential surface.\r\n\\end{abstract}\r\n\\maketitle\r\n\r\n\\subsection*{Description}\r\n\r\nThis code is based on Michel Holst's thesis and Nathan Baker's APBS\r\napproach. The box-method is used to discretize the following (linearized)\r\nPB equation \r\n\r\n\\begin{equation}\r\n-\\nabla.\\left(\\epsilon\\left(\\mathbf{r}\\right)\\nabla u\\left(\\mathbf{r}\\right)\\right)+\\bar{\\kappa}\\left(\\mathbf{r}\\right)u\\left(\\mathbf{r}\\right)=magic\\sum_{i=1}^{N}z_{i}\\delta\\left(\\mathbf{r}-\\mathbf{r}_{i}\\right)\\label{eq:one}\\end{equation}\r\n\r\n\r\nwhere $u\\left(\\mathbf{r}\\right)=e_{c}\\Phi\\left(\\mathbf{r}\\right)/K_{B}T$\r\nand $magic=4\\pi e_{c}^{2}/K_{B}T.$ For a diagonal dielectric tensor,\r\nthe resulting discretized linear PB equations at the nodes $u_{ijk}=u\\left(x_{i},y_{j},z_{k}\\right)$\r\nfor $1\\leq i\\leq N_{x}$, $1\\leq j\\leq N_{y}$ and $1\\leq k\\leq N_{z}$\r\nreads \r\n\r\n\\[\r\n\\left[\\epsilon_{i-1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i-1}}+\\epsilon_{i+1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i}}+\\right.\\]\r\n\r\n\r\n\\[\r\n\\epsilon_{i,j-1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j-1}}+\\epsilon_{i,j+1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j}}+\\]\r\n\r\n\r\n\\[\r\n\\epsilon_{i,j,k-1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k-1}}+\\epsilon_{i,j,k+1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k}}+\\]\r\n\r\n\r\n\\[\r\n\\left.\\kappa_{ijk}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{8}\\right]u_{ijk}+\\]\r\n\r\n\r\n\\[\r\n\\left[-\\epsilon_{i-1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i-1}}\\right]u_{i-1jk}+\\left[-\\epsilon_{i+1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i}}\\right]u_{i+1jk}+\\]\r\n\r\n\r\n\\[\r\n\\left[-\\epsilon_{i,j-1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j-1}}\\right]u_{ij-1k}+\\left[-\\epsilon_{i,j+1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j}}\\right]u_{ij+1k}+\\]\r\n\r\n\r\n\\[\r\n\\left[-\\epsilon_{i,j,k-1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k-1}}\\right]u_{ijk-1}+\\left[-\\epsilon_{i,j,k+1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k}}\\right]u_{ijk+1}=\\]\r\n\r\n\r\n\\begin{equation}\r\nmagic\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{8}f_{ijk}\\label{eq:two}\\end{equation}\r\n\r\n\r\nin which  \r\n\r\n\\[\r\nh_{i}=x_{i+1}-x_{i},\\: h_{j}=y_{j+1}-y_{j}\\: h_{k}=z_{k+1}-z_{k}\\]\r\n\r\n\r\nThe delta functions appearing in the right hand side of the starting\r\nequations are approximated with linear B-splines (spl0) which spread\r\nthe point like charge along the nearest neighborhood. The resulting\r\n$f_{ijk}$ represent the smearing of the point charges along the grid\r\npoints. \r\n\r\nFor more details, including used unit system, please refer to the\r\nMichel Holst's thesis and the APBS user guide online. To visualize\r\nmore clearly the problem, let's explicitly write the first equations\r\nfor a cubic grid of 5x5x5 containing general coefficients\r\n\r\n\\[\r\na_{222}u_{222}+a_{122}u_{122}+a_{322}u_{322}+a_{212}u_{212}+a_{232}u_{232}+a_{221}u_{221}+a_{223}u_{223}=f_{222}\\]\r\n\r\n\r\n\\[\r\na_{322}u_{322}+a_{222}u_{222}+a_{422}u_{422}+a_{312}u_{312}+a_{332}u_{332}+a_{321}u_{321}+a_{323}u_{323}=f_{322}\\]\r\n\r\n\r\n\\[\r\na_{422}u_{422}+a_{122}u_{122}+a_{322}u_{322}+a_{212}u_{212}+a_{232}u_{232}+a_{221}u_{221}+a_{223}u_{223}=f_{422}\\]\r\n\r\n\r\n\\[\r\na_{232}u_{232}+a_{132}u_{132}+a_{332}u_{332}+a_{222}u_{222}+a_{242}u_{242}+a_{231}u_{231}+a_{233}u_{233}=f_{232}\\]\r\n\r\n\r\n\\[\r\n\\ldots\\]\r\n\r\n\r\nin which the nodes are arranged using the natural ordering \r\n\r\n\\[\r\nU=[u_{111},u_{211},..,u_{N_{x}11,}u_{121},..,u_{221},u_{321},..,u_{N_{x}21}...,u_{N_{x}N_{y}N_{z}}]^{T}\\]\r\n\r\n\r\nNote that the prescribed values of nodes $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$\r\nand $u_{ijN_{z}}$ along the faces of the box coming from the Dirichlet\r\nboundary conditions will have their corresponding elements removed\r\nin such a way that only equations for the interior nodes remain. In\r\nother words, we will only consider the following set of unknown nodes\r\n\r\n\\[\r\nU=[u_{222},u_{322},..,u_{N_{x}-1,22,}u_{232},..,u_{332},u_{432},..,u_{N_{x}-2,32}...,u_{N_{x}-1,N_{y}-1,N_{z}-1}]^{T}\\]\r\n\r\n\r\nin such a way that the previous equations become \r\n\r\n\\[\r\na_{222}u_{222}+a_{322}u_{322}+a_{232}u_{232}+a_{223}u_{223}=f_{222}-a_{122}u_{122}-a_{212}u_{212}-a_{221}u_{221}\\equiv b_{222}\\]\r\n\r\n\r\n\\[\r\na_{322}u_{322}+a_{222}u_{222}+a_{422}u_{422}+a_{332}u_{332}+a_{323}u_{323}=f_{322}-a_{312}u_{312}-a_{321}u_{321}\\equiv b_{322}\\]\r\n\r\n\r\n\\[\r\na_{422}u_{422}+a_{322}u_{322}+a_{232}u_{232}+a_{223}u_{223}=f_{422}-a_{122}u_{122}-a_{212}u_{212}-a_{221}u_{221}\\equiv b_{422}\\]\r\n\r\n\r\n\\[\r\na_{232}u_{232}+a_{332}u_{332}+a_{222}u_{222}+a_{242}u_{242}+a_{233}u_{233}=f_{232}-a_{132}u_{132}-a_{231}u_{231}\\equiv b_{232}\\]\r\n\r\n\r\nin which the boundary $u's$ are conveniently brought to the right-hand-side\r\nof the equations. The resulting left-hand side equations can be written\r\nin compact form in term of matrix vector product as follows\r\n\r\n\\[\r\nAu=b\\]\r\n\r\n\r\nin which\r\n\r\n\\[\r\nu\\left(p\\right)=u_{ijk},\\qquad b\\left(p\\right)=b_{ijk},\\qquad p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1\\]\r\n\r\n\r\n\\[\r\ni=2,..,N_{x}-2,\\quad j=2,..,N_{y}-2,\\quad k=2,..,N_{z}-2\\]\r\n\r\n\r\n%\r\n\\begin{figure}\r\n\\includegraphics[scale=0.75]{Amatrix}\r\n\r\n\\caption{A Matrix representation}\r\n\r\n\\end{figure}\r\n\r\n\r\nand $A$ is a (seven banded block tri-diagonal form) $(N_{x}-2)(N_{y}-2)(N_{z}-2)$\r\nby $(N_{x}-2)(N_{y}-2)(N_{z}-2)$ squared symmetric positive definite\r\nmatrix containing the following nonzero elements (see figure 1):\r\n\r\n\\begin{itemize}\r\n\\item The main diagonal elements\r\n\\end{itemize}\r\n\\[\r\nd_{0}(p)=\\left[\\epsilon_{i-1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i-1}}+\\epsilon_{i+1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i}}+\\right.\\]\r\n\r\n\r\n\\[\r\n\\epsilon_{i,j-1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j-1}}+\\epsilon_{i,j+1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j}}+\\]\r\n\r\n\r\n\\[\r\n\\epsilon_{i,j,k-1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k-1}}+\\epsilon_{i,j,k+1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k}}+\\]\r\n\r\n\r\n\\begin{equation}\r\n\\left.\\kappa_{ijk}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{8}\\right]\\label{eq:three}\\end{equation}\r\n\r\n\r\n\\begin{itemize}\r\n\\item The Next upper band diagonal, which is shifted in one column to the\r\nleft from the first column, contains the following elements\r\n\\end{itemize}\r\n\\begin{equation}\r\n\\left[d_{1}(p)=-\\epsilon_{i+1/2,j,k}^{x}\\frac{\\left(h_{j-1}+h_{j}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{i}}\\right]\\label{eq:four}\\end{equation}\r\n\r\n\r\n\\begin{itemize}\r\n\\item The second upper band diagonal which is shifted $N_{x}-2$ columns\r\nfrom the first column \r\n\\end{itemize}\r\n\\begin{equation}\r\nd_{2}(p)=\\left[-\\epsilon_{i,j+1/2,k}^{y}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{k-1}+h_{k}\\right)}{4h_{j}}\\right]\\label{eq:five}\\end{equation}\r\n\r\n\r\n\\begin{itemize}\r\n\\item The third upper band diagonal which is shifted $(N_{x}-2)(N_{y}-2)$\r\ncolumns from the first column\r\n\\end{itemize}\r\n\\begin{equation}\r\nd_{3}(p)=\\left[-\\epsilon_{i,j,k+1/2}^{k}\\frac{\\left(h_{i-1}+h_{i}\\right)\\left(h_{j-1}+h_{j}\\right)}{4h_{k}}\\right]\\label{eq:six}\\end{equation}\r\n\r\n\r\nThe remaining elements of the upper triangular squared matrix A are\r\nset equal to zero. By symmetry we obtain the lower triagonal elements\r\nof the matrix A. Because the matrix A is sparse and large, we can\r\nimplement efficient methods that optimally solve the linear system\r\nfor U. Specifically, we use the biconjugate gradient stabilized method\r\ncombined with the inexact LU decomposition of the matrix A. Having\r\nthe numerical values for the nodes in the interior of the box, we\r\nfinally add the previously removed prescribed values along the six\r\nfaces to get the solution over the complete set of grid points.\r\n\r\n\r\n\\subsection*{Computational algorithm}\r\n\r\n\\begin{enumerate}\r\n\\item We read the input file .inm to get the APBS input files (shifted dielectric\r\ncoefficients, kappa function and pqr data file) as well as the number\r\nof grid points, the box Lengths, and temperature.\r\n\\item By using linear B-splines, we discretize the charge density to get\r\n$f_{ijk}$ for $i=1,..,N_{x},\\quad j=1,..,N_{y},\\quad k=1,..,N_{z}$.\r\nWe also calculate the Dirichlet boundary condition along the six faces\r\nof the box $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$\r\nand $u_{ijN_{z}}$ using the temperature, the value of the bulk dielectric\r\ncoefficient (usually water) and ionic strength.\r\n\\item By using the expressions (\\ref{eq:three}), (\\ref{eq:four}),(\\ref{eq:five}),\r\nand (\\ref{eq:six}), we evaluate the nonzero components of the matrix\r\n$A$, e.g., the diagonal elements $d_{0}(p),d_{1}(p),d_{2}(p),$ and\r\n$d_{3}(p),$ for $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$ and\r\n$i=2,..,N_{x}-1,\\quad j=2,..,N_{y}-1,\\quad k=2,..,N_{z}-1$. The values\r\nfor the shifted dielectric coefficients and kappa function elements\r\nare obtained from the APBS input files. The values of the mesh size\r\n$h_{i},h_{j}$ and $h_{k}$ are obtained from the number of grid points\r\nand the Length of the box. Next, we built the sparse upper triangular\r\nmatrix A by filling with zeros the remaining elements of the matrix\r\nA. Next, we obtain the lower triangular elements of the matrix A by\r\nusing the following symmetry property $A_{pq}=A_{qp}$ for $q=1,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$\r\nand $p=q,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$. \r\n\\item By using the values obtained for the discretized charge density $f_{ijk}$\r\nand the values of the Dirichlet boundary elements multiplied by the\r\nappropriate shifted dielectric coefficient values, we evaluate the\r\nelements of $b_{ijk}$. We use the natural ordering $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$\r\nand $i=2,..,N_{x}-1,\\quad j=2,..,N_{y}-1,\\quad k=2,..,N_{z}-1$ to\r\nconstruct the corresponding vector $b(p)$ (one index) from the data\r\narray structure (three indices) $b_{ijk}$.\r\n\\item We use the inexact $LU$ decomposition of the matrix $A$. The default\r\ntolerance value is set equal to 0.25 which provides a fast evaluation\r\nof the matrices $L$ and $U$. \r\n\\item The resulting $L$ and $U$ matrices, the matrix $A$ and the vector\r\n$b$ are used to approximately solve $Au=b$ for the vector $u$ using\r\nthe biconjugate gradient stabilized method. The default accuracy is\r\nset equal to 10\\textasciicircum{}-9 and the maximum number of iteration\r\nequal to 800. \r\n\\item We use the natural ordering relationship to convert the resulting\r\nvector $u(p)$ to data array structure to get the numerical solution\r\nfor $u_{ijk}$ for $i=2,..,N_{x}-1,\\quad j=2,..,N_{y}-1,\\quad k=2,..,N_{z}-1$.\r\n\\item Finally we add the previously removed values of the nodes at the faces\r\nof the box to obtain the solution for the nodes $u_{ijk}$ over the\r\ncomplete set of grid points, namely for $i=1,..,N_{x},\\quad j=1,..,N_{y},\\quad k=1,..,N_{z}$.\r\n\\item The electrostatic potential $u_{ijk}$ and the charge $f_{ijk}$ maps\r\nare saved in dx format files.\r\n\\item The electrostatic potential surface $u_{ij(N_{z}+1)/2}$ is saved\r\nin tiff and fig format files for visualization purpose. \r\n\\end{enumerate}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "55200c037490e5441d4bb281bb8f3e4ee28210e6", "size": 12497, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "apbs/tools/matlab/solver/MATLAB_PB_SOLVER.tex", "max_stars_repo_name": "ashermancinelli/apbs-pdb2pqr", "max_stars_repo_head_hexsha": "0b1bc0126331cf3f1e08667ccc70dae8eda5cd00", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "apbs/tools/matlab/solver/MATLAB_PB_SOLVER.tex", "max_issues_repo_name": "ashermancinelli/apbs-pdb2pqr", "max_issues_repo_head_hexsha": "0b1bc0126331cf3f1e08667ccc70dae8eda5cd00", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "apbs/tools/matlab/solver/MATLAB_PB_SOLVER.tex", "max_forks_repo_name": "ashermancinelli/apbs-pdb2pqr", "max_forks_repo_head_hexsha": "0b1bc0126331cf3f1e08667ccc70dae8eda5cd00", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3923611111, "max_line_length": 241, "alphanum_fraction": 0.6731215492, "num_tokens": 4673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.4960938294709195, "lm_q1q2_score": 0.4274037895521615}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath,amssymb}\n\\usepackage{breqn}\n\\usepackage{graphicx}\n\\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}\n\\usepackage{cleveref}\n\n\\makeatletter\n\\newcommand*{\\declarecommand}{%\n  \\@star@or@long\\declare@command\n}\n\\newcommand*{\\declare@command}[1]{%\n  \\provide@command{#1}{}%\n  \\renew@command{#1}%\n}\n\\makeatother\n\n\\declarecommand{\\x}{{\\mathbf{x}}}\n\\declarecommand{\\p}{{\\mathbf{p}}}\n\n\\declarecommand{\\u}{{\\mathbf{u}}}\n\\declarecommand{\\U}{{\\mathbf{U}}}\n\\declarecommand{\\grad}{\\nabla}\n\\declarecommand{\\Wi}{\\textnormal{Wi}}\n\\declarecommand{\\Id}{\\mathbb{I}}\n\\declarecommand{\\f}{{\\mathbf{f}}}\n\\declarecommand{\\F}{{\\mathbf{F}}}\n\\declarecommand{\\n}{{\\mathbf{n}}}\n\\declarecommand{\\X}{{\\mathbf{X}}}\n\\declarecommand{\\b}{{\\mathbf{b}}}\n\\declarecommand{\\a}{{\\mathbf{a}}}\n\\declarecommand{\\bmu}{{\\boldsymbol{\\mu}}}\n\\declarecommand{\\tS}{{\\tilde S}}\n\n\\begin{document}\n\n\\section{The Bingham closure}\n\nThe Bingham closure is given by:\n\\begin{equation}\n    S(\\x) = \\int\\psi_B(\\x,\\p)\\p\\p\\p\\p\\,d\\p,\n\\end{equation}\nwhere the Bingham distribution $\\psi_B(\\x,\\p)$ is defined by the constraints that:\n\\begin{subequations}\n    \\begin{align}\n        \\int\\psi_B(\\x,\\p)\\,d\\p      &= \\phi(x),  \\\\\n        \\int\\psi_B(\\x,\\p)\\p\\p\\,d\\p  &= D(\\x),\n    \\end{align}\n\\end{subequations}\nwhere $\\phi$ and $D$ are the zeroth and second moments with respect to the true distribution function $\\psi$. We assume that $\\psi_B(\\x,\\p)$ takes the form:\n\\begin{align}\n    \\psi_B(\\x,\\p) = Ae^{B:\\p\\p}.\n\\end{align}\nGiven $\\phi(\\x)$ and $D(\\x)$, our goals is to find the coefficients $A$ and $B$. Because $B$ only appears contracted against a symmetric matrix, it is sufficient to assume that $B$ is symmetric. In fact, we will see that our goal is even simpler than this: we will only be interested in computing $S:E$ and $S:D$, where $E=\\grad\\u+\\grad\\u^\\intercal$. The purpose of this package is to provide optimized routines for computing these contractions. This documentation describes how the package works.\n\n\\section{The Bingham Closure in 2D}\n\n\\subsection{A simple formula for the closure}\n\nFrom Chaubal and Leal, $B$ and $D$ are diagonalized in the same frame. We assume that we are in this frame; and compute the closure here. We will clean up details afterwards. In this frame, we have that:\n\\begin{subequations}\n    \\begin{align}\n        1 &= \\int_0^{2\\pi}Ae^{\\lambda_0\\cos^2\\theta + \\lambda_1\\sin^2\\theta}\\,d\\theta,   \\\\\n        \\mu_0 &= \\int_0^{2\\pi}Ae^{\\lambda_0\\cos^2\\theta + \\lambda_1\\sin^2\\theta}\\cos^2\\theta\\,d\\theta,   \\\\\n        \\mu_1 &= \\int_0^{2\\pi}Ae^{\\lambda_0\\cos^2\\theta + \\lambda_1\\sin^2\\theta}\\sin^2\\theta\\,d\\theta,\n    \\end{align}\n\\end{subequations}\nNote we have assumed here that $\\phi=1$. $\\mu$ and $\\lambda$ are the eigenvalues of $D$ and $B$ respectively, with $\\mu_0>\\mu_1$. We note that $\\lambda$ can only be fixed up to an additive constant: to see this, let $\\lambda_0$ and $\\lambda_1$ solve the above equations.  Then letting $\\tilde\\lambda_i=\\lambda_i+C$ for $i=0,1$, we have:\n\\begin{equation}\n    \\int_0^{2\\pi}Ae^{\\tilde\\lambda_0\\cos^2\\theta + \\tilde\\lambda_0\\sin^2\\theta}f(\\theta)\\,d\\theta = \\int_0^{2\\pi}Ae^{C}e^{\\lambda_0\\cos^2\\theta + \\lambda_1\\sin^2\\theta}f(\\theta)\\,d\\theta,\n\\end{equation}\nwhich simply changes the definition of $A$. We can choose a convenient choice of $C$ then; it is convenient to choose $C$ so that $\\lambda_0 + \\lambda_1 = 0$. Then we have that:\n\\begin{subequations}\n    \\begin{align}\n        1 &= \\int_0^{2\\pi}Ae^{\\lambda_0(\\cos^2\\theta - \\sin^2\\theta)}\\,d\\theta,   \\\\\n        \\mu_0 &= \\int_0^{2\\pi}Ae^{\\lambda_0(\\cos^2\\theta - \\sin^2\\theta)}\\cos^2\\theta\\,d\\theta.\n    \\end{align}\n\\end{subequations}\nExploiting the trig identity that $\\cos^2\\theta-\\sin^2\\theta=\\cos(2\\theta)$, and because:\n\\begin{equation}\n    \\int_0^{2\\pi}e^{\\lambda_0\\cos(2\\theta)}\\,d\\theta = 2\\pi I_0(\\lambda_0),\n\\end{equation}\nwe find that\n\\begin{equation}\n    A = \\frac{1}{2\\pi I_0(\\lambda_0)},\n\\end{equation}\nwhere $I_v$ is the modified Bessel function of the first kind. Thus we find:\nNow we're down to the single equation:\n\\begin{equation}\n    \\mu_0 = \\frac{1}{2\\pi I_0(\\lambda_0)}\\int_0^{2\\pi}e^{\\lambda_0\\cos(2\\theta)}\\cos^2\\theta\\,d\\theta.\n\\end{equation}\nEvaluating this final integral and simplifying gives:\n\\begin{equation}\n    2\\mu_0 = 1 + \\zeta(\\lambda_0),\n\\end{equation}\nwhere we have defined $\\zeta(x)=I_1(x)/I_0(x)$. Thus to find $\\lambda_0$ given $\\mu_0$, we simply need to solve this nonlinear equation for $\\lambda_0$.\n\n\\subsection{Solution of the closure equation and numerical issues}\n\nIn this section we consider the issues with solving the nonlinear equation:\n\\begin{equation}\n    2\\mu = 1 + \\zeta(\\lambda)\n    \\label{eqn:bingham_nonlinear}\n\\end{equation}\nfor $\\lambda$, given $\\mu\\in[0.5,1.0]$. Note that $\\mu_0$, the largest eigenvalue, must live in this range becuase it is the largest eigenvalue and the eigenvalues sum to $1$. The fundamental problem with simply throwing a naive Newton solver at this equation is that as $\\mu\\to1$, $\\lambda\\to\\infty$. While not a problem in and of itself, $\\zeta(\\lambda)$ is the ratio of $I_1(\\lambda)$ and $I_0(\\lambda)$. Both of these functions diverge exponentially fast as $\\lambda$ gets large, and so naive evaluation of the ratio fails. Nevertheless, their ratio converges to $1$: our primary challenge is to find a way to evaluate $\\zeta$ stably for large arguments. Fortunately, we are in luck! As it turns out, we can write:\n\\begin{equation}\n    I_\\nu(z) = \\frac{e^z}{\\sqrt{2\\pi z}}\\mathcal{P}_\\nu(z),\n\\end{equation}\nwhere $\\mathcal{P}_\\nu(z)$ is a power series in $z^{-1}$ that converges for sufficiently large $z$. Our strategy is clear, then. For small arguments, we can evaluate $\\zeta$ directly. For larger arguments, we compute $\\zeta$ by:\n\\begin{equation}\n    \\zeta(\\lambda) = \\mathcal{P}_1(\\lambda)/\\mathcal{P}_0(\\lambda).\n\\end{equation}\nIn my numerical experiments, the power series $\\mathcal{P}_0$ and $\\mathcal{P}_1$ converge rapidly when the argument is at least $20$, and direct evaluation has no issues for this size argument. We thus evaluate $\\zeta$ directly for $|\\lambda|\\leq20$, and indirectly via the power series representations for $|\\lambda|>20$.\n\nIn order to find $\\lambda$, we compute the solution to the equation $1/2 + \\zeta(\\lambda)/2 - \\mu = 0$. The Jacobian is given by:\n\\begin{equation}\n    2\\mathcal{J}(\\lambda) = 1 - \\zeta(\\lambda)/\\lambda - \\zeta(\\lambda)^2.\n\\end{equation}\nFortunately, the singularity in $\\zeta(\\lambda)/\\lambda$ is removable. We construct a function to evaluate this quantity using the function\\_generator package, on an approximation interval of $[ -1.001, 1.0]$. These bounds are chosen so that evaluation points for the Chebyshev interpolants used by the function\\_generator do not live at the singularity. When $|\\lambda|>1$, we evaluate this quantity direclty.\n\n\\subsection{Fast evaluation of the closure equation}\n\nThis provides a stable way to compute $\\lambda(\\mu)$ for every value of $\\mu\\in[0.5, 1.0]$, but it requires a Newton iteration for every value of $\\mu$ given. Instead, we might consider constructing an interpolant for this function. Unfortunately as mentioned before, as $\\mu\\to1$, $\\lambda\\to\\infty$. Because the function\\_generator package allows for adaptive, brute force interpolation, it could probably handle this. But we can be smarter. Note that what we actually want to calculate is:\n\\begin{equation}\n    S(\\x) = \\psi_B(\\x,\\p)\\p\\p\\p\\p\\,d\\p.\n\\end{equation}\nBy exploiting identities, as we will show momentarily, we can reduce computing all of this to computing:\n\\begin{equation}\n    S_{0000}(\\x) = \\int_0^{2\\pi}Ae^{\\lambda(\\x)\\cos(2\\theta)}\\cos^4\\theta\\,d\\theta.\n\\end{equation}\nAgain, this function can be computed analytically, and dropping the $\\x$, the result is:\n\\begin{equation}\n    S_{0000} = \\frac{1}{2} - \\frac{\\zeta(\\lambda)}{4\\lambda} + \\frac{\\zeta(\\lambda)}{2}\n    \\label{eqn:bingham_integral}\n\\end{equation}\nNow we're getting somewhere: we just define the function $S_{0000}(\\mu)$ as:\n\\begin{itemize}\n    \\item Given, $\\mu$, solve \\Cref{eqn:bingham_nonlinear} for $\\lambda$ using a Newton iteration,\n    \\item Evaluate \\Cref{eqn:bingham_integral} with the argument $\\lambda$ from the first step.\n\\end{itemize}\nFortunately, $S_{0000}(\\mu)$ is a bounded and relatively smooth function of $\\mu$. Thus we can use function\\_generator to construct a nearly machine-precision and very accurate approximation of $S_{0000}(\\mu)$.\n\n\\section{The full algorithm}\n\nWe now assume that we are given $D(\\x)$ and outline a method for computing $(S:E)(\\x)$ and $(S:D)(\\x)$. Because these computations are done pointwise, we will omit $\\x$ for the remainder. We first compute the eigendecomposition of $D$:\n\\begin{equation}\n    D = \\Omega\\Lambda\\Omega^\\intercal.\n\\end{equation}\nSince $D$ is symmetric positive-definite, we may apply the routine np.linalg.eigh (which is faster than np.linalg.eig) in order to find the ordered eigenvalues. We call $\\mu_0$ the larger eigenvalue, and $\\mu_1$ the smaller eigenvalue. Using the methodology from above, we compute $\\tilde S_{0000}(\\mu_0)$. Note that here it is denoted explicitly as $\\tilde S_{0000}$ - this is because this is not actually $S_{0000}$, but that value in the diagonalized frame. Via identites, we may compute some of the other components as:\n\\begin{align}\n    \\tilde S_{0011} &= \\mu_0 - S_{0000},    \\\\\n    \\tilde S_{1111} &= \\mu_1 - S_{0011},    \\\\\n    \\tilde S_{0001} &= 0, \\\\\n    \\tilde S_{0111} &= 0,\n\\end{align}\nWe now simply have to perform a rotation:\n\\begin{equation}\n    S_{ijkl} = \\Omega_{im}\\Omega_{jn}\\Omega_{kq}\\Omega_{lp}\\tilde S_{mnqp},\n\\end{equation}\nto get $S$ back. Calculuating this sum is somewhat nasty. Luckily we can exploit symmetries/identites to speed things up:\n\\begin{align}\n    S_{0000} &= \\Omega_{00}^4\\tilde S_{0000} + 4\\Omega_{00}^3\\Omega_{01}\\tilde S_{0001} + 6\\Omega_{00}^2\\Omega_{01}^2\\tilde S_{0011} + 4\\Omega_{00}\\Omega_{01}^3\\tilde S_{0111} + \\Omega_{01}^4 S_{1111},  \\\\\n    S_{0001} &= \\Omega_{00}^3\\Omega_{10}\\tilde S_{0000} + (3\\Omega^2\\Omega_{01}\\Omega_{10} + \\Omega_{00}^3\\Omega_{11})\\tilde S_{0001} + 3(\\Omega_{00}\\Omega_{01}^2\\Omega_{10} + \\Omega_{00}^2\\Omega_{01}\\Omega_{11})\\tilde S_{0011} +   \\\\\n        &\\qquad(3\\Omega_{00}\\Omega_{01}^2+\\Omega_{11}+\\Omega_{01}^3\\Omega_{10})\\tilde S_{0111} + \\Omega_{01}^3\\Omega_{11}\\tilde S_{1111}.\n\\end{align}\nNote that $\\tilde S_{0001}=\\tilde S_{0111}=0$, and so these terms can be left out of the sums in implementation, reducing these rotations to:\n\\begin{align}\n    S_{0000} &= \\Omega_{00}^4\\tilde S_{0000} + 6\\Omega_{00}^2\\Omega_{01}^2\\tilde S_{0011} + \\Omega_{01}^4 S_{1111},  \\\\\n    S_{0001} &= \\Omega_{00}^3\\Omega_{10}\\tilde S_{0000} + 3(\\Omega_{00}\\Omega_{01}^2\\Omega_{10} + \\Omega_{00}^2\\Omega_{01}\\Omega_{11})\\tilde S_{0011} + \\Omega_{01}^3\\Omega_{11}\\tilde S_{1111}.\n\\end{align}\nKnowing these, we can exploit more identites to find the rest of the components:\n\\begin{subequations}\n    \\begin{align}\n        S_{0000} + S_{0011} &= D_{00},  \\\\\n        S_{0100} + S_{0111} &= D_{01},  \\\\\n        S_{1100} + S_{1111} &= D_{11}.\n    \\end{align}\n\\end{subequations}\nFinally now that we have these components of $S$, we just need to compute $S:E$ and $S:D$. For a general symmetric tensor $T$, we have that:\n\\begin{subequations}\n    \\begin{align}\n        (S:T)_{00} &= S_{0000}T_{00} + S_{0011}T_{11} + 2S_{0001}T_{01},    \\\\\n        (S:T)_{01} &= S_{0001}T_{00} + S_{0111}T_{11} + 2S_{0011}T_{01},    \\\\\n        (S:T)_{11} &= S_{0011}T_{00} + S_{1111}T_{11} + 2S_{0111}T_{01}.\n    \\end{align}\n\\end{subequations}\nSince $S:T$ is symmetric, $(S:T)_{10}=(S:T)_{01}$.\n\n\\end{document}\n", "meta": {"hexsha": "123df0636f507e158b9421a3d6c2201347aed68c", "size": 11606, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bingham_closure/doc/bingham.tex", "max_stars_repo_name": "dbstein/bingham_closure", "max_stars_repo_head_hexsha": "fa3ae440414ade79c4386505bea091fa1ea76afd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bingham_closure/doc/bingham.tex", "max_issues_repo_name": "dbstein/bingham_closure", "max_issues_repo_head_hexsha": "fa3ae440414ade79c4386505bea091fa1ea76afd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bingham_closure/doc/bingham.tex", "max_forks_repo_name": "dbstein/bingham_closure", "max_forks_repo_head_hexsha": "fa3ae440414ade79c4386505bea091fa1ea76afd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.0842105263, "max_line_length": 718, "alphanum_fraction": 0.6932621058, "num_tokens": 3937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4273759259425533}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{float}\n\n\\newcommand{\\comment}[1]{}\n\n\\title{Final Project Team 6}\n\\author{Berenice, Gabriela, Juan, Héctor, Damián}\n\\date{May 2021}\n\n\\begin{document}\n    \\maketitle\n    \\tableofcontents\n    \\newpage\n\n\n\n    \\begin{abstract}\n        The hypothesis of this theorem is that we have a function $F$ that is continuous in a closed interval $[a, b]$, differentiable in the open interval $(a, b)$ and whose values in its extremes $F(a)$ and $F(b)$ match.\n        The thesis of the theorem is that, in this case, the derived function vanishes at some point in the interval $(a, b)$\n        Notice that since the interval is closed, it makes sense to talk about both $F(a)$ and $F(b)$. We will see that, intuitively, this statement is very simple.\n        Rolle's theorem guarantees us that, under these conditions, there must be at least a certain value $x$ of the interval $(a, b)$ for which $F'(x) = 0$. But it only assures us that there has to be that value, not tells us nothing about its how to find it.\n\n        This will be necessary for the problem, because it has a great complexity and will make us develop different mathematical skills to understand how the application of integrals and derivatives works.\n    \\end{abstract}\n\n    \\section{Problem}\n    Let $f$ be a three times differentiable function (defined on $\\mathbb{R}$\n    and real-valued) such that $f$ has at least five distinct real zeros. \n    Prove that $f + 6f' + 12f'' + 8f'''$ has at least two distinct real zeros.\n    \n\n    \\subsection{Polynomial Function}\n    A polynomial is generally represented as $P(x)$. The highest power of the variable of $P(x)$ is known as its degree. Degree of a polynomial function is very important as it tells us about the behaviour of the function $P(x)$ when x becomes very large, and also helps us to know the number of roots that we can have in a function. The domain of a polynomial function is entire real numbers $\\mathbb{R} $.\n\n    \\comment{\n    \\section*{Rolle's Thorem}\n    Let $f$ be a continuous function on $[a, b]$ and differentiable on $]a, b[$ such that $f(a) = f(b)$. Then there exists $c \\in ]a, b[ $ such that $f'(c) = 0$.\n\n    This theorem will be admitted because its proof requires results which are not seen in this course. If $f$ is the constant function, the result is obvious. Otherwise, since $f$ is continuous over $[a, b]$, $f$ is bounded over $[a, b]$\n    and reaches its bounds. This means that there exists $m \\in  [a, b] $ and $M \\in  [a, b] $ such that $\\forall x \\in  [a, b]$, $f(m) \\leqslant  f(x) \\leqslant f(M) (f(m) \\neq  f(M)$ because $f$ is not a constant function$)$. As $f(a) = f(b)$, then we have the following cases:\n\n    \\begin{enumerate}\n        \\item if $m = a$ or $m = b$, then $M \\in  ]a, b[$, hence we have $c = M$;\n        \\item if $M = a$ or $M = b$, then $m \\in  ]a, b[$, hence we have $c = m$;\n        \\item $m \\in  ]a, b[$ and $M \\in  ]a, b[$, hence we have $c = m$ or $c = M$.\n    \\end{enumerate}\n\n    So in all cases $f$ admits a local extremum at a point $c$ of $]a, b[$ and is differentiable on $]a, b[$, hence, according to the proposition 22, $f'(c) = 0$.\n    \\section*{Hint}\n    Use $g : x \\rightarrow  e^ {\\alpha x} $\n    }\n\n    \\subsection{Rolle's Theorem}\n    Suppose $f(x)$ is a function that satisfies all of the following.\n    $f(x)$ is continuous on the closed interval $[a,b]$.\n    $f(x)$ is differentiable on the open interval $(a,b)$.\n    $$f(a) = f(b)$$\n    Then there is a number c such that $a<c<b$ and $f'(c)=0$. Or, in other words $f(x)$ has a critical point in $(a,b)$.\n\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=340px]{img/rollestheorem.jpg}\n        \\caption{Graphic of Rolle's Theorem}\n    \\end{figure}\n\n    In other words, if a continuous curve passes through the same y-value (such as the x-axis) twice and has a unique tangent line (derivative) at every point of the interval, then somewhere between the endpoints it has a tangent parallel to the x-axis. The theorem was proved in 1691 by the French mathematician Michel Rolle, though it was stated without a modern formal proof in the 12th century by the Indian mathematician Bhaskara II. Other than being useful in proving the mean-value theorem, Rolle’s theorem is seldom used, since it establishes only the existence of a solution and not its value.\n\n    This theorem helps us to know how many roots (distinct zeros) our function will have once we have derived it three times.\n\n    \\subsection{Exponential Function}\n    An exponential function is a Mathematical function in form $f(x) = a^x$, where $x$ is a variable and $a$ is a constant which is called the base of the function and it should be greater than $0$. The most commonly used exponential function base is the transcendental number $e$, which is approximately equal to $2.71828$.\n    \n    An exponential function is defined by the formula $f(x) = a^x$, where the input variable x occurs as an exponent. The exponential curve depends on the exponential function and it depends on the value of the x.\n\n    The exponential function is an important mathematical function which is of the form\n\n    $$f(x) = a^x$$\n\n    Where $a > 0$ and is not equal to $1$.\n\n    $x$ is any real number.\n\n    If the variable is negative, the function is undefined for $-1 < x < 1$.\n\n    $$$$\n\n    Here,\n    $x$ is a variable\n    $a$ is a constant, which is the base of the function.\n\n    An exponential curve grows, or decay depends on the exponential function. Any quantity that grows or decays by a fixed per cent at regular intervals should possess either exponential growth or exponential decay.\n\n    \\pagebreak\n    \\section{Solution}\n    Applying Rolle's Theorem:\n\n    $f(x) \\rightarrow 5$ distinct real zeros\n\n    $f'(x) \\rightarrow 4$ distinct real zeros\n\n    $f''(x) \\rightarrow 3$ distinct real zeros\n\n    $f'''(x) \\rightarrow 2$ distinct real zeros\n\n    \\subsection{Hint}\n    We should use $e^{\\alpha x}$\n\n    \\begin{itemize}\n        \\item Can be differentiable as much as we want\n        \\item Can have all zeros the function needs\n        \\item The differentiable function would express the no zeros\n    \\end{itemize}\n\n    \\subsection{Set up:}\n    $$g(x) = e^{\\alpha x} f(x)$$\n    We infer the derivatives from the product rule:\n    $$(f(x) g(x))' = f'(x) g(x) + f(x) g'(x)$$\n    So, we have the consecuent derivatives:\n    \\begin{equation}\n        \\begin{split}\n        &g'(x) = \\alpha e^{\\alpha x} f(x) + e^{\\alpha x} f'(x)\\\\\n        &g''(x) = \\alpha ^2 e^{\\alpha x} f(x) + 2\\alpha ^2 e^{\\alpha x} f'(x) + \\alpha e^{\\alpha x} f''(x)\\\\\n        &g'''(x) = \\alpha ^3 e^{\\alpha x} f(x) + 3\\alpha ^2 e^{\\alpha x} f'(x) + 3\\alpha e^{\\alpha x} f''(x) + e^{\\alpha x} f'''(x)\\\\\n        \\end{split}\n    \\end{equation}\n    Simplifying from the algebraic properties:\n    $$g'''(x) = e^{\\alpha x} (\\alpha ^3  f(x) + 3\\alpha ^2f'(x) + 3\\alpha f''(x) +  f'''(x))$$\n\n    \\subsection{Substitution}\n    In the problem we have: $f + 6f' + 12f'' + 8f'''$\n\n    \\begin{equation}\n        \\begin{split}\n            &8g'''(x) = 8e^{\\alpha x} (\\alpha ^3 f(x) + 3\\alpha ^2 f'(x) + 3\\alpha f''(x) + f'''(x))\\\\\n            &8g'''(x) = e^{\\alpha x} (8\\alpha ^3 f(x) + 24\\alpha ^2 f'(x) + 24\\alpha f''(x) + 8f'''(x))\\\\\n        \\end{split}\n    \\end{equation}\n    Using $\\alpha$ as $\\frac{1}{2}$ we got:\n    \\begin{equation}\n        \\begin{split}\n            8g'''(x) = \n            e^{\\frac{x}{2}} \n            \\left(8\\left(\\frac{1}{2}\\right)^3 f(x) + \n            24\\left(\\frac{1}{2}\\right)^2 f'(x) + \n            24\\left(\\frac{1}{2}\\right) f''(x) + \n            8f'''(x)\\right)\n        \\end{split}\n    \\end{equation}\n\n    So with that we get:\n\n    \\begin{equation}\n        \\begin{split}\n            8g'''(x) = \n            \\frac{e^{\\frac{x}{2}}}{8} \n            \\left(f(x) + \n            6 f'(x) + \n            12 f''(x) + \n            8f'''(x)\\right)\n        \\end{split}\n    \\end{equation}\n\n    \\subsection{Answer:}\n    $$g(x) = 8e^{\\frac{x}{2}} f(x)$$\n\n    In this case, $g'''(x)$ has at least 2 zeros\n\n    \\section{Appendix}\n    Before we found the final solution, we made many attempts on how\n    we could resolve this:\n\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=340px]{img/firstattempt.png}\n        \\caption{First Attempt}\n    \\end{figure}\n\n    \\begin{figure}[H]\n        \\includegraphics[width=340px]{img/secondattempt.png}\n        \\caption{Second Attempt}\n    \\end{figure}\n\n    \\begin{figure}[H]\n        \\includegraphics[width=340px]{img/thirdattempt.png}\n        \\caption{Third Attempt}\n    \\end{figure}\n\n    \\pagebreak\n    \\section{Bibliography}\n    \\begin{itemize}\n        \\item Hosch, W. L. (2021, April 15). Rolle’s theorem | Definition, Equation, \\& Facts. Encyclopedia Britannica. \\\\\n        \\href{https://www.britannica.com/science/Rolles-theorem}{https://www.britannica.com/science/Rolles-theorem}\n\n        \\item Dawkins, P. (2019, February 21). Calculus I - The Mean Value Theorem. \\\\\n        \\href{https://tutorial.math.lamar.edu/classes/calci/MeanValueTheorem.aspx}{https://tutorial.math.lamar.edu/classes/calci/MeanValueTheorem.aspx}\n\n        \\item A. (2021, March 22). General Data Protection Regulation(GDPR) Guidelines BYJU’S. BYJUS. \\\\\n        \\href{https://byjus.com/maths/exponential-functions/}{https://byjus.com/maths/exponential-functions/}\n\n        \\item A. (2021, March 22). General Data Protection Regulation(GDPR) Guidelines BYJU’S. BYJUS.\\\\\n        \\href{https://byjus.com/maths/polynomial-functions/}{https://byjus.com/maths/polynomial-functions/}\n    \\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "00f13b740b26a19965cbf15faa8a05961f1d3dd0", "size": 9681, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "math/proof.tex", "max_stars_repo_name": "HectorMtz22/latex_test", "max_stars_repo_head_hexsha": "d10d956214c7866d895e93752977c4eb3da7f9da", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "math/proof.tex", "max_issues_repo_name": "HectorMtz22/latex_test", "max_issues_repo_head_hexsha": "d10d956214c7866d895e93752977c4eb3da7f9da", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "math/proof.tex", "max_forks_repo_name": "HectorMtz22/latex_test", "max_forks_repo_head_hexsha": "d10d956214c7866d895e93752977c4eb3da7f9da", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.3205741627, "max_line_length": 602, "alphanum_fraction": 0.6369176738, "num_tokens": 2930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.42729588923840733}}
{"text": "\\documentclass{beamer}\n\\usepackage{hyperref}\n\\usepackage{subfig}  %% To include subfigures\n\\usepackage{media9} % \n\\usepackage{ragged2e}  % Allow justification\n\\usepackage{url}\n\\usepackage[margin=20pt,font=small,labelfont=bf,labelsep=period]{caption}\n\n\\hypersetup{pdfstartview={Fit}, bookmarks=True, pdftitle={Wave Propagation Lectures},\n            pdfauthor={Nicolas Guarin-Zapata}, pdfsubject={Lectures},\n            pdfkeywords={Waves, Elasticity, Numerical Methods}}  % Configure hyperref\n\n%--- New commands ----%\n\\newcommand{\\footref}[1]{\\textsuperscript{\\ref{#1}}}\n\\newcommand{\\pardiff}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\pardiffd}[2]{\\frac{\\partial^2 #1}{\\partial #2^2}}\n%---------------------%\n\n%\\usefonttheme[onlymath]{serif}  % Make equations to be in serif fonts\n\\usefonttheme{serif}  % Make equations to be in serif fonts\n\n\\begin{document}\n\n\n%title\n\\title[Wave propagation in solids] % (optional, only for long titles)\n{Wave propagation:}\n\\subtitle{Numerical tools}\n\\author[Guarin-Zapata, Nicolas] % (optional, for multiple authors)\n{Nicol\\'as Guar\\'in Zapata\\\\ \\texttt{\\small nguarin@purdue.edu}\\\\\n{\\tiny Slides available at: \\url{https://github.com/nicoguaro/CE597-slides}}}\n\\institute{Civil Engineering Department\\\\\n  Purdue University}\n\\date{\\today}\n\\subject{Wave propagation}\n\n% Title page\n\\frame{\\titlepage}\n\n% Outline\n\\begin{frame}\n\t\\frametitle{Outline}\n\t\\tableofcontents\n\\end{frame}\n%\n\n%  Relations between elastic constants\n\\section{Relations between elastic constants}\n\\begin{frame}[shrink=50]\n\\frametitle{Relations between elastic constants}\n\\centering\n\n\\vspace{3cm}\n\\begin{table}[h]\n\\centering %\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}\n\\hline \n & $(K,E)$  & $(K,\\lambda)$  & $(K,G)$  & $(K,\\nu)$  & $(E,G)$  & $(E,\\nu)$  & $(\\nu,G)$  & $(\\nu,\\lambda)$  & $(G,\\lambda)$  & $(G,M)$ \\\\\n\\hline \n$K=$  & $K$  & $K$  & $K$  & $K$  & $\\frac{EG}{3(3G-E)}$  & $\\frac{E}{3(1-2\\nu)}$  & $\\lambda+\\frac{2G}{3}$  & $\\frac{\\lambda(1+\\nu)}{3(1-2\\nu)}$  & $\\frac{2G(1+\\nu)}{3(1-2\\nu)}$  & $M-\\frac{4G}{3}$ \\\\\n\\hline \n$E=$  & $E$  & $\\frac{9K(K-\\lambda)}{3K-\\lambda}$  & $\\frac{9KG}{2K+G}$  & $3K(1-2\\nu)$  & $E$  & $E$  & $\\frac{G(3\\lambda+2G)}{\\lambda+G}$  & $\\frac{\\lambda(1+\\nu)(1-2\\nu)}{\\nu}$  & $2G(1+\\nu)$  & $\\frac{G(3-M-4G)}{M-2G}$ \\\\\n\\hline \n$\\lambda=$  & $\\frac{3K(3KE)}{9K-E}$  & $\\lambda$  & $K-\\frac{2G}{3}$  & $\\frac{3K\\nu}{1+\\nu}$  & $\\frac{G(E-2G)}{EG-E}$  & $\\frac{E\\nu}{(1+\\nu)(1-2\\nu)}$  & $\\lambda$  & $\\lambda$  & $\\frac{2G\\nu}{1-2\\nu}$  & $M-2G$ \\\\\n\\hline \n$G=$  & $\\frac{3KE}{9K-E}$  & $\\frac{3(K-\\lambda)}{2}$  & $G$  & $\\frac{3K(1-2\\nu)}{2(1+\\nu)}$  & $G$  & $\\frac{E}{2(1+\\nu)}$  & $G$  & $\\frac{\\lambda(1-2\\nu)}{2\\nu}$  & $G$  & $G$ \\\\\n\\hline \n$\\nu=$  & $\\frac{3K-E}{6K}$  & $\\frac{\\lambda}{3K-\\lambda}$  & $\\frac{3K-2G}{2(3K+G)}$  & $\\nu$  & $\\frac{E}{2G}-1$  & $\\nu$  & $\\frac{\\lambda}{2(\\lambda+G)}$  & $\\nu$  & $\\nu$  & $\\frac{M-2G}{2(M-G)}$ \\\\\n\\hline \n$M=$  & $\\frac{3K(3K+E)}{9K-E}$  & $3K-2\\lambda$  & $K+\\frac{4G}{3}$  & $\\frac{3K(1-\\nu)}{1+\\nu}$  & $\\frac{G(4G-E)}{3G-E}$  & $\\frac{E(1-\\nu)}{(1+\\nu)(1-2\\nu)}$  & $\\lambda+2G$  & $\\frac{\\lambda(1-\\nu)}{\\nu}$  & $\\frac{2G(1-\\nu)}{1-2\\nu}$  & $M$ \\\\\n\\hline \n\\end{tabular}\n\\end{table}\n\n{\\large $K$: Bulk modulus, $\\lambda$: Lam\\'e's first parameter, $E$: Young's\nmodulus, $G$: Shear modulus, $\\nu$: Poisson's ratio, $M$: P-wave\nmodulus.}\n\\end{frame}\n\n% Elastodynamics equations\n\\section{Elastodynamic wave equations}\n\\subsection{Navier-Cauchy Equations}\n\\begin{frame}\n\\frametitle{Navier-Cauchy Equations}\nThe Navier-Cauchy equations read\n\\begin{equation}\n\\rho{ \\pardiffd{\\bold{u}}{t}} = \\bold{f} + ( \\lambda + 2G)\\nabla(\\nabla \\cdot \\bold{u}) - G\\nabla \\times (\\nabla \\times \\bold{u}) \\enspace ,\n\\label{eq:navierVec}\n\\end{equation}\nor, rearranging the constants\n\\begin{equation}\n \\pardiffd{\\bold{u}}{t} = \\bold{f} + \\alpha^2\\nabla(\\nabla \\cdot \\bold{u}) - \\beta^2\\nabla \\times (\\nabla \\times \\bold{u}) \\enspace ,\n\\label{eq:navierVec2}\n\\end{equation}\nbeing $\\alpha$ the speed of the P-wave and $\\beta$ the speed of the S-wave. According to this, our problem just depends on two material properties, the two wave speeds.\n\n\\end{frame}\n\n% Relations for elastic wave speeds\n\\subsection{Relations for elastic wave speeds}\n\\begin{frame}[allowframebreaks]\n\\frametitle{Relations for elastic wave speeds}\nThe P-wave is a dilatational wave with speed $\\alpha$ given by \n\\begin{align*}\n & \\alpha^{2}=\\frac{\\lambda+2G}{\\rho},\\qquad\\alpha^{2}=\\frac{G(1-\\nu)}{\\rho},\\\\\n & \\alpha^{2}=\\frac{M}{\\rho},\\qquad\\alpha^{2}=\\frac{E(1-\\nu)}{(1+\\nu)(1-2\\nu)\\rho},\\\\\n & \\alpha^{2}=\\frac{2\\beta^{2}(1-\\nu)}{1-2\\nu}.\n\\end{align*}\n The S-wave is a distorsional wave with speed $\\beta$ given by \n\\begin{align*}\n & \\beta^{2}=\\frac{G}{\\rho}\\\\\n & \\beta^{2}=\\frac{E}{2(1+\\nu)\\rho},\\\\\n & \\beta^{2}=\\frac{\\alpha^{2}(1-2\\nu)}{2(1-\\nu)}.\n\\end{align*}\n Some particular values for the ratio \n\\[\n\\frac{\\alpha^{2}}{\\beta^{2}}=\\frac{2(1-\\nu)}{1-2\\nu}\n\\]\n are \n\\begin{align*}\n & \\frac{\\alpha^{2}}{\\beta^{2}}=\\frac{4}{3}\\quad\\mbox{for }\\nu=-1\\enspace,\\\\\n & \\frac{\\alpha^{2}}{\\beta^{2}}=2\\quad\\mbox{for }\\nu=0\\enspace,\\\\\n & \\frac{\\alpha^{2}}{\\beta^{2}}=4\\quad\\mbox{for }\\nu=\\frac{1}{3}\\enspace,\\\\\n & \\frac{\\alpha^{2}}{\\beta^{2}}\\rightarrow\\infty\\quad\\mbox{when }\\nu\\rightarrow\\frac{1}{2}\\enspace.\n\\end{align*}\n\\end{frame}\n\n\\subsection{Ashby chart: $E$ vs. $\\rho$}\n\\begin{frame}{Ashby chart: $E$ vs. $\\rho$}\n\\begin{figure}\n\\includegraphics[height=6cm]{img/E_vs_density-vector.pdf} \n\\caption{Ashby chart for Young Modulus vs density. The lines show the sound speed, that is the speed for a wave in a rod made of this\nmaterial.  This value is between the longitudinal and shear wave speeds for Poisson ratios in (-0.5,0.5). \\cite{ashby2005}}\n\\end{figure}\n\\end{frame}\n\n% Solution\n\\section{Solution}\n\\subsection{Time domain vs. Frequency domain}\n\\begin{frame}[allowframebreaks]{Time domain vs. Frequency domain}\nIf we are interested in waves, we are interested in dynamic behavior. To find the solutions to the (linear) equations  we can use one of two approaches:\n\\begin{itemize}\n\\item \\textbf{Time domain,} in this case the equations are solved directly.\n\\item \\textbf{Frequency domain,} the solution is expressed as the superposition (sum) of individual waves with different frequencies. This means that the solutions to the equation (and forces) are of the form\n\\[\\bold{u} = \\bold{U} \\exp(-i\\omega t), \\text{and } \\bold{f} = \\bold{F} \\exp(-i\\omega t)\\]\nsubstituting in the original equation we obtain\n\\begin{equation}\n \\alpha^2\\nabla(\\nabla \\cdot \\bold{U}) - \\beta^2\\nabla \\times (\\nabla \\times \\bold{U})  + \\bold{F} = -\\omega^2\\bold{U} \\enspace ,\n\\label{eq:navier_freq}\n\\end{equation}\n\n\\pagebreak\nThen, we transformed the problem of solving a dynamic equation into solving a set of steady-state problems. For every waveform there is an equivalent function in the frequency domain, i.e., its spectrum.\\footnote{This can be formally defined using the Fourier transform, and computed numerically (efficiently) using the FFT algorithm.}\n\\end{itemize}\n\n\\begin{figure}[h]\n\\centering\n\\subfloat[Ricker pulse.]{\\includegraphics[width=0.4\\textwidth]{img/ricker_pulse.pdf}}\\qquad\n\\subfloat[Ricker pulse spectrum.]{\\includegraphics[width=0.4\\textwidth]{img/ricker_area=2.pdf}}\n\\caption{Ricker pulse and its spectrum.}\n\n\\end{figure}\n\\end{frame}\n\n\\subsection{Numerical methods for waves in solids}\n\\begin{frame}\n\\frametitle{Numerical methods for waves in solids}\nExact solutions for the Navier-Cauchy equations are more an exception than the norm. So, we need methods to approximate the solutions (that's the role of numerical methods in general). A rough classification of the methods used in elastodynamics is:\n\\begin{itemize}\n\\item Spectral/Pseudo-spectral methods\n\\item Domain Discretization methods\n\\begin{itemize}\n\\item Finite Difference Methods (FDM)\n\\item Finite Volume Methods (FVM)\n\\item Finite Element Methods (FEM)\n\\item Boundary Element Methods (BEM)\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\subsubsection{Spectral/Pseudo-spectral methods}\n\\begin{frame}{Spectral/Pseudo-spectral method}\nIn this class of methods we expand the functions of interest in terms of a (orthogonal) basis \\cite{wiki:pseudo_spectral}, i.e.\n\\[\\bold{U}(\\bold{x}) = \\sum\\limits_{n=1}^N c_n h_n(\\bold{x}) \\enspace ,\\]\ne.g., we can use a combination of sine functions\n\\[\\bold{U}(\\bold{x}) = \\sum\\limits_{n=1}^N c_n \\sin(k_n\\bold{x}) \\enspace .\\]\nThis methods produce very accurate solutions and present good convergence rates, but are difficult to apply for complex geometries.\n\\end{frame}\n\n\\subsubsection{Domain discretization methods}\n\\begin{frame}{Domain dizcretization methods}\nIn this set of methods the domain of interest is subdivided (discretized) to obtain a system of linear/algebraic equations. After applying the discretization process we end up with a system like\n\\[[K]\\lbrace \\bold{u}\\rbrace + [M]\\lbrace \\bold{a}\\rbrace = \\lbrace \\bold{f}\\rbrace \\enspace ,\\]\nin the time domain, and\n\\[[K]\\lbrace \\bold{U}\\rbrace - \\omega^2 [M]\\lbrace \\bold{U}\\rbrace = \\lbrace \\bold{F}\\rbrace \\enspace ,\\]\nin the frequency domain. In both equations $[K]$,  and $[M]$ are termed stiffness and mass matrices.\n\n\\end{frame}\n\n\\subsubsection{Finite Difference Methods}\n\\begin{frame}{Finite Difference Methods}\nIn FDM the domain is (commonly) decomposed in rectangular regions where the function is constant \\cite{wiki:FDM}. The differential equation is approximated with difference equations, e.g.\n\\[\\pardiff{u}{x} \\approx \\frac{u(x + \\Delta x) - u(x)}{h}\\]\n\\begin{figure}\n\\includegraphics[height=4cm]{img/FDM.pdf} \n\\caption{Schematic domain discretized in rectangular cells.}\n\\end{figure}\n\\end{frame}\n\n\\subsubsection{Finite Volume Methods}\n\\begin{frame}{Finite Volume Methods}\nIn FVM the geometry is decomposed into regions, denoted as \\emph{Finite volumes}. Some quantities are evaluated (as fluxes) at the interface between neighboring \\emph{finite volumes}, these methods are conservative. This method is more used in CFD, but it is also popular for wave propagation.\\footnote{See for example Clawpack: \\url{http://depts.washington.edu/clawpack/}.}\n\\begin{figure}\n\\includegraphics[height=4cm]{img/FVM.pdf} \n\\caption{A finite volume and its surfaces.}\n\\end{figure}\n\n\\end{frame}\n\n\\subsubsection{Finite Element Methods}\n\\begin{frame}{Finite Element Methods}\nThe FEM is a method that is based on variational principles. It approximates a function in a finite set of points over the domain. To populate the matrices, the domain is split in several subregion called \\emph{elements}.\n\n\\textcolor{blue}{But I'm sure you are going to talk more about this in the rest of the course}\n\\begin{figure}\n\\includegraphics[height=4cm]{img/Piecewise_linear_function2D.pdf} \n\\caption{A piecewise function represented via {finite elements}. From: \\url{https://commons.wikimedia.org/wiki/File:Piecewise_linear_function2D.svg}}\n\\end{figure}\n\n\\end{frame}\n\n\\subsubsection{Boundary Element Methods}\n\\begin{frame}{Boundary Element Methods}\nThe BEM is similar in formulation to the FEM. The main difference lies in the dimensionality of the mesh, since it only requires the discretization of the contour. This method is really popular in fracture mechanics and wave propagation, the latter due to the capability of represent infinite domains.\n\\begin{figure}\n\\includegraphics[height=4cm]{img/BEM.pdf} \n\\caption{2D domain and the discretization of its contour using Boundary Elements.}\n\\end{figure}\n\n\\end{frame}\n\n\\subsection{CFL Condition}\n\\begin{frame}[allowframebreaks]\n\\frametitle{CFL Condition}\n\\justifying\nThe Courant-Friedrichs-Lewy condition (CFL condition) is a necessary\ncondition for convergence while solving PDEs by the method of finite\ndifferences \\cite{CFL}. It arises when explicit time-marching schemes are used.\n\nThe criterion could be stated as \n\\begin{align*}\nC=v_{x}\\frac{\\Delta t}{\\Delta x}\\leq C_{max}\\qquad\\mbox{in 1D}\\enspace;\\\\\nC=v_{x}\\frac{\\Delta t}{\\Delta x}+v_{y}\\frac{\\Delta t}{\\Delta y}\\leq C_{max}\\qquad\\mbox{in 2D}\\enspace;\\\\\nC=v_{x}\\frac{\\Delta t}{\\Delta x}+v_{y}\\frac{\\Delta t}{\\Delta y}+v_{z}\\frac{\\Delta t}{\\Delta z}\\leq C_{max}\\qquad\\mbox{in 3D}\\enspace;\n\\end{align*}\n Where $v_{x_{i}}$ is the wave speed in the\n$x_{i}$ direction, $\\Delta x_{i}$ is the minimum spatial discretization\nin $x_{i}$ direction, $\\Delta t$ is the time step and $C_{max}$\nis the maximum allowable value for $C$, which depends on the time\ndiscretization scheme but should be less than 1.\n\nA graphical representation of the criterion is given in Figure \\ref{fig:CFL}. Intuitively, we can think about the CFL condition as a limit in the speed for transferring information from one node to its neighbors; this \\emph{speed} should be less than the speed for propagation of phenomena in the wave. \n\\begin{figure}\n\\centering\n\\includegraphics[height=4cm]{img/CFLcondition.png} \n\\caption{Graphic representation of the CFL condition in 1D. \\textit{L.A. Barba et al. Practical Numerical Methods with Python, 2014.}}\\label{fig:CFL}\n\\end{figure}\n\nIn elastodynamics, and using the the FEM, the criterion could be re-stated as \n\\begin{align*}\nC\\leq\\alpha\\frac{\\Delta t}{h}\\leq C_{max}\\qquad\\mbox{in 1D}\\enspace;\\\\\nC\\leq2\\alpha\\frac{\\Delta t}{h}\\leq C_{max}\\qquad\\mbox{in 2D}\\enspace;\\\\\nC\\leq3\\alpha\\frac{\\Delta t}{h}\\leq C_{max}\\qquad\\mbox{in 3D}\\enspace;\n\\end{align*}\n where $\\alpha$ is the speed for the P-wave and $h$ is the\nminimum distance between consecutive nodes. This give us the maximum\nallowable timestep as \n\\begin{align}\n\\Delta t\\leq C_{max}\\frac{h}{\\alpha}\\qquad\\mbox{in 1D}\\enspace;\\\\\n\\Delta t\\leq\\frac{C_{max}}{2}\\frac{h}{\\alpha}\\qquad\\mbox{in 2D}\\enspace;\\\\\n\\Delta t\\leq\\frac{C_{max}}{3}\\frac{h}{\\alpha}\\qquad\\mbox{in 3D}\\enspace.\n\\end{align}\n\\end{frame}\n\n\\subsection{Nyquist-Shannon sampling criterion}\n\\begin{frame}[allowframebreaks]\n\\frametitle{Nyquist-Shannon sampling criterion}\n\\justifying\nThe Nyquist--Shannon sampling theorem is a fundamental\nresult in the field of information theory, in particular telecommunications and signal processing. Sampling is the process of converting a signal (for example, a function of continuous time or space) into a numeric sequence (a function of discrete time or space).\n\\begin{figure}\n\\centering\n\\includegraphics[height=2cm]{img/{CPT-sound-nyquist-thereom-1.5percycle}.pdf} \n\\caption{The samples of several different sine waves can be identical, when at least one of them is at a frequency above half the sample rate. From: \\url{https://commons.wikimedia.org/wiki/File:CPT-sound-nyquist-thereom-1.5percycle.svg}}\n\\end{figure}\n\nShannon's version of the theorem states \\cite{Shannon}:\n\n\\begin{quote}\nIf a function $x(t)$ contains no frequencies higher than $B$ hertz,\nit is completely determined by giving its ordinates at a series of\npoints spaced $1/(2B)$ seconds apart. \n\\end{quote}\nThis theorem implies for us in the numerical simulation of wave propagation\nthat \n\\[\nh\\leq\\frac{\\lambda}{2}\\enspace,\n\\]\n where $h$ is the maximum distance between consecutive nodes and\n$\\lambda$ is the shortest wavelength that want to be sampled. So,\nthe selection of $h$ is commonly \n\\[\nh=\\frac{\\lambda}{k}\\enspace,\n\\]\n where $k>2$ is a factor that depends on the numerical method. For\nfinite element methods $k$ is commonly 10.\n\\end{frame}\n\n\\begin{frame}[allowframebreaks]{References}\n\\def\\newblock{}\n\\bibliographystyle{plain}\n\\begin{thebibliography}{1}\n\n\\bibitem{book:arfken} George B. Arfken \\& Hans. J. Weber. Mathematical Methods for Physicists. Elsevier Academic Press, 6th Edition, San Diego, 2005.\n\n\\bibitem{ashby2005} Ashby, Michael F. ``Materials\nselection in mechanical design.\" MRS BULLETIN 30 (2005): 995.\n\n\\bibitem{CFL} Courant, R.; Friedrichs, K.; Lewy, H. (1928), \\emph{\\\"Uber\ndie partiellen Differenzengleichungen der mathematischen Physik} (in\nGerman), Mathematische Annalen 100 (1): 32--74.\n\n\\bibitem{Shannon} C. E. Shannon, \\emph{Communication in the presence\nof noise}, Proc. Institute of Radio Engineers, vol. 37, no. 1, pp.\n10--21, Jan. 1949. Reprint as classic paper in: Proc. IEEE, vol. 86,\nno. 2, (Feb. 1998).\n\n\\bibitem{book:waves-rays} Michael A. Slawinski. Waves and rays in Elastic Continua. Second Edition, 2007.\n \n\\bibitem{wiki:FDM} Finite difference method. (2014, April 29). In Wikipedia, The Free Encyclopedia. Retrieved 00:11, September 25, 2014, from \\url{http://en.wikipedia.org/w/index.php?title=Finite_difference_method&oldid=606345831}\n\n\\bibitem{wiki:FVM} Finite volume method. (2014, April 22). In Wikipedia, The Free Encyclopedia. Retrieved 00:44, September 25, 2014, from \\url{http://en.wikipedia.org/w/index.php?title=Finite_volume_method&oldid=605282055}\n \n\\bibitem{wiki:ondas} Wikipedia community. Onda (f\\'isica) [on line]. Wikipedia, La enciclopedia libre, 2010 ; 22 November 2010.\n\n\\bibitem{wiki:pseudo_spectral} Pseudo-spectral method. (2014, March 14). In Wikipedia, The Free Encyclopedia. Retrieved 23:12, September 24, 2014, from \\url{http://en.wikipedia.org/w/index.php?title=Pseudo-spectral_method&oldid=599542680}\n\n\\end{thebibliography}\n\n\\end{frame}\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "c7567605d79646658ad83ab04332c4bdfb7b5375", "size": 16965, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2014/ce795/CE597-numerical.tex", "max_stars_repo_name": "nicoguaro/talks", "max_stars_repo_head_hexsha": "01e9ddc4a44952a1ea8b1d8acf3cbc17ddbc31e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2014/ce795/CE597-numerical.tex", "max_issues_repo_name": "nicoguaro/talks", "max_issues_repo_head_hexsha": "01e9ddc4a44952a1ea8b1d8acf3cbc17ddbc31e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2014/ce795/CE597-numerical.tex", "max_forks_repo_name": "nicoguaro/talks", "max_forks_repo_head_hexsha": "01e9ddc4a44952a1ea8b1d8acf3cbc17ddbc31e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.654494382, "max_line_length": 374, "alphanum_fraction": 0.7134099617, "num_tokens": 5552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.42729587818541204}}
{"text": "\\documentclass[serif,xcolor=pdftex,dvipsnames,table,hyperref={bookmarks=false,breaklinks}]{beamer}\r\n\r\n\\input{../config.tex}\r\n\r\n\\settitlecard{8}{Numerical Linear Algebra 2}\r\n\r\n\\begin{document}\r\n\r\n\\maketitlepage\r\n\r\n% \\section{Announcements}\r\n% \\subsection{Foo}\r\n%\r\n%\r\n% \\begin{frame}[t]{Announcements}\r\n% \t\\begin{itemize}\r\n% \t\t\\item Assignment 3 is due tonight at 11:55pm.\r\n% \t\t\\item Quiz 4 will go out tonight.\r\n% \t\t\\item Assignment 4 will go out in the next couple of days.\r\n% \t\t\\item Guest lecturer on Tuesday.\r\n% \t\\end{itemize}\r\n% \\end{frame}\r\n\r\n\\section{Numerical Linear Algebra 2}\r\n\\subsection{Foo}\r\n\r\n\\begin{frame}[t]{Matrix Inversion}\r\n\t% Review\r\n\t% Where it is used\r\n\tReview: An $n\\times n$ square matrix $A$ is said to be \\textbf{invertible} if there exists an $n \\times n$ matrix $B$ such that:\r\n\t\r\n\t$$ AB = BA = I$$\r\n\t\r\n\twhere $I$ is the identity matrix. If $B$ exists it is called the \\textbf{inverse} and is denoted $A^{-1}$. Matrix inversion is the process of finding $A^{-1}$ for a given matrix $A$.\r\n\\end{frame}\r\n\t\r\n\\begin{frame}[t]{Matrix Inversion: Applications}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Matrix inverses appear in statistics frequently. Part of the reason for this is because of the appearance of a matrix inverse in the PDF of the multivariate normal distribution. \r\n\t\t\r\n\t\t$$ \\mathcal{N}(x;\\mu,\\Sigma) \\propto \\exp\\left(-\\frac{1}{2}(x-\\mu)^T \\Sigma^{-1}(x - \\mu)\\right) $$\r\n\t\t\\item The analytical solution for least-squares linear regression involves a matrix inverse.\r\n\t\t\\item Matrix inversion plays a fundamental role in many computer graphics routines.\r\n\t\t\\item Matrix inversion is a subroutine for many more complex linear algebra computations.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% Description\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Many algorithms exist for inverting a matrix.\r\n\t\t\\item We will analyze one of the fundamental algorithms called \\textbf{Gauss-Jordan Elimination}.\r\n\t\t\\item \\textbf{Gaussian Elimination} is a method for solving equations of the form $Ax = b$ where $A$ is a matrix, $b$ is a vector, and we are solving for the vector $b$.\r\n\t\t\\item Gaussian elimination can be thought of as a systematic application of simple substitution rules.\r\n\t\t\\item Gauss-Jordan elimination is the application of this idea to the equation $AX = I$ where now $X$ is a matrix rather than a vector.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\tWe'll start with a simple example: Let $A$ be the following $2 \\times 2$ matrix.\r\n\t\r\n\t\\pause\r\n\t$$A = \\begin{bmatrix}[rr]\r\n    \t1 & 3 \\\\\r\n\t\t2 & 5\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\tOur goal is to find the inverse.\r\n\t\\pause\r\n\t$$A^{-1} = \\begin{bmatrix}[rr]\r\n    \t-5 & 3 \\\\\r\n\t\t2 & -1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\tWe begin by writing $A$ in the following augmented form:\r\n\t\r\n\t\\pause\r\n\t$$A = \\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t2 & 5 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\tWe then apply elementary row operations until the left side is equal to the identity matrix. Elementary row operations include:\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Scaling a row by a non-zero constant.\r\n\t\t\\item Adding a scaled row to another row.\r\n\t\t\\item Swapping two rows (we will not use this).\r\n\t\\end{itemize}\r\n\t\r\n\t\\pause\r\n\tIf we are able to do this without getting a row of all zeros on the left, then the right side will be $A^{-1}$. If at any point we get a row with all zeros, then the matrix has no inverse.\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t2 & 5 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t$$R_2 \\leftarrow R_2 - 2R_1$$\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t0 & -1 & -2 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t0 & -1 & -2 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t$$R_2 \\leftarrow -R_2$$\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t0 & 1 & 2 & -1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 3 & 1 & 0\\\\\r\n\t\t0 & 1 & 2 & -1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t$$R_1 \\leftarrow R_1 - 3R_2$$\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rr|rr]\r\n    \t1 & 0 & -5 & 3\\\\\r\n\t\t0 & 1 & 2 & -1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\centering\r\n\t\\Huge{Done!}\r\n\\end{frame}\r\n\r\n% \\begin{frame}[t]{Gauss-Jordan Elimination}\r\n% \t% 2x2 example\r\n% \t$$\\begin{bmatrix}[rr|rr]\r\n%     \t1 & 0 & -5 & 3\\\\\r\n% \t\t0 & 1 & 2 & -1\r\n% \t\\end{bmatrix}$$\r\n%\r\n% \t\\pause\r\n% \t\\centering\r\n% \t\\Huge{Done!}\r\n%\r\n% \\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\tWith such a small matrix it is hard to get a sense for what the steps are:\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item For each row $i$ from top to bottom:\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item Scale the row so that the diagonal entry equals 1.\r\n\t\t\t\\item Subtract a scaled version of row $i$ from each row below $i$ so that the $i$th column in each of these rows is $0$.\r\n\t\t\t\\item This eliminates all entries below the diagonal and sets the diagonal to ones.\r\n\t\t\\end{itemize}\r\n\t\t\\item Repeat this process from the bottom up, this time eliminating entries above the diagonal.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$A = \\begin{bmatrix}[rrr]\r\n    \t2 & 3 & 0\\\\\r\n\t\t1 & -2 & -1\\\\\r\n\t\t2 & 0 & -1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t2 & 3 & 0 & 1 & 0 & 0\\\\\r\n\t\t1 & -2 & -1 & 0 & 1 & 0\\\\\r\n\t\t2 & 0 & -1 & 0 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_1 &\\leftarrow \\frac{1}{2}R_1\\\\\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t1 & -2 & -1 & 0 & 1 & 0\\\\\r\n\t\t2 & 0 & -1 & 0 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t1 & -2 & -1 & 0 & 1 & 0\\\\\r\n\t\t2 & 0 & -1 & 0 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_2 &\\leftarrow R_2 - R_1\\\\\r\n\t\tR_3 &\\leftarrow R_3 - 2R_1\\\\\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & -\\frac{7}{2} & -1 & -\\frac{1}{2} & 1 & 0\\\\\r\n\t\t0 & -\\frac{6}{2} & -1 & -1 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & -\\frac{7}{2} & -1 & -\\frac{1}{2} & 1 & 0\\\\\r\n\t\t0 & -\\frac{6}{2} & -1 & -1 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_2 &\\leftarrow -\\frac{7}{2}R_2\\\\\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & \\frac{2}{7} & \\frac{1}{7} & -\\frac{2}{7} & 0\\\\\r\n\t\t0 & -\\frac{6}{2} & -1 & -1 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & \\frac{2}{7} & \\frac{1}{7} & -\\frac{2}{7} & 0\\\\\r\n\t\t0 & -\\frac{6}{2} & -1 & -1 & 0 & 1\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_3 &\\leftarrow R_3 + \\frac{6}{2}R_2\\\\\r\n\t\tR_3 &\\leftarrow -7R_3\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & \\frac{2}{7} & \\frac{1}{7} & -\\frac{2}{7} & 0\\\\\r\n\t\t0 & 0 & 1 & -4 & -6 & -7\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & \\frac{2}{7} & \\frac{1}{7} & -\\frac{2}{7} & 0\\\\\r\n\t\t0 & 0 & 1 & -4 & -6 & -7\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_2 &\\leftarrow R_2 - \\frac{2}{7}R_3\\\\\r\n\t\tR_1 &\\leftarrow R_1 + 0R_3\\\\\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & 0 & -1 & -2 & 2\\\\\r\n\t\t0 & 0 & 1 & -4 & -6 & -7\r\n\t\\end{bmatrix}$$\r\n\t\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Elimination}\r\n\t% 2x2 example\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & \\frac{3}{2} & 0 & \\frac{1}{2} & 0 & 0\\\\\r\n\t\t0 & 1 & 0 & -1 & -2 & 2\\\\\r\n\t\t0 & 0 & 1 & -4 & -6 & -7\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tR_1 &\\leftarrow R_1 - \\frac{3}{2}R_2\\\\\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t$$\\begin{bmatrix}[rrr|rrr]\r\n    \t1 & 0 & 0 & 2 & 3 & -3\\\\\r\n\t\t0 & 1 & 0 & -1 & -2 & 2\\\\\r\n\t\t0 & 0 & 1 & -4 & -6 & -7\r\n\t\\end{bmatrix}$$\r\n\t\r\n\t\\pause\r\n\t\\centering\r\n\t\\Huge{Done!}\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Complexity}\r\n\t% Complexity\r\n\t% n multiplications\r\n\t% n multiplications\r\n\t% (n - i)*n additions\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item When you scale a row so that its diagonal is one, how many multiplications do we perform? How many times do we do this?\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item $n$ multiplications. One per item in the row.\r\n\t\t\t\\item $n$ times. Once per row.\r\n\t\t\\end{itemize}\r\n\t\t\\item When performing a row reduction (adding one scaled row to another), how many multiplications and additions do we perform? How many many rows to we add row $i$ to?\r\n\t\t\\begin{itemize}\r\n\t\t\t\\item $n$ multiplications. (technically $n-i$)\r\n\t\t\t\\item $n$ additions. (technically $n-i$)\r\n\t\t\t\\item We add row $i$ to all rows below row $i$, so $n-i$ times.\r\n\t\t\\end{itemize}\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Gauss-Jordan Complexity}\r\n\t\\begin{align*}\r\n\t\t\\onslide<1->{\\text{No. Operations } &= 2\\sum_{i=1}^{n}\\left(n + 2n(n-i)\\right)\\\\}\r\n\t\t\\onslide<2->{&= 2\\sum_{i=1}^{n}\\left(n + 2n^2 - 2ni\\right)\\\\}\r\n\t\t\\onslide<3->{&= 2\\left[\\sum_{i=1}^{n}n + 2\\sum_{i=1}^{n}n^2 - 2\\sum_{i=1}^{n}ni\\right]\\\\}\r\n\t\t\\onslide<4->{&= 2\\left[n^2 + 2n^3 - 2n\\frac{n(n+1)}{2}\\right]\\\\}\r\n\t\t\\onslide<5->{&= 2\\left[n^2 + 2n^3 - n^3 + n^2\\right]\\\\}\r\n\t\t\\onslide<6->{&= 4n^2 + 2n^3} \\onslide<7>{= \\mathcal{O}(n^3)}\r\n\t\\end{align*}\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Advanced Matrix Inverse Algorithms}\r\n\t% Description\r\n\tAs with matrix multiplication, more sophisticated algorithms exist the have complexity between $n^2$ and $n^3$.\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Estimating the complexity of NumPy Matrix Inverse}\r\n\t% Fit a line\r\n\tThe algorithm used by NumPy is not well documented. How could we estimate its complexity? \\pause(Hint: We know the complexity is approximately a monomial (e.g. $\\mathcal{O}(n^3)$)).\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\t\\text{Run time } &\\approx Cn^b\\\\\r\n\t\t\\log(\\text{Run time}) &\\approx \\log(C) + b\\log(n)\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\tSolution: \r\n\t\\begin{enumerate}\r\n\t\t\\item Run a bunch of tests for different $n$ and record the run times.\r\n\t\t\\item Fit a line to the $\\log$ run times. The slope will be the degree of the polynomial and the intercept will be the logged constant.\r\n\t\\end{enumerate}\r\n\t \r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}[t]{Estimating the complexity of NumPy Matrix Inverse}\r\n\t% Fit a line\r\n\t\\centering\r\n\t\\Huge{Demo}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Eigenreview}\r\n\t% Description\r\n\t% Eigen Review\r\n\tLet $A$ be a square $n\\times n$ matrix, then the $\\mathbf{v}$ is an \\textbf{eigenvector} of $A$ if\r\n\t\r\n\t$$A\\mathbf{v} = \\lambda\\mathbf{v}$$\r\n\t\r\n\tfor some constant $\\lambda$ known as an \\textbf{eigenvalue}. \\textbf{Eigen decomposition} is the process of finding the eigenvalue/eigenvector pairs of a matrix.\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Eigen Decomposition: Applications}\r\n\t% Description\r\n\t% Eigen Review\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Eigen decompositions are used in many practical applications:\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item Google's PageRank computes the largest eigenvalue/vector pair.\r\n\t\t\t\\item Principal Components Analysis (PCA) is used in many data analysis settings to reduce the dimensionality of a dataset and reduce collinearity.\r\n\t\t\t\\item Spectral clustering is used in machine learning and computer vision for clustering data points and parts of images. Spectral clustering requires calculating the Eigen decomposition of a similarity matrix.\r\n\t\t\\end{itemize}\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Eigen Decomposition: Eigenfaces}\r\n\t% Description\r\n\t% Eigen Review\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item One of the seminal early pieces of work in computer vision worked by compressing images into eigenvectors.\r\n\t\t\\item The basic idea was to calculate the number of images by number of images image covariance matrix and computing the eigenvectors of this matrix.\r\n\t\t\\item The result is one eigenvector for each image.\r\n\t\t\\item The most well known application was facial recognition where each image was of a face, hence eigenfaces.\r\n\t\\end{itemize}\r\n\t\r\n\t\\pause\r\n\t\\centering\r\n\t\\includegraphics[height=1in]{{../Figures/Eigenfaces}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Eigen Decomposition: The Power Method}\r\n\t% Description\r\n\tThe Power method is a method for calculating the eigenvalue corresponding to the greatest eigenvalue. Many other methods for calculating the full set of eigenvalues are generalizations of this method.\r\n\t\r\n\t\\pause\r\n\t\\begin{block}{The Power Method}\r\n\t\t\\begin{enumerate}[<+->]\r\n\t\t\t\\item Given an $n\\times n$ matrix $A$, choose a random initial vector $b_0$.\r\n\t\t\t\\item Then, under some mild assumptions, the following sequence will converge to the dominant eigenvector:\r\n\t\t\t\r\n\t\t\t$$\\frac{Ab_0}{\\norm{Ab_0}},\\frac{A^2b_0}{\\norm{A^2b_0}},\\frac{A^3b_0}{\\norm{A^3b_0}},...$$\r\n\t\t\\end{enumerate}\r\n\t\\end{block}\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Eigen Decomposition: Complexity}\r\n\t% Description\r\n\tIf we were to calculate matrix matrix powers $A^k$ directly using matrix multiplication, what is the complexity of calculating $A^k$?\r\n\t\r\n\t\\pause\r\n\t\\begin{itemize}\r\n\t\t\\item Answer: We would need to perform $k$ matrix multiplications, thus using Strassen's this would take $\\approx\\mathcal{O}(kn^{2.807})$.\r\n\t\\end{itemize}\r\n\t\r\n\t\\pause\r\n\tFortunately, there is a better way. We can use the following interative algorithm:\r\n\t\r\n\t$$b_{k} = \\frac{A^kb_0}{\\norm{A^kb_0}} = \\frac{A(A^{k-1}b_0)}{\\norm{A(A^{k-1}b_0)}} = \\frac{Ab_{k-1}}{\\norm{Ab_{k-1}}}$$\r\n\t\r\n\t\\pause\r\n\tWhat is the complexity of computing $Ab_{k-1}$?\r\n\t\r\n\t\\pause\r\n\t\\begin{itemize}\r\n\t\t\\item The power method has complexity $\\mathcal{O}(n^2)$ \\textbf{per iteration}.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}\r\n\t% Linear Regression Derivation\r\n\tLet $X \\in \\mathbb{R}^{n\\times m}$ be a $n \\times m$ matrix of data cases (i.e. design matrix) and let $y \\in \\mathbb{R}^n$ be a length $n$ vector of real values. Then in ordinary least squares linear regression, we have the following model:\r\n\r\n\t$$y = \\beta X + \\epsilon$$\r\n\r\n\twhere $\\epsilon$ is a normally distributed vector of noise. \\pause Then using Maximum Likelihood Estimation, we estimate $\\hat{\\beta}$ as\r\n\r\n\t$$\\hat{\\beta} = \\argmin_\\beta (\\beta X - y)^T(\\beta X - y)$$\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}\r\n\t% Linear Regression Derivation\r\n\tThe solution to this minimization problem can be found by taking the gradient with respect to $\\beta$, setting it to zero, and solving. The results is:\r\n\t\r\n\t$$\\hat{\\beta} = (X^T X)^{-1}X^Ty$$\r\n\t\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item We can solve this using just matrix inversion and matrix multiplication.\r\n\t\t\\item The advanced linear algebraist may have noticed that $(X^T X)^{-1} X^T$ is called the \\textbf{Moore-Penrose pseudoinverse}.\r\n\t\t\\item There are specialized algorithms for computing the Moore-Penrose pseudoinverse.\r\n\t\t\\item Part of Assignment 4 will be implementing and comparing linear regression using straight inversion vs. pseudoinversion.\r\n\t\\end{itemize}\r\n\r\n\\end{frame}\r\n\r\n% \\begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}\r\n% \t% Demo\r\n% \t\\centering\r\n% \t\\Huge{Demo}\r\n% \\end{frame}\r\n\r\n\\begin{frame}[t]{Linear Algebra in NumPy}\r\n\tNumPy has a sub-module called \\textbf{numpy.linalg} which implements the following groups of methods:\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Products: inner, outer, matrix, etc.\r\n\t\t\\item Decompositions: Cholesky, QR, SVD, Eigen\r\n\t\t\\item Special numbers: rank, norm, determinant, etc.\r\n\t\t\\item Solvers: Inversion, solve $Ax = b$, least squares, pseudoinversion, etc.\r\n\t\t\\item Plus a few more...\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Numerical Linear Algebra: Major Takeaways}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item If you continue to do numerical computing, you will likely find yourself using some of these linear algebra computations.\r\n\t\t\\item Keep the approximate complexities for the major methods in mind so that you know what is feasible in your programs.\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item For example: Directly solving linear regression with 1,000 instances is feasible, but 1,000,000 might not be. In this case you should consider a different method.\r\n\t\t\\end{itemize}\r\n\t\t\\item As a rule of thumb, assume $\\mathcal{O}(n^3)$ runtime.\r\n\t\t\\item Approximations for many of these computations exist that are good enough in many cases.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n% \\begin{frame}[t]{Eigen Decomposition: QR Algorithm}\r\n% \t% Description\r\n% \\end{frame}\r\n%\r\n% \\begin{frame}[t]{Eigen Decomposition: QR Algorithm}\r\n% \t% Description\r\n% \\end{frame}\r\n\r\n% \\section{Sparse Matrices}\r\n% \\subsection{Foo}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "4c97993d6550dbe04c28390f08ad6620528a43db", "size": 17369, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Lecture08/lecture.tex", "max_stars_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_stars_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-18T05:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T05:36:19.000Z", "max_issues_repo_path": "src/Lecture08/lecture.tex", "max_issues_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_issues_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Lecture08/lecture.tex", "max_forks_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_forks_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:22:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-09T20:22:57.000Z", "avg_line_length": 31.6375227687, "max_line_length": 243, "alphanum_fraction": 0.6330819276, "num_tokens": 6294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.4272958719433862}}
{"text": "%%% Template originaly created by Karol Kozioł (mail@karol-koziol.net) and modified for ShareLaTeX use\n\n\\documentclass[a4paper,11pt]{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\n\\renewcommand\\familydefault{\\sfdefault}\n\\usepackage{tgheros}\n\\usepackage[defaultmono]{droidmono}\n\n\\usepackage{amsmath,amssymb,amsthm,textcomp}\n\\usepackage{enumerate}\n\\usepackage{multicol}\n\\usepackage{tikz}\n\n\\usepackage{geometry}\n\\geometry{left=25mm,right=25mm,%\nbindingoffset=0mm, top=20mm,bottom=20mm}\n\n\n\\linespread{1.3}\n\n\\newcommand{\\linia}{\\rule{\\linewidth}{0.5pt}}\n\n% custom theorems if needed\n\\newtheoremstyle{mytheor}\n    {1ex}{1ex}{\\normalfont}{0pt}{\\scshape}{.}{1ex}\n    {{\\thmname{#1 }}{\\thmnumber{#2}}{\\thmnote{ (#3)}}}\n\n\\theoremstyle{mytheor}\n\\newtheorem{defi}{Definition}\n\n% my own titles\n\\makeatletter\n\\renewcommand{\\maketitle}{\n\\begin{center}\n\\vspace{2ex}\n{\\huge \\textsc{\\@title}}\n\\vspace{1ex}\n\\\\\n\\linia\\\\\n\\@author \\hfill \\@date\n\\vspace{4ex}\n\\end{center}\n}\n\\makeatother\n%%%\n\n% custom footers and headers\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\lhead{}\n\\chead{}\n\\rhead{}\n\\lfoot{Object Tracking}\n\\cfoot{}\n\\rfoot{Page \\thepage}\n\\renewcommand{\\headrulewidth}{0pt}\n\\renewcommand{\\footrulewidth}{0pt}\n%\n\n% code listing settings\n\\usepackage{listings}\n\\lstset{\n    language=Matlab,\n    basicstyle=\\ttfamily\\small,\n    aboveskip={1.0\\baselineskip},\n    belowskip={1.0\\baselineskip},\n    columns=fixed,\n    extendedchars=true,\n    breaklines=true,\n    tabsize=4,\n    prebreak=\\raisebox{0ex}[0ex][0ex]{\\ensuremath{\\hookleftarrow}},\n    frame=lines,\n    showtabs=false,\n    showspaces=false,\n    showstringspaces=false,\n    keywordstyle=\\color[rgb]{0.627,0.126,0.941},\n    commentstyle=\\color[rgb]{0.133,0.545,0.133},\n    stringstyle=\\color[rgb]{01,0,0},\n    % numbers=left,\n    % numberstyle=\\small,\n    % stepnumber=1,\n    % numbersep=10pt,\n    % captionpos=t,\n    escapeinside={\\%*}{*)}\n}\n\n%%%----------%%%----------%%%----------%%%----------%%%\n\n\\begin{document}\n\n\\title{The Extended Kalman Filter}\n\n\\author{Mehdi Raza Khorasani, Habib University}\n\n\\date{26/6/2021}\n\n\\maketitle\n\n\\section*{Introduction}\nThe extended Kalman Filter is an extension to the Kalman Filter Algorithm. The KF algorithm is defined for Discrete time Linear time invariant systems (DT LTI), which are of the form: \n\\begin{equation}\n    x_k = Fx_{k-1} + V_k \n\\end{equation}\n\\begin{equation}\n    y_k = Hx_{k} + W_k \n\\end{equation}\nThe algorithm fails when the system cannot be represented as $(1)$ and $(2)$. The extended KF approach suggests that we linearize the system and obtain a linear approximation, and then develop a KF algorithm for it. The following lines describe how a non linear system can be linearized and a KF algorithm can be applied to it.\n\\subsection*{The discrete time non-linear system}\nConsider a non-linear system, defined by the following equations: \n\\begin{equation}\n    x_k = f(x_{k-1}) + V_k \n\\end{equation}\n\\begin{equation}\n    y_k = h(x_{k}) + W_k\n\\end{equation}\nwhere, $V_k$ and $W_k$ is white uncorrelated Gaussian noise defined as follows: \n\n\\begin{equation*}\n    V_k \\sim (0, Q_k)\n\\end{equation*}\n\\begin{equation*}\n    W_k \\sim (0, R_k)\n\\end{equation*}\n\n\\section*{The EKF Algorithm}\nThe algorithm of the EKF consists of linearlizing the plant about the optimal value and consecutively applying the baysian estimation steps. Similarly, the observations are also linearized about the optimal value. The following lines summarize the filtering algorithm: \n\n\\begin{enumerate}\n    \\item \n    Linearization: Compute the Jacobian of $f$ at $\\hat{x}_{k-1|k-1}$ i.e. about the last optimal estimate of $x_k$:\n    \\begin{equation*}\n        F_k = \\nabla_{X^T} f(x) \\mid_{x = \\hat{x}_{k-1|k-1}}\n    \\end{equation*}\n    \n    \\item \n    State Prediction: Compute Predicted mean and co-variance matrix: \n    \\begin{equation*}\n        \\hat{x}_{k|k-1} = f(\\hat{x}_{k-1|k-1})\n    \\end{equation*}\n    \\begin{equation*}\n        P_{k|k-1} = F_k P_{k-1|k-1} F_k^T + Q_k\n    \\end{equation*}\n    \n    \\item \n    Linearization: Compute the jacobian of $h$ at $\\hat{x}_{k|k-1}$ i.e. about the estimate of $x$ given the last estimate: \n    \\begin{equation*}\n        H_k = \\nabla_{X^T} h(x) \\mid_{x = \\hat{x}_{k|k-1}}\n    \\end{equation*}\n    \n    \\item \n    Measurement Prediction: Compute predicted mean, covariance and Kalman gain: \n    \\begin{equation*}\n        \\hat{y}_{k|k-1}  = h(\\hat{x}_{k|k-1})\n    \\end{equation*}\n    \\begin{equation*}\n        S_k = H_k P_{k|k-1} H_k^T + R_k \n    \\end{equation*}\n    \\begin{equation*}\n        K_k = P_{k|k-1} H_k^T S_k^{-1}\n    \\end{equation*}\n    \n    \\item\n    Estimation: Compute the posterior mean and co-variance as follows: \n    \\begin{equation*}\n        \\hat{x}_{k|k} = \\hat{x}_{k|k-1} + K_k(y_k - \\hat{y}_{k|k-1})\n    \\end{equation*}\n    \\begin{equation*}\n        P_{k|k} = P_{k|k-1} - K_k H_k P_{k|k-1}\n    \\end{equation*}\n\\end{enumerate}\n\n\\section*{Simulation}\nWe simulate the non-linear system observed by a Radar. The system and radar are governed by the following equations: \n\n\\begin{equation}\n    \\boldsymbol{x_k} = \n    \\begin{bmatrix}\n    x_k\\\\\n    y_k\\\\\n    \\phi_k\n    \\end{bmatrix} = \n    \\begin{bmatrix}\n    x_{k-1} + T v_k cos(\\phi_{k-1}) \\\\\n    y_{k-1} + T v_k sin(\\phi_{k-1}) \\\\\n    \\phi_{k-1} + T\\omega_k\n    \\end{bmatrix} + \n    \\begin{bmatrix}\n    V_{1, k}\\\\\n    V_{2, k}\\\\\n    V_{3, k}\n    \\end{bmatrix}\n\\end{equation}\n\\begin{equation}\n    \\boldsymbol{y_k} = \n    \\begin{bmatrix}\n    \\sqrt{x_k^2+y_k^2}\\\\\n    tan^{-1}\\frac{y_k}{x_k}\n    \\end{bmatrix}\n\\end{equation}\nwhere $v_k$, $\\omega_k$ are the linear and angular velocities of the object respectively and $T$ is sampling time. They are taken as constants: \n\\begin{equation*}\n    v_k = 0.1, \\\\ \\omega_k = 0.01, \\\\ T = 0.05\n\\end{equation*}\n\\subsection*{Algorithm}\n\n\\subsubsection{Initialization}\n\\begin{enumerate}\n    \\item \n    The co-variance Matrix of process Noise was taken as follows: \n\\begin{equation*}\n    Q_k = \n    \\begin{bmatrix}\n    1e^{-6} & 0 & 0\\\\\n    0 & 1e^{-6} & 0 \\\\\n    0 & 0 & 1e^{-6}\n    \\end{bmatrix}\n\\end{equation*}\n\n    \\item The co-variance Matrix of Radar Noise was taken as follows: \n\\begin{equation*}\n    R_k = \n    \\begin{bmatrix}\n    1e^{-4} & 0 & 0\\\\\n    0 & 1e^{-4} & 0 \\\\\n    0 & 0 & 1e^{-4}\n    \\end{bmatrix}\n\\end{equation*}\n    \n    \\item \n    $\\mathbf{MATLAB}$'s $randn()$ function was used to generate the the noise vectors $V_k$ and $W_k$ of dimensions $3\\times 1$ and $2 \\times 1$ respectively.  \n\n    \\item \n    Compute the true value of $x_k$ and $y_k$ from the model's equation (5) and (6) to simulate the non-linear object and Radar.\n    \n\\end{enumerate}\n\n\\subsubsection{Linearization}\n\\begin{enumerate}\n    \\item \n    The pseudo function for this step is as follows: \n    \\begin{lstlisting}\n        F_k = F_jacobian(T, vk, xhat_km1)\n    \\end{lstlisting}\n    \n    \\item The jacobian of $f$ is computed as follows: \n    \\begin{equation*}\n         F_k = \\begin{bmatrix}\n         \\frac{\\partial f_1}{\\partial x_k} & \\frac{\\partial f_1}{\\partial y_k} & \\frac{\\partial f_1}{\\partial \\phi_k} \\\\ \n         \\frac{\\partial f_2}{\\partial x_k} & \\frac{\\partial f_2}{\\partial y_k} & \\frac{\\partial f_2}{\\partial \\phi_k} \\\\ \n         \\frac{\\partial f_3}{\\partial x_k} & \\frac{\\partial f_3}{\\partial y_k} & \\frac{\\partial f_3}{\\partial \\phi_k}\n         \\end{bmatrix}_{\\mathbf{x} = \\hat{x}_{k-1|k-1}}\n    \\end{equation*}\n    where: \n    \\begin{equation*}\n        \\begin{bmatrix}\n            f_1 \\\\\n            f_2 \\\\\n            f_3 \n        \\end{bmatrix}\n        = \n        \\begin{bmatrix}\n            x_{k-1} + Tv_k \\cos(\\phi_{k-1})\\\\\n             y_{k-1} + Tv_k \\sin(\\phi_{k-1})\\\\\n             \\phi_{k-1} + Tw_k \n        \\end{bmatrix}_{\\mathbf{x} = \\hat{x}_{k-1|k-1}}\n    \\end{equation*}\n    \n     substituting values and taking respective partial derivatives, we get: \n    \\begin{equation*}\n         F_k = \\begin{bmatrix}\n         1 & 0 & -Tv_k \\sin{\\phi_{k-1}} \\\\ \n         0 & 1 & Tv_k \\cos{\\phi_{k-1}} \\\\ \n         0 & 0 & 1\n         \\end{bmatrix}_{\\mathbf{x} = \\hat{x}_{k-1|k-1}}\n    \\end{equation*}\n\\end{enumerate}\n\n\\subsubsection{State Prediction}\n\\begin{enumerate}\n    \\item \n    Pseudo function for this step is: \n     \\begin{lstlisting}\n        [xhat_predict, P_predict] = state_predict(xhat_km1, P_km1, F_k,  Q_k, vk, wk, T)\n    \\end{lstlisting}\n    \\item The mean is predicted by substituting $\\hat{x}_{k-1|k-1}$ directly in $f$ of equation (5)\n    \\item The co-variance is predicted as described earlier.\n    \n\\end{enumerate}\n\n\\subsubsection{Linearization}\n\\begin{enumerate}\n    \\item \n    The pseudo function for this step is as follows: \n    \\begin{lstlisting}\n        H_k = H_jacobian(xhat_predict)\n    \\end{lstlisting}\n    \n    \\item The jacobian of $h$ is computed similar to what was described earlier. It comes out to be:\n    \\begin{equation*}\n         H_k = \\begin{bmatrix}\n         -\\frac{x_k}{\\sqrt{x_k^2+y_k^2} } & \\frac{x_k}{\\sqrt{x_k^2+y_k^2} } & 0 \\\\ \n         \\frac{-y_k}{x_k^2+y_k^2} & \\frac{x_k}{x_k^2+y_k^2} & 0 \n         \\end{bmatrix}_{\\mathbf{x} = \\hat{x}_{k|k-1}}\n    \\end{equation*}\n\\end{enumerate}\n\n\\subsubsection{Measurement Prediction}\n\n    The pseudo function for this step is as follows: \n    \\begin{lstlisting}\n        [yhat_last,K_k] = measurement_predict(xhat_predict, H_k, P_predict, R_k)\n    \\end{lstlisting}\n    \n\\subsubsection{Estimation}\n    The pseudo function for this step is as follows: \n    \\begin{lstlisting}\n        [xhat_optimal,P_optimal] = estimate(y_k, yhat_predict, P_predict, H_k, K_k)\n    \\end{lstlisting}\n\n\\subsection*{Results}\nThe true trajectory, sensor observations and predicted trajectory are plotted in figure 1. As can be observed, the EKF algorithm is able to rightly and accurately able to localize the non-linear object. \n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale = 1.0]{results.eps}\n    \\caption{Trajectory of Non linear Object}\n    \\label{fig:my_label}\n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "543fe9500d72802e11b9b14d0d05e074801aad07", "size": 9951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/report.tex", "max_stars_repo_name": "mehhdiii/Extended-Kalman-Filter-Algorithm", "max_stars_repo_head_hexsha": "c98b3686b85b8eb069c3aac66d29296e8b5dec39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-08-13T11:48:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-16T10:59:57.000Z", "max_issues_repo_path": "Report/report.tex", "max_issues_repo_name": "mehhdiii/Extended-Kalman-Filter-Algorithm", "max_issues_repo_head_hexsha": "c98b3686b85b8eb069c3aac66d29296e8b5dec39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/report.tex", "max_forks_repo_name": "mehhdiii/Extended-Kalman-Filter-Algorithm", "max_forks_repo_head_hexsha": "c98b3686b85b8eb069c3aac66d29296e8b5dec39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.7044776119, "max_line_length": 327, "alphanum_fraction": 0.6398351924, "num_tokens": 3365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.754914975839675, "lm_q1q2_score": 0.4272958688223732}}
{"text": "\\documentclass{article}\n\\pagestyle{empty}\n\\usepackage{amsmath,amssymb,amsfonts,soul}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\setlength{\\oddsidemargin}{0in} \\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{0in} \\setlength{\\textheight}{8.5in}\n\\setlength{\\textwidth}{6.5in}\n\n\\makeatletter\n\\renewcommand*\\env@matrix[1][*\\c@MaxMatrixCols c]{%\n\t\\hskip -\\arraycolsep\n\t\\let\\@ifnextchar\\new@ifnextchar\n\t\\array{#1}}\n\\makeatother\n\n\\begin{document}\n\\begin{flushleft}\n\t\\bfseries{MATH 260, Linear Systems and Matrices, Fall `14}\\\\\n\t\\bfseries{Activity 3:  Elementary Row Operations}\\\\\n%\t\\bfseries{Honor Code:} \\hspace{3.5in}\\bfseries{Names:}\\\\\n\\end{flushleft}\n\\begin{flushleft}\n\n\\section*{Algebra Warmup}\nSolve the following system of equations by elimination. Everytime you add two equations, or multiply by numbers, right out explicitly what you are adding together or multiplying by on the left.\n\n\\vspace{0.25in}\n\n\\begin{center}\n$\\begin{array}{rrrrrcr}\nx&+&y&+&z&=&3\\\\\n2x&-&2y&-&z&=&-9\\\\\n-x&+&y&-&z&=&3\n\\end{array}\n$\n\\end{center}\n\n\\newpage\n\n\\section{Turning Systems into Matrices}\n\nLinear Algebra is a mathematical field which allows fast and easy solving of systems of linear equations by denoting operations on the entire system succinctly.  Notice that it was rather messy to work with all of those equations in the warmup excercise; imagine doing that for 5 or 10 variables and equations. There are two notations we use in Linear Algebra to condense systems: \\textit{Matrix-Vector Form} and \\textit{Augmented Matrices}. Let's turn the system from the warmup into Matrix-Vector Form:\n\n\\vspace{0.2in}\n\na) First, we'll identify all the variables of the system and put them together into one column vector of size $3 \\times 1$: $\\vec{\\textbf{x}}=\\begin{bmatrix} x\\\\y\\\\z\\end{bmatrix}$\n\n\\vspace{0.2in}\n\nb) Make a matrix of the variables' coefficients; we'll call it \\textbf{A}.  It should have size $3 \\times 3$.  Write it out. What would $\\textbf{A}\\cdot\\vec{\\textbf{x}}$ be?\n\n\\vspace{1.5in}\n\nc) Write the values on the right-hand sides of the $=$ as a $3 \\times 1$ column vector.  Call it $\\vec{\\textbf{b}}$.\n\n\\vspace{1in}\n\nd) Using the vectors $\\vec{\\textbf{x}}$, $\\vec{\\textbf{b}}$ and the matrix \\textbf{A}, express the system of equations from the warmup as a single matrix-vector equation.\n\n\\vspace{1.5in}\n\ne) Augmented Matrix form is where we just the coefficients (\\textbf{A}) and the right-hand-side ($\\vec{\\textbf{b}}$). We write is as: $[\\textbf{A}|\\vec{\\textbf{b}}]$. Generally, we actually write out the numbers, as we want to manipulate the augemented matrix.  Write out the full augmented matrix for this system (it should be a $3 \\times 4$ matrix with a vertical line before the last column).\n\n\\newpage\n\n\\section{Row Operations}\n\nThe main reason we want an augemented matrix is to use it for solving systems. One way to solve the system is by doing row operations to get it into \\textit{row echelon form} (REF) or \\textit{reduced row echelon form} (RREF). We'll define these in a bit, once we are comfortable with operations...\\\\\n\n\\vspace{0.1in}\n\n\\hrulefill \\\\\n\\noindent\nThere are three basic row operations we can perform (see page 134 of the text):\\\\\n$R_i$ means row \\textit{i} before an operation while $R_i^*$ denotes row \\textit{i} after an operation.\\\\\n1) Row swap between row \\textit{i} and row \\textit{j}, denoted: $R_i \\leftrightarrow R_j$\\\\\n2) Multiply a row \\textit{i} by a constant \\textit{c} ( with $c\\neq 0$) , denoted: $R_i^*=c R_i$\\\\\n3) Add a (multiple) of a row to another row, denoted: $R_i^*= R_i+c R_j$\\\\\n\\hrulefill \\\\\n\n\\vspace{0.1in}\n\n\\noindent\n\nLets try these out with our augmented matrix version of the warmup problem:\n\n\\vspace{0.2in}\n\na) Perform the following row operations in sequence:\\\\\n\n\\vspace{0.1in}\n\n$\\begin{array}{c}\n\\\\\n\\\\\nR_2 \\leftrightarrow R_3\\\\\n\\\\\n\\\\\n\\\\\n\\end{array}\n$\n\\hspace{0.55in}\n$\\begin{bmatrix}[ccc|c]\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\end{bmatrix}$\n\\hspace{0.2in}\n$\\begin{array}{c}\n\\\\\n\\\\\n\\\\\n\\\\\nR_3^*=R_3+2 R_2\\\\\n\\end{array}\n$\n\\hspace{0.25in}\n$\\begin{bmatrix}[ccc|c]\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\end{bmatrix}$\\\\\n\\vspace{0.1in}\n$\\begin{array}{c}\n\\\\\n\\\\\nR_2^* = R_1 + R_2\\\\\n\\\\\n\\end{array}\n$\n\\hspace{0.25in}\n$\\begin{bmatrix}[ccc|c]\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\end{bmatrix}$\n\\hspace{0.2in}\n$\\begin{array}{c}\n\\\\\n\\\\\nR_2^*= \\frac{1}{2}R_2\\\\\n\\\\\nR_3^*= -\\frac{1}{3}R_3\\\\\n\\end{array}\n$\n\\hspace{0.5in}\n$\\begin{bmatrix}[ccc|c]\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}& \\hspace{0.2in}\\\\\n& & & \\\\\n\\end{bmatrix}$\\\\\n\\vspace{0.1in}\nYou should now have an augmented matrix with 8 non-zero entries.  The first non-zero entry in each row should also be a positive 1.  Now, let's convert this augmented matrix back into equations...\\\\\n\\vspace{0.1in}\nb) Rewrite your final augmented matrix below, without the brackets or line (but leave space between each number). Now, beside each number in column 1 put an `$x$', column 2 a `$y$' and column 3 a `$z$'. Where the vertical line was, put an `=' sign.\n\n\\vspace{1.25in}\n\nc) How does this compare to what you got for the warmup?  How do the row operations compare to what you did to solve by elimination?\n\n\\vspace{1.5in}\n\n\\newpage\n\\section{REF and RREF}\n\nThe matrix we got at the end of 2a was in \\textit{row echelon form}. A matrix in REF has the following traits (see page 136 of the text):\n\n\\begin{enumerate}\n\t\\item Any zero rows are at the bottom\n\t\\item The leftmost non-zero entry of each non-zero row equals 1.\\\\\n (This entry is called its \\textbf{pivot} or \\textbf{leading 1}.)\n\t\\item Each pivot is further to the right than the pivot in the row above it.\n\\end{enumerate}\n\na) Determine if each of the following matrices is in REF or not. If not, perform row operations to turn it into REF.\\\\\n\n\\vspace{0.1in}\n\\begin{center}\n$\\textbf{M}=\\begin{bmatrix}\n0 & 0 & 2\\\\\n1 & 3 & 1\n\\end{bmatrix}\n$\n\\hspace{0.2in}\n$\\textbf{T}=\\begin{bmatrix}\n1 & 3 & 0 & -1 \\\\\n0 & 0 & 1 & -2\n\\end{bmatrix}$\\\\\n\\end{center}\n\n\\vspace{2.5in}\n\n\\textit{Reduced row echelon form} (RREF) is a even more strict form for matrices to take, which adds an additional property to the three above:\\\\\n\\vspace{0.1in}\n\\hrulefill \\\\\n\\indent 4. Each pivot is the only non-zero entry in its column.\\\\\n\\vspace{-3pt}\n\\hrulefill \\\\\n\\vspace{0.1in}\nMatrix \\textbf{T} from (a) is actually in RREF.\\\\\n\n\nb) What additional row operation(s) are required to turn matrix \\textbf{M} into RREF?\n\n\\newpage\n\n\\section{Bringing it Together}\n\nTake the following system of equations, write it first in matrix-vector from, then as an augmented matrix. Finally, use row operations to turn it into RREF:\n\n\\begin{center}\n$\\begin{array}{rrrrrrr}\nx_1 & + & x_2 & + & 2 x_3 & = & 1\\\\\n2 x_1 & - & x_2 & + & x_3 & = & 2\\\\\n4 x_1 & + & x_2 & + & 5 x_3 & = & 4\n\\end{array}$\n\\end{center}\n\n\\end{flushleft}\n\\end{document}", "meta": {"hexsha": "71773340fd3567b07252c0a3876131b9247d49fa", "size": 7459, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Fall 2014 - Capaldi A/Activities/Activity03_ElemRowOps.tex", "max_stars_repo_name": "Pelonza/PB-LinAlg", "max_stars_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Fall 2014 - Capaldi A/Activities/Activity03_ElemRowOps.tex", "max_issues_repo_name": "Pelonza/PB-LinAlg", "max_issues_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fall 2014 - Capaldi A/Activities/Activity03_ElemRowOps.tex", "max_forks_repo_name": "Pelonza/PB-LinAlg", "max_forks_repo_head_hexsha": "c92c2f3f9e3fc87a1a89041eb7bfaa1a87c9276d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0128755365, "max_line_length": 504, "alphanum_fraction": 0.688161952, "num_tokens": 2675, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984434543458, "lm_q2_score": 0.7981867705385762, "lm_q1q2_score": 0.4271084985010432}}
{"text": "\\chapter{\\projcur Programs}\n% \\section{Program}\n\\section{Ridgelet Transform}\n\\subsection{im\\_radon}\n\\index{im\\_radon}\nProgram {\\em im\\_radon} makes an (inverse-) Radon transform of a square\n$n \\times n$ image.\nThe output file which contains the transformation has a \nsuffix, .rad. If the output file name\ngiven by the user does not contain this suffix, it is automatically\nadded. The ``.rad'' file is a FITS format file, and can be manipulated by\nany package implementing the FITS format, or can be converted to another\nformat using the {\\em im\\_convert} program.\nFor the two first Radon transform methods, the user can change the\nnumber of directions and the resolution. For other methods, the \nnumber of directions and the resolution are fixed, and the\nx and y options are not valid. Options f, w and s allow the user to perform\na filtering-backprojection. They are valid only when the selected Radon\nmethod is the second one. ``w'' fixes the width of the filter and the\n``s'' is the sigma parameter of the Gaussian filter.\n{\\bf\n\\begin{center}\n USAGE:  im\\_radon  options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-m type\\_of\\_radon\\_method]}  \n{\\small \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item  Radon transform (resp.\\ backprojection) in spatial domain. \\\\\n       By default, the output image is a $2n \\times n$ image.\n\\item  Radon projection in spatial domain and reconstruction in Fourier domain.\n       By default, the output image is a $2n \\times n$ image.\n       The reconstruction is available only for image with\n       a size $n$ being a power of 2.\n\\item  Radon transformation and reconstruction in Fourier space \n       (i.e.\\ Linogram). \\\\\n       The output is a \n       $2n \\times n$ image. The number of rows is multiplied by two.\n\\item  Finite Radon Transform. \\\\\n       The output image is a $(n+1) \\times n$ image. The input image size $n$\n       must be a prime number.\n\\item  Slant Stack Radon transform. \\\\\n       The output image has twice the number of rows and twice the number\n       of columns of the input image.\n       The output is a $2n \\times 2n$ image.\n       The reconstruction is not available with this transform.\n\\end{enumerate}}\nDefault is Radon transformation and reconstruction in Fourier space.\n\n\\item {\\bf [-y OutputLineNumber]} \\\\\nFor the RADON transform, OutputLineNumber = number of projection,\n and default is twice the number of input image rows. Only valid for Radon\nmethods 1 and 2.\\\\\n% For the inverse RADON transform, OutputLineNumber = number of lines,\n% and default is the input image column number.\n\n\\item {\\bf [-x OutputColumnNumber]} \\\\\nFor the RADON transform, OutputLineNumber = number of pixels per projection,\nand default is the input image column number. Only valid for Radon\nmethods 1 and 2.\\\\\n% For the inv. RADON transform, OutputLineNumber = number of column,\n% and default is the input image column number.\n\n\\item {\\bf [-r]} \\\\\nInverse Radon transform.\n\\item {\\bf [-f]} \\\\\nFilter each scan of the Radon transform. Only valid for Radon\nmethod 2.\n\\item {\\bf [-w FilterWidth]} \\\\\nFilter width. Only valid for Radon\nmethod 2. Default is 100. \n\\item {\\bf [-s SigmaParameter} \\\\\n Sigma parameter for the filtering. Only valid for Radon\nmethod 2. Default is 10.\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no\n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item im\\_radon image.fits trans\\\\\nApply the Radon transform to an image.\n\\item im\\_info -r trans.rad rec\\\\\n Reconstruct an image from its Radon transform.\n\\end{itemize}\n\n\\subsection{rid\\_trans}\n\\index{rid\\_trans}\nProgram {\\em rid\\_trans} makes the  ridgelet transform \n(and the inverse when -r option is set).  \nThe output file which contains the transformation has a \nsuffix, .rid. If the output file name\ngiven by the user does not contain this suffix, it is automatically\nadded. The ``.rid'' file is a FITS format file, and can be manipulated by\nany package implementing the FITS format, or can be converted to another\nformat using the {\\em im\\_convert} program.\nThe default transform is the second one \n(RectoPolar Ridgelets using a  FFT based WT). \nThe two first transform are based on the RectoPolar\n(i.e. linogram) radon transform, but the first applies a standard \nbi-orthogonal wavelet transform (WT) on the Radon image rows, while the\nsecond uses the Fourier-based WT which introduces a redundancy of 2.\nFor an $n \\times n$ image, the output has $2n$ lines and $n$ column \nwith the first transform, and is a $2n \\times 2n$ image for the second.\nWhen the overlapping is set, the size is doubled in each direction.\n\n{\\bf\n\\begin{center}\n USAGE: rid\\_trans options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-t type\\_of\\_ridgelet]}  \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.\n\\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.\n\\item Finite ridgelet transform.\n\\end{enumerate}\nDefault is 2.\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the wavelet transform.\n Default is automatically calculated.\n\\item {\\bf [-b BlockSize]} \\\\\nBlock Size. Default is image size.\n\\item {\\bf [-i]} \\\\\nPrint statistical information about each band. Default is no. \n\\item {\\bf [-O]} \\\\\n No block overlapping. Default is no. When this option is set, the \n number of rows and columns is multiplied by two. \n\\item {\\bf [-r]} \\\\\nInverse Ridgelet transform.\n\\item {\\bf [-x]} \\\\\n Write all bands separately as images in the FITS format with prefix 'band\\_j' \n(j being the band number).\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no\n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item rid\\_transform image.fits trans\\\\\nApply the Ridgelet transform to an image.\n\\item rid\\_transform -r trans.rid rec\\\\\n Reconstruct an image from its Ridgelet transform.\n\\end{itemize}\n\n\\subsection{rid\\_stat}\n\\index{rid\\_stat}\nProgram {\\em rid\\_stat} makes the  ridgelet transform, and \ngives statistical information on the ridgelet coefficients.\nAt each scale, it caculates the standard deviation, the skewness,\nthe kurtosis, the minimum, and the maximum. The output file is a \nfits file containing a two-dimensional array $T[J-1,5]$ ($J$ being the\nnumber of scales), with the following syntax:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item $T[j,0] = $ standard deviation of the jth ridgelet band.\n\\item $T[j,1] = $ skewness of the jth ridgelet band.\n\\item $T[j,2] = $ kurtosis of the jth ridgelet band.\n\\item $T[j,3] = $ minimum of the jth ridgelet band.\n\\item $T[j,4] = $ maximum of the jth ridgelet band.\n\\end{itemize}\nThe last ridgelet scale is not used.\nIf the ``-A'' option is set, these statistics are calculated only for \nthe ridgelet coefficients relative the specified angle.\n{\\bf\n\\begin{center}\n USAGE: rid\\_stat options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-t type\\_of\\_ridgelet]}  \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.\n\\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.\n\\item Finite ridgelet transform.\n\\end{enumerate}\nDefault is 2.\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the wavelet transform.\n Default is automatically calculated.\n\\item {\\bf [-b BlockSize]} \\\\\nBlock Size. Default is 16.\n\\item {\\bf [-O]} \\\\\n   Use overlapping block. Default is no.\n\\item {\\bf [-A Angle]} \\\\\n Statistics for a given angle. The value must be given  in degrees.\n Default is no, statistics are calculated from all coefficients.\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no\n\\end{itemize}\n\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item rid\\_stat -v  image.fits tabstat\\\\\n\\end{itemize}\n\n\\subsection{rid\\_filter}\n\nProgram {\\em rid\\_filter} filters an image using the ridgelet transform.\n\\begin{center}\n USAGE:  rid\\_filter options image\\_in imag\\_out\n\\end{center}\nwhere options are \n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-t type\\_of\\_ridgelet]}  \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.\n\\item RectoPolar Ridgelet Transform using a FFT based pyramidal WT.\n\\item Finite ridgelet transform.\n\\end{enumerate}\nDefault is 2.\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the wavelet transform.\n Default is automatically calculated.\n\\item {\\bf [-h]} \\\\\nApply the ridgelet transform only on the high frequencies.\nDefault is no.\n\n\\item {\\bf [-b BlockSize]} \\\\\nBlock Size. Default is image size.\n\n\\item {\\bf [-F FirstDetectionScale]} \\\\\n First detection scale. Default is 1. \n\n% \\item {\\bf [-i NbrIter]}  \\\\\n%  Number of iteration for the constraint reconstruction.\n%   Default is no. \n% \\item {\\bf [-G RegulParam]}  \\\\\n%   Regularization parameter for the constraint reconstruction.\n%  Default is 0.2.\n% \\item {\\bf [-C ConvergParam]}  \\\\\n%  Convergence parameter. Default is 1.\n\n\\item {\\bf [-s Nsigma]} \\\\\nFalse detection rate. The false detection rate for a detection is given\n\\begin{eqnarray}\n\\epsilon =  \\mbox{erfc}( NSigma / \\sqrt{2})\n\\end{eqnarray}\n{\\em Nsigma} parameter allows us to express the false detection rate\neven if it is not Gaussian noise. \\\\\nDefault is 3.\n\n\\item {\\bf [-g sigma]} \\\\\nGaussian noise: sigma = noise standard deviation.  \\\\\n Default is automatically estimated.\n\n\\item {\\bf [-p]} \\\\\nPoisson noise.\n\n\\item {\\bf [-O]}  \\\\\nDo not apply block overlapping. By default, block overlapping is used.\n\n\\item {\\bf [-v]} \\\\\nVerbose.\n\\end{itemize}\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item rid\\_filter  image.fits fima\\\\\nFilter an image using all default options.\n\\item rid\\_filter -h -s5 image.fits fima\\\\\nFive sigma filtering, filtering only the high frequencies.\n\\end{itemize}\n\n\n\\section{Curvelet Transform}\n\\subsection{cur\\_trans}\n\\index{cur\\_trans}\nProgram {\\em cur\\_trans} determines the  curvelet transform \n(and the inverse when -r option is set).  \nThe output file which contains the transformation has a \nsuffix, .cur. If the output file name\ngiven by the user does not contain this suffix, it is automatically\nadded. The ``.cur'' file is a 3D FITS format file, and can be manipulated by\nany package implementing the FITS format.\nThe curvelet transform uses the ridgelet transform, and the default \nridgelet transform is the RectoPolar one with a FFT based pyramidal WT.\n\n{\\bf\n\\begin{center}\n USAGE: cur\\_trans options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-t type\\_of\\_ridgelet]}  \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.\n\\item RectoPolar Ridgelet Transform using a FFT based pyramidal WT.\n\\item Finite ridgelet transform.\n\\end{enumerate}\nDefault is 2.\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the 2D wavelet transform.\n Default is 4. \n\\item {\\bf [-N number\\_of\\_scale]} \\\\\n Number of scales used in the ridgelet transform.\n Default is automatically calculated.\n\\item {\\bf [-b BlockSize]}  \\\\\nBlock Size. Default is 16.\n\\item {\\bf [-r]}  \\\\\nInverse Curvelet transform.\n\\item {\\bf [-i]}  \\\\\nPrint statistical information about each band. Default is no. \n\\item {\\bf [-O]}  \\\\\n Block overlapping. Default is no. \n\\item {\\bf [-x]} \\\\\n Write all bands separately as images in the FITS format with prefix 'band\\_j' \n(j being the band number).\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no.\n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item cur\\_trans -i image.fits trans\\\\\nCurvelet transform of an image.\n\\item cur\\_trans -r  trans.cur rec\\\\\nImage reconstruction from its curvelet transform.\n\\end{itemize}\n\n\n\\subsection{cur\\_stat}\n\\index{cur\\_stat}\nProgram {\\em cur\\_stat} determines the  curvelet transform, and \ngives statistical information on the curvelet coefficients.\nAt each scale, it caculates the standard deviation, the skewness,\nthe kurtosis, the minimum, and the maximum. The output file is a \nFITS file containing a two-dimensional array $T[J-1,5]$ ($J$ being the\nnumber of bands), with the following syntax:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item $T[j,0] = $ standard deviation of the jth ridgelet band.\n\\item $T[j,1] = $ skewness of the jth ridgelet band.\n\\item $T[j,2] = $ kurtosis of the jth ridgelet band.\n\\item $T[j,3] = $ minimum of the jth ridgelet band.\n\\item $T[j,4] = $ maximum of the jth ridgelet band.\n\\end{itemize}\n{\\bf\n\\begin{center}\n USAGE: cur\\_stat options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the wavelet transform.\n Default is automatically calculated.\n\\item {\\bf [-b BlockSize]} \\\\\nBlock Size. Default is 16.\n\\item {\\bf [-O]} \\\\\n   Use overlapping block. Default is no.\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no\n\\end{itemize}\n\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item cur\\_stat -v  image.fits tabstat\\\\\n\\end{itemize}\n\n\n\\subsection{cur\\_filter}\n\\index{cur\\_filter}\n\nProgram {\\em cur\\_filter} filters an image using the curvelet transform.\n\\begin{center}\n USAGE:  cur\\_filter options image\\_in imag\\_out\n\\end{center}\nwhere options are \n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-t type\\_of\\_ridgelet]} \n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.\n\\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.\n\\item Finite ridgelet transform.\n\\end{enumerate}\nDefault is 2.\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the 2D wavelet transform.\n Default is 4. \n\n\\item {\\bf [-N number\\_of\\_scale]} \\\\\n Number of scales used in the ridgelet transform.\n Default is automatically calculated.\n\n\\item {\\bf [-b BlockSize]}  \\\\\nBlock Size. Default is 16.\n\n\\item {\\bf [-g sigma]} \\\\\nGaussian noise: sigma = noise standard deviation.  \\\\\n Default is automatically estimated.\n\n\\item {\\bf [-s Nsigma]} \\\\\nFalse detection rate. \\\\\nDefault is 3.\n\n\\item {\\bf [-O]}  \\\\\nDo not apply block overlapping. By default, block overlapping is used.\n\n\\item {\\bf [-P]}  \\\\\n Supress the positivity constraint. Default is no. \n\n\\item {\\bf [-I NoiseFileName]}  \\\\\nIf the noise is stationary, the program can estimate the correct \nthresholds from a realization of the noise.\n\n\\item {\\bf [-v]} \\\\\nVerbose\n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item cur\\_filter image.fits sol\\\\\nCurvelet filtering of an image.\n\\item cur\\_filter -n 5 -s4  image.fits sol\\\\\nCurvelet filtering of an image, using five resolution levels, and\na 4-sigma detection.\n\\end{itemize}\n\n\n\\subsection{cur\\_colfilter}\n\\index{cur\\_colfilter}\n\nProgram {\\em cur\\_colfilter} filters a\ncolor image using the curvelet transform.\n\\begin{center}\n USAGE:  cur\\_colfilter options image\\_in imag\\_out\n\\end{center}\nwhere options are \n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-n number\\_of\\_scale]} \\\\\n Number of scales used in the 2D wavelet transform.\n Default is 4. \n\n\\item {\\bf [-N number\\_of\\_scale]} \\\\\n Number of scales used in the ridgelet transform.\n Default is automatically calculated.\n\n\\item {\\bf [-b BlockSize]}  \\\\\nBlock Size. Default is 16.\n\n\\item {\\bf [-g sigma]} \\\\\nGaussian noise: sigma = noise standard deviation.  \\\\\n Default is automatically estimated.\n\n\\item {\\bf [-s Nsigma]} \\\\\nFalse detection rate. \\\\\nDefault is 3.\n\n\\item {\\bf [-O]}  \\\\\nDo not apply block overlapping. By default, block overlapping is used.\n\n\\item {\\bf [-v]} \\\\\nVerbose\n\\end{itemize}\n\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item cur\\_colfilter image.fits sol\\\\\nCurvelet transform of a color image.\n\\end{itemize}\n\n\n\\subsection{cur\\_contrast}\n\\index{cur\\_contrast}\n\nProgram {\\em cur\\_contrast} filters a color image using the curvelet transform.\n\\begin{center}\n USAGE:  cur\\_contrast options image\\_in imag\\_out\n\\end{center}\nwhere options are \n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-n number\\_of\\_scales]} \\\\\nNumber of scales used in the wavelet transform.\nDefault is 4. \n\\item {\\bf [-N number\\_of\\_scales]} \\\\\nNumber of scales used in the ridgelet transform.\nDefault is automatically calculated.\n\\item {\\bf [-b BlockSize]} \\\\\nBlock size used by the curvelet transform. Default is 16.\n\\item {\\bf [-O]} \\\\\nUse overlapping block. Default is no.\n\\item {\\bf [-g sigma]} \\\\\nNoise standard deviation. Only used when filtering is performed.\nDefault is automatically estimated.\n\\item {\\bf [-s NSigmalLow]} \\\\\n Coefficient $<$ NSigmalLow*SigmaNoise is not modified.\n Default is   5.\n\\item {\\bf [-S NSigmalUp]} \\\\\n Coefficient $>$ NSigmalUp*SigmaNoise is not modified.\n Default is  20.\n\\item {\\bf [-M MaxCoeff]} \\\\\nIf MaxBandCoef is the maximum coefficient in a given curvelet band,\n Coefficient $>$ MaxBandCoef*MaxCoeff is not modified.\n Default is 0.5.\n\\item {\\bf  [-P P\\_parameter]} \\\\\nDetermine the degree on non-linearity. P must be in ]0,1[.  \nDefault is 0.5.\n\\item {\\bf [-T P\\_parameter]} \\\\\n Curvelet coefficent saturation parameter. T must be in [0,1].  \nDefault is 0.\n\\item {\\bf [-c]} \\\\\nBy default a sigma clipping is performed. When this option is set, no\nsigma clipping is performed.\n\\item {\\bf [-K ClippingValue]} \\\\\nClipping value. Default is 3.\n\\item {\\bf [-L Saturation]} \\\\\nSaturate the reconstructed image.\nA coefficient larger than Saturation*MaxData is set to Saturation*MaxData.\nDefault is  1. If L is set to 0, then no saturation is applyied.\n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item cur\\_contrast image.fits image\\_out.fits\\\\\nEnhance the contrast using the curvelet transform.\n\\item cur\\_contrast -O image.fits image\\_out.fits\\\\\nEnhance the contrast using the curvelet transform and block overlapping.\n\\item cur\\_contrast -M 0.8 image.fits image\\_out.fits\\\\\nEnhance more the contrast.\n\\end{itemize}\n\n\\subsection{cur\\_colcontrast}\n\\index{col\\_colcontrast}\nThe program {\\em col\\_colcontrast} enhances the contrast of a color image\nusing the curvelet transform.\nThe command line is:\n{\\bf\n\\begin{center}\n USAGE: cur\\_colcontrast option in\\_image out\\_image\n\\end{center}}\nwhere options are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-n number\\_of\\_scales]} \\\\\nNumber of scales used in the wavelet transform.\nDefault is 4. \n\\item {\\bf [-N number\\_of\\_scales]} \\\\\nNumber of scales used in the ridgelet transform.\nDefault is automatically calculated.\n\\item {\\bf [-b BlockSize]} \\\\\nBlock size used by the curvelet transform. Default is 16.\n\\item {\\bf [-O]} \\\\\nUse overlapping block. Default is no.\n\\item {\\bf [-g sigma]} \\\\\nNoise standard deviation.  \nDefault is automatically estimated.\n\\item {\\bf [-s NSigmalLow]} \\\\\n Coefficient $<$ NSigmalLow*SigmaNoise is not modified.\n Default is   5.\n\\item {\\bf [-S NSigmalUp]} \\\\\n Coefficient $>$ NSigmalUp*SigmaNoise is not modified.\n Default is  20.\n\\item {\\bf [-M MaxCoeff]} \\\\\nIf MaxBandCoef is the maximum coefficient in a given curvelet band,\n Coefficient $>$ MaxBandCoef*MaxCoeff is not modified.\n Default is 0.5.\n \\item {\\bf  [-P P\\_parameter]} \\\\\nDetermine the degree of non-linearity. P must be in ]0,1[.  \nDefault is 0.5.\n\\item {\\bf [-T P\\_parameter]} \\\\\n Curvelet coefficent saturation parameter. T must be in [0,1].  \nDefault is 0.\n\\item {\\bf [-c]} \\\\\nBy default a sigma clipping is performed. When this option is set, no\nsigma clipping is performed.\n\\item {\\bf [-K ClippingValue]} \\\\\nClipping value. Default is 3.\n\\item {\\bf [-L Luminance\\_Saturation]} \\\\\nValues in the luminance map which are \nlarger than Saturation*MaxData are set to Saturation*MaxData.\nDefault is  1. \n\\end{itemize}\n\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item cur\\_colcontrast image.tiff image\\_out.tiff\\\\\nEnhance the contrast using the curvelet transform.\n\\item cur\\_colcontrast -n 5 image.tiff image\\_out.tiff\\\\\nDitto, but use five scales instead of four.\n\\item cur\\_colcontrast -M 0.9 image.tiff image\\_out.tiff\\\\\nEnhance more the contrast.\n\\end{itemize}\n\n\n\\section{Combined Filtering}\n\\subsection{cb\\_filter}\n\\index{cb\\_filter}\nProgram {\\em cb\\_filter} filters an image corrupted by Gaussian noise by\n the combined filtering method. By default, the undecimated  bi-orthogonal WT\n and the curvelet transform are used. The number of iterations is defaulted\n 10. In general, the algorithm converges with less than six iterations.\nIf the ``-T'' option is set, the Total Variation is minimized instead of \nthe $l_1$ norm of the multiscale coefficients.\nA deconvolution can also be performed using the ``-P'' option. In this\ncase, a division is first done in Fourier space between the \ninput image and the point spread function. All Fourier components with\na norm lower than $\\epsilon$ (default value is $10^{-3}$) are set to zero.\nThen the deconvolved image is filtered by the combined filtering method\nusing the new noise properties (still Gaussian, but not white).\n\n{\\bf\n\\begin{center}\n USAGE: cb\\_filter options image\\_in trans\\_out\n\\end{center}}\nwhere options are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n \\item {\\bf [-t TransformSelection]}\n\\begin{enumerate}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item A trous algorithm\n\\item Bi-orthogonal WT with 7/9 filters\n\\item Ridgelet transform\n\\item Curvelet transform\n\\item Mirror Basis WT\n% \\item Multiscale Ridgelet\n%\\item Cosinus transform\n%\\item Pyramidal Median transform\n\\end{enumerate}\n\n\\item {\\bf [-n number\\_of\\_scales]} \\\\\nNumber of scales used in the \\`a trous wavelet transform \n%, the PMT and\n and the curvelet transform. \n% Number of ridgelet in the multi-ridgelet transform.\nDefault is 4.\n\n\\item {\\bf [-b BlockSize]}  \\\\\n Block Size in the ridgelet transform.\nDefault is image size.  \n% Starting Block Size in the multi-ridgelet transform. Default is 8. \n\n\\item {\\bf [-i NbrIter]}  \\\\\nNumber of iterations. Default is 10.\n\n\\item {\\bf [-F FirstDetectionScale]} \\\\\nFirst detection scale in the ridgelet transform.\nDefault is 1. \n\n\\item {\\bf [-k]} \\\\\nKill the last scale in ridgelet. % , and multiscale ridgelet transform.\nDefault no.\n\n\\item {\\bf  [-K]} \\\\\nKill last scale in the \\`a trous algorithm and the curvelet. % and the PMT\nDefault no.\n\n\\item {\\bf  [-L FirstSoftThreshold]} \\\\\nFirst soft thresholding value. Default is 0.5.\n\n\\item {\\bf  [-l LastSoftThreshold]} \\\\\nLast soft thresholding value. Default is 0.5.\n\n\\item {\\bf  [-u]} \\\\\n Number of undecimated scales in the WT.\n Default is 1. \n\n\\item {\\bf [-s Nsigma]} \\\\\nFalse detection rate. Default is 4.\n\n\\item {\\bf [-g sigma]} \\\\\nGaussian noise: sigma = noise standard deviation.  \\\\\n Default is automatically estimated.\n\n% \\item {\\bf [-p]} \\\\\n% Poisson Noise. Default is no (Gaussian).\n\n\\item {\\bf [-O]}  \\\\\nNo block overlapping. Default is no.\n\n\\item {\\bf [-T]}  \\\\\n Minimize the Total Variation instead of the L1 norm. \n\n\\item {\\bf [-P PsfFile]}  \\\\\nApply a deconvolution using the PSF in the file PsfFile. \n\n\\item {\\bf [-e Eps]}  \\\\\n Remove frequencies with $|P P^*| < \\epsilon $. \n Default is $10^{-3}$.\n\n\\item {\\bf [-C TolCoef]}  \\\\\n Default is 0.5. \n\n\\item {\\bf [-v]} \\\\\nVerbose. Default is no.\n\\end{itemize}\n\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item cb\\_filter image.fits sol\\\\\nImage filtering by the combined filtering method, using both\nthe curvelet and wavelet transform.\n\\end{itemize}\n\n\n\n", "meta": {"hexsha": "3e9852c87a76bf56ddc26c341663396ee3de75b8", "size": 23554, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr4/ch_curprog.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr4/ch_curprog.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr4/ch_curprog.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.9592944369, "max_line_length": 79, "alphanum_fraction": 0.7321049503, "num_tokens": 6601, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.42697563900267615}}
{"text": "\\chapter{Introduction}\n\nIn machine learning problem\nsettings, we \nare often presented with data\nbut additionally have\ninformation about how the\ndata was collected or generated.\nFurthermore, we may have\nknowledge or access\nto domain expertise that \ncould inform a learning algorithm.\nTraditionally,\none way of incorporating\nprior knowledge or domain\nexpertise into machine\nlearning algorithms\nis by formulating them as probabilistic\ngraphical models, which\noffer flexible avenues for\nincorporating assumptions about data.\nTake, for example, if we are\ntasked with discovering\nclusters in a dataset, but have\nprior knowledge that\nthe features of the data are\ndisentangled or independent,\nwe can incorporate that\ninformation into the\nprior distribution\nover cluster components.\n\nThis strategy, however,\nhas major downsides,\nnamely that the types\nof assumptions that\ncan be incorporated\ninto probabilistic graphical\nmodels have been historically\nlimited to generative models in which\nBayesian inference is tractable.\nThus, in scenarios where\nthe data is high-dimensional\nand exhibits complex structure,\nwe are forced to make\nrestrictive assumptions\nthat enable tractable inference,\nbut limit the capacity\nof our model.\n\nOn the other hand,\nneural networks have emerged\nas a dominant force\nin machine learning,\nthanks to their\nability to scale to large datasets\nand their empirical success on complex\ndata like images and text.\nIncorporating prior knowledge\nor domain expertise into\ndeep learning approaches\nhas often taken the form of\ncustom neural network layers or\narchitectures that are tailored\nto the task at hand,\nand although these strategies\nhave seen empirical success,\nthey are often ad-hoc\nsolutions and do not\nleverage the explicit assumptions\nand modeling of uncertainty that\nprobabilistic graphical models offer.\nCombining deep learning\nmethods with probabilistic graphical\nmodels has thus been\nrecent topic of interest\nwith many open problems\nand challenges.\n\nMuch work has gone into investigating\nwhich models are tractable\nand how to approximate\nintractable ones.\nOne of the most prominent\nmethods to emerge in unsupervised learning\nis the variational autoencoder \\citep[VAE; ][]{Kingma2014, Rezende2014},\nwhich frames autoencoding\nas a probabilistic latent variable model.\nThe VAE models\nthrough a generative process\nwhere latent codes are sampled\nfrom a prior distribution,\nand are then passed through a\nneural network decoder. \nThe encoder is used for inference,\napproximating the posterior\ndistribution of codes given data.\n\nThe VAE is a stepping stone\nfor incorporating\nneural networks into\nstatistical learning,\nbut in its original form,\nhas very simple assumptions.\nThe statistical learning literature,\non the other hand, has\nexplored a wide variety of\nmodels and structures for data.\nIn this thesis, we \nmotivate and discuss\nthe use of Bayesian structured priors\nand the algorithmic challenges\nin incorporating them\nwith deep generative models.\nThe combination\nof a Bayesian structured\nprior with a VAE\nresults\nin a class of models called\nBayesian structured representation learning\nmodels.\n\nIn Part I, we introduce the\ncore ideas and foundations for Bayesian structure\nlearning and present a contribution\nin the space of interactive structure learning.\nIn Part II, we motivate and discuss\nalgorithms and models used in Bayesian structured\nrepresentation learning.\n", "meta": {"hexsha": "3156c13e63f9e61975cfe9d75935dab67e61aa4c", "size": 3384, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writeup/content/introduction.tex", "max_stars_repo_name": "sharadmv/thesis", "max_stars_repo_head_hexsha": "5fbf70c0645e44b2992f3cb4d7c2fbbbf7592d7f", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-30T01:28:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-30T01:28:54.000Z", "max_issues_repo_path": "writeup/content/introduction.tex", "max_issues_repo_name": "sharadmv/thesis", "max_issues_repo_head_hexsha": "5fbf70c0645e44b2992f3cb4d7c2fbbbf7592d7f", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "writeup/content/introduction.tex", "max_forks_repo_name": "sharadmv/thesis", "max_forks_repo_head_hexsha": "5fbf70c0645e44b2992f3cb4d7c2fbbbf7592d7f", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0307692308, "max_line_length": 72, "alphanum_fraction": 0.831855792, "num_tokens": 710, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.4269756293943675}}
{"text": "\\section{Kinematic ages}\n\\subsection{Calculating velocity dispersions}\n\\label{sec:velocity_dispersion}\n\nA kinematic age can be calculated from the velocity dispersion, \\ie\\ standard\ndeviation, of a group of stars.\nThese velocity dispersions can then be converted into an age using an AVR\n\\citep[\\eg][]{holmberg2009, yu2018}.\nKinematic ages represent the {\\it average age} of a group of stars and are\nmost informative when stars are grouped by age.\nIf a group of stars have similar ages, their kinematic age will be close\nthe age of each individual.\nOn the other hand, the kinematic age of a group with large age variance will\nnot provide much information about the ages of individual stars.\nVelocity distributions themselves do not reveal whether a group of stars have\nsimilar or different ages, since either case the velocities are\nGaussian-distributed.\nFortunately however, we can group \\kepler\\ stars by age using the implicit\nassumption that underpins gyrochronology: that stars with the same rotation\nperiod and color are the same age.\n% We discuss the implications of this assumption and cases where it doesn't\n% apply in the Discussion of this paper (section \\ref{sec:discussion}).\n\nIn this paper, we use the kinematic ages published in \\citet{lu2021}.\nIn that work, the kinematic age of each star in our sample was calculated by\nplacing it in a bin with other stars with similar rotation periods, effective\ntemperatures, absolute Gaia magnitudes and Rossby numbers.\nThe kinematic age of each star was estimated by calculating the velocity\ndispersions of stars with these similar parameters, then using an AVR to\ncalculate a corresponding age \\citep{yu2019}.\nThe bin size was optimized using a number of Kepler stars with asteroseismic\nages.\n\nWe used the \\citet{yu2018} AVR to convert velocity dispersion to age.\nThis relation was calibrated using the ages and velocities of red clump stars.\nThey divided their sample into metal rich and poor subsets, and calibrated\nseparate AVRs for each, plus a global AVR.\nTheir AVR is a power law:\n\\begin{equation}\n    \\sigma_{vz} = \\alpha t ^\\beta,\n\\end{equation}\nwhere $\\alpha$ and $\\beta$ take values (6.38, 0.578) for metal rich stars\n(3.89, 1.01) for metal poor stars, and (5.47, 0.765) for all stars.\n\nWe used 1.5$\\times$ the Median Absolute Deviation (MAD) of velocities, which\nis a robust approximation to the standard deviation and is less sensitive to\noutliers.\nVelocity outliers could be binary stars or could be generated by\nunderestimated parallax or proper motion uncertainties.\n\nFigure \\ref{fig:kin_and_clusters} displays the data we used to calibrate our\ngyrochronology model in \\prot-\\teff\\ space.\nKepler field stars are shown as small points, and cluster stars are larger\npoints with black outlines.\nPoints are colored by either their kinematic ages or cluster ages.\nThe left- and right-hand panels have a linear and logarithmic y-axis,\nrespectively.\n\n\\begin{figure}\n\\caption{\n    The calibration data.\nKepler field stars are shown as small points, and cluster stars are larger\npoints with black outlines.\nPoints are colored by either their kinematic ages or cluster ages.\nThe left- and right-hand panels have a linear and logarithmic y-axis,\nrespectively.\n}\n  \\centering \\includegraphics[width=1\\textwidth]{kin_and_clusters_log_lin}\n\\end{figure}\n", "meta": {"hexsha": "a389fa6a7995140c2cfb58f0b8a99b1e3734c295", "size": 3310, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/ages.tex", "max_stars_repo_name": "RuthAngus/aviary", "max_stars_repo_head_hexsha": "73c11348b32c29ffb0bd3d1d6179df95e89c3121", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/ages.tex", "max_issues_repo_name": "RuthAngus/aviary", "max_issues_repo_head_hexsha": "73c11348b32c29ffb0bd3d1d6179df95e89c3121", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/ages.tex", "max_forks_repo_name": "RuthAngus/aviary", "max_forks_repo_head_hexsha": "73c11348b32c29ffb0bd3d1d6179df95e89c3121", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.2857142857, "max_line_length": 78, "alphanum_fraction": 0.7957703927, "num_tokens": 782, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.42690164914887174}}
{"text": "\\chapter{Nomenclature}\n\\markboth{NOMENCLATURE}{}\n\n\\textbf{{\\large Upper-case Roman}}\n\n\\begin{longtable}[l]{ll}\n$\\mathcal{B}$ & Solid body governing equation\\tabularnewline\n$C_D$ & Drag coefficient\\tabularnewline\n$C_L$ & Lift coefficient\\tabularnewline\n$C_s$ & Smagorinsky model constant\\tabularnewline\n$\\mathcal{CC}$ & Correlation coefficient\\tabularnewline\n$D$ & Cylinder diameter\\tabularnewline\n$E$ & Kinetic energy \\tabularnewline\n$\\mathcal{F}$ & Fluid governing equation\\tabularnewline\n$F_x$ & Drag force\\tabularnewline\n$F_y$ & Lift force\\tabularnewline\n$H$ & Helicity \\tabularnewline\n$II, III$ & Non-zero invariants of the anisotropic Reynolds-stress tensor \\tabularnewline\n$K_\\epsilon$ & BDIM convolution kernel \\tabularnewline\n$L$ & Characteristic length\\tabularnewline\n$L_{11}$ & Integral lengthscale\\tabularnewline\n$L_a$ & Spanwise-averaging length\\tabularnewline\n$L_z$ & Cylinder span\\tabularnewline\n$M$ & Number of time steps\\tabularnewline\n$\\mathcal{M}$ & Meta-equation combining fluid and solid governing equations\\tabularnewline\n$N$ & Number of grid points\\tabularnewline\n$P$ & Spanwise-averaged pressure\\tabularnewline\n$R$ & Ratio of mean vortex-stretching term to mean vortex-advection term\\tabularnewline\n$Re$ & Reynolds number \\tabularnewline\n$\\mathcal{S}$ & 3-D Navier--Stokes spatial operator \\tabularnewline\n$\\tilde{\\mathcal{S}}$ & 2-D Navier--Stokes spatial operator \\tabularnewline\n$\\mathcal{S}^R$ & Perfect closure \\tabularnewline\n$S_{ij}$ & Rate-of-strain tensor \\tabularnewline\n$St$ & Strouhal number \\tabularnewline\n$\\vect{U}$ & Spanwise-averaged velocity vector field \\tabularnewline\n$U$ & Characteristic velocity\\tabularnewline\n$U$ & Spanwise-averaged velocity component along the $x$ spatial direction\\tabularnewline\n$U_\\infty$ & Free-stream velocity\\tabularnewline\n$V$ & Spanwise-averaged velocity component along the $y$ spatial direction\\tabularnewline\n$W$ & Spanwise-averaged velocity component along the $z$ spatial direction\\tabularnewline\n$\\mathrm{X}_n$ & Model input set\\tabularnewline\n$\\mathrm{Y}_n$ & Model output set\\tabularnewline\n$Z$ & Enstrophy \\tabularnewline\n\\end{longtable}\n\n\\textbf{{\\large Lower-case Roman}}\n\n\\begin{longtable}[l]{ll}\n$b_{ij}$ & Anisotropic Reynolds-stress tensor \\tabularnewline\n$d$ & Distance function\\tabularnewline\n$f_s$ & Vortex-shedding frequency \\tabularnewline\n$\\vect{h}$ & Force vector field combining convective and viscous forces\\tabularnewline\n$k$ & Turbulence kinetic energy \\tabularnewline\n$p$ & Pressure field \\tabularnewline\n$\\vect{r}$ & Distance vector\\tabularnewline\n$r$ & Radial direction in the cylindrical coordinates frame\\tabularnewline\n$t$ & Time\\tabularnewline\n$t^*$ & Convective time ($t$ scaled with $U$ and $L$)\\tabularnewline\n$\\vect{u}$ & Velocity vector field\\tabularnewline\n$u$ & Velocity component along the $x$ spatial direction\\tabularnewline\n$\\vect{u}_b$ & Velocity boundary condition on solid walls\\tabularnewline\n$\\vect{u}_s$ & Straining velocity vector field\\tabularnewline\n$\\vect{u}_v$ & Columnar vortex velocity vector field\\tabularnewline\n$v$ & Velocity component along the $y$ spatial direction\\tabularnewline\n$w$ & Velocity component along the $z$ spatial direction\\tabularnewline\n$\\vect{x}$ & Spatial coordinates vector \\tabularnewline\n$x$ & Spatial coordinate aligned with the principal (streamwise) flow direction\\tabularnewline\n$y$ & Spatial coordinate aligned with the transverse (crossflow) flow direction\\tabularnewline\n$z$ & Spatial coordinate aligned with the lateral (spanwise) flow direction\\tabularnewline\n\\end{longtable}\n\n\\textbf{{\\large Upper-case Greek}}\n\n\\begin{longtable}[l]{ll}\n$\\Gamma$ & Circulation\\tabularnewline\n$\\Delta$ & LES filter size\\tabularnewline\n$\\vect{\\Omega}$ & Spanwise-averaged vorticity vector field \\tabularnewline\n$\\Omega$ & A general spatial domain \\tabularnewline\n$\\Omega_f$ & Fluid subdomain \\tabularnewline\n$\\Omega_b$ & Solid body subdomain \\tabularnewline\n\\end{longtable}\n\n\\textbf{{\\large Lower-case Greek}}\n\n\\begin{longtable}[l]{ll}\n$\\gamma$ & Rate of strain\\tabularnewline\n$\\delta_{ij}$ & Kronecker delta tensor \\tabularnewline\n$\\delta t$ & Temporal resolution\\tabularnewline\n$\\delta x$ & Spatial resolution\\tabularnewline\n$\\delta_\\epsilon$ & Zeroth-moment of the BDIM convolution kernel \\tabularnewline\n$\\epsilon$ & Turbulence dissipation rate \\tabularnewline\n$\\epsilon_T$ & Trapezoidal quadrature error \\tabularnewline\n$\\vect{\\zeta}^R$ & Spanwise-stress residual vector in the spanwise-averaged VTE \\tabularnewline\n$\\eta$ & Invariant of the anisotropic Reynolds-stress tensor \\tabularnewline\n$\\eta$ & Kolmogorov lengthscale \\tabularnewline\n$\\theta$ & Angular direction in the cylindrical coordinates frame\\tabularnewline\n$\\theta_l$ & Lower separation angle on the cylinder surface\\tabularnewline\n$\\theta_u$ & Upper separation angle on the cylinder surface\\tabularnewline\n$\\vect{\\kappa}$ & Wavenumber vector\\tabularnewline\n$\\kappa$ & Wavenumber\\tabularnewline\n$\\lambda_z$ & Spanwise correlation length \\tabularnewline\n$\\mu$ & Dynamic viscosity\\tabularnewline\n$\\nu$ & Kinematic viscosity\\tabularnewline\n$\\nu_{e}$ & Effective kinematic eddy viscosity in iLES\\tabularnewline\n$\\nu_{t}$ & Kinematic eddy viscosity\\tabularnewline\n$\\xi$ & Invariant of the anisotropic Reynolds-stress tensor \\tabularnewline\n$\\rho$ & Density\\tabularnewline\n$\\sigma$ & Standard deviation\\tabularnewline\n$\\tau$ & Turbulence timescale\\tabularnewline\n$\\vect{\\tau}_{ij}^R$ & Spanwise-stress residual tensor\\tabularnewline\n$\\vect{\\tau}_{ij}^r$ & Anisotropic spanwise-stress residual tensor\\tabularnewline\n$\\chi_{12}$ & Two-point correlation function\\tabularnewline\n$\\vect{\\omega}$ & Vorticity vector field\\tabularnewline\n$\\vect{\\omega}_v$ & Columnar vortex vorticity vector field\\tabularnewline\n\\end{longtable}\n\n\\textbf{{\\large Acronyms}}\n\n\\begin{longtable}[l]{ll}\n2-D & Two-Dimensional\\tabularnewline\n3-D & Three-Dimensional\\tabularnewline\nANN & Artificial Neural Network \\tabularnewline\nBDIM & Boundary Data Immersion Method \\tabularnewline\nCNN & Convolutional Neural Network \\tabularnewline\nDNS & Direct Numerical Simulation \\tabularnewline\nEVM & Eddy-Viscosity Model \\tabularnewline\nFLOP & FLoating-point OPerations\\tabularnewline\nFSI & Fluid-Structure Interaction\\tabularnewline\nHPC & High-Performance Computing \\tabularnewline\nIB & Immersed Boundary\\tabularnewline\niLES & implicit Large-Eddy Simulation\\tabularnewline\nKLB & Kraichnan--Leith--Batchelor\\tabularnewline\nLES & Large-Eddy Simulation\\tabularnewline\nML & Machine-Learning\\tabularnewline\nMIMO & Multiple-Input Multiple-Output \\tabularnewline\nPBML & Physics-Based Machine Learning\\tabularnewline\nPS & Power Spectrum\\tabularnewline\nQUICK & Quadratic Upstream Interpolation for Convective Kinematics\\tabularnewline\nRANS & Reynolds-Averaged Navier--Stokes\\tabularnewline\nReLU & Rectified Linear Unit \\tabularnewline\nRNN & Recurrent Neural Network \\tabularnewline\nSANS & Spanwise-Averaged Navier--Stokes\\tabularnewline\nSGS & SubGrid Scale\\tabularnewline\nSSR & Spanwise-Stress Residual\\tabularnewline\nTKE & Turbulence Kinetic Energy\\tabularnewline\nVIV & Vortex-Induced Vibrations\\tabularnewline\nVTE & Vorticity Transport Equation\\tabularnewline\n\\end{longtable}", "meta": {"hexsha": "bc24564b3373297460bc5b1fce0df46d32ae756e", "size": 7141, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/nomenclature.tex", "max_stars_repo_name": "b-fg/PhD-thesis.tex", "max_stars_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/nomenclature.tex", "max_issues_repo_name": "b-fg/PhD-thesis.tex", "max_issues_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/nomenclature.tex", "max_forks_repo_name": "b-fg/PhD-thesis.tex", "max_forks_repo_head_hexsha": "3398a3b39cb760e072447fb46d7dbbd3b5920b2f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.25, "max_line_length": 95, "alphanum_fraction": 0.7926060776, "num_tokens": 2000, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.42690164914887174}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{III}\n\n\\def\\ntitle{3 Manifolds}\n\\def\\nlecturer{S.\\ Rasmussen}\n\n\\def\\nterm{Lent}\n\\def\\nyear{2019}\n\n\\input{header}\n\n\\renewcommand{\\boundary}{\\partial}\n\\renewcommand{\\b}{\\boundary}\n\\newcommand{\\interior}{\\ocirc}\n\\renewcommand{\\P}{{\\mathbb P}}\n\\newcommand{\\immerse}{\\looparrowright}\n\\DeclareMathOperator{\\grad}{grad}\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Why 3?}\n\n\\subsection{Motivation}\n\n\\paragraph{Poincare conjecture (1904)}\n\nQuestion: how can we distinguish \\(S^3\\) fom other 3-manifolds? The strategy is to find an invariant that distinguishes \\(S^3\\). The frst guess is homology but\n\n\\begin{theorem}[Poincare]\n  There exists a closed oriented 3-manifold \\(P\\) with \\(H_*(P) \\simeq H_*(S^3)\\) but with \\(P \\ncong S^3\\).\n\\end{theorem}\n\n\\begin{notation}\n  We use \\(\\cong\\) to denote homeomorphism and \\(\\simeq\\) to denote isomorphism.\n\\end{notation}\n\nThis is proven in the following way: first invent the fundamental group \\(\\pi_1\\), then construct \\(P\\), which is now known as (-1)-Dehn surgery on left-handed trefoil knot \\(K_T \\subseteq S^3\\). Finally show that \\(|\\pi_1(P)| = 120, |\\pi_1(S^3)| = 1\\) and \\(H_*(P) \\simeq H_*(S^3)\\).\n\n\\subsection{Homotopy}\n\n\\paragraph{Review of homotopy theory}\n\nhomotopy, fundamental groups and higher homotopy groups, homotopy equivalence, weak homotopy equivalence\n\n\\paragraph{Homotopy vs.\\ homology}\n\nLet \\(X\\) and \\(Y\\) be path-connected topological spaces.\n\n\\begin{theorem}[Hurewicz]\\leavevmode\n  \\begin{enumerate}\n  \\item \\(H_1(X, \\Z) \\simeq \\pi_1(X)/[\\pi_1(X), \\pi_1(X)]\\).\n  \\item If \\(\\pi_i(X) = 1\\) for \\(i = \\{1, \\dots, n\\}\\) then\n    \\begin{align*}\n      H_i(X) &= 0 \\text{ for } i \\leq n, i \\neq 0 \\\\\n      H_{n + 1} &\\simeq \\pi_{n + 1}(X)\n    \\end{align*}\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{theorem}[Whitehead]\n  If \\(X, Y\\) are CW complexes. Then a weak homotopy equivalence of \\(X\\) and \\(Y\\) is also a homotopy equivalence.\n\\end{theorem}\n\n\\begin{theorem}[Whitehead-homology variant]\n  Suppose \\(X, Y\\) are simply-connected CW complexes. If the induced homomorphisms \\(f_*: H_k(X; \\Z) \\to H_k(Y; \\Z)\\) are isomorphisms for all \\(k \\leq \\dim X\\) then \\(f: X \\to Y \\) is a homotopy equivalence.\n\\end{theorem}\n\n\\begin{theorem}\n  Any homotopy equivalence \\(f: X \\to Y\\) induces isomorphisms on homology, cohomology, cohomology ring structure (for any coefficients).\n\\end{theorem}\n\n\\subsection{*Simplifications in higher dimension}\n\nLet \\(\\mathcal C\\) be the smooth category when \\(n \\geq 5\\) and topological category \\(n \\geq 4\\).\n\n\\begin{theorem}[Whitney trick]\n  Suppose \\(\\dim X = n\\) where \\(n \\geq 4\\) and \\(P, Q \\subseteq X\\) are \\(\\mathcal \\C\\)-embedded submanifolds and \\(\\dim P + \\dim Q = \\dim X\\). Then \\(P, Q\\) can be locally \\(\\mathcal C\\)-isotoped so that the geometric intersection number equal to the absolute value of algebraic intersection of \\(P, Q\\). Note that algebraic intersection number is signed while teh geometric counterpart is not.\n\\end{theorem}\n\n\\begin{convention}\n  When we say topological embeddings we always mean locally flat embeddings, which will be defined later in the course.\n\\end{convention}\n\n\\begin{definition}[\\(h\\)-cobordism]\n  Let \\(W\\) with \\(\\boundary W = X_1 \\amalg X_2\\) be a cobordism from \\(X_1\\) to \\(X_2\\). \\(W\\) is an \\emph{\\(h\\)-cobordism} if the embeddings \\(X_i \\embed W\\) are homotopy equivalences.\n\\end{definition}\n\n\\begin{convention}\n  All manifolds are compact connected and oriented unless otherwise stated.\n\\end{convention}\n\n\\begin{theorem}[\\(h\\)-cobordism]\n  Suppose \\(\\dim X_i = n, \\dim W = n + 1\\), \\(W\\) is a \\(h\\)-cobordism from \\(X_1\\) to \\(X_2\\). If \\(\\pi_1(X_i) = \\pi_1(W) = 1\\) and \\(n \\geq 4\\) then \\(W\\) is \\(\\mathcal C\\)-isomorphic to \\(X_1 \\times [0, 1]\\).\n\\end{theorem}\n\n\\subsection{Generalised Poincare conjecture}\n\nPoincare conjecture: if \\(S\\) is compact oriented \\(3\\)-manifold homotopy equivalent to \\(S^n\\), then does \\(S \\cong S^n\\)?\n\nGeneralised Poincare conjecture: if \\(S\\) is compact oriented \\(n\\)-manifold homotopy equivalent to \\(S^n\\), then does \\(S \\cong S^n\\)?\n\nIt turns out for \\(n \\geq 4\\), the generalised Poincare conjecture is a corollary of \\(h\\)-cobordism theorem. Sketch of proof for \\(n \\geq 5\\): suppose \\(S\\) is homotopy equivalent to \\(S^n\\), Then \\(\\pi_*(S) \\simeq \\pi_*(S^n), H_*(S) \\simeq H_*(S^n)\\). Delete two balls from \\(S\\) to obtain \\(W \\cong S \\setminus \\interior B_1^n \\amalg \\interior B_2^n\\). Claim that \\(W\\) is a \\(h\\)-cobordism: apply Mayer-Vietoris with \\(A = W, B = B_1^n \\amalg B_2^n\\). Then \\(A \\cap B = S^{n - 1} \\amalg S^{n - 1} =_{\\text{htp}} W \\amalg \\{0, 1\\}, A \\cup B = S, A \\amalg B = W \\).\n\n\\[\n  \\begin{tikzcd}\n    H_n(S^{n - 1} \\amalg S^{n - 1}) \\ar[r] & H_n(W \\amalg \\{0, 1\\}) \\ar[r] & H_n(S) \\ar[dll, out=0, in=180] \\\\\n    H_{n - 1}(S^{n - 1} \\amalg S^{n - 1}) \\ar[r] & H_{n - 1}(W \\amalg \\{0, 1\\}) \\ar[r] & H_{n - 1}(S)\n  \\end{tikzcd}\n\\]\n\nThe first term vanishes because of dimension, the second term vanishes because \\(W\\) is not closed. By homotopy equivalence we get\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & \\Z \\ar[r] & \\Z \\oplus \\Z \\ar[r] & H_{n - 1}(W \\amalg \\{0, 1\\}) \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nWe can compute that \\(H_{n - 1}(W \\amalg \\{0, 1\\}) \\simeq \\Z\\). It is an exercise to show that there is an induced isomorphism on homology \\(H_k(S^n_i) \\to H_k(W)\\) for each \\(k\\). Moreover \\(\\pi_1(W) = 1\\) so \\(S^n_i \\to W\\) are homotopy equivalent.\n\nTherefore \\(W \\cong S^{n - 1} \\times [0, 1]\\) So \\(S \\cong B_1^n \\cup W \\cup B_2^n\\). By Alexander trick map on a \\(S^{n - 1}\\) can be extended \\emph{topologically} to a map on \\(B^n\\) with \\(\\boundary B^n = S^n\\). Extends this homeomorphism over the two balls.\n\nNote that this only applies to topological category and smooth generalised Poincare conjecture is still open in \\(n \\geq 4\\).\n\n\\subsection{Why not higher than 5?}\n\nMoral: homotopy-theoretic techniques can be used to answer most/many questions about topology or smooth structures in dimension \\(\\geq 5\\).\n\n\\section{Lecture 2: Why 3-manifolds? + Embeddings/Knots}\n\n\\subsection*{Active research areas}\n\n\\begin{enumerate}\n\\item An interaction with 4-dimensional manifolds (smooth/symplectic/complex structures)\n\\begin{enumerate}\n\\item Dimension reduction reduces 4-dimensional invariant to 3-dimensional ones (that are fancier ``categorified'') and maps induced by cobordisms.\n\\item symplectic form \\(\\omega\\) on \\(X^4\\) \\(\\implies\\) \\emph{contact structure} \\(\\xi\\) on \\(Y = \\b X\\).\n\\item Stein structure (complex/symplectic structure) on \\(X\\) \\(\\implies\\) Stein-fillable contact structure.\n\\item Normal complex structure sin \\((X, 0)\\) is a real cone over \\(Y = \\)Linkm(X, 0.\n\\end{enumerate}\n\n\\item Geometric group theory: fundamental groups, especially of 3-manifolds:\n\nprime, atoroidal non lens space 3 manifolds \\(\\iff\\) fundmental groups of such 3-manifolds.\n\n\\item 2-dimensional structure\n  \\begin{enumerate}\n  \\item contact stucture: \\(\\xi\\) everywhere nonintegrable \\(2\\)-lane field. ``tight'' contact structure classification\n  \\item minimal genus representatives of embedded surfaces, or knot genus. This is better understood. Thurston norm. The 4-dimensional analogue is still open.\n  \\item Foliations. Taut folations classification. Seifert fibered\n  \\end{enumerate}\n\n\\item 1-dimensional structure: knots and links\n  \\begin{enumerate}\n  \\item embedddings \\(\\amalg_i S^1_i \\embed S^3\\). Every 3-manifold can be realised as \\emph{Dehn surgery} on  a link \\(L \\embed S^3\\). Thus the theory of knot theory is richer that of 3-manifold. We study 3-manifolds via knot invariants (WIlten-Reshetikhin-Turaev invariant).\n  \\item Relations to other areas\n    \\begin{enumerate}\n    \\item Chern-Simons knot invarints: \\(K \\subseteq S^3\\) \\(\\iff\\) Gromov-Witten invariants on \\(O(-1) \\underbrace{\\oplus}_{\\C\\P^1} O(-1)\\).\n    \\item Homfly homology of \\(n\\)str braids \\(\\iff\\) DC sheaves on \\(\\operatorname{HIlb}^n(\\C)\\).\n    \\item Khovanov homology of links in \\(S^3\\) \\(\\iff\\) DC sheaves on other spaces.\n    \\end{enumerate}\n  \\end{enumerate}\n\\end{enumerate}\n\n\\subsection{Course themes}\n\n\\begin{enumerate}\n\\item Decompositions/Constructions of 3-manifolds.\n  \\begin{enumerate}\n  \\item surface decompositions/constructures\n    \\begin{enumerate}\n    \\item prime decomposition --- cut along essential \\(S^2\\)\n    \\item JSJ decomposition --- cut along essential \\(T\\).\n    \\item Mapping tori \\(\\iff\\) surface fibrations.\n    \\end{enumerate}\n  \\item quotient spaces\n    \\begin{enumerate}\n    \\item Hyperbolic quotients\n    \\item quotients of \\(S^7\\). Seifert fibration\n    \\item Morse theoretic\n      \\begin{enumerate}\n      \\item handle decomposition\n      \\item Heegaard splittings/diagrams\n      \\end{enumerate}\n    \\item Dehn surgery on links\n    \\end{enumerate}\n  \\end{enumerate}\n\\item Structure + Invariants for 3-manifolds\n  \\begin{enumerate}\n  \\item Knots \\& links\n    \\begin{enumerate}\n    \\item complement \\(S^3 \\setminus K\\)\n    \\item \\(\\pi_1(S^3 \\setminus K)\\)\n    \\item Alexander polynomials + Turaev torsion\n    \\end{enumerate}\n  \\item Essential/incompressible embedded surfaces, Thurston norm\n  \\item Foliations\n  \\end{enumerate}\n\\end{enumerate}\n\n\\section{Embeddings}\n\n\\begin{definition}[link]\\index{link}\n  A \\emph{link} is an embedding \\(L = \\amalg_i S^1_i \\embed S^3\\) considered up to isotopy. This embedding is either smooth or topoogical and locally flat. These two notions are equivalent.\n\\end{definition}\n\nLet \\(X\\) and \\(Y\\) be topological manifolds.\n\n\\begin{definition}[topological embedding]\\index{topological embedding}\n  A \\emph{topological embedding} \\(X \\embed Y\\) is a map \\(X \\embed Y\\) which is a homeomorphism onto its image.\n\\end{definition}\n\n\\begin{definition}[immersion]\\index{immersion}\n  If \\(X\\) and \\(Y\\) are also smooth then a map \\(f: X \\to Y\\) is an \\emph{immersion} if \\(d_xf: T_xX \\to T_{f(x)}Y\\) is injective for all \\(x \\in X\\).\n\\end{definition}\n\nAs a consequence of inverse function theorem, any immersion is locally an embedding.\n\n\\begin{definition}[smooth embedding]\\index{smooth embedding}\n  A \\emph{smooth embedding} is a topological embedding that is also an immersion.\n\\end{definition}\n\n\\begin{corollary}\n  If \\(X, Y\\) are smooth compact then any bijective immersion is an embedding.\n\\end{corollary}\n\n\\begin{theorem}[Moise]\\index{Moise theorem}\n  There is a canonical correpondence between topological structures and smooth structures on 3-manifolds.\n\\end{theorem}\n\nThus 3-manifolds up to homeomorphism bijects to 3-manifolds up to diffeomorphism.\n\n\\begin{definition}[local flatness]\\index{local flatness}\n  A topologically embedded submanifold \\(X \\subseteq Y\\) is \\emph{locally flat} at \\(x \\in X\\) if \\(x\\) has a neighbourhood \\(x \\in U \\subseteq Y\\) with homeomorphisms \\((U \\cap X, U) \\cong (\\R^{\\dim X}, \\R^{\\dim Y})\\).\n\n  A \\emph{locally flat embedding} is locally flat everywhere.\n\\end{definition}\n\n\\begin{convention}\n  From now on any embedding is smooth or locally flat.\n\\end{convention}\n\n\\begin{definition}[regular neighbourhood]\\index{regular manifolds}\n  A \\emph{regular neighbourhood} of an embedded submanifold \\(X \\subseteq Y\\) is a tubular/collar neighbourhood if the embedding is smooth/topologically flat.\n\\end{definition}\n\nIn 3-dimensions normal bundles are trivial so a regular neighbourhood \\(\\nu(X)\\) is just \\(D^2 \\times X \\embed Y\\) if \\(\\dim X = 1\\) and \\(D^1 \\times X \\embed Y\\) if \\(\\dim Y = 2\\).\n\nIn particular, neighbourhood of a not \\(K \\embed S^3\\) is just a solid torus \\(D^2 \\times S^1 \\embed S^3\\).\n\n\\section{Lecture 3: Link diagrams \\& Alexander Skein relations}\n\n\\begin{eg}\n  Wild knot: not locally flat embedding\n\\end{eg}\n\n\\begin{definition}[isotopy]\\index{isotopy}\n  An \\emph{isotopy} in category \\(\\mathcal C\\) from \\(f_1\\) to \\(f_2: X \\to Y\\) is a homotopy through maps of type \\(\\mathcal C\\).\n\\end{definition}\n\nThe point is, all knots (including wild knot) are isotopic through non-locally flat embeddings to an unknot, and all knots are homotopic to an unknot so we want to exclude the ``bad'' homotopies where a knot can cross itself.\n\n\\subsection{Knot and link diagrams}\n\n\\begin{definition}[link]\\index{link}\n  A \\emph{link} is an (oriented) embedding \\(\\iota: \\coprod_i S_i^1 \\embed S^3\\) of (oriented circles), considered up to isotopy.\n\\end{definition}\n\n\\begin{definition}[link projection]\n  A \\emph{link projection} is an immersion \\(L \\immerse \\Gamma \\embed \\R^2\\), induced by\n  \\[\n    \\begin{tikzcd}\n      L \\ar[r, hook] \\ar[d, \"p|_L\"] & S^3 \\setminus \\{x_0\\} \\ar[r, \"\\cong\"] & \\R^3 \\ar[r, \"\\cong\"] & \\R^2 \\times \\R \\ar[d, \"p\"] \\\\\n      \\Gamma \\ar[rrr] & & & \\R^2\n    \\end{tikzcd}\n  \\]\n  such that \\(x_0 \\notin L\\) and \\(p|_L\\) is an embedding except at double point singularities.\n\\end{definition}\n\nThis aweful looking definition is just a formalisation of a familiar concept that facilitates the study of knots:\n\n\\begin{definition}[link diagram]\\index{link diagram}\n  A \\emph{link diagram} \\(D = (\\Gamma, \\text{crossing} (D))\\) of a link \\(L \\subseteq S^3\\) is an embedded graph \\(\\Gamma \\embed \\R^2\\) from a link projection of \\(D\\), together with decorations at double points to label crossings. We draw a gap in the lower strand.\n\\end{definition}\n\n\\begin{theorem}[Reidemeister moves]\\index{Reidemeister moves}\n  Let \\(D_1\\) and \\(D_2\\) be link diagrams for respective links \\(L_1, L_2 \\subseteq S^3\\). Then \\(L_1\\) and \\(L_2\\) are isotopic if and only if \\(D_1\\) and \\(D_2\\) are related by some combination of the fuollowing moves:\n\\end{theorem}\n\nIt is more important to know that such moves exist than what they actually are.\n\n\\subsection{Alexander Skein relation}\n\nTo compute the alexander polynomial, you first choose an orientation for the link \\(L \\subseteq S^3\\). However, the resulting polynomial is independent of choice of orientation for knots.\n\n\\begin{theorem}[Alexander]\\index{Alexander polynomial}\n  The \\emph{Alexander polynomial}\n  \\[\n    \\Delta: \\{\\text{link diagram}\\} \\to \\Z[t^{-1/2}, t^{1/2}]\n  \\]\n  is specified by 2 conditions:\n  \\begin{enumerate}\n  \\item normalisation: \\(\\Delta(u) = 1\\) where \\(u\\) is the unknot.\n  \\item Skein relation: \\(\\Delta(negative crossing) - \\Delta(positive crossing) = \\Delta(oriented resolution) (t^{-1/2} - t^{1/2})\\) for all \\(c \\in \\text{crossing}(D)\\).\n  \\end{enumerate}\n  \\(\\Delta(D_1) = \\Delta(D_2)\\) if \\(D_1\\) and \\(D_2\\) are diagrams for isotopic links.\n\\end{theorem}\n\n\\begin{theorem}[equivalence of Alexander polynomial]\n  Later we will define an Alexander polynomial for 3-manifolds with \\(b_1 > 0\\). With respect to this definition,\n  \\[\n    \\Delta_{\\text{link}}(L) = \\Delta_{\\text{3-manifold}}(S^3 \\setminus L)\n  \\]\n  for any link \\(L \\subseteq S^3\\).\n\\end{theorem}\n\n\\section{Handle decompositions from Morse Singularities}\n\nHandles: index \\(k\\)-handles are tubular neighbourhood of \\(k\\)-cell CW complex, also are neighbourhoods of Morse critical points.\n\n\\subsection{Morse functions}\n\nLet \\(X \\to \\R\\) be a smooth function on a smooth manifold \\(X\\).\n\n\\begin{definition}[Hessian, critial point]\\index{Hessian}\\index{critcal point}\n  \\(\\textrm{Hess}_p(x)\\) is the Hessian of \\(f\\) at \\(p\\), which is local coordintes is\n  \\[\n    \\left(\n      \\frac{\\partial^2 f}{\\partial x_i \\partial x_J}|_{x = p}\n    \\right)_{ij}.\n  \\]\n\n  \\(\\textrm{crit} f\\) is the set of critical points of \\(f\\), i.e.\\ \\(\\{p \\in X: \\frac{\\partial f}{\\partial x_i} = 0 \\text{ for all } i\\}\\), or more invariantly, \\(df = 0\\).\n\\end{definition}\n\n\\begin{definition}[Morse function]\\index{Morse function}\n  A smooth function \\(f: X \\to \\R\\) on an \\(n\\)-manifold \\(X\\) is \\emph{Morse} if\n  \\begin{enumerate}\n  \\item every critical point of \\(f\\) is isolated. (If \\(X\\) is compact then this implies that critical points are finite)\n  \\item \\(\\textrm{Hess}_p f\\) is nongenerate at each \\(p \\in \\textrm{crit} f\\), if and only if \\(\\det \\neq 0\\), if and only if has all nonzero eigenvalues.\n  \\end{enumerate}\n\\end{definition}\n\n\\subsection{Morse singularities}\n\nA list of descriptions of Morse functions:\n\n\\begin{enumerate}\n\\item If \\(f: X \\to \\R\\) is Morse, then a Taylor series expansion around a critical point \\(p \\in \\textrm{crit} f\\) looks like\n  \\[\n    f(x) = f(p) + \\frac{1}{2} \\sum x_i x_j \\frac{\\partial^2 f}{\\partial x_i x_j}\\Bigg|_p + \\text{ higher order terms}\n  \\]\n\\item \\(\\textrm{Hess}_p f\\) is nondegenerate means that we can rescale coordinates so that all eigenvalues are \\(\\pm 1\\).\n\\item Since partial derivatives commute, \\(\\textrm{Hess}_p f\\) is symmetric. Thus by linear algebra it is diagonalisable and we can write\n  \\[\n    f(x) = f(p) - \\sum_{i = 1}^k x_i^2 + \\sum_{i = k + 1}^n x_i^2 + \\text{ higher order terms}.\n  \\]\n\\end{enumerate}\n\n\\begin{lemma}[Morse lemma]\n  Let \\(X\\) be a smooth manifold and \\(f: X \\to \\R\\) Morse. One can choose coordinates \\(x\\) centred at \\(p \\in \\textrm{crit} f\\) such that\n  \\[\n    f(x) = f(p) - sum_{i = 1}^k x_i^2 + \\sum_{i = k + 1}^n x_i^2.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Use implicit function theorem.\n\\end{proof}\n\n\\begin{definition}[index]\n  The \\emph{index} \\(\\operatorname{ind}_p f\\) of a Morse function \\(f: X \\to \\R\\) at a critical point \\(p\\) is\n  \\[\n    \\operatorname{ind}_p f = \\# \\text{ negative eigenvalues of } \\textrm{Hess}_p,\n  \\]\n  which is the \\(k\\) above.\n\\end{definition}\n\nThus Morse lemma says that index is the (only?) invariant of Morse functions.\n\nMoral: there is a standard local model for each index \\(k\\) Morse critical point.\n\nSee printed notes\n\n\\begin{definition}[\\(k\\)-handle]\n  An index \\(k\\)-handle, or just \\(k\\)-handle, or \\(n\\)-dimensional \\(k\\)-handle is the closure of a tubular neighbourhood of an index \\(k\\) critical point.\n  \\(H_k^m \\cong \\nu(x) \\cong D^k \\times D^{n - k} \\supseteq \\interior B^k\\).\n\\end{definition}\n\nNote that the corners in \\(D^k\\) and \\(D^{n - k}\\) are different\n\n\\section{Lecture 5: Handles from cells, Heegard diagrams}\n\nCell ecomplex interpretation\n\n\\begin{definition}[handle, core, cocore]\\index{handle}\\index{core}\\index{cocore}\n  An \\emph{\\(n\\)-dimension \\(k\\)-handle} \\(H^n_k\\) or \\emph{index \\(k\\)-handle} is a product decomposition\n  \\[\n    H^n_k \\cong D^k \\times D^{n - k} \\cong B^n\n  \\]\n  of the closed \\(n\\)-ball into a \\(k\\)-dimensional \\(k\\)-cell \\emph{core} \\(D^k\\) and \\emph{cocore} \\(D^{n - k}\\).\n\\end{definition}\n\nIf you choose a metric, the core \\(D^k\\) is fat and the cocore \\(D^{n - k}\\) is thin.\n\n\\begin{definition}[attaching region, belt region]\\index{attaching region}\\index{belt region}\n  The boundary \\(\\b H^n_k\\) of an \\(n\\)-dimensional \\(k\\)-handle decomposes as\n  \\begin{align*}\n    \\b H^n_k\n    &\\cong \\b(\\text{core} \\times \\text{cocore}) \\\\\n    &\\cong \\b(\\text{core}) \\times \\text{cocore} \\cup \\text{core} \\times \\b(\\text{cocore}) \\\\\n    &\\cong \\underbrace{\\b D^k \\times D^{n - k}}_{\\text{attaching region}} \\cup \\underbrace{D^k \\times \\p D^{n - k}}_{\\text{belt region}}\n  \\end{align*}\n\\end{definition}\n\nIn a cell complex, we attach a \\(k\\)-cell \\(D^k\\) by gluing its boundary \\(\\b D^k \\cong S^{k - 1}\\) to the cell-complex we have built so far.\n\n\\[\n  \\text{attaching region} (H^n_k)\n  \\cong \\overline{\\nu(\\p D^k)}\n  \\cong \\overline{\\nu S^{k - 1}}\n  \\cong \\p D^k \\times D^{n - k}\n\\]\n\n\\begin{definition}[handle attachment]\\index{handle attachment}\n  The attachment of a \\(k\\)-handle \\(H^n_k\\) to an \\(n\\)-manifold \\(X\\) to product an \\(n\\)-manifold \\(X'\\) is induced by a \\emph{\\(k\\)-handle attachment} cobordism \\(Z\\) from \\(- \\b X\\) to \\(\\b X'\\).\n  \\[\n    Z = (\\b X \\times I) \\cup_{\\text{a.r.}} H^n_r.\n  \\]\n  We have\n  \\[\n    \\p X' \\cong (\\p X \\setminus \\text{a.r.} (H^n_k)) \\cup (\\text{b.r.} (H^n_k)).\n  \\]\n\\end{definition}\n\nAs \\(\\p X \\times I\\) deformation retracts to \\(\\p X\\), we have\n\\[\n  X' \\cong X \\cup Z \\cong X \\cup H^n_k.\n\\]\n\n\\begin{convention}\n  We usually say that we attach a handle along the \\emph{core} of the attaching region.\n\\end{convention}\n\n\\begin{definition}[attaching/belt sphere]\n  \\begin{align*}\n    \\text{attaching region} (H^n_k)\n    &\\cong \\text{core}(\\text{attaching region}(H^n_k)) \\\\\n    &\\cong \\text{core}(\\p D^k \\times D^{n - k}) \\\\\n    &\\cong \\p D^k\n  \\end{align*}\n  \\begin{align*}\n    \\text{belt region} (H^n_k)\n    &\\cong \\text{core}(\\text{belt region}(H^n_k)) \\\\\n    &\\cong \\p D^{n - k}\n  \\end{align*}\n\\end{definition}\n\nConvention reexpressed: to attach a \\(k\\)-handle, we specify where the \\emph{attaching sphere} will be glued.\n\nMorse interpretation, revisited\n\n\\begin{definition}[gradient]\n  Choose a Riemannian metric \\(g\\) on a smooth \\(n\\)-manifold \\(X\\). Let \\(f: X \\to \\R\\) be a smooth function. the gradient \\(\\grad f \\in \\Gamma(TX)\\) of \\(f\\) is the vector field satisfying\n  \\[\n    g(\\grad f, V) = df(V)\n  \\]\n  for \\(V \\in \\text{Vect} X = \\Gamma(TX)\\).\n  Locally,\n  \\[\n    g_x((\\grad f)_x, V_x) = df_x(V_x).\n  \\]\n  In local coordinates,\n  \\[\n    \\grad f = \\sum g^{ik} \\frac{\\partial f}{\\partial x^k}e_i\n  \\]\n  where \\(e_i = \\frac{\\partial  }{\\partial x^i}\\).\n\\end{definition}\n\nIdea: invariant object from partials of \\(f\\), \\(df = \\sum \\frac{\\partial f}{\\partial x^i} \\w dx^i\\). To get a vector field, need a bilinear form to dualise \\(df\\). \\(\\grad f\\) comes from bilinear form (metric), and Hamiltonian vector field \\(f\\) comes from symplectic form.\n\nMoral (Morse theorey intepretation)\n\nQ: In what sense \\(H^n_k \\cong \\overline{\\nu(x)}\\), \\(x \\in \\text{crit} f, \\text{ind}_x f = k\\)?\n\nA: Gradient flow at the boundary of \\(H^n_k\\): \\(\\grad f\\) flows into attaching region \\(H^n_k\\), into \\(x \\in \\text{crit} f\\) in \\(k\\) directions. \\(\\grad f\\) flows out of belt region \\(H^n_k\\), out of \\(x\\) in \\(n - k\\) directions.\n\nFor example, for\n\\[\n  f = - \\sum_{i = 1}^k x_i^2 + \\sum_{j = k + 1}^n x_j^2\n\\]\n\n\n\n\n\n\n\n\n\n\n\n\n\\printindex\n\\end{document}\n\n% https://www.dpmms.cam.ac.uk/~sr727/2019_3manifolds", "meta": {"hexsha": "f50c53e67cca704a129156a20382d0a1daed7801", "size": 21621, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "III/3-manifolds.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "III/3-manifolds.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "III/3-manifolds.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 42.228515625, "max_line_length": 567, "alphanum_fraction": 0.6743906387, "num_tokens": 7170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.4269016491488717}}
{"text": "\\chapter{VRPTW via AI}\\label{vrptw-ai}\nIn this chapter, we will describe our end-to-end deep learning method for solving \\gls{vrptw}.\n\nMachine learning and artificial intelligence have been replacing many hand-engineered algorithms and providing state-of-the-art results. In recent years, reinforcement learning \\ref{rl} and advances in attention models \\ref{attention} has shown great promise to disrupt the field of heuristics algorithms \\cite{rl-constraint-opt, attention-route, dpdp}. Heuristics algorithms \\cite{heuristics-algo} are incomplete methods that can compute solutions efficiently, but are not able to prove the optimality of a solution. Most of the business challenges do not require the most optimal exact solution \\cite{excat-algo} but focus on approximation of the optimal solution in a reasonable time.\n\n\\section{Related Work}\nRegarding the research of solving the \\gls{vrp}, researchers have been mainly concentrating on designing hand-crafted metaheurictis via optimization. However, the great adoption of deep learning is starting to catch up with the field of operations research.\n\nThe first relatively successful deep learning model for solving general \\gls{vrp} was proposed by Vinyals et al. \\cite{vinyals} in the year of 2015 by introducing Pointer Networks. The model uses attention to output\na permutation of the input and the model was trained in the supervised manner by example solutions. In the next year, Bello et al. \\cite{actor-critic-pointer} extended the model of Pointer Networks by adopting the Actor-Critic algorithm that introduced \\gls{rl} and the model was trained on the training samples and did not require labelled data anymore. The reward function was a simple Euclidean length of the routes. The network showed improved performance on larger instances of 50 nodes over the predecessor model using supervised learning. In 2018, Nazari et al. \\cite{nazari} simplified the model of RL-based Pointer Network by omitting the recurrent neural network encoder and replaced it with embedding to D-dimensional vector space. The recurrent neural network is not necessary because the inputs of delivery nodes are not dependent on order \\cite{nazari}. There was no deterioration in performance and the model also supported the constraint for solving split delivery \\ref{split-delivery}.\n\nIn 2018, Kool et al. \\cite{attention-route} proposed a new approach and replaced the Pointer Network with Transformers \\ref{transformer} using Graph Attention Network \\ref{graph-attention-network} instead of positional encoding, and the Actor-Critic algorithm was changed to REINFORCE algorithm. The model showed superior performance. In this thesis, we will extend this model to support the soft time window constraint.\n\nIn 2019, Hottung et al. \\cite{hottung} introduced a novel approach that was inspired by \\gls{lns} \\ref{lns} called Neural Large Neighborhood Search. This model learns the destroy and repair operators by using graph attention network and attention mechanism, and it is outperforming the standard metahesuristics on capacitated vehicle routing problem. However, it is still iterative algorithm based on the local search which results in much larger runtime then end-to-end deep learning methods for \\gls{vrp}.\n\nIn 2021, another paper by Kool et al.\\cite{dpdp} was released with a completely new approach. It combines  dynamic programming and deep learning to solve \\gls{vrp} and promises much better performance than previous solutions. The method uses deep learning to restrict the dynamic programming search space using a policy derived from graph neural network. In the future, we will explore this method in depth and extend the support of constraints for time windows and pick and deliver problem \\ref{pick-and-delivery}\n\n\\section{Solution}\nThe end-to-end deep learning method pro solving \\gls{vrptw} is extension of the work done by Kool et al. \\cite{attention-route}. \n\nLet us describe the high-level concept behind the method. Consider we have a model as blackbox which takes \\gls{vrptw} instance as an input and outputs probabilities for all the \\gls{vrptw} nodes. The probability represents which node should be visited next and by following to the most probable node we get a partial solution which will be considered by the blackbox. We iterate this process until all nodes have been visited and we acquire a feasible plan as shown on Figure \\ref{fig:attention-route-diagram}.\n\n    \\begin{figure}[ht]\n        \\centering\n        \\includegraphics[width=1.0\\textwidth]{resources/vrptw-ai/attention-route-diagram.pdf}\n        \\caption{High-level concept behind the used method.}\n        \\label{fig:attention-route-diagram}\n    \\end{figure}\n\n    \\subsection{Model Architecture}\\label{vrptw-model}\n    The model architecture \\cite{attention-route} leveraging recent advancements in attention mechanism is here extended by the time window constraint. The model is built upon transformers \\ref{transformer}, graph attention network \\ref{graph-attention-network}, and reinforcement learning \\ref{rl}. The network structure is encoder-decoder that fits well for solving sequential decision problems. The structural input instance is extracted by the encoder \\ref{vrptw-encoder} and then the solution is incrementally constructed by the decoder \\ref{vrptw-decoder}.\n    \n    The \\gls{vrptw} input instance is consisted from:\n    \\begin{itemize}\\label{input-data}\n        \\item $X = \\{x_1, \\cdots, x_n\\}$ where $x_i$ is two-dimensional coordinates in the euclidean space.\n        \\item $x_0$ is the location of depot.\n        \\item $D = \\{d_1, \\cdots, d_n\\})$ is the demand capacity for each of the locations.\n        \\item $T = \\{(e_1, l_1), \\cdots, (e_n, l_n)\\})$ is time windows for each of the location where $e_i$ is the beginning and $l_i$ is the end of the considered time window.\n    \\end{itemize}\n    \n    The output is the solution of VRPTW instance and is represented as a permutation $\\pi$ of locations $X \\cup x_0$.\n    \\begin{itemize}\n        \\item $\\pi = \\{\\pi_1, \\cdots, \\pi_T\\} \\in \\{x_0, \\cdots, x_n\\})$ \n    \\end{itemize}\n    \n    \\subsubsection{Encoder}\\label{vrptw-encoder}\n    The encoder uses graph attention network \\ref{graph-attention-network} to embed the node features to graph embedding. Then the decoder architecture is the same as the decoder of transformer \\ref{transformer}. Typicaly, the decoder of transformer uses positional encoding \\cite{positional-encoding} to embed the input, but in this case it has been replace with \\gls{gat} \\ref{graph-attention-network} since we deal with graph-based structure and the input order does not matter.\n    \n    The first step is to perform the initial embedding of input data \\ref{input-data} via learned linear projections as in \\gls{gat}. The $h_{i}^{l}$ represents the node embedding of layer $l \\in \\{0, \\cdots, N\\}$ (N=3).\n    \\begin{equation}\n        \\widetilde{x} = \\text{concat}(X, D, T)\n    \\end{equation}\n    \\begin{equation}\n        h_{i}^{0} = \\begin{cases} W \\widetilde{x}_i + b_i &\\mbox{if } i > 0 \\\\ W \\widetilde{x}_0 + b_0 & \\mbox{if } n = 0 \\end{cases}\n    \\end{equation}\n    \n    The node embeddings are updated via $N$ attention layers, each containing multi-head attention \\ref{multi-head-attention} (M=8) and a fully connected feed-forward network with normalization. The structure is identical to transformer's encoder \\ref{transformer} with additional support of graph structure \\ref{graph-attention-network} as shown on Figure \\ref{fig:encoder-diagram}.\n    \n    \\begin{figure}[ht]\n        \\centering\n        \\includegraphics[width=1.0\\textwidth]{resources/vrptw-ai/encoder-diagram.png}\n        \\caption{Encoder layers \\cite{attention-route}}\n        \\label{fig:encoder-diagram}\n    \\end{figure}\n    \n    The equation \\ref{encoder-qkv} calculates the query $Q$, key $K$ and value $V$ of multi-head attention layer using the node embeddings and weights $W_m^Q$, $W_m^Q$, and $W_m^Q$, respectively. The number of heads is represented by $m \\in \\{1, \\cdots, M\\}$ (M=8).\n    \n    \\begin{equation}\\label{encoder-qkv}\n        \\textbf{q}_{im}^l = W_m^Q h_i^(l-1), \\textbf{k}_{im}^l = W_m^K h_i^(l-1), \\textbf{v}_{im}^l = W_m^V h_i^(l-1)\n    \\end{equation}\n    \n    The query and key values are used in calculating the compatibility $u_{ijm}^l$ of node $i$ with a node $j$ \\ref{mha-compatibility}. If node $i$ is not adjecnt to node $j$ then they are not compatible and the value is set to a large negative number.\n    \n    \\begin{equation}\\label{mha-compatibility}\n        u_{ijm}^l = \\begin{cases} q_{im}^l k_{jm}^l &\\mbox{if $i$ adjacent to $j$} \\\\ -\\infty &\\mbox{otherwise} \\end{cases}\n    \\end{equation}\n    \n    The attention score $a_{ijm}^l \\in [0,1]$ is calculated using softmax from the compatibility values of nodes \\ref{encoder-attention-score}\n    \n    \\begin{equation}\\label{encoder-attention-score}\n        a_{ijm}^l = \\dfrac{e^{u_{ijm}^l}}{\\sum_{j'=0}^n e^{u_{ij'm}^l}}\n    \\end{equation}\n    \n    The transformed $h'_{im}^l$ \\ref{h-prime} aggregates all attention scores across neighbour nodes, which is based on GAT \\ref{graph-attention-network}. \n\n    \\begin{equation}\\label{h-prime}\n        h'_{im}^l = \\sum_{j=0}^n a_{ijm}^l v_{jm}^l\n    \\end{equation}\n    \n    Finally, we may calculate the multi-head attention \\ref{transformer} for layer $l$ as a function of $\\{h_1^{l-1}, \\cdots, h_n^{l-1}\\}$ through $h'_{im}^l$.\n    \n    \\begin{equation}\n        \\text{MHA}_i^l(h_1^{l-1}, \\cdots, h_n^{l-1}) = \\sum_{m=1}^M W_{m}^O h'_{im}^l\n    \\end{equation}\n    \n    \\begin{equation}\n        \\widetilde{h}_i = \\text{BN}^l(h_i^{l-1} + \\text{MHA}_i^l(h_1^{l-1}, \\cdots, h_n^{l-1})))\n    \\end{equation}    \n    \\begin{equation}\n        h_i^l = \\text{BN}^l(\\widetilde{h}_i + \\text{FF}^l(\\widetilde{h}_i))\n    \\end{equation}\n    \n    In the final layer, the encoder computes the aggregated embedding of the input graph as the mean of the final node embeddings.\n    \\begin{equation}\n        h^N = \\dfrac{1}{n} \\sum_{i=1}^m h_i^N\n    \\end{equation}\n    \n    The output of the encoder's final layer is passed to the decoder, which is detailed in the next sections \\ref{vrptw-decoder}.\n    \n    \\subsubsection{Decoder}\\label{vrptw-decoder}\n    Decoder works sequentially through timestamps $t \\in \\{0, \\cdots, n\\}$, at each timestamp one node is selected to be visited based on partial route $\\pi_{1:t-1}$. It is predicting the probability distribution over nodes according to the node embedding and context vector of the encoder \\ref{vrptw-encoder}.\n    \n    \\begin{figure}[ht]\n        \\centering\n        \\includegraphics[width=1.0\\textwidth]{resources/vrptw-ai/decoder-diagram.png}\n        \\caption{Describes the decoder iteration in the construction of a solution. This diagram very nicely visualizes the process and it was used in the paper by Kool et al. \\cite{attention-route}}\n        \\label{fig:encoder-diagram}\n    \\end{figure}\n    \n    The decoder uses a new context vector $h_{c}^{'}$ which represents the state \\ref{rl} and it goes as follows:\n    \\begin{equation}\\label{decode-state-vec}\n        h_{c}^{'} = \\begin{cases} \\text{concat}(h_N; h_0^N; D_t) & \\mbox{if } t = 0 \\\\ \\text{concat}(h_N; h_{\\pi_{1:t-1}}^N; D_t) & \\mbox{if } t > 0 \\end{cases}\n    \\end{equation}\n    The state of $h_{c}^{'}$ is concatenation of $h_N$, the output of the encoder, $h_{\\pi_{1:t-1}}^N$, the embedding of previous partial solution, and $D_t$, the remaining demand capacity of the vehicle.\n    \n    Due to the fact that the decoder architecture is transformer \\ref{transformer}, the next layers are multi-head attentions which are responsible for choosing the next node to visit. This defines the system action \\ref{rl}.\n    \n    The multi-head attention in the decoder is computed in a similar manner as in the decoder \\ref{vrptw-encoder} with a little alternation.\n    \\begin{equation}\n        q_{(c)m} = W_m^Q h_{c}^{'}, k_{jm} = W_m^K h_{j}^{N}, v_{jm} = W_m^V h_{j}^{N}\n    \\end{equation}\n    \n    \\begin{equation}\\label{compatibility-decoder}\n        u_{(c)j} = \\begin{cases} q_c^T k_j &\\mbox{if }  d_j <= D_t \\text{ and } x_j \\notin \\pi_{1:t-1} \\\\ -\\infty &\\mbox{otherwise} \\end{cases}\n    \\end{equation}\n    \n    The equation \\ref{compatibility-decoder} computes the compatibility score and performs a masking mechanism to mask the nodes which have already been visited during the partial route (besides depot $x_0$) and eliminates nodes where the vehicle capacity would overflow. If we would consider a time window as a hard constraint, the calculation of compatibility would have extended masking mechanism to show only nodes which correspond to the time $t$.\n    \n    \\begin{equation}\n        h'_{(c)m} = \\sum_{j=0}^n softmax(u_{(c)j}) v_jm\n    \\end{equation}\n        \n    \\begin{equation}\n        h_{c} = \\text{MHA}(h_{c}^{'}) = \\sum_{m=1}^M W_{m}^O h'_{(c)m}\n    \\end{equation}\n    \n    In order to calculate the desired probability $p_{\\theta}(\\pi_t|X, \\pi_{1:t-1})$, a logit layer. The final layer is a single-head attention.\n    \n    \\begin{equation}\n        q = W^Q h_c, k_j = W^K h_j^N\n    \\end{equation}\n    \n    \\begin{equation}\n        u_j = \\begin{cases} C . \\text{tanh}(q^T k_{c}) &\\mbox{if }  d_j <= D_t \\text{ and } x_j \\notin \\pi_{1:t-1} \\\\ -\\infty &\\mbox{otherwise} \\end{cases}\n    \\end{equation}\n    \n    \\begin{equation}\\label{encoder-attention-score}\n        p_i = p_{\\theta}(\\pi_t|X, \\pi_{1:t-1}) = \\dfrac{e^{u_j}}{\\sum_{j'=0}^n e^{u_{j'}}}\n    \\end{equation}\n    \n    \\subsection{Reinforcement Learning}\\label{vrptw-rl}\n    The model \\ref{vrptw-model} takes \\gls{vrptw} instance and outputs probability distribution over nodes $p_{\\theta}(\\pi|X)$ which is used to sample a full feasible route as a solution $\\pi$. The instance of \\gls{vrptw} $S$ is defined as concatenation of locations, demand capacity and time windows for each node, $S = [X, D, T]$.\n    \n    To train the model, we have to define a reward, respectively, a cost function. The model is trained using REINFORCE algorithm \\ref{reinforce} as proposed by Kool et al. \\cite{attention-route}. The algorithm is based on the computation of the policy gradient, which is defined as\n    \\begin{equation}\\label{encoder-attention-score}\n        \\nabla_{\\theta} \\mathcal{L}(\\theta|X) = \\mathop{\\mathbb{E}}[ \\mathcal{L}(\\pi|X) - b(X)) \\nabla \\ln \\pi (\\pi|X))]\n    \\end{equation}\n    \n        \\subsubsection{VRPTW Cost}\\label{vrptw-rl}\n        For effectively solving \\gls{vrptw}, the cost function is an integral part of a successfully trained model. In this thesis, we propose a new cost function to solve the vehicle routing problem with soft constrained time windows and demand capacity for each node.\n        \n        The cost function is ranking the given solution of \\gls{vrptw} instance. It penalizes the solution based on the length of the routes, early and late visits, and unequal distribution of nodes across vehicles.\n        \n        For a given \\gls{vrptw} instance $S$ and its solution $\\pi$, we propose the cost function as follows:\n        \\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n        \\begin{equation}\\label{vrptw-cost}\n            \\mathcal{L}(\\pi|S) = dis_p(\\pi, S) + t_p(\\pi, S) + bal_p(\\pi, S)\n        \\end{equation}\n        \\begin{equation}\\label{distance-cost}\n            dis_p(\\pi, S) = \\sum_{i=0}^N \\norm{x_{\\pi(i)} - x_{\\pi(i+1)}}_2\n        \\end{equation}\n        The equation \\ref{distance-cost} calculates the length of all routes in Euclidean space.\n        \n        \\begin{equation}\\label{time-cost}\n            t_p(\\pi, S) = \\sum_{i=0}^N (I_{e_i > \\widetilde{t}_i} (e_i - \\widetilde{t}_i) p_e + I_{l_i < \\widetilde{t}_i} (\\widetilde{t}_i - l_i) p_l)\n        \\end{equation}\n        The equation \\ref{time-cost} calculates the penalty for early or late arrival. The time of the visit for a given node $i$ is defined by vector $\\widetilde{t}_i$. We assume that the travel speed is always identical and we approximate that one unit of distance equals to one unit of time. The vector $I$ behaves as a mask $I \\in (0, 1)^n$ which represents if either early or late arrival occurred. The penalty for late arrival $p_l$ should be greater than for early arrival $p_e$ and finding the proper penalties will be empirically determined as a part of experiment chapter \\ref{penalty-experiment}.\n        \n        \\begin{equation}\\label{balance-cost}\n            bal_p(\\pi, S) = \\sigma([|R_0|, \\cdots, |R_k|])\n        \\end{equation}\n        The last subpart of the cost function is calculating balance cost \\ref{balance-cost} that aims to evenly distribute the number of nodes in a route $R_i$ by minimizing its standard deviation. In logistics, we expect to utilize couriers evenly.\n        \n        \\subsubsection{Training loop}\\label{vrptw-loop}\n        \n        Pseudocode of the \\gls{rl} system training loop is as follows\n        \n        \\SetKwInput{KwInput}{Input} \n        \\begin{algorithm}[H]\n            \\KwInput{Number of epoch $E$, steps per epoch $T$, batch size $B$} %significance $\\alpha$\n            \\KwResult{Updated $\\theta$ that maximises reward}\n            \n            Initialize $\\theta$ at random\\;\n            \\For{$epoche = 1, 2, \\cdots, E$}{\n                \\For{$steps = 1, 2, \\cdots, T$}{\n                    Compute context embedding $h^N$ via decoder (\\ref{vrptw-encoder});\n                    \n                    \\For{$t = 1, 2, \\cdots, N$}{\n                        Calculate $p_{\\theta}(\\pi_t|X, \\pi_{1:t-1})$ via encoder for $t$ (\\ref{vrptw-decoder});\n                        \n                        Pick an action based on probability distribution;\n                        \n                        Update the state by visiting a new node;\n                    }\n                    \n                    Compute reward $\\mathcal{L}(\\pi|S)$ (\\ref{vrptw-cost});\n                    \n                    %Compute reward baseline;\n                    \n                    % $\\nabla_{\\theta} \\mathcal{L} \\gets \\mathop{\\mathbb{E}}[ \\mathcal{L}(\\pi|X) - b(X)) \\nabla \\ln \\pi (\\pi|X))]$;\n                    \n                    $\\nabla_{\\theta} \\mathcal{L} \\gets \\mathop{\\mathbb{E}}[ \\mathcal{L}(\\pi|X) \\nabla \\ln \\pi (\\pi|X))]$;\n                    \n                    $\\theta \\gets \\text{Adam}(\\theta, \\nabla_{\\theta} \\mathcal{L})$;\n                }\n         }\n         \\caption{REINFORCE algorithm}\n        \\end{algorithm}\n        \n    \n    \\subsection{Integrating Duration Matrix}\n    Real-world application of \\gls{vrp} require to obtain the distance and duration matrix which represents the weighted transition between graph nodes. The duration between two locations is typically defined by the infrastructure and speed limits on a given route. Such a duration matrix is calculated using map data such as OpenStreetMap \\cite{osm}.\n    \n    The neural network solving \\gls{vrptw} learns to approximate the Euclidean distance between two given points. However, if we would integrate the duration matrix into the cost function of the model, the network would have to derive the duration between two points, which is an impossible task with the given model architecture. Moreover, the planning would be fixed to the location (city) on which the model was trained on.\n    \n    We propose an indirect integration of the duration matrix for the input instance. We may project the duration matrix into the node locations using multidimensional scaling \\cite{mds} which would embed the duration information in a given 2D space.\n", "meta": {"hexsha": "cb5e50726441e4e601d4323652d1b81e10940093", "size": 19405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src_text/04_vrptw_ai.tex", "max_stars_repo_name": "zvadaadam/Vehicle-Routing-Problem-with-Time-Windows-solved-via-Machine-Learning-and-Optimization-Heuristics", "max_stars_repo_head_hexsha": "a6a2f07e9523c17024ceb19f5f9f91f6e93b57e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-03T01:03:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-03T01:03:24.000Z", "max_issues_repo_path": "src_text/04_vrptw_ai.tex", "max_issues_repo_name": "zvadaadam/Vehicle-Routing-Problem-with-Time-Windows-solved-via-Machine-Learning-and-Optimization-Heuristics", "max_issues_repo_head_hexsha": "a6a2f07e9523c17024ceb19f5f9f91f6e93b57e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src_text/04_vrptw_ai.tex", "max_forks_repo_name": "zvadaadam/Vehicle-Routing-Problem-with-Time-Windows-solved-via-Machine-Learning-and-Optimization-Heuristics", "max_forks_repo_head_hexsha": "a6a2f07e9523c17024ceb19f5f9f91f6e93b57e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.8776371308, "max_line_length": 1002, "alphanum_fraction": 0.6928626643, "num_tokens": 5333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.42690164157965366}}
{"text": "\\par\n\\section{Driver programs found in the {\\tt Misc} directory}\n\\label{section:Misc:drivers}\n\\par\nThis section contains brief descriptions of the driver programs.\n\\par\n%=======================================================================\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ntestNDperm msglvl msgFile n1 n2 n3 outPermFile\n\\end{verbatim}\nThis driver program generates a {\\tt Perm} object that contains a\nnested dissection ordering for a {\\tt n1 x n2 x n3} regular grid.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\n{\\tt n1} is the number of points in the first direction.\n\\item\n{\\tt n2} is the number of points in the second direction.\n\\item\n{\\tt n3} is the number of points in the third direction.\n\\item\nThe {\\tt outPermFile} parameter is the output file for the {\\tt Perm}\nobject. \nIf {\\tt outPermFile} is {\\tt none} then the {\\tt Perm} object is not\nwritten to a file. \nOtherwise, the {\\tt Perm\\_writeToFile()} method is called to write\nthe object to \na formatted file (if {\\tt outPermFile} is of the form {\\tt *.permf}),\nor\na binary file (if {\\tt outPermFile} is of the form {\\tt *.permb}).\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ntestOrderViaMMD msglvl msgFile GraphFile seed ETreeFile\n\\end{verbatim}\nThis program reads in a {\\tt Graph} object from a file and computes\na multiple minimum degree ordering of the graph.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt inGraphFile} parameter is the input file for the {\\tt Graph}\nobject. It must be of the form {\\tt *.graphf} or {\\tt *.graphb}.\nThe {\\tt Graph} object is read from the file via the\n{\\tt Graph\\_readFromFile()} method.\n\\item\nThe {\\tt seed} parameter is a random number seed.\n\\item\nThe {\\tt ETreeFile} parameter is the output file for the {\\tt ETree}\nobject. \nIf {\\tt ETreeFile} is {\\tt none} then the {\\tt ETree} object is not\nwritten to a file. \nOtherwise, the {\\tt ETree\\_writeToFile()} method is called to write\nthe object to \na formatted file (if {\\tt ETreeFile} is of the form {\\tt *.etreef}),\nor\na binary file (if {\\tt ETreeFile} is of the form {\\tt *.etreeb}).\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ntestOrderViaND msglvl msgFile GraphFile maxdomainsize seed ETreeFile\n\\end{verbatim}\nThis program reads in a {\\tt Graph} object from a file and computes\na generalized nested dissection ordering of the graph.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt inGraphFile} parameter is the input file for the {\\tt Graph}\nobject. It must be of the form {\\tt *.graphf} or {\\tt *.graphb}.\nThe {\\tt Graph} object is read from the file via the\n{\\tt Graph\\_readFromFile()} method.\n\\item\nThe {\\tt maxdomainsize} parameter governs the partition of a graph.\nIf a subgraph has more than {\\tt maxdomainsize} vertices, it is\nsplit.\n\\item\nThe {\\tt seed} parameter is a random number seed.\n\\item\nThe {\\tt ETreeFile} parameter is the output file for the {\\tt ETree}\nobject. \nIf {\\tt ETreeFile} is {\\tt none} then the {\\tt ETree} object is not\nwritten to a file. \nOtherwise, the {\\tt ETree\\_writeToFile()} method is called to write\nthe object to \na formatted file (if {\\tt ETreeFile} is of the form {\\tt *.etreef}),\nor\na binary file (if {\\tt ETreeFile} is of the form {\\tt *.etreeb}).\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ntestOrderViaMS msglvl msgFile GraphFile maxdomainsize seed ETreeFile\n\\end{verbatim}\nThis program reads in a {\\tt Graph} object from a file and computes\na multisection ordering of the graph.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt inGraphFile} parameter is the input file for the {\\tt Graph}\nobject. It must be of the form {\\tt *.graphf} or {\\tt *.graphb}.\nThe {\\tt Graph} object is read from the file via the\n{\\tt Graph\\_readFromFile()} method.\n\\item\nThe {\\tt maxdomainsize} parameter governs the partition of a graph.\nIf a subgraph has more than {\\tt maxdomainsize} vertices, it is\nsplit.\n\\item\nThe {\\tt seed} parameter is a random number seed.\n\\item\nThe {\\tt ETreeFile} parameter is the output file for the {\\tt ETree}\nobject. \nIf {\\tt ETreeFile} is {\\tt none} then the {\\tt ETree} object is not\nwritten to a file. \nOtherwise, the {\\tt ETree\\_writeToFile()} method is called to write\nthe object to \na formatted file (if {\\tt ETreeFile} is of the form {\\tt *.etreef}),\nor\na binary file (if {\\tt ETreeFile} is of the form {\\tt *.etreeb}).\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ndrawGraph msglvl msgFile inGraphFile inCoordsFile inTagsIVfile\n          outEPSfile linewidth1 linewidth2 bbox[4] rect[4] radius\n\\end{verbatim}\nThis driver program generates a Encapsulated Postscript file \n{\\tt outEPSfile} of a 2-D graph using a {\\tt Graph} object,\na {\\tt Coords} object and a tags {\\tt IV} object that contains the\ncomponent ids of the vertices.\n\\par\nSee the {\\tt doDraw} script file in this directory for an example\ncalling sequence.\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means that all objects are written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt inGraphFile} parameter is the input file for the {\\tt Graph}\nobject. It must be of the form {\\tt *.graphf} or {\\tt *.graphb}.\nThe {\\tt Graph} object is read from the file via the\n{\\tt Graph\\_readFromFile()} method.\n\\item\nThe {\\tt inCoordsFile} parameter is the input file for the {\\tt Coords}\nobject. It must be of the form {\\tt *.coordsf} or {\\tt *.coordsb}.\nThe {\\tt Coords} object is read from the file via the\n{\\tt Coords\\_readFromFile()} method.\n\\item\nThe {\\tt inTagsIVfile} parameter is the input file for the tags\n{\\tt IV} object. \nIt must be of the form {\\tt 'none'}, {\\tt *.ivf} or {\\tt *.ivb}.\nThe {\\tt IV} object is read from the file via the\n{\\tt IV\\_readFromFile()} method.\n\\item\nThe {\\tt outEPSfile} parameter is the output file for the Encapsulated\nPostscript file.\n\\item\nThe {\\tt linewidth1} parameter governs the linewidth of edges\nbetween vertices in the same component.\n\\item\nThe {\\tt linewidth2} parameter governs the linewidth of edges\nbetween vertices in different components.\n\\item\nThe {\\tt bbox[4]} array is the bounding box for the plot.\nIn Postscript the coordinates are in {\\it points}, where there are\n72 points per inch.\nFor example, a bounding box of {\\tt 0 0 200 300} will create a plot\nwhose size is 2.78 inches by 4.17 inches.\n\\item\nThe {\\tt rect[4]} array is the enclosing rectangle for the plot.\nTo put a 20 point margin around the plot, set\n{\\tt rect[0] = bbox[0] + 20},\n{\\tt rect[1] = bbox[1] + 20},\n{\\tt rect[2] = bbox[2] - 20} and\n{\\tt rect[3] = bbox[3] - 20}.\n\\item\nThe {\\tt radius} parameter governs the size of the filled circle\nthat is centered on each vertex.\nThe dimension is in points.\n\\end{itemize}\nSee Figure~\\ref{fig-R2D100} for a plot of the graph of {\\tt R2D100},\na randomly triangulated grid with 100 vertices with {\\tt linewidth1\n= 3}.\nFigure~\\ref{fig-R2D100-fishnet} illustrates a domain decomposition\nobtained from the fishnet algorithm \nof Chapter~\\ref{chapter:GPart:intro} \nwith {\\tt linewidth1 = 3} and {\\tt linewidth2 = 0.1}.\n\\par\n\\begin{figure}[htbp]\n\\caption{{\\sc R2D100}}\n\\label{fig-R2D100}\n\\begin{center}\n\\mbox{\n% \\psfig{file=R2D100notags.eps,height=4.00in,width=4.00in}\n\\psfig{file=../../misc/doc/R2D100notags.eps,height=4.00in,width=4.00in}\n}\n\\end{center}\n\\end{figure}\n\\par\n\\begin{figure}[htbp]\n\\caption{{\\sc R2D100: fishnet domain decomposition}}\n\\label{fig-R2D100-fishnet}\n\\begin{center}\n\\mbox{\n% \\psfig{file=R2D100fishnet.eps,height=4.00in,width=4.00in}\n\\psfig{file=../../misc/doc/R2D100fishnet.eps,height=4.00in,width=4.00in}\n}\n\\end{center}\n\\end{figure}\n\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\ntestSemi msglvl msgFile GraphFile ETreeFile mapFile\n\\end{verbatim}\nThis program is used to compute the effect of using a semi-implicit\nfactorization to solve \n$$\nAX = \n\\left \\lbrack \\begin{array}{cc}\nA_{0,0} & A_{0,1} \\cr\nA_{1,0} & A_{1,1} \n\\end{array} \\right \\rbrack\n\\left \\lbrack \\begin{array}{c}\nX_0 \\cr\nX_1 \n\\end{array} \\right \\rbrack\n=\n\\left \\lbrack \\begin{array}{c}\nB_0 \\cr\nB_1 \n\\end{array} \\right \\rbrack\n= B.\n$$\n$A$ is factored as\n$$\n\\left \\lbrack \\begin{array}{cc}\nA_{0,0} & A_{0,1} \\cr\nA_{1,0} & A_{1,1} \n\\end{array} \\right \\rbrack\n=\n\\left \\lbrack \\begin{array}{cc}\nL_{0,0} & 0 \\cr\nL_{1,0} & L_{1,1} \n\\end{array} \\right \\rbrack\n\\left \\lbrack \\begin{array}{cc}\nU_{0,0} & U_{0,1} \\cr\n 0 & U_{1,1} \n\\end{array} \\right \\rbrack,\n$$\nand to solve $AX = B$, we do the following steps.\n\\begin{itemize}\n\\item solve $L_{0,0} Y_0 = B_0$\n\\item solve $L_{1,1} U_{1,1} X_1 = B_1 - L_{1,0} Y_0$\n\\item solve $U_{0,0} X_0 = Y_0 - U_{0,1} X_1$\n\\end{itemize}\nAn alternative factorization is\n$$\nA =\n\\left \\lbrack \\begin{array}{cc}\nL_{0,0} & 0 \\cr\nA_{1,0}U_{0,0}^{-1} & L_{1,1} \n\\end{array} \\right \\rbrack\n\\left \\lbrack \\begin{array}{cc}\nU_{0,0} & L_{0,0}^{-1}U_{0,1} \\cr\n 0 & U_{1,1} \n\\end{array} \\right \\rbrack.\n$$\nTo solve $AX = B$, we do the following {\\it semi-implicit solve}.\n\\begin{itemize}\n\\item solve $L_{0,0} U_{0,0} Z_0 = B_0$\n\\item solve $L_{1,1} U_{1,1} X_1 = B_1 - A_{1,0} Z_0$\n\\item solve $L_{0,0} U_{0,0} X_0 = B_0 - A_{0,1} X_1$\n\\end{itemize}\nWhen we compare the semi-implicit solve against the explicit solve,\nwe see that the former needs\n$A_{0,1}$ and $A_{1,0}$ but not $L_{1,0}$ or $A_{0,1}$.\nand executes two solves with $L_{0,0}$ and $U_{0,0}$ (instead of one)\nand performs a matrix-matrix multiply with $A_{0,1}$ and $A_{1,0}$\ninstead of $L_{1,0}$ and $U_{0,1}$.\nIn situations where the numbers of entries in $L_{1,0}$ and\n$U_{0,1}$ are much larger than those in $A_{1,0}$ and $A_{0,1}$,\nand the numbers of entries in $L_{0,0}$ and $U_{0,0}$ are not too\nlarge, the semi-implicit factorization can be more efficient.\n\\par\nThis program reads in three objects:\na {\\tt Graph} object,\nan {\\tt ETree} object to specify the ordering,\nand an {\\tt IV} map object that tells which vertices are in the\nwhich blocks of the matrix.\nThe map from vertices to blocks follows the same convention as the\n{\\it component map} from the {\\tt GPart} object.\nIf {\\tt map[v] = 0}, then vertex {\\tt v} belongs to the Schur\ncomplement $(1,1)$ block.\nOtherwise, {\\tt v} belongs to a domain (the domain number is {\\tt\nmap[v]}) and so belongs to the $(0,0)$ block.\nThe output of the program gives statistics for storage and\noperation count for the two types of solves.\nFor example,\n\\begin{verbatim}\n storage: explicit = 1404, semi-implicit = 1063, ratio = 1.321\n opcount: explicit = 2808, semi-implicit = 2742, ratio = 1.024\n\\end{verbatim}\nis the output using the {\\tt do\\_testSemi} driver program for\nthe {\\tt R2D100} matrix.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt GraphFile} parameter is the input file for the {\\tt Graph}\nobject. It must be of the form {\\tt *.graphf} or {\\tt *.graphb}.\nThe {\\tt Graph} object is read from the file via the\n{\\tt Graph\\_readFromFile()} method.\n\\item\nThe {\\tt ETreeFile} parameter is the input file for the {\\tt ETree}\nobject. It must be of the form {\\tt *.etreef} or {\\tt *.etreeb}.\nThe {\\tt ETree} object is read from the file via the\n{\\tt ETree\\_readFromFile()} method.\n\\item\nThe {\\tt mapFile} parameter is the input file for the map {\\tt IV}\nobject. It must be of the form {\\tt *.ivf} or {\\tt *.ivb}.\nThe {\\tt IV} object is read from the file via the\n{\\tt IV\\_readFromFile()} method.\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nallInOne msglvl msgFile type symmetryflag pivotingflag\n         matrixFileName rhsFileName seed\n\\end{verbatim}\nThis {\\it all-in-one} driver program is an example that tests the\nserial $U^TDU$, $U^HDU$ or $LU$ factorization and solve.\nMatrix entries are read in from a file, and then the matrix \nis assembled and factored.\nThe right hand side entries are read in from a file, and the system\nis solved.\nThree input parameters specify the type of system (real or\ncomplex),\nthe type of factorization (symmetric, Hermitian or nonsymmetric)\nand whether pivoting is to be used for numerical stability.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\n{\\tt type} is the type of entries\n\\begin{itemize}\n\\item {\\tt 1} --- ({\\tt SPOOLES\\_REAL}) for real entries\n\\item {\\tt 2} --- ({\\tt SPOOLES\\_COMPLEX}) for complex entries\n\\end{itemize}\n\\item\n{\\tt symmetryflag} defines the factorization\n\\begin{itemize}\n\\item {\\tt 0} --- ({\\tt SPOOLES\\_SYMMETRIC}) \nfor a real or complex $U^TDU$ factorization\n\\item {\\tt 1} --- ({\\tt SPOOLES\\_SYMMETRIC}) \nfor a complex $U^HDU$ factorization\n\\item {\\tt 2} --- ({\\tt SPOOLES\\_SYMMETRIC}) \nfor a real or complex $LU$ factorization\n\\end{itemize}\n\\item\n{\\tt pivotingflag} defines pivoting or not for numerical stability\n\\begin{itemize}\n\\item {\\tt 0} --- ({\\tt SPOOLES\\_NO\\_PIVOTING}) for no pivoting\n\\item {\\tt 1} --- ({\\tt SPOOLES\\_PIVOTING}) for pivoting\n\\end{itemize}\nNote, the code has a pivoting threshold {\\tt tau = 100} hardwired\ninto the code.\n\\item\nThe {\\tt matrixFileName} parameter is the name of the input file\nfor the matrix entries.\nFor a real matrix, this file must have the following form.\n\\begin{verbatim}\nnrow ncol nent\n...\nirow jcol value\n...\n\\end{verbatim}\nwhere the first line has the number of rows, columns and entries.\n(Note, for this driver program {\\tt nrow} must be equal to {\\tt ncol}\nsince we are factoring a square matrix.)\nEach of the {\\tt nent} following lines contain one nonzero entry.\nFor a complex matrix, the file has this structure.\n\\begin{verbatim}\nnrow ncol nent\n...\nirow jcol real_value imag_value\n...\n\\end{verbatim}\nFor both real and complex entries, the entries need not be\ndisjoint,\ni.e., entries with the same {\\tt irow} and {\\tt jcol} values are\n{\\it summed}.\n\\item\nThe {\\tt rhsFileName} parameter is the name of the input file for\nthe right hand side matrix.\nIt has the following structure\n\\begin{verbatim}\nnrow nrhs\n...\nirow value_0 value_1 ... value_\\{nrhs-1\\}\n...\n\\end{verbatim}\nNote, {\\tt nrow} need not be the number of equations, here it is\nthe number of nonzero right hand side entries.\nThis allows us to input sparse right hand sides without specifying\nthe zeroes.\nIn contrast to the input for the matrix entries, the nonzero rows\n{\\it must} be unique.\nThe right hand side entries are not assembled into a dense matrix\nobject, but placed into the object.\n\\item\n{\\tt seed} is a random number seed used for the ordering process.\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\npatchAndGo msglvl msgFile type symmetryflag patchAndGoFlag fudge toosmall\n\n           storeids storevalues matrixFileName rhsFileName seed \n\\end{verbatim}\nThis driver program is used to test the ``patch-and-go''\nfunctionality for a factorization without pivoting.\nWhen small diagonal pivot elements are found, \none of three actions are taken.\nSee the {\\tt PatchAndGoInfo} object for more information.\n\\par\nThe program reads in a matrix $A$ and right hand side $B$,\ngenerates the graph for $A$ and orders the matrix,\nfactors $A$ and solves the linear system $AX = B$ for $X$\nusing multithreaded factors and solves.\nUse the script file {\\tt do\\_patchAndGo} for testing.\n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output.\nUse {\\tt msglvl = 1} for just timing output.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\nThe {\\tt type} parameter specifies a real or complex linear system.\n\\begin{itemize}\n\\item\n{\\tt type = 1 (SPOOLES\\_REAL)} for real,\n\\item\n{\\tt type = 2 (SPOOLES\\_COMPLEX)} for complex.\n\\end{itemize}\n\\item\nThe {\\tt symmetryflag} parameter specifies the symmetry of the matrix.\n\\begin{itemize}\n\\item\n{\\tt type = 0 (SPOOLES\\_SYMMETRIC)} for $A$ real or complex symmetric,\n\\item\n{\\tt type = 1 (SPOOLES\\_HERMITIAN)} for $A$ complex Hermitian,\n\\item\n{\\tt type = 2 (SPOOLES\\_NONSYMMETRIC)}\n\\end{itemize}\nfor $A$ real or complex nonsymmetric.\n\\item\nThe {\\tt patchAndGoFlag} specifies the ``patch-and-go'' strategy.\n\\begin{itemize}\n\\item\n{\\tt patchAndGoFlag = 0} --- if a zero pivot is detected, stop\ncomputing the factorization, set the error flag and return.\n\\item\n{\\tt patchAndGoFlag = 1} --- if a small or zero pivot is detected,\nset the diagonal entry to 1 and the offdiagonal entries to zero.\n\\item\n{\\tt patchAndGoFlag = 2} --- if a small or zero pivot is detected,\nperturb the diagonal entry.\n\\end{itemize}\n\\item\nThe {\\tt fudge} parameter is used to perturb a diagonal entry.\n\\item\nThe {\\tt toosmall} parameter is judge when a diagonal entry is small.\n\\item\nIf {\\tt storeids = 1}, then the locations where action was taken is\nstored in an {\\tt IV} object.\n\\item\nIf {\\tt storevalues = 1}, then the perturbations are\nstored in an {\\tt DV} object.\n\\item\nThe {\\tt matrixFileName} parameter is the name of the files where\nthe matrix entries are read from.\nThe file has the following structure.\n\\begin{verbatim}\nneqns neqns nent\nirow jcol entry\n...  ...  ...\n\\end{verbatim}\nwhere {\\tt neqns} is the global number of equations and {\\tt nent}\nis the number of entries in this file.\nThere follows {\\tt nent} lines, each containing a row index, a\ncolumn index and one or two floating point numbers, one if real,\ntwo if complex.\n\\item\nThe {\\tt rhsFileName} parameter is the name of the files where\nthe right hand side entries are read from.\nThe file has the following structure.\n\\begin{verbatim}\nnrow nrhs\nirow entry ... entry\n...  ...   ... ...\n\\end{verbatim}\nwhere {\\tt nrow} is the number of rows in this file\nand {\\tt nrhs} is the number of rigght and sides.\nThere follows {\\tt nrow} lines, each containing a row index\nand either {\\tt nrhs} or {\\tt 2*nrhs} floating point numbers,\nthe first if real, the second if complex.\n\\item\nThe {\\tt seed} parameter is a random number seed.\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nQRallInOne msglvl msgFile type matrixFileName rhsFileName seed\n\\end{verbatim}\nThis {\\it all-in-one} driver program is an example that tests the\nserial $QR$ factorization and solve.\nMatrix entries are read in from a file, and then the matrix \nis assembled and factored.\nThe right hand side entries are read in from a file, and the system\nis solved.\nOne input parameter specifies the type of system (real or\ncomplex).  \n\\par\n\\begin{itemize}\n\\item\nThe {\\tt msglvl} parameter determines the amount of output ---\ntaking {\\tt msglvl >= 3} means the {\\tt Perm} object is written\nto the output file.\n\\item\nThe {\\tt msgFile} parameter determines the message file --- if {\\tt\nmsgFile} is {\\tt stdout}, then the message file is {\\it stdout},\notherwise a file is opened with {\\it append} status to receive any\noutput data.\n\\item\n{\\tt type} is the type of entries\n\\begin{itemize}\n\\item {\\tt 1} --- ({\\tt SPOOLES\\_REAL}) for real entries\n\\item {\\tt 2} --- ({\\tt SPOOLES\\_COMPLEX}) for complex entries\n\\end{itemize}\n\\item\nThe {\\tt matrixFileName} parameter is the name of the input file\nfor the matrix entries.\nFor a real matrix, this file must have the following form.\n\\begin{verbatim}\nnrow ncol nent\n...\nirow jcol value\n...\n\\end{verbatim}\nwhere the first line has the number of rows, columns and entries.\nEach of the {\\tt nent} following lines contain one nonzero entry.\nFor a complex matrix, the file has this structure.\n\\begin{verbatim}\nnrow nrhs nent\n...\nirow jcol real_value imag_value\n...\n\\end{verbatim}\nFor both real and complex entries, the entries need not be\ndisjoint,\ni.e., entries with the same {\\tt irow} and {\\tt jcol} values are\n{\\it summed}.\n\\item\nThe {\\tt rhsFileName} parameter is the name of the input file for\nthe right hand side matrix.\nIt has the following structure\n\\begin{verbatim}\nnrow nrhs\n...\nirow value_0 value_1 ... value_\\{nrhs-1\\}\n...\n\\end{verbatim}\nNote, {\\tt nrow} need not be the number of equations, here it is\nthe number of nonzero right hand side entries.\nThis allows us to input sparse right hand sides without specifying\nthe zeroes.\nIn contrast to the input for the matrix entries, the nonzero rows\n{\\it must} be unique.\nThe right hand side entries are not assembled into a dense matrix\nobject, but placed into the object.\n\\item\n{\\tt seed} is a random number seed used for the ordering process.\n\\end{itemize}\n%-----------------------------------------------------------------------\n\\end{enumerate}\n", "meta": {"hexsha": "32fe3b9adc3c2c48826f9a77183e895302135ae8", "size": 22818, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/drivers.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/drivers.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/drivers.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 35.1046153846, "max_line_length": 73, "alphanum_fraction": 0.7018143571, "num_tokens": 6623, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.42690164157965366}}
{"text": "\\documentclass{article} % This command is used to set the type of document you are working on such as an article, book, or presenation\n\\usepackage{amsmath}  % This package allows the use of a large range of mathematical formula, commands, and symbols=]\n\\usepackage[linguistics]{forest}\n\\usepackage{tikz}\n\n\\begin{document}\n\n\\title{multiFaAcceleration: A program for the measurement of mutation velocity and acceleration from a four-species multiple alignment}\n\\author{Riley J. Mangan}\n\\maketitle\n\n\\section{Usage}\nmultiFaAcceleration - Performs velocity and acceleration on a four way multiple alignment in multiFa format.\\par\nA four way multiple alignment must contain four species (index 0 to 3) in the topology that species 1 to 3 are successive outgroups of species 0.\\par\nWhile this program accepts an alignment of any four species in this configuration, this program was initially written for a multiple alignment of Human, Chimpanzee, Gorilla, and Orangutan. Variable names in this documentation and in the code itself are named according to these species names.\\par\nThree bed files are returned. The first produces the normalized velocity score, the second returns the normalized acceleration score, and the third returns the normalized initial velocity score for each window of the genome for aln[0] (Human). This program can also produce the raw Velocity and Initial Velocity branch lengths as optional returns.\\par\nmultiFaAcceleration chromName in.fa velocity.bed acceleration.bed initialVelocity.bed\\par\n\n\\section{Distance-based phylogenetic inference with the Fitch-Margoliash method}\n\nConsider a phylogenetic tree with four extant species (Human, Chimpanzee, Gorilla, Orangutan), two extinct ancestors (Human-Chimp Ancestor (HCA) and Human-Gorilla Ancestor (HGA)), and branch lengths (BhumHca, BchimpHca, HCA-HGA, BhgaGor, BhgaOrang) with the following topology.\\par\n\n\\begin{center}\n\\begin{tikzpicture}\n\\node[above] at (-2,0) {$\\textbf{HCA}$};\n\\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\\textbf{HGA}$};\n\\draw (-2,0) -- node[above] {$BhumHcaA$}(-3.5,1.5) node[above] {$\\textbf{Hum}$};\n\\draw (-2,0) -- node[above] {$BchimpHca$}(-3.5,-1.5) node[below] {$\\textbf{Chimp}$};\n\\draw (2,0) -- node[above] {$BhgaGor$}(3.5,1.5) node[above] {$\\textbf{Gor}$};\n\\draw (2,0) -- node[above] {$BhgaOrang$}(3.5,-1.5) node[below] {$\\textbf{Orang}$};\\\n\\end{tikzpicture}\n\\end{center}\n\nConsider that we can measure the pairwise mutation distance between any two extant species on this tree, represented by $D_{ij}$. The distance defined by the sum of branch lengths, also known as the patristic distance, is represented as $d_{ij}$. It follows that the pairwise distance between two extant species is equal to the sum of branch lengths separating those species on the phylogenetic tree shown above. Thus, we are able to produce the following system of linear equations.\n\n\\begin{equation}\n\\begin{split}\n&D_{hum-chimp} \\approx d_{hum-chimp} =  BhumHca + BchimpHca\\\\\n&D_{hum-gor} \\approx d_{hum-gor} = BhumHca + BhcaHga + BhgaGor\\\\\n&D_{chimp-gor} \\approx d_{chimp-gor} = BchimpHca + BhcaHga + BhgaGor\\\\\n&D_{hum-orang} \\approx d_{hum-orang} = BhumHca + BhcaHga + BhgaOrang\\\\\n&D_{chimp-orang} \\approx d_{chimp-orang} = BchimpHca + BhcaHga + BhgaOrang\\\\\n&D_{gor-orang} \\approx d_{gor-orang} = BhgaGor + BhgaOrang\n\\end{split}\n\\end{equation}\n\nIf our interest is to study Human genome evolution, we can define the mutation distance as $BhumHca$, the distance between the human sequence and the sequence of its most recent ancestor with chimpanzees. We can then define the initial mutation distance as $BhcaHga$, the distance along the previous branch the inferred Human-Chimp ancestor and the common ancestor between humans and gorillas (HGA).\\par\nWe can compute branch lengths using the method of Fitch and Margoliash \\cite{pmid5334057} with an alternating least squares optimization algorithm developed by Felsenstein \\cite{pmid11975348}. While the full details and derivations for these methods can be found in these two papers, I will briefly explain the method below.\\par\nDue to such phenomenon as back mutation and discrepancies in INDEL-sensitive distance metrics, it is not always possible to find a set of branch lengths for the above system of equations such that $D_{ij} = d_{ij} \\: \\forall \\: i,j \\in S$, where $S$ is the set of all extant species. Thus, in the Fitch-Margoliash method, we aim to find a set of branch lengths $B$ that minimizes the squared difference between the pairwise and patristic distances. In symbolic terms:\n\\begin{equation*}\n\tQ = \\sum_{i \\in S}\\sum_{j \\in S}w_{ij}(D_{ij} - d_{ij})^2\n\\end{equation*}\nIn the above expression, $w_{ij}$ represents a weight for error terms, and serves to place more of the overall error in the estimated branch lengths on longer branches. This expression is of the form:\n\\begin{equation*}\n\\begin{split}\n\tw_{ij} = \\frac{1}{D_{ij}^2} \\mid D_{ij} \\ne 0\\\\\n\\end{split}\n\\end{equation*}\n\nWhen $D_{ij} = 0$, the weight term $w_{ij}$ approaches positive infinity. In this program, we approximate this limit by assigning an arbitrarily large number to $w_{ij}$. This value is $1000$ by default, but can be controlled by the user with the option $zeroDistanceWeightConstant$.\n\n\\section{Tree reduction and subtree optimization}\nIn the alternating least squares approach top optimize Q described by Felsenstein, we must first reduce the above tree, which contains two internal nodes $HCA$ and $HGA$, to subtrees containing only one internal node. These subtrees, which we refer to as the left and right subtrees, are shown below.\n\nLeft subtree:\n\\begin{center}\n\\begin{tikzpicture}\n\\node[above] at (-2,0) {$\\textbf{HCA}$};\n\\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\\textbf{HGA}$};\n\\draw (-2,0) -- node[above] {$BhumHca$}(-3.5,1.5) node[above] {$\\textbf{Hum}$};\n\\draw (-2,0) -- node[above] {$BchimpHca$}(-3.5,-1.5) node[below] {$\\textbf{Chimp}$};\n\\end{tikzpicture}\n\\end{center}\n\nRight subtree:\n\\begin{center}\n\\begin{tikzpicture}\n\\node[above] at (-2,0) {$\\textbf{HCA}$};\n\\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\\textbf{HGA}$};\n\\draw (2,0) -- node[above] {$BhgaGor$}(3.5,1.5) node[above] {$\\textbf{Gor}$};\n\\draw (2,0) -- node[above] {$BhgaOrang$}(3.5,-1.5) node[below] {$\\textbf{Orang}$};\\\n\\end{tikzpicture}\n\\end{center}\n\nIn the $multiFaAcceleration$ program, these subtrees are produced with the $pruneLeft$ and $pruneRight$ helper functions, respectively. To find the optimal branch lengths for these subtrees, we must find the pairwise distances between the extant species nodes and the ancestral node which is now a leaf in the subtree. For the left subtree, Felsenstein demonstrates that we can calculate these distances as:\n\\begin{equation*}\n\tD_{HumHga} = \\frac{w_{HumGor}(D_{HumGor} - BhgaGor) + w_{Humorang}(D_{HumOrang} - BhgaOrang)}{w_{HumGor} + w_{HumOrang}}\n\\end{equation*}\n\\begin{equation*}\n\tD_{ChimpHga} = \\frac{w_{ChimpGor}(D_{ChimpGor} - BhgaGor) + w_{ChimpOrang}(D_{ChimpOrang} - BhgaOrang)}{w_{ChimpGor} + w_{ChimpOrang}}\n\\end{equation*}\nSimilarly, for the right subtree:\n\\begin{equation*}\n\tD_{HcaGor} = \\frac{w_{HumGor}(D_{HumGor} - BhgaGor) + w_{ChimpGor}(D_{ChimpGor} - BhgaOrang)}{w_{HumGor} + w_{ChimpGor}}\n\\end{equation*}\n\\begin{equation*}\n\tD_{HcaOrang} = \\frac{w_{HumOrang}(D_{HumOrang} - BhgaGor) + w_{ChimpOrang}(D_{ChimpOrang} - BhgaOrang)}{w_{HumOrang} + w_{ChimpOrang}}\n\\end{equation*}\nAs distance is necessarily a non-negative quantity, and the weight constant is set to an arbitrarily large number when $D_{ij} = 0$, the denominator in the above equations can never be zero, and does not need to be otherwise constrained.\\par\nThe three-species left subtree with branch lengths $v$ has the following optimal branch lengths:\n\\begin{equation*}\n\\begin{split}\nv_a = \\frac{(D_{ab} + D_{ac} - D_{bc})}{2}\\\\\nv_b = \\frac{(D_{ab} + D_{bc} - D_{ac})}{2}\\\\\nv_c = \\frac{(D_{ac} + D_{bc} - D_{ab})}{2}\n\\end{split}\n\\end{equation*}\n\n\\section{Constraint for non-negative branch lengths}\nIn some cases, the optimal set of branch lengths for the minimization of Q will include negative branch lengths. While this can be allowed by the user with the option $allowNegative$, this program constrains branch lengths to non-negative values by default. Briefly, when one or more branches from the 3-species subtrees are evaluated as negative values, they are set to 0. From Felsenstein 1997, if branch lengths $v_b$ or $v_c$ are set to zero in this fashion, the new optimal branch length for $v_a$, given that either of these terms are set to zero, can be approximated as:\n\\begin{equation*}\n\t\\hat v_a = \\frac{w_{ab}(D_{ab} - v_b) + w_{ac}(D_{ac} - v_c)}{w_{ab} + w_{ac}}\n\\end{equation*}\n\n\\section{Algorithm for branch length calculations}\nWith these equations in hand, we can now describe the algorithm for computing optimal branch lengths for the four-species tree, which is performed by the helper function $alternatingLeastSquares$ in $multiFaAcceleration$. First, the set of output branch lengths are initialized such that each branch length is equal to 1. In each iteration, the tree is first pruned to the left subtree, and the branch lengths $BhumHca, BchimpHca, BhcaHga$ are then set to the optimal branch lengths for this subtree. Next, the tree is pruned into the right subtree, and the branches $BhcaHga, BhgaGor, BhgaOrang$ are then set to the optimal values for this subtree. Once both optimizations have occurred, the value of Q is calculated for the current branch lengths and compared to the value of Q observed in the previous iteration. If the difference between the estimates of Q falls below a user-specified level of error $\\epsilon$, the answer is returned. Otherwise, a new iteration is initiated. This heuristic will converge on a local minimum for Q and achieve stationarity in finite iterations. Due to the approximation used for non-negative branch lengths, it is possible stationarity will be achieved as the oscillation between two sets of branch lengths. In this case, we take the set of branch lengths associated with the lowest value of Q.\n\\section{Genome-wide acceleration calculation}\nFor a given four-way alignment in multiFa format, $gonomics:multiFaAcceleration$ calculates $BhumHca$ and $BhcaHga$ using pairwise mutation distance (defined as the number of SNPs and INDELs, where each INDEL counts as one mutation regardless of length) for each window of a user-specified window size. Windows may be every possible window of the genome, or may be restricted to a particular subset of the genome using the option $-searchSpaceBed$, which enables the input of a bed file which specifies the regions that should be considered. The option $-searchSpaceProportion$ enables the user to consider all windows in which at least a user-specified proportion of bases are within the searchSpace.\n\nWe define $\\textbf{v}$ as the normalized mutation velocity, or the normalized rate of mutation over the branch $BhumHca$. To calculate $\\textbf{v}$, we calculate the average $BhumHca$ length $E(BhumHca)$ across all windows. For each window:\n\\begin{equation*}\n\t\\textbf{v} = \\frac{BhumHca}{E(BhumHca)}\n\\end{equation*}\n\nSimilarly, the normalized initial rate of mutation, or the normalized rate of mutation over the branch $BhcaHga$, can be calculated as:\n\\begin{equation*}\n\t\\textbf{v}_0 = \\frac{BhcaHga}{E(BhcaHga)}\n\\end{equation*}\nWhere $e(BhcaHga)$ is the average value of $BhcaHga$ over all windows.\\par\n$\\textbf{v}$ and $\\textbf{v}_0$ have intuitive numerical interpretations. If $\\textbf{v} = 1$ for a particular window, the mutation rate in the branch $BhumHca$ is equal to the chromosome-wide average mutation rate. $\\textbf{v} = 2$ would be found in a region evolving twice as quickly, and $\\textbf{v} = 0.5$ in a region evolving at half the average rate. The same interpretations apply for $\\textbf{v}_0$, the rate of evolution along the branch $BhcaHga$.\\par\nFinally, we define the quantity $\\textbf{a}$, for acceleration, as the normalized change in mutation rate between branches branches $BhumHca$ and $BhcaHga$:\n\\begin{equation*}\n\\textbf{a} = \\textbf{v} - \\textbf{v}_0\n\\end{equation*}\n\nThe quantity $\\textbf{a}$ is equal to zero when the mutation rate along $BhumHca$ is equal to the mutation rate along $BhcaHga$. As both $\\textbf{v}$ and $\\textbf{v}_0$ are normalized, this holds true even if $BhumHca$ and $BhcaHga$ are not equal in absolute length, which will be the case when the extant species are not separated by equal amounts of evolutionary time (in the example here, the distance between humans and chimpanzees, about six million years, is nearly triple the 2.5 million years separating the Human-Chimp Ancestor from the Human-Gorilla Ancestor). Positive values for $\\textbf{a}$ indicate accelerated regions, and negative values suggest regions under negative acceleration, in which a region evolved at a slower rate along $BhumHca$ than $BhcaHga$.\n\n\\bibliographystyle{genres}\n\\bibliography{multiFaRefs}\n \n\\end{document}\n", "meta": {"hexsha": "02ee5bfe0b5cc1df329ce92e7b7ccca544556d42", "size": 12958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "riley/multiFaAccelerationREADME/multiFaAcceleration_README.tex", "max_stars_repo_name": "vertgenlab/vglDocumentation", "max_stars_repo_head_hexsha": "b3a486739b123f05a0cc247c498ef2da44e864af", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "riley/multiFaAccelerationREADME/multiFaAcceleration_README.tex", "max_issues_repo_name": "vertgenlab/vglDocumentation", "max_issues_repo_head_hexsha": "b3a486739b123f05a0cc247c498ef2da44e864af", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "riley/multiFaAccelerationREADME/multiFaAcceleration_README.tex", "max_forks_repo_name": "vertgenlab/vglDocumentation", "max_forks_repo_head_hexsha": "b3a486739b123f05a0cc247c498ef2da44e864af", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.2535211268, "max_line_length": 1332, "alphanum_fraction": 0.758604723, "num_tokens": 3730, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4269016340104355}}
{"text": "\\chapter{Interactive Assumptions}\n\nThis chapter covers the implementation of our approach for\nanalyzing interactive assumptions.\n%\nWe get an input of the following form:\n\\begin{verbatim}\nemaps G1 * G2 -> GT.\nisom G1 -> G2.\n\ninput [ X, Y ] in G1.\n\noracle O(m : Fq) = sample A:G1, (A, A*Y, A*X + m*A*X*Y).\n\nwin(U:G1, V:G1, W:G1, mm) = U <> 0 /\\ mm <> m_i /\\ V = UX /\\ W = U*X + m*U*X*Y.\n\\end{verbatim}\n%\nFor now, we make the following assumptions:\n\\begin{enumerate}\n\\item Either the group setting is a generic group or the input, oracle\n  arguments and return values, and winning condition input\n  are all in one group. In the last case, we exploit that the\n  problem is computational.\n\\item All oracle inputs are of type \\verb!Fq!. Allowing for group\n  elements complicates the definition.\n\\end{enumerate}\n%\nWe first compute a formal sum for each \\verb!win! input of type $\\group$\n  as follows:\n\\begin{enumerate}\n\\item Assume that the adversary is given inputs\n  $\\vec{f}$ where $f_j$ defines an element in\n  $\\group$ over random variables~$\\vec{X}$.\n\\item That there is one oracle taking field elements\n  $\\vec{m}$ and returning $\\vec{g}$\n  where $g_j$ defines an element in $\\group$\n  over the variables $\\vec{X}$ and the variables\n  $\\vec{A}$ sampled in the oracle call.\n\\item We assume there are $q$ oracle queries.\n\\item As a first step, we introduce indexed parameters\n  $m_{1,j},\\ldots,m_{l,j}$ ($j \\in [q]$) and\n  indexed random variables\n  $A_{1,j},\\ldots,A_{r,j}$ ($j \\in [q]$).\n\\item Then all computable elements can\n  be expressed as linear combinations as follows:\n  \\[\n    \\alpha_1 f_1 + \\ldots + \\alpha_k f_k\n    + \\Sigma_{i=1}^q \\beta_{1,i}\\, g_1(\\vec{m_i},\\vec{A_i},\\vec{X})\n    \\ldots\n    + \\Sigma_{i=1}^q \\beta_{n,i}\\, g_n(\\vec{m_i},\\vec{A_i},\\vec{X})\n  \\]\n\\item We assume the winning condition takes\n  elements $\\vec{U}$ in $\\group$.\n  Then we use $\\alpha_i^{(j)}$ and $\\beta_i^{(j)}$ (this is a vector) for \n  the coefficients of $U_j$.\n\\end{enumerate}\n\nWe represent such linear combinations as formal sums.", "meta": {"hexsha": "a7fb9bb59109eb96ee86273dcdbd68f48e0a197d", "size": 2027, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/chap-interactive.tex", "max_stars_repo_name": "generic-group-analyzer/gga", "max_stars_repo_head_hexsha": "75d362fb3db4cc34b8e3fc7e6d76d8d31068457f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-08-17T11:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-14T14:00:14.000Z", "max_issues_repo_path": "doc/chap-interactive.tex", "max_issues_repo_name": "generic-group-analyzer/gga", "max_issues_repo_head_hexsha": "75d362fb3db4cc34b8e3fc7e6d76d8d31068457f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/chap-interactive.tex", "max_forks_repo_name": "generic-group-analyzer/gga", "max_forks_repo_head_hexsha": "75d362fb3db4cc34b8e3fc7e6d76d8d31068457f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.9482758621, "max_line_length": 79, "alphanum_fraction": 0.6808090775, "num_tokens": 646, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.42686934091794226}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 05/18/21\n\nNow let us consider the Euler-Lagrange equations of a graph:\n\\begin{align*}\n\t&\\inf_{u} \\left\\{ \\int_\\Omega f(\\nabla u) \\mid \\int_\\Omega g(u) = M \\right\\} \\quad &(P_1)\\\\\n\t&\\inf_{u} \\left\\{ \\int_\\Omega f(\\nabla u) \\mid \\int_{\\Omega }g(u) = M; \\; u = u_0 \\; \\partial \\Omega  \\right\\}  \\quad &(P_2)\n\\end{align*}\n\n\\begin{exmp}\n\tConsider \\(f(z) = \\sqrt{1+\\left| z \\right|^2} \\) and \\(g(s) = \\left| s \\right| \\), \\(u_0 = 0\\). We are looking for minimizers that satisfy \\(\\int_\\Omega \\left| u \\right| = M\\). If \\(u\\geq 0\\), then this integral is exactly the area below the graph of \\(u\\).\\\\\n\n\tProblems of this sort are referred to as being of \\textbf{isoperimetric type}. We have a fixed perimeter, and we want to minimize a function which is constrained along it. It does not always admit a solution, however.\\\\\n\n\tTo see this, consider \\(\\Omega = B_R(0)\\). The minimizer will be a spherical cap described by \\(u(x) = \\sqrt{S^2-\\left| x \\right|^2} - \\sqrt{S^2 - R^2} \\) for some \\(S\\geq R\\). If \\(M > \\dfrac{\\left| B_R \\right| }{2}\\) then there is no graph which can attain \\(M\\) within the constraints!\n\\end{exmp}\n\\begin{figure}[ht]\n    \\centering\n     \\def\\svgwidth{1\\linewidth}\n     \\input{./figures/example-space-for-p_1-and-p_2.pdf_tex}\n     \\caption{Area graph with \\(f(z) = \\sqrt{1+\\left| z \\right|^2} \\) and \\(g(s) = \\left| s \\right| \\)}\n    \\label{fig:example-space}\n\\end{figure}\n\n\\begin{exmp}\n\tConsider \\(f(\\nabla u) = \\dfrac{\\left| \\nabla u \\right|^2}{2}\\), \\(g(u) = \\dfrac{u^2}{2}\\) and \\(u_0 = 0\\).\\\\\n\n\tIn this case, minimizers \\textit{always} exist, and are eigenfunctions of \\(-\\Delta \\) that satisfy the zero Dirichlet condition.\n\\end{exmp}\n\n\\section{Linear Transformations by Smooth Functions}\n\\label{sec:linear_transformations_by_smooth_functions}\n\nWe can learn more about minimizers on the graph family of Euler-Lagrange equations by combining them with nicely behaved functions. Consider\n\\begin{align*}\n\t\\int_\\Omega g(u+t\\varphi ) = M\n\\end{align*}\nfor all non-negative real \\(t\\). What constraints must \\(\\varphi \\) have to satisfy this? We can see that\n\\begin{align*}\n\tg(u+t\\varphi ) = g(u) + tg'(u)\\varphi + \\dfrac{t^2}{2}g''(u)\\varphi^2 + o(t^3)\\implies\\\\\n\tM = M+t \\int_\\Omega g'(u) \\varphi  + \\dfrac{t^2}{2}\\int_\\Omega g''(u)\\varphi^2 + o(t^3)\n\\end{align*}\nfor all \\(t\\). We can actually infer from this that \\(\\int_\\Omega g'(u) \\varphi  = 0\\) by the first-order conservation of \\(\\int g(u)\\)!\\footnote{To check this, apply integration by parts and see what you get.} Then the sum \\(u+t\\varphi \\) only differs from \\(u\\) by \\(o(t^2)\\), and so for small \\(t\\) is relatively close.\\\\\n\n% Diagram\n\nIn the context of differential geometry, we can interpret this new family as the functions in\n\\begin{align*}\n\tT_u\\mathcal{M} = \\left\\{\\varphi  \\mid \\int g'(u)\\varphi  = 0 \\right\\} .\n\\end{align*}\nThis is because if \\(\\varphi :\\int_{\\Omega }g'(u)\\varphi  = 0\\), then there should be an \\(O(t^2)\\) correction such that\n\\begin{align*}\n\tu+t\\varphi +O(t^2) \\in \\mathcal{M}.\n\\end{align*}\n\nLet us discuss these families more formally. Let \\(\\varphi, \\xi  \\in C^{\\infty}(\\overline{\\Omega })\\) such that\n\\begin{align*}\n\t\\int_\\Omega g'(u)\\varphi =0 \\quad \\int_\\Omega  g'(u) \\xi   = 1\n\\end{align*}\nConsider \\(u+t\\varphi +s \\xi  \\in C^{\\infty}(\\Omega )\\) with two parameters \\((t,s)\\). The implicit function theorem tells us that there exists \\(\\varepsilon>0\\) and \\(s(t):(-\\varepsilon,\\varepsilon)\\to \\R\\) such that, if \\(u(t) = u + t\\varphi  + s(t) \\xi  \\), then\n\\begin{align*}\n\t\\int_\\Omega g(u(t)) = M \\quad \\forall \\left| t \\right| <\\varepsilon\\\\\n\ts(0) = 0\n\\end{align*}\nThis \\(s(t)\\) is in essence our \\(O(t^2)\\) correction that allows the families \\(\\varphi \\) to still satisfy our condition. Let us look in more detail how \\(s(t)\\) interacts with our current formulations:\n\n\\begin{align*}\n\t\\int_\\Omega g(u) &= \\int_\\Omega g(u+t\\varphi +s(t) \\xi ) \\\\\n\t&= \\int_\\Omega g(u) + t \\int _\\Omega g'(u) \\left[ \\varphi +s'(0) \\xi  \\right] + \\dfrac{t^2}{2}\\int_\\Omega  g''(u)\\left[ \\varphi +s'(0)\\xi  \\right]^2 + g'(u) \\xi  s''(0) + o(t^2) \\\\\n\t&\\implies 0 = \\int _\\Omega g'(u) \\left[ \\varphi +s'(0) \\xi  \\right] = s'(0) \\int_\\Omega g'(u) \\xi  = s'(0)\\\\\n\t&\\implies 0 = \\int_\\Omega g''(u)\\varphi^2 + s''(0) \\int_\\Omega g'(u) \\xi \n\\end{align*}\nBut notice that \\(\\int_\\Omega g'(u) \\xi  = 1\\), so that\n\\begin{align*}\n\ts''(0) = - \\int_\\Omega g''(u) \\varphi^2\n\\end{align*}\nThis classifies our correction factor up to low orders, so we have that\n\\begin{align*}\n\ts \\approx - \\left[ \\int_\\Omega g''(u) \\varphi^2 \\right] \\cdot \\dfrac{t^2}{2}\n\\end{align*}\n\nNow we can plug this back into the Euler-Lagrange equations of the problem\n\\begin{align*}\n\t\\inf_{u} \\left\\{ \\int_\\Omega f(\\nabla u) \\mid \\int_\\Omega g(u) = M \\right\\} .\n\\end{align*}\nto get\n\\begin{align*}\n\t\\mathcal{F}(u+t\\varphi +s(t) \\xi ) \\geq \\mathcal{F}(u) \\quad \\forall \\left| t \\right| < \\varepsilon\\\\\n\\end{align*}\nand our variations on\n\\begin{align*}\n\tf(\\nabla u + t \\nabla \\varphi + s(t) \\nabla \\xi )\n\\end{align*}\nare given by\n\\begin{align*}\n\t&\\frac{d}{dt} f(\\nabla u + t\\nabla \\varphi + s(t) \\nabla \\xi ) = \\nabla f(\\nabla u+\\ldots) \\cdot (\\nabla \\varphi +s'(t) \\nabla \\xi )\\\\\n\t&= \\nabla f(\\nabla u)\\cdot \\nabla \\varphi \\\\\n\t&\\frac{d^2}{dt^2}f(\\nabla u+t \\nabla \\varphi + s(t) \\nabla \\xi) = (\\nabla \\varphi +s'(t) \\nabla \\xi ) \\cdot \\nabla^2 f(\\nabla u + \\ldots)(\\nabla \\varphi + s'(t) \\nabla \\xi ) + \\nabla f(\\nabla u + \\ldots)\\cdot \\nabla \\xi s''(t) \\\\\n\t&= \\nabla \\varphi \\cdot (\\nabla^2f(\\nabla u)\\nabla \\varphi ) + \\nabla f(\\nabla u)\\cdot \\nabla \\xi s''(0)\n\\end{align*}\n\n\\hrulefill\n\nNow let \\(\\psi \\in C^{\\infty}(\\overline{\\Omega })\\) and choose\n\\begin{align*}\n\t\\varphi = \\psi - \\left[ \\frac{\\int g '(u) \\psi }{\\int  g '(u)^2} \\right] g'(u) = \\int_\\Omega g'(u)\\varphi =0\n\\end{align*}\nOr in other words, we are choosing \\(\\varphi \\) to be \\(\\psi \\) subtracted by its projection along \\(g'(u)\\). We are choosing \\(\\varphi \\) this way so that \\(\\langle g'(u), \\varphi  \\rangle = 0\\). Note that there is an implicit assumption here that \\(g\\) satisfies \\(\\int g '(u)^2 > 0\\). Lastly, choose \\(\\xi = \\dfrac{g'(u)}{\\int_\\Omega g'(u)^2}\\) so that \\(\\langle g'(u),\\xi  \\rangle= 1\\).\n\nNow let's reconsider the Euler-Lagrange equations, but with the choices of \\(\\varphi \\) and \\(\\xi \\) as above. That is, for all \\(\\varphi \\) and \\(\\xi \\) of the form above:\n\\begin{align*}\n\t\\int_\\Omega \\nabla f(\\nabla u)\\cdot \\nabla \\varphi = 0\\\\\n\t\\int_\\Omega \\nabla \\varphi \\cdot (\\nabla^2f(\\nabla u)\\nabla \\varphi ) + s''(0) \\nabla f(\\nabla u)\\cdot \\nabla \\xi \\geq 0\n\\end{align*}\nNow we substitute in the projection form for \\(\\varphi \\) :\n\\begin{align*}\n\t\\int_\\Omega \\nabla f ( \\nabla u) \\cdot \\left[ \\nabla \\psi - \\left[ \\frac{\\int g'(u) \\psi }{\\int g'(u)^2} \\right] g''(u) \\nabla u \\right]= 0 \\\\\n\\implies \\int_\\Omega \\nabla f(\\nabla u)\\cdot \\nabla \\psi - \\lambda (u) \\int_\\Omega g'(u) \\psi = 0\n\\end{align*}\nand so\n\\begin{align*}\n\t\\lambda (u) = \\frac{\\int_\\Omega g''(u) \\left[ \\nabla u \\cdot \\nabla f(\\nabla u) \\right] }{\\int_\\Omega g'(u)^2}\n\\end{align*}\nThis \\(\\lambda(u)\\) is what we refer to by a \\textbf{Lagrange multiplier}.\\\\\n\nNow denote \\(X \\cong \\nabla f(\\nabla u)\\) and observe:\n\\begin{align*}\n\t\\int_\\Omega X \\cdot \\nabla \\psi = \\int_\\Omega dw(\\psi X) - \\int_\\Omega \\psi \\textrm{div}X\\\\\n\t= \\int_{\\partial\\Omega }\\psi (X\\cdot \\nu_\\Omega ) - \\int_\\Omega \\psi \\textrm{div}X.\n\\end{align*}\n\n\\begin{align*}\n\t0 = \\int_{\\partial\\Omega }\\psi \\nu_\\Omega \\cdot \\nabla f(\\nabla u) + \\int_\\Omega \\psi \\left[ -dw(\\nabla f(\\nabla u)) - \\lambda g'(u) \\psi  \\right] \\quad \\forall \\psi \\in C^{\\infty}(\\overline{\\Omega })\n\\end{align*}\nTesting on \\(\\psi =0\\) on \\(\\partial\\Omega \\), but arbitrary otherwise, we get on \\(\\Omega \\) :\n\\begin{align*}\n\t-dw(\\nabla f(\\nabla u)) = \\lambda g'(u)\n\\end{align*}\nOnce we know this we get\n\n\\begin{align*}\n\t\\begin{cases}\n\t-dw(\\nabla f(\\nabla u)) = \\lambda g'(u) & \\Omega \\\\\n\t\\nu_\\Omega \\cdot \\nabla f(\\nabla u) = 0 & \\partial\\Omega\n\t\\end{cases}\n\\end{align*}\n\n\\begin{exmp}\n\tChoosing \\(f(z) = \\dfrac{\\left| z \\right|^2 }{2}\\) and \\(g(u) = \\dfrac{u^2}{2}\\), the above becomes\n\t\\begin{align*}\n\t\t- \\Delta u = \\lambda u \\quad \\Omega \\\\\n\t\t\\frac{\\partial u}{\\partial \\nu_\\Omega } = \\nabla u\\cdot \\nu_\\Omega  = 0 \\quad \\partial\\Omega \n\t\\end{align*}\n\tThis is the Neumann eigenfunctions of the Laplacian \\(\\Omega \\).\n\\end{exmp}\n\n\\begin{exmp}\n\tConsider the space \\(\\Omega  = (0,\\pi )\\), and let \\(u_k(x) = \\cos(kx)\\) for \\(k \\in \\N\\). These are all solutions to\n\t\\begin{align*}\n\t\t-u_k'' = \\lambda u_k \\quad (0,\\pi )\\\\\n\t\tu'_k\\mid_{0,\\pi }=0\n\t\\end{align*}\n\t\\(\\lambda =k^2\\) and \\((u_k) \\cong k^2\\). This is an example of a variational problem with many critical points.\n\\end{exmp}\n\nNotice that if \\(f(z) = \\sqrt{1+\\left| z \\right|^2} \\) then \\(\\nabla f(\\nabla u) \\cdot \\nu_\\Omega = \\frac{\\nabla u \\cdot \\nu_{\\Omega }}{\\sqrt{1+ \\left| \\nabla u \\right|^2} }=0\\).\n\n\\end{document}\n", "meta": {"hexsha": "d755a21f757535350d16e91798e00f940eeed80d", "size": 9282, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture2.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture2.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture2.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.9032258065, "max_line_length": 390, "alphanum_fraction": 0.6332686921, "num_tokens": 3619, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7248702880639792, "lm_q1q2_score": 0.42686823385742473}}
{"text": "\\documentclass[12pt]{article} \\input{physics1}\n\\begin{document}\n\n\\noindent\nName: \\rule[-1ex]{0.55\\textwidth}{0.1pt}\nNetID: \\rule[-1ex]{0.2\\textwidth}{0.1pt}\n\n\\section*{NYU Physics I---Term Exam 6}\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nWhat is the speed of a package orbiting on a circular orbit right near\nthe surface of the Earth? Give your answer in $\\mps$.\n(from Problem Set 11)\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nSketch an orbit of roughly eccentricity 0.9. Most importantly: Show the\npoint about which the object is orbiting, and make sure your pericenter\nand apocenter distances make sense. Don't worry about getting it all right,\njust roughly!\n(from Problem Set 12)\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nDraw a space-time diagram that shows a stationary base E (in the rest\nframe of E) and a ship S moving at speed $0.5\\,c$ in the $x$\ndirection with respect to E. At some time (your choice!) when the base and ship are far\napart, base E sends a light signal to the ship S. Draw that light\nsignal on your diagram too.\n(from Problem Set 13)\n\n\\vfill\n~\n\\clearpage\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nEarth orbits on a nearly circular orbit at 1\\,AU; Jupiter orbits\non a nearly circular orbit at 5.2\\,AU. What is the semi-major axis\nof the transfer orbit that just kisses both of these orbits?\n(from lecture on 2018-11-27)\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nIf you want to observe a time-dilated celebration (or, say, lifetime\nof some unstable particles), time dilated by a factor of 10, how fast\ndoes the party (or do the particles) have to move with respect to you?\nGive your answer in terms of the speed of light $c$.\n(from lecture on 2018-12-04)\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\nWhat is the spacetime interval $(\\Delta s)^2$ between the two events $A$ and $B$?\n$$A = (c\\,t_A, x_A) = (2\\,\\m, 6\\,\\m) $$\n$$B = (c\\,t_B, x_B) = (7\\,\\m, 3\\,\\m) $$\nDon't forget your units. (from the recitation on the interval)\n\n\\vfill\n~\n\\end{document}\n", "meta": {"hexsha": "e4d5f03f345793c1c1c9b44318a84400c14c4dee", "size": 2136, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/physics1_exam6.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/physics1_exam6.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/physics1_exam6.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.375, "max_line_length": 87, "alphanum_fraction": 0.7415730337, "num_tokens": 650, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.42686823035731675}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{enumitem}\n\\usepackage{amsmath}\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{booktabs}\n\\usepackage[font=small, labelfont=bf]{caption}\n\\usepackage[T1]{fontenc}\n\n% macro to select a scaled-down version of Bera Mono (for instance)\n\\makeatletter\n\\newcommand\\BeraMonottfamily{%\n  \\def\\fvm@Scale{0.85}% scales the font down\n  \\fontfamily{fvm}\\selectfont% selects the Bera Mono font\n}\n\\makeatother\n\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.92}\n\n\\lstdefinestyle{mystyle}{\n    backgroundcolor=\\color{backcolour},\n    commentstyle=\\color{codegreen},\n    keywordstyle=\\color{magenta},\n    numberstyle=\\tiny\\color{codegray},\n    stringstyle=\\color{codepurple},\n    basicstyle=\\BeraMonottfamily\\footnotesize,\n    breakatwhitespace=false,         \n    breaklines=true,                 \n    captionpos=b,                    \n    keepspaces=true,                 \n    numbers=left,                    \n    numbersep=5pt,                  \n    showspaces=false,                \n    showstringspaces=false,\n    showtabs=false,                  \n    tabsize=2\n}\n\\lstset{style=mystyle,\n        otherkeywords={True,False}\n}\n\n\\title{CS249 Fall 2020\\\\\n       Problem Set 2: Statistical Inference II}\n\\author{Christopher Munoz Cortes}\n\\date{\\today}\n\n\\usepackage{natbib}\n\\usepackage{graphicx}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Hypothesis Testing}\nAssume a friend of yours currently has a salary of \\$70k per year. She is\nconsidering a switch in her career, and has narrowed down her choices to\nthree different options. She has been able to find the following data points\nfor entry-level salaries (in thousand dollars) for these three choices:\n\\begin{enumerate}\n\\item 143 102 119 157 146 61 119 85 87 102\n\\item 77 143 108 76 92 87 145 60 86 27\n\\item 19 83 87 55 115 41 71 66 101 99\n\\end{enumerate}\nAssume that these data points are IID observations, and the difference between \nthem can only be attributed to noise. Additionally, assume that after\na career change your friend’s salary will be a sample from the same distribution \nas the one behind your observed data points.\n\\begin{enumerate}[label={(\\alph*)}]\n    \\item Can your friend expect an increase in her salary on average if she\n    chooses \\#1?\n    \n    An appropriate null hypothesis to answer this question would be the following\n    one-tail test: $H_0: \\mu_0 \\leq 70$. If we can reject $H_0$, then we can assert\n    that the population mean is higher than \\$70k, and conclude that our friend\n    should expect, on average, an increase in her salary. \n    Since $\\frac{p}{2} = 0.0009 < \\alpha = 0.05$\n    and $t>0$ we reject $H_0$. As a consequence, our friend should expect an\n    increase in her salary on average if she chooses \\#1.\n    \n    \\item Is there any difference between the average salary of the three \n    choices?\n    \n    Here we define $H_0: \\mu_1 = \\mu_2 = \\mu_3$ as our null hypothesis and use an \n    ANOVA test to verify it. The result of the test shows that we have enough evidence\n    to reject the null hypothesis, since $p = 0.04 < \\alpha = 0.05$. As a\n    consequence, we assert that there is a difference between the average salary of\n    the three choices.\n    \n    \\item Is there any difference between the average salary of \\#1 and \\#3?\n    \n    We can answer this question testing the following null hypothesis: $H_0: \\mu_1\n    = \\mu_3$ and verifying its validity. Since $p = 0.01 < \\alpha = 0.05$ we reject \n    $H_0$ and assert that the mean salary for choice 1 and choice 2 are different.\n\\end{enumerate}\n\n\\begin{lstlisting}[language=Python, caption=Code for Question 1 \\emph{Hypothesis\nTesting}]\nimport numpy as np\nfrom scipy import stats\n\ny_1 = np.array([143, 102, 119, 157, 146, 61, 119, 85, 87, 102])\ny_2 = np.array([77, 143, 108, 76, 92, 87, 145, 60, 86, 27])\ny_3 = np.array([19, 83, 87, 55, 115, 41, 71, 66, 101, 99])\n\n# Part (a): H_0: mean >= 70k\nmu_0 = 70\nt_stat, p_val = stats.ttest_1samp(y_1, mu_0)\nprint(f\"t-stat: {t_stat}\")\nprint(f\"p-value: {p_val/2}\")\n\n# Part (b): H_0: mu_1 = mu_2 = mu_3\nf_stat, p_val = stats.f_oneway(y_1, y_2, y_3)\nprint(f\"f-stat: {f_stat}\")\nprint(f\"p-value: {p_val}\")\n\n# Part (c): H_0: mu_1 = mu_3\nt_stat, p_val = stats.ttest_ind(y_1, y_3, equal_var=True)\nprint(f\"t-stat: {t_stat}\")\nprint(f\"p-value: {p_val}\")\n\\end{lstlisting}\n\n\\pagebreak\n\n\\section{Regression to the Mean}\n\\begin{enumerate}[label={(\\alph*)}]\n    \\item Assume $x$ represents the height of the father and $y$ \n    represents the height of the son. Standardize the two \n    covariates. You can use the following code:\n    \n    \\lstinline{x = (x - np.mean(x)) / np.std(x)}\n    \n    \\lstinline{y = (y - np.mean(y)) / np.std(y)}\n    \n    Plot \\lstinline{y} vs. \\lstinline{x} in a scatter plot in Python.\n    \\begin{figure}[h]\n        \\centering\n        \\includegraphics[scale=0.7]{scatter_father_son_height.png}\n        \\caption{\\lstinline{y} vs. \\lstinline{x}}\n        \\label{fig:father_son}\n    \\end{figure}\n    \n    \\item Based on your intuition and without fitting a model, draw the line corresponding to the linear regression for this data.\n    \n    See Figure \\ref{fig:father_son}.\n    \n    \\item Fit a linear regression in Python where the response variable is \n    \\lstinline{y}. Draw the line corresponding to the fitted linear regression in the\n    scatter plot. Does this line match your intuition from the previous part?\n    \n    The line corresponding to the fitter linear regression does not match the line I\n    plotted based on my intuition. See Figure \\ref{fig:father_son} above.\n    %TODO: add equation for the line of best fit\n    \n    \\item Based on the fitted regression line, if a father is 10 inches taller than\n    the average, how much greater is the expected height of the son compared to the\n    average? And if a father is 10 inches shorter than the average, how much smaller\n    is the expected height of the son compared to the average?\n    \n    If a father is 10 inches taller than the average, the expected height of the son\n    is 5.14 inches taller than the average. Conversely, if a father is 10 inches\n    shorter than average, the expected height of the son is 5.14 inches shorter\n    than average.\n    \n    \\item Based on the answer to the previous part, do you think it is fair to say\n    that heights become more and more ``average'' over time? Read about ``regression \n    to the mean'' and revisit your answer.\n    \n    If we didn't take the regression error into consideration, the results from the\n    previous part would lead us to believe that the heights do become more ``average''\n    over generations. However, this is a naive interpretation that ignores the fact\n    that the actual $y_i$ values will not be exactly where the model predicts them to \n    be. Some of them will be closer to the mean, while other will be further from it.\n    In other words, we when take the error in the regression predicting $y$ from $x$,\n    this interpretation is incorrect.\n    \n    \\begin{lstlisting}[language=Python, caption=Standard Error and Confidence\n    Interval for $T$]\nimport pandas as pd\nfrom google.colab import drive\nimport matplotlib.pyplot as plt\nfrom sklearn.linear_model import LinearRegression\n\n# Mount drive\ndrive.mount('/content/drive')\ndf = pd.read_csv('/content/drive/My Drive/father_son.txt', delim_whitespace=True)\n\n# Standardize the two covariates\ndef standardize_feature(feature):\n  return (feature - np.mean(feature)) / np.std(feature)\n\nx = standardize_feature(df['Father'])\ny = standardize_feature(df['Son'])\n\n# Part (a): plot y vs. x\nfig, ax = plt.subplots()\nax.scatter(x, y)\n\n# Part (b): plot intuition line of best fit (y=x)\nx_int = np.linspace(-3,3)\ny_int = x_int\nax.plot(x_int, y_int, linestyle='dashed', color='C1')\n\n# Part (c): fit a linear regression\nx = x.values.reshape(-1, 1)\ny = y.values.reshape(-1,1)\nmodel = LinearRegression()\nmodel.fit(x,y)\ny_hat = model.predict(x)\nax.plot(x, y_hat, linestyle='dashed', color='C2')\nax.legend(['Intuition line of best fit', 'Line of best fit'])\n\n# Part (d)\n# Father 10 in taller than the average\nx_father = df['Father'].mean() + 10\n\n# Transform the value to match the scale of the model fit\nx_father = (x_father - df['Father'].mean()) / df['Father'].std()\nx_father = np.array([x_father])\n\n# Son height for x_father\ny_hat_son = model.predict(x_father.reshape(-1,1))\ny_hat_son = y_hat_son[0][0] * df['Son'].std() + df['Son'].mean()\nprint(f\"The son is {y_hat_son - df['Son'].mean()} inches taller than the average\")\n\n# Part (e)\n# What if the father is 10 in shorter than the average?\nx_father_2 = df['Father'].mean() - 10\nx_father_2 = (x_father_2 - df['Father'].mean()) / df['Father'].std()\nx_father_2 = np.array([x_father_2]).reshape(-1,1)\n\ny_hat_son_2 = model.predict(x_father_2)\ny_hat_son_2 = y_hat_son_2[0][0] * df['Son'].std() + df['Son'].mean()\nprint(f\"The son is {np.abs(y_hat_son_2 - df['Son'].mean())} inches shorter than the average\")\n\\end{lstlisting}\n\\end{enumerate}\n\\pagebreak\n\n\\section{Linear Regression}\nIn this problem, we are going to see what happens if we use a linear regression to \nmodel the relationship between two independent random variables.\n\\begin{enumerate}[label={(\\alph*)}]\n    \\item Simulate 1000 data points from a normal distribution with mean 0 and standard\n    deviation 1. Assign it to a variable named $x$. Simulate another 1000 data points\n    from a similar normal distribution and assign them to variable $y$. Run a linear\n    regression of $y$ vs. $x$. Use \\texttt{statsmodels} to view the statistical\n    properties of the model. What is the slope of the model? Report your observations.\n    \n    I generated $y$ drawing samples from a normal distribution $N(0,1)$. The linear regression results from fitting $y$ vs. $x$ with \\texttt{statsmodels} are shown below:\n    \\begin{figure}[h]\n        \\centering\n        \\includegraphics[scale=0.5]{ols_res.png}\n        \\caption{OLS Regression Results with \\texttt{statsmodels}.}\n        \\label{fig:ols_res}\n    \\end{figure}\n    \n    As shown in Figure \\ref{fig:ols_res}, the slope of the fitted line is -0.0309.\n    \n    \\item Repeat the simulation in the previous part 100 times and gather the\n    slopes in a list. Draw the distribution, and report your conclusions based\n    on the result.\n    \\begin{figure}[h]\n        \\centering\n        \\includegraphics[scale=0.5]{slopes_dist.png}\n        \\caption{Distribution of slope values}\n        \\label{fig:slopes}\n    \\end{figure}\n    \n    The distribution for the slope values is centered around ~0 and has a standard\n    deviation of 0.03. The slope reported by the linear regression model is roughly \n    within one standard deviation of the distribution of the slope values found by \n    running several simulations.\n\\begin{lstlisting}[language=Python, caption=Standard Error and Confidence]\nimport numpy as np\nimport statsmodels.api as sm\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nnp.random.seed(0)\n\n# Simulate 1000 data points from a normal distribution with a mean 0 and std 1\nx = np.random.normal(0,1,1000)\ny = np.random.normal(0,1,1000)\n\n# Fit the model\nx_with_intercept = sm.add_constant(x)\nmodel = sm.OLS(y, x_with_intercept).fit()\ny_hat = model.predict(x_with_intercept)\n\n# Print the results\nprint(model.summary())\n\n# Repeat the simulation 100 times\nslopes = []\nfor i in range(100):\n  x = np.random.normal(0,1,1000)\n  y = np.random.normal(0,1,1000)\n  x_with_intercept = sm.add_constant(x)\n  model = sm.OLS(y, x_with_intercept).fit()\n  slopes.append(model.params[1])\n\n# Get the mean and std dev of the distribution\nslope_std = np.std(slopes)\nslope_mean = np.mean(slopes)\nprint(f\"Slope std: {slope_std}\")\nprint(f\"Slope mean: {slope_mean}\")\n\n# Plot the distribution\nplt.hist(slopes, ec='azure')\nplt.title('Distribution of slope values')\nplt.xlabel('OLS regression slope')\nplt.ylabel('Count')\nplt.savefig('/content/drive/My Drive/slopes_dist.png', dpi=300)\n\\end{lstlisting}\n    \n\\end{enumerate}\n\\pagebreak\n\n\\section{Linear Regression Properties}\n\\begin{enumerate}[label={(\\alph*)}]\n    \\item Assume we have fitted a linear regression model with an intercept to our \n    data. Prove that the sum of residuals in the fitted model is equal to zero:\n    \\[\n        \\sum_{i=0}^n \\hat{\\varepsilon_i} = 0\n    \\]\n    Proof:\n    \\begin{align*}\n        \\sum_{i=0}^n \\hat{\\varepsilon_i} &= \n        \\sum_{i=0}^n (Y_i - \\widehat{Y_i}) \\\\\n        &= Y - X(X^TX)^{-1}X^TY \\\\\n        &= Y - X X^{-1} (X^T)^{-1}  X^T Y \\\\\n        &= Y - I I Y \\\\\n        &= Y - Y = 0\n    \\end{align*}\n    \n    \\item We can write the equation for a linear regression model fitted to a dataset \n    with $p$ features and $n$ data points as\n    \\[\n        Y_i = \\hat{\\beta}_0 + \\sum_{j=1}^p \\hat{\\beta}_j X_{i,j} + \\hat{\\varepsilon_i}\n    \\]\n    where $X_{i,j}$ is the value of $j$-th feature for $i$-th data point and $Y_i$ is\n    the response variable for the $i$-th data point. Assume we have \n    \\emph{centered features} in our data, meaning\n    \\[\n        \\dfrac{1}{n} \\sum_{i=1}^n X_{i,j} = 0\n    \\]\n    prove that the value of the intercept in the fitted model is equal to the\n    average of the response variable in our data:\n    \\[\n        \\hat{\\beta_0} = \\dfrac{1}{n} \\sum_{i=1}^n Y_i\n    \\]\n    Proof:\n    \\begin{align*}\n        \\hat{\\beta_0} &= \\dfrac{1}{n} \\sum_{i=1}^n Y_i \\\\\n        &= \\dfrac{1}{n} \\sum_{i=1}^n (\\hat{\\beta_0} + \\sum_{j=1}^p \\hat{\\beta_j}\n        X_{i,j} + \\hat{\\varepsilon_i}) \\\\\n        &= \\dfrac{1}{n} \\left(n\\hat{\\beta_0} + \\sum_{i=1}^n \\sum_{j=1}^p \\hat{\\beta_j}\n        X_{i,j} + \\sum_{i=1}^n\\hat{\\varepsilon_i} \\right) \\\\\n        &= \\hat{\\beta_0} + \\sum_{j=1}^p \\hat{\\beta_j} \\left(\\dfrac{1}{n}\n        \\sum_{i=1}^n X_{i,j}\\right) \\\\\n        &= \\hat{\\beta_0}\n    \\end{align*}\n\\end{enumerate}\n\n%\\bibliographystyle{plain}\n%\\bibliography{references}\n\\end{document}\n", "meta": {"hexsha": "2436b7ff1cd86c016e52bd4e95be9e4aede890f5", "size": 13924, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw/hw2/hw2.tex", "max_stars_repo_name": "cmunozcortes/cs249", "max_stars_repo_head_hexsha": "1648339d10238c6a9baa261ee7a367607e6385a2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw/hw2/hw2.tex", "max_issues_repo_name": "cmunozcortes/cs249", "max_issues_repo_head_hexsha": "1648339d10238c6a9baa261ee7a367607e6385a2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw/hw2/hw2.tex", "max_forks_repo_name": "cmunozcortes/cs249", "max_forks_repo_head_hexsha": "1648339d10238c6a9baa261ee7a367607e6385a2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.4301075269, "max_line_length": 170, "alphanum_fraction": 0.6850043091, "num_tokens": 4121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.4268682198569925}}
{"text": "%\n\\section{Introduction}%\n%\n\\begin{frame}[t]%\n\\frametitle{Optimization Algorithms}%\n\\begin{itemize}%\n\\item Many questions in the real world are actually optimization problems\\only<2->{, e.g.,\n\\begin{itemize}%\n%\n\\item \\only<-6>{Find the \\emph{shortest} tour for a salesman to visit certain set of cities\\only<-2>{ in China and return to Hefei!}}\\only<7->{\\alert<7>{Traveling Salesman Problem}\\scitep{ABCC2006TTSPACS,LLKS1985TTSPAGTOCO,GP2004TTSPAIV,L2011SGEFTSPIMSS}}%\n%\n\\item<3-> \\only<-6>{I need to transport $n$ items from here to Feixi\\only<-3>{ but they are too big to transport them all at once. How can I load them best into my car so that I have to travel back and forth the least times?}}\\only<7->{\\alert<7>{Bin Packing Problem}\\scitep{KSH1995EHFTBPP}}%\n%\n\\item<4-> \\only<-6>{Which setting of $x_1$, $x_2$, $x_3$, and $x_4$ can make $(x_1\\lor\\lnot x_2 \\lor x_3)\\land(\\lnot x_2\\lor\\lnot x_3 \\lor x_4) \\land (\\lnot x_1\\lor\\lnot x_3 \\lor \\lnot x_4)$ become true\\only<-4>{ (or, at least, as \\emph{many} of its terms as possible)?}}\\only<7->{\\alert<7>{Maximum (3-)Satisfiability Problem}\\scitep{HS2000SAORFROS,TH2004UAIAEEFSAFSAMS,S1978TCOSP,RMK2000EASP}}%\n%\n\\item<5-> \\only<-6>{I want to build a large factory with $n$ workshops.\\only<-5>{ I know the flow of material between each two workshops and now need to choose the locations of the workshops such that the overall running cost incurred by material transportation is \\emph{minimized}.}}\\only<7->{\\alert<7>{Quadratic Assignment Problem}\\scitep{MF1999ACOMATSAACFTQAP,GTD1999ACOQAP}}%\n\\end{itemize}%\n}%\n%\n\\item<6-> Many optimization problems are \\alert<7>{\\NPHard}, meaning that finding the best possible solution will usually not be possible in feasible time.%\n%\n\\item<8-> We use metaheuristic optimization algorithms to give us good approximate solutions within acceptable runtime.%\n%\n\\item<9-> Examples of such algorithms are\\only<-19>{ %\nEvolutionary Algorithms\\scitep{BFM1997EA,CWM2011VOEAFRWA,BFM2000EC1BAAO,BFM2000EC2BAAO,DLJD2000EC,EM1999EC,CDGDMPP1999NIIO,GT2002AIECTAA,WGOEB}\\uncover<10->{, %\nAnt Colony Optimization\\scitep{DMC1996ACO,DS2004ACO,GM2002APBATDOP,ZBMD2004MBSFCOACS,WGOEB}\\uncover<11->{, %\nEvolution Strategies\\scitep{R1965ES,R1973ES,R1994ES,S1965KYASDEFIDS,S1968EOEZDT1,S1975EUNO,WGOEB}\\uncover<12->{, %\nDifferential Evolution\\scitep{WGOEB}\\uncover<13->{, %\nParticle Swarm Optimization\\scitep{WGOEB}\\uncover<14->{, %\nEstimation of Distribution Algorithms\\scitep{PSL2005DE,F2006DE,MMVRCC2006DE,BZSM2006DE,LZ2000DE,MM2005DE,BVPK2006DE,S2010DEFCFOAABKPARS}\\uncover<15->{, %\nCMA-ES\\scitep{HOG1995ESAD,HO1996AANMDIESTCMA,HO2001ESCMA,HMK2003RTTCOTDESWCMACE,HK2004ETCESOMTF,H2006TCESACR,AH2005ARCESWIPS,AH2005PEOAALSEA}\\uncover<16->{, and %\nLocal Search methods\\scitep{HS2005SLSFAA,AL1997LSICO,DBSD2001DOILSA}\\uncover<17->{ such as %\nSimulated Annealing\\scitep{SSF2002FCAIFSA,LA1987SATAA,B1987GAASA,JCS2003HC,KGV1983SA,VC1985SA,DPSW1982MCTICO,DPSW1982MCTICO2,P1970AMCMFTASOCTOCOP,WGOEB}\\uncover<18->{ or %\nTabu Search\\scitep{G1989TSPI,G1990TSPII,GL1993TABU,DWH1989TSTATAAATNN,BT1994TABU}\\uncover<19->{, %\nas well as hybrids of local and global search, such as Memetic Algorithms\\scitep{M1989MA,M2002MA,MC2003AGITMA,ES2003HWOTMA,HKS2005RAIMA,DM2004MA,RS1994FMA}%\n}}}}}}}}}}}\\only<20->{\\dots\\ many}%\n%\n\\item<20-> \\alert<20>{Which of them is best (for my problem)?}%\n\\item<21-> \\alert<21>{How can I make a good algorithm better (for my problem)?}%\n%\n\\end{itemize}%\n%\n\\locate{2}{\\includegraphics[width=0.6\\paperwidth]{\\sharedPath/graphics/optimization/tsp/tsp_example/tsp_example}}{0.2}{0.29}%\n\\locate{3}{\\includegraphics[width=0.875\\paperwidth]{\\sharedPath/graphics/optimization/bin_packing/bin_packing_example/bin_packing_example}}{0.0625}{0.495}%\n\\locate{4}{\\includegraphics[width=0.55\\paperwidth]{\\sharedPath/graphics/optimization/sat/sat_example/sat_example}}{0.225}{0.5}%\n\\locate{5}{\\includegraphics[width=0.85\\paperwidth]{\\sharedPath/graphics/optimization/qap/qap_example/qap_example}}{0.075}{0.625}%\n\\locate{6-7}{\\includegraphics[width=0.78\\paperwidth]{\\sharedPath/graphics/complexity/exponential_functions/exponential_functions}}{0.09}{0.55}%\n%\n\\end{frame}%\n%\n\\begin{frame}[t]%\n\\frametitle{Algorithm Analysis and Comparison}%\n\\begin{itemize}%\n\\item \\alert{Which of the algorithms is best (for my problem)?}%\n\\item<2-> Traditional Approach {\\`{a}} la \\emph{\\inQuotes{QuickSort is better than Bubble Sort because it needs \\bigOOf{n \\log n} while Bubble Sort needs \\bigOOf{n^2} steps to sort $n$ elements in the average case.}}%\n%\n\\item<3-> Complexity Analysis, Theoretical Bounds of Runtime and Solution Quality%\n\\item<4-> \\alert<-9>{Usually not feasible}\\uncover<5->{%\n\\begin{itemize}%\n\\item analysis extremely complicated\\uncover<6->{ since%\n\\item<6-> algorithms are usually randomized\\uncover<7->{ and%\n\\item<7-> have many parameters (e.g., crossover rate, population size)\\uncover<8->{ and%\n\\item<8-> \\inQuotes{sub-algorithms} (e.g., crossover operator, mutation operator, selection algorithm)%\n\\item<9-> optimization problems also differ in many aspects%\n\\item<10-> theoretical results only available for toy problems and extremely simplified algorithms.%\n\\item<11-> \\alert<10>{Currently, not mature enough to be an easy-to-use tool for practitioners}%\n}}}%\n\\end{itemize}%\n}%\n%\n\\item<12-> \\alert{Experimental analysis and comparison only practical alternative.}%\n%\n\\end{itemize}%\n\\end{frame}%\n%\n%\n%\n\\begin{frame}%\n\\frametitle{Performance and Anytime Algorithms}%\n%\n\\emph{\\inQuotes{We use metaheuristic optimization algorithms to give us \\alert<3->{good approximate solutions} within \\alert<4->{acceptable runtime}.}}%\n%\n\\uncover<2->{%\n\\begin{itemize}%\n\\item Algorithm performance has two dimensions\\scitep{NAFR2010RPBBOB2ES,WCTLTCMY2014BOAAOSFFTTSP}:\\uncover<3->{ solution quality\\uncover<4->{ and required runtime}}%\n\\item<5-> Anytime Algorithms\\scitep{BD1989STDPP2} are optimization methods which maintain an approximate solution at \\emph{any time} during their run and iteratively improve this guess.%\n\\item<6-> All metaheuristics are Anytime Algorithms.%\n\\item<7-> Several exact methods like Branch-and-Bound\\scitep{LMSK1963AAFTTSP,Z1993TBABACSOTATSP,Z1999TAADFBABACSOTATSP} are Anytime Algorithms.%\n\\item<8-> Consequence: Most optimization algorithms produce approximate solutions of different qualities at different points during their process.%\n\\item<9-> Experiments must capture solution quality and runtime data.%\n\\end{itemize}%\n}%\n%\n\\locate{3}{\\includegraphics[width=0.55\\paperwidth]{\\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions_1}}{0.225}{0.542}%\n\\locate{4}{\\includegraphics[width=0.55\\paperwidth]{\\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions_2}}{0.225}{0.542}%\n\\locate{5}{\\includegraphics[width=0.55\\paperwidth]{\\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions}}{0.225}{0.542}%\n%\n\\end{frame}%\n%\n\\begin{frame}[t]%\n\\frametitle{Experimental Procedure}%\n\\begin{itemize}%\n\\item In optimization or Machine Learning, the following experimental procedure is often used\\uncover<2->{%\n\\begin{enumerate}%\n\\item Select a \\only<3->{\\alert<3>{set of }}benchmark instance\\only<3->{\\alert<3>{s}}\\only<3-7>{:%\n\\begin{itemize}%\n\\item multiple instances%\n\\item<4-> which cover some different problem features%\n\\item<5-> should be well-known to make results comparable%\n\\only<-6>{%\n\\item<6-> e.g., \\tspLib\\expandafter\\scitep{\\tspLibReferences} for the TSP has instances with different numbers of cities and geometries%\n}%\n\\only<-7>{%\n\\item<7-> e.g., \\bbob\\expandafter\\scitep{\\bbobReferences} offers different benchmark functions for numerical optimization problems%\n}%\n\\end{itemize}%\n}%\n\\item<8-> Do experiment\\only<12->{\\alert<12-13>{s}}\\only<9-13>{:%\n\\begin{itemize}%\n\\item conduct several independent runs of algorithm for each benchmark instance%\n\\item<10-> collect algorithm progress informatio, e.g., as \\emph{\\inQuotes{runtime bestObjectiveValue}} tuples%\n\\item<11-> one log file per run, each log file has several such tuples%\n\\item<12-> repeat for different algorithm parameter settings (e.g., different population sizes of an EA)%\n\\item<13-> repeat with other algorithms for comparison purposes%\n\\end{itemize}%\n}%\n\\item<14-> Evaluate the gathered data\\only<15->{:\\alert<22>{%\n\\begin{itemize}%\n\\item draw diagrams of progress of solution quality over time%\n\\item<16-> draw diagrams of advanced statistical parameters such as ECDF\\scitep{HAFR2012RPBBOBES,HS1998ELVAPAR,TH2004UAIAEEFSAFSAMS,WCTLTCMY2014BOAAOSFFTTSP}\\only<17->{ and ERT\\scitep{HAFR2012RPBBOBES,WCTLTCMY2014BOAAOSFFTTSP}} (over time)%\n\\item<18-> use statistical tests to compare results (at different points during the runs)%\n\\item<19-> analyze the impact of benchmark features and algorithm parameters on the above%\n\\end{itemize}%\n}}%\n%\n\\item<20-> Draw conclusions about algorithm performance and parameter settings%\n\\item<21-> But this is all \\emph{very} cumbersome, involves much work and much data\\dots\n\\end{enumerate}%\n}%\n\\item<22-> The \\optimizationBenchmarking\\ Evaluator can automatize much of this work%\n\\end{itemize}%\n%\n\\locateWithCaption{6}{%\n\\includegraphics[width=0.925\\paperwidth]{\\sharedPath/graphics/optimization/tsp/tspLib_features/tspLib_features_symmetric}%\n}{%\nThe relative amounts of the instances of the 110 symmetric instances of \\tspLib\\ according to their features (the 10 asymmetric instances are not plotted).%\n}{0.0375}{0.51}{0.925}%\n%\n\\locateWithCaption{7}{%\n\\pgfuseimage{bbob_features}%\n}{%\nThe relative amounts of \\bbob\\ benchmark functions according to their features.%\n}{0.0375}{0.51}{0.925}%\n%\n\\locateWithCaption{10}{%\n\\includegraphics[width=0.8\\paperwidth]{\\sharedPath/graphics/optimization/tsp/tspSuite_logfile_example/tspSuite_logfile_example}%\n}{%\nExample for data collected in a log file by \\tspSuite\\scitep{\\tspSuiteReferences}.%\n}{0.0375}{0.53}{0.925}%\n%\n\\locateWithCaption{15-17}{\n\\strut%\n\\includegraphics[width=0.28\\paperwidth]{\\sharedPath/graphics/optimization/performance/progress_example/progress_example}%\n\\uncover<16->{%\n\\strut\\hfill\\strut%\n\\includegraphics[width=0.28\\paperwidth]{\\sharedPath/graphics/optimization/performance/ecdf_example/ecdf_example}%\n\\uncover<17->{%\n\\strut\\hfill\\strut%\n\\includegraphics[width=0.28\\paperwidth]{\\sharedPath/graphics/optimization/performance/ert_example/ert_example}%\n}}\\strut%\n}{%\nExamples for progress\\only<16>{ and ERT}\\only<17->{, ERT, and ECDF} diagrams for different algorithms (signified by different colors) over different sub-sets of the \\tspLib\\ data.%\n}{0.0375}{0.525}{0.925}%\n%\n\\end{frame}%\n%\n%", "meta": {"hexsha": "c870daa5d9584fce06b202c09d69f9475aeb7f71", "size": 10571, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/evaluatorSlides/part_introduction.tex", "max_stars_repo_name": "optimizationBenchmarking/optimizationBenchmarkingDocu", "max_stars_repo_head_hexsha": "41ac5357f443db152765e4bc309d462aff613224", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documents/evaluatorSlides/part_introduction.tex", "max_issues_repo_name": "optimizationBenchmarking/optimizationBenchmarkingDocu", "max_issues_repo_head_hexsha": "41ac5357f443db152765e4bc309d462aff613224", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/evaluatorSlides/part_introduction.tex", "max_forks_repo_name": "optimizationBenchmarking/optimizationBenchmarkingDocu", "max_forks_repo_head_hexsha": "41ac5357f443db152765e4bc309d462aff613224", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.7231638418, "max_line_length": 395, "alphanum_fraction": 0.7736259578, "num_tokens": 3406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.42674595665236403}}
{"text": "\\section*{vEB - Peter Christensen}\n\n\\begin{enumerate}\n\t\\item Define the goal: To get algorithm with $O(\\log\\log u)$ runtime for universe of size U\n\t\\item A recursion tree that where the input shrinks $\\sqrt{u}$ and constant work in the leafs would give that.\n\t\\item Show an example of a bit vector tree, where the leafs are spint into cluster and the parent are the summart vector.\n\t\\item Define the structure vEb with a $u$, summary, cluster, min, max.\n\t\\item Go through an example of how the structure works, such as Figure~20.6.\n\t\\item go through insert and predecessor algorithm and explain how it works.\n\\end{enumerate}", "meta": {"hexsha": "8385ebcd2ca15ed3a26af44539dff811a30a65fc", "size": 624, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Uge3/PeterDisp-vEB.tex", "max_stars_repo_name": "pdebesc/AADS", "max_stars_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Uge3/PeterDisp-vEB.tex", "max_issues_repo_name": "pdebesc/AADS", "max_issues_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Uge3/PeterDisp-vEB.tex", "max_forks_repo_name": "pdebesc/AADS", "max_forks_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.4, "max_line_length": 122, "alphanum_fraction": 0.7580128205, "num_tokens": 162, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5813031051514762, "lm_q2_score": 0.7341195152660688, "lm_q1q2_score": 0.4267459537764623}}
{"text": "\\documentclass[../psets.tex]{subfiles}\n\n\\pagestyle{main}\n\\renewcommand{\\leftmark}{Problem Set \\thesection}\n\n\\begin{document}\n\n\n\n\n\\section{Mechanical Waves}\n\\begin{enumerate}[label={\\arabic*)}]\n    \\item \\marginnote{8/9:}\\textcite{bib:YoungFreedman}: Problem 15.9.\\par\n    Which of the following wave functions satisfies the wave equation?\n    \\begin{enumerate}\n        \\item $y(x,t)=A\\cos(kx+\\omega t)$.\n        \\item $y(x,t)=A\\sin(kx+\\omega t)$.\n        \\item $y(x,t)=A(\\cos kx+\\cos\\omega t)$.\n        \\item For the wave of part (b), write the equations for the transverse velocity and transverse acceleration of a particle at point $x$.\n    \\end{enumerate}\n    \\item \\textcite{bib:YoungFreedman}: Problem 15.26.\\par\n    A fellow student with a mathematical bent tells you that the wave function of a traveling wave on a thin rope is $y(x,t)=(\\SI{2.30}{\\milli\\meter})\\cos[(\\SI{6.98}{\\radian\\per\\meter})x+(\\SI{742}{\\radian\\per\\second})t]$. Being more practical, you measure the rope to have a length of $\\SI{1.35}{\\meter}$ and a mass of $\\SI{0.00338}{\\kilo\\gram}$. You are then asked to determine:\n    \\begin{enumerate}\n        \\item Amplitude.\n        \\item Frequency.\n        \\item Wavelength.\n        \\item Wave speed.\n        \\item Direction the wave is traveling.\n        \\item Tension in the rope.\n        \\item Average power transmitted by the wave.\n    \\end{enumerate}\n    \\item \\textcite{bib:YoungFreedman}: Problem 15.30.\\par\n    \\textbf{Interference of Triangular Pulses.} Two triangular wave pulses are traveling toward each other on a stretched string as shown below. Each pulse is identical to the other and travels at $\\SI{2.00}{\\centi\\meter\\per\\second}$. The leading edges of the pulses are $\\SI{1.00}{\\centi\\meter}$ apart at $t=0$. Sketch the shape of the string at $t=\\SI{0.250}{\\second}$, $t=\\SI{0.500}{\\second}$, $t=\\SI{0.750}{\\second}$, $t=\\SI{1.000}{\\second}$, and $t=\\SI{1.250}{\\second}$.\n    \\begin{center}\n        \\begin{tikzpicture}[scale=1.2]\n            \\footnotesize\n            \\draw [orx,very thick] (0,0)\n                -- (1,0)\n                -- (2,1)\n                -- (3,0)\n                -- (4,0)\n                -- (5,1)\n                -- (6,0)\n                -- (7,0)\n            ;\n    \n            \\draw [very thin,|-|] (0.85,0.05) -- node[left]{$\\SI{1.00}{\\centi\\meter}$} ++(0,0.95);\n            \\draw [very thin,|-|] (1,-0.15) -- node[below]{$\\SI{1.00}{\\centi\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (2,-0.15) -- node[below]{$\\SI{1.00}{\\centi\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (3,0.3) -- node[above]{$\\SI{1.00}{\\centi\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (4,-0.15) -- node[below]{$\\SI{1.00}{\\centi\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (5,-0.15) -- node[below]{$\\SI{1.00}{\\centi\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (6.15,0.05) -- node[right]{$\\SI{1.00}{\\centi\\meter}$} ++(0,0.95);\n    \n            \\draw [grx,ultra thick,-latex] (2,1.1) -- node[above=1mm,black]{$v=\\SI{2.00}{\\centi\\meter\\per\\second}$} ++(1,0);\n            \\draw [grx,ultra thick,-latex] (5,1.1) -- node[above=1mm,black]{$v=\\SI{2.00}{\\centi\\meter\\per\\second}$} ++(-1,0);\n        \\end{tikzpicture}\n    \\end{center}\n    \\item \\textcite{bib:YoungFreedman}: Problem 15.32.\\par\n    \\textbf{Interference of Rectangular Pulses.} The below figure shows two rectangular wave pulses on a stretched string traveling toward each other. Each pulse is traveling with a speed of $\\SI{1.00}{\\milli\\meter\\per\\second}$ and has the height and width shown in the figure. If the leading edges of the pulses are $\\SI{8.00}{\\milli\\meter}$ apart at $t=0$, sketch the shape of the string at $t=\\SI{4.00}{\\second}$, $t=\\SI{6.00}{\\second}$, and $t=\\SI{10.0}{\\second}$.\n    \\begin{center}\n        \\begin{tikzpicture}[scale=1.2]\n            \\footnotesize\n            \\draw [orx!60!black,line join=round,double=orx,double distance=1.2pt] (0,0)\n                -- (1,0)\n                -- (1,0.75)\n                -- (2,0.75)\n                -- (2,0)\n                -- (4,0)\n                -- (4,-1)\n                -- (5,-1)\n                -- (5,0)\n                -- (6,0)\n            ;\n    \n            \\draw [very thin,|-|] (0.5,0.05) -- node[xshift=-0.05cm,fill=white,inner sep=2pt]{$\\SI{3.00}{\\milli\\meter}$} ++(0,0.7);\n            \\draw [very thin,|-|] (1,0.9) -- node[above]{$\\SI{4.00}{\\milli\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (2,-0.15) -- node[below]{$\\SI{8.00}{\\milli\\meter}$} ++(1.95,0);\n            \\draw [very thin,|-|] (4,-1.15) -- node[below]{$\\SI{4.00}{\\milli\\meter}$} ++(1,0);\n            \\draw [very thin,|-|] (5.5,-0.05) -- node[xshift=0.05cm,fill=white,inner sep=2pt]{$\\SI{4.00}{\\milli\\meter}$} ++(0,-0.95);\n    \n            \\draw [grx,ultra thick,-latex] (2.1,0.4) -- ++(0.5,0) node[right,black]{$v=\\SI{1.00}{\\milli\\meter\\per\\second}$};\n            \\draw [grx,ultra thick,-latex] (3.9,-0.75) -- ++(-0.5,0) node[left,black]{$v=\\SI{1.00}{\\milli\\meter\\per\\second}$};\n        \\end{tikzpicture}\n    \\end{center}\n    \\item \\textcite{bib:YoungFreedman}: Problem 15.34.\\par\n    Adjacent antinodes of a standing wave on a string are $\\SI{15.0}{\\centi\\meter}$ apart. A particle at an antinode oscillates in simple harmonic motion with amplitude $\\SI{0.850}{\\centi\\meter}$ and period $\\SI{0.0750}{\\second}$. The string lies along the $+x$-axis and is fixed at $x=0$.\n    \\begin{enumerate}\n        \\item How far apart are the adjacent nodes?\n        \\item What are the wavelength, amplitude, and speed of the two traveling waves that form this pattern?\n        \\item Find the maximum and minimum transverse speeds of a point at an antinode.\n        \\item What is the shortest distance along the string between a node and an antinode?\n    \\end{enumerate}\n    \\item \\textcite{bib:YoungFreedman}: Problem 15.64.\\par\n    A strong string of mass $\\SI{3.00}{\\gram}$ and length $\\SI{2.20}{\\meter}$ is tied to supports at each end and is vibrating in its fundamental mode. The maximum transverse speed of a point at the middle of the string is $\\SI{9.00}{\\meter\\per\\second}$. The tension in the string is $\\SI{330}{\\newton}$.\n    \\begin{enumerate}\n        \\item What is the amplitude of the standing wave at its antinode?\n        \\item What is the magnitude of the maximum transverse acceleration of a point at the antinode?\n    \\end{enumerate}\n    \\item A harmonic wave travels down a string in the $+x$ direction. At position $x=0$ and time $t=0$, the following is observed: the displacement of the string is $+\\SI{1.0}{\\centi\\meter}$, the transverse velocity is $-\\SI{2.0}{\\centi\\meter\\per\\second}$, and the transverse acceleration is $-\\SI{4.0}{\\centi\\meter\\per\\square\\second}$.\n    \\begin{enumerate}\n        \\item What is the frequency of the wave?\n        \\item What is the amplitude of the wave?\n    \\end{enumerate}\n    \\item A long, uniform rope of length $L$ hangs vertically. The only tension in the rope is that produced by its own weight.\n    \\begin{enumerate}\n        \\item Show that, as a function of the distance $y$ from the lower end of the rope, the speed of a transverse wave pulse on the rope is $\\sqrt{gy}$.\n        \\item How much time does it take for a wave pulse to travel from one end of the rope to the other?\n    \\end{enumerate}\n    \\item Using continuity conditions on a string, we derived the relative amplitudes for transmitted and reflected waves at a boundary. Show that the average power of the \\emph{transmitted} wave plus the average power of the \\emph{reflected} wave is equal to the average power of the \\emph{incident} wave. (Otherwise, energy would not be conserved.)\n\\end{enumerate}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "d49d7d3cf1be4aeea4fe7ccce36f870d163da9e2", "size": 7620, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PSets/PSet1/pset1.tex", "max_stars_repo_name": "shadypuck/PHYS13300Notes", "max_stars_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PSets/PSet1/pset1.tex", "max_issues_repo_name": "shadypuck/PHYS13300Notes", "max_issues_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PSets/PSet1/pset1.tex", "max_forks_repo_name": "shadypuck/PHYS13300Notes", "max_forks_repo_head_hexsha": "61c7dcb457b6ce79feba5d9a46e991c88cdcde68", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.6896551724, "max_line_length": 475, "alphanum_fraction": 0.6072178478, "num_tokens": 2491, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.42674595327089077}}
{"text": "\\chapter{Seamless modeling of retarded vdW interactions}\\label{chap:casimir}\n\n{\\sffamily\\mathversion{sans} This chapter briefly discusses the extension of the MBD method to distances at which the finite speed of light cannot be neglected, resulting in the so-called retarded vdW (Casimir) interactions.\nPreviously, microscopic models of vdW interactions such as MBD were restricted to the non-retarded regime, whereas the macroscopic continuous models used for description of Casimir interactions could not be used at short distances and must have been parametrized from experimental data.\nHere, we show that these two descriptions can be unified within a single framework, which then enables seamless calculation of vdW energies both at the non-retarded and retarded (Casimir) regimes.\nThis unification also extends the applicability of the new developments in Chapter~\\ref{chap:polarizability}, because any improvements in a model of material response can be directly used in the study of Casimir physics.\nThe results discussed in this chapter have been published in \\citep*{VenkataramPRL17}.\nThe Maxwell-equation scattering calculations were done by Prashanth Venkataram, the DFT and polarizability screening calculations by myself, and the unified theoretical framework is a result of joint work.\n}\\vspace{1em}\n\nThe ACFD formula and hence the MBD correlation energy in~\\eqref{eq:mbd-rpa} originate from the nonrelativistic quantum mechanics, which assumes that the electromagnetic forces in the form of the Coulomb law acts instantly over any distance.\nThis limits the applicability of MBD to systems that are separated by less than hundreds of angstroms, at which point the time it takes for light to travel between the interacting objects becomes comparable to the frequency of the electronic oscillations that drive the vdW interactions.\n(The speed of light, $c$, in atomic units is approximately 137, the inverse of the fine-structure constant.)\nThe well-known effect of this retardation of the electromagnetic force is the asymptotic $1/R^7$ attraction that replaces the nonrelativistic $1/R^6$ power law.\n\nThe extension of MBD to account for this retardation consists of two steps.\nFirst, the instantaneous dipole operator (eq.~\\ref{eq:dipole-op}) is replaced with its frequency-dependent retarded version, which is proportional to the Green's function, $\\boldsymbol G_0$, of the electric field,\n\\begin{equation}\n  \\tilde{\\mathbf T}(\\mathbf R,u)=\\frac{4\\pi u^2}{c^2}\\boldsymbol G_0=\\big(\\boldsymbol\\nabla\\otimes\\boldsymbol\\nabla'-\\tfrac{u^2}{c^2}\\mathbf I\\big)\\mathrm e^{-|\\mathbf r-\\mathbf r'|u/c}v(|\\mathbf r-\\mathbf r'|)\\Big|_{\\substack{\\mathbf r=\\mathbf R\\\\\\mathbf r'=\\mathbf 0}}\n  \\label{eq:green-maxwell}\n\\end{equation}\nThis substitution prevents one to perform the analytic integration over frequencies analytically (see eq.~\\ref{eq:mbd-rpa}), but otherwise it is a straightforward modification of the MBD method.\n\nThe second step is necessary only because of the kind of systems that we want to study.\nThe prototypical systems studied in the context of Casimir interactions consist of small microscopic bodies such as molecules, and macroscopic objects with nontrivial shapes or surface gratings~\\cite{RodriguezNP11,WoodsRMP16}.\nThe latter are typically large enough that microscopic description of individual atoms in them is unnecessary and, furthermore, such large atomic calculations would be unfeasible.\nAs an alternative, efficient approaches solve directly the continuous Maxwell equations either with scattering or finite-differencing methods~\\cite{RodriguezPRA07,RahiPRD09}.\nThis raises the issue of connecting the continuous and microscopic descriptions.\nIt turns out that such a connection is naturally enabled by the form of the MBD expression for the interaction energy.\nConsider the MBD interaction energy of two bodies, $A$ and $B$,\n\\begin{equation}\n\\begin{aligned}\nE_\\text{int}&=E_{AB}-E_{A}-E_{B} \\\\\n&=\\frac1{2\\pi}\\int_0^\\infty\\mathrm du\\operatorname{Tr}\\big(\\ln(1+(\\boldsymbol\\alpha_A+\\boldsymbol\\alpha_B)\\tilde{\\mathbf T})-\\ln(1+\\boldsymbol\\alpha_A\\tilde{\\mathbf T})-\\ln(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})\\big) \\\\\n&=\\frac1{2\\pi}\\int_0^\\infty\\mathrm du\\operatorname{Tr}\\big(\\ln((1+\\boldsymbol\\alpha_A\\tilde{\\mathbf T}+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})(1+\\boldsymbol\\alpha_A\\tilde{\\mathbf T})^{-1}(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})^{-1})\\big) \\\\\n&=\\frac1{2\\pi}\\int_0^\\infty\\mathrm du\\operatorname{Tr}\\big(\\ln((1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T}(1+\\boldsymbol\\alpha_A\\tilde{\\mathbf T})^{-1})(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})^{-1})\\big) \\\\\n&\\equiv\\frac1{2\\pi}\\int_0^\\infty\\mathrm du\\operatorname{Tr}\\big(\\ln((1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T}_A)(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})^{-1})\\big) \\\\\n&=\\frac1{2\\pi}\\int_0^\\infty\\mathrm du\\operatorname{Tr}\\big(\\ln(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T}_A)-\\ln(1+\\boldsymbol\\alpha_B\\tilde{\\mathbf T})\\big) \\\\\n&=E_B(\\tilde{\\mathbf T}_A)-E_B(\\tilde{\\mathbf T})\n\\end{aligned}\n\\label{eq:casimir-mbd}\n\\end{equation}\nHere, we defined $\\tilde{\\mathbf T}_A=\\tilde{\\mathbf T}(1+\\boldsymbol\\alpha_A\\tilde{\\mathbf T})^{-1}$, which is the retarded dipole operator screened by the electromagnetic response of the body $A$, and the interaction energy between $A$ and $B$ was recast as the difference in the total energy of $B$ calculated with the bare and screened dipole operators.\nThe definition of $\\tilde{\\mathbf T}_A$ has the form of a Dyson-like equation analogous to that for the interacting nonlocal polarizability, which points to two equivalent points of view on the ground-state system of bodies of matter interacting via the electromagnetic force---one as fluctuating polarizations of the electronic density propagated (in the Green's function sense) by the electromagnetic field, the other as fluctuations in the electromagnetic field propagated by the electronic response of the matter.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=10cm]{media/casimir.pdf}\n\\caption{\\textbf{Retardation effects in vdW interactions.}\nInteraction energies of a perpendicular (black) and parallel (red) carbyne wire, fullerene C$_{500}$, and a protein with a golden surface calculated with different models are plotted relative to the prediction of a pairwise approximation as a function of the vertical distance, $z$.\n$\\mathcal{E}$ is the full retarded MBD method (eq.~\\ref{eq:casimir-mbd}), $\\mathcal{E}_0$ is the nonrelativistic approximation ($c\\rightarrow\\infty$ in~\\eqref{eq:green-maxwell}), and $\\mathcal E_\\text{CP}$ is the so-called ``Casimir--Polder approximation'' which approximates the whole microscopic object with a single point.\nThe inset shows the local power-law asymptote for the plate--fullerene system.\n}\\label{fig:casimir}\n\\end{figure}\n\nUsing the formulation in~\\eqref{eq:casimir-mbd}, the MBD interaction energy of a macroscopic body (which can be also a collection of macroscopic bodies) and a set of microscopic objects can be calculated in the following way.\nFirst, one obtains the Green's function of the electric field in the presence of the macroscopic body by an efficient continuous macroscopic method.\nSecond, the screened retarded dipole operator is calculated from the Green's function using~\\eqref{eq:green-maxwell}.\nThird, the vdW interaction energy is calculated using the regular MBD method with the screened and bare dipole operators according to~\\eqref{eq:casimir-mbd}.\nFigure~\\ref{fig:casimir} illustrates the effects of the retardation on the interactions of several prototypical systems with a golden plate.\nThe full retarded MBD interaction energy calculated with~\\ref{eq:casimir-mbd} transitions between the nonrelativistic approximation (the regular MBD), which becomes exact at short distances, and the relativistic Casimir--Polder approximation, which models the microscopic objects as point objects, and becomes exact at large separations.\nIn this regard, this unified framework represents a new seamless approach to multi-scale modeling that enables accurate description of intermolecular interactions at a range spanning several orders of magnitude.\n", "meta": {"hexsha": "6bb57e2bd0f40caada0446c4bee5ddd928077482", "size": 8101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/casimir-interactions.tex", "max_stars_repo_name": "azag0/dissertation", "max_stars_repo_head_hexsha": "7b56b7fba557c58f624cb3ef88b1c91d5f72a765", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/casimir-interactions.tex", "max_issues_repo_name": "azag0/dissertation", "max_issues_repo_head_hexsha": "7b56b7fba557c58f624cb3ef88b1c91d5f72a765", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/casimir-interactions.tex", "max_forks_repo_name": "azag0/dissertation", "max_forks_repo_head_hexsha": "7b56b7fba557c58f624cb3ef88b1c91d5f72a765", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 128.5873015873, "max_line_length": 517, "alphanum_fraction": 0.7922478706, "num_tokens": 2060, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4267459498894175}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{December 4, 2013}\n\\maketitle\n\\section*{8.7}\napplication of laplace transform is what the section is about. we are only doing one application. L-R-C circuit\n\\begin{align*}\n  Q(t)&=\\text{charge}\\\\\n  Q'(t)&=\\frac{\\mathrm{d}Q(t)}{\\mathrm{d}t}=\\text{current}\\\\\n  L\\frac{\\mathrm{d}^2Q}{\\mathrm{d}t^2}+R\\frac{\\mathrm{d}Q}{\\mathrm{d}t}+\\frac{Q}{C}&=E(t)\\\\\n  Q(o)&=Q_0\\\\\n  \\frac{\\mathrm{d}Q}{\\mathrm{d}t}(0)&=I_0\\\\\n  C&=\\text{capacitor Faradey F}\\\\\n  L&=\\text{inductor Henry H}\\\\\n  R&=\\text{resistance Ohm \\omega}\\\\\n  E&=\\text{voltage Volts V}\n\\end{align*}\n\\subsection*{exercise 1}\nsuppose that we consider a circuit ith a capacitor C a resistor R and a voltage supply $E(t)=\\left\\{\\begin{aligned}100&,\\quad0\\leq t\\leq1\\\\0&,\\quad t\\geq 1\\end{aligned}\\right.$. If  $L=0$ find $Q(t)$ and $I(t)$ if $Q(0)=0$, $C=\\frac{1}{50}F$ and $R=50\\omega$\n\\begin{align*}\n  E(t)&=100-100U(t-1)\\\\\n  50\\frac{\\mathrm{d}Q}{\\mathrm{d}t}+50Q&=100-100U(t-1)\\\\\n  Q'+Q=2-2U(t-1) \\intertext{take laplace transform}\\\\\n  \\mathcal{L}\\{Q'\\}&=s\\mathcal{L}\\{Q\\}-Q(0)\\\\\n  s\\mathcal{L}\\{Q\\}-Q(0)+\\mathcal{L}\\{Q\\}&=\\frac{2}{s}-2\\frac{e^{-s}}{s}\\\\\n  \\mathcal{L}\\{Q\\}(s+1)&=2\\left(\\frac{1}{s}-\\frac{e^-s}{s}\\right)\\\\\n  \\mathcal{L}\\{Q\\}&=\\frac{2}{s(s+1)}-\\frac{2e^{-s}}{s(s+1)}\\\\\n  \\frac{2}{s(s+1)}&=\\frac{A}{s}+\\frac{B}{s+1}\\\\\n  2&=A(s+1)+Bs\\\\\n  A&=2,\\quad A+B=0\\\\\n  B&=-2\\\\\n  \\mathcal{L}\\{Q\\}&=(\\frac{2}{s}-\\frac{2}{s+1})-e^{-s}(\\frac{2}{s}-\\frac{2}{s+1})\\\\\n  Q(t)&=2-2e^{-t}-(2-2e^{1-t})U(t-1)\\intertext{case 1, $0<t<1$}\\\\\n  \\frac{\\mathrm{d}U}{\\mathrm{d}t}&=0\\\\\n  \\frac{\\mathrm{d}Q}{\\mathrm{d}t}&=2e^{-t}\\intertext{case 2, $t>1$}\\\\\n\\end{align*}\n\n\\section*{6.3 linear system}\n\\begin{align*}\n  2x+3y&=5\\\\\n  3x+9y&=6\\\\\n  Ax=b\\\\\n  A&=\\left(\\begin{array}{cc}2&3\\\\3&9\\end{array}\\right),X=\\left(\\begin{array}{c}x\\\\y\\end{array}\\right),b=\\left(\\begin{array}{c}5\\\\6\\end{array}\\right)\\\\\n  X&=A^{-1}b\n\\end{align*}\nconsider $y''+5y'+2y=\\cos t$ can you write this in system?\n\\begin{align*}\n  y'&=x\\\\\n  y''&=x'\\\\\n  y''&=-5y'-2y+\\cos t\\\\\n  &=-5x-2y+\\cos t\\\\\n  x'&=\\\\\n  y'&=\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "3352b43e0b8cdbfe34a0b0a27e485d09f4697554", "size": 2240, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "differential equations/diffeq-notes-2013-12-04.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "differential equations/diffeq-notes-2013-12-04.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "differential equations/diffeq-notes-2013-12-04.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0, "max_line_length": 258, "alphanum_fraction": 0.5866071429, "num_tokens": 1087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.4267025913635711}}
{"text": "% \\chapter{Reproduction of GCN}\n\n\\section{Graph Convolution Layer and GCN model}\n\nA neutral network based on graph convolution consists of layers of graph convolution and non-linear activation function. To reproduct the work of Kipf et al.\\cite{DBLP:journals/corr/KipfW16}, a neutral network is modeled by the forward function in Equation \\ref{forward-function-in-gcn}.\n\n\\begin{equation}\n    Z = f(X, A) = \\text{softmax} \\left(\\hat{A}\\cdot \\text{ReLU}\\left(\\hat{A}XW^{(0)}\\right)W(1)\\right)\n    \\label{forward-function-in-gcn}\n\\end{equation}\n\n\\section{Model Implement and Experiment}\n\nThe reproduced model is based on PyTorch package, which contains built-in neutral network model frameworks. The codes are attached in Appendix. \n\nTo regain the training result in the work of Kipf et al\\cite{DBLP:journals/corr/KipfW16}, the model implements the same hyperparameters, as shown in Table \\ref{hyperparam-gcn}.\n\n\\medskip\n\n\\begin{table}[H]\n    \\centering\n    \\small\n    \\begin{tabular}{cccccc}\n        \\hline\n        random seed & hidden units & dropout rate & learning rate & weight decay for L2 loss & epochs \\\\\n        24 & 16 & 0.5 & 0.01 & 5e-4 & 200 \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Hyperparameters in GCN Reproduction}\n    \\label{hyperparam-gcn}\n\\end{table}\n\n\\section{Comparison and Result}\n\nThe training is carried out on \\textbf{Cora} dataset\\cite{Sen_Namata_Bilgic_Getoor_Galligher_Eliassi-Rad_2008} in both reproducable random split measures. The result performance is calculated on the basis on 20 trainings, which \n\nThe original paper performance and comparison is shown in Table \\ref{result-comparison}.\n\n\\begin{table}[H]\n    \\centering\n    \\small\n    \\begin{tabular}{lll}\n        \\hline\n        model & Cora & Citeseer \\\\\n        \\hline\n        ManiReg\\cite{ManiReg} & 59.5 & 60.1 \\\\\n        SemiEmb\\cite{SemiEmb} & 59.0 & 59.6 \\\\\n        LP\\cite{LP} & 68.0 & 45.3 \\\\\n        DeepWalk\\cite{DeepWalk} & 67.2 & 43.2 \\\\\n        ICA\\cite{ICA} & 75.1 & 69.1 \\\\\n        Planetoid*\\cite{DBLP:journals/corr/YangCS16} & 75.7 & 64.7 \\\\\n        GCN (paper) & 81.5 & 70.3 \\\\\n        GCN (paper, rand splits) & 80.1$\\pm$0.5 & 67.9$\\pm$0.5 \\\\\n        \\hline\n        GCN (reproduced) & 82.5 & 73.1 \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Comparison of GCN and Other Model Performance}\n    \\label{result-comparison}\n\\end{table}\n\n\nThe results of reproduction generally matches the original performance. The reproduction appears to have slightly higher accuracy rate, which can be caused by sample shuffling and difference in train-valid-test ratio. The reproduction is in all satisfactory.\n", "meta": {"hexsha": "1919069f6d4b0472ab8531dff99bd773524de1d1", "size": 2609, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/chapters/chapter-2-reproduction-of-gcn.tex", "max_stars_repo_name": "primus2019/BDTA-Course-Project", "max_stars_repo_head_hexsha": "e455bb554d22319b4dbbcc2430970b890a67faaa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/chapters/chapter-2-reproduction-of-gcn.tex", "max_issues_repo_name": "primus2019/BDTA-Course-Project", "max_issues_repo_head_hexsha": "e455bb554d22319b4dbbcc2430970b890a67faaa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/chapters/chapter-2-reproduction-of-gcn.tex", "max_forks_repo_name": "primus2019/BDTA-Course-Project", "max_forks_repo_head_hexsha": "e455bb554d22319b4dbbcc2430970b890a67faaa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.765625, "max_line_length": 287, "alphanum_fraction": 0.690302798, "num_tokens": 783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.42670258833722263}}
{"text": "\\chapter{Object Definition}\n\nObjects in {\\rayshade} are composed of relatively simple {\\em primitive}\nobjects.  These primitives may be used by themselves, or they\nmay be combined to form more complex objects known as {\\em aggregates}.\nA special family of aggregate objects,\n{\\em Constructive Solid Geometry} or CSG\nobjects, are the result of a boolean operations applied to\nprimitive, aggregate, or CSG objects.\n\nThis chapter describes objects from a strictly geometric point of\nview.  Later chapters on surfaces, textures, and shading describe\nhow object appearances are defined.\n\nAn {\\em instance} is an object that has optionally been transformed\nand\ntextured.  They are the entities that are actually rendered by\n{\\rayshade}; when you specify that, for example, a textured\nsphere is to be rendered, you are said to be instantiating\nthe textured sphere.\nAn instance\nis specified as a primitive, aggregate, or CSG object that\nis followed by optional transformation and texturing information.\nTransformations and textures are described in Chapters 7 and 8 respectively.\n\n\\section{The World Object}\n\nWriting a {\\rayshade} input file is principally\na matter of defining a special aggregate object, the World object,\nwhich is a list of the objects in the scene.  When writing a {\\rayshade}\ninput file, all objects that are instantiated outside of object-definition\nblocks are added to the World object; you need not (nor should you)\ndefine the World object explicitly in the input file.\n\n\\section{Primitives}\n\nPrimitive objects are the building box with which other objects are\ncreated.  Each primitive type has associated with it specialized\nmethods for\ncreation,\nintersection with a ray,\nbounding box calculation,\nsurface normal calculation,\nray enter/exit classification,\nand for the computation 2D texture coordinates termed {\\em u-v}\ncoordinates.\nThis latter method is often referred to as the {\\em inverse mapping}\nmethod.\n\nWhile most of these methods should be of little concern to you, the\ninverse mapping methods\nwill affect the way in which certain textures are applied to primitives.\nInverse mapping is a matter of computing normalized $u$ and $v$ coordinates\nfor a given point on the surface of the primitive.  For planar objects,\nthe $u$ and $v$ coordinates of a point are computed\nby linear interpolation based upon the $u$ and $v$ coordinates assigned\nto vertices or other known points on the primitive.  For non-planar\nobjects, $uv$ computation can be considerably more involved.\n\nThis section briefly describes each primitive and\nthe syntax that should be used to create an instance of the primitive.\nIt also describes the inverse mapping method, if any, for each type.\n\n\\begin{defprim}{blob}{{\\em thresh st r} \\evec{p} [{\\em st r} \\evec{p} \\ldots]}\n\tDefines a blob with consisting of a threshold equal to {\\em thresh},\n\tand a\n\tgroup of one or more metaballs.  Each metaball is defined by \n\tits position \\evec{p}, radius {\\em r}, and strength {\\em st}.\n\\end{defprim}\nThe metaballs affect each other according to a superimposed\ndensity distribution:\n\\[\nF(x,y,z) = \\sum_{i=0}^n b_{i}e^{-d_{i}} - T = 0\n\\]\nThere is no inverse mapping method for blobs.\n\n\\begin{defprim}{box}{\\evec{corner1} \\evec{corner2}}\n\tCreates an axis-aligned box\n\twhich has \\evec{corner1} and \\evec{corner2} as\n\topposite corners.\n\\end{defprim}\nTransformations may be applied to the box if a non-axis-aligned instance\nis required.  There is no inverse mapping method for boxes.\n\n\\begin{defprim}{sphere}{{\\em radius} \\evec{center}}\n\tCreates a sphere with the given {\\em radius} and centered at the\n\tgiven position.\n\\end{defprim}\nNote that ellipsoids may be created by applying the proper scaling\nto a sphere.  Inverse mapping on the sphere is accomplished\nby computing the longitude and latitude of the point on the sphere,\nwith the $u$ value corresponding to longitude and $v$ to latitude.\nOn an untransformed sphere, the $z$ axis defines the poles, and the\n$x$ axis intersects the sphere at $u = 0$, $v = 0.5$.  There are\ndegeneracies at the poles: the south pole contains all points of\nlatitude 0., the north all points of latitude 1.\n\n\\begin{defprim}{torus}{{\\em rmajor rminor} \\evec{center} \\evec{up}}\n\tCreates a torus centered at \\evec{center} by rotating\n\ta circle with the given minor radius around the center\n\tpoint at a distance equal to the major radius. \n\\end{defprim}\nIn tori inverse mapping,\nthe $u$ value is computed using the angle of rotation about the\nup vector, and the $v$ value is computing the angle of rotation\naround the tube, with $v=0$ occuring on the innermost point of the tube.\n\n\\begin{defprim}{triangle}{\\evec{p1} \\evec{p2} \\evec{p3}}\n\tCreates a triangle with the given vertices.\n\\end{defprim}\n\n\\begin{defprim}{triangle}{\\evec{p1} \\evec{n1} \\evec{p2} \\evec{n2}\n\t\\evec{p3} \\evec{n3}}\n\tCreates a Phong-shaded triangle with the given vertices and\n\tvertex normals.\n\\end{defprim}\nFor both Phong- and flat-shaded triangles, the $u$ axis is the\nvector from \\evec{p1} to \\evec{p2}, and the $v$ axis the vector\nfrom \\evec{p1} to \\evec{p3}.  There is a degeneracy at\n\\evec{p3}, which contains all points with $v = 1.0$.  This default\nmapping may be modified using the {\\tt triangleuv} primitive described\nbelow.\n\n\\begin{defprim}{triangleuv}{\\evec{p1} \\evec{n1} \\evec{uv1}\n  \\evec{p2} \\evec{n2} \\evec{uv2}\n  \\evec{p3} \\evec{n3} \\evec{uv3}}\n\tCreates a Phong-shaded triangle with the given vertices,\n\tvertex normals.  When performing texturing, the\n\t{\\em uv} given for each vertex are used instead of the\n\tdefault values.\n\\end{defprim}\nWhen computing $uv$ coordinates within the interior of the\ntriangle, linear interpolation of the coordinates associated with\neach triangle vertex is used.\n\n\\begin{defprim}{poly}{\\evec{p1} \\evec{p2} \\evec{p3} [\\evec{p4} \\ldots ]}\n\tCreates a polygon with the given vertices. The vertices\n\tshould be given in counter-clockwise order as one is\n\tlooking at the ``front'' side of the polygon.  The number of\n\tvertices in a polygon is limited only by available memory.\n\\end{defprim}\nInverse mapping for arbitrary polygons is problematical.\n{\\Rayshade}\npunts and equates $u$ with the $x$ coordinate of the point of intersection,\nand $v$ with the $y$ coordinate.\n\n\\begin{defprim}{heightfield}{{\\em file}}\n\tCreates a height field defined by the altitude data stored\n\tin the named {\\em file}.  The height field is based upon\n\tperturbations of the unit square in the $z=0$ plane, and is\n\trendered as a surface tessellated by right isosceles triangles.\n\\end{defprim}\nSee Appendix C for a discussion of the format of a height field file.\nHeight field inverse mapping is straight-forward:  $u$ is the\n$x$ coordinate of the point of intersection, $v$ the $y$ coordinate.\n\n\\begin{defprim}{plane}{\\evec{point} \\evec{normal}}\n\tCreates a plane that passes through the given point and\n\thas the specified normal.\n\\end{defprim}\nInverse mapping on the plane is identical to polygonal inverse mapping.\n\n\\begin{defprim}{cylinder}{{\\em radius} \\evec{bottom} \\evec{top}}\n\tCreates a cylinder that extends from \\evec{bottom} to \\evec{top}\n\tand has the indicated {\\em radius}.  Cylinders are rendered\n\t{\\em without} endcaps.\n\\end{defprim}\nThe cylinder's axis defines the $v$ axis.  The $u$ axis wraps around the\ncylinder, with $u=0$ dependent upon the orientation of the cylinder.\n\n\n\\begin{defprim}{cone}{$rad_{bottom}$ \\evec{bottom} $rad_{top}$ \\evec{top}}\n\tCreats a (truncated) cone that extends from \\evec{bottom} to\n\t\\evec{top}.  The cone will have a radius of $rad_{bottom}$ at\n\t\\evec{bottom} and a radius of $rad_{top}$ at \\evec{top}.\n\tCones are rendered {\\em without} endcaps.\n\\end{defprim}\nCone inverse mapping is analogous to cylinder mapping.\n\n\\begin{defprim}{disc}{{\\em radius} \\evec{pos} \\evec{normal}}\n\tCreates a disc centered at the given position and with the\n\tindicated surface normal.\n\\end{defprim}\nDiscs are useful for placing\nendcaps on cylinders and cones.\nInverse mapping for the disc is based on the computation of the\nnormalized polar coordinates of the point of intersection.  The\nnormalized radius\nof the point of intersection is assigned to $u$, while the normalized angle\nfrom a reference vector is assigned to $v$.\n\n\\section{Aggregate Objects}\n\nAn aggregate is a collection of primitives, aggregate, and CSG\nobjects.  An aggregate, once defined, may be instantiated at will,\nwhich means that\ncopies that are optionally transformed and textured may be made.\nIf a scene calls for the presence of many geometrically identical\nobjects, only one such object need be defined; the one defined object\nmay then be instantiated many times.\n\nAn aggregate is one of several possible types.  These aggregate types\nare differentiated by the type of ray/aggregate intersection algorithm\n(often termed an {\\em acceleration technique} or {\\em efficiency scheme})\nthat is used.\n\nAggregates are defined by giving a keyword that defines the\ntype of the aggregate, followed by\na series of object instantiations and\nsurface definitions, and terminated using the {\\tt end} keyword.\nIf a defined object contains no instantiations, a warning message\nis printed.\n\nThe most basic type of aggregate, the {\\em list}, performs\nintersection testing in the simplest possible way:  Each object in the\nlist is tested for intersection with the ray in turn, and the closest\nintersection is returned.\n\n\\begin{defkey}{list}{\\ldots {\\tt end}}\n\tCreate a List object containing those objects instantiated between\n\tthe {\\tt list}/{\\tt end} pair.\n\\end{defkey}\n\nThe {\\em grid} aggregate\ndivides the region of space it occupies into a number of discrete\nbox-shaped\nvoxels.  Each of these voxels contains a list of the objects that\nintersect the voxel.  This discretization makes it possible to\nrestrict the objects\ntested for intersection to those that are likely to hit the ray,\nand to test\nthe objects in nearly ``closest-first'' order.\n\n\\begin{defkey}{grid}{{\\em xvox yvox zvox} \\ldots {\\tt end}}\n\tCreate a Grid objects composed of {\\em xvox} by {\\em yvox} by\n\t{\\em zvox} voxels containing those objects\n\tinstantiated between the {\\tt grid}/{\\tt end} pair.\n\\end{defkey}\nIt is usually only worthwhile to ``engrid'' rather large,\ncomplex collections of objects.  Grids also use a great deal more\nmemory than List objects.\n\n\\section {Constructive Solid Geometry}\n\nConstructive Solid Geometry is\nthe process of building solid objects from other solids.\nThe three CSG\noperators are Union, Intersection, and Difference.  Each operator\nacts upon two objects and produces a single object result.\nBy combining multiple levels of CSG operators, complex\nobjects can be produced from simple primitives.\n\nThe union of two objects results in an\nobject that encloses the space occupied by the two given objects.\nIntersection results in an object that encloses the space where the two\ngiven objects overlap.  Difference is an order dependent operator; it\nresults in the\nfirst given object minus the space where the second intersected\nthe first.\n\n\\subsection{CSG in {\\Rayshade}}\n\nCSG in {\\rayshade} will generally operate properly when applied to\nconjunction with\non boxes, spheres,\ntori, and blobs.\nThese primitives are by nature consistent, as they all\nenclose a portion of space (no hole from the ``inside'' to the\n``outside''), have surface normals which point outward (they\nare not ``inside-out''), and do not have any extraneous surfaces.\n\nCSG objects may also be constructed from aggregate objects.\nThese aggregates contain\nwhatever is listed inside, and may therefore be inconsistent.\nFor example, an object which contains a single triangle will not\nproduce correct results in CSG models, because the triangle does not enclose\nspace.  However, a collection of four triangles which form a pyramid\ndoes enclose space, and if the triangle normals\nare oriented correctly,\nthe CSG operators should work correctly on the pyramid.\n\nCSG objects are specified by surrounding the objects upon\nwhich to operate, as well as any associated surface-binding commands,\nby the operator verb on one side and the {\\tt end}\nkeyword on the other:\n\n\\begin{defkey}{union}{$<${\\em Object}$>$ $<${\\em Object}$>$\n[$<${\\em Object}$>$ \\ldots] {\\tt end}}\n\tSpecify a new object defined as the union of the\n\tgiven objects.\n\\end{defkey}\n\n\\begin{defkey}{difference}{$<${\\em Object}$>$ $<${\\em Object}$>$ \n[$<${\\em Object}$>$ \\ldots] {\\tt end}}\n\tSpecify a new object defined as the difference of the\n\tgiven objects.\n\\end{defkey}\n\n\\begin{defkey}{intersect}{$<${\\em Object}$>$ $<${\\em Object}$>$\n[$<${\\em Object}$>$ \\ldots] {\\tt end}}\n\tSpecify a new object defined as the intersection of the\n\tgiven objects.\n\\end{defkey}\n\nNote that the current implementation does not support more that two\nobjects in a CSG list (but it is planned for a future version).\n\n% The following aren simple CSG objects using the four consistent\n% primitives:\n% \n% union box ... difference ...\n\n\\subsection{Potential CSG Problems}\n\nA consistent CSG model is one which is made\nup of solid objects with no dangling surfaces.  In {\\rayshade},\nit is quite easy to construct inconsistent models, which will usually\nappear incorrect in the final images.\nIn {\\rayshade}, CSG is implemented by maintaining\nthe tree structure of the CSG operations.  This tree is traversed,\nand the operators therein applied, on a per-ray basis.\nIt is therefore difficult to verify the consistency of\nthe model ``on the fly.''\n\nOne class of CSG problems occur when\nsurfaces of objects being operated upon\ncoincide.  For example, when subtracting a box from another box to make a\nsquare cup, the result will be wrong if the tops of the two boxes\ncoincide.  To correct this, the inner box should be made\nslightly taller than the outer box.\nA related problem that must be\navoided occurs when two coincident surfaces are assigned\ndifferent surface properties.\n\nIt may seem that the union operator is unnecessary, since\nlisting two objects together in an aggregate results\nin an image that appears to be the same.\nWhile the result of such a short-cut\nmay appear the same on the exterior, the interior\nof the resulting object will contain\nextraneous surfaces.\nThe following examples show this quite clearly.\n\n\\begin{verbatim}\n    difference\n      box -2 0 -3  2 3 3\n      union  /* change to list; note bad internal surfaces */\n        sphere 2 1 0 0\n        sphere 2 -1 0 0\n      end\n    end rotate 1 0 0 -40  rotate 0 0 1 50\n\\end{verbatim}\n\nThe visual evidence of an inconsistent CSG object varies depending\nupon the operator being used.\nWhen subtracting a consistent object from and\ninconsistent one, the resulting object will appear to be\nthe union of the two objects, but the shading will be incorrect.\nIt will appear to be inside-out in places, while correct\nin other places.  The inside-out sections indicate the areas\nwhere the problems occur.\nSuch problems are often caused by\npolygons with incorrectly specified\nnormals, or by surfaces that exactly coincide (which\nappear as partial ``Swiss cheese'' objects).\n\nThe following example illustrates an attempt to subtract a sphere from\na pyramid defined using an incorrectly facing triangle.  Note\nthat the resulting image obviously points to which triangle is\nreversed.\n\n\\begin{verbatim}\n    name pyramid list\n        triangle 1 0 0  0 1 0  0 0 1\n        triangle 1 0 0  0 0 0  0 1 0\n        triangle 0 1 0  0 0 0  0 0 1\n        triangle 0 0 1  1 0 0  0 0 0  /* wrong order */\n    end\n\n    difference\n        object pyramid scale 3 3 3 rotate 0 0 1 45\n            rotate 1 0 0 -30 translate 0 -3.5 0\n        sphere 2.4 0 0 0\n    end\n\\end{verbatim}\n\nBy default, cylinders and cones do not have end caps, and thus\nare not consistent primitives.  One must usually\nadd endcaps by listing the\ncylinder or cone with (correctly-oriented) endcap discs in an aggregate.\n\n\\section {Named Objects}\n\nA name may be associated with any primitive, aggregate, or CSG\nobject through the use of the {\\tt name}\nkeyword:\n\n\\begin{defkey}{name}{{\\em objname} $<${\\em Instance\\/}$>$}\n\tAssociate {\\em objname} with the given object.  The\n\tspecified object is not actually instantiated; it\n\tis only stored under the given name.\n\\end{defkey}\n\nAn object thus named may then be instantiated (with possible\nadditional transforming and texturing) via the {\\tt object} keyword:\n\n\\begin{defkey}{object}{{\\em objname} [$<$Transformations$>$] [$<$Textures$>$]}\n\tInstantiate a copy of the object associated with {\\em objname}.\n\tIf given, the transformations and textures are composed\n\twith any already associated with\n\tthe object being instantiated.\n\\end{defkey}\n", "meta": {"hexsha": "f0d3bebecd22cf3a4c6794606d98ad1f05631bd1", "size": 16473, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Doc/Guide/objects.tex", "max_stars_repo_name": "stricaud/rayshade4", "max_stars_repo_head_hexsha": "08ea3c0697442e7446442383456644bd915ece36", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-11-11T09:35:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-29T02:18:10.000Z", "max_issues_repo_path": "Doc/Guide/objects.tex", "max_issues_repo_name": "dspinellis/rayshade4", "max_issues_repo_head_hexsha": "08ea3c0697442e7446442383456644bd915ece36", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Doc/Guide/objects.tex", "max_forks_repo_name": "dspinellis/rayshade4", "max_forks_repo_head_hexsha": "08ea3c0697442e7446442383456644bd915ece36", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2015-11-11T09:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-03T17:08:24.000Z", "avg_line_length": 39.8861985472, "max_line_length": 78, "alphanum_fraction": 0.7624597827, "num_tokens": 4200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.42670258471834716}}
{"text": "\\documentclass[10pt,tgadventor, onlymath]{beamer}\n\n\\usepackage{graphicx,amsmath,amssymb,tikz,psfrag,neuralnetwork, stackengine,array, multirow, fontawesome}\n\n\\input defs.tex\n\\graphicspath{ {./figures/} }\n\n%% formatting\n\n\\mode<presentation>\n{\n\\usetheme{default}\n\\usecolortheme{seahorse}\n}\n\\setbeamertemplate{navigation symbols}{}\n\\usecolortheme[rgb={0.03,0.28,0.59}]{structure}\n\\setbeamertemplate{itemize subitem}{--}\n\\setbeamertemplate{frametitle} {\n\t\\begin{center}\n\t  {\\large\\bf \\insertframetitle}\n\t\\end{center}\n}\n\n\n\\AtBeginSection[] \n{ \n\t\\begin{frame}<beamer> \n\t\t\\tableofcontents[currentsection,currentsubsection] \n\t\\end{frame} \n} \n\n\n\\usetikzlibrary{shapes,arrows}\n\\usetikzlibrary{positioning}\n\\tikzstyle{block} = [rectangle, draw, fill=blue!20, \n    text width=5em, text centered, rounded corners, minimum height=4em]\n\\tikzstyle{line} = [draw, -latex']\n\n\n\n%% begin presentation\n\n\\title{\\large \\bfseries Power Allocation in Heterogeneous Networks for Base Stations with Multiple Antennas}\n\n\\author{Peter Hartig \\\\ \\and Supervisor: Prof. Laura  Cottatellucci\n}\n\n\\date{\\today}\n\n\\begin{document}\n\n\\frame{\n\\thispagestyle{empty}\n\\titlepage\n}\n\n\\section{System Description}\n\\begin{frame}\n\\frametitle{The Heterogeneous Network}\n\t\\includegraphics[width=\\textwidth]{het_net}\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{The Heterogeneous Network Game}\n\\begin{columns}\n\n\\begin{column}{0.5\\linewidth}\n\t\\includegraphics[width=\\textwidth]{het_net}\n\n\\end{column}\n\\begin{column}{0.5\\linewidth}\n\\begin{table}\n    \\setlength{\\extrarowheight}{2pt}\n    \\begin{tabular}{cc|c|c|}\n      & \\multicolumn{1}{c}{} & \\multicolumn{2}{c}{Player $2$}\\\\\n      & \\multicolumn{1}{c}{} & \\multicolumn{1}{c}{$A$}  & \\multicolumn{1}{c}{$B$} \\\\\\cline{3-4}\n      \\multirow{2}*{Player $1$}  & $A$ & $(8,8)$ & $(2,15)$ \\\\\\cline{3-4}\n      & $B$ & $(15,2)$ & $(3,3)$ \\\\\\cline{3-4}\n    \\end{tabular}\n  \\end{table}\n\\end{column}\n\\end{columns}\n\\bigskip\n\\begin{itemize}\n\\item \n\tPlayers $=$ Femto Cell Base Stations (FCBS)\n\\item \n\tPlayer Strategy $=$ FCBS Transmission Scheme\n\\end{itemize}\n\n\\end{frame}\n\n%\\begin{frame}\n%\\frametitle{The Heterogeneous Network Game}\n%\\begin{table}\n%    \\setlength{\\extrarowheight}{2pt}\n%    \\begin{tabular}{cc|c|c|}\n%      & \\multicolumn{1}{c}{} & \\multicolumn{2}{c}{Player $2$}\\\\\n%      & \\multicolumn{1}{c}{} & \\multicolumn{1}{c}{$A$}  & \\multicolumn{1}{c}{$B$} \\\\\\cline{3-4}\n%      \\multirow{2}*{Player $1$}  & $A$ & $(8,8)$ & $(2,15)$ \\\\\\cline{3-4}\n%      & $B$ & $(15,2)$ & $(3,3)$ \\\\\\cline{3-4}\n%    \\end{tabular}\n%  \\end{table}\n%\\bigskip\n%\\begin{itemize}\n%\\item \n%\tPlayers $=$ Femto Cell Base Stations (FCBS)\n%\\item \n%\tPlayer Strategy $=$ FCBS Transmission Scheme\n%\\end{itemize}\n%\n%\\end{frame}\n\n\n\\section{Project Goals}\n\n\\begin{frame}\n\\frametitle{Objectives}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\n\\item Find a Nash Equilibrium between all players.\n\\begin{itemize}\n\\item Preferably a \"social optimal\" Nash Equilibrium.\n\\end{itemize}\n\\item Minimize resources required to reach Nash Equilibrium.\n\\end{enumerate}\n%\\pause\n\\begin{center}\n%\\begin{tikzpicture}{center}\n%\\node [block] (game) {Game with Many Players};\n%\\node [block, right = of game] (central) {Central Problem};\n%\\node [block, right = of central] (distributed) {Distributed Solution to Central Problem};\n%\n%\\path[line] (game) -- (central);\n%\\path[line] (central) -- (distributed);\n%\n%\\end{tikzpicture}\n\t\t\\includegraphics[scale=.2]{het_net}\n\n\\end{center}\n\n\\end{frame}\n\n\\section{Key Tools}\n\n\\begin{frame}\n\\frametitle{Key Tools: The Normalized Nash Equilibrium}\nA Nash equilibrium in which the dual variables (prices) corresponding to constraints are equal up to a constant.\n\\begin{equation}\n\\lambda_f = \\frac{\\lambda_{0}}{ r_f}, \\; \\forall \\; [r_0 \\cdots r_F] > 0 \n\\end{equation}\nChoosing $r_f =1$, all players must pay the same \"price\" to change their strategy. \n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Key Tools: N-Person Concave Games}\nConditions\n\\begin{itemize}\n\\item All player utility functions must be concave with respect to their own strategy.\n\\item The set of strategies for the \\emph{entire} game is convex. \n\\end{itemize}\n\\bigskip\nImplications\n\\begin{itemize}\n\\item Immediately proves existence of a \\emph{pure strategy} Nash Equilibrium.\n\\item Provides an additional sufficient condition for uniqueness of Nash Equilibrium (diagonally strict concavity).\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Key Tools: Potential Games}\n\\begin{enumerate}\n\\item \nPotential Games\n\\begin{itemize}\n\\item \"Central\" optimization function $\\Psi(\\mathbf{s})$ with\n\\end{itemize}\n\\begin{equation}\\label{potential_game_condition}\n\\frac{\\partial \\Psi(\\mathbf{s})}{\\partial \\mathbf{s}_{f}}\n =\n \\frac{\\partial U_f(\\mathbf{s})}{\\partial \\mathbf{s}_{f}}.\n\\end{equation} \n\\item \nWhen all utility functions are concave, the optimum of the potential function corresponds to a Nash Equilibrium.\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Key Tools: Distributed Optimization}\nSome optimization problems may be decomposed into \"sub-problems\".\n\\begin{equation}\nf(x) = \\sum_{i = 1}^{F} f_{i}(x_{i})\n\\end{equation}\nDecomposing the corresponding Lagrangian gives\n\\begin{equation}\nL(x,y) = \\sum_{i = 1}^{F} L_i(x_i,y)\n\\end{equation}\nallows for dual ascent with distributed updates.\n\\end{frame}\n%\n\n\\section{System Model}\n\\begin{frame}\n\\frametitle{System Model: Femto Base Stations}\nEach FCBS is a player in the game and is characterized by:\n\\\\\n\\begin{itemize}\n\\setlength\\itemsep{2em}\n\n\\item \n\t$T_{f}$ antennas to transmit to $K_{f}$ femtocell users ($T_{f} \\geq K_{f}$).\n\\item \n\tThe transmitted \t\t\n\tsignal is $\\mathbf{s}_{f\n\t}= \\mathbf{U}_{f}\\mathbf{x}_{f}$ with $E[\\mathbf{x}_{f}\\mathbf{x}_{f}^H] = \\mathbf{I}$.\n\\item \n\tAn average power constraint $E\\{trace(\\mathbf{U}_{f}^H\\mathbf{U}_{f})\\} \\leq P^{Total}_{f} $.\n\\item \n\tA utility function $U_{f}(\\boldsymbol{\\gamma}_{f}) =\n\t\\sum_{i=1}^{K_{f}}\n    \t U_{f,i}(\\gamma_{f,i}) $\n    \twith non-decreasing function $U_{f,i}(\\cdot)$.\n\\end{itemize}\n\\end{frame}\n\n%\\begin{frame}\n%\\frametitle{System Model: FCBS Users}\n%User $i$ of FBS $f$ has signal to interference plus noise ratio (SINR)\n%\t\\begin{equation*}\n%\t\\gamma_{f,i} = \\frac{\\|\\mathbf{h}^H_{f,i}\\mathbf{u}_{f,i}\\|^2}\n%\t{\\sigma^2_{\\text{noise}}   +\n%\t\\underbrace{\n%\t \\sum_{\\tilde{f}=1, \\tilde{f}\\neq f}^{f} \\sum_{u=1}^{K_{\\tilde{f}}}\n%\t\\|\\mathbf{h}^H_{\\tilde{f},u}\\mathbf{u}_{\\tilde{f},i}\\|^2}_{\\mathrm{inter-cell}}\n%\t + \n%\t \\underbrace{\n%\t \\sum_{\\tilde{k}=1, \\tilde{k}\\neq i}^{K_f}\n%\t \\|\\mathbf{h}^H_{f,\\tilde{k}}\\mathbf{u}_{f,\\tilde{k}}\\|^2}_{\\mathrm{intra-cell}}},\n%\t  \\; i \\in \\{1 ... K_f\\}\n%\t  \\end{equation*}\n%\\end{frame}\n\n\\begin{frame}\n\\frametitle{System Model: Macro Users}\n\tReceived interference constraint given by \n\t\\begin{equation}\n\tE\\{\\sum^F_{f=1} \\mathbf{\\tilde{h}}_{m,f}^T  \\mathbf{U}_{f}\t\t\t\t\t\n\t\\mathbf{U}_{f}^{H} \\mathbf{\\tilde{h}}_{m,f}^*\\} \\leq I^{Threshold}\t\t\n\t_{m}\n\t\\end{equation}\n\t\\bigskip\n\t\\centering\n\t\t\\includegraphics[scale=.2]{het_net}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{System Model: General}\n\\begin{itemize}\n\\setlength\\itemsep{2em}\n\n\\item \n\tNo inter-femto cell interference\n\\item \n\tFCBS have knowledge of channel state information \n\t\\begin{itemize}\n\t\\item \n\tThe downlink channel matrix $\\mathbf{H}_f \\in \\mathbb{C}_{K_{f} \\times T_{f}} $ to its $K_{f} $ users.\n\n\t\\end{itemize}\n\\end{itemize}\n\t\\bigskip\n\t\\centering\n\t\t\\includegraphics[scale=.2]{het_net}\n\\end{frame}\n\n\n\\section{General Setup}\n\n\\begin{frame}\n\n\\frametitle{General Problem Formulation}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\n\\item  Player $f$ has trasnmitted signal $\\mathbf{s}_{f\n\t}= \\mathbf{U}_{f}\\mathbf{x}_{f}$ with strategy $\\mathbf{U}_f$.\n\\begin{itemize}\n\\item $\\mathbf{U}_f$ has an implied power allocation\n\\end{itemize}\n%\\item Simplify by selecting $\\mathbf{U}_f$ as a pseudo inverse of $\\mathbf{H}_f$  (i.e $\\mathbf{H}_f\\mathbf{U}_f = \\mathbf{I}$) such that \n%\t\\begin{equation*}\n%\t\\gamma_{f,i} = \\frac{\\|\\mathbf{h}^H_{f,i}\\mathbf{u}_{f,i}\\|^2}\n%\t{\\sigma^2_{\\text{noise}}}\n%\t\\end{equation*}\n%\twith \n%\t\\begin{equation*}\n%\tU_{f}(\\boldsymbol{\\gamma}_{f}) =\n%\t\\sum_{i=1}^{K_{f}}\n%    \t U_{f,i}(\\gamma_{f,i}) .\n%\t\\end{equation*}\n\\pause\nDoes the problem admit the N-Person Concave game Framework? \n\n\\item  Set of strategies is convex. \\faThumbsOUp\n\\pause\n\\item  $U_{f}(\\boldsymbol{\\gamma}_{f})$ is concave only when $U_{f,i}(\\gamma_{f,i})$ is concave and non-increasing.\n\\faThumbsODown\n\\end{enumerate}\n\\end{frame}\n\n\\section{Convex Setup}\n\n\\begin{frame}\n\\frametitle{Convex Problem Formulation}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\\item Pre-select $\\mathbf{U}_f$ to be a psuedo inverse of $\\mathbf{H}_f$  (i.e $\\mathbf{H}_\\mathrm{f}\\mathbf{U}_\\mathrm{f} = \\mathbf{I}$).\n\\item \n\tNormalize the columns of $\\mathbf{U}_{f}$ such that \n\t $\\|\\mathbf{u}_{f,i}\\|^2 =1 \\;\\forall i \\in \\{1 ... K_{f}\\}$.\n\\item \n\tPlayer $f$ strategy is now the diagonal, power allocation  \t\n\tmatrix $\\mathrm{diag}(\\mathbf{p}_{f})$ with $p_{f,i} \\geq 0, \\forall i \\in \\{1 ... K_{f}\\}$\nsuch that the transmitted \t\t\n\tsignal is \n\t$\\mathbf{s}_{f\t}= \\mathbf{U}_{f} \n\t\\mathrm{diag}(\\mathbf{p}_{f})^{\\frac{1}{2}}\n\t\\mathbf{x}_{f}$.\n\\item \n\tPower constraint given by \n\t\\begin{gather*}\n\t\\sum_{i=1}^{K_{f}} p_{f,i}\n\t  \\leq P^{Total}_{f}.\n\t  \t\\end{gather*}\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Problem Analysis}\nDoes the problem admit the N-Person Concave game Framework? \n\\\\\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\\item  Set of strategies is convex. \\faThumbsOUp\n\\item  $U_{f}(\\boldsymbol{\\gamma}_{f})$ is concave if \n\t$U_{f,i}(\\cdot)$ is non-decreasing and concave (reasonable assumption). \\faThumbsOUp\n\\item \n\tIf $U_{f,i}(\\cdot)$ is strictly concave, this satisfies conditions for the unique Normalized Nash Equilibrium (diagonally strict concavity) . \\faThumbsOUp\n\\end{enumerate}\n\n\\end{frame}\n\n\n\n\\section{A Solution}\n\\begin{frame}\n\\frametitle{Player Optimization Problem}\nEach player attempts to solve the optimization problem given by \n\t\\begin{subequations}\n\t\\begin{align}\n\t    \\underset{\\mathbf{p}_{f} }{\\text{min}} \\;\n\t    & - \\sum_{i=1}^{K_f}\n    \tU_{f,i}(\\gamma_{f,i}) \\label{player_opt_c} \\\\\n\t    \\text{subject to  }\\\\\n\t  &\n\t  \\sum^F_{f=1} E\\{ \\mathbf{\\tilde{h}}_{m,f}^T  \\mathbf{s}_{f} \t\t\t\t\t\t\n\t\\mathbf{s}_{f}^{H} \\mathbf{\\tilde{h}}_{m,f}^* \\}\n\t\\leq I^{Threshold}\t\t\n\t_{m} & m \\in \\{1 ...m\\} \n\t\t\\label{interference_const_c}\\\\\n        & \n        \t\\sum_{i=1}^{K_{f}} p_{f,i}\n\t   \\leq P_{f}^{\\text{Total}}  \\label{power_const_c}\\\\\n        & p_{f,i} \\geq 0 &  i\\in \\{1 ...K_{f}\\} \\label{pos_power_const_c}\n\t\\end{align}\n\t\\end{subequations}\n\nNote that $\\mathbf{U}_{f}$ is pre-selected as a pseudo-inverse to  $\\mathbf{H}_f$.\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Steps Outline}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\n\\item\n\tForm Potential Function.\n\\item\n\tSetup distributed algorithm.\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{The Potential Function}\nThings to note\n\\begin{enumerate}\n\\item\n\tSpacing assumption makes $U_{f}(\\boldsymbol{\\gamma}_{f})$ independent of all other player strategies. \n\n\\item\n\tThe sum of concave functions over a convex set is also concave. Does this satisfy the potential function condition?\n\t\\begin{equation*}\\label{potential_game_condition}\n\\frac{\\partial \\Psi(\\boldsymbol{\\gamma})}{\\partial \\boldsymbol{\\gamma}_{f}}\n =\n \\frac{\\partial U_f(\\boldsymbol{\\gamma})}{\\partial \\boldsymbol{\\gamma}_{f}}\n\\end{equation*} \nYes!\n\\end{enumerate}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Solving for a NNE}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\n\\item\n\tThe potential function of a game with strictly concave utility functions has optimum corresponding to NNE.\n\\item\n\tSatisfying the Diagonally Strict Concavity conditions means the NNE is unique.\n\\end{enumerate}\n\\bigskip\nJust need to solve for the unique optimum of a convex problem.\n\\pause\n\\par\n Can the problem be distributed?\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Distributed Dual Ascent}\nFor $U_{f,i}(\\gamma_{f,i}) = log(1+\\gamma_{f,i})$ and potential function\n\\begin{gather*} \\label{Potential_Function}\n\\Psi(\\mathbf{p}) = \\sum_{f = 1}^{F} U_{f}(\\mathbf{p}_{f}).\n\\end{gather*}\nWe arrive at a central, convex optimization problem given by\n\t\t\\begin{subequations}\n\t\\label{optim}\n\t\\begin{align}\n\t    \\underset{\\mathbf{p}}{\\text{minimize  }}\n\t    & \\; \\Psi(\\mathbf{p}) \\label{potential_game} \\\\\n\t    \\text{subject to  } \\; &\n\t  \\sum^F_{f=1} E\\{\\tilde{\\mathbf{h}}_{m,f}^T  \\mathbf{s}_{f} \t\t\t\t\t\t\n\t\\mathbf{s}_{f}^{H} \\tilde{\\mathbf{h}}_{m,f}^* \\}\\leq I^{Threshold}\t\t\n\t_{m} & m \\in \\{1 ...m\\} \n\t\t\\label{interference_const}\\\\\n        & E\\{trace(\\mathbf{s}_f\\mathbf{s}_f^H)\\}  \\leq P_{f}^{\\text{Total}}  \\label{power_const}\n        & \\forall f \\in \\{1 ... f\\}\\\\\n        & p_{f,i} \\geq 0 &  \\forall i \\in \\{1 ...K_{f}\\} \\; \\forall f \\in \\{1 ... F\\}\\label{pos_power_const}\n\t\\end{align}\n\t\\end{subequations}\n\\end{frame}\n\n\n\\section{Simulation Results}\n\n\\begin{frame}\n\\frametitle{Expected Results}\n\\begin{enumerate}\n\\setlength\\itemsep{2em}\n\n\\item\n\tPower not limiting, at least one interference constraint should be active.\n\\item\n\tPower not limiting, increasing the number of antennas at the base stations should allow for higher utility.\n\\item\n\tThe choice of the psuedoinverse, $\\mathbf{U}_{f}$, should be further optimized. \n\\end{enumerate}\n\\end{frame}\n\n\n\\begin{frame}\n\\frametitle{Multiple Antennas with Constant Power}\n\\begin{figure}\n\t\\includegraphics[width=\\textwidth]{results/central_antenna}\n\t\\caption{With $K_f = 5$ (users), increasing antennas allows players with constant power to increase utility.}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Increasing Power at FCBS}\n\\begin{figure}\n\t\\includegraphics[width=\\textwidth]{results/central_power}\n\t\\caption{For $K_f = 5$ and $T_f = 15$, increasing FCBS power constraint is limited by interference.}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Selecting the Beamformer}\n\\begin{figure}\n\t\\includegraphics[width=\\textwidth]{results/central_beamformer}\n\\caption{With $K_f = 5$ (users) and $T_f = 10$ (antennas), choice of $\\mathbf{U}_{f}$ may depend on the active system constraints.}\n\\end{figure}\n\\end{frame}\n\n\\section{Conclusion}\n\\begin{frame}\n\\frametitle{Continuing Work}\n\\begin{enumerate}\n\\item\n\tImplement distributed version.\n\\item\n\tImprove choice of beamformer using additional DOF. \n\\item\n\tConsider \"fairness\" with respect to FCBS utility.\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n  \\centering \\Large\n  \\emph{Thank You.}\n  \\\\\n\t\\bigskip\n    \\centering \\Large\n  \\emph{Questions or Comments?}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "242681a234173338b9b835b76a6a0534585cbbb7", "size": 14394, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/presentations/final_presentation/final_presentation.tex", "max_stars_repo_name": "pghartig/Power-Control", "max_stars_repo_head_hexsha": "c23613b74c9fe1a1ecd6d415f5bf0cb625920661", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-04-19T01:58:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:24:23.000Z", "max_issues_repo_path": "documentation/presentations/final_presentation/final_presentation.tex", "max_issues_repo_name": "pghartig/Power-Control", "max_issues_repo_head_hexsha": "c23613b74c9fe1a1ecd6d415f5bf0cb625920661", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/presentations/final_presentation/final_presentation.tex", "max_forks_repo_name": "pghartig/Power-Control", "max_forks_repo_head_hexsha": "c23613b74c9fe1a1ecd6d415f5bf0cb625920661", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-21T12:34:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-15T17:23:48.000Z", "avg_line_length": 27.5219885277, "max_line_length": 155, "alphanum_fraction": 0.6865360567, "num_tokens": 4988, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.42670257748059565}}
{"text": "% !TeX root = ../../python-snippets.tex\n\n\\section{Search Algorithms}\n\nThis section contains implementations of certain search algorithms.\n\n\n\\subsection{Binary Search}\n\nThe binary search algortihm is a search algorithm, that finds the position of a target value within a sorted array.\nIt compares the target value to the middle element of the array.\nIf they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found.\n\n\\lstinputlisting[caption=binary\\_search.py]{../standard_lib/binary_search.py}\n", "meta": {"hexsha": "db31edfb02a7890e8ba9a79bc746b8d958638bd4", "size": 669, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ebook/chapters/standard_lib_chapters/search_algorithms.tex", "max_stars_repo_name": "DahlitzFlorian/python-snippets", "max_stars_repo_head_hexsha": "212f63f820b6f5842f74913ed08da18d41dfe7a4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-03-25T09:35:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-08T22:09:03.000Z", "max_issues_repo_path": "ebook/chapters/standard_lib_chapters/search_algorithms.tex", "max_issues_repo_name": "DahlitzFlorian/python-snippets", "max_issues_repo_head_hexsha": "212f63f820b6f5842f74913ed08da18d41dfe7a4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ebook/chapters/standard_lib_chapters/search_algorithms.tex", "max_forks_repo_name": "DahlitzFlorian/python-snippets", "max_forks_repo_head_hexsha": "212f63f820b6f5842f74913ed08da18d41dfe7a4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-05-19T21:18:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-18T12:49:21.000Z", "avg_line_length": 44.6, "max_line_length": 240, "alphanum_fraction": 0.7952167414, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4265688852446884}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** Fourth Chapter *****************************\n%*******************************************************************************\n\n\\chapter{Lattice Configurations and the Gluon Propagator}\\label{chapter:GluonPropagator}\n\\ifpdf\n    \\graphicspath{{Chapter4/Figs/Raster/}{Chapter4/Figs/PDF/}{Chapter4/Figs/}}\n\\else\n    \\graphicspath{{Chapter4/Figs/Vector/}{Chapter4/Figs/}}\n\\fi\n\nNow that we have developed the required background understanding of lattice QCD and the topological objects of interest to this research, we can explain how our calculations are performed. This chapter will first describe how we calculate the Landau gauge gluon propagator on the lattice. This is the primary quantity of interest for the first part of the original research, and as such we will explicitly detail its calculation.  We will then motivate our choice of momentum variables, before proceeding to a description of the renormalisation scheme we employ. Finally, we will present the lattice parameters and data cuts utilised in this work.\n\n\\section{Lattice Definition of the Gluon Propagator}\nIn a gauge field theory the position-space propagator, $D_{\\mu\\nu}(x,y)$, of the gauge boson is the two-point correlation function. In the case of perturbative QCD this can be interpreted as the probability amplitude of a gluon being created at the space-time point $x$, propagating to $y$, and then being annihilated. The propagator therefore serves as a useful measure of the behaviour of gluons as a function of distance; or, correspondingly, as a function of momentum in the momentum-space representation. In this section we detail how the non-perturbative momentum-space Landau gauge gluon propagator is calculated on the lattice. We begin with the definition of the coordinate-space propagator as a two-point correlator~\\cite{Zwanziger:1991gz,Cucchieri:1999sz,Langfeld:2001cz}.\n\\begin{equation}\nD^{ab}_{\\mu\\nu}(x) = \\langle A^a_\\mu(x) \\, A^b_\\nu(0)\\rangle.\n\\label{eq:coordGluonProp}\n\\end{equation}\nThe propagator in momentum space is simply related by the discrete Fourier transform,\n\\begin{equation}\nD^{ab}_{\\mu\\nu}(p) = \\sum_x e^{-ip\\cdot x} \\langle A^a_\\mu(x) \\, A^b_\\nu(0) \\rangle. \n\\end{equation}\nNoting that the coordinate space propagator $D^{ab}_{\\mu\\nu}(x-y)$ only depends on the difference $x-y,$ such that\n\\begin{equation}\n\\langle A^a_\\mu(x) \\, A^b_\\nu(0)\\rangle = \\langle A^a_\\mu(x+y) \\, A^b_\\nu(y)\\rangle\\, ,\n\\end{equation}\nwe can make use of translational invariance to average over the four-dimensional volume to obtain the form for the momentum space propagator.\n\\begin{align}\nD^{ab}_{\\mu\\nu}(p) &= \\frac{1}{V}\\sum_{x,y} e^{-ip\\cdot x}\\langle A^a_\\mu(x+y) \\, A^b_\\nu(y) \\rangle \\nonumber \\\\\n                &= \\frac{1}{V}\\sum_{x,y} \\langle e^{-ip\\cdot (x+y)} A^a_\\mu(x+y) \\, e^{+ip\\cdot y}A^b_\\nu(y) \\rangle \\nonumber \\\\\n                &= \\frac{1}{V}\\langle A^a_\\mu(p) \\, A^b_\\nu(-p) \\rangle. \\label{eq:gluPropxtop}\n\\end{align}\n\nHence we find that the momentum space gluon propagator on a finite lattice with four-dimensional volume $V$ is given by\n%\n\\begin{equation}\nD_{\\mu\\nu}^{ab}(p) \\equiv \\frac{1}{V}\\left \\langle A^a_\\mu (p)\\,A^b_\\nu(-p)\\right\\rangle \\, . \\label{eq:gluonProp}\n\\end{equation}\n%\nIn the continuum, the Landau-gauge momentum-space gluon propagator has the following form~\\cite{Leinweber:1998im,Bonnet:2001uh}\n%\n\\begin{equation}\nD^{ab}_{\\mu\\nu}(p) = \\left ( \\delta_{\\mu\\nu} - \\frac{p_\\mu p_\\nu}{p^2} \\right )\\,\\delta^{ab}\\,D(p^2) \\, ,\n\\end{equation}\n%\nwhere $D(p^2)$ is the scalar gluon propagator.  Contracting Gell-Mann index $b$ with $a$ and\nLorentz index $\\nu$ with $\\mu$ one has\n%\n\\begin{equation}\nD^{aa}_{\\mu\\mu}(p) = (4-1)\\,(n_c^2-1)\\,D(p^2) \\, ,\n\\end{equation}\n%\nsuch that the scalar function can be obtained from the gluon propagator via\n%\n\\begin{equation}\nD(p^2) = \\frac{1}{3(n_c^2-1)}\\,D^{aa}_{\\mu\\mu}(p) \\, ,\n\\label{eq:scalarProp}\n\\end{equation}\n%\nwhere $n_c = 3$ is the number of colours.\n\nAs the lattice gauge links $U_\\mu(x)$ naturally reside in the $3\\times 3$ fundamental representation of $SU(3),$ we now wish to work in the matrix representation of $A_\\mu(x)$, as introduced in Eq.~\\eqref{eq:CovariantDerivative}. Using the orthogonality relation $\\Tr(\\lambda_a\\lambda_b) = 2\\delta_{ab}$ for the Gell-Mann matrices, it is straightforward to see that\n%\n\\begin{equation}\n2\\Tr(A_\\mu\\,A_\\mu) = A^a_\\mu A^a_\\mu\\, ,\n\\end{equation}\n%\nwhich can be substituted into Eq.~\\eqref{eq:scalarProp} to obtain the final expression for the lattice scalar gluon propagator,\n%\n\\begin{equation}\nD(p^2) = \\frac{2}{3\\,(n_c^2-1)\\,V}\\big\\langle {\\rm Tr}\\, A_\\mu(p)\\,A_\\mu(-p) \\big\\rangle \\,. \\label{eq:scalarProp2}\n\\end{equation}\n\nTo calculate Eq.~\\eqref{eq:scalarProp2} on the lattice, we need to define $A_\\mu(p)$. As defined in Eq.~\\eqref{eq:GaugePotentialLat}, we make use of the midpoint definition of the coordinate-space gauge potential in terms of the lattice link variables such that\n%\n\\begin{equation}\nA_\\mu\\left(x+\\frac{a}{2}\\hat{\\mu}\\right) = \\frac{i}{2ag}\\left(U_\\mu(x) - U_\\mu^\\dag(x)\\right) - \\frac{i}{6ag}\\Tr\\left(U_\\mu(x) - U_\\mu^\\dag(x)\\right)I + \\mathcal{O}(a^2)\\, .\n\\end{equation}\n%\nOnce the link variables are fixed to Landau gauge following the procedure described in Sec.~\\ref{sec:LandauGauge}, we can obtain the momentum-space gauge potential by performing a Fourier transform,\n%\n\\begin{equation}\nA_\\mu(p) = \\sum_x e^{-ip\\cdot(x+\\hat{\\mu}/2)}\\, A_\\mu(x+\\hat{\\mu}/2)\\, .\n\\end{equation}\n%\nWe have now constructed a workable lattice definition to calculate the Landau gauge scalar gluon propagator within the lattice framework established in Chapter \\ref{chapter:LatticeQCD}.\n\n\\section{Momentum Variables}\\label{sec:MomentumVariables}\nAs discussed in Sec.~\\ref{sec:Confinement}, it is understood that at high energies QCD is asymptotically free. With this understanding, we expect that at high momentum the Landau gauge gluon propagator will tend towards the Landau gauge photon propagator~\\cite{ryder1996quantum}\n%\n\\begin{equation}\nD_\\gamma(p^2) = \\frac{1}{p^2}\\, .\n\\end{equation}\n%\nHowever, lattice discretisation errors cause a deviation from this idealised behaviour that we would like to systematically account for. To do this, we follow the work of Refs.~\\cite{Weisz:1982zw, Weisz:1983bn,Luscher:1985zq,Symanzik:1983dc,Symanzik:1983gh}. As we are considering the propagator at high momenta, it is sufficient to consider the behaviour of the photon propagator on the lattice. We therefore consider for this section only an Abelian theory. The commutator in the field strength tensor then vanishes, simplifying to\n%\n\\begin{equation}\nF_{\\mu\\nu} = \\partial_\\mu \\,A_\\nu - \\partial_\\nu\\,A_\\mu\n\\end{equation}\n%\nWe consider this Abelian field to be on a lattice generated using the Wilson action (see Eq.~\\eqref{eq:WilsonAction}). From Eq.~\\eqref{eq:FieldStrengthPlaquette} we know that the Wilson action can be written as $\\mathcal{S}_\\text{W} = a^4\\frac{1}{2}\\sum_x F_{\\mu\\nu}F^{\\mu\\nu} + \\mathcal{O}(a^4)$. As we are interested in the momentum-space propagator, we write the field strength tensor at the plaquette midpoint $\\tilde{x}$ as\n%\n\\begin{align}\nF_{\\mu\\nu}(\\tilde{x}) &= \\frac{A_\\nu\\left(\\tilde{x}+a\\frac{\\hat{\\mu}}{2}\\right) - A_\\nu\\left(\\tilde{x}-a\\frac{\\hat{\\mu}}{2} \\right)}{a} - \\frac{A_\\mu\\left(\\tilde{x}+a\\frac{\\hat{\\nu}}{2}\\right) - A_\\mu\\left(\\tilde{x}-a\\frac{\\hat{\\nu}}{2} \\right)}{a}\\nonumber\\\\\n&= \\frac{1}{a} \\sum_p e^{ip\\cdot\\tilde{x}} \\left(\\tilde{A}_\\nu(p)\\, e^{-iap\\frac{\\hat{\\mu}}{2}} - \\tilde{A}_\\nu(p)\\, e^{iap\\frac{\\hat{\\mu}}{2}} - \\tilde{A}_\\mu(p)\\, e^{-iap\\frac{\\hat{\\nu}}{2}} + \\tilde{A}_\\mu(p)\\, e^{iap\\frac{\\hat{\\nu}}{2}}\\right)\\nonumber\\\\\n&= -\\frac{1}{a} \\sum_p e^{ip\\cdot\\tilde{x}}\\left(2i\\sin\\left(\\frac{a p_\\mu}{2}\\right)\\tilde{A}_\\nu(p) - 2i\\sin\\left(\\frac{a p_\\nu}{2}\\right)\\tilde{A}_\\mu(p)\\right)\\nonumber\\\\\n&= - \\sum_p e^{ip\\cdot\\tilde{x}}\\tilde{f}_{\\mu\\nu}(p)\\, ,\n\\end{align}\n%\nwhere\n%\n\\begin{equation}\n\\tilde{f}_{\\mu\\nu}(p) = i\\left(\\hat{k}_\\mu \\tilde{A}_\\nu(p) - \\hat{k}_\\nu \\tilde{A}_\\mu(p)\\right)\\, ,~\\hat{k}_\\mu = \\frac{2}{a}\\sin\\left(\\frac{ap_\\mu}{2}\\right)\\, .\n\\end{equation}\n%\nThe Wilson action can therefore be written as\n%\n\\begin{align}\n\\mathcal{S}_\\text{W} &= a^4\\frac{1}{2}\\sum_{\\tilde{x}}\\sum_{p,\\,p^\\prime}e^{i\\tilde{x}(p+p^\\prime)}\\tilde{f}_{\\mu\\nu}(p) \\, \\tilde{f}^{\\mu\\nu}(p^\\prime)\\nonumber\\\\\n&=a^4\\frac{1}{2}\\sum_{p,\\,p^\\prime} \\delta(p+p^\\prime)\\tilde{f}_{\\mu\\nu}(p) \\, \\tilde{f}^{\\mu\\nu}(p^\\prime) \\nonumber\\\\\n&= a^4\\frac{1}{2}\\sum_{p}\\tilde{f}_{\\mu\\nu}(p) \\, \\tilde{f}^{\\mu\\nu}(-p) + \\mathcal{O}(a^4)\\, . \\label{eq:WilsonMomentum}\n\\end{align}\n%\nWe are now in a position to consider the propagator. Equivalent to the two-point correlator definition, the propagator is also the Green's function of the equations of motion, $M_{\\mu\\nu}$, satisfying\n%\n\\begin{equation}\nM_{\\mu\\nu}D^{\\nu\\lambda}(p) = \\delta_\\mu^\\lambda\\, .\n\\end{equation}\n%\nIn the continuum, we can write the Abelian Lagrangian density in terms of momentum space variables as \n%\n\\begin{align}\n\\mathcal{L} &= \\frac{1}{2}\\tilde{F}_{\\mu\\nu}\\,\\tilde{F}^{\\mu\\nu}\\nonumber\\\\\n&= \\frac{1}{2}(p_\\mu\\,\\tilde{A}_\\nu - p_\\nu\\,\\tilde{A}_\\mu)\\,(p^\\mu\\,\\tilde{A}^\\nu - p^\\nu\\,\\tilde{A}^\\mu)\\nonumber\\\\\n&= (p^2\\delta_{\\mu\\nu} - p_\\mu\\,p_\\nu)\\tilde{A}^\\mu\\,\\tilde{A}^\\nu\\, ,\n\\end{align}\n%\nand hence\n%\n\\begin{equation}\nM_{\\mu\\nu} = (p^2\\delta_{\\mu\\nu} - p_\\mu\\,p_\\nu)\\, .\n\\label{eq:ContEquationsOfMotion}\n\\end{equation}\n%\nHowever, it is understood that in the continuum the equations of motion are not invertible unless an additional gauge fixing term is added, with a gauge fixing parameter $\\alpha$. Hence, the equations of motion for the photon field in momentum space are given by Eq.~\\eqref{eq:ContEquationsOfMotion} with an additional gauge fixing term~\\cite{ryder1996quantum}\n%\n\\begin{equation}\nM_{\\mu\\nu} = p^2\\delta_{\\mu\\nu} - \\left(1-\\frac{1}{\\alpha}\\right)p_\\mu p_\\nu\\, .\n\\end{equation}\n%\nBy inspection, we see that Eq.~\\eqref{eq:WilsonMomentum} for the lattice Wilson action will have the same equations of motion, with the substitution $p_\\mu\\rightarrow \\hat{k}_\\mu$. In turn, this gives the propagator\n%\n\\begin{equation}\nD_{\\mu\\nu}(p) = \\frac{1}{\\hat{k}^2}\\left[\\delta_{\\mu\\nu} + (\\alpha-1)\\frac{\\hat{k}_\\mu \\hat{k}_\\nu}{\\hat{k}^2}\\right]\\, .\n\\end{equation}\nLandau gauge corresponds to setting $\\alpha=0$, so we find that\n%\n\\begin{equation}\nD_{\\mu\\mu}(p) = \\frac{3}{\\hat{k}^2}\\, ,\n\\end{equation}\n%\nand therefore by comparison with Eq.~\\eqref{eq:scalarProp} we see that\n%\n\\begin{equation}\nD(p^2) = \\frac{1}{\\hat{k}^2}\\, .\n\\end{equation}\n%\nThis suggests that for the Wilson action we should make the substitution $p_\\mu\\rightarrow \\hat{k}_\\mu = \\frac{2}{a}\\sin\\left(a p_\\mu/2\\right)$ so that at tree-level we observe the expected behaviour of the gluon propagator.\\\\\n\nA similar analysis can be performed for the L\\\"uscher-Weisz action used in this work, taking into account the contributions from the rectangle terms. The L\\\"uscher-Weisz action written in the same form as Eq.~\\eqref{eq:WilsonMomentum} is~\\cite{Weisz:1982zw}\n%\n\\begin{equation}\n\\mathcal{L}_\\text{LW} = a^4\\frac{1}{2}\\sum_p \\left(1+\\frac{1}{12}a^2\\hat{k}^2\\right) \\tilde{f}_{\\mu\\nu}(p) \\, \\tilde{f}^{\\mu\\nu}(-p) + \\mathcal{O}(a^6)\\, .\n\\end{equation}\n%\nThe equations of motion then become\n%\n\\begin{equation}\nM_{\\mu\\nu} = \\left(\\hat{k}^2 + \\frac{1}{12}a^2\\hat{k}^4\\right)\\delta_{\\mu\\nu} - \\left(1-\\frac{1}{\\alpha}\\right)\\left(\\sqrt{\\hat{k}_\\mu^2 + \\frac{1}{12}a^2\\hat{k}_\\mu^4}\\right)\\left(\\sqrt{\\hat{k}_\\nu^2 + \\frac{1}{12}a^2\\hat{k}_\\nu^4}\\right)\\, .\n\\end{equation}\nTherefore the propagator is\n%\n\\begin{equation}\nD_{\\mu\\nu}(p) = \\frac{1}{q^2}\\left[\\delta_{\\mu\\nu} + (\\alpha-1)\\frac{q_\\mu q_\\nu}{q^2}\\right]\\, ,\n\\end{equation}\nwith\n\\begin{equation}\nq_\\mu = \\sqrt{\\hat{k}_\\mu^2 + \\frac{1}{12}a^2\\hat{k}_\\mu^4} = \\frac{2}{a}\\sqrt { \\sin ^ { 2 } \\left( \\frac { p _ { \\mu } a } { 2 } \\right) + \\frac { 1 } { 3 } \\sin ^ { 4 } \\left( \\frac { p _ { \\mu } a } { 2 } \\right) }\\, .\n\\end{equation}\n%\nIn Landau gauge, this tells us that the tree-level form for the scalar propagator is\n%\n\\begin{equation}\nD(p^2) = \\frac{a^2}{4 \\sin ^ { 2 } \\left( \\frac { p _ { \\mu } a } { 2 } \\right) + \\frac { 1 } { 3 } \\sin ^ { 4 } \\left( \\frac { p _ { \\mu } a } { 2 } \\right)} = \\frac{1}{q^2}\\, .\n\\label{eq:LWCorrection}\n\\end{equation}\\\\\nGiven Eq.~\\eqref{eq:LWCorrection}, in this work we make the variable substitution $p_\\mu\\rightarrow q_\\mu$ to ensure that at high momentum the gluon propagator tends towards tree level as required.\n\n\\section{Renormalisation}\\label{sec:Renormalisation}\nBefore plotting the propagator, it is essential to discuss the issue of renormalisation. On the lattice, we calculate the bare dimensionless propagator $D_B(q^2,\\Lambda)$, as the lattice introduces an explicit regularisation parameter in the form of the momentum cutoff, $\\Lambda = \\pi/a$. This is related to the renormalised propagator $D_R(q^2,\\mu)$ through the relation\n%\n\\begin{equation}\nD_B(q^2,\\Lambda) = Z_3(\\mu, \\Lambda)\\, D_R(q^2,\\mu)\\, ,\n\\label{eq:LatticeRenormalisation}\n\\end{equation}\n%\nwhere $\\mu$ is the renormalisation scale. To obtain the renormalisation constant $Z_3(\\mu, \\Lambda)$, and therefore the renormalised propagator, it is necessary to enforce a renormalisation scheme. Here we employ the momentum space subtraction (MOM) scheme~\\cite{Bowman:2004jm,Leinweber:1998uu,Bonnet:2001uh}, which requires that for some sufficiently large $\\mu$\n%\n\\begin{equation}\nD_R(q^2,\\mu)\\big|_{q^2=\\mu^2}=\\frac{1}{\\mu^2}\\, .\n\\end{equation}\n%\nThis sets the value of the renormalisation constant to be\n%\n\\begin{equation}\nZ_3(\\mu,\\Lambda) = \\, \\mu^2 \\, D_B(\\mu^2,\\Lambda)\\, ,\n\\end{equation}\nsuch that\n%\n\\begin{equation}\nD_R(q^2,\\mu) = \\frac{D_B(q^2,\\Lambda)}{\\mu^2 \\, D_B(\\mu^2,\\Lambda)}\\, .\n\\end{equation}\n%\nThis renormalised propagator is what we plot in e.g. Fig.~\\ref{fig:UntouchedPropagator}, and will be denoted as simply $D(q^2)$ hereafter. The value of $\\mu$ is arbitrary, however to make contact with perturbation theory it is necessary that it is sufficiently large such that it is outside the infrared region where the gluon propagator exhibits substantial deviation from perturbative behaviour. Furthermore, $\\mu$ must be away from the momentum cutoff, as the renormalisation constant is only independent of the cutoff in the limit that the cutoff tends towards infinity~\\cite{Bonnet:2001uh,Boucaud:2006pc}.  Once the renormalisation scheme has been imposed, it is then possible to connect the lattice results with those obtained from perturbation theory by connecting the renormalisation constant from the MOM scheme with those obtained from the renormalisation schemes used in perturbation theory.\\\\\n \nThe crux of this argument is that it is the renormalised propagator, not the bare propagator, that carries the physical meaning.  More generally, it is the shape of the propagator that carries meaning, and we are free to impose a scaling constant without changing the physical significance of the result. To facilitate comparisons between vortex-modified ensembles, we make use of the original $Z_3(\\mu, \\Lambda)$ obtained for the untouched propagator unless specified otherwise. Maintaining this consistency is sufficient to comment on the qualitative shape of the propagator, which is the most significant point of interest in this research.\\\\\n\n\\section{Lattice Parameters and Data Cuts} \\label{sec:LatticeParameters}\nWe calculate the gluon propagator on 100 configurations of a $20^3\\times 40$ $SU(3)$ lattice with spacing $a=0.125\\,\\si{fm}$, as used in Refs.~\\cite{Trewartha:2015nna,OMalley:2011aa}. The momentum variables chosen for both the Wilson and L\\\"uscher-Weisz action have been numerically verified to provide better tree level agreement in Refs.~\\cite{Marenzoni:1994ap, Bonnet:2001uh}, and we present a comparison of the L\\\"uscher-Weisz and uncorrected variables in Fig.~\\ref{fig:MomentumComparison}. To visualise this improvement, we plot $k^2\\,D(k^2)$ (where $k_\\mu=p_\\mu,\\,q_\\mu$ is the momentum variable for the given case under consideration) such that the tree-level propagator appears as $k^2\\,D(k^2)=1$, shown as the black dashed line. This choice of plotting $k^2\\,D(k^2)$ against $ka$ has the benefit of aiding both the visualisation of the tree-level behaviour, and the onset of the non-perturbative infrared properties of the propagator. Via the method described in the previous section, we have renormalised the L\\\"uscher-Weisz corrected propagator such that $q^2\\,D(q^2) = 1$ at $qa=6.0$, and applied this same renormalisation constant to the uncorrected propagator. While this choice of renormalisation point is near the cutoff, it provides a renormalised propagator that approaches tree-level from above. In subsequent sections we will select renormalisation points further away from the cutoff.\\\\\n\nWe can clearly see that at high momenta the corrected gluon propagator tends towards the expected tree-level behaviour, whereas the uncorrected propagator fans out considerably. This fanning is the result of asymmetry between the spatial and temporal components of the propagator, which is accounted for in the tree-level correction~\\cite{Marenzoni:1994ap}. The results presented in Fig.~\\ref{fig:MomentumComparison} clearly motivate the need for tree-level correction when calculating the gluon propagator on the lattice.\\\\ \n%\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=\\linewidth]{./ScalarGluComp_q2_MomentumComparison.pdf}\n\\caption[The renormalised scalar gluon propagator is plotted with no tree-level momentum correction and the L\\\"uscher-Weisz correction.]{\\label{fig:MomentumComparison} The scalar gluon propagator is plotted with no tree-level momentum correction (blue crosses) and the L\\\"uscher-Weisz correction (red dots) presented in Eq.~\\eqref{eq:LWCorrection}. It is clear that the corrected momentum has improved tree-level behaviour, free from the fanning effect present in the uncorrected case.}\n\\end{figure}\n%\n\nWhen considering the gluon propagator we shall maintain the plotting convention introduced in Fig.~\\ref{fig:MomentumComparison} of considering $q^2D(q^2)$ against $qa$ for the remainder of this work. To improve the momentum-corrected propagator presented in  Fig.~\\ref{fig:MomentumComparison} we follow the procedure of Ref.~\\cite{Bonnet:2001uh,Leinweber:1998im} and perform a momentum half-cut. The momentum half-cut corresponds to only considering lattice momenta in the range\n%\n\\begin{equation}\np_\\mu = \\frac{2\\pi n_\\mu}{a N_\\mu},~n_\\mu\\in \\left(-\\frac{N_\\mu}{4},\\,\\frac{N_\\mu}{4}\\right]\\, .\n\\end{equation}\n%\nThis cut limits the positive range of the kinematically corrected $q_\\mu$ to\n%\n\\begin{equation}\nq_\\mu \\in \\left[0,\\, \\frac{2\\sqrt{21}}{3a}\\right]\\approx\\left[0,\\frac{3.06}{a} \\right]\\, .\n\\end{equation}\n%\nFurthermore, a cylinder cut of radius $pa=2$ lattice units is performed, such that we only consider points within two lattice units of the diagonal. This cut is implemented by considering points satisfying\n%\n\\begin{equation}\n|pa|^2\\, \\sin(\\theta_c) \\leq 2\\, ,\n\\end{equation}\n%\nwhere\n%\n\\begin{equation}\n\\theta_c = \\cos^{-1}\\left(\\frac{pa \\cdot \\hat{n}}{|pa|}\\right)\\, ,\n\\end{equation}\n%\nand $\\hat{n} = \\frac{1}{2}(1,\\,1,\\,1,\\,1)$ is the unit vector along the diagonal. This is performed so that all directions are equally sampled, whilst omitting points where one direction dominates the signal. This reduces the impact of lattice cutoff artefacts. Finally, we can take advantage of the rotational symmetry of the scalar propagator to perform $Z(3)$ averaging over the Cartesian coordinates. This means that we average over all points with the same Cartesian radius; for example, we would average across the points $(n_x,n_y,n_z)=(2,1,1),\\,(1,2,1)$ and $(1,1,2)$. These choices of cuts assist in producing a cleaner signal that accurately represents the behaviour of the continuum propagator. With the momentum half-cut, we now renormalise at $qa=3.0$. This choice of renormalisation point is both sufficiently large and away from the lattice momentum cutoff, as well as falling within the momentum half-cut range of $qa\\in [0,\\,3.06]$. This choice of renormalisation point will be used for the remainder of this work.\\\\\n\nWith these cuts implemented, the gluon propagator on the original untouched configurations appears as Fig.~\\ref{fig:UntouchedPropagator}. We observe the expected tree-level behaviour at high momenta, with an infrared enhancement indicative of amplified low-momentum propagation. It should be noted that the difference in peak height observed between Fig.~\\ref{fig:MomentumComparison} and Fig.~\\ref{fig:UntouchedPropagator} is due to the different renormalisation constant. Due to the cuts we have made, we observe a much cleaner signal, particularly in the region $qa\\geq 1.5$, in agreement with the results of Ref.~\\cite{Bonnet:2001uh}. For the remainder of this work we will employ these data cuts and this choice of momentum variables when plotting the gluon propagator to ensure an accurate and clear signal.\n%\n\\begin{figure}\n\\centering\n\\includegraphics[width=\\linewidth]{./ScalarGluComp_q2_NoCoolU.pdf}\n\\caption[The untouched gluon propagator with all data cuts and correct momentum variables utilised.]{\\label{fig:UntouchedPropagator} The untouched gluon propagator with all data cuts and correct momentum variables utilised. We observe a substantially cleaner signal when compared to the untouched propagator shown in Fig.~\\ref{fig:MomentumComparison}.}\n\\end{figure}\n\n\n", "meta": {"hexsha": "0415a717bb47704035573b2d24b582883b979bcb", "size": 21525, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4/chapter4.tex", "max_stars_repo_name": "jamesbiddle/Masters_Thesis", "max_stars_repo_head_hexsha": "275177c3167b490d678575f0078cc6c87614b7bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter4/chapter4.tex", "max_issues_repo_name": "jamesbiddle/Masters_Thesis", "max_issues_repo_head_hexsha": "275177c3167b490d678575f0078cc6c87614b7bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4/chapter4.tex", "max_forks_repo_name": "jamesbiddle/Masters_Thesis", "max_forks_repo_head_hexsha": "275177c3167b490d678575f0078cc6c87614b7bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.7075812274, "max_line_length": 1407, "alphanum_fraction": 0.7235772358, "num_tokens": 6732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.42656887638021634}}
{"text": "Previous chapters introduced some of the fundamental concepts related to robotic perception, and specifically techniques for sensing the environment and extracting useful semantic information. While these techniques provide \\textit{local} information that is crucial for robots to navigate autonomously, additional \\textit{global} information is often required. \nFor example, distance measurements from a laser rangefinder might be useful for detecting objects in an environment, but they only provide information \\textit{relative} to the robot's current position. Alternatively, object detection via computer vision only provides information about what is in the robot's \\textit{current} view. Robotic autonomy, in particular autonomous decision making and planning, generally requires more than just local information to answer questions such as ``have I seen this object before?'' and ``have I been here before?''.\nThese new challenges, associated with building a global understanding of the environment from local measurements, are often referred to as \\textit{localization and mapping}\\footnote{Localization and mapping is the component of the ``think'' part of the ``see, think, act'' cycle that connects with robotic perception.}.\n\n\n\\notessection{Introduction to Localization and Filtering}\n\n\nThe problem of \\textit{localization} is to endow the robot with the ability to understand its current position with respect to its environment in a global sense\\cite{ThrunBurgardEtAl2005}\\cite{SiegwartNourbakhshEtAl2011}.\nOne of the main classes of techniques for robot localization are \\textit{map-based}, where the robot explicitly localizes its position with respect to a \\textit{map} of the environment.\nFor example, consider the floor plan (the environment map) in Figure \\ref{fig:sample-room}: before a robot can navigate to a particular room it must know where in the building it is currently located.\\footnote{Other approaches to navigate in environments include \\textit{behavioral} approaches, which rely on a specified set of behaviors that will result in a desired global behavior without the need for explicit mapping or localization. An example of this approach would be to have a left-wall following behavior for movement about a building.}\n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[width=0.9\\textwidth]{tex/figs/ch13_figs/map.png}\n    \\caption{An example environment where localization is crucial for robotic autonomy. For a robot to move from location A to location B it must first understand which room it is in, and that the only path to B is through the hallway. Extracting such global information about the environment from local measurements (e.g. from a range sensor) requires specialized algorithms.}\n    \\label{fig:sample-room}\n\\end{figure}\n\nThere are two primary components to map-based localization: map representation and belief representation. This chapter focuses on belief representation, which addresses the problem of how to best represent the robot's belief of its current position with respect to the map. One simple approach would be to simply store a best guess of the robot's position (in some map-based coordinate system). However in practice localization information is often \\textit{uncertain}, and representing the belief by only a best guess does not capture this important fact. Therefore one common approach is to use a \\textit{probabilistic} representation of the robot's belief since probability distributions can be used to model uncertainty (and extract best guesses, for example by finding the mean of a unimodal distribution). A variety of probabilistic representations can be used, for example singe-hypothesis or multiple-hypothesis representations as well as continuous or discrete representations. A few examples showing the differences between these types of representations are given in Figure \\ref{fig:belief-representation}.\n\\begin{figure}[ht!]\n\t\\centering\n    \\includegraphics[width=0.6\\textwidth]{tex/figs/ch13_figs/distributions.png}\n    \\caption{A graphical representation of different types of probabilistic representations: (a) a continuous single-hypothesis belief (e.g. from a single Gaussian distribution), (b) a continuous multiple-hypothesis belief (e.g. a mixture of Gaussians), (c) discrete representation with a finite number of possible values.}\n    \\label{fig:belief-representation}\n\\end{figure}\nSome representations are more expressive than others, but there is usually a trade-off with computational complexity of the resulting algorithms that support the representation. Algorithms based on these different probabilistic representations will be presented in this chapter and in subsequent chapters.\n\n\\subsection{Basic Concepts in Probability}\nBefore discussing different types of robot localization algorithms it is useful to provide a review of some of the fundamental concepts from probability. \n\n\\subsubsection{Random Variables}\nUncertain quantities such as sensor measurements, robot state, and environment variables can be modeled as discrete or continuous \\textit{random variables}.\n\\begin{definition}[Discrete Random Variable]\nA discrete random variable $X$ is a random variable that can only take on values from a countable set. Discrete random variables are characterized by a probability mass function $p(x)$ (which can be read as $p(X=x)$, ``the probability that $X$ takes on value $x$'') that satisfies:\n\\begin{equation*}\n    \\sum_x p(x) = 1,\n\\end{equation*}\nwhere the summation is over all possible values of $X$.\n\\end{definition}\n\\begin{definition}[Continuous Random Variable]\nA continuous random variable $X$ is a random variable that can take on values from a continuous range. Continuous random variables are characterized by a probability density function $p(x)$ that satisfies:\n\\begin{equation*}\n    \\int_{-\\infty}^\\infty p(x) dx = 1.\n\\end{equation*}\nThe probability of the random variable taking on a value in the interval $[a,b]$ is similarly defined as:\n\\begin{equation*}\n    P(a \\leq X \\leq b) = \\int_{a}^b p(x) dx = 1.\n\\end{equation*}\n\\end{definition}\nA common example of a discrete random variable is the result of a coin flip, which can only take on two values: heads or tails. In robotics, a common example of a continuous random variable may be the position of the robot, which could take on an infinite number of values.\n\n\\subsubsection{Joint Distributions, Independence, and Conditioning}\nMany applications of probability theory rely on more than one random variable. In these instances it is useful to be able to quantify probabilities associated with multiple random variables at the same time. One of the most fundamental tools when dealing with multiple variables is the \\textit{joint distribution}.\n\\begin{definition}[Joint Distribution]\nThe joint distribution of two random variables $X$ and $Y$ defines the probability associated with both taking on specific values at the same time. This is denoted mathematically as $p(x,y)$, which can be read as $p(X=x \\:\\:\\text{and}\\:\\: Y=y)$.\n\\end{definition}\nIt is also useful to determine whether different random variables have any relationship to each other. In particular, two random variables that do not have any influence on each other in a probabilistic sense are considered to be probabilistically independent.\n\\begin{definition}[Independence]\nTwo random variables $X$ and $Y$ are independent if and only if:\n\\begin{equation} \\label{eq:indep}\n    p(x,y)=p(x)p(y).\n\\end{equation}\nIndependence holds when the occurrence of one value of a random variable does not affect the probability of another random variable taking on a specific value.\n\\end{definition}\nAnother useful tool that relates two random variables is the conditional probability, which defines the probability of a random variable when the value of a second random variable is \\textit{known} or \\textit{fixed}.\n\\begin{definition}[Conditional Probability]\nThe conditional probability of a random variable $X$ taking on a value given that a second random variable $Y$ has a specific value is defined as:\n\\begin{equation} \\label{eq:condprob}\n    p(x\\:|\\: y)\\coloneqq \\frac{p(x,y)}{p(y)}.\n\\end{equation}\nThis can be read as ``the probability of $X$ taking on value $x$ conditioned on the fact that $Y$ has taken on value $y$''.\n\\end{definition}\nNotice that if the random variables $X$ and $Y$ are independent, then the conditional probability definition simplifies to $p(x\\:|\\: y) = p(x)$, which suggests that knowing that $Y$ has taken on value $y$ has provided no new information about the random variable $X$ (which of course is in line with the definition of independence).\nAdditionally, another notion of independence can be defined based on whether or not two random variables are independent when \\textit{conditioned} a third random variable.\n\\begin{definition}[Conditional Independence]\nTwo random variables $X$ and $Y$ are conditionally independent given the value of a third random variable $Z$ if and only if:\n\\begin{equation} \\label{eq:condindep}\n    p(x,y\\:|\\: z) = p(x \\:|\\: z) p(y \\:|\\: z).\n\\end{equation}\n\\end{definition}\nIt is important to note however that conditional independence does not imply independence, and vice versa.\n\n\\subsubsection{Law of Total Probability}\nThe law of total probability defines a relationship between probabilities, joint probabilities, and conditional probabilities.\n\\begin{definition}[Law of Total Probability]\nFor discrete random variables $X$ and $Y$ the law of total probability states that:\n\\begin{equation*}\n    p(x) = \\sum_y p(x,y) = \\sum_y p(x \\:|\\: y) p(y). \n\\end{equation*}\nSimilarly, for continuous random variables this law is given by:\n\\begin{equation*}\n    p(x) = \\int p(x,y) dy = \\int p(x \\:|\\: y) p(y) dy. \n\\end{equation*}\n\\end{definition}\nIn words, this law says that the probability of a random variable $X$ taking on a value $x$ can be found by looking at the joint probabilities between $X$ and $Y$ and accounting for \\textit{all} possible values of $Y$. The second part of the law is a direct result of applying the definition of conditional probabilities.\n\n\\subsubsection{Bayes' Rule}\nThe joint probability $p(x,y)$ between two random variables $X$ and $Y$ can be related to the conditional probabilities $p(x \\:|\\: y)$ and $p(y \\:|\\: x)$ via the definition of conditional probabilities \\eqref{eq:condprob}. In particular, since the joint probability can be equivalently expressed in two ways it can be seen that:\n\\begin{equation*}\n    p(x,y) = p(x \\:|\\: y)p(y) = p(y \\:|\\: x) p(x).\n\\end{equation*}\nThis relationship is commonly referred to as Bayes' rule:\n\\begin{definition}[Bayes' Rule]\nFor discrete random variables $X$ and $Y$, Bayes' rule states that:\n\\begin{equation} \\label{eq:bayes}\n    p(x \\:|\\: y) = \\frac{p(y \\:|\\: x) p(x)}{p(y)}. \n\\end{equation}\n\\end{definition}\nBayes' rule is useful as it provides a relationship between the ``inverse'' conditional probabilities $p(x \\:|\\: y)$ and $p(y \\:|\\: x)$. This is particularly important for \\textit{probabilistic inference}, which is the problem of inferring the value of a random variable from another. \n\nFor example, suppose you had a good initial guess of the probability distribution $p(x)$ for a random variable $X$ (the distribution $p(x)$ in this case is often called the \\textit{prior}, because it is the guess that comes before any new information is taken into account). Then, suppose some new information regarding the value of a random variable $Y$ is obtained. Using Bayes' rule it is possible to update your belief about the probability distribution of $X$ based on this new information. In particular, the new belief is the conditional probability $p(x \\:|\\: y)$ (which is often called the \\textit{posterior} because it comes after new information is introduced). These two distributions are related by Bayes' rule!\n\nBayes' rule can also be extended to cases with additional random variables. For example with three random variables $X$, $Y$, and $Z$, Bayes' rule is:\n\\begin{equation*}\n    p(x \\:|\\: y, z) = \\frac{p(y \\:|\\: x, z) p(x \\:|\\: z)}{p(y \\:|\\: z)}. \n\\end{equation*}\n\n\\subsubsection{Expectation and Covariance}\nProbability distributions define in a vary precise way the probability associated with any particular value of a random variable. However, sometimes it is useful to aggregate this information into more practically useful metrics. Two of the most commonly used metrics are the \\textit{expected value} and the \\textit{covariance}.\n\\begin{definition}[Expected Value]\nThe expected value for a random variable $X$ is denoted as $E[X]$. For discrete random variables the expected value can be computed by:\n\\begin{equation*}\n    E[X] = \\sum_x x p(x).\n\\end{equation*}\nSimilarly, the expected value for a continuous random variable can be computed by:\n\\begin{equation*}\n    E[X] = \\int x p(x) dx.\n\\end{equation*}\n\\end{definition}\nThe expected value can be thought of as the average result of an experiment over an infinite number of trials, and is also sometimes referred to as the \\textit{first moment} of the distribution.\nAdditionally, expectation is a \\textit{linear operator}, such that:\n\\begin{equation*}\n    E[aX + b]= aE[X] + b,\n\\end{equation*}\nfor any values $a$ and $b$.\nIn the case that the random variable $X$ is a vector-valued random variable, the expectation of the random vector is simply the vector of expectations of each element.\n\n\\begin{definition}[Covariance]\nThe covariance between two random variables $X$ and $Y$ is denoted $\\text{cov}(x,y)$ and is computed by:\n\\begin{equation*}\n    \\text{cov}(x,y) = E[(X-E[X])(Y-E[Y])^\\top ] = E[XY^\\top ] - E[X]E[Y]^\\top \n\\end{equation*}\n\\end{definition}\nCovariance is a metric used to describe the relationship between random variables and is positive if greater values of one variable generally corresponds to greater values of the other (and same for lesser values). Similarly, it is negative if the variables tend to show opposite behavior of each other. If there is no general relationship between the two then their covariance is zero (e.g. independent random variables have zero covariance).\n\n\n\\subsection{Markov Models}\nRecall from previous chapters the kinematic and dynamic models that were developed to describe the physical behavior of a robot. These models consisted of a robot state $\\x$, and a set of equations that described how $\\x$ varied in time given some control inputs $\\bu$. In this section another type of model will be developed that is based on these same core ideas. These new models, referred to as \\textit{Markov models}, are commonly used in robotics for localization tasks as well as higher level planning tasks.\n\n\\subsubsection{States, Measurements, and Controls}\nSimilar to previous chapters, the state $\\x$ is a collection of variables that contains information required to define the physical state of the robot. However unlike previous chapters, the state might also include information about the environment (this state has a higher-level perspective). In the context of robotics, the state may include the robot pose (i.e. location and orientation information), velocity, as well as locations and features of surrounding objects in the environment. \nNote that in general the state discussed in this section might be different from the state defined for robot kinematics and dynamics (even if the robot is the same). This is because the choice of model is usually specific to the task at hand, and while the kinematic and dynamic models are useful for control, they may not strictly be necessary (or sufficient) for use in localization and planning tasks.\n\nA discrete time formulation is also used in this context, where the state is specified for discrete time instances and denoted by $\\x_t$ (rather than $\\x(t)$, as was done in previous chapters). The models developed in this section then describe the changes in the state between time steps, for example between $\\x_t$ and $\\x_{t+1}$. It is also useful to define the notation $\\x_{t_1:t_n} \\coloneqq \\x_{t_1},\\x_{t_2},...,\\x_{t_n}$ for describing a sequence of states between times $t_1$ and $t_n$.\n\nThe robot interacts with the environment through control actions and by gathering information through measurements\\footnote{In the context of robot localization, measurements increase the robot's knowledge and control actions tend to result in a loss of knowledge.}. In this context, the measurement data collected at a time $t$ will be denoted as $\\z_t$, and the control data is denoted as $\\bu_t$. Similar to the state, a useful notation for representing a sequence of measurements or controls is given by  $\\z_{t_1:t_n} \\coloneqq \\z_{t_1},\\z_{t_2},...,\\z_{t_n}$ and $\\bu_{t_1:t_n} \\coloneqq \\bu_{t_1},\\bu_{t_2},...,\\bu_{t_n}$. In general, the measurements can come from any number of the sensors discussed in previous sections on robotic perception, including cameras and laser rangefinders.\n\n\\subsubsection{Model}\nThe kinematic and dynamic models from previous chapters (expressed as a set of ordinary differential equations) were deterministic models. However, to leverage a probabilistic framework for robot localization it is typically required that the model also be probabilistic. In the most general sense a probabilistic model can be defined by:\n\\begin{equation} \\label{eq:genprobmod}\np(\\x_t \\mid \\x_{0:t-1}, \\z_{1:t-1}, \\bu_{1:t}),\n\\end{equation}\nwhich defines a probability distribution over the possible current state $\\x_t$ given the state, measurement, and control histories. Note that here the convention that will be used is that the robot executes control $\\bu_t$ first, and then the measurement $\\z_t$ can be made based on the resulting state $\\x_t$. A general probabilistic measurement model can also be defined as:\n\\begin{equation} \\label{eq:genmeasmod}\np(\\z_t \\mid \\x_{0:t}, \\z_{1:t-1}, \\bu_{1:t}).\n\\end{equation}\n\nIn many cases however, the state is defined such that it is \\textit{complete}. A state $\\x_t$ is complete if no variables prior to $\\x_t$ can influence the future states. In other words, $\\x$ contains a sufficient amount of information that the history is not important. This is also known as the \\textit{Markov property}. If the Markov property holds, the probabilistic model \\eqref{eq:genprobmod} can be simplified to:\n\\begin{equation} \\label{eq:markovprobmod}\np(\\x_t \\mid \\x_{t-1}, \\bu_{t}),\n\\end{equation}\nand the measurement model \\eqref{eq:genmeasmod} can be simplified to:\n\\begin{equation} \\label{eq:markovmeasmod}\np(\\z_t \\mid \\x_{t}).\n\\end{equation}\n\nThe resulting overall model with the Markov property, consisting of the state transition probability \\eqref{eq:markovprobmod} and the measurement model \\eqref{eq:markovprobmod} is referred to as a Bayes network model or a hidden Markov model. Graphically this model can be represented as shown in Figure \\ref{fig:hmm}, where the sequencing of the control and measurements are more clearly shown (first control, then measurement).\n\\begin{figure}[ht]\n\t\\centering\n    \\includegraphics[width=0.55\\textwidth]{tex/figs/ch13_figs/hmm.png}\n    \\caption{Graphical representation of the Bayes network model (hidden Markov model). Note that the sequencing assumes that the control is applied, and then a measurement is taken.}\n    \\label{fig:hmm}\n\\end{figure}\n\n\n\\subsection{Bayes Filter}\nGiven a Bayes network model defined by a state transition model \\eqref{eq:markovprobmod} and a measurement model \\eqref{eq:markovmeasmod}, the next task is to determine a way to use this information for robot localization. In particular, the desired task is to estimate the current robot state $\\x_t$ given the measurement and control information that is available. In the probabilistic framework this estimate is referred to as a \\textit{belief distribution}, which is a probability distribution over $\\x$. This distribution assigns a probability to each hypothesis with respect to the true state. Mathematically the belief distribution is denoted as $bel(\\x_t)$ and is defined as:\n\\begin{equation} \\label{eq:belief}\nbel(\\x_t):=p(\\x_t\\mid \\z_{1:t}, \\bu_{1:t}).\n\\end{equation}\nIn other words, the belief $bel(\\x_t)$ is a posterior probability distribution over the state variables conditioned on the available data. A similar distribution, known as the \\textit{prediction} distribution, can also be defined as:\n\\begin{equation} \\label{eq:predbelief}\n\\overline{bel}(\\x_t):=p(\\x_t\\mid \\z_{1:t-1},\\bu_{1:t}),\n\\end{equation}\nwhich is does not include the most recent measurement $\\z_t$. The process of computing a belief from a predicted belief (i.e. the process of accounting for the new measurement $\\z_t$) is called a \\textit{correction} or \\textit{measurement update}.\n\nThe most general algorithm for computing beliefs $bel(\\x_t)$ (which leverages Bayes network models that satisfy the Markov property) is known as the \\textit{Bayes filter}. This filter is a recursive algorithm that consists of a prediction step for computing $\\overline{bel}(\\x_t)$ and a correction step for computing $bel(\\x_t)$ given a new measurement $\\z_t$.\n\n\\subsubsection{Algorithm}\nThe Bayes filter algorithm is given in Algorithm \\ref{alg:bayes}. In this algorithm, the probability associated with each potential state $\\x_t$ is updated via a prediction and a correction. The term $\\eta$ in the correction step is simply a normalization constant that ensures the resulting posterior $bel(\\x_{t})$ satisfies the requirements of a probability density function\\footnote{In fact this normalization constant comes from the denominator in Bayes' rule.}. This algorithm is typically initialized with a prior distribution $bel(\\x_{0})$ that may come from a best guess or simply a uniform distribution.\n\\begin{algorithm}[ht]\n \\KwData{$bel(\\x_{t-1}), \\bu_{t},\\z_{t}$}\n \\KwResult{$bel(\\x_{t})$}\n \\ForEach{$\\x_t$}{\n    $\\overline{bel}(\\x_t) = \\int p(\\x_t\\mid \\bu_{t}, \\x_{t-1}) bel(\\x_{t-1}) d\\x_{t-1}$ \\\\\n    $bel(\\x_t) = \\eta p(\\z_t\\mid \\x_{t})\\overline{bel}(\\x_t)$\n }\n \\Return $bel(\\x_{t})$\n \\caption{Bayes Filter Algorithm}\n \\label{alg:bayes}\n\\end{algorithm}\nNote that the prediction step is essentially just using the state transition model \\eqref{eq:markovprobmod} to guess what might happen to each state for the given control $\\bu_t$. The correction step is then modifying the prediction to actually account for what was observed in the real world.\n\n\\subsubsection{Derivation}\nRecall that the belief distribution is defined as \\eqref{eq:belief}, which can be expanded using Bayes' rule to yield:\n\\begin{equation*}\n\\begin{split}\nbel(\\x_t) &\\coloneqq p(\\x_t\\mid \\z_{1:t}, \\bu_{1:t}), \\\\\n&=\\eta p(\\z_{t}\\mid \\x_{t},\\z_{1:t-1},\\bu_{1:t})p(\\x_{t}\\mid \\z_{1:t-1},\\bu_{1:t}),\n\\end{split}\n\\end{equation*}\nwhere\n\\begin{equation*}\n    \\eta = \\frac{1}{p(\\z_{t}\\mid \\z_{1:t-1},\\bu_{1:t})}.\n\\end{equation*}\nThe Markov property can then be leveraged to simplify $p(\\z_{t}\\mid \\x_{t},\\z_{1:t-1},\\bu_{1:t}) = p(\\z_{t}\\mid \\x_{t})$ and the definition of the prediction belief can be used to give:\n\\begin{equation*}\n\\begin{split}\nbel(\\x_t) = \\eta p(\\z_{t}\\mid \\x_{t}) \\overline{bel}(\\x_t),\n\\end{split}\n\\end{equation*}\nwhich is precisely the second step of the Bayes filter algorithm. Now the derivation of the prediction can be given by again starting from its definition and leveraging the law of total probability:\n\\begin{equation*}\n\\begin{split}\n \\overline{bel}(\\x_t) &= p(\\x_{t}\\mid \\z_{1:t-1},\\bu_{1:t}), \\\\ \n &= \\int p(\\x_{t}\\mid \\x_{t-1},\\z_{1:t-1},\\bu_{1:t}) p(\\x_{t-1}\\mid \\z_{1:t-1},\\bu_{1:t}) d\\x_{t-1}.\n\\end{split}\n\\end{equation*}\nAgain the Markov property can now be used to simplify $p(\\x_{t}\\mid \\x_{t-1},\\z_{1:t-1},\\bu_{1:t}) = p(\\x_{t}\\mid \\x_{t-1},\\bu_{t})$, and additionally the structure of the model makes it possible to remove the $\\bu_t$ term from the prior distribution $p(\\x_{t-1}\\mid \\z_{1:t-1},\\bu_{1:t})$ since the control $\\bu_t$ has no impact on the state $\\x_{t-1}$ (see Figure \\ref{fig:hmm}). Therefore the expression above can be simplified to:\n\\begin{equation*}\n\\begin{split}\n \\overline{bel}(\\x_t) = \\int p(\\x_{t}\\mid \\x_{t-1},\\bu_{t}) bel(\\x_{t-1}) d\\x_{t-1},\n\\end{split}\n\\end{equation*}\nsince by definition $bel(\\x_{t-1}) = p(\\x_{t-1}\\mid \\z_{1:t-1}, \\bu_{1:t-1})$. This result is precisely the prediction step from the Bayes filter algorithm.\n\n\\subsubsection{Practical Considerations}\nThe Bayes filter is a great starting point to derive many useful algorithms, but is itself often not practical to implement. In particular it is generally not reasonable to assume that the integrals in Algorithm \\ref{alg:bayes} can be computed, and if they could be approximated via a numerical scheme this may computationally still be challenging.\n\n\\subsection{Discrete Bayes Filter}\nThe discrete Bayes filter is a discrete version of the Bayes filter previously introduced. This filter can be applied to problems where the state space is finite (i.e. only a finite number of values of $\\x$ are possible). This makes the Bayes filter approach more tractable because the integrals do not need to be computed over an infinite set.\n\nIn the discrete Bayes filter the belief $bel(\\x_{t})$ is represented using a probability mass function rather than a probability density function (as is the case with the \\textit{continuous} Bayes filter). In particular, this probability mass function is simply a finite collection of probabilities $\\{p_{k,t}\\}$ where $p_{k,t}$ is the probability associated with state $k$ at timestep $t$. The algorithm generally follows the exact procedure as the Bayes filter in Algorithm \\ref{alg:bayes}, but with summations replacing the integrals. In particular, the discrete Bayes filter algorithm is provided in Algorithm \\ref{alg:discretebayes}.\n\\begin{algorithm}[ht]\n \\KwData{$\\{p_{k,t-1}\\}, \\bu_{t}, \\z_{t}$}\n \\KwResult{$\\{p_{k,t}\\}$}\n \\ForEach{k}{\n  $\\overline{p}_{k,t}=\\sum_{i} p(\\x_{t}\\mid \\bu_{t}, \\x_{i})p_{i,t-1} $\\\\\n  $p_{k,t}=\\eta p(\\z_{t}\\mid \\x_{k})\\overline{p}_{k,t}$\\\\\n }\n \\Return $p_{k,t}$\n \\caption{Discrete Bayes Filter Algorithm}\n \\label{alg:discretebayes}\n\\end{algorithm}", "meta": {"hexsha": "22f8220ffbdf5a8758c7bcb538b70dc35634a438", "size": 25900, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/source/ch13.tex", "max_stars_repo_name": "StanfordASL/Principles-of-Robot-Autonomy", "max_stars_repo_head_hexsha": "852ce0fd1361d95576f72558d2c29d8610ced652", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-03-23T16:03:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-10T14:15:38.000Z", "max_issues_repo_path": "tex/source/ch13.tex", "max_issues_repo_name": "StanfordASL/Principles-of-Robot-Autonomy", "max_issues_repo_head_hexsha": "852ce0fd1361d95576f72558d2c29d8610ced652", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/source/ch13.tex", "max_forks_repo_name": "StanfordASL/Principles-of-Robot-Autonomy", "max_forks_repo_head_hexsha": "852ce0fd1361d95576f72558d2c29d8610ced652", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 98.1060606061, "max_line_length": 1116, "alphanum_fraction": 0.7642857143, "num_tokens": 6511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.426528841281276}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage[utf8]{luainputenc}\n\\usepackage{aeguill}\n\\usepackage{setspace}\n\n\\tikzstyle{edge} = [fill,opacity=.5,fill opacity=.5,line cap=round, line join=round, line width=50pt]\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\pgfdeclarelayer{background}\n\\pgfsetlayers{background,main}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{17 avril, 2015}\n\\maketitle\n9.4 chromatic plynomials\n\nthe chromatic poly counts the number of \\lambda-colorings of a graph $G$\n\nnotation $P(G,\\lambda)$\n\npolynomial starts at zero and then becomes positive. once positive it's positive forever. discrete poly (integer), not continuous.\n\nleading coefficient is positive from end ending positive\n\nzeros are factors\n\ntwo colorings $C, C'$ are distinct if $\\exists v\\in V(G)$ such that $C(v)\\ne C'(v)$\n\nexample:\n\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { 1 -- {2 -- 3} -- 1 --4--3}\n  [shift=(0:1)];\n\nlet $\\lambda=6$. how many ways can we color $G$ with 6 colors? 1 has 6, 3 has 5, 4 choices for 2 and 4. so 480.\n\nwe have shown:\n\n$P(G,6)=480$ \n\nthe enumeration of choices above, we can get $P(G,\\lambda)=\\lambda(\\lambda-1)(\\lambda-2)^2$\n\n\\subsubsection*{properties}\nthat should make sense\n\\begin{enumerate}\n\\item\nchromatic number: $\\chi(G)=3$\n\\item\nwhat is the smallest $\\lambda$ such that $P(G,\\lambda)>0$? 3o\n\\item\nconvention: $P(G,0)=0\\forall G$\n\\end{enumerate}\n\nformally, if $P(G,\\lambda)$ is the chrompoly of $G$ then $\\chi(G)=\\min\\limits_\\lambda(P(G,\\lambda)>0)$\n\n\\subsubsection*{exercise}\nfind the $P(K_n,\\lambda)$\n\n$P(K_3,\\lambda)=\\lambda(\\lambda-1)(\\lambda-2)$\n\n$P(K_4,\\lambda)=\\lambda(\\lambda-1)(\\lambda-2)(\\lambda-3)$\n\n$P(K_n,\\lambda)=\\prod\\limits_{i=0}^{n-1}(\\lambda-i)=\\frac{\\lambda!}{(\\lambda-n)!}$\n\n\nif $E_n$ is the empty graph (no edges) on $n$ vertices $P(E_n,\\lambda)=\\lambda^n$\n\n\\subsubsection*{exercise}\n$P(C_4,\\lambda)$\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { 1 -- 2 -- 3 -- 4--1 }\n  [shift=(0:1)];\n\n  $P(C_4,\\lambda)=\\lambda(\\lambda-1)^2(\\lambda-2)$ unless the two adjacent to the starting count are the same then $\\lambda(\\lambda-1)^3$\n  \n  this leads to sums in $P(G,\\lambda)$ and so we have graph theoretically two options\n\\begin{enumerate}\n\\item\nif they are the same edge contraction\n\\item\nif they are different then we can insert an edge with no change\n\\end{enumerate}\n\neither choice leads to  a complete graph\n\n\\section*{theorem}\nif $uv\\not\\in E(G)$ and $H$ is the graph $G+uv$ with $uv$ contracted, then $P(G,\\lambda)=P(G+uv,\\lambda)+P(H,\\lambda)$\n\nwe are going to draw graphs instead of using this notation\n\n\\subsubsection*{example}\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 1;2--3 --1--2;4--5;2--4;5--3};\n  =\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 1;2--3 --1--2;4--5;2--4;5--3;5--1};\n  +\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 2--3;4--5;2--4;5--3;5--2};\n\n=\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 1;2--3 --1--2;4--5;2--4;5--3;5--1};\n  +\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 2--3;4--5;2--4;5--3;5--2};\n+\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 2--3;4--5;2--4;5--3;5--2;4--3};\n+\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 3;4--3--5--4};\n\n$\\vdots$\n\n=\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 1;2--3 --1--2;4--5;2--4;5--3;5--1;4--3;5--2};\n  +\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 2--3;4--5;2--4;5--3;5--2;4--3};\n+\n$3\\cdot($\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 2--3;4--5;2--4;5--3;5--2;4--3};\n+\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph { 3;4--3--5--4};\n$)$\n\nhomework is $1,6,7$\n\\end{document}\n", "meta": {"hexsha": "9b0bf7a2e865e567bc8bd0186c1004510bf9ae67", "size": 4444, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-04-17.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-04-17.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-04-17.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6482758621, "max_line_length": 137, "alphanum_fraction": 0.6750675068, "num_tokens": 1666, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040617, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.42652883822835325}}
{"text": "%!TEX program = xelatex\r\n%!TEX root = ./thesis.tex\r\n\\chapter{Experiments}\\label{chap:experiments}\r\n\r\n% \\yan{How about using the title ``Evaluations''?}\r\n% No, thx.\r\n% \\yan{For grammar issues, do you mind using Grammarly \\textit{https://app.grammarly.com/} to check your document? Our lab often uses it when writing English papers.}\r\n% Yep, this whole thesis has already been revised on Grammarly.\r\n\r\nThe GreenEyes model is based on WaveNet and LSTM. Unlike computer vision models, which take 2D images as inputs, the GreenEyes model is trained on 1D sequential data arrays.\r\n\r\nTo build a data feeding pipeline, we built a slice data generator on the $PM_{2.5}$ IAQI data. Train data pairs as below are fed to the model:\r\n\r\n\\begin{equation}\r\n\\left\\{\r\n    \\begin{array}{l}\r\n    X_i=[D(t_i),D(t_{i+1}),...,D(t_{i+L-1})] \\\\\r\n    y_i=P(t_{i+L})\r\n    \\end{array}\r\n\\right.\r\n\\end{equation}\r\n\r\n% 实验目的是用window化的 IAQI 数据（注意是iaqi数据，不是原始pm数据）fit手动标注的 IAQI level\r\n\r\nWhere $D$ denotes the whole $PM_{2.5}$ IAQI data array, $P$ denotes the whole target function, i.e., the polygonized IAQI level we get in the last chapter. It is clear that our model takes a 1D array as input and outputs a scalar.\r\n\r\n$L$ denotes the length of the slice when we sample sequences from the $PM_{2.5}$ IAQI data, and $t_i$, $t_{i+1}$ etc. are the discrete-time points. Note that to make the model to be \\textbf{causal}, the target value $y_i$ in the train data pair is sampled at time point $t_{i+L}$, which is exactly next to the last time point in $X_i$.\r\n\r\nIn our experiment, as the total length of the $PM_{2.5}$ IAQI data is 219,989, setting different values for the length of the slice $L$ will firstly lead to variant input size for the GreenEyes model because the input size equals $L$, which will also make the number of training parameters larger or smaller. Secondly, as the length of the whole sequence data is limited, the larger $L$ is, the less the number of total train data is. Number of total train data is $(219,989-L+1)$.\r\n\r\nWe finally chose 7,200 as the length of the slice for the following reasons:\r\n\\begin{enumerate}\r\n    \\item 7,200 seconds equals 2 hours in the time axis, and we design the model to predict the next second's IAQI level by previous data within these 2 hours.\r\n    \\item The model's size (number of parameters, etc.) w.r.t. the input size of 7,200 is exactly appropriate both for learning and inferring.\r\n\\end{enumerate}\r\n\r\n\\section{Data Sampling and Splitting}\r\n\r\nAs described above, the number of total train data is $(219,989-L+1)$. When setting $L=7200$, it is 212,790, which is an enormous number when feeding the model. Hence, we introduced the sampling method and set stride when collecting train samples from the original data, and the size will be $\\frac{\\lfloor 219,989-L+1 \\rfloor}{stride}+1$. \r\n\r\nMoreover, we split the data into a training set and validation set, with a validation ratio of 0.2. The number of training/validation samples varies when stride varies. Out experiments use 10, 5, 2 as stride's value and Table \\ref{table:N_samples} illustrates the number of training/validation samples.\r\n\r\n\\begin{table}[!htbp]\r\n    \\centering\r\n    \\begin{tabular}{|l|l|l|l|l|}\r\n    \\hline\r\n    $L$ (The length of the slice) & Stride & $N_{samples}$ & $N_{train}$ & $N_{val}$ \\\\ \\hline\r\n    7200 & 10 & 21280  & 17024  & 4256  \\\\ \\hline\r\n    7200 & 5  & 42559  & 34048  & 8511  \\\\ \\hline\r\n    7200 & 2  & 106396 & 85117  & 21279 \\\\ \\hline\r\n    \\end{tabular}\r\n    \\caption{The relationship between different strides and number of samples.}\r\n    \\label{table:N_samples}\r\n\\end{table}\r\n\r\nFigure \\ref{fig:model_feeding_pipeline} shows the model feeding pipeline of our GreenEyes model during training.\r\n\r\n\\begin{figure}[!htbp]\r\n    \\centering\r\n    \\includegraphics[width=2.9in]{graphs/data_slicing.pdf}\r\n    \\caption{Data feeding pipeline when training.}\r\n    \\label{fig:model_feeding_pipeline}\r\n\\end{figure}\r\n\r\n\\section{Sensor Data Augmentation}\r\n\r\nAs brought out before, we believe that with more data together, the model could learn better. Though these four data channels differ a little from each other, they approximately follow the same distribution. Hence, besides training the model on every single channel of \\text{$PM_{2.5}$} data, we also \\textbf{combined} all these channels' data together and fed it. The corresponding data is called \\text{$PM_{2.5}$ (All)}.\r\n\r\n\\section{Experiments}\r\n% 描述实验的组别，个数\r\nAs we sampled $PM_{2.5}$ data from 4 sensors, Sensor 0 to Sensor 3, so we have four channels of $PM_{2.5}$ IAQI data, and there are three different stride values. Finally, we have 12 experiments. Besides, we have a group of augmentation experiments in which all four sensors' data are fed to the model, yielding another three experiments.\r\n% LR 配置\r\nFor each experiment, We optimized our GreenEyes model using Adam \\cite{kingma2017adam} an initial learning rate of 0.0001, which is multiplied by 0.1 after 20 epochs. We trained our model to 100 epochs for each experiment.\r\n% Loss 配置\r\nWe used mean squared error (MSE) as a loss metric and recorded mean absolute error (MAE). They are defined by equations below:\r\n\r\n\\begin{equation}\r\n    MSE(p, y)=E((p_i-y_i)^2)\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n    MAE(p, y)=E(|p_i-y_i|)\r\n\\end{equation}\r\n\r\nWhere $p$ is the prediction sequence and $y$ is the polygonized $PM_{2.5}$ IAQI sequence.\r\n\r\n% four metrics, mean squared error (MSE), mean absolute percentage error (MAPE), mean squared logarithmic error (MSLE).\r\n\r\n\\subsection{Training and Validation} % 15 experiments\r\n\r\n\\subsubsection{Training Loss Curves}\r\n\r\nFigure \\ref{fig:training_mse} and Figure \\ref{fig:val_mse} illustrate the training MSE curves and validation MSE curves respectively. It is observed that our system can fit the data well.\r\n% \\yan{Add a conclusion. } \\yan{It is observed our system can xxx.}\r\n\r\n% \\yan{By the way, does your institution require inserting PDF figures?}\r\n\r\n\\begin{figure}[!htbp]\r\n    \\centering\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/train_curves_stride_10.pdf}\r\n        \\caption{stride=10.}\r\n        \\label{fig:train_stride_10}\r\n    \\end{subfigure}\r\n    \\hfill\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/train_curves_stride_5.pdf}\r\n        \\caption{stride=5.}\r\n        \\label{fig:train_stride_5}\r\n    \\end{subfigure}\r\n    % \\hfill\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/train_curves_stride_2.pdf}\r\n        \\caption{stride=2.}\r\n        \\label{fig:train_stride_2}\r\n    \\end{subfigure}\r\n\\caption{Training MSE curves.}\r\n\\label{fig:training_mse}\r\n\\end{figure}\r\n\r\n\\begin{figure}[!htbp]\r\n    \\centering\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/val_curves_stride_10.pdf}\r\n        \\caption{stride=10.}\r\n        \\label{fig:val_stride_10}\r\n    \\end{subfigure}\r\n    \\hfill\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/val_curves_stride_5.pdf}\r\n        \\caption{stride=5.}\r\n        \\label{fig:val_stride_5}\r\n    \\end{subfigure}\r\n    % \\hfill\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/val_curves_stride_2.pdf}\r\n        \\caption{stride=2.}\r\n        \\label{fig:val_stride_2}\r\n    \\end{subfigure}\r\n\\caption{Validation MSE curves.}\r\n\\label{fig:val_mse}\r\n\\end{figure}\r\n\r\n% 讨论一个 Sensor，其它的放附录\r\n% For Sensor 0, we fed the model with three different stride values. Figure\r\n% the learning curves\r\n% after the learning rate changes at the 20th epoch\r\n% For more model training data, please refer to Appendix \\ref{chapter:other_model_training_data}\r\n% Figure \\ref{fig:model_training_mse_mae_msle} shows the training process. We can infer that the model is already saturated after 100 epochs.\r\n\r\n\\subsubsection{Training Best Metrics}\r\n\r\nAs we used MSE as loss, i.e., the supervising metric, we extracted minimum train MSE and minimum validation MSE from all the training epochs. These best metric results reflect the model's fitting capability. They are all rounded to 4 decimals. \r\n\r\n% We also record other metrics such as MAE during training.\r\n\r\nTable \\ref{table:best_metrics} lists each experiment's final best metrics during training.\r\n\r\n\\begin{table}[!htbp]\r\n    \\centering\r\n    \\begin{tabular}{|c|c|c|c|c|}\r\n        \\hline\\hline\r\n        Data & Stride & Minimum train MSE & Minimum validation MSE & ratio \\\\\\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(0)}} & 10 & 0.0223 & 0.0234 & 0.96 \\\\ \\cline{2-5} \r\n                                        & 5 & 0.0034 & 0.0114 & 0.30 \\\\ \\cline{2-5} \r\n                                        & 2 & \\textbf{\\textit{0.0006}} & \\textbf{\\textit{0.0035}} & 0.16 \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(1)}} & 10 & 0.0486 & 0.0510 & 0.95 \\\\ \\cline{2-5} \r\n                                        & 5 & 0.0058 & 0.0142 & 0.41 \\\\ \\cline{2-5} \r\n                                        & 2 & \\textbf{\\textit{0.0006}} & \\textbf{\\textit{0.0036}} & 0.17 \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(2)}} & 10 & 0.0171 & 0.0187 & 0.92 \\\\ \\cline{2-5} \r\n                                        & 5 & 0.0024 & 0.0092 & 0.27 \\\\ \\cline{2-5} \r\n                                        & 2 & \\textbf{\\textit{0.0012}} & \\textbf{\\textit{0.0066}} & 0.19 \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(3)}} & 10 & 0.0509 & 0.0468 & 1.09 \\\\ \\cline{2-5} \r\n                                        & 5 & 0.0074 & 0.0167 & 0.44 \\\\ \\cline{2-5} \r\n                                        & 2 & \\textbf{\\textit{0.0010}} & \\textbf{\\textit{0.0068}} & 0.15 \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(All)}} & 10 & 0.0068 & 0.0103 & 0.66 \\\\ \\cline{2-5} \r\n                                        & 5 & 0.0014 & 0.0022 & 0.67 \\\\ \\cline{2-5} \r\n                                        & 2 & \\textbf{0.0007} & \\textbf{0.0009} & 0.77 \\\\\r\n        \\hline\r\n        \\hline\r\n    \\end{tabular}\r\n    \\caption{Experiments' final best metrics.}\r\n    \\label{table:best_metrics}\r\n\\end{table}\r\n\r\nWe also define a generalization coefficient ratio as the equation below to measure the model's generalization capability during certain experiments. The larger the ratio,  the better the generalization capability is. The ratio results are rounded to 2 decimals.\r\n\r\n\\begin{equation}\r\n    ratio=\\frac{min(train\\ MSE)}{min(validation\\ MSE)}\r\n\\end{equation}\r\n\r\n\\subsection{Model Evaluation}\r\n\r\n% Evaluation curves\r\n\\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=\\linewidth]{fig/model_eval_pm25_0_stride_10.png}\r\n    \\caption{Evaluation of the GreenEyes model (\\text{$PM_{2.5} (0)$}, stride=10).}\r\n    \\label{fig:model_eval_pm25_0_stride_10}\r\n\\end{figure}\r\n\r\nAs earthquake prediction aims to fit the model and learn time-series information, i.e., the triangular lines in coordination with the acoustic data, our model also fits the level lines regarding their air pollutant concentration data. Figure \\ref{fig:model_eval_pm25_0_stride_10} proves that the model fits the labeled IAQI level lines well, except that its predictions differ from the ground truth a little on some parts of the lines, and especially on the turning corners of the piecewise linear function.\r\n\r\n% Test results table here.\r\nTo quantify the testing results of our model by different parameters, we tested it on the whole $PM_{2.5}$ sequence by setting stride as 1, which is different from the training config. As stride is set to 1, the slice window will move one point after another. Hence, the model can make the inference on the whole source sensor data. When the stride is set a 10, 5, and 2 for different training data sampling configs, these sampled data slices form a subset of the sliced data when the stride is set to 1.\r\n\r\nWe performed the tests using two metrics, mean square error (MSE) and mean absolute error (MAE).\r\n\r\nAnd we test all models trained under different stride parameters and on every channel of $PM_{2.5}$ data. Table \\ref{table:test_mse_mae} lists the statistics of our tests. Digit in the brackets is the channel number. \"All\" means the model is trained by all channels together. All result values of MSE have rounded four decimals, and all MAE values are rounded to 2 decimals.\r\n\r\n\\begin{table}[!htbp]\r\n    \\centering\r\n    \\begin{tabular}{|c|c|c|c|}\r\n        \\hline\\hline\r\n        Data & Stride & MSE & MAE \\\\\\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(0)}} & 10 & 0.0266 & 0.13 \\\\ \\cline{2-4} \r\n                                        & 5 & 0.0144 & 0.11 \\\\ \\cline{2-4} \r\n                                        & 2 & \\textbf{\\textit{0.0037}} & \\textbf{\\textit{0.05}} \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(1)}} & 10 & 0.0517 & 0.18 \\\\ \\cline{2-4} \r\n                                        & 5 & 0.0113 & 0.10 \\\\ \\cline{2-4} \r\n                                        & 2 & \\textbf{\\textit{0.0036}} & \\textbf{\\textit{0.05}} \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(2)}} & 10 & 0.0188 & 0.11 \\\\ \\cline{2-4} \r\n                                        & 5 & 0.0092 & 0.09 \\\\ \\cline{2-4} \r\n                                        & 2 & \\textbf{\\textit{0.0069}} & \\textbf{\\textit{0.07}} \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(3)}} & 10 & 0.0501 & 0.16 \\\\ \\cline{2-4} \r\n                                        & 5 & 0.0108 & 0.09 \\\\ \\cline{2-4} \r\n                                        & 2 & \\textbf{\\textit{0.0070}} & \\textbf{\\textit{0.07}} \\\\ \\hline\r\n        \\multirow{3}{*}{\\text{$PM_{2.5}$(All)}} & 10 & 0.0118 & 0.09 \\\\ \\cline{2-4} \r\n                                        & 5 & 0.0026 & 0.04 \\\\ \\cline{2-4} \r\n                                        & 2 & \\textbf{0.0010} & \\textbf{0.02} \\\\ \\hline\r\n        \\hline\r\n        \\hline\r\n\r\n    \\end{tabular}\r\n    \\caption{Test MSE and MAE under different strides.}\r\n    \\label{table:test_mse_mae}\r\n\\end{table}\r\n\r\nThe data on the table shows that for each channel of $PM_{2.5}$ data, the smaller the stride parameter is, the less the MSE and MAE are, which means the model can fit the target better. This is reasonable and consistent with our intuition.\r\n\r\nMeanwhile, when put all channels' data together and feed the model, it can learn the best result.\r\n\r\nFigure \\ref{fig:test_mse} and Figure \\ref{fig:test_mae} respectively present the test MSE and MAE results by bar plots. The plots are divided into three stride groups, which's stride is 10, 5, 2. Results from the different data channels (or all channels of the data) but sharing the same stride join into the same group for comparisons.\r\n\r\n\\begin{figure}[!htbp]\r\n    \\centering\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/test_mse.pdf}\r\n        \\caption{Test MSE.}\r\n        \\label{fig:test_mse}\r\n    \\end{subfigure}\r\n    \\begin{subfigure}[!htbp]{.45\\textwidth}\r\n        \\centering\r\n        \\includegraphics[width=\\textwidth]{fig/results/test_mae.pdf}\r\n        \\caption{Test MAE.}\r\n        \\label{fig:test_mae}\r\n    \\end{subfigure}\r\n    \\caption{Test MSE and MAE.}\r\n    \\label{fig:test_mse_mae}\r\n\\end{figure}\r\n\r\n\\subsection{Results Analyses}\r\n\r\nFrom the results table and bar plots, we could draw at least two useful and meaningful conclusions. Firstly, for each kind of data, whichever $PM_{2.5}$ (i) or $PM_{2.5}$ (All), when the stride parameter decreases, the model can outcome better results.\r\n\r\nSecondly, in each stride group, $PM_{2.5}$ (All)'s performance surpasses every single channel of $PM_{2.5}$ data, w.r.t. both MSE and MAE. And when the stride is 5 or 2, this conclusion is more significant.\r\n\r\nThe first conclusion is obvious. As Table \\ref{table:N_samples} shows, the smaller the stride is, the number of training samples gets larger. More data will result in a better model's fitting performance. However, while we want the model to predict and fit more precisely, we don't want to sample sliced data from original data flow too frequently (set the stride too small). The model's capability is reflected by its relevant fitting results (MSE, MAE, etc.), while a rather less frequent sampling is configured (e.g., set stride to 10, not 2).\r\n\r\nFor our GreenEyes model, the evaluation curve in Figure \\ref{fig:model_eval_pm25_0_stride_10} shows its fitting capability, as stride 10 is already enough.\r\n\r\nDuring application, we could trade off on this stride parameter to balance the model's performance and the computation costs.\r\n", "meta": {"hexsha": "560fad021a73602207f15a595e9e4a5d3aacd453", "size": 16605, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/c6-experiments.tex", "max_stars_repo_name": "AI-Huang/HKUST_PhD_MPhil_Thesis_LaTeX", "max_stars_repo_head_hexsha": "e528d684b13c16401c31da1cad5e75f5c425a4d6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/c6-experiments.tex", "max_issues_repo_name": "AI-Huang/HKUST_PhD_MPhil_Thesis_LaTeX", "max_issues_repo_head_hexsha": "e528d684b13c16401c31da1cad5e75f5c425a4d6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/c6-experiments.tex", "max_forks_repo_name": "AI-Huang/HKUST_PhD_MPhil_Thesis_LaTeX", "max_forks_repo_head_hexsha": "e528d684b13c16401c31da1cad5e75f5c425a4d6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.3035714286, "max_line_length": 547, "alphanum_fraction": 0.6591990364, "num_tokens": 4797, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4265288285365704}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Wednesday\\\\ 2020-11-4, \\\\ compiled \\\\ \\today}\n\nWe were discussing the flow of plasma from the donor star to the compact object through the inner Lagrangian point.\nThe velocities of the compact object in the frame of the gas are \\(v_\\parallel \\sim \\SI{10}{km/s}\\) and \\(v_\\perp \\sim \\SI{100}{km/s}\\), so we neglect \\(v_{\\parallel}\\).\n\nSuppose we have a mass \\(M\\), and a particle in a bound orbit around this mass.\nIts energy \\(E\\) and energy per unit mass \\(\\epsilon \\) will be \n%\n\\begin{align}\nE = - \\frac{GMm}{2a} && \\epsilon = - \\frac{GM}{2a} \n\\,,\n\\end{align}\n%\nwhile its specific angular momentum will be (in terms of the eccentricity \\(e\\)):\n%\n\\begin{align}\n\\qty( \\frac{L}{m})^2 = \\ell^2 = (1 - e^2) GMa\n\\,.\n\\end{align}\n\nThen, we can write the semimajor axis as \n%\n\\begin{align}\n\\frac{1}{a} = \\frac{(1-e^2) GM}{\\ell^2}\n\\,,\n\\end{align}\n%\nso the specific energy will read\n%mk\n\\begin{align}\n\\epsilon = - \\frac{GM (1-e^2) GM}{2\\ell^2}= - \\frac{(GM)^2(1-e^2)}{2 \\ell^2}\n\\,.\n\\end{align}\n\nWe can ask ourselves: what is the orbit which has the minimum energy \\(\\epsilon _{\\text{min}}\\) at fixed \\(\\ell\\)? The only thing which can vary is the eccentricity \\(e\\), so the minimum energy is attained for the circular orbit, with \\(e = 0\\), where \n%\n\\begin{align}\n\\epsilon _{\\text{min}} = -\\frac{(GM)^2}{2 \\ell^2}\n\\,.\n\\end{align}\n\nThe stream of gas will be subjected to frictional forces, which will dissipate energy, and since the energy of circular orbits is minimum this will circularize the orbit. \nWe will discuss the timescale of this process later.\n\nWe can estimate the radius of circularization, \\(R _{\\text{circ}}\\): we know that for a circular orbit the angular momentum will reach its Keplerian value, \\(L_k\\), and the velocity will reach its Keplerian value. \nThis reads \n%\n\\begin{align}\nv_K = \\sqrt{ \\frac{GM}{R}} \n\\,,\n\\end{align}\n%\nwhich comes from equating \\(v^2 /R\\) and \\(GM/ R^2\\).\nThe Keplerian (specific!) angular momentum reads \n%\n\\begin{align}\nL_K = R v_K \n\\,,\n\\end{align}\n%\nwhich we can compute at \\(R _{\\text{circ}}\\): \n%\n\\begin{align}\nL_K (R _{\\text{circ}}) = \\sqrt{GM R _{\\text{circ}}}\n\\,.\n\\end{align}\n\nIf we fix the specific angular momentum \\(\\ell\\) of an incoming fluid parcel we can then determine the radius of its orbit, \\(R _{\\text{circ}} = \\ell^2 / GM\\). \n\nWe can compute this initial value of \\(\\ell\\) since the velocity of the fluid is given by the \\(v_{\\perp} = \\omega b_1 \\), and then \\(\\ell = v_\\perp b_1 = \\omega b_1^2\\). \nThen, finally, we have \n%\n\\begin{align}\nR _{\\text{circ}} = \\frac{\\omega^2 b_1^{4}}{GM} = \\frac{4 \\pi^2 b_1^{4}}{GM P^2}\n\\,.\n\\end{align}\n\nIn units of the orbital separation, and using Kepler's law \n%\n\\begin{align}\n\\omega^2 = \\frac{G (M_1 + M_2 )}{a^3}\n\\,\n\\end{align}\n%\nwe get (now denoting, more specifically, as \\(M_1 \\) the mass we previously just called \\(M\\)):\n%\n\\begin{align}\n\\frac{R _{\\text{circ}}}{a} &= \\frac{\\omega^2 b_1^{4}}{GM_1  a}  \\\\\n&= \\frac{b_1^{4} G (M_1 + M_2 )}{GM_1 a^{4}} = \\qty(\\frac{b_1 }{a})^{4} (1 + q)\n\\,.\n\\end{align}\n\nYesterday we saw that \\cite[]{frankAccretionPowerAstrophysics2002}:\n%\n\\begin{align}\n\\frac{b_1 }{a} \\approx \\num{.5} - \\num{.227} \\log q\n\\,,\n\\end{align}\n%\nusing which we get \n%\n\\begin{align}\n\\frac{R _{\\text{circ}}}{a} \\approx \\qty(\\num{.5} - \\num{.227} \\log q)^{4} (1+q)\n\\,,\n\\end{align}\n%\nand we can also calculate the radius of the Roche lobe by inverting a result from yesterday (with \\(q \\to 1/q\\)): \n%\n\\begin{align}\n\\frac{R_1}{a} = \\begin{cases}\n    \\num{.38} -\\num{.2} \\log q & \\num{.05} < q < 2 \\\\\n    \\frac{\\num{.426}}{(1 + q)^{1/3}} & q > 2\n\\end{cases}\n\\,.\n\\end{align}\n\nWe can then see that \\(R _{\\text{circ}}\\) is at least 10 times smaller than the radius of the lobe.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/roche-vs-circularization}\n\\caption{Roche lobe of star 1 versus circularization radius; both are plotted as \\(R / a\\).}\n\\label{fig:roche-vs-circularization}\n\\end{figure}\n\nFor a star we would need to ensure that \\(R _{\\text{circ}} > R_{*}\\), but for a compact object there are no issues.\n\n\\subsection{The accretion disk}\n\nParticles at their Keplerian velocities and radii around the compact object would keep orbiting, were it not for dissipative effects, which allow for energy and momentum to be transmitted throughout the disk.\n% If we had two concentric disks, both of which \n\nThere are three characteristic times we need to account for: \n%\n\\begin{align}\nt _{\\text{dyn}} < t _{\\text{rad}} < t _{\\text{visc}}\n\\,,\n\\end{align}\n%\nthe dynamical, radiative and viscous timescale. Injection happens on a short \\(t _{\\text{dyn}}\\) timescale, circularization happens on a longer \\(t _{\\text{rad}}\\) timescale, shrinkage happens on an even longer \\(t _{\\text{visc}}\\) timescale.\n\nThe true trajectory of a fluid element will be a spiral, which we can approximate with a succession of circles.\nThis is how an accretion disk forms. \n\nSince \\(M _{\\text{disc}} \\ll M_1 \\), the self-gravity of the accretion disk is negligible. Therefore, the azimuthal velocity of matter in the disk will closely match the Keplerian velocity \n%\n\\begin{align}\nv_{\\phi } = v_K = \\sqrt{ \\frac{GM_1}{R}}\n\\,.\n\\end{align}\n\nWe can already estimate the efficiency of the accretion process: the specific energy of the gas at the inner radius of the disk, \\(R _{\\text{in}}\\), which is the star radius for a NS and the ISCO for a BH. \nThe specific energy is \n%\n\\begin{align}\n\\epsilon (R _{\\text{in}}) = - \\frac{GM_1 }{R _{\\text{in}}} \n+ \\frac{1}{2} v_K^2 = - \\frac{1}{2} \\frac{GM_1 }{R _{\\text{in}}}\n\\,.\n\\end{align}\n\nThe variation of the energy can be calculated starting from infinity since \\(R_1 \\gg R _{\\text{in}}\\):\\footnote{This is a classical estimate, but it works well enough: for example, for a Schwarzschild BH we have calculated explicitly \\(\\epsilon _\\infty - \\epsilon (R _{\\text{in}}) = 1 - \\sqrt{8/9} \\approx \\SI{6}{\\percent}\\), while this expression would give \\(1/12 \\approx \\SI{8}{\\percent}\\). Not strictly correct, but in the right ballpark.}\n%\n\\begin{align}\n\\epsilon_{\\infty } - \\epsilon (R _{\\text{in}}) = \\frac{1}{2} \\frac{GM_1}{R _{\\text{in}}}\n\\,,\n\\end{align}\n%\ntherefore the luminosity of the disk will be \n%\n\\begin{align}\nL _{\\text{disc}}= \\frac{1}{2} \\frac{GM_1 }{R _{\\text{circ}}} \\dot{M} c^2\n\\,,\n\\end{align}\n%\nonly half of the accretion luminosity, defined as\n%\n\\begin{align}\nL _{\\text{acc}} = \\frac{GM_1 }{R _{\\text{in}}} \\dot{M} c^2\n\\,.\n\\end{align}\n\nNow we want to make more detailed predictions.\nA key point is viscosity: friction between the various gas elements.\n\nLet us consider two layers of the disk.\nThey will have a macroscopic bulk motion, with \\(v_\\phi = R \\Omega(R) \\),\nsuperimposed with a microscopic motion which can be at very small, up to mesoscopic scales. \nWe can have micro-scale motion of ions, but also\nmedium-scale structures can form: turbulent eddies, since the Reynolds number can be shown to be very large.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/turbulent-eddies-accretion}\n\\caption{Turbulent eddies moving.}\n\\label{fig:turbulent-eddies-accretion}\n\\end{figure}\n\nSuppose we have an eddy which starts in \\(A\\), moves radially, and then dissipates in \\(A'\\).\nFurther, let us say that the length scale of its motion is \\(\\lambda \\), and the typical velocity of its motion across the disk is \\(\\overline{v}\\). \n\nIts radius and velocity at \\(A\\) will be \\(R, \\Omega(R) \\times  R\\); at \\(A'\\) they will be \\(R + \\lambda \\) and still \\(\\Omega (R) \\times R\\). \n\nIn terms of specific angular momentum, when the eddy dies it will dissipate angular momentum \\((R+\\lambda) R \\Omega (R) \\).\n\nFor an eddy moving from \\(B\\) to \\(B'\\) in the opposite direction we will have \\(R (R + \\lambda ) \\Omega (R + \\lambda )\\). \nSince the motion is thermal, on average there will be as many particles going in both direction.\n\n% \\todo[inline]{But there is more volume at higher \\(R\\), so more matter!}\n\nSuppose that the height of the disk is \\(H\\): then the mass per unit time carried by the eddies will be \\(H 2 \\pi R \\overline{v} \\rho \\). \n\nThen, the variation of angular momentum will be \n%\n\\begin{align}\n\\frac{\\Delta L}{\\Delta t} &= 2 \\pi R H \\rho \\overline{v} \n\\qty[R (R + \\lambda ) \\Omega (R) - R (R+\\lambda ) \\Omega (R + \\lambda )]  \\\\\n&\\approx - 2 \\pi R^2 (R+ \\lambda ) H \\rho \\overline{v} \\dv{\\Omega }{R} \\lambda  \\\\\n&\\approx - 2\\pi R^3 H \\rho \\overline{v} \\lambda \\dv{\\Omega }{R}\n\\,,\n\\end{align}\n%\nand if we introduce the surface density of the disk: \n%\n\\begin{align}\n\\Sigma = \\int_{- H/2 }^{H/2} \\rho \\dd{z} \\approx \\rho H\n\\,\n\\end{align}\n%\nwe can write this torque as\n%\n\\begin{align}\n\\frac{ \\Delta L}{\\Delta t} = \\tau_{\\text{partial}} \\approx -2 \\pi R \\Sigma \\qty(\\overline{v} \\lambda ) R^2 \\dv{\\Omega }{R}\n\\,.\n\\end{align}\n\nFor a Keplerian accretion disk we always have \\(\\dv*{\\Omega }{R} < 0\\), since \\(\\Omega _K = \\sqrt{GM / R^3}\\): this means that the torque is positive.\nNote, however, that we are still only considering the effect on a certain layer of the one above it --- this is not the full picture yet.\n\nThis is the torque which the inner part of the disk exerts on the outer part, decelerating it. \nWe can then introduce a function \\(G(R) = - \\tau \\), the torque exerted by the outer part of the disk on the inner part, accelerating it. \n\nFor a given layer rotating at \\(R \\Omega (R)\\), the layers above it will try to accelerate it, while the ones below it will try to decelerate it. What will be the net effect? It will be\\footnote{We use the same letter \\(\\tau \\) as before, but we should specify that this time it accounts for all the contributions to a certain layer of the disk, while before it was only one-way.}\n%\n\\begin{align}\n\\tau =  G(R + \\dd{R}) - G(R) = \\dv{G}{R} \\dd{R}\n\\,.\n\\end{align}\n\nThese opposite effects will dissipate heat. \nThe differential work dissipated will be given by \n%\n\\begin{align}\n\\dd{W} = \\tau \\dd{\\phi } = \\dv{G}{R} \\dd{R} \\dd{\\phi }\n\\,,\n\\end{align}\n%\nso, since to a first approximation \\(G\\) can be taken to be a constant, the power will be \n%\n\\begin{align}\n\\dv{W}{t} = \\dv{G}{R} \\dd{R} \\Omega \n\\,.\n\\end{align}\n\nIntegrating to find the total power we get\n%\n\\begin{align}\n\\dot{E} &= \\int_{R _{\\text{in}}}^{R _{\\text{out}} } \\dv{G}{R} \\Omega \\dd{R} \n\\,,\n\\end{align}\n%\nbut we can integrate by parts to find \n%\n\\begin{align}\n\\dot{E} &= \\eval{G \\Omega }_{R _{\\text{in}}}^{R _{\\text{out}}}\n- \\int_{R _{\\text{in}}}^{R _{\\text{out}}} G \\dv{\\Omega }{R} \\dd{R} \n\\,,\n\\end{align}\n%\nso we can identify a global, \\emph{convective term}: the variation of \\(G \\Omega \\). On the other hand \\(G \\dv*{\\Omega }{R} \\dd{R}\\) is a local dissipation term. \n\nLet us introduce the radiated power per unit area of the disk (which is positive, we leave the minus sign out):\n%\n\\begin{align}\nD(R) = \\frac{ \\eval{\\dd{(\\dot{E})}}_{\\text{local}}}{2 \\times 2 \\pi R \\dd{R}}\n&= G \\dv{\\Omega }{R} \\frac{ \\dd{R}}{2 \\times 2 \\pi R \\dd{R}} = \\frac{G}{4 \\pi R} \\dv{\\Omega }{R} \\marginnote{Divided by 2 since the disk has two faces.} \n\\,.\n\\end{align}\n\nThis is written as \n%\n\\begin{align}\nD(R) = \\frac{G}{4 \\pi R} \\dv{\\Omega }{R}\n= \\frac{1}{2} R^2 \\overline{v} \\lambda \\Sigma \\qty(\\dv{\\Omega }{R})^2\n\\,.\n\\end{align}\n\nIn order to dissipate energy the differential rotation \\(\\dv*{\\Omega }{R}\\) is crucial. \n% We see next time that  \\(\\overline{v} \\lambda = \\nu \\), the kinematic viscosity coefficient.\n\n\\end{document}", "meta": {"hexsha": "09dadc222c8883bdca1d21ed4da2959c09378186", "size": 11365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/compact_objects/nov04.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/compact_objects/nov04.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/compact_objects/nov04.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 37.5082508251, "max_line_length": 443, "alphanum_fraction": 0.6700395952, "num_tokens": 3786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4265288245871633}}
{"text": "% !TEX root = ../thesis.tex\n\n\n\\chapter{Tests and Results}\n% \\label{cha:eva_tests_results}\n\nIn this chapter I will first present a few benchmarks. It is important for any simulation to be able to reproduce results that are predicted by theory. For this, I will test collision rates depending on temperature and scattering length as well as the relaxation of the cloud from an initial delta velocity distribution to a Maxwell-Boltzmann distribution. \n\nThen I am going to show how our proposed solution of a compressing box potential compares to similar setups with harmonic trapping configurations in terms of evaporation efficiency and final atom numbers.\n\n\n\\section{Benchmarks}\n\n\\subsection{Collision Rates}\n% Our first test is if the simulation can reproduce accurate collision rates that match the theoretical predictions. For the cross section given in \\cref{eq:crosssection}, we have to take the average \\meanProb over the Maxwell-Boltzmann distributions for both collision partners to find the mean collision rate.\n% \\begin{align*}\n%     \\meanProb &= \\iint \\multidiff{3}{c_1} \\multidiff{3}{c_2}\\; \\frac{8\\pi a^2\\crel}{1 + a^2 k^2} \\times n(\\vec{c}_1) n(\\vec{c}_2) \\\\\n%     &= \\frac{8\\pi a^2}{(2\\pi m \\kB T)^3}\\iint \\multidiff{3}{c_1} \\multidiff{3}{c_2}\\; \\frac{\\crel}{1 + a^2 k^2} \\exp\\!\\left(-\\frac{m(\\vec{c}_1^2 + \\vec{c}_2^2)}{2\\kB T}\\right) \n%     \\intertext{We can now change variables to centre-of-mass and relative coordinates and integrate out the angular part}\n%     &= (4\\pi)^2 \\frac{8\\pi a^2}{(2\\pi m \\kB T)^3}\\int_0^\\infty \\diff{\\crel}\\; \\crel^2 \\frac{\\crel}{1 + a^2 k^2} \\exp\\!\\left(-\\frac{m\\crel^2}{4\\kB T}\\right) \\nonumber \\\\\n%     &\\phantom{=} \\quad \\times \\int_0^\\infty \\diff{c_\\text{COM}}\\; c_\\text{COM}^2 \\exp\\!\\left(-\\frac{mc_\\text{COM}^2}{\\kB T}\\right) \\\\\n%     &= 4\\sqrt{\\pi} a^2 \\left(\\frac{m}{\\kB T}\\right)^\\frac{3}{2} \\int_0^\\infty \\diff{\\crel} \\frac{\\crel^2}{1 + a^2 \\frac{m^2 \\crel^2}{4\\hbar^2}} \\exp\\!\\left(-\\frac{m\\crel^2}{4\\kB T}\\right)\n%     \\intertext{where we have performed the integration over $c_\\text{COM}$ and used the relation $k = \\frac{m\\crel}{2\\hbar}$. Making the integral dimensionless and introducing the (also dimensionless) parameter $\\chi = \\sqrt{\\frac{\\hbar^2}{a^2 m \\kB T}}$ we find}\n%     &= 64\\sqrt{\\pi} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\int_0^\\infty \\diff{u}\\; \\frac{u^3}{\\chi^2 + u^2} \\exp(-u^2) \\\\\n%     &= 32\\sqrt{\\pi} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\left(1 + \\chi^2\\exp(\\chi^2)\\text{Ei}(-\\chi^2)\\right)\n%     \\intertext{where Ei is the exponential integral \\cite[Eq.~6.2.5]{NIST:DLMF}. Because $\\chi^2$ can be much larger than 1, for calculation on a computer it is better to express this using the confluent hypergeometric function $U$ \\cite[Eq.~13.2.6]{NIST:DLMF}:}\n%     \\meanProb &= 32\\sqrt{\\pi} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\left(1 + \\chi^2U(1,1,\\chi^2)\\right).\n% \\end{align*}\n% We can now use our previous result for the mean spatial density in an arbitrary power-law trap from \\cref{eq:spatial_density,eq:mean_density} to find the mean collision rate $\\langle\\Rcoll\\rangle$ as\n% \\begin{align*}\n%     \\langle\\Rcoll\\rangle &= \\langle n\\rangle \\meanProb \\\\\n%     &= 4\\sqrt{\\pi} \\frac{N}{x_0y_0z_0} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\left(1 + \\chi^2U(1,1,\\chi^2)\\right) \\times \\prod_{i\\in\\{x,y,z\\}}\\frac{1}{\\Gamma\\!\\left(1 + \\frac{1}{\\alpha_i}\\right)}\\left(\\frac{U_i}{2 \\kB T}\\right)^{\\frac{1}{\\alpha_i}}. \n% \\end{align*}\nOur first test is if the simulation can reproduce accurate collision rates that match the theoretical predictions. For the cross section given in \\cref{eq:crosssection}, we have to take the average \\meanProb over the Maxwell-Boltzmann distributions for both collision partners to find the mean collision rate. This calculation is done in \\cref{sec:appendix_average} and the result is\n\\begin{equation*}\n    \\meanProb = 32\\sqrt{\\pi} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\left(1 + \\chi^2U(1,1,\\chi^2)\\right),\n\\end{equation*}\nwhere\n\\begin{equation*}\n    \\chi = \\sqrt{\\frac{\\hbar^2}{a^2 m \\kB T}}\n\\end{equation*}\nis a dimensionless parameter that combines the scattering length $a$, the atomic mass $m$ and the temperature $T$. $U(1,1,\\chi^2)$ is one of the confluent hypergeometric functions \\cite[Eq.~13.2.6]{NIST:DLMF}.\n\nWe can now use our previous result for the mean spatial density in an arbitrary power-law trap from \\cref{eq:spatial_density,eq:mean_density} to find the mean collision rate $\\langle\\Rcoll\\rangle$ as\n\\begin{equation}\\label{eq:meancollisionrate}\n    \\langle\\Rcoll\\rangle = \\langle n\\rangle \\meanProb = 4\\sqrt{\\pi} \\frac{N}{x_0y_0z_0} \\cdot \\frac{a\\hbar}{m} \\cdot \\chi \\left(1 + \\chi^2U(1,1,\\chi^2)\\right) \\times \\prod_{i\\in\\{x,y,z\\}}\\frac{1}{\\Gamma\\!\\left(1 + \\frac{1}{\\alpha_i}\\right)}\\left(\\frac{U_i}{2 \\kB T}\\right)^{\\frac{1}{\\alpha_i}}. \n\\end{equation}\n\nTo validate the accuracy of the simulation, we test this for different scattering lengths and temperatures. We choose a (near) box potential with $\\alpha_x = \\alpha_y = \\alpha_z = 1000$, side lengths of \\SI{1}{mm} in all directions and a potential depth of $U_0 = \\SI{e-26}{J} \\sim \\SI{725}{\\micro\\kelvin}\\times\\kB$. The atomic mass is set to \\SI{87}{u}. We start each of the simulations with \\num{4e8} atoms in a $(\\num{0.995} \\times \\num{0.995} \\times \\num{0.995})\\, \\si{\\milli\\meter\\cubed}$ cube with uniform density distribution, let them reach a steady state by waiting for 3 initial mean collision times and then let the simulation continue until 100 initial mean collision times have been elapsed.\n\nThe statistic weight is \\num{32768}, meaning \\num{12207} particles are simulated. The timestep is 1/50 of the mean collision time and for this test, the loss coefficients $K_{1,2,3}$ are all set to 0. The results are shown in \\cref{fig:evap_test_rates} and the measured rates fit the prediction very well. Over all conducted tests, the maximum deviation of the measured from the theoretically predicted rate was \\SI{.784}{\\percent}, with an average of just \\SI{.414}{\\percent}.\n\n\\vfill\n\\begin{figure}[hbp]\n    \\centering\n    \\includegraphics[]{Evap/CollisionRates}\n    \\caption[Collision rate variation with temperature and scattering length]{\\num{4e8} atoms are simulated in an approximate box potential with a volume of $\\sim\\!\\SI{1}{\\milli\\meter\\cubed}$ at different values of the scattering length $a$ and temperature $T$. The collision time is averaged over 100 initial mean collision times and compared to the theoretical result from \\cref{eq:meancollisionrate}. The maximum deviation was measured to be \\SI{.784}{\\percent}.}\n    \\label{fig:evap_test_rates}\n\\end{figure}\n\\vfill\n\n\n\\subsection{Thermal Relaxation}\nNext, we initialise a cloud of \\num{3e8} atoms in the same potential as before and with a scattering length of $a = 100\\, a_0$. The kinetic temperature is set to $T=\\SI{20}{\\micro\\kelvin}$, but every particle is given the same speed initially. We record the speeds of every particle present for 10 initial mean collision times ${\\langle \\tau\\rangle}_\\text{i}$ and average the resulting speed distribution over 50 separate runs. The results are shown in \\cref{fig:evap_relaxation}. After $\\num{8.5}\\,{\\langle \\tau\\rangle}_\\text{i}$, the resulting speed distribution matches the expected Maxwell-Boltzmann distribution.\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[]{Evap/Relaxation}\n    \\caption[Relaxation to a Maxwell-Boltzmann distribution]{The simulation is initialised with \\num{3e8} atoms that all start with the same speed. Over a total of 10 initial mean collision times, the relaxation of the speeds to a Maxwell-Boltzmann distribution is observed.}\n    \\label{fig:evap_relaxation}\n\\end{figure}\n\n% \\subsection{Internal Energy per Atom}\n% Our last test analyses the energy per particle. From the theoretical analysis, we expect \\[\\tilde{E} = \\xi kB T, \\quad \\xi = \\frac{3}{2} + \\frac{1}{\\alpha_x} + \\frac{1}{\\alpha_y} + \\frac{1}{\\alpha_z}\\] per particle in a power-law potential with exponents $\\alpha_{x,y,z}$.\n% We let \\[\\alpha_x = \\alpha_y = \\alpha_z \\equiv \\alpha,\\quad 1 \\leq \\alpha \\leq 100.\\] The starting conditions are: \\todo[inline]{atom number, density, temperature} and we let the system reach equlibrium in \\dots initial mean collision times, before we measure the energy per particle. The results of this can be seen in Figure~\\todo{ref}. Again, we see excellent agreement with the theoretical prediction.\n\n\n\\section{Efficient Evaporation in a Box}\n\\label{sec:eva_test}\nWe now move on to test the proposed evaporation in a box potential. The simulation is partly based on the assumption that the atoms have been cooled to a high starting phase space density before the evaporation sequence. This goes hand in hand with our initial concept for evaporation in a box. Usually, atoms are pre-cooled before evaporative cooling in an optical dipole trap is carried out. It has been shown that $\\Lambda$-enhanced grey molasses cooling is possible on the D2 line of $^{87}$Rb \\cite{Rosi2018enhancedGM}. Here, a final phase space density of \\num{4e-6} was achieved at a temperature of \\SI{4}{\\micro\\kelvin}, corresponding to a density of \\SI{4.9e9}{\\per\\centi\\meter\\cubed}. Starting from a density this low would be disadvantageous for evaporative cooling as it would incur high thermalisation times. Compressing the cloud however would heat the atoms again. Grey molasses cooling is mainly limited by time as the cloud can expand freely and is subject to gravity. With our proposed concept of a box potential, the cloud would not be able to expand indefinitely, given that the trap depth is high enough to contain the falling atoms. We could then repeatedly compress the gas and cool it again. Such an alternating cycle of compression and cooling has already been demonstrated with $^{85}$Rb using a near-resonant dark optical lattice, leading to a density of \\SI{1.2e12}{\\per\\centi\\meter\\cubed} with a temperature of \\SI{10}{\\micro\\kelvin}, equivalent to a phase space density of \\num{2.6e-4} \\cite{PhysRevA.72.043410}. \n\nFor the simulation, we use a box potential created from two ring beams that intersect each other at an angle. The functional form of this potential is\n\\begin{equation} \\label{eq:eva_potential}\n    U(\\vec{r}) = U_0 \\left[ \\left( \\frac{\\sqrt{(-\\sin(\\frac{\\alpha}{2})x + \\cos(\\frac{\\alpha}{2})y)^2 + z^2}}{R} \\right) ^ P + \\left( \\frac{\\sqrt{(\\sin(\\frac{\\alpha}{2})x + \\cos(\\frac{\\alpha}{2})y)^2 + z^2}}{R} \\right) ^ P \\right]\n\\end{equation}\nwhere $\\alpha$ is the angle between the beams, $R$ is the radius of the ring and the exponent $P$ is given by $P = \\num{87}$. This specific value was chosen following the results of Hueck et al.~\\cite{PhysRevLett.120.060402}, where it was demonstrated that a ring beam made by using an axicon can be focused to achieve a power law potential with a similar exponent. \n\\Cref{fig:steinmetz_solid} shows the outline of the potential for the angles $\\alpha=\\SI{90}{\\degree}$ and $\\alpha=\\SI{157.5}{\\degree}$. The latter case is the configuration that will be used in the experiment and therefore also in the simulation below.\n\\vfill\n\\begin{figure}[htbp]\n    \\centering\n    \\begin{subfigure}[b]{.49\\textwidth}\n        \\centering\n        \\input{TexContents/Figures/Evap/BoxTrapEvaporation/Steinmetz1.tikz}\n        \\caption{$\\alpha = \\SI{90}{\\degree}$}\n    \\end{subfigure}\n    \\begin{subfigure}[b]{.49\\textwidth}\n        \\centering\n        \\input{TexContents/Figures/Evap/BoxTrapEvaporation/Steinmetz2.tikz}\n        \\caption{$\\alpha = \\SI{157.5}{\\degree}$}\n    \\end{subfigure}\n    \\caption[Common volume of two crossed cylinders]{It is important to note that the shapes shown here do not represent an equipotential surface of \\cref{eq:eva_potential}. Instead, they simply show the intersection of two cylinders at the two different angles.}\n    \\label{fig:steinmetz_solid}\n\\end{figure}\n\\vfill\n\n% \\begin{figure}[htbp]\n%     \\centering\n%     \\begin{subfigure}[b]{.49\\textwidth}\n%         \\centering\n%         \\includegraphics[trim=0 1.7ex 0 6ex,clip]{Evap/SteinMetzPython}\n%         \\caption{\\SI{90}{\\degree}}\n%     \\end{subfigure}\n%     \\begin{subfigure}[b]{.49\\textwidth}\n%         \\centering\n%         \\includegraphics[trim=0 1.7ex 0 6ex,clip]{Evap/SteinMetzPython_Angle}\n%         \\caption{\\SI{157.5}{\\degree}}\n%     \\end{subfigure}\n%     \\caption{Common volume of two crossed cylinders}\n%     \\label{fig:steinmetz_solid}\n% \\end{figure}\n\n\\subsubsection*{Parameter Optimisation}\nFor all cases, we use a simple optimisation scheme. \nThe initial beam radius is fixed to \\SI{360}{\\micro\\meter} and the initial trap depth is given by $\\SI{50}{\\micro\\kelvin}\\times \\kB$. We then employ only one exponential ramp for the beam radius and the potential depth where we compress the beam to a final radius of \\SI{25}{\\micro\\meter} and a final trap depth of $\\SI{450}{\\nano\\kelvin}\\times \\kB$:\n\\begin{equation*}\n    X(t) = \\frac{X_\\text{f} - X_\\text{i}}{\\euler^{-t_\\text{d}/\\tau} - 1} \\times \\left(\\euler^{-t/\\tau} - 1\\right) + X_\\text{i}.\n\\end{equation*}\nHere, $X$ is the parameter to which the ramp is applied, $X_\\text{i,f}$ are the initial and final values before and after the ramp, $t_\\text{d}$ is the duration of the ramp and $\\tau$ is the exponential time constant.\nAfter an initial coarse search of the available parameter space for $t_\\text{d}$ and $\\tau$ for both parameters, we choose the values that yield the highest possible evaporation efficiency\n\\[\n    \\gamma = -\\frac{\\log(\\tilde{\\rho}_\\text{f}/\\tilde{\\rho}_\\text{i})}{\\log(N_\\text{f}/N_\\text{i})},\n\\]\nwith the initial and final values for the phase space density $\\tilde{\\rho}_\\text{i/f}$ and atom number $N_\\text{i/f}$. Then we go on to vary all three parameters ($t_\\text{d}$, $\\tau$ for the radius $R$ and the trap depth $U_0$) in a smaller range around the previous optimum and try to find an improvement. \n\nIf a phase space density of $\\PSD = 1$ is reached, the simulation is stopped prematurely because it is purely classical and results at higher phase space densities are not valid anymore. \n\n\\subsubsection*{Starting Conditions}\nWe simulate different initial phase space densities ranging from \\num{5e-6} to \\num{e-3} with atom numbers from \\num{2e8} to \\num{3e7} as well as temperatures from \\SI{10}{\\micro\\kelvin} down to \\SI{2.5}{\\micro\\kelvin} for the highest phase space density. We initialise the particles with a harmonic density distribution, where the RMS radius can be calculated from the peak phase space density, the atom number and the temperature.\nThis gives us a range of estimates on how effective this cooling method could be for different starting conditions and we will be able to tell how much pre-cooling is necessary for good results.\nThe cases with their respective fixed parameters are shown in \\cref{tab:evap_cases}.\n\\begin{table}[bp]\n    \\centering\n    \\caption[Initial parameters for the simulated cases]{$\\hat{\\PSD}$ and $\\hat{n}$ are the initial peak phase space and spatial densities, respectively. $\\sigma$ is the RMS radius of the initially harmonic cloud.}\n    \\begin{tabular}{cS[table-format=1.1e-1]S[table-format=1.2]S[table-format=2.1]S[table-format=3]S[table-format=1.1e+2]}\n        \\toprule\n        \\# & \\multicolumn{1}{c}{$\\hat{\\PSD}$} & \\multicolumn{1}{c}{$N/\\num{e8}$} & \\multicolumn{1}{c}{$T$/\\si{\\micro\\kelvin}} & \\multicolumn{1}{c}{$\\sigma$/\\si{\\micro\\meter}} & \\multicolumn{1}{c}{$\\hat{n}$/\\si[per-mode=reciprocal]{\\per\\meter\\cubed}}\\\\\n        \\midrule\n        1  & 5.0e-6 & 2.00 & 10.0  & 809 & 2.4e16 \\\\\n        2  & 1.9e-5 & 1.20 & 7.1 & 528 & 5.4e16 \\\\\n        3  & 7.1e-5 & 0.77 & 5.0   & 345 & 1.2e17 \\\\\n        4  & 2.7e-4 & 0.48 & 3.5 & 225 & 2.7e17 \\\\\n        5  & 1.0e-3 & 0.30 & 2.5 & 147 & 6.0e17 \\\\\n        \\bottomrule\n    \\end{tabular}\n    \\label{tab:evap_cases}\n\\end{table}\n% We simulate two different scenarios for both angles: In the first scenario, we assume that the cycling scheme of compression and cooling works. In that case, we start at a phase space density of \\todo{number} and a temperature of \\todo{number}, corresponding to a density of \\todo{number}. Our initial beam radius is given by \\todo{number}, so we start with \\todo{number} atoms.\n\n% In the second scenario, we do not assume such a great amount of pre-cooling, so we instead start with a phase space density of only \\todo{number} at a temperature of \\todo{number}, corresponding to the results of \\cite{Rosi2018enhancedGM}. At the same initial beam radius, this gives us an initial atom number of \\todo{number}.\nIn all cases, we assume a trap lifetime of \\SI{1}{min} (giving $K_1 = \\SI{.017}{\\per\\second}$), no two-body losses and no influence of gravity. This can be achieved in an experiment with a sample prepared in the absolute ground state of $^{87}$Rb where gravity is compensated by a linear magnetic field. The three-body loss coefficient is taken from \\cite{threebody} as $K_3 = \\SI{1.8e-41}{m^6\\per\\second}$. At densities below \\SI{e19}{\\per\\meter\\cubed}, three body losses are negligible compared to the losses due to background collisions.\n\n\\subsubsection*{Findings}\nIn case 1, the initial density is so low that only a small fraction of the initial atom number can actually be captured in the box. Furthermore, this lower density results in a smaller collision rate and the compression is not fully able to compensate for this. We can achieve efficiencies $\\gamma > 2$ only by making the evaporation ramp \\SI{30}{s} long. Still, the final phase space density is $\\PSD_\\text{f}\\ll 1$ and less than \\num{200000} atoms remain in the trap after the ramp. We can conclude from this that either larger initial trapping beams or a higher initial density would be necessary.\n\nAt initial phase space densities above $\\num{e-5}$, the situation improves drastically and efficiencies close to or above 3 can be achieved. However, this comes again at the expense of long ramp durations.\n\nThe results for all five cases are listed in \\cref{tab:evap_results} and \\cref{fig:evap_comparison} shows a comparison of the cases 2--5 against various results from other research groups. Here we can see that our achieved efficiency can compete with the compared results. In the cases 4 and 5, a large portion of the atoms remains in the trap at a phase space density of $\\PSD = 1$. We also find that the achieved efficiency is very dependent on the initial atom number. This is expected as the initial atom number determines how strong the compression needs to be to achieve high densities and in turn high collision rates.\n\nLastly, we show the optimised trajectory for case 5 in \\cref{fig:evap_trajectory}. During the first second of compression, no evaporation takes place, which is apparent by the relatively constant atom number and phase space density. Starting at a lower trap depth might reduce the total time necessary to reach $\\PSD = 1$.\n\nThe trajectories for the other cases can be found in \\cref{fig:eva_cases14}.\n%\n% \\begin{table}[bp]\n%     \\centering\n%     \\caption{Results and optimised parameters for the simulated cases}\n%     \\begin{tabular}{cS[table-format=1.1e+1]S[table-format=1.1e+1]S[table-format=1.1e-1]S[table-format=1.3]S[table-format=2.1]S[table-format=3]S[table-format=1.2]}\n%         \\toprule\n%         \\# & \\multicolumn{1}{c}{$N_\\text{i}$} & \\multicolumn{1}{c}{$N_\\text{f}$} & \\multicolumn{1}{c}{$\\PSD_\\text{i}$} & \\multicolumn{1}{c}{$\\PSD_\\text{f}$} & \\multicolumn{1}{c}{$T_\\text{i}$/\\si{\\micro\\kelvin}} & \\multicolumn{1}{c}{$T_\\text{f}$/\\si{\\nano\\kelvin}} & \\multicolumn{1}{c}{$\\gamma$} \\\\\n%         \\midrule\n%         1  & 1.1e7 & 1.3e5 & 3.7e-6 & 0.059  & 10 & 152 & 2.17 \\\\\n%         2  & 1.9e7 & 5.5e5 & 1.2e-5 & 0.29 & 7.0 & 137 & 2.83 \\\\\n%         3  & 2.8e7 & 1.3e6 & 3.9e-5 & 0.83 & 5.0 & 185 & 3.20 \\\\\n%         4  & 3.3e7 & 2.0e6 & 1.2e-4 & 1    & 3.6 & 144 & 3.25 \\\\\n%         5  & 2.8e7 & 2.3e6 & 3.4e-4 & 1    & 2.5 & 160 & 3.21 \\\\\n%         \\bottomrule\n%     \\end{tabular}\n%     \\newline\n%     \\vspace{3ex}\n%     \\newline\n%     \\begin{tabular}{cS[table-format=2.0]S[table-format=1.1]S[table-format=2.1]}\n%         \\toprule\n%         \\# & \\multicolumn{1}{c}{$t_\\text{d}$/s} & \\multicolumn{1}{c}{$\\tau_R$/s} & \\multicolumn{1}{c}{$\\tau_{U_0}$/s} \\\\\n%         \\midrule\n%         1  & 30 & 4 & 30 \\\\\n%         2  & 16 & 1.6 & 15 \\\\\n%         3  & 14 & 1.4 & 13 \\\\\n%         4  & 9 & 0.9 & 8.5 \\\\\n%         5  & 7 & 0.7 & 6.5 \\\\\n%         \\bottomrule\n%     \\end{tabular}\n%     \\label{tab:evap_results}\n% \\end{table}\n%\n\n\\clearpage\n\\vbox{\n\\noindent\\begin{minipage}[c][.7518\\textheight][t]{\\textwidth}   \n\n% \\begin{figure}[tp]\n    % \\centering\n    % \\begin{minipage}{1\\textwidth}\n        \\input{TexContents/Figures/Evap/Comparison.pgf}\n        \\captionof{figure}[Comparison of the simulation results against other papers]{The atom numbers in the bottom left figure are extrapolations from the initial atom number and the average efficiency. For the comparison results, the phase space densities are peak values.}\n        \\label{fig:evap_comparison}\n    % \\end{minipage}\n% \\end{figure}\n\\end{minipage}\n\n\\nointerlineskip\n\\noindent\\begin{minipage}[c][.1795\\textheight][b]{\\textwidth}\n\\singlespacing\n\n% \\begin{table}[b]\n    \\centering\n    % \\vspace*{3cm} % change this to align Table 10.1 and 10.2\n    \\captionof{table}[Results and optimised parameters for the simulated cases]{The indices i,f denote the initial and final values. $t_\\text{d}$ is the duration of the simulation and $\\tau_R$/$\\tau_{U_0}$ the time constant for the expontential ramp of the trap radius/potential depth.}\n    \\label{tab:evap_results}\n    \\begin{tabular}{cS[table-format=1.1]S[table-format=1.2]S[table-format=1.1e-1]S[table-format=1.3]S[table-format=2.1]S[table-format=3]S[table-format=1.2]S[table-format=2.0]S[table-format=1.1]S[table-format=2.1]}\n        \\toprule\n        \\# & \\multicolumn{1}{c}{$N_\\text{i}/\\num{e7}$} & \\multicolumn{1}{c}{$N_\\text{f}/\\num{e6}$} & \\multicolumn{1}{c}{$\\PSD_\\text{i}$} & \\multicolumn{1}{c}{$\\PSD_\\text{f}$} & \\multicolumn{1}{c}{$T_\\text{i}$/\\si{\\micro\\kelvin}} & \\multicolumn{1}{c}{$T_\\text{f}$/\\si{\\nano\\kelvin}} & \\multicolumn{1}{c}{$\\gamma$} & \\multicolumn{1}{c}{$t_\\text{d}$/s} & \\multicolumn{1}{c}{$\\tau_R$/s} & \\multicolumn{1}{c}{$\\tau_{U_0}$/s} \\\\\n        \\midrule\n        1  & 1.1 & 0.13 & 3.7e-6 & 0.059  & 10.0 & 152 & 2.17 & 30 & 4.0 & 30.0 \\\\\n        2  & 1.9 & 0.55 & 1.2e-5 & 0.29 & 7.0 & 137 & 2.83 & 16 & 1.6 & 15.0 \\\\\n        3  & 2.8 & 1.3 & 3.9e-5 & 0.83 & 5.0 & 185 & 3.20 & 14 & 1.4 & 13.0 \\\\\n        4  & 3.3 & 2.0 & 1.2e-4 & 1    & 3.6 & 144 & 3.25 & 9 & 0.9 & 8.5 \\\\\n        5  & 2.8 & 2.3 & 3.4e-4 & 1    & 2.5 & 160 & 3.21 & 7 & 0.7 & 6.5 \\\\\n        \\bottomrule\n    \\end{tabular}\n% \\end{table}\n\\end{minipage}\n}\n\n\\clearpage\n%\n%\n\\begin{figure}[bp]\n    \\centering\n    \\includegraphics{Evap/Trajectory}\n    \\caption[Evaporation trajectory for case 5]{It can be seen that the first second does not contribute much to the evaporation. Here, the phase space density \\PSD and atom number $N$ are nearly constant while the temperature $T$ increases due to the compression. The atom number and phase space density axes are logarithmic, the others linear.}\n    \\label{fig:evap_trajectory}\n\\end{figure}\n\n", "meta": {"hexsha": "aa516ff987a33210bd3a4f1bb331f4e3c6f36816", "size": 23027, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TexContents/24EVA-Tests_Results.tex", "max_stars_repo_name": "AvonHaaren/mphil-thesis", "max_stars_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TexContents/24EVA-Tests_Results.tex", "max_issues_repo_name": "AvonHaaren/mphil-thesis", "max_issues_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TexContents/24EVA-Tests_Results.tex", "max_forks_repo_name": "AvonHaaren/mphil-thesis", "max_forks_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.376984127, "max_line_length": 1543, "alphanum_fraction": 0.7010900248, "num_tokens": 7351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.42652882279419446}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Wednesday\\\\ 2021-12-1}\n\nLast time we reached the expression for the plane-wave solution to GR. \n\nConsider a wave propagating along the \\(x^{1}\\) direction. \nOur equation is \\(\\square _F \\overline{h}_{\\mu \\nu } = 0 \\), to be solved together with our gauge condition \\(\\partial_{\\mu } \\overline{h}^{\\mu }{}_\\nu = 0\\). \n\nThe solution will only depend on \\(t - x /c\\), which we denote as \\(w\\). We will have \n%\n\\begin{align}\n\\pdv{}{x} \\overline{h}^{\\mu }{}_{\\nu } &= - \\frac{1}{c} \\pdv{}{w } \\overline{h}^{\\mu }{}_\\nu \\\\\n\\pdv{}{t} \\overline{h}^{\\mu }{}_{\\nu } &=  \\pdv{}{w } \\overline{h}^{\\mu }{}_\\nu \n\\,,\n\\end{align}\n%\nso, the full condition reads \n%\n\\begin{align}\n\\partial_{\\mu }  \\overline{h}^{\\mu }{}_{\\nu } = \\frac{1}{c} \\pdv{}{t} \\overline{h}^{0}{}_\\nu + \\pdv{}{x} \\overline{h}^{x }{}_\\nu \n= \\frac{1}{c} \\pdv{}{w} \\qty[h^{0}{}_{\\nu } - h^{x}{}_{\\nu }]\n= 0\n\\,.\n\\end{align}\n\nThe constant the difference of these perturbations are equal to is inessential --- it can be recovered with a rescaling of, say, background time --- so we have \n%\n\\begin{align}\nh^{0}{}_{\\nu } = h^{x}{}_{\\nu }\n\\,.\n\\end{align}\n\nThe gauge we chose did not fully determine our transformation: equation \\eqref{eq:christoffel-gauge-transformation} will not change if we use an additional \\(\\xi \\) such that \\(\\square \\xi  =0 \\). \n\nIt is possible to choose four more conditions thanks to this: \n%\n\\begin{align}\n0 \n= \\overline{h}^{0}{}_{x}\n= \\overline{h}^{0}{}_{y}\n= \\overline{h}^{0}{}_{z}\n= \\overline{h}^{y}{}_{y} + \\overline{h}^{z}{}_{z}\n\\,.\n\\end{align}\n\nTogether with the ones from before, we find \n%\n\\begin{align}\n0 \n= \\overline{h}^{x}{}_{x}\n= \\overline{h}^{x}{}_{y}\n= \\overline{h}^{x}{}_{z}\n= \\overline{h}^{0}{}_{0}\n\\,,\n\\end{align}\n%\nwhich also means \\(h = 0 = \\overline{h}\\) (since \\(h = - \\overline{h}\\)), therefore \\(\\overline{h}_{\\mu \\nu } = h_{\\mu \\nu } \\). \n\nThe only two nonvanishing components left are \\(h^{y}{}_{y} = - h^{z}{}_z\\) and \\(h^{x}{}_{y} = h^{y}{}_{x}\\). \n\nWe finally have \n%\n\\begin{align}\nh_{\\mu \\nu } = \\left[\\begin{array}{cccc}\n0 & 0 & 0 & 0 \\\\ \n0 & 0 & 0 & 0 \\\\ \n0 & 0 & h_{+} & h_{\\times } \\\\ \n0 & 0 & h_{\\times } & -h_{+}\n\\end{array}\\right]\n\\,.\n\\end{align}\n\nThis is the \\textbf{transverse-traceless gauge}.\n\n\\subsection{The quadrupole approximation}\n\nWe will assume that \\(T_{\\mu \\nu } \\neq 0\\), but that the source of the GW is all contained within a source such that \\(\\abs{x'} < \\epsilon\\), and such that \\(\\epsilon \\ll \\lambda_{GW} = 2 \\pi c / \\omega \\). \nThis means that \\(\\omega \\epsilon / 2 \\pi \\sim v _{\\text{source}} \\ll c\\). \n\nThis line of reasoning assumes that \\(\\omega _{\\text{source}} \\sim \\omega _{\\text{GW}} \\), which we do not know yet --- we will later find that it is in fact true within a factor 2.\n\nThe GW solution reads \n%\n\\begin{align}\n\\overline{h}_{\\mu \\nu }(t, \\vec{x}) &= \\frac{4 G}{c^{4}}\n\\int_{V} \\frac{T_{\\mu \\nu } (t - \\abs{x - x'} / c, c') \\dd[3]{x'}}{\\abs{x - x'}}\n\\,,\n\\end{align}\n%\nwhile in Fourier space we can expand \n%\n\\begin{align}\nT_{\\mu \\nu } (t, \\vec{x}) = \\int \\widetilde{T}_{\\mu \\nu } (\\omega , \\vec{x}) e^{-i \\omega t} \\dd{\\omega }\n\\,.\n\\end{align}\n\nWe then get \n%\n\\begin{align}\n\\int \\overline{h}_{\\mu \\nu } (\\omega , \\vec{x}) e^{-i \\omega t} \\dd{\\omega } = \\frac{4 G}{c^{4}} \n\\int_{V} \\frac{ \\dd[3]{x'}}{\\abs{x - x'}} \\int T_{\\mu \\nu } (\\omega , x') e^{-i \\omega (t - \\abs{x-x'} / c) } \\dd{\\omega }\n\\,,\n\\end{align}\n%\nwhich means that \n%\n\\begin{align}\nh_{\\mu \\nu } (\\omega , x) = \\frac{4G}{c^{4}} \\int \n\\frac{\\dd[3]{x'}}{\\abs{x - x'}}\nT_{\\mu \\nu }(\\omega , x') e^{i \\omega \\abs{x-x'} / c}\n\\,,\n\\end{align}\n%\nwhere we factored out the \\(e^{- i \\omega t}\\) and the integral in \\(\\dd{\\omega }\\). \n\nWith our assumption of slow speed we can expand: \n%\n\\begin{align}\n\\frac{e^{i \\omega \\abs{x-x'} / c}}{\\abs{x-x'}} \\approx \n\\frac{e^{i \\omega r}}{r} \n\\,,\n\\end{align}\n%\nwhere \\(r = \\abs{x}\\). \nThis then yields \n%\n\\begin{align}\nh_{\\mu \\nu }(\\omega , r) = \\frac{4 G}{c^{4}} \\frac{e^{i\\omega r}}{r}\n\\int_{V} T_{\\mu \\nu } (\\omega , x') \\dd[3]{x'}\n\\,,\n\\end{align}\n%\nso we can come back to \n%\n\\begin{align}\n\\overline{h}_{\\mu \\nu } (t, r) = \\frac{4 G}{c^{4}r} \\int T_{\\mu \\nu } (t- r/c, x') \\dd[3]{x'}\n\\,.\n\\end{align}\n\nWe can simplify this thanks to the expression \\(T^{\\mu \\nu }{}_{, \\nu } = 0\\), which means we have conservation laws in the form \\(\\int T^{\\mu 0} \\dd[3]{x}\\). \n\nWe can put these constants to zero (since we are not interested in any non-wavelike behavior, like the stationary Kerr-like metric due to the source). \n\nWe can do an integral of \\(\\partial_{\\mu } T^{\\mu \\nu }= 0\\): \n%\n\\begin{align}\n\\frac{1}{c} \\pdv{}{t} \\int _V T^{n  0} x^{k} \\dd[3]{x} &= - \\int \\pdv{T^{ni}}{x^i} x^{k} \\dd[3]{x}  \\\\\n&= \\underbrace{\\int \\dd{S^{i}} (T^{ni} x^{k})}_{ \\to 0} + \\int T^{nk} \\dd[3]{x}  \\\\\n\\frac{1}{c} \\pdv{}{t} \\int x^{k} T^{n0} \\dd[3]{x} &= \\int T^{nk} \\dd[3]{x}\n\\,.\n\\end{align}\n\nWe can write this as \n%\n\\begin{align}\n\\frac{1}{2} \\pdv{}{t} \\int \\qty[ T^{n0} x^{k} + T^{k0} x^{n}] = \\int T^{nk} \\dd[3]{x}\n\\,.\n\\end{align}\n\nThe time component of the conservation law can be multiplied by \\(x^{n} x^{k}\\): \n%\n\\begin{align}\n\\frac{1}{c} \\pdv{}{t} \\int T^{00} x^{n} x^{k} \\dd[3]{x} \n&= - \\int \\pdv{}{x^{i}} T^{0i} x^{n} x^{k} \\dd[3]{x}  \\\\\n&= + \\int T^{0i} \\pdv{}{x^{i}} (x^{n} x^{k}) \\dd[3]{x}  \\\\\n&= \\int T^{0n} x^{k} + T^{0k} x^{n}  \\dd[3]{x} \n\\,.\n\\end{align}\n\nWe then take a second derivative: \n%\n\\begin{align}\n\\frac{1}{c^2} \\pdv[2]{}{t} \\int T^{00} x^{n} x^{k} \\dd[3]{x} &= \n\\frac{1}{c} \\pdv{}{t} \\int T^{n0} x^{k} + T^{k0} x^{n} \\dd[3]{x}  \\\\\n&= 2 \\int T^{nk} \\dd[3]{x}\n\\,.\n\\end{align}\n\nThis is the \\textbf{virial theorem} in GR. \n\nWe will assume we are working on a \\(t = \\text{const}\\) hypersurface. \nThe metric is purely Euclidean there. \n\nThe object \n%\n\\begin{align}\n\\frac{1}{c^2} \\int T^{00} x^{n} x^{k} \\dd[3]{x} = q^{n k} (t) \n\\,,\n\\end{align}\n%\nthe quadrupole tensor. \nWe then have \n%\n\\begin{align}\n\\frac{1}{2} \\ddot{q}^{n k} (t) = \\int T^{nk} \\dd[3]{x}\n\\,.\n\\end{align}\n\nThe result is therefore \\(h^{\\mu 0} = 0\\), and \n%\n\\begin{align}\n\\overline{h}^{n k} = \\frac{2G}{c^{4} r} \\ddot{q}^{n k}(t)\n\\,.\n\\end{align}\n\n\n\n\\end{document}", "meta": {"hexsha": "6f2f484383da853e1559db432352f2d22674fdf9", "size": 6132, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd_courses/theoretical_gravitation_cosmology/dec01.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "phd_courses/theoretical_gravitation_cosmology/dec01.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd_courses/theoretical_gravitation_cosmology/dec01.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 29.2, "max_line_length": 208, "alphanum_fraction": 0.5642530985, "num_tokens": 2570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.42652882063775616}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n\\usepackage[a4paper,total={6in, 8in}]{geometry}\n\\begin{document}\n\t\n\t\t\\title{Cardano's Formula for Cubic Equations}\n\t\t\\author{Dumebi Valerie Duru}\n\t\t\\maketitle\n\t\\begin{center}\n\t\t\\textbf{Abstract}\n\t\\end{center}\n\t\\paragraph{}\n\t\tGerolamo Cardano was born in Pavia in 1501 as the illegitimate child of a jurist. He attended the University of Padua and became a physician in the town of Sacco, after being rejected by his home town of Milan. He became one of the most famous doctors in all of Europe, having treatwd the pope. He was also an astrologer and an avid gambler, to which he wrote the Book on Games of Chance, which was the first serious treatise on the mathematics of probability. \\cite{cardanoformula}\n\t\n\t\\section{Introduction to Cardano's Formula}\n\t\tCardano's formula for solution of cubic equations for an equation like;\n\t\t\\newline\n\t\t\\begin{math}\n\t\t\tx^{3} + a_{1}x^{2} + a_{2}x + a_{3} = 0\n\t\t\\end{math}\n\t\t\\newline\n\t\tthe parameters Q, R, S and T can be computed thus, \\newline\n\t\t\\begin{align*}\n\t\t\tQ = \\frac{3a_{2}-a_{1}^{2}}{a} &&\n\t\t\tR = \\frac{9a_{1}a_{2}-27a_{3}-2a_{1}^{3}}{54}\n\t\t\\end{align*}\n\t\n\t\t\\begin{align*}\n\t\t\tS = 3 \\sqrt{R + \\sqrt{-Q^{3} + R^{2}}} && T= \\sqrt{R-\\sqrt{Q^{3}+R^{2}}}\n\t\t\\end{align*}\n\t\t\t\\newline\t\n\t\t\tto give the roots;\n\t\t\t\\newline\n\t\t\tx$_{1} = S + T- \\frac{1}{3}a_{1}$\n\t\t\t\\newline\n\t\t\tx$_{2} = \\frac{-(S + T)}{2}$ - $\\frac{a_{1}}{3}$ + i$\\frac{sqrt{3}(s-T)}{2}$\n\t\t\t\\newline\n\t\t\tx$_{3} = \\frac{-(S+T)}{2}$\n\t\t\t\\newline\n\t\t\tNote: x$_{3}$ must not have a co-efficient.\n\t\t\n\t\\subsection{Some Examples}\n\t\\begin{itemize}\n\t\t\\item $x^{3} - 3x^{2} + 4 = 0$\n\t\t\\item $2x^{3} + 6x^{2} + 1 = 0$\n\t\\end{itemize}\t\n\t\n\t\\bibliography{cardano.bib}\n\t\\bibliographystyle{ieeetr}\n\\end{document}\n\n\n\n\n\n\n", "meta": {"hexsha": "ada3b210d9eb50a4aa037fc9f53785a88b63454f", "size": 1745, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week6/Cardano's Formula.tex", "max_stars_repo_name": "Dumebi35/DumebiCSC101", "max_stars_repo_head_hexsha": "6c63aa0879fdc1d99ec8600e29046413093fcfe2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week6/Cardano's Formula.tex", "max_issues_repo_name": "Dumebi35/DumebiCSC101", "max_issues_repo_head_hexsha": "6c63aa0879fdc1d99ec8600e29046413093fcfe2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week6/Cardano's Formula.tex", "max_forks_repo_name": "Dumebi35/DumebiCSC101", "max_forks_repo_head_hexsha": "6c63aa0879fdc1d99ec8600e29046413093fcfe2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0862068966, "max_line_length": 484, "alphanum_fraction": 0.6464183381, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.42652881884478744}}
{"text": "\n\\documentclass[a4paper,11pt]{article}\n\n\\usepackage{physics}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm, mathtools}\n%\\usepackage{hyperref}\n\\usepackage{color}\n\\usepackage{jheppub}\n\\usepackage{tikz}\n\\usetikzlibrary{decorations.pathmorphing}\n\\usepackage[T1]{fontenc} % if needed\n\n% My Documents\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\\usetikzlibrary{decorations.pathmorphing}\n\n\\tikzset{zigzag/.style={decorate, decoration=zigzag}}\n\\def \\L {2.}\n\\definecolor{darkgreen}{HTML}{006622}\n%\\linespread{1.0}\n%\\setlength{\\parindent}{0em}\n%\\setlength{\\parskip}{0.8em}\n\n\\title{\\textbf{AdS/CFT and Other Things}}\n\\author{Aditya Vijaykumar}\n\\affiliation{International Centre for Theoretical Sciences, Bengaluru, India.}\n\\emailAdd{aditya.vijaykumar@icts.res.in}\n\\abstract{This is one's effort to understand what the AdS/CFT Correspondence actually means, with explicit calculations and intuitive explanations of whatever is covered. In the course of one's journey, one hopes to review aspects of Quantum Field Theory as well as AdS spacetimes.\n\t\nOne shall mainly follow the path taken by Prof. Hong Liu in his MIT OCW course String Theory and Holographic Duality, supplementing it with one's own readings and observations. One shall also try to include as many references as possible.  }\n\\begin{document}\n\\maketitle\n\\section{Motivations}\n\\subsection{Spin-2}\n\nFrom a field theory perspective, it is natural to ask whether a massless spin-$2$ particle \\textcolor{red}{Ex : Why is gravity massless spin $ 2 $?} can arise as the bound state of a lower spin theory. If yes, that is equivalent to saying that gravity has effectively \\textit{emerged}. Gluons and quarks can indeed form massive spin-$ 2 $ bound states which are unstable. \\textcolor{red}{Ex : How do spin-$2$ particles arise in QCD?}.\n\\subsection{Weinberg-Witten Theorem}\n\nBut can one generate massless spin-$ 2 $ particles from this by maybe changing the theory a bit? Weinberg and Witten said no. They gave the following theorems\n\n\\begin{itemize}\n\t\n\t\\item \\textbf{Theorem 1} - A theory that allows the construction of a Lorentz covariant conserved current cannot contain a massless particle of spin $  > 1/2 $ with non-vanishing charge.\n\t\\item \\textbf{Theorem 2} - A theory that allows Lorentz covariant conserved stress tensor cannot contain massless particles of spin $ >1 $.\n\\end{itemize}\nAs GR need not have a conserved stress tensor \\textcolor{red}{???}, these theorems do not forbid the graviton. But the second theorem also prohibits renormalizable theories in Minkowski spacetime in having an emergent gravity description. There is, however, a hidden assumption in this theory - it only applies to particles that live in the spacetime of the original theory. This seems like a straightforward, obvious assumption. But, in AdS/CFT, gravity\\footnote{gh} lives in a different spacetime!\n\n\\textbf{\\textcolor{red}{{Prove the Weinberg Witten Theorem}}}\n\n\\section{Black Holes ain't so Black}\n\nIn non-gravitational physics, in principle, one can probe arbitrarily large length scales. When gravity comes in, this stops being true. When $ E \\gg m_p $, there will come a point when the Schwarzchild radius $ r_s \\sim GE_{c} $ will become the fundamental distance scale. \n\n\\subsection{Classical Black Holes}\nThe geometry outside the Schwarzschild Black Hole is given by,\n\\bes\nds^2 = -\\qty(1-\\frac{2M}{r})dt^2 + \\qty(1-\\frac{2M}{r})^{-1} dr^2 + r^2(d\\theta^2 + \\sin^2 \\theta d\\phi^2)\n\\ees\nThis has the following properties,\n\\begin{itemize}\n\t\\item The solution is time reversal symmetric \\textit{ie.} symmetric under $t \\rightarrow -t$. Real black holes form through gravitational collapse, and hence this is not valid for them. Nonetheless, this can be assumed for late time black holes, which really makes the Schwarzschild solution a mathematical idealization of the actual black hole.\n\t\\item Spacetime is non-singular at the horizon. Written in the Schwarzschild coordinates, the horizon is a coordinate singularity, and one can easily verify that it indeed is not a real singularity by \\textcolor{red}{calculating curvature invariants}.\n\t\\item $ r=r_s $ is a null hypersurface.\n\t\\item The horizon is a surface of infinite redshift with respect to far away observer. \\textcolor{red}{Show this explicitly}\n\t\\item There are two important geometric quantities associated with the horizon,\n\t\\bes\n\t\\qq{Horizon Area} A_s = 4\\pi r_s^2 = 16 \\pi M^2 \n\t\\ees\n\t\\bes\n\t\\qq{\\textcolor{red}{Surface Gravity}} \\kappa = \\frac{1}{2}f'(r_s) = \\frac{1}{2r_s} = \\frac{1}{4M}\n\t\\ees\n\\end{itemize}\n\n\n\\subsection{Causal Structure and Rindler Spacetime}\nConsider the region just outside the black hole horizon,\n\\begin{equation*}\nf(r) = f(r_s) + (r-r_s)f'(r_s) + \\ldots= (r-r_s)f'(r_s) + \\ldots\n\\end{equation*}\nFrom the metric, we can see that the proper distance $ \\rho $ is just given by,\n\\begin{equation*}\n\\rho = \\int_{r_s}^r \\dfrac{dr}{\\sqrt{f(r)}} = \\int_{r_s}^r \\dfrac{dr}{\\sqrt{(r-r_s)f'(r_s)}} = 2\\sqrt{\\frac{r-r_s}{f'(r_s)}}\n\\end{equation*}\nHence,\n\\begin{equation*}\nf(r) = (f'(r_s))^2\\rho^2/4 = \\kappa^2 \\rho^2\n\\end{equation*}\nand the metric can be written as,\n\\begin{align*}\nds^2 &= - \\kappa^2 \\rho^2 dt^2 + d\\rho^2 +  r_s^2(d\\theta^2 + \\sin^2 \\theta d\\phi^2)\\\\\n&=   \\underbrace{-\\rho^2 d\\eta^2 + d\\rho^2}_{\\text{(1+1)d Minkowski Spacetime in Rindler coordinates}} +  \\underbrace{r_s^2(d\\Omega^2)}_{\\text{2-sphere}}\n\\end{align*}\n\\textbf{\\textcolor{red}{Continue this from Hartman and other sources}}\n\\end{document}", "meta": {"hexsha": "1c1dedf758357673f83f99e65349a4dc42bc5b8e", "size": 5650, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "selfstudy/adscft/notes/adscft.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "selfstudy/adscft/notes/adscft.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "selfstudy/adscft/notes/adscft.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.854368932, "max_line_length": 499, "alphanum_fraction": 0.7504424779, "num_tokens": 1698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.42652168773932553}}
{"text": "\\documentclass[aps,pra,notitlepage,amsmath,amssymb,letterpaper,12pt]{revtex4-1}\n\\usepackage{amsthm}\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\newenvironment{problem}[2][Problem]{\\begin{trivlist}\n\\item[\\hskip \\labelsep {\\bfseries #1}\\hskip \\labelsep {\\bfseries #2.}]}{\\end{trivlist}}\n\\newenvironment{solution}{\\begin{proof}[Solution]}{\\end{proof}}\n\n\n\\begin{document}\n\n\\title{Classwork 13}\n\\author{Frank Entriken and Grady Lynch}\n\\affiliation{PHYS 220, Schmid College of Science and Technology, Chapman University}\n\\date{\\today}\n\n\\maketitle\n\n\\section{Sombrero Potential}\n\n\\begin{problem}{Specifications}\nSimulate the $x$ and $y$ coordinates of a ball in a double well potential (also known as the \"sombrero\" potential). Variables to consider are the balls mass, $m$, and the ball's friction as it rolls, $f_{\\text{drag}}(\\dot{x}) = -\\nu \\dot{x}$. The \"sombrero\" will be shaken back and forth repeatedly with a driving force $f_{\\text{drive}}(t) = F\\cos(\\omega t)$.\n\nAccording to Newton's Second Law, the ball must satisfy the equation of motion: $$m\\ddot{x} = f_{\\text{hat}}(x) + f_{\\text{drag}}(\\dot{x}) + f_{\\text{drive}}(t) = x - x^3 - \\nu \\dot{x} + F\\cos(\\omega t)$$\n\\end{problem}\n\n\\section{The Solution}\n\n\\begin{solution}\nIn order to compute the coordinates of the ball in motion we used the Runge-Kutta 4th Method. This method accurately predicts each subsequent $x$ and $x$ value by considering the approximations before and after the desired value. By using this method we were able to graphically represent the ball's $x$ and $x$ values over the course of its motion. The graphs below represent the ball at different starting values: $x0$ is the starting $x$ position of the ball, $y0$ is the starting $y$ position of the ball, and $F$ which is the force of the shake.\n\n\\subsection{Our Graphs}\n\n\\begin{figure}[h!]\n  \\includegraphics[width=0.4\\textwidth]{p1.png}\n  \\caption{$x0=-0.9$, $y0=0$, $x0=0.18$}\n  \\label{fig:figlabel}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\includegraphics[width=0.4\\textwidth]{p2.png}\n  \\caption{$x0=0.2$, $y0=0.1$, $x0=0.25$}\n  \\label{fig:figlabel}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\includegraphics[width=0.4\\textwidth]{p3.png}\n  \\caption{$x0=0$, $y0=0$, $x0=0.4$ \\\\ The movement of the this graph uses a slightly modified version of the code from $RK4_2$, where our N value is multiplied by a value of 1000 up from 50.}\n  \\label{fig:figlabel}\n\\end{figure}\n\n\n\\end{solution}\n\\end{document}\n", "meta": {"hexsha": "11f2105f5ee91e8d312bc484ef57764e7c1b63b2", "size": 2424, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/latex_template.tex", "max_stars_repo_name": "chapman-phys220-2018f/cw13-bbb", "max_stars_repo_head_hexsha": "71d4c2cb75b188762c798ac0b68c5d84f37d687c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX/latex_template.tex", "max_issues_repo_name": "chapman-phys220-2018f/cw13-bbb", "max_issues_repo_head_hexsha": "71d4c2cb75b188762c798ac0b68c5d84f37d687c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX/latex_template.tex", "max_forks_repo_name": "chapman-phys220-2018f/cw13-bbb", "max_forks_repo_head_hexsha": "71d4c2cb75b188762c798ac0b68c5d84f37d687c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0727272727, "max_line_length": 550, "alphanum_fraction": 0.7219471947, "num_tokens": 781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4265216835323409}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%                                                                 %\n%  GEANT manual in LaTeX form                              %\n%                                                                 %\n%  Michel Goossens (for translation into LaTeX)                   %\n%  Version 1.00                                                   %\n%  Last Mod. Jan 24 1991  1300   MG + IB                          %\n%                                                                 %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\Origin{G.N.Patrick, L.Urb\\'{a}n}\n\\Submitted{26.09.83}\\Revised{16.12.93}\n\\Version{Geant 3.16}\\Routid{PHYS221}\n\\Makehead{Simulation of Compton scattering}\n\\section{Subroutines}\n\\Shubr{GCOMP}{}\n\\Rind{\\tt GCOMP} generates the Compton scattering of a photon on an \natomic electron. It uses the random number techniques of Butcher and \nMessell \\cite{bib-BUTC} to sample the scattered photon energy according \nto the Klein-Nishina formula \\cite{bib-KLEI}.\n\nThe interaction produces one electron, which is put in the \\FCind{/GCKING/} \ncommon block for further tracking. Tracking of the scattered photon will\ncontinue, with direction and energy changed by the interaction.\nAll input/output information is through {\\tt GEANT} common blocks.\n \n\\begin{tabular}{ll}\nInput: & via COMMON \\FCind{/GCTRACK/} \\\\\nOutput: & via COMMONs \\FCind{/GCTRAK/} and \\FCind{/GCKING/} \n\\end{tabular}\n \nCompton scattering is selected in {\\tt GEANT} by the input data \nrecord {\\tt COMP}. When Compton scattering is selected, \\Rind{GCOMP} \nis called automatically from the {\\tt GEANT} photon tracking\nroutine \\Rind{GTGAMA}.\n\n\\section {Method}\n \nFor a complete account of the Monte Carlo methods used the\ninterested\nuser is referred to the publications of Butcher and Messel \n\\cite{bib-BUTC}, Messel\nand Crawford \\cite{bib-MESS} and Ford and Nelson \\cite{bib-EGS3}.\nOnly the basic formalism is outlined here.\n \nThe quantum  mechanical Klein-Nishina differential cross-section\nis:\n\\[\n\\Phi(E,E') =\\frac{X_0 n \\pi r_0^2 m_{\\rm e}}{E^2}\n     \\left[\\frac{1}{\\epsilon}+\\epsilon\\right]\n     \\left[1 - \\frac{\\epsilon \\sin^2 \\theta}{1+\\epsilon^2}\\right]\n\\]\nwhere,\\quad\n\\begin{tabular}[t]{l@{\\ = \\ }l}\n$E$         & energy of the incident photon   \\\\\n$E'$        & energy of the scattered photon  \\\\\n$\\epsilon$  & $E'/E$                          \\\\\n$m_{e}$     & electron mass                   \\\\\n$n$         & electron density                \\\\\n$r_0$       & classical electron radius       \\\\\n$X_0$       & radiation length\n\\end{tabular}\n \nAssuming an elastic collision, the scattering angle $\\theta$ is\ndefined by the Compton formula:\n \n\\[\nE'   = E \\frac{m_{\\rm e}}{ m_{\\rm e} + E(1-\\cos\\theta )}\n\\]\n \nUsing the combined ``composition and rejection'' Monte Carlo methods\ndescribed in chapter {\\tt PHYS211}, we may set:\n \n\\[\n\\begin{array}{LcLLcL}\nf(\\epsilon)   & = & \\left[\\frac{1}{\\epsilon}+\\epsilon\\right] =\n                    \\sum^{2}_{i=1} \\alpha_i f_i(E)\n                    &  \\multicolumn{2}{l}{\\mbox{for}}\n                    & \\epsilon_0 > \\epsilon > 1     \\\\\ng(\\epsilon)   & = & \\left[ 1 - \\frac{\\epsilon\\sin^2\\theta}{1+\\epsilon^2}\n                    \\right] & \\multicolumn{3}{l}{\\mbox{rejection function}} \\\\\n\\alpha_1      & = & \\frac{1}{\\ln(1/\\epsilon_0)}   &\n\\alpha_2      & = & \\frac{1}{2} (1-\\epsilon_0^2)                             \\\\\nf_1(\\epsilon) & = & \\frac{1}{\\epsilon\\ln(1/\\epsilon_0)} &\nf_2(\\epsilon) & = & \\frac{2\\epsilon}{1-\\epsilon^2}\n\\end{array}\n\\]\n \nThe value of $\\epsilon$ corresponding to the minimum\nphoton energy (backward scattering) is given by:\n\\begin{eqnarray*}\n\\epsilon_0 & = & \\frac{1}{1+2E/m_{\\rm e}}\n\\end{eqnarray*}\n\nGiven a set of random numbers $r_i$ uniformly distributed in [0,1],\nthe sampling procedure for $\\epsilon$ is the following:\n\\begin{enumerate}\n\\item\ndecide which element of the $f(\\epsilon)$ distribution to sample from.\nLet $\\alpha_T = (\\alpha_1+\\alpha_2)r_0$. If $\\alpha_1\\geq\\alpha_T$\nselect $f_1(\\epsilon)$, otherwise select $f_2(\\epsilon)$;\n \n\\item  sample $\\epsilon$ from the distributions\ncorresponding to $f_1$ or $f_2$. For $f_1$ this is simply achieved by:\n\\[\n\\epsilon = \\epsilon_0 e^\\alpha_1 r_1\n\\]\nFor $f_2$, we change variables and use:\n\\[\n\\epsilon' = \\left\\{ \\begin{array}{lll}\n\\max(r_2,r_3) & \\mbox{for } & E/m \\geq (E/m+1)r_4 \\\\\nr_5           & \\multicolumn{2}{l}{\\mbox{for all other cases}}\n \\end{array} \\right.\n\\]\nThen, $\\epsilon = \\epsilon_0+(1-\\epsilon_0)\\epsilon'$;\n \n\\item calculate $\\sin^2\\theta = \\max(0,t(2-t))$ \nwhere $t=m_{\\rm e}(1-\\epsilon)/E'$ \n\n\\item test the rejection function, if $r_6 \\leq g(\\epsilon)$ accept\n$\\epsilon$, otherwise return to step 1.\n\\end{enumerate}\n\nAfter the successful sampling of $\\epsilon$, \\Rind{GCOMP} generates the\npolar angles of the scattered photon with respect to the direction of\nthe parent photon. The azimuthal angle, $\\phi$, is generated isotropically and\n$\\theta$ is as defined above. The momentum vector of the scattered\nphoton is then calculated according to kinematic considerations. Both\nvectors are then transformed into the {\\tt GEANT} coordinate system.\n\n\\section{Restriction}\n \nThe differential cross-section is only valid for those\ncollisions in which the energy of the recoil electron is large compared\nwith its binding energy (which is ignored). However, as pointed out by\nRossi \\cite{bib-ROSS}, this has a negligible effect \nbecause of the small number of\nrecoil electrons produced at very low energies.\n", "meta": {"hexsha": "c3cc01802c3ecf96bcda13e33a7b2ec2646dc310", "size": 5503, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant/phys221.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant/phys221.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant/phys221.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8768115942, "max_line_length": 79, "alphanum_fraction": 0.6178448119, "num_tokens": 1565, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.42649131654241945}}
{"text": "\\documentclass{article}  %Need this.\n\n\\usepackage{amsmath,amsthm,amssymb}\n\n\\usepackage[margin=1in]{geometry}\n\n\n\\newtheorem*{thm}{Theorem}\n\\newtheorem*{cnj}{Conjecture}\n\\newtheorem*{lem}{Lemma}\n\\newtheorem*{cor}{Corollary}\n\\newtheorem*{prop}{Proposition}\n\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\R}{\\mathbb{R}}\n\n\n\n\n\n\\title{Proof Portfolio Problem 8}\n\\author{}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\nAs a reminder, you should pick only one of the following problems. Remember to start ASAP and see me if you need help.\n\n\\emph{The initial deadline for Problems 5-8 is Monday, March 23 (11:59PM). The final deadline is Friday, March 30 (11:59PM).}\n\n%Sets\n\\noindent\\textbf{Conjecture 8A.}\\footnote{The symbol $\\times$ is defined on page 256 of your text.  For two sets $X$ and $Y$, $X \\times Y = \\{(x,y) \\mid x \\in X \\text{ and } y\\in Y.\\}$ Think of ordered pairs, like you're graphing on the Cartesian plane.} If $A,B,$ and $C$ are subsets of some universal set $U$ then\n \\[A\\times (B\\cup C) = (A\\times B) \\cup(A\\times C).\\]\\\\\n \n\n\n\\noindent\\textbf{Conjecture 8B.} Let $X = \\{x \\in\\mathbb{Z} : x \\equiv 2 \\pmod{6} \\}$ and $Y = \\{y\\in\\mathbb{Z} : 3 \\mid y-5\\}$.  Prove that one of these sets is a proper subset of the other (stating your result as a theorem).\\\\\n\n\n\n\n\\section*{Some LaTeX Notes:}\nFor 8A:\n\\begin{verbatim}\n$A\\times (B-C) = (A\\times B) - (A\\times C)$\n\\end{verbatim}\n\n\n\\noindent For 8B:  \\begin{verbatim}\n$X = \\{x \\in\\mathbb{Z} : x \\equiv 2 \\pmod{6} \\}$ \\end{verbatim}\nand \n\n\\begin{verbatim}$Y = \\{y\\in\\mathbb{Z} : 3 \\mid y-5\\}$\\end{verbatim}\n(The \\begin{verbatim} \\ \\end{verbatim} makes the set braces appear.) You could also use \\begin{verbatim} \\Z \\end{verbatim} if you are using my LaTeX file (instead of \\begin{verbatim}\\mathbb{Z} \\end{verbatim}) .)\n\n\n\\end{document}", "meta": {"hexsha": "5ec35f941a30ab235f93501af3b33cb3701fd8c8", "size": 1805, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "from LDK/4-ProofPortfolio/Problems/Problem8.tex", "max_stars_repo_name": "mkjanssen/discrete", "max_stars_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "from LDK/4-ProofPortfolio/Problems/Problem8.tex", "max_issues_repo_name": "mkjanssen/discrete", "max_issues_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "from LDK/4-ProofPortfolio/Problems/Problem8.tex", "max_forks_repo_name": "mkjanssen/discrete", "max_forks_repo_head_hexsha": "4038b6d102000f4eeb27adaa8d0fd2bde63c28ac", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.593220339, "max_line_length": 315, "alphanum_fraction": 0.6792243767, "num_tokens": 650, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.4264913136772769}}
{"text": "\\section{Simulation Results}\n\n\n\nThe results presented in this section were generated by running Monte Carlo simulations of the search procedure, since finding a closed-form solution to the mean \\textbf{T}ime \\textbf{T}o \\textbf{D}ecision (TTD) is not readily available in the general case \\cite{Chung2012AnalysisStrategies}. We simulated the grid, the agents and the targets in order to evaluate the performance of the system.\n%and to analyse how modifying search parameters affects the outcome.\nWe present statistics related to the Monte Carlo simulations, which reveal how modifying parameters of the search procedure affect the outcome. For each set of parameters in tables \\ref{table:VaryingPriorDistribution}, \\ref{table:VaryingInitialBelief}, \\ref{table:MiscalibratedSensor}, \\ref{table:MultipleTargetEGSweep}, \\ref{table:MultipleTargetSaccadicRandom} and \\ref{table:VaryingNumberOfAgents} we ran 5000 simulations, which finish when the agent (or agents) terminates the search. The parameters that we vary in the simulations are shown in Table \\ref{table:SimRunParameters}: \n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{|c|c|c|c|}\n    \\hline\n         Parameter& Configuration 1 & Configuration 2 & Configuration 3 \\\\\n         \\hline\n         Initial Distribution & Gaussian & Uniform & - \\\\\n         \n         \\hline\n         Initial Cumulative Probability & 0.25 & 0.5 & 0.75 \\\\\n         \n         \\hline\n         Sensor Model Parameters & $\\alpha$=0.05, $\\beta$ = 0.02 & $\\alpha$=0.2, $\\beta$ = 0.15 &\n         $\\alpha$=0.4, $\\beta$ = 0.4 \\\\\n         \n         \\hline\n         \\# of Targets Present & 1 & 2 & 3 \\\\\n         \n         \\hline\n         \\# of Agents Used & 1 & 2 & 3 \\\\\n         \n         \\hline\n    \\end{tabular}\n    \\caption{Parameters varied for each simulation run}\n    \\label{table:SimRunParameters}\n\\end{table}\n\nThe meaning of each of these parameters is outlined as follows:\n\\begin{enumerate}\n    \\item The initial belief distribution of each agent describes the distribution of $p(x_0 | e_0, u_0)$, which corresponds to the probability distribution describing its initial belief of the location of the target, prior to gathering any evidence. This may come from prior information about the scene. A Gaussian distribution is peaked, meaning that prior information suggests that some grid cells are more likely to contain the target than others. This can be seen in Figure \\ref{fig:InitialGaussian}. A Uniform distribution is not peaked, reflecting no prior information related to the location of the target. This can be seen in Figure \\ref{fig:InitialUniform}.\n    \\item The initial cumulative belief that the target is present in the region is the agent's belief in whether the target is present in the region, prior to gathering any evidence. It is the cumulative sum of the probabilities of the target presence in each of the grid cells. An initial cumulative belief of 0.25 means that initially, the agent is 25\\% sure that the target is present in the region. \n    \\item The sensor model false positive rate and false negative rate and the parameters $\\alpha$ and $\\beta$ are set out in Section \\ref{subsec:stochasticEnvModel}. These can differ from the true rate at which the sensor will observe positive and negative observations. For example, given that the sensor actually outputs false positives and false negatives at a rate of 0.2 and 0.15 respectively, if the sensor model is calibrated with a false positive rate and false negative rate of 0.05 and 0.02 respectively, it will drastically under-estimate the rate at which false readings are recorded, which is reflected in the way it updates its estimated state.\n    \\item \\# of Targets Present gives the number of distinct targets present in the search region. These are assumed to exist in distinct locations.\n    \\item \\# of Agents Used is the number of agents participating in the search.\n\\end{enumerate}\nThe results of the simulations show how varying these parameters and suggest how to set them to achieve a desired result. We focus on the most commonly reported metrics in the literature, which are related to the distribution of time to decision \\cite{Chung2012AnalysisStrategies}, \\cite{Waharte2010ProbabilisticUAVs}, \\cite{Waharte2010SupportingUAVs} and \\cite{Lau2007OptimalEnvironments}. The time to decision is measured as the number of discrete time-steps before the search concludes. We also report on the rate at which incorrect target locations are returned and the rate at which the agents incorrectly conclude that the target is not present. \n\n\\par For each of the simulations, we arbitrarily chose to use the SPRT cut-off criteria with the upper Type \\Romannum{1} error probability set to 0.1 and the upper Type \\Romannum{2} error probability set to 0.15. In practice, this meant the agent would terminate the search if its cumulative belief that the target was present exceeded 0.895 or fell below 0.143. We generated simulated sensor readings using arbitrarily chosen values of the false positive rate = 0.2 and a false negative rate = 0.15. For each simulation run, we generated random starting locations for the agents and targets in a uniformly spaced 10 $\\times$ 10 grid. \n\\par Unless specified otherwise, we use the following default parameters: sensor model false negative rate = 0.15, sensor model false positive rate = 0.2, initial belief distribution = uniform, initial cumulative belief target is present = 0.5, number of targets present = 1, number of active agents = 1, the $\\epsilon$-greedy search has $\\epsilon$=0.2 and a neighbourhood radius of 4. Histograms showing the results of running the simulation with varying parameters are shown in Appendix \\ref{chap:AppendixTwo}.\n\n\\input{Chapters/MultiAgentTargetDetection/Results/SingleAgentResults.tex}\n\n\n\\input{Chapters/MultiAgentTargetDetection/Results/MultipleAgentResults.tex}\n", "meta": {"hexsha": "6e36739fe82729896501f945b840a936ca8f0f7d", "size": 5863, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/MultiAgentTargetDetection/Results/Results.tex", "max_stars_repo_name": "DavidLSmyth/ResearchMScThesis", "max_stars_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/MultiAgentTargetDetection/Results/Results.tex", "max_issues_repo_name": "DavidLSmyth/ResearchMScThesis", "max_issues_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-06-18T11:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-18T11:59:42.000Z", "max_forks_repo_path": "Chapters/MultiAgentTargetDetection/Results/Results.tex", "max_forks_repo_name": "DavidLSmyth/ResearchMScThesis", "max_forks_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 110.6226415094, "max_line_length": 667, "alphanum_fraction": 0.7646256183, "num_tokens": 1364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4264273351802266}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Chapter 3: intro2 *********************************\n%*******************************************************************************\n\n\\chapter{The projective to Einstein correspondence $N\\rightarrow M$}\n\\label{chap:intro2}\n\nThe purpose of this chapter is to introduce the preliminaries that are required to understand the remainder of the thesis. We will first review projective geometry, including the Cartan and tractor bundles associated with a projective structure, before moving on to the projective to Einstein correspondence of \\cite{DM}. We begin with some notation and conventions.\n\n\\subsubsection{Notation and conventions}\n\\begin{itemize}\n\\item We use $\\R^n$ to mean the real vector space of dimension $n$, and $\\R_n$ to mean its dual. We think of vectors in $\\R^n$ as column vectors, and vectors in $\\R_n$ as row vectors.\n\\item We will projectivise vector spaces by \\textit{line projectivisation}, that is, we will take the space of \\textit{unoriented} lines through the origin, unless stated otherwise.\n\\item When we refer to the projective to Einstein correspondence, the projective manifold will be called $N$ and will have dimension $n$, whilst the Einstein manifold will be called $M$ and will have dimension $2n$.\n\\item We use the letter $\\pi$ for maps to $N$, and the letter $\\kappa$ for maps to $M$. We will attach subscripts to $\\pi$ and $\\kappa$ to give information about the preimage or the significance of the map.\n\\item We use lower case Latin indices $i,j,k,\\dots=1,\\dots,n$ for tensorial objects on $N$ and $a,b,c,\\dots=1,\\dots,2n$ for tensorial objects on $M$.\n\\item We use $\\odot$ and $\\wedge$ to denote the symmetrised and antisymmetrised tensor product respectively. That is,\n\\[\nA\\odot B = \\frac{1}{2}(A\\otimes B + B\\otimes A),\\qquad A\\wedge B = \\frac{1}{2}(A\\otimes B - B\\otimes A).\n\\]\nWe also occasionally write $A^2$ for $A\\odot A$, and in Chapter \\ref{chap:EW_and_toda} we will sometimes omit the $\\odot$ altogether.\n\\item Where indices have been symmetrised or antisymmetrised over, we will enclose them in round or square brackets respectively.\n\\item Our conventions for differential forms are\n\\[\n(d\\omega)_{ab\\dots c}=\\partial_{[a}\\omega_{b\\dots c]},\\qquad (\\eta\\wedge\\omega)_{a\\dots d}=\\eta_{[a\\dots b}\\omega_{c\\dots d]},\\]\n\\[\n\\omega=\\omega_{a\\dots b}\\,dx^{a}\\wedge\\dots\\wedge dx^{b}, \\qquad F_{ab}\\,{d}x^{a}\\wedge{d}x^{b}=F_{[ab]}\\,{d}x^{a}\\otimes{d}x^{b}.\n\\]\n\\item We use $\\hook$ to denote a contraction between a vector and a form.\n\\item The Riemann curvature tensor $R_{abc}^{\\quad d}$ of a connection $\\nabla_a$ is defined by\n\\[\n(\\nabla_a\\nabla_b - \\nabla_b\\nabla_a)X^d = R_{abc}^{\\quad d}X^c,\n\\]\nwhere $X$ is any vector field.\n\\item The Ricci tensor is defined by the contraction $R_{bc} = R_{abc}^{\\quad a}$.\n\\end{itemize}\n\n\n\\section{Projective Geometry}\\label{sec:projgeom}\n\nOur discussion follows Eastwood \\cite{Eastwood}.\n\n\\begin{defi}\\label{def:projstruct} A projective structure $(N,[\\nabla])$\non a manifold $N$ is an equivalence class $[\\nabla]$ of torsion--free affine connections on $N$ which have the same geodesics as unparametrised curves.\n\\end{defi}\n\nThe following proposition converts definition \\ref{def:projstruct} to a more operational form.\n\n\\begin{prop} Two torsion--free connections $\\nabla$ and $\\ov{\\nabla}$ belong to the same projective class if and only if their components $\\Gamma^i_{jk}$ and $\\ov{\\Gamma}^i_{jk}$ are related by\n\\begin{equation}\n\\ov{\\Gamma}^i_{jk} - \\Gamma^i_{jk} = \\delta_{j}^{i}\\Upsilon_{k}+\\delta_{k}^{i}\\Upsilon_{j}\\label{eq:proj_change}\n\\end{equation}\nfor some one--form $\\Upsilon.$\n\\end{prop}\n\n{\\bf Proof.} We denote by $\\mathcal{V}$ the vertical sub--bundle of $T(TN)$, where $\\pi_T:TN\\rightarrow N$ is the tangent bundle to $N$. A connection defines a splitting of the exact sequence\n\\be \\label{eq:TTMsequence}\n0 \\longrightarrow \\mathcal{V} \\longrightarrow T(TN) \\longrightarrow \\pi_T^*TN \\longrightarrow 0\n\\ee\nso that each $\\xi\\in T_xN$ has a unique pull--back in the horizontal sub--bundle complementary to $\\mathcal{V}_x$. The integral curves of these pull--backs, when projected down to $N$, then define the geodesics of the connection.\n\nAny two connections are related by some $\\delta\\Gamma^k_{ij}$, which satisfies $\\delta\\Gamma^k_{ij}=\\delta\\Gamma^k_{(ij)}$ as long as both connections are torsion--free. A change of connection is equivalent to a change in the splitting of (\\ref{eq:TTMsequence}). At $\\xi\\in T_xN$, the change is given by the homomorphism from $T_xN$ to $T_xN=\\mathcal{V}_x$ defined by the contraction $\\xi^i\\Gamma^k_{ij}$. Thus the two connections define the same geodesics if and only if $\\xi^i\\xi^j\\Gamma^k_{ij}$ is a multiple of $\\xi^k$ for all $\\xi^i$. This is true if and only if there is a one--form $\\Upsilon_i$ such that (\\ref{eq:proj_change}) is satisfied.\\footnote{To see this, take some one--form $\\omega_i$ and note that $2\\xi^i\\xi^j\\delta^k_{(i}\\Upsilon_{j)}\\omega_k$ vanishes if and only if $\\xi^k\\omega_k$ does.}\n\\koniec\n\nOne can show that the curvature of a connection $\\nabla$ in the projective class can be uniquely decomposed as\n\\be \\label{eq:projcurvdecomp}\nR_{ijk}^{\\ \\ \\ l} = W_{ijk}^{\\ \\ \\ l} + 2\\delta^l_{[i}\\Rho_{j]k} -2\\Rho_{[ij]}\\delta^l_k,\n\\ee\nwhere the Weyl projective curvature tensor, $W_{ijk}^{\\ \\ \\ l}$, is trace free, and the Schouten tensor, $\\Rho_{ij}$, is given in terms of the Ricci tensor by\n\\[\n\\Rho_{ij}=\\frac{1}{n-1}R_{(ij)}+\\frac{1}{n+1}R_{[ij]}.\n\\]\nThe objects $W_{ijk}^{\\ \\ \\ l}$ and $\\Rho_{ij}$ transform as\n\\be \\label{eq:schout_change}\n\\ov{W}_{ijk}^{\\ \\ \\ l} = W_{ijk}^{\\ \\ \\ l}, \\qquad \\ov{\\Rho}_{ij} = \\Rho_{ij} - \\nabla_i\\Upsilon_j + \\Upsilon_i\\Upsilon_j\n\\ee\nunder a change of representative connection (\\ref{eq:proj_change}). Note that for $n=2$ the Weyl tensor always vanishes.\n\nA projective structure in dimension $n$ is said to be flat if it is diffeomorphic to the real projective space $\\RP^n$ with its standard flat projective structure.\n\\begin{defi} \\label{def:RPn}\nThe real projective space $\\RP^n$ of dimension $n$ is the space of unoriented lines through the origin in $\\R^{n+1}$, thought of as $\\RP^n=(\\R^{n+1}\\backslash\\{0\\})/\\R^*$, where the quotient identifies points $P\\in\\R^{n+1}$ under the equivalence relation\n\\[\n(P^0,\\dots,P^n)\\sim (cP^0,\\dots,cP^n)\\ \\forall\\ c\\in\\R^*.\n\\]\nThe geodesics on $\\RP^n$ are given by planes through the origin in $\\R^{n+1}$ under the projection $\\pi_\\PP:\\R^{n+1}\\rightarrow\\RP^n$.\n\\end{defi}\n\n\\begin{rmk}\nLet $P$ denote a non--zero point in $\\R^{n+1}$ with coordinates $(P^0,\\dots,P^n)^T$, and let $[P]$ denote the corresponding point in $\\RP^n$, labelled by homogeneous coordinates. In a patch $\\mathcal{U}_0$ where $P^0\\neq 0$, we can write $[P]=[1,P^1/P^0,\\dots,P^n/P^0]^T$ and define inhomogeneous coordinates on $\\RP^n$ by\n\\[\n(x^1,\\dots,x^n) = (P^1/P^0,\\dots,P^n/P^0).\n\\]\nIf we combine this with coordinate patches $\\mathcal{U}_i$ where $P^i\\neq 0,\\ i=1,\\dots,n$, we can build an atlas for $\\RP^n$.\n\\end{rmk}\n\n\\begin{rmk}\nThe flat projective structure on $\\RP^n$ has a special duality property which we now discuss. Consider the set of hyperplanes through the origin in $\\R^{n+1}$. These can be specified by their normal vector, which is defined only up to multiplication by $\\R^*$. Let us denote such a hyperplane by a non--zero row vector $L\\in\\R_{n+1}$. A point $P\\in\\R^{n+1}$ lies in the hyperplane defined by $L$ if and only if $L\\cdot P=0$.\n\nWhen we projectivise the $\\R^{n+1}$, any $P\\neq 0$ descends to a point $[P]\\in\\RP^n$, and any hyperplane descends to a hypersurface $[L]\\subset\\RP^n$. The incidence relation $L\\cdot P=0$ is now equivalent to the point $[P]$ lying in the hypersurface $[L]$. The homogeneous coordinates $[L]$ parametrise a second projective space which we think of as the dual to the $\\RP^n$ parametrised by $[P]$, and denote $\\RP_n$.\n\\end{rmk}\n\n\\begin{rmk}\nReal projective space can be viewed as homogeneous space as follows. \nThe group $SL(n+1,\\mathbb{R})$ acts from the left via the fundamental representation on coordinates $(P^0,\\dots,P^n)^T$ in $\\R^{n+1}$, and this descends to a transitive action on $\\RP^n$. By the orbit stabiliser theorem, $\\RP^n=SL(n+1,\\R)/S$, where $S$ is a subgroup stabilising a point. If we choose the point $[1,0,\\dots,0]^T$, the elements of $S$ are matrices of the general form\n\\[\n\\begin{pmatrix}\\mathrm{det}a^{-1} & b\\\\\n0 & a\n\\end{pmatrix}\n\\]\nfor some $a\\in GL(n,\\mathbb{R})$ and $b\\in\\mathbb{R}_{n}$.\n\\end{rmk} \n\n\\begin{rmk}\nThe necessary and sufficient condition for flatness of a projective structure depends on the dimension of the manifold on which it is defined. In dimension $n>2$, a projective structure is flat if and only if its Weyl projective curvature tensor vanishes. However, for $n=2$ the projective Weyl tensor is always vanishing. It can be shown that a projective structure on a \\textit{surface} is flat if and only if the Cotton tensor $\\nabla_{[i}\\Rho_{j]k}$ vanishes for any choice of representative connection.\n\\end{rmk}\n\n\\subsection{The Cartan bundle}\n\nOne way of understanding the construction in \\cite{DM}\nis via the Cartan bundle \\cite{Cartan} of the projective structure $(N,[\\nabla])$ (see also \\cite{KobNag,Sharpe}). Cartan geometries generalise Klein's Erlangen programme \\cite{Klein}, a study of homogeneous spaces $G/S$, to the curved case, in which the total space $G$ is replaced by a principal right $S$-bundle over a manifold $N$ such that the tangent space to $N$ at every point is isomorphic to the Lie algebra quotient $\\mathfrak{g}/\\mathfrak{s}$. Since projective structures are modelled on $\\mathbb{RP}^{n}$, which can be viewed as a homogeneous space, they constitute a type of Cartan geometry.\n\nIn the Riemannian case, the model space is $\\mathbb{R}^{n}\\cong\\mathrm{Euc}(n)/SO(n)$. The corresponding Cartan geometry is a general, curved Riemannian manifold. One has an obvious subclass of frames which are ``adapted'' to the metric, i.e. those which are orthonormal. We can thus think of a curved Riemannian manifold as a principal $SO(n)$ bundle whose tangent spaces are modelled on $\\mathbb{R}^{n}\\cong\\mathfrak{Euc}(n)/\\mathfrak{so}(n)$. We say that Riemannian manifolds are Cartan geometries of type $(\\mathrm{Euc}(n),SO(n))$.\n\nThe theory of Cartan geometries was developed as part of Cartan's\n\\textit{method of moving frames}. The idea is to pick out some adapted frames for manifolds equipped with some non-metric structure. The bundle of such frames over a manifold is then a principal bundle $\\pi_\\mathcal{G}:\\mathcal{G}\\rightarrow N$ with structure group $S$.\n\nThe bundle $\\mathcal{G}$ is equipped with a $\\mathfrak{g}$-valued one-form\n$\\theta$ called the Cartan connection. It defines an isomorphism $\\theta:T_{u}\\mathcal{G}\\rightarrow\\mathfrak{g}$ at every point $u\\in \\mathcal{G}$ such that the vertical subspace $\\mathcal{V}_{u}\\mathcal{G}\\subset T_{u}\\mathcal{G}$ is mapped to $\\mathfrak{s}$ and the horizontal subpace $\\mathcal{H}_{u}\\mathcal{G}\\subset T_{u}\\mathcal{G}$ is defined as the inverse image of $\\mathfrak{g}/\\mathfrak{s}$. Note that it is not a connection in the usual sense of a principal bundle connection, since it takes value in a Lie algebra larger than that of the structure group. Further details can be found in \\cite{Sharpe}.\n\n%The importance of the Cartan connection is that it satisfies a number of properties, in particular equivariance, i.e. $R_{h}^{*}\\theta=\\mathrm{Ad}(h^{-1})\\theta$ for all $h\\in H$. \n\nIn the projective case, if we choose the point which is stabilised by $S$ to be $[1,0,\\dots,0]$, the Cartan connection can be written as a matrix\n\\be \\label{eq:cartan_connection}\n\\theta=\\begin{pmatrix}-\\mathrm{tr}\\phi & \\eta\\\\\n\\omega & \\phi\n\\end{pmatrix},\n\\ee\nwhere $\\omega$, $\\eta$ and $\\phi$ are one-forms valued in $\\mathbb{R}^{n}$, $\\mathbb{R}_{n}$ and $\\mathfrak{gl}(n,\\mathbb{R})$ respectively.\nWe will refer to the components of $\\omega$ and $\\eta$ with respect\nto the natural basis of $\\mathfrak{sl}(n+1,\\mathbb{R})$ as $\\{\\omega^{(i)}\\}$ and $\\{\\eta_{(i)}\\}$, so that $\\omega^{(i)}$ and $\\eta_{(i)}$ are both one-forms taking values in $\\R$.\n\n\\begin{defi}\nThe Cartan geometry of a projective structure $(N,[\\nabla])$ consists of a principal right $S$--bundle $\\pi_\\mathcal{G}:\\mathcal{G}\\rightarrow N$, where the right--action of some $s\\in S$ on $\\mathcal{G}$ is denoted by $R_s$, and a one--form $\\theta$ on $\\mathcal{G}$ called the Cartan connection, which takes values in $\\mathfrak{sl}(n+1,\\mathbb{R})$. The Cartan connection can be written in the form (\\ref{eq:cartan_connection}) and has the following properties:\n\\begin{enumerate}\n\\item $\\theta_u:T_u\\mathcal{G}\\rightarrow\\mathfrak{sl}(n+1,\\R)$ is an isomorphism for all $u\\in \\mathcal{G}$;\n\\item $\\theta(\\xi_\\mathfrak{v})=\\mathfrak{v}$ for all fundamental vector fields $\\xi_\\mathfrak{v}$ on $\\mathcal{G}$;\n\\item $R^*_s\\theta = \\mathrm{Ad}(s^{-1})\\theta=s^{-1}\\theta s$ for all $s\\in S$.\n\\item If $\\xi$ is a vector field on $\\mathcal{G}$ with the property that $\\eta(\\xi)=\\phi(\\xi)=0$ and $\\omega(\\xi)\\in\\R^n\\backslash\\{0\\}$, then the integral curve of $\\xi$ projects down to a geodesic on $N$ and conversely every geodesic of $[\\nabla]$ arises in this way.\n\\item The $\\mathfrak{sl}(n+1,\\mathbb{R})$-valued\ncurvature two-form $\\Theta$ satisfies\n\\be \\label{eq:curvature_2-form}\n\\Theta=d\\theta+\\theta\\wedge\\theta=\\begin{pmatrix}0 & L(\\omega\\wedge\\omega)\\\\\n0 & W(\\omega\\wedge\\omega)\n\\end{pmatrix},\n\\ee\nwhere $L$ and $W$ are smooth curvature functions valued in $\\mathrm{Hom}(\\R^n\\wedge\\R^n,\\R_n)$ and $\\mathrm{Hom}(\\R^n\\wedge\\R^n,\\R_n\\otimes\\R^n)$ respectively. The function $W$ represents the Weyl projective curvature tensor appearing in (\\ref{eq:projcurvdecomp}).\n\\end{enumerate}\n\\end{defi}\n\n\\begin{rmk}The Cartan geometry of a projective structure is unique in the sense that for any two Cartan geometries $(\\widehat{\\pi}_\\mathcal{G}:\\widehat{\\mathcal{G}}\\rightarrow N,\\widehat{\\theta})$ and $(\\pi_\\mathcal{G}:\\mathcal{G}\\rightarrow N,\\theta)$ of type $(SL(n+1,\\R),S)$ satisfying the above properties there is a $S$--bundle isomorphism $\\nu:\\mathcal{G}\\rightarrow\\widehat{\\mathcal{G}}$ such that $\\nu^*\\widehat{\\theta}=\\theta$. %This means that although we cannot choose a unique connection on the tangent bundle to $N$, we can choose a unique connection on the Cartan bundle.\n\\end{rmk}\n\n\\begin{rmk} \\label{rmk:theta_symmetry}\nFor every open set $\\mathcal{U}\\subset N$, projective vector fields on $\\mathcal{U}$ are in one-to-one correspondence with vector fields on $\\pi_\\mathcal{G}^{-1}(\\mathcal{U})$\nwhich preserve $\\theta$ and are equivariant under the principal $S$--action.\n\\end{rmk}\n\n\n\n\n\n\n\\subsection{Tractor bundles}\nThe Cartan connection also gives us a unique connection on any bundle associated to $\\mathcal{G}$ via some $S$--module. In particular, let $\\mathcal{B}$ be a vector space and $\\rho_\\mathcal{B}:S\\rightarrow GL(\\mathcal{B})$ a representation of $S$ acting on $\\mathcal{B}$. We can construct an \\textit{associated bundle}\n\\[\\pi_\\mathcal{B}:\\mathcal{G}\\times_{\\rho_\\mathcal{B}} \\mathcal{B}\\rightarrow N \\]\nwhere points in $\\mathcal{G}\\times_{\\rho_\\mathcal{B}} \\mathcal{B}$ are equivalence classes of pairs $[u,v]$, where $u\\in \\mathcal{G}$ and $v\\in \\mathcal{B}$, up to the equivalence relation\n\\[\n(u_1,v_1)\\sim (u_2,v_2) \\quad \\Leftrightarrow \\quad \\exists\\ s\\ \\mbox{such that}\\  u_2=u_1 s,\\  v_2 = \\rho_\\mathcal{B}(s^{-1}) v_1.\n\\]\n\nWe thus obtain a vector bundle over $N$ whose fibres are diffeomorphic to $\\mathcal{B}$. A section $\\tilde{\\sigma}:N\\rightarrow \\mathcal{G}\\times_{\\rho_\\mathcal{B}} \\mathcal{B}$ is represented by a map ${\\sigma}:\\mathcal{G}\\rightarrow \\mathcal{B}$ which is equivariant in the sense that ${\\sigma}(us)=\\rho_\\mathcal{B}(s^{-1}){\\sigma}(u)$ for all $s\\in S$. Importantly, any such bundle inherits a connection from the Cartan connection $\\theta$ on $\\mathcal{G}$. The concept of an associated bundle applies to any principal bundle, but we call vector bundles which are associated to a Cartan bundle \\textit{tractor} bundles, and the connections that they inherit from the Cartan connection are called tractor connections.\n\nA particularly important example of a vector bundle associated to $\\mathcal{G}$ is the \\textit{cotractor bundle}, which defined by the canonical action of $S$ on $\\R_{n+1}$ given by $(s,L)\\mapsto Ls^{-1}$. We call this bundle $\\pi_\\mathcal{T}:\\cT^*\\rightarrow N$. In order to describe its connection, we consider a section represented by $\\sigma:\\mathcal{G}\\rightarrow\\R_{n+1}$ and define the one--form\n\\be \\label{eq:df-ftheta}\nd\\sigma - \\sigma\\theta.\n\\ee\nThis turns out to be a \\textit{semi--basic}\\footnote{Recall that a semi--basic form on a fibre bundle $\\mathcal{G}\\rightarrow N$ is a form which is a linear combination, with coefficients parametrised by the fibres, of basic forms on $\\mathcal{G}$ (i.e. forms which are the pull-backs of forms on $N$).} one--form satisfying\n\\[\nR_s^*(d\\sigma-\\sigma\\theta) = (d\\sigma - \\sigma\\theta)s,\n\\]\nmaking $\\sigma\\mapsto d\\sigma-\\sigma\\theta$ an equivariant connection on $\\cT^*$.\n\nAlthough this construction of $\\mathcal{T}^*$ relies on the Cartan bundle, it is possible to construct it independently. In order to do so we need the notion of a \\textit{projective density}.%To do so, we consider the transformation of the derivative of a volume form under a projective change (\\ref{eq:proj_change}). This approach can be motivated by the fact that the special linear group $SL(n,\\R)$, which we have already seen to be important in projective geometry, is the group of volume preserving transformations of $\\R^n$.\n\\subsubsection{Projective densities}\nFrom the projective change of connection (\\ref{eq:proj_change}) we can derive the corresponding change in $\\nabla\\chi$ for some $m$--form $\\chi$ on $N$:\n\\be \\label{eq:p-form_change}\n\\ov{\\nabla}_i\\chi_{jk\\dots l} = \\nabla_i\\chi_{jk\\dots l} - (m+1)\\Upsilon_i\\chi_{jk\\dots l} - (m+1)\\Upsilon_{[i}\\chi_{jk\\dots l]}.\n\\ee\nIn particular, for a volume form ($m=n$) we find\n\\[\n\\ov{\\nabla}_i\\chi_{jk\\dots l} = \\nabla_i\\chi_{jk\\dots l} - (n+1)\\Upsilon_i\\chi_{jk\\dots l},\n\\]\nwhere the final term in (\\ref{eq:p-form_change}) has vanished because it contains a symmetrisation over $n+1$ indices. We can write this in a more compact way as\n\\[\n\\ov{\\nabla}_i\\chi = \\nabla_i\\chi - (n+1)\\Upsilon_i\\chi.\n\\]\n\nNote that for sections $\\tau$ of the bundle $\\mathcal{E}(w):=(\\Lambda^n)^{-w/(n+1)}$ we have\n\\be \\label{eq:ddensity_change}\n\\ov{\\nabla}_i\\tau = \\nabla_i\\tau + w\\Upsilon_i\\tau.\n\\ee\nWe called such sections \\textit{projective densities of weight $w$}, and for any vector bundle $\\mathcal{B}\\rightarrow N$ we write $\\mathcal{B}(w)$ for the tensor product of $\\mathcal{B}$ with $\\mathcal{E}(w)$. For example, $T^*N(w)$ is the bundle of one--forms with projective weight $w$, and for sections $\\mu_i$ of $T^*N(w)$ we have\n\\be \\label{eq:dweighted_form_change}\n\\ov{\\nabla}_i\\mu_j = \\nabla_i\\mu_j + (w-1)\\Upsilon_i\\mu_j - \\Upsilon_j\\mu_i.\n\\ee\n\n\\subsubsection{The cotractor bundle}\nWe can now define the cotractor bundle $\\pi_\\cT:\\mathcal{T}^*\\rightarrow N$. For a choice of connection in the projective class we identify\n\\be \\label{eq:T*splitting}\n\\mathcal{T}^* = \\mathcal{E}(1)\\oplus T^*N(1),\n\\ee\nso that a section can be represented by a pair\n\\be \\label{eq:T*coords}\n\\begin{pmatrix}\n{\\tau} \\\\ {\\mu}_i\n\\end{pmatrix}.\n\\ee\nUnder a change of projective connection (\\ref{eq:proj_change}), this splitting changes according to\n\\be \\label{eq:chi_mu_change}\n\\ov{\\begin{pmatrix}\n{\\tau} \\\\ {\\mu}_i\n\\end{pmatrix}} =\n\\begin{pmatrix}\n\\tau \\\\ \\mu_i + \\Upsilon_i\\tau\n\\end{pmatrix}.\n\\ee\nNote the exact sequence\n\\be \\label{eq:T*sequence}\n0\\longrightarrow T^*N(1)\\longrightarrow \\mathcal{T}^* \\overset{V}\\longrightarrow \\mathcal{E}(1)\\longrightarrow 0,\n\\ee\nwhere we call the map $V$ the projective \\textit{canonical tractor}\\footnote{In fact $V$ is a section of a bundle $\\mathcal{T}(1)$, where $\\mathcal{T}$ can be identified with a direct sum $\\mathcal{E}(1)\\oplus TN(1)$ given a choice of connection in the projective class. The natural pairing between $\\mathcal{T}$ and $\\mathcal{T}^*$ defines the map $V:\\mathcal{T}^*\\rightarrow\\mathcal{E}(1)$.}. A choice of connection in the projective class defines a splitting (\\ref{eq:T*splitting}) of (\\ref{eq:T*sequence}).\n\nThe bundle $\\mathcal{T}^*$ admits a projectively invariant \\textit{tractor connection} given by\n\\be \\label{eq:tractor_connection}\n\\nabla^\\mathcal{T}_i \\begin{pmatrix}\n\\tau \\\\ \\mu_j\n\\end{pmatrix}\n= \\begin{pmatrix}\n\\nabla_i \\tau - \\mu_i \\\\\n\\nabla_i\\mu_j + \\Rho_{ij}\\tau\n\\end{pmatrix},\n\\ee\nwhere $\\nabla$ is the choice of projective connection and $\\Rho_{ij}$ is its Schouten tensor. This turns out to agree with (\\ref{eq:df-ftheta}). Under a change of projective connection (\\ref{eq:proj_change}), we find\n\\begin{align*}\n\\ov{\\nabla}^\\mathcal{T}_i\\ov{\\begin{pmatrix}\n\\tau \\\\ \\mu_j\n\\end{pmatrix}}\n&= \\ov{\\nabla}^\\mathcal{T}_i\\begin{pmatrix}\n\\tau \\\\ \\mu_j + \\Upsilon_j\\tau \\end{pmatrix} \\\\\n&= \\begin{pmatrix}\n\\ov{\\nabla}_i\\tau - (\\mu_i + \\Upsilon_i\\tau) \\\\\n\\ov{\\nabla}_i(\\mu_j+\\Upsilon_j\\tau) + \\ov{\\Rho}_{ij}\\tau\n\\end{pmatrix} \\\\\n&= \\begin{pmatrix}\n\\nabla_i\\tau + \\Upsilon_i\\tau - (\\mu_i + \\Upsilon_i\\tau) \\\\\n\\nabla_i(\\mu_j + \\Upsilon_j\\tau) - \\Upsilon_j(\\mu_i + \\Upsilon_i\\tau)\n+ (\\Rho_{ij} - \\nabla_i\\Upsilon_j + \\Upsilon_i\\Upsilon_j) \\tau\n\\end{pmatrix},\n\\end{align*}\nwhere we have used (\\ref{eq:chi_mu_change}) in the first line, (\\ref{eq:tractor_connection}) in the second and (\\ref{eq:ddensity_change}), (\\ref{eq:dweighted_form_change}) and (\\ref{eq:schout_change}) in the third. After some cancellation, we identify\n\\begin{align*}\n\\ov{\\nabla}^\\mathcal{T}_i\\ov{\\begin{pmatrix}\n\\tau \\\\ \\mu_j\n\\end{pmatrix}}\n&= \\begin{pmatrix}\n\\nabla_i\\tau - \\mu_i \\\\\n\\nabla_i\\mu_j + \\Upsilon_j\\nabla_i\\tau - \\Upsilon_j\\mu_i + \\Rho_{ij}\\tau\n\\end{pmatrix} \\\\\n&= \\ov{\\begin{pmatrix}\n\\nabla_i\\tau - \\mu_i \\\\\n\\nabla_i\\mu_j + \\Rho_{ij}\\tau\n\\end{pmatrix}}\n= \\ov{\\nabla^\\mathcal{T}_i \\begin{pmatrix}\n\\tau \\\\ \\mu_j\n\\end{pmatrix}}\n\\end{align*}\nusing (\\ref{eq:tractor_connection}) and the change of splitting (\\ref{eq:chi_mu_change}) adapted to the tensor product of $T^*N$ and $ \\cT^*$ of which the derivative is a section.\n\nAny tensor product of $\\cT,\\cT^*$ and $\\cE(1)$ is equipped with a tractor connection which is inherited from the connection on the standard cotractor bundle. Equivalently, any such tensor product can be thought of as an associated vector bundle to the Cartan bundle $\\mathcal{G}$, with its connection inherited from the Cartan connection via the corresponding representation of $S$. It is this connection, with its special equivariance property, that allows us to construct an Einstein metric as an invariant of the projective structure. This construction is the subject of the following section.\n\n\\section{The projective to Einstein correspondence}\nConsider a quotient of the total space $\\mathcal{G}$ of the\nCartan bundle by $GL(n,\\mathbb{R})$, which is embedded in $S$\nin the obvious way:\n\\be \\label{eq:GL(n)_embedding}\nGL(n,\\mathbb{R})\\ni a\\longmapsto\\begin{pmatrix}\\mathrm{det}a^{-1} & 0\\\\\n0 & a\n\\end{pmatrix}\\in S.\n\\ee\nIt is easily verified that \n\\[\n\\begin{pmatrix}\\mathrm{det}a^{-1} & 0\\\\\n0 & a\n\\end{pmatrix}\\begin{pmatrix}0 & \\eta\\\\\n\\omega & 0\n\\end{pmatrix}\\begin{pmatrix}\\mathrm{det}a^{-1} & 0\\\\\n0 & a\n\\end{pmatrix}^{-1}=\\begin{pmatrix}0 & \\eta a^{-1}\\mathrm{det}a^{-1}\\\\\n(\\mathrm{det}a)a\\omega & 0\n\\end{pmatrix},\n\\]\nfor any $a\\in GL(n,\\mathbb{R})$, meaning that due to the equivariance\nproperty of the Cartan connection, the natural contraction $\\eta\\omega:=\\sum_{i}\\eta_{(i)}\\otimes\\omega^{(i)}$\ndefined by $\\theta$ is preserved by the adjoint action of this $GL(n,\\mathbb{R})$\nsubgroup. It thus descends to a naturally defined object on the quotient\n$M=\\mathcal{G}/GL(n,\\mathbb{R})$.\n\n\\begin{theo}{\\cite{DM}}\\label{thm:DM}\nThere exist a metric and two--form\n$(g,\\Omega)$ on $\\mbox{\\ensuremath{M=\\mathcal{G}/GL(n,\\mathbb{R})}}$ such\nthat the quotient map $\\kappa_q:P\\rightarrow M$ gives\n\\begin{eqnarray} \n\\kappa_q^{*}g & = & \\mathrm{Sym}(\\eta\\omega) \\label{eq:g_cartan} \\\\\n\\kappa_q^{*}\\Omega & = & \\mathrm{Ant}(\\eta\\omega), \\label{eq:Omega_cartan}\n\\end{eqnarray}\nwhere $\\mathrm{Sym}$ and $\\mathrm{Ant}$ denote the symmetric and\nanti-symmetric parts of the $(0,2)$ tensor $\\eta\\omega$. Moreover,\n$\\Omega$ is closed as a consequence of the Bianchi identity satisfied by the curvature two--form (\\ref{eq:curvature_2-form}), $g$\nis Einstein with non-zero scalar curvature, and the two are related\nby an endomorphism $J$ satisfying $J^{2}=Id$. Hence $(g,\\Omega)$\nis an almost para--K\\\"ahler structure on $M$.\n\\end{theo}\n\n\n\\begin{rmk}\nThe full proof of Theorem \\ref{thm:DM} only appears explicitly in \\cite{DM} in the case $n=2$, although it can be generalised to $n>2$. This generalisation is discussed in their appendix. They show that the Ricci scalar of $g$ is $24$ in the case $n=2$. In Chapter \\ref{chap:KK_lift} we will need the Ricci scalar for general $n$. We will calculate this under the assumption (stated without proof in \\cite{DM}) that $g$ is Einstein.\n\\end{rmk}\n\n\\begin{rmk}\nThe quotient $M$ turns out to be an affine bundle over $N$ with\nstructure group $S$, i.e. $S$ acts affinely on the fibres of $\\pi_M:M\\rightarrow N$,\nand sections of this bundle are in one-to-one correspondence with\nrepresentative connections $\\nabla\\in[\\nabla]$. This means that given\nsome choice of connection $\\nabla\\in[\\nabla]$ we have a diffeomorphism\n$\\kappa_A:T^{*}N\\rightarrow M$ with which we can pull back the pair\n$(g,\\Omega)$. In canonical local coordinates $(x^{i},\\zeta_{i})$ on\nthe cotangent bundle, we find\n\\begin{eqnarray}\n\\kappa_A^{*}g & = &  d\\zeta_{i}\\odot dx^{i}-(\\Gamma_{ij}^{k}\\zeta_{k}-\\zeta_{i}\\zeta_{j}-\\Rho_{ij}) dx^{i}\\odot dx^{j},\\label{eq:coord_form}\\\\\n\\kappa_A^{*}\\Omega & = &  d\\zeta_{i}\\wedge dx^{i}+\\Rho_{ij} dx^{i}\\wedge dx^{j},\\qquad i,j=1,\\dots ,n.\\nonumber \n\\end{eqnarray}\nHere $\\Gamma_{jk}^{i}$ are the connection components of the representative\nconnection $\\nabla$ that we chose, and its Schouten tensor is denoted $\\Rho_{ij}$. This can be shown to be projectively invariant\nin the sense that a different choice of $\\nabla\\in[\\nabla]$ corresponds\nto shifting the fibre coordinates $\\zeta_{i}$, i.e. metrics on $T^{*}N$\nresulting from pulling back $g$ using different representative connections\nare isometric. Explicitly, a projective transformation (\\ref{eq:proj_change})\ncorresponds to a change\n\\begin{equation}\n\\zeta_{i}\\longrightarrow \\zeta_{i}+\\Upsilon_{i}.\\label{eq:zeta_change}\n\\end{equation}\n\\end{rmk}\n\n\n\\begin{rmk}\nIn fact, the metric and symplectic form (\\ref{eq:coord_form}) turn\nout to belong to a one-parameter family $\\{(g_\\Lambda,\\Omega_\\Lambda)\\,;\\,\\Lambda\\neq 0\\}$, which\ncan be written in local coordinates as \n\\begin{eqnarray}\ng_{\\Lambda} & = &  d\\zeta_{i}\\odot dx^{i}-(\\Gamma_{ij}^{k}\\zeta_{k}-\\Lambda \\zeta_{i}\\zeta_{j}-\\Lambda^{-1}\\Rho_{ij}) dx^{i}\\odot dx^{j}\\label{eq:general_g}\\\\\n\\Omega_{\\Lambda} & = &  d\\zeta_{i}\\wedge dx^{i}+\\frac{1}{\\Lambda}\\Rho_{ij} dx^{i}\\wedge dx^{j},\\qquad i,j=1,\\dots ,n.\\label{eq:general_omega}\n\\end{eqnarray}\nMetrics of the form (\\ref{eq:general_g}) are a subclass of so-called\nOsserman metrics. More details can be found in \\cite{osserman}. They are all Einstein with non--zero scalar curvature $24\\Lambda$, but for $\\Lambda\\neq1$ the relation to projective geometry is lost. For the remainder of the thesis we will write $g$ for $g_{\\Lambda=1}$ unless stated otherwise. Note that $\\{g_\\Lambda\\}$ will be the subject of Chapter \\ref{chap:KK_lift}, whilst in Chapters  \\ref{chap:EW_and_toda} and \\ref{chap:c-proj} we will restrict our attention to $g$ because the projective geometry is a key aspect of the content of these chapters.\n\\end{rmk}\n\n\n\n\\begin{rmk}\nOne could also consider taking a quotient of $\\mathcal{G}$ by a different subgroup of $S$. The $\\R^*$ bundle over $M$ which we will discuss in Chapter \\ref{chap:KK_lift} will turn out to be a quotient of $\\mathcal{G}$ by $SL(n,\\R)$.\n\\end{rmk}\n\n\\begin{rmk}\nAs mentioned above, in the special case where the $(N,[\\nabla])$ is a projective surface, $M$ has dimension four, and so anti--self--duality is defined. It turns out that both the symplectic form $\\Omega$ and the conformal curvature of $g$ are ASD. Both of these facts will play an important role in Chapter \\ref{chap:EW_and_toda}.\n\\end{rmk}\n\n\\begin{rmk}\nNote that an endomorphism $J$ which squares to the identity defines two $n$--dimensional sub--bundles of the tangent bundle $TM$ defined at each $m\\in M$ as the vector subspaces of $T_mM$ which have eigenvalues $\\pm 1$ with respect to $J$. These sub--bundles form a pair of smooth distributions $D_\\pm$ in $TM$. Further discussion of the endomorphism $J$ will appear in Chapter \\ref{chap:c-proj}.\n\\end{rmk}\n\n\\subsection{Symmetries of $M$}\n\nRecall that a projective vector field on any manifold with a connection\ngenerates a one--parameter family of transformations which preserve the\ngeodesics of that connection up to parametrisation. Projective vectors\nfields thus naturally arise as the symmetries of a projective structure.\nExplicitly, a vector field $\\widehat{K}$ is projective if it satisfies\n\\begin{equation}\n\\mathcal{L}_{\\widehat{K}}\\Gamma_{ij}^{k}=\\delta_{i}^{k}\\Upsilon_{j}+\\delta_{j}^{k}\\Upsilon_{i}\\label{eq:proj_transf}\n\\end{equation}\nfor some 1-form $\\Upsilon$, where $\\Gamma_{ij}^{k}$ are the connection\ncomponents, and their Lie derivative is defined by\\footnote{Despite the fact that connection components are not tensorial objects, one can still define their Lie derivative with respect to a vector $\\widehat{K}$ by considering how they transform when one moves infinitesimally along the curve defined by $\\widehat{K}$. See \\cite{yano} for further details.}\n\\begin{equation}\n\\mathcal{L}_{\\widehat{K}}\\Gamma_{ij}^{k}\\equiv\\frac{\\partial^{2}\\widehat{K}^{k}}{\\partial x^{i}\\partial x^{j}}+\\widehat{K}^{m}\\frac{\\partial\\Gamma_{ij}^{k}}{\\partial x^{m}}-\\Gamma_{ij}^{m}\\frac{\\partial \\widehat{K}^{k}}{\\partial x^{m}}+\\Gamma_{im}^{k}\\frac{\\partial \\widehat{K}^{m}}{\\partial x^{j}}+\\Gamma_{mj}^{k}\\frac{\\partial \\widehat{K}^{m}}{\\partial x^{i}}.\\label{eq:liederivGamma}\n\\end{equation}\n\n\nOne consequence of the symmetry property of the Cartan connection discussed in remark \\ref{rmk:theta_symmetry} is that for every open set $\\mathcal{U}\\subset N$ we have an isomorphism between the Lie algebra of projective vector fields on $\\mathcal{U}$ and the Lie algebra of vector fields on $\\pi_\\mathcal{G}^{-1}(\\mathcal{U})$ preserving the natural contraction $\\eta\\omega$. Such vector fields must descend to vector fields on $\\pi_M^{-1}(\\mathcal{U})$ preserving $(g,\\Omega)$. In fact, it can be shown that every Killing vector field of $(M,g_\\Lambda)$ is also symplectic with respect to $\\Omega_\\Lambda$ and is therefore the lift of a projective vector field on $(N,[\\nabla])$.\n\nExplicitly, for every projective vector field $\\widehat{K}$ of $(N,[\\nabla])$\nthere is a corresponding symmetry $K$ of $(M,g_{\\Lambda},\\Omega_\\Lambda)$\ngiven in local coordinates by \n\\begin{equation}\n{K}=\\widehat{K}-\\zeta_{i}\\frac{\\partial \\widehat{K}^{j}}{\\partial x^{i}}\\frac{\\partial}{\\partial \\zeta_{j}}+\\frac{1}{\\Lambda}\\Upsilon_{i}\\frac{\\partial}{\\partial \\zeta_{i}},\\label{eq:kvf_from_pvf}\n\\end{equation}\nwhere $\\Upsilon_{i}$ is defined by (\\ref{eq:proj_transf}).\n\n\\subsection{Tractor perspective} \\label{sec:trac_construction}\n\nFrom the tractor perspective, the space $M$ will turn out to be the projectivised cotractor bundle of $N$ with an $\\RP^{n-1}$ sub--bundle removed from each fibre. We can understand what this $\\RP^{n-1}$ sub--bundle is as follows.\n\nOn the total space of $\\cT^*$ we pull back $\\pi_\\mathcal{T}:\\cT^*\\to N$ along $\\pi_\\mathcal{T}$ to get $\\pi_\\mathcal{T}^*(\\cT^*)\\to \\cT^*$ as a vector bundle over the total space $\\cT^*$. By construction this bundle has a tautological section $W\\in \\Gamma (\\pi_\\cT^*(\\cT^*))$.  We also have $\\pi_\\cT^*(\\cT(w))$ for any weight $w$, and we shall write simply $V\\in \\Gamma(\\pi_\\cT^*(\\cT(1)))$ for the pull back to $\\cT^*$ of the canonical tractor $V$ on $N$.\n\nNow define\n\\be\n\\label{projection_map}\n\\kappa_\\PP: \\cT^*\\longrightarrow \\mathcal{M}:=\\mathbb{P}(\\cT^*)\n\\ee\nby the fibre--wise projectivisation, and use $\\pi_\\cM$ for the map\n$$\n\\pi_\\cM:\\mathcal{M}\\to N.\n$$\nWe denote by $\\cE_{\\cT^*}(w')$, for $w'\\in \\mathbb{R}$, the line\nbundle on $\\mathbb{P}(\\cT^*)$ whose sections correspond to functions\n$f: \\pi_\\cT^*\\cT^* \\to\\mathbb{R} $ that are homogeneous of degree $w^\\prime$ in\nthe fibres of $\\pi_\\cT^*\\cT^*\\to \\mathbb{P}(\\cT^*)$. For any weight $w$ we also have $\\cE(w)$ on $N$ and its pull back to the bundle $\\pi_\\cM^*\\cE(w)\\to \\mathbb{P}(\\cT^*)$.\nWe define the product of these two density bundles on $\\cM$ as\n$$\n\\ce(w,w'):= \\pi_\\cT^*\\cE(w) \\otimes \\cE_{\\cT^*}(w').\n$$\n\nOn $\\cT^*$ there is  a canonical density $\\tau\\in \\Gamma(\\pi_\\cT^*\\cE(1))$ given by\n$$\n\\tau:= V\\hook W,\n$$\n%% and this is homogeneous of degree 1 up the fibres of $\\pi$ in the total space $\\cT^*$.\nNote that $\\tau$ is homogeneous of degree 1 up the fibres of the\nmap $\\kappa_\\PP:\\cT^*\\to \\mathcal{M}$. Thus $\\tau$ determines, and is equivalent\nto, a section (that we also denote) $\\tau$ of the density bundle $\\cE(1,1)$. So $\\mathcal{M}$ is stratified according to\nwhether or not $\\tau$ is vanishing, and we write $\\mathcal{Z}(\\tau)$\nto denote, in particular, the zero locus of $\\tau$. We will show in Chapter \\ref{chap:c-proj} that $M$ can be identified with $\\mathcal{M}\\setminus \\mathcal{Z}(\\tau)$.\n\n%\\rs{Note the\n%  second density bundle is not necessarily orientable.}\n\n\n\\subsection{The model case} \\label{sec:intro_model}\nWhen $(N,[\\nabla])$ is the flat projective structure $\\RP^n$, the metric and symplectic form (\\ref{eq:coord_form}) reduce to\n\\be \\label{eq:intro_model_g}\ng = d\\zeta_i\\odot dx^i + \\zeta_i\\zeta_j\\,dx^i\\odot dx^j, \\quad \\Omega = d\\zeta_i\\wedge dx^i,\\quad i,j=1,\\dots,n.\n\\ee\nIn this case the Cartan bundle of $N$ is just $SL(n+1,\\R)$, and $M$ is simply the Lie group quotient $SL(n+1,\\R)/GL(n,\\R)$. The cotractor bundle has zero curvature, and although it is not trivial, the restriction of $\\PP(\\cT^*)$ to the set $\\mathcal{Z}(\\tau)\\neq 0$ is. %in fact if we instead take $N$ to be the sphere $S^n$ with its standard flat projective structure where the geodesics are great circles, the tractor bundle is trivial. Note that $S^n$ is a double cover of $\\RP^n$ which is orientable in all dimensions, and consists of the set of \\textit{oriented} lines in $\\R^{n+1}$. We obtain it by taking an analogous quotient of $\\R^{n+1}$ where points are considered equivalent only up to multiplication by a \\textit{positive} number. Replacing $\\RP^n$ with $S^n$ allows us to write $cT=S^n\\times\\R^3$, so\nWe can thus write $M$ as\n\\[\nM=\\{([P],[L])\\in\\RP^n\\times\\RP_n\\ |\\ P\\cdot L\\neq 0\\}.\n\\]\n\nAs discussed in Section \\ref{sec:projgeom}, a point $[L]\\in\\RP_n$ represents a line $[L]\\subset\\RP^n$ which passes through $P\\in\\RP^n$ if and only if $L\\cdot P=0$. In Chapter \\ref{chap:EW_and_toda} we will show that for $n=2$, the conformal structure on $M$ can be obtained by demanding that two pairs $([P], [L])$ and $([\\tP], [\\tL])$ are null--separated if there exists a line which contains the three points $([P], [\\tP], [L]\\cap [\\tL])$.\n\nWe also find in the model case that the symplectic form $\\Omega$ is parallel with respect to the Levi--Civita connection $^{\\bf g}\\nabla$ of $g$, meaning that the endomorphism $J$ of $TM$ which relates $g$ and $\\Omega$ is also parallel. As a result of this, the distributions $D_\\pm$ defined by the two $n$--dimensional eigen--bundles of $J$ are parallel in the sense that $^{\\bf g}\\nabla_{\\xi_1}\\xi_2\\in\\Gamma(D_\\pm)$ for all $\\xi_1\\in \\Gamma(TM),\\ \\xi_2\\in\\Gamma(D_\\pm)$. This makes the distributions \\textit{Frobenius integrable}, meaning that the Lie bracket of any two sections of $D_\\pm$ is also a section of $D_\\pm$, or equivalently (as shown by Frobenius) that each of the two distributions is tangent to a foliation by sub--manifolds of dimension $n$ at every point.\n\nTo see that a parallel distribution is necessarily Frobenius integrable, note that the Lie bracket can be written\n\\[\n[\\xi_1,\\xi_2]= \\nabla_{\\xi_1}\\xi_2- \\nabla_{\\xi_2}\\xi_1\\in\\Gamma(D)\\quad\\mbox{for all}\\quad \\xi_1,\\xi_2\\in\\Gamma(D),\n\\]\nwhere $D$ is a distribution which is parallel with respect to a connection $\\nabla$. The Frobenius integrability of $D_\\pm$ makes $(M,g,\\Omega)$ not only almost para--K\\\"ahler but also para--K\\\"ahler. Further discussion about this distinction can be found in Chapter \\ref{chap:c-proj}.", "meta": {"hexsha": "48a699dd4bbe3cd156bd661d38fe24cb1c0de07a", "size": 36503, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/intro2.tex", "max_stars_repo_name": "AliceWaterhouse/thesis", "max_stars_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/intro2.tex", "max_issues_repo_name": "AliceWaterhouse/thesis", "max_issues_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/intro2.tex", "max_forks_repo_name": "AliceWaterhouse/thesis", "max_forks_repo_head_hexsha": "9abb336680cbf11f9aca809b26947e59557c2af8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.5262054507, "max_line_length": 814, "alphanum_fraction": 0.7115305591, "num_tokens": 11723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.4264273347304011}}
{"text": "%!TEX root =  ../main.tex\n\n\\objective{Use but also know the limitations of inverse trigonometric functions}\n\n\nThe standard trigonometric functions work by receiving angles as input, and outputting\nthe appropriate ration of side from the Unit Circle.  Often, we need have the ratio of sides\nand wish to know the angle that must exist between them.  Thinking in terms of functions,\nthis is the inverse of the normal, asking for the input corresponding to a given output.\nBut as we saw last section, the trigonometric functions all have an infinite number of\nrepetitions of each output.  They are not invertible.\n\nThat is to say, they do not invert to functions across their entire domains.  We must limit\ntheir possible input if their inverses are to be functions.  The criteria of deciding the\ninverse domains are:\n\\begin{itemize}\n\\item All possible outputs must be represented\n\\item Be as continuous as possible\n\\item Be centered around the origin\n\\end{itemize}\n\ninsert 6 inverse relations and highlighted ranges\n\ninsert unit circle with relevant semi-circles\n\n\\subsection{Composing}\n\\subsubsection{Inverse inside Normal}\nIt is straight-forward to interpret $\\sin(\\sin^{-1}(\\frac{1}{2}))$:  ``What is sine when\nsine is one-half?''  Very easy: it is one-half!  What about $\\sin(\\cos^{-1}(\\frac{1}{2}))$?\n``What is sine, when cosine is one-half?''  We could fine the angle were cosine has that\nvalue ($60^\\circ$) and take the sine of that angle, but we could also recognize that\narccosine is giving us adjacent-over-hypotenuse, and sine is asking for opposite-over-hypotenuse,\nand easy problem to solve with Pythagorus's help.  It is $\\frac{\\sqrt{3}}{2}$.\n\nThe second approach --- drawing a right triangle with two of the side-lengths known --- is\na much more power tool and extendable to more circumstances.  Consider \n$\\cos(\\sin^{-1}(x))$.  ``What is cosine when sine is $x$?''  Again, sine is giving us\nadjacent over hypotenuse.  We can imagine a right-triangle with one angle, call it\n$\\theta$.  Sine of $\\theta$ means the adjacent is $x$ and the hypotenuse is 1.\nThe Pythagorean Theorem will allow is to find the opposite: it must be $\\sqrt{1-x^2}$.\n\n\\begin{figure}\n\\begin{centering}\n\\begin{tikzpicture}\n\t\\draw (0,0) -- (2,0) -- (2,1) -- cycle;\n\t\\node (A) at (1.2,0) [anchor=north] {$x$};\n\t\\node (B) at (1.2,.5) [anchor=south] {1};\n\t\\node (C) at (.5,.2) [anchor=west] {$\\theta$};\n\t\\draw (1.9,0) -- (1.9,.1) -- (2.0,.1);\n\\end{tikzpicture}\n\\caption{A visualization of $\\cos(\\sin^{-1}(x))$.}\n\\end{centering}\n\\end{figure}\n\n\\subsubsection{Normal inside Inverse}\nPerhaps you would be surprised at the answer if you put $\\sin^{-1}(\\sin(3))$ into your\nTI-8*.  Would you expect it to answer 3?  How can we verbalize what this expression\nis asking?  ``Extend an arc 2 units and record the resulting height above the $x$-axis.\nWhat angle produces this height above the $x$-axis?''  We could interpret it visually\non the unit circle like this:\n\n\\begin{figure}[h]\n\\begin{centering}\n\\begin{tikzpicture}[scale=1.5]\n\t\\draw[<->] (-1.1,0) -- (1.1,0) node [anchor=west] {$x$};\n\t\\draw[<->] (0,-1.1) -- (0,1.1) node[anchor=south] {$y$};\n\t\\draw (0,0) circle (1);\n\t\\draw[->] (0,0) ++ (0:1.1) arc (0:170:1.1) node[midway,xshift=1.5cm] {3 radians};\n\t\\draw[dotted] (-1.1,0.14) -- (1.1,0.14);\n\\end{tikzpicture}\n\\caption{3 radians is a height arcsine can find in \\texttt{QI}.}\n\\end{centering}\n\\end{figure}\n\nNotice that the height above the $x$-axis -- the sine of the angle -- is achievable in\nthe first quadrant.  Arcsine --- because it is a function and can only return one\nvalue per input --- must answer a positive input in the first quadrant.\n\n\\subsection{Derivatives}\nHow can we find the derivatives of inverse trigonometric functions?  The\ndefinitions of inverses is very helpful: swapping $x$ and $y$.  Inverse sine is just\n$x=\\sin(y)$.  Using implicit differentiation, we get $dx=\\cos(y)dy$.  Therefore,\n$$\n\\frac{dy}{dx} = \\frac{1}{\\cos(y)} = \\frac{1}{\\cos(\\sin^{-1}(x))}\n$$\n\nAs we saw above, this can be simplified.  You will find all six inverse trigonometric \nfunctions derivatives in the exercises.\n", "meta": {"hexsha": "88a137bb57a3ccec8872e63c4e25c0c5dd8cc24d", "size": 4087, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch09/0905.tex", "max_stars_repo_name": "aquatiki/AnalysisTextbook", "max_stars_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-10-08T15:05:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-07T12:32:53.000Z", "max_issues_repo_path": "ch09/0905.tex", "max_issues_repo_name": "aquatiki/AnalysisTextbook", "max_issues_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch09/0905.tex", "max_forks_repo_name": "aquatiki/AnalysisTextbook", "max_forks_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.9213483146, "max_line_length": 97, "alphanum_fraction": 0.7142158062, "num_tokens": 1227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.8333245953120233, "lm_q1q2_score": 0.4264260325295411}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{II}\n\n\\def\\ntitle{Riemann Surfaces}\n\\def\\nlecturer{H.\\ Krieger}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2018}\n\n\\input{header}\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\section{Complex analysis \\& Branching/Multivalued functions}\n\n\\subsection{Holomorphicity}\n\n\\begin{definition}\n  A smooth function \\(f: U \\to \\C\\) from a domain (i.e.\\ an open connected subset of \\(\\C\\)) is \\emph{holomorphic} or \\emph{analytic} if either of the following holds:\n  \\begin{enumerate}\n  \\item \\(f\\) is differentiable in the sense of limits (which is equivalent to satisfying the Cauchy-Riemann equations),\n  \\item for each \\(a \\in U\\), \\(f\\) has a power series expansion\n    \\[\n      f(z) = \\sum_{n \\geq 0} a_n (z - a)^n,\n    \\]\n    valid on some disk \\(D(a, r)\\) with positive radius \\(r > 0\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{remark}\n  1 implies 2 since \\(f\\) being differentiable allows us to construct \\(a_n\\) using Cauchy Integral Formula. 2 implies 1 since \\(f\\) having power series allows term-by-term differentiation.\n\\end{remark}\n\nBy 2, if \\(a \\in U\\) and \\(f\\) is not identically \\(0\\) near \\(a\\), then there exists some minimal \\(m \\geq 0\\) such that \\(a_m \\neq 0\\). It follows that \\(f(z) = a_m (z - a)^m (1 + g(z - a))\\) where \\(\\lim_{z \\to a} g(z - a) = 0\\). Therefore for \\(z\\) sufficiently close to \\(a\\), \\(f\\) is nonzero. This is known as\n\n\\begin{theorem}[Principle of isolated zeros]\n  An analytic function on a domain \\(U\\) which is not identically zero has isolated zeros, i.e.\\ around each \\(a \\in U\\), there exists a disk \\(\\Delta_a\\) on which \\(f(z) \\neq 0\\) unless possibly at \\(z = a\\).\n\\end{theorem}\n\nIf \\(f\\) is identically \\(0\\) near \\(a\\), then there exists a disk \\(\\Delta_a\\) on which \\(f(z) = 0\\) for all \\(z \\in \\Delta_a\\). Consider \\(V := \\bigcup_{a: f|_{\\Delta_a} = 0} \\Delta_a\\) and \\(W := \\bigcup_{a: f \\neq 0 \\text{ near } a} \\Delta_a\\). \\(V\\) and \\(W\\) are open and disjoint so by connectivity of \\(U\\), one of them is empty so \\(f = 0\\) on \\(U\\) or has isolated zeros. Thus having isolated zero is a property of a domain, not a local property.\n\n\\begin{corollary}\n  If \\(f\\) and \\(g\\) are analytic on \\(U\\) then either \\(f = g\\) on \\(U\\) or \\(f(z) = g(z)\\) on a discrete set.\n\\end{corollary}\n\n\\begin{definition}\n  If \\(f\\) is analytic on the punctured disk \\(D(a, r)^* := D(a, r) \\setminus \\{a\\}\\) for some \\(r > 0\\), then \\(f\\) has an isolated singularity at \\(a\\).\n\\end{definition}\n\nIn this case, we obtain the analogue of power series, \\emph{Laurent series} at \\(a\\)\n\\[\n  f(z) = \\sum_{n = -\\infty}^{\\infty} c_n (z - a)^n.\n\\]\n\nThere are three possibilities:\n\\begin{enumerate}\n\\item removable singularity: \\(c_n = 0\\) for all \\(n < 0\\).\n\\item pole: there exists \\(N < 0\\) such that \\(c_N \\neq 0\\) and \\(c_n = 0\\) for all \\(n < N\\). We say \\(f\\) has a pole of order \\(-N\\) and can write \\(f(z) = (z - a)^N g(z)\\) where \\(g\\) is analytic and nonzero at \\(a\\).\n\\item essential singularity: \\(c_n \\neq 0\\) for infinitely many \\(n < 0\\).\n\\end{enumerate}\n\nHowever, characterisation in terms of Laurent series is coordinate-dependent. Intrinsically, recall that\n\n\\begin{theorem}\n  \\(f\\) has a removable singularity at \\(a\\) if and only if \\(f\\) is bounded on \\(D(a, r)^*\\).\n\\end{theorem}\n\n\\begin{theorem}[Casorati-Weierstrass]\n  \\(f\\) has an essential singularity at \\(a\\) if and only if for every punctured disk \\(D(a, r)^*\\) in the domain of \\(f\\), the image \\(f(D(a, r)^*)\\) is dense in \\(\\C\\).\n\\end{theorem}\n\nFor completeness sake, we state that \\(f\\) has a pole at \\(a\\) if and only if neither of the above happens (so \\(\\lim_{z \\to a} |f(z)| = \\infty\\)).\n\nThis allows us, for example, to extend the definitions to infinity. Consider the Riemann sphere \\(\\C_\\infty\\), on which a neighbourhood of infinity is the complement of a closed set not including \\(\\infty\\). Mapping it to the complex plane, we define a puncutre disk around \\(\\infty\\) to be the complement of a closed disk in \\(\\C\\). Then we can talk conveniently about singularity at \\(\\infty\\).\n\n\\begin{eg}\n  \\(f(z) = \\frac{1}{e^z - 1}\\) is meromorphic on \\(\\C\\) with poles at \\(z = 2\\pi n i\\) where \\(n \\in \\Z\\). By considering \\(g(z) = \\frac{z}{e^z - 1}\\) which has removable singularity at \\(0\\), we know \\(f\\) has ple of order \\(1\\) at \\(0\\), and therefore at all poles by periodicity.\n\n  At \\(\\infty\\), we have an essential singularity : along the imaginary axis, \\(|f(z)|\\) can be arbitrarily big so it cannot be a removable singularity. Along the positive real axis, \\(|f(z)| \\to 0\\) so it cannot be a pole.\n\\end{eg}\n\n\\begin{definition}[meromorphic function]\\index{meromorphic function}\n  \\(f\\) is \\emph{meromorphic} on a domain \\(U \\subseteq \\C_\\infty\\)  if it has only isolated singularies, none of which are essential.\n\\end{definition}\n\n\\subsection{Complex logarithm}\n\nGiven nonzero \\(z = r e^{i \\theta}\\), if \\(e^w = z\\), we know that \\(w = \\log r + (2\\pi n + \\theta) i\\) for some \\(n \\in \\Z\\). We can make a continuous choice of \\(\\log z\\) on, for example, \\(U = \\C \\setminus \\R_{\\geq 0}\\), by choosing \\(0 < \\theta < 2\\pi\\) and fixing some \\(n \\in \\Z\\). This makes \\(f_n(z) := \\log r + (2\\pi n + \\theta)i\\) a well-defined continuous analytic function on \\(U\\).\n\n\\begin{note}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(g: U \\to V\\) is an analytic bijection, then any inverse \\(h: V \\to U\\) is analytic.\n  \\item If \\(g: U \\to V\\) is analytic, then any \\emph{continuous} inverse \\(h: V \\to U\\) is analytic.\n  \\end{enumerate}\n\\end{note}\n\nMore naturally,\n\n\\begin{proposition}\n  Fix \\(n \\in \\Z\\) and define \\(h(z) := \\int_{-1}^z \\frac{dw}{w} + (2n + 1)\\pi i\\) for \\(z \\in U\\), where the integral is taken over the straight line from \\(-1\\) to \\(z\\), then \\(h\\) is analytic on \\(U\\) and inverse to \\(z \\mapsto e^z\\).\n\\end{proposition}\n\n\\begin{proof}\n  First show \\(h\\) is analytic with \\(f'(z) = \\frac{1}{z}\\).\n  \\[\n    \\frac{h(z + \\tau) - h(z)}{\\tau}\n    = \\frac{1}{\\tau} \\int_z^{z + \\tau} \\frac{dw}{w}\n  \\]\n  for \\(\\tau\\) sufficiently small (such that the triangle formed by \\(-1\\), \\(z\\) and \\(z + \\tau\\) lies in \\(U\\)) by Cauchy's Theorem. Then\n  \\[\n    \\left| \\frac{1}{\\tau} \\int_z^{z + \\tau} \\frac{dw}{w} - \\frac{1}{z} \\right|\n    = \\left| \\frac{1}{\\tau} \\int_z^{z + \\tau} \\frac{z - w}{zw} dw \\right|\n    \\to 0\n  \\]\n  as \\(\\tau \\to 0\\).\n\n  Now define \\(g(z) = \\frac{e^{h(z)}}{z}\\) so \\(g'(z) = \\frac{z e^{h(z)} h'(z) - e^{h(z)}}{z}\\) and so \\(g'(z) = 0\\) identically. \\(g(-1) = 1\\) so \\(e^{h(z)} = z\\) for all \\(z \\in U\\).\n\n\\end{proof}\n\n\\begin{definition}[direct analytic continuation]\\index{analytic continuation!direct}\n  A \\emph{function element} in a domain \\(U\\) is a pair \\((f, D)\\) where \\(D\\) is a subdomain of \\(U\\) and \\(f\\) is an analytic function on \\(D\\). Two function elements \\((f, D)\\) and \\((g, E)\\) are equivalent, write \\((f, D) \\sim (g, E)\\) if \\(D \\cap E \\neq \\emptyset\\) and \\(f = g\\) on \\(D \\cap E\\).\n\n  We say \\((g, E)\\) is a \\emph{direct analytic continuation} of \\((f, D)\\).\n\\end{definition}\n\nWhy do we make such a definition? We know the power series\n\\[\n  \\sum_{r \\geq 0} z^k = \\frac{1}{1 - z}\n\\]\nis defined on \\(D(0, 1)\\) and cannot be extended to any larger domain due to natural boundary. However, \\(\\frac{1}{1 - z}\\) is homomorphic  on \\(\\C \\setminus \\{1\\}\\) so sometimes the domain forced by definition of a function is not the maximal possible. In other words, sometimes we are looking at the ``correct'' function with a ``wrong'' domain.\n\n\\begin{definition}[analytic continuation along path]\\index{analytic continuation!along path}\n  We say \\((g, E)\\) is an \\emph{analytic continuation of \\((f, D)\\) along \\(\\gamma\\)} if \\(\\gamma: [0, 1] \\to U\\) and there exist function elements \\((f_i, D_i)\\), \\(i \\in \\{0, \\dots, n\\}\\) and \\(0 = t_0 < t_2 < \\dots < t_n = 1\\) such that\n  \\[\n    (f, D) = (f_0, D_0) \\sim (f_1, D_1) \\sim \\dots \\sim (f_{n - 1}, D_{n - 1}) \\sim (f_n, D_n) = (g, E)\n  \\]\n  and \\(\\gamma([t_j, t_{j + 1}]) \\subseteq D_j\\) for \\(j \\in \\{0, \\dots, n - 1\\}\\).\n\n  Write \\((f, D) \\approx_\\gamma (g, E)\\).\n\\end{definition}\n\n\\begin{remark}\n  As \\(\\C\\) has a path-connected basis for the topology, domains are path-connected.\n\\end{remark}\n\n\\begin{definition}[analytic continuation]\\index{analytic continuation}\n  We say \\((g, E)\\) is an \\emph{analytic continuation} of \\((f, D)\\) if there exists a path \\(\\gamma\\) such that \\((f, D) \\approx_\\gamma (g, E)\\). In this case we write \\((f, D) \\approx (g, E)\\).\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\((f, D) \\approx_\\gamma (g, E)\\) and \\((f, D) \\approx_\\gamma (h, E)\\) then \\(g = h\\) by repeated application of the identity principle. In other words, \\(g\\) is completely determined by \\(f\\) and \\(\\gamma\\).\n  \\item Analytic continuation is an equivalence relation (exercise), but direct analytic continuation is \\emph{not} transitive, even if the pairwise intersections of the domains are nonempty. If fact, that is the whole point of analytic continuation along path.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{definition}[complete analytic function]\\index{complete analytic function}\n  An equivalence class of function elements under \\(\\approx\\) is a \\emph{complete analytic function}.\n\\end{definition}\n\n\\begin{eg}[complex logarithm]\n  Let \\(U = \\C\\) be the ambient space. Given \\(\\alpha < \\beta\\) in \\(\\R\\), define\n  \\[\n    E_{(\\alpha, \\beta)} := \\{z = r^{i \\theta}: r > 0, \\alpha < \\theta < \\beta\\}.\n  \\]\n  Note \\(\\C \\setminus \\R_{\\geq 0} = E_{(0, 2\\pi)}\\). If \\(\\beta - \\alpha \\leq 2\\pi\\), define\n  \\[\n    f_{(\\alpha, \\beta)}(z) = \\log r + i\\theta\n  \\]\n  where \\(z = re^{i\\theta}, \\alpha < \\theta < \\beta\\). Then \\((f_{(\\alpha, \\beta)}, E_{(\\alpha, \\beta)})\\) is a function element for any such \\(\\alpha, \\beta\\).\n\n  Let\n  \\begin{align*}\n    A &= (-\\frac{\\pi}{2}, \\frac{\\pi}{2}) \\\\\n    B &= (\\frac{\\pi}{6}, \\frac{7\\pi}{6}) \\\\\n    C &= (\\frac{5\\pi}{6}, \\frac{11\\pi}{6})\n  \\end{align*}\n  and \\(\\gamma: [0, 1] \\to U, t \\mapsto e^{2\\pi i t}\\) and choose\n  \\[\n    0 = t_0 < t_1 = \\frac{1}{6} < t_2 = \\frac{1}{2} < t_3 = \\frac{5}{6} < t_4 = 1\n  \\]\n  and \\((f_A, E_A), (f_B, E_B), (f_C, E_C)\\) the corresponding function elements.\n\n  When the \\emph{intervals} overlap, the function elements agree so\n  \\[\n    (f_A, E_A) \\sim (f_B, E_B) \\sim (f_C, E_C),\n  \\]\n  but\n  \\[\n    f_C(z) = f_A(z) + 2\\pi i, z \\in E_A \\cap E_C\n  \\]\n  which shows nontransitivity of \\(\\sim\\). In fact, \\(f_A + 2\\pi i \\sim f_C\\). However we see \\((f_A, E_A) \\approx_\\gamma (f_C, E_C)\\) and so \\((f_A, E_A) \\approx (f_C, E_C)\\). By repeating the process with intervals moving to infinity to \\(\\R\\), we see that all the \\(\\log r + (2\\pi n + \\theta) i\\) are in the same class for \\(\\approx\\). On the other hand, if \\((f, D) \\approx_\\gamma (f_{A'}, E_{A'})\\) for some interval \\(A'\\) then applying identity principle along the path to \\(e^{f_i}\\) shows that \\(f\\) is one of the branches of \\(\\log\\).\n\n  Now we can define a space that contains all branches of logarithm. On \\(U = \\C \\setminus \\R_{\\geq 0}\\), define\n  \\[\n    f_n(z) = \\log n + (2\\pi n + \\theta)i\n  \\]\n  where \\(0 < \\theta < 2\\pi\\). Then \\((f_n, U)\\) are function elements in the complete analytic function of \\(\\log\\), and ``almost'' all of them. Take \\(\\Z\\) copies of \\(U\\) and we can glue them along \\(\\R_{\\geq 0}\\). More precisely, for any \\(n \\in \\Z\\) and \\(\\alpha > 0\\), there exists a neighbourhood \\(V\\) of \\(\\alpha\\) and a function element \\((g, V)\\) such that\n  \\[\n    (f_{n + 1}, E_{(0, \\varepsilon)}) \\sim (g, V) \\sim (f_n, E_{(2\\pi - \\varepsilon, 2\\pi)})\n  \\]\n  for some \\(\\varepsilon > 0\\).\n\n  This object is the ``gluing construction'' of the Riemann surface associated to \\(\\log\\). Since these \\((g, V)\\) exist, the resulting surface \\(R\\) will admit a \\emph{continuous} function \\(f\\) such that the following diagram commutes:\n  \\[\n    \\begin{tikzcd}\n      R \\ar[r, \"f\"] \\ar[d, \"\\pi\"] & \\C \\ar[dl, \"\\exp\"] \\\\\n      \\C^*\n    \\end{tikzcd}\n  \\]\n\n  The rigorous construction is as follow. Let \\(R = \\coprod _{k \\in \\Z} \\C^*\\) and a basis for the topology on \\(R\\) is\n  \\begin{enumerate}\n  \\item disks contained in a single sheet: \\(D((\\eta, k), r)\\) disk of radius \\(r\\) about \\(\\eta \\in \\C \\setminus \\R_{\\geq 0}\\) at level \\(k\\), where \\(r\\) is sufficently small such that the disk does not intersect \\(\\R_{\\geq 0}\\),\n  \\item disks along \\(\\R_{\\geq 0}\\): for \\(\\eta > 0, k \\in \\Z, r < |\\eta|\\),\n    \\[\n      A((\\eta, k), r) = \\{(z, k): |z - \\eta| < r, \\Im z \\geq 0\\} \\amalg \\{(z, k - 1), |z - \\eta| < r, \\Im z < 0\\}.\n    \\]\n  \\end{enumerate}\n\nCheck that this makes \\(R\\) a Hausdorff, path-connected space. \\(R\\) comes with a natural projection \\(\\pi: R \\to \\C^*, (\\eta, k) \\mapsto \\eta\\). This is a continuous map as the preimage of a small disk \\(D(\\eta, r) \\subseteq \\C^*\\) is countably many copies of that disk, one for each sheet. This is precisely the definition of a covering space.\n\\end{eg}\n\n\\begin{definition}[covering space]\\index{covering space}\n  A \\emph{covering space} of a topological space \\(X\\) is a continuous map \\(p: \\tilde X \\to X\\) where \\(\\tilde X\\) and \\(X\\) are Hausdorff and path-connected and \\(p\\) is a local homeomorphism, i.e.\\ for each \\(\\tilde x \\in \\tilde X\\), there exists a neighbourhood \\(\\tilde N\\) of \\(\\tilde x\\) such that \\(p|_{\\tilde N}\\) is a homeomorphism.\n\n    \\(X\\) is the \\emph{base space} of \\(p\\).\n\n    The cover is \\emph{regular} if for all \\(x \\in X\\), there exists a neighbourhood of \\(x\\) such that \\(p^{-1}(N)\\) is a disjoint union of sets mapped homeomorphically by \\(p\\) to \\(N\\).\n\\end{definition}\n\n\\begin{note}\n  Whether including regularity in the definition of covering space is a matter of taste. It is ususally included in algebraic topology, e.g.\\ in IID Algebraic Topology.\n\\end{note}\n\n\\begin{remark}\n  \\(\\pi: R \\to \\C^*\\) is a regular cover.\n\\end{remark}\n\n\\begin{eg}[a non-regular cover]\n  Consider \\(p: \\tilde X \\to \\C^*, z \\mapsto e^z\\) where\n  \\[\n    \\tilde X = \\{z \\in \\C: 0 < \\Im z < 4\\pi\\}.\n  \\]\n  It is a covering space but consider \\(1 \\in \\C^*\\). Any preimage of a sufficiently small disk centred at \\(1\\) will be the disjoint union of one disk at \\(2\\pi i\\) and two half disks at \\(0\\) and \\(4\\pi i\\) each. Thus \\(p\\) fails to be a regular cover as we choose the ``wrong'' domain.\n\\end{eg}\n\nDefine\n\\begin{align*}\n  f: R &\\to \\C \\\\\n  (\\eta, k) &\\mapsto \\log r + (2\\pi k + \\theta) i\n\\end{align*}\nwhere \\(\\eta = re^{i\\theta}, 0 \\leq \\theta < 2\\pi\\). Then \\(f\\) is a continuous bijection and the following diagram commutes:\n\\[\n  \\begin{tikzcd}\n    R \\ar[r, \"f\"] \\ar[d, \"\\pi\"] & \\C \\ar[dl, \"\\exp\"] \\\\\n    \\C^*\n  \\end{tikzcd}\n\\]\n\nA similar construction can be done for the multivalued function \\(z^{1/n}\\) where \\(n \\in \\N\\). As a multivalued function,\n\\[\n  (e^{i\\theta})^{1/n} = r^{1/n} e^{i\\theta/n} e^{2\\pi ki/n}\n\\]\nfor \\(k \\in \\Z/n\\Z\\). Define \\(R_n = \\coprod_{k \\in \\Z/n\\Z} \\C^*\\) but glue near modulo \\(n\\) (``top sheet to bottom sheet''). Then we have \\(f_n, \\pi_n\\) such that the following diagram commutes:\n\\[\n  \\begin{tikzcd}\n    R_n \\ar[r, \"f_n\"] \\ar[d, \"\\pi_n\"] & \\C^* \\ar[dl, \"z \\mapsto z^n\"] \\\\\n    \\C^*\n  \\end{tikzcd}\n\\]\n\n\\begin{definition}[regular/singular point]\\index{regular point}\n  Let \\(f(z) = \\sum_{k \\geq 0} a_k z^k\\) with radius of convergence \\(1\\). A point \\(z \\in \\p D(0, 1)\\) is \\emph{regular} if there exists a neighbourhood \\(N\\) of \\(z\\) and a holomorphic \\(g\\) on \\(N\\) such that \\(g = f\\) on \\(N \\cap D(0, 1)\\), i.e.\\ \\(g\\) is a regular analytic continuation of \\(f\\).\n\n  If \\(z \\in \\p D(0, 1)\\) is not regular it is \\emph{singular}.\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item The regular points of \\(\\p D(0, 1)\\) form an open set in the subspace topology on \\(\\p D(0, 1)\\).\n  \\item \\(z\\) is regular does \\emph{not} mean that the series converges at \\(z\\). Consider the classical example \\(f(z) = \\sum_{k \\geq 0} z^k\\), which is regular everywhere except \\(z = 1\\) (\\(g(z) = \\frac{1}{1 - z}\\)).\n  \\item The converse does not hold either. A series converges at \\(z\\) does not imply that it is regular there. For example, \\(g(z) = \\sum_{k \\geq 2} \\frac{z^k}{(k - 1)k}\\) converges at all \\(z \\in \\p D(0, 1)\\). If it was regular at such a point then the second derivative \\(g''(z) = \\sum_{k \\geq 0} z^k\\) would also be regular at \\(z\\). But \\(g''(z) \\to \\infty\\) as \\(z \\to 1\\) so \\(f\\) cannot agree on a neighbourhood of \\(1\\) with any holomorphic function.\n  \\end{enumerate}\n\\end{remark}\n\nHowever, regularity does affect radius of convergence:\n\\begin{proposition}\n  Suppose \\(f(z) = \\sum_{k \\geq 0} a_kz^k\\) with radius of convergence \\(1\\). Then there exists a singular point on \\(\\p D(0, 1)\\).\n\\end{proposition}\n\n\\begin{proof}\n  Suppose not so for each \\(z \\in \\p D(0, 1)\\) there exists a neighbourhood \\(N_z\\) of \\(z\\) and \\(g_z\\) on \\(N_z\\) holomorphic with \\(g_z = f\\) on \\(N_z \\cap D(0, 1)\\). These extensions can be glued together by identity principle. As \\(\\p D(0, 1)\\) is compact, there exists a finite collection of \\(z_1, \\dots, z_m \\in \\p D(0, 1)\\) such that \\(N_{z_i}\\)'s cover \\(\\p D(0, 1)\\). wlog let the neighbourhoods be disks. Then we can choose \\(\\delta > 0\\) sufficiently small such that \\(f\\) is holomorphic on \\(D(0, 1 + \\delta)\\). Contradiction.\n\\end{proof}\n\n\\begin{definition}[natural boundary]\\index{natural boundary}\n  The disk boundary \\(\\p D(0, 1)\\) is the \\emph{natural boundary} for \\(f\\) if all points on the boundary are singular.\n\\end{definition}\n\n\\begin{eg}\n  \\(f(z) = \\sum_{k \\geq 0} z^{k!}\\) has natural boundary \\(\\p D(0, 1)\\). Consider \\(\\omega = e^{2\\pi i \\frac{p}{q}}\\) a root of unity. For \\(0 < r < 1\\),\n  \\[\n    f(r \\omega)\n    = \\sum_{k \\geq 0} r^{k!} \\omega^{k!}\n    = \\sum_{k \\leq q - 1} r^{k!} \\omega^{k!} + \\sum_{k \\geq q} r^{k!}\n  \\]\n  so as \\(r \\to 1\\) the last term goes to infinity so this cannot agree with a holomorphic function on a neighbourhood of \\(\\omega\\). Since the closure of roots of unity is \\(\\p D(0, 1)\\), every point is singular.\n\\end{eg}\n\n\\begin{definition}[Riemann surface]\\index{Riemann surface}\n  A \\emph{Riemann surface} \\(R\\) is a connected, Hausdorff topological space, together with a collection of homeomorphisms \\(\\phi_\\alpha: U_\\alpha \\to D_\\alpha \\subseteq \\C\\) with \\(U_\\alpha\\) open, so that\n  \\begin{enumerate}\n  \\item \\(\\bigcup_{\\alpha} U_\\alpha = R\\),\n  \\item if \\(U_\\alpha \\cap U_\\beta \\neq \\emptyset\\) then \\(\\phi_\\beta \\compose \\phi_\\alpha^{-1}\\) is analytic on \\(\\phi_\\alpha(U_\\alpha \\cap U_\\beta)\\).\n  \\end{enumerate}\n\n  For a given \\(\\alpha\\), \\((U_\\alpha, \\phi_\\alpha)\\) is a \\emph{chart}, and these compositions \\(\\phi_\\beta \\compose \\phi_\\alpha^{-1}\\) are \\emph{transition functions}. The collection of charts is known as an \\emph{atlas} on \\(R\\).\n\\end{definition}\n\nIn other words, a Riemann surface is precisely a one-dimensional complex manifold.\n\n\\begin{definition}[analytic function between Riemann surfaces]\\index{analytic}\n  Let \\(R, S\\) be Riemann surfaces with atlases \\(\\{(U_\\alpha, \\phi_\\alpha)\\}\\) and \\(\\{(V_\\beta, \\psi_\\beta)\\}\\) respectively. A continuous map \\(f: R \\to S\\) is \\emph{analytic} or \\emph{holomorphic} if whenever \\(U_\\alpha \\cap f^{-1}(V_\\beta) \\neq \\emptyset\\), then\n  \\[\n    \\psi_\\beta \\compose f \\compose \\phi_\\alpha^{-1}\n  \\]\n  on \\(\\phi_\\alpha(U_\\alpha \\cap f^{-1}(V_\\beta))\\) is analytic.\n\\end{definition}\n\n\\begin{remark}\n  Analyticity is local. An equivalent definition is to say \\(f\\) is analytic at \\(x \\in R\\) if whenever \\(x \\in U_\\alpha \\cap f^{-1}(V_\\beta)\\) then \\(\\psi_\\beta \\compose f \\compose \\phi_\\alpha^{-1}\\) is analytic on a neighbourhood of \\(\\phi_\\alpha(x)\\).\n\\end{remark}\n\n\\begin{eg}\n  \\((\\C, z)\\) is a Riemann surface with one chart where we denote by \\(z\\) the map \\(z \\mapsto z\\), as is \\((\\C, z + 1)\\) and \\((\\C, \\conj z)\\).\n\\end{eg}\n\n\\begin{eg}\n  The Möbius band cannot be made into a Riemann surface because it is non-orientable. Informally, if we put an atlas on the Möbius band, we could choose it so that the centre circle maps to a space homeomorphic to a circle. And as analytic transition implies conformity, consistent choice of ``inside'' of the circle leads to a consistent choice on ``inside'' on the Möbius band, which is a contradiction.\n\\end{eg}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item Each transition function has continuous inverses and so are conformal equivalence on their domains.\n  \\item \\(R\\) is connected with a path-connected basis so \\(R\\) is path-connected.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{definition}[equivalent atlas]\\index{atlas!equivalent}\n  Two atlases \\(\\{(U_\\alpha, \\phi_\\alpha\\}\\) and \\(\\{(V_\\beta, \\psi_\\beta)\\}\\) are \\emph{equivalent} if their union is also an atlas, i.e.\\ whenever \\(U_\\alpha \\cap V_\\beta \\neq \\emptyset\\) then \\(\\psi_\\beta \\compose \\phi_\\alpha^{-1}\\) on \\(\\phi(U_\\alpha \\cap V_\\beta)\\) is analytic.\n\\end{definition}\n\n\\begin{eg}\n  \\((\\C, z)\\) and \\((\\C, z + 1)\\) are equivalent: \\(z \\mapsto z + 1\\) (or \\(z \\mapsto z - 1\\)) are analytic. On the other had \\((\\C, z)\\) and \\((\\C, \\conj z)\\) are not equivalent as \\(z \\mapsto \\conj z\\) is not analytic.\n\\end{eg}\n\nWe will see later that the notion of equivalence defines an equivalence relation on the collection of atlases on a fixed \\(R\\).\n\n\\begin{definition}[conformal structure]\\index{conformal structure}\n  An equivalence class of atlases on \\(R\\) is a \\emph{conformal structure} on \\(R\\).\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(R\\) is a Riemann surface and \\(S \\subseteq R\\) is open and connected then restriction of the chart maps provides a conformal structure on \\(S\\), for which \\(i: S \\embed R\\) is analytic.\n  \\item Two atlases are equivalent if and only if the identity map is analytic.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{proposition}\n  Let \\(f: R \\to S, g: S \\to T\\) be analytic maps of Riemann surfaces. Then \\(g \\compose f\\) is analytic.\n\\end{proposition}\n\n\\begin{proof}\n  Suppose \\(\\{(U_\\alpha, \\phi_\\alpha)\\}, \\{(V_\\beta, \\psi_\\beta)\\}\\) and \\(\\{(W_\\gamma, \\theta_\\gamma)\\}\\) are atlases on \\(R, S\\) and \\(T\\) respectively. Let \\(h = g \\compose f\\) which is continuous. Suffices to show that whenever\n  \\[\n    Y := U_\\alpha f^{-1}(V_\\beta) \\cap h^{-1} (W_\\gamma)\n  \\]\n  is nonempty then\n  \\[\n    \\theta_\\gamma \\compose g \\compose f \\compose \\phi_\\alpha^{-1}\n  \\]\n  is analytic on \\(Y\\). Since \\(\\psi_\\beta \\compose f \\compose \\phi_\\alpha^{-1}\\) is analytic on \\(\\phi_\\alpha(Y)\\) and \\(\\theta_\\gamma \\compose g \\compose \\psi_\\beta^{-1}\\) is analytic on \\(\\psi_\\beta \\compose f (Y)\\), we concluded that\n  \\[\n    \\theta_\\gamma \\compose g \\compose \\psi_\\beta^{-1} \\compose \\psi_\\beta \\compose f \\compose \\phi_\\alpha^{-1}\n  \\]\n  is analytic on \\(\\alpha_\\alpha(Y)\\).\n\\end{proof}\n\n\\begin{corollary}\n  Equivalence of atlas is an equivalence relation.\n\\end{corollary}\n\n\\begin{proposition}\n  Suppose \\(R\\) is a Riemann surface and \\(\\pi: \\tilde R \\to R\\) is a covering map. Then there is a unique conformal structure on \\(\\tilde R\\) which makes \\(\\pi\\) analytic.\n\\end{proposition}\n\n\\begin{proof}\n  Given \\(\\tilde z \\in \\tilde R\\), we can find \\(\\tilde N\\) of \\(\\tilde z\\) on which \\(\\pi: \\tilde N \\to N\\) is a homeomorphism onto its image. Let \\((V, \\varphi)\\) be a chart containing the image \\(\\pi(\\tilde z)\\). Define \\(U_{\\tilde z} = \\pi^{-1}(V) \\cap \\tilde N\\) and \\(\\varphi_{\\tilde z} = \\varphi \\compose \\pi\\). This defines a chart on some neighbourhood of \\(\\tilde z\\) and \\(\\{(U_{\\tilde z}, \\varphi_{\\tilde z})\\}_{\\tilde z \\in \\tilde R}\\) defines an atlas: this is clearly a cover and the transition functions \\(\\varphi_{\\tilde z} \\compose \\varphi_{\\tilde w}^{-1}\\) are the restrictions of transition functions for \\(R\\). \\(\\pi\\) is analytic with respect to this conformal structure as the composite maps are transition maps of \\(R\\). Uniqueness follows from a similar argument.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(R = \\coprod_{k \\in \\Z} \\C^*\\) and \\(\\pi: R \\to \\C^*, (\\eta, k) \\mapsto \\eta\\) be a covering map. Then there exists a unique conformal structure on \\(R\\) for which \\(\\pi\\) is analytic. Note that the following diagram commutes, \\(f\\) is a continuous map and locally \\(f\\) is the composition of inverse of \\(\\exp\\) and projection so \\(f\\) is analytic.\n  \\[\n    \\begin{tikzcd}\n      R \\ar[r, \"f\"] \\ar[d, \"\\pi\"] & \\C \\ar[dl, \"\\exp\"] \\\\\n      \\C^*\n    \\end{tikzcd}\n  \\]\n  As \\(f\\) is a bijection by construction, it has a global analytic inverse.\n\\end{eg}\n\n\\begin{definition}[conformal equivalence]\\index{conformal equivalence}\n  An analytic map \\(f: R \\to S\\) of Riemann surfaces is a \\emph{conformal equivalence} if there exists \\(g: S \\to R\\) analytic inverse to \\(f\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(f\\) as above for the logarithm Riemann surface is a conformal equivalence: the inverse of \\(f\\) is continuous and locally it is given by \\(\\pi^{-1} \\compose \\exp\\) so is analytic. Therefore \\((R, \\pi)\\) and \\((\\C, \\exp)\\) cannot be ``told apart''.\n  \\item \\((\\C, z)\\) and \\((\\C, \\conj z)\\) are conformally equivalent as \\(f(z) = \\conj z\\) is a conformal equivalence.\n  \\item\n    \\[\n      \\begin{tikzcd}\n        R_n \\ar[r, \"f_n\"] \\ar[d, \"\\pi_n\"] & \\C^* \\ar[dl, \"z \\mapsto z^n\"] \\\\\n        \\C^*\n      \\end{tikzcd}\n    \\]\n    Again there exists a unique conformal structure on \\(R_n\\) making \\(\\pi\\) analytic. It follows that \\(f\\) is analytic. Note that one could imagine adding two points to \\(R_n\\) and replacing \\(\\C^*\\) with \\(\\C \\cup \\{\\infty\\} = \\C_\\infty\\). Doing so ruins \\(\\pi\\) as a cover, but sometimes it's worth it (compactness!).\n  \\item \\(\\C_\\infty = \\C \\cup \\{\\infty\\}\\) equipped with the sphere topology via steoreographic projection. Define two charts: \\((\\C, z)\\) and \\((\\C_\\infty \\setminus \\{0\\}, \\frac{1}{z})\\). The transition functions are \\(\\frac{1}{z}\\) which are anlaytic on \\(\\C^*\\). It makes \\(\\C_\\infty\\) a compact Riemann surface. This is sometimes denoted by \\(\\hat \\C\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}[analytic function]\n  If \\(R\\) is a Riemann surface, an analytic map \\(f: R \\to \\C\\) is an \\emph{analytic function}.\n\\end{definition}\n\nTherefore we use ``map'' to denote maps between Riemann surfaces and reserve ``function'' for a \\(\\C\\)-valued map.\n\nRecall from IB Analysis II and IB Complex Analysis\n\n\\begin{theorem}[inverse function theorem]\n  Given analytic \\(g\\) on a domain \\(V \\subseteq \\C\\) and \\(a \\in V\\) such that \\(g'(a) \\neq 0\\), there exists a neighbourhood \\(N\\) of \\(a\\) such that \\(g|_N : N \\to g(N)\\) is a conformal equivalence.\n\\end{theorem}\n\nConsider an analytic function \\(f: R \\to \\C\\). Given \\(p \\in R\\), choose a chart \\((U, \\varphi)\\) with \\(p \\in U\\). wlog \\(f(p) = 0\\). and write \\(a = \\varphi(p)\\). Locally around \\(a\\), \\(f \\compose \\varphi^{-1}\\) is analytic so can be written as \\(g(z)^r\\) where \\(g\\) is a conformal equivalence: we can write any nonconstant analytic function sending \\(a \\mapsto 0\\) as \\((z - a)^r h(z)\\) where \\(h\\) is analytic and nonzero on a neighbourhood of \\(a\\). Then there is a neighbourhood \\(V\\) of \\(a\\) such that \\(h(V)\\) does not intersect any ray from the origin. This allows us to define a logarithm on \\(h(V)\\) and \\(r\\)th root\n\\[\n  \\ell(z) := \\exp( \\frac{1}{r} \\log h(z)).\n\\]\nThen \\(f \\compose \\varphi^{-1}\\) is of the form \\(g(z)^r\\) where \\(g(z) = (z - a)\\ell(z)\\). Then \\(g'(a) = \\ell(a) \\neq 0\\) so conformal.\n\nDefine a chart on the intersection of \\(\\varphi(U)\\) with domain of \\(g\\), together with the chart \\(\\psi = g \\compose \\phi\\). Therfore up to translation, any analytic function on a Riemann surface is locally equivalent to a powering map.\n\n\\begin{definition}[complex torus]\\index{complex torus}\n  Let\n  \\[\n    \\Lambda = \\Z \\tau_1 + \\Z \\tau_2 \\subseteq \\C\n  \\]\n  be a lattice where \\(\\tau_1, \\tau_2\\) are nonzero in \\(\\C\\) with \\(\\frac{\\tau_1}{\\tau_2} \\notin \\R\\), i.e.\\ are linearly independent over \\(\\R\\). The quotient group \\(T = \\C / \\Lambda\\) can be equipped with a complex structure, known as a \\emph{complex torus}.\n\\end{definition}\n\nThe complex structure is constructed as follow. Equip the quotient group \\(T = \\C / \\Lambda\\) with quotient topology. \\(\\pi: \\C \\to T\\) is continuous so \\(T\\) is connected. \\(\\pi\\) is also open: if \\(U\\) is an open set in \\(\\C\\) then\n\\[\n    \\pi^{-1}(\\pi(U)) = \\bigcup_{\\omega \\in \\Lambda} \\omega + U\n  \\]\n  a union of open sets so open. Note that any closed parallelogram\n  \\[\n    P_z = \\{z + r \\tau_1 + s \\tau_2: r, s \\in [0, 1]\\}\n  \\]\n  maps onto \\(T\\) by \\(\\pi\\). So \\(T\\) is the continuous image of a compact set so compact. \\(T\\) is also Hausdorff: note first that \\(\\Lambda\\) is a discrete set: if \\(\\Lambda\\) contained an accummultaion point then \\(0\\) is also a limit point, i.e.\\ for all \\(k \\in \\N\\) there exists \\(m_k, n_k \\in \\Z\\) (and wlog \\(n_k \\neq 0\\)) such that\n  \\[\n    |m_k \\tau_1 + n_k \\tau_2| < \\frac{1}{k}\n  \\]\n  but then\n  \\[\n    \\left| \\frac{m_k}{n_k} - \\frac{\\tau_2}{\\tau_1} \\right|\n    < \\frac{1}{k|n_k|\\tau_1}\n    \\leq \\frac{1}{k|\\tau_1|}\n    \\to 0\n  \\]\n  as \\(k \\to \\infty\\) so \\(\\frac{\\tau_2}{\\tau_1} \\in \\R\\), contradiction. Thus given two points \\(w_1, w_2 \\in T\\) we can choose preimages \\(x_i \\in p^{-1}(w_i)\\) and neighbourhoods \\(N_i\\) or \\(z_i\\) such that\n  \\[\n    \\left( \\bigcup_{\\omega \\in \\Lambda} N_1 + \\omega \\right) \\cap \\left( \\bigcup_{\\omega \\in \\Lambda} N_2 + \\omega \\right) = \\emptyset,\n  \\]\n  i.e.\\ \\(\\pi(N_1)\\) and \\(\\pi(N_2)\\) are open disjoint with \\(w_i \\in \\pi(N_i)\\).\n\n  Now show \\(\\pi\\) is a covering map: by the above \\(\\pi\\) is a covering map, in fact regular: given \\(w \\in T\\), choose \\(z \\in \\C\\) such that \\(\\pi^{-1}(w)\\) lies in the interior of \\(\\Lambda\\)-translates of \\(P_z\\), then choose a neighbourhood \\(N\\) of the unique preimage of \\(w\\) in \\(P_z\\) which is contained in the interior of \\(P_z\\). Then \\(\\pi(N)\\) satisfies\n  \\[\n    \\pi^{-1}(\\pi(N)) = \\bigcup_{\\omega \\in \\Lambda} \\omega + N\n  \\]\n  is a disjoint union of \\(\\pi(N)\\).\n\n  Finally for the complex structure of \\(T\\), given \\(a \\in T\\), choose \\(z \\in \\C\\) such that \\(\\pi(z) = a\\) and a neighbourhood \\(N_a\\) of \\(a\\) on which the regularity is realised. In particular, the component \\(N_z\\) of \\(\\pi^{-1}(N_a)\\) containing \\(z\\) has \\(\\pi|_{N_z}: N_z \\to N_a\\) a homeomorphism. Define a chart to be the image of a disk \\(D_z\\) about \\(z\\) contained in \\(N_z\\). Write \\(U_a = \\pi(D_z)\\) and define a chart map \\(\\phi_a = (\\pi|_{N_z})^{-1}\\) on \\(U_a\\). Claim this defines an atlas on \\(T\\): clearly this is a cover and claim the trasition maps are translations: suppose \\(U_a \\cap U_b = \\emptyset\\), for each \\(w \\in U_a \\cap U_b\\) there exists \\(\\omega_w \\in \\Lambda\\) such that \\(\\phi_b^{-1} \\compose \\phi_a(w) = w + \\omega_w\\). But \\(w \\mapsto \\omega_w\\) is a continuous function on a connected set and it takes values in a discrete set so is constant. Thus the transition functions are translations so analytic.\n\nIn example sheet 1 we'll show that different lattices can yield conformally equivalent tori. In example sheet 2 we give characterisation of conformal equivalence classes of tori in terms of \\(\\Lambda\\). In some sense complex tori are the most important class of Riemann surfaces.\n\n\\begin{theorem}[open mapping theorem]\\index{open mapping theorem}\n  Let \\(f: R \\to S\\) be a nonconstant analytic map of Rieman surfaces. Then \\(f\\) is an open map.\n\\end{theorem}\n\n\\begin{proof}\n  Suppose \\(W \\subseteq R\\) is open. Choose \\(z \\in W\\) and charts \\((U, \\phi)\\) of \\(z\\), \\((V, \\psi)\\) of \\(f(z)\\). Choose a disk \\(D\\) about \\(\\phi(z)\\) sufficiently small such that\n  \\[\n    \\phi^{-1}(D) \\subseteq W \\cap f^{-1}(V) \\cap U.\n  \\]\n  Then\n  \\[\n    (\\psi \\compose f \\compose \\phi^{-1})(D)\n  \\]\n  is open so \\((f \\compose \\psi^{-1})(D) = f(\\phi^{-1}(D))\\) is open. Thus\n  \\[\n    f(z) \\in (f \\compose \\phi^{-1})(D)) \\subseteq f(W)\n  \\]\n  so \\(f(W)\\) is open.\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(f: R \\to S\\) be a nonconstant analytic map. If \\(R\\) is compact then \\(f(R) = S\\) and \\(S\\) is compact.\n\\end{corollary}\n\n\\begin{proof}\n  \\(f(R)\\) is open because \\(f\\) is open. It is also closed as it is compact in \\(S\\), a Hausdorff space. As \\(S\\) is connected, the nonempty clopen set \\(f(R)\\) is precisely \\(S\\). The second claim follows.\n\\end{proof}\n\n\\begin{corollary}\n  Complex tori and \\(\\C_\\infty\\) admit no analytic function which are nonconstant.\n\\end{corollary}\n\nWe have seen a special case of this in IB Complex Analysis: if \\(f: \\C_\\infty \\to \\C\\) is analytic then \\(f(\\infty) \\in \\C\\) so \\(f\\) is bounded on a neighbourhood of \\(\\infty\\). By Liouville's theorem \\(f\\) is constant.\n\n\\begin{definition}\n  Let \\(h: R \\to \\R\\) be a continuous function on a Riemann surface \\(R\\). \\(h\\) is \\emph{harmonic} if for all charts \\((U, \\phi)\\) of \\(R\\), \\(h \\compose \\phi^{-1}\\) is harmonic on \\(\\phi(U)\\).\n\\end{definition}\n\nRecall that a harmonic function on a domain in \\(\\C\\) is the real part of some analytic funciton locally, same is true for harmonic functions on Riemann surfaces. Thus harmonicity is well-defined independent of charts.\n\n\\begin{proposition}\n  Suppose \\(h: R \\to \\R\\) is harmonic on a Riemann surface \\(R\\). Then if \\(h\\) is nonconstant, \\(h\\) is open. In particular if \\(R\\) is compact, \\(R\\) admits no nonconstant harmonic function.\n\\end{proposition}\n\n\\begin{proof}\n  Given such a nonconstant \\(h: R \\to \\R\\) and open set \\(U \\subseteq R\\) and \\(z \\in U \\subseteq R\\), choose \\(z \\in V \\subseteq U\\) open such that \\(h = \\Re g\\) for some analytic function \\(g\\) on \\(V\\).\n  \\[\n    \\begin{tikzcd}\n      V \\ar[d, \"g\"] \\ar[dr, \"h\"] \\\\\n      g(V) \\ar[r, \"\\Re\"] & \\R\n    \\end{tikzcd}\n  \\]\n  By open mapping theorem if \\(g\\) is nonconstant then it is open. Since \\(\\Re\\) is open, their composition \\(h\\) is as well. For a proof that \\(g\\) is nonconstant, see example sheet 1 Q13.\n\n  The second claim follows.\n\\end{proof}\n\nHere we digress a little bit on non-examibable content before heading to the next chapter. A fundamental result about harmonic functions on Riemann surfaces is that they ``almost'' exist. We cannot find nonconstant harmonic function from a compact Riemann surface. But as the next best alternative we have\n\n\\begin{theorem}\n  Let \\(R\\) be a Riemann surface, \\(P \\neq Q \\in R\\). Then there exists a harmonic function \\(h: R \\setminus \\{P, Q\\} \\to \\R\\) such that for any chart \\(\\phi: U \\to \\C\\) about \\(P\\) with \\(\\phi(P) = 0\\), \\(h \\compose \\phi^{-1}\\) is \\(\\log |z|\\) plus a bounded function near \\(0\\), and for any chart \\(\\psi: V \\to \\C\\) about \\(Q\\) with \\(\\psi(Q) = 0\\), \\(h \\compose \\psi^{-1}\\) is \\(-\\log |z|\\) plus a bounded function near \\(0\\).\n\\end{theorem}\n\n% Terry Tao's notes on Riemann-Roch\n\n\\begin{theorem}[Riemann existence theorem, classical version]\\index{Riemann existence theorem}\n  Let \\(R\\) be a compact Riemann surface and \\(P \\neq Q\\) in \\(R\\). Then there exists a meromorphic function \\(f\\) on \\(R\\) with \\(f(P) \\neq f(Q)\\).\n\\end{theorem}\n\n% separating points in algebraic geometry\n% for reference, see Doanldson's notes (wait till we do monodromy)\n\n\\section{Meromorphic functions}\n\n\\begin{definition}[meromorphic]\\index{meromorphic}\n  A \\emph{meromorphic} function on a Riemann surface \\(R\\) is an analytic map to \\(\\C_\\infty\\).\n\\end{definition}\n\n\\begin{proposition}\n  Let \\(U \\subseteq \\C\\) is a domain. A function \\(f: U \\to \\C_\\infty\\) is meromorphic if and only if it is meromorphic as a map from a Riemann surface.\n\\end{proposition}\n\n\\begin{proof}\n  Assume \\(f: U \\to \\C_\\infty\\) is analytic. Given \\(a \\in U\\), if \\(f(a) \\in \\C\\) then \\(f\\) is an analytic function near \\(a\\) so meromorphic. If \\(f(a) = \\infty\\) then by considering the chart \\((\\C \\setminus \\{0\\}, \\frac{1}{z})\\) of \\(\\C_\\infty\\) near \\(\\infty\\), we see that \\(g(z) = \\frac{1}{f(z)}\\) is analytic on a neighbourhood of \\(a\\) with \\(g(a) = 0\\). Thus \\(g(z) = (z - a)^r h(z)\\) where \\(h\\) is analytic nonzero on a neighbourhood of \\(a\\) so \\(f(z) = (z - a)^{-r} \\frac{1}{h(z)}\\), which is meromorphic as a complex function.\n\n  All the implications above are equivalences so the reverse also holds.\n\\end{proof}\n\n\\begin{eg}\n  In example sheet 1 Q15 we show that \\(\\{(z, w): w^2 = z^3 - z\\} \\subseteq \\C^2\\) admits a conformal structure via the coordinate projection maps. We may alternatively do this geometrically by gluing. Define \\(f(z) = z^3 - z\\) and define \\(U = \\C \\setminus ([-1, 0] \\cup [1, \\infty))\\). Claim that we can define a square root of \\(f\\) on \\(U\\) (in other words, direct analytic continuation is transitive): this can be done locally at any point of \\(U\\). To show it's well-defined, consider a closed path \\(\\gamma \\subseteq U\\). By a result about winding number in example sheet 1 Q1,\n  \\[\n    I(f \\compose \\gamma, 0) = I(\\gamma, -1) + I(\\gamma, 0) + I(\\gamma, 1).\n  \\]\n  We can check that \\(I(\\gamma, 1) = 0\\) and \\(I(\\gamma, -1) = I(\\gamma, 0)\\) so \\(I(f \\compose \\gamma, 0) \\in 2 \\Z\\). Therefore if we define locally some \\(\\exp(\\frac{1}{2} \\log f(z))\\), as we travel along \\(\\gamma\\), the change in \\(\\log\\) is\n  \\[\n    \\int_\\gamma \\frac{f'(z)}{f(z) - 0} dz = 2\\pi i I(f \\compose \\gamma, 0) = 2n\\pi i\n  \\]\n  for some \\(n \\in 2\\Z\\) by argument principle. Thus \\(\\frac{1}{2} \\log f(z)\\) change by \\(n\\pi i\\).\n\n  If we let \\(U_+, U_-\\) be two copies of \\(U\\) and denote by \\(g_+: U_+ \\to \\C\\) the map we just constructed and let \\(g_- = -g_+\\), glue according to the identifying segments (see image) to obtain a single surface \\(R\\) and an analytic function \\(g\\) on \\(R\\) which agrees with \\(g_+\\) on \\(U_+\\) and \\(g_-\\) on \\(U_-\\). Topologically, this is a torus minus four points.\n\n  It might be instructive to compare algebraic and gemeotric/topological construction and advantage of each. Later we'll learn to extract topological information \\emph{directly} from the algebraic definition.\n\\end{eg}\n\n\\subsection{Space of germs and monodromy}\n\n\\begin{definition}[lift]\\index{lift}\n  Suppose \\(\\pi: \\tilde X \\to X\\) is a (topological) covering map, and \\(\\gamma: [0, 1] \\to X\\) is a path. Then a \\emph{lift} of \\(\\gamma\\) is a path \\(\\tilde \\gamma: [0, 1] \\to \\tilde X\\) such that \\(\\pi \\compose \\tilde \\gamma = \\gamma\\).\n\\end{definition}\n\n\\begin{proposition}\n  If \\(\\tilde gamma_1, \\tilde \\gamma_2\\) are lifts of \\(\\gamma\\) with \\(\\gamma_1(0) = \\gamma_2(0)\\) then \\(\\gamma_1 = \\gamma_2\\).\n\\end{proposition}\n\n\\begin{proof}\n  Define\n  \\begin{align*}\n    I_1 &= \\{t \\in [0, 1]: \\tilde \\gamma_1(t) = \\tilde \\gamma_2(t)\\} \\\\\n    I_2 &= \\{t \\in [0, 1]: \\tilde \\gamma_1(t) \\neq \\tilde \\gamma_2(t)\\}\n  \\end{align*}\n  Claim that both are open in \\([0, 1]\\). First suppose \\(\\tau \\in I_2\\). As \\(\\tilde X\\) is Hausdorff, there exist open disjoint \\(U_1, U_2\\) with \\(\\tilde \\gamma_1(\\tau) \\in U_1, \\tilde \\gamma_2(\\tau) \\in U_2\\). Paths are continuous so \\(\\tilde \\gamma_1^{-1}(U_1)\\) and \\(\\tilde \\gamma_2^{-1}(U_2)\\) are open neighbourhoods of \\(\\tau\\) in \\([0, 1]\\), their intersection is thus open and contained in \\(I_2\\), so \\(I_2\\) is open.\n\n  Suppose now that \\(\\tau \\in I_1\\). Choose an open neighbourhood \\(\\tilde N\\) of \\(\\tilde \\gamma_1(\\tau) = \\tilde \\gamma_2(\\tau)\\) in \\(\\tilde X\\) such that \\(\\pi|_{\\tilde N}\\) is a homeomorphism onto its image. We have \\(\\pi(\\tilde \\gamma_1(t)) = \\pi(\\tilde \\gamma_2(t))\\) for all \\(t\\) as they are both lifts for \\(\\gamma\\), so on \\(\\tilde N\\) this implies that \\(\\tilde \\gamma_1(t) = \\tilde \\gamma_2(t)\\). By continuity of paths, there exists \\(\\delta > 0\\) such that \\(t \\in (\\tau - \\delta, \\tau + \\delta) \\subseteq [0, 1]\\) implies \\(\\tilde \\gamma_1(t), \\tilde \\gamma_2(t) \\in \\tilde N\\). So the interval \\((\\tau - \\delta, \\tau + \\delta) \\subseteq [0, 1] \\subseteq I_1\\) so \\(I_1\\) is open. THus \\(I_1 = [0, 1]\\) by connectivity.\n\\end{proof}\n\nIn summary, lifts are unique up to choice of basepoints.\n\nAs for existence, lifts may not exist if the cover is not regular. c.f.\\ nonregular cover exmaple. However, it is the \\emph{only} obstruction to the construction of a lift.\n\n\\begin{proposition}\n  Suppose \\(\\pi: \\tilde X \\to X\\) is a regular covering map. Given \\(\\gamma\\) in \\(X\\) and \\(z \\in \\tilde X\\) such that \\(\\pi(z) = \\gamma(0)\\), there is a (unique) lift \\(\\tilde \\gamma\\) of \\(\\gamma\\) with \\(\\tilde \\gamma(0) = z\\).\n\\end{proposition}\n\n\\begin{proof}\n  Define\n  \\[\n    I = \\{t \\in [0, 1]: \\text{ exists lift } \\tilde \\gamma: [0, 1] \\to \\tilde X \\text{ of \\(\\gamma\\) with } \\tilde \\gamma(0) = z\\}\n  \\]\n  and let \\(\\tau = \\sup I\\). Suppose for contradiction \\(\\tau \\neq 1\\). Choose an open neighbourhood \\(U\\) of \\(\\gamma(\\tau)\\) such that \\(\\pi^{-1}(U) = \\coprod_j \\tilde U_j\\) and \\(\\pi|_{\\tilde U_j}\\) is a homeomorphism onto \\(U\\). By continuity of \\(\\gamma\\), there exists \\(\\delta > 0\\) such that \\(\\gamma([\\tau - \\delta, \\tau + \\delta]) \\subseteq U\\). Since \\(\\tau\\) is the supremum, exists \\(\\tau_1 \\in [\\tau - \\delta, \\tau]\\) such that \\(\\gamma\\) lifts to \\(\\tilde \\gamma\\) on \\([0, \\tau_1]\\) with \\(\\tilde \\gamma(0) = z\\). Choose \\(j\\) such that \\(\\tilde \\gamma(\\tau_1) \\in \\tilde U\\). Define an extension of \\(\\tilde \\gamma\\) on \\([\\tau, \\tau + \\delta]\\) by \\((\\pi|_{\\tilde U_j})^{-1} \\compose \\gamma\\). This gives a lift of \\(\\gamma\\) to \\([0, \\tau + \\delta]\\), contradicting \\(\\tau = \\sup I\\). Thus \\(\\tau = 1\\).\n\\end{proof}\n\n\\begin{definition}[homotopy]\\index{homotopy}\n  We say paths \\(\\alpha, \\beta\\) in \\(X\\) are \\emph{homotopic} in \\(X\\) if there exists a family \\(\\gamma_s\\) of paths where \\(s \\in [0, 1]\\) such that\n  \\begin{enumerate}\n  \\item \\(\\gamma_0 = \\alpha, \\gamma_1 = \\beta\\),\n  \\item \\(\\gamma_s(0) = \\alpha(0) = \\beta(0)\\) and \\(\\gamma_s(1) = \\alpha(1) = \\beta(1)\\) for all \\(s \\in [0, 1]\\),\n  \\item \\([0, 1] \\times [0, 1] \\to X, (s, t) \\mapsto \\gamma_s(t)\\) is continuous.\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{definition}[simply connected]\\index{simply connected}\n  We say \\(X\\) is \\emph{simply connected} if any path in \\(X\\) is homotopic to a constant path.\n\\end{definition}\n\n\\begin{theorem}[monodromy theorem]\\index{monodromy theorem}\n  Let \\(\\pi: \\tilde X \\to X\\) be a covering map and \\(\\alpha, \\beta\\) be paths in \\(X\\). Assume that\n  \\begin{enumerate}\n  \\item \\(\\alpha\\) and \\(\\beta\\) are homotopic in \\(X\\),\n  \\item \\(\\alpha\\) and \\(\\beta\\) have lifts \\(\\tilde \\alpha\\) and \\(\\tilde \\beta\\) respectively with \\(\\tilde \\alpha(0) = \\tilde \\beta(0)\\),\n  \\item every path in \\(X\\) with \\(\\gamma(0) = \\alpha(0) = \\beta(0)\\) has a lift \\(\\tilde \\gamma\\) with \\(\\tilde \\gamma(0) = \\tilde \\alpha(0) = \\tilde \\beta(0)\\).\n  \\end{enumerate}\n  Then the lifts \\(\\tilde \\alpha\\) and \\(\\tilde \\beta\\) are homotopic. In particular, \\(\\tilde \\alpha(1) = \\tilde \\beta(1)\\).\n\\end{theorem}\n\n\\begin{proof}\n  Non-examinable and omitted. See, for example, IID Algebraic Topology.\n\\end{proof}\n\n\\begin{eg}\n  Consider \\(z \\mapsto z^n\\) on \\(\\C^* = \\C \\setminus \\{0\\}\\). This is a regular covering map. Consider a loop \\(\\gamma\\) based at \\(1\\). The preimages of \\(1\\) are the \\(n\\)th roots of unity \\(\\xi_n^k\\), \\(1 \\leq k \\leq n\\). Any lift of \\(\\gamma\\) will start at some \\(\\xi_n^k\\) and end at \\(\\xi_n^{k + 1}\\). As this is a regular cover, monodromy theorem tells that any path based at \\(1\\) has a lift whose endpoints are the same as if we lifted \\(\\gamma^{0n}\\) for some \\(n \\in \\Z\\). Note to any path \\(\\alpha\\) we have an associated permutation of the set \\(\\{\\xi_n^k\\}_{1 \\leq k \\leq n}\\) by considering where the lift starting at \\(\\xi_n^k\\) ends, i.e.\\ an element of \\(S_n\\). The subset of \\(S_n\\) arising in this way is generated by \\((123\\dots n)\\), which is the cyclic subgroup \\(C_n\\).\n\n  (It is an exercise to show that any closed path in the punctured plane is homotopic to an integer multiple of \\(\\gamma\\).)\n\\end{eg}\n\n\\subsection{Space of germs}\n\nSuppose \\(G \\subseteq \\C\\) is a domain throughout this section.\n\n\\begin{definition}[germ]\\index{germ}\n  Given \\(z \\in G\\) and \\((f, D)\\) and \\((g, E)\\) function elements. We say \\((f, D) \\equiv_z (g, E)\\) if \\(z \\in D \\cap E\\) and \\(f = g\\) on a neighbourhood of \\(z\\). The equivalence class under \\(\\equiv_z\\) of \\((f, D)\\) is called the \\emph{germ} of \\(f\\) at \\(z\\), denoted by \\([f]_z\\).\n\\end{definition}\n\nCompare this with direct analytic continuation, which is \\emph{not} an equivalence relation.\n\nNote that two germs \\([f]_z, [g]_w\\) are equal if and only if \\(z = w\\) and \\(f = g\\) on a neighbourhood of \\(z = w\\).\n\n\\begin{definition}\n  The \\emph{space of germs on \\(G\\)} is the set\n  \\[\n    \\mathcal G = \\{[f]_z: z \\in G \\text{ and } (f, D) \\text{ is a function element with } z \\in D\\}.\n  \\]\n\\end{definition}\n\n\\begin{notation}\n  Given a function element \\((f, D)\\), write\n  \\[\n    [f]_D = \\{[f]_z: z \\in D\\} \\subseteq \\mathcal G\n  \\].\n\\end{notation}\n\nThe goal is to show that \\(\\mathcal G\\) is the union of Riemann surfaces. First we define the topology on \\(\\mathcal G\\) to be the one generated by the basis of elements of the form \\([f]_D\\). Given \\([f]_D\\) and \\([g]_E\\), if \\([h]_z \\in [f]_D \\cap [g]_E\\) then \\(z \\in D \\cap E\\) and \\(h = f = g\\) on a neighbourhood of \\(z\\). Thus there exists domain \\(D'\\) with \\(z \\in D'\\) and \\([h]_{D'} \\subseteq [f]_D \\cap [g]_E\\).\n\nThe topology is Hausdorff: suppose \\([f]_z \\neq [g]_w\\) in \\(\\mathcal G\\), represented by \\((f, D)\\) and \\((g, E)\\) repsectively. If \\(z \\neq w\\) choose \\(D \\cap E = \\emptyset\\) so \\([f]_z \\in [f]_D\\) and \\([g]_w \\in [g]_E\\) and these open sets are disjoint. If \\(z = w\\) choose \\(D = E\\). Claim that \\([f]_D \\cap [g]_E = \\emptyset\\): for suppose \\([h]_s \\in [f]_D \\cap [g]_E\\) then by definition exists neighbourhood \\(N\\) of \\(s\\) such that \\(h = f = g\\) on \\(N\\) so that \\(f = g\\) on \\(D = E\\). In particular \\([f]_z = [g]_z = [g]_w\\), contradiction.\n\nThe connected components of \\(\\mathcal G\\) cover \\(G\\) via the forgetful map \\(\\pi([f]_z) = z\\). To show this is a cover, let \\(V \\subseteq G\\) be an open set, then\n\\[\n  \\pi^{-1}(V) = \\{[f]_z: z \\in V\\} = \\bigcup_{D \\subseteq V} \\{[f]_D: (f, D) \\text{ is a function element}\\}\n\\]\nwhich is open. Locally on \\([f]_D\\), \\(\\pi\\) is a bijection. On such a set \\([f]_D\\), \\(U \\subseteq [f]_D\\) is open if and only if \\(U = \\bigcup_\\alpha [f]_{D_\\alpha}\\), if and only if \\(\\pi(U) = \\bigcup_\\alpha D_\\alpha\\), if and only if \\(\\pi(U)\\) is open.\n\nFor conformal structure on \\(\\mathcal G\\), we know by a previous proposition that on each connected component of \\(\\mathcal G\\), there exists a unique conformal structure making \\(\\pi\\) analytic. These charts can be taken to be \\((U, \\varphi)\\) with \\(U = [f]_D\\) and \\(\\varphi = \\pi_U\\).\n\n\\(\\mathcal G\\) is more than a conformal structure. It comes with an evaluation map\n\\begin{align*}\n  E: \\mathcal G &\\to \\C \\\\\n  [f]_z &\\mapsto f(z)\n\\end{align*}\nwhich is analytic: given a chart \\(([f]_D, \\pi|_{[f]_D})\\) of \\(\\mathcal G\\),\n\\[\n  E \\compose (\\pi|_{[f]_D})^{-1}(z) = E([f]_z) = f(z)\n\\]\nwhich is analytic in \\(z\\). So \\(E\\) is analytic.\n\nThe stalk space \\(\\mathcal G\\) incorporates all information about analytic functions on \\(G\\). The following a method to translate topological information of \\(\\mathcal G\\) to analytic information of complete analytic functions:\n\n\\begin{theorem}\n  Let \\((f, D)\\) and \\((g, E)\\) be function elements on \\(G\\) and \\(\\gamma: [0, 1] \\to G\\) a path with \\(\\gamma(0) \\in D, \\gamma(1) \\in E\\). Then \\((g, E)\\) is analytic continuation of \\((f, D)\\) along \\(\\gamma\\) if and only if there exists a lift \\(\\tilde \\gamma: [0, 1] \\to \\mathcal G\\) of \\(\\gamma\\) such that \\(\\tilde \\gamma(0) = [f]_{\\gamma(0)}, \\tilde \\gamma(1) = [g]_{\\gamma(1)}\\).\n\\end{theorem}\n\n\\begin{proof}\n  Suppose there exists \\((f_j, D_j)_{j = 1}^n\\) and \\(0 = t_0 < t_1 < \\dots < t_n = 1\\) with\n  \\[\n    (f, D) = (f_1, D_1) \\sim (f_2, D_2) \\sim \\dots \\sim (f_n, D_n) = (g, E)\n  \\]\n  and \\(f_{j - 1} = f_j\\) on \\(D_{j - 1} \\cap D_j\\) and \\(\\gamma([t_{j - 1}, t_j]) \\subseteq D_j\\) for all \\(j\\). We can define a lift\n  \\[\n    \\tilde \\gamma(t) = [f_j]_{\\gamma(t)}, t \\in [t_{j - 1}, t_j]\n  \\]\n  which is well-defined. Claim it is continuous: suppose \\([h]_U \\subseteq \\mathcal G\\) and \\(\\tilde \\gamma(\\tau) \\in [h]_U\\). Then\n  \\[\n    \\tilde \\gamma(\\tau) = [f_j]_{\\gamma(\\tau)}\n  \\]\n  for some \\(j\\) so \\(f_j = h\\) on an open neighbourhood \\(N\\) of \\(\\gamma(\\tau)\\). As \\(\\gamma\\) is continuous, there exists \\(\\delta > 0\\) such that if \\(|t - \\tau| < \\delta\\) then \\(\\gamma(t) \\in N\\). Then for such \\(t\\),\n  \\[\n    \\tilde \\gamma(t) = [f_j]_{\\gamma(t)} = [h]_{\\gamma(t)} \\in [h]_U\n  \\]\n  so \\(\\tilde \\gamma\\) is continuous. \\(\\tilde \\gamma\\) satisfies the lifting properties.\n\n  Conversely, suppose there is a lift \\(\\tilde \\gamma\\) of \\(\\gamma\\) in \\(\\mathcal G\\) with \\(\\tilde \\gamma(0) = [f]_{\\gamma(0)}\\) and \\(\\tilde \\gamma(1) = [g]_{\\gamma(1)}\\). For each \\(t \\in [0, 1]\\), there exists a function element \\((f_t, D_t)\\) with \\(\\tilde \\gamma(t) = [f_t]_{\\gamma(t)}\\). Note that \\([f_t]_{D_t}\\) contains \\(\\tilde \\gamma(t)\\). We have for each \\(t\\) an open interval \\(I_t\\) with \\(\\tilde \\gamma(I_t) \\subseteq [f_t]_{D_t}\\). By compactness there exists a finite subcover, say intervals \\([a_k, b_k]\\), ordered so that \\(a_{k + 1} < b_k\\) for \\(k = 1, \\dots, n - 1\\). Choose for each \\(k\\) some \\(t_k \\in (a_{k + 1}, b_k)\\) and rename the corresponding open sets in \\(\\mathcal G\\) \\([f_k]_{D_k}\\). wlog assume all \\(D_k\\)'s are disks. Since \\(\\tilde \\gamma(0) = [f]_{\\gamma(0)}\\) and \\(\\tilde \\gamma(1) = [g]_{\\gamma(1)}\\), we can also assume \\(D_1 \\subseteq D, D_n \\subseteq E\\) so \\(f = f_1\\) on \\(D_1\\) and \\(g = f_n\\) on \\(D_n\\). for each \\(1 \\leq k \\leq n - 1\\), we have\n  \\[\n    \\tilde \\gamma(t_k) \\in [f_k]_{D_k} \\subseteq [f_{k + 1}]_{D_{k + 1}},\n  \\]\n  so \\(f_k = f_{k + 1}\\) on \\(D_k \\cap D_{k + 1}\\) by the identity principle, as \\(f_k = f_{k + 1}\\) on a neighbourhood of \\(\\gamma(t_k)\\). So\n  \\[\n    (f, D) \\sim (f_1, D_1) \\sim \\dots \\sim (f_n, D_n) \\sim (g, E).\n  \\]\n  Finally, on \\([t_{k - 1}, t_k]\\), we have\n  \\[\n    \\gamma([t_{k - 1}, t_k]) = \\pi(\\tilde \\gamma([t_{k -1}, t_k])) \\subseteq \\pi([f_k]_{D_k}) = D_k,\n  \\]\n  thus completing the proof.\n\\end{proof}\n\nAccording to the way we present monodromy theorem (as a purely topological theorem) and the correpondence between lift of paths in the stalk space and analytic continuation, we can expect some results uniqueness of analytic continuation.\n\n\\begin{proposition}\n  If \\((g, E)\\) and \\((h, E)\\) are analytic continuations of \\((f, D)\\) along \\(\\gamma \\subseteq G\\) then \\(g = h\\) on \\(E\\).\n\\end{proposition}\n\n\\begin{proof}\n  Basically done by correspondence between lift and analytic continuation and monodromy theorem. Let \\((g, E)\\) and \\((h, E)\\) correspond to lifts \\(\\tilde \\gamma\\) and \\(\\tilde \\gamma'\\) respectively based at \\([f]_{\\gamma(0)}\\). Uniqueness of lifts implies that \\(\\tilde \\gamma(1) = \\tilde \\gamma'(1)\\), i.e.\\ \\([g]_{\\gamma(1)} = [h]_{\\gamma(1)}\\), so \\(g = h\\) on a neighbourhood of \\(\\gamma(1)\\) so on \\(E\\) by identity principle.\n\\end{proof}\n\nWe can also derive the so-called classical monodromy theorem\n\n\\begin{theorem}[classical monodromy theorem]\\index{monodromy theorem!classical}\n  Suppose \\((f, D)\\) can be continued analytically along all paths in \\(G\\) starting in \\(D\\). Then if \\((g, E)\\) and \\((h, E)\\) are analytic continuations of \\(f\\) along paths \\(\\alpha\\) and \\(\\beta\\) respectively, and \\(\\alpha\\) is homotopic to \\(\\beta\\) then \\(g = h\\) on \\(E\\).\n\\end{theorem}\n\n\\begin{theorem}\n  Find lifts \\(\\tilde \\alpha\\) and \\(\\tilde \\beta\\) corresponding to \\((g, E)\\) and \\((h, E)\\) respectively. Note \\(\\tilde \\alpha(0) = [f]_{\\alpha(0)} = [f]_{\\beta(0)} = \\tilde \\beta(0)\\). By monodromy theorem we have \\(\\tilde \\alpha(1) = \\tilde \\beta(1)\\) so \\(g = h\\) on \\(E\\) again by identity principle.\n\\end{theorem}\n\n\\begin{corollary}\n  Suppose \\(G\\) is a simply connected domain and \\((f, D)\\) is a function element on \\(G\\) which can be analytically continued along all \\(\\gamma \\subseteq G\\) paths with \\(\\gamma(0) \\in D\\). Then \\(f\\) extends to \\(G\\).\n\\end{corollary}\n\n\\begin{proof}\n  Define for \\(z \\in G\\) \\(f(z)\\) as follows: we fix \\(z_0 \\in D\\) and find a path \\(\\gamma\\) on \\(G\\) with \\(\\gamma(0) = z_0\\) and \\(\\gamma(1) = z\\). By assumption \\(f\\) can be analytically continued along the path so by classical monodromy theorem and simply connectedness this is well-defined for all \\(z \\in G\\).\n\\end{proof}\n\n\n\n\n% compactness, tells us exactly what the connected componenets are\n\n\\begin{corollary}\n  Let \\(\\mathcal F\\) be a complete analytic function on \\(G\\) and define\n  \\[\n    \\mathcal G_{\\mathcal F} = \\bigcup_{(f, D) \\in \\mathcal F} [f]_D.\n  \\]\n  Then \\(\\mathcal G_{\\mathcal F}\\) is a connected component of \\(\\mathcal G\\).\n\\end{corollary}\n\n\\begin{proof}\n  Each \\(\\mathcal G\\) is locally path-connected, so path-connected component is the same as connected component. The corollary follows from the theorem.\n\\end{proof}\n\n\\begin{definition}[Riemann surface associated to complete analytic function]\\index{Riemann surface!associated to complete analytic function}\n  \\(\\mathcal G_{\\mathcal F}\\) is the \\emph{Riemman surface associated to the complete analytic function \\(\\mathcal F\\)}.\n\\end{definition}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item For each \\((f, D) \\in \\mathcal F\\), the evaluation map \\(E\\) provides a single valued extension \\(f \\compose \\pi\\) on \\([f]_D\\) to all of \\(\\mathcal G_{\\mathcal F}\\).\n    \\[\n      \\begin{tikzcd}\n        \\mathcal G_{\\mathcal F} \\ar[r, \"E\"] \\ar[d, \"\\pi\"] & \\C \\\\\n        D \\ar[ur, \"f\"']\n      \\end{tikzcd}\n    \\]\n  \\item In example sheet 2 Q7 we will show that in general \\(\\pi: \\mathcal G_{\\mathcal F} \\to G\\) is not a regular cover.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{eg}\n  Let \\(R' = \\{(z, w) \\in \\C^2: w^2 = z^3 - z, w \\neq 0\\}\\) and let \\(\\mathcal G_{\\mathcal F}\\) be the Riemann surface associated to \\(\\sqrt{z^3 - z}\\) over the domain \\(G = \\C \\setminus\\{-1, 0, 1\\}\\). Recall that the Riemann surface structure on \\(R'\\) can be obtained via \\(\\pi_z\\).\n\n  Define\n  \\begin{align*}\n    g: \\mathcal G_{\\mathcal F} &\\to R' \\\\\n    [f]_z &\\mapsto (\\pi([f]_z), E([f]_z))\n  \\end{align*}\n  \\(g\\) is continuous as a product of continuous map. \\(g\\) is also analytic: if \\(([f]_D, \\pi)\\) is a chart of \\(\\mathcal G_{\\mathcal F}\\) then\n  \\[\n    (\\pi_z \\compose g \\compose \\pi^{-1})(s) = (\\pi_z \\compose g)([f]_s) = \\pi_z(\\pi([f]_s), E([f]_s)) = \\pi([f]_s) = s\n  \\]\n  so analytic and open.\n\n  Define an inverse \\(h\\) of \\(g\\): given \\((z, w) \\in R'\\), choose a neighbourhood \\(N\\) on which \\(\\pi_z\\) is a local homeomorphism. Define \\(h((z, w)) = [\\pi_w \\compose \\pi_z^{-1}]_z\\), then this is inverse to \\(g\\) so \\(g\\) is a conformal equivalence.\n\\end{eg}\n\nWe have so far seen three constructions of this Riemann surface:\n\\begin{enumerate}\n\\item embedded curve construction,\n\\item space of germ \\(\\mathcal G_{\\mathcal F}\\) of \\(\\sqrt{z^3 - z}\\),\n\\item gluing construction.\n\\end{enumerate}\nThe above shows 1 and 2 are equivalent and we sill show 2 and 3 are equivalence in example sheet 2. Each construction has its advantange\n\\begin{enumerate}\n\\item inherit properties of \\(\\C^2\\),\n\\item always exists, although quite abstract. Moreover it is a covering space and is equipped with analytic maps \\(\\pi\\) and \\(E\\),\n\\item can get our hands on topology. Compactification\n\\end{enumerate}\n\n\\subsection{Compactifying Riemann surfaces}\n\nRecall the construction of Riemann sphere. We one-point compactify \\(\\C\\) by adding a point \\(\\infty\\). Then we define charts \\((\\C, z)\\) and \\(((\\C\\setminus \\{0\\}) \\cup \\{\\infty\\}, \\frac{1}{z})\\). The result is a map \\(\\C \\embed \\C_\\infty\\) that is not only a (dense) topological embedding into a compact space, but also an analytic map.\n\nIn general, suppose \\(X\\) and \\(Y\\) are topological spacs, \\(U \\subseteq X, V \\subseteq Y\\) open and \\(\\phi: U \\to V\\) a homeomorphism. Let \\(Z = X \\amalg Y / \\sim_\\phi\\) where \\(a \\sim_\\phi b\\) if and only if \\(a = b, a = \\phi(b)\\) or \\(a = \\phi^{-1}(b)\\). \\(Z\\) is known as the \\emph{gluing of \\(X\\) and \\(Y\\) along \\(\\phi\\)}.\n\n\\begin{proposition}\n  Suppose \\(X\\) and \\(Y\\) are Riemann surfaces and \\(U \\subseteq X\\) and \\(V \\subseteq Y\\) are nonempty open sets with \\(\\phi: U \\to V\\) an isomorphism of Riemann surfaces. If \\(Z = X \\amalg Y / \\sim_\\phi\\) is Hausdorff then there exists a unique conformal structure on \\(Z\\) for which \\(i_X: X \\embed Z, i_y: Y \\embed Z\\) are analytic.\n\\end{proposition}\n\n\\begin{proof}\n  Note \\(i_x, i_Y\\) are homeomorphisms. For each chart \\((W, \\psi)\\) of \\(X\\) we define a chart \\((i_X(W), \\psi \\compose i_X^{-1})\\) on \\(Z\\), similarly for charts of \\(Y\\). Transition maps come from those of \\(X\\) or \\(Y\\) or those composed with \\(\\phi\\) so are analytic. \\(Z\\) is connected for if we could disconnect \\(Z\\) we could disconnect \\(X\\) or \\(Y\\). So \\(Z\\) admits a conformal structure, with analytic inclusion. Uniqueness is immediate.\n\\end{proof}\n\n\\begin{eg}\n  \\(R = \\{(z, w) \\in \\C^2: w^2 = z^3 - z\\}\\). We have seen that \\(R\\) minus points where \\(w \\neq 0\\) is a topological torus minus 4 points. Now we compactify it.\n\n  Consider \\(t =  \\frac{1}{z}, u = \\frac{1}{w}\\). Then the defining equation becomes\n  \\[\n    \\frac{1}{u^2} = \\frac{1}{t^3} - \\frac{1}{t},\n  \\]\n  i.e.\n  \\[\n    t^3 = u^2 - u^2t^2 = u^2 (1 - t^2).\n  \\]\n  Unfortunately it is not a Riemann surface via either \\(\\pi_t\\) or \\(\\pi_u\\) at \\((0, 0)\\)! But not all hope is lost. Write\n  \\[\n    t = \\left(\\frac{u}{t} \\right)^2 (1 - t^2)\n  \\]\n  and let \\(v = \\frac{u}{t} = \\frac{z}{w}\\). Then the surface becomes \\(Y = \\{(t, v) \\in \\C^2: t = v^2 (1 - t^2)\\}\\). \\(Y\\) does have one or both projections \\(\\pi_t, \\pi_v\\) a local homeomorphism around each point, including \\((0, 0)\\) so \\(Y\\) admits a conformal structure. Consider the isomorphism\n  \\begin{align*}\n    U &\\to V \\\\\n    (z, w) &\\mapsto (t, v) = (\\frac{1}{z}, \\frac{z}{w})\n  \\end{align*}\n  where \\(U \\subseteq R\\) are points where neither \\(z\\) or \\(w\\) is \\(0\\) and \\(V\\) its isomorphic image in \\(Y\\). Consider the gluing of \\(R\\) and \\(Y\\) along this isomorphism, call it \\(X\\), with inclusions \\(i_R: R \\embed X, i_Y: Y \\embed X\\). The image of \\(R\\) in \\(X\\) is \\(X \\setminus \\{1 \\text{ points}\\}\\) % why so?\n  and all points in \\(i_R(R)\\) can be separated, similarly in \\(i_Y(Y)\\). If \\(P \\in X \\setminus i_Y(Y)\\) and \\(Q \\in X \\setminus i_R(R)\\) so \\(P\\) is \\((0, 0)\\) and \\(Q\\) is \\((0, 0)\\) in local coordinates then\n  \\begin{align*}\n    &\\{(z, w) \\in R: |z| < 1\\} \\\\\n    &\\{(t, v) \\in Y: |t| < 1\\}\n  \\end{align*}\n  separate \\(P\\) and \\(Q\\).\n\n  \\(X\\) admits a conformal structure for which \\(i_R, i_Y\\) are analytic. Consider\n  \\begin{align*}\n    D_R &= \\{(z, w) \\in R: |z| \\leq 2\\} \\\\\n    D_Y &= \\{(t, v) \\in Y: |t| \\leq 2\\}\n  \\end{align*}\n  these are compact in \\(R \\amalg Y\\) so map to compact sets in \\(X\\) via the continuous quotient map. Thus as a finite union of compact sets \\(X\\) is compact. Note this agrees with our topological intuition that \\(X\\) can be compactified by the addition of a single point.\n\\end{eg}\n\n\\subsection{Branching}\n\nNote these projection maps are \\emph{not} coverings on \\(R\\) (or \\(X\\)) but they still have controlled behaviour.\n\n\\begin{definition}[multiplicity/valency]\\index{multiplicity}\\index{valency}\n  Let \\(f: R \\to S\\) be an nonconstant analytic map of Riemann surfaces and \\(z_0 \\in R\\). Locally we can write\n  \\[\n    f(z) = f(z_0) + (z - z_0)^{m_f(z_0)} g(z)\n  \\]\n  where \\(g(z)\\) nonzero analytic. \\(m_f(z_0)\\) is the \\emph{multiplicity} or \\emph{valency} of \\(f\\) at \\(z_0\\).\n\\end{definition}\n\n\\begin{lemma}\n  Suppose \\(g, h\\) are nonconstant analytic on domains in \\(\\C\\) and the image of \\(h\\) is contained in the domain of \\(g\\). Then\n  \\[\n    m_{g \\compose h}(z) = m_h(z) m_g(h(z)).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Left as an exercise.\n\\end{proof}\n\nAs a corollary, multiplicity is well defined. Indeed if \\(z \\in R, f(z) \\in S\\) and \\((U, \\phi), (\\tilde U, \\tilde \\phi)\\) are charts for \\(z\\), \\((V, \\psi), (\\tilde V, \\tilde \\psi)\\) are charts for \\(f(z)\\) then \\(m_f(z)\\) is given by the multiplicity of its local expression, which is\n\\begin{align*}\n  \\tilde \\psi \\compose f \\compose \\tilde \\phi^{-1}\n  &= \\tilde \\psi \\compose (\\psi^{-1} \\compose \\psi \\compose f \\compose \\phi^{-1} \\compose \\phi) \\compose \\tilde \\phi^{-1} \\\\\n  &= (\\tilde \\psi \\compose \\psi^{-1}) \\compose (\\psi \\compose f \\compose \\phi^{-1}) \\compose (\\phi \\compose \\tilde \\phi^{-1})\n\\end{align*}\nthe transition maps have multiplicity 1 everywhere so by the lemma the multiplicity of the local expressions agree.\n\nNote that the points at which \\(m_f(z) > 1\\) are isolated, by the (local) principle of isolated zeros. In particular if \\(R\\) is compact then \\(\\{z \\in R: m_f(z) > 1\\}\\) is finite. %Note that in complex analysis we expressed local mapping degree in terms of derivatives. On Riemann surfaces we don't have derivative (really???) but multiplicity still makes sense.\n\n\\begin{definition}[ramification point, ramification index, branch point]\\index{ramification point}\\index{ramification index}\\index{branch point}\n  Let \\(f: R \\to S\\) be nonconstant analytic. If \\(z \\in R\\) has \\(m_f(z) > 1\\), we call \\(z\\) a \\emph{ramification point} of \\(f\\) and \\(m_f(z)\\) in this case is called the \\emph{ramification index} at \\(z\\), and \\(f(z)\\) is a \\emph{branch point} of \\(f\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(p(z) = \\sum_{k = 0}^d a_kz^k\\) be an analytic map \\(\\C \\to \\C\\) with \\(d \\geq 1, a_d \\neq 0\\). \\(p\\) extends to an analytic map of the Riemann sphere via \\(p(\\infty) = \\infty\\). At \\(\\infty\\) the local expression is\n  \\[\n    \\frac{1}{p(\\frac{1}{z})} = \\frac{1}{\\sum_{k = 0}^d a_k z^{-k}} = \\frac{z^d}{\\sum_{k = 0}^d a_k z^{d - k}} = z^d g(z)\n  \\]\n  for some \\(g\\) analytic and nonzero near \\(0\\). Thus \\(m_p(\\infty) = d\\).\n\\end{eg}\n\n\\begin{theorem}[valency theorem]\\index{valency theorem}\n  Let \\(f: R \\to S\\) be a nonconstant analytic map of Riemann surfaces. If \\(R\\) is compact then there exists \\(n \\geq 1\\) such that \\(f\\) is an \\(n\\)-to-\\(1\\) map counting multiplicity, i.e.\\ for all \\(w \\in f(S)\\),\n  \\[\n    \\sum_{z \\in f^{-1}(w)} m_f(z) = n.\n  \\]\n\\end{theorem}\n\nSee how false this can be for noncompact Riemann surfaces!\n\n\\begin{proof}\n  By the principle of isolated zeros \\(f^{-1}(w)\\) is a finite set for all \\(w \\in S\\). Define then\n  \\[\n    n(w) = \\sum_{z \\in f^{-1}(w)} m_f(z).\n  \\]\n  We want to show \\(n: S \\to \\Z\\) is constant. But \\(S\\) is connected so suffcie to show \\(n\\) is locally constant. Fix \\(w_0 \\in S\\) and let \\(f^{-1}(w_0) = \\{z_1, \\dots, z_q\\}\\). For each \\(z_k\\), \\(f\\) is locally \\(z \\mapsto z^{m_f(z_k)}\\) on a neighbourhood of \\(z_k\\). Choose a chart \\((N_k, \\phi)\\) around \\(z_k\\) such that \\(\\phi(N_k)\\) is a disk around \\(\\phi(z_k)\\). \\(f|_{N_k}\\) is an \\(m_f(z_k)\\)-to-\\(1\\) map to its image. wlog choose the \\(N_k\\) disjoint. Note that \\(R \\setminus \\bigcup N_k\\) is compact so \\(f(R \\setminus \\bigcup N_k)\\) is compact, and there exists \\(M\\) open neighbourhood of \\(w_0\\) such that \\(f(R \\setminus \\bigcup N_k) \\cap M = \\emptyset\\). Let \\(N = f(N_1) \\cap \\dots \\cap f(N_q) \\cap M\\), an open neighbourhood of \\(w_0\\). For \\(w \\in N\\), \\(f^{-1}(w) \\subseteq \\bigcup_{k = 1}^q N_k\\) so\n  \\[\n    n(w) = \\sum_{z \\in f^{-1}(w)} m_f(w) = \\sum_{z \\in f^{-1}(w_0)} m_f(z) = n(w_0).\n  \\]\n\\end{proof}\n\n\\begin{definition}[degree/valency]\\index{degree}\\index{valency}\n  Let \\(f: R \\to S\\) be a nonconstant analytic map with \\(R\\) compact. Then we call the number \\(n\\) the \\emph{degree} or \\emph{valency} of \\(f\\).\n\\end{definition}\n\n\\begin{corollary}[fundamental theorem of algebra]\n  Let \\(p\\) be nonconstant polynomial of degree \\(d\\). Then \\(p\\) has \\(d\\) roots in \\(\\C\\).\n\\end{corollary}\n\n\\begin{proof}\n  \\(p\\) extends to a map \\(p: \\C_\\infty \\to \\C_\\infty\\) and \\(p^{-1}(\\infty) = \\infty\\) with multiplicity \\(d\\). So by valency theorem \\(0\\) also has \\(d\\) preimages counting multiplicity.\n\\end{proof}\n\n\n\n\\printindex\n\\end{document}\n\n% https://www.dpmms.cam.ac.uk/~hk439/teaching.html", "meta": {"hexsha": "4d4e3ab6f01e62527a87d5f3c1a202ef7775b2bf", "size": 63370, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "II/riemann_surfaces.tex", "max_stars_repo_name": "b-mehta/tripos", "max_stars_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-27T11:16:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-27T11:16:41.000Z", "max_issues_repo_path": "II/riemann_surfaces.tex", "max_issues_repo_name": "b-mehta/tripos", "max_issues_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "II/riemann_surfaces.tex", "max_forks_repo_name": "b-mehta/tripos", "max_forks_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.0748230536, "max_line_length": 1002, "alphanum_fraction": 0.6299826416, "num_tokens": 21924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632683808532, "lm_q2_score": 0.7853085758631158, "lm_q1q2_score": 0.4263151801805642}}
{"text": "\\documentclass[letterpaper, 10pt, twocolumn]{article}\n\\usepackage{multicol}\n\\usepackage{blindtext}\n\\usepackage{geometry}\n\\geometry{letterpaper, margin=0.75in}\n\n\\usepackage{xcolor}\n\n\\usepackage{tikz}\n\\usetikzlibrary{calc}\n\n\n\\usepackage{amsmath, amsthm, amsfonts}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\n\n\\DeclareMathOperator{\\dist}{d}\n\\DeclareMathOperator{\\proj}{Proj}\n\\DeclareMathOperator{\\atan}{atan}\n\\usepackage{../potentialgap}\n\n\\newcommand{\\editadd}[1]{\\textcolor{magenta}{#1}}\n\\newcommand{\\modified}[1]{\\textcolor{blue}{#1}}\n\\newcommand{\\remove}[1]{\\textcolor{yellow}{\\st{#1}}}\n\n\n\\begin{document}\n\\section{Potential Gap Theorem}\n\n\\input{minimalTheorem.tex}\n\nFor this document to be standalone, the important constructions\nassociated to the motion vector field will be reproduced here, followed\nby the proof proper.\n\n\\subsection{Potential Gap Gradient Fields}\n\\input{pgapFields.tex}\n\n\\begin{definition}[Gap Gradient Field]\n  The potential field $\\attPot(\\xv)$ and circulation field $\\rotVF(\\xv)$\n  given by \\eqref{eq:dpot} \\eqref{eq:gcirc} define the gradient field\n  $\\Dv(\\xv) = \\hat{\\nabla}\\attPot(\\xv) + \\rotVF(\\xv)$.\n\\end{definition}\n\n\\begin{definition}\n  $\\hat \\nabla F$ is the gradient of $F$ with normalization to unit length\n  for non-zero magnitude gradients.\n\\end{definition}\n\n\\subsection{Potential Gap Proof of Passage}\n\n\\input{minimalProof.tex}\n\n\\end{document}\n\n", "meta": {"hexsha": "e3346c206473439e04b322c08da29486ca4e4310", "size": 1574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SuppMat/assets/theorem/theorem.tex", "max_stars_repo_name": "ivaROS/PotentialGap", "max_stars_repo_head_hexsha": "680a9c1c76d54fd2265379f85d881b7941ad0383", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SuppMat/assets/theorem/theorem.tex", "max_issues_repo_name": "ivaROS/PotentialGap", "max_issues_repo_head_hexsha": "680a9c1c76d54fd2265379f85d881b7941ad0383", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-07-22T19:01:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-26T23:55:02.000Z", "max_forks_repo_path": "SuppMat/assets/theorem/theorem.tex", "max_forks_repo_name": "ivaROS/PotentialGap", "max_forks_repo_head_hexsha": "680a9c1c76d54fd2265379f85d881b7941ad0383", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-07-25T00:14:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-11T12:38:28.000Z", "avg_line_length": 25.3870967742, "max_line_length": 74, "alphanum_fraction": 0.7598475222, "num_tokens": 466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4262858670024777}}
{"text": "\\documentclass{doomnote}\n\n% For Demo Purposes:\n\\usepackage{lipsum}\n\n\\title{Simple DoomNote Demo}\n\\date{\\today}\n\\renewcommand*{\\lecnum}{1}\n\n\\begin{document}\n\\tableofcontents\n\\section{Sample Title}\n\\lipsum[2]\n\\begin{theorem}\n  \\lipsum[2]\n\\end{theorem}\n\n\\begin{proof}\n  {\\textasteriskcentered}\n  Insert some fancy proof\n  {\\textasteriskcentered}\\\\\n  \\begin{equation*}\n    \\frac{d}{dt}\\int\\int_{\\Sigma}\\textbf{B} \\cdot \\text{d}\\textbf{S} = \\int\\int_{\\Sigma}\\frac{\\delta\\textbf{B}}{\\delta{t}} \\cdot \\text{d}\\textbf{S}\n  \\end{equation*}\n\\end{proof}\n\\begin{eg}\n  \\lipsum[2]\n\\end{eg}\n\n\\begin{definition}\n  Example Definition. Not much to see here )).\n\\end{definition}\n\\end{document}\n", "meta": {"hexsha": "db6aab5c4bac8a5369aeed3581e0794b0c811343", "size": 675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples/simple/simple.tex", "max_stars_repo_name": "rshchekotov/doomtex", "max_stars_repo_head_hexsha": "2c586141f87594ee9658c79c0f79e27821f53ae6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/simple/simple.tex", "max_issues_repo_name": "rshchekotov/doomtex", "max_issues_repo_head_hexsha": "2c586141f87594ee9658c79c0f79e27821f53ae6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple/simple.tex", "max_forks_repo_name": "rshchekotov/doomtex", "max_forks_repo_head_hexsha": "2c586141f87594ee9658c79c0f79e27821f53ae6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.8529411765, "max_line_length": 147, "alphanum_fraction": 0.6962962963, "num_tokens": 243, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4262858578715318}}
{"text": "\\section{General theory}\nThe idea, pioneered by Picard and Vessiot, was for a given differential equation $L \\in k[\\partial]$ with differential extension $K/k$ and PV ring $R$ we get a functor\n$$\\trm{DGal}(K/k) : \\trm{CAlg}_{k^\\partial} \\longrightarrow \\trm{Grp}$$\nwhich assigns to each commutative $k^\\partial$ algebra $A$ the group of elements $\\varphi \\in \\trm{Aut}_{k^\\partial}(R \\otimes A)$ such that\n$$\\xymatrix{\nR \\otimes_{k^\\partial} A \\ar[r]^{\\partial_R \\otimes id_A} \\ar[d]_\\varphi &R\\otimes_{k^\\partial} A\\ar[d]^\\varphi\\\\\nR \\otimes_{k^\\partial} A \\ar[r]_{\\partial_R \\otimes id_A} & R \\otimes_{k^\\partial} A\\\\\n}$$\ncommutes. As all $A$ points (i.e. functor evaluated at $A \\in \\trm{CAlg}_{k^ \\partial}$) are subgroups of $\\trm{Gl}_l(k^\\partial)$ for some $l \\leq \\trm{deg} L$, we see that it is an affine group scheme over $k^\\partial$. Umemura extended the definition the functor via:\n$$\\trm{Inf-Gal} := \\trm{Ume} : \\trm{CAlg_k} \\longrightarrow \\trm{Grp}$$\n\\index{Symbol}{$\\trm{Inf-Gal}$}\n\\index{Symbol}{$\\trm{Ume}$}\nwhich assigns to each commutative differential algebra $A$ over a differential field $k$ a group object $G$ or more generally: a formal group law/formal group scheme. In \\cite{Heid13}, this functor is introduced as the \\textit{Umemura-functor}. However, Heiderich uses a bialgebraic approach - that is - let $D$ be a bialgebra and $A$ a $D$-module algebra. The question tackled by the bialgebraic approach is:\n\\bd\n\\item[How] to extend the action of a derivation on tensor products of $D$-modules $A^{\\otimes n}$ for all $n \\geq 0$?\\\\\n\\item[Answer] use its coalgebraic structure $\\Delta, \\eps$ (or equivalently the $D$-module algebraic structure).\n\\ed\nMore importantly, the question for formalization and generalizations of the bialgebraic approach of the PV theory builds an extended framework to deal with the above question in terms of iterative derivation and difference equations in positive characteristic or arbitrary characteristic, respectively. However, this is well beyond the scope of this paper.\\\\\n\\indent To explain this approach, we have to introduce some additional constructs. Although, most of the definition in the linear case are still used (as for instance Picard-Vessiot rings/fields). However, we usually do not assume $K/k$ to be field extension, rather some ring (i.e. an associative $k$-algebra).\n\\subsection{Basics}\nAs in the last section, $(k,\\partial)$ is differential field and $K$ is a differential extension such that $k(x) := k(x_1,\\ldots,x_n)$ is a differential field/ring and $[K:k(x)] = [K:k(x)]_{\\trm{sep}} < \\infty$, as field/ring extension in the classical sense. Note, that $(K, \\{\\partial, \\partial_i = [x_j \\longmapsto \\delta_{i,j}] : 1 \\leq i \\leq n\\})$ is also a differential algebra. In addition, let $\\trm{char} k = 0$.\n\\subsubsection{Universal Taylor homomorphism and iterative derivations}\nLet $K/k$ be as above and $K[[t]]$ the ring of formal power series over $K$.\n\\begin{defi}[Universal Taylor]\nThe map\n$$\\iota : K \\longrightarrow K[[t]],\\ a \\longmapsto \\sum_{n \\geq 0} \\frac{\\partial(a)}{n!} t^n$$\nis called the universal Taylor-morphism.\n\\index{Symbol}{$\\iota$}\n\\index{Index}{homomorphism!universal Taylor}\n\\end{defi}\nBefore exploring why this is called universal we need some additional definitions.\n\\begin{defi}[$n$-variate iterative derivations]\nLet $K/k$ be as above, %$K[[w]]$ be the ring of formal power series in multiple variables $w = (w_i)_{i=1}^n$, \nwith $k$-derivations $\\partial_{x_i}$, where $x = (x_i)_{i=1}^n$. A family of $C_k$-module homomorphisms $(\\theta^{(\\alpha)})_{\\alpha \\in \\nz_0^n} \\subset \\trm{Hom}_{C_k}(K,K)$ defines an $n$-variate iterative derivation, if\n\\bn\n\\item $\\theta^{(0)} = id_K$,\n\\item $\\theta^{(\\alpha)}(a + b) = \\theta^{(\\alpha)}(a) + \\theta^{(\\alpha)}(b)$,\n\\item $\\theta^{(\\alpha)} (a b) = \\sum_{\\alpha_1 + \\alpha_2 = \\alpha} \\theta^{(\\alpha_1)} (a) \\theta^{(\\alpha_2)} (b)$ and\n\\item $\\theta^{(\\alpha_1)} \\circ \\theta^{(\\alpha_2)}(a) = \\left(\\bao{c}\n\\alpha_1 + \\alpha_2\\\\\n\\alpha_1\\\\\n\\ea\\right) \\theta^{(\\alpha_1 + \\alpha_2)} (a)$,\n\\en\nfor all $a, b \\in K$ and $\\alpha, \\alpha_i \\in \\nz_0^n$. Moreover, for an iterative derivation $\\theta$ we call the subring\n$$k^\\theta := \\left\\{x \\in k : \\theta^{(\\alpha)}(x) = 0,\\ \\forall \\alpha \\in \\nz_0^n\\bsl \\{0\\}\\right\\} = \\bigcap_{\\alpha \\in \\nz_0^n \\bsl \\{0\\}} \\ker \\theta^{(\\alpha)}$$\nits subring of iterative constants (or simply constants).\n\\index{Symbol}{$\\theta$}\n\\index{Index}{derivation!iterative}\n\\end{defi}\n\\bsp\n\\bn\n\\item The family of $C_k$-homomorphisms $\\{\\iota^{\\alpha}\\}$, given in the definition of the universal Taylor-morphism, clearly defines a mono-variate iterative derivation. We will show this shortly.\n\\item Let $\\trm{char} k = p \\neq 0$, and $K = k(x)$, then\n$$\\theta^{(m)} = \\left[x^n \\longmapsto \\left(\\bao{c}\nn\\\\\nk\\\\\n\\ea\\right) x^{n - m}\\right],\\ m \\geq 0$$\nis an example in positive characteristic. Indeed, its ring of iterative constants is $k$.\n\\en\n\\bmk The $n$-variate iterative derivations may be applied to positive characteristic. However, in case of the Taylor-morphism, this is only applicable to characteristic zero.\\\\\n\\indent We call a ring $(R, \\theta)$ an iterative differential ring, in particular for $R = k[x_1,\\ldots,x_n]$ it is $\\trm{Der}_{\\trm{ID^n}}$. The transcendence degree $n$ can be omitted to get a more general definition of $\\trm{Der}_{\\trm{ID}}$, the set of iterative derivations.\n\\begin{defi}\nLet $K/k$ be as above (with $\\trm{char} k = 0$) and let $\\theta^{(\\alpha)} := \\left[a \\longmapsto \\frac{\\partial_x^\\alpha(a)}{\\alpha!}\\right]$ define the iterative derivation (wrt. $x$):\n$$\\theta_x := \\sum_{\\alpha \\in \\nz_0^n} \\theta^{(\\alpha)} w^\\alpha : K \\longmapsto K[[w]],\\ a \\longmapsto \\sum_{\\alpha \\in \\nz_0^n} \\theta^{(\\alpha)}(a) w^\\alpha.$$\n\\end{defi}\nBoth maps play a prominent role in the definition of the so called Umemura functor. Returning to the universal Taylor-morphism, we have\n\\begin{lemm}\nLet $K/k$ be as above, $\\partial_t$ be the $K$-derivation $t \\longmapsto 1$ on $K[[t]]$ and $\\iota$ denote the Taylor-morphism. Then the following diagrams commute:\n$$\\bao{cc}\n\\xymatrix{\nK \\ar[rd]_{id_K}\\ar[r]^\\iota &K[[t]]\\ar[d]^{\\pi_t}\\\\\n&K\n}&\n\\xymatrix{\nK \\ar[r]^{\\iota_u}\\ar[d]_{\\iota} &K[[u]]\\ar[d]^{\\iota[[u]]}\\\\\nK[[t]] \\ar[r]_{t\\mapsto t+u}&K[[t]][[u]]\\\\\n}\n\\ea,$$\nwhere $\\iota_u$ represents an equivalent Taylor morphism $K \\longrightarrow K[[u]]$ (replacing $t$ with $u$ in $\\iota : K \\longrightarrow K[[t]]$), $\\pi_t = [x \\longmapsto x \\mod t]$ and $\\iota[[u]] : K[[u]] \\longrightarrow K[[t]][[u]], \\sum_{n \\geq 0} a_n u^n \\longmapsto \\sum_{n \\geq 0} \\iota(a_n) u^n$.\\\\\nIn addition, the following diagram also commutes for all $i \\geq 0$:\n$$\\xymatrix{\nK \\ar[r]^\\iota\\ar[d]_{\\partial_K^i}&K[[t]]\\ar[d]^{\\partial_t^i}\\\\\nK&K[[t]]\\ar[l]^{\\pi_t},\\\\\n}$$\nwhere $\\partial_K$ is the extension of $\\partial \\in \\trm{Der}_C(k)$ on $K$.\n\\end{lemm}\n\\bws The first diagram and the third are equivalent if $i = 0$. Also, the first diagram is an immediate consequence of the definition of $\\iota$ as it is defined by iterative derivations $\\iota^{(k)} : K \\longrightarrow K$.\n\\bn\n\\item Pick some $a \\in K$, then the upper part of the diagram yields:\n$$\\iota[[u]] \\circ \\iota_u(a) = \\iota[[u]]\\left(\\sum_{n\\geq 0} \\frac{\\partial^n(a)}{n!} u^n\\right) = \\sum_{n + m\\geq0} \\frac{\\partial^{n+m}(a)}{n!m!} t^m u^n$$\nFollowing the lower part:\n$$f(a) = \\sum_{n\\geq0} \\frac{\\partial^n(a)}{n!}(t + u)^n = \\sum_{n\\geq0} \\sum_{m \\leq n}\\left(\\bao{c}\nn\\\\\nm\\\\\n\\ea\\right) \\frac{\\partial^{n'}(a)}{n'!} t^{m'} u^{n'-m'} = \\sum_{m'+n'\\geq0} \\frac{\\partial^{n'+m'}(a)}{m'! n'!} t^{m'} u^{n'},$$\nSetting $m = m'$ and $n' = n + m$ in both parts, we see by comparison of coefficients that the claim holds.\n\\item Pick $a \\in K$, then:\n$$\\pi_t \\circ \\partial_t^i\\circ\\iota(a) = \\pi_t \\circ \\partial_t^i\\left(\\sum_{n\\geq0} \\frac{\\partial^n(a)}{n!} t^n\\right) = \\pi_t\\left(\\sum_{n \\geq i} \\frac{ \\partial^n(a)}{(n - i)!} t^{n-i}\\right) = \\partial^i(a),$$\ncompleting the prove.\n\\en\n\\bmk The second part of the prove, in essence, shows that $\\iota$ is indeed an iterative derivation. Moreover, $K[[t]]$ is a $D = k[\\partial]$-module algebra and $\\iota$ is a homomorphism of $D$-module algebras.\n\\begin{defi}\nThe following algebras are differential sub-algebras of $K[[t]]$:\n\\bn\n\\item $\\mathcal{K} := K\\{\\iota(K)\\}_{\\partial_x}$, i.e. is generated by $K$ and the image of $K$ under $\\iota$ - closed under the $k$-derivations $\\partial_x$.\n\\item $\\kappa := K\\{\\iota(k)\\}_{\\partial_x}$, i.e. is generated by $K$ and the image of $k$ under $\\iota$ - closed under the $k$-derivations $\\partial_x$.\n\\en\n\\end{defi}\n\\bmk The partial differential subalgebras of $K[[t]]$ can be expressed as\n\\bn\n\\item $\\kappa = \\left<\\iota(a), b : a \\in k, b \\in K\\right>_{k-\\trm{alg}}$ and\n\\item $\\mathcal{K} = \\left<\\partial_x^{\\alpha}(\\iota(a)), b : a, b \\in K, \\alpha \\in \\nz_0^n\\right>_{k-\\trm{alg}}$.\n\\en\n\\subsubsection{The Umemura functor}\nLet $K/k$ be as above and let $A$ be a commutative (ass.) $K$-algebra (i.e. a ring containing $K$). We will consider the following tensor product:\n$$K[[t]] \\otimes A[[w]] := K[[t]] \\otimes_K A[[w]],$$\nwith the algebra structure induced by the composition of $\\theta_x : K \\longrightarrow K[[w]]$ and the image of $K[[w]]$ in $A[[w]]$ via the $K$-linear unit-homomorphisms:\n$$\\bao{rrclcrcl}                \n\\eta_{K[[t]]}': &K &\\longrightarrow& K[[t]],&& a &\\longmapsto& a\\cdot t^0\\\\\n&&&&&&&\\\\\n\\eta_A : &K &\\longrightarrow& A,&& a &\\longmapsto& a\\cdot 1_A\\\\\n\\ea$$\nand\n$$\\theta_x[[t]] : K[[t]] \\longrightarrow K[[t]] \\otimes K[[w]],\\ \\sum_{i\\geq0} a_i t^i \\longmapsto \\sum_{\\substack{i\\geq0\\\\k \\in \\nz_0^n}} \\frac{\\partial_x^k(a_i)}{k!} t^i \\otimes w^k,$$\nwhere the tensor product is defined over $K$, making the following diagram commutative\n$$\\xymatrix{\nK \\ar[rr]^{\\eta_{K[[t]]}} \\ar[d]_{\\eta_{K[[t]]} \\otimes \\eta_{A[[w]]}} && K[[t]]\\ar[d]^{\\theta_x[[w]]}\\\\\nK[[t]] \\otimes A[[w]] && K[[t]] \\otimes K[[w]]\\ar[ll]_{id \\otimes \\eta_{A}[[w]]}.\\\\\n}$$\nThis defines a partial differential algebra structure on $K[[t]] \\otimes A[[w]]$:\n$$\\bao{rrcl}                                    \n\\partial_t :& K[[t]]\\otimes A[[w]] &\\longrightarrow& K[[t]]\\otimes A[[w]]\\\\\n& \\sum_{(i,k) \\in \\nz_0^{n+1}} a_{i,k} t^i\\otimes w^k&\\longmapsto& \\sum_{(i+1,k) \\in \\nz_0^{n+1}} i a_{i,k} t^{i-1} \\otimes w^k\\\\\n&&&\\\\\n\\partial_{x_i} :& K[[t]]\\otimes A[[w]] &\\longrightarrow& K[[t]]\\otimes A[[w]]\\\\\n& \\sum_{(i,k) \\in \\nz_0^{n+1}} a_{i,k} t^i\\otimes w^k&\\longmapsto& \\sum_{(i,k) \\in \\nz_0^{n+1}} \\partial_{x_i}(a_{i,k}) t^{i-1} \\otimes w^k\\\\\n&&&\\\\\n\\partial_{w_i} :& K[[t]]\\otimes A[[w]] &\\longrightarrow& K[[t]]\\otimes A[[w]]\\\\\n& \\sum_{(i,k) \\in \\nz_0^{n+1}} a_{i,k} t^i\\otimes w^k&\\longmapsto& \\sum_{(i,k+e_i) \\in \\nz_0^{n+1}} k_i a_{i,k} t^{i-1} \\otimes w^{k-e_i},\\\\\n\\ea$$\nwhere $e_i$ denotes the canonical base vector in $\\zz^n$. We note that while $\\partial_t, \\partial_{w_i} \\in \\trm{Der}_K(K[[t]]\\otimes A[[w]])$ the derivation $\\partial_{x_i}$ is in $\\trm{Der}_k(K[[t]] \\otimes A[[w]])$. To specify,\n$$\\bao{rcl}\n\\partial_t &\\in& \\trm{Der}_{A[[w]]}(K[[t]] \\otimes A[[w]]),\\\\\n&&\\\\\n \\partial_{w_i} &\\in& \\trm{Der}_{K[[t]] \\otimes A[[w \\bsl\\{w_i\\}]]}(K[[t]]\\otimes A[[w]]),\\\\\n&&\\\\\n \\partial_{x_i} &\\in& \\trm{Der}_{k[[t]] \\otimes k[[w]]} (K[[t]]\\otimes A[[w]]),\\\\\\ea$$\nwhere $\\partial_\\zeta \\in \\trm{Der}_A(B)$ implies $B^{\\partial_\\zeta} \\supseteq A$.\n%\\begin{defi}[Linear topological rings]\n%A topological ring $R$ is called linear if there is a fundamental neighborhood basis of $0 \\in R$.\n%%Ein topologischer Ring $R$ hei\\ss{}t linear, falls es eine fundamentale Umgebungsbasis von $0 \\in R$ gibt.\n%\\end{defi}\n%For further discussion see appendix. If $R$ is a linear topological ring with fundamental neighborhood basis $\\beta(0)$ then every open neighborhood of zero contains at least one ideal, trivially the zero ideal as ideals are stable under intersection. Let $\\{I_i \\in \\beta(0) : i \\in \\mathcal{I}\\}$ be a system of ideals then the union is a subset of $R$ containing ideals of the form%  Ist nun $R$ ein linear topologischer Ring, mit fundamentaler Umgebungsbasis $\\beta(0)$, dann enth\\\"alt jede offene Umgebung der Null mindestens ein Ideal $I \\in \\beta(0)$, trivialerweise mindestens $(0)$, da der Schnitt beliebiger Ideale wieder ein Ideal ergibt. Sei $\\{I_i \\in \\beta(0) : i \\in \\mathcal{I}\\}$ ein System von Idealen, dann ist deren Vereinigung eine Teilmenge von $R$, die alle Ideale der Form\n%$$\\bigcap_{i \\in \\mathcal{I}'} I_i, \\forall \\mathcal{I}' \\subset \\mathcal{I}\\ \\trm{and}\\ |\\mathcal{I}'| < \\infty$$\n%defining an open neighborhood of zero. On the other hand, the intersections are also neighborhoods of zero. Hence, all elements are clopen in $R$.%enth\\\"alt und definiert damit eine offene Umgebung der Null. Andererseits sind die Schnitte der Ideale auch Umgebungen der Null, d.h. damit sind alle Ideale \\textit{clopen} in $R$.\n%\\begin{defi}[Complete topological rings]\n%Let $R$ be a linear topological ring with fundamental neighborhood basis $\\beta(0)$. $\\hat{R}$ is called complete if%Sei $R$ ein linear topologischer Ring mit Fundamental-UB $\\beta(0)$. Ein Ring $\\hat{R}$ hei\\ss{}t Vervollst\\\"andigung von $R$, falls\n%$$\\hat{R} \\simeq \\lim_{\\substack{\\longleftarrow\\\\I \\in \\beta(0)}} R/I$$\n%i.e. the pro-finite limit of $R/I)$ for all $I \\in \\beta(0)$ and ring morphisms\n%$R/I \\longrightarrow R/J$, for all $I \\subset J$ - ordered by inclusion.%d.h. der pro-endliche (oder inverse) Limes von  $(R/I)_{I \\in \\beta(0)}$, mit Ringmorphismen $R/I \\longrightarrow R/J$ f\\\"ur alle $I \\subset J$ und $\\beta(0)$ angeordnet bzgl. Inklusion.\n%\\end{defi}\n%Now, we are equipped with the appropriate tools to continue.\nFor the definition of linear topological rings, linear topological rings with fundamental basis and their completion consult the appendix.\n\\begin{defi}\nLet $K/k$ and $K[[t]] \\otimes A[[w]]$ be as above. The $K$-algebra $K[[t]] \\hat{\\otimes} A[[w]]$ is called the completion of $K[[t]] \\otimes A[[w]]$ wrt the $\\left<w\\right>$-adic topology. To specify, if the neighborhood basis is defined by\n$$\\beta(0) = \\left\\{\\left<1\\otimes w\\right>^i : i \\geq 1\\right\\} = \\left\\{\\left<1 \\otimes w^i : \\ w^i = w_1^{i_1} \\ldots w_n^{i_n}, \\sum i_j = i\\right> : i \\geq 1\\right\\},$$\nthen the completion is simply the pro-finite limit\n$$\\lim_{\\substack{\\longleftarrow\\\\I \\in \\beta(0)}} K[[t]] \\otimes A[[w]]/I.$$\n\\end{defi}\nLastly, we note that the two algebras $\\kappa \\hat{\\otimes} A[[w]]$ and $\\mathcal{K} \\hat{\\otimes} A[[w]]$ are differential subalgebras of $K[[t]] \\hat{\\otimes} A[[w]]$. \n\\begin{defi}[Umemura functor]\nLet $K[[t]] \\otimes A[[w]]$ and $K[[t]] \\hat{\\otimes} A[[w]]$ be as above. Let $\\trm{CAlg}_K$ and $\\trm{Grp}$ denote the categories of commutative $K$-algebras and groups, respectively. The Umemura functor is the functor\n$$\\trm{Ume}(K/k) : \\trm{CAlg}_K \\longrightarrow \\trm{Grp}$$\nassigning to every $A \\in \\trm{CAlg}_K$ the group of automorphisms $\\varphi$ of $\\mathcal{K} \\hat{\\otimes} A[[w]]$ wrt to derivations $\\partial_t, \\partial_x, \\partial_w$ leaving $\\kappa \\hat{\\otimes} A[[w]]$ fixed and making\n$$\\xymatrix{\n\\mathcal{K} \\hat{\\otimes} A[[w]] \\ar[d]_{\\varphi}\\ar[rd]^{\\psi}&\\\\\n\\mathcal{K} \\hat{\\otimes} A[[w]] \\ar[r]_{\\psi}&\\mathcal{K} \\hat{\\otimes} \\left(A/N(A)\\right)[[w]]\\\\\n}$$\ncommutative, where $\\psi := id_\\mathcal{K} \\otimes \\pi[[w]]$. Moreover, if $\\lambda : A \\longrightarrow B$ is a morphism in $\\trm{CAlg}_K$, then one defines\n$$\\trm{Ume}(K/k)(\\lambda) : \\trm{Ume}(K/k)(A) \\longrightarrow \\trm{Ume}(K/k)(B),\\ \\varphi \\longmapsto \\varphi \\otimes id_{B[[w]]}.$$\n\\index{Index}{functor!Umemura}\n\\end{defi}\n\\bmk Some additional statements are in place:\n\\bn\n\\item for any $A \\in \\trm{CAlg}_K$ the set $N(A) \\subset \\trm{Ann}(A)$ is the nilradical of $A$ and $\\pi$ is its canonical projection $A \\longrightarrow A/N(A)$.\\index{Index}{nilradical}\n\\item for $A, B \\in \\trm{CAlg}_K$ and $\\lambda \\in \\trm{Hom}_{K-\\trm{alg}}(A,B)$ we regard $B[[w]]$ as a $A[[w]]$-algebra via\n$$\\lambda[[w]] : A[[w]] \\longrightarrow B[[w]], \\sum_{\\alpha} a_\\alpha w^\\alpha \\longmapsto \\sum_\\alpha \\lambda(a_\\alpha) w^\\alpha.$$\n\\item Umemura introduced the so called Lie-Ritt functors and shows that $\\trm{Ume}(K/k)$ is such a functor \\cite{Ume96,Ume96b}. Heiderich gives a more general definition in \\cite{Heid10} which we are going to repeat for clarity.\n\\en\n\\subsection{The Lie-Ritt functor}\nAs previously, we work in the same setting: $K/k$ a differential extension, $A \\in \\trm{CAlg}_K$ and all its algebras as above. Furthermore, let $n$ denote the transcendence degree of $K/k$.\n\\subsubsection{The infinitesimal coordinate transformation group}\nFirstly, we define a special set of evaluation maps, which will be referred to as the set of infinitesimal coordinate transformation. It is shown that this set is indeed a group wrt. to composition. For $A[[w]]$ we define the differential algebra $A[[w]]\\{\\{Y\\}\\}$ to be the algebra of differential formal power series with coefficients in $A[[w]]$ (conforming to the definition of the ring of differential polynomials, \\ref{RingOfDiffPolys} on pg. \\pageref{RingOfDiffPolys}), i.e. a transcendental extension of $A[[w]]$, with variables $\\left\\{Y_i^{(j)} : 1 \\leq i \\leq n, j \\in \\nz_0^n\\right\\}$, where the super script index indicates $\\partial_{Y_j}\\left(Y_i^{(k)}\\right) = Y_i^{(k+e_j)}$ (i.e. $A[[w]]$-derivations with $e_j \\in \\nz_0^n$ the canonical base vector).\n\\begin{defi}\nWe define\n\\bn\n\\item the set $$\\Gamma(A,n) := \\left\\{\\Phi = (\\phi_1,\\ldots,\\phi_n) \\in A[[w]]^n : \\phi_i \\equiv w_i \\mod N(A)\\right\\},$$\nwith group structure via composition: $\\Psi \\cdot \\Phi := \\left(\\psi_1(\\Phi),\\ldots,\\psi_n(\\Phi)\\right)$ - the infinitesimal coordinate transformation group.\n\\item an $n$-variate iterative derivation $\\theta$ wrt. $w$, such that\n$$\\theta^{(l)}\\left(Y_i^{(k)}\\right) := \\left(\\bao{c}\nk + l\\\\\nk\\\\\n\\ea\\right) Y_i^{(k+l)}\\ \\forall l, k \\in \\nz_0^n,$$\nand its restriction to $K$ coincides with $\\theta_x$ as defined above.\n\\item the iterative differential subalgebra: \n$$A[[w]]\\{A[[Y]]\\}_\\theta := A[[w]]\\left[\\left[\\theta^{(l)}\\left(Y_i^{(0)}\\right) : l \\in \\nz_0^n, 1 \\le i \\leq n\\right]\\right] \\subset A[[w]]\\{\\{Y\\}\\},$$\n\\item for $F \\in A[[w]]\\{A[[Y]]\\}_\\theta$ and $\\Phi \\in \\Gamma(A,n)$ $F\\mid_{Y = \\Phi} = \\sigma(F,\\Phi)$,  where\n$$\\bao{rrcl}\n\\sigma : &A[[w]]\\{A[[Y]]\\}_\\theta \\times \\Gamma(A,n) &\\longrightarrow &A[[w]]\\\\\n&&&\\\\\n&\\left(Y_i^{(k)},\\Phi\\right)&\\longmapsto&\\theta^{(k)}(\\phi_i)\\\\\n\\ea$$\n\\en\n\\index{Index}{group!infinitesimal transformation}\n\\end{defi}\n\\bmk We shall note the set $\\Gamma(A,n)$ can be considered as substitution homomorphism \n$$\\hat{\\phi}_i = \\left[w_i \\longmapsto\n\\phi_i\\right],\\ \\hat{\\phi}_i\\mid_{A[[w]]/\\left<w_i\\right>} = id_{A[[w]]/\\left<w_i\\right>}$$\non $A[[w]]$. To see that this set is indeed a group, note that\n\\bn\n\\item associativity and closedness follows immediately from the last statement,\n\\item the unit element is simply $id_{A[[w]]}$ and\n\\item first, we note that if $u \\in A^\\times$ then $x := u + a \\in A^\\times$ for all $a \\in N(A)$, as\n$$x - u \\in N(A) \\LRA \\exists m \\in \\nz,\\ \\trm{such}\\ \\trm{that}\\ (x - u)^m = 0 = \\sum_{0\\leq l\\leq m}\\left(\\bao{c}m\\\\l\\\\\n\\ea\\right) x^l (-u)^{m-l}$$\n$$\\LRA (-u)^m = x \\sum_{1 \\leq l\\leq m}\\left(\\bao{c}m\\\\l\\\\\\ea\\right) x^{l-1} (-u)^{m-l} \\in A^\\times.$$\nNow, pick $\\phi_i = a_i + w_i$ and $\\psi_i = (1 + b_i) w_i$ then the inverse is $\\phi_i^{-1} = w_i - a_i$ and $\\psi_i^{-1} = (1 + b_i)^{-1} w_i$ for all $a_i, b_i \\in N(A)$.\n\\en\nFurthermore, let $X$ denote $\\trm{map}(\\{1,\\ldots,n\\} \\times \\nz_0^n,\\nz_0) = \\nz_0^{\\{1,\\ldots,n\\} \\times \\nz_0^n}$ - is an element $F \\in A[[w]]\\{A[[Y]]\\}_\\Psi$ defined as\n$$F = \\sum_{\\substack{\\alpha \\in \\nz_0^n\\\\k \\in X}} a_{\\alpha,k} w^\\alpha \\prod_{(i,\\beta) \\in \\{1,\\ldots,n\\} \\times \\nz_0^n} \\left(Y_i^{(\\beta)}\\right)^{k(i,\\beta)},$$\nthen the image $F\\mid_{Y=\\Phi}$ for a given $\\Phi \\in \\Gamma(A,n)$ is\n$$\\sigma(F,\\Phi) = F\\mid_{Y=\\Phi} = \\sum_{\\substack{\\alpha \\in \\nz_0^n\\\\k \\in X}} a_{\\alpha,k} w^\\alpha \\prod_{(i,\\beta) \\in \\{1,\\ldots,n\\} \\times \\nz_0^n} \\theta^{(\\beta)}\\left(\\phi_i\\right)^{k(i,\\beta)}.$$\nWith these definitions in place we can proceed with\n\\begin{defi}[Lie-Ritt functor]\nA Lie-Ritt functor over $K$ is a group functor $G$ on $\\trm{CAlg}_K$ such that there exits an $n \\in \\nz$ and an ideal $I \\subset K[[w]]\\{K[[Y]]\\}_\\theta$ such that $G(A) \\simeq Z(I)(A)$, where\n$$Z(I)(A) := \\left\\{\\Phi \\in \\Gamma(A,n) : F\\mid_{Y = \\Phi} = 0\\ \\forall F \\in I\\right\\}.$$\n\\index{Index}{functor!Lie-Ritt}\n\\end{defi}\n\\bmk If $\\Phi \\in \\Gamma(A,n)$ is fixed we denote by $\\sigma_\\Phi(F)$ simply $\\sigma(F,\\Phi)$. Umemura defines the Lie-Ritt functors over $K$ via ideals in $K[[w]]\\{\\{Y\\}\\}$. However, Heiderich remarks that, in general, $\\sigma_\\Phi(F)$ is not well defined for arbitrary $F \\in K[[w]]\\{\\{Y\\}\\}$.\n\\begin{prop}\\label{LieRittFunctor}\nEvery Lie-Ritt functor over some commutative ring $K$ is isomorphic to a formal group scheme over $K$.\n\\end{prop}\n\\bws See \\cite{Heid10}, proof of prop. 2.11.\n\\subsubsection{Umemura functor as Lie-Ritt functor}\nWe repeat and extend some of our above definitions. We set $k^\\partial =: C$ (a commutative ring).\n\\begin{defi}\nLet $G$ be a monoid, $D^1$ an irreducible pointed cocommutative $C$-Hopf-algebra of Birkhoff-Witt type and $D$ be the smashed product $D^1\\#C[G]$ ($D^1$ as a $C[G]$-module algebra). If $A$ is a $D$-module algebra with structure map $\\Psi$ %we denote by $_C\\mathcal{M}(D,A)$ the $C$-module of $D$-module algebra homomorphisms, i.e. the subset of $f \\in \\trm{Hom}_C(D,A)$ such that the following diagram commutes:\n%$$\\xymatrix{\n%D \\otimes D\\ar[r]^{id_D \\otimes f}\\ar[d]_{\\Psi_D}&D \\otimes A\\ar[d]^{\\Psi_A}\\\\\n%D \\ar[r]_f&A\\\\\n%}$$\n%where $\\Psi_D$ denotes the $D$-module algebra structure on $D$ itself.\nwe define the map:\n$$\\rho : A \\longrightarrow \\trm{Hom}_C(D,A),\\ a \\longmapsto \\Psi(\\_ \\otimes a) = [d \\longmapsto \\Psi(d \\otimes a)].$$\nThis map is called the module algebra homomorphism.\n\\end{defi}\n\\bmk Let us discuss some immediate consequences for any $D$-module algebra $A$. Firstly, for the definition of $\\rho$ we use the isomorphism:\n$$\\trm{Hom}_C(D \\otimes A, A) \\simeq \\trm{Hom}_C(A, \\trm{Hom}_C(D,A)).$$\nSecondly, we get two other homomorphisms, induced by $\\Psi_0 : D \\otimes A \\longrightarrow A$ and $\\Psi_{\\trm{int}} : D \\otimes \\trm{Hom}_C(D,A) \\longrightarrow \\trm{Hom}_C(D,A)$:\n$$\\bao{rrcl}\n\\rho_0 : & A & \\longrightarrow & \\trm{Hom}_C(D,A)\\\\\n& a & \\longmapsto & a \\eps_D\\\\\n&&&\\\\\n\\rho_{\\trm{int}} : & \\trm{Hom}_C(D,A) & \\longrightarrow &\\trm{Hom}_C(D \\otimes D,A) \\simeq \\trm{Hom}_C(D,\\trm{Hom}_C(D,A))\\\\\n& f & \\longmapsto &\\Psi_{\\trm{int}}(\\_ \\otimes f) := [d \\otimes d' \\longmapsto f \\circ \\mu_D(d \\otimes d')].\\\\\n\\ea$$\n$\\Psi_0$ and $\\Psi_{\\trm{int}}$ are the trivial and internal module algebra homomorphism, respectively.\n%\\bn\n%\\item $_C\\mathcal{M}(D,A)$ is a $C$-algebra via convolution:\n%$$f \\otimes g \\longmapsto \\mu_A \\circ\\left(f \\otimes g\\right) \\circ \\Delta_D,$$\n%\\item we define\n%$$\\rho = \\left[a \\longmapsto \\Psi_A(\\_ \\otimes a) := \\left[d \\longmapsto \\Psi_A(d\\otimes a)\\right]\\right]\\in\\:_C\\mathcal{M}(A,\\!_C\\mathcal{M}(D,A))$$\n%via the isomorphism $_C\\mathcal{M}(D\\otimes A,A) \\stackrel{\\sim}{\\longrightarrow} _C\\mathcal{M}(A,\\!_C\\mathcal{M}(D,A))$,\n%\\item for every $C$ bialgebra/Hopf-algebra $D$ and $D$-module algebra $A$\n%$$\\rho_0 := [a \\longmapsto \\eps a := [d \\longmapsto \\eps(d) a]]$$\n%defines the trivial $D$-module algebra structure on $A$.\n%\\en\n\n\\begin{lemm}\n$\\Psi$ is a morphism of $D$-module algebra structure on $A$ if and only if $\\rho$ is morphism of $C$-algebras such that the following diagrams commute:\n$$\\bao{cc}\n\\xymatrix{\nA \\ar[rr]^{\\rho}\\ar[d]_\\rho&&\\trm{Hom}_C(D,A)\\ar[d]^{\\trm{Hom}_C(D,\\rho)}\\\\\n\\trm{Hom}_C(D,A) \\ar[rr]_{\\trm{Hom}_C(\\mu_D,A)}&&\\trm{Hom}_C(D,\\!\\trm{Hom}_C(D,A))\\\\\n}\n&\\xymatrix{\nA \\ar[r]^{\\rho}\\ar[rd]_{id_A}&\\trm{Hom}_C(D,A)\\ar[d]^{ev_{1_D}}\\\\\n&A\\\\\n}\n\\ea,$$\nidentifying $\\trm{Hom}_C(D \\otimes D,A)$ and $\\trm{Hom}_C(D,\\!\\trm{Hom}_C(D,A))$.\n\\end{lemm}\n\\bmk A short proof is given in \\cite{Heid10}, pg. 35. Nevertheless, we shall remark on some aspects of the notation:\n\\bn\n\\item the morphism $\\trm{Hom}_C(\\mu_D,A)$ is equivalent to the just defined $\\rho_{\\trm{int}}$.\n\\item the morphism $\\trm{Hom}_C(D,\\rho)$ denotes:\n$$\\bao{rcl}\nD^* \\otimes A &\\longrightarrow& D^* \\otimes \\trm{Hom}(D,A)\\\\\n&&\\\\\n\\delta \\otimes a &\\longmapsto& \\delta \\otimes \\Psi(\\_\\otimes a) = \\delta \\otimes \\rho(a)\\\\\n\\ea$$\n\\en\n%In both cases, we are restricting to the submodule of $D$-module algebra morphisms in $\\trm{Hom}(D,A)$ and $\\trm{Hom}(D,\\trm{Hom}(D,A))$, respectively.\nIn \\cite{Heid13} it is shown that if $D \\simeq D_{der}$ and $\\qz \\subset A$, then $\\trm{Hom}_C(D,A)$ is isomorphic to $A[[t]]$ and $\\rho$ is given by the universal Taylor homomorphism.\n\\begin{prop}\\label{GroupLaw}\nLet $F$ be an $n$-dimensional group law over some commutative ring $C$. The associated group functor $\\mathfrak{F}$ is isomorphic to the Lie-Ritt functor $Z(I) \\subset \\Gamma(C,n)$ with $n$-variate higher differential ideal\n$$I := \\left<\\theta^{(\\alpha)}(F(w,\\Psi(Y))) : \\alpha \\in \\nz_0^n\\bsl\\{0\\}\\right>_{C[[w]]\\{C[[Y]]\\}},$$\nwhere $\\Psi \\in C[[y]]^n$ such that $\\Psi(0) = 0, F(\\Psi(u),u) = 0$ for all $u \\in C[[y]]^n$.\n\\end{prop}\n\\bmk Notion of formal group laws and formal groups is given in the appendix. A prove as well as the proposition can be found in \\cite{Heid10}, pg. 97.\n\\bsp \\label{example_Heid_add_mul_grp_law}%Let $n \\in \\nz$ and $\\mathcal{F}$ be a family of differential polynomials over some differential field $(k,\\partial)$, in particular explicit differential equations. Our Picard-Vessiot extension $k(x)$ is of the $\\partial x_i = p_i(x_1,\\ldots,x_n)$. Fix $K = k(x)$ and $A = K[\\eps] \\simeq K[X]/\\left<X^2\\right>$ (i.e. the dual numbers of $K$). We know that $\\Gamma(A,n) = \\{\\Phi \\in A[[w]]^n : \\Phi \\equiv w \\mod N(A)^n\\}$. Hence\n%$$\\Gamma(A,n) := \\left\\{\\left(\\sum_{\\alpha \\in \\nz_0^n} a_{i,\\alpha} w^\\alpha\\right)_{i=1}^n : a_{i,e_j} \\equiv 1 \\mod N(A) \\wedge a_{i,\\alpha} \\equiv 0 \\mod N(A) \\forall \\alpha \\neq e_j,\\ 1\\leq i, j \\leq n\\right\\}.$$\nHeiderich shows in case of the $\\zz$-algebra $\\zz[[w]]\\{\\zz[[Y]]\\}_\\theta$ and $n = 1$ that the functor induced by the subset $\\{a + w: a \\in N(A)\\}$ of $\\Gamma(A,1)$ is isomorphic to the additive group scheme $\\mathbb{G}_a$ for every $\\zz$-algebra $A$. The associated ideal in $\\zz[[w]]\\{\\zz[[Y]]\\}$ is generated by $Y^{(1)} - 1$ and $Y^{(j)}$ for all $j \\geq 2$. The subset $\\{(1 + a) w : a \\in N(A)\\}$ is isomorphic to the multiplicative group scheme $\\mathbb{G}_m$. The associated ideal is generated by $w Y^{(1)} - Y$ and $Y^{(j)}$ for all $j \\geq 2$.% Extending his approach we construct the following sets:\n%$$\\bao{rcl}\n%G_1(A) &:=& \\left\\{w + a_i e_i \\in A[[w]]^n: a_i \\in N(A), 1 \\leq i \\leq n\\right\\}\\\\\n%&&\\\\\n%G_2(A) &:=& \\left\\{w + b_i w_i e_i \\in A[[w]]^n : b_i \\in N(A), 1 \\leq i \\leq n\\right\\}\\\\\n%\\ea$$\n%Here we use $w = \\sum_{i=1}^n w_i e_i \\in A[[w]]$.% Next we have to compute the ideal $I$ in $K[[w]]\\{K[[Y]]\\}$ such that $F\\mid_{Y=\\Phi} = 0$ for all $F \\in I$ and $\\Phi \\in G_i(A)$ with $i = 1,2$.\n\\begin{satz}\nThe Umemura functor $\\trm{Ume}$ is a Lie-Ritt functor.\n\\end{satz}\n\\bws This is a consequence of theorem 2.14 (summarized in corollary 2.15) in \\cite{Heid10} and \\cite{Heid11}.\n\\begin{koro}\n$\\trm{Ume}(K/k)$ is a formal group scheme.\n\\end{koro}\n\\subsection{PV-theory of Artinian simple module algebras}\nHere, $(k,\\partial)$ is again a differential field (more general a simple artinian $D$-module algebra) - with $\\trm{char} k = 0$ and let $R$ be the PV-ring over $k$. For clarity, we are going to repeat some of the previous constructs, though we will adhere to the notation introduced in \\cite{Heid10}. For $\\partial : k \\longrightarrow k$ we define\n$$D := k[\\partial]\\ \\trm{and}\\ \\Psi : D \\otimes A \\longrightarrow A, d \\otimes a \\longmapsto d(a)$$\nfor all $A \\in \\trm{CAlg}_k$, as derivation bialgebra over $k$ and $\\Psi$ the $D$-module algebra structure morphism. Recall there is a unique morphism $\\rho \\in \\trm{Hom}_C(A,\\:\\trm{Hom}_C(D,A))$, with\n$$\\rho = \\left[a \\longmapsto \\left[d \\longmapsto \\Psi(d \\otimes a)\\right]\\right].$$\nIn addition, the differential subalgebra $A^\\rho$ is defined as $A^\\Psi$ (i.e. the constant differential subalgebra).\n\\begin{defi}\nLet $(K, \\partial_K)/(k,\\partial)$ be a differential extension. We call $K/k$ a PV extension if the following statements hold:\n\\bn\n\\item $K^{\\rho_K} = k^{\\rho}$,\n\\item there is a differential subalgebra $k \\subset R \\subset K$, with $R^{\\rho_R} = k^\\rho$ such that $Q(R) = K$ and a $k^\\rho$-subalgebra:\n$$H := (R \\otimes_k R)^{\\rho_R \\otimes \\rho_R},$$\nand $H$ generates $R\\otimes_k R$ as a left/right $R$-algebra.\n\\en\n\\end{defi}\n\\bmk \\label{HeidRemk} In \\cite{Heid10} it is shown that $R$ is unique and the map $R \\otimes_{k^\\rho} H \\longrightarrow R \\otimes_k R$ is an isomorphism of $D$-module algebras. Since we only restrict to derivation module algebras (Heidereich uses a general bialgebra) we want to elaborate on some of the constructs before proceeding.\n\\bn\n\\item instead of $R = k[x_{i,j},1/\\det X]$, where $X \\in  \\trm{Gl}_n(R)$ is the fundamental solution, we use $k[X,X^{-1}]$. But clearly, both $k$-algebras define isomorphic rings (as the inverse matrix $X^{-1}$ is composed of entries in $k[x_{ij}]$ and has the inverse of $\\det X$ as factor).\n\\item The subalgebra $H$ is called the Hopf-algebra of $K/k$ and $R$ is called prinicpal $D$-module algebra of $K/k$.\n\\item The Galois group $\\trm{DGal}(K/k) := \\trm{Spec}(H)$.\n\\item In addition we have $H \\simeq k^\\rho[(X\\otimes1)(1 \\otimes X^{-1}),(1\\otimes X)(X^{-1} \\otimes 1)]$. Nevertheless, we will not use this.\n\\en\n\\begin{prop}\\label{prop_hopf_struct}\nThe differential subalgebra $H \\subset R\\otimes_k R$ carries an $R$-coalgebra structure given by the coalgebra structure on $R\\otimes R$:\n\\bn\n\\item $\\Delta_{R\\otimes R} : R\\otimes_k R \\longrightarrow (R\\otimes_k R) \\otimes_R (R\\otimes_k R)$, $a \\otimes b \\longmapsto a \\otimes 1 \\otimes 1 \\otimes b$,\n\\item $\\eps : R\\otimes_k R \\longrightarrow R$, $a \\otimes b \\longmapsto a b$ and lastly\n\\item $S: R \\otimes_k R \\longrightarrow R \\otimes_k R$, $a \\otimes b \\longmapsto b \\otimes a$ an antipode\n\\en\nmaking $R\\otimes R$ and its subalgebra $H$ a Hopf-algebra.\n\\end{prop}\n\\subsubsection{Comparing general theory with PV theory}\nWe assume as in \\cite{Heid13} $(K/k, R, H)$ to be an finitely generated PV extension of an artinian $D$-module algebras with $D = D^1 \\# k.G$ for some pointed irreducible cocommutative bialgebra of Birkhoff-Witt type (cofree), $R$ the principle $D$-module algebra and $H$ its associate Hopf algebra. Furthermore, let $X \\in \\trm{Gl}_n(R)$ be the fundamental matrix, i.e. $R \\simeq k[X,X^{-1}]$, for each (minimal) prime ideal $\\mathfrak{p}) \\subset K$ the field $K/\\mathfrak{p}$ be finitely generated and separable over $k/(k \\cap \\mathfrak{p}$ and the transcendence degree $n$ for $K/k$ agree for all $\\mathfrak{p} \\in \\trm{Spec}(K)$. We have a unique $n$-variate iterative derivation\n$$\\theta_x : K \\longrightarrow K[[w]],\\ x_i \\longmapsto x_i + w_i$$\nand two $D$-module algebra homomrphisms:\n$$\\rho = [a \\longmapsto ev_a = [d \\longmapsto \\Psi(d \\otimes a)]] \\in \\trm{Hom}(K, \\trm{Hom}(D, K))$$\n$$\\rho_0 = [a \\longmapsto a \\cdot \\eps_D = [d \\longmapsto \\eps_D(d) a]] \\in \\trm{Hom}(K, \\trm{Hom}(D,K)).$$\n\\begin{defi}\nWe denote with $D_{\\trm{der}}$ the derivation bialgebra $k[\\partial] \\subset \\trm{End}_{k^\\partial}(k)$, with\n$D_{\\trm{ID}}$ the iterative derivation bialgebra $k[\\theta]$ for some iterative derivation $\\theta : k \\longrightarrow k[[t]]$ and with $D_{\\trm{ID}^n}$ the $n$-variate iterative derivation bialgebra.\n\\end{defi}\nIn \\cite{Heid13} it is noted that $D_{\\trm{der}} \\simeq D_{\\trm{ID}}$, $D_{\\trm{ID}}^{\\otimes n} \\simeq D_{\\trm{ID}^n}$ and $\\trm{Hom}(D_{\\trm{der}},A) \\simeq A[[t]]$ and $\\trm{Hom}(D_{ID}^{\\otimes n}, A) \\simeq A[[w]]$ with $w = (w_1,\\ldots,w_n)$ for all commutative algebras $A$ and $\\trm{char}k = 0$. Therefore, $\\trm{Hom}(D_{\\trm{der}},K)$ is clearly closed with respect to $\\theta_x = \\sum_{\\alpha} \\frac{1}{\\alpha!}\\partial_x^\\alpha \\otimes w^\\alpha$:\n$$f = [d \\longmapsto f(d)] \\longmapsto \\theta_x(f) = \\left[d \\longmapsto \\theta_x(f(d)) = \\sum_\\alpha \\frac{1}{\\alpha!} \\partial_x^\\alpha(f(d)) \\otimes w^\\alpha\\right].$$\nWe recall that $[\\partial_x,\\partial_K] = 0$, i.e. $K$ is a partial different algebra wrt. $\\{\\partial_K = \\partial, \\partial_x\\}$. It takes a little more to show closedness for $\\rho(K)$:\n$$\\bao{rcl}\nf = ev_a &=& [d \\longmapsto \\Psi_K(d \\otimes a)]\\\\\n&&\\\\\n&\\longmapsto& \\theta_x(ev_a)\\\\\n&&\\\\\n&=& \\left[d \\longmapsto \\sum_\\alpha \\theta_x^{(\\alpha)} (ev_a(d)) \\otimes w^\\alpha = \\sum_\\alpha d\\left(\\theta^{(\\alpha)}_x(a)\\right) \\otimes w^\\alpha\\right]\\\\\n&&\\\\\n&=& \\sum_\\alpha ev_{\\theta^{(\\alpha)}_x(a)} \\otimes w^\\alpha\\\\\n\\ea$$\nFor $w \\stackrel{\\pi_w}{\\mapsto} 0$ we have identity and $\\partial_{w_i} = [w_j \\longmapsto \\delta_{i,j}]$, $\\partial_w^\\beta = \\partial_{w_1}^{\\beta_1} \\circ \\ldots \\circ \\partial_{w_l}^{\\beta_l}$ for all $\\beta \\in \\nz_0^l$ we get:\n$$\\pi(\\partial_w^\\beta(\\theta_x(f))) = \\partial_x\\beta(f).$$\n\\begin{defi}\nFor some field $k$ we call a $k$-algebra $K$ \\'{e}tal if $K \\otimes_k \\ov{k} \\simeq \\ov{k}^n$ as a vector space over the algebraic closure $\\ov{k}$ of $k$ and $n \\geq n$ an integer.\n\\end{defi}\n\\bmk An algebra $K$ over $k$ is \\'{e}tal if and only if\n$$K \\simeq \\prod_{i=1}^n k[x]/\\left<f_i\\right>,\\ f_i \\in k[x] \\trm{separable}.$$\n\\subsection{Example} Revisiting our example on \\pageref{twoD} with $\\left(k \\subseteq \\ov{\\qz}, \\partial = 0_{\\ov{\\qz}}\\right)$ and the $k$-linear differential operator $L = \\partial^2 - a \\cdot id_k \\in k[\\partial] =: D$, $a \\in k^\\times$. We are going to use the notation already introducted in \\ref{twoD}, pg. \\pageref{twoD}. Again, we are discussing two cases:\n\\bd\n\\item[reducible] The polynomial $X^2 - a \\in k[X]$ decomposes into two linear factors $X - \\sqrt{a}, X + \\sqrt{a} \\in k[X]$. In this case, we denote the PV ring with $R_1$.\n\\item[irreducible] The polynomial $X^2 - a \\in k[X]$ is irreducible - i.e. $k[X]/\\left<X^2 - a\\right>$ is a field extension over $k$. We denote the PV ring with $R_2$.\n\\ed\nWe remark that due to the \"constness\" of $a \\in k$, $R_2(\\sqrt{a)}) \\simeq k(\\sqrt{a}) \\otimes_k R_2$ gets a $D$ module algebra via\n$$\\bao{rrcl}\n\\rho_{R(\\sqrt{a})} : & k(\\sqrt{a}) \\otimes_k R_2 &\\longrightarrow &\\trm{Hom}_k(D, k(\\sqrt{a}) \\otimes R_2)\\\\\n&&&\\\\\n&\\alpha \\otimes r &\\longmapsto & \\left[d \\otimes \\alpha \\otimes r \\longmapsto \\alpha \\otimes d(r)\\right].\\\\\\ea$$\nFurthermore, our two PV rings are isomorphic via the isomorphis defined on pg. \\pageref{PVisomorph}, $R_1 \\simeq R_2(\\sqrt{a})$. As above, over Hopf algebra $D$ is $k[\\partial]$ and $\\Psi_k$ is trivial (i.e. subalgebra of $R^{\\Psi_R}$). Next, we want to describe\n\\paragraph{The prinicple $D$ module algebra}\nwhich in our case is simply $R_i$, $i = 1, 2$.\n\\subsubsection{The Hopf-algebra and its module algebra}\nFirst, we note that $D$ is a cocommutative Hopf-algebra over $k = \\currfield$, being a field, is simple (as a ring) and artinian since every descending chain of ideals stabilizes after finitely many steps ($(1)$ and $(0)$ are the only ideals). Next, we recall that $K = \\currfield(y_1)$ with $\\currfield$-derivation $\\partial = [y_1 \\longmapsto \\sqrt{a} y_1, y_{-1} \\longmapsto - \\sqrt{a} y_{-1}]$. Now, we want to show the $D$-module algebra structure on $K$, or $R = \\currfield[y_1,y_{-1}]$. Let $\\Psi_K : D \\otimes K \\longrightarrow K,  \nd \\otimes x = \\sum_i d_i \\partial^i \\otimes x \\longrightarrow \\sum_i d_i \\partial^i(x) =: d(x)$. We need to show $\\Psi_K(d_1 \\otimes \\Psi_K(d_2 \\otimes x)) = \\Psi_K(\\mu_D \\otimes id_K(d_1 \\otimes d_2 \\otimes x))$, i.e. $K$ is a $D$-left module, which is immediately clear as the LHS simply says $d_1(d_2(x))$ and the RHS says $\\mu_D(d_1 \\otimes d_2)(x) = (d_1 \\circ d_2)(x)$ being equal. Next, we want to introduce the $D$-left comodule structure on $K$. An obvious choice is $\\rho := \\eta \\otimes id_K : K \\simeq k \\otimes K \\longrightarrow k[\\partial] \\otimes K, x \\longmapsto 1_D \\otimes x$ providing the desired commutativity of the diagrams:\n$$\\bao{cc}\n\\xymatrix{\nK \\ar[r]^\\rho \\ar[d]_\\rho & D \\otimes K\\ar[d]^{id_D \\otimes \\rho}\\\\\nD \\otimes K \\ar[r]_{\\Delta_D \\otimes id_K} & D \\otimes D \\otimes K\\\\\n} &\n\\xymatrix{\nK \\ar[r]^\\rho \\ar[rd]_\\sim & D \\otimes K\\ar[d]^{\\eps \\otimes id_K}\\\\\n&K,}\\\\\n\\ea$$\nin particular, we get $\\Psi_K(\\rho(x)) = id_K(x) = x$ (i.e. $\\Psi_K$ is the left inverse of $\\rho$). To conclude, we have shown that both\n$$\\bao{cc}\n\\xymatrix{\nD \\otimes K^{\\otimes2} \\ar[d]_{\\Delta_D \\otimes id_K \\otimes id_K} \\ar[rr]^{id_D \\otimes \\mu_K}& & D \\otimes K \\ar[r]^{\\Psi_K} & K\\\\\nD^{\\otimes2} \\otimes K^{\\otimes2} \\ar[d]_{id_D \\otimes \\tau \\otimes id_K}&&&\\\\\n(D \\otimes K)^{\\otimes2} \\ar[rrr]_{\\Psi_K \\otimes \\Psi_K} & & &K \\otimes K \\ar[uu]_{\\mu_K}\\\\\n} &\n\\xymatrix{\nD \\ar[rr]^{id_D \\otimes \\eta_K} \\ar[rrd]_{\\eps \\otimes id_K}&& D \\otimes R.1_K\\ar[d]^{\\Psi_K}\\\\\n&&K\\\\\n}\\\\\n\\ea$$\ncommute. \n\\subsubsection{The Hopf-algebra of constants}\nMore precisely, $H$ is the kernel of $\\Delta_D(\\partial) : R \\otimes_k R \\longrightarrow R \\otimes_k R$. We are going to show this in a short instance. Reformulating the definition of $H$ more generally (i.e. $D = k[\\partial]$, $k^{\\Psi_k} = k^\\partial = \\currfield$ in our case):\n%$$\\bao{rclcl}\n%\\partial_R(X X^{-1}) &=& \\partial_R(1_R) &=& \\partial_R(X) X^{-1} + X \\partial_R(X^{-1})\\\\\n%&&&&\\\\\n%&=& 0&&\\\\\n%&&\\LRA&&\\\\\n%X\\partial_R(X^{-1}) &=& - \\partial(X) X^{-1} &=& -A X X^{-1}\\\\\n%&&\\LRA&&\\\\\n%\\partial_R(X^{-1}) &=& -X^{-1} A&&\\\\\n%\\ea$$\n%We get the same result for $\\partial(X^{-1} X)$. On the other hand, $X^{-1} = \\det X^{-1} \\left(\\bao{cc}a x_1 & -x_2\\\\\n%-x_2 & x_1\\\\\n%\\ea\\right)$, hence $\\partial(X^{-1}) = \\partial(\\det X^{-1}) \\left(\\bao{cc}a x_1 & -x_2\\\\\n%-x_2 & x_1\\\\\n%\\ea\\right) + \\det X^{-1} \\left(\\bao{cc}a x_2 & -a x_1\\\\\n%-a x_1 & x_2\\\\\n%\\ea\\right) \\stackrel{!}{=} X^{-1} A$ implying $\\partial(\\det X^{-1}) = -\\frac{\\partial(\\det X)}{\\det X^2} = 0$. Direct computation confirms this. Hence we see that $\\det X^{i} \\otimes \\det X^{j} \\in H$ for $i, j \\in \\{0, \\pm1\\}$. Now let us consider the two factor decompositions of $\\det X = a x_1^2 - x_2^2 = (\\pm\\sqrt{a} x_1 + x_2)(\\pm\\sqrt{a} x_1 - x_2)$ (where the roots of $a$ are always having the same sign).\n%$$\\bao{rcl}\n%\\Delta(\\partial)\\left([\\sqrt{a} x_1 + x_2] \\otimes [\\sqrt{a} x_1 - x_2]\\right) &=&\n%(1\\otimes \\partial + \\partial\\otimes 1)\\left([\\sqrt{a} x_1 + x_2] \\otimes [\\sqrt{a} x_1 - x_2]\\right)\\\\\n%&&\\\\\n%&=& (\\sqrt{a} x_1 + x_2) \\otimes \\partial(\\sqrt{a} x_1 - x_2)\\\\\n%&& + \\partial(\\sqrt{a} x_1 + x_2) \\otimes (\\sqrt{a} x_1 - x_2)\\\\\n%&&\\\\\n%&=& (\\sqrt{a} x_1 + x_2) \\otimes (\\sqrt{a} x_2 - a x_1)\\\\\n%&& + (\\sqrt{a} x_2 + a x_1) \\otimes (\\sqrt{a} x_1 - x_2)\\\\\n%&&\\\\\n%&=& 0\\\\\n%\\ea$$\n%By symmetry, this holds for $(\\sqrt{a} x_1 - x_2) \\otimes (\\sqrt{a} x_1 + x_2)$ and by Leibniz-rule for\n%$(\\det X^{-1} \\otimes \\det X^{-1}) (\\sqrt{a} x_1 \\pm x_2) \\otimes (\\sqrt{a} x_1 \\mp x_2)$. On the other hand, $\\Delta(1) = 1 \\otimes 1$ and clearly all elements fulfill\n$$H:= \\left\\{r_1 \\otimes r_2 : \\Psi_{R\\otimes R}(d \\otimes (r_1 \\otimes r_2)) = \\eps_D(d) (r_1 \\otimes r_2)\\right\\}.$$\nWith $\\eps_D(\\partial^i) = \\delta_{0,i}$ and image of $1_D$ under comultiplication being $1_D\\otimes 1_D$, we only need to compute $\\ker \\Delta_D(\\partial)$\n$$\\bao{rcl}\nH &=& (\\partial_R \\circ \\mu_R)^{-1}(0)\\\\\n&&\\\\\n&=& \\{r_1 \\otimes r_2 \\in R\\otimes_k R : \\partial_R \\circ \\mu_R (r_1 \\otimes r_2) = 0\\}\\\\\n&&\\\\\n&=& \\{r_1 \\otimes r_2 : (1 \\otimes \\partial + \\partial \\otimes 1)(r_1 \\otimes r_2) = 0\\}\\\\\n&&\\\\\n&=& (\\Delta (\\partial))^{-1}(0) = \\ker \\Delta(\\partial)\\\\\n\\ea.$$\n%As we just saw, the elements $\\alpha (\\pm \\sqrt{a} x_1 \\pm x_2) \\otimes (\\pm\\sqrt{a} x_1 \\mp x_2) \\in H$ for $\\alpha \\in \\{1 \\otimes 1, \\det X^{-1} \\otimes \\det X^{-1}\\}$. On the other hand, we get that $r_1 \\otimes r_2 \\in H\\bsl\\{0, 1\\otimes 1\\}$ if and only if $r_1\\otimes r_2 \\in \\mu_R^{-1}(\\det X)$. This is obviously the case for the above defined elements. Additionally, $a x_1 \\otimes x_1 - x_2 \\otimes x_2$ is an element in $H$ which ca be verified either by direct computation or by our reformulated definition of $H$.\\\\\nAs $\\partial(y_{\\pm 1}) = \\pm \\sqrt{a} y_{\\pm 1}$ we get:\n$$\\bao{rclcl}\n\\Delta_D(\\partial)(y_1 \\otimes y_{-1}) &=& \\sqrt{a} y_1 \\otimes y_{-1} - \\sqrt{a} y_{1} \\otimes y_{-1} &=& 0\\\\\n&&&&\\\\\n\\Delta_D(\\partial)(y_{-1} \\otimes y_{1}) &=& -\\sqrt{a} y_{-1} \\otimes y_{1} + \\sqrt{a} y_{-1} \\otimes y_{1} &=& 0\\\\\n\\ea$$\n$$H \\supset \\currfield\\left[y_1\\otimes y_{-1},y_{-1} \\otimes y_1\\right].$$\nFollowing our notation from example \\ref{twoD} on page \\pageref{twoD}, since $a x_1 \\otimes x_1 + x_2 \\otimes x_2, \\sqrt{a} (x_1 \\otimes x_2 - x_2 \\otimes x_1) \\in \\left(S(L_+)\\oplus (L_-)\\right)^{\\otimes 2}$ are the only other generating elements already contained in $\\currfield\\left[y_1\\otimes y_{-1},y_{-1} \\otimes y_1\\right]$, we get\n$$H \\subset \\currfield\\left[y_1\\otimes y_{-1},y_{-1} \\otimes y_1\\right].$$\nNext, we want to introduce the comultiplication and counit for the elements defined above as described in \\ref{prop_hopf_struct}.% Since $H$ is generated by units in $R$ (or more explicitly its tenors in $R\\otimes_k R$) we see that all generators form a group-like sub Hopf algebra in $H$, i.e. $\\Delta_H(x) = x \\otimes x, \\eps_H(x) = 1, S(x) = x^{-1}$ for some generator $x \\in H$. Hence, if $x, y \\in H$ are generators of $H$ we get\nHence, $\\Delta_H = [y_{\\pm 1} \\otimes y_{\\mp 1} \\longmapsto y_{\\pm 1} \\otimes 1 \\otimes 1 \\otimes y_{\\mp 1}], \\eps = [y_{\\pm 1} \\otimes y_{\\mp 1} \\longmapsto y_{\\pm 1} y_{\\mp 1}]$ and $S = [y_{\\pm 1} \\otimes y_{\\mp 1} \\longmapsto y_{\\mp 1} \\otimes y_{\\pm 1}]$.\n$$\\eps_H(a \\otimes b) = a b = \\frac{1}{2}\\eps_H(a \\otimes b + b \\otimes a),\\ \\eps_H(a \\otimes b - b \\otimes a) = 0,\\ \\Delta(x - y) = x\\otimes x - y \\otimes y.$$\nExpanding the coproduct:\n$$\\bao{rcl}\nx - y &=& \\underbrace{(\\sqrt{a} x_1 + x_2)}_{y_1} \\otimes \\underbrace{(\\sqrt{a} x_1 - x_2)}_{y_{-1}} - (\\sqrt{a} x_1 - x_2) \\otimes (\\sqrt{a} x_1 + x_2)\\\\\n&&\\\\\n&=& a x_1 \\otimes x_1 - \\sqrt{a} x_1 \\otimes x_2 + \\sqrt{a} x_2 \\otimes x_1 + x_2 \\otimes x_2 \\\\\n&&\\\\\n&& - a x_1 \\otimes x_1 - \\sqrt{a} x_1 \\otimes x_2 + \\sqrt{a} x_2 \\otimes x_1 - x_2 \\otimes x_2\\\\\n&&\\\\\n&=& 2 \\sqrt{a} (x_2 \\otimes x_1 - x_1 \\otimes x_2)\\\\\n\\ea$$\nWe remark that the coproduct is defined via $R^{\\otimes 2} \\otimes_R R^{\\otimes 2}$. Hence, $R$-scalars in the inner positions cancel. Its coproduct is:\n$$\\bao{rcl}\n\\Delta_H(x - y) &=& x \\otimes x - y \\otimes y\\\\\n&&\\\\\n&=& (\\sqrt{a} x_1 + x_2) \\otimes (\\sqrt{a} x_1 - x_2) \\otimes (\\sqrt{a} x_1 + x_2) \\otimes (\\sqrt{a} x_1 - x_2)\\\\\n&&\\\\\n&& - (\\sqrt{a} x_1 - x_2) \\otimes (\\sqrt{a} x_1 + x_2) \\otimes (\\sqrt{a} x_1 - x_2) \\otimes (\\sqrt{a} x_1 + x_2)\\\\\n&&\\\\\n&=& (\\sqrt{a} x_1 + x_2) \\otimes 1_H \\otimes 1_H \\otimes (\\sqrt{a} x_1 - x_2)\\\\\n&&\\\\\n&& - (\\sqrt{a} x_1 - x_2) \\otimes 1_H \\otimes 1_H \\otimes (\\sqrt{a} x_1 + x_2)\\\\\n&&\\\\\n&=& 2 \\sqrt{a} (x_2 \\otimes 1 \\otimes 1 \\otimes x_1 - x_1 \\otimes 1 \\otimes 1 \\otimes x_2)\\\\\n%&=& 2 a \\sqrt{a} x_1 \\otimes x_1 \\otimes (x_2 \\otimes x_1 - x_1 \\otimes x_2) + 2 a \\sqrt{a} (x_2 \\otimes x_1 - x_1 \\otimes x_2) \\otimes x_1 \\otimes x_1\\\\\n%&&\\\\\n%&& + 2 \\sqrt{a} x_2 \\otimes x_2 \\otimes (x_2 \\otimes x_1 - x_1 \\otimes x_2) + 2 \\sqrt{a} (x_2 \\otimes x_1 - x_1 \\otimes x_2) \\otimes x_2 \\otimes x_2\\\\\n%&&\\\\\n%&=& 2 \\sqrt{a} (x_2 \\otimes x_1 - x_1 \\otimes x_2) \\otimes (a x_1 \\otimes x_1 - x_2 \\otimes x_2)\\\\\n%&&\\\\\n%&& + 2 \\sqrt{a} (a x_1 \\otimes x_1 - x_2 \\otimes x_2) \\otimes (x_2 \\otimes x_1 - x_1 \\otimes x_2)\\\\\n%&&\\\\\n%&=& 2 \\sqrt{a} (x - y) \\otimes (a x_1 \\otimes x_1 - x_2 \\otimes x_2) + 2 \\sqrt{a} (a x_1 \\otimes x_1 - x_2 \\otimes x_2) \\otimes (x - y)\\\\\n%&&\\\\\n%&=& 2 \\sqrt{a} [(a x_1 \\otimes x_1 - x_2 \\otimes x_2),x - y]_{R\\otimes R},\\\\\n&&\\\\\n&=& y_1 \\otimes 1 \\otimes 1 \\otimes y_{-1} - y_{-1} \\otimes 1 \\otimes 1 \\otimes y_1\\\\\n\\ea$$\n%where $[.,.]_{R\\otimes R}$ denotes the Lie-bracket of $R\\otimes R$ wrt to the tensor product (not the intrinsic Lie-bracket). This is a direct proof of cocommutativity (for the sub Hopf algebra $k[x - y]$). But clearly, if all generators are cocommutative then so are their linear combinations. However, the other generators differ only in the sign of $\\sqrt{a}$ and/or in carrying a factor $\\det X^i \\otimes \\det X^j$, $i, j = 0, -1$. But this is also a group-like element implying all coproducts are of the above form (modulo sign of root and factor). \nIn particular, following prop. \\ref{GroupLikeHopfIdeal} we know the set of differences of group-like elements generates a bi-ideal in $H$. Since $H$ itself is generated by group-like elements, we get $I(\\mathcal{G}(H)) := \\left<g - h : g, h \\in \\mathcal{G}(H)\\right>$ is a proper bi-ideal in $H$. It is enough to show that $I(\\mathcal{G}(H))$ is stable under antipode action:\n$$S : H \\otimes H \\longrightarrow H,\\ y_{\\pm 1}^i \\otimes y_{\\mp 1}^j \\longmapsto y_{\\pm}^{-i} \\otimes y_{\\mp}^{-j}, i, j \\in \\zz.$$\nBut $S$ maps the generators of $I(\\mathcal{G}(H))$ to its generators:\n$$y_1 \\otimes y_{-1} \\longmapsto y_{-1} \\otimes y_1,\\ y_{-1} \\otimes y_1 \\longmapsto y_1 \\otimes y_{-1},$$\nimplying\n$$S(g) \\in I(\\mathcal{G}(H)), \\forall g \\in \\mathcal{G}(H).$$\nSummarizing, we get:\n%This shows that the coalgebra $I$ generated by $x - y$, where $x = y_1 \\otimes y_{-1}, y = \\tau_{R\\otimes R}(x) \\in H$, is a sub coalgebra of $\\ker \\eps$. Next, we have to show %indeed a (two-sided) coideal $I$ in $H$.\n%$$\\Delta(I) \\subset H \\otimes I + I \\otimes H\\ \\wedge\\ I \\subset \\ker \\eps.$$\n%But clearly:\n%$$\\bao{rcl}\n%\\Delta_H(x-y) &=& \\frac{1}{2} \\underbrace{(y_1 \\otimes y_{-1} - y_{-1} \\otimes y_1)}_{\\in I} \\otimes_R \\underbrace{(y_1 \\otimes y_{-1} + y_{-1} \\otimes y_1)}_{\\in H}\\\\\n%&&\\\\\n%&& + \\frac{1}{2} \\underbrace{(y_1 \\otimes y_{-1} + y_{-1} \\otimes y_1)}_{\\in H} \\otimes_R \\underbrace{(y_1 \\otimes y_{-1} - y_{-1} \\otimes y_1)}_{\\in I},\\\\\n%\\ea$$\n%showing skew-primitivity and subsequently, our claim. The ideal property simply follows from the fact that $\\eps$ is an algebra homomorphism. To summarize:\n$$\\bao{ccc}\nH &=& \\currfield[y_1 \\otimes y_{-1},y_{-1} \\otimes y_1]\\\\\n&&\\\\\nI &=& H.(y_1 \\otimes y_{-1} - y_{-1} \\otimes y_1) \\ \\trm{Hopf-ideal}\\\\\n\\ea$$\nWe have already shown, that our differential equation $L(x) = 0$ decomposes into two factors. This was used in our last computations. However, in case $L$ does not decompose the primary computations (PV-ring is $R = k[x_1,x_2,1/(a x_1^2 - x_2^2)]$, etc.) are still valid. Only our Hopf-algebra $H$ is generated by different elements.\n%\n%We remark that both $R = \\currfield[y_1,y_{-1}]$ and $H = \\currfield[y_1\\otimes y_{-1},y_{-1}\\otimes y_1]$ do not have any $D = \\currfield[\\partial]$-stable ideals:\n%\\bd\n%\\item[Case $R$] Let $I \\subset R$ be an ideal and we assume differential closedness - i.e. $\\partial(I) \\subset I$.\n%%As a noetherian $R$-submodule of a noetherian module $R$ (generated by $y_{\\pm 1}$ over $\\currfield$), $I$ is finitely generated. Hence, let $S:= \\{s\\} \\subset I$ be one generating set. By differential closedness, we get for any $s \\in S$:\n%%$$\\partial(s) = \\partial\\left(\\sum_{i=-m}^n s_i y_1^i\\right) = \\sum_{i=-m}^n s_i \\partial(y_1^i) = \\sum_{i=-m}^n i \\sqrt{a} s_i y_1^i \\in I$$\n%%$$\\LRA \\partial(s) - s = \\sum_{i=-m}^n (i \\sqrt{a} - 1) s_i y_1^i \\in I$$\n%%But both, $s, \\partial(s) - s$ are of degree $n$, or $m$ wrt. $y_{\\pm 1}$ and $y_1^m (\\partial(s) - s) \\in \\currfield[y_1]$.\n %There is an $I' \\subset \\currfield[y_1]$, such that $S_{y_1}^{-1}(I') \\subset I$. By definition of $I$, we get\n%$$y_1^m t \\in I' \\RA \\partial(y_1^m t) = \\underbrace{m \\sqrt{a} y_1^m t}_{\\in I'} + \\underbrace{y_1^m \\partial(t)}_{\\in \\partial(I')},$$\n%but identifying $I' := I \\cap \\frac{\\currfield[y_1]}{1}$ we get $\\partial(I') \\subset I'$. Being a PID, $\\currfield[y_1]$ all $I'$ are of the form $\\left<s\\right>$. On the other hand, $\\partial$ operates on all weight spaces $\\currfield.y_1^i$, $i \\geq 1$, invariantly:\n%$$\\bao{rrcl}\n%\\partial_i := \\partial\\mid_{\\currfield.y_1^i} : &\\currfield.y_1^i &\\longrightarrow& \\currfield.y_1^i\\\\\n%&&&\\\\\n%&y_1^i &\\longmapsto&i \\sqrt{a} y_1^i\\\\\n%\\ea$$\n%Hence, the degree of all polynomials in $\\partial(I')$ and the preimages in $I'$ do agree. Each derivative of the generators $s$ agree in degree but also reduce to zero modulo $\\left<s\\right>$ contradicting our claim $\\partial(s) \\in \\left<s\\right>$. Thus, all $D$-stable ideals in $R$ are indeed trivial.\n%\\item[Case $H$] Exactly as the case above, since $H \\simeq \\currfield[y_1,y_{-1}]$.\n%\\ed\n%\n%i.e. both are simple $D$-module algebras over $\\currfield$.\n\\paragraph{Isomorphism}\nWe claim, that $(H, \\Psi_H) \\simeq (R, \\Psi_0)$ as $D$-module algebras and $\\currfield$-Hopf algebras,\n where\n$$\\Psi_0 = [d \\otimes r \\longmapsto \\eps_D(d) r].$$\n\\bws Consider the map \n$$\\bao{rrcl}\n\\varphi : &R &\\longrightarrow &H\\\\\n&y_1^i&\\longmapsto&y_1^i \\otimes y_{-1}^i\\\\\n&y_{-1}^i&\\longmapsto&y_{-1}^i \\otimes y_1^i,\\\\\n\\ea$$\ndefining an $\\currfield$-algebra homomorphism. We remark that $R$ has group-like generators $1, y_1, y_{-1}$ which are antipode-stable. Consequently, $\\varphi$ does commute:\n$$(\\varphi \\otimes \\varphi) \\Delta_R = \\Delta_H \\varphi,\\ S_H \\varphi = \\varphi S_R,\\ \\eps_H = \\eps_R \\varphi.$$\nThus, it is enough to show that $\\varphi$ is a bijection. As $1_R \\longmapsto 1_R \\otimes 1_R$ $\\varphi$ is a monomorphism. And clearly, $\\sum_{i=-m}^n \\lambda_i y_1^i \\in \\varphi^{-1}\\left(\\sum_{i=-m}^n \\lambda_i y_{1}^i \\otimes y_{-1}^i\\right)$, making $\\varphi$ surjective. Therefore, $\\trm{Spec}(R) \\simeq \\trm{Spec}(H)$. Consequently, we have that\n$$\\trm{Spec}(H) \\simeq \\trm{Spec}(\\currfield[y_1]) \\bsl \\left\\{\\left<y_1\\right>\\right\\} = \\left\\{\\left<y_1 - a\\right> : a \\in \\currfield^\\times\\right\\} \\cup \\{0\\}.$$\nRecalling the definition of $H = \\ker \\Delta_D(\\partial)$ clearly shows the first part. The set of maximal ideals $\\max(R)$ forms indeed a group:\n$$X := \\max(R) = \\trm{Spec}(R) \\bsl \\{0\\} = \\left\\{\\left<y_1 - a\\right> : a \\in \\currfield^\\times\\right\\} \\simeq \\currfield^\\times,$$\nas claimed in remark  \\ref{HeidRemk} if we consider the following map:\n$$\\bao{rrcl}\nm : &X \\times X &\\longrightarrow& X,\\\\\n&&&\\\\\n& \\left(\\left<y_1 - a\\right>,\\left<y_1 - b\\right>\\right) &\\longmapsto& \\left<y_1 - a b\\right>.\\\\\n\\ea$$\nLastly, we recall the example \\ref{example_Heid_add_mul_grp_law} on pg. \\pageref{example_Heid_add_mul_grp_law}, second part. Analogously to the example of Heiderich, we have for any $A \\in \\trm{CAlg}_{\\currfield(y_1)}$,\n$$\\mathbb{G}_\\cdot := \\{ \\varphi = [\\lambda_0 + \\lambda_1 w \\longmapsto \\lambda_0 + \\lambda_1 (1 + a) w] : a \\in N(A)\\}$$\ndefines the group functor - assigning to each $A$ the subgroup of all automorphisms its group of infinitesimal transformation group $\\Gamma(1,A)$.% We fix one $n \\geq 2$ and set $A = \\currfield(y_1)[\\eps_n] \\simeq \\currfield(y_1)[X]/\\left<X^n\\right>$. Therefore,\n%$$N(A) = \\bigoplus_{i=1}^{n-1} \\currfield(y_1).\\eps_n^i$$\n%and $\\Gamma(1,\\currfield(y_1)[\\eps_n]) = \\{w \\mapsto w (1 + a) : a \\in N(\\currfield(y_1)[\\eps_n])\\}$.\n%Next, we shall compute the algebras $\\kappa$ and $\\mathcal{K}$, or $\\kappa \\otimes A[[w]]$ and $\\mathcal{K} \\otimes A[[w]]$ respectively, for $A = K[\\eps] \\simeq K[X]/\\left<X^2\\right>$ and the univeral Taylor-morphism $\\iota : K \\longrightarrow K[[t]]$ and Umemura morphism $\\theta_x : K \\longrightarrow K[[w]]$\n%$$\\bao{rcl}\n%\\trm{im} \\iota &=& \\left\\{\\sum_{i \\geq 0} \\frac{1}{i!} \\partial^i (a) t^i : a \\in K\\right\\}\\\\\n%&&\\\\\n%&=& \\left\\{\\sum_{i \\geq 0} \\frac{1}{i!} \\partial^i \\left(\\frac{f}{g}\\right) t^i : f, g \\in \\ov{\\qz}[x_1,x_2], g \\neq 0\\right\\}\\\\\n%&&\\\\\n%\\trm{im} \\iota\\mid_k &:=& \\left\\{\\sum_{i \\geq 0} \\frac{\\partial^i(a)}{i!} t^i : a \\in \\ov{\\qz}\\right\\}\\\\\n%&&\\\\\n%&=& \\ov{\\qz}\\\\\n%&&\\\\\n%\\trm{im} \\theta_x &=& \\left\\{\\sum_{\\alpha \\in \\nz_0^2} \\frac{1}{\\alpha!} \\partial_x^\\alpha(a) w^\\alpha : a \\in \\ov{\\qz}(x_1,x_2)\\right\\}\\\\\n%&&\\\\\n%\\ea$$\n%Hence, $\\kappa = K$ and $\\mathcal{K} = \\left<\\partial_x^\\alpha(\\iota(a)), b : a, b \\in \\ov{\\qz}(x_1,x_2)\\right>$. The extension $\\theta_x[[t]] : K[[t]] \\longrightarrow K[[t]] \\otimes_K K[[w]]$ yields\n%$$\\bao{rcl}\n%\\trm{im} \\theta_x[[t]]\\mid_\\kappa &=& \\left\\{\\sum_{\\alpha \\in \\nz_0^2} \\frac{1}{\\alpha!} \\partial_x^\\alpha(a) w^\\alpha : a \\in \\ov{\\qz}(x_1,x_2)\\right\\}\\\\\n%&&\\\\\n%\\trm{im} \\theta_x[[t]]\\mid_{\\mathcal{K}} &=& \\left\\{\\sum_{\\alpha \\in \\nz_0^2} \\frac{1}{\\alpha!} \\partial_x^\\alpha(a) w^\\alpha : a \\in \\mathcal{K}\\right\\}\\\\\n%&&\\\\\n%&=& \\left\\{\\sum_{(i,\\alpha) \\in \\nz_0^3} \\frac{1}{\\alpha! i!} \\partial_x^\\alpha(\\partial^i(a)) t^i \\otimes w^\\alpha : a \\in \\ov{\\qz}(x_1,x_2)\\right\\}\\\\\n%\\ea$$\n%Furthermore, let $\\Phi = (\\phi_i)_{i=1}^2 \\in A[[w]]^2$ with $\\phi_i \\equiv w_i \\mod N(A)[[w]] \\simeq \\left<1_{K[[t]]} \\otimes \\eps \\right>$, i.e. $\\Phi \\in \\Gamma(K[\\eps],2)$. That means $\\phi_i = \\sum_\\alpha a_{i,\\alpha} w^\\alpha \\in \\Gamma(K[\\eps],2) \\LRA a_{i,\\alpha} \\equiv 0 \\mod N(A)$ for all $\\alpha \\neq e_i$ and $a_{i,e_i} \\equiv 1 \\mod N(A)$ and $1 \\leq i \\leq 2$:\n%\\commt{This is some stupid shit...}\n\\paragraph{General constructs from Umemura and Heiderich}\nNext, we want to construt the differential subalgebras $\\kappa$ and $\\mathcal{K}$ in $K[[t]]$. As $k = \\currfield$ we get that\n$$\\kappa := \\currfield(y)\\{\\iota(\\currfield)\\}_{\\partial_y} = \\currfield(y).$$\nThis is obvious, as $\\partial^i(\\currfield) = \\{0\\}$ for all $i \\geq 1$. We want to show that our PV-ring $R = \\currfield[y,y^{-1}]$ is a differential subalgebra in the differential ring $(\\currfield[[t]], \\partial_t := \\frac{d}{d t})$.\n$$\\bao{rcl}\ny &=& \\sum_{i \\geq 0} y_i t^i,\\ y_i \\in \\currfield\\\\\n\\partial(y) &=& \\partial_t(y)\\\\\n&=&\\sum_{i \\geq 0} (i + 1) y_{i + 1} t^{i} = \\sqrt{a} y = \\sqrt{a} \\sum_{i\\geq 0} y_i t^i\\\\\n&\\LRA&\\\\\ny_{i} &=& \\sqrt{a}\\frac{y_{i-1}}{i}, \\forall i \\geq 1\\\\\n&=& \\sqrt{a}^i \\frac{y_0}{i!}\\\\\n\\ea$$\nHence, we get that $y = \\sum_{i \\geq 0} \\frac{(\\sqrt{a} y_0 t)^i}{i!}$. Since $\\partial_t(y) = \\sqrt{a} y_0 y$, we have $y_0 = 1$ or in short:\n$$y = \\exp(\\sqrt{a} t),$$\nwith $\\exp$ as defined in Analysis. The inverse $y^{-1}$ is easily compute in the same fashion. Computing the image of $y$ under $\\iota$:\n$$\n\\iota(y) = \\sum_{i \\geq 0} \\frac{\\partial^i(y)}{i!} t^i = \\sum_{i \\geq 0} \\sqrt{a}^i \\frac{y}{i!} t^i\n= y \\exp(\\sqrt{a} t),$$\nand applying the iterative derivation \n$\\theta_y(x) = \\sum_{\\alpha \\in \\nz_0^n} \\frac{\\partial_y^\\alpha(x)}{\\alpha!} w^\\alpha$ to $\\iota(y)$, we yield\n$$\\theta_y(\\iota(y)) = \\theta_y(y \\exp(\\sqrt{a}t )) = \\sum_{\\alpha \\in \\nz_0^1} \\frac{\\partial_y^\\alpha(y \\exp(\\sqrt{a}t ))}{\\alpha!} w^\\alpha = y \\exp(\\sqrt{a}t ) + w \\exp(\\sqrt{a}t ) = (y + w)\\exp(\\sqrt{a}t ).$$\nUmemura calls this the generalized solution of our differential equation in $\\currfield(y)[[w]][[t]][t^{-1}]$ (\\cite{Ume96b}, exp. 3.4.2). Now, let us pick $A = \\currfield(y)[\\eps] = \\currfield(y)[X]/\\left<X^2\\right>$ then $$\\trm{Ume}(\\currfield(y)/\\currfield)(A) = \\{\\phi \\in \\Gamma_{1 A} : \\phi \\equiv w \\mod N(A)[[w]]\\}$$\nTherefore, $N(A)$ is $\\currfield(y).\\eps$ and we get either of the two possible (affine group) schemes $\\mathbb{G}_a$ and $\\mathbb{G}_m$ as $A$ point of $\\trm{Ume}(\\currfield(y)/\\currfield)$ as described by Heiderich. Checking both:\n$$\\bao{rcl}\n\\varphi_a &=& [(y + w) \\exp (\\sqrt{a} t) \\longmapsto (y + w + a) \\exp (\\sqrt{a} t)] \\in \\mathbb{G}_a,\\ a \\in \\currfield(y).\\eps\\\\\n&&\\\\\n\\varphi_m &=& [(y + w) \\exp (\\sqrt{a} t) \\longmapsto (y + w (1 + a)) \\exp (\\sqrt{a} t)] \\in \\mathbb{G}_m,\\ a \\in \\currfield(y).\\eps\n\\ea$$\nHowever, as $w \\longmapsto 0$ does not commute with the first type of $\\currfield(y)$ automorphisms we get that clearly the multiplicative group scheme is the $A$ point.\n\\paragraph{Conclusion}\nIn stead of working in the algebraic closure $\\currfield$, we could have just as easily worked in $\\qz$ and $\\qz(\\sqrt{a})$. The only difference would be the prime ideals in the PV ring $R$ or $R(\\sqrt{a}) \\simeq \\qz \\otimes_\\qz R$, respectively. Both cases would rely on the fact where the polynomial $X^2 - a \\in k[X]$ is irreducible over $k$. In the first case $\\sqrt{a} \\notin k$, we get a two-dimensional $k$ solution space, in the latter a one-dimensional solutions space.", "meta": {"hexsha": "0c41689c8aeb5f80a5e65485a9e4e5ac25b38b62", "size": 56007, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Script_Diff_Gal07/DModules.tex", "max_stars_repo_name": "gmuel/texlib", "max_stars_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Script_Diff_Gal07/DModules.tex", "max_issues_repo_name": "gmuel/texlib", "max_issues_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Script_Diff_Gal07/DModules.tex", "max_forks_repo_name": "gmuel/texlib", "max_forks_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.238317757, "max_line_length": 797, "alphanum_fraction": 0.6467227311, "num_tokens": 21926, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6406358479787609, "lm_q1q2_score": 0.42628584905533123}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{comment}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{0.5em}\n\n\\title{Block Two: The Information Layer}\n\\author{Yangtao Ge}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\section{Chapter 2: Binary Value and Number System}\n\\begin{abstract}\nThis chapter describes binary values -- the way in which computer \\textbf{hardware} represents and manages information.\nIt also puts the binary value in all number system.\n\\end{abstract}\n\n\\subsection{Number and  Computing}\nSome definitions of Numbers:\n\\begin{itemize}\n    \\item Number: A unit of an abstract mathematical system subject to \\underline{the laws of arithmetic} (succession, addition and multiplication).\n    \\item Natural number: The number \\textbf{0} and any number obtained by \\underline{reaptedly adding to 1} to 1.\n    \\item Negative number: A value less than zero and with a sign oppsite to its \\textbf{positive counterpart}\n    \\item Rational number: An integer or the \\underline{quotient} of two integers (division by zero included)\n\\end{itemize}\n\n\\subsection{Positional Notation}\nSome definitions of Base:\n\\begin{itemize}\n    \\item Base: The foundational value of a number system, which dictates \\textbf{number digits} and the \\textbf{value of digit Position}\n    \\item Positional notation: A way of expressing number in different base system in a following way:\n    \\begin{equation}\n        d_n * R^{n-1} + d_{n-1} * R^{n-2} + ... + d_2 * R + d_1\n    \\end{equation}\n    where \\textbf{Base-R} has \\textit{n} digits and $d_i$ represents\n    the digit in the \\textit{i}th position\n\\end{itemize}\n\nWatch out the digit in a number. e.g. 2074 does not have base \\textbf{less than Base-8}\nbecause digit 7 is used here.\n\n\\textbf{2 digits} is needed to represent the base value. e.g. 10 is \\underline{ten} in decimal.\n10 is \\underline{eight} in base 8. 10 is \\underline{two} in binary.\n\nCarry and borrow system is also applied to other base system. However, the value represented binary\nthese carries and borrows means the \\textbf{value of the base}.\n\nAll power of 2 number system can be transfered to \\textbf{binary}, then to \\textbf{decimal}.\nExamples are as follows:\n\\begin{center}\n\\underline{count every 4 digits for Hex}\n\n1010110 = 101(5) \\& 0110(6)  \n\n\\underline{count every three digits for Oct}\n\n101010111100 = 101(5) \\& 010(2) \\& 111(7) \\& 100(4)\n\\end{center}\n\nAlgorithm for Base 10 to Other Bases is as follows:\n\\begin{lstlisting}\n    WHILE (the quotient is not zero):\n        Divide the decimal number by the new base\n        Make the reminder the next digit to the left in the answer\n        Replace the decimal number with the quotient\n\\end{lstlisting}    \nThis algorithm shows that:\n\\begin{itemize}\n    \\item The production of new number is \\textbf{from right to left}    \n    \\item Quotient is repeatedly used, reminder is the \\textbf{answer}\n\\end{itemize}\n\nsome definitions about bit:\n\\begin{itemize}\n    \\item binary digit: A digit in the \\textbf{binary number} system\n    \\item bit: Binary digit\n    \\item byte: \\textbf{Eight} binary digits\n    \\item word: A group of one or more \\underline{bytes} \\newline\n    \\emph{the number of bits in a word = word length of the computer}\n\\end{itemize}\n\n\\section{Chapter 3: Data Representation}\n\\begin{abstract}\nThis chapter includes how to store a certain type of information and represent in a computer environment\n\\end{abstract}\n\n\\subsection{Data and Computers}\nSome definitions related to data:\n\\begin{itemize}\n    \\item Data: basic value and facts\n    \\item Information: Organized data and can provide \\textbf{useful solutions} to problems\n    \\item Multimeadia: Sevral different media types i.e. Numbers, Text, Audio, images and etc.\n    \\item Bandwidth: The number of bits or bytes that can be transmitted from one place to \n    another \\underline{within a fixed time}\n    \\item Data compression: shrink the size of the data\n    \\item Compression ratio:\n    \\begin{equation}\n        Ratio = \\frac{Compressed\\ Size}{Original\\ Size}\n    \\end{equation}\n    $0 < Ratio < 1$, closer to zero $\\rightarrow$ tighter the compression\n    \\item Lossless: \\underline{Without any Loss} in the process of compaction\n    \\item Lossy: \\underline{Is lost} in the process of compaction\n\\end{itemize}\n\nReal world is \\textbf{infinite}, but computer is \\textbf{finite}\n\nSome definitions about types of data:\n\\begin{itemize}\n    \\item Analog data: A \\textbf{continuous} representation of data\n    e.g. mercury thermometer (\\underline{smooth wave})\n    \\item Digital data: A \\textbf{discrete} representation of data\n    e.g. button (\\underline{square wave})\n\\end{itemize}\n\nIn computer:\n\\begin{itemize}\n    \\item Analog Data $\\xrightarrow{\\text{digitize}}$ Digital Data \n    \\item use \\textbf{binary} system to represent them     \n\\end{itemize}\n\nDegraded: Electronic signals degrades as they move down a line (\\textbf{Threshold})\n\nSome definitions about Digital signals:\n\\begin{itemize}\n    \\item Pulse-Code Modulation (PCM): Variation in a signal that jumps sharply between two \\textbf{extremes}\n    \\item Reclocked: The act of reasserting an original digital signal before \\textbf{too much degreadation occurs}\n\\end{itemize}\n\n\\underline{Analog vs Digital:} (need review)\n\\begin{itemize}\n    \\item[\\textbf{Analog}] degrades $\\rightarrow$ in-range value $\\rightarrow$ valid $\\rightarrow$ information lost\n    \\item[\\textbf{Digital}] degrades $\\rightarrow$ PCM $\\rightarrow$ high to low $\\rightarrow$ reclocked $\\rightarrow$ information saved  \n\\end{itemize}\n\n\\emph{n} bits can represent $2^{n}$ things.\\newline\nIncrease the number of bits by 1 $\\Rightarrow$ \\textbf{double} the number of things we can represent\n\n\\subsection{Representing Numeric Data}\n\\subsubsection{Negative Values}\n\\underline{The work flow is:}\\newline\nSign-Magnitude Representation $\\rightarrow$ Fixed-sized Numbers $\\rightarrow$ Two's Complement\n\n\\begin{itemize}\n    \\item Sign-Magnitude Representation: ``value + sign'' \\newline\n    Problem: Will have \\textbf{two} representation of 0 (+0 \\& -0)\n    \\item Fixed-sized Numbers: use half of the integers to represent negatives \\newline\n    Method: Add the number together and \\textbf{dicard} any carries\n    \\begin{equation}\n        Negative(I) = 10^k - I\n    \\end{equation}\n    Problem: Can't be represnet in computer\n    \\item Two's Complement: use certain number of bits to represent a integer and \\underline{leftmost} one bit for representing \\textbf{sign}\n    e.g. -(2) is 11111110 \\newline\n    Method: \\textbf{invert} the bits and \\textbf{add 1}\n    \\begin{equation}\n        Negative(I) = 2^k - I\n    \\end{equation}\n\\end{itemize}\n\n\\emph{Overflow} occurs when the value that we compute cannot fit into \\underline{the number of bits} we have allocated for the result\\newline\ne.g. 01111111(127) + 00000011(3) = 10000010(-126) is not +130\n\n\\subsubsection{Real Numbers}\nDifferent from Math: all noninteger values $\\Leftrightarrow$ Real Number\n\n\\emph{Radix} means the \\textbf{dot} that separates the \\underline{whole} \npart from the \\underline{fractional} part in a real number in \\textit{any base}\n\n\\emph{Floating Point} means a representation of a real number that keeps track of the \\textbf{sign}, \\textbf{mantissa}, and \\textbf{exponent}\n\nBase-10:\n\\begin{equation}\n    R = sign * mantissa * 10^{exp}\n\\end{equation}\nBase-2:\n\\begin{equation}\n    R = sign * mantissa * 2^{exp}\n\\end{equation}\n\nFloating Point needs 64 bits: $64 = 1(sign) + 11(exponent) + 52(mantissa)$ i.e. double precision\n\n\\underline{Algorithm} Converting fractional parts from base-10 to other:\n\\begin{lstlisting}\n    WHILE (the fractional part is not zero):\n        Multiply the fractional part by the new base\n        Make the whole part the next digit to the left in the answer\n        Replace the fractional part with the result of multiplication\n\\end{lstlisting}\n\nNoticed that:\n\\begin{itemize}\n    \\item it is possible that the loop will \\textbf{never end} $\\rightarrow$ precision problems\n    \\item instead of division, \\textbf{multiplication} is used here\n    \\item More detail method of computing the Floating point is \\textbf{NOT} included in this book\n\\end{itemize}\n\n\\subsection{Representing Text}\n\\underline{Finite} number of characters $\\rightarrow$ list all of them $\\rightarrow$ represent in binary \\newline\nBut it is only \\textbf{English}, Other language has other characters.\n\n\\underline{ASCII} $\\xrightarrow{Only\\ for}$ English, \\underline{Unicode} $\\xrightarrow{comprimise}$ other language\n\n\\emph{Character set} is a list of character and the codes used to represent each one.\n\n\\subsubsection{Character Set}\nTwo kinds of character sets are used:\n\\begin{itemize}\n    \\item ASCII: \\textbf{8} bits are used\n    \\item Unicode: \\textbf{16} bits are used \n\\end{itemize}\nNotice that:\n\\begin{itemize}\n    \\item ASCII will not affect Unicode\n    \\item ASCII $\\xrightarrow{Subset}$ Unicode \\newline\n    i.e. first eight bits are representing original ASCII\n\\end{itemize}\n\n\\subsubsection{Text Compression}\nThree kinds of ways are possible for text compression:\n\\begin{itemize}\n    \\item Keyword Encoding: Replacing a frequently used word with a \\textbf{single} character \\newline\n    Limitations:\n    \\begin{itemize}\n        \\item the character is already in the text $\\rightarrow$ meaning confusing\n        \\item Upper \\& Lower Case problem\n        \\item Frequent words are usually \\textbf{short}\n    \\end{itemize}\n    \\item Run-length Encoding: Replacing a long series of a repeated character with a count of repetition\\newline\n    i.e. $String = Flag + Repetition + Times$ \\newline\n    e.g. AAAAAAA = *A7 \\newline\n    Limitations:\n    \\begin{itemize}\n        \\item worthless to encode repetitions less than \\textbf{Three}\n        \\item Use ASCII digit to represent the ``Times''\n    \\end{itemize}\n    \\item Huffman Encoding: Using a variable-length binary string to represent a character\n    Limitations:\n    \\begin{itemize}\n        \\item one string cannot \\textbf{prefix} the other string\n        \\item Encoding only focusing on particular text\n    \\end{itemize}\n\\end{itemize}\n\n\\subsection{Representing Audio Data}\nSound is \\textbf{Analog} $\\xrightarrow{Digitalize}$ computer signals $\\xrightarrow{sampling}$ distinct voltage levels $\\rightarrow$ Hardware\n\n\\emph{sampling} is periodically measure the voltage of the signal and record the appropriate numeric value\n\nMP3 is the \\textbf{most common} audio format in the world, which employs both \\underline{lossy} and \\underline{lossless} compression\n\n\\subsection{Representing Images and Graphics}\nRepresenting colour:\n\\begin{itemize}\n    \\item \\textit{HiColor}: 16-bit color depth\\newline\n    i.e. $C = R(5) + G(5) + B(5) + 1$\n    \\item \\textit{TrueColor}: 24-bit color depth\\newline\n    i.e. $C = R(8) + G(8) + B(8)$  (0-255 each)\n\\end{itemize}\n\nSome definitions abot digital images and Graphics:\n\\begin{itemize}\n    \\item Pixel: Individual dots used to represent a picture stands for picture element\n    \\item Resolution: The number of pixel used to represent a picture \n    \\item Raster-graphics format: storing image information pixel by pixel \\newline\n    e.g. GIF, BMP, JPEG\n\\end{itemize}\n\nFour types of formats:\n\\begin{itemize}\n    \\item BMP: Bitmap file\\newline\n    Characteristic: strightforward, very large(record colour \\underline{pixel by pixel})\n    \\item GIF: Graphics Interchange Format\\newline\n    Characteristic: \\textbf{256} colours only, can do \\textbf{animation}\n    \\item JPEG: reduings the size of image but more colourful\n    \\item PNG: Portable Network Graphics\\newline\n    Characteristic: Editable, but not animations\n\\end{itemize}\n\n\\subsection{Representing Video}\n\\emph{Video codec} means COmpressor/DECompressor i.e. shrink the size and play on a computer or over Network\n\nTwo types of compression(unimportant, detail needs references):\n\\begin{itemize}\n    \\item temporal: Based on differences between \\textbf{consecutive frames}\n    \\item spatial: Base on the same compression techniques used for still images\n\\end{itemize}\n\\end{document}", "meta": {"hexsha": "00ddddc585ecaf17aaa6ee9b28fcb2f3e6ff997b", "size": 12022, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CSIlluminated/Block2/Block2.tex", "max_stars_repo_name": "YangtaoGe518/CompReadingNotes", "max_stars_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CSIlluminated/Block2/Block2.tex", "max_issues_repo_name": "YangtaoGe518/CompReadingNotes", "max_issues_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CSIlluminated/Block2/Block2.tex", "max_forks_repo_name": "YangtaoGe518/CompReadingNotes", "max_forks_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.1712328767, "max_line_length": 148, "alphanum_fraction": 0.7373149226, "num_tokens": 3209, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4262858444898583}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{DFTB2/CPE and DFTB3/CPE gradients}\n\\author{andersx@chem.wisc.edu}\n\n\\usepackage{natbib}\n\\usepackage{graphicx}\n\\usepackage{fullpage}\n\\usepackage{amsmath}\n\\usepackage{cases}\n\\usepackage{mathtools}\n\n%\\newcommand{\\beq}{\\begin{equation}}\n%\\newcommand{\\eeq}{\\end{equation}}\n\\renewcommand{\\thesection}{\\arabic{section}.}\n\\numberwithin{equation}{section}\n\n\\renewcommand{\\theequation}{\\thesection\\arabic{equation}}\n\\renewcommand{\\thesubsection}{\\thesection\\arabic{subsection}}\n\n\n\\begin{document}\n% \\maketitle\n\\section{Notation}\nSummation over atom centers is denoted by summation over indices $a, b, c,$ etc. Summation over AO-basis functions is denoted by summation over indices such as $\\mu, \\nu,$ etc. The notation \"$\\mu \\in a$\" means that the basis function $\\mu$ is centered on the atom $a$.\n\\\\\\\\In the following sections we let $q_a$ be the \\textit{Mulliken population} (always a strictly positive quantity), defined as:\n\\begin{equation}\n    q_a = \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}\n    C_{\\mu i} C_{\\nu i} S_{\\mu\\nu}\n\\end{equation}\n\\\\\\\\The charge fluctuation is then: \n\\begin{equation}\n    \\Delta q_a = q_a - q_a^0\n\\end{equation}\n\\\\\\\\Similarly the \\textit{partial Mulliken charge} is defined as \n\\begin{equation}\n    \\Delta Q_a = q_a^0 - q_a = - \\Delta q_a\n\\end{equation}\nAll the equations are presented for DFTB2, but the presented derived terms are the same for DFTB3, since the extra DFTB3 energy terms are additive.\n\n\\section{DFTB2/CPE energy}\n\n\n\\subsection{CPE energy}\nThe CPE energy is given by:\\cite{cpekaminski}\n\\begin{equation}\n    E_{\\mathrm{cpe}} = \\mathbf{c}^T \\cdot \\mathbf{M} \\cdot \\mathbf{q} + \\frac{1}{2} \\mathbf{c}^T \\cdot \\mathbf{N} \\cdot \\mathbf{c},\\label{eq:cpe_energy}\n\\end{equation}\nwhere the first order CPE-DFTB2 Coulomb interaction matrix elements are given by:\n\\begin{equation}\n    M_{ij} = f(R_{ij})\\iint \\frac{\\phi_i^\\mathrm{cpe}\\left(\\mathbf{r}\\right)\\phi_j^\\mathrm{dftb2}\\left(\\mathbf{r'}\\right)}{\\left| \\mathbf{r} - \\mathbf{r'}\\right|} \\mathrm{d}\\mathbf{r}\\mathrm{d}\\mathbf{r'}\n\\end{equation}\nand the second order CPE-CPE Coulomb interaction matrix elements are given by:\n\\begin{equation}\n    N_{ij} = \\iint \\frac{\\phi_i^\\mathrm{cpe}\\left(\\mathbf{r}\\right)\\phi_j^\\mathrm{cpe}\\left(\\mathbf{r'}\\right)}{\\left| \\mathbf{r} - \\mathbf{r'}\\right|} \\mathrm{d}\\mathbf{r}\\mathrm{d}\\mathbf{r'}\n\\end{equation}\nThe CPE basis functions depend on the Mulliken population, while the DFTB basis functions only have a charge dependence in DFTB3.\n\\\\\\\\The set of coefficients of the CPE response density basis that variationally minimizes the total CPE energy in Eqn.~\\ref{eq:cpe_energy} is given (analytically) by:\n\\begin{equation}\n    \\mathbf{c}= -\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q}\n\\end{equation}\nUsing the above relation, the CPE energy can be recast into:\n\\begin{eqnarray}\n    E_{\\mathrm{cpe}}\n    &=& \\mathbf{c}^T \\cdot \\mathbf{M} \\cdot \\mathbf{q} + \\frac{1}{2} \\mathbf{c}^T \\cdot \\mathbf{N} \\cdot \\mathbf{c} \\\\\n    &=& -(\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})^T \\cdot \\mathbf{M} \\cdot \\mathbf{q} + \\frac{1}{2} + (\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})^T \\cdot \\mathbf{N} \\cdot (\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})\\\\\n    &=& -(\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})^T \\cdot \\mathbf{M} \\cdot \\mathbf{q} + \\frac{1}{2} (\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})^T  \\cdot \\mathbf{M} \\cdot \\mathbf{q}\\\\\n    &=& -\\frac{1}{2} (\\mathbf{N}^{-1} \\cdot \\mathbf{M} \\cdot \\mathbf{q})^T  \\cdot \\mathbf{M} \\cdot \\mathbf{q}\n\\end{eqnarray}\n\n\\subsection{DFTB2 energy}\nThe DFTB2 energy is given by:\\cite{dftb2}\n\\begin{equation}\n    E_\\mathrm{dftb2} = \\sum_i^\\mathrm{occ} n_i  \\sum_\\mu \\sum_\\nu C_{\\mu i}  C_{\\nu i} H^0_{\\mu\\nu} + \\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}+ \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} % + \\frac{1}{3} \\sum_{ab} q_a^2 q_b \\Gamma_{ab}\n\\end{equation}\nThe DFTB2 Hamiltonian matrix elements are given by:\\cite{dftb2}\n\\begin{equation}\n    H_{\\mu\\nu}^{\\mathrm{(dftb2)}} = H^0_{\\mu\\nu} + \\frac{1}{2}S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c \n\\end{equation}\n\\subsection{Combined DFTB2/CPE energy}\nThe full DFTB2/CPE energy is given by:\n\\begin{eqnarray}\n    E_\\mathrm{{dftb2/cpe}} &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} H_{\\mu\\nu}^{\\mathrm{(dftb2)}}  \n    + \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab}\n    + E_{\\mathrm{cpe}} \\nonumber\\\\\n    &=& \\underbrace{\\sum_i^\\mathrm{occ} n_i  \\sum_\\mu \\sum_\\nu C_{\\mu i}  C_{\\nu i} H^0_{\\mu\\nu}}_{E_\\mathrm{H0}}\n        + \\underbrace{\\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}}_{E_\\gamma}\n    + \\underbrace{\\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab}}_{E_\\mathrm{rep}}\n%        && \\underbrace{- \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\left(\n%    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n%    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b}\n%\\right)}_{E_\\mathrm{shift}}\\nonumber\\\\\n + E_{\\mathrm{cpe}}\\\\\\nonumber\\\\\n&=&  E_\\mathrm{H0} + E_\\gamma + E_\\mathrm{rep} + E_\\mathrm{cpe}\\label{eq:shorthand}\n\\end{eqnarray}\nThe CPE Hamiltonian shift is given by:\\cite{gieseyork2012}\n\\begin{equation}\n    \\Delta H_{\\mu\\nu}^{\\mathrm{(cpe)}} =  \\frac{1}{2} S_{\\mu\\nu} \\left(\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b}\n\\right) \\qquad \\mu \\in a, \\nu \\in b\n\\end{equation}\nNote that here $q_a$ and $q_b$ are the Mulliken populations. Giese and York (2012) give the derivative in terms of the Mulliken charge and differ by a sign. See Appendix A for details.\n\\\\\\\\The occupied orbital energies is given in the terms of the (optimized) coefficients and the matrix elements mentioned previously:\n\\begin{eqnarray}\n    \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} H_{\\mu\\nu}\\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} \\left(H_{\\mu\\nu}^{\\mathrm{(dftb2)}} + \\Delta H_{\\mu\\nu}^{\\mathrm{(cpe)}} \\right)\\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} H_{\\mu\\nu}^0\n    + \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c \\nonumber\\\\\n    && +\\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i  \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\left(\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b} \\right)\\label{eq:orbital_energies}\n\\end{eqnarray}\nUsing the relation above, the energy can be calculated in terms of the orbital energies (as implemented in CHARMM), by isolating $E_\\mathrm{H0}$ in Eqn.~\\ref{eq:orbital_energies} and inserting into Eqn.~\\ref{eq:shorthand}.\n\n\\begin{eqnarray}\n    E_\\mathrm{{dftb2/cpe}}\n    &=& \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \n    - \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c \\nonumber\\\\\n    && \\underbrace{- \\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\left(\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b} \\right)}_{E_\\mathrm{shift}} \\nonumber\\\\\n    && +\\ \\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}\n    + \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} + E_{\\mathrm{cpe}}\n\\end{eqnarray}\nThe $E_\\mathrm{shift}$ must be subtracted from the electronic energy to compensate for double counting when adding $E_\\mathrm{cpe}$ to the electronic energy in terms of the occupied orbital energies.\n\\\\\\\\The following relation is useful:\n\\begin{eqnarray}\n    E_\\mathrm{shift}\n    &=& - \\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\left(\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b} \\right) \\nonumber\\\\\n    &=& - \\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} \\nonumber\\\\\n    && - \\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b} \\nonumber\\\\\n    &=& - \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} \\nonumber\\\\\n    &=& -  \\sum_a  \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} q_a\n\\end{eqnarray}\nUsing the above relation, the DFTB2/CPE energy can be simplified to:\n\\begin{equation}\n    E_\\mathrm{{dftb2/cpe}} = \\sum_i^\\mathrm{occ} n_i \\varepsilon_i - \\frac{1}{2}\\sum_{ab} \\left(q_a + q_a^0 \\right)\\Delta q_b \\gamma_{ab}\n    - \\sum_a  \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} q_a + E_{\\mathrm{cpe}}\n\\end{equation}\n\n\n\\clearpage\n\\section{DFTB2/CPE energy gradient}\nThe energy gradient is the derivative of the energy with respect to the nuclear coordinates under the following constraint:\\cite{dftb3}\n\\begin{equation}\n    - F_{kx} = \\frac{\\partial}{\\partial R_{kx}} \\left[ E_\\mathrm{{dftb2/cpe}} - \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \\left(\\sum_{\\mu} \\sum_{\\nu} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} - 1  \\right) \\right]\n\\end{equation}\nUsing the notation of Eq.~\\ref{eq:shorthand}, we can rewrite this as:\n\\begin{equation}\n    - F_{kx} = \\frac{\\partial}{\\partial R_{kx}} \\left[  E_\\mathrm{H0} + E_\\gamma + E_\\mathrm{rep} + E_\\mathrm{cpe} - \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \\left(\\sum_{\\mu} \\sum_{\\nu} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} - 1 \\right) \\right]\n\\end{equation}\nSeparating the terms that appear in the standard DFTB2 gradient, and the DFTB2/CPE gradient, we arrive at the CPE gradient correction:\n\\begin{eqnarray}\n    - F_{kx} &=& \\frac{\\partial}{\\partial R_{kx}} \\left[  E_\\mathrm{H0} + E_\\gamma + E_\\mathrm{rep}  + E_\\mathrm{cpe} - \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \\left(\\sum_{\\mu} \\sum_{\\nu} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} - 1 \\right) \\right]\\nonumber\\\\\n             &=& \\underbrace{\\frac{\\partial}{\\partial R_{kx}} \\left[  E_\\mathrm{H0} + E_\\gamma  + E_\\mathrm{rep}- \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \\left(\\sum_{\\mu} \\sum_{\\nu} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} - 1 \\right) \\right]}_{\\mathrm{Same~as~the~DFTB2~gradient}}\n    +\\frac{\\partial}{\\partial R_{kx}} E_\\mathrm{cpe} \\nonumber\\\\\n    &=& -F_{kx}^\\mathrm{(dftb2)} + \\frac{\\partial E_\\mathrm{cpe}}{\\partial R_{kx}}\n\\end{eqnarray}\nThe last term is new, and is presented in the next sections.\n\n\\subsection{CPE gradient: $-F_{kx}^\\mathrm{(cpe)} = \\frac{\\partial E_\\mathrm{cpe}}{\\partial R_{kx}}$}\nThe CPE energy depends explicitly on the coordinates via the Coulomb integrals, and implicitly on the coordinates via the CPE coefficients and the Mulliken population:\n\n\\begin{eqnarray}\n    -F_{kx}^\\mathrm{(cpe)} &=& \\frac{\\partial E_\\mathrm{{cpe}}\\left(R_{kx}\\right)}{\\partial R_{kx}} \\nonumber\\\\\n%-F_{kx}^\\mathrm{(cpe)} &=& \\frac{\\partial E_\\mathrm{{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial R_{kx}} \\nonumber\\\\\n    &=& \\sum_i \\frac{\\partial E_\\mathrm{{cpe}}\\left(\\mathbf{q}, c_{i}(R_{kx})\\right)}{\\partial c_{i}}    \n    \\frac{\\partial c_{i}(R_{kx})}{\\partial R_{kx}} \n    + \\sum_a \\frac{\\partial E_\\mathrm{{cpe}}\\left(q_a(R_{kx}), \\mathbf{c}\\right)}{\\partial q_a}    \n    \\frac{\\partial q_a(R_{kx})}{\\partial R_{kx}} \n    + \\frac{\\partial E_\\mathrm{{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial R_{kx}}\n\\end{eqnarray}\nThe first derivative term is zero, since the CPE energy is variationally optimized with respect to the $\\mathbf{c}$ coefficients. \n\\subsubsection{Dependence on $q_a$}\nThe second term can be divided into two factors. The first factor can be calculated as described in the previous section (it is the same term as found in the Hamiltonian-shift.) - i.e.~the derivatives with respect to the Mulliken populations. \nIn the CPE charge-independent case:\n\\begin{equation}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} = [\\mathbf{c^T}  \\cdot \\mathbf{M}]_a\n\\end{equation}\nAnd in the CPE charge-dependent case:\n\\begin{equation}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} = \n    \\mathbf{c^T} \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{M}}{\\mathrm{\\partial}q_a}\\right) \\cdot \\mathbf{q} \n    + [\\mathbf{c^T}  \\cdot \\mathbf{M}]_a + \\frac{1}{2}\\mathbf{c}^T \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{N}}{\\mathrm{\\partial}q_a}\\right) \\cdot \\mathbf{c}. \n\\end{equation}\nThe second factor can be calculated for $a \\neq k$ by:\\cite{dftb3}\n\\begin{equation}\n    \\frac{\\partial q_{a\\neq k}}{\\partial R_{kx}} \n    = \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu \\in a} \\sum_{\\nu \\in k}  C_{\\mu i} C_{\\nu i}\\frac{\\partial S_{\\mu\\nu}}{\\partial R_{kx}}\n\\end{equation}\nor for $a=k$:\n\\begin{equation}\n    \\frac{\\partial q_{k}}{\\partial R_{kx}} \n    = \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu \\in k} \\sum_{\\nu \\not\\in k}  C_{\\mu i} C_{\\nu i}\\frac{\\partial S_{\\mu\\nu}}{\\partial R_{kx}}\n\\end{equation}\nThis term must be calculated in the DFTB2 gradient code, where the derivative of the overlap matrix is already being calculated.\n\n\\subsubsection{(Explicit) dependence on $R_{kx}$}\nThe derivative with respect to $R_{kx}$ is written via the matrix derivatives.\n\\begin{equation}\n    \\frac{\\partial E_\\mathrm{{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial R_{kx}} = \n    \\mathbf{c^T} \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{M}}{\\mathrm{\\partial}R_{kx}}\\right) \\cdot \\mathbf{q} \n    + \\frac{1}{2}\\mathbf{c}^T \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{N}}{\\mathrm{\\partial}R_{kx}}\\right) \\cdot \\mathbf{c}. \n\\end{equation}\n\n\n\\clearpage\n\\section{DFTB2 electric field contribution}\nThe energy in an electric field $\\vec{F}$ is given by the interaction of the field with the partial charges:\n\\begin{eqnarray}\n    E_\\mathrm{EF/dftb2} \n    &=& \\sum_i^\\mathrm{occ} n_i  \\sum_\\mu \\sum_\\nu C_{\\mu i}  C_{\\nu i} H^0_{\\mu\\nu} + \\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}+ \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} - \\sum_a \\Delta Q_a\\ \\vec{F} \\cdot \\vec{r}_a\\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i  \\sum_\\mu \\sum_\\nu C_{\\mu i}  C_{\\nu i} H^0_{\\mu\\nu} + \\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}+ \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} \\\\\n    &&+\\ \\underbrace{\\sum_a q_a\\ \\vec{F} \\cdot \\vec{r}_a}_{\\Delta E_{\\mathrm{EF/dftb2}}}\\label{eq:dftb_ef_energy} - \\sum_a q^0_a\\ \\vec{F} \\cdot \\vec{r}_a\n\\end{eqnarray}\nwhere $q_a$ are the Mulliken populations, $\\Delta Q_a$ are the partial Mulliken charges, and $q^0_a$ are the charges of the nuclei.\nBefore deriving the Hamiltonian we note the following relation:\n\\begin{equation}\n    \\frac{\\partial \\Delta E_{\\mathrm{EF/dftb2}}}{\\partial q_a}\n    = \\frac{\\partial}{\\partial q_a} \\sum_{a'} q_{a'}\\ \\vec{F} \\cdot \\vec{r}_{a'} = \\vec{F} \\cdot \\vec{r}_a\n\\end{equation}\nCombining the above with Eq.~\\ref{eq:q_rho}, the corresponding Hamiltonian element to be added to the DFTB2 Hamiltonian element is given by:\n\\begin{eqnarray}\n    \\Delta H_{\\mu\\nu}^{\\mathrm{(EF/dftb2)}} \n    &\\equiv& \\frac{\\partial \\Delta  E_{\\mathrm{EF/dftb2}}}{\\partial \\rho_{\\mu\\nu}}\\nonumber\\\\\n    &=&  \\sum_a \\frac{\\partial \\Delta  E_{\\mathrm{EF/dftb2}}}{\\partial q_a} \n     \\frac{\\partial q_a}{\\partial \\rho_{\\mu\\nu}}\\nonumber\\\\\n     &=& \\frac{1}{2} S_{\\mu\\nu} \\left( \\vec{r}_a + \\vec{r}_b\n \\right) \\cdot \\vec{F}  \\qquad \\mu \\in a, \\nu \\in b\n\\end{eqnarray}\nSo the matrix elements of the DFTB2 Hamiltonian matrix in the presence of an electric field  are:\n\\begin{equation}\n    H_{\\mu\\nu} = H^0_{\\mu\\nu} + \\frac{1}{2}S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c  + \\frac{1}{2} S_{\\mu\\nu} \\left( \\vec{r}_a + \\vec{r}_b \\right) \\cdot \\vec{F}  \\qquad \\mu \\in a, \\nu \\in b \\label{eq:dftb_ef_hamil}\n\\end{equation}\nThe DFTB2 energy in an electric field has the following orbital energies:\n\\begin{eqnarray}\n    \\sum_i^\\mathrm{occ} n_i \\varepsilon_i \n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} H_{\\mu\\nu}\\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} \\left(H_{\\mu\\nu}^{\\mathrm{(dftb2)}} + \\Delta H_{\\mu\\nu}^{\\mathrm{(EF/dftb2)}} \\right)\\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu} \\sum_{\\nu}  C_{\\mu i} C_{\\nu i} H_{\\mu\\nu}^0\n    + \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c \\nonumber\\\\\n    && + \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} \n    S_{\\mu\\nu} \\left( \\vec{r}_a + \\vec{r}_b \\right) \\cdot \\vec{F} \\label{eq:orbital_energies_ef}\n\\end{eqnarray}\nIsolating $H_0$ in the above and inserting into Eq.~\\ref{eq:dftb_ef_energy} the DFTB2 energy in the presence of an external field is written in terms of the orbital energies:\n\\begin{eqnarray}\n    E_\\mathrm{EF/dftb2}  \n    &=& \\sum_i^\\mathrm{occ} n_i \\varepsilon_i - \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} S_{\\mu\\nu} \\sum_c \\left( \\gamma_{ac} + \\gamma_{bc} \\right)\\Delta q_c \\nonumber\\\\\n    && -\\ \\frac{1}{2} \\sum_i^\\mathrm{occ} n_i \\sum_a \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b}  C_{\\mu i} C_{\\nu i} \n    S_{\\mu\\nu} \\left( \\vec{r}_a + \\vec{r}_b \\right) \\cdot \\vec{F}  + \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} + \\sum_a q_a\\ \\vec{F} \\cdot \\vec{r}_a \\nonumber\\\\\n    &=& \\sum_i^\\mathrm{occ} n_i \\varepsilon_i - \\frac{1}{2}\\sum_{ab} \\left(q_a + q_a^0 \\right)\\Delta q_b \\gamma_{ab} + \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab}  - \\sum_a q^0_a\\ \\vec{F} \\cdot \\vec{r}_a\n\\end{eqnarray}\nSo only the nuclear charge term has to be added to the energy expressed in terms of the orbital energies.\n\n\n\\subsection{DFTB2 dipole moment}\nThe dipole moment of a molecule is given by the DFTB2 Mulliken partial charges.\n\\begin{equation}\n    \\vec{\\mu}^{(dftb2)} = \\sum_a \\Delta Q_a\\ \\vec{r}_a = \\sum_a q^0_a\\ \\vec{r}_a - \\sum_a q_a\\ \\vec{r}_a \n\\end{equation}\n\n\n\\section{DFTB2/CPE electric field contribution}\nThe CPE-dipole functions interact directly with an external electric field and enter the energy CPE energy as:\n\\begin{equation}\n    E_{\\mathrm{EF/cpe}} = \\mathbf{c}^T \\cdot \\left( \\mathbf{M} \\cdot \\mathbf{q} - \\mathbf{f} \\right) + \\frac{1}{2} \\mathbf{c}^T \\cdot \\mathbf{N} \\cdot \\mathbf{c},\n\\end{equation}\nwhere $\\mathbf{f}$ is a $3N$ vector containing $N$ repeats of the components of the electric field.\n% , i.e.\n% \\begin{equation}\n%     \\mathbf{f} = \n%     \\begin{bmatrix}\n%         F_{x}\\\\\n%         F_{y}\\\\\n%         F_{z}\\\\\n%         F_{x}\\\\\n%         F_{y}\\\\\n%         F_{z}\\\\\n%         \\vdots\n%     \\end{bmatrix}\n% \\end{equation}\nIn the electric field, the variational analytical solution of the coefficients becomes:\n\\begin{equation}\n    \\mathbf{c}= -\\mathbf{N}^{-1} \\cdot \\left(\\mathbf{M} \\cdot \\mathbf{q} - \\mathbf{f} \\right)\n\\end{equation}\nThe DFTB2/CPE energy in the electric field is simply:\n\\begin{equation}\n  E_\\mathrm{EF/dftb2/cpe} \n= \\sum_i^\\mathrm{occ} n_i  \\sum_\\mu \\sum_\\nu C_{\\mu i}  C_{\\nu i} H^0_{\\mu\\nu} + \\frac{1}{2} \\sum_{ab} \\Delta q_a \\Delta q_b \\gamma_{ab}+ \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} - \\sum_a \\Delta Q_a\\ \\vec{F} \\cdot \\vec{r}_a + E_{\\mathrm{EF/cpe}}\n\\end{equation}\n% \\\\\\\\We can use the above definition of the dipole moment to show, that the Hamiltonian contribution due to the CPE-dipoles vanishes (due to the CPE-coefficients being optimized variationally.)\n% \\begin{eqnarray}\n%     \\Delta H_{\\mu\\nu}^{\\mathrm{(EF/cpe)}} \n%     &\\equiv& \\frac{\\partial \\Delta E_{\\mathrm{EF/cpe}}}{\\partial \\rho_{\\mu\\nu}}\\nonumber\\\\\n%     &=&  \\sum_i \\frac{\\partial \\Delta E_{\\mathrm{EF/cpe}}}{\\partial c_i} \n%      \\frac{\\partial c_i}{\\partial \\rho_{\\mu\\nu}}= 0\n% \\end{eqnarray}\n\\\\\\\\Since no additional terms from the CPE basis/electric field interaction enter the Hamiltonian matrix (since this interaction does not depend on $\\mathbf{q}$), we can write the DFTB2/CPE energy in the presence of an external field in terms of the orbital energies as:\n\\begin{eqnarray}\n    E_\\mathrm{EF/dftb2/cpe}  \n    &=& \\sum_i^\\mathrm{occ} n_i \\varepsilon_i - \\frac{1}{2}\\sum_{ab} \\left(q_a + q_a^0 \\right)\\Delta q_b \\gamma_{ab} + \\frac{1}{2} \\sum_{ab} V^\\mathrm{rep}_{ab} -\\sum_a \\Delta Q_a\\ \\vec{F} \\cdot \\vec{r}_a\\nonumber\\\\\n    && - \\sum_a  \\frac{\\partial E_{\\mathrm{EF/cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} q_a +\\ E_{\\mathrm{EF/cpe}}\n\\end{eqnarray}\nAgain, $q_a$ is a Mulliken \\textit{population} and $\\Delta Q_a$ is the partial Mulliken \\textit{charge}.\n\n\\subsection{DFTB2/CPE dipole moment}\nWe define $\\vec{\\mu}^{\\mathrm{(cpe)}}_a$ as the total dipole due to the CPE-basis functions centered on atom $a$. This is given by the coefficients to the same functions:\n\\begin{equation}\n    \\vec{\\mu}^{\\mathrm{(cpe)}}_a =  \n    \\begin{bmatrix}\n        c_{ax}\\\\\n        c_{ay}\\\\\n        c_{az}\\\\\n    \\end{bmatrix}\n\\end{equation}\nwhere $c_{ax}$ is the coefficient of the dipole function centered on atom $a$ in the $x$-direction, and so on.\nThe total dipole-moment of the molecule in the DFTB2/CPE description is now:\n\\begin{equation}\n    \\vec{\\mu}^{\\mathrm{(dftb2/cpe)}} = \\sum_a \\Delta Q_a\\ \\vec{r}_a + \\sum_a \\vec{\\mu}^{\\mathrm{(cpe)}}_a\n\\end{equation}\n\n\n\\section{DFTB2 and DFTB2/CPE polarizability}\nThe elements of the polarizability tensor is calculated as:\n\\begin{equation}\n    \\alpha_{ij} = \\left(\\frac{\\partial \\mu_i }{\\partial F_j}\\right)_{\\vec{F}=0} = - \\left(\\frac{\\partial^2 E }{\\partial F_i\\partial F_j}\\right)_{\\vec{F}=0}\n\\end{equation}\nwhere $i$ and $j$ are the $x$, $y$, $z$ Cartesian components and $\\mu_i$ is the $i$-component of the DFTB2 or DFTB2/CPE dipole moment.\nThe partial derivatives are calculated numerically by means of the two-point, forward-backtrack finite differences method, e.g.:\n\\begin{equation}\n \\alpha_{ij} = \\frac{ \\mu_i \\left(F_j + h \\right) - \\mu_i\\left(F_j - h\\right) }{2h}% = \\frac{ E\\left(F_j\\right) - E\\left(F_j + h \\right) - E\\left(F_j - h\\right) }{h^2}\n\\end{equation}\n\\\\\\\\The isotropic polarizability used in the fitting routine is calculated as:\n\\begin{equation}\n    \\alpha_{\\mathrm{iso}} = \\frac{1}{3} \\left( \\alpha_{xx} +\\alpha_{yy} + \\alpha_{zz}  \\right)\n\\end{equation}\n\n\n\n\n\\bibliographystyle{unsrt}\n\\bibliography{references}\n\\clearpage\n\\section*{Appendices}\n\\appendix\n\\section{Hamiltonian shifts}\n\n\\subsection{Mulliken population}\n\\label{sec:mulliken}\nFirst we define the density matrix is defined in terms of the coefficient matrix:\n\\begin{equation}\n    \\rho_{\\mu\\nu} = \\sum_i^\\mathrm{occ} n_i C_{\\mu i} C_{\\nu i}\n\\end{equation}\nWe can then define the Mulliken population by the density matrix:\n\\begin{eqnarray}\n    q_a \n    &=& \\sum_i^\\mathrm{occ} n_i \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b} C_{\\mu i} C_{\\nu i} S_{\\mu\\nu}\\nonumber\\\\\n    &=& \\frac{1}{2} \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b} \\left( \\rho_{\\mu\\nu} + \\rho_{\\nu\\mu}\\right) S_{\\mu\\nu}\n\\end{eqnarray}\nThe charge fluctuation is then: \n\\begin{equation}\n    \\Delta q_a = q_a - q_a^0\n\\end{equation}\nUsing these definitions we derive the following relation:\n\\begin{equation}\n    \\frac{\\partial q_a}{\\partial \\rho_{\\mu\\nu}}\n    = \\frac{\\partial }{\\partial \\rho_{\\mu\\nu}} \\left[ \\frac{1}{2} \\sum_{\\mu \\in a} \\sum_b \\sum_{\\nu \\in b} \\left( \\rho_{\\mu\\nu} + \\rho_{\\nu\\mu}\\right) S_{\\mu\\nu} \\right]\n    = \\begin{cases} \n        \\frac{1}{2} S_{\\mu\\nu}& \\quad \\mu \\in a\\\\\n        \\frac{1}{2} S_{\\mu\\nu}& \\quad \\nu \\in a\\\\\n        S_{\\mu\\nu}& \\quad \\mu \\in a \\quad \\mathrm{and}\\quad \\nu \\in a\\\\\n    \\end{cases}\\label{eq:q_rho}\n\\end{equation}\nNote that the \\textit{Mulliken population} is always a positive number, and the \\textit{Mulliken charge} is the negative of the Mulliken population.\n\n\\subsection{CPE Hamiltonian shift}\nUsing the relation from section \\ref{sec:mulliken}, the CPE Hamiltonian shift is calculated using the chain rule:\n\\begin{eqnarray}\n    \\Delta H_{\\mu\\nu}^{\\mathrm{(cpe)}} &=& \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial \\rho_{\\mu\\nu}}\\\\\n    &=& \\sum_i \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial c_i} \n    \\frac{\\partial c_i}{\\partial \\rho_{\\mu\\nu}}\n    + \\sum_a \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} \n    \\frac{\\partial q_a}{\\partial \\rho_{\\mu\\nu}}\\\\\n    &=& \\frac{1}{2} S_{\\mu\\nu} \\left(\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} +\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_b}\n\\right) \\qquad \\mu \\in a, \\nu \\in b\n\\end{eqnarray}\nNote that the last derivative is taken with respect to the Mulliken population. In Giese and York (2012) the negative sign is adopted.\n\\\\\\\\The CPE energy has no parametric dependence on the density, but depends implicitly via the charges and coefficients.\nThe first term is zero due to the CPE energy being variationally minimized with respect to the coefficients.\nThe first part of the second term is in the CPE charge-independent case:\n\\begin{equation}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} = [\\mathbf{c^T}  \\cdot \\mathbf{M}]_a\n\\end{equation}\nIn the CPE charge-dependent case:\n\\begin{equation}\n    \\frac{\\partial E_{\\mathrm{cpe}}\\left[\\mathbf{q}, \\mathbf{c}\\right]}{\\partial q_a} = \n    \\mathbf{c^T} \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{M}}{\\mathrm{\\partial}q_a}\\right) \\cdot \\mathbf{q} \n    + [\\mathbf{c^T}  \\cdot \\mathbf{M}]_a + \\frac{1}{2}\\mathbf{c}^T \\cdot \\left( \\frac{\\mathrm{\\partial}\\mathbf{N}}{\\mathrm{\\partial}q_a}\\right) \\cdot \\mathbf{c}. \n\\end{equation}\nSee Giese and York (2012) for details.\\cite{gieseyork2012}\n\\end{document}\n \n", "meta": {"hexsha": "08a08ff818c303c2a8e1c89c012873e99026b2bb", "size": 26400, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gradient.tex", "max_stars_repo_name": "andersx/cpe-gradient-latex", "max_stars_repo_head_hexsha": "749476bd0c1b257a074abf1bc2bf772e6c4928e9", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-05-04T10:40:40.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-04T10:40:40.000Z", "max_issues_repo_path": "gradient.tex", "max_issues_repo_name": "andersx/cpe-gradient-latex", "max_issues_repo_head_hexsha": "749476bd0c1b257a074abf1bc2bf772e6c4928e9", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gradient.tex", "max_forks_repo_name": "andersx/cpe-gradient-latex", "max_forks_repo_head_hexsha": "749476bd0c1b257a074abf1bc2bf772e6c4928e9", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.9225181598, "max_line_length": 270, "alphanum_fraction": 0.6585606061, "num_tokens": 10188, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.42627359492912786}}
{"text": "\n\\chapter{Multimodal Hashing for General Data}\n\\label{chap:crh}\n\n%-------------------------------------------------------------------------------\n\\section{Introduction}\n\nAs stated earlier, the \\mbox{SMH} model and the \\mbox{MLBE} model require the data points in different modalities to be aligned or organized in graphs. However, these assumptions might not be the case in some applications. \n\nIn this chapter, we present a novel model for data in general form. Specifically, we develop Co-Regularized Hashing (\\mbox{CRH}), which is based on a boosted co-regularization framework. For each bit of the hash codes, \\mbox{CRH} learns a group of hash functions, one for each modality, by minimizing a novel loss function. Although the loss function is non-convex, it is in a special form which can be expressed as a difference of convex functions.  As a consequence, the Concave-Convex Procedure~(CCCP)~\\cite{yuille2001nips}\ncan be applied to solve the optimization problem iteratively.  We use a stochastic gradient method in each \\mbox{CCCP} iteration. After learning the hash functions for one bit, \\mbox{CRH} proceeds to learn more bits via a boosting procedure such that the bias introduced by the hash functions can be sequentially minimized.\n\nIn the following, we present the \\mbox{CRH} model in Section~\\ref{crh:model}. Empirical study conducted on three real data sets is reported in Section~\\ref{crh:exps} before the conclusion in Section~\\ref{crh:conclusion}.\n\n%-------------------------------------------------------------------------------\n\\section{Co-Regularized Hashing}\n\\label{crh:model}\n\n%We use boldface lowercase letters and calligraphic letters to denote vectors and sets, respectively. For a vector $\\x $, $\\x^{T} $ denotes its transpose and $\\|\\x\\| $ its $\\ell_2$ norm. \n\n\n%*******************************************************************************\n\\subsection{Objective Function}\n\nSuppose that there are two sets of data points from two modalities,\\footnote{For simplicity of our presentation, we focus on the bimodal case here and leave the discussion on extension to more than two modalities to Section~\\ref{sec:moel:ext}.}\ne.g., $\\{\\x_{i}\\in\\mathcal{X}\\}_{i=1}^{I}$ for a set of $I$ images from some feature space $\\mathcal{X}$ and $\\{\\y_{j}\\in\\mathcal{Y}\\}_{j=1}^{J}$ for a set of $J$ textual documents from another feature space $\\mathcal{Y}$. We also have a set of $N$ inter-modality point pairs $\\Theta = \\{(\\x_{a_1},\\y_{b_1}), (\\x_{a_2},\\y_{b_2}),\\dots, (\\x_{a_N},\\y_{b_N})\\}$, where, for the $n$th pair, ${a_n}$ and $b_{n}$ are indices of the points in $\\mathcal{X}$ and $\\mathcal{Y}$, respectively. We further assume that each pair has a label $s_{n} = 1$ if $\\x_{a_n}$ and $\\y_{b_n}$ are similar and $s_{n}=0$ otherwise.  The notion of inter-modality similarity varies from application to application.  For example, if an image includes a tiger and a textual document is a research paper on tigers, they should be labeled as similar.  On the other hand, it is highly unlikely to label the image as similar to a textual document on basketball.\n%\\footnote{*** In general, you should write it as $\\Theta = \\{(\\x_{a_1},\\y_{b_1}), (\\x_{a_2},\\y_{b_2}),\\dots, (\\x_{a_N},\\y_{b_N})\\}$.}\n\nFor each bit of the hash codes, we define two linear hash functions as follows:\n\\begin{align}\nf(\\x ) = \\sgn(\\w_{x}^{T}\\x) \\ \\ \\mbox{and} \\ \\ g(\\y ) &= \\sgn(\\w_{y}^{T}\\y),\\nonumber\n\\end{align}\nwhere $\\sgn(\\cdot)$ denotes the sign function, and $\\w_{x}$ and $\\w_{y}$ are projection vectors which, ideally, should map similar points to the same hash bin and dissimilar points to different bins.  Our goal is to achieve \\mbox{HFL} by learning $\\w_{x}$ and $\\w_{y}$ from the multimodal data.\n\nTo achieve this goal, we propose to minimize the following objective function \\wrt~(with respect to) $\\w_{x}$ and $\\w_{y}$:\n\\begin{align}\n\\mathcal{O}= \\frac{1}{I}\\sum\\limits_{i=1}^{I}\\ell_{i}^{x}+\\frac{1}{J}\\sum\\limits_{j=1}^{J}\\ell_{j}^{y}+\\gamma\\sum_{n=1}^{N}\\omega_{n}\\ell_{n}^{*}+\\frac{\\lambda_{x}}{2}\\|\\w_{x}\\|^{2}+\\frac{\\lambda_{y}}{2}\\|\\w_{y}\\|^{2},\n\\label{eqn:loss}\n\\end{align}\nwhere $\\ell_{i}^{x}$ and $\\ell_{j}^{y}$ are intra-modality loss terms for modalities $\\mathcal{X}$ and $\\mathcal{Y}$, respectively. In this work, we define them as:\n\\begin{align}\n\\ell_{i}^{x}&=\\big[1-f(\\x_i)(\\w_{x}^{T}\\x_i)\\big]_{+}=\\big[1-|\\w_{x}^{T}\\x_{i}|\\big]_{+},\\nonumber\\\\\n\\ell_{j}^{y}&=\\big[1-g(\\y_j)(\\w_{y}^{T}\\y_j)\\big]_{+}=\\big[1-|\\w_{y}^{T}\\y_{j}|\\big]_{+},\\nonumber\n\\end{align}\nwhere $[a]_{+}$ is equal to $a$ if $a \\ge 0$ and 0 otherwise.  We note that the intra-modality loss terms are similar to the hinge loss in the (linear) support vector machine but have quite different meaning. Conceptually, we want the projected values to be far away from 0 and hence expect the hash functions learned to have good generalization ability~\\cite{mu2010cvpr}.\nFor the inter-modality loss term $\\ell_{n}^{*}$, we associate with each point pair a weight $\\omega_{n}$, with $\\sum\\nolimits_{n=1}^{N}\\omega_n=1$, to normalize the loss as well as compute the bias of the hash functions. In this paper, we define $\\ell_{n}^{*}$ as\n\\begin{align}\n\\ell_{n}^{*} = s_{n}d_{n}^{2}+(1-s_{n})\\tau(d_{n}),\\nonumber\n\\end{align}\nwhere $d_{n} = \\w_{x}^{T}\\x_{a_n}-\\w_{y}^{T}\\y_{b_n}$ and $\\tau(d)$ is called the smoothly clipped inverted squared deviation (\\mbox{SCISD}) function. \n\n\n%\\footnote{*** But the nature of the problem is different.  You are not dealing with a classification problem here.  Implicitly you want the projected values to be far away from 0.  It is only in this sense that it is similar to the maximum margin criterion.}\n\nThe \\mbox{SCISD} function was first proposed in~\\cite{quadrianto2011icml}.  It can be defined as follows:\n\\begin{align}\n\\tau(d) & =\\left\\{ \\begin{array}{ll}\n         -\\frac{1}{2}d^{2}+\\frac{a\\lambda^2}{2} & \\mbox{if ~} |d| \\le \\lambda \\\\\n         \\frac{d^{2}-2a\\lambda|d|+a^2\\lambda^2}{2(a-1)}& \\mbox{if ~}\\lambda < |d|\\le a\\lambda\\\\\n         0 & \\mbox{if ~} a\\lambda<|d|,\\nonumber\n                          \\end{array} \\right.\n\\end{align}\nwhere $a$ and $\\lambda$ are two user-specified parameters.  The \\mbox{SCISD} function penalizes projection vectors that result in small distance between dissimilar points after projection.  A more important property is that it can be expressed as a difference of two convex functions.  Specifically, we can express $\\tau(d) = \\tau_{1}(d) - \\tau_{2}(d)$ where\n\\begin{align}\n\\tau_{1}(d) = \\left\\{ \\begin{array}{ll}\n         0 & \\mbox{if ~}|d| \\le \\lambda \\\\\n         \\frac{ad^{2}-2a\\lambda|d|+a\\lambda^2}{2(a-1)}& \\mbox{if ~}\\lambda < |d|\\le a\\lambda\\\\\n         \\frac{1}{2}d^{2}-\\frac{a\\lambda^2}{2} & \\mbox{if ~} a\\lambda<|d|\\nonumber\n                          \\end{array} \\right.\\ \\mbox{and}  \\ \\ \n\\tau_{2}(d) = \\frac{1}{2}d^{2}-\\frac{a\\lambda^2}{2}.\\nonumber\n\\end{align}\n%Obviously, both $\\tau_{1}(\\cdot)$ and $\\tau_{2}(\\cdot)$ are convex functions. \n\n%*******************************************************************************\n%\\subsection{Relaxation via \\mbox{CCCP}}\n%\n%It is easy to realize that all the terms in the objective function~(\\ref{eqn:loss}) are convex except $\\tau(\\cdot)$, which, as explained above, can be expressed as a difference of two convex functions. As a consequence, we can use \\mbox{CCCP} to solve the non-convex optimization problem iteratively with each iteration minimizing a convex upper bound of the original objective function.\n%\n%%\n%%The only non-convex term in the objective function is $\\tau(d_{n})$, but it can be easily decomposed to the difference of two convex functions~\\cite{quadrianto2011icml}. \n%%\n%%Because both $\\tau_{1}(d_{n})$ and $\\tau_{2}(d_{n})$ are convex functions \\wrt (with respect to) $\\w_{x}$ or $\\w_{y}$, and we can use a general \\mbox{CCCP} approach to get two convex upper bounds, respectively.\n%\n%Briefly speaking, given an objective function $f_{0}(x)-g_{0}(x)$ where both $f_{0}$ and $g_{0}$ are convex, \\mbox{CCCP} works iteratively as follows.  The variable $x$ is first randomly initialized to $x_0$.  At the $t$th iteration, \\mbox{CCCP} minimizes the following convex upper bound of $f_{0}(x)-g_{0}(x)$ at location $x_{t}$:\n%$$f_{0}(x)-\\big(g_{0}(x_{t})+\\partial_{x}g_{0}(x_{t})(x-x_{t})\\big),$$\n%where $\\partial_{x}g_{0}(x_{t})$ is the first derivative of $g(x)$ at $x_{t}$. This optimization problem can be solved using any convex optimization solver to obtain $x_{t+1}$.  Given an initial value $x_{0}$, the solution sequence $\\{x_{t}\\}$ found by \\mbox{CCCP} is guaranteed to reach a local minimum or a saddle point. \n%\n%For our problem, at the $t$th \\mbox{CCCP} iteration, the convex upper bound of $\\tau(d_{n})$ \\wrt~$\\w_{x}$ is:\n%\\begin{align}\n%%\\label{eqn:upperx}\n%\\hat{\\tau}_{x}(d_{n}) &= \\tau_{1}(d_{n})-\\frac{({d}^{(t)}_{n})^{2}}{2}+\\frac{a\\lambda^2}{2}-{d}^{(t)}_{n}\\x_{a_n}^{T}(\\w_{x}-\\w_{x}^{(t)})\\nonumber,\n%\\end{align}\n%where $\\w_{x}^{(t)}$ is the value of $\\w_{x}$ at the $t$th iteration and ${d}^{(t)}_{n} = (\\w^{(t)}_{x})^{T}\\x_{a_n}-\\w_{y}^{T}\\y_{b_n}$.\n%\n%\n%Similarly, the convex upper bound of $\\tau(d_{n})$ \\wrt~$\\w_{y}$ at the $t$th iteration is:\n%\\begin{align}\n%%\\label{eqn:uppery}\n%\\hat{\\tau}_{y}(d_{n}) &= \\tau_{1}(d_{n})-\\frac{({d}^{(t)}_{n})^{2}}{2}+\\frac{a\\lambda^2}{2}+{d}^{(t)}_{n}\\y_{b_n}^{T}(\\w_{y}-\\w_{y}^{(t)}),\\nonumber\n%\\end{align}\n%where $\\w_{y}^{(t)}$ is the value of $\\w_{y}$ at the $t$th iteration and ${d}^{(t)}_{n} = \\w_{x}^{T}\\x_{a_n}-(\\w^{(t)}_{y})^{T}\\y_{b_n}$.\n%%The convex upper bound \\wrt $\\w_{y}$ is:\n%%\\begin{align}\n%%\\hat{\\tau}(n) &= \\tau_{1}(n)-\\frac{1}{2}(\\hat{d}^{(t)}_{n})^{2}+\\frac{a\\lambda^2}{2}+d^{(t)}_{n}\\y_{b_n}^{T}(\\w_{2}-\\w_{2}^{t})\\nonumber,\n%%\\end{align}\n%%where $\\hat{d}^{(t)}_{n} = \\w_{1}^{T}\\x_{a_n}-(\\w^{(t)}_{2})^{T}\\y_{b_n}$.\n\n\n%*******************************************************************************\n\\subsection{Optimization}\n\nThough the objective function (\\ref{eqn:loss}) is nonconvex \\wrt $\\w_{x}$ and $\\w_{y}$, we can optimize it \\wrt~$\\w_{x}$ and $\\w_{y}$ in an alternating manner. Take $\\w_{x}$ for example, we remove the irrelevant terms and get the following objective:\n\\begin{align}\n\\frac{1}{I}\\sum\\limits_{i=1}^{I}\\ell_{i}^ {x}+\\frac{\\lambda_{x}}{2}\\|\\w_{x}\\|^{2}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\ell_{n}^{*},\n\\label{obj:x}\n\\end{align}\nwhere\n\\begin{align}\n\\ell_{i}^{x}=\\left\\{ \\begin{array}{ll}\n         0 & \\mbox{if ~}|\\w_{x}^{T}\\x_{i}| \\ge 1 \\\\\n         1- \\w_{x}^{T}\\x_{i} & \\mbox{if ~}0\\le\\w_{x}^{T}\\x_{i} < 1 \\\\\n         1+\\w_{x}^{T}\\x_{i} & \\mbox{if ~} -1 <\\w_{x}^{T}\\x_{i}<0\\nonumber\n                          \\end{array} \\right..\n%\n\\end{align}\n\nIt is easy to realize that the objective function~(\\ref{obj:x}) can be expressed as a difference of two convex functions in different cases. As a consequence, we can use \\mbox{CCCP} to solve the non-convex optimization problem iteratively with each iteration minimizing a convex upper bound of the original objective function.\n\nBriefly speaking, given an objective function $f_{0}(x)-g_{0}(x)$ where both $f_{0}$ and $g_{0}$ are convex, \\mbox{CCCP} works iteratively as follows.  The variable $x$ is first randomly initialized to $x^{(0)}$.  At the $t$th iteration, \\mbox{CCCP} minimizes the following convex upper bound of $f_{0}(x)-g_{0}(x)$ at location $x^{(t)}$:\n$$f_{0}(x)-\\big(g_{0}(x^{(t)})+\\partial_{x}g_{0}(x^{(t)})(x-x^{(t)})\\big),$$\nwhere $\\partial_{x}g_{0}(x^{(t)})$ is the first derivative of $g(x)$ at $x^{(t)}$. This optimization problem can be solved using any convex optimization solver to obtain $x^{(t+1)}$.  Given an initial value $x^{(0)}$, the solution sequence $\\{x^{(t)}\\}$ found by \\mbox{CCCP} is guaranteed to reach a local minimum or a saddle point.\n\nFor our problem, the optimization problem at the $t$th iteration is minimizing the following upper bound of Equation~(\\ref{obj:x}) \\wrt $\\w_x$:\n\\begin{align}\n\\mathcal{O}_{x}=\\frac{\\lambda_{x}\\|\\w_{x}\\|^{2}}{2}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\left(s_{n}d_{n}^{2}+(1-s_{n})\\zeta^{x}_{n}\\right) + \\frac{1}{I}\\sum\\limits_{i=1}^{I}\\ell_{i}^{x},\n\\label{eqn:objx}\n\\end{align}\nwhere $\\zeta^{x}_{n} = \\tau_{1}(d_{n})-\\tau_{2}(d_{n}^{(t)})-{d}^{(t)}_{n}\\x_{a_n}^{T}(\\w_{x}-\\w_{x}^{(t)}),{d}^{(t)}_{n} = (\\w^{(t)}_{x})^{T}\\x_{a_n}-\\w_{y}^{T}\\y_{b_n},$\n%\\begin{align}\n%\\iota_{i}^{x}=& \\left\\{ \\begin{array}{ll}\n%      0 & \\mbox{if ~}|\\w_{x}^{T}\\x_{i}| \\ge 1 \\\\\n%      1-\\left(|(\\w^{(t)}_{x})^{T}\\x_{i}|+\\sgn\\left((\\w^{(t)}_{x})^{T}\\x_{i}\\right)\\x_{i}^{T}(\\w_{x}-\\w_{x}^{(t)})\\right)& \\mbox{if ~} |\\w_{x}^{T}\\x_{i}|<1\\nonumber\n%                       \\end{array} \\right.,\n%\\end{align}\nand $\\w_{x}^{(t)}$ is the value of $\\w_{x}$ at the $t$th iteration.\n\n%Note that we use subgradient of the absolute function since it is non-differentiable at some locations.\n%where $\\zeta^{x}_{n} = \\tau_{1}(d_{n})-\\tau_{2}(d_{n}^{(t)})-{d}^{(t)}_{n}\\x_{a_n}^{T}(\\w_{x}-\\w_{x}^{(t)})$, $\\iota_{i}^{x}=|(\\w^{(t)}_{x})^{T}\\x_{i}|+\\sgn((\\w^{(t)}_{x})^{T}\\x_{i})\\x_{i}^{T}(\\w_{x}-\\w_{x}^{(t)})$, $\\w_{x}^{(t)}$ is the value of $\\w_{x}$ at the $t$th iteration and ${d}^{(t)}_{n} = (\\w^{(t)}_{x})^{T}\\x_{a_n}-\\w_{y}^{T}\\y_{b_n}$.\n\n%For each vector $\\w_{x}$ or $\\w_{y}$, the corresponding convex upper bound at the current location is minimized.\n%\\footnote{*** What do you mean by a new objective?  The objective function remains unchanged.  You are just taking a coordinate descent approach by optimizing the SAME objective function but with respect to DIFFERENT optimization variables. Answer: The convex upper bound \\wrt different optimization variables are different, because the DC part is replaced by Taylor expansions at different locations.}\nTo find a local optimal solution of problem~(\\ref{eqn:objx}), we can use any gradient based methods. In this work, we develop a stochastic gradient solver based on Pegasos~\\cite{shalev2007icml}, which is known to be one of the fastest solvers for margin-based classifiers. Specifically, we randomly select $k$ point from each modality and $l$ point pairs to evaluate the gradient at each iteration. %Note that since the subproblem in each \\mbox{CCCP} iteration is convex, in fact any off-the-shelf solver could be used.  We use the aforementioned solver due mainly to its efficiency. \n%\\footnote{*** The logic of this paragraph is confusing.  First, the objective function is always the same.  Alternating between $\\w_x$ and $\\w_y$ is just the nature of the coordinate descent procedure.  Second, since the optimization problem in each CCCP iteration is convex, in principle any off-the-shelf solver can give the optimal solution.  However, the stochastic subgradient solver is used here for the efficiency concern.}\n\n% each \\mbox{CCCP} iteration, the objective involved is convex and any . In this paper, we  proposed by. \n\n%with respect to their convex upper bound, respectively.\n\n%At the $t$th iteration, the optimization problem \\wrt~$\\w_{x}$ uses the following objective function which includes only those terms in $\\mathcal{O}$ that depend on $\\w_{x}$:\n%\\begin{align}\n%\\mathcal{O}_{x}\n%=& \\frac{1}{I}\\sum\\limits_{i=1}^{I}\\big[1-|\\w_{x}^{T}\\x|\\big]_{+}+\\frac{\\lambda_{x}}{2}\\|\\w_{x}\\|^{2}\\nonumber\\\\\n%&+\\gamma\\sum_{n=1}^{N}\\omega_{n}\\left(s_{n}d_{n}^{2}+(1-s_{n})\\hat{\\tau}_{x}(d_{n})\\right).\n%\\label{eqn:objx}\n%\\end{align}\n\nThe key step of our method is to evaluate the gradient of objective function~(\\ref{eqn:objx}) \\wrt~$\\w_{x}$, which can be computed as\n\\begin{align}\n\\frac{\\partial \\mathcal{O}_{x}}{\\partial \\w_{x} }=2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\x_{a_n}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{x}+\\lambda_{x}\\w_{x}- \\frac{1}{I}\\sum\\limits_{i=1}^{I}\\pii^{x}_{i},\n\\end{align}\n%\\begin{align}\n%\\frac{\\partial \\mathcal{O}_{x}}{\\partial \\w_{x} }=\\left\\{ \\begin{array}{ll}\n%      2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\x_{a_n}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{x}+\\lambda_{x}\\w_{x} & \\mbox{if ~}|\\w_{x}^{T}\\x| \\ge 1 \\\\\n%      2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\x_{a_n}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{x}+\\lambda_{x}\\w_{x}- \\frac{1}{I}\\sum\\limits_{i=1}^{I}\\left(\\sgn((\\w^{(t)}_{x})^{T}\\x_{i})\\x_{i}\\right)& \\mbox{if ~} |\\w_{x}^{T}\\x|<1\\nonumber\n%                       \\end{array} \\right.\n%\\end{align}\nwhere $\\muu_{n}^{x}=(1-s_{n}) \\left(\\frac{\\partial \\tau_1}{\\partial d_{n}}-{d}^{(t)}_{n}\\right)\\x_{a_n} $,\n\\begin{align}\n\\frac{\\partial \\tau_1}{\\partial d_{n}} & =\\left\\{ \\begin{array}{ll}\n         0 & \\mbox{if ~} |d_{n}| \\le \\lambda \\\\\n         \\frac{ad_{n}-2a\\lambda\\sgn(d_{n})}{(a-1)}& \\mbox{if ~}\\lambda < |d_{n}|\\le a\\lambda\\\\\n         d_{n} & \\mbox{if ~}a\\lambda<|d_{n}|.\\nonumber\n                          \\end{array} \\right.\\ \\mbox{and} \\ \n                          \\pii^{x}_{i}=\\left\\{ \\begin{array}{ll}\n                                0 & \\mbox{if ~}|\\w_{x}^{T}\\x_{i}| \\ge 1 \\\\\n                                \\sgn\\left(\\w^{T}_{x}\\x_{i}\\right)\\x_{i}& \\mbox{if ~} |\\w_{x}^{T}\\x_{i}|<1\\nonumber\n                                                 \\end{array} \\right..\n\\end{align}\n\n%To update $\\w_{x}$, we use \\mbox{CCCP} coupled with stochastic gradient descent (\\mbox{SGD})~\\cite{bottou2007nips}. Specifically, at one \\mbox{CCCP} iteration, the objective function for $\\w_{x}$ is:\n\n%Then we use stochastic gradient descent to find a local minimum, which is also a global minimum, of $\\mathcal{L}_{x}$. We note that at some locations, the gradient of $f(x) = |x|$ may not exist, and we use subgradient $\\nabla f(x) = \\sgn(x)$ instead.\n\nSimilarly, the objective function for the optimization problem \\wrt~$\\w_{y}$ at the $t$th \\mbox{CCCP} iteration is:\n\\begin{align}\n\\mathcal{O}_{y}=\\frac{\\lambda_{y}\\|\\w_{y}\\|^{2}}{2}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\left(s_{n}d_{n}^{2}+(1-s_{n})\\zeta^{y}_{n}\\right) + \\frac{1}{J}\\sum\\limits_{j=1}^{I}\\ell_{j}^{y},\n\\label{eqn:objy}\n\\end{align}\nwhere $\\zeta^{y}_{n} = \\tau_{1}(d_{n})-\\tau_{2}(d_{n}^{(t)})+{d}^{(t)}_{n}\\y_{b_n}^{T}(\\w_{y}-\\w_{y}^{(t)}), {d}^{(t)}_{n} = \\w_{x}^{T}\\x_{a_n}-(\\w^{(t)}_{y})^{T}\\y_{b_n}$, $\\w_{y}^{(t)}$ is the value of $\\w_{y}$ at the $t$th iteration and \n\\begin{align}\n\\ell_{j}^{y}=\\left\\{ \\begin{array}{ll}\n         0 & \\mbox{if ~}|\\w_{y}^{T}\\y_{j}| \\ge 1 \\\\\n         1- \\w_{y}^{T}\\y_{j} & \\mbox{if ~}0\\le\\w_{y}^{T}\\y_{j} < 1 \\\\\n         1+\\w_{y}^{T}\\y_{j} & \\mbox{if ~} -1 <\\w_{y}^{T}\\y_{j}<0\\nonumber\n                          \\end{array} \\right..\n%\n\\end{align}\n%\\begin{align}\n%\\iota_{j}^{y}=& \\left\\{ \\begin{array}{ll}\n%      0 & \\mbox{if ~}|\\w_{y}^{T}\\y_{j}| \\ge 1 \\\\\n%      1-\\left(|(\\w^{(t)}_{y})^{T}\\y_{j}|+\\sgn\\left((\\w^{(t)}_{y})^{T}\\y_{j}\\right)\\y_{j}^{T}(\\w_{y}-\\w_{y}^{(t)})\\right)& \\mbox{if ~} |\\w_{y}^{T}\\y_{j}|<1\\nonumber\n%                       \\end{array} \\right.,\n%%\\label{eqn:objx}\n%\\end{align}\n\n\n%\\begin{align}\n%\\mathcal{O}_{y}=\\left\\{ \\begin{array}{ll}\n%      \\frac{\\lambda_{y}\\|\\w_{y}\\|^{2}}{2}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\left(s_{n}d_{n}^{2}+(1-s_{n})\\zeta^{y}_{n}\\right) & \\mbox{if ~}|\\w_{y}^{T}\\y| \\ge 1 \\\\\n%      1+\\frac{\\lambda_{y}\\|\\w_{y}\\|^{2}}{2}+\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\left(s_{n}d_{n}^{2}+(1-s_{n})\\zeta^{y}_{n}\\right) - \\frac{1}{J}\\sum\\limits_{j=1}^{J}\\iota_{j}^{y}& \\mbox{if ~} |\\w_{y}^{T}\\y|<1\\nonumber\n%                       \\end{array} \\right.\n%%\\label{eqn:objx}\n%\\end{align}\n%where $\\zeta^{y}_{n} = \\tau_{1}(d_{n})-\\tau_{2}(d_{n}^{(t)})+{d}^{(t)}_{n}\\y_{b_n}^{T}(\\w_{y}-\\w_{y}^{(t)})$, $\\iota_{j}^{y}=|(\\w^{(t)}_{y})^{T}\\y_{i}|+\\sgn((\\w^{(t)}_{y})^{T}\\y_{i})\\y_{i}^{T}(\\w_{y}-\\w_{y}^{(t)})$, $\\w_{y}^{(t)}$ is the value of $\\w_{y}$ at the $t$th iteration and ${d}^{(t)}_{n} = \\w_{x}^{T}\\x_{a_n}-(\\w^{(t)}_{y})^{T}\\y_{b_n}$.\n\nThe corresponding gradient is given by\n\\begin{align}\n\\frac{\\partial \\mathcal{O}_{y}}{\\partial \\w_{y} }=-2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\y_{b_n}-\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{y}+\\lambda_{y}\\w_{y}- \\frac{1}{J}\\sum\\limits_{j=1}^{I}\n\\pii^{y}_{j},\n\\end{align}\nwhere $\\muu_{n}^{y}=(1-s_{n}) \\left(\\frac{\\partial \\tau_1}{\\partial d_{n}}-{d}^{(t)}_{n}\\right)\\y_{b_n}$ and\n\\begin{align}\n\\pii^{y}_{j}=\\left\\{ \\begin{array}{ll}\n    0 & \\mbox{if ~}|\\w_{y}^{T}\\y_{j}| \\ge 1 \\\\\n    \\sgn\\left(\\w_{y}^{T}\\y_{j}\\right)\\y_{j}& \\mbox{if ~} |\\w_{y}^{T}\\y_{j}|<1\\nonumber\n                                     \\end{array} \\right..\n\\end{align}\n\n%\\begin{align}\n%\\frac{\\partial \\mathcal{O}_{y}}{\\partial \\w_{y} }=\\left\\{ \\begin{array}{ll}\n%      -2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\y_{b_n}-\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{y}+\\lambda_{y}\\w_{y} & \\mbox{if ~}|\\w_{y}^{T}\\y| \\ge 1 \\\\\n%      -2\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}s_{n}d_{n}\\y_{b_n}-\\gamma\\sum\\limits_{n=1}^{N}\\omega_{n}\\muu_{n}^{y}+\\lambda_{y}\\w_{y}- \\frac{1}{J}\\sum\\limits_{j=1}^{I}\\left(\\sgn((\\w^{(t)}_{y})^{T}\\y_{j})\\y_{j}\\right)& \\mbox{if ~} |\\w_{y}^{T}\\y|<1\\nonumber\n%                       \\end{array} \\right.\n%\\end{align}\n%where $\\muu_{n}^{y}=(1-s_{n}) \\left(\\frac{\\partial \\tau_1}{\\partial d_{n}}-{d}^{(t)}_{n}\\right)\\y_{b_n} $.\n\n%The optimization for each bit is stochastic gradient descent, and we will use subgradient~\\cite{boyd2004convex} for those hinge loss functions. We should list the gradient here.\n\n\n\n%*******************************************************************************\n\\subsection{Algorithm}\n\nSo far we have only discussed how to learn the hash functions for one bit of the hash codes.  To learn the hash functions for multiple bits, one could repeat the same procedure and treat the learning for each bit independently.  However, as reported in previous studies~\\cite{wang2010cvpr,liu2011icml}, it is very important to take into consideration the relationships between different bits in \\mbox{HFL}. In other words, to learn compact hash codes, we should coordinate the learning of hash functions for different bits.\n\nTo this end, we take the standard \\mbox{AdaBoost}~\\cite{freund1997adaboost} approach to learn multiple bits sequentially.\n%\\footnote{*** Has this same approach been used for \\mbox{HFL} by others? ~\\cite{bronstein2010cvpr} also used boosting to update $\\omega_n$ for each pair, but their rule is different from ours.}\nIntuitively, this approach allows learning of the hash functions in later stages to be aware of the bias introduced by their antecedents.  The overall algorithm of \\mbox{CRH} is summarized in Algorithm~\\ref{alg:CRH}. %\\footnote{*** You are abusing the symbols $w$ and $N$ (which have been used before), leading to confusion.}\n\n\\begin{algorithm}[htb]\n   \\caption{Co-Regularized Hashing}\n   \\label{alg:CRH}\n\\begin{algorithmic}\n%\\begin{multicols}{2}\n   \\STATE {\\bfseries Input:} \\\\\n   $\\mathcal{X},\\mathcal{Y}$ -- multimodal data \\\\\n   $\\Theta$ -- inter-modality point pairs\\\\\n   $K$ -- code length\\\\\n   $\\lambda_{x},\\lambda_{y},\\gamma$ -- regularization parameters\\\\\n   $a,\\lambda$ -- parameters for \\mbox{SCISD} function\n   \\STATE {\\bfseries Output:} \\\\\n   $\\w_{x}^{(k)}, k=1,\\dots, K$ -- projection vectors for $\\mathcal{X}$ \\\\\n      $\\w_{y}^{(k)}, k=1,\\dots, K$ -- projection vectors for $\\mathcal{Y}$ \n   \\STATE\n\t\\STATE {\\bfseries Procedure:}\n%   \\STATE Initialize $noChange = true$.\n   \\STATE Initialize $\\omega_{n}^{(1)} = 1/N, \\, \\forall n \\in \\{1,2,\\dots,N\\}$.\n   \\FOR{$k=1$ {\\bfseries to} $K$}\n%   \\IF{$x_i > x_{i+1}$}\n   \\REPEAT\n   \\STATE Optimize Equation~(\\ref{eqn:objx}) to get $\\w_{x}^{(k)}$;\n   \\STATE Optimize Equation~(\\ref{eqn:objy}) to get $\\w_{y}^{(k)}$;\n   \\UNTIL{convergence.}\n\n   \\STATE Compute error of current hash functions:\n   \\begin{align}\n   \\epsilon_{k} = \\sum\\nolimits_{n=1}^{N}\\omega^{(k)}_{n}\\I_{[s_{n}\\ne h_{n} ]},\\nonumber\n   \\end{align}\n   where $\\I_{[a]} = 1$ if $a$ is true and $\\I_{[a]} = 0$ otherwise, and\n   \\begin{align}\n   h_{n} & = \\left\\{ \\begin{array}{ll}\n            1 & f(\\x_{a_n}) = g(\\y_{b_n}) \\\\\n            0 & f(\\x_{a_n}) \\ne g(\\y_{b_n})\\nonumber\n                             \\end{array} \\right..\n   \\end{align}\n   \\STATE Set $\\beta_{k} = \\epsilon_{k}/(1-\\epsilon_{k}).$\n   \\STATE Update the weight for each point pair:\n   $$\\omega^{(k+1)}_{n} =\\omega^{(k)}_{n}\\beta_{k}^{1-\\I_{[s_{n}\\ne h_{n}]}}.$$\n%   \\ENDIF\n   \\ENDFOR\n%\\end{multicols}\n\\end{algorithmic}\n\\end{algorithm}\n\nThe first computationally expensive part of the algorithm is to evaluate the gradients. The time complexity is $O((k+l)d)$, where $d$ is the data dimensionality, and $k$ and $l$ are the numbers of random points and random pairs, respectively, for the stochastic gradient solver. In our experiments, we set $k=1$ and $l=500$.  We notice that further increasing the two numbers brings no significant performance improvement. We leave the theoretical study of the impact of $k$ and $l$ to our future work. Another major computational cost comes from updating the weights of the inter-modality point pairs.  The time complexity is $O(dN)$, where $N$ is the number of inter-modality point pairs.\n\nTo summarize, our algorithm scales linearly with the number of inter-modality point pairs and the data dimensionality. In practice, the number of inter-modality point pairs is usually small, making our algorithm very efficient.\n%\\begin{figure}[htb] %\\vspace{-0.3cm}\n%\\begin{wrapfigure}{r}{0.6\\textwidth}\n%\\subfigure[Upating $\\w_{x}$]{\\label{fig:convergex}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.4cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/convergence_x, width=0.8\\textwidth} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Upating $\\w_{y}$]{\\label{fig:convergey}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.4cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/convergence_y, width=0.8\\textwidth} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%%\\vspace{-0.25cm}\n%\\caption{Illustration of convergence behavior}\\label{fig:converge}\\end{wrapfigure}\n%%\\vspace{-0.4cm}\n%\\end{figure}\n\n%\\begin{multicols}{2}\n%\\begin{minipage}[b]{0.4\\linewidth}\n%In Figure~\\ref{fig:converge}, we empirically show the convergence behavior of our algorithm by plotting the objective function values and the corresponding upper bounds \\wrt~the number of iterations. We can see that the bounds are very tight and our algorithm converges very fast and becomes stable after 20 iterations.\n%\\end{minipage}\n%\\begin{minipage}[b]{0.3\\linewidth} %\\vspace{-0.4cm}\n%        \\centering %\\vspace{-1cm}\n%        \\epsfig{figure=fig/convergence_x, width=0.8\\textwidth} %\\vspace{-1.5cm}\n%        \\caption{Upating $\\w_{x}$}\n%    \\end{minipage}\n%\\begin{minipage}[b]{0.3\\linewidth} %\\vspace{-0.4cm}\n%        \\centering %\\vspace{-1cm}\n%        \\epsfig{figure=fig/convergence_y, width=0.8\\textwidth} %\\vspace{-1.5cm}\n%        \\caption{Upating $\\w_{x}$}\n%    \\end{minipage}\n%%\\begin{minipage}{0.65\\linewidth}\n\n\n\n%\\end{minipage}\n%\\end{multicols}\n%*******************************************************************************\n\\subsection{Extensions}\n\\label{sec:moel:ext}\n%\\subsection{Kernelization}\nWe briefly discuss two possible extensions of \\mbox{CRH} in this subsection.  First, we note that it is easy to extend \\mbox{CRH} to learn nonlinear hash functions via the kernel trick~\\cite{shawe2004book}. Specifically, according to the generalized representer theorem~\\cite{scholkopf2001colt}, we can represent the projection vectors $\\w_{x}$ and $\\w_{y}$ as\n\\begin{align}\n\\w_{x} = \\sum\\nolimits_{i=1}^{I}\\alpha_{i}\\phi_{x}(\\x_i) \\ \\ \\mbox{and} \\ \\ \\w_{y} = \\sum\\nolimits_{j=1}^{J}\\beta_{j}\\phi_{y}(\\y_j),\\nonumber\n\\end{align}\nwhere $\\phi_{x}(\\cdot)$ and $\\phi_{y}(\\cdot)$ are kernel-induced feature maps for modalities $\\mathcal{X}$ and $\\mathcal{Y}$, respectively. Then the objective function~(\\ref{eqn:loss}) can be expressed in kernel form and kernel-based hash functions can be learned by minimizing a new but very similar objective function.\n%Because we do not use kernel in our experiments and discussion, and kernel is extremely important for machine learning and vision problems, we should clearly talk about the kernel extension and convince the reviewers.\n\n%\\subsection{Beyond Two Modalities}\n\nAnother possible extension is to make \\mbox{CRH} support more than two modalities. Taking a new modality $\\mathcal{Z}$ for example, we need to incorporate into Equation~(\\ref{eqn:loss}) the following terms: loss and regularization terms for $\\mathcal{Z}$, and all pairwise loss terms involving $\\mathcal{Z} $ and other modalities, e.g., $\\mathcal{X} $ and $\\mathcal{Y}$.\n\nFor both extensions, it is straightforward to adapt the algorithm presented above to solve the new optimization problems.\n\n%*******************************************************************************\n\\subsection{Discussion}\n\\mbox{CRH} is closely related to a recent multimodal metric learning method called MultiNPP~\\cite{quadrianto2011icml}, because \\mbox{CRH} uses a loss function for inter-modality point pairs which is similar to MultiNPP. However, \\mbox{CRH} is a general framework and other loss functions for inter-modality point pairs can also be adopted. The two methods have at least three significant differences.  First, our focus is on \\mbox{HFL} while MultiNPP is on metric learning through embedding. Second, in addition to the inter-modality loss term, the objective function in \\mbox{CRH} includes two intra-modality loss terms for large margin HFL while MultiNPP only has a loss term for the inter-modality point pairs.\nThird, CRH uses boosting to sequentially learn the hash functions but MultiNPP does not take this aspect into consideration. \n\nAs discussed briefly in~\\cite{quadrianto2011icml}, one may first use MultiNPP to map multimodal data into a common real space and then apply any unimodal \\mbox{HFL} method for multimodal hashing. However, this naive two-stage approach has some limitations.  First, both stages can introduce information loss which impairs the quality of the hash functions learned.  Second, a two-stage approach generally needs more computational resources.  These two limitations can be overcome by using a one-stage method such as \\mbox{CRH}.\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\\section{Experiments}\n\\label{crh:exps}\n\n%-------------------------------------------------------------------------------\n\\subsection{Experimental Settings}\n\nIn our experiments, we compare \\mbox{CRH} with two state-of-the-art multimodal hashing methods, namely, \\mbox{CMSSH}~\\cite{bronstein2010cvpr}\\footnote{We used the implementation generously provided by the authors.} and \\mbox{CVH}~\\cite{kumar2011ijcai},\\footnote{We implemented the method ourselves because the code is not publicly available.} for two crossmodal retrieval tasks: (1)~\\textit{image query vs.\\ text database}; (2)~\\textit{text query vs.\\ image database}. The goal of each retrieval task is to find from the text (image) database the nearest neighbors for the image (text) query.\n\n%\\footnote{We have tried several two-stage methods which combine  \\mbox{Multi-NPP} and some representative unimodal \\mbox{HFL} methods, e.g., \\mbox{Multi-NPP+SH} and \\mbox{Multi-NPP+LSH}, but did not obtain comparable results. We do not report them in the paper due to page limitations.}\n\nWe use two benchmark data sets which are, to the best of our knowledge, the largest fully paired and labeled multimodal data sets. We further divide each data set into a database set and a query set. To train the models, we randomly select a group of documents from the database set to form the training set. Moreover, we randomly select 0.1\\% of the point pairs from the training set. For fair comparison, all models are trained on the same training set and the experiments are repeated 5 times.\n%\\footnote{*** Do you mean: we randomly select 0.1\\% of the point pairs from the training set?}\n%$$\\mbox{AP} = \\frac{1}{L}\\sum_{r=1}^{R} P(r) \\, \\delta(r),$$\n\nThe mean average precision (\\mbox{mAP}) is used as the performance measure. To compute the \\mbox{mAP}, we first evaluate the average precision (\\mbox{AP}) of a set of $R$ retrieved documents as $\\mbox{AP} = \\frac{1}{L}\\sum_{r=1}^{R} P(r) \\, \\delta(r)$, where $L$ is the number of true neighbors in the retrieved set, $P(r)$ denotes the precision of the top $r$ retrieved documents, and $\\delta(r)=1$ if the $r$th retrieved document is a true neighbor and $\\delta(r)=0$ otherwise.  The \\mbox{mAP} is then computed by averaging the \\mbox{AP} values over all the queries in the query set. The larger the \\mbox{mAP}, the better the performance. In the experiments, we set $R=50$. Besides, we also report the precision and recall within a fixed Hamming radius.\n\nWe use cross-validation to choose the parameters for \\mbox{CRH} and find that the model performance is only mildly sensitive to the parameters. As a result, in all experiments, we set $\\lambda_{x}=0.01, \\lambda_{y}=0.01, \\gamma = 1000, a=3.7$, and $\\lambda=1/a$. Besides, unless specified otherwise, we fix the training set size to $2{,}000$ and the code length $K$ to 24.\n\n%Our model is mildly sensitive to the parameters. \n\n%*******************************************************************************\n\\subsection{Results on \\mbox{Wiki} Data Set}\n\nThe \\mbox{Wiki} data set, generated from Wikipedia featured articles, consists of $2{,}866$ image-text pairs.\\footnote{\\url{http://www.svcl.ucsd.edu/projects/crossmodal/}} In each pair, the text is an article describing some events or people and the image is closely related to the content of the article. The images are represented by 128-dimensional \\mbox{SIFT}~\\cite{lowe2004ijcv} feature vectors, while the text articles are represented by the probability distributions over 10 topics learned by a latent Dirichlet allocation (\\mbox{LDA}) model~\\cite{blei2003jmlr}. Each pair is labeled with one of 10 semantic classes.  We simply use these class labels to identify the neighbors. Moreover, we use 80\\% of the data as the database set and the remaining 20\\% to form the query set.\n\nThe mAP values of the three methods and a method based on binarizing MultiNPP (Bin-MultiNPP) are reported in Table~\\ref{crh:table:wiki-compare-map}.  We can see that \\mbox{CRH} outperforms \\mbox{CVH} and \\mbox{CMSSH} under all settings and \\mbox{CVH} performs slightly better than \\mbox{CMSSH}.  We note that \\mbox{CMSSH} ignores the intra-modality relational information and \\mbox{CVH} simply treats each bit independently.  Hence the performance difference is expected. Also, we can see that binarizing MultiNPP directly always achieves the worst performance.\n\n%\\vspace{-0.4cm}\n%\\begin{table}[htb] \n%\\caption{\\mbox{mAP} comparison on \\mbox{Wiki}} %\\vspace{0.05in}\n%\\label{crh:table:wiki-compare-map}\n%\\begin{center}\n%\\begin{tabular}{|c|c|c|c|}\n%\\toprule[1pt]\\addlinespace[0pt]\n%\\multirow{2}{7em}{\\centering Task}&\\multirow{2}{1.5cm}{\\centering Method}&\\multicolumn{2}{|c|}{Code Length}\\\\\n%\\cline{3-4}\n%& &  $K=24$&  $K=48$\\\\\n%\\addlinespace[0pt]\\midrule[1pt]\\addlinespace[0pt]\n%\\multirow{3}{7em}{\\centering Image Query \\\\ vs. \\\\Text Database}\n%&\\mbox{CRH}&${\\bf 0.2607}$&${\\bf 0.2393}$\\\\\n%\\cline{2-4}\n%&\\mbox{CVH}&${{0.1843}}$&${0.1894}$\\\\\n%\\cline{2-4}\n%&\\mbox{CMSSH}&${0.1785}$&${0.1666}$\\\\\n%%\\cline{2-4}\n%%&\\mbox{MultiNPP+SH}&${0.1577}$&${0.1577}$\\\\\n%\\addlinespace[0pt]\\midrule[0.7pt]\\addlinespace[0pt]\n%\\multirow{3}{7em}{\\centering Text Query \\\\ vs. \\\\Image Database}\n%&\\mbox{CRH}&${\\bf{0.3407}}$&${\\bf 0.3167}$\\\\\n%\\cline{2-4}\n%&\\mbox{CVH}&${0.2839}$&${0.1812}$\\\\\n%\\cline{2-4}\n%&\\mbox{CMSSH}&${0.1977}$&${0.2030}$\\\\\n%%\\cline{2-4}\n%%&\\mbox{MultiNPP+SH}&${0.1577}$&${0.1577}$\\\\\n%\\addlinespace[0pt]\\bottomrule[1pt]\n%\\end{tabular} %\\vspace{-0.25cm}\n%\\end{center}\n%\\end{table}\n\n\\begin{table}[htb] \n\\caption{\\mbox{mAP} comparison on \\mbox{Wiki}}\\label{crh:table:wiki-compare-map}\\vspace{-0.5cm}\n\\begin{center}\n{\\small\n\\begin{tabular}{|c|c|c|c|c|}\n\\toprule[1pt]\\addlinespace[0pt]\n\\multirow{2}{7em}{\\centering Task}&\\multirow{2}{1.5cm}{\\centering Method}&\\multicolumn{3}{|c|}{Code Length}\\\\\n\\cline{3-5}\n& &  $K=24$&  $K=48$&  $K=64$\\\\\n\\addlinespace[0pt]\\midrule[1pt]\\addlinespace[0pt]\n\\multirow{4}{7em}{\\centering Image Query \\\\ vs. \\\\Text Database}\n&\\mbox{CRH}&${\\bf 0.2537\\pm0.0206}$&${\\bf 0.2399\\pm0.0185}$&${\\bf 0.2392\\pm0.0131}$\\\\\n\\cline{2-5}\n&\\mbox{CVH}&${{0.2043\\pm0.0150}}$&${0.1788\\pm 0.0149}$&${0.1732\\pm0.0072}$\\\\\n\\cline{2-5}\n&\\mbox{CMSSH}&${0.1965\\pm 0.0123}$&${0.1780\\pm0.0080}$&${0.1624\\pm0.0073}$\\\\\n\\cline{2-5}\n&\\mbox{Bin-MultiNPP}&${0.1790\\pm 0.0202}$&${0.1672\\pm0.0130}$&${0.1628\\pm0.0175}$\\\\\n\\addlinespace[0pt]\\midrule[0.7pt]\\addlinespace[0pt]\n\\multirow{4}{7em}{\\centering Text Query \\\\ vs. \\\\Image Database}\n&\\mbox{CRH}&${\\bf{0.2896\\pm0.0214}}$&${\\bf 0.2882\\pm0.0261}$&${\\bf 0.2989\\pm0.0293}$\\\\\n\\cline{2-5}\n&\\mbox{CVH}&${0.2714\\pm0.0164}$&${0.2304\\pm0.0104}$&${0.2156\\pm0.0202}$\\\\\n\\cline{2-5}\n&\\mbox{CMSSH}&${0.2179\\pm 0.0161}$&${0.2094\\pm0.0072}$&${0.2040\\pm0.0135}$\\\\\n\\cline{2-5}\n&\\mbox{Bin-MultiNPP}&${0.1925\\pm0.0173}$&${0.1927\\pm0.0284}$&${0.1847\\pm0.0195}$\\\\\n\\addlinespace[0pt]\\bottomrule[1pt]\n\\end{tabular} \\vspace{-0.25cm}\n}\n\\end{center}\n\\end{table}\n\n\\begin{figure}[ht]\n\\begin{center}\n\\subfigure[Varying Code Length]{\\label{crh:fig:wiki-code-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-code-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Varying Code Length]{\\label{crh:fig:wiki-code-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-code-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Varying Training Set]{\\label{crh:fig:wiki-train-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-train-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Varying Training Set]{\\label{crh:fig:wiki-train-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-train-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Pre-Rec Curve]{\\label{crh:fig:wiki-pr-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-pr-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Pre-Rec Curve]{\\label{crh:fig:wiki-pr-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-pr-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Recall Curve]{\\label{crh:fig:wiki-rec-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-rec-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Recall Curve]{\\label{crh:fig:wiki-rec-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/wiki-comp-rec-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}} %\\vspace{-0.2cm}\n\\end{center} \\vspace{-0.5cm}\n\\caption{Results on \\mbox{Wiki}}\\label{crh:fig:wiki-compare-curve}\n\\end{figure}\n\nWe further compare the three methods on several aspects in Figure~\\ref{crh:fig:wiki-compare-curve}. We first vary the code length $K$ and plot the precision within a Hamming radius of 2 in subfigures~\\ref{crh:fig:wiki-code-xy} and~\\ref{crh:fig:wiki-code-yx}. As $K$ increases, the performance of \\mbox{CRH} also improves but the other two methods cannot benefit from increasing $K$. We then vary the size of the training set in subfigures~\\ref{crh:fig:wiki-train-xy} and~\\ref{crh:fig:wiki-train-yx}. Although \\mbox{CVH} performs the best when the training set is small, its performance is gradually surpassed by \\mbox{CRH} as the size increases.  In the remaining subfigures, we plot the precision-recall curves and recall curves for all three methods. It is obvious that \\mbox{CRH} outperforms its two counterparts by a large margin.\n\n%The precision-recall curves and recall curves show that \\mbox{CRH} achieves the best performance. We set the code length $K=24$ and training set size $2{,}000$ to get the figures, if not specifically indicated.\n\n\n%The first row is for the task of \\textit{image query vs.\\ text database} and the second row is for the task of \\textit{text query vs.\\ image database}.\n\n%*******************************************************************************\n\\subsection{Results on \\mbox{Flickr} Data Set}\n\nThe \\mbox{Flickr} data set consists of $186{,}577$ image-tag pairs  pruned from the \\mbox{NUS} data set\\footnote{\\url{http://lms.comp.nus.edu.sg/research/NUS-WIDE.htm}}~\\cite{nus-wide-civr09} by keeping the pairs that belong to one of the 10 largest classes. The images are represented by 500-dimensional \\mbox{SIFT} vectors. To obtain more compact representations of the tags, we perform \\mbox{PCA} on the original tag occurrence features and obtain 1000-dimensional feature vectors. Each pair is annotated by at least one of 10 semantic labels, and two points are defined as neighbors if they share at least one label. We use 99\\% of the data as the database set and the remaining 1\\% to form the query set.\n\n\nThe mAP values of the three methods are reported in Table~\\ref{crh:table:flickr-compare-map}. In the task of image query vs. text database, \\mbox{CRH} performs comparably to \\mbox{CMSSH}, which is better than \\mbox{CVH}. However, in the other task, \\mbox{CRH} achieves the best performance. At the same time, we observe that CRH beat Bin-MultiNPP by a large margin.\n\n\n%\\vspace{-0.5cm}\n%\\begin{table}[htb] %\n%\\caption{\\mbox{mAP} comparison on \\mbox{Flickr}} %\\vspace{0.05in}\n%\\label{crh:table:flickr-compare-map}\n%\\begin{center}\n%\\begin{tabular}{|c|c|c|c|}\n%\\toprule[1pt]\\addlinespace[0pt]\n%\\multirow{2}{7em}{\\centering Task}&\\multirow{2}{1.5cm}{\\centering Method}&\\multicolumn{2}{|c|}{Code Length}\\\\\n%\\cline{3-4}\n%& &  $K=24$&  $K=48$\\\\\n%\\addlinespace[0pt]\\midrule[1pt]\\addlinespace[0pt]\n%\\multirow{3}{7em}{\\centering Image Query \\\\ vs. \\\\Text Database}\n%&\\mbox{CRH}&${\\bf 0.5393}$&${0.5336}$\\\\\n%\\cline{2-4}\n%&\\mbox{CVH}&${{0.4704}}$&${0.4512}$\\\\\n%\\cline{2-4}\n%&\\mbox{CMSSH}&${0.5356}$&${\\bf 0.5361}$\\\\\n%%\\cline{2-4}\n%%&\\mbox{MultiNPP+SH}&${0.}$&${0.}$\\\\\n%\\addlinespace[0pt]\\midrule[0.7pt]\\addlinespace[0pt]\n%\\multirow{3}{7em}{\\centering Text Query \\\\ vs. \\\\Image Database}\n%&\\mbox{CRH}&${\\bf{0.5244}}$&${\\bf 0.5170}$\\\\\n%\\cline{2-4}\n%&\\mbox{CVH}&${0.4560}$&${0.4511}$\\\\\n%\\cline{2-4}\n%&\\mbox{CMSSH}&${0.4970}$&${0.4790}$\\\\\n%%\\cline{2-4}\n%%&\\mbox{MultiNPP+SH}&${0.}$&${0.}$\\\\\n%\\addlinespace[0pt]\\bottomrule[1pt]\n%\\end{tabular}\n%\\end{center} %\n%\\end{table}\n%\\vspace{-0.2cm}\n\n\n\\begin{table}[htb] %\n\\caption{\\mbox{mAP} comparison on \\mbox{Flickr}}\\label{crh:table:flickr-compare-map}\\vspace{-0.5cm}\n\\begin{center}\n{\\small\n\\begin{tabular}{|c|c|c|c|c|}\n\\toprule[1pt]\\addlinespace[0pt]\n\\multirow{2}{7em}{\\centering Task}&\\multirow{2}{1.5cm}{\\centering Method}&\\multicolumn{3}{|c|}{Code Length}\\\\\n\\cline{3-5}\n& &  $K=24$&  $K=48$&  $K=64$\\\\\n\\addlinespace[0pt]\\midrule[1pt]\\addlinespace[0pt]\n\\multirow{4}{7em}{\\centering Image Query \\\\ vs. \\\\Text Database}\n&\\mbox{CRH}&${0.5259\\pm 0.0094}$&${0.4990\\pm 0.0075}$&${\\bf 0.4929\\pm 0.0064}$\\\\\n\\cline{2-5}\n&\\mbox{CVH}&${{0.4717\\pm0.0035}}$&${0.4515\\pm0.0041}$&$0.4471\\pm 0.0023$\\\\\n\\cline{2-5}\n&\\mbox{CMSSH}&${\\bf 0.5287\\pm 0.0123}$&${\\bf 0.5098\\pm0.0141}$&$0.4911\\pm 0.0220$\\\\\n\\cline{2-5}\n&\\mbox{Bin-MultiNPP}&${0.4775\\pm0.0211}$&${0.4527\\pm 0.0143}$&${0.4446\\pm0.0259}$\\\\\n\\addlinespace[0pt]\\midrule[0.7pt]\\addlinespace[0pt]\n\\multirow{4}{7em}{\\centering Text Query \\\\ vs. \\\\Image Database}\n&\\mbox{CRH}&${\\bf{0.5364\\pm 0.0021}}$&${\\bf 0.5185\\pm 0.0050}$&${\\bf 0.5064\\pm 0.0055}$\\\\\n\\cline{2-5}\n&\\mbox{CVH}&${0.4598\\pm0.0020}$&${0.4519\\pm0.0029}$&$0.4477\\pm0.0058$\\\\\n\\cline{2-5}\n&\\mbox{CMSSH}&${0.5029\\pm 0.0321}$&${0.4815\\pm 0.0101}$&$0.4660\\pm0.0298$\\\\\n\\cline{2-5}\n&\\mbox{Bin-MultiNPP}&${0.4767\\pm 0.0147}$&${0.4524\\pm 0.0115}$&${0.4450\\pm0.0125}$\\\\\n\\addlinespace[0pt]\\bottomrule[1pt]\n\\end{tabular}\n}\n\\end{center} %\n\\end{table}\n\nSimilar to the previous subsection, we have conducted a group of experiments to compare the three methods on several aspects and report the results in Figure~\\ref{crh:fig:flickr-compare-curve}. We first compare the precision under different code lengths in subfigures~\\ref{crh:fig:flickr-code-xy} and~\\ref{crh:fig:flickr-code-xy}. In almost all code lengths, \\mbox{CRH} outperforms the other two methods. The results for varying the size of the training set are plotted in subfigures~\\ref{crh:fig:flickr-train-xy} and~\\ref{crh:fig:flickr-train-xy}. As more training data are used, \\mbox{CRH} always performs better but the performance of \\mbox{CVH} and \\mbox{CMSSH} has high variance. Finally, the precision-recall curves and recall curves are shown in the remaining subfigures. Similar to the results on \\mbox{Wiki}, \\mbox{CRH} performs the best. However, the performance gap is smaller here.\n\n%that \\mbox{CRH} achieves the best performance. We set the code length $K=24$ and training set size $2{,}000$ to get the figures, if not specifically indicated.\n\n\\begin{figure}[ht]\n\\begin{center}\n\\subfigure[Varying Code Length]{\\label{crh:fig:flickr-code-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-code-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Varying Code Length]{\\label{crh:fig:flickr-code-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-code-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Varying Training Set]{\\label{crh:fig:flickr-train-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-train-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Varying Training Set]{\\label{crh:fig:flickr-train-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-train-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Pre-Rec Curve]{\\label{crh:fig:flickr-pr-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-pr-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Pre-Rec Curve]{\\label{crh:fig:flickr-pr-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-pr-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\\\\n\\subfigure[Recall Curve]{\\label{crh:fig:flickr-rec-xy}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-rec-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\subfigure[Recall Curve]{\\label{crh:fig:flickr-rec-yx}\n    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%        \\centering\\vspace{-1cm}\n        \\epsfig{figure=fig/crh/flickr-comp-rec-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n    \\end{minipage}}\n\\end{center}\\vspace{-0.5cm}\n\\caption{Results on \\mbox{Flickr}}\\label{crh:fig:flickr-compare-curve}\n %\\vspace{-0.4cm}\n\\end{figure}\n%%\\subsubsection{Discussion}\n%%\\label{MH:exps:disc}\n\n\n%\\subsection{Results on MIRFlickr Data Set}\n%\n%The MIRFlickr data set is ffered by the LIACS Medialab at Leiden University, The Netherlands.\\footnote{\\url{http://press.liacs.nl/mirflickr/}} There are 1 million images downloaded from the flickr.com, and each image is represented by two different descriptors, that is, the 150 dimensional EH descriptor and the 43 dimensional HT descriptor. Each image is also labeled with several tags. There are in total $1{,}386$ tags based on which we define similarity, meaning that we label two images as similar if the share one or more tags and dissimilar otherwise. We randomly choose $5{,}000$ points to form the query set and use the remaining data as the database set.\n%\n%The averaged precision values within the Hamming radius 2 are reported in Table~\\ref{table:flickr1m-compare-precision}.\n%\n%\\begin{table}[htb] %\n%\\caption{Precision comparison on \\mbox{MIRFlickr}}\\label{table:flickr1m-compare-precision} \\vspace{-0.5cm}\n%\\begin{center}\n%{\\small\n%\\begin{tabular}{|c|c|c|c|c|}\n%\\toprule[1pt]\\addlinespace[0pt]\n%\\multirow{2}{7em}{\\centering Task}&\\multirow{2}{1.5cm}{\\centering Method}&\\multicolumn{3}{|c|}{Code Length}\\\\\n%\\cline{3-5}\n%& &  $K=24$&  $K=48$&  $K=64$\\\\\n%\\addlinespace[0pt]\\midrule[1pt]\\addlinespace[0pt]\n%\\multirow{4}{7em}{\\centering Image Query \\\\ vs. \\\\Text Database}\n%&\\mbox{CRH}&${\\bf 0.\\pm 0.}$&${0.\\pm 0.}$&${0.\\pm 0.}$\\\\\n%\\cline{2-5}\n%&\\mbox{CVH}&${{0.}}$&${0.}$&\\\\\n%\\cline{2-5}\n%&\\mbox{CMSSH}&${0.}$&${\\bf 0.}$&\\\\\n%\\cline{2-5}\n%&\\mbox{Bin-MultiNPP}&${0.}$&${0.}$&\\\\\n%\\addlinespace[0pt]\\midrule[0.7pt]\\addlinespace[0pt]\n%\\multirow{4}{7em}{\\centering Text Query \\\\ vs. \\\\Image Database}\n%&\\mbox{CRH}&${\\bf{0.\\pm 0.}}$&${\\bf 0.\\pm 0.}$&${0.\\pm 0.}$\\\\\n%\\cline{2-5}\n%&\\mbox{CVH}&${0.}$&${0.}$&\\\\\n%\\cline{2-5}\n%&\\mbox{CMSSH}&${0.}$&${0.}$&\\\\\n%\\cline{2-5}\n%&\\mbox{Bin-MultiNPP}&${0.}$&${0.}$&\\\\\n%\\addlinespace[0pt]\\bottomrule[1pt]\n%\\end{tabular}\n%}\n%\\end{center} %\n%\\end{table}\n\n%The four different aspects are studied in Figure~\\ref{crh:fig:flickr1m-compare-curve}.\n%\n%\\begin{figure}[ht]\n%\\begin{center}\n%\\subfigure[Varying Code Length]{\\label{crh:fig:flickr1m-code-xy}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-code-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Varying Training Set]{\\label{crh:fig:flickr1m-train-xy}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-train-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Pre-Rec Curve]{\\label{crh:fig:flickr1m-pr-xy}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-pr-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Recall Curve]{\\label{crh:fig:flickr1m-rec-xy}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-rec-xy, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%    \\\\\n%\\subfigure[Varying Code Length]{\\label{crh:fig:flickr1m-code-yx}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-code-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Varying Training Set]{\\label{crh:fig:flickr1m-train-yx}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-train-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Pre-Rec Curve]{\\label{crh:fig:flickr1m-pr-yx}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-pr-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\n%\\subfigure[Recall Curve]{\\label{crh:fig:flickr1m-rec-yx}\n%    \\begin{minipage}[b]{0.45\\linewidth} %\\vspace{-0.3cm}\n%%        \\centering\\vspace{-1cm}\n%        \\epsfig{figure=fig/crh/flickr-comp-rec-yx, width=0.8\\textwidth}%, height=3.4cm} %\\vspace{-1.5cm}\n%    \\end{minipage}}\\vspace{-0.2cm}\n%\\end{center}\n%\\caption{Results on \\mbox{Flickr}}\\label{crh:fig:flickr1m-compare-curve}\n% %\\vspace{-0.4cm}\n%\\end{figure}\n\n%-------------------------------------------------------------------------------\n\\section{Conclusion}\n\\label{crh:conclusion}\n\nIn this chapter, we have presented a novel method for multimodal hash function learning based on a boosted co-regularization framework which is named co-regularized hashing (CRH). In \\mbox{CRH}, there is no data assumption such as those the data are aligned or organized in graphs. Because the objective function of the optimization problem is in the form of a difference of convex functions, we develop an efficient learning algorithm based on \\mbox{CCCP} and a stochastic gradient method.  Experimental study based on two benchmark data sets shows that \\mbox{CRH} outperforms two state-of-the-art multimodal hashing methods.\n\nTo take this work further, we would like to conduct theoretical analysis of \\mbox{CRH} and apply it to some other tasks such as multimodal medical image alignment. Another possible research issue is to develop sublinear optimization algorithms to further improve the scalability of \\mbox{CRH}.\n\n", "meta": {"hexsha": "fd6913853880d6c7f0e1ec1a41ffa1c7c30abe63", "size": 52962, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_zhen/TexFile/6_crh.tex", "max_stars_repo_name": "yzhen-li/paper", "max_stars_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis_zhen/TexFile/6_crh.tex", "max_issues_repo_name": "yzhen-li/paper", "max_issues_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-19T06:22:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-19T07:15:40.000Z", "max_forks_repo_path": "thesis_zhen/TexFile/6_crh.tex", "max_forks_repo_name": "zhenyisx/paper", "max_forks_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.616, "max_line_length": 927, "alphanum_fraction": 0.6584154677, "num_tokens": 18897, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.42627359492912775}}
{"text": "% !TEX root=../report.tex\n\n\\section{Case study}\n\nThere are three possible observations we can do on tasks:\n\\begin{enumerate}\n  \\item Does it have a value? ($\\Value(t) \\neq \\bot$)\n  \\item Is it possible to send events to it? ($\\Inputs(t) \\neq \\nothing$)\n  \\item Is it succeeding? ($\\Failing(t) = \\False$)\n\\end{enumerate}\nBelow a table of possible results when applying these observations to different tasks.\n\n\\begin{equation*}\n  \\begin{array}{llll}\n    \\toprule\n                                                         & \\Value           & \\Inputs                                                    & \\Failing \\\\\n    \\midrule\n    \\Fail                                                & \\bot             & \\nothing                                                   & \\False \\\\\n    \\addlinespace\n    \\Edit v                                              & v                & \\set{v', \\Empty}                                           & \\True \\\\\n    \\View v                                              & v                & \\nothing                                                   & \\True \\\\\n    \\Enter \\tau                                          & \\bot             & \\set{v'}                                                   & \\True \\\\\n    \\Let l = \\Ref v \\In \\Update l                        & v                & \\set{v'}                                                   & \\True \\\\\n    \\Let l = \\Ref v \\In \\Watch l                         & v                & \\nothing                                                   & \\True \\\\\n    \\addlinespace\n    \\Edit v \\Then \\lambda x. \\Fail                       & \\bot             & \\set{v', \\Empty}                                           & \\True \\\\\n    \\View v \\Then \\lambda x. \\Fail                       & \\bot             & \\nothing                                                   & \\True \\\\\n    \\Enter \\tau \\Then \\lambda x. \\Fail                   & \\bot             & \\set{v'}                                                   & \\True \\\\\n    \\Let l = \\Ref v \\In \\Update l \\Then \\lambda x. \\Fail & \\bot             & \\set{v'}                                                   & \\True \\\\\n    \\Let l = \\Ref v \\In \\Watch l \\Then \\lambda x. \\Fail  & \\bot             & \\nothing                                                   & \\True \\\\\n    \\addlinespace\n    \\Edit v_1 \\And \\Edit v_2                             & \\tuple{v_1, v_2} & \\set{\\Left v_1', \\Left \\Empty, \\Right v_2', \\Right \\Empty} & \\True \\\\\n    \\View v_1 \\And \\Edit v_2                             & \\tuple{v_1, v_2} & \\set{\\Right v_2', \\Right \\Empty}                           & \\True \\\\\n    \\View v_1 \\And \\View v_2                             & \\tuple{v_1, v_2} & \\nothing                                                   & \\True \\\\\n    \\Enter \\tau_1 \\And \\Edit v_2                         & \\bot             & \\set{\\Left v_1', \\Right v_2', \\Right \\Empty}               & \\True \\\\\n    \\Enter \\tau_1 \\And \\View v_2                         & \\bot             & \\set{\\Left v_1'}                                           & \\True \\\\\n    \\Enter \\tau_1 \\And \\Enter \\tau_2                     & \\bot             & \\set{\\Left v_1', \\Right v_2'}                              & \\True \\\\\n    \\Fail \\And \\Edit v_2                                 & \\bot             & \\set{\\Right v_2', \\Right \\Empty}                           & \\True \\\\\n    \\Fail \\And \\View v_2                                 & \\bot             & \\nothing                                                   & \\True \\\\\n    \\Fail \\And \\Fail                                     & \\bot             & \\nothing                                                   & \\False \\\\\n    \\addlinespace\n    t_1                                                  & \\bot             & \\nothing                                                   & \\True \\\\\n    \\bottomrule\n  \\end{array}\n\\end{equation*}\n\n\\begin{equation*}\n  \\begin{split}\n    t_1 := & \\Let l_1 = \\Ref \\False \\In \\\\\n           & \\Let l_2 = \\Ref \\False \\In \\\\\n           & u_1 @\\ (\\Watch l_1 \\Then \\lambda b. \\If{b}{\\Update l_2}{\\Fail}) \\\\\n           & \\quad \\And \\\\\n           & u_2 @\\ (\\Watch l_2 \\Then \\lambda b. \\If{b}{\\Update l_1}{\\Fail})\n  \\end{split}\n\\end{equation*}\n\nConclusions:\n\\todo{\n  What todo?\n}\n\\begin{itemize}\n  \\item\n    When we have always writeable editors, $\\Inputs$ and $\\Failing$ agree.\n  \\item\n    Introducing readonly editors will make $\\Inputs(t) = \\nothing$ but keeps $\\Failing = \\True$.\n  \\item\n    Taking $\\Inputs$ as a predicate to step to a task is tempting,\n    but as we just reasoned,\n    we will not be able to step to a readonly editor\\ldots\n  \\item\n    On the other hand,\n    taking $\\Failing$ as a predicate to step to a task,\n    will still prohibit to step to $\\Fail$ or pairs thereof.\n    However, it is possible to step to a locked task like $t_1$.\n    It is not immediately observable as failing,\n    but it clearly does not have any possible events it can handle.\n\\end{itemize}\n", "meta": {"hexsha": "15e43c5da681d1117dde59c1ae50abd20c6a3505", "size": 4935, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/report/casestudy.tex", "max_stars_repo_name": "mklinik/task-semantics", "max_stars_repo_head_hexsha": "e7b846338d5da59ed5d00aef81f9874cadbbdd9f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/report/casestudy.tex", "max_issues_repo_name": "mklinik/task-semantics", "max_issues_repo_head_hexsha": "e7b846338d5da59ed5d00aef81f9874cadbbdd9f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/report/casestudy.tex", "max_forks_repo_name": "mklinik/task-semantics", "max_forks_repo_head_hexsha": "e7b846338d5da59ed5d00aef81f9874cadbbdd9f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.2692307692, "max_line_length": 150, "alphanum_fraction": 0.3724417427, "num_tokens": 1154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4262460460779327}}
{"text": "%!TEX root = ../thesis.tex\n\n%%%%% Chapter: System Architecture %%%%%\n\\chapter{Alignment Algorithm}\n\\label{chap:align}\n\n\\ifpdf\n    \\graphicspath{{Chapter5/Figs/Raster/}{Chapter5/Figs/PDF/}{Chapter5/Figs/}}\n\\else\n    \\graphicspath{{Chapter5/Figs/Vector/}{Chapter5/Figs/}}\n\\fi\n\n\n\\section{Overview}\n\nThe use of the \\texttt{diff}-based alignment algorithm in the system is inspired by the work \\cite{lanchantin2015development} which used a \\texttt{diff}-based algorithm to align imperfect captions to audio of TV shows. In fact, the \\texttt{diff} algorithm (which solves the LCS problem) is a subset of a more general mathematical formulation of the 2-sequence alignment problem, which will be explained in \\Cref{sec:diff-formulation} with enough detail. After the discussion of the general formulation, we will explain how to adapt this formulation to the real alignment algorithm used in the system. \n\n\\section{General Formulation of Alignment Problems}\n\\label{sec:diff-formulation}\n\nLet $X$ = $X_1^n$ = ($X_1$,$X_2$,\\ldots,$X_n$) and $Y$ = $Y_1^n$ = ($Y_1$,$Y_2$,\\ldots,$Y_m$) be two sequences of symbols where $X_i \\in A$ and $Y_j \\in B$ for all $i$ and $j$. The sets $A$ and $B$ are also called \\textit{alphabets}. Let $\\phi$ be the \\textit{null symbol} which satisfies $\\phi \\notin A$ and $\\phi \\notin B$. Let $A^*$ = $A\\cup\\{\\phi\\}$ and $B^*$ = $B\\cup\\{\\phi\\}$.\n\nLet $Z$ = $Z_1^p$ = ($Z_1$,$Z_2$,\\ldots,$Z_p$), where $Z_i$ = $(S_i, T_i)$. Denote $S$ = $S_1^p$ = ($S_1$,$S_2$,\\ldots,$S_p$) and $T$ = $T_1^p$ = ($T_1$,$T_2$,\\ldots,$T_p$). We say $Z$ is an \\textit{alignment} of sequences $X$ and $Y$ if:\n\\begin{enumerate}\n  \\item $Z_i \\in A^* \\times B^*$ and $Z_i \\neq (\\phi,\\phi)$ for all $i$\n  \\item $X$ can be made equal to $S$ by inserting 0 or more null symbols $\\phi$\n  \\item $Y$ can be made equal to $T$ by inserting 0 or more null symbols $\\phi$\n\\end{enumerate}\n\nNow define the \\textit{Joint Weight Function}, $\\mathcal{F}(\\cdot,\\cdot)$: $A^* \\times B^* \\to \\mathbb{R}$. The \\textit{optimal alignment} $Z_{opt}$ is the alignment that maximise the sum of the joint weights, $\\mathcal{W}$:\n\\begin{equation}\n  Z_{opt} \\,=\\, \\argmax_{Z} \\mathcal{W}(Z) \\,=\\, \\argmax_{Z} \\sum_{i=1}^{p} \\mathcal{F}(S_i,T_i)\n\\end{equation}\nwhere $p$ denotes the length of $Z$ and may vary when $Z$ changes. The optimal alignment could be found by the \\textit{Needleman-Wunsch Algorithm}~\\cite{needleman1970general} with time and space complexity $O(nm)$.\n\n\\section{Example: DNA Sequences}\n\nIn bioinformatics we often need to align different DNA sequences. To illustrate the above formulation, we use two example DNA sequences $X$ = \\texttt{GCATGCT} and $Y$ = \\texttt{GATTACA} with alphabets $A$ = $B$ = \\{\\texttt{A}, \\texttt{T}, \\texttt{G}, \\texttt{C}\\}. An example alignment could be:\n\\begin{center}\n  \\texttt{GCATG-CT}\\\\\n  \\texttt{G-ATTACA}\n\\end{center}\nwe can use $Z$ = (\n  (\\texttt{G},\\texttt{G}),\n  (\\texttt{C},$\\phi$),\n  (\\texttt{A},\\texttt{A}),\n  (\\texttt{T},\\texttt{T}),\n  (\\texttt{G},\\texttt{T}),\n  ($\\phi$,\\texttt{A}),\n  (\\texttt{C},\\texttt{C}),\n  (\\texttt{T},\\texttt{A})\n) to express this alignment using the formulation in \\Cref{sec:diff-formulation}.\n\nUsually when comparing two sequences, we care about the total weight (or score) of converting the first sequence to the second sequence by three basic operations: \\textit{insertion}, \\textit{deletion} and \\textit{substitution}. These could be actually reflected in the Joint Weight Function $\\mathcal{F}$:\n\\[\n  \\begin{cases}\n    \\mathcal{F}(\\phi,y) & \\text{\\quad insert } y \\text{ into } X \\\\\n    \\mathcal{F}(x,\\phi) & \\text{\\quad delete } x \\text{ from } X \\\\\n    \\mathcal{F}(x,y) & \\text{\\quad substitute } x \\text{ with } y\n  \\end{cases}\n\\]\nIn the alignment of DNA sequences, it is common to assign positive scores for matches (same symbols) and negative scores for mismatches (insertions, deletions, substitutions with different symbols). If we define $\\mathcal{F}(x,y)$ to be +1 if $x$ = $y$ and -1 otherwise, the total weight (or score) $\\mathcal{W}$ can be calculated as:\n\\[ \\mathcal{W}(Z) = + 1 - 1 + 1 + 1 - 1 - 1 + 1 - 1 = 0 \\]\n\n\\section{Alignment in the System}\n\\label{sec:align-in-system}\n\nIn our system, we need to find the alignment between chunks of the handout text and segments of the lecture audio file. As a first step, we define $X$ to be the sequence of extracted words in the handout and define $Y$ to be the sequence of transcribed words in the corresponding audio file.\n\nWe can now define our Joint Weight Function $\\mathcal{F}$. For the baseline alignment algorithm, the optimal alignment of $X$ and $Y$ just solves the \\textit{longest common subsequence} problem, like the original \\texttt{diff} algorithm. This is equivalent to using the following simple JWF:\n\\begin{equation}\n  \\mathcal{F}(x,y) = \n  \\begin{cases}\n    1 & \\text{if } x = y\\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n  \\label{eq:jwf-baseline}\n\\end{equation}\nThe optimal alignment $Z_{opt}$ could then be found with the JWF in \\Cref{eq:jwf-baseline}.\n\nAs a next step, we should notice that each word in $X$ links to a unique chunk ID in the handout and each word in $Y$ is associated with a starting timestamp in the audio file. These information can be combined with the optimal alignment of $X$ and $Y$ to assign a time interval to each chunk of the handout.\n\n\\begin{figure}[!tb]\n  \\centering\n  \\includegraphics[width=.9\\textwidth]{align-algo-fig.eps}\n  \\caption{Illustration of how to assign audio segments to handout chunks with the optimal alignment $Z_{opt}$}\n  \\label{fig:align-algo-fig}\n\\end{figure}\n\n\\Cref{fig:align-algo-fig} illustrates the strategy of assigning audio segments to handout chunks based on the optimal alignment $Z_{opt}$. The word matches in $Z_{opt}$ are indicated by solid lines between words in handout chunks and the points on the audio timeline. Chunk 1, 2, 3 have 3, 0, 2 matches respectively.\n\nFirst we assign $\\overline{s_1 e_1}$ and $\\overline{s_3 e_3}$ to chunk 1 and chunk 3 respectively based on the matches. Then we divide $\\overline{e_1 s_3}$ into three segments using two points $p_1$ and $p_2$ with ratio 3:4:2 based on these observations: there are 3 words between the last matched word and the last word in chunk 1; chunk 2 has no matches and has 4 words in total; there are 2 words between the first word and the first matched word in chunk 3. Finally, $p_1$ becomes the ending timestamp for chunk 1 and the starting timestamp for chunk 2, whilst $p_2$ becomes the ending timestamp for chunk 2 and the starting timestamp for chunk 3.\n\nThis strategy can be extended to any number of handout chunks. For each chunk with matches, the segment which corresponds to the first matched word and the last matched word is first assigned to this chunk. Then for each empty segment between the endpoints of the assigned segments, it is first divided into smaller segments based on the relative lengths (in number of words) of the unmatched words of the relevant handout chunks, and these smaller segments are then assigned to the corresponding chunks.\n\nNote that this strategy is based on the assumption that the time spent on explaining a handout chunk is roughly proportional to the length of the chunk (in number of words).\n\n\n\\section{Extending the Baseline JWF}\n\nClearly the joint weight function can do more than just finding the longest common subsequence (\\Cref{eq:jwf-baseline}) of two sequences. In this section we will discuss how the JWF could be extended in various ways.\n\n\\subsection{Adding Time Constraint}\n\\label{subsec:time-constraint}\n\nBased on the assumptions that the lecturers will read the handouts in the strictly sequential order and that the amount of time spent on explaining a specific handout chunk is roughly proportional to the number of words in that chunk, we would expect that for any single match in the optimal alignment $Z_{opt}$, the difference between the relative position of the matching word in the handout and the relative position of the matching word in the audio file should be relatively small. \n\nHere we define the relative position of a word in the handout as the total number of its preceding words divided by the total number of words in the handout. Similarly we can define the the relative position of a word in the audio file to be the time difference between the timestamp of the word and the origin of the audio file, divided by the total length of the audio file. Clearly both of the relative positions range from 0 to 1.\n\nIn CUED the lectures are normally 50-minute long. Let $Z$ be a valid alignment and $(x,y)$ be an element in $Z$. Define $\\mathcal{D}(x,y)$ as the difference between $x$'s relative position (in the handout) and $y$'s relative position (in the audio file) scaled by a factor of 50. We can interpret $\\mathcal{D}(x,y)$ as the distance between $x$ and $y$ in minutes on the timeline of the audio file.\n\nIn the alignment algorithm, we would like to penalise large values of $\\mathcal{D}(x,y)$. In the actual alignment system we use the Gaussian function with standard deviation $\\sigma_t$, which yields the following JWF:\n\\begin{equation}\n  \\mathcal{F}(x,y) = \n  \\begin{cases}\n    \\exp \\left(-\\frac{\\mathcal{D}(x,y)}{2 \\sigma_t^2}\\right) & \\text{if } x = y\\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n  \\label{eq:jwf-gauss}\n\\end{equation}\nwe have removed the preceding normalising term of the Gaussian since it won't affect the optimal alignment. The Gaussian function decays when $\\mathcal{D}(x,y)$ increases, which automatically penalises matches with large differences in relative positions.\n\n\\subsection{Penalising Common-word Matches}\n\\label{subsec:common-word-penalty}\n\nIn an alignment, matches of common words like `a', `the' and `it' should be assigned less weight than matches of other kinds of words. The Oxford Corpus have listed 100 most commonly used English words \\cite{oec-common-words} based on the word frequencies in the corpus. Define the following function $\\mathcal{C}(x)$ with a parameter $\\alpha_c > 0$:\n\\begin{equation}\n  \\mathcal{C}(x) = \n  \\begin{cases}\n    \\alpha_c & \\text{if } x \\text{ in the Oxford Corpus list}\\\\\n    1 & \\text{otherwise}\n  \\end{cases}\n\\end{equation}\nClearly $\\alpha_c$ should be less than 1 in order to penalise common-word matches. Combining this function with \\Cref{eq:jwf-gauss} yields the final JWF in the alignment algorithm:\n\\begin{equation}\n  \\mathcal{F}(x,y) = \n  \\begin{cases}\n    \\mathcal{C}(x) \\exp \\left(-\\frac{\\mathcal{D}(x,y)}{2 \\sigma_t^2}\\right) & \\text{if } x = y\\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n  \\label{eq:jwf-final}\n\\end{equation}\nnote that the final $\\mathcal{F}(x,y)$ has two adjustable parameters $\\sigma_t$ and $\\alpha_c$.\n\n\n\\nomenclature[z-JWF]{JWF}{Joint Weight Function}\n\\nomenclature[g-nullsymb]{$\\phi$}{null symbol in sequence alignment}\n\\nomenclature[x-jwf]{$\\mathcal{F}(x,y)$}{joint weight function with input symbols $x$ and $y$}\n\\nomenclature[x-sigma]{$\\sigma_t$}{Gaussian standard deviation for adding time constraint}\n\\nomenclature[x-alpha]{$\\alpha_c$}{coefficient for penalising common-word matches}", "meta": {"hexsha": "7bbd03066d62a8c544cd04cd22fd9c347c2edc85", "size": 11035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter5/chapter5.tex", "max_stars_repo_name": "zyc-goose/iibproj-thesis-cued", "max_stars_repo_head_hexsha": "cc6f017cabc32d15c40ab05786630c6cddbca660", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter5/chapter5.tex", "max_issues_repo_name": "zyc-goose/iibproj-thesis-cued", "max_issues_repo_head_hexsha": "cc6f017cabc32d15c40ab05786630c6cddbca660", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter5/chapter5.tex", "max_forks_repo_name": "zyc-goose/iibproj-thesis-cued", "max_forks_repo_head_hexsha": "cc6f017cabc32d15c40ab05786630c6cddbca660", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.5666666667, "max_line_length": 651, "alphanum_fraction": 0.7295876756, "num_tokens": 3185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.42624603860303517}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage[english]{babel}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{amssymb}\n\\usepackage{enumerate}\n\\usepackage[hidelinks]{hyperref}\n\n\\author{Jayadev Naram}\n\\title{Iterative Methods} \n\n\\begin{document}\n\n\\maketitle \n\n\\maketitle\n \n\\tableofcontents\n\n\\newpage\n\n%\\part{}\n  \n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{mydef}{Definition}\n\\newtheorem*{remark}{Remark}\n\\newtheorem{prop}{Proposition}\n\n\\section{Introduction}\n\nWe want to solve $Ax=b$, where $A\\in\\mathbb{C}^{n\\times n}$ is a large non-singular matrix. To solve such a large system using Gaussian elimination is very costly and hence we turn to iterative methods for approximate solutions.\n\n\\subsection{Iterative Methods}\nAn iterative method is defined by an initial guess $x_0$ to the exact solution $\\tilde{x}=A^{-1}b,$ followed by a sequence of further approximations $\\{x_i\\}_{i>0}$. The error is given by $e_i=\\tilde{x}-x_i$ and residual by $r_i=b-Ax_i=Ae_i.$ For a given choice of $x_0$, an iterative method converges if $\\|\\tilde{x}-x_m\\|\\rightarrow 0$ as $m\\rightarrow \\infty.$ An iterative method experiences finite termination if for some d we have $x_m=\\tilde{x}\\;\\forall\\;m\\ge d.$\n\n\\subsection{Polynomial Methods}\nA polynomial method is an iterative method satisfying, $e_m=P_m(A)e_0$, for some polynomial $P_m(z)=1-zQ_{m-1}(z)$ of degree no greater than m satisfy $P_m(0)=1$. Then, $e_m=(I-Q_{m-1}(A)A)e_0=e_0-Q_{m-1}(A)r_0.$ Equivalently,\n$$x_m-x_0\\in\\mathcal{K}_m(A,r_0),$$\nwhere $\\mathcal{K}_m(A,v)=span\\{A^iv\\}^{m-1}_{i=0}$ is the Krylov subspace.\n\n\\subsection{Projection Methods}\nA projection method is an iterative method satisfying the following relation. For any m and initial guess $x_0$ let $\\mathcal{L}_m$ be a $l_m$-dimensional subspace and $\\mathcal{R}_m$ be a $r_m$-dimensional subspace. Assuming $x_{m-1}$ exists, we define $x_m$ to be a vector satisfying:\n\\begin{align}\nx_m-x_{m-1}\\in\\mathcal{R}_m,\\;\\tilde{x}-x_m\\in\\mathcal{L}_m\n\\end{align}\n\nNote that such $x_m$ may not exist and may not be unique. In this setting, $x_{m-1}+\\mathcal{R}_m$ is called the solution space and the orthogonality condition of (1) is called the Petrov-Galerkin condition.\n\nNow consider the specific form such $x_m$ takes. Let $L_m(R_m)$ be $n\\times l_m\\;(n\\times r_m)$ matrix whose columns form a basis for $\\mathcal{L}_m(\\mathcal{R}_m)$. Then for some $r_m\\times 1$ vector $\\alpha$, we have $$x_m=x_{m-1}+R_m\\alpha,\\;e_m=e_{m-1}-R_m\\alpha.$$ \nThe Petrov-Galerkin condition yields, $L^*_me_m=0\\implies L^*_me_{m-1}=L^*_mR_m\\alpha.$ If $L^*_mR_m$ is square and non-singular, then $\\alpha=(L^*_mR_m)^{-1}L^*_me_{m-1}.$ Thus,\n$$x_m=x_{m-1}+R_m(L^*_mR_m)^{-1}L^*_me_{m-1},$$\n$$e_m=[I-R_m(L^*_mR_m)^{-1}L^*_m]e_{m-1}.$$\n\nDefine $P_m=I-R_m(L^*_mR_m)^{-1}L^*_m$, then it easy to see that $P_m$ is a projection matrix (How does $P_m$ work\\textbf{???}) and hence the name projection methods is appropriate. It is desirable that $x_m$ exist and be unique for any m. Given a particular $x_{m-1}$, a given projection method breaks down at step m if $x_m$ as defined by (1) does not exist or is not unique. If $l_m<r_m$ and $x_m$ satisfying (1) exists, then such $x_m$ cannot be unique(\\textbf{???}).\n\n\\begin{theorem}[\\textbf{Existence/Uniquness}]\nSuppose $l_m=r_m>0.$ Then breakdown occurs at step m iff $L^*_mR_m$ is singular.\n\\end{theorem}\n\n\\begin{corollary}[\\textbf{Finite Termination}]\nSuppose for a particular $e_0$ breakdown never occurs for any step of projection method, and $x_{m-1}\\neq \\tilde{x}$ implies $dim(\\mathcal{R}_m)\\gneqq dim(\\mathcal{R}_{m-1})$ for any m. Then convergence is attained within n steps: $x_d=\\tilde{x}$ for some $d\\le n$.\n\\end{corollary}\n\n\\begin{proof}\nSuppose breakdown does not occur at step m. Then by uniqueness $$x_m=\\tilde{x}\\Leftrightarrow e_{m-1}\\in\\mathcal{R}_m,$$ \n($e_m=P_me_{m-1}=0\\implies e_{m-1}=R_m(L^*_mR_m)^{-1}L^*_me_{m-1}$). Since \n\\end{proof}\n\n\\newpage\n\n\\section{General Projection Methods}\n\nLet A $\\in\\mathbb{R}^{n\\times n}$ and $\\mathcal{K}\\;and\\;\\mathcal{L}$ be two m-dimensional subspaces of $\\mathbb{R}^n$. A projection technique onto the subspace $\\mathcal{K}$ and orthogonal to $\\mathcal{L}$ with an initial guess $x_0$ is a process which finds an approximate solution $\\tilde{x}$ by imposing the conditions that $\\tilde{x}$ belong to $x_0+\\mathcal{K}$ and that the new residual vector be orthogonal to $\\mathcal{L}$, i.e, $$find\\;\\;\\;\\tilde{x}\\in x_0+\\mathcal{K},\\;such\\;that\\;\\;b-A\\tilde{x}\\perp \\mathcal{L}.$$\n$$\\tilde{x}=x_0+\\delta,\\;\\delta\\in\\mathcal{K}$$\n$$(r_0-A\\delta,w)=0,\\;\\forall\\,w\\in\\mathcal{L},\\;where\\;r_0=b-Ax_0.$$\n\nLet $V=[v_1,\\cdots,v_m]_{n\\times m}\\;and\\;W=[w_1,\\cdots,w_m]_{n\\times m}$ whose column-vectors form a basis of $\\mathcal{K}$ and $\\mathcal{L}$, respectively.\nThen approximate solution can be written as:\n$$\\tilde{x}=x_0+Vy,$$\nwhere y can found from the orthogonality constraint:\n$$W^TAVy=W^Tr_0.$$\nIf $W^TAV$ is non-singular, then $\\tilde{x}=x_0+V(W^TAV)^{-1}W^Tr_0.$\n\n\\begin{algorithm}\n\\caption{Prototype Projection Method}\n\\begin{algorithmic}[1]\n\\Repeat\n\t\\State Select a pair of subspaces $\\mathcal{K}\\;and\\;\\mathcal{L}$\n\t\\State Choose basis $V$=$[v_1,\\cdots,v_m],\\;W$=$[w_1,\\cdots,w_m]\\;for\\;\\mathcal{K}\\;and\\;\\mathcal{L}$\n\t\\State $r\\gets b-Ax$\n\t\\State $y\\gets (W^TAV)^{-1}W^Tr$\n\t\\State $x\\gets x+Vy$\n\\Until{Convergence}\n\\end{algorithmic}\n\\end{algorithm}\n\nNon-singularity of A is not sufficient condition for non-singularity of $W^TAV$.\n\n\\begin{prop}\nLet $A,\\;\\mathcal{L}\\;and\\;\\mathcal{K}$ satisfy either one of the two following conditions:\n\\begin{enumerate}[i.]\n\\item A is SPD and $\\mathcal{L}=\\mathcal{K}$, or\n\\item A is non-singular and $\\mathcal{L}=A\\mathcal{K}$.\n\\end{enumerate}\nThen $B=W^TAV$ is non-singular for any bases V and W of $\\mathcal{K}\\;and\\;\\mathcal{L}$.\n\\end{prop}\n\n\\begin{proof}\nConsider case(i). Since $\\mathcal{L}=\\mathcal{K}$, then $W=VG$, where G is a non-singular $m\\times m$ matrix. Then $B=W^TAV={G^T}V^TAV$. Since A is SPD, so is $V^TAV$ and since G is non-singular, B is non-singular. \\\\\nNow, consider case(ii). Since $\\mathcal{L}=A\\mathcal{K}$, then $W=AVG$, where G is a non-singular $m\\times m$ matrix. Then $B=W^TAV={G^T}(AV)^TAV$. Since A is non-singular, then $(AV)_{n\\times m }$ full rank matrix and so is $(AV)^TAV$ and therefore, B is non-singular.\n\\end{proof}\n\n\\begin{theorem}\nAssume that A is SPD and $\\mathcal{L}=\\mathcal{K}.$ Then a vector $\\tilde{x}$ is the result of an (orthogonal) projection method onto $\\mathcal{K}$ with the  starting vector $x_0$ iff it minimizes the A-norm if the error over $x_0+\\mathcal{K},$ i.e, iff\n$$\\tilde{x} = \\underset{x\\in x_0+\\mathcal{K}}{\\arg\\min}\\|x_*-x\\|_A=\\underset{x\\in x_0+\\mathcal{K}}{\\arg\\min}(A(x_*-x),x_*-x)^{\\frac{1}{2}}$$\n\\end{theorem}\n\n\\begin{proof}\nFirst we prove that if $\\tilde{x}$ minimizes A-norm of the error, then it is the result of orthogonal projection method with $x_0$ onto $\\mathcal{K}$. Assume columns of V to be basis vectors of $\\mathcal{K}$, then the objective function can be written as:\n\\begin{align*}\nE(x) &= (A(x_*-x),x_*-x)^{\\frac{1}{2}},\\qquad(x\\in x_0+\\mathcal{K}) \\\\\n\\implies E(y) &= (A(x_*-x_0-Vy),x_*-x_0-Vy)^{\\frac{1}{2}},\\;\\;(y\\in\\mathbb{R}^m) \\\\\n\\implies E^2(y) &= (A(x_*-x_0-Vy),x_*-x_0-Vy), \\\\\n&= (x_*-x_0-Vy)^TA(x_*-x_0-Vy),\\\\\n&= c + 2y^TV^T(Ax_0-Ax_*) + y^TV^TAVy, \\\\\n&= c - 2y^TV^T(b-Ax_0) + y^TV^TAVy = f(y), \\\\\n\\frac{\\partial f(y)}{\\partial y} = 0 &\\implies V^T(b-A(x_0+Vy)) = 0 \\\\\n&\\implies V^T(b-A\\tilde{x}) = 0 \\\\\n&\\implies b-A\\tilde{x}\\perp \\mathcal{K}.\n\\end{align*}\nTherefore the residue of vector which minimizes A-norm of error over $x_0+\\mathcal{K}$ is orthogonal to $\\mathcal{K}$, therefore it is the result of orthogonal projection method onto $\\mathcal{K}$ starting with $x_0$. Now we prove the converse, i.e, the result of orthogonal projection method onto $\\mathcal{K}$ starting with $x_0$ minimizes A-norm of error over $x_0+\\mathcal{K}$. We know $V^T(b-A\\tilde{x}) = 0$, i.e, $(x_*-\\tilde{x},v)_A=0\\;\\forall\\;v\\in\\mathcal{K}$. \n\\begin{align*}\n\\implies \\|x_*-x\\|_A &= \\|x_*-\\tilde{x}+\\tilde{x}-x\\|_A,\\qquad(\\tilde{x},x\\in x_0+\\mathcal{K}) \\\\\n&= \\|x_*-\\tilde{x}\\|_A+\\|\\tilde{x}-x\\|_A,\\,\\text{(since }x_*-\\tilde{x}\\text{ is A-orthogonal to }\\mathcal{K}) \\\\\n\\implies \\|x_*-\\tilde{x}\\|_A &\\le \\|x_*-x\\|_A,\\;\\forall\\;x\\in x_0+\\mathcal{K}.\n\\end{align*}\nTherefore $\\tilde{x}$ minimizes the A-norm of the error.\n\\end{proof}\n\n\\begin{corollary}\nLet A be an arbitrary square matrix and assume that $\\mathcal{L}=A\\mathcal{K}.$ Then a vector $\\tilde{x}$ is the result of an (oblique) projection method onto $\\mathcal{K}$ orthogonally to $\\mathcal{L}$ with the starting vector $x_0$ iff it minimizes the 2-norm of the residual vector $b-Ax$ over $x\\in x_0+\\mathcal{K}$, i.e, iff\n$$\\tilde{x}=\\underset{x\\in x_0+\\mathcal{K}}{\\arg\\min}\\|b-Ax\\|_2$$\n\\end{corollary}\n\n\\begin{prop}\nLet $\\tilde{x}$ be the approximate solution obtained from a projection process onto $\\mathcal{K}$ orthogonally to $\\mathcal{L}=A\\mathcal{K}$, and let $\\tilde{r} = b-A\\tilde{x}$. Then,\n$$\\tilde{r}=(I-P)r_0,$$\nwhere P denotes the orthogonal projector onto $\\mathcal{K}$.\n\\end{prop}\n\n\\begin{proof}\nLet $r_0=b-Ax_0$, then\n\\begin{align*}\n\\tilde{r} &= b-A\\tilde{x}\\\\\n&= b-A(x_0+\\delta),\\qquad(\\delta\\in\\mathcal{K})\\\\\n&= r_0-A\\delta.\n\\end{align*}\nBy orthogonality condition we have $\\tilde{r}\\perp A\\mathcal{K}$, i.e, $A\\delta$ is the projection of $r_0$ onto $A\\mathcal{K}$. Therefore, if P is the orthogonal projector onto $A\\mathcal{K}$, then\n$$Pr_0=A\\delta \\implies \\tilde{r}=(I-P)r_0$$\nIt follows from the above that $\\Vert \\tilde{r}\\Vert_2 \\le \\Vert r_0\\Vert_2.$ Therefore, this class of methods can be termed as \\textbf{Residual Projection Methods}.\n\\end{proof}\n\n\\begin{prop}\nLet $\\tilde{x}$ be the approximate solution obtained from an orthogonal projection process onto $\\mathcal{K}$, and let $\\tilde{d} = x_*-\\tilde{x}$. Then,\n$$\\tilde{d}=(I-P_A)d_0,$$\nwhere $P_A$ denotes the projector onto $\\mathcal{K}$, which is orthogonal with respect to A-inner product.\n\\end{prop}\n\n\\begin{proof}\nLet $d_0=x_*-x_0$ be the initial error, and let $\\tilde{d}=x_*-\\tilde{x}$, where $\\tilde{x}=x_0+\\delta$ is the approximate solution resulting from the projection step. We know that residual of the approximate solution is orthogonal to $\\mathcal{K}$, i.e, $\\tilde{r}=A\\tilde{d}=A(d_0-\\delta)$, $\\tilde{r}\\perp \\mathcal{K}$.\n\\begin{align*}\n&\\implies (A(d_0-\\delta),w)=0\\;\\forall\\;w\\in\\mathcal{K} \\\\\n&\\implies (d_0-\\delta,w)_A=0\\;\\forall\\;w\\in\\mathcal{K}\n\\end{align*}\nTherefore, if $P_A$ is the projector onto $A\\mathcal{K}$, which is orthogonal with respect to A-inner product, then $\\delta$ is the A-orthogonal projection of $d_0$, i.e,\n$$P_Ad_0=\\delta \\implies \\tilde{d}=(I-P_A)d_0.$$\nIt follows from the above that $\\Vert \\tilde{d}\\Vert_A \\le \\Vert d_0\\Vert_A.$ Therefore, this class of methods can be termed as \\textbf{Error Projection Methods}.\n\\end{proof}\n\n\nDefine $\\mathcal{P}_{\\mathcal{K}}$ to be the orthogonal projector onto $\\mathcal{K}$ and let $\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}$ be the (oblique) projector onto $\\mathcal{K}$ and orthogonally to $\\mathcal{L}$. Then \n$$\\mathcal{P}_{\\mathcal{K}}x\\in\\mathcal{K}\\;and\\;x-\\mathcal{P}_{\\mathcal{K}}x\\perp\\mathcal{K},$$\n$$\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}x\\in\\mathcal{K}\\;and\\;x-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}x\\perp\\mathcal{L}$$\n\n\\begin{theorem}\nAssume that $\\mathcal{K}$ is invariant under A and the initial residue, i.e, $r_0=b-Ax_0$ belongs to $\\mathcal{K}.$ Then the approximate solution obtained from any (oblique or orthogonal) projectioon method onto $\\mathcal{K}$ is exact.\n\\end{theorem}\n\n\\begin{proof}\nAn approximate solution $\\tilde{x}$ is defined by \n\\begin{align*}\n&\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}(b-A\\tilde{x})=0,\\;where\\;\\tilde{x}=x_0+\\delta,\\;\\delta\\in\\mathcal{K}. \\\\\n&\\implies \\mathcal{Q}^\\mathcal{L}_\\mathcal{K}(b-Ax_0-A\\delta)=0 \\\\\n&\\implies \\mathcal{Q}^\\mathcal{L}_\\mathcal{K}r_0=\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\delta \\\\\n&\\text{But }\\mathcal{K}\\text{ is invariant under A, then }A\\delta\\in\\mathcal{K}. \\\\\n&\\implies r_0=A\\delta,\\;(\\text{since }r_0\\in\\mathcal{K}\\text{ and }\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\delta=A\\delta) \\\\\n&\\implies A\\tilde{x}=b\n\\end{align*}\n\\end{proof}\n\n\\begin{theorem}[\\textbf{General Error Bound}]\nLet $\\gamma=\\|\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A(I-\\mathcal{P}_\\mathcal{K})\\|_2$ and assume that b is a member of $\\mathcal{K}$ and $x_0=0$. Then the exact solution $x_*$ of the problem is such that\n$$\\|b-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\mathcal{P}_\\mathcal{K}x_*\\|_2\\le\\gamma\\|(I-\\mathcal{P}_\\mathcal{K})x_*\\|_2.$$\n\\end{theorem}\n\n\\begin{proof}\nSince $b\\in\\mathcal{K},$\n\\begin{align*}\nb-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\mathcal{P}_\\mathcal{K}x_*&=\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}b-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\mathcal{P}_\\mathcal{K}x_* \\\\\n&=\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}(b-A\\mathcal{P}_\\mathcal{K}x_*) \\\\\n&=\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A(I-\\mathcal{P}_\\mathcal{K})x_* \\\\\n&=\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A(I-\\mathcal{P}_\\mathcal{K})(I-\\mathcal{P}_\\mathcal{K})x_* \\\\\n\\implies \\|b-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\mathcal{P}_\\mathcal{K}x_*\\|_2 &= \\|\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A(I-\\mathcal{P}_\\mathcal{K})(I-\\mathcal{P}_\\mathcal{K})x_*\\|_2 \\\\\n&\\le \\|\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A(I-\\mathcal{P}_\\mathcal{K})\\|_2\\|(I-\\mathcal{P}_\\mathcal{K})x_*\\|_2 \\\\\n\\implies \\|b-\\mathcal{Q}^\\mathcal{L}_\\mathcal{K}A\\mathcal{P}_\\mathcal{K}x_*\\|_2 &\\le \\gamma\\|(I-\\mathcal{P}_\\mathcal{K})x_*\\|_2 \\\\\n\\end{align*}\n\\end{proof}\n\n\\section{One-Dimensional Projection Methods}\n\nOne-dimensional projection processes are defined when $\\mathcal{K}=span\\{v\\}\\;and\\\\\\;\\mathcal{L}=span\\{w\\}.$ In this case, the new approximation  takes the form $x\\leftarrow x+\\alpha v$, where the orthogonality condition $r-A\\delta\\perp w$ yields,\n$$\\alpha = \\frac{(r,w)}{(Av,w)},\\;where\\;r=b-Ax_0.$$\n\n\\subsection{Steepest Descent}\n\nThe steepest descent algorithm is defined when A is SPD and $v=w=r.$ \n\n\\begin{lemma}[\\textbf{Kantorovich inequality}]\nLet B be any real SPD matrix and $\\lambda_1,\\;\\lambda_n$ its largest and smallest eigenvalues. Then,\n$$\\frac{(Bx,x)(B^{-1}x,x)}{(x,x)}\\le\\frac{(\\lambda_1+\\lambda_n)^2}{4\\lambda_1\\lambda_n},\\;\\forall\\;x\\neq 0$$\n\\end{lemma}\n\n\\begin{proof}\nIt is equvivalent to prove the statement for any unit vector x. Since B is SPD, it can be diagonalized by similarity transformation with an orthogonal matrix Q, $B=Q^TDQ.$\n$$(Bx,x)(B^{-1}x,x)=(Q^TDQx,x)(Q^TD^{-1}Qx,x)=(DQx,Qx)(D^{-1}Qx,Qx).$$\nDefine $y=Qx=(y_1,y_2,\\cdots,y_n)^T,\\;and\\;\\beta_i={y_i}^2$. Then,\n$$\\lambda\\equiv (Dy,y) = \\sum^n_{i=1}\\beta_i\\lambda_i,\\;\\sum^n_{i=1}\\beta_i=1$$\n$$\\psi(y)=(D^{-1}y,y)=\\sum^n_{i=1}\\beta_i\\frac{1}{\\lambda_i}.$$\nNote that $\\lambda$ is a convex combinations of eigenvalues of B. Then,\n$$(Bx,x)(B^{-1}x,x)=\\lambda\\psi(y).$$\nNoting that $f(\\lambda)=1/{\\lambda}$ is a convex function for $x\\in\\mathbb{R}_{++}$, $\\psi(y)$ containis all the convex combinations of $1/\\lambda_i$s which is bounded above by line passing through $(\\lambda_1,1/{\\lambda_1})\\;and\\;(\\lambda_n,1/{\\lambda_n})$, i.e,\n$$\\psi(y)\\le \\frac{1}{\\lambda_1}+\\frac{1}{\\lambda_n}-\\frac{\\lambda}{\\lambda_1\\lambda_n}.$$\n$$\\implies (Bx,x)(B^{-1}x,x)=\\lambda\\psi(y)\\le \\lambda\\Big(\\frac{1}{\\lambda_1}+\\frac{1}{\\lambda_n}-\\frac{\\lambda}{\\lambda_1\\lambda_n}\\Big).$$\nThe right-hand side is maximum when $\\lambda=\\dfrac{\\lambda_1+\\lambda_n}{2}$  yielding,\n$$(Bx,x)(B^{-1}x,x)\\le\\frac{(\\lambda_1+\\lambda_n)^2}{4\\lambda_1\\lambda_n}$$\n\\end{proof}\n\n\\begin{algorithm}\n\\caption{Steepest Descent Algorithm}\n\\begin{algorithmic}[1]\n\\State Compute $r=b-Ax$ and $p=Ar$\n\\Repeat\n\t\\State $\\alpha\\gets (r,r)/(p,r)$\n\t\\State $x\\gets x+\\alpha r$\n\t\\State $r\\gets r-\\alpha p$\n\t\\State Compute $p=Ar$\n\\Until{Convergence}\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{theorem}\nLet A be a SPD. Then, A-norms of the error vectors $d_k=x_*-x_k$ generated by the above algorithm satsify the following relation:\n$$\\|d_{k+1}\\|_A\\le\\Big(\\frac{\\lambda_1-\\lambda_n}{\\lambda_1+\\lambda_n}\\Big)\\|d_k\\|_A,$$\nand the algorithm converges for any initial guess $x_0.$\n\\end{theorem}\n\n\\begin{proof}\nWe know that $d_{k+1}=x_*-x_{k+1}$, but $x_{k+1}=x_k+\\alpha_k r_k.$\n$$\\implies d_{k+1}=x_*-(x_k+\\alpha_k r_k)=d_k-\\alpha_k r_k.$$\nNow consider,\n\\begin{align*}\n\\|d_{k+1}\\|^2_A &= (d_{k+1},d_k-\\alpha_k r_k)_A \\\\\n&= (d_{k+1},d_k)_A-(d_{k+1},\\alpha_k r_k)_A \\\\\n(d_{k+1},\\alpha_k r_k)_A &= (Ad_{k+1},\\alpha_k r_k) = (r_{k+1},\\alpha_k r_k), \\\\\n&= (r_k-\\alpha_kAr_k,r_k),\\text{ where }\\alpha_k=\\frac{(r_k,r_k)}{(Ar_k,r_k)}, \\\\\n&= (r_k,r_k)-\\frac{(r_k,r_k)}{(Ar_k,r_k)}(Ar_k,r_k) = 0 = (r_{k+1},r_k). \\\\\n\\implies (d_{k+1},\\alpha_k r_k)_A &= 0.\n\\end{align*}\n\\begin{align*}\n\\implies \\|d_{k+1}\\|^2_A &= (d_{k+1},d_k)_A \\\\\n&= (d_{k+1},Ad_k) \\qquad(\\text{since A is SPD}),\\\\\n&= (d_k-\\alpha_k r_k,r_k) \\\\\n&= (A^{-1}r_k,r_k)-\\alpha_k(r_k,r_k) \\\\\n\\text{But, }\\|d_k\\|^2_A = (Ad_k,d_k) &= (r_k,d_k) = (A^{-1}r_k,r_k), \\\\\n\\implies \\|d_{k+1}\\|^2_A &= (A^{-1}r_k,r_k)\\Big(1-\\frac{(r_k,r_k)^2}{(Ar_k,r_k)(A^{-1}r_k,r_k)}\\Big), \\\\\n\\text{From Kantorovich inequality,} \\\\\n&\\le \\|d_{k}\\|^2_A\\Big(1-\\frac{4\\lambda_1\\lambda_n}{(\\lambda_1+\\lambda_n)^2}\\Big), \\\\\n\\implies \\|d_{k+1}\\|_A&\\le\\Big(\\frac{\\lambda_1-\\lambda_n}{\\lambda_1+\\lambda_n}\\Big)\\|d_k\\|_A.\n\\end{align*}\n\\end{proof}\n\n\\section{Krylov Subspace Methods}\n\nWe define Krylov Subspace to be \n$$\\mathcal{K}_m(A,v)=span\\{v,Av,A^2v,\\cdots,A^{m-1}v\\}.$$\nThen, $x=p(A)v,\\;\\forall\\;x\\in\\mathcal{K}_m\\text{, where }deg(p)<m.$\n\n\\begin{mydef}[Minimal Polynomial of a vector]\nMonic polynomial of least degree such that $p(A)v=0$ is called minimal polynomial of v and degree of such polynomial is called grade$(\\mu)$.\n\\end{mydef}\n\n\\begin{theorem}\nLet $\\mu$ be the grade of v. Then $\\mathcal{K}_\\mu$ is invariant under A and $\\mathcal{K}_\\mu = \\mathcal{K}_m\\;\\forall\\;m\\ge\\mu.$\n\\end{theorem}\n\n\\begin{proof}\nSince, grade of v is $\\mu$ there exists a polynomial p of degree $\\mu$, such that $p(A)v=0,\\;where\\;p(A) = p_0I+p_1A+\\cdots+p_{\\mu-1}A^{\\mu-1}+A^\\mu.$\n$$\\implies A^\\mu v = -(p_0I+p_1A+\\cdots+p_{\\mu-1}A^{\\mu-1})v\\qquad(1)$$\nBut, $\\forall\\;x\\in\\mathcal{K}_\\mu,\\;x=q(A)v,\\;deg(q)<\\mu,$ i.e,\n\\begin{align*}\nx &= q_0v+q_1Av+\\cdots+q_{\\mu-1}A^{\\mu-1}v,\\;\\forall\\;x\\in\\mathcal{K}_\\mu, \\\\\n\\implies Ax &= q_0Av+q_1A^2v+\\cdots+q_{\\mu-1}A^\\mu v, \\\\\n\\text{Case 1: }& q_{\\mu-1} = 0,\\;then\\;Ax\\in\\mathcal{K}_\\mu. \\\\\n\\text{Case 2: }& q_{\\mu-1} \\neq 0,\\text{ then replace }A^\\mu v\\;by\\;(1),\\;Ax\\in\\mathcal{K}_\\mu.\n\\end{align*}\nTherefore, $\\mathcal{K}_\\mu$ is invariant under A. Similarily it can be seen that $\\mathcal{K}_\\mu = \\mathcal{K}_m \\\\\n\\;\\forall\\;m\\ge\\mu.$\n\\end{proof}\n\n\\begin{corollary}\n$dim(\\mathcal{K}_m) = min\\{m,grade(v)\\}.$\n\\end{corollary}\n\n\\newpage\n\n\\section{Arnoldi's Method for Linear Systems (FOM)}\n\nArnoldi's procedure is an algorithm for building an orthogonal basis of the Krylov subspace $\\mathcal{K}_m$.\n\n\\begin{algorithm}\n\\caption{Arnoldi-Modified Gram-Schmidt}\n\\begin{algorithmic}[1]\n\\State Choose a vector $v_1$ of norm 1\n\\For{$j= 1,2,\\cdots,m$}\n\t\\State Compute $w_j = Av_j$\n\t\\For{$i= 1,2,\\cdots,j$}\n\t\t\\State $h_{ij} = (w_j,v_i)$\n\t\t\\State $w_j = w_j - h_{ij}v_i$\n\t\\EndFor\n\t\\State EndDo\n\t\\State $h_{j+1,j} = \\|w_j\\|_2$. \n\t\\State If $h_{j+1,j}=0$ Stop; found an invariant subspace $[v_1,\\cdots,v_j]$\n\t\\State $v_{j+1}=w_j/h_{j+1,j}$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{prop}\nDenote by $V_m=[v_1,v_2,\\cdots,v_m]_{n\\times m}\\;and\\;\\bar{H}_m,\\;the\\;(m+1)\\times m$ Hessenberg matrix whose non-zero entries $h_{ij}$ are defined by the above algorithm and by $H_m$ the matrix obtained from $\\bar{H}_m$ by removing the last row. Then,\n$$AV_m=V_mH_m+w_me^T_m=V_{m+1}\\bar{H}_m,$$\n$$V^T_mAV_m=H_m.$$\n\\end{prop}\n\n\\begin{proof}\nFrom lines 6,8 we have, $w_j = Av_j - h_{ij}v_i$ and $w_j=v_{j+1}h_{j+1,j}.$\n$$\\implies Av_j = \\sum^{j+1}_{i=1}h_{ij}v_i \\implies AV_m = V_mH_m+w_me^T_m=V_{m+1}\\bar{H}_m.$$\n$$\\text{Since }V^T_m\\text{ is orthogonal, we get }V^T_mAV_m=H_m.$$\n\\end{proof}\n\nGiven an initial guess $x_0$ to the original linear system $Ax=b$, we now consider an orthogonal projection method which takes $\\mathcal{L}=\\mathcal{K}=\\mathcal{K}_m(A,r_0),$ with\n$$\\mathcal{K}_m(A,r_0)=span\\{r_0,Ar_0,A^2r_0,\\cdots,A^{m-1}r_0\\},$$\nin which $r_0=b-Ax_0.$ This method seeks an approximate solution $x_m$ from the affine subspace $x_0+\\mathcal{K}_m$ of dimension m by imposing the following orthogonality constraint:\n$$b-Ax_m\\perp \\mathcal{K}_m.$$\nIf $v_1=r_0/\\|r_0\\|_2$ in Arnoldi's method, and we set $\\beta=\\|r_0\\|_2,$ then\n$$V^T_mAV_m=H_m,\\;V^T_mr_0=V^T_m(\\beta v_1)=\\beta e_1.$$\nAs a result, the approximate solution using the above m-dimensional subspaces is given by:\n$$x_m=x_0+V_my_m,$$\nwhere $y_m$ can be found by imposing orthogonality constraint that $$V^T_m(b-Ax_m)=0\\implies y_m=H^{-1}_m(\\beta e_1).$$\n\n\\newpage\n\n\\begin{algorithm}\n\\caption{Full Orthogonalization Method (FOM)}\n\\begin{algorithmic}[1]\n\\State Compute $r_0=b-Ax_0,\\;\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\State Define the $m\\times m$ matrix $H_m = \\{h_{ij}\\}_{i,j=1,2,\\cdots,m};Set\\;H_m=0$\n\\For{$j= 1,2,\\cdots,m$}\n\t\\State Compute $w_j = Av_j$\n\t\\For{$i= 1,2,\\cdots,j$}\n\t\t\\State $h_{ij} = (w_j,v_i)$\n\t\t\\State $w_j = w_j - h_{ij}v_i$\n\t\\EndFor\n\t\\State EndDo\n\t\\State $h_{j+1,j} = \\|w_j\\|_2$. If $h_{j+1,j}=0$ Stop\n\t\\State $v_{j+1}=w_j/h_{j+1,j}$\n\\EndFor\n\\State EndDo\n\\State Compute $y_m=H^{-1}_m\\beta e_1$ and $x_m=x_0+V_my_m$\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{prop}\nThe residual vector of the approximate solution $x_m$ computed by the FOM Algorithm is such that \n$$r_m=b-Ax_m=-h_{m+1,m}e^T_my_mv_{m+1}$$\nand, therefore,\n$$\\|r_m\\|_2=\\|b-Ax_m\\|_2=h_{m+1,m}|e^T_my_m|.$$\n\n\\begin{proof}\n\\begin{align*}\nr_m&=b-Ax_m \\\\\n&= b-Ax_0-AV_my_m \\\\\n&= r_0 - (V_mH_m+w_me^T_m)y_m \\\\\n&= r_0 - V_mH_m(H^{-1}_m\\beta e_1) - w_me^T_my_m \\\\\n&= r_0 - V_mV^T_mr_0 - h_{m+1,m}e^T_my_mv_{m+1}=-h_{m+1,m}e^T_my_mv_{m+1}.\n\\end{align*}\n\\end{proof}\n\\end{prop}\n\n\\subsection{Variation 1: Restarted FOM}\n\n\\begin{algorithm}\n\\caption{Restarted FOM (FOM(m))}\n\\begin{algorithmic}[1]\n\\State Compute $r_0=b-Ax_0,\\;\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\State Generate $V_m\\;and\\;H_m$ using Arnoldi algorithm starting with $v_1$.\n\\State Compute $y_m=H^{-1}_m\\beta e_1$ and $x_m=x_0+V_my_m$. If satisfied then Stop.\n\\State Set $x_0=x_m$ and go to 1.\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Variation 1: IOM and DIOM}\n\nA formula can be developed whereby the current approximate solution $x_m$ can be computed from the previous approximation $x_{m-1}$ and a small number vectors are updated at each step. This progressive formulation of the solution leads to an algorithm termed as Direct IOM (DIOM).\\\\\nThe Hessenberg matrix obtained from IOM has a band structure with bandwidth $k+1$, i.e,\n\n\\begin{algorithm}\n\\caption{Incomplete Orthogonalization Method (IOM)}\n\\begin{algorithmic}[1]\n\\State Compute $r_0=b-Ax_0,\\;\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\State Define the $m\\times m$ matrix $H_m = \\{h_{ij}\\}_{i,j=1,2,\\cdots,m};Set\\;H_m=0$\n\\For{$j= 1,2,\\cdots,m$}\n\t\\State Compute $w_j = Av_j$\n\t\\For{$i= max\\{1,j-(k-1)\\},2,\\cdots,j$}\n\t\t\\State $h_{ij} = (w_j,v_i)$\n\t\t\\State $w_j = w_j - h_{ij}v_i$\n\t\\EndFor\n\t\\State EndDo\n\t\\State $h_{j+1,j} = \\|w_j\\|_2$. If $h_{j+1,j}=0$ Stop\n\t\\State $v_{j+1}=w_j/h_{j+1,j}$\n\\EndFor\n\\State EndDo\n\\State Compute $y_m=H^{-1}_m\\beta e_1$ and $x_m=x_0+V_my_m$\n\\end{algorithmic}\n\\end{algorithm}\n\n\n\\begin{align*}\nH_m &= \\left( \\begin{array}{ccccc}\nh_{11} & h_{12} & h_{13} &  &  \\\\\nh_{21} & h_{22} & h_{23} & h_{24} &  \\\\\n & h_{32} & h_{33} & h_{34} & h_{35} \\\\\n &  & h_{43} & h_{44} & h_{45} \\\\\n &  &  & h_{54} & h_{55} \\\\\n\\end{array} \\right) = L_mU_m \\\\\n&= \\left( \\begin{array}{ccccc}\n1 &  &  &  &  \\\\\nl_{21} & 1 &  &  &  \\\\\n & l_{32} & 1 &  &  \\\\\n &  & l_{43} & 1 &  \\\\\n &  &  & l_{54} & 1 \\\\\n\\end{array} \\right)\\times \n\\left( \\begin{array}{ccccc}\nu_{11} & u_{12} & u_{13} &  &  \\\\\n & u_{22} & u_{23} & u_{24} &  \\\\\n &  & u_{33} & u_{34} & u_{35} \\\\\n &  &  & u_{44} & u_{45} \\\\\n &  &  &  & u_{55} \\\\\n\\end{array} \\right) \n\\end{align*}\nThe approximate solution then is given by \n$$x_m=x_0+V_mU^{-1}_mL^{-1}_m(\\beta e_1).$$\nDefine $P_m\\equiv V_mU^{-1}_m\\;and\\;z_m=L^{-1}_m(\\beta e_1),$ we have $x_m=x_0+P_mz_m.$ Because of the structure of $U_m,\\;P_m$ can be updated easily. Indeed, equating the last columns of the matrix relation $P_mU_m=V_m$ yields,\n$$\\sum^m_{i=m-k+1} u_{im}p_i=v_m\\implies p_m = \\frac{1}{u_{mm}}\\Bigg( v_m-\\sum^{m-1}_{i=m-k+1}u_{im}p_i \\Bigg).$$\nTherefore, $p_m$ can be computed using previous $p_i's$ and $v_m$. In addition, due to the structure of $L_m$, we have compute $z_m$ by,\n$$z_m=\\left[ \\begin{array}{c} z_{m-1} \\\\ \\zeta_m \\end{array} \\right]\\text{, where }\\zeta_m=-l_{m,m-1}\\zeta_{m-1}.$$\nNow, the approximate solution is,\n$$x_m=x_0+\\left[ \\begin{array}{cc} P_{m-1} & p_m \\end{array} \\right]\\left[ \\begin{array}{c} z_{m-1} \\\\ \\zeta_m \\end{array} \\right]=x_0+P_{m-1}z_{m-1}+p_m\\zeta_m.$$\nNoting that $x_{m-1}=P_{m-1}z_{m-1}$, $x_m$ can be updated as follows:\n$$x_m=x_{m-1}+\\zeta_mp_m.$$\nThis gives the following algorithm, called \\textbf{Incomplete Orthogonalization Method}(DIOM).\n\n\\begin{algorithm}\n\\caption{Direct Incomplete Orthogonalization Method (DIOM)}\n\\begin{algorithmic}[1]\n\\State Choose $x_0$ and compute $r_0=b-Ax_0,\\;\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\For{$m= 1,2,\\cdots$, until convergence}\n\t\\State Compute $w_m = Av_m$\n\t\\For{$i= max\\{1,m-k+1\\},2,\\cdots,m$}\n\t\t\\State $h_{im} = (w_m,v_i)$\n\t\t\\State $w_m = w_m - h_{im}v_i$\n\t\\EndFor\n\t\\State $h_{m+1,m} = \\|w_m\\|_2$. If $h_{m+1,m}=0$ Stop\n\t\\State $v_{m+1}=w_m/h_{m+1,m}$\n\t\\State Update the LU factorization of $H_m$, i.e, obtain the last column \t\n\t\\State $\\qquad U_m$ using the previous k pivots. If $u_{mm}=0$ Stop.\n\t\\State $\\zeta_m = \\beta$ if $m=1$ else $-l_{m,m-1}\\zeta_{m-1}$\n\t\\State $p_m = u^{-1}_{mm}\\Big( v_m-\\sum^{m-1}_{i=m-k+1}u_{im}p_i \\Big)(\\text{for }i\\le0\\text{ set }u_{im}p_i\\equiv0)$\n\t\\State $x_m=x_{m-1}+\\zeta_mp_m$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{remark}\nObserve that $V^T_mAV_m=H_m$ is still valid because the orthogonality properties were not used to derive this relation. As a consequence the following result  is also valid,\n\\begin{align*}\nr_m = b-Ax_m &= -h_{m+1,m}e^T_my_mv_{m+1} \\\\\n\\implies \\|b-Ax_m\\|_2 &= h_{m+1,m}|e^T_my_m| \\\\\n\\text{But, }y_m = H^{-1}_m(\\beta\te_1) &= U^{-1}_mz_m \\implies e^T_my_m = \\zeta_m/u_{mm} \\\\\n\\implies \\|b-Ax_m\\|_2 &= h_{m+1,m}\\Bigl|\\frac{\\zeta_m}{u_{mm}}\\Bigr|\n\\end{align*}\n\\end{remark}\n\nSince the residual vectors is a scalar multiple of $v_{m+1}$ and since the $v_i$'s are no longer orthogonal, IOM and DIOM are not orthogonal projection techniques. They can however be viewed as oblique projection techniques onto $\\mathcal{K}_m$ orthogonally to an artificially constructed subspace.\n\n\\begin{prop}\nIOM and DIOM are mathematically equivalent to projection process onto $\\mathcal{K}_m$ and orthogonally to\n$$\\mathcal{L}_m=span\\{z_1,z_2,\\cdots,z_m\\},$$\n$$where\\;z_i=v_i-(v_i,v_{m+1})v_{m+1},\\;i=1,2,\\cdots,m.$$\n\\end{prop}\n\n\\begin{proof}\nFrom the construction of $\\mathcal{L}_m,\\;v_{m+1}$ is orthogonal to $\\mathcal{L}_m$ and we know the final residue $r_m$ is a scalar multiple of $v_{m+1}$, hence the approximate solution $x_m\\in\\mathcal{K}_m$ and residue vector $r_m\\perp\\mathcal{L}_m$.  \n\\end{proof}\n\n\\section{Symmetric Lanczos Algorithm}\n\nThe symmetric lanczos algorithm can be viewed as a simplification of Arnoldi's method for the particular case of symmetric matrix. When A is symmetric, then the Hessenberg matrix $H_m$ will become symmetric tridiagonal. The standard notation used to descsribe the Lanczos algorithm is obtained by setting \n$$\\alpha_j=h_{jj},\\;\\beta_j=h_{j-1,j},$$\nand if $T_m$ denotes the resulting $H_m$ matrix, it is of the form,\n$$\nT_m = \\left( \\begin{array}{ccccc}\n\\alpha_1 & \\beta_2 &  &  &  \\\\\n\\beta_2 & \\alpha_2 & \\beta_3 &  &  \\\\\n & . & . & . &  \\\\\n &  & \\beta_{m-1} & \\alpha_{m-1} & \\beta_{m} \\\\\n &  &  & \\beta_m & \\alpha_m \\\\\n\\end{array} \\right). \n$$\n\nThis leads to the following form of Modified Gram-Schmidt variant of \\\\ Arnoldi's method:\n\n\\begin{algorithm}\n\\caption{Lanczos Method for Linear Systems}\n\\begin{algorithmic}[1]\n\\State Compute $r_0=b-Ax_0,\\;\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\State Set $\\beta_1=0\\;and\\;v_0=0$\n\\For{$j= 1,2,\\cdots,m$} \\Comment Orthogonalization Procedure\n\t\\State $w_j = Av_j-\\beta_jv_{j-1}$\n\t\\State $\\alpha_j=(w_j,v_j)$\n\t\\State $w_j = w_j-\\alpha_jv_j$\n\t\\State $\\beta_{j+1} = \\|w_j\\|_2.$ If $\\beta_{j+1}=0$ then Stop\n\t\\State $v_{j+1} = w_j/\\beta_{j+1}$\n\\EndFor\n\\State EndDo\n\\State Set $T_m=tridiag(\\beta_i,\\alpha_i,\\beta_{i+1})$, and $V_m=[v_1,\\cdots,v_m].$\n\\State Compute $y_m=H^{-1}_m\\beta e_1$ and $x_m=x_0+V_my_m$\n\\end{algorithmic}\n\\end{algorithm}\n\n\\section{Conjugate Gradient}\n\nThe conjugate gradient algorithm can be derived from the Lanczos algorithm in the same way DIOM was derived from IOM. Infact, the conjugate gradient algorithmm can be viewed as a variation of DIOM for the case when A is symmetric.\n\nFirst write the LU factorization of $T_m$ as $T_m=L_mU_m.$ The matrix $L_m$ is unit lower bidiagonal and $U_m$ is unit upper bidiagonal matrix. Thus the factorization of $T_m$ is of the form\n$$\nT_m = \n\\left( \\begin{array}{ccccc}\n1 &  &  &  &  \\\\\n\\lambda_2 & 1 &  &  &  \\\\\n & . & . &  &  \\\\\n &  & \\lambda_{m-1} & 1 &  \\\\\n &  &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)\\times \n\\left( \\begin{array}{ccccc}\n\\eta_1 & \\beta_2 &  &  &  \\\\\n & \\eta_2 & \\beta_3 &  &  \\\\\n &  & . & . &  \\\\\n &  &  & \\eta_{m-1} & \\beta_m \\\\\n &  &  &  & \\eta_m \\\\\n\\end{array} \\right).\n$$\n\nThe approximate solution is then given by,\n$$x_m=x_0+V_mU^{-1}_mL^{-1}_m(\\beta e_1) = x_0+P_mz_m.$$\nAs for DIOM, $p_m$, the last column of $P_m$, can be computed from the previous $p_i's\\;and\\;v_m$ by the simple update\n$$p_m=\\eta^{-1}_m[v_m-\\beta_mp_{m-1}].$$\nNote that $\\beta_m$ is a scalar computed from the Lanczos algorithm, while $\\eta_m$ results from the m-th Gaussian elimination step on the tridiagonal matrix, i.e, $\\lambda_m=\\frac{\\beta_m}{\\eta_{m-1}},\\;\\eta_m=\\alpha_m-\\lambda_m\\beta_m.$ In addition, following again what has been shown for DIOM, $z_m=\\left[ \\begin{array}{c} z_{m-1} \\\\ \\zeta_m \\end{array} \\right],\\;where\\;\\zeta_m=-\\lambda_m\\zeta_{m-1}.$\nAs a result, $x_m$ can be updated at each step as follows:\n$$x_m=x_{m-1}+\\zeta_mp_m.$$\nThis gives the following algorithm, which we call as direct version of Lanczos algorithm for linear systems.\n\n\\begin{algorithm}\n\\caption{D-Lanczos}\n\\begin{algorithmic}[1]\n\\State Choose $x_0$ and compute $r_0=b-Ax_0,\\;\\zeta_1=\\beta=\\|r_0\\|_2,\\;and\\;v_1=r_0/\\beta$\n\\State $\\lambda_1=\\beta_1=0,\\;p_0=0$\n\\For{$m= 1,2,\\cdots$, until convergence}\n\t\\State Compute $w_m = Av_m-\\beta_mv_{m-1}\\;and\\;\\alpha_m=(w,v_m)$\n\t\\State If $m > 1$ then compute $\\lambda_m=\\frac{\\beta_m}{\\eta_{m-1}}$ and $\\zeta_m=-\\lambda_m\\zeta_{m-1}$\n\t\\State $\\eta_m=\\alpha_m-\\lambda_m\\beta_m$\n\t\\State $p_m = \\eta^{-1}_m[v_m-\\beta_mp_{m-1}]$\n\t\\State $x_m=x_{m-1}+\\zeta_mp_m$\n\t\\State If $x_m$ has converged then Stop\n\t\\State $w=w-\\alpha_mv_m$\n\t\\State $\\beta_{m+1}=\\|w\\|_2,\\;v_{m+1}=w/\\beta_{m+1}$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\nObserve that the residual vector for this algorithm is in the direction of $v_{m+1}.$ Therefore, the residual vectors are orthogonal to each other as in FOM. Likewise, the vectors $p_i$ are A-orhogonal or conjugate to each other.\n\n\\begin{prop}\nLet $r_m=b-Ax_m,\\;and\\;p_m,m=0,1,\\cdots,$ be the residual vectors and auxiliary vectors produced by D-Lanczos algorithm. Then,\n\\begin{enumerate}[i)]\n\\item Each residual vector $r_m$ is such that $r_m=\\sigma_{m}v_{m+1}$, where $\\sigma_m$ is a certain scalar. As a result, the residual vectors are orthogonal to each other.\n\\item The auxiliary vectors $p_i$ form an A-conjuagte set, i.e,\n$$(Ap_i,p_j)=0,\\;for\\;i\\neq j.$$\n\\end{enumerate}\n\\end{prop}\n\n\\begin{proof}\nThe first part is immediate consequence of the following relation:\n$$r_m=b-Ax_m=-h_{m+1,m}e^T_my_mv_{m+1}$$\nNow we prove the second part. Consider the matrix $P^T_mAP_m$,\n$$P^T_mAP_m = U^{-T}_mV^T_mAV_mU^{-1}_m = U^{-T}_mT_mU^{-1}_m = U^{-T}_mL_m$$\nNow we observe $U^{-T}_mL_m$ is a lower triangular matrix which is also symmetric since it is equal to the symmetric matrix $P^T_mAP_m$. Therefore it must be diagonal.\n\\end{proof}\n\nA consequence of the above proposition is that a version of the algorithm  can be derived by imposing the orthogonality and conjugacy conditions. This gives the Conguate Gradient algorithm which we now derive. \n\n\\begin{remark}\nInorder to conform with the standard notation used in the literature to describe the algorithm, the indexing of the p vectors now begins at zero instead of one as was done so far.\n\\end{remark}\n\nThe vector $x_{j+1},r_{j+1},p_{j+1}$ can be expressed as follows:\n$$x_{j+1}=x_j+\\alpha_jp_j,\\quad r_{j+1}=r_j-\\alpha_jAp_j,\\quad p_{j+1}=r_{j+1}+\\beta_jp_j.$$\nIt can be seen that $(Ap_j,r_j)=(Ap_j,p_j+\\beta_jp_{j-1})=(Ap_j,p_j).$ Now imposing constraints,\n\\begin{enumerate}\n\\item Orthogonality Conditions on $r_i$'s gives $(r_j-\\alpha_jAp_j,r_j)=0$, as a result,\n$$\\alpha_j = \\frac{(r_j,r_j)}{(Ap_j,r_j)}=\\frac{(r_j,r_j)}{(Ap_j,p_j)}$$\n\\item Conjugacy Conditions on $p_i$'s gives $(p_{j+1},Ap_j)=0$. But,\n\\begin{align*}\n(p_{j+1},Ap_j) &= (r_{j+1}+\\beta_jp_j,Ap_j) = -\\frac{1}{\\alpha_j}(r_{j+1}+\\beta_jp_j,r_{j+1}-r_j)\\\\ \n(p_{j+1},&Ap_j) = 0 \\implies \\beta_j=\\frac{(r_{j+1},r_{j+1})}{(r_j,r_j)}\n\\end{align*}\n\\end{enumerate}\nIt is important to note that the scalar $\\alpha_j,\\beta_j$ in this algorithm and D-Lanczos are different.\n\nPutting these relation together gives the following algorithm.\n\n\\begin{algorithm}\n\\caption{Conjugate Gradient}\n\\begin{algorithmic}[1]\n\\State Choose $x_0$ and compute $r_0=b-Ax_0,\\;p_0=r_0.$\n\\For{$j= 0,1,2,\\cdots$, until convergence}\n\t\\State $\\alpha_j=(r_j,r_j)/(Ap_j,p_j)$\n\t\\State $x_{j+1}=x_j+\\alpha_jp_j$\n\t\\State $r_{j+1}=r_j-\\alpha_jAp_j$\n\t\\State $\\beta_j=(r_{j+1},r_{j+1})/(r_j,r_j)$\n\t\\State $p_{j+1}=r_{j+1}+\\beta_jp_j$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\n\\newpage\n\n\\begin{remark}[$LDL^T$ Factorization of $T_m$]\nWe have already seen the LU decomposition of $T_m$:\n$$\nT_m = \n\\left( \\begin{array}{ccccc}\n1 &  &  &  &  \\\\\n\\lambda_2 & 1 &  &  &  \\\\\n & . & . &  &  \\\\\n &  & \\lambda_{m-1} & 1 &  \\\\\n &  &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)\\times \n\\left( \\begin{array}{ccccc}\n\\eta_1 & \\beta_2 &  &  &  \\\\\n & \\eta_2 & \\beta_3 &  &  \\\\\n &  & . & . &  \\\\\n &  &  & \\eta_{m-1} & \\beta_m \\\\\n &  &  &  & \\eta_m \\\\\n\\end{array} \\right),\n$$\nwhere $$\\eta_1 = \\alpha_1,\\;\\lambda_k=\\dfrac{\\beta_k}{\\eta_{k-1}},\\;\\eta_k=\\alpha_k-\\lambda_k\\beta_k,\\;k=2,3,\\cdots,m.$$ \nNotice here that U can be further factorized as $U=DL^T$ such that $D=\\text{diag}(\\eta_1,\\eta_2,\\cdots,\\eta_m)$. Therefore we arrive at the $LDL^T$ decomposition of $T_m$ to be $T_m=L_mD_mL^T_m$, i.e,\n$$\nT_m = \n\\left( \\begin{array}{cccc}\n1 &  &  &   \\\\\n\\lambda_2 & 1 &  &  \\\\\n & . & . &  \\\\\n &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)\n\\left( \\begin{array}{cccc}\n\\eta_1 &  &  &   \\\\\n & \\eta_2 &  &  \\\\\n &  & . &  \\\\\n &  &  & \\eta_m \\\\\n\\end{array} \\right)\n\\left( \\begin{array}{cccc}\n1 &  &  &   \\\\\n\\lambda_2 & 1 &  &  \\\\\n & . & . &  \\\\\n &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)^T.\n$$\n\\end{remark}\n\n\\begin{prop}\nLet $A_m=(P^T_mP_m)^{-1}$, then $A_{m+1}=\\left[ \\begin{array}{cc}\n\\tilde{A}_m & \\lambda_{m+1}e_m \\\\\n\\lambda_{m+1}e^T_m & 1\\\\\n\\end{array} \\right]$, where $\\tilde{A}_m=A_m+\\lambda^2_{m+1}e_me^T_m.$\n\\end{prop}\n\n\\begin{proof}\nFirst notice that from the above factorization of $L_m$ that, \n$$P_m=V_mL^{-T}_m\\implies A_m = L^T_mL_m.$$\nThen \n\\begin{align*}\nA_m&=\\left( \\begin{array}{ccccc}\n1 &  &  &  &  \\\\\n\\lambda_2 & 1 &  &  &  \\\\\n & . & . &  &  \\\\\n &  & . & 1 &  \\\\\n &  &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)\n\\left( \\begin{array}{ccccc}\n1 & \\lambda_2 &  &  &  \\\\\n & 1 & . &  &  \\\\\n &  & . & . &  \\\\\n &  &  & 1 & \\lambda_m \\\\\n &  &  &  & 1 \\\\\n\\end{array} \\right)^T \\\\\n&= \\left( \\begin{array}{ccccc}\n1+\\lambda^2_2 & \\lambda_2 &  &  &  \\\\\n\\lambda_2 & 1+\\lambda^2_3 & . &  &  \\\\\n & . & . & . &  \\\\\n &  & . & 1+\\lambda^2_m & \\lambda_m \\\\\n &  &  & \\lambda_m & 1 \\\\\n\\end{array} \\right)\n\\end{align*}\nTherefore, $A_m=(P^T_mP_m)^{-1}$ is tridiagonal and $A_{m+1}$ can constructed from $A_m$ as follows:\n$A_{m+1}=\\left[ \\begin{array}{cc}\n\\tilde{A}_m & \\lambda_{m+1}e_m \\\\\n\\lambda_{m+1}e^T_m & 1\\\\\n\\end{array} \\right]$, where $\\tilde{A}_m=A_m+\\lambda^2_{m+1}e_me^T_m.$\n\\end{proof}\n\n\\begin{prop}\nThe $r_j$ vectors obtained in the Conjugate Gradient algorithm follow the following recurrence relation:\n$$Ar_j=\\hat{\\beta}_jr_{j-1}+(\\alpha_{j+1})r_j+\\hat{\\beta}_{j+1}r_{j+1}.$$ \n\\end{prop}\n\n\\begin{proof}\nWe know, $r_m=b-Ax_m=c_mv_{m+1}=\\{-\\beta_{m+1}(e^T_my_m)\\}v_{m+1}$, where  $y_m=T^{-1}_m(\\beta_0e_1).$ Then $e^T_my_m=e^T_mL^{-T}_mD^{-1}_mL^{-1}_m(\\beta_0e_1)$. Now we evaluate the value of $e^T_my_m$. It can be seen that \n$$L^{-1}_m =\n\\left( \\begin{array}{cccccc}\n1 &  &  &  &  & \\\\\n-\\lambda_2 & 1 &  &  &  & \\\\\n\\lambda_2\\lambda_3 & -\\lambda_3 & 1 &  &  & \\\\\n\\vdots &  &  & \\ddots &  & \\\\\n &  &  &  & 1 &  \\\\\n\\hat{l} & -\\hat{l}/\\lambda_2 & \\hdots &  & -\\lambda_m & 1 \\\\\n\\end{array} \\right),\\text{ where }\\hat{l}=(-1)^{m-1}\\prod^m_{i=2}\\lambda_i.$$\nEach entry of $L^{-1}_m$ can be written as,\n\\[   \n(L^{-1}_m)_{i,j} = \n     \\begin{cases}\t\n      (-1)^{i-j}\\underset{k = j+1}{\\overset{i}{\\prod}}\\lambda_k, &\\quad\\text{for }i>j\\\\\n      \\qquad \\qquad 1, &\\quad\\text{for }i=j\\\\\n      \\qquad \\qquad 0, &\\quad\\text{for }i<j\n     \\end{cases}\n\\]\nNow notice that, $L^{-1}_me_1$ will give the first column of $L^{-1}_m$ and similarly $e^T_mL^{-T}_m = (L^{-1}_me_m)^T = e^T_m$ and hence $e^T_mD^{-1}_m=\\frac{1}{\\eta_m}e^T_m$. Then $$c_m=-\\dfrac{\\beta_0\\beta_{m+1}}{\\eta_m}e^T_mL^{-T}_me_1=-\\dfrac{\\beta_0\\beta_{m+1}}{\\eta_m}(L^{-1}_m)_{m,1}=(-1)^{m}\\beta_0\\bigg(\\dfrac{\\beta_{m+1}}{\\eta_m}\\bigg)\\underset{i=2}{\\overset{m}{\\prod}}\\lambda_i.$$\nNotice that $\\lambda_{m+1}=\\dfrac{\\beta_{m+1}}{\\eta_m}$. Therefore, $$r_m = c_mv_{m+1}\\text{ , where }c_m=(-1)^{m}\\beta_0\\underset{i=2}{\\overset{m+1}{\\prod}}\\lambda_i.$$\n\nFrom Lanczos algorithm we know, $AV_m=V_mT_m+\\beta_{m+1}v_{m+1}e^T_m.$ On compare the last column of the matrices on both sides of the equation we get, \n$$Av_m=\\beta_mv_{m-1}+\\alpha_mv_m+\\beta_{m+1}v_{m+1}.$$\nRaising the index of the terms in the above equation we get,\n$$Av_{m+1}=\\beta_{m+1}v_{m}+\\alpha_{m+1}v_{m+1}+\\beta_{m+2}v_{m+2}.$$\nOn substituting $r_m$ in it leads to,\n\\begin{align*}\nA\\dfrac{r_m}{c_m}&=\\beta_{m+1}\\dfrac{r_{m-1}}{c_{m-1}}+\\alpha_{m+1}\\dfrac{r_{m}}{c_{m}}+\\beta_{m+2}\\dfrac{r_{m+1}}{c_{m+1}} \\\\\n\\implies Ar_m&=\\bigg(\\dfrac{\\beta_{m+1}c_m}{c_{m-1}}\\bigg)r_{m-1}+\\alpha_{m+1}r_{m}+\\bigg(\\dfrac{\\beta_{m+2}c_m}{c_{m+1}}\\bigg)r_{m+1}.\n\\end{align*}\n\\end{proof}\n\n\\section{Convergence Analysis}\n\nHere we show the convergence of CG Algorithm using Chebyshev polynomials.\n\n\\subsection{Real Chebyshev Polynomials}\n\n\\begin{mydef}\nThe Chebyshev polynomial of the first kind of degree k is defined by:\n\\[   \nC_k(t) = \n     \\begin{cases}\t\n      \\, cos[k\\,cos^{-1}(t)], &\\quad\\text{for }|t|\\le 1\\\\\n       cosh[k\\,cosh^{-1}(t)], &\\quad\\text{otherwise.}\\\\\n     \\end{cases}\n\\]\n\\end{mydef}\n\nIt can be seen that $C_0(t)=1,\\;C_1(t)=t,$ can be easily extended by the following trigonometric relation\n$$cos[(k+1)\\theta]+cos[(k-1)\\theta]=2cos\\theta\\,cosk\\theta.$$\nThis also shows the important three-term recurrence relation\n$$C_{k+1}(t)=2tC_k(t)-C_{k-1}(t).$$\n\n\\begin{prop}\nIf $|t|>1$, then $C_k(t)=\\frac{1}{2}\\bigg[\\Big(t+\\sqrt{t^2-1}\\Big)^k+\\Big(t+\\sqrt{t^2-1}\\Big)^{-k}\\bigg]$\n\\end{prop}\n\n\\begin{proof}\n$\\text{We know, }C_k(t) = cosh[k\\,cosh^{-1}(t)],|t|>1,\\;cosh\\,\\theta=\\frac{1}{2}\\big(e^\\theta+e^{-\\theta}\\big).$ Then,\n$C_k(t) = \\frac{1}{2}\\Big[(e^\\theta)^k+(e^\\theta)^{-k}\\Big],$ where $\\theta = cosh^{-1}(t),$ i.e, $t=cosh\\,\\theta$ \n\\begin{align*}\n&\\implies t = \\frac{1}{2}\\big(e^\\theta+e^{-\\theta}\\big) \\implies e^{2\\theta}-2te^\\theta+1=0 \\\\\n&\\implies e^\\theta = t \\pm \\sqrt{t^2-1}\n\\end{align*}\nNotice that $t + \\sqrt{t^2-1}=\\frac{1}{t - \\sqrt{t^2-1}}.$ Then, for $|t|>1,$\n$$C_k(t)=\\frac{1}{2}\\bigg[\\Big(t+\\sqrt{t^2-1}\\Big)^k+\\Big(t+\\sqrt{t^2-1}\\Big)^{-k}\\bigg]\\gtrapprox\\frac{1}{2}\\Big(t+\\sqrt{t^2-1}\\Big)^k.$$\n\\end{proof}\n\nIn what follows  we denote by $\\mathbb{P}_k$ as the set of all polynomials of degree k.\n\n\\begin{remark}\nThe Chebyshev polynomials are polynomials with the largest possible leading coefficient whose absolute value on the interval $[-1,1]$ is bounded by 1.\n\\end{remark}\n\n\\begin{theorem}\nLet $[\\alpha,\\beta]$ be a non-empty interval in $\\mathbb{R}$ and let $\\gamma$ be any real scalar outside $[\\alpha,\\beta].$ Then,\n$$\\hat{C}_k(t)=\\frac{C_k\\Big(1+2\\frac{t-\\beta}{\\beta-\\alpha}\\Big)}{C_k\\Big(1+2\\frac{\\gamma-\\beta}{\\beta-\\alpha}\\Big)}=\\underset{p\\in\\mathbb{P}_k,\\,p(\\gamma)=1}{\\arg\\min}\\;\\;\\underset{t\\in[\\alpha,\\beta]}{\\max}|p(t)|.$$\n\\end{theorem}\n\n\\begin{remark}\nIf $\\gamma\\le\\alpha$, the absolute values are needed in the denominators and exchanging the roles of $\\alpha$ and $\\beta$, i.e,\n$$\\hat{C}_k(t)=\\frac{C_k\\Big(1+2\\frac{\\alpha-t}{\\beta-\\alpha}\\Big)}{C_k\\Big(1+2\\frac{\\alpha-\\gamma}{\\beta-\\alpha}\\Big)}.$$\n\\end{remark}\n\nWe can further state following which is the result of the above remark and theorem.\n\n\\begin{corollary}\n$\\underset{p\\in\\mathbb{P}_k,\\,p(\\gamma)=1}{\\arg\\min}\\;\\;\\underset{t\\in[\\alpha,\\beta]}{\\max}|p(t)| = \\dfrac{1}{|C_k(1+2\\frac{\\gamma-\\beta}{\\beta-\\alpha})|}$\n\\end{corollary}\n\n\\subsection{Convergence of CG Algorithm}\n\n\\begin{lemma}\nLet $x_m$ be the approximate solution obtained from the m-th step of the CG algorithm, and let $d_m=x_*-x_m$ where $x_*$ is the exact solution. Then, $x_m=x_0+q_m(A)r_0$, where $q_m$ is a polynomial of degree $m-1$ such that\n$$\\|(I-Aq_m(A))d_0\\|_A = \\underset{q\\in \\mathbb{P}_{m-1}}{\\min}\\|(I-Aq(A))d_0\\|_A.$$\n\\end{lemma}\n\n\\begin{proof}\nConsider the following objective function in the polynomial q\n$$\\|(I-Aq(A))d_0\\|_A = \\|d_0-Aq(A)d_0\\|_A = \\|x_*-(x_0+Aq(A)r_0)\\|_A = \\|x_*-x\\|_A.$$\nAnd also observe that $\\forall\\,x\\in x_0+\\mathcal{K}_m(A,r_0),\\,x=x_0+q(A)r_0,q\\in\\mathbb{P}_{m-1}$. Therefore minimizing x over $x_0+\\mathcal{K}_m(A,r_0)$ and q over $\\mathbb{P}_{m-1}$ are equivalent. We know that $x_m = \\underset{x\\in x_0+\\mathcal{K}}{\\arg\\min}\\|x_*-x\\|_A$. $\\text{Hence, }q_m=\\underset{q\\in \\mathbb{P}_{m-1}}{\\arg\\min}\\|(I-Aq(A))d_0\\|_A.$\n\\end{proof}\n\n\\begin{theorem}\nLet $\\eta=\\dfrac{\\lambda_n}{\\lambda_1-\\lambda_n}$ and $\\kappa = \\dfrac{\\lambda_1}{\\lambda_n},$ then\n$$\\|x_*-x_m\\|_A\\le \\dfrac{\\|x_*-x_0\\|_A}{C_m(1+2\\eta)}\\le 2\\bigg[\\dfrac{\\sqrt{\\kappa}-1}{\\sqrt{\\kappa}+1}\\bigg]^m\\|x_*-x_0\\|_A.$$\n\\end{theorem}\n\n\\begin{proof}\nFrom the previous lemma, it is known that $\\|x_*-x_m\\|_A$ is the minimum of the error over polynomials $r(t)=1-tq(t)$ which take the value one at 0, i.e,\n$$\\|x_*-x_m\\|_A=\\underset{r\\in \\mathbb{P}_m,\\;r(0)=1}{\\min}\\|r(A)d_0\\|_A.$$\nLet $\\lambda_i,i=1,2,\\cdots,n$ are the eigenvalues of A, and $\\xi_i,i=1,2,\\cdots,n$ are the components of the initial error $d_0$ in the eigenbasis. Let eigen decomposition of $A=U\\Lambda U^T,$ where $\\Lambda=diag(\\lambda_1,\\lambda_2,\\cdots,\\lambda_n),$ then $d_0=U\\xi,\\;\\xi=[\\xi_1\\;\\xi_2\\;\\cdots\\;\\xi_n]^T$ and $r(A)=Ur(\\Lambda)U^T$. Then,\n\\begin{align*}\n\\|r(A)d_0\\|^2_A &= (Ar(A)d_0,r(A)d_0) = d^T_0r(A)A\\,r(A)d_0 \\\\\n&= \\xi^TU^TUr(\\Lambda)U^TU{\\Lambda}U^TUr(\\Lambda)U^T U\\xi \\\\\n&= \\xi^T \\Lambda r(\\Lambda)^2\\xi = \\sum^n_{i=1}\\lambda_ir(\\lambda_i)^2\\xi^2_i \\le \\underset{i}{\\max}(r(\\lambda_i)^2)\\|d_0\\|^2_A \\\\\n\\implies \\|r(A)d_0\\|^2_A &\\le \\underset{\\lambda\\in[\\lambda_n,\\lambda_1]}{\\max}(r(\\lambda_i)^2)\\|d_0\\|^2_A.\n\\end{align*}\nTherefore,\n\\begin{align*}\n\\|x_*-x_m\\|_A&\\le\\underset{r\\in \\mathbb{P}_m,\\;r(0)=1}{\\min}\\;\\;\\underset{\\lambda\\in[\\lambda_n,\\lambda_1]}{\\max}|r(\\lambda_i)|\\|d_0\\|_A \\\\\n&= \\dfrac{\\|x_*-x_0\\|_A}{C_m(1+2\\eta)}.\n\\end{align*}\nWe know, $C_m(t)\\ge \\frac{1}{2}\\Big(t+\\sqrt{t^2-1}\\Big)^m$, then \n$$C_m(1+2\\eta)\\ge \\frac{1}{2}\\Big(1+2\\eta+2\\sqrt{\\eta(\\eta-1)}\\Big)^m.$$\nNow notice that\n$$1+2\\eta+2\\sqrt{\\eta(\\eta-1)} = (\\sqrt{\\eta}+\\sqrt{\\eta+1})^2  = \\dfrac{(\\sqrt{\\lambda_n}+\\sqrt{\\lambda_1})^2}{\\lambda_1-\\lambda_n} = \\dfrac{\\sqrt{\\kappa}-1}{\\sqrt{\\kappa}+1}.$$\n$$\\text{Therefore, }\\|x_*-x_m\\|_A\\le 2\\bigg[\\dfrac{\\sqrt{\\kappa}-1}{\\sqrt{\\kappa}+1}\\bigg]^m\\|x_*-x_0\\|_A.$$\n\\end{proof}\n\n\\section{Deflated-CG Algorithm}\n\n\\subsection{Deflated Lanczos algorithm}\n\nA $\\in \\mathbb{R}^{n \\times n}$ is SPD and define $W=[w_1\\;w_2\\;\\cdots\\;w_k],\\;w_i\\in\\mathbb{R}^n$ are linearly independent vectors. Let $v_1\\in\\mathbb{R}^n$ be a unit vector such that $W^Tv_1=0.$\n\n\\begin{prop}\nLet W and A be defined as above, then $W^TAW$ is SPD.\n\\end{prop}\n\n\\begin{proof}\nLet $x\\in\\mathbb{R}^k$. We know that the columns of W are linearly independent, hence $Wx=0 \\Leftrightarrow x=0.$ Let $y=Wx$, then $x^TW^TAWx=y^TAy\\ge 0$ (since A is SPD).\n\\end{proof}\n\nWe want to generate a sequence $\\{v_j\\}_{j=1,2,\\cdots}$ of vectors such that \n$$v_{j+1}\\perp \\text{span}\\{W,v_1,v_2,\\cdots,v_j\\},\\;\\|v_{j+1}\\|_2=1.$$\n\nTo obtain such a sequence, we apply Lanczos algorithm to the following auxiliary  matrix:\n$$B=A-AW(W^TAW)^{-1}W^TA,$$\nwith the given initial vector $v_1$. Then we get a sequence $\\{v_j\\}_{j=1,2,\\cdots}$ which satisfies\n$$BV_j=V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j,\\text{ where }\nT_j = \\left( \\begin{array}{ccccc}\n\\rho_1 & \\sigma_2 &  &  &  \\\\\n\\sigma_2 & \\rho_2 & \\sigma_3 &  &  \\\\\n & . & . & . &  \\\\\n &  & \\sigma_{j-1} & \\rho_{j-1} & \\sigma_{j} \\\\\n &  &  & \\sigma_j & \\rho_j \\\\\n\\end{array} \\right)$$\n\nIt is guaranteed by the Lanczos algorithm that the vectors $v_j$ are orthogonal to each other. By comparing the last column on the both sides of the above equation, we get\n$$\\sigma_{j+1}v_{j+1}=Bv_j-\\sigma_jv_{j-1}-\\rho_jv_j.$$\n\nIt can also be seen that $W^TB=0.$\n\n\\begin{prop}\nLet W and $v_{j+1}$ be defined as above. Then $W^Tv_{j+1}=0\\;\\forall\\;j=1,2,\\cdots.$\n\\end{prop}\n\n\\begin{proof}\nWe prove by induction on j. It is clear from the definition that $W^Tv_1=0.$ Now assume that the propsition is true till $j-1$, i.e, $W^Tv_{k+1}=0\\;\\forall\\;k=1,2,\\cdots,j.$ Now we prove for $k=j+1.$ \n\nWe know, $\\sigma_{j+1}v_{j+1}=Bv_j-\\sigma_jv_{j-1}-\\rho_jv_j$, then\n$$\\implies \\sigma_{j+1}W^Tv_{j+1} = W^TBv_j-\\sigma_jW^Tv_{j-1}-\\rho_jW^Tv_j=0.$$\n\\end{proof}\n\nTherefore, we arrive at the following algorithm:\n\n\\begin{algorithm}\n\\caption{Deflated Lanczos Algorithm}\n\\begin{algorithmic}[1]\n\\State Choose k linearly independent vectors $w_1,w_2,\\cdots,w_k$ and \\\\ \\qquad define $W=[w_1\\;w_2\\;\\cdots\\;w_k]$\n\\State Choose an initial vector $v_1$ such that $W^Tv_1=0\\text{ and }\\|v_1\\|_2=1.$\n\\For{$j= 1,2,\\cdots,m$}\n\t\\State Solve $W^TAW\\hat{v_j}=W^TAv_j\\text{ for }\\hat{v_j}$\n\t\\State $z_j=Av_j-AW\\hat{v_j}$\n\t\\State $\\rho_j=v^T_jz_j$\n\t\\State $\\hat{v_{j+1}}=z_j-\\sigma_jv_{j-1}-\\rho_jv_j$\n\t\\State $\\sigma_{j+1}=\\|\\hat{v_{j+1}}\\|_2$; If $\\sigma_{j+1}=0$ Exit.\n\t\\State $v_{j+1}=\\hat{v_{j+1}}/\\sigma_{j+1}$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Deflated-CG algorithm}\n\nWe want to solve $Ax=b$, A is SPD. Based on deflated Lanczos algorithm we wish to derive a projection method similar to CG-algorithm. \n\nAssume $x_0$ is the initial guess and initial residue $r_0=b-Ax_0$ such that $r_0\\perp W.$ Now set $v_1=r_0/\\|r_0\\|_2$ and define $\\mathcal{K}_{k,j}(A,W,r_0)\\equiv\\text{span}\\{W,V_j\\}$. At j-th step of the projection, we seek for the approximate solution $x_j\\in x_0+\\mathcal{K}_{k,j}(A,W,r_0)$ and $r_j=b-Ax_j\\perp \\mathcal{K}_{k,j}(A,W,r_0).$\n\n\\begin{lemma}\nIf $x_j\\;and\\;r_j$ satisfy the above conditions, then $r_j=c_jv_{j+1},$ for some scalar $c_j$. Thus $\\mathcal{K}_{k,j}(A,W,r_0)=\\text{span}\\{W,r_0,r_1,\\cdots,r_{j-1}\\}$ and the residuals $r_i$'s are orthogonal to each other.\n\\end{lemma}\n\n\\begin{proof}\nLet $x_j=x_0+W\\hat{\\xi}_j+V_j\\hat{\\eta}_j$, for some $\\hat{\\xi}_j, \\hat{\\eta}_j.$ And we know $B=A-AW(W^TAW)^{-1}W^TA$ and $BV_j=V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j$, then we get $$AV_j=AW\\Delta_j+V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j, \\;\\Delta_j=(W^TAW)^{-1}W^TA.$$\nHence, $r_j = r_0-AW\\hat{\\xi}_j-AV_j\\hat{\\eta}_j = r_0-AW\\hat{\\xi}_j-(AW\\Delta_j+V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)\\hat{\\eta}_j.$\n\\begin{align*}\nW^Tr_j &= W^Tr_0-(W^TAW)(\\hat{\\xi}_j-\\Delta_j\\hat{\\eta}_j)-W^T(V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)\\hat{\\eta}_j \\\\\n\\implies 0 &= -(W^TAW)\\hat{\\xi}_j - (W^TAW)\\Delta_j\\hat{\\eta}_j \\\\\n\\implies (&W^TAW)\\hat{\\xi}_j + (W^TAW)\\Delta_j\\hat{\\eta}_j = 0 \\implies \\hat{\\xi}_j = -\\Delta_j\\hat{\\eta}_j\n\\end{align*}\nTherefore, we have $$x_j = x_0-W\\Delta_j\\hat{\\eta}_j+V_j\\hat{\\eta}_j$$ and $$r_j = r_0-(V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)\\hat{\\eta}_j.$$\nWe know, $V_j^Tr_j=0\\implies 0 = V_j^Tr_0-T_j\\hat{\\eta}_j\\implies \\hat{\\eta}_j = \\|r_0\\|_2T^{-1}_je_1$. Now substituting this equation in the above equation, we get\n\\begin{align*}\nr_j &= r_0-\\|r_0\\|_2V_jT_j(T^{-1}_je_1)-\\|r_0\\|_2\\sigma_{j+1}v_{j+1}e^T_j(T^{-1}_je_1) \\\\\n &= (-\\|r_0\\|_2\\sigma_{j+1}e^T_jT^{-1}_je_1)v_{j+1} = c_jv_{j+1}\n\\end{align*}\n\\end{proof}\n\nLet $T_j=L_jD_jL^T_j$ and define $P_j\\equiv [p_0\\;p_1\\;\\cdots\\;p_{j-1}]=(-W\\Delta_j+V_j)L^{-T}_j\\Lambda_j$, where $\\Lambda_j=\\text{diag}\\{c_0,c_1,\\cdots,c_{j-1}\\}.$\n\n\\begin{prop}\nThe approximate solution $x_j$, the residual $r_j$ and the descent direction $p_j$ satisfy the following recurrence relations:\n\\begin{align*}\nx_j=x_{j-1}+\\alpha_{j-1}p_{j-1},\\;r_j=r_{j-1}-\\alpha_{j-1}Ap_{j-1},\\;p_j=r_j+\\beta_{j-1}p_{j-1}-W\\hat{\\mu}_j,\n\\end{align*}\nfor some $\\alpha_{j-1},\\beta_{j-1},\\hat{\\mu}_j.$ Thus $\\mathcal{K}_{k,j}(A,W,r_0)=\\text{span}\\{W,p_0,p_1,\\cdots,p_{j-1}\\}$.\n\\end{prop}\n\n\\begin{proof}\nLet $\\hat{\\zeta}_j=\\|r_0\\|_2(L_jD_j\\Lambda_j)^{-1}e_1$. We know,\n\\begin{align*}\nx_j&=x_0+\\|r_0\\|_2(-W\\Delta_j+V_j)T^{-1}_je_1\\\\\n&=x_0+[(-W\\Delta_j+V_j)L^{-T}_j\\Lambda_j][\\|r_0\\|_2\\Lambda^{-1}_jL^{T}_j(L_jD_jL^T_j)^{-1}_je_1] \\\\\n&= x_0+P_j\\zeta_j\n\\end{align*}\nNow notice that $L_jD_j\\Lambda_j$ is lower bidiagonal matrix, then we have,\n$$\\zeta_j=\\left[ \\begin{array}{c} \\zeta_{j-1} \\\\ \\alpha_{j-1} \\end{array} \\right],\\text{ for some scalar }\\alpha_{j-1}.$$\nHence, $$x_j = x_{j-1}+\\alpha_{j-1}p_{j-1}\\text{ and }r_j = r_{j-1}-\\alpha_{j-1}Ap_{j-1}.$$\nWe know that $P_j=(-W\\Delta_j+V_j)L^{-T}_j\\Lambda_j,$ then \n$$P_j\\Lambda^{-1}_jL^{T}_j\\Lambda_j=(-W\\Delta_j\\Lambda_j+V_j\\Lambda_j).$$\nNow notice that $\\Lambda^{-1}_jL^{T}_j\\Lambda_j$ is a unit upper bidiagonal matrix. Comparing the last columns of the both sides of this equation \n$$p_{j-1}-\\beta_{j-2}p_{j-2}=-W\\hat{\\mu}_{j-1}+c_{j-1}v_j,$$\nwhere $\\hat{\\mu}_{j-1}=c_{j-1}\\hat{v}_j\\;and\\;\\beta_{j-2}=-c_{j-1}u_{j-1,j}/c_{j-2}.$\n\\end{proof}\n\n\\begin{prop}\nThe vectors $p_j$ are A-orthogonal to each other, i.e, $P^T_jAP_j$ is diagonal. In addition, they are also A-orthogonal to all $w_i$'s, i.e, $W^TAP_j=0.$\n\\end{prop}\n\n\\begin{proof}\n\\begin{align*}\nP^T_jAP_j&= P^T_j(-AW\\Delta_j+AV_j)L^{-T}_j\\Lambda_j \\\\\n&= P^T_j(V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)L^{-T}_j\\Lambda_j \\\\\n&= \\Lambda_jL^{-1}_j(-\\Delta^T_jW^T+V^T_j)(V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)L^{-T}_j\\Lambda_j \\\\\n&= \\Lambda_jL^{-1}_jT_jL^{-T}_j\\Lambda_j = \\Lambda^2_jD_j\\text{, which is diagonal.}\n\\end{align*}\nConsider, \n$$W^TAP_j=W^T(V_jT_j+\\sigma_{j+1}v_{j+1}e^T_j)L^{-T}_j\\Lambda_j=0.$$\n\\end{proof}\n\n\\begin{prop}\nThe coefficients in Delfated-CG satisfy the relations\n$$\\alpha_j=\\dfrac{(r_j,r_j)}{(Ap_j,p_j)},\\quad \\hat{\\mu}_j=(W^TAW)^{-1}Ar_j,\\quad \\beta_j=\\dfrac{(r_{j+1},r_{j+1})}{(r_j,r_j)}.$$\n\\end{prop}\n\n\\begin{proof}\nFrom the orthogonality constraints on residuals, $r^T_{j-1}r_j=0.$ Then,\n\\begin{align*}\n&\\implies r^T_{j-1}(r_{j-1}-\\alpha_{j-1}Ap_{j-1}) = 0 \\\\\n&\\implies \\alpha_{j-1}=\\dfrac{(r_{j-1},r_{j-1})}{(r_{j-1},Ap_{j-1})} \\\\\n\\text{But, }&(p_{j-2},Ap_{j-1})=0\\;and\\;(W\\hat{\\mu}_{j-1},Ap_{j-1})=0 \\\\\n&\\implies \\alpha_{j-1}=\\dfrac{(r_{j-1},r_{j-1})}{(\\beta_{j-2}p_{j-2}+r_{j-1}-W\\hat{\\mu}_{j-1},Ap_{j-1})} \\\\\n&\\implies \\alpha_{j-1}=\\dfrac{(r_{j-1},r_{j-1})}{(p_{j-1},Ap_{j-1})}\n\\end{align*}\nWe know, \n\\begin{align*}\np_j&=r_j+\\beta_{j-1}p_{j-1}-W\\hat{\\mu}_j \\\\\n\\implies W^TAp_j&=W^TAr_j+\\beta_{j-1}W^TAp_{j-1}-W^TAW\\hat{\\mu}_j \\\\\n\\implies \\hat{\\mu}_j&=(W^TAW)^{-1}Ar_j \\\\\n\\text{Similarly, }p^T_{j-1}Ap_j&=p^T_{j-1}Ar_j+\\beta_{j-1}p^T_{j-1}Ap_{j-1}-p^T_{j-1}AW\\hat{\\mu}_j \\\\\n\\implies \\beta_{j-1} &= -\\dfrac{(Ap_{j-1},r_j)}{(p_{j-1},Ap_{j-1})}=\\dfrac{1}{\\alpha_{j-1}}\\dfrac{(r_j-r_{j-1},r_j)}{(p_{j-1},Ap_{j-1})} \\\\\n\\implies \\beta_{j-1} &= \\dfrac{(r_{j+1},r_{j+1})}{(r_j,r_j)}\n\\end{align*}\n\\end{proof}\n\n\\begin{remark}\nTo guarantee that initial guess $x_0$ satisfies $W^Tr_0=0$, we can choose $x_0$ in the form \n$$x_0=x_{-1}+W(W^TAW)^{-1}W^Tr_{-1},$$\nwhere $x_{-1}$ is arbitrary and $r_{-1}=b-Ax_{-1}$. \\\\\nThen, $$W^Tr_0 = W^Tr_{-1}-(W^TAW)(W^TAW)^{-1}W^Tr_{-1}=0.$$\n\\end{remark}\n\nPutting these relation together gives the following algorithm.\n\n\\newpage\n\n\\begin{algorithm}\n\\caption{Deflated-CG}\n\\begin{algorithmic}[1]\n\\State Choose k linearly independent vectors $w_1,w_2,\\cdots,w_k$ and \\\\ \\qquad define $W=[w_1\\;w_2\\;\\cdots\\;w_k]$\n\\State Choose an initial guess $x_0$ such that $W^Tr_0=0,$ where $r_0=b-Ax_0$\n\\State Solve $W^TAW\\hat{\\mu}_0=W^TAr_0$ for $\\hat{\\mu}_0$ and set $p_0=r_0-W\\hat{\\mu}_0$\n\\For{$j= 1,2,\\cdots,m$,}\n\t\\State $\\alpha_{j-1}=(r_{j-1},r_{j-1})/(Ap_{j-1},p_{j-1})$\n\t\\State $x_{j}=x_{j-1}+\\alpha_{j-1}p_{j-1}$\n\t\\State $r_{j}=r_{j-1}-\\alpha_{j-1}Ap_{j-1}$\n\t\\State $\\beta_{j-1}=(r_j,r_j)/(r_{j-1},r_{j-1})$\n\t\\State Solve $W^TAW\\hat{\\mu}_j=W^TAr_j$ for $\\hat{\\mu}_j$\n\t\\State $p_{j}=r_{j}+\\beta_{j-1}p_{j-1}-W\\hat{\\mu}_j$\n\\EndFor\n\\State EndDo\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{thebibliography}{9}\n\\bibitem{SaadBook} \nY. Saad, Iterative Methods for Sparse Linear Systems, PWS publishing company, Boston, MA, 1996. \n\n\\bibitem{deflatedCG}\nY. Saad, M. Yeung, J. Erhel, F. Guyomarc’H, A deflated version of the conjugate gradient algorithm, SIAM J. Sci. Comput., 21 (2000), pp. 1909–1926.\n\n\\bibitem{iterMethNLS}\nW. D. Joubert and T. A. Manteuffel, Iterative Methods for Nonsymmetric Linear Systems, Academic Press, New York, 1990, pp. 149–171 \n\n\\end{thebibliography}\n\n\\end{document}", "meta": {"hexsha": "38ad5514f375693ba5ee43bde51197ca0b61263e", "size": 53781, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notesSaad/notesSaad.tex", "max_stars_repo_name": "JayD1/Tex-files", "max_stars_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notesSaad/notesSaad.tex", "max_issues_repo_name": "JayD1/Tex-files", "max_issues_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notesSaad/notesSaad.tex", "max_forks_repo_name": "JayD1/Tex-files", "max_forks_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.9808743169, "max_line_length": 527, "alphanum_fraction": 0.655584686, "num_tokens": 22418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.808067204308405, "lm_q1q2_score": 0.42610718883295445}}
{"text": "\\documentclass{article}\n%\\documentclass[journal]{IEEEtran}\n%\\documentclass{report}\n%\\documentclass{acta}\n\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{xcolor}\n\n\\DeclareMathOperator{\\dd}{d\\!}\n\\DeclareMathOperator{\\ddd}{\\mathrm{d}}\n\n\n\\begin{document}\n\n\\title{Special Relativity and Lagrangians}\n\\author{Gerd Wagner}\n\n\\maketitle\n\n\\begin{abstract}\nIn the first part of the paper we derive two foundations of special relativity.\nBoth are based on the invariance of the space time interval $c^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2$,\ni.e. the constance of the speed of light.\nThese foundations are:\n\\begin{itemize}\n    \\item[1.] The invariance for any space time interval not only for that of light.\n    \\item[2.] The Lorentz transformation.\n\\end{itemize}\n\nThe second part is about some aspects of the Lagrange formulation of particle dynamics:\n\\begin{itemize}\n    \\item[1.] We show how the energy of a particle can be derived from studying how its action $S$ changes with time translations.\n    \\item[2.] We do a detailed discussion of the relativistic particle in an electromagnetic field.\n              The major result will be the transformation law of the electromagnetic potentials.\n    \\item[3.] We motivate the Lagrangian for the free particle in special relativity.\n    \\item[4.] We derive $E=mc^2$\n\\end{itemize}\n\nThe third part is about relativistic field Lagrangians and their transformation properties.\nIt's the continuation of our study of non relativistic field theory in \\cite{LagrangeOfField}:\n\\begin{itemize}\n    \\item[1. (*)] We formulate the Lagrangian formlism of fields for special relativity where in contrast to \\cite{LagrangeOfField} time is not a special coordinate anymore.\n    \\item[2. (**)] We show the invariance of the Euler-Lagrange equations under arbitray transformations of space and time as well as arbitrary transformations of the fields.\n              We also explain how the Lagrangian changes under these transformations.\n    \\item[3.] We use (*) and (**) to turn the classical Lagrangian of electrodynamics into its relativistic form.\n    \\item[4.] We use (*) and (**) once more and show that the Lagrangian is invariant under Lorentz transformations.\n              Which means we show the functional form of the Lagrangian doesn't change and thus that the equations of motion (Maxwell's equations) don't change.\n\\end{itemize}\n\n\n\\end{abstract}\n\n\n\\section{Introduction}\n\nLagrangians clear up the relation of equations of motion to coordinates.\nThis is especially important for special relativity which foundations lie in considering the laws of physics from within different coordinate systems i.e. inertial reference frames.\nWe want to make clear that once the transformation rules of the Lagrange formalism are derived, major results of relativistic electrodynamics can be found by simply applying these rules.\nThese results are:\n\\begin{itemize}\n\\item[1.] Turning the non relativistic Lagrangian of electrodynamics into its relativistic form by defining a simple coordinate transformation and applying the rules.\n\\item[2.] Proof that the Lagrangian of electrodynamics and the laws of electrodynamics (Maxwell's equations) are invariant under Lorentz transformations by applying the rules.\n\\end{itemize}\n\nThe second point requires some detailed discussion of relativistic particle physics, which is done in section \\ref{particleLagrangian}.\nIn this discussion we will derive the way electromagnetic potentials transform under Lorentz transformations.\n\nOnce we stepped so deep into relativistic particle physics we felt we also had to include the relativistic free particle and derive its famous energy $E=m c^2$\n\n\n\\section{Two foundations of special relativity} \\label{foundations}\n\n\\subsection{Invariance of the space time interval \\\\ $\\Delta s = \\sqrt{c^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2}$ \\cite{LandauInterval}} \\label{sectionInvarianceSpaceTime}\nWe consider two inertial reference frames $T$, $T'$ with coordinates $t,x,y,z$ and $t',x',y',z'$.\nInertial reference frames are reference frames in which a body with zero net force acting upon it is not accelerating.\nThe possible transformations between inertial reference frames are translations in space and time, rotations in space and motion with constant velocity.\n\nFrom within $T$ and $T'$ we observe a particle and a light pulse.\nThe light pulse we assume traveling in one direction with velocity $c$ such that it has nearly as well defined position as the particle.\n\nThe empiric fact, which started the theory of special relativity is that\n\\begin{equation} \\label{constantsSpeedOfLight}\n0 = c^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2 = c^2\\Delta t'^2 - \\Delta x'^2 - \\Delta y'^2 - \\Delta z'^2\n\\end{equation}\nholds the for the light pulse's coordinates in the two inertial reference frames $T$ and $T'$.\n\\footnote{This is the ususal mathematical way to state that the speed of light is the same in all inertial reference frames.\nThat the speed of light is the same in all inertial reference frames is also known as the second postulate of special relativity.\nThere are altogether two postulates of special relativity.\nThe two-postulate basis for special relativity is the one historically used by Einstein, and it remains the starting point today.\nThe first postulate, which is also called \"principle of relativity\" and postulates that the laws of physics are the same in all inertial frames of reference,\nwill become relevant in section \\ref{sectionFirstPostulate} of this paper.}\n\n\nIf $T$ and $T'$ are relative to each other at rest the equality\n\\begin{equation}\nc^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2 = c^2\\Delta t'^2 - \\Delta x'^2 - \\Delta y'^2 - \\Delta z'^2\n\\end{equation}\nis true for the particle, too.\nThis is because without relative motion the only transformations left are translations in space and time and rotations in space.\nFor these transformations the even more restrictive relations\n\n\\begin{equation} \\label{noVelocityTransform}\n\\Delta t = \\Delta t' \\; \\text{and} \\; \\Delta x^2 + \\Delta y^2 + \\Delta z^2 = \\Delta x'^2 + \\Delta y'^2 + \\Delta z'^2\n\\end{equation}\nhold. (Note 1: If these relations wouldn't hold when $T$ and $T'$ are relative to each other at rest, this would be a strong hint that space wasn't homogeneous and isotropic.\nNote 2: The issues that led to special relativity arise only when $T$ and $T'$ are moving relative to each other.)\\\\\n\nThe question we now aim to answer is: Is it true that for any transformation connecting the two inertial reference frames the equation\n\n\\begin{equation} \\label{invarianceSpaceTimeInterv}\n    c^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2 = c^2\\Delta t'^2 - \\Delta x'^2 - \\Delta y'^2 - \\Delta z'^2\n\\end{equation}\nholds for the particle's coordinates in $T$ and $T'$, too?\n\nAs we already reasoned the only transformations this question isn't already answered for, are those which include a constant relative velocity $\\vec{v}$ between $T$ and $T'$.\nSince we already know that rotations in space have no effect on\n\n\\begin{align*}\n    &\\Delta s^2 := c^2\\Delta t^2 - \\Delta x^2 - \\Delta y^2 - \\Delta z^2 \\\\\n    &\\text{and} \\\\\n    &\\Delta s'^2 := c^2\\Delta t'^2 - \\Delta x'^2 - \\Delta y'^2 - \\Delta z'^2\n\\end{align*}\nthe direction of $\\vec{v}$ can't have an effect either. So only the absolute value $|\\vec{v}|$ of $\\vec{v}$ could be responsible for $\\Delta s^2 \\neq \\Delta s'^2 $.\nThus the possible relation between $\\Delta s'$ and $\\Delta s$ can be expressed by a family of functions $F$ parametrized by $|\\vec{v}|$ such that\n\n\\begin{equation}\n    \\Delta s' = F_{|\\vec{v}|} (\\Delta s)\n\\end{equation}\n\nBelow we will show that $F$ can't depend on $|\\vec{v}|$ at all.\nIf so, then $F$ relates $\\Delta s'$ and $\\Delta s$ the same way no matter what the transformation between $T$ and $T'$ is.\nThus we can use any special case of a transformation to determine $F$.\nSince any of \\ref{noVelocityTransform} and \\ref{constantsSpeedOfLight} lead to\n\n\\begin{equation}\n    \\Delta s' = \\Delta s\n\\end{equation}\n$F$ must be the identity function.\nSo \\ref{invarianceSpaceTimeInterv} holds for the particle, too.\n\\\\\n\n\nTo prove $F$ cannot depend on $|\\vec{v}|$ we consider three inertial reference frames $T_1$,$T_2$,$T_3$ with constant relative velocities\n\n\\begin{align*}\n    &\\vec{v_{12}} \\; \\text{between} \\; T_1 \\; \\text{and} \\; T_2 \\\\\n    &\\vec{v_{23}} \\; \\text{between} \\; T_2 \\; \\text{and} \\; T_3 \\\\\n    &\\vec{v_{13}} \\; \\text{between} \\; T_1 \\; \\text{and} \\; T_3 \\\\\n\\end{align*}\nThe equations for the relations between $\\Delta s_1$, $\\Delta s_2$, $\\Delta s_3$ then would read\n\n\\begin{equation}\\label{Fofv1}\n\\Delta s_2 = F_{|\\vec{v_{12}}|}(\\Delta s_1)\n\\end{equation}\n\n\\begin{equation} \\label{Fofv2}\n\\Delta s_3 = F_{|\\vec{v_{13}}|}(\\Delta s_1)\n\\end{equation}\n\n\\begin{equation} \\label{Fofv3}\n\\Delta s_3 = F_{|\\vec{v_{23}}|}(\\Delta s_2)\n\\end{equation}\nPlugin \\ref{Fofv1} into \\ref{Fofv3} leads to $\\Delta s_3 = F_{|\\vec{v_{23}}|} \\circ F_{|\\vec{v_{12}}|} (\\Delta s_1)$ which with \\ref{Fofv2} leads to the function identity\n\n\\begin{equation} \\label{FRelation}\nF_{|\\vec{v_{13}}|} = F_{|\\vec{v_{23}}|} \\circ F_{|\\vec{v_{12}}|}\n\\end{equation}\nat the same time the vector equation $\\vec{v_{13}} = \\vec{v_{12}} + \\vec{v_{23}}$ must hold. For the absolute values this means\n\n\\begin{equation}\n    |\\vec{v_{13}}| = \\sqrt{|\\vec{v_{12}}|^2 + |\\vec{v_{23}}|^2 + 2 |\\vec{v_{12}}||\\vec{v_{23}}| \\cos(\\alpha)}\n\\end{equation}\nwhere $\\alpha$ is the angle between $\\vec{v_{12}}$ and $\\vec{v_{23}}$.\n\nThis way the left hand side of equation \\ref{FRelation} would depend on $\\alpha$ but the right hand side would not. Because of this contradiction $F$ cannot depend on the relative velocity between inertial reference frames.\n\n\n\n\n\\subsection{The Lorentz transformation} \\label{sectionLorentzTransformation}\n\n\\subsubsection{Non relativistic setup} \\label{setup}\nWe observe a particle from within two inertial reference frames $T$ and $T'$.\nInertial reference frames are reference frames in which a body with zero net force acting upon it is not accelerating.\nThe axis of the frames point in the same direction and $T'$ moves with velocity $v$ along $T$'s $x$-axis such that their classical Galilean transformation is given by:\n\n\\begin{equation} \\label{Galilei}\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n1 & 0\n\\\\\n-v & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\;,\\; y'=y \\;,\\; z'=z\n\\end{equation}\n\nwhere $t,x,y,z$ are the coordinates of the particle in $T$ and $t',x',y',z'$ are the coordinates of the particle in $T'$.\nAs we can see from these equations we chose $t=t'=0$ to be the time when the coordinate frames are on top of each other.\n\n\\subsubsection{Ansatz for a transformation compatible with invariance of the space time interval}\n\nSince at $t=t'=0$ the two reference frames $T$ and $T'$ are on top of each other \\ref{invarianceSpaceTimeInterv} turns into\n\n\\begin{equation} \\label{spaceTimeElement}\nc^2t'^2-x'^2-y'^2-z'^2 = c^2t^2-x^2-y^2-z^2.\n\\end{equation}\nAs an ansatz for a coordinate transformation between the two reference frames which is consistent with \\ref{spaceTimeElement} we write:\n\\begin{align} \\label{ansatz}\n\\left(\\begin{array}{c}\nct'\n\\\\\nx'\n\\end{array} \\right)\n&=\n\\begin{pmatrix}\na & d\n\\\\\nb & e\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right) \\\\\ny' &= y \\nonumber \\\\\nz' &= z \\nonumber\n\\end{align}\n\n\n\\subsubsection{Finding the matrix elements of the ansatz}\n\nBecause of $y'=y, z'=z$, equation \\ref{spaceTimeElement} and the ansatz \\ref{ansatz} result in the following matrix equation\n\n\\begin{equation} \\label{matrixEquationLorentzTransform}\n\\left[\n\\begin{pmatrix}\na & d\n\\\\\nb & e\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right)\n\\right]^t\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\left[\n\\begin{pmatrix}\na & d\n\\\\\nb & e\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right)\n\\right]\n=\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right)^t\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\nSince $t$ and $x$ are arbitrary the only way for this equation to be true is\n\n\\begin{equation} \\label{minkowski}\n\\begin{pmatrix}\na & b\n\\\\\nd & e\n\\end{pmatrix}\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\begin{pmatrix}\na & d\n\\\\\nb & e\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\end{equation}\n\n\\begin{equation}\n\\iff\n\\begin{pmatrix}\na & b\n\\\\\nd & e\n\\end{pmatrix}\n\\begin{pmatrix}\na & d\n\\\\\n-b & -e\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\end{equation}\n\n\\begin{equation}\n\\iff\n\\begin{pmatrix}\na^2-b^2 & ad-be\n\\\\\nad-be & d^2-e^2\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n1 & 0\n\\\\\n0 & -1\n\\end{pmatrix}\n\\end{equation}\n\n\n\n\nThese are three equations for four parameters $a,b,d,e$. This means one free parameter will remain.\nWe are now going to solve these equations in such a way that $a,d,e$ are expressed through $b$:\n\n\\begin{equation}\na(b) = \\pm \\sqrt{1+b^2}\n\\end{equation}\n\n\\begin{equation}\n-1 = d^2-e^2 = \\frac{b^2e^2}{a^2} -e^2 = e^2 \\bigg(\\frac{b^2}{a^2} - 1 \\bigg)\n\\end{equation}\n\n\\begin{equation}\n\\iff e^2 = \\frac{1}{1-\\frac{b^2}{a^2}} = \\frac{1}{1-\\frac{b^2}{1+b^2}} = \\frac{1}{\\frac{1+b^2-b^2}{1+b^2}} = 1+b^2\n\\end{equation}\n\n\\begin{equation}\n\\iff e(b) = \\pm \\sqrt{1+b^2}\n\\end{equation}\n\n\n\\begin{equation}\nd^2 = e^2 -1 = b^2 \\iff d(b) = \\pm b\n\\end{equation}\n\n\\begin{equation} \\label{matrixExpressedByB}\n\\implies\n\\begin{pmatrix}\na & d\n\\\\\nb & e\n\\end{pmatrix}\n=\n\\begin{pmatrix}\n\\sqrt{1+b^2} & b\n\\\\\nb & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\end{equation}\n\nIn \\ref{matrixExpressedByB} we chose the positive solutions only.\nThis can be rectified by checking that the matrix \\ref{matrixExpressedByB} solves equation \\ref{minkowski}.\n\nThe transformation law now reads\n\n\\begin{equation}\n\\left(\\begin{array}{c}\nct'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n\\sqrt{1+b^2} & b\n\\\\\nb & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nct\n\\\\\nx\n\\end{array} \\right)\n\\;,\\; y'=y \\;,\\; z'=z\n\\end{equation}\n\nNext we want to move the speed of light $c$ from the vectors to the matrix.\nTo do so we write the above equation in the following form:\n\n\\begin{equation}\n\\begin{pmatrix}\nc & 0\n\\\\\n0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n\\sqrt{1+b^2} & b\n\\\\\nb & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\begin{pmatrix}\nc & 0\n\\\\\n0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\n\\begin{equation}\n\\iff\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n1/c & 0\n\\\\\n0 & 1\n\\end{pmatrix}\n\\begin{pmatrix}\n\\sqrt{1+b^2} & b\n\\\\\nb & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\begin{pmatrix}\nc & 0\n\\\\\n0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\n\\begin{equation}\n\\iff\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n\\sqrt{1+b^2} /c & b /c\n\\\\\nb & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\begin{pmatrix}\nc & 0\n\\\\\n0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\n\\begin{equation} \\label{transformationBasedOnb}\n\\iff\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n\\sqrt{1+b^2} & b /c\n\\\\\nc b  & \\sqrt{1+b^2}\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\n\\subsubsection{Calculation of $b$} \\label{calcOfB}\n\nWe would now like to give a physical interpretation of $b$.\nTo do so we consider \\ref{spaceTimeElement} for the special case where the particle moves with the origin of reference frame $T'$.\n\nFirst we use $y'=y, z'=z$ to simplify \\ref{spaceTimeElement} to\n\n\\begin{equation} \\label{spaceTimeElementReduced}\nc^2t'^2-x'^2 = c^2t^2-x^2\n\\end{equation}\n\nSince the particle resides in the origin of $T'$, $x'$ is zero which simplifies \\ref{spaceTimeElementReduced} to\n\n\\begin{equation}\nct' = \\sqrt{c^2 t^2 - x^2}\n\\end{equation}\n\nFurthermore the velocity of the particle in $T$ is given by the relative speed $v$ between the two reference frames.\nThis provides us with a relation between $x$ and $t$: $x/t=v$. Using this we can write\n\n\\begin{equation}\nct' = \\sqrt{c^2 t^2 - x^2} = \\sqrt{1 - \\frac{x^2}{c^2t^2}} \\; \\; \\; ct = \\sqrt{1 - \\frac{v^2}{c^2}} \\; \\; \\; ct\n\\end{equation}\n\n\\begin{equation} \\label{timeDilation}\n\\iff t' = \\sqrt{1 - \\frac{v^2}{c^2}} \\; \\; \\; t\n\\end{equation}\n\nThis special case of the transformation has to be consistent with our more general transformation given by \\ref{transformationBasedOnb}.\nThus the following two equations must hold for our special case:\n\n\\begin{equation}\nt' = \\sqrt{1+b^2} \\; \\; t + \\frac{b}{c} x = \\sqrt{1+b^2} \\; \\; t + \\frac{b}{c} v t\n\\end{equation}\nand\n\\begin{equation}\nt' = \\sqrt{1 - \\frac{v^2}{c^2}} \\; \\; \\; t\n\\end{equation}\n\nThis results in the following condition for b:\n\n\n\\begin{equation}\n\\sqrt{1 - \\frac{v^2}{c^2}} \\; \\; t = \\sqrt{1+b^2} \\; \\; t + \\frac{b}{c} v t\n\\end{equation}\n\n\\begin{equation} \\label{find_b}\n\\iff \\sqrt{1 - \\frac{v^2}{c^2}} = \\sqrt{1+b^2} + \\frac{b}{c} v\n\\end{equation}\n\n\nIt is certainly possible, but tedious to solve \\ref{find_b} for $b$. So we provide the solution\n\n\\begin{equation}\nb = \\frac{-v/c}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\end{equation}\n\nand check it is right:\n\n\\begin{equation}\n\\sqrt{1+b^2} + \\frac{b}{c} v\n= \\sqrt{1+\\frac{v^2/c^2}{1 - \\frac{v^2}{c^2}}} - \\frac{v^2/c^2}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n= \\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}  - \\frac{v^2/c^2}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n=  \\sqrt{1 - \\frac{v^2}{c^2}}\n\\end{equation}\n\nq.e.d.\n\n\n\\subsubsection{Lorentz transformation} \\label{sectLorentzTransform}\n\nIn preparation to plug $b$ into \\ref{transformationBasedOnb} we first consider\n\n\\begin{equation}\n\\sqrt{1+b^2}\n= \\sqrt{1 + \\frac{v^2/c^2}{1 - \\frac{v^2}{c^2}}}\n= \\sqrt{\\frac{1 - v^2/c^2 + v^2/c^2}{1 - \\frac{v^2}{c^2}}}\n= \\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\end{equation}\n\nUsing this \\ref{transformationBasedOnb} turns into\n\n\\begin{equation} \\label{lorentz}\n\\left(\\begin{array}{c}\nt'\n\\\\\nx'\n\\end{array} \\right)\n=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}} & \\frac{-v/c^2}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\\\\n\\frac{-v}{\\sqrt{1 - \\frac{v^2}{c^2}}}  & \\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n=\n\\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\begin{pmatrix}\n1 & -v/c^2\n\\\\\n-v & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\nt\n\\\\\nx\n\\end{array} \\right)\n\\end{equation}\n\nwhich is called Lorentz transformation.\n\n\\subsubsection{Interpretation and generalization} \\label{sectionGeneralizationLorentz}\n\nThis result with rigor is valid for the inertial reference frame $T'$ in which the particle is at rest at the frames origin.\nEven if the particle is accelerated along the $x$ axis, for small time intervals there always exists such an inertial reference frame.\nThose reference frames are called 'the particles momentary rest frame'.\n\\\\\n\\\\\nIf we look at \\ref{lorentz} in its full 4 dimensional form\n\n\\begin{equation}\n\\left(\\begin{array}{c}\n              t'\n              \\\\\n              x'\n              \\\\\n              y'\n              \\\\\n              z'\n\\end{array} \\right)\n=\n\\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\begin{pmatrix}\n    1 & -v/c^2 & 0 & 0\n    \\\\\n    -v & 1 & 0 & 0\n    \\\\\n    0 & 0 & 1 & 0\n    \\\\\n    0 & 0 & 0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\n          t\n          \\\\\n          x\n          \\\\\n          y\n          \\\\\n          z\n\\end{array} \\right)\n\\end{equation}\nit is obvious that it can be multiplied by rotation matrices\n\\begin{equation}\n\\begin{pmatrix}\n    1 & 0\n    \\\\\n    0 & R\n\\end{pmatrix}\n\\;,\\; \\text{where $R$ denotes a 3 dimensional rotation matrix}\n\\end{equation}\nand that these products still fulfill \\ref{spaceTimeElement}.\nThis in mind we can claim, that our derivation is valid for the momentary rest frame of a particle moving in an arbitrary direction relative to $T$.\n\\\\\n\\\\\nWith less rigor we can claim that for any two inertial reference frames $T$, $T'$ the particle's coordinates transform according to \\ref{lorentz}.\nBut still, \\ref{lorentz} fulfills the central proposition \\ref{spaceTimeElement} and thus is a good candidate for being the right transformation.\nIf this was true, the generalizations we just discussed will be applicable, too.\n\n\n\\section{Concepts and notations}\n\n\\subsection{Proper time} \\label{sectionProperTime}\n\nBe $T'$ with coordinates $t', x_1',x_2',x_3'$ a particle's momentary rest inertial reference frame (IRF) and be $T$ with coordinates $t, x_1,x_2,x_3$ an IRF from which we observe the particle.\nThen\n\\begin{equation}\n    c^2dt'^2 - dx'^2 = c^2dt^2 - dx^2\n\\end{equation}\nwith $x' := (x_1',x_2',x_3')$ and $x := (x_1,x_2,x_3)$ holds.\n\nBecause in the particle's momentary rest IRF $dx'=0$ we are left with\n\\begin{equation} \\label{defProperTime}\nc dt' = \\sqrt{c^2dt^2 - dx^2} = c \\sqrt{1- \\frac{v^2}{c^2}} \\; dt \\iff dt' = \\sqrt{1- \\frac{v^2}{c^2}} \\; dt\n\\end{equation}\nwhere $v=v(t)$ is the particles momentary velocity in the observer IRF.\n\nAccording to its definition $dt' = \\sqrt{1-\\frac{v^2}{c^2}} \\; dt$ is the time interval in the particles momentary rest IRF that corresponds to the time interval $dt$ in the observer IRF.\nSo any observer can calculate how long a time interval $dt$ in his IRF will be in the particles momentary rest IRF by $\\sqrt{1-\\frac{v^2}{c^2}} \\; dt$.\nThus all observers in IRFs will agree upon the time interval $dt'$ in the particles momentary rest IRF.\nThrough this recipe $dt'$ is the same in any IRF. By convention time intervals in the particle's momentary rest IRF are named $d\\tau$ and are called \"proper time\":\n\\begin{equation}\n    d\\tau = \\sqrt{1-\\frac{v^2}{c^2}} \\; dt\n\\end{equation}\nA more formal and even simpler way to see that $d\\tau$ is the same in every IRF is: If in one observer IRF the particle travels the distance\n\\begin{equation}\n    dx = \\left(\\begin{array}{c}\n                   dx_1\\\\\n                   dx_2\\\\\n                   dx_3\\\\\n    \\end{array} \\right)\n\\end{equation}\nin time $dt$ then the value of $c^2 dt^2 - dx^2$ is the same in every other IRF, too.\nThe same is true for its square root:\n\\begin{equation}\n    \\sqrt{c^2 dt^2 - dx^2} = \\sqrt{1-\\frac{v^2}{c^2}} \\; dt = d\\tau\n\\end{equation}\n\n\\subsection{4-velocity} \\label{section4Velocity}\nThe invariance of proper time $d\\tau$ allows us to define a new object which under Lorentz transformations transforms like $(c \\; dt,dx_1,dx_2,dx_3)$:\n\\begin{equation}\n    u := \\frac{1}{d \\tau}\n    \\left(\\begin{array}{c}\n              c \\; dt\\\\\n              dx_1\\\\\n              dx_2\\\\\n              dx_3\\\\\n    \\end{array} \\right)\n    = \\frac{1}{\\sqrt{1-\\frac{v^2}{c^2}}}\n    \\left(\\begin{array}{c}\n              c \\\\\n              v_1\\\\\n              v_2\\\\\n              v_3\\\\\n    \\end{array} \\right)\n\\end{equation}\n$u$ is called the particles \"4-velocity\".\n\n\\subsection{Notations} \\label{sectionNotations}\nFrom section \\ref{sectionGeneralizationLorentz} we know that Lorentz transformations can be written as $4 \\times 4$ matrices.\nIn the following we consider $\\Lambda$ as such a matrix:\n\nFor any Lorentz transformation $\\Lambda$ of a particle's coordinates and time $X := (c t,x_1,x_2,x_3)$ the following equation must hold\n\\begin{equation} \\label{generalConditionForLorentzTransformations}\n\\Lambda^t g \\Lambda = g \\;\\; \\text{where} \\;\\;\ng :=\n\\begin{pmatrix}\n    1 & 0 & 0 & 0\n    \\\\\n    0 & -1 & 0 & 0\n    \\\\\n    0 & 0 & -1 & 0\n    \\\\\n    0 & 0 & 0 & -1\n\\end{pmatrix}\n\\;\\begin{array}{c}\\text{In special relativity} \\\\ \\text{$g$ is called metric tensor} \\\\ \\text{or simply metric.}\\end{array}\n\\end{equation}\nThis is the general form of \\ref{matrixEquationLorentzTransform} and a direct consequence of \\ref{invarianceSpaceTimeInterv}.\nIt is the formal definition of a general Lorentz transformation, i.e. any $4 \\times 4$-matrix that fulfills this equation is a Lorentz transformation of $X$.\nWith these definitions the transformation of $X$ by $\\Lambda$ is given by matrix-vector multiplication $\\Lambda X$.\nUp to now we know three 4-component objects that transform like $X$.\nThose are $X$ itself, intervals $dX$ of $X$ and the 4-velocity $u$ from the former section.\nAny 4-component object that transforms like $X$ is called a \"4-vector\".\n\n\\subsection{Invariance of the 4-vector product} \\label{invarianceOf4VectorProduct}\nThe product $V^t g W$ of two 4-vectors $V,W$ is invariant under Lorentz-Transformations, i.e. is the same in any IRF.\nProof:\n\\begin{equation}\n    (\\Lambda V)^t g (\\Lambda W) = V^t \\Lambda^t g \\Lambda W = V^t g W\n\\end{equation}\n\n\\subsubsection{Proper time revisited}\nWith the concept of the 4-vector product we can write\n\\begin{align}\n    & dX^{t} g \\; dX = c^2 dt^2 - dx^2 \\\\\n    \\iff & \\sqrt{dX^{t} g \\; dX} = c \\; \\sqrt{1-\\frac{v^2}{c^2}} \\; dt = c \\; d\\tau\n\\end{align}\nThis is another proof of the invariance of $d\\tau$ is invariant under Lorentz-Transformations.\n\\footnote{\nAccording to the upcoming section \\ref{sectionInvariance} the invariance of $d\\tau$ under Lorentz-Transformations is given by the fact that\n\\begin{equation}\n    d\\tau = \\sqrt{1-\\frac{v^2}{c^2}} \\; dt = \\sqrt{1-\\frac{v'^2}{c^2}} \\; dt'\n\\end{equation}\nis true for any two IRFs $T$ and $T'$ where time is given by $t$ and $t'$ respectively and the particle's velocity is given by $v$ and $v'$ respectively.\n}\n\n\n\\section{On the Lagrange formulation of particle dynamics} \\label{particleLagrangian}\n\nThe main result of this section will be the derivation of the transformation law of the electromagnetic potentials $A,\\phi$ as given in \\cite{LagrangeOfField} from the invariance of the Lorentz force.\nAnother important result will be the derivation of $E=mc^2$.\n\nQuite a few preparations in the field of classical non relativistic particle physics will be needed for this.\nThese preparations are done in the first subsection.\n\n\\subsection{On the Lagrange formulation of classical non relativistic particle dynamics}\n\n\\subsubsection{Energy conservation} \\label{energyConservation}\nThe Lagrange formalism for particle physics as described in \\cite{WagnerGuthrie}, as we will show, allows to derive energy conservation from analyzing how the action $S$ behaves under infinitesimal time translations. \nBy doing so we will find a definition for the energy of any physical system that is described by a particle Lagrangian. \\\\\n\nTo kick off we consider the action\n\n\\begin{equation}\nS = \\int_{t_1}^{t_2} L(q(t), \\dot{q}(t), t) \\dd t\n\\end{equation}\n\nwhere $L(q(t), \\dot{q}(t), t)$ is the particle's Lagrange function, $q$ the particle's position coordinates and $t$ time. $t_1$,$t_2$ are fixed but arbitrary endpoints of a time interval of which we calculate the particle's action $S$. \n($S$ can be considered as a function of $t_1$ and $t_2$: $S = S(t_1,t_2)$)\n\nWe now ask by what amount $S$ changes if time is changed from $t$ to $t + \\delta t$ with $\\delta t$ being a small time interval.\nThe resulting change $\\delta S$ of $S$ is given by\n\n\\begin{equation} \\label{defDelS}\n\\delta S = \\int_{t_1 + \\delta t}^{t_2 + \\delta t} L(q(t), \\dot{q}(t), t) \\dd t \n- \\int_{t_1}^{t_2} L(q(t), \\dot{q}(t), t) \\dd t\n\\end{equation}\n\nNext we use the substitution rule which is given by\n\\begin{equation}\n\\int_{\\varphi(t_1)}^{\\varphi(t_2)} f(x) \\dd x = \\int_{t_1}^{t_2} f(\\varphi(t)) \\; \\dot{\\varphi}(t) \\dd t\n\\end{equation}\n\nFor $\\varphi (t) = t + \\delta t$ the rule reads\n\\begin{equation}\n\\int_{t_1 + \\delta t}^{t_2 + \\delta t} f(t) \\dd t = \\int_{t_1}^{t_2} f(t + \\delta t) \\dd t\n\\end{equation}\n\nSince $\\delta t$ is small we can write\n\\begin{equation}\n\\int_{t_1 + \\delta t}^{t_2 + \\delta t} f(t) \\dd t \n= \\int_{t_1}^{t_2} \\bigg(f(t) + \\frac{\\dd f}{\\dd t} \\delta t \\bigg) \\dd t\n\\end{equation} \n\nApplying this to \\ref{defDelS} we arrive at\n\n\\begin{equation}\n\\delta S = \\int_{t_1}^{t_2} \\bigg(L + \\frac{\\dd L}{\\dd t} \\delta t \\bigg) \\dd t - \\int_{t_1}^{t_2} L \\dd t\n= \\delta t \\int_{t_1}^{t_2} \\frac{\\dd L}{\\dd t} \\dd t\n\\end{equation}\n\nWe will now assume that the particle's trajectory $q(t)$ is its physical trajectory which fulfills the Euler-Lagrange-Equation\n\n\\begin{equation} \\label{ParticleEulLagEqu}\n\\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L}{\\partial q} = 0\n\\end{equation}\n\nTo make use of this equation we reformulate $\\delta S$ as follows\n\n\\begin{equation}\n\\delta S = \\delta t \\int_{t_1}^{t_2} \\frac{\\dd L}{\\dd t} \\dd t\n= \\delta t \\int_{t_1}^{t_2} \\bigg(\n\\frac{\\partial L}{\\partial q} \\dot{q} + \\frac{\\partial L}{\\partial \\dot{q}} \\ddot{q} + \\frac{\\partial L}{\\partial t} \n\\bigg) \\dd t\n\\end{equation}\n\nIntegration by parts of the second term leads to\n\n\\begin{equation}\n\\delta S = \\delta t \\int_{t_1}^{t_2} \\bigg(\n\\frac{\\partial L}{\\partial q} \\dot{q} -\\bigg( \\frac{\\dd }{\\dd t}\\frac{\\partial L}{\\partial \\dot{q}} \\bigg) \\dot{q} \n + \\frac{\\partial L}{\\partial t}\n\\bigg) \\dd t\n+ \\delta t \\bigg[ \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg]_{t_1}^{t_2}\n\\end{equation}\n\nWith \\ref{ParticleEulLagEqu} we are left with\n\n\\begin{equation}\n\\delta S = \\delta t \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t\n+ \\delta t \\bigg[ \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg]_{t_1}^{t_2}\n= \\delta t \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t\n+ \\delta t \\int_{t_1}^{t_2} \\frac{\\dd}{\\dd t} \\bigg( \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg) \\dd t\n\\end{equation}\n\nWe now found two expressions for $\\delta S$:\n\n\\begin{equation}\n\\delta S = \\delta t \\int_{t_1}^{t_2} \\frac{\\dd L}{\\dd t} \\dd t \n\\;\\; \\text{and} \\;\\;\n\\delta S = \\delta t \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t\n+ \\delta t \\int_{t_1}^{t_2} \\frac{\\dd}{\\dd t} \\bigg( \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg) \\dd t\n\\end{equation}\n\nSetting these to equal gives\n\n\\begin{align}\n\\int_{t_1}^{t_2} \\frac{\\dd L}{\\dd t} \\dd t\n&=  \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t\n+ \\int_{t_1}^{t_2} \\frac{\\dd}{\\dd t} \\bigg( \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg) \\dd t \\\\\n\\iff\n- \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t  \n&=  \\int_{t_1}^{t_2} \\bigg(\n\\frac{\\dd}{\\dd t} \\bigg( \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q} \\bigg) - \\frac{\\dd L}{\\dd t} \\bigg) \\dd t \\\\\n\\iff\n- \\int_{t_1}^{t_2} \\frac{\\partial L}{\\partial t} \\dd t  \n&=  \\int_{t_1}^{t_2} \\frac{\\dd}{\\dd t} \\bigg(\\frac{\\partial L}{\\partial \\dot{q}} \\dot{q}  - L \\bigg) \\dd t\n\\end{align}\n\n\nFor the case $\\partial L / \\partial t = 0 $ this leads to\n\\begin{equation}\n0 = \\int_{t_1}^{t_2} \\frac{\\dd}{\\dd t} \\bigg(\\frac{\\partial L}{\\partial \\dot{q}} \\dot{q}  - L \\bigg) \\dd t\n\\end{equation}\n\nSince $t_1$ and $t_2$ are arbitrary this equation can only be true if\n\n\\begin{equation} \\label{legendre}\n0 = \\frac{\\dd}{\\dd t} \\bigg(\\frac{\\partial L}{\\partial \\dot{q}} \\dot{q}  - L \\bigg) \n\\implies \nE := \\frac{\\partial L}{\\partial \\dot{q}} \\dot{q}  - L = const\n\\end{equation}\n\n\\textbf{Interpretation}\n\\begin{itemize}\n\\item $E$ is called energy of the particle. $E$ is defined for any particle that can be described by the Lagrange formalism for particle physics. It is constant in time when $\\partial L / \\partial t = 0 $ i.e. when the particle's Lagrangian doesn't explicitly depend on time but depends on time through the particles coordinates $q(t)$ only.\n\n\\item \n$E$ was derived from analyzing how $S$ behaves under infinitesimal time translation. So energy conservation can be considered as a consequence of the behavior of a particle's action $S$ under infinitesimal time translations.\n\n\\item\nThere are more transformations, e.g. spacial translations and rotations, which also lead to conserved quantities. \nThose are easier to derive because for them $\\delta S = 0$. They can be found in any classical mechanics text book.\n\n\\item\nFor the standard classical mechanics Lagrangian\n\\begin{equation}\nL = T-V = \\frac{1}{2} m v^2 - V \n\\end{equation}\nthe energy calculates to\n\\begin{equation}\nE = \\frac{\\partial}{\\partial v} \\bigg(\\frac{1}{2} m v^2 - V \\bigg) v - \\bigg(\\frac{1}{2} m v^2 - V\\bigg) =  \\frac{1}{2} m v^2 + V\n\\end{equation}\n\n\\end{itemize}\n\n\\subsubsection{Invariance of a Lagrangian} \\label{sectionInvariance}\nLet $q=f(\\bar{q},t)$ be an invertible and differentiable transformation of coordinates $q=(q_1,q_2, ...,q_n)$ and let $L=L(q, \\dot{q},t)$ be a Lagrangian of the $q$.\n$L$ is called invariant under the transformation $f$ if\n\n\\begin{equation} \\label{defInvarianceLagrange1}\n    \\bar{L}(\\bar{q},\\dot{\\bar{q}},t) = L(\\bar{q},\\dot{\\bar{q}},t)\n\\end{equation}\nwhere $\\bar{L}$ is as usual defined by $\\bar{L}(\\bar{q},\\dot{\\bar{q}},t) := L(f(\\bar{q}), \\dot{f}(\\bar{q}),t)$.\nFrom this definition another equivalent formulation of \\ref{defInvarianceLagrange1} follows immediately:\n\n\\begin{equation} \\label{defInvarianceLagrange2}\nL(q,\\dot{q},t) = L(\\bar{q},\\dot{\\bar{q}},t)\n\\end{equation}\n\nA good way to picture invariance is that the structure of the Lagrangian is such that the transformation cancels out.\n\\\\ \\\\\n\\textbf{Example:}\nAn example is a Lagrangian of a particle in classical mechanics in cartesian coordinates of the form $L=\\frac{1}{2}m v^2 - V(|x|)$ where $x$ and $v$ denote a particle's position and velocity respectively.\nIf in this case the transformation is a rotation of the particles coordinates $x = f(\\bar{x}) := R\\bar{x}$ with $1 = R^tR $ then $L$ is invariant under this transformation.\n\\\\ \\\\\nSince the Euler-Lagrange equations are never changed by transformations of the form $q=f(\\bar{q},t)$ the following is true:\n\\\\ \\\\\n\\hypertarget{hrefDefintionFormInvariance}{\\textbf{Definition of form invariance:}} \\\\\nIf a Lagrangian is invariant under a transformation $f$ the equations of motion in the two sets of coordinates that f connects will be the same with just the untransformed and transformed coordinates interchanged.\n\n\\subsubsection{Generalization of the invariance of a Lagrangian} \\label{sectionGeneralizationInvariance}\nWe are going to generalize the ideas of the last section in such a way that we are able to include fields.\nAn example for a particle Lagrangian with fields is that of a charged particle in an electromagnetic field.\n\nThe generalized particle Lagrangian we assume to be of the form\n\\begin{equation}\n    L = L \\bigg(\\psi,\\frac{\\partial \\psi}{\\partial q},\\frac{\\partial \\psi}{\\partial t},q,\\dot{q},t\\bigg)\n\\end{equation}\nwhere $\\psi$ denotes a field that generally consists of multiple components (like for example the electric field).\nBe\n\\begin{align}\n    &q=f(\\bar{q}) \\\\\n    &\\psi = F(\\bar{\\psi})\n\\end{align}\ntransformations of the coordinates and the field, then the transformed Lagrangian is as usual defined by\n\\begin{equation} \\label{defineGeneralizedParticleLagrangianTransform}\n    \\bar{L} \\bigg(\\bar{\\psi},\\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}},\\frac{\\partial \\bar{\\psi}}{\\partial t},\\bar{q},\\dot{\\bar{q}},t\\bigg)\n    := L \\bigg(F,\\frac{\\partial F}{\\partial f},\\frac{\\partial F}{\\partial t}, f,\\dot{f},t\\bigg)\n\\end{equation}\nThe Lagrangian is called invariant under the transformations $f$ and $F$, if\n\\begin{equation} \\label{defInvarianceLagrange1Generalized}\n    \\bar{L} \\bigg(\\bar{\\psi},\\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}},\\frac{\\partial \\bar{\\psi}}{\\partial t},\\bar{q},\\dot{\\bar{q}},t\\bigg)\n    = L \\bigg(\\bar{\\psi},\\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}},\\frac{\\partial \\bar{\\psi}}{\\partial t},\\bar{q},\\dot{\\bar{q}},t\\bigg)\n\\end{equation}\nfrom which again immediately follows that\n\\begin{equation} \\label{defInvarianceLagrange2Generalized}\n    L \\bigg(\\bar{\\psi},\\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}},\\frac{\\partial \\bar{\\psi}}{\\partial t},\\bar{q},\\dot{\\bar{q}},t\\bigg)\n    = L \\bigg(\\psi,\\frac{\\partial \\psi}{\\partial q},\\frac{\\partial \\psi}{\\partial t},q,\\dot{q},t\\bigg)\n\\end{equation}\nNotes:\n\\begin{itemize}\n    \\item The concept of invariance may be generalized to any function which transforms according to \\ref{defineGeneralizedParticleLagrangianTransform}.\n    \\item In the following we will learn that the Lagrangian of a particle in special relativity takes the form $L \\sqrt{1 - \\frac{v^2}{c^2}}$,\n    where only the part $L$ will turn out to be invariant under Lorentz transformations, while $L \\sqrt{1 - \\frac{v^2}{c^2}}$ as a whole is not invariant under Lorentz transformations.\n\\end{itemize}\n\n\n\n\\subsubsection{The Lorentz force and its Lagrangian} \\label{sectionLorentzForceLagrangian}\n\nThe Lorentz force on a particle with charge $e$ in cartesian coordinates is given by\n\n\\begin{equation} \\label{lorentzForceLaw}\n    F_L = e E + e v \\times B\n\\end{equation}\nwhere $v$ is the particles velocity and $E,B$ are respectively the electric and magnetic fields at the particle's coordinates.\nThe Lagrangian that corresponds to the Lorentz force is given by\n\n\\begin{equation} \\label{lorentzForceLagrangian}\n    L_L = - e (\\phi - A \\cdot v)\n\\end{equation}\nwhere $\\phi, A$ are respectively the electric and magnetic potentials as discussed in \\cite{LagrangeOfField}\n\n$L_L$ is the part of the Lagrangian of a charged particle in an electro magnetic field that represents the particle's interaction with the electro magnetic field.\nIn classical mechanics the whole Lagrangian is\n\\begin{equation}\n    L = \\frac{1}{2}mv^2 + L_L\n\\end{equation}\n\nTo show that $L_L$ reproduces the Lorentz force $F_L$ we prove\n\n\\begin{equation}\n    F_L = -\\bigg(\\frac{\\dd}{\\dd t} \\frac{\\partial L_L}{\\partial v} - \\frac{\\partial L_L}{\\partial x} \\bigg)\n\\end{equation}\n\nWe start with\n\n\\begin{equation}\n    \\frac{\\partial L_L}{\\partial v_i} = e A_i\n\\end{equation}\n\n\\begin{align}\n    \\implies & \\frac{\\dd}{\\dd t} \\frac{\\partial L_L}{\\partial v_i} = e \\bigg(\\frac{\\partial A_i}{\\partial t} + \\frac{\\partial A_i}{\\partial x_j} v_j\\bigg) \\\\\n    & \\text{with} \\;\\; i,j \\in \\{1,2,3\\} \\\\\n    & \\text{and implicit sum over duplicate indices} \\nonumber\n\\end{align}\nTo understand the term $\\frac{\\partial A_i}{\\partial x_j} v_j$ we consider that during some small time interval $\\dd t$ the particles coordinates change by $\\dd x_j = v_j \\dd t$.\nHence $A_i$'s change resulting from the change $\\dd x_j$ is given by $\\frac{\\partial A_i}{\\partial x_j} \\dd x_j = \\frac{\\partial A_i}{\\partial x_j} v_j \\dd t$.\nSo the coordinate wise contribution of $A_i$ to the total time derivative of $\\frac{\\partial L_L}{\\partial v_i}$ is $\\frac{\\partial A_i}{\\partial x_j} v_j$.\n\nWe continue with $\\frac{\\partial L_L}{\\partial x_i}$:\n\n\\begin{equation}\n    \\frac{\\partial L_L}{\\partial x_i} = -e \\frac{\\partial \\phi}{\\partial x_i} + e \\frac{\\partial A_j}{\\partial x_i} v_j\n\\end{equation}\nThus\n\\begin{align}\n    \\frac{\\dd}{\\dd t} \\frac{\\partial L_L}{\\partial v_i} - \\frac{\\partial L_L}{\\partial x_i}\n    & = e \\bigg(\\frac{\\partial A_i}{\\partial t} + \\frac{\\partial A_i}{\\partial x_j} v_j\\bigg)\n    - \\bigg( -e \\frac{\\partial \\phi}{\\partial x_i} + e \\frac{\\partial A_j}{\\partial x_i} v_j \\bigg) \\nonumber \\\\\n    & = - e \\bigg( -\\frac{\\partial \\phi}{\\partial x_i} - \\frac{\\partial A_i}{\\partial t} \\bigg)\n    - e \\bigg( v_j \\frac{\\partial A_j}{\\partial x_i}  - v_j \\frac{\\partial A_i}{\\partial x_j}  \\bigg)\n\\end{align}\nWe next use the relations $B = \\nabla \\times A$ and $E = - \\nabla \\phi - \\frac{\\partial A}{\\partial t}$ which were introduced in  \\cite{LagrangeOfField}.\n\nAs an intermediate step we consider\n\\begin{align}\n[v \\times B]_i &= [v \\times (\\nabla \\times A)]_i \\nonumber \\\\\n&=\\epsilon_{ijk} v_j [\\nabla \\times A]_k \\nonumber \\\\\n&=\\epsilon_{ijk} v_j \\epsilon_{kln} \\frac{\\partial A_n}{\\partial x_l} \\nonumber \\\\\n&=\\epsilon_{kij} \\epsilon_{kln} v_j  \\frac{\\partial A_n}{\\partial x_l} \\nonumber \\\\\n&=(\\delta_{il} \\delta_{jn} - \\delta_{in} \\delta_{jl} ) v_j  \\frac{\\partial A_n}{\\partial x_l} \\nonumber \\\\\n&=v_j \\frac{\\partial A_j}{\\partial x_i} - v_j \\frac{\\partial A_i}{\\partial x_j} \\nonumber\n\\end{align}\nwhere $\\epsilon_{ijk}$ is the Levi-Civita symbol, $\\delta_{ij}$ is the Kronecker delta and where we made use of the rule\n$\\epsilon_{ijk} \\epsilon_{ilm} = \\delta_{jl}\\delta_{km} - \\delta_{jm}\\delta_{kl}$.\n\nWith that we arrive at\n\\begin{equation}\n    \\frac{\\dd}{\\dd t} \\frac{\\partial L_L}{\\partial v_i} - \\frac{\\partial L_L}{\\partial x_i}\n    = - e E_i - e [v \\times B]_i = -F_L_i\n\\end{equation}\nwhich is the result we wanted to prove.\n\n\\subsection{On the Lagrange formulation of relativistic particle dynamics} \\label{sectionOnRelativisticParticles}\n\n\\subsubsection{The first postulate of special relativity} \\label{sectionFirstPostulate}\nThe first postulate of special relativity says that the laws of physics are the same in all IRFs.\nThis is to say they are \\hyperlink{hrefDefintionFormInvariance}{form invariant} in all IRFs.\n\nAs time is changed by Lorentz transformations we cannot simply use the results from section \\ref{sectionInvariance} but have to argue in a somewhat different way:\nWe require that a particle's action integral\n\\begin{equation} \\label{relativisticAction}\n    S = \\int\\limits_{\\tau_1}^{\\tau_2} L \\dd \\tau\n\\end{equation}\nover it's proper time $\\tau$ must be invariant\n\\footnote{For brevity in the sub sections of \\ref{sectionOnRelativisticParticles} by invariant we mean invariant under Lorentz transformations.}.\nNotable aspects of this are:\n\\begin{itemize}\n    \\item The invariance of $S$ is to be understood in the sense of sections \\ref{sectionInvariance} and \\ref{sectionGeneralizationInvariance}.\n    \\item Since the interval $d  \\tau$ of proper time is invariant then for $S$ to be invariant the Lagrangian $L$ must be invariant, too.\n    \\item When $S$ is invariant any stationary point of $S$ is invariant, too.\n\\end{itemize}\nIn an observer IRF with time $t$ and where the particle's velocity is $v$ we may write \\ref{relativisticAction} in the form\n\\begin{equation} \\label{relativisticActionWithObserver}\n    S = \\int\\limits_{\\tau_1}^{\\tau_2} L \\dd \\tau = \\int\\limits_{t_1}^{t_2} L \\; \\sqrt{1-\\frac{v^2}{c^2}} \\; \\dd t\n\\end{equation}\nwhere in the last equation we used the substitution rule $\\int_{\\varphi(t_1)}^{\\varphi(t_2)} f(x) \\dd x = \\int_{t_1}^{t_2} f(\\varphi(t)) \\; \\dot{\\varphi}(t) \\dd t$ with $\\dot{\\varphi}(t)= \\frac{d \\tau}{d t} = \\sqrt{1-\\frac{v(t)^2}{c^2}}$.\n\\\\\n\\\\\n\\textbf{Form invariance:}\\\\\nThe equations of motion for $L \\; \\sqrt{1-\\frac{v^2}{c^2}}$ will be form invariant in all IRFs as long as $L$ is invariant.\nThis is because different of observers will just plug their particle velocity in $\\sqrt{1-\\frac{v^2}{c^2}}$ and then calculate the Euler-Lagrange equations for $L \\; \\sqrt{1-\\frac{v^2}{c^2}}$.\nThis will not be able to break the definition of \\hyperlink{hrefDefintionFormInvariance}{form invariance}.\n\n\\subsubsection{Application to the Lorentz force law} \\label{sectionConsequencesOfInvarianceLorentzForce}\nIt is usually said that the first postulate of special relativity claims that the laws of physics are the same in all IRFs.\nIn the introduction of his first paper on special relativity \\cite{EinsteinSpecialRelativity} Einstein did not mention this general form.\n\\\\\n\\\\\n\\hypertarget{einsteinsOriginalFirstPostulate}{\\textbf{Einsteins original first postulate:}}\nHis original formulation was that by postulate the laws of Maxwell's electrodynamics are the same in every IRF.\n\\\\\n\\\\\nHere we make the weaker assumption that the Lorentz force law $F_L = eE + ev \\times B$ (see \\ref{lorentzForceLaw}) is the same in every IRF, i.e. is \\hyperlink{hrefDefintionFormInvariance}{form invariant}.\nWith \\ref{lorentzForceLagrangian} the part of the action that represents the Lorentz force can be written as\n\\begin{equation}\n    S_L = \\int\\limits_{t_1}^{t_2} L_L \\; \\dd t \\;\\; \\text{with} \\;\\; L_L = - e (\\phi - A \\cdot v)\n\\end{equation}\nwhich can be given the form \\ref{relativisticActionWithObserver} by writing\n\\begin{equation}\n    S_L = \\int\\limits_{t_1}^{t_2} \\frac{L_L}{\\sqrt{1-\\frac{v^2}{c^2}}} \\; \\sqrt{1-\\frac{v^2}{c^2}} \\; \\dd t\n        = \\int\\limits_{\\tau_1}^{\\tau_2} \\frac{L_L}{\\sqrt{1-\\frac{v^2}{c^2}}} \\;  \\dd \\tau\n\\end{equation}\nThe form invaraince of the Lorentz force law now requires\n\\begin{equation}\n    \\frac{L_L}{\\sqrt{1-\\frac{v^2}{c^2}}} = \\frac{- e (\\phi - A \\cdot v)}{\\sqrt{1-\\frac{v^2}{c^2}}}\n\\end{equation}\nto be invariant.\nThis is equivalent to\n\\begin{align}\n    \\frac{L_L}{\\sqrt{1-\\frac{v^2}{c^2}}} &= \\frac{- e (\\phi - A \\cdot v)}{\\sqrt{1-\\frac{v^2}{c^2}}}  = - \\frac{1}{\\sqrt{1-\\frac{v^2}{c^2}}} \\; e (\\frac{\\phi}{c} , A_1, A_2, A_3) \\; g\n    \\left(\\begin{array}{c}\n      c \\\\\n      v_1\\\\\n      v_2\\\\\n      v_3\\\\\n    \\end{array} \\right) \\nonumber \\\\\n    &= - e (\\frac{\\phi}{c} , A_1, A_2, A_3) \\; g \\; u \\label{invariantLorentzForceLagrangian}\n\\end{align}\nbeing invariant.\nNote that in this formula we used the 4-velocity $u$ from section \\ref{section4Velocity}.\n\nTo explicitly study the meaning of this we consider the following:\nBe $T$ and $T'$ two IRFs.\nFrom both we observe a particle.\nLet the particles space and time coordinates in $T$ and $T'$ be given by $X = (ct,x_1,x_2,x_3)$ and $X' = (ct',x_1',x_2',x_3')$ respectively.\nThen there exists a Lorentz transformation $\\Lambda$ such that $X' = \\Lambda X$.\n(Note that $X$ and $X'$ describe the same position in space and time, namely the particle's position.)\nWhat invariance of \\ref{invariantLorentzForceLagrangian} means, is\n\\begin{align}\n    &\\;e (\\frac{\\phi'(X')}{c} , A_1'(X'), A_2'(X'), A_3'(X')) \\; g \\; u' \\nonumber \\\\\n    = &\\;e (\\frac{\\phi(X)}{c} , A_1(X), A_2(X), A_3(X)) \\; g \\; u \\;\\;\\; \\text{see \\ref{defInvarianceLagrange1Generalized} and \\ref{defInvarianceLagrange2Generalized}} \\nonumber \\\\\n%    = &\\;e (\\frac{\\phi(\\Lambda X)}{c} , A_1(\\Lambda X), A_2(\\Lambda X), A_3(\\Lambda X)) \\; g \\; u\n\\end{align}\nFrom section \\ref{section4Velocity} we know that $u'=\\Lambda u$.\nThus the above equation turns into\n\\begin{align}\n    &\\;e (\\frac{\\phi'(X')}{c} , A_1'(X'), A_2'(X'), A_3'(X')) \\; g \\; \\Lambda u \\nonumber \\\\\n    = &\\;e (\\frac{\\phi(X)}{c} , A_1(X), A_2(X), A_3(X)) \\; g \\; u \\label{invarianceLorentzLagrange}\n\\end{align}\nThe simplest way to fulfill this equation is that\n\\begin{equation}\n    (\\frac{\\phi'(X')}{c} , A_1'(X'), A_2'(X'), A_3'(X'))\n    = \\left[ \\Lambda\n           \\left(\\begin{array}{c}\n                     \\phi(X) / c \\\\\n                     A_1(X)\\\\\n                     A_2(X)\\\\\n                     A_3(X)\\\\\n           \\end{array} \\right) \\right]^t\n\\end{equation}\nbecause then \\ref{invarianceLorentzLagrange} turns into\n\\begin{align}\n&\\;e (\\frac{\\phi(X)}{c} , A_1(X), A_2(X), A_3(X)) \\; \\Lambda^t \\; g \\; \\Lambda u \\nonumber \\\\\n= &\\;e (\\frac{\\phi(X)}{c} , A_1(X), A_2(X), A_3(X)) \\; g \\; u \\nonumber\n\\end{align}\nwhich with \\ref{generalConditionForLorentzTransformations} is true.\n\nSo we find that in the sense of section \\ref{sectionNotations}\n\\begin{equation} \\label{vectorPotentialsAreA4Vector}\n    \\left(\\begin{array}{c}\n              \\phi / c \\\\\n              A_1\\\\\n              A_2\\\\\n              A_3\\\\\n    \\end{array} \\right)\n  \\;\\; \\text{is a 4-vector.}\n\\end{equation}\nThis is an important result!\nIt will be further investigated and compared to an alternative derivation in section \\ref{sectionGauge}\n\n\n\n\\subsubsection{The relativistic free particle} \\label{sectionRelativisticFreeParticle}\nNext we are going to find the Lagrangian for the free particle in special relativity.\nRemember: A free particle is a particle with zero net force acting upon it.\n\\footnote{As in classical mechanics the Lagrangian of a particle in an electromagnetic field will be the sum of the Lagrangian of the free particle and $L_L$.}\n\nThe simplest guess that can be thought of is that $L$ is some constant $k$ which is just the same in any IRF.\nThe way we will proceed is to compare this guess with the classical limit and see if it works.\nIn case it works we will find out what the value of $k$ is.\n\nWe assume we observe the particle from within some observer IRF with time $t$.\nIn the observer IRF we assume particle's velocity to be given by $v$.\nThe particles Lagrangian in the observer IRF according to \\ref{relativisticActionWithObserver} will then be\n\\begin{equation}\n    L = k \\sqrt{1-\\frac{v^2}{c^2}}\n\\end{equation}\n\nTo compare $k \\sqrt{1 - \\frac{v^2}{c^2}}$ to its classical limit, i.e. for the limit $v << c$, we first consider some some mathematical preliminaries:\\\\\n\n$(1+\\epsilon)^\\alpha$ for small $\\epsilon$ can be approximated by the first two terms of its Taylor series:\n\\begin{equation}\n    (1+\\epsilon)^\\alpha\n    \\approx (1+\\epsilon)^\\alpha \\Big|_{\\epsilon = 0}\n    + \\frac{\\dd \\; (1+\\epsilon)^\\alpha}{\\dd \\epsilon}\\Big|_{\\epsilon = 0} \\cdot \\epsilon\n    = 1 + \\alpha (1+\\epsilon)^{\\alpha -1} \\Big|_{\\epsilon = 0} \\cdot \\epsilon\n    = 1 + \\alpha \\epsilon\n\\end{equation}\n\nApplying this approximation to our relativistic Lagrangian with $\\epsilon = - v^2/c^2$ results in\n\n\\begin{equation}\n    L \\approx k \\bigg(1 + \\frac{1}{2} \\bigg(-\\frac{v^2}{c^2} \\bigg) \\bigg)\n    = k + \\frac{1}{2} \\bigg(-\\frac{k}{c^2} \\bigg) v^2\n\\end{equation}\n\nSince additional constants (in our case $k$) do not have effect on the equation of motion (i.e. the Euler-Lagrange-Equation) it is sufficient to compare the second term of this approximation to the free particle Lagrangian of classical mechanics, which is given by $L=1/2 m v^2$.\nThe two become identical if we choose\n\\begin{equation}\n    - \\frac{k}{c^2} = m \\iff k = -mc^2\n\\end{equation}\n\nThus our guess of the relativistic free particle Lagrangian is consistent with classical mechanics for small particle velocity $v$ if we write\n\n\\begin{equation} \\label{freeRelativistivParticleLagrangian}\nL = -mc^2 \\sqrt{1-\\frac{v^2}{c^2}}\n\\end{equation}\n\n\n\\subsubsection{Energy of the relativistic free particle ($E=mc^2$)}\n\nWith \\ref{freeRelativistivParticleLagrangian} the energy of the free particle can according to \\ref{legendre} be calculated as follows:\n\n\\begin{align}\n    E &= \\frac{\\partial L}{\\partial v} v - L \\\\\n    &= -m c^2 \\frac{1}{2 \\sqrt{1-\\frac{v^2}{c^2}}} \\bigg(-\\frac{2v}{c^2} \\bigg) \\cdot v\n    -\\bigg(-mc^2 \\sqrt{1-\\frac{v^2}{c^2}} \\bigg) \\\\\n    &= m c^2 \\bigg(\\frac{v^2/c^2}{\\sqrt{1-\\frac{v^2}{c^2}}} + \\sqrt{1-\\frac{v^2}{c^2}} \\bigg) \\\\\n    &= m c^2 \\bigg(\\frac{v^2/c^2 + 1 - v^2/c^2}{\\sqrt{1-\\frac{v^2}{c^2}}} \\bigg) \\\\\n    &= \\frac{m c^2}{\\sqrt{1-\\frac{v^2}{c^2}}}\n\\end{align}\n\nFor a particle at rest ($v=0$) this takes Einstein's famous form, which tells us that in the theory of special relativity a particle with mass $m$ is assigned an energy $E = m c^2$.\n\n\n\\subsubsection{The equations of motion of the free relativistic particle} \\label{sectionEquOfMotionFreeParticle}\n\nThe equations of motion for the free relativistic particle are given by\n\n\\begin{align}\n    &0 = \\frac{\\dd}{\\dd t} \\frac{\\partial }{\\partial v_i} \\bigg(-mc^2 \\sqrt{1-\\frac{v^2}{c^2}}\\bigg) - \\frac{\\partial }{\\partial x_i} \\bigg(-mc^2 \\sqrt{1-\\frac{v^2}{c^2}}\\bigg)\n    \\nonumber \\\\\n    \\iff &0 = \\frac{\\dd}{\\dd t} \\frac{\\partial }{\\partial v_i} \\bigg(-mc^2 \\sqrt{1-\\frac{v^2}{c^2}}\\bigg) \\;\\; \\text{for} \\;\\; i \\in \\{1,2,3\\}\n\\end{align}\n\nWe start with\n\n\\begin{equation}\n    \\frac{\\partial L}{\\partial v_i} = - m c^2 \\frac{1}{2 \\sqrt{1 - \\frac{v^2}{c^2}}} \\bigg(- \\frac{2 v_i}{c^2}\\bigg) = \\frac{m v_i}{\\sqrt{1 - \\frac{v^2}{c^2}}}\n\\end{equation}\n\n\n\\begin{align}\n   \\implies \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial v_i}\n   &= \\frac{m \\dot{v_i}}{\\sqrt{1 - \\frac{v^2}{c^2}}} + \\frac{m v_i}{-2 \\sqrt{1 - \\frac{v^2}{c^2}}^3} \\frac{-2 v_j \\dot{v_j}}{c^2} \\;\\; \\text{with imlicit sum over} \\;\\; j \\in \\{1,2,3\\} \\nonumber \\\\\n   &= \\frac{m \\dot{v_i}}{\\sqrt{1 - \\frac{v^2}{c^2}}} + \\frac{m v_i}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} \\frac{v_j \\dot{v_j}}{c^2} \\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\bigg( \\dot{v_i} + \\frac{v_i}{\\frac{c^2 - v^2}{c^2}} \\frac{v_j \\dot{v_j}}{c^2} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\bigg( \\dot{v_i} + \\frac{v_i}{c^2 - v^2} v_j \\dot{v_j} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\frac{1}{c^2 -v^2} \\bigg( (c^2 -v^2) \\dot{v_i} + v_i v_j \\dot{v_j} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\frac{1}{c^2 -v^2} \\bigg( c^2 \\dot{v_i} - v_j v_j \\dot{v_i} + v_i v_j \\dot{v_j} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\frac{c^2}{c^2 -v^2} \\bigg( \\dot{v_i} + \\frac{v_i v_j \\dot{v_j} - v_j v_j \\dot{v_i}}{c^2} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}} \\frac{c^2}{c^2\\big(1- \\frac{v^2}{c^2}\\big)} \\bigg( \\dot{v_i} + \\frac{v_i v_j \\dot{v_j} - v_j v_j \\dot{v_i}}{c^2} \\bigg)\\nonumber \\\\\n   &= \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} \\bigg( \\dot{v_i} + \\frac{v_i v_j \\dot{v_j} - v_j v_j \\dot{v_i}}{c^2} \\bigg) \\label{relativisticFreeEquationOfMotion}\n\\end{align}\n\n\nThe identity\n\n\n\\begin{align}\n    [ v \\times (v \\times \\dot{v})]_i &= \\epsilon _{ijk} v_j (v \\times \\dot{v})_k \\nonumber \\\\\n    &= \\epsilon _{ijk} v_j \\epsilon _{kln} v_l \\dot{v}_n \\nonumber \\\\\n    &= \\epsilon_{kij} \\epsilon _{kln}  v_j v_l \\dot{v}_n \\nonumber \\\\\n    &= (\\delta_{il} \\delta_{jn} - \\delta_{in} \\delta_{jl})  v_j v_l \\dot{v}_n \\nonumber \\\\\n    &= v_j v_i \\dot{v}_j - v_j v_j \\dot{v}_i \\nonumber \\\\\n\\end{align}\n\nallows to write \\ref{relativisticFreeEquationOfMotion} as\n\n\\begin{equation}\n    \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial v} = \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} (\\dot{v} + \\frac{1}{c^2} v \\times (v \\times \\dot{v}))\n\\end{equation}\n\nSo the equation of motion for the free relativistic particle reads\n\n\\begin{equation}\n    0 = \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} (\\dot{v} + \\frac{1}{c^2} v \\times (v \\times \\dot{v}))\n\\end{equation}\n\n\\subsubsection{Lagrangian of the relativistic particle in an electromagnetic field}\n\nAs a results from sections \\ref{sectionConsequencesOfInvarianceLorentzForce} and \\ref{sectionRelativisticFreeParticle} we can write down the Lagrangian of the relativistic particle in an electromagnetic field:\n\\begin{align} \\label{lagrangianOfRelativisticParticleInEMField}\nL &= -mc^2 \\sqrt{1-\\frac{v^2}{c^2}} \\; - e (\\phi - A \\cdot v) \\nonumber \\\\\n&= ( -mc^2 - e (\\frac{\\phi}{c} , A_1, A_2, A_3) \\; g \\; u)) \\sqrt{1-\\frac{v^2}{c^2}}\n\\end{align}\n\n\n\\subsubsection{The equations of motion of the relativistic particle in an electromagnetic field}\nThe equations of motion of the relativistic particle in an electromagnetic field\ncan be calculate from \\ref{lagrangianOfRelativisticParticleInEMField} and with the results from sections \\ref{sectionLorentzForceLagrangian} and \\ref{sectionEquOfMotionFreeParticle} reads:\n\n\\begin{align}\n    &F_L = \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} (\\dot{v} + \\frac{1}{c^2} v \\times (v \\times \\dot{v})) \\nonumber \\\\\n    \\iff & eE + e v \\times B = \\frac{m}{\\sqrt{1 - \\frac{v^2}{c^2}}^3} (\\dot{v} + \\frac{1}{c^2} v \\times (v \\times \\dot{v}))\n\\end{align}\n\n\n\\section{Relativistic field Lagrangians}\n\nIn \\cite{LagrangeOfField} we derived the Lagrange formalism for classical fields.\nClassical in the sence that time was a special coordinate which was treated well separated from spacial coordinates.\nAs we learned in section \\ref{foundations}, in special relativity spacial coordinates and time are not clearly separated anymore.\nThis becomes obvious when we look at \\ref{lorentz} where in contrast to \\ref{Galilei} the spacial coordinate $x$ contributes to time.\n\nThat's the reason why we strive to modify the Lagrange formalism for fields in such a way that time and spacial coordinates are treated uniformly:\n\n\\begin{equation} \\label{relativisticFielLagrangian}\n    \\mathcal{L} = \\mathcal{L}\\bigg(\\psi,\\frac{\\partial \\psi}{\\partial q}\\bigg)\n\\end{equation}\n\nwhere $q$ denotes spacial coordinates including time and $\\psi$ denotes the field.\nThe field may consist of multiple components.\nA well known example for a multiple component field is the electric field which in classical non relativistic electrodynamics consists of three components, that make up its direction in space.\n\nThe most intuitive ansatz for an action $S$ created from $\\mathcal{L}$ is\n\n\\begin{equation} \\label{relativisticFielAction}\n    S = \\int\\limits_{A} \\mathcal{L}\\bigg(\\psi,\\frac{\\partial \\psi}{\\partial q}\\bigg) \\dd q^{n}\n\\end{equation}\n\nwhere $n$ denotes the number (dimension) of the coordiantes $q$ and $A$ an arbitrary n-dimensional area in the space of the $q$.\n\\\\\n\nAs laid out in \\cite{WagnerGuthrie} and \\cite{LagrangeOfField} we have clear criteria to decide if the Lagrangian formalism arising\nfrom \\ref{relativisticFielLagrangian} and \\ref{relativisticFielAction} is useful. These criteria are:\n\n\\begin{itemize}\n    \\item[1.] Does the principle of stationary action lead to Euler-Lagrange equations?\n    \\item[2.] Are the Euler-Lagrange equations invariant under arbitrary differentiable and invertible transformations of the coordinates $q$ and the fields $\\psi$?\n    \\item[3.] Does the Lagrangian $\\mathcal{L}$ transform in a well defined way.\n\\end{itemize}\n\nIf these criteria are fulfilled we are well motivated to find Lagrangians for physical field theories such that their field equations\nbecome the Euler-Lagrange equations of these Lagrangians.\n\n\\subsection{Euler Lagrange equations \\cite{LagrangeOfField}} \\label{sectionEulerLagrangeEquation}\n\nWe consider the variations $\\delta S$ of $S$ that result from variations $\\delta \\psi$ of the fields.\nThe variation of the fields is arbitrary except from the condition that it vanishes on the border of $A$ which we denote by $\\partial A$:\n\n\\begin{equation}\n    \\delta \\psi(q) = 0 \\; \\text{when} \\; q \\in \\partial A\n\\end{equation}\n\n\nThe variation of $S$ is given by\n\n\\begin{equation} \\label{actionVariation}\n    \\delta S = \\int\\limits_{A} \\frac{\\partial \\mathcal{L}}{\\partial \\psi} \\delta \\psi\n               + \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\cdot  \\delta \\bigg(\\frac{\\partial \\psi}{\\partial q}\\bigg) \\dd q ^n\n\\end{equation}\n\n\nIf we consider the possibly multidimensional components of $\\psi$ indexed by $j$ and the $q$ coordinates by $i$ these summands mean:\n\\begin{equation}\n    \\frac{\\partial \\mathcal{L}}{\\partial \\psi} \\cdot \\delta \\psi\n    = \\sum_{j} \\frac{\\partial \\mathcal{L}}{\\partial \\psi_{j}} \\; \\delta \\psi_{j}\n\\end{equation}\n\\begin{equation}\n    \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\cdot \\delta \\bigg(\\frac{\\partial \\psi} {\\partial q}\\bigg)\n    = \\sum_{i,j} \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi_{j}}{\\partial q_{i}}} \\; \\delta \\bigg(\\frac{\\partial \\psi_{j}} {\\partial q_{i}}\\bigg)\n\\end{equation}\n\nWe integrate the second summand of \\ref{actionVariation} by parts. To do so we use the identity\n$\\delta \\big(\\frac{\\partial \\psi} {\\partial q}\\big)\n= \\frac{\\partial \\psi_2} {\\partial q} - \\frac{\\partial \\psi_1} {\\partial q}\n= \\frac{\\partial (\\psi_2 - \\psi_1)} {\\partial q}\n= \\frac{\\partial \\delta \\psi} {\\partial q}$\n\n\\begin{equation}\n    \\delta S = \\int\\limits_{A}\n    \\frac{\\partial \\mathcal{L}}{\\partial \\psi} \\cdot \\delta \\psi\n    -\\bigg(\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\\bigg) \\cdot \\delta \\psi\n    \\dd q^n\n    + \\int\\limits_{A} \\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\cdot \\delta \\psi \\bigg) \\dd q^n\n\\end{equation}\nThe second integral vanishes because of Gauss's theorem and $\\delta \\psi(q) = 0$ for any $q$ on the surface $\\partial A$ of $A$.\n\n\\begin{equation}\n\\delta S = \\int\\limits_{A}\n\\frac{\\partial \\mathcal{L}}{\\partial \\psi} \\cdot \\delta \\psi\n-\\bigg(\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\\bigg) \\cdot \\delta \\psi\n\\dd q^n\n\\end{equation}\n\n\nIf we use the same index conventions for the field $\\psi$ and $q$ as we did above the last term means\n\n\\begin{equation}\n    \\bigg(\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\\bigg) \\cdot \\delta \\psi\n    = \\sum_j \\bigg(\\sum_i \\frac{\\partial}{\\partial q_i} \\; \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi_j}{\\partial q_i}} \\bigg)\\bigg) \\; \\delta \\psi_j\n\\end{equation}\nwhere the sum over $i$ is called the divergence of $\\partial \\mathcal{L} / \\partial \\frac{\\partial \\psi_j}{\\partial q}$.\n\nThe last rewrite of $\\delta S$ we do is\n\n\\begin{equation}\n    \\delta S = \\int\\limits_{A}\n    \\bigg(\n    \\frac{\\partial \\mathcal{L}}{\\partial \\psi}\n    -\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\\bigg) \\cdot \\delta \\psi\n    \\dd q^n\n\\end{equation}\n\nSince $\\delta \\psi$ is arbitrary (except from its border conditions) the only way to make $S$ stationary (which is equivalent to require $\\delta S = 0$) is that $\\mathcal{L}$ fulfills the condition\n\n\\begin{equation} \\label{EulerLagrangeField}\n    0 = \\frac{\\partial \\mathcal{L}}{\\partial \\psi}\n    -\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\n\\end{equation}\nThis is the Euler-Lagrange equation we were looking for.\nOf course this equation actually consist of multiple equations for the coordinates and the field components.\nThat is why it is common to use the plural and speak of the Euler-Lagrange equation\\textbf{s}.\n\n\\subsection{Invariance of the Euler-Lagrange equations under transformations \\cite{LagrangeOfField}} \\label{LagrangeTranformation}\n\nThis section is very close to what we did in section 3 of \\cite{LagrangeOfField}.\nNonetheless it is worth verifying that the arguments work without time as a special coordinate, too.\n\\\\\n\nLet $q=f(\\bar{q})$ be an invertible and differentiable transformation of the coordinates and $\\psi=F(\\bar{\\psi})$ be an invertible and differentiable transformation of the field.\nWe define the transformed Lagrangian  $\\bar{\\mathcal{L}}$ by\n\n\\begin{equation} \\label{LagrTransform}\n\\bar{\\mathcal{L}}\\bigg(\\bar{\\psi}, \\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}}\\bigg)\n:= \\mathcal{L}\\bigg(F(\\bar{\\psi}) , \\frac{\\partial F(\\bar{\\psi})}{\\partial f}\\bigg)\n\\bigg| det \\frac{\\partial f}{\\partial \\bar{q}} \\bigg|\n\\end{equation}\nwhere $\\big| det \\frac{\\partial f}{\\partial \\bar{q}} \\big|$ is the absolute value of the determinant of the Jacobian matrix of $f$ with respect to the coordinates $\\bar{q}$. \\\\\n\nWe will prove that from requiring $S$ to be stationary the two equations\n\n\\begin{equation} \\label{ELGTransformed}\n0 = \\frac{\\partial \\bar{\\mathcal{L}}}{\\partial \\bar{\\psi}}\n-\\frac{\\partial}{\\partial \\bar{q}} \\cdot \\bigg( \\frac{\\partial \\mathcal{\\bar{L}}}{\\partial \\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}}} \\bigg)\n\\end{equation}\nand\n\n\\begin{equation} \\label{ELGUntransformed}\n0 = \\frac{\\partial \\mathcal{L}}{\\partial \\psi}\n-\\frac{\\partial}{\\partial q} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial \\psi}{\\partial q}} \\bigg)\n\\end{equation}\nfollow and thus that the Euler-Lagrange equations are independent of arbitrary coordinate and field transformations as long as the transformation of the Lagrangian is given by \\ref{LagrTransform}. \\\\\n\nTo do so we consider arbitrary but small variations $\\delta \\bar{\\psi}$ of the field $\\bar{\\psi}$ that vanish on the surface of an area of space $\\bar{A}$.\nThese we use to find the condition for\n\n\\begin{equation}\n    S = \\int\\limits_{\\bar{A}} \\bar{\\mathcal{L}}\\bigg(\\bar{\\psi}, \\frac{\\partial \\bar{\\psi}}{\\partial \\bar{q}}\\bigg) \\dd \\bar{q}^n\n    = \\int\\limits_{\\bar{A}} \\mathcal{L}\\bigg(F(\\bar{\\psi}), \\frac{\\partial F(\\bar{\\psi})}{\\partial f}\\bigg)\n    \\bigg| det \\frac{\\partial f}{\\partial \\bar{q}} \\bigg| \\dd \\bar{q}^n\n\\end{equation}\nto become stationary.\\\\\n\n\\ref{ELGTransformed} just follows from repeating the considerations of section \\ref{sectionEulerLagrangeEquation}. \\\\\n\nTo prove \\ref{ELGUntransformed} we look at\n\n\\begin{equation}\n    S = \\int\\limits_{\\bar{A}} \\mathcal{L}\\bigg(F(\\bar{\\psi}), \\frac{\\partial F(\\bar{\\psi})}{\\partial f}\\bigg)\n    \\bigg| det \\frac{\\partial f}{\\partial \\bar{q}} \\bigg| \\dd \\bar{q}^n\n\\end{equation}\nwhich by using the transformation formula of multidimensional integrals can be turned into\n\n\\begin{equation}\n    S = \\int\\limits_{f(\\bar{A})} \\mathcal{L}\\bigg(F(\\bar{\\psi}), \\frac{\\partial F(\\bar{\\psi})}{\\partial f}\\bigg) \\dd f^n\n\\end{equation}\nwhere $f(\\bar{A})$ is the picture of $\\bar{A}$ under the coordinate transformation $f$.\n\n\nBased on this formula the variation $\\delta S$ of $S$ is given by\n\n\\begin{equation}\n    \\delta S = \\int\\limits_{f(\\bar{A})}\n    \\frac{\\partial \\mathcal{L}}{\\partial F} \\cdot \\delta F\n    + \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial F}{\\partial f}} \\cdot \\delta \\bigg(\\frac{\\partial F} {\\partial f}\\bigg)\n    \\dd f^n\n\\end{equation}\nwhere\n\n\\begin{equation} \\label{deltaFDefinition}\n\\delta F = \\frac{\\partial F}{\\partial \\bar{\\psi}} \\delta \\bar{\\psi}\n\\end{equation}\n\n\nIntegration by parts of the second term leads to\n\n\\begin{equation} \\label{calcDeltaSSection3}\n\\begin{split}\n    \\delta S = \\int\\limits_{f(\\bar{A})}\n    \\frac{\\partial \\mathcal{L}}{\\partial F} \\cdot \\delta F\n    -\\bigg(\\frac{\\partial}{\\partial f} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial F}{\\partial f}} \\bigg)\\bigg) \\cdot \\delta F\n    \\dd f^n\n    + \\int\\limits_{f(\\bar{A})} \\frac{\\partial}{\\partial f} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial F}{\\partial f}} \\cdot \\delta F \\bigg) \\dd f^n\n\\end{split}\n\\end{equation}\nwhere the identity\n$\\delta \\big(\\frac{\\partial F} {\\partial f}\\big)\n= \\frac{\\partial F_2} {\\partial f} - \\frac{\\partial F_1} {\\partial f}\n= \\frac{\\partial (F_2 - F_1)} {\\partial f}\n= \\frac{\\partial \\delta F} {\\partial f}$\nwas used. \\\\\n\nThe second integral of \\ref{calcDeltaSSection3} can be transformed into an integral over the surface of $f(\\bar{A})$ which we denote by $\\partial (f(\\bar{A}))$. This surface is the same as the picture of the surface of $\\bar{A}$ under $f$:\n\\begin{equation}\n    \\partial (f(\\bar{A})) = f(\\partial \\bar{A})\n    \\footnote {The simplest way to picture this equation is to imagine a real area in space, which is described from within two systems of coordinates.}\n\\end{equation}\nTo show that the third term vanishes, we will prove, that $\\delta F$ is zero for any $q \\in \\partial (f(\\bar{A}))$:\n\\\\\n\\\\\n\n\\noindent \\textbf{Begin proof}\n\\\\\nLet $q$ be an element of $\\partial (f(\\bar{A}))$.\n\\footnote{The simplest way to picture this element is to imagine a real point on the surface of the area in space, which is described from within two systems of coordinates.}\nThen for $q$ there exists an unique $\\bar{q} \\in \\partial \\bar{A}$ which is defined by $q=f(\\bar{q})$.\nWe are going to use the fact from above that $\\delta \\bar{\\psi}(\\bar{q}) = 0$.\nWe recall that the variation $\\delta \\bar{\\psi}$ is a difference between two fields which we name $\\bar{\\psi}_1$ and $\\bar{\\psi}_2$ such that\n\\begin{equation}\n    \\delta \\bar{\\psi} = \\bar{\\psi}_2 - \\bar{\\psi}_1\n\\end{equation}\nThe value of $F$ considered as a function of $q$ is given by\n\\begin{equation}\n    F(q) = F(\\bar{\\psi}(\\bar{q})) \\;\\; \\text{with} \\;\\; \\bar{q} \\;\\; \\text{defined through} \\;\\; q=f(\\bar{q})\n    \\iff \\bar{q} = f^{-1}(q)\n\\end{equation}\nThe variation $\\delta F$ that results from the difference $\\delta \\bar{\\psi}$ between $\\bar{\\psi}_1$ and $\\bar{\\psi}_2$ is given by\n\\begin{equation}\n    \\delta F(q) = F(\\bar{\\psi}_2(\\bar{q})) - F(\\bar{\\psi}_1(\\bar{q}))\n    = F(\\bar{\\psi}_1(\\bar{q}) + \\delta \\bar{\\psi} (\\bar{q})) - F(\\bar{\\psi}_1(\\bar{q}))\n    = \\frac{\\partial F}{\\partial \\bar{\\psi}} \\delta \\bar{\\psi} (\\bar{q})\n\\end{equation}\nSince $\\delta \\bar{\\psi}(\\bar{q})$ is zero by assumption, $\\delta F(q)$ is zero, too, which finishes the proof.\n\\\\\n\\textbf{End proof}\n\\\\\n\\\\\n\n\\noindent As to $\\delta S$ we are now left with\n\n\n\\begin{equation}\n    \\delta S = \\int\\limits_{f(\\bar{A})}\n    \\bigg(\n    \\frac{\\partial \\mathcal{L}}{\\partial F}\n    -\\frac{\\partial}{\\partial f} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial F}{\\partial f}} \\bigg)\\bigg) \\cdot \\delta F\n    \\dd q^n\n\\end{equation}\n\nBecause of \\ref{deltaFDefinition} $\\delta F$ is equally arbitrary as $\\delta \\bar{\\psi}$. Thus the only way for $\\delta S$ to become zero is\n\n\\begin{equation}\n    0 =\n    \\frac{\\partial \\mathcal{L}}{\\partial F}\n    -\\frac{\\partial}{\\partial f} \\cdot \\bigg( \\frac{\\partial \\mathcal{L}}{\\partial \\frac{\\partial F}{\\partial f}} \\bigg)\n\\end{equation}\n\nIf we now replace $F$ and $f$ according to their definitions by $\\psi$ and $q$ this equation turns into \\ref{ELGUntransformed} and thus finishes the proof.\n\n\n\\subsection{Relativistic electrodynamics}\n\n\\subsubsection{Relativistic from of the Lagrangian of electrodynamics} \\label{sectionRelativisticLagrangianElectrodynamics}\nIn literature on electrodynamics it is common to state that electrodynamics is a relativistic theory.\nThis is to say that the first postulate, see section \\ref{sectionFirstPostulate}, applies to the laws of electrodynamics.\n\nBased on the previous two sections we will show that by two simple transformations of the\nnon relativistic Lagrangian of electrodynamics it can be made clear what this statement exactly means and in which sense it is true.\n\nIn fact based on the results from section \\ref{sectionConsequencesOfInvarianceLorentzForce} and appendix \\ref{appendixConinuity} we are able to prove that the laws of electrodynamics are the same in every inertial reference frame.\n\\\\\n\nWe start with the non relativistic Lagrangian of electrodynamics from \\cite{LagrangeOfField}:\n\n\\begin{equation} \\label{LagrangianElectDynClassical}\n    \\mathcal{L} = \\epsilon_0 \\frac{(-\\nabla\\phi - \\frac{\\partial A}{\\partial t})^2 - c^2 (\\nabla \\times A)^2}{2} - \\rho\\phi + j \\cdot A\n\\end{equation}\n\n\nIn the sense of section \\ref{LagrangeTranformation} we consider the following transfomations of\n\\begin{itemize}\n    \\item time $t$ and the three spacial coodinates $x$\n    \\item the fields $\\phi$ and $A$\n    \\item the charge density $\\rho$ and the current density $j$\n\\end{itemize}\n\n\\begin{equation} \\label{coordinateTransformClassical}\n\\left(\\begin{array}{c}\n          t\n          \\\\\n          x_1\n          \\\\\n          x_2\n          \\\\\n          x_3\n\\end{array} \\right)\n= f(x_0,x_1,x_2,x_3)\n:=\n\\begin{pmatrix}\n    1/c & 0 & 0 & 0\n    \\\\\n    0 & 1 & 0 & 0\n    \\\\\n    0 & 0 & 1 & 0\n    \\\\\n    0 & 0 & 0 & 1\n\\end{pmatrix}\n\\left(\\begin{array}{c}\n          x_0\n          \\\\\n          x_1\n          \\\\\n          x_2\n          \\\\\n          x_3\n\\end{array} \\right)\n=\n\\left(\\begin{array}{c}\n          x_0/c\n          \\\\\n          x_1\n          \\\\\n          x_2\n          \\\\\n          x_3\n\\end{array} \\right)\n\\end{equation}\n\n\n\\begin{equation} \\label{fieldTransformClassical}\n    \\left(\\begin{array}{c}\n              \\phi\n              \\\\\n              A_1\n              \\\\\n              A_2\n              \\\\\n              A_3\n    \\end{array} \\right)\n    = F_A(A_0,A_1,A_2,A_3)\n    :=\n    \\begin{pmatrix}\n        c & 0 & 0 & 0\n        \\\\\n        0 & 1 & 0 & 0\n        \\\\\n        0 & 0 & 1 & 0\n        \\\\\n        0 & 0 & 0 & 1\n    \\end{pmatrix}\n    \\left(\\begin{array}{c}\n              A_0\n              \\\\\n              A_1\n              \\\\\n              A_2\n              \\\\\n              A_3\n    \\end{array} \\right)\n    =\n    \\left(\\begin{array}{c}\n              c A_0\n              \\\\\n              A_1\n              \\\\\n              A_2\n              \\\\\n              A_3\n    \\end{array} \\right)\n\\end{equation}\n\n\\begin{equation} \\label{currentTransformClassical}\n    \\left(\\begin{array}{c}\n              \\rho\n              \\\\\n              j_1\n              \\\\\n              j_2\n              \\\\\n              j_3\n    \\end{array} \\right)\n    = F_J (J_0,J_1,J_2,J_3)\n    :=\n    \\begin{pmatrix}\n        1/c & 0 & 0 & 0\n        \\\\\n        0 & 1 & 0 & 0\n        \\\\\n        0 & 0 & 1 & 0\n        \\\\\n        0 & 0 & 0 & 1\n    \\end{pmatrix}\n    \\left(\\begin{array}{c}\n              J_0\n              \\\\\n              J_1\n              \\\\\n              J_2\n              \\\\\n              J_3\n    \\end{array} \\right)\n    =\n    \\left(\\begin{array}{c}\n              J_0/c\n              \\\\\n              J_1\n              \\\\\n              J_2\n              \\\\\n              J_3\n    \\end{array} \\right)\n\\end{equation}\n\n\n\\footnote{\nOne may argue that this transformation is nothing but a change of variables or a change of units and to treat it as a transformation of the Lagrangian is exaggerated.\nThis true in the sense that the equations of motions (Maxwell's equations) can be rewritten in the new variables/units straight forward.\nBut since this paper stressed the importance of the transformation behavior of the Lagrangian and the Euler-Lagrange equations much, we found it adequate to use it at this point, too.\n\nAfter all when the transformation is defined there is no discussion needed how it applies to the Lagrangian or to the equations of motion.\nAll there is to do it is to apply rule \\ref{LagrTransform}, algebra and calculus.\nFurthermore we think it's worth pointing out that a change of units can be interpreted as a coordinate transformation.\nAs discussed in \\cite{WagnerGuthrie} coordinates are not part of nature but are just a human means  to think about nature.\nRealizing that this holds for units too, makes the argument relevant to every day life, where units are quite inevitable.\nNonetheless because of their are arbitrariness units can't be part of reality itself.\n\nThose who tend to philosophize may find that units are a suitable means to illustrate the shadows in Plato's Cave.\n\nAnyway we feel it satisfying that the Lagrange formalism restricts and makes clear the influence that coordinates and units have in scientific thinking.\n} % end \\footnote\n\n\nThe transformed Lagrangian, which we denote $\\mathcal{L}_R$, is according to \\ref{LagrTransform} given by\n\n\\begin{equation}\n    \\mathcal{L}_R = \\frac{1}{c} \\mathcal{L} \\bigg(F, \\frac{\\partial F}{\\partial f} \\bigg) \\;,\\; \\text{$F$ symbolizes $F_A$ and $F_J$}\n\\end{equation}\nThe factor $1/c$ comes from the determinant of the matrix in \\ref{coordinateTransformClassical}.\nThis matrix is the Jacobi matrix of $f$ with respect to $x_0,x_1,x_2,x_3$ and thus according to \\ref{LagrTransform} the determinant of this matrix has to be included.\n\nReplacing $\\mathcal{L}$, $F$ and $f$ by their definitions results in\n\n\\begin{equation}\n    \\mathcal{L}_R = \\frac{1}{c} \\bigg\\{ \\frac{\\epsilon_0}{2} \\bigg[ \\bigg(-c \\nabla A_0 - \\frac{\\partial A}{\\partial (\\frac{x_0}{c})}\\bigg)^2 - c^2 \\bigg(\\nabla \\times A\\bigg)^2 \\bigg]\n    - \\big( J_0 A_0 - J \\cdot A \\big) \\bigg\\}\n\\end{equation}\n\n\\begin{equation} \\label{maxwellHalfRelatifistic}\n    = \\frac{1}{c} \\bigg\\{ - \\frac{c^2 \\epsilon_0}{2} \\bigg[ -\\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2 + \\bigg(\\nabla \\times A\\bigg)^2 \\bigg]\n    - \\big( J_0 A_0 - J \\cdot A \\big) \\bigg\\}\n\\end{equation}\nwhere $A$ and $J$ without index denote  $\\left( \\begin{array}{c} A_1 \\\\ A_2 \\\\ A_3 \\end{array} \\right)$ and $\\left( \\begin{array}{c} J_1 \\\\ J_2 \\\\ J_3 \\end{array} \\right)$ respectively.\nFor the next steps we will concentrate on the two terms in square brackets.\nFirst we look at $\\big(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\big)^2$:\n\n\\begin{equation} \\label{A0_Equation}\n    \\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2\n      = \\bigg(\\frac{\\partial A_i}{\\partial x_0} + \\frac{\\partial A_0}{\\partial x_i} \\bigg) \\bigg(\\frac{\\partial A_i}{\\partial x_0} + \\frac{\\partial A_0}{\\partial x_i} \\bigg)\n\\end{equation}\nwhere we implicitly sum over the duplicate index $i$ from $1$ to $3$.\n\\\\\n\\\\\n\\noindent We will now use the following definition of a new symbol $\\partial$:\n\n\\begin{equation} \\label{partialDerivTimesG}\n\\partial_0 := \\frac{\\partial}{\\partial x_0} \\;,\\;\n\\partial_1 := -\\frac{\\partial}{\\partial x_1} \\;,\\;\n\\partial_2 := -\\frac{\\partial}{\\partial x_2} \\;,\\;\n\\partial_3 := -\\frac{\\partial}{\\partial x_3}\n\\end{equation}\n\\\\\n\\noindent\n\\textbf{Note:} The defintion can also be written as:\n\\begin{equation}\n    \\left(\\begin{array}{c}\n              \\partial_0\n              \\\\\n              \\partial_1\n              \\\\\n              \\partial_2\n              \\\\\n              \\partial_3\n    \\end{array} \\right)\n    := g\n    \\left(\\begin{array}{c}\n              \\frac{\\partial}{\\partial x_0}\n              \\\\\n              \\frac{\\partial}{\\partial x_1}\n              \\\\\n              \\frac{\\partial}{\\partial x_2}\n              \\\\\n              \\frac{\\partial}{\\partial x_3}\n    \\end{array} \\right)\n    =\n    \\left(\\begin{array}{c}\n              \\frac{\\partial}{\\partial x_0}\n              \\\\\n              -\\frac{\\partial}{\\partial x_1}\n              \\\\\n              -\\frac{\\partial}{\\partial x_2}\n              \\\\\n              -\\frac{\\partial}{\\partial x_3}\n    \\end{array} \\right)\n\\end{equation}\nwhere the metric tensor $g$ was defined in \\ref{generalConditionForLorentzTransformations}.\n\\\\\n\\\\\n\\noindent\nWith definition \\ref{partialDerivTimesG} equation \\ref{A0_Equation} turns into\n\n\\begin{equation}\n\\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2\n= \\big(\\partial_0 A_i - \\partial_i A_0 \\big) \\big(\\partial_0 A_i - \\partial_i A_0 \\big)\n\\end{equation}\n\n\\begin{equation}\n= \\frac{1}{2} \\bigg[  \\big(\\partial_0 A_i - \\partial_i A_0 \\big) \\big(\\partial_0 A_i - \\partial_i A_0 \\big)\n                    + \\big(\\partial_i A_0 - \\partial_0 A_i \\big) \\big(\\partial_i A_0 - \\partial_0 A_i \\big)\\bigg]\n\\end{equation}\n\n\nwith $F_{0i} := \\partial_0 A_i - \\partial_i A_0 $ and $F_{i0} := \\partial_i A_0 - \\partial_0 A_i \\big$\n\n\\begin{equation}\n    = \\frac{1}{2} \\bigg[ F_{0i}F_{0i} + F_{i0}F_{i0} \\bigg]\n\\end{equation}\n\n\nNext we look at $(\\nabla \\times A)^2$:\n\n\\begin{equation}\n    (\\nabla \\times A)^2 = \\epsilon_{ijk} \\epsilon_{ilm} \\frac{\\partial A_k}{\\partial x_j} \\frac{\\partial A_m}{\\partial x_l}\n\\end{equation}\n\n\nwhere again we implicitly sum over all duplicate indexes from $1$ to $3$.\n\n\n\\begin{equation}\n    = \\epsilon_{ijk} \\epsilon_{ilm} \\partial_j A_k \\partial_l A_m\n\\end{equation}\n\nwith the rule $\\epsilon_{ijk} \\epsilon_{ilm} = \\delta_{jl}\\delta_{km} - \\delta_{jm}\\delta_{kl}$ this can be written as\n\n\\begin{equation}\n    = (\\delta_{jl}\\delta_{km} - \\delta_{jm}\\delta_{kl}) \\partial_j A_k \\partial_l A_m\n\\end{equation}\n\n\\begin{equation}\n    = \\partial_j A_k \\partial_j A_k - \\partial_j A_k \\partial_k A_j\n\\end{equation}\n\n\\begin{equation}\n    = \\frac{1}{2} \\bigg[   \\partial_j A_k \\partial_j A_k - \\partial_j A_k \\partial_k A_j\n                         + \\underbrace{\\partial_k A_j \\partial_k A_j}_\\text{$= \\partial_j A_k \\partial_j A_k$}  - \\partial_j A_k \\partial_k A_j \\bigg]\n\\end{equation}\n\n\\begin{equation}\n    = \\frac{1}{2} \\bigg[ (\\partial_j A_k - \\partial_k A_j) (\\partial_j A_k - \\partial_k A_j)  \\bigg]\n\\end{equation}\n\nwith $F_{jk} := (\\partial_j A_k - \\partial_k A_j)$\n\n\\begin{equation}\n    = \\frac{1}{2} F_{jk} F_{jk}\n\\end{equation}\n\nThus for the term $\\bigg[ -\\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2 + \\bigg(\\nabla \\times A\\bigg)^2 \\bigg]$\nof equation \\ref{maxwellHalfRelatifistic} we find:\n\n\\begin{equation}\n    -\\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2 + \\bigg(\\nabla \\times A\\bigg)^2\n    = \\frac{1}{2} \\bigg[ -(F_{0i} F_{0i} + F_{i0} F_{i0}) + F_{jk} F_{jk}\\bigg]\n\\end{equation}\n\n\nWe define $F_{\\mu\\nu} := \\partial_\\mu A_\\nu - \\partial_\\nu A_\\mu$ with $\\mu, \\nu \\in \\{0,1,2,3\\}$.\nIf we take into account that from this definition $F_{00} = 0$ follows, we can write\n\n\\begin{equation}\n-\\bigg(\\frac{\\partial A}{\\partial x_0} + \\nabla A_0 \\bigg)^2 + \\bigg(\\nabla \\times A\\bigg)^2\n= \\frac{1}{2} F_{\\mu\\nu}F_{\\alpha\\beta} g_{\\mu\\alpha} g_{\\nu\\beta}\n\\end{equation}\nwhere $g_{\\mu\\nu}$ are the elements of the metric tensor \\ref{generalConditionForLorentzTransformations}.\n\\\\\n\\\\\n\\noindent\n\\textbf{Note:} For the rest of this paper we will always consider greek indexes to run from $0$ to $3$ and will always implicitly sum over duplicate indexes.\n\\footnote{A note for experienced readers: In this paper we don't user upper and lower indices, we write metric tensors instead.}\n\\\\\n\\\\\n\\noindent\nWe are now ready to put this result back into \\ref{maxwellHalfRelatifistic}:\n\n\\begin{equation}\n    \\mathcal{L}_R = \\frac{1}{c} \\bigg\\{ - \\frac{c^2 \\epsilon_0}{2} \\frac{1}{2} F_{\\mu\\nu}F_{\\alpha\\beta} g_{\\mu\\alpha} g_{\\nu\\beta} - \\big( J_0 A_0 - J \\cdot A \\big) \\bigg\\}\n\\end{equation}\n\nwith $1/\\mu_0=c^2 \\epsilon_0 $ this turns into\n\n\\begin{equation} \\label{electrodynLagrangeRelativistic}\n    \\mathcal{L}_R = \\frac{1}{c} \\bigg\\{ - \\frac{1}{4 \\mu_0} F_{\\mu\\nu}F_{\\alpha\\beta} g_{\\mu\\alpha} g_{\\nu\\beta} - J_\\mu A_\\nu g_{\\mu\\nu} \\bigg\\}\n\\end{equation}\n\n\\subsubsection{Interpretation}\n\\begin{itemize}\n    \\item[1.] $\\mathcal{L}_R$ in the form \\ref{electrodynLagrangeRelativistic} is called the relativistic Lagrangian of electrodynamics.\n              The reason why it is called \"relativistic\" will be explained in the next section.\n    \\item[2.] \\ref{electrodynLagrangeRelativistic} is the result of the transformation given by \\ref{coordinateTransformClassical},\n              \\ref{fieldTransformClassical} and \\ref{currentTransformClassical} and the application of the transformation rule \\ref{LagrTransform}.\n\\end{itemize}\n\n\\subsubsection{Why the laws of electrodynamics are the same in every inertial reference frame}\n\nFor $\\mathcal{L}_R$ in the form \\ref{electrodynLagrangeRelativistic} we consider another transformation of the coordinates $x_0, x_1, x_2, x_3$ the fields $A_0,A_1,A_2,A_3$ and $J_0,J_1,J_2,J_3$:\n\n\\begin{equation} \\label{coordinateTransform}\n    x_\\mu = f(\\bar{x})_\\mu := \\Lambda_{\\mu\\nu} \\bar{x}_\\nu\n\\end{equation}\n\n\\begin{equation} \\label{fieldTransform}\n    A_\\mu = F_A(\\bar{A})_\\mu := \\Lambda_{\\mu\\nu} \\bar{A}_\\nu\n\\end{equation}\n\n\\begin{equation} \\label{currentTransform}\n    J_\\mu = F_J(\\bar{J})_\\mu := \\Lambda_{\\mu\\nu} \\bar{J}_\\nu\n\\end{equation}\nwhere $\\Lambda$ is an arbitrary Lorentz transformation as discussed in section \\ref{sectionNotations}.\nIn the above equations we used the same index based notation as we did in the end of section \\ref{sectionRelativisticLagrangianElectrodynamics}.\nIn the following we will go on to use this notation.\nPlease be aware that based on this notation equation \\ref{generalConditionForLorentzTransformations} can be written as\n\\begin{equation} \\label{invarianceWithMetricTensor}\n    g_{\\mu\\nu} = \\Lambda^t_{\\mu\\alpha} g_{\\alpha\\beta} \\Lambda_{\\beta\\nu}\n    \\; \\iff \\; g_{\\mu\\nu} = \\Lambda_{\\alpha\\mu} g_{\\alpha\\beta} \\Lambda_{\\beta\\nu}\n\\end{equation}\n\\\\\n\\noindent\n\\textbf{Note:}\n\n\\noindent\nFirst and foremost we are  interested in what happens to $\\mathcal{L}_R$ when this transformation is applied using rule \\ref{LagrTransform}.\nTo do so we don't have to be aware of the physical meaning of the transformation.\nBut for readers who don't appreciate this abstraction it might be helpful that\n\\begin{itemize}\n    \\item \\ref{coordinateTransform} is the way the coordinates transform in the real physical world.\n    This was discussed in section \\ref{sectionLorentzTransformation}.\n    \\item \\ref{fieldTransform} was shown to be true in section \\ref{sectionConsequencesOfInvarianceLorentzForce}.\n    \\item \\ref{currentTransform} is shown in appendix \\ref{appendixConinuity}.\n\\end{itemize}\n\\\\\n\\noindent\nFirst we look after the absolute value of the determinant of the Jacobian matrix in \\ref{LagrTransform}:\n\n\\begin{equation}\n    \\frac{\\partial f}{\\partial \\bar{x}} = \\Lambda \\implies \\bigg| det \\frac{\\partial f}{\\partial \\bar{x}} \\bigg| = |det \\Lambda|\n\\end{equation}\n\nfrom $g = \\Lambda^t g \\Lambda$ follows\n\\begin{equation} \\label{determinantOfLorentzTransform}\n    -1 = det g = det g \\;  det^2 \\Lambda \\; \\implies \\; 1 = det^2 \\Lambda \\; \\implies \\; |det \\Lambda | = 1\n\\end{equation}\n\nAs a preparation for writing down $\\bar{\\mathcal{L}}_R$ we rewrite \\ref{electrodynLagrangeRelativistic} with $F$ and $\\partial$ replaced by there definitions:\n\n\\begin{align}\n    \\mathcal{L}_R = & \\frac{1}{c} \\bigg\\{ -\\frac{1}{4\\mu_0} \\label{LagrangePartialA}\n    \\big(\\partial_\\mu A_\\nu - \\partial_\\nu A_\\mu \\big)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\big(\\partial_\\alpha A_\\beta - \\partial_\\beta A_\\alpha\\big) - J_\\mu g_{\\mu\\nu} A_\\nu \\bigg\\}\n    \\\\\n     = & \\frac{1}{c} \\bigg\\{ -\\frac{1}{4\\mu_0}  \\nonumber \\\\\n    & \\bigg(g_{\\mu\\tau} \\frac{\\partial A_\\nu}{\\partial x_\\tau} - g_{\\nu\\epsilon} \\frac{\\partial A_\\mu}{\\partial x_\\epsilon} \\bigg)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\bigg(g_{\\alpha\\pi} \\frac{\\partial A_\\beta}{\\partial x_\\pi} - g_{\\beta\\gamma} \\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\bigg) - J_\\mu g_{\\mu\\nu} A_\\nu \\bigg\\}\n\\end{align}\n\n\n\nBy applying \\ref{LagrTransform} we find the transformed Lagrangian $\\bar{\\mathcal{L}}_R$ to be\n\n\\begin{align}\n    \\bar{\\mathcal{L}}_R = & \\frac{1}{c} \\bigg\\{ -\\frac{1}{4\\mu_0}  \\nonumber \\\\\n    & \\bigg(g_{\\mu\\tau} \\frac{\\partial F_A(\\bar{A})_\\nu}{\\partial f(\\bar{x})_\\tau} - g_{\\nu\\epsilon} \\frac{\\partial F_A(\\bar{A})_\\mu}{\\partial f(\\bar{x})_\\epsilon} \\bigg)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\bigg(g_{\\alpha\\pi} \\frac{\\partial F_A(\\bar{A})_\\beta}{\\partial f(\\bar{x})_\\pi} - g_{\\beta\\gamma} \\frac{\\partial F_A(\\bar{A})_\\alpha}{\\partial f(\\bar{x})_\\gamma} \\bigg) \\nonumber \\\\\n    & - F_J(\\bar{J})_\\mu g_{\\mu\\nu} F_A(\\bar{A})_\\nu \\bigg\\}\n\\end{align}\n\nWe look for a way to express $g_{\\mu\\tau} \\frac{\\partial}{\\partial f(\\bar{x})_\\tau}$ by components of $\\frac{\\partial}{\\partial \\bar{x}}$.\nTo do so we start with the chain rule:\n\n\\begin{equation}\n    \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = \\frac{\\partial f_\\nu}{\\partial \\bar{x}_\\alpha} \\frac{\\partial}{\\partial f_\\nu}\n\\end{equation}\nbecause of \\ref{coordinateTransform} this turns into\n\n\\begin{equation}\n    \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = \\Lambda_{\\nu\\alpha} \\frac{\\partial}{\\partial f_\\nu}\n\\end{equation}\nmultiplying both sides with $\\Lambda^{-1}_{\\alpha\\mu}$ gives\n\n\\begin{equation}\n    \\Lambda^{-1}_{\\alpha\\mu} \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = \\frac{\\partial}{\\partial f_\\nu} \\delta_{\\nu\\mu} = \\frac{\\partial}{\\partial f_\\mu}\n\\end{equation}\nmultiplying both sides with $g_{\\mu\\beta}$ leads to\n\n\\begin{equation}\n    \\Lambda^{-1}_{\\alpha\\mu} g_{\\mu\\beta} \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = g_{\\mu\\beta} \\frac{\\partial}{\\partial f_\\mu}\n    \\iff (\\Lambda^{-1}  g )_{\\alpha\\beta} \\; \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = g_{\\mu\\beta} \\frac{\\partial}{\\partial f_\\mu}\n\\end{equation}\nusing $g = g^t$ and $(\\Lambda^{-1} g)^t = g \\Lambda^{-1 t}$ this turns into\n\n\\begin{equation}\n    (g \\Lambda^{-1 t} )_{\\beta\\alpha} \\; \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = g_{\\beta\\mu} \\frac{\\partial}{\\partial f_\\mu}\n\\end{equation}\nBy inverting both sides of \\ref{invarianceWithMetricTensor} and using $g=g^{-1}$ we find\n$\\Lambda^{-1}g\\Lambda^{-1t} = g \\iff g\\Lambda^{-1t} = \\Lambda g$.\nThus we can write\n\n\\begin{equation}\n    (\\Lambda g )_{\\beta\\alpha} \\; \\frac{\\partial}{\\partial \\bar{x}_\\alpha} = g_{\\beta\\mu} \\frac{\\partial}{\\partial f_\\mu}\n\\end{equation}\nWe use definition \\ref{partialDerivTimesG} for the transformed coordinates and write $\\bar{\\partial}_\\nu := g_{\\nu\\mu} \\frac{\\partial}{\\partial \\bar{x}_\\mu}$.\nThis leads us to\n\n\\begin{equation} \\label{transformPartial}\n    \\Lambda_{\\beta\\nu} \\bar{\\partial}_\\nu = g_{\\beta\\mu} \\frac{\\partial}{\\partial f_\\mu}\n    \\iff (\\Lambda \\bar{\\partial})_\\beta = g_{\\beta\\mu} \\frac{\\partial}{\\partial f_\\mu}\n\\end{equation}\n\n\n\nNow $\\bar{\\mathcal{L}}_R$ can be written as\n\n\\begin{align}\n    \\bar{\\mathcal{L}}_R = \\frac{1}{c} \\bigg\\{ & -\\frac{1}{4\\mu_0}  \\nonumber \\\\\n    & \\bigg((\\Lambda \\bar{\\partial})_\\mu F_A(\\bar{A})_\\nu - (\\Lambda \\bar{\\partial})_\\nu F_A(\\bar{A})_\\mu \\bigg)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\bigg((\\Lambda \\bar{\\partial})_\\alpha F_A(\\bar{A})_\\beta - (\\Lambda \\bar{\\partial})_\\beta F_A(\\bar{A})_\\alpha \\bigg) \\nonumber \\\\\n    & - F_J(\\bar{J})_\\mu g_{\\mu\\nu} F_A(\\bar{A})_\\nu \\bigg\\}\n\\end{align}\nNext we use \\ref{fieldTransform} and \\ref{currentTransform}:\n\n\\begin{align} \\label{LagrangeTransformed2}\n    \\bar{\\mathcal{L}}_R = \\frac{1}{c} \\bigg\\{ & -\\frac{1}{4\\mu_0}  \\nonumber \\\\\n    & \\bigg((\\Lambda \\bar{\\partial})_\\mu (\\Lambda\\bar{A})_\\nu - (\\Lambda \\bar{\\partial})_\\nu (\\Lambda \\bar{A})_\\mu \\bigg)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\bigg((\\Lambda \\bar{\\partial})_\\alpha (\\Lambda \\bar{A})_\\beta - (\\Lambda \\bar{\\partial})_\\beta (\\Lambda \\bar{A})_\\alpha \\bigg) \\nonumber \\\\\n    & - (\\Lambda \\bar{J})_\\mu g_{\\mu\\nu} (\\Lambda \\bar{A})_\\nu \\bigg\\}\n\\end{align}\nMultplying out the first summand one of the resulting terms is\n\n\\begin{align}\n    & (\\Lambda \\bar{\\partial})_\\mu (\\Lambda\\bar{A})_\\nu g_{\\mu\\alpha} g_{\\nu\\beta} (\\Lambda \\bar{\\partial})_\\alpha (\\Lambda \\bar{A})_\\beta \\nonumber\n    \\\\\n    & =\n      \\Lambda_{\\mu\\epsilon} \\bar{\\partial}_\\epsilon \\Lambda_{\\nu\\tau} \\bar{A}_\\tau\n      g_{\\mu\\alpha} g_{\\nu\\beta}\n      \\Lambda_{\\alpha\\pi} \\bar{\\partial}_\\pi \\Lambda_{\\beta\\sigma} \\bar{A}_\\sigma \\nonumber\n    \\\\\n    & =\n      \\Lambda_{\\mu\\epsilon} g_{\\mu\\alpha} \\Lambda_{\\alpha\\pi} \\;\\;\n      \\Lambda_{\\nu\\tau} g_{\\nu\\beta} \\Lambda_{\\beta\\sigma} \\;\\;\n      \\bar{\\partial}_\\epsilon \\bar{A}_\\tau \\bar{\\partial}_\\pi \\bar{A}_\\sigma \\nonumber\n    \\\\\n      & =\n      (\\Lambda^tg\\Lambda)_{\\epsilon\\pi} \\;\\; (\\Lambda^tg\\Lambda)_{\\tau\\sigma} \\;\\;\n      \\bar{\\partial}_\\epsilon \\bar{A}_\\tau \\bar{\\partial}_\\pi \\bar{A}_\\sigma \\nonumber\n    \\\\\n    & = g_{\\epsilon\\pi} \\;\\; g_{\\tau\\sigma} \\;\\; \\bar{\\partial}_\\epsilon \\bar{A}_\\tau \\bar{\\partial}_\\pi \\bar{A}_\\sigma\n\\end{align}\nInterchanging indexes the following way $\\epsilon \\rightarrow \\mu, \\tau \\rightarrow \\nu, \\pi \\rightarrow \\alpha, \\sigma \\rightarrow \\beta$ turns this into\n\n\\begin{equation}\n    g_{\\mu\\alpha} \\;\\; g_{\\nu\\beta} \\;\\; \\bar{\\partial}_\\mu \\bar{A}_\\nu \\bar{\\partial}_\\alpha \\bar{A}_\\beta\n\\end{equation}\nWith analogous calculations for the remaining terms \\ref{LagrangeTransformed2} turns into\n\n\\begin{equation} \\label{LagrangeTransformFinal}\n    \\bar{\\mathcal{L}}_R = \\frac{1}{c} \\bigg\\{ -\\frac{1}{4\\mu_0}\n    \\big(\\bar{\\partial}_\\mu \\bar{A}_\\nu - \\bar{\\partial}_\\nu \\bar{A}_\\mu \\big)\n    g_{\\mu\\alpha} g_{\\nu\\beta}\n    \\big(\\bar{\\partial}_\\alpha \\bar{A}_\\beta - \\bar{\\partial}_\\beta \\bar{A}_\\alpha\\big)\n    - \\bar{J}_\\mu g_{\\mu\\nu} \\bar{A}_\\nu \\bigg\\}\n\\end{equation}\n\n\\subsubsection{Interpretation} \\label{invarianceMaxwell}\n\nWe found that the following equation holds:\n\\begin{equation}\n    \\bar{\\mathcal{L}}_R(\\bar{A}, \\frac{\\partial \\bar{A}}{\\partial \\bar{x}}) = \\mathcal{L}_R(\\bar{A}, \\frac{\\partial \\bar{A}}{\\partial \\bar{x}})\n\\end{equation}\nusing \\ref{LagrTransform} and the fact that $|det\\lambda| = 1$, see \\ref{determinantOfLorentzTransform}, we can also write\n\\begin{equation}\n    \\bar{\\mathcal{L}}_R(\\bar{A}, \\frac{\\partial \\bar{A}}{\\partial \\bar{x}}) = \\mathcal{L}_R(A, \\frac{\\partial A}{\\partial x})\n\\end{equation}\nSo we find that the Lagrangian of the electromagnetic field satisfies a similar notion of invariance as discussed in sections \\ref{sectionInvariance} and \\ref{sectionGeneralizationInvariance}\nfor particle Lagrangians.\n\nSince the Euler-Lagrange equations don't change under transformations at all, it is obvious that the fields' equations of motion also look the same\nin the transformed and untransformed coordinates and fields.\nThat is why the laws of electrodynamics (Maxwell's equations) are the same in every inertial reference frame.\n\n\n\\section{Relativistic form of Maxwell's equations}\nWe calculate the equation of motion \\ref{EulerLagrangeField} for an arbitrary component $A_\\tau$ of $A$.\nIn this section we once and again make use of the definition $F_{\\mu\\nu} := \\partial_\\mu A_\\nu - \\partial_\\nu A_\\mu$ from section \\ref{sectionRelativisticLagrangianElectrodynamics}.\nWe start with\n\n\\begin{align}\n  \\frac{\\partial \\mathcal{L}}{\\partial\\frac{\\partial A_\\tau}{\\partial x_\\epsilon}}\n  = & \\frac{\\partial}{\\partial\\frac{\\partial A_\\tau}{\\partial x_\\epsilon}}\n  \\bigg[\n  -\\frac{1}{4 c \\mu_0}\n  \\big(\\partial_\\mu A_\\nu - \\partial_\\nu A_\\mu \\big)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\big(\\partial_\\alpha A_\\beta - \\partial_\\beta A_\\alpha\\big)\n  \\bigg] \\\\\n  = & -\\frac{1}{4 c \\mu_0} \\frac{\\partial}{\\partial\\frac{\\partial A_\\tau}{\\partial x_\\epsilon}}\n  \\bigg[\n  \\bigg(g_{\\mu\\sigma} \\frac{\\partial A_\\nu}{\\partial x_\\sigma} - g_{\\nu\\pi} \\frac{\\partial A_\\mu}{\\partial x_\\pi} \\bigg)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\bigg(g_{\\alpha\\eta} \\frac{\\partial A_\\beta}{\\partial x_\\eta} - g_{\\beta\\gamma} \\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\bigg)\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  \\bigg(g_{\\mu\\sigma} \\delta_{\\tau\\nu}\\delta_{\\epsilon\\sigma} - g_{\\nu\\pi}\\delta_{\\mu\\tau}\\delta_{\\epsilon\\pi} \\bigg)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\bigg(g_{\\alpha\\eta} \\frac{\\partial A_\\beta}{\\partial x_\\eta} - g_{\\beta\\gamma} \\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\bigg) \\nonumber \\\\\n  & +  \\bigg(g_{\\mu\\sigma} \\frac{\\partial A_\\nu}{\\partial x_\\sigma} - g_{\\nu\\pi} \\frac{\\partial A_\\mu}{\\partial x_\\pi} \\bigg)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\bigg( g_{\\alpha\\eta}\\delta_{\\tau\\beta}\\delta_{\\epsilon\\eta} - g_{\\beta\\gamma}\\delta_{\\tau\\alpha}\\delta_{\\epsilon\\gamma} \\bigg)\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  \\bigg(g_{\\mu\\epsilon} \\delta_{\\tau\\nu} - g_{\\nu\\epsilon}\\delta_{\\mu\\tau} \\bigg)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\bigg(g_{\\alpha\\eta} \\frac{\\partial A_\\beta}{\\partial x_\\eta} - g_{\\beta\\gamma} \\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\bigg) \\nonumber \\\\\n  & +  \\bigg(g_{\\mu\\sigma} \\frac{\\partial A_\\nu}{\\partial x_\\sigma} - g_{\\nu\\pi} \\frac{\\partial A_\\mu}{\\partial x_\\pi} \\bigg)\n  g_{\\mu\\alpha} g_{\\nu\\beta}\n  \\bigg( g_{\\alpha\\epsilon}\\delta_{\\tau\\beta} - g_{\\beta\\epsilon}\\delta_{\\tau\\alpha} \\bigg)\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  \\bigg(\\delta_{\\alpha\\epsilon} g_{\\tau\\beta} - \\delta_{\\beta\\epsilon}g_{\\alpha\\tau} \\bigg)\n  \\bigg(g_{\\alpha\\eta} \\frac{\\partial A_\\beta}{\\partial x_\\eta} - g_{\\beta\\gamma} \\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\bigg) \\nonumber \\\\\n  & + \\bigg(g_{\\mu\\sigma} \\frac{\\partial A_\\nu}{\\partial x_\\sigma} - g_{\\nu\\pi} \\frac{\\partial A_\\mu}{\\partial x_\\pi} \\bigg)\n  \\bigg( \\delta_{\\mu\\epsilon}g_{\\nu\\tau} - \\delta_{\\nu\\epsilon}g_{\\mu\\tau} \\bigg)\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  \\bigg(\n  g_{\\epsilon\\eta}g_{\\tau\\beta}\\frac{\\partial A_\\beta}{\\partial x_\\eta} - \\delta_{\\tau\\gamma}\\frac{\\partial A_\\epsilon}{\\partial x_\\gamma}\n  - \\delta_{\\tau\\eta}\\frac{\\partial A_\\epsilon}{\\partial x_\\eta} + g_{\\epsilon\\gamma}g_{\\tau\\alpha}\\frac{\\partial A_\\alpha}{\\partial x_\\gamma}\n  \\bigg) \\nonumber \\\\\n  & + \\bigg(\n  g_{\\epsilon\\sigma}g_{\\nu\\tau}\\frac{\\partial A_\\nu}{\\partial x_\\sigma} - \\delta_{\\sigma\\tau}\\frac{\\partial A_\\epsilon}{\\partial x_\\sigma}\n  - \\delta_{\\pi\\tau}\\frac{\\partial A_\\epsilon}{\\partial x_\\pi} + g_{\\epsilon\\pi}g_{\\mu\\tau}\\frac{\\partial A_\\mu}{\\partial x_\\pi}\n  \\bigg)\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  g_{\\epsilon\\eta}g_{\\tau\\beta}\\frac{\\partial A_\\beta}{\\partial x_\\eta} - \\frac{\\partial A_\\epsilon}{\\partial x_\\tau}\n  - \\frac{\\partial A_\\epsilon}{\\partial x_\\tau} + g_{\\epsilon\\gamma}g_{\\tau\\alpha}\\frac{\\partial A_\\alpha}{\\partial x_\\gamma} \\nonumber \\\\\n  & +   g_{\\epsilon\\sigma}g_{\\nu\\tau}\\frac{\\partial A_\\nu}{\\partial x_\\sigma} - \\frac{\\partial A_\\epsilon}{\\partial x_\\tau}\n  - \\frac{\\partial A_\\epsilon}{\\partial x_\\tau} + g_{\\epsilon\\pi}g_{\\mu\\tau}\\frac{\\partial A_\\mu}{\\partial x_\\pi}\n  \\bigg] \\nonumber \\\\ \\\\\n  = & -\\frac{1}{4 c \\mu_0}\n  \\bigg[\n  4 \\cdot g_{\\epsilon\\eta}g_{\\tau\\beta}\\frac{\\partial A_\\beta}{\\partial x_\\eta} - 4 \\cdot \\frac{\\partial A_\\epsilon}{\\partial x_\\tau}\n  \\bigg] \\nonumber \\\\\n  = & -\\frac{1}{c \\mu_0}\n  \\bigg[\n  g_{\\epsilon\\eta}g_{\\tau\\beta}\\frac{\\partial A_\\beta}{\\partial x_\\eta} - \\frac{\\partial A_\\epsilon}{\\partial x_\\tau}\n  \\bigg] \\nonumber \\\\\n  = & -\\frac{1}{c \\mu_0}\n  \\bigg[\n  g_{\\tau\\beta} \\partial_\\epsilon A_\\beta - g_{\\tau\\beta}g_{\\beta\\alpha}\\frac{\\partial A_\\epsilon}{\\partial x_\\alpha}\n  \\bigg] \\nonumber \\\\\n  = & -\\frac{1}{c \\mu_0} g_{\\tau\\beta}\n  \\bigg[\n  \\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon\n  \\bigg] \\nonumber \\\\\n  = & -\\frac{1}{c \\mu_0} g_{\\tau\\beta} F_{\\epsilon\\beta} \\nonumber\n\\end{align}\n\nNext we look at\n\\begin{equation}\n  \\frac{\\partial \\mathcal{L}}{\\partial A_\\tau}\n  = \\frac{\\partial }{\\partial A_\\tau} \\bigg( - \\frac{1}{c} J_\\mu g_{\\mu\\nu} A_\\nu \\bigg)\n  = - \\frac{1}{c} J_\\mu g_{\\mu\\nu} \\delta_{\\nu\\tau}\n  = - \\frac{1}{c} J_\\mu g_{\\mu\\tau}\n  = - \\frac{1}{c} g_{\\tau\\beta} J_\\beta\n\\end{equation}\n\nThus according to \\ref{EulerLagrangeField} the equation of motion is given by\n\n\\begin{equation}\n  0 = - \\frac{1}{c} g_{\\tau\\beta} J_\\beta\n  + \\frac{\\partial}{\\partial x_\\epsilon}\n  \\bigg(\n  \\frac{1}{c \\mu_0} g_{\\tau\\beta}\n  \\bigg(\n  \\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon\n  \\bigg)\n  \\bigg)\n\\end{equation}\n\\begin{equation}\n  \\iff 0 = g_{\\tau\\beta} \\bigg(J_\\beta\n  - \\frac{1}{\\mu_0}  \\frac{\\partial}{\\partial x_\\epsilon}\\big( \\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon \\big) \\bigg)\n\\end{equation}\n\n\\begin{equation}\n  \\iff 0 = J_\\beta - \\frac{1}{\\mu_0}  \\frac{\\partial}{\\partial x_\\epsilon}\\big( \\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon \\big)\n\\end{equation}\n\n\\begin{equation}\n  \\iff \\mu_0 J_\\beta = g_{\\epsilon\\alpha}g_{\\alpha\\pi}\\frac{\\partial}{\\partial x_\\pi}\\big( \\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon \\big)\n\\end{equation}\n\n\\begin{equation} \\label{equationOfMotionUntransformed}\n\\iff \\mu_0 J_\\beta = g_{\\epsilon\\alpha}  \\partial_\\alpha \\big(\\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon \\big)\n= g_{\\epsilon\\alpha}  \\partial_\\alpha F_{\\epsilon\\beta}\n\\end{equation}\n\nThis is the relativistic from of Maxwell's equations.\n\n\\section{Gauge and Lorentz transformations} \\label{sectionGauge}\nWe will define gauge in the context of a particle Lagrangian and will explore how it is connected to gauge in the context of the electromagnetic potentials.\nThe aim of this section is to clarify the interaction beween gauges of the electromagnetic potentials and Lorentz transformation.\nIt will turn out that they have no influence,\ni.e. the four components of $(\\phi/c, A_1,A_2,A_3)$ will turn out to transform under Lorentz transformations like the components of $(ct,x_1,x_2,x_3)$ in any gauge.\n\n\\subsection{Gauge of a particle Lagrangian}\nA particle Lagrangian can be changed the following way without changing its equation of motion:\n\n\\begin{equation}\n  L(q,\\dot{q}, t) \\rightarrow L(q,\\dot{q}, t) + \\frac{\\dd}{ \\dd t} F(q,t)\n\\end{equation}\nwhere F ist an arbitrary function of the coordinates and time.\nA change of this kind is called a gauge.\n\nTo prove that the equations of motion are not changed by a gauge we calculate the Euler-Lagrange equations for the right hand side:\n\n\\begin{align}\n  & \\frac{\\dd}{\\dd t} \\frac{\\partial \\big(L + \\frac{\\dd F}{\\dd t}\\big)}{\\partial \\dot{q}} - \\frac{\\partial \\big(L + \\frac{\\dd F}{\\dd t}\\big)}{\\partial q} \\nonumber \\\\\n  & = \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L }{\\partial q}\n  + \\frac{\\dd}{\\dd t} \\frac{\\partial}{\\partial \\dot{q}} \\frac{\\dd F}{\\dd t}  - \\frac{\\partial}{\\partial q} \\frac{\\dd F}{\\dd t} \\nonumber \\\\\n  & = \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L }{\\partial q}\n  + \\frac{\\dd}{\\dd t} \\frac{\\partial}{\\partial \\dot{q}} \\bigg( \\frac{\\partial F}{\\partial q} \\dot{q} + \\frac{\\partial F}{\\partial t} \\bigg)\n  - \\frac{\\partial}{\\partial q} \\bigg( \\frac{\\partial F}{\\partial q} \\dot{q} + \\frac{\\partial F}{\\partial t} \\bigg) \\nonumber \\\\\n  & = \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L }{\\partial q}\n  + \\frac{\\dd}{\\dd t} \\frac{\\partial F}{\\partial q}\n  - \\bigg(\\frac{\\partial^2 F}{\\partial q^2} \\dot{q} + \\frac{\\partial }{\\partial t} \\frac{\\partial F}{\\partial q} \\bigg) \\nonumber \\\\\n  & = \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L }{\\partial q}\n  + \\frac{\\dd}{\\dd t} \\frac{\\partial F}{\\partial q}\n  - \\frac{\\dd}{\\dd t} \\bigg(\\frac{\\partial F}{\\partial q} \\bigg) \\nonumber \\\\\n  & = \\frac{\\dd}{\\dd t} \\frac{\\partial L}{\\partial \\dot{q}} - \\frac{\\partial L }{\\partial q} + 0\n\\end{align}\nThis is the same term as without gauge, which proves that the gauge doesn't change the equations of motion.\n\n\\subsection{Connection between the gauges of the particle Lagrangian and the electromagnetic field}\nA gauge of the electromagnetic potentials is given by\n\n\\begin{align}\n  A &\\rightarrow A' = A + \\nabla \\lambda(x,t) \\label{gaugeVectorPotential} \\\\\n  \\phi &\\rightarrow \\phi' = \\phi - \\frac{\\partial}{\\partial t} \\lambda(x,t) \\label{gaugeScalarPotential}\n\\end{align}\nwhere $\\lambda$ is an arbitrary function of the spacial coordinates and time.\nThis gauge is defined in such a way that it has no effect on the fields $E,B$.\nTo prove this we calculate the fields from the gauged potentials $A', \\phi'$ using the formulas $B = \\nabla \\times A$ and $E = - \\nabla \\phi - \\frac{\\partial A}{\\partial t}$ as defined for example in section 4 of \\cite{LagrangeOfField}:\n\\begin{align}\n  B' &= \\nabla \\times A' = \\nabla \\times (A + \\nabla \\lambda) = \\nabla \\times A + 0 = \\nabla \\times A = B \\\\\n  E' &= -\\nabla \\phi - \\frac{\\partial A'}{\\partial t} = -\\nabla \\bigg( \\phi - \\frac{\\partial \\lambda}{\\partial t} \\bigg) -\\frac{\\partial}{\\partial t} ( A + \\nabla \\lambda) \\nonumber \\\\\n  &= -\\nabla \\phi - \\frac{\\partial A}{\\partial t} + \\frac{\\partial \\nabla \\lambda}{\\partial t} - + \\frac{\\partial \\nabla \\lambda}{\\partial t} = -\\nabla \\phi - \\frac{\\partial A}{\\partial t} = E\n\\end{align}\n\nNext we will calculate in which way this gauge will affect the Lagrangian $L_L$ of the Lorentz force:\nThe way $L_L$ changes by a gauge of the electromagnetic potentials is given by\n\n\\begin{align}\n  L_L = - e (\\phi - A \\cdot v) \\rightarrow & -e(\\phi-\\frac{\\partial \\lambda}{\\partial t}) - (A + \\nabla \\lambda) \\cdot v) \\nonumber \\\\\n  & = - e (\\phi - A \\cdot v) - e (\\frac{\\partial \\lambda}{\\partial t} - \\nabla \\lambda \\cdot v) \\nonumber \\\\\n  & = - e (\\phi - A \\cdot v) - e \\frac{\\dd \\lambda}{\\dd t} \\nonumber \\\\\n  & = - e (\\phi - A \\cdot v) - \\frac{\\dd \\; (e \\lambda)}{\\dd t}\n\\end{align}\nThis shows that changing the gauge of the electromagnetic potentials changes the Lagrangian by a total time derivative.\nAs we saw above this change won't affect the equations of motion.\nBoth gauges are consistent in so far as they don't effect physical, i.e. measurable, phenomena.\n\n\\subsection{The effect of Lorentz transfomations on physical phenomena in the case of a charged particle in an electromagnetic field}\n\nWe consider two IRFs $T, \\bar{T}$ with coordinates $X=(ct, x_1, x_2, x_3)$ and $\\bar{X}=(c \\bar{t}, \\bar{x_1}, \\bar{x_2}, \\bar{x_3})$ which move relative to each other with non zero speed.\nThe equations of motion for a charged particle in an electromagnetic field in these two coordinate systems are given by\n\\begin{align}\n  \\frac{\\dd}{\\dd t} \\frac{\\partial L_{free}}{\\partial v} - \\frac{\\partial L_{free}}{\\partial x} &= e E + e v \\times B \\\\\n  \\text{and} \\nonumber \\\\\n  \\frac{\\dd}{\\dd \\bar{t}} \\frac{\\partial \\bar{L}_{free}}{\\partial \\bar{v}} - \\frac{\\partial \\bar{L}_{free}}{\\partial \\bar{x}} &= e \\bar{E} + e \\bar{v} \\times \\bar{B}\n\\end{align}\nwhere $L_{free}$ denotes the free partical Lagrangian $L_{free} = - m c^2 \\sqrt{1 - \\frac{v^2}{c^2}}$.\n\\footnote{If the particle in $T$ and $\\bar{T}$ moves with a speed small compared to the speed of light we may also choose $L_{free} = \\frac{1}{2} m v^2$.}\n\nAlthough the structure of both sets of equations is the same as the first postulate of special relativity requires the ingredients aren't at all, i.e.\n\\begin{equation}\n  \\bar{v} \\neq v \\;,\\; \\bar{E} \\neq E \\;,\\; \\bar{B} \\neq B \\;,\\; \\bar{L}_{free} \\neq L_{free}\n\\end{equation}\nThat these quantities aren't the same in $T$ and $\\bar{T}$ is most famously discussed in the introduction of Einstein's first paper on special relativity\\cite{EinsteinSpecialRelativity}.\n\nAs the change of $E$ and $B$ results from Lorentz transformation's of the potentials $\\phi, A$ it must be impossible to express a Lorentz transformation by a gauge transformation of $\\phi, A$.\nThis is because by definition and construction gauge transformations never change the fields.\n\n\\subsection{Lorenz gauge and the transformation law of the elecromagnetic potentials}\nIn this section we discuss a less general derivation of the result \\ref{vectorPotentialsAreA4Vector}.\nThe derivation is less general because it needs a fixed gauge, namely the so called Lorenz gauge.\nWe suspect that this derivation seduces some people, who don't know of section \\ref{sectionConsequencesOfInvarianceLorentzForce}, to believe in a stronger or different relation between Lorentz transformations and gauge transformations than there really is.\n\nThe first step is to turn \\ref{gaugeVectorPotential} and \\ref{gaugeScalarPotential} into a relativistic form using $\\phi=c A_0, t=\\frac{x_0}{c}, \\partial_0 = \\frac{\\partial}{\\partial x_0}, \\partial_i = - \\frac{\\partial}{\\partial x_i}$ for $i \\in {1,2,3}$, see \\ref{fieldTransformClassical} and \\ref{partialDerivTimesG}:\n\\begin{equation}\n  A_\\mu = \\left(\\begin{array}{c}\n                      \\phi /c\n                      \\\\\n                      A_1\n                      \\\\\n                      A_2\n                      \\\\\n                      A_3\n          \\end{array} \\right)_\\mu\n  \\rightarrow\n  A'_\\mu = \\left(\\begin{array}{c}\n                                \\phi' /c\n                                \\\\\n                                A'_1\n                                \\\\\n                                A'_2\n                                \\\\\n                                A'_3\n  \\end{array} \\right)_\\mu\n  =\n  \\left(\\begin{array}{c}\n          \\phi /c - \\frac{1}{c} \\frac{\\partial \\lambda}{\\partial t}\n          \\\\\n          A_1 + \\frac{\\partial \\lambda}{\\partial x_1}\n          \\\\\n          A_2 + \\frac{\\partial \\lambda}{\\partial x_2}\n          \\\\\n          A_3 + \\frac{\\partial \\lambda}{\\partial x_3}\n  \\end{array} \\right)_\\mu\n  =\n  A_\\mu - \\partial_\\mu \\lambda\n\\end{equation}\nNext we turn to Maxwells's equations in their relativistic form:\n\\begin{equation}\n  \\mu_0 J_\\beta = g_{\\epsilon\\alpha}  \\partial_\\alpha \\big(\\partial_\\epsilon A_\\beta - \\partial_\\beta A_\\epsilon \\big)\n  = g_{\\epsilon\\alpha} \\partial_\\alpha \\partial_\\epsilon A_\\beta - g_{\\epsilon\\alpha} \\partial_\\alpha \\partial_\\beta A_\\epsilon\n\\end{equation}\nThe trick is now to choose the gauge function $\\lambda$ in such a way that\n\\begin{equation}\n  g_{\\epsilon\\alpha} \\partial_\\alpha \\partial_\\beta A_\\epsilon = 0\n\\end{equation}\nThis gauge is called Lorenz gauge.\nThe proof that such a gauge function exists can for example be found in \\cite{JacksonLorentzGauge}.\nIn this gauge Maxwell's equations take the form\n\\begin{equation} \\label{maxwellsEquationsLorenzGauged}\n  \\mu_0 J_\\beta = g_{\\epsilon\\alpha} \\partial_\\alpha \\partial_\\epsilon A_\\beta\n\\end{equation}\nTo derive \\ref{vectorPotentialsAreA4Vector} from this equation we consider two IRFs $T, \\bar{T}$ with coordinates $x_\\nu, \\bar{x}_\\nu$, potentials $A_\\nu, \\bar{A}_\\nu$ and currents $J_\\nu, \\bar{J}_\\nu$.\nAccording to \\hyperlink{einsteinsOriginalFirstPostulate}{Einsteins original first postulate} equation \\ref{maxwellsEquationsLorenzGauged} in the coordinates of $\\bar{T}$ is given by\n\\begin{equation} \\label{maxwellsEquationsLorenzGaugedBarred}\n  \\mu_0 \\bar{J}_\\beta = g_{\\epsilon\\alpha} \\bar{\\partial}_\\alpha \\bar{\\partial}_\\epsilon \\bar{A}_\\beta\n\\end{equation}\nFrom appendix \\ref{appendixConinuity} and \\ref{transformPartial} we know that $\\bar{J}_\\nu = \\Lambda_{\\nu\\gamma} J_\\gamma$ and $\\bar{\\partial}_\\nu = \\Lambda_{\\nu\\gamma} \\partial_\\gamma$ where $\\Lambda$ denotes the Lorentz transformation of the coordiantes from $T$ to $\\bar{T}$.\nPlugin these into \\ref{maxwellsEquationsLorenzGaugedBarred} und using $\\Lambda^t g \\Lambda = g$ leads to\n\\begin{equation}\n  \\mu_0 \\Lambda_{\\beta\\gamma}J_\\gamma = g_{\\epsilon\\alpha} \\partial_\\alpha \\partial_\\epsilon \\bar{A}_\\beta\n\\end{equation}\nThen the simplest way to make this equation consistent with \\ref{maxwellsEquationsLorenzGauged} is to assume\n\\begin{equation}\n  \\bar{A}_\\beta = \\Lambda_{\\beta\\gamma} A_\\gamma\n\\end{equation}\nwhich is equivalent to \\ref{vectorPotentialsAreA4Vector}.\n\n\n\\appendix\n\n\\section{Transformation of $J_\\mu$} \\label{appendixConinuity}\n\n\nWe are going to motivate why \\ref{currentTransform} is the physically correct behavior of $J_\\mu$ under Lorentz transformations.\nWe use the empiric fact that the electric charge is conserved in every inertial reference frame.\nThe formula that describes this fact is the continuity equation:\n\n\\begin{equation}\n    0 = \\frac{\\partial \\rho}{\\partial t} + \\nabla \\cdot j = \\frac{\\partial (c \\rho)}{\\partial (ct)} + \\frac{\\partial j_i}{\\partial x_i}\n\\end{equation}\nwith \\ref{coordinateTransformClassical}, \\ref{currentTransformClassical} and \\ref{partialDerivTimesG} this equation can be written as\n\n\\begin{equation} \\label{relativisticContinuity}\n    0 = \\partial_0 J_0 - \\partial_i J_i = g_{\\mu\\nu} \\partial_\\mu J_{\\nu}\n\\end{equation}\n\n\nLet $T$ and $\\bar{T}$ be two inertial reference frames with coordinates $x_0, x_1, x_2, x_3$ and $\\bar{x}_0, \\bar{x}_1, \\bar{x}_2, \\bar{x}_3$\nIf we denote the current in $\\bar{T}$ by $\\bar{J}$ the continuity equation in $\\bar{T}$ reads:\n\n\\begin{equation} \\label{relativisticContinuityTransfored}\n    0 = g_{\\mu\\nu} \\bar{\\partial}_\\mu \\bar{J}_{\\nu}\n\\end{equation}\n\nIf $\\Lambda$ is the Lorentz transformation that connects the frames' coordinates ($x_\\mu = \\Lambda_{\\mu\\nu} \\bar{x}_\\nu$) then according to \\ref{transformPartial}\n$\\partial_\\mu = \\Lambda_{\\mu\\nu} \\bar{\\partial}_\\nu$ is true.\n\nNext we need an expression for the connection between $J$ and $\\bar{J}$.\nThus we write $J_\\mu=G(\\bar{J})_\\mu$, where $G$ is some yet undefined function.\nWith this \\ref{relativisticContinuity} can be written as\n\n\\begin{align} \\label{continuityTransformed}\n0 & =  g_{\\mu\\nu} \\partial_\\mu J_{\\nu} \\nonumber \\\\\n  & = g_{\\mu\\nu} \\Lambda_{\\mu\\alpha} \\bar{\\partial}_\\alpha  G(\\bar{J})_\\nu \\nonumber \\\\\n  & = (g \\Lambda)_{\\nu\\alpha} \\bar{\\partial}_\\alpha  G(\\bar{J})_\\nu \\nonumber \\\\\n  & = (\\Lambda^t g )_{\\alpha\\nu} \\bar{\\partial}_\\alpha  G(\\bar{J})_\\nu \\nonumber \\\\\n\\end{align}\n\nThe simplest guess to make this formula consistent with \\ref{relativisticContinuityTransfored} is $G(\\bar{J})_\\nu = \\Lambda_{\\nu\\beta} \\bar{J}_\\beta$.\nBecause then \\ref{continuityTransformed} becomes equivalent to \\ref{relativisticContinuityTransfored}:\n\n\\begin{align}\n    0 & = (\\Lambda^t g )_{\\alpha\\nu} \\bar{\\partial}_\\alpha  \\Lambda_{\\nu\\beta} \\bar{J}_\\beta \\nonumber \\\\\n      & = (\\Lambda^t g \\Lambda)_{\\alpha\\beta} \\bar{\\partial}_\\alpha  \\bar{J}_\\beta \\nonumber \\\\\n      & = g_{\\alpha\\beta} \\bar{\\partial}_\\alpha  \\bar{J}_\\beta \\nonumber \\\\\n      & = g_{\\mu\\nu} \\bar{\\partial}_\\mu  \\bar{J}_\\nu \\nonumber\n\\end{align}\n\n\n\\begin{thebibliography}{9}\n\n\\bibitem{LandauInterval} L.D. Landau and E.M. Lifshitz, The classical theory of fields, Chapter 1 Paragraph 2 Intervals\n\n\\bibitem{WagnerGuthrie} Gerd Wagner and Matt Guthrie, Demystifying the Lagrangian of Classical Mechanics\n\n\\bibitem {SusskindRelativisticLagrange} Susskind Lectures, Special Relativity, Lecture 3, \\url{https://theoreticalminimum.com/courses/special-relativity-and-classical-field-theory/2012/spring/lecture-3}\n\n\\bibitem{LandauRelativisticLagrange} L.D. Landau and E.M. Lifshitz, The classical theory of fields, Chapter 2 Paragraph 1 The principle of least action\n\n\\bibitem{LagrangeOfField} Gerd Wagner, Demystifying the Lagrange formalism of field theory\n\n\\bibitem{EinsteinSpecialRelativity} A. Einstein, Zur Elektrodynamik bewegter K\\\"{o}rper (English Translation: On the Electrodynamics of Moving Bodies), Annalen der Physik 1905, 17, 891--921\n\n\\bibitem{JacksonLorentzGauge} John David Jackson, Classical Electrodynamics, Edition , Chapter 3.2 ff.\n\n\\end{thebibliography}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "5953909a0c29855af1cced2ad4de7f07e788e04e", "size": 110808, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LagarangeRelativity.tex", "max_stars_repo_name": "mwguthrie/lagrangian", "max_stars_repo_head_hexsha": "ac16747a58b967399ed0f66ae4de661a26bc7194", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LagarangeRelativity.tex", "max_issues_repo_name": "mwguthrie/lagrangian", "max_issues_repo_head_hexsha": "ac16747a58b967399ed0f66ae4de661a26bc7194", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LagarangeRelativity.tex", "max_forks_repo_name": "mwguthrie/lagrangian", "max_forks_repo_head_hexsha": "ac16747a58b967399ed0f66ae4de661a26bc7194", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.1114649682, "max_line_length": 341, "alphanum_fraction": 0.6740668544, "num_tokens": 37587, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4260973286900688}}
{"text": "\\section{The Simple Gerstner Wave Approach}\\label{sec:simple_gerstner_waves}\n\n% In the simple gerstner wave approach talk on how I build the application\n% because SLProject wasn't compiling and say also that 0 A.D. was an overkill to\n% start with. Talk about the LSD MDMA strange effects, talk about the parameters\n% that have to be shit out of the ass. Talk about the Shading method used. Also\n% mention that 16 weeks ago you didn't know anything and that's why you choose\n% to implement the gerstner approach.\n\nWe opted to implement the Gerstner Wave approach from \\cref{subsub:gerstner}\nbecause it was the easiest one to understand and well described in\n\\autocite{fernando2004gpu}. Furthermore, it does no represent a daunting task\nfor someone new to the graphics pipeline programming.\n\nWe integrated the water model into a demonstration application coded in C++\nusing OpenGL and the \\textit{GLEW}, \\textit{GLFW} and \\textit{stb} libraries.\nC++ was used because both applications in \\autoref{subsec:candidate_apps} are\nprogrammed with it. We choose \\textit{GLEW} because it is a cross-platform\nlibrary to load the OpenGL extensions. \\textit{GLFW} is used for the window\ncreation and keyboard interactions. Finally we utilize the simple but powerful\ncapabilities of \\textit{stb} to read and load images into memory.\n\nWe programmed the following classes: \\texttt{Camera}, \\texttt{Plane},\n\\texttt{Skybox}, \\texttt{FPSCounter}. The \\texttt{Camera} class represents the\nposition of the camera in spherical coordinates\\footnote{Our implementation is\n    based on the recommendation of the Graphics Stackexchange post:\n\\url{https://computergraphics.stackexchange.com/questions/151/}}. This makes it\neasier to compute the zoom and rotation in the $\\varphi$ and $\\theta$\ndirections. We use the \\texttt{Plane} class to build a grid of vertices with\nthe corresponding indices. The grid always points to the $y$\ndirection\\footnote{In OpenGL the $z$ coordinate points out of the screen.}, and\ncan have a arbitrary resolution (amount of vertices) as well as size. This class\nis used to represent the water. The \\texttt{Skybox} a simply cube whose indices\nare specified counterclockwise such that the normals point inwards. The\nparticularity of it, is that the depth buffer is disabled before the OpenGL draw\ncall is issued and re-enabled afterwards. Every object rendered after it, will\nbe displayed in front of it. Finally the \\texttt{FPSCounter} class tracks the\ntime needed to compute each frame.\n\nIn the vertex shader of the water plane we compute the position, normal and\ntangent vectors as in\n\\cref{eq:gerstner_position,eq:gerstner_normal,eq:gerstner_tangent} with the only\nsubtlety that the $y$ and $z$ coordinates are flipped. We use four waves ($i =\n4$) with the constants $g = 9.81$, $\\kappa = 0.2$, $\\pi = 3.14159265358979$ and \nvalues for $\\omega$, $\\varphi$, $A$, $Q$ and $\\textbf{D}$ as follows:\n\n\\begin{equation}\\label{eq:gerstner_constants}\n\\begin{split}\n    \\omega ={}& \\Big\\{\\sqrt{g 2\\pi}, \\sqrt{g 4\\pi}, \\sqrt{g 10\\pi}, \\sqrt{g\n    \\pi}\\Big\\},\\\\\n    %\n    \\varphi ={}& \\{0.4 \\omega_1, 0.3 \\omega_2, 0.3 \\omega_3, 0.1 \\omega_4\\},\\\\\n    %\n    A ={}& \\{0.01, 0.008, 0.017, 0.003\\},\\\\\n    %\n    Q ={}& \\Bigg\\{\\frac{\\kappa}{\\omega_1 A_1 i}, \\frac{\\kappa}{\\omega_2 A_2 i},\n    \\frac{\\kappa}{\\omega_3 A_3 i}, \\frac{\\kappa}{\\omega_4 A_4 i} \\Bigg\\},\\\\\n    %\n    \\textbf{D} ={}& \\Bigg\\{\\begin{bmatrix}0.0 \\\\ 0.5\\end{bmatrix},\n    \\begin{bmatrix}0.8 \\\\ 0.7\\end{bmatrix}, \\begin{bmatrix}0.6 \\\\\n    0.6\\end{bmatrix}, \\begin{bmatrix}0.7 \\\\ -0.3\\end{bmatrix}\\Bigg\\}\n\\end{split}\n\\end{equation}\n\nThe implementation can be found in \\autoref{lst:vertex} on\npage~\\pageref{lst:vertex}.\n\n\\lstdefinestyle{glsl}{\n  belowcaptionskip=1\\baselineskip,\n  breaklines=true,\n  xleftmargin=\\parindent,\n  language=C,\n  showstringspaces=false,\n  basicstyle=\\footnotesize\\ttfamily,\n  keywordstyle=\\bfseries\\color{red!70!black},\n  commentstyle=\\itshape\\color{black!40},\n  morekeywords={vec3, vec4, dot, reflect, refract, mix, pow, texture, sin, cos},\n  %255 75 62\n}\n\\lstset{style=glsl, caption={Implementation of\n\\cref{eq:gerstner_position,eq:gerstner_normal,eq:gerstner_tangent}},\nlabel={lst:vertex},captionpos=b}\n\\begin{figure}[ht!]\n\\begin{lstlisting}\nvec4 position = in_Position;\nvec3 normal = vec3(0.0, 1.0, 0.0);\nvec3 tangent = vec3(0.0, 0.0, 1.0);\n\nfor(int i = 0; i < NUMWAVES; i++) {\n    float alpha = w[i] * dot(D[i], position.xz) + phi[i] * t;\n    float WA = w[i] * A[i];\n    float sinAlpha = sin(alpha);\n    float cosAlpha = cos(alpha);\n    float DxCos = D[i].x * cosAlpha;\n    float DyCos = D[i].y * cosAlpha;\n    float DxDy = D[i].x * D[i].y;\n\n    position.x += Qs[i] * A[i] * DxCos;\n    position.y += A[i] * sinAlpha;\n    position.z += Qs[i] * A[i] * DyCos;\n\n    normal.x -= D[i].x * WA * cosAlpha;\n    normal.y -= Qs[i] * WA * sinAlpha;\n    normal.z -= D[i].y * WA * cosAlpha;\n\n    tangent.x -= Qs[i] * DxDy * WA * sinAlpha;\n    tangent.y += D[i].y * WA * cosAlpha;\n    tangent.z -= Qs[i] * D[i].y * D[i].y * WA * sinAlpha;\n}\n\\end{lstlisting}\n\\end{figure}\n\nWe pass to the fragment shader the local position, normal and tangent vectors \nas well as the local light position and the roughness of the surface.\n\nIn the fragment shader we update the normal with the values read from the normal\nmap. Then we transform the light position, vertex position and normal into the\neye space. We compute the reflection and refraction vectors as described in\n\\autoref{subsec:ocean_details} with the help of glsl's \\texttt{reflect(\\ldots)}\nand \\texttt{refract(\\ldots)} functions. The two corresponding colors are fetched\nfrom the cube map texture of the skybox and mixed together based on Schlick's\napproximation of the Fresnel term. This gives our \\texttt{ambient} term, whose\ncomputation is shown in \\autoref{lst:fragment_refref}\non~\\pageref{lst:fragment_refref}. \\texttt{F\\_0} results form\n\\autoref{eq:schlick_cst} with $n_{water} = 1.333$ and equal to 0.020373.\n\\texttt{RATIO} is the ratio between the water and air refractive indices and\nequal to 0.75.\n\n\\lstset{style=glsl, caption={Reflection and refraction color computation},\nlabel={lst:fragment_refref},captionpos=b}\n\\begin{figure}[ht!]\n\\begin{lstlisting}\nvec3 reflected = reflect(incident_eye, n);\nreflected = vec3(inverse_V * vec4(reflected, 0.0));\n\nvec3 refracted = refract(incident_eye, n, RATIO);\nrefracted = vec3(inverse_V * vec4(refracted, 0.0));\n\nvec4 reflectColor = texture(cube_texture, reflected);\nvec4 refractColor = texture(cube_texture, refracted);\n\nvec4 ambient = mix(refractColor, reflectColor, F(F0, v, n));\n\\end{lstlisting}\n\\end{figure}\n\nFor the \\texttt{specular} term we use the Cook-Torrance microfacet specular\nBRDF\\footnote{Bidirectional reflectance distribution function} as\ndescribed in \\autoref{eq:cook-torrance_spec}.\n\n\\begin{equation}\\label{eq:cook-torrance_spec}\n    f(\\textbf{l}, \\textbf{v}) ={} \\frac{F(\\textbf{l}, \\textbf{h})\n        G(\\textbf{l}, \\textbf{v}, \\textbf{h}) D(\\textbf{h})}{4\n    (\\textbf{n} \\cdot \\textbf{l}) (\\textbf{n} \\cdot \\textbf{v})}\n\\end{equation}\n%\n$F(\\textbf{l}, \\textbf{h})$ is Schlick's approximation of the Fersnel term as\nseen in \\autoref{eq:schlick}. For $D(\\textbf{h})$, the normal distribution\nfunction, we use the GGX/Trowbridge-Reitz function:\n\n\\begin{equation}\\label{eq:ndf_ggx}\n    D(\\textbf{h}) ={} \\frac{\\alpha^2}{\\pi{({(\\textbf{n} \\cdot \\textbf{h})}^2\n    (\\alpha^2 - 1) + 1)}^2}\n\\end{equation}\n%\n$\\alpha$ is the squared roughness. And for the specular geometric attenuation\nterm $G(\\textbf{l}, \\textbf{v}, \\textbf{h})$ we take the height correlated Smith\nfunction:\n\n\\begin{equation}\\label{eq:height_smith_a}\n    k ={} \\frac{\\alpha}{2}\n\\end{equation}\n\\begin{equation}\\label{eq:height_smith_b}\n    G_1(\\textbf{x}) ={} \\frac{\\textbf{n} \\cdot \\textbf{x}}{(\\textbf{n} \\cdot\n    \\textbf{x})(1 - k) + k}\n\\end{equation}\n\\begin{equation}\\label{eq:height_smith_c}\n    G(\\textbf{l}, \\textbf{v}, \\textbf{h}) ={} G_1(\\textbf{l}) G_1(\\textbf{v})\n\\end{equation}\n\nWe choose to use the same equations as in \\autocite{karis2013real} for\n$F(\\textbf{l}, \\textbf{h})$, $G(\\textbf{l}, \\textbf{v}, \\textbf{h})$ and\n$D(\\textbf{h})$. The implementation of those functions can be found in\n\\autoref{lst:fragment_brdf} on page~\\pageref{lst:fragment_brdf}. To reduce the\ncomputations we avoid using the \\texttt{dot(\\ldots)} function inside of them.\nInstead we pass the value of the computed dot product.\n\n\\lstset{style=glsl, caption={Cook-Torrance microfacet specular BRDF helper\nfunctions}, label={lst:fragment_brdf},captionpos=b}\n\\begin{figure}[ht!]\n\\begin{lstlisting}\n// Shlick approximation\nfloat F(float F_0, vec3 v, vec3 h) {\n\n    return F_0 + (1 - F_0) * pow((1 - max(dot(v, h), 0)), 5);\n}\n\nfloat G_smith(float nx, float k) {\n\n    return nx / (nx * (1 - k) + k);\n}\n\n// Height correlated Smith\nfloat G(float nl, float nv, float k) {\n\n    return G_smith(nl, k) * G_smith(nv, k);\n}\n\n// Trowbridge-Reitz\nfloat D(float nh, float alpha2) {\n\n    float denom = nh * nh * (alpha2 - 1) + 1;\n    return alpha2 / (PI * denom * denom);\n}\n\\end{lstlisting}\n\\end{figure}\n\nFinally we output the final fragment color as the sum of the ambient and\nspecular values: \\texttt{out\\_Color = specular + ambient}.\n", "meta": {"hexsha": "9c693678677f2cb99ce80927e36041642484e4f4", "size": 9162, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/report/text/3_methods.tex", "max_stars_repo_name": "SamuelGauthier/rtwr", "max_stars_repo_head_hexsha": "957f9f45e93d99f3f82b1b3cb6e988d296991675", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/report/text/3_methods.tex", "max_issues_repo_name": "SamuelGauthier/rtwr", "max_issues_repo_head_hexsha": "957f9f45e93d99f3f82b1b3cb6e988d296991675", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/report/text/3_methods.tex", "max_forks_repo_name": "SamuelGauthier/rtwr", "max_forks_repo_head_hexsha": "957f9f45e93d99f3f82b1b3cb6e988d296991675", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.8356164384, "max_line_length": 80, "alphanum_fraction": 0.712289893, "num_tokens": 2933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.42609732828562247}}
{"text": "\\documentclass[11pt,oneside]{article}\t%use\"amsart\"insteadof\"article\"forAMSLaTeXformat\n\\usepackage{geometry}\t\t%Seegeometry.pdftolearnthelayoutoptions.Therearelots.\n\\geometry{letterpaper}\t\t%...ora4paperora5paperor...\n%\\geometry{landscape}\t\t%Activateforforrotatedpagegeometry\n%\\usepackage[parfill]{parskip}\t\t%Activatetobeginparagraphswithanemptylineratherthananindent\n\\usepackage{graphicx}\t\t\t\t%Usepdf,png,jpg,orepsßwithpdflatex;useepsinDVImode\n\t\t\t\t\t\t\t\t%TeXwillautomaticallyconverteps-->pdfinpdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage[colorlinks]{hyperref}\n\n%----macros begin---------------------------------------------------------------\n\\usepackage{color}\n\\usepackage{amsthm}\n\\usepackage{amsmath}\n\n\\def\\conv{\\mbox{\\textrm{conv}\\,}}\n\\def\\aff{\\mbox{\\textrm{aff}\\,}}\n\\def\\E{\\mathbb{E}}\n\\def\\R{\\mathbb{R}}\n\\def\\Z{\\mathbb{Z}}\n\\def\\tex{\\TeX}\n\\def\\latex{\\LaTeX}\n\\def\\v#1{{\\bf #1}}\n\\def\\p#1{{\\bf #1}}\n\\def\\T#1{{\\bf #1}}\n\n\\def\\vet#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\\def\\mat#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\n\\def\\lin{\\mbox{\\rm lin}\\,}\n\\def\\aff{\\mbox{\\rm aff}\\,}\n\\def\\pos{\\mbox{\\rm pos}\\,}\n\\def\\cone{\\mbox{\\rm cone}\\,}\n\\def\\conv{\\mbox{\\rm conv}\\,}\n\\newcommand{\\homog}[0]{\\mbox{\\rm homog}\\,}\n\\newcommand{\\relint}[0]{\\mbox{\\rm relint}\\,}\n\n%----macros end-----------------------------------------------------------------\n\n\\title{Boolean combinations of cellular complexes as chain operations\n\\footnote{This document is part of the \\emph{Linear Algebraic Representation with CoChains} (LAR-CC) framework~\\cite{cclar-proj:2013:00}. \\today}\n}\n\\author{Alberto Paoluzzi}\n%\\date{}\t\t\t\t\t\t\t%Activatetodisplayagivendateornodate\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\\nonstopmode\n\n%-------------------------------------------------------------------------------\n\\section{Introduction}\n%-------------------------------------------------------------------------------\n\nIn this module a novel approach to Boolean operations of cellular complexes is defined and implemented. The novel algorithm may be summarised as follows. \n\nFirst we compute the CDC (Common Delaunay Complex) of the input LAR complexes $A$ and $B$, to get a LAR of the \\emph{simplicial} CDC.\n\nThen, we split the cells intersecting the boundary faces of the input complexes, getting the final \\emph{polytopal} SCDC  \n(Split Common Delaunay Complex), whose cells  provide the  basis for the linear coordinate representation of both input \ncomplexes, upon the same space decomposition.\n\nAfterwards, every Boolean result is computed by bitwise operations, between the coordinate representations of the transformed $A$ and $B$ input.\n\n\nFinally a greedy assembly of SCDC cells is executed, in order to if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nFinally a greedy assembly of SCDC cells is executed, in order to return a polytopal complex with a reduced number of cells.\n\n\n\n\\subsection{Preview of the Boolean algorithm}\n%-------------------------------------------------------------------------------\n\nThe goal is the computation of $A \\diamond B$, with $\\diamond\\in \\{\\cup, \\cap, -\\}$, where a LAR representation of both $A$ and $B$ is given. The Boolean algorithm works as follows.\n\n\\begin{enumerate}\n\\item \nEmbed both cellular complexes $A$ and $B$ in the same space (say, identify their common vertices) by $V_{ab} = V_a \\cup V_b$.\n\\item \nBuild their CDC  (Common Delaunay Complex) as the LAR of \\emph{Delaunay triangulation} of the vertex set $V_{ab}$, and embedded $\\partial A$ and $\\partial B$ in it.\n\\item \nSplit the (highest-dimensional) cells of CDC crossed by $\\partial A$ or $\\partial B$. Their lower dimensional faces remain partitioned accordingly. We name the resulting complex SCDC (Split Common Delaunay Complex).\n\\item \nWith respect to the SCDC basis of $d$-cells $C_d$, compute two coordinate chains $\\alpha,\\beta: C_d \\to \\{0,1\\}$, such that: \n\\begin{align}\n\t\\alpha(cell) &= 1  \\quad\\mbox{if\\ } |cell| \\subset A;  \\quad\\mbox{else\\ } \\alpha(cell) = 0, \\nonumber\\\\\n\t\\beta(cell) &= 1  \\quad\\mbox{if\\ } |cell| \\subset B;  \\quad\\mbox{else\\ } \\beta(cell) = 0. \\nonumber\n\\end{align}\n\\item \nExtract accordingly the SCDC chain corresponding to $A \\diamond B$, with $\\diamond\\in \\{\\cup, \\cap, -\\}$.\n\\end{enumerate}\n\n\n\\subsection{Remarks}\n%-------------------------------------------------------------------------------\n\nYou may  make an analogy between the SCDC (\\emph{Split} CDC) and a CDT (Constrained Delaunay Triangulation).  In part they coincide, but in general, the SCDC is a polytopal complex, and is not a simplicial complex as the CDC.\n\nThe more complex algorithmic step is the cell splitting.  \nEvery time, a single $d$-cell  $c$  is split by a single hyperplane (cutting its interior)  giving either two splitted cells $c_1$ and $c_2$, or just one output cell (if the hyperplane is the affine hull of the CDC facet)\nwhatever the input cell dimension $d$.  After every splitting of the cell interior, the row $c$ is substituted (within the \\texttt{CV} matrix) by $c_1$, and $c_2$ is \nadded to the end of the \\texttt{CV} matrix, as a new row.\n\nThe splitting process is started by ``splitting seeds\" generated by $(d-1)$-faces of both operand boundaries.\nIn fact, every such face, say $f$, has vertices on CDC and \\emph{may} split some incident CDC $d$-cell.  In particular, starting from its vertices,\n$f$ must split the CDC cells in whose interior it passes though.\n\nSo, a dynamic data structure is set-up, storing for each boundary face $f$ the list of cells it must cut, and, for every CDC $d$-cell with interior traversed\nby some such $f$, the list of cutting faces.  This data structure is continuously updated during the splitting process, using the \nadjacent cells of the split ones, who are to be split in turn.  Every split cell may add some adjacent cell to be split, and after the split,\nthe used pair (\\texttt{cell,face}) is removed.  The splitting process continues until the data structure becomes empty.\n\nEvery time a cell is split, it is characterized as either internal (1) or external (0) to the used (oriented) boundary facet f, so that the two \nresulting subcells $c_1$ and $c_2$  receive two opposite characterization (with respect to the considered boundary).\n\nAt the very end, every (polytopal) SCDC $d$-cell has two bits of information (one for argument $A$ and one for argument $B$), telling whether it is internal  (1) or external (0) or unknown (-1) with respect to every Boolean argument.\n\nA final recursive traversal of the SCDC, based on cell adjacencies, transforms every $-1$ into either 0 or 1, providing the two final chains to be bitwise operated, depending on the Boolean operation to execute.\n\n\n%-------------------------------------------------------------------------------\n\\section{Step 1: merging discrete spaces}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Requirements}\n%-------------------------------------------------------------------------------\n\nThe \\emph{join} of two sets $P, Q \\subset \\E^d$ is the set $PQ = \\{\\alpha \\v{x} + \\beta \\v{y}\\,| \\v{x} \\in P,\\  \\v{y} \\in Q\\}$,\nwhere $\\alpha, \\beta \\in \\R$, $\\alpha, \\beta \\geq 0$, and $\\alpha + \\beta = 1$. The join operation is associative and commutative.\n\n\n\\paragraph{Input} \nTwo LAR models of two non-empty ``solid'' $d$-spaces $A$ and $B$, denoted as \\texttt{(V1,CV1)} and \\texttt{(V2,CV2)}. \n\n\n\\paragraph{Output} \nThe LAR representation \\texttt{(V,CV)} of Delaunay triangulation (simplicial $d$-complex) of the set $\\conv AB \\subset \\E^d$, convex hull of the join of $A$ and $B$, named Common Delaunay Complex (CDC) in the following.\n\n\\paragraph{Auxiliary data structures} \n\nThis software module if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nThis software module returns also:\n\n\\begin{enumerate}\n\\item \n\na dictionary \\texttt{vertDict} of \\texttt{V} vertices, with \\emph{key} the symbolic representation of vertices \\texttt{v} if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\na dictionary \\texttt{vertDict} of \\texttt{V} vertices, with \\emph{key} the symbolic representation of vertices \\texttt{v} returned by expressions \\texttt{vcode(4)(v)}, $\\texttt{v}\\in \\texttt{V}$, and with values the finite ordinal numbers of the vertices;\n\n\\item \nthe numbers \\texttt{n1}, \\texttt{n12}, \\texttt{n2} of the elements of \\texttt{V1}, $\\texttt{V1}\\cap\\texttt{V2}$, and \\texttt{V2}, respectively. Notice that the following assertions must hold (see Figure~\\ref{fig:bounds}):\n\\begin{align}\n\\texttt{n1} - \\texttt{n12} + \\texttt{n2} &= \\texttt{n} \\\\\n0 < \\texttt{n} - \\texttt{n2}  &\\leq  \\texttt{n1}  <  \\texttt{n} \n\\end{align}\n\n\\item the input boundary complex \\texttt{(V,BC)}, with $\\texttt{BC} = \\texttt{BC1+BC2}$, i.e.~the union of the  two boundary $(d-1)$-complexes \\texttt{(V,BC1)} and \\texttt{(V,BC2)}, defined on the common vertices.\n\\end{enumerate}\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.5\\linewidth]{images/bounds} \n   \\caption{Relationships inside the orderings of CDC vertices}\n   \\label{fig:bounds}\n\\end{figure}\n\n\\subsection{Implementation}\n%-------------------------------------------------------------------------------\n\n\n\\subsubsection{Summary}\n\n%-------------------------------------------------------------------------------\n@D First Boolean step\n@{\"\"\" First Boolean step \"\"\"\ndef larBool1():\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool1\")\n\n\tV, CV1,CV2, n1,n12,n2 = mergeVertices(model1,model2)\n\tVV = AA(LIST)(range(len(V)))\n\tV,CV,vertDict,n1,n12,n2,BC,nbc1,nbc2 = makeCDC(arg1,arg2)\n\tW,CW,VC,BCellCovering,cellCuts,boundary1,larUnsignedBoundary2,BCW = makeSCDC(V,CV,BC,nbc1,nbc2)\n\tassert len(VC) == len(V) \n\tassert len(BCellCovering) == len(BC)\n\n\tif TRACE: tracing = mytrace(tracing,\"<larBool1\")-1\n\treturn W,CW,VC,BCellCovering,cellCuts,boundary1,larUnsignedBoundary2,BCW \n@}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Detail functions}\n\n\n\n%-------------------------------------------------------------------------------\n@D Merge two dictionaries with keys the point locations\n@{\"\"\" Merge two dictionaries with keys the point locations \"\"\"\ndef mergeVertices(model1, model2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">mergeVertices\")\n\n\t(V1,CV1),(V2,CV2) = model1, model2\n\n\tn = len(V1); m = len(V2)\n\tdef shift(CV, n): \n\t\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">shift\")\n\t\tif TRACE: tracing = mytrace(tracing,\"<shift\")-1\n\t\treturn [[v+n for v in cell] for cell in CV]\n\tCV2 = shift(CV2,n)\n\n\tvdict1 = defaultdict(list)\n\tfor k,v in enumerate(V1): vdict1[vcode(4)(v)].append(k) \n\tvdict2 = defaultdict(list)\n\tfor k,v in enumerate(V2): vdict2[vcode(4)(v)].append(k+n) \n\tvertDict = defaultdict(list)\n\tfor point in vdict1.keys(): vertDict[point] += vdict1[point]\n\tfor point in vdict2.keys(): vertDict[point] += vdict2[point]\n\n\tcase1, case12, case2 = [],[],[]\n\tfor item in vertDict.items():\n\t\tkey,val = item\n\t\tif len(val)==2:  case12 += [item]\n\t\telif val[0] < n: case1 += [item]\n\t\telse: case2 += [item]\n\tn1 = len(case1); n2 = len(case12); n3 = len(case2)\n\n\tinvertedindex = list(0 for k in range(n+m))\n\tfor k,item in enumerate(case1):\n\t\tinvertedindex[item[1][0]] = k\n\tfor k,item in enumerate(case12):\n\t\tinvertedindex[item[1][0]] = k+n1\n\t\tinvertedindex[item[1][1]] = k+n1\n\tfor k,item in enumerate(case2):\n\t\tinvertedindex[item[1][0]] = k+n1+n2\n\n\tV = [eval(p[0]) for p in case1] + [eval(p[0]) for p in case12] + [eval(\n\t\t\t\tp[0]) for p in case2]\n\tCV1 = [sorted([invertedindex[v] for v in cell]) for cell in CV1]\n\tCV2 = [sorted([invertedindex[v] for v in cell]) for cell in CV2]\n\n\n\tif TRACE: tracing = mytrace(tracing,\"<mergeVertices\")-1\n\treturn V,CV1,CV2, n1+n2,n2,n2+n3\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\t\n%-------------------------------------------------------------------------------of\n@D Make Common Delaunay Complex\n@{\"\"\" Make Common Delaunay Complex \"\"\"\nfrom scipy.spatial import Delaunay\ndef makeCDC(arg1,arg2, brep=False):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">makeCDC\")\n\n\n\t(V1,basis1), (V2,basis2) = arg1,arg2\n\t(facets1,cells1),(facets2,cells2) = basis1[-2:],basis2[-2:]\n\tmodel1, model2 = (V1,cells1),(V2,cells2)\n\n\tV, _,_, n1,n12,n2 = mergeVertices(model1, model2)\n\tn = len(V)\n\tassert n == n1 - n12 + n2\n\t\n\tCV = sorted(AA(sorted)([simplex for simplex in Delaunay(array(V)).simplices.tolist() \n\t\tif not (-0.0001 < scipy.linalg.det([V[v]+[1] for v in simplex]) < 0.0001) ]))\n\t\n\tvertDict = defaultdict(list)\n\tfor k,v in enumerate(V): vertDict[vcode(4)(v)] += [k]\n\t\n\tif brep == False:\n\t\tsigns1,BC1 = signedCellularBoundaryCells(V1,basis1)\n\t\t\n\t\tBC1pairs = zip(*signedCellularBoundaryCells(V1,basis1))\n\t\tBC1 = [basis1[-2][face] if sign>0 else swap(basis1[-2][face]) for (sign,face) in BC1pairs]\n\t\n\t\tBC2pairs = zip(*signedCellularBoundaryCells(V2,basis2))\n\t\tBC2 = [basis2[-2][face] if sign>0 else swap(basis2[-2][face]) for (sign,face) in BC2pairs] \n\n\telse:\n\t\tBC1,BC2 = basis1[-1],basis2[-1]\n\t\n\tBC = [[ vertDict[vcode(4)(V1[v])][0] for v in cell] for cell in BC1] + [ \n\t\t\t[ vertDict[vcode(4)(V2[v])][0] for v in cell] for cell in BC2] #+ qhullBoundary(V)\n\t\t\n\n\tif TRACE: tracing = mytrace(tracing,\"<makeCDC\")-1\n\treturn V,CV,vertDict,n1,n12,n2,BC,len(BC1),len(BC2)\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n%-------------------------------------------------------------------------------\n\\section{Step 2: splitting cells}\n%-------------------------------------------------------------------------------\n\nThe goal of this section is to transform the CDC simplicial complex, into the polytopal Split Common Delaunay Complex (SCDC), by splitting the $d$-cells of CDC crossed in their interior by some cell of the input boundary complex.\n\n\\subsection{Requirements}\n%-------------------------------------------------------------------------------\nWe call here for a sequential implementation, following every $(d-1)$-facet \\texttt{lambda} in \\texttt{BC} (for \\emph{Boundary Cells}). We start the splitting with \\texttt{COVECTOR(lambda)} from \\texttt{cell}, one of the CDC $d$-cells  incident on a vertex of \\texttt{lambda}, and continue the splitting on the $d$-cells $(d-1)$-adjacent  to \\texttt{cell}, where (a) \\texttt{COVECTOR(lambda)} either crosses the \\texttt{cell}'s interior or contains one of \\texttt{cell}'s $(d-1)$-facets \\and{and} (b) such that the intersection with \\texttt{lambda} is not empty, until the queue (or stack) of $d$-cells to intersect with \\texttt{covector} is not empty.\n\n\\paragraph{Best computational strategy}\nFirst associate to each cutting facet the list of cells it may cut; then execute all the cuts. In this way we can compute the adjacency matrix just one time at the beginning of the procedure, and do not need to update it after every split.\n\n\\paragraph{Input}\nThe output of previous algorithm stage.\n\n\\paragraph{Output}\nThe LAR representation \\texttt{(W,PW)} of the SCDC,\n\n\\paragraph{Auxiliary data structures} \n\nThis software module if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nThis software module returns also\n a dictionary \\texttt{splitFacets}, with keys the  input boundary faces and values the list of pairs\\texttt{(covector,fragmentedFaces)}.   \n\n\n\\subsection{Implementation}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Summary}\n\n%-------------------------------------------------------------------------------\n@D Second Boolean step\n@{\"\"\" Second Boolean step \"\"\"\ndef larBool2(boundary1,larUnsignedBoundary2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool2\")\n\n\tdim = len(W[0])\n\tWW = AA(LIST)(range(len(W)))\n\tFW = convexFacets (W,CW)\n\t_,EW = larFacets((W,FW), dim=2)\n\tboundary1,larUnsignedBoundary2,FWdict = makeFacetDicts(FW,boundary1,larUnsignedBoundary2)\n\tif dim == 3: \n\t\t_,EW = larFacets((W,FW), dim=2)\n\t\tbases = [WW,EW,FW,CW]\n\telif dim == 2: bases = [WW,FW,CW]\n\telse: print \"\\nerror: not implemented\\n\"\n\n\tif TRACE: tracing = mytrace(tracing,\"<larBool2\")-1\n\treturn W,CW,dim,bases,boundary1,larUnsignedBoundary2,FW,BCW\n@}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Detail functions}\n\n\n\\paragraph{Computing the adjacent cells of a given cell}\nTo perform this task we make only use of the \\texttt{CV} list. In a more efficient implementation we should make direct use of the sparse adjacency matrix, to be dynamically updated together with the \\texttt{CV} list.\nThe computation of the adjacent $d$-cells of a single $d$-cell is given here by extracting a column of the $\\texttt{CSR}(M_d\\, M_d^t)$. This can be done by multiplying $\\texttt{CSR}(M_d)$ by its transposed row corresponding to the query $d$-cell. \n\n%-------------------------------------------------------------------------------\n@D Computing the adjacent cells of a given cell\n@{\"\"\" Computing the adjacent cells of a given cell \"\"\"\ndef adjacencyQuery (V,CV):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">adjacencyQuery\")\n\n\tdim = len(V[0])\n\tcsrCV =  csrCreate(CV)\n\tcsrAdj = matrixProduct(csrCV,csrTranspose(csrCV))\n\tdef adjacencyQuery0 (cell):\n\t\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">adjacencyQuery0\")\n\n\t\tnverts = len(CV[cell])\n\t\tcellAdjacencies = csrAdj.indices[csrAdj.indptr[cell]:csrAdj.indptr[cell+1]]\n\n\t\tif TRACE: tracing = mytrace(tracing,\"<adjacencyQuery0\")-1\n\t\treturn [acell for acell in cellAdjacencies if dim <= csrAdj[cell,acell] < nverts]\n\n\tif TRACE: tracing = mytrace(tracing,\"<adjacencyQuery\")-1\n\treturn adjacencyQuery0\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Relational inversion (characteristic matrix transposition)}\n\nThe operation could be executed by simple matrix transposition of the CSR (Compressed Sparse Row) representation of the sparse characteristic matrix $M_d \\equiv \\texttt{CV}$.\nA simple relational inversion using Python lists is given here. The \\texttt{invertRelation} function \nis given here, linear in the size of the \\texttt{CV} list, where the complexity of each cell is constant and \nsmall in most cases.\n\n%-------------------------------------------------------------------------------\n@D Characteristic matrix transposition\n@{\"\"\" Characteristic matrix transposition \"\"\"\ndef invertRelation(CV):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">invertRelation\")\n\n\tdef myMax(List):\n\t\t#if TRACE: global tracing;tracing = mytrace(tracing+1,\">myMax\")\n\n\t\tif List==[]: \n\t\t\t#if TRACE: tracing = mytrace(tracing,\"<myMax\")-1\n\t\t\treturn -1\n\t\telse: \n\t\t\t#if TRACE: tracing = mytrace(tracing,\"<myMax\")-1\n\t\t\treturn max(List)\n\t\t\t\n\tcolumnNumber = max(AA(myMax)(CV))+1\n\tVC = [[] for k in range(columnNumber)]\n\tfor k,cell in enumerate(CV):\n\t\tfor v in cell:\n\t\t\tVC[v] += [k]\n\n\tif TRACE: tracing = mytrace(tracing,\"<invertRelation\")-1\n\treturn VC\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Computation of splitting tests}\n\nIn order to compute, in the simplest and more general way, whether each of the two split $d$-cells is internal or external to the splitting boundary $d-1$-facet, it is necessary to consider the oriented covector $\\phi$ (or one-form) canonically associated to the facet $f$ by the covector representation theorem, i.e.~the corresponding oriented hyperplane. In this case, the internal/external attribute of the split cell will be computed by evaluating the pairing $<v,\\phi>$.\n\n%-------------------------------------------------------------------------------\n@D Splitting tests\n@{\"\"\" Splitting tests \"\"\"\ndef testingSubspace(V,covector):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">testingSubspace\")\n\n\tdef testingSubspace0(vcell):\n\t\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">testingSubspace0\")\n\n\t\tinout = SIGN(sum([INNERPROD([[1.]+V[v],covector]) for v in vcell]))\n\n\t\tif TRACE: tracing = mytrace(tracing,\"<testingSubspace0\")-1\n\t\treturn inout\n\n\tif TRACE: tracing = mytrace(tracing,\"<testingSubspace\")-1\n\treturn testingSubspace0\n\t\ndef cuttingTest(covector,polytope,V):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">testingSubspace0\")\n\n\tsigns = [INNERPROD([covector, [1.]+V[v]]) for v in polytope]\n\tsigns = eval(vcode(4)(signs))\n\n\tif TRACE: tracing = mytrace(tracing,\"<testingSubspace0\")-1\n\treturn any([value<-0.001 for value in signs]) and \\\n\t\t\tany([value>0.001 for value in signs])\n\t\ndef tangentTest(covector,facet,adjCell,V,f):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">tangentTest\")\n\n\tcommon = list(set(facet).intersection(adjCell))\n\tsigns = [INNERPROD([covector, [1.]+V[v]]) for v in common]\n\tcount = 0\n\tfor value in signs:\n\t\tif -0.0001<value<0.0001: count +=1\n\tif count >= len(V[0]): \n\n\t\tif TRACE: tracing = mytrace(tracing,\"<tangentTest\")-1\n\t\treturn True\n\telse: \n\n\t\tif TRACE: tracing = mytrace(tracing,\"<tangentTest\")-1\n\t\treturn False\t\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\\paragraph{Elementary splitting test}\n\nLet us remember that the adjacency matrix between $d$-cells is computed via SpMSpM multiplication by the double application \n\\[\n\\texttt{adjacencyQuery(V,CV)(cell)}, \n\\] \nwhere the first application \\texttt{adjacencyQuery(V,CV)}\n\nif TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nreturn\ns a partial function with bufferisation of the adjacency matrix, and the second application to \\texttt{cell} if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\ns a partial function with bufferisation of the adjacency matrix, and the second application to \\texttt{cell} returns the list of adjacent $d$-cells sharing with it a $(d-1)$-dimensional facet.\n\n%-------------------------------------------------------------------------------\n@D Elementary splitting test\n@{\n@< Splitting tests @>\n\n\"\"\" Elementary splitting test \"\"\"\ndef dividenda(V,CV, cell,facet,covector,unchosen):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">dividenda\")\n\n\tout = []\n\tadjCells = adjacencyQuery(V,CV)(cell)\n\tfor adjCell in set(adjCells).difference(unchosen):\n\t\tif (cuttingTest(covector,CV[adjCell],V) and \\\n\t\t\tcellFacetIntersecting(facet,adjCell,covector,V,CV)) or \\\n\t\t\ttangentTest(covector,facet,CV[adjCell],V,adjCell): \n\t\t\tout += [adjCell]\n\n\tif TRACE: tracing = mytrace(tracing,\"<dividenda\")-1\n\treturn out\n@}\n%-------------------------------------------------------------------------------\n(True and True) or False\n\n\\paragraph{CDC cell splitting with one or more facets}\n\n\nWhen splitting a $d$-cell with some hyperplanes, we need to if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nWhen splitting a $d$-cell with some hyperplanes, we need to return not only either the two cut parts or the cell itself when the hyperplane is tangent to a $(d-1)$-face, but also the facet lying on the hyperplane. \n\nIn the first cade it is directly computed by the \\texttt{SPLITCELL} function, and if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nIn the first cade it is directly computed by the \\texttt{SPLITCELL} function, and return\ned as the \\texttt{equal} set of points. In the second case, the cell is transformed by the map that sends the hyperplane in the $x_d=0$ subspace ($z=0$ in 3D), and the searched facet is if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\ned as the \\texttt{equal} set of points. In the second case, the cell is transformed by the map that sends the hyperplane in the $x_d=0$ subspace ($z=0$ in 3D), and the searched facet is returned as the (back-transformed) set of cell vertices on this subspace. \n\nActually, the process is strongly complicated by the fact that the input cell (and its facets) may be cut by several hyperplanes. By now, we resort to the simplest computation, even if more time-expensive:  to compare each vertex of each cell fragment, against every hyperplanes. This approach will adapt well to the writing of a computational kernel on the GPU.\n\n%-------------------------------------------------------------------------------\n@D CDC cell splitting with one or more cutting facets\n@{\"\"\" CDC cell splitting with one or more cutting facets \"\"\"\n# new implementation\ndef fragment(cell,cellCuts,V,CV,BC):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">fragment\")\n\n\tvcell = CV[cell]\n\tcellFragments = [[V[v] for v in vcell]]\n\t\n\tfor f in cellCuts[cell]:\n\t\tfacet = BC[f]\n\t\tplane = COVECTOR([V[v] for v in facet])\n\t\tk = 0\n\t\twhile True:\n\t\t\tfragment = cellFragments[k]\n\t\t\n\t\t\t#if not tangentTest(plane,facet,fragment,V,f):\n\t\t\t[below,equal,above] = SPLITCELL(plane,fragment,tolerance=1e-3,ntry=4)\n\n\t\t\tif below != above:\n\t\t\t\tcellFragments[k] = below\n\t\t\t\tcellFragments += [above]\n\t\t\tk += 1\n\t\t\tif k >= len(cellFragments): break\n\t\t\t\t\n\t\tfacets = facetsOnCuts(cellFragments,cellCuts,V,BC)\n\n\tif TRACE: tracing = mytrace(tracing,\"<fragment\")-1\n\treturn cellFragments\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{SCDC splitting with every boundary facet}\nThe function \\texttt{makeSCDC} is used  to compute the LAR model \\texttt{(W,CW)} of the SCDC.\n\nIt takes as input the LAR model \\texttt{(V,CV)} of the CDC, and the LAR model \\texttt{(V,BC)} of the input Boolean Complex, and if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nIt takes as input the LAR model \\texttt{(V,CV)} of the CDC, and the LAR model \\texttt{(V,BC)} of the input Boolean Complex, and returns both a new LAR model \\texttt{(W,CW)} and the vertex-cell relation \\texttt{VC}, i.e.~the transposed of \\texttt{CV}.\n\nFor every $\\texttt{k} \\in \\texttt{BC}$, a list \\texttt{cellsToSplit}\n\nThe array \\texttt{cellCuts}  stores, for each cell in \\texttt{CV}, the list of original boundary cells that will cut it, possibly by adjusting the \\texttt{cellCuts} array length with empty lists.\nTherefore, the main loop in the \\texttt{makeSCDC} function generates one or more cells in \\texttt{CW}, starting from the $k$-th cell in \\texttt{CV} and the $k$-th list \\texttt{frags} in \\texttt{cellCuts}.\n\n\n%-------------------------------------------------------------------------------\n@D SCDC splitting with every boundary facet\n@{\"\"\" SCDC splitting with every boundary facet \"\"\"\ndef makeSCDC(V,CV,BC,nbc1,nbc2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">makeSCDC\")\n\n\tprint \"V,CV,BC,nbc1,nbc2 =\",V,CV,BC,nbc1,nbc2\n\t\t\n\tindex,defaultValue = -1,-1\n\tVC = invertRelation(CV)\n\tCW,BCfrags = [],[]\n\tWdict = dict()\n\tBCellcovering = boundaryCover(V,CV,BC,VC)\n\tFW = set()\n\t\n\tprint \"BCellcovering =\",BCellcovering,\"\\n\"\n\n\tcellCuts = invertRelation(BCellcovering)\n\tprint \"cellCuts =\",cellCuts,\"\\n\"\n\tfor k in range(len(CV) - len(cellCuts)): cellCuts += [[]]\n\n\tdef verySmall(number): \n\t\t#if TRACE: global tracing;tracing = mytrace(tracing+1,\">verySmall\")\t\t\n\t\t#if TRACE: tracing = mytrace(tracing,\"<verySmall\")-1\n\t\treturn abs(number) < 10**-5.5\n\t\n\tfor k,cuts in enumerate(cellCuts):\n\t\tif cuts == []:\n\t\t\tcell = []\n\t\t\tfor v in CV[k]:\n\t\t\t\tkey = vcode(4)(V[v])\n\t\t\t\tif Wdict.get(key,defaultValue) == defaultValue:\n\t\t\t\t\tindex += 1\n\t\t\t\t\tWdict[key] = index\n\t\t\t\t\tcell += [index]\n\t\t\t\telse: \n\t\t\t\t\tcell += [Wdict[key]]\n\t\t\t# uncut cells of CDC\n\t\t\tCW += [cell]  # OK !\n\t\telse:\n\t\t\tcellFragments = fragment(k,cellCuts,V,CV,BC)\n\t\t\tfor cellFragment in cellFragments:\n\t\t\t\tcellFrag = []\n\t\t\t\tfor v in cellFragment:\n\t\t\t\t\tkey = vcode(4)(v)\n\t\t\t\t\tif Wdict.get(key,defaultValue) == defaultValue:\n\t\t\t\t\t\tindex += 1\n\t\t\t\t\t\tWdict[key] = index\n\t\t\t\t\t\tcellFrag += [index]\n\t\t\t\t\telse: \n\t\t\t\t\t\tcellFrag += [Wdict[key]]\n\t\t\t\t# split cells of CDC\n\t\t\t\tCW += [cellFrag]\t  # OK\n\n\t\t\t\tfor f in cuts:\n\t\t\t\t\tthefacet = []\n\t\t\t\t\tfor w in cellFragment:\n\t\t\t\t\t\tif verySmall( PROD([ COVECTOR( [V[v] for v in BC[f]] ) , [1.]+w ]) ):\n\t\t\t\t\t\t\tthefacet += [ Wdict[vcode(4)(w)] ]\n\t\t\t\t\tBCfrags += [(f, thefacet)]\t\t\n\t\t\t\t\n\tprint \"\\nmakeSCDC >>\"\n\tprint \"end loop\"\n\tCW = sorted(AA(sorted)(CW))\n\tprint \"\\nBCfrags =\",BCfrags\n\tBCW = [ [ Wdict[vcode(4)(V[v])] for v in cell ] for cell in BC]\n\tW = sorted(zip( Wdict.values(), Wdict.keys() ))\n\tW = AA(eval)(TRANS(W)[1])\n\tdim = len(W[0])\n\tprint \"\\nCW =\",CW,\"\\n\"\n\tprint \"W =\",W,\"\\n\"\n\t\n\tFW = larConvexFacets(W,CW)\n\tprint \"\\nFW =\",FW,\"\\n\"\n\t\n\tboundary1,larUnsignedBoundary2 = boundaryEmbedding(BCfrags,nbc1,dim)\n\n\tif TRACE: tracing = mytrace(tracing,\"<makeSCDC\")-1\n\treturn W,CW,VC,BCellcovering,cellCuts,boundary1,larUnsignedBoundary2,BCW\n@}\n%-------------------------------------------------------------------------------\n\nfor h in cuts:\n\tfor w in cellFragment:\n\t\tif verySmall( PROD([ COVECTOR( [V[v] for v in BC[h]] ) , [1.]+w ]) ):\n\t\t\tBCfrags += (h, Wdict[vcode(4)(w)] )\n\n%-------------------------------------------------------------------------------\n@D Boolean argument boundaries embedding in SCDC\n@{\"\"\" Boolean argument boundaries embedding in SCDC \"\"\"\ndef boundaryEmbedding(BCfrags,nbc1,dim):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">boundaryEmbedding\")\n\n\tboundary1,larUnsignedBoundary2 = defaultdict(list),defaultdict(list)\t\t\t\t\t\t \n\tfor h,frags in BCfrags:\n\t\tif h < nbc1: boundary1[h] += [frags]\n\t\telse: larUnsignedBoundary2[h] += [frags]\t\n\tboundarylist1,boundarylist2 = [],[]\n\tfor h,facets in boundary1.items():\n\t\tboundarylist1 += [(h, AA(eval)(set([str(sorted(f)) \n\t\t\t\t\t\t\tfor f in facets if len(set(f)) >= dim])) )]\n\tfor h,facets in larUnsignedBoundary2.items():\n\t\tboundarylist2 += [(h, AA(eval)(set([str(sorted(f)) \n\t\t\t\t\t\t\tfor f in facets if len(set(f)) >= dim])) )]\n\tboundary1,larUnsignedBoundary2 = dict(boundarylist1),dict(boundarylist2)\n\n\tif TRACE: tracing = mytrace(tracing,\"<boundaryEmbedding\")-1\n\treturn boundary1,larUnsignedBoundary2\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@D Make facets dictionaries\n@{\"\"\" Make facets dictionaries \"\"\"\ndef makeFacetDicts(FW,boundary1,larUnsignedBoundary2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">makeFacetDicts\")\n\t\n\tprint \"boundary1 =\",boundary1\n\tprint \"larUnsignedBoundary2 =\",larUnsignedBoundary2\n\tprint \"FW =\",FW\n\t\n\tFWdict = dict()\n\tfor k,facet in enumerate (FW): FWdict[str(facet)] = k\n\t\n\tprint \"FWdict =\",FWdict\n\n\tfor key,value in boundary1.items():\n\t\tvalue = [FWdict[str(facet)] for facet in value]\n\t\tboundary1[key] = value\n\t\t\n\tfor key,value in larUnsignedBoundary2.items():\n\t\tvalue = [FWdict[str(facet)] for facet in value]\n\t\tlarUnsignedBoundary2[key] = value\n\n\tprint \"boundary1 =\",boundary1\n\tprint \"larUnsignedBoundary2 =\",larUnsignedBoundary2\n\n\tif TRACE: tracing = mytrace(tracing,\"<makeFacetDicts\")-1\n\treturn boundary1,larUnsignedBoundary2,FWdict\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Computation of boundary facets covering with CDC cells}\n\nIn the following script's input, \\texttt{V} and  \\texttt{CV} are the vertices of CDC, respectively, \\texttt{VC} is the \\texttt{CV} inverse relation, and \\texttt{BC} are the boundary cells of the Boolean input parameters.\n\n\n\n%-------------------------------------------------------------------------------\n@D Computation of boundary facets covering with CDC cells\n@{\"\"\" Computation of boundary facets covering with CDC cells \"\"\"\ndef boundaryCover(V,CV,BC,VC):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">boundaryCover\")\n\n\tBC = AA(sorted)(BC)\n\n\tprint \"\\nboundaryCover >>\"\n\tprint \"V =\",V\n\tprint \"CV =\",CV\n\tprint \"BC =\",BC\n\tprint \"VC =\",VC,\"\\n\"\n\n\tcellsToSplit = list()\n\tboundaryCellCovering = []\n\n\tfor k,facet in enumerate(BC):\n\t\tprint \"\\nk,facet =\",k,facet\n\t\tcovector = COVECTOR([V[v] for v in facet])\n\t\tseedsOnFacet = VC[facet[0]] \n\t\t# seedsOnFacet = list(set(CAT([VC[h] for h in facet])))\n\t\tcellsToSplit = []\n\t\tfor cell in seedsOnFacet:\n\t\t\tcellsToSplit += [dividenda(V,CV, cell,facet,covector,[])]\n\t\t\t\t\n\t\tcellsToSplit = set(CAT(cellsToSplit))\t\t\n\t\tif cellsToSplit == set(): cellsToSplit=set(seedsOnFacet) ## NB !!!  BUG !!!!\n\t\twhile True:\n\t\t\tnewCells = [dividenda(V,CV, cell,facet,covector,cellsToSplit) \n\t\t\t\t\t\t\tfor cell in cellsToSplit ]\n\t\t\tif newCells != []: newCells = CAT(newCells)\n\t\t\tcovering = cellsToSplit.union(newCells)\n\t\t\tif covering == cellsToSplit: \n\t\t\t\tbreak\n\t\t\tcellsToSplit = covering\n\t\t\t\n\t\tboundaryCellCovering += [list(covering)]\t\n\n\tif TRACE: tracing = mytrace(tracing,\"<boundaryCover\")-1\n\treturn boundaryCellCovering\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Cell-facet intersection test}\n\n%-------------------------------------------------------------------------------\n@D Cell-facet intersection test\n@{\"\"\" Cell-facet intersection test \"\"\"\ndef cellFacetIntersecting(boundaryFacet,cell,covector,V,CV):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">cellFacetIntersecting\")\n\n\tpoints = [V[v] for v in CV[cell]]\n\tvcell1,newFacet,vcell2 = SPLITCELL(covector,points,tolerance=1e-3,ntry=4)\n\tboundaryFacet = [V[v] for v in boundaryFacet]\n\ttranslVector = boundaryFacet[0]\n\t\n\t# translation \n\tnewFacet = [ VECTDIFF([v,translVector]) for v in newFacet ]\n\tboundaryFacet = [ VECTDIFF([v,translVector]) for v in boundaryFacet ]\n\t\n\t# linear transformation: boundaryFacet -> standard (d-1)-simplex\n\td = len(V[0])\n\ttransformMat = mat( boundaryFacet[1:d] + [covector[1:]] ).T.I\n\t\n\t# transformation in the subspace x_d = 0\n\tnewFacet = (transformMat * (mat(newFacet).T)).T.tolist()\n\tboundaryFacet = (transformMat * (mat(boundaryFacet).T)).T.tolist()\n\t\n\t# projection in E^{d-1} space and Boolean test\n\tnewFacet = MKPOL([ AA(lambda v: v[:-1])(newFacet), \n\t\t\t\t\t\t\t[range(1,len(newFacet)+1)], None ])\n\tboundaryFacet = MKPOL([ AA(lambda v: v[:-1])(boundaryFacet), \n\t\t\t\t\t\t\t[range(1,len(boundaryFacet)+1)], None ])\n\tverts,cells,pols = UKPOL(INTERSECTION([newFacet,boundaryFacet]))\n\t\n\n\tif verts == []: \n\t\tif TRACE: tracing = mytrace(tracing,\"<cellFacetIntersecting\")-1\n\t\treturn False\n\telse: \n\t\tif TRACE: tracing = mytrace(tracing,\"<cellFacetIntersecting\")-1\n\t\treturn True\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\n\n\n\n%-------------------------------------------------------------------------------\n\\section{Step 3: cell labeling}\n%-------------------------------------------------------------------------------\n\nThe goal of this stage is to label every cell of the SCDC with two bits, corresponding to the input spaces $A$ and $B$, and telling whether the cell is either internal (1) or external (0) to either spaces.\n\n\\subsection{Requirements}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Input}\nThe output of previous algorithmic stage.\n\n\\paragraph{Output}\nThe array \\texttt{cellLabels} with \\emph{shape} $\\texttt{len(PW)}\\times 2$, and values in $\\{0,1\\}$.\n\n\n\\subsection{Implementation}\n%-------------------------------------------------------------------------------\n\nThe labelling of LAR of the SCDC may be decomposed in five consecutive steps. The first step was actually executed during the splitting stage, by accumulating a single facet of every split cells embedded on the affine hull (the covector hyperplane) of the splitting boundary \\texttt{facet}. The second  step provides the computation of the sparse matrix of the linear coboundary operator $\\delta_{d-1}: C_{d-1} \\to C_d$.\nThe third step operates upon the previous two pieces of information, in order to compute the coboundary chain of the boundary chain of both input Boolean arguments.\nThe fourth step attaches a \\textsc{in/out} label to each $d$-cell of the previously computed $d$-chain.\nFinally, the fifth step spreads around the labels to cover all the $d$-cells of SCDC. This knowledge allows for the computation of every interesting Boolean expressions between the input complexes.\n\n\\subsubsection{Summary}\n\n%-------------------------------------------------------------------------------\n@D Third Boolean step\n@{\"\"\" Third Boolean step \"\"\"\ndef larBool3():\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool3\")\n\n\tcoBoundaryMat = signedCellularBoundary(W,bases).T\n\tboundaryMat = coBoundaryMat.T\n\tCWbits = [[-1,-1] for k in range(len(CW))]\n\tCWbits = cellTagging(boundary1,boundaryMat,CW,FW,W,BCW,CWbits,0)\n\tCWbits = cellTagging(larUnsignedBoundary2,boundaryMat,CW,FW,W,BCW,CWbits,1)\n\tfor cell in range(len(CW)):\n\t\tif CWbits[cell][0] == 1:\n\t\t\tCWbits = booleanChainTraverse(0,cell,W,CW,CWbits,1)\t\t\n\t\tif CWbits[cell][0] == 0:\n\t\t\tCWbits = booleanChainTraverse(0,cell,W,CW,CWbits,0)\n\t\tif CWbits[cell][1] == 1:\n\t\t\tCWbits = booleanChainTraverse(1,cell,W,CW,CWbits,1)\n\t\tif CWbits[cell][1] == 0:\n\t\t\tCWbits = booleanChainTraverse(1,cell,W,CW,CWbits,0)\n\tchain1,chain2 = TRANS(CWbits)\n\t\n\tchain = [k for k,cell in enumerate(chain1) if cell==1]\n\t_,bound1 = chain2complex(W,CW,chain,boundaryMat)\n\t\n\tchain = [k for k,cell in enumerate(chain2) if cell==1]\n\t_,bound2 = chain2complex(W,CW,chain,boundaryMat)\n\t\n\n\tif TRACE: tracing = mytrace(tracing,\"<larBool3\")-1\n\treturn W,CW,FW,boundaryMat,bound1,bound2,chain1,chain2,CWbits\n@}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Detail functions}\n\n\n\n\\paragraph{Computation of boundary cells embedded in SCDC}\n\n%-------------------------------------------------------------------------------\n@D Computation of embedded boundary cells\n@{\"\"\" Computation of embedded boundary cells \"\"\"\ndef facetsOnCuts(cellFragments,cellCuts,V,BC):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">facetsOnCuts\")\n\n\n\n\tpass\n\n\tif TRACE: tracing = mytrace(tracing,\"<facetsOnCuts\")-1\n\treturn #facets\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Coboundary operator on SCDC space decomposition}\n\nIn this section we develop a stronger characterisation of the boundaries, by fully tagging in SCDC the internal coboundary of boundaries of $A$ and $B$ Boolean arguments. This novel strategy should allow the recursive tagging extension to work correctly in all cases.\n\nAs we know, the  coboundary operators $\\delta_{k-1}: C_{k-1} \\to C_k$ are the transpose of the boundary operators $\\partial_k: C_k \\to C_{k-1}$ ($1\\leq k\\leq d$). We therefore proceed to the construction of the operator $\\delta_{d-1}$, according to the procedure illustrated in~\\cite{}. For this purpose we need to use both the $C_d$ and the $C_{d-1}$ bases of SCDC. The first basis is generated as \\texttt{CV} array during the splitting. The second basis will be built from $C_d$ using the proper $d$-adjacency algorithm from~\\cite{}. \n\nLet us remember that a (co)boundary operator may be applied to \\emph{any} chain from the linear space of chains defined upon a cellular complex. \nIn our case we have already generated the $(d-1)$-chains $\\partial A$ and $\\partial B$ while building the SCDC, by accumulating, in the course of the splitting phase, the $(d-1)$-facets discovered while tracking the boundaries of $A$ and $B$. We just need now to tag (a subset of) $\\delta_{d-1}\\partial_d A$ and $\\delta_{d-1}\\partial_d B$.\n\n\n\\paragraph{Computation of facets of a connected polytopal LAR model}\n\nThe $(d-1)$-facets of a $d$-dimensional \\emph{polytopal and convex} LAR model are computed by the below \\texttt{convexFacets} function by using both the algorithm codified by the function \\texttt{larFacets} for the facets \\emph{internal} to the complex, \\emph{and} the \\texttt{convexBoundary} algorithm for the facets on the convex boundary of the complex.\n\nConversely, the \\texttt{larConvexFacets} function can be used to compute the $(d-1)$-facets of a possibly \\emph{non-connected and/or non-convex} polytopal complex.\n\n%-------------------------------------------------------------------------------\n@D Coboundary operator on the convex decomposition of common space\n@{\"\"\" Coboundary operator on the convex decomposition of common space \"\"\"\nfrom scipy.spatial import ConvexHull\n\ndef qhullBoundary(V):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">qhullBoundary\")\n\n\tpoints = array(V)\n\thull = ConvexHull(points)\n\tout = hull.simplices.tolist()\n\n\tif TRACE: tracing = mytrace(tracing,\"<qhullBoundary\")-1\n\treturn sorted(out)\n\ndef facetDimensionTest(V,facet,covector):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">facetDimensionTest\")\n\n\tcovector = eval(covector)\n\n\tif TRACE: tracing = mytrace(tracing,\"<facetDimensionTest\")-1\n\treturn all([ -0.01 < INNERPROD([[1.]+W[v],covector]) < 0.01 for v in facet ])\n\ndef convexFacets (V,CV,dim=2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">convexFacets\")\n\n\tdim = len(V[0])\n\tmodel = V,CV\n\tV,FV = larFacets(model,dim)\t\n\tFV = AA(eval)(list(set(AA(str)(AA(sorted)(FV + convexBoundary(V,CV))) )))\n\n\tif TRACE: tracing = mytrace(tracing,\"<convexFacets\")-1\n\treturn FV\n\ndef larConvexFacets (V,CV,dim=2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larConvexFacets\")\n\n\tFV = []\n\tfor cell in CV: \n\t\tfv = convexFacets([V[v] for v in cell],[range(len(cell))],dim)\n\t\tFV += [tuple([cell[v] for v in facet]) for facet in fv]\n\n\tif TRACE: tracing = mytrace(tracing,\"<larConvexFacets\")-1\n\treturn sorted(AA(list)(set(FV)))\n\t\nif __name__ == \"__main__\":\n\tV = [[0,0],[1,0],[1,1],[0.5,1],[0,1]]\n\tCV = [[0,1,2,3,4]]\n\tFV = convexFacets(V,CV)\n\t\nif __name__ == \"__main__\":\n\tV,CV = larCuboids((10,10,10))\n\tFV = convexFacets(V,CV,2)\n\t#EV = convexFacets(V,FV,1)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Computation of boundary operator}\n\nThe computation of the boundary operator $\\partial_d$ on the SCDC $d$-basis \\texttt{(W,CW)} requires the knowledge of the $(d-1)$-basis \\texttt{(W,FW)}. The goal of this section is hence the---partially incremental---computation of \\texttt{FW}. This set can be partitioned into \\emph{internal} cells, that have 2 cofaces, and \\emph{boundary} cells, that have only 1 coface. The first subset is easily computed by the \\texttt{larFacets} function; the computation of the second subset requires some more work, specified in the following.\n\nFirst, we compute the 0-chain of boundary vertices of the SCDC, using \\emph{qHull}, and take advantage of the \\texttt{CV} matrix to extract the chain of $d$-cells sharing with the boundary a $(d-1)$facet. Second, using the \\emph{partial} boundary operator generated by using only the interior $(d-1)$-facets, and the associated $(d-2)$-boundary operator, we select the sub-chain made by the non-closed $d$-cells of this subset. Third, the boundary facet of each of them is finally selected, added to the $(d-1)$-basis of SCDC, and the corresponding row is added at the bottom line of the matrix of $\\partial_{d-1}$.\n\n%-------------------------------------------------------------------------------\n@D Computation of boundary operator of a convex LAR model\n@{\"\"\" Computation of boundary operator of a convex LAR model\"\"\"\ndef convexBoundary(V,CV): \n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">convexBoundary\")\n\thull = ConvexHull(array(V), qhull_options=\"Qc\")\n\tboundaryEquations = list(set(AA(tuple)(hull.equations.tolist())))\n\t\n\tcoplanarVerts = hull.coplanar.tolist()\n\tif coplanarVerts != []:  coplanarVerts = CAT(coplanarVerts)\n\tboundaryVerts = set( CAT(qhullBoundary(V)) + coplanarVerts )\n\t\n\tdim, boundaryFacets = len(V[0]), []\n\tsplitFacets = [[] for k in range(len(boundaryEquations))]\n\tfor cell in CV:\n\t\tfacet = list(boundaryVerts.intersection(cell))\n\t\tif len(facet) >= dim:\n\t\t\tcovector = COVECTOR([V[v] for v in facet])\n\t\t\tif all([ -0.01 < INNERPROD([ [1.]+V[v], covector ]) < 0.01 for v in facet ]):\n\t\t\t\tboundaryFacets += [ facet ]\n\t\t\telse:\n\t\t\t\tsplitFacets = [[] for k in range(len(boundaryEquations))]\n\t\t\t\tfor v in facet:\n\t\t\t\t\tfor k,equation in enumerate(boundaryEquations):\n\t\t\t\t\t\tif -0.01 < INNERPROD([ V[v]+[1.], equation ]) < 0.01:\n\t\t\t\t\t\t\tsplitFacets[k] += [v]\n\t\t\tboundaryFacets += [f for f in splitFacets if f != [] and len(f)>=dim ]\n\n\tif TRACE: tracing = mytrace(tracing,\"<convexBoundary\")-1\n\treturn boundaryFacets\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Coboundary of boundary chains}\n\n%-------------------------------------------------------------------------------\n@D Coboundary of boundary chain\n@{\"\"\" Coboundary of boundary chain \"\"\"\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Labeling seeds}\n\n%-------------------------------------------------------------------------------\n@D Writing labelling seeds on SCDC\n@{\"\"\" Writing labelling seeds on SCDC \"\"\"\ndef cellTagging(boundaryDict,boundaryMat,CW,FW,W,BC,CWbits,arg):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">cellTagging\")\n\n\tdim = len(W[0])\n\tfor face in boundaryDict:\n\t\tfor facet in boundaryDict[face]:\n\t\t\tcofaces = list(boundaryMat[facet].tocoo().col)\n\t\t\tif len(cofaces) == 1: \n\t\t\t\tCWbits[cofaces[0]][arg] = 1\n\t\t\telif len(cofaces) == 2:\n\t\t\t\tv0 = list(set(CW[cofaces[0]]).difference(FW[facet]))[0]\n\t\t\t\tv1 = list(set(CW[cofaces[1]]).difference(FW[facet]))[0]\n\t\t\t\t# take d affinely independent vertices in face (TODO: use pivotSimplices() \n\t\t\t\tsimplex0 = BC[face][:dim] + [v0]\n\t\t\t\tsimplex1 = BC[face][:dim] + [v1]\n\t\t\t\tsign0 = sign(det([W[v]+[1] for v in simplex0]))\n\t\t\t\tsign1 = sign(det([W[v]+[1] for v in simplex1]))\n\t\t\t\t\n\t\t\t\tif sign0 == 1: CWbits[cofaces[0]][arg] = 1\n\t\t\t\telif sign0 == -1: CWbits[cofaces[0]][arg] = 0\n\t\t\t\tif sign1 == 1: CWbits[cofaces[1]][arg] = 1\n\t\t\t\telif sign1 == -1: CWbits[cofaces[1]][arg] = 0\n\t\t\telse: \n\t\t\t\tprint \"error: too many cofaces of boundary facets\"\n\n\tif TRACE: tracing = mytrace(tracing,\"<cellTagging\")-1\n\treturn CWbits\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Recursive diffusion of labels}\nA recursive function \\texttt{booleanChainTraverse} is given in the script below, where \n\n%-------------------------------------------------------------------------------\n@D Recursive diffusion of labels on SCDC\n@{\"\"\" Recursive diffusion of labels on SCDC \"\"\"\ndef booleanChainTraverse(h,cell,V,CV,CWbits,value):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">booleanChainTraverse\")\n\n\tadjCells = adjacencyQuery(V,CV)(cell)\n\tfor adjCell in adjCells: \n\t\tif CWbits[adjCell][h] == -1:\n\t\t\tCWbits[adjCell][h] = value\n\t\t\tCWbits = booleanChainTraverse(h,adjCell,V,CV,CWbits,value)\n\n\tif TRACE: tracing = mytrace(tracing,\"<booleanChainTraverse\")-1\n\treturn CWbits\n@}\n%-------------------------------------------------------------------------------\n\n\n\n%-------------------------------------------------------------------------------\n\\section{Step 4: greedy cell gathering}\n%-------------------------------------------------------------------------------\n\nThe goal of this stage is to make as lower as possible the number of cells in the  output LAR of the space $AB$, partitioned into convex cells.\n\n\\paragraph{Input}\nThe LAR model \\texttt{(W,PW)} of the SCDC and the array \\texttt{cellLabels}.\n\n\\paragraph{Output}\nThe LAR representation \\texttt{(W,RW)} of the final fragmented and labeled space $AB$.\n\n\n\\subsection{Requirements}\n%-------------------------------------------------------------------------------\n\nThe algorithm proposed here for $d$-cell gathering into bigger polytopes is local and greedy. Starting from an initial random $d$-cell, a $(d-1)$-connected $d$-chain is built, by attaching, one at a time, single cells to the boundary of the chain, after (local) verification that the support of the new chain will remain a convex set. \n\nIn case of failure of the test, the facets of the current chain boundary are checked for the gluing of their adjacent and external $d$-coface, until either a new convex is built, or no single cell can be attached convexly, so that the attachment process relative to that chain stops, and its boundary vertices are written in the LAR of a new complex, to gather a single new polytope generated by them. \n\nActually, during the stage of boundary checking for finding a new cocell to glue, only a subchain is checked, obtained by subtraction from the boundary of the cutting facets, where attachments are not possible, without\nviolating the topology of Boolean results. \n\nTwo main algorithm components are needed here. The first one concerns the extraction of the current $d$-chain boundary, the subtraction from it of the splitting facets, and the selection of the facet where to glue another $d$-cell; the second one deals with the convexity test of the candidate (chain $+$ boundary cocell) pair.\n\nThe local convexity test will extract, using the (co)boundary matrix of the current chain, the coboundary of the boundary of the candidate facet, and, selected the matrix of hyperplanes associated to it, will compute the centroid of the facet and the vector of signs exposed by the point transformed by right product with this matrix. The local test of convexity is satisfied if and only if all new vertices expose the same signs (or zero), when transformed by this matrix. In other words, the test is satisfied  if all new vertices remain internal (or non external) to the cone generated by such set of boundary hyperplanes.\n\nEvery time that a new cell has been selected to join the current chain, the cell is also signed as already used, and hence as no more available for other choices. Of course, the algorithm terminates when all the input  $d$-cells have been selected and signed.\n\n\n\\subsection{Implementation}\n%-------------------------------------------------------------------------------\nA synthetic view of the simplification process is given by the script below.\nThe first tool provides a mapping from $(d-1)$-facets of SCDC to their embedding hyperplanes, i.e. to their affine hulls of codimension 1. The second one compute the boundary $(d-1)$-complex of the SCDC $d$-chain currently transformed into a single convex cell. The algorithmic bulk of the simplification process is contained in the script entitled \\texttt{Sticking cells together}. The last script provides the high-level interface to transform the generated SCDC into a strongly simplified polytopal complex.\n\n\\paragraph{High-level description}\n\n%-------------------------------------------------------------------------------\n@D Simplification of the output polytopal complex\n@{@< Mapping from facets to hyperplanes @>\n@< Building the boundary complex of the current chain @>\n@< Sticking cells together @>\n@< Gathering and writing a polytopal complex @>\n@}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Summary}\n\n\n%-------------------------------------------------------------------------------\n@D Fourth Boolean step\n@{\"\"\" Fourth Boolean step \"\"\"\ndef larBool4(W,CW,FW,boundaryMat,boundary1,larUnsignedBoundary2,CWbits):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool4\")\n\n\tX,CX,CXbits = gatherPolytopes(W,CW,FW,boundaryMat,boundary1,larUnsignedBoundary2,CWbits)\n\tFX = larConvexFacets (X,CX)\n\n\tif TRACE: tracing = mytrace(tracing,\"<larBool4\")-1\n\treturn X,CX,FX,CXbits\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsubsection{Detail functions}\n\n\n\n\n\\paragraph{Mapping from facets to hyperplanes}\n\nThe function \\texttt{facet2covectors} if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nThe function \\texttt{facet2covectors} return the list of hyperplane covectors, with first term homogeneous, i.e.~the row vector $(c,a,b)$ for the line equation $ax+by+c=0$, or the row vector $(d,a,b,c)$ for the plane equation $ax+by+cz+d=0$.\n%-------------------------------------------------------------------------------\n@D Mapping from facets to hyperplanes\n@{\"\"\" Mapping from hyperplanes to lists of facets \"\"\"\ndef facet2covectors(W,FW):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">facet2covectors\")\n\tif TRACE: tracing = mytrace(tracing,\"<facet2covectors\")-1\n\treturn [COVECTOR([W[v] for v in facet]) for facet in FW]\n\ndef boundaries(boundary1,larUnsignedBoundary2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">boundaries\")\n\n\t#if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\n\t#return set(CAT(boundary1.values() + larUnsignedBoundary2.values()))\n\n\tif TRACE: tracing = mytrace(tracing,\"<boundaries\")-1\n\treturn boundary1.union(larUnsignedBoundary2)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Building the complex of the current chain}\n\nThe function \\texttt{chain2complex} if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nThe function \\texttt{chain2complex} returns the boundary complex of the current \\texttt{chain}, minus the facet in \\texttt{constraints}, where non $d$-cell may be attached to the current \\texttt{chain}.\nIt is computed via multiplication between the matrix of boundary operator and the coordinate representation \\texttt{chainCoords} of \\texttt{chain}. The \\texttt{constraint} set is finally subtracted to the result.  \n\n%-------------------------------------------------------------------------------\n@D Building the boundary complex of the current chain\n@{from scipy.sparse import csc_matrix\n\"\"\" Building the boundary complex of the current chain \"\"\"\ndef chain2complex(W,CW,chain,boundaryMat,constraints=[]):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">chain2complex\")\n\n\tchainCoords = csc_matrix((len(CW), 1))\n\tfor cell in chain: chainCoords[cell] = 1\n\tboundaryCells = set((boundaryMat * chainCoords).tocoo().row)\n\tenvelope = boundaryCells.difference(constraints)\n\n\tif TRACE: tracing = mytrace(tracing,\"<chain2complex\")-1\n\treturn envelope,boundaryCells\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Sticking cells together}\n%-------------------------------------------------------------------------------\n@D Sticking cells together\n@{\"\"\" Sticking cells together \"\"\"\n@< Testing the convexity of a single added vertex @>\n@< Testing the convexity when attaching a cell to a chain @>\n@< Elongate a chain while supports a convex set @>\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Testing the convexity of a single added vertex}\nA single cell is possibly attached to the boundary envelope of the current \\texttt{chain}. In case of success\n\nthe function \\texttt{protrudeChain} if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\nthe function \\texttt{protrudeChain} return\ns \\texttt{True}; otherwise if TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\ns \\texttt{True}; otherwise returns \\texttt{False}. \n%-------------------------------------------------------------------------------\n@D Testing the convexity of a single added vertex\n@{\"\"\" Testing the convexity of a single added vertex \"\"\"\ndef pairing(v,w):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">pairing\")\n\n\tvalue = PROD([v,w])\n\n\tif -0.01 < value < 0.01: \n\t\tif TRACE: tracing = mytrace(tracing,\"<aaaa\")-1\n\t\treturn 0\n\telse: \n\t\tif TRACE: tracing = mytrace(tracing,\"<pairing\")-1\n\t\treturn SIGN(value)\n\ndef convexTest(theSigns,vertex,theCone):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">convexTest\")\n\n\tsigns = [ pairing( [1]+vertex,covector ) for covector in theCone]\n\n\tif TRACE: tracing = mytrace(tracing,\"<convexTest\")-1\n\treturn all([theSign*sign >= 0 for (theSign,sign) in zip(theSigns,signs)])\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Testing the convexity of current chain}\n%-------------------------------------------------------------------------------\n@D Testing the convexity when attaching a cell to a chain\n@{\"\"\" Testing the convexity when attaching a cell to a chain \"\"\"\ndef testAttachment(cell,usedCells,theFacet,chain,\n\t\t\t\t\tW,CW,FW,boundaryMat,boundaryCells,covectors):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">testAttachment\")\n\t\n\ttheFacetVerts = set(FW[theFacet])\n\tflag = False\n\tfacetRing = [facet for facet in boundaryCells if facet!=theFacet and \\\n\t\t\t\t len(theFacetVerts.intersection(FW[facet])) >= len(W[0])-1]\n\ttheCone = [covectors[f] for f in facetRing]\n\ttheFacetPivot = CCOMB([W[v] for v in FW[theFacet]])\n\ttheSigns = [ pairing( [1]+theFacetPivot, covector ) for covector in theCone ]\n\tif not any([sign==0 for sign in theSigns]):\n\t\ttestingSet = set(CW[cell]).difference(theFacetVerts)\n\t\tflag = all([ convexTest(theSigns,W[vertex],theCone) for vertex in testingSet])\n\n\tif TRACE: tracing = mytrace(tracing,\"<testAttachment\")-1\n\treturn flag\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Chain elongation while is convex}\n\n%-------------------------------------------------------------------------------\n@D Elongate a chain while supports a convex set\n@{\"\"\" Elongate a chain while supports a convex set \"\"\"\ndef protrudeChain (W,CW,FW,chain,boundaryMat,covectors,usedCells,constraints):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">protrudeChain\")\n\n\tverts = []\n\twhile True:\t\n\t\tchanged = False\n\t\tenvelope,boundaryFacets = chain2complex(W,CW,chain,boundaryMat,constraints)\n\t\tfor facet in envelope:\n\t\t\tsuccess = False\n\t\t\tchainCoords = csr_matrix((1,len(FW)))\n\t\t\tchainCoords[0,facet] = 1\n\t\t\tcocells = list((chainCoords * boundaryMat).tocoo().col)\n\t\t\t\n\t\t\tif len(cocells)==2:\n\t\t\t\tif cocells[0] in chain: cell = cocells[1]\n\t\t\t\telif cocells[1] in chain: cell = cocells[0]\n\t\t\t\tif not usedCells[cell]:\n\t\t\t\t\tsuccess = testAttachment(cell,usedCells,facet,chain, \\\n\t\t\t\t\t\t\t\tW,CW,FW,boundaryMat,boundaryFacets,covectors)\n\t\t\t\tif success: \n\t\t\t\t\tchanged = True\n\t\t\t\t\tusedCells[cell] = True\n\t\t\t\t\tchain += [cell]\n\t\t\telse: print \"error: in protrudeChain (len(cocells) not equal to 2)\"\n\t\t\tchainCoords = csc_matrix((len(CW),1))\n\t\t\tfor cell in chain: \n\t\t\t\tchainCoords[cell,0] = 1\n\t\t\t\tusedCells[cell] = True\n\t\t\tboundaryFacets = list((boundaryMat*chainCoords).tocoo().row)\n\t\tif not changed: break\t\t\n\t\t\t\n\tverts = [FW[facet] for facet in boundaryFacets]\n\tverts = sorted(list(set(CAT(verts))))\n\n\tif TRACE: tracing = mytrace(tracing,\"<protrudeChain\")-1\n\treturn verts,usedCells\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Gathering and writing a polytopal complex}\n\nThe task of the \\texttt{gatherPolytopes} function, given below, is to return the LAR \\texttt{(X,CX)} of the SCDC \\texttt{(W,CW)} generated by the previous phases of the Boolean algorithm, after reducing its representation to a much smaller size, (a) by gathering subsets of cells into single bigger polytopal cells within the characteristic matrix \\texttt{CX}, and (b) by assembling their boundary vertices into the (reduced) vertex set \\texttt{X}. Of course, while reducing the number of polytopal cells, the procedure should not change the Boolean structure of the input complex, i.e. the support spaces $|C_A|, |C_B|$ of proper chains $C_A$ and $C_B$ and of their Boolean combinations.\n\n%-------------------------------------------------------------------------------\n@D Gathering and writing a polytopal complex\n@{\"\"\" Gathering and writing a polytopal complex \"\"\"\ndef gatherPolytopes(W,CW,FW,boundaryMat,bounds1,bounds2,CWbits):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">gatherPolytopes\")\n\n\tusedCells = [False for cell in CW]\n\tcovectors = facet2covectors(W,FW)\n\tconstraints = boundaries(bounds1,bounds2)\n\tXdict,index,CX,defaultValue,CXbits = dict(),0,[],-1,[]\n\twhile not all(usedCells):\n\t\tfor k,cell in enumerate(CW):\n\t\t\tif not usedCells[k]:\n\t\t\t\tchain = [k]\n\t\t\t\tusedCells[k] = True\n\t\t\t\tverts,usedCells = protrudeChain(W,CW,FW,chain,boundaryMat,\n\t\t\t\t\t\t\t\t\tcovectors,usedCells,constraints)\n\t\t\t\tCX += [ verts ]\n\t\t\t\tCXbits += [ CWbits[k] ]\n\t\t\t\t\n\tX,CX = larRemoveVertices(W,CX)\n\n\tif TRACE: tracing = mytrace(tracing,\"<gatherPolytopes\")-1\n\treturn X,CX,CXbits\n@}\n%-------------------------------------------------------------------------------\n\n\\subsubsection{Final removal of redundant vertices}\n\nAfter the simplification step, that replaces two or more convex $d$-cells with a single one cell,\nand the subsequent computation of the facets of the new cells, some vertices may become redundant,\nsince are not intersection of at least $d$ affine hulls supporting the $(d-1)$-facets.\n\n\\paragraph{Removal of redundant vertices from simplified LAR model}\n\nThe input to the function \\texttt{larVertexRemoval} is the triple \\texttt{X}, \\texttt{CX}, \\texttt{FX} of vertices, cells-by-vertices, and facets-by-vertices, where some of vertices may be redundant.\nTherefore, for each vertex, we compute the subset of incident facets, and then the subset of supporting covectors, i.e. the affine functions defining their affine hulls. If their number is greater or equal to the dimension of the embedding space, i.e.~to the number of coordinates of vertices,  then the vertex is non-redundant, and cannot be eliminated from the LAR model. If the vertex $k$ is redundant, the corresponding value \\texttt{X[k]} is substituted by the empty list. At the very end a rewriting vertex dictionary is generated and used to produce the novel output \\texttt{V}, \\texttt{CV}, and \\texttt{FV}.\nLet us notice that the array \\texttt{affineHullNumber} represents, for each vertex, the number of incident affine hulls. Hence, when \\texttt{affineHullNumber[k]} is less that \\texttt{dim}, the vertex \\texttt{X[k]} is redundant, and can be eliminated.\n\n\n%-------------------------------------------------------------------------------\n@D Removal of redundant vertices from simplified LAR model\n@{\"\"\" Removal of redundant vertices from simplified LAR model \"\"\"\ndef facetCovectors(X,FX):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">facetCovectors\")\n\n\tcovectors = defaultdict(list) \n\tfor k,facet in enumerate(FX):\n\t\tcovect = list(COVECTOR([X[v] for v in facet]))\n\t\tnormalizedCovect = UNITVECT([ h*SIGN(covect[0])  for h in covect])\n\t\tfor h,comp in enumerate(normalizedCovect): \n\t\t\tif not isclose(0.0, comp): \n\t\t\t\ttheSign = SIGN(comp)\n\t\t\t\tbreak\n\t\tnormalizedCovect = [x*theSign  if x!=abs(0.0) else x for x in normalizedCovect]\n\t\tcovectors[vcode(4)(normalizedCovect)] += [k]\n\n\tif TRACE: tracing = mytrace(tracing,\"<facetCovectors\")-1\n\treturn covectors\n\ndef larVertexRemoval(X,CX,FX):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larVertexRemoval\")\n\n\tdim = len(X[0])\n\tcovectors = facetCovectors(X,FX)\n\tCovectF = covectors.values()\n\tFCovect = invertRelation(CovectF)\n\tXF = invertRelation(FX)\n\taffineHullNumber = [len([FCovect[face] for face in vertFaces]) for vertFaces in XF]\n\tY = [X[k] if val>=dim else [] for k,val in enumerate(affineHullNumber)]\n\tnewIndex, Z = 0, dict()\n\tfor oldIndex, vertex in enumerate(Y):\n\t\tif vertex != []:\n\t\t\tZ[oldIndex] = newIndex  # (old,new) vertex indices\n\t\t\tnewIndex += 1\n\tV = [None for k in range(len(Z))]\n\tfor old,new in Z.items():\n\t\tV[new] = X[old]\n\tFV = [[Z[v] for v in facet if v in Z] for facet in FX]\n\tCV = [[Z[v] for v in cell if v in Z] for cell in CX]\n\n\tif TRACE: tracing = mytrace(tracing,\"<larVertexRemoval\")-1\n\treturn V,CV,FV\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Remove double instances of cells}\n\n%-------------------------------------------------------------------------------\n@O test/py/larstruct/test10.py\n@{\"\"\" Remove double instances of cells (and the unused vertices) \"\"\"\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom larcc import *\nfrom mapper import evalStruct\n\n@< Transform Struct object to LAR model pair @>\n@< Remove the double instances of cells @>\nVIEW(EXPLODE(1.2,1.2,1.2)(MKPOLS((W,FW))))\n\n@< Remove the unused vertices @>\n@}\n%-------------------------------------------------------------------------------\n\nThe actual removal of double cells (useful in several applications, and in particular in the extraction of boundary models from 3D medical images) is performed by first generating a dictionary of cells, using as key the tuple given by the cells themselves, and then removing those discovered having a double instance.\nThe algorithm is extremely simple, and its implementation, given below, is straightforward.\n\n%-------------------------------------------------------------------------------\n@D Remove the double instances of cells\n@{\"\"\" Remove the double instances of cells \"\"\"\ncellDict = defaultdict(list)\nfor k,cell in enumerate(FW):\n    cellDict[tuple(cell)] += [k]\nFW = [list(key) for key in cellDict.keys() if len(cellDict[key])==1]\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@D Remove the unused vertices\n@{\"\"\" Remove the unused vertices \"\"\"\nprint \"len(W) =\",len(W)\nV,FV = larRemoveVertices(W,FW)\nprint \"len(V) =\",len(V)\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@D Remove the unused vertices from a LAR model pair\n@{\"\"\" Remove the unused vertices \"\"\"\ndef larRemoveVertices(V,FV):\n    vertDict = dict()\n    index,defaultValue,FW,W = -1,-1,[],[]\n        \n    for k,incell in enumerate(FV):\n        outcell = []\n        for v in incell:\n            key = vcode(4)(V[v])\n            if vertDict.get(key,defaultValue) == defaultValue:\n                index += 1\n                vertDict[key] = index\n                outcell += [index]\n                W += [eval(key)]\n            else: \n                outcell += [vertDict[key]]\n        FW += [outcell]\n    return W,FW\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\section{The main Boolean procedure}\n%-------------------------------------------------------------------------------\n\n\\subsection{Goal: generating the Boolean complex}\n\n\n\\subsection{Implementation}\n\n\n%-------------------------------------------------------------------------------\n@D Boolean Algorithm\n@{\"\"\" Boolean Algorithm \"\"\"\ndef larBool(arg1,arg2, brep=False):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool\")\n\n\tV1,basis1 = arg1\n\tV2,basis2 = arg2\n\tcells1 = basis1[-1]\n\tcells2 = basis2[-1]\n\tmodel1,model2 = (V1,cells1),(V2,cells2)\n\t\t\n\t@< First Boolean step @>\n\tW,CW,VC,BCellCovering,cellCuts,boundary1,larUnsignedBoundary2,BCW = larBool1()\n\tVIEW(EXPLODE(1.2,1.2,1.2)(MKPOLS((W,CW))))\n\t\n\t@< Second Boolean step @>\n\tW,CW,dim,bases,boundary1,larUnsignedBoundary2,FW,BCW = larBool2(boundary1,larUnsignedBoundary2)\n\n\t@< Third Boolean step @>\n\tV,CV,FV,boundaryMat,boundary1,larUnsignedBoundary2,chain1,chain2,CWbits = larBool3()\n\t\n\tsubmodel = SKEL_1(STRUCT(MKPOLS((V,CV))))\n\tVV = AA(LIST)(range(len(V)))\n\t\n\tif DEBUG:\n\t\tVIEW(larModelNumbering(1,1,1)(V,[VV,FV,CV],submodel,1))\n\t\tVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,[cell for k,cell in enumerate(CV) if sum(CWbits[k])==2]))))\n\t\n\t@< Fourth Boolean step @>\n\tW,CX,FX,CXbits = larBool4(V,CV,FV,boundaryMat,boundary1,larUnsignedBoundary2,CWbits)\n\n\tW,CX,FX = larVertexRemoval(W,CX,FX)\n\tchain1,chain2 = TRANS(CXbits)\n\t\n\tboundaryMat = larBoundary(CX,FX)\n\n\tdef theBoundary(boundaryMat,CX,coords):\n\t\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">theBoundary\")\n\n\t\tchainCoords = csc_matrix((len(CX), 1))\n\t\tfor cell in coords: chainCoords[cell,0] = 1\n\t\tboundaryCells = list((boundaryMat * chainCoords).tocoo().row)\n\t\torientations = list((boundaryMat * chainCoords).tocoo().data)\n\t\torientedBoundary = [ FX[face] for (sign,face) in zip(orientations,boundaryCells)  if sign == 1 ]\n\n\t\tif TRACE: tracing = mytrace(tracing,\"<theBoundary\")-1\n\t\treturn orientedBoundary\n\n\n\tdef larBool0(op):\n\t\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">larBool0\")\n\t\tif op == \"union\": \n\t\t\tucoords,uchain = TRANS([(k,cell) for k,(cell,c1,c2) in enumerate(zip(CX,chain1,chain2)) if c1+c2>=1])\n\n\t\t\tif TRACE: tracing = mytrace(tracing,\"<theBoundary\")-1\n\t\t\treturn W,CW,uchain,CX,FX,theBoundary(boundaryMat,CX,ucoords)\n\t\telif op == \"intersection\": \n\t\t\tdata = TRANS([(k,cell) for k,(cell,c1,c2) in enumerate(zip(CX,chain1,chain2)) if c1*c2==1])\n\t\t\tif data != []: \n\t\t\t\ticoords,ichain = data\n\n\t\t\t\tif TRACE: tracing = mytrace(tracing,\"<larBool0\")-1\n\t\t\t\treturn W,CW,ichain,CX,FX,theBoundary(boundaryMat,CX,icoords)\n\t\t\telse: \n\t\t\t\ticoords,ichain = [],[]\n\n\t\t\t\tif TRACE: tracing = mytrace(tracing,\"<larBool0\")-1\n\t\t\t\treturn W,CW,[],[],[],[]\n\t\telif op == \"xor\": \n\t\t\txcoords,xchain = TRANS([(k,cell) for k,(cell,c1,c2) in enumerate(zip(CX,chain1,chain2)) if c1+c2==1])\n\n\t\t\tif TRACE: tracing = mytrace(tracing,\"<larBool0\")-1\n\t\t\treturn W,CW,xchain,CX,FX,theBoundary(boundaryMat,CX,xcoords)\n\t\telif op == \"difference\": \n\t\t\tdata = TRANS([(k,cell) for k,(cell,c1,c2) in enumerate(zip(CX,chain1,chain2)) if c1==1 and c2==0])\n\t\t\tif data != []: \n\t\t\t\ticoords,ichain = data\n\n\t\t\t\tif TRACE: tracing = mytrace(tracing,\"<larBool0\")-1\n\t\t\t\treturn W,CW,ichain,CX,FX,theBoundary(boundaryMat,CX,icoords)\n\t\t\telse: \n\t\t\t\ticoords,ichain = [],[]\n\n\t\t\t\tif TRACE: tracing = mytrace(tracing,\"<larBool0\")-1\n\t\t\t\treturn W,CW,[],[],[],[]\n\t\telse: print \"Error: non implemented op\"\n\n\n\tif TRACE: tracing = mytrace(tracing,\"<larBool\")-1\n\treturn larBool0\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n\\section{LAR simplification}\n%-------------------------------------------------------------------------------\n\nOccasionally, we may need to simplify \n\n%-------------------------------------------------------------------------------\n\\section{Exporting the library}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O larlib/larlib/bool1.py\n@{\"\"\" Module for Boolean ops with LAR \"\"\"\n@< Initial import of modules @>\nfrom splitcell import *\nDEBUG = True\nTRACE,tracing = True,-1\n\n@< Symbolic utility to represent points as strings @>\n\n@< Merge two dictionaries with keys the point locations @>\n\n@< Make Common Delaunay Complex @>\n\n@< Cell-facet intersection test @>\n\n@< Elementary splitting test @>\n\n@< Computing the adjacent cells of a given cell @>\n\n@< Computation of boundary facets covering with CDC cells @>\n\n@< CDC cell splitting with one or more cutting facets @>\n\n@< Boolean argument boundaries embedding in SCDC @>\n\n@< Make facets dictionaries @>\n\n@< SCDC splitting with every boundary facet @>\n\n@< Characteristic matrix transposition @>\n\n@< Computation of embedded boundary cells @>\n\n@< Coboundary operator on the convex decomposition of common space @>\n\n@< Computation of boundary operator of a convex LAR model @>\n\n@< Writing labelling seeds on SCDC @>\n\n@< Recursive diffusion of labels on SCDC @>\n\n@< Mapping from facets to hyperplanes @>\n\n@< Simplification of the output polytopal complex @>\n\n@< Removal of redundant vertices from simplified LAR model @>\n\n@< Remove the unused vertices from a LAR model pair @>\n\n@< Boolean Algorithm @>\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n%-------------------------------------------------------------------------------\n\\section{Tests and examples}\n%-------------------------------------------------------------------------------\n\n\n\t\n%-------------------------------------------------------------------------------\n@D Debug via visualization\n@{\"\"\" Debug via visualization \"\"\"\n\nV1,(VV1,EV1,FV1) = arg1\nV2,(VV2,EV2,FV2) = arg2\nglass = MATERIAL([1,0,0,0.3,  0,1,0,0.3,  0,0,1,0.3, 0,0,0,0.3, 100])\n\nVIEW(STRUCT([\n\tglass(EXPLODE(1.1,1.1,1.1)(MKPOLS((V1,FV1)))),\n\tglass(EXPLODE(1.1,1.1,1.1)(MKPOLS((V2,FV2))))\n]))\n\nglass = MATERIAL([1,0,0,0.6,  0,1,0,0.6,  0,0,1,0.6, 0,0,0,0.6, 100])\n\nboolean = larBool(arg1,arg2)\t\n\nW,CW,chain,CX,FX,orientedBoundary = boolean(\"xor\")\nVIEW(glass(EXPLODE(1.2,1.2,1.2)(MKPOLS((W,chain)))))\n\nif DEBUG:\n\tVIEW(SKEL_1(EXPLODE(1.1,1.1,1.1)(MKPOLS((W,orientedBoundary)))))\n\t\n\tW,CW,chain,CX,FX,orientedBoundary = boolean(\"union\")\n\tVIEW(EXPLODE(1.1,1.1,1)(MKPOLS((W,chain))))\n\tVIEW(SKEL_1(EXPLODE(1.1,1.1,1.1)(MKPOLS((W,orientedBoundary)))))\n\t\n\tW,CW,chain,CX,FX,orientedBoundary = boolean(\"intersection\")\n\tif chain != []:\n\t\tVIEW(EXPLODE(1.1,1.1,1)(MKPOLS((W,chain))))\n\t\tVIEW(SKEL_1(EXPLODE(1.1,1.1,1.1)(MKPOLS((W,orientedBoundary)))))\n\t\n\tW,CW,chain,CX,FX,orientedBoundary = boolean(\"difference\")\n\tif chain != []:\n\t\tVIEW(EXPLODE(1.1,1.1,1)(MKPOLS((W,chain))))\n\t\tVIEW(SKEL_1(EXPLODE(1.1,1.1,1.1)(MKPOLS((W,orientedBoundary)))))\n\t\n\t\tVIEW(EXPLODE(1.1,1.1,1.1)(MKPOLS((W,CX))))\n\nsubmodel = SKEL_1(STRUCT(MKPOLS((W,FX))))\nVV = AA(LIST)(range(len(W)))\nVIEW(larModelNumbering(1,1,1)(W,[VV,FX,CX],submodel,1))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool11} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool12} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool13} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool14} \n   \\caption{2D example of file \\texttt{test/py/bool1/test1.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC.}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test0.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\n\"\"\" Definition of Boolean arguments \"\"\"\nn = 8\nmod_1 = AA(LIST)(range(n)), [[2*k,2*k+1] for k in range(n/2)]\nsquares1 = larModelProduct([mod_1,mod_1])\n\nmod_2 = AA(LIST)([0.5+k*2 for k in range(n/2)]),[[2*k,2*k+1] for k in range(n/4)]\nsquares2 = larModelProduct([mod_2,mod_2])\n\nV1 = squares1[0]\nV2 = squares2[0]\nVV1 = AA(LIST)(range(len(V1)))\nVV2 = AA(LIST)(range(len(V2)))\nEV1 = larConvexFacets (*squares1)\nEV2 = larConvexFacets (*squares2)\nFV1 = squares1[1]\nFV2 = squares2[1]\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test0b.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\n\"\"\" Definition of Boolean arguments \"\"\"\nn = 4\n\nmod_1 = AA(LIST)(range(n)), [[2*k,2*k+1] for k in range(n/2)]\nsquares1 = INSR(larModelProduct)([mod_1,mod_1,mod_1])\nV1 = squares1[0]\nVV1 = AA(LIST)(range(len(V1)))\nFV1 = larConvexFacets (squares1[0],squares1[1])\n_,EV1 = larFacets((V1,FV1),1)\nCV1 = squares1[1]\narg1 = V1,(VV1,EV1,FV1,CV1)\n\nmod_2 = AA(LIST)([0.5+k*2 for k in range(n/2)]),[[2*k,2*k+1] for k in range(n/4)]\nsquares2 = INSR(larModelProduct)([mod_2,mod_2,mod_2])\nV2 = squares2[0]\nVV2 = AA(LIST)(range(len(V2)))\nFV2 = larConvexFacets (squares2[0],squares2[1])\n_,EV2 = larFacets((V2,FV2),1)\nCV2 = squares2[1]\narg2 = V2,(VV2,EV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test0c.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nTRACE,tracing = True,-1\nfrom bool1 import *\n\n\"\"\" Definition of Boolean arguments \"\"\"\nn = 2\n\nmod_1 = AA(LIST)(range(n)), [[2*k,2*k+1] for k in range(n/2)]\nsquares1 = INSR(larModelProduct)([mod_1,mod_1,mod_1])\nV1 = squares1[0]\nVV1 = AA(LIST)(range(len(V1)))\nFV1 = larConvexFacets (squares1[0],squares1[1])\n_,EV1 = larFacets((V1,FV1),1)\nCV1 = squares1[1]\narg1 = V1,(VV1,EV1,FV1,CV1)\n\nn = 4\nmod_2 = AA(LIST)([0.5+k*2 for k in range(n/2)]),[[2*k,2*k+1] for k in range(n/4)]\nsquares2 = INSR(larModelProduct)([mod_2,mod_2,mod_2])\nV2 = squares2[0]\nVV2 = AA(LIST)(range(len(V2)))\nFV2 = larConvexFacets (squares2[0],squares2[1])\n_,EV2 = larFacets((V2,FV2),1)\nCV2 = squares2[1]\narg2 = V2,(VV2,EV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test1.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\n\"\"\" Definition of Boolean arguments \"\"\"\nV1 = [[3,0],[11,0],[13,10],[10,11],[8,11],[6,11],[4,11],[1,10],[4,3],[6,4],\n\t\t[8,4],[10,3]]\nFV1 = [[0,1,8,9,10,11],[1,2,11],[3,10,11],[4,5,9,10],[6,8,9],[0,7,8],[2,3,\n\t\t11],[3,4,10],[5,6,9],[6,7,8]]\nEV1 = [[0,1],[0,7],[0,8],[1,2],[1,11],[2,3],[2,11],[3,4],[3,10],[3,11],[4,\n\t\t5],[4,10],[5,6],[5,9],[6,7],[6,8],[6,9],[7,8],[8,9],[9,10],[10,11]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[0,3],[14,2],[14,5],[14,7],[14,11],[0,8],[3,7],[3,5]]\nFV2 = [[0,5,6,7],[0,1,7],[4,5,6],[2,3,6,7],[1,2,7],[3,4,6]]\nEV2 = [[0,1],[0,5],[0,7],[1,2],[1,7],[2,3],[2,7],[3,4],[3,6],[4,5],[4,6],\n\t\t[5,6],[6,7]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool21} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool22} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool23} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool24} \n   \\caption{2D example of file \\texttt{test/py/bool1/test2.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC.}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test2.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[3,0],[11,0],[13,10],[10,11],[8,11],[6,11],[4,11],[1,10],[4,3],[6,4],\n\t\t[8,4],[10,3]]\nFV1 = [[0,1,8,9,10,11],[1,2,11],[3,10,11],[4,5,9,10],[6,8,9],[0,7,8]]\nEV1 = [[0,1],[0,7],[0,8],[1,2],[1,11],[2,11],[3,10],[3,11],[4,5],[4,10],[5,\n\t\t9],[6,8],[6,9],[7,8],[8,9],[9,10],[10,11]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[0,3],[14,2],[14,5],[14,7],[14,11],[0,8],[3,7],[3,5]]\nFV2 = [[0,5,6,7],[0,1,7],[4,5,6],[2,3,6,7],[1,2,7],[3,4,6]]\nEV2 = [[0,1],[0,5],[0,7],[1,2],[1,7],[2,3],[2,7],[3,4],[3,6],[4,5],[4,6],\n\t\t[5,6],[6,7]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool31} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool32} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool33} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool34} \n   \\caption{2D example of file \\texttt{test/py/bool1/test3.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC.}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test3.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[3,0],[11,0],[13,10],[10,11],[8,11],[6,11],[4,11],[1,10],[4,3],[6,4],\n\t\t[8,4],[10,3]]\nFV1 = [[0,1,8,9,10,11],[1,2,11],[3,10,11],[4,5,9,10],[6,8,9],[0,7,8]]\nEV1 = [[0,1],[0,7],[0,8],[1,2],[1,11],[2,11],[3,10],[3,11],[4,5],[4,10],[5,\n\t\t9],[6,8],[6,9],[7,8],[8,9],[9,10],[10,11]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[0,3],[14,2],[14,5],[14,7],[14,11],[0,8],[3,7],[3,5]]\nFV2 = [[0,5,6,7],[0,1,7],[4,5,6],[2,3,6,7]]\nEV2 = [[0,1],[0,5],[0,7],[1,7],[2,3],[2,7],[3,6],[4,5],[4,6],[5,6],[6,7]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool41} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool42} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool43} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool44} \n   \\caption{2D example of file \\texttt{test/py/bool1/test4.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC.}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test4.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[10,0],[10,10],[0,10]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[2.5,2.5],[12.5,2.5],[12.5,12.5],[2.5,12.5]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool51} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool52} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool53} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool54} \n   \\caption{2D example of file \\texttt{test/py/bool1/test5.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC. (ERRORS in the images)}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n\n\\paragraph{ERROR}\n\nProblems remain with facet extraction from a (too) small convex complex, both if made of simplices\n(the automatically generated \\texttt{FW} is wrong) and if made of cuboids\n(the automatically generated \\texttt{FX} is wrong too). Errors to solve in the implementation of automatic extraction of facets.\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test5a.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[5,0],[5,5],[0,5]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[5,0],[10,0],[10,5],[5,5]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test5b.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[5,0],[5,5],[0,5]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[5,2],[10,2],[10,7],[5,7]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test5c.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[5,0],[5,5],[0,5]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[5,5],[10,5],[10,10],[5,10]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test5d.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[5,0],[5,5],[0,5]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[5,6],[10,6],[10,11],[5,11]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool61} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool62} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool63} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool64} \n   \\caption{2D example of file \\texttt{test/py/bool1/test6.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC. (ERRORS in the images)}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n\n\\paragraph{ERROR}\n\nProblems remain with tagging of 3D cell as internal/external to Boolean boundaries. Errors to solve in the implementation of  general (no simplicial) signed boundary operator matrix.\n\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test6.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0,0],[10,0,0],[10,10,0],[0,10,0],[0,0,10],[10,0,10],[10,10,10],[0,10,10]]\nV1,[VV1,EV1,FV1,CV1] = larCuboids((1,1,1),True)\nV1 = [SCALARVECTPROD([5,v]) for v in V1]\n\nV2 = [SUM([v,[2.5,2.5,2.5]]) for v in V1]\n[VV2,EV2,FV2,CV2] = [VV1,EV1,FV1,CV1]\n\narg1 = V1,(VV1,EV1,FV1,CV1)\narg2 = V2,(VV2,EV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test6b.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0,0],[10,0,0],[10,10,0],[0,10,0],[0,0,10],[10,0,10],[10,10,10],[0,10,10]]\nV1,[VV1,EV1,FV1,CV1] = larCuboids((1,1,1),True)\nV1 = [SCALARVECTPROD([5,v]) for v in V1]\n\nV2 = [SUM([v,[2.5,2.5,0.0]]) for v in V1]\n[VV2,EV2,FV2,CV2] = [VV1,EV1,FV1,CV1]\n\narg1 = V1,(VV1,EV1,FV1,CV1)\narg2 = V2,(VV2,EV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test6c.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0,0],[10,0,0],[10,10,0],[0,10,0],[0,0,10],[10,0,10],[10,10,10],[0,10,10]]\nV1,[VV1,EV1,FV1,CV1] = larCuboids((1,1,1),True)\nV1 = [SCALARVECTPROD([5,v]) for v in V1]\n\nV2 = [SUM([v,[2.5,0.0,0.0]]) for v in V1]\n[VV2,EV2,FV2,CV2] = [VV1,EV1,FV1,CV1]\n\narg1 = V1,(VV1,EV1,FV1,CV1)\narg2 = V2,(VV2,EV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool71} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool72} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool73} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool74} \n   \\caption{2D example of file \\texttt{test/py/bool1/test7.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC. }\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test7.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\n\nV1 = [[0,0],[10,0],[10,10],[0,10]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[2.5,2.5],[7.5,2.5],[7.5,7.5],[2.5,7.5]]\nFV2 = [range(4)]\nEV2 = [[0,1],[1,2],[2,3],[0,3]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool81} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool82} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool83} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool84} \n   \\caption{2D example of file \\texttt{test/py/bool1/test8.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC. (ERRORS: Numeric (?) errors in the splitting procedure?)}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test8.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\n\nn = 48\nV1 = [[5*cos(angle*2*PI/n)+2.5, 5*sin(angle*2*PI/n)+2.5] for angle in range(n)]\nFV1 = [range(n)]\nEV1 = TRANS([range(n),range(1,n+1)]); EV1[-1] = [0,n-1]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[4*cos(angle*2*PI/n), 4*sin(angle*2*PI/n)] for angle in range(n)]\nFV2 = [range(n)]\nEV2 = EV1\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test9.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nn = 6\nV1 = [[5*cos(angle*2*PI/n), 5*sin(angle*2*PI/n)] for angle in range(n)]\nFV1 = [range(n)]\nEV1 = TRANS([range(n),range(1,n+1)]); EV1[-1] = [0,n-1]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[4*cos(angle*2*PI/n), 4*sin(angle*2*PI/n)] for angle in range(n)]\nFV2 = [range(n)]\nEV2 = EV1\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool101} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool102} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool103} \n   \\includegraphics[height=0.244\\linewidth,width=0.244\\linewidth]{images/bool104} \n   \\caption{2D example of file \\texttt{test/py/bool1/test10.py}. (a) The cell numbering of SCDC; (b) the \\textsc{xor} of Boolean arguments; (c) the boundaries of exploded 2-cells of \\emph{reduced} SCDC; (d) exploded 1-cells of \\emph{reduced} SCDC.}\n   \\label{fig:example}\n\\end{figure}\n\n\n%-------------------------------------------------------------------------------\n@O test/py/bool1/test10.py\n@{\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nV1 = [[0,0],[15,0],[15,14],[0,14]]\nFV1 = [range(4)]\nEV1 = [[0,1],[1,2],[2,3],[0,3]]\nVV1 = AA(LIST)(range(len(V1)))\n\nV2 = [[1,1],[7,1],[7,6],[1,6], [8,1],[14,1],[14,7],[8,7], [1,7],[7,7],[7,13],\n\t\t[1,13], [8,8],[14,8],[14,13],[8,13]]\nFV2 = [range(4),range(4,8),range(8,12),range(12,16)]\nEV2 = [[0,1],[1,2],[2,3],[0,3], [4,5],[5,6],[6,7],[4,7], [8,9],[9,10],[10,11],[8,11], [12,13],[13,14],[14,15],[12,15]]\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,EV1,FV1)\narg2 = V2,(VV2,EV2,FV2)\n\n@< Debug via visualization @>\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\\subsection{Random data input} \n\n%------------------------------------------------------------------\n@D Random data input \n@{@< Generation of $n$ random points in the unit $d$-disk @>\n@< Generation of $n$ random points in the standard $d$-cuboid @>\n@< Triangulation of random points @>\n@}\n%------------------------------------------------------------------\n\n\\paragraph{Random points in unit disk} \nFirst we generate a  set of $n$ random points in the unit $D^d$ disk centred on the origin, to be subsequently used to generate a random Delaunay complex of variable granularity.\n\n%------------------------------------------------------------------\n@D Generation of $n$ random points in the unit $d$-disk \n@{def randomPointsInUnitCircle(n=200,d=2, r=1):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">randomPointsInUnitCircle\")\n\n\tpoints = random.random((n,d)) * ([2*math.pi]+[1]*(d-1))\n\n\tif TRACE: tracing = mytrace(tracing,\"<randomPointsInUnitCircle\")-1\n\treturn [[SQRT(p[1])*COS(p[0]),SQRT(p[1])*SIN(p[0])] for p in points]\n\t## TODO: correct for $d$-sphere\n\nif __name__==\"__main__\":\n\tVIEW(STRUCT(AA(MK)(randomPointsInUnitCircle()))) \n@}\n%------------------------------------------------------------------\n\n\\paragraph{Random points in the standard $d$-cuboid} \nA set of $n$ random $d$-points is then generated within the standard $d$-cuboid, i.e.~withing the $d$-dimensional interval with a vertex on the origin.\n\n%------------------------------------------------------------------\n@D Generation of $n$ random points in the standard $d$-cuboid \n@{def randomPointsInUnitCuboid(n=200,d=2):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">randomPointsInUnitCircle\")\n\tif TRACE: tracing = mytrace(tracing,\"<randomPointsInUnitCircle\")-1\n\treturn random.random((n,d)).tolist()\n\nif __name__==\"__main__\":\n\tVIEW(STRUCT(AA(MK)(randomPointsInUnitCuboid()))) \n@}\n%------------------------------------------------------------------\n\n\n\n\\paragraph{Triangulation of random points} The Delaunay triangulation of \\texttt{randomPointsInUnitCircle} is generated by the following macro.\n\n\n%------------------------------------------------------------------\n@D Triangulation of random points\n@{from scipy.spatial import Delaunay\ndef randomTriangulation(n=200,d=2,out='disk'):\n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">randomTriangulation\")\n\n\tif out == 'disk':\n\t\tV = randomPointsInUnitCircle(n,d)\n\telif out == 'cuboid':\n\t\tV = randomPointsInUnitCuboid(n,d)\n\tCV = Delaunay(array(V)).vertices\n\tmodel = V,CV\n\n\tif TRACE: tracing = mytrace(tracing,\"<randomTriangulation\")-1\n\treturn model\n\nif __name__==\"__main__\":\n\tfrom lar2psm import *\n\tVIEW(EXPLODE(1.5,1.5,1)(MKPOLS(model)))\n@}\n%------------------------------------------------------------------\n\n\n\n%------------------------------------------------------------------\n@o test/py/bool1/test11.py\n@{\"\"\" Union of 2D non-structured grids \"\"\"\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom bool1 import *\n\nmodel1 = randomTriangulation(100,2,'disk')\nV1,CV1 = model1\nVIEW(EXPLODE(1.5,1.5,1)(MKPOLS(model1)+cellNames(model1,CV1,MAGENTA)))\nFV1 = convexFacets (V1,CV1)\nVV1 = AA(LIST)(range(len(V1)))\n\nmodel2 = randomTriangulation(100,2,'cuboid')\nV2,CV2 = model2\nV2 = larScale( [2,2])(V2)\nmodel2 = V2,CV2 \nVIEW(EXPLODE(1.5,1.5,1)(MKPOLS(model2)+cellNames(model2,CV2,RED)))\nFV2 = convexFacets (V2,CV2)\nVV2 = AA(LIST)(range(len(V2)))\n\narg1 = V1,(VV1,FV1,CV1)\narg2 = V2,(VV2,FV2,CV2)\n\n@< Debug via visualization @>\n@}\n%------------------------------------------------------------------\n\n\n%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\\appendix\n%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n%-------------------------------------------------------------------------------\n\\section{Appendix: utility functions}\n%-------------------------------------------------------------------------------\n@D Initial import of modules\n@{from pyplasm import *\nfrom scipy import *\nimport sys\n\"\"\" import modules from larcc/lib \"\"\"\nsys.path.insert(0, 'lib/py/')\nfrom lar2psm import *\nfrom simplexn import *\nfrom larcc import *\nfrom largrid import *\nfrom myfont import *\nfrom mapper import *\nfrom larstruct import *\n@}\n%------------------------------------------------------------------\n\\subsection{Numeric utilities}\n\nA small set of utility functions is used to transform a \\emph{point} representation, given as array of coordinates, into a string of fixed format to be used as point key into python dictionaries.\n\n%------------------------------------------------------------------\n@D Symbolic utility to represent points as strings\n@{\"\"\" TODO: use package Decimal (http://docs.python.org/2/library/decimal.html) \"\"\"\nglobal PRECISION\nPRECISION = 3.\n\ndef mytrace(tracing,name):\n\tstring = tracing*\"  \" + name\n\tprint string\n\treturn(tracing)\n\ndef verySmall(number): \n\tif TRACE: global tracing;tracing = mytrace(tracing+1,\">verySmall\")\n\tif TRACE: tracing = mytrace(tracing,\"<verySmall\")-1\n\treturn abs(number) < 10**-(PRECISION)\n\ndef prepKey (args): \n\treturn \"[\"+\", \".join(args)+\"]\"\n\ndef fixedPrec(value):\n\tout = round(value*10**(PRECISION))/10**(PRECISION)\n\tif out == -0.0: out = 0.0\n\treturn str(out)\n\t\ndef vcode(4) (vect): \n\t#if TRACE: global tracing;tracing = mytrace(tracing+1,\">vcode(4)\")\n\t\"\"\"\n\tTo generate a string representation of a number array.\n\tUsed to generate the vertex keys in PointSet dictionary, and other similar operations.\n\t\"\"\"\n\n\t#if TRACE: tracing = mytrace(tracing,\"<vcode(4)\")-1\n\treturn prepKey(AA(fixedPrec)(vect))\n@}\n%------------------------------------------------------------------\n\n\n\\bibliographystyle{amsalpha}\n\\bibliography{bool1}\n\n\\end{document}\n%------------------------------------------------------------------\n\n\n\n", "meta": {"hexsha": "c8974c1ab66ac0e56af4d583fb4ea13459cbec24", "size": 98492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/tex/bool1.tex", "max_stars_repo_name": "cvdlab/lar-cc", "max_stars_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-20T04:48:12.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-20T04:48:12.000Z", "max_issues_repo_path": "src/tex/bool1.tex", "max_issues_repo_name": "Ahdhn/lar-cc", "max_issues_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-02-20T21:57:07.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T07:18:11.000Z", "max_forks_repo_path": "src/tex/bool1.tex", "max_forks_repo_name": "Ahdhn/lar-cc", "max_forks_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-04T10:47:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-10T17:32:50.000Z", "avg_line_length": 40.4318555008, "max_line_length": 688, "alphanum_fraction": 0.6097348008, "num_tokens": 28174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4260973236763892}}
{"text": " %% Private\n\n\n\n\n  %% Old: Once the ordered set of constraints is defined, we discuss the idea of introducing an additional constraint to the set. The introduction of an additional constraint is problematic because it can hide or render irrelevant constraints that already exist in the set. However, by restricting the analysis to the \\textit{relevant} set of constraints, we are able to\n\n  %% Old: We now move on to the sources of consumption concavity. In our setting, there are two sources of consumption concavity: risk and constraints. The properties of consumption under risk have already been derived in \\citet{carroll&kimball:concavity}. We therefore restrict our attention to showing how liquidity constraints make the consumption function concave. Once the relationship between liquidity constraints and consumption concavity is established, we use the results on consumption concavity and prudence to show under which conditions liquidity constraints heighten prudence.\n\n  \\subsection{Liquidity Constraints and Kink Points}\\label{sec:LCandKinks}\n  Recall that we are working with a consumer whose horizon goes from $0$ to $T$. We define a liquidity constraint dated $t$ as a constraint that requires savings at the \\textit{end of period} $t \\in (0, T]$ to be non-negative (the assumption of non-negativity is without loss of generality as shown in Theorem \\ref{thm:lcip2}).\n\n\n  We first define what we mean by a kink point which is induced by a constraint. To have a distinct terminology for the effects of current-period and future-period constraints, we will use the word `binds' to refer to the potential effects of a constraint in the period in which it applies and will use the term `impinges' to describe the effect of a future constraint on current consumption.\n  \\begin{defn}(Kink Point.) \\\\\n    We define a kink point, $\\wAlt_{t,n}$ as the level of market resources at which constraint $n$ stops binding or impinging on time $t$ consumption.\n  \\end{defn}\n  \\noindent A kink point corresponds to a transition from a level of market resources where a current constraint binds or a future constraint impinges, to a level of market resources where that constraint no longer binds or impinges.\n\n\n  The timing of a constraint relative to other existing constraints matters for the effects of the constraint. We therefore define an ordered set to keep track of the existing constraints.\n  \\begin{defn} (An Ordered Set of Relevant Constraints.) \\\\\n    We define $\\mathcal{T}$ as an ordered set of dates at which a relevant constraint exists. We define $\\mathcal{T}[1]$ as the last period in which a constraint exists, $\\mathcal{T}[2]$ as the date of the last period before $\\mathcal{T}[1]$ in which a constraint exists, and so on.\n  \\end{defn}\n  \\noindent $\\mathcal{T}$ is the set of relevant constraints, ordered from the last to the first constraint. We order them from last to first because a constraint in period $t$ only affects behavior prior to period $t$ (and $t$ itself). The set of constraints from period $t$ to $T$ summarizes all relevant information in period $t$. Further, and as discussed below, the effect of imposing the next constraint in $\\mathcal{T}$ on consumption is unambiguous only if one imposes constraints chronologically from last to first (and all constraints are of the no-borrowing type).\n\n  For any $t \\in [0, T)$, we define $c_{t,n}$ as the optimal consumption function in period $t$ assuming that the first $n$ constraints in $\\mathcal{T}$ have been imposed. For example, $c_{t,0}({m})$ is the consumption function in period $t$ when no constraint has been imposed, $c_{t,1}({m})$ is the consumption function in period $t$ after the chronologically last constraint has been imposed, and so on. $\\Omega_{t,n}, V_{t,n}$, and other functions are defined correspondingly.\n\n\n\n  \\subsection{A Fixed Set of Constraints}\\label{subsec:Piecewise}\n\n  We first consider an initial situation in which a consumer is solving a perfect foresight optimization problem with a finite horizon that begins in period $t$ and ends in period $T$. The consumer begins with market resources ${m}_{t}$ and earns constant income ${y}$ in each period. Lemma \\ref{lem:LcAndCc} shows how this consumer's behavior in period $t$ changes from an initial situation with $n\\geq 0$ constraints to a situation in which $n+1$ liquidity constraints has been imposed.\n\n  \\begin{lemma}\\label{lem:LcAndCc}(Liquidity Constraints Cause Counterclockwise Concavification.) \\\\\n    Consider an agent who has a utility function with $u'> 0 $ and $u'' < 0$, faces constant income ${y}$, and is impatient ($\\beta R < 1$). Assume that the agent faces a set $\\mathcal{T}$ of $N$ relevant constraints. Then $c_{t,n+1}({m})$ is a counterclockwise concavification of $c_{t,n}({m})$ around $\\wAlt_{t,n+1}$ for $n \\leq N-1$.\n  \\end{lemma}\n\n  \\noindent See Appendix \\ref{app:pfclc} for the proof. When we have an ordered set of constraints, $\\mathcal{T}$, the introduction of the next constraint generates a counterclockwise concavification of the consumption function.\n\n\n\n\n\n\n\n\n\n  \\subsection{Additional Constraints}\n  \\label{subsec:IncreaseNumConstr}\n\n  Lemma \\ref{lem:LcAndCc} analyzes the case where there is a preordained set of constraints $\\mathcal{T}$ which were applied sequentially in reverse chronological order. We now examine how behavior will be modified if we add a new date $\\hat{\\tau}$ to the set of dates at which the consumer is constrained.\n\n  Call the new set of dates $\\hat{\\mathcal{T}}$ with $N+1$ constraints (one more constraint than before), and call the consumption rules corresponding to the new set of dates\n  $\\hat{c}_{t,1}$ through $\\hat{c}_{t,N+1}$. Now call $m$ the\n  number of constraints in $\\mathcal{T}$ at dates strictly\n  greater than $\\hat{\\tau}$.  Then note that that $\\hat{c}_{\\hat{\\tau},m} =\n  c_{\\hat{\\tau},m}$, because at dates after the date at which the new constraint (number $m+1$) is\n  imposed, consumption is the same as in the absence of the new constraint.\n  Now recall that imposition of the constraint at $\\hat{\\tau}$ causes a counterclockwise concavification of the consumption function around a new kink point, $\\wAlt_{\\hat{\\tau},m+1}$. That is, $\\hat{c}_{\\hat{\\tau},m+1}$ is a counterclockwise concavification of $\\hat{c}_{\\hat{\\tau},m} = c_{\\hat{\\tau},m}$.\n\n  The most interesting observation, however, is that behavior under constraints $\\hat{\\mathcal{T}}$ in periods strictly before $\\hat{\\tau}$ \\textit{cannot} be described as a counterclockwise concavification of behavior under $\\mathcal{T}$.  The reason is that the values of wealth at which the earlier constraints caused kink points in the consumption functions before period $\\hat{\\tau}$ will not generally correspond to kink points once the extra constraint has been added.\n\n  \\hypertarget{CurrConstrHidesFutKink}{}\n\n  \\begin{figure}[ht]\n    {\\centering \\includegraphics[width=.95\\textwidth]{\\FigDir/CurrConstrHidesFutKink}}\n    \\caption{How a future constraint can move a current kink}\n    \\footnotesize {\\emph{Notes:} $c_{t,1}$ is the original consumption function with one constraint that induces a kink point at $\\omega_{t,1}$. $\\hat{c}_{t,2}$ is the modified consumption function in where we have introduced one new constraint. The two constraints affect $\\hat{c}_{t,2}$ through two kink points: $\\hat{\\omega}_{t,1}$ and $\\hat{\\omega}_{t,2}$. Since we introduced the new constraint at a later point in time than the current existing constraint, the future constraint affects the position of the kink induced by the current constraint and the modified consumption function $\\hat{c}_{t,2}$ is not a counterclockwise concavification of ${c}_{t,1}$.}\n    \\label{fig:LCtHidesLCtpn}\n  \\end{figure}\n\n  Figure~\\ref{fig:LCtHidesLCtpn} presents an example. The original $\\mathcal{T}$ contains only a single constraint, at the end of period $t+1$, inducing a kink point at $\\wAlt_{t,1}$ in the consumption rule $c_{t,1}$. The expanded set of constraints $\\hat{\\mathcal{T}}$ adds one constraint at period $t+2$. $\\hat{\\mathcal{T}}$ induces two kink points in the updated consumption rule $\\hat{c}_{t,2}$, at $\\hat{\\wAlt}_{t,1}$ and $\\hat{\\wAlt}_{t,2}$.  It is true that imposition of the new constraint causes consumption to be lower than before at every level of wealth below $\\hat{\\wAlt}_{t,1}$.  However, this does not imply higher prudence of the value function at every ${m} <\\hat{\\wAlt}_{t,1}$.  In particular, the original consumption function is strictly concave at $\\wAlt_{t,1}$, while the new consumption function is linear at $\\wAlt_{t,1}$, so prudence is greater before than after imposition of the new constraint at $\\wAlt_{t,1}$.\n\n  The intuition is straightforward. At levels of initial wealth below $\\hat{\\wAlt}_{t,1}$, the consumer had been planning to end period $t+2$ with negative wealth. With the new constraint, the old plan of ending up with negative wealth is no longer feasible and the consumer will save more for any given level of current wealth below $\\hat{\\wAlt}_{t,1}$, including $\\wAlt_{t,1}$. But the reason $\\wAlt_{t,1}$ was a kink point in the initial situation was that it was the level of wealth where consumption would have been equal to market resources in period $t+1$. Now, because of the extra savings induced by the constraint in $t+2$, the period $t+1$ constraint will no longer bind for a consumer who begins period $t$ with wealth $\\wAlt_{t,1}$. In other words, at wealth $\\wAlt_{t,1}$ the extra savings induced by the new constraint prevents the original constraint from being relevant at $\\wAlt_{t,1}$.\n\n  Notice, however, that all constraints that existed in $\\mathcal{T}$ will remain relevant at \\textit{some} $m$ under $\\hat{\\mathcal{T}}$ even after the new constraint is imposed - they just induce kink points at different levels of market resources than before (in Figure \\ref{fig:LCtHidesLCtpn}, the first constraint causes a kink at $\\hat{\\wAlt}_{t,2}$ rather than $\\wAlt_{t,1}$).\n\n  \\subsection{A More General Analysis}\n  \\label{subsubsec:MoreGenConstr}\n  The preceding analyses required income to be constant, the liquidity constraints to be of the no-borrowing type, and consumers to be impatient ($\\beta R < 1$).  We now relax these requirements.\n  %% Old: We now want to allow time variation in the level of income ${y}_{t}$ and in the location of the liquidity constraint .  We also drop the restriction that $\\beta R < 1$, allowing the consumer to desire consumption growth over time.\n\n  Under these more general circumstances, a constraint imposed in a given period can render constraints in either earlier or later periods irrelevant.  For example, consider a consumer with CRRA utility and $\\beta R=1$ who earns income of 1 in each period, but who is required to arrive at the end of period $T-2$ with savings of 5.  Then a constraint that requires savings to be greater than zero at the end of period $T-3$ will have no effect because the consumer is required by the constraint in period $T-2$ to end period $T-3$ with savings greater than 4.\n\n  Formally, consider now imposing the first constraint, which applies in period $\\tau < T$.  The simplest case, analyzed before, was a constraint that requires the minimum level of end-of-period wealth to be ${a}_{\\tau} \\geq 0$.  Here we generalize this to ${a}_{\\tau} \\geq \\sConst_{\\tau,1}$ where in principle we can allow borrowing by choosing $\\sConst_{\\tau,1}$ to be a negative number. Now for constraint $1$ calculate the kink points for prior periods from\n  \\begin{eqnarray}\n    u'(c_{\\tau,1}^{\\#}) & = & R\\beta u'(c_{\\tau+1,0}(R\\sConst_{\\tau,1}+{y}_{\\tau + 1}))\n    \\\\ \\wAlt_{\\tau,1} & = & (V_{\\tau,1}')^{-1}(u'(c_{\\tau,1}^{\\#})).\n  \\end{eqnarray}\n  In addition, for constraint $2$ recursively calculate\n  \\begin{eqnarray}\n    \\underline{\\sConst}_{\\tau-1,1} & = & (\\sConst_{\\tau,1}-{y}_{\\tau,2}+\\underline{c})/R  \\label{eq:cgt0}\n  \\end{eqnarray}\n  where $\\underline{\\sConst}_{\\tau-1,1}$ is the level of wealth that constraint $1$ requires the agent to end period $\\tau-1$ with and $\\underline{c}$ is the lower bound for the value of consumption permitted by the model (independent of constraints).\\footnote{For example, CRRA utility is well defined only on the positive real numbers, so for a CRRA utility consumer $\\underline{c}=0$.  In other cases, for example with exponential or quadratic cases, there is nothing to prevent consumption of $-\\infty$, so for those models $\\underline{c}=-\\infty$, unless there is a desire to restrict the model to positive values of consumption, in which case the $c\\geq 0$ constraint will be implemented through the use of \\eqref{eq:cgt0}.}\n\n  Now assume that the first $n$ constraints in $\\mathcal{T}$ have been imposed, and consider imposing constraint number $n+1$, which we assume applies at the end of period $\\tau$.  The first thing to check is whether constraint number $n+1$ is relevant given the already-imposed set of constraints. This is simple: A constraint that requires ${a}_{\\tau} \\geq \\sConst_{\\tau,n+1}$ will be irrelevant if $\\max_{i \\in [1,n]} [\\underline{\\sConst}_{\\tau,i}] \\geq \\sConst_{\\tau,n+1}$, i.e.\\ if one of the existing constraints already implies that savings must be greater or equal to value required by the new constraint.  If the constraint is irrelevant then the analysis proceeds simply by dropping this constraint and renumbering the constraints in $\\mathcal{T}$ so that the former constraint $n+2$ becomes constraint $n+1$, $n+3$ becomes $n+2$, and so on.\n\n  Now consider the other possible problem: That constraint number $n+1$ imposed in period $\\tau$ will render irrelevant some of the constraints that have already been imposed.  This too is simple to check: It will be true if the proposed $\\sConst_{\\tau,n+1} \\geq \\sConst_{\\tau,i}$ for any $i \\leq n$ and for all ${m}$.\\footnote{If a constraint is irrelevant for the lowest ${m}$ that t could enter period $\\tau$ with, then it is irrelevant for all ${m}$.} The fix is again simple: Counting down from $i=n$, find the smallest value of $i$ for which $\\sConst_{\\tau,n+1} \\geq \\sConst_{\\tau,i}$.  Then we know that constraint $n+1$ has rendered constraints $i$ through $n$ irrelevant. The solution is to drop these constraints from $\\mathcal{T}$ and start the analysis over again with the modified $\\mathcal{T}$.\n\n  If this set of procedures is followed until the chronologically earliest relevant constraint has been imposed, the result will be a $\\mathcal{T}$ that contains a set of constraints that can be analyzed as in the simpler case. In particular, proceeding from the final $\\mathcal{T}[1]$ through $\\mathcal{T}[N]$, the imposition of each successive constraint in $\\mathcal{T}$ now causes a counterclockwise concavification of the consumption function around successively lower values of wealth as progressively earlier constraints are applied and the result is again a piecewise linear and strictly concave consumption function with the number of kink points equal to the number of constraints that are relevant at any feasible level of wealth in period $t$.\n\n  The preceding discussion establishes the following result:\n\n  \\begin{theorem}\\label{thm:lcip2} (Liquidity Constraints Cause Counterclockwise Concavification.) \\\\\n    Consider an agent in period $t$ who has a utility function with $u' > 0$, $u'' < 0$, $u''' \\geq 0$, and non-increasing absolute prudence ($-u'''/u''$). Assume that the agent faces a set $\\mathcal{T}$ of $N$ relevant constraints.  Then $c_{t,n+1}({m})$ is a counterclockwise concavification of $c_{t,n}({m})$ around $\\wAlt_{t,n+1}$.\n    %\tWhen $n \\leq N-1$ constraints have been imposed, the imposition of constraint $n+1$ strictly increases absolute prudence of the agent's value function if the utility function satisfies $u''' > 0$ and ${m}_{t} < \\wAlt_{t,n+1}$ or if $u''' = 0$ and $\\frac{c'_{t,n+1}}{c'_{t,n}}$ strictly declines at ${m}$.\n  \\end{theorem}\n\n\n\n  %% Old: \\begin{theorem}\\label{thm:lcip2} (Liquidity Constraints Increase Prudence.) \\\\\n  %%   Old:   Consider an agent in period $t$ who has a utility function with $u' > 0$, $u'' < 0$, $u''' \\geq 0$, and non-increasing absolute prudence ($-u'''/u''$). Assume that the agent faces a set $\\mathcal{T}$ of $N$ relevant constraints. When $n \\leq N-1$ constraints have been imposed, the imposition of constraint $n+1$ strictly increases absolute prudence of the agent's value function if the utility function satisfies $u''' > 0$ and ${m}_{t} < \\wAlt_{t,n+1}$ or if $u''' = 0$ and $\\frac{c'_{t,n+1}}{c'_{t,n}}$ strictly declines at ${m}$.\n  %%   Old: \\end{theorem}\n\n  \\noindent Theorem \\ref{thm:lcip2} is a generalization of Lemma \\ref{lem:LcAndCc}. Even if we relax the assumptions that income is constant and the agent is impatient, the imposition of an extra (more general) constraint increases absolute prudence of the value function as long as we are careful when we select the set $\\mathcal{T}$ of relevant constraints.\n\n  For an agent that only faces liquidity constraints, but no risk, the shape of the consumption function is piecewise linear.\n  %% Old: \\begin{corollary}(Piecewise Linear Consumption Function.) \\\\\n  %%   Old:   Consider an agent who has a utility function with $u'> 0$ and $u'' < 0$, faces constant income ${y}$, and is impatient. Assume that the agent faces a set $\\mathcal{T}$ of $N$  constraints. When $n \\leq N$ constraints have been imposed, $c_{t,n}({m})$ is a piecewise linear increasing concave function with kink points at successively larger values of wealth at which future constraints stop impinging on current consumption.\n  %%   Old: \\end{corollary}\n  Since the consumption function is piecewise linear, the new consumption function, $c_{t,n+1}({m})$ is not necessarily strictly more concave than $c_{t,n}({m})$ for all ${m}$. This is where the concept of counterclockwise concavification is useful. Even though $c_{t,n+1}({m})$ is not strictly more concave than $c_{t,n}({m})$ everywhere, it is a counterclockwise concavification and we can apply Lemma \\ref{lem:CCToPrud} and \\ref{lem:ccandstrictprud} to show that the introduction of the next liquidity constraint increases absolute prudence of the value function.\n\n  \\begin{corollary}\\label{cor:lcip} (Liquidity Constraints Increase Prudence.) \\\\\n    Consider an agent in period $t$ who has a utility function with $u' > 0$, $u'' < 0$, $u''' \\geq 0$, and non-increasing absolute prudence ($-u'''/u''$). Assume that the agent faces a set $\\mathcal{T}$ of $N$ relevant constraints. When $n \\leq N-1$ constraints have been imposed, the imposition of constraint $n+1$ strictly increases absolute prudence of the agent's value function if the utility function satisfies $u''' > 0$ and ${m}_{t} < \\wAlt_{t,n+1}$ or if $u''' = 0$ and $\\frac{c'_{t,n+1}}{c'_{t,n}}$ strictly declines at ${m}$.\n  \\end{corollary}\n  \\begin{proof}\n    By Theorem \\ref{thm:lcip2}, the imposition of constraint $n+1$ constitutes a counterclockwise concavification of $c_{t,n}({m})$. By Lemma \\ref{lem:CCToPrud} and \\ref{lem:ccandstrictprud}, such a concavification (strictly) increases absolute prudence of the value function.\n  \\end{proof}\n  \\noindent %In the subsequent discussions, we consider cases where we relax the assumptions underlying Corollary \\ref{cor:lcip}. We first consider the case where we add an extra constraint to the set of constraints. Next, we consider the cases with time-varying deterministic income, general constraints, and no assumption on time discounting.\n\n  %% Old: Finally, consider adding a new constraint to the problem and call the new set of constraints $\\hat{\\mathcal{T}}$.  Suppose the new constraint applies in period $\\hat{\\tau}$.  Then the analysis of the new situation will be like the analysis of an added constraint in the simpler case in section \\ref{subsec:IncreaseNumConstr} if the new constraint is relevant given the constraints that apply after period $\\hat{\\tau}$ and the new constraint does not render any of those later constraints irrelevant. If the new constraint fails either of these tests, the analysis of $\\hat{\\mathcal{T}}$ can proceed from the ground up as described above.\n\n\n  \\newpage\n", "meta": {"hexsha": "ff2ce887f7d809046aec5ec2eab5ae6106ba0d53", "size": 20048, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Sections/LCandCC.tex", "max_stars_repo_name": "DrDrij/LiqConstr", "max_stars_repo_head_hexsha": "f6bc85dab49e181abc5f99b56a39a672cb2b0a7e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Sections/LCandCC.tex", "max_issues_repo_name": "DrDrij/LiqConstr", "max_issues_repo_head_hexsha": "f6bc85dab49e181abc5f99b56a39a672cb2b0a7e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sections/LCandCC.tex", "max_forks_repo_name": "DrDrij/LiqConstr", "max_forks_repo_head_hexsha": "f6bc85dab49e181abc5f99b56a39a672cb2b0a7e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 147.4117647059, "max_line_length": 938, "alphanum_fraction": 0.7450618516, "num_tokens": 5233, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.42609731445792237}}
{"text": "\n\\chapter[PhotoElectric effect]{PhotoElectric effect}\n\\section{Cross section and Mean free path}\n\n\\subsection{binding energy of the shells} \nThe binding energy of the inner shells have been parameterised as:\n\\[\n   B_i (Z) = Z^2 (a_i + b_i Z + c_i Z^2 + d_i Z^3 )  \n\\]\nwhere $ i = K, L_1, L_2 $, and the constants $a_i, b_i, c_i,d_i$\nare tabulated inside dedicated functions.\n\n\\subsection{Cross section per atom}\nLets $E_{\\gamma} =$ incident gamma energy, and $\\epsilon = E_{\\gamma}/m_{e}c^2 $ \\\\\nThe photoelectric total cross-section per atom has been parameterised as:\n\\[\n   \\sigma(Z,\\epsilon)=\\frac{Z^{\\alpha}} {\\epsilon^{\\beta}} F(Z,\\epsilon)\n\\]\n\\\\ \nwhere $\\alpha$ and $\\beta$ are results of a fit, and $F(Z,\\epsilon)$ is:\n\\[\n  \\begin{array}{lll}\n  \\mbox{for\\quad} E_{\\gamma} > B_K: & F=  p_{1K }/Z  + p_{2K }/\\epsilon  + p_{3K } \n                           & + p_{4K }Z + p_{5K }\\epsilon +p_{6K } Z^2 \\\\\n                       & & + p_{7K }Z\\epsilon + p_{8K }\\epsilon^2 + p_{9K }Z^3 \\\\                          \n       & & + p_{10K} Z^2\\epsilon + p_{11K} Z/\\epsilon^2 + p_{12K}\\epsilon^3 \\\\\n  \\mbox{for\\quad} E_{\\gamma} \\in ]B_{L1}, B_K]: &\n                                   F= p_{1L1}/Z + p_{2L1}/\\epsilon + p_{3L1} \\\\\n  \\mbox{for\\quad} E_{\\gamma} \\in ]B_{L2}, B_{L1}]: &                                    \n                                   F= p_{1L2}/Z + p_{2L2}/\\epsilon + p_{3L2} \\\\\n  \\mbox{for\\quad} E_{\\gamma} \\leq B_{L2}: & F= p_{1M}\n  \\end{array}\n\\]\n\\\\ \nThe fit was made over 301 data points chosen between:\n\\[5 \\leq Z \\leq 100\\quad \\mbox{and} \\quad 10 \\; keV \\leq E \\leq 50\\; MeV \\]\nThe values of the parameters are defined within the method which computes the\ncross section per atom. \\\\\nThe accuracy of the fit is estimated to be:\n\\begin{displaymath}\n \\frac{\\Delta \\sigma}{\\sigma} \\leq \n    \\left\\{\n        \\begin{array}{ll} 25\\% & \\mbox{near to the peaks} \\\\\n                          10\\% & \\mbox{elsewhere.}\n         \\end{array}\n    \\right.\n\\end{displaymath}\n\n\\subsection{Mean free path}\n\n\\begin{itemize}\n\\item[*]\n         In a simple material the number of atoms per volume is:\n         \\[n  = \\frac{\\mathcal{N}\\rho}{A}\\]\n         where:\n         \\begin{eqnarray*}\n          \\mathcal{N} &  & \\mbox{Avogadro's number} \\\\\n          \\rho        &  & \\mbox{density of the medium} \\\\\n          A           &  & \\mbox{mass of mole} \n         \\end{eqnarray*}\n\\item[*]\n         In a compound material the number of atoms of Element elm per volume is:\n         \\[n_{elm}  = \\frac{\\mathcal{N}\\rho w_{elm}}{A_{elm}}\\]\n         where:\n         \\begin{eqnarray*}\n          \\mathcal{N} &  & \\mbox{Avogadro's number} \\\\\n          \\rho        &  & \\mbox{density of the medium} \\\\\n          w_{elm}     &  & \\mbox{proportion by mass of the Element elm}\\\\\n          A_{elm}     &  & \\mbox{mass of mole of the Element elm} \n         \\end{eqnarray*} \n\\item[*] \n         The mean free path, $\\lambda$, for a photon to interact via photo electric\n         effect is given by\n         \\[\n           \\lambda(E_{\\gamma}) \\equiv \\frac{1}{\\Sigma (E_{\\gamma})} \n             = \\frac{1}{\\sum_{elm}{\\lbrack n_{elm} \\sigma(Z_{elm},E_{\\gamma})\\rbrack}}\n         \\]\n         where $\\sum_{elm}$ runs over all Elements the material is made of.\n\\end{itemize}\n\n\\section{final state}\n\\subsection{choose an Element}\nThe binding energy of the shells depend of the atomic number $Z_{elm}$. \\\\\nIn a compound material one choose randomly an Element on the basis of the\nprobability:\n\\[\n  Prob(Z_{elm},E_{\\gamma}) = \n                      \\frac{n_{elm} \\sigma(Z_{elm},E_{\\gamma})}{\\Sigma (E_{\\gamma})}\n\\]\n\\subsection{final state}\nThe simulation is presently rather crude.             \\\\\nA quanta can be absorbed if $E_{\\gamma} > B_{shell}$.\nThe photoelectron is emitted with kinetic energy:\n\\[T_{photoelectron} = E_{\\gamma}-B_{shell}(Z_{elm})\\]\n\\\\ \nThe electron has the same direction as the incident gamma.\n\\section{Status of this document}\n 9.10.98  created by M.Maire.\n", "meta": {"hexsha": "b0042131314223d395942528c0a42a49ca8dc385", "size": 3948, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant4/electromagnetic/standard/photoelec.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant4/electromagnetic/standard/photoelec.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant4/electromagnetic/standard/photoelec.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8787878788, "max_line_length": 107, "alphanum_fraction": 0.5704154002, "num_tokens": 1273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303236047049, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.426082579867741}}
{"text": "\\documentclass[12pt,letterpaper]{article}\n\\usepackage{fullpage}\n\\usepackage[top=2cm, bottom=4.5cm, left=2.5cm, right=2.5cm]{geometry}\n\\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}\n\\usepackage{lastpage}\n% \\usepackage{hyperref}\n\\usepackage{enumerate}\n\\usepackage{fancyhdr}\n\\usepackage{mathrsfs}\n\\usepackage{xcolor}\n\\usepackage{graphicx}\n\\usepackage{listings}\n%\\usepackage{mcode}\n%\\usepackage{hyperref}\n\\usepackage{movie15}\n\\usepackage{float}\n\n\n\\usepackage[colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref}\n\n% load package with ``framed'' and ``numbered'' option.\n\\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}\n\n% \\hypersetup{%\n%   colorlinks=true,\n%   linkcolor=blue,\n%   linkbordercolor={0 0 1}\n% }\n \n% \\renewcommand\\lstlistingname{Algorithm}\n% \\renewcommand\\lstlistlistingname{Algorithms}\n% \\def\\lstlistingautorefname{Alg.}\n\n% \\lstdefinestyle{Python}{\n%     language        = Python,\n%     frame           = lines, \n%     basicstyle      = \\footnotesize,\n%     keywordstyle    = \\color{blue},\n%     stringstyle     = \\color{green},\n%     commentstyle    = \\color{red}\\ttfamily\n% }\n\n\\setlength{\\parindent}{0.0in}\n\\setlength{\\parskip}{0.05in}\n\n% Edit these as appropriate\n\\newcommand\\course{Digital Signal Processing}\n\\newcommand\\hwnumber{2}                  % <-- homework number\n\\newcommand\\NetIDa{Mehdi Raza Khorasani}           % <-- NetID of person #1\n\\newcommand\\NetIDb{}           % <-- NetID of person #2 (Comment this line out for problem sets)\n\n\\pagestyle{fancyplain}\n\\headheight 35pt\n\\lhead{\\NetIDa}\n\\lhead{\\NetIDa\\\\\\NetIDb}                 % <-- Comment this line out for problem sets (make sure you are person #1)\n\\chead{\\textbf{\\Large Homework \\hwnumber}}\n\\rhead{\\course \\\\ \\today}\n\\lfoot{}\n\\cfoot{}\n\\rfoot{\\small\\thepage}\n\\headsep 1.5em\n\n\\begin{document}\n\n\\section*{Question 1}\n\\subsection*{Part (a)}\nFrom the definition of Z-Transform: \n\\[\n    X(z)= \\sum_{n=-\\infty}^{\\infty} x(n)z^{-n}\n\\]\nSo we get: \n\\[\n    X(z) = (3)z^{-3} + (0)z^{-2} + (0)z^{-1} + (6)z^{0} + (1)z^{1} + (-4)z^{2}\n\\]\n\\[\n\\boxed{\nX(z) = 3z^{-3} +  6 + z  -4z^{2}\n}\n\\]\n\n\\subsection*{Part (b)}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.5]{figures/q1task2.eps}\n    \\caption{PZ plot for Q1}\n    \\label{PZq1}\n\\end{figure}\n\\subsubsection*{Proof 1}\nWe know that if system is FIR, then it is non-recursively and defined as follows: \n\\[\n    y(n)=\\sum^{\\infty}_{k=-\\infty} b_k x(n-k)\n\\]\nTaking Z-transform, we get: \n\\[\n    Y(z) = \\sum^{\\infty}_{k=-\\infty} b_k X(z)z^{-k}\n\\]\nFrom above equation, we can observe the following constraint for FIR system: \n\\begin{enumerate}\n    \\item It can contain any number of zeros. \n    \\item It does not contain any poles.\n    \\item Its ROC will be the whole z plane (due to absense of poles).\n\\end{enumerate}\nSince the given system violates the condition 2 and 3, it is not FIR. So it  can be safely termed \\textbf{IIR}.\n\\subsubsection*{Proof 2}\nWe have: \n\\[\n    H(z) = G z^{N-M} \\dfrac{\\prod_{k=1}^{M} (z-z_k)}{\\prod_{k=1}^N (z-p_k)}\n\\]\nwhere $G = \\dfrac{b_o}{a_o}$.\\\\\nIn our case: \n\\[\n    N=M=1\n\\]\nThen: \n\\[\n    H(z) = G z^0 \\dfrac{z}{z-0.5}\n\\]\n\\[\n    H(z) = G \\dfrac{z}{z-0.5}\n\\]\nWe know that: \n\\[\n    H(z) = \\dfrac{Y(z)}{X(z)}\n\\]\nSo the system function can be written as: \n\\[\n    \\dfrac{Y(z)}{X(z)} = \\dfrac{b_o}{a_o} (\\dfrac{z}{z-0.5})\n\\]\nMultiply and divide by $z^{-1}$:\n\\[\n    \\dfrac{Y(z)}{X(z)} = \\dfrac{b_o}{a_o} (\\dfrac{1}{1-0.5z^{-1}})\n\\]\nRe-arranging: \n\\[\n    a_o Y(z) - 0.5a_oY(z)z^{-1} = b_o X(z) \n\\]\nConverting to LCCDE form: \n\\[\n    a_o y(n) - 0.5 a_o y(n-1) = b_o x(n-1)\n\\]\n\\[\n\\boxed{\n    a_o y(n) = 0.5 a_o y(n-1) + b_o x(n-1)\n}\n\\]\nThe given LCCDE is recursively defined hence the system is indeed IIR. Verified!\n\\pagebreak\n\\section*{Question 2}\nGiven: \n\\[\n    y(n) = 0.8 y(n-1)-0.6y(n-2) + x(n)+ 2x(n-1)\n\\]\n\\subsection*{Part (a)}\nTaking Z-Transform on both sides: \n\\[\n    Y(z) = 0.8 z^{-1}Y(z) -0.6Y(z) z^{-2} + X(z) + 2X(z) z^{-1}\n\\]\n\\[\n    Y(z)(1+0.6z^{-2} - 0.8z^{-1}) =  X(z)(1+2z^{-1})\n\\]\n\\[\n    \\dfrac{Y(z)}{X(z)} = \\dfrac{1+2z^{-1}}{1-0.8z^{-1} + 0.6z^{-2}}\n\\]\n\\[\n    = \\dfrac{z^2 + 2z}{z^2-0.8z + 0.6}\n\\]\n\\[\n    H(z) = \\dfrac{z(z + 2)}{z^2-0.8z + 0.6}\n\\]\n\n\\subsection*{Part (b)}\n\\subsubsection*{Zeros}\nZeros are as follows: \n\\[\n    z = 0\n\\]\n\\[\n    z=-2\n\\]\n\\subsubsection*{Poles}\nCalculating roots of the equation below: \n\\[\n    z^2-0.8z+0.6 = 0\n\\]\nPoles are as follows: \n\\[\n    p = 0.4 + 0.6633j\n\\]\n\\[\n    p = 0.4 - 0.6633j\n\\]\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.5]{figures/q2task3.eps}\n    \\caption{PZ plot}\n    \\label{PZq2}\n\\end{figure}\n\\subsection*{Part (c)}\nThe outer most pole is located at: \n\\[\n    r = \\sqrt{0.4^2 +0.6633^2} = 0.7746\n\\]\nSince system is causal, the ROC consists of $r>0.7746$. This implies that the ROC will include the unit circle (we may also observe this from the PZ plot). So system is stable. \n\\pagebreak\n\\section*{Question 3}\nGiven: \n\n\\[\n    H(z) = \\dfrac{z^2+z}{z^2+z-0.75}\n\\]\n\\subsection*{Part (a)}\n\\begin{figure}[!h]\n    \\centering\n    \\includegraphics[scale=0.5]{figures/q3task1.eps}\n    \\caption{PZ plot for Q3}\n    \\label{PZq3}\n\\end{figure}\n\\subsubsection*{Zeros}\nZeros are calculated as follows: \n\\[\n    z(z+1) = 0\n\\]\nThen, \n\\[\n\\boxed{\nz = 0\n}\n\\]\n\\[\n    \\boxed{\n    z = -1\n    }\n\\]\n\\subsubsection*{Poles}\n\nPoles are calculated as follows: \n\\[\n    z^2+z-0.75 = 0 \n\\]\n\\[\n\\boxed{\np = -1.5\n}\n\\]\n\\[\n\\boxed{\np = 0.5\n}\n\\]\n\n\\subsection*{Part (b)}\nThe outer most pole lies at: \n\\[\n    r = 1.5\n\\]\nWith the system obeying causality, its ROC will be $r>1.5$. So ROC doesn't includes the unit circle. So system is \\textbf{unstable}\n\n\\subsection*{Part (c)}\nThe system function can be written as: \n\\[\n    \\dfrac{Y(z)}{X(z)} = \\dfrac{z^2+z}{z^2+z-0.75}\n\\]\nMultiply and divide by $z^{-2}$\n\\[\n    \\dfrac{Y(z)}{X(z)} = \\dfrac{1+z^{-1}}{1+z^{-1} - 0.75z^{-2}}\n\\]\n\n\\[\n Y(z) + Y(z)z^{-1} -0.75Y(z)z^{-2} = X(z) + X(z)z^{-1}    \n\\]\nAbove equation can now be converted into LCCDE form: \n\\[\n    y(n) + y(n-1) -0.75y(n-2) = x(n) + x(n-1) \n\\]\n\\[\n\\boxed{\n    y(n) = -y(n-1) +0.75y(n-2) + x(n) + x(n-1) \n}\n\\]\n\\pagebreak\n\\section*{Question 4}\nGiven: \n\\[\n    X(z) = \\dfrac{z}{z^2+z-0.75}\n\\]\n\\[\n    \\dfrac{X(z)}{z} = \\dfrac{1}{z^2+z-0.75}\n\\]\nCreating partial fractions: \n\\[\n  \\dfrac{1}{(z+1.5)(z-0.5)} = \\dfrac{A_1}{(z+1.5)}  +\\dfrac{A_2}{(z-0.5)}\n\\]\n\\[\n 1 = A_1(z-0.5)+A_2(z+1.5)\n\\]\n\\subsection*{For $A_1$}\nPut $z=-1.5$\n\\[\n     1 = -2A_1  +0\n\\]\n\\[\n\\boxed{\nA_1 = -0.5\n}\n\\]\n\\subsection*{For $A_2$}\nPut $z=0.5$\n\\[\n     0.5 = 2A_2  +0\n\\]\n\\[\n\\boxed{\nA_2 = 0.25\n}\n\\]\nThen Partial fraction expansion becomes: \n\\[\n\\boxed{\n  \\dfrac{X(z)}{z} = \\dfrac{-0.5}{(z+1.5)}  +\\dfrac{0.25}{(z-0.5)}\n}\n\\]\n\\[\n    X(z) = \\dfrac{-0.5z}{(z+1.5)}  +\\dfrac{0.25z}{(z-0.5)}\n\\]\nMultiply and divide by $z^{-1}$:\n\\[\n    X(z) =  \\dfrac{-0.5}{(1+1.5z^{-1})}  +\\dfrac{0.25}{(1-0.5z^{-1})}\n\\]\nFrom the lookup table, the inverse transform is given as: \n\\[\n\\boxed{\n    x(n) = [-0.5(-1.5)^n + 0.25( 0.5)^n] u(n)\n}\n\\]\n\\pagebreak\n\\section*{Question 5}\n\n\\subsection*{Part (a)}\nSince the fiter is high pass, we may place pole at $\\omega = \\pi$ and zero at $\\omega = 0$. One possible arrangement is shown in the PZ plot:\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale=0.5]{figures/q5task1.eps}\n    \\caption{PZ plot for Q5}\n    \\label{PZq5}\n\\end{figure}\n\\subsection*{Part (b)}\n\\begin{enumerate}\n    \\item This is a band-pass filter for frequencies near $\\omega=\\pm \\pi/ 2$. It is so because we see poles at frequency $\\pm \\pi/ 2$  (Poles are placed near frequencies to be emphasized). Similarly, we see zeros at $\\omega = \\pi $ and $\\omega = 0$ (zeros are placed near frequencies to be de-emphasized). Hence this filter will block low and high frequencies ($\\omega = 0 $ and $\\omega = \\pi$) and pass frequencies around $\\omega = \\pm \\pi/ 2$. \n    \\item \n    At $\\omega =0$, the response is: \n    \\[\n     |H(\\omega)| = b_o \\dfrac{\\textit{product of length of vector: zero to unit circle}}{\\textit{product of length of vector: pole to unit circle}}\n    \\]\n    Hence the response in this case will be (Assuming poles at $r = 0.9$): \n    \\[\n    |H(\\omega)| = b_o \\dfrac{1\\times 1}{0.9 \\times 0.9}\n    \\]\n    \\[\n    |H(\\omega)| =  1.234b_o\n    \\]\n\\end{enumerate}\n\\section*{Index}\nThe complete source code can be found at: \\href{https://github.com/mehhdiii/Z-Transform-Basics}{GitHub/mehhdiii/}\n\\end{document}\n", "meta": {"hexsha": "1cc9c9bce3be99602cb472fcbfe9efdd47ffa8ac", "size": 8382, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "mehhdiii/Z-Transform-Basics", "max_stars_repo_head_hexsha": "d0fb919f484f8dbe273ee55634da3cecb94f4895", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "mehhdiii/Z-Transform-Basics", "max_issues_repo_head_hexsha": "d0fb919f484f8dbe273ee55634da3cecb94f4895", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "mehhdiii/Z-Transform-Basics", "max_forks_repo_head_hexsha": "d0fb919f484f8dbe273ee55634da3cecb94f4895", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.7154471545, "max_line_length": 447, "alphanum_fraction": 0.5942495824, "num_tokens": 3371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.42608257454794407}}
{"text": "\\section{Use of Higher Order Functions}\n\n\\begin{lstlisting}[language=Haskell]\nmodule ProgExercises.FS_2019_ProgExer05Prob_V01 where\n\n-- Develop some functions to work with order lists.\n-- Make use of higher-order functions and/or recursion.\n\ntoBeImplemented = undefined\n\ntype ArtName = String   -- name of article\ntype Number = Int       -- number of ordered articles\ntype Order = (ArtName, Number)\n\ntype Price = Int   -- price of an article in Rappen\ntype Pricing = (ArtName, Price)\ntype PricedOrder = (ArtName, Number, Price)\n\n-- Note: Order and Pricing are exactly the SAME type.\n-- However, we distinguish them on the software engineering level,\n-- but we must be careful.\n\nol01 :: [Order]\nol01 =\n  [(\"Schraube M4\", 100),\n   (\"Mutter M4\", 100),\n   (\"Unterlegscheibe M4\", 200)]\n\npl01 :: [Pricing]\npl01 =\n  [(\"Schraube M4\", 5),\n   (\"Unterlegscheibe M4\", 2),\n   (\"Mutter M4\", 5),\n   (\"Zahnrad 36Z\", 1300)]\n\n-- Given a name and a list of name item pairs, myLookup returns the first\n-- item in the list that matches the given name.\n-- If the list does not contain the given name, myLookup fails.\n-- Later we will write a better function that returns a value indicating\n-- whether an item has been found or not.\nexa_myLookup =\n  myLookup 39 [(5, 'a'), (39, 'b'), (7, 'c'), (39, 'd')] == 'b'\n\nmyLookup :: Eq a => a -> [(a, b)] -> b\nmyLookup x ((x', y) : xs)\n  | x == x' = y\n  | otherwise = myLookup x xs \n\n-- Given an order list and a pricing list, addPrices adds the prices\n-- according to the pricing list to the order list.\n-- Precondition:\n--   All article names in the order list occur in the pricing list.\nexa_addPrices =\n  addPrices ol01 pl01 ==\n    [(\"Schraube M4\",100,500),\n     (\"Mutter M4\",100,500),\n     (\"Unterlegscheibe M4\",200,400)]\n\naddPrices :: [Order] -> [Pricing] -> [PricedOrder]\naddPrices ol pl = map (\\(name, num) -> (name, num, myLookup name pl * num)) ol\n\n-- totalPrice determines the total price of an order list.\nexa_totalPrice =\n  totalPrice (addPrices ol01 pl01) == 1400\n\ntotalPrice :: [PricedOrder] -> Price\ntotalPrice pol = sum (map (\\(_, _, price) -> price) pol)\n\n\n\n\n-- totalNumPrice determines the total number of items and the total price\n-- of an order list.\ntotalNumPrice :: [PricedOrder] -> (Number, Price)\ntotalNumPrice pol = (sum nums, sum prices)\n  where (_, nums, prices) = unzip3 pol\n\n-- Returns items that (for the number ordered) cost more than a given maxPrice.\nexa_tooExpensive =\n  tooExpensive 450 (addPrices ol01 pl01) ==\n    [(\"Schraube M4\",100,500),\n     (\"Mutter M4\",100,500)]\n\ntooExpensive :: Price -> [PricedOrder] -> [PricedOrder]\ntooExpensive maxPrice pol = filter (\\(_, _, price) -> price > maxPrice) pol\n\n-- Adds an order to an order list.\n-- If the article name added already occurs in the order list,\n-- the number is accordingly incremented.\nexa_add =\n  addOrder (\"Mutter M4\", 250) ol01 ==\n    [(\"Schraube M4\", 100),\n     (\"Mutter M4\", 350),\n     (\"Unterlegscheibe M4\", 200)]\n\naddOrder :: Order -> [Order] -> [Order]\naddOrder (name, num) ((name', num') : ol)\n  | name == name' = (name, num + num') : ol\n  | otherwise = (name', num') : addOrder (name, num) ol\naddOrder nameNum [] = [nameNum]\n\n-- addOrderList adds all orders of a new order list to an old order list.\nexa_addOrderList =\n  addOrderList (tail ol01) ol01 ==\n    [(\"Schraube M4\", 100),\n     (\"Mutter M4\", 200),\n     (\"Unterlegscheibe M4\", 400)]\n\naddOrderList :: [Order] -> [Order] -> [Order]\naddOrderList olNew olOld = foldr addOrder olOld olNew\n\n-- Removes an order with a given article name from a given order list.\nexa_removeOrder =\n  removeOrder \"Schraube M4\" ol01 ==\n    [(\"Mutter M4\", 100),\n     (\"Unterlegscheibe M4\", 200)]\n\nremoveOrder :: ArtName -> [Order] -> [Order]\nremoveOrder name ol = filter (\\(name', _) -> name' /= name) ol\n\\end{lstlisting}\n\n\\clearpage", "meta": {"hexsha": "ee5cd9c62d6a3f53f700c3a687dcb223379c3d5e", "size": 3785, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TSM_AdvPrPa/Excercises/Haskell/08_HigherOrderFunctions.tex", "max_stars_repo_name": "nortismo/mse-documentations", "max_stars_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_stars_repo_licenses": ["Beerware"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TSM_AdvPrPa/Excercises/Haskell/08_HigherOrderFunctions.tex", "max_issues_repo_name": "nortismo/mse-documentations", "max_issues_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_issues_repo_licenses": ["Beerware"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TSM_AdvPrPa/Excercises/Haskell/08_HigherOrderFunctions.tex", "max_forks_repo_name": "nortismo/mse-documentations", "max_forks_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_forks_repo_licenses": ["Beerware"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-15T07:10:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-15T07:10:24.000Z", "avg_line_length": 31.0245901639, "max_line_length": 79, "alphanum_fraction": 0.67001321, "num_tokens": 1135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277512, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.42603568572356515}}
{"text": "% !TEX root = ../main.tex\n% chktex-file 21\n\\section{Hyperparameter optimization}%\n\\label{sec:hyperparams}\n\nAs described in the introduction, the goal of hyperparameter optimization is to find a global minimum of \\(l\\).\nSince \\(l\\) is generally unknown, analytical methods or gradient descent cannot usually be applied.\nThe only way the get information about \\(l\\) is to evaluate it on individual configurations \\(\\lambda\\) which is costly.\nThere are multiple ways to reduce the total cost of those evaluations:\n\\begin{enumerate}\n\t\\item \\textbf{Number \\(T\\) of evaluations of \\(l\\):}\n\t\tDuring optimization multiple hyperparameter configurations \\(\\lambda_1, \\dots, \\lambda_T\\) will be evaluated using \\(l\\).\n\t\t\\(T\\) is usually fixed when using a grid search or a random search.\n\t\tAfter evaluating \\(T\\) configurations, the best one is chosen.\n\t\tThose na{\\\"\\i}ve approaches assume that \\(l(\\lambda)\\) is independent of \\(l(\\lambda')\\) for all pairs \\(\\lambda \\neq \\lambda'\\).\n\t\tWe will see that this strong assumption of independence is not necessarily true which in turn allows us to reduce \\(T\\).\n\t\\item \\textbf{Training dataset size \\(S\\):}\n\t\tThe performance of a given configuration \\(l(\\lambda)\\) is computed by training the learner on \\(\\Dtrain\\) which is expensive for big datasets.\n\t\tBy training on \\(S\\) instead of \\(|\\Dtrain|\\) datapoints the evaluation can be sped up.\n\t\\item \\textbf{Number of training iterations \\(E\\):}\n\t\tDepending on the learner, training often is an iterative process, e.~g.\\@ gradient descent.\n\t\tTo speed up hyperparameter optimization training could be terminated before convergence.\n\\end{enumerate}\n\n\\subsection{FABOLAS}%\n\\label{sec:hyperparams:fabolas}\n\nThe first approach we will discuss is called Fabolas (Fast Bayesian Optimization of Machine Learning Hyperparameters on Large Datasets)~\\cite{Klein2017}.\nIt can be applied to any learner \\(L\\) and is based upon two main ideas:\n\\begin{enumerate}\n\t\\item The validation loss \\(l\\) is modeled as a \\textit{Gaussian process} (GP) \\(f\\) based on the assumption that two configurations \\(\\lambda\\) and \\(\\lambda'\\) will perform similar if they are similar according to some kernel \\(k(\\lambda, \\lambda')\\).\n\t\tThe Gaussian process \\(f\\) is used as a surrogate to estimate the expected value and variance of \\(l\\) given \\(\\lambda\\).\n\t\tUsing \\textit{Bayesian optimization} \\(l\\) will be probed at promising positions to iteratively improve \\(f\\).\n\t\tHyperparameter configurations that are expected to perform worse than the current optimum will not be probed.\n\t\tThis effectively reduces \\(T\\).\n\t\\item The training dataset size \\(S\\) is modeled as an additional hyperparameter of \\(f\\) giving the optimizer an additional degree of freedom.\n\t\tThis allows extrapolating the value of \\(l\\) when trained on the complete dataset while only probing smaller subsets\n\t\twhich effectively reduces \\(S\\).\n\\end{enumerate}\nWe will now describe how those two ideas can be applied.\n\n\\subsubsection{Gaussian processes}%\n\\label{sec:hyperparams:fabolas:gaussian}\n\nA Gaussian process is a family of \\textit{random variables} (RVs) \\({(X_\\theta)}_{\\theta \\in \\Theta}\\), s.~t.\\@ every finite subset of them follows a multivariate normal distribution.\nMore intuitively it can be understood as a probability distribution over functions \\(f: \\Theta \\to \\mathbb{R}\\) where \\(X_\\theta \\mathrel{\\widehat{=}} f(\\theta)\\).\nPrior knowledge about the likelihood of each \\(f\\) is described by a prior mean function \\(\\mu_0(\\theta) = \\mathbb{E}[f(\\theta)]\\) and a positive-definite kernel \\(k(\\theta, \\theta') = \\mathrm{Cov}(f(\\theta), f(\\theta'))\\).\nThe covariance kernel models how informative it is to know \\(f(\\theta)\\) to determine \\(f(\\theta')\\).\n\nLet \\(\\mathcal{D}_n = {\\{(\\bm{\\theta}_i, \\bm{y}_i)\\}}_{i = 1}^{n}\\) denote a set of observations.\nThose observations can be used to update the means and variances of the RVs via GP regression.\nThis collapses the space of possible functions \\(f\\) to those functions that align with \\(\\mathcal{D}_n\\) (see fig.~\\ref{fig:fabolas:matern}):\n\\begin{align}\n\t\\bm{m} :=&\\ {(\\mu_0(\\bm{\\theta}_1), \\dots, \\mu_0(\\bm{\\theta}_n))}^T \\nonumber \\\\\n\t\\bm{k}(\\theta) :=&\\ {(k(\\bm{\\theta}_1, \\theta), \\dots, k(\\bm{\\theta}_n, \\theta))}^T \\nonumber \\\\\n\t\\bm{K} \\in&\\ \\mathbb{R}^{n \\times n}, \\bm{K}_{ij} := k(\\bm{\\theta}_i, \\bm{\\theta}_j) \\nonumber \\\\\n\t\\mathbb{E}[f(\\theta)\\, |\\, \\mathcal{D}_n] :=&\\ \\mu_n(\\theta) = \\mu_0(\\theta) + \\bm{k}{(\\theta)}^T \\bm{K}^{-1} (\\bm{y} - \\bm{m}) \\\\\n\t\\mathrm{Cov}(f(\\theta), f(\\theta')\\, |\\, \\mathcal{D}_n) :=&\\ k(\\theta, \\theta') - \\bm{k}{(\\theta)}^T \\bm{K}^{-1} \\bm{k}(\\theta')\n\\end{align}\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.8\\linewidth]{gfx/fabolas/matern.pdf}\n\t\\caption{\n\t\t(Left) Comparison between different covariance kernels.\n\t\t(Middle) Randomly sampled functions \\(f\\) using those kernels.\n\t\t(Right) Random samples after two \\(f\\) values were observed and incorporated into the model via GP regression.\n\t\t\\source{Shahriari2016}\n\t}\\label{fig:fabolas:matern}\n\\end{figure}\n\nFabolas works by modeling the loss function \\(l\\) as a Gaussian process \\(f \\sim \\mathcal{GP}(m, k)\\) with parameter set \\(\\Theta := \\Lambda \\times [0, 1]\\) where \\(\\mu_0(\\lambda, s) = \\mathbb{E}[f(\\lambda, s)] = \\mathbb{E}[l(\\lambda)\\, |\\, \\text{training size}\\ s]\\).\nTo model the covariances between different combinations of hyperparameters and training set sizes, the following product kernel is used:\n\\begin{align}\n\tk((\\lambda, s), (\\lambda', s')) :=&\\ k_{\\textsc{Matérn5}}(d_M(\\lambda, \\lambda')) \\cdot k_{\\mathrm{lin}}(s, s')\n\\end{align}\nHere \\(k_{\\textsc{Matérn5}}\\) denotes the stationary Matérn kernel (\\(\\nu = \\nicefrac{5}{2}\\)) with \\(d_M\\) being the Mahalanobis distance between the two compared hyperparameter configurations.\n\\(k_{\\mathrm{lin}}\\) essentially is a simple linear kernel modeling the assumption that \\(l\\) monotonically decreases when \\(s\\) is increased.\nWe will now give an intuition for this choice of kernel and refer to~\\citet{Klein2017} for the details.\n\nThe Mahalanobis distance \\(d_M\\) is used instead of the Euclidean distance because the hyperparameters in a configuration typically use very different scales and are in some cases also correlated.\nFigure~\\ref{fig:fabolas:mahalanobis} gives an intuition for this.\n\\begin{figure}[t]\n\t\\centering\n\t\\includegraphics[width=0.7\\linewidth]{gfx/fabolas/mahalanobisDistance.pdf}\n\t\\caption{\n\t\tIntuition for the Mahalanobis distance.\n\t\tUsing the Euclidean distance the red points would be equally far away from the blue one.\n\t\tThe Mahalanobis distance fixes this by first normalizing the hyperparameters and removing correlations.\n\t}\\label{fig:fabolas:mahalanobis}\n\\end{figure}\n\nBased on the Mahalanobis distance between two configurations \\(\\lambda, \\lambda'\\) the \\textsc{Matérn5} kernel is used to compute a covariance.\nThe class of Matérn kernels interpolates between the Gaussian (\\textsc{Sq-Exp}) and the exponential (\\textsc{Matérn1}) kernel (see fig.~\\ref{fig:fabolas:matern}).\nBecause the exponential kernel drops off quickly, configurations quickly become uncorrelated which causes noisy samples.\nThe Gaussian kernel drops off less quickly causing smoother samples.\nFabolas uses \\textsc{Matérn5} as it empirically fits the smoothness of typical loss functions \\(l\\) quite well.\nPlease refer to \\citet{Schoen2017} for an explanation of why this is the case.\n\n\\subsubsection{Bayesian optimization}%\n\\label{sec:hyperparams:fabolas:bayesian}\n\nTo find \\(\\arg\\min_\\lambda l(\\lambda)\\) the bias and variance of \\(f\\) has to be reduced by probing \\(l\\) at promising positions.\nThis is called Bayesian optimization.\nThe estimated minimum after \\(n\\) probes is described by \\(\\arg\\min_\\lambda \\mu_n(\\lambda, s = 1)\\), i.~e.\\@ the configuration with the smallest predicted error on the full test dataset.\nTo reduce the number of probes required until this minimum converges, an \\textit{acquisition function} is used.\nIts role is to trade-off exploration vs.\\@ exploitation of \\(l\\) by describing the expected utility of probing \\((\\lambda_{n+1}, s_{n+1})\\) given a set of previous probes \\(\\mathcal{D}_n\\).\nFabolas uses an aquisition function that rates configurations by their \\textit{information gain} per computation time:\n\\begin{align}\n\ta_F(\\lambda, s) :=&\\ \\frac{1}{c(\\lambda, s)} \\mathbb{E}_y\\left[ p(y\\, |\\, \\lambda, s, \\mathcal{D}_n)\\ \\cdot \\mathrm{KL}_{\\hat{\\lambda}}(p_{\\min}(\\hat{\\lambda}\\, |\\, \\mathcal{D}_n \\cup \\{(\\lambda, s, y)\\})\\, \\|\\, u(\\hat{\\lambda}))\\right] \\\\\n\tp_{\\min}(\\lambda\\, |\\, \\mathcal{D}) :=&\\ p(\\lambda \\in \\arg\\min_{\\lambda'}{f(\\lambda', s = 1)}\\, |\\, \\mathcal{D}) \\nonumber\n\\end{align}\nIt measures the expected amount of available information about the optimal configuration if a given configuration were probed, i.~e.\\@ the Kullback-Leibler divergence between the density \\(p_{\\min}(\\lambda)\\) of \\(\\lambda\\) being optimal after a probe and the uniform density \\(u(\\lambda)\\).\nThis information gain of a probe is compared to its expected associated computation time \\(c\\).\n\\(c\\) is estimated using a separate Gaussian process that is maintained alongside \\(f\\).\nFabolas considers the cost of a probe because it tries to minimize the total optimization time not the total number of probes.\n\nSince it is infeasible to compute \\(a_F\\) numerically, its maximum is estimated using \\textit{Markov-Chain Monte Carlo} (MCMC).\nThe estimated most promising configuration will be probed.\nThe resulting loss value and runtime are then used to update the loss model \\(f\\) and cost model \\(c\\) via GP regression.\n\n\\subsubsection{Evaluation}%\n\\label{sec:hyperparams:fabolas:eval}\nFabolas was evaluated in \\textit{support vector machine} (SVM) and \\textit{convolutional neural network} (CNN) optimization tasks on the MNIST and CIFAR-10 dataset respectively\\footnote{A reference implementation can be found at \\url{https://github.com/automl/RoBO}}.\nFigure~\\ref{fig:fabolas:eval} compares Fabolas to the following other hyperparameter optimization approaches:\n\\begin{itemize}\n\t\\item \\textbf{Random Search:}\n\t\tSimple random hyperparameter search.\n\t\tEach configuration is evaluated on the full dataset.\n\t\\item \\textbf{Entropy Search \\& Expected Improvement:}\n\t\tBayesian optimization methods that always evaluate on the full dataset.\n\t\tExpected Improvement uses an aquisition function that simply probes at the current expected optimum.\n\t\tEntropy Search uses an aquisition function similar to the one used by Fabolas but without the cost model.\n\t\\item \\textbf{MTBO-\\(N\\) (Multi-Task Bayesian Optimization~\\cite{Swersky2013}):}\n\t\tLike Fabolas but restricts probes to two sizes \\(s \\in \\{\\nicefrac{1}{N}, 1\\}\\), i.~e.\\@ either a small subsample or the entire dataset is used.\n\t\tMultiple values for \\(N\\) are evaluated: 4, 32 and 512.\n\\end{itemize}\n\\begin{figure}\n\t\\begin{subfigure}[b]{0.32\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{gfx/fabolas/time1.png}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.32\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{gfx/fabolas/time2.png}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.34\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{gfx/fabolas/size.png}\n\t\\end{subfigure}\n\t\\caption{\n\t\tSVM optimization on the MNIST dataset.\\\n\t\t\\sourceinline{Klein2017}\n\t\t(Left) Comparison of the test performance over time of different optimzers.\n\t\t(Middle) Comparison of Fabolas with different MTBO subsample sizes.\n\t\t(Right) Comparison of the subsample sizes \\(s\\) that MTBO and Fabolas choose for their probes.\n\t\tThe average over 10 runs is depicted.\n\t}\\label{fig:fabolas:eval}\n\\end{figure}\nAll Bayesian optimization approaches are at least one order of magnitude faster than random search.\nBy allowing two probing sizes, MTBO is one additional order of magnitude faster.\nDepending on the choice of \\(N\\) MTBO sometimes improves faster than Fabolas initially.\nOnce Fabolas starts improving, it does however find a good configuration about one order of magnitude faster than MTBO.\\\nThe optimal configuration is found at roughly the same time by both Fabolas and MTBO.\\\nOverall Fabolas finds a good configuration between 100 and 1000 times faster than random search does.\nSimilar results are obtained when optimizing CNNs on CIFAR-10.\n\n\\subsection{Learning Curve Extrapolation}%\n\\label{sec:hyperparams:earlyterm}\n\nThe second approach for speeding up hyperparameter optimization focuses on reducing the number of training iterations \\(E\\).\nIt can in principle be applied to any gradient descent based learner and can be integrated into any hyperparameter optimizer.\nThe idea is to monitor the learning curve of a learner during training with a hyperparameter configuration \\(\\lambda\\).\nIf it is unlikely that a good accuracy will be reached with \\(\\lambda\\), training will be terminated before convergence.\n\nThe method was first described by \\citet{Domhan2015} in the context of hyperparameter optimization for \\textit{deep neural networks} (DNNs) that are trained using \\textit{stochastic gradient descent} (SGD).\nSince no strong assumptions specific to DNNs are made, it can however also be used for other learners.\nDNNs were used because their gradient descent steps are comparatively expensive.\n\n\\subsubsection{Extrapolation Method}%\n\\label{sec:hyperparams:earlyterm:method}\n\nLet \\(y_{1:n}\\) denote the observed learning curve of SGD after \\(n\\) iterations, i~e.\\@ the sequence of training accuracies \\(y_i \\in [0, 1]\\).\nNormally SGD iterations would be run for each hyperparameter configuration \\(\\lambda\\) until convergence or until a maximum number of iterations \\(E\\) has been reached.\nThe learning curve extrapolation optimization works by predicting \\(y_E\\) every \\(p\\) iterations:\n\\begin{algorithmic}[1]\n\\State{\\(\\hat{y} \\gets -\\infty\\)}\n\\For{\\(\\lambda \\gets\\) next hyperparameter configuration to evaluate}\n\t\\State{\\(n \\gets 0\\)}\n\t\\Repeat\\\n\t\t\\State{Run \\(p\\) SGD iterations using \\(\\lambda\\) with resulting accuracies \\(y_{(n + 1):(n + p)}\\).}\n\t\t\\State{\\(n \\gets n + p\\)}\n\t\t\\State{Estimate \\(P(y_E < \\hat{y}\\, |\\, y_{1:n})\\).}\\label{line:earlyterm:estimate}\n\t\\Until{\\(\\text{SGD converged} \\lor n \\geq E \\lor P(y_E < \\hat{y}\\, |\\, y_{1:n}) > \\delta\\)}\n\t\\State{\\algorithmicif\\ \\(y_n > \\hat{y}\\) \\algorithmicthen\\ \\(\\hat{y} \\gets y_n\\) \\algorithmicend\\ \\algorithmicif}\n\\EndFor\\\n\\end{algorithmic}\nThe prediction step (line~\\ref{line:earlyterm:estimate}) uses a probabilistic model.\nSimilar to Fabolas, a distribution over candidate functions is fit to the observations \\(y_{1:n}\\).\nUnlike Fabolas however, which uses a flexible non-parametric GP model, we use prior knowledge about the shape of learning curves to restrict the model to parameterized, increasing, saturating functions.\nMore specifically, the learning curve \\(y_{1:n}\\) is modeled as a linear combination \\(f_{\\mathit{comb}}\\) of a family of given functions.\n\\begin{align}\n\tf_{\\mathit{comb}}(t\\, |\\, \\xi) :=&\\ \\sum_{k = 1}^{K} w_k f_k(t\\, |\\, \\theta_k),\\\n\t\\xi = (w_1, \\dots, w_k, \\theta_1, \\dots, \\theta_k, \\sigma^2) \\\\\n\ty_t \\sim&\\ \\mathcal{N}(f_{\\mathit{comb}}(t\\, |\\, \\xi), \\sigma^2)\n\\end{align}\n\\citet{Domhan2015} use \\(K = 11\\) types of functions \\(\\{f_1, \\dots, f_K\\}\\) that are each parameterized by \\(\\{\\theta_1, \\dots, \\theta_K\\}\\).\nThe assumption is that every function type captures certain aspects of learning curves.\nBy allowing linear combinations a more powerful model can be obtained.\nFigure~\\ref{fig:earlyterm:models} illustrates this idea.\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.75\\linewidth]{gfx/earlyterm/models.png}\n\t\\caption{\n\t\tComparison of an observed learning curve (black) with the 11 types of learning curve models and a linear combination of them.\n\t\tEach type is parameterized to fit the first 50 observations \\(y_{1:50}\\).\n\t\tAs can be seen in the legend on the left, the linear combination has the smallest deviation \\(\\Delta y\\) from the observed data after 300 iterations.\n\t}\\label{fig:earlyterm:models}\n\\end{figure}\nTo estimate the probability \\(P(y_E < \\hat{y}\\, |\\, y_{1:n})\\) MCMC is used to sample \\(S\\) learning curves \\(\\{\\xi_1, \\dots, \\xi_S\\}\\) from the posterior\n\\begin{align}\n\tP(\\xi\\, |\\, y_{1:n}) \\propto&\\ P(y_{1:n}\\, |\\, \\xi) P(\\xi) \\\\\n\tP(y_{1:n}\\, |\\, \\xi) =&\\ \\prod_{t = 1}^{n} \\mathcal{N}(y_t; f_{\\mathit{comb}}(t\\, |\\, \\xi), \\sigma^2) \\\\\n\tP(\\xi) \\propto&\\ \\mathbbm{1}[f_{\\mathit{comb}}(1\\, |\\, \\xi) < f_{\\mathit{comb}}(E\\, |\\, \\xi) \\land \\forall k: w_k > 0]\n\\end{align}\nThe prior \\(P(\\xi)\\) is used to model the fact that learning curves do not typically decrease over time.\nGiven the learning curve samples, we can now estimate\n\\begin{align}\n\tP(y_E < \\hat{y}\\, |\\, y_{1:n}) =&\\ \\int P(\\xi\\, |\\, y_{1:n}) P(y_E < \\hat{y}\\, |\\, \\xi)\\, \\mathrm{d}\\xi \\\\\n\t\\approx&\\ \\frac{1}{S} \\sum_{s = 1}^S \\Phi(\\hat{y}; f_{\\mathit{comb}}(E\\, |\\, \\xi_s), \\sigma^2) \\nonumber\n\\end{align}\n\n\\subsubsection{Evaluation}%\n\\label{sec:hyperparams:earlyterm:eval}\n\n\\begin{figure}[t]\n\t\\begin{subfigure}{0.4\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{gfx/earlyterm/samples.png}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.6\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\linewidth]{gfx/earlyterm/time.png}\n\t\\end{subfigure}\n\t\\caption{\n\t\tEvaluation of early termination on the CIFAR-10 dataset.\n\t\tThe left graph shows the learning curves of all hyperparameter configurations that were evaluated.\n\t\tThe right graph shows the average validation error over time.\n\t\t\\source{Domhan2015}\n\t}\\label{fig:earlyterm:eval}\n\\end{figure}\nThe early termination method we just described was evaluated on the CIFAR-10, CIFAR-100 and MNIST dataset.\nFigure~\\ref{fig:earlyterm:eval} shows the behavior of early termination and the obtained speedup on CIFAR-10.\nAs expected, configurations with learning curves that tend to approach low accuracies are terminated early.\nConfigurations with high accuracies are evaluated until convergence.\nThis approach consistently speeds up the hyperparameter optimization by a factor of two across the tested datasets while reaching the same quality.\n", "meta": {"hexsha": "755ba0afce358cf6e2998abc32a9873952d983e7", "size": 17938, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/content/chapter-hyperparams.tex", "max_stars_repo_name": "Cortys/aml-seminar", "max_stars_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/content/chapter-hyperparams.tex", "max_issues_repo_name": "Cortys/aml-seminar", "max_issues_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/content/chapter-hyperparams.tex", "max_forks_repo_name": "Cortys/aml-seminar", "max_forks_repo_head_hexsha": "29f27bebceaaa6c3ac054d0719a389978bc717b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.0703125, "max_line_length": 291, "alphanum_fraction": 0.7354220091, "num_tokens": 5053, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.615087862571909, "lm_q1q2_score": 0.42603567693391314}}
{"text": "% !TEX root = ./appendix.tex\n\n\\section{CMRA constructions}\n\n% We will use the notation $\\mcarp{M} \\eqdef |M| \\setminus \\{\\mzero_M\\}$ for the carrier of monoid $M$ without zero. When we define a carrier, a zero element is always implicitly added (we do not explicitly give it), and all cases of multiplication that are not defined (including those involving a zero element) go to that element.\n\n% To disambiguate which monoid an element is part of, we use the notation $a : M$ to denote an $a$ s.t.\\ $a \\in |M|$.\n\n% When defining a monoid, we will show some \\emph{frame-preserving updates} $\\melt \\mupd \\meltsB$ that it supports.\n% Remember that\n% \\[\n% \t\\melt \\mupd \\meltsB \\eqdef \\always\\All \\melt_f. \\melt \\sep \\melt_f \\Ra \\Exists \\meltB \\in \\meltsB. \\meltB \\sep \\melt_f.\n% \\]\n% The rule \\ruleref{FpUpd} (and, later, \\ruleref{GhostUpd}) allows us to use such updates in Hoare proofs.\n% The following principles generally hold for frame-preserving updates.\n% \\begin{mathpar}\n% \t\\infer{\n% \t\t\\melt \\mupd \\meltsB\n% \t}{\n% \t\t\\melt \\mupd \\meltsB \\cup \\meltsB'\n% \t}\n% \t\\and\n% \t\\infer{\n% \t\t\\melt \\mupd \\meltsB\n% \t}{\n% \t\t\\melt \\mtimes \\melt_f \\mupd \\{ \\meltB \\mtimes \\melt_f \\mid \\meltB \\in \\meltsB \\}\n% \t}\n% \\end{mathpar}\n\n\\subsection{Agreement}\n\n\\ralf{Copy some stuff from the paper, at least in case we find that there are things which are too long for the paper.}\n\n% \\subsection{Exclusive monoid}\n\n% Given a set $X$, we define a monoid such that at most one $x \\in X$ can be owned.\n% Let $\\exm{X}$ be the monoid with carrier $X \\uplus \\{ \\munit \\}$ and multiplication\n% \\[\n% \\melt \\cdot \\meltB \\;\\eqdef\\;\n% \\begin{cases}\n%   \\melt & \\mbox{if } \\meltB = \\munit \\\\\n%   \\meltB & \\mbox{if } \\melt = \\munit\n% \\end{cases}\n% \\]\n\n% The frame-preserving update\n% \\begin{mathpar}\n% \\inferH{ExUpd}\n%   {x \\in X}\n%   {x \\mupd \\melt}\n% \\end{mathpar}\n% is easily shown, as the only possible frame for $x$ is $\\munit$.\n\n% Exclusive monoids are cancellative.\n% \\begin{proof}[Proof of cancellativity]\n% If $\\melt_f = \\munit$, then the statement is trivial.\n% If $\\melt_f \\neq \\munit$, then we must have $\\melt = \\meltB = \\munit$, as otherwise one of the two products would be $\\mzero$.\n% \\end{proof}\n\n% \\subsection{Agreement monoid}\n\n% Given a set $X$, we define a monoid such that everybody agrees on which $x \\in X$ has been chosen.\n% Let $\\agm{X}$ be the monoid with carrier $X \\uplus \\{ \\munit \\}$ and multiplication\n% \\[\n% \\melt \\cdot \\meltB \\;\\eqdef\\;\n% \\begin{cases}\n% \\melt & \\mbox{if } \\meltB = \\munit \\lor \\melt = \\meltB \\\\\n% \\meltB & \\mbox{if } \\melt = \\munit\n% \\end{cases}\n% \\]\n\n% Agreement monoids are cancellative.\n% \\begin{proof}[Proof of cancellativity]\n% \tIf $\\melt_f = \\munit$, then the statement is trivial.\n% \tIf $\\melt_f \\neq \\munit$, then if $\\melt = \\munit$, we must have $\\meltB = \\munit$ and we are done.\n% \tSimilar so for $\\meltB = \\munit$.\n% \tSo let $\\melt \\neq \\munit \\neq \\meltB$ and $\\melt_f \\mtimes \\melt = \\melt_f \\mtimes \\meltB \\neq \\mzero$.\n% \tIt follows immediately that $\\melt = \\melt_f = \\meltB$.\n% \\end{proof}\n\n% \\subsection{Finite Powerset Monoid}\n\n% Given an infinite set $X$, we define a monoid $\\textmon{PowFin}$ with carrier $\\mathcal{P}^{\\textrm{fin}}(X)$ as follows:\n% \\[\n% \\melt \\cdot \\meltB \\;\\eqdef\\; \\melt \\cup \\meltB \\quad \\mbox{if } \\melt \\cap \\meltB = \\emptyset\n% \\]\n\n% We obtain:\n% \\begin{mathpar}\n% \t\\inferH{PowFinUpd}{}\n% \t\t{\\emptyset \\mupd \\{ \\{x\\} \\mid x \\in X  \\}}\n% \\end{mathpar}\n\n% \\begin{proof}[Proof of \\ruleref{PowFinUpd}]\n% \tAssume some frame $\\melt_f \\sep \\emptyset$. Since $\\melt_f$ is finite and $X$ is infinite, there exists an $x \\notin \\melt_f$.\n% \tPick that for the result.\n% \\end{proof}\n\n% The powerset monoids is cancellative.\n% \\begin{proof}[Proof of cancellativity]\n% \tLet $\\melt_f \\mtimes \\melt = \\melt_f \\mtimes \\meltB \\neq \\mzero$.\n% \tSo we have $\\melt_f \\sep \\melt$ and $\\melt_f \\sep \\meltB$, and we have to show $\\melt = \\meltB$.\n% \tAssume $x \\in \\melt$. Hence $x \\in \\melt_f \\mtimes \\melt$ and thus $x \\in \\melt_f \\mtimes \\meltB$.\n% \tBy disjointness, $x \\notin \\melt_f$ and hence $x \\in meltB$.\n% \tThe other direction works the same way.\n% \\end{proof}\n\n% \\subsection{Product monoid}\n% \\label{sec:prodm}\n\n% Given a family $(M_i)_{i \\in I}$ of monoids ($I$ countable), we construct a product monoid.\n% Let $\\prod_{i \\in I} M_i$ be the monoid with carrier $\\prod_{i \\in I} \\mcarp{M_i}$ and point-wise multiplication, non-zero when \\emph{all} individual multiplications are non-zero.\n% For $f \\in \\prod_{i \\in I} \\mcarp{M_i}$, we write $f[i \\mapsto a]$ for the disjoint union $f \\uplus [i \\mapsto a]$.\n\n% Frame-preserving updates on the $M_i$ lift to the product:\n% \\begin{mathpar}\n%   \\inferH{ProdUpd}\n%   {a \\mupd_{M_i} B}\n%   {f[i \\mapsto a] \\mupd \\{ f[i \\mapsto b] \\mid b \\in B\\}}\n% \\end{mathpar}\n% \\begin{proof}[Proof of \\ruleref{ProdUpd}]\n% Assume some frame $g$ and let $c \\eqdef g(i)$.\n% Since $f[i \\mapsto a] \\sep g$, we get $f \\sep g$ and $a \\sep_{M_i} c$.\n% Thus there exists $b \\in B$ such that $b \\sep_{M_i} c$.\n% It suffices to show $f[i \\mapsto b] \\sep g$.\n% Since multiplication is defined pointwise, this is the case if all components are compatible.\n% For $i$, we know this from $b \\sep_{M_i} c$.\n% For all the other components, from $f \\sep g$.\n% \\end{proof}\n\n% If every $M_i$ is cancellative, then so is $\\prod_{i \\in I} M_i$.\n% \\begin{proof}[Proof of cancellativity]\n% Let $\\melt, \\meltB, \\melt_f \\in \\prod_{i \\in I} \\mcarp{M_i}$, and assume $\\melt_f \\mtimes \\melt = \\melt_f \\mtimes \\meltB \\neq \\mzero$.\n% By the definition of multiplication, this means that for all $i \\in I$ we have $\\melt_f(i) \\mtimes \\melt(i) = \\melt_f(i) \\mtimes \\meltB(i) \\neq \\mzero_{M_i}$.\n% As all base monoids are cancellative, we obtain $\\forall i \\in I.\\; \\melt(i) = \\meltB(i)$ from which we immediately get $\\melt = \\meltB$.\n% \\end{proof}\n\n% \\subsection{Fractional monoid}\n% \\label{sec:fracm}\n\n% Given a monoid $M$, we define a monoid representing fractional ownership of some piece $\\melt \\in M$.\n% The idea is to preserve all the frame-preserving update that $M$ could have, while additionally being able to do \\emph{any} update if we own the full state (as determined by the fraction being $1$).\n% Let $\\fracm{M}$ be the monoid with carrier $(((0, 1] \\cap \\mathbb{Q}) \\times M) \\uplus \\{\\munit\\}$ and multiplication\n% \\begin{align*}\n%  (q, a) \\mtimes (q', a') &\\eqdef (q + q', a \\mtimes a') \\qquad \\mbox{if $q+q'\\le 1$} \\\\\n%  (q, a) \\mtimes \\munit &\\eqdef (q,a) \\\\\n%  \\munit \\mtimes (q,a) &\\eqdef (q,a).\n% \\end{align*}\n\n% We get the following frame-preserving update.\n% \\begin{mathpar}\n% \t\\inferH{FracUpdFull}\n% \t\t{a, b \\in M}\n% \t\t{(1, a) \\mupd (1, b)}\n%   \\and\\inferH{FracUpdLocal}\n% \t  {a \\mupd_M B}\n% \t  {(q, a) \\mupd \\{q\\} \\times B}\n% \\end{mathpar}\n\n% \\begin{proof}[Proof of \\ruleref{FracUpdFull}]\n% Assume some $f \\sep (1, a)$. This can only be $f = \\munit$, so showing $f \\sep (1, b)$ is trivial.\n% \\end{proof}\n\n% \\begin{proof}[Proof of \\ruleref{FracUpdLocal}]\n% \tAssume some $f \\sep (q, a)$. If $f = \\munit$, then $f \\sep (q, b)$ is trivial for any $b \\in B$. Just pick the one we obtain by choosing $\\munit_M$ as the frame for $a$.\n\t\n% \tIn the interesting case, we have $f = (q_f, a_f)$.\n% \tObtain $b$ such that $b \\in B \\land b \\sep a_f$.\n% \tThen $(q, b) \\sep f$, and we are done.\n% \\end{proof}\n\n% $\\fracm{M}$ is cancellative if $M$ is cancellative.\n% \\begin{proof}[Proof of cancellativitiy]\n% If $\\melt_f = \\munit$, we are trivially done.\n% So let $\\melt_f = (q_f, \\melt_f')$.\n% If $\\melt = \\munit$, then $\\meltB = \\munit$ as otherwise the fractions could not match up.\n% Again, we are trivially done.\n% Similar so for $\\meltB = \\munit$.\n% So let $\\melt = (q_a, \\melt')$ and $\\meltB = (q_b, \\meltB')$.\n% We have $(q_f + q_a, \\melt_f' \\mtimes \\melt') = (q_f + q_b, \\melt_f' \\mtimes \\meltB')$.\n% We have to show $q_a = q_b$ and $\\melt' = \\meltB'$.\n% The first is trivial, the second follows from cancellativitiy of $M$.\n% \\end{proof}\n\n% \\subsection{Finite partial function monoid}\n% \\label{sec:fpfunm}\n\n% Given a countable set $X$ and a monoid $M$, we construct a monoid representing finite partial functions from $X$ to (non-unit, non-zero elements of) $M$.\n% \\ralf{all outdated}\n% Let ${X} \\fpfn {M}$ be the product monoid $\\prod_{x \\in X} M$, as defined in \\secref{sec:prodm} but restricting the carrier to functions $f$ where the set $\\dom(f) \\eqdef \\{ x \\mid f(x) \\neq \\munit_M \\}$ is finite.\n% This is well-defined as the set of these $f$ contains the unit and is closed under multiplication.\n% (We identify finite partial functions from $X$ to $\\mcarp{M}\\setminus\\{\\munit_M\\}$ and total functions from $X$ to $\\mcarp{M}$ with finite $\\munit_M$-support.)\n\n% We use two frame-preserving updates:\n% \\begin{mathpar}\n%   \\inferH{FpFunAlloc}\n%   {a \\in \\mcarp{M}}\n%   {f \\mupd \\{ f[x \\mapsto a] \\mid x \\notin \\dom(f) \\}}\n%   \\and\n%   \\inferH{FpFunUpd}\n%   {a \\mupd_M B}\n%   {f[i \\mapsto a] \\mupd \\{ f[i \\mapsto b] \\mid b \\in B\\}}\n% \\end{mathpar}\n% Rule \\ruleref{FpFunUpd} simply restates \\ruleref{ProdUpd}.\n\n% \\begin{proof}[Proof of \\ruleref{FpFunAlloc}]\n%   Assume some $g \\sep f$. Since $\\dom(f \\mtimes g)$ is finite, there will be some undefined element $x \\notin \\dom(f \\mtimes g)$. Let $f' \\eqdef f[x \\mapsto a]$. This is compatible with $g$, so we are done.\n% \\end{proof}\n\n% We write $[x \\mapsto a]$ for the function mapping $x$ to $a$ and everything else in $X$ to $\\munit$.\n\n% %\\subsection{Disposable monoid}\n% %\n% %Given a monoid $M$, we construct a monoid where, having full ownership of an element $\\melt$ of $M$, one can throw it away, transitioning to a dead element.\n% %Let \\dispm{M} be the monoid with carrier $\\mcarp{M} \\uplus \\{ \\disposed \\}$ and multiplication\n% %% The previous unit must remain the unit of the new monoid, as is is always duplicable and hence we could not transition to \\disposed if it were not composable with \\disposed\n% %\\begin{align*}\n% %  \\melt \\mtimes \\meltB &\\eqdef \\melt \\mtimes_M \\meltB & \\IF \\melt \\sep[M] \\meltB \\\\\n% %  \\disposed \\mtimes \\disposed &\\eqdef \\disposed \\\\\n% %  \\munit_M \\mtimes \\disposed &\\eqdef \\disposed \\mtimes \\munit_M \\eqdef \\disposed\n% %\\end{align*}\n% %The unit is the same as in $M$.\n% %\n% %The frame-preserving updates are\n% %\\begin{mathpar}\n% % \\inferH{DispUpd}\n% %   {a \\in \\mcarp{M} \\setminus \\{\\munit_M\\} \\and a \\mupd_M B}\n% %   {a \\mupd B}\n% % \\and\n% % \\inferH{Dispose}\n% %  {a \\in \\mcarp{M} \\setminus \\{\\munit_M\\} \\and \\All b \\in \\mcarp{M}. a \\sep b \\Ra b = \\munit_M}\n% %  {a \\mupd \\disposed}\n% %\\end{mathpar}\n% %\n% %\\begin{proof}[Proof of \\ruleref{DispUpd}]\n% %Assume a frame $f$. If $f = \\disposed$, then $a = \\munit_M$, which is a contradiction.\n% %Thus $f \\in \\mcarp{M}$ and we can use $a \\mupd_M B$.\n% %\\end{proof}\n% %\n% %\\begin{proof}[Proof of \\ruleref{Dispose}]\n% %The second premiss says that $a$ has no non-trivial frame in $M$. To show the update, assume a frame $f$ in $\\dispm{M}$. Like above, we get $f \\in \\mcarp{M}$, and thus $f = \\munit_M$. But $\\disposed \\sep \\munit_M$ is trivial, so we are done.\n% %\\end{proof}\n\n% \\subsection{Authoritative monoid}\\label{sec:auth}\n\n% Given a monoid $M$, we construct a monoid modeling someone owning an \\emph{authoritative} element $x$ of $M$, and others potentially owning fragments $\\melt \\le_M x$ of $x$.\n% (If $M$ is an exclusive monoid, the construction is very similar to a half-ownership monoid with two asymmetric halves.)\n% Let $\\auth{M}$ be the monoid with carrier\n% \\[\n% \t\\setComp{ (x, \\melt) }{ x \\in \\mcarp{\\exm{\\mcarp{M}}} \\land \\melt \\in \\mcarp{M} \\land (x = \\munit_{\\exm{\\mcarp{M}}} \\lor \\melt \\leq_M x) }\n% \\]\n% and multiplication\n% \\[\n% (x, \\melt) \\mtimes (y, \\meltB) \\eqdef\n%      (x \\mtimes y, \\melt \\mtimes \\meltB) \\quad \\mbox{if } x \\sep y \\land \\melt \\sep \\meltB \\land (x \\mtimes y = \\munit_{\\exm{\\mcarp{M}}} \\lor \\melt \\mtimes \\meltB \\leq_M x \\mtimes y)\n% \\]\n% Note that $(\\munit_{\\exm{\\mcarp{M}}}, \\munit_M)$ is the unit and asserts no ownership whatsoever, but $(\\munit_{M}, \\munit_M)$ asserts that the authoritative element is $\\munit_M$.\n\n% Let $x, \\melt \\in \\mcarp M$.\n% We write $\\authfull x$ for full ownership $(x, \\munit_M):\\auth{M}$ and $\\authfrag \\melt$ for fragmental ownership $(\\munit_{\\exm{\\mcarp{M}}}, \\melt)$ and $\\authfull x , \\authfrag \\melt$ for combined ownership $(x, \\melt)$.\n% If $x$ or $a$ is $\\mzero_{M}$, then the sugar denotes $\\mzero_{\\auth{M}}$.\n\n% \\ralf{This needs syncing with the Coq development.}\n% The frame-preserving update involves a rather unwieldy side-condition:\n% \\begin{mathpar}\n% \t\\inferH{AuthUpd}{\n% \t\t\\All\\melt_f\\in\\mcar{\\monoid}. \\melt\\sep\\meltB \\land \\melt\\mtimes\\melt_f \\le \\meltB\\mtimes\\melt_f \\Ra \\melt'\\mtimes\\melt_f \\le \\melt'\\mtimes\\meltB \\and\n% \t\t\\melt' \\sep \\meltB\n% \t}{\n% \t\t\\authfull \\melt \\mtimes \\meltB, \\authfrag \\melt \\mupd \\authfull \\melt' \\mtimes \\meltB, \\authfrag \\melt'\n% \t}\n% \\end{mathpar}\n% We therefore derive two special cases.\n\n% \\paragraph{Local frame-preserving updates.}\n\n% \\newcommand\\authupd{f}%\n% Following~\\cite{scsl}, we say that $\\authupd: \\mcar{M} \\ra \\mcar{M}$ is \\emph{local} if\n% \\[\n% \t\\All a, b \\in \\mcar{M}. a \\sep b \\land \\authupd(a) \\neq \\mzero \\Ra \\authupd(a \\mtimes b) = \\authupd(a) \\mtimes b\n% \\]\n% Then,\n% \\begin{mathpar}\n% \t\\inferH{AuthUpdLocal}\n% \t{\\text{$\\authupd$ local} \\and \\authupd(\\melt)\\sep\\meltB}\n% \t{\\authfull \\melt \\mtimes \\meltB, \\authfrag \\melt \\mupd \\authfull \\authupd(\\melt) \\mtimes \\meltB, \\authfrag \\authupd(\\melt)}\n% \\end{mathpar}\n\n% \\paragraph{Frame-preserving updates on cancellative monoids.}\n\n% Frame-preserving updates are also possible if we assume $M$ cancellative:\n% \\begin{mathpar}\n%  \\inferH{AuthUpdCancel}\n%   {\\text{$M$ cancellative} \\and \\melt'\\sep\\meltB}\n%   {\\authfull \\melt \\mtimes \\meltB, \\authfrag \\melt \\mupd \\authfull \\melt' \\mtimes \\meltB, \\authfrag \\melt'}\n% \\end{mathpar}\n\n% \\subsection{Fractional heap monoid}\n% \\label{sec:fheapm}\n\n% By combining the fractional, finite partial function, and authoritative monoids, we construct two flavors of heaps with fractional permissions and mention their important frame-preserving updates.\n% Hereinafter, we assume the set $\\textdom{Val}$ of values is countable.\n\n% Given a set $Y$, define $\\FHeap(Y) \\eqdef \\textdom{Val} \\fpfn \\fracm(Y)$ representing a fractional heap with codomain $Y$.\n% From \\S\\S\\ref{sec:fracm} and~\\ref{sec:fpfunm} we obtain the following frame-preserving updates as well as the fact that $\\FHeap(Y)$ is cancellative.\n% \\begin{mathpar}\n% \t\\axiomH{FHeapUpd}{h[x \\mapsto (1, y)] \\mupd h[x \\mapsto (1, y')]} \\and\n% \t\\axiomH{FHeapAlloc}{h \\mupd \\{\\, h[x \\mapsto (1, y)] \\mid x \\in \\textdom{Val} \\,\\}}\n% \\end{mathpar}\n% We will write $qh$ with $h : \\textsort{Val} \\fpfn Y$ for the function in $\\FHeap(Y)$ mapping every $x \\in \\dom(h)$ to $(q, h(x))$, and everything else to $\\munit$.\n\n% Define $\\AFHeap(Y) \\eqdef \\auth{\\FHeap(Y)}$ representing an authoritative fractional heap with codomain $Y$.\n% We easily obtain the following frame-preserving updates.\n% \\begin{mathpar}\n% \t\\axiomH{AFHeapUpd}{\n% \t\t(\\authfull h[x \\mapsto (1, y)], \\authfrag [x \\mapsto (1, y)]) \\mupd (\\authfull h[x \\mapsto (1, y')], \\authfrag [x \\mapsto (1, y')])\n% \t}\n% \t\\and\n% \t\\inferH{AFHeapAdd}{\n% \t\tx \\notin \\dom(h)\n% \t}{\n% \t\t\\authfull h \\mupd (\\authfull h[x \\mapsto (q, y)], \\authfrag [x \\mapsto (q, y)])\n% \t}\n% \t\\and\n% \t\\axiomH{AFHeapRemove}{\n% \t\t(\\authfull h[x \\mapsto (q, y)], \\authfrag [x \\mapsto (q, y)]) \\mupd \\authfull h\n% \t}\n% \\end{mathpar}\n\n% \\subsection{STS with tokens monoid}\n% \\label{sec:stsmon}\n\n% \\ralf{This needs syncing with the Coq development.}\n\n% Given a state-transition system~(STS) $(\\STSS, \\ra)$, a set of tokens $\\STSS$, and a labeling $\\STSL: \\STSS \\ra \\mathcal{P}(\\STST)$ of \\emph{protocol-owned} tokens for each state, we construct a monoid modeling an authoritative current state and permitting transitions given a \\emph{bound} on the current state and a set of \\emph{locally-owned} tokens.\n\n% The construction follows the idea of STSs as described in CaReSL \\cite{caresl}.\n% We first lift the transition relation to $\\STSS \\times \\mathcal{P}(\\STST)$ (implementing a \\emph{law of token conservation}) and define upwards closure:\n% \\begin{align*}\n%  (s, T) \\ra (s', T') \\eqdef&\\, s \\ra s' \\land \\STSL(s) \\uplus T = \\STSL(s') \\uplus T' \\\\\n%  \\textsf{frame}(s, T) \\eqdef&\\, (s, \\STST \\setminus (\\STSL(s) \\uplus T)) \\\\\n%  \\upclose(S, T) \\eqdef&\\, \\setComp{ s' \\in \\STSS}{\\exists s \\in S.\\; \\textsf{frame}(s, T) \\ststrans \\textsf{frame}(s', T) }\n% \\end{align*}\n\n% \\noindent\n% We have\n% \\begin{quote}\n% \tIf $(s, T) \\ra (s', T')$\\\\\n% \tand $T_f \\sep (T \\uplus \\STSL(s))$,\\\\\n% \tthen $\\textsf{frame}(s, T_f) \\ra \\textsf{frame}(s', T_f)$.\n% \\end{quote}\n% \\begin{proof}\n% This follows directly by framing the tokens in $\\STST \\setminus (T_f \\uplus T \\uplus \\STSL(s))$ around the given transition, which yields $(s, \\STST \\setminus (T_f \\uplus \\STSL{T}(s))) \\ra (s', T' \\uplus (\\STST \\setminus (T_f \\uplus T \\uplus \\STSL{T}(s))))$.\n% This is exactly what we have to show, since we know $\\STSL(s) \\uplus T = \\STSL(s') \\uplus T'$.\n% \\end{proof}\n\n% Let $\\STSMon{\\STSS}$ be the monoid with carrier\n% \\[\n% \t\\setComp{ (s, S, T) \\in \\exm{\\STSS} \\times \\mathcal{P}(\\STSS) \\times \\mathcal{P}(\\STST) }{ \\begin{aligned} &(s = \\munit \\lor s \\in S) \\land \\upclose(S, T) = S   \\land{} \\\\& S \\neq \\emptyset \\land \\All s \\in S. \\STSL(s) \\sep T  \\end{aligned} }\n% \\]\n% and multiplication\n% \\[\n% \t(s, S, T) \\mtimes (s', S', T') \\eqdef (s'' \\eqdef s \\mtimes_{\\exm{\\STSS}} s', S'' \\eqdef S \\cap S', T'' \\eqdef T \\cup T') \\quad \\text{if }\\begin{aligned}[t] &(s = \\munit \\lor s' = \\munit) \\land T \\sep T' \\land{} \\\\& S'' \\neq \\emptyset \\land (s'' \\neq \\munit \\Ra s'' \\in S'') \\end{aligned}\n% \\]\n\n% Some sugar makes it more convenient to assert being at least in a certain state and owning some tokens: $(s, T) : \\STSMon{\\STSS} \\eqdef (\\munit, \\upclose(\\{s\\}, T), T) : \\STSMon{\\STSS}$, and\n% $s : \\STSMon{\\STSS} \\eqdef (s, \\emptyset) : \\STSMon{\\STSS}$.\n\n% We will need the following frame-preserving update.\n% \\begin{mathpar}\n% \t\\inferH{StsStep}{(s, T) \\ststrans (s', T')}\n% \t {(s, S, T) \\mupd (s', \\upclose(\\{s'\\}, T'), T')}\n% \\end{mathpar}\n% \\begin{proof}[Proof of \\ruleref{StsStep}]\n% Assume some upwards-closed $S_f, T_f$ (the frame cannot be authoritative) s.t.\\ $s \\in S_f$ and $T_f \\sep (T \\uplus \\STSL(s))$. We have to show that this frame combines with our final monoid element, which is the case if $s' \\in S_f$ and $T_f \\sep T'$.\n% By upward-closedness, it suffices to show $\\textsf{frame}(s, T_f) \\ststrans \\textsf{frame}(s', T_f)$.\n% This follows by induction on the path $(s, T) \\ststrans (s', T')$, and using the lemma proven above for each step.\n% \\end{proof}\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"iris\"\n%%% End: \n", "meta": {"hexsha": "768cd1c1fceda905242906aad9cbbfb647c5ec22", "size": 18625, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/constructions.tex", "max_stars_repo_name": "amintimany/iris-backup", "max_stars_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/constructions.tex", "max_issues_repo_name": "amintimany/iris-backup", "max_issues_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/constructions.tex", "max_forks_repo_name": "amintimany/iris-backup", "max_forks_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.3766233766, "max_line_length": 354, "alphanum_fraction": 0.6514899329, "num_tokens": 6947, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4260356720467403}}
{"text": "\\documentclass{article}\r\n\\usepackage{amsmath}\r\n\\usepackage{amsfonts}\r\n\\usepackage{graphicx}\r\n\\title{Modeling Corruption in America using the Bush and Obama Administration}\r\n\\author{Joshua Wollenweber}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\t\\begin{abstract}\r\n\tThis paper intends to model corruption in the United States of America through a variation of the universal model of interraction (Lotka-Volterra). The model uses logistic decay of corruption and assumes that the new presidential administration interacts with the policies and achievements of the old administration. Data from the Obama and Bush presidential administrations were used as they directly follow each other chronologically. This interraction is assumed to affect the corruption level of the nation. Solution curves were created using a global and local carrying capacity, but yielded no significant difference. The model was determined to be ineffective at forecasting corruption levels in the United States.\r\n\t\\end{abstract}\r\n\r\n\t\\newpage\r\n\t\\section{Introduction}\r\n\t\\paragraph{}\r\n\tThe goal of this project was to find a suitable model for forecasting corruption in the United States of America. To measure corruption, the Corruption Perception Index (CPI) was used from Transparency.org.\r\n\t\\paragraph{}\r\n\tTransparency.org attempts to measure the perception of corruption in the public sector by consolidating and normalizing data from surveys by several big data businesses, which give their own measure of corruption. CPI has been measured in a rapidly increasing number of countries around the world since 1995. The CPI in the US has been measured from 1995 until their most recent report for 2018. \r\n\t\\paragraph{}\r\n\tCorruption can also be understood as the abuse of power, and presidential administrations demonstrate their abuse of power through their actions during term. Many of these actions may be self-serving (corrupt) and conflict (compete) with the policies and achievements of the administration preceding them. Therefore, the universal model of interaction will be used in attempts to model corruption within the US.\r\n\r\n\t\\section{Methods}\r\n\t\t\\subsection{Determining the Model}\r\n\t\tThe CPI data for the US is shown with a trend-fitting curve in Figure \\ref{USA CPI}. It is important to note the oscillitory nature of its change throughout the years.\t\r\n\t\t\\begin{figure}[h]\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=1\\textwidth]{USA_CPI}\r\n\t\t\\caption{Shows the CPI score of the US from 1995 to 2018 with a lower bound of 7 and an upper bound of 8}\r\n\t\t\\label{USA CPI}\r\n\t\t\\end{figure}\r\n\r\n\t\t\\paragraph{}\r\n\t\tBecause of the oscillations in CPI throughout the years, it is important to fit the data to a growth/decay model. The nature of change in CPI must be indentified in order to determine the best model to use for this project. Logistic growth was tested, and Figure \\ref{Logistic Fit} shows the data to fit logistic decay.\r\n\t\t\\begin{figure}[h]\r\n\t\t\\centering\r\n\t\t\\includegraphics[width=1\\textwidth]{logistic_fit}\r\n\t\t\\caption{Shows the fit of US CPI data to a logistic decay model of growth. Noting the y-intercept identifies the global carrying capacity K to be 7.4194.}\r\n\t\t\\label{Logistic Fit}\r\n\t\t\\end{figure}\r\n\r\n\r\n\t\t\\subsection{Model}\r\n\t\t\\paragraph{}\r\n\t\tWith this information, the following model was produced using four assumptions.\r\n\t\t\\begin{enumerate}\r\n\t\t\\item The change in CPI of the current (new) presidential administration is affected by the CPI of the previous (old) presidential administration.\r\n\t\t\\item There is logistic decay in the change in CPI for any administration in the US.\r\n\t\t\\item The CPI will go through logistic growth if the administration is corrupt, and will go through logistic decay if the administration is non-corrupt (coefficients a and m).\r\n\t\t\\item The CPI will decrease if the new administration takes measures to deface or remove achievements/policies created by the old administration (coefficients b and n).\r\n\t\t\\end{enumerate}\r\n\t\t\\paragraph{}\r\n\t\tThe universal model of interaction was used, which is a variation of the Lotka-Volterra equation. The Obama administration (2009-2016) is identified as the new administration, x, and the Bush administration (2001-2008) is identified as the old administration, y.\r\n\t\t\\begin{equation}\r\n\t\tx'=x(-a(1-\\frac{x}{K})-by)\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\ty'=y(-m(1-\\frac{y}{K})-nx)\r\n\t\t\\end{equation}\r\n\t\t\r\n\r\n\t\t\\subsection{Coefficients}\r\n\t\t\\paragraph{}\r\n\t\tCoefficients were determined using the initial conditions for each administration. MatLab code was used to calculate these values, and the following equations were used. \r\n\t\t\\begin{equation}\r\n\t\tC_{x} = \\ln{\\frac{x_{0}}{x_{0}-K}}\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\tC_{y} = \\ln{\\frac{y_{0}}{y_{0}-K}}\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\ta = -\\ln{\\frac{K+x_{1}}{x_{1}}+C}\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\tm = -\\ln{\\frac{K+y_{1}}{y_{1}}+C}\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\tb = \\frac{-x'-x(a(1-\\frac{x}{K})}{x*y}\r\n\t\t\\end{equation}\r\n\t\t\\begin{equation}\r\n\t\tn = \\frac{-y'-y(m(1-\\frac{y}{K})}{x*y}\r\n\t\t\\end{equation}\r\n\t\t\\paragraph{}\r\n\t\tWhile the global carrying capacity, K, was used in the initial test of the model, local carrying capacities for each administration were calculated. The following equations were used for their calculation.\r\n\t\t\\begin{equation}\r\n\t\tK_{x} = x_{1} * \\frac{2*x_{0}*x_{2}-x_{0}*x_{1}-x_{1}*x_{2}}{x_{0}*x_{2}-x_{1}*x_{1}}\r\n\t\t\\end{equation}\t\r\n\t\t\\begin{equation}\r\n\t\tK_{y} = y_{1} * \\frac{2*y_{0}*y_{2}-y_{0}*y_{1}-y_{1}*y_{2}}{y_{0}*y_{2}-y_{1}*y_{1}}\r\n\t\t\\end{equation}\t\r\n\r\n\t\\section{Results}\r\n\t\\paragraph{}\r\n\tThe nullclines for x' and y' were determined to gain an expectation for the results. This is shown in Figure \\ref{Phase Portrait}.\r\n\t\\begin{figure}[h]\r\n\t\\centering\r\n\t\\includegraphics[width=1\\textwidth]{phase_portrait}\r\n\t\\caption{Shows the phase portrait of the model equations. L1 denotes the nullcline for the Obama administration. L2 denotes the nullcline for the Bush administration. Trajectories are shown in mahogany.}\r\n\t\\label{Phase Portrait}\r\n\t\\end{figure}\r\n\r\n\t\\paragraph{}\r\n\tThe phase portrait and solution curves are shown in Figure \\ref{Solution1}. The solution curves show slight oscillation around their equillibrium points. These curves predict the CPI up to 10 years after the initial year. This graph uses the universal carrying capacity value of 7.4194. The Obama administration reaches an equillibrium at a CPI of 7, and the Bush administration reaches an equillibrium at a CPI of 7.5.\r\n\t\\begin{figure}[!]\r\n\t\\centering\r\n\t\\includegraphics[width=1\\textwidth]{solution_universal_k}\r\n\t\\caption{The top graphics shows the phase portait as it oscillates around (7, 7.45). The bottom graphic shows the solutions of x (blue) and y (red)}\r\n\t\\label{Solution1}\r\n\t\\end{figure}\r\n\r\n\t\\paragraph{}\r\n\tAnother test using local carrying capacites from equations (9) and (10) is shown in Figure \\ref{Solution2}. This shows no significant difference from Figure \\ref{Solution1}, but there is slightly more oscillation about the equillibrium point (7, 7.45).\r\n\t\\begin{figure}[!]\r\n\t\\centering\r\n\t\\includegraphics[width=1\\textwidth]{solution_local_k}\r\n\t\\caption{The top graphics shows the phase portait as it oscillates around (7, 7.45). The bottom graphic shows the solutions of x (blue) and y (red)}\r\n\t\\label{Solution2}\r\n\t\\end{figure}\r\n\r\n\t\\paragraph{}\r\n\tOther approaches not displayed include: changing the initial conditions to the second and third year of a president's administration, experimenting with the values of a,n and b,m. It was determined that a and n must be negative for the solution curves to converge to a CPI value, that the initial conditions have an extremely varying effect on the equillibrium point on the solution curves, and positive b and m will yield an increasing solution curve that reaches an equillibrium while a negative b and m will yield a decreasing solution curve that reaches an equillibrium. The slight oscillation in the solution curves shown in Figures \\ref{Solution1} and \\ref{Solution2} was the most oscillation seen in any trials.\r\n\r\n\t\\section{Conclusions}\r\n\t\\paragraph{}\r\n\tIt is clear that neither solution curves match with the actual trend shown in Figure \\ref{USA CPI}. It is therefore clear that this model fails to accurately forecast the CPI in the US for any years after its initial condition. In order to improve the accuracy and effectiveness of the model, several steps can be taken.\r\n\t\\begin{enumerate}\r\n\t\\item Find a fit better than logistic decay. Figure \\ref{Logistic Fit} demonstrates that the data does fit logistic decay, but it also clearly shows that the fit is poor, and may be coincidental.\r\n\t\\item Improve interaction term with coefficients b and m. This term is likely too simple to model the complexity of this problem, and should model the real-world impact of postive-negative interaction between administrations more accurately.\r\n\t\\end{enumerate}\r\n\tIt is not clear yet to say that the universal model of interaction is a poor skeleton to use for this problem. This model's assumptions seem to correctly interpret the trend CPI would have given competitive vs cooperative administrations. The model's terms have not accurately portraited the complexity of the problem, and additions to the current assumptions should be made.\r\n\r\n\\end{document}", "meta": {"hexsha": "77288801d76ceed51b089916af6b229dbe5ec251", "size": 9271, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Math 1360 Term Project.tex", "max_stars_repo_name": "Jwoll22/US-CPI-Lotka-Volterra", "max_stars_repo_head_hexsha": "566c8a50c0cb2235b8dfd9f47dccc21ef1363c03", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Math 1360 Term Project.tex", "max_issues_repo_name": "Jwoll22/US-CPI-Lotka-Volterra", "max_issues_repo_head_hexsha": "566c8a50c0cb2235b8dfd9f47dccc21ef1363c03", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Math 1360 Term Project.tex", "max_forks_repo_name": "Jwoll22/US-CPI-Lotka-Volterra", "max_forks_repo_head_hexsha": "566c8a50c0cb2235b8dfd9f47dccc21ef1363c03", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.7067669173, "max_line_length": 723, "alphanum_fraction": 0.7600043145, "num_tokens": 2352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043814, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4260356661748741}}
{"text": "\\documentclass[10pt,letterpaper,notitlepage]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\\usepackage{float}\n\\usepackage{cite}\n\\usepackage{fancyvrb}\n\n\\usepackage[ruled,vlined]{algorithm2e}\n\n\n\\usepackage[left=0.75in, right=0.75in, bottom=1.0in,top=0.75in]{geometry}\n\n%\\usepackage{caption} \n%\\captionsetup[table]{skip=10pt}\n%\\usepackage[font=small,labelfont=bf]{caption}\n\n\\usepackage{comment}\n\\usepackage{listings}\n\n\\usepackage{color}\n\\definecolor{Brown}{cmyk}{0,0.81,1,0.60}\n\\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}\n\\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}\n\n\\usepackage{multicol}\n\n\\usepackage{appendix}\n\n\\usepackage{fancyhdr}\n%\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=black,bookmarksopen=true,bookmarks]{hyperref}\n\\usepackage{bookmark}\n\n\\numberwithin{equation}{section} \n\n\n%============================= Put document title here\n\\newcommand{\\DOCTITLE}{Compressible inviscid fluid flow solver using the MUSCLE-Hancock method and a HLLC Riemann solver.}  \n\n%=============================  Load list of user-defined commands\n% Mark URL's\n\\newcommand{\\URL}[1]{{\\textcolor{blue}{#1}}}\n%\n% Ways of grouping things\n%\n\\newcommand{\\bracket}[1]{\\left[ #1 \\right]}\n\\newcommand{\\bracet}[1]{\\left\\{ #1 \\right\\}}\n\\newcommand{\\fn}[1]{\\left( #1 \\right)}\n\\newcommand{\\ave}[1]{\\left\\langle #1 \\right\\rangle}\n\\newcommand{\\norm}[1]{\\Arrowvert #1 \\Arrowvert}\n\\newcommand{\\abs}[1]{\\arrowvert #1 \\arrowvert}\n%\n% Partial derivative\n\\newcommand{\\partialderiv}[2]{\\frac{\\partial #1}{\\partial #2}}\n%\n% Bold quantities\n% \n\\newcommand{\\Omegabf}{\\mathbf{\\Omega}}\n\\newcommand{\\bnabla}{\\boldsymbol{\\nabla}}\n\\newcommand{\\position}{\\mathbf{x}}\n\\newcommand{\\velocity}{\\mathbf{u}}\n\\newcommand{\\dotp}{\\boldsymbol{\\cdot}}\n\n\\newcommand{\\uvec}[1]{\\boldsymbol{\\hat{\\textbf{#1}}}}\n\n\\newcommand{\\ihat}{\\uvec{\\i}}\n\\newcommand{\\jhat}{\\uvec{\\j}}\n\\newcommand{\\khat}{\\uvec{k}}\n\n\\newcommand{\\hatbf}[1]{\\hat{\\mathbf{#1}}}\n\n%\\newcommand{\\ihat}{\\boldsymbol{\\hat{\\textbf{\\i}}}}\n%\\newcommand{\\jhat}{\\boldsymbol{\\hat{\\textbf{\\j}}}}\n%\\newcommand{\\khat}{\\boldsymbol{\\hat{\\textbf{\\k}}}}\n\n%\\newcommand{\\ihat}{{\\bm{\\hat{\\textnormal{\\bfseries\\i}}}}}\n%\\newcommand{\\jhat}{{\\bm{\\hat{\\textnormal{\\bfseries\\j}}}}}\n%\\newcommand{\\khat}{{\\bm{\\hat{\\textnormal{\\bfseries\\k}}}}}\n%\n% Vector forms\n%\n\\renewcommand{\\vec}[1]{\\mbox{$\\stackrel{\\longrightarrow}{#1}$}}\n\\renewcommand{\\div}{\\mbox{$\\vec{\\mathbf{\\nabla}} \\cdot$}}\n\\newcommand{\\grad}{\\mbox{$\\vec{\\mathbf{\\nabla}}$}}\n\\newcommand{\\bb}[1]{\\bar{\\bar{#1}}}\n%\n% Vector forms boldfaced\n\\newcommand{\\bvec}[1]{\\mathbf{#1}}\n\\newcommand{\\bdiv}{\\boldsymbol{\\nabla} \\boldsymbol{\\cdot}}\n\\newcommand{\\bgrad}{\\bnabla}\n\\newcommand{\\mat}[1]{\\bar{\\bar{#1}}}\n%\n%\n% Equation beginnings and endings\n%\n% Un-numbered equation with alignment\n\\newcommand{\\beq}{\\begin{equation*} \\begin{aligned}}\n\\newcommand{\\eeq}{\\end{aligned}\\end{equation*}}\n% Numbered equation with alignment\n\\newcommand{\\beqn}{\\begin{equation}\\begin{aligned}}\n\\newcommand{\\eeqn}{\\end{aligned}\\end{equation}}  \n\n%\n% Quick commands for symbols\n%\n\\newcommand{\\Edensity}{\\mathcal{E}}\n\n\n\\newcommand{\\jcr}[1]{\\textcolor{magenta}{#1}}\n\\usepackage[normalem]{ulem}\n\\newcommand{\\ssout}[1]{\\sout{\\textcolor{magenta}{#1}}}\n\n%\n% Code syntax highlighting\n%\n%\\lstset{language=C++,frame=ltrb,framesep=2pt,basicstyle=\\linespread{0.8} \\small,\n%\tkeywordstyle=\\ttfamily\\color{OliveGreen},\n%\tidentifierstyle=\\ttfamily\\color{CadetBlue}\\bfseries,\n%\tcommentstyle=\\color{Brown},\n%\tstringstyle=\\ttfamily,\n%\tshowstringspaces=true,\n%\ttabsize=2,}\n\n\\lstset{language=C++,frame=ltrb,framesep=8pt,basicstyle=\\linespread{0.8} \\Large,\ncommentstyle=\\ttfamily\\color{OliveGreen},\nkeywordstyle=\\ttfamily\\color{blue},\nidentifierstyle=\\ttfamily\\color{CadetBlue}\\bfseries,\nstringstyle=\\ttfamily,\ntabsize=2,\nshowstringspaces=false,\nnumbers=left,\ncaptionpos=t}\n\n\\renewcommand{\\lstlistingname}{\\textbf{Code Snippet}}% Listing -> Code Snippet\n\n\n\\begin{document}\n\\noindent\n{\\LARGE\\textbf{\\DOCTITLE}}\n\\newline\n\\newline\n\\newline\n\\noindent\n{\\Large Jan I.C. Vermaak$^{1,2}$, Jim E. Morel$^{1,2}$}\n\\newline\n\\noindent\\rule{\\textwidth}{1pt}\n{\\small $^1$Center for Large Scale Scientific Simulations, Texas A\\&M Engineering Experiment Station, College Station, Texas, USA.}\n\\newline\\noindent\n{\\small $^2$Nuclear Engineering Department, Texas A\\&M University, College Station, Texas, USA.}\n\\newline\n\\newline\n\\textbf{Abstract:}\\newline\\noindent\nWork is work for some, but for some it is play.\n\\newline\n\\newline\\noindent\n{\\small\n\\textbf{Keywords:} hydrodynamics}\n\n\\section{Introduction}\nFor this research we develop a fluid flow solver for the solution of flow problems involving compressible inviscid ideal gases. The governing equations are the Euler equations defined as\n\\beqn \n\\partialderiv{\\rho}{t} + \\bnabla \\dotp (\\rho \\velocity) = 0\n\\eeqn \n\\beqn \n\\partialderiv{(\\rho\\velocity)}{t} + \\bnabla \\dotp \\{ \\rho \\velocity \\otimes \\velocity\\}  + \\bnabla p = \\mathbf{f}\n\\eeqn \n\\beqn \n\\partialderiv{E}{t} + \\bnabla \\dotp [(E + p)\\velocity] = q,\n\\eeqn \nwhere $\\rho$ is the fluid density, $\\velocity = [u_x, u_y, u_z] =[u,v,w]$ is the fluid velocity in cartesian coordinates, $p$ is the fluid pressure, $\\mathbf{f} = [f_x,f_y,f_z]$ is an arbitrary momentum-density source or sink, $E$ is the material energy-density comprising kinetic energy-density, $\\frac{1}{2} \\rho ||\\velocity||^2$, and internal energy-density, $\\rho e$, such that $E = \\frac{1}{2} \\rho ||\\velocity||^2 + \\rho e$, where $e$ is the specific internal energy. The value $q$ is an arbitrary energy-density source or sink.\n\nThe ideal gas law provides the closure relation\n\\beqn \np = (\\gamma - 1) \\rho e\n\\eeqn \nwhere $\\gamma$ is the ratio of the constant-pressure specific heat, $c_p$, to the constant-volume specific heat, $c_v$, i.e., $\\gamma = \\frac{c_p}{c_v}$, and is a material property.\n\n\\vspace{1cm}\n\\subsection{Notation in preparation for numerical schemes}\nThe conservation of mass-, momentum-, and energy equations can be written in the following form\n\\beqn \\label{eq:euler_operator_form}\n\\partialderiv{\\mathbf{U}}{t} + \n\\partialderiv{}{x}\\mathbf{F}(\\mathbf{U}) +\n\\partialderiv{}{y}\\mathbf{G}(\\mathbf{U}) +\n\\partialderiv{}{z}\\mathbf{H}(\\mathbf{U}) \n&= \n \\mathbf{Q} \\\\\n\\eeqn \nwhere\n\\beqn \n\\mathbf{U} = \n\\begin{bmatrix}\n\\rho \\\\ \n\\rho u \\\\\n\\rho v \\\\\n\\rho w \\\\ \nE\n\\end{bmatrix}\n, \\quad \n\\mathbf{F}(\\mathbf{U})=\n\\begin{bmatrix}\n\\rho u \\\\\n\\rho uu + p\\\\\n\\rho uv \\\\\n\\rho uw \\\\\nu(E+p)\n\\end{bmatrix}\n,\n\\mathbf{G}(\\mathbf{U})=\n\\begin{bmatrix}\n\\rho v \\\\\n\\rho v u \\\\\n\\rho vv + p \\\\\n\\rho vw \\\\\nv(E+p)\n\\end{bmatrix}\n,\n\\mathbf{H}(\\mathbf{U})=\n\\begin{bmatrix}\n\\rho w \\\\\n\\rho wu \\\\\n\\rho wv \\\\\n\\rho ww + p \\\\\nw(E+p)\n\\end{bmatrix}\n, \\text{ and }\n\\mathbf{Q} = \n\\begin{bmatrix}\n0 \\\\\nf_x \\\\\nf_y \\\\\nf_z \\\\\nq\n\\end{bmatrix}.\n\\eeqn \nThe $\\mathbf{U}$ vector is now a collection of the conserved variables, \nthe $\\mathbf{F}$, $\\mathbf{G}$ and $\\mathbf{H}$ vectors is representative of generic flux terms, and the $\\mathbf{Q}$ vector is a generic source term. We will be using this notation in the sections that follow.\n\n\n\\vspace{1cm}\n\\subsection{General Finite Volume discretization}\nConsider the cell volume, in 3D, shown in Figure \\ref{fig:faceorientation} below.\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.5\\linewidth]{figures/FaceOrientation}\n\\caption{Schematic of a multidimensional cell.}\n\\label{fig:faceorientation}\n\\end{figure}\n\n\\noindent\nWe first apply a spatial integration of Eq. \\eqref{eq:euler_operator_form} over the finite volume of a cell,\n\\beqn \n\\int_V \\biggr( \n\\partialderiv{\\mathbf{U}}{t} + \n\\bnabla \\dotp \\mathcal{F}(\\mathbf{U})\n\\biggr) dV &= \n\\int_V \\mathbf{Q} dV \\\\\n\\eeqn \nwhere $\\mathcal{F} (\\mathbf{U}) = \\big[\n\\mathbf{F}(\\mathbf{U}),\n\\mathbf{G}(\\mathbf{U}), \n\\mathbf{H}(\\mathbf{U})\n\\big]$. Next, using Gauss's divergence theorem, allows us to write\n\\beqn\n\\int_V \\partialderiv{\\mathbf{U}}{t}  dV \n+ \n\\int_S \\mathbf{n} \\dotp \\mathcal{F}  dA &= \n\\int_V \\mathbf{Q} dV .\n\\eeqn \nNow, using cell $c$ as the volume of integration, and assuming $\\mathbf{U}$ and $\\mathbf{Q}$ constant over the cell, with values $\\mathbf{U}_c$ and $\\mathbf{Q}_c$, the above equation becomes\n\\beqn \\label{eq:general_finite_volume}\nV_c \\partialderiv{\\mathbf{U}_c}{t} \n+ \n\\sum_{f=0}^{N_{f,c}{-}1} \n\\mathbf{A}_f \\dotp \\mathcal{F}_f\n= \nV_c \\mathbf{Q}_c.\n\\eeqn \nwhere $V_c$ is the volume of the cell, $N_{f,c}$ is the number of faces for cell $c$, $\\mathbf{A}_f$ is the area-vector of face $f$, which is the product of the face area, $A_f$, and the face normal, $\\mathbf{n}_f$ (i.e., $\\mathbf{A}_f = A_f \\mathbf{n}_f$), and $\\mathcal{F}_f = \\mathcal{F}(\\mathbf{U}_f)$ is the face flux vector.  The treatment of the $\\mathcal{F}_f$ term is the topic of the MUSCL-Hancock method which we detail in section \\ref{section:MHM}.\n\n\\vspace{1cm}\n\\subsection{Multidimensional transformation of interface fluxes} \\label{section:3dtransformation}\nMost of the Riemann solver schemes presented in \\cite{Toro} are for one dimensional geometries. A transformation technique is prescribed in \\cite{Toro}, using the rotational-invariant property of the fluid flow, that allows one to use the one dimensional formulations.\n\nGiven the arbitrary face area vector, $\\mathbf{A}_f=\\mathbf{n}_f A_f$, we first seek a rotation matrix, $R_{\\ihat}$, to rotate any vector about an axis $\\mathbf{a}_{\\ihat}$ such that it is aligned with $\\ihat$. To determine $R_{\\ihat}$ we first set the rotation axis as\n\\beqn \n\\mathbf{a}_{\\ihat} = \n\\begin{cases}\n\\dfrac{\\mathbf{n}_f \\times \\ihat}{||\\mathbf{n}_f \\times \\ihat||}, &\\text{ if } \\mathbf{n_f}\\dotp \\ihat < 1{-}\\epsilon \\\\\n\\jhat, &\\text{ if } \\mathbf{n_f}\\dotp \\ihat \\ge 1{-}\\epsilon\n\\end{cases}\n\\eeqn \nand the angle of rotation, $\\theta_{\\ihat}$, as\n\\beqn \n\\theta_{\\ihat} = \\arccos (\\mathbf{n}_f \\dotp \\ihat).\n\\eeqn \nWe then apply Rodrigues's formula as detailed in appendix \\ref{appendix:Roderigues_formula} to obtain $R_{\\ihat}$, the associated rotation matrix. With this matrix in hand we can form the general transformation matrix, $T_{\\ihat}$, defined as\n\\beqn\nT_{\\ihat} = \\text{diag}(1,R,1) = \n\\begin{bmatrix}\n1 & 0         & 0         & 0         & 0 \\\\\n0 & R_{00} & R_{01} & R_{02} & 0 \\\\\n0 & R_{10} & R_{11} & R_{12} & 0 \\\\\n0 & R_{20} & R_{21} & R_{22} & 0 \\\\\n0 & 0         & 0         & 0         & 1 \\\\\n\\end{bmatrix}\n\\eeqn\nwhich can be used to define \n\\beqn \n\\hatbf{F} (\\mathbf{U})= \\mathbf{F}(T_{\\ihat} \\mathbf{U})\n\\eeqn \nsuch that\n\\beqn \n\\mathbf{n}_f \\dotp \\mathcal{F}_f\n= \\mathbf{n} \\dotp [\n\\mathbf{F}(\\mathbf{U}_f),\n\\mathbf{G}(\\mathbf{U}_f),\n\\mathbf{H}(\\mathbf{U}_f)]\n=\nT_{\\ihat}^{-1} \\hatbf{F}_f\n\\eeqn \nwhere we also define\n\\beqn \n\\mathbf{F}^*(\\mathbf{U}) = T_{\\ihat}^{-1} \\hatbf{F} (\\mathbf{U})\n\\eeqn \nallowing us to write Eq. \\eqref{eq:general_finite_volume} as \n\\beqn \n\\partialderiv{\\mathbf{U}_c}{t} \n+ \n\\frac{1}{V_c}\n\\sum_{f=0}^{N_{f,c}{-}1} \nA_f  \\mathbf{F}_f^*\n=  \\mathbf{Q}_c.\n\\eeqn \nIn this form any Riemann solver can simply be supplied with $\\mathbf{U}$ for the cells on either side of an interface, and the face normal, $\\mathbf{n}_f$, in order to use the classical one dimensional formulations contained in \\cite{Toro}. The given Riemann solver will then produce the appropriate value for $\\mathbf{F}_f^*$.\n\n\n\n%\\vspace{1cm}\n%\\subsection{One dimensional Finite Volume discretization}\n%In one dimension we will be using the indexing scheme as shown in Figure \\ref{fig:mesh1d} below. Cell indices are $i\\in[0, N_c-1]$ where $N_c$ is the number of cells in the problem. The indices also indicate a cell's position from left to right, $i{=}0$ denoting the left-most cell and $i{=}N_c{-1}$ denoting the right-most cell. Throughout this research we will also use \\textit{virtual nodes} to indicate the interfaces between cells, these will be denoted with half indices, i.e., $i{=}\\frac{1}{2}$ denotes the interface between cell $i=0$ and cell $i=1$.\n%\\begin{figure}[H]\n%\\centering\n%\\includegraphics[width=1.0\\linewidth]{figures/Mesh1D}\n%\\caption{One dimensional mesh description.}\n%\\label{fig:mesh1d}\n%\\end{figure}\n%Using this indexing scheme allows us to write Eq. \\eqref{eq:general_finite_volume} as\n%\\beqn \n%\\partialderiv{\\mathbf{U}_i}{t} + \\frac{\\ihat}{\\Delta x_i}  \\dotp\n%\\biggr(\n%\\mathbf{F}_{i{+}\\frac{1}{2}} - \\mathbf{F}_{i{-}\\frac{1}{2}}\n%\\biggr)\n%= \\mathbf{Q}_i\n%\\eeqn \n%where $\\mathbf{F}_{i{+}\\frac{1}{2}}$ and $\\mathbf{F}_{i{-}\\frac{1}{2}}$ are now the interface flux terms and are not yet defined. The definition of these interface fluxes is the topic of next section.\n\n\n\\vspace{1cm}\n\\section{MUSCL-Hancock Method (MHM)} \\label{section:MHM}\nThe MUSCL-Hancock method is conceptually simple. It prescribes how the interface fluxes are to be computed at the beginning of a time step and then how to supply the necessary inputs to a Riemann-solver for the computation of the preserved variables at the end of the timestep.\n\nMUSCL stands for Monotone Upstream-centered Scheme for Conservation Laws. The scheme as modified by S. Hancock gives the method its name. We will refer to this method by using the abbreviation $MHM$.\n\\newline\n\\newline\n\\noindent\nA single time step using MHM involves four basic steps.\n\n\\subsection{Step 1 - Compute the maximum timestep}\nGenerally, the time step size, $\\Delta t$, needs to be limited in order to ensure numerical stability. The Courant-Friedrichs-Lewy (CFL) condition is the ratio\n\\beqn \n\\frac{||\\mathbf{u}|| \\Delta t}{L_c} \\le CFL,\n\\eeqn \nwhere $L_c$ is the characteristic length of cell $c$ and the value of $CFL$ is subject to the relevant numerical scheme under consideration. For explicit schemes the value of $CFL$ is generally less than 1. When $CFL=1$ the above expression indicates that the distance traveled by a unit of information, traveling at a velocity $\\mathbf{u}$, over a time period $\\Delta t$, cannot exceed the length of a cell. \n\nBy specifying the value of $CFL$ the CFL-limited time step size for cell $c$, $\\Delta t_{hydro,c}$, is then\n\\beqn \n\\Delta t_{hydro,c} = \\frac{CFL \\ L_c}{||\\mathbf{u}||}\n\\eeqn \nwhere $||\\mathbf{u}||$ has not yet been resolved. One option for $\\mathbf{u}$ is to use the maximum possible wave speed based on the velocity and sound speed in cell $c$, $\\mathbf{u}_c$ and $a_c$ respectively, as\n\\beqn \n||\\mathbf{u}||= ||\\mathbf{u}_c|| + a_c,\n\\eeqn\nwhere\n\\beqn \na_c = \\sqrt{\\frac{\\gamma_c p_c}{\\rho_c}}.\n\\eeqn \nThe simulation time-step size-limit, $\\Delta t_{hydro}$, is then \n\\beqn \n\\Delta t_{hydro} = \\min_c \\biggr(\\Delta t_{hydro,c}\\biggr).\n\\eeqn \n\nFor finer control of the simulation the user may also specify a maximum time step size, $\\Delta t_{max}$. Finally, the simulation time step size, $\\Delta t$, is then\n\\beqn \n\\Delta t = \\max \\biggr( \\Delta t_{max}, \\Delta t_{hydro}\\biggr).\n\\eeqn \n\n\n\\subsection{Step 2 - Estimate the gradient $\\bnabla \\mathbf{U}$}\nProvided that an orthogonal mush is used, the gradient can be estimated in each cell $c$ from\n\\beqn \\label{eq:gradient}\n\\big\\{ \\bnabla \\mathbf{U} \\big\\}_c^n\n\\approx\n\\frac{1}{V_c}\n\\sum_{f=0}^{N_{f,c}{-1}}  \n\\biggr\\{\n\\mathbf{A}_f \\otimes\n\\biggr(\n\\frac{||\\position_f - \\position_c||}{||\\position_{cn} - \\position_c||} \\mathbf{U}_c^n\n+\n\\frac{||\\position_c - \\position_f||}{||\\position_{cn} - \\position_c||} \\mathbf{U}_{cn}^n\n\\biggr)\n\\biggr\\},\n\\eeqn \nwhere $V_c$ is the volume of cell $c$, $N_{f,c}$ is the number of faces for cell $c$, $A_f$ the face area-vector of face $f$ (i.e., $\\mathbf{A}_f = A_f \\mathbf{n}_f$), $\\position_{cn}$ is the centroid of the neighboring cell $cn$ at face $f$, and finally $\\mathbf{U}_{cn}$ is the finite volume cell-constant value of $\\mathbf{U}$ for cell $cn$. For non-orthogonal meshes the gradient can be corrected as shown in \\cite{Moukalled}.\n\\newline \n\\newline\n\\textbf{Limiting:}\\newline\nThe cell-wise gradients computed in Eq. \\eqref{eq:gradient} requires limiting to avoid numerical oscillations. The chosen limiting scheme, to ensure specific properties when coupled with radiation transport (i.e., asymptotic diffusion limit), is the double minmod limiter, as prescribed in \\cite{McClarrenSlopes}. The definition of the double minmod limiter in \\cite{McClarrenSlopes} is either misleading or incorrectly defined as it implies that all gradients are limited to $\\ge 0$, therefore we define this limiter in detail here based on the cited literature of \\cite{McClarrenSlopes}.\n\nThe \\textbf{general vector-based minmod limiter}, for an $M$ amount of vectors with each vector having $N$ elements, is defined as\n\\beqn\n\\text{minmod}(\\mathbf{U}^0, \\dots, \\mathbf{U}^{M-1}) = \n\\begin{bmatrix}\n\t\\text{minmod}(U_0^0, \\dots, U_0^{M-1}) \\\\\n\t\\vdots \\\\\n\t\\text{minmod}(U_{N-1}^0, \\dots, U_{N-1}^{M-1})\n\\end{bmatrix},\n\\eeqn \nwhere $U_n^m$ denotes the $n$-th entry of the $m$-th vector. The \\textbf{general scalar-based minmod limiter}, for $M$ amount of scalar elements, is defined as\n\\beqn \n\\text{minmod}(c_0, \\dots, c_{M-1}) = \n\\begin{cases}\n\t0, &\\text{ if } \\text{sign}(a_0) \\ne  \\text{sign}(a_m) \\text{ for any } m \\\\\n\t\\min(a_0, \\dots, a_{M-1}), &\\text{ if } a_m > 0 \\text{ for all } m \\\\\n\t\\max(a_0, \\dots, a_{M-1}), &\\text{ if } a_m < 0 \\text{ for all } m \\\\\n\\end{cases}.\n\\eeqn \nThese two general limiters are used to define the \\textbf{double minmod limiter} for the gradient of cell $c$, which has $M$ amount of neighbor cells.\n\\beqn \n\\text{double minmod limited }\\big\\{ \\bnabla \\mathbf{U} \\big\\}_c^n = \n\t\\text{minmod}\\biggr(\n\t\\big\\{ \\bnabla \\mathbf{U} \\big\\}_{c}^n,\n\t\\alpha \\bigg\\{ \\position_{ccn,x} \\otimes\n\t\\dfrac{\\mathbf{U}_{cn} - \\mathbf{U}_c}{||\\position_{ccn}||^2} \\bigg\\} \\text{ for all } cn\\in[0,M-1]\n\t\\biggr) \n\\eeqn \nwhere $\\position_{ccn} = \\position_{cn} - \\position_c$ and $\\alpha{=2}$ denoting the ``double''. When $\\alpha{=0}$ the scheme reduces to the unlimited scheme and if $\\alpha{=1}$ the scheme is the standard minmod limiter.\n\n\\newpage\n\\subsection{Step 3 - Advance the conserved variables by half a time step}\nAdvance the cell-centered values over half a time step as\n\\beqn \n\\mathbf{U}_c^{n{+}\\frac{1}{2}} = \\mathbf{U}_c^n - \\frac{\\frac{1}{2}\\Delta t^n}{V_c} \\sum_{f=0}^{N_{f,c}{-1}} \n\\biggr(\nA_f \\mathbf{F}_f^{*n}\n\\biggr)\n+ \\frac{1}{2}\\Delta t^n \\mathbf{Q}.\n\\eeqn \nwhere $\\mathbf{F}_f^{*n} = \\mathbf{F}^*(\\mathbf{U}_f^n) $. $\\mathbf{U}_f^n$ is extrapolated from $\\mathbf{U}_c^n$ as\n\\beqn \n\\mathbf{U}_f^{n} = \\mathbf{U}_c^{n}  + (\\position_{f} - \\position_c) \\dotp \\big\\{ \\bnabla \\mathbf{U} \\big\\}_c^n\n\\eeqn \nwhere $\\position_f$ is the face-centroid.\n\n\n\\subsection{Step 4 - Execute a series of Riemann solvers}\nA Riemann solver computes the interface fluxes, $\\mathbf{F}_f^{*\\mathcal{R},n{+}\\frac{1}{2}}$, using $\\mathbf{U}_c^{n{+}\\frac{1}{2}}$, where $\\mathcal{R}$ denotes the specific Riemann solver. These interface fluxes are then used to advance the conserved variables by a single timestep as\n\\beqn \n\\mathbf{U}_c^{n+1} = \\mathbf{U}_c^n - \\frac{\\Delta t^n}{V_c} \\sum_{f=0}^{N_{f,c}{-1}} \n\\biggr(\nA_f\n\\mathbf{F}_f^{*\\mathcal{R},n{+}\\frac{1}{2}}\n\\biggr)\n+ \\Delta t^n \\mathbf{Q}.\n\\eeqn \nThe discontinuity across a face is treated as a one dimensional problem with a left and right side having different values for $\\mathbf{U}$, i.e., $\\mathbf{U}_L = \\mathbf{U}_{f,c}^{n{+}\\frac{1}{2}}$ and $\\mathbf{U}_R = \\mathbf{U}_{f,cn}^{n{+}\\frac{1}{2}}$ for the left and right side respectively. The face values of $\\mathbf{U}$ are extrapolated using the gradient $\\{\\bnabla\\mathbf{U}\\}^n$ such that\n\\begin{subequations}\n\\begin{equation}\n\\mathbf{U}_{f,c}^{n} = \\mathbf{U}_c^{n+\\frac{1}{2}}  + (\\position_{f} - \\position_c) \\dotp \\big\\{ \\bnabla \\mathbf{U} \\big\\}_c^n\n\\end{equation}\n\\begin{equation}\n\\mathbf{U}_{f,cn}^{n} = \\mathbf{U}_{cn}^{n+\\frac{1}{2}}  + (\\position_{f} - \\position_{cn}) \\dotp \\big\\{ \\bnabla \\mathbf{U} \\big\\}_{cn}^n.\n\\end{equation}\n\\end{subequations}\n\n\n\n\nWhen using the HLLC solver, as described in \\cite{Toro}, the Riemann solver will compute $\\mathbf{F}_f^{*hllc,n{+}\\frac{1}{2}}$ after which we compute the conserved variables at $n+1$ from\n\\beqn \n\\mathbf{U}_c^{n+1} = \\mathbf{U}_c^n - \\frac{\\Delta t^n}{V_c} \\sum_{f=0}^{N_{f,c}{-1}} \n\\biggr(\nA_f\n\\mathbf{F}_f^{*hllc,n{+}\\frac{1}{2}}\n\\biggr)\n+ \\Delta t^n \\mathbf{Q}.\n\\eeqn \nThe HLLC Riemann solver is detailed in section \\ref{section:HLLC}.\n\n\\newpage \n\\section{The HLLC Approximate Riemann Solver} \\label{section:HLLC}\nThe Harten, Lax and van Leer (HLL) solver scheme was developed in 1983 \\cite{Toro} and requires estimates for the fastest wave/signal/shock velocities emerging from a discontinuity. Later Toro, Spruce and Speares proposed the Harten, Lax, van Leer, \\textit{Contact} (HLLC) scheme \\cite{Toro} which adds another wave to the problem.\n\\newline\n\\newline\nThe first input, required by the HLLC Riemann solver, is the face normal, $\\mathbf{n}_f$, which allows us to compute the transformation matrix, $T_{\\ihat}$, as per section \\ref{section:3dtransformation}. The other input parameters are then\n\\beqn \n\\mathbf{U}_L &= T_{\\ihat} \\mathbf{U}_{f,c}^{n{+}\\frac{1}{2}}, \\\\\n\\mathbf{U}_R &= T_{\\ihat} \\mathbf{U}_{f,cn}^{n{+}\\frac{1}{2}}, \\\\\n\\mathbf{F}_L &= \\mathbf{F}(T_{\\ihat} \\mathbf{U}_{f,c}^{n{+}\\frac{1}{2}}), \\\\\n\\mathbf{F}_R &= \\mathbf{F}(T_{\\ihat} \\mathbf{U}_{f,cn}^{n{+}\\frac{1}{2}}), \\\\\np_L &= p_c, \\quad \\gamma_L = \\gamma_c,\\\\\np_R &= p_{cn}, \\quad \\gamma_R = \\gamma_{cn},\n\\eeqn \nwhere the quantifies denoted with $c$ denotes those belonging to the cell which maintains a negative sense with respect to face $f$, and conversely $cn$ denotes the quantities associated with the cell maintaining a positive sense with respect to the face.\n\n\n\\subsection{Left and right wave speed estimation}\nThe HLLC Riemann solver is predicated on knowing an estimate for wave speeds $S_L$ and $S_R$, which we estimate as\n\\beqn \nS_L = \\min(u_L-a_L, u_R-a_R)\n\\eeqn \nand\n\\beqn \nS_R = \\max(u_L+a_L,u_R+a_R).\n\\eeqn \nwhere $a_L$ and $a_R$ are the sound speeds associated with the left- and right conserved variables as\n\\beqn \na = \\sqrt{\\frac{\\gamma p}{\\rho}}.\n\\eeqn \nNext we require the contact wave speed.\n\n\\subsection{Contact wave speed}\nThe contact wave speed, $S_*$, is given by\n\\beqn \nS_* = \\frac{p_R - p_L +\\rho_L u_L(S_L-u_L) - \\rho_R u_R(S_R-u_R)}\n{\\rho_L (S_L-u_L) - \\rho_R(S_R-u_R)}.\n\\eeqn \n\n\\subsection{Intermediate fluxes}\nAs per \\cite{Toro} the intermediate fluxes, $\\mathbf{F}_{*L}$ and $\\mathbf{F}_{*R}$ are given by\n\\beqn \nF_{*K} = \n\\frac\n{S_* (S_K \\mathbf{U}_K - \\mathbf{F}_K) + S_K(p_K+\\rho_L(S_K-u_K)(S_*-u_K))D_*}\n{S_K - S_*}\n\\eeqn \nfor $K=L$ and $K=R$. The vector $\\mathbf{D}_*$ is a vector such that\n\\beqn \n\\mathbf{F}(\\mathbf{U}) = u \\mathbf{U} + p\\mathbf{D},\n\\eeqn \ntherefore \n\\beqn \n\\mathbf{D}_* = [0,1,0,0,S_*]^T\n\\eeqn \n\n\\subsection{Interface flux}\nThe interface flux $\\mathbf{F}_f^{*hllc}$ is now given by\n\\beqn \n\\mathbf{F}_f^{*hllc} &= \nT_{\\ihat}^{-1} \\mathbf{F}_f^{hllc}  \\\\\n\\mathbf{F}_f^{hllc} &= \n\\begin{cases}\n\\mathbf{F}_L &,\\text{ if } S_L \\ge 0, \\\\\n\\mathbf{F}_{*L} &,\\text{ if } S_L \\le 0 \\le S_*, \\\\\n\\mathbf{F}_{*R} &,\\text{ if } S_* \\le 0 \\le S_R, \\\\\n\\mathbf{F}_R &,\\text{ if } S_R \\le 0\n\\end{cases}\n\\eeqn \n\n\\vspace{1cm}\n\\section{Verification - Sod shock tube problem}\nThe Sod shock tube problem is a simple problem with the following specifications:\n\\begin{itemize}\n\t\\item The one dimensional problem domain has a total size of 1.0 spanning $x\\in[-\\frac{1}{2},\\frac{1}{2}]$.\n\t\\item The left-half of the problem has an initial state denoted with $L$ and the right-half has an initial state denoted with $R$.\n\t\\item At time $t=0$:\n\t\\begin{itemize}\n\t\t\\item Densities: $\\rho_L = 1$, $\\rho_R = 0.125$\n\t\t\\item Pressures: $p_L=1$, $p_R=0.1$\n\t\t\\item Velocity: $u=0 \\ \\forall x$  \n\t\t\\item Ratio of specific heats: $\\gamma=1.4 \\ \\forall x$\n\t\t\\item Boundary conditions: Transmissive\n\t\\end{itemize} \n\\end{itemize}\n\nAs time evolves the problem exhibits a shock-wave, a contact-wave and a rarefaction-wave. The analytical solution has been obtain from a Fortran code by Timmers \\cite{Timmers}. At time $t=0.2$ the analytical solution for $\\rho$, $p$, $u$ and $e$ is tabulated over 500 points in appendix \\ref{appendix:sodanasol}.\n\nThe MHM-HLLC scheme employed above has been executed with the following inputs:\n\\begin{itemize}\n\t\\item $\\Delta t_{max}=1e-2$\n\t\\item $CFL=0.3$\n\t\\item Maximum number of timesteps, $2000$\n\t\\item Maximum total time, $0.2$\n\t\\item $\\Delta x=0.01$ or 100 cells.\n\\end{itemize}\nThe program reached the maximum total time after 73 iterations and the results at $t=0.2$ is compared to the analytical solution in Figure \\ref{fig:compinfflow1dtest1output}.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=1.0\\linewidth]{figures/CompInFFlow1D_Test1_output.png}\n\t\\caption{Numerical results compared to the analytical results at $t=0.2$.}\n\t\\label{fig:compinfflow1dtest1output}\n\\end{figure}\n\n\n\\newpage\n\\begin{thebibliography}{1}\n\t\n%\t\\bibitem{LewisMiller} Lewis E.E., Miller W.F., {\\em Computational Methods of Neutron Transport}, JohnWiley \\& Sons, 1984\n\t\n\t\\bibitem{Toro} Toro E.F., {\\em Riemann Solvers and Numerical Methods for Fluid Dynamics - A Practical Introduction}, third edition, Springer, 2009.\n\t\n\t\\bibitem{Moukalled} Moukalled F.,  Mangani L., Darwish M., {\\em The Finite Volume Method in Computational Fluid Dynamics - An Advanced Introduction withOpenFOAM® and Matlab®}, Springer, 2016.\n\t\n\t\\bibitem{McClarrenSlopes} McClarren R.G., Lowrie R.B., {\\em The effects of slope limiting on asymptotic-preserving numerical methods for hyperbolic conservation laws}, Journal of Computational Physics, vol 227 p9711-9726, 2008.\n\t\n\t\\bibitem{Timmers} Timmers F.X., {\\em Exact Riemann Solver}, Website: https://cococubed.com/code\\_pages/exact\\_riemann.shtml, accessed April 22, 2022.\n\t\n\t   \n\\end{thebibliography}\n\n\\newpage\n\\begin{appendices}\n\\section{Roderigues's formula} \\label{appendix:Roderigues_formula}\nRoderigues' formula for the rotation of a vector $\\mathbf{v}$ about a unit vector $\\mathbf{a}$ with right-hand rule\n\\begin{equation}\n\\newcommand{\\vvec}{\\mathbf{v}}\n\\newcommand{\\avec}{\\mathbf{a}}\n\\begin{aligned}\n\\vvec_{rotated} &= \\cos \\theta \\vvec + (\\avec \\dotp \\vvec)(1-\\cos \\theta) \\avec + \\sin \\theta (\\avec \\times \\vvec)\n\\end{aligned}\n\\end{equation}\nIn matrix form\n\\beqn \n\\mathbf{v}_{rotated} = A \\mathbf{v}\n\\eeqn \nwhere\n\\beqn \nA = \n\\begin{bmatrix}\n0 & -a_z & a_y \\\\\na_z & 0 & -a_x \\\\\n-a_y & a_x & 0\n\\end{bmatrix}\n\\eeqn \nand\n\\beqn \nR = I + \\sin\\theta A + (1-\\cos\\theta) A^2\n\\eeqn\n\n\n\\section{Sod shock tube problem - analytical solution at $t=0.2$} \\label{appendix:sodanasol}\n{\\scriptsize \n\\begin{verbatim}\n   i           x    density     pressure    velocity    energy      i           x    density     pressure    velocity    energy \n   1   -5.00E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  251    1.00E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   2   -4.98E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  252    3.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   3   -4.96E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  253    5.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   4   -4.94E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  254    7.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   5   -4.92E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  255    9.02E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   6   -4.90E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  256    1.10E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   7   -4.88E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  257    1.30E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   8   -4.86E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  258    1.50E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n   9   -4.84E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  259    1.70E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  10   -4.82E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  260    1.90E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  11   -4.80E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  261    2.10E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  12   -4.78E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  262    2.30E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  13   -4.76E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  263    2.51E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  14   -4.74E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  264    2.71E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  15   -4.72E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  265    2.91E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  16   -4.70E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  266    3.11E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  17   -4.68E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  267    3.31E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  18   -4.66E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  268    3.51E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  19   -4.64E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  269    3.71E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  20   -4.62E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  270    3.91E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  21   -4.60E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  271    4.11E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  22   -4.58E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  272    4.31E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  23   -4.56E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  273    4.51E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  24   -4.54E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  274    4.71E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  25   -4.52E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  275    4.91E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  26   -4.50E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  276    5.11E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  27   -4.48E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  277    5.31E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  28   -4.46E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  278    5.51E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  29   -4.44E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  279    5.71E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  30   -4.42E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  280    5.91E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  31   -4.40E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  281    6.11E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  32   -4.38E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  282    6.31E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  33   -4.36E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  283    6.51E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  34   -4.34E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  284    6.71E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  35   -4.32E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  285    6.91E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  36   -4.30E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  286    7.11E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  37   -4.28E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  287    7.31E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  38   -4.26E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  288    7.52E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  39   -4.24E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  289    7.72E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  40   -4.22E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  290    7.92E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  41   -4.20E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  291    8.12E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  42   -4.18E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  292    8.32E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  43   -4.16E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  293    8.52E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  44   -4.14E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  294    8.72E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  45   -4.12E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  295    8.92E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  46   -4.10E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  296    9.12E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  47   -4.08E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  297    9.32E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  48   -4.06E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  298    9.52E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  49   -4.04E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  299    9.72E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  50   -4.02E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  300    9.92E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  51   -4.00E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  301    1.01E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  52   -3.98E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  302    1.03E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  53   -3.96E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  303    1.05E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  54   -3.94E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  304    1.07E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  55   -3.92E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  305    1.09E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  56   -3.90E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  306    1.11E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  57   -3.88E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  307    1.13E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  58   -3.86E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  308    1.15E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  59   -3.84E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  309    1.17E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  60   -3.82E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  310    1.19E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  61   -3.80E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  311    1.21E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  62   -3.78E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  312    1.23E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  63   -3.76E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  313    1.25E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  64   -3.74E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  314    1.27E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  65   -3.72E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  315    1.29E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  66   -3.70E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  316    1.31E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  67   -3.68E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  317    1.33E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  68   -3.66E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  318    1.35E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  69   -3.64E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  319    1.37E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  70   -3.62E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  320    1.39E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  71   -3.60E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  321    1.41E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  72   -3.58E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  322    1.43E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  73   -3.56E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  323    1.45E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  74   -3.54E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  324    1.47E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  75   -3.52E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  325    1.49E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  76   -3.50E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  326    1.51E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  77   -3.48E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  327    1.53E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  78   -3.46E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  328    1.55E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  79   -3.44E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  329    1.57E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  80   -3.42E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  330    1.59E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  81   -3.40E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  331    1.61E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  82   -3.38E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  332    1.63E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  83   -3.36E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  333    1.65E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  84   -3.34E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  334    1.67E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  85   -3.32E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  335    1.69E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  86   -3.30E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  336    1.71E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  87   -3.28E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  337    1.73E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  88   -3.26E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  338    1.75E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  89   -3.24E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  339    1.77E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  90   -3.22E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  340    1.79E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  91   -3.20E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  341    1.81E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  92   -3.18E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  342    1.83E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  93   -3.16E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  343    1.85E-01    4.26E-01    3.03E-01    9.27E-01    1.78E+00\n  94   -3.14E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  344    1.87E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n  95   -3.12E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  345    1.89E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n  96   -3.10E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  346    1.91E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n  97   -3.08E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  347    1.93E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n  98   -3.06E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  348    1.95E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n  99   -3.04E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  349    1.97E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 100   -3.02E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  350    1.99E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 101   -3.00E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  351    2.01E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 102   -2.98E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  352    2.03E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 103   -2.96E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  353    2.05E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 104   -2.94E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  354    2.07E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 105   -2.92E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  355    2.09E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 106   -2.90E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  356    2.11E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 107   -2.88E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  357    2.13E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 108   -2.86E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  358    2.15E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 109   -2.84E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  359    2.17E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 110   -2.82E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  360    2.19E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 111   -2.80E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  361    2.21E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 112   -2.78E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  362    2.23E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 113   -2.76E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  363    2.25E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 114   -2.74E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  364    2.27E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 115   -2.72E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  365    2.29E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 116   -2.70E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  366    2.31E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 117   -2.68E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  367    2.33E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 118   -2.66E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  368    2.35E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 119   -2.64E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  369    2.37E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 120   -2.62E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  370    2.39E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 121   -2.60E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  371    2.41E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 122   -2.58E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  372    2.43E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 123   -2.56E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  373    2.45E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 124   -2.54E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  374    2.47E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 125   -2.52E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  375    2.49E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 126   -2.49E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  376    2.52E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 127   -2.47E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  377    2.54E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 128   -2.45E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  378    2.56E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 129   -2.43E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  379    2.58E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 130   -2.41E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  380    2.60E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 131   -2.39E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  381    2.62E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 132   -2.37E-01    1.00E+00    1.00E+00    0.00E+00    2.50E+00  382    2.64E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 133   -2.35E-01    9.96E-01    9.94E-01    4.88E-03    2.50E+00  383    2.66E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 134   -2.33E-01    9.89E-01    9.84E-01    1.32E-02    2.49E+00  384    2.68E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 135   -2.31E-01    9.82E-01    9.75E-01    2.16E-02    2.48E+00  385    2.70E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 136   -2.29E-01    9.75E-01    9.65E-01    2.99E-02    2.47E+00  386    2.72E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 137   -2.27E-01    9.68E-01    9.56E-01    3.83E-02    2.47E+00  387    2.74E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 138   -2.25E-01    9.61E-01    9.46E-01    4.66E-02    2.46E+00  388    2.76E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 139   -2.23E-01    9.54E-01    9.37E-01    5.50E-02    2.45E+00  389    2.78E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 140   -2.21E-01    9.48E-01    9.27E-01    6.33E-02    2.45E+00  390    2.80E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 141   -2.19E-01    9.41E-01    9.18E-01    7.17E-02    2.44E+00  391    2.82E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 142   -2.17E-01    9.34E-01    9.09E-01    8.00E-02    2.43E+00  392    2.84E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 143   -2.15E-01    9.28E-01    9.00E-01    8.84E-02    2.43E+00  393    2.86E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 144   -2.13E-01    9.21E-01    8.91E-01    9.67E-02    2.42E+00  394    2.88E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 145   -2.11E-01    9.14E-01    8.82E-01    1.05E-01    2.41E+00  395    2.90E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 146   -2.09E-01    9.08E-01    8.73E-01    1.13E-01    2.41E+00  396    2.92E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 147   -2.07E-01    9.01E-01    8.65E-01    1.22E-01    2.40E+00  397    2.94E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 148   -2.05E-01    8.95E-01    8.56E-01    1.30E-01    2.39E+00  398    2.96E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 149   -2.03E-01    8.88E-01    8.47E-01    1.38E-01    2.38E+00  399    2.98E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 150   -2.01E-01    8.82E-01    8.39E-01    1.47E-01    2.38E+00  400    3.00E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 151   -1.99E-01    8.76E-01    8.30E-01    1.55E-01    2.37E+00  401    3.02E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 152   -1.97E-01    8.69E-01    8.22E-01    1.64E-01    2.36E+00  402    3.04E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 153   -1.95E-01    8.63E-01    8.14E-01    1.72E-01    2.36E+00  403    3.06E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 154   -1.93E-01    8.57E-01    8.05E-01    1.80E-01    2.35E+00  404    3.08E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 155   -1.91E-01    8.50E-01    7.97E-01    1.89E-01    2.34E+00  405    3.10E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 156   -1.89E-01    8.44E-01    7.89E-01    1.97E-01    2.34E+00  406    3.12E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 157   -1.87E-01    8.38E-01    7.81E-01    2.05E-01    2.33E+00  407    3.14E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 158   -1.85E-01    8.32E-01    7.73E-01    2.14E-01    2.32E+00  408    3.16E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 159   -1.83E-01    8.26E-01    7.65E-01    2.22E-01    2.32E+00  409    3.18E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 160   -1.81E-01    8.20E-01    7.57E-01    2.30E-01    2.31E+00  410    3.20E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 161   -1.79E-01    8.14E-01    7.50E-01    2.39E-01    2.30E+00  411    3.22E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 162   -1.77E-01    8.08E-01    7.42E-01    2.47E-01    2.30E+00  412    3.24E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 163   -1.75E-01    8.02E-01    7.34E-01    2.55E-01    2.29E+00  413    3.26E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 164   -1.73E-01    7.96E-01    7.27E-01    2.64E-01    2.28E+00  414    3.28E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 165   -1.71E-01    7.90E-01    7.19E-01    2.72E-01    2.28E+00  415    3.30E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 166   -1.69E-01    7.84E-01    7.12E-01    2.80E-01    2.27E+00  416    3.32E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 167   -1.67E-01    7.79E-01    7.04E-01    2.89E-01    2.26E+00  417    3.34E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 168   -1.65E-01    7.73E-01    6.97E-01    2.97E-01    2.26E+00  418    3.36E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 169   -1.63E-01    7.67E-01    6.90E-01    3.05E-01    2.25E+00  419    3.38E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 170   -1.61E-01    7.61E-01    6.83E-01    3.14E-01    2.24E+00  420    3.40E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 171   -1.59E-01    7.56E-01    6.76E-01    3.22E-01    2.24E+00  421    3.42E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 172   -1.57E-01    7.50E-01    6.69E-01    3.31E-01    2.23E+00  422    3.44E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 173   -1.55E-01    7.45E-01    6.62E-01    3.39E-01    2.22E+00  423    3.46E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 174   -1.53E-01    7.39E-01    6.55E-01    3.47E-01    2.22E+00  424    3.48E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 175   -1.51E-01    7.33E-01    6.48E-01    3.56E-01    2.21E+00  425    3.50E-01    2.66E-01    3.03E-01    9.27E-01    2.85E+00\n 176   -1.49E-01    7.28E-01    6.41E-01    3.64E-01    2.20E+00  426    3.52E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 177   -1.47E-01    7.23E-01    6.34E-01    3.72E-01    2.20E+00  427    3.54E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 178   -1.45E-01    7.17E-01    6.28E-01    3.81E-01    2.19E+00  428    3.56E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 179   -1.43E-01    7.12E-01    6.21E-01    3.89E-01    2.18E+00  429    3.58E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 180   -1.41E-01    7.06E-01    6.15E-01    3.97E-01    2.18E+00  430    3.60E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 181   -1.39E-01    7.01E-01    6.08E-01    4.06E-01    2.17E+00  431    3.62E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 182   -1.37E-01    6.96E-01    6.02E-01    4.14E-01    2.16E+00  432    3.64E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 183   -1.35E-01    6.90E-01    5.95E-01    4.22E-01    2.16E+00  433    3.66E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 184   -1.33E-01    6.85E-01    5.89E-01    4.31E-01    2.15E+00  434    3.68E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 185   -1.31E-01    6.80E-01    5.83E-01    4.39E-01    2.14E+00  435    3.70E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 186   -1.29E-01    6.75E-01    5.77E-01    4.47E-01    2.14E+00  436    3.72E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 187   -1.27E-01    6.70E-01    5.71E-01    4.56E-01    2.13E+00  437    3.74E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 188   -1.25E-01    6.65E-01    5.64E-01    4.64E-01    2.12E+00  438    3.76E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 189   -1.23E-01    6.60E-01    5.58E-01    4.72E-01    2.12E+00  439    3.78E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 190   -1.21E-01    6.55E-01    5.52E-01    4.81E-01    2.11E+00  440    3.80E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 191   -1.19E-01    6.50E-01    5.47E-01    4.89E-01    2.10E+00  441    3.82E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 192   -1.17E-01    6.45E-01    5.41E-01    4.98E-01    2.10E+00  442    3.84E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 193   -1.15E-01    6.40E-01    5.35E-01    5.06E-01    2.09E+00  443    3.86E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 194   -1.13E-01    6.35E-01    5.29E-01    5.14E-01    2.08E+00  444    3.88E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 195   -1.11E-01    6.30E-01    5.23E-01    5.23E-01    2.08E+00  445    3.90E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 196   -1.09E-01    6.25E-01    5.18E-01    5.31E-01    2.07E+00  446    3.92E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 197   -1.07E-01    6.20E-01    5.12E-01    5.39E-01    2.06E+00  447    3.94E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 198   -1.05E-01    6.15E-01    5.07E-01    5.48E-01    2.06E+00  448    3.96E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 199   -1.03E-01    6.11E-01    5.01E-01    5.56E-01    2.05E+00  449    3.98E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 200   -1.01E-01    6.06E-01    4.96E-01    5.64E-01    2.05E+00  450    4.00E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 201   -9.92E-02    6.01E-01    4.90E-01    5.73E-01    2.04E+00  451    4.02E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 202   -9.72E-02    5.96E-01    4.85E-01    5.81E-01    2.03E+00  452    4.04E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 203   -9.52E-02    5.92E-01    4.80E-01    5.89E-01    2.03E+00  453    4.06E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 204   -9.32E-02    5.87E-01    4.74E-01    5.98E-01    2.02E+00  454    4.08E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 205   -9.12E-02    5.83E-01    4.69E-01    6.06E-01    2.01E+00  455    4.10E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 206   -8.92E-02    5.78E-01    4.64E-01    6.14E-01    2.01E+00  456    4.12E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 207   -8.72E-02    5.73E-01    4.59E-01    6.23E-01    2.00E+00  457    4.14E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 208   -8.52E-02    5.69E-01    4.54E-01    6.31E-01    2.00E+00  458    4.16E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 209   -8.32E-02    5.64E-01    4.49E-01    6.39E-01    1.99E+00  459    4.18E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 210   -8.12E-02    5.60E-01    4.44E-01    6.48E-01    1.98E+00  460    4.20E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 211   -7.92E-02    5.56E-01    4.39E-01    6.56E-01    1.98E+00  461    4.22E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 212   -7.72E-02    5.51E-01    4.34E-01    6.65E-01    1.97E+00  462    4.24E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 213   -7.52E-02    5.47E-01    4.29E-01    6.73E-01    1.96E+00  463    4.26E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 214   -7.31E-02    5.42E-01    4.25E-01    6.81E-01    1.96E+00  464    4.28E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 215   -7.11E-02    5.38E-01    4.20E-01    6.90E-01    1.95E+00  465    4.30E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 216   -6.91E-02    5.34E-01    4.15E-01    6.98E-01    1.94E+00  466    4.32E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 217   -6.71E-02    5.30E-01    4.11E-01    7.06E-01    1.94E+00  467    4.34E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 218   -6.51E-02    5.25E-01    4.06E-01    7.15E-01    1.93E+00  468    4.36E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 219   -6.31E-02    5.21E-01    4.02E-01    7.23E-01    1.93E+00  469    4.38E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 220   -6.11E-02    5.17E-01    3.97E-01    7.31E-01    1.92E+00  470    4.40E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 221   -5.91E-02    5.13E-01    3.93E-01    7.40E-01    1.91E+00  471    4.42E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 222   -5.71E-02    5.09E-01    3.88E-01    7.48E-01    1.91E+00  472    4.44E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 223   -5.51E-02    5.05E-01    3.84E-01    7.56E-01    1.90E+00  473    4.46E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 224   -5.31E-02    5.01E-01    3.79E-01    7.65E-01    1.90E+00  474    4.48E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 225   -5.11E-02    4.96E-01    3.75E-01    7.73E-01    1.89E+00  475    4.50E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 226   -4.91E-02    4.92E-01    3.71E-01    7.81E-01    1.88E+00  476    4.52E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 227   -4.71E-02    4.88E-01    3.67E-01    7.90E-01    1.88E+00  477    4.54E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 228   -4.51E-02    4.85E-01    3.63E-01    7.98E-01    1.87E+00  478    4.56E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 229   -4.31E-02    4.81E-01    3.58E-01    8.06E-01    1.86E+00  479    4.58E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 230   -4.11E-02    4.77E-01    3.54E-01    8.15E-01    1.86E+00  480    4.60E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 231   -3.91E-02    4.73E-01    3.50E-01    8.23E-01    1.85E+00  481    4.62E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 232   -3.71E-02    4.69E-01    3.46E-01    8.32E-01    1.85E+00  482    4.64E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 233   -3.51E-02    4.65E-01    3.42E-01    8.40E-01    1.84E+00  483    4.66E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 234   -3.31E-02    4.61E-01    3.38E-01    8.48E-01    1.83E+00  484    4.68E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 235   -3.11E-02    4.57E-01    3.35E-01    8.57E-01    1.83E+00  485    4.70E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 236   -2.91E-02    4.54E-01    3.31E-01    8.65E-01    1.82E+00  486    4.72E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 237   -2.71E-02    4.50E-01    3.27E-01    8.73E-01    1.82E+00  487    4.74E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 238   -2.51E-02    4.46E-01    3.23E-01    8.82E-01    1.81E+00  488    4.76E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 239   -2.30E-02    4.43E-01    3.19E-01    8.90E-01    1.80E+00  489    4.78E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 240   -2.10E-02    4.39E-01    3.16E-01    8.98E-01    1.80E+00  490    4.80E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 241   -1.90E-02    4.35E-01    3.12E-01    9.07E-01    1.79E+00  491    4.82E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 242   -1.70E-02    4.32E-01    3.08E-01    9.15E-01    1.79E+00  492    4.84E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 243   -1.50E-02    4.28E-01    3.05E-01    9.23E-01    1.78E+00  493    4.86E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 244   -1.30E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00  494    4.88E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 245   -1.10E-02    4.26E-01    3.03E-01    9.27E-01    1.78E+00  495    4.90E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 246   -9.02E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00  496    4.92E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 247   -7.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00  497    4.94E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 248   -5.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00  498    4.96E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 249   -3.01E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00  499    4.98E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n 250   -1.00E-03    4.26E-01    3.03E-01    9.27E-01    1.78E+00  500    5.00E-01    1.25E-01    1.00E-01    0.00E+00    2.00E+00\n\\end{verbatim}\n}\n\\end{appendices}\n\n\\end{document}", "meta": {"hexsha": "1d4abb2771695cdeda29f830ef8e41edfc6050ab", "size": 58977, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "RadHydro/HydroSolver/Doc_MHM_HLLC/MHM_HLLC.tex", "max_stars_repo_name": "Naktakala/rad_hydro", "max_stars_repo_head_hexsha": "7562499340522d56a94ff04a46beb32dc78cb6e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "RadHydro/HydroSolver/Doc_MHM_HLLC/MHM_HLLC.tex", "max_issues_repo_name": "Naktakala/rad_hydro", "max_issues_repo_head_hexsha": "7562499340522d56a94ff04a46beb32dc78cb6e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RadHydro/HydroSolver/Doc_MHM_HLLC/MHM_HLLC.tex", "max_forks_repo_name": "Naktakala/rad_hydro", "max_forks_repo_head_hexsha": "7562499340522d56a94ff04a46beb32dc78cb6e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.5262582057, "max_line_length": 589, "alphanum_fraction": 0.59034878, "num_tokens": 30794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4260356642417815}}
{"text": "%auto-ignore\n\\providecommand{\\MainFolder}{..}\n\\documentclass[\\MainFolder/Text.tex]{subfiles}\n\n\n\\begin{document}\n\\section{Results about vanishing of Chern-Simons Maurer-Cartan element}\n\\label{Sec:Vanishing}\n\n\\Modify[inline]{Do I really need that $\\pi_\\Harm \\Htp = 0$? What is precisely the defininition?}\n\nIn the situation of Definition~\\ref{Def:PushforwardMCdeRham}, let $\\Gamma \\in \\TRRG_{klg}$ be a reduced trivalent ribbon graph, $L=(L_1,L_2,L_3)$ its labeling, $x_i$ the integration variable associated to the $i$-th internal vertex, $\\Prpg(x_i,x_j)$ an admissible Hodge propagator on the oriented internal edge between $x_i$ and~$x_j$, and $\\alpha_{ij}\\in \\Harm(M)[1]$ the harmonic form on the $j$-th external vertex on the $i$-th boundary component. Recall that we denote by $\\omega_i = \\Susp \\alpha_{i1}\\dotsc\\alpha_{is_i}$ the $i$-th input of $\\PMC_{lg}$ and by $D$ the total form-degree of all inputs. \n\nBy saying ``\\emph{a graph vanishes}'' we mean that $I(\\sigma_L) = 0$ in the given context.\n\n\n\\begin{Proposition}[Vanishing of graphs with $\\NOne$] \\label{Prop:PMCEqualsMC}\nIn the setting of Definition~\\ref{Def:PushforwardMCdeRham}, suppose that the following condition is satisfied: \n\\begin{description}\n\\item[($V_{\\NOne}$)] Every graph $\\Gamma \\in \\TRRG_{klg}$, $\\Gamma \\neq Y$ which has $\\NOne = \\SuspU 1\\in \\Harm(M)[1]$ at an external vertex vanishes. \n\\end{description}\nThen $\\PMC$ is strictly reduced, and the following holds depending on the dimension $n$:\n\\begin{enumerate}[label=(\\alph*)]\n \\item For $n>3$: All graphs which are not trees or circular vanish. Therefore, $\\PMC_{lg} = 0$ for all $(l,g)\\neq (1,0)$, $(2,0)$, and it follows that all higher operations~$\\OPQ_{1lg}^\\PMC$ vanish on the chain level.\n  \\item For $n=3$: A tree vanishes unless all $\\eta_{1}$,~$\\dotsc$, $\\eta_{s}$ are one-forms. Therefore, $\\PMC_{10}(\\Susp \\alpha_1 \\dots \\alpha_s) \\neq 0$ implies $\\deg(\\eta_i)=1$ for all $i$.\n \\item For $n<3$: All trees except for $Y$ vanish. Therefore, we have $\\PMC_{10} = \\MC_{10}$, and consequently $\\OPQ_{110}^\\PMC = \\OPQ_{110}^\\MC$.\n\\end{enumerate}\nMoreover, we have \n\\begin{enumerate}[resume,label=(\\alph*)]\n \\item A circular graph vanishes unless all $\\eta_{11}$, $\\dotsc$, $\\eta_{2s_2}$ are one-forms. Therefore, $\\PMC_{20}(\\Susp^2 \\alpha_{11}\\dots \\alpha_{1s_1} \\otimes \\alpha_{21}\\dots \\alpha_{2s_2})\\neq 0$ implies $\\deg(\\eta_{ij})=1$ for all $i$, $j$.\n\\end{enumerate}\nIn addition to $(V_{\\NOne})$, suppose that $\\HDR^1(M) = 0$. Then:\n\\begin{enumerate}[resume,label=(\\alph*)]\n \\item All circular graphs vanish. Therefore, we have $\\PMC_{20} = 0$, and consequently $\\OPQ_{120}^\\PMC = \\OPQ_{120}$.\n\\item For $n\\le 6$: All trees except for $Y$ vanish. Therefore, we have $\\PMC_{10} = \\MC_{10}$, and consequently $\\OPQ_{110}^\\PMC = \\OPQ_{110}^\\MC$. \n\\end{enumerate} \n\\end{Proposition}\n\n\\begin{proof}\nThe proof is just combinatorics with $D$. Suppose that a trivalent ribbon graph $\\Gamma\\neq Y$ does not vanish on the input $\\omega_1$, $\\dotsc$, $\\omega_l$. Because all external vertices of $\\Gamma$ are adjacent to an $A$-vertex or a $B$-vertex, the assumption $(V_{\\NOne})$ implies $D\\ge s$, where $s$ is the total number of external vertices. A combination of~\\eqref{Eq:TotDeg} and~\\eqref{Eq:TrivalentFormula} yields\n$$ nk - (n-1)e = D \\ge s = 3k - 2e\\quad\\Equiv\\quad(n-3)k \\ge (n-3)e. $$\n\\begin{ProofList}[label=(\\alph*)]\n\\item For $n>3$, we get $k \\ge e$, which implies that $\\Gamma$ is either a tree or a circular graph.\n\\item If $\\Gamma$ is a tree, then $s = k + 2$ and $e = k-1$. From~\\eqref{Eq:TotDeg} we get\n\\begin{equation} \\label{Eq:TreeEq}\nD = nk - (n-1)(k-1) = k+n-1.  \n\\end{equation}\nNow $D$ is the sum of $s=k+2$ form-degrees $\\deg(\\eta_{ij})>0$, and hence~\\eqref{Eq:TreeEq} for $n=3$ implies that $\\deg(\\eta_{ij}) = 1$ for all $i$, $j$.\n\\item For $n<3$, we get $e \\ge k$, which implies that $\\Gamma$ is not a tree.\n\\item If $\\Gamma$ is a circular graph, then $e=k=s$, and we get using~\\eqref{Eq:TotDeg} that\n$$ D = nk - (n-1)k = k. $$\nHere $D$ is the sum of $s=k$ form-degrees $\\deg(\\eta_{ij})>0$, and hence $\\deg(\\eta_{ij})=1$ for all $i$, $j$.\n\\end{ProofList}\nWe will now assume, in addition, that $\\Harm^1(M) \\simeq \\HDR^1(M) = 0$.\\Add[caption={DONE Add in addition}]{This is now assumed in addition to (1)!}\n\\begin{ProofList}[resume, label=(\\alph*)]\n\\item We must have $D\\ge 2 s$, which is in contradiction with $D = s$ for a circular graph. Therefore, $\\PMC_{20} = 0$.\n\\item Finally, for a tree $\\Gamma \\neq Y$, we have\n\\begin{equation*}\n k+n-1 = D \\ge 2 s = 2(k + 2)\\quad\\Equiv\\quad  n-5 \\ge k. \\end{equation*}\nThis finishes the proof of the proposition.\\qedhere\n\\end{ProofList}\n\\end{proof}\n\n%Notice that if Conjecture~\\ref{Conj:GStd} for $\\PrpgStd$ holds, then we can take $\\PrpgStd$ as the Hodge propagator and the next proposition implies that Proposition~\\ref{Prop:PMCEqualsMC} holds.\n\n\\begin{Proposition}[Special Hodge propagator]\\label{Prop:COne}\nIn the setting of Definition~\\ref{Def:PushforwardMCdeRham}, suppose that the Hodge propagator $\\Prpg$ is special. Then the condition ($V_{\\NOne}$), and hence Proposition~\\ref{Prop:PMCEqualsMC} holds.\n\\end{Proposition}\n\\begin{proof}\nIt is easy to see that $A_{\\alpha_1,\\alpha_2} = \\Htp(\\eta_1 \\wedge \\eta_2)$ for all $\\alpha_1$, $ \\alpha_2\\in \\Harm(M)[1]$, and that $-B_{\\NOne}$ is the Schwartz kernel of $\\Htp \\circ \\Htp$. Therefore, (P4) and (P5) imply $A_{\\alpha_1,\\NOne}=0$ and $B_{\\NOne} = 0$, respectively.\n\nAs for the integral $I(\\sigma_L)$,  one has to apply the Fubini theorem in order to integrate out single vertices $A_{\\alpha_1, \\NOne}$ and $B_{\\NOne}$. This step relies on $L^1$-integrability of the integrand which follows from \\cite{Cieliebak2018} (the integrand comes from a smooth form on a compact manifold with corners).\n\\end{proof}\n%Another implication of Proposition~\\ref{Prop:PMCEqualsMC} is that $\\PMC$ becomes strictly reduced, and hence we can define the reduced twisted $\\IBLInfty$-algebra $\\dIBL^\\PMC(\\RedCycC(\\Harm))$.\n\\begin{Proposition}[Vanishing of $A$-vertices]\\label{Prop:Avertexvanish}\nIn the setting of Definition~\\ref{Def:PushforwardMCdeRham}, suppose that the following condition is satisfied:\n\\begin{description}\n\\item[($V_A$)] Every graph with an $A$-vertex vanishes.\n\\end{description}\nThen we have $\\PMC_{10} = \\MC_{10}$, and the only contribution to $\\PMC_{20}(\\Susp^2 \\alpha_{11}\\dots \\alpha_{1s_1} \\otimes \\alpha_{21}\\dots \\alpha_{2s_2})$ comes from $O_k$-graphs with $k = s_1 + s_2 = D$.\n\\end{Proposition}\n\n\\begin{proof}\nThe only trees and circular graphs which are not excluded by the assumption are the $Y$-graph and $O_k$-graphs, respectively (the external branches contract). The condition on form-degrees is obtained as in the proof of Proposition~\\ref{Prop:PMCEqualsMC}.\n\nTo argue that $I(\\sigma_L)=0$, we again need $L^1$-integrability as in the proof of Proposition \\ref{Prop:COne}.\n\\end{proof}\n\n%\\begin{Remark}[Integrability for trees]\n%Given a tree, we can start at a leaf and write $I(\\sigma_L)$ as an iterative integral of contributions $A_{\\alpha_1,\\alpha_2}$ for $\\alpha_1$, $\\alpha_2 \\in \\DR(M)$. These are smooth forms, and hence integrability is guaranteed. Therefore, the result $\\PMC_{10} = \\MC_{10}$ is independent of the convergence results from~\\cite{Cieliebak2018}.\n%\\end{Remark}\n\n\\begin{Proposition}[$1$-connected geometrically formal manifolds] \\label{Prop:GeomForm}\nLet $M$ be a geometrically formal $n$-manifold and $\\Prpg$ a special Hodge propagator (it exists by Proposition~\\ref{Prop:ExistenceG}). If $\\HDR^1(M) = 0$, then the following holds:\n\\begin{description}\n\\item[$(n\\neq 2)$]  All $Y \\neq \\Gamma \\in \\RRG_{klg}$ with $k$, $l\\ge 1$, $g\\ge 0$ vanish, and hence $\\PMC = \\MC$.\n\\item[$(n=2)$] All $Y\\neq \\Gamma \\in \\RRG_{kl0}$ with $k$, $l\\ge 1$ vanish, and hence $\\PMC_{l0} = \\MC_{l0}$ for all~$l\\ge 1$.\n\\end{description}\n\\end{Proposition}\n\\begin{proof}\nGiven $\\eta_1$, $\\eta_2 \\in \\Harm$, geometric formality implies $\\eta_1 \\wedge \\eta_2 \\in \\Harm$, and hence $A_{\\alpha_1,\\alpha_2} = \\Htp(\\eta_1\\wedge\\eta_2) = 0$. We see that $(V_{\\NOne})$ and $(V_{A})$ are satisfied, and hence the implications of Propositions~\\ref{Prop:PMCEqualsMC} and~\\ref{Prop:Avertexvanish} hold. The claim for $n>3$ follows.\n\nAs for $n=3$, Poincar\\'e duality implies $\\HDR^2(M;\\R)=0$. \\Correct[caption={DONE Wrong reference}]{Here is not Eq:GenusFormula but the relationf of A B C vertices to graph variables}Therefore, the total form-degree $D$ satisfies $D= n B$, where $B$ is the number of $B$-vertices. We see using \\eqref{Eq:ChangeOfVariables} that \\eqref{Eq:TotDeg} is equivalent to\n\\begin{equation}\\label{Eq:VerticesEq}\nB+\\frac{1}{2}(3-n) C = D = nB\\quad\\Equiv\\quad (n-1)B = \\frac{1}{2}(3-n) C.\n\\end{equation}\nIt follows that $B=0$, and hence all reduced graphs vanish.\n\nAs for $n=2$, we get from \\eqref{Eq:VerticesEq} and \\eqref{Eq:GenusFormulaa} that $B\\ge l$ is equivalent to $g\\ge 1$.\n\\qedhere\n\\end{proof}\n\n\n\n\n%Notice that in order to show $\\MC_{10} = \\PMC_{10}$, i.e., that all trees vanish, we do not need the convergence results from \\cite{Cieliebak2018} because we can write $I(\\sigma_L)$ as an iteration of integral $\\int_x \\FKFubini-Tonelli  because \n\n\\begin{Remark}[$\\AInfty$-homotopy transfer]  \\label{Rem:RemMu}\nIn~\\cite{Cieliebak2018}, it will be shown that the $\\AInfty$-algebra $\\Harm(M)_\\PMC = (\\Harm(M),(\\mu_k))$ induced by $\\PMC_{10}$ agrees with the $\\AInfty$-algebra obtained by the $\\AInfty$-homotopy transfer\n$$\\begin{tikzcd}\n\\biggl(\\ \\begin{gathered}\\DR(M) \\\\ m_1,\\  m_2\\end{gathered}\\ \\biggr)\\arrow[rightsquigarrow]{r} & \n\\biggl(\\ \\begin{gathered}\n\\Harm(M) \\\\\n\\mu_1\\equiv 0,\\ \\mu_2 = \\pi_\\Harm m_2 (\\iota_\\Harm, \\iota_\\Harm),\\ \\mu_3,\\ \\dotsc\n\\end{gathered}\\ \\biggr)\n\\end{tikzcd}$$\n using the homotopy retract (see~\\cite{Vallette2012})\n$$\\begin{tikzcd}[column sep=large]\n(\\DR(M),m_1)  \\arrow[loop left]{l}{\\Htp}  \\arrow[shift left]{r}{\\pi_\\Harm}  & \\arrow[shift left]{l}{\\iota_\\Harm} (\\Harm(M),m_1 \\equiv 0).\n\\end{tikzcd}$$\nThe operation $\\mu_k$ of the transferred $\\AInfty$-structure is computed as a sum over planar trees with a root and $k$ leaves decorated by $\\iota_\\Harm$ at the leaves, $\\pi_\\Harm$ at the root and~$\\Htp$ at the internal edges (see \\cite{Akaho2007}). The result of \\cite{Cieliebak2018} is plausible because the part of $\\PMC_{10}$ contributing to $\\mu_k$ is a sum over trivalent ribbon trees with $k+1$ leaves.\n\nIn~\\cite{Cieliebak2018}, they will also show that $\\iota_1\\coloneqq \\iota_\\Harm: \\Harm \\rightarrow \\DR$ extends to an $\\AInfty$-quasi-isomorphism $(\\iota_k)_{k\\ge 1}$ from $(\\Harm,(\\mu_k))$ to $(\\DR,m_1,m_2)$. The induced chain map on the dual cyclic bar complexes is then the map $\\HTP_{110}^\\MC$ coming from the $\\IBLInfty$-theory in the Overview.\n\\end{Remark}\n\n%The following proposition is an immediate consequence of \\eqref{Rem:RemMu}.\n\n\\begin{Proposition}[Twisted boundary operator for formal manifolds]\\label{Prop:Formal}\nIn the setting of Definition~\\ref{Def:PushforwardMCdeRham}, suppose that $M$ is formal in the sense of rational homotopy theory. Then there is a quasi-isomorphism\n$$\\begin{tikzcd}\n\\HHTP_{110}: (\\CDBCyc \\HDR(M)[3-n], \\OPQ_{110}^\\MC)\\arrow{r}{} & (\\CDBCyc \\Harm(M)[3-n],\\OPQ_{110}^\\PMC). \\end{tikzcd}$$\n\\end{Proposition}\n\n\\begin{proof}\nFormality of $M$ is equivalent to the existence of a zig-zag of quasi-isomorphisms of dga's (see \\cite{Vallette2012}) \n$$\\begin{tikzcd}[column sep=normal] (\\H_{\\mathrm{dR}}(M),m_1\\equiv 0, m_2) \\arrow[rightsquigarrow]{r} &\\bullet\\quad\\dotsb\\quad\\bullet &\\arrow[rightsquigarrow]{l} (\\DR(M),m_1,m_2). \\end{tikzcd}$$\nBecause a dga-quasi-isomorphism has a homotopy inverse in the category of $\\AInfty$-algebras, we get a direct $\\AInfty$-quasi-isomorphism \n$$\\begin{tikzcd}\n(g_k):\\quad (\\DR(M),m_1,m_2) \\arrow[rightsquigarrow]{r} & (\\H_{\\mathrm{dR}}(M),m_1\\equiv 0, m_2).\n\\end{tikzcd}$$\nPrecomposing with $(\\iota_k)$ from Remark~\\ref{Rem:RemMu}, we get the $\\AInfty$-isomorphism \n$$\\begin{tikzcd}\n(h_k):\\quad (\\Harm(M),(\\mu_k)) \\arrow[rightsquigarrow]{r} & (\\HDR(M),m_1\\equiv 0,m_2). \\end{tikzcd}$$\nThis induces the quasi-isomorphism $\\HHTP_{110}$ of the cyclic cochain complexes.\n\\end{proof}\n\n\\begin{Remark}[On formality]\\phantomsection\n%\\begin{RemarkList} \\item \nGeometrically formal manifolds include $\\Sph{n}$, $\\C P^n$ and Lie groups (see~\\cite{Kotschick2000}). Any geometrically formal manifold is formal. Every simply-connected manifold of dimension at most $6$ is formal (see \\cite{Miller1979}).\n%\\item Proposition~\\ref{Prop:GeomForm} for geometrically formal $M$ strengthens Proposition~\\ref{Prop:Formal} in the sense that we can take $h = \\pi_{\\Harm}^*$ (the componentwise precomposition with $\\pi_\\Harm$) as the quasi-isomorphism.\\qedhere\n%\\end{RemarkList} \n\\end{Remark}\n%\n%In the light of the above propositions, we expect that the following holds (we will try to give a proof in \\cite{MyPhD}).\n%\n%\\begin{Conjecture}[Canonicity of the $\\IBL$-structure for formal manifolds]\\label{Conj:Formality}In the setting of Definition~\\ref{Def:PushforwardMCdeRham},\n%the following implication holds:\n%$$ M\\text{ formal}\\ \\&\\ \\HDR^1(M)=0 \\quad\\Implies\\quad \\IBL(\\HIBL^\\PMC(\\CycC(\\Harm)))\\simeq \\IBL(\\HIBL^\\MC(\\CycC(\\HDR))). $$ \n%\\end{Conjecture}\n%The only interesting questions for formal $M$ with $\\HDR^1(M)=0$ are according to Proposition~\\ref{Prop:PMCEqualsMC} the following:\n%\\begin{enumerate}[label=(Q\\arabic*)]\n%\\item Does there exist a simply connected $3$-manifold with a non-trivial higher $\\IBLInfty$-operation $\\OPQ_{1lg}^\\PMC$ on the homology?\n%\\item Does $\\Sph{2}$ posses any? NO NO NO DEGREE REASONS.\n%\\end{enumerate}\n%In Section \\ref{Section:Computation}, we attempt to compute $\\dIBL^\\PMC(\\Sph{2})$ directly and arrive to the partial result that $\\OPQ^\\PMC_{1l0}=0$ for $l\\ge 1$ and $\\OPQ_{111}^\\PMC=0$.\n\\end{document}\n", "meta": {"hexsha": "66dd8dd3cc0125e9b43d77853853e2387f3a92d8", "size": 13729, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Subfiles/String_Vanish.tex", "max_stars_repo_name": "p135246/phd-thesis", "max_stars_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subfiles/String_Vanish.tex", "max_issues_repo_name": "p135246/phd-thesis", "max_issues_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subfiles/String_Vanish.tex", "max_forks_repo_name": "p135246/phd-thesis", "max_forks_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.5649717514, "max_line_length": 606, "alphanum_fraction": 0.7063150994, "num_tokens": 4773, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4260356642417815}}
{"text": "\\documentclass[]{article}\n\n%opening\n\\title{Vision and Perception}\n\\author{Nijat Mursali | 1919669}\n\\usepackage{tikz}\n\\usetikzlibrary{calc,intersections,through,backgrounds}\n\\usepackage{graphicx}\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\tThis document is used to illustrate all the homework exercises that has been given during Vision and Perception course in 2020/21. There are overall 14 exercises that needed to be done during this time. \n\n\n\\end{abstract}\n\n\\section{Homework 1 - Degenerate Conic}\nAs mentioned during the video of Geometric Parameters, we needed to compute the $M_{2}$ as we did for $M_{1}$ and then computing the null space of $M_{1}$ and verifying that is 2, then computing the cross product of null space vectors and after normalizing to obtain the $x_{3} = 1$, we needed to think about the result.\n\\vspace{0.4em}\n\nThe idea is here space of $M_{1}$ and verifying that is 2, then computing the cross product of null space vectors and after normalizing to obtain the $x_{3} = 1$, we needed to think about the result.\t\n\n\\centerline {\n\\begin{tikzpicture}\n\\draw (-1.5, 0) coordinate(A) -- (2,0.2) coordinate (B) node [black, scale=1] {$l_{1}$};\n\\draw (-1,-1) coordinate(C) -- (1.5,1.5) coordinate (D) node [black, scale=1] {$l_{2}$};\n\\node[red,scale=3] at (intersection of  A--B and C--D){.};\n\\end{tikzpicture}\n}\nThus, we need to consider the two intersecting lines that we have seen in our lecture: \n\n\\centerline {\n$l_{1} = (0.2500, 3.200, 1.0000)^T$  \n$l_{2} = (-2.0000, 0.5000, 1.0000)^T$ \n}\n\n\\centerline {\n\t$x = l_{1} \\times l_{2} = (-0.4138, 0.3448, 1.0000)^T$\n}\n\n\\vspace{0.5em}\n\n\\centerline {\n$M_{1} = l_{1}l_{1}^T = \n\\left( {\\begin{array}{*{20}c}\n\t0.0625 & 0.8000 & 0.2500 \\\\\n\t0.8000 & 10.2400 & 3.2000 \\\\\n\t0.2500 &  3.2000 & 1.0000   \n\t\\end{array} } \\right)$\n}\n\nThus, by computing the degenerate conic for $l_{2}$, we could get something following:\n\n\\centerline {\n$M_{2} = l_{2}l_{2}^T = \n\\left( {\\begin{array}{*{20}c}\n\t4.0000 & -1.0000 & -2.0000 \\\\\n\t-1.0000 & 0.2500 & 0.5000 \\\\\n\t-2.0000 &  0.5000 & 1.0000   \n\t\\end{array} } \\right)$\n}\n\nAs we see from the book, the null space can be computed by span as following:\n\n\\centerline {\n\t$Null(M_{1}) = Span\\{\\left( {\\begin{array}{*{20}c}\n\t0.2210 \\\\\n\t0.2751 \\\\\n\t-0.9357  \n\t\\end{array} } \\right),\\left( {\\begin{array}{*{20}c}\n\t-0.9724 \\\\\n\t 0.1353 \\\\\n\t-0.1899  \n\t\\end{array} } \\right) \\}$ \n}\n\nand \n\n\\centerline { $Null(M_{2}) = Span\\{\\left( {\\begin{array}{*{20}c}\n\t0 \\\\\n\t0.8944 \\\\\n\t-0.4472  \n\t\\end{array} } \\right),\\left( {\\begin{array}{*{20}c}\n\t-0.4880 \\\\\n\t-0.3904 \\\\\n\t-0.7807  \n\t\\end{array} } \\right) \\}$ }\n\nFinally, we need to calculate the cross-product of the null-space components of $M_{1}$ as:\n\n$M_{1} = (0.2210, 0.2751, -0.9357) \\times (-0.9724, 0.1353, -0.18,99) = (0.0744, 0.9518, 0.2974)^T$\n\\vspace{0.2em}\nthen, for $M_{2}$ it will be like:\n\\vspace{0.2em}\n\n$M_{2} = (0, 0.8944 - 0.4472) \\times (-0.4880, -0.3904, -0.7807) = (-.8728, 0.2182, 0.4365)^T$\n\nWe come up to the result that these two results are no more than the original lines, $l_{1}$ and $l_{2}$ with unitary norm.  \n\n\\section{Homework 2 - Five Points Define a Conic}\n\nAs we know for each point the conic passes through\n\n\\centerline {$ax_{i}^2 + bx_{i}y_{i} + cy_{i}^2 + dx_{i} + ey_{i} + f = 0$ }\n\n\\vspace{0.4em}\n\nor \n\n\\centerline {\n\t($x_{i}^2, x_{i}y_{i}, y_{i}^2, x_{i}, y_{i}, f)c = 0$, where $c = (a,b,c,d,e,f)$ \n}\n\nstacking constraints yields \n\n\n\\centerline {\n\t$\\left[ {\\begin{array}{*{20}c}\n\t\tx_1^2 & x_1y_1 & y_1^2 & x_1 & y_1 & 1 \\\\\n\t\tx_2^2 & x_2y_2 & y_2^2 & x_2 & y_2 & 1 \\\\\n\t\tx_3^2 & x_3y_3 & y_3^2 & x_3 & y_3 & 1 \\\\\n\t\tx_4^2 & x_4y_4 & y_4^2 & x_4 & y_4 & 1 \\\\\n\t\tx_5^2 & x_5y_5 & y_5^2 & x_5 & y_5 & 1 \n\t\t\\end{array} } \\right]c = 0$\t\n}\n\n\n\nthus to determine the parameters of the equation, we need at least five points. Consider the following: \n\n\\centerline {\n\t\\includegraphics[scale=0.5]{scr2}\n}\n\nAs we see from the equation, we need to determine the parameters of the equation with at least five points. So, for this homework we just chose 4 points in xy plane with different values, thus we have the following set of equations:\n\n\\centerline {\n\t$\\left[ {\\begin{array}{*{20}c}\n\t\t\t0 & 0 & 16 & 0 & 4 & 1 \\\\\n\t\t\t1 & 1 & 1  & 1 & 1 & 1 \\\\\n\t\t\t9 & 24 & 64  & 3 & 8 & 1 \\\\\n\t\t\t36 & 36 & 36  & 6 & 6 & 1 \\\\\n\t\t\t49 & 21 & 9  & 7 & 3 & 1\\\\   \n\t\\end{array} } \\right] \n\t\\left[ {\\begin{array}{*{20}c}\n\t\t\ta \\\\ \n\t\t\tb \\\\ \n\t\t\tc \\\\ \n\t\t\td \\\\ \n\t\t\te \\\\ \n\t\t\tf    \n\t\\end{array} } \\right] = 0 $\n}\n\nfrom which we obtain the following values:\n\n\\centerline {\n\t$a = 0.0876$, $b = 0.0258$, $c = 0.0532$, $d = -0.7038$, $e = -0.4629$, $f = 1$,  \n}\n\nthus giving us following result:\n\n\\centerline {\n\\includegraphics[scale=0.5]{scr1}\n}\n\n\n\\section{Homework 3 - Compute the DLT algorithm}\nIn order to solve this problem, we needed to take one picture and apply the algorithm to check the coordinates of the shape. The idea is to pick 4 points on two different images by hand and apply the DLT algorithm showing the calculations. Additionally, the point selection is arbitrary. \n\nThus, we consider the following picture where we selected the four points as DLT algorithm stated in order to get 2D point correspondences {$x_i \\leftrightarrow  x_i'$}.\n\n\\centerline {\n\t\\includegraphics[scale=0.4]{src}\n}\n\nFrom the 2D to 2D point correspondences we need to determine 2D homography matrix H such that $x_i' = Hx_i$. \n\nThe fundamental goal of ours is to apply homography so that the outline shape of object forms a rectangle. The homogeneous coordinates for the shape are:\n\n\\centerline {\n\t$A = \\left[ {\\begin{array}{*{20}c}\n\t\t281.0 & 234.0 & 1.0 \\\\\n\t\t587.0 & 580.0 & 1.0 \\\\\n\t\t808.0 & 375.0 & 1.0 \\\\\n\t\t506.0 & 45.0 & 1.0\n\t\t\\end{array} } \\right]$\n}\n\nand our target shape has the coordinates: \n\n\\centerline {\n\t$B = \\left[ {\\begin{array}{*{20}c}\n\t\t172.0 & 347.0 & 1.0 \\\\\n\t\t566.0 & 580.0 & 1.0 \\\\\n\t\t763.0 & 340.0 & 1.0 \\\\\n\t\t336.0 & 166.0 & 1.0\n\t\t\\end{array} } \\right]$\n}\n\nthus yielding the following equation: \n\n\\centerline {\n\t$B = AH$\n}\n\n\nin which we ought to find the homography that produces such transformation. The matrix A is non-square, thus it cannot be inverted, we have to resort to the Direct Linear Transformation algorithm, in which at least three non-co-linear points are used to find the 8 independent terms of the transformation matrix. Since our settings have four points, our system is over determined, from which we derive the following transformation matrix:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H = \\left[ {\\begin{array}{*{20}c}\n\t\t9.7955 & 2.1074 & -1.4142 \\\\\n\t\t-3.4637 & 7.1861 & 2.9439 \\\\\n\t\t-4.2166 & -1.3235 & 1.000\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nfrom which we finally obtain the following transformation:\n\n\\vspace{0.5em}\n\\centerline {\n\t\\includegraphics[scale=0.4]{out}\n}\n\n\\vspace{0.5em}\n\n\\section{Homework 4 - Affine Transformations}\n\nThe task for this exercise is to show that an affine transformation preserves both parallel lines and area. First of all let's describe what exactly affine transformation is. Affine transformation is a function mapping an affine space onto itself that preserves the dimension of any affine subspaces and also preserves the ratio of the lengths of parallel line segments. Additionally, those sets of parallel affine subspaces still remain the same parallel after an affine transformation and and in this exercise we needed to show that. \n\n\\subsection{Affine transformation preserves parallel lines}\nAs we have talked in the lecture, we have: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$l_1 = (0, 1, 1)^T$ and $l_2=(0,2.45,1)^T$\n}\n\n\\vspace{0.5em}\n\nThese lines are parallel as they cross-product give us the following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$l_1 \\times l_2 = (-1.45, 0, 0)^T$\n}\n\n\\vspace{0.5em}\nPoints of the two lines can be obtained as follows:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$p_1$, $p_2 = Null(l_1)$, \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$p_1=(-0.707, 0.500, -0.500)^T$ and $p_2=(-0.707, -0.500, 0.500)$ \n}\n\n\\vspace{0.5em}\n\nConversely, \n\n\n\\centerline {\n\t$q_1$, $q_2 = Null(l_2)$, \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$q_1=(-0.936, 0.123, -0.328)^T$ and $q_2=(-0.351, -0.328, 0.877)$ \n}\n\nGiven the following transformation parameters: $\\alpha = 0.7$, $s_1=1.4$, $s_2=0.9$, $t_x=t_y=1.2$, we obtain the following affine transformation matrix:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H = \\left[ {\\begin{array}{*{20}c}\n\t\t1.07080 & 0.0618 & 1.2000 \\\\\n\t\t0.9019 & 1.8825 & 1.2000 \\\\\n\t\t0 & 0 & 1.0000\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nApplying the affine transformation onto the lines, we obtain:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$l_1' = l_1H = (0.902, 1.88, 2.20)$ and $l_2' = l_2H = (2.40, 5.02, 4.20)$ \n}\n\n\\vspace{0.5em}\n\nand so, we verify:\n\n\\centerline {\n\t$l_1' \\times l_2'=(-3.14, 1.51, 0)^T$\n}\n\nGiven the last coordinate in 0, we can ascertain that the lines remain parallel after the transformation.\n\n\\subsection{Affine transformation preserves area}\n\nGiven the two triangles formed by an arbitrary collection of lines, $l_1, l_2, l_3$ and $l_4$:\n\n\\centerline {\n\t\\includegraphics[scale=0.3]{hw4}\n}\n\nwhere $l_1$ and $l_2$ are parallel. We also know from the first example that, we can calculate the $p_i$ as $p_1 = l_1 \\times l_3$, $p_2 = l_1 \\times l_4$, $p_3 = l_3 \\times l_4$ and also finding $q_i$ will be as $q_1 = l_2 \\times l_4$, $q_2 = l_2 \\times l_3$.We can calculate the area $S$ of the triangles $A$ and $B$, using Heron's relation:\n\n\\centerline {\n\t$S_A = \\sqrt{s(s-a)(s-b)(s-c)}$\n} \n\nwhere s is the semi-perimeter of the triangle $S$.\n\nFor triangle A, the relation is as follows:\n\n\\centerline {\n\t$S_A=\\sqrt{s_A(s_A - \\overline{p_1p_3})(s_A - \\overline{p_1p_2}) (s_A - \\overline{p_2p_3})}$\n}\n\nAs for triangle $B$, we have:\n\n\\centerline {\n\t$S_B=\\sqrt{s_B(s_B - \\overline{p_1p_3})(s_B - \\overline{p_1p_2}) (s_B - \\overline{p_2p_3})}$\n}\n\nHence, for both triangles, their respective areas can be simply described by the distance of the intersecting points. Given an arbitrarily affine transformation $H$, that can be described as:\n\n\n\n\\centerline{ $H = \\left[ {\\begin{array}{*{20}c}\n\t\tA & t \\\\\n\t\t\\overrightarrow{0} & 1   \n\t\t\\end{array} } \\right]$ }\n\nTaking a line segment of each triangles, we can get the ratio as:\n\n\\centerline {\n\t$\\frac{\\overline{p_1p_3}}{\\overline{q_2q_3}} = \\frac{\\sqrt{(l_3 \\times l_4 - l_1 \\times l_3)(l_3 \\times l_4 - l_1 \\times l_3)}}{\\sqrt{(l_3 \\times l_4 - l_2 \\times l_3)(l_3 \\times l_4 - l_2 \\times l_3)}}$\n}\n\nIf we analyze the ratio's behavior under the transformation H by simply multiplying them with H, we get the following equation: \n\n\\centerline {\n\t$\\frac{\\overline{p_1p_3}'}{\\overline{q_2q_3}'} = \\frac{\\overline{p_1p_3}}{\\overline{q_2q_3}}$\n}\n\nThis relation can be naturally extended to any two line segments, thus the ratio between the areas of the triangle are also preserved. \n\n\n\\section{Homework 5 - Homography keeps lines tangent to conics}\nConsider the following line $l$, tanget to the conic $C$ at the point $x$, \n\n\\centerline {\n\t\\includegraphics[scale=0.5]{scr3}\n}\n\nAs we have seen in our class slides, we know that $l = Cx$ and $x^Tl=x^TCx = 0$. For this exercise, we need to show that $X^TCX=0$ that $l=Cx$. Additionally it was required to show the configuration $l^Tx=0$. Using the homography $H$ on $x$, we get $x'=Hx$, and to reverse this transformation, we can use the inverse homography $H^-1$. With the aformentioned properties, we can rewrite the equations like so:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x^TCx = (H^{-1}x')^TC(H^{-1}x') = 0$\n}\n\\vspace{0.5em}\n\nthis, in turn, is equivalent to :\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x^TCx = x'(H^{-1})^TCH^{-1}x' = x'C'x' = 0$.\n}\n\n\\vspace{0.5em}\n\nFrom the relation $l = Cx$, we have:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$(H^{-1})^Tl = (H^{-1})^TCx$,\n}\n\n\\vspace{0.5em}\n\nwhich can be rewritten to:\n\n\\vspace{0.5em}\n\n\\centerline {\t\n\t$(H^{-1})^Tl = (H^{-1})^TC(H^{-1}H)x$.\n}\n\n\\vspace{0.5em}\n\nAs we have previously seen: $C' = (H^{-1})^TCH^{-1}$, and so the previous equation becomes:\n\n\\centerline {\n\t$(H^{-1})^Tl = C'Hx$\n}\n\n\\vspace{0.5em}\n\nwhich finally gives us:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$l' = C'x'$\n}\n\nwhich it shows from the equation that $l'$ is also tangent to $C'$.\n\n\\section{Homework 6 - SVD for given matrix}\nAs we have seen from the example, the matrix A which we out to decompose is the following: \n\n\\vspace{0.5em}\n\n\\centerline{ $A = \\left[ {\\begin{array}{*{20}c}\n\t\t2 & 3 & 1 \\\\\n\t\t1 & 4 & -2   \n\t\t\\end{array} } \\right]$ }\n\t\nThe singular value decomposition (SVD) property proposes that any given matrix can be decomposed in three matrices that is:\n\n\\vspace{0.5em}\n\n\\centerline { $A = U \\Sigma V^T$}\n\n\\vspace{0.5em}\n\nwhere $\\Sigma$ is a rectangular diagonal matrix and, $U$ and $V^T$ are orthogonal matrices. To obtain these matrices, we first compute the product $A^TA$ as following:\n\n\\vspace{0.5em}\n\n\n\\centerline {\n\t$A^TA = (U \\Sigma V^T)^T U \\Sigma V^T = V (\\Sigma^T \\Sigma)V^T $ \n}\n\n\\vspace{0.5em}\n\n\nwhich will be equal to \n\n\\vspace{0.5em}\n\n\\centerline{ $A^TA = \\left[ {\\begin{array}{*{20}c}\n\t\t5 & 10 & 0 \\\\\n\t\t10 & 25 & -5 \\\\ \n\t\t0 & -5 & 5   \n\t\t\\end{array} } \\right]$ \n}\n\n\\vspace{0.5em}\n\t\nfrom this relation, we extract the eigenvalues of $A^TA$ as follows:\n\n\\vspace{0.5em}\n\t\n\\centerline {\n\t$(A^TA - I \\lambda) x = 0$\n}\n\n\\vspace{0.5em}\n\nin which, in order to obtain a non-trivial solution, the following property must hold:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$det(A^TA - I \\lambda) = 0$\n}\n\n\\vspace{0.5em}\n\nwhich gives the following equation:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$(5- \\lambda) (25 - \\lambda)(5 - \\lambda) - 25(5 - \\lambda) - 100(5 - \\lambda) = 0 $\n}\n\n\\vspace{0.5em}\n\nFrom this equation, we arrive at the following solutions: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\lambda_{1} = 30$, $\\lambda_{2} = 5$, $\\lambda_{3} = 0$ \n}\n\n\\vspace{0.5em}\n\nTo obtain the eingenvectors, we must find the vectors that lie in the null-space of the resulting matrices once\neach eigenvalue is substituted:\n\nFor $\\lambda = 30$: \n\n\\vspace{0.5em}\n\n\\centerline{ $\\left[ {\\begin{array}{*{20}c}\n\t\t-25 & 10 & 0 \\\\\n\t\t10 & -5 & -5 \\\\ \n\t\t0 & -5 & -25   \n\t\t\\end{array} } \\right] x = 0$,  }\n\nGiving us the following expressions: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$-25x_{1} + 10x_{2} = 0$, \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$10x_{1} - 5x_{2} - 5x_{3} =0$, \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$-5x_{2} - 25x_{3} = 0$\t\n}\n\n\\vspace{0.5em}\n\nfrom this linear set of equations, we arrive at the following solution: \n\n\\centerline {\n\t$x = [-1, -2.5, 0.5]^T$,\n}\n\n\\vspace{0.5em}\n\nwhich is then normalized: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x = [-0.3651, -0.9129, 0.1826]^T$.\n}\n\n\\vspace{0.5em}\n\nRepeating the same procedure for the other eigenvalues, we arrive at: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x = [-0.4472, 0, -0.8944]^T$ and $x = [0.8165, -0.4082, -0.4082]^T$\n}\n\n\\vspace{0.5em}\n\nLike so, we obtain the matrix $V$, compose of the column vectors: \n\n\\vspace{0.5em}\n\n\\centerline{ $V = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.3651 & -0.4472 & 0.8165 \\\\\n\t\t-0.9129 & 0 & -0.4082 \\\\ \n\t\t0.1826 & -0.8944 & -0.4082   \n\t\t\\end{array} } \\right]$ \n}\n\n\\vspace{0.5em}\n\t\nfurthemore, we also obtain the matrix $\\lambda$, which is the square root of the diagonal matrix composed of the calculated eigenvalues: \n\n\\vspace{0.5em}\n\n\\centerline{ $\\Sigma = \\left[ {\\begin{array}{*{20}c}\n\t\t\\sqrt{30} & 0 & 0 \\\\\n\t\t0 & \\sqrt{5} & 0 \\\\ \n\t\t0 & 0 & 0   \n\t\t\\end{array} } \\right]$ \n}\n\n\\vspace{0.5em}\n\nsince the last row is a product of any above row, we can write:\n\n\\vspace{0.5em}\n\n\\centerline{ $\\Sigma = \\left[ {\\begin{array}{*{20}c}\n\t\t\\sqrt{30} & 0 & 0 \\\\\n\t\t0 & \\sqrt{5} & 0   \n\t\t\\end{array} } \\right]$ \n}\n\n\\vspace{0.5em}\n\nThe last step is to determine the orthonormal matrix $U$. This can be obtained by the following product:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$AV = U \\Sigma V^TV$\n} \n\n\\vspace{0.5em}\n\nwhere we cross out the $\\Sigma V^TV$ that gives us only $AV = U$. Hence:\n\n\\vspace{0.5em}\n\n\\centerline{ $\\left[ {\\begin{array}{*{20}c}\n\t\t2 & 3 & 1 \\\\\n\t\t1 & 4 & -2   \n\t\t\\end{array} } \\right] \n\t\t\t\\left[ {\\begin{array}{*{20}c}\n\t\t-0.3651 & -0.4472 & 0.8165 \\\\\n\t\t-0.9129 & 0 & -0.4082 \\\\ \n\t\t0.1826 & -0.8944 & -0.4082  \n\t\t\\end{array} } \\right] = U \\left[ {\\begin{array}{*{20}c}\n\t\t\\sqrt{30} & 0 & 0 \\\\\n\t\t0 & \\sqrt{5} & 0   \n\t\t\\end{array} } \\right]$ \n}\n\n\\vspace{0.5em}\n\nwhich gives us the following matrix $U$:\n\n\\vspace{0.5em}\n\\centerline {\n\t$U = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.6 & -0.8 \\\\\n\t\t-0.8 & 0.6   \n\t\t\\end{array} } \\right]$\n}\n\n\\section{Homework 7 - Projective Transformation}  \nThe task here is to find the projective transformation $H$ and define the type of quadric from the quadric equation.\n\nFirstly, let's clarify some points we have learned in our lectures. \n\n\\centerline {\n\t3D point in $R^3$ which is $X = (X, Y, Z)^T$ in $P^3 : (x_1, x_2, x_3, x_4)^T$,\n}\n\n\\centerline {\n\tEuclidean frame $\\pi : ax + by + cz +d = 0$, where\n\t$\\pi^TX = 0 => (a b c d) ^T\\left[ {\\begin{array}{*{20}c}\n\t\tx_1 \\\\\n\t\tx_2 \\\\ \n\t\tx_3 \\\\\n\t\tx_4  \n\t\t\\end{array} } \\right] = 0$\t\n}\n\nThus, \n\n\\centerline {\n\t$X = (X_1, X_2, X_3, X_4)$ derives, \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t\t$X^TAX = 4x_1^2 + 4x_1x_2 - 2x_1x_3 + 2x_1x_4 + 5x_2^2 - 2x_2x_4 + 2x_3^2 + 2x_3x_4 + 2x_4^2 = 0$\n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\sum_{1 \\leq i \\leq  j \\leq 4 }^{4} a_{ij}x_iy_i  = 4*x_1^2 + 2*2x_1x_2 + $ \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$+ 2 * (-1)x_1x_3 + 2* (1)x_1x_4 + 5*x_2^2 + 2(0)x_2x_3 + 2(-1)x_2x_4 +$\n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$+  2*x_3^2 + 2*(-1)x_2x_4 + 2* x_3^2 + 2*(1)x_3x_4 + 2*x_4 = 0$\n}\n\n\\vspace{0.5em}\n\nThen, we get the following A matrix,\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$A = a_ia_j = \\left[ {\\begin{array}{*{20}c}\n\t\ta_{11} & a_{12} & a_{13} & a_{14} \\\\\n\t\ta_{21} & a_{22} & a_{23} & a_{24} \\\\ \n\t\ta_{31} & a_{32} & a_{31} &  a_{34} \\\\\n\t\ta_{41} & a_{42} & a_{43} & a_{44}  \n\t\t\\end{array} } \\right] =  \\left[ {\\begin{array}{*{20}c}\n\t\t4 & 2 & -1 & 1 \\\\\n\t\t2 & 5 & 0 & -1 \\\\ \n\t\t0 & 0 & 2 &  1 \\\\\n\t\t0 & 0 & 0 & 2  \n\t\t\\end{array} } \\right] = 0 $ \n}\n\n\\vspace{0.5em}\n\nWe also need to remember $Q = U^TDU$ which is equal to $H^TDH$ where U is orthogonal matrix and D is diagonal matrix. \n\nThen from the following equation we are getting the $\\lambda$ values. \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$|\\lambda I - A| = \\left[ {\\begin{array}{*{20}c}\n\t\t\\lambda - 4 & -2 & 1 & -1 \\\\\n\t\t-2 & \\lambda - 5 & 0 & 1 \\\\ \n\t\t1 & 0 & \\lambda - 2 &  -1 \\\\\n\t\t-1 & 1 & -1 & \\lambda - 2  \n\t\t\\end{array} } \\right] = 0$\n}\n\n\\vspace{1.0em}\n\n\\centerline {\n\t$\\lambda ^4 - 13 \\lambda ^3 + 52 \\lambda ^2 - 81 \\lambda + 25 = 0$, \n}\n\n\\vspace{1.0em}\n\n\\centerline {\n\t$\\lambda _1 = 6.6637$, $\\lambda _2 = 3.6360$, $\\lambda _3 = 2.7153$, $\\lambda _4 = -0.0151$\n}\n\n\\vspace{1.0em}\n\nThen, from the matrix we get the $V$ values, \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$V_1 = \\left[ {\\begin{array}{*{20}c}\n\t\t-9.2387 \\\\\n\t\t-11.7071 \\\\ \n\t\t2.1953 \\\\\n\t\t1  \n\t\t\\end{array} } \\right]$, \n\t$V_2 = \\left[ {\\begin{array}{*{20}c}\n\t\t0.9476 \\\\\n\t\t-0.6564 \\\\ \n\t\t0.0319 \\\\\n\t\t1  \n\t\t\\end{array} } \\right]$, \n\t$V_3 = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.5125 \\\\\n\t\t0.9964 \\\\ \n\t\t2.1143 \\\\\n\t\t1  \n\t\t\\end{array} } \\right]$,\n\t$V_4 = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.6963 \\\\\n\t\t0.4770 \\\\ \n\t\t-0.8417 \\\\\n\t\t1  \n\t\t\\end{array} } \\right]$,  \n}\n\n\\vspace{1.0em}\n\nThen, from the formula of $U_i = \\frac{AV_i}{\\sigma _i}$, we tried to find the $U$ value and got the following values:\n\n\\centerline  {\n\t$U_1 = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t-23.8491 \\\\\n\t\t-30.312 \\\\ \n\t\t5.6681 \\\\\n\t\t2.5814  \n\t\t\\end{array} } \\right] $, \t$U_2 = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t1.6564 \\\\\n\t\t-1.2517 \\\\ \n\t\t0.3620 \\\\\n\t\t2.0575  \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{1.0em}\n\n\\centerline {\n\t$U_3 = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.3444 \\\\\n\t\t1.4607 \\\\ \n\t\t3.4840 \\\\\n\t\t1.6768  \n\t\t\\end{array} } \\right] $, \t$U_4 = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t-0.0856 \\\\\n\t\t0.0418 \\\\ \n\t\t-0.1043 \\\\\n\t\t0.1220  \n\t\t\\end{array} } \\right] $\n}\n\n\nThus, the final $U$ will be: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$U = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t0.4475 & 0.2008 & −0.6208 & −0.6115 \\\\\n\t\t−0.3066 & −0.3472 & 0.4300 & −0.7749 \\\\ \n\t\t0.5410 & −0.8281 & −0.0210 & 0.1453 \\\\\n\t\t−0.6427 & −0.3917 & −0.6551 & 0.0662\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nAs we have found the $U$ matrix, now we could get the homography $H$ by finding the inverse of $U$ which gives us:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H = U^{-1} = \\frac{AV_i}{\\sigma _i} = \\left[ {\\begin{array}{*{20}c}\n\t\t0.4475 & −0.3066 & 0.5410 & −0.6427 \\\\\n\t\t0.2008 & −0.3472 & −0.8281 & −0.3917 \\\\ \n\t\t−0.6208 & 0.4300 & −0.0210 & −0.6551 \\\\\n\t\t−0.6115 & −0.7749 & 0.1453 & 0.0662\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nFinally, we could find the class by calculating $(H^{-1})^TAH^{-1}$ which gives the following matrix: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$(H^{-1})^TAH^{-1} =  \\left[ {\\begin{array}{*{20}c}\n\t\t-0.0152 & 0 & 0 & 0 \\\\\n\t\t0 & 2.7154 & 0 & 0 \\\\ \n\t\t0 & 0 & 3.6361 & 0 \\\\\n\t\t0 & 0 & 0 & 6.6637\n\t\t\\end{array} } \\right] $\n}\n\n\nAs we know from our lectures, the result is circular hyperboloid. \n\\section{Homework 8 - Point Equations}\nThe task here is to define the pairs of point equations for the direction and pair of plane equations for coordinate planes. As we know that, in $P2$ the lines and points are dual, but in $P3$ two points have 6 degree of freedom which is represented by two 4-vectors. Thus, for a given homogeneous coordinate system in $P3$, we have the following set of point equations that define the axes:\n\nAs we have learned from the lecture \n\n\\centerline {\n\t$ax_1 + bx_2 + cx_3 + dx_4 = 0$ gives $(a: b: c: d)$\n}\n\nwhere \n\n\\centerline {\n\t$\\pi ^TX = 0$ gives  $(a, b, c, d)^T \\left[ {\\begin{array}{*{20}c}\n\t\tx_1 \\\\\n\t\tx_2 \\\\ \n\t\tx_3 \\\\\n\t\tx_4   \n\t\t\\end{array} } \\right] = 0$\n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x = (1, 0, 0, 1)^T$, $y = (0, 1, 0, 1)^T$ and $z = (0, 0, 1, 1)^T$\n} \n\n\\vspace{0.5em}\n\nand the coordinate planes:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x - y = (0, 0, 1, 1)^T$, $y - z = (1, 0, 0, 1)^T$ and $x - z = (0, 1, 0, 1)^T$\n}\n\n\\vspace{0.5em}\n\nGiven the equation of the quadric used in the previous exercise:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$X^TAX = 4x_1^2 + 4x_1x_2 - 2x_1x_3 + 2x_1x_4 + 5x_2^2 - 2x_2x_4 + 2x_3^2 + 2x_3x_4 + 2x_4^2$\n}\n\n\\vspace{0.5em}\n\nwhich can be rewritten as: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$Q = \\left[ {\\begin{array}{*{20}c}\n\t\t4 & 2 & -1 & 1\\\\\n\t\t2 & 5 & 0 & -1 \\\\ \n\t\t-1 & 0 & 2 & 1 \\\\\n\t\t1 & -1 & 1 & 2  \n\t\t\\end{array} } \\right]$,\n}\n\n\\vspace{0.5em}\n\nas well as the following coordinates of a plane: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\pi = (2, 3, 1, 1)^T$\n}\n\nthus giving us the following null space:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$M_ \\pi = \\left[ {\\begin{array}{*{20}c}\n\t\t−0.775 & −0.258 & −0.258 \\\\\n\t\t0.604 & -0.132 & -0.132 \\\\ \n\t\t-0.132 & 0.956 & -0.044 \\\\\n\t\t-0.132 & -0.044 & 0.956  \n\t\t\\end{array} } \\right]$,\n}\n\n\\vspace{0.5em}\n\nFrom the relation of  $C = M_ \\pi ^TQM_ \\pi$, we obtain the relation for the conic:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$C = \\left[ {\\begin{array}{*{20}c}\n\t\t2.617 & 0.717 & −1.437 \\\\\n\t\t0.717 & 2.742 & 1.358 \\\\ \n\t\t-1.437 & 1.358 & 1.973  \n\t\t\\end{array} } \\right]$,\n}\n\n\\vspace{0.5em}\n\nthus, the conic is represented as following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$C = 2.617x_1^2 + 0.358x_1x_2 + 2.742x_2^2 - 0.718x_1x_3 + 0.679x_2x_3 + 1.973x_3^2$\n}\n\n\\section{Homework 9 - Equation of Conic}\n\nFirst of all, as we know a quadric is a surface in $P3$ defined by the equation \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$X^TQX = 0$\n}\n\n\\vspace{0.5em}\n\nwhere $Q$ is a symmetric $4 \\times 4$ matrix. \n\nIt's also clear that plane $\\pi$ can be found as following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\pi : ax + by + cz + d = 0$ and $n(x,y,z)^T + d = 0$\n}\n\n\\vspace{0.5em}\n\nwhere  $n$ is the normal to the plane computed by $n=(a,b,c)^T$ and $a$, $b$, $c$, $d$ are the points. \n\nThe intersection of a plane $\\pi$ with a quadric $Q$ is a conic. Computing the conic can be tricky because it requires a coordinate system for the plane. As we know, a coordinate system for the plane can be defined by complement space to $\\pi$ as \n\n\\centerline {\n\t$X= Mx$. \n}\n\nPoints on $\\pi$ are on $Q$ if \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$X^TQX = x^TM^TQMx = 0$\n}\n\n\\vspace{0.5em}\n\nThese points lie on a conic $C$, since $x^TCx = 0$ with $C = M^TQM$.\n\\section{Homework 10 - Proof for $cos(\\theta)$}  \n\nPoints on the plane at infinity $(\\pi _ \\infty)$, which may be written as $X_ \\infty = (d^T, 0)^T$ are mapped to the image plane by a general camera $P = CR[I|t]$ as \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$x = PX_ \\infty = CR[I|t](d^T, 0)^T = CRd$\n}\n\n\\vspace{0.5em}\n\nThus, in this case $H = CR$ is the planar homography between $(\\pi _ \\infty)$ and the image plane. Since the absolute conic $(\\Omega _ \\infty)$ is on $(\\pi _ \\infty)$, we can compute its image as \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\omega = (CC^T)^-1 = C^-TC^1$\n}\n\n\\vspace{0.5em}\n\nWe can simply prove this by $\\omega = (CR)^{-T} I (CR)^{-1}$ which is lastly equal to $C^{-T}C^{-1}$. \n\n\\vspace{0.5em}\n\nLike  $(\\Omega _ \\infty)$, $\\omega$ is an imaginary point conic with no real points. It cannot really be observed in an image. $\\omega$ is dependent only on the internal parameters of the camera and is independent of the camera's position or orientation. Thus,\nit follows from above that the angle between two rays is given by the simple equation:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$cos \\theta = \\frac{x_1^T(C^{-T}C^{-1})x_2}{\\sqrt{x_1^T(C^{-T}C^{-1})x_x \\sqrt{x_2^T(C^{-T}C^{-1})x_2}}} = \\frac{x_1^T \\omega x_1}{\\sqrt{x_1^T \\omega x_1} \\sqrt{x_2^T \\omega x_2}}$\n}\n\n\\vspace{0.5em}\n\nThe above expression is independent of the choice of the projective coordinate on the image. To see this consider any 2D projective transformation $H$. The points $x_i$ are transformed to $Hx_i$, and $\\omega$ transforms to $H^-T \\omega H^-1$. Hence, the expression for $cos (\\theta)$ is unchanged. Thus, it will still be valid for any projective frame. \n\n\n\\section{Homework 11 - Euclidean Rotation}\n\nThe idea here is that dual conic here the duality is between planes and points. Thus, $Q_ \\infty ^*$ is made by planes tangent to $(\\Omega _ \\infty)$, therefore any plane that belongs to $Q_ \\infty ^*$ envelope is tangent to $\\Omega$. \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$\\pi = \\Omega _ \\infty X = \\pi ^TQ_ \\infty ^* = 0$ \n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$Q_ \\infty ^* = \\left[ {\\begin{array}{*{20}c}\n\t\tI & 0 \\\\\n\t\t0^T & 0   \n\t\t\\end{array} } \\right]$,\n}\n\n\\vspace{0.5em}\n\nWhen we consider the Euclidean transformation represented by the matrix \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H_E = \\left[ {\\begin{array}{*{20}c}\n\t\tR & 0 \\\\\n\t\t0^T & 1   \n\t\t\\end{array} } \\right] =  \\left[ {\\begin{array}{*{20}c}\n\t\tcos \\theta & -sin \\theta & 0 & 0 \\\\\n\t\tsin \\theta & cos \\theta  & 0 & 0 \\\\ \n\t\t0 & 0 & 1 & 0 \\\\ \n\t\t0 & 0 & 0 & 1   \n\t\t\\end{array} } \\right] $,\n}\n\n\\vspace{0.5em}\n\nThis is a rotation by $ \\theta $ about the z-axis with a zero translation. Geometrically it is evident that the family of XY -planes orthogonal to the rotation axis are simply rotated about the Z -axis by this transformation.\n\nThis means that there is a pencil of fixed planes orthogonal to the Z -axis. The planes\nare fixed as sets, but not point-wise as any (finite) point (not on the axis) is rotated in horizontal circles by this Euclidean action. Algebraically, the fixed planes of H are the eigenvectors of $H^T$. We also need to mention that fixed planes are eigen-vectors of $H_E^T$ which we need to find it in order to define the planes. \n\nFor defining planes, we have to find the eigenvectors of $H_E^T$ by:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$[H_E^T - \\lambda I]v = 0 $ which gives $\\left[ {\\begin{array}{*{20}c}\n\t\tcos \\theta - \\lambda & sin \\theta & 0 & 0 \\\\\n\t\t-sin \\theta & cos \\theta - \\lambda & 0 & 0 \\\\ \n\t\t0 & 0 & 1 - \\lambda & 0 \\\\ \n\t\t0 & 0 & 0 & 1 - \\lambda   \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nThus, we have to find such $\\lambda$ that satisfies $det(H_E^T - \\lambda I) = 0$\n\n\\vspace{0.5em}\n\nCorresponding eigenvectors of $H_E^T$ are \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$E_1 = \\left( {\\begin{array}{*{20}c}\n\t\t1 \\\\\n\t\ti \\\\ \n\t\t0 \\\\\n\t\t0   \n\t\t\\end{array} } \\right)$, $E_2 = \\left( {\\begin{array}{*{20}c}\n\t\t1 \\\\\n\t\t-i \\\\ \n\t\t0 \\\\\n\t\t0   \n\t\t\\end{array} } \\right)$, \t$E_3 = \\left( {\\begin{array}{*{20}c}\n\t\t0 \\\\\n\t\t0 \\\\ \n\t\t1 \\\\\n\t\t0   \n\t\t\\end{array} } \\right)$, \t$E_4 = \\left( {\\begin{array}{*{20}c}\n\t\t0 \\\\\n\t\t0 \\\\ \n\t\t0 \\\\\n\t\t1   \n\t\t\\end{array} } \\right)$\n}\n\n\\vspace{0.5em}\n\nThe eigenvectors $E_3$ and $E_4$ are degenerate. However, $E_1$ and $E_2$ doesn't correspond to real planes. Thus there is a pencil of fixed planes which is spanned by these eigenvectors ($E_3$ and $E_4$). The axis of this pencil is the line of intersection of the the planes (perpendicular to the Z -axis) with $\\pi _ \\infty$, and the pencil includes $\\pi _ \\infty$ .\n\nThe example also illustrates the connection between the geometry of the projective\nplane, $P_2$ , and projective 3-space, $P_3$ . A plane $\\pi$ intersects $\\pi _ \\infty$ in a line which is the line at infinity,  $l_ \\infty$ , of the plane $\\pi$. A projective transformation of $P3$ induces a subordinate plane projective transformation on $\\pi$.\n\nTo conclude the ideas, those planes are span of eigen-vectors and they will not be affected because of transformation (not translation, but rotation).\n\n\\section{Homework 12 - Camera Centre }\n\nThe camera centre $C$ is the point for which $PC = 0$. Numerically, this right null-vector may be obtained from the SVD of $R$. Algebraically, the centre $C = (X, Y,Z,T)^T$, where \n\n\\centerline {\n\t$X=det([p_2, p_3, p_4])$, $Y=-det([p_1, p_3, p_4])$, \n}\n\n\\centerline {\n\t$Z=det([p_1, p_2, p_4])$, $T=-det([p_1, p_2, p_3])$\n}\n\nand the $P$ is \n\n\\centerline {\n\t$P=[M | -MC] = K[R | -RC ]$\n}\n\nWe can easily find K nad R by decomposing M as $M = KR$ using the $RQ$ decomposition. The matrix $R$ gives the orientation of camera, whereas $K$ is calibration matrix. \n\n\\centerline {\n\t\t$K = \\left[ {\\begin{array}{*{20}c}\n\t\t\\alpha _x & s & x_0\\\\\n\t\t0 & \\alpha _y & y_0 \\\\ \n\t\t0 & 0 & 1   \n\t\t\\end{array} } \\right]$ and $R|t = \\left[ {\\begin{array}{*{20}c}\n\t\tr_{11} & r_{12} & r_{13} & t_1 \\\\\n\t\tr_{21} & r_{22} & r_{23} & t_2 \\\\ \n\t\tr_{31} & r_{32} & r_{33} & t_3    \n\t\t\\end{array} } \\right]$\n}\n\nFor our problem we have $P$ as:\n\n\\centerline {\n\t$P = $\n}\n\nThus, when we decompose the matrix $M$ as $KR$ using QR-decomposition \n\n\\centerline {\n\t$P = [M| -MC]$ the centre $C = -R^Tt$\n}\n\nFor our problem, $M$ and $MC$ equals \n\n\\centerline {\n\t$M = \\left[ {\\begin{array}{*{20}c}\n\t\t0.6773 & 8.6606 & 7.9236 \\\\\n\t\t-4.2765 & 5.4432 & 7.8011 \\\\ \n\t\t-0.91189 & 0.4426 & 10.4433     \n\t\t\\end{array} } \\right]$, $MC = \\left[ {\\begin{array}{*{20}c}\n\t\t-2000000.61370 \\\\\n\t\t1000 \\\\ \n\t\t30.0518     \n\t\t\\end{array} } \\right] $\n}\n\nThen, we can compute $C$ by\n\n\n\nWe get  $C$ \n\n\\centerline {\n\t$C = \\left[ {\\begin{array}{*{20}c}\n\t\t27964.6 &  19.410.2 & 1635.09   \n\t\t\\end{array} } \\right]^T$\n}\n\nb) For this exercise, we needed to find the translation vector which can be calculated as \n\n\\centerline {\n\t$t = -RC$, thus $t =\\left[ {\\begin{array}{*{20}c}\n\t\t31751.7 \\\\\n\t\t19688.7 \\\\ \n\t\t-15127.2   \n\t\t\\end{array} } \\right] $\n}\n\n\n\\section{Homework 13 - Calibration Device }\n\\subsection{Implement a example of a simple calibration device}\n\n\n\n\\centerline {\n\t\\includegraphics[scale=0.5]{squares}\n}\n\nThe idea here is to take the image of three squares and compute the K. For this, we need to take several steps. As we know, for implementing the simple calibration device, we used to follow the steps that showed in the book. Firstly, we need to find the homography H for each square. \n\nThen, we need to compute the imaged circular points for the plane of that square as $H(1, \\pm i, 0)^T$. \n\n\nBefore the last step, we need to fit a conic $\\omega$ to the six imaged circular points. The constraint that the imaged circular points lie on $\\omega$ may be rewritten as two real contrains. If $h_1 \\pm ih_2$ lies on $\\omega$ then $(h_1 \\pm ih_2)^T \\omega ()h_1 \\pm ih_2) = 0$, and the imaginary and real parts give respectively: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$h_1^T \\omega h_2 = 0$ and $h_1^T \\omega h_1 = h_2^T \\omega h_2$\n}\n\n\\vspace{0.5em}\n\nwhich are equations linear in $\\omega$. \n\nFinally, we need to compute the calibration $K$ from $\\omega = (KK^T)-1$ using the Cholesky factorization. \n\n\\vspace{0.4em}\n\nThus, for the first step, we used OpenCV library in order to get the corners of the squares. The points are as following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t\t$S_1 =\\left[ {\\begin{array}{*{20}c}\n\t\t77.7704 & 75.5438 & 1.0 \\\\\n\t\t111.0461 & 208.2040 & 1.0  \\\\ \n\t\t246.7895 & 165.1987 & 1.0 \\\\\n\t\t243.4158 & 38.8666 & 1.0  \n\t\t\\end{array} } \\right] $, $S_2 =\\left[ {\\begin{array}{*{20}c}\n\t\t302.4889 & 42.3844 & 1.0 \\\\\n\t\t301.1318 & 164.1352 & 1.0  \\\\ \n\t\t423.8295 & 229.9800 & 1.0 \\\\\n\t\t452.5454 & 100.7878 & 1.0  \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nand the last square's coordinates are: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$S_3 =\\left[ {\\begin{array}{*{20}c}\n\t\t250.2883 & 197.7703 & 1.0 \\\\\n\t\t174.3199 & 164.1352 & 1.0  \\\\ \n\t\t423.8295 & 229.9800 & 1.0 \\\\\n\t\t348.1797 & 362.9188 & 1.0  \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nThen, we needed to find the homographies, and we have done it also using the library which gave overall three homographies. \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H_1 =\\left[ {\\begin{array}{*{20}c}\n\t\t1.09317181e-03 & 4.96735473e-03 & -4.61466910e-01 \\\\\n\t\t4.28243203e-03 & -1.13379462e-03 & -2.42372406e-01  \\\\ \n\t\t-8.34657587e-04 & -1.04738101e-03 & 1.00000000e+00 \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$H_2 =\\left[ {\\begin{array}{*{20}c}\n\t\t-4.38946955e-03 & 1.28792782e-02 & 7.44873229e-01 \\\\\n\t\t1.49341334e-02 & -1.30224096e-04 & -4.48894349e+00  \\\\ \n\t\t3.27712794e-03 & -2.49170706e-03 & 1.00000000e+00\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\n\n\\centerline {\n\t$H_3 =\\left[ {\\begin{array}{*{20}c}\n\t\t-4.73274525e-03 & 1.87530587e-02 & -2.50705370e+00 \\\\\n\t\t1.22991572e-02 & 8.54371755e-03 & -4.48894349e+00  \\\\ \n\t\t2.36397229e-04 & 4.24985472e-03 & 1.00000000e+00\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nThen, we had to compute the imaged circular points for the plane of that square as we mentioned above. Writing $H=[h_1, h_2, h_3]$, the imaged circular points are $h_1 +ih_2$ and $h_1 - ih_2$. From those equations, we have got the P matrices.\n\n\nAs the following step, we needed to fit a conic $\\omega$ to the six imaged circular points. The constraint that the imaged circular points lie on $\\omega$ may be written as two real constraints. Then, we had to find the $\\omega$ which we found by A matrix which is found by the columns of $H$ matrix. We have found the $\\omega$ as:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ \\omega =\\left[ {\\begin{array}{*{20}c}\n\t\t0.00000000e+00 \\\\\n\t\t7.07106781e-01 \\\\\n\t\t1.11022302e-16 \\\\\n\t\t1.00613962e-16 \\\\ \n\t\t-7.07106781e-01 \\\\\n\t\t-5.32072216e-16\n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nThen, we have divided the $\\omega$ with Numpy array into three conics and stored it into the array to find the Cholensky factorization. We have got the new matrix as following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ W =\\left[ {\\begin{array}{*{20}c}\n\t\t5.15012402e-01 & 7.07106781e-01 & 1.00613962e-16 \\\\\n\t\t7.07106781e-01 & 1.11022302e-16 & 2.55616781e-01\\\\\n\t\t1.00613962e-16 & 5.42056781e-05 & 3.45077216e-16 \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nFinally, using the Cholensky factorization (with \\textit{np.linalg}), we have computed the $K$ as following:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ K =\\left[ {\\begin{array}{*{20}c}\n\t\t1046.5 & -9.5 & 505.2 \\\\\n\t\t0 & 1064.2 & 374.4 \\\\\n\t\t0 & 0 & 1 \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\n\n\\subsection{Implement Vanishing Points}\n\nFirstly, vanishing point is the image of a point at infinity. Since parallel lines intersect at infinity, the intersection of parallel lines in the image is the vanishing point. As a result, we can two parallel lines, and find the intersection in the image, and the intersection is one vanishing points. Repeat this process, we can find a second and third vanishing point.\n\nAs we have discussed in class, there can be several vanishing in an image, depending on where the images were taken. It's also dependent on how many objects you have in the image. In order to find the vanishing points, you need to have several steps in mind: \\\\\n\n1. remember that all parallel lines will meet in a vanishing point\n\n2. know which lines in the image are really parallel \\\\ \n\nFor example, in the following picture we have found three vanishing points. \n\n\\vspace{0.5em}\n\n\\centerline {\n\t\\includegraphics[scale=0.4]{vanishing}\n}\n\n\\section{Homework 14 - Computing the DLT Algorithm}\n\nThe task here was to build a reference shape for calibration as a check-board typically checker-board must not be square. One side must contain an even number of squares and the other side must contain an odd number of squares. We need to measure the dimension of the check-board square. \n\nUsing the harry corner detector, we first found the corners and added them into our code for further computation. For our example, we have taken overall 8 points as shown in the following matrix where first row shows the $x$ axis and second row shows the $y$ axis. As the checker-board is in 2D we don't care about z-axis. At this stage, we get the matrix as following: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ x =\\left[ {\\begin{array}{*{20}c}\n\t\t454 & 663 & 238 & 658 & 237 & 25 & 442 & 445 \\\\\n\t\t236 & 442 & 1382 & 623 & 814 & 442 & 1317 & 412 \\\\\n\t\t1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 &  \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nWhen we normalize the matrices (by checking them with the ruler as mentioned in class), we get the following results: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ X =\\left[ {\\begin{array}{*{20}c}\n\t\t6 & 9 & 3 & 9 & 3 & 0 & 6 & 6 \\\\\n\t\t3 & 6 & 18 & 9 & 12 & 6 & 18 & 6 \\\\\n\t\t1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 &  \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nThe next step was to compute the A matrix using the points we have got, but before that we needed to get the correspondences of the coordination points. When, we computed them we also computed the A matrix which had overall 12 columns. \n\nThen, we have tried to compute $H$ by $H=AA^T$, as our A matrix had 12 columns, when we multiply it with it's transpose it will also give the same columns as $A$. After computing the $H$ matrix, we could get the $V$ by using eigen-vectors and after that we could get the $P$ which is the calibration matrix. The following matrix is calibration matrix which is $3 \\times 4$:\n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ P =\\left[ {\\begin{array}{*{20}c}\n\t\t65.4500 & 7.1226 & -14.6073 & 283.6928 \\\\\n\t\t-15.0209 & 39.2664 & 64.1435 & -1175.6065 \\\\\n\t\t0.0094 & 0.0249 & -0.0506 & 1.7929   \n\t\t\\end{array} } \\right] $\n}\n\n\\vspace{0.5em}\n\nAs we know from the $Exercise$ $12$, we could find M (which is the first $3 \\times 3$ matrix in P) and then we could get the $R$ and $K$ from the QR-decomposition of $M$. The following matrices are $M$, $R$ accordingly. \n\n\\vspace{0.5em}\n\n \\centerline {\n \t$ M =\\left[ {\\begin{array}{*{20}c}\n \t\t65.4500 & 7.1226 & -14.6073  \\\\\n \t\t-15.0209 & 39.2664 & 64.1435  \\\\\n \t\t 0.0094 & 0.0249 & -0.0506    \n \t\t\\end{array} } \\right] $, $ R =\\left[ {\\begin{array}{*{20}c}\n \t\t-0.9746 & -0.2236 & -0.0002  \\\\\n \t\t0.2236 & -0.9746 & -0.0005  \\\\\n \t\t-0.0001 & -0.0006 & 0.9999    \n \t\t\\end{array} } \\right] $\n }\n\n\\vspace{0.5em}\n\nFinally, we could find the $K$ which is the following matrix: \n\n\\vspace{0.5em}\n\n\\centerline {\n\t$ K =\\left[ {\\begin{array}{*{20}c}\n\t\t-67.1516 & 1.84118 & 28.5852  \\\\\n\t\t0.00000 & -39.8647 & -59.2506  \\\\\n\t\t0.00000 & 0.00000 & -0.0839    \n\t\t\\end{array} } \\right] $,\n}\n\n\\vspace{0.5em}\n\nFinally, it was asked to compute the algebraic and geometric errors and then comparing the results obtained by the DLT with the results obtained with the calibration using the absolute conic. In our case error decreased after every iteration and the table is as follows:\n\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\label{tab:table1}\n\t\t\\begin{tabular}{l|c|r} \n\t\t\t$iter$ & $error$ \\\\\n\t\t\t\\hline\n\t\t\t1 & 1.53 \\\\\n\t\t\t2 & 1.10 \\\\\n\t\t\t... & ... \\\\\n\t\t\t8 & 0.35 \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\n\n\\end{document}\n", "meta": {"hexsha": "bf98588634f7542d405c30378c2c908fb1d73a25", "size": 39814, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HOMEWORK/HW1/SOLVED/template_Article.tex", "max_stars_repo_name": "nijatmursali/vision-and-perception", "max_stars_repo_head_hexsha": "8787ec5350dd0f2b8baa763f0cbc892fa582e2e1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HOMEWORK/HW1/SOLVED/template_Article.tex", "max_issues_repo_name": "nijatmursali/vision-and-perception", "max_issues_repo_head_hexsha": "8787ec5350dd0f2b8baa763f0cbc892fa582e2e1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HOMEWORK/HW1/SOLVED/template_Article.tex", "max_forks_repo_name": "nijatmursali/vision-and-perception", "max_forks_repo_head_hexsha": "8787ec5350dd0f2b8baa763f0cbc892fa582e2e1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.4369189907, "max_line_length": 536, "alphanum_fraction": 0.6328678354, "num_tokens": 15503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7577943658046608, "lm_q1q2_score": 0.4260141960764366}}
{"text": "% !TeX root = ../thesis.tex\n% !TeX spellcheck = en_GB\n% !TeX encoding = UTF-8\n\nA forward start option is an option that starts at a specified future date (called the \\emph{determination date}), with an expiration date set further in the future\\footnote{\\url{http://www.math.umn.edu/~spirn/5076/Lecture16.pdf} (Page 5)}. A forward start option starts at a specified date in the future; however, the premium is paid in advance, and the time of expiration is established at the time the forward start option is purchased. Since the asset price at the start of this option is not known a priori, it is common to specify that the strike price will be set in the future so that the option is initially at the money or a certain percentage in the money or out of the money.\n\nThe payoff of a forward start call option with time to expiration $ T $ and such that the strike is determined at the money at time $ u $ is given by $ (S_T - S_u)_+ $\\footnote{\\url{http://www.stat.nus.edu.sg/~stalimtw/MFE5010/PDF/L2forward.pdf}}.\n\nA \\emph{cliquet option} or a \\emph{ratchet option} is an exotic option consisting of a series of consecutive forward start options. The first such option is active immediately, and once it expires the second comes into existence, and so on. Each option is struck \\emph{at-the-money} when it becomes active. Therefore, such an option periodically settles and resets its strike price at the level of the underlying during the time of settlement. Investors can opt to receive their payout either when each option expires or wait until the entire time has elapsed.\n\nUsually, the return on a cliquet option is capped and floored. The capping and flooring may be local or global (or both). The motivation behind bounding the return is to provide the investor safety against downside risks, yet allowing significant upside potential. Consequently, the investor is also constrained from having unbounded gains. Capping the maximum ensures that the payoff is never too extreme and therefore that the value of the contract is not too outrageous. Some variants of cliquet options are as follows:\n\\begin{description}\n\t\\item[Reverse cliquet] Amounts to a cash flow minus a capped cliquet of puts.\n\t\\item[Digital cliquet] The forward-starting options are digital options.\n\\end{description}\n\nThe following example, copied verbatim from Investopedia\\footnote{\\url{http://www.investopedia.com/terms/c/cliquet.asp}}, provides a good illustration.\n\\begin{eg}\n\tA three-year cliquet option with a strike of 1000 would expire worthless on the first year if the underlying was to be 900. This value (900) would then be the new strike price for the following year and should the underlying on the settlement be 1200, the contract holder would receive a payout and the strike would reset to this new level. Higher volatility provides better conditions for investors to earn profits.\n\\end{eg}\n\n\n\n\\paragraph{Literature review}\nThe literature for pricing of cliquet options is primarily based on partial differential equations (PDE) techniques. Notable mentions include Wilmott's finite difference (FD) approach in a non-linear uncertain volatility model (UVM) in 2002 \\cite{Wilmott2002}. Later in 2006, Windcliff et al.\\cite{Windcliff2006} explored a variety of modelling alternatives, including jump diffusion models, local volatility and UVM models, again using finite differences methods. They compared the use of a running sum of returns formulation to an average return formulation. Methods for grid construction, interpolation of jump conditions, and application of boundary conditions were also compared.\n\n\n\\paragraph{Lattice method}\nGaudenzi \\emph{et al}\\cite{Gaudenzi2011} introduced a discrete method for pricing cliquet options in the Cox Ross Rubinstein model \\cite{Cox1979} introduced in Chapter \\ref{cha:models}. This singular points method is faster than the alternative lattice based approaches available, while retaining a fair bit of flexibility to handle varying volatilities and rates of interest. Most of the chapter is inspired by this paper.\n\nThe central idea of the method, as we saw in Chapter \\ref{cha:asian}, is to give, at every monitoring date, a continuous representation of the cliquet option price as a piecewise-linear function of the sum of the returns over the corresponding period. This function is characterized only by a set of points, called \\emph{singular points}, which can easily be computed recursively by backward induction. Although the number of singular points grows rapidly at every monitoring date, it is possible to reduce their number drastically in a\nstraightforward way, controlling the error involved by the elimination procedure at the same time. Moreover, the error control process leads automatically to the convergence of the approximations to the continuous value.\n\n\n\n\\section{Cliquet contracts and models}\n\\label{sec:clq-models}\n\nJust as in the case of Asian options, we shall assume that the evolution of the prices of the risky asset $ (S_t)_t $ is governed by the Black-Scholes stochastic differential equation as discussed in Equation \\ref{eq:continuous-risky-sde-risk-neutral} of Chapter \\ref{cha:models}. Its solution is given by Equation \\ref{eq:continous-risky}b. Whenever there is a continuous divident yield, we modify the equation according the remark \\ref{rem:continuous-dividend}. Moreover, we shall consider the discrete model setup exactly as described in the beginning of Section \\ref{sec:asian-binom} of Chapter \\ref{cha:asian}.\n\n\nLet $T$ be the maturity of the cliquet contract. Let the payoffs depend on the $ N $ preordained observation times $ t_1, t_2, \\dots, t_{N} $ ($ t_0 = 0 $). At these observation times, the value of the underlying are $ ( S_i )_i, S_i = S_{t_i}, i \\in \\left[ N \\right] $. The returns for the time interval $ ( t_{i-1}, t_i ] $ are given by\n\\begin{equation}\n\t\\label{eq:clq-return}\n\tR_i = \\frac{S_i - S_{i-1}}{S_{i-1}} = \\frac{S_i}{S_{i-1}} - 1 \\ .\n\\end{equation}\n\nDuring each time interval, the return is capped and floored locally by the quantities $ C_{loc} $ and $ F_{loc} $. In other words, we consider the quantity $ \\max \\{ F_{loc}, \\min \\{ C_{loc}, R_i \\} \\} $ rather than the return itself. The sum of these quantities till time $t_i$ is called the `running sum' and is given by\n\\begin{equation}\n\t\\label{eq:clq-rsz}\n\tZ_i = \\sum_{k = 1}^{i} \\max \\{ F_{loc}, \\min \\{ C_{loc}, R_k \\} \\}.\n\\end{equation}\n\nWe also consider a global cap $ C_{glob} $ and floor $ F_{glob} $. Thus, the expression for the payoff finally becomes\n\\begin{equation}\n\t\\label{eq:clq-payoff}\n\t\\mathrm{payoff} = \\mathrm{notional} \\cdot \\max \\{ F_{glob}, \\min \\{ C_{glob}, Z_{N} \\} \\}.\n\\end{equation}\n\nFor ease of notation, we take $ \\mathrm{notional} = 1 $.\n\nWe note that the case $ C_{glob} > N C_{loc} $ is equivalent to $ C_{glob} = N C_{loc} $. Similarly, the case $ F_{glob} < N F_{loc} $ is equivalent to $ F_{glob} = N F_{loc} $. In general, we may write the following.\n\\begin{subequations}\n\t\\label{eq:clq-update-glob}\n\t\\begin{align*}\n\t\tF_{glob} &= \\max \\{ N F_{loc}, F_{glob} \\}  \\\\\n\t\tC_{glob} &= \\min \\{ N C_{loc}, C_{glob} \\}\n\t\\end{align*}\n\\end{subequations}\n\nWe assume that the difference between two observation times is constant and we denote by $m$ the number of steps of the binomial tree in every period (so that the total number of steps of the binomial tree is $ n = m N $).\n\n\n\n\\section{The singular points method for cliquet options}\n\\label{sec:clq-sp}\n\nThe binomial method may always be used to price any option, including path-dependent ones. The binomial method looks through all possible paths of the underlying in order to price the option. The number of possible paths are $ 2 ^ {m N} $. Thus, the method is inherently extremely computationally expensive due to the exponential dependence of the number of paths on $m$ and $ N $. The theoretical computational complexity is $ O( m^{N} ) $, as in \\cite[Page 128]{Gaudenzi2011}.\n\nA modification of the singular points method described in the previous chapter solves this problem for cliquet options by the process of approximation. The method of approximation selectively removes certain paths that would be normally considered, but which do not affect the result in a significant manner. This may be done by putting an \\emph{a priori} error bound while removing points. The method turns out to be significantly faster and memory efficient compared to known binomial techniques. Moreover, its flexible is evinced by the fact that it is adaptable for varying interest rate and volatility in each observational period.\n\nThe price function in the cliquet case is not necessarily convex due to the presence of a global cap (see Figure \\ref{fig:clq-maturity}), as opposed to the Asian case. Since the algorithm starts from maturity, it follows that we cannot assume convexity at any point of time. It was primarily the convexity of the price functions in the Asian case that allowed us to obtain simple upper and lower bounds of the exact binomial price. Nevertheless, in the case of cliquet options, the singular points approach still provides an efficient binomial framework, even in the absence of convexity of the price functions, as we shall see.\n\nWe redefine singular points to exclude the constraint of convexity. The reader is advised to keep in mind the ideas introduced in Section \\ref{subsec:asian-notations} of Chapter \\ref{cha:asian}.\n\n\\begin{dfn}[singular points and singular values]\n\t\\label{def:clq-sp}\n\tLet $ P = (P_i)_{i \\in [n]} = ( (x_i, y_i) )_{i \\in [n]} $, $ n \\in \\mathbb{N} $ be a sequence of points such that $ a = x_0 < x_1 < \\dots < x_{n-1} < x_n = b \\  \\forall i \\in [n] $.\n\t\n\tLet $ f:[a,b] \\to [0, \\infty) $ be the function obtained by linear interpolation of the points in $P$. The definition of $f$ ensures that the function is continuous and piecewise-linear.\n\t\n\tThen, the elements of $P$ are called \\emph{singular points of $f$} and the abscissae $ \\{ x_i \\}_{i \\in [n]} $ are called \\emph{singular values of $f$}.\n\\end{dfn}\n\n\n\\begin{rem}[characterisation]\n\t\\label{rem:clq-char}\n\tNote that the singular points characterise such a function completely, even without the requirement of convexity. This is clear from \\ref{rem:asian-char}.\n\\end{rem}\n\n\n\\subsection{The method}\n\\label{subsec:clq-method}\n\nOur aim is to look at every possible value taken by the running sum $Z$ within the bounds $ [ F_{loc}, C_{loc} ] $ for each time interval $ t_1, \\dots, t_{N} $. If we know the price function at maturity, we may use a backward procedure (in time) in order to obtain a continuous representation of the cliquet price as a piecewise-linear function of the running sum $Z$. Since it is piecewise-linear and continuous, the function may be represented using its singular points. Thus, we see an evolution of singular points as we go back in time. Since the number of singular points may be significantly high for any computer, we shall introduce an error controlled approximation procedure to reduce the number of singular points.\n\nLet the number of singular points at each observational time $ t_i $ be $ L_{i} $, where $ i \\in \\{ 1, \\dots, N \\} $. For each singular point $ l \\in \\{ 1, \\dots, L_i \\} $, the abscissa is called the \\emph{singular running sum} $ Z_i^l $ and the ordinate is called the \\emph{singular price} $ P_i^l $. Thus, the singular points are denoted by\n\\begin{equation*}\n\t( Z_i^l, P_i^l ) \\qquad \\forall l \\in \\{ 1, \\dots, L_i \\}\n\\end{equation*}\n\n\n\\paragraph{At maturity}\nAt maturity ($ t_{N{obs}} = T $), for every running sum $Z$, the price of the cliquet option $ V_{N}(Z) $ as function of $Z$, is given by\n\\begin{equation}\n\t\\label{eq:clq-vnobs-maturity}\n\tV_{N}(Z) = \\max \\{ Fglob, \\min\\{ Cglob, Z \\} \\}\n\\end{equation}\n\nWe note the following.\n\\begin{enumerate}\n\t\\item $ V_{N}(Z) $ is a continuous and piecewise-linear function \n\t\\item $ V_{N}(Z) $ is defined in the interval $ [ N F_{loc}, N C_{loc} ] $\n\t\\item There are only four points where the function changes slope, namely $ N F_{loc} $, $ F_{glob} $, $ C_{glob} $ and $ N C_{loc} $. This is because if $ Z < F_{glob} $, the price is constant. Same can be said about $ Z > C_{glob} $. Thus the four numbers enumerated above form the complete set of singular running sums at maturity ($ L_N = 4 $).\n\\end{enumerate}\n\nFocusing further on point 3 above, we note down the singular running sums and corresponding prices.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Singular points at maturity}\n\t\\label{tab:clq-maturity}\n\t\\begin{tabular}{ccc}\n\t\t\\toprule\n\t\t$l$  &  $ Z_{N}^l $  &  $ P_{N}^l $ \\\\\n\t\t\\midrule\n\t\t1  &  $ N F_{loc} $  &  $ F_{glob} $ \\\\\n\t\t2  &  $ F_{glob} $  &  $ F_{glob} $ \\\\\n\t\t3  &  $ C_{glob} $  &  $ C_{glob} $ \\\\\n\t\t4  &  $ N C_{loc} $  &  $ C_{glob} $ \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\nA more visual representation of the price function at maturity is given in Figure \\ref{fig:clq-maturity}.\n\\begin{figure}[h]\n\t\\centering\n\t\n\t\\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}\n\t\\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}\n\t\\definecolor{qqqqff}{rgb}{0.,0.,1.}\n\t\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]\n\t\\draw[->,color=black] (0.,0.) -- (9.,0.);\n\t\\foreach \\x in {,1.,2.,3.,4.,5.,6.,7.,8.}\n\t\\draw[shift={(\\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);\n\t\\draw[color=black] (8.77813297657717,0.054247335995569544) node [anchor=south west] { Z};\n\t\\draw[->,color=black] (0.,0.) -- (0.,5.);\n\t\\foreach \\y in {,1.,2.,3.,4.}\n\t\\draw[shift={(0,\\y)},color=black] (2pt,0pt) -- (-2pt,0pt);\n\t\\draw[color=black] (0.06780919373316127,4.698691618151926) node [anchor=west] { P};\n\t\\clip(-0.5,-0.5) rectangle (9.,5.);\n\t\\draw [line width=1.2pt] (1.,1.)-- (2.,1.);\n\t\\draw [line width=1.2pt] (2.,1.)-- (7.,4.);\n\t\\draw [line width=1.2pt] (7.,4.)-- (8.,4.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (1.,1.)-- (1.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (2.,1.)-- (2.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (7.,4.)-- (7.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (8.,4.)-- (8.,0.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (1.,1.)-- (0.,1.);\n\t\\draw [line width=0.4pt,color=cqcqcq] (7.,4.)-- (0.,4.);\n\t\\begin{scriptsize}\n\t\\draw [fill=qqqqff] (1.,1.) circle (1.5pt);\n\t\\draw[color=qqqqff] (0.9258283422770954,1.3896041224221845) node {$S_1$};\n\t\\draw [fill=qqqqff] (2.,1.) circle (1.5pt);\n\t\\draw[color=qqqqff] (1.7666623445682952,1.3896041224221845) node {$S_2$};\n\t\\draw [fill=qqqqff] (7.,4.) circle (1.5pt);\n\t\\draw[color=qqqqff] (7.204959681967829,3.5594975622449665) node {$S_3$};\n\t\\draw [fill=qqqqff] (8.,4.) circle (1.5pt);\n\t\\draw[color=qqqqff] (8.181412071725351,3.6001830642416435) node {$S_4$};\n\t\\draw [fill=xdxdff] (1.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (0.5732205348646567,-0.31918696143825614) node {$F_{loc} N$};\n\t\\draw [fill=xdxdff] (2.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (2.254888539447056,-0.31918696143825614) node {$F_{glob}$};\n\t\\draw [fill=xdxdff] (7.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (6.526867744636216,-0.31918696143825614) node {$C_{glob}$};\n\t\\draw [fill=xdxdff] (8.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (8.452648846657995,-0.3463106294360409) node {$C_{loc} N$};\n\t\\draw [fill=xdxdff] (0.,1.) circle (1.5pt);\n\t\\draw[color=xdxdff] (-0.050624047480426926,0.73863609047535) node {$F_{glob}$};\n\t\\draw [fill=xdxdff] (0.,4.) circle (1.5pt);\n\t\\draw[color=xdxdff] (-0.07774772497369145,3.7358014042305676) node {$C_{glob}$};\n\t\\end{scriptsize}\n\t\\end{tikzpicture}\n\t\n\t\\caption{The price function at maturity}\n\t\\label{fig:clq-maturity}\n\\end{figure}\n\n\n\\paragraph{The penultimate time step}\n\nWe consider the time step $ N - 1 $. If the running sum at time $ t_{N - 1} $ is denoted by $ Z $, then the corresponding price depends on the possible returns of the underlying asset during the time interval $ [ t_{N - 1}, T ] $.\n\nWe revisit equation \\ref{eq:clq-return} once more. Now we note that since the number of time steps in each interval is $m$, there will be $m$ up movements or down movements of the asset. Thus, there are $ m + 1 $ possible outcomes, given by $ S_i = u^{-m + 2j} S_{i-1}, j \\in [m] $. Corresponding to these cases, there are also $ m + 1 $ returns, given by\n\\begin{equation}\n\t\\label{eq:clq-return-final}\n\tR_j = u^{-m + 2j} - 1 \\qquad j \\in [m]\n\\end{equation}\n\nSince the probability of an up movement in time $ \\Delta T $ is $p$, we have that the probability of each return is distributed binomially, and is given by\n\\begin{equation}\n\t\\label{eq:clq-prb-binom}\n\tp_j = \\binom{m}{j} p^j (1-p)^{m-j}\n\\end{equation}\n\nThe above derivations assume that there has been no local flooring or capping of the returns. In the case of such bounds, the actual possibilities are fewer in number, and we need to put bounds on $j$. We can do this in the following fashion.\n\nIn the case of a local floor, we must have\n\\begin{alignat*}{9}\n\t                 &&  F_{loc}  \\quad & \\ge \\quad  u^{ -m + 2 j_{\\min} } - 1 && \\\\\n\t\\implies  \\qquad &&  \\log(F_{loc} + 1)  \\quad & \\ge \\quad  ( -m + 2 j_{\\min} ) \\log(u)  &&  \\qquad \\qquad \\dots (\\log \\text{is monotonic}) \\\\\n\t\\implies  \\qquad &&  \\frac{\\log(F_{loc} + 1)}{\\log(u)}  \\quad & \\ge \\quad  ( -m + 2 j_{\\min} )  &&  \\qquad \\qquad \\dots (u > 1 \\implies \\log(u) > 0) \\\\\n\t\\implies  \\qquad &&  j_{\\min}  \\quad & \\le \\quad  \\frac{ \\log(F_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2}  &&  \\qquad \\qquad \\dots (u = e^{ \\sigma \\Delta T }) \\\\\n\t\\implies  \\qquad &&  j_{\\min}  \\quad & = \\quad  \\floor{ \\frac{ \\log(F_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2} }  &&  \\qquad \\qquad \\dots (j \\in [m]) \\\\\n\\end{alignat*}\nWhere $ \\floor{\\cdot} $ denotes the floor function.\n\nSimilarly, in the case of local cap, we have\n\\begin{alignat*}{9}\n\t                 &&  C_{loc}  \\quad & \\le \\quad  u^{ -m + 2 j_{\\max} } - 1 && \\\\\n\t\\implies \\qquad  &&  \\log(C_{loc} + 1)  \\quad & \\le \\quad  ( -m + 2 j_{\\max} ) \\log(u)  &&  \\qquad \\qquad \\dots (\\log \\text{is monotonic}) \\\\\n\t\\implies \\qquad  &&  \\frac{\\log(C_{loc} + 1)}{\\log(u)}  \\quad & \\le \\quad  ( -m + 2 j_{\\max} )  &&  \\qquad \\qquad \\dots (u > 1 \\implies \\log(u) > 0) \\\\\n\t\\implies \\qquad  &&  j_{\\max}  \\quad & \\ge \\quad  \\frac{ \\log(C_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2}  &&  \\qquad \\qquad \\dots (u = e^{ \\sigma \\Delta T }) \\\\\n\t\\implies \\qquad  &&  j_{\\max}  \\quad & = \\quad  \\ceil{ \\frac{ \\log(C_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2} }  &&  \\qquad \\qquad \\dots (j \\in [m]) \\\\\n\\end{alignat*}\nWhere $ \\ceil{\\cdot} $ denotes the ceiling function.\n\nWe represent by $ j_0 $ the number of possibilities of the return after enforcing the local floor and cap. Summarising\n\\begin{subequations}\n\t\\label{eq:clq-j-mix-max}\n\t\\begin{align}\n\t\tj_{\\min} &= \\floor{ \\frac{ \\log(F_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2} }  \\\\\n\t\tj_{\\max} &= \\ceil { \\frac{ \\log(C_{loc} + 1) }{ 2 \\sigma \\Delta T } + \\frac{m}{2} }  \\\\\n\t\tj_0 &= j_{\\max} - j_{\\min}\n\t\\end{align}\n\\end{subequations}\n\n$ \\forall j \\le j_{\\min} $, the return is $ F_{loc} $, and $ \\forall j \\ge j_{\\max} $, the return is $ C_{loc} $. For the other indices, the return remains unchanged.\n\nWe shift the indices from $ \\{ j_{\\min}, \\dots, j_{\\max} \\} $ to $ \\{ 0, \\dots, j_0 \\} $ by putting $ j' = j - j_{\\min} $. Table \\ref{tab:clq-shift} highlights the shifted indices, and the corresponding returns and probabilities.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Shifted returns and probabilities}\n\t\\label{tab:clq-shift}\n\t\\begin{tabular}{cccc}\n\t\t\\toprule\n\t\tRange$(j)$  &  $ j' $  &  $ R_j' $  &  $ p_j' $  \\\\\n\t\t\\midrule\n\t\t$ j \\le j_{\\min} $  &  $ 0 $  &  $ F_{loc} $  &  $ \\sum_{k=0}^{j_{\\min}} p_k $  \\\\\n\t\t$ \\{ j_{\\min} + 1, \\dots, j_{\\max} - 1 \\} $  &  $ j - j_{\\min} $ &  $ R_{j + j_{\\min}} $  &  $ p_{j + j_{\\min}} $  \\\\\n\t\t$ j \\ge j_{\\max} $  &  $ j_0 $  &  $ C_{loc} $  &  $ \\sum_{k=j_{\\max}}^{m} p_k $  \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\begin{rem}[shifted indices]\n\t\\label{rem:clq-shift}\n\tNote that the $ j' $s represents the indices of the possible paths that can \\emph{actually} be taken respecting the constraints of the local floor and cap, whereas $ j $ represents the indices of all possible paths without respect to any constraints. Thus, we are more interested in the shifted indices. Similarly, $ p_j' $ represents the probability of taking the path $ j' $, and $ R_j' $ represents the corresponding return.\n\\end{rem}\n\nNow we focus on how to determine the price function at time $ t_{N - 1} $. Recall that at maturity, the function $ V_{N}(Z) $ giving the price of the cliquet option as a function of the running sum $ Z $ at maturity, is the piecewise linear function whose singular points are presented in Table \\ref{tab:clq-maturity}. At the penultimate time step $ t_{N - 1} $, we must have $ Z \\in [ (N-1) F_{loc}, (N-1) C_{loc} ] $. Note that $ Z $ is the running sum till the penultimate time step. The price function at this time is given as a discounted conditional expectation of the price function at maturity given the information at penultimate time. Thus\n\\begin{equation}\n\t\\label{eq:clq-penultimate}\n\tV_{N-1} (Z) = e^{- m \\Delta T} \\sum_{j=0}^{j_0} \\left[ p_j' V_{N} (Z + R_j') \\right] ,\n\\end{equation}\nwhere $ p_j' $ and $ R_j' $ are given in Table \\ref{tab:clq-shift}.\n\nSince $ V_{N} $ is piecewise-linear and continuous, and the above is just a linear combination of such functions, the resulting function is also piecewise-linear and continuous, and thus may be completely represented by singular points. The next logical step is of course to figure out a method to compute these singular points.\n\nFrom equation \\ref{eq:clq-penultimate}, we note that each singular point $ l $ at maturity may have $ j_0 + 1 $ possible returns, given by\n\\begin{equation}\n\t\\label{eq:clq-b}\n\tB_{l,j} = Z_N^l - R_j' \\qquad j \\in [j_0]\n\\end{equation}\n\nThen the maximum number of singular points at time $ t_{N-1} $ is $ ( j_0 + 1 ) L_N $. But not all the running sums at time $ t_{N-1} $ would belong to the interval $ [ (N-1) F_{loc}, (N-1) C_{loc} $. All the $ B_{l,j} $ which belong to the interval become the abscissa of a singular point at time $ t_{N-1} $. The corresponding singular price is determined by formula \\ref{eq:clq-penultimate}. The term $ V_{N} (B_{l,j} + R_k') $, required by the formula, is computed using linearity of the price function at maturity. We just need to figure out the interval $ l_0 $ such that $ ( B_{l,j} + R_k' ) \\in [ Z_N^{l_0}, Z_N^{l_0 + 1} ] $, and evaluate $ V_{N} (B_{l,j} + R_k') $ by linear interpolation of the extrema. Such an interpolation gives not an approximation by the exact value due to the piecewise-linear nature of the original function.\n\nFinally, the singular points thus obtained are sorted in ascending order on the basis of the running sums. This ordered sequence of singular points $ ( ( Z_{N-1}^l, P_{N-1}^l ) )_l , l \\in \\{ 1, \\dots, L_{N-1} \\} $ completely characterises the price function at time $ V_{N-1}(Z) $.\n\n\n\\paragraph{At all times}\nThe previous argument may be applied iteratively in a backward fashion at each step $ N-2, N-3, \\dots, 1, 0 $ to obtain the singular points at each time step. At time 0, there is only one singular point $ (0, P_0^1) $, and $ P_0^1 $ provides the exact binomial price of the cliquet option. The equality of this price and the exact binomial price is proved in Proposition \\ref{thm:clq-equality}.\n\n\n\\begin{prp}[The singular points method gives the binomial price]\n\t\\label{thm:clq-equality}\n\t$ P_0^l $ coincides with the exact binomial price with $ n $ time steps of the cliquet option.\n\\end{prp}\n\n\\begin{proof}\n\tLet the running sum $ Z_{i_1, \\dots, i_k} = \\sum_{j=1}^{k} R_{i_j}', \\  (i_1, \\dots, i_k) \\in [j_0]^k, k \\in \\{ 1, \\dots, N \\} $, and associate them to the prices $ P_{i_1, \\dots, i_k} $.\n\tThen the exact binomial price $ Q_n $ of the cliquet option is given by\n\t\\begin{equation*}\n\t\tQ_n = e^{-rT} \\sum_{i_1, \\dots, i_N = 0}^{j_0} \\left( p_{i_1}' \\cdot \\dots \\cdot p_{i_N}' \\max \\left\\{ F_{glob}, \\min \\left\\{ C_{glob}, Z_{i_1, \\dots, i_N} \\right\\} \\right\\} \\right) ,\n\t\\end{equation*}\n\twhere $ p_{i_k}' $ is the probability of actually taking the path $ i_k $ at the time interval $ k $. This expression can be computed backward.\n\t\n\tAt maturity, set $ P_{i_1, \\dots, i_N} = \\max \\left\\{ F_{glob}, \\min \\left\\{ C_{glob}, Z_{i_1, \\dots, i_N} \\right\\} \\right\\} $.\n\t\n\tAlong the tree the prices $ P_{i_1, \\dots, i_k}, k \\in [N-1] $, are evaluated by the\n\tbackward formula\n\t\\begin{equation*}\n\t\tP_{i_1, \\dots, i_k}  =  e^{-r \\frac{T}{N}}  \\sum_{j=0}^{j_0} p_j' P_{i_1, \\dots, i_k, j}\n\t\\end{equation*}\n\t\n\tFinally, we get $ Q_n = e^{-r \\frac{T}{N}}  \\sum_{j=0}^{j_0} p_j' P_j $.\n\t\n\tWe now prove the result by backward induction. At maturity, for every choice of the running sum $ Z = Z_{i_1, \\dots, i_N} $, the price $ P_{i_1, \\dots, i_N} $ coincides with the value of the option $ v_N(Z) $. By construction (Equation \\ref{eq:clq-penultimate}), this holds true\n\talso for every running sum evaluated at step $ N - 1 $, and iteratively, at all the nodes\n\tof the tree. Thus, the price $ Q_n $ coincides with the price $ P_0^1 $ determined by the singular points algorithm.\n\\end{proof}\n\n\n\\begin{rem}[Generalisation]\n\tThe method is easily generalised to cases with (discrete) time-varying interest rates and volatilities. In other words, for each \\emph{observed} time interval $ [t_{i-1}, t_{i}] $ denoted by $ i \\in \\{1, 2, \\dots, N \\} $, we can take different values of $ r_i, \\sigma_i $. The technique requires modification only for the computation of the probabilities $ p' $ and the returns $ R' $ which have to be evaluated at every observation time by using the corresponding $ r_i $ and $ \\sigma_i $.\n\t\n\tIn fact, we may even take varying local floors and caps, denoted $ F_i^{loc}, C_i^{loc} $. In this case, we also have to compute $ j_{\\min}, j_{\\max}, j_0 $ for each period individually.\n\\end{rem}\n\n\n\\begin{rem}[Computational dependence on volatility]\n\tThe time of computation of the pure binomial method for cliquet options is strongly dependent on the volatility. In fact the total number of paths needed to determine the price is $ m^N $. Because of the presence of the global cap and floor, the number of paths can be reduced to $ ( j_0 + 1 ) N $, where $ j_0 = j_{\\max} - j_{\\min} $. But $ j_0 $ is strictly dependent on $ \\sigma $ (see Equation \\ref{eq:clq-j-mix-max}) and the difference in the computational time between large and small volatilities becomes very high (see also Table \\ref{tab:clq-results}).\n\\end{rem}\n\n\n\n\\subsection{Approximation}\n\\label{subsec:clq-approx}\n\nThe method demonstrated in Section \\ref{subsec:clq-method} gives us the actual binomial price of the cliquet option. But as was mentioned earlier, the computational complexity of the method is theoretically the same as that of the binomial method, which is $ m^N $. But contrary to the binomial method, the singular point method enables us to use precise, efficient and controlled approximation to accelerate the procedure significantly. Thus its efficacy become apparent when we have time and memory constraints, or we wish to substantially increase the number of intermediate time steps.\n\nThe prime idea of the approximation procedure is to remove singular points in a controlled manner in order to simplify the computations. To this end, we fix a given maximal level $ h > 0 $ of the error in each period. Now, we eliminate singular points in a fashion so that the function after deletion of the points ($ \\tilde{V}_i $) is different from the original function by less than ($ h $) at each point. This may be achieved as follows.\n\nStart with the point $ ( Z_i^1, P_i^1 ) $. Find the largest index $ l > 1 $ such that the distances between the straight line joining $ ( Z_i^1, P_i^1 ) $ and $ ( Z_i^l, P_i^l ) $ and the points $ ( Z_i^2, P_i^2 ), ( Z_i^3, P_i^3 ), \\dots, ( Z_i^{l-1}, P_i^{l-1} ) $ are always less than $ h $. Note that this, coupled with the fact that the original function is piecewise-linear, ensures that the differences in the values of the functions for any value of the running sum would be bounded over by $ h $. Now delete the points $ ( Z_i^2, P_i^2 ), ( Z_i^3, P_i^3 ), \\dots, ( Z_i^{l-1}, P_i^{l-1} ) $. The point $ ( Z_i^l, P_i^l ) $ now becomes the second singular point, and we continue the procedure iteratively starting with this point till we cover all the points. Figure \\ref{fig:clq-approx} elaborates on this graphically. The elimination of points $ S_3 $ to $ S_6 $ gives function $ V_1 $ (bold, blue), which has maximum error $ \\le h $. Elimination of points $ S_3 $ to $ S_7 $ gives function $ V_2 $ (dashed, red), which has maximum error $ > h $. Thus we choose $ V_1 $ as the approximation function.\n\nSince at each $ N $ the upper bound for the error is $ h $, if we repeat the approximation procedure at every observational time, the total error infused in the price of the option is bounded by $ Nh $.\n\n\n\\begin{figure}[h]\n\t\\centering\n\t\n\t\\definecolor{ffqqqq}{rgb}{1.,0.,0.}\n\t\\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}\n\t\\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}\n\t\\definecolor{qqqqff}{rgb}{0.,0.,1.}\n\t\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]\n\t\\draw[->,color=black] (0.,0.) -- (12.,0.);\n\t\\foreach \\x in {,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.}\n\t\\draw[shift={(\\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);\n\t\\draw[color=black] (11.72949725895975,0.0665249798016828) node [anchor=south west] { Z};\n\t\\draw[->,color=black] (0.,0.) -- (0.,8.);\n\t\\foreach \\y in {,1.,2.,3.,4.,5.,6.,7.}\n\t\\draw[shift={(0,\\y)},color=black] (2pt,0pt) -- (-2pt,0pt);\n\t\\draw[color=black] (0.08315626418944566,7.641135707448683) node [anchor=west] { P};\n\t\\clip(-0.5,-0.5) rectangle (12.,8.);\n\t\\draw [line width=2.pt,color=qqqqff] (1.,1.)-- (2.,1.);\n\t\\draw [line width=1.2pt] (2.,1.)-- (3.,1.75);\n\t\\draw [line width=1.2pt] (3.,1.75)-- (4.,2.);\n\t\\draw [color=cqcqcq] (1.,1.)-- (1.,0.);\n\t\\draw [color=cqcqcq] (2.,1.)-- (2.,0.);\n\t\\draw [color=cqcqcq] (3.,1.75)-- (3.,0.);\n\t\\draw [color=cqcqcq] (4.,2.)-- (4.,0.);\n\t\\draw [color=cqcqcq] (1.,1.)-- (0.,1.);\n\t\\draw [line width=1.2pt] (4.,2.)-- (6.,2.75);\n\t\\draw [line width=1.2pt] (8.,4.)-- (9.,5.);\n\t\\draw [line width=2.pt,color=qqqqff] (9.,5.)-- (10.,7.);\n\t\\draw [color=cqcqcq] (6.,2.75)-- (6.,0.);\n\t\\draw [color=cqcqcq] (9.,5.)-- (9.,0.);\n\t\\draw [color=cqcqcq] (11.,7.)-- (11.,0.);\n\t\\draw [line width=1.2pt] (6.,2.75)-- (8.,4.);\n\t\\draw [color=cqcqcq] (8.,4.)-- (8.,0.);\n\t\\draw [color=cqcqcq] (10.,7.)-- (10.,0.);\n\t\\draw [line width=2.pt,color=qqqqff] (10.,7.)-- (11.,7.);\n\t\\draw [line width=2.pt,color=qqqqff] (2.,1.)-- (9.,5.);\n\t\\draw [line width=1.2pt,dash pattern=on 4pt off 4pt,color=ffqqqq] (2.,1.)-- (10.,7.);\n\t\\draw [line width=1.6pt,dotted,color=qqqqff] (6.004094596374262,3.288054055071007)-- (6.,2.75);\n\t\\draw [color=cqcqcq] (10.,7.)-- (0.,7.);\n\t\\draw [line width=1.6pt,dotted,color=ffqqqq] (7.999695997451529,5.499771998088647)-- (8.,4.);\n\t\\begin{scriptsize}\n\t\\draw [fill=qqqqff] (1.,1.) circle (1.5pt);\n\t\\draw[color=qqqqff] (0.9857079256833694,1.3545251161896577) node {$S_1$};\n\t\\draw [fill=qqqqff] (2.,1.) circle (1.5pt);\n\t\\draw[color=qqqqff] (1.8339018204157151,1.40441885104092) node {$S_2$};\n\t\\draw [fill=qqqqff] (3.,1.75) circle (1.5pt);\n\t\\draw[color=qqqqff] (2.9149332548785085,2.0530374041073274) node {$S_3$};\n\t\\draw [fill=qqqqff] (4.,2.) circle (1.5pt);\n\t\\draw[color=qqqqff] (4.21217097623386,1.8201999748014375) node {$S_4$};\n\t\\draw [fill=xdxdff] (1.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (0.9191829143318129,-0.3917556036045157) node {$Z_1$};\n\t\\draw [fill=xdxdff] (2.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (1.950320590280939,-0.35849311370367437) node {$Z_2$};\n\t\\draw [fill=xdxdff] (3.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (2.948195760554287,-0.35849311370367437) node {$Z_3$};\n\t\\draw [fill=xdxdff] (4.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (3.9294396779897456,-0.3917556036045157) node {$Z_4$};\n\t\\draw [fill=xdxdff] (0.,1.) circle (1.5pt);\n\t\\draw[color=xdxdff] (0.05435776676157797,0.8888502575778783) node {$F_{glob}$};\n\t\\draw [fill=xdxdff] (0.,7.) circle (1.5pt);\n\t\\draw[color=xdxdff] (0.021095261085799705,6.8262047048780685) node {$C_{glob}$};\n\t\\draw [fill=qqqqff] (6.,2.75) circle (1.5pt);\n\t\\draw[color=qqqqff] (6.1413963054290015,2.5519747526199485) node {$S_5$};\n\t\\draw [fill=qqqqff] (8.,4.) circle (1.5pt);\n\t\\draw[color=qqqqff] (8.153777898813587,3.8159493688519217) node {$S_6$};\n\t\\draw [fill=qqqqff] (9.,5.) circle (1.5pt);\n\t\\draw[color=qqqqff] (9.201546827600602,4.847086555778005) node {$S_7$};\n\t\\draw [fill=qqqqff] (10.,7.) circle (1.5pt);\n\t\\draw[color=qqqqff] (10.16615949219817,6.809573459927647) node {$S_8$};\n\t\\draw [fill=qqqqff] (11.,7.) circle (1.5pt);\n\t\\draw[color=qqqqff] (11.197297168147298,6.792942214977227) node {$S_9$};\n\t\\draw [fill=xdxdff] (6.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (5.95845252421222,-0.3418618687532536) node {$Z_5$};\n\t\\draw [fill=xdxdff] (8.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (7.954202864758916,-0.35849311370367437) node {$Z_6$};\n\t\\draw [fill=xdxdff] (9.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (8.952078035032265,-0.37512435865409505) node {$Z_7$};\n\t\\draw [fill=xdxdff] (11.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (10.897934617065292,-0.37512435865409505) node {$Z_9$};\n\t\\draw [fill=xdxdff] (10.,0.) circle (1.5pt);\n\t\\draw[color=xdxdff] (9.933321952467724,-0.35849311370367437) node {$Z_8$};\n\t\\draw[color=qqqqff] (6.607071384889897,3.849211858752763) node {$V_1$};\n\t\\draw[color=ffqqqq] (5.675721225968106,3.9822618183561285) node {$V_2$};\n\t\\draw [color=qqqqff] (6.004094596374262,3.288054055071007)-- ++(-1.5pt,-1.5pt) -- ++(3.0pt,3.0pt) ++(-3.0pt,0) -- ++(3.0pt,-3.0pt);\n\t\\draw[color=qqqqff] (6.340971339483671,3.0841745910334106) node {$\\le$ h};\n\t\\draw [color=ffqqqq] (7.999695997451529,5.499771998088647)-- ++(-1.5pt,-1.5pt) -- ++(3.0pt,3.0pt) ++(-3.0pt,0) -- ++(3.0pt,-3.0pt);\n\t\\draw[color=ffqqqq] (8.30345917435459,4.847086555778005) node {>h};\n\t\\end{scriptsize}\n\t\\end{tikzpicture}\n\t\n\t\\caption{Approximation procedure}\n\t\\label{fig:clq-approx}\n\\end{figure}\n\n\n\\begin{rem}[Comparison with Asian options]\n\tWhile using approximations for Asian options, the error bound was $ nh $, where $ n $ was the number of time steps considered for computation (refer to Section \\ref{sec:asian-approx} of Chapter \\ref{cha:asian}). But in the case of the cliquet options, the error depends only on the $ h $ and the number of observations - precluding any dependence on the computational parameters. This technique gives a precise approximation of the price without considering upper and lower estimates.\n\\end{rem}\n\nThe following proposition proves that the approximation of the price obtained by this method does converge to the price of the cliquet option in the continuous model. The proposition and proof is directly from .\n\n\n\\begin{prp}[Convergence to the continuous model]\n\t\\label{thm:convergence-continuous}\n\tLet us denote by $ Q_n^h $ the approximation of the price evaluated with $ n $ time steps and with maximal level of error at every monitoring date $ h = h(n) $. If $ h(n) \\to 0 $ as $ n \\to \\infty $, then $ Q_n^{h(n)} $ converges to the price of the cliquet option in the continuous model.\n\\end{prp}\n\nWe skip the proof of the proposition since it is not the main focus of our exposition. The proof is mathematically delicate, and needs a general result on the weak convergence of stochastic processes. This is a generalisation of what we saw in Section \\ref{subsec:discrete-to-continuous} of Chapter \\ref{cha:models}. The result may be found in \\cite{kushner1984approximation} and \\cite{Kushner:1992:NMS:151172}, and we refer the interested reader to \\cite[Proposition 2]{Gaudenzi2011} for a rigorous proof.\n\n\n\n\\clearpage\n\\section{The program}\n\\label{sec:clq-program}\n\n\\subsection{Algorithm}\n\n\\begin{algorithm}[H]\n\t\\DontPrintSemicolon\n\t\n\t\\KwIn{\\\\\n\t\t\\qquad \\emph{Contract details}  \\\\\n\t\t\\qquad \\quad time to maturity: $ T $ \\\\\n\t\t\\qquad \\quad number of observations: $ N $ \\\\\n\t\t\\qquad \\quad local floor and cap: $ F_{loc}, C_{loc} $  \\\\\n\t\t\\qquad \\quad global floor and cap: $ F_{glob}, C_{glob} $ \\\\\n\t\t\n\t\t\\qquad \\emph{Details of the underlying asset}  \\\\\n\t\t\\qquad \\quad initial price: $ s_0 $, volatility: $ \\sigma $, continuous dividend rate: $ q $  \\\\\n\t\t\n\t\t\\qquad \\emph{Market parameters} -- spot interest rate: $ r $ \\\\\n\t\t\n\t\t\\qquad \\emph{Computational parameters} -- time steps within each observed period: $ m $ \\\\\n\t}\n\t\n\t\\KwOut{The price of the option at the initial time}\n\t\n\t\\Begin{\n\t\tUpdate $ F_{glob} $ and $ C_{glob} $ using Equations \\ref{eq:clq-update-glob}. \\;\n\t\t\n\t\tSet $ \\Delta T, u, p $ from the formulae in Section \\ref{sec:clq-models}. \\;\n\t\t\n\t\tCompute the returns and probabilities using Equation \\ref{eq:clq-return-final} and Equation \\ref{eq:clq-prb-binom}. \\;\n\t\t\n\t\tCompute $ j_{\\min}, j_{\\max}, j_0 $ (Equations \\ref{eq:clq-j-mix-max}) and shifted returns (Table \\ref{tab:clq-shift}). \\;\n\t\t\n\t\t\\tcp{$ S_i $ and $ S_+ $ denotes the current ($ i^{\\mathrm{th}} $) and next ($ (i+1)^{\\mathrm{th}} $) list of singular points.}\n\t\t\n\t\t$ S_N \\leftarrow \\{ (N F_{loc}, F_{glob}), (F_{glob}, F_{glob}), (C_{glob}, C_{glob}), (N C_{loc}, C_{glob}) \\} $ \\tcp{Table \\ref{tab:clq-maturity}.}\n\t\t\t\t\n\t\t$ S_+ \\leftarrow S_N $ \\;\n\t\t\n\t\t\\For{$ i \\in \\{ N-1, \\dots, 0 \\} $}{\n\t\t\t$ S_i \\leftarrow \\emptyset, \\qquad L_+ \\leftarrow \\mathrm{length}(S_+) $ \\;\n\t\t\t\n\t\t\t\\ForAll{$ (l, j) \\in [L_+] \\times [j_0 + 1] $}{\n\t\t\t\tCompute $ B_{l,j} $ using Equation \\ref{eq:clq-b}, replacing $ N $ by $ i $. \\;\n\t\t\t\t\n\t\t\t\t\\If{ $ ( B_{l,j} + R_k' ) \\notin [ Z_N^{l_0}, Z_N^{l_0 + 1} ] $ } {\n\t\t\t\t\tContinue \\tcp*{to the next item in the loop}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tFind $ l_0 $ such that $ ( B_{l,j} + R_k' ) \\in [ Z_{i+1}^{l_0}, Z_{i+1}^{l_0 + 1} ] $. \\;\n\t\t\t\t\n\t\t\t\tEvaluate $ V_{i+1} (B_{l,j} + R_k') $ by linear interpolation of the extrema. \\;\n\t\t\t\t\n\t\t\t\tEvaluate $ V_{i}(B_{l,j}) $ by using Equation \\ref{eq:clq-penultimate}, replacing $ N $ by $ i $. \\;\n\t\t\t\t\n\t\t\t\t$ S_i \\leftarrow S_i \\cup (B_{l,j}, V_{N-1}(B_{l,j})) $ \\;\n\t\t\t}\n\t\t\t\n\t\t\tApproximate as described in Section \\ref{subsec:clq-approx}. \\;\n\t\t\t\n\t\t\t$ S_+ \\leftarrow S_i $ \\;\n\t\t}\n\t\t\\KwRet{$ (S_i)_{1,2} $    \\tcp*{Singular price at time 0} }\n\t}\n\t\n\t\\caption{Pricing cliquet options using the singular points method}\n\\end{algorithm}\n\n\n\\clearpage\n\\subsection{Implementation}\nThe algorithm was implemented in Python 3.5.0 (2015-09-13).\n\n\\paragraph{mymath.py}\nThis file contains the $ \\binom{n}{k} $ function.\n\n\\inputminted[tabsize=4]{python}{../code/mymath.py}\n\\label{lst:mymath}\n\n\\paragraph{cliquet.py}\nThis file contains the function \\emph{cliquet\\_sp}, which returns the price of the cliquet option at time 0.\n\n\\inputminted[tabsize=4]{python}{../code/cliquet.py}\n\\label{lst:clq}\n\n\n\n\\clearpage\n\\section{Results and conclusions}\n\\label{sec:clq-results}\n\nIn this section, we provide some numerical results that we have obtained from our program, along with the reported values of the same from \\cite[Section 4]{Gaudenzi2011}. They compare the results with other techniques, namely Monte Carlo and the finite difference method of Windcliff et al\\cite{Windcliff2006}. In all the experiments, the number of time steps considered were 10, 20, 50, 100, 200, 500 and 1000. The cases considered are as follows:\n\\begin{enumerate}\n\t\\item Constant volatility of $ \\sigma = 0.2 $\n\t\\item Constant volatility of $ \\sigma = 0.02 $, in order to test the efficiency of the methods for low volatility cases\n\t\\item Varying volatility for each observational period, as $ \\sigma(i) = 0.05 + 0.04i, i = 1, \\dots, 8 $. (This is denoted by \\emph{Var} in the $ \\sigma $ column of Table \\ref{tab:clq-results}.) The contract maturity is of 2 years, with quarterly monitoring dates.\n\\end{enumerate}\nIn order to obtain corroboration with the continuous value, we also report the price obtained by using Monte Carlo method with 1,000,000 of trials, along with the values in the 95\\% confidence interval.\n\nThe specifications of the cliquet contract for the cases with constant volatility are as follows.\n\\begin{itemize}\n\t\\item $ F_{loc} = 0, C_{loc} = 0.08, F_{glob} = 0.16, C_{glob} = \\infty $\n\t\\item $ T = 5 $ years\n\t\\item $ N = 5 $\n\t\\item $ r = 0.03 $\n\\end{itemize}\n\nAll simulations were run on a computer with the specifications given in Table \\ref{tab:specs} of Chapter \\ref{cha:asian}. All times were measured to 3 significant digits in seconds using the \\emph{timeit} module of python, run from the terminal.\n\nTable \\ref{tab:clq-results} highlights the results.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{Results for cliquet options}\n\t\\label{tab:clq-results}\n\t%\t\\rowcolors{1}{Burlywood1}{}\n\t\\begin{tabular}{rrccccc}\n\t\t\\toprule\n\t\t\\multirow{2}{1em}{$ \\sigma $}  &  \\multirow{2}{1em}{$ m $}\n\t\t&  \\multicolumn{3}{c}{Price}  &  \\multicolumn{2}{c}{Time (s)\\tablefootnote{$ \\infty $ means time taken is more than an hour.}}  \\\\\n\t\t\\cmidrule(lr){3-5}\\cmidrule(lr){6-7}\n\t\t&&  Bin  &  SP  &  MC  &  Bin  &  SP  \\\\\n\t\t\\midrule\n\t\t\\multirow{7}{2em}{$ 0.2 $}\n\t\t&    10  &  0.165661911  &  0.165661911  &  \\multirow{7}{5em}{0.174106 (0.17398 -- 0.17423)}  &  0.000561  &  0.000555  \\\\\n\t\t&    20  &  0.172300056  &  0.172300056  &    &  0.000671  &  0.000675  \\\\\n\t\t&    50  &  0.172501269  &  0.172501269  &    &  0.00185  &  0.00175  \\\\\n\t\t&   100  &  0.172501269  &  0.173927464  &    &  0.00413  &  0.00297  \\\\\n\t\t&   200  &  0.173716366  &  0.173716366  &    &  0.0165  &  0.00828  \\\\\n\t\t&   500  &  0.173922597  &  0.173922671  &    &  0.0875  &  0.0437  \\\\\n\t\t&  1000  &  0.174051949  &  0.174051983  &    &  2.38  &  0.183  \\\\\n\t\t\\midrule\n\t\t\\multirow{7}{2em}{$ 0.02 $}\n\t\t&    10  &  0.151234115  &  0.151234416  &  \\multirow{7}{5em}{0.150525 (0.150472 -- 0.150578)}  &  0.128  &  0.0295  \\\\\n\t\t&    20  &  0.149734212  &  0.149734992  &    &  1.01  &  0.199  \\\\\n\t\t&    50  &  0.150228984  &  0.150230185  &    &  7.96  &  0.868  \\\\\n\t\t&   100  &  0.150386306  &  0.150387954  &    &  70  &  2.36  \\\\\n\t\t&   200  &  0.150465004  &  0.150466828  &    &  600  &  6.09  \\\\\n\t\t&   500  &  0.150508871  &  0.150510526  &    &  $ \\infty $  &  24.2  \\\\\n\t\t&  1000  &  0.150522368  &  0.150524027  &    &  $ \\infty $  &  55  \\\\\n\t\t\\midrule\n\t\t\\multirow{7}{2em}{Var}\n\t\t&    10  &  0.188738321  &  0.188738321  &  \\multirow{7}{5em}{0.226169 (0.225978 -- 0.226360)}  &  0.00258  &  0.00253  \\\\\n\t\t&    20  &  0.192927333  &  0.192927296  &    &  0.0153  &  0.0139  \\\\\n\t\t&    50  &  0.192650261  &  0.192650204  &    &  0.510  &  0.0638  \\\\\n\t\t&   100  &  0.193452450  &  0.193452358  &    &  2.43  &  0.162  \\\\\n\t\t&   200  &  0.193657595  &  0.193657617  &    &  14.6  &  0.364  \\\\\n\t\t&   500  &  0.193742799  &  0.193742732  &    &  3600  &  1.11  \\\\\n\t\t&  1000  &  0.193776040  &  0.193776165  &    &  $ \\infty $  &  2.97  \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\n\\begin{rem}[Computational dependence on volatility]\n\tThe computational time of the pure binomial method for cliquet options is strongly dependent on the volatility. In fact the total number of paths needed to determine the price is $ m N $. Because of the presence of the global cap and floor, the number of paths can be reduced to $ (j_0 + 1) N $. But $ j_0 $ is strictly dependent on $ \\sigma $ (see Equation \\ref{eq:clq-j-mix-max}), and the difference in the computational time between large and small volatilities becomes very high, as is evinced from the constant volatility cases in Table \\ref{tab:clq-results}.\n\\end{rem}\n\n\n% This plot was generated by plotly\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{img/timing-cliquet}\n\t\\caption[Timing -- cliquet]{Timing the singular point method for cliquet option with constant volatility $ \\sigma = 0.2 $. The quadratic curve provides a pragmatic bound for the runtimes. The exponential curve is too conservative.}\n\t\\label{fig:clq-timing}\n\\end{figure}\n\n\n\\begin{rem}[Computational complexity]\n\tWe remarked earlier that although the computational complexity of the algorithm without approximation is the same as that of the binomial model, enabling approximations decreases the complexity to a polynomial time algorithm. In fact, the Figure \\ref{fig:clq-timing} corroborates exactly to this. The blue dots denotes the time taken to run the algorithm for constant volatility of $ \\sigma = 0.2 $. The brown bold curve is a quadratic function of the number of time steps $ m $, whereas the green dash-dot curve is an exponential function of the same. We varied the parameters so that the curves fits the data. We see that the quadratic function serves as an upper bound for the running time for most data points in the plot, except for a few points, which may be treated as outliers. Thus, we may conclude that the computational complexity of the algorithm is $ O(m^2) $ in this case. In fact, our experiments show that this is indeed the general trend. Thus, even though we have not found out the theoretical complexity of the algorithm, in practice the algorithm is competitive.\n\t\n\tNote that for the Asian case, the experimental complexity is $ O(n^3) $, whereas in the cliquet case, it is $ O(m^2) $. (Recall that in the cliquet case, $ n = N m $, where we can consider $ N $ as constant as it is specified in the contract.)\n\\end{rem}\n\n\n\\paragraph{Concluding remarks}\nWe note that, in all cases, the difference between the prices in obtained by the singular points method and the binomial method is significantly smaller than the theoretical value of $ N \\cdot 10^{-6} $. Moreover, as in the case examined $ N C_{loc} < C_{glob} $ (which is equivalent to $ N C_{loc} = C_{glob} $), the price functions $ V_i(Z) $ are always convex and this implies that the approximation procedure will provide an upper estimate of the exact binomial value.\n\nThus, the singular points method is quite capable in pricing cliquet options in a Black-Scholes framework with piecewise constant interest rates and volatilities. The implementation is quite simple, and the price obtained by the method converges to the price of continuous model. In absence of approximation, the price matches the exact binomial price. The ability to set \\emph{a priori} error bounds differentiates it from the alternative algorithms.\n\nNumerical comparisons indicate that the method is accurate both for standard and small volatilities, and that it avoids the computational problems arising from the application of the standard binomial method. For small volatilities and large numbers of observation times in particular, the improvement with respect to the binomial standard technique is very significant. Experimental results show that the computational complexity in practice is around $ O(m^2) $.\n\n\n%%% Local Variables:\n%%% LaTeX-command: \"latex -shell-escape\"\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "d58e1984eabcef96a4e04eeb96fb11c4a39d52e5", "size": 46552, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MathMods/Thesis/docs/tex/cliquet.tex", "max_stars_repo_name": "homdx/edu", "max_stars_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MathMods/Thesis/docs/tex/cliquet.tex", "max_issues_repo_name": "homdx/edu", "max_issues_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MathMods/Thesis/docs/tex/cliquet.tex", "max_forks_repo_name": "homdx/edu", "max_forks_repo_head_hexsha": "a32c9f1777f80a54c3d4a3fc8389748fe27739c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-09-15T21:30:43.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-15T21:30:43.000Z", "avg_line_length": 71.8395061728, "max_line_length": 1110, "alphanum_fraction": 0.6896803574, "num_tokens": 15553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.4260141911092249}}
{"text": "\\section{Model}\n\nThe TMD system is described by\nthe effective tight-biding, low-energy, two-valley Hamiltonian\n\\cite{PhysRevLett.108.196802},\n\\begin{equation}\n  \\label{eq:tmd:hamiltonian}\n  H_τ^0 \\ofK\n  = a t \\left( τ k_x σ_x + k_y σ_y \\right) ⊗ I_2\n    + \\frac{Δ}{2} σ_z ⊗ I_2 - λ τ \\left(σ_z - 1 \\right) ⊗ S_z.\n\\end{equation}\nThe (periodic) Bloch orbital states\n(see \\cref{s:appendix:tight-binding}) are\n\\begin{equation}\n  \\ketOrbitalK{ν}\n  = \\frac{T_{\\vK +  τ \\vc{K}}}{\\sqrt{N}}\n    ∑_{n = 1}^N e^{i \\left( \\vK + τ \\vc{K} \\right) ⋅ \\vRn{n}}\n    T \\of{\\vRn{n}} \\ketOrbital{ν},\n\\end{equation}\nwhere $N$ is the number of \\ce{M}-type atoms in the system,\n\\begin{subequations}\n  \\begin{alignat}{2}\n    & \\ketOrbital{+} && = \\Ket{d_{z^2}} ⊗ \\Ket{\\s}, \\\\\n    & \\ketOrbital{-} && = \\frac{1}{\\sqrt{2}}\n        \\left( \\Ket{d_{x^2 - y^2}} + i τ \\Ket{d_{xy}} \\right) ⊗ \\Ket{\\s},\n  \\end{alignat}\n\\end{subequations}\nand $\\Ket{d_{xy}}$ and $\\Ket{d_{x^2 - y^2}}$\nrefer to the angular momentum orbitals\nin the symmetry group $E \\left( d_{xy}, d_{x^2 - y^2} \\right)$.\nThe operators $σ_i$ are Pauli operators acting\non the two Bloch orbital states\n(indexed by $ν = ±$)\nsuch that $σ_z \\ketOrb{±}{\\ofK} = ± \\ketOrb{±}{\\ofK}$.\nThe valley index $τ = ±$, corresponding to the $± \\vc{K}$ points,\nand the spin index ${\\s} = ±$ (or ${\\s} =\\ ↑↓$),\ncorresponding to the $z$-component of the spin through $s_z = {\\s} / 2$,\nare good quantum numbers.%\n\\footnote{%\n  Only in this chapter do we use $s$ to denote spin.\n  In the appendices, we adopt the more traditional symbol $σ$.\n}\nThe momentum $\\vK$ is measured from the valley center,\ni.e., for a given valley, the total momentum relative to the center\nof the Brillouin zone is $\\vK + τ \\vc{K}$.\nThe energy gap is $Δ$, the spin splitting in the valence band is $2 λ$,\nthe lattice constant is $a$, and $t$ is the effective hopping integral.\n\\Cref{eq:tmd:hamiltonian}\ncan be written in matrix form in the Bloch orbital basis,\n\\begin{equation}\n  \\left[ H_{τ \\s}^0 \\ofK \\right]\n  = \\left[\n    \\begin{matrix}\n      \\dfrac{Δ}{2}                     & a t \\left( τ k_x - i k_y \\right) \\\\\n      a t \\left( τ k_x + i k_y \\right) & λ τ \\s - \\dfrac{Δ}{2}\n    \\end{matrix}\n    \\right].\n\\end{equation}\n\nThe energy spectrum,\n\\begin{equation}\n  \\label{eq:energy}\n  \\fnEnergy{n} \\of{k}\n  = \\frac{1}{2} \\left( λ τ {\\s} + n \\sqrt{{\\left( 2 a t k \\right)}^2\n  + {\\left( Δ - λ τ {\\s} \\right)}^2} \\right),\n\\end{equation}\nwith $k = \\abs{\\vK}$\nand $n = 1$ ($n = -1$) indexing the conduction (valence) band\nis shown in \\cref{fig:energy}.\nFor a fixed band, we have the inverse relation,\n\\begin{equation}\n  {\\left( \\frac{a t k}{Δ / 2} \\right)}^2\n  = {\\left( \\frac{2 E}{Δ} \\right)}^2\n    + 2 τ \\s \\left( \\frac{λ}{Δ} \\right) \\left( 1 - \\frac{2 E}{Δ} \\right) - 1,\n\\end{equation}\nwhere $E > Δ / 2$ for $n = 1$ and\n$E < - \\left( Δ / 2 - λ τ \\s \\right)$ for $n = -1$.\nNote the relations\n\\begin{subequations}\n  \\begin{align}\n    θ_{-↓}^{n} \\of{k} + θ_{+↑}^{n} \\of{k} & = 2π , \\\\\n    \\fnTheta{+} - \\fnTheta{-} & = - τ π, \\\\\n    ϕ_{-\\vK} - ϕ_{\\vK} & = π.\n  \\end{align}\n\\end{subequations}\n\n\\begin{figure}\n  \\includegraphics[width=\\columnwidth]{figures/energy-bands}\n  \\caption{%\n    Energy bands for $\\ce{WSe2}$ as given by \\cref{eq:energy}\n    with $a t = \\SI{3.939}{\\electronvolt \\per \\angstrom}$,\n    $Δ = \\SI{1.60}{\\electronvolt}$,\n    and $λ = \\SI{0.23}{\\electronvolt}$.\n    Each valley is centered at $± \\vc{K}$ relative to the center of the\n    Brillouin zone.\n    The energy for a given band depends only on the distance $k$\n    measured from the valley center.\n  }\\label{fig:energy}\n\\end{figure}\n\nWe focus on doped systems\nsuch that the chemical potential $μ$ lies in the upper valence bands.\nWithin each band, the Bloch basis eigenstates are written\nin terms of the orbital states as elements on the Block sphere,\n\\begin{equation}\n  \\Ket{u_{τ {\\s}}^n \\of{k, ϕ}}\n  = \\cos{\\frac{\\fnTheta{n}}{2}} \\ketOrb{+}{\\of{k, ϕ}}\n  + e^{-i τ ϕ}\n    \\sin{\\frac{\\fnTheta{n}}{2}} \\ketOrb{-}{\\of{k, ϕ}},\n\\end{equation}\nwhere $k_x + i τ k_y = k e^{i τ ϕ}$ and\n\\begin{equation}\n  \\tan{\\frac{\\fnTheta{n}}{2}}\n  = \\frac{a t τ k}{\\dfrac{Δ}{2} - \\fnEnergy{-n} \\of{k}}\n  = \\frac{a t τ k}{\\fnEnergy{n} \\of{k} - \\fnEnergy{-} \\of{0}}.\n\\end{equation}\nThe polar angle on the Bloch sphere\nof the conduction and valence bands are related by\n$\\fnTheta{-} - \\fnTheta{+} = τ π$.\nThe mapping of the energy band to the Bloch sphere,\nparametrized by $\\left( θ, ϕ \\right)$,\nencodes the topological character:\nas one moves from the node out to infinity,\nthe states sweep either the northern or southern hemisphere\nwith a chirality determined by the Berry curvature.\n", "meta": {"hexsha": "5ae90c08a54ef3d3716865cfd4b94303e7fcb62c", "size": 4623, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/_dichalcogenides-model.tex", "max_stars_repo_name": "razor-x/doctoral-thesis", "max_stars_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-25T23:01:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-25T23:01:11.000Z", "max_issues_repo_path": "tex/_dichalcogenides-model.tex", "max_issues_repo_name": "evansosenko/doctoral-thesis", "max_issues_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/_dichalcogenides-model.tex", "max_forks_repo_name": "evansosenko/doctoral-thesis", "max_forks_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.6904761905, "max_line_length": 77, "alphanum_fraction": 0.6234047156, "num_tokens": 1771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.42601418803413077}}
{"text": "\\chapter{Specifying and running a computation}\r\n\r\n\\section{Normalizations}\r\n\\label{sec:normalizations}\r\n\r\n{\\setlength{\\parindent}{0cm}\r\nDimensional quantities in \\sfincs~are normalized to ``reference'' values that are denoted by a bar:\\\\\r\n$\\bar{B}$ = reference magnetic field, typically 1 Tesla.\\\\\r\n$\\bar{R}$ = reference length, typically 1 meter.\\\\\r\n$\\bar{n}$ = reference density, typically $10^{20}$ m$^{-3}$, $10^{19}$ m$^{-3}$, or something similar.\\\\\r\n$\\bar{m}$ = reference mass, typically either the mass of hydrogen or deuterium.\\\\\r\n$\\bar{T}$ = reference temperature in energy units, typically 1 eV or 1 keV.\\\\\r\n$\\bar{v} = \\sqrt{2 \\bar{T} / \\bar{m}}$ = thermal speed at the reference temperature and mass\\\\\r\n$\\bar{\\Phi}$ = reference electrostatic potential, typically 1 V or 1 kV.\\\\\r\n}\r\n\r\nYou can choose any reference parameters you like, not just the values\r\nsuggested here. However, if you use a {\\ttfamily vmec} or {\\ttfamily .bc} magnetic equilibrium\r\nby choosing \\parlink{geometryScheme} = 5, 11, or 12, then you MUST use $\\bar{B}$ = 1 Tesla and $\\bar{R}$ = 1 meter.\r\nThe code ``knows'' about the reference values only through\r\nthe 3 combinations \\parlink{Delta}, \\parlink{alpha}, and \\underscoreparlink{nu\\_n}{nu_n}\r\nin the {\\ttfamily \\hyperref[sec:physicsParameters]{physicsParameters}} namelist.\r\n\r\nNormalized quantities are denoted by a ``hat''.  Taking the magnetic field as an example,\r\n$\\hat{B}=B/\\bar{B}$, where $\\hat{B}$ is called {\\ttfamily BHat} in the fortran code and \\HDF~output file.\r\n\r\n\\section{Radial coordinates}\r\n\\label{sec:radialCoordinates}\r\n\r\nA variety of flux-surface label coordinates are used in other codes and in the literature.\r\nOne common choice (used in \\vmec) is $\\psi_N$, the toroidal flux normalized to its\r\nvalue at the last closed flux surface.  Another common choice is an ``effective normalized minor radius''\r\n$r_N$, defined by $r_N=\\sqrt{\\psi_N}$.  For gradients of density, temperature, and electrostatic potential (i.e. the radial\r\nelectric field), it is useful to use a dimensional local minor radius $r = r_N a$, where $a$ is some\r\nmeasure of the plasma effective outer minor radius.  Finally, one could also use $\\psi$ directly.\r\nFor maximum flexibility, \\sfincs~permits any of these four radial coordinates to be used, and different radial\r\ncoordinates can be used in different aspects of a given computation.  Output quantities which depend\r\non the radial coordinate, such as radial fluxes, are often given with respect to all radial coordinates.\r\nIn \\sfincs, the four radial coordinates are named as follows:\\\\\r\n\r\n{\\setlength{\\parindent}{0cm}\r\n\r\n{\\ttfamily \\hypertarget{psiHat}{psiHat}} = $\\hat\\psi$ is the toroidal flux (divided by $2\\pi$), normalized by $\\bar{B}\\bar{R}^2$.\\\\\r\n\r\n{\\ttfamily \\hypertarget{psiN}{psiN}} = $\\psi_N$ is the toroidal flux normalized by its value at the last closed flux surface.\\\\\r\n\r\n{\\ttfamily \\hypertarget{rHat}{rHat}} = $\\hat{r}$ is defined as {\\ttfamily aHat}$\\sqrt{\\mbox{\\ttfamily psiN}}$, where {\\ttfamily aHat} is an effective minor radius of the last closed flux surface normalized by $\\bar{R}$.\\\\\r\n\r\n{\\ttfamily \\hypertarget{rN}{rN}} = $r_N$ is defined as $\\sqrt{\\mbox{\\ttfamily psiN}}$.\\\\\r\n\r\n}\r\n\r\nThese four radial coordinates are identified by the numbers 0, 1, 2, and 3 respectively.\r\n\r\nWhen setting up a run, you can make several independent choices for radial coordinates.  One parameter\r\nyou select is \\parlink{inputRadialCoordinateForGradients} in the \r\n{\\ttfamily \\hyperref[sec:geometryParameters]{geometryParameters}} namelist.\r\nThis parameter controls which coordinate is used to specify the gradients. The possible values of \\parlink{inputRadialCoordinateForGradients} are:\\\\\r\n\r\n{\\setlength{\\parindent}{0cm}\r\n\r\n0: Use derivatives with respect to {\\ttfamily psiHat}: Density gradients are specified using \\parlink{dnHatdpsiHats}, \r\ntemperature gradients are specified using \\parlink{dTHatdpsiHats},  a single $E_r$ is specified using\r\n\\parlink{dPhiHatdpsiHat}, and a range of $E_r$ for a scan is specified using \\parlink{dPhiHatdpsiHatMin}-\\parlink{dPhiHatdpsiHatMax}.\r\n\\\\\r\n\r\n1: Use derivatives with respect to {\\ttfamily psiN}: Density gradients are specified using \\parlink{dnHatdpsiNs}, \r\ntemperature gradients are specified using \\parlink{dTHatdpsiNs},  a single $E_r$ is specified using\r\n\\parlink{dPhiHatdpsiN}, and a range of $E_r$ for a scan is specified using \\parlink{dPhiHatdpsiNMin}-\\parlink{dPhiHatdpsiNMax}.\r\n\\\\\r\n\r\n2: Use derivatives with respect to {\\ttfamily rHat}: Density gradients are specified using \\parlink{dnHatdrHats}, \r\ntemperature gradients are specified using \\parlink{dTHatdrHats},  a single $E_r$ is specified using\r\n\\parlink{dPhiHatdrHat}, and a range of $E_r$ for a scan is specified using \\parlink{dPhiHatdrHatMin}-\\parlink{dPhiHatdrHatMax}.\r\n\\\\\r\n\r\n3: Use derivatives with respect to {\\ttfamily rN}: Density gradients are specified using \\parlink{dnHatdrNs}, \r\ntemperature gradients are specified using \\parlink{dTHatdrNs},  a single $E_r$ is specified using\r\n\\parlink{dPhiHatdrN}, and a range of $E_r$ for a scan is specified using \\parlink{dPhiHatdrNMin}-\\parlink{dPhiHatdrNMax}.\r\n\\\\\r\n\r\n4: Same as option 2, except the radial electric field is specified using \\parlink{Er}. Thus, derivatives with respect to {\\ttfamily rHat} will be used:\r\nDensity gradients are specified using \\parlink{dnHatdrHats}, \r\ntemperature gradients are specified using \\parlink{dTHatdrHats},  a single $E_r$ is specified using\r\n\\parlink{Er}, and a range of $E_r$ for a scan is specified using \\parlink{ErMin}-\\parlink{ErMax}.\r\n\\\\\r\n}\r\n\r\nThe most common choice is the default, 4.  The quantity \\parlink{Er} in both the input and output files is defined as \r\n$- d\\hat{\\Phi} / d \\hat{r} = -(\\bar{R} / \\bar{\\Phi}) d \\Phi / d r$.\r\n\r\nAnother choice involving radial coordinates is how to specify the flux surface for the computation.\r\nThis choice is made using the parameter \\parlink{inputRadialCoordinate} in the {\\ttfamily \\hyperref[sec:geometryParameters]{geometryParameters}}\r\nnamelist, which is again an integer from 0 to 3, and this parameter need not be the same as \\parlink{inputRadialCoordinateForGradients}.\r\nAn extra complication with specifying the flux surface is that the magnetic equilibrium file will contain data on a finite number of surfaces,\r\nand you may wish to use one of these surfaces.  For this reason, the parameters for specifying the flux surface have {\\ttfamily \\_wish}\r\nappended to the name. In other words, the allowed values for \\parlink{inputRadialCoordinate} are:\\\\\r\n\r\n{\\setlength{\\parindent}{0cm}\r\n\r\n0: Specify the flux surface using \\underscoreparlink{psiHat\\_wish}{psiHat_wish}.\\\\\r\n\r\n1: Specify the flux surface using \\underscoreparlink{psiN\\_wish}{psiN_wish}.\\\\\r\n\r\n2: Specify the flux surface using \\underscoreparlink{rHat\\_wish}{rHat_wish}.\\\\\r\n\r\n3: Specify the flux surface using \\underscoreparlink{rN\\_wish}{rN_wish}.\\\\\r\n\r\n}\r\n\r\nWhen using \\parlink{geometryScheme} == 11 or 12, \\sfincs~will always shift the ``wish'' value so it matches an available surface in the magnetic equilibrium file.\r\nFor \\parlink{geometryScheme} == 5, the \\parlink{VMECRadialOption} parameter lets you can choose whether to shift to the nearest surface in the magnetic equilibrium file,\r\nor to interpolate the \\vmec~data onto the exact value of radius you specify.\r\n\r\nIf you perform a radial scan, then there is a third choice you can make: which radial coordinate to use in the {\\ttfamily profiles} file.\r\nThis choice is made with an integer 0, 1, 2, or 3 in the first non-comment line of the {\\ttfamily profiles} file.\r\nThe radial coordinate used in the {\\ttfamily profiles} file need not be the same as either\r\n\\parlink{inputRadialCoordinate} or \\parlink{inputRadialCoordinateForGradients}.\r\nNote however that the maximum and minimum radial electric field specified in the {\\ttfamily profiles}\r\nfile must be given in terms of the electric field variable selected by \\parlink{inputRadialCoordinateForGradients}.\r\n\r\nFor more details about the behavior of \\parlink{inputRadialCoordinate}, \\parlink{inputRadialCoordinateForGradients}, and \\parlink{VMECRadialOption},\r\nsee section \\ref{sec:geometryParameters}.\r\n\r\n\\section{Trajectory models}\r\n\\label{sec:trajectoryModels}\r\n\r\nAs discussed in \\cite{sfincsPaper},\r\none of the capabilities of \\sfincs~is to compare various models for the terms in the kinetic equation involving $E_r$.\r\nThese variations of the kinetic equation are called ``trajectory models'' in \\cite{sfincsPaper}.\r\nThe relevant terms in the kinetic equation can be turned off and on by certain Boolean parameters in the {\\ttfamily \\hyperref[sec:physicsParameters]{physicsParameters}} namelist.\r\nThe models described in \\cite{sfincsPaper} are selected as follows:\\\\\r\n\r\n{\\setlength{\\parindent}{0cm}\r\n\r\n\\underline{Full trajectories:}\\\\\r\n{\\ttfamily \r\n\\parlink{includeXDotTerm} = .true.\\\\\r\n\\parlink{includeElectricFieldTermInXiDot} = .true.\\\\\r\n\\parlink{useDKESExBDrift} = .false.\\\\\r\n}\r\n\r\n\\underline{Partial trajectories:}\\\\\r\n{\\ttfamily\r\n\\parlink{includeXDotTerm} = .false.\\\\\r\n\\parlink{includeElectricFieldTermInXiDot} = .false.\\\\\r\n\\parlink{useDKESExBDrift} = .false.\\\\\r\n}\r\n\r\n\\underline{DKES trajectories:}\\\\\r\n{\\ttfamily\r\n\\parlink{includeXDotTerm} = .false.\\\\\r\n\\parlink{includeElectricFieldTermInXiDot} = .false.\\\\\r\n\\parlink{useDKESExBDrift} = .true.\\\\\r\n}\r\n}\r\n\r\nThere is not a significant difference in computational cost between these models.\r\n\r\n\r\n%\\section{Quasineutrality and variation of the electrostatic potential on the flux surface}\r\n\\section{Calculations with $\\Phi_1(\\theta,\\zeta)$, includePhi1 = {\\ttfamily .true.}}\r\n\\label{sec:qn}\r\n\r\nOne choice you should consider in setting up a computation is whether or not\r\nto include variation on the flux surface of the electrostatic potential, $\\Phi_1(\\theta,\\zeta)$.\r\nSuch variation does occur to some degree in a real plasma, but it has traditionally been  \r\nneglected in analytical theory and in many codes such as \\dkes~(however, nowadays analytical modelling exists, see e.g. \\cite{Buller2018} and references therein).  It can be proved\r\nthat including $\\Phi_1$ has no effect on the particle or heat fluxes, parallel flows, or bootstrap current\r\nwhen $E_r=0$, but generally there can be some difference when $E_r \\ne 0$.\r\n(There is a subtlety in showing that the heat flux is the same with and without $\\Phi_1$,\r\ndiscussed in the notes 20150325-01 in \\path{sfincs/doc/}.) \r\n\r\nIn \\sfincs, you can choose whether or not to\r\ninclude $\\Phi_1$ using the parameter \\parlink{includePhi1} in the \r\n{\\ttfamily \\hyperref[sec:physicsParameters]{physicsParameters}}\r\nnamelist. \r\nFurthermore, the parameters \\parlink{includePhi1InKineticEquation}, \\parlink{includePhi1InCollisionOperator} and \\parlink{quasineutralityOption} can be used to control how $\\Phi_1$ is included in the system of equations. \r\n\\sfincs~also allows to read $\\Phi_1$ as an input by using \\parlink{readExternalPhi1}. This is useful for looking at the effect on the transport by a $\\Phi_1$ generated by some mechanism not treated by \\sfincs, or for using $\\Phi_1$ calculated by another code. Moreover, with $\\Phi_1$ as an input the runs are typically cheaper than if \\sfincs~calculates $\\Phi_1$ itself, so if the potential variation is not expected to change in a parameter scan this setting could be useful to reuse the same $\\Phi_1$ and decrease the computational costs. \r\nIf and only if $\\Phi_1$ is included as an unknown (i.e. not if $\\Phi_1$ is an input with \\parlink{readExternalPhi1}), a quasineutrality equation is solved\r\nat each point on the flux surface.  Due to these extra unknowns ($\\Phi_1$) and extra equations\r\n(quasineutrality), the system matrix is slightly larger when \\parlink{includePhi1} is \\true.\r\nSpecifically, the number of rows and columns are each increased by \\Ntheta$\\times$\\Nzeta$+1$.  This increase is miniscule compared\r\nto the number of rows and columns associated with the kinetic equation, which depends not only on real space\r\nbut also on velocity space and species.  \r\n%Thus, there is very little extra computational cost associated\r\n%with \\parlink{includePhi1}. \r\nThus, there is typically not a substantial increase in memory requirements associated with \\parlink{includePhi1} (however, setting the preconditioner option \\parlink{reusePreconditioner} = \\false~can lead to a significant increase in memory requirements). \r\nThe time requirements will normally increase when \\parlink{includePhi1} is \\true~because the system of equations is then nonlinear (except if \\parlink{readExternalPhi1} is \\true). \r\nThe nonlinear equations are solved with a Newton method using the Scalable Nonlinear Equations Solvers (SNES) in \\PETSc. SNES internally employs KSP for the solution of its linear systems. \r\nNote that for a nonlinear calculation the \\sfincs~output file \\parlink{outputFileName} will contain the results of each nonlinear iteration in the relevant output parameters. The final result of the calculation is stored in the last position of the arrays. \r\nThe resolution parameters required for numerical convergence in nonlinear calculations are often similar to the parameters in the corresponding linear calculations (based on experience). \r\nA sanity check to control that the nonlinear calculation is not incorrect (however it is not a guarantee for numerical convergence), is to check that the total flux-surface averaged particle flux for the lowest order distribution function $\\displaystyle \\left\\langle \\int d^3 v \\, f_{s0} \\, \\bm{v}_{\\mathrm{d} s} \\cdot \\nabla \\psi \\right\\rangle = \\left\\langle \\int d^3 v \\, f_{s0} \\left(\\bm{v}_{\\mathrm{m} s} + \\bm{v}_{E}\\right) \\cdot \\nabla \\psi \\right\\rangle$ of each plasma species $s$ comes out as 0. This can e.g. be done by comparing \\underscoreparlink{particleFlux\\_vm0\\_psiHat}{particleFlux_vm0_psiHat} to \\underscoreparlink{particleFlux\\_vE0\\_psiHat}{particleFlux_vE0_psiHat} in the \\sfincs~output file \\parlink{outputFileName} and see that they are equal but with opposite sign. \r\n\r\nYou may wish to set \\parlink{includePhi1} = \\true~when\r\nusing \\sfincs~to model an experiment, and set \\parlink{includePhi1} = \\false~when\r\ncomparing \\sfincs~with analytic theory or with another code that does not include $\\Phi_1$. \r\nIn Ref~\\cite{Mollen2018} there are examples of \\sfincs~calculations with \\parlink{includePhi1} = \\true~for experimental data.\r\n\r\n\\subsection{\\PETSc~commands}\r\nIn this section we summarize experiences with the Scalable Nonlinear Equations Solvers (SNES) in \\PETSc, \r\nand list some of the command-line flags associated with \\PETSc~which can be useful for nonlinear calculations. \r\n(See section~\\ref{sec:PETScCommands} for general useful options in \\sfincs.) \r\n\r\nIf the nonlinear solver fails to converge with the default settings, a first useful thing to try is setting \\parlink{reusePreconditioner} = \\false~in the {\\ttfamily \\hyperref[sec:preconditionerOptions]{preconditionerOptions}} namelist (note that memory requirements might increase). \r\nSecondly, it can be useful to change the SNES linesearch type (see -snes\\_linesearch\\_type flag below) and to increase the absolute convergence tolerance (see -ksp\\_atol flag below) for the KSP iterations and the relative convergence tolerance (see -snes\\_rtol flag below) for the SNES iterations. \r\nMoreover, note that in each nonlinear iteration the nested linear iterations will start with the current residual. If the calculation progresses towards nonlinear convergence this implies that the starting residual norm in each nonlinear iteration is smaller and smaller. Therefore in a calculation with \\parlink{includePhi1} = \\true~it is sometimes useful to use a less strict requirement on \\parlink{solverTolerance} in the {\\ttfamily \\hyperref[sec:resolutionParameters]{resolutionParameters}} namelist, since in the last nonlinear iterations the residual will otherwise end up being unnecessarily small causing long run times (this problem is also avoided by appropriate -ksp\\_atol and -snes\\_rtol flags).\\\\ \r\nSome useful \\PETSc~flags taken from Ref~\\cite{PETSc2017}:\\\\\r\n\r\n\\subsubsection{KSP}\r\n\r\nKSP is intended for solving nonsingular linear systems of the form $A x = b$. \r\nThe residual at iteration $k$ is $r_k \\equiv b - A x_k$ and convergence is detected if\r\n\\[\r\n\\left\\|r_k\\right\\|_2 < \\mathrm{max} \\left(\\text{\\ttfamily rtol} \\cdot \\left\\|b\\right\\|_2, \\text{\\ttfamily atol}\\right).\r\n\\]\r\nDivergence is detected if\r\n\\[\r\n\\left\\|r_k\\right\\|_2 > \\text{\\ttfamily dtol} \\cdot \\left\\|b\\right\\|_2.\r\n\\]\r\n\\\\\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-ksp\\_atol {\\normalfont \\ttfamily$<$atol$>$}}\r\n{The absolute convergence tolerance absolute size of the (possibly preconditioned) residual norm in the KSP iterations. \r\nThe default is {\\ttfamily 1e-50}, which in practice implies that absolute convergence will never be fulfilled. \r\nSetting this to a value of the order {\\ttfamily 1e-10} can be useful in a nonlinear calculation.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-ksp\\_rtol {\\normalfont \\ttfamily$<$rtol$>$}}\r\n{The relative convergence tolerance, relative decrease in the (possibly preconditioned) residual norm in the KSP iterations. \r\nThe default in \\PETSc~is {\\ttfamily 1e-5}, \r\nbut the value in \\sfincs~is set by \\parlink{solverTolerance} in the {\\ttfamily \\hyperref[sec:resolutionParameters]{resolutionParameters}} namelist. This can be overwritten by using the flag.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-ksp\\_divtol {\\normalfont \\ttfamily$<$dtol$>$}}\r\n{The divergence tolerance, amount (possibly preconditioned) residual norm can increase before KSP concludes that the method is diverging.\r\nThe default is {\\ttfamily 1e5}, which is usually a good setting.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-ksp\\_max\\_it {\\normalfont \\ttfamily$<$maxits$>$}}\r\n{Maximum number of iterations to use in KSP. \r\nThe default is {\\ttfamily 1e4}, which is usually a good setting.} \r\n\r\n\\subsubsection{SNES}\r\n\r\nThe SNES class includes methods for solving systems of nonlinear equations of the form $\\bm{F} \\left(\\bm{x}\\right) = 0$, \r\nwhere $\\bm{F}~:~\\Re^n \\rightarrow \\Re^n$. \r\n\\PETSc's default method for solving the nonlinear equation is Newton's method. The general\r\nform of the $n$-dimensional Newton's method for solving the system is \r\n\\[\r\n\\bm{x}_{k + 1} = \\bm{x}_{k} - \\bm{J} \\left(\\bm{x}_{k}\\right)^{-1} \\bm{F} \\left(\\bm{x}_{k}\\right),~~k = 0, 1, \\ldots\r\n\\]\r\nwhere $\\bm{x}_{0}$ is an initial approximation to the solution and $\\bm{J} \\left(\\bm{x}_{k}\\right) = \\bm{F}^\\prime \\left(\\bm{x}\\right)$, the Jacobian, is nonsingular at each iteration. In practice, the Newton iteration is implemented by the following two\r\nsteps: (Approximately) solve $\\bm{J} \\left(\\bm{x}_{k}\\right) \\Delta \\bm{x}_{k} = - \\bm{F} \\left(\\bm{x}_{k}\\right)$,  update $\\bm{x}_{k + 1} = \\bm{x}_{k} + \\Delta \\bm{x}_{k}$. \r\nIn the output it is useful to pay attention to the reason why the SNES iterations have converged/diverged. \r\nSNES iterations typically only finish successfully due to one of the following reasons (see SNES flags): {\\ttfamily SNES\\_CONVERGED\\_FNORM\\_ABS}, {\\ttfamily SNES\\_CONVERGED\\_FNORM\\_RELATIVE},\\\\ {\\ttfamily SNES\\_CONVERGED\\_SNORM\\_RELATIVE}. \r\nIn the \\sfincs~output file \\parlink{outputFileName} there is also a flag {\\ttfamily didNonlinearCalculationConverge} which specifies if the nonlinear calculation converged.\\\\\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_type  {\\normalfont \\ttfamily$<$type$>$}}\r\n{SNES includes several Newton-like nonlinear solvers based on line search techniques and trust region methods. A table of \\PETSc~nonlinear solvers can be found in Ref~\\cite{PETSc2017}. In \\sfincs~the (default) method SNESNEWTONLS ({\\ttfamily \\bfseries -snes\\_type} {\\normalfont \\ttfamily newtonls}) seems to work the best and we have not yet had any success with the other solvers. \r\n}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_linesearch\\_type  {\\normalfont \\ttfamily$<$type$>$}}\r\n{This flag is only used when {\\ttfamily \\bfseries -snes\\_type} {\\normalfont \\ttfamily newtonls}. The different options are {\\normalfont \\ttfamily basic}, {\\normalfont \\ttfamily bt}, {\\normalfont \\ttfamily l2}, {\\normalfont \\ttfamily cp}, {\\normalfont \\ttfamily nleqerr}, {\\normalfont \\ttfamily shell}. \r\nThe default is {\\normalfont \\ttfamily bt}, but in \\sfincs~the experience is that {\\normalfont \\ttfamily l2} or {\\normalfont \\ttfamily cp} can often work better. \r\nDepending on the chosen method there are other flags that can be used to control how the search is performed: {\\ttfamily \\bfseries -snes\\_linesearch\\_alpha}, {\\ttfamily \\bfseries -snes\\_linesearch\\_damping}, {\\ttfamily \\bfseries -snes\\_linesearch\\_maxstep}, {\\ttfamily \\bfseries -snes\\_linesearch\\_max\\_it}, {\\ttfamily \\bfseries -snes\\_linesearch\\_minlambda}, {\\ttfamily \\bfseries -snes\\_linesearch\\_order}. We have not yet had any success with other values than the default for all these flags. \r\n}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_atol {\\normalfont \\ttfamily$<$atol$>$}}\r\n{The absolute convergence tolerance absolute size of the residual norm in the SNES iterations. \r\nThe default is {\\ttfamily ?}, but usually this flag can be ignored. \r\nIf $\\left\\|\\bm{F} \\left(\\bm{x}_{k}\\right)\\right\\|_2 \\leq \\text{\\ttfamily atol}$ then the output flag {\\ttfamily SNES\\_CONVERGED\\_FNORM\\_ABS} is specified.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_rtol {\\normalfont \\ttfamily$<$rtol$>$}}\r\n{The relative convergence tolerance, relative decrease in the residual norm in the SNES iterations. \r\nThe default in \\PETSc~is {\\ttfamily ?}, setting this to {\\ttfamily 1e-6} can be a good option. \r\nIf $\\left\\|\\bm{F} \\left(\\bm{x}_{k}\\right)\\right\\|_2 \\leq \\text{\\ttfamily rtol} \\cdot \\left\\|\\bm{F} \\left(\\bm{x}_{0}\\right)\\right\\|_2$ then the output flag {\\ttfamily SNES\\_CONVERGED\\_FNORM\\_RELATIVE} is specified.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_stol {\\normalfont \\ttfamily$<$stol$>$}}\r\n{The convergence tolerance in terms of the norm of the change in the solution between steps in the SNES iterations.\r\nThe default is {\\ttfamily ?}, but usually this flag can be ignored. \r\nIf $\\left\\|\\Delta \\bm{x}\\right\\|_2 \\leq \\text{\\ttfamily stol} \\cdot \\left\\|\\bm{x}\\right\\|_2$ then the output flag {\\ttfamily SNES\\_CONVERGED\\_SNORM\\_RELATIVE} is specified.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_max\\_it {\\normalfont \\ttfamily$<$maxit$>$}}\r\n{The maximum number of iterations before SNES stops. \r\nThe default is {\\ttfamily 50}, which is usually a good setting. (Sometimes convergence is slow in SNES but after more than 50 iterations it is unlikely that convergence will be reached.)} \r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_view}\r\n{Dumps detailed information to stdout related to the nonlinear solver.}\r\n\r\n\\myhrule\r\n\r\n\\PETScParam{-snes\\_linesearch\\_monitor}\r\n{Dumps detailed information to stdout at every iteration of the nonlinear solver to display the iteration's progress when a line search is performed.}\r\n\r\n\r\n\\section{Poloidal and toroidal magnetic drifts}\r\n\\label{sec:magneticDrifts}\r\n\r\nYou can choose to either include or not include the poloidal and toroidal magnetic drifts.\r\nThese drifts are turned off by default.  To turn them on, all you need to do is\r\nset \\parlink{magneticDriftScheme}~$>$~0 (with the default being \\parlink{magneticDriftScheme}~=~1) in the {\\ttfamily \\hyperref[sec:physicsParameters]{physicsParameters}} namelist. \r\n(Setting \\parlink{magneticDriftScheme}~=~2 uses a slightly different parallel magnetic drift, which gives\r\nindistinguishable results to setting 1 for all cases examined so far, and which is in fact exactly identical to setting 1\r\nin the limit of vanishing plasma beta.)\r\nIf the poloidal/toroidal magnetic drifts are turned on, you must use VMEC\r\ngeometry (\\parlink{geometryScheme}~=~5), since the magnetic drifts\r\ndepend on various derivatives of the components of the magnetic field which\r\nare not available in the simplified geometry models. \r\n(In fact, to include poloidal/toroidal magnetic drifts in a radially local code like \\sfincs~is somewhat ambiguous since the approximation made when neglecting the radial derivatives of the unknowns is different in different coordinate system.)\r\n\r\nThe magnetic drift terms introduce nonzeros in the system matrix,\r\nand therefore increase the memory and time required for factorization.\r\nThe change is small; a typical increase in both memory and time is 20-40\\%.\r\nThese magnetic drift terms typically have a minor effect on the physics outputs except when the radial\r\nelectric field is near 0.\r\n\r\nIf the electrostatic potential is not constant on flux surfaces and poloidal/toroidal magnetic drifts\r\nare included, certain cross-terms exist in the kinetic equation which have not yet been implemented in \\sfincs.\r\nThus, at present it is not strictly correct to simultaneously set  \\parlink{magneticDriftScheme}~$>$~0 \r\nand  \\parlink{includePhi1} = \\true, but it is allowed for testing purposes. \r\n\r\n\\section{Sparse direct solver packages}\r\n\\label{sec:solvers}\r\n\r\nAs discussed briefly in section \\ref{sec:gmres}, the most computationally demanding step in \r\n\\sfincs~is the direct $LU$-factorization of a very large sparse nonsymmetric real matrix. The \\PETSc~library\r\nwhich \\sfincs~uses has interfaces to a large number of other packages for direct factorization of such matrices,\r\nmaking it possible to choose among the various solver packages with just a command-line flag ({\\ttfamily -pc\\_factor\\_mat\\_solver\\_package}).  Some lists of the direct solvers\r\navailable in \\PETSc~can be found \\href{http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSolverPackage.html#MatSolverPackage}{here}\r\nor in the ``direct solvers''-``LU'' section of \\href{http://www.mcs.anl.gov/petsc/documentation/linearsolvertable.html}{this page}.\r\nIt is important for the $LU$-solver package to be one that is efficiently parallelized, \r\nin order to be able to solve problems at the high resolutions required for experimentally relevant collisionality and magnetic geometry.\r\nThe recommended choice of $LU$ solver is \\href{http://mumps-solver.org/}{\\mumps} (which is the default), and another good option is \\href{http://crd-legacy.lbl.gov/~xiaoye/SuperLU/}{\\superludist}.\r\n(The {\\ttfamily PARDISO} library available in the Intel Math Kernel Library is probably suitable as well, though we have not investigated it yet.)\r\nIn side-to-side comparisons, we find \\mumps~systematically uses substantially less memory and time than \\superludist~for factorization.\r\nIn principle, other solver packages for asymmetric matrices that are interfaced to \\PETSc~could be used as well, such as {\\ttfamily UMFPACK}, {\\ttfamily PASTIX}, etc.\r\n\r\nThere are two ways to choose between solver packages.\r\nOne method is the \\sfincs~parameter \\parlink{whichParallelSolverToFactorPreconditioner} in the \r\n{\\ttfamily \\hyperref[sec:otherNumericalParameters]{otherNumericalParameters}} namelist.\r\nThis parameter only allows you to choose between \\mumps~ and \\superludist, not other solver packages interfaced to \\PETSc.\r\nAnother way to choose between solver packages is the command-line flag {\\ttfamily -pc\\_factor\\_mat\\_solver\\_package},\r\nfollowed by one of the options in quotation marks \\href{http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSolverPackage.html#MatSolverPackage}{here}.\r\nThe command-line flag overrides the namelist parameter.\r\n\r\nThe physics outputs of the code should be independent of the solver package used to several significant digits.\r\nIn principle, different solver packages solving the same linear system should find the identical solution.\r\nHowever there will be small differences in the solutions associated with roundoff error.\r\n\r\nNote that {\\ttfamily superlu} and \\superludist~are distinct libraries. The former is serial while the latter is parallelized.\r\nTherefore there is no reason to use {\\ttfamily superlu}; \\superludist~is always preferable.\r\n\r\nThe \\mumps~package has a large number of control parameters, which are documented in the \\mumps~manual which can be downloaded \\href{http://mumps-solver.org/}{here}.\r\nYou do not need to be aware of most of these control parameters.\r\nHowever, several parameters which may be useful are discussed in section \\ref{sec:mumpsControlParameters}.\r\nIt is also worth being aware of the section of the \\mumps~manual on error messages. \r\nThis section is useful for interpreting the {\\ttfamily INFO(1)} and {\\ttfamily INFO(2)} error codes that\r\nare reported if \\sfincs~exits with an error associated with \\mumps. \r\n\r\nThe \\superludist~package has many fewer options than \\mumps. \r\nYou can find of list of the options by running \\sfincs~with the {\\ttfamily -help} command-line flag when\r\nusing \\superludist, and searching the output for lines containing {\\ttfamily superlu\\_dist}.\r\nThe \\superludist~options are also documented in the package's manual, available \\href{http://crd-legacy.lbl.gov/~xiaoye/SuperLU/#superlu_dist}{here}.\r\nWe have not found any advantage in adjusting\r\nany of the \\superludist~options.\r\n\r\nThe \\PETSc~library includes a built-in sparse direct solver which works on only a single processor.\r\nYou can select this solver using the command-line flag \\\\\r\n\\centerline{\\ttfamily -pc\\_factor\\_mat\\_solver\\_package petsc}\\\\\r\nThis solver could potentially be useful if you are running on a system that does not have \\mumps~or \\superludist~installed,\r\nand you are only considering problems that require sufficiently little memory (e.g. tokamaks) that parallelization is not required.\r\nHowever, this solver is less robust than \\mumps~or \\superludist, sometimes exiting with an error message that there is a zero pivot\r\neven though  \\mumps~and \\superludist~can solve the same system with no problem. Therefore, even if you plan to use only a single processor,\r\nwe still recommend that you install  \\mumps~or \\superludist.\r\n\r\n\\section{Parallelization: Choosing the number of nodes \\& processors}\r\n\\label{sec:parallelization}\r\n\r\nUsually the limiting factor for \\sfincs~is not time but memory.\r\n(The time required depends on the resolution used, but jobs for experimentally relevant W7-X parameters\r\ntypically take under 10 minutes.)\r\nTherefore, when considering how many nodes to request for a \\sfincs~job,\r\nthe first issue to consider is ensuring you have requested sufficient total memory.\r\nA good way to determine the memory required (assuming you are using the default solver \\mumps)\r\nis to first run \\sfincs~on 1 node using the parameters of interest\r\nand look for the following line in standard output:\\\\\r\n\\centerline{\\ttfamily ** TOTAL     space in MBYTES for IC factorization         :       1072}\\\\\r\nThe number at the end will generally be different; it depends not only on the\r\nresolution and number of species used, but also increases with the number of processors\r\nas discussed below.  Make sure the number of nodes requested times the number of megabytes per node exceeds this number.\r\nThis line in standard output is generated by \\mumps, so if you are using a different solver, this information is not printed,\r\nand you may need to determine the number of nodes by trial-and-error.\r\nSince some memory on each node is used by the operating system and by \\sfincs~functions other than the solver,\r\nyou may need to use a slightly higher number of nodes than this estimate suggests.\r\nFor experimentally relevant W7-X and HSX parameters, we typically use 2-6 nodes with 64 GB each.\r\nProblems with lower resolution requirements, such as tokamaks, often can be run on a single node.\r\n\r\nThe `IC' in the above line stands for `in core', meaning the $L$ and $U$ factors are stored\r\nin memory rather than on disk.  In \\mumps, one can also choose to do an `out of core' (OOC) solve,\r\nin which case substantially less memory is typically required.  The price you pay for this memory savings is time, since\r\ndisk access is slow compared to memory access.  Due to this slowdown, we have not used the OOC capability much, but\r\nyou might find it useful in some circumstances.\r\nTo see how much memory would be required for an OOC solve,\r\nlook for the following line in standard output:\\\\\r\n\\centerline{\\ttfamily ** TOTAL     space in MBYTES for OOC factorization        :       128}\\\\\r\n(The number at the end will generally be different.)\r\nTo invoke out-of-core mode, you must take two steps. First, use the following command-line flag when calling \\sfincs:\\\\\r\n\\centerline{\\ttfamily -mat\\_mumps\\_icntl\\_22 1}\\\\\r\nSecond, you must set the environment variable {\\ttfamily MUMPS\\_OOC\\_TMPDIR} to some reasonable directory\r\nbefore calling \\sfincs. This environment variable could be set for example in the batch job file.\r\nTemporary files containing the $L$ and $U$ factors will be stored in the directory indicated.\r\n\r\nAnother issue to consider is how many processors to use.  It is not always best to use the maximum number of processes\r\navailable on the number of nodes you have chosen. The reason is that as the preconditioner matrix is divided among\r\nmore and more processes, the $LU$ factorization becomes less efficient, requiring more memory and more communication.\r\nIf you examine the \\mumps~IC and OOC memory requirements indicated above, you will find they increase somewhat \r\nas the number of processes increase.\r\nOne needs to find a balance between speed (favoring many processes) and memory requirements (favoring few processes).\r\nWhile it is almost always better overall to use 2 processes compared to 1 process, it is not always better to use 128 processes\r\ncompared to 64 processes.  The sweet spot is often in the range of 16-64 processes.\r\nTo determine how to request fewer processes than the maximum available on a given number of nodes,\r\nsee the documentation for your computing system.\r\n\r\nIf more memory is required than is available, the system will usually terminate your job with an out-of-memory (OOM) error.\r\nWhen this occurs, you need to either increase the number of nodes requested or decrease the number of processors\r\nrequested.\r\n\r\nMost of the time, \\sfincs~is run via \\sfincsScan~as some parameter is scanned, such as the radial electric field.\r\nIn this case, the scan is ``embarassingly parallel'' in the sense that each job in the scan is completely independent\r\nof the other jobs.  Even if each individual job requires only 1 or a small number of nodes, it is still useful\r\nto run \\sfincs~on a computing system with many nodes so the scan can be carried out in parallel.\r\n\r\n%\\section{Issues with running on 1 processor}\r\n\r\n\\section{Monoenergetic transport coefficients}\r\n\\label{sec:monoenergetic}\r\n\r\nBy setting \\parlink{RHSMode} = 3, \\sfincs~can be run in a mode\r\nwhere it solves the same kinetic equation (prior to discretization) as \r\n\\dkes~and other monoenergetic codes.\r\nWhen \\parlink{RHSMode} = 3, the values of \\parlink{Zs}, \\parlink{THats}, \\parlink{nHats},\r\n\\parlink{mHats}, \\underscoreparlink{nu\\_n}{nu_n}, and {\\ttfamily dPhiHatdXXX} are all ignored.\r\nInstead, the collisionality is set by \\parlink{nuPrime}, and the radial electric field is set\r\nby \\parlink{EStar}.  The first of these quantities is the dimensionless collisionality\r\n\\begin{equation}\r\n\\mbox{\\parlink{nuPrime}} = \\frac{(G+\\iota I) \\nu}{v B_0}\r\n\\end{equation}\r\nwhere $G$ and $I$ are defined in (\\ref{eq:covariant}), $\\iota=1/q$ is the rotational transform,\r\n$v$ is the speed at which the monoenergetic calculation is being performed, and $B_0$ is the (0,0) Fourier harmonic of $B$\r\nwith respect to the Boozer poloidal and toroidal angles. The collision\r\nfrequency $\\nu$ is here the value of $\\nu_\\mathrm{ii}$ one would have if\r\n$v$ were the thermal speed. That is, in SI units,\r\n\\begin{equation}\r\n  \\nu=\\frac{4}{3\\sqrt{\\pi}}\\frac{n Z^4e^4\\ln \\Lambda}{4\\pi\\epsilon_0^2m^2v^3}.\r\n\\end{equation}\r\n%\r\nThe normalized radial electric field is\r\n\\begin{equation}\r\n\\mbox{\\parlink{EStar}} = \\frac{cG}{\\iota v B_0} \\frac{d\\Phi}{d\\psi}\r\n\\end{equation}\r\n(Gaussian units).\r\nWhen {\\ttfamily RHSMode} == 1, {\\ttfamily nuPrime} and {\\ttfamily EStar} are ignored.\r\n\\todo{Should be change the behavior of RHSMode=2 so it uses nuPrime and EStar instead of nu\\_n?}\r\n\r\nThe two parameters \\parlink{nuPrime} and \\parlink{EStar} are\r\nrelated to the corresponding DKES parameters {\\ttfamily CMUL} and\r\n{\\ttfamily EFIELD} by\r\n\\begin{eqnarray}\r\n  \\mbox{\\ttfamily\r\n    CMUL}&\\equiv&\\frac{\\nu_\\mathrm{D}}{v}=\\frac{3\\sqrt{\\pi}}{4}\\left(\\mathrm{erf}(1)-\\mathrm{Ch}(1)\\right)\r\n  \\frac{B_0}{G+\\iota I}\\mbox{\\ttfamily nuPrime},\\\\\r\n  \\mbox{\\ttfamily EFIELD}&\\equiv&-\\left[\\frac{d\\Phi}{dr}\\right]_\\mathrm{DKES}\\frac{1}{vB_0}=-\\frac{\\iota}{G}\\left[\\frac{d\\Psi}{dr}\\right]_\\mathrm{DKES}\\mbox{\\ttfamily EStar},\r\n\\end{eqnarray}\r\nwhere $\\mathrm{Ch}$ is the Chandrasekhar function and $\\nu_\\mathrm{D}$\r\nis the actual pitch-angle deflection frequency of the particle.\r\n\\todo{These expressions are in SI units. Should there be some\r\n  factors of $c$ to adhere to the Gaussian standard used here?\r\n  Probably not.}\r\n\r\n\\section{Poloidal and toroidal angles}\r\n\r\nIf you are interested in any of the output quantities that vary on a flux surface,\r\nsuch as the density or electrostatic potential, then it is important to know\r\nhow the poloidal and toroidal angles ($\\theta$ and $\\zeta$) in \\sfincs~are defined.\r\nThe definitions of the poloidal and toroidal angles in \r\n\\sfincs~depend on the input parameter \\parlink{geometryScheme}. When a \\vmec~equilibrium is imported by setting\r\n\\parlink{geometryScheme} = 5, then \\sfincs~will use the same poloidal and toroidal angles\r\nas \\vmec.  The toroidal angle in this case is the normal cylindrical coordinate. Note that field lines\r\nare not straight in these \\vmec~coordinates.\r\nFor any other setting of \\parlink{geometryScheme}, \\sfincs~will use Boozer coordinates.\r\n\r\n", "meta": {"hexsha": "acb948ac4889ea8f2e65f9c6fea5663d71414b9a", "size": 37358, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/manual/version3/runs.tex", "max_stars_repo_name": "amollen/sfincs", "max_stars_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2017-10-13T15:15:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:56:20.000Z", "max_issues_repo_path": "doc/manual/version3/runs.tex", "max_issues_repo_name": "amollen/sfincs", "max_issues_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-01-02T09:04:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-28T09:53:21.000Z", "max_forks_repo_path": "doc/manual/version3/runs.tex", "max_forks_repo_name": "amollen/sfincs", "max_forks_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-03-19T14:30:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-03T14:37:14.000Z", "avg_line_length": 72.96484375, "max_line_length": 790, "alphanum_fraction": 0.7638792227, "num_tokens": 9824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.42601418803413077}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** First Chapter *****************************\n%*******************************************************************************\n\\chapter{Background}\n\\label{chapter:background}\n% \\section{Notation and Basic Concepts}\n% \\paragraph{}\n% It will be useful to clarify some of the notation throughout this work.\n% \\begin{itemize}\n% \\item Vectors will be denoted by boldface lowercase letters: $\\vec{u}, \\vec{x}, ...$\n% \\item Matrices will be denoted by uppercase letters: $A, M, ...$\n% \\item Probability mass functions will be denoted by uppercase letters: $P(x),\n%   Q(z), ...$\n% \\item Probability density functions will be denoted by lowercase letters: $p(y),\n%   q(u), ...$\n% \\item In general, exact/continuous values will be denoted by unannotated letters\n%   (e.g. $z_i, \\vec{w}$), their quantized counterparts denoted by a hat\n%   ($\\hat{z}_i, \\hat{\\vec{w}}$) and their approximate counterparts by a tilde\n%   ($\\tilde{z}_i, \\vec{\\tilde{w}}$).\n% \\item $\\Exp_{p(x)}[f(x)]$ denotes the expected value of $f(x)$ with respect to\n%   the mass / density $p(x)$, i.e.:\n%   \\[\n%     \\Exp_{p(x)}[f(x)] = \\int_\\Omega f(x) \\d p(x),\n%   \\]\n%   where $\\Omega$ is the sample space. As $\\Omega$ will usually denote $\\Reals^n$\n%   or will be understood from context, it will be omitted, and the integral will\n%   be rewritten as\n%   \\[\n%     \\Exp_{p(x)}[f(x)] = \\int f(x)p(x) \\d x.\n%   \\]\n% \\item $H[X]$ denotes the Shannon entropy of the random variable $X$. If $X$ is\n%   discrete, then it is defined as\n%   \\[\n%     -\\sum_{X=x}P(X=x)\\log P(X=x).\n%   \\]\n%   If it is continuous, then it will refer to the \\textit{differential entropy}\n%   of $X$, namely\n%   \\[\n%     -\\int_{\\X}\\log p(x) \\d p(x),\n%   \\]\n%   where $\\X$ denotes the support of $X$.\n%   \\paragraph{Note:} we used the natural logarithm in our definition of entropy,\n%   and hence its units are \\textbf{nats}. If we used the base 2 logarithm\n%   instead, the units would be \\textbf{bits}.\n% \\item $\\KL{q(x)}{p(x)}$ denotes the Kullback-Leibler divergence between two\n%   distributions and is defined as\n%   \\[\n%     \\KL{q(x)}{p(x)} = \\Exp_{q(x)}\\left[\\log\\frac{q(x)}{p(x)}\\right].\n%   \\]\n% \\item $I[X : Y]$ denotes the mutual information between random variables $X$ and\n%   $Y$ and is defined as\n%   \\[\n%     I[X : Y] = \\KL{p(x, y)}{p(x)p(y)},\n%   \\]\n%   where $(X, Y) \\sim p(x, y)$ and $p(x)$ and $p(y)$ denote the marginals.\n% \\end{itemize}\n\\section{Image Compression}\n\\label{sec:intro_image_compression}\n\\par\nThe field of image compression is a vast topic that mainly spans over the fields\nof computer science and signal processing, but incorporates methods and\nknowledge from several\nother disciplines, such as mathematics, neuroscience, psychology\nand photography. In this section, we introduce the reader to the basics of the\ntopic, starting with source coding, then through lossy compression, we arrive at\nthe concepts of rate and distortion. Finally, we introduce transform coding, the\ncategory in which our work falls as well.\n\n\\subsection{Source Coding}\nFrom a theoretical point of view, given some source $S$, a sender and a\nreceiver, compression may be described as the aim of the sender communicating an\narbitrary sequence $X_1, X_2, \\hdots, X_n$ taken from $S$ to the receiver in as few bits\nas possible, such that the receiver may recover relevant information from the message.\nIf the receiver can always recover all the information from the message of the sender, we\ncall the algorithm \\textbf{lossless}, otherwise, we call it \\textbf{lossy}. \n\\par\nAt first, it might not seem intuitive to allow for lossy compression, and in some\ndomains, this is true, e.g. in text compression. However, \nhumans' audio-visual perception is neither completely aligned with the range of\nwhat can be digitally represented, nor does it always scale the same way\n(\\cite{eskicioglu1994image}, \\cite{psnr}, \\cite{gupta2011modified}). Hence,\nthere is a great opportunity for compressing media in a lossy way by discarding\ninformation with the change being imperceptible for a human observer while\nmaking significant gains in size reduction.\n\\subsection{Lossy Compression}\nAs the medium of interest in lossy compression is generally assumed to be a\nreal-valued vector $\\vec{x} \\in \\Reals^N$, such as RGB pixel intensities in an\nimage or frequency coefficients in an audio file, the usual pipeline consists of \nan encoder $C \\circ \\Enc$, mapping a point $\\vec{x} \\in \\Reals^N$ to a string of bits and a\ndecoder mapping from bitstrings to some reconstruction $\\hat{\\vec{x}}$. The\nfactor of the encoder $\\Enc$  can be understood as a map from $\\Reals^N$ to a\nfinite symbol set $\\A$, called a \\textbf{lossy encoder}, and $C$ can be\nunderstood as a map from $\\A$ to a\nstring of bits called a \\textbf{lossless code} (\\cite{goyal2001theoretical}).\nWe examine both $\\Enc$ and $C$ in more detail in Section\n\\ref{sec:transform_coding}.\nThe decoder then can be thought of as inverting the code first and then using an\napproximate inverse of\n$\\Enc$ to get the reconstruction $\\hat{\\vec{x}}$: $\\Dec \\circ C^{-1}$.\nGiven these, it is of paramount importance to quantify\n\\begin{itemize}\n\\item The \\textbf{distortion} of the compressor. On average, how closely does\n  $\\hat{\\vec{x}}$ resemble $\\vec{x}$?\n\\item The \\textbf{rate} of the compressor. On average, how many bits are\n  required to communicate $\\vec{x}$? We want this to be as low as possible of course.\n\\end{itemize}\n\n\\subsection{Distortion}\n\\label{sec:intro_distrotion}\nIn order to measure ``closeness'' in the space of interest $\\ImSpace$,\na distance metric $d(\\cdot, \\cdot): \\ImSpace\n\\times \\ImSpace \\rightarrow \\Reals$ is introduced. Then, the distortion $D$ is \nis defined as\n\\[\n  D = \\Exp{d(\\vec{x}, \\hat{\\vec{x}})}{p(\\hat{\\vec{x}})}.\n\\]\nA popular choice of $d$, across many domains of compression is the normalized $L_2$ metric\nor Mean Squared Error (MSE), defined as\n\\[\n  d(\\vec{x}, \\hat{\\vec{x}}) = \\frac{1}{N} \\sum_{i}^N (x_i - \\hat{x}_i)^2, \\quad\n  \\ImSpace = \\Reals^N.\n\\]\nIt is a popular metric as it is simple, easy to implement and has nice\ninterpretations in both the Bayesian (\\cite{bishop2013pattern}) and the MDL\n(\\cite{hinton1993keeping}, to be introduced in Section \\ref{sec:mdl}) settings.\nIn the image compression setting, however, the MSE is problematic, since \noptimizing for it does not necessarily translate to obtaining pleasant-looking\nreconstructions (\\cite{zhao2015loss}). Hence, more appropriate, so-called\n\\textit{perceptual metrics} were developed. The two most common ones used today\nare Peak Signal-to-Noise Ratio (PSNR) (\\cite{psnr}, \\cite{gupta2011modified}) and the\nStructural Similarity Index (SSIM) (\\cite{wang2004image}) and its multiscale\nversion (MS-SSIM) (\\cite{msssim}). Crucially, these two metrics are also\ndifferentiable, thus they lend themselves for gradient-based optimization.\n\n\\subsection{Rate}\nWe noted above that the code used after the lossy encoder is lossless. To\nfurther elaborate, in virtually all cases it is an \\textbf{entropy code}\n(\\cite{goyal2001theoretical}). This means that we assume that each symbol\nin the representation $\\vec{z} = \\Enc(\\vec{x})$ has some probability mass\n$P(z_i)$. A fundamental result by Shannon states that $\\vec{z}$ may not be\nencoded losslessly in fewer than $H[\\vec{z}]$ nats:\n\\begin{theorem}{(Proven by \\cite{shannon1998mathematical}, presented as stated in\n    \\cite{mackay2003information})}\n$N$ i.i.d. random variables each with entropy $H[X]$ can be compressed into more\nthan $N\\cdot H[X]$ bits with negligible risk of information loss, as $N\n\\rightarrow \\infty$; conversely if they are compressed into fewer than $NH[X]$ bits it is virtually certain that information will be lost.\n\\end{theorem}\nEntropy codes, such as Huffman codes (\\cite{huffman1952method}) or Arithmetic\nCoding (\\cite{rissanen1981universal}) can get very close to this lower bound.\nWe discuss coding methods further in Section \\ref{sec:coded_sampling}. \n\\begin{framed}\n  In particular, entropy codes can compress each symbol $z_i$ in $-\\log P(z_i)$ nats.\n\\end{framed}\nThe rate (in nats) of the compression algorithm is defined\nas the average number of nats required to code a single dimension of the input, i.e.\n\\[\n  R = \\frac{1}{N} H[\\vec{z}].\n\\]\n\\subsection{Transform Coding}\n\\label{sec:transform_coding}\nThe issue with source coding is that coding $\\vec{x}$ might have a lot of\ndependencies across its dimensions. For images, this manifests on multiple\nscales and semantic levels, e.g. a pixel being blue might indicate that most\npixels around it are blue as the scene is depicting the sky or a body of water;\na portrait of a face will also imply that eyes, a nose and mouth are probably\npresent, etc. Modelling and coding this dependence structure in very high\ndimensions is challenging or intractable, and hence we need\nto make simplifying assumptions about it to proceed.\n\\par\n\\textit{Transform coding} attempts to solve the above problem by decomposing the\nencoder function $\\Enc = Q \\circ T$ into a so-called \\textbf{analysis transform}\n$T$ and a \\textbf{quantizer} $Q$. The idea is to transform the input into a\ndomain, such that the dependencies between the dimensions are removed, and hence\nthey can be coded individually. The decoder inverts the steps of the encoder,\nwhere the inverse operation of $T$ is called the \\textbf{synthesis transform}\n(\\cite{gupta2011modified}).\n\\par\nIn \\textit{linear transform coding}, $T$ is an invertible linear transformation,\nsuch as a discrete cosine transformation (DCT), as it is in the case of JPEG\n(\\cite{wallace1992jpeg}), or discrete wavelet transforms in JPEG 2000\n(\\cite{rabbani2002overview}). While simple, fast and elegant, linear transform\ncoding has the key limitation that it can only at most remove correlations (i.e.\nfirst-order dependencies), and this can severely limit its efficiency\n(\\cite{balle2016endtrans}). Instead, \\cite{balle2016endtrans} propose a method for\n\\textit{non-linear transform coding}, where $T$ is replaced by a highly\nnon-linear transformation, and its inverse is now replaced by an approximate\ninverse, which is a separate non-linear transformation. Both $T$ and its\napproximate inverse are learnt, and the authors show that with a more\ncomplicated transformation they can easily surpass the performance of the much\nmore fine-tuned JPEG codecs.\n\\par\nOur work also falls into this line of research, although with significant\ndifferences, which will be pointed out later.\n\n\\subsection{The Significance of Quantization in Lossy Compression}\n\\par\nThe reason why quantization is required in lossy compression algorithms is\nthat it allows to reducing information content of data. To study the\nprecise meaning of this, we put the problem in a formal setting.\nLet us define the quantizer as a function $[\\cdot]: R \\rightarrow S$, where\n$R$ is the original representation space (in transform coding this would be the\nimage $T(\\Reals^N)$), and a quantized space $S$ (usually $\\Ints^N$). $[\\cdot]$\nis always many-to-one mapping. Let $[s]^{-1} = \\{x \\in R \\mid [x] = s \\}$ be\nthe preimage of $s$. Then, we have the further requirement on $[\\cdot]$ \nthat the fibres of $S$ partition $R$, i.e.\n\\[\n  \\text{if } s \\neq t \\Rightarrow [s]^{-1} \\cap [t]^{-1} = \\emptyset.\n\\]\nA popular option for the quantizer is the rounding function, mapping $[\\cdot]: \\Reals\n\\rightarrow \\Ints$, where for each integer $z \\in \\Ints$ it is defined as $x\n\\in \\left[z - \\frac12, z + \\frac12\\right) \\mapsto z$. Given some probability mass $P(x)$ \nfor some data $x$, we have seen that using entropy coding $x$ can be encoded in\n$-\\log P(x)$ nats. The way quantization enables better compression, is that it\naggregates the probability mass of all elements in $[s]^{-1}$ into the mass of $s$.\nNamely, for each $s$, the quantizer induces a new probability mass function\n$\\hat{Q}(s)$, such that\n\\[\n  \\hat{Q}(s) = \\int_{[s]^{-1}} p(x) \\d x,\n\\]\nwhere the integral is replaced by summation for discrete $[s]^{-1}$. This will allow\nus to code $x$ in potentially much fewer nats. To put it precisely, assume $[x] =\ns$, then\n\\[\n  -\\log \\hat{Q}(s) = -\\log \\int_{[s]^{-1}} p(x) \\d x \\leq -\\log P(x).\n\\]\nThis is at the cost of introducing distortion (see Section\n\\ref{sec:intro_distrotion}), as we will not be able to reconstruct $x$ from $s$.\nIn particular, quantization is vital for continuous $x$, as the probability mass\nof each $x$ is 0, and hence we would require $-\\log P(x) = \\infty$ nats to\nencode them without quantization.\n\n\\section{Theoretical Foundations}\n\\label{sec:intro_theoretical_foundations}\n\\par\nWe now shift our focus from image compression to the foundations of\nneural compression. We begin with the Minimum Description Length (MDL)\nPrinciple (\\cite{rissanen1986stochastic}) and the Bits-Back Argument\n(\\cite{hinton1993keeping}), the two core theoretical guiding\nprinciples of this work. We then see how based on these, as well as on\nmore recent work (\\cite{harsha2007communication}, \\cite{havasi2018minimal})\nwe can develop a general ML-based compression framework that does not include\nquantization in its pipeline, thus allowing gradient-based optimization methods\nto be used in training our compression algorithms.\n\n\\subsection{The Minimum Description Length Principle} \n\\label{sec:mdl}\nOur approach is based on the Minimum Description Length (MDL) Principle\n(\\cite{rissanen1986stochastic}). In essence, it is a formalization of Occam's\nRazor, i.e. the simplest model that describes the data well is the best model of\nthe data (\\cite{grünwald2007minimum}). Here, ``simple'' and ``well'' need to be\ndefined, and these definitions are precisely what the MDL principle gives us.\nInformally, it asserts that given a class of hypotheses $\\Hypos$ (e.g. a certain\nstatistical model and its parameters) and some data $\\Data$, if a particular\nhypothesis $H \\in \\Hypos$ can be described with at most $L(H)$ bits and the using the\nhypothesis the data can be described with at most $L(\\Data \\mid H)$ bits, then the\nminimum description length of the data is\n\\begin{equation}\n\\label{eq:min_desc_princ}\n  L(\\Data) = \\min_{H \\in \\Hypos}\\{ L(H) + L(\\Data \\mid H) \\},\n\\end{equation}\nand the best hypothesis is an $H$ that minimizes the above quantity.\n\\par\nCrucially, the MDL principle can thus be interpreted as telling us that\n\\textbf{the best model of the data is the one that compresses it the most}.\nThis makes Eq \\ref{eq:min_desc_princ} a very appealing learning objective for\noptimization-based compression methods, ours included.\nBelow, we briefly review how this has been applied so far and how it translates\nto our case.\n\\subsection{The Bits-back Argument}\nHere we present the bits-back argument, introduced in\n\\cite{hinton1993keeping}. The main goal of their work was to develop a\nregularisation technique for neural networks, and while they talk about the\ncompression of the model, the first method that realized bits-back\n efficiency came much later, developed by \\cite{havasi2018minimal}. \nAlthough the argument is essentially just the direct application of the MDL\nprinciple, it can seem quite counter-intuitive at first. Hence, we begin this\nsection with an example to illustrate the goal of the argument,\nand only then move on to formulate it in more generality.\n\n\\paragraph{Example}\nLet us be given a simple regression problem on the dataset $\\Data = (\\X, \\Y)$,\nwhere $\\X = (x_1, \\hdots, x_n), \\Y = (y_1, \\hdots, y_n)$ are both one\ndimensional input and target sets and $(x_i, y_i)$ are a corresponding training\npair. Assume we wish to fit a simple model:\n\\[\n  \\hat{y} = f(x) = \\alpha x + \\beta,\n\\]\nwhere we wish to learn the parameters $\\alpha$ and $\\beta$.\nAssuming a Gaussian likelihood with mean 0 and variance 1 on the residuals $\\delta\n= y - \\hat{y}$ ,\n\\[\n  p(\\delta \\mid x, \\alpha, \\beta) = \\Norm{\\delta \\mid 0, 1},\n\\]\na popular way of fitting the model is using Maximum Likelihood Estimation (MLE),\ni.e. maximizing $\\prod_i p(\\delta_i \\mid x_i, \\alpha, \\beta)$ which is equivalent to\nminimizing the negative logarithm of this quantity, $-\\sum_i \\log p(\\delta_i \\mid\nx_i, \\alpha, \\beta)$. It can be easily seen that this works out to be equivalent\nto minimizing the Mean Squared Error (MSE) between the predicted values and the\ntargets:\n\\[\n  L(\\Data \\mid \\alpha, \\beta) = \\frac{1}{n} \\sum_i (y_i - f(x_i))^2.\n\\]\nA usual issue with MLE algorithms is that they are heavily overparameterized for\nthe problem they are supposed to be solving and hence can easily overfit (this\nis most likely not an issue with our toy model, but we shall pretend for the\nsake of the argument). To solve this issue, a standard technique is to\nintroduce some regularisation term to the loss. Here we are interested in\napplying the MDL principle directly.\n\\par\nBefore we discuss how it is applied, we must make precise the setting in which\nit \\textit{can} apply. In particular, the MDL principle assumes the form of a\ncommunications problem. Assume two parties, Alice and Bob share $\\X$, and some\nother arbitrary pre-agreed information, but only Alice has access to $\\Y$. Then,\nthe MDL principle asks for the minimal message that Alice needs to send to Bob,\nsuch that he may recover $\\Y$ completely. With this setup in mind, we can continue.\n\\par\nTo apply the MDL principle, we need to be able to calculate the\nMDLs of the data given a hypothesis and the MDLs of our hypotheses.\nNotice, that the former is already available\nin the form of the MSE for a given hypothesis, and hence $L(\\Data \\mid \\alpha,\n\\beta)$ is not an overload of notation. To code the hypothesis\n(the pair ($\\alpha, \\beta$) in our\ncase), we need to define two distributions over our parameters: a prior $P_\\theta$, that\ngives us the regularizing effect and stays fixed, and a posterior $Q_\\phi$, the\ndistribution that we learn and assume that our parameters come\nfrom it. We use the $\\theta$ and $\\phi$ to denote the sufficient\nstatistics of the prior and posterior, respectively. Now, learning changes, as\nwe are no longer optimizing a single hypothesis ($\\alpha, \\beta$), but a whole\nclass of hypotheses $Q_\\phi(\\alpha, \\beta)$, by finding the best fitting set\nof sufficient statistics $\\phi$ for our dataset. Thus, our initial data\ndescription length now becomes an expectation over the possible hypotheses:\n\\[\n  L(\\Data \\mid \\phi) = \\Exp{L(\\Data \\mid \\alpha, \\beta)}{Q_\\phi}.\n\\]\nDefining the regularizing term, however, turns out to be trickier than expected,\nand lies at the core of the bits-back argument. We seek to find the minimum\ndescription length of a hypothesis $(\\alpha, \\beta)$. Using a $Q_\\phi$, we know\nwe can encode a concrete hypothesis in $-\\log Q_\\phi (\\alpha, \\beta)$ nats, and thus a\nreasonable first guess for the MDL would be\n\\begin{equation}\n\\label{eq:hypothesis_entropy}\n  \\Exp{-\\log Q_\\phi(\\alpha, \\beta)}{Q_\\phi},\n\\end{equation}\ni.e. the Shannon entropy of $Q_\\phi$.\nThis turns out to be wrong, however, for the reason that Bob should be able to\ndecode Alice's message, and since he does not have access to $Q_\\phi$, he cannot\ndo this. \nAt this point, we note, that as $P_\\theta$ is fixed, we may assume that Alice\nand Bob share it a priori. This allows us to code a pair $(\\alpha, \\beta)$ in\n$-\\log P_\\theta(\\alpha, \\beta)$ nats that Bob can decode, and hence a\nreasonable second guess for the MDL could be\n\\begin{equation}\n\\label{eq:hypothesis_cross_entropy}\n\\Exp{-\\log P_\\theta(\\alpha, \\beta)}{Q_\\phi},\n\\end{equation}\ni.e. the cross-entropy between $Q_\\phi$ and $P_\\theta$, which is also the\nexpected length of the actual message that gets sent to communicate the\nparameters. Note, that since the hypotheses are still drawn from $Q_\\phi$,\nthe expectation needs to be taken over it. This also turns out to be wrong,\nas the bits-back argument shows that \\textit{not all} of the bits used for\nthe message are used to code $Q_\\phi$. Once the parameters are sent, Alice also\nsends every residual $\\delta_i$, obtained by using the parameter set sent to Bob.\n\\par\nOnce Bob has decoded $(\\alpha, \\beta)$ and each $\\delta_i$,\nhe can fully recover each $y_i$ by calculating $x_i + \\delta_i$. Now, since he\nhas access to both $\\X, \\Y$ and $P_\\theta$, he may also fit a $Q_\\psi$ to the\ndata, using the same learning algorithm as Alice used to fit her $Q_\\phi$. The\nkey observation in (\\cite{hinton1993keeping}) is that so long as this learning\nalgorithm is \\textit{deterministic} after sufficient training Bob can achieve\n$\\psi = \\phi$, i.e. he recovers Alice's posterior distribution. This means that\nBob can sample the same $(\\alpha, \\beta)$ pair that was sent to him (e.g.\nby also sharing a random seed with Alice either before their communication or\nduring, at at most an $\\Oh(1)$ cost, which is negligible).\n\\begin{framed}\nThis must mean, that\nAlice not only communicated $Q_\\phi$ itself to Bob, but also the \\textit{random\n  bits} that were used in conjunction with $Q_\\phi$ to draw the sample $(\\alpha,\n\\beta)$.\n\\end{framed}\nThe fact that Alice has communicated both $Q_\\phi$ and the random bits in a $-\\log\nP_\\theta(\\alpha, \\beta)$ nat long message, means that to get the cost\nof communicating $Q_\\phi$ only, we simply need to subtract the length of the\nrandom bits. But since $(\\alpha, \\beta)$ were drawn from $Q_\\phi$, their length\nis going to be precisely $-\\log Q_\\phi(\\alpha, \\beta)$. Hence, the expected\nhypothesis description length is the expectation of this difference, namely\n\\[\n  \\Exp{-\\log P_\\theta (\\alpha, \\beta) - (-\\log Q_\\phi(\\alpha, \\beta))}{Q_\\phi}\n  =  \\Exp{\\log \\frac{Q_\\phi(\\alpha, \\beta)}{P_\\theta (\\alpha, \\beta)}}{Q_\\phi}\n  = \\KL{Q_\\phi}{P_\\theta}.\n\\]\nAbove the rightmost term is called the \\textbf{Kullback-Leibler Divergence}\nbetween $Q_\\phi$ and $P_\\phi$. It is defined as\n\\[\n  \\KL{Q}{P} = \\sum_{x \\in \\Omega} Q(x)\\log\\frac{Q(x)}{P(x)}\n\\]\nfor probability mass functions $Q$ and $P$, where $\\Omega$ denotes the sample\nspace, and\n\\[\n  \\KL{q}{p} = \\int_\\Omega q(x) \\log\\frac{q(x)}{p(x)} \\d x\n\\]\nfor probability density functions $q$ and $p$.\n\\par\nThe fact that Bob can ``get the random bits back ''used in sampling the\nhypothesis is the namesake of the argument.\n\n\\paragraph{The general argument}\nWe are now ready to state the general bits-back argument. Assume Alice has\ntrained a model for a regression problem, on a dataset $\\Data = (\\X, \\Y)$, with\ntraining pairs $(\\vec{x}_i, \\vec{y}_i)$, and shares $\\X$ with Bob. Her model has\nparameters $\\vec{w}$, with prior $p_\\theta(\\vec{w})$, and uses the likelihood\nfunction $p(\\vec{y} \\mid \\vec{w}, \\vec{x})$, both shared with Bob. Assume that\nAlice has a learned posterior $q_\\phi(\\vec{w} \\mid \\Data)$ over the weights, and now\nwishes to communicate the targets $\\Y$ to Bob.\n\\par\nThen, the bits-back argument states that if Alice acts according to the MDL\nprinciple, then she can communicate $q_\\phi$ to Bob in $\\KL{q_\\phi}{p_\\theta}$\nnats, as follows:\n\\begin{enumerate}\n\\item Alice draws a random sample $\\hat{\\vec{w}} \\sim q_{\\phi}(\\vec{w})$. This\n  represents a message of $- \\log q_\\phi(\\hat{\\vec{w}})$ nats.\n\\item $\\hat{\\vec{w}}$ is then used to calculate the residuals $\\vec{r}_i$ between\n  the model's output and the targets.\n\\item $\\hat{\\vec{w}}$ is coded\n  using its prior $p_\\theta$, and sent to Bob alongside the residuals\n  $\\vec{r}_i$.\n  The total length of the message that contains\n  the posterior information is hence $-\\log p_{\\theta}(\\hat{\\vec{w}})$.\n\\item Bob, decodes $\\hat{\\vec{w}}$ using the same prior $p_\\theta$. He then\n  recovers all targets $\\Y$ by adding each $\\vec{r}_i$ to his model's output with\n  parameters set to $\\hat{\\vec{w}}$ upon input $\\vec{x}_i$.\n\\item He then trains his model using the same deterministic algorithm as Alice\n  did, to recover Alice's posterior $q_\\phi$. Hence, the random bits that were\n  used to communicate the sample must be deducted from the cost of\n  communicating $q_\\phi$. The cost of these bits is precisely $-\\log\n  q_\\phi(\\hat{\\vec{w}})$. Taking the expectation of the difference w.r.t. $q_\\phi$,\n  the total cost of communicating $q_\\phi$ is\n  \\[\n    \\Exp{\\log q_\\phi(\\vec{w}) - \\log p_\\theta(\\vec{w})}{q_\\phi} = \\KL{q_\\phi}{p_\\theta}.\n  \\]\n\\end{enumerate}\n\n\\paragraph{Caveats of the argument}\nNote, that the original argument merely derives the minimum description length\nfor the weights $\\vec{w}$, but clearly does not achieve it (as we have to send a\nmessage whose expected length is $\\Exp{-\\log p_\\theta(\\vec{w})}{q_\\phi}$). The\nauthors merely state that these bits can be ``recovered'', and propose that a\n``free'' auxiliary message might be coded in them, but do not give any\npropositions as to how sending these bits in the first place might be avoided.\nNonetheless, as the notion of bit-back efficiency has expanded in recent years,\nit is customary to call any method \\textit{bits-back efficient} that transmits \nsome information in $\\KL{q}{p}$ nats, for some posterior $q$ and prior $p$ over \nthe information.\n\n\\section{Compression without Quantization}\n\\label{sec:compression_without_quantization}\n\\par\nIn this section, we present a general framework for lossy data compression, based on\nthe arguments presented above, as well as the works of\n\\cite{harsha2007communication} and \\cite{havasi2018minimal}. \n\n\\par\nAs mentioned at the end of the previous section, the bits-back argument\npostulates that communicating the distribution of the parameter set of a model\nmay be achieved in $K = \\KL{q(\\vec{w})}{p(\\vec{w})}$ nats, where $q$ and $p$ are the\nposterior and prior over the parameters, respectively. However, they do not give\na method for achieving this, rather they show that only $K$ nats are used to\ncommunicate the posterior in a longer message. Furthermore, the original MDL setup\nalso requires to send the residuals from the model output.\n\\par\nFor compression, however, we are only interested the communicating a sample and\nnot its distribution, though still at bits-back efficiency. \nThe correct communication problem for this was formulated by\n\\cite{harsha2007communication}, and it is as\nfollows:\n\\begin{framed}\nLet $X$ and $Y$ be two correlated random variables, with sample spaces\n$\\X$ and $\\Y$ respectively, and with joint distribution $p(X, Y) = q(Y \\mid\nX)p(Y)$. Given a concrete $x \\in \\X$, what is the minimal\nmessage Alice needs to send to Bob, such he can generate a sample according to\nthe distribution $q(Y \\mid X = x)$?\n\\end{framed}\n\\par \nWe can interpret $\\X$ as the set of all data that we might wish to compress\n(e.g. the set of all RGB-coded natural images, the set of all MP3 coded audio\nfiles, etc.), and $\\Y$ as the set of latent codes of the data, from which we may\nobtain our lossy reconstruction. \n\\par\nThe solution to the above problem requires essentially the same mild assumptions\nthe bits-back argument does, namely that Alice and Bob are allowed to\nshare a fixed prior $p(Y)$ on the latent codes, as well as the seed used for\ntheir random generators. The significance of the latter assumption is that Alice\nand Bob will be able to reconstruct the same sequence of random numbers. Given\nthese assumptions, \\cite{harsha2007communication} propose a rejection sampling\nalgorithm to sample from $q(Y \\mid X = x)$ using $p(Y)$, depicted in Algorithm\n\\ref{alg:harsha_rej_sampling} in the Appendix. Alice uses this algorithm to\nsample $q$, but she also keeps track of the number of proposals made by the\nalgorithm. Once Alice's algorithm accepts a proposal from $p$, it is sufficient\nfor Alice to communicate the sample's index $K$ to Bob. Bob can then obtain the\ndesired sample from $q$, by simply drawing $K$ samples from $p$, and since he\ncan generate the same $K$ samples as Alice did, the $K$th sample he draws is\ngoing to be an exact sample from $q$. The communication cost of $K$ is\n$\\log K$ nats. \\cite{harsha2007communication} then also prove the following result.\n\\begin{theorem}{(\\cite{harsha2007communication})}\n  \\label{thm:bits-back_efficiency}\nLet $X$ and $Y$ be random variables as given above. And let the communication\nproblem be set as above. Let $T[X : Y]$ denote the MDL (in nats) of a sample\n$Y=y \\sim q(Y \\mid X=x)$. Then,\n\\begin{equation}\n\\label{eq:harsha_upper_bound}\n  I[X : Y] \\leq T[X : Y] \\leq I[X : Y] + 2\\log \\left[ I[X : Y] + 1 \\right] + \\Oh(1),\n\\end{equation}\nwhere $I[ X : Y ]$ is called the mutual information between $X$ and $Y$, and is\ndefined as\n\\[\n  I[ X : Y ] = \\Exp{\\KL{q(Y \\mid X)}{p(Y)}}{p(X)}\n\\]\nFurthermore, $\\log K$, given by Algorithm \\ref{alg:harsha_rej_sampling},\nachieves the upper bound in Eq \\ref{eq:harsha_upper_bound}.\n\\end{theorem}\n\\par\nThe above theorem tells us that while in the classical sense bits-back efficiency\nis the best that we can do, it also tells us that we can get very close to it.\nHence, from now on, we shall refer to any algorithm that achieves this tight\nupper bound as bits-back efficient as well.\n\\par\nTo translate this to a general ML-based compression framework, we shall switch\nto notation more common in statistical modelling, concretely, we shall denote\nour data by $\\vec{x}$ and the latent code $\\vec{z}$. Now, let us assume a\ngenerative model over these variables, $p(\\vec{x}, \\vec{z}) = p(\\vec{x} \\mid\n\\vec{z})p_\\theta(\\vec{z})$, where $p(\\vec{x} \\mid \\vec{z})$ is the data likelihood, and\n$p_\\theta(\\vec{z})$ is the prior over the latent code, with sufficient\nstatistics $\\theta$. Let us also assume an approximate posterior $q_\\phi(\\vec{z}\n\\mid \\vec{x})$ over the latent code, with sufficient statistics $\\phi$. Then our\nframework is as follows:\n\\begin{enumerate}\n\\item Given some dataset $\\Data = \\{\\vec{x}_1, \\hdots, \\vec{x}_n\\}$ where the\n  training examples are distributed according to $p(\\vec{x})$, we fit our\n  generative model to it, by fitting $\\theta$ and $\\phi$ using the (weighted) MDL\n  objective:\n  \\begin{equation}\n    \\label{eq:mdl_elbo}\n    \\begin{gathered}\n      L(\\Data) = \\Exp{L(\\vec{x})}{p(\\vec{x})}, \\\\\n      \\text{where } L(\\vec{x}) = \\Exp{L(\\vec{x} \\mid \\vec{z}) + L(\\vec{z})}{q_\\phi}\n      =  -\\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi} + \\beta\\KL{q_\\phi}{p_\\theta}.\n    \\end{gathered}\n  \\end{equation}\n  This training objective is well known in the neural generative modelling\n  literature as the Evidence Lower Bound (ELBO) (\\cite{kingma2013auto},\n  \\cite{higgins2017beta}). The expectation over $p(\\vec{x})$ is usually taken over\n  randomly drawn mini-batches from $\\Data$ using Stochastic Gradient Descent (SGD).\n  Here $\\beta$ is a\n  hyperparameter that can be set to trade off a smaller description length at\n  the cost of worse reconstruction, or the other way around, thus allowing the\n  user to reach different points on the rate-distortion curve. See Section\n  \\ref{sec:derive_weighted_elbo} for the derivation of Eq \\ref{eq:mdl_elbo} and\n  discussion on its validity.\n\n  \\item Once $\\theta$ and $\\phi$ have been learned, we fix them (equivalent to\n    sharing them with Bob in the communication problem).\n\n  \\item Now, if we wish to compress some new data $\\vec{x}'$, use a bits-back\n    efficient sampling algorithm (such as Algorithm\n    \\ref{alg:harsha_rej_sampling}) to sample $q(\\vec{z} \\mid \\vec{x}')$ using\n    $p(\\vec{z})$, and use the code output of the sampling algorithm as the\n    compression code, along with the random seed that was used to obtain the sample. \n    We shall refer to such algorithms as \\textbf{coded sampling algorithms}.\n\n  \\item To decompress, since we always have access to the fixed prior\n    $p_\\theta$, and we have the random seed the compressing party used, we may\n    run the coded sampling algorithm in ``decode'' mode to recover the sample $\\vec{z}'$\n    from $q_\\phi$. Finally, we may run the reconstruction transformation of our\n    generative model to recover a lossy reconstruction $\\hat{\\vec{x}}'$.\n\\end{enumerate}\n\n\\par \nThis framework is inspired by the work of \\cite{havasi2018minimal}, where they\nused a very similar framework to achieve state-of-the-art weight compression in\nBayesian Neural Networks.\n\\par\nIn this thesis, we use this framework to train $\\beta$-VAEs as our choice of\ngenerative models and demonstrate the efficiency of our method compared to the\nstate-of-the-art in neural compression. More details on this will be given in\nChapter \\ref{chapter:method}. \n\n\\subsection{Relation of Quantization to Our Framework}\n\\par\nWe present a similar argument to the one given in \\cite{havasi2018minimal}.\nRecall the original representation space $R$ and quantized space $S$ of a\nquantizer $[\\cdot]$. Recall also the Kronecker delta function on $x$, defined as \n\\[\n  \\delta_{x}(y) = \n  \\begin{cases}\n    1 & \\text{if } y = x \\\\\n    0 & \\text{otherwise}.\n  \\end{cases}\n\\]\nGiven a particular $x \\in R$, we have seen that\nquantization allows us to code it in $-\\log \\hat{Q}([x])$ nats. If we manipulate\nthis term slightly, we get\n\\begin{align*}\n  -\\log \\hat{Q}([x]) &= \\sum_{s \\in S} \\left[ -\\delta_{[x]}(s)\\log \\hat{q}([x]) + \\underbrace{\\delta_{[x]}(s) \\log \\delta_{[x]}(s)}_{= 0} \\right] \\\\\n                     &= \\sum_{s \\in S} \\delta_{[x]}(s)\\log\\frac{\\delta_{[x]}(s)}{\\hat{q}([x])} \\\\\n                     &= \\KL{\\delta_{[x]}}{\\hat{Q}}.\n\\end{align*}\nThis shows that quantization of a deterministic parameter set is also\nbits-back efficient, with the posterior distribution family restricted to point masses. Thus\nthe clear advantage of our framework comes from the fact that we allow much more\nposteriors than point masses. \n\n\\subsection{Derivation of the Training Objective}\n\\label{sec:derive_weighted_elbo}\n\\par\nIn this section, we present the derivation of Eq \\ref{eq:mdl_elbo}. Thus, let our\nlikelihood $p(\\vec{x} \\mid \\vec{z})$, our latent prior $p_\\theta(\\vec{z})$ and\napproximate posterior $q_\\phi(\\vec{z} \\mid \\vec{x})$ be given. Then, given a budget\nof $C$ nats, we want to optimize the following constrained objective on the\ndescription lengths:\n\\[\n  \\Exp{\\Exp{-L(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})}}{p(\\vec{x})}\n  \\quad \\text{subject to } \\Exp{L(\\vec{z})}{p(\\vec{x})} < C.\n\\]\nAs we have seen in the sections above, these quantities can be replaced by\n\\begin{equation}\n\\label{eq:framework_hard_train_target}\n\\Exp{\\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})}}{p(\\vec{x})}\n\\quad \\text{subject to } \\Exp{\\KL{q_{\\phi}(\\vec{z} \\mid\n    \\vec{x})}{p_{\\theta}(\\vec{z})}}{p(\\vec{x})} < C.\n\\end{equation}\n\nAs we want to use gradient-based optimization of our models, we need to find a\ncontinuous relaxation of Eq \\ref{eq:framework_hard_train_target}.\nTo this end, we rewrite the terms inside the ``outer'' expectation as their\nLagranagian relaxation under the KKT conditions (\\cite{karush2014minima},\n\\cite{kuhn2014nonlinear}, \\cite{higgins2017beta}) and get:\n\\[\n  \\F(\\theta, \\phi, \\beta, \\vec{x}) = \n  \\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})}\n  - \\beta (\\KL{q_{\\phi}(\\vec{z} \\mid \\vec{x})}{p_{\\theta}(\\vec{z})} - C).\n\\]\nBy the KKT conditions if $C \\geq 0$ then $\\beta \\geq 0$, hence discarding the last\nterm in the above equation will provide a lower bound for it:\n\\[\n  \\F(\\theta, \\phi, \\beta, \\vec{x}) \\geq\n  \\L(\\theta, \\phi, \\beta, \\vec{x}) =\n  \\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})} - \\beta\n  \\KL{q_{\\phi}(\\vec{z} \\mid \\vec{x})}{p_{\\theta}(\\vec{z})}.\n\\]\nFinally, taking the expectation over this again gives\n\\begin{equation}\n\\label{eq:framework_train_target}\n\\begin{aligned}\n  \\Exp{\\L(\\theta, \\phi, \\beta, \\vec{x})}{p(\\vec{x})} &=\n  \\Exp{\\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})}}{p(\\vec{x})} - \\beta\n  \\Exp{\\KL{q_{\\phi}(\\vec{z} \\mid \\vec{x})}{p_{\\theta}(\\vec{z})}}{p(\\vec{x})} \\\\\n  &= \\Exp{\\Exp{\\log p(\\vec{x} \\mid \\vec{z})}{q_\\phi(\\vec{z})}}{p(\\vec{x})} - \\beta\n  I[ \\vec{x} : \\vec{z} ] \\\\\n  &= \\Exp{L(\\vec{x})}{p(\\vec{x})}.\n\\end{aligned}\n\\end{equation}\nThis is the training objective of $\\beta$-VAEs first derived in\n\\cite{higgins2017beta}, although we note that it is applicable any generative\nmodel where the assumed conditions are present.\n\\par\nAn important caveat of the above formulation is that the samples from\n$p(\\vec{x})$ should comparable, in the sense the initial hard optimization objective\nof setting an average nat budget is reasonable. In the case of image data, if\nall images are the same size, this is fine, as our continuous relaxation will\nallow for images with high information content to have slightly longer code\nlengths than $C$ nats and ones with low information content will have shorter\nlengths. However, if we used different sized images during training, it would be\nless justified to set the same average code budget for, say, a $200 \\times 300$ pixel\nimage and a $2000 \\times 2000$ image, as the latter will naturally contain more\ninformation than the former. Hence, in this case, it would be more reasonable\nto make the budget a function of the number of pixels the image contains,\nalthough this might make the formulation of the training objective much harder.\n\\par\nAn approach taken in all neural image compression methods we examined is instead\nto train on random, but equal-sized patches extracted from each training image.\nWhile other works do this to make training more computationally feasible. As\nfar as we are aware, we are the first ones to argue that this practice is not only\nconvenient but mandatory for the training procedure to be sound.\n\n\\nomenclature[z-VAE]{VAE}{Variational Auto-Encoder}\n\\nomenclature[z-MSE]{MSE}{Mean Squared Error}\n\\nomenclature[z-MAE]{MAE}{Mean Absolute Error}\n\\nomenclature[z-PLN]{PLN}{Probabilistic Ladder Network}\n", "meta": {"hexsha": "43b53b7b301763209df808a2e6f6ce2a47e02b0a", "size": 37331, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "masters-thesis/Chapter2-Background/chapter2.tex", "max_stars_repo_name": "gergely-flamich/miracle-compression", "max_stars_repo_head_hexsha": "7bee78f47982dda123343d25ead9de3c8bce17f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "masters-thesis/Chapter2-Background/chapter2.tex", "max_issues_repo_name": "gergely-flamich/miracle-compression", "max_issues_repo_head_hexsha": "7bee78f47982dda123343d25ead9de3c8bce17f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2020-01-28T22:13:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T00:22:22.000Z", "max_forks_repo_path": "masters-thesis/Chapter2-Background/chapter2.tex", "max_forks_repo_name": "gergely-flamich/miracle-compression", "max_forks_repo_head_hexsha": "7bee78f47982dda123343d25ead9de3c8bce17f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.1814223512, "max_line_length": 148, "alphanum_fraction": 0.725777504, "num_tokens": 10469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4259392822926508}}
{"text": "\\documentclass[thesis.tex]{subfiles}\n\n\\begin{document}\n\nCoupled-cluster theory is a powerful method for approximating solutions to the many-body Schr\\\"odinger equation.  Because of its effectiveness and economical scaling it has been a staple of many-body quantum mechanics for decades.  This chapter details various aspects of the coupled-cluster approach and presents ground-state results for multiple systems.  First, the CC wave operator and the corresponding effective Hamiltonian will be introduced and used to derive the CC equations.  Then, results from MBPT are used to illuminate the underlying many-body physics of the CC wave function.  After the mathematical foundations of coupled cluster theory are outlined, specific implementation details are discussed and demonstrated by focusing on two simple examples.  Finally, the nuclear many-body problem is formally introduced, along with a brief description of the nuclear interactions used in this work, and selected results are shown.\n\n\\section{Exponential Ansatz} \\label{section:exponentialansatz}\n\nCoupled cluster theory is based on expressing the $A$-particle correlated wave function $\\corrket$ using the exponential ansatz \\cite{COESTER1960477,CIZEK19664256,HUBBARD1957539,HUGENHOLTZ1957481},\n\\begin{equation} \\label{eq:cc_ansatz}\n  \\corrket = \\E^{\\Top}\\refket.\n\\end{equation}\nThe cluster operator $\\Top \\equiv \\Top_{1} + \\Top_{2} + \\cdots + \\Top_{A}$, is composed of $k$-particle $k$-hole excitation operators, $\\Top_{k}$, which have the form,\n\\begin{gather} \\label{eq:cc_amps}\n  \\Top_{1} \\equiv \\sum_{ai} \\tamp{a}{i}\\normord{\\co{a}\\ao{i}}, \\notag \\\\\n  \\Top_{2} \\equiv \\frac{1}{4}\\sum_{abij} \\tamp{ab}{ij}\\normord{\\co{a}\\co{b}\\ao{j}\\ao{i}}, \\notag \\\\\n  \\vdots \\notag \\\\\n  \\Top_{k} \\equiv \\left(\\frac{1}{k!}\\right)^2 \\sum_{\\substack{a_{1} \\ldots a_{k} \\\\ i_{1} \\ldots i_{k}}} \\tamp{a_{1} \\cdots a_{k}}{i_{1} \\cdots i_{k}}\\normord{\\co{a_{1}} \\cdots \\co{a_{k}} \\ao{i_{k}} \\cdots \\ao{i_{1}}},\n\\end{gather}\nwhere the unknown matrix elements, $\\tamp{a_{1} \\ldots a_{k}}{i_{1} \\ldots i_{k}}$, are known as \\textit{cluster amplitudes} \\cite{SHAVITT2009}.\n\nUsing the CC ansatz, the Schr\\\"odinger equation can be rewritten by left-multiplying with $\\refbra \\E^{-\\Top}$ as,\n\\begin{gather} \\label{eq:cc_schrodeq}\n  \\Ham \\E^{\\Top} \\refket = E \\E^{\\Top} \\refket \\notag \\\\\n  \\hspace{-1.0cm}\\longrightarrow \\ \\ \\refbra\\EHam\\refket = E,\n\\end{gather}\nwhere the \\textit{coupled cluster effective Hamiltonian} is defined as,\n\\begin{align} \\label{eq:cc_heff0}\n  \\EHam \\equiv \\E^{-\\Top} \\Ham \\E^{\\Top},\n\\end{align}\nin which the wave operator, $\\E^{\\Top}$, acts as a similarity transform on the Hamiltonian.  Using the normal-ordered Hamiltonian $\\EHamN$ and the correlation energy $\\Ecorr$ from Eq.\\ \\eqref{eq:normal_schrodinger}, this can rewritten as,\n\\begin{align} \\label{eq:cc_heff1}\n  \\HamN \\E^{\\Top} \\refket = \\Ecorr \\E^{\\Top} \\refket \\notag \\\\\n  \\hspace{-1.0cm}\\longrightarrow \\ \\ \\refbra\\EHamN\\refket = \\Ecorr,\n\\end{align}\nwhere the \\textit{normal-ordered effective Hamiltonian} is constructed equivalently to Eq.\\ \\eqref{eq:cc_heff0},\n\\begin{align} \\label{eq:cc_heff0}\n  \\EHamN \\equiv \\E^{-\\Top} \\HamN \\E^{\\Top}.\n\\end{align}\n\nAn important characteristic of the effective Hamiltonian, $\\EHam$ and $\\EHamN$, is that because the cluster operator, which contains no de-excitations, is not Hermitian, the exponential wave operator cannot be unitary, and thus $\\EHam$ is not Hermitian.  This initially seems like an explicit contradiction to any standard quantum mechanics formulation where observables are associated with the real eigenvalues of Hermitian matrices. Technically, the existence and reality of the CC solution is only guaranteed when the full cluster operator is used $\\Top = \\Top_{1} + \\cdots + \\Top_{A}$, see \\cite{ZIVKOVIC1977,PIECUCH1990,PIECUCH2000,MOISEYEV2011}.  However, while the non-Hermiticity does require some special considerations which will be discussed, this fundamental problem does not materialize in this work.\n\nThe effective Hamiltonian in Eq.\\ \\eqref{eq:cc_heff0} can be rewritten with commutators ($[ \\hat{A},\\hat{B} ] = \\hat{A}\\hat{B} - \\hat{B}\\hat{A}$) according to the Baker--Campbell--Hausdorff expansion as,\n\\begin{align} \\label{eq:bch-cc}\n  \\EHam = \\Ham + [\\Ham, \\Top] + \\frac{1}{2!} [[\\Ham, \\Top], \\Top] + \\frac{1}{3!} [[[\\Ham, \\Top], \\Top], \\Top] + \\frac{1}{4!} [[[[\\Ham, \\Top], \\Top], \\Top], \\Top] + \\cdots,\n\\end{align}\nwhich terminates at four-nested commutators when using a two-body  interaction.  This commutator expression ensures that CC theory is size-extensive and contains only connected terms.  In addition, because $\\Top$ is an excitation operator, terms of the form $\\Top\\Ham$ are necessarily disconnected and thus vanish \\cite{SHAVITT2009}.  Therefore the CC effective Hamiltonian can be further reduced to\n\\begin{align} \\label{eq:cc_heff1}\n  \\EHam = \\left(\\Ham e^{\\Top}\\right)_{\\mathrm{c}},\n\\end{align}\nwhere the subscript ``$\\mathrm{c}$'' indicates that only connected terms are used.\n\n\\subsection{The Coupled Cluster Equations} \\label{section:intro_cc_equations}\n\nIn practice, the cluster operator $\\Top$ must be truncated for calculations to be computationally feasible.  In this work, we use only single and double excitations where applicable,\n\\begin{align*}\n  \\Top = \\Top_{1} + \\Top_{2}.\n\\end{align*}\nThis is known as coupled cluster with singles and doubles (CCSD), with an asymptotic computational cost that scales like $\\mathcal{O}\\left( n_{p}^{4}n_{h}^{2} \\right)$, where $n_{h}$ is the number of hole states and $n_{p}$ is the number of particle states.  This truncation has been successfully applied to many problems in quantum chemistry \\cite{BARTLETT2007291} and nuclear physics \\cite{KOWALSKI2004132501,HAGEN2014096302}.\n\nThe unknown cluster amplitudes in CCSD, $\\amp{a}{i}$ and $\\amp{ab}{ij}$, can be calculated by left-multiplying Eq.\\ \\eqref{eq:cc_schrodeq} with $\\statebra{a}{i} \\E^{-\\Top}$ and with $\\statebra{ab}{ij} \\E^{-\\Top}$, respectively,\n\\begin{align} \\label{eq:ccsd1}\n  \\statebra{a}{i} \\EHam \\refket &= 0, \\notag \\\\\n  \\statebra{ab}{ij} \\EHam \\refket &= 0.\n\\end{align}\nAfter the Fock matrix has been diagonalized, the diagonal components of Eq.\\ \\eqref{eq:ccsd1} can be separated and, after expanding the exponent in Eq.\\ \\eqref{eq:cc_heff1}, the non-vanishing terms of the CCSD amplitude equations in the HF basis become,\n\\begin{gather} \\label{eq:ccsd2}\n  \\statebra{a}{i} \\left[ \\Ham_{2} \\left(\\Top_{1} + \\Top_{2} + \\Top_{1}\\Top_{2} + \\frac{1}{2!} \\Top_{1}^{2} + \\frac{1}{3!} \\Top_{1}^{3}\\right) \\right]_{\\mathrm{c}} \\refket = \\Edenom{a}{i}\\amp{a}{i} \\\\\n  \\statebra{ab}{ij} \\left[ \\Ham_{2} \\left(1 + \\hat{T}_1 + \\hat{T}_2 + \\frac{1}{2} \\hat{T}_1^{2} + \\hat{T}_1\\hat{T}_2 + \\frac{1}{2!} \\hat{T}_2^{2} + \\frac{1}{3!} \\hat{T}_1^{3} + \\frac{1}{2!} \\hat{T}_1^{2} \\hat{T}_2 + \\frac{1}{4!} \\hat{T}_1^{4}\\right) \\right]_{\\mathrm{c}} \\refket = \\Edenom{ab}{ij}\\amp{ab}{ij}, \\notag\n\\end{gather}\nwhere $\\Edenom{}{}$ are equivalent to the MBPT energy denominators from Eq.\\ \\eqref{eq:energy_denominators}.\n\nThese non-linear equations are solved using an iterative procedure where the cluster amplitudes on the right-hand side of Eq.\\ \\eqref{eq:ccsd1} and Eq.\\ \\eqref{eq:ccsd2} are updated by calculating the terms on the left-hand side until a fixed point is reached.  Like the HF iterative procedure, employing convergence acceleration techniques can reduce the number of CC iterations required.  Detailed techniques for solving these equations are discussed in section \\ref{section:solvingcc}.\n\n\n\\section{Linked-Cluster Theorem and MBPT} \\label{section:linkedcluster}\n\nThe exponential ansatz in Eq.\\ \\eqref{eq:cc_ansatz} and the cluster amplitudes in Eq.\\ \\eqref{eq:cc_amps} are not just useful mathematical constructs for solving the many-body problem. They represent physical many-body dynamics and can be derived from the results of many-body perturbation theory, see section \\ref{section:MBPT}.  The \\textit{linked-cluster theorem} \\cite{HUGENHOLTZ1957481,FRANTZ196016,BRANDOW1967} states that the sum of all time orderings of a disconnected diagram is equal to the product of the two subdiagrams.  Using the results and techniques from the factorization theorem, \\ref{section:factorization_theorem}, the linked-cluster theorem can be used to factorize specific MBPT terms such that they can be analytically summed to infinite order.  This infinite summation is the main principle behind coupled cluster theory and can be shown to lead naturally to the exponential ansatz.\n\nThe first step in deriving the exponential ansatz is to group all the linked MBPT diagrams of Eq.\\ \\eqref{eq:linked_MBPT} into classes according to their number of disconnected pieces.  The first class, where all the terms are connected, can be defined as the cluster excitation operator $\\Top$, depicted by the vertex type \\raisebox{-5pt}{\\mbox{\\includegraphics[height=20pt]{diagrams/CCSD_dE/CCSD_dE-figure3.pdf}}}.  The connected terms can then be characterized by their excitation type such that $\\Top_{k}$ corresponds to $\\ph{k}{k}$ excitations.\n\nThe $\\Top_{1}$ operator represents the class of all connected $\\ph{1}{1}$ MBPT diagrams, which are determined by the number of particle-hole pairs (or pair of up- and down-lines) at the top of the diagram,\n\\begin{align} \\label{eq:t1_def}\n  \\Top_{1}\\refket \\equiv \\sdiagram{CC_Amps/CC_Amps-figure0} &= \\left(\\Top^{(1)}_{1} + \\Top^{(2)}_{1} + \\cdots\\right)\\refket = \\sdiagram{MBPT_linked/MBPT_linked-figure0} + \\sdiagram{MBPT_linked/MBPT_linked-figure4} + \\sdiagram{MBPT_linked/MBPT_linked-figure8} \\notag \\\\\n  &+ \\sdiagram{MBPT_linked/MBPT_linked-figure10} + \\sdiagram{MBPT_linked/MBPT_linked-figure11} + \\sdiagram{MBPT_linked/MBPT_linked-figure16} + \\sdiagram{MBPT_linked/MBPT_linked-figure17} + \\cdots,\n\\end{align}\nwhere only first-order $\\Top^{(1)}$ and second-order $\\Top^{(2)}$ terms are shown while resolvant lines and labels are removed for clarity.\nThe $\\Top_{2}$ operator similarly represents the class of all connected $\\ph{2}{2}$ MBPT diagrams.  The first- and second-order terms that belong to this class are,\n\\begin{align} \\label{eq:t2_def}\n  \\Top_{2}\\refket \\equiv \\sdiagram{CC_Amps/CC_Amps-figure1} &= \\left(\\Top^{(1)}_{2} + \\Top^{(2)}_{2} + \\cdots\\right)\\refket = \\sdiagram{MBPT_linked/MBPT_linked-figure1} + \\sdiagram{MBPT_linked/MBPT_linked-figure2} + \\sdiagram{MBPT_linked/MBPT_linked-figure3} \\notag \\\\\n  &+ \\sdiagram{MBPT_linked/MBPT_linked-figure6} + \\sdiagram{MBPT_linked/MBPT_linked-figure7} + \\sdiagram{MBPT_linked/MBPT_linked-figure13} + \\sdiagram{MBPT_linked/MBPT_linked-figure14} + \\sdiagram{MBPT_linked/MBPT_linked-figure15} + \\cdots.\n\\end{align}\nAdditionally, the $\\Top_{3}$ operator represents the class of all connected $\\ph{3}{3}$ MBPT diagrams, of which there is only two second-order terms,\n\\begin{align}\n  \\Top_{3}\\refket \\equiv \\sdiagram{CC_Amps/CC_Amps-figure2} &= \\left(\\Top^{(2)}_{3} + \\cdots\\right)\\refket = \\sdiagram{MBPT_linked/MBPT_linked-figure18} + \\sdiagram{MBPT_linked/MBPT_linked-figure19} + \\cdots.\n\\end{align}\nSo far, this is merely a redefinition of the connected class of MBPT diagrams up to all orders and is not particularly useful.  But the disconnected diagrams, neglected up to this point, can be recombined using the factorization theorem \\ref{section:factorization_theorem} to provide a powerful simplification (see \\cite{SHAVITT2009} for a more thorough derivation).\n\nAs an example, the remaining disconnected first- and second-order diagrams can be written as the product of connected diagrams.  First, the second-order disconnected diagram from the term $\\fop^{2}\\refket$ can be rewritten by adding a duplicate with the left and right subdiagrams exchanged, which doesn't change the value because the state labels are generic.  Then, the two disconnected diagrams can be rewritten using the factorization theorem following the example of Eq.\\ \\eqref{eq:factorization2},\n\\begin{equation}\n  \\xdiagram{MBPT/MBPT-figure12} = \\frac{1}{2}\\left( \\xdiagram{MBPT/MBPT-figure12} + \\xdiagram{MBPT/MBPT-figure13} \\right) = \\frac{1}{2}\\left( \\xdiagram{MBPT/MBPT-figure0} \\right)^{2}.\n\\end{equation}\nThe resulting product involves the first-order component of the $\\Top_{1}$ operator in Eq.\\ \\eqref{eq:t1_def}, $\\Top^{(1)}_{1}$.  Algebraically, this process is written below,\n\\begin{align} \\label{eq:t1_factorization}\n  \\sum_{\\mathclap{abij}}\\frac{\\fint{a}{i}\\fint{b}{j}}{\\Edenom{ab}{ij}\\Edenom{a}{i}}\\ket{\\Phi^{ab}_{ij}} &= \\frac{1}{2}\\sum_{\\mathclap{abij}}\\frac{\\fint{a}{i}\\fint{b}{j}}{\\Edenom{ab}{ij}\\Edenom{a}{i}}\\ket{\\Phi^{ab}_{ij}} + \\frac{1}{2}\\sum_{\\mathclap{abij}}\\frac{\\fint{a}{i}\\fint{b}{j}}{\\Edenom{ab}{ij}\\Edenom{b}{j}}\\ket{\\Phi^{ab}_{ij}} = \\frac{1}{2}\\sum_{\\mathclap{abij}}\\fint{a}{i}\\fint{b}{j}\\frac{\\Edenom{b}{j} + \\Edenom{a}{i}}{\\Edenom{ab}{ij}\\Edenom{a}{i}\\Edenom{b}{j}}\\ket{\\Phi^{ab}_{ij}} \\notag \\\\\n  &= \\frac{1}{2}\\left(\\sum_{\\mathclap{ai}}\\frac{\\fint{a}{i}}{\\Edenom{a}{i}}\\ket{\\Phi^{a}_{i}}\\right)\\left(\\sum_{\\mathclap{bj}}\\frac{\\fint{b}{j}}{\\Edenom{b}{j}}\\ket{\\Phi^{b}_{j}}\\right) = \\frac{1}{2}\\left(\\Top^{(1)}_{1}\\right)^{2}.\n\\end{align}\n\nThis procedure can be repeated for the single second-order disconnected term from $\\Vop^{2}\\refket$,\n\\begin{align}\n  \\xdiagram{MBPT/MBPT-figure21} &= \\frac{1}{2}\\left( \\xdiagram{MBPT/MBPT-figure21} + \\xdiagram{MBPT/MBPT-figure22} \\right) \\notag \\\\\n  &\\hspace{140pt} = \\frac{1}{2}\\left( \\xdiagram{MBPT/MBPT-figure1} \\right)^{2}.\n\\end{align}\nA similar results gives the product involving the first-order component of the $\\Top_{2}$ operator in Eq.\\ \\eqref{eq:t2_def}, $\\Top^{(1)}_{2}$.  Again, the factorization process is written algebraically,\n\\begin{align} \\label{eq:t2_factorization}\n  \\frac{1}{16}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ab}{ij}\\vint{cd}{kl}}{\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}}\\ket{\\Phi^{abcd}_{ijkl}} &= \\frac{1}{32}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ab}{ij}\\vint{cd}{kl}}{\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}}\\ket{\\Phi^{abcd}_{ijkl}} + \\frac{1}{32}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\frac{\\vint{ab}{ij}\\vint{cd}{kl}}{\\Edenom{abcd}{ijkl}\\Edenom{cd}{kl}}\\ket{\\Phi^{abcd}_{ijkl}} \\notag \\\\\n  &= \\frac{1}{32}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\vint{ab}{ij}\\vint{cd}{kl}\\frac{\\Edenom{cd}{kl} + \\Edenom{ab}{ij}}{\\Edenom{abcd}{ijkl}\\Edenom{ab}{ij}\\Edenom{cd}{kl}}\\ket{\\Phi^{abcd}_{ijkl}} \\notag \\\\\n  &= \\frac{1}{2}\\left(\\frac{1}{4}\\sum_{\\mathclap{abij}}\\frac{\\vint{ab}{ij}}{\\Edenom{ab}{ij}}\\ket{\\Phi^{ab}_{ij}}\\right)\\left(\\frac{1}{4}\\sum_{\\mathclap{cdkl}}\\frac{\\vint{cd}{kl}}{\\Edenom{cd}{kl}}\\ket{\\Phi^{cd}_{kl}}\\right) = \\frac{1}{2}\\left(\\Top^{(1)}_{2}\\right)^{2}.\n\\end{align}\n\nLastly, for the disconnected terms from $\\Vop\\fop\\refket$ and $\\fop\\Vop\\refket$, the first duplication step can be skipped and the diagrams can be factorized following the procedure in Eq.\\ \\eqref{eq:factorization2},\n\\begin{equation}\n  \\xdiagram{MBPT/MBPT-figure5} + \\xdiagram{MBPT/MBPT-figure9} = \\xdiagram{MBPT/MBPT-figure29}.\n\\end{equation}\nThis factorization results in a mixed term between the first-order components from the $\\Top_{1}$ and $\\Top_{2}$ operators,\n\\begin{align} \\label{eq:t1t2_factorization}\n  \\frac{1}{4}\\sum_{\\mathclap{\\substack{abc \\\\ ijk}}}\\frac{\\vint{ab}{ij}\\fint{c}{k}}{\\Edenom{abc}{ijk}\\Edenom{ab}{ij}}\\ket{\\Phi^{abc}_{ijk}} &+ \\frac{1}{4}\\sum_{\\mathclap{\\substack{abc \\\\ ijk}}}\\frac{\\vint{ab}{ij}\\fint{c}{k}}{\\Edenom{abc}{ijk}\\Edenom{c}{k}}\\ket{\\Phi^{abc}_{ijk}} = \\frac{1}{4}\\sum_{\\mathclap{\\substack{abcd \\\\ ijkl}}}\\vint{ab}{ij}\\fint{c}{k}\\frac{\\Edenom{c}{k} + \\Edenom{ab}{ij}}{\\Edenom{abc}{ijk}\\Edenom{ab}{ij}\\Edenom{c}{k}}\\ket{\\Phi^{abc}_{ijk}} \\notag \\\\\n  &= \\left(\\sum_{\\mathclap{ck}}\\frac{\\fint{c}{k}}{\\Edenom{c}{k}}\\ket{\\Phi^{c}_{k}}\\right)\\left(\\frac{1}{4}\\sum_{\\mathclap{abij}}\\frac{\\vint{ab}{ij}}{\\Edenom{ab}{ij}}\\ket{\\Phi^{ab}_{ij}}\\right) = \\Top^{(1)}_{1}\\Top^{(1)}_{2}\n\\end{align}\n\nAdding these factorized contributions from Eqs.\\ \\eqref{eq:t1_factorization}, \\eqref{eq:t2_factorization}, and \\eqref{eq:t1t2_factorization} gives $\\frac{1}{2}\\left(\\Top^{(1)}_{1}\\right)^{2} + \\Top^{(1)}_{1}\\Top^{(1)}_{2} + \\frac{1}{2}\\left(\\Top^{(1)}_{2}\\right)^{2} = \\frac{1}{2}\\left(\\Top^{(1)}_{1} + \\Top^{(1)}_{2}\\right)^{2}$.  Repeating this procedure for all diagrams with two disconnected parts ($\\mathrm{L}=2$) adds similar terms of all orders. The final contribution from the $\\mathrm{L}=2$ class of diagrams with two disconnected parts is,\n\\begin{equation}\n  \\sum_{n=0}^{\\infty}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket_{\\mathrm{L=2}} = \\frac{1}{2}\\Top^{2}.\n\\end{equation}\nA similar form results from any class of diagrams with $k$ disconnected pieces,\n\\begin{equation}\n  \\sum_{n=0}^{\\infty}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket_{\\mathrm{L=}k} = \\frac{1}{k!}\\Top^{k}.\n\\end{equation}\n\nTherefore, summing over all classes of diagrams gives the final result that justifies the exponential ansatz,\n\\begin{equation}\n  \\ket{\\Psi} = \\sum_{k=0}^{\\infty}\\sum_{n=0}^{\\infty}\\left[\\hat{R}_{0}\\mathop{(\\hat{V} - \\Delta E_{0})}\\right]^{n}\\refket_{\\mathrm{L=}k} = \\sum_{k=0}^{\\infty}\\frac{1}{k!}\\Top^{k}\\refket = \\E^{\\Top}\\refket.\n\\end{equation}\nThis equation shows the true strength and elegance of coupled cluster theory.  By an ingenious reorganization and factorization of certain MBPT diagrams, the exponential ansatz captures the contribution of these excitations to infinite order.  A more comprehensive derivation of the linked-cluster theorem can by found in \\cite{SHAVITT2009}.\n\n\\section{Example: Pairing Model} \\label{section:pairingmodel}\n\nIt's beneficial to illustrate a simplified example of coupled cluster theory.  For this purpose, we turn our attention to the simple pairing model.  This system uses a model space of $N$ shells, or degenerate groups of single-particle states, each with two opposite spin orbitals.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.35\\linewidth]{CC/Pairing_Space.pdf}\n  \\caption{Schematic representation of the pairing model space.  The shells are equally spaced and doubly degenerate with one spin-up and one spin-down state.}\n  \\label{fig:pairing_space}\n\\end{figure}\n\nWith a closed-shell reference state, the Hamiltonian is restricted to interact only between unbroken pairs, which can be written as,\n\\begin{gather} \\label{eq:pairing_ham}\n  \\HamB{1} = \\delta \\sum_{p}^{N} \\mathop{(p-1)} \\left[ \\co{p_{+}}\\ao{p_{+}} +\\ \\co{p_{-}}\\ao{p_{-}} \\right],\\ \\ \\text{and} \\notag \\\\\n  \\HamB{2} = -\\frac{g}{2} \\sum_{pq}^{N} \\co{p_{+}}\\co{p_{-}}\\ao{q_{-}}\\ao{q_{+}},\n\\end{gather}\nwhere $\\delta$ and $g$ are free parameters and the $\\pm$ labels represent the spin-up and spin-down states, respectively.\n\nAs with all other coupled cluster calculations in this work, the first step is transforming the problem to the Hartree-Fock basis.  In this case, the restriction to unbroken pairs means that the original single-particle states do not mix with states in other shells.  In fact, the original basis is already an eigenbasis of the Fock operator, Eq.\\ \\eqref{eq:fock_operator}, so that the HF transformation is reduced to a redefinition of the single-particle energies to their corresponding Hartree-Fock energies, leaving the two-body interaction unchanged,\n\\begin{gather}\\label{eq:pairing_hf}\n  \\varepsilon_{p_{m_{p}}} = \\Hint{1}{p_{m_{p}}}{p_{m_{p}}} + \\sum_{im_{i}}\\Hint{2}{p_{m_{p}}i_{m_{i}}}{p_{m_{p}}i_{m_{i}}} = \\delta\\mathop{(p-1)} - \\frac{g}{2}, \\notag \\\\\n  \\vint{pq}{rs} = \\Hint{2}{pq}{rs}.\n\\end{gather}\nBecause of the pairing restriction, only hole-state energies have to be redefined.\n\nThe next step in calculating the ground-state correlation energy is to solve the CCD equations in the Hartree-Fock basis.  The system of equations comes from the terms of Eq.\\ \\eqref{eq:ccsd2} that contain only the $\\Top_{2}$ operator, and are most easily derived with diagrammatic techniques, see \\cite{SHAVITT2009}.\n\\begin{gather} \\label{eq:ccd_equations}\n  \\statebra{ab}{ij}\\mathop{(\\Ham\\E^{\\Top_{2}})_{\\text{C}}}\\refket\\ - \\diagram{CCSD_t2/CCSD_t2-figure2} - \\diagram{CCSD_t2/CCSD_t2-figure1} = \\diagram{CCSD_t2/CCSD_t2-figure0} \\notag \\\\[-1.5ex]\n  + \\diagram{CCSD_t2/CCSD_t2-figure5} + \\diagram{CCSD_t2/CCSD_t2-figure6} + \\diagram{CCSD_t2/CCSD_t2-figure7} + \\diagram{CCSD_t2/CCSD_t2-figure11} \\notag \\\\[-1.5ex]\n  + \\diagram{CCSD_t2/CCSD_t2-figure12} + \\diagram{CCSD_t2/CCSD_t2-figure13} + \\diagram{CCSD_t2/CCSD_t2-figure14} \\notag \\\\\n  \\mathop{(\\varepsilon_{i} + \\varepsilon_{j} - \\varepsilon_{a} - \\varepsilon_{b})}\\tamp{ab}{ij} = \\vint{ab}{ij} + \\frac{1}{2}\\sum\\limits_{\\mathclap{kl}}\\vint{kl}{ij}\\tamp{ab}{kl} + \\frac{1}{2}\\sum\\limits_{\\mathclap{cd}}\\vint{ab}{cd}\\tamp{cd}{ij} - \\Perm{ij|ab}\\sum\\limits_{\\mathclap{kc}}\\vint{kb}{ic}\\tamp{ac}{kj} \\notag \\\\\n  + \\frac{1}{4}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ab}{kl}\\tamp{cd}{ij} + \\Perm{ab}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ac}{lj}\\tamp{bd}{ki} - \\Perm{ij}\\frac{1}{2}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ab}{lj}\\tamp{cd}{ki} - \\Perm{ab}\\frac{1}{2}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{db}{ij}\\tamp{ca}{kl}.\n\\end{gather}\nThe CCD equations are written in this particular form so that an initial guess for all the amplitudes $\\tamp{ab}{ij}$ can be used to calculate the right-hand side of Eq.\\ \\eqref{eq:ccd_equations} and update the amplitudes on the left-hand side iteratively until the amplitudes do not change within a certain tolerance.\n\nLastly, the CCD correlation energy can be found with the $\\Top_{2}$ term of Eq.\\ \\eqref{eq:cc_schrodeq},\n\\begin{equation} \\label{eq:ccd_energy}\n  \\Ecorr_{\\text{CCD}} = \\refbra\\mathop{(\\Ham\\E^{\\Top_{2}})_{\\text{C}}}\\refket\\ = \\diagram{CCSD_dE/CCSD_dE-figure0}\\ =\\ \\frac{1}{4}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{cd}{kl}.\n\\end{equation}\nThe correlation energies for a specific case, with $\\delta = 1.0$, $N = 4$, and $A = 4$, were calculated for a number of different interaction strengths, $g$.  The results are shown in Fig.\\ \\ref{fig:pairingplot} along with the MBPT correlation energies to third (MBPT3) and fourth (MBPT4) orders for comparison.  The nonzero MBPT expressions for second and third order are,\n\\begin{align} \\label{eq:mbpt_2_3}\n  \\Ecorr_{\\text{MBPT2}} &= \\frac{1}{4}\\sum\\limits_{\\mathclap{ijab}}\\frac{\\vint{ij}{ab}\\vint{ab}{ij}}{\\Edenom{ab}{ij}}, \\\\\n  \\Ecorr_{\\text{MBPT3}} &= \\Ecorr_{\\text{MBPT2}} + \\frac{1}{8}\\sum\\limits_{\\mathclap{ijabcd}}\\frac{\\vint{ij}{ab}\\vint{ab}{cd}\\vint{cd}{ij}}{\\Edenom{ab}{ij}\\Edenom{cd}{ij}} + \\frac{1}{8}\\sum\\limits_{\\mathclap{ijklab}}\\frac{\\vint{ij}{ab}\\vint{kl}{ij}\\vint{ab}{kl}}{\\Edenom{ab}{ij}\\Edenom{ab}{kl}}.\n\\end{align}\nGenerally, the fourth-order expression contains 39 additional terms.  However, most of these vanish in this case because of the form of the pairing interaction.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.8\\textwidth]{CC/CCDMBPT4theory.pdf}\n  \\caption{Correlation energy for the pairing model with exact diagonalization, CCD, and perturbation theory to third (MBPT3) and fourth order (MBPT4) for a range of interaction values, $g$.}\n  \\label{fig:pairingplot}\n\\end{figure}\n\nAlso shown are the exact results from the CI method.  With an example this small, it's possible to diagonalize, and even show explicitly, the full CI Hamiltonian matrix for an exact result.  There are six possible Slater determinants with no broken pairs, one representing the reference state, four representing various $\\ph{2}{2}$ excitations, and one representing a $\\ph{4}{4}$ excitation.  The diagonal elements of the matrix include the single-particle energies of the constituent states, and the matrix elements between Slater determinants with no overlap vanish in accordance with the Slater-Condon rules, see Eq.\\ \\eqref{eq:slater_condon} and \\cite{SLATER1929,CONDON1930}.  The full Hamiltonian matrix to be diagonalized is,\n\\begin{equation}\n  H = \\begin{bmatrix}\n    2\\delta -g & -g/2 & -g/2 & -g/2 & -g/2 & 0 \\\\ -g/2 & 4\\delta -g &\n    -g/2 & -g/2 & -0 & -g/2 \\\\ -g/2 & -g/2 & 6\\delta -g & 0 & -g/2 &\n    -g/2 \\\\ -g/2 & -g/2 & 0 & 6\\delta-g & -g/2 & -g/2 \\\\ -g/2 & 0 & -g/2\n    & -g/2 & 8\\delta-g & -g/2 \\\\ 0 & -g/2 & -g/2 & -g/2 & -g/2 &\n    10\\delta -g\n  \\end{bmatrix}.\n\\end{equation}\n\nAs methods to obtain the ground-state correlation energy, both CI and CC decouple, to some degree, the reference state and excitations from it.  This decoupling has the effect of shuffling correlations into the reference state and suppressing matrix elements connected to it.  Full decoupling between the reference state and all other Slater determinants can only be achieved with untruncated versions of these techniques, while decoupling of the strongest correlations can be approximately obtained with appropriate truncations.  However, unlike other many-body methods, the most unique aspect of the CC similarity transformation is that because of its non-unitarity, the resulting Hamiltonian will not be Hermitian.  This decoupling and non-Hermiticity can be seen in Fig.\\ \\ref{fig:pairingmatrix}, which shows the effect of the CC similarity transformation on the Hamiltonian for a pairing case with $N = 6$ and $A = 4$.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=\\textwidth]{CC/pairingmatrix.pdf}\n  \\caption{Visualization of the CCD similarity transform on the pairing Hamiltonian for four particles and six shells.  This shows the main function of CCD, which is to decouple $\\ph{2}{2}$ excitations from the ground state, shown by the suppression of matrix elements on the first column. In the pairing model, this also has the effect of decoupling $\\ph{2}{2}$ excitations from $\\ph{4}{4}$ excitations.  Also, the non-unitary nature of the transformation is obvious given the asymmetry of the resulting Hamiltonian.}\n  \\label{fig:pairingmatrix}\n\\end{figure}\nThe effective Hamiltonian $\\EHam$ shown in Fig.\\ \\ref{fig:pairingmatrix} can be explicitly built, and it happens to be beneficial to do so as part of most CC calculations, both for solving the CC equations and for use in post-CC methods.  This topic is discussed in detail in the next section.\n\n\n\n\n\\section{Solving the Coupled Cluster Equations} \\label{section:solvingcc}\n\nAs described above, the coupled cluster equations are solved by first initializing all of the cluster amplitudes, then updating them by computing various sums over particle and hole combinations, $\\text{CC}\\mathop{(\\Top)}$.  This updating procedure is performed over multiple iterations until the amplitudes stay unchanged within a certain tolerance,\n\\begin{align} \\label{eq:cc_algorithm}\n  &\\text{Initialize}:&    \\hspace{-20pt}&\\Top^{\\mathop{(0)}} = \\Top_{\\text{init}}, \\notag \\\\\n  &\\text{Iterate}:&       \\hspace{-20pt}&\\Top^{\\mathop{(n+1)}}\\ \\leftarrow\\ \\text{CC}\\mathop{(\\Top^{\\mathop{(n)}})}.\n\\end{align}\n\nGenerally, the convergence of this algorithm depends on the relative magnitudes between the inter-particle force and the single-particle energy spacing.  For a relatively small Fermi gap between the closed shell of occupied states and the unoccupied particle states, the energy denominators will approach zero and cause a divergent or chaotic solution \\cite{SZAKACS2008}.  Physically, this situation occurs when a system exhibits strong many-particle clustering, which is difficult to capture with only the single and double excitations of CCSD.  A simple way to avoid this ill-defined behavior is to scale the energy denominators for early iterations or to employ linear mixing to dampen the solution,\n\\begin{equation} \\label{eq:cc_damping}\n  \\Top^{\\mathop{(n+1)}} \\leftarrow\\ \\alpha\\text{CC}\\mathop{(\\Top^{\\mathop{(n)}})} + \\left(1 - \\alpha\\right)\\Top^{\\mathop{(n)}}.\n\\end{equation}\nIf a solution to a highly-collective system does not diverge, it typically converges very slowly.  To improve the convergence rate, techniques already utilized for the Hartree-Fock iterations can also be employed here, such as DIIS \\cite{PULAY1980393,PULAY1982556} or Broyden's method \\cite{BROYDEN1965557}.  The additional computational complexity for the CC iterations is simply a multiplicative factor equal to the number of iterations performed.  Typical calculations in this work with DIIS acceleration are converged within $\\sim 30$ iterations.  Therefore, any significant improvements to the CC algorithm will involve the expensive sums embedded within the function $\\text{CC}\\mathop{(\\Top^{\\mathop{(n)}})}$.\n\n\n\\subsection{Symmetry Channels} \\label{section:symmetry_channels}\n\nFor the coupled cluster equations, as well as many other many-body methods, the first way to simplify the various sums is to exploit any symmetries of the underlying Hamiltonian of a particular problem.  These symmetries manifest as conserved quantities, and because of the underlying nature of the cluster operators, see Section\\ \\ref{section:linkedcluster}, these must conserve these quantum numbers as well.  For example, the pairing Hamiltonian of Section\\ \\ref{section:pairingmodel} has a symmetry that conserves both the total spin projection and the number of pairs.  The Coulomb Hamiltonian of Section\\ \\ref{section:electrongas}, which has translational symmetry, conserves the linear momentum of any state.  Finally, the spherical symmetry of the nuclear Hamiltonian ensures that angular momentum and parity are conserved.  To utilize these symmetries, any sums that contain many-body states with different conserved quantum numbers can be ignored.  For efficiency, these symmetry groups can be pre-sorted into \\textit{channels}, $\\Sigma_{\\vec{\\xi}}$, where $\\vec{\\xi}$ represents the relevant quantum numbers of a certain channel.\n\nFor CCSD calculations, useful types of channels include the direct two-body channels, $\\Sigma_{\\vec{\\xi}_{1}}$--which categorizes the vector sum of two single-particle-state quantum numbers--and the cross two-body channels, $\\Sigma_{\\vec{\\xi}_{2}}$--which categorizes the vector difference of two single-particle-state quantum numbers or, equivalently, the vector sum of a the quantum numbers of a single-particle state and a time-reversed single-particle state.\n\\begin{gather}\n  \\vec{\\xi}_{pq} = \\vec{\\xi}_{p} + \\vec{\\xi}_{q}\\ \\ \\longrightarrow\\ \\ \\ket{pq} \\in \\Sigma_{\\vec{\\xi}_{1}=\\vec{\\xi}_{pq}} \\\\\n  \\vec{\\xi}_{p\\bar{q}} = \\vec{\\xi}_{p} - \\vec{\\xi}_{q} = \\vec{\\xi}_{p} + \\vec{\\xi}_{\\bar{q}}\\ \\ \\longrightarrow\\ \\ \\ket{p\\bar{q}} \\in \\Sigma_{\\vec{\\xi}_{2}=\\vec{\\xi}_{p\\bar{q}}}\n\\end{gather}\nAlso useful are the one-body channels, $\\Sigma_{\\vec{\\xi}_{3}}$, which categorize both single-particle states by their conserved quantum numbers.  These one-body channels can also characterize a special type of three-body state: the vector difference between the quantum numbers of a direct two-body state and a single-particle state or, equivalently, the vector sum of the quantum numbers of a two-body direct state and a time-reversed single-particle state,\n\\begin{gather}\n  \\vec{\\xi}_{p}\\ \\ \\longrightarrow\\ \\ \\ket{p} \\in \\Sigma_{\\vec{\\xi}_{3}=\\vec{\\xi}_{p}} \\\\\n  \\vec{\\xi}_{pq\\bar{r}} = \\vec{\\xi}_{p} + \\vec{\\xi}_{q} - \\vec{\\xi}_{r} = \\vec{\\xi}_{p} + \\vec{\\xi}_{q} + \\vec{\\xi}_{\\bar{r}}\\ \\ \\longrightarrow\\ \\ \\ket{pq\\bar{r}} \\in \\Sigma_{\\vec{\\xi}_{3}=\\vec{\\xi}_{pq\\bar{r}}}.\n\\end{gather}\n\nUsing these channel structures, the interaction matrix elements and cluster amplitudes can be built in different ways.  The full applicability of these structures are shown in detail in appendix \\ref{chapter:appendix_computational}, but a few examples using sums in the CCD equations \\eqref{eq:ccd_equations} are shown here.  The direct two-body channels can be used when two summed indices appear in the bra- or ket-state of multiple matrix-elements,\n\\begin{equation} \\label{eq:channel_sums_1}\n  \\frac{1}{2}\\sum\\limits_{\\mathclap{cd}}\\vint{ab}{cd}\\tamp{cd}{ij} = \\frac{1}{2}\\sum\\limits_{\\mathclap{\\ket{cd}}}\\vint{ab}{cd}\\tamp{cd}{ij}\\ \\ \\text{for}\\ \\ket{cd} \\in \\Sigma_{\\vec{\\xi}_{ab}}=\\Sigma_{\\vec{\\xi}_{ij}}.\n\\end{equation}\nThe cross two-body channels are used when two summed indices appear in the opposite corresponding bra- and ket-states of multiple matrix-matrix elements,\n\\begin{equation} \\label{eq:channel_sums_2}\n  \\sum\\limits_{\\mathclap{kc}}\\vint{kb}{ic}\\tamp{ac}{kj} = \\sum\\limits_{\\mathclap{\\ket{k\\bar{c}}}}\\vint{k\\bar{c}}{i\\bar{b}}\\tamp{a\\bar{j}}{k\\bar{c}}\\ \\ \\text{for}\\ \\ket{k\\bar{c}} \\in \\Sigma_{\\vec{\\xi}_{i\\bar{b}}}=\\Sigma_{\\vec{\\xi}_{a\\bar{j}}}.\n\\end{equation}\nLastly, the one- and three-body channels are used when a single summed index appears opposite a direct two-body state in multiple matrix elements,\n\\begin{equation} \\label{eq:channel_sums_3}\n  \\frac{1}{2}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{db}{ij}\\tamp{ca}{kl} = \\frac{1}{2}\\sum\\limits_{\\mathclap{\\substack{\\ket{kl\\bar{c}} \\\\ \\ket{d}}}}\\vint{kl\\bar{c}}{d}\\tamp{d}{ij\\bar{b}}\\tamp{a}{kl\\bar{c}}\\ \\ \\text{for}\\ \\ket{kl\\bar{c}},\\ket{d} \\in \\Sigma_{\\vec{\\xi}_{ij\\bar{b}}}=\\Sigma_{\\vec{\\xi}_{a}}.\n\\end{equation}\n\n\n\\subsection{Matrix Structures and Intermediates} \\label{section:maxtrix_intermediates}\n\nSymmetry channels not only provide an organized structure for the interaction matrix elements and cluster amplitudes, and remove any terms that violate the underlying symmetry of a problem, but they also naturally provide an efficient way of performing sums using matrix-matrix multiplications.  For example, the sums in Eqs.\\ \\eqref{eq:channel_sums_1}--\\eqref{eq:channel_sums_3} can be reformulated as matrix-matrix multiplications by structuring the channel-separated interaction matrix elements and cluster amplitudes into individual matrices.  These operations can be performed very quickly using highly optimized linear algebra algorithms like those found in BLAS (Basic Linear Algebra Subprograms) \\cite{blas}.  The matrices can be reordered so that the summed indices correspond to the internal columns and rows of those matrices.\n\nFor the direct two-body case of Eq.\\ \\eqref{eq:channel_sums_1}, the structures are already in the correct order such that the state $\\ket{cd}$, indexed by the columns of $\\bvint{}{}$ and the rows of $\\btamp{}{}$, is summed by multiplying the two matrices,\n\\begin{equation} \\label{eq:channel_matrices_1}\n  \\frac{1}{2}\\sum\\limits_{\\mathclap{cd}}\\vint{ab}{cd}\\tamp{cd}{ij} = \\frac{1}{2}\\bvint{ab}{cd}\\cdot\\btamp{cd}{ij}\\ \\ \\text{for}\\ \\ket{ab},\\ket{ij},\\ket{cd} \\in \\Sigma_{\\vec{\\xi}_{1}}.\n\\end{equation}\nFor the cross two-body case of Eq.\\ \\eqref{eq:channel_sums_2}, the states $\\ket{j}$, $\\ket{b}$, and $\\ket{c}$ are time reversed so that the summed variables are collected in a state $\\ket{k\\bar{c}}$.  Then the matrix structures are reordered so this state is indexed by columns and rows of $\\btamp{}{}$ and $\\bvint{}{}$, respectively,\n\\begin{equation} \\label{eq:channel_matrices_2}\n  \\sum\\limits_{\\mathclap{kc}}\\vint{kb}{ic}\\tamp{ac}{kj} = \\btamp{a\\bar{j}}{k\\bar{c}}\\cdot\\bvint{k\\bar{c}}{i\\bar{b}}\\ \\ \\text{for}\\ \\ket{a\\bar{j}},\\ket{i\\bar{b}},\\ket{k\\bar{c}} \\in \\Sigma_{\\vec{\\xi}_{2}}.\n\\end{equation}\nLastly, for the case of Eq.\\ \\eqref{eq:channel_sums_3}, the states $\\ket{b}$ and $\\ket{c}$ are time-reversed so that the states $\\ket{d}$ and $\\ket{kl\\bar{c}}$ appear in two different matrix elements.  Then, the matrix structures are reorganized so the summed states occur in the appropriate rows and columns for matrix-matrix multiplication,\n\\begin{equation} \\label{eq:channel_matrices_3}\n  \\frac{1}{2}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{db}{ij}\\tamp{ca}{kl} = \\frac{1}{2}\\btamp{a}{kl\\bar{c}}\\cdot\\bvint{kl\\bar{c}}{d}\\cdot\\btamp{d}{ij\\bar{b}}\\ \\ \\text{for}\\ \\ket{a},\\ket{ij\\bar{b}},\\ket{kl\\bar{c}},\\ket{d} \\in \\Sigma_{\\vec{\\xi}_{3}}.\n\\end{equation}\n\nThese sums correspond to different components of the updated cluster amplitudes according to Eq.\\ \\eqref{eq:cc_algorithm}, so that different channel structures of the matrix-matrix multiplications correspond to different amplitude structures according to the sum's external indices.  The two external direct two-body states of Eq.\\ \\eqref{eq:channel_matrices_1}, $\\ket{ab}$ and $\\ket{ij}$, naturally map to the direct amplitude structure,\n\\begin{equation} \\label{eq:amp_matrices_1}\n  \\btamp{ab}{ij}\\ \\leftarrow\\ \\frac{1}{2}\\bvint{ab}{cd}\\cdot\\btamp{cd}{ij}\\ \\ \\text{for}\\ \\ket{ab},\\ket{ij},\\ket{cd} \\in \\Sigma_{\\vec{\\xi}_{1}}.\n\\end{equation}\nSimilarly, the two external cross two-body states of Eq.\\ \\eqref{eq:channel_matrices_2}, $\\ket{a\\bar{j}}$ and $\\ket{i\\bar{b}}$, naturally map to the cross amplitude structure,\n\\begin{equation} \\label{eq:amp_matrices_2}\n  \\btamp{a\\bar{j}}{i\\bar{b}}\\ \\leftarrow\\ \\btamp{a\\bar{j}}{k\\bar{c}}\\cdot\\bvint{k\\bar{c}}{i\\bar{b}}\\ \\ \\text{for}\\ \\ket{a\\bar{j}},\\ket{i\\bar{b}},\\ket{k\\bar{c}} \\in \\Sigma_{\\vec{\\xi}_{2}}.\n\\end{equation}\nLastly, the one- and three-body external states of of Eq.\\ \\eqref{eq:channel_matrices_3}, $\\ket{a}$ and $\\ket{i\\bar{b}}$, naturally map to the one-body amplitude structure characterized by the index $a$,\n\\begin{equation} \\label{eq:amp_matrices_3}\n  \\btamp{a}{ij\\bar{b}}\\ \\leftarrow\\ \\frac{1}{2}\\btamp{a}{kl\\bar{c}}\\cdot\\bvint{kl\\bar{c}}{d}\\cdot\\btamp{d}{ij\\bar{b}}\\ \\ \\text{for}\\ \\ket{a},\\ket{ij\\bar{b}},\\ket{kl\\bar{c}},\\ket{d} \\in \\Sigma_{\\vec{\\xi}_{3}}.\n\\end{equation}\n\nThe last summation in the matrix-matrix form of Eqs.\\ \\eqref{eq:channel_matrices_3} and \\eqref{eq:amp_matrices_3} involves two multiplications, which suggests the need for an \\textit{intermediate} matrix to hold the result of the first operation.  This is the last main ingredient to an efficient CC algorithm.  To see the benefit of intermediate structures, it's helpful to examine an expensive sum from the CCD equations.  For typical calculations, particle states outnumber hole states by an order of magnitude, $n_{p} \\sim 10n_{h}$, which means that one of the most expensive sums is,\n\\begin{equation}\n  \\frac{1}{4}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ab}{kl}\\tamp{cd}{ij}.\n\\end{equation}\nBecause this term must be computed for each $\\tamp{ab}{ij}$, its computational cost naively scales as $\\mathcal{O}\\left( N_{h}^{4}N_{p}^{4}\\right)$.  However, using the matrix form of this sum and an intermediate matrix,\n\\begin{equation} \\label{eq:intermediate}\n  \\frac{1}{4}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ab}{kl}\\tamp{cd}{ij} = \\frac{1}{4}\\btamp{ab}{kl}\\cdot\\left(\\bvint{kl}{cd}\\cdot\\btamp{cd}{ij}\\right) = \\frac{1}{4}\\btamp{ab}{kl}\\cdot\\bxint{kl}{ij}\\ \\rightarrow\\ \\btamp{ab}{ij}.\n\\end{equation}\nthis term is now computed as the combination of two sums, each scaling as $\\mathcal{O}\\left( N_{h}^{4}N_{p}^{2}\\right)$.  These intermediates can also be used as a way to combine similar sums.  For example, the last step of Eq.\\ \\eqref{eq:intermediate} has a very similar structure to the first sum in Eq.\\ \\eqref{eq:ccd_equations}.  Therefore, the two sums can be written with a common intermediate as,\n\\begin{gather} \\label{eq:intermediate_2}\n  \\frac{1}{2}\\sum\\limits_{\\mathclap{kl}}\\vint{kl}{ij}\\tamp{ab}{kl} + \\frac{1}{4}\\sum\\limits_{\\mathclap{klcd}}\\vint{kl}{cd}\\tamp{ab}{kl}\\tamp{cd}{ij} = \\frac{1}{2}\\btamp{ab}{kl}\\cdot\\left[ \\bvint{kl}{ij} + \\frac{1}{2}\\bvint{kl}{cd}\\cdot\\btamp{cd}{ij} \\right] = \\frac{1}{4}\\btamp{ab}{kl}\\cdot\\bxint{kl}{ij}\\ \\rightarrow\\ \\btamp{ab}{ij}, \\notag \\\\\n  \\text{where},\\hspace{10pt} \\bxint{kl}{ij} = \\bvint{kl}{ij} + \\frac{1}{2}\\bvint{kl}{cd}\\cdot\\btamp{cd}{ij}.\n\\end{gather}\n\nIt just so happens that this form of the intermediate $\\xint{kl}{ij}$ is equivalent to the $\\mathrm{hhhh}$ component of the CCD similarity transformed Hamiltonian, $\\EHam$.  Constructing other intermediates in this way gives similar results, so it's a natural extension to actually construct the effective Hamiltonian at each iteration for the express purpose of using it as different intermediate components for the CC equations.  This has the added benefit of having already computed the effective Hamiltonian for post-CC methods.  The different components of the CCD effective Hamiltonian, $\\EHam_{\\mathrm{CCD}} = \\left(\\Ham\\E^{\\Top_{2}}\\right)_{\\mathrm{c}}$, are written below in both algebraic and diagrammatic form.  One-body components correspond to the vertex type \\raisebox{-5pt}{\\mbox{\\includegraphics[height=20pt]{diagrams/CCSD_1b/CCSD_1b-figure23.pdf}}} and two-body terms correspond to the vertex type \\raisebox{-5pt}{\\mbox{\\includegraphics[height=20pt]{diagrams/CCSD_1b/CCSD_1b-figure24.pdf}}}.  The $\\mathrm{pp}$, one-body component of $\\EHam_{\\mathrm{CCD}}$ is,\n\\begin{align} \\label{eq:ccd_eff1}\n  \\diagram{CCSD_1b/CCSD_1b-figure3} &= \\diagram{CCSD_1b/CCSD_1b-figure4} + \\diagram{CCSD_1b/CCSD_1b-figure5} \\notag \\\\\n  \\xint{a}{b} &= \\fint{a}{b} - \\frac{1}{2}\\sum\\limits_{klc}\\vint{kl}{bc}\\tamp{ac}{kl}.\n\\end{align}\nThe $\\mathrm{hh}$, one-body component is,\n\\begin{align} \\label{eq:ccd_eff2}\n  \\diagram{CCSD_1b/CCSD_1b-figure12} &= \\diagram{CCSD_1b/CCSD_1b-figure9} + \\diagram{CCSD_1b/CCSD_1b-figure10} \\notag \\\\\n  \\xint{i}{j} &= \\fint{i}{j} + \\frac{1}{2}\\sum\\limits_{kcd}\\vint{ik}{cd}\\tamp{cd}{jk}.\n\\end{align}\nThe $\\mathrm{hhhh}$, two-body component, which appears as the intermediate in Eqs.\\ \\eqref{eq:intermediate} and \\eqref{eq:intermediate_2}, is,\n\\begin{align} \\label{eq:ccd_eff3}\n  \\diagram{CCSD_2b/CCSD_2b-figure18} &= \\diagram{CCSD_2b/CCSD_2b-figure19} + \\diagram{CCSD_2b/CCSD_2b-figure20} \\notag \\\\\n  \\xint{ij}{kl} &= \\vint{ij}{kl} + \\frac{1}{2}\\sum\\limits_{cd}\\vint{ij}{cd}\\tamp{cd}{kl}.\n\\end{align}\nLastly, the $\\mathrm{hphp}$, two-body component is,\n\\begin{align} \\label{eq:ccd_eff4}\n  \\diagram{CCSD_2b/CCSD_2b-figure34} &= \\diagram{CCSD_2b/CCSD_2b-figure31} + \\frac{1}{2}\\fdiagram{CCSD_2b/CCSD_2b-figure36} \\notag \\\\\n  \\xint{ia}{jb} &= \\vint{ia}{jb} - \\frac{1}{2}\\sum\\limits_{kc}\\vint{ik}{cb}\\tamp{ca}{jk}.\n\\end{align}\n\nUsing these terms, the CCD equations can be written in pseudo-linear form using the $\\ph{2}{2}$ component of effective Hamiltonian form of the equations, Eq.\\ \\eqref{eq:ccsd1}.  This also explicitly shows the decoupling of the effective Hamiltonian with $\\ph{2}{2}$ excitations.  The $\\mathrm{pphh}$, two-body component, which should vanish when the CCS amplitudes have converged, is,\n\\begin{align} \\label{eq:ccd_double_linear}\n  \\diagram{CCSD_2b/CCSD_2b-figure59} = 0 &= \\diagram{CCSD_2b/CCSD_2b-figure60} + \\diagram{CCSD_2b/CCSD_2b-figure61} + \\diagram{CCSD_2b/CCSD_2b-figure62} \\notag \\\\[-1.5ex]\n  &+ \\diagram{CCSD_t2/CCSD_t2-figure6} + \\diagram{CCSD_2b/CCSD_2b-figure64} + \\diagram{CCSD_2b/CCSD_2b-figure65} \\notag \\\\\n  \\xint{ab}{ij} = 0 &= \\vint{ab}{ij} + \\Perm{ab}\\sum\\limits_{\\mathclap{c}}\\xint{a}{c}\\tamp{cb}{ij} - \\Perm{ij}\\sum\\limits_{\\mathclap{k}}\\xint{k}{i}\\tamp{ab}{kj} \\notag \\\\\n  &+ \\frac{1}{2}\\sum\\limits_{\\mathclap{cd}}\\xxint{ab}{cd}\\tamp{cd}{ij} + \\frac{1}{2}\\sum\\limits_{\\mathclap{kl}}\\xint{kl}{ij}\\tamp{ab}{kl} - \\Perm{ab|ij}\\sum\\limits_{\\mathclap{kc}}\\xint{kb}{ic}\\tamp{ac}{kj}.\n\\end{align}\nThe components and intermediates of the CCSD effective Hamiltonian are much more complicated and are shown with their corresponding sums in appendix \\ref{chapter:eff_ham_diagrams}.\n\n\n\n\n\\section{Example: Homogeneous Electron Gas} \\label{section:electrongas}\n\nAnother relatively simple calculation using the CCD approximation is the homogeneous electron gas.  This example aims to calculate the ground state energy of a three-dimensional gas of electrons subject to Coulomb repulsion.  This is an approximate model of the valence electrons in a metal, subject to a uniform background of positive charge from the nuclei and core electrons \\cite{GROSS1991}.  As will be explained below, this calculation employs pure-momentum eigenstates such that $\\ph{1}{1}$ excitations from the reference state are forbidden by momentum conservation.  This means that the problem reduces to the doubles approximation.  To obtain realistic results, a sufficiently-sized basis with a sufficient number of electrons must be used.  Therefore, the improvements discussed in Section \\ref{section:solvingcc} are necessary to keep the computation time manageable as the system size increases.\n\nWith a uniform background potential, the electron gas can be constructed using eigenfunctions of the kinetic energy operator, $\\HamB{1} = \\Top = \\frac{-\\hbar^{2}}{2m}\\nabla^{2}$.  In an infinite volume, however, there are an unlistable number of plane wave modes which satisfy this condition due to the continuous nature of the linear momentum eigenstates.  Therefore, the single-particle orbits will be constructed in a finite box of volume $\\Omega$ and length $L$, and then the limit $L\\rightarrow \\infty$ can be taken after various expectation values have been computed,\n\\begin{gather} \\label{eq:plane_wave}\n  \\frac{-\\hbar^{2}}{2m}\\nabla^{2}\\phi_{\\mathbf{k}\\sigma}(\\mathbf{r}) = \\epsilon_{\\mathbf{k}}\\phi_{\\mathbf{k}\\sigma}(\\mathbf{r}), \\notag \\\\\n  \\phi_{\\mathbf{k}\\sigma}(\\mathbf{r}) = \\frac{1}{\\sqrt{\\Omega}}\\exp{(i\\mathbf{kr})}\\xi_{\\sigma},\n\\end{gather}\nwhere $m$ is the electron mass, $\\mathbf{k}$ is the wave number, and $\\xi_{\\sigma}$ is the spin function for either spin up or down electrons\n\\begin{equation}\n  \\xi_{\\sigma=+1/2} = \\left(\\begin{array}{c} 1\n    \\\\ 0 \\end{array}\\right) \\hspace{0.5cm}\n  \\xi_{\\sigma=-1/2} = \\left(\\begin{array}{c} 0 \\\\ 1 \\end{array}\\right).\n\\end{equation}\n\nAssuming the single-particle orbits follow periodic boundary conditions within the containing box ($\\phi(\\mathbf{r}_{i}) = \\phi(\\mathbf{r}_{i} + L)$ for $i = x,y,z$) the wave numbers are quantized,\n\\begin{equation}\n  k_{i} = \\frac{2\\pi n_{i}}{L}\\hspace{0.5cm} i = x,y,z \\hspace{0.5cm} n_{i} = 0, \\pm 1, \\pm 2, \\dots\n\\end{equation}\nA state can therefore be characterized by the quantum numbers $n_{x}$, $n_{x}$, and $n_{x}$ as well as the spin quantum number $\\sigma$.  The energy of such a state, independent of the spin, can be written as\n\\begin{equation} \\label{eq:infinite_energy}\n  \\epsilon_{n_{x}, n_{y}, n_{z}} = \\frac{\\hbar^2}{2m}\\left(k_{x}^{2} + k_{y}^{2} + k_{z}^{2}\\right) = \\frac{\\hbar^{2}}{2m}\\left(\\frac{2\\pi }{L}\\right)^{2} \\left( n_{x}^{2} + n_{y}^{2} + n_{z}^{2}\\right).\n\\end{equation}\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=\\linewidth]{CC/Infinite_Space.pdf}\n  \\caption{Visulization of the Fourier transform of a finite box.  This transformation characterizes the construction of the single-particle basis for infinite matter, mapping plane waves in coordinate space onto finitely-spaced points in momentum space.}\n  \\label{fig:infinite_space}\n\\end{figure}\n\nNow that the single-particle orbits are established, a particular basis consisting of these orbits can be chosen such that all states are included up to a closed shell.  This basis is then filled with electrons until a closed Fermi level is obtained.  Additionally, only the unpolarized case, in which all orbitals are occupied with one spin-up and one spin-down electron, will be considered here.  For this spherical-type level structure, the number of electrons required for closed shells increases quickly.  For example, the first six shells contain $2$, $14$, $38$, $54$, $66$ and $114$ states, respectively.\n\nA finite number of electrons $A$ in a finite box of volume $\\Omega$ naturally leads to the characterization of an infinite system by its number density density $\\rho = A/\\Omega$.  The average inter-electron distance, or \\textit{Wigner-Seitz radius}, is defined as\n\\begin{equation} \\label{wigner-seitz}\n  \\frac{4}{3}\\pi r_{s}^{3} = \\frac{1}{\\rho},\\hspace{0.5cm} r_{s} = \\left(\\frac{3}{4\\pi\\rho}\\right)^{1/3}.\n\\end{equation}\nIn practice, these calculations are defined by the total number of shells included in the basis, the number of electrons, and the Wigner-Seitz radius, usually given in units of the Bohr radius, $r_{b} = \\frac{\\hbar}{mc\\alpha}$, where $c$ is the speed of light and $\\alpha$ is the fine-structure constant.\n\nThe last ingredient to this many-body calculation is the interaction between the electrons, the well-known Coulomb force.  Using atomic units, where the elementary charge $e = 1$ and the Coulomb constant $\\frac{1}{4\\pi\\varepsilon_{0}} = 1$, this potential is simply\n\\begin{equation} \\label{eq:coulomb}\n  V\\left( \\mathbf{r}_{1}, \\mathbf{r}_{2}\\right) = \\frac{1}{\\lvert \\mathbf{r}_{1} - \\mathbf{r}_{2} \\rvert}.\n\\end{equation}\nAs mentioned in chapter \\ref{chapter:manybody}, this potential can be utilized in second-quantization by computing antisymmetrized integrals over the basis states.  In this case, the integrals have the form,\n\\begin{equation} \\label{eq:coloumb_integral}\n  \\Hint{2}{pq}{rs} \\equiv \\int d\\mathbf{r}_{1} d\\mathbf{r}_{2}\\  \\phi^{*}_{\\mathbf{k}_{p}\\sigma_{p}}(\\mathbf{r}_{1})\\phi^{*}_{\\mathbf{k}_{q}\\sigma_{q}}(\\mathbf{r}_{2}) \\frac{1}{\\lvert \\mathbf{r}_{1} - \\mathbf{r}_{2} \\rvert} \\left[\\phi_{\\mathbf{k}_{r}\\sigma_{r}}(\\mathbf{r}_{1})\\phi_{\\mathbf{k}_{s}\\sigma_{s}}(\\mathbf{r}_{2}) - \\phi_{\\mathbf{k}_{s}\\sigma_{s}}(\\mathbf{r}_{1})\\phi_{\\mathbf{k}_{r}\\sigma_{r}}(\\mathbf{r}_{2})\\right].\n\\end{equation}\nThe symmetries of the Coulomb potential guarantee that the total linear momentum and total spin projection are conserved such that,\n\\begin{equation} \\label{eq:coulomb-conserve}\n  \\mathbf{k}_{p} + \\mathbf{k}_{q} = \\mathbf{k}_{r} + \\mathbf{k}_{s} \\hspace{0.5cm} \\text{and} \\hspace{0.5cm} \\sigma_{p} + \\sigma_{q} = \\sigma_{r} + \\sigma_{s}.\n\\end{equation}\nThe integral is relatively simple given the form of the basis functions. The result is given in terms of the momentum transfer, $\\mathbf{q}_{1} = \\mathbf{k}_{p} - \\mathbf{k}_{r}$ and $\\mathbf{q}_{2} = \\mathbf{k}_{p} - \\mathbf{k}_{r}$,\n\\begin{equation} \\label{eq:coulomb-int}\n  \\Hint{2}{pq}{rs} = \\frac{4\\pi \\hbar c \\alpha}{\\Omega}\\left[ \\frac{\\delta_{\\sigma_{p}\\sigma_{r}}\\delta_{\\sigma_{q}\\sigma_{s}}}{\\lvert \\mathbf{q}_{1} \\rvert^{2}} - \\frac{\\delta_{\\sigma_{p}\\sigma_{s}}\\delta_{\\sigma_{q}\\sigma_{r}}}{\\lvert \\mathbf{q}_{2} \\rvert^{2}} \\right]\n\\end{equation}\n\nThe last preparation step before performing the coupled cluster algorithm is the Hartree-Fock transformation.  As with the pairing model, the single-particle orbitals are already eigenfunctions of the Fock operator, in this case because the translational invariance of the plane wave basis functions ensure that the HF terms of the form $\\Hint{2}{pi}{qi}$ vanish due to momentum conservation, see Eq.\\ \\eqref{eq:fock_operator}.  Therefore, the HF transformation consists simply of redefining the single-particle energies while the two-body interaction is left unchanged.\n\\begin{gather}\\label{eq:infinite_hf}\n  \\varepsilon_{p} = \\epsilon_{\\mathbf{k}_{p}} + \\sum_{i}\\Hint{2}{pi}{pi} \\notag \\\\\n  \\vint{pq}{rs} = \\Hint{2}{pq}{rs}\n\\end{gather}\n\nAs mentioned above, in the plane-wave basis, any single excitation from the reference state vanishes automatically due to momentum conservation so that $\\tamp{a}{i} = 0$.  Therefore, it's necessary to include only double excitations (before adding triples, etc.).  Therefore, calculations for the electron gas use the pseudo-linear form of the CCD equations \\eqref{eq:double_linear} and an effective Hamiltonian that excludes single excitations in Eqns.\\ \\eqref{eq:ccd_eff1}-\\eqref{eq:eff4}.  To explore the HEG equation-of-state, the total energy per electron can be calculated as a function of the Wigner-Seitz radius.\n\\begin{figure}[h]\n  \\includegraphics[width=\\linewidth]{CC/Electronic_Gas.pdf}\n  \\caption{CCD energy per electron in Hartrees for the 3D homogeneous electron gas as function of the Wigner-Seitz radius in units of Bohr radii. The calculation used periodic boundary conditions and a basis with 25 shells, resulting in a total of $1238$ single-particle states. Also plotted are the variational quantum Monte Carlo (VMC) results from \\cite{LOPEZ2006}.}  \n  \\label{fig:Electronic_Gas}\n\\end{figure}\nIn the limit $N,L \\rightarrow \\infty$, the plot in Fig.\\ \\ref{fig:Electronic_Gas} represents the equation-of-state for a 3D electron gas at absolute zero.  This curve can reveal many thermodynamic properties of the electron gas including the saturation density and saturation energy, which occur at the lowest point on the curve.  The CCD results are compared with the quasi-exact results from variational quantum Monte Carlo calculations from \\cite{LOPEZ2006}.  The discrepancies between the saturation energies from the two methods can be partially attributed to an insufficient basis size.  However, even an appropriate extrapolation to an infinite basis won't be able to recover all of the required correlations, which suggests that CCSDT might be necessary.  Regardless of the value to the saturation energy, these CCD results do qualitatively reproduce the saturation radius at $r_{s} \\approx 5.0$.\n\n\n\n\\section{Coupled Cluster for Finite Nuclei} \\label{section:cc_nuclei}\n\nThe main purpose of this work is to calculate properties of atomic nuclei with coupled cluster theory.  From a many-body perspective, the main process is computing the converged cluster amplitudes and thus the important correlations of the system.  These amplitudes comprise the CC similarity transformation, which is versatile for constructing any effective operator, such as the Hamiltonian, that can act on the correlated system.  Therefore, the first step in calculating beta-decay properties of nuclei is solving for the ground-state wave function of specific closed-shell nuclei.\n\n\n\\subsection{Harmonic Oscillator Basis} \\label{section:ho_basis}\nCalculations of finite nuclei follow the basic structure of the algorithms used for the pairing model and the homogeneous electron gas, but they also differ in some significant ways.  Like the other examples, the first step is to construct a proper single-particle basis and reference state.  Because the nuclear Hamiltonian conserves angular momentum and parity, it's useful to construct orbits that are eigenfunctions of these operators.  For a system with no external potential, like the electron gas, this suggests a basis made of plane waves.  However, plane waves do not represent the bound states of a nucleus very well.  This property can be satisfied by introducing a fictitious external potential that mimics the mean field from the collection of nucleons.  Some phenomenological potentials, like the Woods-Saxon potential, properly consider the resonance and continuum states of realistic nuclei in addition to the bound states.  Many-body techniques discussed in this work have been applied to model spaces that include all three types of single-particle states \\cite{MICHEL2006,HAGEN2007169} with some success.  However, for the many-body states considered in this work, it's sufficient to consider only bound single-particle states.  Therefore, the nuclear basis will be constructed from the isotropic harmonic oscillator,\n\\begin{equation}\n  V\\left(r\\right) = \\frac{1}{2}m\\omega^{2}r^{2}.\n\\end{equation}\n\nAn eigenstate of the harmonic oscillator potential is defined by its principal quantum number $n$ and its orbital angular momentum quantum number $l$, which is denoted by the letters s, p, d, f... for the values $l=0,1,2,3...$ respectively.  Because of spin-orbit terms in the nuclear Hamiltonian, the orbital angular momentum is coupled to a particle spin to a total angular momentum of $j = \\lvert \\mathbf{l} + \\mathbf{s} \\rvert$, which results in a degeneracy of $2j + 1$ for each orbit.  This basis does not provide any simplification to eliminate single excitations, so CCSD will be used for all the following calculations.  A schematic version of this single-particle basis is shown in Fig.\\ \\ref{fig:Harmonic_Oscillator}.  The shell structure of this basis is characterized by the energy quantum numbers, $e = 2n + l$, of the HO single-particle spectrum.  This can be used to define the maximum-energy shell and the size of a HO basis with the parameter $e_{\\mathrm{max}}$.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.6\\linewidth]{CC/HO.pdf}\n  \\caption{A schematic illustration of the harmonic oscillator basis used for calculations of nuclei. Shown is an example of a initial reference state for carbon-14, with 6 protons filled to the p$3/2$-subshell closure and 8 neutrons filled to the p$1/2$-shell closure.  See text for details on the single-particle states.}\n  \\label{fig:Harmonic_Oscillator}\n\\end{figure}\n\nOne issue with this construction, is that while the single-particle orbits are eigenstates of the angular momentum operator and localized to the external potential, they are not translationally invariant, which is required by the nuclear Hamiltonian.  This means that there is a fictitious center-of-mass kinetic energy which must be removed from the Hamiltonian.  The COM kinetic energy can be written as the sum of one- and two-body pieces,\n\\begin{equation}\n  \\Top_{\\mathrm{cm}} = \\frac{\\mathbf{P}_{\\mathrm{cm}}}{2mA} = \\sum^{A}_{pq}\\frac{\\mathbf{p}_{p}\\cdot\\mathbf{p}_{q}}{2mA} = \\sum^{A}_{p}\\frac{\\mathbf{p}^{2}_{p}}{2mA} + \\sum^{A}_{p<q}\\frac{\\mathbf{p}_{p}\\cdot\\mathbf{p}_{q}}{mA}.\n\\end{equation}\nThe one-body piece is just a scaled form of the original kinetic energy operator, and the two-body piece is given in a similar form to the original two-body Hamiltonian.  Both can be integrated into matrix elements like Eq.\\ \\eqref{eq:braket_integration},\n\\begin{gather} \\label{eq:ke_integration}\n    \\KEint{1}{p}{q} \\equiv \\int d\\mathbf{r}_{1}\\  \\phi^{*}_{p}\\left(\\mathbf{r}_{1}\\right) \\frac{\\mathbf{p}^{2}_{1}}{2mA} \\phi_{q}\\left(\\mathbf{r}_{1}\\right), \\notag \\\\\n    \\KEint{2}{pq}{rs} \\equiv \\int d\\mathbf{r}_{1} d\\mathbf{r}_{2}\\  \\phi^{*}_{p}\\left(\\mathbf{r}_{1}\\right)\\phi^{*}_{q}\\left(\\mathbf{r}_{2}\\right) \\frac{\\mathbf{p}_{1}\\cdot\\mathbf{p}_{2}}{mA} \\left[\\phi_{r}\\left(\\mathbf{r}_{1}\\right)\\phi_{s}\\left(\\mathbf{r}_{2}\\right) - \\phi_{s}\\left(\\mathbf{r}_{1}\\right)\\phi_{r}\\left(\\mathbf{r}_{2}\\right)\\right].\n\\end{gather}\nSubtracting the COM kinetic energy results in the \\textit{intrinsic} Hamiltonian for finite nuclear systems,\n\\begin{align} \\label{eq:intrinsic_hamiltonian}\n  \\Ham_{\\mathrm{in}} = \\left(1 - \\frac{1}{A}\\right)\\sum_{\\mathclap{pq}}\\KEint{1}{p}{q}\\ \\co{p}\\ao{q} &+ \\frac{1}{4}\\sum_{\\mathclap{pqrs}}\\left(\\Hint{2}{pq}{rs} - \\KEint{2}{pq}{rs}\\right)\\ \\co{p}\\co{q}\\ao{s}\\ao{r} \\notag \\\\\n  &+ \\frac{1}{36}\\sum_{\\mathclap{pqrstu}}\\Hint{3}{pqr}{stu}\\ \\co{p}\\co{q}\\co{r}\\ao{u}\\ao{t}\\ao{s} + \\cdots,\n\\end{align}\nThis form of the bare Hamiltonian (up to the three-body force) is used in the Hartree-Fock transformation.  Then, after normal-ordering, the three-body piece is discarded, which is referred to as a NN+3N-induced interaction.  The use of a localized external potential has further complications involving the COM wave function that are discussed in section \\ref{section:CoM}.\n\nA special property of this single-particle basis that can be exploited to reduce the computational complexity of the problem is the degeneracy of each orbital, due to the angular momentum projection of each single-particle state, $m_{j} = \\{ -j, -j+1, \\cdots , j-1, j \\}$.  According to the Wigner-Eckart theorem \\cite{WIGNER1959,ECKART1930}, the geometrical component of a wave function, dependent on its projection $m_{j}$, can be isolated as a Clebsch-Gordon coefficient.  Because these coefficients have compact summation rules, any diagram and corresponding sum can be written in terms of the $j$-orbitals instead of the single-particle $m_{j}$ states, commonly known as $J$-scheme and $M$-scheme, respectively.  Calculations in $J$-scheme require complicated angular momentum coupling, detailed in appendix \\ref{chapter:angular_momentum}, but involve roughly an order of magnitude fewer states compared with an $M$-scheme calculation in the same model space.\n\n\n\\subsection{The Nuclear Interaction} \\label{section:nuclear_interaction}\n\nPerhaps the most important component in nuclear structure calculations, and also perhaps the most easily overlooked component from a many-body perspective, is the nuclear Hamiltonian.  Further complicated by the composite nature of protons and neutrons, bound by gluon exchange within the nucleon, the inter-nucleon interaction is a residual force of virtual pion exchanges and other, more exotic processes.  Early \\emph{ab initio} calculations avoided this complexity by using phenomenological interactions, tuned to reproduce certain properties of a nucleus.  These phenomenological forces were effectively used for calculations using shell-model CI and density-functional theory, but were restricted by the conditions of the fitted parameters.\n\nThese problems, along with the success of quantum field theories in high-energy physics, motivated the effort to describe the inter-nucleon interaction in terms of the underlying theory of the strong force, quantum chromodynamics (QCD) \\cite{HATSUDA1994221,LEPAGE1980}.  However, while calculations of nuclei in terms of their constituent quarks using lattice QCD have made some progress with increases in computing power, they have been confined to few nucleon systems \\cite{BEANE2012}.  The problem is finding a way to express the high-energy QCD interactions as low-energy forces between nucleons.  Such a problem, containing two vastly different scales, can be rewritten as an effective theory.\n\n\\begin{figure}[h]\n  \\centering\n  \\fbox{\\includegraphics[width=0.7\\linewidth]{CC/chiralforces.pdf}}\n  \\caption{Diagrammatic form of the chiral EFT expansion up to N$^{3}$LO.  The solid lines represent nucleons and the dashed lines represent pions.  The different vertices represent higher-order interactions.  Figure taken from  \\cite{MACHLEIDT2016}.}  \n  \\label{fig:Chiral_Forces}\n\\end{figure}\n\nChiral effective field theory ($\\chi$EFT), which exploits the large difference in scales between the low-energy regime of nuclear physics and the high-energy regime of QCD, is built from a general Lagrangian consistent with the broken chiral symmetry of QCD \\cite{EPELBAUM20091773,MACHLEIDT2016}.  This broken symmetry, a consequence of non-zero quark masses, results in several hadronic structures including protons, neutrons, and mesons, the lightest of which is the pion, $m_{\\pi}\\approx 140\\mathrm{MeV}/c^{2}$ \\cite{BERINGER2012}.  This can be exploited by systematically writing a Lagrangian as the sum of pion exchanges of increasing order.  Additional contact interactions, which represent exchanges of heavier mesons, are also included and must be fit to low-energy nuclear data.  The hierarchy of $\\chi$EFT terms, which contain 3N and higher many-body forces, are ordered by power counting the expansion term $(m_{\\pi}/\\Lambda)$, where $\\Lambda$ is an energy cutoff between the low- and high-energy scales, and is shown up to N$^{3}$LO in Fig.\\ \\ref{fig:Chiral_Forces}.\n\nThis work exclusively employs the NN force of the N$^{3}$LO interaction from Entem and Machleidt with a cutoff of $\\Lambda=500\\ \\mathrm{MeV}$ \\cite{ENTEM2003}.  For most calculations, this interaction is coupled with the N$^{2}$LO 3N interaction from Navr\\'{a}til with a cutoff of $\\Lambda=400\\ \\mathrm{MeV}$ \\cite{NAVRATIL2007}.  This NN+3N(400) interaction is successful at reproducing low- and medium-mass nuclei, but begins to overbind beyond the $sd$-shell.  As mentioned in the introduction, these bare Hamiltonians exhibit strong repulsion at short ranges among high-momentum states.  Therefore to soften the interaction, the similarity renormalization group method is used to integrate high-momentum modes out of the interaction while preserving observables \\cite{BOGNER201094,ROTH2011072501}.\n\n\n\\subsection{Ground-State Results for Nuclei} \\label{section:nuclear_results}\n\nThe main object of this section is to demonstrate the validity of all the ingredients which have been discussed so far: the harmonic oscillator basis, the NN+3N(400) chiral interaction, and the $J$-scheme CCSD algorithm.  To accomplish this, calculations for different nuclei will be compared to the corresponding experimental values.  Additionally, results for different input parameters will be presented to verify that the observables are independent of non-physical variables.  Once again, all results are computed with a HF-optimized basis, see section \\ref{section:hartree-fock}.\n\nFirst, the ground-state energies should be independent of the SRG cutoff parameter $\\lambda_{\\mathrm{SRG}}$.  While the SRG evolution should preserve any observables, the renormalization process induces 3N and higher-body forces which can be missed by truncations of the many-body method in both the cluster amplitudes and the Hamiltonian.  The trade-off here is that larger cutoff parameters produce interactions that contain higher-momentum components, which reduce a system's convergence properties, but induce fewer many-body forces, so that systems can be accurately described with fewer correlations.  Conversely, a smaller cutoff parameter means that solutions can be more easily converged, but it also requires a many-body method that includes more correlations or higher-order forces \\cite{ROTH2012}.  To show this effect, the ground state for oxygen-16 is shown for different cutoff parameters and for both the NN and NN+3N-induced interactions.  \n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{CC/ground_state_srg.pdf}\n  \\caption{Ground-state energies for ${}^{16}$O for the EM N$^{3}$LO NN only interaction and with the added 3N interaction from Navr\\'{a}til, both SRG softened with $\\lambda_{\\mathrm{SRG}}=1.88,2.24\\ \\mathrm{fm}^{-1}$.  The energies are plotted for $e_\\mathrm{max}=10,12$.  The most obvious difference is between the NN and NN+3N calculations, showing the importance of including 3N forces.  The differences between the cutoff parameters are resolved within $\\sim 1\\%$ with the inclusion of 3N forces and can be rectified further by including additional correlations or full 3N forces.  The experimental binding energy is shown with the grey dashed line.}\n  \\label{fig:Ground_State_srg}\n\\end{figure}\nAccounting for both the small dependence on the SRG cutoff parameter and the minor inaccuracies from the truncations made to the cluster operator and the Hamiltonian, the rest of this work will use the NN+3N(400)-induced interaction with an SRG cutoff parameter of $\\lambda_{\\mathrm{SRG}}=2.0\\ \\mathrm{fm}^{-1}$.\n\nNext, any nuclear observables calculated with this framework should be independent of the fictitious confining potential.  This can be verified by showing the ground-state energies of various nuclei as a function of the underlying harmonic oscillator energy, $\\hbar\\omega$.  Convergence is reached by increasing the size of the model space until the resulting curve is flat.  Figure\\ \\ref{fig:Ground_State1} shows the convergence for the \\textit{doubly-magic}, $N=Z$ nuclei, ${}^{4}$He, ${}^{16}$O, ${}^{20}$Ca, and ${}^{56}$Ni, where both protons and neutrons fill the same major shell closure.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{CC/ground_state1.pdf}\n  \\caption{Ground-state energies for doubly magic nuclei as a function of the harmonic oscillator energy $\\hbar\\omega$ with the NN+3N(400) interaction, SRG softened with $\\lambda_{\\mathrm{SRG}}=2\\mathrm{fm}^{-1}$.  The energies are plotted for $e_\\mathrm{max}=8,10,12$, showing the convergence as the model space increases.  The results are independent of the underlying oscillator frequency to $\\sim 1\\%$ for $e_\\mathrm{max}=12$.  The grey dashed line is the experimental binding energy.  The overbinding of this interaction becomes apparent as the system size increases.}\n  \\label{fig:Ground_State1}\n\\end{figure}\nAll the results converge to a variance of $<1\\%$ at $e_{\\mathrm{max}}=12$ for intermediate values of $\\hbar\\omega$.  While a larger model space is always desirable, this level of variance justifies the use of $e_{\\mathrm{max}}=12$ for post-CC calculations.  Additionally, these results show the limitations of the NN+3N(400) interaction, as overbinding increases with the system size, where the ground-state energies of ${}^{20}$Ca and ${}^{56}$Ni differ from their experimental binding energies by $\\sim 8\\%$ and $\\sim 13\\%$, respectively.\n\nThe ground-state results are also shown for singly-magic nuclei, where either the protons or neutrons fill a sub-shell closure.  This has the potential complication of a vanishing energy gap between the hole and particle states, like the picture in Fig.\\ \\ref{fig:Harmonic_Oscillator}, which causes undefined behavior in the CC algorithm (see section \\ref{section:solvingcc}).  However, the subshell orbitals repel each other when transformed during the Hartree-Fock algorithm \\cite{LEVIT1999}, so these systems are valid in some cases.  The ground-state energies for ${}^{14}$C, ${}^{22}$O, and ${}^{34}$Si are plotted as a function of the underlying oscillator potential in Fig.\\ \\ref{fig:Ground_State2}.  The smaller energy gap involved in these systems results in stronger excitations missed by the CCSD approximation, causing further deviations from the experimental values.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\linewidth]{CC/ground_state2.pdf}\n  \\caption{Ground-state energies for singly magic nuclei as a function of the harmonic oscillator energy $\\hbar\\omega$ with the NN+3N(400) interaction, SRG softened with $\\lambda_{\\mathrm{SRG}}=2\\mathrm{fm}^{-1}$.  The energies are plotted for different $e_\\mathrm{max}$.  The results are independent of the underlying oscillator frequency to $\\sim 1\\%$ for $e_\\mathrm{max}=12$.  The grey dashed line is the experimental binding energy.  These results underbind with respect to their doubly-magic counterparts in Fig.\\ \\ref{fig:Ground_State1}.}\n  \\label{fig:Ground_State2}\n\\end{figure}\n\n\\section{Ground-State Center-of-Mass Factorization} \\label{section:CoM}\nWhile an intrinsic Hamiltonian can be built by removing the center-of-mass (COM) kinetic energy, Eq.\\ \\eqref{eq:intrinsic_hamiltonian}, there is still an inconsistency between the translational invariance of the underlying harmonic oscillator basis and translationally-invariant nuclear many-body states \\cite{LIPKIN1958,GLOECKNER1974313}.  This inconsistency can materialize in certain calculations in the form of spurious, non-physical states.\n\nOf course, this problem can be avoided by using more complicated basis states that obey translational invariance, such as the use of Jacobi coordinates, but such methods are limited to few-body problems \\cite{BISHOP19901341,NOGGA2002054003}.  Another possible solution is to use the harmonic oscillator basis in an untruncated space of Slater determinants up to a certain harmonic oscillator shell.  Known as the $N_{\\mathrm{max}}$ space, this treatment can be successfully applied within no-core shell model calculations \\cite{NAVRATIL2009083101}. However, the factorial scaling of this method restricts its use to light nuclei.  It can be shown that in the $N_{\\mathrm{max}}$ space, the eigenstates of the intrisic Hamiltonian are also eigenstates of the COM Hamiltonian, and any state perfectly factorizes into a COM component and a translationally-invariant, intrinsic component,\n\\begin{equation} \\label{eq:com_factorize}\n  \\corrket = \\ket{\\Corr_{\\mathrm{in}}}\\ket{\\Corr_{\\mathrm{cm}}}.\n\\end{equation}\n\nThis factorization results in a compound energy spectrum, where the intrinsic component of the spectrum is degenerate for each COM excitation.  Therefore, the intrinsic spectrum can be recovered by offsetting the COM Hamiltonian by the corresponding excitation energies, such that the COM energies vanish, $E_{\\mathrm{cm}} = 0$.  However, with truncated methods like CCSD, this factorization is not guaranteed, and COM energies, no longer eigenenergies of the COM Hamiltonian, can take on values $E_{\\mathrm{cm}} \\neq 0$.  In this case, the intrinsic spectrum is contaminated with nonphysical, \\textit{spurious} states.\n\nBecause the specific form is irrelevant \\cite{VINCENT2973}, the shifted COM Hamiltonian can be assumed to take the form of a harmonic trap with a oscillator strength of $\\hbar\\widetilde{\\omega}$, not necessarily equal to the oscillator strength of the underlying basis $\\hbar\\widetilde{\\omega}$,\n\\begin{equation} \\label{eq:com_hamiltonian}\n  \\Ham_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right) = \\frac{\\mathbf{P}_{\\mathrm{cm}}}{2mA} + \\frac{1}{2}mA\\widetilde{\\omega}^{2}\\mathbf{R}_{\\mathrm{cm}} - \\frac{3}{2}\\hbar\\widetilde{\\omega},\n\\end{equation}\noffset by the ground-state energy, $\\frac{3}{2}\\hbar\\widetilde{\\omega}$.  In the $N_{\\mathrm{max}}$ space, the factorization in Eq.\\ \\eqref{eq:com_factorize} occurs regardless of $\\hbar\\widetilde{\\omega}$, while in truncated methods like CCSD, the COM oscillator strength is a free parameter which can be used to probe the level of COM contamination.  If a frequency exists such that $E_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right) \\approx 0$, then the wave function is approximately factorized, and the COM wave function is in its ground state \\cite{HAGEN2009062503,JANSEN2013}.\n\nThe COM energy, $E_{\\mathrm{cm}}$, can be calculated by using a version of the Hellmann-Feynman theorem by adding the COM Hamiltonian as a perturbation and computing the difference quotient \\cite{DIERCKSEN198129,ERNZERHOF199359},\n\\begin{equation} \\label{eq:com_energy}\n  E_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right) \\equiv \\element{\\Corr}{\\Ham_{\\mathrm{cm}}}{\\Corr} \\approx \\frac{1}{2\\delta}\\left(\\element{\\Corr}{\\Ham + \\delta\\Ham_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right)}{\\Corr} - \\element{\\Corr}{\\Ham - \\delta\\Ham_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right)}{\\Corr}\\right).\n\\end{equation}\nBecause the operator $\\mathbf{R}_{\\mathrm{cm}}$ depends only on the underlying single-particle basis regardless of the COM oscillator frequency, it can be rewritten in terms of $\\Ham_{\\mathrm{cm}}$ to find the relationship between $\\omega$ and $\\widetilde{\\omega}$,\n\\begin{equation}\n  \\frac{1}{\\widetilde{\\omega}^{2}}\\left(\\Ham_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right) - \\Top_{\\mathrm{cm}} + \\frac{3}{2}\\hbar\\widetilde{\\omega}\\right) = \\frac{1}{\\omega^{2}}\\left(\\Ham_{\\mathrm{cm}}\\left(\\omega\\right) - \\Top_{\\mathrm{cm}} + \\frac{3}{2}\\hbar\\omega\\right).\n\\end{equation}\nUsing the known value $\\element{\\Corr}{\\Top_{\\mathrm{cm}}}{\\Corr} = \\frac{3}{4}\\hbar\\widetilde{\\omega}$ and the requirement that $E_{\\mathrm{cm}}\\left(\\widetilde{\\omega}\\right)=0$ gives the following relation that relates the COM oscillator frequency to the underlying basis frequency,\n\\begin{equation} \\label{eq:com_hw}\n  \\hbar\\widetilde{\\omega} = \\hbar\\omega + \\frac{2}{3}E_{\\mathrm{cm}}\\left(\\omega\\right) \\pm \\sqrt{\\left(\\frac{2}{3}E_{\\mathrm{cm}}\\left(\\omega\\right)\\right)^{2} + \\frac{4}{3}\\hbar\\omega E_{\\mathrm{cm}}\\left(\\omega\\right)}.\n\\end{equation}\n\nThe ground-state COM energies are plotted for ${}^{16}$O and ${}^{40}$Ca using the COM Hamiltonian with two different oscillator strengths in Fig.\\ \\ref{fig:CoM_Ground_State}: that of the underlying basis, $\\hbar\\omega$, and one of the two solutions to Eq.\\ \\eqref{eq:com_hw}, $\\hbar\\widetilde{\\omega}_{\\pm}$.  Of the two $\\hbar\\widetilde{\\omega}_{\\pm}$, which are shown as the solutions to Eq.\\ \\eqref{eq:com_hw} in the inset, one typically results in a large COM energy while the other vanishes, which is plotted.  Because the COM energies approximately vanish regardless of the underlying basis frequency, the COM wave function is in its ground state and approximately factorized from the intrinsic nuclear wave function.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=\\textwidth]{CC/CoM1.pdf}\n  \\caption{Ground-state COM energies, Eq.\\ \\eqref{eq:com_hamiltonian}, for ${}^{16}$O and ${}^{40}$Ca at various harmonic oscillator frequencies with the NN+3N(400)-induced interaction with $\\lambda_{\\mathrm{SRG}}=2.0\\ \\mathrm{fm}^{-1}$ at $e_{\\mathrm{max}}=12$.  Using the proper COM oscillator frequencies shows the approximate factorization of Eq.\\ \\eqref{eq:com_factorize}.}\n  \\label{fig:CoM_Ground_State}\n\\end{figure}\n\nUnfortunately, when intrinsic states are coupled to COM excited-states, they can contaminate the spectrum of intrinsic states that are coupled to the COM ground-state.  These spurious states can be essentially removed from the ground-state spectrum with the Lawson-Gloeckner method \\cite{GLOECKNER1974313}.  When the proper COM oscillator strength is chosen such that the COM ground-state energy vanishes, the COM Hamiltonian can be added to the intrinsic Hamiltonian at an arbitrarily large scale, $\\beta$, without changing the ground-state spectrum,\n\\begin{equation} \\label{eq:lawson-term}\n  \\Ham_{\\mathrm{in}} \\rightarrow \\Ham_{\\mathrm{in}} + \\beta\\Ham_{\\mathrm{cm}}.\n\\end{equation}\nWhen $\\beta$ is arbitrarily large, eigenenergies of intrinsic states coupled to COM excited states will increase by the COM energy quanta, $\\beta\\hbar\\widetilde{\\omega}$, such that they are removed from the range of low-lying states of interest.  The method will be used to remove spurious states from the spectra of open-shell states in section \\ref{chapter:eom}.\n  \n\\end{document}\n", "meta": {"hexsha": "d84beae04914e00e6bfaafac430178910e737a88", "size": 76510, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CC.tex", "max_stars_repo_name": "novarios/Thesis", "max_stars_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CC.tex", "max_issues_repo_name": "novarios/Thesis", "max_issues_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CC.tex", "max_forks_repo_name": "novarios/Thesis", "max_forks_repo_head_hexsha": "55feaec71ec2de255c6df52df5229ddaca10790a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 140.6433823529, "max_line_length": 1336, "alphanum_fraction": 0.7424258267, "num_tokens": 23093, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4259392753865028}}
{"text": "\\epigraph{I went to the Math Olympiad Summer Program (MOP) after my tenth grade year. The first classes started with Professor Rousseau writing ‘Counting’ on the board. \\textit{Good}, I thought. \\textit{I can count . . . } Within ten minutes I was thoroughly lost.}{--- Richard Rusczyk}\n\\input{Ch7/intro}\n\n\\section{The Principle of Multiplication}\n\\input{Ch7/p_mult}\n\n\\section{Permutations}\n\\input{Ch7/permutation}\n\n\\section{Combinations and the Principle of Division}\n\\input{Ch7/combination}", "meta": {"hexsha": "1f9036b94b08bba2d6bea0d3cd7ed4de0205d1d2", "size": 492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch7/main.tex", "max_stars_repo_name": "jonlin1000/discr_math", "max_stars_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-22T03:31:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-14T02:26:40.000Z", "max_issues_repo_path": "Ch7/main.tex", "max_issues_repo_name": "jonlin1000/discr_math", "max_issues_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch7/main.tex", "max_forks_repo_name": "jonlin1000/discr_math", "max_forks_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.7272727273, "max_line_length": 286, "alphanum_fraction": 0.7703252033, "num_tokens": 134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754371026368, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4259392684803545}}
{"text": "\\chapter{STR solutions}\n\\begin{abox}\n\tPractice set 1 solutions\n\t\\end{abox}\n\\begin{enumerate}\n\t\\item Consider the decay process $\\tau^{-} \\rightarrow \\pi^{-}+v_{\\tau}$ in the rest frame of the $\\tau^{-} .$The masses of the $\\tau^{-}, \\pi^{-}$and $v_{\\tau}$ are $M_{\\tau}, M_{\\pi}$ and zero respectively.\\\\\n\t\\textbf{A} The energy of $\\pi^{-}$is\n\t{\\exyear{NET JUNE 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\left(M_{\\tau}^{2}-M_{\\pi}^{2}\\right) c^{2}}{2 M_{\\tau}}$\n\t\\task[\\textbf{B.}]$\\frac{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right) c^{2}}{2 M_{\\tau}}$\n\t\\task[\\textbf{C.}]$\\left(M_{\\tau}-M_{\\pi}\\right) c^{2}$\n\t\\task[\\textbf{D.}]$\\sqrt{M_{\\tau} M_{\\pi}} c^{2}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\intertext { From conservation of energy }\n\t M_{\\tau} c^{2}&=E_{\\pi}+E_{v} \\text {. }\\\\\n\tE_{\\pi}^{2}&=p^{2} c^{2}+M_{\\pi}^{2} c^{4} \\text { and } E_{v}^{2}=p^{2} c^{2} \\text { since momentum of } \\pi^{-} \\text {and } v_{\\tau} \\text { is same. }\\\\\n\tM_{\\tau} c^{2}&=E_{\\pi}+E_{v}, M_{\\pi}^{2} c^{4}=E_{\\pi}^{2}-E_{v}^{2} \\Rightarrow E_{\\pi}-E_{v}=\\frac{M_{\\pi}^{2} c^{4}}{M_{\\tau} c^{2}}\\\\\n\tE_{\\pi}-E_{v}&=\\frac{M_{\\pi}^{2} c^{2}}{M_{\\tau}} \\text { and } E_{\\pi}+E_{v}=M_{\\tau} c^{2} \\Rightarrow E_{\\pi}=\\frac{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right) c^{2}}{2 M_{\\tau}}\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\\textbf{B} The velocity of  $\\pi^{-} \\text {is }$\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] $\\frac{\\left(M_{\\tau}^{2}-M_{\\pi}^{2}\\right) c}{M_{\\tau}^{2}+M_{\\pi}^{2}}$\n\t\\task[\\textbf{B.}]$\\frac{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right) c}{M_{\\tau}^{2}-M_{\\pi}^{2}}$ \n\t\\task[\\textbf{C.}] $\\frac{M_{\\pi} c}{M_{\\tau}}$\n\t\\task[\\textbf{D.}]$\\frac{M_{\\tau} c}{M_{\\pi}}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n\\text { Velocity of } \\pi^{-} \\quad E_{\\pi}&=\\frac{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right) c^{2}}{2 M_{\\tau}}=\\frac{M_{\\pi} c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}} \\Rightarrow\\left(1-\\frac{v^{2}}{c^{2}}\\right)=\\frac{4 M_{\\pi}^{2} M_{\\tau}^{2}}{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right)^{2}}\\\\\n\\Rightarrow \\frac{v^{2}}{c^{2}}&=1-\\frac{4 M_{\\pi}^{2} M_{\\tau}^{2}}{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right)^{2}}\\\\\n\\frac{v^{2}}{c^{2}}&=\\frac{M_{\\tau}^{4}+M_{\\pi}^{4}+2 M_{\\tau}^{2} M_{\\pi}^{2}-4 M_{\\pi}^{2} M_{\\tau}^{2}}{\\left(M_{\\tau}^{2}+M_{\\pi}^{2}\\right)^{2}}\\\\\nv&=\\left(\\frac{M_{\\tau}^{2}-M_{\\pi}^{2}}{M_{\\tau}^{2}+M_{\\pi}^{2}}\\right) c\n\\end{align*}\nThe correct option is \\textbf{(a)}\t\n\\end{answer}\n\n\t\\item A constant force $F$ is applied to a relativistic particle of rest mass $m$. If the particle starts from rest at $t=0$, its speed after a time $t$ is\n\t{\\exyear{NET DEC 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\mathrm{Ft} / \\mathrm{m}$\n\t\\task[\\textbf{B.}]$c \\tanh \\left(\\frac{F t}{m c}\\right)$\n\t\\task[\\textbf{C.}]$c\\left(1-e^{-F t / m c}\\right)$\n\t\\task[\\textbf{D.}]$\\frac{F c t}{\\sqrt{F^{2} t^{2}+m^{2} c^{2}}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\frac{d p}{d t}&=F \\Rightarrow p=F t+c . \\text { At } t=0, p=0 \\text { so, } c=0\\\\\n\tp&=F t \\Rightarrow \\frac{m u}{\\sqrt{1-\\frac{u^{2}}{c^{2}}}}\\\\\n\tu&=\\frac{\\left(\\frac{F}{m}\\right) t}{\\sqrt{1+\\left(\\frac{F t}{m c}\\right)^{2}}}=\\frac{F c t}{\\sqrt{F^{2} t^{2}+m^{2} c^{2}}}\\\\\n\t\\end{align*}\n\tThe correct option is \\textbf{(d)}\n\\end{answer}\n\n\t\\item Two events separated by a (spatial) distance $9 \\times 10^{9} \\mathrm{~m}$, are simultaneous in one inertial frame. The time interval between these two events in a frame moving with a constant speed $0.8 c$ (where the speed of light $c=3 \\times 10^{8} \\mathrm{~m} / \\mathrm{s}$ ) is\n\t{\\exyear{NET JUNE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $60 \\mathrm{~s}$\n\t\\task[\\textbf{B.}]$40 \\mathrm{~s}$\n\t\\task[\\textbf{C.}]$20 s$\n\t\\task[\\textbf{D.}] $0 s$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tx_{2}^{\\prime}-x_{1}^{\\prime}&=9 \\times 10^{9} m \\text { and } t_{2}^{\\prime}-t_{1}^{\\prime}=0 . \\text { Then }\\\\\n\tt_{2}-t_{1}&=\\left(\\frac{t_{2}^{\\prime}+\\frac{v}{c^{2}} x_{2}^{\\prime}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)-\\left(\\frac{t_{1}^{1}+\\frac{v}{c^{2}} x_{1}^{\\prime}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)\\\\\n\tt_{2}-t_{1}&=\\frac{t_{2}^{\\prime}-t_{1}^{\\prime}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+\\frac{v}{c^{2}} \\frac{\\left(x_{2}^{\\prime}-x_{1}^{\\prime}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=\\frac{v}{c^{2}} \\frac{\\left(x_{2}^{\\prime}-x_{1}^{\\prime}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n\t\\text { Put } v&=0.8 c \\quad \\Rightarrow t_{2}-t_{1} \\cong 40 \\mathrm{sec}\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\n\t\\item What is proper time interval between the occurrence of two events if in one inertial frame events are separated by $7.5 \\times 10^{8} \\mathrm{~m}$ and occur $6.5 \\mathrm{~s}$ apart?\n\t{\\exyear{NET JUNE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $6.50 \\mathrm{~s}$\n\t\\task[\\textbf{B.}]$6.00 \\mathrm{~s}$\n\t\\task[\\textbf{C.}]$5.75 \\mathrm{~s}$\n\t\\task[\\textbf{D.}]$5.00 \\mathrm{~s}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\text{Proper time interval}\n\t\\Delta t=\\sqrt{\\left(\\Delta t^{\\prime}\\right)^{2}-\\frac{r^{2}}{c^{2}}}=\\sqrt{(6.5)^{2}-\\left(\\frac{7.5}{3}\\right)^{2}}=6 \\text { sec. }\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item The muon has mass $105 \\mathrm{MeV} / \\mathrm{c}^{2}$ and mean life time $2.2 \\mu \\mathrm{s}$ in its rest frame. The mean distance traversed by a muon of energy $315 \\mathrm{MeV}$ before decaying is approximately,\n\t{\\exyear{NET DEC 2012}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $3 \\times 10^{5} \\mathrm{~km}$ \n\t\\task[\\textbf{B.}]$2.2 \\mathrm{~cm}$\n\t\\task[\\textbf{C.}]$6.6 \\mu \\mathrm{m}$\n\t\\task[\\textbf{D.}]$1.98 \\mathrm{~km}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\text { Since } E&=315 \\mathrm{MeV} \\text { and } m_{0}=105 \\frac{\\mathrm{MeV}}{c^{2}} \\text {. }\\\\\n\tE=m c^{2} \\Rightarrow E&=\\frac{m_{0} c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}} \\Rightarrow 315\t\\\\\n\t315&=\\frac{105}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}} \\Rightarrow v=0.94 c\\\\\n\t\\text{Now}, t&=\\frac{t_{0}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n\tt_{0}&=2.2 \\mu s \\Rightarrow t=\\frac{2.2 \\times 10^{-6}}{\\sqrt{1-\\frac{8}{9}}} \\Rightarrow t=6.6 \\mu s\\\\\n\t\\text { Now the distance traversed by muon is } v t&=0.94 c \\times 6.6 \\times 10^{-6}=1.86 \\mathrm{~km} \\text {. }\n\t\\end{align*}\n\tThe correct option is \\textbf{(d)}\n\\end{answer}\n\t\\item The area of a disc in its rest frame $S$ is equal to 1 (in some units). The disc will appear distorted to an observer $O$ moving with a speed $u$ with respect to $S$ along the plane of the disc. The area of the disc measured in the rest frame of the observer $O$ is $(c$ is the speed of light in vacuum)\n\t{\\exyear{NET JUNE 2013}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\left(1-\\frac{u^{2}}{c^{2}}\\right)^{1 / 2}$\n\t\\task[\\textbf{B.}]$\\left(1-\\frac{u^{2}}{c^{2}}\\right)^{-1 / 2}$\n\t\\task[\\textbf{C.}]$\\left(1-\\frac{u^{2}}{c^{2}}\\right)$\n\t\\task[\\textbf{D.}]$\\left(1-\\frac{u^{2}}{c^{2}}\\right)^{-1}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n&\\text { Area of disc from } \\mathrm{S} \\text { frame is } 1 \\text { i.e. } \\pi a^{2}=1 \\text { or } \\pi a \\cdot a=1\\\\\n&\\text { Area of disc from } S^{\\prime} \\text { frame is } \\pi a \\cdot b=\\pi a \\cdot a \\sqrt{1-\\frac{u^{2}}{c^{2}}}=1 \\cdot \\sqrt{1-\\frac{u^{2}}{c^{2}}}=\\sqrt{1-\\frac{u^{2}}{c^{2}}}\\\\\n&\\text { where } b=a \\sqrt{1-\\frac{u^{2}}{c^{2}}}\n\\end{align*}\nThe correct option is \\textbf{(a)}\t\n\\end{answer}\n\n\t\\item The recently-discovered Higgs boson at the LHC experiment has a decay mode into a photon and a $Z$ boson. If the rest masses of the Higgs and $Z$ boson are $125 \\mathrm{GeV} / \\mathrm{c}^{2}$ and $90 \\mathrm{GeV} / \\mathrm{c}^{2}$ respectively, and the decaying Higgs particle is at rest, the energy of the photon will approximately be\n\t{\\exyear{NET JUNE 2014}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $35 \\sqrt{3} \\mathrm{GeV}$\n\t\\task[\\textbf{B.}]$35 \\mathrm{GeV}$\n\t\\task[\\textbf{C.}]$30 \\mathrm{GeV}$\n\t\\task[\\textbf{D.}]$15 \\mathrm{GeV}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tH_{B} &\\rightarrow P_{H}+Z_{B}\\\\\n\t\\intertext { From conservation of momentum }\n\t 0&=\\vec{P}_{1}+\\vec{P}_{2} \\Rightarrow \\vec{P}_{1}=-\\vec{P}_{2} \\Rightarrow\\left|P_{1}\\right|=\\left|P_{2}\\right|\\\\\n\t\\text { Now } E_{H_{B}}&=E_{P_{H}}+E_{Z_{B}} \\Rightarrow E_{P_{H}}+E_{Z_{B}}=M_{H_{B}} c^{2}\\\\\n\tE_{P_{H}}^{2}&=P_{1}^{2} c^{2}+0 \\text { and } E_{Z_{B}}^{2}=P_{2}^{2} c^{2}+M_{Z_{B}}^{2} c^{4}\\\\\n\t&\\Rightarrow\\left(E_{Z_{B}}-E_{P_{H}}\\right)\\left(E_{Z_{B}}+E_{P_{H}}\\right)=M_{Z_{B}}^{2} c^{4} \\quad \\because\\left|P_{1}\\right|=\\left|P_{2}\\right|\\\\\n\t&\\Rightarrow E_{Z_{B}}-E_{P_{H}}=\\frac{M_{Z_{B}}^{2} c^{4}}{M_{H_{B}} c^{2}}=\\frac{M_{Z_{B}}^{2} c^{2}}{M_{H_{B}}} \\quad \\because E_{Z_{B}}+E_{P_{H}}=M_{H_{B}} c^{2}\\\\\n\t&\\Rightarrow 2 E_{P_{H}}=M_{H_{B}} c^{2}-\\frac{M_{z_{B}}^{2} c^{2}}{M_{H_{B}}} \\Rightarrow E_{P_{H}}=\\frac{\\left(M_{H_{B}}^{2}-M_{z_{B}}^{2}\\right) c^{2}}{M_{H_{B}}}\\\\\n\t&\\Rightarrow E_{P_{H}}=\\left(\\frac{125 \\times 125-90 \\times 90}{2 \\times 125}\\right) \\times \\frac{c^{4}}{c^{4}}=30.1 \\mathrm{GeV}\n\t\\end{align*}\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item Consider three inertial frames of reference $A, B$ and $C$. the frame $B$ moves with a velocity $\\frac{c}{2}$ with respect to $A$, and $C$ moves with a velocity $\\frac{c}{10}$ with respect to $B$ in the same direction. The velocity of $C$ as measured in $A$ is\n\t{\\exyear{NET JUNE 2015}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{3 c}{7}$\n\t\\task[\\textbf{B.}]$\\frac{4 c}{7}$\n\t\\task[\\textbf{C.}]$\\frac{c}{7}$\n\t\\task[\\textbf{D.}] $\\frac{\\sqrt{3} c}{7}$\n\\end{tasks}\n\\begin{answer}$\\left. \\right. $\t\\\\\n\\begin{minipage}{0.5\\textwidth}\n\t\t\\begin{align*}\n\tv&=\\frac{c}{2}, \\quad u_{x}^{\\prime}=\\frac{c}{10}\\\\\n\tu_{x}&=\\frac{u_{x}^{\\prime}+v}{1+\\frac{u^{\\prime} v_{x}}{c^{2}}}=\\frac{4 c}{7}\n\t\\end{align*}\n\\end{minipage}\n\t\\begin{minipage}{0.5\\textwidth}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{NET 1}\n\t\\end{figure}\n\t\\end{minipage}\nThe correct option is \\textbf{(b)}\n\\end{answer}\n\n\t\\item Consider a particle of mass $m$ moving with a speed $v$. If $T_{R}$ denotes the relativistic kinetic energy and $T_{N}$ its non-relativistic approximation, then the value of $\\frac{\\left(T_{R}-T_{N}\\right)}{T_{R}}$ for $v=0.01 c$, is\n\t{\\exyear{NET DEC 2015}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $1.25 \\times 10^{-5}$\n\t\\task[\\textbf{B.}]$5.0 \\times 10^{-5}$\n\t\\task[\\textbf{C.}]$7.5 \\times 10^{-5}$\n\t\\task[\\textbf{D.}]$1.0 \\times 10^{-4}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tT_{N}&=\\frac{1}{2} m_{0} v^{2}, T_{R}=m c^{2}-m_{0} c^{2}=\\frac{m_{0} c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}-m_{0} c^{2} \\quad(\\because v=0.01 c)\\\\\n\t\\text { Now, } \\frac{\\left(T_{R}-T_{N}\\right)}{T_{R}}&=1-\\frac{T_{N}}{T_{R}}=1-\\frac{\\frac{1}{2} m_{0} v^{2}}{\\frac{m_{0} c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}-m_{0} c^{2}}\\\\\n\t&=1-\\frac{\\frac{\\frac{v^{2}}{2}}{c^{2}}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}-c^{2}}=1-\\frac{\\frac{(0.01)^{2}}{2}}{\\frac{1}{\\sqrt{1-(0.01)^{2}}}}-1\\\\\n\t\\frac{T_{R}-T_{N}}{T_{R}}&=0.75\n\t\\end{align*}\n\tNone of the option is correct.\n\\end{answer}\n\t\\item Let $(x, t)$ and $\\left(x^{\\prime}, t^{\\prime}\\right)$ be the coordinate systems used by the observers $O$ and $O^{\\prime}$, respectively. Observer $O^{\\prime}$ moves with a velocity $v=\\beta c$ along their common positive $x$ axis. If $x_{+}=x+c t$ and $x_{-}=x-c t$ are the linear combinations of the coordinates, the Lorentz transformation relating $O$ and $O^{\\prime}$ takes the form\n\t{\\exyear{NET JUNE 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $x_{+}^{\\prime}=\\frac{x_{-}-\\beta x_{+}}{\\sqrt{1-\\beta^{2}}}$ and $x_{-}^{\\prime}=\\frac{x_{+}-\\beta x_{-}}{\\sqrt{1-\\beta^{2}}}$\n\t\\task[\\textbf{B.}]$x_{+}^{\\prime}=\\sqrt{\\frac{1+\\beta}{1-\\beta}} x_{+}$and $x_{-}^{\\prime}=\\sqrt{\\frac{1-\\beta}{1+\\beta}} x_{-}$\n\t\\task[\\textbf{C.}]$x_{+}^{\\prime}=\\frac{x_{+}-\\beta x_{-}}{\\sqrt{1-\\beta^{2}}}$ and $x_{-}^{\\prime}=\\frac{x_{-}-\\beta x_{+}}{\\sqrt{1-\\beta^{2}}}$\n\t\\task[\\textbf{D.}]$x_{+}^{\\prime}=\\sqrt{\\frac{1-\\beta}{1+\\beta}} x_{+}$and $x_{-}^{\\prime}=\\sqrt{\\frac{1+\\beta}{1-\\beta}} x_{-}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nx_{+}^{\\prime}&=x^{\\prime}+c t^{\\prime}\\\\\n&=\\frac{x-v t}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+\\frac{c\\left(t-\\frac{v x}{c^{2}}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=\\frac{x\\left(1-\\frac{v}{c}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+\\frac{c t\\left(1-\\frac{v}{c}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n&=x \\sqrt{\\frac{1-\\frac{v}{c}}{1+\\frac{v}{c}}}+c t \\sqrt{\\frac{1-\\frac{v}{c}}{1+\\frac{v}{c}}}=\\sqrt{\\frac{1-\\frac{v}{c}}{1+\\frac{v}{c}}}(x+c t)\\\\\nx_{+}^{\\prime}&=\\sqrt{\\frac{1-\\beta}{1+\\beta}} x_{+}\\\\\nx_{-}^{\\prime}&=x^{\\prime}-c t^{\\prime}=\\frac{x-v t}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}-\\frac{c\\left(t-\\frac{v x}{c^{2}}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=\\frac{x\\left(1+\\frac{v}{c}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}-\\frac{c t\\left(1+\\frac{v}{c}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\nx_{-}^{\\prime}&=x \\sqrt{\\frac{1+\\frac{v}{c}}{1-\\frac{v}{c}}}-c t \\sqrt{\\frac{1+\\frac{v}{c}}{1-\\frac{v}{c}}} \\Rightarrow x_{-}^{\\prime}=\\sqrt{\\frac{1+\\beta}{1-\\beta}}(x-c t) \\Rightarrow x_{-}^{\\prime}=\\sqrt{\\frac{1+\\beta}{1-\\beta} x_{-}}\n\\end{align*}\nThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\n\t\\item For a particle of energy $E$ and momentum $p$ (in a frame $F$ ), the rapidity $y$ is defined as $y=\\frac{1}{2} \\ln \\left(\\frac{E+p_{3} c}{E-p_{3} c}\\right) .$ In a frame $F^{\\prime}$ moving with velocity $v=(0,0, \\beta c)$ with respect to $F$, the rapidity $y^{\\prime}$ will be\n\t{\\exyear{NET JUNE 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $y^{\\prime}=y+\\frac{1}{2} \\ln \\left(1-\\beta^{2}\\right)$\n\t\\task[\\textbf{B.}]$y^{\\prime}=y-\\frac{1}{2} \\ln \\left(\\frac{1+\\beta}{1-\\beta}\\right)$\n\t\\task[\\textbf{C.}]$y^{\\prime}=y+\\ln \\left(\\frac{1+\\beta}{1-\\beta}\\right)$\n\t\\task[\\textbf{D.}]$y^{\\prime}=y+2 \\ln \\left(\\frac{1+\\beta}{1-\\beta}\\right)$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\ny&=\\frac{1}{2} \\ln \\left(\\frac{E+p_{3} c}{E-p_{3} c}\\right)\\\\\n\\text { Then } y^{\\prime}&=\\frac{1}{2} \\ln \\left(\\frac{E^{\\prime}+p_{3}^{\\prime} c}{E^{\\prime}-p_{3}^{\\prime} c}\\right)\\\\\n\\text { Where } p_{3}^{\\prime}&=\\gamma\\left(p_{3}-v\\left(\\frac{E}{c^{2}}\\right)\\right) \\quad E^{\\prime}=\\gamma\\left(E-v p_{3}\\right)\\\\\n\\text { Put the value of } p_{3}^{\\prime} \\text { and } E^{\\prime} \\text { one will get } y^{\\prime}&=\\frac{1}{2} \\ln \\left(\\frac{\\left(E+p_{3} c\\right)-\\frac{v}{c}\\left(E+p_{3} c\\right)}{\\left(E-p_{3} c\\right)+\\frac{v}{c}\\left(E-p_{3} c\\right)}\\right)\\\\\n\\frac{1}{2} \\ln \\left(\\frac{\\left(E+p_{3} c\\right)(1-\\beta)}{\\left(E-p_{3} c\\right)(1+\\beta)}\\right) &\\Rightarrow \\frac{1}{2} \\ln \\left(\\frac{\\left(E+p_{3} c\\right)}{\\left(E-p_{3} c\\right)}\\right)+\\frac{1}{2} \\ln \\left(\\frac{1-\\beta}{1+\\beta}\\right)\\\\\ny+\\frac{1}{2} \\ln \\left(\\frac{1-\\beta}{1+\\beta}\\right)& \\Rightarrow y-\\frac{1}{2} \\ln \\left(\\frac{1+\\beta}{1-\\beta}\\right)\n\\end{align*}\nThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\t\\item A relativistic particle moves with a constant velocity $v$ with respect to the laboratory frame. In time $\\tau$, measured in the rest frame of the particle, the distance that it travels in the laboratory frame is\n\t{\\exyear{NET DEC 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $v \\tau$\n\t\\task[\\textbf{B.}]$\\frac{c \\tau}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}$\n\t\\task[\\textbf{C.}]$v \\tau \\sqrt{1-\\frac{v^{2}}{c^{2}}}$\n\t\\task[\\textbf{D.}]$\\frac{v \\tau}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}$\n\\end{tasks}\n\\begin{answer}$\\left. \\right. $\\\\\n\t\\begin{minipage}{0.5\\textwidth}\n\t\\begin{align*}\n\t\\text { From Particle } x_{1}^{\\prime}&=0 x_{2}^{\\prime}=0\\\\\n\tt_{\\text {initial }}&=t_{1}^{\\prime} \\quad t_{\\text {final }}=t_{2}^{\\prime}\\\\\n\tx_{1}&=\\frac{x_{1}^{\\prime}+v t_{1}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}, x_{2}=\\frac{x_{2}^{\\prime}+v t_{2}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}\\\\\n\tx_{2}-x_{1}&=\\frac{x_{2}^{\\prime}-x_{1}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}+\\frac{v\\left(t_{2}^{\\prime}-t_{1}^{\\prime}\\right)}{\\sqrt{1-v^{2} / c^{2}}}\\\\\n\t\\Delta x&=\\frac{v\\left(t_{2}^{\\prime}-t_{1}^{\\prime}\\right)}{\\sqrt{1-v^{2} / c^{2}}}=\\frac{v \\tau}{\\sqrt{1-v^{2} / c^{2}}}\n\t\\end{align*}\t\n\t\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{problem 2}\n\t\\end{figure}\n\\end{minipage}\nThe correct option is \\textbf{(d)}\n\\end{answer}\n\t\\item Consider a radioactive nucleus that is travelling at a speed $\\frac{c}{2}$ with respect to the lab frame. It emits $\\gamma$-rays of frequency $v_{0}$ in its rest frame. There is a stationary detector, (which is not on the path of the nucleus) in the lab. If a $\\gamma$-ray photon is emitted when the nucleus is closest to the detector, its observed frequency at the detector is\n\t{\\exyear{NET DEC 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\sqrt{3}}{2} v_{0}$\n\t\\task[\\textbf{B.}]$\\frac{1}{\\sqrt{3}} v_{0}$\n\t\\task[\\textbf{C.}]$\\frac{1}{\\sqrt{2}} v_{0}$\n\t\\task[\\textbf{D.}]$\\sqrt{\\frac{2}{3}} v_{0}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tv&=v_{0} \\sqrt{1-\\frac{v^{2}}{c^{2}}} \\quad \\text { (If detector is not in the path at nucleus) }\\\\\n\tv&=v_{0} \\sqrt{1-\\frac{1}{4}}=v_{0} \\frac{\\sqrt{3}}{2}\n\t\\end{align*}\n\tThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item An inertial observer sees two events $E_{1}$ and $E_{2}$ happening at the same location but $6 \\mu s$ apart in time. Another observer moving with a constant velocity $v$ (with respect to the first one) sees the same events to be $9 \\mu s$ apart. The spatial distance between the events, as measured by the second observer, is approximately\n\t{\\exyear{NET JUNE 2017}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $300 m$\n\t\\task[\\textbf{B.}]$1000 m$\n\t\\task[\\textbf{C.}]$2000 m$\n\t\\task[\\textbf{D.}]$2700 m$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n\tx_{2}^{1}-x_{1}^{1}&=0, t_{2}^{1}-t_{1}^{1}=6 \\times 10^{-6}, t_{2}-t_{1}=9 \\times 10^{-6}, x_{2}-x_{1}=?\\\\\nt_{2}-t_{2}&=9 \\times 10^{-6}\\\\\n\\left(\\frac{t_{2}^{1}+\\frac{v}{c^{2}} x_{2}^{1}}{\\sqrt{1-v^{2} / c^{2}}}\\right)-\\frac{\\left(t_{1}^{\\prime}+\\frac{v}{c^{2}} x_{1}^{\\prime}\\right)}{\\sqrt{1-v^{2} / c^{2}}}&=9 \\times 10^{-6}\\\\\n\\frac{t_{2}^{\\prime}-t_{1}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}&=9 \\times 10^{-6} \\Rightarrow \\frac{6 \\times 10^{-6}}{\\sqrt{1-v^{2} / c^{2}}}=9 \\times 10^{-6}\\\\\nv&=\\sqrt{\\frac{5}{9}} c \\Rightarrow \\sqrt{1-\\frac{v^{2}}{c^{2}}}=2 / 3\\\\\n\\left(x_{2}-x_{1}\\right)&=\\left(\\frac{x_{2}^{\\prime}+v t_{2}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}\\right)-\\left(\\frac{x_{1}^{\\prime}+v t_{1}^{\\prime}}{\\sqrt{1-v^{2} / c^{2}}}\\right)\\\\\n\\frac{v}{\\sqrt{1-v^{2} / c^{2}}}\\left(t_{2}^{\\prime}-t_{1}^{\\prime}\\right)\\\\\n\\left(x_{2}-x_{1}\\right)&=\\frac{\\sqrt{5}}{3} c \\times \\frac{9}{6} \\times\\left(6 \\times 10^{-6}\\right)=\\frac{\\sqrt{5}}{3} \\times 3 \\times 10^{8} \\times \\frac{9}{6} \\times 6 \\times 10^{-6}\\\\\n&=9 \\times \\sqrt{5} \\times 10^{2}=20.12 \\times 10^{2} \\simeq 2000 m\n\\end{align*}\nThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item A light signal travels from a point $A$ to a point $B$, both within a glass slab that is moving with uniform velocity (in the same direction as the light) with speed $0.3 c$ with respect to an external observer. If the refractive index of the slab is $1.5$, then the observer will measure the speed of the signal as\n\t{\\exyear{NET DEC 2017}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $0.67 c$\n\t\\task[\\textbf{B.}]$0.81 c$\n\t\\task[\\textbf{C.}]$0.97 c$\n\t\\task[\\textbf{D.}] $c$\n\\end{tasks}\n\\begin{answer}$\\left. \\right. $\\\\\n\t\\begin{minipage}{0.5\\textwidth}\n\\begin{align*}\nv&=0.3 c\\\\\nu_{x}^{\\prime}&=\\frac{c}{n} n=1.5\\\\\nu_{x}&=\\frac{u_{x}^{\\prime}+v}{1+\\frac{u_{x}^{\\prime} v}{c^{2}}}=\\frac{0.3 c+\\frac{c}{n}}{1+\\frac{c}{n} \\cdot \\frac{0.3 c}{c^{2}}}\\\\\nu_{x}&=0.81 c\n\\end{align*}\n\t\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=3cm,width=5cm]{problem 4}\n\\end{figure}\n\\end{minipage}\nThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item Two particles $A$ and $B$ move with relativistic velocities of equal magnitude $v$, but in opposite directions, along the $x$-axis of an inertial frame of reference. The magnitude of the velocity of $A$, as seen from the rest frame of $B$, is\n\t{\\exyear{NET JUNE 2018}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{2 v}{\\left(1-\\frac{v^{2}}{c^{2}}\\right)}$ \n\t\\task[\\textbf{B.}]$\\frac{2 v}{\\left(1+\\frac{v^{2}}{c^{2}}\\right)}$\n\t\\task[\\textbf{C.}] $2 v \\sqrt{\\frac{c-v}{c+v}}$ \n\t\\task[\\textbf{D.}]$\\frac{2 v}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tu_{x}^{\\prime}&=v \\quad V=v\\\\\n\tu_{x}&=\\frac{u_{x}^{\\prime}+V}{1+\\frac{u_{x} V}{c^{2}}}\\\\\n\tu_{x}&=\\frac{v+v}{1+\\frac{v^{2}}{c^{2}}}=\\frac{2 v}{1+\\frac{v^{2}}{c^{2}}}\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\n\t\\item The energy of a free relativistic particle is $E=\\sqrt{|\\vec{p}|^{2} c^{2}+m^{2} c^{4}}$, where $m$ is its rest mass, $\\vec{p}$ is its momentum and $c$ is the speed of light in vacuum. The ratio $v_{g} / v_{p}$ of the group velocity $v_{g}$ of a quantum mechanical wave packet (describing this particle) to the phase velocity $v_{p}$ is\n\t{\\exyear{NET JUNE 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $|\\vec{p}| c / E$\n\t\\task[\\textbf{B.}]$|\\vec{p}| m c^{3} / E^{2}$\n\t\\task[\\textbf{C.}] $|\\vec{p}|^{2} c^{3} / E^{2}$\n\t\\task[\\textbf{D.}]$|\\vec{p}| c / 2 E$\n\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tE^{2}&=p^{2} c^{2}+m^{2} c^{4} \\text { and } v_{g}=\\frac{d E}{d p}, v_{p}=\\frac{E}{p}\\\\\n\t\t2 E \\frac{d E}{d p}&=2 p c^{2} \\Rightarrow \\frac{E}{p} \\frac{d E}{d p}=c^{2}\\\\\n\t\t\\frac{v_{g}}{v_{p}}&=\\frac{c^{2}}{v_{p}^{2}} \\quad \\frac{v_{g}}{v_{p}}=\\frac{c^{3} p^{2}}{E^{2}}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item An inertial frame $K^{\\prime}$ moves with a constant speed $v$ with respect to another inertial frame $K$ along their common $x$ - direction. Let $(x, c t)$ and $\\left(x^{\\prime}, c t^{\\prime}\\right)$ denote the spacetime coordinates in the frames $K$ and $K^{\\prime}$, respectively. Which of the following spacetime diagrams correctly describes the $t^{\\prime}$ - axis $\\left(x^{\\prime}=0\\right.$ line $)$ and the $x^{\\prime}$ - axis $\\left(t^{\\prime}=0\\right.$ line $)$ in the $x$-ct plane? (In the following figures $\\tan \\phi=v / c$ )\n{\t\\exyear{NET JUNE 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{PROBLEM 5}\n\t\\end{figure}\n\t\\task[\\textbf{B.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{PROBLEM 6}\n\t\\end{figure}\n\t\\task[\\textbf{C.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{PROBLEM 7}\n\t\\end{figure}\n\t\\task[\\textbf{D.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=4cm,width=5cm]{PROBLEM8}\n\t\\end{figure}\n\\end{tasks}\n\\begin{answer}\n$\t\\left(\\begin{array}{c}\n\t\tc t^{\\prime} \\\\\n\t\tx^{\\prime} \\\\\n\t\ty^{\\prime} \\\\\n\t\tz^{\\prime}\n\t\\end{array}\\right)=\\left(\\begin{array}{cccc}\n\t\t\\cosh \\phi & -\\sinh \\phi & 0 & 0 \\\\\n\t\t-\\sinh \\phi & \\cos \\phi & 0 & 0 \\\\\n\t\t0 & 0 & 1 & 0 \\\\\n\t\t0 & 0 & 0 & 1\n\t\\end{array}\\right)\\left(\\begin{array}{l}\n\t\tc t \\\\\n\t\tx \\\\\n\t\ty \\\\\n\t\tz\n\t\\end{array}\\right)$\\\\\n\t$\\text { Where } v=\\cosh \\phi, \\beta v=\\sinh \\phi \\beta=\\tanh \\phi$\\\\\n\tThe correct option is \\textbf{(a)}\n\\end{answer}\n\n\t\\item A relativistic particle of mass $m$ and charge $e$ is moving in a uniform electric field of strength $\\varepsilon$. Starting from rest at $t=0$, how much time will it take to reach the speed $\\frac{c}{2}$ ?\n\t{\\exyear{NET DEC 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{1}{\\sqrt{3}} \\frac{m c}{e \\varepsilon}$\n\t\\task[\\textbf{B.}]$\\frac{m c}{e \\varepsilon}$\n\t\\task[\\textbf{C.}]$\\sqrt{2} \\frac{m c}{e \\varepsilon}$\n\t\\task[\\textbf{D.}]$\\sqrt{\\frac{3}{2}} \\frac{m c}{e \\varepsilon}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n\\frac{d p}{d t}&=e \\varepsilon\\\\\np&=e \\varepsilon t+c\\\\\n\\text { At } t&=0, p=0, c=0\\\\\n\\frac{m v}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}&=e \\varepsilon t\\\\\nt&=\\frac{m}{e \\varepsilon} \\frac{v}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n\\text { Put } v&=\\frac{c}{2}, \\quad t=\\frac{m}{e \\varepsilon} \\frac{c / 2}{\\sqrt{1-\\frac{1}{4}}}=\\frac{m c}{\\sqrt{3} e \\varepsilon}\\\\\nt&=\\frac{m c}{\\sqrt{3} e E}\n\\end{align*}\nThe correct option is \\textbf{(a)}\t\n\\end{answer}\n\\end{enumerate}\n\\newpage\n\\begin{abox}\n\tPractice set 2 solutions\n\t\\end{abox}\n\\begin{enumerate}\n\n\t\\item For the set of all Lorentz transformations with velocities along the $x$-axis consider the two statements given below:\n\tP: If $L$ is a Lorentz transformation, then, $L^{-1}$ is also a Lorentz transformation.\n\tQ: If $L_{1}$ and $L_{2}$ are Lorentz transformations, then $L_{1} L_{2}$ is necessarily a Lorentz transformation.\n\tChoose the correct option\n\t{\\exyear{GATE 2010}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $P$ is true and $Q$ is false\n\t\\task[\\textbf{B.}]Both $P$ and $Q$ are true\n\t\\task[\\textbf{C.}]Both $P$ and $Q$ are false\n\t\\task[\\textbf{D.}]$P$ is false and $Q$ is true\n\\end{tasks}\n\\begin{answer}\nThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item A $\\pi^{0}$ meson at rest decays into two photons, which moves along the $x$-axis. They are both detected simultaneously after a time, $t=10 \\mathrm{~s} .$ In an inertial frame moving with a velocity $v=0.6 c$ in the direction of one of the photons, the time interval between the two detections is\n\t{\\exyear{GATE 2010}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $15 c$\n\t\\task[\\textbf{B.}]$0 \\mathrm{~s}$\n\t\\task[\\textbf{C.}] $10 \\mathrm{~s}$\n\t\\task[\\textbf{D.}]$20 s$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nt_{1}&=t_{0} \\sqrt{\\frac{1+\\frac{v}{c}}{1-\\frac{v}{c}}}=10 \\sqrt{\\frac{1+0.6}{1-0.6}}=10 \\times 2=20 \\mathrm{sec}\\\\\nt_{2}&=t_{0} \\sqrt{\\frac{1-\\frac{v}{c}}{1+\\frac{v}{c}}}=10 \\sqrt{\\frac{1-0.6}{1+0.6}}=10 \\times \\frac{1}{2}=5 \\mathrm{sec}\\\\\n\\mathrm{t}_{1}-\\mathrm{t}_{2}&=15 \\mathrm{sec}\n\\end{align*}\t\nThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item Two particles each of rest mass $m$ collide head-on and stick together. Before collision, the speed of each mass was $0.6$ times the speed of light in free space. The mass of the final entity is\n{\t\\exyear{GATE 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $5 m / 4$\n\t\\task[\\textbf{B.}]$2 m$\n\t\\task[\\textbf{C.}]$5 \\mathrm{~m} / 2$\n\t\\task[\\textbf{D.}]$25 \\mathrm{~m} / \\mathrm{s}$\n\\end{tasks}\n\\begin{answer}\nFrom conservation of energy\\\\\n$$\n\\frac{m c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+\\frac{m c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=m_{1} c^{2} \\Rightarrow \\frac{2 m c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=m_{1} c^{2}\n$$\nSince $v=0.6 c \\Rightarrow m_{1}=5 \\mathrm{~m} / 2$\t\\\\\nThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item A rod of proper length $l_{0}$ oriented parallel to the $x$-axis moves with speed $2 c / 3$ along the $x$-axis in the $S$-frame, where $c$ is the speed of light in free space. The observer is also moving along the $x$-axis with speed $c / 2$ with respect to the $S$-frame. The length of the rod as measured by the observer is\n\t{\\exyear{GATE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $0.35 l_{0}$\n\t\\task[\\textbf{B.}]$0.48 l_{0}$\n\t\\task[\\textbf{C.}]$0.87 l_{0}$\n\t\\task[\\textbf{D.}]$0.97 l_{0}$\n\\end{tasks}\n\\begin{answer}\n$l=l_{0} \\sqrt{1-\\frac{u_{x}^{2}}{c^{2}}}=0.97 l_{0}$\\\\\nThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\t\\item An electron is moving with a velocity of $0.85 c$ in the same direction as that of a moving photon. The relative velocity of the electron with respect to photon is\n{\t\\exyear{GATE 2013}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $c$\n\t\\task[\\textbf{B.}]$-c$\n\t\\task[\\textbf{C.}] $0.15 c$\n\t\\task[\\textbf{D.}]$-0.15 c$\n\\end{tasks}\n\\begin{answer}\nThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\n\t\\item  The relativistic form of Newton's second law of motion is \n{\t\\exyear{GATE 2013}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $F=\\frac{m c}{\\sqrt{c^{2}-v^{2}}} \\frac{d v}{d t}$ \n\t\\task[\\textbf{B.}]$F=\\frac{m \\sqrt{c^{2}-v^{2}}}{c} \\frac{d v}{d t}$\n\t\\task[\\textbf{C.}]$F=\\frac{m c^{2}}{c^{2}-v^{2}} \\frac{d v}{d t}$\n\t\\task[\\textbf{D.}]$F=m \\frac{c^{2}-v^{2}}{c^{2}} \\frac{d v}{d t}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tP&=\\frac{m v}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\t\\\\\n\tF&=\\frac{d P}{d t}=m \\frac{d v}{d t} \\cdot \\frac{1}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+m v\\left(-\\frac{1}{2}\\right) \\cdot \\frac{1}{\\left(1-\\frac{v^{2}}{c^{2}}\\right)^{3 / 2}} \\cdot \\frac{-2 v}{c^{2}} \\frac{d v}{d t}\\\\\n\tF&=m \\frac{d v}{d t} \\frac{1}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\left(1+\\frac{1}{2} \\frac{v^{2} / c^{2}}{\\left(1-\\frac{v^{2}}{c^{2}}\\right)}\\right)\\\\\n\t&=m \\frac{d v}{d t}\\left(\\frac{1-v^{2} / 2 c^{2}}{\\left(1-\\frac{v^{2}}{c^{2}}\\right)^{3 / 2}}\\right)\\\\\n\t&=m \\frac{d v}{d t}\\left[\\frac{\\left(1-v^{2} / c^{2}\\right)^{1 / 2}}{\\left(1-v^{2} / c^{2}\\right)\\left(1-v^{2} / c^{2}\\right)^{1 / 2}}\\right]=\\frac{m c^{2}}{\\left(c^{2}-v^{2}\\right)} \\frac{d v}{d t}\n\t\\end{align*}\nThe correctoption is \\textbf{(c)}\n\\end{answer}\n\t\\item If the half-life of an elementary particle moving with speed $0.9$ c in the laboratory frame is $5 \\times 10^{-8} s$, then the proper half-life is $\\times 10^{-8}$ s. $\\left(c=3 \\times 10^{8} \\mathrm{~m} / \\mathrm{s}\\right)$\n\t{\\exyear{GATE 2014}}\n\\begin{answer}\n\\begin{align*}\n\tt&=\\frac{t_{0}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n\tt_{0}&=t \\times \\sqrt{1-\\frac{v^{2}}{c^{2}}}=5 \\times 10^{-8} \\times \\sqrt{0.19}=2.18 \\times 10^{-8} \\mathrm{~s}\n\\end{align*}\t\n\\end{answer}\n\t\\item In an inertial frame $S$, two events $A$ and $B$ take place at $\\left(c t_{A}=0, \\vec{r}_{A}=0\\right)$ and $\\left(c t_{B}=0, \\vec{r}_{B}=2 \\hat{y}\\right)$, respectively. The times at which these events take place in a frame $S^{\\prime}$ moving with a velocity $0.6 c \\hat{y}$ with respect to $S$ are given by\n\t{\\exyear{GATE 2015}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $c t_{A}^{\\prime}=0 ; c t_{B}^{\\prime}=-\\frac{3}{2}$\n\t\\task[\\textbf{B.}]$c t_{A}^{\\prime}=0 ; c t_{B}^{\\prime}=0$\n\t\\task[\\textbf{C.}]$c t_{A}^{\\prime}=0 ; c t_{B}^{\\prime}=\\frac{3}{2}$\n\t\\task[\\textbf{D.}] $c t_{A}^{\\prime}=0 ; c t_{B}^{\\prime}=\\frac{1}{2}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n&\\text { Velocity of } S^{\\prime} \\text { with respect to } S \\text { is } v=0.6 c\\\\\nt_{A}^{\\prime}&=\\frac{t_{A}-\\frac{v}{c^{2}} y}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n&\\text { For event } \\mathrm{A}, t_{A}=0, y=0 \\text {. So } \\mathrm{ct}_{A}^{\\prime}=0\\\\\nt_{B}^{\\prime}&=\\frac{t_{B}-\\frac{v}{c^{2}} y}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n&\\text { For event } \\mathrm{B}, t_{B}=0, y=2 \\text {. So } c t_{B}^{\\prime}=-\\frac{3}{2}\n\\end{align*}\nThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item A particle with rest mass $M$ is at rest and decays into two particles of equal rest masses $\\frac{3}{10} M$ which move along the $z$ axis. Their velocities are given by\n\t{\\exyear{GATE 2015}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\vec{v}_{1}=\\vec{v}_{2}=(0.8 c) \\hat{z}$\n\t\\task[\\textbf{B.}]$\\vec{v}_{1}=-\\vec{v}_{2}=(0.8 c) \\hat{z}$\n\t\\task[\\textbf{C.}]$\\vec{v}_{1}=-\\vec{v}_{2}=(0.6 c) \\hat{z}$\n\t\\task[\\textbf{D.}]$\\vec{v}_{1}=(0.6 c) \\hat{z} ; \\vec{v}_{2}=(-0.8 c) \\hat{z}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tM &\\rightarrow \\frac{3}{10} M+\\frac{3}{10} M\\\\\n\t\\intertext { From momentum conservation }\n\t0&=\\vec{P}_{1}+\\vec{P}_{2} \\Rightarrow \\vec{P}_{1}=-\\vec{P}_{2} \\Rightarrow\\left|P_{1}\\right|=\\left|P_{2}\\right|\\\\\n\t\\intertext { From energy conservation }\n\tE&=E_{1}+E_{2}\\\\\n\t\\Rightarrow M c^{2}&=\\frac{3}{10} \\frac{M c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}+\\frac{3}{10} \\frac{M c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}} \\Rightarrow M c^{2}=\\frac{3}{5} \\frac{M c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\\\\n\t\\left(1-\\frac{v^{2}}{c^{2}}\\right)&=\\frac{9}{25} \\Rightarrow \\frac{v^{2}}{c^{2}}=\\frac{16}{25} \\Rightarrow v=0.8 c\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item The kinetic energy of a particle of rest mass $m_{0}$ is equal to its rest mass energy. Its momentum in units of $m_{0} c$, where $c$ is the speed of light in vacuum, is\n\t(Give your answer upto two decimal places)\n\t{\\exyear{GATE 2016}}\n\\begin{answer}\n\\begin{align*}\nm_{0} c^{2}&=E-m_{0} c^{2} \\Rightarrow E=2 m_{0} c^{2}\\\\\n&\\Rightarrow \\frac{m_{0} c^{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=2 m_{0} c^{2} \\Rightarrow v=\\frac{\\sqrt{3}}{2} c\\\\\n\\cdot E^{2}&=p^{2} c^{2}+m_{0}^{2} c^{4} \\Rightarrow 4 m_{0}^{2} c^{4}-m_{0}^{2} c^{4}=p^{2} c^{2} \\Rightarrow p=\\sqrt{3} m_{0} c=1.732 m_{0} c\n\\end{align*}\t\n\\end{answer}\n\t\\item In an inertial frame of reference $S$, an observer finds two events occurring at the same time at coordinates $x_{1}=0$ and $x_{2}=d$. A different inertial frame $S^{\\prime}$ moves with velocity $v$ with respect to $S$ along the positive $x$-axis. An observer in $S^{\\prime}$ also notices these two events and finds them to occur at times $t_{1}^{\\prime}$ and $t_{2}^{\\prime}$ and at positions $x_{1}^{\\prime}$ and $x_{2}^{\\prime}$ respectively.\n\tIf $\\Delta t^{\\prime}=t_{2}^{\\prime}-t_{1}^{\\prime}, \\Delta x^{\\prime}=x_{2}^{\\prime}-x_{1}^{\\prime}$ and $\\gamma=\\frac{1}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}$, which of the following statements is true?\n\t{\\exyear{GATE 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\Delta t^{\\prime}=0, \\Delta x^{\\prime}=\\gamma d$\n\t\\task[\\textbf{B.}] $\\Delta t^{\\prime}=0, \\Delta x^{\\prime}=\\frac{d}{\\gamma}$\n\t\\task[\\textbf{C.}]$\\Delta t^{\\prime}=\\frac{-\\gamma v d}{c^{2}}, \\Delta x^{\\prime}=\\gamma d$\n\t\\task[\\textbf{D.}] $\\Delta t^{\\prime}=\\frac{-\\gamma v d}{c^{2}}, \\Delta x^{\\prime}=\\frac{d}{\\gamma}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tt_{2}^{\\prime}-t_{1}^{\\prime}&=\\left(\\frac{t_{2}-\\frac{v x_{2}}{c^{2}}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)-\\left(\\frac{t_{1}-\\frac{v x_{1}}{c^{2}}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right) \\Rightarrow \\Delta t^{\\prime}=\\gamma \\Delta t-\\frac{\\gamma v \\Delta x}{c^{2}}\\\\\n\t\\text { It is given, } \\Delta t&=0, \\Delta x=d\\\\\n\t\\Rightarrow \\Delta t^{\\prime}&=-\\frac{\\gamma v \\Delta x}{c^{2}}=-\\frac{\\gamma v d}{c^{2}}\\\\\n\tx_{2}^{\\prime}-x_{1}^{\\prime}&=\\left(\\frac{x_{2}-v t_{2}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)-\\left(\\frac{x_{1}-v t_{1}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right) \\Rightarrow \\Delta x^{\\prime}=\\gamma(\\Delta x-v \\Delta t)\\\\\n\t\\Rightarrow \\Delta x^{\\prime}&=\\gamma d\n\t\\end{align*}\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item A particle of rest mass $M$ is moving along the positive $x$-direction. It decays into two photons $\\gamma_{1}$ and $\\gamma_{2}$ as shown in the figure. The energy of $\\gamma_{1}$ is $1 \\mathrm{GeV}$ and the energy of $\\gamma_{2}$ is $0.82 \\mathrm{GeV}$. The value of $M$ (in units of $\\frac{\\mathrm{GeV}}{c^{2}}$ ) is upto two decimal places)\n\t{\\exyear{GATE }}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{problem 17}\n\t\\end{figure}\n\\begin{answer}\n\\begin{align*}\n\\sqrt{p^{2} c^{2}+M^{2} c^{4}}&=E_{1}+E_{2}=1.82 \\mathrm{GeV}\\\\\np&=\\frac{E_{1}}{c} \\cos \\theta_{1}+\\frac{E_{2}}{c} \\cos \\theta_{2}=\\frac{1 G e V}{c} \\frac{1}{\\sqrt{2}}+\\frac{0.82 G e V}{c} \\frac{1}{2}=\\frac{1.11 G e V}{c}\\\\\n&\\Rightarrow p^{2} c^{2}+m^{2} c^{4}=3.312 \\Rightarrow m^{2} c^{4}=3.312-1.23=2.08\\\\\n&\\Rightarrow m=\\sqrt{2.076}=1.44\n\\end{align*}\n\\end{answer}\n\t\\item An object travels along the $x$-direction with velocity $\\frac{C}{2}$ in a frame $O$. An observer in a frame $O^{\\prime}$ sees the same object travelling with velocity $\\frac{C}{4}$. The relative velocity of $O^{\\prime}$ with respect to $O$ in units of $c$ is.............. (up to two decimal places).\n\t{\\exyear{GATE 2017}}\n\\begin{answer}\n\t\\begin{align*}\n\tu_{x}^{\\prime}&=\\frac{C}{2}, v=\\frac{C}{4}\\\\\n\tu_{x}&=\\frac{u_{x}^{\\prime}-v}{1-\\frac{u_{x}^{\\prime} v}{c^{2}}}=\\frac{\\frac{c}{2}-\\frac{c}{4}}{1-\\frac{c}{2} \\cdot \\frac{c}{4} \\cdot \\frac{1}{c^{2}}}=\\frac{2 c}{7}=0.28 c\n\t\\end{align*}\n\\end{answer}\n\t\\item A spaceship is travelling with a velocity of $0.7 c$ away from a space station. The spaceship ejects a probe with a velocity $0.59$ c opposite to its own velocity. A person in the space station would see the probe moving at a speed $X_{C}$, where the value of $X$ is (up to three decimal places).\n\t{\\exyear{GATE 2018}}\n\\begin{answer}$\\left. \\right. $\\\\\n\t\\begin{minipage}{0.5\\textwidth}\n\t\\begin{align*}\n\tv&=0 \\cdot 7 c, u_{x}^{\\prime}=-0 \\cdot 59 c\\\\\n\tu_{x}&=\\frac{u_{x}^{\\prime}+v}{1+\\frac{u_{x}^{\\prime} v}{c_{2}}}\\\\\n\tu_{x}&=\\frac{-0.59 c+0.7 c}{1-0.7 \\times 0.59}=\\frac{0.11 c}{1-0.413}=\\frac{0.11 c}{0.587}=0.187 c\n\t\\end{align*}\n\t\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=3cm,width=5cm]{PROBLEM 18}\n\\end{figure}\t\t\n\\end{minipage}\n\\end{answer}\n\t\\item Two spaceships $A$ and $B$, each of the same rest length $L$, are moving in the same direction with speeds $\\frac{4 c}{5}$ and $\\frac{3 c}{5}$, respectively, where $c$ is the speed of light. As measured by $B$, the time taken by $A$ to completely overtake $B$ [see figure below] in units of $L / c$ (to the nearest integer) is\n\t{\\exyear{GATE 2019}}$\\left. \\right. $\\\\\n\t\\begin{minipage}{0.5\\textwidth}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{PROBLEM 19}\n\t\\end{figure}\t\n\t\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{PROBLEM 20}\n\t\\end{figure}\n\\end{minipage}\n\\begin{answer}\n\t\\begin{align*}\n\tu_{A, B}&=\\frac{\\frac{4}{5} c-\\frac{3}{5} c}{1-\\frac{4}{5} c \\cdot \\frac{3}{5} c \\cdot \\frac{1}{c^{2}}}=\\frac{\\frac{c}{5}}{\\frac{13}{25}}=\\frac{5}{13} c\t\\\\\n\t&\\text { Kinematic equation is given by }\\\\\n\t\\frac{5}{13} c \\times t&=L \\sqrt{1-\\frac{25}{169}}+L \\Rightarrow t=\\frac{5 L}{c} \\Rightarrow \\alpha=5\n\t\\end{align*}\n\\end{answer}\n\t\\item Two events, one on the earth and the other one on the Sun, occur simultaneously in the earth's frame. The time difference between the two events as seen by an observer in a spaceship moving with velocity $0.5 c$ in the earth's frame along the line joining the earth to the Sun is $\\Delta t$, where $c$ is the speed of light. Given that light travels from the Sun to the earth in $8.3$ minutes in the earth's frame, the value of $|\\Delta t|$ in minutes (rounded off to two decimal places) is\n\t(Take the earth's frame to be inertial and neglect the relative motion between the earth and the sun)\n\t{\\exyear{GATE 2019}}\n\\begin{answer}\n\\begin{align*}\nt_{2}^{\\prime}-t_{1}^{\\prime}&=0 \\quad x_{2}^{\\prime}-x_{1}^{\\prime}=8.3 \\times 3 \\times 10^{8} \\times 60 \\quad v=0.5 c\\\\\n\\Delta t&=t_{2}-t_{1}=\\left(\\frac{t_{2}^{\\prime}+\\frac{v x_{2}^{\\prime}}{c^{2}}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)-\\left(\\frac{t_{1}^{\\prime}+\\frac{v x_{1}^{\\prime}}{c^{2}}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)=\\left(\\frac{t_{2}-t_{1}^{\\prime}}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}\\right)+\\frac{v}{c^{2}} \\frac{\\left(x_{2}^{\\prime}-x_{1}^{\\prime}\\right)}{\\sqrt{1-\\frac{v^{2}}{c^{2}}}}=4.77 \\min\n\\end{align*}\t\n\\end{answer}\n\\end{enumerate}", "meta": {"hexsha": "e803343da6374a7edd64a13fdc4811c29f86bc68", "size": 38188, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Classical Mechanics  -CSIR/chapter/str solutions.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Classical Mechanics  -CSIR/chapter/str solutions.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Classical Mechanics  -CSIR/chapter/str solutions.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.1248097412, "max_line_length": 545, "alphanum_fraction": 0.5989316016, "num_tokens": 16535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4258869093028392}}
{"text": "% !TEX root = ../main.tex\n\\section{Permutation-invariant Recommender Models}\n\\label{sec:models}\n\\Cref{prop:universal-approximation} shows that \\gls{rfs} can approximate permutation-invariant recommendation models. We describe several common recommendation models and show that they are permutation-invariant, before comparing their performance to \\gls{rfs} in \\Cref{sec:rfs-experiments}.\n\n\\citet{gopalan2014content-based} develop a probabilistic matrix factorization model of user consumption data. \\Gls{ctpf} models user preferences using a generative process,\n\\input{ch-rfs/ctpf_generative_process}\nTo show that \\gls{ctpf} is permutation-invariant, consider the Poisson likelihood function over words $w_{dv}$. Conditional on the latent item representation $\\theta_d$ and latent word representation $\\beta_v$, every word in the document $w_{dv}$ is independent; the joint probability of words in a document factorizes:\n\\begin{align}\n  p(w_{d} \\mid \\theta_d, \\beta_v) &= \\prod_{w_{dv} \\in w_d} p(w_{dv} \\mid \\theta_d, \\beta_v)\\, .\n\\end{align}\n\\gls{ctpf} makes predictions using expectations under the posterior. The posterior is proportional to the the log joint of the model, and the attributes of items (words in documents) enter into the model only via the above product. The product of the probability of words in a document is invariant to a reordering of the words in the document, and therefore \\gls{ctpf} is permutation-invariant.\n\nWord embedding models~\\citep{mikolov2013distributed} can be used as recommendation models if the embeddings are learned using a modified context window. For an item with attributes $x_m$, let the context window for attribute ${j\\in x_m}$ be the set of other attributes of the same item ${j' \\in x_m: j'\\neq j}$. To recommend items using this model of attributes $\\beta_j$ for $j \\in V$, item embeddings are computed as the average of their attribute embeddings. Users are represented as the average of the embeddings of the items they consume, and recommendation is performed using the cosine similarity of user and item embeddings. This is a permutation-invariant model, as the output of the model depends on the sum of attribute embeddings (summation is invariant to permutation).\n\nStarSpace is also an embedding model and represents users as a sum over a user's consumed items' attribute embeddings (there is no explicit user embedding). In contrast to the word embedding model, StarSpace is trained on a classification objective with negative samples drawn from the the set of items~\\citep{wu2018starspace:}. As model predictions depend on sums of attributes, StarSpace is a permutation-invariant recommendation model.\n\nWe next consider LightFM~\\citep{kula2015metadata}, a permutation-invariant recommendation model. We show that if the \\gls{bpr} objective~\\citep{rendle2009bpr:} is used, LightFM is an instance of \\acrshort{rfs}. \\footnote{The LightFM paper~\\citep{kula2015metadata} uses a logistic objective to which \\Cref{prop:maximizing-recall} applies. LightFM with the \\gls{bpr} objective is unpublished but implemented in code released by the author. For completeness, we studied LightFM with both objectives to ensure its performance is equivalent to \\gls{rfs} when the \\gls{bpr} objective is used.} Although the \\gls{bpr} objective is designed for ranking, models trained with it can be used to construct classifiers. The \\gls{bpr} objective is\n$${\\log\\sigma\\left(f(u, x_m; \\mbgamma) - f(u, x_k; \\mbgamma)\\right)}\\, ,$$\nwhere $m$ corresponds to a positive label $\\yum = 1$, $k$ corresponds to a negative label $\\yuk = 0$, and $f$ is parameterized as in \\gls{rfs}~\\citep{kula2015metadata}. A ranking function $f$ optimizes the \\gls{bpr} objective if~${f\\rightarrow \\infty}$ for the positive example and $f$ is constant for the negative example; or, if $f$ is constant for the positive example and $f\\rightarrow -\\infty$ for the negative example. In either case, a constant can be added to yield a perfect classifier from the ranking function $f$ (positive examples are ranked higher than negative examples in the optimal ranking, so there exists such a constant). That we can construct a classifier from the \\gls{bpr} objective means that \\Cref{prop:maximizing-recall} applies: permutation-invariant models such as LightFM, trained with the \\gls{bpr} objective, are instances of the \\gls{rfs} class of recommendation models.\n\nThe regression function $f$ in \\gls{rfs} can also be parameterized using a recurrent network, as in \\citet{bansal2016ask-the-gru:}. Such a recommendation model can be made permutation-invariant if averaged over permutations of attributes fed to the network. Attributes are treated as a sequence and the marginalization is over these permutations,\n\\begin{equation}\np(\\yum = 1 \\mid x_m) =\n  \\frac{1}{\\lvert \\pi(x_m) \\rvert}\\sum_{\\pi \\in \\pi(x_m)}\\sigma\\left(\\phi(\\theta_u,\\{\\beta_{\\pi(1)}, \\ldots,\n  \\beta_{\\pi(J)}\\})\\right) \\, .\n\\label{eq:rnn}\n\\end{equation}\nHere $\\beta_j$ are attribute embeddings, $\\pi(x_m)$ denotes the set of all permutations of the attributes $x_m$, and $\\phi$ is the output of a recurrent neural network architecture~\\citep{bansal2016ask-the-gru:} projected to a scalar.", "meta": {"hexsha": "89b17d06b33650ba7afb03fc19ef3237d568fa0b", "size": 5171, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-rfs/sec_models.tex", "max_stars_repo_name": "altosaar/thesis", "max_stars_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-21T18:56:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T12:18:53.000Z", "max_issues_repo_path": "ch-rfs/sec_models.tex", "max_issues_repo_name": "altosaar/thesis", "max_issues_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch-rfs/sec_models.tex", "max_forks_repo_name": "altosaar/thesis", "max_forks_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 178.3103448276, "max_line_length": 903, "alphanum_fraction": 0.7803132856, "num_tokens": 1321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4258869025344649}}
{"text": "\n    \\documentclass{article}\n    \\usepackage{amsfonts}\n    \\usepackage{amsmath,multicol,eso-pic}\n    \\begin{document}\n    \\title{Algebra 101 worksheet 1 Solutions} \n \\date{\\vspace{-5ex}} \n \\maketitle\n\n        \\section{Linear equations}\n        \n        \\begin{enumerate}\n        \\item$$a =\\frac{g - 5}{H - 14}$$\n\\item$$N =\\frac{16}{- S + w}$$\n\\item$$A =\\frac{h + 4}{E - 6}$$\n\\item$$w =\\frac{z}{15} - \\frac{23}{15}$$\n\\item$$b =\\frac{K - 5}{Y - 23}$$\n\\item$$M =\\frac{10}{S - 4}$$\n\\item$$y =\\frac{- V + z}{T - X}$$\n\\item$$p =\\frac{6}{Q + 2}$$\n\\item$$p =\\frac{- V + g}{t + 5}$$\n\\item$$H =\\frac{y - 20}{E - u}$$\n\\item$$M =\\frac{R + 10}{R - k}$$\n\\item$$M =\\frac{- b + 9}{j + 26}$$\n\\item$$V =\\frac{P - X}{Q - S}$$\n\\item$$P =- \\frac{e}{13} + \\frac{1}{13}$$\n\\item$$g =- \\frac{37}{7}$$\n\\item$$K =\\frac{S + 6}{T + 23}$$\n\\item$$d =\\frac{Q + 24}{N + 10}$$\n\\item$$D =- \\frac{27}{m - 8}$$\n\\item$$E =\\frac{- y + 2}{q + 5}$$\n\\item$$r =\\frac{c - 10}{x + 5}$$\n        \\end{enumerate}\n        \n\n        \\section{Quadratic equations}\n        \n        \\begin{enumerate}\n        \\item$$y = - \\frac{15}{8} - \\frac{\\sqrt{65}}{8}, y = - \\frac{15}{8} + \\frac{\\sqrt{65}}{8}$$\n\\item$$x = \\frac{19}{18} + \\frac{\\sqrt{757}}{18}, x = - \\frac{\\sqrt{757}}{18} + \\frac{19}{18}$$\n\\item$$x = -10, x = 23$$\n\\item$$y = \\frac{1}{4} + \\frac{\\sqrt{177}}{4}, y = - \\frac{\\sqrt{177}}{4} + \\frac{1}{4}$$\n\\item$$x = 0, x = 22$$\n\\item$$x = \\frac{8}{13} - \\frac{3 i}{13} \\sqrt{29}, x = \\frac{8}{13} + \\frac{3 i}{13} \\sqrt{29}$$\n\\item$$x = -2, x = 10$$\n\\item$$x = - \\frac{1}{22} + \\frac{\\sqrt{309}}{22}, x = - \\frac{\\sqrt{309}}{22} - \\frac{1}{22}$$\n\\item$$x = 0, x = \\frac{24}{5}$$\n\\item$$y = - \\frac{11}{20} - \\frac{\\sqrt{799} i}{20}, y = - \\frac{11}{20} + \\frac{\\sqrt{799} i}{20}$$\n\\item$$x = 0, x = \\frac{4}{15}$$\n\\item$$x = 12, x = 15$$\n\\item$$y = 2, y = 6$$\n\\item$$x = -17, x = 23$$\n\\item$$x = -7, x = -1$$\n\\item$$x = -13, x = -5$$\n\\item$$x = -3, x = \\frac{7}{4}$$\n\\item$$x = \\frac{5}{21} + \\frac{2 \\sqrt{85}}{21}, x = - \\frac{2 \\sqrt{85}}{21} + \\frac{5}{21}$$\n\\item$$y = \\frac{25}{26} + \\frac{\\sqrt{1041}}{26}, y = - \\frac{\\sqrt{1041}}{26} + \\frac{25}{26}$$\n\\item$$x = 0, x = 1$$\n        \\end{enumerate}\n        \n\n        \\section{Compute the derivative}\n        \n        \\begin{enumerate}\n        \\item$$\\frac{1}{x} \\left(14 x + 12\\right) - \\frac{1}{x^{2}} \\left(7 x^{2} + 12 x - 24\\right)$$\n\\item$$\\frac{2 \\sqrt{x} \\left(27 x^{2} - 18\\right)}{\\left(- 9 x^{3} + 18 x + 7\\right)^{2}} + \\frac{1}{\\sqrt{x} \\left(- 9 x^{3} + 18 x + 7\\right)}$$\n\\item$$\\frac{1}{\\left(16 x^{3} - 23 x^{2} + 5 x\\right)^{2}} \\left(\\log{\\left (x \\right )} + \\tan{\\left (x \\right )}\\right) \\left(- 48 x^{2} + 46 x - 5\\right) + \\frac{\\tan^{2}{\\left (x \\right )} + 1 + \\frac{1}{x}}{16 x^{3} - 23 x^{2} + 5 x}$$\n\\item$$- \\left(e^{x} + \\tan{\\left (x \\right )}\\right) e^{- x} + \\left(e^{x} + \\tan^{2}{\\left (x \\right )} + 1\\right) e^{- x}$$\n\\item$$- \\left(19 x + e^{x}\\right) e^{- x} + \\left(e^{x} + 19\\right) e^{- x}$$\n\\item$$\\frac{1}{x} \\left(48 x - \\sin{\\left (x \\right )} + 7\\right) - \\frac{1}{x^{2}} \\left(24 x^{2} + 7 x + \\cos{\\left (x \\right )}\\right)$$\n\\item$$\\frac{1}{\\tan^{2}{\\left (x \\right )}} \\left(\\log{\\left (x \\right )} + \\sin{\\left (x \\right )}\\right) \\left(- \\tan^{2}{\\left (x \\right )} - 1\\right) + \\frac{\\cos{\\left (x \\right )} + \\frac{1}{x}}{\\tan{\\left (x \\right )}}$$\n\\item$$\\frac{1}{x} \\left(12 x^{2} + \\frac{1}{x}\\right) - \\frac{1}{x^{2}} \\left(4 x^{3} + \\log{\\left (x \\right )} - 17\\right)$$\n\\item$$\\frac{1}{\\sin{\\left (x \\right )}} \\left(- 51 x^{2} + 48 x + 14 + \\frac{1}{x}\\right) - \\frac{\\cos{\\left (x \\right )}}{\\sin^{2}{\\left (x \\right )}} \\left(- 17 x^{3} + 24 x^{2} + 14 x + \\log{\\left (x \\right )} - 14\\right)$$\n\\item$$\\left(\\frac{1}{x} + \\frac{1}{2 \\sqrt{x}}\\right) e^{- x} - \\left(\\sqrt{x} + \\log{\\left (x \\right )}\\right) e^{- x}$$\n        \\end{enumerate}\n        \n\n    \\end{document}\n    ", "meta": {"hexsha": "45a9630e8687057013294c8f3fd74182100000ca", "size": 3851, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "algebra1_solutions.tex", "max_stars_repo_name": "luisromero87/mathexamgen", "max_stars_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "algebra1_solutions.tex", "max_issues_repo_name": "luisromero87/mathexamgen", "max_issues_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "algebra1_solutions.tex", "max_forks_repo_name": "luisromero87/mathexamgen", "max_forks_repo_head_hexsha": "9b17d689125851aefd63ded241106c9e77b7d6a5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.746835443, "max_line_length": 241, "alphanum_fraction": 0.4749415736, "num_tokens": 1842, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4258868882475938}}
{"text": "\\documentclass{article} %[11pt]{amsart}\n\\usepackage{geometry}\n\\geometry{letterpaper}\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{siunitx}\n\\usepackage{tikz}\n\\usepackage{lscape}\n\\usepackage{pgfplots}\n\\usetikzlibrary{\n  arrows,\n  calc,\n  decorations.markings,\n  decorations.pathreplacing,\n  dsp,\n  fit,\n  positioning\n}\n\\input{../util/airfoils.tex}\n\\input{../util/wing.tex}\n\\input{../util/coordinate_systems.tex}\n\\input{../util/control.tex}\n\n\\pgfplotsset{grid style={dashed,gray!25}}\n\n\\newcommand{\\qhat}{\\hat{q}}\n\\newcommand{\\cbar}{\\bar{c}}\n\\newcommand{\\qbar}{\\bar{q}}\n\\newcommand{\\cmd}{\\mathrm{cmd}}\n\\newcommand{\\ff}{\\mathrm{ff}}\n\\newcommand{\\eff}{\\mathrm{eff}}\n\\newcommand{\\app}{\\mathrm{app}}\n\\newcommand{\\wind}{\\mathrm{wind}}\n\\newcommand{\\grav}{\\mathrm{grav}}\n\\newcommand{\\kite}{\\mathrm{kite}}\n\\newcommand{\\nom}{\\mathrm{nom}}\n\\newcommand{\\aero}{\\mathrm{aero}}\n\\newcommand{\\geom}{\\mathrm{geom}}\n\\newcommand{\\cw}{\\mathrm{cw}}\n\n\n\\begin{document}\n\n\\section{Curvature from force balance}\n\n\\begin{figure}[h]\n\\begin{center}\n  \\begin{tikzpicture}[scale=0.75]\n    \\begin{scope}[shift={(-5, 0)}, scale=0.3, rotate=-10]\n      \\DrawWingFront[]\n      \\draw[line width=1.5pt, -latex] (4, 1) -- (9, 1) node[midway, above] {$-Y$};\n      \\draw[line width=1.5pt, -latex] (0, 5) -- (0, 12) node[midway, right] {$L$};\n      \\draw (-5.86, -0.13) -- (0, -4.92);\n      \\draw (5.86, -0.13) -- (0, -4.92);\n      \\draw[dashed] (0, -4.92) -- (0, -15);\n    \\end{scope}\n    \\node at (-5, -3) {$\\phi_t$};\n    \\draw[line width=1.5pt, -latex] (-5.25, -1.45) --\n    (-3.5, -4.3) node[midway, above right] {$t$};\n    \\draw[line width=1.5pt, -latex] (-3.5, -1) -- (-2, -2)\n    node[midway, below left] {$W$};\n    \\draw (-5.25, -1.45) -- (0, -10) node[midway, above right] {$l_t$};\n    %\\draw[dashed] (-5.25, -1.45) -- (-0.975, 1.175);\n    \\node at (-0.5, -8.5) {$\\gamma$};\n    \\draw[dashed] (0, -10) -- (0, -5);\n    %\\draw[dashed] (-5, 0) -- (-10, 0) node[near end, above] {$-\\phi$};\n    %\\draw[line width=1.5pt, -latex] (-7, 0) -- (-9, 0) node[midway, below]\n    %{$mv^2/R$};\n    \\DrawCoordinateSystem{shift={(0, -10)}, scale=1}\n                         {$x_{\\cw}$}{$y_{\\cw}$}{$z_{\\cw}$}\n  \\end{tikzpicture}\n  \\caption{Diagram of force balance in the stability axes' y-z plane.}\n\\end{center}\n\\end{figure}\n\nBy balancing forces in the stability axes' y-z plane, it is possible\nto relate the curvature of a kite's flight path to a few known\nparameters of the kite (e.g. lift coefficient, wing area, and mass)\nand the easily measured roll angle between the kite and the tether.\nThis implies that it is possible to steer the kite simply by\ncontrolling the tether roll angle.  Indeed, this is the approach taken\nin the current flight controller.  Here an appoximate relationship\nbetween tether roll angle and curvature is derived.  To simplify the\nrelationship, the tether is appoximated as a straight line from the\nground-station to the bridle point.  Other effects on the tether such\nas the catenary from gravity are ignored.\n\nIt is easiest to conduct the force balance along axes that are\nparallel and perpendicular to the tether.  Because the wing is forced\nto fly on the surface of a sphere with radius equal to the tether\nlength, $l_t$, the acceleration parallel to the tether is\n$a_{\\parallel} = v_i^2/l_t$.  The lift, pylon side force, and weight\neach have components along the direction perpendicular to the tether.\nTogether, these create an acceleration perpendicular to the tether\ngiven by\n\\begin{equation}\nm_{\\eff} a_{\\bot} = L \\sin \\phi_t - Y \\cos \\phi_t -\nW_{\\cw, x} \\cos \\gamma - W_{\\cw, z} \\sin \\gamma\n\\end{equation}\nHere $m_{\\eff}$ is the effective mass of the kite, which is given by\n$m_{\\eff} = m_{\\kite} + m_{\\mathrm{tether}} / 3$.  The extra term from\nthe tether mass comes from calculating the acceleration of a point\nmass at the end of a rigid rod due to a force applied at the point\nmass.  Also, a few small approximations were made such as ignoring\nforces from motor thrust, ignoring the component of drag along the\nstability z-axis, and ignoring the cosine term from projecting the\nlift vector onto the stability z-axis.\n\nThe curvature and thus acceleration that is relevant for control is\nthat in the crosswind flight plane.  The parallel and perpendicular\naccelerations can be combined, projected onto the crosswind $x$-axis,\nand converted to a curvature as follows:\n\\begin{equation}\n\\kappa_{\\cw} = \\frac{1}{l_t} \\sin \\gamma +\n\\frac{\\rho A v_{\\app}^2}{2 m_{\\eff} v_i^2}\n\\left(C_L \\sin \\phi_t - C_Y \\cos \\phi_t \\right) \\cos \\gamma -\n\\frac{m}{m_{\\eff} v_i^2}\n(g_{\\cw,x} \\cos \\gamma + g_{\\cw,z} \\sin \\gamma) \\cos \\gamma\n\\end{equation}\n%\nIt is somtimes useful to decompose this total, in-plane curvature into\ncomponents caused by the tether sphere, aerodynamic angles, wind, and\ngravity:\n\\begin{equation}\n\\kappa_{\\cw} = \\kappa_0 + \\kappa_{\\aero} + \\kappa_{\\wind} + \\kappa_{\\grav}\n\\end{equation}\n%\nwhere\n%\n\\begin{eqnarray}\n\\kappa_0 &=& \\frac{1}{l_t} \\sin \\gamma \\\\\n\\kappa_{\\aero} &=&\n\\frac{\\rho A}{2 m_{\\eff}} \\left(C_L \\sin \\phi_t - C_Y \\cos \\phi_t \\right) \\cos \\gamma \\\\\n\\kappa_{\\wind} &=&\n\\left( \\frac{v_w^2 - 2 \\vec{v}_i \\cdot \\vec{v}_w}{v_i^2} \\right) \\kappa_{\\aero} \\\\\n\\kappa_{\\grav} &=&\n-\\frac{m}{m_{\\eff} v_i^2}\n(g_{\\cw,x} \\cos \\gamma + g_{\\cw,z} \\sin \\gamma) \\cos \\gamma\n\\end{eqnarray}\n\n\\section{Curvature mixer}\n\nThe curvature mixer takes as input the curvature command,\n$\\kappa_{\\cmd}$, and a component of the curvature command due to lift\nand tether roll, $\\kappa^{\\aero}_{\\cmd}$.  It returns the inner loop\nincidence and tether angle commands and angular rate commands that\nwill generate these curvatures.\n\n\\begin{equation}\n[\\alpha_{\\cmd},\\; \\Delta {C_L}_{\\cmd},\\; \\beta_{\\cmd},\\; {\\phi_t}_{\\cmd}]^T\n= F(\\kappa_{\\cmd}^{\\aero})\n\\end{equation}\n\n\n\\begin{equation}\n\\kappa_{\\cw} \\approx v \\cdot |\\vec{\\omega}|\n\\end{equation}\n\n\n\\begin{equation}\n\\kappa^{\\cw} = \\frac{|\\vec{a}_b \\times \\vec{v}_b|}{|\\vec{v}_b|^3}\n\\end{equation}\n\n\\begin{equation}\n[p_{\\cmd},\\; r_{\\cmd}]^T = G(\\kappa_{\\cmd}^{\\geom})\n\\end{equation}\n\n\\begin{eqnarray}\n\\alpha_{\\cmd} &=& \\alpha_{\\nom} \\\\\n\\Delta {C_L}_{\\cmd} &=& 0 \\\\\n\\beta_{\\cmd} &=& 0 \\\\\n{\\phi_t}_{\\cmd} &=& \\sin^{-1} \\left(\n\\frac{2 m \\kappa_{\\cmd}^{\\aero}}{\\rho A {C_L}_{\\nom}} +\n\\frac{C_{Y_0}}{{C_L}_{\\nom}} \\right)\n\\end{eqnarray}\n\n\\end{document}\n", "meta": {"hexsha": "2bfa0060688155e92560ea4f02905a35f50d3bda", "size": 6297, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/control/crosswind/crosswind_curvature.tex", "max_stars_repo_name": "leozz37/makani", "max_stars_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1178, "max_stars_repo_stars_event_min_datetime": "2020-09-10T17:15:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:59:35.000Z", "max_issues_repo_path": "documentation/control/crosswind/crosswind_curvature.tex", "max_issues_repo_name": "leozz37/makani", "max_issues_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-22T05:22:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-22T05:22:35.000Z", "max_forks_repo_path": "documentation/control/crosswind/crosswind_curvature.tex", "max_forks_repo_name": "leozz37/makani", "max_forks_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 107, "max_forks_repo_forks_event_min_datetime": "2020-09-10T17:29:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T09:00:14.000Z", "avg_line_length": 35.1787709497, "max_line_length": 88, "alphanum_fraction": 0.6682547245, "num_tokens": 2184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778403, "lm_q2_score": 0.672331705744791, "lm_q1q2_score": 0.42586180301478016}}
{"text": "\\section{Optimization of Curry Programs}\n\nAfter the invocation of the Curry front end,\nwhich parses a Curry program and translates it into the intermediate FlatCurry\nrepresentation, \\CYS applies a transformation\nto optimize Boolean equalities occurring in the Curry program.\nThe ideas and details of this optimization are described\nin \\cite{AntoyHanus15LOPSTR}.\nTherefore, we sketch only some basic ideas and options\nto influence this optimization.\n\nConsider the following definition of the operation \\code{last}\nto extract the last element in list:\n%\n\\begin{curry}\nlast xs | xs == _++[x]\n        = x\n where x free\n\\end{curry}\n%\nIn order to evaluate the condition \\ccode{xs == \\us{}++[x]},\nthe Boolean equality is evaluated to \\code{True} or \\code{False}\nby instantiating the free variables \\code{\\us} and \\code{x}.\nHowever, since we know that a condition must be evaluated to\n\\code{True} only and all evaluations to \\code{False} can be ignored,\nwe can use the constrained equality to obtain a more efficient program:\n%\n\\begin{curry}\nlast xs | xs =:= _++[x]\n        = x\n where x free\n\\end{curry}\n%\nSince the selection of the appropriate equality operator\nis not obvious and might be tedious, \\CYS encourages\nprogrammers to use only the Boolean equality operator \\ccode{==}\nin programs.\nThe constraint equality operator \\ccode{=:=} can be considered\nas an optimization of \\ccode{==} if it is ensured that only\npositive results are required, e.g., in conditions of program rules.\n\nTo support this programming style, \\CYS has a built-in optimization phase\non FlatCurry files. For this purpose, the optimizer analyzes\nthe FlatCurry programs for occurrences of \\ccode{==}\nand replaces them by \\ccode{=:=} whenever the result \\code{False}\nis not required.\nThe usage of the optimizer can be influenced by setting\nthe property flag \\code{bindingoptimization} in the\nconfiguration file \\code{\\curryrc}.\nThe following values are recognized for this flag:\n\\begin{description}\n\\item[\\code{no}:] Do not apply this transformation.\n\\item[\\code{fast}:] This is the default value.\nThe transformation is based on pre-computed values for\nthe prelude operations in order to decide whether the\nvalue \\code{False} is not required as a result of a Boolean equality.\nHence, the transformation can be efficiently performed\nwithout any complex analysis.\n\\item[\\code{full}:] Perform a complete ``required values'' analysis\nof the program (see \\cite{AntoyHanus15LOPSTR})\nand use this information to optimize programs.\nIn most cases, this does not yield better results so that\nthe \\code{fast} mode is sufficient.\n\\end{description}\n%\nHence, to turn off this optimization, one can either modify\nthe flag \\code{bindingoptimization} in the\nconfiguration file \\code{\\curryrc} or dynamically pass this change\nto the invocation of \\CYS by\n\\begin{quote}\n\\ldots{} \\code{-Dbindingoptimization=no} \\ldots\n\\end{quote}\n", "meta": {"hexsha": "c0a4f67dd0e5c4304c5a2088fa91ef7d80210555", "size": 2877, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/tooldocs/transbooleq/manual.tex", "max_stars_repo_name": "DouglasRMiles/pakcs_lib", "max_stars_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-17T23:02:46.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-17T23:02:46.000Z", "max_issues_repo_path": "docs/src/tooldocs/transbooleq/manual.tex", "max_issues_repo_name": "DouglasRMiles/pakcs_lib", "max_issues_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/src/tooldocs/transbooleq/manual.tex", "max_forks_repo_name": "DouglasRMiles/pakcs_lib", "max_forks_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-09T16:02:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T16:02:18.000Z", "avg_line_length": 39.4109589041, "max_line_length": 78, "alphanum_fraction": 0.774070212, "num_tokens": 704, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.42586179885612185}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{bssn-eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.62.044034 equation (14)}\n\nThe advice given by Miguel Alcubierre, Bernd Brugmann etal (Phys Rev D (67) 084023,\n2nd-3rd paragraph on pg. 084023-4)\n\n\\begin{quote}\n... if one wants to achieve numerical stability. In the computer code we do not use the numerically\nevolved ${\\bar{\\Gamma}}^i$ in all places, but we follow this rule:\n\nPartial derivatives $\\partial_j {\\bar{\\Gamma}}^i$ are computed as finite differences\nof the independent variables ${\\bar{\\Gamma}}^i$ that are evolved using ...\n\\end{quote}\n\nThe Einstein Toolkit code uses the same rule -- the only place where the \\emph{evolved} ${\\bar{\\Gamma}}^i$\nare used is in computing the $\\partial_j {\\bar{\\Gamma}}^i$ terms in the equation\nfor ${\\bar{R}}_{ij}$, that is equation (18) of the Phys Rev D (62) 044034 paper.\n\n\\clearpage\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'bssn-eqtns-14.json'\n   cdblib.create (jsonfile)\n\n   # --------------------------------------------------------------------------\n\n   Rphi := -2 DBar_{a b}{\\phi} - 2 gBar_{a b} gBar^{c d} DBar_{c d}{\\phi}\n           +4 DBar_{a}{\\phi} DBar_{b}{\\phi} - 4 gBar_{a b} gBar^{c d} DBar_{c}{\\phi} DBar_{d}{\\phi}.\n\n                                                           # cdb(eq15.prd,Rphi)\n\n   RBar := - (1/2) gBar^{l m} \\partial_{l m}{gBar_{a b}}\n           + (1/2) gBar_{k a} \\partial_{b}{GammaBar^{k}}\n           + (1/2) gBar_{k b} \\partial_{a}{GammaBar^{k}}\n           + (1/2) GammaBar^{k} GammaBar_{a b k}\n           + (1/2) GammaBar^{k} GammaBar_{b a k}\n           + gBar^{l m} gBar^{k e} (  GammaBar_{e l a} GammaBar_{b k m}\n                                    + GammaBar_{e l b} GammaBar_{a k m}\n                                    + GammaBar_{k a m} GammaBar_{e l b}).\n\n                                                           # cdb(eq18.prd,RBar)\n\n   defRab := R_{a b} -> @(Rphi) + @(RBar).\n\n   Rab := RBar_{a b} + Rphi_{a b}.                         # cdb(eq14.01,Rab)\n   Rab := R_{a b}.                                         # cdb(eq14.00,Rab)\n\n   substitute (Rab, defRab)                                # cdb(eq14.02,Rab)\n   substitute (Rab, defDBar1)                              # cdb(eq14.03,Rab)\n   substitute (Rab, defDBar2)                              # cdb(eq14.04,Rab)\n   substitute (Rab, defGamma2GammaBar)                     # cdb(eq14.05,Rab)\n   distribute (Rab)                                        # cdb(eq14.06,Rab)\n   eliminate_kronecker (Rab)                               # cdb(eq14.07,Rab)\n\n   Rab = product_sort (Rab)                                # cdb(eq14.08,Rab)\n\n   rename_dummies (Rab)                                    # cdb(eq14.09,Rab)\n   canonicalise   (Rab)                                    # cdb(eq14.10,Rab)\n\n   foo := GammaBar^{a} GammaBar_{b c a} -> gBar^{d e} GammaBar^{a}_{d e} GammaBar_{b c a}.\n\n   substitute (Rab, foo)                                   # cdb(eq14.11,Rab)\n   substitute (Rab, defGBarSq)                             # cdb(eq14.12,Rab)\n   substitute (Rab, defGammaBarD)                          # cdb(eq14.13,Rab)\n   substitute (Rab, defGammaBarU)                          # cdb(eq14.14,Rab)\n   distribute (Rab)                                        # cdb(eq14.15,Rab)\n\n   foo := \\partial_{a}{gBar_{b c}} gBar^{b c} -> 0.   # follows from det(g) = 1\n\n   substitute   (Rab,foo)                                  # cdb(eq14.16,Rab)\n   canonicalise (Rab)                                      # cdb(eq14.17,Rab)\n\n   foo := gBar^{b e} gBar^{c f} \\partial_{a}{gBar_{b c}}  -> - \\partial_{a}{gBar^{e f}}.\n   bah := gBar^{e b} gBar^{f c} \\partial_{a}{gBar_{b c}}  -> - \\partial_{a}{gBar^{e f}}.\n   moo := gBar^{e b} gBar^{c f} \\partial_{a}{gBar_{b c}}  -> - \\partial_{a}{gBar^{e f}}.\n\n   substitute (Rab,foo)                                    # cdb(eq14.18,Rab)\n   substitute (Rab,bah)                                    # cdb(eq14.19,Rab)\n   substitute (Rab,moo)                                    # cdb(eq14.20,Rab)\n\n   Rab = product_sort (Rab)                                # cdb(eq14.21,Rab)\n                                                           # cdb(eq14.99,Rab)\n\n   defRab := R_{a b} -> @(Rab).   # used later in bssn-ricci-scalar.tex\n\n   cdblib.put ('Rab',Rab,jsonfile)\n   cdblib.put ('defRab',defRab,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      \\cdb{eq14.00} = \\Cdb*{eq14.01}\n                    = \\Cdb*{eq14.02}\n                    = \\Cdb*{eq14.03}\n                    = \\Cdb*{eq14.04}\n                    = \\Cdb*{eq14.05}\n                    = \\Cdb*{eq14.06}\n                    = \\Cdb*[\\hskip 2cm\\hfill]{eq14.07}\n                    = \\Cdb*{eq14.08}\n                    = \\Cdb*{eq14.09}\n                    = \\Cdb*{eq14.10}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      \\cdb{eq14.00} = \\Cdb*{eq14.11}\n                    = \\Cdb*{eq14.12}\n                    = \\Cdb*{eq14.13}\n                    = \\Cdb*[\\hskip 2cm\\hfill]{eq14.14}\n                    = \\Cdb*{eq14.15}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      \\cdb{eq14.00} = \\Cdb*[\\hskip 2cm\\hfill]{eq14.16}\n                    = \\Cdb*[\\hskip 2cm\\hfill]{eq14.17}\n                    = \\Cdb*{eq14.18}\n                    = \\Cdb*{eq14.19}\n                    = \\Cdb*{eq14.20}\n                    = \\Cdb*{eq14.21}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\def\\gBar{{\\bar{g}}}\n\\def\\dgBar#1{{\\partial_{#1}}\\gBar}\n\nThere is a single term in this final expression that appears to be neither symmetric in $ab$ nor part of a symmetric pair, namely\n\\begin{gather*}\n   \\dgBar{b}_{cd} \\dgBar{a}^{cd}\n\\end{gather*}\nIt is, however, easy to show that this term is symmetric in $ab$. Start by noting that, for any $\\gBar_{ab}$,\n\\begin{align*}\n   \\dgBar{a}^{cd} = -\\gBar^{ce}\\gBar^{df}\\dgBar{a}_{ef}\n\\end{align*}\nNow contract both sides with $\\dgBar{b}_{cd}$ to obtain\n\\begin{align*}\n   \\dgBar{a}^{cd}\\dgBar{b}_{cd} = -\\gBar^{ce}\\gBar^{df}\\dgBar{a}_{ef}\\dgBar{b}_{cd}\n\\end{align*}\nThe right hand side is clearly symmetric in $ab$ and thus the left hand must also be symmtric in $ab$.\n\n\\end{document}\n", "meta": {"hexsha": "93a9d9ef77b17d1454fd78cef7889efd19bb1c79", "size": 6179, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bssn/cadabra/bssn-eqtns-14.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-numerical", "max_stars_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-25T11:36:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T11:36:06.000Z", "max_issues_repo_path": "bssn/cadabra/bssn-eqtns-14.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-numerical", "max_issues_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bssn/cadabra/bssn-eqtns-14.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-numerical", "max_forks_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8616352201, "max_line_length": 129, "alphanum_fraction": 0.4845444247, "num_tokens": 2017, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4258617946974637}}
{"text": "\\documentclass{article}\r\n\r\n\\usepackage[preprint]{./template/neurips_2020}\r\n\r\n\\usepackage[utf8]{inputenc} % allow utf-8 input\r\n\\usepackage[T1]{fontenc}    % use 8-bit T1 fonts\r\n\\usepackage{hyperref}       % hyperlinks\r\n\\usepackage{url}            % simple URL typesetting\r\n\\usepackage{booktabs}       % professional-quality tables\r\n\\usepackage{amsfonts}       % blackboard math symbols\r\n\\usepackage{nicefrac}       % compact symbols for 1/2, etc.\r\n\\usepackage{microtype}      % microtypography\r\n\\usepackage{physics}\r\n\\usepackage{amsmath}\r\n\r\n\r\n\\title{Chapter 1: Introduction and Overview}\r\n\r\n\\author{\r\n  John Martinez \\\\\r\n  \\texttt{john.r.martinez14@gmail.com} \\\\\r\n  % examples of more authors\r\n  % \\And\r\n  % Coauthor \\\\\r\n  % Affiliation \\\\\r\n  % Address \\\\\r\n  % \\texttt{email} \\\\\r\n  % \\AND\r\n  % Coauthor \\\\\r\n  % Affiliation \\\\\r\n  % Address \\\\\r\n  % \\texttt{email} \\\\\r\n  % \\And\r\n  % Coauthor \\\\\r\n  % Affiliation \\\\\r\n  % Address \\\\\r\n  % \\texttt{email} \\\\\r\n  % \\And\r\n  % Coauthor \\\\\r\n  % Affiliation \\\\\r\n  % Address \\\\\r\n  % \\texttt{email} \\\\\r\n}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n%\\begin{abstract}\r\n%  The abstract paragraph should be indented \\nicefrac{1}{2}~inch (3~picas) on\r\n%  both the left- and right-hand margins. Use 10~point type, with a vertical\r\n%  spacing (leading) of 11~points.  The word \\textbf{Abstract} must be centered,\r\n%  bold, and in point size 12. Two line spaces precede the abstract. The abstract\r\n%  must be limited to one paragraph.\r\n%\\end{abstract}\r\n\r\n\\section{Introduction}\r\n\r\n%%% Section 1.1\r\n\\subsection{Global Perspective}\r\nn/a\r\n\r\n%%% Section 1.2\r\n\\subsection{Quantum Bits}\r\nWhat is a qubit? Just as a classical bit has a \\emph{state} - either $0$ or $1$\r\n- a qubit also has a state. Two possible states for a qubit are the states\r\n$\\ket{0}$ and $\\ket{1}$, which as you might guess corresponds to the states\r\n$0$ and $1$ for a classical bit. The difference between bits and qubits is\r\nthat a qubit can be in a state \\emph{other} than $\\ket{0}$ or $\\ket{1}$. It\r\nis also possible to form \\emph{a linear combination} of states, often\r\ncalled \\emph{superpositions}:\r\n\r\n\\begin{center}\r\n  $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$\r\n\\end{center}\r\n\r\nWhere $\\alpha, \\beta \\in \\mathbb{C}$.  Unfortunately, we cannot examine a qubit\r\nto determine its quantum state, that is, the values of $\\alpha$ and\r\n$\\beta$.  Instead, quantum mechanics tells us that we can only aquire\r\nmuch more restricted information about the quantum state. When we measure a\r\nqubit we get either the result $0$, with probability $\\abs{\\alpha}^{2}$, or the\r\nresult $1$, with probability $\\abs{\\beta}^{2}$ with\r\n$\\abs{\\alpha}^{2} + \\abs{\\beta}^{2} = 1$, since probabilities must sum to $1$.\r\n\r\nThis equation can also be represented as \r\n\r\n\\begin{center}\r\n  $\\ket{\\psi} = \\cos(\\frac{\\theta}{2})\\ket{0} + e^{i\\phi}\\sin(\\frac{\\theta}{2})\\ket{1}$\r\n\\end{center}\r\n\r\n%%% Section 1.2.1\r\n\\subsubsection{Multiple Qubits}\r\nA two qubit system will have four \\emph{computational basis states} denoted\r\n$\\ket{00}, \\ket{01}, \\ket{10}, \\ket{11}$. The state vector describing two qubits is\r\n\r\n\\begin{center}\r\n  $\\ket{\\psi} = \\alpha_{00}\\ket{00} + \\alpha_{01}\\ket{01} + \\alpha_{10}\\ket{10} + \\alpha_{11}\\ket{11}$\r\n\\end{center}\r\nAnd again, the probabilities must sum to one, satisfying the condition\r\n$\\sum_{x \\in \\{0, 1\\}^{2}}{\\abs{\\alpha_{x}^{2}} = 1}$, where the notation\r\n'$x \\in \\{0, 1\\}^{2}$' means 'the set of strings of length two with each letter\r\nbeing either zero or one'.  Subsets of multi-qubit systems can be measured.\r\nMeasuring the first qubit of the above two qubit system gives $0$ with\r\nprobability $\\abs{\\alpha_{00}^{2}} + \\abs{\\alpha_{01}^{2}}$. The\r\npost-measurement state would then be\r\n\r\n\\begin{center}\r\n    $\\ket{\\psi'} = \\frac{\\alpha_{00}\\ket{00} + \\alpha_{01}\\ket{01} }{\\sqrt{\\abs{\\alpha_{00}^{2}} + \\abs{\\alpha_{01}^{2}}}}$\r\n\\end{center}\r\n\r\nAn important two qubit state is the \\emph{Bell state} or \\emph{EPR pair}, \r\n\r\n\\begin{center}\r\n    $\\frac{\\ket{00} + \\ket{11}}{\\sqrt{2}}$\r\n\\end{center}\r\n\r\nBell states are important because their measurement outcomes are\r\n\\emph{correlated}.\r\n\r\n%%% Section 1.3\r\n\\subsection{Quantum Computation}\r\n\r\n%%% Section 1.3.1\r\n\\subsubsection{Single Qubit Gates}\r\nThe quantum $\\mathbf{NOT}$ gate acts \\emph{linearly}.\r\n\\begin{center}\r\n  $\\mathit{X} \\equiv \\begin{bmatrix}\r\n     1 & 0 \\\\\r\n     0 & 1\r\n   \\end{bmatrix}$\r\n\\end{center}\r\nIf we write the quantum state $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$ in\r\nvector notation\r\n\\begin{center}\r\n    $\\begin{bmatrix}\r\n       \\alpha \\\\\r\n       \\beta\r\n     \\end{bmatrix}$\r\n\\end{center}\r\nthen the $\\mathbf{NOT}$ gate operation can be represented as\r\n\\begin{center}\r\n  $\\mathit{X} \\begin{bmatrix}\r\n     \\alpha \\\\\r\n     \\beta\r\n   \\end{bmatrix} = \\begin{bmatrix}\r\n     \\beta \\\\\r\n     \\alpha\r\n   \\end{bmatrix}$\r\n\\end{center}\r\nThere is a restriction on the the type of matrix that can be a quantum gate and\r\nthat is that the operation must preserve the normalization condition (i.e.\r\n$\\abs{\\alpha}^{2} + \\abs{\\beta}^{2} = 1$). The appropriate condition on the\r\nmatrix representing the gate is that the matrix $\\mathit{U}$ describing the\r\nsingle qubit gate must be \\emph{unitary}, that is\r\n$\\mathit{U}^{\\dagger}\\mathit{U} = \\mathit{I}$ (where $\\mathit{X}^{\\dagger}$\r\nis the transpose of the complex conjugate of $\\mathit{X}$).\r\n\r\nOther important single qubit quantum gates are the $\\mathit{Z}$ gate\r\n\\begin{center}\r\n  $\\mathit{Z} \\equiv \\begin{bmatrix}\r\n    1 & 0 \\\\\r\n    0 & -1\r\n  \\end{bmatrix}$\r\n\\end{center}\r\nwhich leaves $\\ket{0}$ unchanged and flips the sign of $\\ket{1}$, and the\r\n\\emph{Hadamard} gate\r\n\\begin{center}\r\n  $\\mathit{H} \\equiv \\frac{1}{\\sqrt{2}}\\begin{bmatrix}\r\n    1 & 1 \\\\\r\n    1 & -1\r\n  \\end{bmatrix}$\r\n\\end{center}\r\nThe Hadamard operation is just a rotation of the sphere about the $\\hat{y}$\r\naxis by $90^{\\circ}$, followed by a rotation about the $\\hat{x}$ axis by\r\n$180^{\\circ}$.\r\n\r\n%%% Section 1.3.2\r\n\\subsubsection{Multiple Qubit Gates}\r\nThe prototypical multi-qubit logic gate is the \\emph{controlled}-$\\mathbf{NOT}$\r\nor $\\mathbf{CNOT}$ gate.\r\n\r\n\\begin{center}\r\n  $ \\mathit{U_{\\mathit{CN}}} \\equiv \\begin{bmatrix}\r\n    1 & 0 & 0 & 0 \\\\\r\n    0 & 1 & 0 & 0 \\\\\r\n    0 & 0 & 0 & 1 \\\\\r\n    0 & 0 & 1 & 0\r\n  \\end{bmatrix}$\r\n\\end{center}\r\nThe gate has two inputs, a \\emph{control} qubit and a \\emph{target} qubit. If\r\nthe control qubit is set to $0$, then the target qubit is left alone. If the\r\ncontrol qubit is set to $1$, then the target qubit is flipped.\r\n\r\n\\begin{center}\r\n  $\\ket{00} \\to \\ket{00}$;\r\n  $\\ket{01} \\to \\ket{01}$;\r\n  $\\ket{10} \\to \\ket{11}$;\r\n  $\\ket{11} \\to \\ket{10}$;\r\n\\end{center}\r\n\r\n%%% Section 1.3.3\r\n\\subsubsection{Measurement in non-standard basis}\r\nThe states $\\ket{0}$ represent just one of many possible choices of basis\r\nstates for a qubit. Another possible choice is\r\n\r\n\\begin{center}\r\n  $\\ket{+} \\equiv \\frac{(\\ket{0} + \\ket{1})}{\\sqrt{2}} $ and\r\n  $\\ket{-} \\equiv \\frac{(\\ket{0} - \\ket{1})}{\\sqrt{2}} $\r\n\\end{center}\r\n\r\n%%% Section 1.3.4\r\n\\subsubsection{Quantum Circuits?}\r\n%%% Need to learn how to draw circuits in LaTex\r\n\r\n%%% Section 1.3.5\r\n\\subsubsection{Copying Circuit?}\r\n\r\n%%% Section 1.3.6\r\n\\subsubsection{Example: Bell States}\r\n\r\n\\begin{center}\r\n  $\\ket{\\beta_{00}} = \\frac{\\ket{00} + \\ket{11}}{\\sqrt 2}$;\r\n\r\n  $\\ket{\\beta_{01}} = \\frac{\\ket{01} + \\ket{10}}{\\sqrt 2}$;\r\n\r\n  $\\ket{\\beta_{10}} = \\frac{\\ket{00} - \\ket{11}}{\\sqrt 2}$;\r\n\r\n  $\\ket{\\beta_{11}} = \\frac{\\ket{01} - \\ket{10}}{\\sqrt 2}$;\r\n\\end{center}\r\nThese are known as the \\emph{Bell states}, or \\emph{EPR states or pairs}.\r\n\r\n%%% Section 1.4\r\n\\subsection{Quantum Algorithms}\r\n\r\n%%% Section 1.4.1\r\n\\subsubsection{Classical Computations on a Quantum Computer?}\r\n\r\n%%% Section 1.4.2\r\n\\subsubsection{Quantum Parallelism}\r\nSuppose $f(x) : \\{0, 1\\} \\to \\{0, 1\\}$ is a function with a one-bit domain\r\nand range. A convenient way of computing this function on a quantum computer is\r\nto consider a two qubit quantum computer which starts in the state $\\ket{x, y}$.\r\nIt is possible with a sequence of gates to turn this into the state\r\n$U_f : \\ket{x, y} \\to \\ket{x, y \\oplus f(x)}$.  In particular, if we apply\r\nthe Hadamard gate to\r\n$\\mathit{H} \\ket{0}$ we obtain $\\frac{\\ket{0} + \\ket{1}}{\\sqrt 2}$. Now\r\napplying\r\n$U_f$ we get $\\frac{\\ket{y, y \\oplus f(0)} + \\ket{y, y \\oplus f(1)}}{\\sqrt 2}$.\r\nAnd now letting $y = \\ket{0}$, we get\r\n$\\frac{\\ket{0, f(0)} + \\ket{0, f(1)}}{\\sqrt 2}$.  This is a remarkable state,\r\nin that we have information about $f(0)$ and $f(1)$ simultaneously!\r\n\r\nThis procedure can me generalized to functions on an arbitrary number of bits,\r\nby using the \\emph{Walsh-Hadamard transform}. For $n = 2$ qubits we get\r\n\r\n\\begin{center}\r\n  $\\frac{\\ket{0} + \\ket{1}}{\\sqrt 2}\\frac{\\ket{0} + \\ket{1}}{\\sqrt 2} = \r\n   \\frac{\\ket{00} + \\ket{01} + \\ket{10} + \\ket{11}}{2}$\r\n\\end{center}\r\nWe can write $\\mathit{H}^{\\otimes 2}$ to denote the parallel action of two\r\nHadamard gates. More generally, the result of performing the Walsh-Hadamard\r\ntransform on $n$ qubits initially in the $\\ket{0}$ state is\r\n\r\n\\begin{center}\r\n  $\\frac{1}{\\sqrt{2^{n}}}\\displaystyle\\sum_{x} \\ket{x}$\r\n\\end{center}\r\nAnd we write $\\mathit{H}^{\\otimes n}$ to denote this operation.\r\n\r\n% \\begin{center}\r\n% \\end{center}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "b3775de22cf1e487164f3d130aa6dd666cda3da2", "size": 9204, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "one/notes.tex", "max_stars_repo_name": "gobrewers14/quantum-computing-notes", "max_stars_repo_head_hexsha": "af3d11703ecafd2a45da31b1a74112fe3937af35", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "one/notes.tex", "max_issues_repo_name": "gobrewers14/quantum-computing-notes", "max_issues_repo_head_hexsha": "af3d11703ecafd2a45da31b1a74112fe3937af35", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "one/notes.tex", "max_forks_repo_name": "gobrewers14/quantum-computing-notes", "max_forks_repo_head_hexsha": "af3d11703ecafd2a45da31b1a74112fe3937af35", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8382352941, "max_line_length": 124, "alphanum_fraction": 0.6446110387, "num_tokens": 3060, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4258617937095075}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{The equation of state and degenerate gasses}\n\n\\marginpar{Tuesday\\\\ 2020-10-20, \\\\ compiled \\\\ \\today}\n\n% Still no answer about the quadrupole stuff\n\n% 151879\n\nWe move away from the relativistic realm, and treat the more classical Equation of State (EoS). \nIn general \\(P\\) could be a function of \\(\\rho \\), \\(\\mu \\), \\(T\\) and other variables. \nAn often-used one is \\(P = P (\\rho )\\); also sometimes we use \\(u = u(\\rho )\\), where \\(u\\) is the internal energy density. \n\nWe will treat the equation of state of a completely degenerate gas. \n\nLet us start for a very simple system: a \\textbf{hydrogen plasma}. \nIt is a collection of \\(e^{-}\\) and protons \\(p\\). \n\nWe have complete collisional ionization for \\(T \\gtrsim \\SI{e5}{K}\\). \nUnder which conditions is this plasma relativistic or nonrelativistic? This is shown as the blue area in figure \\ref{fig:relativisticity_degeneracy}.\n\nThe electrons are surely relativistic if \\(k_B T \\gtrsim m_e c^2\\), which corresponds to \\(T \\gtrsim \\SI{6e9}{K}\\). \nFor the protons, an analogous equation yields \\(T \\gtrsim \\SI{e13}{K}\\): these temperatures are basically never reached for realistic astrophysical scenarios. \n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\textwidth]{figures/relativisticity_degeneracy.pdf}\n\\caption{}\n\\label{fig:relativisticity_degeneracy}\n\\end{figure}\n\nIn the region of \\(\\SI{e5}{K} \\lesssim T \\lesssim \\SI{e9}{K}\\) (for low densities), the plasma will be ionized but not relativistic. \n\nThe ideal gas law for the electrons reads \\(P_e = n_e k_B T\\), for the ions \\(P_i = n_i k_B T\\). \nHowever, electrons are much lighter than protons, so for the same forces they will accelerate more, so they will radiate away more energy. \n\nAnother complication is the following: consider a collection of \\(N\\) ionic species, then for each of these (labelled by \\(k\\)) we will have \\(P_{i, k}= n_{i, k} k_B T\\). \nThe total pressure can be calculated by summing over all of these, plus the electrons: \n%\n\\begin{align}\nP &= n_e k_B T + \\sum _{k} n_{i, k} k_B T = k_B T \\qty(n_e + \\sum_k n_{i, k})  \\\\\n&= \\frac{nk_B T}{\\mu }\n\\,,\n\\end{align}\n%\nwhere \\(\\mu \\) is the \\emph{mean molecular weight}, calculated through the total baryonic number density \\(n\\): \n%\n\\begin{align}\n\\mu = \\qty[\\frac{n_e}{n} + \\frac{\\sum _{k} n_{i, k}}{n} ]^{-1}\n\\,.\n\\end{align}\n\nFor a pure hydrogen plasma, we have one electron per proton, so the baryonic density is equal to the hydrogen atom density and we find \n%\n\\begin{align}\n\\mu_{\\ce{H}} = \\qty[1 + 1]^{-1} = \\frac{1}{2}\n\\,.\n\\end{align}\n\nFor a pure helium plasma we have two electrons per Helium nucleus, which contains 4 baryons: so, \n%\n\\begin{align}\n\\mu_{\\ce{^{4}He}} = \\qty[ \\frac{2}{4} + \\frac{4}{4}]^{-1} = \\frac{4}{3}\n\\,.\n\\end{align}\n\nThis holds under the assumption that the plasma behaves like an ideal gas, and that the electrons and protons are nonrelativistic. \nThere is a crucial reason why the first assumption fails: \\textbf{degeneracy}.\n\nElectrons obey Dirac statistics, and if the density is high enough they can behave very similarly to the \\(T = 0\\) limit even for high temperatures. The region in which they behave like a fully degenerate gas is shown in pink in figure \\ref{fig:relativisticity_degeneracy}. \n\nThe distribution function for a system of fermions reads \n%\n\\begin{align}\n\\frac{ \\dd{N}}{ \\dd[3]{x} \\dd[3]{p}} = \\frac{2}{h^3} \\underbrace{\\qty[\\exp(\\frac{E }{k_B T} - \\alpha ) + 1]^{-1}}_{f}\n\\,.\n\\end{align}\n\nHere, the \\emph{degneracy parameter} is \\(\\alpha = \\mu / k_B T\\), where \\(\\mu  \\) is the chemical potential. \nThe energy is expressed as \\(E = \\sqrt{m^2 c^{4} + p^2 c^2}\\).\n\nIf we want to compute \\(\\alpha \\), we can just integrate: \n%\n\\begin{align}\nn &= \\int_{\\mathbb{R}^3} \\frac{ \\dd{N}}{ \\dd[3]{x} \\dd[3]{p}} \\dd[3]{p}  \\\\\n&= \\frac{2}{h^3} \\int_0^{\\infty } \n\\qty[\\exp(\\frac{E }{k_B T} - \\alpha ) + 1]^{-1} 4 \\pi p^2 \\dd{p}\n\\,.\n\\end{align}\n\nThis integral can be computed for any value of \\(\\alpha \\) and \\(T\\): we then find \\(n = n(\\alpha , T)\\). Inverting this relation, we find \\(\\alpha = \\alpha (n, T)\\). \n\nThe logarithm of the absolute value of \\(\\alpha k_B T = \\mu \\) can be plotted against \\(\\log n\\) for different values of the temperature \\(T\\). For each \\(T\\), there is a cusp: \\(\\alpha \\) changes sign. It can become very big and positive or very big and negative. \n\n% \\todo[inline]{Do plot!}\n\nLet us start with the case \\(\\abs{\\alpha } \\gg 1 \\) and \\(\\alpha < 0\\): this corresponds to low \\(n\\), high \\(T\\). \nThen, the \\(- \\alpha \\) appearing in the distribution is large and positive: then, the distribution looks like \\(f \\sim \\exp(- \\frac{E}{k_B T})\\), the Maxwell-Boltzmann distribution. \nThe gas is behaving like an ideal gas. \n\nAnother option is \\(\\abs{\\alpha } \\gg 1\\), \\(\\alpha > 0\\). This is the case in which we have low \\(T\\), high \\(n\\). Even in the \\(T \\to 0\\) limit, the product \\(\\alpha k_B T \\) stays finite: this is a function of \\(n\\), and is called \\(E _F\\).\n\nThe distribution then looks like \\(f \\sim \\qty[\\exp( (E - E_F) / k_B T) + 1]^{-1} \\to [E \\leq E_F] = [p \\leq p_F]\\) in the limit \\(T \\to 0\\).\n(I use the Iverson bracket: \\([\\text{proposition}]\\) is 1 if the proposition is true, 0 if it is false).  \n\nThe higher \\(n\\) is, the higher the \\(T\\) for which the behavior is close to the \\(T \\to 0\\) limit. \n\nIn the \\(T \\to 0\\) limit, we can do the integration analytically: this yields an explicit expression for \\(n\\) in terms of the Fermi momentum \\(p_F\\) corresponding to the Fermi energy \\(E_F\\): \n%\n\\begin{align}\nn &= \\frac{2}{h^3} \\int [p \\leq p_F] 4 \\pi p^2 \\dd{p} = \\frac{8 \\pi p_F^3}{3 h^3} \\\\\np_F &= \\sqrt[3]{\\frac{3n }{8 \\pi }} h\n\\,.\n\\end{align}\n\nThis momentum is a characteristic of \\(n\\) independently of the temperature: for \\(T > 0\\) it will not be a hard limit anymore, but it is still a good descriptor of the Fermi gas. \n\nWe can write \n%\n\\begin{align}\nE_F = \\sqrt{m^2 c^{4} + p_F^2 c^2} = \\sqrt{1 + x_F^2} m c^2\n\\,,\n\\end{align}\n%\nwhere \\(x_F = p_F / mc^2\\).\nFor a nonrelativistic particle distribution \\(x_F \\ll 1\\), so \\(E_F \\approx mc^2 + x_F^2 mc^2/2\\). \nThe dependence on the number density of the kinetic part is \\(\\sim x_F^{2} \\sim n^{2/3}\\). \n\nOn the other hand, in the ultrarelativistic limit \\(E_F \\approx x_F mc^2 \\sim x_F \\sim n^{1/3}\\).\n\nThis is the reason why in figure \\ref{fig:relativisticity_degeneracy} the pink boundary curves down in the blue (relativistic region). \n\nIt is useful to define this quantity in terms of proper density, in \\SI{}{g/cm^3}, instead of number density.\n\nWe have \n%\n\\begin{align}\nx_F = \\frac{p_F}{mc} = \\qty( \\frac{3h^3}{8 \\pi })^{1/3} \\frac{1}{mc} n^{1/3}\n\\,;\n\\end{align}\n%\nthe only degenerate species we will consider will be electrons, so the \\(n\\) in this equation should be substituted for \\(n_e\\), which we can express\nby multiplying above and below by the mean baryon mass \\(m_b\\) multiplied by the baryon density \\(n\\), whose product is the baryonic mass density \\(\\rho \\):\n%\n\\begin{align}\nn_e = \\frac{n_e m_b n}{n m_b} \n= \\rho \\frac{n_e}{n} \\frac{1}{m_b}\n= \\frac{\\rho}{\\mu _e m_b} \n\\,,\n\\end{align}\n%\nwhich gives us: \n%\n\\begin{align}\nx_F &\\sim \\qty( \\frac{n_e}{\\SI{6e35}{m^{-3}}})^{1/3} \\\\\nx_F &\\sim \\qty( \\frac{\\rho / \\mu _e}{\\SI{e9}{kg / m^3}})^{1/3}\n% x_F &=\\sim \\num{e-2} \\qty(\\frac{\\rho }{m_e})^{1/3}\n\\,.\n\\end{align}\n\n% \\todo[inline]{Are we sure about this? I think I missed something.}\nThis corresponds to the vertical delimiter in figure \\ref{fig:relativisticity_degeneracy}: even at cold \\(T\\) for high enough densities the gas becomes relativistic.\n\nThe internal energy density \\(u\\) (not denoted as \\(\\rho \\) to avoid confusion between it and the mass density) is computed in general as \n%\n\\begin{align}\nu &= \\frac{2}{h^3}\\int E(p) \\frac{ \\dd{N}}{ \\dd[3]{x} \\dd[3]{p}} \\dd[3]{p} \n\\,,\n\\end{align}\n%\nwhich in our case (complete degeneracy) is \n%\n\\begin{align}\nu &= \\frac{2}{h^3} \\int_{0}^{p_F} \\sqrt{m^2c^{4} + p^2c^2} 4 \\pi p^2 \\dd{p}  \\\\\n&= \\frac{8}{h^3} \\pi  mc^2 (mc)^3 \\int_0^{p_F} \\sqrt{1 + x^2} x^2 \\dd{x}  \\\\\n&= \\frac{8 \\pi m^4 c^{6}}{h^3} \\frac{x_F^{4}}{4} I(x_F)\n\\,,\n\\end{align}\n%\nwhere \\(I(x_F)\\) can be computed analytically, but it is of order 1 as can be seen by the asymptotics of the integral. \n\nThe integral reads \n%\n\\begin{align}\n\\int_0^{p_F} \\sqrt{1 + x^2} x^2 \\dd{x} &= \\frac{1}{8} \\qty[x_F (1 + 2 x_F)^2 \\sqrt{1 + x_F^2} - \\log(x_F + \\sqrt{1 + x_F^2})]  \\\\\n&\\overset{\\text{def}}{=} \\frac{x_F^{4}}{4} I(x_F)\n\\,.\n\\end{align}\n\nFor the pressure we have a similar integral, which however is more complicated from the conceptual point of view. \n\nThe first law of thermodynamics states that \n%\n\\begin{align}\n\\dd{U} + p \\dd{V} = 0\n\\,,\n\\end{align}\n%\nas long as the transformation does not exchange heat with its surroundings. \nNote that \\(\\dd{u} = \\dd{(U/ V)} = V^{-1} \\dd{U} - U V^{-2} \\dd{V}\\), which means that \n%\n\\begin{align}\n\\frac{ \\dd{U}}{V} = \\dd{u} + \\frac{u}{V} \\dd{V}\n\\,.\n\\end{align}\n\nSubstituting into the first law of thermodynamics, \n%\n\\begin{align}\n\\dd{u} + \\frac{U}{V} \\dd{V} + P \\frac{\\dd{V}}{V} &= 0  \\\\\n\\dd{u} + \\qty( \\frac{U}{V} + P) \\frac{ \\dd{V}}{V} &= 0\n\\,,\n\\end{align}\n%\nbut since \\(V \\propto 1/n\\) we have \n%\n\\begin{align}\n\\frac{ \\dd{V}}{V} = - \\frac{ \\dd{n}}{n}\n\\,.\n\\end{align}\n\nSubstituting this in, we get \n%\n\\begin{align}\n\\dd{u} - (P+u) \\frac{ \\dd{n}}{n} = 0 \n\\,.\n\\end{align}\n\nThis means that \n%\n\\begin{align}\nn \\frac{\\dd{u}}{ \\dd{n}} = P + u\n\\,,\n\\end{align}\n%\nwhich allows us to compute the pressure! \nThe only step remaining is to replace \\(\\dd{n} / n\\) with an expression in terms of \\(x_F\\), which is \n%\n\\begin{align}\n\\frac{ \\dd{x_F}}{x_F} = 3 \\frac{ \\dd{n}}{n}\n\\,.\n\\end{align}\n\nThis finally yields \n%\n\\begin{align}\nP = \\frac{x_F}{3} \\dv{u}{x_F} - u\n\\,.\n\\end{align}\n\nThen we are almost done: we can compute the pressure with \\(u\\), for which we have an analytic expression, and \\(\\dv*{u}{x_F}\\), which we can easily find since the original expression for \\(u\\) was an integral in \\(\\dd{x_F}\\), from which we can read off the integrand. \n\nThis yields \n%\n\\begin{align}\nP &= \\frac{8 \\pi m^4 c^{5}}{h^3} \\qty[ \n    \\frac{1}{3} x_F^3 \\sqrt{1 + x_F^2 } \n    - \\frac{1}{8} \\qty(x_F (1 + 2 x_F)^2 \\sqrt{1 + x_F^2} \n    - \\log(x_F + \\sqrt{1 + x_F^2}))\n]  \\\\\n&= \\frac{m^4 c^{5} \\pi }{h^3}\n\\qty[\n    x_F \\sqrt{1 + x_F^2}\n    \\qty( \\frac{8}{3} x_F^2 - \\qty(1 + 2 x_F^2))\n    + \\log(x_F + \\sqrt{1 + x_F^2})\n]  \\\\\n&= \\frac{m^4 c^{5} \\pi }{h^3} \\qty[\n    x_F \\sqrt{1+ x_F^2} \n    \\qty( \\frac{2}{3} x_F^2 - 1)\n    +\n    \\log(x_F + \\sqrt{1 + x_F^2})\n]\n\\,.\n\\end{align}\n\n\\end{document}\n", "meta": {"hexsha": "b08b195ff4435afc2f8809775123d44b798c104f", "size": 10514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/compact_objects/oct20.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/compact_objects/oct20.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/compact_objects/oct20.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 37.6845878136, "max_line_length": 274, "alphanum_fraction": 0.6428571429, "num_tokens": 3785, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.42586178955084947}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage{float}\n\\usepackage{subfigure}\n\\usepackage{subfloat}\n\n\\title{CS294 Deep RL Assignment 2: Policy Gradients}\n\n\\author{Mohamed Khodeir}\n\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\n\\section*{Problem 1. State Dependent Baselines}\n\\subsection*{(a)}\n% I will use the notation $\\tau_{t+1}^{(s_t,a_t)}$ to refer to the remainder of a trajectory that passes through $s_t, a_t$\n% $$ \\Sigma_{t=1}^{T} E_{\\tau \\sim P_{\\theta}(\\tau)}[ \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)] $$\n\nAs given in the question, we can use the chain rule to deconstuct $P_\\theta(\\tau)$ as: \n$$P_\\theta(\\tau) = P_{\\theta}(s_t, a_t) P_\\theta(\\tau/s_t,a_t | s_t, a_t)$$\n\nWe can then use the law of iterated expectations to express the expectation over $\\tau$ as:\n\n$$  E_{\\tau/s_t,a_t \\sim P_\\theta(\\tau/s_t,a_t | s_t, a_t)}[ E_{(s_t, a_t) \\sim P_{\\theta}(s_t, a_t)}[\\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)]] $$\n\n% The expression inside the inner expectation is constant with respect to $\\tau_{t+1}^{(s_t,a_t)}$ so the whole expression just reduces to:\n\nLooking just at the inner expectation, we see:\n\n$$  E_{(s_t, a_t) \\sim P_{\\theta}(s_t, a_t)}[ \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)] $$\n\n\n%  as a sum:\n\n% $$  \\int_{(s_t, a_t)}  P_{\\theta}(s_t, a_t)( \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)) $$\n\nExpanding the expectation, we can rewrite that as a nested integral, the first over $s_t$ and the second over $a_t$. We can also substitute the full form of $P_{\\theta}(s_t, a_t)$  as a product of the policy and the state marginal.\n\n$$  \\int_{s_t} \\int_{a_t}  P_{\\theta}(s_t)\\pi_\\theta(a_t | s_t) \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) $$\n\nTaking terms in common\n$$  \\int_{s_t}  P_{\\theta}(s_t) b(s_t) \\int_{a_t} \\pi_\\theta(a_t | s_t) \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) $$\n\nUsing the identity  $\\pi_\\theta(a_t | s_t) \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) = \\nabla_\\theta\n\\pi_\\theta (a_t|s_t)$, we get:\n\n$$  \\int_{s_t}  P_{\\theta}(s_t) b(s_t) \\int_{a_t} \\nabla_\\theta\n\\pi_\\theta (a_t|s_t) $$\n\nbecomes by linearity of differentiation:\n\n$$  \\int_{s_t}  P_{\\theta}(s_t) b(s_t) \\nabla_\\theta \\int_{a_t} \n\\pi_\\theta (a_t|s_t) $$\n\nThe inner integral, being an integral over a propper probility distribution just sums to 1.\n\n$$  \\int_{s_t}  P_{\\theta}(s_t) b(s_t) \\nabla_\\theta (1)$$\n\nbecomes\n\n$$  \\int_{s_t}  P_{\\theta}(s_t) b(s_t) (0) = 0$$\n.\nSo going back to the full equation in (12):\n\n$$\\sum_{t=1}^T E_{\\tau \\sim P_\\theta}[\\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)] =$$\n$$\\sum_{t=1}^T E_{\\tau/s_t,a_t \\sim P_\\theta(\\tau/s_t,a_t | s_t, a_t)}[ E_{(s_t, a_t) \\sim P_{\\theta}(s_t, a_t)}[\\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t)]] = $$\n$$\\sum_{t=1}^T E_{\\tau/s_t,a_t \\sim P_\\theta(\\tau/s_t,a_t | s_t, a_t)}[0] = $$\n$$ 0 $$\n\n\\subsection*{(b)}\n\n\\subsubsection*{(a)}\n\nLet's consider $P_\\theta(s_{t+1:T}, a_{t:T} | s_{1:t}, a_{1:t-1})$, the probability of the \"rest\" of the trajerctory after ($s_1, a_1, s_2, a_2, ... a_{t-1}, s_t$).\n\nBecause an MDP satisfies the Markov property, we know that given $s_t$ and $a_t$, the probability of $s_{t+1}$ is independent of previous states and actions.\n\nTherefore $P_\\theta(s_{t+1:T}, a_{t:T} | s_{1:t}, a_{1:t-1})$ should exactly equal $P_\\theta(s_{t+1:T}, a_{t:T} | s_t)$\n\nWe can show this using Bayes rule and by substituting the full form of $P_\\theta(\\tau)$, where $\\tau$ is the whole trajectory ($s_1, a_1, s_2, a_2, ... a_{T-1}, s_T$). See Appendix.\n\n\n% $$\\frac{P(s_1)\\prod_{i = 2}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}{P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}$$\n\\subsubsection*{(b)}\nI will start by rewriting the expression for the probability of the \"rest\" of the trajectory using bayes rule:\n$$P_\\theta(s_{t+1:T}, a_{t:T}|s_{1:t}, a_{1:t-1}) = P_\\theta(s_{t+1:T}, a_{t+1:T}|s_{1:t}, a_{1:t})P_\\theta(a_t | s_{1:t}, a_{1:t})$$\n\nThis allows us to write:\n$$P_\\theta(\\tau) = P_\\theta(s_{1:t}, a_{1:t-1}) P_\\theta(a_t | s_{1:t}, a_{1:t}) P_\\theta(s_{t+1:T}, a_{t+1:T}|s_{1:t}, a_{1:t})$$\n\nNote that, in our case $P_\\theta(a_t | s_{1:t}, a_{1:t}) = \\pi_\\theta(a_t|s_t)$.\n\n% $$E_{\\tau \\sim P_\\theta(\\tau)} \\bigg[ f \\bigg] = E_{(s_{1:t}, a_{1:t-1}) \\sim P_\\theta(s_{1:t}, a_{1:t-1})} \\bigg[ E_{a_t \\sim P_\\theta(a_t | s_{1:t}, a_{1:t})} \\big[E_{s_{t+1:T}, a_{t+1:T} \\sim P_\\theta(s_{t+1:T}, a_{t+1:T}|s_{1:t}, a_{1:t})} \\big[f\\big]\\big] \\bigg]$$\n$$E_{\\tau \\sim P_\\theta} \\bigg[  \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\bigg] =$$\n$$E_{(s_{1:t}, a_{1:t-1}) \\sim P_\\theta} \\bigg[ E_{a_t \\sim P_\\theta} \\big[E_{s_{t+1:T}, a_{t+1:T} \\sim P_\\theta} \\big[ \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\big]\\big] \\bigg]$$\n\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) \\bigg[ \\int_{a_t} \\pi_\\theta(a_t|s_t) \\big[\\int_{s_{t+1:T}, a_{t+1:T}} P_\\theta(s_{t+1:T}, a_{t+1:T}|s_{1:t}, a_{1:t})  \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\big] \\bigg]$$\n\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) \\bigg[ \\int_{a_t} \\pi_\\theta(a_t|s_t) \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\big[\\int_{s_{t+1:T}, a_{t+1:T}} P_\\theta(s_{t+1:T}, a_{t+1:T}|s_{1:t}, a_{1:t}) \\big] \\bigg]$$\n\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) \\bigg[ \\int_{a_t} \\pi_\\theta(a_t|s_t) \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\big[Const\\big] \\bigg]$$\n\nMaking use of that useful identity again, and moving constants out of the inner integral:\n\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) b(s_t) \\big[Const\\big] \\bigg[ \\nabla_\\theta \\int_{a_t} \\pi_\\theta (a_t|s_t) \\bigg]$$\n\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) b(s_t) \\big[Const\\big] \\bigg[ \\nabla_\\theta Const \\bigg]$$\n$$\\int_{(s_{1:t}, a_{1:t-1})}P_\\theta(s_{1:t}, a_{1:t-1}) b(s_t) \\big[Const\\big] \\bigg[0 \\bigg] = 0$$\n\nAs we've shown that $$E_{\\tau \\sim P_\\theta} \\bigg[  \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\bigg] = 0$$ it follows that $$\\sum_{t = 1}^T E_{\\tau \\sim P_\\theta} \\bigg[  \\nabla_\\theta \\log \\pi_\\theta (a_t|s_t) b(s_t) \\bigg] =0 $$\n\n\n\n% Rewriting the numerator:\n% $$\\frac{P(s_1)(\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})(\\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}\n% {P(s_1)\\prod_{i = 2}^{i = t)}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}$$\n\n% $$\\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) = P_\\theta(s_{t+1}|a_{t}, s_{t})P_\\theta(a_{t}|s_{t})\\prod_{i = t+2}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})$$\n\n\n\\section*{Problem 4. CartPole}\n\\subsection*{Learning Curves for Small/Large Batch Sizes}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{sb_cartpole.png}\n\\caption{Small Batch}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{lb_cartpole.png}\n\\caption{Large Batch}\n\\end{figure}\n\n\\subsection*{Analysis questions}\n\\subsubsection*{Trajectory-Centric vs Reward-To-Go w/out Advantage Centering}\nWe can see that the reward to go estimator displays higher performance, though the effect seems to be significantly less pronounced with larger batch sizes.\n\\subsubsection*{Advantage Centering}\nAdvantage centering certainly seems to have helped by reducing the variance of the estimator, which we can see in the more stable learning curve for both small and larger batch sizes. \n\\subsubsection*{Batch Size}\nThe batch size also seems to be very effective at reducing the variance of the gradient estimators both in the reward-to-go estimator as well as the trajectory-centric one. It also converges more quickly in the number of iterations in all cases. \n\n\\section*{Problem 5. Inverted Pendulum}\n\\subsection*{Learning Curve for Smallest Batch Size and Largest Learning Rate}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{problem-5.png}\n\\caption{The learning rate used is 0.01, and the batch size is 1000.}\n\\end{figure}\n\n\\section*{Problem 7. Lunar Landing}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{lunar_landing.png}\n\\caption{S}\n\\end{figure} \n\n\n\\section*{Problem 8. HalfCheetah}\n\\subsection*{batch size and learning rate}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{half_cheetah_bsize_lr.png}\n\\caption{S}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{halfcheetah_rtg_baseline.png}\n\\caption{S}\n\\end{figure}\n% \\begin{table}[H]\n% \\centering\n% \\begin{tabular}{l|l|l|r}\n% & Game & Mean & Std \\\\\\hline\n% Expert & HalfCheetah & 2374.79 & 772.96\\\\\n% BC Agent & HalfCheetah & 2110.61 & 947.18\\\\\n% Expert & Humanoid & 2908.21 & 929.65\\\\\n% BC Agent & Humanoid & 45.01 & 13.77\n% \\end{tabular}\n% \\caption{Stats reported over 100 rollouts. The HalfCheetah BC agent used a network of 128 and 64 units respectively followed by an output layer over 6 dimensions of the action space. The Humanoid agent 256 and 128 units respectively followed by an output layer over 17 dimensions of the action space.}\n% \\end{table}\n\n\n% \\subsection*{2.3 Experimentation}\n\n% \\begin{figure}[H]\n% \\centering\n% \\includegraphics[width=1\\textwidth]{{../2.3-propdata-halfcheetah}.png}\n% \\caption{\\label{fig:propdata}I chose to look at the effect of more training data on the BC Agent's performance. I trained the HalfCheetah agent using subsets of the data between 10\\% and 100\\%.}\n% \\end{figure}\n\n\n% \\subsection*{3.2 DAgger}\n% \\begin{figure}[H]\n% \\centering\n% \\includegraphics[width=1\\textwidth]{{../3.2 - Dagger Comparison}.png}\n% \\caption{\\label{fig:dagger}I chose the task on which the behavior cloning agent performed poorest relative to the expert policy - Humanoid. I used the same architecture as in the behavior cloning experiments (i.e. 256 relu > 128 relu -> 17 lin). I ran 20 episodes of the algorithm, training the policy for 80000 steps from scratch each episode, and generating 10 rollouts worth of samples for the next iteration. }\n% \\end{figure}\n\\section*{Appendix}\n\\subsection*{Problem 1 (b)}\n\n$$P_\\theta(s_{t+1:T}, a_{t:T} | s_{1:t}, a_{1:t-1}) = \\frac{P_\\theta(\\tau)}{P(s_{1:t}, a_{1:t-1})}$$\n\nRecall that the numerator, $P_\\theta(\\tau)$ is:\n\n$$P_\\theta(\\tau) = P(s_1)\\prod_{i = 2}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})$$\n\nWe can equivalently represent that as:\n\n$$P_\\theta(\\tau) = \\Bigg( P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg) \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})$$\n\nThe denomenator $P(s_{1:t}, a_{1:t-1})$ simply marginalizes $P_\\theta$ over all possible assignments of the remaining states and actions. i.e.\n\n$$P(s_{1:t}, a_{1:t-1}) = \\sum_{a_{t:T}}\\sum_{s_{t+1:T}} P_\\theta(\\tau) = \\sum_{a_{t:T}}\\sum_{s_{t+1:T}} P(s_1)\\prod_{i = 2}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) = $$\n\nFactoring out the terms that dont depend on the summation domains:\n\n$$ \\Bigg(P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg) \\sum_{a_{t:T}}\\sum_{s_{t+1:T}} \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})$$\n\n\nNow, substituting this for our numerator and denomenator we get:\n\n$$P_\\theta(s_{t+1:T}, a_{t:T} | s_{1:t}, a_{1:t-1}) = \\frac{ \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}{ \\sum_{a_t}^T\\sum_{s_{t+1:T}} \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}$$\n\nWe can follow a similar procedure starting from $P_\\theta(s_{t+1:T}, a_{t:T} | s_t)$ to show that they reduce to the same expression. \n\n\n $$P_\\theta(s_{t+1:T}, a_{t:T} | s_t) = \\frac{\\sum_{a_1:t-1}\\sum_{s_1:t-1} P_\\theta(\\tau)}{\\sum_{a_1:t-1}\\sum_{s_1:t} \\sum_{a_t:T-1}\\sum_{s_t+1:T} P_\\theta(\\tau)}$$\n \n \n Substituting our factored form for $P_\\theta$, looking  only at numerator:\n \n  $$\\sum_{a_1:t-1}\\sum_{s_1:t-1} \\Bigg( P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg) \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) = $$\n  \n  $$\\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\sum_{a_1:t-1}\\sum_{s_1:t-1} \\Bigg( P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg)$$\n Now denomenator: \n \n $$\\sum_{a_1:t-1}\\sum_{s_1:t-1} \\sum_{a_t:T-1}\\sum_{s_t+1:T} \\Bigg( P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg) \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) = $$\n \n  $$\\sum_{a_{1:t-1}}\\sum_{s_{1:t-1}} \\Bigg( P(s_1)\\prod_{i = 2}^{i = t}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) \\Bigg) \\sum_{a_t:T-1}\\sum_{s_t+1:T}  \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1}) = $$\n  \n  Putting it all together:\n  $$P_\\theta(s_{t+1:T}, a_{t:T} | s_t) = \\frac{ \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}{ \\sum_{a_t}^T\\sum_{s_{t+1:T}} \\prod_{i = t+1}^{i = T}P_\\theta(s_i|a_{i-1}, s_{i-1})P_\\theta(a_{i-1}|s_{i-1})}$$\n  \n\\end{document}\n", "meta": {"hexsha": "d1456caba1c2b710b8fc4d5c0907a8c179460682", "size": 13130, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw2/report/report.tex", "max_stars_repo_name": "Khodeir/homework", "max_stars_repo_head_hexsha": "3e3f19e0d5a423a158e33bb9259b5300957416fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw2/report/report.tex", "max_issues_repo_name": "Khodeir/homework", "max_issues_repo_head_hexsha": "3e3f19e0d5a423a158e33bb9259b5300957416fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw2/report/report.tex", "max_forks_repo_name": "Khodeir/homework", "max_forks_repo_head_hexsha": "3e3f19e0d5a423a158e33bb9259b5300957416fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.4901960784, "max_line_length": 416, "alphanum_fraction": 0.6498095963, "num_tokens": 5518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.7956580976404297, "lm_q1q2_score": 0.42575539777143306}}
{"text": "\n\\section{Comparing Storkey and Hebbian learning}\n\nWhen training a Hopfield network, we have employed two types of learning: the\nfirst one is the Hebbian learning, while the second one is Storkey learning.\nThe advantage of the latter is that it increases the capacity of the network\nand the basin of attraction of the clusters. We will now explain some\nexperiments we did with both types of learning in order to see how the\nlearning type affects the basin of attraction for clusters.\n\nWe will now show how the learning determines the basin of attraction of a\nGaussian distributed cluster. The generation was done using the T2 method\ndescribed in section ~\\ref{sec:fexp}.\n\n\\begin{table}[h]\n\\centering\n  \\begin{tabular}{|c|c|c|c|c|c|}\n    \\hline\n    \\tmtextbf{Learning} & N & Cluster size & $\\mu$ & $\\sigma$ & Average size\n    of basin of attraction\\\\\n    \\hline\n    Hebbian & 50 & 2 & 25 & 5 & 10.0\\\\\n    \\hline\n    Storkey & 50 & 2 & 25 & 5 & 18.0\\\\\n    \\hline\n    Hebbian & 50 & 4 & 25 & 5 & 1.5\\\\\n    \\hline\n    Storkey & 50 & 4 & 25 & 5 & 4\\\\\n    \\hline\n    Hebbian & 50 & 4 & 25 & 10 & 5.75\\\\\n    \\hline\n    Storkey & 50 & 4 & 25 & 10 & 8.0\\\\\n    \\hline\n    Hebbian & 50 & 5 & 25 & 5 & 4.4\\\\\n    \\hline\n    Storkey & 50 & 5 & 25 & 5 & 4.8\\\\\n    \\hline\n    Hebbian & 50 & 6 & 25 & 5 & 4.2\\\\\n    \\hline\n    Storkey & 50 & 6 & 25 & 5 & 4.4\\\\\n    \\hline\n    Hebbian & 50 & 6 & 25 & 10 & 4.45\\\\\n    \\hline\n    Storkey & 50 & 6 & 25 & 10 & 5.61\\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Results comparing Storkey and Hebbian learning for various parameters}\n\\end{table}\n\n\n\nThe results confirm what the mathematical theory showed us: Storkey learning\nincreases the average basin of attraction. We must note that this does not\ncome without a price: training the network using Storkey learning slowed down\nour experiments, as it is more expensive. Depending to the application, this\nis an acceptable trade off. All our functions and experiments can be performed\nwith both types of learning, just by changing a parameter (the learning type),\nwhich enables any user of our libraries to make the choice depending on the\nuse case.\n\nThe following results show the difference between Storkey and Hebbian learning in the experiments we talked about before.\nThe aim of repeating the experiments with Storkey learning was to see what kind of impact the learning type has in respect to the average basin size.\nBoth curves (given by Hebbian and Storkey learning) follow the same shape, which also gives confidence in the initial results obtained with Hebbian learning: an initial fast drop in\naverage basin size, with a steadily increase afterwards.\n\\\\*\nThe best way to express out results is by showing the two different trends, obtained with the 2 methods we have employed: T1 and T2.\n\n\\subsection{T1 Method}\n\nFor the T1 method, one can easily notice that Storkey learning gives bigger basin sizes. While this was expected when experimenting with one cluster\n (\\ref{fig:plot-storkey-T1-onecluster}), the surprise comes from the second chart (\\ref{fig:plot-storkey-T1-twoclusters}): the  increased basin size in the second cluster. Even though the network is trained with 2 clusters\nand they affect each others basin sizes, both sizes increase with Storkey learning, without it giving a different ration between the average.\n\n%T1\n\n\\begin{figure}[!ht]\n  \\centering\n  \\input{plot-storkey-T1-onecluster-100}\n\\caption{Comparing the impact of different learning methods on the average basin size of patterns belonging to a cluster generated using T1.}\n\\label{fig:plot-storkey-T1-onecluster}\n\\end{figure}\n\n\\begin{figure}[!ht]\n  \\centering\n  \\input{plot-storkey-T1-twocluster-100}\n\\caption{Comparing the impact of different learning methods on the average basin size of patterns belonging to two clusters generated using T1. The first cluster has fixed $p = 0.2$}\n\\label{fig:plot-storkey-T1-twoclusters}\n\\end{figure}\n\n\n%T2\n\\clearpage\n\\subsection{T2 Method}\n\nThe results are different when looking at T2 type experiments:\nthe difference between the two learning methods is less straight forward.\nWhen training a Hopfield network with one cluster (\\ref{fig:plot-storkey-T2-onecluster})  there is a critical point from which the Storkey learning clearly gives a bigger basin size\n(at a standard deviation approximately 5.0), but before that it seems like the two methods give very similar results.\n\\\\*\nEven more interesting results come from training the network with two clusters (as seen in \\ref{fig:plot-storkey-T2-twoclusters}): surprisingly, when the standard deviation of the second cluster\nis less than 9, the Hebbian learning provides a bigger basin size. After that point, Storkey learning acts as expected, by giving a\nbigger basin size when compared to Hebbian. Note that the threshold point of this crossover is very close to the standard deviation of the first\ncluster, which was fixed to 10.\n\\\\* These results enables us to speculate that Storkey learning is more sensitive to non independent patterns. Both the results from T1 experiments with\n2 clusters and the T2 experiments show this. However, we believe that more investigation needs to be done in order to have confidence in these results.\n\n\n\\begin{figure}[!ht]\n  \\centering\n  \\input{plot-storkey-T2-onecluster-100}\n\\caption{Comparing the impact of different learning methods on the average basin size of patterns belonging to a cluster generated using T2.}\n\\label{fig:plot-storkey-T2-onecluster}\n\\end{figure}\n\n\\begin{figure}[!ht]\n  \\centering\n  \\input{plot-storkey-T2-twocluster-100}\n\\caption{Comparing the impact of different learning methods on the average basin size of patterns belonging to two clusters generated using T2. The first cluster has fixed $\\sigma = 10$}\n\\label{fig:plot-storkey-T2-twoclusters}\n\\end{figure}\n", "meta": {"hexsha": "c440791209eaf886f27330121889f3186be8e689", "size": 5769, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/learningexperiments.tex", "max_stars_repo_name": "imperialhopfield/hopfield", "max_stars_repo_head_hexsha": "d64e21b1c7b915755ae535685ffd7dfd25e3970f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-07-30T10:00:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T15:49:06.000Z", "max_issues_repo_path": "report/learningexperiments.tex", "max_issues_repo_name": "imperialhopfield/hopfield", "max_issues_repo_head_hexsha": "d64e21b1c7b915755ae535685ffd7dfd25e3970f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/learningexperiments.tex", "max_forks_repo_name": "imperialhopfield/hopfield", "max_forks_repo_head_hexsha": "d64e21b1c7b915755ae535685ffd7dfd25e3970f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-12-19T13:06:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-03T13:32:21.000Z", "avg_line_length": 47.6776859504, "max_line_length": 222, "alphanum_fraction": 0.7524700988, "num_tokens": 1568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953797290153, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4257054363822719}}
{"text": "%% Template for the submission to:\n%%   Statistical Science [STS]\n%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% In this template, the places where you   %%\n%% need to fill in your information are     %%\n%% indicated by '???'.                      %%\n%%                                          %%\n%% Please do not use \\input{...} to include %%\n%% other tex files. Submit your LaTeX       %%\n%% manuscript as one .tex document.         %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass[sts]{imsart}\n\n%% Packages\n\\RequirePackage{amsthm,amsmath,amsfonts,amssymb}\n\\RequirePackage[authoryear]{natbib}\n\\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref}\n\\RequirePackage{graphicx}\n\\RequirePackage{enumitem}\n\\usepackage[ruled,linesnumbered]{algorithm2e}\n\\SetKwInput{KwInput}{Input} % Set the Input\n\\SetKwInput{KwOutput}{Output} % set the Output\n\\SetKwInput{KwNotation}{Notation}\n\\RequirePackage{microtype} % Ryan added this\n\n\\startlocaldefs\n\\def\\R{\\mathbb{R}}\n\\def\\C{\\mathbb{C}}\n\\def\\E{\\mathbb{E}}\n\\def\\P{\\mathbb{P}}\n\\def\\T{\\mathsf{T}}\n\\def\\Cov{\\mathrm{Cov}}\n\\def\\Var{\\mathrm{Var}}\n\\def\\half{\\frac{1}{2}}\n\\def\\tr{\\mathrm{tr}}\n\\def\\df{\\mathrm{df}}\n\\def\\dim{\\mathrm{dim}}\n\\def\\col{\\mathrm{col}}\n\\def\\row{\\mathrm{row}}\n\\def\\nul{\\mathrm{null}}\n\\def\\rank{\\mathrm{rank}}\n\\def\\nuli{\\mathrm{nullity}}\n\\def\\spa{\\mathrm{span}}\n\\def\\sign{\\mathrm{sign}}\n\\def\\supp{\\mathrm{supp}}\n\\def\\diag{\\mathrm{diag}}\n\\def\\aff{\\mathrm{aff}}\n\\def\\conv{\\mathrm{conv}}\n\\def\\dom{\\mathrm{dom}}\n\\def\\hy{\\hat{y}}\n\\def\\hf{\\hat{f}}\n\\def\\hmu{\\hat{\\mu}}\n\\def\\halpha{\\hat{\\alpha}}\n\\def\\hbeta{\\hat{\\beta}}\n\\def\\htheta{\\hat{\\theta}}\n\\def\\cA{\\mathcal{A}}\n\\def\\cB{\\mathcal{B}}\n\\def\\cD{\\mathcal{D}}\n\\def\\cE{\\mathcal{E}}\n\\def\\cF{\\mathcal{F}}\n\\def\\cG{\\mathcal{G}}\n\\def\\cK{\\mathcal{K}}\n\\def\\cH{\\mathcal{H}}\n\\def\\cI{\\mathcal{I}}\n\\def\\cL{\\mathcal{L}}\n\\def\\cM{\\mathcal{M}}\n\\def\\cN{\\mathcal{N}}\n\\def\\cP{\\mathcal{P}}\n\\def\\cS{\\mathcal{S}}\n\\def\\cT{\\mathcal{T}}\n\\def\\cW{\\mathcal{W}}\n\\def\\cX{\\mathcal{X}}\n\\def\\cY{\\mathcal{Y}}\n\\def\\cZ{\\mathcal{Z}}\n\\newcommand{\\argmin}{\\mathop{\\mathrm{argmin}}}\n\\newcommand{\\argmax}{\\mathop{\\mathrm{argmax}}}\n\\newcommand{\\minimize}{\\mathop{\\mathrm{minimize}}}\n\\newcommand{\\subjectto}{\\mathop{\\mathrm{subject\\,\\,to}}}\n\\def\\hx{\\hat{x}}\n\\def\\hp{\\hat{p}}\n\\def\\hF{\\hat{F}}\n\\def\\hS{\\hat{S}}\n\\def\\bx{\\bar{x}}\n\\def\\bp{\\bar{p}}\n\\def\\bF{\\bar{F}}\n\\def\\bS{\\bar{S}}\n\\def\\hP{\\hat{P}}\n\\def\\tP{\\tilde{P}}\n\\def\\tD{\\tilde{D}}\n\\def\\D{\\mathcal{D}}\n\\def\\I{\\mathcal{I}}\n\\def\\T{\\mathcal{T}}\n\\def\\th{^\\mathrm{th}}\n\\def\\st{^\\mathrm{st}}\n\\def\\rd{^\\mathrm{rd}}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                          %%\n%% Uncomment next line to change            %%\n%% the type of equation numbering           %%\n%%                                          %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\numberwithin{equation}{section}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                          %%\n%% For Axiom, Claim, Corollary, Hypothesis, %%\n%% Lemma, Theorem, Proposition              %%\n%% use \\theoremstyle{plain}                 %%\n%%                                          %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\theoremstyle{plain}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{corollary}{Corollary}\n\\newtheorem{proposition}{Proposition}\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                          %%\n%% For Assumption, Definition, Example,     %%\n%% Notation, Property, Remark, Fact         %%\n%% use \\theoremstyle{remark}                %%\n%%                                          %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\theoremstyle{remark}\n\\newtheorem*{remark}{Remark}\n\\newtheorem{assumption}{Assumption}\n\\endlocaldefs\n\n\\begin{document}\n\\begin{frontmatter}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                                          %%\n%% Enter the title of your article here     %%\n%%                                          %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\title{Real-Time Estimation of COVID-19 Infections: Deconvolution and Sensor\n  Fusion}  \n\\runtitle{Real-Time Estimation of COVID-19 Infections}\n\n\\begin{aug}\n\\author[A]{\\fnms{Maria} \\snm{Jahja}\\ead[label=e1]{maria@stat.cmu.edu}},\n\\author[B]{\\fnms{Andrew} \\snm{Chin}\\ead[label=e2]{achin23@jhu.edu}},\n\\and\n\\author[C]{\\fnms{Ryan J.} \\snm{Tibshirani}\\ead[label=e3]{ryantibs@cmu.edu}}\n\\address[A]{Maria Jahja is Ph.D. Candidate, \n  Department of Statistics \\& Data Science, \n  Machine Learning Department,  \n  Carnegie Mellon University, \n  Pittsburgh, PA \\printead{e1}.} \n\\address[B]{Andrew Chin is Statistical Developer, \n  Machine Learning Department,\n  Carnegie Mellon University, \n  Pittsburgh, PA \\printead{e2}.} \n\\address[C]{Ryan J. Tibshirani is Professor, \n  Department of Statistics \\& Data Science, \n  Machine Learning Department, Carnegie Mellon University,\n  Pittsburgh, PA \\printead{e3}.} \n\\end{aug}\n\n\\begin{abstract}\nWe propose, implement, and evaluate a method to estimate the daily number of new\nsymptomatic COVID-19 infections, at the level of individual U.S.\\ counties, by\ndeconvolving daily reported COVID-19 case counts using an estimated\nsymptom-onset-to-case-report delay distribution. Importantly, we focus on\nestimating infections in real-time (rather than retrospectively), which poses\nnumerous challenges. To address these, we develop new methodology for both the \ndistribution estimation and deconvolution steps, and we employ a sensor fusion \nlayer (which fuses together predictions from models that are trained to track\ninfections based on auxiliary surveillance streams) in order to improve accuracy\nand stability. \n\\end{abstract}\n\n\\begin{keyword}\n\\kwd{COVID-19}\n\\kwd{nowcasting}\n\\kwd{deconvolution}\n\\kwd{sensor fusion}\n\\end{keyword}\n\n\\end{frontmatter}\n\n\\section{Introduction}\n\\label{sec:intro}\n\nAccurate, real-time estimates of incident infections play a critical role in\ninforming the public health response to the spread of a disease through a\npopulation. However, official metrics on disease activity published by\ntraditional public health surveillance systems in the United States do not in\nfact reflect activity in real-time, as they suffer from some degree of latency\ndue to the way their reporting pipelines are set up and implemented.\n\nWith addressing the latency in traditional public health reporting a part of the\nmotivation, the last decade has seen a rise in the development of \\emph{digital\n  surveillance} streams in public health. Search and social media trends have\nconstituted much of the focus \\citep[e.g.,][]{Brownstein:2009, Ginsberg:2009,\nSalathe:2012, Kass-Hout:2013, Paul:2017}. More broadly, \\emph{auxiliary\nsurveillance} streams that operate outside of traditional public health\nsurveillance, like online surveys, medical device logs, or electronic medical \nrecords, have also received significant attention\n\\citep[e.g.,][]{Kass-Hout:2011, Carlson:2013, Viboud:2014, Smolinski:2015,\nSantillana:2016, Charu:2017, Yang:2019, Ackley:2020, Leuba:2020, Radin:2020}.\n\nAuxiliary surveillance can improve not only on the timeliness but also on the  \naccuracy and robustness of traditional public health reporting. \nAuxiliary data streams have therefore become an integral part of modern systems for\ndisease \\emph{nowcasting} \\citep[e.g.,][]{McIver:2014, Santillana:2015,\n  Yang:2015, Farrow:2016, Jahja:2019, Brooks:2020}, which, put broadly, are used\nto estimate the contemporaneous value of a signal that will only be fully\nobserved at a later date, using partial or noisy data.    \n\n\\subsection{Surveillance During the Pandemic}\n\nDuring the COVID-19 pandemic, public health surveillance has produced, on one\nhand, some of the most detailed public health data that the U.S.\\ has ever seen,\nsuch as daily, county-level data on reported COVID-19 cases and deaths. It has\nalso, on the other hand, painted an imperfect picture of situational awareness,\nwhich created a number of downstream challenges for the public health \nresponse. See, e.g., \\citet{Rosenfeld:2021} and references therein for an\noverview of the issues. In this paper, we identify a few issues surrounding\nCOVID-19 case reporting in particular, propose methodology to address \nthem, and implement and evaluate this proposal over eight months of pandemic\ndata.   \n\nTo give some background, in the early days of the pandemic, a handful of\nnon-gonvermental groups such as JHU CSSE \\citep{Dong:2020} (and also the COVID\nTracking Project, the New York Times, and USAFacts) became known as the most \ntrustworthy sources for aggregate public health reporting data on COVID-19 in\nthe U.S. They were founded around the idea of scraping COVID-19 data published\ndaily on dashboards that are run by local public health authorities (such as\nstate and county departments of public health), which, at the time, provided\nmore accurate and timely data than federal health authorities (probably due to\nunrecoverable failures at one or more points along the reporting pipeline). In\nfact, not only in the early days of the pandemic, but throughout, the data\npublished by these groups has been invaluable for decision-makers, modelers,\njournalists, and the general public; for example, data from JHU CSSE remains the\ngold standard for COVID-19 case and death forecast evaluation in the COVID-19\nForecast Hub \\citep{ForecastHub}, a community-driven repository of forecasts\nthat serves as the official source for forecasting communications by the U.S.\\\nCDC.\n\nTurning our focus now to case reporting, JHU scrapes cumulative case numbers\nthat are published daily on local health authority dashboards, and subsequently\nderives a notion of case incidence based on day-to-day differences in cumulative\ncounts. Note that, by construction, this definition of incidence reflects the\nnumber of new COVID-19 cases that are \\emph{reported} (to the public) on any\ngiven day. Of course, this is not the same as the number of new cases by date\ntested, specimen collection date, or symptom onset date. Any of the latter\noptions would be more informative (increasingly so) as a definition of\nincidence; revamping our surveillance systems so that they can directly provide\nthese and other aggregates of interest to the public health response is a\ncritical task for future public health crises.\n\n The reality of the current pandemic: alignment by report date is the only\noption available, given the data published broadly on local health authority\ndashboards, hence collected and aggregated by data scrapers. JHU publishes the\nnumber of new COVID-19 case reports per U.S.\\ county, daily, at a 1-day\nlag. However, since report dates can lag behind symptom onset dates by many days\n(a typical lag is around 5-10, but lags can be up to 30 days or more; see\nFigure~\\ref{fig:line_list_time}), this is actually giving us a glimpse into\nCOVID activity in the recent past, rather than the present.\n\nImportantly, the CDC publishes a de-identified patient-level data set (``line\nlist'') on COVID-19 infections \\citep{cdc_public}, which provides a symptom \nonset date column. In principle, this should allow us to construct a notion of\ncase incidence that is aligned by symptom onset date, but this is not possible\nin practice, due to two barriers. First, the CDC only publishes updates to the \nline list monthly (due to the complexity of managing this data set). Second, \nand more problematically, this line list is fraught with missingness,\nextending well beyond missingness in the symptom onset column: the \\emph{total}\nnumber of COVID-19 cases according to this line list (whether the symptom onset\ndate is observed or not) is far less than the total number of cases from JHU\n(e.g., in early September 2021, the CDC line list reports about 30 million total\nversus about 40 million from JHU), and some states (such as Texas) appear to \nmissing nearly all of their cases in the line list altogether (see\nFigure~\\ref{fig:line_list_state}). \n\n\\subsection{Nowcasting by Deconvolution}\n\nIn what follows in this paper, we use the CDC line list to estimate a delay\ndistribution between symptom onset and report dates, and then use this delay\ndistribution to deconvolve daily numbers of new case reports published by JHU\nCSSE to estimate daily numbers of new symptomatic infections. Moreover, we train\nmodels that track historical trends between past infection estimates and\nauxiliary signals of COVID-19 activity from Delphi's COVIDcast project\n\\citep{Reinhart:2021}, and we fuse together predictions from these models in\norder to improve the accuracy and robustness of our estimates of new infections\nfor the most recent 10 days (where deconvolution is particularly\nchallenging). An illustration is given in Figure~\\ref{fig:deconv_demo}.\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/nowcast_demo.pdf}\n\\caption{Illustration of estimating latent infections from reported cases. The \n  dashed red line displays infection rates estimated ``naively'' in real-time,\n  by directly deconvolving case data up through early February 2021, while\n  the solid black line display infection rates estimated using finalized data\n  from roughly four months afterwards. The blue region on the\n  right-hand side highlights a period in which the real-time estimate deviates \n  substantially from the finalized one, due to the fact that we are lacking \n  sufficient (future) case observations needed to perform a ``full''\n  deconvolution. The green triangles represent real-time nowcasts made by sensor\n  fusion, which reduces the volatility of the real-time estimate and tracks the\n  finalized estimate nicely. Lastly, the (scaled) reporting delay distribution\n  estimated at the midpoint of November 2020 is drawn in purple, with the median\n  reporting delay (8 days) marked as a dotted gray line.} \n\\label{fig:deconv_demo}\n\\end{figure*}\n\nWe focus on estimating new infections in \\emph{real-time}, laying out a\nframework for an operational nowcasting system that is forced to cope with all\nof the challenges of disease tracking using provisional data. At any given\nnowcast date $t$, to estimate the number of symptomatic infections at day $t-k$\n(for small values of $k$, such as $k=1,2,\\ldots$), we make sure to use data that\nwould have actually been available at $t$. This not only affects the way we\ncarry out all of our experiments (model training and evaluation), it also leads\nus to develop some new interesting methodology to deal with the issue of\n\\emph{right truncation} (highlighted in Figure~\\ref{fig:deconv_demo} by the blue\nregion). For example, in order to estimate the delay distribution in real-time,\nwe develop a Kaplan-Meier-like procedure to deal with a kind of right censoring\nthat occurs in the line list. We also develop specialized regularization techniques\nto control the volatility of estimates around the nowcast date in an\noptimization problem that we solve for real-time deconvolution.    \n\nAn outline for this paper is as follows. In Section~\\ref{sec:preliminaries}, we\ncover various preliminary details about the problem setup. Retrospective\nconstruction of the delay distribution and deconvolution are described in\nSection~\\ref{sec:deconv_retro}, whereas real-time estimation is the focus in\nSection~\\ref{sec:deconv_realtime}. Sensor fusion is covered in\nSection~\\ref{sec:leverage_aux}, and extensive evaluations---comparing nowcasts\nmade in real-time to those made retrospectively (using ``finalized'' data that\nwould have only been available much later), are performed in\nSection~\\ref{sec:evaluation}. In Section~\\ref{sec:discussion}, we conclude with\na discussion and describe a few directions for future work. \n\nR and Python code\nfor reproducing all figures and results in this paper can be found at\n\\url{https://github.com/cmu-delphi/stat-sci-nowcast}. \n\n\\subsection{Related Work}\n\\label{sec:related_work}\n\nIn the computational epidemiology literature, the term ``nowcasting'' has been\napplied to a variety of related but distinct estimation problems. Broadly\nspeaking, what these problems have in common is that they are about real-time\nestimation of some quantity, based on partial or noisy data. They differ in\n\\emph{what} is being estimated, and whether this quantity will eventually be\nfully observed (after enough time has passed) or whether it is latent. Examples\nin the former non-latent setting, which span applications in influenza, dengue,\nand COVID-19, include \\citet{Yang:2015, Farrow:2016, Jahja:2019, Brooks:2020,\n  McGough:2020, Hawryluk:2021}. \n\nThe latent setting exhibits another degree of diversity within itself. In our\nwork, we target symptomatic COVID-19 infections, which, to be perfectly clear,\nis a latent time series. Another example along similar lines is\n\\citet{Goldstein:2009}, who estimate influenza infection incidence via Bayesian\ndeconvolution of mortality data. Meanwhile, other authors might view inferring \nlatent infections as just a stepping stone toward ultimately estimating the \ninstantaneous reproductive number $R_t$, a key epidemic parameter. Important \ncontributions to the methodology on real-time estimation of $R_t$ include: \n%\\citet{Wallinga:2004}, who propose a forward-looking approach (in fact, to\n%estimate a related but slightly different quantity known as the case\n%reproductive number) based on an estimate of the serial interval;\n\\citet{Bettencourt:2008}, who use a local approximation to the SIR model, and \n\\citet{Cori:2013, Thompson:2019}, who use a discretization of the renewal\nequation within a Bayesian framework. For a thorough review and comparison of\nthese methods, see \\citet{Gostic:2020}. The latter paper also discusses in some\ndetail the importance of properly modeling the delay between infection onset and\ncase report, and the issue of right truncation, which, as we will see, are\ncentral issues in our paper as well. \n\nThe aforementioned methods have been applied and extended to build systems for\nreal-time $R_t$ nowcasting during the COVID-19 pandemic by \\citet{Abbott:2020,\n  rtlive, Chitwood:2021}. A key difference between these approaches and ours is \nthat they infer infections through forward-filling: loosely speaking, they\nconvolve forward a candidate estimate of infections, obtain feedback by\ncomparing the result to measured cases, and iterate to refine estimates. This\ncan be effective given accurate prior knowledge, but of course it can be hard to\njudge the accuracy of prior knowledge in practice. We take a more flexible\napproach and estimate infections via direct deconvolution. Our approach is\nnonparametric, but is still fairly simple and computationally efficient. We also\nfocus on fusing in auxiliary sources of information in order to improve\nreal-time accuracy and robustness. We remark that, if estimates of $R_t$ were\ndesired, then these could certainly be inferred as a by-product of our infection\nnowcasts.\n\nFinally, deconvolution has been extensively studied for many years in many\nfields, notably signal and image processing, where deconvolution is sometimes\ncalled deblurring. As an inverse problem, deconvolution is ill-posed in settings\nin which the convolution operator is not known exactly or observations are made\nwith noise \\citep{Oppenheim:2017}. Approaches to overcome this traditionally\ninvolve regularization, as in the classical Wiener deconvolution\n\\citep{Wiener:1964}, which stabilizes the inversion using an estimated\nsignal-to-noise ratio. Alternative approaches employ familiar regularization\ntechniques such as $\\ell_1$ and $\\ell_2$ penalities \\citep{Taylor:1979,\n  Debeye:1990}. Most related to our paper is deconvolution using total variation \nregularization, first proposed by \\citet{Rudin:1994}, and now a central tool in\nsignal and image processing.\n\n\\section{Preliminaries}\n\\label{sec:preliminaries}\n\nIn the remainder of this paper, we develop a framework for estimating the daily\nsymptomatic COVID-19 infection rate (where by ``rate'' we mean a count per\n100,000 people, the standard units in epidemiology), concentrating on infections\nthat will eventually result in a reported COVID-19 case. To be clear on\nnomenclature: for convenience, we will often abbreviate ``symptomatic\ninfection'' by ``infection'' (and so, terms like ``infection onset'' and\n``infection rate'' should be implicitly interpreted as symptomatic). To\nestimate infection rates, we deconvolve reported case rates with an estimated\nsymptom-onset-to-case-report delay distribution. To reiterate, we use case data\nfrom JHU CSSE \\citep{Dong:2020}, and to infer the delay distribution, we use a\nde-identified line list on patient-level infections from the CDC\n\\citep{cdc_public}. \n\n\\smallskip\n\\paragraph*{Auxiliary Indicators.}\n\nAfter deconvolution, we improve our infection rate estimates by incorporating a\nnumber of contemporaneous signals that track COVID activity---we will also \nrefer to these as \\emph{indicators}---which are publicly available through\nDelphi's COVIDcast API \\citep{Reinhart:2021}. The five indicators that we\nconsider, described below, provide auxiliary information on COVID-19 outside of \ntraditional public heath reporting. Here and throughout, we abbreviate\nCOVID-like illness by CLI. \n\n\\begin{enumerate}\n\\item Change Healthcare COVID (CHNG-COVID): The percentage of outpatient\n  visits that have confirmed COVID-19 diagnostic codes, based on de-identified \n  Change Healthcare medical claims data. \n\\item Change Healthcare CLI (CHNG-CLI): The percentage of outpatient visits that\n  have COVID-like diagnostic codes, based on the same data.\n\\item Doctor Visits CLI (DV-CLI): The same definition as CHNG-CLI, but applied\n  to de-identified medical claims data from other health systems partners. \n\\item COVID Trends and Impact Survey CLI in the community\n  (CTIS-CLIIC): The estimated percentage of people reporting  \n  illness in their household or local community, based on Delphi's COVID\n  Trends and Impact Survey (CTIS), in partnership with Facebook. \n\\item Google searches for anosmia and ageusia (Google-AA): A measure of volume\n  for Google queries related to anosmia or ageusia (loss of smell or taste),\n  from Google's COVID-19 Search Trends data set. \n\\end{enumerate}\n\nRoughly speaking, we study these particular indicators (ordered roughly from\n``late'' to ``early'') because conceptually they reflect data measurements that\nwould be made at some period of time in between infection onset and case report\nto a public health authority, and therefore would be relevant in inferring\nlatent infection rates. More information on these indicators and their\nunderlying data sources is given in \\citet{Reinhart:2021}. For more information\non CTIS in particular, see \\citet{Salomon:2021}; and for a study of how these\nand similar indicators can improve COVID-19 forecasting, see\n\\citet{McDonald:2021}.\n\n\\smallskip\n\\paragraph*{Sensor Fusion.}  \n\nFor each of the auxiliary indicators described above, we train a model to\nestimate latent infection rates from indicator values, using historical data\n(described in Section~\\ref{sec:sensor_models}). At each nowcast date, we then  \nuse such a model to estimate the latent infection rate from the current\nindicator value, which gives a total of five estimates (one from each of the\nfive models), along with a sixth estimate coming from an autoregressive model \ntrained on historical estimated infection rates. We will refer these six \ncontemporaneous estimates as \\emph{sensors}.\n\nIn this paper, we consider (as described in Section~\\ref{sec:sensor_fusion})\nvarious methods for combining these estimates into a single estimate of the  \ninfection rate, which we will call \\emph{sensor fusion} methods. Broadly\nspeaking, sensor fusion is a form of ensembling, which is ubiquitous in in\npredictive modeling in statistics and machine learning, as it can often help\nimprove both accuracy and robustness. In our particular application, the sensors\nthemselves are constructed from data streams operating outside of traditional\npublic health reporting, which itself contributes an additional important angle\nin terms of robustness. % in the estimation of latent infection rates (as these \n% are tied to  public health reports via a convolutional model).  \n\n\\subsection{Problem Setup}\n\\label{sec:problem_setup}\n\n\\paragraph*{Estimation Period.}\n\nFor every day $t$ in between October 1, 2020 and June 1, 2021 inclusive (243\ndays in total), we estimate the symptomatic infection rate at day $t-k$, using  \nonly data that would have been as of time $t$, which in this context we call the  \n\\emph{nowcast date}. Estimation of the latent infection rate at time $t-k$ (for\npositive $k$) is technically a backcast, though we will not be careful to\ndistinguish this notationally from nowcasting, and will generally refer to this\nas nowcasting at lag $k$. We produce estimates for each $k=1,\\ldots,10$, a total  \nof 10 targets per nowcast date $t$. \n\nWhen we say above that nowcasts are made using data that would have been\navailable \\emph{as of} a given nowcast date $t$, we mean that we adhere not to\nonly the real-time availability (latency) of signals at $t$, but also the\n\\emph{version} of the data published at $t$---simply put, imagine that we\n``rewind'' the clock to time $t$ and query the API to receive the data that\nwould have been returned then. This is possible becausse the COVIDcast API\nrecords and provides access to all historical versions of data, as described in\n\\citet{Reinhart:2021}. As epidemic data is often subject to revision, if we\ntrain and evaluate models on ``finalized'' data (that would have been available\nonly at a much later time point) then this can lead to inaccurate conclusions\nabout real-time model performance; see, e.g., \\citet{McDonald:2021}.\n\nFurther, it is worth noting that reported case data from JHU is available at a\n1-day lag, and we assume that there is at least another 1-day lag between\nsymptom onset and case report (explained in\nSection~\\ref{sec:delay_distribution}). Hence through real-time deconvolution\nalone we would be able to make nowcasts at a 2-day lag at the earliest. Making\nnowcasts at a 1-day lag is possible with sensor fusion, using auxiliary signals \nwith 1-day latency (explained in Section~\\ref{sec:leverage_aux}). In this sense,\nsensor fusion is able to improve not only accuracy, but also latency, and buys\nus 1 extra day. \n\n\\smallskip\n\\paragraph*{Geographic Scope.}\n\nWe produce nowcasts at the county resolution, but for computational purposes, we\nrestrict our attention to the 200 U.S.\\ counties with the highest\npopulation. We additionally produce estimates for each of the 50 U.S.\\ states. \n(Some of the methodology that we use for sensor fusion requires a geographical\nhierarchy, thus using the remaining $\\approx$ 3000 U.S.\\ counties we aggregate\nthese within each state to create ``rest-of-state'' jurisdictions, and make\nestimates for these as well, for the purposes or maintaining such a hierachy.) \n\n\\smallskip\n\\paragraph*{Evaluation.}\n\nWe evaluate all nowcasts made in between October 1, 2020 and June 1, 2021\ninclusive (243 days in total) and at each of the 250 locations in consideration \n(50 states and the 200 largest counties) against latent infection rate estimates \nobtained by deconvolving the case rate data available as of August 30, 2021. \nWe will refer to the latter as \\emph{finalized} infection rate estimates (as \nopposed to real-time ones); details are given in Section~\\ref{sec:ground_truth}. \n\n\\subsection{Confounding}\n\\label{sec:confounding}\n\nEstimates of COVID infections obtained by deconvolving reported cases will\ngenerally underestimate the true number of infections, because many infections\nare undetected or untested, and as such, do not appear later on in case\nreports. If we wanted to estimate the true number of symptomatic infections\nfrom case reports, then we would need to have some sense of the fraction of \nsymptomatic infections that go untested. Of course, this only gets more\ncomplicated if we extend our consideration to both symptomatic and asymptomatic\ninfections.  \n\nOther authors, e.g., \\citet{Chitwood:2021}, have taken the ambitious step of\nproposing and implementing frameworks with parameters that account for such\nconfounding. However, adjustments for case ascertainment and asymptomatic\ninfections generally rely, at least to some nontrivial extent, on model\nassumptions (typically, mechanistic ones) that are difficult to substantiate.\n\nWe take a different perspective and pose the problem as one of real-time \ndeconvolution only. We seek to answer the question:   \n\\begin{quote}\n\\it\nCan we estimate---in real-time---the number of new symptomatic COVID-19\ninfections that will eventually appear in case reports?  \n\\end{quote}\nHence, by construction, confounding is not a problem that we even attempt   \nto reconcile (because the target we track, infections that eventually show up\nin case reports, simply inherits any confounding that would be present in the\ncase reporting stream in the first place). \n\nOur approach can be seen as one that runs in parallel (rather than in\ncontradiction) to an approach that explicitly models and removes the effects of\nconfounding in case reporting. We focus on addressing the deconvolution problem\nas carefully as possible, with a concern for real-time estimation, and an eye\ntoward using auxiliary signals to improve accuracy and robustness. Estimates of\nparameters that account for confounding (that comes from other work focused on  \nthese aspects) could certainly be applied to our deconvolution estimates post\nhoc in order to adjust them appropriately; we revisit this idea in the\ndiscussion. \n\nLastly, under an assumption that the confounding acts as a multiplicative bias\nthat changes slowly over time, our real-time infection rate\nestimates---themselves subject to confounding, as explained above---can be\npost-processed to derive real-time \\emph{approximately unconfounded} estimates\nof $R_t$. This is also described in the discussion.\n\n\\section{Retrospective Deconvolution}\n\\label{sec:deconv_retro}\n\nIn this section, we study and fit a convolutional model between infections and  \nreported cases. We adopt a \\emph{retrospective} angle here and do not concern\nourselves with data availability or versioning issues; this is covered in the\nnext section.   \n\n\\subsection{Convolutional Model}\n\\label{sec:conv_model}\n\nFor simplicity, we introduce the convolutional model in just a single\nlocation. We denote by $y_t$ the number of new cases that are reported at time\n$t$, and by $x_t$ the number of new infections that have onset at time $t$. Our\njumping-off point is the following model:\n\\begin{equation}\n\\label{eq:conv_model1}\n\\E[y_t \\,|\\, x_s, s \\leq t] = \\sum_{s=1}^t \\pi_t(s) \\, x_s, \n\\end{equation}\nwhere for each $s \\leq t$,\n\\begin{equation}\n\\label{eq:delay_prob1}\n\\pi_t(s) = \\P\\big( \\text{case report at $t$} \\,|\\, \\text{infection onset at   \n  $s$} \\big). \n\\end{equation}\nWe refer to the probabilities above as \\emph{delay probabilities} at time $t$,\nand the entire sequence $(\\pi_t(s) : s \\leq t)$, as the \\emph{delay\n  distribution} at time $t$. \n\nThe justification for \\eqref{eq:conv_model1}, \\eqref{eq:delay_prob1} is\nelementary: to count $y_t$, we enumerate all infections that ever occurred in\nthe past:  \n\\[\ny_t = \\sum_{s=1}^t \\sum_{i=1}^{x_s} 1\\{\\text{the $i\\th$ \\hspace{-3pt} infection   \n  at $s$ gets reported at $t$}\\}.\n\\]\nTaking a conditional expectation on both sides above, and using linearity,\ndelivers \\eqref{eq:conv_model1}, \\eqref{eq:delay_prob1}.\n\nIn the next subsections, we will describe how to estimate the probabilities\n$\\pi_t(s)$ in \\eqref{eq:delay_prob1}, and how to use this alongside the observed\ncase reports $y_t$ in order to estimate the latent infections in\n\\eqref{eq:conv_model1}. \n\n\\subsection{Estimating the Delay Distribution} \n\\label{sec:delay_distribution}\n\nAt the outset, we place the following assumptions on the delay distribution in \norder to make its estimation (using the CDC line list data, to be described\nshortly) more tractable.   \n\n\\begin{assumption}\n\\label{asm:delay_support} \nInfections are always reported within $d=45$ days; that is, $\\pi_t(s) = 0$\nwhenever $s < t-d$. \n\\end{assumption}\n\n\\begin{assumption}\n\\label{asm:zero_at_zero}\nThe probability of zero delay is zero; that is, $\\pi_t(t) = 0$.\n\\end{assumption}\n\n\\begin{assumption}\n\\label{asm:geo_invar}\nThe delay distribution is geographically invariant (it is the same for any\nlocation). \n\\end{assumption}\n\nAssumption~\\ref{asm:delay_support} is innocuous. The vast majority of pairs of\nrecorded infection dates and report dates in the CDC line list data fall within\n$d=45$ days of one another. Assumption~\\ref{asm:zero_at_zero} is perhaps less\ninnocuous but still fairly minor, and it is a consequence of the fact that a\ndelay of zero (infection date equal to report date) has been used inconsistently\nin the CDC line list: this could mean a true delay of zero, or it could be a\ncode for missingness.\n\nAssumption~\\ref{asm:geo_invar} is the most noteworthy and troublesome. We do\n\\emph{not} believe it to be true that different locations actually have\nidentical patterns of delay between infections and case reports; conversely, we\nexpect there to be a considerable amount of variability between locations in\nthis regard. While we do allow the delay distribution to change over time (see\nFigure~\\ref{fig:line_list_time} for evidence for the importance of this), we\nconsider Assumption~\\ref{asm:geo_invar} to be a weakness of our work. However,\nthe \\emph{data is simply not there} in the CDC line list to warrant\nlocation-specific estimation of the delay distribution (see\nFigure~\\ref{fig:line_list_state}), thus we resort to estimating a nation-wide\ndelay distribution.\n\nMeanwhile, it is worth pointing out that better (location-specific) estimates of\nthe delay distribution could be simply plugged into our deconvolution\nmethodology (detailed in Section~\\ref{sec:ground_truth}) to yield better\nestimates of latent infections. This would carry over to all of the real-time  \nmethodology for deconvolution and sensor fusion (in\nSection~\\ref{sec:deconv_realtime}) as well. In other words, a strength of our\nmethodology is that it can treat the delay distribution as an input, and a user\n(say, a local health official) can replace the default nation-wide delay\ndistribution with a more-informed local one in order to get more-informed local \nestimates. \n\nIn light of Assumptions~\\ref{asm:delay_support} and \\ref{asm:zero_at_zero}, we\nchange our notation henceforth, and rewrite \\eqref{eq:conv_model1},\n\\eqref{eq:delay_prob1} as: \n\\begin{equation}\n\\label{eq:conv_model2}\n\\E[y_t \\,|\\, x_s, s \\leq t] = \\sum_{k=1}^d p_t(k) \\, x_{t-k},  \n\\end{equation}\nwhere for $k=1,\\ldots,d$,\n\\begin{equation}\n\\label{eq:delay_prob2}\np_t(k) = \\P\\big( \\text{case report at $t$} \\,|\\, \\text{onset at $t-k$} \\big). \n\\end{equation}\n\n\\smallskip\n\\paragraph*{CDC Line List.}\n\nThe CDC provides de-identified patient-level surveillance data on COVID-19 in\nboth public and restricted forms \\citep{cdc_public, cdc_restricted}. The\nrestricted one is made available under a data use agreement. The public line\nlist contains the same patient-level records as the restricted one, but it has\ngeographic details withheld. (There is another publicly available that contains\ngeographic details, but withholds temporal details). We use the public data\nset\\footnote{The CDC does not take responsibility for the scientific validity or\n  accuracy of methodology, results, statistical analyses, or conclusions\n  presented.} \nin this paper for estimating the delay distribution, since missingness compels\nus to make nation-wide (rather than location-specific) estimates.\n\nIt is worth noting that the line list is itself provisional and subject to\nrevision. Furthermore, the CDC only publishes updates to the line list\nmonthly. In this paper, for simplicity, we use a single version of the CDC line\nlist---released on September 9, 2021---to construct all delay\ndistributions. Nonetheless, in our real-time nowcasting experiments, we \nrestrict our access to data in this line list that would have been available at\neach nowcast date $t$ (rows whose report date to the CDC is at most $t$) to\nconstruct delay distribution estimates at $t$. This is highly nontrivial, due to\nbias induced by truncation of data after $t$ (see\nSection~\\ref{sec:delay_adjust}). \n\n\\smallskip\n\\paragraph*{Missing Values.}\n\nThe CDC line list (both public and restricted data sets) is subject to a high\ndegree of missingness. Such missingness manifests itself in a variety of\nways. For the public line list published on September 9, 2021: \n\\begin{itemize}\n\\item it has 29,851,450 rows, compared to 39,365,080 cumulative cases reported  \n  by JHU CSSE on September 9, 2021;\n\\item 8.64\\% of rows are missing the case report date (the\n  \\texttt{cdc\\_report\\_dt} column);    \n\\item 53.6\\% of rows are missing the symptom onset date (the \\texttt{onset\\_dt}\n  column);   \n\\item of all rows in which symptom onset date is present, the case report date\n  is also present, but when a report date is missing in practice it sometimes \n  gets filled in with the onset date, clouding the interpretation of a zero \n  delay.\\footnote{Confirmed by personal communication with the CDC.}     \n\\end{itemize}\nDue to the last point, we exclude zero in the construction of all delay\ndistribution estimates, in what follows. \n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/combined_linelist_plots_20210601.pdf}\n\\caption{Top: cumulative case count per state on June 1, 2021, as reported by\n  JHU CSSE, compared to the complete case count (where both onset date and\n  report date are observed) per state up through the same date, in the CDC\n  restricted line list. Most states have less than 50\\% of the cases appear in\n  complete form in the line list, and some (e.g., Texas) have almost none at\n  all. Bottom: proportion of complete cases with zero delay per state in the\n  same line list data. There is very wide variation between these proportions.} \n\\label{fig:line_list_state}\n\\end{figure*}\n\nThe restricted line list is no better with respect to such missingness, \nexhibiting nearly exactly the same patterns as those described above. It\ndoes additionally provide geographic details, which allows us to examine how  \nmissingness is dispersed across different locations. \nFigure~\\ref{fig:line_list_state} displays results to this end, using  \nthe restricted line list released on October 12, 2021. The top panel shows that\nthere is a high degree of missingness in complete case counts (those with\nboth onset date and report date observed) in most states, often well over 50\\%,\nand moreover, missingness is far from uniform at random: e.g., Texas has barely\nany of its cases present in the line list. The latter observation is why we\nresort to estimating nation-wide delay distributions, in what follows. \n\nThe bottom panel in the figure shows that there is also a high degree of\nheterogeneity in the fraction of complete cases with zero delay (between onset\ndate and report date) across states. Some states (e.g., California) have zero\ndelays for nearly all of their complete cases, while others (e.g., Delaware)\nhave zero delays for none of their complete cases, suggesting that the practice\nof setting a missing report date equal to the associated onset date is highly\ninconsistent between states. This only further corroborates the decision to\nexclude zero delays from the data set when estimating the delay distribution. \n\n\\smallskip\n\\paragraph*{Delay Distribution Estimation.}\n\nFrom the public line list, we estimate the delay distribution at each time $t$, \nnamely the probabilities in \\eqref{eq:delay_prob2} for $k=1,\\ldots,d$, using the  \nempirical distribution of all lags, excluding zero, between complete onset and\nreport dates, for all onset dates falling in $[t-2d+1, t]$. Then, we fit a gamma\ndensity to the empirical distribution by the method of moments, and discretize\nthe resulting density over the support $\\{1,\\ldots,d\\}$. For concreteness,\nthis procedure is described in Algorithm~\\ref{alg:delay_dist_retro}.   \n\n\\begin{algorithm}[tb]\n\\caption{Delay distribution estimation, retrospective}\n\\label{alg:delay_dist_retro}\n\\DontPrintSemicolon\n\\KwInput{Time $t$, support size $d$, window size $w=2d$, line list $\\D$ \n  with onset dates $a_i$ and report dates $b_i$.} \n\\KwOutput{Estimated delay probabilities \\smash{$\\hp_t(1), \\ldots, \\hp_t(d)$}.}  \n\nFind all pairs in $\\D$ with onset dates within a recent time window: $I_t = \\{i \n: a_i \\in (t-w, t]\\}$. \n\nCompute the empirical distribution of lags $1,\\ldots,d$ among these pairs: \n$$\n\\bp_t(k) = \\frac{|\\{i \\in I_t: b_i - a_i = k\\}|}\n{\\sum_{\\ell=1}^d |\\{i \\in I_t: b_i - a_i = \\ell\\}|}, \\;\\; k=1,\\ldots,d. \n$$\n\nFit a gamma density to \\smash{$\\bp_t(1), \\ldots, \\bp_t(d)$} using the method of\nmoments (matching the mean and variance). \n\nDiscretize this gamma density to the support set $\\{1,\\ldots,d\\}$, call the \nresult \\smash{$\\hp_t(1), \\ldots, \\hp_t(d)$}, and return these probabilities.\n\\end{algorithm}\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./figures/finalized_delay_quantiles.pdf}\n\\includegraphics[width=0.9\\linewidth]{./figures/overlay_finalized_delay_dist.pdf}\n\\caption{Top: quantiles of the estimated delay distribution returned by \n  Algorithm~\\ref{alg:delay_dist_retro} at the levels 50\\%, 75\\%, and 95\\%, as \n  $t$ varies from June 1, 2020 to June 1, 2021. Bottom: estimated delay\n  distributions overlaid for three nowcast dates within the same time\n  interval.}    \n\t\\label{fig:line_list_time}\n\\end{figure}\n\nWe use only ``recent'' pairs of onset and report dates at time $t$ (whose onset\ndate lies in $[t-2d+1, t]$) in order to adapt to the nonstationarity in\nreporting delays over time. The top panel in Figure~\\ref{fig:line_list_time}\nplots quantiles of the estimated delay distribution from\nAlgorithm~\\ref{alg:delay_dist_retro}, as $t$ ranges from June 1, 2020 to June 1,\n2021. We see sharp drops in all quantiles during the first half of this period,\nand then a more gradual decline over time. The bottom panel in the figure gives\na qualitative sense of how the delay distribution estimates change in shape over\ntime.\n\n\\subsection{Defining Ground Truth}\n\\label{sec:ground_truth}\n\nGiven the estimated delay distributions over time from the previous subsection, \nwe now describe how to estimate latent infections in the model\n\\eqref{eq:conv_model2}. In short, we will solve one large optimization problem\nto perform deconvolution. To define the best possible retrospective estimates of\nlatent infections over the period October 1, 2020 to June 1, 2021, which we will\ntreat as \\emph{ground truth} in what follows (in the sense that they will be the\npoint of comparison for all of our real-time estimates), we will perform\ndeconvolution over a wider time period than the previously specified one in\norder to avoid any bias issues at the boundaries (where there is insufficient\ndata for accurate deconvolution; more details are provided in the next\nsection): our retrospective deconvolution runs from May 1, 2020 to August 28,\n2021, a period we denote by $\\T$, and uses case data published on August 30,\n2021. \n\nFor location $\\ell$, denote by $y_{\\ell,t}$ and $x_{\\ell,t}$ the number of new\ncases reported and number of new infections that onset at time $t$,\nrespectively, per 100,000 people. Note that $y_{\\ell,t},x_{\\ell,t}$ obey\n\\eqref{eq:conv_model2}, \\eqref{eq:delay_prob2}, because we have just rescaled\nthe underlying counts here by a constant (in order to put them on the scale of\nrates), and recall, we assume that all locations have the same delay\ndistribution (Assumption~\\ref{asm:geo_invar}).\n\nGiven the delay distribution estimates from\nAlgorithm~\\ref{alg:delay_dist_retro}, \\smash{$\\hp_t = (\\hp_t(1), \\ldots, \n  \\hp_t(d))$} for $t \\in \\T$, we estimate the full vector \\smash{$x_\\ell =\n  (x_{\\ell,t})_{t \\in \\T}$} of latent infection rates across time, separately\nfor each location $\\ell$, by solving the problem:   \n\\begin{multline}\n\\label{eq:tf_retro}\n\\minimize_{x_\\ell} \\; \\sum_{t \\in \\T} \\bigg( y_{\\ell,t} - \\sum_{k=1}^d \\hp_t(k)\n\\, x_{\\ell, t-k} \\bigg)^2 +{} \\\\ \\lambda \\|D^{(4)} x_\\ell\\|_1,   \n\\end{multline}\nwhere $D^{(4)}$ is a matrix such that $D^{(4)} v$ gives all 4$\\th$-order\ndifferences of a vector $v$, and $\\|\\cdot\\|_1$ is the $\\ell_1$ norm. Problem \n\\eqref{eq:tf_retro} could be called a trend-filtering-regularized least squares \ndeconvolution problem. We solve it (as well as all related optimization problems\nin this paper) numerically with an adaption of the ADMM algorithm of \n\\citet{ramdas2016fast}, detailed in Appendix~\\ref{app:tf_admm}. \n\nThe solution \\smash{$\\hx_\\ell$} in problem \\eqref{eq:tf_retro} takes the form of\na cubic piecewise polynomial (discrete spline) with adaptively chosen\nknots \\citep{tibshirani2014adaptive, tibshirani2020divided}. The tuning\nparameter $\\lambda \\geq 0$ controls its complexity, and we choose it using  \n3-fold cross-validation: we hold out every third value from training, and impute\nit by the average of the neighboring trained estimates; to compute the\nvalidation error, we reconvolve the full vector of imputed infections and\nmeasure against observed cases. \n \n\\section{Real-Time Deconvolution}\n\\label{sec:deconv_realtime}\n\nReal-time deconvolution refers to the the task of deconvolving case reports\nobserved up until time $t$ to estimate latent infections up until $t$,\nrepeatedly, as $t$ marches over the period of interest. We are particularly\nfocused on estimating recent latent infections---nowcasting at a $k$-day lag,\nwhich means estimating at $t$ the latent infection rate at time $t-k$.\n\nCompared to retrospective deconvolution, real-time deconvolution differs in two\nimportant ways. The first is that we are forced to work with provisional case\ndata, subject to revision at times in the future, as discussed earlier in\nSection~\\ref{sec:problem_setup}. All of our experiments in what follows use\nproperly-versioned data that would have been available as of the nowcast date.\nWe use the notation \\smash{$y^{(t)}_{\\ell,s}$} to reflect the reported case rate\nin location $\\ell$ at time $s$ as of time $t$. Reported case data from JHU is\navailable at a 1-day lag and therefore, as of time $t$, we only observe\n\\smash{$y^{(t)}_{\\ell,s}$} up through $s=t-1$ (we use analogous superscript\nnotation for all auxiliary signals and estimates). This means we can only\nproduce deconvolution estimates \\smash{$\\hx^{(t)}_{\\ell,s}$} up through $s=t-2$ \n(recall we exclude zero delays, in Assumption~\\ref{asm:zero_at_zero}). \n\n\\begin{figure}[tb]\n\\centering\t\n\\includegraphics[width=0.95\\linewidth]{./figures/right_truncation_illustration.pdf}\n\\caption{Illustration of right truncation with a delay distribution of length 3\n  (which is taken to be stationary for simplicity). At the nowcast time $t$,\n  some ``part'' of the latent signal $x_t$ will appear in $y_{t+1},y_{t+2}$;\n  likewise, some ``part'' of $x_{t-1}$ will appear in $y_{t+1}$.}   \n\\label{fig:right_truncation}\n\\end{figure}\n\nThe second issue of note, in real-time deconvolution, is \\emph{right\n  truncation}: in nowcasting at lag $k$, where $k$ is small (compared to $d$),\nwe are only able to carry out a ``partial'' deconvolution, as much of the needed  \ninformation would come from case reports occurring in the future, past time the\nnowcast date $t$. Figure~\\ref{fig:right_truncation} gives an illustration. Thus,\nif we simply performed real-time deconvolution by solving the problem analogous\nto \\eqref{eq:tf_retro}, using data that would have been available at time $t$,   \n\\begin{multline}\n\\label{eq:tf_realtime1}\n\\minimize_{x^{(t)}_\\ell} \\; \\sum_{s < t} \\bigg( y^{(t)}_{\\ell,s} -\n\\sum_{k=1}^d \\hp^{(t)}_s(k) \\, x^{(t)}_{\\ell, s-k} \\bigg)^2 +{} \\\\  \n\\lambda \\big\\|D^{(4)} x^{(t)}_\\ell\\big\\|_1,\n\\end{multline}\nthen we would find that the solution \\smash{$\\hx^{(t)}_\\ell = (\\hx^{(t)}_{\\ell,s}\n  : s < t)$} has highly volatile components for $s$ close to $t$.\n\nThe problem does not stop there; the truncation of data after the nowcast time\n$t$ also affects estimation of the delay distribution itself. Most rows in the\nline list with an onset date of $s=t-k$, for small $k$, will only have a report\ndate (and thus not appear in the line list) until after time $t$. This means\nthat the estimate \\smash{$\\hp^{(t)}_s$} of $p_s$ given by the empirical\ndistribution of all available line list data, with report date less than $t$,\nwill be biased toward smaller lag values (i.e., it will place too little weight\non larger lag values).    \n\nIn the next two subsections, we work through each of these truncation issues in\nturn, by incorporating extra regularization around the right boundary into the  \ncriterion in \\eqref{eq:tf_realtime1}, and estimating the delay distribution\nfrom truncated data using a Kaplan-Meier-like approach. \n\n\\subsection{Incorporating Extra Regularization}\n\\label{sec:extra_regularization}\n\nWe consider two forms of extra regularization to dampen the variability of trend\nfiltering estimates toward the right boundary. \n\n\\smallskip\n\\paragraph*{Natural Trend Filtering.}\n\nA natural cubic spline places additional regularity on top of the cubic spline,\nby maintaining that the function be linear beyond the left and right boundary\npoints of the underlying domain. Natural trend filtering proceeds in a similar\nvein, but operating in the space of discrete splines; see\n\\citet{tibshirani2020divided}. Transporting this idea over to our real-time  \ndeconvolution problem \\eqref{eq:tf_realtime1}, and applying it to the right\nboundary only, gives:\n\\begin{equation}\n\\label{eq:tf_realtime2}\n\\begin{alignedat}{2}\n&\\minimize_{x^{(t)}_\\ell} \\; && \\sum_{s < t} \\bigg( y^{(t)}_{\\ell,s} -\n\\sum_{k=1}^d \\hp^{(t)}_s(k) \\, x^{(t)}_{\\ell, s-k} \\bigg)^2 +{} \\\\  \n& && \\hspace{100pt} \\hfill\n\\lambda \\big\\|D^{(4)}  x^{(t)}_\\ell \\big\\|_1 \\\\\n&\\subjectto && \\;\\; x^{(\\ell)}_t - 2x^{(\\ell)}_{t-1} + x^{(\\ell)}_{t-2} = 0.\n\\end{alignedat}\n\\end{equation}\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=.315\\linewidth]{./figures/ny_tf.pdf}\n\\includegraphics[width=.315\\linewidth]{./figures/ny_ntf.pdf}\n\\includegraphics[width=.315\\linewidth]{./figures/ny_tapered_ntf.pdf}\n\\caption{Comparison of boundary behavior for real-time deconvolution in New \n  York, displayed for a sample of different nowcast dates (where each colored\n  curve traces out the deconvolution estimates for a different nowcast\n  date). The black dashed line indicates finalized infections, estimated roughly\n  three months after June 1, 2021.}  \n\\label{fig:boundary_comparison}\n\\end{figure*}\n\nThe left and middle panels of Figure~\\ref{fig:boundary_comparison} demonstrate\nthe improvement that the additional constraints in \\eqref{eq:tf_realtime2} can\nhave on the boundary estimates, particularly during periods of dynamic change in\nthe underlying case trajectories.\n\n\\smallskip\n\\paragraph*{Tapered Smoothing.}\n\nThe right truncation phenomenon is not a binary one and there is increasingly\nless and less information available for deconvolution as we move the time index\n$s$ up toward the nowcast date $t$. Therefore, we design a second penalty to add\nto the criterion in \\eqref{eq:tf_realtime2} to gradually increase the amount of\nregularization accordingly:  \n\\begin{equation}\n\\label{eq:tf_realtime3}\n\\begin{alignedat}{2}\n&\\minimize_{x^{(t)}_\\ell} \\; && \\sum_{s < t} \\bigg( y^{(t)}_{\\ell,s} -\n\\sum_{k=1}^d \\hp^{(t)}_s(k) \\, x^{(t)}_{\\ell, s-k} \\bigg)^2 +{} \\\\  \n& && \\hspace{25pt} \\hfill\n\\lambda \\big\\|D^{(4)} x^{(t)}_\\ell \\big\\|_1 +\n\\gamma \\big\\|W^{(t)} D^{(1)} x^{(t)}_\\ell \\big\\|_2^2 \\\\ \n&\\subjectto && \\;\\; x^{(\\ell)}_t - 2x^{(\\ell)}_{t-1} + x^{(\\ell)}_{t-2} = 0, \n\\end{alignedat}\n\\end{equation}\nwhere $D^{(1)} v$ gives the first-order differences of a vector $v$, and \n$W^{(t)}$ is a diagonal matrix that is supported on the last $d$ diagonal\nentries, these being (in reverse order, starting with the last entry): \n$$\n\\frac{1}{\\sqrt{\\hF^{(t)}_{t-1}(k)}}, \\;\\; k=1,\\dots,d, \n$$\nwhere \\smash{$\\hF^{(t)}_{t-1}$} is the cumulative distribution function (CDF) \ncorresponding to the estimated delay distribution \\smash{$\\hp^{(t)}_{t-1}$} at\nthe most recent time $t-1$. The parameter $\\gamma \\geq 0$ controls the\nstrength of the additional ``tapered'' penalty in \\eqref{eq:tf_realtime3}, and\nwe tune $\\lambda,\\gamma$ with a two-stage cross-validation procedure: \n\\begin{enumerate}\n\\item fix $\\gamma =0$, and tune $\\lambda$ using 3-fold cross-validation,\n  as before;    \n\\item fix $\\lambda$ at the value in Step 1, and tune $\\gamma$ using \n  7-fold forward-validation: for $s= t-2, \\ldots, t-8$, we solve the\n  deconvolution problem with a working nowcast date of $s$, linearly extrapolate\n  to impute an estimate at $s+1$, and then we reconvolve the solution vector\n  along with this imputed point and measure error against observed cases at time\n  $s+1$; the validation error is obtained by averaging these errors over the\n  iterations $s =  t-2, \\ldots, t-8$. \n\\end{enumerate}\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/effect_tapered_ntf.pdf}\n\\caption{Effect of the tapered smoothing penalty, as we vary the \ncorresponding tuning parameter $\\gamma$, for a single real-time \ndeconvolution example with on nowcast date February 1, 2021. The gray \nregion highlights the  components on which the tapered smoothing penalty \nacts.}\n\\label{fig:tapered_smooth}\n\\end{figure*}\n\nFigure~\\ref{fig:tapered_smooth} displays the effect of varying $\\gamma$ on the\nsolution in \\eqref{eq:tf_realtime3}, for a particular deconvolution example, to\ngive a qualitative sense of the role of the tapered penalty. Furthermore, the\nright panel in Figure~\\ref{fig:boundary_comparison} demonstrates the benefit\nthis penalty can provide in nowcasting.\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.85\\linewidth]{./figures/tapered_smoothing_03_small_square.pdf}\n\\caption{Comparing regularization approaches by MAE for nowcasting (the shaded\n  bands here and henceforth, in all MAE figures, correspond to 95\\% bootstrap\n  confidence intervals.) Both approaches for additional regularization give a\n  huge improvement on trend filtering. The biggest improvement comes from\n  combining the two approaches.}\n\t\\label{fig:extra_reg}\n\\end{figure}\n\nLastly, and importantly, Figure~\\ref{fig:extra_reg} quantifies the improvement\noffered by the additional regularization mechanisms, in terms of mean absolute\nerror (MAE) measured against finalized infections in nowcasting at a $k$-day\nlag, for each $k=2,\\ldots,10$. This is averaged over all locations and every\n10th nowcast date in the evaluation set. We see a considerable improvement in \nboth the natural trend filtering and tapered smoothing modifications, with the\nbiggest improvement occurring when the two are combined as in\n\\eqref{eq:tf_realtime3}, and hence we stick with this framework in what follows. \n\n\\subsection{Adjusting the Delay Distribution for Truncation}   \n\\label{sec:delay_adjust}\n\nNow we propose an iterative adjustment to the empirical distribution of\ntruncated line list data in order to overcome the truncation bias. To develop\nintuition, we first describe the problem using a simple abstraction, formulate a\ngeneral solution, and then we translate this back over to our particular\nsetting.   \n\n\\smallskip\n\\paragraph*{KM-Adjustment Under Truncation.}\n\nSuppose $p$ is a distribution that is supported on $\\{1,\\ldots,d\\}$, and we observe\nindependent random draws that we can partition into two sets: $\\D_1$ and $\\D_2$,\nwhere $\\D_2$ contains draws from $p$ and $\\D_1$ contains draws from $p$\nconditional on the random variable lying in $[1,z_1]$, for a fixed $z_1 \\in\n\\{1,\\ldots,d\\}$. Denote by \\smash{$\\hp_\\D$} the empirical distribution based on\na data set $\\D$. Clearly \\smash{$\\hp_{\\D_2}$} is unbiased for $p$, but\n\\smash{$\\hp_{\\D_1}$} is generally biased (it always places zero mass above\n$z_1$), and thus the pooled estimate \\smash{$\\hp_{\\D_1 \\cup \\D_2}$} would be\nbiased as well.\n\nTo build a more informed estimate based on the pooled sample, the intuition \nis as follows. First, observe that the only way we can estimate $p(k)$ for $k > \nz_1$ is by using $\\D_2$. Then, this gives an estimate of \\smash{$S(z_1) =\n  \\sum_{k >  z_1} p(k)$}, the survival function of $p$ at $z_1$, and we can\nestimate $p(k)$ for $k \\leq z_1$, denoting $Z \\sim p$, by observing that  \n$$\np(k) = \\P(Z = k \\,|\\, Z \\leq z_1) (1-S(z_1)).\n$$\nwhere we estimate $\\P(Z = k | Z \\leq z_1)$ using the empirical distribution     \nover the set $\\D_1 \\cup \\D_2 \\cap [1, z_1]$. In other words, we construct our   \ndistribution estimate \\smash{$\\bp$} using two steps:     \n\\begin{enumerate}\n\\item define $\\bp(k) = \\hp_{\\D_2}(k)$ for $k > z_1$, and also $\\bS(z_1) =\n  \\sum_{k >  z_1} \\bp(k)$;\n\\item define $\\bp(k) = \\hp_{\\D_0}(k) (1-\\bS(z_1))$ for $k \\leq z_1$, where we\n  let $\\D_0 = \\D_1 \\cup \\D_2 \\cap [1, z_1]$. \n\\end{enumerate}\n\nWe can readily generalize the above to a setting in which we observe $N$ data \nsets, with varying levels of truncation:\n\\begin{equation}\n\\label{eq:data_seq_trunc}\n\\text{$\\D_i$ contains draws $Z \\sim p \\,| Z \\leq z_i$, $i=1,\\ldots,N$},\n\\end{equation}\nwhere $1 \\leq z_1 < \\cdots < z_N = d$, and we set $z_0=0$ for notational\nsimplicity. To construct an estimate of $p$ based on all the samples, we proceed \niteratively as before: first we estimate $p(k)$ for $k > z_{N-1}$ based on the\ndata in $\\D_N$, then we estimate $p(k)$ for $k \\in (z_{N-2},z_{N-1}]$ based on\ndata in $\\D_{N-1} \\cup \\D_2 \\cap [1, z_{N-1}]$, and so on. \nAlgorithm~\\ref{alg:dist_seq_trunc} spells out the procedure in full. \n\n\\begin{algorithm}[tb]\n\\caption{Distribution estimation under sequential truncation} \n\\label{alg:dist_seq_trunc}\n\\DontPrintSemicolon\n\\KwInput{Data sets and truncation limits $\\D_i$ and $z_i$, for $1,\\ldots,N$, as \n  in \\eqref{eq:data_seq_trunc}.}    \n\\KwOutput{Estimated probabilities \\smash{$\\bp(1),\\ldots,\\bp(d)$}.}\n\nInitialize $\\bS(d) = 0$. \n\n\\For{$i = N, \\ldots, 1$} {\n  Set $\\D_0 = \\bigcup_{j=i}^N D_j \\cap [1, z_i]$.\n  \n  Compute $\\bp(k)$, for $k \\in (z_{i-1}, z_i]$ based on the empirical\n  distribution of data in $\\D_0$ and an estimate of the survival function at\n  $z_i$:     \n  $$\n  \\bp(k) = \\hp_{\\D_0}(k) (1-\\bS(z_i)), \\;\\; k \\in (z_{i-1}, z_i].\n  $$\n  \n  Compute an estimate of the survival function at $z_{i-1}$: \n  $$\n  \\bS(z_{i-1}) = \\bS(z_i) + \\sum_{k \\in (z_{i-1}, z_i]} \\bp(k). \n  $$\n}\n\nReturn \\smash{$\\bp(1),\\ldots,\\bp(d)$}. \n\\end{algorithm}\n\nThe algorithm just derived may be seen as Kaplan-Meier-like, in the sense that \nit is motivated by the decomposition\n$$\np(k) = \\P(Z=k \\,|\\, Z \\leq z_i) (1-S(z_i)), \\;\\; k \\in (z_{i-1}, z_i]. \n$$\nWe use an unbiased plug-in estimate for each term in the product above  \nbased on the appropriate data. The Kaplan-Meier estimator has a similar plug-in \nfoundation \\citep{kaplan1958nonparametric}, so we refer to our approach as the  \n\\emph{KM-adjusted estimator} of the distribution under truncation. \n\n\\smallskip\n\\paragraph*{Application to CDC Line List.}\n\nPorting the last idea over to the CDC line list, we can use it to estimate the\ndelay distribution at time $s$ using the line list as of time $t$. Note that if\n$s < t-d$ then we can still use Algorithm~\\ref{alg:delay_dist_retro}, as\nthere is no truncation issue whatsoever. However, if $s \\geq t-d$, then we would \nneed to apply the KM-adjusted estimator, because we would be using the rows in\nthe line list whose onset date is at or shortly before $s$, but are only able to\nsee those whose report date is at most $t-1$ (thus would have been available \nat time $t$). After making this adjustment to the empirical distribution, we\napply gamma smoothing as before. This is detailed in\nAlgorithm~\\ref{alg:delay_dist_realtime}. \n\n\\begin{algorithm}[tb]\n\\caption{Delay distribution estimation in real-time}\n\\label{alg:delay_dist_realtime}\n\\DontPrintSemicolon\n\\KwInput{Nowcast time $t$, working onset time $s$, support size $d$, window size \n  $w=2d$, truncated line list \\smash{$\\D^{(t)}$} with onset dates $a_i$ and report\n  dates $b_i$ such that $b_i < t$.}  \n\\KwOutput{Estimated delay probabilities \\smash{$\\hp^{(t)}_s(1), \\ldots,\n    \\hp^{(t)}_s(d)$}.}   \n\n\\If{$s < t-d$} {\n  Return probability estimates from Algorithm~\\ref{alg:delay_dist_retro}\n  (setting $t=s$ and \\smash{$\\D=\\D^{(t)}$} in the notation of that algorithm).} \n\nSet $N=d-(t-s)+2$. \n\n\\For{$i = 1, \\ldots, N-1$} {\n  Define \n  \\begin{align*}\n  \\D_i &= \\{ b_i - a_i :  a_i = s-i+1 \\} \\\\\n    z_i &= t-s+i-2. \n  \\end{align*}\n}\n\nDefine $\\D_N = \\{ b_i - a_i :  a_i \\in (s-w, t-d) \\}$ and $z_N = d$.\n\nUse Algorithm~\\ref{alg:dist_seq_trunc} (applied to $\\D_i$, $z_i$,\n$i=1,\\ldots,N$) to compute probability estimates \\smash{$\\bp_t(1), \\ldots, \n  \\bp_t(d)$}. \n\nFit a gamma density to \\smash{$\\bp_t(1), \\ldots, \\bp_t(d)$} using the method\nof moments (matching the mean and variance). \n\nDiscretize this gamma density to the support set $\\{1,\\ldots,d\\}$, call the \nresult \\smash{$\\hp_t(1), \\ldots, \\hp_t(d)$}, and return these probabilities. \n\\end{algorithm}\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.85\\linewidth]{./figures/range_overlay.pdf}\n\\includegraphics[width=0.85\\linewidth]{./figures/l1_summary.pdf}\n\\caption{Top: estimated delay distributions overlaid for all nowcast dates in\n  the month of November 2020, when $s=t-1$ (working onset date one day \n  before the nowcast date). Bottom: mean $\\ell_1$ distance to finalized\n  estimate of the delay distribution, as a function of the lag $k=t-s$.}     \n\\label{fig:delay_dist_realtime}\n\\end{figure}\n\nFigure~\\ref{fig:delay_dist_realtime} compares the KM-adjusted and naive\nestimates of the delay distribution, Algorithm~\\ref{alg:delay_dist_realtime}\nversus Algorithm~\\ref{alg:delay_dist_retro} applied directly to\n\\smash{$\\D^{(t)}$}, the line list available at each nowcast date $t$. In terms\nof $\\ell_1$ distance, measured to the finalized delay distribution estimate\ncomputed retrospectively (based on the full untruncated line list), and averaged\nover all  nowcast dates in the evaluation period, we see that the KM-adjustment\ngreatly improves the accuracy at all lags $k=2,\\ldots,10$ (where $k=t-s$, the \ndifference between the nowcast and working onset dates). \n\n\\subsection{Shortening the Deconvolution Window}\n\nLastly, we investigate shortening the window used in the regularized\ndeconvolution problem \\eqref{eq:tf_realtime3} so that we use only a window \nlength of $w$ days before $t$:\n\\begin{equation}\n\\label{eq:tf_realtime4}\n\\begin{alignedat}{2}\n&\\minimize_{x^{(t)}_\\ell} \\; && \\sum_{s \\in [t-w, t)} \\bigg( y^{(t)}_{\\ell,s} - \n\\sum_{k=1}^d \\hp^{(t)}_s(k) \\, x^{(t)}_{\\ell, s-k} \\bigg)^2 +{} \\\\  \n& && \\hspace{25pt} \\hfill\n\\lambda \\big\\|D^{(4)} x^{(t)}_\\ell \\big\\|_1 +\n\\gamma \\big\\|W^{(t)} D^{(1)} x^{(t)}_\\ell \\big\\|_2^2 \\\\ \n&\\subjectto && \\;\\; x^{(\\ell)}_t - 2x^{(\\ell)}_{t-1} + x^{(\\ell)}_{t-2} = 0, \n\\end{alignedat}\n\\end{equation}\nAs we are mainly interested in the components of the solution\n\\smash{$\\hx^{(t)}_s$} for $s$ close to $t$, shortening the training window is\ncomputationally advantageous and should not change the behavior of the solution\nvery much for $s$ close to $t$.\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.85\\linewidth]{./figures/deconvolution_window_05_small_square.pdf}\n\\caption{Comparing window lengths used in regularized deconvolution by\n  MAE for nowcasting. The performance is very similar throughout.}\n\\label{fig:deconvolution_window}\n\\end{figure}\n\nFigure~\\ref{fig:deconvolution_window} compares \\eqref{eq:tf_realtime4} with\n$w=2d$, $w=4d$, and ``all-past'', which is the original problem\n\\eqref{eq:tf_realtime3}, in terms of mean absolute error (MAE) measured against\nfinalized infections in nowcasting at a $k$-day lag, for each\n$k=2,\\ldots,10$. This is averaged over all locations and every 10th nowcasting\ndate in the evaluation set. The performance is basically identical for window\nlengths $2d$ and $4d$, and though all-past may appear to have the slightest \nadvantage, this does not warrant the extra computation, hence in what follows\nwe stick to \\eqref{eq:tf_realtime4} with a window length $w=2d$ as our\nreal-time deconvolution estimator.    \n\n\\section{Leveraging Auxiliary Signals}\n\\label{sec:leverage_aux}\n\nThe indicators enumerated in Section~\\ref{sec:preliminaries} have displayed\nimpressive correlations to reported COVID-19 cases \\citep{Reinhart:2021}, and\nmoreover, demonstrated an ability to improve the accuracy of case forecasting\nand hotspot prediction models \\citep{McDonald:2021}. In this section, we\ndescribe how to use each indicator to build a real-time \\emph{sensor} that\nestimates the latent infection rate, and how to fuse such estimates together\ninto a single nowcast.\n\n\\subsection{Sensor Models}\n\\label{sec:sensor_models}\n\nAt each prediction time $t$, for each location $\\ell$, and for each of the five\nindicators (abbreviated CHNG-COVID, CHNG-CLI, DV-CLI, CTIS-CLIIC, and\nGoogle-AA), we will train a model to predict in real-time\nlatent infections from indicator values. Let \\smash{$\\hx^{(t)}_{\\ell,s}$} denote\nthe solution at time $s$ in problem \\eqref{eq:tf_realtime4}, which represents\nour best estimate of the latent infection rate at time $s$ as of time $t$ from\ndeconvolution of case rates alone. \n\nWe use \\smash{$z^{i,(t)}_{\\ell,s}$} to denote the value of indicator $i$ at time\n$s$ and location $\\ell$, as of time $t$. We fit a simple linear model to predict \nlatent infections from indicator values by solving \n\\begin{equation}\n\\label{eq:sensor_reg}\n\\minimize_{\\beta_0, \\beta_1} \\; \\sum_{s = t-d}^{t-\\tilde{k}_i}\nw^{(t)}_s \\big( \\hx^{(t)}_{\\ell,s} - \\beta_0 - \\beta_1 z^{i,(t)}_{\\ell,s} \\big)^2,\n\\end{equation}\nwhich is a weighted linear regression over the time period $[t-d,\nt-\\tilde{k}_i]$, where \\smash{$\\tilde{k}_i = \\max\\{k_i, 2\\}$} and $k_i$ denotes\nthe lag at which indicator $i$ is available. This is:\n\\begin{itemize}\n\\item $k_i=1$ for CTIS-CLIIC and\n  Google-AA\\footnote{Our treatment of Google-AA is different from the \n  rest. Google's team did not start publishing this signal until September 2020,\n  and the historical latency of this signal was sporadic, but was often longer\n  than 1 week. However, unlike (say) the claims-based signals, revisions are\n  never made after initial publication, and the latency of the signal is not an\n  unavoidable property of the data type, and therefore we use finalized signal\n  values, with a 1-day lag, in our analysis.}; and \n\\item $k_i=4$ for the claims-based indicators, due to heavy revision or\n  ``backfill'' over the first several days in the underlying claims data after\n  an outpatient visit date \\citep{Reinhart:2021}. \n\\end{itemize}\nNotice that, as defined, \\smash{$\\tilde{k}_i$} is the lag at which \\emph{both}\nthe deconvolution estimate of infection rate and auxiliary signal $i$ are\navailable, which is the data we need to fit the linear sensor model (response\nand covariate data, respectively). \n\nThe observation weights in \\eqref{eq:sensor_reg} are given by\n$$\nw^{(t)}_{t-k} = \\hS^{(t)}_{t-1}(k-1), \\;\\; k=1,\\ldots,d.\n$$ \nHere \\smash{$\\hS^{(t)}_{t-1}$} is the survival function of\n\\smash{$\\hp^{(t)}_{t-1}$}, the estimated delay distribution from the most recent\ntime point $t-1$. We define \\smash{$\\hS^{(t)}_{t-1}(1) = 1$}, corresponding to \nthe exclusion of 0-day delays. This scheme upweights the more recent estimates\n(responses in the regression) of latent infections as they contain more timely\ninformation for nowcasting (assuming that the right-truncation bias has been\neffectively mitigated in the deconvolution step).\n\nGiven the solution \\smash{$\\hbeta^{i,(t)}_{\\ell,0}, \\hbeta^{i,(t)}_{\\ell,1}$} in\n\\eqref{eq:sensor_reg}, we then define a sensor---which is just a prediction from\nthe fitted linear model---based on indicator $i$, for time $s$ and location\n$\\ell$, as of time $t$, as:\n\\begin{equation}\n\\label{eq:sensor_def}\n\\bx^{i,(t)}_{\\ell,s} = \\hbeta^{i,(t)}_{\\ell,0} + \\hbeta^{i,(t)}_{\\ell,1} \\,\nz^{i,(t)}_{\\ell,s}. \n\\end{equation}\nThis sensor is available up until $s=t-k_i$. For the CTIS-CLIIC and Google-AA\nsensors, the lag is $k_i=1$, smaller than the inherent lag of 2 in the\ndeconvolution estimate. \n\nIn brief, each sensor model takes a certain indicator and transforms it---using\na location-specific and time-varying mapping---to the scale of local infection\nrates. While this mapping is simple (based on linear regression), it is also\nhighly nontrivial, as it inherently accounts for geographic biases and\nnonstationarity.\n\nFinally, in addition to defining sensors based on \\eqref{eq:sensor_reg},\n\\eqref{eq:sensor_def} for each of the five auxiliary sensors, we also define a\nsixth sensor based on a 3$\\rd$ order autoregressive model trained on\n\\smash{$\\hx^{(t)}_\\ell = (\\hx^{(t)}_{\\ell,s} : s < t)$}. It is constructed \nexactly as in \\eqref{eq:sensor_reg}, \\eqref{eq:sensor_def} (same weights and\nsame training window). Henceforth we abbreviate it AR(3). \n\n\\subsection{Sensor Missingness}\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/availability.pdf}\n\\caption{Proportion of observed (non-missing) values over the evaluation \n  period from October 1, 2020 to June 1, 2021, and over all locations, as a \n  function of lag $k=1,\\ldots,10$. (NTF refers to the real-time deconvolution\n  estimator, and simple average refers to the sensor fusion method that \n  averages all available sensors.) The bottom two rows reflect the\n  intersection of location-time pairs for which all data---deconvolution \n  estimates and sensors---are available for that given lag, with and\n  without including the Google-AA sensor, since this sensor has a large amount\n  of individual missingness. Each intersection at each given lag $k$ is restricted\n  to data whose latency is not greater than $k$. For example, the bottom\n  leftmost cell computes the porportions of locations and dates at which AR(3), \n  CTIS-CLIIC, and the simple average are concurrently available.} \n\\label{fig:sensor_avail}\n\\end{figure*}\n\nTo be clear \\eqref{eq:sensor_reg}, \\eqref{eq:sensor_def} are to be implicitly\nunderstood as performed over observed (non-missing) indicator values. If an\nindicator value is missing at a particular location and time, then we drop it\nfrom the training set in \\eqref{eq:sensor_reg}, and do not produce a\ncorresponding sensor value in \\eqref{eq:sensor_def}. For a summary of\nmissingness in the sensors, see Figure~\\ref{fig:sensor_avail}.\n\nIn general, an indicator will be missing when there is insufficient underlying\ndata (from surveys, medical claims, etc.) to form a reliable signal value at a\ngiven location and time. However, the situation is different for the Google-AA\nindicator: here missingness occurs because the COVID-19 search trends data set\nis released after using a differential privacy layer \\citep{Bavadekar:2020}, and\na missing value means that the level of noise added for privacy protection is\nhigh compared to the search count. Therefore we impute missing Google-AA signal\nvalues by zeros in our analysis; we do this unless the Google-AA signal was\nmissing for a particular location and \\emph{all} times in the evaluation period,\nin which case we leave it as missing for this location entirely.\n\n\\subsection{Sensor Fusion}\n\\label{sec:sensor_fusion}\n\nSensor fusion (SF), broadly speaking, refers to the process of assimilating  \ndata sources, each of which ideally contains complementary information, in order\nto produce more accurate estimates or predictions. SF falls into the general \nclass of ensemble methods, and the sensors constructed in the previous section\ncan be thought of as base learners, to be subsequently combined.\n\nWe consider the following five ensemble methods. In each case, we describe how\nto form the estimate at time $s$ and location $\\ell$ as of time $t$. Though not\nexplicitly stated, it is to be implicitly understood that all sensor values are\nas of time $t$ as well. \n\n\\begin{enumerate}\n\\item Simple average: the average of available sensors at time $s$ and location \n  $\\ell$. \n\\item Simple regression: the prediction from a linear regression model at time\n  $s$ and location $\\ell$, fit to available sensors over the training period at\n  location $\\ell$. \n\\item Ridge: the prediction from a ridge regression model at time $s$ and\n  location $\\ell$, fit to available sensors over the training period and over\n  locations $j$ such that $j,\\ell$ lie in the same U.S.\\ state (including the\n  state sensor itself).   \n\\item Lasso: same as in the last item, but using the lasso instead of ridge\n  regression. \n\\item KF-SF: the Kalman-Filter-inspired method for sensor fusion from\n  \\citet{Farrow:2016, Jahja:2019}, with covariance shrinkage, and\n  operating on the geographical hierarchy within each U.S.\\ state. \n\\end{enumerate}\nMethods 2--5 are trained on the most recent $2d$ time points, and 3--5 are tuned\nusing 7-fold forward validation, where we allow them to choose a lag-specific\ntuning parameter. Methods 1--2 are ``simple'' in the sense that for nowcasting\nat a location $\\ell$ they use sensors from $\\ell$ only. Methods 3--5 are more\nsophisticated in that they pool information across locations within the same\nstate. % (using sensors from neighboring counties and from the parent state for  \n% nowcasting in a given county).\n\nThe KF-SF method requires a proper geographical hierarchy and thus we create\n``rest-of-state'' jurisdictions by aggregating the remaining counties (outside\nof the top 200 counties nationally) within each state, and to run KF-SF, we\ncreate an AR(3) sensor at these rest-of-state locations (since one sensor at\neach location is sufficient). It is worth noting that, as shown in\n\\citet{Jahja:2019}, KF-SF bears a close connection to ridge in Model 4: it \nis in fact equivalent to a modified ridge optimization problem that imposes\nadditional linear constraints. \n\n\\section{Evaluation}\n\\label{sec:evaluation}\n\nWe now evaluate nowcasting performance over all locations and all but every 10th\nnowcasting date in our evaluation period from October 1, 2020 to June 1,\n2021. (We do this because it gives us a ``pure'' test set, since every 10th\nnowcasting date was already used to choose the real-time deconvolution\nmethodology in Section~\\ref{sec:deconv_realtime}.) As before, we compare to\nfinalized estimates of infection rates computed via retrospective deconvolution,\nas in Section~\\ref{sec:deconv_retro}. \n\nFor the purposes of making fair comparisons, in every analysis (figure) that we\npresent, we only aggregate over the intersection of nowcasts dates and locations\nat which the particular estimates under consideration---coming from real-time \ndeconvolution, individual sensor models, or sensor fusion---are all\navailable. Abiding by this rule leads us to examine several different ways of\nstratifying results, as the full intersection is fairly sparse (see the\nsecond-to-last row in Figure~\\ref{fig:sensor_avail}). In particular, we\nconsider the following two dimensions used to define strata:\\footnote{To be\n  explicit, when we say we do not ``include'' certain sensors, it means both \n  that we ignore results from their individual sensor models (in computing the\n  common intersection of available nowcast dates and locations), and \\emph{also}\n  that we exclude them in running the sensor fusion methods.}  \n\\begin{itemize}\n\\item inclusion of Google-AA or not; \n\\item inclusion of all claims-based sensors (CHNG-CLI, CHNG-COVID, and DV-CLI)\n  or not. \n\\end{itemize}\nIn what follows, we first examine the performance of individual sensor models\nand a certain sensor fusion method (the simple average) compared to real-time\ndeconvolution, and then examine the relative performance of the different sensor\nfusion methods.  \n\n\\subsection{Performance of Sensors and Sensor Fusion}\n\nWe begin by comparing the MAE of nowcasts from natural trend filtering (NTF) \nusing tapered smoothing, as in \\eqref{eq:tf_realtime4} (the real-time\ndeconvolution estimator chosen based on the analysis in\nSection~\\ref{sec:deconv_realtime}) to those from individual sensor models and\nthe simple average sensor fusion method. Despite its simplicity, the simple\naverage appears to be the best-performing sensor fusion method overall (details\nin the next subsection), and so we stick with it as the de facto sensor fusion\nmethod in this subsection. The results here do not include Google-AA; results\nincluding Google-AA are shown in Appendix~\\ref{app:eval_plots}. \n\nFigure~\\ref{fig:mae_all_no_google_aa} displays the MAE from various methods as\na function of lag $k$. The top and bottom panels do not and do include the \nclaims-based sensors, respectively. In either case, we see that up until\nlag 6, all sensors outperform the real-time deconvolution estimate from NTF. The\nsimple average of all sensors improves accuracy even further, and achieves the\nbest MAE for all lags up through lag 6. We recall that NTF (with tapered\nsmoothing) itself already provides a huge increase in accuracy over the more\nnaive method for real-time deconvolution given by applying trend filtering\nwithout extra boundary regularization (Figure~\\ref{fig:extra_reg}). \nAt lag 7, the NTF estimate catches up to about equal accuracy, and then\nsurpasses sensor fusion and all sensors in accuracy at lag 8 and onward. An\ninterpretation for this: right truncation ceases to be a significant problem\npast lag 7, and thus we are better off performing deconvolution directly in\norder to estimate infections more than a week into the past.   \n\n\\begin{figure}[tb]\n\\centering \n\\includegraphics[width=0.85\\linewidth]{./figures/lineplot_no_claims_no_google_aa.pdf} \n\\includegraphics[width=0.85\\linewidth]{./figures/lineplot_claims_no_google_aa.pdf}\n\\caption{Comparing NTF to individual sensor models and the simple average sensor\n  fusion method by MAE for nowcasting. The top panel excludes the claims-based\n  sensors, whereas the bottom includes them. For lags smaller than 7, all\n  methods improve upon NTF (with tapered smoothing), with simple average being \n  the best among them.}    \n\\label{fig:mae_all_no_google_aa}\n\\end{figure}\n\nFigure~\\ref{fig:sensor_rank_no_google_aa} displays the empirical distributions\nof ranks of nowcast errors coming from each method, computed with respect to\neach other, over common nowcast tasks (defined by a location-date-lag\ntriplet). For example, in a particular nowcast task, we assign a rank of 1 to\nthe method with the smallest absolute error for that nowcast task. The top panel\nagain excludes claims-based signals, and the bottom panel includes them. The\nstriking feature in either panel, particularly the bottom panel, is that the\nsimple average has a highly distinctive distribution of ranks---it is rarely the\nbest method, but never the worst. While this is not particularly surprising\n(averaging random variables tends to be variance-reducing, as long as the\nvariables are not too correlated), it also points to a key property of sensor\nfusion---a certain kind of robustness, beyond accuracy.\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_claims_no_google_aa.pdf}\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_no_claims_no_google_aa.pdf}\n\\caption{Comparing NTF to individual sensor models and the simple average sensor\n  fusion method by relative ranks over common nowcast tasks. The top panel\n  excludes all claims-based sensors and considers lags 1--5, whereas the bottom\n  panel includes them and considers lags 4--9 (the first 5 lags at which all\n  methods are available, in either case). The simple average exhibits striking\n  consistency: it is rarely the best, but also never the worst.} \n\t\\label{fig:sensor_rank_no_google_aa}\n\\end{figure}\n\n\\subsection{Relative Performance of Sensor Fusion Methods}\n \nWe now compare the various sensor fusion methods to each other. The results here\ndo not include claims-based signals; results including claims-based signals are\nshown in Appendix~\\ref{app:eval_plots}. Figure~\\ref{fig:mae_sml} displays the\nMAE of the various sensor fusion estimates, but divided up into three panels,\ndefined by averaging over small, medium, and large states (the figure caption\nprovides more details). Recall that for the lasso, ridge, and KF-SF approaches,\na model in a particular county is fit using the sensors from other counties in\nthe same state. Larger states have more pooling of information across locations\nand present a greater potential for gains in accuracy. We see that the simple\naverage method is typically the best sensor fusion method at each lag, but for\nmedium and large states, KF-SF catches up with it and is just about as accurate.\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/boxenplot_no_claims.pdf}\n\\caption{Comparing sensor fusion methods by boxenplots of nowcasting\n  errors (each box conveys the level 25\\%, 50\\%, and 75\\% quantiles of the  \n  absolute error distribution.) The three panels average over small (containing\n  less than 5 locations), medium (between 5 and 14 locations), and large (more\n  than 15 locations) states. Simple average performs generally the best\n  throughout, but KF-SF catches up for medium and large states.}  \n\t\\label{fig:mae_sml}\n\\end{figure*}\n\nFigure~\\ref{fig:rank_ensemble} displays the relative ranking of sensor fusion\nmethods. The simple average and KF-SF methods appear the most favorable\n(often the best, and less so the worst), followed by lasso, then ridge, and \nlastly simple regression (most often the worst).   \n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_fusion_no_claims.pdf}\n\\caption{Comparing sensor fusion methods by relative ranks over common nowcast \n  tasks, and considering only lags 1--5. The simple average and KF-SF methods\n  consistently perform in the top half, while simple regression is most often\n  the worst.}\n\t\\label{fig:rank_ensemble}\n\\end{figure}\n\n\\section{Discussion}\n\\label{sec:discussion}\n\nIn this work, we proposed, implemented, and evaluated a framework for real-time\nestimation of new symptomatic COVID-19 infections from case reports. At time\n$t$, in order to nowcast the infection rate at time $t-k$ (for small values of\n$k$, such as $k=1,2,\\ldots$), the main steps are to:  \n\\begin{enumerate}\n\\item estimate a symptom-onset-to-case-report delay distribution using the most \n  recent data available in a line list provided by the CDC;  \n\\item perform regularized deconvolution on the most recent case data available \n  from JHU CSSE; \n\\item update models to track recent infection rates from various auxiliary\n  signals (based on COVID-related data from medical insurance claims, online\n  surveys, and Google searches), and fuse together the predictions from these\n  models in order to stabilize recent estimates of infection rates. \n\\end{enumerate}\nIn each step, we proposed methodological advances that improved the accuracy of\nour nowcasts, when measured against finalized infection rate estimates obtained\nby retrospective deconvolution (using data that would have only been available \nmonths later). While using auxiliary signals (step 3) did help in terms of\naccuracy and robustness, the additional regularization devices that we\nincorporated into real-time deconvolution (step 2) ended up providing the\nbiggest benefit to accuracy. \n\nTo reiterate, we purposely defined our target of estimation to be symptomatic\ninfections that would eventually show up in public health reports, allowing us\nto focus on developing and testing tools for real-time deconvolution and sensor\nfusion, with minimal assumptions (e.g., without a mechanistic model for disease\nspread). Estimating the number of true symptomatic infections at any point in\ntime---whether or not they will appear in case reports---is of course a much\nharder problem. However, our methodology may be seen as a contribution toward\nsolving this larger problem in real-time; moreover, some simple post hoc\ncorrections could be applied to our real-time estimates in order to adjust for\nconfounding. For example, if $a_{\\ell,t}$ is the fraction of untested\nsymptomatic infections in location $\\ell$ at at time $t$, which (say) is\nestimated from external data sources, then we could just multiply each element\n\\smash{$\\hp^{(t)}_{\\ell,s}$} of the delay distribution used in\n\\eqref{eq:tf_realtime4} by $b_{\\ell,t}=1/(1-a_{\\ell,t})$ in order to estimate\n\\emph{all} symptomatic infections from case reports. Due to the way we have set\nup the deconvolution problem (cross-validating over optimal choices of tuning\nparameters), this would be essentially equivalent to post-mulitplying the\nnowcast \\smash{$\\hx^{(t)}_{\\ell,s}$} we already produce by $b_{\\ell,t}$.\n\nWe finish by describing a few directions for future work.\n\n\\smallskip\n\\paragraph*{Post Hoc Smoothing.}\n\nAs we saw in Section~\\ref{sec:evaluation}, sensor fusion provides a real-time\nimprovement on pure deconvolution up until about a 10-day lag, and past that\npoint, the deconvolution estimates appear stable enough that sensor fusion\nbecomes unnecessary. While the quantative benefit of sensor fusion for small\nlags is clear, sensor fusion is also lacking in the following qualitative\naspect: its estimates do not always appear visually smooth across time (this is\nbecause the sensors themselves need not be smooth over time, and furthermore, \nsensor fusion may end up using a different subset of sensors at each lag,\ncreating additional jaggedness). Post smoothing techniques would be worth\ninvestigating here, to aid visual consumption.\n\n\\smallskip\n\\paragraph*{$R_t$ Estimation.} \n\nThe instantaneous reproductive number $R_t$, the average number of secondary\ninfections at time $t$ generated from a primary infection in the past, is a\nuseful and interpretable parameter that reflects the dynamics of epidemic growth\nin a population. In the SIR model, the instantaneous reproductive number $R_t$\nand growth rate $r_t$ at time $t$ obey the following relationship:\n\\[\nR_t \\approx 1 + \\frac{r_t}{\\gamma}, \n\\] \nwhere $\\gamma$ denotes the recovery rate in the SIR model. While this is\nwell-known in the literature on mathematical modeling of epidemics (and is exact\nunder local exponential growth; see, e.g., \\citet{Wallinga:2007}), its use in\nthe presence of confounding seems to be underexplored and potentially\nundervalued. If $I_t$ denotes the number of new infections at $t$, then using a\nsimple discrete difference approximation to $r_t$ leads to: \n\\[\nR_t \\approx 1 + \\frac{1}{\\gamma}\\bigg( \\frac{I_{t+1}}{I_t} - 1 \\bigg). \n\\]\nA similar though not identical approximation is given in\n\\citet{Bettencourt:2008}, where $I_{t+1}/I_t-1$ is replaced by\n$\\log(I_{t+1}/I_t)$. Critically, incident infections only enter right-hand side\nabove as a \\emph{ratio} of values adjacent in time, and thus if we are only able\nto estimate this up to an unknown multiplicative factor (due to confounding),\nthen this factor approximately cancels in the ratio as long as it is slowly\nvarying in time. In slightly more detail (and for simplicity, considering just a\nsingle location), suppose as before that a fraction $a_t$ of infections go\nuntested at time $t$. Then $I_t = b_t x_t$ where $x_t$ is the number of new\ninfections at time $t$ that show up in case reports (i.e., the focus of this\npaper) and $b_t = 1/(1-a_t)$. From the previous display,   \n\\[\nR_t \\approx 1 + \\frac{1}{\\gamma}\\bigg( \\frac{b_{t+1} x_{t+1}}{b_t x_t} - 1\n\\bigg) \\approx 1 + \\frac{1}{\\gamma}\\bigg( \\frac{x_{t+1}}{x_t} - 1 \\bigg),\n\\]\nwhere the last approximation is motivated by an additional assumption the \nuntested fraction varies slowly over time (so $b_{t+1}/b_t \\approx\n1$). This shows that estimates of $x_t$ can produce \\emph{approximately\n  unconfounded} estimates of $R_t$, even though $x_t$ is itself confounded\ndue to a lack of universal testing. This is true both in the retrospective and \nreal-time sense, and will be the topic of future study.     \n\n% In other words, estimating $R_t$ may be more tractable than estimating $N_t$, \n% since an assumption of slow-varying bias $b_t$ means that the confounding \n% ``cancels out'' in the change ratio.  \n\n\\smallskip\n\\paragraph*{Evaluation via Reconvolution.}\n\nAn important avenue for evaluating our methodology (beyond evaluating against\nfinalized infection rate estimates, as we do in this paper), would be to\nreconvolve our real-time nowcasts of infection rates forward in time in order to\npredict future case rates, and evaluate these predictions against finalized case\nreporting data. Making and evaluating point predictions would be relatively\nstraightforward, however, distributional forecasts are currently the standard in\nepidemiological forecasting (and also in COVID-19 forecasting), and adding a\ndistributional layer to our nowcasts (and propagating this through the\nconvolution operator) requires substantial new developments, and we leave it to\nfuture work.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Support information, if any,             %%\n%% should be provided in the                %%\n%% Acknowledgements section.               %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{acks}[Acknowledgments]\nThe authors are grateful to Logan Brooks, Roni Rosenfeld, James Sharpnack, Sam \nAbbott, Joel Hellewell, and Sebastian Funk for several early insightful\nconversations.   \n \nMJ was supported by a fellowship from the Center for Machine Learning and \nHealth at Carnegie Mellon. AC and RJT were supported by a gift from Google.org.   \n\\end{acks}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Funding information, if any,             %%\n%% should be provided in the                %%\n%% funding section.                        %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \\begin{funding}\n%  The first author was supported by ...\n\n%  The second author was supported in part by ...\n% \\end{funding}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Supplementary Material, including data   %%\n%% sets and code, should be provided in     %%\n%% {supplement} environment with title      %%\n%% and short description. It cannot be      %%\n%% available exclusively as external link. %%\n%% All Supplementary Material must be       %%\n%% available to the reader on Project       %%\n%% Euclid with the published article.      %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\begin{supplement}\n%\\stitle{???}\n%\\sdescription{???.}\n%\\end{supplement}\n\n\\begin{appendix}\n\t\n\\section{ADMM for Solving Deconvolution Problems}  \n\\label{app:tf_admm}\n\nHere we give details on the ADMM approach used to solve the regularized least\nsquares deconvolution problems in Sections~\\ref{sec:deconv_retro} and\n\\ref{sec:deconv_realtime}. We first focus on problem \\eqref{eq:tf_retro}, and\nthen we discuss the modifications needed when incorporating extra regularization\nfor real-time deconvolution as in \\eqref{eq:tf_realtime4}. To simplify notation,\nwe will henceforth drop the subscript dependnece of all quantities on the\nlocation $\\ell$, as well as the superscript dependence on the nowcast date $t$\nfor the real-time problems.\n\nWe also use \\smash{$\\hP$} to denote the (Toeplitz) convolution matrix with rows\ndetermined by \\smash{$\\hp_s$}, $s<t$, i.e., such that for any vector $x$ (of\nappropriate dimension) \n$$\n(\\hP x)_s = \\sum_{k=1}^d \\hp_k x_{s-k}.\n$$\n(We leave the dimensions of \\smash{$\\hP$} and $x$ here purposely ambiguous,\nwhich should always be clear from the context anyway; this allows us to borrow\nsimilar notation across problems with different underlying dimensions.) Thus we\ncan rewrite \\eqref{eq:tf_retro} as \n$$\n\\minimize_x \\; \\| y - \\hP x \\|_2^2 + \\lambda \\|D^{(4)} x\\|_1. \n$$\nTo apply ADMM, we must introduce auxiliary variables, and as in\n\\citet{ramdas2016fast}, we use the following ``specialized'' decomposition \n(which improves the convergence speed):\n\\begin{alignat*}{2}\n&\\minimize_x \\; && \\| y - \\hP x \\|_2^2 + \\lambda \\|D^{(1)} \\alpha\\|_1 \\\\ \n&\\subjectto && \\;\\; \\alpha = D^{(3)} x,\n\\end{alignat*}\nwhere we used the recursive nature of the difference operators, writing the\n4$\\th$-order operator as a product of the 1$\\st$- and 3$\\rd$-order operators: \n\\smash{$D^{(4)} = D^{(1)} D^{(3)}$}. The above problem gives rise to the\naugmented Lagrangian: \n\\begin{multline*}\n\\cL(x, \\alpha, u) = \\| y - \\hP x \\|_2^2 + \\lambda \\|D^{(1)} \\alpha\\|_1 +{} \\\\ \n\\rho \\|\\alpha -  D^{(3)} x + u\\|_2^2 -  \\rho \\|u\\|_2^2, \n\\end{multline*}\nwhich corresponds to following ADMM updates, writing \\smash{$D=D^{(3)}$} for \nbrevity:  \n\\begin{align*}\nx &\\leftarrow (\\hP^T \\hP + \\rho D^T D)^{-1} \\big( \\hP^T y + \\rho D^T\n    (\\alpha + u)\\big) \\\\   \n\\alpha &\\leftarrow \\argmin_z \\; \\| D x  - u - z \\|_2^2 +\n\\frac{\\lambda}{\\rho} \\|D^{(1)} \\alpha\\|_1 \\\\\nu & \\leftarrow u + \\alpha - D x.\n\\end{align*}\nThe $\\alpha$-update here requires solving a 1-dimensional fused lasso problem, \nwhich can be done in linear-time with the dynamic programming approach of \n\\citet{johnson2013dynamic}. The $x$-update is more expensive than in pure\ntrend filtering (with no convolution operator) but owing to the bandedness of\n\\smash{$\\hP$} (and $D$, though the bandwidth $d$ of \\smash{$\\hP$} dominates), it\ncan still be solved in $O(nd)$ operations. Further, in this and all applications  \nof ADMM, we follow the recommendation of \\citet{ramdas2016fast} and set the\nLagrangian parameter equal to the tuning parameter, $\\rho = \\lambda$. \n\nAs for the two extensions presented in \\eqref{eq:tf_realtime4}, the natural  \ntrend filtering constraints can be be enforced by introducing a linear\ninterpolant matrix as described in Section~11.2 of \\citet{tibshirani2020divided}.\nThis effectively replaces the convolution matrix \\smash{$\\hP$} and the 3$\\rd$\ndifference operator $D$, in the ADMM steps above, by \\smash{$\\tP$} and\n\\smash{$\\tD$}, respectively, which are given by right multiplying $P$ and $D$ by\nthe interpolant matrix.  \n\nMoreover, the additional tapered smoothing term can be pushed into the augmented\nLagrangian, and only alters the $x$-update, now becoming:       \n\\begin{multline*}\nx \\leftarrow (\\tP^T \\tP + \\gamma M^T M + \\rho \\tD)^{-1} \\cdot{} \\\\\n \\big(\\tP^T y + \\rho \\tD^T(\\alpha + u)\\big),\n\\end{multline*}\nwhere $M$ is the matrix $W^{(t)} D^{(1)}$ in the tapered penalty in\n\\eqref{eq:tf_realtime4} times the linear interpolant matrix.\n\n\\section{Additional Evaluation Results}\n\\label{app:eval_plots}\n\nFigures~\\ref{fig:mae_all} and \\ref{fig:sensor_rank} are analogous to\nFigures~\\ref{fig:mae_all_no_google_aa} and \\ref{fig:sensor_rank_no_google_aa},\nbut with the inclusion of the Google-AA sensor. Similarly,\nFigures~\\ref{fig:mae_sml_claims} and \\ref{fig:rank_ensemble_claims} are the\ncounterparts to Figures~\\ref{fig:mae_sml} and \\ref{fig:rank_ensemble}, but with\nthe inclusion of claims-based sensors.\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.85\\linewidth]{./figures/lineplot_claims.pdf}\n\\includegraphics[width=0.85\\linewidth]{./figures/lineplot_no_claims.pdf}\n\\caption{As in Figure~\\ref{fig:mae_all_no_google_aa}, but including Google-AA.}    \n\\label{fig:mae_all}\n\\end{figure}\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_claims.pdf}\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_no_claims.pdf}\n\\caption{As in Figure~\\ref{fig:sensor_rank_no_google_aa}, but including Google-AA.}\n\\label{fig:sensor_rank}\n\\end{figure}\n\n\\begin{figure*}[tb]\n\\centering\n\\includegraphics[width=0.95\\linewidth]{./figures/boxenplot_claims.pdf}\n\\caption{As in Figure~\\ref{fig:mae_sml}, but including claims-based signals.}\n\\label{fig:mae_sml_claims}\n\\end{figure*}\n\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=0.975\\linewidth]{./figures/rankplot_fusion_claims.pdf}\n\\caption{As in Figure~\\ref{fig:rank_ensemble}, but including claims-based\n  signals.} \n\\label{fig:rank_ensemble_claims}\n\\end{figure}\n\n% \\section{Log-Change-Ratio Approximation for $R_t$} \n% \\label{app:log_change_ratio}\n\n% We consider the standard susceptible-infected-recovered (SIR) model\n% \\citep{Kermack:1927} with transmission rate $\\beta$ and recovery rate\n% $\\gamma$. Let $S(t),I(t),R(t)$ denote the fraction of susceptible, infected,\n% recovered individuals, respectively, at time $t$, in some underlying\n% population. Then the SIR model evolves according to the continuous-time dynamics\n% (subject to some initial conditions):\n% \\begin{align*}\n% S'(t) &= -\\beta S(t) I(t) \\\\\n% I'(t) &= \\beta S(t) I(t) - \\gamma I(t) \\\\\n% R'(t) &= \\gamma I(t).\n% \\end{align*} \n\n% The instantaneous reproductive number in this model is defined as $R_t = \n% S(t) \\beta / \\gamma$. We can interpret the $R_t$ as being determined by \n% the slope of a natural first-order approximation to the curve $\\log I(t)$ at\n% time $t$. That is, looking back at the differential equation for $I(t)$, if we\n% forget about the fact that $S(t)$ actually depends on $t$, this ``looks like'' \n% $I'(t)$ is a ``constant'' times $I(t)$ (that ``constant'' being $\\beta S(t) -\n% \\gamma$), which suggests that for $t$ near a point $t_0$,   \n% \\begin{align}\n% \\nonumber\n% I(t) &\\approx I(t_0) \\exp\\big( (\\beta S(t) - \\gamma) (t-t_0) \\big) \\\\ \n% \\label{eq:inf_approx}\n% &= I(t_0) \\exp\\big(\\gamma (R_t - 1) (t-t_0)\\big).\n% \\end{align}\n\n% Now let $T(t)$ denote the total fraction of individuals who have ever been\n% infected at time $t$ (note, $T(t) = 1-S(t)$). Then this evolves according to the \n% dynamics: \n% $$\n% T'(t) = \\beta S(t) I(t).\n% $$\n% Consider the change in total infecteds from time $t$ to $t+1$, also called the\n% \\emph{incidence proportion} over this period, denoted $\\Delta T(t+1) = T(t+1) - \n% T(t)$. Using this as a discrete approximation to the derivative (backward\n% difference) of the total infecteds curve, \n% \\begin{align*}\n% \\Delta T(t+1) &\\approx \\beta S(t+1) I(t+1) \\\\\n% &\\approx \\beta S(t) I(t) \\exp\\big(\\gamma (R_t - 1)\\big),\n% \\end{align*}\n% where in the second line we used the local-linear approximation to log-infecteds\n% curve from \\eqref{eq:inf_approx}, as well as a local-constant approximation to\n% the susceptible curve (which underlies this local-linear approximation in the\n% first place). By the same logic,  \n% $$\n% \\Delta T(t) \\approx \\beta S(t) I(t),\n% $$\n% and thus \n% $$\n% \\frac{\\Delta T(t+1)}{\\Delta T(t)} \\approx \\exp\\big(\\gamma (R_t - 1)\\big). \n% $$\n% In other words, from the ratio $\\Delta T(t+1) / \\Delta T(t)$, we can estimate\n% $R_t$, provided that we already know (or can estimate) $\\gamma$. This\n% establishes the claim in \\eqref{eq:log_change_ratio} by taking logs of each\n% side, and noting that if $N_t$ is the number of new infections at each $t$, then\n% $N_{t+1} / N_t = \\Delta T(t+1) / \\Delta T(t)$ (because the total number of\n% individuals in the population cancels in the ratio).\n\\end{appendix}\n\n\\bibliographystyle{imsart-nameyear}\n\\bibliography{ryantibs, nowcast}      \n\\end{document}\n\n\n", "meta": {"hexsha": "617e556d84e29dd52e6615c00d7605576b991676", "size": 98613, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/paper.tex", "max_stars_repo_name": "cmu-delphi/stat-sci-nowcast", "max_stars_repo_head_hexsha": "38088e1510a009fff636aed68bccb46b5bc46731", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/paper.tex", "max_issues_repo_name": "cmu-delphi/stat-sci-nowcast", "max_issues_repo_head_hexsha": "38088e1510a009fff636aed68bccb46b5bc46731", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/paper.tex", "max_forks_repo_name": "cmu-delphi/stat-sci-nowcast", "max_forks_repo_head_hexsha": "38088e1510a009fff636aed68bccb46b5bc46731", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.0948186528, "max_line_length": 90, "alphanum_fraction": 0.7491608611, "num_tokens": 26511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.4257054156575992}}
{"text": "\\section{Proofs: Comparison of  Rule Transformation Strategies}\\label{sec:comparison_proofs}\n\nWe restate and give detailed proofs of two lemmas of \\secref{sec:rule_inversion}.\n\n\n\\begin{lemma}\\label{lemma:mp_to_md_with_proof}\n  Any model ${\\cal M}_P$ of ${\\cal F}_P$ can be transformed into a model\n  ${\\cal M}_D$ of ${\\cal F}_D$.\n\\end{lemma}\n\n\\begin{proof}\n  We consider the transformation of a model ${\\cal M}_P$ to a model\n  ${\\cal M}_D$, and assume ${\\cal M}_P$ is a model of ${\\cal F}_P$. \n  We now construct an interpretation ${\\cal M}_D$ for the formulas with the\n  signature over ${\\cal F}_D$.\n\n  The interpretation ${\\cal M}_D$ will be the same as ${\\cal M}_P$,\n  except for (1) the interpretation of the new types \\texttt{Rulename$_C$},\n  each of which will be chosen to be the set of all rule names having $C$ as\n  conclusion, and (2) the interpretation of the new predicates $C^+$ on which\n  we will focus now: \n  For each rule  $\\forall x_1, \\dots, x_n.\\; Pre(x_1,\n  \\dots, x_n) \\IMPL C(x_1, \\dots, x_n)$ with name  $rn$, whenever the $n$-tuple\n  $(a_1, \\dots, a_n)$ satsifies the precondition $Pre$ under ${\\cal M}_P$ and, consequently,\n  $(a_1, \\dots, a_n) \\in C^{{\\cal M}_P}$, we will have   $(rn, a_1, \\dots, a_n) \\in (C^+)^{{\\cal M}_D}$.\n\n  It remains to be shown that ${\\cal M}_D$ is indeed a model of ${\\cal\n    M}_D$. We show that related formulas in ${\\cal F}_P$ and ${\\cal F}_D$\n  are interpreted as true in ${\\cal M}_P$ resp.{} ${\\cal M}_D$, where two\n  formulas are \\emph{related} if they are rules originating from the same rule\n  of ${\\cal R}_M$, or if they are related inversion predicates $Inv_C$ and $Inv_{C^+}$.\n\n  We first address related rules. The proof is by well-founded induction over\n  the rule order $\\prec_R$. Consider a rule $r_P \\in {\\cal F}_P$ with rule\n  name $rn_P$ which by construction has the form\n  $r_p = \\forall x_1, \\dots x_n.\\; pre_P^o \\AND \\NOT pre_P^1 \\AND \\NOT pre_P^k\n  \\IMPL C(x_1, \\dots, x_n)$.\n  We make a case distinction:\n  \\begin{itemize}\n  \\item Assume that for arguments $(a_1, \\dots, a_n)$, interpretation\n    ${\\cal M}_P$ satisfies the precondition\n    $pre_P^o \\AND \\NOT pre_P^1 \\AND \\NOT pre_P^k$ and thus also the\n    conclusion. In this case, $(rn_P, a_1, \\dots, a_n)\\in (C^+)^{{\\cal M}_D}$, thus\n    satisfying the related rule $r_D \\in {\\cal F}_D$.\n  \\item Assume that for arguments $(a_1, \\dots, a_n)$, interpretation\n    ${\\cal M}_P$ does not satisfy the precondition. Either $pre_P^o$ is not\n    satisfied, leading again to a satisfying assignment of the related rule\n    $r_D$, or one of the $pre_P^i$ is satisfied.\n\n    In this case, as the rule $r_P^i$ with precondition $pre_P^i$ is strictly\n    smaller than $r_P$ \\wrt{} $\\prec_R$, by induction hypothesis, also the\n    postcondition of $r_P^i$ will be satisfied, so that in ${\\cal M}_D$, one\n    negated precondition of the related rule $r_D$ is not satisfied, so $r_D$\n    is satisfied.\n  \\end{itemize}\n\n  Once the equi-satisfiability of related rules has been established, it is\n  easy to do so for related inversion predicates $Inv_C$ and $Inv_{C^+}$.\n\\end{proof}\n\n\n\\begin{lemma}\\label{lemma:md_to_mp_with_proof}\n  Any model ${\\cal M}_D$ of ${\\cal F}_D$ can be transformed into a model\n  ${\\cal M}_P$ of ${\\cal F}_P$.\n\\end{lemma}\n\n\\begin{proof} (Sketch)\n  In analogy to \\lemmaref{lemma:mp_to_md}, we start from a model ${\\cal M}_D$\n  of ${\\cal F}_D$ and construct a model ${\\cal M}_P$ of ${\\cal F}_P$. \n\n  As in \\lemmaref{lemma:mp_to_md}, the proof is by induction on $\\prec_R$.\n  Consider a rule $r_D \\in {\\cal F}_D$ with rule\n  name $rn_D$ which by construction has the form\n  $r_D = \\forall x_1, \\dots x_n.\\; pre_D^o \\AND \\NOT post_D^1(rn_1) \\AND \\NOT post_D^k(rn_k)\n  \\IMPL C^+(rn_D, x_1, \\dots, x_n)$. Again, we make a case distinction:\n  \\begin{itemize}\n  \\item Assume that for arguments $(a_1, \\dots, a_n)$, interpretation\n    ${\\cal M}_D$ satisfies the precondition and thus also the conclusion. In\n    this case, $(a_1, \\dots, a_n)\\in C^{{\\cal M}_P}$, thus satisfying the\n    related rule $r_P \\in {\\cal F}_P$.\n  \\item Assume that for arguments $(a_1, \\dots, a_n)$, interpretation\n    ${\\cal M}_D$ does not satisfy the precondition. The interesting situation\n    is if one $post_D^i(rn_i)$ is satisfied. At this point, we need the\n    inversion formula of $post_D^i$, of the form\n    $\\forall r.\\; post_D^i(r) \\IMPL P_1(r) \\OR \\dots \\OR P_p(r)$. The rule\n    name $rn_i$ permits to select precisely the precondition $P_j$ of the\n    related formula\n    $r_P = \\forall x_1, \\dots x_n.\\; pre_P^o \\AND \\NOT pre_P^1 \\AND \\NOT\n    pre_P^k \\IMPL C(x_1, \\dots, x_n)$.\n  \\end{itemize}\n\\end{proof}", "meta": {"hexsha": "a970f8058474e72c5f7247482f1b620a5172ca07", "size": 4631, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Publications/Papers/CLAR2021/comparison_proofs.tex", "max_stars_repo_name": "smucclaw/complaw", "max_stars_repo_head_hexsha": "3b42b0a2b815aa452981029a8f33150ea7c8b2f4", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2020-05-29T22:29:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-22T08:31:20.000Z", "max_issues_repo_path": "Publications/Papers/CLAR2021/comparison_proofs.tex", "max_issues_repo_name": "smucclaw/complaw", "max_issues_repo_head_hexsha": "3b42b0a2b815aa452981029a8f33150ea7c8b2f4", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-03T17:32:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-30T04:48:53.000Z", "max_forks_repo_path": "Publications/Papers/CLAR2021/comparison_proofs.tex", "max_forks_repo_name": "smucclaw/complaw", "max_forks_repo_head_hexsha": "3b42b0a2b815aa452981029a8f33150ea7c8b2f4", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2020-06-15T02:52:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-26T05:22:58.000Z", "avg_line_length": 50.8901098901, "max_line_length": 104, "alphanum_fraction": 0.6741524509, "num_tokens": 1566, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.42570540827163517}}
{"text": "\\documentclass[Thesis.tex]{subfiles}\n\\begin{document}\n\\chapter{The Quantum Problem}\n\\label{chp:the-quantum-problem}\n\n\\glsresetall\n\n\\section{Problem Statement}\n\nSay you want to investigate the properties of some quantum mechanical system.\nThe first step is then to firmly establish how we should describe this system\nand the laws that govern its behaviour.\\footnote{For the entirety of this\nthesis, we shall assume that the systems we consider do not show any significant\nrelativistic behaviour, so that no such considerations are necessary.}\n\nIf our system of interest consisted of non-quantum entities (e.g.\\ the\ntrajectory of a baseball as it is thrown through the air towards a batter), we\nwould likely turn to our classical laws, such as Newton's second law of motion\n%\n\\begin{align}\n    \\sum_i \\vec F_i(t) = \\dv{\\vec p(t)}{t},\n\\end{align}\n%\n\\noindent where $\\vec F_i$ are the forces acting on the ball, and $\\vec p$ is its momentum at\nany given point in time, $t$. Using the law of motion we can use our knowledge about how the\nenvironment affects the object to \\emph{deterministically} calculate the resulting\nbehaviour. The really nice thing is that, if we also know the mass of the object, we\ncan derive the value of any other measurable physical quantity of interest. As such,\nwe can say that \\emph{solving} a classical system consists of the following steps:\n\n\\begin{enumerate}\n    \\item Define the environment, i.e.\\ the forces acting on the object(s)\n    \\item Use the second law of motion to obtain momentum $\\vec p(t)$ and position $\\vx(t)$\n    \\item Compute quantity of interest, $Q(\\vec p, \\vec x; t)$\n\\end{enumerate}\n\nMoving to the quantum world, much of the same procedure remains the same. For the quantum\ncase, we have a different law of motion. In our non-relativistic view, this is the\n\\gls{tdse}:\n\n\\begin{align}\n    \\hat H\\ket{\\Psi} &= i\\hbar \\pdv{}{t}\\ket{\\Psi},\\label{eq:schrodinger-time-dependent-general}\n\\end{align}\n%\nwhere $i=\\sqrt{-1}$ is the imaginary unit and $\\hbar=\\flatfrac{h}{2\\pi}$ is the reduced Planck constant.\nThe thing we want to solve for in this case is the so called wave function $\\ket{\\Psi}$\n(explained momentarily), while the description of the system (analogous to the forces in\nclassical mechanics) goes into $\\hat H$. We refer to the latter as the Hamiltonian\noperator, and it should be a complete description of the kinetic and potential\nenergies of the particles involved. As an example, we write the equation for a\nsingle particle at position $\\vx$ in an energy potential $V(\\vx; t)$ as follows\n(where we explicitly use the position basis):\n\n\\begin{align}\n    \\qty[-\\frac{\\hbar^2}{2m} \\laplacian + V(\\vb x; t)]\\Psi(\\vb x;t) =\n    i\\hbar\\pdv{\\Psi(\\vb x; t)}{t},\\label{eq:schrodinger-time-dependent-position-basis}\n\\end{align}\n%\nwhere the first term constitutes the kinetic energy of the particle (with mass $m$), and the second term is\nnaturally the potential energy. For the systems that we shall consider in this thesis, the\nHamiltonians will all take this form, only varying the functional form of $V$.\n\nKnowing the wave function $\\Psi$ of a system is analogous to knowing position\nand momentum in the classical view in that we can compute any observable\nquantity from it (more on this in \\cref{sec:obs-from-psi-to-Q}). As such, obtaining the full\nexpression for the correct wave function is of immense use.\n\nThe wave function lacks a clear physical intuition for what exactly it \\emph{is},\nlike we have for position and momentum in classical mechanics. Perhaps the most helpful way to view $\\Psi$ is\nthrough the fact that its squared absolute value, $\\abs{\\Psi(\\vb x; t)}^2$, is the\nprobability of finding a particle at position $\\vb x$ at time $t$. Thinking of the (squared\nnorm of the) wave function as a substitute for the classical position $\\vb x$ can\ntherefore be a helpful aid, as long as we keep the probabilistic nature of it in mind.\n\nSummarizing the steps for \\emph{solving} a quantum system, analogous to the\nclassical approach, we have the following plan:\n\\begin{enumerate}\n    \\item Define the environment through choosing a form for the Hamiltonian $\\hat H$\n    \\item Use the \\gls{tdse} to obtain the wave function $\\ket\\Psi$\n    \\item Use the wave function to compute quantities $Q$ of interest\n\\end{enumerate}\n\n\\section{Stationary States}\n\nThe \\gls{tdse} (\\cref{eq:schrodinger-time-dependent-position-basis}) is a partial differential equation,\nsince it contains partial derivatives of the wave function with respect to both position and\ntime. The standard approach to solving this equation is through \\emph{separation of\nvariables}. We assume that we can factorize the full wave function as follows:\n\n\\begin{align}\n    \\Psi(\\vb x; t) &= \\psi(\\vb x)\\phi(t).\\label{eq:separatable-wave-func-def}\n\\end{align}\n%\nIn addition, we assume that $V(\\vb x; t) = V(\\vb x)$, i.e.\\ that the potential is\ntime-independent.\\footnote{There are systems for which this assumption does not hold. We\nwill, however, restrict ourself to consider only Hamiltonians for which this description\nis valid} With these assumptions, we can divide through with $\\Psi$ in\n\\cref{eq:schrodinger-time-dependent-position-basis} and obtain the\nfollowing:\\footnote{It could be tempting to simply strike $\\Psi$ from the lhs.\\ of\n\\cref{eq:schrodinger-time-dependent-position-basis} when dividing by $\\Psi$. Nevertheless, we\nmust remember that the Hamiltonian is an operator (specifically seen through the\n$\\laplacian$ in this case), and so we must divide only after letting this operate on\n$\\Psi$.}\n\n\\begin{align}\n    \\qty[- \\frac{\\hbar^2}{2m} \\laplacian \\psi + V(\\vb x)\\psi]\\psi^{-1} &=\n    i\\hbar\\dv{\\phi}{t} \\phi^{-1}.\n\\end{align}\n%\nWe now make the following subtle observation: Since the lhs., a function of $\\vb x$, is\nequal to the rhs, a function of $t$, they must both be equal to a constant. If\nthis was not true, we could vary one of $\\vx$ or $t$ and alter only one side of\nthe equation, leaving it invalid.\nAs both sides have units of energy, let's denote this constant energy as $E$, and proceed\nto solve each equation by itself.\n\nThe time dependent equation becomes:\n\n\\begin{align}\n    i\\hbar \\dv{\\phi}{t} &= E\\phi(t),\n\\end{align}\nwhich is trivial to solve:\n\\begin{align}\n    \\phi(t) &= Ae^{-iEt/\\hbar},\n\\end{align}\nfor some constant $A=\\phi(0)$ determined by boundary conditions.\n\nThe time-independent equation, known as the \\gls{tise}, is:\n\\begin{align}\n    - \\frac{\\hbar^2}{2m} \\laplacian\\psi + V(\\vb x)\\psi =\n    E\\psi.\\label{eq:schrodinger-time-independent-position-basis}\n\\end{align}\nThe solutions to this equation are the \\emph{stationary states} of the system. If\nwe are able to find these solutions, then we automatically have also the full time\ndependent solution through \\cref{eq:separatable-wave-func-def}.\n\nIf we return \\cref{eq:schrodinger-time-independent-position-basis} to the more general\nform,\n\\begin{align}\n    \\hat H \\ket{\\psi} &= E\\ket{\\psi},\n\\end{align}\nwe can recognize the problem as an eigenvalue problem where we seek the eigenvalues ($E$)\nand eigenvectors ($\\ket{\\psi}$) of the operator $\\hat H$. In light of this, we prefer to\nexplicitly label the equation to account for the possibility that the equation could have\nmultiple (potentially infinite) solutions, and write this as\n\\begin{align}\n    \\hat H\\ket{\\psi_n} &= E_n\\ket{\\psi_n}.\n\\end{align}\nEach of the $\\ket{\\psi_n}$ represents one possible stationary state, and could for instance be\ndifferent levels of energy excitations within an atom. For our purposes, we will only care\nabout the so called \\emph{ground state}, i.e.\\ the state $\\ket{\\psi_n}$ corresponding to the\nlowest possible $E_n$. By convention, we assume that the energies are ordered such that $E_i\n\\leq E_j$ if $i < j$, and denote the ground state as $\\ket{\\psi_0}$ and the corresponding ground\nstate energy as $E_0$.\n\n\n\\section{Many-Body Systems}\n\nUp until now, for simplicity, we've only considered the description of single-particle\nsystems. Changing the number of particles is a change in the system description, and as\nsuch it entails modifying the Hamiltonian operator accordingly. Everything presented thus\nfar generalizes well to the case of more than one particle, simply by introducing the\nappropriate sums. The general form of the many-body Hamiltonian we will consider is now:\n\n\\begin{align}\n    \\hat H &= - \\sum_{i=1}^N \\frac{\\hbar^2}{2m_i} \\laplacian_i + V(\\vb x_1, \\vb x_2,\\dots,\n    \\vb x_N)\\\\\n    &= -\\sum_{i=1}^N \\frac{\\hbar^2}{2m_i} \\laplacian_i + V(\\vb\n    X),\\label{eq:Hamiltonian-operator-general}\n\\end{align}\nwere $\\mat X \\defeq (\\vb x_1\\ \\vb x_2\\ \\dots\\ \\vb x_N)^T\\in \\mathbb{R}^{N\\times D}$ is the matrix\nof $D$-dimensional row vectors of coordinates for each particle. For further clarity,\n$\\vb x_i \\defeq \\sum_{d=1}^D x_{i,d} \\vb e_d$ is a $D$-dimensional vector described by\nits coordinates $x_{i,d}$ (with unit vectors $\\vb{e}_d$), and the corresponding Laplacian\noperator is\n\\begin{align}\n    \\laplacian_k \\defeq \\sum_{d = 1}^D \\pdv[2]{}{x_{k,d}}.\n\\end{align}\n\n\n\\section{Requirements of Wave Functions}\\label{sec:requirements-of-wave-functions}\n\nWe have stated earlier that by solving the Schrödinger equation and obtaining the wave\nfunction, we can compute any desirable quantity of interest. In order for the wave\nfunction to fulfill this rather impressive encoding of everything about the system, it has\nto satisfy certain criteria. We now devote some special consideration to make these\nrequirements explicit.\n\nIn order to represent a physically observable system, a wave function $\\Psi$ must:\n\\begin{enumerate}\n    \\item Be a solution to the Schrödinger equation\n    \\item Be normalizable (in order to represent a probability)\n    \\item Be a continuous function of space\n    \\item Have a continuous first order spacial derivative\n    \\item Obey suitable symmetry requirements\n\\end{enumerate}\n%\nWhile the first requirement is obvious, points 2-4 boil down to $\\Psi$ taking a\nfunctional form that is well behaved, satisfying required boundary conditions and being\npossible to view as a \\gls{pdf}. The last point is perhaps less clear, and\nwe devote some further attention to this point in particular.\n\n\n\\subsection{Symmetry of Wave Functions}\n\nNature has many examples of systems made up of particles of the same\nspecies. That is, the particles all have the same mass, spin, electromagnetic\ncharge etc.\\ such that there is no way to  distinguish one from the other by\nmeasuring their properties. An example could be the electrons of an atom, all of\nwhich have the exact same physical properties.\n\nIn classical mechanics, we can still distinguish identical particles by other\nmeans. Imagine for instance a set of perfectly identical planets in orbit. Even\nthough they have all of the same physical properties, we can still enumerate\nthem and keep track of which is which. This is due to the fact that their\nposition in time and space is deterministically defined by their current state,\nwhich allows us to track them.\n\nIn quantum mechanics, however, we no longer have this deterministic view. In\nthis world, even if we know where all the individual electrons are at a specific\npoint in time, we cannot say with certainty where they will be at a later\ntime. We blame this on the uncertainty principle, and the result is that systems of\nidentical particles become systems of \\emph{indistinguishable} particles in\nquantum mechanics.\n\nConsider now a system of two indistinguishable particles, labeled $\\vec x_1$ and\n$\\vec x_2$, where $\\vec x_i$ contains all the quantum numbers required to describe\nparticle $i$ (e.g.\\ position coordinates and the $z$ component of spin). The\nsystem is then described by a wave function\n\n\\begin{align}\n    \\Psi(\\vec x_1, \\vec x_2).\n\\end{align}\nBecause the particles are indistinguishable, this labeling of 1 and 2 is\narbitrary, and so we should be able to relabel them:\n\n\\begin{align}\n    \\Psi(\\vec x_2, \\vec x_1).\n\\end{align}\n\nThese two expressions, which represent exchanging the two particles, \\emph{must}\ndescribe the same physical system. That is, the probabilities of both states\nmust be equal:\n\n\\begin{align}\n    \\abs{\\Psi(\\vec x_1, \\vec x_2)}^2 &= \\abs{\\Psi(\\vec x_2, \\vec x_1)}^2\\\\\n    \\iff \\Psi(\\vec x_1,\\vec x_2) &= e^{i\\alpha}\\Psi(\\vec x_2, \\vec x_1),\n\\end{align}\ni.e.\\ they can only differ in their complex phase, which doesn't affect any measurable\nquantity. Repeating the exchange once more yields the original wave function,\n\n\\begin{align}\n    \\Psi(\\vec x_1,\\vec x_2) &= e^{2i\\alpha}\\Psi(\\vec x_1, \\vec x_2)\\\\\n    \\iff e^{i\\alpha} &= \\pm 1.\n\\end{align}\nThis result states that any wave function, upon the exchange of\nindistinguishable particles, must be either symmetric (same sign) or\nanti-symmetric (opposite sign) to that of the original. This is generalizable to\nany number of particles, and is known as the \\emph{Pauli exclusion principle}.\nThe following theorem summarizes the result~\\cite{PhysRev-58-716}:\n\n\\begin{theorem}[Spin-Statistic\n    Theorem]\\label{theorem:spin-statistic}\n\n    The wave function of a system of identical integer spin particles has the same value\n    when the positions of any two particles are swapped. Particles with wave functions\n    symmetric under exchange are called bosons.\n\n    The wave function of a system of identical half-integer spin particles changes sign\n    when two particles are swapped. Particles with wave functions antisymmetric under\n    exchange are called fermions.\n\\end{theorem}\n\n\\section{Observables - From Wave Function to Measurement}\n\\label{sec:obs-from-psi-to-Q}\n\nWe have repeatedly claimed that armed with the correct wave function we can compute any\nmeasurable quantity of interest. Finally, we consider how exactly we can go\nabout doing so.\n\nAssume we want to compute an observable $O$. The first step is to determine the\ncorresponding \\emph{operator} $\\hat O$. This is in general done by taking the classical\ndescription of the observable and performing a canonical transformation.\\footnote{There are\nalso quantities that do not have a classical analog (e.g.\\ spin) for which we can still\nfind operator forms.} Most notably, we have for the following transformations for\nposition and momentum:\n\n\\begin{align}\n    \\vb x &\\rightarrow \\hat\\vx,\\\\\n    \\vb p &\\rightarrow -i\\hbar\\grad.\n\\end{align}\nFor example, as is often the case, let's say we want to compute the total energy of the\nsystem. For $N$ particles that would classically be:\n\\begin{align}\n    H = \\sum_{i=1}^N \\frac{p_i^2}{2m_i} + V(\\vb X),\n\\end{align}\nwhere $\\vb p_i$ denotes the momentum of particle $i$, all of which are placed in some\nspacial potential $V$. It is easily verified that if we perform the above mentioned\nsubstitutions we will recover \\cref{eq:Hamiltonian-operator-general} and recognize\nit as the Hamiltonian operator, $\\hat H$.\n\nFinally, having both the wave function and the appropriate operator $\\hat O$ we can\nproceed. Observables no longer have definite values in general as in classical\nmechanics. Instead, we associate an expectation value with respect to the\n\\gls{pdf} described by $\\Psi$:\\footnote{Note that quantities\ncan still have definite values in certain states. This is then evident by the\nexpectation values having zero associated variance.}\n\n\\begin{align}\n    \\expval{O}=\\expval{\\hat O}&= \\frac{\\expval{\\hat O}{\\Psi}}{\\braket{\\Psi}} \\\\\n    &= \\frac{\\int\\dd{\\vb X} \\Psi^*(\\vb X)\\hat O(\\vb X)\\Psi(\\vb X)}{\\int\\dd{\\vb X}\n    \\abs{\\Psi(\\vb X)}^2},\n\\end{align}\nwhere $\\int\\dd{\\vb X}\\qty(\\cdot)$ indicates an integral over all possible configurations of the\nsystem (e.g.\\ all possible position and spin values for each particle). Often we have\nrequired the wave function to be normalized in such a way that the denominator is equal to\nunity, and it can then be omitted.\n\nFor many-body systems it should be apparent that this integral quickly becomes intractable\nto compute analytically. In practice we employ a numerical strategy to evaluate these\nintegrals, where the technique we use depends on the dimensionality of the integral and\nthe required level of accuracy. In our case, due to the large number\nof degrees of freedom in the systems we shall investigate, we will use\n\\gls{mci}. This will be discussed in more detail in \\cref{chp:monte-carlo}.\n\n\\section{Example Systems}\n\nSo far we have not presented any particular systems. In this thesis we focus our\nattention on two particular systems for illustrative purposes. We chose these systems\nfor their simplicity and/or the amount of preexisting results available\nin the literature. We do this in order to benchmark our results against\nknown exact solutions, or when these do not exist, against verified approximate\nresults available in the literature.\n\n\\subsection{Quantum Dots}\n\\label{sec:quantum-dots-theory}\n\nWe consider a system of electrically charged particles (e.g.\\ electrons) confined in a pure\nisotropic harmonic oscillator potential, with an idealized total Hamiltonian\ngiven by:\n\n\\begin{align}\n    \\begin{split}\n        \\hat H &= \\sum_{i=1}^N\\qty(-\\frac{1}{2}\\laplacian_i + V_{ext}(\\vec r_i)) +\n        \\sum_{i < j} V_{int}(\\vec r_i, \\vec r_j)\\\\\n        &= \\sum_{i=1}^N\\qty(-\\frac{1}{2}\\laplacian_i + \\frac{1}{2}\\omega^2\n        r_i^2) + \\sum_{i < j} \\frac{1}{r_{ij}},\n    \\end{split}\\label{eq:H-QD-def}\n\\end{align}\nwhere we use natural units ($\\hbar=c=m_e=1$) with energies in\natomic units (a.u.), $N$ denotes the number of particles in the system, and\n$\\omega$ is the oscillator frequency of the trap. Further, $\\vec r_i$\ndenotes the position vector of particle $i$, with $r_i \\defeq \\norm{\\vec r}$ and\n$r_{ij}\\defeq \\norm{\\vec r_i - \\vec r_j}$ defined for notational brevity.\n\nThis system describes particles trapped in a parabolic potential well that pulls\nthem towards the bottom at all times, while simultaneously feeling the repulsive\nCoulomb forces from the other particles. This hinders all particles from settling together\nat the bottom. Even for this somewhat idealized system, the interplay between these two\nopposing forces gives rise to a surprisingly complex problem, which will prove remarkably\nhard to solve analytically even for two particles, and utterly impossible for higher $N$.\n\nWith the natural units in place, the only involved quantity without a proper\nunit is length, i.e.\\ what unit does the $\\vb r_i$ have. A convenient\nchoice is to consider the mean square vibrational amplitude, $\\expval{r^2}$, for\na single particle at $T = \\SI{0}{\\kelvin}$ placed in the oscillator trap.\nComputing the expectation value we get\n$\\expval{r^2}=\\flatfrac{\\hbar}{2m\\omega}$, and we define the unit of length as the\ncharacteristic length of the trap, $a_{ho}=\\qty(2\\expval{r^2})^{\\flatfrac{1}{2}}=\\qty(\\flatfrac{\\hbar}{m\\omega})^{\\flatfrac{1}{2}}$~\\cite{mhj-compphys-II}.\n\nIn our case, we limit ourselves to $N=2$ interacting electrons in two\ndimensions in a trap with a frequency such that $\\hbar \\omega =\n1$.\\footnote{Note that, due to the natural units, this implies that $\\omega =\n  1$, which further means that $a_{ho} = 1$. It should be apparent why we use these\n  definitions, as it simplifies both units and expressions.} We do this because for\nthis case we have exact, analytical solutions for the ground state energy. With the\ninteraction term included, the ground state energy is $E_0 = \\SI{3}{\\au}$~\\cite{Taut1993}.\nThis limitation is purely one of convenience, as having exact benchmarks makes for better\nverification of results. Furthermore, limiting the size of the problem makes the required\ncomputation time manageable, which is good when experimenting with different techniques.\n\n\\subsubsection{Simple Non-Interacting Case}\\label{sec:simple-non-inter-HO}\nIf we omit the interacting terms in \\cref{eq:H-QD-def} we have\nthe standard harmonic oscillator Hamiltonian:\n\\begin{align}\n  \\label{eq:ho-no-interaction-hamiltonian}\n    \\hat H_0 &= \\sum_{i=1}^N\\qty(-\\frac{1}{2}\\laplacian_i +\n    \\frac{1}{2}\\omega^2 r_i^2).\n\\end{align}\nThis Hamiltonian lends itself to analytical solutions, and the stationary\nsingle particle states are (in 2D)~\\cite{griffiths_schroeter_2018}:\n\\begin{align}\\label{eq:ho-single-particle-orbitals}\n    \\phi_{n_x, n_y}(x, y) &= A H_{n_x}(\\sqrt\\omega x)H_{n_y}(\\sqrt\\omega y)\n    e^{-\\frac{\\omega}{2}\\qty(x^2 + y^2)},\n\\end{align}\nfor quantum numbers $n_x, n_y = 0, 1,\\dots$, and the Hermite polynomials\n$H_n$ (not to be confused with the Hamiltonians, and never to be mentioned again). The\nground state, $n_x=n_y=0$ is simply\n\\begin{align}\n  \\label{eq:ho-no-interaction-ground-state}\n    \\phi_{00}(x,y) =\n    \\sqrt{\\frac{\\omega}{\\pi}}e^{-\\frac{\\omega}{2}\\qty(x^2+y^2)}.\n\\end{align}\nUsing this wavefunction we can calculate the ground state\nenergy for one particle,\n\\begin{align}\n    \\epsilon_{00} = \\frac{\\expval{\\hat H_0}{\\phi_{00}}}{\\braket{\\phi_{00}}}\n    = \\omega = \\SI{1}{\\au}\n\\end{align}\nThe ground state wavefunction for the (unperturbed) two-electron case is simply the\nproduct of the one-electron wave functions,\n\\begin{align}\n    \\begin{split}\n        \\Phi(\\vec r_1, \\vec r_2) &= \\phi_{00}(\\vec r_1)\\phi_{00}(\\vec r_2)\\\\\n        &= \\frac{\\omega}{\\pi} e^{-\\frac{\\omega}{2}\\qty(r_1^2+r_2^2)}.\n    \\end{split}\\label{eq:Phi-non-inter}\n\\end{align}\nWe can once again evaluate the ground state energy analytically, which yields\n\\begin{align}\n    E_0 = \\frac{\\expval{\\hat H_0}{\\Phi}}{\\braket{\\Phi}}\n    = 2\\omega =\\SI{2}{\\au}\n\\end{align}\nThis result is not surprising, as adding one more particle, without any\ninteractions, should simply double the energy. Another way to look at it is\nthat the simple harmonic oscillator solution gives $\\flatfrac{\\omega}{2}$\nper degree of freedom, so adding another two yields and extra $\\omega$.\n\n\nWhen the two particles are electrons, we may say something about their total\nspin. As electrons are fermions, their total wavefunction must be\nanti-symmetric upon interchanging the labels $1$ and $2$.\n\\Cref{eq:Phi-non-inter} is obviously symmetric, and so the\nspin-wavefunction must necessarily be anti-symmetric. For the combination of\ntwo spin-1/2 particles, there is only one candidate, namely the spin-$0$\nsinglet:\n\n\\begin{align}\n    \\chi_0 = \\frac{1}{\\sqrt 2}\\qty(\\ket{\\uparrow\\downarrow} -\n    \\ket{\\downarrow\\uparrow}).\n\\end{align}\nA similar argument can be made for particles with different spins.\n\n\\subsubsection{Considerations from the Virial Theorem}\n\nThe virial theorem gives a general relation for the time-averaged kinetic\nenergy $\\expval{K}$ and the corresponding potential energy\n$\\expval{V_{pot}}$ of a stable system of $N$ particles. In general the\ntheorem states:\n\n\\begin{align}\n    \\expval{K} = -\\frac{1}{2}\\sum_{k=1}^N \\expval{\\vec F_k \\cdot \\vec\n    r_k},\\label{eq:virial-theorem}\n\\end{align}\nwhere $\\vec F_k$ denotes the combined forces acting on particle $k$, located\nat position $\\vec r_k$. For a radial potential on the form $V(r)=ar^n$, such\nthat the potential between any two particles in the system depends on some\npower of the inter-particle distance, the\ntheorem takes the following form:\n\\begin{align}\n    \\expval{K} = \\frac{n}{2}\\expval{V_{TOT}}\n\\end{align}\nwhere $V_{TOT}$ denotes the sum of the potential energy $V(r)$ over all\npairs of particles.\n\nAlthough the harmonic oscillator potential does not depend on the\n\\emph{inter-particle} distance, but rather on the positions of each particle,\nit % TODO, what was the edit?\nworks out to the same relation in our case. Computing the full relation for\nour Hamiltonian for two electrons in two dimensions, it even works out so\nthat we can use the same relation on the harmonic oscillator potential and the Coulomb\npotential separately, and add the result. This means that the virial theorem\npredicts the following~\\cite{Katriel2012}:\n\n\\begin{align}\n    \\expval{K} = \\expval{V_{ext}} -\n    \\frac{1}{2}\\expval{V_{int}}.\\label{eq:virial-result}\n\\end{align}\nNote that this implies that we should consider the \\emph{total} kinetic\nenergy, and the \\emph{total} external and internal potential energies, as opposed to per\nparticle.\n\n\n\\subsection{Liquid $^4$He}\n\\label{sec:liquid-helium-theory}\n\nConsider now an infinite collection of helium atoms ($^4$He) packed with a given density,\n$\\rho$. As infinities are hard to work with, we model this by considering a\ncubic simulation box with side lengths $L$ and periodic boundary conditions. The\ninfinite collection is then composed of stacking copies of such simulation boxes\ntogether. ~\\cref{fig:pbc-illustration} shows an illustration of the idea.\n\n\\begin{figure}[h]\n  \\centering\n  \\input{illustrations/PBC-illustration.tex}\n  \\caption[Illustration of periodic boundary conditions]{Illustration of $^4$He organized into a grid of identical simulation\n    boxes. The actual boxes are three-dimensional.\\citesource{writing/illustrations/PBC-illustration.tex}}\n  \\label{fig:pbc-illustration}\n\\end{figure}\n\n\nThe Hamiltonian for this system is\n\n\\begin{align}\n    \\hat H &= -\\sum_{i=1}^N \\frac{\\hbar^2}{2m}\\laplacian_i + \\sum_{i < j} V(r_{ij})\n\\end{align}\ni.e.\\ the kinetic energy of all atoms, plus an interaction potential dependent on\nthe distance between all pairs of atoms. The mass $m$ is the mass of one $^4He$\natom. The form of $V$ is not known analytically, but is experimentally probed to\ngreat accuracy. Theorists have since fitted specific functional forms to the\nexperimental data, and we will do our calculations using one of these\npotentials. The most commonly used is the simple Lennard-Jones (LJ)\npotential~\\cite{Kalos-1981}:\n\n\\begin{align}\n    \\label{eq:Lennard-Jones-def}\n    V(r)\n     &= 4\\epsilon\\qty[\\qty( \\frac{\\sigma}{r} )^{12} - \\qty( \\frac{\\sigma}{r} )^6 ]\n\\end{align}\nwith $\\epsilon/\\kappa = \\SI{10.22}{\\K}$\\footnote{$\\kappa$ is the Boltzmann constant.} and $\\sigma = \\SI{2.556}{\\angstrom}$. This\nmodels the competing forces of the atoms' mutual repulsion and attraction. The\npositive term describes the short range Pauli repulsion due to overlapping\nelectron orbitals, and the negative term describes the long range attraction\ndue to phenomena such as van der Waals forces.\n\nWe can also use the slightly more accurate (and complicated) potential named HFDHE2~\\cite{Aziz-hfdhe2}:\n\n\\begin{align}\n    \\label{eq:HFDHE2-def}\n    V(r) &= \\epsilon\n    \\left\\{\\!\\begin{aligned}\n        &A \\exp(-\\alpha \\frac{r }{ r_m})\\\\\n        &- F(r) \\qty[ C_6  \\qty(\\frac{r_m }{ r})^6 + C_8  \\qty(\\frac{r_m }{ r})^8 + C_{10} \\qty(\\frac{r_m }{ r})^{10}]\n    \\end{aligned}\\right\\}\n\\end{align}\nwith\n\n\\begin{align}\n    F(r) &= \\begin{cases}\n        \\exp( - [D \\frac{r_m}{r} -  1]^2 ) & \\qfor \\frac{r}{r_m} \\leq D\\\\\n        1 & \\qotherwise\n    \\end{cases}\n\\end{align}\nwith the following parameters:\n\\begin{align}\\label{eq:HFDHE2-parameters}\n    \\begin{split}\n        &A = \\num{0.5448504e6}\\\\\n        &\\alpha = \\num{13.353384}\\\\\n        &D = \\num{1.241314}\\\\\n        &r_m= \\SI{2.9673}{\\angstrom}\n    \\end{split}\n    \\begin{split}\n        &\\epsilon/\\kappa = \\SI{10.8}{\\K}\\\\\n        &C_6= \\num{1.37732412}\\\\\n        &C_8= \\num{0.4253785}\\\\\n        &C_{10}= \\num{0.178100}\\\\\n    \\end{split}\n\\end{align}\nBoth potentials grow rapidly for small $r$, and tend to $0$ for large $r$. The\ninteresting sections of both potentials are shown\nin~\\cref{fig:helium-potentials-plot}. The potentials are very similar, with the\nmain difference being the depth of the well and how sharply the potential dies\noff.\n\n\\begin{figure}[h]\n  \\centering\n  \\input{illustrations/helium-potentials.tex}\n  \\caption[Lennard-Jones and HFDHE2 potentials]{Lennard-Jones and HFDHE2 potentials used to model the potential\n    between pairs of $^4$He atoms. Both potentials grow rapidly towards infinity\n  when $r\\to0$ and approach zero when $r\\to\\infty$.\\citesource{writing/illustrations/helium-potentials.tex}}\n  \\label{fig:helium-potentials-plot}\n\\end{figure}\n\n\n\n\\subsubsection{A Note About Units}\n\nIn the literature it is common to express the energies in Kelvin per particle,\nand lengths in angstrom~\\cite{Kalos-1981, Aziz-hfdhe2, ruggeri2018}. In order to convert energies to temperatures we\ndivide by the Boltzmann constant, $\\kappa$, because it has the unit of Joules per\nKelvin. The Hamiltonian becomes:\n\\begin{align}\n  \\hat H &= -\\sum_{i=1}^N \\frac{\\hbar^2}{2m\\kappa}\\laplacian_i + \\sum_{i<j}\\frac{1}{\\kappa}V(r_{ij}).\n\\end{align}\n\nIf we use SI units for the constants involved we get:\n\\begin{align}\n  \\frac{\\hbar^2}{2m\\kappa} = \\SI{6.059651974e-20}{\\metre^2\\kelvin} = \\SI{6.059651974}{\\angstrom^2\\kelvin},\n\\end{align}\nwhich turns out to be a reasonably sized number when we use angstrom as units for\nlengths.\\footnote{Note that $\\laplacian$ has units of $\\text{length}^{-2}$, so\n  the units work out to Kelvin.} We will use these values in the implementation,\nand simply refer to energies in Kelvin when we study this system. However, if\nthe reader ever wants to convert the units, for comparison with other works\nperhaps, simply multiplying with the value of $\\kappa$ in the unit system of\nchoice should yield the corresponding energy.\n\n\n\\subsubsection{Minimum Image}\n\nBecause we assume a periodic structure we must take this into account when\ncalculating distances. Consider two particles, A and B, located at opposite\ncorners of the simulation box. What is the distance between them? The intuitive\nanswer is $\\norm{\\vb r_A - \\vb r_B} = \\sqrt{3}\\,L$, i.e.\\ the length of the\ndiagonal of the cubic box. Nevertheless, the answer we should use is zero. The\nreason is that there is a periodic copy of the box stacked such that A and the\nperiodic B copy are located at the same corner. This way of calculating\ndistances is called minimum image, and says that we should use the shortest\npossible distance. In general, if two particles have a distance of $\\Delta x =\n\\flatfrac{L}{2} + \\delta_x$ ($\\delta_x\\geq 0$, each spatial coordinate handled\nindividually), the minimum image distance is $\\Delta x_{\\mathit{min}} = \\Delta x\n- L = \\flatfrac{L}{2} - \\delta_x$.\n\nIn our implementation, whenever we need a distance between two particles, we use\nthe following prescription (example in Python):\n\n\\begin{lstlisting}[language=Python]\nimport numpy as np\n\n# Example coordinates.\nL = 5.0\np1, p2 = np.array([0, 0, 0]), np.array([2, 3, 4])\n\ndiff = p2 - p1  # [2, 3, 4]\ndiff_minimum = diff - L * np.round(diff / L)  # [2, -2, -1]\n\\end{lstlisting}\nThe last variable, \\texttt{diff\\_minimum} represents the minimum image distance\nvector and this is the one used for any further calculations.\n\n\\subsubsection{Correcting for Periodicity in Potentials}\n\nThe potential $V(r_{ij})$ depend on the inter-particle distances. However,\nthere is an infinite amount of particle pairs if we consider the system as a\nwhole. We use periodic boundary conditions, and shall only consider pairs where\nboth particles are in the simulation box (but still respecting the minimum image\nconvention). This limitation excludes any interactions that act on length scales\nlarger than $\\flatfrac{L}{2}$, and this can have a significant impact on the\ntotal system.\n\nIn an attempt to limit this effect, we modify the potentials slightly. First we\nexplicitly truncate the potential to be zero for large distances, and shift it\nslightly so that the function remains continuous. That is, considering $V(r)$\nfrom~\\cref{eq:Lennard-Jones-def}, we change it as follows:\n\n\\begin{align}\n  \\label{eq:Lennard-Jones-truncated-def}\n  V_\\mathit{trunc}(r) &=\n                          \\begin{cases}\n                            V(r) - V(\\flatfrac{L}{2}) & \\qfor r \\leq \\flatfrac{L}{2}\\\\\n                            0 & \\qotherwise\n                          \\end{cases}.\n\\end{align}\nNote that in order for this truncation to be sensible, we must use a\nsufficiently large box so that $V(\\flatfrac{L}{2})$ is sufficiently close to\nzero. What exactly \\emph{sufficiently} means is left rather vague, but we\nmention it as a potential source of error.\\\\\n\nThe truncation obviously leads to slightly less precise results, but this can\npartially be corrected for with so-called \\emph{tail corrections}. The approach\nis to model the potential contribution of all particles further away than\n$\\flatfrac{L}{2}$ in a mean-field manner. The result is simply adding a constant\nterm, and acts only to shift the total potential in a given direction. As the\npurpose of this thesis is not to obtain the most realistic results possible, and\nrather a \\emph{relative} comparison of methods, we will not spend more time on\nspecific ways of implementing such corrections.\n\n\n\\end{document}\n", "meta": {"hexsha": "135ddfbc0ef6af845cbee0233aca2b0c16aefe12", "size": 32266, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writing/QuantumTheory.tex", "max_stars_repo_name": "johanere/qflow", "max_stars_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-07-24T21:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-11T18:18:24.000Z", "max_issues_repo_path": "writing/QuantumTheory.tex", "max_issues_repo_name": "johanere/qflow", "max_issues_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2019-02-19T10:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-18T09:42:13.000Z", "max_forks_repo_path": "writing/QuantumTheory.tex", "max_forks_repo_name": "bsamseth/FYS4411", "max_forks_repo_head_hexsha": "72b879e7978364498c48fc855b5df676c205f211", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-11-04T15:17:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-03T16:37:38.000Z", "avg_line_length": 48.3023952096, "max_line_length": 155, "alphanum_fraction": 0.7419264861, "num_tokens": 8835, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.42565306174023454}}
{"text": "\\section{The Empirical Dust Attenuation Framework} \\label{sec:dem}\nIn this section, we describe the Empirical Dust Attenuation (\\eda)\nframework and present the \\eda~prescription used in this work to apply \ndust attenuation to our simulated galaxies.\n%For each simulated galaxy, the \\eda~assigns a dust attenuation\n%curve that is parameterized as a function of the galaxy's properties \n%($M_*$, ${\\rm SSFR}$), the \\eda~parameters, and randomly\n%sampled inclination. With the \\eda, we can apply a wide variety of dust\n%attenuation that include correlation between dust attenuation and physical\n%galaxy properties. \n% Later, we demonstrate that we can accurately reproduce SDSS observations with the \\eda~and use it to test galaxy formation models and shed light on dust in galaxies. \nWe begin by defining the dust attenuation curve, $A(\\lambda)$, as \n\\begin{equation} \\label{eq:full_atten}\n    F_o (\\lambda) = F_i (\\lambda) 10^{-0.4 A(\\lambda)}\n\\end{equation}\nwhere $F_o$ is the observed flux and $F_i$ is the intrinsic flux. We normalize\nthe attenuation to the $V$ band attenuation, \n\\begin{equation} \n    A(\\lambda) = A_V \\frac{k(\\lambda)}{k_V}\n\\end{equation}\nso that $A_V$ determines the amplitude of the attenuation, while $k(\\lambda)$\ndetermines the wavelength dependence. \nThe \\eda~assigns a $A_V$ and $k(\\lambda)$ for each simulated galaxy. \nFor $A_V$, we use the slab model~\\citep[\\eg][]{somerville1999, somerville2012},\nwhere $A_V$ is a \n%The \\eda~framework assigns $A(\\lambda)$ to every galaxy in the simulations using some flexible prescription. For the \\eda~prescription in this work, we assign $A_V$ for each galaxy using the slab model, where $A_V$ is a\nfunction of galaxy inclination, $i$, and galaxy properties: %its optical depth, $\\tau_V$: \n\\begin{equation} \\label{eq:slab}\n    A_V = -2.5 \\log \\left[ \\frac{1 - e^{-\\tau_V\\,\\sec i}}{\\tau_V\\,\\sec i} \\right].\n\\end{equation}\n$\\tau_V$ is the $V$-band optical depth that depends linearly on $M_*$ and\n$\\ssfr$: \n%We parameterize $\\tau_V$ using a linear $M_*$ and $\\ssfr$ dependence: \n\\begin{equation} \\label{eq:tauv}\n    \\tau_V(M_*, \\sfr) = \\mtaum \\log \\left(\\frac{M_*}{10^{10} M_\\odot}\\right) +\n    \\mtaus \\log \\left(\\frac{\\ssfr}{10^{-10}yr^{-1}}\\right) + c_\\tau.\n\\end{equation}\n$\\mtaum$, $\\mtaus$, and $c_\\tau$ represent the $M_*$ dependence, the $\\ssfr$\ndependence, and amplitude of $\\tau_V$. Since $\\tau_V$ is optical depth, we\nimpose a $\\tau_V \\ge 0$ limit.\nFor each galaxy, we uniformly sample $\\cos i$ from 0 to 1 to introduce\nstochasticity. \nThis produces significant variance in $A_V$ so galaxies with the same\nproperties do not have identical dust attenuation.\n\nOur $\\tau_V$ parameterization is based on correlations between dust attenuation\nand galaxy properties that have been established by\nobservations~\\citep[\\eg~][]{garn2010, battisti2016, salim2020}.\nPrevious works have parameterized dust attenuation based on other galaxy properties\nsuch as gas density, gas metallicity, or star-gas geometry, motivated by\nthe fact that dust attenuation on small scales depends on local stellar and gas\nproperties~\\citep[\\eg][]{somerville1999, somerville2012, steinacker2013,\ncamps2015, narayanan2018, trayford2020, vogelsberger2020}. \nGalaxies in the SIMBA, TNG, and EAGLE, however, have\nsubstantially different gas masses and metallicites~\\citep[][Maller \\etal~in prep.]{dave2020}.  \nIf we were to parameterize $\\tau_V$ using these properties, their differences\nwould dominate any comparison of dust attenuation.\n%Instead, our parameterization for $\\tau_V$ is based on the correlation between dust attenuation and galaxy properties that have been established by observations~\\citep[\\eg~][]{garn2010, battisti2016, salim2020}.\nIn Appendix~\\ref{sec:slab}, we confirm the correlation between $A_V$ and\nthe properties $M_*$ and $\\ssfr$ in the \\cite{salim2018} GSWLC2 sample\n(Figure~\\ref{fig:dep}). \n%We therefore include in Eq.~\\ref{eq:tauv} the correlation between $A_V$ and galaxy $M_*$ and $\\ssfr$.\n\nIn our \\eda, we use the slab model because it provides a simple\nprescription for generating a distribution of $A_V$ that depends on\nrandomly sampled $i$, with loose physical motivations.\nFor star-forming galaxies, which typically have disc-like morphologies, the\nslab model produces $A_V$ that is correlated with $i$ in a way consistent\nwith observations: edge-on galaxies have higher $A_V$ than face-on\ngalaxies~\\citep[\\eg][]{conroy2010, wild2011, battisti2017, salim2020}.\nNevertheless, the slab model is a simplification. \nIn reality, $A_V$ depends on the detailed star-to-dust geometry.\nFurthermore, we assign $A_V$ to all galaxies, not just star-forming.\nFor quiescent galaxies, which typically have elliptical morphologies, the\nslab model serves only as an \\emph{empirical} prescription for statistically \nsampling $A_V$. \nThe~\\eda~seeks to assign an accurate distribution of dust\nattenuation curves for an ensemble of galaxies --- \\emph{not} to accurately\nmodel dust attenuation for individual galaxies.\nIn this regard, we demonstrate in Appendix~\\ref{sec:slab} that the slab model\ncan match the observed distribution of $A_V$, even for samples that\ninclude quiescent galaxies.\n\nFor the wavelength dependence of the attenuation curve, $k(\\lambda)$, we\nuse \\cite{noll2009} parameterization: \n\\begin{equation} \\label{eq:noll}\n    k(\\lambda) = \\left(k_{\\rm Cal}(\\lambda) + D(\\lambda)\\right) \\left(\n    \\frac{\\lambda}{\\lambda_V} \\right)^\\delta.\n\\end{equation}\nHere $k_{\\rm Cal}(\\lambda)$ is the \\cite{calzetti2001} curve: \n\\[\n    k_{\\rm Cal}(\\lambda) = \n    \\begin{cases} \n        2.659 (-1.857 + 1.040/\\lambda) + R_V, & 6300 A \\le \\lambda \\le\n        22000 A \\\\ \n        2.659 (-2.156 + 1.509/\\lambda - 0.198/\\lambda^2 + 0.011/\\lambda^3) +\n        R_V & 1200 A \\le \\lambda \\le 6300 A\n    \\end{cases}\n\\]\nwhere $\\lambda_V = 5500 A$ is the $V$ band wavelength and $\\delta$ is the slope\noffset of the attenuation curve from $k_{\\rm Cal}$. Since $\\delta$ correlates \nwith galaxy properties~\\citep[\\eg][see also Appendix~\\ref{sec:slab}]{wild2011, battisti2016, leja2017, salim2018},\nwe parameterize $\\delta$ with a similar $M_*$ and $\\ssfr$ dependence as\n$\\tau_V$:  \n\\begin{align} \\label{eq:delta}\n    \\delta(M_*, \\sfr) &= \\mdeltam \\log \\left(\\frac{M_*}{10^{10}\n    M_\\odot}\\right) + \\mdeltas \\log \\left(\\frac{\\ssfr}{10^{-10}yr^{-1}}\\right)\n    + c_\\delta.\n\\end{align}\n% Although a number of works have found correlation between the attenuation\n% curve slope and inclination~\\citep{wild2011, chevallard2013, battisti2017b},\n% \\cite{salim2020}, most recently, found that the driver of this trend is the\n% relationship between $A_V$ and slope. We therefore do not include an\n% inclination dependence in $\\delta$. \n$D(\\lambda)$ in Eq.~\\ref{eq:noll} is the UV dust bump, which we parameterize using\nthe standard Lorentzian-like Drude profile:\n\\begin{equation}\n    D(\\lambda) = \\frac{E_b(\\lambda~\\Delta \\lambda)^2}{(\\lambda^2 -\n    \\lambda_0^2)^2 + (\\lambda~\\Delta \\lambda)^2}\n\\end{equation}\nwhere $\\lambda_0 = 2175 \\AA$, $\\Delta \\lambda = 350\\AA$, and $E_b$ are the\ncentral wavelength, full width at half maximum, and strength of the bump,\nrespectively. \nWe include the UV dust bump since we use UV color as one of our observables.\n\\cite{kriek2013} and \\cite{tress2018} find that $E_b$ correlates with $\\delta$ for star-forming galaxies at $z{\\sim}2$.\n\\cite{narayanan2018} confirmed this dependence in simulations. \nHence, we assume a fixed relation between $E_B$ and $\\delta$: $E_b =\n-1.9~\\delta + 0.85$~\\citep{kriek2013}. \nAllowing the slope and amplitude\nof the $E_B$ and $\\delta$ relation to vary does {\\em not} impact our results;\nhowever, we also do not derive any meaningful constraints on them. In\nTable~\\ref{tab:free_param}, we list and describe all of the free parameters of\nour \\eda~prescription. \n\n%In $\\tau_V$ we include the correlation between $A_V$ and the galaxy's properties , found in both observations and simulations~\\citep[\\eg][]{narayanan2018, salim2020}. \n\n\n$\\ssfr$ of galaxies are used to calculate $\\tau_V$ and $\\delta$ in\nEqs.~\\ref{eq:tauv} and~\\ref{eq:delta}. However, due to mass and temporal resolution limits,\nsome galaxies in the simulations have $\\sfr=0$ --- \\ie~an unmeasurably low\nSFR~\\citep{hahn2019c}. They account for 17, 19, 9\\% of galaxies\nin SIMBA, TNG, and EAGLE, respectively. Since Eqs.~\\ref{eq:tauv}\nand~\\ref{eq:delta} depend on $\\log\\ssfr$, they cannot be used in the equations\nto derive $\\tau_V$ and $\\delta$ for these galaxies. To account for this issue,\nwe assign $\\sfr_{\\rm min}$, the minimum non-zero $\\sfr$ in each simulation, to\n$\\sfr=0$ galaxies when calculating $\\tau_V$ and $\\delta$. For SIMBA, TNG, and\nEAGLE, $\\sfr_{\\rm min}=0.000816$, $0.000268$, and $0.000707 M_\\odot/yr$,\nrespectively. Although \nthis assumes that $\\sfr=0$ galaxies have similar dust properties as the galaxies \nwith $\\sfr = \\sfr_{\\rm min}$, since the simulations have very low $\\sfr_{\\rm min}$ \nwe expect galaxies with $\\sfr = \\sfr_{\\rm min}$ to have little recent\nstar-formation and low gas mass, similar to $\\sfr=0$ galaxies. \n\n%Since $\\sfr=0$ galaxies do not account for a large fraction of our simulated galaxies, we directly sample their observables ($G, R, NUV$, and $FUV$) from the distribution of observables for SDSS quiescent galaxies. This way, we ensure that the attenuation of $\\sfr=0$ galaxies does not impact the rest of the \\eda~parameters. In Appendix~\\ref{sec:res}, we discuss the resolution effects in more detail and demonstrate that our results are \\emph{not} impacted by other prescriptions for attenuating $\\sfr=0$ galaxies.\n\nIn summary, to apply the \\eda~to a simulated galaxy population, we first\nassign a randomly sampled $i$ to each galaxy ($\\cos i$ uniformly sampled from 0 to 1).\n$\\tau_V$ and $\\delta$ are calculated for\nthe galaxy based on its $M_*$,\n$\\ssfr$ and the \\eda~parameters. \nWe then calculate $A_V$ and $k(\\lambda)$ to determine $A(\\lambda)$ for each galaxy.\nAfterwards, we attenuate the galaxy SEDs using Eq.~\\ref{eq:full_atten} and use\nthe attenuated SEDs to calculate the observables: $g, r, NUV$, and $FUV$\nabsolute magnitudes. \nIn Figure~\\ref{fig:dem_av}, we present attenuation curves, $A(\\lambda)$,\ngenerated by the \\eda~for galaxies with different $\\sfr$ and $M_*$ values.  \nWe present star-forming galaxies with $\\{M_*, \\sfr\\} = \\{10^{10}M_\\odot,\n10^{0.5}M_\\odot/yr\\}$ (blue), $\\{10^{11}M_\\odot, 10^{1} M_\\odot/yr\\}$\n(green) and a quiescent galaxy with $\\{10^{11}M_\\odot, 10^{-2}M_\\odot/yr\\}$\n(red).\nWe use an arbitrary set of \\eda~parameters ($\\mtaum, \\mtaus, c_\\tau,\n\\mdeltam, \\mdeltas, c_\\delta$) within the prior range listed in\nTable~\\ref{tab:free_param}. \nWe set $i=0$ (edge-on) for all $A(\\lambda)$ in Figure~\\ref{fig:dem_av} for\nsimplicity.\n%In practice the \\eda~uniformly samples $\\cos i$ from 0 to 1 for each galaxy.\nFor comparison, we include the \\cite{calzetti2001} attenuation curve. \nThe \\eda~produces attenuation curves with a wide range of amplitudes and slopes\nfor galaxies based on their physical properties. \n\n\\begin{figure}\n\\begin{center}\n    \\includegraphics[width=0.6\\textwidth]{figs/dems.pdf}\n    \\caption{\\label{fig:dem_av}\n    Attenuation curves, $A(\\lambda)$, assigned by our Empirical Dust\n    Attenuation (\\eda) prescription to edge-on galaxies with different $\\sfr$ and\n    $M_*$ values for an arbitrary set of \\eda~parameters. We include\n    $A(\\lambda)$ for star-forming galaxies with $\\{M_*, \\sfr\\} =\n    \\{10^{10}M_\\odot, 10^{0.5}M_\\odot/yr\\}$ (blue), $\\{10^{11}M_\\odot, 10^{1}\n    M_\\odot/yr\\}$ (green) and a quiescent galaxy with $\\{10^{11}M_\\odot,\n    10^{-2}M_\\odot/yr\\}$ (red). We set $i=0$ for\n    all the galaxies in the figure for simplicity but in practice the\n    \\eda~uniformly samples $\\cos i$ from 0 to 1 for each galaxy.\n    For comparison, we include the \\cite{calzetti2001} attenuation curve.\n    {\\em The \\eda~provides a flexible prescription for assigning dust\n    attenuation to galaxies based on their physical properties ($M_*$ and\n    $\\ssfr$) and the \\eda~parameters.}\n    } \n\\end{center}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% table of free parameters\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{table}\n    \\caption{Free parameters of the Empirical Dust Attenuation Model}\n    \\begin{center}\n        \\begin{tabular}{ccc} \\toprule\n            Parameter & Definition & prior\\\\[3pt] \\hline\\hline\n            %\\multicolumn{3}{c}{DEM with slab model}\\\\ \\hline\n            $\\mtaum$ & $M_*$ dependence of the optical depth, $\\tau_V$ & flat $[-5., 5.]$\\\\\n            $\\mtaus$ & $\\ssfr$ dependence of $\\tau_V$  & flat $[-5., 5.]$\\\\\n            $c_{\\tau}$ & amplitude of $\\tau_V$ & flat $[0., 6.]$\\\\\n            %\\hline\n            %\\multicolumn{3}{c}{DEM with $\\mathcal{N}_T$ model}\\\\ \\hline\n            %$m_{\\mu,1}$ & Slope of the $\\log M_*$ dependence of optical depth,\n            %$\\tau_V$ & flat $[-5., 5.]$\\\\\n            %$m_{\\mu,2}$ & Slope of the $\\log {\\rm SFR}$ dependence of optical\n            %depth, $\\tau_V$ & flat $[-5., 5.]$\\\\\n            %$c_{\\mu}$ & amplitude of the optical depth, $\\tau_V$ & flat $[0., 6.]$\\\\ \n            %$m_{\\sigma,1}$ & Slope of the $\\log M_*$ dependence of optical depth, $\\tau_V$ & flat $[-5., 5.]$\\\\\n            %$m_{\\sigma,2}$ & Slope of the $\\log {\\rm SFR}$ dependence of optical depth, $\\tau_V$ & flat $[-5., 5.]$\\\\\n            %$c_{\\sigma}$ & amplitude of the optical depth, $\\tau_V$ & flat $[0.1, 3.]$\\\\ \n            %\\hline\n            $\\mdeltam$ & $M_*$ dependence of $\\delta$, the attenuation curve slope offset & flat $[-4., 4.]$\\\\\n            $\\mdeltas$ & $\\ssfr$ dependence of $\\delta$ & flat $[-4., 4.]$\\\\\n            $c_{\\delta}$ & amplitude of $\\delta$ & flat $[-4., 4.]$\\\\\n            %$f_{\\rm neb}$ & nebular attenuation fraction & flat $[1., 4.]$\\\\\n            \\hline\n        \\end{tabular} \\label{tab:free_param}\n    \\end{center}\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "2e531b378f9528c5d2be6ce1cea26c1433151bac", "size": 13854, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/paper/dem.tex", "max_stars_repo_name": "IQcollaboratory/galpopFM", "max_stars_repo_head_hexsha": "1b30abc1cc2fd1119d0f34a237b0c1112d7afc9d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-08T17:36:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-08T17:36:06.000Z", "max_issues_repo_path": "doc/paper/dem.tex", "max_issues_repo_name": "IQcollaboratory/galpopFM", "max_issues_repo_head_hexsha": "1b30abc1cc2fd1119d0f34a237b0c1112d7afc9d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 35, "max_issues_repo_issues_event_min_datetime": "2020-02-07T19:02:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-04T14:28:05.000Z", "max_forks_repo_path": "doc/paper/dem.tex", "max_forks_repo_name": "IQcollaboratory/galpopFM", "max_forks_repo_head_hexsha": "1b30abc1cc2fd1119d0f34a237b0c1112d7afc9d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.9531914894, "max_line_length": 517, "alphanum_fraction": 0.6948895626, "num_tokens": 4238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.42565304915690655}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{mhchem}\n\\usepackage{stmaryrd}\n\\usepackage{graphicx}\n\\usepackage[export]{adjustbox}\n\\graphicspath{ {./images/} }\n\\usepackage{bbold}\n\\usepackage{hyperref}\n\\hypersetup{colorlinks=true, linkcolor=blue, filecolor=magenta, urlcolor=cyan,}\n\\urlstyle{same}\n\n\\begin{document}\n\\section{Contents}\n1 Convolutional Neural Networks $\\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots$\n\n$1.1$ Convolutional operations $\\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots$\n\n1.1.1 Images as matrix $\\ldots \\ldots \\ldots \\ldots \\ldots . . . . . . . . . . . . . . . . .$\n\n1.1.2 Convolution operation with one channel $\\ldots \\ldots \\ldots \\ldots \\ldots .$\n\n1.1.3 Convolution with stride (one channel) $\\ldots \\ldots \\ldots \\ldots \\ldots \\ldots .$\n\n1.1.4 Convolutional operations with multi-channel $\\ldots \\ldots \\ldots \\ldots .6$\n\n$1.1 .5$ Pooling operation in CNNs $\\ldots \\ldots . \\ldots . . . . . . . . . . . . . . . . .$\n\n$1.2$ Examples of convolution filters and performance $\\ldots \\ldots \\ldots \\ldots, \\ldots$\n\n1.2.1 Calculation with convolutions .............................. 8\n\n$1.2 .2 \\quad$ Image convolution examples $\\ldots \\ldots \\ldots \\ldots . \\ldots . . . . . . . . . .$\n\n1.2.3 Line detection by 1D Laplacian $\\ldots \\ldots \\ldots . \\ldots . . . . . . . . .$\n\n1.2.4 Edge detection by 2D Laplacian operator $\\ldots \\ldots \\ldots \\ldots \\ldots .12$\n\n1.2.5 The Laplacian of Gaussian $\\ldots \\ldots \\ldots \\ldots . . . . . . . . . . . .$\n\n1.2.6 Other examples with ReLU activation $\\ldots \\ldots \\ldots \\ldots \\ldots .15$\n\n1.2.7 Some other examples $\\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots . . . . . . . . . . . . . . . . . . .$\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-01}\n\nReferences $\\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots \\ldots$\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-02}\n\n\\section{Convolutional Neural Networks}\n\\subsection{Convolutional operations}\n\\subsubsection{Images as matrix}\nAn image can be viewed as a piecewise constant function on a grid. Images with different resolutions can then be viewed as functions on grids of different sizes. The use of such multiple-grids is a main technique used in the standard multigrid method for solving discretized partial differential equations, and it can also be interpreted as a main ingredient used in convolutional neural networks (CNN) for image calssification.\n\nAn image can be viewed as a function on a grid [6] on a rectangle domain $\\Omega \\in \\mathcal{R}^{2}$. Without loss of generality, we assume that the grid, $\\mathcal{T}$, is of size\n$$\nm=2^{s}, \\quad n=2^{t}\n$$\nfor some integers $s, t \\geq 1$. Starting from $\\mathcal{T}_{1}=\\mathcal{T}$, we consider a sequence of coarse grids with $J=\\min (s, t)$ (as depicted in Fig. 1.1.1 with $J=4)$ :\n$$\n\\mathcal{T}_{1}, \\mathcal{T}_{2}, \\ldots, \\mathcal{T}_{J}\n$$\nsuch that $\\mathcal{T}_{\\ell}$ consist of $m_{\\ell} \\times n_{\\ell}$ grid points, with\n$$\nm_{\\ell}=2^{s-\\ell+1}, \\quad n_{\\ell}=2^{t-\\ell+1} .\n$$\nHere, please note that each element in this grid can be viewed as a pixel or an image or an element in a matrix.\n\n\\subsubsection{Convolution operation with one channel}\nFor simplicity of exposition, we denote\n$$\nm=m_{1}=2^{s}, \\quad n=n_{1}=2^{t} .\n$$\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-04}\n\nFig. 1.1. multilevel grids for piecewise constant functions (images)\n\nDefinition 1. A convolution defined on $\\mathbb{R}^{m \\times n}$ is a linear mapping $K *: \\mathbb{R}^{m \\times n} \\mapsto \\mathbb{R}^{m \\times n}$ defined with padding, for any $g \\in \\mathbb{R}^{m \\times n}$ by:\n$$\n[K * g]_{i, j}=\\sum_{p, q=-k}^{k} K_{p, q} g_{i+p, j+q}, \\quad i=1: m, j=1: n\n$$\nHere we note that the indices for the entries in $K$ are given un a special way. For example, if $k=1, K \\in \\mathbb{R}^{3 \\times 3}$, and\n$$\nK=\\left(\\begin{array}{ccc}\nK_{-1,-1} & K_{-1,0} & K_{-1,1} \\\\\nK_{0,-1} & K_{0,0} & K_{0,1} \\\\\nK_{1,-1} & K_{1,0} & K_{1,1}\n\\end{array}\\right)\n$$\nfor we may have the following 2D Laplacian kernel\n$$\nK=\\left(\\begin{array}{ccc}\n0 & -1 & 0 \\\\\n-1 & 4 & -1 \\\\\n0 & -1 & 0\n\\end{array}\\right)\n$$\nThe coefficients in (1.17) constitute a kernel matrix\n$$\nK \\in \\mathbb{R}^{(2 k+1) \\times(2 k+1)}\n$$\nwhere $k$ is often taken as a small integer. Here padding means how $g_{i+p, j+q}$ is defined when $(i+p, j+q)$ is out of $1: m$ or $1: n$. The following three choices are often used\n$$\ng_{i+p, j+q}=\\left\\{\\begin{array}{lll}\n0, & & \\text { zero padding, } \\\\\nf_{(i+p)} & (\\bmod m),(s+q) & (\\bmod n), & \\text { periodic padding } \\\\\nf_{|i-1+p|,|j-1+q|}, & & \\text { reflected padding }\n\\end{array}\\right.\n$$\nif\n$$\ni+p \\notin\\{1,2, \\ldots, m\\} \\text { or } j+q \\notin\\{1,2, \\ldots, n\\}\n$$\nHere $d(\\bmod m) \\in\\{1, \\cdots, m\\}$ means the remainder when $d$ is divided by $m$.\n\nHere is a diagram for convolution with one channel (and also stride one).\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-05}\n\n\\subsubsection{Convolution with stride (one channel)}\nDefinition 2. Convolution with stride 2 is defined as\n$$\n\\left[K *_{2} g\\right]_{i, j}=\\sum_{p, q=-k}^{k} K_{p, q} g_{2 i+p-1,2 j+q-1}, \\quad i=1:\\left\\lfloor\\frac{m+1}{2}\\right\\rfloor, j=1:\\left\\lfloor\\frac{n+1}{2}\\right\\rfloor\n$$\nWe note that, in general, for any given integer $s \\geq 1$, a convolution with stride $s$ for $g \\in \\mathbb{R}^{m \\times n}$ can be defined as:\n$$\n\\left[K *_{s} g\\right]_{i, j}=\\sum_{p, q=-k}^{k} K_{p, q} g_{s(i-11)+p+1, s(j-1)+q+1}, \\quad i=1:\\left\\lfloor\\frac{m+1}{s}\\right\\rfloor, j=1:\\left\\lfloor\\frac{n+1}{s}\\right\\rfloor .\n$$\nHere $\\left\\lfloor\\frac{m}{s}\\right\\rfloor$ denotes the biggest integer that less than $\\frac{m}{s}$. The following is a diagram for stride 2 .\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-05(1)}\n\nLemma 1. The convolution with stride 2 can be written as:\n$$\nK *_{2} g=\\mathcal{S}(K * g),\n$$\nwhere $\\mathcal{S}$ is a stride operator defined by:\n$$\n\\mathcal{S}: \\mathbb{R}^{m \\times n} \\mapsto \\mathbb{R}^{\\frac{m+1}{2} \\times \\frac{n+1}{2}},\n$$\nwith\n$$\n[\\mathcal{S}(g)]_{i, j}=g_{2 i-1,2 j-1}, \\quad i=1:\\left\\lfloor\\frac{m+1}{2}\\right\\rfloor, j=1:\\left\\lfloor\\frac{n+1}{2}\\right\\rfloor\n$$\nExample 1. The so-called average pooling with kernel size $3 \\times 3$ and stride 2 means\n$$\nK *_{2},\n$$\nwhere\n$$\nK=\\frac{1}{9}\\left(\\begin{array}{lll}\n1 & 1 & 1 \\\\\n1 & 1 & 1 \\\\\n1 & 1 & 1\n\\end{array}\\right)\n$$\n\n\\subsubsection{Convolutional operations with multi-channel}\nOne important class of linear mapping is the so-called convolution:\n$$\n\\theta: \\mathbb{R}^{c \\times m \\times n} \\mapsto \\mathbb{R}^{h \\times m \\times n},\n$$\nwhere $m \\times n$ is called the spatial dimension or resolution, $c$ and $h$ are corresponding to input and output channels. The operation is defined by\n$$\n[\\theta(f)]_{s}=\\sum_{t=1}^{c} K_{s, t} *[f]_{t}+b_{s} \\mathbf{1} \\in \\mathbb{R}^{m \\times n}, \\quad s=1: h,\n$$\nwhere $1 \\in \\mathbb{R}^{m \\times n}$ is a $m \\times n$ matrix with all elements being 1 , and for $[f], \\in \\mathbb{R}^{m \\times n}$ represent for the $t$-th channel\n$$\n\\left[K_{s, t} *[f]_{t}\\right]_{i, j}=\\sum_{p, q=-k}^{k} K_{s, t ; p, q} f_{t ; i+p, j+q}, \\quad i=1: m, j=1: n\n$$\nThe coefficients kernel $K_{s, t}$ in (1.17) constitute a kernel matrix\n$$\nK_{s, t} \\in \\mathbb{R}^{(2 k+1) \\times(2 k+1)}\n$$\nwhere $k$ is often taken as small integers.\n\nHere a more compact notation for multi-channel convolution can be written as\n$$\n\\theta(f)=K * f+\\mathbf{b}\n$$\nwhere\n$$\nf=\\left(\\begin{array}{c}\n{[f]_{1}} \\\\\n{[f]_{2}} \\\\\n\\vdots \\\\\n{[f]_{c}}\n\\end{array}\\right), \\quad K=\\left(\\begin{array}{cccc}\nK_{1,1} & K_{1,2} & \\cdots & K_{1, c} \\\\\nK_{2,1} & K_{2,2} & \\cdots & K_{2, c} \\\\\n\\vdots & \\vdots & \\ddots & \\vdots \\\\\nK_{h, 1} & K_{h, 2} & \\cdots & K_{h, c}\n\\end{array}\\right), \\quad \\mathbf{b}=\\left(\\begin{array}{c}\nb_{1} \\mathbf{1} \\\\\nb_{2} \\mathbf{1} \\\\\n\\vdots \\\\\nb_{h} \\mathbf{1}\n\\end{array}\\right)=b \\otimes 1\n$$\nFurthermore, we have the following natural extension of convolution with stride for multi-channel by\n$$\n[\\theta(f)]_{s}=\\sum_{t=1}^{c} K_{s, t} *_{2}[f]_{t}+b_{s} 1 \\in \\mathbb{R}^{\\tilde{m} \\times \\tilde{n}}, \\quad s=1: h,\n$$\nwhere\n$$\n\\tilde{m}=\\left\\lfloor\\frac{m+1}{2}\\right\\rfloor, \\quad \\tilde{n}=\\left\\lfloor\\frac{n+1}{2}\\right\\rfloor\n$$\n\n\\subsubsection{Pooling operation in CNNs}\nFinally, we introduce another type of important operation in CNNs - pooling. The key purpose for pooling operator is to reduce the spatial resolution of images (features) in a typical CNN models. Basically, pooling is an operator\n$$\nT: \\mathbb{R}^{c_{1} \\times m_{1} \\times n_{1}} \\mapsto \\mathbb{R}^{c_{2} \\times m_{2} \\times n_{2}} .\n$$\nwhere\n$$\nm_{2}=\\left\\lfloor\\frac{m+1}{s}\\right\\rfloor, \\quad n_{2}=\\left\\lfloor\\frac{n+1}{s}\\right\\rfloor\n$$\nfor any choice of $c_{2} \\geq 1$. Here $s$ is also called the stride in pooling operations. There are generally two types of pooling\n\n\\section{Convolution with stride s as pooling}\nIn this case, it often happens that\n$$\nT=R *_{s}, \\quad(s=2 \\text { for the main case }) .\n$$\nHere $R$ can be learned or fixed such as average pooling as we discussed before.\n\n\\section{Nonlinear pooling}\nThe most commonly used nonlinear pooling is called max-pooling, a max pooling with kernel size $(2 k+1) \\times(2 k+1)$ and stride $s$ is is defined as\n$$\n\\left[R_{\\max }(f)\\right]_{t ; i, j}=\\max \\left\\{f_{t ; s i+p-1, s j+q-1} \\mid-k \\leq p, q \\leq k\\right\\}\n$$\nhere $t$ means channel and $c_{2}=c_{1}$ in this case.\n\nHere is an example for max-pooling with kernel size $2 \\times 2$ and stride 2 .\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-07}\n\n\\subsection{Examples of convolution filters and performance}\nIn this section, we will give a brief description how convolution operations are used for image processing. One useful description can be found in the following link:\n\n\\href{http://aishack.in/tutorials/image-convolution-examples/}{http://aishack.in/tutorials/image-convolution-examples/}\n\nConvolutions is a technique for general signal processing. People studying electrical/electronics will tell you the near infinite sleepless nights these convolutions have given them. Entire books have been written on this topic. And the questions and theorems that need to be proved are [insurmountable]. But for computer vision, we'll just deal with some simple things.\n\nA convolution lets you do many things, like calculate derivatives, detect edges, apply blurs, etc. A very wide variety of things. And all of this is done with a \"convolution kernel\"\n\n\\subsubsection{Calculation with convolutions}\nThe most direct way to compute a convolution would be to use multiple for loops. But that causes a lot of repeated calculations. And as the size of the image and kernel increases, the time to compute the convolution increases too (quite drastically).\n\nTechniques haves been developed to calculate convolutions rapidly. One such technique is using the Discrete Fourier Transform. It converts the entire convolution operation into a simple multiplication. Fortunately, you don't need to know the math to do this in OpenCV. It automatically decides whether to do it in frequency domain (after the DFT) or not.\n\n\\subsubsection{Image convolution examples}\nA convolution is very useful for signal processing in general. There is a lot of complex mathematical theory available for convolutions. For digital image processing, you don't have to understand all of that. You can use a simple matrix as an image convolution kernel and do some interesting things!\n\n\\subsubsection{Line detection by 1D Laplacian}\nWith image convolutions, you can easily detect lines. Here are four convolutions to detect horizontal, vertical and lines at 45 degrees:\n\nHere's $0,90,45,135$ lines detection that I got on an image:\n$$\n\\begin{array}{|c|c|c|}\n\\hline-1 & -1 & -1 \\\\\n\\hline 2 & 2 & 2 \\\\\n\\hline-1 & -1 & -1 \\\\\n\\hline\n\\end{array}\n$$\n$$\n\\begin{array}{|c|c|c|}\n\\hline-1 & 2 & -1 \\\\\n\\hline-1 & 2 & -1 \\\\\n\\hline-1 & 2 & -1 \\\\\n\\hline\n\\end{array}\n$$\n$$\n\\begin{array}{|c|c|c|}\n\\hline-1 & -1 & 2 \\\\\n\\hline-1 & 2 & -1 \\\\\n\\hline 2 & -1 & -1 \\\\\n\\hline\n\\end{array}\n$$\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-09}\n\n(a) image\n$$\n\\left(\\begin{array}{ccc}\n-1 & -1 & -1 \\\\\n2 & 2 & 2 \\\\\n-1 & -1 & -1\n\\end{array}\\right)\n$$\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-09(1)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-09(2)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-09(3)}\n\n(e) result\n\nFig. 1.2. A horizontal line detection done with convolutions\n\nIn Lena, the black background is the original result, the white background is obtained by subtracting the original result from 255, the same below.\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(1)}\n\n(d) image $\\left(\\begin{array}{lll}-1 & 2 & -1 \\\\ -1 & 2 & -1 \\\\ -1 & 2 & -1\\end{array}\\right)$\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(2)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(3)}\n\n(e) result\n\nFig. 1.3. A vertical line detection done with convolutions\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(4)}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(5)}\n\n(b) filter (c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-10(6)}\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11(1)}\n\n(e) result\n\nFig. 1.4. A 45 degress line detection done with convolutions\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11(2)}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11(3)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11(4)}\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-11(5)}\n\n(c) result\n\nFig. 1.5. A 135 degress line detection done with convolutions\n\n\\subsubsection{Edge detection by 2D Laplacian operator}\nThe laplacian is the second derivative of the image. It is extremely sensitive to noise, so it isn't used as much as other operators. Unless, of course you have specific requirements.\n\n\\begin{tabular}{|c|c|c|}\n\\hline\n0 & $-1$ & 0 \\\\\n\\hline\n$-1$ & 4 & $-1$ \\\\\n\\hline\n0 & $-1$ & 0 \\\\\n\\hline\n\\end{tabular}\n\n\\begin{tabular}{|c|c|c|}\n\\hline\n$-1$ & $-1$ & $-1$ \\\\\n\\hline\n$-1$ & 8 & $-1$ \\\\\n\\hline\n$-1$ & $-1$ & $-1$ \\\\\n\\hline\n\\end{tabular}\n\nThe laplacian operator\n\n(include diagonals)\n\nHere's the result with the convolution kernel without diagonals:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-12}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-12(1)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-12(2)}\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-12(3)}\n\n(c) result\n\nFig. 1.6. A laplace operator done with convolutions\n\nThe result with the convolution kernel with diagonals:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-13}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-13(1)}\n\n(d) image\n$$\n\\left(\\begin{array}{ccc}\n-1 & -1 & -1 \\\\\n-1 & 8 & -1 \\\\\n-1 & -1 & -1\n\\end{array}\\right)\n$$\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-13(2)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-13(3)}\n\n(e) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-13(4)}\n\nFig. 1.7. A laplace operator include diagonals done with convolutions\n\n\\subsubsection{The Laplacian of Gaussian}\nThe laplacian alone has the disadvantage of being extremely sensitive to noise. So, smoothing the image before a laplacian improves the results we get. This is done with a $5 \\times 5$ image convolution kernel.\n\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n0 & 0 & $-1$ & 0 & 0 \\\\\n\\hline\n0 & $-1$ & $-2$ & $-1$ & 0 \\\\\n\\hline\n$-1$ & $-2$ & 16 & $-2$ & $-1$ \\\\\n\\hline\n0 & $-1$ & $-2$ & $-1$ & 0 \\\\\n\\hline\n0 & 0 & $-1$ & 0 & 0 \\\\\n\\hline\n\\end{tabular}\n\nThe result on applying this image convolution was:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-14}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-14(1)}\n\n(d) image\\\\\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-14(2)}\n\n(b) filter\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-14(3)}\\\\\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-14(4)}\n\nFig. 1.8. A Laplacian of Gaussian operator done with convolutions\n\n\\subsubsection{Other examples with ReLU activation}\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15}\n$$\n\\left(\\begin{array}{ccccc}\n0 & 0 & -1 & 0 & 0 \\\\\n0 & -1 & -2 & -1 & 0 \\\\\n-1 & -2 & 16 & -2 & -1 \\\\\n0 & -1 & -2 & -1 & 0 \\\\\n0 & 0 & -1 & 0 & 0\n\\end{array}\\right)\n$$\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(1)}\n\n(c) convolution result\n\n(a) input image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(2)}\n\n(d) result after ReLU $\\left(\\begin{array}{lll}\\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9} \\\\ \\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9} \\\\ \\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9}\\end{array}\\right)$\n\n(e) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(3)}\n\n(f) result after average\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(4)}\n\n(g) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(5)}\n\n(j) ReLU\n$$\n\\left(\\begin{array}{ccccc}\n0 & 0 & -1 & 0 & 0 \\\\\n0 & -1 & -2 & -1 & 0 \\\\\n-1 & -2 & 16 & -2 & -1 \\\\\n0 & -1 & -2 & -1 & 0 \\\\\n0 & 0 & -1 & 0 & 0\n\\end{array}\\right)\n$$\n(h) filter\n\n$\\left(\\begin{array}{lll}\\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9} \\\\ \\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9} \\\\ \\frac{1}{9} & \\frac{1}{9} & \\frac{1}{9}\\end{array}\\right)$\n\n(k) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-15(6)}\n\n(1) average\n\n\\subsubsection{Some other examples}\n\\section{Edge detection}\nThe above kernels are in a way edge detectors. Only thing is that they have separate components for horizontal and vertical lines. A way to \"combine\" the results is to merge the convolution kernels. The new image convolution kernel looks like this:\n\n\\begin{tabular}{|r|l|l|}\n\\hline\n$-1$ & $-1$ & $-1$ \\\\\n\\hline\n$-1$ & 8 & $-1$ \\\\\n\\hline\n$-1$ & $-1$ & $-1$ \\\\\n\\hline\n\\end{tabular}\n\nBelow result I got with edge detection:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-16}\n\n(m) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-16(1)}\n\n(p) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-16(2)}\n\n(n) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-16(3)}\n\n(o) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-16(4)}\n\n(q) result\n\nFig. 1.9. A edge detection done with convolutions\n\n\\section{The Sobel Edge Operator}\nThe above operators are very prone to noise. The Sobel edge operators have a smoothing effect, so they're less affected to noise. Again, there's a horizontal component and a vertical component.\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17}\n\n\\begin{tabular}{|c|c|c|}\n\\hline\n$-1$ & $-2$ & $-1$ &  &  \\\\\n\\hline\n0 & 0 & 0 &  &  \\\\\n\\hline\n1 & 2 & 1 &  &  \\\\\n\\hline\n\\multicolumn{2}{|c|}{Horizontal} & $-1$ & 0 & 1 \\\\\n\\hline\n$-2$ & 0 & 2 &  &  \\\\\n\\hline\n$-1$ & 0 & 1 &  &  \\\\\n\\hline\n\\end{tabular}\n\nOn applying horizontal component in image, the result was:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17(1)}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17(2)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17(3)}\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17(4)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-17(5)}\n\n(e) result\n\nFig. 1.10. A horizontal sobel edge operator done with convolutions\n\nOn applying vertical component in image, the result was:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-18}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-18(1)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-18(2)}\n$$\n\\left(\\begin{array}{lll}\n-1 & 0 & 1 \\\\\n-2 & 0 & 2 \\\\\n-1 & 0 & 1\n\\end{array}\\right)\n$$\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-18(3)}\n\n(c) result\\\\\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-18(4)}\n\n(e) result\n\nFig. 1.11. A vertical sobel edge operator done with convolutions\n\nFig. 1.11. A vertical sobel edge operator done with convolutions\n\n\\section{Simple box blur}\n${ }^{1}$ Here's a first and simplest. This convolution kernel has an averaging effect. So you end up with a slight blur. The image convolution kernel is:\n$$\n\\begin{array}{|l|l|l|}\n\\hline 1 / 9 & 1 / 9 & 1 / 9 \\\\\n\\hline 1 / 9 & 1 / 9 & 1 / 9 \\\\\n\\hline 1 / 9 & 1 / 9 & 1 / 9 \\\\\n\\hline\n\\end{array}\n$$\nNote that the sum of all elements of this matrix is $1.0$. This is important. If the sum is not exactly one, the resultant image will be brighter or darker.\n\nHere's a blur that I got on an image:\n\n$\\overline{{ }^{1} \\text { The following examples are from the website, http://aishack.in/tutorials/image- }}$ convolution-examples/\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19(1)}\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19(2)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19(3)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19(4)}\n\n(e) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-19(5)}\n\n(f) result\n\nFig. 1.12. A simple blur done with convolutions\n\n\\section{Gaussian blur}\nGaussian blur has certain mathematical properties that makes it important for computer vision. And you can approximate it with an image convolution. The image convolution kernel for a Gaussian blur is:\n\n\\begin{tabular}{|l|l|l|l|l|l|l|}\n\\hline\n0 & 0 & 0 & 5 & 0 & 0 & 0 \\\\\n\\hline\n0 & 5 & 18 & 32 & 18 & 5 & 0 \\\\\n\\hline\n0 & 18 & 64 & 100 & 64 & 18 & 0 \\\\\n\\hline\n5 & 32 & 100 & 100 & 100 & 32 & 5 \\\\\n\\hline\n0 & 18 & 64 & 100 & 64 & 18 & 0 \\\\\n\\hline\n0 & 5 & 18 & 32 & 18 & 5 & 0 \\\\\n\\hline\n0 & 0 & 0 & 5 & 0 & 0 & 0 \\\\\n\\hline\n\\end{tabular}\n\nHere's a result that I got:\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20}\n\n(a) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20(1)}\n\n(d) image\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20(2)}\n\n(b) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20(3)}\n\n(e) filter\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20(4)}\n\n(c) result\n\n\\includegraphics[max width=\\textwidth]{2022_01_06_b5ce182ed1bd5f482e5bg-20(5)}\n\n(f) result\n\nFig. 1.13. A Gaussian blur done with convolutions\n\n\\subsubsection{Summary}\nYou got to know about some important operations that can be approximated using an image convolution. You learned the exact convolution kernels used and also saw an example of how each operator modifies an image. I hope this helped!\n\n\\section{References}\n[1] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A largescale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248-255. Ieee, 2009.\n\n[2] J. He, Y. Chen, and J. Xu. Constrained linear data-feature mapping for image classification. arXiv preprint arXiv: $1911.10428,2019 .$\n\n[3] $\\mathrm{K}$. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 770-778, 2016 .\n\n[4] K. He, X. Zhang, S. Ren, and J. Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision, pages 630-645. Springer, $2016 .$\n\n[5] A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, $2009 .$\n\n[6] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pages $1097-1105,2012$.\n\n[7] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, $86(11): 2278-2324,1998 .$\n\n[8] K. Simonyan and A. Zisserman. Very deep convolutional networks for largescale image recognition. arXiv preprint arXiv: $1409.1556,2014 .$\n\n[9] J. Xu and L. Zikatanov. Algebraic multigrid methods. Acta Numerica, 26:591$721,2017 .$\n\n\n\\end{document}", "meta": {"hexsha": "cdcc83b28085b3781b0123213cf38207b27ed2ab", "size": 25673, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Module4/m4_02/d02convolutionoperation_video_notes.tex", "max_stars_repo_name": "liuzhengqi1996/math452_Spring2022", "max_stars_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Module4/m4_02/d02convolutionoperation_video_notes.tex", "max_issues_repo_name": "liuzhengqi1996/math452_Spring2022", "max_issues_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Module4/m4_02/d02convolutionoperation_video_notes.tex", "max_forks_repo_name": "liuzhengqi1996/math452_Spring2022", "max_forks_repo_head_hexsha": "b01d1d9bee4778b3069e314c775a54f16dd44053", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.169250646, "max_line_length": 428, "alphanum_fraction": 0.704475519, "num_tokens": 9352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.42565304915690655}}
{"text": "% To compile single chapters put a % symbol in front of \"\\comment\" and \"}%end of comment\" below \n%    and take off the % symbol from \"\\end{document\" at the bottom line. Undo before compiling\n%    the complete thesis\n%%Note: You can only use \\section command, you are not allowed, per TTU Graduate School, use\n%%\\subsection command for ghigher level subheadings. At most level 2 subheadings are allowed.\n\n\\chapter{DASP Feature Classification and Results}\n\\label{DASP Device Classification Chapter}\n\n\\section[Learning Overview]{Learning Overview}\n\nThe DASP algorithms described in Chapter \\ref{DASP Algorithm Development Chapter} were specifically developed to align, cluster, or otherwise group URE signal features in a 2-D image structure, with a goal of providing a method for the detection, characterization, and classification of devices based upon their conducted URE.  To ascertain the performance of the DASP algorithms, conducted URE was first collected from a variety of electronic devices, as outlined in Chapter \\ref{URE Data Collection Chapter}, to provide a suitable data set for evaluation.  In Chapter \\ref{DASP Feature Extraction Chapter} a suite of algorithms was developed to scale and highlight features of interest within DASP images and, in addition, a method for extracting statistical features was also presented.  A processing flow for feature generation was defined in Chapter \\ref{Simulation and Testing Configuration} to enable 1-D feature vector evaluation through LDA and k-NN machine learners.  Finally, all DASP images were scaled and stored as TIFF image files to enable image classification through MATLAB\\textsuperscript \\textregistered 's CNN deep learning framework.\n\nBefore evaluation of the classification performance of the DASP derived features, an initial unsupervised clustering analysis was performed on the statistical based features in Section \\ref{Device Clustering Analysis} to determine if the features were separable and to better understand and visualize the data.  The DASP algorithms were evaluated for their performance in a one-versus-all classification configuration using LDA and k-NN with statistical-based features and CNN with the stored TIFF images in Section \\ref{Single Device Classification}.  Section \\ref{Multiple Device Classification} provides an evaluation of the DASP transforms and associated learning algorithms applied to an all-versus-all classification configuration where multiple URE signals were present in the same capture.  Finally, Section \\ref{Clutter Analysis} presents analysis of a trained CNN's ability to detect URE clutter and associate unknown devices with known devices based upon their URE signatures. \n\n\\section[Statistical Feature Clustering Analysis]{Statistical Feature Clustering Analysis}\n\\label{Device Clustering Analysis}\n\nAn initial clustering analysis was performed on the statistical based feature vectors to confirm the separability of device classes.  The feature vector for each sample was formed by concatenating features from all image segments (including the whole image) of all DASP transforms.  In the process of forming the feature vectors it was found that the MASP-Low Scatter, MASP-Low Edge Array, MASP-Low Radon Array, and MASP-High Scatter based statistical feature vectors contained invalid values.  Upon further examination, the scaling process applied to these DASP transforms resulted in a large number of columns and rows with all zeros and therefore generated undefined statistical values.  After removal of the four ill-formed DASP transform statistical feature vectors, the concatenation of the remaining feature vectors resulted in a combined feature matrix, $\\textit{\\bf{X}}_C$, of $12000$ samples by $1173$ features.  The $12000$ samples were the result of $1200$ samples per device with $9$ devices plus the \\textit{None} class.  The $1173$ features were comprised of $13 \\times 90$ features for the remaining $13$ DASP transforms plus the $3$ SCAP auto-covariance statistical features.\n\nA Principal Component Analysis (PCA) rank reduction was applied to $\\textit{\\bf{X}}_C$ to reduce the feature space down to $3$ features, $\\textit{\\bf{X}}_{C,3}$, to aid in visualization.  Figure \\ref{fig:cluster_truth} provides a 2-D scatter plot of the rank reduced statistical feature matrix with the class values encoded in the scatter colors.  With only $2$ features shown it was evident that at least $4$ classes (\\textit{fluorescentlights}, \\textit{dellmonitor}, \\textit{dellxps}, and \\textit{hpzbook}) were highly separable from the remaining $6$ classes.\n\n\\begin{figure}[tb]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_cluster_truth.eps}\n\t\\centering\n\t\\caption{Scatter plot of the top two statistical features from the PCA reduced feature set.  The point colors represent the ground truth and show a clear separation among several of the classes (\\textit{hpzbook}, \\textit{dellxps}, \\textit{fluorescentlights}, and \\textit{dellmonitor}).}\n\t\\label{fig:cluster_truth}\n\\end{figure}\n\nBecause only $4$ classes showed clear visual class separation through a 2-D projection of $\\textit{\\bf{X}}_{C,3}$, a gap analysis based upon a Gaussian-Mixture Model clustering was performed on the $\\textit{\\bf{X}}_{C,3}$ matrix to confirm the presence of approximately $10$ classes to further validate the data set.  Figure \\ref{fig:cluster_gap} provides a plot of the gap values and corresponding standard deviations for $k = [1,2, \\ldots, 19, 20]$\\footnote{$k$ in the context of unsupervised clustering and k-means defines the number of classes (or clusters), as opposed to $k$ in the context of k-NN which corresponds to the number of nearest neighbors for supervised learning.}. \n\n\\begin{figure}[tb]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_cluster_gap.eps}\n\t\\centering\n\t\\caption{Plot of gap values with standard deviation error bars for the top three PCA reduced feature set, $\\textit{\\bf{X}}_{C,3}$.  The gap analysis shows a dip at $k=8$ with the minimum cluster variances between $k=8$ and $k=10$.}\n\t\\label{fig:cluster_gap}\n\\end{figure}\n\nFigure \\ref{fig:cluster_gap} shows a dip in gap values at $k=8$ along with a corresponding drop in the standard deviation.  The minimum standard deviation occurs at $k=9$, with the second lowest standard deviation at $k=10$, which confirms the presence of approximately $8$ to $10$ classes.  Given that $k$ was known to be $10$, the gap assessment provided a good indicator that the statistical features were separable across all $10$ classes.  \n\nA k-means clustering of the $\\textit{\\bf{X}}_{C,3}$ matrix with $k=10$ was then performed to further validate the results observed in the gap analysis, with the results shown in Figure \\ref{fig:cluster_kmeans}.  The ``x'' marks show the k-means cluster centers, while the cluster colors are based upon a majority vote of known devices assigned to a particular cluster.  The k-means clustering did show many correct cluster assignments, however the \\textit{hpzbook} cluster was incorrectly split in to two classes and the \\textit{linksysrouter} class did not comprise the majority of any assigned cluster.\n\n\\begin{figure}[tb]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_cluster_kmeans.eps}\n\t\\centering\n\t\\caption{2-D scatter plot of a k-means clustering of top two statistical features from a PCA reduced feature set, with the ``x'' marks designating the k-means cluster centers.  The color coding and class assignments were based upon a majority vote of the known classes for a particular k-means cluster.  The k-means algorithm was not able to separate the \\textit{linksysrouter} class from the overlapping clusters and incorrectly separated the \\textit{hpzbook} class in to two separate clusters.}\n\t\\label{fig:cluster_kmeans}\n\\end{figure}\n\nGiven the two distinct clusterings associated with the \\textit{hpzbook} class, the k-means algorithm incorrectly separated the \\textit{hpzbook} class and was therefore not able to generate a separate cluster with a majority of \\textit{linksysrouter} devices.  The unsupervised clustering analysis showed that with only $3$ features the devices were mostly separable and indicated that a larger feature space may be required to correctly identify devices using supervised learning techniques.\n\n\\section[One-Versus-All Device Classification]{One-Versus-All Device Classification}\n\\label{Single Device Classification}\n\nThe DASP algorithms were first evaluated on their respective abilities to generate features relevant for one-versus-all classification.  Single device classification was performed based on the assumption that only one of the $10$ devices (or classes) was represented within a given sample.  One-versus-all classification was performed with LDA and k-NN learners on the statistical features as described in Section \\ref{Statistical Features Single Device Classification}, whereas CNN learners were trained and tested against DASP images in a one-versus-all configuration as shown in Section \\ref{Convolutional Neural Network Single Device Classification}.\n\n\\subsection[Statistical Feature Analysis]{Statistical Feature Analysis}\n\\label{Statistical Features Single Device Classification}\n\nBefore ascertaining the performance of the DASP-derived statistical features, several machine learning algorithms were evaluated based upon the following criteria:\n\n\\begin{itemize}\n  \\item Ability to provide one-versus-all multi-class classification results.\n  \\item Minimal or no “tuning” parameters.\n\t\\item No prior knowledge of the class means or covariances.\n\t\\item Robust and repeatable results.\n\t\\item No requirement for an overly complex or optimum classifier.\n\t\\item Retain some tie to the physical understanding of the underlying feature space.\n\t\\item No requirement to handle class skew.\n\\end{itemize}\n\\label{list:ml_eval}\n\nSeveral learning methods were explored for their applicability in evaluating the DASP statistical features, to include LDA, QDA, k-NN, Perceptrons, AdaBoost, and neural networks.  Although many of the candidate learning algorithms could have provided nearly optimum results in terms of classification, an optimized learner was not necessarily required for evaluation of the DASP-derived features.  Given the self-imposed requirements for the machine learning algorithm, neural networks and AdaBoost were eliminated based upon their high level of abstraction between the feature space and the learner, tuning parameter sensitivity, and repeatability \\cite{Friedman2001}. \n\nThe remaining algorithms, LDA, QDA, k-NN, and Perceptrons were further evaluated with LDA and k-NN eventually being utilized. Perceptrons may not converge or can take a long time to converge if the classes are not linearly separable and, in addition, the decision plane may change given different starting conditions \\cite{Friedman2001}. LDA and QDA are closely related and differ only in the underlying assumption in the equality of class covariances with both providing similar classification performance.  LDA was eventually chosen for its simplicity, repeatability, and direct physical tie to the feature space where it attempts to maximize the distance between the class means and minimize the within-class variance \\cite{Friedman2001}.  Certain assumptions were made about the underlying feature space for LDA to be a valid choice for classification.  LDA assumes that the feature means and variances are Gaussian distributed and each class shares the same covariance.  Furthermore, the utilization of LDA assumes that the classes are linearly separable. \n\nTo balance the closed-form statistical-based solutions provided by LDA, k-NN was also used as an secondary learning method because of its non-parametric approach and simplicity.  In addition, k-NN does not make any assumptions about the underlying data such as linear separability and the equality of class covariances.  Although the choice of classifiers would have been re-evaluated had the early classification attempts performed poorly, LDA and k-NN were able to separate DASP generated statistical features at high classification accuracies ($>90\\%$) in early testing and provided a robust and repeatable evaluation method for comparing the various DASP algorithms.\n\nTable \\ref{tab:stat_lda_acc} provides the results of a $4$-fold one-versus-all LDA classifier applied to the statistical-based DASP features for each of the $14$ DASP algorithm and image transform combinations as outlined in Table \\ref{tab:dasp_config_parameters}, excluding the MASP-Low Scatter, MASP-Low Edge Array, MASP-Low Radon Array, and MASP-High Scatter combinations because of their previously noted invalid feature vectors.  Each DASP combination was evaluated using the entire feature set across all segments, $\\textit{\\bf{X}}$, using only the top image segment, $\\textit{\\bf{X}}_1$, and using a rank $3$ PCA reduced feature set.  The ``Combined'' DASP feature set, $\\textit{\\bf{X}}_C$, was formed by concatenating the $\\textit{\\bf{X}}$ feature vectors for all valid DASP algorithm and transform combinations.\n\n\\begin{table}[tb]\n\t\\caption{One-versus-all 4-fold cross validation LDA classification accuracies for the statistically derived features.  All algorithms (except the SCAP-vec feature set) exceeded $95\\%$ accuracy when all segments were used, while the majority still exceeded $82\\%$ when only the top grid was leveraged.  }\n\t\\csvautotabular{./dasp_algorithm_results/dasp_stat_lda_results.txt}\n\t\\centering\n\t\\label{tab:stat_lda_acc}\n\\end{table}\n\nThe results in Table \\ref{tab:stat_lda_acc} show that using all segments, or $90$ features, provided accuracies exceeding $98\\%$ for the majority of DASP combinations.  Using only $9$ features from the top segment provided accuracies on the order of $85\\%$, with HASP-F Radon Array providing the highest accuracy at $94.7\\%$.  The reduced rank feature sets performed worse, on average, than the $\\textit{\\bf{X}}$ and $\\textit{\\bf{X}}_1$ feature sets, however the rank reduced Combined feature set, $\\textit{\\bf{X}}_{C,3}$, was able to obtain an accuracy of $94.6\\%$ with only $3$ features.  It should be noted that the although the combination of all segments and all feature sets, $\\textit{\\bf{X}}_C$, was able to reach an accuracy of $100\\%$, it utilized a feature vector length of $1173$, or greater than $10$ times the number of features in the individual DASP combinations.\n\nTable \\ref{tab:stat_knn_acc} provides the results of a $4$-fold one-versus-all k-NN classifier applied to the statistical-based DASP features for each of the $14$ DASP algorithm and image transform combinations as outlined in Table \\ref{tab:dasp_config_parameters}, excluding the MASP-Low Scatter, MASP-Low Edge Array, MASP-Low Radon Array, and MASP-High Scatter combinations.  The k-NN learner was configured to utilize an inverse-squared Euclidean distance metric with $k=10$ nearest neighbors.  Each DASP combination was evaluated using the entire feature set from all segments, $\\textit{\\bf{X}}$, only the top image segment, $\\textit{\\bf{X}}_1$, and using a rank $3$ PCA reduced feature set.  \n\n\\begin{table}[tb]\n\t\\caption{One-versus-all 4-fold cross validation k-NN classification accuracies for the statistically derived features for all DASP algorithm and image transformations.  All algorithms (except the SCAP-vec feature set) exceeded $95\\%$ accuracy when all grids were used, while the majority were in the $80\\%$ range when only the top grid was leveraged.  Several of the PCA rank reduced feature sets exceeded $90\\%$ with the combined feature set obtaining $96.7\\%$, while the majority were in the $80\\%$ range.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_stat_knn_results.txt}\n\t\\centering\n\t\\label{tab:stat_knn_acc}\n\\end{table}\n\nThe results in Table \\ref{tab:stat_knn_acc} show that using $\\textit{\\bf{X}}$, or $90$ features, provided accuracies exceeding $98\\%$ for the majority of DASP combinations with the HASP-F Array, HASP-D Array, and Combined feature sets reaching $100\\%$.  Using only $9$ features from the top segment, $\\textit{\\bf{X}}_1$, provided accuracies on the order of $95\\%$, with the SCAP Array features providing the highest accuracy at $97.2\\%$.  The reduced rank feature sets performed only slightly worse on average than the $\\textit{\\bf{X}}$ and $\\textit{\\bf{X}}_1$ feature sets, however the rank reduced Combined feature set, $\\textit{\\bf{X}}_{C,3}$, was able to obtain an accuracy of $97.2\\%$, while the HASP-D Array, HASP-F Array, and FASP Array features sets also exceeded $90\\%$ with only $3$ features.  As with the LDA results, it should be noted that although the $\\textit{\\bf{X}}_C$ feature set was able to reach an accuracy of $100\\%$, it utilized a feature vector length of $1173$, or greater the $10$ times the number of features in the individual DASP combinations. \n\nThe k-NN learning algorithm significantly outperformed the LDA learning method, especially with the Top segment and rank reduced feature sets indicating that the assumptions underlying the LDA algorithm, such as linear separability and Gaussian distribution of features, were not valid.  Figure \\ref{fig:stat_cm_cum} provides a cumulative confusion matrix generated by averaging all of the confusion matrices of the LDA and k-NN learners.   \n\n\\begin{figure}[tb]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_AllCombined_conf.eps}\n\t\\centering\n\t\\caption{Cumulative confusion matrix for all of the results in Table \\ref{tab:stat_lda_acc} and Table \\ref{tab:stat_knn_acc}.  Results were obtained by summing the confusion matrices of all LDA and k-NN results and normalizing to percentages.  The table shows that the majority of the classes performed well with no strong confusion between two classes except for the \\textit{viewsonicmonitor} class which was confused with the \\textit{None} class at a rate of $11\\%$.}\n\t\\label{fig:stat_cm_cum}\n\\end{figure}\n\nThe cumulative results show that the largest confusion existed between the \\textit{viewsonicmonitor} and \\textit{None} devices with an $11\\%$ misclassification rate.  The second highest misclassification rate of $6\\%$ occurred between the \\textit{delloptiplex} and \\textit{hplaserjet} devices.  Interestingly, Figure \\ref{fig:cluster_truth} shows significant overlap between the \\textit{viewsonicmonitor} and \\textit{None} classes and the \\textit{delloptiplex} and \\textit{hplaserjet} classes in the 2-D scatter plot of $\\textit{\\bf{X}}_{C,3}$, thus providing results consistent with Figure \\ref{fig:stat_cm_cum}.\n\n\\subsection[DASP Image Analysis]{DASP Image Analysis}\n\\label{Convolutional Neural Network Single Device Classification}\n\nConvolutional Neural Networks are a deep learning framework specifically designed for processing and classifying images and are widely used in the object recognition and computer vision communities.  CNNs have a variety of building blocks with an infinite number of configurations, but the foundational component of a CNN is the convolution (conv) layer.  The convolution layer is comprised of tunable filters that are updated through training to highlight areas, objects, or features within an image.  Convolution layers are typically followed by an activation layer and a pooling (pool) layer that ``scan'' and ``downsample'' the convolution filter outputs.  The pooling layer can ``downsample'' by several different methods, such as maximum pooling or averaging pooling, as it ``scans'' the convolution filter output by a fixed stride length.  The rectifying linear unit (reLU) implements the function $f(x) = \\max(0,x)$ and is typically used as the activation layer.  A fully connected (fc) layer is implemented to connect with all input neurons and provide a scaled output by adding a bias and multiplying by a weighting factor.  The fully connected layer provides the higher level learning by calculating the appropriate convolution and pooling layer input weights for classification.   For instance, a series of convolution, activation, and pooling layers may learn an ``eye'', a ``nose'', and a ``mouth'', but the fully connected layer learns that together these features form a ``face''. \n\nAs opposed to learning on feature vectors, as demonstrated in Section \\ref{Statistical Features Single Device Classification}, a CNN trains and learns directly from the DASP images.  A very basic CNN was developed to perform one-versus-all classification of the DASP images, as described in Figure \\ref{fig:cnn_net_single}.  The network consisted of an initial single-channel image input layer which resized the $500 \\times 500$ pixel TIFF images to $25 \\times 25$ pixels.  The input layer was followed by a convolution layer (\\textit{conv1}) comprised of $20$ filters of size $5 \\times 5$, a reLU layer, a max pooling layer (\\textit{pool1}) with a $2 \\times 2$ downsampling filter and a stride of $2$.  A fully connected layer (\\textit{fc1}) with $10$ output neurons was utilized for the higher level learning.  A softmax classification layer was used to perform the one-versus-all classification.\n\n\\begin{figure}[htbp!]\n\t\\includegraphics[width=0.3\\textwidth,keepaspectratio]{./misc_graphics/dasp_cnn_simple_network.png}\n\t\\centering\n\t\\caption{Diagram of the Convolutional Neural Network used for one versus all device classification of DASP images. The network only utilizes one convolution, max pooling, and fully connected layer, in addition to a $25 \\times 25$ image input layer.}\n\t\\label{fig:cnn_net_single}\n\\end{figure}\n\nThe CNN in Figure \\ref{fig:cnn_net_single} was trained using the parameters in Table \\ref{tab:cnn_simple_train} where the Stochastic Gradient Descent with Momentum (SGDM) is defined by \\footnote{https://www.mathworks.com/help/nnet/ref/trainingoptions.html, June $23$, $2017$}\n\\begin{equation}\n    \\theta_{l+1} = \\theta_{l} - \\alpha \\nabla E \\left(\\theta_{l}\\right) + \\gamma \\left( \\theta_{l} - \\theta_{l-1} \\right)\n\t\t\\label{eq:sgdmeq}\n\\end{equation}\nwhere $l$ is the iteration number, $\\alpha$ is the learning rate, $\\theta$ specifies the updated parameter, and $E(\\theta)$ is the cross entropy loss function\n\\begin{equation}\n    E(\\theta) = \\sum^{n}_{i=1} \\sum^{k}_{j=1} t_{ij} \\ln y_{j} \\left( x_{i},\\theta \\right)\n\t\t\\label{eq:xentropyeq}\n\\end{equation}\n where $t_{ij}$ indicates the $i^{th}$ sample number is a member of the $j^{th}$ class and $y_{j}(x_{i},\\theta)$ is the output for the $i^{th}$ sample.\n\n\\begin{table}[tb]\n\t\\caption{Table of training parameters for the one-versus-all CNN.}\n\t\\centering\n\t\t\\begin{tabular}{c|c}\n\t\t\\hline\n\t\tCNN Training Parameter & Parameter Value\\\\\n\t\t\\hline\n    Test Image Holdback Percentage & $20\\%$ \\\\\n\t\tLearning Rate &  $1\\times10^{-6}$\\\\\n\t\tMini-Batch Size & $150$ \\\\\n\t\tLoss Function & Cross Entropy Function\\\\\n\t\tUpdate Algorithm & Stochastic Gradient Descent with Momentum\\\\\n    \\hline\n\t\t\\end{tabular}\n\t\\label{tab:cnn_simple_train}\n\\end{table}\n\nTable \\ref{tab:cnn_single_results} provides the blind testing results of the trained one-versus-all CNN.  All DASP image and transform combinations provided a greater than $97\\%$ accuracy, with the SCAP Array being the best performer at $99.9\\%$.  The MATLAB\\textsuperscript \\textregistered~CNN architecture does not allow for multiple column convolution streams\\footnote{as of June, $2017$} so combined training on all DASP image combinations could not be implemented, but given the near optimal results from the individual DASP image transforms the combined training and testing was not required for the one-versus-all device classification.  \n\n\\begin{table}[tb]\n\t\\caption{One-versus-all CNN classification results for all DASP algorithm processes.  All processes attained a greater than $97\\%$ classification accuracy, with $10$ achieving accuracies greater than $99\\%$.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_cnn_results.txt}\n\t\\centering\n\t\\label{tab:cnn_single_results}\n\\end{table}\n\nMATLAB\\textsuperscript \\textregistered ~ provides a method for inspecting a trained CNN network through the \\textit{deepDreamImage} \\footnote{https://www.mathworks.com/help/nnet/ref/deepdreamimage.html, July $06$, $2017$} command.  DeepDream image creation was developed by Google\\textsuperscript \\textregistered ~~ \\cite{Mordvintsev2015} to allow researchers to visualize a composite image of layer activations within a trained network to develop understanding and insights into the learned features from a given training set.  Table \\ref{tab:cnn_fc_dream_table} shows the \\textit{deepDreamImage} outputs for the fully connected layers of select trained CNNs.  The DeepDream images looked very similar in structure to the DASP training images illustrated in Chapter \\ref{DASP Algorithm Development Chapter} and Appendix B.  Appendix B provides sample images of all DASP transformations for all test and training devices in Table \\ref{tab:collection_devices}.  The CMASP Edge Array DeepDream image, Figure \\ref{fig:cnnfc2}, is particularly interesting in that a checkerboard pattern was formed to process the large number of intersecting lines and radials that are inherent to CMASP images.\n\n{\\centering\n\\begin{table}[tb]\n\t\\caption{Table of DeepDream images of select fully connected layers from the one-versus-all CNNs trained on DASP images.  The DeepDream images highlight the learned activations associated with the DASP training images.}\n\t\\begin{tabular}{ccc}\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_2.eps}\n\t\t\\caption{CMASP, Edge Array}\\label{fig:cnnfc2}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_3.eps}\n\t\t\\caption{CMASP, Radon Array}\\label{fig:cnnfc3}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_4.eps}\n\t\t\\caption{FASP, Array}\\label{fig:cnnfc4}\n\t\t\\end{subfigure}    \\\\\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_6.eps}\n\t\t\\caption{HASP-F, Edge Array}\\label{fig:cnnfc6}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_7.eps}\n\t\t\\caption{HASP-F, Radon Array}\\label{fig:cnnfc7}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_8.eps}\n\t\t\\caption{HASP-D, Array}\\label{fig:cnnfc8}\n\t\t\\end{subfigure}    \\\\\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_9.eps}\n\t\t\\caption{MASP (Low), Array}\\label{fig:cnnfc9}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_10.eps}\n\t\t\\caption{MASP (Low), Scatter}\\label{fig:cnnfc10}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_11.eps}\n\t\t\\caption{MASP (Low), Edge Array}\\label{fig:cnnfc11}\n\t\t\\end{subfigure}    \\\\\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_13.eps}\n\t\t\\caption{MASP (High), Array}\\label{fig:cnnfc13}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_14.eps}\n\t\t\\caption{MASP (High), Scatter}\\label{fig:cnnfc14}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_single_dream_fc_17.eps}\n\t\t\\caption{SCAP, Array}\\label{fig:cnnfc17}\n\t\t\\end{subfigure}\n\t\\end{tabular}\n\\label{tab:cnn_fc_dream_table}\n\\end{table}\n}\n\n\\section[Multiple Device Classification]{Multiple Device Classification}\n\\label{Multiple Device Classification}\n\nOne-versus-all classification analysis in Section \\ref{Single Device Classification} assumed that one and only one device was present in a given URE capture; however, that is not completely practical in an environment where many devices may be operating at the same time.  The LDA, k-NN, and CNN learners were all designed for one-versus-all classification and therefore were adapted for all-versus-all classification.  There are several methods for accomplishing multi-device detection and classification, 1) train a multi-class classifier for one-versus-all classification and set a threshold for detection, 2) train separate two-class classifiers for each device in a one-versus-none testing configuration, or 3) train a multi-class classifier with multiple labels per sample.  LDA cannot be trained as an all-versus-all multi-class classifier and therefore could not be easily adapted other than to develop a threshold for detection of present devices.  CNNs can be trained with multiple labels per sample given an appropriate network and loss function, however MATLAB\\textsuperscript \\textregistered ~ does not provide this functionality and therefore the CNN's previously trained on single-devices were adapted, similarly to the LDA learner, with a threshold to detect multiple classes.  \\cite{Sorower2010, Zhang2007, Spyromitros2008} demonstrate the feasibility of using k-NN learners for multi-label classification, with the majority of the multi-label k-NN learners being adaptations of one-versus-none learning (Binary Relevance).  Given the threshold based approach of the LDA and CNN learners, the one-versus-all training of the LDA and CNN learners, and the redundancy in analyzing the statistical-based feature sets with k-NN, a multi-label k-NN was not utilized for processing of the multi-device statistical feature vectors. \n\n\\subsection[Multiple Device Test Configuration]{Multiple Device Test Configuration}\n\nMulti-device capture files were generated to test the single device trained LDA and CNN learners for multi-device classification.  The URE collection effort outlined in Chapter \\ref{URE Data Collection Chapter} only collected a single device per capture, therefore single device captures were added in the time domain to form multi-device URE files.  One hundred multi-device captures were generated for each of $2$ through $9$ device combinations.  The multi-device combinations files were generated through a random selection process that excluded the \\textit{None} state and more than one example of a class within a given multi-device file.  The multi-file generation process therefore generated $(9-2) \\times 100 = 700$ multi-device test files.\n\nThe multi-device time domain files were subsequently processed with the DASP algorithms, feature extractors, and TIFF image creation processes outlined in Figure \\ref{fig:dasp_lda_knn_process_flow} and Figure \\ref{fig:dasp_cnn_process_flow}.  The generated multi-device DASP arrays and files were not used for training, but only as test inputs to the LDA and CNN learners trained on single devices.  To illustrate the superposition of multiple devices within a DASP image Figure \\ref{fig:multi_device_image} shows the individual MASP (Low) scatter images for the \\textit{cyberpowerups} and \\textit{fluorescentlights}, as well as the combined MASP (Low) scatter image derived from the URE time domain superpositioning of the two devices.  The combined image shows artifacts of both the \\textit{cyberpowerups} and \\textit{fluorescentlights} device images as highlighted by the oval and circle, respectively.   \n\n\\begin{figure}[htbp!]\n\t\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{./misc_graphics/multiDeivceImages.png}\n\t\\centering\n\t\\caption{MASP (Low) Scatter images for the \\textit{cyberpowerups}, \\textit{fluorescentlights}, and the multi-device combined image.  DASP image features for the \\textit{cyberpowerups} and \\textit{fluorescentlights} devices are shown by the oval and round circles, respectively.}\n\t\\label{fig:multi_device_image}\n\\end{figure}\n\n\\subsection[Statistical Feature Analysis]{Statistical Feature Analysis}\n\\label{Statistical Features Multiple Device Classification}\n\nThe LDA learner trained in a one-versus-all method calculates a ``score'' for each class and selects the class with the greatest score.  To adapt for multi-device classification, the score vector was normalized using their z-score and a threshold of $0.5$ standard deviations was utilized to detect the presence of a specific class.  The results of the multi-device LDA classifier are shown in Table \\ref{tab:stat_lda_multi} for each of the DASP combinations, including the results of the combined feature set.  The accuracy (ACC), true positive rate (TPR), false positive rate (FPR) true negative rate (TNR), false negative rate (FNR), precision (PR), and F-score (FSCORE) are provided. \n\n\\begin{table}[tb]\n\t\\caption{Classification accuracies and statistical measures of the multi-class LDA classifier using statistical based feature sets derived from all DASP algorithm processes.  Given $9$ possible class assignments with the \\textit{None} class removed, the overall accuracies were around $50\\%$.   Although the classifiers had significant False Negative Rates, the majority had Precisions exceeding $75\\%$.  The MASP (High) Array feature set performed best with a precision of $1$, while only providing an accuracy of $50.9\\%$ and a True Positive Rate of $0.2$.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_stat_lda_all_multi_results.txt}\n\t\\centering\n\n\t\\label{tab:stat_lda_multi}\n\\end{table}\n\nThe results in Table \\ref{tab:stat_lda_multi} show poor accuracy for all DASP combinations, however the false positive rates were relatively low which is further reflected in the high precisions, with the MASP (High) Array and Combined feature sets attaining precisions of $1$ and $0.96$, respectively.  Further analysis showed that the learners also had a high rate of false negatives, which taken in combination with the high precisions, means that while the LDA learners often missed the presence of a device they were detected with high confidence.  It should also be noted that the multi-device LDA learner was not trained on the \\textit{None} state.  The assumption was made that the presence of a device was already determined and therefore the multi-device classifier was utilized to determine if a specific known device was present.\n\n\\subsection[DASP Image Analysis]{DASP Image Analysis}\n\\label{Convolutional Neural Network Multiple Device Classification}\n\nThe process of using a CNN learner trained on single devices to test for the presence of multiple device was handled in much the same way as that of the LDA learner in Section \\ref{Statistical Features Multiple Device Classification}.  A score vector was extracted from the CNN network for each test sample and scaled by their z-score.  A threshold of $0.5$ standard deviations was then used to detect the presence of a given device.  To combine the DASP algorithms, the pre-normalized score vectors for each of the DASP algorithms were summed together, normalized, then compared to the detection threshold.  Early testing using the very basic CNN described in Figure \\ref{fig:cnn_net_single}, showed very poor results due to network simplicity and over-training and, therefore, a new CNN was designed to better address multi-device classification and prevent over-training.\n\nFigure \\ref{fig:cnn_net_multi} shows the network topology of the multi-device CNN with reduced over-training susceptibility and improved multi-device classification performance.  The network used a single-channel image input layer that resizes input images to $100 \\times 100$ pixels, as opposed to the $25 \\times 25$ resolution in the single device CNN.  The input was connected to a $20\\%$ dropout layer which was followed by two serially connected sets of convolution, reLU, max-pooling layers.  The dropout layer at the input sets each of its $100 \\times 100$ pixel inputs to zero with a probability of $20\\%$ to limit over-training of the network \\cite{Srivastava2014}.  The two convolution layers, \\textit{conv1} and \\textit{conv2}, were each configured with $10$ filters of sizes $10 \\times 10$ and $5 \\times 5$, respectively. Both of the max-pooling layers utilized a $2 \\times 2$ downsampling filter with a stride of one.  A fully connected layer (\\textit{fc1}) with an output width of $100$ followed the convolution and pooling layers and feeds an additional reLU layer and $50\\%$ dropout layer.  A final fully connected layer (\\textit{fc2}) with an output width of $10$ was then followed by the softmax classification layer.  The dropout layers were added to specifically prevent, or at least limit, over training of the more complex network.  The additional convolution pooling layers were added to allow for processing of more complex shapes and structures within the DASP images, while the additional $100$ wide fully connected layer was included for higher levels of learning and abstraction.\n\n\\begin{figure}[htbp!]\n\t\\includegraphics[width=0.2\\textwidth,keepaspectratio]{./misc_graphics/dasp_cnn_multi_network.png}\n\t\\centering\n\t\\caption{Diagram of the Convolutional Neural Network used for multi-class device classification of DASP images. The input layer compressed input images to $100 \\times 100$pixels, while only utilizing two convolution, max pooling, and fully connected layers along with two dropout layers to limit over training.  A fully connected layer of width $100$ was included to allow for higher level learning.}\n\t\\label{fig:cnn_net_multi}\n\\end{figure}\n\nThe results from the multi-device testing of the trained multi-class CNNs are presented in Table \\ref{tab:cnn_multi_testrmvd}.  The results for all $17$ of the DASP image and transform combinations is shown along with the combined CNN learner results.  Although the CNNs did not provide great accuracies, averaging slightly under $60\\%$, they did outperform the LDA multi-device classifiers and were able to achieve a high average precision of $88\\%$ with the combined results attaining a precision of $97\\%$.  As with the LDA results, the CNN multi-device classifiers had high false negative rates, but reported the presence of devices with high confidence.\n\n\\begin{table}[tb]\n\t\\caption{Classification accuracies and statistical metrics of the CNN multi-class classifiers.  The classification accuracies averaged around $60\\%$, while classification Precisions were on the order of $0.90$. The combined CNN learner obtained an accuracy of $66.7\\%$ and a $0.97$ precision.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_cnn_multi_nonemultirmvd_results.txt}\n\t\\centering\n\t\\label{tab:cnn_multi_testrmvd}\n\\end{table}\n \nTable \\ref{tab:cnn_multi_acc_add_device} provides a listing of CNN multi-device classification results versus the number of devices present within a given test sample.  Initial inspection showed a monotonically decreasing accuracy which was to be expected in that more devices would result in more noise and signal confounders to contribute to misclassification, but for captures with less than $5$ devices accuracies exceeded $79\\%$ with precisions exceeding $83\\%$.  It should be noted that for $9$ devices in a given capture, there can be no false positives or true negatives in that all classes are present.  \n\n\\begin{table}[tb]\n\t\\caption{Classification accuracies and statistical metrics of the CNN multi-class classifiers with respect to the number of devices within the test capture.  The relative accuracies monotonically decreased for each additional device, validating the testing approach.  The precisions monotonically increased ultimately reaching $1$ at $9$ devices, which was expected because all devices are present and any detected device was by definition the correct answer.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_cnn_multi_nonemultirmvd_results_versus_numdevices.txt}\n\t\\centering\n\t\\label{tab:cnn_multi_acc_add_device}\n\\end{table}\n\nIn addition to analyzing the multi-class results based on the number of devices, an analysis was also performed to evaluate the classifier performance based upon the presence of a particular device type within a capture, with the results shown in Table \\ref{tab:cnn_multi_acc_devtype}.  Several devices, \\textit{dellxps}, \\textit{fluorescentlights}, \\textit{dellmonitor}, and \\textit{hpzbook}, were more easily detected and therefore their presence and absence within a particular capture was determined with accuracies exceeding $80\\%$, whereas the remaining devices had an average accuracy of $45\\%$.  The precisions for all devices exceeded $90\\%$, except for the \\textit{viewsonicmonitor} which only had a precision of $62\\%$.  The poor performance of the \\textit{viewsonicmonitor} class was particularly noted in that it also showed significant confusion with the \\textit{None} class in the cumulative confusion matrix in Figure \\ref{fig:stat_cm_cum}.  \n\n\\begin{table}[tb]\n\t\\caption{Classification performance of the CNN multi-class classifiers versus the presence of a given device type.  As shown, the \\textit{fluorescentlights}, \\textit{dellxps}, and \\textit{hpzbook} specifically performed well with classification accuracies exceeding $98\\%$ and precisions exceeding $0.97$.  The \\textit{viewsonicmonitor} class was the least identifiable class with an accuracy of $39.8\\%$ and a precision of $0.62$.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_cnn_multi_nonemultirmvd_results_versus_devicetype.txt}\n\t\\centering\n\t\\label{tab:cnn_multi_acc_devtype}\n\\end{table}\n\nFigure \\ref{fig:cnnmultinonermvdroc} provides a Receiver Operation Characteristic (ROC) curve, along with the detection threshold utilized for the results in Tables \\ref{tab:cnn_multi_testrmvd}, \\ref{tab:cnn_multi_acc_add_device}, and \\ref{tab:cnn_multi_acc_devtype}, for the combined multi-device CNN classifier.  The classifier was near perfect for the \\textit{dellxps}, \\textit{fluorescentlights}, and \\textit{hpzbook} classes, with the next best classifier being for the \\textit{dellmonitor}.  The remainder of the classifiers did not perform well with higher thresholds, which was confirmed by the high false negative rates observed in Table \\ref{tab:cnn_multi_testrmvd} and Table \\ref{tab:cnn_multi_acc_devtype}.  The \\textit{viewsonicmonitor} classifier performed the worse and actually dips below the random guess boundary for higher thresholds as does the \\textit{delloptiplex}.  A curve below the random guess line indicate that an increase in the threshold would result in a higher rate of false positives.  Because the ROC curves were generated for a multi-class classifier, a potential confounding feature from a different class may initiate a false positive output.  The detection threshold location indicated that a higher precision was attainable for the \\textit{viewsonicmonitor} class with a lower threshold, however the false negative rates of several of the other device classes would have increased significantly.\n\n\\begin{figure}[htbp!]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonemultirmvd_roc.eps}\n\t\\centering\n\t\\caption{Receiver Operation Characteristic curves for each class of the multi-class CNN classifiers.   As shown, two classes (\\textit{viewsonicmonitor} and \\textit{delloptiplex}) did not perform well with increasing thresholds and therefore seemed to be dominated by other class features at higher thresholds.  It was also shown that the \\textit{hpzbook}, \\textit{dellxps}, and \\textit{fluorescentlights} obtained nearly perfect ROC curves with the multi-class CNN classifiers.}\n\t\\label{fig:cnnmultinonermvdroc}\n\\end{figure}\n\nDeepDream images were generated for the MASP (Low) Scatter plot trained multi-class CNN learner, Table \\ref{tab:cnn_net_layers_masplscatter}, to provide a visual inspection of the composite layer activations for the more complex multi-class CNN.  DeepDream images were provided for both of the convolution layers, \\textit{conv1} and \\textit{conv2}, and the wider fully connected layer, \\textit{fc1}.  The convolution layers performed lower level learning to determine the optimal filters for extracting features of interest from the DASP images, while the fully connected layer learned how to group these learned image features to identify specific devices.  As with the DeepDream images in Table \\ref{tab:cnn_fc_dream_table}, each layer closely resembled the underlying structure of the input MASP (Low) images as presented in Section \\ref{Modulation Aligned Signal Projection}.\n\n{\\centering\n\\begin{table}[tb]\n\t\\caption{DeepDream images of the convolution layers and the first fully connected layer for the MASP (Low) Scatter plot multi-class CNN classifier.}\n\t\\begin{tabular}{cc}\n\t\t\\begin{subfigure}{0.5\\textwidth}\\centering\\includegraphics[width=0.9\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_layers_3.eps}\n\t\t\\caption{Convolution Layer \\#1 (conv1)}\\label{fig:cnnlayerconv1}\n\t\t\\end{subfigure}&\n\t\t\\begin{subfigure}{0.5\\textwidth}\\centering\\includegraphics[width=0.9\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_layers_6.eps}\n\t\t\\caption{Convolution Layer \\#2 (conv2)}\\label{fig:cnnlayersconv2}\n\t\t\\end{subfigure} \\\\\n\t\t\\multicolumn{2}{c}{\\begin{subfigure}{0.5\\textwidth}\\centering\\includegraphics[width=0.9\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_layers_9.eps}\n\t\t\\caption{Fully Connected Layer \\#1 (fc1)}\\label{fig:cnnlayerfc1}\n\t\t\\end{subfigure}}\\\\\n\t\\end{tabular}\n\\label{tab:cnn_net_layers_masplscatter}\n\\end{table}\n}\n\n\\section[Clutter Analysis]{Clutter Analysis}\n\\label{Clutter Analysis}\n\nIn addition to one-versus-all and all-versus-all multi-device classification, it was useful to understand the classifier response to URE clutter, or rather a device that had not been trained upon.  Clutter analysis was performed to 1) determine the ability of the classifier to ignore or otherwise not generate false positives when clutter is present and 2) develop a similarity measurement between a clutter input and known devices.  URE signal captures were performed on the clutter devices listed in Table \\ref{tab:collection_devices} and processed with the same parameters and test conditions applied to the test device captures as described in Chapter \\ref{Simulation and Testing Configuration}.  Analysis of the clutter URE DASP images was performed using the multi-class CNN as described in Section \\ref{Convolutional Neural Network Multiple Device Classification}.  \n\nThe multi-class CNN classifier was presented with single clutter device DASP images and evaluated for the number of times the unknown device was misclassified as a previously observed device.  Table \\ref{tab:cnn_clutter_percentage} provides the correct clutter assignment percentages for each of the DASP combinations.  A correct clutter assignment was defined as the clutter device not being classified as a known device.  Several of the DASP trained CNNs (FASP Array, HASP-D Array, MASP (Low) Array, and MASP (High) Array, performed very poorly and frequently misclassified a clutter device as a known device; however, the combination of DASP CNN classifiers was able to correctly identify clutter, or rather not identify as a known device, $80.9\\%$ of the time.  The combined CNN testing was performed using a voting scheme between all of the trained CNNs and setting a fixed threshold for detection.   \n\n\\begin{table}[tb]\n\t\\caption{Percentage of DASP clutter testing images that were correctly identified as \\textit{clutter} for all DASP algorithm processes.   Although all of the algorithms performed poorly with only one providing a correct clutter identification over $50\\%$ (MASP (Low) - Scatter), the combined vote across all algorithms provided an $80\\%$ correct clutter assignment percentage.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_cnn_clutter_percentage.txt}\n\t\\centering\n\t\\label{tab:cnn_clutter_percentage}\n\\end{table}\n\nThe results in Table \\ref{tab:cnn_clutter_percentage} show that clutter devices presented to the trained CNNs resulted in a significant number of false positives.  To better understand the classes to which the clutter devices were incorrectly assigned and to understand the similarity between clutter devices and known devices, a confusion matrix was generated in Figure \\ref{fig:cnn_clutter_percent} that outlines the percentage of ``likeness'' a clutter device was to a known device.   The ``likeness'' was determined by the cumulative score of each clutter device for each known class across all DASP combinations.  Each row provides the percentage that a given clutter device is similar to a known device, with each row summing to a full $100\\%$. \n\n\\begin{figure}[tb]\n\t\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_cnn_clutter_device_percentage.eps}\n\t\\centering\n\t\\caption{Confusion matrix showing the percentage similarity of each clutter device to previously trained devices.  Most devices have their strongest correlation with the \\textit{viewsonicmonitor} on the order of $30\\%$, with the \\textit{linksysrouter} being the second most similar device on average.}\n\t\\label{fig:cnn_clutter_percent}\n\\end{figure}\n\nAs with the previous results in Figure \\ref{fig:stat_cm_cum} and Table \\ref{tab:cnn_multi_acc_devtype}, the \\textit{viewsonicmonitor} continued to confound several of the classifiers.  All of the clutter devices showed a strong and maximum resemblance to the \\textit{viewsonicmonitor} device.   Given that the \\textit{viewsonicmonitor} was most often confused with the \\textit{None} class, as demonstrated in Figure \\ref{fig:cluster_truth} and Figure \\ref{fig:stat_cm_cum}, it was hypothesized that the similarity of the clutter devices to the \\textit{None} class caused the strong response to the \\textit{viewsonicmonitor} class.   Because all devices were collected with the same process and in the same environment, they all share certain vestiges of the underlying ``off'' state which possibly resulted in the high rate of \\textit{viewsonicmonitor} misclassifications.\n\n\\section[Results Analysis]{Results Analysis}\n\\label{Results Analysis}\n\nIn Section \\ref{Single Device Classification} the performance of features derived from the DASP algorithms was evaluated in a one-versus-all learner configuration.  Three different learners, LDA, k-NN, and CNN, were used to train and learn on statistical based features and DASP images.  Evaluation of the statistical based features with LDA and k-NN demonstrated the viability of DASP based features for device URE classification.  The performance of the k-NN learner far exceeded that of the LDA learner with respective average accuracies of $91.5\\%$ versus $84.1\\%$.  This was most likely due the fact that the features were not linearly separable and therefore assumptions underlying the application of LDA were not valid.  Even with the poor average performance of LDA, the PCA reduced feature set was still able to achieve an accuracy of $94\\%$ with only $3$ features, whereas the k-NN learner was able to attain $97.2\\%$.  The k-NN learner was able to achieve $98\\%$ accuracy for $7$ of the DASP algorithms with only $90$ features and $10$ DASP transforms exceeded $98\\%$ with only $9$ features.  Even with the success of the k-NN learner applied to the statistical feature sets, the CNN learner applied to the DASP images was able to achieve an average accuracy of $99\\%$ with the simplest of CNN network topologies and an input image resolution of only $25 \\times 25$ pixels.\n\nSection \\ref{Multiple Device Classification} explored the separability of the DASP generated features when multiple devices were present within the same test sample.  The LDA learner was utilized with a score threshold methodology to evaluate the presence or absence of a particular device within a test capture.  Evaluation of the DASP statistical features with multi-device samples did not achieve accuracies much greater than $50\\%$, but was able to obtain an average precision of $80\\%$.  The CNN was also tested against multi-device captures and the simple CNN used for single device classification was found to perform poorly during early testing.  A new CNN topology was developed to better handle multiple classes and limit over-training.  The new multi-device CNN also did not achieve accuracies much above $50\\%$ and only had an average precision of $82\\%$, but was able to achieve a precision of $97\\%$ when all CNN learners were used in combination.  Determining the classification accuracy versus the number of devices within a capture showed that for $4$ or less devices in a capture an $80\\%$ device classification accuracy was achievable.  The goal was to determine the separability of DASP features for multi-device classification problems and the combining of CNN learners showed promise and seemed a viable approach for application to multi-device classification problem sets.  It should also be noted that the testing was only performed on one second snippets of data and given the low false positive rates observed with the multi-device learners, it seems reasonable and practical to average multiple observations over time to improve the multi-device performance of the learners.\n\nIn Section \\ref{Clutter Analysis} the responses of the multi-device CNN learners were evaluated when presented with previously unobserved devices (i.e. clutter).  The goal was to determine the DASP image trained CNN classifier sensitivity to clutter devices as well as to develop a method for determining the similarities between known and unknown devices.  Although the individual CNN learners were not able correctly identify clutter at an accuracy greater than $50\\%$, the combination of learners was able to properly assign an unknown device to a clutter class with an accuracy exceeding $80\\%$.   Additionally, evaluation of the clutter devices showed a strong similarity with the \\textit{viewsonicmonitor} device, which was explainable by the strong confusion between the \\textit{None} and \\textit{viewsonicmonitor} classes, as identified in Figure \\ref{fig:stat_cm_cum}.\n\nThe analysis in Sections \\ref{Single Device Classification}, \\ref{Multiple Device Classification}, and \\ref{Clutter Analysis} all demonstrated the viability and applicability of using DASP algorithms to generate strong features for detection, characterization, and classification of devices based upon their URE.  Although the results were not always optimal, especially in the case of clutter identification, improvements in the learning and training processes could significantly improve the results.  The performance of CNN learners for classification of DASP images far exceeded the performance of the LDA and k-NN learners applied to statistically derived feature sets.  Both the single device and multi-device CNN topologies were fairly simple, as compared to AlexNet \\cite{Krizhevsky2012} for instance, and significant improvements could be made to the CNN architecture to target DASP specific images.  Additionally, the training, testing, and learning processes were developed to evaluate DASP specific features and could be adapted and improved to better address operational concerns, such as multi-device and clutter assignment requirements.  For instance, more training on samples with multiple combinations of devices and clutter could significantly improve the ability to identify devices and in addition a separate CNN leaner could be trained for each known device in a one-versus-none configuration to find a specific device instead of comparing one-versus-all. \n\nUsing the results from Sections \\ref{Single Device Classification} and \\ref{Multiple Device Classification} an evaluation was performed on all of the classification results for all of the DASP algorithms.  An average of all of the accuracies and precisions for all of the DASP learners was calculated, along with the standard deviation for each of the accuracy results.  The results are presented in order from best to worst in Table \\ref{tab:dasp_ranking_nullsrmvd}.  Because of the indeterminate statistics associate with the MASP (Low) Scatter, Edge, and Radon arrays, the accuracy results could not be computed for the statistical feature-based learning algorithms and therefore were not included in Table \\ref{tab:dasp_ranking_nullsrmvd}.  Given that the raw MASP arrays outperformed their transformed counterparts in Table \\ref{tab:cnn_single_results}, the exclusion of the MASP transformed arrays did not affect the overall rankings. \n\n\\begin{table}[tb]\n\t\\caption{Ranking of the average accuracies and for all of the DASP classifiers, statistical feature based and CNN image analysis, with the removal of the MASP (Low) scatter, edge, and radon arrays.}\n\t\\csvautotabular{./dasp_algorithm_results/dasp_transform_scores_rank_nullsrmvd.txt}\n\t\\centering\n\t\\label{tab:dasp_ranking_nullsrmvd}\n\\end{table}\n\nExamination of the results in Table \\ref{tab:dasp_ranking_nullsrmvd} showed that the unprocessed DASP arrays outperformed their transformed counterparts for all DASP algorithms, except for CMASP.  The range of average accuracies was only $8\\%$ with no significant deviations in the average accuracy.  The top $6$ DASP rankings were all represented by a different DASP algorithm, with the SCAP array ranking $9^{th}$ directly behind two HASP-F transformed arrays.  The results show that continued processing and transformations of the DASP images is not necessary for classification purposes and therefore the raw arrays can be used in most circumstances, except for the CMASP algorithm which ranked best with the Edge Array transformation.\n\nThe DASP algorithm parameters were chosen heuristically and did not take in to account \\textit{a priori} knowledge of a device's URE characteristics.  Optimization of the DASP parameters to specific devices or classes of devices could significantly improve the results in Sections \\ref{Single Device Classification} and \\ref{Multiple Device Classification} and could potentially change the ranking of DASP algorithms in Table \\ref{tab:dasp_ranking_nullsrmvd}; however, the superior performance of the raw arrays over the transformed DASP arrays (i.e. Edge and Radon transforms) would likely be maintained.\n\n%\\begin{figure}[tb]\n\t%\\csvautotabular{./dasp_algorithm_results/dasp_transform_scores_rank.txt}\n\t%\\centering\n\t%\\caption{Ranking of the average accuracies and precisions for all of the DASP algorithm process classifiers, statistical features and CNN analysis.  In addition, the standard deviation of the accuracies is also provided to indicate the applicability across multiple learning methods.  The MASP images adnd associated transforms dominate the results, but because of the statistical instabilities from the image scaling the MASP scatter, edge, and radon arrays were only evaluated with the CNN classifier and therefore skew the results.}\n\t%\\label{fig:dasp_ranking}\n%\\end{figure}\n\n%{\\centering\n%\\begin{table}[tb]\n\t%\\begin{tabular}{ccc}\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_2.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc2}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_3.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc3}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_4.eps}\n\t\t%\\caption{Figure B}\\label{fig:cnnmultifc4}\n\t\t%\\end{subfigure}    \\\\\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_6.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc6}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_7.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc7}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_8.eps}\n\t\t%\\caption{Figure B}\\label{fig:cnnmultifc8}\n\t\t%\\end{subfigure}    \\\\\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_9.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc9}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_10.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc10}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_11.eps}\n\t\t%\\caption{Figure B}\\label{fig:cnnmultifc11}\n\t\t%\\end{subfigure}    \\\\\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_13.eps}\n\t\t%\\caption{Figure C}\\label{fig:cnnmultifc13}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_14.eps}\n\t\t%\\caption{Figure A}\\label{fig:cnnmultifc14}\n\t\t%\\end{subfigure}&\n\t\t%\\begin{subfigure}{0.3\\textwidth}\\centering\\includegraphics[width=0.8\\columnwidth]{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_dream_fc_17.eps}\n\t\t%\\caption{Figure A again}\\label{fig:cnnmultifc17}\n\t\t%\\end{subfigure}\n\t%\\end{tabular}\n%\\caption{Table of Deep Dream images of fully connected layers of select DASP transforms from multi network training}\n%\\label{tab:cnnultifcdreamtable}\n%\\end{table}\n%}\n%\\begin{figure}[tb]\n\t%\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_cluster_kmed.eps}\n\t%\\centering\n\t%\\caption{Clustering of top two PCA features using Kmed}\n\t%\\label{fig:clustertruth}\n%\\end{figure}\n%\n%\n%\\subsection[Device Similarity]{Device Similarity}\n%\n%\\blindtext[1]\n%\n%\\begin{figure}[tb]\n\t%\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_stat_cluster_link.eps}\n\t%\\centering\n\t%\\caption{Dendrogram using top three PCA features}\n\t%\\label{fig:clusterdendrogram}\n%\\end{figure}\n\n%\\subsection[Image Similarity]{Image Similarity}\n%\n%\\blindtext[1]\n%\n%\\begin{figure}[tb]\n\t%\\csvautotabular{./dasp_algorithm_results/dasp_ssim_acc_results.txt}\n\t%\\centering\n\t%\\caption{Table of classification accuracies for SSIM image classification.   The \\textit{x12} column only uses $12$ images for testing against per class, whereas the \\textit{x120} uses 120 images per class for comparison.   The results show a classification improvement for most DASP algorithm processes with an increase in the number of comparison images.  The combined results show a $99.2\\%$ and $98.7\\%$ classification accuracy for \\textit{x12} and \\textit{x120} respectively.   The combined classification accuracy was based on a class vote across all DASP algorithm processes.}\n\t%\\label{fig:ssim_acc}\n%\\end{figure}\n%\n%\\begin{figure}[tb]\n\t%\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_ssim_120_120_conf.eps}\n\t%\\centering\n\t%\\caption{Confusion matrix for the \\textit{x12} combined SSIM classifier.   The \\textit{None} class is misclassified as a \\textit{viewsonicmonitor} in $8\\%$ of tests.}\n\t%\\label{fig:ssim_120_cm}\n%\\end{figure}\n%\n%\\begin{figure}[tb]\n\t%\\includegraphics[width=\\textwidth]{./dasp_algorithm_results/dasp_ssim_1200_1200_conf.eps}\n\t%\\centering\n\t%\\caption{Confusion matrix for the \\textit{x12} combined SSIM classifier.   The \\textit{None} class is misclassified as a \\textit{viewsonicmonitor} in $11\\%$ of tests and as a \\textit{linksysrouter} in $3\\%$ of tests.}\n\t%\\label{fig:ssim_1200_cm}\n%\\end{figure}\n\n%\\subsection[Image Similarity]{Image Similarity}\n%\n%\\blindtext[1]\n%\n%\\begin{figure}[tb]\n\t%\\csvautotabular{./dasp_algorithm_results/dasp_ssim_multi_results.txt}\n\t%\\centering\n\t%\\caption{Classification accuracies and statistical measures of the multi-class classifier using SSIM based feature sets derived from all DASP algorithm processes.  Given $9$ possible class assignments with the \\textit{None} class removed, the overall accuracies were around $45\\%$, with none of the SSIM classifier Precisions exceeding $0.65$.}\n\t%\\label{fig:ssim_multi}\n%\\end{figure}\n\n%\\begin{figure}[tb]\n\t%\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{./dasp_algorithm_results/dasp_cnn_multi_nonemultirmvd_class_acc_numdevices.eps}\n\t%\\centering\n\t%\\caption{Plot of the multi-class CNN classification results as shown in \\ref{fig:cnn_multi_acc_add_device}.  The monotonic decrease in accuracies with no major discontinuities confirms the viability of the testing methodology.}\n\t%\\label{fig:cnn_multi_acc_dev_plot}\n%\\end{figure}\n\n%\\begin{figure}[tb]\n\t%\\csvautotabular{./dasp_algorithm_results/dasp_cnn_multi_nonermvd_results.txt}\n\t%\\centering\n\t%\\caption{The classification accuracies and statistical metrics for the multi-class CNN classifier is provided, when all DASP images are used for training, regardless of their utilization and presence in the training set.  The results are comparable and in some respects are $1$ to $5$ percentage points lower than the results in \\ref{fig:cnn_multi_testrmvd}.  The slightly poorer results could be the result of over training and a single device's features dominating other devices in certain multi-class combinations.}\n\t%\\label{fig:cnn_multi_acc_alltrained}\n%\\end{figure}\n", "meta": {"hexsha": "241f24058200517227374697573c815b127b7bc3", "size": 65522, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "research/dissertation/DASPClassification.tex", "max_stars_repo_name": "argodev/learn", "max_stars_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "research/dissertation/DASPClassification.tex", "max_issues_repo_name": "argodev/learn", "max_issues_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 15, "max_issues_repo_issues_event_min_datetime": "2020-01-28T22:25:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-11T23:21:02.000Z", "max_forks_repo_path": "research/dissertation/DASPClassification.tex", "max_forks_repo_name": "argodev/learn", "max_forks_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 135.9377593361, "max_line_length": 1841, "alphanum_fraction": 0.7995482433, "num_tokens": 15844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6757646010190477, "lm_q1q2_score": 0.4255793863045708}}
{"text": "\\documentclass{warpdoc}\n\\newlength\\lengthfigure                  % declare a figure width unit\n\\setlength\\lengthfigure{0.158\\textwidth} % make the figure width unit scale with the textwidth\n\\usepackage{psfrag}         % use it to substitute a string in a eps figure\n\\usepackage{subfigure}\n\\usepackage{rotating}\n\\usepackage{pstricks}\n\\usepackage[innercaption]{sidecap} % the cute space-saving side captions\n\\usepackage{scalefnt}\n\\usepackage{amsmath}\n\\usepackage{bm}\n\n%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newcommand{\\alb}{\\vspace{0.2cm}\\\\} % array line break\n\\newcommand{\\mfd}{\\displaystyle}\n\\newcommand{\\nd}{{n_{\\rm d}}}\n\\newcommand{\\M}{{\\bf M}}\n\\newcommand{\\N}{{\\bf N}}\n\\newcommand{\\B}{{\\bf B}}\n\\newcommand{\\BI}{\\overline{{\\bf B}}}\n\\newcommand{\\A}{{\\bf A}}\n\\newcommand{\\C}{{\\bf C}}\n\\newcommand{\\T}{{\\bf T}}\n\\newcommand{\\co}{,~~}\n\\newcommand{\\band}{{\\rm Band}}\n\\renewcommand{\\fontsizetable}{\\footnotesize\\scalefont{1.0}}\n\\renewcommand{\\fontsizefigure}{\\footnotesize}\n\\renewcommand{\\vec}[1]{\\bm{#1}}\n\\setcounter{tocdepth}{3}\n\\let\\citen\\cite\n\n%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\setcounter{tocdepth}{3}\n\n%%%%%%%%%%%%%=--NEW COMMANDS ENDS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\\author{\n  Bernard Parent\n}\n\n\\email{\n  bernparent@gmail.com\n}\n\n\\department{\n  Department of Aerospace Engineering\t\n}\n\n\\institution{\n  Pusan National University\n}\n\n\\title{\n  Source Terms Discretization\n}\n\n\\date{\n  September 2016\n}\n\n%\\setlength\\nomenclaturelabelwidth{0.13\\hsize}  % optional, default is 0.03\\hsize\n%\\setlength\\nomenclaturecolumnsep{0.09\\hsize}  % optional, default is 0.06\\hsize\n\n\\nomenclature{\n\n  \\begin{nomenclaturelist}{Roman symbols}\n   \\item[$a$] speed of sound\n  \\end{nomenclaturelist}\n}\n\n\n\\abstract{\nabstract\n}\n\n\\begin{document}\n\\sloppy\n  \\pagestyle{headings}\n  \\pagenumbering{arabic}\n  \\setcounter{page}{1}\n%%  \\maketitle\n  \\makewarpdoctitle\n%  \\makeabstract\n  \\tableofcontents\n%  \\makenomenclature\n%%  \\listoftables\n%%  \\listoffigures\n\n\n\n\\section{Splitting of the Source Terms to Obtain Positivity}\n\nConsider an ordinary differential equation of the form:\n%\n\\begin{equation}\n\\frac{d U}{d t}  = S \n\\end{equation}\n%\nwhere $t$ is time, $S$ is the source term vector, and $U$ is the vector of conserved variables. Discretize the latter using a first-order backward operator for the time derivative (a usual strategy when solving chemically-reacting flow). Then:\n%\n\\begin{equation}\n\\frac{U_{m}-U_{m-1}}{\\Delta t} = S_{m} \n\\label{eqn:disceq}\n\\end{equation}\n%\nwhere $m$ refers to the time level and $\\Delta t$ to the physical time step.   \n\nNow, let's rewrite $S$ as a function of the flux eigenvectors and eigenvalues:\n%\n\\begin{equation}\n S_{m} = L^{-1}_{m} \\Lambda_{m}^S L_{m} U_{m}\n\\label{eqn:S1}\n\\end{equation}\n%\nThe latter should be understood as a definition of the $S$ eigenvalues, $\\Lambda_{m}^S$. Multiply both sides by $L_{m}$:\n%\n\\begin{equation}\n L_{m} S_{m} =  \\Lambda_{m}^S L_{m} U_{m}\n\\end{equation}\n%\nor,\n%\n\\begin{equation}\n \\left[ L_{m} S_{m} \\right]_{r} =  \\left[ \\Lambda_{m}^S\\right]_{r,r} \\left[L_{m} U_{m}\\right]_r\n\\end{equation}\n%\nIsolate the eigenvalues:\n%\n\\begin{equation}\n\\left[ \\Lambda_{m}^S\\right]_{r,r}=\\frac{ \\left[ L_{m} S_{m} \\right]_{r}}{\\left[L_{m} U_{m}\\right]_r}  \n\\label{eqn:Lambda_S}\n\\end{equation}\n%\nIt can be easily shown that the discretization equation would conform to the rule of the positive coefficients (and hence lead to a positivity-preserving algorithm) only if all the terms within $\\Lambda_{m}^S$ are negative \\cite{jcp:2012:parent}. Unfortunately, this is seldom the case and this is why the solution can become tainted with negative mass fractions, negative temperature, or negative pressure. For this reason, we will seek a discretization of the source term of the form:\n%\n\\begin{equation}\n  S_{m} = L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m} + L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1}\n  \\label{eqn:source_split}\n\\end{equation}\n%\nwhere $\\Lambda^-$ and $\\Lambda^+$ are diagonal matrices composed strictly of negative and positive eigenvalues, respectively. \n\nTo see why this would lead to a positivity-preserving algorithm, substitute the latter in Eq.\\ (\\ref{eqn:disceq}):\n%\n\\begin{equation}\n\\frac{U_{m}-U_{m-1}}{\\Delta t} = L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m} + L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1}\n\\end{equation}\n%\nPut the $U_m$ terms on the LHS and the $U_{m-1}$ terms on the RHS:\n%\n\\begin{equation}\n\\frac{1}{\\Delta t} U_{m} - L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m}\n=\n   L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1} + \\frac{1}{\\Delta t} U_{m-1}\n\\end{equation}\n%\nRearrange:\n%\n\\begin{equation}\n L^{-1}_{m} \\left(\\frac{1}{\\Delta t} I -  \\Lambda_{m}^-  \\right) L_{m} U_{m}\n=\n   L^{-1}_{m-1} \\left( \\Lambda_{m-1}^+ + \\frac{1}{\\Delta t} I \\right) L_{m-1} U_{m-1} \n\\end{equation}\n%\nBecause the  eigenvalues are strictly positive within both terms, the latter adheres to the rule of the positive coefficients and will hence be positivity preserving. \n\n\n\\section{Source Vector Splitting}\n\nPerhaps the simplest way the source term eigenvalues $\\Lambda^+$ and $\\Lambda^-$ can be found is through vector splitting. This is accomplished by first defining the source eigenvalues $\\Lambda_{m}^S$ and $\\Lambda_{m-1}^S$ such that the following two equations hold:\n%\n\\begin{equation}\n S_{m} = L^{-1}_{m} \\Lambda_{m}^S L_{m} U_{m}\n\\end{equation}\n%\n%\n\\begin{equation}\n S_{m} = L^{-1}_{m-1} \\Lambda_{m-1}^S L_{m-1} U_{m-1}\n\\end{equation}\n%\nFrom the latter it can be easily shown that the source eigenvalues correspond to:\n%\n\\begin{equation}\n\\left[ \\Lambda_{m}^S\\right]_{r,r}=\\frac{ \\left[ L_{m} S_{m} \\right]_{r}}{\\left[L_{m} U_{m}\\right]_r}  \n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ \\Lambda_{m-1}^S\\right]_{r,r}=\\frac{ \\left[ L_{m-1} S_{m} \\right]_{r}}{\\left[L_{m-1} U_{m-1}\\right]_r}  \n\\end{equation}\n%\nFrom the latter we can obtain the negative and positive eigenvalues as follows:\n%\n\\begin{equation}\n\\Lambda_m^- = \\frac{1}{2} \\left( \\Lambda_m^S - |\\Lambda_m^S| \\right)\n\\end{equation}\n%\n%\n\\begin{equation}\n\\Lambda_{m-1}^+ = \\frac{1}{2} \\left( \\Lambda_{m-1}^S + |\\Lambda_{m-1}^S| \\right)\n\\end{equation}\n%\n\n\n\\section{Source Difference Splitting}\n\n\nWe now wish to outline an algorithm which would yield the source terms positive and negative eigenvalues, $\\Lambda^+$ and $\\Lambda^-$ from the source term $S$.\n\nThis is accomplished by first substituting the $S$ eigenvalues outlined in Eq.\\ (\\ref{eqn:Lambda_S}) in Eq.\\  (\\ref{eqn:S1}). After some reformatting, the following is obtained:\n%\n\\begin{equation}\nS_{m}=\n\\underbrace{ L^{-1}_{m-1} Y^+_{m-1} L_{m-1} U_{m-1} \n+ L^{-1}_{m} Z^-_{m} L_{m} U_{m}}_\\textrm{\\small positivity-preserving}\n+\\underbrace{ L^{-1}_{m-1} Y^-_{m-1} L_{m-1} U_{m-1} \n+ L^{-1}_{m} Z^+_{m} L_{m} U_{m}}_\\textrm{\\small not~necessarily~positivity-preserving}\n\\label{eqn:S_split}\n\\end{equation}\n%\nwith the diagonal matrices $Y^{\\pm}$ and $Z^{\\pm}$ set equal to: \n%\n\\begin{equation}\n \\left[Y_{m-1}^-\\right]_{r,r}  = 0\n\\label{eqn:Yminus1}\n\\end{equation}\n%\n%\n\\begin{equation}\n \\left[Z_{m}^-\\right]_{r,r}  = \\min\\left(0,~\\left[ \\Lambda_{m}^S\\right]_{r,r}\\right)\n\\label{eqn:Zminus1}\n\\end{equation}\n%\n%\n\\begin{equation}\n \\left[ Y_{m-1}^+\\right]_{r,r}  = 0\n\\label{eqn:Yplus1}\n\\end{equation}\n%\n%\n\\begin{equation}\n \\left[Z_{m}^+\\right]_{r,r}  = \\max\\left(0,~\\left[ \\Lambda_{m}^S\\right]_{r,r}\\right)\n\\label{eqn:Zplus1}\n\\end{equation}\n%\nThus far, the souce terms have not been modified and the stencil is still not positivity-preserving. \n\nOne way that the stencil could be made positivity-preserving is simply by dropping the last two terms on the RHS of Eq.\\ (\\ref{eqn:S_split}). But, by doing so, the source terms would be modified substantially. For this reason, instead of discarding the two terms that are not necessarily positivity-preserving, let us recast them into new terms, some of which being guaranteed to be positivity-preserving. This can be accomplished by first defining the diagonal matrices $Q$ and $R$ such that the following two statements hold:\n%\n\\begin{equation}\nL^{-1}_{m} R_{m} L_{m} U_{m} \\equiv L^{-1}_{m-1} Y^-_{m-1} L_{m-1} U_{m-1}\n\\label{eqn:R_definition}\n\\end{equation}\n%\n%\n\\begin{equation}\nL^{-1}_{m-1} Q_{m-1} L_{m-1} U_{m-1} \\equiv L^{-1}_{m} Z^+_{m} L_{m} U_{m}\n\\label{eqn:Q_definition}\n\\end{equation}\n%\nThen, using the latter two definitions, the split source terms outlined in Eq.\\ (\\ref{eqn:S_split}) can be rewritten as:\n%\n\\begin{equation}\nS_{m}=\n+ L^{-1}_{m-1} (Y^+_{m-1}+Q_{m-1}) L_{m-1} U_{m-1} \n+ L^{-1}_{m} (Z^-_{m}+R_{m}) L_{m} U_{m}\n\\label{eqn:S_split_2}\n\\end{equation}\n%\nwhere the matrices $R$ and $Q$ can  be obtained in terms of the other matrices by multiplying both sides of Eqs.\\ (\\ref{eqn:R_definition}) and (\\ref{eqn:Q_definition}) by $L_{m}$, writing in tensor form, and then isolating $R$ and $Q$:\n%\n\\begin{equation}\n\\left[R_{m}\\right]_{r,r}  = \\frac{\\left[L_{m} L^{-1}_{m-1} Y^-_{m-1} L_{m-1} U_{m-1}\\right]_r}{\\left[L_{m} U_{m}\\right]_r}\n\\label{eqn:R_2}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[Q_{m-1}\\right]_{r,r} = \\frac{\\left[L_{m-1} L^{-1}_{m} Z^+_{m} L_{m} U_{m}\\right]_r}{\\left[L_{m-1} U_{m-1}\\right]_r}\n\\label{eqn:Q_2}\n\\end{equation}\n%\nNow, let us split again $S$ as a sum of positivity-preserving terms and not-necessarily-positivity-preserving terms. This can be done by rewriting Eq.\\ (\\ref{eqn:S_split_2}) as:\n%\n\\begin{align}\nS_{m}&=\n\\underbrace{ \n L^{-1}_{m-1} (Y^+_{m-1})^{k+1} L_{m-1} U_{m-1}+L^{-1}_{m} (Z^-_{m})^{k+1} L_{m} U_{m}}_\\textrm{\\small positivity-preserving}\\nonumber\\alb\n&+\\underbrace{  L^{-1}_{m-1} (Y^-_{m-1})^{k+1} L_{m-1} U_{m-1} \n+ L^{-1}_{m} (Z^+_{m})^{k+1} L_{m} U_{m}}_\\textrm{\\small not~necessarily~positivity-preserving} \n\\label{eqn:S_split_3}\n\\end{align}\n%\nwhere the superscript $k$ is an iteration counter such that $(\\cdot)^{k+1}$ refers to an update of the properties $(\\cdot)$. Then, for Eq.\\ (\\ref{eqn:S_split_3}) to be equal to the split source terms, Eq.\\ (\\ref{eqn:S_split_2}), the  updated $Y^\\pm$ and $Z^\\pm$ diagonal matrices must be equal to: \n%\n\\begin{equation}\n\\left[ Y^-_{m-1}\\right]^{k+1}_{r,r} = \\min \\left(0,~\\left[Y^+_{m-1}\\right]^k_{r,r}+\\left[Q_{m-1}\\right]^k_{r,r}  \\right) \n\\label{eqn:Yminus2}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Z^-_{m}\\right]^{k+1}_{r,r} = \\min \\left(0,~\\left[Z^-_{m}\\right]^k_{r,r}+\\left[R_{m}\\right]^k_{r,r}  \\right) \n\\label{eqn:Zminus2}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Y^+_{m-1}\\right]^{k+1}_{r,r} = \\max \\left(0,~\\left[Y^+_{m-1}\\right]^k_{r,r}+\\left[Q_{m-1}\\right]^k_{r,r}  \\right) \n\\label{eqn:Yplus2}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Z^+_{m}\\right]^{k+1}_{r,r} = \\max \\left(0,~\\left[Z^-_{m}\\right]^k_{r,r}+\\left[R_{m}\\right]^k_{r,r}  \\right) \n\\label{eqn:Zplus2}\n\\end{equation}\n%\nwhere the notation  $(\\cdot)^k$ denotes the property $(\\cdot)$ at the previous iteration count. Then, after substituting $R$ and $Q$ from Eq.\\ (\\ref{eqn:R_2}) and (\\ref{eqn:Q_2}) the latter 4 equations become:\n%\n\\begin{equation}\n\\left[ Y^-_{m-1}\\right]^{k+1}_{r,r} = \\min \\left(0,~\\left[Y^+_{m-1}\\right]^k_{r,r}+\\frac{\\left[L_{m-1} L^{-1}_{m} (Z^+_{m})^k L_{m} U_{m}\\right]_r}{\\left[L_{m-1} U_{m-1}\\right]_r}  \\right) \n\\label{eqn:Yminus3}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Z^-_{m}\\right]^{k+1}_{r,r} = \\min \\left(0,~\\left[Z^-_{m}\\right]^k_{r,r}+\\frac{\\left[L_{m} L^{-1}_{m-1} (Y^-_{m-1})^k L_{m-1} U_{m-1}\\right]_r}{\\left[L_{m} U_{m}\\right]_r}  \\right) \n\\label{eqn:Zminus3}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Y^+_{m-1}\\right]^{k+1}_{r,r} = \\max \\left(0,~\\left[Y^+_{m-1}\\right]^k_{r,r}+\\frac{\\left[L_{m-1} L^{-1}_{m} (Z^+_{m})^k L_{m} U_{m}\\right]_r}{\\left[L_{m-1} U_{m-1}\\right]_r}  \\right) \n\\label{eqn:Yplus3}\n\\end{equation}\n%\n%\n\\begin{equation}\n\\left[ Z^+_{m}\\right]^{k+1}_{r,r} = \\max \\left(0,~\\left[Z^-_{m}\\right]^k_{r,r}+\\frac{\\left[L_{m} L^{-1}_{m-1} (Y^-_{m-1})^k L_{m-1} U_{m-1}\\right]_r}{\\left[L_{m} U_{m}\\right]_r}  \\right) \n\\label{eqn:Zplus3}\n\\end{equation}\n%\nBy performing several iterations $k=1,2,3,..$, the latter set of equations essentially transforms (as much as possible) the not-necessarily-positivity-preserving terms into positivity-preserving terms (see Eq.\\ (\\ref{eqn:S_split_3})). However, it is noted that when used in conjunction with Eq.\\ (\\ref{eqn:S_split_3}), the latter expressions for $Y^\\pm$ and $Z^\\pm$ will yield exactly the original source terms independently of how many times the matrices $Y^\\pm$ and $Z^\\pm$ are updated. To make the scheme positivity-preserving, rewrite the source terms, Eq.\\ (\\ref{eqn:S_split_3}), as:\n%\n\\begin{equation}\nS_{m}=\n L^{-1}_{m-1} \\Lambda^+_{m-1} L_{m-1} U_{m-1} \n+ L^{-1}_{m} \\Lambda^-_{m} L_{m} U_{m}\n\\label{eqn:S_split_3_2}\n\\end{equation}\n%\nwith the positive eigenvalues $\\Lambda^+$ being set to the sum of the positive wave speeds from both the previous time level $m-1$ and the current time level $m$:  \n%\n\\begin{equation}\n\\Lambda_{m-1}^+ = Y^+_{m-1} + Z^+_{m} \n\\label{eqn:lambdapluQ_2}\n\\end{equation}\n%\nand with the negative eigenvalues $\\Lambda^-$ defined as the sum of the negative wave speeds originating from both the previous time level $m-1$ and the current time level $m$:\n%\n\\begin{equation}\n\\Lambda_{m}^- = Z^-_{m} + Y^-_{m-1} \n\\label{eqn:lambdaminuQ_2}\n\\end{equation}\n%\nCompared to the original source terms, the latter source terms formulation does not modify the wave speed:  the wave speed lost by the source term at the previous iteration is gained by the source term at the next iteration and vice-versa. \n\nIn summary, the ``iterative form'' of the positivity-preserving source terms presented in this section consists of (i) initializing the $Y^\\pm$ and $Z^\\pm$ diagonal matrices using Eqs.\\ (\\ref{eqn:Yminus1}) to (\\ref{eqn:Zplus1}), (ii) updating the $Y^\\pm$ and $Z^\\pm$ diagonal matrices through an iterative process by using Eqs.\\ (\\ref{eqn:Yminus3}) to (\\ref{eqn:Zplus3}), (iii) determining the positive and negative eigenvalues through Eqs.\\ (\\ref{eqn:lambdapluQ_2}) and (\\ref{eqn:lambdaminuQ_2}) using the latest updates of the $Y^\\pm$ and $Z^\\pm$ matrices, and (iv) determining the flux at the interface as in Eq.\\ (\\ref{eqn:S_split_3_2}). It is here recommended to update the $Y^\\pm$ and $Z^\\pm$ matrices only two times, as further updating the latter matrices seldomly results in a noticeable improvement of the solution while requiring more computing effort. \n\n%Finally, it is noted that the flux function presented in this section yields exactly the one presented in Section 3.1 when no iterations are performed (that is, when the $Y^\\pm$ and $Z^\\pm$ matrices are set as in Eqs.\\ (\\ref{eqn:Yminus1})-(\\ref{eqn:Zplus1}) and not subsequently updated).\n\n\n\\section{Local Pseudotime Step}\n\nRecall the discretization equation Eq.\\ (\\ref{eqn:disceq}):\n%\n\\begin{equation}\n\\frac{U_{m}-U_{m-1}}{\\Delta t} = S_{m} \n\\end{equation}\n%\nAdd a pseudotime derivative:\n%\n\\begin{equation}\n\\frac{U^{n+1}_m-U_m}{\\Delta \\tau}\n+\\frac{U_{m}-U_{m-1}}{\\Delta t} = S_{m} \n\\end{equation}\n%\nSplit the source term in positive and negative vectors following Eq.\\ (\\ref{eqn:source_split}):\n%\n\\begin{equation}\n  S_{m} = L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m} + L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1}\n\\end{equation}\n%\nSubstituting the latter in the former:\n%\n\\begin{equation}\n\\frac{U^{n+1}_m-U_m}{\\Delta \\tau}\n+\\frac{U_{m}-U_{m-1}}{\\Delta t} = L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m} + L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1}\n\\end{equation}\n%\nOn  the LHS, keep only the $n+1$ term:\n%\n\\begin{equation}\n\\frac{1}{\\Delta \\tau} U^{n+1}_m\n = L^{-1}_{m} \\Lambda_{m}^- L_{m} U_{m} + L^{-1}_{m-1} \\Lambda_{m-1}^+ L_{m-1} U_{m-1}\n-\\frac{1}{\\Delta t} U_{m}+\\frac{1}{\\Delta t} U_{m-1}\n+\\frac{1}{\\Delta \\tau} U_m\n\\end{equation}\n%\nRegroup similar terms together:\n%\n\\begin{equation}\n\\frac{1}{\\Delta \\tau} U^{n+1}_m\n = L^{-1}_{m} \\left( \\Lambda_{m}^- + \\frac{1}{\\Delta \\tau}I -\\frac{1}{\\Delta t}I\\right) L_{m} U_{m} \n + L^{-1}_{m-1} \\left( \\Lambda_{m-1}^+ + \\frac{1}{\\Delta t}I \\right) L_{m-1} U_{m-1}\n\\end{equation}\n%\n \n\n\n\\bibliographystyle{warpdoc}\n\\bibliography{all}\n\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "90348dec4576e21a7c4f345cb751c63adf1d3ad5", "size": 15953, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cycle/ressource/doc/report.tex", "max_stars_repo_name": "zhanghuanqian/CFDWARP", "max_stars_repo_head_hexsha": "9340a8526bb263d910f79d79e84dcac7aec211b6", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2018-09-13T13:58:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T21:44:13.000Z", "max_issues_repo_path": "cycle/ressource/doc/report.tex", "max_issues_repo_name": "zhanghuanqian/CFDWARP", "max_issues_repo_head_hexsha": "9340a8526bb263d910f79d79e84dcac7aec211b6", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-11-10T11:28:30.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-23T09:21:28.000Z", "max_forks_repo_path": "cycle/ressource/doc/report.tex", "max_forks_repo_name": "zhanghuanqian/CFDWARP", "max_forks_repo_head_hexsha": "9340a8526bb263d910f79d79e84dcac7aec211b6", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 20, "max_forks_repo_forks_event_min_datetime": "2018-07-26T08:17:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T08:41:55.000Z", "avg_line_length": 35.769058296, "max_line_length": 864, "alphanum_fraction": 0.6660816147, "num_tokens": 5957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4255793863045707}}
{"text": "\\documentclass[]{BasiliskReportMemo}\n\\usepackage{AVS}\n\n\n\\newcommand{\\submiterInstitute}{Autonomous Vehicle Simulation (AVS) Laboratory,\\\\ University of Colorado}\n\n\\newcommand{\\ModuleName}{test\\textunderscore okeefeEKF}\n\\newcommand{\\subject}{Sunline EKF Module and Test}\n\\newcommand{\\status}{Initial document}\n\\newcommand{\\preparer}{T. Teil}\n\\newcommand{\\summary}{This module implements and tests a Extended Kalman Filter in order to estimate the sunline direction.}\n\n\n\\begin{document}\n\n\n\\makeCover\n\n\n\n%\n%\tenter the revision documentation here\n%\tto add more lines, copy the table entry and the \\hline, and paste after the current entry.\n%\n\\pagestyle{empty}\n{\\renewcommand{\\arraystretch}{2}\n\\noindent\n\\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}\n\\hline\n{\\bfseries Rev}: & {\\bfseries Change Description} & {\\bfseries By} \\\\\n\\hline\nDraft & Initial Revision & T. Teil \\\\\n\\hline\n\n\\end{longtable}\n}\n\n\\newpage\n\\setcounter{page}{1}\n\\pagestyle{fancy}\n\n\\tableofcontents\n~\\\\ \\hrule ~\\\\\n\n%\\begin{figure}[htb]\n%\t\\centerline{\n%\t\\includegraphics[]{Figures/Fig1}\n%\t}\n%\t\\caption{Sample Figure Inclusion.}\n%\t\\label{fig:Fig1}\n%\\end{figure}\n\n\\section{Introduction}\nThe Sunline Extended Kalman filter (EKF) in the AVS Basilisk simulation is a sequential\nfilter implemented to give the best estimate of the desired states.\nIn this method we estimate the sun heading with no rigorous estimate of rate. This is done per the paper written by Steve O'Keefe, hence the module name \"okeefeEKF\".\nThe EKF reads in the message written by the coarse sun sensor, and writes a message \ncontaining the sun estimate. \n\nThis document summarizes the content of the module, how to use it, and the test that \nwas implemented for it. More information on the filter derivation can be found in Reference [\\citenum{Teil:2018fe}], and more information on the square root unscented filter can be found in Reference [\\citenum{OKeefe:2013fk}].\n\n\n\\section{Filter Set-up, initialization, and I/O}\n\n\\subsection{Dynamics}\n\nThe states that are estimated in this filter are the sunline vector, and it's rate of change $\\bm X^* = \\begin{bmatrix} \\bm d\\end{bmatrix}^T$. The star superscript represents that\nthis is the reference state. \n\nThe dynamics are given in equation \\ref{eq:dyn}. Given the nature of the filter, there is an unobservable state component: the rotation about the $\\bm d$ axis. In order to remedy this, we project the states along this axis and subtract them, in order to measure only observable state components. \n\n\\begin{equation}\\label{eq:dyn}\n\\bm F(\\bm X) =\\dot{\\bm d}  = - \\bm \\omega \\times \\bm d\n\\end{equation}\n\nThis leads us to the computation of the dynamics matrix $A = \\left[\\frac{\\partial \\bm F (\\bm X, t_i)}{\\partial \\bm X}\\right]^{*}$. The partials are given in equation \\ref{eq:dynmat}, and were verified in Mathematica.\n\n\\begin{align}\\label{eq:dynmat}\nA&= \\begin{bmatrix} \\frac{\\partial \\bm F (\\bm d, t_i)}{\\partial \\bm d}  \\end{bmatrix} \\\\\n&=  - \\begin{bmatrix} \\tilde{\\bm \\omega}\\end{bmatrix} \n\\end{align}\n\nIf rate gyro measurements are available, we can use the $\\bm \\omega$ vector that they provide. In the case where they are not available, we can approximate it by logging an extra time step of the sun heading vector estimate $\\bm d$:\n\n\\begin{equation}\n\\bm \\omega_k = \\frac{1}{\\Delta t} \\frac{\\bm d_k \\times \\bm d_{k-1}}{\\|\\bm d_k \\times \\bm d_{k-1} \\|} \\arccos\\left( \\frac{\\bm d_k \\cdot \\bm d_{k-1}}{\\|\\bm d_k \\| \\| \\bm d_{k-1}\\|}\\right) \n\\end{equation}\n\nThe measurement model is given in equation \\ref{eq:meas}, and the $H$ matrix defined as $H = \\left[\\frac{\\partial \\bm G (\\bm X, t_i)}{\\partial \\bm X}\\right]^{*}$ is given in equation $\\ref{eq:Hmat}$. \n\nIn this filter, the only measurements used are from the coarse sun sensor. For the $i^\\mathrm{th}$ sensor, the measurement is simply given by the dot product of the sunline heading and the normal to the sensor. This yields easy partial derivatives for the H matrix, which is a matrix formed of the rows of transposed normal vectors (only for those which received a measurement). Hence the $H$ matrix has a changing size depending on the amount of measurements. \n\n\\begin{equation}\\label{eq:meas}\n\\bm G_i(\\bm X) = \\bm n_i \\cdot \\bm d\n\\end{equation}\n\n\\begin{equation}\\label{eq:Hmat}\n\\bm H(\\bm X) = \\begin{bmatrix} \\bm n_1^T \\\\ \\vdots \\\\ \\bm n_i^T \\end{bmatrix} \n\\end{equation}\n\n\\subsection{User initialization}\n\n\nIn order for the filter to run, the user must set a few parameters:\n\n\n\\begin{itemize}\n\\item The angle threshold under which the coarse sun sensors do not read the measurement: \\\\ \n\\texttt{FilterContainer.sensorUseThresh = 0.}\n\\item The process noise value, for instance:\\\\\n \\texttt{FilterContainer.qProcVal = 0.001}\n\\item The measurement noise value, for instance: \\\\\n \\texttt{FilterContainer.qObsVal = 0.001}\n \\item The threshold in the covariance norm leading to the switch from the EKF update to the linear Kalman Filter update (discussed more closely in the Measurement update part):\\\\\n \\texttt{FilterContainer.ekfSwitch = 5}\n\\item The initial covariance: \\\\\n \\texttt{Filter.covar =} \\\\\n  \\texttt{ [0.4, 0., 0., \\\\ 0.,0.4, 0.,  \\\\ 0., 0., 0.4]}\n \\item The initial state :\\\\\n \\texttt{Filter.state = [1., 0., 1.]}\n\\end{itemize}\n\nThe messages must also be set as such:\n\n\\begin{itemize}\n\\item    \\texttt{ filterObject.navStateOutMsgName = \"sunline$\\_$state$\\_$estimate\"}\n\\item    \\texttt{ filterObject.filtDataOutMsgName = \"sunline$\\_$filter$\\_$data\"}\n\\item   \\texttt{ filterObject.cssDataInMsgName = \"css$\\_$sensors$\\_$data\"}\n\\item   \\texttt{ filterObject.cssConfInMsgName = \"css$\\_$config$\\_$data\"}\n\\end{itemize}\n\n\\subsection{Inputs and Outputs}\n\nThe EKF reads in the measurements from the coarse sun sensors. These are under the form of a list of cosine values. Knowing the normals to each of the sensors, we can therefore use them to estimate sun heading.\n\n\\section{Filter Algorithm}\n\nOnce the filter has been properly setup in the python code, it can go through it's algorithm:\n\n\\subsubsection*{Initialization}\n\nFirst the filter is initialized. This can be done at any time during a simulation in order to reset \nthe filter. \n\n\\begin{itemize}\n\\item Time is set to $t_0$\n\\item The state $\\bm X^*$ is set to the initial state  $\\bm X_0^*$\n\\item The state error $\\bm x$ is set to it's initial value $\\bm x_0$\n\\item The covariance $P$ is set to the initial state  $P_0$\n\\end{itemize}\n\n\n\\subsubsection*{Time Update}\n\nAt some time $t_i$, if the update filter method is called, a time update will first be executed.\n\n\\begin{itemize}\n\\item The state is propagated using the dynamics $\\bm F$ with initial conditions $\\bm X^*(t_{i-1})$\n\\item Compute the dynamics matrix $A(t) = \\left[\\frac{\\partial \\bm F (\\bm X, t)}{\\partial \\bm X}\\right]^{*}$ which is evaluated on the reference trajectory\n\\item Integrate the STM, $\\dot{\\Phi}(t, t_{i-1}) = A(t) \\Phi (t, t_{i-1})$ with initial conditions $\\Phi(t_{i-1}, t_{i-1}) = I$\n\\end{itemize}\n\nThis gives us $\\bm X^*(t_i)$ and $\\Phi(t_{i}, t_{i-1})$.\n\n\\subsubsection*{Observation read in}\n\n\\underline{If no measurement is read in at time $t_i$:}\n\n\\begin{itemize}\n\\item $\\bm X^*(t_i)$ previously computed becomes the most recent reference state\n\\item $\\bm x_i = \\bm \\bar{x}_i = \\Phi(t_{i}, t_{i-1}) x_{i-1}$ is the new state error \n\\item $P_i = \\bar{P}_i =\\Phi(t_{i}, t_{i-1}) P_{i-1} \\Phi^T(t_{i}, t_{i-1})$ becomes the updated covariance\n\\end{itemize}\n\\underline{If a measurement is read in}, the algorithm computes the observation, the observation state matrix, and the Kalman Gain.\n\n\\begin{itemize}\n\\item The observation ($\\bm Y_i$) is compared to the observation model, giving the innovation: $\\bm y_i = \\bm Y_i - G(\\bm X_i^*, t_i)$\n\\item Compute the observation matrix along the reference trajectory: $\\tilde{H}_i = \\left[\\frac{\\partial \\bm G (\\bm X, t_i)}{\\partial \\bm X}\\right]^{*}$\n\\item Compute the Kalman Gain $K_i = \\bar{P}_i \\tilde{H_i}^T\\left(\\tilde{H_i} \\bar{P}_i \\tilde{H_i}^T + R_i \\right)^{-1}$\n\\end{itemize}\n\n\\subsubsection*{Measurement Update}\n\nDepending on the covariance, the filter can either update as a classic, linear Kalman Filter, or as the Extended Kalman filter.\nThis is done in order to assure robust and fast filter convergence. Indeed in a scenario with a very large initial covariance, the EKF's\nchange in reference trajectory could delay or inhibit the convergence. In order to remedy this, a few linear updates are performed if the \nmaximum value in the covariance is greater than a user-set threshold.\n\n\\underline{Linear update:}\n\n\\begin{itemize}\n\\item The state error is updated using the time updated value: $\\bm x_i =  \\bm \\bar{x}_i + K_i\\left[\\bm y_i - \\tilde{H}_i \\bm \\bar{x}_i \\right]$\n\\item The covariance is updated using the Joseph form of the covariance update equation:\n$P_i = \\left( I - K_i \\tilde{H}_i\\right) \\bar{P}_{i} \\left( I - K_i \\tilde{H}_i\\right)^T + K_i R_i K_i^T$\n\\item The reference state stays the same, and it's propagated value $\\bm X^*(t_i)$ becomes $\\bm X^*(t_{i-1})$\n\\end{itemize}\n\n \\underline{EKF update:}\n\n\\begin{itemize}\n\\item The state error is updated using the innovation and the Kalman Gain: $\\bm x_i =   K_i\\bm y_i $\n\\item The reference state is changed by the state error: $\\bm X^*(t_i) =  \\bm X^*(t_i) + \\bm x_i $\n\\item The covariance is updated using the Joseph form of the covariance update equation:\n$P_i = \\left( I - K_i \\tilde{H}_i\\right) \\bar{P}_{i} \\left( I - K_i \\tilde{H}_i\\right)^T + K_i R_i K_i^T$\n\\item The new reference state is now used $\\bm X^*(t_i)$ becomes $\\bm X^*(t_{i-1})$\n\\end{itemize}\n\n \n\n\n\\section{Test Design}\nThe unit test for the sunlineEKF module is located in:\\\\\n\n\\noindent\n{\\tt FswAlgorithms/attDetermination/sunlineEKF/$\\_$UnitTest/test$\\_$SunlineEKF.py} \\\\\n\nAs well as another python file containing plotting functions:\n\n\\noindent\n{\\tt FswAlgorithms/attDetermination/sunlineEKF/$\\_$UnitTest/SunlineEKF$\\_$test$\\_$utilities.py} \\\\\n\nThe test is split up into 4 subtests, the last one is parametrized in order to test different scenarios. The first test creaks up all of the individual filter methods and tests them individually. The second test verifies that in the case where the state is zeroed out from the start of the simulation, it remains at zero. The third test verifies the behavior of the time update in a general case. The final test is a full filter test.\n\n\\subsection{\\texttt{sunline$\\_$individual$\\_$test}}\n\nIn each of these individual tests, random inputs are fed to the methods and their values are computed in parallel in python. These two values are then compared to assure that the correct computations are taking place. \n\\begin{itemize}\n\\item \\underline{Dynamics Matrix}: This method computes the dynamics matrix $A$. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{State and STM propagation}: This method propagates the state using the $\\bm F$ function as well as the STM using $\\dot{\\Phi} = A \\Phi$. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{$H$ and $y$ propagation}: This method computes the $H$ matrix, and compares the measurements to the expected measurements given the state. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{Kalman gain}: This method computes the $K$ matrix. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{EKF update}: This method performs the measurement update in the case of an EKF. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\item \\underline{Linear Update}: This method performs the measurement update in the linear case. Tolerance to absolute error $\\epsilon = 10^{-10}$.\n\n\\textcolor{ForestGreen}{Passed}\n\\end{itemize}\n\n\\subsection{\\texttt{StatePropStatic}}\n\nThis test runs the filter with no measurements. It initializes with a zeroed state, and assures that at the end of the simulation all values are still at zero. Plotted results are seen in Figure \\ref{fig:StatesExpected}.\n\nTolerance to absolute error: $\\epsilon = 10^{-10}$\n\n\\textcolor{ForestGreen}{Passed}\n\n\\input{AutoTeX/StatesExpected.tex}\n\n\\subsection{\\texttt{StatePropVariable}}\n\nThis test also takes no measurements in, but gives a random state with rate of change. It then tests that the states and covariance are as expected throughout the time of simulation. Plotted results are seen in Figure \\ref{fig:StatesCompare}. We indeed see that the state and covariance for the test and the code overlap perfectly.\n\nTolerance to absolute error: $\\epsilon = 10^{-10}$\n\n\\textcolor{ForestGreen}{Passed}\n\\input{AutoTeX/StatesCompare.tex}\n\n\\subsection{\\texttt{Full Filter test}}\n\nThis test the filter working from start to finish. No measurements are taken in for the first 20 time steps. Then a heading is given through the CSS message. Halfway through the simulation, measurements stop, and 20 time steps later a different heading is read. The filter must be robust and detect this change. This test is parametrized for different test lengths, different initial conditions, different measured headings, and with or without measurement noise. All these are successful.\n\n\\vspace{0.2cm}\nTolerance to absolute error without measurement noise: $\\epsilon = 10^{-10}$\n\nTolerance to absolute error with measurement noise: $\\epsilon = 10^{-2}$\n\n\\textcolor{ForestGreen}{Passed}\n\nPlotted results are seen in Figures \\ref{fig:StatesPlot}, \\ref{fig:StatesTarget}, and \\ref{fig:PostFit}. Figure \\ref{fig:StatesPlot} shows the state error and covariance over the run. We see the covariance initially grow, then come down quickly as measurements are used. It grows once again as the measurements stop before bringing the state error back to zero with a change in sun heading. \n\nFigure \\ref{fig:StatesTarget} shows the evolution of the state vector compared to the true values. The parts where there is a slight delay is due to the fact that no observations are read in. \n\nFigure \\ref{fig:PostFit} shows the post fit residuals for the filter, with the $3\\sigma$ measurement noise values. We see that the observations are read in well an that the residuals are brought back down to noise. We do observe a slight bias in the noise. This could be due to the equations of motion, and is not concerning.\n\n\\input{AutoTeX/StatesPlot.tex}\n\\input{AutoTeX/StatesTarget.tex}\n\\input{AutoTeX/PostFit.tex}\n\n\\bibliographystyle{AAS_publication}   % Number the references.\n\\bibliography{references}   % Use references.bib to resolve the labels.\n\n\\end{document}\n", "meta": {"hexsha": "9f48958d95d5c10aa765c48869adb13d2b932e58", "size": 14490, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/fswAlgorithms/attDetermination/okeefeEKF/_Documentation/Okeefe_EKF.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/fswAlgorithms/attDetermination/okeefeEKF/_Documentation/Okeefe_EKF.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/fswAlgorithms/attDetermination/okeefeEKF/_Documentation/Okeefe_EKF.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.4539249147, "max_line_length": 489, "alphanum_fraction": 0.7416149068, "num_tokens": 4034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4255793686885255}}
{"text": "\\subsubsection{Yield Curves}\n\nThe top level XML elements for each \\lstinline!YieldCurve! node are shown in Listing \\ref{lst:top_level_yc}.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<YieldCurve>\n  <CurveId> </CurveId>\n  <CurveDescription> </CurveDescription>\n  <Currency> </Currency>\n  <DiscountCurve> </DiscountCurve>\n  <Segments> </Segments>\n  <InterpolationVariable> </InterpolationVariable>\n  <InterpolationMethod> </InterpolationMethod>\n  <ZeroDayCounter> </ZeroDayCounter>\n  <Tolerance> </Tolerance>\n  <Extrapolation> </Extrapolation>\n  <BootstrapConfig>\n    ...\n  </BootstrapConfig>\n</YieldCurve>\n\\end{minted}\n\\caption{Top level yield curve node}\n\\label{lst:top_level_yc}\n\\end{listing}\n\nThe meaning of each of the top level elements in Listing \\ref{lst:top_level_yc} is given below. If an element is labelled \nas 'Optional', then it may be excluded or included and left blank.\n\\begin{itemize}\n\\item CurveId: Unique identifier for the yield curve.\n\\item CurveDescription: A description of the yield curve. This field may be left blank.\n\\item Currency: The yield curve currency.\n\\item DiscountCurve: If the yield curve is being bootstrapped from market instruments, this gives the CurveId of the\nyield curve used to discount cash flows during the bootstrap procedure. If this field is left blank or set equal to the\ncurrent CurveId, then this yield curve itself is used to discount cash flows during the bootstrap procedure.\n\\item Segments: This element contains child elements and is described in the following subsection.\n\\item InterpolationVariable [Optional]: The variable on which the interpolation is performed. The allowable values are\ngiven in Table \\ref{tab:allow_interp_variables}. If the element is omitted or left blank, then it defaults to\n\\emph{Discount}.\n\\item InterpolationMethod [Optional]: The interpolation method to use. The allowable values are given in Table\n\\ref{tab:allow_interp_methods}. If the element is omitted or left blank, then it defaults to \\emph{LogLinear}.\n\\item ZeroDayCounter [Optional]: The day count basis used internally by the yield curve to calculate the time between\ndates. In particular, if the curve is queried for a zero rate without specifying the day count basis, the zero rate that\nis returned has this basis. If the element is omitted or left blank, then it defaults to \\emph{A365}.\n\n\\item \\lstinline!Tolerance! [Optional]: The tolerance used by the root finding procedure in the bootstrapping algorithm. If the\nelement is omitted or left blank, then it defaults to \\num[scientific-notation=true]{1.0e-12}. It is preferable to use the \n\\lstinline!Accuracy! node in the \\lstinline!BootstrapConfig! node below for specifying this value. However, if this node is \nexplicitly supplied, it takes precedence for backwards compatibility purposes.\n\n\\item Extrapolation [Optional]: Set to \\emph{True} or \\emph{False} to enable or disable extrapolation respectively. If\nthe element is omitted or left blank, then it defaults to \\emph{True}.\n\n\\item \\lstinline!BootstrapConfig! [Optional]: this node holds configuration details for the iterative bootstrap \nthat are described in section \\ref{sec:bootstrap_config}. If omitted, this node's default values described \nin section \\ref{sec:bootstrap_config} are used.\n\n\\end{itemize}\n\n\\begin{table}[h]\n\\centering\n  \\begin{tabular}{|l|l|}\n    \\hline\n    {\\bfseries Variable} & {\\bfseries Description} \\\\\n    \\hline\n    Zero & The continuously compounded zero rate \\\\ \\hline\n    Discount & The discount factor \\\\ \\hline\n    Forward & The instantaneous forward rate \\\\ \\hline \n  \\end{tabular}\n  \\caption{Allowable interpolation variables.}\n  \\label{tab:allow_interp_variables}\n\\end{table}\n\n\\begin{table}[h]\n\\centering\n  \\begin{tabular} {|l|p{10cm}|}\n    \\hline\n    {\\bfseries Method} & {\\bfseries Description} \\\\\n    \\hline\n    Linear & Linear interpolation \\\\ \\hline\n    LogLinear & Linear interpolation on the natural log of the interpolation variable \\\\ \\hline\n    NaturalCubic & Monotonic Kruger cubic interpolation with second derivative at left and right \\\\ \\hline\n    FinancialCubic & Monotonic Kruger cubic interpolation with second derivative at left and \n                     first derivative at right \\\\ \\hline\n    ConvexMonotone & Convex Monotone Interpolation (Hagan, West) \\\\ \\hline\n    Quadratic & Quadratic interpolation \\\\ \\hline\n    LogQuadratic & Quadratic interpolation on the natural log of the interpolation variable \\\\ \\hline\n    Hermite & Hermite cubic spline interpolation \\\\ \\hline\n    CubicSpline & Non-monotonic cubic spline interpolation with second derivative at left and right \\\\ \\hline\n    ExponentialSplines & Exponential Spline curve fitting, for Fitted Bond Curves only \\\\ \\hline\n    NelsonSiegel & Nelson-Siegel curve fitting, for Fitted Bond Curves only \\\\ \\hline\n    Svensson & Svensson curve fitting, for Fitted Bond Curves only \\\\ \\hline\n  \\end{tabular}\n  \\caption{Allowable interpolation methods.}\n  \\label{tab:allow_interp_methods}\n\\end{table}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\\subsubsection*{Segments Node} \\label{ss:segments_node}\n%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nThe \\lstinline!Segments! node gives the zero rates, discount factors and instruments that comprise the yield curve. This\nnode consists of a number of child nodes where the node name depends on the segment being described. Each node has a\n\\lstinline!Type! that determines its structure. The following sections describe the type of child nodes that are\navailable. Note that for all segment types below, with the exception of \\lstinline!DiscountRatio! and \\lstinline!AverageOIS!, the \n\\lstinline!Quote! elements within the \\lstinline!Quotes! node may have an \\lstinline!optional! attribute indicating whether or\nnot the quote is optional. Example:\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<Quotes>\n  <Quote optional=\"true\"></Quote>\n</Quotes>\n\\end{minted}\n%\\hrule\n\n\\subsubsection*{Direct Segment}\nWhen the node name is \\lstinline!Direct!, the \\lstinline!Type! node has the value \\emph{Zero} or \\emph{Discount} and the\nnode has the structure shown in Listing \\ref{lst:direct_segment}. We refer to this segment here as a direct segment\nbecause the discount factors, or equivalently the zero rates, are given explicitly and do not need to be\nbootstrapped. The \\lstinline!Quotes! node contains a list of \\lstinline!Quote! elements. Each \\lstinline!Quote! element\ncontains an ID pointing to a line in the {\\tt market.txt} file, i.e.\\ in this case, pointing to a particular zero rate\nor discount factor. The \\lstinline!Conventions! node contains the ID of a node in the {\\tt conventions.xml} file\ndescribed in section \\ref{sec:conventions}. The \\lstinline!Conventions! node associates conventions with the quotes.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<Direct>\n  <Type> </Type>\n  <Quotes>\n    <Quote> </Quote>\n    <Quote> </Quote>\n     <!--...-->\n  </Quotes>\n  <Conventions> </Conventions>\n</Direct>\n\\end{minted}\n\\caption{Direct yield curve segment}\n\\label{lst:direct_segment}\n\\end{listing}\n\n\n\\subsubsection*{Simple Segment}\nWhen the node name is \\lstinline!Simple!, the \\lstinline!Type! node has the value \\emph{Deposit}, \\emph{FRA},\n\\emph{Future}, \\emph{OIS}, \\emph{Swap} or \\emph{BMA Basis Swap} and the node has the structure shown in Listing\n\\ref{lst:simple_segment}. This segment holds quotes for a set of deposit, FRA, Future, OIS or swap instruments\ncorresponding to the value in the \\lstinline!Type! node. These quotes will be used by the bootstrap algorithm to imply\na discount factor, or equivalently a zero rate, curve. The only difference between this segment and the direct segment\nis that there is a \\lstinline!ProjectionCurve! node. This node allows us to specify the CurveId of another curve to\nproject floating rates on the instruments underlying the quotes listed in the \\lstinline!Quote! nodes during the\nbootstrap procedure. This is an optional node. If it is left blank or omitted, then the projection curve is assumed to\nequal the curve being bootstrapped i.e.\\ the current CurveId.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<Simple>\n  <Type> </Type>\n  <Quotes>\n    <Quote> </Quote>\n    <Quote> </Quote>\n    <!--...-->\n  </Quotes>\n  <Conventions> </Conventions>\n  <ProjectionCurve> </ProjectionCurve>\n</Simple>\n\\end{minted}\n\\caption{Simple yield curve segment}\n\\label{lst:simple_segment}\n\\end{listing}\n\n\\subsubsection*{Average OIS Segment}\nWhen the node name is \\lstinline!AverageOIS!, the \\lstinline!Type! node has the value \\emph{Average OIS} and the node\nhas the structure shown in Listing \\ref{lst:average_ois_segment}. This segment is used to hold quotes for Average OIS\nswap instruments. The \\lstinline!Quotes! node has the structure shown in Listing \\ref{lst:average_ois_quotes}. Each\nquote for an Average OIS instrument (a typical example in a USD Overnight Index Swap) consists of two quotes, a vanilla\nIRS quote and an OIS-LIBOR basis swap spread quote.  The IDs of these two quotes are stored in the\n\\lstinline!CompositeQuote! node. The \\lstinline!RateQuote! node holds the ID of the vanilla IRS quote and the\n\\lstinline!SpreadQuote! node holds the ID of the OIS-LIBOR basis swap spread quote.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<AverageOIS>\n  <Type> </Type>\n  <Quotes>\n    <CompositeQuote> </CompositeQuote>\n    <CompositeQuote> </CompositeQuote>\n    <!--...-->\n  </Quotes>\n  <Conventions> </Conventions>\n  <ProjectionCurve> </ProjectionCurve>\n</AverageOIS>\n\\end{minted}\n\\caption{Average OIS yield curve segment}\n\\label{lst:average_ois_segment}\n\\end{listing}\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<Quotes>\n  <CompositeQuote>\n    <SpreadQuote> </SpreadQuote>\n    <RateQuote> </RateQuote>\n  </CompositeQuote>\n  <!--...-->\n</Quotes>\n\\end{minted}\n\\caption{Average OIS segment's quotes section}\n\\label{lst:average_ois_quotes}\n\\end{listing}\n\n\\subsubsection*{Tenor Basis Segment}\nWhen the node name is \\lstinline!TenorBasis!, the \\lstinline!Type! node has the value \\emph{Tenor Basis Swap} or\n\\emph{Tenor Basis Two Swaps} and the node has the structure shown in Listing \\ref{lst:tenor_basis_segment}. This segment\nis used to hold quotes for tenor basis swap instruments. The quotes may be for a conventional tenor basis swap where\nIbor of one tenor is swapped for Ibor of another tenor plus a spread. In this case, the \\lstinline!Type! node has the\nvalue \\emph{Tenor Basis Swap}. The quotes may also be for the difference in fixed rates on two fair swaps where one swap\nis against Ibor of one tenor and the other swap is against Ibor of another tenor. In this case, the \\lstinline!Type!\nnode has the value \\emph{Tenor Basis Two Swaps}. Again, the structure is similar to the simple segment in Listing\n\\ref{lst:simple_segment} except that there are two projection curve nodes. There is a \\lstinline!ProjectionCurveShort!\nnode for the index with the shorter tenor. This node holds the CurveId of a curve for projecting the floating rates on\nthe short tenor index. Similarly, there is a \\lstinline!ProjectionCurveLong! node for the index with the longer\ntenor. This node holds the CurveId of a curve for projecting the floating rates on the long tenor index. These are\noptional nodes. If they are left blank or omitted, then the projection curve is assumed to equal the curve being\nbootstrapped i.e.\\ the current CurveId. However, at least one of the nodes needs to be populated to allow the bootstrap\nto proceed.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<TenorBasis>\n  <Type> </Type>\n  <Quotes>\n    <Quote> </Quote>\n    <Quote> </Quote>\n    <!--...-->\n  </Quotes>\n  <Conventions> </Conventions>\n  <ProjectionCurveLong> </ProjectionCurveLong>\n  <ProjectionCurveShort> </ProjectionCurveShort>\n</TenorBasis>\n\\end{minted}\n\\caption{Tenor basis yield curve segment}\n\\label{lst:tenor_basis_segment}\n\\end{listing}\n\n\\subsubsection*{Cross Currency Segment}\nWhen the node name is \\lstinline!CrossCurrency!, the \\lstinline!Type! node has the value \\emph{FX Forward},\n\\emph{Cross Currency Basis Swap} or \\emph{Cross Currency Fix Float Swap}. When the \\lstinline!Type! node has the value\n\\emph{FX Forward}, the node has the structure shown in Listing \\ref{lst:fx_forward_segment}. This segment is used to\nhold quotes for FX forward instruments. The \\lstinline!DiscountCurve! node holds the CurveId of a curve used to\ndiscount cash flows in the other currency i.e.\\ the currency in the currency pair that is not equal to the currency in\nListing \\ref{lst:top_level_yc}. The \\lstinline!SpotRate! node holds the ID of a spot FX quote for the currency pair that\nis looked up in the {\\tt market.txt} file.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<CrossCurrency>\n  <Type> </Type>\n  <Quotes>\n    <Quote> </Quote>\n    <Quote> </Quote>\n          ...\n  </Quotes>\n  <Conventions> </Conventions>\n  <DiscountCurve> </DiscountCurve>\n  <SpotRate> </SpotRate>\n</CrossCurrency>\n\\end{minted}\n\\caption{FX forward yield curve segment}\n\\label{lst:fx_forward_segment}\n\\end{listing}\n\nWhen the \\lstinline!Type! node has the value \\emph{Cross Currency Basis Swap} then the node has the structure shown in\nListing \\ref{lst:xccy_basis_segment}. This segment is used to hold quotes for cross currency basis swap instruments. The\n\\lstinline!DiscountCurve! node holds the CurveId of a curve used to discount cash flows in the other currency i.e.\\ the\ncurrency in the currency pair that is not equal to the currency in Listing \\ref{lst:top_level_yc}. The\n\\lstinline!SpotRate! node holds the ID of a spot FX quote for the currency pair that is looked up in the {\\tt\n  market.txt} file. The \\lstinline!ProjectionCurveDomestic! node holds the CurveId of a curve for projecting the\nfloating rates on the index in this currency i.e.\\ the currency in the currency pair that is equal to the currency in\nListing \\ref{lst:top_level_yc}. It is an optional node and if it is left blank or omitted, then the projection curve is\nassumed to equal the curve being bootstrapped i.e.\\ the current CurveId. Similarly, the\n\\lstinline!ProjectionCurveForeign! node holds the CurveId of a curve for projecting the floating rates on the index in\nthe other currency. If it is left blank or omitted, then it is assumed to equal the CurveId provided in the\n\\lstinline!DiscountCurve! node in this segment.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<CrossCurrency>\n  <Type> </Type>\n  <Quotes>\n    <Quote> </Quote>\n    <Quote> </Quote>\n          ...\n  </Quotes>\n  <Conventions> </Conventions>\n  <DiscountCurve> </DiscountCurve>\n  <SpotRate> </SpotRate>\n  <ProjectionCurveDomestic> </ProjectionCurveDomestic>\n  <ProjectionCurveForeign> </ProjectionCurveForeign>\n</CrossCurrency>\n\\end{minted}\n\\caption{Cross currency basis yield curve segment}\n\\label{lst:xccy_basis_segment}\n\\end{listing}\n\n\\subsubsection*{Zero Spread Segment}\n\nWhen the node name is \\lstinline!ZeroSpread!, the \\lstinline!Type!\nnode has the only allowable value \\emph{Zero Spread},  and the node has the structure shown in \nListing \\ref{lst:zero_spread_segment}. This segment is used to build yield\ncurves which are expressed as a spread over some reference yield curve.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n    <ZeroSpread>\n          <Type>Zero Spread</Type>\n          <Quotes>\n            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/2Y</Quote>\n            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/5Y</Quote>\n            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/10Y</Quote>\n            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/20Y</Quote>\n          </Quotes>\n          <Conventions>EUR-ZERO-CONVENTIONS-TENOR-BASED</Conventions>\n          <ReferenceCurve>EUR1D</ReferenceCurve>\n    </ZeroSpread>\n\\end{minted}\n\\caption{Zero spread yield curve segment}\n\\label{lst:zero_spread_segment}\n\\end{listing}\n\n\n\\subsubsection*{Fitted Bond Segment}\n\\label{sec:fitted_bond_segment}\n\nWhen the node name is \\lstinline!FittedBond!, the \\lstinline!Type! node has the only allowable value \\emph{FittedBond},\nand the node has the structure shown in Listing \\ref{lst:fitted_bond_segment}. This segment is used to build yield\ncurves which are fitted to liquid bond prices. The segment has the following elements:\n\n\\begin{itemize}\n\\item Quotes: a list of bond price quotes, for each security in the list, reference data must be available\n\\item IborIndexCurves: for each Ibor index that is required by one of the bonds to which the curve is fitted, a mapping\n  to an estimation curve for that index must be provided\n\\item ExtrapolateFlat: if true, the parametric curve is extrapolated flat in the instantaneous forward rate before the\n  first and after the last maturity of the bonds in the calibration basket. This avoids unrealistic rates at the short\n  end or for long maturities in the resulting curve.\n\\end{itemize}\n\nThe \\lstinline!BootstrapConfig! has the following interpretation for a fitted bond curve:\n\n\\begin{itemize}\n\\item Accuracy [Optional, defaults to 1E-12]: the desired accuracy expressed as a weighted rmse in the implied quote,\n  where 0.01 = 1 bp. Once this accuracy is reached in a calibration trial, the fit is accepted, no further calibration\n  trials re run. In general, this parameter should be set to a higher than the default value for fitted bond curves.\n\\item GlobalAccuracy [Optional]: the acceptable accuracy. If the Accuracy is not reached in any calibration trial, but\n  the GloablAccuracy is met, the best fit among the calibration trials is selected as a result of the calibration. If\n  not given, the best calibration trial is compared to the Accuracy parameter instead.\n\\item DontThrow [Optional, defaults to false]: If true, the best calibration is always accepted as a result, i.e. no\n  error is thrown even if the GlobalAccuracy is breached.\n\\item MaxAttempts [Optional, defaults to 5]: The maximum number of calibration trials. Each calibration trial is run with a random calibratio\n  seed. Random calibration seeds are currently only supported for the NelsonSiegel interpolation method.\n\\end{itemize}\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n    <YieldCurve>\n      ...\n      <Segments>\n        <FittedBond>\n          <Type>FittedBond</Type>\n          <Quotes>\n            <Quote>BOND/PRICE/SECURITY_1</Quote>\n            <Quote>BOND/PRICE/SECURITY_2</Quote>\n            <Quote>BOND/PRICE/SECURITY_3</Quote>\n            <Quote>BOND/PRICE/SECURITY_4</Quote>\n            <Quote>BOND/PRICE/SECURITY_5</Quote>\n          </Quotes>\n          <!-- mapping of Ibor curves used in the bonds from which the curve is built -->\n          <IborIndexCurves>\n            <IborIndexCurve iborIndex=\"EUR-EURIBOR-6M\">EUR-EURIBOR-6M</IborIndexCurve>\n          </IborIndexCurves>\n          <!-- flat extrapolation before first and after last bond maturity -->\n          <ExtrapolateFlat>true</ExtrapolateFlat>\n        </FittedBond>\n      </Segments>\n      <!-- NelsonSiegel, Svensson, ExponentialSplines -->\n      <InterpolationMethod>NelsonSiegel</InterpolationMethod>\n      <YieldCurveDayCounter>A365</YieldCurveDayCounter>\n      <Extrapolation>true</Extrapolation>\n      <BootstrapConfig>\n        <!-- desired accuracy (in implied quote) -->\n        <Accuracy>0.1</Accuracy>\n        <!-- tolerable accuracy -->\n        <GlobalAccuracy>0.5</GlobalAccuracy>\n        <!-- do not throw even if tolerable accuracy is breached -->\n        <DontThrow>false</DontThrow>\n        <!-- max calibration trials to reach desired accuracy -->\n        <MaxAttempts>20</MaxAttempts>\n      </BootstrapConfig>\n    </YieldCurve>\n\\end{minted}\n\\caption{Fitted bond yield curve segment}\n\\label{lst:fitted_bond_segment}\n\\end{listing}\n\n\\subsubsection*{Yield plus Default Segment}\n\\label{sec:yield_plus_default}\n\nWhen the node name is \\lstinline!YieldPlusDefault!, the \\lstinline!Type! node has the only allowable value \\emph{Yield\n Plus Default}, and the node has the structure shown in Listing \\ref{lst:yield_plus_default_segment}. This segment is\nused to build all-in discounting yield curves from a benchmark curve and (a weighted sum of) default curves. The\nconstruction is in some sense inverse to the benchmark default curve construction, see \\ref{ss:benchmark_default_curve}.\n\n\\begin{itemize}\n\\item ReferenceCurve: the benchmark yield curve serving as the basis of the resulting yield curve\n\\item DefaultCurves: a list of default curves whose weighted sum is added to the benchmark yield curve\n\\item Weights: a list of weights for the default curves, the number of weights must match the number of default curves\n\\end{itemize}\n\nNotice that it is explicitly allowed to use default curves in different currencies than the benchmark yield curve. In\nthe construction, the hazard rate is reinterpreted as an instantaneous forward rate, and the sum of the curves is being\nbuilt in the instantaneous forward rate.\n\nThe definition takes into account the recovery rates associated to each default curve. The resulting discount factor is\ncomputed as\n\n\\begin{equation}\nP(0,t) = \\prod_i  S_i(t)^{(1-R)w_i}\n\\end{equation}\n\nwhere $S_i$ and $R_i$ are the survival probabilities and recovery rates of the source default curves, and $w_i$ are the\nweights.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n  <YieldCurve>\n    <CurveId>BenchmarkPlusDefault</CurveId>\n    <CurveDescription>USD Libor 3M + 0.5 x CDX.NA.HY + 0.5 x EUR.10BP</CurveDescription>\n    <Currency>USD</Currency>\n    <DiscountCurve/>\n    <Segments>\n      <YieldPlusDefault>\n        <Type>Yield Plus Default</Type>\n        <ReferenceCurve>USD3M</ReferenceCurve>\n        <DefaultCurves>\n          <DefaultCurve>Default/USD/CDX.NA.HY</DefaultCurve>\n          <DefaultCurve>Default/EUR/EUR.10BP</DefaultCurve>\n        </DefaultCurves>\n        <Weights>\n          <Weight>0.5</Weight>\n          <Weight>0.5</Weight>\n        </Weights>\n      </YieldPlusDefault>\n    </Segments>\n  </YieldCurve>\n</YieldCurves>\n\\end{minted}\n\\caption{Yield plus default curve segment}\n\\label{lst:yield_plus_default_segment}\n\\end{listing}\n\n\\subsubsection*{Weighted Average Segment}\n\\label{sec:weigthed_average}\n\nWhen the node name is \\lstinline!WeightedAverage!, the \\lstinline!Type! node has the only allowable value\n\\emph{Weighted Average}, and the node has the structure shown in Listing \\ref{lst:weighted_average_segment}. This segment\nis used to build a curve with instantaneous forward rates that are the weighted sum of instantaneous forward rates of\nreference curves. This way a projection curve for non-standard Ibor curves can be build, e.g. to project a Euribor2M\nindex using the curves for 1M and 3M.\n\n\\begin{itemize}\n\\item ReferenceCurve1: the first source curve\n\\item ReferenceCurve2: the second source curve\n\\item Weight1: the weight of the first curve\n\\item Weights: the weight of the second curve\n\\end{itemize}\n\nIf $P_1(0,t)$ and $P_2(0,t)$ denote the discount factors of the two reference curves, the discount factor $P(0,t)$ of\nthe resulting curve is defined as\n\n\\begin{equation}\nP(0,t) = P_1(0,t)^{w_1}P_2(0,t)^{w_2}\n\\end{equation}\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<YieldCurve>\n  <CurveId>EUR2M</CurveId>\n  <CurveDescription>Euribor2M forwarding curve, interpolated from 1M and 3M</CurveDescription>\n  <Currency>EUR</Currency>\n  <DiscountCurve>EUR1D</DiscountCurve>\n  <Segments>\n    <WeightedAverage>\n      <Type>Weighted Average</Type>\n      <ReferenceCurve1>EUR1M</ReferenceCurve1>\n      <ReferenceCurve2>EUR3M</ReferenceCurve2>\n      <Weight1>0.5</Weight1>\n      <Weight2>0.5</Weight2>\n    </WeightedAverage>\n  </Segments>\n</YieldCurve>\n\\end{minted}\n\\caption{Weighted Average yield curve segment}\n\\label{lst:weighted_average_segment}\n\\end{listing}\n\n\\subsubsection*{Ibor Fallback Segment}\n\\label{sec:ibor_fallback_curve_segment}\n\nWhen the node name is \\lstinline!IborFallback!, the \\lstinline!Type! node has the only allowable value \\emph{Ibor\n  Fallback}, and the node has the structure shown in Listing \\ref{lst:ibor_fallback_segment}. This segment is used to\nbuild a projection curve for an Ibor index based on a risk free rate and a spread.\n\n\\begin{listing}[H]\n%\\hrule\\medskip\n\\begin{minted}[fontsize=\\footnotesize]{xml}\n<YieldCurve>\n  <CurveId>USD-LIBOR-3M</CurveId>\n  <CurveDescription>USD-Libor-3M built from USD-SOFR plus spread</CurveDescription>\n  <Currency>USD</Currency>\n  <DiscountCurve/>\n  <Segments>\n    <IborFallback>\n      <Type>Ibor Fallback</Type>\n      <IborIndex>USD-LIBOR-3M</IborIndex>\n      <RfrCurve>Yield/USD/USD-SOFR</RfrCurve>\n      <!-- optional, if not given the rfr index and sprad are read from the ibor\n           fallback configuration -->\n      <RfrIndex>USD-SOFR</RfrIndex>\n      <Spread>0.0026161</Spread>\n    </IborFallback>\n  </Segments>\n</YieldCurve>\n\\end{minted}\n\\caption{Ibor fallback segment}\n\\label{lst:ibor_fallback_segment}\n\\end{listing}\n", "meta": {"hexsha": "9fb4ac6d3182f28249d19ce1556aa74ad2d53c25", "size": 25133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/UserGuide/curve_configurations/yieldcurves.tex", "max_stars_repo_name": "mrslezak/Engine", "max_stars_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 335, "max_stars_repo_stars_event_min_datetime": "2016-10-07T16:31:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T07:12:03.000Z", "max_issues_repo_path": "Docs/UserGuide/curve_configurations/yieldcurves.tex", "max_issues_repo_name": "mrslezak/Engine", "max_issues_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-10-31T04:20:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T16:39:57.000Z", "max_forks_repo_path": "Docs/UserGuide/curve_configurations/yieldcurves.tex", "max_forks_repo_name": "mrslezak/Engine", "max_forks_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 180, "max_forks_repo_forks_event_min_datetime": "2016-10-08T14:23:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T10:43:05.000Z", "avg_line_length": 46.1155963303, "max_line_length": 141, "alphanum_fraction": 0.7464289977, "num_tokens": 6628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.42554503797113946}}
{"text": "\\chapter{Classification}\n\n\\section{Introduction}\n\nImage classification consists in extracting added-value information from images. \nSuch processing methods classify pixels within images into geographical connected \nzones with similar properties, and identified by a common class label. The \nclassification can be either unsupervised or supervised.\n\nUnsupervised classification does not require any additional information about the\nproperties of the input image to classify it. On the contrary, supervised methods \nneed a preliminary learning to be computed over training datasets having similar \nproperties than the image to classify, in order to build a classification model.\n\n%In statistical classification, each object is represented by $d$ features (a\n%measurement vector), and the goal of classification becomes finding compact and\n%disjoint regions (decision regions\\cite{Duda2000}) for classes in a\n%$d$-dimensional feature space. Such decision regions are defined by decision\n%rules that are known or can be trained.  The simplest configuration of a\n%classification consists of a decision rule and multiple membership functions;\n%each membership function represents a class. Figure~\\ref{fig:simple}\n%illustrates this general framework.\n\n%\\begin{figure}[h]\n%  \\centering\n%  \\includegraphics[width=0.7\\textwidth]{DudaClassifier.eps}\n%  \\itkcaption[Simple conceptual classifier]{Simple conceptual classifier.}\n%  \\label{fig:simple}\n%\\end{figure}\n\n%This framework closely follows that of Duda and\n%Hart\\cite{Duda2000}. The classification process can be described\n%as follows:\n\n%\\begin{enumerate}\n%\\item{A measurement vector is input to each membership function.}\n%\\item{Membership functions feed the membership scores to the\n%    decision rule.}\n%\\item{A decision rule compares the membership scores and returns a\n%    class label.}\n%\\end{enumerate}\n\n%\\begin{figure}\n%  \\centering\n%  \\includegraphics[width=0.7\\textwidth]{StatisticalClassificationFramework.eps}\n%  \\itkcaption[Statistical classification framework]{Statistical classification\n%framework.}\n%  \\protect\\label{fig:StatisticalClassificationFramework}\n%\\end{figure}\n\n%This simple configuration can be used to formulated various classification\n%tasks by using different membership functions and incorporating task specific\n%requirements and prior knowledge into the decision rule. For example, instead\n%of using probability density functions as membership functions, through\n%distance functions and a minimum value decision rule (which assigns a class\n%from the distance function that returns the smallest value) users can achieve a\n%least squared error classifier. As another example, users can add a rejection\n%scheme to the decision rule so that even in a situation where the membership\n%scores suggest a ``winner'', a measurement vector can be flagged as ill\n%defined. Such a rejection scheme can avoid risks of assigning a class label\n%without a proper win margin.\n\n%Note that to use these concepts into your own programs, you might have to link\n%to other OTB libraries (edit the \\code{TARGET\\_LINK\\_LIBRARIES} to add them),\n%for example OTBLearning, OTBMarkov.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Machine Learning Framework}\n\n\\subsection{Machine learning models}\n\\label{sec:MLGenericFramework}\n\nThe OTB classification is implemented as a generic Machine Learning\nframework, supporting several possible machine learning libraries as backends.\nThe base class \\doxygen{otb}{MachineLearningModel} defines this framework.\nAs of now libSVM (the machine learning library historically integrated in OTB),\nmachine learning methods of OpenCV library (\\cite{opencv_library}) and also\nShark machine learning library (\\cite{shark_library}) are available. Both\nsupervised and unsupervised classifiers are supported in the framework.\n\nThe current list of classifiers available through the same generic interface within the OTB is:\n\n\\begin{itemize}\n  \\item \\textbf{LibSVM}: Support Vector Machines classifier based on libSVM.\n  \\item \\textbf{SVM}: Support Vector Machines classifier based on OpenCV, itself based on libSVM.\n  \\item \\textbf{Bayes}: Normal Bayes classifier based on OpenCV.\n  \\item \\textbf{Boost}: Boost classifier based on OpenCV.\n  \\item \\textbf{DT}: Decision Tree classifier based on OpenCV.\n  \\item \\textbf{RF}: Random Forests classifier based on the Random Trees in OpenCV.\n  \\item \\textbf{GBT}: Gradient Boosted Tree classifier based on OpenCV (removed in version 3).\n  \\item \\textbf{KNN}: K-Nearest Neighbors classifier based on OpenCV.\n  \\item \\textbf{ANN}: Artificial Neural Network classifier based on OpenCV.\n  \\item \\textbf{SharkRF} : Random Forests classifier based on Shark.\n  \\item \\textbf{SharkKM} : KMeans unsupervised classifier based on Shark.\n\\end{itemize}\n\nThese models have a common interface, with the following major functions:\n\\begin{itemize}\n  \\item \\code{SetInputListSample(InputListSampleType *in)} : set the list of input samples\n  \\item \\code{SetTargetListSample(TargetListSampleType *in)} : set the list of target samples\n  \\item \\code{Train()} : train the model based on input samples\n  \\item \\code{Save(...)} : saves the model to file\n  \\item \\code{Load(...)} : load a model from file\n  \\item \\code{Predict(...)} : predict a target value for an input sample\n  \\item \\code{PredictBatch(...)} : prediction on a list of input samples\n\\end{itemize}\n\nThe \\code{PredictBatch(...)} function can be multi-threaded when\ncalled either from a multi-threaded filter, or from a single location. In\nthe later case, it creates several threads using OpenMP.\nThere is a factory mechanism on top of the model class (see\n\\doxygen{otb}{MachineLearningModelFactory}). Given an input file,\nthe static function \\code{CreateMachineLearningModel(...)} is able\nto instantiate a model of the right type.\n\nFor unsupervised models, the target samples \\textbf{still have to be set}. They\nwon't be used so you can fill a ListSample with zeros.\n\n%-------------------------------------------------------------------------------\n\\subsection{Training a model}\n\nThe models are trained from a list of input samples, stored in a\n\\subdoxygen{itk}{Statistics}{ListSample}. For supervised classifiers, they\nalso need a list of targets associated to each input sample. Whatever the\nsource of samples, it has to be converted into a \\code{ListSample} before\nbeing fed into the model.\n\nThen, model-specific parameters can be set. And finally, the \\code{Train()}\nmethod starts the learning step. Once the model is trained it can be saved\nto file using the function \\code{Save()}. The following examples show how\nto do that.\n\n\\input{TrainMachineLearningModelFromSamplesExample.tex}\n\n\\input{TrainMachineLearningModelFromImagesExample.tex}\n\n%-------------------------------------------------------------------------------\n\\subsection{Prediction of a model}\n\nFor the prediction step, the usual process is to:\n\\begin{itemize}\n\\item Load an existing model from a file.\n\\item Convert the data to predict into a \\code{ListSample}.\n\\item Run the \\code{PredictBatch(...)} function.\n\\end{itemize}\n\nThere is an image filter that perform this step on a whole image, supporting\nstreaming and multi-threading: \\doxygen{otb}{ImageClassificationFilter}.\n\n\\ifitkFullVersion\n\\input{SupervisedImageClassificationExample.tex}\n\\fi\n\n%-------------------------------------------------------------------------------\n\\subsection{Integration in applications}\n\nThe classifiers are integrated in several OTB Applications. There is a base\nclass that provides an easy access to all the classifiers:\n\\subdoxygen{otb}{Wrapper}{LearningApplicationBase}. As each machine learning\nmodel has a specific set of parameters, the base class\n\\code{LearningApplicationBase} knows how to expose each type of classifier with\nits dedicated parameters (a task that is a bit tedious so we want to implement\nit only once). The \\code{DoInit()} method creates a choice parameter named\n\\code{classifier} which contains the different supported classifiers along\nwith their parameters.\n\nThe function \\code{Train(...)} provide an easy way to train the selected\nclassifier, with the corresponding parameters, and save the model to file.\n\nOn the other hand, the function \\code{Classify(...)} allows to load a model\nfrom file and apply it on a list of samples.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Supervised classification}\n\n\\subsection{Support Vector Machines}\n\\label{sec:SupportVectorMachines}\n\n\\subsubsection{SVM general description}\nKernel based learning methods in general and the Support Vector\nMachines (SVM) in particular, have been introduced in the last years\nin learning theory for classification and regression tasks,\n\\cite{vapnik}. SVM have been successfully applied to text\ncategorization, \\cite{joachims}, and face recognition,\n\\cite{osuna}. Recently, they have been successfully used for the\nclassification of hyperspectral remote-sensing images, \\cite{bruzzoneSVM}.\n\nSimply stated, the approach consists in searching for the separating\nsurface between 2 classes by the determination of the subset of\ntraining samples which best describes the boundary between the 2\nclasses. These samples are called support vectors and completely\ndefine the classification system. In the case where the two classes are\nnonlinearly separable, the method uses a kernel expansion in order to make\nprojections of the feature space onto higher dimensionality spaces\nwhere the separation of the classes becomes linear.\n\n\n\\subsubsection{SVM mathematical formulation}\n\nThis subsection reminds the basic principles of SVM learning and\nclassification. A good tutorial on SVM can be found in, \\cite{burges}.\n \nWe have $N$ samples represented by the couple $(y_i,\\mathbf{x}_i),\ni=1\\ldots N$ where $y_i \\in \\{-1,+1\\}$ is the class label and\n$\\mathbf{x}_i \\in \\mathbb{R}^n$ is the feature vector of dimension\n$n$. A classifier is a function  $$f(\\mathbf{x},\\boldsymbol{\\alpha}) :\n\\mathbf{x}\\mapsto y$$ where $\\boldsymbol{\\alpha}$ are the classifier\nparameters. The SVM finds the optimal separating hyperplane which\nfulfills the following constraints :\n    \\begin{itemize}\n      \\item The samples with labels $+1$ and $-1$ are on different\n      sides of the hyperplane.\n      \\item The distance of the closest vectors to the hyperplane is\n      maximised. These are the support vectors (SV) and this distance is\n      called the margin.\n    \\end{itemize}\n\n    The separating hyperplane has the equation\n    $$\\mathbf{w}\\cdot\\mathbf{x}+b=0;$$ with $\\mathbf{w}$ being its\n    normal vector and $x$ being any point of the hyperplane. The\n    orthogonal distance to the origin is given by\n    $\\frac{|b|}{\\|\\mathbf{w}\\|}$. Vectors located outside the\n    hyperplane have either $\\mathbf{w}\\cdot\\mathbf{x}+b>0$ or\n      $\\mathbf{w}\\cdot\\mathbf{x}+b<0$.\n\n    Therefore, the classifier function can be written as\n    $$f(\\mathbf{x},\\mathbf{w}, b)=sgn(\\mathbf{w}\\cdot\\mathbf{x}+b).$$\n    \nThe SVs are placed on two hyperplanes which are parallel to the\n      optimal separating one. In order to find the optimal\n      hyperplane, one sets $\\mathbf{w}$ and\n      $b$ : $$\\mathbf{w}\\cdot\\mathbf{x}+b=\\pm 1.$$\n\nSince there must not be any vector inside the margin, the following\nconstraint can be used:\n    $$\\mathbf{w}\\cdot\\mathbf{x}_i+b\\ge +1\\text{ if }y_i=+1;$$\n    $$\\mathbf{w}\\cdot\\mathbf{x}_i+b\\le -1\\text{ if }y_i=-1;$$ which\n    can be rewritten as $$y_i(\\mathbf{w}\\cdot\\mathbf{x}_i+b)-1\\ge 0~  ~ \\forall i.$$\n\n    The orthogonal distances of the 2 parallel hyperplanes to the\n    origin are $\\frac{|1-b|}{\\|\\mathbf{w}\\|}$ and\n      $\\frac{|-1-b|}{\\|\\mathbf{w}\\|}$. Therefore the modulus of the\n    margin is equal to $\\frac{2}{\\|\\mathbf{w}\\|}$ and it has to be\n    maximised.\n\n    Thus, the problem to be solved is:\n\n\t\\begin{itemize}\n\t\\item Find $\\mathbf{w}$ and $b$ which minimise\n\t $\\left\\{ \\frac{1}{2}\\|\\mathbf{w}\\|^2 \\right\\}$\n\t\\item under the constraint :\n\t $y_i(\\mathbf{w}\\cdot\\mathbf{x}_i+b)\\ge 1~  ~ i=1\\ldots N.$\n\t\\end{itemize}\n\n\tThis problem can be solved by using the Lagrange multipliers\n\twith one multiplier per sample. It can be shown that only the\n\tsupport vectors will have a positive Lagrange multiplier.\n\n\tIn the case where the two classes are not exactly linearly\n\tseparable, one can modify the constraints above by using \n      $$\\mathbf{w}\\cdot\\mathbf{x}_i+b\\ge +1 - \\xi_i \\text{ if }y_i=+1;$$\n    $$\\mathbf{w}\\cdot\\mathbf{x}_i+b\\le -1+\\xi_i \\text{ if }y_i=-1;$$\n    $$\\xi_i\\ge 0~  ~\\forall i.$$\n\n\tIf $\\xi_i > 1$, one considers that the sample is wrong. The\n\tfunction which has then to be minimised is\n\t$\\frac{1}{2}\\|\\mathbf{w}\\|^2 + C\\left( \\sum_i \\xi_i\\right); $,\n\twhere $C$ is a tolerance parameter. The optimisation problem\n\tis the same than in the linear case, but one multiplier has to\n\tbe added for each new constraint $\\xi_i\\ge 0$.\n\n\tIf the decision surface needs to be non-linear, this solution\n\tcannot be applied and the kernel approach has to be adopted.\n\n\nOne drawback of the SVM is that, in their basic version, they can only\nsolve two-class problems. Some works exist in the field of multi-class\nSVM (see \\cite{allwein00reducing,weston98multiclass}, and the\ncomparison made by \\cite{hsu01comparison}), but they are\nnot used in our system.\n\nYou have to be aware that to achieve better convergence of the algorithm it is \nstrongly advised to normalize feature vector components in the $[-1;1]$ \ninterval.\n\nFor problems with $N > 2$ classes, one can choose either to train $N$\nSVM (one class against all the others), or to train $N\\times(N-1)$ SVM\n(one class against each of the others). In the second approach, which\nis the one that we use, the final decision is taken by choosing the\nclass which is most often selected by the whole set of SVM.\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Shark Random Forests}\n\nThe Random Forests algorithm is also available in OTB machine learning\nframework. This model builds a set of decision trees. Each tree may not give\na reliable prediction, but taking them together, they form a robust classifier.\nThe prediction of this model is the mode of the predictions of individual trees.\n\nThere are two implementations: one in OpenCV and the other on in\nShark. The Shark implementation has a noteworthy advantage: the training step\nis parallel. It uses the following parameters:\n\\begin{itemize}\n\\item The number of trees to train\n\\item The number of random attributes to investigate at each node\n\\item The maximum node size to decide a split\n\\item The ratio of the original training dataset to use as the out of bag sample\n\\end{itemize}\n\nExcept these specific parameter, its usage is exactly the same as the other\nmachine learning models (such as the SVM model).\n\n%-------------------------------------------------------------------------------\n\\subsection{Generic Kernel SVM (deprecated)}\nOTB has developed a specific interface for user-defined kernels. However, the \nfollowing functions use a deprecated OTB interface. The code source for these\nGeneric Kernels has been removed from the official repository. It is now\navailable as a remote module: \\href{https://github.com/jmichel-otb/GKSVM}{GKSVM}.\n\nA function $k(\\cdot,\\cdot)$ is considered to be a kernel when:\n\\begin{align}\\label{eqMercer}\n        \\forall g(\\cdot) \\in {\\cal L}^2(\\mathbbm{R}^n) \\quad & \\text{so \nthat} \\quad\n        \\int g(\\boldsymbol{x})^2 d\\boldsymbol{x} \\text{ be finite,} \\\\\n        & \\text{then} \\quad \\int k(\\boldsymbol{x},\\boldsymbol{y}) \\, \ng(\\boldsymbol{x})\n        \\, g(\\boldsymbol{y}) \\, d\\boldsymbol{x} d\\boldsymbol{y} \\geqslant 0,\n        \\notag\n\\end{align}\nwhich is known as the {\\em Mercer condition\\/}.\n\nWhen defined through the OTB, a kernel is a class that inherits from\n\\code{GenericKernelFunctorBase}. Several virtual functions have to \nbe overloaded:\n\\begin{itemize}\n\\item The \\code{Evaluate} function, which implements the behavior of the \nkernel\nitself. For instance, the classical linear kernel could be re-implemented\nwith:\n\\begin{verbatim}\n        double\n        MyOwnNewKernel\n        ::Evaluate ( const svm_node * x, const svm_node * y,\n                     const svm_parameter & param ) const\n        {\n                return this->dot(x,y);\n        }\n\\end{verbatim}\nThis simple example shows that the classical dot product is already \nimplemented\ninto \\code{otb::GenericKernelFunctorBase::dot()} as a protected\nfunction.\n\\item The \\code{Update()} function which synchronizes local variables and \ntheir\nintegration into the initial SVM procedure. The following examples will show\nthe way to use it.\n\\end{itemize}\n\nSome pre-defined generic kernels have already been implemented in OTB:\n\\begin{itemize}\n\\item \\code{otb::MixturePolyRBFKernelFunctor} which implements a \nlinear mixture\nof a polynomial and a RBF kernel;\n\\item \\code{otb::NonGaussianRBFKernelFunctor} which implements a non\ngaussian RBF kernel;\n\\item \\code{otb::SpectralAngleKernelFunctor}, a kernel that integrates\nthe Spectral Angle, instead of the Euclidean distance, into an inverse \nmultiquadric kernel.\nThis kernel may be appropriated when using multispectral data.\n\\item \\code{otb::ChangeProfileKernelFunctor}, a kernel which is\ndedicated to the supervized classification of the multiscale change profile\npresented in section \\ref{sec:KullbackLeiblerProfile}.\n\\end{itemize}\n\n\\subsubsection{Learning with User Defined Kernels}\n\\label{sec:Learningwithuserdefinedkernel}\n\\ifitkFullVersion\n\\input{SVMGenericKernelImageModelEstimatorExample.tex}\n\\fi\n\n\\subsubsection{Classification with user defined kernel}\n\n\\ifitkFullVersion\n\\input{SVMGenericKernelImageClassificationExample.tex}\n\\fi\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Unsupervised classification}\n\n\\subsection{K-Means Classification}\n\\label{sec:KMeansClassifier}\n\n\\subsubsection{Shark version}\n\nThe KMeans algorithm has been implemented in Shark library, and has been\nwrapped in the OTB machine learning framework. It is the first unsupervised\nalgorithm in this framework. It can be used in the same way as other machine\nlearning models. Remember that even if unsupervised model don't use a label\ninformation on the samples, the target ListSample still has to be set in\n\\code{MachineLearningModel}. A ListSample filled with zeros can be used.\n\nThis model uses a hard clustering model with the following parameters:\n\\begin{itemize}\n\\item The maximum number of iterations\n\\item The number of centroids (K)\n\\item An option to normalize input samples\n\\end{itemize}\n\nAs with Shark Random Forests, the training step is parallel.\n\n\\subsubsection{Simple version}\n\\ifitkFullVersion\n\\input{ScalarImageKmeansClassifier.tex}\n\\fi\n\\ifitkFullVersion\n\\input{ScalarImageKmeansModelEstimator.tex}\n\\fi\n\n\\subsubsection{General approach}\n\\ifitkFullVersion\n\\input{KMeansImageClassificationExample.tex}\n\\fi\n\n\\subsubsection{k-d Tree Based k-Means Clustering}\n\\label{sec:KdTreeBasedKMeansClustering}\n\\ifitkFullVersion\n\\input{KdTreeBasedKMeansClustering.tex}\n\\fi\n%-------------------------------------------------------------------------------\n\\subsection{Kohonen's Self Organizing Map}\n\\label{sec:SOM}\n\\input{Kohonen}\n%%%1. Construction SOM\n\\subsubsection{Building a color table}\n\\label{sec:SOMColorTable}\n\\input{SOMExample}\n\\subsubsection{SOM Classification}\n\\label{sec:SOMClassification}\n\\input{SOMClassifierExample}\n\n\\subsubsection{Multi-band, streamed classification}\n\n\\ifitkFullVersion\n\\input{SOMImageClassificationExample.tex}\n\\fi\n\n%%%2. Lecture SOM et ensemble de vecteurs autre image pour construire\n%%%ActivationMAP \n\n%\\subsection{Bayesian classification}\n%-------------------------------------------------------------------------------\n\\subsection{Bayesian Plug-In Classifier}\n\\label{sec:BayesianPluginClassifier}\n\n\\ifitkFullVersion\n\\input{BayesianPluginClassifier.tex}\n\\fi\n\n%-------------------------------------------------------------------------------\n\\subsection{Expectation Maximization Mixture Model Estimation}\n\\label{sec:ExpectationMaximizationMixtureModelEstimation}\n\n\\ifitkFullVersion\n\\input{ExpectationMaximizationMixtureModelEstimator.tex}\n\\fi\n\n\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Statistical Segmentations}\n\\label{sec:StatisticalSegmentations}\n\n%\\subsection{Markov Random Fields}\n\n\\subsubsection{Stochastic Expectation Maximization}\n\\label{sec:SEM}\n\nThe Stochastic Expectation Maximization (SEM) approach is a stochastic \nversion of the EM mixture estimation seen on\nsection~\\ref{sec:ExpectationMaximizationMixtureModelEstimation}. It has been \nintroduced by \\cite{CeDi95} to prevent convergence of the EM approach from\nlocal minima. It avoids the analytical maximization issued by integrating a\nstochastic sampling procedure in the estimation process. It induces an almost\nsure (a.s.) convergence to the algorithm.\n\nFrom the initial two step formulation of the EM mixture estimation, the SEM\nmay be decomposed into 3 steps:\n\\begin{enumerate}\n\\item \\textbf{E-step}, calculates the expected membership values for each \nmeasurement vector to each classes.\n\\item \\textbf{S-step}, performs a stochastic sampling of the membership vector\nto each classes, according to the membership values computed in the E-step.\n\\item \\textbf{M-step}, updates the parameters of the membership probabilities\n(parameters to be defined through the class\n\\subdoxygen{itk}{Statistics}{ModelComponentBase} and its inherited classes).\n\\end{enumerate}\nThe implementation of the SEM has been turned to a contextual SEM in the sense\nwhere the evaluation of the membership parameters is conditioned to\nmembership values of the spatial neighborhood of each pixels.\n\n\\ifitkFullVersion\n\\input{SEMModelEstimatorExample.tex}\n\\fi\n\n%-------------------------------------------------------------------------------\n\\subsection{Classification using Markov Random Fields}\n\\label{sec:MarkovRandomField}\n\nMarkov Random Fields are probabilistic models that use the statistical\ndependency between\npixels in a neighborhood to infeer the value of a give pixel.\n\n\\subsubsection{ITK framework}\n\\label{sec:MarkovRandomFieldITK}\nThe\n\\subdoxygen{itk}{Statistics}{MRFImageFilter} uses the maximum a posteriori (MAP)\nestimates for modeling the MRF. The object traverses the data set and uses the\nmodel generated by the Mahalanobis distance classifier to get the the distance\nbetween each pixel in the data set to a set of known classes, updates the\ndistances by evaluating the influence of its neighboring pixels (based on a MRF\nmodel) and finally, classifies each pixel to the class which has the minimum\ndistance to that pixel (taking the neighborhood influence under consideration).\nThe energy function minimization is done using the iterated conditional modes\n(ICM) algorithm \\cite{Besag1986}.\n\n\\ifitkFullVersion\n\\input{ScalarImageMarkovRandomField1.tex}\n\\fi\n\n\\subsubsection{OTB framework}\n\\label{sec:MarkovRandomFieldOTB}\nThe ITK approach was considered not to be flexible enough for some\nremote sensing applications. Therefore, we decided to implement our\nown framework.\n\\index{Markov}\n\n\\begin{figure}[th]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{MarkovFramework.eps}\n  \\itkcaption[OTB Markov Framework]{OTB Markov Framework.}\n  \\label{fig:markovFramework}\n\\end{figure}\n\n\\index{Markov!Classification}\n\\ifitkFullVersion\n\\input{MarkovClassification1Example.tex}\n\\fi\n\n\\index{Markov!Classification}\n\\ifitkFullVersion\n\\input{MarkovClassification2Example.tex}\n\\fi\n\n\\index{Markov!Classification}\n\\ifitkFullVersion\n\\input{MarkovClassification3Example.tex}\n\\fi\n\n\\index{Markov!Regularization}\n\\ifitkFullVersion\n\\input{MarkovRegularizationExample.tex}\n\\fi\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Fusion of Classification maps}\n\n\\subsection{General approach of image fusion}\nIn order to obtain a relevant image classification it is sometimes necessary to \nfuse several classification maps coming from different classification methods \n(SVM, KNN, Random Forest, Artificial Neural Networks,...). The fusion of \nclassification maps combines them in a more robust and precise one. Two methods are \navailable in the OTB: the majority voting and the Demspter Shafer framework.\n\n%-------------------------------------------------------------------------------\n\\subsection{Majority voting}\n\\subsubsection{General description}\nFor each input pixel, the Majority Voting method consists in choosing the more \nfrequent class label among all classification maps to fuse. In case of not unique \nmore frequent class labels, the undecided value is set for such pixels in \nthe fused output image.\n\n\\subsubsection{An example of majority voting fusion}\n\\ifitkFullVersion\n\\input{MajorityVotingFusionOfClassificationMapsExample.tex}\n\\fi\n\n%-------------------------------------------------------------------------------\n\\subsection{Dempster Shafer}\n\n\\subsubsection{General description}\nA more adaptive fusion method using the Dempster Shafer theory \n(\\href{http://en.wikipedia.org/wiki/Dempster-Shafer_theory}{http://en.wikipedia.org/wiki/Dempster-Shafer\\_theory}) \nis available within the OTB. This method is adaptive as it is based on the \nso-called belief function of each class label for each classification map. Thus, \neach classified pixel is associated to a degree of confidence according to the \nclassifier used. In the Dempster Shafer framework, the expert's point of view \n(i.e. with a high belief function) is considered as the truth. In order to \nestimate the belief function of each class label, we use the Dempster Shafer \ncombination of masses of belief for each class label and for each classification \nmap. In this framework, the output fused label of each pixel is the one with the \nmaximal belief function.\n\nLike for the majority voting method, the Dempster Shafer fusion handles not \nunique class labels with the maximal belief function. In this case, the output \nfused pixels are set to the undecided value.\n\nThe confidence levels of all the class labels are estimated from a comparison of \nthe classification maps to fuse with a ground truth, which results in a \nconfusion matrix. For each classification maps, these confusion matrices are then \nused to estimate the mass of belief of each class label.\n\n\n\\subsubsection{Mathematical formulation of the combination algorithm}\n\nA description of the mathematical formulation of the Dempster Shafer combination \nalgorithm is available in the following OTB Wiki page: \n\\href{http://wiki.orfeo-toolbox.org/index.php/Information_fusion_framework}{http://wiki.orfeo-toolbox.org/index.php/Information\\_fusion\\_framework}.\n\n\\subsubsection{An example of Dempster Shafer fusion}\n\\ifitkFullVersion\n\\input{DempsterShaferFusionOfClassificationMapsExample.tex}\n\\fi\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Classification map regularization}\n\n%\\subsection{Regularization by neighborhood-based majority voting}\n\n\\ifitkFullVersion\n\\input{ClassificationMapRegularizationExample.tex}\n\\fi\n\n\n\n", "meta": {"hexsha": "1ff8502157758e3c04540583c2c71933a8168db9", "size": 27015, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/SoftwareGuide/Latex/Classification.tex", "max_stars_repo_name": "xcorail/OTB", "max_stars_repo_head_hexsha": "092a93654c3b5d009e420f450fe9b675f737cdca", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-02-13T14:48:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-03T02:54:28.000Z", "max_issues_repo_path": "Documentation/SoftwareGuide/Latex/Classification.tex", "max_issues_repo_name": "xcorail/OTB", "max_issues_repo_head_hexsha": "092a93654c3b5d009e420f450fe9b675f737cdca", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-10-14T10:11:38.000Z", "max_issues_repo_issues_event_max_datetime": "2015-10-15T08:26:23.000Z", "max_forks_repo_path": "Documentation/SoftwareGuide/Latex/Classification.tex", "max_forks_repo_name": "xcorail/OTB", "max_forks_repo_head_hexsha": "092a93654c3b5d009e420f450fe9b675f737cdca", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-10-08T12:04:06.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-19T08:00:47.000Z", "avg_line_length": 42.2769953052, "max_line_length": 148, "alphanum_fraction": 0.7425134185, "num_tokens": 6365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4255450305905669}}
{"text": "\\documentclass{article}\n\\usepackage{leonine,amsmath,amssymb,amsthm,graphicx}\n\\setkeys{Gin}{width=\\linewidth,totalheight=\\textheight,keepaspectratio}\n\\graphicspath{{graphics/}}\n% Prints a trailing space in a smart way.\n\\usepackage{xspace}\n% Inserts a blank page\n\\newcommand{\\blankpage}{\\newpage\\hbox{}\\thispagestyle{empty}\\newpage}\n% \\usepackage{units}\n% Typesets the font size, leading, and measure in the form of 10/12x26 pc.\n\\newcommand{\\measure}[3]{#1/#2$\\times$\\unit[#3]{pc}}\n\n\\theoremstyle{definition}\n\\newtheorem{pred}[thm]{Prediction}\n\n\\title{Askesis: Negative Pathway 2} \\author{Eric Purdy}\n\n\\begin{document}\n\n\\maketitle\n\\section{Overview}\n\nThe purpose of the negative pathway is to filter out potential\nmovements produced by the positive pathway, leaving only the desired\nmovements as output from the deep nuclear cells. Our theory of the\nnegative pathway is very similar to the perceptron model of Albus,\nalthough we modify the input to each perceptron slightly.\n\n\\section{Purkinje Cells and Basket Cells}\n\\label{sec-purkinje}\n\nLet $G_i(t)$ be the firing of the $i$-th granular cell at time $t$.\n\nWe model the basket cell as \n$$B_j(t) = \\sigma \\left(\\sum_i W^-_{ij} G_i(t) +\\theta^-_j \\right).$$\n\nWe model the Purkinje cell as\n$$P_j(t) = \\sigma \\left(\\sum_i W^+_{ij} G_i(t) +\\theta^+_j - \\alpha B_j(t) \\right).$$\n\nWe will use a simpler model for the combined basket cell-Purkinje cell\npair:\n\\begin{align*}\nP_j(t) &= \\sigma \\left(\\sum_i (W^+_{ij}-W^-_{ij}) G_i(t) + (\\theta^+_j\n- \\theta^-_j)\\right)\\\\ &= \\sigma \\left(\\sum_i W_{ij} G_i(t) +\\theta_j \\right),\n\\end{align*}\nwhere the $W_{ij}$ and $\\theta_j$ are free to take on both positive\nand negative values.\n\nLet $y_j(t)$ be $1$ if the $j$-th inferior olive cell fires at time\n$t$, and $-1$ otherwise. We assume that the inferior olive cells are\nin one-to-one correspondence to the Purkinje cells, which is a slight\nsimplification.\n\nIn order to best set the weights $W_{ij}$ and bias $\\theta_j$ of the\n$j$-th Purkinje cell, we minimize the following function:\n$$L(\\{W_{ij}\\}, \\{\\theta_j\\}) = \\sum_t y_j(t) \\left(W_{ij} G_i(t) +\n\\theta_j\\right) + \\lambda \\sum_i W_{ij}^2. $$ \nThis rewards us for having the Purkinje cell activation ($W_{ij}\nG_i(t) + \\theta_j$) low when the climbing fiber is active\n($y_j(t)=1$), and for having the Purkinje cell activation high when\nthe climbing fiber is inactive ($y_j(t)=-1$). Since the Purkinje cell\nsuppresses the corresponding deep nuclear cell, and the climbing fiber\nencodes the information that we want the corresponding deep nuclear\ncell to fire, this is the desired behavior.\n\nThe term $\\lambda \\sum_i W_{ij}^2$ is necessary to prevent the weights\nfrom increasing without bound. It favors parameter settings with\nsmaller weights, which are thought of as being ``simpler'' in the\nmachine learning literature; favoring smaller weights is thus a form\nof Occam's Razor. The constant multiplier $\\lambda$ controls the\ntradeoff between this term and the other term. The larger $\\lambda$\nis, the more the algorithm will favor model simplicity (small weights)\nover fitting the data well.\n\nThis can be compared with the support vector machine (SVM), an\nalgorithm that minimizes the following function:\n$$L(\\{W_{ij}\\}, \\{\\theta_j\\}) = \\sum_t \\left[ 1+y(t)\\left(\\sum_i\n  W_{ij} G_i(t) + \\theta_j\\right)\\right]_+ + \\lambda \\sum_i\nW_{ij}^2,$$ where $[a]_+$ is zero if $a$ is negative, and\nequal to $a$ otherwise. The difference between the two is that\nthe SVM uses the ``hinge loss'' while we are simply using a linear\nloss function. This difference means that we get extra credit for\nbeing more certain that we are right; with the hinge loss, we are\npenalized a lot when we are certain but wrong, but not rewarded for\nbeing more certain when we are right. These loss functions, as well as\nthe step loss function, are shown in Figure \\ref{fig-hinge}; the hinge\nloss is a sort of combination of the step loss function and the linear\nloss function.\n\n\\begin{figure}\n\\includegraphics[width=0.3\\linewidth]{step_loss.png}\n\\includegraphics[width=0.3\\linewidth]{linear_loss.png}\n\\includegraphics[width=0.3\\linewidth]{hinge_loss.png}\n\\caption{Various loss functions: the step loss function, the linear loss function, and the hinge loss function.}\n\\label{fig-hinge}\n\\end{figure}\n\nThe partial derivatives are:\n\\begin{align*}\n\\frac{\\partial L(W)}{\\partial W_{ij}} &= \\sum_t y(t) G_i(t) + 2\\lambda W_{ij}\\\\\n\\frac{\\partial L(W)}{\\partial \\theta_j} &= \\sum_t y(t).\\\\\n\\end{align*}\nUsing stochastic gradient descent (since we want to minimize\n$L(\\{W_{ij}\\}, \\{\\theta_j\\})$), this leads to the update rules\n\\begin{align*}\n\\Delta W_{ij} &= -\\eta y_j(t) G_i(t) - \\frac{2\\eta\\lambda}{T} W_{ij}\\\\\n\\Delta \\theta_j &= -\\eta y_j(t). \\\\\n\\end{align*}\nWe apply this to the actual synapse weights and cell biases by adding\n$\\frac{1}{2}\\Delta W_{ij}$ to the weight $W^+_{ij}$ and\n$-\\frac{1}{2}\\Delta W_{ij}$ to the weight $W^-_{ij}$, and adding\n$\\frac{1}{2}\\Delta \\theta_j$ to $\\theta^+_j$ and adding\n$-\\frac{1}{2}\\Delta \\theta_j$ to $\\theta^-_j$. This is consistent with\nthe observed learning behavior at the parallel fiber-Purkinje cell\nsynapse and the parallel fiber-basket cell synapse:\n\\begin{itemize} \n\\item LTD at the parallel fiber-Purkinje cell synapse when the\n  inferior olive cell fires at the same time as the parallel fiber\n  ($y_j(t)=1, G_i(t)=1$)\n\\item LTP at the parallel fiber-Purkinje cell synapse when the\n  parallel fiber fires but the inferior olive cell does not\n  ($y_j(t)=-1, G_i(t)=1$)\n\\item LTP at the parallel fiber-basket cell synapse when the inferior\n  olive cell fires at the same time as the parallel fiber ($y_j(t)=1,\n  G_i(t)=1$)\n\\item LTD at the parallel fiber-basket cell synapse when the parallel\n  fiber fires but the inferior olive cell does not ($y_j(t)=-1,\n  G_i(t)=1$)\n\\item No change when the parallel fiber is inactive ($G_i(t)=0$)\n\\end{itemize}\nWe also predict an exponential decay of the weights at both types of\nsynapse, as well as changes in the intrinsic excitability of the\nbasket cells and Purkinje cells corresponding to the change in\n$\\theta^-_j$ and $\\theta^+_j$, respectively. The exponential decay\nwould contribute to memories in the negative pathway being short-lived\nrelative to memories in the positive pathway, which seems to be the\ncase.\n\nWe have phrased these as if the climbing fiber and parallel fiber\nactivations should be synchronized, but learning is observed to be\nmaximized then there is a delay on the order of 100 milliseconds\nbetween the activation of the parallel fiber and the activation of the\nclimbing fiber. This makes sense: the climbing fiber is activated by\nslower, non-cerebellar networks, so its input will always arrive\ndelayed relative to the relevant stimuli reaching the Purkinje and\nbasket cells.\n\n\\subsection{Symmetry-breaking mechanism for the Purkinje cells}\n\nEach Purkinje cell receives as input, in addition to its input from\nthe parallel fibers, collaterals from several nearby granular\ncells. This input is weighted more highly than that at the parallel\nfiber-Purkinje cell synapse. We posit that these collaterals exist to\nbreak the symmetry between Purkinje cells that project to the same\ndeep nuclear cell, so that we can learn multiple different\nclassifiers, each of which is capable of suppressing the deep nuclear\ncell. Otherwise, adjacent Purkinje cells would receive the same input.\n(Recall that nearby inferior olive cells tend to be coupled with gap\njunctions, so that the input from the inferior olive would also be the\nsame for each Purkinje cell.)\n\n\n\\end{document}\n", "meta": {"hexsha": "47825256d10e10742a6f7c3f7d1d403cfb2a86c9", "size": 7533, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "askesis/negative2.tex", "max_stars_repo_name": "advancedresearch/ethicophysics", "max_stars_repo_head_hexsha": "52806b53d6d3ee92e1bd2a8c00f7728cebc9e684", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2018-04-26T17:10:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-19T01:56:36.000Z", "max_issues_repo_path": "askesis/negative2.tex", "max_issues_repo_name": "advancedresearch/ethicophysics", "max_issues_repo_head_hexsha": "52806b53d6d3ee92e1bd2a8c00f7728cebc9e684", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 46, "max_issues_repo_issues_event_min_datetime": "2018-04-26T16:25:59.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-15T10:13:05.000Z", "max_forks_repo_path": "askesis/negative2.tex", "max_forks_repo_name": "advancedresearch/ethicophysics", "max_forks_repo_head_hexsha": "52806b53d6d3ee92e1bd2a8c00f7728cebc9e684", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-05-13T17:37:48.000Z", "max_forks_repo_forks_event_max_datetime": "2018-05-13T17:37:48.000Z", "avg_line_length": 45.9329268293, "max_line_length": 112, "alphanum_fraction": 0.7500331873, "num_tokens": 2117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.42554503059056686}}
{"text": "%!TEX root = vorlage.tex\n\n\\subsection{Base line experiments}\\label{sec:ap3}\n\nThe most basic information for pixel-wise semantic segmentation is the color of\nthe pixel. Typically, images are in RGB format. This means the image has\nthree~channels ({\\color{red} R}ed, {\\color{green} G}reen, {\\color{blue} B}lue).\nEach channel has 8~bit and thus $2^8 = 256$ possible values, ranging from 0 to\n255. This gives ${(2^8)}^3 = \\num{16777216}$ possible colors for each pixel.\nObviously, only the color can not give a perfect result in all circumstances as\nthe measured color changes due to smoke, shadows, specular~highlights and\ninsufficient illumination. But it gives an impression how important local\nfeatures are for the specific problem.\n\nA model with 64~sigmoid nodes in a first hidden layer with $\\SI{50}{\\percent}$\ndropout~\\cite{srivastava2014dropout}, 64~ReLu nodes in a second hidden layer\nwith $\\SI{50}{\\percent}$ dropout and one sigmoid output unit was used as a\nbaseline.\n\nThe architecture of the baseline model is visualized\nin~\\cref{fig:baseline-architecture}. Neither preprocessing nor data\naugmentation were applied.\n\nThe baseline model achieved a pixel-wise accuracy\nof~$\\SI{92.88}{\\percent}$,\\footnote{This is the same as the DICE coefficient.}\na precision of $\\SI{76.13}{\\percent}$ and a recall of $\\SI{32.94}{\\percent}$.\nThe confusion matrix is given in~\\cref{table:cm-model-301}.\n\n\\begin{figure}[ht]\n    \\centering\n    \\input{mlp-architecture}\n    \\caption{Architecture of the baseline model.}\n    \\label{fig:baseline-architecture}\n\\end{figure}\n", "meta": {"hexsha": "ab3fa00d58bccb3fea3cc17107d9fdf633ab26cd", "size": 1557, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "AP8/paper/04-2-ap3.tex", "max_stars_repo_name": "TensorVision/MediSeg", "max_stars_repo_head_hexsha": "222fcab98d82f48f09304eda3cfbfe4d6ac825b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2016-08-15T17:57:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-19T05:08:29.000Z", "max_issues_repo_path": "AP8/paper/04-2-ap3.tex", "max_issues_repo_name": "TensorVision/MediSeg", "max_issues_repo_head_hexsha": "222fcab98d82f48f09304eda3cfbfe4d6ac825b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2016-04-11T10:20:34.000Z", "max_issues_repo_issues_event_max_datetime": "2016-08-09T21:47:48.000Z", "max_forks_repo_path": "AP8/paper/04-2-ap3.tex", "max_forks_repo_name": "TensorVision/MediSeg", "max_forks_repo_head_hexsha": "222fcab98d82f48f09304eda3cfbfe4d6ac825b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-06-21T04:08:58.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-01T14:02:40.000Z", "avg_line_length": 44.4857142857, "max_line_length": 79, "alphanum_fraction": 0.7591522158, "num_tokens": 420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.42554503059056686}}
{"text": "\\documentclass{scrartcl}\n\\usepackage[a4paper,left=1in,right=1in,top=1.2in,bottom=1in]{geometry}\n\\usepackage{siunitx}\n\\usepackage{graphicx}\n\\setkomafont{disposition}{\\normalfont\\bfseries}\n\\usepackage{amsmath}\n\\usepackage{easytable}\n\\usepackage{lipsum}\n\\usepackage{ragged2e}\n\\allowdisplaybreaks\n\n%title\n\\title{Extra assignment:\\\\Inference for continuous detection and discrimination}\n\\subtitle{Theoretical Neuroscience II}\n\\author{Johannes G\\\"atjen}\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Maximum joint density/probability}\n\\label{maxes}\n\nI determined the peak density of the joint probability density function with three different computational methods.\\footnote{I also tried to derive the maximum directly (analytically) from the probability density function, but gave up after still getting apparently wrong results after multiple attempts. One result included $c_s = -c_0$, another gave $x_k = \\sqrt{\\frac{1}{2\\pi}}, \\theta_s = \\theta_k, c_s= \\frac{c_0}{2} + \\sqrt{\\frac{c_0^2}{4}+\\frac{c_0}{8e^2}}$} The results are summed up in the following table. For the first method, I wrote a function that evaluates the pdf directly and used a library function to iteratively find the maximum. For the second method I sampled the same function at fixed points at linearly spaced values for $\\theta_k$ and logarithmically spaced values for $x_k$ and $c_s$, and selected the maximum from those results. Transforming the density function into a probability function, I also obtained an analytic result for the peak (discretized) probability. Lastly I generated stimuli and responses according to the probability distributions and calculated the empirical/numerical peak density and probability from the results. The chosen parameters are $c_0 = 1$ and $\\theta_k = 0$. \n\n\n\\centering\n\\begin{TAB}(r, 10pt, 20pt)[4pt]{cc|c|c|c}{c|ccc|cc}\n& \\textbf{Method} & $\\mathbf{x_k}$ & $\\mathbf{c_s}$ & $\\mathbf{\\theta_s}$ \\\\\n\\textbf{peak density}\t& direct optimization\t& $\\approx\\num{1e-100}$ & $\\approx\\num{1e-100}$ & $\\approx 3.7$ \\\\\n& analytic & \\num{1e-8} & \\num{2e-8} & 2 \\\\\n& numeric & 0 & \\num{3e-8}  & 3.7\\\\\n\\textbf{peak probability}& analytic & 10 & 1 & 0 \\\\\t\n& numeric & 7.3 & 0.65 & 0 \\\\\t\n\\end{TAB}\n\n\\justify\nThe results for the location of the peak probability do not agree closely for the response and contrast, but are within an order of magnitude. Since they are on a logarithmic scale, we cannot expect much better.\n\nThe results for the peak density show $x_k$ and $c_s$ close to zero. However the density function with $x_k = 0$ is equal to zero (so not maximal), and it is not defined for $c_s = 0$. The response rate $x_k$ is Rayleigh distributed with a mean determined by the stimulus contrast $c_s$ and orientation $\\theta_s$. The mean tends towards zero with $c_s$. A Rayleigh distribution with the mean tending towards zero degenerates into a Dirac delta function $\\operatorname{\\delta}(x - \\epsilon)$. This means the density at that point tends to infinity.\n\n\\section{Marginal response distribution}\n\nFigure \\ref{margs} shows the marginal distribution of the response rate, once derived analytically, once numerically, as described in Section \\ref{maxes}. Qualitatively the analytic and numeric solutions agree well. The absolute values for the numeric solution are a bit smaller than for the analytic solution.\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXProb_analytic_final}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXProb_numeric_final} \\\\\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXDens_analytic_final}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXDens_numeric_final}\\\\\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXLogDens_analytic_final}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/s2/margXLogDens_numeric_final}\\\\\n\\caption{Left column: Analytic solution. Right column: Numeric solution. Rows, top to bottom: Marginal (disrcretized) probability with logarithmically spaced values of $x$, marginal probability density, log of marginal probability density.}\n\\label{margs}\n\\end{figure}\n\n\\section{Posterior of contrast and orientation, given response}\n\nFigure \\ref{posts} shows the posterior probability of contrast and orientation, given a response rate. For low response rates the most likely stimulus is of non-preferred orientation, and has a higher contrast than the most likely stimulus with the preferred orientation. For higher response rates the posterior for the preferred stimulus orientation is highest.\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.49\\textwidth, clip]{../pics/post_analytic_lowresp}\n\\includegraphics[width=0.49\\textwidth, clip]{../pics/post_numeric_lowresp} \\\\\n\\includegraphics[width=0.49\\textwidth, clip]{../pics/post_analytic_highresp}\n\\includegraphics[width=0.49\\textwidth, clip]{../pics/post_numeric_highresp}\\\\\n\\caption{Left column: Analytic solution. Right column: Numeric solution. Posterior distribution for $x_k=\\num{6.7e-4}$ (top) and for $x_k=45.3$ (bottom). $c_0 = 1, \\theta_k = 0$}\n\\label{posts}\n\\end{figure}\n\n\\section{Probability and latency of object detection}\n\\label{plat}\nI estimated the probability and latency of correctly detecting an object as a function of object duration and contrast. For a given sequence of stimuli and their response rates and a fixed window size I determined the most likely stimulus for every time step. The differences between true and detected contrast and orientation were transformed to be in the range $\\left[0, 1\\right]$. For the orientation I used the function $\\operatorname{f}(\\theta_s, \\theta_d) = \\frac{- \\cos{(\\theta_s - \\theta_d)} + 1}{2}$ and for the contrast the function $\\operatorname{f}(c_s, c_d) = \\lvert \\operatorname{cdf}(c_s, c_0) - \\operatorname{cdf}(c_d, c_0) \\rvert $ where subscripts $s$ and $d$ refer to the stimulus and detected values respectively and cdf is the cumulative density function for the distribution of stimulus contrast. If the result of these functions was smaller than a given threshold for both contrast and orientation at at least one point in time the corresponding stimulus was said to be correctly detected and the latency was set to the difference between stimulus onset and first time of correct detection.\n\nSome example results are shown in Figure \\ref{funs}. Overall trends appear to be as follows: Very low contrast and very high contrast objects are more difficult to detect than objects with average contrast. The latency is more or less independent of contrast, except for very high contrasts, where the latency is higher. Latency of detection is close to the worst possible value for short stimuli and otherwise independendent of stimulus duration. Probability of detection is high for all stimuli longer than the window size, with perhaps a small positive correlation between object duration and detection probability. For objects with a shorter duration than the window size the probability of detection rises rapidly with a longer duration. See also Figure \\ref{sect}.\n\n%These results indicate that larger window sizes worsen detection performance. However this is only so because of the specific way of measuring the performance. Which stimulus is detected after a single correct inference is completely ignored. Because the variance of the inferred stimulus properties is larger for smaller window sizes, it is likelier to get the stimulus correct at least once, even if on average the error is larger.\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t4/latency_of_dur_4chans_1_8_8_01}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t4/latency_of_contr_4chans_1_8_8_01}\\\\\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t4/prob_of_con_4chans_1_8_8_01}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t4/prob_of_dur_4chans_1_8_8_01}\\\\\n\\caption{Probability and latency of stimulus detection as functions of stimulus duration and contrast. Chosen parameters: $c_0 = 1, \\tau_0 = 8$, integration window size $=8$, detection threshold $=0.1$, number of channels $=4$. The red line in the top left plot indicates the maximum possible latency. Points on the line mean that the stimulus was either not detected at all, or detected at the last point in time before the next stimulus began. Actual results can be slightly above the line because the results for multiple durations are put together. The mean of zero values was set to zero, which explains the zero points in the bottom right plot.}\n\\label{funs}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.66\\textwidth, clip]{../pics/t4/prob_of_dur_1_8_8_01_section}\n\\caption{Chosen parameters: $c_0 = 1, \\tau_0 = 8$, integration window size $=8$, detection threshold $=0.1$, number of channels $=12$. Illustration of the initial rapid rise of detection probability for stimuli shorter than the window size. }\n\\label{sect}\n\\end{figure}\n\n\\section{Standard deviaton of error}\n\nI estimated the precision of the inferred stimuli as a function of object duration and contrast with the standard deviation of the error. I generated stimuli, responses and inferred stimuli as described in Section \\ref{plat}, but did not transform the difference into the $\\left[0, 1\\right]$ range. Some results are shown in Figure \\ref{stds}. \n\nComparing window sizes of 1 and 8, with the mean duration $\\tau_0$ also set to 1 or 8 show that the inference is more precise with the smaller window size. The dependence of orientation and contrast precision on object duration are basically identical. For the small window size there is no clear dependence between object duration and precision. For the longer window size there is a clear trend of higher precision for longer duration objects. The absolute standard deviation values are much higher than for the short window though, approaching the short window performance only for very long duration objects.\n\nThe orientation precision seems to be independent of object contrast for small window sizes, and much larger for long windows, except for very low and very high contrast objects.\nThe standard deviation of the contrast error grows with the object contrast for the short window, but is high for all object contrast values for the long window.  \n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t5/oridur_highnum_1_8_1_8}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t5/oridur_highnum_1_8_8_8}\\\\\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t5/condur_highnum_1_8_1_8}\n\\includegraphics[width=0.47\\textwidth, clip]{../pics/t5/condur_highnum_1_8_8_8}\\\\\n\\caption{Standard deviation of orientation and contrast error as functions of object duration. Chosen parameters: $c_0 = 1, \\tau_0 = 8$, number of channels $=8$, left column integration window size $=1$, right column integration window size $=8$. Note the much larger scale of the y axis for the larger window size.}\n\\label{stds}\n\\end{figure}\n\n\\section{Optimal window size for parameters}\n\nFinally I estimated the optimal window size for a given set of environment parameters $c_0$ and $\\tau_0$. For the given parameters I generated stimuli and responses, and from the responses the inferred stimulus for different window sizes. As in Section \\ref{plat} the difference of true and inferred stimulus contrast and orientation was transformed to the range $\\left[0, 1\\right]$ so that errors in estimated contrast and orientation would be weighted roughly equally. An exemplary result is shown in Figure \\ref{optws}. We can see that with a higher $\\tau_0$ longer window sizes are preferred. The relationship between contrast and optimal window size is unclear.\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.55\\textwidth, clip]{../pics/optws_chan8}\n\\caption{The ``optimal'' window size as a function of environment parameters $c_0$ (contrast) and $\\tau_0$ (duration), using 8 channels.}\n\\label{optws}\n\\end{figure}\n\n\n%\\begin{align*}\n%r_k =& c_s \\exp{(2 \\cos{\\theta_k-\\theta_s)}}\\\\\n%\\ln{\\operatorname{p}(x_k, c_s, \\theta_s)} =& \n%\t\\ln{\\frac{\\pi}{2} + \n%\t\\ln{x_k} - \n%\t2 \\ln{r_k} - \n%\t\\frac{\\pi x_k^2}{4r_k^2} -\n%\t\\ln{2\\pi} - \n%\t\\frac{c_s}{c_0} - \n%\t\\ln{c_0}}\\\\\t\n%\\operatorname{p} (x_k, c_s, \\theta_s) =& \n%\t\\frac{x_k r_k}{4 c_0} \\cdot \n%\t\\exp{\\left( \n%\t\t-\\frac{\\pi x_k^2}{4r_k^2} - \n%\t\t\\frac{c_s}{c_0} - 2 \n%\t\t\\right)}\\\\\t\n%0 = \\frac{\\partial \\operatorname{p} (x_k, c_s, \\theta_s)}{\\partial x_k} =& \n%\t\\frac{r_k}{4c_0} \n%\t\\exp{\\left( \n%\t\t-x_k^2 \n%\t\t\\frac{\\pi}{4r_k^2} - \n%\t\t\\frac{c_s}{c_0} - 2 \n%\t\t\\right)} + \n%\t\\frac{x_k r_k}{4c_0}\n%\t\\frac{-2\\pi x_k}{4r_k^2} \n%\t\\exp{\\left( \n%\t\t-x_k^2 \n%\t\t\\frac{\\pi}{4r_k^2} \n%\t\t\\right) }\\\\\t\n%=& \\underbrace{\n%\t\t\\exp{\\left( \n%\t\t\t-x_k^2 \n%\t\t\t\\frac{\\pi}{4r_k^2}  \n%\t\t\t\\right)}\n%\t\t\\frac{r_k}{4c_0}}_{\\neq 0} \\cdot \n%\t\\left( 1 - 2\\pi x_k^2 \\right)\\\\\n%x_k^2 =& \\frac{1}{2\\pi}\\\\\n%x_k =& \\sqrt{\\frac{1}{2\\pi}}\\\\ \\\\\n%\\operatorname{p}(\\sqrt{1/2\\pi}, c_s, \\theta_s) =& \n%\t\\frac{c_s \n%\t\t\\exp{\\left( \n%\t\t\t2 \\cos{\\theta_k - \\theta_s}\n%\t\t\t\\right)}}\n%\t\t{4c_0\\sqrt{2\\pi}} \\cdot\n%\t \\exp{\\left(\n%\t \t-\\frac{1}{8c_s}\n%\t \t\\exp{\\left(\n%\t \t\t-2\\cos{\\theta_k - \\theta_s}\n%\t \t\t\\right)}-\n%\t \t\\frac{c_s}{c_0}-2\n%\t \t\\right)} \\\\\t \t\n%0 = \\frac{\\partial \\operatorname{p}(\\sqrt{1/2\\pi}, c_s, \\theta_s)}{\\partial \\theta_s} =& \\exp{\\left(\n%\t\t-\\frac{1}{8c_s}\n%\t\t\\exp{\\left(\n%\t\t\t-2\\cos{\\theta_k - \\theta_s}\n%\t\t\t\\right)} -\n%\t\t\\frac{c_s}{c_0}-2\n%\t\t\\right)} \\cdot \\\\\n%\t&\\frac{c_s \n%\t\t\\exp{\\left(\n%\t\t\t2 \\cos{\\theta_k - \\theta_s}\n%\t\t\t\\right)}}\n%\t\t{4c_0\\sqrt{2\\pi}} \n%\t\\frac{2\\sin{\\theta_k-\\theta_s}}{8c_s\\exp{\\left(\n%\t\t2\\cos{\\theta_k - \\theta_s}\n%\t\t\\right)}} \\\\\n%+& \\exp{\\left(\n%\t\t-\\frac{1}{8c_s}\n%\t\t\\exp{\\left(\n%\t\t\t-2\\cos{\\theta_k - \\theta_s}\n%\t\t\t\\right)} -\n%\t\t\\frac{c_s}{c_0}-2\n%\t\t\\right)} \\cdot \\\\\n%\t &\\exp{\\left(\n%\t \t2\\cos{\\theta_k - \\theta_s}\n%\t \t\\right)} \n%\t \\frac{2c_s\\sin{\\theta_k-\\theta_s}}{4c_0\\sqrt{2\\pi}} \\\\\n%=& \\underbrace{\\exp{\\left(\n%\t\t-\\frac{1}{8c_s}\n%\t\t\\exp{\\left(\n%\t\t\t-2\\cos{\\theta_k - \\theta_s}\n%\t\t\t\\right)} -\n%\t\t\\frac{c_s}{c_0}-2\n%\t\t\\right)}\n%\t\\exp{(2\\cos{\\theta_k-\\theta_s})}\n%\t\\frac{2c_s}{4c_0\\sqrt{2\\pi}}}_{\\neq 0} \\cdot \\\\\n%\t&\\sin{(\\theta_k-\\theta_s)}\n%\t\\underbrace{\\left(\n%\t\t\\frac{1}{8c_s} \\exp{(-2\\cos{(\\theta_k-\\theta_s)})}\n%\t\t+1\n%\t\t\\right)}_{\\neq 0}\\\\\n%0 =& \\sin{\\theta_k - \\theta_s} \\\\\n%\\theta_s =& \\theta_k \\\\ \\\\\n%\\operatorname{p}(\\sqrt{1/2\\pi}, c_s, \\theta_k) =& \\frac{c_s e^2}{4c_0 \\sqrt{2\\pi}}\n%\t\\exp{\\left(\n%\t\t-\\frac{1}{8c_se^2} - \n%\t\t\\frac{c_s}{c_0} - 2\n%\t\t\\right)} \\\\\n%0 = \\frac{\\partial \\operatorname{p}(\\sqrt{1/2\\pi}, c_s, \\theta_k)}{\\partial c_s} =& \n%\t\\frac{c_s e^2}{4c_0 \\sqrt{2\\pi}}\n%\t\\exp{\\left(\n%\t\t-\\frac{1}{8c_se^2} - \n%\t\t\\frac{c_s}{c_0} - 2\n%\t\t\\right)}\n%\t\\left(\n%\t\t-\\frac{1}{c_0}\n%\t\t+ \\frac{1}{8c_s^2e^2}\n%\t\t\\right)\t\\\\\n%\t+& \\exp{\\left(\n%\t\t-\\frac{1}{8c_se^2} - \n%\t\t\\frac{c_s}{c_0} - 2\n%\t\t\\right)}\n%\t\\frac{e^2}{4c_0\\sqrt{2\\pi}} \\\\\n%=& \\underbrace{\\left(\n%\t\\exp{\\left(\n%\t\t-\\frac{1}{8c_se^2} - \n%\t\t\\frac{c_s}{c_0} - 2\n%\t\t\\right)}\n%\t\\frac{e^2}{4c_s\\sqrt{2\\pi}}\n%\t\\right)}_{\\neq 0} \\cdot\n%\t\\left(\n%\t\t\\frac{1}{8c_se^2} - \\frac{c_s}{c_0} + 1\n%\t\t\\right)\\\\\n%0 =& c_s^2 - c_sc_0 - \\frac{c_0}{8e^2} \\\\\n%c_s =& \\frac{c_0}{2} +\n%\t\\sqrt{\n%\t\t\\frac{c_0^2}{4}+\n%\t\t\\frac{c_0}{8e^2}}\n%\\end{align*}\n\n\n\\end{document}", "meta": {"hexsha": "b0981aafdb0fc21932e153b7d7ff7a50b8d21541", "size": 15148, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "extra/pdf/extra.tex", "max_stars_repo_name": "gaetjen/TNSII_Exercises", "max_stars_repo_head_hexsha": "d82eb790132e9066c6ad41e7f90ba193145a2e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "extra/pdf/extra.tex", "max_issues_repo_name": "gaetjen/TNSII_Exercises", "max_issues_repo_head_hexsha": "d82eb790132e9066c6ad41e7f90ba193145a2e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "extra/pdf/extra.tex", "max_forks_repo_name": "gaetjen/TNSII_Exercises", "max_forks_repo_head_hexsha": "d82eb790132e9066c6ad41e7f90ba193145a2e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.4864864865, "max_line_length": 1221, "alphanum_fraction": 0.7268946396, "num_tokens": 4780, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883592602049, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.42554503059056675}}
{"text": "\\documentclass{article}\n    % General document formatting\n    \\usepackage[margin=0.7in]{geometry}\n    \\usepackage[parfill]{parskip}\n    \\usepackage[utf8]{inputenc}\n    \\usepackage{amsmath}\n    \\usepackage{amssymb}\n    \\usepackage{tikz}\n    \\usepackage{fancyhdr}\n    \\usepackage{listings}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Edgar Jacob Rivera Rios - A01184125}\n\n\\begin{document}\n\\begin{titlepage}\n\n    \\newcommand{\\HRule}{\\rule{\\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here\n\n    \\center % Center everything on the page\n\n    %----------------------------------------------------------------------------------------\n    %\tHEADING SECTIONS\n    %----------------------------------------------------------------------------------------\n\n    \\textsc{\\LARGE Tecnológico de Monterrey}\\\\[1.5cm] % Name of your university/college\n    \\textsc{\\Large Fundamentos de computación}\\\\[0.5cm] % Major heading such as course name\n    %\\textsc{\\large Minor Heading}\\\\[0.5cm] % Minor heading such as course title\n\n    %----------------------------------------------------------------------------------------\n    %\tTITLE SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\HRule \\\\[0.4cm]\n    { \\huge \\bfseries Homework 2}\\\\[0.4cm] % Title of your document\n    \\HRule \\\\[1.5cm]\n\n    %----------------------------------------------------------------------------------------\n    %\tAUTHOR SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\begin{minipage}{0.4\\textwidth}\n    \\begin{flushleft} \\large\n    \\emph{Student:}\\\\\n    Jacob \\textsc{Rivera} % Your name\n    \\end{flushleft}\n    \\end{minipage}\n    ~\n    \\begin{minipage}{0.4\\textwidth}\n    \\begin{flushright} \\large\n    \\emph{Professor:} \\\\\n    Dr. Hugo \\textsc{Terashima} % Supervisor's Name\n    \\end{flushright}\n    \\end{minipage}\\\\[2cm]\n\n    % If you don't want a supervisor, uncomment the two lines below and remove the section above\n    %\\Large \\emph{Author:}\\\\\n    %John \\textsc{Smith}\\\\[3cm] % Your name\n\n    %----------------------------------------------------------------------------------------\n    %\tDATE SECTION\n    %----------------------------------------------------------------------------------------\n\n    {\\large \\today}\\\\[2cm] % Date, change the \\today to a set date if you want to be precise\n\n    %----------------------------------------------------------------------------------------\n    %\tLOGO SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\includegraphics[width=0.4\\textwidth,height=\\textheight,keepaspectratio]{logo-tec-negro.png} % Include a department/university logo - this will require the graphicx package\n\n    %----------------------------------------------------------------------------------------\n\n    \\vfill % Fill the rest of the page with whitespace\n\n\\end{titlepage}\n\n\n\\section{Problems}\nSolve the following problems:\n\\begin{enumerate}\n    \\item Use  the  substitution  method  to  solve  the  following  recurrences  and  determine  their  corresponding complexity. Establish the proper initial conditions for each problem.\n    \\begin{enumerate}\n        \\item $T(n) = 4T(n/2) +n^4$\n        \\begin{equation*}\n            T(n)=\\begin{cases}\n              b & \\text{if $n = 1$}.\\\\\n              aT(\\frac{n}{c}) + bn^x, & \\text{otherwise}.\n            \\end{cases}\n        \\end{equation*}\n        \\begin{equation*}\n            n = 2^k\n        \\end{equation*}\n\n        \\begin{align*}\n            T(n) &= 2^2T(n/2) + n^4\\\\\n            &= 2^2(2^2T(\\frac{n}{2^2}) + (\\frac{n}{2})^4) + n^4\\\\\n            &= 2^4(2^2T(\\frac{n}{2^3}) + (\\frac{n}{2^2})^4 )+ \\frac{n^4}{2^2} + n^4\\\\\n            &= 2^6(2^2T(\\frac{n}{2^4}) + (\\frac{n}{2^3})^4)+ \\frac{n^4}{2^4} + \\frac{n^4}{2^2} + n^4\\\\\n            &= 2^8T(\\frac{n}{2^4}) + \\frac{n^4}{2^6}+ \\frac{n^4}{2^4} + \\frac{n^4}{2^2} + n^4\\\\\n            &=2^{2k}T(\\frac{n}{2^k}) +\\sum^{k -1}_{i=0} \\frac{n^4}{2^{2i}}\\\\\n            &=2^{2k}T(\\frac{n}{2^k}) +n^4 \\sum^{k -1}_{i=0} \\frac{1}{2^{2i}}\\\\\n            &=2^{n}T(0) +n^4 \\sum^{k -1}_{i=0} \\frac{1}{2^{2i}}\\\\\n            &=n^4 \\sum^{k -1}_{i=0} \\frac{1}{2^{2i}}\\\\\n            &=n^4 \\sum^{k -1}_{i=0} 2^{-2i}\\\\\n            &=n^4 * \\frac{1-2^k}{1-2}\\\\\n            &=n^4\\\\\n            &\\in O(n^4)\n        \\end{align*}\n\n        \\item $T(n) = 3T(n/3) + n log(n)$\n        \\begin{equation*}\n            n = 3^k\n        \\end{equation*}\n        \\begin{align*}\n            T(n) &= 3T(n/3) + n log(n)\\\\\n            &= 3(3T(\\frac{n}{3^2}) + \\frac{n}{3} log(\\frac{n}{3})) + n log(n)\\\\\n            &= 3^k T(\\frac{n}{3^k}) + \\sum_{i =0 }^{k-1} n log(\\frac{n}{3^i})\\\\\n            &= 3^k T(0) + \\sum_{i =0 }^{k-1}n log(\\frac{n}{3^i})\\\\\n            &= n \\sum_{i =0 }^{k-1} log(\\frac{n}{3^i})\\\\\n            &= n log^2(n) \\\\\n            &\\in n log^2(n)\n        \\end{align*}\n\n        \\item $T(n) = 3T(n/3) + \\frac{\\sqrt{n}}{log(n)}$\n        \\begin{equation*}\n            n = 3^k\n        \\end{equation*}\n        \\begin{align*}\n            T(n) &= 3T(n/3) + \\frac{\\sqrt{n}}{log(n)}\\\\\n            &= 3(3T(\\frac{n}{3^2}) + \\frac{\\sqrt{n/3}}{log(n/3)}) + \\frac{\\sqrt{n}}{log(n)}\\\\\n            &= 3^2T(\\frac{n}{3^2}) + 3\\frac{\\sqrt{n/3}}{log(n/3)}) + \\frac{\\sqrt{n}}{log(n)}\\\\\n            &= 3^2(3T(\\frac{n}{3^3}) + \\frac{\\sqrt{n/3}}{log(n/3)}) + 3\\frac{\\sqrt{n/3}}{log(n/3)} + \\frac{\\sqrt{n}}{log(n)}\\\\\n            &= 3^3T(\\frac{n}{3^3}) + 3^2\\frac{\\sqrt{n/3}}{log(n/3)} + 3\\frac{\\sqrt{n/3}}{log(n/3)} + \\frac{\\sqrt{n}}{log(n)}\\\\\n            &= 3^kT(\\frac{n}{3^k}) + \\sum_{i =0}^{k-1}3^i\\frac{\\sqrt{n/3^i}}{log(n/3^i)} \\\\\n            &= 3^kT(0) + \\sum_{i =0}^{k-1}3^i\\frac{\\sqrt{n/3^i}}{log(n/3^i)}\\\\\n            &= \\sum_{i =0}^{k-1}3^i\\frac{\\sqrt{n/3^i}}{log(n/3^i)}\\\\\n            &= \\sum_{i =0}^{k-1}3^i\\frac{\\sqrt{n/3^i}}{log(n/3^i)} \\leq 3^{log(n)}\\\\\n            \\in O(3^{log(n)})\n        \\end{align*}\n        \\item $T(n) = T(n - 3) +n$\n        \\begin{equation*}\n            n = 3k\n        \\end{equation*}\n        \\begin{align*}\n            T(n) &= T(n -3) + n\\\\\n            T(n-1) &= T(n-4) + n\\\\\n            T(n-3) &= T(n-6) + n\\\\\n            &= T(n-6) + 2n\\\\\n            &= T(n-3k) + kn\\\\\n            &= T(n-3\\frac{n}{3}) + \\frac{n}{3}n\\\\\n            &= T(0) + \\frac{n}{3}n\\\\\n            &= \\frac{n^2}{3}\\\\\n            &\\in O(n^2)\n        \\end{align*}\n    \\end{enumerate}\n    \\item  Modify the algorithm for multiplying two numbers $X$ and $Y$(that with complexity $n^{1,59}$), dividing each number in three parts. Describe the algorithm and derive its complexity. Is it better than dividing by two parts? Explain.\n\n    The algorithm would keep the same functioning as the old one, the only difference being how it's divided. As such, the recurrence would be\n\n    \\begin{align*}\n        T(n) = 8T(n/3) + kn\n    \\end{align*}\n\n    Which results in a complexity $O(n^{1.893})$ which would result in worst performance than using a two parts split\n\n    \\item The run time of an algorithm $A$ for solving a problem is given by the recurrence $T(n) = 7T(n/4) + n.$ A different algorithm $A^{\\prime}$ for solving the same problem has a running time given by $T^{\\prime}(n) =aT^{\\prime}(n/7) +n$. Determine  the  integer  value $a$ with  which  algorithm $A$ is  better  than  algorithm $A^{\\prime}$.  Explain  your process.\n\n    By the use of the master theorem, we know that $T(n) \\in O(n^{1.404})$ and $T'(n) \\in O(n)$, so only when $n = 1$ the algorithms are going to make the same number of steps.\n\n    \\item For each of the following algorithms, which each receive an integer as input, determine what they do,establish the corresponding recurrence,and solve it to find the computational complexity.\n    \\begin{lstlisting}\n    ALGORITHM BR(n)\n        // Input a positive integer n\n        if n = 1 return 1\n        else return BR(floor(n/2)) + 1\n    \\end{lstlisting}\n\n    This algorithm returns the power of 2 closest to the input number, without surpassing it. The recurrence would be: $T(n) = T(n/2) + 1$, which complexity would be $O(log(n))$\n\n    \\begin{lstlisting}\n    ALGORITHM Question(n)\n        // Input a positive integer n\n        if n = 1 return 1\n        else return Question(n-1) + n*n*n\n    \\end{lstlisting}\n\n    This algorithm gives us the sum of the cubes of all numbers until n. As such, the recurrence would be $T(n) = T(n - 1) + n^3$, which results in complexity of $O(n^4)$\n    \\begin{align*}\n        n = k\n        T(n) &= T(n - 1) + n^3\\\\\n        T(n - 1 ) &= T(n - 2) + 2n^3\\\\\n        T(n) &= T(n - k) + kn^3\\\\\n        T(n) &= T(0) + n^4\\\\\n        \\in O(n^4)\n    \\end{align*}\n\n    \\item The Towers of Hanoi problem is often used as an example when teaching recursion. Six disks of different sizes are piled on a peg in order by size, with the largest at the bottom. There are two empty pegs. The problem is to move all the disks to the third peg by moving only one at a time a never placing a disk on top of a smaller one. The second peg may be used for intermediate moves. The usual solution recursively moves all but the last disk from the starting peg to the spare peg, then moves the remaining disks on the start peg to the destination peg, and then recursively moves all the others from the spare peg to the destination peg. Illustrate these steps and explain the procedure in a pseudocode. Write a recurrence equation to determine the number of moves done and solve it.\n\n    The solution proposed would be fairly easy to implement following the next pseudocode:\n    \\begin{lstlisting}\n    Towers(disk, source, destination, auxiliar)\n        //Disk is the number of the disk to be moved, source is the starting\n        point, destination is the goal and auxiliar is the spare peg\n        if (disk == 1)\n            move(disk, destination)\n        else\n            Towers(n - 1, source, auxiliar, destination)\n            move(disk, destination)\n            Towers(n - 1, auxiliar, destination, source)\n    \\end{lstlisting}\n\n    \\begin{align*}\n        T(1) &= 1\\\\\n        n &= k +1\\\\\n        T(n) &= 2T(n-1)\\\\\n        &= 2^2T(n-2)\\\\\n        &= 2^kT(n-k)\\\\\n        &= 2^{n-1}T(n-(n -1))\\\\\n        &= 2^{n-1}T(1)\\\\\n        &= 2^{n-1}\\\\\n        &\\in \\theta(2^{n-1})\n    \\end{align*}\n\n\\end{enumerate}\n\\end{document}", "meta": {"hexsha": "8a9415edd4b65ca7e1307f73ed3a7d1aa372c112", "size": 10287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FirstPart/Homework2.tex", "max_stars_repo_name": "edjacob25/ComputationalFundaments", "max_stars_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FirstPart/Homework2.tex", "max_issues_repo_name": "edjacob25/ComputationalFundaments", "max_issues_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FirstPart/Homework2.tex", "max_forks_repo_name": "edjacob25/ComputationalFundaments", "max_forks_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3171806167, "max_line_length": 798, "alphanum_fraction": 0.5012151259, "num_tokens": 3261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.42554502320999416}}
{"text": "\\section{Models}\nIn this section, we describe the models used in this paper: BI-LSTM, CRF, and Bert. \n\\begin{figure*}[t]\n    \\begin{center}\n        \\includegraphics[width=\\textwidth]{figures/model_struct.pdf}\n    \\end{center}\n    \\caption{Two model in this paper, BiLSTM + CRF \\& Bert + CRF}\n    \\label{fig:model}\n\\end{figure*}\n\n\n\\subsection{Bi-LSTM}\n\\label{sec:lstm}\n\nRecurrent neural networks (RNNs) are a family of neural networks that operate on sequential data. They take as input a sequence of vectors $(\\mathbf{x}_1, \\mathbf{x}_2, \\ldots, \\mathbf{x}_n)$ and return another sequence $(\\mathbf{h}_1, \\mathbf{h}_2, \\ldots, \\mathbf{h}_n)$ that represents some information about the sequence at every step in the input. Although RNNs can, in theory, learn long dependencies, in practice they fail to do so and tend to be biased towards their most recent inputs in the sequence. Long Short-term Memory Networks (LSTMs) have been designed to combat this issue by incorporating a memory-cell and have been shown to capture long-range dependencies. They do so using several gates that control the proportion of the input to give to the memory cell, and the proportion from the previous state to forget.\nWe use the following implementation:\n\\\\\n\\begin{align*}\n\\mathbf{i}_{t} &= \\sigma(\\mathbf{W}_{xi}\\mathbf{x}_{t} + \\mathbf{W}_{hi}\\mathbf{h}_{t-1} + \\mathbf{W}_{ci}\\mathbf{c}_{t-1} + \\mathbf{b}_{i})\\\\\n\\mathbf{c}_{t} &= (1 - \\mathbf{i}_{t})\\odot\\mathbf{c}_{t-1} +\\\\\n&\\qquad \\mathbf{i}_{t}\\odot \\tanh(\\mathbf{W}_{xc}\\mathbf{x}_{t} + \\mathbf{W}_{hc}\\mathbf{h}_{t-1} + \\mathbf{b}_{c})\\\\\n\\mathbf{o}_{t} &= \\sigma(\\mathbf{W}_{xo}\\mathbf{x}_{t} + \\mathbf{W}_{ho}\\mathbf{h}_{t-1} + \\mathbf{W}_{co}\\mathbf{c}_{t} + \\mathbf{b}_{o})\\\\\n\\mathbf{h}_{t} &= \\mathbf{o}_{t}\\odot\\tanh(\\mathbf{c}_{t}),\n\\end{align*}\nwhere $\\sigma$ is the element-wise sigmoid function, and $\\odot$ is the element-wise product.\n\nFor a given sentence $(\\mathbf{x}_1, \\mathbf{x}_2, \\ldots, \\mathbf{x}_n)$ containing $n$ words, each represented as a $d$-dimensional vector, an LSTM computes a representation $\\overrightarrow{\\mathbf{h}_t}$ of the left context of the sentence at every word $t$. Naturally, generating a representation of the right context $\\overleftarrow{\\mathbf{h}_t}$ as well should add useful information. This can be achieved using a second LSTM that reads the same sequence in reverse. We will refer to the former as the forward LSTM and the latter as the backward LSTM. These are two distinct networks with different parameters. This forward and backward LSTM pair is referred to as a bidirectional LSTM.\n\nThe representation of a word using this model is obtained by concatenating its left and right context representations, $\\mathbf{h}_{t} = [\\overrightarrow{\\mathbf{h}_{t}} ; \\overleftarrow{\\mathbf{h}_{t}}]$. These representations effectively include a representation of a word in context, which is useful for numerous tagging applications.\n\n\\subsection{CRF Tagging Models}\n\\label{sec:crf}\n\n\\begin{figure*}[t]\n    \\begin{center}\n        \\includegraphics[width=\\textwidth]{figures/batch.pdf}\n    \\end{center}\n    \\caption{Train Set \\& Dev Set epoch \\& F1 distribute in CWS problem}\n    \\label{fig:batch}\n\\end{figure*}\n\n\\begin{figure*}[t]\n    \\begin{center}\n        \\includegraphics[width=\\textwidth]{figures/batch2.pdf}\n    \\end{center}\n    \\caption{Train Set \\& Dev Set epoch \\& F1 distribute in NER problem}\n    \\label{fig:batch2}\n\\end{figure*}\n\nA very simple---but surprisingly effective---tagging model is to use the $\\mathbf{h}_t$'s as features to make independent tagging decisions for each output $y_t$ ~\\cite{ling2015finding}. Despite this model's success in simple problems like POS tagging, its independent classification decisions are limiting when there are strong dependencies across output labels. NER is one such task, since the ``grammar'' that characterizes interpretable sequences of tags imposes several hard constraints (e.g., I-PER cannot follow B-LOC;) that would be impossible to model with independence assumptions.\n\nTherefore, instead of modeling tagging decisions independently, we model them jointly using a conditional random field. For an input sentence\n$$\\mathbf{X} = (\\mathbf{x}_1, \\mathbf{x}_2, \\ldots, \\mathbf{x}_n),$$\nwe consider $\\mathbf{P}$ to be the matrix of scores output by the bidirectional LSTM network. $\\mathbf{P}$ is of size $n~\\times~k$, where $k$ is the number of distinct tags, and $P_{i, j}$ corresponds to the score of the $j^{th}$ tag of the $i^{th}$ word in a sentence. For a sequence of predictions\n$$\\mathbf{y} = (y_1, y_2, \\ldots, y_n),$$\nwe define its score to be\n$$s(\\mathbf{X}, \\mathbf{y})=\\sum_{i=0}^{n} A_{y_i, y_{i+1}} + \\sum_{i=1}^{n} P_{i, y_i}$$\nwhere $\\mathbf{A}$ is a matrix of transition scores such that $A_{i, j}$ represents the score of a transition from the tag $i$ to tag $j$. $y_0$ and $y_n$ are the \\textit{start} and \\textit{end} tags of a sentence, that we add to the set of possible tags. $\\mathbf{A}$ is therefore a square matrix of size $k+2$.\n\\\\\n\\\\\nA softmax over all possible tag sequences yields a probability for the sequence $\\mathbf{y}$:\n$$p(\\mathbf{y} | \\mathbf{X}) = \\frac{\n\te^{s(\\mathbf{X}, \\mathbf{y})}\n}{\n\t\\sum_{\\mathbf{\\widetilde{y}} \\in \\mathbf{Y_X}} e^{s(\\mathbf{X}, \\mathbf{\\widetilde{y}})}\n}.$$\nDuring training, we maximize the log-probability of the correct tag sequence:\n\n\\subsection{Bert}\n\n\\input{figures/corps.tex}\n\\input{figures/batch_size2.tex}\n\\input{figures/batchSize.tex}\n\\input{figures/hyper_param.tex}\n\\input{figures/bert.tex}\n\\input{figures/best.tex}\n\n\nBERT is one of the key innovations in the recent progress of contextualized representation learning \\cite{peters2018deep,howard2018universal,devlin2018bert}.\nThe idea behind the progress is that even though the word embedding layer (in a typical neural network for NLP) is trained from large-scale corpora, training a wide variety of neural architectures that encode contextual representations only from the limited supervised data on end tasks is insufficient.\nUnlike ELMo \\cite{peters2018deep} and ULMFiT \\cite{howard2018universal} that are intended to provide additional features for a particular architecture that bears human's understanding of the end task, BERT adopts a fine-tuning approach that requires almost no specific architecture for each end task. This is desired as an intelligent agent should minimize the use of prior human knowledge in the model design. Instead, it should learn such knowledge from data. BERT has two parameter intensive settings: \n\n\n\\begin{itemize}\n    \\item {\\bf \\bertbase}: L=12, H=768, A=12, Total Parameters=110M\n    \\item {\\bf \\bertlarge}: L=24, H=1024, A=16, Total Parameters=340M\n\\end{itemize}", "meta": {"hexsha": "b8c85d7c3a36751782e997a34b350ec3e0ceec80", "size": 6679, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "final_paper/sections/models.tex", "max_stars_repo_name": "iofu728/Chinese_T-Sequence-annotation", "max_stars_repo_head_hexsha": "a923abe2c8f09dbee752937d80a4c063e581d124", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-06-26T04:43:26.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-09T06:19:01.000Z", "max_issues_repo_path": "final_paper/sections/models.tex", "max_issues_repo_name": "iofu728/Chinese_T-Sequence-annotation", "max_issues_repo_head_hexsha": "a923abe2c8f09dbee752937d80a4c063e581d124", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "final_paper/sections/models.tex", "max_forks_repo_name": "iofu728/Chinese_T-Sequence-annotation", "max_forks_repo_head_hexsha": "a923abe2c8f09dbee752937d80a4c063e581d124", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-04-09T06:19:02.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-19T13:50:52.000Z", "avg_line_length": 76.7701149425, "max_line_length": 831, "alphanum_fraction": 0.7364874981, "num_tokens": 1912, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334527, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4254963740894445}}
{"text": "\\documentclass[a4paper,10.5pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{wrapfig}\n\\usepackage{amssymb}\n\\usepackage{setspace}\n\\usepackage{bm}\n\\usepackage{tikz}\n\\usetikzlibrary{decorations.pathmorphing,decorations.markings}\n\\usepackage{float}\n\\usepackage{cite}\n\\usepackage{fancyhdr}\n\\usepackage{lastpage}\n\\usepackage{listings}\n\\usepackage{graphicx}\n\\usepackage{multicol}\n\\usepackage{enumitem}\n\\usepackage{color}\n\\renewcommand{\\thefootnote}{\\alph{footnote}}\n\n\n\\setlength{\\textwidth}{16cm}\n\\setlength{\\oddsidemargin}{0cm}\n\\setlength{\\textheight}{23cm}\n\\setlength{\\topmargin}{-1cm}\n\\setlength\\parindent{0pt}\n\\renewcommand{\\baselinestretch}{1.2}\n\\addtolength{\\skip\\footins}{7pt}\n\n\\pagestyle{fancyplain}\n\\lhead{}\n\\rhead{Tom Young 2021}\n\\cfoot{}\n\\lfoot{}\n\n\n\\begin{document}\n\n\\subsection{Gaussian Process Regression}\n\nA Gaussian process (GP) is a collection of random variables such that any collection obey a multivariate normal distribution (MVN). Generally,\n\\begin{equation}\n\t\\text{MVN} \\sim \\mathcal{N}(\\boldsymbol{\\mu}, \\boldsymbol{\\Sigma})\n\\end{equation}\nis defined by its mean ($\\boldsymbol{\\mu} \\in \\mathbb{R}^d$) and covariance ($\\boldsymbol{\\Sigma} \\in \\mathbb{R}^{d \\times d}$, positive semi-definite) for a $d$-dimensional distribution.%\\footnote{The semi-definite requirement is because the PDF includes $\\boldsymbol{\\Sigma}^{-1}$.}\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{mvn_annotated.pdf}\n\t\\vspace{0.1cm}\n\t\\hrule \n\t\\caption{Various multivariate normal distributions in one and two dimensions.}\n\\end{figure}\n\nTo use a GP for regression the output ($y$) is defined in a linear way,\n\\begin{equation}\n\ty = \\sum_i w_i \\,\\phi_i(\\boldsymbol{x}) \\equiv \\boldsymbol{w}^T\\tilde{\\boldsymbol{x}}\n\\end{equation}\nwhere $\\boldsymbol{w}$ are the weights to be found and $\\phi_i$ is a non-linear basis function of the input values ($\\boldsymbol{x}$). The distribution of outputs and weights are set to be Gaussians,\n\\begin{equation}\n\t\\begin{aligned}\n\t\ty^* &= \\boldsymbol{w}^T\\tilde{\\boldsymbol{x}} + \\varepsilon \\qquad : \\quad\n\t\t\\varepsilon \\sim \\mathcal{N}(0, \\sigma^2)\\\\\n\t\tw &\\sim \\mathcal{N}(0, c\\mathbb{I})  \\qquad\\;\\; : \\quad c \\in \\mathbb{R}\n\t\\end{aligned}\t\n\\end{equation}\nwhere the asterisk denotes a predicted value, $\\boldsymbol{w}^T\\tilde{\\boldsymbol{x}} := z$ form the GP and $\\epsilon$ is a Gaussian error.\n\\\\\\\\\nTo do inference requires the posterior (predictive) distribution of $y$, given a set of known values. For the full set of $y$ then,\\footnote{As the sum of independent MVNs just sum their means and covariances.}\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\boldsymbol{y}^* &= \\boldsymbol{z} + \\boldsymbol{\\varepsilon} \\\\\n\t\t&\\sim \\mathcal{N}(\\boldsymbol{\\mu}, \\mathsf{K} + \\sigma^2\\mathbb{I})\n\t\\end{aligned}\n\\end{equation} \ndefining $\\mathsf{C} = \\mathsf{K} + \\sigma\\mathbb{I}$ and splitting the vectors and matrices into known (train) and an unknown (${}^*$) components,\n\n\\begin{equation}\n\t\\begin{pmatrix}\n\t\ty^*\\\\\n\t\t\\boldsymbol{y}_\\text{train}\n\t\\end{pmatrix}\n\t\\sim \\mathcal{N}\\left(\n\t\t\\begin{pmatrix}\n\t\t\t\\mu*\\\\\n\t\t\t\\boldsymbol{\\mu_\\text{train}}\n\t\t\\end{pmatrix}\n\t,\n\t\\begin{pmatrix}\n\t\t\\mathsf{C}^* & \\mathsf{C}^*_\\text{train} \\\\\n\t\t\\mathsf{C}^{* T}_\\text{train} & \\mathsf{C}_\\text{train}\n\t\\end{pmatrix}\n\t\\right)\n\\end{equation}\n\nthen the conditional distribution of $y^*$ is,\n\n\\begin{equation}\n\t(y^* | \\boldsymbol{y}_\\text{train}) \\sim \\mathcal{N}(\\mu^* +  \\mathsf{C}^{* T}_\\text{train}\\mathsf{C}_\\text{train}^{-1}(\\boldsymbol{y}_\\text{train} - \\boldsymbol{\\mu}_\\text{train})\n\t, \\mathsf{D})\n\\end{equation}\nwhere $\\mathsf{D}$ is the covariance the exact form of which is omitted. \n\\\\\\\\\n{\\large\\bfseries{References}}\n\n[1] C. E. Rasmussen and C. K. I. Williams, Gaussian Processes for Machine Learning, the MIT Press, 2006,\nISBN 026218253X.\n\n\n\\end{document}", "meta": {"hexsha": "3458741987e98bc3c3414efab242f6b3b9d92970", "size": 3810, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gaptrain/common/gp_intro/gp.tex", "max_stars_repo_name": "t-young31/gap-train", "max_stars_repo_head_hexsha": "864574abe20cc6072376e7c36ffb2ee1635e74e3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2021-02-16T15:25:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T12:09:37.000Z", "max_issues_repo_path": "gaptrain/common/gp_intro/gp.tex", "max_issues_repo_name": "duartegroup/gap-train", "max_issues_repo_head_hexsha": "864574abe20cc6072376e7c36ffb2ee1635e74e3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-04-09T16:07:47.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-05T15:40:50.000Z", "max_forks_repo_path": "gaptrain/common/gp_intro/gp.tex", "max_forks_repo_name": "t-young31/gap-train", "max_forks_repo_head_hexsha": "864574abe20cc6072376e7c36ffb2ee1635e74e3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-23T16:55:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-03T23:40:28.000Z", "avg_line_length": 34.6363636364, "max_line_length": 284, "alphanum_fraction": 0.7149606299, "num_tokens": 1316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.42549636423348486}}
{"text": "\n\\documentclass[a4paper,UKenglish,cleveref, autoref]{lipics-v2019}\n%This is a template for producing LIPIcs articles.\n%See lipics-manual.pdf for further information.\n%for A4 paper format use option \"a4paper\", for US-letter use option \"letterpaper\"\n%for british hyphenation rules use option \"UKenglish\", for american hyphenation rules use option \"USenglish\"\n%for section-numbered lemmas etc., use \"numberwithinsect\"\n%for enabling cleveref support, use \"cleveref\"\n%for enabling cleveref support, use \"autoref\"\n\n\n%\\graphicspath{{./graphics/}}%helpful if your graphic files are in another directory\n\n\\bibliographystyle{plainurl}% the mandatory bibstyle\n\n\\title{Integrality of stable matchings polytope} %TODO Please add\n\n% \\titlerunning{Dummy short title}%optional, please use if title is longer than one line\n\n\\author{Kishlaya Jaiswal}{Chennai Mathematical Institute }{kishlaya@cmi.ac.in}{}{}%TODO mandatory, please use full name; only 1 author per \\author macro; first two parameters are mandatory, other parameters can be empty. Please provide at least the name of the affiliation and the country. The full address is optional\n\n\\authorrunning{K. Jaiswal}%TODO mandatory. First: Use abbreviated first/middle names. Second (only in severe cases): Use first author plus 'et al.'\n\n\\Copyright{Kishlaya Jaiswal}%TODO mandatory, please use full first names. LIPIcs license is \"CC-BY\";  http://creativecommons.org/licenses/by/3.0/\n\n%\\ccsdesc[100]{General and reference~General literature}\n%\\ccsdesc[100]{General and reference}%TODO mandatory: Please choose ACM 2012 classifications from https://dl.acm.org/ccs/ccs_flat.cfm\n\n%\\keywords{Dummy keyword}%TODO mandatory; please add comma-separated list of keywords\n\n%\\category{}%optional, e.g. invited paper\n\n%\\relatedversion{}%optional, e.g. full version hosted on arXiv, HAL, or other respository/website\n%\\relatedversion{A full version of the paper is available at \\url{...}.}\n\n%\\supplement{}%optional, e.g. related research data, source code, ... hosted on a repository like zenodo, figshare, GitHub, ...\n\n%\\funding{(Optional) general funding statement \\dots}%optional, to capture a funding statement, which applies to all authors. Please enter author specific funding statements as fifth argument of the \\author macro.\n\n%\\acknowledgements{I want to thank \\dots}%optional\n\n\\nolinenumbers %uncomment to disable line numbering\n\n\\hideLIPIcs  %uncomment to remove references to LIPIcs series (logo, DOI, ...), e.g. when preparing a pre-final version to be uploaded to arXiv or another public repository\n\n%Editor-only macros:: begin (do not touch as author)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\EventEditors{John Q. Open and Joan R. Access}\n\\EventNoEds{2}\n\\EventLongTitle{42nd Conference on Very Important Topics (CVIT 2016)}\n\\EventShortTitle{CVIT 2016}\n\\EventAcronym{CVIT}\n\\EventYear{2016}\n\\EventDate{December 24--27, 2016}\n\\EventLocation{Little Whinging, United Kingdom}\n\\EventLogo{}\n\\SeriesVolume{42}\n\\ArticleNo{23}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\theoremstyle{definition}\n\\newtheorem*{lemma*}{Lemma}\n\\newtheorem*{definition*}{Definition}\n\\newtheorem*{theorem*}{Theorem}\n\\begin{document}\n\n\\maketitle\n\n%TODO mandatory: add short abstract of the document\n\\begin{abstract}\nGiven a complete bipartite graph with edge preferences, we know that Gale-Shapley algorithm confirms the existence of (and outputs) a stable matching. Further, we know that perfect matching polytope is integral. We want to add additional constraints corresponding to stability and see if these new constraints still keeps the polytope integral.\n\nU. Rothblum showed that integrality of polytope remains intact even if the preference lists of men and women are incomplete, in his 1992 paper - \\textsl{Characterization of stable matchings as extreme points of a polytope}, which I shall present now.\n\\end{abstract}\n\n\\section{Modelling Perfect Matchings}\n\\label{sec:typesetting-summary}\n\nConsider the problem of determining a perfect matching for complete bipartite graph $(U,V)$ (with $|U|=|V|$). We know that it can be modeled using a system of linear inequalities as follows:\n\n\\begin{align}\n    \\sum_{j \\in V} x_{ij} &= 1 & \\forall i \\in U \\\\\n    \\sum_{i \\in U} x_{ij} &= 1 & \\forall j \\in V \\\\\n    x_{ij} &\\geq 0 & \\forall (i,j) \\in U \\times V\n\\end{align}\n\nWe have variables $\\{x_{ij}\\}$ for each edge $(i,j) \\in U \\times V$, such that $x_{ij} = 1$ iff $(i,j)$ edge is in the matching, otherwise $x_{ij}=0$.\n\n\\begin{remark*}\nIn convex optimization problems, when the underlying polytope is integral, linear programming can be used to solve integer programming problems for the given system of inequalities, a problem that can otherwise be more difficult.\n\\end{remark*}\n\nSo the first question arises is if this polytope $P$ is integral, after the relaxation of variables $0 \\leq x_{ij} \\leq 1$?\n\nHere is an interesting observation: the matrix $(x_{ij})_{U \\times V}$ is a doubly stochastic matrix iff $\\{x_{ij}\\}$ is a feasible point for the polytope $P$. And furthermore, each perfect matching corresponds to a permutation matrix.\n\n\\textsl{Birkhoff-von Neumann} theorem states that polytope $P$ is the convex hull of $U \\times V$ permutation matrices and furthermore that the vertices of the polytope $P$ are precisely the permutation matrices. Therefore, the perfect matchings are the extreme (integer) points of this polytope.\n\n% \\section{Stable Perfect Matching}\n\n% Returning back to our stable perfect matching problem, we first ask: can the stability constraint be modeled as a linear inequality? And if so, then does the resulting polytope still has the integrality of extreme points?\n\n% Rothblum addressed this problem in a more general setting, that is when lists are incomplete, strict and singlehood is permitted (some vertices can remain unmatched). This is what we shall discuss now.\n\n\\section{Stable Matching with Incomplete Lists}\n\nWe begin with sets of men $M$ and women $W$ (not necessarily equal in size). Each man $m$ has preference list $W_m \\subseteq W$ along with a strict preference order $>_m$ on it, such that $w_1 >_m w_2$ (where $w_1, w_2 \\in W_m$) means $m$ prefers $w_1$ over $w_2$. Similarly we have $(M_w, >_w)$ as the preference list for each woman $w$.\n% We will assume that the lists are consistent that is $w \\in W_m \\iff m \\in M_w$.\n\nNow since the lists are incomplete, some people might remain unmatched as well. we need to re-setup linear inequalities to denote a matching between men and women:\n\n% =============================================\n%  Make the following equations align properly\n% =============================================\n\n\\begin{align}\n    \\sum_{j \\in W} x_{ij} \\leq 1 && \\forall i \\in M \\\\\n    \\sum_{i \\in M} x_{ij} \\leq 1 && \\forall j \\in W \\\\\n    x_{ij} \\geq 0 && \\forall (i,j) \\in M \\times W\n\\end{align}\n\nWe additionally also want that if a woman doesn't appears in some man's list then that edge variable should be zero, that is, let $A = \\{(m,w) \\mid m \\in M_w \\text{ and } w \\in W_m\\}$ be the set of possible pairs, then\n\n\\begin{align}\n    x_{ij} = 0 && \\forall (i,j) \\not \\in A\n\\end{align}\n\nNow we need the final constraint for stability. For that we redefine blocking pair. Given a matching $N$, $(m,w) \\in A$ blocks $N$ if any of the following holds:\n\\begin{itemize}\n    \\item $m$ and $w$ both have a partner in $N$ but $w >_m N(m)$ and $m >_w N(w)$\n    \\item Only $m$ has a partner in $N$ but $w >_m N(m)$\n    \\item Only $w$ has a partner in $N$ but $m >_w N(w)$\n    \\item Both $m$ and $w$ don't have partners in $N$\n\\end{itemize}\n\nHence the stability constraint should be:\n\n\\begin{align}\n    \\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} \\geq 1 && \\forall (m,w) \\in A\n\\end{align}\n\nIndeed if $\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} < 1 \\implies \\sum_{j >_m w} x_{mj} = \\sum_{m >_ w i} x_{iw} = x_{mw} = 0$ which means that either $m$ has no partner or if he does then $w >_m x(m)$ and similarly either $w$ has no partner or if she does then $m >_w x(w)$.\n\n\\begin{remark*}\nThe same stability constraint works in the case of equal sizes of both sets of men and women and complete lists also.\n\\end{remark*}\n\nWe also note that if $\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} = 1$ then either $m$ and $w$ are matched together or one of them has a strictly better and other has strictly worse partner.\n\nThe only other possibility is $\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} = 2$ which says that both $m$ and $w$ have strictly better partners.\n\\newline\n\nFinally, we relax our variables to $0 \\leq x_{ij} \\leq 1$ and discuss the integrality of the polytope $(4)-(8)$: \\textsl{the stable matching polytope}.\n\n% \\newpage\n\nWe begin by showing that every integer point is an extreme point. Before we proceed I'd like to add a remark here that the author directly concludes this as a consequence of Birkhoff theorem. In my opinion, the result is not so straight-forward as feasible points may not be doubly stochastic. So we shall state (and prove) here a generalization of the Birkhoff theorem from which the result shall follow.\n\n\\begin{definition*}\nA matrix $Q$ is said to be doubly substochastic if its entries are nonnegative and all its row and column sums are at most one.\n\\end{definition*}\n\\begin{definition*}\nA matrix P is said to be a partial permutation matrix if it has at most one nonzero entry in each row and column, and these nonzero entries (if any) are all $1$.\n\\end{definition*}\n\\begin{theorem*}\nEvery doubly substochastic matrix is a finite convex combination of partial permutation matrices. Conversely, a finite convex combination of partial permutation matrices is evidently double substochastic.\n\\end{theorem*}\n\\begin{proof}\nLet $Q$ be a doubly substochastic matrix. Consider the matrix $Q' = \\begin{bmatrix} Q & I-D_r\\\\I-D_c & Q^T\\end{bmatrix}$, where $D_r$ and $D_c$ are diagonal matrices with the row and column sums of $Q$ respectively. Notice that $Q'$ is now a doubly stochastic matrix and hence we can now apply Birkhoff theorem to complete the proof.\n\\end{proof}\n\nHere is a simple observation: Let $P$ be a polytope such that all it's integer points are extreme points, then for any subpolytope $Q \\subseteq P$ all it's integer points are extreme points.\n\nWe mention this because the equations $(4)-(6)$ form a simple polytope where each feasible point can be identified with a substochastic matrix and integral feasible point with a partial permutation matrix, and vice-versa. Hence we can apply our above theorem and observation to conclude that any integer point is an extreme point for the stable matching polytope.\n\\newline \n\nConversely, let $\\{x_{ij}\\}$ be an extreme point. We want to argue that if it is not integral then it can be written as a convex combination of two other feasible points. For that, we consider two extreme matchings which can be extracted out of any feasible solution. Denote by $S_M(x) = \\{m \\in M \\mid \\sum_{j \\in W} x_{mj} > 0\\}$ (men who weren't left unmatched). For $m \\in S_M(x)$ let $W^*(x,m)$ and $W_*(x,m)$ be the most preferred woman and the least preferred woman of $m$ in the list $\\{w \\mid x_{mw} > 0\\}$, respectively. Similarly we can define $S_W(x) = \\{w \\in W \\mid \\sum_{i \\in M} x_{iw} > 0\\}$ and maps $M^*(x,w)$ and $M_*(x,w)$ for all $w \\in S_W(x)$.\n\nWhat we shall do is for every man $m \\in S_M(x)$ increment the edge variable $(m, W^*(x,m))$ by $\\epsilon$ and decrement $(m, W_*(x,m))$ by $\\epsilon$. This shall give us another feasible solution. Similarly, if we exchange the increment/decrement in above process, then we get another feasible solution. And then $x$ is the middle point of these two feasible solutions. To make this idea precise, we define our extreme matchings $x^*$ and $x_*$ as follows:\n\n$$\n(x^*)_{mw} =\n     \\begin{cases}\n       1 &\\quad m \\in S_M(x) \\text{ and } w=W^*(x,m) \\\\\n       0 &\\quad \\text{otherwise.} \\\\\n     \\end{cases}\n$$\n\n$$\n(x_*)_{mw} =\n     \\begin{cases}\n       1 &\\quad m \\in S_M(x) \\text{ and } w=W_*(x,m) \\\\\n       0 &\\quad \\text{otherwise.} \\\\\n     \\end{cases}\n$$\n\nObserve that $x$ is a matching (integer point) iff $x^*=x_*$ that is both the most preferred and least preferred partner are same. So we consider $z = x^* - x_*$. To proceed, we state a few properties about $z$, corresponding to our original constraints:\n\n\\begin{itemize}\n    \\item $\\sum_{j \\in W} z_{ij} = 0, i \\in M$ (row sums are zero)\n    \\item $\\sum_{i \\in M} z_{ij} = 0, j \\in W$ (column sums are zero)\n    \\item $x_{ij} = 0 \\implies z_{ij} = 0, (i,j) \\in M \\times W$\n    \\item $z_{ij} = 0, (i,j) \\not \\in A$\n    \\item $\\left(\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} = 1 \\right) \\implies \\left(\\sum_{j >_m w} z_{mj} + \\sum_{m >_ w i} z_{iw} + z_{mw} = 0\\right)$\n\\end{itemize}\n\nAssuming these properties, we can choose a small enough $\\epsilon > 0$, such that both $x + \\epsilon z$ and $x - \\epsilon z$ are feasible solutions. Then we re-write $x = \\frac{1}{2}(x + \\epsilon z) + \\frac{1}{2}(x - \\epsilon z)$. Since $x$ was an extreme point, we conclude that $z=0$ and hence the integrality of $x$ follows.\n\nTo prove above-mentioned properties we shall build some results (which shall be of independent interest) using our intuition from stable marriage with complete lists problem. An essential result we had was men-optimal matching is women-pessimal and vice-versa. Rothblum establishes a similar result here.\n\n\\begin{lemma*}\nFor $(m,w) \\in A$,\n\\begin{itemize}\n    \\item $\\Big( \\big(m \\not \\in S_M(x)\\big)$ or $\\big(m \\in S_M(x)$ and $w \\geq_m W^*(x,m)\\big) \\Big)$ $\\implies$ $\\Big(\\sum_{i \\in M} x_{iw} = 1$ and $m \\leq_w M_*(x,w)\\Big)$ (Converse is also true provided $\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} = 1$)\n    \\item $\\big( m \\in S_M(x)$ and  $w = W^*(x,m) \\big) \\iff \\big( \\sum_{i \\in M} x_{iw} = 1$ and $m = M_*(x,w) \\big)$\n    \\item $m \\in S_M(x) \\iff \\sum_{j \\in W} x_{mj} = 1$\n\\end{itemize}\n\\end{lemma*}\n\nThe first two points dictate what we said about optimality vs pessimality, whose proofs follow from a simple manipulation of inequalities. But I, particularly, find the last point of more interest as it tells that the row sums are always either $0$ or $1$, which was apriori not at all expected. The proof technique used for this point is equally interesting and moreover helps in establishing the validity of the matchings $x^*$ and $x_*$.\n\nIt is clear that that if $\\sum_{j \\in W} x_{mj} = 1$ then $m \\in S_M(x)$. For the converse, Let us consider the set $F_W(x) = \\{w \\mid \\sum_{i \\in M} x_{iw}=1\\}$ and the map $W^*(x,.) : S_M(x) \\rightarrow F_W(x)$ (definition is valid because of the second point in the lemma). Moreover, injectivity also follows from the second point because if $w=W^*(x,m_1)=W^*(x,m_2)$ then $m_1 = M_*(x,w) = m_2$. Now consider the following inequality:\n\n$$|F_W(x)| = \\sum_{j \\in F_W(x)} \\sum_{i \\in M} x_{ij} = \\sum_{i \\in S_M(x)} \\sum_{j \\in F_W(x)} x_{ij} \\leq \\sum_{i \\in S_M(x)} 1 = |S_M(x)|$$\n\nImplying that it is surjective also and hence equality is achieved in the above equation, which tells us that for $i \\in S_M(x)$ $\\sum_{j \\in F_W(x)} x_{ij} = 1$, completing the proof.\n\nSimilarly, with the roles reversed, we have the analogous lemma:\n\\begin{lemma*}\nFor $(m,w) \\in A$,\n\\begin{itemize}\n    \\item $\\Big( \\big[w \\not \\in S_W(x)\\big]$ or $\\big[w \\in S_W(x)$ and $m \\geq_w M^*(x,w)\\big] \\Big)$ $\\implies$ $\\Big(\\sum_{j \\in W} x_{mj} = 1$ and $w \\leq_m W_*(x,m)\\Big)$ (Converse is also true provided $\\sum_{j >_m w} x_{mj} + \\sum_{m >_ w i} x_{iw} + x_{mw} = 1$)\n    \\item $\\big[ w \\in S_W(x)$ and  $m = M^*(x,w) \\big] \\iff \\big[ \\sum_{j \\in W} x_{mj} = 1$ and $w = W_*(x,m) \\big]$\n    \\item $w \\in S_W(x) \\iff \\sum_{i \\in M} x_{iw} = 1$\n\\end{itemize}\n\\end{lemma*}\n\nI would like to add that since the row and columns sums are always $1$ (or $0$ in case someone remains unmatched), as established by the above lemmas, the exact same proof goes through in the original stable marriage with complete lists instance.\n\n\\section{Conclusion}\n\nIt is interesting to note that these lemmas indeed add a lot of structure/restrictions on the feasible points. They can be used to give an easy proof for the \\textsl{Decomposition property}, which is: if $x$ and $y$ are two stable matchings, and $(m,w)$ is a pair in the matching $x$, then if one of them prefers the matching $x$ over $y$ then their partner prefers the matching $y$ over $x$ - which seems intuitive from our optimality vs pessimality result.\n\nAs a last remark, Rothblum adds that in the case of many-to-one matching, for example: students have to be matched to colleges where several students can be matched to a single college, depending upon the number of available seats; our results can be easily extended by cloning each college as many times as available seats in that college, and uniformly ordering them in each student's list.\n\n\\section{Further Work}\n\nFollowing this course, the next immediate question for me to ask would be: What happens if there are ties in the preference lists?\n\nIn such a case, the ordering on the preference lists will not be strict one. We have crucially used that strictness in our stability constraint and in the lemmas. So it is interesting to see where would (if) the above lemmas fail?\n\nWe have also seen in class that there are different notions of stability in case of ties. So, I would like to study about the following:\n\\begin{itemize}\n    \\item Can we model super-stability, strong-stability and weak-stability respectively as linear inequalities?\n    \\item Will the resulting polytope be integral with those matchings as their extreme points?\n\\end{itemize}\n\\end{document}\n\n", "meta": {"hexsha": "8178fc45eddf1d9d2c445bf0130fe99a4906f4b5", "size": 17594, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "topics_in_algo/report/main.tex", "max_stars_repo_name": "kishlaya/assignments", "max_stars_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-17T09:28:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-14T17:40:34.000Z", "max_issues_repo_path": "topics_in_algo/report/main.tex", "max_issues_repo_name": "kishlaya/assignments", "max_issues_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "topics_in_algo/report/main.tex", "max_forks_repo_name": "kishlaya/assignments", "max_forks_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.1937984496, "max_line_length": 667, "alphanum_fraction": 0.7110946914, "num_tokens": 5078, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.8128673178375734, "lm_q1q2_score": 0.42547129514147647}}
{"text": "\\chapter{Appendix: \\uclid{} Grammar}\n\n\\newcommand{\\paratitle}[1]{\\textsf{\\textbf{#1}}}\n\\newcommand{\\nonterminal}[1]{$\\langle \\textit{#1} \\rangle$}\n\n\\setlength{\\grammarindent}{12em} % increase separation between LHS/RHS \n\nThis appendix describes \\uclid{}'s grammar.\n\n\\section{Grammar of Modules and Declarations}\n\\paratitle{A model} consist of a list of modules. Each module consists of a list of declarations followed by an optional control block.\n\\begin{grammar}\n     <Model> ::= <Module>*\n\n     <Module> ::= \\keywordbf{module} <Id>~~ `{' <Decl>* <ControlBlock>? `}'\n\\end{grammar}\n\n\\paratitle{Declarations} can be of the following types.\n\\begin{grammar}\n     <Decl> ::= <TypeDecl> \n            \\alt <InputsDecl> \n            \\alt <OutputsDecl> \n            \\alt <VarsDecl> \n            \\alt <SharedVarsDecl> \n            \\alt <DefineDecl>\n            \\alt <ConstsDecl> \n            \\alt <ConstLitDecl>\n            \\alt <FuncDecl> \n            \\alt <ProcedureDecl> \n            \\alt <InstanceDecl>\n            \\alt <InitDecl> \n            \\alt <NextDecl> \n            \\alt <AxiomDecl>\n            \\alt <SpecDecl> \n\\end{grammar}\n\n\\paratitle{Type declarations} declare either a type synonym or an uninterpreted type.\n\\begin{grammar}\n     <TypeDecl> ::= \\keywordbf{type} <Id> `=' <Type> `;'\n              \\alt \\keywordbf{type} <Id> `;'\n\n\\end{grammar}\n\n\\paratitle{Variable declarations} can refer to inputs, outputs, state variables, symbolic constants, named constant literals, shared variables, or define declarations.\n\\begin{grammar}\n     <InputsDecl> ::=\n       \\keywordbf{input} ~ <IdList> `:' <Type> `;'\n\n     <OutputsDecl> ::=\n       \\keywordbf{output} ~ <IdList> `:' <Type> `;'\n\n     <VarsDecl> ::=\n       \\keywordbf{var} ~ <IdList> `:' <Type> `;'\n\n     <ConstsDecl> ::=\n       \\keywordbf{const} ~ <IdList> `:' <Type> `;'\n\n     <ConstLitDecl> ::=\n       \\keywordbf{const} ~ <Id> ~ `:' <Type> = <Number> `;'\n\n     <SharedVarsDecl> ::=\n       \\keywordbf{sharedvar} ~ <IdList> `:' <Type> `;'\n\n     <DefineDecl> ::= \n       \\keywordbf{define} <Id> `(' <IdTypeList> `)' `:' <Type> `=' <Expr>  `;'\n\n\\end{grammar}\n\n\\paratitle{Function declarations} refer to uninterpreted functions. \n\\begin{grammar}\n     <FuncDecl> ::= \n       \\keywordbf{function} <Id> `(' <IdTypeList> `)' `:' <Type> `;'\n\n\\end{grammar}\n\n\\paratitle{Procedure declarations} consist of a formal parameter list, a list of return values and types, \nfollowed by optional pre-/post-conditions and the list of state variables modified by procedure.\n\\begin{grammar}\n     <ProcedureDecl> ::=\n       \\keywordbf{procedure} <Id> `(' <IdTypeList> ')' <ProcReturnArg>? \\\\\n       <RequireExprs> <EnsureExprs> <ModifiesExprs> \\\\\n       <BlkStmt>\n\n     <ProcReturnArg> ::= \\keywordbf{returns} `(' <IdTypeList> `)'\n\n     <RequireExprs> ::= ( \\keywordbf{requires} <Expr> `;' )*\n\n     <EnsureExprs> ::= ( \\keywordbf{ensures} <Expr> `;' )*\n\n     <ModifiesExprs> ::= ( \\keywordbf{modifies} <IdList> `;' )*\n\n\\end{grammar}\n\n\\paratitle{Instance declarations} allow the instantiation (duh!) of other modules. They consist of the instance name, the name of the module being instantiated and the list of mappings for the instances' inputs, output and shared variables. \n\\begin{grammar}\n     <InstanceDecl> ::= \\keywordbf{instance} <Id> `:' <Id> <ArgMapList> `;'\n\n     <ArgMapList>   ::= `(' `)' \n                    \\alt `(' <ArgMap> `,' <ArgMapList> `)'\n\n     <ArgMap> ::= <Id> `:' `(' `)' \n              \\alt <Id> `:' `(' <Expr> `)'\n             \n\\end{grammar}\n\n\\paratitle{Axioms} refer to assumptions while a \\paratitle{specification declaration} refers to design \\keywordbf{invariants}. Note \\keywordbf{axiom} and \\keywordbf{assume} are synonyms, as are \\keywordbf{property} and \\keywordbf{invariant}.\n\n\\begin{grammar}\n     <AxiomDecl> ::= <AxiomKW> <Id> `:' <Expr> `;'\n                 \\alt <AxiomKW> <Expr> `;'\n\n     <AxiomKW> ::= \\keywordbf{axiom} | \\keywordbf{assume}\n\n     <SpecDecl> ::= <PropertyKW> <Id> `:' <Expr> `;'\n                 \\alt <PropertyKW> <Expr> `;'\n\n     <PropertyKW> ::= \\keywordbf{property} | \\keywordbf{invariant}\n\\end{grammar}\n\n\\paratitle{Init} and \\paratitle{next} blocks consist of lists of statements.\n\\begin{grammar}\n     <InitDecl> ::= \\keywordbf{init} <BlkStmt>\n\n     <NextDecl> ::= \\keywordbf{next} <BlkStmt>\n\n\\end{grammar}\nAssignment statements in the \\keywordbf{next} block declaration must\nassign primed variables only, and are concurrently evaluated.\n\n\\section{Statement Grammar}\n\\paratitle{Statements} are the following types, most of which should be familiar. Note the support for simultaneous assignment \\`a la Python. The keyword \\keywordbf{next} allows for synchronous scheduling of instantiated modules.\n\\begin{grammar}\n     <Statement> \n       ::= \\keywordbf{skip} `;' \n       \\alt \\keywordbf{assert} <Expr> `;'\n       \\alt \\keywordbf{assume} <Expr> `;'\n       \\alt \\keywordbf{havoc} <Id>  `;'\n       \\alt <LhsList> `=' <ExprList> `;'\n       \\alt \\keywordbf{call} `(' <LhsList> `)' `=' <Id> <ExprList> `;'\n       \\alt \\keywordbf{call} <Id> `(' <ExprList> `)' `;'\n       \\alt \\keywordbf{next} `(' <Id> `)' `;'\n       \\alt <IfStmt>\n       \\alt <CaseStmt>\n       \\alt <ForLoop>\n       \\alt <WhileLoop>\n       \\alt <BlkStmt>\n\\end{grammar}\n\n\\paratitle{Block statements} are a list of variables with local scope, and a list of statements.\n\n\\begin{grammar}\n    <BlkStmt> ::= `{' <BlockVarDecl>* <Statement>* `}'\n\n    <BlockVarDecl> ::= \\keywordbf{var} <IdList> `:' <Type> `;'\n\\end{grammar}\n\n\n\\paratitle{Assignments} and \\paratitle{call} statements refer to the nonterminal \\nonterminal{LhsList}. As the name suggests, this is a list of syntactic forms that can appear on the left hand side of an assignment. \\nonterminal{Lhs} are of four types: (i) identifiers, bitvector slices within identifiers, (iii) array indices, and (iv) fields within records.\n\\begin{grammar}\n    <LhsList> ::= <Lhs> (`,' <Lhs>)*\n\n    <Lhs> ::= <Id>\n\t  \\alt <Id> `'' \n          \\alt <Id> `[' <Expr> `:' <Expr> `]'\n          \\alt <Id> `[' <ExprList> `]'\n          \\alt <Id> (`.' <Id>)+\n\\end{grammar}\n\n\\paratitle{If} statements are as per usual. ``Braceless'' if statements are not permitted.\n\\begin{grammar}\n    <IfStmt> ::= \n    \\keywordbf{if} `(' <CondExpr> `)'  <BlkStmt> \\\\ \\keywordbf{else} <BlkStmt>\n    \\alt \\keywordbf{if} `(' <CondExpr> `)'  <BlkStmt>\n\n    <IfExpr> ::= <Expr> | *\n\\end{grammar}\n\n\\paratitle{Case} statements are as follows.\n\\begin{grammar}\n    <CaseStmt> ::= \\keywordbf{case} <CaseBlock>* \\keywordbf{esac}\n\n    <CaseBlock> ::= <Expr> `:' <BlkStmt>\n                \\alt \\keywordbf{default} `:' <BlkStmt>\n\\end{grammar}\n\n\\paratitle{For loops} allow iteration over a statically defined range of values.\n\\begin{grammar}\n    <ForLoop> ::= \\keywordbf{for} <Id> \\keywordbf{in} \\keywordbf{range} `(' <Number> ',' <Number> `)' \\\\\n                  <BlkStmt>\n\\end{grammar}\n\n\\paratitle{While loops} allow unbounded iteration.\n\\begin{grammar}\n    <WhileLoop> ::= \\keywordbf{while} `(' <CondExpr> `)' \\\\\n                  <InvariantClause>* \\\\\n                  <BlkStmt>\n\n    <InvariantClause> ::= \\keywordbf{invariant} <Expr> `;'\n\\end{grammar}\n\n\\section{Expression Grammar}\nLet us turn to \\paratitle{expressions}, which may be quantified. \n\\begin{grammar}\n    <Expr> ::= <E1>\n\n    <E1> ::= <E2>\n         \\alt `(' \\keywordbf{forall} `(' <IdTypeList> `)' `::' E1 `)'\n         \\alt `(' \\keywordbf{exists} `(' <IdTypeList> `)' `::' E1 `)'\n\n\\end{grammar}\n\nThe usual logical and bitwise operators are allowed.\n\\begin{grammar}\n    <E2> ::= <E3> `<==>' <E2> | <E3>\n\n    <E3> ::= <E4> `==>' <E3> | <E4>\n\n    <E4> ::=  <E5> `&&' <E4> | <E5> `||' <E4> | \n         \\alt <E5> `&' <E4> | <E5> `|' <E4> | <E5> `^' <E4> \n         \\alt <E5>\n\\end{grammar}\n\nAs are relational operators, bitvector concatentation (++) and arithmetic.\n\n\\begin{grammar}\n<E5> ::=  <E6> <RelOp> <E6> | <E6>\n\n<RelOp> ::= `>' | `<' | `=' | `!=' | `>=' | `<='\n\n<E6> ::=  <E7> `++' <E6> | <E7>\n\n<E7> ::=  <E8> `+' <E7> | <E8>\n\n<E8> ::=  <E8> `-' <E9> | <E9>\n\n<E9> ::= <E9> `*' <E10> | <E9> `/' <E10> | <E10>\n\\end{grammar}\n\nThe unary operators are arithmetic negation (unary minus), logical negation and bitwise negation of bitvectors.\n\\begin{grammar}\n    <E10> ::= <UnOp> <E11> | <E11>\n\n    <UnOp> ::= `-' | `!' | `~'\n\\end{grammar}\n\nArray select, update and bitvector select operators are defined as follows.\n\\begin{grammar}\n    <E11> ::= <E12> `[' <Expr> (`,' <Expr>)* `]'\n          \\alt <E12> `[' <Expr> (`,' <Expr>)* `->' <Expr> `]'\n          \\alt <E12> `[' <Expr> `:' <Expr> `]'\n          \\alt <E12>\n\\end{grammar}\n\nFunction invocation, record selection, and access to variables in instantiated modules is as follows.\n\\begin{grammar}\n    <E12> ::=  <E13> `(' <ExprList> `)'\n          \\alt <E13> (`.' <Id>)+\n\\end{grammar}\n\nAnd finally, we have the terminal symbols, identifiers, record field access, tuples and the if-then-else operator.\n\\begin{grammar}\n    <E12> ::= \\keywordbf{false} | \\keywordbf{true} | <Number> | <String>\n          \\alt <Id> | <Id> `.' <Id>\n          \\alt `{' <Expr> (`,' <Expr>)* `}'\n          \\alt \\keywordbf{if} `(' <Expr> `)' \\keywordbf{then} <Expr> \\keywordbf{else} <Expr>\n\\end{grammar}\n\nStrings can only be used as arguments to the \\texttt{print} command in the control block.\n\n\\section{Types}\n\n\\begin{grammar}\n<Type> ::= <PrimitiveType> \n       \\alt <EnumType> \n       \\alt <TupleType> | <RecordType> \n       \\alt <ArrayType> \n       \\alt <SynonymType> \n       \\alt <ExternalType> \n%%     }\n\\end{grammar}\n\nSupported primitive types are Booleans, integers and bit-vectors. Bit-vector types are defined according the regular expression `bv[0-9]+' and the number following `bv' is the width of the bit-vector.\n\n\\begin{grammar}\n    <PrimitiveType> ::= \\keywordbf{boolean} | \\keywordbf{integer} | <BitVectorType>\n\\end{grammar}\n\nEnumerated types are defined using the \\keywordbf{enum} keyword.\n\\begin{grammar}\n    <EnumType> ::= \\keywordbf{enum} `{' <IdList> `}'\n\\end{grammar}\n\nTuple types are declared using curly brace notation.\n\\begin{grammar}\n    <TupleType> ::= `{' <Type>  (`,' <Type>)* `}'\n\\end{grammar}\n\nRecord types use the keyword \\keywordbf{record}.\n\\begin{grammar}\n    <Recordtype> ::= \\keywordbf{record} `{' <IdTypeList> `}'\n\\end{grammar}\n\nArray types are defined using square brackets. The list of types within square brackets defined the array's index type.\n\\begin{grammar}\n    <ArrayType> ::= `[' <Type> (`,' <Type>)* `]' <Type>\n\\end{grammar}\n\nType synonyms are just identifiers, while external types refer to synonym types defined in a different module.\n\\begin{grammar}\n    <SynonymType> ::= <Id>\n\n    <ExternalType> ::= <Id> `.' <Id>\n\\end{grammar}\n\n\\section{Control Block}\n\\paratitle{The control block} consists of a list of commands. A command can have an optional result object, an optional argument object, an optional list of command parameters and finally an optional list of argument expressions. \n\\begin{grammar}\n     <ControlBlock> ::= \\keywordbf{control}~~ `{' <Cmd>* `}'\n\n     <Cmd> ::= (<Id> `=' )? (<Id> `.')? <CmdName> \\\\\n              (`[' <IdList> `]')? <ExprList>? `;'\n\\end{grammar}\n\n\nThe following is a list of currently accepted commands.\n\n\\begin{grammar}\n    <CmdName> ::= `bmc' \\alt\n                  `bmc_LTL' \\alt\n                  `bmc_noLTL' \\alt\n                  `check' \\alt\n                  `clear\\_context' \\alt\n                  `induction' \\alt\n                  `print' \\alt\n                  `print\\_cex' \\alt\n                  `print\\_module' \\alt\n                  `print\\_results' \\alt\n                  `print\\_smt2'\n                  `synthesize\\_invariant' \\alt\n                  `unroll' \\alt\n                  `verify'\n\\end{grammar}\n\n\\section{Miscellaneous Nonterminals} \n\n\\nonterminal{IdList}, \\nonterminal{IdTypeList} and \\nonterminal{ExprList} are non-empty, comma-separated list of identifiers, identifier/type tuples and expressions respectively.\n\\begin{grammar}\n     <IdList> ::= <Id> \\alt <Id> `,' <IdList>\n\n     <IdTypeList> ::=  <Id> (`,' <Id>)* `:' <Type> \n                  \\alt <Id> (`,' <Id>)* `:' <Type> `,' <IdTypeList>\n\n     <ExprList> ::=  <Expr>\n                \\alt <Expr> `,' <ExprList>\n\\end{grammar}\n\n", "meta": {"hexsha": "f6ffe5c53ca99895b706250c71fc22a1eeac0056", "size": 12126, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tutorial/ch-grammar.tex", "max_stars_repo_name": "ymanerka/uclid", "max_stars_repo_head_hexsha": "355d060026ca141e81331acb05c4e2d8a52aa80f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 83, "max_stars_repo_stars_event_min_datetime": "2018-02-05T22:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T13:06:15.000Z", "max_issues_repo_path": "tutorial/ch-grammar.tex", "max_issues_repo_name": "ymanerka/uclid", "max_issues_repo_head_hexsha": "355d060026ca141e81331acb05c4e2d8a52aa80f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 87, "max_issues_repo_issues_event_min_datetime": "2018-07-10T08:17:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-05T01:17:01.000Z", "max_forks_repo_path": "tutorial/ch-grammar.tex", "max_forks_repo_name": "ymanerka/uclid", "max_forks_repo_head_hexsha": "355d060026ca141e81331acb05c4e2d8a52aa80f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2019-01-28T12:54:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-14T22:31:08.000Z", "avg_line_length": 33.9663865546, "max_line_length": 359, "alphanum_fraction": 0.592858321, "num_tokens": 3747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4252502096228598}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage{graphicx}\n\\author{Didrik Jonassen, Imre Kerr}\n\\title{Project 1B\\\\ IT3708 --- Subsymbolic methods in AI}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Representation and Development}\nWe chose to represent the chromosome as a binary vector of length $4B$. Every four bits are interpreted as a binary number, meaning that the genome codes for $B$ integers between 0 and 15. These integers are then normalized so they all sum to 1, and the resulting fractions are the troop deployment for each battle.\n\n\\section{Strategy Entropy}\nStrategy entropy is a measure of how ``spread out'' the troops are for a given strategy. Putting all troops in one battle gives minimum entropy, and spreading them evenly over all battles gives maximum entropy. This is interesting because it characterizes a strategy as a single number, letting you get the gist of the strategy without having to interpret the deployment numbers themselves.\n\n\\section{EA Parameters}\n\\begin{tabular}{|l|l|}\n\\hline\nParameter & value \\\\\n\\hline \\hline\nPopulation Size & 20 \\\\\nMutation Rate & $\\frac{1}{40B}$ \\\\\nCrossover Rate & 100\\% \\\\\nSelection Mechanism & Fitness Proportionate \\\\\nSelection Protocol & Generational Mixing \\\\\nLitter size & 20 \\\\\nGenerations & 400 \\\\\n\\hline\n\\end{tabular}\n\n\\section{Base Case Summary}\n\\begin{tabular}{|c|c|c|l|}\n\\hline\nB & R_{f} & L_{f} & Notes \\\\\n\\hline \\hline\n5 & 0 & 0 & Switches between various strategies putting everything on two battles \\\\\n5 & 0 & 1 & Puts everything on battle 1 \\\\\n5 & 0 & 0.5 & Same as (5,0,0), but weighted towards the first of the two \\\\\n5 & 1 & 0 & Spread out, weighted towards the earlier battles \\\\\n5 & 1 & 1 &  All on battle 1 \\\\\n5 & 1 & 0.5 & All on battle 1 \\\\\n5 & 0.5 & 0 & Switches between various 2-battle strategies \\\\\n5 & 0.5 & 1 & All on battle 1 \\\\\n5 & 0.5 & 0.5 & All on battle 1 \\\\\n20 & 0 & 0 & Converges toward fewer battles, step by step \\\\\n20 & 0 & 1 & Same as B = 5, but slower\\\\\n20 & 0 & 0.5 & Same as B = 5, but slower \\\\\n20 & 1 & 0 & Switches between different strategies involving the 10 first battles \\\\\n20 & 1 & 1 & Same as B = 5, but slower \\\\\n20 & 1 & 0.5 & Same as B = 5, but slower \\\\\n20 & 0.5 & 0 & Switches between different strategies with no clear pattern \\\\\n20 & 0.5 & 1 & Same as B = 5, but slower \\\\\n20 & 0.5 & 0.5 & Same as B = 5, but slower \\\\\n\\hline\n\\end{tabular}\nYou'll notice that the descriptions for most the B=20 runs were the same. They did however provide us with a clearer look at what was going on, so these runs were not wasted.\n\n\\section{Signature Cases}\nFor each of these cases we give:\n\\begin{itemize}\n\\item{an entropy plot showing the average entropy in the population}\n\\item{a fitness plot showing the best, worst and average (plus/minus std.dev.) fitness in the population} \n\\item{and a strategy plot, which is a visualization of the winning strategy in each generation. The horizontal axis is generations, and the vertical axis is normalized troop deployment. This plot makes it very easy to see what the dominant strategy looks like at any given point.}\n\\end{itemize}\n\\subsection{Case 1: $B=5, R_{f}=0, L_{f}=1$}\n\\centerline{\\includegraphics[width=1.2\\textwidth]{case1}}\nThis case quickly converges towards putting all troops on the first battle. This is not surprising, since having $L_{f}=1$ means that losing the first battle will make the morale zero for all the following battles. This is true for all cases with $L_{f}=1$.\n\n\\subsection{Case 2: $B=20, R_{f}=0, L_{f}=0$}\n\\centerline{\\includegraphics[width=1.2\\textwidth]{case2}}\n\\small{(There are two distinct regions that unfortunately both happened to be blue.)}\\\\\nThis case gradually converges towards a strategy involving putting everything on two battles, with the trend being one less battle every few generations. We think this can be explained as follows: In order to mutate an n-battle strategy into an (n-1)-battle strategy that beats the original, only one of the battles needs to have a lower weight, and all the other weights will rise as a result. Conversely, if an (n+1)-battle strategy is to beat an n-battle strategy, more than one of the battles needs to get an updated value. Thus it is easier to find winning strategies with lower numbers of battles, so it converges towards lower numbers, with the limit being 2.\n\n\\subsection{Case 3: $B=20, R_{f}=1, L_{f}=0$}\n\\centerline{\\includegraphics[width=1.2\\textwidth]{case3}}\nHere we see a chaotic switching between strategies involving approximately the first half of the battles. Weighting towards earlier battles makes sense due to redeployment, but other than that this one is hard to explain. We made the strategy plot greyscale for this one in order to better see which battles were included in the strategy.\n\n\\section{Brief Discussion}\nIn the cases where there exists an optimal solution, we see that co-evolution finds this solution quite quickly. In the more complex cases, for any given strategy there is a strategy that can beat it, and this will eventually be found. The limiting factor in these cases is how easy it is to get to that strategy by random mutation. This has parallels in biology, where most change we observe is gradual, with quantum leaps being quite rare.\n\n\\end{document}\n", "meta": {"hexsha": "bf6579081589fcaf39260e587009c527f56cab89", "size": 5251, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/report-1b.tex", "max_stars_repo_name": "didrikjonassen/ea", "max_stars_repo_head_hexsha": "018000aec2c50eca8260748ab7a47da07290b05e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/report-1b.tex", "max_issues_repo_name": "didrikjonassen/ea", "max_issues_repo_head_hexsha": "018000aec2c50eca8260748ab7a47da07290b05e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/report-1b.tex", "max_forks_repo_name": "didrikjonassen/ea", "max_forks_repo_head_hexsha": "018000aec2c50eca8260748ab7a47da07290b05e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-12T14:36:10.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-12T14:36:10.000Z", "avg_line_length": 63.265060241, "max_line_length": 666, "alphanum_fraction": 0.7459531518, "num_tokens": 1392, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283033, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.4252502082780929}}
{"text": "\\chapter{Code Structure}\\label{structure}\n\nRoughly the code structure is displayed in Fig.\\ref{graph}. For more accurate and detailed description, run Doxygen utility and refer the generated documentation.\n\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.8\\textwidth]{graph.pdf}\n\t\t\\caption{\\label{graph} Class dependency (crudely)}\n\t\\end{center}\n\\end{figure}\n\nEach of the the constituent elements are briefly described next. \n\n\\section{Code structure}\n\\subsection{Tensor}\nMEANDG has a central datastructure called as `Tensor', which forms all the important arrays, matrices, multidimensional storage lists etc.\nRefer `include/Tensor' for details. Tensor class is made of 4 sub-classes. \n\\begin{verbatim}\nTensorO1<dType>, TensorO2<dType>, TensorO3<dType>, Matrix<dType>\n\\end{verbatim}\nFrom these, $O(1), O(2), O(3)$ tensors can be created of arbitrary dimensions. The tensor objects interact with one another and \nhave several in-build methods such as $L_1, L_2, L_\\infty$ norms etc. All the maths functions accept objects of Tensor library. \n\nFollowing example code shows usage of tensor class:\n\\begin{verbatim}\nTensorO1<double> A(5);\t\t// creates a O(1) tensor of size 5 with \n\t\t\t\t// data-members of the type double\nTensorO1<double> C(5);\n\nfor (int i=0; i<5; i++){\n\t// generate a random number between 0 and 100\n\tdouble valueA = getRandom(0.0,100.0);\t\n\t// generate another random number between 0 and 100\n\tdouble valueC = getRandom(0.0,100.0);\t\n\n\t// set value at ith index\n\tA.setValue(i, valueA);\t\t\t\n\tC.setValue(i, valueC);\n};\n// now A and C have random values \n\ndouble dotAnswer = Math::dot(A,C);\t\t// perform math product between two arrays\ncout << dotAnswer << endl;\t\t\t// print the answer\n\n\n\\end{verbatim}\n\nFor further details and the available functions, refer the code documentation.\n\n\\subsection{Point}\nPoint is a physical point in $(x,y,z)$ coordiante system. It has a unique id, and description of its location. \n\n\\subsection{Cell}\nIf the domain is indicated by $\\Omega$, then the descritization of the domain ($\\Omega_h$) is described as,\n\\begin{equation}\n\t\\Omega_h = \\bigcup\\limits_{l = 1}^ n S_i\n\\end{equation}\nwhere $S_i$ are the finite volume cells. These are non-overlapping pieces of the domain. \nEach cell has the following important attributes (among others):\n\\begin{itemize}\n\t\\item Vertices (of the type `Point')\n\t\\item Faces (i.e. boundary of the cell)\n\t\\item Degrees of Freedom (i.e. locations where unkowns are evaluated)\n\t\\item Data (such as the conserved variables)\n\t\\item Volume \n\t\\item Mathematical constructs (Mass matrix, Stiffness matrix etc.)\n\t\\item Mapping onto the standart cell (Jacobian etc.)\n\\end{itemize}\n\nThus, each of these parameters (among others) can be accessed using the accessor (get, set) functions of the class `Cell'. \nFor further details, refer Cell.h and Cell.cpp.\n\n\\subsection{Face}\nA face is the boundary of a Cell. The face has following important attributes:\n\\begin{itemize}\n\t\\item Geometrical information (area, normal, vertices etc.)\n\t\\item Neighbour and Owner cells\n\t\\item Data (numerical flux and variables)\n\t\\item Mapping (Jacobian etc.)\n\\end{itemize}\n\n\\subsection{GeometryIO}\nThis module reads the input file in the OpenFOAM format and fills the data arrays. Refer:\n\\begin{verbatim}\nGeometryIO::fillDataArrays(args)\n\\end{verbatim}\n\n\\subsection{Functional Space}\nThis module is responsible for everything related to $L^2, H^1$ functional spaces. It contains nodal, modal basis functions and derivatives.\nIt also computes various matrices used in DG formulation. \n\n\\subsection{Math functions}\nThese are various mathematical functions.\n\n\\subsection{Gasdynamics, Riemann solvers etc.}\nDepending on the system of equations which one wants to solve, include the physics-specific functions and files. For example, for\nEuler's equations of Gasdynamics, we have Gasdyanmics.cpp module and corresponding Riemann solvers. \nApart from these, there are test functions, display functions etc. Refer the code files in `include/' and `src/' folders.\n\n\\subsection{DG}\nThis is the core (central) module of the code. It performs following operations:\n\\begin{itemize}\n\t\\item Memory management \n\t\\item Cells, faces creation \n\t\\item Calling appropriate functions for computation of cell matrices\n\t\\item Time integration\n\t\\item PDE solving\n\\end{itemize}\n\nCurrently it is configured to solve the hyperbolic system of PDEs of the type:\n\\begin{equation}\n\t\\frac{\\partial {Q}}{\\partial{t}} + \\nabla .  {\\bf F}(Q) = 0\n\\end{equation}\n\n", "meta": {"hexsha": "791634beabdf15388df7a2c935fb620af6c2c2c2", "size": 4476, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lab_Manual/structure.tex", "max_stars_repo_name": "vachan-potluri/MEANDG", "max_stars_repo_head_hexsha": "a4a22653b5d71b186e179519b0d26a21d3faf1b5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lab_Manual/structure.tex", "max_issues_repo_name": "vachan-potluri/MEANDG", "max_issues_repo_head_hexsha": "a4a22653b5d71b186e179519b0d26a21d3faf1b5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lab_Manual/structure.tex", "max_forks_repo_name": "vachan-potluri/MEANDG", "max_forks_repo_head_hexsha": "a4a22653b5d71b186e179519b0d26a21d3faf1b5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-06-12T10:01:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-21T06:27:42.000Z", "avg_line_length": 38.5862068966, "max_line_length": 162, "alphanum_fraction": 0.7587131367, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6261241772283035, "lm_q1q2_score": 0.42525019608036085}}
{"text": "\\section{Overview}\nFrom earlier calibration versions of data from the autocorrelators\nof Odin-SMR we know that calibrated spectra from both high and \nlow altitudes contain spectral features not caused by the atmospheric\nspecies.\nThis short report contains a likely explanation\nof how these spectral features are induced\nand how they affect the spectra.\n\n\n\\clearpage\n\\newpage\n\n\\section{Spectral features in spectra}\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{odinspectrumpattern.png}\\\\\n\\caption{Wave induced pattern in calibrated spectra. The red line represents \na perturbed brightness temperature spectrum of the\nhot load (a cosinus wave with eight cycles is added)\nThe blue line represents a perturbed brightness temperature\nspectrum of the cold sky (a cosinus wave with four cycles is added).\nThe thin red lines represent perfectly calibrated spectra.\nThe green lines show what features the cosinus waves of the\nreferences induce on calibrated spectra if they are not taken into account.\n}\n\\label{fig:study2ac2a}\n\\end{figure}\n\nFrom earlier calibration versions of data from the autocorrelators\nof Odin-SMR we know that calibrated spectra from both high and \nlow altitudes contain spectral features not caused by the atmospheric\nspecies. \nThe spectral features, which are different at low and and high altitudes, \nare instead caused by the instrument itself and not taken into account\nin the calibration process.\n\nThe calibration process (level1a to level1b) is based on that we have \nmeasurements of the clod sky (\\(C_{s}(f)\\) at 2.7 K), hot load (\\(C_{L}(f)\\)\nat around 290 K), and the target atmosphere (\\(C_{A}(f)\\) \nat unkown temperature \\(T_{A}\\)).\nThe calibration process can be understand as a linear interpolation\nof \\(C_{A}(f)\\)  using \\(C_{s}(f)\\) and \\(C_{L}(f)\\) and their temperatures\nas references.\n \nThe calibration process assumes that both the cold sky and hot load signal\nare clean. Figure~\\ref{fig:study2ac2a} shows an example of what would happen with\ncalibrated spectra if these signals are not clean\n(but the target signal is clean).\nIn the example the blue line represents a perturbed brightness temperature\nspectrum of the cold sky (a cosinus wave with four cycles is added).\nThe red line represents a perturbed brightness temperature spectrum of the\nhot load (a cosinus wave with eight cycles is added).\nThe thin red lines can be interpreted as perfectly calibrated spectra.\n\nThe green lines show what features the cosinus waves of the\nreferences induce on calibrated spectra if they are not taken into account:\n\nAt low brightness temperatures this pattern is caused by the\nthe wave on the cold sky signal (and 180 degree phase shifted\nw.r.t. wave on the cold sky signal).\n\nAt high brightness temperatures this pattern is caused by the\nthe wave on the hot load signal (and 180 degree phase shifted\nw.r.t. wave on the hot load signal).\n\nAt intermediate brightness temperatures the pattern is a linear\ncombination of the mentioned pattern,\ni.e. (using the equations in the figure) \n\\begin{equation}\n\\Delta T=c \\cdot cos\\left(\\frac{f2\\pi}{d}+\\pi\\right) \\cdot (1-w(f)) \n+a \\cdot cos \\left( \\frac{f2\\pi}{b}+\\pi \\right) \\cdot w(f)\n\\end{equation}\nwhere\n\\begin{equation}\nw(f)=\\frac{C_{A}(f)-C_{s}(f)}{C_{L}(f)-C_{S}(f)}\\approx\\frac{T_{A}(f)}{T_{L}(f)}\n\\end{equation}\n\n\\section{Odin data}\n\\subsection{AC2}\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spechigh.png}\\\\\n\\caption{High tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec1}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2speclow.png}\\\\\n\\caption{Low tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec2}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spec1015.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec3}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spec1520.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec4}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spec3035.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec5}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spec4045.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec6}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac2spec5560.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC2 (strat 1).}\n\\label{fig:study2spec7}\n\\end{figure}\n\\clearpage\n\\newpage\n\\subsection{AC1}\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac1spechigh.png}\\\\\n\\caption{High tangent altitude median spectrum from AC1 (strat 2).}\n\\label{fig:study2spec8}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac1speclow.png}\\\\\n\\caption{Low tangent altitude median spectrum from AC1 (strat 2).}\n\\label{fig:study2spec9}\n\\end{figure}\n\n\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac1spec4045.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC1 (strat 2).}\n\\label{fig:spec1}\n\\end{figure}\n\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.7]{ac1spec5560.png}\\\\\n\\caption{Intermediate tangent altitude median spectrum from AC1 (strat 2).}\n\\label{fig:spec1}\n\\end{figure}\n\n\n\n\n\n", "meta": {"hexsha": "62ff5eaf93e1cc389bef3c3418deaf8375657ee3", "size": 5435, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "odincal/docs/part2.tex", "max_stars_repo_name": "Odin-SMR/odincal", "max_stars_repo_head_hexsha": "4c40f0d762b5ee8cbfd7f305cf6aa7ed9ec50206", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "odincal/docs/part2.tex", "max_issues_repo_name": "Odin-SMR/odincal", "max_issues_repo_head_hexsha": "4c40f0d762b5ee8cbfd7f305cf6aa7ed9ec50206", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "odincal/docs/part2.tex", "max_forks_repo_name": "Odin-SMR/odincal", "max_forks_repo_head_hexsha": "4c40f0d762b5ee8cbfd7f305cf6aa7ed9ec50206", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7409638554, "max_line_length": 81, "alphanum_fraction": 0.7687212511, "num_tokens": 1540, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.42525019473559383}}
{"text": "\\documentclass{beamer}\n\n\\input{../../shared_slides.tex}\n\n\\title{Projected Gradient Descent}\n\n\\begin{document}\n\\maketitle\n\\frame{\\tableofcontents}\n\n\\section{Introduction}%\n\n\n\n\\begin{frame}\n  \\frametitle{Constrained Optimization}\n\n  \\begin{minipage}{0.5\\textwidth}\n    \\begin{block}{Constrained optimization problem}\n      \\begin{equation}\n        \\begin{aligned}\n          \\text{minimize } & f(x)\\\\\n          \\text{subject to } & x\\in C\n        \\end{aligned}\n      \\end{equation}\n      \\textcolor{blue}{How to solve them}\n      \\begin{itemize}\n        \\item Project onto $C$\n        \\item transform to \\textit{unconstrained problem}\n      \\end{itemize}\n    \\end{block}\n  \\end{minipage}\n  \\begin{minipage}{0.45\\textwidth}\n    \\begin{figure}[ht]\n      \\centering\n      \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{constrained_3d}\n      % \\caption{\\label{fig:label} }\n    \\end{figure}\n  \\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Constrained Optimization}\n\n  \\begin{minipage}{0.5\\textwidth}\n    \\begin{block}{Constrained optimization problem}\n      \\begin{equation}\n        \\begin{aligned}\n          \\text{minimize } & f(x)\\\\\n          \\text{subject to } & x\\in C\n        \\end{aligned}\n      \\end{equation}\n      \\end{block}\n      \\textcolor{blue}{We will focus on:}\n      \\begin{itemize}\n        \\item \\textbf{Projected Gradient Descent}\n      \\end{itemize}\n  \\end{minipage}\n  \\begin{minipage}{0.45\\textwidth}\n    \\begin{figure}[ht]\n      \\centering\n      \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{constrained_3d}\n      % \\caption{\\label{fig:label} }\n    \\end{figure}\n  \\end{minipage}\n\\end{frame}\n\n\\section{Projection}%\n\\label{sec:}\n\n\\begin{frame}\n  \\frametitle{Projected Gradient Descent}\n\n  \\textcolor{blue}{Idea:} After every step project back onto the set: $\\Pi_C(x) :=\\argmin_{y\\in C} \\Vert y-x \\Vert$.\n\n    \\begin{figure}[ht]\n      \\centering\n      \\includegraphics[width=\\textwidth,height=0.7\\textheight,keepaspectratio]{test}\n      % \\caption{\\label{fig:label} }\n    \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Projected subgradient method}\n  \\begin{equation}\n    \\text{(constrained setting)} \\quad \\min_{x\\in C}\\, f(x)\n  \\end{equation}\n  \\begin{algorithm}[H]\n    \\caption{Projected subgradient method}\\label{label:}\n    \\begin{algorithmic}[1]\n      \\For{$k=0, 1, \\dots$}\n      \\State{Pick $g_k \\in \\partial f(x_k)$}\n      \\State{$y_{k+1} =  x_k- \\alpha g_k $}\n      \\State{$x_{k+1} = \\Pi_C(y_{k+1})$}\n      \\EndFor\n    \\end{algorithmic}\n  \\end{algorithm}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Properties of the Projection}\n  \\begin{block}{Fact}\n    Let $C\\subseteq \\R^d$ be closed and convex, $x\\in C$ and $y \\in \\R^d$.Then\n    \\begin{itemize}\n      \\item $\\langle x- \\Pi_C(y), y - \\Pi_C(y)  \\rangle \\le 0$\n      \\item $\\Vert x - \\Pi_C(y) \\Vert^2 + \\Vert y - \\Pi_c(y) \\Vert^2 \\le \\Vert y-x \\Vert^2$\n    \\end{itemize}\n  \\end{block}\n  \\begin{figure}[ht]\n    \\centering\n    \\includegraphics[height=0.5\\textheight,keepaspectratio]{projection_property}\n    % \\caption{\\label{fig:label} }\n  \\end{figure}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Properties of the Projection}\n  \\begin{block}{Fact}\n    Let $C\\subseteq \\R^d$ be closed and convex, $x\\in C$ and $y \\in \\R^d$.Then\n    \\begin{itemize}\n      \\item $\\langle x- \\Pi_C(y), y - \\Pi_C(y)  \\rangle \\le 0$\n      \\item $\\Vert x - \\Pi_C(y) \\Vert^2 + \\Vert y - \\Pi_c(y) \\Vert^2 \\le \\Vert y-x \\Vert^2$\n    \\end{itemize}\n  \\end{block}\n  \\begin{proof}\n    Since $\\Pi_C(x)$ is the minimizer of a differentiable convex function $d_x(y) =\\frac12 \\Vert y-x \\Vert^2$ over $C$, by the \\textbf{first-order optimality condition}\n    \\begin{align}\n      0 &\\le \\langle \\nabla d_x(\\Pi_C(x)), y - \\Pi_C(x) \\rangle \\\\\n        &= \\langle \\Pi_C(x) - x, y - \\Pi_C(x) \\rangle\n    \\end{align}\n  \\end{proof}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Results for projected GD}\n  For \\textbf{closed}, \\textbf{convex} set $C\\subset \\R^d$ \\textcolor{blue}{same} number of gradient steps.\n  \\begin{itemize}\n    \\item Lipschitz convex function over $C$: $\\mathcal{O}(\\epsilon^{-2})$ steps\n    \\item Smooth convex function over $C$: $\\mathcal{O}(\\epsilon^{-1})$ steps\n    \\item Smooth and strongly convex over $C$: $\\mathcal{O}(\\log(\\epsilon^{-1}))$\n  \\end{itemize}\n\n  But:\n  \\begin{itemize}\n    \\item Each step requires a projection onto $C$\n    \\item May or may not be easy to compute\n  \\end{itemize}\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{The projection step: $\\Pi_C(x) := \\argmin_{y\\in C} \\Vert y-x \\Vert$}\n  Computing $\\Pi_C(x)$ is an optimization problem itself.\n\n  Efficient in relevant cases:\n  \\begin{itemize}\n    \\item Box constraints: $C= [a_1, b_1] \\times \\dots \\times [a_d, b_d]$\n    \\item Affine subspace (requires solution of system of linear equations)\n          \\begin{figure}[ht]\n            \\centering\n            \\includegraphics[scale=.12]{projection_onto_affine_space}\n          \\end{figure}\n    \\item Projection onto ball with center $c$\n          \\begin{figure}[ht]\n            \\centering\n            \\includegraphics[scale=.2]{projection_onto_ball}\n          \\end{figure}\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Convergence analysis}\n  \\begin{proof}\n    We can deduce the exact same inequality as before\n    \\begin{equation}\n      \\begin{aligned}\n        \\Vert x_{k+1} - x^* \\Vert^2 &= \\Vert \\Pi_C(x_k - \\alpha g_k) - \\Pi_C(x^*) \\Vert^2 \\\\\n        &\\le \\Vert x_k - \\alpha g_k - x^* \\Vert^2 \\\\\n        &= \\Vert x_k-x^* \\Vert^2 + 2 \\alpha \\langle g_k, x^*-x_k \\rangle + \\alpha^2 \\Vert g_k \\Vert^2\\\\\n        &\\le \\Vert x_k-x^* \\Vert^2 + 2 \\alpha (f^* - f(x_k))+ \\alpha^2 \\Vert g_k \\Vert^2.\n      \\end{aligned}\n    \\end{equation}\n    Continue the proof as in the unconstrained setting.\n  \\end{proof}\n\\end{frame}\n\n\n\\section{Proximal Gradient}%\n\\label{sec:}\n\n\n\\begin{frame}\n  \\frametitle{Composite minimization problem}\n\n  Consider objective function composed as\n  \\begin{equation}\n    f(x) = g(x) + h(x)\n  \\end{equation}\n  where\n  \\begin{itemize}\n    \\item $g$ is \\textcolor{blue}{nice}\n    \\item $h$ is \\textcolor{blue}{simple}\n  \\end{itemize}\n  typically we mean nice means smooth. Relevant if $h$ is not differentiable.\n  Most notably: Lasso\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Idea}\n  Classical gradient step for $g$:\n  \\begin{equation}\n    x_{k+1} = \\argmin_{x} g(x_k) + \\langle \\nabla g(x_k), x-x_k \\rangle + \\frac{1}{2 \\alpha} \\Vert x-x_k \\Vert^2\n  \\end{equation}\n  Now, for $f= g+h$ we keep this for $g$ and add $h$ \\textcolor{blue}{unmodified}:\n  \\begin{align}\n    x_{k+1} &= \\argmin_{x} g(x_k) + \\langle \\nabla g(x_k), x-x_k \\rangle + \\frac{1}{2 \\alpha} \\Vert x-x_k \\Vert^2 \\textcolor{red}{+ h(x)} \\\\\n    &= \\argmin_x \\frac{1}{2 \\alpha} \\Vert x - (x_k - \\alpha \\nabla g(x_k)) \\Vert^2 + h(x)\n  \\end{align}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{The proximal gradient algorithm}\n\n  An iteration is defined as\n  \\begin{block}{}\n  \\begin{equation}\n    x_{k+1} = \\prox{\\alpha h}{x_k - \\alpha \\nabla g(x_k)}\n  \\end{equation}\n  \\end{block}\n  where the \\textcolor{blue}{proximal mapping} for a function $h$ and parameter $\\alpha$ is defined as\n  \\begin{equation}\n    \\prox{\\alpha h}{x} = \\argmin_{y \\in \\R^d} \\left\\{ h(y) + \\frac{1}{2 \\alpha} \\Vert y-x \\Vert^2\\right\\}.\n  \\end{equation}\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{A generalization of (projected) GD}\n\n  \\begin{itemize}\n    \\item $h \\equiv 0$ recovers \\textcolor{blue}{gradient descent}.\n    \\item $h = \\chi_C$ recovers \\textcolor{blue}{projected gradient descent}\n          We call $\\chi_C$ the \\textbf{indicator function} of $C$\n          \\begin{align}\n            \\chi_C&: \\R^d \\to \\R \\cup +\\infty \\\\\n              & x \\mapsto \\begin{cases}\n                0 & \\text{if $x \\in C$} \\\\\n                +\\infty & \\text{otherwise.}\n              \\end{cases}\n          \\end{align}\n          Proximal mapping becomes\n          \\begin{equation}\n            \\prox{\\alpha h}{x} = \\argmin_{y \\in \\R^d} \\left\\{ \\chi_C(y) + \\frac{1}{2 \\alpha} \\Vert y-x \\Vert^2\\right\\} = \\argmin_{y \\in C} \\{ \\Vert y-x \\Vert^2\\}.\n          \\end{equation}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Convergence}\n\n  Same complexity as GD or projected GD,\n\n  \\textcolor{blue}{if we can compute the proximal mapping!}\n\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "8f08d0c64baf244de8e19e67a2cbd0051b2af57c", "size": 8259, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/04_Projected_GD/projected_GD.tex", "max_stars_repo_name": "kiwomuc/optimization-for-DS-lecture", "max_stars_repo_head_hexsha": "43ea50ef85f73b5bbc7659e8c457218ae136bb94", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-10-03T14:40:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-20T15:34:36.000Z", "max_issues_repo_path": "slides/04_Projected_GD/projected_GD.tex", "max_issues_repo_name": "kiwomuc/optimization-for-DS-lecture", "max_issues_repo_head_hexsha": "43ea50ef85f73b5bbc7659e8c457218ae136bb94", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2021-10-21T13:02:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-06T19:50:32.000Z", "max_forks_repo_path": "slides/04_Projected_GD/projected_GD.tex", "max_forks_repo_name": "kiwomuc/optimization-for-DS-lecture", "max_forks_repo_head_hexsha": "43ea50ef85f73b5bbc7659e8c457218ae136bb94", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2021-10-05T21:47:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-04T15:38:30.000Z", "avg_line_length": 29.183745583, "max_line_length": 168, "alphanum_fraction": 0.6210194939, "num_tokens": 2824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.42518928671889505}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{makeidx}\n\\usepackage{graphicx}\n\n\\newtheorem{defi}{Defintion}\n\n\\author{moi}\n\\begin{document}\n\\section{Introduction}\nWe shall concentrate our discussion on fixed points and its implication with regard to algebra. We assume the reader confident with basic ring and module theory. In particular, unless stated otherwise we assume each ring $R$ to be commutative and unital (i.e. with one $1_R \\in R$.\n\\subsection{Polynomial example}\nLet $R$ be a ring. Firstly, let us discuss the specialisation of fixed points in the polynomial case.\n\\begin{defi}[Polynomial case]\nFix $f \\in R[X]\\backslash R$. An element $r_f \\in R$ is a fixed point wrt. to $f$, if $f \\in \\ker \\phi_{r_f}$ or equivalently if $r_f \\in \\ker \\rho \\circ \\psi (f)$, where\n$$\\begin{array}{rrclcrcl}\nev_r : & R[X] & \\longrightarrow & R,&& \\sum_i f_i X^i & \\longmapsto & \\sum_i f_i r^i\\\\\n\\rho : &R& \\longrightarrow &\\mathrm{CRng}(R[X],R),&& r &\\longmapsto& ev_r\\\\% = \\left[\\sum_i f_i X^i \\longmapsto \\sum_i f_i r^i\\right],\\\\\n\\psi :& R[X] &\\longrightarrow& R[X],&& f &\\longmapsto &f - x,\\ \\mathrm{and}\\\\\n\\phi_r := ev_r \\circ \\psi :& R[X]& \\longrightarrow& R&,& f &\\longmapsto& ev_r (f - x).\\\\\n\\end{array}$$\n\\end{defi}\nFirstly, we note that $\\psi$ is an $R$ module automorphism and $ev_r$ is a ring homomorphism (hence, the notation of the class of ring homs $\\mathrm{CRng}(R[X],R)$). The equivalence is obvious. However, the map $\\phi_r$ is not a module \n\n\\end{document}", "meta": {"hexsha": "25307d7c282ff7d4d55e05fda313b420b0dbb323", "size": 1568, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg_fixed_pts/alg_fixed_pts.tex", "max_stars_repo_name": "gmuel/texlib", "max_stars_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "alg_fixed_pts/alg_fixed_pts.tex", "max_issues_repo_name": "gmuel/texlib", "max_issues_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg_fixed_pts/alg_fixed_pts.tex", "max_forks_repo_name": "gmuel/texlib", "max_forks_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.0, "max_line_length": 281, "alphanum_fraction": 0.705994898, "num_tokens": 525, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4250267293941805}}
{"text": "%! Author = tstreule\n\n\\section{Potentiometric Biosensors}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Redox Reaction}\n%\n\\textbf{oxidation}: $e^-$ donor (\\textit{anode}) \\qquad\n\\textbf{reduction}: $e^-$ acceptor (\\textit{cathode})\n\n\\formtex{Chemical reaction}{\\ce{A*ox + B*X + z*e^- <=>[$k_{red}$][$k_{ox}$] C*red + D*Y}}\n\\vspace{-.5mm}\n\\formbox{reaction quotient}{\n    Q = \\mathrm{\\frac{a\\ped{ox}^A \\;\\cdot\\; a\\ped{X}^B}{a\\ped{red}^C \\;\\cdot\\; a\\ped{Y}^D}}\n}\n%\\textcolor{gray}{$= \\Big(\\prod\\limits_j a_j^{v_j}\\Big)$}\n\\begin{tabular}{@{$\\bullet\\;$}l @{\\quad$\\bullet\\;$}l}\n    $\\mathrm{a}\\ped{ion} = r\\ped{ion} [\\mathrm{ion}]/\\unitfrac[1]{mol}{l}$ &\n    $\\mathrm{a}\\ped{solids} = 1$\\\\\n    $\\mathrm{a}\\ped{gas} = p\\ped{gas}/\\unit[1.013]{bar}$ &\n    $[\\ce{H2O}] = 1$\n\\end{tabular}\n\n\\formula{Standard conditions}{\n    T = \\SI{1}{\\degreeCelsius}, \\quad\n    p = \\SI{101.3}{\\kilo\\pascal} = \\SI{1.013}{\\bar}\n}\n\\formula{\\centering ``STP''}{\n    [\\mathrm{ion}] \\equiv c\\ped{ion} = \\unitfrac[1]{mol}{l}, \\quad\n    r = 1 \\text{ ``activity coeff.''}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Electrochemistry}\n%\n\\formtex{Dynamic equi.}{no net charge over time ($k_1 = k_{-1}$)}\n\\formula{Chemical potential}{\\mu_j = \\big( \\pderiv{G}{n_j} \\big)_{p,T,n'}}\n\\formula{Equilibrium}{\\mu_A = \\mu_B}\n\\quad general: $\\sum\\limits\\ped{prod}v_j\\mu_j = \\sum\\limits\\ped{react}v_j\\mu_j$\n\\vspace{-.5mm}\n\\formula{Chemical potential}{\\mu\\ped{redox}\\equiv E\\ped{\\emph{F},redox}\\equiv E^*}\n%\\quad where \\quad $D\\ped{red}(\\lambda,E^*) = D\\ped{ox}(\\lambda,E^*)$\n\\formbox{Equilibrium}{\\bar\\mu_A = \\bar\\mu_B}\n\\quad $\\bar\\mu_j = \\mu_j^0 + z_jF\\Delta\\phi$\n\n\\formula{\\textbf{Contact potential}}{\\Delta\\phi\n    = V\\ped{in}-V\\ped{out} = \\frac{k\\ped{B}T}{Q} \\ln\\left(\\frac{[C]\\ped{out}}{[C]\\ped{in}}\\right)\n}\n\\formula{~}{\\phantom{\\Delta\\phi}\n    = -\\frac{\\Delta_rG}{zF}\n    = \\frac{1}{zF} \\Big( \\sum\\limits\\ped{ox} v_j\\mu_j - \\sum\\limits\\ped{red} v_j\\mu_j + z\\mu_e \\Big)\n}\n\\formbox{Nernst eq., $\\Delta\\phi$}{E {=} E^0 {-} \\frac{\\unit[59]{mV}}{z} \\log_{10}Q}\n\\textcolor{gray}{\\footnotesize $\\frac{RT}{zF}\\ln Q = \\frac{2.303 RT}{zF}\\log_{10}Q$}\n\\formtex{~}{$E\\ped{cell}=E_1-E_2$ \\quad or \\quad let $E_1 \\overset{!}{=} E_2 \\to \\mathrm{pH}=\\ldots$}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Ion-selective Electrodes \\textnormal{(ISE)}}\n%\nSensor is seperated to solution through a \\ce{H+} permeable glass.\n\\formbox{pH electrode}{\\mathrm{pH} = -\\log_{10} a\\ped{\\ce{H+}} = \\frac{K'-\\Delta\\phi}{\\unit[0.059]{V}}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Bioenzymatic Electrodes}\n%\n\\formtex{Find out how much}{\\fbox{\\ce{substrate + X + ... ->[enzyme] product + Y + ...}}}\n\\formtex{of an enzyme was}{Detect \\textbf{``a lot''} \\ce{X}}\n\\formtex{initially present}{\\hfill$\\leftrightarrow$ \\textbf{``very few''} \\ce{substrate} was initially present}\n", "meta": {"hexsha": "c6709e37c3aae5aace574377c680076f588cc8cc", "size": 2946, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/BE18/sections/09_potentiometric_biosensors.tex", "max_stars_repo_name": "tstreule/eth-cheat-sheets", "max_stars_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-26T23:11:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T23:11:57.000Z", "max_issues_repo_path": "src/BE18/sections/09_potentiometric_biosensors.tex", "max_issues_repo_name": "tstreule/eth-cheat-sheets", "max_issues_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/BE18/sections/09_potentiometric_biosensors.tex", "max_forks_repo_name": "tstreule/eth-cheat-sheets", "max_forks_repo_head_hexsha": "c61f9fd3b13edf405f790581b4d5eacb50b4f1c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6363636364, "max_line_length": 111, "alphanum_fraction": 0.567209776, "num_tokens": 1129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4250267223449432}}
{"text": "\n\n\\section*{Notes Week 8}\n\n\\begin{itemize}\n\n    \\item A \\definition{loop} is an edge that connects a node to itself. Mostly relevant to directed graphs \\\\\n    \\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] \n        \\node[main] (1) {$x_1$};  \n        \\draw (1) to [out=180,in=270,looseness=5] (1);  \n    \\end{tikzpicture}\n\n    \\item A \\definition{simple path} is a path where all vertices are distinct except possibly the first and last. \\\\\n    \\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] \n        \\node[main] (1) {$x_1$};  \n        \\node[main] (2) [right of = 1] {$x_2$};  \n        \\node[main] (3) [right of = 2] {$x_3$};  \n        \\node[main] (4) [right of = 3] {$x_4$};  \n        \\draw (1) -- (2);  \n        \\draw (3) -- (4);  \n        \\draw (2) -- (3);  \n    \\end{tikzpicture}\n\n    \\item A \\definition{cycle} is a path that starts and ends on the same vertex.\n\n    \\item \\definition{Acyclic} graphs contain no cycles.\n\n    \\item \\definition{DAG}: Directed Acyclic Graph\n\n    \\item \\definition{Strongly} connected graphs are ones where any vertex has a path to any other vertex; \\definition{Weakly} connected graphs have vertices without paths to other vertices.\n\n    \\item A \\definition{Bipartite Graph} is one we can separate vertices into two groups where edges only travel between groups. \\\\\n    \\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] \n        \\node[main] (1) {$x_1$};  \n        \\node[main] (2) [right of = 1] {$x_2$};  \n        \\node[main] (3) [right of = 2] {$x_3$};  \n        \\node[main] (4) [right of = 3] {$x_4$};\n        \\node[main] (5) [below right of = 1] {$x_5$};\n        \\node[main] (6) [below right of = 2] {$x_6$};\n        \\node[main] (7) [below right of = 3] {$x_7$};  \n        \\draw (1) -- (5);\n        \\draw (2) -- (5);\n        \\draw (2) -- (6);\n        \\draw (3) -- (6);\n        \\draw (3) -- (7);\n        \\draw (4) -- (7);  \n    \\end{tikzpicture} \n\n    \\item Formally, a \\definition{Bipartite Graph} is $BG = (A \\cup B, E)$ such that every edge connects an element of A with an element B.\n    \n    \\item A complete Bipartite graph is one where all nodes in group B are connected to all nodes in group B.\n\n    \\item A \\definition{Tree} is any connected, undirected, acyclic graph.\n\n\\end{itemize}\n\n\\pagebreak\n\n\\section*{Depth-First $vs$ Breadth-First Searches}\n\n\\begin{tabularx}{\\textwidth}{X X}\n\n    \\definition{Depth-First Search}\n\n    \\begin{enumerate}\n\n        \\item Push Start Vertex\n        \\item Mark start vertex as visited\n        \\item Loop until stack empty\n        \\begin{enumerate}\n            \\item Pop $U$\n            \\item Mark $U$ as visited\n            \\item For each of $U$ unvisited neighbors, push them\n        \\end{enumerate}\n\n    \\end{enumerate}\n\n    &\n\n    \\definition{Breadth-First Search}\n\n    \\begin{enumerate}\n\n        \\item Enqueue Start Vertex\n        \\item Mark start vertex as visited\n        \\item Loop until queue empty\n        \\begin{enumerate}\n            \\item Dequeue $U$\n            \\item Mark $U$ as visited\n            \\item For each of $U$ unvisited neighbors, Enqueue them\n        \\end{enumerate}\n\n    \\end{enumerate}\n\n\\end{tabularx}\n\n\\begin{itemize}\n\n    \\item Both BFS and DFS are $O(V + E)$\n    \\begin{itemize}\n        \\item Vertices: $V = n$\n        \\item Edges: $E = n(n-1)/2$ at most in a complete, undirected graph\n        \\item Therefore: $O(n + n^2) = O(n^2)$ as an upper bound, but is dependet on\n    \\end{itemize}\n\n    \\item Under what circumstances would BFS or DFS run faster?\n\n    \\item Well, neither? Closer on graph favors BFS.\n\n\\end{itemize}\n\n\\section*{Topological Sort}\n\n\\begin{itemize}\n\n    \\item An ordering of vertices in a directed, acyclic graph such that, if there is a path, from vertex $A$ to vertex $B$, then vertex $B$ appears after vertex $A$ in the order. \\\\\n    \n\\end{itemize}\n\n\\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] \n        \\node[main] (1) {$x_1$};\n        \\node[main] (2) [right of = 1] {$x_2$};\n        \\node[main] (3) [right of = 2] {$x_3$};\n        \\node[main] (4) [right of = 3] {$x_4$};\n        \\draw[->] (1) -- (2);\n        \\draw[->] (3) -- (4);\n        \\draw[->] (2) -- (3);\n\\end{tikzpicture}\n\n\\begin{itemize}\n\n    \\item Topological sorts are not guaranteed to be unique. There could be many correct orders.\n\n    \\item Examples: Family Tree, Course Prerequisites\n\n    \\item Assumptions:\n    \\begin{enumerate}\n        \\item Indegree for each vertex is stored\n        \\item Edges stored in an adjacency list\n    \\end{enumerate}\n\n\\end{itemize}\n\n\\pagebreak\n\n\\begin{algorithm}\n    \\caption{Topological Sort 1 $O(n^2)$}\n    \\begin{algorithmic}\n        \\While{Graph is not empty}\n            \\State Find any vertex with no incoming edges\n            \\State Display Vertex\n            \\State Remove it, and its edges, from the graph\n        \\EndWhile\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\begin{algorithm}\n    \\caption{Topological Sort 2}\n    \\begin{algorithmic}\n        \\State Maintain a queue of vertices with indegree $0$\n        \\While Queue is not empty\n            \\State Dequeue a vertex\n            \\State Display the Vertex\n            \\State Remove it and its edges from the graph\n            \\State Update remaining Vertices, enqueueing any whose indgree is $0$\n        \\EndWhile\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\begin{itemize}\n    \\item Each vertex enqueued and dequeued once $\\rightarrow O(n^2)$\n    \\item Each edge gets removed once $\\rightarrow n^2$ potential\n    \\item Therefore, Topological Sort 2 is $O(V+E)$\n    \\item TS2 depends on number of edges, whereas TS1 depends on nodes\n    \\item TS2 approaches TS1 only when the graph is complete, or close to it\n\\end{itemize}\n\n\\section*{The Selection Problem}\n\nFind the $k^{th}$ largest number in a set of $n$ numbers.\n\n\\begin{itemize}\n\n    \\item \\definition{$i^{th}$ order statistic}: the $i^{th}$ smallest term in a set of $n$ elements\n    \\item Recall week 1 notes; best algorithm was $O(nlog(n))$\n    \\item It's possible to make this $O(n)$\n    \\begin{itemize}\n        \\item Pick a good pivot similar to QuickSort\n        \\item Then like Binary Search, use the half that's relevant\n        \\item The dividing runs in $(log(n))$ but the pivot search runs in $O(n)$\n    \\end{itemize}\n\n\\end{itemize}\n\n\n\\end{document}", "meta": {"hexsha": "9935bd4ac5c8a7c3390790b62a106fa598bb2164", "size": 6332, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Week 8/notes.tex", "max_stars_repo_name": "Bkrenz/calu-csc360", "max_stars_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/Week 8/notes.tex", "max_issues_repo_name": "Bkrenz/calu-csc360", "max_issues_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Week 8/notes.tex", "max_forks_repo_name": "Bkrenz/calu-csc360", "max_forks_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.306122449, "max_line_length": 190, "alphanum_fraction": 0.6102337334, "num_tokens": 1904, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376236, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.42502671897927563}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{bm}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{8cm}\n\\setlength{\\figureheight}{6cm}\n\n\\newlength\\squarefigurewidth\n\\newlength\\squarefigureheight\n\n\\setlength{\\squarefigurewidth}{7cm}\n\\setlength{\\squarefigureheight}{6cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\trans}{^\\top}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\mat}[1]{\\bm{\\mathrm{#1}}}\n\\renewcommand{\\vec}[1]{\\bm{\\mathrm{#1}}}\n\n\\DeclareMathOperator{\\var}{var}\n\n\\begin{document}\n\n{\\large \\textbf{CSE 515T (Spring 2015) Midterm solutions}}\n\\begin{enumerate}\n\\item\n  Consider two coins with unknown bias $\\theta_1$ and $\\theta_2$,\n  respectively.  We place independent, identical beta priors on these\n  quantities:\n  \\begin{equation*}\n    p(\\theta_1) = \\mc{B}(\\theta_1; 2, 2);\n    \\qquad\n    p(\\theta_2) = \\mc{B}(\\theta_2; 2, 2).\n  \\end{equation*}\n  Imagine someone flips both coins and tells you that \\emph{exactly\n    one} of the outcomes (but not which) was a ``head.''  Thus the\n  observation was either HT or TH, but you are not told which.  The\n  below expressions are conditioned on ``H'' to indicate this\n  observation.\n  \\begin{itemize}\n  \\item\n    Give an expression for the posterior of the first coin's bias\n    given this observation, $p(\\theta_1 \\given \\text{H})$.  Simplify\n    the result as much as you can.  Plot the prior and the posterior\n    for $\\theta_1$ over the interval $\\theta_1 \\in (0, 1)$.\n  \\item\n    Give an expression for the joint posterior $p(\\theta_1, \\theta_2\n    \\given \\text{H})$. Plot the joint prior, the likelihood, and the\n    joint posterior as three separate heat maps over the unit square\n    $(\\theta_1, \\theta_2) \\in (0, 1)^2$.  Use a grid with at least 100\n    values along each of the two $\\theta$ axes.\n  \\item\n    Summarize what the observation taught us about the bias of the\n    coins.\n  \\end{itemize}\n\\end{enumerate}\n\n\\subsection*{Solution}\n\nThe outcome of the unseen experiment was either HT or TH.  These are\nmutually exhaustive and independent events, so we may use the sum\nrule to derive the desired posterior:\n\\begin{equation*}\n  p(\\theta_1 \\given \\text{H})\n  =\n  \\Pr(\\text{HT})p(\\theta_1 \\given \\text{HT})\n  +\n  \\Pr(\\text{TH})p(\\theta_1 \\given \\text{TH})\n  .\n\\end{equation*}\nNotice that both $p(\\theta_1 \\given \\text{HT})$ and $p(\\theta_1 \\given\n\\text{TH})$ can be computed explicitly as updated beta distributions,\nnow that the coins in the outcomes have been identified:\n\\begin{align*}\n  p(\\theta_1 \\given \\text{HT})\n  &=\n  \\mc{B}(\\theta_1; 3, 2)\n  \\\\\n  p(\\theta_1 \\given \\text{TH})\n  &=\n  \\mc{B}(\\theta_1; 2, 3).\n\\end{align*}\n\nWhat is $\\Pr(\\text{HT})$?  It can be calculated explicitly, but a\nsimpler approach is to appeal to symmetry between the coins to\nconclude $\\Pr(\\text{HT}) = \\Pr(\\text{TH}) = \\nicefrac{1}{2}$.  Thus\n\\begin{equation*}\n  p(\\theta_1 \\given \\text{H})\n  =\n  \\tfrac{1}{2}\n  \\bigl(\n  p(\\theta_1 \\given \\text{HT}) +\n  p(\\theta_1 \\given \\text{TH})\n  \\bigr)\n  =\n  \\tfrac{1}{2}\n  \\bigl(\n  \\mc{B}(\\theta_1; 3, 2) +\n  \\mc{B}(\\theta_1; 2, 3)\n  \\bigr)\n  .\n\\end{equation*}\nWe can simply this expression further.  The posterior is proportional\nto\n\\begin{equation*}\n  p(\\theta_1 \\given \\text{H})\n  \\propto\n  \\theta_1^2 (1 - \\theta_1)\n  +\n  \\theta_1 (1 - \\theta_1)^2\n  =\n  \\theta_1(1 - \\theta_1)\n  \\propto\n  \\mc{B}(\\theta_1; 2, 2).\n\\end{equation*}\nTherefore the distribution of $\\theta_1$ has not changed given our\nobservation!  The prior (and posterior!) for $\\theta_1$ is plotted\nin Figure \\ref{problem_1_prior_1}.\n\n\\begin{figure}\n  \\centering\n  \\input{figures/problem_1_prior_1}\n  \\caption{The prior and posterior (given the observation H) of\n    $\\theta_1$.}\n  \\label{problem_1_prior_1}\n\\end{figure}\n\nThere are two ways to compute the joint posterior over $(\\theta_1,\n\\theta_2)$: the easy way and the hard way.  The easy way is to use the\nsum rule again to write\n\\begin{align*}\n  p(\\theta_1, \\theta_2 \\given \\text{H})\n  &=\n  \\Pr(\\text{HT})\n  p(\\theta_1, \\theta_2 \\given \\text{HT})\n  +\n  \\Pr(\\text{TH})\n  p(\\theta_1, \\theta_2 \\given \\text{TH})\n  \\\\\n  &=\n  \\tfrac{1}{2}\n  \\mc{B}(\\theta_1; 3, 2)\n  \\mc{B}(\\theta_2; 2, 3)\n  +\n  \\tfrac{1}{2}\n  \\mc{B}(\\theta_1; 2, 3)\n  \\mc{B}(\\theta_2; 3, 2).\n\\end{align*}\n\nIf we go with the hard way, we begin by computing the joint prior.  By\nindependence, we have:\n\\begin{equation*}\n  p(\\theta_1, \\theta_2)\n  =\n  \\mc{B}(\\theta_1; 2, 2)\n  \\mc{B}(\\theta_2; 2, 2).\n\\end{equation*}\nTo derive the likelihood, we again note that our observation could\nhave been generated by two mutually independent events: HT or TH.\nGiven $\\theta_1$ and $\\theta_2$, the total probability of these\nevents is:\n\\begin{equation*}\n  \\Pr(\\text{H} \\given \\theta_1, \\theta_2)\n  =\n  \\theta_1(1 - \\theta_2)\n  +\n  (1 - \\theta_1)\\theta_2;\n\\end{equation*}\nthe first term accounts for HT and the second term for TH.  The\nposterior is now:\n\\begin{align*}\n  p(\\theta_1, \\theta_2 \\given \\text{H})\n  &=\n  \\tfrac{1}{Z}\n  \\Pr(\\text{H} \\given \\theta_1, \\theta_2)\n  p(\\theta_1, \\theta_2)\n  \\\\\n  &=\n  \\tfrac{1}{Z}\n  \\bigl(\n  \\theta_1(1 - \\theta_2)\n  +\n  (1 - \\theta_1)\\theta_2\n  \\bigr)\n  \\mc{B}(\\theta_1; 2, 2)\n  \\mc{B}(\\theta_2; 2, 2).\n\\end{align*}\nThe normalization constant is\n\\begin{equation*}\n  Z\n  =\n  \\Pr(\\text{H})\n  =\n  \\int_0^1\n  \\int_0^1\n  \\bigl(\n  \\theta_1(1 - \\theta_2)\n  +\n  (1 - \\theta_1)\\theta_2\n  \\bigr)\n  \\mc{B}(\\theta_1; 2, 2)\n  \\mc{B}(\\theta_2; 2, 2)\n  \\intd{\\theta_1}\n  \\intd{\\theta_2}.\n\\end{equation*}\nThis integral is tractable and equals\n\\nicefrac{1}{2}.\\footnote{\\url{http://goo.gl/wRofuX}} In fact, this is\nalways true for any arbitrary mean-\\nicefrac{1}{2} beta priors on\n$\\theta_1, \\theta_2$: if our best guess is that each coin is unbiased,\nthen the outcomes HT/TH always have equal combined probability as the\noutcomes HH/TT.\n\nThe posterior is now\n\\begin{equation*}\n  p(\\theta_1, \\theta_2 \\given \\text{H})\n  =\n  2\n  \\bigl(\n  \\theta_1(1 - \\theta_2)\n  +\n  (1 - \\theta_1)\\theta_2\n  \\bigr)\n  \\mc{B}(\\theta_1; 2, 2)\n  \\mc{B}(\\theta_2; 2, 2).\n\\end{equation*}\nThis is equivalent to the expression we derived with ``the easy way.''\n\nThe prior, likelihood, and posterior are plotted below.  From the\nposterior, we can see that joint probabilities corresponding to\njointly low or high values: these combinations would correspond to a\nhigher probability of seeing either HH or TT observations.  Despite\nthe marginals for $\\theta_1$ and $\\theta_2$ remaining unchanged, the H\nobservation has entangled the previously independent beliefs in the\nanticorrelated posterior.\n\n\\begin{figure}\n  \\centering\n  \\input{figures/problem_1_joint_prior.tex}\n  \\caption{The joint prior $p(\\theta_1, \\theta_2)$.}\n  \\label{problem_joint_prior}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\input{figures/problem_1_joint_likelihood.tex}\n  \\caption{The joint likelihood $p(\\text{H} \\given \\theta_1, \\theta_2)$.}\n  \\label{problem_joint_likelihood}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\input{figures/problem_1_joint_posterior.tex}\n  \\caption{The joint posterior $p(\\theta_1, \\theta_2 \\given \\text{H})$.}\n  \\label{problem_joint_posterior}\n\\end{figure}\n\n\\clearpage\n\\begin{enumerate}\n\\setcounter{enumi}{1}\n\\item\n  Consider the three-dimensional parameter vector $\\vec{\\theta} =\n  [\\theta_1, \\theta_2, \\theta_3]\\trans$, with the following joint\n  multivariate Gaussian prior:\n  \\begin{equation*}\n    p(\\vec{\\theta})\n    =\n    \\mc{N}(\\vec{\\theta}; \\vec{\\mu}, \\mat{\\Sigma})\n    =\n    \\mc{N}\n    \\left(\n    \\begin{bmatrix}\n      \\theta_1 \\\\\n      \\theta_2 \\\\\n      \\theta_3\n    \\end{bmatrix}\n    ;\n    \\begin{bmatrix}\n      0 \\\\\n      1 \\\\\n      2\n    \\end{bmatrix},\n    \\begin{bmatrix}\n      1 & 2 & 0   \\\\\n      2 & 9 & 0 \\\\\n      0 & 0 & 16\n    \\end{bmatrix}\n    \\right).\n  \\end{equation*}\n  We are going to consider a decision problem with action space\n  $\\mc{A} = \\{1, 2, 3\\}$.  The result of choosing an action $a \\in\n  \\mc{A}$ will be to observe the exact value of $\\theta_a$, the $a$th\n  element of $\\vec{\\theta}$.\n\n  Consider the following loss functions, $\\ell_1$ and $\\ell_2$:\n  \\begin{equation*}\n    \\ell_1(\\vec{\\theta}, a) =\n    \\begin{cases}\n      1 & \\theta_a   >  0 \\\\\n      0 & \\theta_a \\leq 0\n    \\end{cases}\n    \\qquad\n    \\ell_2(\\vec{\\theta}, a) = \\min(0, \\theta_a).\n  \\end{equation*}\n  For each:\n  \\begin{itemize}\n  \\item\n    Write a generic expression for the expected loss of action $a$ in\n    terms of $\\vec{\\mu}$ and $\\mat{\\Sigma}$.  Evaluate any integrals\n    you encounter.\n  \\item\n    Give a numerical value for the expected loss of each action, using\n    the values of $(\\vec{\\mu}, \\mat{\\Sigma})$ provided above.\n  \\item\n    State the Bayes action.\n  \\end{itemize}\n\\end{enumerate}\n\n\\subsection*{Solution}\n\nFirst, we note that the loss functions only depend on $\\vec{\\theta}$\nthrough $\\theta_a$, so we must only consider the marginal belief about\n$\\theta_a$ when contemplating action $a$.  By applying the marginalization\nformula for multivariate Gaussians, this belief is:\n\\begin{equation*}\n  p(\\theta_a) = \\mc{N}(\\theta_a; \\mu_a, \\Sigma_{aa}).\n\\end{equation*}\nFor loss $\\ell_1$, we may calculate the expected loss of each action:\n\\begin{equation*}\n  \\mathbb{E}\n  \\bigl[\n    \\ell_1(\\vec{\\theta}, a)\n  \\bigr]\n  =\n  \\int_{-\\infty}^\\infty\n  \\ell_1(\\vec{\\theta}, a)\n  p(\\theta_a)\n  \\intd{\\theta_a}\n  =\n  \\int_0^\\infty\n  \\mc{N}(\\theta_a; \\mu_a, \\Sigma_{aa})\n  \\intd{\\theta_a}\n  =\n  1 - \\Phi(0; \\mu_a, \\Sigma_{aa}).\n\\end{equation*}\nUsing this result, we may numerically calculate the expected loss for\neach action:\n\\begin{equation*}\n  \\mathbb{E}\\bigl[\\ell_1(\\vec{\\theta}, 1)\\bigr]\n  =\n  0.5 \\qquad\n  \\mathbb{E}\\bigl[\\ell_1(\\vec{\\theta}, 2)\\bigr]\n  =\n  0.631 \\qquad\n  \\mathbb{E}\\bigl[\\ell_1(\\vec{\\theta}, 3)\\bigr]\n  =\n  0.691.\n\\end{equation*}\nThe Bayes action is $a = 1$, with the lowest expected loss.\n\nFor loss $\\ell_2$, we proceed in the same way:\n\\begin{equation*}\n  \\mathbb{E}\n  \\bigl[\n    \\ell_2(\\vec{\\theta}, a)\n  \\bigr]\n  =\n  \\int_{-\\infty}^\\infty\n  \\ell_2(\\vec{\\theta}, a)\n  p(\\theta_a)\n  \\intd{\\theta_a}\n  =\n  \\int_{-\\infty}^0\n  \\theta_a\n  \\mc{N}(\\theta_a; \\mu_a, \\Sigma_{aa})\n  \\intd{\\theta_a}.\n\\end{equation*}\nWe may compute this definite integral; I used a table of Gaussian\nintegrals\\footnote{\\url{http://en.wikipedia.org/wiki/List_of_integrals_of_Gaussian_functions}}\nand the identity\n\\begin{equation*}\n  \\phi\\biggl(\n  \\frac{a - \\mu}{\\sigma}\n  \\biggr)\n  =\n  \\sigma \\mc{N}(a; \\mu, \\sigma^2)\n\\end{equation*}\nto derive\n\\begin{equation*}\n  \\mathbb{E}\n  \\bigl[\n    \\ell_2(\\vec{\\theta}, a)\n  \\bigr]\n  =\n  \\mu_a \\Phi(0; \\mu_a, \\Sigma_{aa})\n  -\n  \\Sigma_{aa}\n  \\mc{N}(0; \\mu_a, \\Sigma_{aa}).\n\\end{equation*}\nUsing this result, we may numerically calculate the expected loss for\neach action:\n\\begin{equation*}\n  \\mathbb{E}\\bigl[\\ell_2(\\vec{\\theta}, 1)\\bigr]\n  =\n  -0.399 \\qquad\n  \\mathbb{E}\\bigl[\\ell_2(\\vec{\\theta}, 2)\\bigr]\n  =\n  -0.763 \\qquad\n  \\mathbb{E}\\bigl[\\ell_2(\\vec{\\theta}, 3)\\bigr]\n  =\n  -0.791.\n\\end{equation*}\nThe Bayes action is now $a = 3$, with the lowest expected loss.\n\n\\clearpage\n\\begin{enumerate}\n\\setcounter{enumi}{2}\n\\item\n  Consider a $d$-dimensional vector $\\vec{\\theta}$ with an arbitrary\n  multivariate Gaussian distribution:\n  \\begin{equation*}\n    p(\\vec{\\theta})\n    =\n    \\mc{N}(\\vec{\\theta}; \\vec{\\mu}, \\mat{\\Sigma}).\n  \\end{equation*}\n  \\begin{itemize}\n  \\item\n    Give a general expression for the distribution of the following\n    (scalar) value $\\tau$.\n    \\begin{equation*}\n      \\tau = \\theta_1 + 2\\theta_2 + \\dotsb d\\theta_d\n    \\end{equation*}\n  \\item\n    Consider again the specific distribution of the three-dimensional\n    vector $\\vec{\\theta}$ from the last problem, as well as the action\n    space $\\mc{A}$ with the same observation mechanism: after choosing\n    $a \\in \\mc{A}$, we will observe the corresponding value\n    $\\theta_a$.  Suppose we may select one action and then must\n    predict $\\tau$ under a squared loss function:\n    \\begin{equation*}\n      \\ell(\\tau, \\hat{\\tau}) = (\\tau - \\hat{\\tau})^2.\n    \\end{equation*}\n    Using the distribution from the last problem. what is the expected\n    loss of each of the three available actions?  Which is the Bayes\n    action?\n  \\end{itemize}\n\\end{enumerate}\n\n\\subsection*{Solution}\n\nDefine the (row) vector $\\vec{d}\\trans = [1, 2, \\dotsc, d]$.  We first\nnotice that $\\tau$ is simply a linear transformation of\n$\\vec{\\theta}$:\n\\begin{equation*}\n  \\tau = \\vec{d}\\trans \\vec{\\theta};\n\\end{equation*}\ntherefore $\\tau$ has a multivariate Gaussian distribution:\n\\begin{equation*}\n  p(\\tau)\n  =\n  p(\\vec{d}\\trans \\vec{\\theta})\n  =\n  \\mc{N}(\\tau; \\vec{d}\\trans \\vec{\\mu}, \\vec{d}\\trans \\mat{\\Sigma} \\vec{d}).\n\\end{equation*}\n\nIn the second part of the question, we must consider estimating $\\tau$\nunder a squared loss function $\\ell(\\tau, \\hat{\\tau}) = (\\tau -\n\\hat{\\tau})^2$.  A general result from Bayesian decision theory is\nthat the Bayes action is to estimate $\\hat{\\tau}$ as the (posterior)\nmean of $\\tau$.  For example, given the initial belief from the last\nproblem, we would predict $\\hat{\\tau} = \\vec{d}\\trans \\vec{\\mu} = 8$.\nWhat is the \\emph{expected} loss when predicting the mean $\\hat{\\tau}\n= \\mathbb{E}[\\tau]$?\n\\begin{equation*}\n  \\mathbb{E}\n  \\Bigl[\n    \\ell\\bigl(\\tau, \\mathbb{E}[\\tau]\\bigr)\n  \\Bigr]\n  =\n  \\mathbb{E}\n  \\Bigl[\n    \\bigl(\\tau - \\mathbb{E}[\\tau]\\bigr)^2\n  \\Bigr]\n  =\n  \\var [ \\tau ]\n  =\n  \\vec{d}\\trans \\mat{\\Sigma} \\vec{d}.\n\\end{equation*}\nThe expected squared loss is simply the variance of $\\tau$!  Conveniently,\nwe have a closed-form expression for this variance.\n\nThe problem asks us to consider how we would proceed with estimating\n$\\tau$ if we could observe one of the entries of the vector\n$\\vec{\\theta}$ before making our prediction $\\hat{\\tau}$.  If we wish\nto minimize our expected loss, we should minimize the variance of\n$\\tau$ with our observation.  Observing an entry of $\\vec{\\theta}$ is\na conditioning observation of a multivariate Gaussian.  We have a\nclosed-form expression for the posterior covariance of $\\vec{\\theta}$\nafter observing any entry $\\theta_a$.  Remarkably, the posterior\ncovariance of $\\vec{\\theta}$ does not depend on the actual value we\nobserve, only the index of the entry we choose, $a$.  The posterior\ncovariance matrices $\\mat{\\Sigma}_{\\vec{\\theta} \\given \\theta_a}$ for\neach available action $a \\in \\mc{A}$ are:\n\\begin{align*}\n  \\mat{\\Sigma}_{\\vec{\\theta} \\given \\theta_1}\n  &=\n  \\begin{bmatrix}\n    0 & 0 & 0   \\\\\n    0 & 5 & 0   \\\\\n    0 & 0 & 16\n  \\end{bmatrix}\n  \\\\\n  \\mat{\\Sigma}_{\\vec{\\theta} \\given \\theta_2}\n  &=\n  \\begin{bmatrix}\n    \\frac{5}{9} & 0 & 0   \\\\\n    0           & 0 & 0   \\\\\n    0           & 0 & 16\n  \\end{bmatrix}\n  \\\\\n  \\mat{\\Sigma}_{\\vec{\\theta} \\given \\theta_3}\n  &=\n  \\begin{bmatrix}\n    1 & 2 & 0 \\\\\n    2 & 9 & 0 \\\\\n    0 & 0 & 0\n  \\end{bmatrix}.\n\\end{align*}\nThe expected losses of our final prediction of $\\hat{\\tau}$\ngiven $\\theta_a$ is now given by\n\\begin{equation*}\n  \\mathbb{E}\\bigl[\\ell(\\tau, \\hat{\\tau}) \\given \\theta_a \\bigr]\n  =\n  \\vec{d}\\trans \\mat{\\Sigma}_{\\vec{\\theta} \\given \\theta_a} \\vec{d}.\n\\end{equation*}\nFor our particular problem, the expected final loss after each potential\naction is:\n\\begin{equation*}\n  \\mathbb{E}\\bigl[\\ell(\\tau, \\hat{\\tau}) \\given \\theta_1\\bigr]\n  =\n  164 \\qquad\n  \\mathbb{E}\\bigl[\\ell(\\tau, \\hat{\\tau}) \\given \\theta_2\\bigr]\n  =\n  144\\,\\nicefrac{5}{9} \\qquad\n  \\mathbb{E}\\bigl[\\ell(\\tau, \\hat{\\tau}) \\given \\theta_3\\bigr]\n  =\n  45.\n\\end{equation*}\nThe Bayes action is $a = 3$.  Despite the fact that $\\theta_3$ is\nuncorrelated with the other two entries, collapsing its large variance\nfrom $16$ to zero has the effect of reducing the variance of $\\tau$\n(and therefore our expected loss) by $3^2 \\cdot 16 = 144$.\n\n\\clearpage\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item\n  Consider the following data:\n  \\begin{align*}\n    \\vec{x} &= [0.54, 1.84, -2.26, 0.86, 0.32]\\trans; \\\\\n    \\vec{y} &= [-1.31, -0.43, 0.34, 3.58, 2.77]\\trans.\n  \\end{align*}\n  Consider the Bayesian linear regression model with $\\phi(x) = [1,\n    x]\\trans$.  Use the prior $p(\\vec{w}) = \\mc{N}(\\vec{w}; \\vec{0},\n  \\mat{I})$.\n\n  Plot the posterior probability that the slope of the regression line\n  is positive as a function of the standard deviation of the\n  observation noise $\\sigma$ (the noise variance is then $\\sigma^2$).\n  Use a grid of at least 100 points in the range $\\sigma \\in (0.01,\n  10)$.\n\\end{enumerate}\n\n\\subsection*{Solution}\n\nUsing the given linear regression model, we assume\n\\begin{equation*}\n  y\n  =\n  \\phi(x)\\trans \\vec{w} + \\varepsilon\n  =\n  w_1 + w_2 x + \\varepsilon.\n\\end{equation*}\nThe second entry of the weight vector $\\vec{w}$, $w_2$, therefore\nserves as the slope of the regression line.\n\nThe Bayesian linear regression model gives the following posterior for\n$\\vec{w}$ given observations $\\data$ and a specified noise variance\n$\\sigma^2$:\n\\begin{equation*}\n  p(\\vec{w} \\given \\data, \\sigma^2)\n  =\n  \\mc{N}(\\vec{w};\n  \\vec{\\mu}_{\\vec{w}\\given\\data},\n  \\mat{\\Sigma}_{\\vec{w}\\given\\data}\n  ),\n\\end{equation*}\nwhere\n\\begin{align*}\n  \\vec{\\mu}_{\\vec{w}\\given\\data}\n  &=\n  \\mat{X}\\trans\n  (\\mat{X}\\mat{X}\\trans + \\sigma^2 \\mat{I})\\inv\n  \\vec{y};\n  \\\\\n  \\mat{\\Sigma}_{\\vec{w}\\given\\data}\n  &=\n  \\mat{I}\n  -\n  \\mat{X}\\trans\n  (\\mat{X}\\mat{X}\\trans + \\sigma^2 \\mat{I})\\inv\n  \\mat{X},\n\\end{align*}\nwhere we have plugged the given prior $p(\\vec{w}) = \\mc{N}(\\vec{w};\n\\vec{0}, \\mat{I})$ into the general result.\n\nGiven a value of $\\sigma$, the formulas above give the posterior over\n$\\vec{w}$.  To determine the probability that $w_2$ is positive, we\nsimply take the marginal posterior distribution and evaluate the\nnormal \\acro{CDF}:\n\\begin{equation*}\n  \\Pr(w_2 > 0 \\given \\data, \\sigma^2)\n  =\n  1 -\n  \\Phi\\bigl(\n  0;\n  (\\vec{\\mu}_{\\vec{w}\\given\\data})_2\n  ,\n  (\\mat{\\Sigma}_{\\vec{w}\\given\\data})_{22}\n  \\bigr).\n\\end{equation*}\n\nThis quantity is plotted as a function of $\\sigma$ in Figure\n\\ref{problem_4}.  The larger the noise, the less confident we become\nabout the sign of the slope.\n\n\\begin{figure}\n  \\centering\n  \\input{figures/problem_4.tex}\n  \\caption{The posterior probability that the slope of the regression\n    line is positive as a function of the noise standard deviation\n    $\\sigma$.  Note the limits on the $y$-axis.}\n  \\label{problem_4}\n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "504cd0b50bfec1912212656e2d1b2391dfb94451", "size": 19316, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "spring_2015/midterm/solutions/miderm_solutions.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "spring_2015/midterm/solutions/miderm_solutions.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "spring_2015/midterm/solutions/miderm_solutions.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 27.7928057554, "max_line_length": 94, "alphanum_fraction": 0.6618865189, "num_tokens": 6777, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.42502671193003844}}
{"text": "\\chapter{Overview}\r\n\r\n\r\nThe \\sfincs~code is a freely available, open-source tool for solving neoclassical-type kinetic problems in nonaxisymmetric or axisymmetric plasmas\r\nwith nested toroidal flux surfaces.\r\nAs with other neoclassical codes, the input information used by \\sfincs~is the equilibrium magnetic geometry together with the density, radial density gradient, temperature,\r\nand radial temperature gradient of each species.  The code then solves a drift-kinetic equation for each species,\r\nyielding the (gyro-angle averaged) distribution function.  Moments of the distribution function are computed such as the parallel\r\nflow, bootstrap current, radial particle flux, radial heat flux, and variation of the density over a flux surface.  \r\nThese moments are all saved in the output file, and if you wish, you can also save the distribution function itself.\r\nOptionally, a quasi-neutrality\r\nequation can be solved at the same time as the drift-kinetic equations, yielding the self-consistent variation of the electrostatic potential on a flux surface.\r\n\r\nThe kinetic equations solved in \\sfincs~have four independent variables: poloidal angle $\\theta$, toroidal angle $\\zeta$,\r\nnormalized speed $x = v / v_{thermal}$, and pitch angle $\\xi = v_{||}/v$.  The third velocity coordinate (gyro-angle) does not appear\r\nsince gyro-averaged equations are solved.  The flux surface label (radius) coordinate is only a parameter, rather than a full independent variable,\r\nsince a radially local approximation is made. \r\nThe solution is the first-order distribution function $f_{s1} \\left(\\theta, \\zeta, x, \\xi\\right)$ (where the full distribution is $f_s = f_{s0} + f_{s1}$) on the flux surface for all species $s$, and if quasi-neutrality is solved also the electrostatic potential variation on the flux surface $\\Phi_1 \\left(\\theta, \\zeta\\right) = \\Phi-\\left<\\Phi\\right>$. \r\n\r\nThis document discusses the practical use and operation of the code.  For more details about the specific equations implemented,\r\nsee the version 3 technical documentation available in the \\path{sfincs/docs} directory.\r\nRef \\cite{sfincsPaper} gives many details and some early physics results.\r\n\r\nOften, the limiting factor for \\sfincs~is the ability of the libraries \\mumps~or \\superludist~to factorize the preconditioner matrix, discussed in section \\ref{sec:gmres}.\r\nYou may therefore find it useful to see the control parameters and error codes in the \\mumps~user manual:\r\n\\url{http://mumps.enseeiht.fr/doc/userguide_5.0.0.pdf}.\r\n\r\nThis manual describes ``version 3'' of \\sfincs.  \r\nTo preserve previous versions of the code that have been used for publications, two older versions of the\r\ncode called singleSpecies and multiSpecies are also present in the repository.  \r\nFor all versions, both MATLAB and fortran editions exist which are independent of each other.\r\nThe MATLAB editions exist primarily for debugging the fortran editions.\r\nThe same algorithms are implemented in the two different languages, and for identical input parameters, \r\nthe matrices and output quantities from the different editions should agree to several significant digits (roughly within the solver tolerance.)\r\nAny significant differences between the matrices and output of the MATLAB and fortran editions can be used to identify a bug.\r\nThe MATLAB versions are serial whereas the fortran versions\r\nare parallelized, so the fortran versions are significantly faster and can access much more memory.\r\nFor realistic experimental geometry and collisionality, the resolution (and hence memory) requirements will mean\r\nyou will need to use the fortran edition.\r\n\r\n\\section{Features}\r\n\r\n\\begin{itemize}\r\n\r\n\\item\r\nBoth self-species and inter-species collisions are treated using the most accurate linear operator available, the full linearized Fokker-Planck collision operator,\r\nwith no approximation of the field-particle term or expansion in mass ratio.  This collision operator conserves mass, momentum, and energy.\r\n\r\n\\item\r\nRealistic experimental geometry can be simulated using an interface to \\vmec.  Analytic model equilibria can also be used.\r\n\r\n\\item\r\nFull coupling in the speed (or equivalently, kinetic energy) coordinate is retained, i.e. no monoenergetic approximation is made.  However,\r\nif desired, \\sfincs~can also be run in monoenergetic mode to compare with older codes.\r\n\r\n\\item\r\nThe code is formulated to permit solution of a wide variety of kinetic equations, whether or not phase space volume and/or energy are conserved, so individual terms can be turned on or off to examine their effect. \r\n\r\n\\item\r\nA variety of models for terms involving the radial electric field are available to allow comparison between models. \r\n\r\n\\item\r\nYou can choose to include or not include the poloidal and toroidal magnetic drifts in the kinetic equation.\r\n\r\n\\item\r\nThe code takes advantage of modern algorithms (GMRES) and parallelized libraries (\\PETSc, \\superludist, and \\mumps).\r\n\r\n\\item\r\nEfficient representation of velocity space is achieved using a pseudospectral method based upon non-classical orthogonal polynomials. \\cite{speedGrids}\r\n\r\n\\item\r\nThe electrostatic potential can either be taken to be constant or non-constant on a flux surface.\r\n\r\n\\item\r\nOptional nonlinear terms in the kinetic equation (involving both the non-Maxwellian distribution function and poloidal/toroidal electric field) can be included using Newton's method. \r\n\r\n\\item \r\nThe radial classical particle and heat fluxes are calculated.\r\n\r\n\\end{itemize}\r\n\r\n\\section{Limitations}\r\n\r\n\\begin{itemize}\r\n\r\n\\item\r\nThe \\sfincs~code is radially local, in the sense that it approximates \r\nthe radial derivative of the distribution function $\\partial f/\\partial \\psi$ by\r\nthe derivative of a Maxwellian flux function $\\partial f_M(\\psi,x)/\\partial \\psi$.\r\nThis approximation is important for reducing the otherwise 5D space of independent variables $(\\psi,\\theta,\\zeta,x,\\xi)$\r\nto a 4D space $(\\theta,\\zeta,x,\\xi)$.\r\nAs a result, \\sfincs~cannot compute certain finite-orbit-width effects that occur when the radial extent of the particle orbits\r\nbetween bounces or transits is not small compared to the scale of radial variation in the equilibrium.\r\nSuch finite orbit width effects are significant near the magnetic axis, and in strong transport barriers, such as the pedestal of a tokamak H-mode.\r\n\r\n\\item\r\nTurbulence is neglected.  There are good theoretical reasons to expect that the neoclassical effects computed by \\sfincs~should\r\ndecouple from turbulence, as detailed in \\cite{AbelReview}.  However, this argument relies on an expansion in $\\rho_* \\ll 1$, and so may break down\r\nin some circumstances when $\\rho_*$ is not sufficiently small.\r\n\r\n\\item\r\nIt is assumed that nested toroidal magnetic surfaces exist. Thus, the code cannot accurately model regions of stochastic field,\r\nmagnetic islands, or open field lines.\r\n\r\n\\end{itemize}\r\n\r\n\\section{Geometry options}\r\nIn \\sfincs, a variety of options are available for the magnetic field geometry.  The geometry can be read directly\r\nfrom a {\\ttfamily vmec wout}\r\nfile, or from the {\\ttfamily .bc} format Boozer-coordinate data files used at the Max Planck Institute for Plasma Physics (IPP).\r\nA general analytic model for the magnetic field is also available, given by equation (\\ref{eq:Bmodel}),\r\nas are several analytic models for LHD and W7-X in which 3 or 4 Fourier components are retained.\r\nThe primary switch for controlling the magnetic geometry in \\sfincs~is the \\parlink{geometryScheme} parameter\r\nin the {\\ttfamily \\hyperref[sec:geometryParameters]{geometryParameters}} input namelist.\r\nFor more details about geometry options in \\sfincs, see section \\ref{sec:geometryParameters}.\r\n\r\n\\section{GMRES/KSP and preconditioning}\r\n\\label{sec:gmres}\r\n\r\nAt its heart, \\sfincs~solves one or more large sparse linear systems $Ax=b$.  Here $b$ is a known right-hand side vector,\r\n$A$ is a large (often millions $\\times$ millions) known sparse matrix, and $x$ is the desired and unknown solution vector.\r\nThe direct way to solve such systems is to $LU$-factorize\r\nthe matrix $A$ into lower- and upper-triangular factors.\r\nOnce the $L$ and $U$ factors are found, the solution of the linear system\r\nfor any right-hand side vector can be rapidly obtained.  However, even if the original matrix is sparse, the $L$ and $U$ factors\r\nare generally not sparse, and so a very large amount of memory can be required for a direct $LU$-factorization.\r\n\r\nAn alternative way to solve\r\nsuch large linear systems is with a so-called ``Krylov-space'' iterative method, which can dramatically reduce the memory required\r\ncompared to a direct solution.  For the non-symmetric matrices that arise in \\sfincs, the preferred Krylov-space\r\nalgorithm is called GMRES (Generalized Minimal RESidual.)  In \\sfincs, the \\PETSc~library is used to solve the large systems\r\nof equations. \\PETSc~calls its family of linear solvers KSP, so in the output of \\sfincs~you will see a ``KSP residual'' reported\r\nas GMRES iterates towards the solution.\r\n\r\nAn important element of Krylov methods is preconditioning.  The art of preconditioning is to find a linear operator which has similar eigenvalues\r\nto the ``true'' matrix you would like to invert (or more precisely, to $LU$-factorize), but which can be inverted faster.\r\nIf a good preconditioner can be found, the number of GMRES iterations is greatly reduced.  Many schemes for preconditioning exist,\r\nbut the version adopted in \\sfincs~is to explicity form and $LU$-factorize a preconditioning matrix which is similar\r\nto the true matrix (but somewhat simpler).  There is a basic trade-off:\r\nthe more similar the preconditioner matrix is to the true matrix, the fewer iterations will be required, but the more time will\r\nbe required to $LU$-factorize the preconditioning operator.  The usual preconditioner matrix in \\sfincs~is obtained by dropping all coupling\r\nbetween grid points in the speed coordinate and dropping coupling between species.  The preconditioner matrix need not be a physically\r\naccurate or meaningful operator; as long as GMRES converges, the solution obtained will be independent of the preconditioner to whatever tolerance is specified.\r\n\r\n\\section{\\sfincs~vs. \\sfincsScan}\r\nThe core fortran part of \\sfincs~solves the kinetic equation for each species\r\nat a single flux surface, a single value of $E_r$, and a single set of other parameters.\r\nHowever, often the goal is to determine the ambipolar $E_r$ at one or more surfaces, or to scan some other parameter.\r\nFor this task, the \\sfincsScan~family of \\python~scripts is available.\r\nUsing these scripts, it is also possible to scan other variables in the input file,\r\nand in particular, to scan the resolution parameters to ensure\r\nthe physical output quantities are numerically converged.\r\nFor a full list of the types of scans available, see section \\ref{sec:sfincsScanParams}\r\n\r\n\\section{Input and Output}\r\n\r\nThe input parameters for a \\sfincs~computation are specified in a file named {\\ttfamily input.namelist}.\r\nThis file contains both information for the fortran part of \\sfincs~(in standard fortran namelist format),\r\nas well as special lines beginning with {\\ttfamily !ss} which are read by \\sfincsScan.\r\nThe variables which can be specified in {\\ttfamily input.namelist} are detailed in chapter \\ref{ch:input}.\r\nFor scans over minor radius, an additional file named {\\ttfamily profiles} is used to specify the profiles of density and temperature\r\nfor each species, as well as the range of radial electric field to consider.\r\n\r\nThe output from a single \\sfincs~computation is saved in \\HDF~format in the file %{\\ttfamily sfincsOutput.h5}.\r\nspecified by \\parlink{outputFileName}.\r\nTo browse this file you can enter {\\ttfamily h5dump outputFileName|less} %{\\ttfamily h5dump sfincsOutput.h5|less} \r\nfrom the command line.\r\nEvery array saved in this file is annotated with strings that describe the array dimensions,\r\nfor example \\Ntheta$\\times$ \\Nzeta. One of the array dimensions may be {\\ttfamily iteration},\r\nwhich can either indicate the iteration of the Newton solver for a nonlinear calculation,\r\nor which right-hand side vector was used when computing a transport matrix.\r\nMany of the variables in the output file are also annotated with\r\ntext that describes their meaning and normalization. \r\nSome of the most frequently used output quantities are detailed in chapter~\\ref{ch:output}.\r\n\r\n\\section{Questions, Bugs, and Feedback}\r\n\r\nWe enthusiastically welcome any contributions to the code or documentation.\r\nFor write permission to the repository, or to report any bugs, provide feedback, or ask questions, contact Matt Landreman at\r\n\\href{mailto:matt.landreman@gmail.com}{\\nolinkurl{matt.landreman@gmail.com} }\r\n\r\n\r\n", "meta": {"hexsha": "676455b12740d964bd5716d7d3ecf94d955a8f81", "size": 12711, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/manual/version3/overview.tex", "max_stars_repo_name": "amollen/sfincs", "max_stars_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2017-10-13T15:15:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:56:20.000Z", "max_issues_repo_path": "doc/manual/version3/overview.tex", "max_issues_repo_name": "amollen/sfincs", "max_issues_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-01-02T09:04:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-28T09:53:21.000Z", "max_forks_repo_path": "doc/manual/version3/overview.tex", "max_forks_repo_name": "amollen/sfincs", "max_forks_repo_head_hexsha": "a529954fd36330e1b5c816612943f39829f3542f", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-03-19T14:30:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-03T14:37:14.000Z", "avg_line_length": 69.4590163934, "max_line_length": 356, "alphanum_fraction": 0.7864054756, "num_tokens": 2885, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.8499711870587667, "lm_q2_score": 0.5, "lm_q1q2_score": 0.42498559352938337}}
{"text": "% file: EM_dump.tex\n% Electrodynamics, in unconventional ``grande'' format; fitting a widescreen format\n% Electricity and Magnetism notes \"dump\" \n% \n% github        : ernestyalumni\n% linkedin      : ernestyalumni \n% wordpress.com : ernestyalumni\n%\n% This code is open-source, governed by the Creative Common license.  Use of this code is governed by the Caltech Honor Code: ``No member of the Caltech community shall take unfair advantage of any other member of the Caltech community.'' \n% \n\n\\documentclass[10pt]{amsart}\n\\pdfoutput=1\n\\usepackage{mathtools,amssymb,lipsum,caption}\n\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage[utf8]{inputenc}\n\\usepackage{listings}\n\\usepackage[table]{xcolor}\n\\usepackage{pdfpages}\n%\\usepackage[version=3]{mhchem}\n\\usepackage{mhchem}\n\n\\usepackage{tikz}\n\\usetikzlibrary{matrix,arrows}\n\n\\usepackage{multicol}\n\n\\hypersetup{colorlinks=true,citecolor=[rgb]{0,0.4,0}}\n\n\\oddsidemargin=15pt\n\\evensidemargin=5pt\n\\hoffset-45pt\n\\voffset-55pt\n\\topmargin=-4pt\n\\headsep=5pt\n\\textwidth=1120pt\n\\textheight=595pt\n\\paperwidth=1200pt\n\\paperheight=700pt\n\\footskip=40pt\n\n\n\n\n\n\n\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}{Corollary}\n%\\newtheorem*{main}{Main Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{proposition}{Proposition}\n\n\\newtheorem{definition}{Definition}\n\\newtheorem{remark}{Remark}\n\n\\newenvironment{claim}[1]{\\par\\noindent\\underline{Claim:}\\space#1}{}\n\\newenvironment{claimproof}[1]{\\par\\noindent\\underline{Proof:}\\space#1}{\\hfill $\\blacksquare$}\n\n%This defines a new command \\questionhead which takes one argument and\n%prints out Question #. with some space.\n\\newcommand{\\questionhead}[1]\n  {\\bigskip\\bigskip\n   \\noindent{\\small\\bf Question #1.}\n   \\bigskip}\n\n\\newcommand{\\problemhead}[1]\n  {\n   \\noindent{\\small\\bf Problem #1.}\n   }\n\n\\newcommand{\\exercisehead}[1]\n  { \\smallskip\n   \\noindent{\\small\\bf Exercise #1.}\n  }\n\n\\newcommand{\\solutionhead}[1]\n  {\n   \\noindent{\\small\\bf Solution #1.}\n   }\n\n\n\\title{Electromagnetism, Electrodynamics Dump;  \\large Electricity and Magnetism dump (includes notes and solutions to Purcell's Electricity and Magnetism}\n\\author{Ernest Yeung \\href{mailto:ernestyalumni@gmail.com}{ernestyalumni@gmail.com}}\n\\date{7 mars 2017}\n\\keywords{Electromagnetism, Electrodynamics, Electricity, Magnetism}\n\\begin{document}\n\n\\definecolor{darkgreen}{rgb}{0,0.4,0}\n\\lstset{language=Python,\n frame=bottomline,\n basicstyle=\\scriptsize,\n identifierstyle=\\color{blue},\n keywordstyle=\\bfseries,\n commentstyle=\\color{darkgreen},\n stringstyle=\\color{red},\n }\n%\\lstlistoflistings\n\n\\maketitle\n\nFrom the beginning of 2016, I decided to cease all explicit crowdfunding for any of my materials on physics, math.  I failed to raise \\emph{any} funds from previous crowdfunding efforts.  I decided that if I was going to live in \\emph{abundance}, I must lose a scarcity attitude.  I am committed to keeping all of my material \\textbf{open-sourced}.  I give all my stuff \\emph{for free}.   \n\nIn the beginning of 2017, I received a very generous donation from a reader from Norway who found these notes useful, through \\emph{PayPal}.  If you find these notes useful, feel free to donate directly and easily through \\href{https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_name=ernestyalumni&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted}{PayPal}, which won't go through a 3rd. party such as indiegogo, kickstarter, patreon.  Otherwise, under the \\emph{open-source MIT license}, feel free to copy, edit, paste, make your own versions, share, use as you wish.    \n\n\\noindent gmail        : ernestyalumni \\\\\nlinkedin     : ernestyalumni \\\\\ntwitter      : ernestyalumni \\\\\n\n\n  \n\\setcounter{tocdepth}{1}\n\\tableofcontents\n\n\\begin{multicols*}{2}\n\n\n\\begin{abstract}\nElectricity and Magnetism notes \"dump\" - Everything about or involving electricity and magnetism, electrodynamics.\n\n\\end{abstract}\n\n\\part{Math}\n\n\\section{Codifferential, The \"Vector Potential\" and Laplacian}  \n\\emph{Keywords}: codifferential, vector potential, Laplacian\n\n\\subsection{Codifferential $\\delta$}\n\nFor smooth manifold $M$, $\\text{dim}M = n$, \n\\begin{equation}\n\\boxed{\n\\begin{aligned}\n\t& \\delta : \\Omega^k(M) \\to \\Omega^{k-1}(M) \\\\ \t\n\t& \\delta = (-1)^{n(k+1)+1} * d*\n\\end{aligned}\n}\n\\end{equation}\n\nFor $k=1,2$ cases, \n\\[\n\\begin{aligned}\n\t& \\delta = (-1)^{n(1+1)+1} * d* = (-1) *d* \\\\ \n\t& \\delta = (-1)^{n(2+1) + 1} * d * = (-1)^{3n+1} *d*\n\\end{aligned}\n\\]\nFor $n=d=3$, \n\\[\n\\begin{aligned}\n\t& \\mathbf{\\delta} : \\Omega^2(M) \\to \\Omega^1(M) \\\\ \n\t& \\mathbf{\\delta} = \\mathbf{* d * }\n\\end{aligned}\n\\]\n\n\\subsection{the \"Vector Potential\"}\n\nIf $B=\\mathbf{d} A$, $B\\in \\Omega^2(M)$, \n\\[\n\\begin{gathered}\nB= B_{jk} dx^j \\wedge dx^k = \\mathbf{d}A = \\frac{ \\partial A_k}{ \\partial x^j} dx^j \\wedge dx^k  \\\\\n B_{jk} = \\frac{ \\partial A_k}{ \\partial x^j} \n\\end{gathered}\n\\]\nSo these statements are equivalent: \n\\begin{equation}\n\\boxed{ \nB =\\mathbf{d} A \\Longleftrightarrow \\mathbf{B} = \\text{curl} \\mathbf{A}\n}\n\\end{equation}\n\nIndeed, recall the \\emph{deRham cohomology}:\n\n\\[\n\\begin{gathered}\n\tH^k_{\\text{deRham}}(M) = Z^k(M)/ \\text{im}d = \\frac{Z^k(M)}{ d\\Omega^{k-1}(M) }\n\\end{gathered}\n\\]\nAnd so this form for $B=\\mathbf{d}A$ presupposes that \n\\[\nB \\in [1] = [\\mathbf{d}A ] \\in H^2_{\\text{deRham}}(M')\n\\]\nBut it should be noted on another manifold, this form may not hold; indeed, consider a submanifold or domain $M' \\subseteq M$.  In this case\n\\[\nH^2_{\\text{deRham}}(M') \\ni B\n\\]\n\n\\subsection{Laplacian}\n\n\\begin{definition}[Laplacian]\n\\begin{equation}\n\\begin{aligned}\n\t& \\Delta : \\Omega^k(M) \\to \\Omega^k(M) \\\\ \n\t& \\Delta = d\\delta + \\delta d\n\\end{aligned}\n\\end{equation}\n\\end{definition}\n\nBoth recognizing the equivalence between these 2 formulations:\n\\[\n\\mathbf{*d*}B = \\mathbf{\\delta}B \\Longleftrightarrow \\text{curl} \\mathbf{B}\n\\]\nand acknowledging that it \\emph{has} to be the case that $\\mathbf{*d*}B$ is the correct expression, coming from $d*F$ for the electromagnetic 2-form $F$, \n\\[\n\\mathbf{\\delta} B = \\mathbf{\\delta} \\mathbf{d}A = \\Delta A - \\mathbf{d \\delta} A\n\\]\nThen\n\\[\n\\begin{gathered}\n\t\\mathbf{*d}A = \\frac{ \\sqrt{|\\mathbf{g} |} }{ (d-2)! } \\epsilon_{i_1i_2 \\dots i_{d-2} jk} g^{jj'} g^{kk'} \\frac{ \\partial A_{k'}}{ dx^{j'} } dx^{i_1} \\wedge \\dots \\wedge dx^{i_{d-2}} = \\sqrt{ |\\mathbf{g} | } \\epsilon_{ijk} g^{jj'} g^{kk'} \\frac{ \\partial A_{k'} }{ \\partial x^{j'} } dx^i  \\\\\n\\end{gathered}\n\\]\n\n\nConsider the expression \n\\[\n\\text{curl}\\mathbf{B} = \\text{curl}( \\text{curl} \\mathbf{A})\n\\]\nI will generalize it and point out its misgivings.  \n\nCalculating from definitions for $*$ and $d$, \n\\[\n\\begin{gathered}\n\t\\mathbf{d} \\mathbf{*} \\mathbf{d} A = \\frac{ \\epsilon_{i_1 i_2 \\dots i_{d-2} jk } }{ (d-2)! } \\frac{ \\partial }{ \\partial x^l} \\left( \\sqrt{|\\mathbf{g} |} g^{jj'} g^{kk'} \\frac{ \\partial A_{k'} }{ \\partial x^{j'} } \\right) dx^l \\wedge dx^{i_1} \\wedge \\dots \\wedge dx^{i_{d-2} } \\\\ \n\t\\mathbf{*} \\mathbf{d} \\mathbf{*} \\mathbf{d} A = \\frac{ \\sqrt{ |\\mathbf{g} | } }{ (d-d(-1))! } \\frac{ \\epsilon_{id'i_1' i_2' \\dots i'_{d-2} } }{ (d-2)! } g^{l'l} g^{i_1' i_1} g^{i_2' i_2} \\dots g^{i_{d-2}' i_{d-2} } \\frac{ \\partial }{ \\partial x^l } \\left( \\sqrt{ |\\mathbf{g} | } g^{jj'} g^{kk'} \\frac{ \\partial A_{k'} }{ \\partial x^{j'} } \\right) \\epsilon_{i_1 i_2 \\dots i_{d-2} jk } dx^i = \\\\\n\\xrightarrow{d=3} \\sqrt{ |\\mathbf{g} | } \\epsilon_{il'm'} g^{l'l} g^{m'm} \\frac{ \\partial }{ \\partial x^l} \\left( \\sqrt{ |\\mathbf{g} | } g^{jj'} g^{kk'} \\frac{ \\partial A_{k'} }{ \\partial x^{j'} } \\right) \\epsilon_{mjk} dx^i\n\\end{gathered}\n\\]\nIn $\\mathbb{R}^3$, \n\\[\n\\mathbf{*} \\mathbf{d} \\mathbf{*} \\mathbf{d} A \\xrightarrow{ \\mathbb{R}^3} \\frac{ \\partial }{ \\partial x^j} \\left( \\frac{ \\partial A_k }{ \\partial x^j} \\right) - \\frac{ \\partial }{ \\partial x^k} \\left( \\frac{ \\partial A_k}{ \\partial x^j} \\right)\n\\]\nAt this point, in the \"vector calculus\" formulation, the partial derivatives in the $- \\frac{ \\partial }{ \\partial x^k} \\left( \\frac{ \\partial A_k}{ \\partial x^j} \\right)$ would be exchanged in order, and then a so-called \"choice of gauge\" for $\\nabla \\cdot A \\equiv \\text{div}A$ would be \"made,\" making this term equal $0$.  As we clearly see above, this should not be the case.  Rather, this choice should be made:\n\\begin{equation}\n\\mathbf{d \\delta } A = 0\n\\end{equation}\nThis is because we should directly use the \"manifestly covariant\" definition of the Laplacian:\n\\begin{equation}\n\\begin{gathered}\n\t\\mathbf{* d * d } A = (-1)^{d(1-1) +1} \\mathbf{ \\delta d} A = (-1)^{0+1} \\mathbf{ \\delta d } A = (-1)^{1} (\\Delta - \\mathbf{d\\delta } ) A \\\\\n\\xrightarrow{ d=3} (-1)(\\Delta - \\mathbf{ d\\delta } ) A\t\n\\end{gathered}\n\\end{equation}\nNote that $k=1$, i.e. we're dealing with 1-form $A$ here, in the $(-1)^{d(k-1)+1}$ factor.  \n\nSo the true expression is this (to reiterate and emphasize the point):\n\\begin{equation}\t\n\\mathbf{\\delta}B = (-1) (\\Delta - \\mathbf{d\\delta } ) A\n\\end{equation}\n\nAre there any necessary constraints on $A$ to make it, such that $\\mathbf{d\\delta }A=0$?  Perhaps we can take a look at how the definition of the codifferential $\\mathbf{\\delta}$ necessitates that this diagram commutes:\n\\[\n \\begin{tikzpicture}\n  \\matrix (m) [matrix of math nodes, row sep=7.8em, column sep=7.8em, minimum width=5.2em]\n  {\n \\Omega^1(M)  &  \\Omega^{d-1}(M)  \\\\ \n\t\\Omega^0(M) &  \\Omega^d(M)  \\\\ \n};\n  \\path[->]\n  (m-1-1) edge node [above] {$ \\mathbf{*} $ }  (m-1-2)\nedge node [auto] {$\\mathbf{\\delta} $ } (m-2-1) \n\t(m-1-2) edge node [auto] {$ \\mathbf{d} $ } (m-2-2)\n\t(m-2-1) edge node [auto] {$ \\mathbf{ * } (-1) $ }(m-2-2)\n  ;\n\\end{tikzpicture}   \\qquad \\quad \\, \n\\begin{tikzpicture}\n  \\matrix (m) [matrix of math nodes, row sep=7.8em, column sep=7.8em, minimum width=5.2em]\n  {\n A  &  \\mathbf{*}A  \\\\ \n\t\\delta A &  \\mathbf{d}\\mathbf{*} A  \\\\ \n};\n  \\path[|->]\n  (m-1-1) edge node [above] {$ \\mathbf{*} $ }  (m-1-2)\nedge node [auto] {$\\mathbf{\\delta} $ } (m-2-1) \n\t(m-1-2) edge node [auto] {$ \\mathbf{d} $ } (m-2-2)\n\t(m-2-1) edge node [auto] {$ \\mathbf{ * } (-1) $ }(m-2-2)\n  ;\n\\end{tikzpicture}  \n\\]\n\n\n\n\\part{Maxwell's Equations; My version of Maxwell's Equations}\n\n\\section{My version of Maxwell's equations}\n\n\\subsection{Maxwell's Equations, my version, in \"vector calculus\" form}\n\nIf $\\nabla \\cdot \\mathbf{B} = 0$, then\n\\begin{equation}\n\t\\nabla \\times \\mathbf{E} = \\frac{-1}{c} \\left( \\frac{ \\partial \\mathbf{B} }{\\partial t} \\right)\n\\end{equation}\n\nIf $\\nabla \\cdot \\mathbf{E} = 4\\pi \\rho_{\\text{total}}$, then \n\\begin{equation}\n\\begin{aligned}\n\t\\nabla \\times \\mathbf{B} & = \\frac{1}{c} \\left( \\frac{ \\partial \\mathbf{E}}{ \\partial t} + 4\\pi \\frac{ \\partial \\mathbf{P} }{ \\partial t} +  \\right.  \\\\\n\t& \\left.   + 4\\pi \\mathbf{J}_{\\text{free}} + 4\\pi c \\nabla \\times \\mathbf{M}  \\right)\n\\end{aligned}\n\\end{equation}\n\n\\subsection{Maxwell's Equations, my version, over spacetime manifold $M$}\n\nFor spacetime manifold $M$, of dimensions $\\text{dim}M = d+1$, and for \n\\[\n\\begin{aligned}\n\t& E \\in \\Omega^1(M) \\\\ \n\t& B \\in \\Omega^2(M)\n\\end{aligned}\n\\]\nIf $\\mathbf{d}B=0$, then \n\\begin{equation}\\label{Eq:MaxwellsEqnsDGEBInduction}\n\\boxed{ \t\\mathbf{d}E + \\frac{ \\partial B}{ \\partial t} = 0  }\n\\end{equation}\n\nIf $\\mathbf{\\delta}E = \\mathbf{*} \\mathbf{d} \\mathbf{*} E = 4\\pi \\rho_{\\text{total}}$, \n\\begin{equation}\\label{Eq:MaxwellsEqnsDGEBFaraday}\n\t\\boxed{ \\mathbf{\\delta} B = \\mathbf{*} \\mathbf{d} \\mathbf{*} B = \\frac{ \\partial E}{ \\partial t} + 4\\pi \\frac{ \\partial P}{ \\partial t} + 4\\pi J_{\\text{free}} + 4\\pi c \\mathbf{\\delta} \\mathbf{M} }\n\\end{equation}\nwith $\\mathbf{M} \\in \\Omega^2(M)$, magnetization in matter (i.e. matter magnetization) is \\emph{necessarily} a 2-form.  \n\n\\subsubsection{Some of the algebra (scratch) work/explicit calculations, for Maxwell's Equations, my version, over spacetime manifold $M$}\n\n\\[\n\\mathbf{d}B \\Longleftrightarrow \\nabla \\cdot B\n\\]\nsince component-wise, \n\\[\n\\begin{gathered}\n\t\\mathbf{d} B = \\frac{ \\partial }{ \\partial x^k } B_{ij} dx^k \\wedge dx^i \\wedge dx^j \\Longleftrightarrow \\nabla \\cdot B \n\\end{gathered}\n\\]\n\\[\n\\mathbf{d}E = -\\frac{ \\partial B}{\\partial t}   \\Longleftrightarrow \\nabla \\times E \\equiv \\text{curl} E = \\frac{-1}{c} \\frac{ \\partial \\mathbf{B}}{ \\partial t}  \n\\]\nsince, component-wise, \n\\[\n\\mathbf{d} E = \\frac{ \\partial }{ \\partial x^k} E_i dx^k \\wedge dx^i = \\frac{ \\partial }{ \\partial x^j} E_k dx^j \\wedge dx^k = \\frac{ -\\partial }{ \\partial t} B_{jk} dx^j \\wedge dx^k \n\\]\nFor $\\mathbf{\\delta} E = \\mathbf{*} \\mathbf{d} \\mathbf{*} E = 4\\pi \\rho_{\\text{total}}$, consider\n\\[\n\\begin{gathered}\n\t\\mathbf{*} E = \\frac{1}{ (d-1)!} \\sqrt{ \\mathbf{g}} \\epsilon_{i_1i_2 \\dots i_{d-1} j_1} E_j g^{jj_1} e^{i_1} \\wedge e^{i_2} \\wedge \\dots \\wedge e^{i_{d-1}} = \\frac{1}{2} \\sqrt{ \\mathbf{g}} \\epsilon_{ijk} E_{k'} g^{k'k} dx^i \\wedge dx^j \n\\end{gathered}\n\\]\nFurther, \n\\[\n\\begin{gathered}\n\t\\mathbf{d} \\mathbf{*} E = \\frac{1}{ (d-1)! } \\frac{ \\partial }{ \\partial x^k} (\\sqrt{ \\mathbf{g}} E_j g^{jj_1} ) \\epsilon_{i_1 i_2 \\dots i_{d-1} j_1 } dx^k \\wedge dx^{i_1} \\wedge dx^{i_2} \\wedge \\dots \\wedge dx^{i_{d-1}} = \\\\\n=\\frac{1}{(d-1)!} \\frac{ \\partial }{ \\partial x^k} (\\sqrt{ \\mathbf{g}} E^{j_1} ) \\epsilon_{i_1 i_2 \\dots i_{d-1} j_1} \\epsilon^{ k i_1 i_2 \\dots i_{d-1} } \\frac{ \\text{vol}^d}{ \\sqrt{ |\\mathbf{g} | } } = \\\\\n=\\frac{1}{(d-1)!} \\frac{ \\partial }{ \\partial x^k} (\\sqrt{ |\\mathbf{g} | } E^{j_1} ) \\delta^k_{ j_1} (d-1)! \\frac{ \\text{vol}^d}{ \\sqrt{ |\\mathbf{g} | } } = \\frac{1}{ \\sqrt{ |\\mathbf{g} | }} \\frac{ \\partial }{ \\partial x^k} (\\sqrt{ |\\mathbf{g} |} E^k) \\text{vol}^d \n\\end{gathered}\n\\]\nwhere this (generalized) Kronecker delta relation was used: \n\\[\n\\frac{1}{p!} \\delta^{\\mu_1 \\dots \\mu_p }_{\\nu_1 \\dots \\nu_p } \\delta^{ \\nu_1 \\dots \\nu_p }{ \\rho_1 \\dots \\rho_p } = \\delta^{\\mu_1 \\dots \\mu_p }_{ \\rho_1 \\dots \\rho_p }\n\\]\nwhere \n\\[\n\\delta^{\\mu_1 \\dots \\mu_n }_{ \\nu_1 \\dots \\nu_n } = \\epsilon^{\\mu_1 \\dots \\mu_n} \\epsilon_{ \\nu_1 \\dots \\nu_n }\n\\]\nNote that \n\\[\n\\begin{aligned}\n\t*1 & = \\text{vol} \\\\\n**1  & = (-1)^{0(n-0)} 1 = 1 = *\\text{vol}\n\\end{aligned}\n\\]\nand so \n\\[\n\\mathbf{*} \\mathbf{d} \\mathbf{*} E = \\mathbf{\\delta} E = \\frac{1}{\\sqrt{ |\\mathbf{g} | } } \\frac{ \\partial }{ \\partial x^k} ( \\sqrt{ | \\mathbf{g} | } E^k )\n\\]\nIndeed, we had generalized the divergence, but on a 1-form:\n\\begin{equation}\n\\begin{aligned}\n\t& \\mathbf{\\delta} : \\Omega^1(M) \\to C^{\\infty}(M) \\\\ \n\t& -\\mathbf{\\delta} E = -\\mathbf{\\delta} (E_kdx^k)  = \\frac{1}{\\sqrt{|\\mathbf{g} |} } \\frac{ \\partial }{ \\partial x^k} (\\sqrt{ |\\mathbf{g} | } E^k) \\equiv \\frac{1}{\\sqrt{ |\\mathbf{g} | } } \\frac{ \\partial }{ \\partial x^k} ( \\sqrt{ |\\mathbf{g} | }  g^{kk_1} E_{k_1} )\n\\end{aligned}\n\\end{equation}\n\n\\section{Magnetostatics, macroscopic Magnetism, Magnetic permeability, magnetic susceptibility, field $\\mathbf{H}$, free currents and field $\\mathbf{H}$}\n\n\\emph{Keywords}: magnetic permeability, magnetic susceptibility\n\nSuppose we have matter (i.e. the \"macroscopic problem\", referred to from Jackson (1998), Sec. 5.8 \"Macroscopic Equations, Boundary Conditions on $B$ and $H$\", \\cite{Jack1998}), \\emph{not} a vacuum.  \n\nAtoms in matter have electrons, $e^-$ in orbit, contributing to (rapidly) fluctuating magnetic moments $\\mathbf{m}$, along with $e^-$'s intrinsic $\\mathbf{m}$.  \n\nConsider an average macroscopic magnetization or magnetic moment density $\\mathbf{M}(\\mathbf{x})$ defined in a \"vector calculus\" manner by Jackson (1998) \\cite{Jack1998}, \n\\[\n\\mathbf{M}(\\mathbf{x}) = \\sum_I N_I\\langle \\mathbf{m}_I\\rangle , \\qquad \\, I \\equiv \\text{ index of a particle } \n\\]\n\nRecalling Maxwell's Equations, Eq. \\ref{Eq:MaxwellsEqnsDGEBFaraday}, \n\\[\n\\mathbf{\\delta} B = \\frac{ \\partial E}{ \\partial t} + 4\\pi \\frac{ \\partial P }{ \\partial t} + 4\\pi J_{\\text{free}} + 4\\pi c \\mathbf{\\delta}\\mathbf{M}\n\\]\nConsider a time-independent $E$ and negligible $P$.  Then \n\\[\n\\Longrightarrow \\mathbf{\\delta} B =  4\\pi J_{\\text{free}} + 4\\pi c \\mathbf{\\delta}\\mathbf{M}\n\\]\nJackson (1998) \\cite{Jack1998} considers this magnetization $\\mathbf{M}$ as contributing to an \\emph{effective current density} by vector calculus arguments of it having a vector potential form, and so he proceeds to write it as (Jackson (1998), Eqn. (5.80) \\cite{Jack1998})\n\\[\n\\text{curl} \\mathbf{B} = \\mu_0 (\\mathbf{J} + \\text{curl}\\mathbf{M} ) \\qquad \\, (SI)\n\\]\nThen Jackson \\emph{defines} the macroscopic field $\\mathbf{H}$, in Jackson (1998), Eqn. (5.81) \\cite{Jack1998}, \n\\[\n\\mathbf{H} := \\frac{1}{\\mu_0} \\mathbf{B} - \\mathbf{M}\n\\]\n\nHowever, Purcell's treatment is both more lucid, and more grounded in what $B$ field really is physically, less relying upon artificial artifices.  \n\n\\subsection{Free currents $\\mathbf{J}_{\\text{free}}$ and the field $\\mathbf{H}$, magnetic susceptibility}\n\ncf. Purcell (1984) \\cite{Purc1984}, Sec. 11.10 Free Currents, and the Field $\\mathbf{H}$  \n\n\\emph{Keywords}: $\\mathbf{H}$, volume magnetic susceptibility\n\nBound current $\\mathbf{J}_{\\text{bound}}$ are current associated with molecular or atomic magnetic moments, including the intrinsic magnetic moment of particles with spin.  \n\nFree currents $\\mathbf{J}_{\\text{free}}$ are ordinary conduction currents.  \n\n\\begin{equation}\n\\mathbf{J}_{\\text{bound}} = c \\nabla \\times \\mathbf{M}\n\\end{equation}\ncf. Purcell (1984), Eq. (44) of Ch. 11 \\cite{Purc1984}\n\nAt a surface, where $\\mathbf{M}$ is discontinuous, we have a surface current density $\\mathcal{J}$.  \n\n\nBy superposition, \n\\begin{equation}\n\t\\nabla \\times \\mathbf{B} = \\frac{ 4\\pi }{c} (\\mathbf{J}_{\\text{bound}} + \\mathbf{J}_{\\text{free} } ) = \\frac{4\\pi }{ c} \\mathbf{J}_{\\text{total} }\n\\end{equation}\ncf. Purcell (1984), Eq. (50) of Ch. 11 \\cite{Purc1984}\n\nThus, \n\\[\n\\begin{gathered}\n\\nabla \\times \\mathbf{B} = \\frac{ 4\\pi}{c}(c\\nabla \\times \\mathbf{M} ) + \\frac{4\\pi}{c} \\mathbf{J}_{\\text{free}} = \\\\\n\t= \\nabla \\times (\\mathbf{B} - 4\\pi \\mathbf{M} ) = \\frac{4\\pi }{c} \\mathbf{J}_{\\text{free} }\n\\end{gathered}\n\\]\ncf. Purcell (1984), Eq. (51) of Ch. 11 \\cite{Purc1984}\n\nPurcell also defines \n\\begin{equation}\n\\mathbf{H} := \\mathbf{B}-4\\pi \\mathbf{M}\n\\end{equation}\ncf. Purcell (1984), Eq. (52) of Ch. 11 \\cite{Purc1984}; and so \n\\[\n\\begin{gathered}\n\\nabla \\times \\mathbf{H} = \\frac{4\\pi}{c} \\mathbf{J}_{\\text{free}} \\qquad \\, (cgs) \\qquad \\qquad \\, \\nabla \\times \\mathbf{H} = \\mathbf{J}_{\\text{free}} \\qquad \\, (SI)\n\\end{gathered}\n\\]\ncf. Purcell (1984), Eq. (53), (53'), respectively, of Ch. 11 \\cite{Purc1984}.  \n\nIn magnetic systems, it is precisely the free currents that we can control.  So $\\mathbf{H}$ is useful:\n\n\\begin{equation}\n\\begin{gathered}\n\\int_C \\mathbf{H} \\cdot d\\mathbf{l} = \\frac{4\\pi}{c}\\int_S \\mathbf{J}_{\\text{free}} \\cdot d\\mathbf{a} = \\frac{4\\pi}{c} I_{\\text{free}} \\qquad \\, (cgs) \\qquad \\qquad \\, \\int_C \\mathbf{H} \\cdot d\\mathbf{l} = \\int_S \\mathbf{J}_{\\text{free}} \\cdot d\\mathbf{a} =  I_{\\text{free}} \\qquad \\, (SI)\n\\end{gathered}\n\\end{equation}\nwhere in SI, $H \\sim \\frac{ \\text{ amps } }{ \\text{ meter } }$.  cf. Purcell (1984), Eq. (54), (54'), respectively, of Ch. 11 \\cite{Purc1984}.  \n\n$\\mathbf{B}$ is the \\emph{fundamental magnetic field vector}; it is \\textbf{only} $\\mathbf{B}$ s.t. $\\nabla \\cdot \\mathbf{B} =0$ or $\\mathbf{d}B=0$  \n\nThe basic magnetic field inside matter is $\\mathbf{B}$, \\emph{not} $\\mathbf{H}$.  That's not a matter of mere definition, but a \\emph{consequence of the absence of magnetic charges}.  cf. Purcell (1984)\\cite{Purc1984}.   \n\nNow \n\\begin{equation}\n\\mathbf{M} = \\chi_m \\mathbf{H}\n\\end{equation}\ncf. Purcell (1984), Eq. (56) Ch. 11 \\cite{Purc1984}. \n\nThe lines of $\\mathbf{H}$ inside the magnet look just like the lines of $\\mathbf{E}$ inside the polarized cylinder.   \\\\\n- $\\mathbf{H}$ is the fiction of magnetic poles; if there wre magnetic poles then $\\mathbf{H}$ is the macroscopic $\\mathbf{B}$ filed inside the material.  \n\nFor any material in which $\\mathbf{M}$ is porportional to $\\mathbf{H}$, \n\\begin{equation}\n\\boxed{ \n\\begin{gathered}\n\t\\mathbf{B} = \\mathbf{H} + 4\\pi \\mathbf{M} = (1+4\\pi \\chi_m) \\mathbf{H} \\\\\n\\mu = 1 + 4\\pi \\chi_m\n\\end{gathered}\n}\n\\end{equation}\n\nSo \\emph{if} there was a linear response between magnetization $\\mathbf{M}$ and the measured macroscopic field $\\mathbf{H}$, related through the volume magnetic susceptibility, $\\chi_m$, ($\\mathbf{M} = \\chi_m \\mathbf{H}$), then for $\\mathbf{\\delta} B = 4\\pi J_{\\text{free}} + 4\\pi c \\mathbf{\\delta} \\mathbf{M}$, \n\\[\n\\mathbf{\\delta} (B-4\\pi c M) = \\mathbf{\\delta} H = \\mathbf{\\delta} \\frac{ B}{ \\mu } = 4\\pi J_{\\text{free}} \\Longrightarrow \\mathbf{B} = \\mu 4\\pi J_{\\text{free}} \n\\]\nand so we have the usual expression (make the comparison)\n\\[\n\\text{curl} \\mathbf{B} = \\mu 4\\pi \\mathbf{J}_{\\text{free}}\n\\]\nObtaining an integral form, \n\\[\n\\begin{gathered}\n\t\\mathbf{*} \\mathbf{\\delta} B = \\mathbf{*} \\mathbf{*} \\mathbf{d} \\mathbf{*} B = (-1)^{2(d-2)} \\mathbf{d}\\mathbf{*} B = \\mu 4\\pi \\mathbf{*} J_{\\text{free}} \\xrightarrow{ \\int_S } \\int_S \\mathbf{d} \\mathbf{*} B =  \\int_{\\partial S} \\mathbf{*} B = \\mu 4\\pi \\int_S \\mathbf{*} J_{\\text{free}}\n\\end{gathered}\n\\]\n\nJackson seems to imply to treat macroscopic field $\\mathbf{H}$ as what you measure, since $\\mathbf{J}_{\\text{free}}$ is what one can measure and control, pointed out sagely by Purcell.  So consider this, as I write down an integral form,\n\\[\n\\begin{gathered}\n\\mathbf{*} \\mathbf{\\delta} H  = \\mathbf{d} \\mathbf{*} H = 4\\pi \\mathbf{*} J_{\\text{free}} \\xrightarrow{ \\int_S } \\int_S \\mathbf{d} \\mathbf{*} H = \\int_{\\partial S} \\mathbf{*} H = 4\\pi \\int_S \\mathbf{*} J_{\\text{free}}\n\\end{gathered}\n\\]\nIf, over $S$, $\\mathbf{J}_{\\text{free}}$ is uniform, $\\frac{4\\pi}{c} \\int_S \\mathbf{*} \\mathbf{J}_{\\text{free}} = \\frac{4\\pi }{c} I_{\\text{free}}$.  If we can measure the current, we can obtain the line integral of $\\mathbf{H}$.  But we should really be aware that what we're \\emph{really} measuring is $B-4\\pi c \\mathbf{M}$ - would it be possible to measure the macroscopic $\\mathbf{M}$ itself?\n\n\\section{Eddy Currents}\n\nI build upon the physical setup proposed by Jackson (1998) \\cite{Jack1998} in Section 5.18 \"Quasi-Static Magnetic Fields in Conductors; Eddy Currents; Magnetic Diffusion.\"   \n\nFor a system (with characteristic) length $L$, $L$ being small, \\\\\ncompared to electromagnetic wavelength associated with dominant time scale of problem $T$, \n\\[\n\\begin{gathered}\n\tf := \\frac{1}{T} ; \\quad \\, \\omega = 2\\pi f ; \\quad \\, \\omega \\lambda = c \\Longrightarrow \\lambda = \\frac{c}{ \\omega } = \\frac{c}{ 2\\pi f } = \\frac{Tc}{2\\pi }  \\\\\n\\frac{L}{\\lambda} = \\frac{LTc}{2\\pi } \\gg 1\n\\end{gathered}\n\\]\nFrom Maxwell's equations, in particular, Faraday's Law, and in its integral form (over 2-dim. \\emph{closed} surface $S$), \n\\begin{equation}\n\\begin{gathered}\n\\mathbf{d}E + \\frac{ \\partial }{ \\partial t } B = 0 \\text{ or } -\\mathbf{d}E =\\frac{ \\partial B}{ \\partial t} \\xrightarrow{ \\int_S } \\int_S \\frac{ \\partial B}{ \\partial t} = -\\int_S \\mathbf{d}E = -\\int_{\\partial S} E\n\\end{gathered}\n\\end{equation}\nSo on $S$, changing magnetic flux $\\int \\frac{ \\partial B}{ \\partial t}$ results in $E$ field, circulating around boundary of $S$, $\\partial S$.  \n\nWe know that in a conductor, free conducting electrons get pushed around by $E$ fields, result in a current density $J$.  \n\n$J$ is related to $E$, \\emph{empirically} (by Ohm's Law)\n\\[\nJ = \\sigma E\n\\]\nwhere $\\sigma$ is the resistivity.  \n\nThen use the force law on this induced current $J$ from the $B$ field set up:\n\\[\nF_{\\text{net}} = \\frac{1}{c} \\int_S J\\times B dA\n\\]\nBy working through the right-hand rule, $F_{\\text{net}}$ the force on those currents induced in the conductor due to the $B$ that's there, is in the direction to help oppose changing (increasing or decreasing $\\frac{\\partial B}{ \\partial t}$).  \n\nTo find $B$, suppose $B=dA$, i.e. $B\\in H^2_{\\text{deRham}}(M)$, i.e. $B=\\text{curl}A$.  \n\nFor sure, \n\\[\n\\mathbf{\\delta} (B-4\\pi c \\mathbf{M}) = 4\\pi J \\Longleftrightarrow \\text{curl}(B-4\\pi c \\mathbf{M} ) = \\text{curl} H = 4\\pi J\n\\]\nBe warned now that the relation $B=\\mu H$ may not be valid on all domains of interest; $\\mu$ could even be a tensor! (e.g. $B_{ij} = \\mu^{kl}_{ij} H_{kl}$).  However, both Jackson (1998) \\cite{Jack1998} in Sec. 5.18 Quasi-Static Magnetic Fields in Conductors; Eddy Currents; Magnetic Diffusion, pp. 219, and Smythe (1968), Ch. X (his Ch. 10), pp. 368 \\cite{Smyt1968}, continues on \\emph{as if} this relation is linear: $B=\\mu H$.  \n\nNevertheless, as we want to find $B$ by finding its \"vector potential\" $A$, we obtain a diffusion equation: \n\\begin{equation}\\label{Eq:EddyCurrentsAdiffusion}\n\\begin{gathered}\n\t- \\mathbf{\\delta}B = \\mathbf{*d*d}A = (-1) \\mathbf{\\delta d} A = (-1)( \\Delta - \\mathbf{d\\delta} ) A \\xrightarrow{ \\mathbf{d\\delta} A = 0 } - \\Delta A = \\\\\n\t= 4\\pi \\mu J = 4\\pi \\mu \\sigma E = 4\\pi \\mu \\sigma \\left( -\\frac{ \\partial A}{ \\partial t} \\right) \\\\\n\\Longrightarrow \\boxed{ \\Delta A = 4\\pi \\mu \\sigma \\frac{ \\partial A}{ \\partial t } }\n\\end{gathered}\n\\end{equation}\nwhere in the first 2 steps (equalities), $- \\mathbf{\\delta}B = \\mathbf{*d*d}A = (-1) \\mathbf{\\delta d} A$ it's interesting to note that the codifferential $\\mathbf{\\delta}$ for the 2 form $B$ had to be written out explicitly, and then the codifferential for the 1-form $A$ is \\emph{different} from the $\\mathbf{\\delta}$ for $B$ by a(n important) factor of $(-1)$; where $\\mathbf{d\\delta} A=0$ must be satisfied by the form $A$ takes; and where, since $B=\\mathbf{d}A$,\n\\begin{equation}\n\\begin{gathered}\n\t\\mathbf{d}E + \\frac{ \\partial B}{ \\partial t} = \\mathbf{d} E + \\frac{ \\partial }{ \\partial t} \\mathbf{d} A = \\mathbf{d} \\left( E+ \\frac{ \\partial A}{ \\partial t} \\right) = 0 \\Longrightarrow E = -\\frac{ \\partial A}{ \\partial t} + \\text{grad}\\Phi \\xrightarrow{ \\Phi = \\text{ constant } } E = -\\frac{ \\partial A}{ \\partial t}\n\\end{gathered}\n\\end{equation}\nwhereas a choice of gauge for $E$ was chosen so that $\\Phi=\\text{constant}$ (and so a particular form for $E$ was chosen, amongst those in the \\emph{same} equivalence class of $H^1_{\\text{deRham}}(M)$.  \n\nTo ensure that the differential geometry formulation is in agreement with the practical vector calculus formulation, compare Eq. \\ref{Eq:EddyCurrentsAdiffusion} with Eq. (5.160) of Jackson (1998) \\cite{Jack1998} and Eq. (10) in Sec. 10.00 of Smythe (1968) \\cite{Smyt1968}.  \n\nTo summarize what's going on, I think one should at least understand in one's head how Maxwell's Equations apply, (and I will try to write in SI here)\n\\begin{equation}\n\\boxed{\n\\begin{gathered}\n\\int_S \\frac{ \\partial \\mathbf{B}}{ \\partial t} dA = -\\oint \\mathbf{E}\\cdot d\\mathbf{s} \\Longrightarrow \\mathbf{J}=\\sigma \\mathbf{E} \\Longrightarrow \\mathbf{F}_{\\text{net}} = \\int_S \\mathbf{J} \\times \\mathbf{B} dA  \\\\\n\\text{ to find } \\mathbf{B} = ? \\qquad \\, \\text{ using form } \\mathbf{B} = \\nabla \\times \\mathbf{A}, \\\\\n\\nabla^2 \\mathbf{A} = \\mu \\sigma \\frac{ \\partial \\mathbf{A} }{ \\partial t} \\qquad \\, (SI)\n\\end{gathered}\n}\n\\end{equation}\nwhere, a change in magnetic flux over a surface $S$ over the conductor, $\\int_S \\frac{ \\partial \\mathbf{B}}{ \\partial t}dA$ induces a circulation of $E$ field around $S$, $-\\oint \\mathbf{E} \\cdot d\\mathbf{s}$, and this $E$ field is pushing around \\emph{free conducting charges} according to Ohm's law, $\\mathbf{J} = \\sigma \\mathbf{E}$, with $\\sigma$ being the conductivity of the conducting material, and this current density $\\mathbf{J}$ is then acted upon by the prevailing $B$ field, according to the usual force law.  To find $\\mathbf{B}$, one can find $\\mathbf{A}$ and \\emph{try} to find $\\mathbf{A}$ analytically.  \n\nKeep in mind that for $\\nabla^2 \\mathbf{A} = \\mu \\sigma \\frac{ \\partial \\mathbf{A}}{ \\partial t}$, we had used, critically, the Maxwell equation $\\mathbf{\\nabla} \\times \\mathbf{H} = \\mathbf{J}$, with $\\mathbf{J}$ being the \\emph{induced current of free conducting charges on the conductor}.  This $\\mathbf{H}$ will contribute (through linear superposition) to the $\\mathbf{B}$ that could already be there due to the permanent magnet.  \n\n\n\\end{multicols*}\n\n\\begin{thebibliography}{9}\n\n\\bibitem{Jack1998}\nJ.D. Jackson.  \\textbf{Classical Electrodynamics} Third Edition.  Wiley.  1998.   ISBN-13: 978-0471309321\n\n\\bibitem{Purc1984}\nEdward M. Purcell.  \\textbf{Electricity and Magnetism} (Berkeley Physics Course, Vol. 2) Second Edition.  McGraw-Hill Science/Engineering/Math.  1984.  ISBN-13: 978-0070049086\n\n\\bibitem{Mori2001}\nShigeyuki Morita.  \\textbf{Geometry of Differential Forms (Translations of Mathematical Monographs, Vol. 201)}.  American Mathematical Society (August 28, 2001).   ISBN-13: 978-0821810453\n\n\\bibitem{OCalinDChang2005}\nOvidiu Calin, Der-Chen Chang. \\textbf{Geometric Mechanics on Riemannian Manifolds: Applications to Partial Differential Equations} (Applied and Numerical Harmonic Analysis).  Birkh\\\"{a}user. 2005. ISBN-13: 978-0817643546\n\n\\bibitem{Smyt1968}\nWilliam R. Smythe, \\textbf{Static and Dynamic Electricity}.  3rd ed. (McGraw-Hill, New York, 1968).  \n\n  \\end{thebibliography}\n\n\\end{document}\n\n\n\n\n    \n", "meta": {"hexsha": "98d6898dc8061f09a0152d7d8f7f41facb44b049", "size": 28800, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX_and_pdfs/EM_dump.tex", "max_stars_repo_name": "wacfeldwang333/mathphysics", "max_stars_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2017-01-10T14:24:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:19:23.000Z", "max_issues_repo_path": "LaTeX_and_pdfs/EM_dump.tex", "max_issues_repo_name": "wacfeldwang333/mathphysics", "max_issues_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2017-09-29T09:29:53.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T03:12:29.000Z", "max_forks_repo_path": "LaTeX_and_pdfs/EM_dump.tex", "max_forks_repo_name": "wacfeldwang333/mathphysics", "max_forks_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 25, "max_forks_repo_forks_event_min_datetime": "2018-01-21T05:33:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T20:15:13.000Z", "avg_line_length": 46.677471637, "max_line_length": 662, "alphanum_fraction": 0.6635763889, "num_tokens": 10718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7772998560157665, "lm_q1q2_score": 0.4249794868159666}}
{"text": "\\clearpage\n\\newpage\n\n\n\\section{Results}\n\\paragraph{Statistical errors} We used coalescent simulations of neutral\npolymorphisms under spatial models of admixture to compare the statistical\nerrors of the AQP and APLS estimates with those of the {\\tt tess3}\nalgorithm~\\citep{Caye2016}. The ground truth for the $Q$-matrix (${\\bf Q}_0$)\nwas computed from the mathematical model for admixture proportions used to\ngenerate the data. For the $G$-matrix, the ground truth matrix (${\\bf G}_0$) was\ncomputed from the empirical genotype frequencies in the two population samples\nbefore an admixture event. The root mean squared errors (RMSE) for the ${\\bf Q}$\nand ${\\bf G}$ estimates decreased as the sample size and the number of loci\nincreased (Figure~\\ref{fig:fig1}). For all algorithms, the statistical errors were generally\nsmall when the number of loci was greater than $10$k SNPs. Those results\nprovided evidence that the three algorithms produced equivalent estimates of the\nmatrices ${\\bf Q}_0$ and ${\\bf G}_0$. The results also provided a check\nthat the APLS and {\\tt tess3} algorithms converged to the same estimates as\nthose obtained after the application of the AQP algorithm, which is guaranteed\nto converge mathematically.\n\n\n\\paragraph{The benefit of including spatial information in algorithms} Using\nneutral coalescent simulations of spatial admixture, we compared the statistical\nestimates obtained from the spatial algorithm APLS and the non-spatial\nalgorithm {\\tt snmf}~\\citep{Frichot2014}. For various levels of ancestral\npopulation differentiation, estimates obtained from the spatial algorithm were\nmore accurate than for those obtained using non-spatial approaches\n(Figure~\\ref{fig:fig2}). For the larger samples, much finer population structure\nwas detected with the spatial method than with the non-spatial algorithm\n(Figure~\\ref{fig:fig2}).\n\nIn simulations of outlier loci, we used the area under the precision-recall\ncurve (AUC) for quantifying the performances of tests based on the estimates of\nancestry matrices, {\\bf Q} and {\\bf G}. In addition, we computed AUCs for\n$F_{\\rm ST}$-based neutrality tests using truly ancestral genotypes. As they\nrepresented the maximum reachable values, AUCs based on truly ancestral\ngenotypes were always higher than those obtained for tests based on\nreconstructed matrices. For all values of the relative selection intensity, AUCs\nwere higher for spatial methods than for non-spatial methods (Figure~\\ref{fig:fig3}, the\nrelative selection intensity is the ratio of migration rates at neutral and\nadaptive loci). For high selection intensities, the performances of tests based\non estimates of ancestry matrices were close to the optimal values reached by\ntests based on true ancestral frequencies. These results provided evidence that\nincluding spatial information in ancestry estimation algorithms improves the\ndetection of signatures of hard selective sweeps having occurred in unknown\nancestral populations.\n\n\\paragraph{Sensitivity of estimates to spatial measurements} Next, we used the\nsimulated data sets to evaluate the robustness of APLS estimates to inaccurate\nmeasurements of spatial coordinates. To this aim, Gaussian noise was added to\ntruly observed geographic coordinates by considering values of the\nnoise-to-signal ratio ranging from 0 to 3. We computed variograms in all cases,\nand found that the spatial signal was removed from simulations for\nnoise-to-signal ratios greater than two, while the signal was still observable\nwith a noise-to-signal ratio lower than one. For all simulations, we compared\nthe relative error of APLS $Q$-matrix estimates to those obtained from an\nnon-spatial method ({\\tt snmf}). For small levels of uncertainty in spatial\ncoordinates the errors of APLS estimates were lower than those of {\\tt snmf}\n(Figure~\\ref{fig:fig2_5}). For simulations with $n = 500$ individuals and $L =\n10^5$ loci, a larger noise-to-signal ratio increased statistical errors in the\n$Q$-matrix estimates from the APLS algorithm. For smaller noise-to-signal ratios,\nRMSEs remained generally lower for the APLS algorithm than for methods without\nspatial coordinates. For simulations with $n = 50$ individuals and $L = 10^4$\nloci, the APLS estimates were more accurate than the non-spatial estimates. This\nunexpected result could be explained by subtle algorithmic differences in tested\nprograms. To a large extent, estimates from the APLS algorithm were robust to\nuncertainty in spatial measurements. Standard graphical tests such as a\nvariogram analysis can help deciding whether our spatially explicit algorithm is\nuseful or not.\n\n\n\\paragraph{Runtime and convergence analyses} We subsampled a large SNP data set\nfor {\\it A. thaliana} ecotypes to compare the convergence properties and\nruntimes of the {\\tt tess3}, AQP, and APLS algorithms. In those experiments, we\nused $K = 6$ ancestral populations, and replicated 5 runs for each simulation.\nFor $n = 100-600$ individuals ($L = 50$k SNPs), the APLS algorithm required more\niterations (25 iterations) than the AQP algorithm (20 iterations) to converge to\nits solution (Figure~\\ref{fig:fig4}). This was less than for {\\tt tess3} (30 iterations). For\n$L = 10-200$k SNPs ($n = 150$ individuals), similar results were observed. For\n$50$k SNPs, the runtimes were significantly lower for the APLS algorithm than\nfor the {\\tt tess3} and AQP algorithms. For $L = 50$k SNPs and $n = 600$\nindividuals, it took on average 1.0 min for the APLS and 100 min for the AQP\nalgorithm to compute ancestry estimates. For {\\tt tess3}, the runtime was on\naverage 66 min. For $L = 100$k SNPs and $n = 150$ individuals, it took on\naverage 0.6 min (9.0 min) for the APLS (AQP) algorithm to compute ancestry\nestimates. For {\\tt tess3}, the runtime was on average 1.3 min. For those\nvalues of $n$ and $L$, the APLS algorithm implementation ran about 2 to 100\ntimes faster than the other algorithm implementations.\n \n\\paragraph{Human data analysis} To evaluate a case of model misspecification, we\nanalyzed data from the 1000 Genomes project for African Americans, Africans from\nNigeria and from Kenya, and Europeans from the United Kingdom and from Italy.\nUsing the default values for the hyper-parameters, the Laplacian matrix was a\nblock diagonal matrix where each block corresponded to one of the five\npopulations. The spatial variogram exhibited a flat shape. For $K = 2$, the APLS\nestimates for the African American population were equal to $24.2 \\%$ for\nEuropean ancestors and $75.8 \\%$ for African ancestors. The corresponding {\\tt\n  snmf} estimates were equal to $22.4 \\%$ for European ancestors and $77.6 \\%$\nfor African ancestors. For $K = 3$, the APLS estimates for the African American\npopulation were equal to $21.4 \\%$ for European ancestors, $51.8 \\%$ for West\nAfrican ancestors and $26.8 \\%$ for East African ancestors. The corresponding\n{\\tt snmf} estimates were equal to $22.2 \\%$ for European ancestors, $68.4 \\%$\nfor West African ancestors and $9.4 \\%$ for East African ancestors. Overall, the\nresults obtained with our spatial method for African Americans were similar to\nthose obtained with {\\tt snmf}. The main difference between APLS and {\\tt snmf}\nestimates were for African populations. For Africans, {\\tt snmf} detected two\ndistinct genetic clusters whereas APLS detected a larger proportion of shared\nancestry between Eastern and Western populations.\n\n\n\\paragraph{Application to European ecotypes of {\\it Arabidopsis thaliana}} We\nused the APLS algorithm to survey spatial population genetic structure and\nperform a genome scan for adaptive alleles in European ecotypes of the plant\nspecies {\\it A. thaliana}. The cross validation criterion decreased rapidly from\n$K=1$ to $K=3$ clusters, indicating that there were three main ancestral groups\nin Europe, corresponding to geographic regions in Western Europe, Eastern and\nCentral Europe and Northern Scandinavia. For $K$ greater than four, the values\nof the cross validation criterion decreased in a slower way, indicating that\nsubtle substructure resulting from complex historical isolation-by-distance\nprocesses could also be detected (Figure~\\ref{fig:fig5}). The spatial analysis provided an\napproximate range of $\\sigma = 150$km for the spatial variogram (Figure~\\ref{fig:fig5}).\nFigure~\\ref{fig:map} displays the $Q$-matrix estimate interpolated on a geographic map of\nEurope for $K = 6$ ancestral groups. The estimated admixture coefficients\nprovided clear evidence for the clustering of the ecotypes in spatially\nhomogeneous genetic groups.\n\n\\paragraph{Targets of selection in {\\it A. thaliana} genomes} Tests based on the\n$F^Q_{\\rm ST}$ statistic were applied to the 241k SNP data set to reveal new\ntargets of natural selection in the {\\it A. thaliana} genome. {\\it A. thaliana}\noccurs in a broad variety of habitats, and local adaptation to the environment\nis acknowledged to be important in shaping its genetic diversity through\nspace~\\citep{Hancock2011, Fournier-Level2011}. The APLS algorithm was run on the\n1,095 European lines of {\\it A. thaliana} with $K=6$ ancestral populations and\n$\\sigma = 1.5$ for the range parameter. Using the Benjamini-Hochberg algorithm to\ncontrol the FDR at the level $1\\%$, the program produced a list of 12,701\ncandidate SNPs, including linked loci and representing 3\\% of the total number\nof loci. The top 100 candidates included SNPs in the flowering-related genes\nSHORT VEGETATIVE PHASE (SVP), COP1-interacting protein 4.1 (CIP4.1) and FRIGIDA\n(FRI) ($p$-values $< 10^{-300}$). These genes were detected by previous scans\nfor selection on this dataset~\\citep{Horton2012}. We performed a gene ontology\nenrichment analysis using AmiGO in order to evaluate which biological functions\nmight be involved in local adaptation in Europe. We found a significant\nover-representation of genes involved in cellular processes (fold enrichment of\n1.06, $p$-value equal to 0.0215 after Bonferonni correction).\n\n\n", "meta": {"hexsha": "37fe1d712799ce0aae3bd0d0752b3aee43b4af07", "size": 9921, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2Article/Article/results.tex", "max_stars_repo_name": "cayek/Thesis", "max_stars_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2Article/Article/results.tex", "max_issues_repo_name": "cayek/Thesis", "max_issues_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2Article/Article/results.tex", "max_forks_repo_name": "cayek/Thesis", "max_forks_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.5838926174, "max_line_length": 93, "alphanum_fraction": 0.79266203, "num_tokens": 2404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.42497948399538554}}
{"text": "\\chapter{Problem set Solutions Fourier}\n\\begin{abox}\n\tPractise Set-1\n\\end{abox}\n\\begin{enumerate}[label=\\color{ocre}\\textbf{\\arabic*.}]\n\t\\item   The first few terms in the Laurent series for $\\frac{1}{(z-1)(z-2)}$ in the region $1 \\leq|z| \\leq 2$ and around $z=1$ is\n\t{\\exyear{NET/JRF(JUNE-2012)}}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}] $\\frac{1}{2}\\left[1+z+z^{2}+\\ldots\\right]\\left[1+\\frac{z}{2}+\\frac{z^{2}}{4}+\\frac{z^{3}}{8}+\\ldots .\\right]$\n\t\t\\task[\\textbf{B.}] $\\frac{1}{1-z}-z-(1-z)^{2}+(1-z)^{3}+\\ldots .$\n\t\t\\task[\\textbf{C.}] $\\frac{1}{\\mathrm{z}^{2}}\\left[1+\\frac{1}{\\mathrm{z}}+\\frac{1}{\\mathrm{z}^{2}}+\\ldots .\\right]\\left[1+\\frac{2}{\\mathrm{z}}+\\frac{4}{\\mathrm{z}^{2}}+\\ldots . .\\right]$\n\t\t\\task[\\textbf{D.}]  $2(z-1)+5(z-1)^{2}+7(z-1)^{3}+\\ldots$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\frac{1}{(z-1)(z-2)}&=\\frac{1}{z-2}-\\frac{1}{z-1}=\\frac{1}{1-z}+\\frac{1}{(z-1)-1}\\\\&=\\frac{1}{1-z}-(1+(1-z))^{-1}\\\\\n\t\t&=\\frac{1}{1-z}-\\left[1+(1-z)+\\frac{(-1)(-2)}{2 !}(1-z)^{2}+\\frac{(-1)(-2)(-3)}{3 !}(1-z)^{3} \\ldots\\right]\\\\\n\t\t&=\\frac{1}{1-z}-\\left[z+(1-z)^{2}-(1-z)^{3}+\\ldots . .\\right]\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item Consider a sinusoidal waveform of amplitude $1 V$ and frequency $f_{0}$. Starting from an arbitrary initial time, the waveform is sampled at intervals of $\\frac{1}{2 f_{0}}$. If the corresponding Fourier spectrum peaks at a frequency $\\bar{f}$ and an amplitude $\\bar{A}$, them\n\t{\\exyear{NET/JRF(JUNE-2012)}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\bar{f}=2 f_{0}$ and $\\bar{A}=1 V$\n\t\t\\task[\\textbf{B.}] $\\bar{f}=2 f_{0}$ and $0 \\leq \\bar{A} \\leq 1 V$\n\t\t\\task[\\textbf{C.}] $\\bar{f}=0$ and $\\bar{A}=1 V$\n\t\t\\task[\\textbf{D.}] $\\bar{f}=\\frac{f_{0}}{2}$ and $\\bar{A}=\\frac{1}{\\sqrt{2}} V$\n\t\\end{tasks}\n\t\\begin{answer}$\\left. \\right. $\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=4cm,width=8cm]{diagram-20211005(11)-crop}\n\t\t\\end{figure}\n\t\t\\begin{align*}\n\t\ty&=1 \\sin \\left(2 \\pi f_{0} t\\right)\\\\\n\t\t\\text{The Fourier transform is:}\\\\\n\t\tF(y)&=\\frac{1}{2}\\left[\\delta\\left(f+f_{0}\\right)\\right]-\\delta\\left[f-f_{0}\\right]\\\\\n\t\t\\text{In Fourier domain }\\bar{f}&=f_{0}, \\bar{A}=\\frac{1}{2}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item The Fourier transform of the derivative of the Dirac $\\delta-$ function, namely $\\delta^{\\prime}(x)$, is proportional to\n\t{\\exyear{NET/JRF(DEC-2013)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] 0\n\t\t\\task[\\textbf{B.}] 1\n\t\t\\task[\\textbf{C.}] $\\sin k$\n\t\t\\task[\\textbf{D.}] $i k$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{Fourier transform of }\\delta^{\\prime}(x)\\\\\n\t\tH(K)=\\int_{-\\infty}^{\\infty} \\delta^{\\prime}(x) e^{i k x} d x&=i k e^{(k \\cdot 0)}=i k\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\t\\item The Laplace transform of $6 t^{3}+3 \\sin 4 t$ is\n\t{\\exyear{NET/JRF(JUNE-2015)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $\\frac{36}{s^{4}}+\\frac{12}{s^{2}+16}$\n\t\t\\task[\\textbf{B.}] $\\frac{36}{s^{4}}+\\frac{12}{s^{2}-16}$\n\t\t\\task[\\textbf{C.}] $\\frac{18}{s^{4}}+\\frac{12}{s^{2}-16}$\n\t\t\\task[\\textbf{D.}] $\\frac{36}{s^{3}}+\\frac{12}{s^{2}+16}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL\\left[6 t^{3}+3 \\sin 4 t\\right] &\\quad \\because L\\left[t^{n}\\right]=\\frac{\\sqrt{n+1}}{s^{n+1}}\\\\\n\t\t\\because L[\\sin a t]&=\\frac{a}{\\left(s^{2}+a^{2}\\right)}\\\\\n\t\tL\\left[6 t^{3}+3 \\sin 4 t\\right]&=\\frac{6 \\times \\sqrt{4}}{s^{4}}+\\frac{3 \\times 4}{s^{2}+16}=\\frac{36}{s^{4}}+\\frac{12}{s^{2}+16}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (A)}\n\t\\end{answer}\n\t\\item  The Fourier transform of $f(x)$ is $\\tilde{f}(k)=\\int_{-\\infty}^{+\\infty} d x e^{i k x} f(x)$.\n\tIf $f(x)=\\alpha \\delta(x)+\\beta \\delta^{\\prime}(x)+\\gamma \\delta^{\\prime \\prime}(x)$, where $\\delta(x)$ is the Dirac delta-function (and prime denotes derivative), what is $\\tilde{f}(k) ?$\n\t{\\exyear{NET/JRF(DEC-2015)}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\alpha+i \\beta k+i \\gamma k^{2}$\n\t\t\\task[\\textbf{B.}] $\\alpha+\\beta k-\\gamma k^{2}$\n\t\t\\task[\\textbf{C.}]  $\\alpha-i \\beta k-\\gamma k^{2}$\n\t\t\\task[\\textbf{D.}] $i \\alpha+\\beta k-i \\gamma k^{2}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\tilde{f}(k)&=\\int_{-\\infty}^{\\infty} d x e^{i k x}\\left(\\alpha \\delta(x)+\\beta \\delta^{\\prime}(x)+\\gamma \\delta^{\\prime \\prime}(x)\\right)\\\\\n\t\t\\int_{-\\infty}^{\\infty} \\alpha \\delta(x) e^{i k x} d x&=\\alpha\\\\\n\t\t\\int_{-\\infty}^{\\infty} \\beta \\delta^{\\prime}(x) e^{i k x} d x&=\\beta\\left[\\left.e^{i k x} \\delta(x)\\right|_{-\\infty} ^{\\infty}-\\int_{-\\infty}^{\\infty} i k e^{i k x} \\delta(x) d x\\right]=-i \\beta k\\\\\n\t\t\\int_{-\\infty}^{\\infty} \\gamma \\delta^{\\prime \\prime}(x) e^{i k x} d x&=-\\gamma k^{2}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (C)}\n\t\\end{answer}\n\t\\item  What is the Fourier transform $\\int d x e^{i l x} f(x)$ of\n\t$$\n\tf(x)=\\delta(x)+\\sum_{n=1}^{\\infty} \\frac{d^{n}}{d x^{n}} \\delta(x)\n\t$$\n\twhere $\\delta(x)$ is the Dirac delta-function?\n\t{\\exyear{NET/JRF(JUNE-2016)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}]  $\\frac{1}{1-i k}$\n\t\t\\task[\\textbf{B.}] $\\frac{1}{1+i k}$\n\t\t\\task[\\textbf{C.}] $\\frac{1}{k+i}$\n\t\t\\task[\\textbf{D.}] $\\frac{1}{k-i}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tf(x)&=\\delta(x)+\\sum_{n=1}^{\\infty} \\frac{d^{n}}{d x^{n}} \\delta(x)\\\\&=\\sum_{n=0}^{\\infty} \\frac{d^{n}}{d x^{n}} \\delta(x)=\\sum_{n=0}^{\\infty} \\delta^{(n)}(x)\\\\\n\t\t\\because F[\\delta(x)]&=1 \\Rightarrow F\\left[\\delta^{(n)}(x)\\right]\\\\&=(-i k)^{n} F[\\delta(x)]=(-i k)^{n}\\\\\n\t\t\\because f(x)&=\\sum_{n=0}^{\\infty} \\delta^{(n)}(x)\\\\\n\t\t\\Rightarrow F[f(x)]&=\\sum_{n=0}^{\\infty}(-i k)^{n}=1-i k+(i k)^{2}-(i k)^{3}+\\ldots .\\\\&=\\frac{1}{1-(-i k)}=\\frac{1}{1+i k}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item The Laplace transform of\n\t$$\n\tf(t)=\\left\\{\\begin{array}{cc}\n\t\\frac{t}{T}, & 0<t<T \\\\\n\t1 & t>T\n\t\\end{array}\\right.\n\t$$\n\tis\n\t{\\exyear{NET/JRF(DEC-2016)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $\\frac{-\\left(1-e^{-s T}\\right)}{s^{2} T}$\n\t\t\\task[\\textbf{B.}] $\\frac{\\left(1-e^{-s T}\\right)}{s^{2} T}$\n\t\t\\task[\\textbf{C.}] $\\frac{\\left(1+e^{-s T}\\right)}{s^{2} T}$\n\t\t\\task[\\textbf{D.}] $\\frac{\\left(1-e^{s T}\\right)}{s^{2} T}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{we can write}\n\t\tf(t)&=\\left[u_{0}(t)-u_{T}(t)\\right] \\frac{t}{T}+u_{T}(t)\\\\&=\\left[1-u_{T}(t)\\right] \\frac{t}{T}+u_{T}(t)=\\frac{t}{T}-u_{T}(t) \\frac{t}{T}+u_{T}(t)\n\t\t\\intertext{Hence the transform of $f(t)$ is}\n\t\tL\\{f(t)\\}&=L\\left\\{\\frac{t}{T}\\right\\}-L\\left\\{u_{T}(t)\\left[\\frac{(t-T)+T}{T}\\right]\\right\\}+L\\left\\{u_{T}(t)\\right\\}\\\\\n\t\t&=\\frac{1}{s^{2} T}-\\frac{e^{-s T}}{T}\\left(\\frac{1}{s^{2}}+\\frac{T}{s}\\right)+\\frac{e^{-s T}}{s}=\\frac{1-e^{-s T}}{s^{2} T}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item The Fourier transform $\\int_{-\\infty}^{\\infty} d x f(x) e^{i k x}$ of the function $f(x)=\\frac{1}{x^{2}+2}$ is\n\t{\\exyear{NET/JRF(DEC-2016)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $\\sqrt{2} \\pi e^{-\\sqrt{2}|| \\mid}$\n\t\t\\task[\\textbf{B.}] $\\sqrt{2} \\pi e^{-\\sqrt{2 k}}$\n\t\t\\task[\\textbf{C.}] $\\frac{\\pi}{\\sqrt{2}} e^{-\\sqrt{2 k}}$\n\t\t\\task[\\textbf{D.}] $\\frac{\\pi}{\\sqrt{2}} e^{-\\sqrt{2}|k|}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{Fourier transform of }f(x)&=\\frac{1}{x^{2}+a^{2}}, \\\\ a>0\\text{ is }\\int \\frac{1}{x^{2}+a^{2}} e^{i k x} d x&=\\frac{\\pi}{a} e^{-a|k|}\\\\\n\t\t\\text{Hence }\\int \\frac{1}{x^{2}+a^{2}} e^{i k x} d x&=\\frac{\\pi}{\\sqrt{2}} e^{-\\sqrt{2}|k|}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\t\\item Consider the differential equation $\\frac{d y}{d t}+a y=e^{-b t}$ with the initial condition $y(0)=0$. Then the Laplace transform $Y(s)$ of the solution $y(t)$ is\n\t{\\exyear{NET/JRF(DEC-2017)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $\\frac{1}{(s+a)(s+b)}$\n\t\t\\task[\\textbf{B.}] $\\frac{1}{b(s+a)}$\n\t\t\\task[\\textbf{C.}] $\\frac{1}{a(s+b)}$\n\t\t\\task[\\textbf{D.}] $\\frac{e^{-a}-e^{-b}}{b-a}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{Given }\\frac{d y}{d t}+a y&=e^{-b t}\n\t\t\\intertext{Taking Laplace transform of both sides}\n\t\t\\text{\tWe obtain}\\\\\n\t\tL\\left\\{\\frac{d y}{d t}\\right\\}+a L\\{y(t)\\}&=L\\left\\{e^{-b t}\\right\\} \\Rightarrow s Y(s)-y(0)+a Y(s)=\\frac{1}{s+b}\\\\\n\t\t\\text{Since, }\ty(0)&=0,\\text{ we obtain}\\\\\n\t\t(s+a) Y(s)&=\\frac{1}{s+b} \\Rightarrow Y(s)=\\frac{1}{(s+a)(s+b)}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (A)}\n\t\\end{answer}\n\t\\item  The Fourier transform $\\int_{-\\infty}^{\\infty} d x f(x) e^{i k x}$ of the function $f(x)=e^{-|x|}$\n\t{\\exyear{NET/JRF(JUNE-2018)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $-\\frac{2}{1+k^{2}}$\n\t\t\\task[\\textbf{B.}] $-\\frac{1}{2\\left(1+k^{2}\\right)}$\n\t\t\\task[\\textbf{C.}] $\\frac{2}{1+k^{2}}$\n\t\t\\task[\\textbf{D.}] $\\frac{2}{\\left(2+k^{2}\\right)}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\int_{-\\infty}^{+\\infty} d x e^{-|x|} e^{i k x}&=\\int_{-\\infty}^{+\\infty} d x e^{-|x|} \\cos k x d x\\text{ odd functions in }k x\\text{ vanishes}\\\\\n\t\t\\Rightarrow 2 \\int_{0}^{\\infty} e^{-x} \\cos k x d x&=2 \\frac{e^{-x}}{1+k^{2}}[-\\cos k x+k \\sin k x]_{0}^{\\infty}\\\\\n\t\t\\because \\int e^{a x} \\cos b x d x&=\\frac{e^{a x}}{a^{2}+b^{2}}[a \\cos b x+b \\sin b x]\\\\\n\t\t\\Rightarrow 2 \\int_{0}^{\\infty} e^{-x} \\cos k x d x&=2 \\frac{e^{0}}{1+k^{2}}=\\frac{2}{1+k^{2}}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (C)}\n\t\\end{answer}\n\t\\item The function $f(t)$ is a periodic function of period $2 \\pi$. In the range $(-\\pi, \\pi)$, it equals $e^{-t}$. If $f(t)=\\sum_{-\\infty}^{\\infty} c_{n} e^{\\text {int }}$ denotes its Fourier series expansion, the sum $\\sum_{-\\infty}^{\\infty}\\left|c_{n}\\right|^{2}$ is\n\t{\\exyear{NET/JRF(DEC-2019)}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] 1\n\t\t\\task[\\textbf{B.}] $\\frac{1}{2 \\pi}$\n\t\t\\task[\\textbf{C.}] $\\frac{1}{2 \\pi} \\cosh (2 \\pi)$\n\t\t\\task[\\textbf{D.}]  $\\frac{1}{2 \\pi} \\sinh (2 \\pi)$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tf(t)&=e^{-t} \\quad-\\pi<x<\\pi\\\\\n\t\tf(t)&=\\sum_{-\\infty}^{\\infty} c_{n} e^{\\mathrm{int}}\\\\\n\t\t\\sum_{-\\infty}^{\\infty}\\left|c_{n}\\right|^{2}&=\\frac{1}{2 \\pi} \\int_{-\\pi}^{\\pi} e^{-2 t} d t=\\left.\\frac{1}{2 \\pi} \\cdot \\frac{e^{-2 t}}{-2}\\right|_{-\\pi} ^{\\pi}\\\\&=\\frac{1}{2 \\pi}\\left[\\frac{e^{-2 \\pi}-e^{2 \\pi}}{-2}\\right]=\\frac{1}{2 \\pi} \\sinh 2 \\pi\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\\end{enumerate}\n\\colorlet{ocre1}{ocre!70!}\n\\colorlet{ocrel}{ocre!30!}\n\\setlength\\arrayrulewidth{1pt}\n\\begin{table}[H]\n\t\\centering\n\t\\arrayrulecolor{ocre}\n\t\\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}\n\t\t\\hline\n\t\t\\multicolumn{4}{|c|}{\\textbf{Answer key}}\\\\\\hline\\hline\n\t\t\\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\\\\hline\n\t\t1&\\textbf{B} &2&\\textbf{B}\\\\\\hline \n\t\t3&\\textbf{D} &4&\\textbf{A} \\\\\\hline\n\t\t5&\\textbf{C} &6&\\textbf{B} \\\\\\hline\n\t\t7&\\textbf{B}&8&\\textbf{D}\\\\\\hline\n\t\t9&\\textbf{A}&10&\\textbf{C}\\\\\\hline\n\t\t11&\\textbf{D} &&\\textbf{}\\\\\\hline\n\t\t\n\t\\end{tabular}\n\\end{table}\n\n\\newpage\n\\begin{abox}\n\tPractise Set-2\n\\end{abox}\n\\begin{enumerate}[label=\\color{ocre}\\textbf{\\arabic*.}]\n\t\\item If $f(x)=\\left\\{\\begin{array}{ll}0 & \\text { for } x<3, \\\\ x-3 & \\text { for } x \\geq 3\\end{array}\\right.$ then the Laplace transform of $f(x)$ is\n\t{\\exyear{GATE 2010}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $s^{-2} e^{3 s}$\n\t\t\\task[\\textbf{B.}] $s^{2} e^{3 s}$\n\t\t\\task[\\textbf{C.}] $s^{-2}$\n\t\t\\task[\\textbf{D.}] $s^{-2} e^{-3 s}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL\\{f(x)\\}&=\\int_{0}^{\\infty} e^{-s x} f(x) d x\\\\&=\\int_{0}^{3} e^{-s x} f(x) d x+\\int_{3}^{\\infty} e^{-s x} f(x) d x\\\\&=\\int_{3}^{\\infty}(x-3) e^{-s x} d x\\\\\n\t\tL\\{f(x)\\}&=\\left.(x-3) \\frac{e^{-s x}}{-s}\\right|_{3} ^{\\infty}-\\int_{3}^{\\infty} 1 \\cdot\\left(\\frac{e^{-s x}}{-s}\\right) d x\\\\&=0+\\frac{1}{s} \\int_{3}^{\\infty} e^{-s x} d x\\\\&=\\frac{1}{s}\\left[\\frac{e^{-s x}}{-s}\\right]_{3}^{\\infty}=s^{-2} e^{-3 s}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\t\\item The coefficient of $e^{i k x}$ in the Fourier expansion of $u(x)=A \\sin ^{2}(\\alpha x)$ for $k=-2 \\alpha$ is\n\t{\\exyear{GATE 2017}}\n\t\\begin{tasks}(4)\n\t\t\\task[\\textbf{A.}] $\\frac{A}{4}$\n\t\t\\task[\\textbf{B.}] $\\frac{-A}{4}$\n\t\t\\task[\\textbf{C.}] $\\frac{A}{2}$\n\t\t\\task[\\textbf{D.}] $\\frac{-A}{2}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{\tSince, }\\sin (\\alpha x)&=\\frac{e^{i \\alpha x}-e^{-i \\alpha x}}{2 i} \\Rightarrow \\sin ^{2}(\\alpha x)\\\\&=\\frac{e^{i 2 \\alpha x}-2+e^{-2 i \\alpha x}}{(-4)}\\\\\n\t\t\\text{Since, }2 \\alpha&=-k,\\text{ hence }\\sin ^{2}(\\alpha x)\\\\&=\\frac{e^{-i k x}-2+e^{i k x}}{(-4)}\\\\\n\t\t\\text{Hence, }c_{k}&=\\frac{A}{2 \\pi} \\int_{-\\pi}^{\\pi} \\sin ^{2}(\\alpha x) d x\\\\&=-\\frac{A}{8 \\pi}\\left[\\int_{-\\pi}^{\\pi} e^{-i k x} e^{-i k x} d x-2 \\int_{-\\pi}^{\\pi} e^{-i k x} d x+\\int_{-\\pi}^{\\pi} e^{-i k x} e^{i k x} d x\\right]\\\\\n\t\t&=-\\frac{A}{8 \\pi}\\left[\\int_{-\\pi}^{\\pi} e^{-2 i k x} d x-2 \\int_{-\\pi}^{\\pi} e^{-i k x} d x+\\int_{-\\pi}^{\\pi} d x\\right]\n\t\t\\intertext{The first two integrals are zero and the third integral has the value $2 \\pi$.\n\t\t\tThus,}\n\t\tc_{k}&=-\\frac{A}{8 \\pi}(2 \\pi)=-\\frac{A}{4}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item Given the fundamental constants $\\hbar$ (Planck's constant), $G$ (universal gravitation constant) and $c$ (speed of light), which of the following has dimension of length?\n\t{\\exyear{JEST 2014}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}]$\\sqrt{\\frac{\\hbar G}{c^{3}}}$\n\t\t\\task[\\textbf{B.}] $\\sqrt{\\frac{\\hbar G}{c^{5}}}$\n\t\t\\task[\\textbf{C.}]$\\frac{\\hbar G}{c^{3}}$\n\t\t\\task[\\textbf{D.}] $\\sqrt{\\frac{\\hbar c}{8 \\pi G}}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\left[\\frac{\\left[M L^{2} T^{-1}\\right]\\left[M^{-1} L^{3} T^{-2}\\right]}{L^{3} T^{-3}}\\right]^{\\frac{1}{2}}&=\\left[L^{2}\\right]^{\\frac{1}{2}}=L\\\\\n\t\t\\hbar=\\left[M L^{2} T^{-1}\\right], G=\\frac{g r^{2}}{m}&=\\left[M^{-1} L^{3} T^{-2}\\right]\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (A)}\n\t\\end{answer}\n\t\\item The Fourier transform of the function $\\frac{1}{x^{4}+3 x^{2}+2}$ up to proportionality constant is\n\t{\\exyear{JEST 2017}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}]$\\sqrt{2} \\exp \\left(-k^{2}\\right)-\\exp \\left(-2 k^{2}\\right)$\n\t\t\\task[\\textbf{B.}]$\\sqrt{2} \\exp (-|k|)-\\exp (-\\sqrt{2}|k|)$\n\t\t\\task[\\textbf{C.}]$\\sqrt{2} \\exp (-\\sqrt{|k|})-\\exp (-\\sqrt{2|k|})$\n\t\t\\task[\\textbf{D.}]  $\\sqrt{2} \\exp \\left(-\\sqrt{2} k^{2}\\right)-\\exp \\left(-2 k^{2}\\right)$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tf(x)&=\\frac{1}{\\left(x^{4}+3 x^{2}+2\\right)}=\\frac{1}{\\left(x^{2}+1\\right)}-\\frac{1}{\\left[x^{2}+(\\sqrt{2})^{2}\\right]}\n\t\t\\intertext{Now, Fourier transform of $f(x)$ is,}\n\t\tF(p)&=A \\int_{-\\infty}^{\\infty} f(x) e^{-1 k x} d x\\\\\n\t\t&=A \\int_{-\\infty}^{\\infty}\\left[\\frac{1}{\\left(x^{2}+1\\right)}-\\frac{1}{x^{2}+(\\sqrt{2})^{2}}\\right] e^{-i k x} d x=A\\left[\\int_{-\\infty}^{\\infty} \\frac{1}{\\left(x^{2}+1\\right)} \\times e^{-i k x} d x-\\int_{-\\infty}^{\\infty} \\frac{e^{-i k x}}{x^{2}+(\\sqrt{2})^{2}} d x\\right]\\\\\n\t\t\\because &\\int_{-\\infty}^{\\infty} \\frac{1}{\\left(x^{2}+a^{2}\\right)} e^{-i k x} d x=\\sqrt{\\frac{\\pi}{2}} \\frac{e^{-a|k|}}{a}\\\\\n\t\tF(k)&=A\\left[\\sqrt{\\frac{\\pi}{2}} \\frac{e^{-|k|}}{1}-\\sqrt{\\frac{\\pi}{2}} \\frac{e^{-\\sqrt{2} \\mid k}}{\\sqrt{2}}\\right]=\\frac{A \\sqrt{\\pi}}{2}[\\sqrt{2} \\exp (-|k|)-\\exp (-\\sqrt{2}|k|)]\\\\\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (B)}\n\t\\end{answer}\n\t\\item The function $f(x)=\\cosh x$ which exists in the range $-\\pi \\leq x \\leq \\pi$ is periodically repeated between $x=(2 m-1) \\pi$ and $(2 m+1) \\pi$, where $m=-\\infty$ to $\\infty$. Using Fourier series, indicate the correct relation at $x=0$\n\t{\\exyear{JEST 2017}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\sum_{n=-\\infty}^{\\infty} \\frac{(-1)^{n}}{1-n^{2}}=\\frac{1}{2}\\left(\\frac{\\pi}{\\cosh \\pi}-1\\right)$\n\t\t\\task[\\textbf{B.}]$\\sum_{n=-\\infty}^{\\infty} \\frac{(-1)^{n}}{1-n^{2}}=2 \\frac{\\pi}{\\cosh \\pi}$\n\t\t\\task[\\textbf{C.}]$\\sum_{n=-\\infty}^{\\infty} \\frac{(-1)^{-n}}{1+n^{2}}=2 \\frac{\\pi}{\\sinh \\pi}$\n\t\t\\task[\\textbf{D.}] $\\sum_{n=1}^{\\infty} \\frac{(-1)^{n}}{1+n^{2}}=\\frac{1}{2}\\left(\\frac{\\pi}{\\sinh \\pi}-1\\right)$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tf(x)&=\\cosh x, \\quad-\\pi \\leq x \\leq \\pi\\\\\n\t\t\\text{Here, }a_{0}&=\\frac{1}{2 \\pi} \\int_{-\\pi}^{\\pi} \\cosh x d x=\\frac{1}{2 \\pi}[\\sinh x]_{-\\pi}^{\\pi}=\\frac{\\sinh \\pi}{\\pi}\\\\\n\t\tb_{n}&=0,\\text{ due to even function}\\\\\n\t\t\\text{\tand }a_{n}&=\\frac{1}{2 \\pi} \\int_{-\\pi}^{\\pi}\\left(e^{x}+e^{-x}\\right) \\cos n x d x\\qquad\n\t\t\\left[\\because \\cosh x=\\frac{1}{2}\\left(e^{x}+e^{-x}\\right)\\right]\\\\\n\t\ta_{n}&=\\frac{1}{2 \\pi}\\left[\\frac{e^{x}}{\\left(1+n^{2}\\right)}(\\cos n x+n \\sin n x)+\\frac{e^{-x}}{1+n^{2}}(-\\cos n x+n \\sin n x)\\right]_{-\\pi}^{\\pi}\\\\\n\t\t&=\\frac{1}{2 \\pi}\\left[\\frac{e^{\\pi}(-1)^{n}}{\\left(1+n^{2}\\right)}-\\frac{e^{-\\pi}(-1)^{n}}{\\left(1+n^{2}\\right)}-\\frac{e^{-\\pi}(-1)^{n}}{\\left(1+n^{2}\\right)}+\\frac{e^{\\pi}(-1)^{n}}{\\left(1+n^{2}\\right)}\\right]\\\\&=\\frac{2(-1)^{n} \\cdot 2 \\sinh \\pi}{2 \\pi\\left(1+n^{2}\\right)}=\\frac{2(-1)^{n} \\sinh \\pi}{\\pi\\left(1+n^{2}\\right)}\\\\\n\t\t\\text{\tHence, }f(x)&=a_{0}+\\sum_{n=1}^{\\infty}\\left(a_{n} \\cos n x+b_{n} \\sin n x\\right) \\Rightarrow \\cosh x=\\frac{\\sinh \\pi}{\\pi}+\\sum_{n=1}^{\\infty} \\frac{2(-1)^{n} \\sinh \\pi}{\\pi\\left(1+n^{2}\\right)} \\cos n x\\\\\n\t\t\\text{At }x&=0,\\\\\n\t\t\\sum_{n=1}^{\\infty} \\frac{2(-1)^{n} \\sinh \\pi}{\\pi\\left(1+n^{2}\\right)}&=\\left(1-\\frac{\\sinh \\pi}{\\pi}\\right) \\Rightarrow \\sum_{n=1}^{\\infty} \\frac{(-1)^{n}}{\\left(1+n^{2}\\right)}=\\frac{1}{2}\\left[\\frac{\\pi}{\\sinh \\pi}-1\\right]\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\t\\item The Laplace transform of $\\frac{(\\sin (a t)-a t \\cos (a t))}{\\left(2 a^{3}\\right)}$ is\n\t{\\exyear{JEST 2018}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}]$\\frac{2 a s}{\\left(s^{2}+a^{2}\\right)^{2}}$\n\t\t\\task[\\textbf{B.}]$\\frac{s^{2}-a^{2}}{\\left(s^{2}+a^{2}\\right)^{2}}$\n\t\t\\task[\\textbf{C.}]$\\frac{1}{(s+a)^{2}}$\n\t\t\\task[\\textbf{D.}] $\\frac{1}{\\left(s^{2}+a^{2}\\right)^{2}}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tL\\left\\{\\frac{\\sin a t-a t \\cos a t}{2 a^{3}}\\right\\}=\\frac{1}{\\left(s^{2}+a^{2}\\right)^{2}}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (D)}\n\t\\end{answer}\n\\end{enumerate}\n\\colorlet{ocre1}{ocre!70!}\n\\colorlet{ocrel}{ocre!30!}\n\\setlength\\arrayrulewidth{1pt}\n\\begin{table}[H]\n\t\\centering\n\t\\arrayrulecolor{ocre}\n\t\\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}\n\t\t\\hline\n\t\t\\multicolumn{4}{|c|}{\\textbf{Answer key}}\\\\\\hline\\hline\n\t\t\\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\\\\hline\n\t\t1&\\textbf{D} &2&\\textbf{B}\\\\\\hline \n\t\t3&\\textbf{A} &4&\\textbf{B} \\\\\\hline\n\t\t5&\\textbf{D} &6&\\textbf{D} \\\\\\hline\n\t\t\n\t\\end{tabular}\n\\end{table}", "meta": {"hexsha": "8668095009775fd6ef4103195a1c7556b27dd81b", "size": 18415, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CSIR- Mathematical Physics/chapter/Problem set Solutions Fourier.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CSIR- Mathematical Physics/chapter/Problem set Solutions Fourier.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CSIR- Mathematical Physics/chapter/Problem set Solutions Fourier.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.1671388102, "max_line_length": 332, "alphanum_fraction": 0.5578604399, "num_tokens": 8731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.4249666180119423}}
{"text": "\\section{Refinement Reflection}\n\\label{sec:formalism}\n\\label{sec:types-reflection}\n\\label{sec:refinementreflection:theory}\nNext, we formalize refinement reflection\nvia a core calculus \\corelan.\n%\nWe define a decidable SMT language \\smtlan to approximate the\nhigher order, potentially diverging\ntarget language \\corelan\nand present a decidable and sound type system\nfor \\corelan.\n\n\\subsection{Syntax}\n\\input{text/refinementreflection/syntax}\n%\nFigure~\\ref{fig:syntax} summarizes the syntax of \\corelan,\nwhich is essentially the calculus \\undeclang (from~\\S~\\ref{sec:language})\nwith explicit recursion and a special $\\erefname$ binding\nto denote terms that are reflected into the refinement logic.\n%\nThe elements of \\corelan are layered into\nprimitive constants, values, expressions, binders\nand programs.\n\n\\mypara{Constants}\nThe primitive constants of \\corelan\ninclude all the primitive logical\noperators $\\op$, here, the set $\\{ =, <\\}$.\n%\nMoreover, they include the\nprimitive booleans $\\etrue$, $\\efalse$,\nintegers $\\mathtt{-1}, \\mathtt{0}$, $\\mathtt{1}$, \\etc,\nand logical operators $\\mathtt{\\land}$, $\\mathtt{\\lor}$, $\\mathtt{\\lnot}$, \\etc.\n\n\\mypara{Data Constructors}\n%\nData constructors are special constants.\n% Each data type has an equality predicate $\\haseq{T}$\n% that is true only if values of type $T$ can be finitely compared.\nFor example, the data type \\tintlist, which represents\nfinite lists of integers, has two data constructors: $\\dnull$ (nil)\nand $\\dcons$ (cons).\n\n\\mypara{Values \\& Expressions}\n%\nThe values of \\corelan include\nconstants, $\\lambda$-abstractions\n$\\efun{x}{\\typ}{e}$, and fully\napplied data constructors $D$\nthat wrap values.\n%\nThe expressions of \\corelan\ninclude values, variables $x$,\napplications $\\eapp{e}{e}$, and\n$\\mathtt{case}$ expressions.\n\n\\mypara{Binders \\& Programs}\n%\nA \\emph{binder} $\\bd$ is a series of possibly recursive\n$\\mathtt{let}$ definitions, followed by an expression.\n%\nA \\emph{program} \\prog is a series of $\\erefname$\ndefinitions, each of which names a function\nthat is reflected into the refinement\nlogic, followed by a binder.\n%\nThe stratification of programs via binders\nis required so that arbitrary recursive definitions\nare allowed in the program but cannot be inserted into the logic\nvia refinements or reflection.\n%\n(We \\emph{can} allow non-recursive $\\mathtt{let}$\nbinders in expressions $e$, but omit them for simplicity).\n\n\\subsection{Operational Semantics}\nWe define $\\hookrightarrow$ to be the small step, call-by-name\n$\\beta$-reduction semantics for \\corelan.\n%\nWe evaluate reflected terms %$\\erefb{x}{\\gtyp}{e}{\\prog}$\nas recursive $\\mathtt{let}$ bindings, with extra termination-check\nconstraints imposed by the type system:\n%\n$$\n\\erefb{x}{\\gtyp}{e}{\\prog}\n\\hookrightarrow\n\\eletb{x}{\\gtyp}{e}{\\prog}\n$$\n%\nWe define $\\evalsto{}{}$ to be the reflexive,\ntransitive closure of $\\evals{}{}$.\n%\nMoreover, we define $\\betaeq{}{}$ to be the reflexive,\nsymmetric, and transitive closure of $\\evals{}{}$.\n\n\\mypara{Constants} Application of a constant requires the\nargument be reduced to a value; in a single step, the\nexpression is reduced to the output of the primitive\nconstant operation, \\ie ${c\\ v} \\hookrightarrow \\ceval{c}{v}$.\n%\nFor example, consider $=$, the primitive equality\noperator on integers.\n%\nWe have $\\ceval{=}{n} \\defeq =_n$\nwhere $\\ceval{=_n}{m}$ equals \\etrue\niff $m$ is the same as $n$.\n%\n\n\\mypara{Equality}\nWe assume that the equality operator\nis defined \\emph{for all} values,\nand, for functions, is defined as\nextensional equality.\n%\nThat is, for all\n$f$ and\n$f'$,\n$\\evals{(f = f')}{\\etrue}$\n   $\\mbox{iff}$\n  $\\forall v.\\ \\betaeq{f\\ v}{f'\\ v}$.\n%\nWe assume source \\emph{terms} only contain implementable equalities\nover non-function types; while function extensional equality only appears\nin \\emph{refinements} and is approximated by the underlying logic.\n\n\n\\subsection{Types}\n\n\\corelan types include basic types, which are \\emph{refined} with predicates,\nand dependent function types.\n%\n\\emph{Basic types} \\btyp comprise integers, booleans, and a family of data-types\n$T$ (representing lists, trees \\etc).\n%\nFor example, the data type \\tintlist represents lists of integers.\n%\nWe refine basic types with predicates (boolean-valued expressions \\refa) to obtain\n\\emph{basic refinement types} $\\tref{v}{\\btyp}{\\refa}$.\n%\n%\nWe use \\tlabel to mark provably terminating\ncomputations and use\nrefinements to ensure that if\n${{e}\\text{:}{\\tref{v}{\\btyp^\\tlabel}{\\refa'}}}$,\nthen $e$ terminates (as in chapter~\\ref{chapter:refinedhaskell}).\n%\nFinally, we have dependent \\emph{function types} $\\tfun{x}{\\typ_x}{\\typ}$\nwhere the input $x$ has the type $\\typ_x$ and the output $\\typ$ may\nrefer to the input binder $x$.\n%\nWe write $\\btyp$ to abbreviate $\\tref{v}{\\btyp}{\\etrue}$,\nand \\tfunbasic{\\typ_x}{\\typ} to abbreviate \\tfun{x}{\\typ_x}{\\typ} if\n$x$ does not appear in $\\typ$.\n%\n%We use $r$ to refer to refinements.\n\n\\mypara{Constants}\nFor each constant $c$ we define its type \\constty{c}, \\eg%\n%\n$$\n\\begin{array}{lcl}\n\\constty{3} &\\doteq& \\tref{v}{\\tint}{v = 3}\\\\\n\\constty{+} &\\doteq& \\tfun{\\ttx}{\\tint}{\\tfun{\\tty}{\\tint}{\\tref{v}{\\tint}{v = x + y}}}\\\\\n\\constty{\\leq} &\\doteq& \\tfun{\\ttx}{\\tint}{\\tfun{\\tty}{\\tint}{\\tref{v}{\\tbool}{v \\Leftrightarrow x \\leq y}}}\\\\\n\\end{array}\n$$\n%\n\n\\subsection{Refinement Reflection}\\label{subsec:logicalannotations}\n%\nThe key idea in our work is to\n\\emph{strengthen} the output type of functions\nwith a refinement that \\emph{reflects} the\ndefinition of the function in the logic.\n%\nWe do this by treating each\n%\n$\\erefname$-binder\n%\n(${\\erefb{f}{\\gtyp}{e}{\\prog}}$)\n%\nas a $\\eletname$-binder with a reflected singleton type\n%\n(${\\eletb{f}{\\exacttype{\\gtyp}{e}}{e}{\\prog}}$)\n%\nduring type checking (rule $\\rtreflect$ in Figure~\\ref{fig:typing}).\n\n\\mypara{Reflection}\n%\nWe write \\exacttype{\\typ}{e} for the \\emph{reflection}\nof the term $e$ into the type $\\typ$,  defined by strengthening\n\\typ as:\n%\n$$\n\\begin{array}{lcl}\n\\exacttype{\\tref{v}{\\btyp}{r}}{e}\n  & \\defeq\n  & \\tref{v}{\\btyp}{r \\land v = e}\\\\\n\\exacttype{\\tfun{x}{\\typ_x}{\\typ}}{\\efun{y}{}{e}}\n  & \\defeq\n  & \\tfun{x}{\\typ_x}{\\exacttype{\\typ}{e\\subst{y}{x}}}\n\\end{array}\n$$\n%\nAs an example, recall from \\S~\\ref{sec:refinementreflection:overview}\nthat the @reflect fib@ strengthens the type of\n@fib@ with the refinement @fibP@.\n%% NV In Overview, we have fibP v n = v = fib n && fibR v n\n%% NV Here we get the reflection part (fibR v n)\n%% NV which we can verify\n%% NV at each fix invocation we also get the v = fib n portion\n%% NV via the exact rule\n%% NV We can not add the v = fib n as a port condition, because\n%% NV we cannot prove it.\n\n\n\\mypara{Consequences for Verification}\n%\nReflection has two consequences for verification.\n%\nFirst, the reflected refinement is \\emph{not trusted};\nit is itself verified (as a valid output type)\nduring type checking.\n%\nSecond, instead of being tethered to quantifier\ninstantiation heuristics or having to program\n``triggers'' as in Dafny~\\citep{dafny} or\n\\fstar~\\citep{fstar},\n%\nthe programmer can predictably ``unfold'' the\ndefinition of the function during a proof simply\nby ``calling'' the function, which, as discussed\nin~\\S~\\ref{sec:evaluation}, we have found to be\na very natural way of structuring proofs.\n\n\n\\subsection{The SMT logic \\smtlan}\n\\corelan is a higher order, potentially diverging language\nthat cannot be used for decidable verification.\n%\nNext, we describe \\smtlan, a conservative, first order\napproximation of \\corelan where higher order features are\napproximated with uninterpreted functions,\nyielding an SMT-based\nalgorithmic logic that enjoys soundness and decidability.\n\n\\input{text/refinementreflection/smtsyntax}\n\n\\mypara{Syntax}\n%\nFigure~\\ref{fig:smtsyntax} summarizes the syntax\nof \\smtlan, the \\emph{sorted} (SMT-)\ndecidable logic of quantifier-free equality,\nuninterpreted functions and linear\narithmetic (QF-EUFLIA) ~\\citep{Nelson81,SMTLIB2}.\n%\nThe \\emph{terms} of \\smtlan include\nintegers $n$,\nbooleans $b$,\nvariables $x$,\ndata constructors $\\dc$ (encoded as constants),\nfully applied unary \\unop and binary \\binop operators,\nand application $x\\ \\overline{\\pred}$ of an uninterpreted function $x$.\n%\nThe \\emph{sorts} of \\smtlan include the built-in\n\\tint and \\tbool.\n%\nThe interpreted functions of \\smtlan, \\eg\nthe logical constants $=$ and $<$,\n%% NV and the uninterpreted functions app and lam\n%% NV but we have not introduced these yet\nhave the function sort $\\sort \\rightarrow \\sort$.\n%\nOther functional values in \\corelan, \\eg\nreflected \\corelan functions and\n$\\lambda$-expressions, have the first-order\nuninterpreted sort \\tsmtfun{\\sort}{\\sort}.\n%\nThe universal sort \\tuniv represents all other values.\n\n\\subsection{Transforming \\corelan into \\smtlan}\n%\n\\label{subsec:embedding}\n\n%\\input{defuncrules}\n%\nA \\emph{type environment} $\\env$ is a sequence of type bindings\n$\\tbind{x_1}{\\typ_1},$ $\\ldots,\\tbind{x_n}{\\typ_n}$.\nWe use the type environment to define the judgment\n\\tologicshort{\\env}{e}{\\typ}{\\pred}{\\sort}{\\smtenv}{\\axioms}\nthat transforms a $\\corelan$ term $e$\n% under an environment $\\env$,\ninto a $\\smtlan$ term $\\pred$.\n%\nMost of the transformation rules are identity\nand can be found in~\\cite{vazou16techrep}.\nHere we discuss the non-identity ones.\n\n\\mypara{Embedding Types}\n%\nWe embed \\corelan types into \\smtlan sorts as:\n%\n\\[\n\\begin{array}{rclcrcl}\n\\embed{\\tint}                       & \\defeq &  \\tint & \\quad &\n\\embed{T}                           & \\defeq &  \\tuniv \\\\\n\\embed{\\tbool}                      & \\defeq &  \\tbool & \\quad &\n\\embed{\\tfun{x}{\\typ_x}{\\typ}} & \\defeq & \\tsmtfun{\\embed{\\typ_x}}{\\embed{\\typ}}\n\\end{array}\n\\]\n\n\n\\mypara{Embedding Constants}\n%\nElements shared on both \\corelan and \\smtlan\ntranslate to themselves.\n%\nThese elements include\nbooleans,\nintegers,\nvariables,\nbinary\nand unary\noperators.\n%\nSMT solvers do not support currying,\nand so in \\smtlan, all function symbols\nmust be fully applied.\n%\nThus, we assume that all applications\nto primitive constants and data\nconstructors are fully applied, \\eg by converting\nsource terms like @(+ 1)@ to\n@(\\z -> z+1)@.\n%\n\n\n\\mypara{Embedding Functions}\n%\nAs \\smtlan is a first-order logic, we\nembed $\\lambda$-abstraction\nusing the uninterpreted function\n\\smtlamname{}{}.\n%\n$$\n\\inference{\n    \\tologicshort{\\env, \\tbind{x}{\\typ_x}}{e}{}{\\pred}{}{}{} &\n        \\hastype{\\env}{(\\efun{x}{}{e})}{(\\tfun{x}{\\typ_x}{\\typ})}\\\\\n}{\n\t\\tologicshort{\\env}{\\efun{x}{}{e}}{(\\tfun{x}{\\typ_x}{\\typ})}\n\t        {\\smtlamname{\\embed{\\typ_x}}{\\embed{\\typ}}\\ {x}\\ {\\pred}}\n\t        {\\sort'}{\\smtenv, \\tbind{f}{\\sort'}}{\\andaxioms{\\{\\axioms_{f_1}, \\axioms_{f_2}\\}}{\\axioms}}\n}[\\lgfun]\n$$\n%\nThe term $\\efun{x}{}{e}$ of type\n${\\typ_x \\rightarrow \\typ}$ is transformed\nto\n${\\smtlamname{\\sort_x}{\\sort}\\ x\\ \\pred}$\nof sort\n${\\tsmtfun{\\sort_x}{\\sort}}$, where\n%\n$\\sort_x$ and $\\sort$ are respectively\n$\\embed{\\typ_x}$ and $\\embed{\\typ}$,\n%\n${\\smtlamname{\\sort_x}{\\sort}}$\nis a special uninterpreted function\nof sort\n${\\sort_x \\rightarrow \\sort\\rightarrow\\tsmtfun{\\sort_x}{\\sort}}$,\nand\n$x$ of sort $\\sort_x$ and $r$ of sort $\\sort$ are\nthe embedding of the binder and body, respectively.\n%\nAs $\\smtlamname{}{}$ is an SMT-function,\nit \\emph{does not} create a binding for $x$.\n%\nInstead, $x$ is renamed to\na \\emph{fresh} name pre-declared in\nthe SMT logic.\n\n\n\\mypara{Embedding Applications}\n%\nDually, we embed applications via\ndefunctionalization~\\citep{Reynolds72}\nwith the uninterpreted $\\smtappname{}{}$ function.\n%\n$$\n\\inference{\n\t\\tologicshort{\\env}{e'}{\\typ_x}{\\pred'}{\\embed{\\typ_x}}{\\smtenv}{\\axioms'}\n\t&\n\t\\tologicshort{\\env}{e}{\\tfun{x}{\\typ_x}{\\typ}}{\\pred}{\\tsmtfun{\\embed{\\typ_x}}{\\embed{\\typ}}}{\\smtenv}{\\axioms}\n\t&\n\t\\hastype{\\env}{e}{{\\typ_x}\\rightarrow{\\typ}}\n}{\n\t\\tologicshort{\\env}{e\\ e'}{\\typ}{\\smtappname{\\embed{\\typ_x}}{\\embed{\\typ}}\\ {\\pred}\\ {\\pred'}}{\\embed{\\typ}}{\\smtenv}{\\andaxioms{\\axioms}{\\axioms'}}\n}[\\lgapp]\n$$\n%\nThe term ${e\\ e'}$, where $e$ and $e'$ have\ntypes ${\\typ_x \\rightarrow \\typ}$ and $\\typ_x$,\nis transformed to\n${\\tbind{\\smtappname{\\sort_x}{\\sort}\\ \\pred\\ \\pred'}{\\sort}}$\nwhere\n%\n$\\sort$ and $\\sort_x$ are $\\embed{\\typ}$ and $\\embed{\\typ_x}$,\nthe\n${\\smtappname{\\sort_x}{\\sort}}$\nis a special uninterpreted function of sort\n${\\tsmtfun{\\sort_x}{\\sort} \\rightarrow \\sort_x \\rightarrow \\sort}$,\nand\n$\\pred$ and $\\pred'$ are the respective translations of $e$ and $e'$.\n\n\n\\mypara{Embedding Data Types}\n%\nWe translate each data constructor to a\npredefined \\smtlan constant ${\\smtvar{\\dc}}$ of\nsort ${\\embed{\\constty{\\dc}}}$.\n$$\n\t\\tologicshort{\\env}{\\dc}{\\constty{\\dc}}{\\smtvar{\\dc}}{\\embed{\\constty{\\dc}}}{\\emptyset}{\\emptyaxioms}\n$$\n%\nFor each datatype, we assume the existence of reflected functions that\n\\emph{check} the top-level constructor\nand \\emph{select} their individual fields.\n%\nFor example, for lists, we assume the existence of measures:\n%\n\\begin{mcode}\n  isNil []     = True     isCons (x:xs) = True\n  isNil (x:xs) = False    isCons []     = False\n\n  sel1 (x:xs)  = x        sel2 (x:xs)   = xs\n\\end{mcode}\n%\nDue to the simplicity of their syntax the above checkers and selectors\ncan be automatically instantiated in the logic\n(\\ie without actual calls to the reflected functions at source level)\nusing the measure mechanism (\\S~\\ref{sec:measures}).\n\nTo generalize, let $\\dc_i$ be a data constructor such that\n$$\n\\constty{\\dc_i} \\defeq \\typ_{i,1} \\rightarrow \\dots \\rightarrow \\typ_{i,n} \\rightarrow \\typ\n$$\nThen the \\emph{check function}\n${\\checkdc{{\\dc_i}}}$ has the sort\n$\\tsmtfun{\\embed{\\typ}}{\\tbool}$,\nand the \\emph{select function}\n${\\selector{\\dc}{i,j}}$ has the sort\n$\\tsmtfun{\\embed{\\typ}}{\\embed{\\typ_{i,j}}}$.\n%\n\n\n% \\mypara{Checking and Projection}\n%\nWe translate case-expressions\nof \\corelan into nested $\\mathtt{if}$\nterms in \\smtlan, by using the check\nfunctions in the guards, and the\nselect functions for the binders\nof each case.\n$$\n\\inference{\n\t\\tologicshort{\\env}{e}{\\typ_e}{\\pred}{\\embed{\\typ_e}}{\\smtenv}{\\axioms} &&\n\t\\tologicshort{\\env}{e_i\\subst{\\overline{y_i}}{\\overline{\\selector{\\dc_i}{}\\ x}}\\subst{x}{e}}{\\typ}{\\pred_i}{\\embed{\\typ}}{\\smtenv}{\\axioms_i}\n}{\n\t\\tologicshort{\\env}{\\ecase{x}{e}{\\dc_i}{\\overline{y_i}}{e_i}}{\\typ}\n\t {\\eif{\\smtappname{}{}\\ \\checkdc{\\dc_1}\\ \\pred}{\\pred_1}{\\ldots} \\ \\mathtt{else}\\ \\pred_n}{\\embed{\\typ}}{\\smtenv}\n\t {\\andaxioms{\\axioms}{\\axioms_i}}\n}[\\lgcase]\n$$\n%\nFor example, the body of the list append function\n%\n\\begin{code}\n  []     ++ ys = ys\n  (x:xs) ++ ys = x : (xs ++ ys)\n\\end{code}\n%\nis reflected into the \\smtlan refinement:\n%\n$$\n\\ite{\\mathtt{isNil}\\ \\mathit{xs}}\n    {\\mathit{ys}}\n    {\\mathtt{sel1}\\ \\mathit{xs}\\\n       \\dcons\\\n       (\\mathtt{sel2}\\ \\mathit{xs} \\ \\mathtt{++}\\  \\mathit{ys})}\n$$\n%\nWe favor selectors to the axiomatic translation of\nHALO~\\citep{halo} to avoid\nuniversally quantified formulas and the resulting\ninstantiation unpredictability.\n\n\n\\subsection{Typing Rules}\n\\input{text/refinementreflection/typing}\n%\nNext, we present the\ntyping, well-formedness, and subtyping~\\citep{Knowles10,Vazou14}\nrules of \\corelan.\n\n\\mypara{Typing}\nA judgment \\hastype{\\env}{\\prog}{\\typ} states that\nthe program $\\prog$ has the type $\\typ$ in\nthe environment $\\env$.\nThat is, when the free variables in $\\prog$ are\nbound to expressions described by $\\env$, the\nprogram $\\prog$ will evaluate to a value\ndescribed by $\\typ$.\n\n\\mypara{Rules}\n%\nAll but two of the rules are standard~\\cite{Knowles10,Vazou14}.\n%\nFirst, rule \\rtreflect is used to strengthen the type of each\nreflected binder with its definition, as described previously\nin \\S~\\ref{subsec:logicalannotations}.\n%\nSecond, rule \\rtexact strengthens the expression with\na singleton type equating the value and the expression\n(\\ie reflecting the expression in the type).\n%\nThis is a generalization of the ``selfification'' rules\nfrom \\cite{Ou2004,Knowles10}, and is required to\nequate the reflected functions with their definitions.\n%\nFor example, the application $(\\fib\\ 1)$ is typed as\n${\\tref{v}{\\tint}{\\fibdef\\ v\\ 1 \\wedge v = \\fib\\ 1}}$ where\nthe first conjunct comes from the (reflection-strengthened)\noutput refinement of \\fib~\\S~\\ref{sec:refinementreflection:overview} and\nthe second comes from rule~\\rtexact.\n%\n%%Finally, rule \\rtfix is used to type the intermediate\n%%$\\texttt{fix}$ expressions that appear, not in the\n%%surface language but as intermediate terms in the\n%%operational semantics.\n\n\n\\mypara{Well-formedness}\nA judgment \\iswellformed{\\env}{\\typ} states that\nthe refinement type $\\typ$ is well-formed in\nthe environment $\\env$.\n%\nFollowing chapter~\\ref{chapter:refinedhaskell}, the type $\\typ$ is well-formed if all\nthe refinements in $\\typ$ are $\\tbool$-typed,\nprovably terminating expressions in $\\env$.\n%\n%%\\mypara{Termination}\n%%%\n%%Under arbitrary beta-reduction semantics\n%%(which includes lazy evaluation), soundness\n%%of refinement type checking requires checking\n%%termination, for two reasons:\n%%%\n%%(1)~to ensure that refinements cannot diverge, and\n%%(2)~to account for the environment during subtyping~\\citep{Vazou14}.\n%%%\n%%We use \\tlabel to mark provably terminating\n%%computations, and extend the rules to use\n%%refinements to ensure that if\n%%${\\ahastype{\\env}{e}{\\tref{v}{\\btyp^\\tlabel}{r}}}$,\n%%then $e$ terminates~\\citep{Vazou14}.\n%%%\n\n\\mypara{Subtyping}\nA judgment \\issubtype{\\env}{\\typ_1}{\\typ_2} states\nthat the type $\\typ_1$ is a subtype of %the type\n$\\typ_2$ in the environment $\\env$.\n%\nInformally, $\\typ_1$ is a subtype of $\\typ_2$ if\nthe refinement of $\\typ_1$ \\emph{implies}\nthe refinement of $\\typ_2$\nunder the assumptions described by $\\env$.\n%\nSubtyping of basic types reduces to implication checking.\n\n\\mypara{Verification Conditions}\nThe implication or \\emph{verification condition} (VC)\n${\\vcond{\\env}{\\pred}}$\nis \\emph{valid} only if the set of values\ndescribed by $\\env$, is subsumed by\nthe set of values described by $\\pred$.\n%\n$\\env$ is embedded into logic by conjoining\n(the embeddings of) the refinements of\nprovably terminating binders (Chapter~\\ref{chapter:refinedhaskell}):\n%\n\\begin{align*}\n\\embed{\\env} \\defeq & \\bigwedge_{x \\in \\env} \\embed{\\env, x} \\\\\n\\intertext{where we embed each binder as}\n\\embed{\\env, x} \\defeq & \\begin{cases}\n                           \\pred  & \\text{if } \\env(x)=\\tref{v}{\\btyp^{\\tlabel}}{e},\\\n                                    \\tologicshort{\\env}{e\\subst{v}{x}}{\\btyp}{\\pred}{\\embed{\\btyp}}{\\smtenv}{\\axioms} \\\\\n                           \\etrue & \\text{otherwise}.\n                         \\end{cases}\n\\end{align*}\n\n\nIt is important to note that since \\smtlan\nis carefully restricted to SMT-decidable theories,\nVC checking, and thus type checking of \\corelan, is decidable.\n\n\\subsection{Soundness}\n\nFollowing \\undeclang from chapter~\\ref{chapter:refinedhaskell}, in~\\citep{vazou16techrep}, we show that\nif validity checking respects the axioms of $\\beta$-equivalence,\nthen \\corelan is sound.\n\nWe define the $\\beta$-equivalence axioms on the uninterpreted function\nthat represent $\\lambda$-abstraction (\\smtlamname{}{}) and\nand application (\\smtappname{}{}).\n$$\n\\begin{array}{rcl}\n\\forall x\\ y\\ e. \\smtlamname{}{}\\ x\\ e\n  & = & \\smtlamname{}{}\\ y\\ (e\\subst{x}{y}) \\\\\n\\forall x\\ e_x\\ e. (\\smtappname{}{}\\ (\\smtlamname{}{}\\ x\\ e)\\ e_x)\n  & = &  e\\subst{x}{e_x}\n\\end{array}\n$$\n%\n We prove that when validity checking assumes the $\\beta$-equivalence\n axioms, \\corelan is sound.\n\n\\begin{theorem}{[Soundness of \\corelan]}\\label{thm:safety}\nAssuming the $\\beta$-equivalence axioms,\nif \\hastype{\\emptyset}{\\prog}{\\typ}\n       and $\\evalsto{\\prog}{w}$ then $\\hastype{\\emptyset}{w}{\\typ}$.\n\\end{theorem}\n\nTheorem~\\ref{thm:safety} lets us interpret well typed terminating programs as proofs of\npropositions.\n%\nFor example, in \\S~\\ref{sec:refinementreflection:overview} we verified that\n%\n$\\fibincrname\\text{ :: }{\\tfun{n}{\\tnat}{\\ttref{\\fib{n} \\leq \\fib{(n+1)}}}}$.\n%\nVia soundness of \\corelan, we get runtime monotonicity of @fib@.\n$$\n\\forall n. \\evalsto{0 \\leq n}{\\etrue} \\Rightarrow \\evalsto{\\fib{n} \\leq \\fib{(n+1)}}{\\etrue}\n$$\n% \\section{Algorithmic Verification}\\label{sec:algorithmic}\n\n\\mypara{Approximation of $\\beta$-equivalence}\n%\nThough sound and precise, directly extending the logic with $\\beta$-equivalence axioms\nwould render SMT validity checking undecidable.\n%\nNext, we discuss an incomplete,\nyet decidable, technique that allows the\nuser to manually instantiate the $\\beta$-equivalence axioms\nwhen required for precise typing.\n", "meta": {"hexsha": "376786ecfde78f20913cb4db4c66b9f93cd2ab95", "size": 20319, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinementreflection/shorttheory.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinementreflection/shorttheory.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinementreflection/shorttheory.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 31.0688073394, "max_line_length": 149, "alphanum_fraction": 0.7048575225, "num_tokens": 6317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585844894971, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4249666146058015}}
{"text": "\\documentclass{article}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage[T5]{fontenc}\n\\usepackage[utf8]{inputenc}\n\n% You can use a package 📦 called booktabs \\usepackage{booktabs} for a visually better table.\n\\usepackage{booktabs}\n\n\\graphicspath{ {images/} }\n\n% from begin-latex-in-minutes\n\\usepackage{listings}\n\\usepackage{color}\n\n\\lstdefinestyle{mystyle}{\nkeywordstyle=\\color{magenta},\nbackgroundcolor=\\color{yellow},\ncommentstyle=\\color{green},\nbasicstyle=\\footnotesize,\n}\n\\lstset{style=mystyle}\n\n\\begin{document}\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.25\\textwidth]{mesh}\n    \\caption{a nice plot}\n    \\label{fig:mesh1}\n\\end{figure}\n\nAs you can see in the figure \\ref{fig:mesh1}, the\nfunction grows near 0. Also, in the page \\pageref{fig:mesh1}\nis the same example.\n\n\\begin{itemize}\n  \\item The individual entries are indicated with a black dot, a so-called bullet.\n  \\item The text in the entries may be of any length.\n\\end{itemize}\n\n\\begin{enumerate}\n  \\item This is the first entry in our list\n  \\item The list numbers increase with each entry we add\n\\end{enumerate}\n\nIn physics, the mass-energy equivalence is stated\nby the equation $E=mc^2$, discovered in 1905 by Albert Einstein.\n\nThe mass-energy equivalence is described by the famous equation\n\\[ E=mc^2 \\]\ndiscovered in 1905 by Albert Einstein.\nIn natural units ($c = 1$), the formula expresses the identity\n\\begin{equation}\nE=m\n\\end{equation}\n\n\nSubscripts in math mode are written as $a_b$ and superscripts are written as $a^b$. These can be combined an nested to write expressions such as\n\n\\[ T^{i_1 i_2 \\dots i_p}_{j_1 j_2 \\dots j_q} = T(x^{i_1},\\dots,x^{i_p},e_{j_1},\\dots,e_{j_q}) \\]\n\nWe write integrals using $\\int$ and fractions using $\\frac{a}{b}$. Limits are placed on integrals using superscripts and subscripts:\n\n\\[ \\int_0^1 \\frac{dx}{e^x} =  \\frac{e-1}{e} \\]\n\nLower case Greek letters are written as $\\omega$ $\\delta$ etc. while upper case Greek letters are written as $\\Omega$ $\\Delta$.\n\nMathematical operators are prefixed with a backslash as $\\sin(\\beta)$, $\\cos(\\alpha)$, $\\log(x)$ etc.\n\n\\paragraph{dsfsfsdfds}\nThis is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself\n\n\n\\section{zczxzzcxzx}\nWe begin a section with section and a paragraph with paragraph. You can also add subsection with subsection and subparagraph with subparagraph\n\n\\subsection{zczxcxzcc}\nWe begin a section with section and a paragraph with paragraph. You can also add subsection with subsection and subparagraph with subparagraph\nxcvcxvcxv\n\nHi let me introduce myself\\footnote{\\label{myfootnote}Hello footnote}.\n... (later on)\n\nI'm referring to myself \\ref{myfootnote}.\n\n\\begin{table}[h!]\n  \\centering\n  \\caption{Caption for the table.}\n  \\label{tab:table1}\n\n  \\begin{tabular}{|l|c|||r|}\n    \\hline\n    1 sadfsd sdfsf sfds & 2 sdfds dsfd sdf sdf & asdasd asd asdaad adaa 3\\\\\n    \\hline\n    a & b xcv dfd dsf sdfsd & ada adsdc\\\\\n    \\hline\n  \\end{tabular}\n\n\\end{table}\n\n\n\\paragraph{dsfsfsdfds}\nThis is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself\n\n\\paragraph{dsfsfsdfds}\nThis is a paragraph. Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself Hi let me introduce myself\n\n\\begin{figure}[h]\n  % \\includegraphics[width=\\linewidth]{mesh.png}\n  \\includegraphics[width=0.25\\linewidth]{mesh.png}\n  \\caption{What is it about?}\n  \\label{fig:whateverlabel}\n\\end{figure}\n\n\\begin{verbatim}\n  #include <iostream>\n\n  int main()\n  {\n    std::cout << \"hello world!\\n\";\n    return 0;\n  }\n\\end{verbatim}\n\n\\begin{lstlisting}[language=Python]\n\n  print \"Hello World!\"\n\n\\end{lstlisting}\n\n\n\nLorem ipsum dolor sit amet \\lstinline{print \"Hello World\"} , consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\n\\input{part2}\n\n\n\\end{document}", "meta": {"hexsha": "35f30e8ddc336b355862844dbef9a82d1e0f123e", "size": 4396, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_learning/part1.tex", "max_stars_repo_name": "mariandumitrascu/my-latexcv", "max_stars_repo_head_hexsha": "30b8aface8936ee326417d2a54c9ce7c4f67bc04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_learning/part1.tex", "max_issues_repo_name": "mariandumitrascu/my-latexcv", "max_issues_repo_head_hexsha": "30b8aface8936ee326417d2a54c9ce7c4f67bc04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_learning/part1.tex", "max_forks_repo_name": "mariandumitrascu/my-latexcv", "max_forks_repo_head_hexsha": "30b8aface8936ee326417d2a54c9ce7c4f67bc04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4, "max_line_length": 478, "alphanum_fraction": 0.746132848, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4249111580202287}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{hyperref}\n\\usepackage{amsmath,amssymb,amsthm}\n\n\\theoremstyle{plain}\n\\newtheorem{result}{Result}[section]\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\n\\newcommand{\\GF}{\\operatorname{GF}}\n\n\\title{DammSum: efficient mnemonic seeds from quasigroup checksums}\n\\author{Cypher Stack \\\\ for Slaz Labs}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThis technical note describes DammSum, a method for producing digital asset mnemonic seed checksums that are robust against all single substitutions and transpositions.\nThe method uses an optimization of the Damm algorithm to produce and validate checksums efficiently, in particular without requiring elementwise construction of a required quasigroup and its associated Cayley table.\n\\end{abstract}\n\nThis document describes technical information relevant to mnemonic seed generation in digital assets.\nIt has not been independently reviewed, and may contain errors.\nThe author asserts no warranty and disclaims liability for its use.\nThe author further expresses no endorsement of Slaz Labs or its associated entities.\n\n\n\\section{Introduction}\n\nMany digital asset projects and protocols support the use of mnemonic seeds to generate keys in common client applications.\nAt its core, a mnemonic seed is simply a mapping between a given list of words and a corresponding bit string; depending on the method used, this bit string is used to produce keys, either directly or using a pseudorandom function like a hash function or key derivation function.\n\nMnemonic seeds are useful precisely because they are designed for use by humans, as they can be easily written down, spoken by voice, typed into wallet software, or otherwise securely stored using physical media.\nHowever, this poses challenges:\n\\begin{itemize}\n\t\\item What happens if the user communicates the seed over a noisy channel, and one or more words are substituted with others?\n\t\\item What happens if the user reads the seed incorrectly, and one or more words are transposed?\n\t\\item What happens if the user stores the seed incorrectly, and it is truncated when later read?\n\\end{itemize}\n\nOne mitigation to these and related challenges is to introduce a checksum to the seed phrase.\nWhen generating a seed, client software first uses suitable randomness to produce the bitstring intended for use in key generation.\nIt then maps the bitstring to the mnemonic seed using a given word list.\nFinally, it produces the checksum, which (depending on the method used) is typically prepended or appended to the seed.\nWhen later communicating or using the seed, client software ensures that the checksum is valid for the given seed.\n\nWhen considering designs for checksums, we consider two important concepts from coding theory relating to errors: detection and correction.\nA design that detects errors is intended to alert the user that some particular type of transmission error occurred, and that the seed is invalid.\nA design that corrects errors can do more, identifying the (ideally unique) valid seed to which the errors were applied.\nDifferent constructions provide varying degrees of error detection and correction.\n\nIn this technical note, we describe a checksum design called DammSum that has the following properties:\n\\begin{itemize}\n\t\\item The checksum design is compatible with the common Electrum word set used in many digital asset projects.\n\t\\item The checksum is a single word, regardless of the length of the seed.\n\t\\item All erasure errors are detected.\n\t\\item All single substitution errors are detected.\n\t\\item All single adjacent transpositions, including transposition of the checksum itself, are detected.\n\t\\item Computation and verification of a checksum is efficient, with no lookup tables or complex computations required.\n\\end{itemize}\n\nWhile error detection is useful, this design does not permit unique correction of substitution, transposition, or erasure errors.\n\n\n\\section{Mathematical background}\n\nIn a dissertation \\cite{damm_thesis} and related papers \\cite{damm2000,damm2007}, Damm notes the applicability of group structures to check digits, in particular observing that while the use of a group operation on antisymmetric permutation compositions can always detect single substitutions, it is limited in detection of adjacent transpositions based on the order of the group.\nIt is shown that replacement of the general group structure with at least a weakly totally antisymmetric quasigroup removes this limitation, such that a checksum construction based on this structure reliably and provably detects single substitutions and adjacent transpositions.\n\nThis observation then reduces the problem of checksum design to construction of weakly totally antisymmetric quasigroups of the required order, as well as optimizations for evaluation of the quasigroup operation on each digit of the seed.\n\nFor completeness, we define quasigroups, the weakly totally antisymmetric and totally antisymmetric properties, and the Damm algorithm, but refer the reader to \\cite{damm_thesis,damm2000,damm2007} for a more complete treatment.\n\n\n\\subsection{Quasigroups and asymmetry}\n\n\\begin{definition}\n\tA \\textit{quasigroup} $(G,\\star)$ is a set $G \\neq \\emptyset$ closed under a binary operation $\\star$ such that for all $a,b \\in G$ there exist unique $x,y \\in G$ such that $a \\star x = b$ and $y \\star a = b$.\n\\end{definition}\n\nFor the Damm algorithm, we will consider finite quasigroups, where the definition implies the usual cancellation laws.\n\n\\begin{definition}\n\tA quasigroup $(G,\\star)$ is \\textit{weakly totally antisymmetric} if for all $c,x,y \\in G$, if $(c \\star x) \\star y = (c \\star y) \\star x$, then $x = y$.\n\\end{definition}\n\n\\begin{definition}\n\tA quasigroup $(G,\\star)$ is \\textit{totally antisymmetric} if it is weakly totally antisymmetric and $x \\star y = y \\star x$ implies $x = y$ for all $x,y \\in G$.\n\\end{definition}\n\nThe paper \\cite{damm2007} proves that there exist totally antisymmetric quasigroups of order $n$ for all $n \\not\\in \\{2,6\\}$, and that there exists a weakly totally antisymmetric quasigroup of order $n$ if and only if there exists a totally antisymmetric quasigroup of order $n$.\n\nFor the specific DammSum construction we describe later, the following additional results from \\cite{damm2007} will be useful.\n\n\\begin{result}\n\t\\label{result:gf_is_ta}\n\tLet $k > 1$ be an integer, and let $G = \\GF(2^k)$ be the Galois field with $2^k$ elements.\n\tLet $a \\in G$ such that $a \\not\\in \\{0,1\\}$, and define the binary operation $\\star$ such that $x \\star y = ax + y$ for all $x,y \\in G$.\n\tThen $(G,\\star)$ is a totally antisymmetric quasigroup.\n\\end{result}\n\n\\begin{result}\n\t\\label{result:permute_wta}\n\tLet $(G,\\star)$ be a totally antisymmetric quasigroup, and let $\\beta: G \\to G$ be a permutation of the elements of $G$.\n\tDefine a binary operation $\\star'$ on $G$ such that for all $x,y \\in G$, we have $x \\star' y = x \\star \\beta(y)$.\n\tThen $(G,\\star')$ is a weakly totally antisymmetric quasigroup.\n\\end{result}\n\nWe now prove that a particular construction over a Galois field is a weakly totally antisymmetric quasigroup.\n\n\\begin{result}\n\t\\label{result:wta}\n\tLet $k > 1$ be an integer, and let $G = \\GF(2^k)$ be the Galois field with $2^k$ elements.\n\tDefine a binary operation $\\star'$ on $G$ such that for $x,y \\in G$ we have $x \\star' y = 2 \\cdot (x + y)$.\n\tThen $(G,\\star')$ is a weakly totally antisymmetric quasigroup.\n\\end{result}\n\n\\begin{proof}\n\tDefine a binary operation $\\star$ on $G = \\GF(2^k)$ such that $x \\star y = 2 \\cdot x + y$ for all $x,y \\in G$; then by Result \\ref{result:gf_is_ta}, $(G,\\star)$ is a totally antisymmetric quasigroup.\n\n\tLet $\\beta: G \\to G$ be a permutation on $G$ defined such that $\\beta(x) = 2 \\cdot x$ for all $x \\in G$.\n\tThen for all $x,y \\in G$ we have\n\t\\begin{alignat*}{1}\n\t\tx \\star' y &= 2 \\cdot (x + y) \\\\\n\t\t&= 2 \\cdot x + 2 \\cdot y \\\\\n\t\t&= 2 \\cdot x + \\beta(y) \\\\\n\t\t&= x \\star \\beta(y)\n\t\\end{alignat*}\n\tResult \\ref{result:permute_wta} implies that $(G,\\star')$ is weakly totally antisymmetric.\n\\end{proof}\nNote that by construction, $x \\star' x = 0$ for all $x \\in G$.\n\n\\subsection{Damm algorithm}\n\nWe now define the Damm algorithm, which produces a checksum that provably detects single substitutions and adjacent transpositions.\nThe algorithm requires a finite weakly totally antisymmetric quasigroup $(G,\\star)$ of order $n$, where for notational convenience we denote $G = \\{0,1,\\ldots,n-1\\}$.\nFor optimization purposes, it further requires that $x \\star x = 0$ for all $x \\in G$ (the element $0$ is arbitrary and denoted as such for convenience); this is equivalent to asserting that the diagonal of the Cayley table for $G$ contain only this element.\n\nLet $w = d_m | d_{m-1} | \\cdots | d_1$ be an $m$-digit word formed by concatenating the digits $\\{d_i\\}_{i=1}^m$, where $d_i \\in G$ for all $i \\in [1,m]$ and $m > 0$.\nDefine the checksum of $w$ to be the digit $d_0$ such that the equation\n$$(\\cdots((d_m \\star d_{m-1}) \\star d_{m-2}) \\star \\cdots \\star d_1) \\star d_0 = 0$$\nholds.\nObserve that because we require $x \\star x = 0$ for all $x \\in G$, we may simplify the above equation by defining \n$$d_0 = (\\cdots((d_m \\star d_{m-1}) \\star d_{m-2}) \\star \\cdots \\star d_1)$$\nand using the former equation as verification of the checksum $d_0$.\n\nBecause $(G,\\star)$ is a weakly totally antisymmetric quasigroup, any single substitution or transposition is detected.\n\n\n\\section{DammSum}\n\nWe now describe the construction of DammSum, a method for efficiently producing Damm-based checksums for digital asset mnemonic seed phrases.\n\nLet $k = 11$, so $2^k = 2^{11} = 2048$.\nLet $m = 12$.\nLet $G = \\GF(2^k)$, and define the binary operation $\\star'$ on $G$ such that $x \\star' y = 2 \\cdot (x + y)$ for all $x,y \\in G$.\n\nGeneration of a DammSum seed proceeds as follows:\n\\begin{enumerate}\n\t\\item For $i \\in [1,m]$, sample a digit $d_i \\in G$ uniformly at random, and let $w = d_m | d_{m-1} | \\cdots | d_1$.\n\t\\item Compute $d_0 = (\\cdots((d_m \\star' d_{m-1}) \\star' d_{m-2}) \\star' \\cdots \\star' d_1)$.\n\t\\item For each $i \\in [0,m]$, let $D_i$ be the English word from the Electrum word list corresponding to $d_i$.\n\t\\item Output the seed $D_m | D_{m-1} | \\cdots | D_1 | D_0$.\n\\end{enumerate}\n\nTo verify a DammSum seed has the correct checksum:\n\\begin{enumerate}\n\t\\item For each $i \\in [0,m]$, let $d_i$ be the element of $\\GF(2^k)$ corresponding to $D_i$.\n\t\\item If the equation\n\t$$(\\cdots((d_m \\star' d_{m-1}) \\star' d_{m-2}) \\star' \\cdots \\star' d_1) \\star' d_0 = 0$$\n\tholds, then verification succeeds; otherwise, it fails.\n\\end{enumerate}\n\nThe above construction meets the requirements of the Damm algorithm by Result \\ref{result:wta}.\nFurther, a seed generated in this manner has $\\log_2\\left((2^{11})^{12}\\right) = 132$ bits of entropy.\n\n\n\\section{Implementation}\n\nWe can implement DammSum efficiently, and note here how to do so.\n\nConsider a representation of $\\GF(2^k)$ as the set of binary-valued polynomials of degree at most $k-1$, reduced by an arbitrary monic irreducible binary-valued polynomial $f$ of degree exactly $k$.\nWhile all choices of $f$ are valid, for efficiency we seek a polynomial of low weight.\nFor our purpose, we use the table in \\cite{hp}, which lists $f(x) = x^{11} + x^2 + 1$.\n\nIn order to compute the checksum for a seed, we must compute quantities of the form $2 \\cdot (x + y)$ in $\\GF(2^k)$.\nThe sum $x + y$ is simply the bitwise \\texttt{XOR} of the binary representations of $x$ and $y$, which is trivial to compute.\n\nIn order to compute the multiplication of the sum $x + y$ by $2$, it suffices to perform a bitwise left shift of $x + y$ and, if the result has the $k$ bit set, \\texttt{XOR} this result with the binary representation of $f(2) = 2053$.\n\nWe then iterate this process over each digit in the seed to produce the checksum.\n\n\n\\section{Observations}\n\nWe note that while computation and verification of DammSum checksums is extremely efficient and can detect single substitution and transposition errors, it cannot uniquely correct them in all cases.\n\nIn order to provide robust and flexible error correction, a design based on constructions like Bose-Chaudhuri-Hocquenghem codes \\cite{hocquenghem,bose} is recommended; however, such constructions are generally more complex and marginally less efficient.\n\n\n\\bibliographystyle{plain}\n\\bibliography{main}\n\n\n\\end{document}\n", "meta": {"hexsha": "632ed191ceb14a41c58083f85f40e844e3f9ebbf", "size": 12423, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "AaronFeickert/dammsum", "max_stars_repo_head_hexsha": "05e8694d04b6236564e75e0ccfb0f3addcfa15e7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "AaronFeickert/dammsum", "max_issues_repo_head_hexsha": "05e8694d04b6236564e75e0ccfb0f3addcfa15e7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "AaronFeickert/dammsum", "max_forks_repo_head_hexsha": "05e8694d04b6236564e75e0ccfb0f3addcfa15e7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-30T18:11:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T18:11:05.000Z", "avg_line_length": 58.8767772512, "max_line_length": 380, "alphanum_fraction": 0.7508653304, "num_tokens": 3331, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.42488718665941977}}
{"text": "\\section{Factorial designs: Round 2}\n\nDesigns with more than one independent variable refer to designs where\nthe experimenter manipulates at least two independent variables.\nConsider the light-switch example from the previous chapter. Imagine you\nare trying to figure out which of two light switches turns on a light.\nThe dependent variable is the light (we measure whether it is on or\noff). The first independent variable is light switch \\#1, and it has two\nlevels, up or down. The second independent variable is light switch \\#2,\nand it also has two levels, up or down. When there are two independent\nvariables, each with two levels, there are four total conditions that\ncan be tested. We can describe these four conditions in a 2x2 table.\n\n\\begin{longtable}[]{@{}ccc@{}}\n\\toprule\n& Switch 1 Up & Switch 1 Down\\tabularnewline\n\\midrule\n\\endhead\nSwitch 2 Up & Light ? & Light ?\\tabularnewline\nSwitch 2 Down & Light ? & Light ?\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nThis kind of design has a special property that makes it a factorial\ndesign. That is, the levels of each independent variable are each\nmanipulated across the levels of the other indpendent variable. In other\nwords, we manipulate whether switch \\#1 is up or down when switch \\#2 is\nup, and when switch numebr \\#2 is down. Another term for this property\nof factorial designs is ``fully-crossed''.\n\nIt is possible to conduct experiments with more than independent\nvariable that are not fully-crossed, or factorial designs. This would\nmean that each of the levels of one independent variable are not\nnecessarilly manipulated for each of the levels of the other independent\nvariables. These kinds of designs are sometimes called unbalanced\ndesigns, and they are not as common as fully-factorial designs. An\nexample, of an unbalanced design would be the following design with only\n3 conditions:\n\n\\begin{longtable}[]{@{}ccc@{}}\n\\toprule\n& Switch 1 Up & Switch 1 Down\\tabularnewline\n\\midrule\n\\endhead\nSwitch 2 Up & Light ? & Light ?\\tabularnewline\nSwitch 2 Down & Light ? & NOT MEASURED\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nFactorial designs are often described using notation such as AXB, where\nA= the number of levels for the first independent variable, and B = the\nnumber of levels for the second independent variable. The fully-crossed\nversion of the 2-light switch experiment would be called a 2x2 factorial\ndesign. This notation is convenient because by multiplying the numbers\nin the equation we can find the number of conditions in the design. For\nexample 2x2 = 4 conditions.\n\nMore complicated factorial designs have more indepdent variables and\nmore levels. We use the same notation describe these designs. The number\nfor each variable represents the number of levels for that variable, and\nthe number of numbers in the equation represents the number of\nvariables. So, a 2x2x2 design has three independent variables, and each\none has 2 levels, for a total of 2x2x2=6 conditions. A 3x3 design has\ntwo independent variables, each with three levels, for a total of 9\nconditions. Designs can get very complicated, such as a 5x3x6x2x7\nexperiment, with five independent variables, each with differing numbers\nof levels, for a total of 1260 conditions. If you are considering a\ncomplicated design like that one, you should consider how to simplify\nit.\n\n\\subsection{2x2 Factorial designs}\\label{x2-factorial-designs}\n\nFor simplicity, we will focus mainly on 2x2 factorial designs. As with\nsimple designs with only one independent variable, factorial designs\nhave the same basic empirical question. Did the manipulation cause a\nchange in the measurement? However, 2x2 designs have more than one\nmanipulation, so there is more than one way that a change in measurement\ncan be observed. So, we end up asking the basic empirical question more\nthan once.\n\nMore specifically, the analysis of factorial designs are split into two\nparts: main effects and interactions. Main effects are occur when the\nlevels of one independent variable cause a change in the dependent\nvariable. In a 2x2 design, there are two independent variables, so there\nare two possible main effects: the main effect of independent variable\n1, and the main effect of independent variable 2. An interaction occurs\nwhen the effect of one independent variable \\emph{depends} on the levels\nof the other independent variable. My experience in teaching the concept\nof main effects and interactions is that they are confusing. So, I\nexpect that these definitions will not be very helpful, and although\nthey are clear and precise, they only become helpful as definitions\nafter you understand the concepts\\ldots{}so they are not useful for\nexplaining the concepts. To explain the concepts we will go through\nseveral different kinds of examples.\n\nTo briefly add to the confusion, or perhaps to illustrate why these two\nconcepts can be confusing, we will look at the eight possible outcomes\nthat could occur in a 2x2 factorial experiment.\n\n\\begin{longtable}[]{@{}cccc@{}}\n\\toprule\nPossible outcome & IV1 main effect & IV2 main effect &\nInteraction\\tabularnewline\n\\midrule\n\\endhead\n1 & yes & yes & yes\\tabularnewline\n2 & yes & no & yes\\tabularnewline\n3 & no & yes & yes\\tabularnewline\n4 & no & no & yes\\tabularnewline\n5 & yes & yes & no\\tabularnewline\n6 & yes & no & no\\tabularnewline\n7 & no & yes & no\\tabularnewline\n8 & no & no & no\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nIn the table, a yes means that there was statistically significant\ndifference for one of the main effects or interaction, and a no means\nthat there was not a statisically significant difference. As you can\nsee, just by adding one more independent variable, the number of\npossible outcomes quickly become more complicated. When you conduct a\n2x2 design, the task for analysis is to determine which of the 8\npossibilites occured, and then explain the patterns for each of the\neffects that occurred. That's a lot of explaining to do.\n\n\\subsection{Main effects}\\label{main-effects}\n\nMain effects occur when the levels of an independent variable cause\nchange in the measurement or dependent variable. There is one possible\nmain effect for each independent variable in the design. When we find\nthat independent variable did cause change, then we say there was a main\neffect. When we find that the independent variable did not cause change,\nthen we say there was no main effect.\n\nThe simplest way to understand a main effect is to pretend that the\nother independent variables do not exist. If you do this, then you\nsimply have a single-factor design, and you are asking whether that\nsingle factor caused change in the measurement. For a 2x2 experiment,\nyou do this twice, once for each independent variable.\n\nLet's consider a silly example to illustrate an important property of\nmain effects. In this experiment the dependent variable will be height\nin inches. The independent variables will be shoes and hats. The shoes\nindependent variable will have two levels: wearing shoes vs.~no shoes.\nThe hats independent variable will have two levels: wearing a hat\nvs.~not wearing a hat. The experiment will provide the shoes and hats.\nThe shoes add 1 inch to a person's height, and the hats add 6 inches to\na person's height. Further imagine that we conduct a within-subjects\ndesign, so we measure each person's height in each of the fours\nconditions. Before we look at some example data, the findings from this\nexperiment should be pretty obvious. People will be 1 inch taller when\nthey wear shoes, and 6 inches taller when they where a hat. We see this\nin the example data from 10 subjects presented below:\n\n\\begin{longtable}[]{@{}rrrr@{}}\n\\toprule\nNoShoes\\_NoHat & Shoes\\_NoHat & NoShoes\\_Hat & Shoes\\_Hat\\tabularnewline\n\\midrule\n\\endhead\n56 & 57 & 62 & 63\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n58 & 59 & 64 & 65\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n58 & 59 & 64 & 65\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n57 & 58 & 63 & 64\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nThe mean heights in each condition are:\n\n\\begin{longtable}[]{@{}lr@{}}\n\\toprule\nNoShoes\\_NoHat & 57.1\\tabularnewline\nShoes\\_NoHat & 58.1\\tabularnewline\nNoShoes\\_Hat & 63.1\\tabularnewline\nShoes\\_Hat & 64.1\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nTo find the main effect of the shoes manipulation we want to find the\nmean height in the no shoes condition, and compare it to the mean height\nof the shoes condition. To do this, we \\emph{collapse}, or average over\nthe observations in the hat conditions. For example, looking only at the\nno shoes vs.~shoes conditions we see the following averages for each\nsubject.\n\n\\begin{longtable}[]{@{}rr@{}}\n\\toprule\nNoShoes & Shoes\\tabularnewline\n\\midrule\n\\endhead\n59 & 60\\tabularnewline\n60 & 61\\tabularnewline\n61 & 62\\tabularnewline\n60 & 61\\tabularnewline\n60 & 61\\tabularnewline\n60 & 61\\tabularnewline\n61 & 62\\tabularnewline\n60 & 61\\tabularnewline\n60 & 61\\tabularnewline\n60 & 61\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nThe group means are:\n\n\\begin{longtable}[]{@{}lr@{}}\n\\toprule\nNoShoes & 60.1\\tabularnewline\nShoes & 61.1\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nAs expected, we see that the average height is 1 inch taller when\nsubjects wear shoes vs.~do not wear shoes. So, the main effect of\nwearing shoes is to add 1 inch to a person's height.\n\nWe can do the very same thing to find the main effect of hats. Except in\nthis case, we find the average heights in the no hat vs.~hat conditions\nby averaging over the shoe variable.\n\n\\begin{longtable}[]{@{}rr@{}}\n\\toprule\nNoHat & Hat\\tabularnewline\n\\midrule\n\\endhead\n56.5 & 62.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n58.5 & 64.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n58.5 & 64.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n57.5 & 63.5\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nThe group means are:\n\n\\begin{longtable}[]{@{}lr@{}}\n\\toprule\nNoHat & 57.6\\tabularnewline\nHat & 63.6\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nAs expected, we the average height is 6 inches taller when the subjects\nwear a hat vs.~do not wear a hat. So, the main effect of wearing hats is\nto add 1 inch to a person's height.\n\nInstead of using tables to show the data, let's use some bar graphs.\nFirst, we will plot the average heights in all four conditions.\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-7-1}\n\nSome questions to ask yourself are 1) can you identify the main effect\nof wearing shoes in the figure, and 2) can you identify the main effet\nof wearing hats in the figure. Both of these main effects can be seen in\nthe figure, but they aren't fully clear. You have to do some visual\naveraging.\n\nPerhaps the most clear is the main effect of wearing a hat. The red bars\nshow the conditions where people wear hats, and the green bars show the\nconditions where people do not wear hats. For both levels of the wearing\nshoes variable, the red bars are higher than the green bars. That is\neasy enough to see. More specifically, in both cases, wearing a hat adds\nexactly 6 inches to the height, no more no less.\n\nLess clear is the main effect of wearing shoes. This is less clear\nbecause the effect is smaller so it is harder to see. How to find it?\nYou can look at the red bars first and see that the red bar for\nno\\_shoes is slightly smaller than the red bar for shoes. The same is\ntrue for the green bars. The green bar for no\\_shoes is slightly smaller\nthan the green bar for shoes.\n\n\\begin{figure}\n\\includegraphics[width=.5\\linewidth]{Factorial_files/figure-latex/unnamed-chunk-8-1} \\end{figure}\n\n\\begin{figure}\n\\includegraphics[width=.5\\linewidth]{Factorial_files/figure-latex/unnamed-chunk-8-2} \\end{figure}\n\nData from 2x2 designs is often present in graphs like the one above. An\nadvantage of these graphs is that they display means in all four\nconditions of the design. However, they do not clearly show the two main\neffects. Someone looking at this graph alone would have to guesstimate\nthe main effects. Or, in addition to the main effects, a researcher\ncould present two more graphs, one for each main effect (however, in\npractice this is not commonly done because it takes up space in a\njournal article, and with practice it becomes second nature to ``see''\nthe presence or absence of main effects in graphs showing all of the\nconditions). If we made a separate graph for the main effect of shoes we\nshould see a difference of 1 inch between conditions. Similarly, if we\nmade a separate graph for the main effect of hats then we should see a\ndifference of 6 between conditions. Examples of both of those graphs\nappear in the margin.\n\nWhy have we been talking about shoes and hats? These independent\nvariables are good examples of variables that are truly independent from\none another. Neither one influences the other. For example, shoes with a\n1 inch sole will always add 1 inch to a person's height. This will be\ntrue no matter whether they wear a hat or not, and no matter how tall\nthe hat is. In other words, the effect of wearing a shoe does not depend\non wearing a hat. More formally, this means that the shoe and hat\nindependent variables do not interact. It would be very strange if they\ndid interact. It would mean that the effect of wearing a shoe on height\nwould depend on wearing a hat. This does not happen in our universe. But\nin some other imaginary universe, it could mean, for example, that\nwearing a shoe adds 1 to your height when you do not wear a hat, but\nadds more than 1 inch (or less than 1 inch) when you do wear a hat. This\nthought experiment will be our entry point into discussing interactions.\nA take-home message before we begin is that some independent variables\n(like shoes and hats) do not interact; however, there are many other\nindependent variables that do.\n\n\\subsection{Interactions}\\label{interactions}\n\nInteractions occur when the effect of an independent variable depends on\nthe levels of the other independent variable. As we discussed above,\nsome independent variables are independent from one another and will not\nproduce interactions. However, other combinations of independent\nvariables are not independent from one another and they produce\ninteractions. Remember, independent variables are always manipulated\nindependently from the measured variable (see margin note), but they are\nnot necessarilly independent from each other.\n\n\\begin{marginfigure}\nThese ideas can be confusing if you think that the word ``independent''\nrefers to the relationship between independent variables. However, the\nterm ``independent variable'' refers to the relationship between the\nmanipulated variable and the measured variable. Remember, ``independent\nvariables'' are manipulated independently from the measured variable.\nSpecifically, the levels of any independent variable do not change\nbecause we take measurements. Instead, the experimenter changes the\nlevels of the independent variable and then observes possible changes in\nthe measures.\n\\end{marginfigure}\n\nThere are many simple examples of two independent variables being\ndependent on one another to produce an outcome. Consider driving a car.\nThe dependent variable (outcome that is measured) could be how far the\ncar can drive in 1 minute. Independent variable 1 could be gas (has gas\nvs.~no gas). Independent variable 2 could be keys (has keys vs.~no\nkeys). This is a 2x2 design, with four conditions.\n\n\\begin{longtable}[]{@{}ccc@{}}\n\\toprule\n& Gas & No Gas\\tabularnewline\n\\midrule\n\\endhead\nKeys & can drive & x\\tabularnewline\nNo Keys & x & x\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\nImportantly, the effect of the gas variable on driving depends on the\nlevels of having a key. Or, to state it in reverse, the effect of the\nkey variable on driving depends on the levesl of the gas variable.\nFinally, in plain english. You need the keys and gas to drive.\nOtherwise, there is no driving.\n\n\\subsection{What makes a people\nhangry?}\\label{what-makes-a-people-hangry}\n\nTo continue with more examples, let's consider an imaginary experiment\nexamining what makes people hangry. You may have been hangry before.\nIt's when you become highly irritated and angry because you are very\nhungry\\ldots{}hangry. I will propose an experiment to measure conditions\nthat are required to produce hangriness. The pretend experiment will\nmeasure hangriness (we ask people how hangry they are on a scale from\n1-10, with 10 being most hangry, and 0 being not hangry at all). The\nfirst independent variable will be time since last meal (1 hour vs.~5\nhours), and the second independent variable will be how tired someone is\n(not tired vs very tired). I imagine the data could look something the\nfollowing bar graph.\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-10-1}\n\nThe graph shows clear evidence of two main effects,\n\\emph{and an interaction}. There is a main effect of time since last\nmeal. Both the bars in the 1 hour conditions have smaller hanger ratings\nthan both of the bars in the 5 hour conditions. There is a main effect\nof being tired. Both of the bars in the ``not tired'' conditions are\nsmaller than than both of the bars in the ``tired'' conditions. What\nabout the interaction?\n\nRemember, an interaction occurs when the effect of one independent\nvariable depends on the level of the other independent variable. We can\nlook at this two ways, and either way shows the presence of the very\nsame interaction. First, does the effect of being tired depend on the\nlevels of the time since last meal? Yes. Look first at the effect of\nbeing tired only for the ``1 hour condition''. We see the red bar\n(tired) is 1 unit lower than the green bar (not\\_tired). So, there is an\neffect of 1 unit of being tired in the 1 hour condition. Next, look at\nthe effect of being tired only for the ``5 hour'' condition. We see the\nred bar (tired) is 3 units lower than the green bar (not\\_tired). So,\nthere is an effect of 3 units for being tired in the 5 hour condition.\nClearly, the size of the effect for being tired depends on the levels of\nthe time since last meal variable. We call this an interaction.\n\nThe second way of looking at the interaction is to start by looking at\nthe other variable. For example, does the effect of time since last meal\ndepend on the levels of the tired variable? The answer again is yes.\nLook first at the effect of time since last meal only for the red bars\nin the ``not tired'' condition. The red bar in the 1 hour condition is 1\nunit smaller than the red bar in the 5 hour condition. Next, look at the\neffect of time since last meal only for the green bars in the ``tired''\ncondition. The green bar in the 1 hour condition is 3 units smaller than\nthe green bar in the 5 hour condition. Again, the size of the effect of\ntime since last meal depends on the levels of the tired variable.No\nmatter which way you look at the interaction, we get the same numbers\nfor the size of the interaction effect, which is 2 units (a difference\nbetween 3 and 1 = 2). The interaction suggests that something special\nhappens when people are tired and haven't eaten in 5 hours. In this\ncondition, they can become very hangry. Whereas, in the other\nconditions, there are only small increases in being hangry.\n\n\\subsection{Identifying main effects and\ninteractions}\\label{identifying-main-effects-and-interactions}\n\nResearch findings are often presented to readers using graphs or tables.\nFor example, the very same pattern of data can be displayed in a bar\ngraph, line graph, or table of means. These different formats can make\nthe data look different, even though the pattern in the data is the\nsame. An important skill to develop is the ability to identify the\npatterns in the data, regardless of the format they are presented in.\nSome examples of bar and line graphs are presented in the margin, and\ntwo example tables are presented below. Each format displays the same\npattern of data.\n\n\\begin{marginfigure}\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-11-1} \\end{marginfigure}\n\\begin{marginfigure}\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-11-2} \\end{marginfigure}\n\n\\begin{longtable}[]{@{}lll@{}}\n\\toprule\nDV I & V1 I & V2\\tabularnewline\n\\midrule\n\\endhead\n10 & Level\\_1 & Level\\_1\\tabularnewline\n12 & Level\\_2 & Level\\_1\\tabularnewline\n17 & Level\\_1 & Level\\_2\\tabularnewline\n13 & Level\\_2 & Level\\_2\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\n\\begin{verbatim}\n##          df$IV2\n## df$IV1    Level_1 Level_2\n##   Level_1      10      17\n##   Level_2      12      13\n\\end{verbatim}\n\nAfter you become comfortable with interpreting data in these different\nformats, you should be able to quickly identify the pattern of main\neffects and interactions. For example, you would be able to notice that\nall of these graphs and tables show evidence for two main effects and\none interaction.\n\nAs an exercise toward this goal, we will first take a closer look at\nextracting main effects and interactions from tables. This exercise will\nhow the condition means are used to calculate the main effects and\ninteractions. Consider the table of condition means below.\n\n\\begin{longtable}[]{@{}cccc@{}}\n\\toprule\n& & IV1 &\\tabularnewline\n\\midrule\n\\endhead\n& & A & B\\tabularnewline\nIV2 & 1 & 4 & 5\\tabularnewline\n& 2 & 3 & 8\\tabularnewline\n\\bottomrule\n\\end{longtable}\n\n\\subsection{Main effects}\\label{main-effects-1}\n\nMain effects are the differences between the means of single independent\nvariable. Notice, this table only shows the condition means for each\nlevel of all independent variables. So, the means for each IV must be\ncalculated. The main effect for IV1 is the comparison between level A\nand level B, which involves calculating the two column means. The mean\nfor IV1 Level A is (4+3)/2 = 3.5. The mean for IV1 Level B is (5+8)/2 =\n6.5. So the main effect is 3 (6.5 - 3.5). The main effect for IV2 is the\ncomparison between level 1 and level 2, which involves calculating the\ntwo row means. The mean for IV2 Level 1 is (4+5)/2 = 4.5. The mean for\nIV2 Level 2 is (3+8)/2 = 5.5. So the main effect is 1 (5.5 - 4.5). The\nprocess of computing the average for each level of a single independent\nvariable, always involves collapsing, or averaging over, all of the\nother conditions from other variables that also occured in that\ncondition\n\n\\subsection{Interactions}\\label{interactions-1}\n\nInteractions ask whether the effect of one independent variable depends\non the levels of the other independent variables. This question is\nanswered by computing difference scores between the condition means. For\nexample, we look the effect of IV1 (A vs.~B) for both levels of of IV2.\nFocus first on the condition means in the first row for IV2 level 1. We\nsee that A=4 and B=5, so the effect IV1 here was 5-4 = 1. Next, look at\nthe condition in the second row for IV2 level 2. We see that A=3 and\nB=8, so the effect of IV1 here was 8-3 = 5. We have just calculated two\ndifferences (5-4=1, and 8-3=5). These difference scores show that the\nsize of the IV1 effect was different across the levels of IV2. To\ncalculate the interaction effect we simply find the difference between\nthe difference scores, 5-1=4. \\emph{In general, if the difference\nbetween the difference scores is different, then there is an interaction\neffect.}\n\n\\subsection{Example bar graphs}\\label{example-bar-graphs}\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-13-1}\n\nThe IV1 graph shows a main effect only for IV1 (both red and green bars\nare lower for level 1 than level 2). The IV1\\&IV2 graphs shows main\neffects for both variables. The two bars on the left are both lower than\nthe two on the right, and the red bars are both lower than the green\nbars. The IV1xIV2 graph shows an example of a classic cross-over\ninteraction. Here, there are no main effects, just an interaction. There\nis a difference of 2 between the green and red bar for Level 1 of IV1,\nand a difference of -2 for Level 2 of IV1. That makes the differences\nbetween the differences = 4. Why are their no main effects? Well the\naverage of the red bars would equal the average of the green bars, so\nthere is no main effect for IV2. And, the average of the red and green\nbars for level 1 of IV1 would equal the average of the red and green\nbars for level 2 of IV1, so there is no main effect. The bar graph for\nIV2 shows only a main effect for IV2, as the red bars are both lower\nthan the green bars.\n\n\\subsection{Example line graphs}\\label{example-line-graphs}\n\nYou may find that the patterns of main effects and interaction looks\ndifferent depending on the visual format of the graph. The exact same\npatterns of data plotted up in bar graph format, are plotted as line\ngraphs for your viewing pleasure. Note that for the IV1 graph, the red\nline does not appear because it is hidden behind the green line (the\npoints for both numbers are identical).\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-14-1}\n\n\\subsection{Interpreting main effects and\ninteractions}\\label{interpreting-main-effects-and-interactions}\n\nThe presence of an interaction can sometimes change how we interpet main\neffects. For example, a really strong interaction can produce the\nappearance of a main effect, even though when we look at the data most\npeople would agree the main effect is not there.\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-15-1}\n\nIn the above graph there is clearly an interaction. IV2 has no effect\nunder level 1 of IV1 (e.g., the red and green bars are the same). IV2\nhas a large effect under level 2 of IV2 (the red bar is 2 and the green\nbar is 9). So, the interaction effect is a total of 7. Are there any\nmain effects? This is a debatable question. Consider the main effect for\nIV1. The mean for level 1 is (2+2)/2 = 2, and the mean for level 2 is\n(2+9)/2 = 5.5. There is a difference between the means of 3.5, which is\nconsistent with a main effect. Consider, the main effect for IV2. The\nmean for level 1 is again (2+2)/2 = 2, and the mean for level 2 is again\n(2+9)/2 = 5.5. Again, there is a difference between the means of 3.5,\nwhich is consistent with a main effect. What is going on here is that\nthe process of averagin over conditions that we use to compute main\neffects is causing a main effect to appear, even though we don't really\nsee clear evidence of main effects.\n\nClear evidence of a main effect typically refers to cases where there is\na consistent additive influence. For example, if there really was a main\neffect of IV1, then both red and green bars for level 2 should be\nhigher, not just one of them. In other words, the effect of IV1 did not\nuniformly raise or lower the means across all of the other conditions.\nFor this reason, the main effects that we observed by performing the\ncalculation are really just an interaction in disguise.\n\nThe next example shows a case where it would be more appropriate to\nconclude that the main effects and the interaction were both real.\n\n\\includegraphics{Factorial_files/figure-latex/unnamed-chunk-16-1}\n\nCan you spot the interaction right away? The difference between red and\ngreen bars is small for level 1 of IV1, but large for level 2. The\ndifferences between the differences are different, so there is an\ninteraction. But, we also see clear evidence of two main effects. For\nexample, both the red and green bars for IV1 level 1 are higher than IV1\nLevel 2. And, both of the red bars (IV2 level 1) are higher than the\ngreen bars (IV2 level 2).\n\n\n", "meta": {"hexsha": "326248ba836a9dd1999792efda9b8bf93fbdd693", "size": 27472, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LatexVersion/Factorial.tex", "max_stars_repo_name": "danBurrell/research_methods_with_R", "max_stars_repo_head_hexsha": "74745c4bd69d185f1a36ef38638be8cc55966b06", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2017-12-29T16:39:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-24T12:46:59.000Z", "max_issues_repo_path": "LatexVersion/Factorial.tex", "max_issues_repo_name": "danBurrell/research_methods_with_R", "max_issues_repo_head_hexsha": "74745c4bd69d185f1a36ef38638be8cc55966b06", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LatexVersion/Factorial.tex", "max_forks_repo_name": "danBurrell/research_methods_with_R", "max_forks_repo_head_hexsha": "74745c4bd69d185f1a36ef38638be8cc55966b06", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2017-09-01T14:17:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T23:17:38.000Z", "avg_line_length": 46.2491582492, "max_line_length": 97, "alphanum_fraction": 0.7830518346, "num_tokens": 6996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632979641571, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.4248787372692031}}
{"text": "\\documentclass{article}\n\\usepackage{expsagetex}\n\\usepackage{amsmath}\n\\usepackage{parskip}\n\\usepackage{shortvrb}\n\\usepackage{csquotes}\n\\usepackage{expl3}\n\\usepackage[svgnames]{xcolor}\n\\usepackage{tikz}\n\\usepackage{xfp}\n\\usepackage{siunitx}\n\\sisetup{group-separator = \\text{\\,}}\n\\usepackage{hyperref}\n\\hypersetup{colorlinks=true, anchorcolor=Lime, linkcolor=RoyalBlue,\n            urlcolor=Crimson}\n\n\\title{%\n  \\pkg{expsagetex} -- a fully expandable interface for SageTeX%\n  \\thanks{This file describes \\pkg{expsagetex}~v0.1, last revised 2020-01-11.}%\n}\n\\author{%\n  Florent Rougon%\n  \\thanks{%\n    E-mail: \\href{mailto:f.rougon@free.fr}{mailto:f.rougon@free.fr}%\n  }%\n}\n\n\\newcommand*{\\pkg}{\\textsf}\n\\newcommand*{\\meta}[1]{$\\langle \\textsl{#1} \\rangle$}\n\\newcommand*{\\tikzname}{Ti\\emph{k}Z}\n\n\\setlength{\\parindent}{0pt}     % will probably look better here\n\n\\begin{document}\n\n\\maketitle\n\\begin{abstract}\n  This package is based on \\texttt{sagetex.sty}, the style file for SageTeX.\n  One deficiency of current \\texttt{sagetex.sty} (version~3.3 from 2019/01/09)\n  is that it doesn't provide any user-accessible way to retrieve a result\n  computed by Sage in places where only expansion happens. This packages uses\n  the low-level SageTeX machinery to implement a set of commands that can\n  \\enquote{record} results computed by Sage and a fully expandable command\n  that can yield any such result wherever you need it, even in expansion-only\n  contexts.\n\\end{abstract}\n\n\\MakeShortVerb{\\|}\n\n\\tableofcontents\n\\clearpage\n\nBesides the \\nameref{sec:quick-start} section below, there is introductory\nmaterial to \\pkg{expsagetex}\n\\href{https://tex.stackexchange.com/questions/521319/sagetex-1000sep-for-sage-calculated-number-siunitx/521389#521389}{on\n  TeX.stackexchange.com}.\n\n\\section{Quick start}\n\\label{sec:quick-start}\n\nGetting a result from Sage using \\pkg{expsagetex} involves three steps in the\n\\LaTeX\\ code:\n\\begin{enumerate}\n\\item Recording a Python expression to be written to the\n  \\texttt{.sagetex.sage} file. This step is done with one of the |\\est*Record|\n  functions.\n\\item Using the result where you need it. This is done with |\\estGet| and\n  works in many places, in particular in expansion-only contexts (inside\n  |\\edef|, |\\message|, |\\write|, etc.).\n\\item Declaring that you use the result, so that a warning can be displayed if\n  the result isn't available yet (|\\estGet| can't print the warning itself\n  because it must work in expansion-only contexts). This is done with\n  |\\estRefUsed|.\n\\end{enumerate}\n\nStep~3 can be done before or after step~2, but must come after step~1. When\nyou run |sage| on the \\texttt{.sagetex.sage} file written by step~1, the\nPython expression is evaluated, converted to a Python string and written to\nthe |.sagetex.sout| file. This file is in turn read by \\texttt{sagetex.sty} at\nstartup, which makes the result available for |\\estGet|.\n\nThus, a very simple example can be\n\\estRecordFormatted{\\littleFermatExple}{(45**6) \\percent 7}%\n\\estRefUsed{\\littleFermatExple}%\n$45^6 \\equiv \\estGet{\\littleFermatExple} \\pmod 7$. This was obtained with:\n\\begin{verbatim}\n\\estRecordFormatted{\\littleFermatExple}{(45**6) \\percent 7}%\n\\estRefUsed{\\littleFermatExple}%\n$45^6 \\equiv \\estGet{\\littleFermatExple} \\pmod 7$\n\\end{verbatim}\n\nFor compiling, use the same method as with \\pkg{sagetex} (which\n\\pkg{expsagetex} relies on): you need one \\LaTeX\\ run, one |sage| run on the\n\\texttt{.sagetex.sage} file followed by at least one more \\LaTeX\\ run (if more\nare needed, warnings are printed by \\LaTeX\\ as usual).\n\n\\section{Examples}\n\n\\subsection{Integers}\n\n\\subsubsection{Local assignments}\n\nWhen using |\\estRecordFormatted{|\\meta{macro}|}{|\\meta{expr}|}| with a Python\nexpression \\meta{expr} that evaluates to an integer,\n|\\estGet[|\\meta{fallback}|]{|\\meta{macro}|}| should give (i.e., expand to) the\nexpected result. This is because calling |str()| on a Python integer doesn't\nuse any exponent notation, thus |latex()| should not add any formatting. Let's\nexecute the following Python statement using the |sageblock| environment:\n\n\\begin{sageblock}\nx = 2**333\n\\end{sageblock}\n\nNow, record the value of $x$ and associate it with macro |\\mymacro|. This\nmakes |\\mymacro| a kind of reference to the saved value, but to retrieve the\ntokens associated to this reference, you have to use |\\estGet| instead of\n|\\ref| (this can be done in an expansion-only context like inside |\\edef|,\nwhich is impossible with |\\ref|). See section~\\ref{sec:technical-details}\nbelow for more details on this.\n{%\n  \\estRecordFormatted{\\mymacro}{x}%\n  Recover the saved value and format it with the |\\num| macro of\n  \\pkg{siunitx}:\\\\\n  \\num{\\estGet[-1]{\\mymacro}}.%\n  \\estRefUsed{\\mymacro}\\\\\n  This was achieved with the following calls:\n\\begin{verbatim}\n\\estRecordFormatted{\\mymacro}{x}\n\\num{\\estGet[-1]{\\mymacro}}\n\\estRefUsed{\\mymacro}\n\\end{verbatim}\n}%\n\\ifx\\mymacro\\undefined\\else\n  \\par Bug: |\\mymacro| should be undefined here!\n\\fi\n\nAnother way to do the same without having Sage call |latex()| at all is to\nuse |\\estRecordStr| to record a string representation of the integer we are\ninterested in:\n\\begin{verbatim}\n\\estRecordStr{\\mymacro}{str(x)}\n\\num{\\estGet[-1]{\\mymacro}}\n\\estRefUsed{\\mymacro}\n\\end{verbatim}\n\n\\pagebreak[3]\n\nNotes:\n\\begin{itemize}\n\\item |\\estGet| wraps its return value within |\\unexpanded| (|\\exp_not:n|),\n  which implies that it won't expand further when used in |\\edef| or an\n  \\pkg{expl3} |x|-type argument.\n\\item In order to use the result of evaluating a Python expression in the\n  \\LaTeX\\ document, it is not necessary to store it in a Python variable.\n  Example:%\n  \\estRecordFormatted{\\twoToTheThenth}{2**10}%\n  \\estRefUsed{\\twoToTheThenth}%\n  \\[ 2^{10} = \\estGet{\\twoToTheThenth} \\]\n\\end{itemize}\n\nAnother example with variables:\n\n\\begin{sageblock}\nx = 23 % 8         # That is, x = 7.\ny = 2*x\n\\end{sageblock}\n\nSave the value of $1000000\\times (y-10)$ (as computed by Sage) and associate\nit with macro |\\numberBasedOnY|.\n\\estRecordFormatted{\\numberBasedOnY}{1000000*(y-10)}%\n% Use the value -1000000 when Sage hasn't written the result to the .sout file\n% yet.\n\\[ 1000000\\times (y - 10) = \\num{\\estGet[-1000000]{\\numberBasedOnY}} \\]\n\\estRefUsed{\\numberBasedOnY}\n\n\\subsubsection{Global assignments}\n\nWhile |\\estRecordFormatted| assigns locally to the macro given by its\nfirst argument, all |\\est*Record| functions have a global variant that\nperforms a global assignment instead. The global variant of\n|\\estRecordFormatted| is |\\estGRecordFormatted|, that of\n|\\estRecordStr| is |\\estGRecordStr|, that of\n|\\estARecordFormatted| is |\\estGARecordFormatted|, etc. Example:\n\n\\begin{sageblock}\nx = 3+4\n\\end{sageblock}\n\nSave the value of $x$ and globally assign macro |\\Iamseven| to allow us\nto retrieve the saved value.\n{%\n  \\estGRecordFormatted{\\Iamseven}{x}%\n}%\nGet it back from outside the group where this was done, and format it with\n|\\num|: the result is\n\\num{\\estGet[-2]{\\Iamseven}}.%\n\\estRefUsed{\\Iamseven}\n\n\\subsection{Floating point numbers}\n\n|\\estRecordFormatted| works with floating point numbers, but it uses \\LaTeX\\\nmarkup if the string representation of the result (in Python) uses exponent\nnotation. When this is not desirable---i.e., when you just want a numerical\nresult without any formatting---use |\\estRecordFloat| or one of its variants.\nExample:\n\\begin{sageblock}\nx = 3.1415927\n\\end{sageblock}\n\\estRecordFloat{\\PiRoundedByPython}{x}{.2f}%\n\\estRefUsed{\\PiRoundedByPython}%\n$x$ rounded to two decimal places is \\estGet[0]{\\PiRoundedByPython}. This was\nrounded by Python.\n\\estRecordFloat{\\PiRoundedBySiunitx}{x}{.10f}%\n\\estRefUsed{\\PiRoundedBySiunitx}%\nThanks to the expandable nature of |\\estGet|, one can also do this: $x$\nrounded to four decimal places is\n\\num[round-mode=places, round-precision=4]{\\estGet[0]{\\PiRoundedBySiunitx}}.\nThis was rounded by \\pkg{siunitx}.\n\nOf course, one can also compute a float with Sage without storing it into a\nPython variable. Here is an approximation of $\\pi$ using an expression based\non Machin's formula and the power series expansion of $\\arctan$:\n\\estRecordFloat{\\PiViaMachinAndPowerSeries}\n  {\n    N(4*sum([ (-1)**n / (2*n+1) * (4*(1/5)**(2*n+1) - (1/239)**(2*n+1))\n              for n in range(10) ]))\n  }{.6f}%\n\\estRefUsed{\\PiViaMachinAndPowerSeries}%\n\\begin{align*}\n  \\pi &= 4\\sum_{n=0}^{+\\infty} \\frac{(-1)^n}{(2n+1)}\n         \\Biggl( 4 \\, {\\Bigl( \\frac{1}{5} \\Bigr)}^{2n+1} \\! -\n                 {\\Bigl( \\frac{1}{239} \\Bigr)}^{2n+1} \\Biggr)\\\\\n      &\\approx \\estGet[0]{\\PiViaMachinAndPowerSeries}\n\\end{align*}\n\n\\subsection{Strings}\n\nFunctions working on Python strings are the most general here. For instance,\n|\\estRecordFormatted| first evaluates |latex(...)| in Sage (Python), where\n|...| is the Python expression you entered; this results in a string with\n\\LaTeX\\ math-mode formatting commands (e.g., if evaluating |str(...)| in Python string yields something containing brackets or\nexponents); then this string is written to the |.sout| file inside an\nargument of |\\newlabel|, which \\pkg{sagetex} reads at startup. Similarly,\n|\\estRecordFloat| causes Python to convert a float to a string using the\nuser-specified format, then this string is written to the |.sout| file\ninside an argument of |\\newlabel|, just as with\n|\\estRecordFormatted|. This applies to global and array variants of the\n\\pkg{expsagetex} functions as well.\n\nSo, |\\estRecordStr| and its variants can be very useful in case your\nPython code returns a data type that isn't handled in a satisfactory way by\nfunctions belonging to the families of |\\estRecordFormatted| or\n|\\estRecordFloat|. All you have to do is to make your Python code format\nyour data as a string with a syntax that is convenient for the \\LaTeX\\\ndocument; you record this string with |\\estRecordStr| or one of its\nvariants, use |\\estGet| and |\\estRefUsed| as usual and voilà, your new data\ntype is nicely handled by \\pkg{expsagetex}. We'll see an example of this\napproach in\nsection~\\ref{sec:plotting-with-tikzname-based-on-Sage-computations}, where\nPython code generates a large amount of $(x_i, y_i)$ coordinates from two\nlists of floats $[x_1, \\dotsc, x_n]$ and $[y_1, \\dotsc, y_n]$. The Python code\nformats the list of $(x_i, y_i)$ coordinates in a form that is suitable for\nthe \\tikzname\\ \\texttt{plot coordinates} operation, which allows one to plot\nthe data right away.\n\nHere is a very simple example with |\\estRecordStr| used to record a Sage\n(Python) string:\n\\begin{sageblock}\n some_string = \"abc  def\"\n\\end{sageblock}\n\\estRecordStr{\\somestring}{some_string}%\nX\\estGet{\\somestring}Y%\n\\estRefUsed{\\somestring}\n\nThe two spaces between |abc| and |def| are present in the\n|.sout| file, but get coalesced into a single space token when\n|\\newlabel| tokenizes its second argument. If this is not desired, the\neasiest way is probably to use another character instead of space (e.g.,\n\\verb|~|).\n\n\\subsection{Using array data}\n\\label{sec:using-array-data}\n\n\\pkg{expsagetex} offers variants of |\\estRecordFormatted|,\n|\\estGRecordFormatted|, |\\estRecordFloat|, |\\estGRecordFloat|, |\\estRecordStr|\nand |\\estGRecordStr| that allow one to easily use an index inside the macro\nname given for the recording operation. These variants all have the letter\n\\texttt{A} (standing for ``array'') right before \\texttt{Record}.\n\nWhere the non-array versions of the |\\est*Record*| commands take one argument\nspecifying the destination macro name, the array versions accept two arguments\n\\meta{base} and \\meta{index} and determine the destination macro name as the\nresult of expanding |\\csname |\\meta{base}@\\meta{index}|\\endcsname|. As a\nconsequence, the \\meta{base} and \\meta{index} arguments are recursively\nexpanded, which can be used to dynamically compute a numeric index using for\ninstance |\\numexpr|, or whatever you want.\n\nHere is an example that uses Python to evaluate the elements of a Vandermonde\nmatrix:\n\\ExplSyntaxOn\n\\int_new:N \\l__my_row_int\n\\int_new:N \\l__my_col_int\n\\int_new:N \\g__my_row_counter_int\n\\clist_const:Nn \\c__my_clist { 2, sqrt(2)/2, 2/7, 4/3, 1/5 }\n\\clist_const:Nn \\c__my_formatted_clist\n  { 2, \\frac{\\sqrt{2}}{2}, \\frac{2}{7}, \\frac{4}{3}, \\frac{1}{5} }\n\\seq_new:N \\l__my_matrix_rows_seq\n\n\\int_step_variable:nnNn { 1 } { 5 } \\l__my_row_int\n  {\n    % One l3seq per matrix row\n    \\seq_clear_new:c { l__my_matrix_row \\l__my_row_int _seq }\n    % \\use:c needs two expansion steps to do its work\n    \\exp_args:NNo \\seq_put_right:No \\l__my_matrix_rows_seq\n      { \\use:c { l__my_matrix_row \\l__my_row_int _seq } }\n\n    \\int_step_variable:nnNn { 1 } { 5 } \\l__my_col_int\n      {\n        \\tl_set:Nx \\l_tmpa_tl\n          {\n            ( \\clist_item:Nn \\c__my_clist { \\l__my_row_int } ) **\n                                                          ( \\l__my_col_int - 1 )\n          }\n        \\estARecordFormatted { Vandermonde } { \\l__my_row_int - \\l__my_col_int }\n          { \\tl_use:N \\l_tmpa_tl }\n        \\seq_put_right:cx { l__my_matrix_row \\l__my_row_int _seq }\n          { \\estAGet [0] { Vandermonde } { \\l__my_row_int - \\l__my_col_int } }\n        \\estARefUsed { Vandermonde } { \\l__my_row_int - \\l__my_col_int }\n      }\n  }\n\n\\[ \\renewcommand{\\arraystretch}{1.2}\n  \\mathcal{V} \\Bigl( \\clist_use:Nn \\c__my_formatted_clist { , } \\Bigr) =\n   \\begin{bmatrix}\n     \\int_gzero:N \\g__my_row_counter_int\n     \\seq_map_inline:Nn \\l__my_matrix_rows_seq\n       {\n         \\int_gincr:N \\g__my_row_counter_int\n         \\seq_use:Nn #1 { & }\n         % Append \\\\ unless it is the last line\n         \\int_compare:nNnT\n           { \\g__my_row_counter_int } < { \\seq_count:N \\l__my_matrix_rows_seq }\n           { \\\\ }\n       }\n   \\end{bmatrix} \\]\n\\ExplSyntaxOff\n\nThis technique can be used to plot curves with \\tikzname\\ based on coordinates\ncomputed by Python, but this is rather wasteful. We'll see a better method\nin section~\\ref{sec:plotting-with-tikzname-based-on-Sage-computations}.\n\n\\subsection{Displaying lists}\n\\label{sec:lists}\n\n|\\estRecordFormatted| is fine for a list of integers:%\n\\estRecordFormatted{\\listA}{list(range(2, 21, 3))}%\n\\begin{quote}\n  \\estRefUsed{\\listA}%\n  $\\estGet[{[]}]{\\listA}$\n\\end{quote}\n\nIt may do what you want for floats too:\n\\estRecordFormatted{\\listB}{map(float, list(range(2, 21, 3)))}%\n\\begin{quote}\n  \\estRefUsed{\\listB}%\n  $\\estGet[{[]}]{\\listB}$\n\\end{quote}\n\nBut beware: if you use |\\estRecordFormatted|, floats are formatted by Sage's\n|latex()| function:\n\\estRecordFormatted{\\listC}{[1e-10] + [5.0, 3e-14]}\n\\begin{quote}\n  \\small\n  \\estRefUsed{\\listC}%\n  $\\estGet[{[]}]{\\listC}$\n\\end{quote}\n\nHere is a way to use a Python list of floats formatted with no exponent\nand using a chosen number of decimal places:%\n% We format each float individually as a string. We could as well omit the\n% outer brackets: they are just string characters here (the final assembled\n% expression is a Python string; it is *not* evaluated as a list by Python).\n\\estRecordStr{\\listD}\n  {\n    '[' +\n    ', '.join(map(lambda x: \"\\percent.14f\" \\percent (x,), [1e-10, 5.0, 3e-14])) +\n    ']'\n  }\n\\begin{quote}\n  \\estRefUsed{\\listD}%\n  $\\estGet[{[]}]{\\listD}$\n\\end{quote}\n\n\\subsection{Plotting with \\tikzname\\ based on Sage computations}\n\\label{sec:plotting-with-tikzname-based-on-Sage-computations}\n\nPlotting functions based on coordinates computed by Sage can be done using\narray-style functions of \\pkg{expsagetex} (see\nsection~\\ref{sec:using-array-data}), however such an approach is vastly\ninefficient if the plot uses a significant number of points. A better approach\nis to prepare one string on the Python side containing all needed coordinates\nin a format that the \\LaTeX\\ plotting code can easily handle. This way, only\none reference---as in |\\label| and |\\ref|---is used to pass data for the whole\nplot. As an example, here is a part of the Euler spiral where all coordinates\nare computed by Sage and transferred in one go to the \\LaTeX\\ side (for the\nfull Euler Spiral, you need to make $t$ vary from $-\\infty$ to $+\\infty$).\n%\n\\begin{sagesilent}\n  x = var('x')\n  start = -5*pi/2\n  end = 5*pi/2\n  nb_samples = 2000\n  delta = float(end-start)/(nb_samples-1)\n\\end{sagesilent}\n%\n\\estRecordStr{\\computedCoordsRef}\n  {\n    \" \".join([ \"(\\percent.6f, \\percent.6f)\" \\percent\n               (0.1*( numerical_integral(cos(x**2), 0, t)[0] ),\n                0.1*( numerical_integral(sin(x**2), 0, t)[0] ))\n               for t in ( start + _*delta for _ in range(nb_samples) ) ])\n  }\n\\edef\\computedCoords{\\estGet[(0,0)]{\\computedCoordsRef}}\n\\estRefUsed{\\computedCoordsRef}\n%\n\\begin{center}\n\\begin{tabular}{cc}\n\\raisebox{-0.5\\height}{%\n  \\begin{tikzpicture}\n    \\draw[red!60!black, scale=20] plot coordinates { \\computedCoords };\n  \\end{tikzpicture}%\n}\\hspace*{0.06\\linewidth} &\n\\hspace*{0.06\\linewidth}%\n$ \\newcommand{\\diff}{\\mathop{}\\!\\mathrm{d}}\n  \\left\\{\n    \\begin{array}{>{\\displaystyle}l}\n      x(t) = \\int_{0}^{t} \\cos s^2 \\diff s\\\\[10pt]\n      y(t) = \\int_{0}^{t} \\sin s^2 \\diff s\n    \\end{array}\n  \\right. ,\\ t \\in [-\\frac{5\\pi}{2}, \\frac{5\\pi}{2}]$\n\\end{tabular}\n\\end{center}\n\n\\section{Expandable commands work everywhere!}\n\nSince |\\estGet| is expandable and we have |\\usepackage{xfp}| in the preamble,\nwe can do:\n\\begin{verbatim}\n$\\fpeval{3*\\estGet[-1]{\\Iamseven}}$\n\\end{verbatim}\nThis expands to $\\fpeval{3*\\estGet[-1]{\\Iamseven}}$, since |\\Iamseven|\ncontains the last value of $x$ computed by Sage, which is $7$ (if Sage hasn't\nbeen run yet, it expands to $-3$ due to the fallback value \\texttt{-1}\nspecified in the optional argument of |\\estGet|).%\n\\estRefUsed{\\Iamseven}%\n\n{%\n  Given that \\TeX\\ expands the right-hand side of integer, dimen and glue\n  assignments until this yields the proper syntactic element, one can also use\n  |\\estGet| like this:\n  \\begin{verbatim}\n  \\count2=4\n  \\multiply \\count2 by \\estGet[-1]{\\Iamseven}\n  \\the\\count2\n  \\estRefUsed{\\Iamseven}% just to be clean\n  \\end{verbatim}\n  \\count2=4\n  \\multiply \\count2 by \\estGet[-1]{\\Iamseven}\n  $\\rightarrow$ \\the\\count2 % prints 28 (4*7)\n  \\estRefUsed{\\Iamseven}\n}\n\n\\bigskip\nSame thing with a |\\dimen| register:\n\\begin{verbatim}\n\\dimen0=1pt\n\\dimen0=\\estGet[-1]{\\Iamseven}\\dimen0\n\\the\\dimen0\n\\estRefUsed{\\Iamseven}% just to be clean\n\\end{verbatim}\n\\dimen0=1pt\n\\dimen0=\\estGet[-1]{\\Iamseven}\\dimen0\n$\\rightarrow$ \\the\\dimen0 % prints 7.0pt\n\\estRefUsed{\\Iamseven}\n\n\\newcommand*{\\grammarsymbol}[1]{\\mbox{\\meta{#1}}}%\nAnd since \\LaTeX\\ lengths are |\\skipdef| tokens and |\\setlength| is\nbasically a glue assignment, one can have fun with\n|\\estGet[-1]{\\Iamseven}| expanding to the \\grammarsymbol{factor} of\na \\grammarsymbol{normal dimen} (cf.~\\TeX book p.~270):\n\\begin{verbatim}\n\\dimen0=2pt\n\\dimen2=3pt\n\\newlength{\\mylength}\n\\setlength{\\mylength}{%\n       \\estGet[-1]{\\Iamseven}\\dimen0\n  plus \\estGet[-1]{\\Iamseven}\\dimen2}%\n\\the\\mylength\n\\estRefUsed{\\Iamseven}% just to be clean\n\\end{verbatim}\n\\dimen0=2pt\n\\dimen2=3pt\n\\newlength{\\mylength}\n\\setlength{\\mylength}{%\n       \\estGet[-1]{\\Iamseven}\\dimen0\n  plus \\estGet[-1]{\\Iamseven}\\dimen2}%\n$\\rightarrow$ \\the\\mylength % prints 14.0pt plus 21.0pt\n\\estRefUsed{\\Iamseven}\n\n\\section{Troubleshooting}\n\nIn case something goes wrong when using \\pkg{sagetex} or \\pkg{expsagetex}, you\nmay get stuck and unable to perform a full \\LaTeX\\ run. This can for instance\nhappen if one of your Python expressions is invalid. This kind of error is\nsimilar to problems that may occur when something ``bad'' was written to the\n|.aux| file. The cure is similar too: locate the error (inspecting the\n\\texttt{.sagetex.sage} and \\texttt{.sagetex.sout} files can help; if the\nproblem is an invalid Python expression, the |sage| run will tell you),\nregenerate the files containing invalid things after fixing their source, then\nrerun the \\LaTeX\\ and |sage| commands as usual. Typically, you'll fix a Python\nexpression in your |.tex| file, remove the |.sagetex.sout| file and rerun\n\\LaTeX, |sage| and again \\LaTeX. If you want to be \\emph{really} sure to\nrestart from a clean state, remove the \\texttt{.sagetex.sage},\n\\texttt{.sagetex.sout} and |.aux| files before redoing the \\LaTeX\\ \\& |sage|\ndance.\n\n\\section{Technical details}\n\\label{sec:technical-details}\n\nSome comments about what a call such as |\\estRecordStr{\\mymacro}{|$s$|}| as\nseen below really does ($s$ must evaluate in Python to a string). Informally,\none might be tempted to say that this saves the value of $s$ in the specified\nmacro, but that would be rather inaccurate. After the call to |\\estRecordStr|,\nthe specified macro contains an integer which is used to form a reference\nname---a label, if you wish---through which we can get the value of $s$ using\ninner gears of the |\\label| and |\\ref| machinery. The \\texttt{.sagetex.sout}\nfile written when running Sage on the \\texttt{.sagetex.sage} file contains\n|\\newlabel| commands that define the associated text (tokens) for reference\nnames \\texttt{@sageinline0}, \\texttt{@sageinline1}, etc. The trailing number\nis what is really stored by the above call to |\\estRecordStr| as the\nreplacement text of |\\mymacro|. \\texttt{sagetex.sty} reads this\n\\texttt{.sagetex.sout} file at startup when it exists, which defines the\nlabels from the point of view of the \\LaTeX\\ kernel and allows us to retrieve\nthe Sage output for each recorded expression (after the |\\newlabel| commands\nhave been executed, the Sage outputs are available, after some simple data\nextraction, in macros |\\r@@sageinline0|, |\\r@@sageinline1|, etc.).\n\n\\end{document}\n", "meta": {"hexsha": "f37cb63ef175f93234190c1bcf715872ecba6503", "size": 21284, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/expsagetex.tex", "max_stars_repo_name": "frougon/expsagetex", "max_stars_repo_head_hexsha": "522dac1cf812c3b232b01137a1600cbb0b8ba815", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-12T01:07:50.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-12T01:07:50.000Z", "max_issues_repo_path": "doc/expsagetex.tex", "max_issues_repo_name": "frougon/expsagetex", "max_issues_repo_head_hexsha": "522dac1cf812c3b232b01137a1600cbb0b8ba815", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/expsagetex.tex", "max_forks_repo_name": "frougon/expsagetex", "max_forks_repo_head_hexsha": "522dac1cf812c3b232b01137a1600cbb0b8ba815", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7686703097, "max_line_length": 126, "alphanum_fraction": 0.7211520391, "num_tokens": 6581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7826624789529376, "lm_q1q2_score": 0.42487872294032347}}
{"text": "\\nwfilename{_src/2019/day/01.nw}\\nwbegindocs{0}\\newpage% ===> this file was generated automatically by noweave --- better not edit it\n\\section{Day 1: The Tyranny of the Rocket Equation}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/1}}\n\\nwenddocs{}\\nwfilename{_src/2019/gap/01.nw}\\nwbegindocs{0}\\subsection{GAP Solution}\n\n\\begin{marginfigure}\n\\[\n \\text{fuel} := \\text{mass} \\backslash 3 - 2\n\\]\n\\end{marginfigure}\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW3RAD1b-3gOu99-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-1}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{\\relax}{NW3RAD1b-3gOu99-2}\\nwenddeflinemarkup\nFuelRequiredModule := function( mass )\n    return Int( Float( mass / 3 ) ) - 2;\nend;;\n\n\n\\nwalsodefined{\\\\{NW3RAD1b-3gOu99-2}\\\\{NW3RAD1b-3gOu99-3}\\\\{NW3RAD1b-3gOu99-4}}\\nwnotused{Day01.g}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW3RAD1b-3gOu99-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-2}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW3RAD1b-3gOu99-1}{NW3RAD1b-3gOu99-3}\\nwenddeflinemarkup\nPartOne := function( )\n    local input, line, mass, sum;;\n    sum := 0;\n    input := InputTextFile ( \"./input/day01.txt\" );\n    line := ReadLine( input );\n    repeat\n        mass := Int( Chomp( line ) );\n        sum := sum + FuelRequiredModule( mass );\n        line := ReadLine( input );\n    until line = fail or IsEndOfStream( input );\n    return sum;\nend;;\n\n\n\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW3RAD1b-3gOu99-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-3}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW3RAD1b-3gOu99-2}{NW3RAD1b-3gOu99-4}\\nwenddeflinemarkup\nTotalFuelRequiredModule := function( mass )\n    local fuel;;\n    fuel := FuelRequiredModule( mass );\n    if IsPosInt( fuel ) then\n        return fuel + TotalFuelRequiredModule( fuel );\n    else\n        return 0;\n    fi;\nend;;\n\n\n\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW3RAD1b-3gOu99-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-4}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW3RAD1b-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW3RAD1b-3gOu99-3}{\\relax}\\nwenddeflinemarkup\nPartTwo := function( )\n    local input, line, mass, sum;;\n    sum := 0;\n    input := InputTextFile ( \"./input/day01.txt\" );\n    line := ReadLine( input );\n    repeat\n        mass := Int( Chomp( line ) );\n        sum := sum + TotalFuelRequiredModule( mass );\n        line := ReadLine( input );\n    until line = fail or IsEndOfStream( input );\n    return sum;\nend;;\n\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\\nwenddocs{}\\nwfilename{_src/2019/day/04.nw}\\nwbegindocs{0}\\newpage\n\\section{Day 4: Secure Container}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/4}}\n\\nwenddocs{}\\nwfilename{_src/2019/haskell/04.nw}\\nwbegindocs{0}\\subsection{Haskell Solution}\n\n\\newthought{My puzzle input} was the range \\text{236491-713787}, which I converted into a\nlist of lists of \\hs{digits}.\n\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW35miTa-1GvnV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW35miTa-1GvnV-1}}}\\moddef{Input~{\\nwtagstyle{}\\subpageref{NW35miTa-1GvnV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}}\\nwenddeflinemarkup\ngetInput :: IO [[Int]]\ngetInput = pure $ reverse . digits 10 <$> [236491 .. 713787]\n\\nwused{\\\\{NW35miTa-15Rjc8-1}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\\newthought{Spoiler:} Parts One and Two vary only in the strictness of the definition of a double, so a generic solver can be parameterized by the binary operation to compare the number of adjacent digits that are the same with \\hs{2}. In both parts of the puzzle, it must also be the case that the digits never decrease, i.e. the password \\hs{isSorted}.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW35miTa-2ApJRg-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW35miTa-2ApJRg-1}}}\\moddef{Generic solver~{\\nwtagstyle{}\\subpageref{NW35miTa-2ApJRg-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}}\\nwenddeflinemarkup\nsolve :: (Int -> Int -> Bool) -> [[Int]] -> Int\nsolve = count . (isSorted <&&>) . hasDouble\n  where\n    hasDouble cmp = any ((`cmp` 2) . length) . group\n\\nwused{\\\\{NW35miTa-15Rjc8-1}}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\\newthought{For Part One,} there must be a double, i.e. at least two adjacent digits that are the same.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW35miTa-2iOjQS-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{\\relax}{NW3AzXtx-2iOjQS-1}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW3AzXtx-2iOjQS-4} :: [[Int]] -> Int\n\\nwlinkedidentc{partOne}{NW3AzXtx-2iOjQS-4} = solve (>=)\n\\nwalsodefined{\\\\{NW3AzXtx-2iOjQS-1}\\\\{NW3AzXtx-2iOjQS-2}\\\\{NW3AzXtx-2iOjQS-3}\\\\{NW3AzXtx-2iOjQS-4}}\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW35miTa-2iOjQS-1}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\n\\newthought{For Part Two,} the password must have a strict double.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW35miTa-4P9qKy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW35miTa-4P9qKy-1}}}\\moddef{Part Two~{\\nwtagstyle{}\\subpageref{NW35miTa-4P9qKy-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{\\relax}{NW3AzXtx-4P9qKy-1}\\nwenddeflinemarkup\n\\nwlinkedidentc{partTwo}{NW3AzXtx-4P9qKy-1} :: [[Int]] -> Int\n\\nwlinkedidentc{partTwo}{NW3AzXtx-4P9qKy-1} = solve (==)\n\\nwalsodefined{\\\\{NW3AzXtx-4P9qKy-1}}\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwindexuse{\\nwixident{partTwo}}{partTwo}{NW35miTa-4P9qKy-1}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\n\n\\newthought{Bring it} all together.\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW35miTa-15Rjc8-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW35miTa-15Rjc8-1}}}\\moddef{Day04.hs~{\\nwtagstyle{}\\subpageref{NW35miTa-15Rjc8-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nmodule AdventOfCode.Year2019.Day04 where\n\nimport AdventOfCode.TH (defaultMain)\nimport AdventOfCode.Util (count, (<&&>))\nimport Data.FastDigits (digits)\nimport Data.List (group)\nimport Data.List.Ordered (isSorted)\n\n\\nwlinkedidentc{main}{NW3AzXtx-19Srvv-1} :: IO ()\n\\nwlinkedidentc{main}{NW3AzXtx-19Srvv-1} = $(defaultMain)\n\n\\LA{}Input~{\\nwtagstyle{}\\subpageref{NW35miTa-1GvnV-1}}\\RA{}\n\n\\LA{}Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}\\RA{}\n\n\\LA{}Part Two~{\\nwtagstyle{}\\subpageref{NW35miTa-4P9qKy-1}}\\RA{}\n\n\\LA{}Generic solver~{\\nwtagstyle{}\\subpageref{NW35miTa-2ApJRg-1}}\\RA{}\n\\nwnotused{Day04.hs}\\nwidentuses{\\\\{{\\nwixident{main}}{main}}}\\nwindexuse{\\nwixident{main}}{main}{NW35miTa-15Rjc8-1}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\\nwenddocs{}\\nwfilename{_src/2019/day/08.nw}\\nwbegindocs{0}\\newpage\n\\section{Day 8: }\\todor{Add missing title}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/8}}\n\\nwenddocs{}\\nwfilename{_src/2019/haskell/08.nw}\\nwbegindocs{0}\\subsection{Haskell solution}\n\n\\newthought{A pixel} can be black, white, or transparent.\n\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW3AzXtx-2M5oYw-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-2M5oYw-1}}}\\moddef{Define a Pixel data type~{\\nwtagstyle{}\\subpageref{NW3AzXtx-2M5oYw-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\ndata \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1}\n  = \\nwlinkedidentc{Black}{NW3AzXtx-2M5oYw-1}\n  | \\nwlinkedidentc{White}{NW3AzXtx-2M5oYw-1}\n  | \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1}\n  deriving (Enum, Eq)\n\\nwindexdefn{\\nwixident{Pixel}}{Pixel}{NW3AzXtx-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{Black}}{Black}{NW3AzXtx-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{White}}{White}{NW3AzXtx-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-2M5oYw-1}\\eatline\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\nShow black pixels as spaces, white ones as hashes, and transparent as dots.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW3AzXtx-QyGx2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-QyGx2-1}}}\\moddef{Implement \\hs{Show} for \\code{}Pixel\\edoc{}~{\\nwtagstyle{}\\subpageref{NW3AzXtx-QyGx2-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\ninstance Show \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1} where\n  show \\nwlinkedidentc{Black}{NW3AzXtx-2M5oYw-1} = \" \"\n  show \\nwlinkedidentc{White}{NW3AzXtx-2M5oYw-1} = \"#\"\n  show \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1} = \".\"\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW3AzXtx-QyGx2-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW3AzXtx-QyGx2-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-QyGx2-1}\\nwindexuse{\\nwixident{White}}{White}{NW3AzXtx-QyGx2-1}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\n\\newthought{Define a {\\Tt{}\\nwlinkedidentq{Layer}{NW3AzXtx-LSl4Q-1}\\nwendquote}} as a list of {\\Tt{}\\nwlinkedidentq{Row}{NW3AzXtx-LSl4Q-1}\\nwendquote}s, and a {\\Tt{}\\nwlinkedidentq{Row}{NW3AzXtx-LSl4Q-1}\\nwendquote} as a list of {\\Tt{}\\nwlinkedidentq{Pixel}{NW3AzXtx-2M5oYw-1}\\nwendquote}s.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW3AzXtx-LSl4Q-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-LSl4Q-1}}}\\moddef{Define a few convenient type aliases~{\\nwtagstyle{}\\subpageref{NW3AzXtx-LSl4Q-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\ntype \\nwlinkedidentc{Image}{NW3AzXtx-LSl4Q-1} = [\\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1}]\n\ntype \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1} = [\\nwlinkedidentc{Row}{NW3AzXtx-LSl4Q-1}]\n\ntype \\nwlinkedidentc{Row}{NW3AzXtx-LSl4Q-1} = [\\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1}]\n\\nwindexdefn{\\nwixident{Image}}{Image}{NW3AzXtx-LSl4Q-1}\\eatline\n\\nwindexdefn{\\nwixident{Layer}}{Layer}{NW3AzXtx-LSl4Q-1}\\eatline\n\\nwindexdefn{\\nwixident{Row}}{Row}{NW3AzXtx-LSl4Q-1}\\eatline\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Row}}{Row}}}\\nwidentuses{\\\\{{\\nwixident{Pixel}}{Pixel}}}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW3AzXtx-LSl4Q-1}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\newthought{Parse an {\\Tt{}\\nwlinkedidentq{Image}{NW3AzXtx-LSl4Q-1}\\nwendquote},} i.e. one or more {\\Tt{}\\nwlinkedidentq{Layer}{NW3AzXtx-LSl4Q-1}\\nwendquote}s comprised of \\hs{height}\n{\\Tt{}\\nwlinkedidentq{Row}{NW3AzXtx-LSl4Q-1}\\nwendquote}s of \\hs{width} {\\Tt{}\\nwlinkedidentq{Pixel}{NW3AzXtx-2M5oYw-1}\\nwendquote}s.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW3AzXtx-4aeb4o-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-4aeb4o-1}}}\\moddef{Parse an image~{\\nwtagstyle{}\\subpageref{NW3AzXtx-4aeb4o-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{image}{NW3AzXtx-4aeb4o-1} :: Int -> Int -> Parser \\nwlinkedidentc{Image}{NW3AzXtx-LSl4Q-1}\n\\nwlinkedidentc{image}{NW3AzXtx-4aeb4o-1} width height = some layer\n  where\n    layer :: Parser \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1}\n    layer = count height row\n    row :: Parser \\nwlinkedidentc{Row}{NW3AzXtx-LSl4Q-1}\n    row = count width pixel\n\\nwindexdefn{\\nwixident{image}}{image}{NW3AzXtx-4aeb4o-1}\\eatline\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{image}}{image}}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Row}}{Row}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW3AzXtx-4aeb4o-1}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW3AzXtx-4aeb4o-1}\\nwindexuse{\\nwixident{Row}}{Row}{NW3AzXtx-4aeb4o-1}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\nParse an encoded black, white, or transparent pixel.\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW3AzXtx-1aCFXy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-1aCFXy-1}}}\\moddef{Parse a pixel~{\\nwtagstyle{}\\subpageref{NW3AzXtx-1aCFXy-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\npixel :: Parser \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1}\npixel =\n  (char '0' *> pure \\nwlinkedidentc{Black}{NW3AzXtx-2M5oYw-1} <?> \"A black pixel\")\n    <|> (char '1' *> pure \\nwlinkedidentc{White}{NW3AzXtx-2M5oYw-1} <?> \"A white pixel\")\n    <|> (char '2' *> pure \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1} <?> \"A transparent pixel\")\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW3AzXtx-1aCFXy-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW3AzXtx-1aCFXy-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-1aCFXy-1}\\nwindexuse{\\nwixident{White}}{White}{NW3AzXtx-1aCFXy-1}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\n\\newthought{Solve} Part One.\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW3AzXtx-2iOjQS-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-2iOjQS-1}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{NW35miTa-2iOjQS-1}{NW3AzXtx-2iOjQS-2}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW3AzXtx-2iOjQS-4} :: \\nwlinkedidentc{Image}{NW3AzXtx-LSl4Q-1} -> Int\n\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{partOne}}{partOne}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW3AzXtx-2iOjQS-1}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW3AzXtx-2iOjQS-1}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\nReturn the product of the number of ones ({\\Tt{}\\nwlinkedidentq{White}{NW3AzXtx-2M5oYw-1}\\nwendquote} pixels) and the number of\ntwos ({\\Tt{}\\nwlinkedidentq{Transparent}{NW3AzXtx-2M5oYw-1}\\nwendquote} pixels) in the \\hs{layer} with the fewest {\\Tt{}\\nwlinkedidentq{Black}{NW3AzXtx-2M5oYw-1}\\nwendquote} pixels.\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NW3AzXtx-2iOjQS-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-2iOjQS-2}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{NW3AzXtx-2iOjQS-1}{NW3AzXtx-2iOjQS-3}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW3AzXtx-2iOjQS-4} layers = numberOf \\nwlinkedidentc{White}{NW3AzXtx-2M5oYw-1} layer * numberOf \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1} layer\n  where\n\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partOne}}{partOne}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW3AzXtx-2iOjQS-2}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-2iOjQS-2}\\nwindexuse{\\nwixident{White}}{White}{NW3AzXtx-2iOjQS-2}\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\nFind the \\hs{layer} with the fewest zeros\\todoo{sp?}, i.e. {\\Tt{}\\nwlinkedidentq{Black}{NW3AzXtx-2M5oYw-1}\\nwendquote} pixels.\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NW3AzXtx-2iOjQS-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-2iOjQS-3}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{NW3AzXtx-2iOjQS-2}{NW3AzXtx-2iOjQS-4}\\nwenddeflinemarkup\n    layer = minimumBy (compare `on` numberOf \\nwlinkedidentc{Black}{NW3AzXtx-2M5oYw-1}) layers\n\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW3AzXtx-2iOjQS-3}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\nReturn the number of elements equivalent to a given one, in a given list of\nlists of elements of the same type. More specifically, return the number of\n{\\Tt{}\\nwlinkedidentq{Pixel}{NW3AzXtx-2M5oYw-1}\\nwendquote}s of a given color in a given {\\Tt{}\\nwlinkedidentq{Layer}{NW3AzXtx-LSl4Q-1}\\nwendquote}.\n\n\\todoo{There's gotta be a Data.List function for this..}\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NW3AzXtx-2iOjQS-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-2iOjQS-4}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{NW3AzXtx-2iOjQS-3}{\\relax}\\nwenddeflinemarkup\n    numberOf :: Eq a => a -> [[a]] -> Int\n    numberOf x = sum . fmap (length . filter (== x))\n\\nwindexdefn{\\nwixident{partOne}}{partOne}{NW3AzXtx-2iOjQS-4}\\eatline\n\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\n\\newthought{Solve} Part Two.\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NW3AzXtx-4P9qKy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-4P9qKy-1}}}\\moddef{Part Two~{\\nwtagstyle{}\\subpageref{NW35miTa-4P9qKy-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwprevnextdefs{NW35miTa-4P9qKy-1}{\\relax}\\nwenddeflinemarkup\n\\nwlinkedidentc{partTwo}{NW3AzXtx-4P9qKy-1} :: \\nwlinkedidentc{Image}{NW3AzXtx-LSl4Q-1} -> String\n\\nwlinkedidentc{partTwo}{NW3AzXtx-4P9qKy-1} layers =\n  unlines . map (concatMap show) $\n    foldl decodeLayer (\\nwlinkedidentc{transparentLayer}{NW3AzXtx-dIQyV-1} 25 6) layers\n  where\n    decodeLayer :: \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1} -> \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1} -> \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1}\n    decodeLayer = zipWith (zipWith decodePixel)\n    decodePixel :: \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1} -> \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1} -> \\nwlinkedidentc{Pixel}{NW3AzXtx-2M5oYw-1}\n    decodePixel \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1} below = below\n    decodePixel above _ = above\n\\nwindexdefn{\\nwixident{partTwo}}{partTwo}{NW3AzXtx-4P9qKy-1}\\eatline\n\\nwused{\\\\{NW35miTa-15Rjc8-1}\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{transparentLayer}}{transparentLayer}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW3AzXtx-4P9qKy-1}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW3AzXtx-4P9qKy-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW3AzXtx-4P9qKy-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-4P9qKy-1}\\nwindexuse{\\nwixident{transparentLayer}}{transparentLayer}{NW3AzXtx-4P9qKy-1}\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\n\\newthought{Define a helper function} to create a transparent layer.\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NW3AzXtx-dIQyV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-dIQyV-1}}}\\moddef{A transparent layer~{\\nwtagstyle{}\\subpageref{NW3AzXtx-dIQyV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW3AzXtx-19Srvv-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{transparentLayer}{NW3AzXtx-dIQyV-1} :: Int -> Int -> \\nwlinkedidentc{Layer}{NW3AzXtx-LSl4Q-1}\n\\nwlinkedidentc{transparentLayer}{NW3AzXtx-dIQyV-1} width height = replicate height (replicate width \\nwlinkedidentc{Transparent}{NW3AzXtx-2M5oYw-1})\n\\nwindexdefn{\\nwixident{transparentLayer}}{transparentLayer}{NW3AzXtx-dIQyV-1}\\eatline\n\\nwused{\\\\{NW3AzXtx-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{transparentLayer}}{transparentLayer}}}\\nwidentuses{\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Transparent}}{Transparent}}}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW3AzXtx-dIQyV-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW3AzXtx-dIQyV-1}\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\n\\todo[inline]{Add some prose here.}\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NW3AzXtx-19Srvv-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW3AzXtx-19Srvv-1}}}\\moddef{Day08.hs~{\\nwtagstyle{}\\subpageref{NW3AzXtx-19Srvv-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nmodule AdventOfCode.Year2019.Day08 where\n\nimport AdventOfCode.Input (parseInput)\nimport AdventOfCode.TH (defaultMain, inputFilePath)\nimport Control.Applicative ((<|>))\nimport Data.Function (on)\nimport Data.List (minimumBy)\nimport Text.Trifecta (Parser, char, count, some, (<?>))\n\n\\LA{}Define a Pixel data type~{\\nwtagstyle{}\\subpageref{NW3AzXtx-2M5oYw-1}}\\RA{}\n\n\\LA{}Implement \\hs{Show} for \\code{}Pixel\\edoc{}~{\\nwtagstyle{}\\subpageref{NW3AzXtx-QyGx2-1}}\\RA{}\n\n\\LA{}Define a few convenient type aliases~{\\nwtagstyle{}\\subpageref{NW3AzXtx-LSl4Q-1}}\\RA{}\n\n\\nwlinkedidentc{main}{NW3AzXtx-19Srvv-1} :: IO ()\n\\nwlinkedidentc{main}{NW3AzXtx-19Srvv-1} = $(defaultMain)\n\ngetInput :: IO \\nwlinkedidentc{Image}{NW3AzXtx-LSl4Q-1}\ngetInput = parseInput (\\nwlinkedidentc{image}{NW3AzXtx-4aeb4o-1} 25 6) $(inputFilePath)\n\n\\LA{}Part One~{\\nwtagstyle{}\\subpageref{NW35miTa-2iOjQS-1}}\\RA{}\n\n\\LA{}Part Two~{\\nwtagstyle{}\\subpageref{NW35miTa-4P9qKy-1}}\\RA{}\n\n\\LA{}Parse an image~{\\nwtagstyle{}\\subpageref{NW3AzXtx-4aeb4o-1}}\\RA{}\n\n\\LA{}Parse a pixel~{\\nwtagstyle{}\\subpageref{NW3AzXtx-1aCFXy-1}}\\RA{}\n\n\\LA{}A transparent layer~{\\nwtagstyle{}\\subpageref{NW3AzXtx-dIQyV-1}}\\RA{}\n\\nwindexdefn{\\nwixident{main}}{main}{NW3AzXtx-19Srvv-1}\\eatline\n\\nwnotused{Day08.hs}\\nwidentdefs{\\\\{{\\nwixident{main}}{main}}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{image}}{image}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW3AzXtx-19Srvv-1}\\nwindexuse{\\nwixident{image}}{image}{NW3AzXtx-19Srvv-1}\\nwendcode{}\n\n\\nwixlogsorted{c}{{A transparent layer}{NW3AzXtx-dIQyV-1}{\\nwixd{NW3AzXtx-dIQyV-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Day01.g}{NW3RAD1b-3gOu99-1}{\\nwixd{NW3RAD1b-3gOu99-1}\\nwixd{NW3RAD1b-3gOu99-2}\\nwixd{NW3RAD1b-3gOu99-3}\\nwixd{NW3RAD1b-3gOu99-4}}}%\n\\nwixlogsorted{c}{{Day04.hs}{NW35miTa-15Rjc8-1}{\\nwixd{NW35miTa-15Rjc8-1}}}%\n\\nwixlogsorted{c}{{Day08.hs}{NW3AzXtx-19Srvv-1}{\\nwixd{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Define a few convenient type aliases}{NW3AzXtx-LSl4Q-1}{\\nwixd{NW3AzXtx-LSl4Q-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Define a Pixel data type}{NW3AzXtx-2M5oYw-1}{\\nwixd{NW3AzXtx-2M5oYw-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Generic solver}{NW35miTa-2ApJRg-1}{\\nwixd{NW35miTa-2ApJRg-1}\\nwixu{NW35miTa-15Rjc8-1}}}%\n\\nwixlogsorted{c}{{Implement \\hs{Show} for \\code{}Pixel\\edoc{}}{NW3AzXtx-QyGx2-1}{\\nwixd{NW3AzXtx-QyGx2-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Input}{NW35miTa-1GvnV-1}{\\nwixd{NW35miTa-1GvnV-1}\\nwixu{NW35miTa-15Rjc8-1}}}%\n\\nwixlogsorted{c}{{Parse a pixel}{NW3AzXtx-1aCFXy-1}{\\nwixd{NW3AzXtx-1aCFXy-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Parse an image}{NW3AzXtx-4aeb4o-1}{\\nwixd{NW3AzXtx-4aeb4o-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Part One}{NW35miTa-2iOjQS-1}{\\nwixd{NW35miTa-2iOjQS-1}\\nwixu{NW35miTa-15Rjc8-1}\\nwixd{NW3AzXtx-2iOjQS-1}\\nwixd{NW3AzXtx-2iOjQS-2}\\nwixd{NW3AzXtx-2iOjQS-3}\\nwixd{NW3AzXtx-2iOjQS-4}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Part Two}{NW35miTa-4P9qKy-1}{\\nwixd{NW35miTa-4P9qKy-1}\\nwixu{NW35miTa-15Rjc8-1}\\nwixd{NW3AzXtx-4P9qKy-1}\\nwixu{NW3AzXtx-19Srvv-1}}}%\n\\nwixlogsorted{i}{{\\nwixident{Black}}{Black}}%\n\\nwixlogsorted{i}{{\\nwixident{Image}}{Image}}%\n\\nwixlogsorted{i}{{\\nwixident{image}}{image}}%\n\\nwixlogsorted{i}{{\\nwixident{Layer}}{Layer}}%\n\\nwixlogsorted{i}{{\\nwixident{main}}{main}}%\n\\nwixlogsorted{i}{{\\nwixident{partOne}}{partOne}}%\n\\nwixlogsorted{i}{{\\nwixident{partTwo}}{partTwo}}%\n\\nwixlogsorted{i}{{\\nwixident{Pixel}}{Pixel}}%\n\\nwixlogsorted{i}{{\\nwixident{Row}}{Row}}%\n\\nwixlogsorted{i}{{\\nwixident{Transparent}}{Transparent}}%\n\\nwixlogsorted{i}{{\\nwixident{transparentLayer}}{transparentLayer}}%\n\\nwixlogsorted{i}{{\\nwixident{White}}{White}}%\n", "meta": {"hexsha": "7e305d8b69502c4a4c00e8bce81ab522337c6326", "size": 23895, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_src/tex/2019.tex", "max_stars_repo_name": "yurrriq/advent-of-code", "max_stars_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-11-04T10:32:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-05T07:36:22.000Z", "max_issues_repo_path": "_src/tex/2019.tex", "max_issues_repo_name": "yurrriq/aoc19", "max_issues_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_src/tex/2019.tex", "max_forks_repo_name": "yurrriq/aoc19", "max_forks_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-26T19:27:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-26T19:27:21.000Z", "avg_line_length": 77.0806451613, "max_line_length": 649, "alphanum_fraction": 0.7526679222, "num_tokens": 10373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593452091673, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.4248743997792714}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\n\\title{Marlin Diagram}\n\\date{July 2020}\n\n\\usepackage[x11names]{xcolor}\n\\usepackage[b4paper,margin=1.2in]{geometry}\n\\usepackage{tikz}\n\\usepackage{afterpage}\n\n\\newenvironment{rcases}\n  {\\left.\\begin{aligned}}\n  {\\end{aligned}\\right\\rbrace}\n\n\\begin{document}\n\n\\newcommand{\\cm}[1]{\\ensuremath{\\mathsf{cm}_{#1}}}\n\\newcommand{\\vcm}[1]{\\ensuremath{\\mathsf{vcm}_{#1}}}\n\\newcommand{\\s}{\\ensuremath{\\hat{s}}}\n\\newcommand{\\w}{\\ensuremath{\\hat{w}}}\n\\newcommand{\\x}{\\ensuremath{\\hat{x}}}\n\\newcommand{\\z}{\\ensuremath{\\hat{z}}}\n\\newcommand{\\za}{\\ensuremath{\\hat{z}_A}}\n\\newcommand{\\zb}{\\ensuremath{\\hat{z}_B}}\n\\newcommand{\\zc}{\\ensuremath{\\hat{z}_C\n}}\n\\newcommand{\\zm}{\\ensuremath{\\hat{z}_M}}\n\n\\newcommand{\\val}{\\ensuremath{\\mathsf{val}}}\n\\newcommand{\\row}{\\ensuremath{\\mathsf{row}}}\n\\newcommand{\\col}{\\ensuremath{\\mathsf{col}}}\n\\newcommand{\\rowcol}{\\ensuremath{\\mathsf{rowcol}}}\n\n\\newcommand{\\hval}{\\ensuremath{\\widehat{\\val}}}\n\\newcommand{\\hrow}{\\ensuremath{\\widehat{\\row}}}\n\\newcommand{\\hcol}{\\ensuremath{\\widehat{\\col}}}\n\\newcommand{\\hrowcol}{\\ensuremath{\\widehat{\\rowcol}}}\n\n\\newcommand{\\bb}{\\ensuremath{\\mathsf{b}}}\n\\newcommand{\\denom}{\\ensuremath{\\mathsf{denom}}}\n\n\\newcommand{\\sumcheckinner}{\\mathsf{inner}}\n\\newcommand{\\sumcheckouter}{\\mathsf{outer}}\n\n\\newcommand{\\Prover}{\\mathcal{P}}\n\\newcommand{\\Verifier}{\\mathcal{V}}\n\n\\newcommand{\\F}{\\mathbb{F}}\n\n\\newcommand{\\DomainA}{H}\n\\newcommand{\\DomainB}{K}\n\n\\newcommand{\\vPoly}[1]{\\ensuremath{v_{#1}}}\n\n\nThis diagram (on the following page) shows the interaction of the Marlin prover and verifier. It is similar to the diagrams in the paper (Figure 5 in Section 5 and Figure 7 in Appendix E, in the latest ePrint version), but with two changes: it shows not just the AHP but also the use of the polynomial commitments (the cryptography layer); and it aims to be fully up-to-date with the recent optimizations to the codebase. This diagram, together with the diagrams in the paper, can act as a ``bridge\" between the codebase and the theory that the paper describes.\n\n\\section{Glossary of notation}\n\\begin{table*}[htbp]\n  \\centering\n  \\begin{tabular}{c|c}\n    $\\F$ & the finite field over which the R1CS instance is defined \\\\\n     \\hline\n    $x$ & public input \\\\\n     \\hline\n    $w$ & secret witness \\\\\n     \\hline\n    $\\DomainA$ & variable domain \\\\\n     \\hline\n    $\\DomainB$ & matrix domain \\\\\n     \\hline\n    $X$ & domain sized for input (not including witness) \\\\\n     \\hline\n    $v_D(X)$ & vanishing polynomial over domain $D$ \\\\\n    \\hline\n    $u_D(X, Y)$ & bivariate derivative of vanishing polynomials over domain $D$\\\\\n     \\hline\n    $A, B, C$ & R1CS instance matrices \\\\\n    \\hline\n    $A^*, B^*, C^*$ &\n    \\begin{tabular}{@{}c@{}}shifted transpose of $A,B,C$ matries given by $M^*_{a,b} := M_{b,a} \\cdot u_\\DomainA(b,b) \\; \\forall a,b \\in \\DomainA$ \\\\ (optimization from Fractal, explained in Claim 6.7 of that paper) \\end{tabular} \\\\\n     \\hline\n    $\\hrow, \\hcol$ &\n    \\begin{tabular}{@{}c@{}} LDEs of (respectively) row positions and column positions of non-zero elements of any \\\\ linear combination of $A^*$, $B^*$, and $C^*$ (the choice of combination is irrelevant).\\end{tabular} \\\\\n    \\hline\n    ${\\hrowcol}$ &\n    \\begin{tabular}{@{}c@{}} LDE of the element-wise product of $\\row$ and $\\col$, given separately for efficiency  \\\\ (namely to allow this product to be part of a \\textit{linear} combination) \\end{tabular} \\\\\n    \\hline\n    $\\hval_{\\{A^*, B^*, C^*\\}}$ &\n    \\begin{tabular}{@{}c@{}} preprocessed polynomials containing LDEs of \\\\ the values of non-zero elements of any linear combination of $A^*$, $B^*$, and $C^*$. \\\\ That is, if $\\kappa$ is the $k$-th element of $\\DomainB$, then $(\\sum_M \\eta_M \\hval_{M^*})(\\kappa)$ is the \\\\$k$-th non-zero entry of $\\sum_M \\eta_M M^*$, for arbitrary $\\eta_{\\{A, B, C\\}} \\in \\F$.\\end{tabular} \\\\\n     \\hline\n    $\\Prover$ & prover \\\\\n     \\hline\n    $\\Verifier$ & verifier \\\\\n     \\hline\n    $\\Verifier^{p}$ &\n    \t\\begin{tabular}{@{}c@{}} $\\Verifier$ with ``oracle\" access to polynomial $p$ (via commitments provided \\\\ by the indexer, later opened as necessary by $\\Prover$) \\end{tabular}\\\\\n    \\hline\n    $\\bb$ & bound on the number of queries \\\\\n    \\hline\n    $r_M(X, Y)$ & an intermediate polynomial defined by $r_M(X, Y) = M^*(Y,X)$\\\\\n    \\hline\n  \\end{tabular}\n\\end{table*}\n\n\\afterpage{%\n\\newgeometry{margin=0.2in}\n\n\\section{Diagram}\n\n\\centering\n\\begin{tikzpicture}[scale=0.95, every node/.style={scale=0.95}]\n\n\\tikzstyle{lalign} = [minimum width=3cm,align=left,anchor=west]\n\\tikzstyle{ralign} = [minimum width=3cm,align=right,anchor=east]\n\n\\node[lalign] (prover) at (-3,27.3) {%\n$\\Prover(\\F, \\DomainA, \\DomainB, A, B, C, x, w)$\n};\n\n\\node[ralign] (verifier) at (16.2,27.3) {%\n$\\Verifier^{\\hrow, \\hcol, \\hrowcol, \\hval_{A^*}, \\hval_{B^*}, \\hval_{C^*}}(\\F, \\DomainA, \\DomainB, x)$\n};\n\n\\draw [line width=1.0pt] (-3,27.0) -- (16,27.0);\n\n\\node[lalign] (prover1) at (-3,26.1) {%\n$z := (x, w), z_A := Az, z_B := Bz$ \\\\\nsample $\\w(X) \\in \\F^{<|w|+\\bb}[X]$ and $\\za(X), \\zb(X) \\in \\F^{<|\\DomainA|+\\bb}[X]$ \\\\\nsample mask poly $\\s(X) \\in \\F^{<3|\\DomainA|+2\\bb-2}[X]$ such that $\\sum_{\\kappa \\in \\DomainA}\\s(\\kappa) = 0$\n};\n\n\\draw [->] (-2,24.8) -- node[midway,fill=white] {commitments $\\cm{\\w}, \\cm{\\za}, \\cm{\\zb}, \\cm{\\s}$} (15,24.8);\n\n\\node[ralign] (verifier1) at (16,24.0) {%\n$\\eta_A, \\eta_B, \\eta_C \\gets \\F$ \\\\\n$\\alpha \\gets \\F \\setminus \\DomainA$\n};\n\n\\draw [->] (15,23.3) -- node[midway,fill=white] {$\\eta_A, \\eta_B, \\eta_C, \\alpha \\in \\F$} (-2,23.3);\n\n\\node[lalign] (prover2) at (-3,22.5) {%\ncompute $t(X) := \\sum_M \\eta_M r_M(\\alpha, X)$\n};\n\n\\draw (-2.9,22.0) rectangle (15.9,3.8);\n\n\\node (sc1label) at (6.5,21.7) {%\n\\textbf{sumcheck for} $\\s(X) + u_H(\\alpha, X) \\left(\\sum_M \\eta_M \\zm(X)\\right) - t(X)\\z(X)$ \\textbf{ over } $\\DomainA$\n};\n\n\\node[lalign] (prover3) at (-2,20.7) {%\nlet $\\zc(X) := \\za(X) \\cdot \\zb(X)$ \\\\\nfind $g_1(X) \\in \\F^{|\\DomainA|-1}[X]$ and $h_1(X)$ such that \\\\\n$s(X)+u_H(\\alpha, X)(\\sum_M \\eta_M \\zm(X)) - t(X)\\z(X) = h_1(X)\\vPoly{\\DomainA}(X) + Xg_1(X)$ \\hspace{0.3cm} $(*)$\n};\n\n\\draw [->] (-1,19.5) -- node[midway,fill=white] {commitments $\\cm{t}, \\cm{g_1}, \\cm{h_1}$} (14,19.5);\n\n\\node[ralign] (verifier2) at (15.4,19.1) {%\n$\\beta \\gets \\F \\setminus \\DomainA$\n};\n\n\\draw [->] (14,18.7) -- node[midway,fill=white] {$\\beta \\in \\F$} (-1,18.7);\n\n\\draw (-0.85,18.2) rectangle (13.85,7.6);\n\n\\node (sc2label) at (6.5,17.6) {%\n\\textbf{sumcheck for } $\\sum\\limits_{M \\in \\{A, B, C\\}} \\eta_M \\frac{\\vPoly{\\DomainA}(\\beta) \\vPoly{\\DomainA}(\\alpha)\\hval_{M^*}(X)}{\\color{purple}(\\beta-\\hrow(X))(\\alpha-\\hcol(X))} $ \\textbf{ over } $\\DomainB$\n};\n\n\\node[align=center] (mid1) at (6.5, 15) {%\n$\\begin{aligned} \n\\text{let } {\\color{purple} \\denom(X)} &{}:= (\\beta - \\hrow(X)) (\\alpha - \\hcol(X)) \\\\\n                                       &{}= {\\color{gray}\\alpha\\beta} - {\\color{gray}\\alpha}\\hrow(X) - {\\color{gray}\\beta}\\hcol(X) + \\hrowcol(X) \\text{ (over $\\DomainB$)}\\\\\\\\\n    \\text{ let } {\\color{orange} a(X)} &{}:= {\\color{gray} \\vPoly{\\DomainA}(\\beta) \\vPoly{\\DomainA}(\\alpha)} \\sum\\limits_{M \\in \\{A, B, C\\}} \\eta_M \\hval_{M^*}(X)\n\\\\\\\\\n    \\text{ let } {\\color{Green4} b(X)} &{}:= {\\color{purple} \\denom(X)}\\\\\\\\\n\\end{aligned}$\n};\n\n\\node[lalign] (prover4) at (-0.75,12.2) {%\nfind $g_2(X) \\in \\F^{|\\DomainB|-1}[X]$ and $h_2(X)$ s.t. \\\\\n$h_2(X)\\vPoly{\\DomainB}(X) = {\\color{orange} a(X)} - {\\color{Green4} b(X)} (Xg_2(X)+t(\\beta)/|\\DomainB|)$ \\hspace{0.3cm} $(**)$\n};\n\n\\draw [->] (0,11.2) -- node[midway,fill=white] {commitments $\\cm{g_2}, \\cm{h_2}$} (13,11.2);\n\n\\draw [->] (13,10.5) -- node[midway,fill=white] {$\\gamma \\in \\F$} (0,10.5);\n\n\\node[ralign] (verifier3) at (14.5, 10.9) {%\n$\\gamma \\gets \\F$\n};\n\n\\draw[dashed] (1.5,10.0) rectangle (11.5,7.8);\n\n\\node[align=center] (mid4) at (6.5, 8.9) {%\nTo verify $(**)$, $\\Verifier$ will need to check the following: \\\\[10pt]\n$ \\underbrace{{\\color{orange} a({\\color{black} \\gamma})} - {\\color{Green4} b({\\color{black} \\gamma})} {\\color{gray} (\\gamma g_2(\\gamma) + t(\\beta) / |\\DomainB|) - \\vPoly{\\DomainB}(\\gamma)} h_2(\\gamma)}_{\\sumcheckinner(\\gamma)} \\stackrel{?}{=} 0 $\n};\n\n\\node[ralign] (verifier3) at (15.4, 6.9) {%\nCompute $\\x(X) \\in \\F^{<|x|}[X]$ from input $x$\n};\n\n\\draw[dashed] (-2.7,7.4) rectangle (15.7,4.2);\n\n\\node[align=center] (mid5) at (6.5, 5.3) {%\nTo verify $(*)$, $\\Verifier$ will need to check the following: \\\\[10pt]\n$ \\underbrace{s(\\beta) + {\\color{gray} v_H(\\alpha, \\beta)} ({\\color{gray} \\eta_A} \\za(\\beta) + {\\color{gray} \\eta_C\\zb(\\beta)} \\za(\\beta) + {\\color{gray} \\eta_B\\zb(\\beta)}) - {\\color{gray} t(\\beta) \\vPoly{X}(\\beta)} \\w(\\beta) - {\\color{gray} t(\\beta) \\x(\\beta)} - {\\color{gray} \\vPoly{\\DomainA}(\\beta)} h_1(\\beta) - {\\color{gray} \\beta g_1(\\beta)}}_{\\sumcheckouter(\\beta)} \\stackrel{?}{=} 0 $\n};\n\n\\node[lalign] (prover5) at (-3,2.9) {%\n$v_{g_2} := g_2(\\gamma)$ \\\\[3pt]\n$v_{g_1} := g_1(\\beta), v_{\\zb} := \\zb(\\beta), v_{t} := t(\\beta)$\n};\n\n\\draw [->] (-2,1.9) -- node[midway,fill=white] {$v_{g_2}, v_{g_1}, v_{\\zb}, v_{t}$} (15,1.9);\n\n\\node[align=center] (mid7) at (6.5,0.8) {%\nuse index commitments $\\hrow, \\hcol, \\hrowcol, \\hval_{\\{A^*, B^*, C^*\\}}$, commitment $\\cm{h_2}$, {\\color{gray} and evaluations $g_2(\\gamma),t(\\beta)$} \\\\\nto construct virtual commitment $\\vcm{\\sumcheckinner}$\n};\n\n\\node[align=center] (mid8) at (6.5,-0.5) {%\nuse commitments $\\cm{\\s}, \\cm{\\za}, \\cm{\\w}, \\cm{h_1}$ {\\color{gray} and evaluations $\\zb(\\beta), t(\\beta), g_1(\\beta)$} \\\\\nto construct virtual commitment $\\vcm{\\sumcheckouter}$\n};\n\n\\node[ralign] (verifier4) at (16,-1.4) {%\n$\\xi_1, \\dots, \\xi_5 \\gets F$\n};\n\n\\draw [->] (15,-2.1) -- node[midway,fill=white] {$\\xi_1, \\dots, \\xi_5$} (-2,-2.1);\n\n\\node[lalign] (prover6) at (-3,-3.6) {%\nuse $\\mathsf{PC}.\\mathsf{Prove}$ with randomness $\\xi_1, \\dots, \\xi_5$ to \\\\\nconstruct a batch opening proof $\\pi$ of the following: \\\\\n$(\\cm{g_2}, {\\color{red} \\vcm{\\sumcheckinner}})$ at $\\gamma$ evaluate to $(v_{g_2}, {\\color{red} 0})$ \\hspace{0.3cm} ${\\color{red} (**)}$ \\\\\n$(\\cm{g_1}, \\cm{\\zb}, \\cm{t}, {\\color{red} \\vcm{\\sumcheckouter}})$ at $\\beta$ evaluate to $(v_{g_1}, v_{\\zb}, v_{t}, {\\color{red} 0})$ \\hspace{0.3cm} ${\\color{red} (*)}$ \\\\\n};\n\n\\draw [->] (-2,-4.7) -- node[midway,fill=white] {$\\pi$} (15,-4.7);\n\n\\node[ralign] (verifier5) at (16,-6.0) {%\nverify $\\pi$ with $\\mathsf{PC}.\\mathsf{Verify}$, using randomness $\\xi_1, \\dots, \\xi_5$, \\\\\nevaluations $v_{g_2}, v_{g_1}, v_{\\zb}, v_{t}$, and \\\\\ncommitments $\\cm{g_2},\\vcm{\\sumcheckinner}, \\cm{g_1}, \\cm{\\zb}, \\cm{t}, \\vcm{\\sumcheckinner}$\n};\n\n\\end{tikzpicture}\n\n\\clearpage\n\\restoregeometry\n}\n\n\n\\end{document}\n", "meta": {"hexsha": "0e53437fff0807f174b8d2102511aaa39a666acc", "size": 10605, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diagram/diagram.tex", "max_stars_repo_name": "nirvantyagi/marlin", "max_stars_repo_head_hexsha": "2f2bbefe8cb453888e522a8857e7279d88b06599", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": 84, "max_stars_repo_stars_event_min_datetime": "2019-09-18T12:52:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-28T18:53:30.000Z", "max_issues_repo_path": "diagram/diagram.tex", "max_issues_repo_name": "nirvantyagi/marlin", "max_issues_repo_head_hexsha": "2f2bbefe8cb453888e522a8857e7279d88b06599", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": 32, "max_issues_repo_issues_event_min_datetime": "2020-11-12T06:02:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-27T01:18:22.000Z", "max_forks_repo_path": "diagram/diagram.tex", "max_forks_repo_name": "nirvantyagi/marlin", "max_forks_repo_head_hexsha": "2f2bbefe8cb453888e522a8857e7279d88b06599", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2019-10-27T17:09:30.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-02T16:13:36.000Z", "avg_line_length": 40.4770992366, "max_line_length": 561, "alphanum_fraction": 0.6060348892, "num_tokens": 4193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4248743982569049}}
{"text": "% This document is part of the emcee3 project.\n% Copyright 2015 Dan Foreman-Mackey\n%\n%  RULES OF THE GAME\n%\n%  * 80 characters\n%  * line breaks at the ends of sentences\n%  * eqnarrys ONLY\n%\n\n\\documentclass[12pt,preprint]{aastex}\n\n\\pdfoutput=1\n\n\\usepackage{color,hyperref}\n\\definecolor{linkcolor}{rgb}{0,0,0.5}\n\\hypersetup{colorlinks=true,linkcolor=linkcolor,citecolor=linkcolor,\n            filecolor=linkcolor,urlcolor=linkcolor}\n\\usepackage{url}\n\\usepackage{amssymb,amsmath}\n\\usepackage{subfigure}\n\\usepackage{booktabs}\n\n\\usepackage{natbib}\n\\bibliographystyle{apj}\n\n% Typography\n\\newcommand{\\project}[1]{\\textsl{#1}}\n\\newcommand{\\license}{MIT License}\n\\newcommand{\\paper}{\\textsl{Article}}\n\\newcommand{\\foreign}[1]{\\emph{#1}}\n\\newcommand{\\etal}{\\foreign{et\\,al.}}\n\\newcommand{\\etc}{\\foreign{etc.}}\n\n\\newcommand{\\figref}[1]{\\ref{fig:#1}}\n\\newcommand{\\Fig}[1]{\\figurename~\\figref{#1}}\n\\newcommand{\\fig}[1]{\\Fig{#1}}\n\\newcommand{\\figlabel}[1]{\\label{fig:#1}}\n\\newcommand{\\Tab}[1]{Table~\\ref{tab:#1}}\n\\newcommand{\\tab}[1]{\\Tab{#1}}\n\\newcommand{\\tablabel}[1]{\\label{tab:#1}}\n\\newcommand{\\Eq}[1]{Equation~(\\ref{eq:#1})}\n\\newcommand{\\eq}[1]{\\Eq{#1}}\n\\newcommand{\\eqalt}[1]{Equation~\\ref{eq:#1}}\n\\newcommand{\\eqlabel}[1]{\\label{eq:#1}}\n\\newcommand{\\sectionname}{Section}\n\\newcommand{\\Sect}[1]{\\sectionname~\\ref{sect:#1}}\n\\newcommand{\\sect}[1]{\\Sect{#1}}\n\\newcommand{\\sectalt}[1]{\\ref{sect:#1}}\n\\newcommand{\\App}[1]{Appendix~\\ref{sect:#1}}\n\\newcommand{\\app}[1]{\\App{#1}}\n\\newcommand{\\sectlabel}[1]{\\label{sect:#1}}\n\n% Algorithms\n\\usepackage{algorithm}\n\\usepackage{algorithmicx}\n\\usepackage[]{algpseudocode}\n\\newcommand*\\Let[2]{\\State #1 $\\gets$ #2}\n\\newcommand{\\Alg}[1]{Algorithm~\\ref{alg:#1}}\n\\newcommand{\\alg}[1]{\\Alg{#1}}\n\\newcommand{\\alglabel}[1]{\\label{alg:#1}}\n\n% To-do\n\\newcommand{\\todo}[3]{{\\color{#2}\\emph{#1}: #3}}\n\\newcommand{\\dfmtodo}[1]{\\todo{DFM}{red}{#1}}\n\n% Response to referee\n\\definecolor{mygreen}{rgb}{0, 0.50196, 0}\n\\newcommand{\\response}[1]{#1}\n% \\newcommand{\\response}[1]{{\\color{mygreen} {\\bf #1}}}\n\n% Notation for this paper.\n\\newcommand{\\T}{{\\ensuremath{\\mathrm{T}}}}\n\\newcommand{\\bvec}[1]{{\\ensuremath{\\boldsymbol{#1}}}}\n\\newcommand{\\lnprob}{{\\ensuremath{\\mathcal{L}}}}\n\\newcommand{\\pos}{{\\bvec{q}}}\n\\newcommand{\\mom}{{\\bvec{p}}}\n\\newcommand{\\mass}{{\\bvec{M}}}\n\\newcommand{\\normal}[2]{{\\ensuremath{\\mathcal{N}(#1,\\,#2)}}}\n\n\\begin{document}\n\n\\title{%\n    Affine-invariant Hamiltonian Monte Carlo\n}\n\n\\newcommand{\\uw}{2}\n\\newcommand{\\sagan}{3}\n\\author{%\n    Daniel~Foreman-Mackey\\altaffilmark{1,\\uw,\\sagan}\n}\n\\altaffiltext{1}         {To whom correspondence should be addressed:\n                          \\url{danfm@uw.edu}}\n\\altaffiltext{\\uw}       {Astronomy Department, University of Washington,\n                          Seattle, WA 98195}\n\\altaffiltext{\\sagan}    {Sagan Fellow}\n\n\n\\begin{abstract}\n\nHamiltonian Monte Carlo (HMC) sampling is an efficient method for drawing\nsamples from a probability density when the gradient of the probability with\nrespect to the parameters can be computed.\nWe present a simple but effective affine-invariant HMC method that uses an\nensemble of samplers to adaptively update the mass matrix.\nWe demonstrate the performance of this method on some simple test cases and\ncompare its computational cost on a real data analysis problem in exoplanet\nastronomy.\nA well-tested and efficient Python implementation is released alongside this\nnote.\n\n\\end{abstract}\n\n\\keywords{%\nmethods: data analysis\n---\nmethods: statistical\n}\n\n\\section{Introduction}\n\n% Text. \\citep{Foreman-Mackey:2013}\n% Adaptive: \\citet{Girolami:2011, Wang:2013, Hoffman:2014}\n% \\section{Hamiltonian Monte Carlo}\n\nPseudocode for the standard implementation of the Hamiltonian Monte Carlo\n(HMC) algorithm \\citep{Neal:2011} is shown in \\alg{basic-hmc}.\nIn this implementation, there are $(D^2 + D) / 2 + 2$ tuning parameters, where\n$D$ is the dimension of the problem.\nOf these parameters, $(D^2 + D) / 2$ are the elements of the positive\ndefinite mass matrix \\bvec{M} and the other 2 are the step size $\\epsilon$ and\nthe number of steps $L$.\nMost practical applications of HMC fix the mass matrix to a constant (often\nset to 1) times the identity and reduce the tuning to only the two parameters\n$\\epsilon$ and $L$.\nMethods have been developed to automatically tune these parameters \\citep[for\nexample][]{Hoffman:2014}.\n\nThe major problem with fixing the mass matrix to be diagonal is that the\n\\emph{units} of the input space can change the performance of the algorithm.\nFor example, sampling from a Gaussian with different variances in the\ndifferent dimensions or covariance between the parameters will be less\nefficient than sampling from an isotropic Gaussian.\nIt has been demonstrated that samplers that satisfy affine invariance can be\nvery useful for real problems in science where the dynamic range of parameters\ncan vary by orders of magnitude \\citep{Goodman:2010, Foreman-Mackey:2013}.\nIt turns out that HMC can be simply adapted to an affine-invariant algorithm.\n\nThe affine-invariant samplers proposed by \\citet{Goodman:2010} sample the\ntarget density by evolving an \\emph{ensemble} of parallel MCMC chains (called\n``walkers'') where the instantaneous proposal for one walker is conditioned on\nthe current locations of the other walkers, the \\emph{complementary ensemble}.\nIf the move preserves the conditional distribution of the target walker given\nthe complementary ensemble, it will also preserve the joint distribution of\nthe ensemble.\nThe intuition from these proposals can be incorporated into HMC to derive an\naffine-invariant algorithm.\n\n\n\n\n\\begin{algorithm}\n    \\caption{Standard implementation of a single HMC step \\alglabel{basic-hmc}}\n    \\begin{algorithmic}\n        \\Function{HMCStep}{$\\lnprob(\\pos),\\,\\pos_t,\\,\\mass,\\,\\epsilon,\\,L$}\n        \\State $\\mom_t \\sim \\normal{\\bvec{0}}{\\mass}$\n            \\Comment{sample the initial momentum exactly}\n        \\Let{\\pos}{$\\pos_t$}\n        \\State\n        \\Let{\\mom}{$\\mom_t + \\frac{\\epsilon}{2}\\,\\nabla\\lnprob(\\pos)$}\n            \\Comment{run $L$ steps of leapfrog integration}\n        \\For{$l \\gets 1 \\textrm{ to } L$}\n            \\Let{\\pos}{$\\pos + \\epsilon\\,\\mass^{-1}\\,\\mom$}\n            \\If{$l < L$}\n                \\Let{\\mom}{$\\mom + \\epsilon\\,\\nabla\\lnprob(\\pos)$}\n            \\EndIf\n        \\EndFor\n        \\Let{\\mom}{$\\mom + \\frac{\\epsilon}{2}\\,\\nabla\\lnprob(\\pos)$}\n            \\Comment{synchronize the momentum and position}\n        \\State\n        \\State{$r \\sim \\mathcal{U}(0, 1)$}\n        \\If{$r < \\exp\\left[\\lnprob(\\pos) - \\frac{1}{2}\\mom^T\\mass^{-1}\\mom\n            - \\lnprob(\\pos_t)+\\frac{1}{2}{\\mom_t}^T\\mass^{-1}\\mom_t \\right]$}\n            \\State\\Return{$\\pos$}   \\Comment{accept}\n        \\Else\n            \\State\\Return{$\\pos_t$} \\Comment{reject}\n        \\EndIf\n        \\EndFunction\n    \\end{algorithmic}\n\\end{algorithm}\n\n\n\\begin{algorithm}\n    \\caption{Affine-invariant HMC \\alglabel{ai-hmc}}\n    \\begin{algorithmic}\n\\Function{AIHMCStep}{$\\lnprob(\\pos),\\,\\{\\pos_k\\}_{k=1}^K,\\,\\epsilon,\\,L$}\n\\For{$k \\gets 1 \\textrm{ to } K$}\n    \\Let{${\\mass_k}^{-1}$}{$\\mathrm{Cov}(\\pos_{[k]})$}\n        \\Comment{estimate the empirical mass matrix}\n    \\State $\\mom_k \\sim \\normal{\\bvec{0}}{\\mass_k}$\n        \\Comment{sample the initial momentum exactly}\n    \\State\n    \\Let{$\\mom^\\prime$}{$\\mom_k$} \\Comment{save the initial coordinates}\n    \\Let{$\\pos^\\prime$}{$\\pos_k$}\n    \\State\n    \\Let{$\\mom^\\prime$}{$\\mom^\\prime +\n                \\frac{\\epsilon}{2}\\,\\nabla\\lnprob(\\pos^\\prime)$}\n        \\Comment{run $L$ steps of leapfrog integration}\n    \\For{$l \\gets 1 \\textrm{ to } L$}\n        \\Let{$\\pos^\\prime$}{$\\pos^\\prime +\n                \\epsilon\\,{\\mass_k}^{-1}\\,\\mom^\\prime$}\n        \\If{$l < L$}\n            \\Let{$\\mom^\\prime$}{$\\mom^\\prime +\n                \\epsilon\\,\\nabla\\lnprob(\\pos^\\prime)$}\n        \\EndIf\n    \\EndFor\n    \\Let{$\\mom^\\prime$}{$\\mom^\\prime +\n                \\frac{\\epsilon}{2}\\,\\nabla\\lnprob(\\pos^\\prime)$}\n        \\Comment{synchronize the momentum and position}\n    \\State\n    \\State{$r \\sim \\mathcal{U}(0, 1)$}\n    \\If{$r < \\exp\\left[\n        \\lnprob(\\pos^\\prime)\n        - \\frac{1}{2}{\\mom^\\prime}^T{\\mass_k}^{-1}\\mom^\\prime\n        - \\lnprob(\\pos_k)\n        + \\frac{1}{2}{\\mom_k}^T{\\mass_k}^{-1}\\mom_k \\right]$}\n        \\Let{$\\pos_k$}{$\\pos^\\prime$}   \\Comment{accept}\n    \\Else\n        \\Let{$\\pos_k$}{$\\pos_k$}   \\Comment{reject}\n    \\EndIf\n\\EndFor\n\\State\\Return{$\\{ \\pos_k \\}_{k=1}^K$}\n\\EndFunction\n    \\end{algorithmic}\n\\end{algorithm}\n\n\\clearpage\n\\bibliography{emcee-hmc}\n\\clearpage\n\n\\end{document}\n", "meta": {"hexsha": "438d28785490402d7c06e0882b85b73d140d69e1", "size": 8523, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/hmc/ms.tex", "max_stars_repo_name": "dfm/emcee3", "max_stars_repo_head_hexsha": "0fa3be8cdb9af0308125db328f87f162d0a92a19", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2015-04-10T15:33:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-26T02:59:20.000Z", "max_issues_repo_path": "documents/hmc/ms.tex", "max_issues_repo_name": "dfm/emcee3", "max_issues_repo_head_hexsha": "0fa3be8cdb9af0308125db328f87f162d0a92a19", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2016-02-12T01:44:02.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-24T11:39:11.000Z", "max_forks_repo_path": "documents/hmc/ms.tex", "max_forks_repo_name": "dfm/emcee3", "max_forks_repo_head_hexsha": "0fa3be8cdb9af0308125db328f87f162d0a92a19", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-04-20T06:42:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-21T10:04:43.000Z", "avg_line_length": 35.2190082645, "max_line_length": 79, "alphanum_fraction": 0.664906723, "num_tokens": 2694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.42487439499875945}}
{"text": "%auto-ignore\n\\providecommand{\\MainFolder}{..}\n\\documentclass[\\MainFolder/Text.tex]{subfiles}\n\\begin{document}\n\\section{Twisted IBL-infinity-structure for spheres\n%The $\\IBL$-structure on the homology of $\\OPQ_{110}^\\PMC$.\n}\n\\label{Section:HomSphere}\nLet $e_0$, $e_1$ be the basis of $\\Harm(\\Sph{n})[1]$ defined by\n\\begin{equation*} \\label{Eq:BasisOfHarm}\n e_0 \\coloneqq \\NOne \\coloneqq \\SuspU 1, \\quad e_1\\coloneqq\\NVol \\coloneqq \\frac{1}{V}\\SuspU\\Vol.\n\\end{equation*}\nThe degrees satisfy\n$$ \\Abs{\\NOne} = -1, \\quad \\Abs{\\NVol} = n-1. $$\nThe matrix of the pairing $\\Pair$ with respect to the basis $e_0$, $e_1$ reads\n$$ \\Pair=\\begin{pmatrix}\n 0 & 1 \\\\\n (-1)^{n} & 0\n\\end{pmatrix}. $$\nThe dual basis $e^0$, $e^1$ to $e_0$, $e_1$ with respect to $\\Pair$ is thus\n$$ e^0= \\NVol,\\quad e^1 = (-1)^{n} \\NOne. $$\nIt follows that the matrix $(T^{ij})$ from~\\eqref{Eq:PropagatorT} satisfies\n\\begin{equation*} \n%\\label{Eq:KerIdMatrix}\n (T^{ij}) = - \\begin{pmatrix}\n0 & 1 \\\\\n1 & 0\n\\end{pmatrix}.\n\\end{equation*}\n%This data will be used below to write down the canonical operations $\\OPQ_{210}$, $\\OPQ_{120}$ (see Def.~\\ref{Def:CanonicaldIBL}).\n\nWe clearly have\n$$ \\CRedDBCyc \\Harm(\\Sph{1}) = \\Bigl\\{ \\sum_{k=1}^\\infty c_k \\NVol^{k*} \\BigMid c_k \\in \\R \\Bigr\\}, $$\nwhere $\\NVol^{k*}$ is the dual to the cyclic word $\\NVol^k = \\NVol \\dots \\NVol$ of length $k$. Observe that the cyclic symmetry gives\n\\begin{equation*}\n\\NVol^i = (-1)^{(n-1)(i-1)} \\NVol^i\\quad\\text{for all }i\\ge 1.\n\\end{equation*}\nTherefore, $\\NVol^{i*} = 0$ holds if both $n$ and $i$ are even.\n\nFor $n\\ge 2$, the vector space $\\Harm(\\Sph{n})$ is connected and simply-connected, and Proposition~\\ref{Prop:SimplCon} implies that there are no long reduced cyclic cochains (i.e., we have only finite sums of $\\NVol^{k*}$'s). \n\n\nThe product $\\mu_2: \\Harm[1]^{\\otimes 2} \\rightarrow \\Harm[1]$ from \\eqref{Eq:HarmProd} has the following matrix with respect to the basis $\\NOne$, $\\NVol$:\n\\begin{equation*} \n%\\label{Eq:BinaryOperatorSphere}\n \\mu_2 = \\begin{pmatrix} \\NOne &  \\NVol \\\\ (-1)^n \\NVol & 0 \\end{pmatrix}.\n\\end{equation*}\nBecause $\\mu_2(\\NVol, \\NVol) = 0$, we get\n\\begin{equation*}\n%\\label{Eq:RedHIBLSn}\n\\HIBL^\\MC(\\RedCycC(\\Harm(\\Sph{n})))[1] = \\begin{cases}\n                        \\langle \\Susp \\NVol^{i*} \\mid i \\ge 1 \\rangle & \\text{for }n\\ge 3\\text{ odd}, \\\\\n                        \\langle  \\Susp \\NVol^{2i-1*} \\mid i\\ge 1 \\rangle & \\text{for }n\\text{ even},\\\\\n \\bigl\\{ \\Susp\\sum_{k=1}^\\infty c_k \\NVol^{k*} \\mid c_k\\in \\R \\bigr\\} & \\text{for }n=1. \n\\end{cases}\n\\end{equation*}\nBecause we are in the strictly unital and strictly augmented case, we obtain\n\\begin{equation} \\label{Eq:HIBLSn}\n\\HIBL^\\MC(\\CycC)[1] = \\begin{cases}\n\\langle \\Susp \\NVol^{i*}, \\Susp \\NOne^{2j-1*} \\mid i, j \\ge 1\\rangle & \\text{for }n\\ge 3 \\text{ odd}, \\\\\n\\langle \\Susp \\NVol^{2 i-1*}, \\Susp \\NOne^{2j-1*} \\mid i, j \\ge 1\\rangle &\\text{for }n\\text{ even}, \\\\\n \\bigl\\langle \\Susp\\sum_{k=1}^\\infty c_k \\NVol^{k*}, \\Susp \\NOne^{2j-1*}\\mid c_k\\in \\R, j \\ge 1\\bigr\\rangle & \\text{for }n=1. \n\\end{cases}\n\\end{equation}\n%Note that the canonical Maurer-Cartan element $\\MC$ satisfies\n%$$ (-1)^n \\MC_{10}(\\Susp \\NOne \\NVol \\NOne) = \\MC_{10}(\\Susp\\NVol\\NOne\\NOne) = \\MC_{10}(\\Susp\\NOne\\NOne\\NVol) = (-1)^{n-2}. $$\nThe canonical $\\IBL$-operations can be written as\n\\begin{align*}\n\\OPQ_{210}(\\Susp^2 \\psi_1 \\otimes \\psi_2)(\\Susp \\omega) &= \\begin{multlined}[t]-\\sum \\varepsilon(\\omega\\mapsto \\omega^1 \\omega^2)[(-1)^{(n-1)\\Abs{\\omega^1}} \\psi_1(e_0 \\omega^1) \\\\ \\psi_2(e_1 \\omega^2) + (-1)^{\\Abs{\\omega_1}}\\psi_1(e_1 \\omega^1) \\psi_2(e_0 \\omega^2)], \\end{multlined} \\\\\n\\OPQ_{120}(\\Susp \\psi)(\\Susp^2 \\omega_1\\otimes \\omega_2) & = \\begin{multlined}[t] - \\frac{1}{2} \\sum \\varepsilon(\\omega_1\\mapsto \\omega_{1}^{1}) \\varepsilon(\\omega_2\\mapsto \\omega_{2}^{1}) [(-1)^{(n-1)\\Abs{\\omega_{1}^{1}}} \\\\ \\psi(e_0 \\omega_{1}^{1} e_1 \\omega_{2}^{1})  + (-1)^{\\Abs{\\omega_{1}^{1}}}\\psi(e_1 \\omega_{1}^{1} e_0 \\omega_{2}^{1})] \\end{multlined}\n\\end{align*}\nfor all $\\psi$, $\\psi_1$, $\\psi_2 \\in \\CDBCyc\\Harm$ and generating words $\\omega$, $\\omega_1$, $\\omega_2\\in \\BCyc\\Harm$. For all $k$, $k_1$, $k_2 \\ge 1$, we have\n$$ \\OPQ_{210}((\\Susp \\NVol^{k_1*}) \\cdot (\\Susp \\NVol^{k_2*})) = 0\\quad\\text{and}\\quad \\OPQ_{120}(\\Susp \\NVol^{k*}) = 0$$\nbecause both $\\OPQ_{210}$ and $\\OPQ_{120}$ feed $\\NOne$ into their inputs. For the \\emph{canonically twisted reduced $\\IBL$-algebra}, this implies the following:\n$$ \\IBL\\bigl(\\HIBL^\\MC(\\RedCycC)\\bigr) = \\bigl(\\HIBL^\\MC(\\RedCycC), \\OPQ_{210} \\equiv 0, \\OPQ_{120} \\equiv 0 \\bigr)\\quad \\text{for all }n\\in \\N.  $$\nBy Proposition~\\ref{Prop:Ones}, the only possibly non-zero relation  of $\\IBL(\\HIBL^\\MC(\\CycC))$ is   \n$$\\begin{aligned}\n& \\OPQ_{210}(\\Susp \\NOne^* \\otimes \\Susp \\NVol^{k*}) \\\\[\\jot]\n&\\qquad = (-1)^{n-2} \\Susp (\\NVol^{k*} \\circ \\iota_\\NVol) \\\\ \n&\\qquad = (-1)^{n-2}\\bigl(\\sum_{i=1}^{k-1} (-1)^{i \\Abs{\\NVol}}\\bigr)\\Susp\\NVol^{k-1 *}\n= \\begin{cases}\n   -(k-1) \\Susp \\NVol^{k-1*} & \\text{for }n\\text{ odd},\\\\\n    0 & \\text{for }n\\text{ even}.\n  \\end{cases}\\end{aligned}$$\nThe reason for $0$ for even $n$ is that either $k$ is odd, in which case $\\sum_{i=1}^{k-1} (-1)^i = 0$, or $k$ is even, in which case $\\NVol^{k*} = 0$. Therefore, for the \\emph{canonically twisted $\\IBL$-algebra}, we have\n\\begin{equation*}\n%\\label{Eq:CanonTwistIBL}\n\\IBL\\bigl(\\HIBL^\\MC(\\CycC)\\bigr) = \\bigl(\\HIBL^\\MC(\\CycC), \\OPQ_{210}, \\OPQ_{120} \\equiv 0 \\bigr)\\quad \\text{for all }n\\in \\N,\n\\end{equation*}\nwhere $\\HIBL^\\MC(\\CycC)$ is given by \\eqref{Eq:HIBLSn} and $\\OPQ_{210}$ satisfies the following:\n\\begin{description}[font=\\normalfont\\itshape]\n\\item[($n$ even):] $\\OPQ_{210} \\equiv 0$.\n\\item[($n\\ge 3$ odd):] The non-trivial relations are\n$$ \\OPQ_{210}(\\Susp \\NOne^* \\otimes \\Susp \\NVol^{k*}) = \\OPQ_{210}(\\Susp \\NVol^{k*} \\otimes \\Susp \\NOne^*) = -(k-1) \\NVol^{k-1*}\\quad\\text{for }k\\ge 2.  $$\n\\item[($n=1$):]  The non-trivial relations are\n$$ \\OPQ_{210}\\Bigl(\\Susp \\NOne^* \\otimes \\Susp\\sum_{k=1}^\\infty c_k \\NVol^{k*}\\Bigr) = - \\Susp \\sum_{k=1}^\\infty k c_{k+1} \\NVol^{k*} \\quad\\text{for }c_k\\in \\R. $$\n\\end{description}\nRecall that the twist by $\\MC$ does not produce any higher operation $\\OPQ_{1lg}^\\MC$.\n\nWe will now consider $\\dIBL^\\PMC(\\CycC(\\Harm(\\Sph{n})))$. Recall that $\\OPQ_{110}^\\PMC = \\OPQ_{210}\\circ_1 \\PMC_{10}$, $\\OPQ_{210}^\\PMC = \\OPQ_{210}$ and $\\OPQ_{120}^\\PMC = \\OPQ_{120} + \\OPQ_{210}\\circ_1 \\PMC_{20}$. By Proposition~\\ref{Proposition:MCSphere}, we have $\\PMC_{10} = \\MC_{10}$ for all $n\\in \\N$ and $\\PMC_{20} = 0$ for all $n\\ge 2$. It follows that $\\OPQ_{110}^\\PMC = \\OPQ_{110}^\\MC$ for all $n\\in \\N$ and that the only non-trivial twist may occur in $\\OPQ_{120}^\\PMC$ for $\\Sph{1}$. Using~\\eqref{Eq:Twistn2}, we get for all $\\psi\\in \\CDBCyc \\Harm(\\Sph{n})$ and generating words $\\omega_1$, $\\omega_2 \\in \\BCyc \\Harm(\\Sph{n})$ the following:\n\\begin{equation}\n\\begin{aligned}\n& (\\OPQ_{210}\\circ_1 \\PMC_{20})(\\Susp \\psi)(\\Susp \\omega_1 \\otimes \\Susp \\omega_2) \\label{Eq:CoprodTwist}\\\\\n& \\quad = \\begin{multlined}[t] (-1)^{n-2}\\Bigl[ \\sum \\varepsilon(\\omega_1 \\mapsto \\omega_1^1 \\omega_1^2)\\psi(\\NOne \\omega_1^1)\\PMC_{20}(\\Susp \\NVol \\omega_1^2 \\otimes \\Susp \\omega_2) \\\\ {}+ (-1)^{(n-3+\\Abs{\\omega_1})(n-3+\\Abs{\\omega_2})} \\sum \\varepsilon(\\omega_2 \\mapsto \\omega_2^1 \\omega_2^2) \\psi(\\NOne \\omega_2^1)  \\\\ \\PMC_{20}(\\Susp \\NVol \\omega_2^2 \\otimes \\Susp \\omega_1)\\Bigr].  \\end{multlined}\\end{aligned}\n\\end{equation}\n\nIn this paragraph, we suppose that $n=1$ and compute $\\OPQ_{120}^\\PMC$. Clearly, $(\\OPQ_{210}\\circ_1\\PMC_{20})(\\Susp \\NVol^{k*}) = 0$ for all $k\\ge 1$ since~$\\NOne$ is fed into $\\NVol^{k*}$. A non-zero evaluation of $(\\OPQ_{210}\\circ_1\\PMC_{20})(\\Susp\\NOne^{k*})$ for some $k\\ge 1$ odd is possible only on $\\Susp \\NOne^{k-1}\\NVol^{k_1}\\otimes \\Susp\\NVol^{k_2}$ for $k_1$, $k_2\\ge 0$ (up to a transposition of arguments and their cyclic permutation). If $k>1$, only the first summand of~\\eqref{Eq:CoprodTwist} contributes, and we get\n%\n\\begin{equation*}\n\\begin{aligned}\n&(\\OPQ_{210}\\circ_1\\PMC_{20})(\\Susp\\NOne^{k*})(\\Susp \\NOne^{k-1}\\NVol^{k_1}\\otimes \\Susp\\NVol^{k_2})  \\\\\n& \\qquad= \\begin{multlined}[t] (-1)^{n-2} \\sum \\varepsilon(\\NOne^{k-1}\\NVol^{k_{1}} \\mapsto \\omega_1 \\omega_2) \\NOne^{k*}(\\NOne \\omega_1) \\PMC_{20}(\\Susp \\NVol \\omega_2\\otimes \\Susp \\NVol^{k_2}) \\end{multlined} \\\\ & \\qquad = (-1)^{n-2} \\NOne^{k*}(\\NOne\\NOne^{k-1}) \\PMC_{20}(\\Susp \\NVol\\NVol^{k_{1}}\\otimes \\Susp \\NVol^{k_2})  \\\\ & \\qquad = - \\PMC_{20}(\\Susp \\NVol^{k_{1}+1}\\otimes \\Susp\\NVol^{k_2}).\n\\end{aligned}\n\\end{equation*}\n%\nAccording to Proposition~\\ref{Proposition:MCSphere}, this is non-zero if and only if $k_{1}+k_2$ is odd. It follows that \n$$ \\OPQ_{120}^\\PMC \\neq \\OPQ_{120}^\\MC = \\OPQ_{120}\\quad\\text{on the chain level for }\\Sph{1}. $$\nHowever, the chains $\\Susp \\NOne^{k-1}\\NVol^{k_1}\\otimes \\Susp \\NVol^{k_2}$ for $k>1$ do not survive to the homology (c.f., \\eqref{Eq:HIBLSn}). The only possibility is thus $k=1$. In this case, both summands of~\\eqref{Eq:CoprodTwist} contribute, and  using~\\eqref{Eq:MC20}, we get for all $k_1$, $k_2 \\ge 1$ the following:\n%\n\\allowdisplaybreaks\n\\begin{align*}\n&(\\OPQ_{210}\\circ_1\\PMC_{20})(\\Susp\\NOne^*)(\\Susp\\NVol^{k_1} \\otimes \\Susp\\NVol^{k_2}) \\\\ &\\qquad = \\begin{multlined}[t](-1)^{n-2}\\Bigl[\\sum \\varepsilon(\\NVol^{k_1} \\mapsto \\NVol^0 \\NVol^{k_1}) \\NOne^*(\\NOne) \\PMC_{20}(\\Susp\\NVol^{k_1+1}\\otimes \\Susp \\NVol^{k_2}) \\\\ {}+ (-1)^{(n-3 + k_1(n-1))(n-3 + k_2(n-1))} \\sum \\varepsilon(\\NVol^{k_2} \\mapsto \\NVol^0 \\NVol^{k_2})  \\NOne^*(\\NOne)\\\\ \\PMC_{20}(\\Susp \\NVol^{k_2 + 1} \\otimes\\Susp\\NVol^{k_1})\\Bigr] \\end{multlined}\n\\\\&\\qquad = -  k_1 \\PMC_{20}(\\Susp\\NVol^{k_1+1}\\otimes\\Susp\\NVol^{k_2}) -  k_2 \\PMC_{20}(\\Susp\\NVol^{k_2+1}\\otimes\\Susp\\NVol^{k_1}) \\\\ \n&\\qquad = \\begin{multlined}[t] -\\frac{1}{2}(k_1+k_2+1)!I(k_1+k_2+1)\\Bigl[(-1)^{k_1} k_1 (k_1+1) \\binom{k_1+k_2}{k_1+1} \\\\ {}+ (-1)^{k_2} k_2  (k_2+1) \\binom{k_1+k_2}{k_2+1}\\Bigr] \\end{multlined} \\\\ \n&\\qquad =  -\\frac{1}{2}(k_1+k_2+1)! k_1 k_2 \\binom{k_1+k_2}{k_1} \\underbrace{I(k_1 + k_2 + 1) [(-1)^{k_1} + (-1)^{k_2}]}_{=:(*)}.\n\\end{align*}\n%\nDenoting $k\\coloneqq k_1 + k_2 + 1$, we have that $(-1)^{k_1} + (-1)^{k_2} = 0$ for $k$ even and $I(k) = 0$ for~$k$ odd. Therefore, $(*) = 0$ for any $k_1$, $k_2\\ge 1$.\nThis implies that \n$$ \\OPQ_{120}^\\PMC = \\OPQ_{120}^\\MC = \\OPQ_{120}\\quad\\text{on the homology for }\\Sph{1}. $$\nWe conclude that the \\emph{twisted $\\IBL$-algebra} satisfies\n$$ \\IBL\\bigl(\\HIBL^\\PMC(\\CycC(\\Harm(\\Sph{n})))\\bigr) = \\IBL\\bigl(\\HIBL^\\MC(\\CycC(\\Harm(\\Sph{n})))\\bigr) \\quad\\text{for all }n\\in \\N. $$\n\nAs for the \\emph{higher twisted operations}, combining Propositions~\\ref{Prop:dIBL} and~\\ref{Proposition:MCSphere}, we see that for~$\\Sph{n}$ with $n\\in \\N\\backslash\\{2\\}$ all higher operations~$\\OPQ_{1lg}^\\PMC$ vanish already on the chain level. For $n=2$, we have that $\\OPQ_{1l0}^\\PMC = 0$ for all $l\\ge 3$ and $\\OPQ_{111}^\\PMC = 0$ on the chain level. However, we did not prove that all higher operations vanish on the chain level. As for the operations induced on the homology, the graded vector space~$\\HIBL^\\PMC(\\CycC(\\Harm(\\Sph{2})))$ is concentrated in even degrees and $\\OPQ_{1lg}^\\PMC$ are odd (see Definition~\\ref{Def:IBLInfty}). Therefore, all higher operations vanish also on $\\HIBL^\\PMC(\\CycC(\\Harm(\\Sph{2})))$.\n\n\nThe string topology $\\StringH(\\Sph{n})$ and the string operations $\\StringOp_2$ and $\\StringCoOp_2$ were computed in \\cite{Basu2011} for all $n\\in \\N$.\n%For $n\\ge 2$, they used the method of minimal models to get $\\StringCoH^*(\\Sph{n}; \\Q)$. For $n$ odd, $\\StringOp_2$ \n%\\eqref{Eq:Gysin} They obtained $\\StringH_*(\\Sph{1}; \\Z)$ by topological considerations.\nWe review their results and basic ideas below:\n\nWe will consider \\emph{even spheres} first. The minimal model for the Borel construction $\\LoopBorel \\Sph{2m}$ for $m\\in \\N$ is denoted by $\\Lambda^{\\Sph{1}}(2,m)$ --- it is the free graded commutative dga (=:cdga) over~$\\R$ generated by homogenous vectors $x_1$, $y_1$, $x_2$, $y_2$, $u$ of degrees\n$$ \\Abs{x_1} = 2m,\\quad \\Abs{y_1} = 2m - 1, \\quad\\Abs{x_2} = 4m-1,\\quad \\Abs{y_2} = 2(2m - 1),\\quad\\Abs{u} = 2, $$\nwhose differential $\\Dd$ satisfies\n$$ \\Dd y_1 = 0, \\quad \\Dd x_1 = y_1 u, \\quad \\Dd y_2 = - 2 x_1 y_1, \\quad\\Dd x_2 = x_1^2 + y_2 u. $$\nThe minimal model for the loop space $\\Loop \\Sph{2m}$ is the dga $\\Lambda(2,m)$ which is obtained from $\\Lambda^{\\Sph{1}}(2,m)$ by setting $u = 0$. A computation (see \\cite[Theorem 3.6]{Basu2011}) gives the following for all $m\\in \\N$:\n\\begin{equation}\\label{Eq:EvenSphereString}\n\\begin{aligned}\n\\H^*(\\Loop \\Sph{2m}; \\R) &\\simeq \\H(\\Lambda(2,m), \\Dd) =\\langle y_2^i x_1 - 2 i y_1 x_2 y_2^{i-1}, y_1 y_2^j, 1 \\mid i, j\\in \\N_0 \\rangle,  \\\\\n\\StringCoH^*(\\Loop \\Sph{2m}; \\R) &\\simeq \\H(\\Lambda^{\\Sph{1}}(2,m),\\Dd) = \\langle y_1 y_2^i, u^j \\mid i, j\\in \\N_0\\rangle,\n\\end{aligned}\n\\end{equation}\nwhere $y_2^0 \\coloneqq u^0 \\coloneqq 1$ is the unit in $\\Lambda^{\\mathrlap{\\Sph{1}}\\hphantom{S}}(2,m)$ and $\\langle \\cdot \\rangle$ denotes the linear span over~$\\R$. Clearly, the cohomology groups are degree-wise finite-dimensional, and hence, using the universal coefficient theorem, they are isomorphic to the corresponding homology groups. We can thus identify $\\H(\\Loop \\Sph{2m}; \\R)$ and $\\StringH(\\Loop\\Sph{2m}; \\R)$ with the vector spaces on the right hand side of \\eqref{Eq:EvenSphereString}. We have $\\StringH_{2k}= \\langle u^k \\rangle$ for all $k\\in \\N_0$, and hence the multiplication with $u$ induces an isomorphism $\\StringH_{2k} \\simeq \\StringH_{2k+2}$. This corresponds to the cap product with the Euler class in \\eqref{Eq:Gysin}, and exactness of the sequence implies $\\Mark(\\StringH_{2k}) = \\Erase(\\StringH_{2k}) = 0$. Using this and degree considerations, we get $\\StringOp_2=\\StringCoOp_2 = 0$.\n\n\nWe will now consider \\emph{odd spheres} with $n\\ge 3$. The minimal model for $\\LoopBorel \\Sph{2m+1}$ \nfor $m\\in \\N$ is denoted simply by $\\Lambda(x,y,u)$ --- it is the free cdga on homogenous vectors $x$, $y$, $u$ of degrees\n$$ \\Abs{x} = 2m+1, \\quad \\Abs{y} = 2m,\\quad \\Abs{u} = 2, $$\nsuch that\n$$ \\Dd x = y u, \\quad \\Dd y = \\Dd u = 0. $$\nWe get immediately\n$$\\begin{aligned}\n\\H^*(\\Loop \\Sph{2m+1}; \\R) & \\simeq \\langle x^i, y^j \\mid i, j \\in \\N_0 \\rangle,  \\\\\n\\StringCoH^*(\\Loop \\Sph{2m+1}; \\R) &\\simeq \\langle y^i, u^j \\mid i,j \\in \\N_0 \\rangle, \\end{aligned}$$\nand we can again identify $\\H$ and $\\StringH$ with the vector spaces on the right hand side. Clearly, $\\StringH_{2k-1} = 0$ for all $k\\in \\N$, and hence $\\StringOp_2 = \\StringCoOp_2 = 0$ for degree reasons (the operations are odd).\n\nWe will now consider \\emph{the circle} $\\Sph{1}$. For every $i\\in \\Z$, let $\\alpha_i : \\Sph{1} \\rightarrow \\Sph{1}$ and $\\theta_i : \\Sph{1} \\rightarrow \\Loop \\Sph{1}$ be the maps defined by\n$$ \\alpha_i(z) \\coloneqq z^i\\quad\\text{and}\\quad\\theta_i(w) \\coloneqq w \\alpha_i \\quad \\text{for all }w,z\\in \\Sph{1}\\subset \\C. $$\nBy examining the equivariant homology of connected components of $\\Loop \\Sph{1}$ containing~$\\alpha_i$ separately as in \\cite[Section 2.1.4]{Basu2011}, we get \n$$\\begin{aligned}\n\\H(\\Loop \\Sph{1}; \\R) &=\\langle \\alpha_i, \\theta_j \\mid i,j\\in \\Z\\rangle, \\\\\n\\StringH(\\Loop \\Sph{1}; \\R) &= \\langle u^i, \\theta_0 u^j, \\alpha_k \\mid i, j \\in \\N_0, k\\in \\Z\\backslash\\{0\\} \\rangle,\n\\end{aligned}$$\nwhere $u$ corresponds to the Euler class and\n$$ \\Abs{u} = 2, \\quad \\Abs{\\theta_i} =1, \\quad \\Abs{\\alpha_i} = 0 $$\nare the degrees in the singular chain complex. On \\cite[p. 21]{Basu2011} they show that the string cobracket $\\StringCoOp_2$ is $0$ and that all non-trivial relations for the string bracket $\\StringOp_2: \\StringH(\\Loop \\Sph{1})[2]^{\\otimes 2}\\rightarrow \\StringH(\\Loop \\Sph{1})[2]$ are the following:\n\\begin{equation*}\n%\\label{Eq:NontrivRelString}\n\\StringOp_2( \\Susp \\alpha_{k}, \\Susp \\alpha_{-k}) = k^2 \\Susp\\theta_0 \\quad\\forall k \\in \\N.\n\\end{equation*}\n\nWe will now compare the reduced $\\IBL$-structures motivated by Conjecture~\\ref{Conj:StringTopology}. The point-reduced versions $\\RedStringH(\\Loop \\Sph{n})$ for $n\\ge 2$ are obtained from $\\StringH(\\Loop \\Sph{n})$ by deleting $u^i$. We have the following isomorphisms of graded vector spaces:\n$$ \\begin{aligned}\n  \\HIBL^{\\PMC}(\\RedCycC(\\Harm(\\Sph{n})))[1] &\\longrightarrow  \\RedStringH(\\Loop \\Sph{n})[3-n] && \\\\ \n       \\Susp \\NVol^i &\\longmapsto \\Susp y^i  &&\\text{for }n> 1\\text{ odd}, \\\\  \n    \\Susp \\NVol^{2i+1} &\\longmapsto \\Susp y_1 y_2^i  &&\\text{for }n\\text{ even}.\n  \\end{aligned}$$\nBecause all operations are trivial, it induces the isomorphism\n$$ \\IBL\\bigl(\\HIBL^{\\PMC}(\\RedCycC(\\Harm(\\Sph{n})))\\bigr) \\simeq \\IBL\\bigl(\\RedStringH(\\Loop \\Sph{n})[2-n]\\bigr) \\quad\\text{for }n\\ge 2. $$\nFor $n = 1$, the reduced homology is seemingly different.\n\n\\begin{Remark}[Triviality for degree reasons]\\label{Rem:DegRes}\\Modify[caption={DONE Too dense text}]{Add paragraphs here --- too dense. Ans also add $\\Sph{1}$!!}\n%Generators of the reduced cyclic cohomology for $\\Sph{2m-1}$ with $m\\ge 2$ are $\\Susp \\NVol^{i*}$ of degrees $2n-4$, $3n-5$, $4n-6$, $\\dots$, whereas the generators for $\\Sph{2m}$ are $\\Susp \\NVol^{2i-1 *}$ of degrees $2n-4$, $4n-6$, $6n-8$, $\\dots$ for $i=1$, $2$, $3$, $\\dots$. We see that in both cases, the reduced homology concentrates in even degrees, and hence any $\\IBLInfty$-structure on the reduced homology must be trivial for degree reasons.Prop:Ones\n%$-2(n-3)(g-1) + n -4$\n%\n%The non-reduced \\eqref{Prop:Ones}\n%$\\OPQ_{1lg}^\\PMC(\\Susp\\NOne^*) = - \\PMC_{lg} \\circ \\iota_\\NVol$\n%The non-reduced cyclic cohomology contains in addition $\\Susp \\NOne^{2i-1*}$ of degrees $n-4$, $n-6$, $n-8$, $\\dots$ and the non-reduced string topology contains $\\Susp u^i$ of degrees $n-1$, $n+1$, $n+3$, $\\dots$ for $i=1$, $2$, $3$, $\\dots$. \nThe graded vector spaces \n$$ \\StringH(\\Loop \\Sph{2m-1})[3-n]\\quad\\text{and}\\quad\\HIBL^\\PMC(\\CycC(\\Harm(\\Sph{2m})))[1] $$\nare concentrated in even degrees, and so any $\\IBLInfty$-structure must be trivial for degree reasons. On the other hand, the graded vector spaces \n$$ \\StringH(\\Loop \\Sph{2m})\\quad\\text{and}\\quad\\HIBL^\\PMC(\\CycC (\\Harm(\\Sph{2m-1})))[1] $$\nhave both even and odd degrees, and hence an additional argument is needed to prove vanishing of the $\\IBL$-structure. This is not the case of the reduced homology, which is again concentrated in even degree.\\qedhere\n%Therefore, the integrals computed in Section~\\ref{Section:MCSphere} were useful at least for $\\Sph{2m-1}$.\n\n\\Add[caption={DONE Non-trivial degree}]{Add here the computation of which relations on homology are not implied automatically by degree reasons.}\n\\end{Remark}\n\\end{document}\n", "meta": {"hexsha": "33b3c9e8a5fa30b2073da18f2e8ec8bc8cb9bb7b", "size": 18477, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Subfiles/Comp_SnIBL.tex", "max_stars_repo_name": "p135246/phd-thesis", "max_stars_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subfiles/Comp_SnIBL.tex", "max_issues_repo_name": "p135246/phd-thesis", "max_issues_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subfiles/Comp_SnIBL.tex", "max_forks_repo_name": "p135246/phd-thesis", "max_forks_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 88.4066985646, "max_line_length": 913, "alphanum_fraction": 0.6495102019, "num_tokens": 7638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.42487439021824763}}
{"text": "\\documentclass{report}\n\n\\usepackage{amsmath} % provides numberwithin (and lots more)\n\\usepackage{graphicx}\n\\usepackage{listings}\n\\usepackage[backend=bibtex]{biblatex}\n\\bibliography{qfrmTechnicalQuestionsDev}\n\n\n\\newtheorem{problem}{}\n\\numberwithin{problem}{chapter} % important bit\n\\let\\oldroblem\\problem\n\\renewcommand{\\problem}{\\oldroblem\\normalfont}\n\\newcommand{\\ds}{\\displaystyle}\n\n\\begin{document}\n\n\\begin{titlepage}\n\\begin{center}\n {\\huge\\bfseries Fixed Income Primer\\\\}\n % ----------------------------------------------------------------\n \\vspace{1.5cm}\n {\\bfseries Pete Benson}\\\\[5pt]\n pbenson@umich.edu\\\\[14pt]\n  % ----------------------------------------------------------------\n \\vspace{10cm}\n % ----------------------------------------------------------------\n\\includegraphics{QFRM_rgb}\\\\[5pt]\n{Department of Mathematics}\\\\[5pt]\n{530 Church Street, 2082C East Hall}\\\\[5pt]\n{Ann Arbor, MI 48109-1043,\n USA}\\\\\n \\vfill\n\n\\end{center}\n\\end{titlepage}\n\n\\tableofcontents\n\\newpage\n\n%----------------------\n% review\n%----------------------\n\\chapter{Introduction}\nDiscuss: this preps you for a fixed income interview, and includes practice exercises via Excel, python, etc.\n\n\\section{What are fixed income instruments?}\nFixed income instruments feature guaranteed payments. Examples include short term borrowing, bonds, swaps, MBS (mortgage-backed securities), CDOs (collateralized debt obligations), CDS (credit default swaps), and their many variations.\n\nTo model a fixed income instrument, you need to understand the underlying contract, which guides the timing and size of payments, and who will be paying. Timing and size of payments are used to value payments, and the payer affects the likelihood that payment will be made.\n\n\\subsection{Payers}\nBroadly, you can divide payers into riskless payers (e.g. sovereign countries that owe money denominated in their own currency), and everyone else. Typical examples of a riskless payer would be the US Treasury, making payments on bills, notes, and bonds.  Note that this would not include a country that does not control its own currency, such as countries in the EU. Greece, for example, can issue EUR-denominated debt, but that does not guarantee they can meet their obligations. Even Germany could potentially default on EUR-denominated debt, but this is considered very unlikely. In rare instances, countries may even default bonds denominated in their own currency, such as in the 1998 Russian financial crisis. \n\nThe rest of the payers could be categorized as businesses, or pools of individuals, and there are securities for each. \n\n\\subsection{Zero coupon bond with riskless payer}\nDiscuss time value of money, present value, term structure of interest rates, term structure of discount prices.\n\n\\subsection{Fixed coupon bond with riskless payer}\nDiscuss simple pricing based off discount curve, also formulated in terms of interest rates, Par vs premium vs discount bonds. Compound interest continuous vs. periodic compounding, coupon schedules, accounting conventions, accrual (clean vs dirty), primary vs secondary markets, treasury auctions. \n\n\\subsection{Bootstrapping zero coupon curves}\nForward rate curve, mention variety of techniques, demonstrate piecewise flat forward curve.\n\n\n\n\n\\subsection{Bootstrapping a zero coupon curve}\n\n%----------------------\n%Bibliography\n%----------------------\n\\printbibliography\n\n\n\n\\end{document}\n", "meta": {"hexsha": "457c01289a1e25d08055aa634abcbfe450c80423", "size": 3398, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "files/quantFixedIncomePrimer/quantFixedIncomePrimer.tex", "max_stars_repo_name": "israeldi/friday-workshop", "max_stars_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "files/quantFixedIncomePrimer/quantFixedIncomePrimer.tex", "max_issues_repo_name": "israeldi/friday-workshop", "max_issues_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "files/quantFixedIncomePrimer/quantFixedIncomePrimer.tex", "max_forks_repo_name": "israeldi/friday-workshop", "max_forks_repo_head_hexsha": "6d5105d65c7d19190b8cda9a1ec7c9cb77e1d3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0126582278, "max_line_length": 717, "alphanum_fraction": 0.723660977, "num_tokens": 744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.42479890002114595}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%  lb.tex\n%\n%  Section on lattice Boltzmann hydrodynamics\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\section{Lattice Boltzmann Hydrodynamics}\n\\label{section:lb-hydrodynamics}\n\nWe review here the lattice Boltzmann method applied to a simple\nNewtonian fluid with particular emphasis on the relevant\nimplementation in \\textit{Ludwig}.\n\n\\subsection{The Navier Stokes Equation}\n\nWe seek to solve the isothermal Navier-Stokes equations which, often\nwritten in vector form, express mass conservation\n\\begin{equation}\n\\partial_t \\rho + \\boldsymbol{\\nabla}.(\\rho\\mathbf{u}) = 0\n\\label{eq_mass1}\n\\end{equation}\nand the conservation of momentum\n\\begin{equation}\n\\partial_t (\\rho\\mathbf{u}) + \\boldsymbol{\\nabla}.(\\mathbf{\\rho uu}) =\n-\\boldsymbol{\\nabla}p + \\eta \\nabla^2 \\mathbf{u}\n+\\zeta \\boldsymbol{\\nabla}(\\boldsymbol{\\nabla}.\\mathbf{u}).\n\\label{eq_momentum1}\n\\end{equation}\nEquation~\\ref{eq_mass1} expresses the local rate of change of the\ndensity $\\rho(\\mathbf{r}; t)$ as the divergence of the flux of\nmass associated with the velocity field $\\mathbf{u}(\\mathbf{r}; t)$.\nEquation~\\ref{eq_momentum1} expresses Newton's second law for\nmomentum, where the terms on the right hand side represent the\nforce on the fluid.\n\nFor this work, it is more convenient to rewrite these equations\nin tensor notation, where Cartesian coordinates ${x,y,z}$ are\nrepresented by indices $\\alpha$ and $\\beta$, viz\n\\begin{equation}\n\\partial_t \\rho + \\nabla_\\alpha (\\rho u_\\alpha) = 0\n\\end{equation}\nand\n\\begin{equation}\n\\partial_t (\\rho u_\\alpha) + \\nabla_\\beta (\\rho u_\\alpha u_\\beta)\n= -\\nabla_\\alpha p\n+  \\eta \\nabla_\\beta (u_\\alpha \\nabla_\\beta + \\nabla_\\alpha u_\\beta)\n+ \\zeta \\nabla_\\alpha (\\nabla_\\gamma u_\\gamma).\n\\end{equation}\nHere, repeated Greek indices are understood to be summed over.\nThe conservation law is seem better if the forcing terms of the\nright hand side are combined in the fluid stress $\\Pi_{\\alpha\\beta}$\nso that\n\\begin{equation}\n\\partial_t (\\rho u_\\alpha) +\\nabla_\\beta \\Pi_{\\alpha\\beta} = 0.\n\\end{equation}\nIn this case the expanded expression for the stress tensor is\n\\begin{equation}\n\\Pi_{\\alpha\\beta} = p \\delta_{\\alpha\\beta} + \\rho u_\\alpha u_\\beta \n+ \\eta \\nabla_\\alpha u_\\beta + \\zeta (\\nabla_\\gamma u_\\gamma)\\delta_{\\alpha\\beta}\n\\end{equation}\nwhere $\\delta_{\\alpha\\beta}$ is that of Kroneker. Th Navier-Stokes\nequations in three dimensions have 10 degrees of freedom\n(or hydrodynamic modes) being\n$\\rho$, three components of the mass flux $\\rho u_\\alpha$, and 6 independent\nmodes from the (symmetric) stress tensor $\\Pi_{\\alpha\\beta}$.\n\n\\subsection{The Lattice Boltzmann Equation}\n\nThe Navier-Stokes equation may be approximated in a discrete system\nby the lattice Boltzmann equation (LBE). A discrete density\ndistribution function $f_i(\\mathbf{r}; t)$ at lattice points $\\mathbf{r}$\nand time $t$ evolves according to\n\\begin{equation}\nf_i (\\mathbf{r} + \\mathbf{c}_i \\Delta t; t + \\Delta t) =\nf_i (\\mathbf{r}; t) + \\sum_j \\mathcal{L}_{ij}\n\\big( f_i(\\mathbf{r};t) - f_i^{\\mathrm{eq}}(\\mathbf{r};t) \\big)\n\\end{equation}\nwhere $\\mathbf{c}_i$ is the discrete velocity basis and $\\Delta t$\nis the discrete time step. The collision operator\n$\\mathcal{L}_{ij}$ provides the mechanism to compute a discrete\nupdate from the non-equilibrium distribution\n$f_i(\\mathbf{r}; t)- f_i^\\mathrm{eq}(\\mathbf{r};t)$. Additional terms\nmay be added to this equation to represent external body forces,\nthermal fluctuations, and so on. These additional terms are discussed\nin the following sections.\n\n\\subsubsection{The distribution function and its moments}\n\nIn lattice Boltzmann, the density and velocity of the continuum fluid\nare complemented by the  distribution function\n$f_i(\\mathbf{r}; t)$ defined with reference to the\ndiscrete velocity space $c_{i\\alpha}$.\nIt is possible to relate the hydrodynamic quantities to the distribution\nfunction via its moments, that is\n\\begin{equation}\n\\rho(\\mathbf{r};t) = \\sum_i f_i(\\mathbf{r};t),  \\quad\n\\rho u_\\alpha(\\mathbf{r};t) = \\sum_i f_i(\\mathbf{r};t) c_{i\\alpha},  \\quad\n\\Pi_{\\alpha\\beta}(\\mathbf{r};t) =\n\\sum_i f_i(\\mathbf{r};t) c_{i\\alpha} c_{i\\beta}.\n\\label{equation-lb-f-moments}\n\\end{equation}\nHere, the index of the summation is over the number of discrete\nvelocities used as the basis, a number which will be denoted\n$N_\\mathrm{vel}$. For example, in three dimensions\n$N_\\mathrm{vel}$ is often 19 and the basis is referred to as D3Q19.\n\nThe number of moments, or modes, supported by a velocity\nset is exactly $N_\\mathrm{vel}$, and these can be written in general as\n\\begin{equation}\nM^a(\\mathbf{r};t) = \\sum_i m_i^a f_i(\\mathbf{r};t),\n\\end{equation}\nwhere the $m_i$ are the eigenvectors of the collision matrix in the LBE.\nFor example, in the case of the density, all the \n$m_i^a = 1$ and the mode $M^a$ is the density $\\rho = \\sum_i f_i$. Note\nthat the number of modes supported by a given basis will generally exceed the\nnumber of hydrodynamic modes; the excess modes have no direct physical\ninterpretation and are variously referred to as non-hydrodynamic, kinetic,\nor ghost, modes.\nThe ghost modes take no part in bulk hydrodynamics, but may become important\nin other contexts, such as thermal fluctuations and near boundaries.\nThe distribution function can be related to the modes\n$M^a(\\mathbf{r};t)$ via\n\\begin{equation}\nf_i(\\mathbf{r};t) = w_i \\sum_a m_i^a N^a M^a(\\mathbf{r};t).\n\\end{equation}\nIn this equation, $w_i$ are the standard LB weights appearing in the\nequilibrium distribution function, while the $N^a$ are a per-mode\nnormalising factor uniquely determined by the orthogonality condition\n\\begin{equation}\nN^a \\sum_i w_i m_i^a m_i^b = \\delta_{ab}.\n\\end{equation}\nWriting the basis this way has the advantage that the equilibrium\ndistribution projects directly into the hydrodynamic modes only.\nPutting it another way, we may write\n\\begin{equation}\nf_i^\\mathrm{eq} = w_i \\big(\\rho + \\rho c_{i\\alpha}u_\\alpha / c_s^2\n+ (c_{i\\alpha} c_{i\\beta} - c_s^2\\delta_{\\alpha\\beta})\n(\\Pi_{\\alpha\\beta}^\\mathrm{eq} - p\\delta_{\\alpha\\beta})/2c_s^4 \\big)\n\\end{equation}\nwhere only (equilibrium) hydrodynamic quantities appear on the right hand side.\n\n\\subsubsection{Collision and relaxation times}\n\n\n\n\\subsection{Model Basis Descriptions}\n\n\\subsubsection{D2Q9}\n\nThe D2Q9 model in two dimensions consists one zero vector (0,0), four\nvectors of length unity being $(\\pm 1,0)$ and $(0, \\pm 1)$, and four\nvectors of length $\\sqrt{2}$ being $(\\pm 1, \\pm 1)$. The eigenvectors of\nthe collision matrix, with associated weights and normalisers are shown\nin Table~\\ref{table-d2q9-spec}. In two dimensions there are six hydrodynamic\nmodes and a total of three kinetic modes, or ghost modes.\n\n\\begin{table}[t]\n\\begin{center}\n\\begin{tabular}{|l|r|rrrrrrrrr|r|l|}\n\\hline\\hline\n$M^a$ & $p$ & \\multicolumn{9}{c|}{$m_i^a$} & $N^a$  &\\\\\n\\hline\n$\\rho$ & - & 1 &  1 &  1 &  1 &  1 &  1 &  1 &   1 &  1 & 1 &$\\mathbf{1}$ \\\\\n\\hline\n$\\rho c_{ix}$ & - & 0 &  1 &  1 & 1 & 0 &  0 & -1 &  1 & -1 & 3 & $c_{ix}$ \\\\\n\\hline\n$\\rho c_{iy}$ & - & 0 & 1 &  0 &  -1 &  1 &  -1 & 1 & 0 & -1 & 3  &$c_{iy}$ \\\\\n\\hline\n$Q_{xx}$ & 1/3 & -1 &  2 &  2 & 2 & -1 & -1 & 2 & 2 & 2 & 9/2 \n& $c_{ix} c_{ix} - c_s^2$ \\\\\n\\hline\n$Q_{xy}$ & - & 0 &  1 & 0 & -1 & 0 & 0 & -1 & 0 & 1 & 9 & $c_{ix} c_{iy}$ \\\\\n\\hline\n$Q_{yy}$ & 1/3 & -1 &  2 & -1 & 2 & 2 & 2 & 2 & -1 & 2 & 9/2\n& $c_{iy} c_{iy} - c_s^2$ \\\\\n\\hline\\hline\n$\\chi^1$ & - &  1 & 4 & -2 & 4 & -2 & -2 & 4 & -2 & 4 & 1/4 & $\\chi^1$ \\\\\n\\hline\n$J_{ix}$ & - & 0 &  4 & -2 & 4 & 0 & 0 & -4 & -2 & -4 & 3/8\n& $\\chi^1 \\rho c_{ix}$\\\\\n\\hline\n$J_{iy}$ & - & 0 & 4 & 0 & -4 & -2 & 2 & 4 & 0 & -4 & 3/8\n& $\\chi^1 \\rho c_{iy}$\\\\\n\\hline\\hline\n$w_i$ & 1/36 & 16 & 1 & 4 & 1 & 4 & 4 & 1 & 4 & 1 & & $w_i$\\\\\n\\hline\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Table showing the details of the basis used for the D2Q9 model\nin two dimensions. The nine modes $M^a$ include six hydrodynamic modes,\none scalar kinetic mode $\\chi^1$, and one vector kinetic mode $J_{i\\alpha}$.\nThe weights in the equilibrium distribution function are $w_i$ and the\nnormaliser for each mode is $N^a$. The eigenvectors of the collision\nmatrix are the columns of the transformation matrix $m^a_i$. The pre-factor\n$p$ (where present) multiplies all the elements to the right in that row.}\n\\label{table-d2q9-spec}\n\\end{table}\n\n\n\n\\subsubsection{D3Q15}\n\nThe D3Q15 model in three dimensions consists of a set of vectors:\none zero vector $(0,0,0)$, six vectors of length unity being\n$(\\pm 1, 0, 0)$ cyclically permuted, and 8 vectors of length\n$\\sqrt{3}$ being $(\\pm 1, \\pm 1, \\pm 1)$.\nThe eigenvalues and eigenvectors of the collision\nmatrix used for D3Q15 are given in Table~\\ref{table-d3q15-spec}.\n\n\n\\begin{table}[t]\n\\centering\n\\tabcolsep=4pt\n\\begin{tabular}{|l|r|r|rrrrrr|rrrrrrrr|r|l|}\n\\hline\\hline\n$M^a$ & $p$ & \\multicolumn{15}{c|}{$m_i^a$} & $N^a$  &\\\\\n\\hline\n$\\rho$ & - &\n 1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &  1 &\n1 &$\\mathbf{1}$ \\\\\n\\hline\n$\\rho c_{ix}$ & - &\n 0 &  1 & -1 &  0 &  0 &  0 &  0 &  1 & -1 &  1 & -1 &  1 & -1 &  1 & -1 &\n3  & $c_{ix}$ \\\\\n\\hline\n$\\rho c_{iy}$ & - &\n 0 &  0 &  0 &  1 & -1 &  0 &  0 &  1 &  1 & -1 & -1 &  1 &  1 & -1 & -1 &\n3  &$c_{iy}$ \\\\\n\\hline\n$\\rho c_{iz}$ & - &\n 0 &  0 &  0 &  0 &  0 &  1 & -1 &  1 &  1 &  1 &  1 & -1 & -1 & -1 & -1 &\n3  & $c_{iz}$ \\\\\n\\hline\n$Q_{xx}$ & 1/3 &\n-1 &  2 &  2 & -1 & -1 & -1 & -1 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &\n9/2  & $c_{ix} c_{ix} - c_s^2$ \\\\\n\\hline\n$Q_{yy}$ & 1/3 &\n-1 & -1 & -1 &  2 &  2 & -1 & -1 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &\n 9/2 & $c_{iy} c_{iy} - c_s^2$ \\\\\n\\hline\n$Q_{zz}$ & 1/3 &\n-1 & -1 & -1 & -1 & -1 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &  2 &\n 9/2 & $c_{iz} c_{iz} - c_s^2$ \\\\\n\\hline\n$Q_{xy}$ & - &\n 0 &  0 &  0 &  0 &  0 &  0 &  0 &  1 & -1 & -1 &  1 &  1 & -1 & -1 &  1 &\n9  & $c_{ix} c_{iy}$ \\\\\n\\hline\n$Q_{yz}$ & - &\n 0 &  0 &  0 &  0 &  0 &  0 &  0 &  1 &  1 & -1 & -1 & -1 & -1 &  1 &  1 &\n9  & $c_{iy} c_{iz}$ \\\\\n\\hline\n$Q_{zx}$ & - &\n 0 &  0 &  0 &  0 &  0 &  0 &  0 &  1 & -1 &  1 & -1 & -1 &  1 & -1 &  1 &\n9  & $c_{iz} c_{ix}$ \\\\\n\\hline\\hline\n$\\chi^1$ & - &\n-2 &  1 &  1 &  1 &  1 &  1 &  1 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -2 &\n1/2 & $\\chi^1$ \\\\\n\\hline\n$J_{ix}$ & - &\n 0 &  1 & -1 &  0 &  0 &  0 &  0 & -2 &  2 & -2 &  2 & -2 &  2 & -2 &  2 &\n3/2 & $\\chi^1 \\rho c_{ix}$\\\\\n\\hline\n$J_{iy}$ & - &\n 0 &   0 &  0 &  1 & -1 &  0 &  0 & -2 & -2 &  2 &  2 & -2 & -2 &  2 &  2 &\n3/2 & $\\chi^1 \\rho c_{iy}$\\\\\n\\hline\n$J_{iz}$ & - &\n 0 &   0 &  0 &  0 &  0 &  1 & -1 & -2 & -2 & -2 & -2 &  2 &  2 &  2 &  2 &\n3/2 & $\\chi^1 \\rho c_{iz}$\\\\\n\\hline\n$\\chi^3$ & - &\n 0 &   0 &  0 &  0 &  0 &  0 &  0 &  1 & -1 & -1 &  1 & -1 &  1 &  1 & -1 &\n9 & $c_{ix} c_{iy} c_{iz}$ \\\\\n\\hline\\hline\n$w_i$ & 1/72 &\n$16$ & 8 & 8 & 8 & 8 & 8 & 8 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 &\n & $w_i$\\\\\n\\hline\\hline\n\\end{tabular}\n\n\\caption{Table showing the details of the basis used for the D3Q15 model\nin three dimensions. The fifteen modes $M^a$ include two scalar kinetic\nmodes $\\chi^1$ and $\\chi^3$, and one vector kinetic mode $J_{i\\alpha}$.\nThe weights in the equilibrium distribution are $w_i$ and the normaliser\nfor each mode is $N^a$. The eigenvectors of the collision matrix are the\ncolumns of the transformation matrix $m_i^a$. The pre-factor $p$ simply\nmultiplies all elements of $m_i^a$ in that row as a convenience.\n\\label{table-d3q15-spec}\n}\n\\end{table}\n\n\n\\subsubsection{D3Q19}\n\nThe D3Q19 model in three dimensions is constructed with velocities:\none zero vector $(0,0,0)$, three vectors of length unity being\n$(\\pm 1, 0, 0)$ cyclically permuted, and twelve vectors of length\n$\\sqrt{2}$ being $(\\pm 1, \\pm 1, 0)$ cyclically permuted. The\ndetails of the D3Q19 model are set out in Table~\\ref{table-d3q19-spec}.\n\n\\begin{table}[t]\n\\centering\n\\tabcolsep=4pt\n\\begin{tabular}{|l||r|rrrrrr|rrrr|rrrr|rrrr|r||}\n\\hline\\hline\n$M^a$ & \\multicolumn{19}{c||}{$m_i^a$} & $N^a$\\\\\n\\hline\n$\\rho $ & 1 &  1 &  1 &  1 &  1 &  1 &  1 & \n         1 &  1 &  1 &   1 &  1 &  1 &  1 & 1 & 1 & 1 & 1 & 1\n& 1\\\\\n\\hline\n$\\rho c_{ix}$ & 0 &  1 &  -1 &  0 &  0 &  0 &  0 & \n         1 &  1 &  -1 &   -1 &  1 &  1 &  -1 & -1 & 0 & 0 & 0 & 0\n& 3 \\\\\n\\hline\n$\\rho c_{iy}$ & 0 &  0 &  0 &  1 &  -1 &  0 &  0 & \n         1 &  -1 &  1 &   -1 &  0 &  0 &  0 & 0 & 1 & 1 & -1 & -1\n& 3\\\\\n\\hline\n$\\rho c_{iz}$ & 0 &  0 &  0 &  0 &  0 &  1 &  -1 & \n         0 &  0 &  0 &   0 &  1 &  -1 &  1 & -1 & 1 & -1 & 1 & -1\n& 3\\\\\n\\hline\n$Q_{ixx}$ & -1 &  2 &  2 &  -1&  -1 &  -1 &  -1 & \n         2 &  2 &  2 &   2 &  2 &  2 &  2 & 2 & -1 & -1 & -1 & -1\n& 9/2\\\\\n\\hline\n$Q_{iyy}$ & -1 &  -1 &  -1 &  2&  2 &  -1 &  -1 & \n         2 &  2 &  2 &   2 &  -1 &  -1 &  -1 & -1 & 2 & 2 & 2 & 2\n& 9/2\\\\\n\\hline\n$Q_{izz}$ & -1 &  -1 &  -1 &  -1&  -1 &  2 &  2 & \n         -1 &  -1 &  -1 &   -1 &  2 &  2 & 2 & 2 & 2 & 2 & 2 & 2\n& 9/2\\\\\n\\hline\n$Q_{ixy}$ & 0 &  0 &  0 &  0&  0 &  0 &  0 & \n          1 &  -1 &  -1 &    1 &  0 &  0 & 0 & 0 & 0 & 0 & 0 & 0\n& 9\\\\\n\\hline\n$Q_{ixz}$ & 0 &  0 &  0 &  0&  0 &  0 &  0 & \n          0 &   0 &   0 &   0 &  1 & -1 & -1 & 1 & 0 & 0 & 0 & 0\n& 9\\\\\n\\hline\n$Q_{iyz}$ & 0 &  0 &  0 &  0&  0 &  0 &  0 & \n          0 &   0 &   0 &   0 &  0 & 0 & 0 & 0 & 1 & -1 & -1 & 1\n& 9\\\\\n\\hline\\hline\n$\\chi^1$ & 0 &  1 &  1 &  1 &  1 &  -2 &  -2 & \n         -2 &  -2 &  -2 &  -2 &  1 &  1 & 1 & 1 & 1 & 1 & 1 & 1\n& 3/4\\\\\n\\hline\n$\\chi^1 \\rho c_{ix}$ & 0 &  1 &  -1 &  0&  0 &  0 &  0 & \n         -2 &  -2 &  2 &  2 &  1 &  1 & -1 & -1 & 0 & 0 & 0 & 0\n& 3/2\\\\\n\\hline\n$\\chi^1 \\rho c_{iy}$ & 0 &  0 &  0 &  1&  -1 &  0 &  0 & \n         -2 &  2 &  -2 &  2 &  0 &  0 & 0 & 0 & 1 & 1 & -1 & -1\n& 3/2\\\\\n\\hline\n$\\chi^1 \\rho c_{iz}$ & 0 &  0 &  0 &  0&  0 &  -2 &  2 & \n         0 &  0 &  0 &  0 &  1 &  -1 & 1 & -1 & 1 & -1 & 1 & -1\n& 3/2\\\\\n\\hline\n$\\chi^2$ & 0 &  1 &  1 &  -1&  -1 &  0 &  0 & \n         0 &  0 &  0 &  0 &  -1 &  -1 & -1 & -1 & 1 & 1 & 1 & 1\n& 9/4\\\\\n\\hline\n$\\chi^2 \\rho c_{ix}$ & 0 &  1 &  -1 &  0&  0 &  0 &  0 & \n         0 &  0 &  0 &  0 &  -1 &  -1 & 1 & 1 & 0 & 0 & 0 & 0\n& 9/2\\\\\n\\hline\n$\\chi^2 \\rho c_{iy}$ & 0 &  0 &  0 & -1&   1 &  0 &  0 & \n         0 &  0 &  0 &  0 &   0 &  0 & 0 & 0 & 1 &  1 & -1 & -1\n& 9/2\\\\\n\\hline\n$\\chi^2 \\rho c_{iz}$ & 0 &  0 &  0 &  0&  0 &  0 &  0 & \n         0 &  0 &  0 &  0 &  -1 &  1 & -1 & 1 & 1 & -1 & 1 & -1\n& 9/2\\\\\n\\hline\n$\\chi^3$ & 1 &  -2 &  -2 &  -2&  -2 &  -2 &  -2 & \n         1 &  1 &  1 &  1 &  1 &  1 & 1 & 1 & 1 & 1 & 1 & 1\n& 1/2\\\\\n\\hline\\hline\n$w_i$ & 12 & 2 & 2 & 2 & 2 & 2 & 2 & \n1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\n& \\\\\n\\hline\\hline\n\\end{tabular}\n\\caption{Table showing the details of the basis used for the D3Q19 model in\nthree dimensions. The nineteen modes $M^a$ include ten hydrodynamic modes,\nthree scalar kinetic modes $\\chi^1$, $\\chi^2$, and $\\chi^3$; there are also\ntwo vector kinetic modes $\\chi^1 \\rho c_{i\\alpha}$\nand $\\chi^2 \\rho c_{i\\alpha}$. The weights in the equilibrium distribution\nfunction are $w_i$, and the normaliser for each mode is $N^a$. The\neigenvectors of the collision matrix are the columns of the transformation\nmatrix $m^a_i$.\n\\label{table-d3q19-spec}\n}\n\\end{table}\n\n\n\\subsection{Fluctuating LBE}\n\nIt is possible \\cite{adhikari2005} to simulate fluctuating\nhydrodynamics for an isothermal fluid via the inclusion of\na fluctuating stress $\\sigma_{\\alpha\\beta}$:\n\\begin{equation}\n\\Pi_{\\alpha\\beta} = p\\delta_{\\alpha\\beta} + \\rho u_\\alpha u_\\beta\n+ \\eta_{\\alpha\\beta\\gamma\\delta} \\nabla_\\gamma u_\\delta + \\sigma_{\\alpha\\beta}.\n\\end{equation}\nThe fluctuation-dissipation theorem relates the magnitude of this\nrandom stress to the isothermal temperature and the viscosity.\n\nIn the LBE, this translates to the addition of a random contribution\n$\\xi_i$ to the distribution at the collision stage, so that\n\\begin{equation}\n\\ldots + \\xi_i.\n\\end{equation}\n\nFor the conserved modes $\\xi_i = 0$. For all the non-conserved modes,\ni.e., those with dissipation, the fluctuating part may be written\n\\begin{equation}\n\\xi_i (\\mathbf{r}; t) = w_i m_i^a \\hat{\\xi}^a (\\mathbf{r}; t) N^a\n\\end{equation}\nwhere $\\hat{\\xi}^a$ is a noise term which has a variance determined\nby the relaxation time for given mode\n\\begin{equation}\n\\left< \\hat{\\xi}^a \\hat{\\xi}^b \\right> =\n\\frac{\\tau_a + \\tau_b + 1}{\\tau_a \\tau_b}\n\\left< \\delta M^a \\delta M^b \\right>.\n\\label{eq_fvar}\n\\end{equation}\n\n\\subsubsection{Fluctuating stress}\n\nFor the stress, the random contribution to the distributions is\n\\begin{equation}\n\\xi_i = w_i \\frac{Q_{i\\alpha\\beta} \\hat{\\sigma}_{\\alpha\\beta}}{4c_s^2}\n\\end{equation}\nwhere $\\hat{\\sigma}_{\\alpha\\beta}$ is a symmetric matrix of random\nvariates drawn from a Gaussian distribution with variance given\nby equation~\\ref{eq_fvar}. In the case that the shear and bulk\nviscosities are the same, i.e., there is a single relaxation\ntime, then the variances of the six independent components of\nthe matrix are given by\n\\begin{equation}\n\\left< \\hat{\\sigma}_{\\alpha\\beta} \\hat{\\sigma}_{\\mu\\nu} \\right> =\n\\frac{2\\tau + 1}{\\tau^2}\n(\\delta_{\\alpha\\mu}\\delta_{\\beta\\nu} + \\delta_{\\alpha\\nu} \\delta_{\\beta\\mu}).\n\\end{equation}\n\n\n\\subsection{Hydrodynamic Boundary Conditions}\n\n\\subsubsection{Bounce-Back on Links}\n\nA very general method for the representation of solid objects\nwithin the LB approach was put forward by Ladd \\cite{l94a, l94b}.\nSolid objects (of any shape) are defined by a boundary surface\nwhich intersects some of the velocity vectors $\\mathbf{c}_i$\njoining lattice nodes. Sites inside are designated solid, while\nsites outside remain fluid. The correct boundary condition is\ndefined by identifying \\textit{links} between fluid and solid\nsites, which allows those elements of the distribution which would\ncross the boundary at the propagation step to be ``bounced-back''\ninto the fluid. This bounce-back on links is an efficient method\nto obtain the  correct hydrodynamic interaction between solid\nand fluid.\n\n\\subsubsection{Fixed objects}\n\n\\subsubsection{Moving objects}\n\nColloidal particles are assumed to be spherical with a geometrical\ncentre $\\mathbf{r}_c$, which is also the centre of mass. The\ncentre is allowed to move continuously across the lattice\nwith velocity $\\mathbf{U}$; the particle has an angular velocity\n$\\mathbf{\\Omega}$. The surface of the colloid is defined by an\ninput radius, $a_0$, which determines which lattice nodes are\ninside or outside the colloid. (The hydrodynamic properties of\nthe colloid are specified by a different radius $a_h$ --- more\nof this later.) The boundary links are then the set of vectors\njoining lattice nodes which intersect the spherical surface\n$\\{\\mathbf{c}_b\\}$. Note that a lattice node exactly at\nthe solid-fluid interface is defined to be outside the colloid.\n\nIn the original approach of Ladd, fluid occupied nodes both inside\nand outside the particle. The effect of the ``internal fluid'' is\nknown to be restricted to short time scales (compared to the\ncharacteristic time $a_0^2/\\nu$), on which the fluid inside the\nparticle relaxes to a solid body rotation \\cite{heemels}. However,\nwe use fully solid particles via the approach introduced by\nNguyen and Ladd \\cite{nguyen-ladd2002}.\n\n\n\nA boundary link is defined as joining a node $\\mathbf{r}$\ninside the particle to one outside at $\\mathbf{r} + \\mathbf{c}_b \\Delta t$.\nIf the post-collision distributions are denoted by $f^\\ast$, then\nthe distributions must be reflected at the solid surface so that\n\\begin{equation}\n\\label{eq:colloid_bbl1}\nf_{b'}(\\mathbf{r}; t + \\Delta t) = f_b^\\ast (\\mathbf{r}; t)\n- \\frac{2w_{c_b} \\rho_0 \\mathbf{u}_b.\\mathbf{c}_b}{c_s^2}\n\\end{equation}\nwhere the boundary link $\\mathbf{c}_{b'} = -\\mathbf{c}_b$.\nNote that the local density at the fluid site $\\rho(\\mathbf{r};t)$\nis replaced by\nthe mean fluid density $\\rho_0$. in the second term on the right-hand side.\nThe velocity at the boundary is\n\\begin{equation}\n\\label{eq-colloid-ub}\n\\mathbf{u}_b = \\mathbf{U} + \\mathbf{\\Omega}\\times\\mathbf{r}_b.\n\\end{equation}\n\nThe force exerted on a\nsingle link is\n\\begin{equation}\n\\mathbf{F}_b(\\mathbf{r} + {\\scriptstyle\\frac{1}{2}}\\mathbf{c}_b\\Delta t;\nt + {\\scriptstyle\\frac{1}{2}}\\Delta t) = \\frac{\\Delta x^3}{\\Delta t}\n\\Big[ 2f_b^\\ast(\\mathbf{r}; t) - \\frac{2w_{c_b}\\rho_0 \\mathbf{u}_b .\n\\mathbf{c}_b}{c_s^2} \\Big] \\mathbf{c}_b,\n\\label{eq-colloid-fb}\n\\end{equation}\nwith corresponding torque $\\mathbf{T}_b = \\mathbf{r}_b \\times \\mathbf{F}_b$.\nThe total hydrodynamic force on the particle is then found by taking\nthe sum of\n$\\mathbf{F}_b$ over all the boundary links defining the particle.\nThere is an associated torque on each link of $\\mathbf{r}_b\\times\\mathbf{F}_b$,\nwhich again is summed over all links to give the total torque on the colloid.\nColloid dynamics is discussed in more detail in Section~\\ref{section:colloids}.\n\n\n\n\n% End section\n\\vfill\n\\pagebreak\n", "meta": {"hexsha": "68bcd68ee60bcc86c9434a62a147a8d0721c23a0", "size": 20706, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/lb.tex", "max_stars_repo_name": "qikaifzj/ludwig", "max_stars_repo_head_hexsha": "e16d2d3472772fb3a36c1ee1bde028029c9ecd2d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2018-10-05T11:54:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T06:40:49.000Z", "max_issues_repo_path": "docs/lb.tex", "max_issues_repo_name": "yangyang14641/ludwig", "max_issues_repo_head_hexsha": "25905b523bc67bc8f88bc757503f7e89362042af", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 108, "max_issues_repo_issues_event_min_datetime": "2018-07-26T11:01:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T07:51:10.000Z", "max_forks_repo_path": "docs/lb.tex", "max_forks_repo_name": "yangyang14641/ludwig", "max_forks_repo_head_hexsha": "25905b523bc67bc8f88bc757503f7e89362042af", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2018-12-21T19:05:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T07:51:32.000Z", "avg_line_length": 37.9926605505, "max_line_length": 81, "alphanum_fraction": 0.6173089926, "num_tokens": 8276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4247988825165615}}
{"text": "%\\documentclass[11pt]{article}\n%\\usepackage{fullpage,euler}\n%\\usepackage[latin1]{inputenc}\n%\\begin{document}\n%\\title{Writing ad-hoc Tactics in Coq}\n%\\author{} \n%\\date{}\n%\\maketitle\n%\\tableofcontents\n%\\clearpage\n\n\\chapter[Writing ad-hoc Tactics in Coq]{Writing ad-hoc Tactics in Coq\\label{WritingTactics}}\n\n\\section{Introduction}\n\n\\Coq\\ is an open proof environment, in the sense that the collection of\nproof strategies offered by the system can be extended by the user.\nThis feature has two important advantages. First, the user can develop\nhis/her own ad-hoc proof procedures, customizing the system for a\nparticular domain of application. Second, the repetitive and tedious\naspects of the proofs can be abstracted away implementing new tactics\nfor dealing with them. For example, this may be useful when a theorem\nneeds several lemmas which are all proven in a similar but not exactly\nthe same way. Let us illustrate this with an example.\n\nConsider the problem of deciding the equality of two booleans. The\ntheorem establishing that this is always possible is state by \nthe following theorem:\n\n\\begin{coq_example*}\nTheorem decideBool : (x,y:bool){x=y}+{~x=y}.\n\\end{coq_example*}\n\nThe proof proceeds by case analysis on both $x$ and $y$. This yields\nfour cases to solve. The cases $x=y=\\textsl{true}$ and\n$x=y=\\textsl{false}$ are immediate by the reflexivity of equality.\n\nThe other two cases follow by discrimination. The following script\ndescribes the proof:\n\n\\begin{coq_example*}\nDestruct x.\n  Destruct y.\n    Left ; Reflexivity.\n    Right; Discriminate.\n  Destruct y.\n    Right; Discriminate.\n    Left ; Reflexivity.\n\\end{coq_example*}\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\nNow, consider the theorem stating the same property but for the\nfollowing enumerated type:\n\n\\begin{coq_example*}\nInductive Set Color := Blue:Color | White:Color | Red:Color.\nTheorem decideColor : (c1,c2:Color){c1=c2}+{~c1=c2}.\n\\end{coq_example*}\n\nThis theorem can be proven in a very similar way, reasoning by case\nanalysis on $c_1$ and $c_2$. Once more, each of the (now six) cases is\nsolved either by reflexivity or by discrimination:\n\n\\begin{coq_example*}\nDestruct c1. \n  Destruct c2.\n    Left  ; Reflexivity.\n    Right ; Discriminate.\n    Right ; Discriminate.\n  Destruct c2.  \n    Right ; Discriminate.\n    Left  ; Reflexivity.\n    Right ; Discriminate.\n  Destruct c2.  \n    Right ; Discriminate.\n    Right ; Discriminate.\n    Left  ; Reflexivity.\n\\end{coq_example*}\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\nIf we face the same theorem for an enumerated datatype corresponding\nto the days of the week, it would still follow a similar pattern. In\ngeneral, the general pattern for proving the property\n$(x,y:R)\\{x=y\\}+\\{\\neg x =y\\}$ for an enumerated type $R$ proceeds as\nfollow:\n\\begin{enumerate}\n\\item Analyze the cases for $x$. \n\\item For each of the sub-goals generated by the first step, analyze\nthe cases for $y$.\n\\item The remaining subgoals follow either by reflexivity or\nby discrimination.\n\\end{enumerate}\n\nLet us describe how this general proof procedure can be introduced in\n\\Coq.\n\n\\section{Tactic Macros}\n\nThe simplest way to introduce it is to define it as new a\n\\textsl{tactic macro}, as follows:\n\n\\begin{coq_example*}\nTactic Definition DecideEq [$a $b] := \n   [<:tactic:<Destruct $a;\n              Destruct $b;\n              (Left;Reflexivity) Orelse (Right;Discriminate)>>].\n\\end{coq_example*}\n\nThe general pattern of the proof is abstracted away using the\ntacticals ``\\texttt{;}'' and \\texttt{Orelse}, and introducing two\nparameters for the names of the arguments to be analyzed.\n\nOnce defined, this tactic can be called like any other tactic, just\nsupplying the list of terms corresponding to its real arguments. Let us\nrevisit the proof of the former theorems using the new tactic\n\\texttt{DecideEq}:\n\n\\begin{coq_example*}\nTheorem decideBool : (x,y:bool){x=y}+{~x=y}.\nDecideEq x y.\nDefined.\n\\end{coq_example*}\n\\begin{coq_example*}\nTheorem decideColor : (c1,c2:Color){c1=c2}+{~c1=c2}.\nDecideEq c1 c2.\nDefined.\n\\end{coq_example*}\n\nIn general, the command \\texttt{Tactic Definition} associates a name\nto a parameterized tactic expression, built up from the tactics and\ntacticals that are already available. The general syntax rule for this\ncommand is the following:\n\n\\begin{tabbing}\n\\texttt{Tactic Definition} \\textit{tactic-name} \\= \n\\texttt{[}\\$$id_1\\ldots \\$id_n$\\texttt{]}\\\\\n\\> := \\texttt{[<:tactic:<} \\textit{tactic-expression} \\verb+>>]+\n\\end{tabbing}\n\nThis command provides a quick but also very primitive mechanism for\nintroducing new tactics. It does not support recursive definitions,\nand the arguments of a tactic macro are restricted to term\nexpressions.  Moreover, there is no static checking of the definition\nother than the syntactical one. Any error in the definition of the\ntactic ---for instance, a call to an undefined tactic--- will not be\nnoticed until the tactic is called.\n\n%This command provides a very primitive mechanism for introducing new\n%tactics. The arguments of a tactic macro are restricted to term\n%expressions.  Hence, it is not possible to define higher order tactics\n%with this command. Also, there is no static checking of the definition\n%other than syntactical. If the tactic contain errors in its definition\n%--for instance, a call to an undefined tactic-- this will be noticed\n%during the tactic call.\n\nLet us illustrate the weakness of this way of introducing new tactics\ntrying to extend our proof procedure to work on a larger class of\ninductive types.  Consider for example the decidability of equality\nfor pairs of booleans and colors:\n\n\\begin{coq_example*}\nTheorem decideBoolXColor : (p1,p2:bool*Color){p1=p2}+{~p1=p2}.\n\\end{coq_example*}\n\nThe proof still proceeds by a double case analysis, but now the\nconstructors of the type take two arguments. Therefore, the sub-goals\nthat can not be solved by discrimination need further considerations\nabout the equality of such arguments:\n\n\\begin{coq_example}\n  Destruct p1;\n    Destruct p2; Try (Right;Discriminate);Intros.\n\\end{coq_example}\n\nThe half of the disjunction to be chosen depends on whether or not\n$b=b_0$ and $c=c_0$. These equalities can be decided automatically\nusing the previous lemmas about booleans and colors. If both\nequalities are satisfied, then it is sufficient to rewrite $b$ into\n$b_0$ and $c$ into $c_0$, so that the left half of the goal follows by\nreflexivity.  Otherwise, the right half follows by first contraposing\nthe disequality, and then applying the invectiveness of the pairing\nconstructor.\n\nAs the cases associated to each argument of the pair are very similar,\na tactic macro can be introduced to abstract this part of the proof:\n\n\\begin{coq_example*}\nHints Resolve decideBool decideColor.\nTactic Definition SolveArg [$t1 $t2] := \n [<:tactic:<\n   ElimType {$t1=$t2}+{~$t1=$t2};\n   [(Intro equality;Rewrite equality;Clear equality) |\n    (Intro diseq; Right; Red; Intro absurd;\n     Apply diseq;Injection absurd;Trivial) |\n    Auto]>>].\n\\end{coq_example*}\n\nThis tactic is applied to each corresponding pair of arguments of the\narguments, until the goal can be solved by reflexivity:\n\n\\begin{coq_example*}\nSolveArg b b0;\n  SolveArg c c0;\n    Left; Reflexivity.\nDefined.\n\\end{coq_example*}\n\nTherefore, a more general strategy for deciding the property \n$(x,y:R)\\{x=y\\}+\\{\\neg x =y\\}$ on $R$ can be sketched as follows:\n\\begin{enumerate}\n\\item Eliminate $x$ and then $y$.\n\\item Try discrimination to solve those goals where $x$ and $y$ has\nbeen introduced by different constructors.\n\\item If $x$ and $y$ have been introduced by the same constructor,\nthen iterate the tactic \\textsl{SolveArg} for each pair of\narguments. \n\\item Finally, solve the left half of the goal by reflexivity.\n\\end{enumerate}\n\nThe implementation of this stronger proof strategy needs to perform a\nterm decomposition, in order to extract the list of arguments of each\nconstructor. It also requires the introduction of recursively defined\ntactics, so that the \\textsl{SolveArg} can be iterated on the lists of\narguments. These features are not supported by the \\texttt{Tactic\nDefinition} command. One possibility could be extended this command in\norder to introduce recursion, general parameter passing,\npattern-matching, etc, but this would quickly lead us to introduce the\nwhole \\ocaml{} into \\Coq\\footnote{This is historically true. In fact,\n\\ocaml{} is a direct descendent of ML, a functional programming language\nconceived language for programming the tactics of the theorem prover\nLCF.}.  Instead of doing this, we prefer to give to the user the\npossibility of writing his/her own tactics directly in \\ocaml{}, and then\nto link them dynamically with \\Coq's code. This requires a minimal\nknowledge about \\Coq's implementation. The next section provides an\noverview of \\Coq's architecture.\n\n%It is important to point out that the introduction of a new tactic\n%never endangers the correction of the theorems proven in the extended\n%system. In order to understand why, let us introduce briefly the system\n%architecture.\n\n\\section{An Overview of \\Coq's Architecture}\n\nThe implementation of \\Coq\\ is based on eight \\textsl{logical\nmodules}. By ``module'' we mean here a logical piece of code having a\nconceptual unity, that may concern several \\ocaml{} files. By the sake of\norganization, all the \\ocaml{} files concerning a logical module are\ngrouped altogether into the same sub-directory. The eight modules\nare:\n\n\\begin{tabular}{lll}\n1. & The logical framework           & (directory \\texttt{src/generic})\\\\\n2. &  The language of constructions  & (directory \\texttt{src/constr})\\\\\n3. &  The type-checker               & (directory \\texttt{src/typing})\\\\\n4. &  The proof engine               & (directory \\texttt{src/proofs})\\\\\n5. &  The language of basic tactics  & (directory \\texttt{src/tactics})\\\\\n6. &  The vernacular interpreter     & (directory \\texttt{src/env})\\\\\n7. &  The parser and the pretty-printer  & (directory \\texttt{src/parsing})\\\\\n8. &  The standard library           & (directory \\texttt{src/lib})\n\\end{tabular}\n\n\\vspace{1em}\n\nThe following sections briefly present each of the modules above.\nThis presentation is not intended to be a complete description of \\Coq's\nimplementation, but rather a guideline to be read before taking a look\nat the sources. For each of the modules, we also present some of its\nmost important functions, which are sufficient to implement a large\nclass of tactics.\n\n\n\\subsection[The Logical Framework]{The Logical Framework\\label{LogicalFramework}}\n\nAt the very heart of \\Coq there is a generic untyped language for\nexpressing abstractions, applications and global constants. This\nlanguage is used as a meta-language for expressing the terms of the\nCalculus of Inductive Constructions. General operations on terms like\ncollecting the free variables of an expression, substituting a term for\na free variable, etc, are expressed in this language.\n\nThe meta-language \\texttt{'op term} of terms has seven main\nconstructors:\n\\begin{itemize}\n\\item $(\\texttt{VAR}\\;id)$, a reference to a global identifier called  $id$;\n\\item $(\\texttt{Rel}\\;n)$, a bound variable, whose binder is the $nth$\n      binder up in the term;\n\\item $\\texttt{DLAM}\\;(x,t)$, a deBruijn's binder on the term $t$;\n\\item $\\texttt{DLAMV}\\;(x,vt)$, a deBruijn's binder on all the terms of \n      the vector $vt$;\n\\item $(\\texttt{DOP0}\\;op)$, a unary operator $op$;\n\\item $\\texttt{DOP2}\\;(op,t_1,t_2)$, the application of a binary\noperator $op$ to the terms $t_1$ and $t_2$;\n\\item $\\texttt{DOPN} (op,vt)$, the application of an n-ary operator $op$ to the\nvector of terms $vt$.\n\\end{itemize}\n\nIn this meta-language, bound variables are represented using the\nso-called deBrujin's indexes. In this representation, an occurrence of\na bound variable is denoted by an integer, meaning the number of\nbinders that must be traversed to reach its own\nbinder\\footnote{Actually, $(\\texttt{Rel}\\;n)$ means that $(n-1)$ binders\nhave to be traversed, since indexes are represented by strictly\npositive integers.}. On the other hand, constants are referred by its\nname, as usual. For example, if $A$ is a variable of the current\nsection, then the lambda abstraction $[x:A]x$ of the Calculus of\nConstructions is represented in the meta-language by the term:\n\n\\begin{displaymath}\n(DOP2 (Lambda,(Var\\;A),DLAM (x,(Rel\\;1)))\n\\end{displaymath}\n\nIn this term, $Lambda$ is a binary operator.  Its first argument\ncorrespond to the type $A$ of the bound variable, while the second is\na body of the abstraction, where $x$ is bound.  The name $x$ is just kept\nto pretty-print the occurrences of the bound variable.\n\n%Similarly, the product\n%$(A:Prop)A$ of the Calculus of Constructions is represented by the\n%term:\n%\\begin{displaumath}\n%DOP2 (Prod, DOP0 (Sort (Prop Null)), DLAM (Name \\#A, Rel 1))\n%\\end{displaymath}\n\nThe following functions perform some of the most frequent operations\non the terms of the meta-language:\n\\begin{description}\n\\fun{val Generic.subst1 : 'op term -> 'op term -> 'op term}\n    {$(\\texttt{subst1}\\;t_1\\;t_2)$ substitutes $t_1$ for \n      $\\texttt{(Rel}\\;1)$ in $t_2$.}\n\\fun{val Generic.occur\\_var : identifier -> 'op term -> bool}\n    {Returns true when the given identifier appears in the term,\n    and false otherwise.}\n\\fun{val Generic.eq\\_term : 'op term -> 'op term -> bool}\n    {Implements $\\alpha$-equality for terms.}  \n\\fun{val Generic.dependent : 'op term -> 'op term -> bool}\n    {Returns true if the first term is a sub-term of the second.}\n%\\fun{val Generic.subst\\_var : identifier -> 'op term -> 'op term}\n%    { $(\\texttt{subst\\_var}\\;id\\;t)$ substitutes the deBruijn's index\n%     associated to $id$ to every occurrence of the term\n%    $(\\texttt{VAR}\\;id)$ in $t$.}\n\\end{description}\n\n\\subsubsection{Identifiers, names and sections paths.} \n\nThree different kinds of names are used in the meta-language. They are\nall defined in the \\ocaml{} file \\texttt{Names}.\n\n\\paragraph{Identifiers.}  The simplest kind of names are\n\\textsl{identifiers}. An identifier is a string possibly indexed by an\ninteger. They are used to represent names that are not unique, like\nfor example the name of a variable in the scope of a section.  The\nfollowing operations can be used for handling identifiers:\n\n\\begin{description}\n\\fun{val Names.make\\_ident : string -> int -> identifier}\n    {The value $(\\texttt{make\\_ident}\\;x\\;i)$ creates the\n    identifier $x_i$. If $i=-1$, then the identifier has\n    is created with no index at all.}\n\\fun{val Names.repr\\_ident : identifier -> string * int}\n    {The inverse operation of \\texttt{make\\_ident}: \n     it yields the string and the index of the identifier.}\n\\fun{val Names.lift\\_ident : identifier -> identifier}\n    {Increases the index of the identifier by one.}\n\\fun{val Names.next\\_ident\\_away : \\\\\n\\qquad identifier -> identifier list -> identifier}\n    {\\\\ Generates a new identifier with the same root string than the\n    given one, but with a new index, different from all the indexes of\n    a given list of identifiers.} \n\\fun{val Names.id\\_of\\_string : string ->\n    identifier} \n    {Creates an identifier from a string.}  \n\\fun{val  Names.string\\_of\\_id : identifier -> string} \n    {The inverse operation: transforms an identifier into a string}\n\\end{description}\n\n\\paragraph{Names.} A \\textsl{name} is either an identifier or the \nspecial name \\texttt{Anonymous}. Names are used as arguments of\nbinders, in order to pretty print bound variables.\nThe following operations can be used for handling names:\n\n\\begin{description}\n\\fun{val Names.Name: identifier -> Name}\n    {Constructs a name from  an identifier.}\n\\fun{val Names.Anonymous : Name}\n    {Constructs a special, anonymous identifier, like the variable abstracted \n     in the term $[\\_:A]0$.}\n\\fun{val\n     Names.next\\_name\\_away\\_with\\_default : \\\\ \\qquad\n          string->name->identifier list->identifier}\n{\\\\ If the name is not anonymous, then this function generates a new\n    identifier different from all the ones in a given list. Otherwise, it\n    generates an identifier from the given string.}\n\\end{description}\n\n\\paragraph[Section paths.]{Section paths.\\label{SectionPaths}}\nA \\textsl{section-path} is a global name to refer to an object without\nambiguity.  It can be seen as a sort of filename, where open sections\nplay the role of directories. Each section path is formed by three\ncomponents: a \\textsl{directory} (the list of open sections); a\n\\textsl{basename} (the identifier for the object); and a \\textsl{kind}\n(either CCI for the terms of the Calculus of Constructions, FW for the\nthe terms of $F_\\omega$, or OBJ for other objects). For example, the\nname of the following constant:\n\\begin{verbatim}\n     Section A.\n     Section B.\n     Section C.\n     Definition zero := O.\n\\end{verbatim}\n\nis internally represented by the section path:\n\n$$\\underbrace{\\mathtt{\\#A\\#B\\#C}}_{\\mbox{dirpath}}\n\\underbrace{\\mathtt{\\tt \\#zero}}_{\\mbox{basename}}\n\\underbrace{\\mathtt{\\tt .cci}_{\\;}}_{\\mbox{kind}}$$\n\nWhen one of the sections is closed, a new constant is created with an\nupdated section-path,a nd the old one is no longer reachable.  In our\nexample, after closing the section \\texttt{C}, the new section-path\nfor the constant {\\tt zero} becomes:\n\\begin{center}\n\\texttt{ \\#A\\#B\\#zero.cci}\n\\end{center}\n\nThe following operations can be used to handle section paths:\n\n\\begin{description}\n\\fun{val Names.string\\_of\\_path : section\\_path -> string}\n    {Transforms the section path into a string.}\n\\fun{val Names.path\\_of\\_string : string -> section\\_path}\n    {Parses a string an returns the corresponding section path.}\n\\fun{val Names.basename : section\\_path -> identifier}\n    {Provides the basename of a section path}\n\\fun{val Names.dirpath : section\\_path -> string list}\n    {Provides the directory of a section path}\n\\fun{val Names.kind\\_of\\_path : section\\_path -> path\\_kind}\n    {Provides the kind of a section path}\n\\end{description}\n\n\\subsubsection{Signatures} \n\nA \\textsl{signature} is a mapping associating different informations\nto identifiers (for example, its type, its definition, etc). The\nfollowing operations could be useful for working with signatures:\n\n\\begin{description}\n\\fun{val Names.ids\\_of\\_sign  : 'a signature -> identifier list}\n    {Gets the list of identifiers of the signature.}\n\\fun{val Names.vals\\_of\\_sign : 'a signature -> 'a list}\n    {Gets the list of values associated to the identifiers of the signature.}\n\\fun{val Names.lookup\\_glob1 : \\\\ \\qquad\nidentifier -> 'a signature -> (identifier *\n    'a)}\n    {\\\\ Gets the value associated to a given identifier of the signature.}\n\\end{description}\n\n\n\\subsection{The Terms of the Calculus of Constructions}\n\nThe language of the Calculus of Inductive Constructions described in\nChapter \\ref{Cic} is implemented on the top of the logical framework,\ninstantiating the parameter $op$ of the meta-language with a\nparticular set of operators.  In the implementation this language is\ncalled \\texttt{constr}, the language of constructions.\n\n% The only difference\n%with respect to the one described in Section \\ref{} is that the terms\n%of \\texttt{constr} may contain \\textsl{existential variables}. An\n%existential variable is a place holder representing a part of the term\n%that is still to be constructed. Such ``open terms'' are necessary\n%when building proofs interactively.\n\n\\subsubsection{Building Constructions}\n\nThe user does not need to know the choices made to represent\n\\texttt{constr} in the meta-language. They are abstracted away by the\nfollowing constructor functions:\n\n\\begin{description}\n\\fun{val Term.mkRel          : int -> constr}\n    {$(\\texttt{mkRel}\\;n)$ represents deBrujin's index $n$.}\n\n\\fun{val Term.mkVar : identifier -> constr} \n    {$(\\texttt{mkVar}\\;id)$\n    represents a global identifier named $id$, like a variable\n    inside the scope of a section, or a hypothesis in a proof}.\n\n\\fun{val Term.mkExistential : constr} \n   {\\texttt{mkExistential} represents an implicit sub-term, like the question\n    marks in the term \\texttt{(pair ? ? O true)}.}\n\n%\\fun{val Term.mkMeta         : int -> constr}\n%    {$(\\texttt{mkMeta}\\;n)$ represents an existential variable, whose\n%     name is the integer $n$.}\n\n\\fun{val Term.mkProp         : constr}\n    {$\\texttt{mkProp}$ represents the sort \\textsl{Prop}.}\n\n\\fun{val Term.mkSet          : constr}\n    {$\\texttt{mkSet}$ represents the sort \\textsl{Set}.}\n\n\\fun{val Term.mkType         : Impuniv.universe -> constr}\n    {$(\\texttt{mkType}\\;u)$ represents the term\n    $\\textsl{Type}(u)$. The universe $u$ is represented as a \n    section path indexed by an integer. }\n\n\\fun{val Term.mkConst : section\\_path -> constr array -> constr}\n    {$(\\texttt{mkConst}\\;c\\;v)$ represents a constant whose name is\n    $c$. The body of the constant is stored in a global table,\n    accessible through the name of the constant. The array of terms\n    $v$ corresponds to the variables of the environment appearing in\n    the body of the constant when it was defined. For instance, a\n    constant defined in the section \\textsl{Foo} containing the\n    variable $A$, and whose body is $[x:Prop\\ra Prop](x\\;A)$ is\n    represented inside the scope of the section by\n    $(\\texttt{mkConst}\\;\\texttt{\\#foo\\#f.cci}\\;[| \\texttt{mkVAR}\\;A\n    |])$.  Once the section is closed, the constant is represented by\n    the term $(\\texttt{mkConst}\\;\\#f.cci\\;[| |])$, and its body\n    becomes $[A:Prop][x:Prop\\ra Prop](x\\;A)$}.\n\n\\fun{val Term.mkMutInd : section\\_path -> int -> constr array ->constr}\n    {$(\\texttt{mkMutInd}\\;c\\;i)$ represents the $ith$ type\n    (starting from zero) of the block of mutually dependent\n    (co)inductive types, whose first type is $c$.  Similarly to the\n    case of constants, the array of terms represents the current\n    environment of the (co)inductive type. The definition of the type\n    (its arity, its constructors, whether it is inductive or co-inductive, etc.)\n    is stored in a global hash table, accessible through the name of \n    the type.}\n\n\\fun{val Term.mkMutConstruct : \\\\ \\qquad section\\_path -> int -> int -> constr array\n    ->constr} {\\\\ $(\\texttt{mkMutConstruct}\\;c\\;i\\;j)$ represents the\n    $jth$ constructor of the $ith$ type of the block of mutually\n    dependent (co)inductive types whose first type is $c$. The array\n    of terms represents the current environment of the (co)inductive\n    type.}\n\n\\fun{val Term.mkCast : constr -> constr -> constr}\n    {$(\\texttt{mkCast}\\;t\\;T)$ represents the annotated term $t::T$ in\n    \\Coq's syntax.}  \n\n\\fun{val Term.mkProd : name ->constr ->constr -> constr}\n    {$(\\texttt{mkProd}\\;x\\;A\\;B)$ represents the product $(x:A)B$.\n     The free ocurrences of $x$ in $B$ are represented by deBrujin's\n     indexes.}\n\n\\fun{val Term.mkNamedProd : identifier -> constr -> constr -> constr}\n    {$(\\texttt{produit}\\;x\\;A\\;B)$ represents the product $(x:A)B$,\n     but the bound occurrences of $x$ in $B$ are denoted by \n     the identifier $(\\texttt{mkVar}\\;x)$. The function automatically \n     changes each occurrences of this identifier into the corresponding \n     deBrujin's index.}\n\n\\fun{val Term.mkArrow : constr -> constr -> constr}\n    {$(\\texttt{arrow}\\;A\\;B)$ represents the type $(A\\rightarrow B)$.}\n\n\\fun{val Term.mkLambda       : name -> constr -> constr -> constr}\n    {$(\\texttt{mkLambda}\\;x\\;A\\;b)$ represents the lambda abstraction \n     $[x:A]b$. The free ocurrences of $x$ in $B$ are represented by deBrujin's\n     indexes.}\n\n\\fun{val Term.mkNamedLambda : identifier -> constr -> constr -> constr}\n    {$(\\texttt{lambda}\\;x\\;A\\;b)$ represents the lambda abstraction \n     $[x:A]b$, but the bound occurrences of $x$ in $B$ are denoted by \n     the identifier $(\\texttt{mkVar}\\;x)$. }\n\n\\fun{val Term.mkAppLA        : constr array -> constr}\n    {$(\\texttt{mkAppLA}\\;t\\;[|t_1\\ldots t_n|])$ represents the application\n    $(t\\;t_1\\;\\ldots t_n)$.}\n\n\\fun{val Term.mkMutCaseA : \\\\ \\qquad\n    case\\_info -> constr ->constr\n    ->constr array -> constr} \n    {\\\\ $(\\texttt{mkMutCaseA}\\;r\\;P\\;m\\;[|f_1\\ldots f_n|])$\n    represents the term \\Case{P}{m}{f_1\\ldots f_n}. The first argument\n    $r$ is either \\texttt{None} or $\\texttt{Some}\\;(c,i)$, where the\n    pair $(c,i)$ refers to the inductive type that $m$ belongs to.}\n\n\\fun{val Term.mkFix :  \\\\ \\qquad\nint array->int->constr array->name\n    list->constr array->constr}\n    {\\\\ $(\\texttt{mkFix}\\;[|k_1\\ldots k_n |]\\;i\\;[|A_1\\ldots\n    A_n|]\\;[|f_1\\ldots f_n|]\\;[|t_1\\ldots t_n|])$ represents the term\n    $\\Fix{f_i}{f_1/k_1:A_1:=t_1 \\ldots f_n/k_n:A_n:=t_n}$}\n\n\\fun{val Term.mkCoFix  : \\\\ \\qquad\n    int -> constr array -> name list ->\n    constr array -> constr}\n    {\\\\ $(\\texttt{mkCoFix}\\;i\\;[|A_1\\ldots\n    A_n|]\\;[|f_1\\ldots f_n|]\\;[|t_1\\ldots t_n|])$ represents the term\n    $\\CoFix{f_i}{f_1:A_1:=t_1 \\ldots f_n:A_n:=t_n}$. There are no\n    decreasing indexes in this case.}\n\\end{description}\n\n\\subsubsection{Decomposing Constructions}\n\nEach of the construction functions above has its corresponding\n(partial) destruction function, whose name is obtained changing the\nprefix \\texttt{mk} by \\texttt{dest}. In addition to these functions, a\nconcrete datatype \\texttt{kindOfTerm} can be used to do pattern\nmatching on terms without dealing with their internal representation\nin the meta-language. This concrete datatype is described in the \\ocaml{}\nfile \\texttt{term.mli}. The following function transforms a construction\ninto an element of type \\texttt{kindOfTerm}:\n\n\\begin{description}\n\\fun{val Term.kind\\_of\\_term : constr -> kindOfTerm}\n    {Destructs a term of the language \\texttt{constr},\nyielding the direct components of the term. Hence, in order to do \npattern matching on an object $c$ of \\texttt{constr}, it is sufficient\nto do pattern matching on the value $(\\texttt{kind\\_of\\_term}\\;c)$.}\n\\end{description}\n\nPart of the information associated to the constants is stored in \nglobal tables. The following functions give access to such \ninformation:\n\n\\begin{description}\n\\fun{val Termenv.constant\\_value    : constr -> constr}\n    {If the term denotes a constant, projects the body of a constant}\n\\fun{Termenv.constant\\_type     : constr -> constr}\n    {If the term denotes a constant, projects the type of the constant}\n\\fun{val mind\\_arity        : constr -> constr}\n    {If the term denotes an inductive type, projects its arity (i.e.,\n     the type of the inductive type).}\n\\fun{val Termenv.mis\\_is\\_finite    : mind\\_specif -> bool}\n    {Determines whether a recursive type is inductive or co-inductive.}\n\\fun{val Termenv.mind\\_nparams : constr -> int}\n    {If the term denotes an inductive type, projects the number of \n     its general parameters.}\n\\fun{val Termenv.mind\\_is\\_recursive : constr -> bool}\n    {If the term denotes an inductive type, \n     determines if the type has at least one recursive constructor. }\n\\fun{val Termenv.mind\\_recargs : constr -> recarg list array array}\n    {If the term denotes an inductive type, returns an array $v$ such \n     that the nth element of $v.(i).(j)$ is\n    \\texttt{Mrec} if the $nth$ argument of the $jth$ constructor of\n    the $ith$ type is recursive, and \\texttt{Norec} if it is not.}.\n\\end{description}\n\n\\subsection[The Type Checker]{The Type Checker\\label{TypeChecker}}\n\nThe third logical module is the type checker. It concentrates two main\ntasks concerning the language of constructions.\n\nOn one hand, it contains the type inference and type-checking\nfunctions.  The type inference function takes a term\n$a$ and a signature $\\Gamma$, and yields a term $A$ such that\n$\\Gamma \\vdash a:A$.  The type-checking function takes two terms $a$\nand $A$ and a signature $\\Gamma$, and determines whether or not\n$\\Gamma \\vdash a:A$.\n\nOn the other hand, this module is in charge of the compilation of\n\\Coq's abstract syntax trees into the language \\texttt{constr} of\nconstructions. This compilation seeks to eliminate all the ambiguities\ncontained in \\Coq's abstract syntax, restoring the information\nnecessary to type-check it.  It concerns at least the following steps:\n\\begin{enumerate}\n\\item Compiling the pattern-matching expressions containing \nconstructor patterns, wild-cards, etc, into terms that only\nuse the primitive \\textsl{Case} described in Chapter \\ref{Cic}\n\\item Restoring type coercions and synthesizing the implicit arguments\n(the one denoted by question marks in\n{\\Coq} syntax: see Section~\\ref{Coercions}).\n\\item Transforming the named bound variables into deBrujin's indexes.\n\\item Classifying the global names into the different classes of\nconstants (defined constants, constructors, inductive types, etc).\n\\end{enumerate}\n\n\\subsection{The Proof Engine}\n\nThe fourth stage of \\Coq's implementation is the \\textsl{proof engine}:\nthe interactive machine for constructing proofs. The aim of the proof\nengine is to construct a top-down derivation or \\textsl{proof tree},\nby the application of \\textsl{tactics}. A proof tree has the following\ngeneral structure:\\\\\n\n\\begin{displaymath}\n\\frac{\\Gamma \\vdash ? = t(?_1,\\ldots?_n) : G}\n     {\\hspace{3ex}\\frac{\\displaystyle \\Gamma_1 \\vdash ?_1 = t_1(\\ldots) : G_1}\n         {\\stackrel{\\vdots}{\\displaystyle {\\Gamma_{i_1} \\vdash ?_{i_1} \n           : G_{i_1}}}}(tac_1)\n      \\;\\;\\;\\;\\;\\;\\;\\;\\;\n      \\frac{\\displaystyle \\Gamma_n \\vdash ?_n = t_n(\\ldots) : G_n}\n         {\\displaystyle \\stackrel{\\vdots}{\\displaystyle {\\Gamma_{i_m} \\vdash ?_{i_m} :\n     G_{i_m}}}}(tac_n)} (tac)    \n\\end{displaymath}\n\n\n\\noindent Each node of the tree is called a \\textsl{goal}. A goal\nis a record type containing the following three fields:\n\\begin{enumerate}\n\\item the conclusion $G$ to be proven;\n\\item a typing signature $\\Gamma$ for the free variables in $G$;\n\\item if the goal is an internal node of the proof tree, the\ndefinition $t(?_1,\\ldots?_n)$ of an \\textsl{existential variable}\n(i.e. a possible undefined constant) $?$ of type $G$ in terms of the\nexistential variables of the children sub-goals. If the node is a\nleaf, the existential variable maybe still undefined.\n\\end{enumerate}\n\nOnce all the existential variables have been defined the derivation is\ncompleted, and a construction can be generated from the proof tree,\nreplacing each of the existential variables by its definition.  This\nis exactly what happens when one of the commands\n\\texttt{Qed}, \\texttt{Save} or \\texttt{Defined} is invoked\n(see Section~\\ref{Qed}). The saved theorem becomes a defined constant,\nwhose body is the proof object generated.\n\n\\paragraph{Important:} Before being added to the\ncontext, the proof object is type-checked, in order to verify that it is\nactually an object of the expected type $G$.  Hence, the correctness\nof the proof actually does not depend on the tactics applied to\ngenerate it or the machinery of the proof engine, but only on the\ntype-checker. In other words, extending the system with a potentially\nbugged new tactic never endangers the consistency of the system.\n\n\\subsubsection[What is a Tactic?]{What is a Tactic?\\label{WhatIsATactic}}\n%Let us now explain what is a tactic, and how the user can introduce\n%new ones. \n\nFrom an operational point of view, the current state of the proof\nengine is given by the mapping $emap$ from existential variables into\ngoals, plus a pointer to one of the leaf goals $g$.  Such a pointer\nindicates where the proof tree will be refined by the application of a\n\\textsl{tactic}. A tactic is a function from the current state\n$(g,emap)$ of the proof engine into a pair $(l,val)$. The first\ncomponent of this pair is the list of children sub-goals $g_1,\\ldots\ng_n$ of $g$ to be yielded by the tactic. The second one is a\n\\textsl{validation function}. Once the proof trees $\\pi_1,\\ldots\n\\pi_n$ for $g_1,\\ldots g_n$ have been completed, this validation\nfunction must yield a proof tree $(val\\;\\pi_1,\\ldots \\pi_n)$ deriving\n$g$.\n\nTactics can be classified into \\textsl{primitive} ones and\n\\textsl{defined} ones. Primitive tactics correspond to the five basic\noperations of the proof engine:\n\n\\begin{enumerate}\n\\item Introducing a universally quantified variable into the local\ncontext of the goal.\n\\item Defining an undefined existential variable \n\\item Changing the conclusion of the goal for another\n--definitionally equal-- term.\n\\item Changing the type of a variable in the local context for another\ndefinitionally equal term.\n\\item Erasing a variable from the local context.\n\\end{enumerate}\n\n\\textsl{Defined} tactics are tactics constructed by combining these\nprimitive operations.  Defined tactics are registered in a hash table,\nso that they can be introduced dynamically. In order to define such a\ntactic table, it is necessary to fix what a \\textsl{possible argument}\nof a tactic may be. The type \\texttt{tactic\\_arg} of the possible\narguments for tactics is a union type including:\n\\begin{itemize}\n\\item quoted strings;\n\\item integers;\n\\item identifiers;\n\\item lists of identifiers;\n\\item plain terms, represented by its abstract syntax tree;\n\\item well-typed terms, represented by a construction;\n\\item a substitution for bound variables, like the\nsubstitution in the tactic \\\\$\\texttt{Apply}\\;t\\;\\texttt{with}\\;x:=t_1\\ldots\nx_n:=t_n$, (see Section~\\ref{apply});\n\\item a reduction expression, denoting the reduction strategy to be\nfollowed.\n\\end{itemize}\nTherefore, for each function $tac:a \\rightarrow tactic$ implementing a\ndefined tactic, an associated dynamic tactic $tacargs\\_tac:\n\\texttt{tactic\\_arg}\\;list \\rightarrow tactic$ calling $tac$ must be\nwritten. The aim of the auxiliary function $tacargs\\_tac$ is to inject\nthe arguments of the tactic $tac$ into the type of possible arguments\nfor a tactic.\n\nThe following function can be used for registering and calling a\ndefined tactic:\n\n\\begin{description}\n\\fun{val Tacmach.add\\_tactic : \\\\ \\qquad\nstring -> (tactic\\_arg list ->tactic) -> unit}\n    {\\\\ Registers a dynamic tactic with the given string as access index.}\n\\fun{val Tacinterp.vernac\\_tactic : string*tactic\\_arg list -> tactic}\n    {Interprets a defined tactic given by its entry in the\n     tactics table with a particular list of possible arguments.}\n\\fun{val Tacinterp.vernac\\_interp        : CoqAst.t -> tactic}\n    {Interprets a tactic expression formed combining \\Coq's tactics and\n          tacticals, and described by its abstract syntax tree.}\n\\end{description}\n\nWhen programming a new tactic that calls an already defined tactic\n$tac$, we have the choice between using the \\ocaml{} function\nimplementing $tac$, or calling the tactic interpreter with the name\nand arguments for interpreting $tac$. In the first case, a tactic call\nwill left the trace of the whole implementation of $tac$ in the proof\ntree. In the second, the implementation of $tac$ will be hidden, and\nonly an invocation of $tac$ will be recalled (cf. the example of\nSection \\ref{ACompleteExample}.  The following combinators can be used\nto hide the implementation of a tactic:\n\n\\begin{verbatim}\ntype 'a hiding_combinator = string -> ('a -> tactic) -> ('a -> tactic)\nval Tacmach.hide_atomic_tactic  : string -> tactic -> tactic\nval Tacmach.hide_constr_tactic  : constr          hiding_combinator\nval Tacmach.hide_constrl_tactic : (constr list)   hiding_combinator\nval Tacmach.hide_numarg_tactic  : int             hiding_combinator\nval Tacmach.hide_ident_tactic   : identifier      hiding_combinator\nval Tacmach.hide_identl_tactic  : identifier      hiding_combinator\nval Tacmach.hide_string_tactic  : string          hiding_combinator\nval Tacmach.hide_bindl_tactic   : substitution    hiding_combinator\nval Tacmach.hide_cbindl_tactic  : \n          (constr * substitution) hiding_combinator\n\\end{verbatim}\n\nThese functions first register the tactic by a side effect, and then\nyield a function calling the interpreter with the registered name and\nthe right injection into the type of possible arguments.\n\n\\subsection{Tactics and Tacticals Provided by \\Coq}\n\nThe fifth logical module is the library of tacticals and basic tactics\nprovided by \\Coq. This library is distributed into the directories\n\\texttt{tactics} and \\texttt{src/tactics}. The former contains those\nbasic tactics that make use of the types contained in the basic state\nof \\Coq. For example, inversion or rewriting tactics are in the\ndirectory \\texttt{tactics}, since they make use of the propositional\nequality type.  Those tactics which are independent from the context\n--like for example \\texttt{Cut}, \\texttt{Intros}, etc-- are defined in\nthe directory \\texttt{src/tactics}. This latter directory also\ncontains some useful tools for programming new tactics, referred in \nSection \\ref{SomeUsefulToolsforWrittingTactics}.\n\nIn practice, it is very unusual that the list of sub-goals and the\nvalidation function of the tactic must be explicitly constructed by\nthe user. In most of the cases, the implementation of a new tactic\nconsists in supplying the appropriate arguments to the basic tactics\nand tacticals.\n\n\\subsubsection{Basic Tactics}\n\nThe file \\texttt{Tactics} contain the implementation of the basic\ntactics provided by \\Coq. The following tactics are some of the most\nused ones:\n\n\\begin{verbatim}\nval Tactics.intro           : tactic\nval Tactics.assumption      : tactic\nval Tactics.clear           : identifier list -> tactic\nval Tactics.apply           : constr -> constr substitution -> tactic\nval Tactics.one_constructor : int -> constr substitution -> tactic\nval Tactics.simplest_elim   : constr -> tactic\nval Tactics.elimType        : constr -> tactic\nval Tactics.simplest_case   : constr -> tactic\nval Tactics.caseType        : constr -> tactic\nval Tactics.cut             : constr -> tactic\nval Tactics.reduce          : redexpr -> tactic\nval Tactics.exact           : constr -> tactic\nval Auto.auto               : int option -> tactic\nval Auto.trivial            : tactic\n\\end{verbatim}\n\nThe functions hiding the implementation of these tactics are defined\nin the module \\texttt{Hiddentac}. Their names are prefixed by ``h\\_''.\n\n\\subsubsection[Tacticals]{Tacticals\\label{OcamlTacticals}}\n\nThe following tacticals can be used to combine already existing\ntactics:\n\n\\begin{description}\n\\fun{val Tacticals.tclIDTAC : tactic}\n    {The identity tactic: it leaves the goal as it is.}\n\n\\fun{val Tacticals.tclORELSE : tactic -> tactic -> tactic}\n    {Tries the first tactic and in case of failure applies the second one.}\n\n\\fun{val Tacticals.tclTHEN : tactic -> tactic -> tactic}\n  {Applies the first tactic and then the second one to each generated subgoal.}\n\n\\fun{val Tacticals.tclTHENS : tactic -> tactic list -> tactic}\n    {Applies a tactic, and then applies each tactic of the tactic list to the\n     corresponding generated subgoal.}\n\n\\fun{val Tacticals.tclTHENL : tactic -> tactic -> tactic}\n    {Applies the first tactic, and then applies the second one to the last\n     generated subgoal.}\n\n\\fun{val Tacticals.tclREPEAT : tactic -> tactic}\n    {If the given tactic succeeds in producing a subgoal, then it\n     is recursively applied to each generated subgoal, \n     and so on until it fails. }\n\n\\fun{val Tacticals.tclFIRST : tactic list -> tactic}\n    {Tries the tactics of the given list one by one, until one of them\n     succeeds.}\n\n\\fun{val Tacticals.tclTRY : tactic -> tactic}\n    {Tries the given tactic and in case of failure applies the {\\tt\n    tclIDTAC} tactical to the original goal.}\n\n\\fun{val Tacticals.tclDO : int -> tactic -> tactic}\n    {Applies the tactic a given number of times.}\n\n\\fun{val Tacticals.tclFAIL : tactic}\n    {The always failing tactic: it raises a {\\tt UserError} exception.}\n\n\\fun{val Tacticals.tclPROGRESS  : tactic -> tactic}\n    {Applies the given tactic to the current goal and fails if the \n     tactic leaves the goal unchanged}\n\n\\fun{val Tacticals.tclNTH\\_HYP :  int -> (constr -> tactic) -> tactic}\n    {Applies a tactic to the nth hypothesis of the local context.\n     The last hypothesis introduced correspond to the integer 1.}\n\n\\fun{val Tacticals.tclLAST\\_HYP :  (constr -> tactic) -> tactic}\n    {Applies a tactic to the last hypothesis introduced.}\n\n\\fun{val Tacticals.tclCOMPLETE : tactic -> tactic}\n    {Applies a tactic and fails if the tactic did not solve completely the\n      goal}\n\n\\fun{val Tacticals.tclMAP : ('a -> tactic) -> 'a list -> tactic}\n    {Applied to the function \\texttt{f} and the list \\texttt{[x\\_1;\n        ... ; x\\_n]}, this tactical applies the tactic\n      \\texttt{tclTHEN (f x1) (tclTHEN (f x2) ... ))))}}\n    \n\\fun{val Tacicals.tclIF : (goal sigma -> bool) -> tactic -> tactic -> tactic}\n    {If the condition holds, apply the first tactic; otherwise,\n      apply the second one}\n\n\\end{description}\n\n\n\\subsection{The Vernacular Interpreter}\n\nThe sixth logical module of the implementation corresponds to the\ninterpreter of the vernacular phrases of \\Coq. These phrases may be\nexpressions from the \\gallina{} language (definitions), general\ndirectives (setting commands) or tactics to be applied by the proof\nengine. \n\n\\subsection[The Parser and the Pretty-Printer]{The Parser and the Pretty-Printer\\label{PrettyPrinter}}\n\nThe last logical module is the parser and pretty printer of \\Coq,\nwhich is the interface between the vernacular interpreter and the\nuser. They translate the chains of characters entered at the input\ninto abstract syntax trees, and vice versa. Abstract syntax trees are\nrepresented by labeled n-ary trees, and its type is called\n\\texttt{CoqAst.t}.  For instance, the abstract syntax tree associated\nto the term $[x:A]x$ is:\n\n\\begin{displaymath}\n\\texttt{Node}\n ((0,6), \"LAMBDA\",\n  [\\texttt{Nvar}~((3, 4),\"A\");~\\texttt{Slam}~((0,6),~Some~\"x\",~\\texttt{Nvar}~((5,6),\"x\"))])\n\\end{displaymath}\n\nThe numbers correspond to \\textsl{locations}, used to point to some\ninput line and character positions in the error messages. As it was\nalready explained in Section \\ref{TypeChecker}, this term is then\ntranslated into a construction term in order to be typed.\n\nThe parser of \\Coq\\ is implemented using \\camlpppp. The lexer and the data\nused by \\camlpppp\\ to generate the parser lay in the directory\n\\texttt{src/parsing}.  This directory also contains \\Coq's\npretty-printer. The printing rules lay in the directory\n\\texttt{src/syntax}.  The different entries of the grammar are\ndescribed in the module \\texttt{Pcoq.Entry}.  Let us present here two\nimportant functions of this logical module:\n\n\\begin{description}\n\\fun{val Pcoq.parse\\_string : 'a Grammar.Entry.e -> string -> 'a}\n    {Parses a given string, trying to recognize a phrase\n     corresponding to some entry in the grammar. If it succeeds,\n     it yields a value associated to the grammar entry. For example,\n     applied to the entry \\texttt{Pcoq.Command.command}, this function\n    parses a term of \\Coq's language, and yields a value of type \n    \\texttt{CoqAst.t}. When applied to the entry\n    \\texttt{Pcoq.Vernac.vernac}, it parses a vernacular command and\n    returns the corresponding Ast.}\n\\fun{val gentermpr       : \\\\ \\qquad \npath\\_kind -> constr assumptions -> constr -> std\\_ppcmds}\n    {\\\\ Pretty-prints a well-typed term of certain kind (cf. Section\n    \\ref{SectionPaths}) under its context of typing assumption.}\n\\fun{val gentacpr        : CoqAst.t -> std\\_ppcmds}\n    {Pretty-prints a given abstract syntax tree representing a tactic\n     expression.}\n\\end{description}\n\n\\subsection{The General Library}\n\nIn addition to the ones laying in the standard library of \\ocaml{},\nseveral useful modules about lists, arrays, sets, mappings, balanced\ntrees, and other frequently used data structures can be found in the\ndirectory \\texttt{lib}. Before writing a new one, check if it is not\nalready there!\n\n\\subsubsection{The module \\texttt{Std}}\nThis module in the directory \\texttt{src/lib/util} is opened by almost \nall modules of \\Coq{}. Among other things, it contains a definition of \nthe different kinds of errors used in \\Coq{} :\n\n\\begin{description}\n\\fun{exception UserError of string * std\\_ppcmds}\n    {This is the class of ``users exceptions''. Such errors arise when \n      the user attempts to do something illegal, for example \\texttt{Intro}\n      when the current goal conclusion is not a product.}\n\n\\fun{val Std.error : string -> 'a}\n    {For simple error messages}\n\\fun{val Std.errorlabstrm : string -> std\\_ppcmds -> 'a}\n    {See Section~\\ref{PrettyPrinter} : this can be used if the user\n      want to display a term or build a complex error message}\n\n\\fun{exception Anomaly of string * std\\_ppcmds}\n    {This for reporting bugs or things that should not\n      happen. The tacticals \\texttt{tclTRY} and\n      \\texttt{tclTRY} described in Section~\\ref{OcamlTacticals} catch the\n      exceptions of type \\texttt{UserError}, but they don't catch the\n      anomalies. So, in your code, don't raise any anomaly, unless you\n      know what you are doing. We also recommend to avoid constructs\n      such as \\texttt{try ... with \\_ -> ...} : such constructs can trap \n      an anomaly and make the debugging process harder.}\n\n\\fun{val Std.anomaly : string -> 'a}{}\n\\fun{val Std.anomalylabstrm : string -> std\\_ppcmds -> 'a}{}\n\\end{description}\n\n\\section{The tactic writer mini-HOWTO}\n\n\\subsection{How to add a vernacular command}\n\nThe command to register a vernacular command can be found\nin module \\texttt{Vernacinterp}:\n\n\\begin{verbatim}\nval vinterp_add : string * (vernac_arg list -> unit -> unit) -> unit;;\n\\end{verbatim}\n\nThe first argument is the name, the second argument is a function that\nparses the arguments and returns a function of type\n\\texttt{unit}$\\rightarrow$\\texttt{unit} that do the job.\n\nIn this section we will show how to add a vernacular command\n\\texttt{CheckCheck} that print a type of a term and the type of its\ntype.\n\nFile \\texttt{dcheck.ml}:\n\n\\begin{verbatim}\nopen Vernacinterp;;\nopen Trad;;\nlet _ = \n  vinterp_add \n   (\"DblCheck\",\n    function [VARG_COMMAND com] ->\n       (fun () -> \n          let evmap = Evd.mt_evd () \n          and sign = Termenv.initial_sign () in\n           let {vAL=c;tYP=t;kIND=k} = \n                 fconstruct_with_univ evmap sign com in\n             Pp.mSGNL [< Printer.prterm c; 'sTR \":\"; \n                       Printer.prterm t; 'sTR \":\"; \n                       Printer.prterm k >] )\n      | _ -> bad_vernac_args \"DblCheck\")\n;;\n\\end{verbatim}\n\nLike for a new tactic, a new syntax entry must be created.\n\nFile \\texttt{DCheck.v}:\n\n\\begin{verbatim}\nDeclare ML Module \"dcheck.ml\".\n\nGrammar vernac vernac := \n  dblcheck [ \"CheckCheck\" comarg($c) ] -> [(DblCheck $c)].\n\\end{verbatim}\n\nWe are now able to test our new command:\n\n\\begin{verbatim}\nCoq < Require DCheck.\nCoq < CheckCheck O.\nO:nat:Set\n\\end{verbatim}\n\nMost Coq vernacular commands are registered in the module \n  \\verb+src/env/vernacentries.ml+. One can see more examples here.\n\n\\subsection{How to keep a hashtable synchronous with the reset mechanism}\n\nThis is far more tricky. Some vernacular commands modify some\nsort of state (for example by adding something in a hashtable). One\nwants that \\texttt{Reset} has the expected behavior with this\ncommands.\n\n\\Coq{} provides a general mechanism to do that. \\Coq{} environments\ncontains objects of three kinds: CCI, FW and OBJ. CCI and FW are for\nconstants of the calculus. OBJ is a dynamically extensible datatype\nthat contains sections, tactic definitions, hints for auto, and so\non. \n\nThe simplest example of use of such a mechanism is in file\n\\verb+src/proofs/macros.ml+ (which implements the \\texttt{Tactic\n  Definition} command). Tactic macros are stored in the imperative\nhashtable \\texttt{mactab}. There are two functions freeze and unfreeze\nto make a copy of the table and to restore the state of table from the\ncopy. Then this table is declared using \\texttt{Library.declare\\_summary}.\n\nWhat does \\Coq{} with that ? \\Coq{} defines synchronization points.\nAt each synchronisation point, the declared tables are frozen (that\nis, a copy of this tables is stored).\n\nWhen \\texttt{Reset }$i$ is called, \\Coq{} goes back to the first\nsynchronisation point that is above $i$ and ``replays'' all objects\nbetween that point \nand $i$. It will re-declare constants, re-open section, etc.\n\nSo we need to declare a new type of objects, TACTIC-MACRO-DATA. To\n``replay'' on object of that type is to add the corresponding tactic\nmacro to \\texttt{mactab}\n\nSo, now, we can say that \\texttt{mactab} is synchronous with the Reset\nmechanism$^{\\mathrm{TM}}$.\n\nNotice that this works for hash tables but also for a single integer\n(the Undo stack size, modified by the \\texttt{Set Undo} command, for\nexample).\n\n\\subsection{The right way to access to Coq constants from your ML code}\n\nWith their long names, Coq constants are stored using:\n\n\\begin{itemize}\n\\item a section path\n\\item an identifier\n\\end{itemize}\n\nThe identifier is exactly the identifier that is used in \\Coq{} to\ndenote the constant; the section path can be known using the\n\\texttt{Locate} command:\n\n\\begin{coq_example}\n  Locate S.\n  Locate nat.\n  Locate eq.\n\\end{coq_example}\n\nNow it is easy to get a constant by its name and section path:\n\n\n\\begin{verbatim}\nlet constant sp id = \n  Machops.global_reference (Names.gLOB (Termenv.initial_sign ())) \n    (Names.path_of_string sp) (Names.id_of_string id);;\n\\end{verbatim}\n\n\nThe only issue is that if one cannot put:\n\n\n\\begin{verbatim}\nlet coq_S = constant \"#Datatypes#nat.cci\" \"S\";;\n\\end{verbatim}\n\n\nin his tactic's code. That is because this sentence is evaluated\n\\emph{before} the module \\texttt{Datatypes} is loaded. The solution is\nto use the lazy evaluation of \\ocaml{}:\n\n\n\\begin{verbatim}\nlet coq_S = lazy (constant \"#Datatypes#nat.cci\" \"S\");;\n\n... (Lazy.force coq_S) ...\n\\end{verbatim}\n\n\nBe sure to call always Lazy.force behind a closure -- i.e. inside a\nfunction body or behind the \\texttt{lazy} keyword.\n\nOne can see examples of that technique in the source code of \\Coq{},\nfor example \n\\verb+plugins/omega/coq_omega.ml+.\n\n\\section[Some Useful Tools for Writing Tactics]{Some Useful Tools for Writing Tactics\\label{SomeUsefulToolsforWrittingTactics}}\nWhen the implementation of a tactic is not a straightforward\ncombination of tactics and tacticals, the module \\texttt{Tacmach}\nprovides several useful functions for handling goals, calling the\ntype-checker, parsing terms, etc. This module is intended to be \nthe interface of the proof engine for the user.\n\n\\begin{description}\n\\fun{val Tacmach.pf\\_hyps               : goal sigma -> constr signature}\n    {Projects the local typing context $\\Gamma$ from a given goal $\\Gamma\\vdash ?:G$.} \n\\fun{val pf\\_concl              : goal sigma -> constr}\n    {Projects the conclusion $G$ from a given goal $\\Gamma\\vdash ?:G$.}\n\\fun{val Tacmach.pf\\_nth\\_hyp            : goal sigma -> int -> identifier *\n    constr}\n    {Projects the $ith$ typing constraint $x_i:A_i$ from the local\n     context of the given goal.}\n\\fun{val Tacmach.pf\\_fexecute           : goal sigma -> constr -> judgement}\n    {Given a goal whose local context is $\\Gamma$ and a term $a$, this\n     function infers a type $A$ and a kind $K$ such that the judgement\n     $a:A:K$ is valid under $\\Gamma$, or raises an exception if there\n     is no such judgement. A judgement is just a record type containing\n     the three terms $a$, $A$ and $K$.}\n\\fun{val Tacmach.pf\\_infexecute : \\\\\n     \\qquad\ngoal sigma -> constr -> judgement * information}\n    {\\\\ In addition to the typing judgement, this function also extracts \n     the $F_{\\omega}$ program underlying the term.}\n\\fun{val Tacmach.pf\\_type\\_of            : goal sigma -> constr -> constr}\n    {Infers a term $A$ such that $\\Gamma\\vdash a:A$ for a given term\n    $a$, where $\\Gamma$ is the local typing context of the goal.}\n\\fun{val Tacmach.pf\\_check\\_type         : goal sigma -> constr -> constr -> bool}\n    {This function yields a type $A$ if the two given terms $a$ and $A$  verify $\\Gamma\\vdash\n     a:A$ in the local typing context $\\Gamma$ of the goal. Otherwise,\n    it raises an exception.}\n\\fun{val Tacmach.pf\\_constr\\_of\\_com      : goal sigma -> CoqAst.t -> constr}\n    {Transforms an abstract syntax tree into a well-typed term of the\n    language of constructions. Raises an exception if the term cannot\n    be typed.}\n\\fun{val Tacmach.pf\\_constr\\_of\\_com\\_sort : goal sigma -> CoqAst.t -> constr}\n    {Transforms an abstract syntax tree representing a type into\n    a well-typed term of the language of constructions. Raises an\n    exception if the term cannot be typed.}\n\\fun{val Tacmach.pf\\_parse\\_const        : goal sigma -> string -> constr}\n    {Constructs the constant whose name is the given string.}\n\\fun{val\nTacmach.pf\\_reduction\\_of\\_redexp  : \\\\\n         \\qquad goal sigma -> red\\_expr -> constr -> constr}\n    {\\\\ Applies a certain kind of reduction function, specified by an\n     element of the type red\\_expr.}\n\\fun{val Tacmach.pf\\_conv\\_x      : goal sigma -> constr -> constr -> bool}\n    {Test whether  two given terms are definitionally equal.}\n\\end{description}\n\n\\subsection[Patterns]{Patterns\\label{Patterns}}\n\nThe \\ocaml{} file \\texttt{Pattern} provides a quick way for describing a\nterm pattern and performing second-order, binding-preserving, matching\non it. Patterns are described using an extension of \\Coq's concrete\nsyntax, where the second-order meta-variables of the pattern are\ndenoted by indexed question marks. \n\nPatterns may depend on constants, and therefore only to make have\nsense when certain theories have been loaded. For this reason, they\nare stored with a \\textsl{module-marker}, telling us which modules\nhave to be open in order to use the pattern. The following functions\ncan be used to store and retrieve patterns form the pattern table:\n\n\\begin{description}\n\\fun{val Pattern.make\\_module\\_marker : string list -> module\\_mark}\n    {Constructs a module marker from a list of module names.}\n\\fun{val Pattern.put\\_pat : module\\_mark -> string -> marked\\_term}\n    {Constructs a pattern from a parseable string containing holes\n     and a module marker.}\n\\fun{val Pattern.somatches    : constr ->   marked\\_term-> bool}\n    {Tests if a term matches a pattern.} \n\\fun{val dest\\_somatch : constr -> marked\\_term -> constr list}\n    {If the term matches the pattern, yields the list of sub-terms\n     matching the occurrences of the pattern variables (ordered from\n     left to right). Raises a \\texttt{UserError} exception if the term\n     does not match the pattern.} \n\\fun{val Pattern.soinstance : marked\\_term -> constr list -> constr} \n    {Substitutes each hole in the pattern \n     by the corresponding term of the given the list.}\n\\end{description}\n\n\\paragraph{Warning:} Sometimes, a \\Coq\\ term may have invisible\nsub-terms that the matching functions are nevertheless sensible to.\nFor example, the \\Coq\\ term $(?_1,?_2)$ is actually a shorthand for\nthe expression $(\\texttt{pair}\\;?\\;?\\;?_1\\;?_2)$.\nHence, matching this term pattern \nwith the term $(\\texttt{true},\\texttt{O})$ actually yields the list\n$[?;?;\\texttt{true};\\texttt{O}]$ as result (and \\textbf{not}\n$[\\texttt{true};\\texttt{O}]$, as could be expected).\n\n\\subsection{Patterns on Inductive Definitions}\n\nThe module \\texttt{Pattern} also includes some functions for testing\nif the definition of an inductive type satisfies certain\nproperties. Such functions may be used to perform pattern matching\nindependently from the name given to the inductive type and the\nuniverse it inhabits.  They yield the value $(\\texttt{Some}\\;r::l)$ if\nthe input term reduces into an application of an inductive type $r$ to\na list of terms $l$, and the definition of $r$ satisfies certain\nconditions. Otherwise, they yield the value \\texttt{None}.\n\n\\begin{description}\n\\fun{val Pattern.match\\_with\\_non\\_recursive\\_type : constr list option}\n    {Tests if the inductive type $r$ has no recursive constructors}\n\\fun{val Pattern.match\\_with\\_disjunction : constr list option}\n    {Tests if the inductive type $r$ is a non-recursive type\n     such that all its constructors have a single argument.}\n\\fun{val Pattern.match\\_with\\_conjunction : constr list option}\n    {Tests if the inductive type $r$ is a non-recursive type\n     with a unique constructor.}\n\\fun{val Pattern.match\\_with\\_empty\\_type  : constr list option}\n    {Tests if the inductive type $r$ has no constructors at all}\n\\fun{val Pattern.match\\_with\\_equation    : constr list option}\n    {Tests if the inductive type $r$ has a single constructor\n     expressing the property of reflexivity for some type. For\n     example, the types $a=b$, $A\\mbox{==}B$ and $A\\mbox{===}B$ satisfy\n     this predicate.}\n\\end{description}\n\n\\subsection{Elimination Tacticals}\n\nIt is frequently the case that the subgoals generated by an\nelimination can all be solved in a similar way, possibly parametrized\non some information about each case, like for example:\n\\begin{itemize}\n\\item the inductive type of the object being eliminated;\n\\item its arguments (if it is an inductive predicate);\n\\item the branch number;\n\\item the predicate to be proven;\n\\item the number of assumptions to be introduced by the case\n\\item the signature of the branch, i.e., for each argument of\nthe branch whether it is recursive or not.\n\\end{itemize}\n\nThe following tacticals can be useful to deal with such situations.\nThey  \n\n\\begin{description}\n\\fun{val Elim.simple\\_elimination\\_then : \\\\ \\qquad\n(branch\\_args -> tactic) -> constr -> tactic}\n    {\\\\ Performs the default elimination on the last argument, and then\n     tries to solve the generated subgoals using a given parametrized\n     tactic. The type branch\\_args is a record type containing all \n     information mentioned above.}\n\\fun{val Elim.simple\\_case\\_then : \\\\ \\qquad\n(branch\\_args -> tactic) -> constr -> tactic}\n    {\\\\ Similarly, but it performs case analysis instead of induction.}\n\\end{description}\n\n\\section[A Complete Example]{A Complete Example\\label{ACompleteExample}}\n\nIn order to illustrate the implementation of a new tactic, let us come\nback to the problem of deciding the equality of two elements of an\ninductive type.\n\n\\subsection{Preliminaries}\n\nLet us call \\texttt{newtactic} the directory that will contain the\nimplementation of the new tactic. In this directory will lay two\nfiles: a file \\texttt{eqdecide.ml}, containing the \\ocaml{} sources that\nimplements the tactic, and a \\Coq\\ file \\texttt{Eqdecide.v}, containing\nits associated grammar rules and the commands to generate a module\nthat can be loaded dynamically from \\Coq's toplevel. \n\nTo compile our project, we will create a \\texttt{Makefile} with the\ncommand \\texttt{do\\_Makefile} (see Section~\\ref{Makefile}) :\n\n\\begin{quotation}\n  \\texttt{do\\_Makefile eqdecide.ml EqDecide.v > Makefile}\\\\\n  \\texttt{touch .depend}\\\\\n  \\texttt{make depend}\n\\end{quotation}\n\nWe must have kept the sources of \\Coq{} somewhere and to set an\nenvironment variable \\texttt{COQTOP} that points to that directory.\n\n\\subsection{Implementing the Tactic}\n\nThe file \\texttt{eqdecide.ml} contains the implementation of the\ntactic in \\ocaml{}. Let us recall the main steps of the proof strategy\nfor deciding the proposition $(x,y:R)\\{x=y\\}+\\{\\neg x=y\\}$ on the\ninductive type $R$:\n\\begin{enumerate}\n\\item Eliminate $x$ and then $y$.\n\\item Try discrimination to solve those goals where $x$ and $y$ has\nbeen introduced by different constructors.\n\\item If $x$ and $y$ have been introduced by the same constructor,\n      then analyze one by one the corresponding pairs of arguments.\n      If they are equal, rewrite one into the other. If they are\n      not, derive a contradiction from the invectiveness of the\n      constructor.\n\\item Once all the arguments have been rewritten, solve the left half\nof the goal by reflexivity.\n\\end{enumerate}\n\nIn the sequel we implement these steps one by one. We start opening\nthe modules necessary for the implementation of the tactic:\n\n\\begin{verbatim}\nopen Names\nopen Term\nopen Tactics\nopen Tacticals\nopen Hiddentac\nopen Equality\nopen Auto\nopen Pattern\nopen Names\nopen Termenv\nopen Std\nopen Proof_trees\nopen Tacmach\n\\end{verbatim}\n\nThe first step of the procedure can be straightforwardly implemented as\nfollows:\n\n\\begin{verbatim}\nlet clear_last = (tclLAST_HYP (fun c -> (clear_one (destVar c))));;\n\\end{verbatim}\n\n\\begin{verbatim}\nlet mkBranches = \n        (tclTHEN  intro \n        (tclTHEN (tclLAST_HYP h_simplest_elim)\n        (tclTHEN  clear_last\n        (tclTHEN  intros \n        (tclTHEN (tclLAST_HYP h_simplest_case)\n        (tclTHEN  clear_last\n                  intros))))));;\n\\end{verbatim}\n\nNotice the use of the tactical \\texttt{tclLAST\\_HYP}, which avoids to\ngive a (potentially clashing) name to the quantified variables of the\ngoal when they are introduced.\n\nThe second step of the procedure is implemented by the following\ntactic:\n\n\\begin{verbatim}\nlet solveRightBranch  = (tclTHEN simplest_right discrConcl);;\n\\end{verbatim}\n\nIn order to illustrate how the implementation of a tactic can be \nhidden, let us do it with the tactic above:\n\n\\begin{verbatim}\nlet h_solveRightBranch =\n    hide_atomic_tactic \"solveRightBranch\" solveRightBranch\n;;\n\\end{verbatim}\n\nAs it was already mentioned in Section \\ref{WhatIsATactic}, the\ncombinator \\texttt{hide\\_atomic\\_tactic} first registers the tactic\n\\texttt{solveRightBranch} in the table, and returns a tactic which\ncalls the interpreter with the used to register it. Hence, when the\ntactical \\texttt{Info} is used, our tactic will just inform that\n\\texttt{solveRightBranch} was applied, omitting all the details\ncorresponding to \\texttt{simplest\\_right} and \\texttt{discrConcl}.\n\n\n\nThe third step requires some auxiliary functions for constructing the\ntype $\\{c_1=c_2\\}+\\{\\neg c_1=c_2\\}$ for a given inductive type $R$ and\ntwo constructions $c_1$ and $c_2$, and for generalizing this type over\n$c_1$ and $c_2$:\n\n\\begin{verbatim}\nlet mmk         = make_module_marker [\"#Logic.obj\";\"#Specif.obj\"];;\nlet eqpat       = put_pat mmk \"eq\";;                 \nlet sumboolpat  = put_pat mmk \"sumbool\";;             \nlet notpat      = put_pat mmk \"not\";;   \nlet eq          = get_pat eqpat;;\nlet sumbool     = get_pat sumboolpat;;\nlet not         = get_pat notpat;;\n\nlet mkDecideEqGoal rectype c1 c2 g = \n     let equality    = mkAppL [eq;rectype;c1;c2] in\n     let disequality = mkAppL [not;equality]\n     in  mkAppL [sumbool;equality;disequality]\n;;\nlet mkGenDecideEqGoal rectype g = \n      let hypnames = ids_of_sign (pf_hyps g) in \n      let xname    = next_ident_away (id_of_string \"x\") hypnames\n      and yname    = next_ident_away (id_of_string \"y\") hypnames\n      in  (mkNamedProd xname rectype \n           (mkNamedProd yname rectype \n            (mkDecideEqGoal rectype (mkVar xname) (mkVar yname) g)))\n;;\n\\end{verbatim}\n\nThe tactic will depend on the \\Coq modules \\texttt{Logic} and\n\\texttt{Specif}, since we use the constants corresponding to\npropositional equality (\\texttt{eq}), computational disjunction\n(\\texttt{sumbool}), and logical negation (\\texttt{not}), defined in\nthat modules. This is specified creating the module maker\n\\texttt{mmk} (see Section~\\ref{Patterns}).\n\nThe third step of the procedure can be divided into three sub-steps.\nAssume that both $x$ and $y$ have been introduced by the same\nconstructor.  For each corresponding pair of arguments of that\nconstructor, we have to consider whether they are equal or not.  If\nthey are equal, the following tactic is applied to rewrite one into\nthe other:\n\n\\begin{verbatim}\nlet eqCase  tac = \n         (tclTHEN intro  \n         (tclTHEN (tclLAST_HYP h_rewriteLR)\n         (tclTHEN clear_last \n                  tac)))\n;;\n\\end{verbatim}\n\n\nIf they are not equal, then the goal is contraposed and a\ncontradiction is reached form the invectiveness of the constructor:\n\n\\begin{verbatim}\nlet diseqCase = \n    let diseq  = (id_of_string \"diseq\") in\n    let absurd = (id_of_string \"absurd\")\n    in (tclTHEN (intro_using diseq)\n       (tclTHEN  h_simplest_right\n       (tclTHEN  red_in_concl\n       (tclTHEN  (intro_using absurd)\n       (tclTHEN  (h_simplest_apply (mkVar diseq))\n       (tclTHEN  (h_injHyp absurd)\n                  trivial ))))))\n;;\n\\end{verbatim}\n\nIn the tactic above we have chosen to name the hypotheses because\nthey have to be applied later on. This introduces a potential risk\nof name clashing if the context already contains other hypotheses \nalso named ``diseq'' or ``absurd''.\n\nWe are now ready to implement the tactic \\textsl{SolveArg}.  Given the\ntwo arguments $a_1$ and $a_2$ of the constructor, this tactic cuts the\ngoal with the proposition $\\{a_1=a_2\\}+\\{\\neg a_1=a_2\\}$, and then\napplies the tactics above to each of the generated cases. If the\ndisjunction cannot be solved automatically, it remains as a sub-goal\nto be proven.\n\n\\begin{verbatim}\nlet solveArg a1 a2 tac  g = \n     let rectype = pf_type_of g a1 in\n     let decide  = mkDecideEqGoal rectype a1 a2 g\n     in  (tclTHENS  (h_elimType decide) \n                      [(eqCase tac);diseqCase;default_auto]) g\n;;\n\\end{verbatim}\n\nThe following tactic implements the third and fourth steps of the\nproof procedure:\n\n\\begin{verbatim}\nlet conclpatt = put_pat mmk \"{<?1>?2=?3}+{?4}\"\n;;\nlet solveLeftBranch rectype g = \n      let (_::(lhs::(rhs::_))) = \n               try (dest_somatch (pf_concl g) conclpatt) \n               with UserError (\"somatch\",_)-> error \"Unexpected conclusion!\" in\n      let nparams   = mind_nparams rectype   in\n      let getargs l = snd (chop_list nparams (snd (decomp_app l))) in\n      let rargs   = getargs rhs\n      and largs   = getargs lhs\n      in  List.fold_right2 \n             solveArg largs rargs (tclTHEN h_simplest_left h_reflexivity) g\n;;\n\\end{verbatim}\n\nNotice the use of a pattern to decompose the goal and obtain the\ninductive type and the left and right hand sides of the equality. A\ncertain number of arguments correspond to the general parameters of\nthe type, and must be skipped over. Once the corresponding list of\narguments \\texttt{rargs} and \\texttt{largs} have been obtained, the\ntactic \\texttt{solveArg} is iterated on them, leaving a disjunction\nwhose left half can be solved by reflexivity.\n\nThe following tactic joints together the three steps of the \nproof procedure:\n\n\\begin{verbatim}\nlet initialpatt = put_pat mmk \"(x,y:?1){<?1>x=y}+{~(<?1>x=y)}\"\n;;\nlet decideGralEquality g = \n  let (typ::_) = try (dest_somatch (pf_concl g) initialpatt)\n                 with UserError (\"somatch\",_) -> \n                        error \"The goal does not have the expected form\" in\n  let headtyp = hd_app (pf_compute g typ) in\n  let rectype = match (kind_of_term  headtyp) with\n                 IsMutInd _ -> headtyp \n               | _          -> error (\"This decision procedure only\"\n                                      \" works for inductive objects\") \n  in (tclTHEN   mkBranches \n     (tclORELSE h_solveRightBranch (solveLeftBranch rectype))) g\n;;\n;;\n\\end{verbatim}\n\nThe tactic above can be specialized in two different ways: either to\ndecide a particular instance $\\{c_1=c_2\\}+\\{\\neg c_1=c_2\\}$ of the\nuniversal quantification; or to eliminate this property and obtain two\nsubgoals containing the hypotheses $c_1=c_2$ and $\\neg c_1=c_2$\nrespectively.\n\n\\begin{verbatim}\nlet decideGralEquality = \n  (tclTHEN mkBranches (tclORELSE h_solveRightBranch solveLeftBranch))\n;;\nlet decideEquality c1 c2 g = \n     let rectype = pf_type_of g c1 in\n     let decide  = mkGenDecideEqGoal rectype g\n     in  (tclTHENS (cut decide) [default_auto;decideGralEquality]) g\n;;\nlet compare c1 c2 g = \n     let rectype = pf_type_of g c1 in\n     let decide  = mkDecideEqGoal rectype c1 c2 g\n     in  (tclTHENS (cut decide) \n                [(tclTHEN  intro \n                 (tclTHEN (tclLAST_HYP simplest_case)\n                          clear_last));\n                  decideEquality c1 c2]) g\n;;\n\\end{verbatim}\n\nNext, for each of the tactics that will have an entry in the grammar\nwe construct the associated dynamic one to be registered in the table\nof tactics. This function can be used to overload a tactic name with\nseveral similar tactics.  For example, the tactic proving the general\ndecidability property and the one proving a particular instance for\ntwo terms can be grouped together with the following convention: if\nthe user provides two terms as arguments, then the specialized tactic\nis used; if no argument is provided then the general tactic is invoked.\n\n\\begin{verbatim}\nlet dyn_decideEquality  args g =\n      match args with \n       [(COMMAND com1);(COMMAND com2)]  -> \n          let c1 = pf_constr_of_com g com1\n          and c2 = pf_constr_of_com g com2\n          in  decideEquality c1 c2 g \n     | [] ->  decideGralEquality g\n     | _  ->  error \"Invalid arguments for dynamic tactic\"\n;;\nadd_tactic \"DecideEquality\" dyn_decideEquality\n;;\n\nlet dyn_compare args g =\n      match args with \n       [(COMMAND com1);(COMMAND com2)]  -> \n          let c1 = pf_constr_of_com g com1\n          and c2 = pf_constr_of_com g com2\n          in  compare c1 c2 g\n     | _  ->  error \"Invalid arguments for dynamic tactic\"\n;; \nadd_tactic \"Compare\" tacargs_compare\n;;\n\\end{verbatim}\n\nThis completes the implementation of the tactic. We turn now to the\n\\Coq file \\texttt{Eqdecide.v}.\n\n\n\\subsection{The Grammar Rules}\n\nAssociated to the implementation of the tactic there is a \\Coq\\ file\ncontaining the grammar and pretty-printing rules for the new tactic,\nand the commands to generate an object module that can be then loaded\ndynamically during a \\Coq\\ session. In order to generate an ML module,\nthe \\Coq\\ file must contain a\n\\texttt{Declare ML module} command for all the \\ocaml{} files concerning\nthe implementation of the tactic --in our case there is only one file,\nthe file \\texttt{eqdecide.ml}: \n\n\\begin{verbatim}\nDeclare ML Module \"eqdecide\".\n\\end{verbatim}\n\nThe following grammar and pretty-printing rules are\nself-explanatory. We refer the reader to the Section \\ref{Grammar} for\nthe details:\n\n\\begin{verbatim}\nGrammar tactic simple_tactic :=\n  EqDecideRuleG1 \n       [ \"Decide\"  \"Equality\" comarg($com1)  comarg($com2)] -> \n       [(DecideEquality $com1 $com2)]\n| EqDecideRuleG2 \n       [ \"Decide\" \"Equality\"  ] -> \n       [(DecideEquality)]\n| CompareRule \n       [ \"Compare\" comarg($com1) comarg($com2)] -> \n       [(Compare $com1 $com2)].\n\nSyntax tactic level 0:\n  EqDecideRulePP1 \n       [(DecideEquality)]   -> \n       [\"Decide\" \"Equality\"]\n| EqDecideRulePP2 \n       [(DecideEquality $com1 $com2)]   -> \n       [\"Decide\" \"Equality\" $com1 $com2]\n| ComparePP \n       [(Compare $com1 $com2)] -> \n       [\"Compare\" $com1 $com2].\n\\end{verbatim}\n\n\n\\paragraph{Important:} The names used to label the abstract syntax tree \nin the grammar rules ---in this case ``DecideEquality'' and\n``Compare''--- must be the same as the name used to register the\ntactic in the tactics table. This is what makes the links between the\ninput entered by the user and the tactic executed by the interpreter.\n\n\\subsection{Loading the Tactic}\n\nOnce the module \\texttt{EqDecide.v} has been compiled, the tactic can\nbe dynamically loaded using the \\texttt{Require} command. \n\n\\begin{coq_example}\nRequire EqDecide.\nGoal (x,y:nat){x=y}+{~x=y}.\nDecide Equality.\n\\end{coq_example}\n\nThe implementation of the tactic can be accessed through the\ntactical \\texttt{Info}:\n\\begin{coq_example}\nUndo.\nInfo Decide Equality.\n\\end{coq_example}\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\nRemark that the task performed by the tactic \\texttt{solveRightBranch}\nis not displayed, since we have chosen to hide its implementation.\n\n\\section[Testing and Debugging your Tactic]{Testing and Debugging your Tactic\\label{test-and-debug}}\n\nWhen your tactic does not behave as expected, it is possible to trace\nit dynamically from \\Coq. In order to do this, you have first to leave\nthe toplevel of \\Coq, and come back to the \\ocaml{} interpreter. This can\nbe done using the command \\texttt{Drop} (see Section~\\ref{Drop}). Once\nin the \\ocaml{} toplevel, load the file \\texttt{tactics/include.ml}.\nThis file installs several pretty printers for proof trees, goals,\nterms, abstract syntax trees, names, etc.  It also contains the\nfunction \\texttt{go:unit -> unit} that enables to go back to \\Coq's\ntoplevel. \n\nThe modules \\texttt{Tacmach} and \\texttt{Pfedit} contain some basic\nfunctions for extracting information from the state of the proof\nengine. Such functions can be used to debug your tactic if\nnecessary. Let us mention here some of them:\n\n\\begin{description}\n\\fun{val get\\_pftreestate         : unit -> pftreestate}\n    {Projects the current state of the proof engine.}\n\\fun{val proof\\_of\\_pftreestate    : pftreestate -> proof}\n    {Projects the current state of the proof tree. A pretty-printer \n      displays it in a readable form.  }\n\\fun{val top\\_goal\\_of\\_pftreestate : pftreestate -> goal sigma}\n    {Projects the goal and the existential variables mapping from\n     the current state of the proof engine.} \n\\fun{val nth\\_goal\\_of\\_pftreestate : int -> pftreestate -> goal sigma}\n    {Projects the goal and mapping corresponding to the $nth$ subgoal\n     that remains to be proven}\n\\fun{val traverse                : int -> pftreestate -> pftreestate}\n    {Yields the children of the node that the current state of the \n     proof engine points to.}\n\\fun{val solve\\_nth\\_pftreestate   : \\\\ \\qquad\nint -> tactic -> pftreestate ->  pftreestate}\n     {\\\\ Provides the new state of the proof engine obtained applying \n      a given tactic to some unproven sub-goal.}\n\\end{description}\n\nFinally, the traditional \\ocaml{} debugging tools like the directives\n\\texttt{trace} and \\texttt{untrace} can be used to follow the\nexecution of your functions. Frequently, a better solution is to use\nthe \\ocaml{} debugger, see Chapter \\ref{Utilities}.\n\n\\section[Concrete syntax for ML tactic and vernacular command]{Concrete syntax for ML tactic and vernacular command\\label{Notations-for-ML-command}}\n\n\\subsection{The general case}\n\nThe standard way to bind an ML-written tactic or vernacular command to\na concrete {\\Coq} syntax is to use the\n\\verb=TACTIC EXTEND= and \\verb=VERNAC COMMAND EXTEND= macros.\n\nThese macros can be used in any {\\ocaml} file defining a (new) ML tactic\nor vernacular command. They are expanded into pure {\\ocaml} code by\nthe {\\camlpppp} preprocessor of {\\ocaml}. Concretely, files that use\nthese macros need to be compiled by giving to {\\tt ocamlc} the option \n\n\\verb=-pp \"camlp4o -I $(COQTOP)/parsing grammar.cma pa_extend.cmo\"=\n\n\\noindent which is the default for every file compiled by means of a Makefile\ngenerated by {\\tt coq\\_makefile} (see Chapter~\\ref{Addoc-coqc}). So,\njust do \\verb=make= in this latter case.\n\nThe syntax of the macros is given on figure\n\\ref{EXTEND-syntax}. They can be used at any place of an {\\ocaml}\nfiles where an ML sentence (called \\verb=str_item= in the {\\tt ocamlc}\nparser) is expected. For each rule, the left-hand-side describes the\ngrammar production and the right-hand-side its interpretation which\nmust be an {\\ocaml} expression. Each grammar production starts with\nthe concrete name of the tactic or command in {\\Coq} and is followed\nby arguments, possibly separated by terminal symbols or words.\nHere is an example:\n\n\\begin{verbatim}\nTACTIC EXTEND Replace\n  [ \"replace\" constr(c1) \"with\" constr(c2) ] -> [ replace c1 c2 ]\nEND\n\\end{verbatim}\n\n\\newcommand{\\grule}{\\textrm{\\textsl{rule}}}\n\\newcommand{\\stritem}{\\textrm{\\textsl{ocaml\\_str\\_item}}}\n\\newcommand{\\camlexpr}{\\textrm{\\textsl{ocaml\\_expr}}}\n\\newcommand{\\arginfo}{\\textrm{\\textsl{argument\\_infos}}}\n\\newcommand{\\lident}{\\textrm{\\textsl{lower\\_ident}}}\n\\newcommand{\\argument}{\\textrm{\\textsl{argument}}}\n\\newcommand{\\entry}{\\textrm{\\textsl{entry}}}\n\\newcommand{\\argtype}{\\textrm{\\textsl{argtype}}}\n\n\\begin{figure}\n\\begin{tabular}{|lcll|}\n\\hline\n{\\stritem}\n & ::= & \n\\multicolumn{2}{l|}{{\\tt TACTIC EXTEND} {\\ident} \\nelist{\\grule}{$|$} {\\tt END}}\\\\\n & $|$ & \\multicolumn{2}{l|}{{\\tt VERNAC COMMAND EXTEND} {\\ident} \\nelist{\\grule}{$|$} {\\tt END}}\\\\\n&&\\multicolumn{2}{l|}{}\\\\\n{\\grule} & ::= & \n\\multicolumn{2}{l|}{{\\tt [} {\\str} \\sequence{\\argument}{} {\\tt ] -> [} {\\camlexpr} {\\tt ]}}\\\\\n&&\\multicolumn{2}{l|}{}\\\\\n{\\argument} & ::= & {\\str} &\\mbox{(terminal)}\\\\\n & $|$ & {\\entry} {\\tt (} {\\lident} {\\tt )} &\\mbox{(non-terminal)}\\\\\n&&\\multicolumn{2}{l|}{}\\\\\n{\\entry} \n & ::= & {\\tt string} & (a string)\\\\\n & $|$ & {\\tt preident} & (an identifier typed as a {\\tt string})\\\\\n & $|$ & {\\tt ident} & (an identifier of type {\\tt identifier})\\\\\n & $|$ & {\\tt global} & (a qualified identifier)\\\\\n & $|$ & {\\tt constr} & (a {\\Coq} term)\\\\\n & $|$ & {\\tt openconstr} & (a {\\Coq} term with holes)\\\\\n & $|$ & {\\tt sort} & (a {\\Coq} sort)\\\\\n & $|$ & {\\tt tactic} & (an ${\\cal L}_{tac}$ expression)\\\\\n & $|$ & {\\tt constr\\_with\\_bindings} & (a {\\Coq} term with a list of bindings\\footnote{as for the tactics {\\tt apply} and {\\tt elim}})\\\\\n & $|$ & {\\tt int\\_or\\_var} & (an integer or an identifier denoting an integer)\\\\\n & $|$ & {\\tt quantified\\_hypothesis} & (a quantified hypothesis\\footnote{as for the tactics {\\tt intros until}})\\\\\n & $|$ & {\\tt {\\entry}\\_opt} & (an optional {\\entry} )\\\\\n & $|$ & {\\tt ne\\_{\\entry}\\_list} & (a non empty list of {\\entry})\\\\\n & $|$ & {\\tt {\\entry}\\_list} & (a list of {\\entry})\\\\\n & $|$ & {\\tt bool} & (a boolean: no grammar rule, just for typing)\\\\\n & $|$ & {\\lident} & (a user-defined entry)\\\\\n\\hline\n\\end{tabular}\n\\caption{Syntax of the macros binding {\\ocaml} tactics or commands to a {\\Coq} syntax}\n\\label{EXTEND-syntax}\n\\end{figure}\n\nThere is a set of predefined non-terminal entries which are\nautomatically translated into an {\\ocaml} object of a given type. The\ntype is not the same for tactics and for vernacular commands. It is\ngiven in the following table:\n\n\\begin{small}\n\\noindent \\begin{tabular}{|l|l|l|}\n\\hline\n{\\entry} & {\\it type for tactics} & {\\it type for commands} \\\\\n{\\tt string} & {\\tt string} & {\\tt string}\\\\\n{\\tt preident} & {\\tt string} & {\\tt string}\\\\\n{\\tt ident} & {\\tt identifier} & {\\tt identifier}\\\\\n{\\tt global} & {\\tt global\\_reference} & {\\tt qualid}\\\\\n{\\tt constr} & {\\tt constr} & {\\tt constr\\_expr}\\\\\n{\\tt openconstr} & {\\tt open\\_constr} & {\\tt constr\\_expr}\\\\\n{\\tt sort} & {\\tt sorts} & {\\tt rawsort}\\\\\n{\\tt tactic} & {\\tt glob\\_tactic\\_expr * tactic} & {\\tt raw\\_tactic\\_expr}\\\\\n{\\tt constr\\_with\\_bindings} & {\\tt constr with\\_bindings} & {\\tt constr\\_expr with\\_bindings}\\\\\\\\\n{\\tt int\\_or\\_var} & {\\tt int or\\_var} & {\\tt int or\\_var}\\\\\n{\\tt quantified\\_hypothesis} & {\\tt quantified\\_hypothesis} & {\\tt quantified\\_hypothesis}\\\\\n{\\tt {\\entry}\\_opt} & {\\it the type of entry} {\\tt option} & {\\it the type of entry} {\\tt option}\\\\\n{\\tt ne\\_{\\entry}\\_list} & {\\it the type of entry} {\\tt list} & {\\it the type of entry} {\\tt list}\\\\\n{\\tt {\\entry}\\_list} & {\\it the type of entry} {\\tt list} & {\\it the type of entry} {\\tt list}\\\\\n{\\tt bool} & {\\tt bool} & {\\tt bool}\\\\\n{\\lident} & {user-provided, cf next section} & {user-provided, cf next section}\\\\\n\\hline\n\\end{tabular}\n\\end{small}\n\n\\bigskip\n\nNotice that {\\entry} consists in a single identifier and that the {\\tt\n\\_opt}, {\\tt \\_list}, ... modifiers are part of the identifier.\nHere is now another example of a tactic which takes either a non empty\nlist of identifiers and executes the {\\ocaml} function {\\tt subst} or\ntakes no arguments and executes the{\\ocaml} function {\\tt subst\\_all}.\n\n\\begin{verbatim}\nTACTIC EXTEND Subst\n| [ \"subst\" ne_ident_list(l) ] -> [ subst l ]\n| [ \"subst\" ] -> [ subst_all ]\nEND\n\\end{verbatim}\n\n\\subsection{Adding grammar entries for tactic or command arguments}\n\nIn case parsing the arguments of the tactic or the vernacular command\ninvolves grammar entries other than the predefined entries listed\nabove, you have to declare a new entry using the macros\n\\verb=ARGUMENT EXTEND= or \\verb=VERNAC ARGUMENT EXTEND=. The syntax is\ngiven on Figure~\\ref{ARGUMENT-EXTEND-syntax}. Notice that arguments\ndeclared by \\verb=ARGUMENT EXTEND= can be used for arguments of both\ntactics and vernacular commands while arguments declared by\n\\verb=VERNAC ARGUMENT EXTEND= can only be used by vernacular commands.\n\nFor \\verb=VERNAC ARGUMENT EXTEND=, the identifier is the name of the\nentry and it must be a valid {\\ocaml} identifier (especially it must\nbe lowercase).  The grammar rules works as before except that they do\nnot have to start by a terminal symbol or word.  As an example, here\nis how the {\\Coq} {\\tt Extraction Language {\\it language}} parses its\nargument:\n\n\\begin{verbatim}\nVERNAC ARGUMENT EXTEND language\n| [ \"Ocaml\" ] -> [ Ocaml ]\n| [ \"Haskell\" ] -> [ Haskell ]\n| [ \"Scheme\" ] -> [ Scheme ]\nEND\n\\end{verbatim}\n\nFor tactic arguments, and especially for \\verb=ARGUMENT EXTEND=, the\nprocedure is more subtle because tactics are objects of the {\\Coq}\nenvironment which can be printed and interpreted. Then the syntax\nrequires extra information providing a printer and a type telling how\nthe argument behaves. Here is an example of entry parsing a pair of\noptional {\\Coq} terms.\n\n\\begin{verbatim}\nlet pp_minus_div_arg pr_constr pr_tactic (omin,odiv) = \n  if omin=None && odiv=None then mt() else\n    spc() ++ str \"with\" ++\n    pr_opt (fun c -> str \"minus := \" ++ pr_constr c) omin ++\n    pr_opt (fun c -> str \"div := \" ++ pr_constr c) odiv\n\nARGUMENT EXTEND minus_div_arg \n  TYPED AS constr_opt * constr_opt\n  PRINTED BY pp_minus_div_arg\n| [ \"with\" minusarg(m) divarg_opt(d) ] -> [ Some m, d ]\n| [ \"with\" divarg(d) minusarg_opt(m) ] -> [ m, Some d ]\n| [ ] -> [ None, None ]\nEND\n\\end{verbatim}\n\nNotice that the type {\\tt constr\\_opt * constr\\_opt} tells that the\nobject behaves as a pair of optional {\\Coq} terms, i.e. as an object\nof {\\ocaml} type {\\tt constr option * constr option} if in a\n\\verb=TACTIC EXTEND= macro and of type {\\tt constr\\_expr option *\nconstr\\_expr option} if in a \\verb=VERNAC COMMAND EXTEND= macro.\n\nAs for the printer, it must be a function expecting a printer for\nterms, a printer for tactics and returning a printer for the created\nargument. Especially, each sub-{\\term} and each sub-{\\tac} in the\nargument must be typed by the corresponding printers. Otherwise, the\n{\\ocaml} code will not be well-typed.\n\n\\Rem The entry {\\tt bool} is bound to no syntax but it can be used to\ngive the type of an argument as in the following example:\n\n\\begin{verbatim}\nlet pr_orient _prc _prt = function\n  | true -> mt ()\n  | false -> str \" <-\"\n\nARGUMENT EXTEND orient TYPED AS bool PRINTED BY pr_orient\n| [ \"->\" ] -> [ true ]\n| [ \"<-\" ] -> [ false ]\n| [ ] -> [ true ]\nEND\n\\end{verbatim}\n\n\\begin{figure}\n\\begin{tabular}{|lcl|}\n\\hline\n{\\stritem} & ::= & \n {\\tt ARGUMENT EXTEND} {\\ident} {\\arginfo} {\\nelist{\\grule}{$|$}} {\\tt END}\\\\\n& $|$ & {\\tt VERNAC ARGUMENT EXTEND} {\\ident} {\\nelist{\\grule}{$|$}} {\\tt END}\\\\\n\\\\\n{\\arginfo} & ::= & {\\tt TYPED AS} {\\argtype} \\\\\n&& {\\tt PRINTED BY} {\\lident} \\\\\n%&& \\zeroone{{\\tt INTERPRETED BY} {\\lident}}\\\\\n%&& \\zeroone{{\\tt GLOBALIZED BY} {\\lident}}\\\\\n%&& \\zeroone{{\\tt SUBSTITUTED BY} {\\lident}}\\\\\n%&& \\zeroone{{\\tt RAW\\_TYPED AS} {\\lident} {\\tt RAW\\_PRINTED BY} {\\lident}}\\\\\n%&& \\zeroone{{\\tt GLOB\\_TYPED AS} {\\lident} {\\tt GLOB\\_PRINTED BY} {\\lident}}\\\\\n\\\\\n{\\argtype} & ::= & {\\argtype} {\\tt *} {\\argtype} \\\\ \n& $|$ & {\\entry} \\\\\n\\hline\n\\end{tabular}\n\\caption{Syntax of the macros binding {\\ocaml} tactics or commands to a {\\Coq} syntax}\n\\label{ARGUMENT-EXTEND-syntax}\n\\end{figure}\n\n%\\end{document}\n", "meta": {"hexsha": "3e29886762aff35a921a43cabb42a7c319a4e9f4", "size": 82824, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tus.tex", "max_stars_repo_name": "JasonGross/test-broken-tar", "max_stars_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tus.tex", "max_issues_repo_name": "JasonGross/test-broken-tar", "max_issues_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tus.tex", "max_forks_repo_name": "JasonGross/test-broken-tar", "max_forks_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.3706293706, "max_line_length": 148, "alphanum_fraction": 0.7227011494, "num_tokens": 22559, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.42469179567794835}}
{"text": "\n\\subsubsection{Advection vs. Diffusion Sensitivity \\textsc{Cyder} Results}\nSome of the  radionuclide transport models in \\Cyder depend on the advective velocity as well as the diffusion\ncharacteristics of the medium. By evaluating the sensitivity to the advective velocity and reference\ndiffusivity of the radionuclide transport in the Mixed Cell model, trends similar to those found in the \\gls{GDSM} were found with the \\Cyder tool.\nSpecifically, increased advection and increased diffusion lead to greater release. Also, when both are varied, a boundary between diffusive and advective\nregimes can be seen. An example of these results are shown in Figure\n\\ref{fig:dr_adv_diff}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=\\linewidth]{./results/images/adv_vel_diff.eps}\n\\caption[Advection vs. Diffusion Sensitivity in \\textsc{Cyder}]{Dual advective velocity\nand reference diffusivity sensitivity for a non-sorbing, infinitely soluble\nnuclide.}\n\\label{fig:dr_adv_diff}\n\\end{figure}\n", "meta": {"hexsha": "d3b959fd3ab9197e1f1eb646dcd6adead4e244ec", "size": 994, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "results/adv_vel_diff_results.tex", "max_stars_repo_name": "katyhuff/2017-huff-rapid", "max_stars_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "results/adv_vel_diff_results.tex", "max_issues_repo_name": "katyhuff/2017-huff-rapid", "max_issues_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "results/adv_vel_diff_results.tex", "max_forks_repo_name": "katyhuff/2017-huff-rapid", "max_forks_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.2222222222, "max_line_length": 153, "alphanum_fraction": 0.8138832998, "num_tokens": 249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.538983220687684, "lm_q1q2_score": 0.42468169350790497}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{January 16 2019}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\\newtheorem{claim}{Claim}\n\n\\DeclareMathOperator{\\Int}{Int}\n\\DeclareMathOperator{\\grad}{grad}\n\\DeclareMathOperator{\\Ker}{Ker}\n\\DeclareMathOperator{\\Ima}{Im}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\mb}[1]{\\mathbf{#1}}\n\\newcommand{\\hlfspc}[0]{\\mathbb{H}}\n\\newcommand{\\loint}[0]{\\operatorname{L}\\int}\n\\newcommand{\\hiint}[0]{\\operatorname{U}\\int}\n\\newcommand{\\indic}[1]{\\chi_{#1}}\n\n\\begin{document}\n\n\\maketitle\n\nLast time, we used partitions of unity to obtain an extended definition of the integral, which we didn't quite finish proving the consistency of of. So let's recall where we were at:\n\\begin{theorem}\n  Let \\(A \\subseteq \\reals^n\\) be open, and \\(f\\) be a locally bounded function of \\(A\\) where the set of discontinuities of \\(f\\) has measure 0. Then, if \\(\\Phi\\) is a partition of unity for \\(A\\) subordinate to \\(\\{A\\}\\) (note that for this definition a \\(\\mc{C}^0\\) partition is enough, i.e. just continuous)\n  \\begin{equation}\n    \\int_Af = \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n  \\end{equation}\n  provided that\n  \\begin{equation}\n    \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi |f|\n  \\end{equation}\n  converges.\n\\end{theorem}\nWhat we showed last time is that\n\\begin{enumerate}\n\n  \\item The existence of the integral and it's value is independent of the parititon of unity chosen to compute it.\n\n  \\item The integral \\textit{always} exists if \\(A\\) and \\(f\\) are both bounded.\n\n  \\item We \\textit{want} to show that if we're in a situation where the integral exists according to our old definition, so that in particular \\(A\\) and \\(f\\) will be bounded, then our new definition agrees with the old one. That is, if moreover, \\(A\\) is Jordan measurable, then\n  \\begin{equation}\n    \\int_Af = \\sum_{\\varphi \\in \\Phi}\\int_A\\varphi f\n  \\end{equation}\n  where the left hand side is computed using the old definition\n\\end{enumerate}\n\\begin{proof}\n  For every \\(\\epsilon > 0\\), there is a compact Jordan-measurable subset \\(C \\subset A\\) such that \\begin{equation}\n    V(A \\setminus C) = \\int_{A \\setminus C}1 = \\int_A\\chi_{A \\setminus C} < \\epsilon\n  \\end{equation}\n  So how do we get this \\(C\\)? We're given that \\(A\\) is Jordan measurable, so as \\(A\\) is bounded we can cover the boundary of \\(A\\) by the interiors of finitely many closed balls \\(\\mc{B}\\) (or rectangles) of total volume \\(< \\epsilon\\). So we can take\n  \\begin{equation}\n    C = A \\setminus \\Int\\bigcup\\mc{B}\n  \\end{equation}\n  (we could also take the union of interiors). Why is \\(C\\) Jordan measurable? Since the boundary of \\(C\\) is a subset of the boundary of \\(\\Int\\bigcup\\mc{B}\\), which is has measure zero, it follows that \\(C\\) has boundary of measure zero and is hence Jordan measurable.\n\n  Since \\(C\\) is compact, only finitely many of our partition functions \\(\\varphi \\in \\Phi\\) are nonzero on \\(C\\). So we'll take a finite sum, look at the difference, and show that that difference goes to zero: consider any finite subset \\(F\\) of \\(\\Phi\\) including the ones which are nonzero on \\(C\\). Consider\n  \\begin{equation}\n    \\left|\\int_Af - \\sum_{\\varphi \\in F}\\int_A\\varphi f\\right|\n    \\label{absint}\n  \\end{equation}\n  As the absolute value of the integral is less than or equal to the integral of the absolute value, we have that equation \\ref{absint} is less than or equal to\n  \\begin{equation}\n    \\int_A\\left|f - \\sum_{\\varphi \\in F}\\varphi f\\right|\n    \\label{intabs}\n  \\end{equation}\n  Since \\(f\\) is bounded, we can choose \\(M\\) such that \\(|f| \\leq M\\). So equation \\ref{intabs} is less than or equal to\n  \\begin{equation}\n    M\\int_A\\left(1 - \\sum_{\\varphi \\in F}\\varphi\\right)\n    = M \\int_A\\sum_{\\varphi \\in \\Phi \\setminus F}\\varphi\n    \\label{intrem}\n  \\end{equation}\n  Since\n  \\begin{equation}\n    \\forall \\varphi \\in \\Phi \\setminus F, \\forall c \\in C, \\varphi(c) = 0\n  \\end{equation}\n  we have that equation \\ref{intrem} is less than or equal to\n  \\begin{equation}\n    MV(A \\setminus C) \\leq M\\epsilon\n  \\end{equation}\n\n\\end{proof}\nAs I mentioned last time, you can do this in another way which perhaps looks more like the improper integral from first year calculus, and that's integrating with bigger and bigger sets. Let me state that, but I won't prove it, and rather put it on the problem set:\n\\begin{theorem}\n  Let \\(A\\) be open, \\(f: A \\to \\reals\\) be locally bounded and let the set of discontinuties of \\(f\\) have measure zero. Write\n  \\begin{equation}\n    A = \\bigcup_{n \\in \\nats}C_n\n  \\end{equation}\n  where each \\(C_n\\) is compact and Jordan Measurble and satisfy \\(C_n \\subset \\Int C_{n + 1}\\). Part of the exercise is to show that we can do this. Then \\(f\\) is integrable on \\(A\\) if and only if\n  \\begin{equation}\n    \\left\\{\\int_{C_i}|f| : n \\in \\nats\\right\\}\n  \\end{equation}\n  is bounded. Note that if this is the case, the sequence\n  \\begin{equation}\n    \\left\\{\\int_{C_i}f : n \\in \\nats\\right\\}\n  \\end{equation}\n  converges absolutely, and we can write\n  \\begin{equation}\n    \\int_Af = \\lim_{n \\to \\infty}\\int_{C_n}f\n  \\end{equation}\n\\end{theorem}\n\\begin{proof}\n  Exercise.\n\\end{proof}\nIt's good to appreciate that the improper integral which we defined using a partition of unity can be expressed in this way. It's also really good to do the above exercise as an exercise in using partitions of unity.\n\nThere's a little gap in the treatment of partitions of unity last time which I want to fill here. In the first case, where \\(A\\) was compact, we defined\n\\begin{equation}\n  \\psi_1,...,\\psi_p\n\\end{equation}\nsuch that \\(\\psi_1 + ... \\psi_p > 0\\) on an open set \\(U \\supseteq A\\). We then let\n\\begin{equation}\n  \\varphi_i = \\frac{\\psi_i}{\\psi_1 + ... \\psi_p}\n\\end{equation}\nThis is all well and good, but individual \\(\\varphi_i\\) might be defined on sets that go outside \\(U\\), and we have to worry about dividing by zero to guarantee that each bump function is \\(\\mc{C}^\\infty\\) everywhere. To deal with this, we can simply multiply everything by another bump function (we can find one which is 1 on \\(A\\) and zero outside a compact set \\(U\\)).\n\nLet \\(f(x)\\) be a \\(\\mc{C}^\\infty\\) bump function such that \\(f = 1\\) on \\(A\\), \\(f = 0\\) outside a compact subset of \\(U\\). Then the set of functions\n\\begin{equation}\n  \\{f \\cdot \\varphi_i : i \\in 1,...,p\\}\n\\end{equation}\nis a partition of unity as required.\n\nBefore we finish, I want to say something about integration by substitution, or change of variables.\n\n\\section{Change of Variables}\n\nRecall the single-variable \\underline{integration by substitution} formula\n\\begin{equation}\n  \\int_{g(a)}^{g(b)} f = \\int_a^b(f \\circ g)g'\n  \\label{onesubform}\n\\end{equation}\nThis holds whenever ``both sides make sense'', e.g. if \\(f\\) is continuous and \\(g\\) is continuously differentiable. The hypotheses, however, could be weaker. When we talk about integration by substitution, our \\(g\\) is going to be the change of variables. But change of variables means like ``invertible''. So not just any \\(g\\), but in particular 1-to-1. I wanted to point out how, in terms of our formula, we should think about this in the case where \\(g\\) is one-to-one. So suppose it is so. Then equation \\ref{onesubform} can be rewritten as\n\\begin{equation}\n  \\int_{g([a, b])}f = \\int_{[a, b]}(f \\circ g)|g'|\n\\end{equation}\nsince otherwise the equaton would not be correct if \\(g\\) was decreasing. So this is what our change-of-variables formula is going to look like. We'll look at that next time.\n\\end{document}\n", "meta": {"hexsha": "82e94d1e55345aa0346c153d744d2d4b1b540051", "size": 8206, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/jan16.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/jan16.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/jan16.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.4337349398, "max_line_length": 546, "alphanum_fraction": 0.7036314892, "num_tokens": 2558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4246220459636986}}
{"text": "\\documentclass[12pt]{amsbook}\n%\\usepackage[utf8]{inputenc}\n\n\\usepackage{tikz}\n\\newcommand*\\circled[1]{\\tikz[baseline=(char.base)]{\n            \\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}\n\\usepackage{color}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\usepackage[pdfpagelabels,hyperindex=false]{hyperref}\n\n\n%%%%\\usepackage{amsmidx}\n\\usepackage{appendix}\n\\usepackage{booktabs}\n\\usepackage[normalem]{ulem}\n%%%%\\makeindex{LABdriver6}\n\\usepackage[lastexercise]{exercise}\n\n\\newcommand{\\xxj}{x^{(j)}}  \n\n\\newcommand{\\xxi}{x^{(i)}}  \n\\newcommand{\\bp}{\\mathbb{P}}  \n\\newcommand{\\br}{\\mathbb{R}} \n \\newcommand{\\brm}{\\mathbb{R}^m} \n \\newcommand{\\brn}{\\mathbb{R}^n} \n \\newcommand{\\bbrm}{$\\mathbb{R}^m\\,$} \n \\newcommand{\\bbrn}{$\\mathbb{R}^n\\,$} \n\n\\newcommand{\\calr}{\\mathcal{R}}  \n\\newcommand{\\caln}{\\mathcal{N}}  \n\n\n\\numberwithin{equation}{section}\n% We'll use the equation counter for all our theorem environments, so\n% that everything will be numbered in the same sequence.\n%       Theorem environments\n\\theoremstyle{plain} %% This is the default, anyway\n\\newtheorem{thm}[equation]{Theorem}\n\\newtheorem{cor}[equation]{Corollary}\n\\newtheorem{lem}[equation]{Lemma}\n\\newtheorem{prop}[equation]{Proposition}\n\\theoremstyle{definition}\n\\newtheorem{defn}[equation]{Definition}\n\\newtheorem{Property}[equation]{Property}\n\\theoremstyle{remark}\n\\newtheorem{rem}[equation]{Remark}\n\\newtheorem{ex}[equation]{Example}\n\\newtheorem{notation}[equation]{Notation}\n\\newtheorem{terminology}[equation]{Terminology}\n\n%\\includeonly{LinearSystems,Exercises}\n%\\includeonly{Exercises}\n\n%\\includeonly{Eigenvectors,Exercises}\n%\\includeonly{Eigenvectors}\n%\\includeonly{PS8}\n\n%\\includeonly{GeometrySubspacestex}\n\n\n%\\usepackage{makeidx}\n%\\usepackage{robustindex}\n\n\\makeindex\n \n\n\\begin{document}\n\n\\section*{Exercises for Chapter 1}\n\n\\begin{Exercise}\n%\\begin{Exercise}[title={Computing an inverse}, difficulty = 0, label = rank1sum]\nLet $A, B, C$ be given by\n\\begin{align*}\nA =  \\left[ \n\\begin{array}{ccc} \n1& 1&  3\\\\ \\noalign{\\medskip}   \n0& 1&  3\\\\ \\noalign{\\medskip}         \n1& 2   & 2 \n\\end{array}\n \\right],\\,\\,\\, B =  \\left[ \n\\begin{array}{rrr} \n2& 0&  -1\\\\ \\noalign{\\medskip}   \n0& 1&  3\\\\ \\noalign{\\medskip}         \n0& 1   & -2 \n\\end{array}\n \\right],\\,\\,\\,\n C=  \\left[ \n\\begin{array}{rr} \n0& 1\\\\ \\noalign{\\medskip}   \n1& 1\\\\ \\noalign{\\medskip}         \n-1& -1   \n\\end{array}\n \\right] ,\\,\\,\\,\n D=  \\left[ \n\\begin{array}{rrr} \n0& 1 & 3\\\\ \\noalign{\\medskip}          \n-1& -1   &-1\n\\end{array}\n \\right] \n\\end{align*}\n%\\end{Exercise}\nFor each problem find $X$ if possble.  If X doesn't exist say why.\n\\begin{itemize}\n\\item[a)]$X =  2A+3B$\n\\item[b)]$ X =7A + 2C$\n\\item[c)]$X =  BC$\n\\item[d)] $X = CB$\n\\item[e)]$ X = (A+2B)C$\n\\item[f)] Without actually computing the product, what is the size of the matrix $X = DC$\n\\end{itemize}\n\n\\end{Exercise}\n\n\n\\begin{Exercise}\nShow that in general $AB \\ne BA $ where  $A$ and $B$ are square.  It is sufficient to provide a single counter example for $A, B \\in \\mathbb{R}^{2 \\times 2}$.\n\\end{Exercise}\n\n\n\n\\begin{Exercise}\n%\n%\\begin{Exercise}[title={Computing an inverse}, difficulty = 0, label = rank1sum]\nLet $A, b, x$ be given by\n\\begin{align*}\nA =  \\left[ \n\\begin{array}{rr} \n1& 1\\\\ \\noalign{\\medskip}            \n1& 2   \n\\end{array}\n \\right],\\,\\,\\, b =  \\left[ \n\\begin{array}{r} \n0\\\\ \\noalign{\\medskip}   \n1 \n\\end{array}\n \\right],\\,\\,\\,\n x=  \\left[ \n\\begin{array}{r} \nx_1\\\\ \\noalign{\\medskip}   \nx_2\n\\end{array}\n \\right] \n\\end{align*}\n%\\end{Exercise}\nWrite $$Ax=b$$ \nas a system of linear equations without matrix notation.\n\\end{Exercise}\n\n\\begin{Exercise}\n%\\begin{Exercise}[title={Computing an inverse}, difficulty = 0, label = rank1sum]\nLet $A, b, x$ be given by\n\\begin{align*}\nA =  \\left[ \n\\begin{array}{rrrr} \n1& 1& 0& 3\\\\ \\noalign{\\medskip}   \n0& 1&  0&3\\\\ \\noalign{\\medskip}         \n1& 2   &-1& 2 \n\\end{array}\n \\right],\\,\\,\\, b =  \\left[ \n\\begin{array}{r} \n2\\\\ \\noalign{\\medskip}   \n-1\\\\ \\noalign{\\medskip}         \n1 \n\\end{array}\n \\right],\\,\\,\\,\n x=  \\left[ \n\\begin{array}{r} \nx_1\\\\ \\noalign{\\medskip}   \nx_2\\\\ \\noalign{\\medskip} \nx_3\\\\ \\noalign{\\medskip}                 \nx_4   \n\\end{array}\n \\right] \n\\end{align*}\n%\\end{Exercise}\nWrite $$Ax=b$$ \nas a system of linear equations without matrix notation.\n\\end{Exercise}\n\n\n\\begin{Exercise}\nWrite the linear system\n$$2x_1+x_2 = 7$$\n$$3x_1-x_2 = 2$$\nin the form $$Ax=b$$\nWhat  are $A, b, x$?\n\\end{Exercise}\n\n\\begin{Exercise}\nWrite the linear system\n$$5x_1-4x_2 = 1$$\n$$3x_1+5x_2 = 2$$\n$$6x_1-4x_2 = 8$$\n$$7x_1+6x_2 = 2$$\n$$2x_1-4x_2 = 9$$\n$$8x_1+9x_2 = 2$$\nin the form $$Ax=b$$\nWhat are $A, b, x$?\n\\end{Exercise}\n\n\\begin{Exercise}\nLet $A, B, C \\in \\mathbb{R}^{m \\times n}$.\nProvide a mathmatical proof of the associative law of addition for matrices, i.e., \n$$(A+B)+C = A+(B+C)$$  \nHint: you may use the fact that $(a+b)+c = a +(b+c) $ where $a, b, c$ are real\nnumbers.  Identify the $(i,j)$ component of the resulting matrix on each side of the equation\nand show they are equal.\n\\end{Exercise}\n\n\\begin{Exercise}\nThe transpose of a matrix $A \\in \\mathbb{R}^{m\\times n}$ (possibly not square) is the new matrix\n$$X_{ij} = A_{ji}$$   The standard notation for this is $$X  = A^T$$  Given the matrices as defined in\nProblem 1 find\n\\begin{itemize}\n\\item[a)] $A^T$\n\\item[b)] $B^T$\n\\item[c)] $C^T$\n\\item[d)] $D^T$\n\\end{itemize}\n\\end{Exercise}\n\\begin{Exercise}\nThe matrix $A$ is said to be symmetric if $A = A^T$.\n\\begin{itemize}\n\\item[a)] Construct an example of a symmetric matrix.\n\\item[b)] Can a matrix be symmetric if it is not square?\n\\item[c)] What is the plural of the word matrix?\n\\end{itemize}\n\\end{Exercise}\n\n\\begin{Exercise}\n\\begin{itemize}\n\\item[a)] Find the $(i,j)$ entry of the matrix\n$AB$.\n\\item[b)] Find the $(i,j)$ entry of the matrix $(AB)^T$.\n\\item[c)] Find the $(i,j)$ entry of the matrix product $B^TA^T$.\n\\item[d)] Hence justify the equation\n$(AB)^T = B^TA^T$\n\\item[e)] Is the matrix $XX^T$ symmetric?\n\\end{itemize}\n\\end{Exercise}\n\n\n\\bigskip\n\n\\begin{Exercise}[title={Scalar product}, difficulty = 0, label = exmm]\n\tCompute the scalar (or dot) product of the vectors\n\t$$u =  \\left[ \\begin {array}{c} \n\t9 \\\\ \\noalign{\\medskip}       \n\t2 \\\\ \\noalign{\\medskip}        \n\t-1\\end {array}\n\t\\right], \\quad v=\n\t\\left[ \\begin {array}{cccc} \n\t0  \\\\ \\noalign{\\medskip}       \n\t2  \\\\ \\noalign{\\medskip}        \n\t1 \\end {array}\n\t\\right] \n\t$$\n\\end{Exercise}\n\n\\bigskip\n\n\\begin{Exercise}[title={2-norm of a vector}, difficulty = 0, label = exmm]\n\\Question \tLet \n\t$$ x =  \\left[ \\begin {array}{c} \n\t3 \\\\ \\noalign{\\medskip}       \n\t4 \\\\ \\noalign{\\medskip}    \n\t    \t-7 \\\\ \\noalign{\\medskip}        \n\t8\\end {array}\n\t\\right] \n\t$$\n\tFind the 2-norm $\\| x \\|_2$.\n\t\\Question \tLet \n\t$$ x =  \\left[ \\begin {array}{c} \n\t1 \\\\ \\noalign{\\medskip}       \n\t1 \\\\ \\noalign{\\medskip}           \n\t1\\end {array}\n\t\\right] \n\t$$\n\tFind the 2-norm $\\| x \\|_2$.\n\n\t\\Question \tLet \n\t$$ x =  \\left[ \\begin {array}{c} \n\t1/ \\sqrt{3} \\\\ \\noalign{\\medskip}       \n\t1/ \\sqrt{3}\\\\ \\noalign{\\medskip}           \n1/ \\sqrt{3}\\end {array}\n\t\\right] \n\t$$\n\tFind the 2-norm $\\| x \\|_2$.\n\n\t\n\\end{Exercise}\n\n\n\\bigskip\n\n\\begin{Exercise}[title={Angle between vectors}, difficulty = 0, label = exmm]\n\\Question\tCompute the angle between the vectors\n\t$$u =  \\left[ \\begin {array}{c} \n\t1 \\\\ \\noalign{\\medskip}       \n\t2 \\\\ \\noalign{\\medskip} \n\t8 \\\\ \\noalign{\\medskip}        \n\t-1\\end {array}\n\t\\right], \\quad v=\n\t\\left[ \\begin {array}{cccc} \n\t-1  \\\\ \\noalign{\\medskip} \n    2 \\\\ \\noalign{\\medskip}              \n\t-1  \\\\ \\noalign{\\medskip}        \n\t3 \\end {array}\n\t\\right] \n\t$$\n\tproviding your answer in both radians and degrees.\n\\Question\nCompute the angle between the vectors\n$$u =  \\left[ \\begin {array}{c} \n1 \\\\ \\noalign{\\medskip}       \n2 \\\\ \\noalign{\\medskip}       \n0\\end {array}\n\\right], \\quad v=\n\\left[ \\begin {array}{cccc} \n0 \\\\ \\noalign{\\medskip}             \n0  \\\\ \\noalign{\\medskip}        \n3 \\end {array}\n\\right] \n$$\nproviding your answer in both radians and degrees.\n\n\\Question\nCompute the angle between the vectors\n$$u =  \\left[ \\begin {array}{c} \n1 \\\\ \\noalign{\\medskip}       \n2 \\\\ \\noalign{\\medskip}       \n0\\end {array}\n\\right], \\quad v=\n\\left[ \\begin {array}{cccc} \n-6 \\\\ \\noalign{\\medskip}             \n-12  \\\\ \\noalign{\\medskip}        \n0 \\end {array}\n\\right] \n$$\nproviding your answer in both radians and degrees.\n\n\n\\end{Exercise}\n\n\n\n\\bigskip\n\n\\begin{Exercise}[title={A simple sum}, difficulty = 0, label = exmm]\nLet\n$$A =  \\left[ \\begin {array}{cccc} \n9  & 8  & 6 & 7 \\\\ \\noalign{\\medskip}       \n2  & 2  & 7 & 8 \\\\ \\noalign{\\medskip}        \n-1  & 3  & 1 & 1\\end {array}\n \\right] \n+\n \\left[ \\begin {array}{cccc} \n0  & 1  & 6 & 7 \\\\ \\noalign{\\medskip}       \n2  & 2  & 2 & 8 \\\\ \\noalign{\\medskip}        \n1  & -3  & 0 & 1\\end {array}\n \\right] \n$$\nFind $A$.\n\\end{Exercise}\n\n\n\n\\begin{Exercise}[title={More addition}, difficulty = 0, label = exmm]\n\\Question \nLet\n$$a =  \\left[ \\begin {array}{c} \n1   \\\\ \\noalign{\\medskip}       \n2   \\\\ \\noalign{\\medskip}    \n-2  \\\\ \\noalign{\\medskip}        \n1   \\end {array}\n \\right] $$\nand $$\nb =  \\left[ \\begin {array}{c} \n0   \\\\ \\noalign{\\medskip} \n0    \\\\ \\noalign{\\medskip}        \n5   \\\\ \\noalign{\\medskip}        \n-1   \\end {array}\n \\right] \n$$\nFind $a+b$.\n\n\\Question Let\n$$u =  \\left[ \\begin {array}{ccccc} \ne  & 2  & -4 & 0 & -1  -1   \\end {array}     \n \\right] $$\nand $$\nv =  \\left[ \\begin {array}{ccccc} \n\\pi  & 1  &1  &0 &0-1   \\end {array}\n \\right] \n$$\nFind $u+v$.\n\n\n\\Question Let\n$$A =  \\left[ \\begin {array}{ccc} \n\\sqrt{2}  & 8  & 6  \\\\ \\noalign{\\medskip}       \n2  & 1  & 7  \\\\ \\noalign{\\medskip}    \n-12  & 1  & 1 \\\\ \\noalign{\\medskip}        \n1  & 0  & -1 \\end {array}\n \\right] $$\nand $$\nB =  \\left[ \\begin {array}{cccc} \n0  & 1  & 2  \\\\ \\noalign{\\medskip} \n2  & -1  & 4  \\\\ \\noalign{\\medskip}        \n-2  & 2  & 2  \\\\ \\noalign{\\medskip}        \n1  & -1  & 1 \\end {array}\n \\right] \n$$\nFind $A+B$.\n\\end{Exercise}\n\n\n\\bigskip\n\n\\begin{Exercise}[title={A simple product}, difficulty = 0, label = exmm]\n\\Question\tLet\n\t$$M =  \\left[ \\begin {array}{ccc} \n\t2  & 1  & 3 \\\\ \\noalign{\\medskip}            \n\t1  & -1  & 4 \\end {array}\n\t\\right], \\quad N=\n\t\\left[ \\begin {array}{cc} \n\t2  & 2 \\\\ \\noalign{\\medskip}             \n\t1  & -1\\end {array}\n\t\\right] \n\t$$\n\\Question\tFind the product $NM$.  Which of the products $MN$, $MM$ and $NN$ make sense?\n\\end{Exercise}\n\n\n\n\\begin{Exercise}[title={Matrix Multiplication}, difficulty = 0, label = exmm]\n\tLet\n\t$$A = \\left( \\begin{array}{rrrr}\n\t1 & -2 & 1 & 1\\\\\n\t2 & 2 & -3 &0\\\\\n\t1 & 2 & 1 &-1\\end{array} \\right)$$\n\t$$B = \\left( \\begin{array}{rrr}\n\t9 & 8 & 6 \\\\\n\t2 & 2 & 7\\\\\n\t1 & 3 & 1 \\\\\n\t-1 &2 &0\\end{array} \\right)$$\n\tCompute the product $AB$.\n\\end{Exercise}\n\\bigskip\n\n\n\\begin{Exercise}[title={Matrix Multiplication}, difficulty = 0, label = exmm]\n\tLet\n\t$$A = \\left( \\begin{array}{rrrr}\n\t-1 & 2 & 0 & -1\\\\\n\t3 & -4 & 2 &1\\end{array} \\right)$$\n\t$$B = \\left( \\begin{array}{rrr}\n\t-4 & 1 \\\\\n\t1 & 2\\\\\n\t1 & 1 \\\\\n\t1 &-7\\end{array} \\right)$$\n\tCompute the product $AB$.\n\\end{Exercise}\n\\bigskip\n\n\n\\bigskip\n\n\\begin{Exercise}[title={$AB \\ne BA$}, difficulty = 0, label = exmm]\nLet\n$$A = \\left( \\begin{array}{rr}\n1 & 0\\\\\n2 & 2 \\end{array} \\right)$$\n$$B = \\left( \\begin{array}{rr}\n2 & 1\\\\\n1 & 1 \\end{array} \\right)$$\n\\Question Find $AB$.\n\\Question Find $BA$.\n\\end{Exercise}\n\\bigskip\n\n\\bigskip\n\n\\begin{Exercise}[title={$AB \\ne BA$}, difficulty = 0, label = exmm]\nLet\n$$A = \\left( \\begin{array}{rr}\n-1 & 2\\\\\n0 & 1 \\end{array} \\right)$$\n$$B = \\left( \\begin{array}{rr}\n9 & -6\\\\\n4 & -2 \\end{array} \\right)$$\n\\Question Find $AB$.\n\\Question Find $BA$.\n\\end{Exercise}\n\\bigskip\n\n\n\n\n\\index{vector!position}\n\\begin{Exercise}[title={Position vectors}, difficulty = 0, label = exmm]\nThe representation of an $n$-tuple $x$ as a position vector involves drawing a line with\narrow fron the origin ${\\mathbf{0}}$ to $x$.\nLet\n$$x = \\left( \\begin{array}{r}\n1 \\\\\n2 \\end{array} \\right), \\quad\ny = \\left( \\begin{array}{r}\n-1 \\\\\n3 \\end{array} \\right)\n$$\n\\Question Draw the position vectors associated with the points $x$ and $y$.\n\\Question Compute $w = 3x-2y$ and plot this position vector.\n\\end{Exercise}\n\\bigskip\n\n\n\\index{vector!position}\n\\begin{Exercise}[title={Position vectors}, difficulty = 0, label = exmm]\nConsider the vector starting at the point $(3,2)$ and ending at $(-2,1)$.\n\\Question Express this vector in terms of two position vectors, i.e., \nvectors that have the origin as an end point.\n\\Question Draw the three vectors.\n\\end{Exercise}\n\n\\bigskip\n\\begin{Exercise}[title={Transpose again}, difficulty = 0, label = 3T]\n\tShow that\n\t$$(ABC)^T = C^TB^TA^T$$\n\tWhat restrictions are there on the sizes of the matrices $A, B, C$?\n\t\n\t%Solution: \n\t%$$A^T(A^{-1})^T = (A^{-1}A)^T = I$$\n\t%$$(A^{-1})^TA^T = (AA^{-1})^T = I$$\n\t\n\\end{Exercise}\n\n\\end{document}", "meta": {"hexsha": "ad86f4add764df8cce1a8c94938679079f5018e3", "size": 12723, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MATLAB/PS1questions (1).tex", "max_stars_repo_name": "henriquem27/School-Projects", "max_stars_repo_head_hexsha": "dbad7f48db1cc4fe5a4f42c4cac03ec9464afe23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MATLAB/PS1questions (1).tex", "max_issues_repo_name": "henriquem27/School-Projects", "max_issues_repo_head_hexsha": "dbad7f48db1cc4fe5a4f42c4cac03ec9464afe23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MATLAB/PS1questions (1).tex", "max_forks_repo_name": "henriquem27/School-Projects", "max_forks_repo_head_hexsha": "dbad7f48db1cc4fe5a4f42c4cac03ec9464afe23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3449541284, "max_line_length": 158, "alphanum_fraction": 0.6051245775, "num_tokens": 4809, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736783928749127, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.4246220450377995}}
{"text": "\\chapter{\\proj Geometric Registration}\n\\label{ch_register}\n\\index{registration}\n% \\chapterhead{Programs}\n\\markright{Geometric registration}\n\n\\section{Introduction}\nImage registration is a procedure which determines \nthe best spatial fit between two or more images that overlap the same \nscene, and were acquired at the same or at a different time, by identical or \ndifferent sensors. \nThus, registration is required for  processing a new set of data \nin such a way that its \nimage under an appropriate transform is in a proper geometrical \nrelationship with the previous set of data. \n\\bigskip\n\nSeveral digital techniques have been used for automatic registration of \nimages such as cross-correlation, normal cross-correlation and minimum \ndistance criteria.  \nThe advantage of the wavelet transform is that it produces both \nspatial and frequency domain information which allow the study of \nthe image by frequency bands \\cite{reg:djamdji1,reg:djamdji2,reg:djamdji3}. \\\\\n \nAn automatic image registration procedure can be helpful for several\napplications:\n\\begin{enumerate}\n\\item Comparison between two images obtained at the same wavelength.\n\\item Comparison between two images obtained at different wavelengths.\n\\item Pixel field of view distortion estimation.\n\\end{enumerate}\n \\bigskip\n \nThe geometrical correction is usually performed by three operations:\n\\begin{itemize}\n\\item The measure of a set of well-defined ground control points (GCPs), which are \n      features well located both in the input image and in the reference image.\n\\item The determination of the warping or deformation model, by specifying a \n      mathematical deformation model defining the relation between the \n      coordinates $(x,y)$ and $(X,Y)$ in the reference and input image respectively.\n\\item The construction of the corrected image by output-to-input mapping.\n\\end{itemize}\n\n\\bigskip\nThe main difficulty lies in the automated localization of the corresponding \nGCPs, since the accuracy of their determination will affect the overall \nquality of the registration.  In fact, there are always ambiguities in \nmatching two sets of points, as a given point corresponds to a small region \n{\\em D}, which takes into account the prior geometric uncertainty between \nthe two images and many objects could be contained in this region.\n\\bigskip\n\n One property of the wavelet transform is to have a sampling step proportional \nto the scale.  When we compare the images in the wavelet transform space, \nwe can choose a scale corresponding to the size of the region {\\em D}, so \nthat no more than one object can be detected in this area, and the matching \nis done automatically.\n\n\\section{Deformation model}%Polynomial Transformation\nGeometric correction requires a spatial transformation to invert an unknown \ndistortion function.  A general model for characterizing misregistration \nbetween two sets of remotely sensed data is a pair of bivariate polynomials \nof the form:\n\\begin{eqnarray*}\nx_i = \\displaystyle{ \\sum^{N}_{p=0} \\sum^{N-p}_{q=0} a_{pq} \nX^{p}_{i} Y^{q}_{i} = Q(X_{i}, Y_{j}) } \\\\\ny_i = \\displaystyle{ \\sum^{N}_{p=0} \\sum^{N-p}_{q=0} b_{pq} \nX^{p}_{i} Y^{q}_{i} = R(X_{i}, Y_{j}) }\n\\end{eqnarray*}\nwhere $(X_{i},Y_{i})$ are the coordinates of the $i^{th}$ GCP in the \nreference image, $(x_{i},y_{i})$ the corresponding GCP in the input \nimage and $N$ is the degree of the polynomial.\n\nUsually, for images taken \nunder the same {\\em imaging direction}, polynomials of degree one or two \nare sufficient as they can model most of the usual deformations like shift, \nscale, skew, perspective and rotation (see Table 3.1). \n\nWe then compute the unknown parameters \n($(N+1)(N+2)/2$ for each polynomial) using the least mean square \nestimator. \\\\ \n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{l|c} \\hline \nShift       & $x  =  a_0 + X$                        \\\\ \n            & $y  =  b_0 + Y$                        \\\\ \\hline\nScale       & $x  =  a_1 X$                          \\\\ \n            & $y  =  b_2 Y$                          \\\\ \\hline\nSkew        & $x  =  X + a_2 Y$                      \\\\\n            & $y  =  Y$                              \\\\ \\hline\nPerspective & $x  =  a_3 X Y$                        \\\\\n            & $y  =  Y$                              \\\\ \\hline\nRotation    & $x  =   \\cos \\theta X + \\sin \\theta Y$ \\\\\n     \t    & $x  =  -\\sin \\theta X + \\cos \\theta Y$ \\\\ \\hline \n\\end{tabular}\n\\caption{Some common deformations.}\n\\end{center}\n\\label{table:deformations}\n\\end{table}\n\n\n\\section{Image registration: mr\\_fusion}\n\\index{mr\\_fusion}\nProgram {\\em mr\\_fusion} performs the geometrical registration \nof two images having the same size, and same resolution. Four deformation\nmodels are available (``-d\" option). The program may fail to register the image\nwhen not enough control points are detected. In this case, the user can try\nanother deformation model which may be more adapted to his data, or modify\nthe noise model parameters. Here the noise model is only used for structure\ndetection. If the image contains strong features, the threshold parameter \n``-s\"\ncan be set at a greater value. Hence, the registration will be performed only\nfrom the strongest feature of the image. The number of scales is also very\nimportant. Indeed, the maximum distance between two pixels of the same point\nin the two images  must be less than or equal to the size of the wavelet at the\nlast scale. The number of scales can be fixed either using \ndirectly the ``-n\" option,\nor using the ``-D\" option. \nBy choosing the latter, the user gives the maximum distance\nbetween two pixels of the same point, and the program calculates automatically\nthe correct number of scales. \n\n{\\bf\n\\begin{center}\n USAGE: mr\\_fusion option image\\_ref image\\_in image\\_out\n\\end{center}}\nOptions are:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item {\\bf [-p]} \\\\\nPoisson Noise. Default is no Poisson component (just Gaussian).\n\\item {\\bf [-g SigmaNoise]} \\\\\nSigmaNoise = Gaussian noise standard deviation. Default is automatically estimated.\n\\item {\\bf [-c gain,sigma,mean]} \\\\\nSee section~\\ref{sect_support}.\n\\item {\\bf [-n number\\_of\\_scales]} \\\\\nNumber of scales used in the multiresolution transform. Default is 4.\n\\item {\\bf [-s NSigma]} \\\\\nThresholding at NSigma * SigmaNoise. Default is 5.\n\\item{\\bf [-r res\\_min]} \\\\\nMinimum resolution for the reconstruction. \nThe registration procedure is stopped at scale res\\_min and \nthe resulting deformation model is used to register the input image. \nDefault value is 1.\n\\item{\\bf [-D dist\\_max]} \\\\\nMaximum estimated distance between two identical points in both images. \nThis value is used to estimate the number of scales for the wavelet transform.\n% \\item{\\bf [-l]} \\\\\n%  Sub-scene and scene registration:\n%  the sub-scene is considered to be part of a larger scene. \n% image\\_in is registered, and the resulting deformation model is used to \n% register the larger scene.\n\\item{\\bf [-i Interpolation type]} \\\\\nType of interpolation:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item  0: Zero order interpolation -- nearest neighbor.\n\\item  1: First order interpolation -- bilinear.\n\\item  2: Second order interpolation -- bicubic.\n\\end{itemize}\nDefault is 2.\n\\item{\\bf [-d DeforModel] } \\\\\nType of registration deformation model: \\\\\nThe type of polynomial model used for the geometrical registration. Three \ntypes\nare available:\n      \\begin{itemize}\n      \\baselineskip=0.4truecm\n      \\itemsep=0.1truecm\n      \\item 0: Polynomial of the first order of type I:\n            \\begin{eqnarray}\n            x^{'} & = & aX - bY + c_x \\\\\n            y^{'} & = & bX + aY + c_y \n            \\end{eqnarray}\n      \\item 1: Polynomial of the first order of type II:\n            \\begin{eqnarray}\n             x^{'} & = & aX + bY + c \\\\\n             y^{'} & = & dX + eY + f\n            \\end{eqnarray}\n      \\item 2: Polynomial of the second order:\n            \\begin{eqnarray}\n            x^{'} & = & aX^{2} + bY^{2} + cXY + dX + eY + f \\\\\n            y^{'} & = & gX^{2} + hY^{2} + iXY + jX + kY + l \n            \\end{eqnarray}\n      \\item 3: Polynomial of the third order.\n      \\end{itemize}\nDefault is 1.\n\\item{\\bf [-o]} \\\\\nManual Options specifications:\\\\\nA few options are provided in order to have more control on the procedure. \nUsing manual options, the following parameters can be fixed by the user \nfor each scale:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item Matching distance: \\\\\n      The distance used for the matching procedure. The procedure looks for each control\n      point candidate in the reference image which is the corresponding control point\n      candidate in the input image within a radius of {\\em Matching distance}.\n\\item Threshold level: \\\\\n      The threshold level used for thresholding the wavelet transform. \n\\item Type of registration deformation model (same as option -d).\n\\item Type of interpolation (same as option -i).\n\\end{itemize}\nThe available manual options are the following:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\itemsep=0.1truecm\n\\item 0:  Everything is taken care of by the program.\n\\item 1:  The matching distance is specified manually for each resolution.\n\\item 2:  The threshold level is specified manually for each resolution  and for\n      both the reference image and the input image.\n\\item 3:  The type of deformation model is specified manually for each resolution.\n\\item 4:  The matching distance, the Threshold level and the Type of deformation model \n      are specified manually for each resolution.\n\\item 5:  The matching distance, the threshold level, the type of deformation model \n      and the type of interpolation are specified manually for each resolution.\n\\end{itemize}\nThe default is none (0).\n\\item{\\bf [-w]} \\\\\nThe following files are written to  disk:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item deform\\_model.txt: contains the calculated coefficients of the \ndeformation model, allowing us to calculate the coordinates in the \nsecond image of a given point from its coordinates in the reference image.\n\\item scale\\_j\\_control\\_points.dat: contains the set of control points for\n each scale. The first line contains the number of control points, and all\n other lines the values Xr,Yr,Xi,Yi,\n where  Xr and Yr are the coordinates of the control point in the reference \n image (origin is (0,0)), and  Xi and Yi are the coordinates of the \n corresponding control point in the input image (second image).\n \\item xx\\_grill\\_in: an artificial image which contains a ``grilled'' image.\n \\item xx\\_grill\\_out: the resulting image after applying the deformation \n model to the artificial one.\n\\end{itemize}\nThe default is none.\n\\end{itemize}\n\n\\begin{figure}[htb]\n\\centerline{\n\\vbox{\n\\hbox{\n\\psfig{figure=ch5_dec_ngc.ps,bbllx=1.8cm,bblly=7cm,bburx=19.2cm,bbury=24.3cm,width=8cm,height=8cm}\n\\psfig{figure=ch5_diff_ngc_dec.ps,bbllx=1.8cm,bblly=7cm,bburx=19.2cm,bbury=24.3cm,width=8cm,height=8cm}\n}\n\\hbox{\n\\psfig{figure=ch5_rec_ngc.ps,bbllx=1.8cm,bblly=7cm,bburx=19.2cm,bbury=24.3cm,width=8cm,height=8cm}\n\\psfig{figure=ch5_diff_ngc_rec.ps,bbllx=1.8cm,bblly=7cm,bburx=19.2cm,bbury=24.3cm,width=8cm,height=8cm}\n}\n}}\n\\caption{Synthetic image (upper left) and difference between the original \nand the synthetic image (upper right). Registered image (bottom left) \nand difference between NGC2997 and the registered image (bottom right). }\n\\label{fig_ngc_register}\n\\end{figure}\n\nA strong distortion was applied to the galaxy NGC2997 (see \nFigure \\ref{fig_ngc}). \nA synthetic image was made by shifting it by 5 and 10 pixels \nin each axis direction. Then this image\nwas rotated by 10 degrees and Gaussian noise was added. \nFigure \\ref{fig_ngc_register} shows the synthetic image \n(upper left panel), and also the difference\nbetween the original image and the synthetic one (upper right panel).\nFigure \\ref{fig_ngc_register} (bottom left and right) shows the \ncorrected image and the residual between the original image \nand the corrected image.\nThe two images have been correctly -- and automatically -- registered.\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item mr\\_fusion -n 6 -s 10 -d 1 ngc2997.fits  dec\\_ngc  register\\_ima\\\\ \nRegister the image dec\\_ngc on ngc2997, with a 10 sigma detection, 6 scales,\nand using the first order deformation model of type 2. The \nresult is presented\nin Figure \\ref{fig_ngc_register}.\n\\end{itemize}\n\n\\clearpage\n\\newpage\n\nIf the deformation model is not sophisticated enough to resolve a specific\nproblem, the result will certainly not be correct, but the user can still\nuse the CGP points which do not depend on any model.\n", "meta": {"hexsha": "e1722e35b770c73296118ab50b35b44fee5fbd6f", "size": 12554, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr1/ch_register.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr1/ch_register.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr1/ch_register.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.8951048951, "max_line_length": 103, "alphanum_fraction": 0.7224788912, "num_tokens": 3285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.42445210526895905}}
{"text": "\\chapter[Black Holes]{Black Holes}\\label{chapter:pbhs}\nThis chapter provides background information on black holes\n\n\\section{History}\n\n\\section{Theory}\nEinstein's equation (in natural units, i.e. $c, h = 1$) is:\n\\begin{equation}\nG_{\\mu\\nu} = 8\\pi T_{\\mu\\nu}\n\\end{equation}\nThe unique static, spherically-symmetric solution to Einstein's equation is the Schwarszchild metric\nSchwarszchild metric\n\\subsection{Hawking Radiation}\nIn the classical treatment, black holes have no temperature and do not emit blackbody radiation; intuitively, energy cannot escape a black hole because the worldlines of particles inside the event horizon are trapped within Schwarschild radius $r=2GM$. \nIn the 1970s, however, it was noted that black holes appear to exhibit many of the same properties as classical thermodynamic systems.\nThe black hole area theorem is one example: during black hole mergers, the total black hole surface area is nondecreasing in much the same way that the Second Law of thermodynamics states that the entropy of a closed system is nondecreasing.\nFurther work by Bekenstein in 1972 led to the following analogies between black holes and thermodynamic quantities:\n\\begin{center}\n\\begin{tabular}{ccc}\nEntropy & $\\longleftrightarrow$ & Surface Area\\\\\nTemperature & $\\longleftrightarrow$ & Surface Gravity $\\kappa$\\\\\nEnergy & $\\longleftrightarrow$  & Mass\\\\\n\\end{tabular}\n\\end{center}\nBlack hole thermodynamics remains an area of active research, and recent work has added new terms to this list.\nAs an example, in anti-deSitter space the geometrical volume of a Schwarszchild black hole is equal to the thermodynamic volume associated with it.\n\nHowever, the work of Hawking and Beckenstein in the 1970s led to the understanding that black holes are really cool.\nThe Hawking temperature of a black hole is given by:\n\\begin{equation}\nT = \\frac{\\hbar c^3}{8\\pi k_B GM}\n\\end{equation}\n\nAs the black hole emits radiation, it loses mass and becomes hotter.\nThis process continues until the entirety (or nearly so- see Section X) of the black hole mass is emitted as Hawking radiation.\n\n\\section{Primordial Black Holes}\nBlack holes formed via stellar collapse cannot be smaller than approximately 2 solar masses.\n\\subsection{Formation Mechanisms}\nSee Halzen et al etc\n\\subsection{Constraints on Dark Matter}\nStuff from Carr et al, Kusenko et al\n\n\\subsection{Prospects for detection}\nFor a description of the $\\gamma$-ray spectrum of small black holes, see Appendix \\ref{chapter:pbh_spectrum}.", "meta": {"hexsha": "e9ccd148799bfbd52cd48f44ca0101604058fc8a", "size": 2492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter3.tex", "max_stars_repo_name": "christian-johnson/phd-thesis", "max_stars_repo_head_hexsha": "269a0a554963753ca7c81144428f80f3f97239cf", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter3.tex", "max_issues_repo_name": "christian-johnson/phd-thesis", "max_issues_repo_head_hexsha": "269a0a554963753ca7c81144428f80f3f97239cf", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter3.tex", "max_forks_repo_name": "christian-johnson/phd-thesis", "max_forks_repo_head_hexsha": "269a0a554963753ca7c81144428f80f3f97239cf", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.3777777778, "max_line_length": 253, "alphanum_fraction": 0.7945425361, "num_tokens": 599, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.42445210129632693}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsfonts}\n\\usepackage{syntax}\n\\usepackage{stmaryrd}\n\\usepackage{mathpartir}\n\\usepackage{tipa}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\chead{Globally Ordered Type System}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{30pt}\n\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Zt}{$\\Z$}\n\n% Create a relational rule\n% [#1] - Additional mathpartir arguments\n% {#2} - Name of the rule\n% {#3} - Premises for the rule\n% {#4} - Conclusions for the rule\n\\newcommand{\\relationRule}[4][]{\\inferrule*[lab={\\sc #2},#1]{#3}{#4}}\n\n\\newcommand{\\rel}[1]{\\ensuremath{\\llbracket {#1} \\rrbracket}}\n\\newcommand{\\ttt}{\\texttt}\n\\newcommand{\\transform}{\\rightsquigarrow}\n\\newcommand{\\proj}{\\pi}\n\\newcommand{\\ttuple}{(\\tau_1, \\ldots, \\tau_n)}\n\\newcommand{\\etuple}{(e_1,\\ldots,e_n)}\n\\newcommand{\\bool}{\\mathrm{bool}}\n\\newcommand{\\integer}{\\mathrm{int}}\n\\newcommand{\\option}{\\mathrm{option}}\n\\newcommand{\\uoption}[1]{(\\bool,#1)}\n\\newcommand{\\opt}[1]{\\texttt{opt-#1}}\n\\newcommand{\\varOf}[1]{\\texttt{varOf}(#1)}\n\n\n\n\\begin{document}\n\\section*{Globally Ordered Type Systems}\nA globally ordered type system is similar to an ordered type system, in that it specifies certain variables as ``ordered'', and aims to ensure that each variable is used exactly once, in the order that they were defined. However, unlike a ``normal'' ordered type system, the set of ordered variables is determined in advance -- all variables declared during the program itself are considered to be unordered. Since all ordered variables have global scope, this means we can refer to a singular order throughout the program.\n\nSpecifically, a globally ordered type system is defined with respect to an ordered set $G = \\{g_1, \\dots, g_n\\}$ of \\emph{global variables}. Our goal is to enforce that $g_1$ is always used before $g_2$, $g_2$ before $g_3$, and so on.\nThe \\emph{types} in a globally ordered type system specify which global variables have been used so far. The system contains $n+1$ base types $\\tau_0, \\tau_1, \\dots, \\tau_n$. If an expression has type $\\tau_i$, that signifies that all $g_j$ with $j <= i$ have been used; if $i < n$, this means that we expect $g_{i+1}$ to be the next global variable used.\n\nConvention: we use the symbols $\\tau_i$ to represent the specific types $\\tau_0, \\dots, \\tau_n$. The symbol $\\tau$ with a non-integer subscript (or no subscript) denotes any type.\n\nA major benefit of this system over regular ordered type systems is that functions which use the globally ordered variables can be defined ``out-of-order'', and have a type signature that specifies when they may be used. For the moment, we will consider a non-functional (i.e. dpt-like) language, in which function are defined only in declarations and there are no higher-order functions. For simplicity, we still restrict our language to have only single-argument functions (but allow multiple arguments to be passed in via tuples).\n\nAs a result, our system also contains function types $\\tau_i \\rightarrow \\tau_j$ where $i < j$, as well as a special ``polymorphic'' function type $\\alpha \\rightarrow \\alpha$ for functions which do not use global variables.\n\n   $\\tau$ $::=$ \\\\\n\t \\indent\\ \\ \\ \\textpipe\\ $\\tau_0$ \\textpipe\\ $\\tau_1$ \\textpipe\\ \\dots \\textpipe\\ $\\tau_n$\\\\\n\t \\indent\\ \\ \\ \\textpipe\\ $\\tau_i \\rightarrow \\tau_j$\\\\\n\t \\indent\\ \\ \\ \\textpipe\\ $\\alpha \\rightarrow \\alpha$\n\n\\section*{A Sample Language}\nTo explore this system in practice, we'll write up some rules for applying it to a simple dpt-like language, defined below.\n\n\\begin{grammar}\n  <prog> ::= <decl> \\alt <decl>; <prog>\n\n  <decl> ::=\n  def $\\tau$ f(x_1, \\dots, x_n) \\{<statement>\\}\n  \\alt <statement>\n\n  <statement> ::=\n  if <expr> then <statement> else <statement>\n  \\alt let x = <expr>\n  \\alt <statement>; <statement>\n  \\alt <expr>\n\n  <expr> ::=\n  <value>\n  \\alt x\n  \\alt <expr>, <expr>\n  \\alt f <expr>\n\n  <value> ::=\n  true \\alt false \\alt \\Zt\n  \\alt <value>, <value>\n\n\\end{grammar}\n\nNote that in this system we track two kinds of variables: function variables $f$ which may only be bound to functions, and regular variables $x$ which may not be bound to functions. Also note that we expect function definitions to be annotated with their input type here, but in practice we can easily infer it.\n\nNote that a globally ordered type system says nothing about the ``actual'' types of the values in the program. It is \\emph{only} concerned with checking the order of the global variables. That said, it can be freely used alongside a regular type inference algorithm, and so we assume that all expressions we consider are well-typed in the conventional sense.\n\nOur rules will define a three place relation $\\Gamma, \\tau_i \\vdash e \\colon \\tau$. Note that the $\\Gamma$ context here only stores information about function variables, since they're the only relevant ones.\nNote also that we include in the context a type telling us which global variables have been used so far. Our intention is that a program $p$ should be ``well-typed'' iff $\\emptyset, \\tau_0 \\vdash p \\colon \\tau_n$.\n\nWe also have a very similar relation for declarations of the form $\\Gamma, \\tau_i \\vdash e \\colon \\Gamma', \\tau$.\n\nWhen writing rules, we use the convention that the metavariable $x$ matches all \\emph{non-global} variables. We will always denote global variables using symbols of the form $g_i$. We use the metavariable $v$ for values and $e$ for expressions\n\nTo start out, let's write the high-level rules:\n\n\\begin{mathpar}\n  \\relationRule{prog-single}{\n   \\Gamma, \\tau_i \\vdash d\\ \\colon \\Gamma', \\tau_j\n  }{\n          \\Gamma, \\tau_i \\vdash d\\ \\colon \\tau_j\n  }\n\n\t\\relationRule{prog}{\n   \\Gamma, \\tau_i \\vdash d\\ \\colon \\Gamma', \\tau_j\\\\\n   \\Gamma', \\tau_j \\vdash p\\ \\colon \\tau_k\n\t}{\n          \\Gamma, \\tau_i \\vdash d; p\\ \\colon \\tau_k\n\t}\n\\end{mathpar}\n\n\\begin{mathpar}\n  \\relationRule{decl-def}{\n   \\Gamma, \\tau_k \\vdash s\\ \\colon \\tau_j\n  }{\n          \\Gamma, \\tau_i \\vdash \\texttt{def}\\ \\tau_k\\ f(x_1, \\dots, x_n) \\{s\\} \\colon \\Gamma[f := \\tau_k \\rightarrow \\tau_j], \\tau_i\n  }\n\n\t\\relationRule{decl-statement}{\n     \\Gamma, \\tau_i \\vdash s\\ \\colon \\tau_j\n\t}{\n     \\Gamma, \\tau_i \\vdash s\\ \\colon \\Gamma, \\tau_j\n\t}\n\\end{mathpar}\n\nNow we can write rules governing statements. These are pretty straightforward.\n\n\\begin{mathpar}\n  \\relationRule{statement-if}{\n     \\Gamma, \\tau_i \\vdash e\\ \\colon \\tau_j\\\\\n     \\Gamma, \\tau_j \\vdash s_1\\ \\colon \\tau_k\\\\\n     \\Gamma, \\tau_j \\vdash s_2\\ \\colon \\tau_k\n\t}{\n     \\Gamma, \\tau_i \\vdash \\texttt{if } e \\texttt{ then } s_1 \\texttt{ else } s_2\\ \\colon \\tau_k\n\t}\n\n  \\relationRule{statement-let}{\n     \\Gamma, \\tau_i \\vdash e\\ \\colon \\tau_j\n\t}{\n     \\Gamma, \\tau_i \\vdash \\texttt{let } x\\ =\\ e\\ \\colon \\tau_j\n\t}\n\n  \\relationRule{statement-seq}{\n     \\Gamma, \\tau_i \\vdash s_1\\ \\colon \\tau_j\\\\\n     \\Gamma, \\tau_j \\vdash s_1\\ \\colon \\tau_k\n\t}{\n     \\Gamma, \\tau_i \\vdash s_1;s_2\\ \\colon \\tau_k\n\t}\n\\end{mathpar}\n\nFinally, we can write some expr rules that actually make changes to the output type. The first few cases are easy: evaluating a value or non-global variable doesn't use any global variables.\n\n\\begin{mathpar}\n\t\\relationRule{value}{\n   \\\n\t}{\n          \\Gamma, \\tau_i \\vdash v\\ \\colon \\tau_i\n\t}\n\n\t\\relationRule{local variable}{\n   \\\n\t}{\n          \\Gamma, \\tau_i \\vdash x\\ \\colon \\tau_i\n\t}\n\\end{mathpar}\n\nOn the other hand, when we evaluate a global variable, our output type increases.\n\n\\begin{mathpar}\n\t\\relationRule{global variable}{\n   \\\n\t}{\n          \\Gamma, \\tau_i \\vdash g_i\\ \\colon \\tau_{i+1}\n\t}\n\\end{mathpar}\n\nEvaluating a tuple is nothing new; it's just a sequencing operation like we've seen before.\n\n\\begin{mathpar}\n\t\\relationRule{tuple}{\n          \\Gamma, \\tau_i \\vdash e_1\\ \\colon \\tau_j\\\\\n          \\Gamma, \\tau_j \\vdash e_2\\ \\colon \\tau_k\n\t}{\n          \\Gamma, \\tau_i \\vdash e_1, e_2\\ \\colon \\tau_k\n\t}\n\\end{mathpar}\n\nFinally, we can actually use our function types (and $\\Gamma$!).\n\n\\begin{mathpar}\n\t\\relationRule{app}{\n\t\t\t \\tau_i \\vdash e \\colon \\tau_j\\\\\n       \\Gamma[f] = \\tau_j \\rightarrow \\tau_k\n\t}{\n       \\tau_i \\vdash f\\ e \\colon \\tau_k\n\t}\n\n  \\relationRule{app}{\n  \t\t \\tau_i \\vdash e \\colon \\tau_j\\\\\n       \\Gamma[f] = \\alpha \\rightarrow \\alpha\n  }{\n       \\tau_i \\vdash f\\ e \\colon \\tau_j\n  }\n\\end{mathpar}\n\nAnd that's that!\n\n\\subsection{Functional Languages}\nExtending this to languages with function values and higher-order functions isn't difficult, but it is somewhat less elegant. The problem we run into is expressions which return a function value and also use a global variable; for example,\n\\texttt{let f = let x = g1 in (fun y -> x + y)}.\nCurrently, our typing relation can either return a function type or a return a base type indicating which global variables have been used, \\emph{but not both}. So we would need to extend the typing relation to return both.\n\nI guess we could also just have two typing rules for function expressions.\n\n\\begin{mathpar}\n\\relationRule{fun1}{\n    \\\n}{\n     \\tau_i \\vdash \\texttt{fun } \\tau_j\\ x \\rightarrow e\\ \\colon \\tau_i\n}\n\n\\relationRule{fun2}{\n    \\tau_j \\vdash e\\ \\colon \\tau_k\n}{\n     \\tau_i \\vdash \\texttt{fun } \\tau_j\\ x \\rightarrow e\\ \\colon \\tau_j \\rightarrow \\tau_k\n}\n\\end{mathpar}\n\nIn fact, the first rule could be viewed as just the value rule. Hell, it might even work. It would be hella sketchy though.\n\n\\section*{Weak Globally Ordered Type System}\nIt's pretty easy to see how we could convert this to a weakly-ordered type system (in which each ordered variable may be used at most once, instead of exactly once) just by inserting some inequalities into the rules. More interesting, though, is the observation that this corresponds to adding subtyping, with the base rule\n\n\\begin{mathpar}\n\t\\relationRule{subtyping}{\n\t\t\t i < j\n\t}{\n      \t\\tau_i <: \\tau_j\n\t}\n\\end{mathpar}\n\nand all other standard subtyping rules (refl, trans, function subtyping.)\n\n\\end{document}\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "ddf11527477e27b07583e1260b316bbdad97e062", "size": 10152, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/global typing.tex", "max_stars_repo_name": "DanielBentleyMacLeod/lucid", "max_stars_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2021-07-07T16:09:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T14:49:38.000Z", "max_issues_repo_path": "notes/global typing.tex", "max_issues_repo_name": "DanielBentleyMacLeod/lucid", "max_issues_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2021-08-30T16:48:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:19:34.000Z", "max_forks_repo_path": "notes/global typing.tex", "max_forks_repo_name": "DanielBentleyMacLeod/lucid", "max_forks_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-05T23:14:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:10:32.000Z", "avg_line_length": 37.6, "max_line_length": 533, "alphanum_fraction": 0.7031126872, "num_tokens": 3025, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6187804337438502, "lm_q1q2_score": 0.4244520933510627}}
{"text": "%!TEX root = soutenance_lei_2018.tex\r\n\\subsection{Mapping of the heat flux of an insulated small container by infrared thermography}\r\n\\frame{\\tableofcontents[currentsection,currentsubsection]}\r\n\r\n\\begin{frame}{ATP test}\r\n    the overall coefficient of heat transfer ($K$) is defined as:\r\n    \\begin{equation*}\r\n        K = \\frac{W}{S\\cdot \\Delta \\theta}\r\n    \\end{equation*}\r\n    $W$: Power \\\\\r\n    $\\Delta \\theta$: a  steady  temperature  difference\\\\\r\n    $S$ is the mean surface of the equipment:\r\n    \\begin{equation*}\r\n        S = \\sqrt{S_i \\cdot S_e}\r\n    \\end{equation*}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Theory \\& Methods}\r\n    Symbolically Ohm’s law:\r\n    \\begin{equation*}\r\n        I = \\frac{\\Delta V}{R_e}\r\n    \\end{equation*}\r\n    \\pause\r\n    Analogy to an electrical circuit, Fourier’s law can be written similarly as\r\n    \\begin{equation*}\r\n        q = \\frac{\\Delta T}{R_t}\r\n    \\end{equation*}\r\n\r\n    \\pause\r\n    \\begin{figure}\r\n        \\centering\r\n        \\includegraphics[scale=0.55]{img/ch2/Therm_Res.png}\r\n        % \\caption{Overall thermal resistance of the roll-container}\r\n        % \\label{Therm_Res}\r\n    \\end{figure}\r\n\r\n    \\centering\r\n    \\begin{minipage}[c]{0.8\\textwidth}\r\n        $\\theta_i$: inside temperature,  $\\theta_{wi}$: internal wall temperature\\\\\r\n        $\\theta_e$: outside temperature, $\\theta_{we}$: external wall temperature\r\n    \\end{minipage}\r\n\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Theory \\& Methods}\r\n    Heat flux computation:\\\\ \r\n    by a thermal flux meter in a reference zone:\r\n    \\begin{equation*}\r\n        q_{ref} = \\frac{\\theta_{we}(x_r,y_r)-\\theta_e}{1/h_e}\r\n    \\end{equation*}\r\n    which gives that:\r\n    \\begin{equation*}\r\n        h_e = \\frac{q_{ref}}{\\theta_{we}(x_r,y_r)-\\theta_e}\r\n    \\end{equation*}\r\n    then:\r\n    \\pause\r\n    \\begin{equation*}\r\n        q(x,y) = \\frac{q_{ref}}{\\theta_{we}(x_r,y_r)-\\theta_e}(\\theta_{we}(x,y)-\\theta_e)\r\n    \\end{equation*}\r\n    where $\\theta_{we}(x,y)$ is the temperature at each point of the external surface.    \r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Experimental Setup}\r\nRoll-container:\r\n    \\begin{figure}[!htbp]\r\n        \\centering\r\n        \\includegraphics[scale=0.08]{img/ch2/DSC_0191.jpg}\r\n        \\includegraphics[scale=0.08]{img/ch2/DSC_0189.jpg}\r\n        \\caption{The roll container used for the test [outside and inside]}\r\n        % \\label{box}\r\n    \\end{figure}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Results}\r\nValues from heat flux meter:\r\n    \\begin{figure}\r\n        % \\centering\r\n        \\hspace*{-18pt}\r\n        \\includegraphics[scale=0.275]{img/ch2/It_project_2014_QProfile.png}\r\n        \\includegraphics[scale=0.275]{img/ch2/It_project_2014_TProfile.png}\r\n        % \\caption{Data from thermal flux meter (heat flux and temperature profiles)}\r\n        % \\label{flux_meter}\r\n    \\end{figure}\r\n    \\centering\r\n    \\small{Mean values (steady condition) are $q_r=9.73\\; W/m^2$ and $T_r = 7.83\\; ^\\circ$C.}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Results--\\small{Thermal raw images}}\r\n    \\begin{figure}\r\n        \\vspace*{-5pt}\r\n        \\centering\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_front_m.jpg}\r\n        \\hspace{5pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_back_m.jpg}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_left_m.jpg}\r\n        \\hspace{5pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_right_m.jpg}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_top.jpg}\r\n        \\vspace*{-5pt}\r\n        \\caption{\\footnotesize{The temperature map of the roll container (front, rear, left, right and top surfaces)}}\r\n        % \\label{Q_box}\r\n    \\end{figure}\r\n\\end{frame}\r\n\r\n\\begin{frame}{Results--\\small{Image correction}}\r\n    Several image geometrical corrections exit, while an easier way to realize is to apply the \\alert{homography} technique from computer vision.\\\\\r\n    \\pause\r\n    Briefly, the planar homography relates the transformation between two planes (up to a scale factor):\r\n    \\begin{equation*}\r\n        s\\begin{bmatrix}\r\n        x'\\\\y'\\\\1\r\n        \\end{bmatrix}\r\n        =H \\begin{bmatrix}\r\n        x\\\\y\\\\1\r\n        \\end{bmatrix}\r\n        = \\begin{bmatrix}\r\n        h_{11} & h_{12} & h_{13}\\\\h_{21} & h_{22} & h_{23}\\\\h_{31} & h_{32} & h_{33}\r\n        \\end{bmatrix}\r\n        \\begin{bmatrix}\r\n        x\\\\y\\\\1\r\n        \\end{bmatrix}\r\n    \\end{equation*}\r\nIt is generally normalized with $h_{33}=1$\r\n\\end{frame}\r\n\r\n\\begin{frame}{Results--\\small{Homography}}\r\n    \\begin{figure}[ht]\r\n        \\centering\r\n        \\includegraphics[scale=0.45]{img/ch2/homography_perspective_correction.jpg}\r\n    \\end{figure}\r\n    \\pause\r\n    In our case, the ratio between the length and the width of the roll container is known. Once the projective transformation matrix in images has been obtained, a bilinear interpolation with the projective transformation matrix into the raw images will be performed.\r\n\r\n    Recall: \r\n        \\begin{equation*}\r\n            q(x,y) = \\frac{q_r}{\\theta_{we}(x_r,y_r)-\\theta_e}(\\theta_{we}(x,y)-\\theta_e)\r\n        \\end{equation*}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Results--\\small{Heat flux map}}\r\n    \\begin{figure}\r\n        \\vspace*{-5pt}\r\n        \\centering\r\n        \\includegraphics[scale=0.25]{img/ch2/Q_front_m.jpg}\r\n        \\hspace{5pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/Q_back_m.jpg}\r\n        \\hspace*{5pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/Q_left_m.jpg}\r\n        \\hspace{5pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/Q_right_m.jpg}\r\n        \\includegraphics[scale=0.25]{img/ch2/Q_top.jpg}\r\n        \\vspace*{-5pt}\r\n        \\caption{\\footnotesize{The heat flux map of the roll container (front, rear, left, right and top surfaces)}}\r\n        % \\label{Q_box}\r\n    \\end{figure}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Results--\\small{Vehicle results}}\r\n    \\begin{figure}\r\n        \\vspace*{-5pt}\r\n        \\centering\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_truck_lt_m}\r\n        \\hspace{3pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_truck_rt_m}\r\n        % \\vspace{3pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_truck_bk11_m}\r\n        \\hspace{6pt}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_truck_bk12_m}\r\n        \\includegraphics[scale=0.25]{img/ch2/IR_truck_tp_m}\r\n        \\vspace*{-5pt}\r\n        \\caption{\\footnotesize{The temperature map of the refrigerated vehicle (left, right, rear1, rear2 and top surfaces)}}\r\n    \\end{figure}\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}{Discussion}\r\n    \\begin{itemize}[<+->]\r\n    \\pause\r\n    \\large\r\n        \\item Thermal resistance model works well\r\n        \\item Homography application offers good results in roll-container\r\n        \\item The convective heat transfer coefficient not constant around the roll-container surfaces\r\n        \\item Unable to apply homography in large size of vehicle panel \r\n        \\item Thermal reflection in vehicle results\r\n    \\end{itemize}\r\n\\end{frame}\r\n", "meta": {"hexsha": "cdd5c427f90f89462fae5301c0c2ac96372385b3", "size": 6809, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "beamer/chp2.tex", "max_stars_repo_name": "Crescent-Saturn/PhD_grind", "max_stars_repo_head_hexsha": "aaa976e6c1c9bf932cd7cb44147a6a25a0537e39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "beamer/chp2.tex", "max_issues_repo_name": "Crescent-Saturn/PhD_grind", "max_issues_repo_head_hexsha": "aaa976e6c1c9bf932cd7cb44147a6a25a0537e39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "beamer/chp2.tex", "max_forks_repo_name": "Crescent-Saturn/PhD_grind", "max_forks_repo_head_hexsha": "aaa976e6c1c9bf932cd7cb44147a6a25a0537e39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0979381443, "max_line_length": 269, "alphanum_fraction": 0.6231458364, "num_tokens": 2011, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.42445209335106265}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n%\\makeindex\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on \n\n\\section{Subspaces}\n\\begin{defn}[Subspace]\t\nLet $(V,F,+,\\cdot )$ be a vector space. A subset $U \\subseteq V$ is a subspace if $(U,F,+,\\cdot )$ is itself a vector space under the same operations as \\(V\\).\n\\end{defn}\n\n\\begin{lemma}[Conditions for subspaces]\n $U \\subseteq V$ is a subspace if and only if\n\\begin{itemize}\n\t\\item $\\overline{0}$ is still in $U$\n\t\\item  $U$ is closed under addition: if $u,v \\in U$ then $u+v \\in U$\n\t\\item $U$ is closed under scalar multiplication;  if $v \\in U$ and $\\lambda \\in F$ then $\\lambda \\cdot v \\in U$\n\\end{itemize}\n\\end{lemma}\nThe three conditions ensure that the additive identity of $V$ is in $U$, and that both addition and scalar multiplication make sense in U.\n\n%If $u \\in U$ then $(3) \\implies (-1)\\cdot u\\in U\\implies-u\\in U$, therefore $U$ contains additive inverses.\n%Remaining axioms are inherited from V, such as associativity. \n%\\begin{figure}[ht]\n%    \\centering\n%    \\incfig{figure-1}\n%    \\caption{Visual of subspaces}\n%    \\label{fig:visual_of_subspaces}\n%\\end{figure}\n\n\\begin{exmp}[Example of subspace]\nLet $F = \\R$ and $ V = \\left\\{f \\mid  f:(0,3)\\to \\R \\right\\} $. Let\n\\begin{align*}\nU = \\left\\{ f \\in V \\mid f \\text{ differentiable, } f'(2) = 0 \\right\\} \\subseteq V .\n\\end{align*}\nThen \\(U\\subset V\\) is a subspace.\n\\end{exmp}\n\n\\begin{proof}[Proof of Example]\nThe zero vector of V is $\\overline{0}:(0,3)\\to \\R$ defined by $\\overline{0}:x\\mapsto  0$. The zero vector is differentiable and zero at $x=2$, so the zero vector is in our set U.\\\\\n\nNow we want to show that $U$ is closed under addition. Let $f,g \\in U$. By the linearity of differentiation, $(f+g)$ is differentiable, and so satisfies the first property of U. If $f'(2)=0$ and $g'(2)=0$, then $\\frac{d}{dx}(f(x)+g(x))\\mid_{x=2} = 0 + 0 = 0$\\\\\n\nFinally, we want to show that U is closed under scalar multiplication. Let $f\\in U$ and $\\lambda \\in \\R$. Consider $\\lambda \\cdot f(x)$. Because $\\lambda$ is a scalar, we know that $\\lambda \\cdot f(x)$ is still differentiable. Moreover, the derivative of the new function is simply $\\lambda \\cdot f'(x)$, and at $x = 2$, $\\lambda \\cdot f'(2) = \\lambda \\cdot 0 = 0$ and so U is still closed under scalar multiplication.\n\\end{proof}\n\n% \\printindex\n\\end{document}\n", "meta": {"hexsha": "e0a06543419a9c0c5cc0a13de70ad1062ba1bb2d", "size": 2695, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Linear Algebra/Notes/source/09-05-19-Subspaces.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Linear Algebra/Notes/source/09-05-19-Subspaces.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Linear Algebra/Notes/source/09-05-19-Subspaces.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4615384615, "max_line_length": 418, "alphanum_fraction": 0.6842300557, "num_tokens": 874, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.42439546888331947}}
{"text": "\\documentclass[]{article}\n\\RequirePackage{amsmath}\n\n\\usepackage{graphicx}\n%\\graphicspath{{./figures/}}\n\\usepackage{amssymb}\n\\usepackage{color}\n\\usepackage{hyperref}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\bibliographystyle{IEEEtran}\n\n\\newcommand{\\knote}[1]{\\textcolor{green}{A: {#1}}}\n\\newcommand{\\dnote}[1]{\\textcolor{red}{D: {#1}}}\n\\newcommand{\\vk}[1]{\\textcolor{blue}{V: {#1}}}\n\\newcommand{\\lnote}[1]{\\textcolor{cyan}{L: {#1}}}\n\\newcommand{\\Name}{$Autolykos$}\n\\def\\Let#1#2{\\State #1 $:=$ #2}\n\\def\\LetRnd#1#2{\\State #1 $\\gets$ #2}\n\n\\newcommand{\\pk}{\\mathsf{pk}}\n\\newcommand{\\sk}{\\mathsf{sk}}\n\n\\begin{document}\n    \\title{\\Name: The Ergo Platform PoW Puzzle}\n\n    \\author{Alexander Chepurnoy, Vasily Kharin, Dmitry Meshkov}\n\n    \\date{April 6, 2019\\\\v1.0}\n    \\maketitle\n\n    %    \\begin{abstract}\n    %        This document contains the full description of \\Name~-- the PoW protocol that is going to be used in Ergo platform.\n    %    \\end{abstract}\n\n\n    \\section{Introduction}\n\n    Security of Proof-of-Work blockchains relies\n    on multiple miners trying to produce new blocks by\n    participating in PoW puzzle lottery, and the network is secure if the\n    majority of them are honest. However, the reality becomes much more complicated\n    than the original one-CPU-one-vote idea from the Bitcoin whitepaper\\cite{nakamoto2008bitcoin}.\n\n    The first threat to decentralization came from mining pools -- miners tend\n    to unite in mining pools.\n    Regardless of the PoW algorithm number of pools controlling more then 50\\% of\n    computational power is usually quite small: 4 pools in Bitcoin, 2 in Ethereum, 3 in ZCash, etc.\n    This problem led to the notion of non-outsourceable puzzles~\\cite{miller2015nonoutsourceable,daian2017piecework}.\n    These are the puzzles constructed in such a way that if a mining pool outsources the puzzle\n    to a miner, miner can recover pool's private key and steal the reward with a non-negligible probability.\n    However the existing solutions either have too large solution size (kilobyte is already\n    on the edge of acceptability for distributed ledgers) or very specific and\n    can not be modified or extended in any way without breaking non-outsourceability.\n\n    The second threat to cryptocurrencies decentralization is that ASIC-equipped miners are\n    able to find PoW solutions orders of magnitude faster and more efficiently\n    than miners equipped with the commodity hardware. In order to reduce the\n    disparity between the ASICs and regular hardware, memory-bound computations\n    where proposed in~\\cite{dwork2003memory}. The most interesting practical\n    examples are two\n    asymmetric memory-hard PoW schemes which require significantly less memory\n    to verify a solution than to find it~\\cite{biryukov2017equihash,ethHash}.\n    Despite the fact that ASICs already exist for both of them~\\cite{ETHAsics,EquihashAsics},\n    they remain the only asymmetric memory-hard PoW algorithms in use.\n\n    In this paper we propose \\Name{} --- new asymmetric memory-hard non-outsourceable PoW puzzle.\n    In Section~\\ref{puzzle} we provide a full\n    specification of \\Name, while in Section~\\ref{discussion} we discuss its\n    properties. Few auxiliary algorithms are placed in~\\nameref{appendix}.\n\n    \\section{Ergo PoW puzzle}\n    \\label{puzzle}\n\n    The proposed scheme requires following components:\n    \\begin{enumerate}\n        \\item Cyclic group $\\mathbb{G}$ of prime order~$q$ with fixed generator~$g$\n        and identity element~$e$.\n        Secp256k1 elliptic curve is used for this purposes.\n        \\item Number of elements $k$ required in the solution. Value $k=32$ is used in\n        implementation.\n        \\item Number $N$ of elements in the list\n        $R\\subset\\mathbb{Z}/q\\mathbb{Z}$ to be stored in miner's memory.\n        Value $N=2^{26}$ is used in implementation.\n        \\item Hash function $H$ which returns the values in $\\mathbb{Z}/q\\mathbb{Z}$.\n        Particular implementation is based on Blake2b256 and is described in Alg.\\ref{alg:H}.\n        \\item Hash function $genIndexes$ which returns a list of numbers from\n        $0\\dots(N-1)$ of size $k$.\n        It is based on Blake2b256 and is described in Alg.\\ref{alg:genIndexes}.\n        \\item Target interval parameter $b$, that is recalculated via difficulty adjustment rules.\n        \\item Constant message $M=[0,\\dots,1023].flatMap(i => Longs.toByteArray(i))$ that is used to enlarge message size and increase elements calculation time.\n    \\end{enumerate}\n\n    \\Name{} is based on one list $k$-sum problem: miner should find\n    $k$ elements from the pre-defined list $R$ of size $N$, such that\n    $\\sum_{j \\in J} r_{j} - sk = d$ is in the interval $\\{-b,\\dots,0,\\dots,b\\mod q\\}$.\n    In addition, we require set of element indexes $J$ to be obtained\n    by one-way pseudo-random function $genIndexes$. This prevents optimizations as\n    soon as it is hard to find such a seed,\n    that $genIndexes(seed)$ returns the desired indexes.\n\n    Thus we assume that the only option for miner is to use the simple brute-force algorithm~\\ref{alg:prove} to\n    create a valid block.\n\n    \\begin{algorithm}[H]\n        \\caption{Block mining}\n        \\label{alg:prove}\n        \\begin{algorithmic}[1]\n            \\State \\textbf{Input}: upcoming block header hash $m$, key pair $pk=g^{sk}$\n            \\State Generate randomly a new key pair $w=g^x$\n            \\State Calculate $r_{i \\in [0,N)}=H(j||M||pk||m||w)$\n            \\While{$true$}\n            \\LetRnd{$nonce$}{$\\mathsf{rand}$}\n            \\Let{$J$}{$genIndexes(m||nonce)$}\n            \\Let{$d$}{$\\sum_{j \\in J}{r_j} \\cdot x - sk \\mod q$}\n            \\If{$d < b$}\n            \\State \\Return $(m,pk,w,nonce,d)$\n            \\EndIf\n            \\EndWhile\n        \\end{algorithmic}\n    \\end{algorithm}\n\n    Note that although the mining process utilizes private keys, solution itself\n    only contains public keys. Solution verification can be performed by Alg.~\\ref{alg:verify}.\n\n    \\begin{algorithm}[H]\n        \\caption{Solution verification}\n        \\label{alg:verify}\n        \\begin{algorithmic}[1]\n            \\State \\textbf{Input}: $m,pk,w,nonce,d$\n            \\State require $d < b$\n            \\State require $pk,w\\in \\mathbb{G}$ and $pk,w \\ne e$\n            \\Let{$J$}{$genIndexes(m||nonce)$}\n            \\Let{$f$}{$\\sum_{j \\in J} H(j||M||pk||m||w)$}\n            \\State require $w^f = g^dpk$\n        \\end{algorithmic}\n    \\end{algorithm}\n\n\n    \\section{Discussion}\n    \\label{discussion}\n\n    First, notice that in Algorithm~\\ref{alg:prove} we refer to construction\n    $f(m,nonce,w,pk)=\\sum_{j\\in genIndexes(m||nonce)} H(j||M||pk||w)$ as a hash\n    function. Public key plays a role of commitment. Therefore, the pair\n    $(pk,d)$ is a Schnorr signature with a public key $w$ over the message\n    $(m,nonce)$ with a hash function $f$. If one denotes $e$ the corresponding\n    value of $f$, and pass to more common notations:\n    $e=f(m,nonce,w,w^eg^{-d})$. The puzzle consists in trying\n    different nonces and keys in order for signature to satisfy\n    $d\\in\\{-b,\\dots,0,\\dots,b\\}$. Security follows from the security of Schnor\n    signatures, and outsourcing the puzzle is equivalent to outsourcing the\n    signature (or parts of signature creation routine). The only difference from\n    conventional setup is the design of function $f$. It must be constructed in such\n    a way that efficient massive evaluations with different nonces require\n    allocating large amount of memory (benefitting from data reuse), whereas\n    single evaluation on verifier's side can be done ``on fly''.\n\n    To achieve this, algorithm~\\ref{alg:prove} requires to keep the whole list $R$ during the main loop.\n    Every pre-calculated hash occupies 32 bytes, so the whole list of $N$ elements\n    occupies $N \\cdot 32 = 2 Gb$ of memory.\n    For sure, a miner can recalculate these elements ``on fly'' during the main loop and\n    thus reduce memory requirements.\n    However in such a case the number of calls of $H$ will significantly grow up~(e.g.\n    assuming GPU hashrate $G = 2^{30} H/s$~\\cite{gpuHashrate} and block interval $t=120~s$,\n    every element will be used $(G / N) \\cdot k \\cdot t = 3 \\cdot 10^4$ times on average.)\n    reducing miner's efficiency and profit.\n\n    While list $R$ is quite big, it's filling consumes quite a lot of time: our initial implementation~\\cite{ergoMiner}\n    consumed ~25 seconds on Nvidia GTX 1070 to fill list $R$. This part, however, may be sufficiently\n    optimized if miner in addition stores a list of unfinalized hashes $u_{i \\in [0,N)}=H(i||M||pk$\n    in memory, consuming 5 more Gigabytes of it. In such a case this work to calculate unfinalized hashes should\n    be done only once during mining initialization while finalizing them and filling the list $R$\n    for the new header will only consume few milliseconds~(for about 50 ms on Nvidia GTX 1070).\n\n    The protocol is quite efficient in terms of solution size and verification time: it consists of 2 public keys of\n    size 32 bytes, number $d$ that is at most 32 bytes\n    (but contains a lot of leading zeros in case of the small target $b$) and an\n    8-bytes long nonce. Header verification requires verifier to calculate 1 $genIndexes$\n    hash, $k$ hashes $H$ and perform two exponentiations in the group. Reference\n    Scala implementation~\\cite{ergoGit} allows verifying block header in 2\n    milliseconds on Intel Core i5-7200U, 2.5GHz.\n\n    \\bibliography{references}\n\n    \\section*{Appendix}\n    \\label{appendix}\n\n    Implementation of hash function $H$ which returns the values in $\\mathbb{Z}/q\\mathbb{Z}$:\n\n    \\begin{algorithm}[H]\n        \\caption{Numeric hash}\n        \\label{alg:H}\n        \\begin{algorithmic}[1]\n            \\Function{H}{$input$}\n            \\Let{$validRange$}{$(2^{256} / q) \\cdot q$}\n            \\Let{$hashed$}{$Blake2b256(input)$}\n            \\If{$hashed < validRange$}\n            \\State \\Return $hashed.mod(q)$\n            \\Else\n            \\State \\Return $H(hashed)$\n            \\EndIf\n            \\EndFunction\n        \\end{algorithmic}\n    \\end{algorithm}\n\n    Implementation of hash function $genIndexes$ which returns a list of size $k$ with numbers in $0\\dots (N-1)$:\n\n    \\begin{algorithm}[H]\n        \\caption{Index generator}\n        \\label{alg:genIndexes}\n        \\begin{algorithmic}[1]\n            \\Function{genIndexes}{$seed$}\n            \\Let{$hash$}{$Blake2b256(seed)$}\n            \\Let{$extendedHash$}{$hash||hash$}\n            \\State \\Return $(0\\dots{k-1}).map(i => extendedHash.slice(i,i+4).mod(N))$\n            \\EndFunction\n        \\end{algorithmic}\n    \\end{algorithm}\n\n\\end{document}", "meta": {"hexsha": "ccd331933cc9be4c9c1d83615ae6eb1355f53aa5", "size": 10646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/yellow/pow/ErgoPow.tex", "max_stars_repo_name": "scasplte2/ergo", "max_stars_repo_head_hexsha": "9964f415526f491a4837774d80b59792e1e2b8bb", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-28T17:15:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-28T17:15:35.000Z", "max_issues_repo_path": "papers/yellow/pow/ErgoPow.tex", "max_issues_repo_name": "scasplte2/ergo", "max_issues_repo_head_hexsha": "9964f415526f491a4837774d80b59792e1e2b8bb", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/yellow/pow/ErgoPow.tex", "max_forks_repo_name": "scasplte2/ergo", "max_forks_repo_head_hexsha": "9964f415526f491a4837774d80b59792e1e2b8bb", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1719457014, "max_line_length": 161, "alphanum_fraction": 0.6781889912, "num_tokens": 2873, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4243897482130324}}
{"text": "\\chapter*{Abstract}\n\\addcontentsline{toc}{chapter}{Abstract}\n\\vspace{-1em}\n\n\nElectricity systems are facing the pressure to change in response to the effects of new technology, particularly the proliferation of renewable technologies (such as solar PV systems and wind generation) leading to the retirement of traditional generation technologies that provide stabilising inertia.\nThese changes create an imperative to consider potential future market structures to facilitate the participation of distributed energy resources (DERs; such as EVs and batteries) in grid operation.\nHowever, this gives rise to general questions surrounding the ethics of market structures and how they could be fairly applied in future electricity systems. Particularly the most basic question ``how \\textit{should} electricity be valued and traded'' is fundamentally a moral question without any easy answer.\nWe give a survey of philosophical attitudes around such a question, before presenting a series of ways that these intuitions have been cast into mathematics, including: the Vickrey-Clarke-Groves mechanism, Locational Marginal Pricing, the Shapley Value, and Nash bargaining solution concepts.\n\nWe compared these different methods, and attempted a new synthesis that brought together the best features of each of them; called the `Generalised Neyman and Kohlberg Value' or the GNK-value for short.\nThe GNK value was developed as a novel bargaining solution concept for many player non-cooperative transferable utility generalised games, and thus it was intrinsically flexible in its application to various aspects of powersystems.\nWe demonstrated the features of the GNK-value against the other mathematical solutions in the context of trading the immediate consumption/generation of power on small sized networks under linear-DC approximation, before extending the computation to larger networks.\nThe GNK value proved to be difficult to compute for large networks but was shown to be approximable for larger networks with a series of sampling techniques and a proxy method.\nThe GNK value was ethically compared to other mechanisms with the unfortunate discovery that it allowed for participants to be left worse-off for participating, violating the ethical notion of `euvoluntary exchange' and `individual rationality'; but was offered as an interesting innovation in the space of transferable utility generalised games notwithstanding.\n\nFor sampling the GNK value, there was a range of new and different techniques developed for stratified random sampling which iteratively minimise newly derived concentration inequalities on the error of the sampling.\nThese techniques were developed to assist in the computation of the GNK value to larger networks, and they were evaluated in the context of sampling synthetic data, and in computation of the Shapley Value of cooperative game theory.\nThese new sampling techniques were demonstrated to be comparable to the more orthodox Neyman sampling method despite not having access to stratum variances.\n\n\n\n", "meta": {"hexsha": "16fe37d85f30fb4c05c6fcb54f69b5fe406620c5", "size": 3038, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/appendages/abstract.tex", "max_stars_repo_name": "Markopolo141/Thesis_code", "max_stars_repo_head_hexsha": "df7cffff8127641b0fed0309adf38cfc9372e618", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/appendages/abstract.tex", "max_issues_repo_name": "Markopolo141/Thesis_code", "max_issues_repo_head_hexsha": "df7cffff8127641b0fed0309adf38cfc9372e618", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/appendages/abstract.tex", "max_forks_repo_name": "Markopolo141/Thesis_code", "max_forks_repo_head_hexsha": "df7cffff8127641b0fed0309adf38cfc9372e618", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 132.0869565217, "max_line_length": 362, "alphanum_fraction": 0.831797235, "num_tokens": 558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.42428027333302853}}
{"text": "\\documentclass[a4paper]{IEEEtran} \n\\usepackage[cmex10]{amsmath} \n\\usepackage{cite} \n%\\usepackage{multicol}\n%\\usepackage{fancyhdr}\n\\usepackage{graphicx} \n\\usepackage[colorlinks=false, hidelinks]{hyperref} \n\n\\interdisplaylinepenalty=2500\n\\setlength{\\IEEEilabelindent}{\\IEEEilabelindentB}\n\n\\markboth{640--402 Quantum Mechanics B: Energy Levels and Spectrum of Hydrogenic Atoms}{} \n\n%\\title{ \\large{ \\textsc{640-402 Quantum Mechanics B -- Assignment } }\\\\[1mm]\n%       \\huge{{\\bf \\sffamily Energy Levels and Spectrum of \\\\ Hydrogenic Atoms}} }\n\\title{Energy Levels and Spectrum of Hydrogenic Atoms} \n\\author{ Michael Papasimeon\\\\ 16 April, 1998} % \\\\\n\\date{April 16, 1998}\n\n\\newcommand{\\ket}[1]{| #1 \\rangle}\n\\newcommand{\\bra}[1]{\\langle #1 |}\n\\newcommand{\\element}[3]{\\bra{#1} #2 \\ket{#3}}\n\n\\renewcommand{\\sectionmark}[1]{\\markboth{#1}{}}\n\\renewcommand{\\sectionmark}[1]{\\markright{\\thesection\\ #1}}\n\n%\\lhead[\\fancyplain{}{\\it\\thepage}]%\n%      {\\fancyplain{}{\\it\\rightmark}}\n%\\rhead[\\fancyplain{}{\\it\\leftmark}]%\n%      {\\fancyplain{}{\\it\\thepage}}\n%\\cfoot{}\n\n\n\\begin{document}\n\\maketitle\n\\thispagestyle{plain} \n\n\\begin{abstract}\n\tThis paper describes the energy levels and spectrum of hydrogenic atoms.\n\tThe effects of relativistic corrections and spin-orbit coupling are taken\n\tinto account to show the fine structure of hydrogenic atoms. In addition,\n\tnuclear effects giving rise to hyperfine structure and quantum \n\telectrodynamic effects giving rise to the Lamb shift are also discussed.\n\tThe spectrum of hydrogenic atoms is discussed in the radio, infra-red,\n\tvisible, UV and X-Ray regions.\n\\end{abstract}\n\n%\\tableofcontents\n%\\newpage\n\n%\\begin{multicols}{2}\n\n%\\setcounter{page}{1}\n\n\\section{Introduction}\n    \\IEEEPARstart{A} hydrogenic atom is one with a nucleus of charge $Z$ and a single electron. \n    Therefore the physics of Hydrogen ($\\mathsf{H}$) with $Z = 1$, singly ionised \n    Helium ($\\mathsf{He^+}$) with $Z = 2$, doubly ionised Lithium ($\\mathsf{Li^{++}}$) \n    and so forth, is essentially the same. The quantum mechanics of the Hydrogen atom \n    is applicable to other atoms which only have a single electron. A study of the\n    spectrum of hydrogen was one of the earliests tests of quantum mechanics.\n\n\\section{Schr\\\"odinger Equation}\n\n    \\subsection{Energy Levels}\n    A hydrogenic atom can be thought of as an electron with charge ($-e$) moving around\n    the spherically symmetric Coulomb potential of the nucleus which has charge $Z$.\n    The Hamiltonian for this atomic system can then be written down as\n    \\begin{equation} \n        H = \\frac{\\bf{p}^2}{2\\mu} - \\frac{Ze^2}{4 \\pi \\epsilon_0 r}.\n    \\end{equation} \n    where the first term corresponds to the kinetic energy of the electron, and\n    the second term corresponds to the Coulombic attraction between the electron and \n    the nucleus. The momentum of the electron is $\\bf{p}$, $Z$ is the number of protons\n    in the nucleus, $r$ is the distance between the electron and the nucleus, $e$ is\n    the fundamental electric charge on an electron or proton and $\\mu$ is\n    the reduced mass of the system given by\n    \\begin{equation}\n        \\mu = \\frac{Mm}{M + m}\n    \\end{equation}\n    The problem reduces to solving the time independent Schr\\\"odinger equation\n    for the above Hamiltonian.\n    \\begin{equation}\n    \\left[ \\frac{{\\bf p}^2}{2\\mu} - \\frac{Ze^2}{4 \\pi r}\\right] \\psi_{nlm} = E_n \\psi_{nlm} \n    \\end{equation}\n    Solving for this equation gives the energy levels of hydrogenic atoms $E_n$, and \n    and corresponding wavefunctions $\\psi_{nlm}$. The energy levels only depend on the\n    principle quantum number $n$, whereas the wavefunctions also depend on the \n    orbital angular momentum quantum number $l$ ($l = 0, 1, ... n - 1$) and \n    magnetic quantum number $m$ ($m = -l, -l + 1, ... , +l - 1, +l$).\n    The wavefunctions of hydrogenic atoms are given by\n    \\begin{equation}\n        \\psi_{nlm}({\\bf r}) = \\psi_{nlm}(r,\\theta,\\phi)\n                           = R_{nl}(r) Y_{lm}(\\theta, \\phi)\n    \\end{equation}\n    where $R_{nl}(r)$ are the radial wavefunctions and $Y_{lm}(\\theta, \\phi)$ are\n    spherical harmonics. The corresponding energy levels of hydrogenic atoms are\n    given by\n    \\begin{equation}\n        E_n = - \\frac{1}{2} \\mu c^2 \\frac{Z^2 \\alpha^2}{n^2}\n    \\end{equation}\n    where $\\alpha$ is the fine structure constant \n    ($ \\alpha = e^2 / (4 \\pi \\epsilon_0 \\hbar c) $).\n    Since the energy levels depend only on the principle quantum number $n$, we see\n    that the energy levels are degenerate for different values of $l$ and $m$ at a \n    given value of $n$.\n    \n    Figure~\\ref{fig:hydrogen-energy} shows the energy levels for the case when $Z = 1$ (Hydrogen).\n    The degeneracy in $l$ can be seen for the different values of $n$.\n    The energy levels shown are known as the gross structure of atomic hydrogen.\n\n    \\begin{figure}[!t] \n        \\centering\n        \\includegraphics[width=\\columnwidth]{levels.eps}\n        \\caption{Energy Levels of Hydrogen Atoms} \n        \\label{fig:hydrogen-energy} \n    \\end{figure} \n\n    \\subsection{Rydberg States}\n    A highly excited hydrogenic atom, that is one with a large principal quantum \n    number $n$ is said to be known as a \\emph{Rydberg Atom}, or to be in a\n    \\emph{Rydberg State}.\n    Table~\\ref{tbl:rydberg} compares some properties of a hydrogen atom in a $n=1$ state\n    and one in a $n=100$ state.\n\n    \\begin{table} \n        \\caption{Bohr orbit radius and binding energy for Hydrogen atoms in \n                 the ground state $n=1$ and Rydberg state $n=100$} \n        \\label{tbl:rydberg} \n        \\centering\n        \\begin{tabular}{p{4cm}rr} \\hline\n            {\\bf Quantity}               & $\\mathbf{n = 1}$          & $\\mathbf{n = 100}$ \\\\ \\hline \\hline \n            Bohr Orbit Radius [m]        &  $5.3 \\times 10^{-11}$    & $5.3 \\times 10^{-7}$ \\\\ \n            Binding Energy $|E_n|$ [eV]  &  $-13.6 \\times 10^0$      & $1.36 \\times 10^{-3}$ \\\\ \\hline\n        \\end{tabular}\n    \\end{table} \n\n    The Rydberg Atom with $n = 100$, is of an extremely large size -- approximately the size\n    of a simple bacteria. However, such an atom has a very small ionisation energy and hence\n    the electron is very weakly bound.\n\n    \\subsection{Hydrogenic Spectrum}\n    Figure~\\ref{fig:spectrum} shows the spectrum of atomic hydrogen as predicted by the\n    Bohr model of the atom and by Schr\\\"odinger's equation. As can be seen there\n    are a number of series of spectral lines -- Lyman, Balmer, Paschen and Brackett.\n\n    \\begin{figure*}[!t]\n        \\centering\n        \\includegraphics[width=0.7\\textwidth]{spectrum}\n        \\caption{Spectrum of Atomic Hydrogen} \n        \\label{fig:spectrum} \n    \\end{figure*} \n\n    The hydrogen series appear close together in the electromagnetic spectrum.\n    For example, the Lyman Series is in the Ultra-Violet (UV) Region, the Balmer\n    series is in the Visible-UV region and the Paschen, Brackett and Pfund series\n    are in the Infra-Red (IR) Region.\n\n     \\begin{table}\n        \\centering\n        \\caption{Lyman, Balmer and Paschen Spectral Lines} \n        \\label{tbl:spectral-lines} \n        \\centering\n        \\begin{tabular}{cc} \\hline \n            \\multicolumn{2}{c}{\\bf Lyman Series (Ultra Violet Region)} \\\\ \\hline \n            Spectral Line & Wavelength (\\AA) \\\\ \\hline \n            Ly$_{\\alpha}$     &   1216    \\\\ \n            Ly$_{\\beta}$      &   1026    \\\\ \n            Ly$_{\\gamma}$     &   972.5   \\\\\n            Ly$_{\\delta}$    &   949.7   \\\\ \\hline \n\n            \\multicolumn{2}{c}{\\bf Balmer Series (Visible--Ultra Violet Region)} \\\\ \\hline \n            Spectral Line & Wavelength (\\AA) \\\\ \\hline \n            H$_{\\alpha}$     &   6563    \\\\ \n            H$_{\\beta}$      &   4861    \\\\ \n            H$_{\\gamma}$     &   4340   \\\\ \\hline \n\n            \\multicolumn{2}{c}{\\bf Paschen Series (Infra Red Region)} \\\\ \\hline \n            Spectral Line & Wavelength (\\AA) \\\\ \\hline \n            P$_{\\alpha}$     &   18751    \\\\ \n            P$_{\\beta}$      &   12818    \\\\  \\hline\n\n\n        \\end{tabular}\n    \\end{table} \n\n    %The schematic spectral diagram below shows the Balmer series of atomic\n    %hydrogen. It shows the positions of the spectral lines in the electromagnetic\n    %spectrum.\n\n    %\\begin{figure}[!t] \n    %    \\centering\n    %    \\includegraphics[width=\\columnwidth]{balmer}\n    %    \\caption{Balmer Spectrum for Atomic Hydrogen} \n    %    \\label{fig:balmer} \n    %\\end{figure} \n\n\\section{Fine Structure}\n    Although the energy levels for hydrogenic atoms shown above agree qualitatively with\n    experiment, very precise measurements of the hydrogen spectrum reveal the existence \n    a finer structure which can not be explained with the Hamiltonian used above.\n    Experiments reveals that some of the energy levels are split into many smaller levels\n    and therefore many of the degeneracies are lifted.\n\n    The fine structure of the energy levels of hydrogenic atoms are due to relativistic\n    effects and the spin of the electron which were not taken into account in the previous\n    section. We can obtain an estimate on how much the energy levels are shifted, by \n    using perturbation theory if we assume the the relativistic and spin effects are \n    small. We can treat the Hamiltonian, energy eigenfunctions and energy levels as\n    the unperturbed case and use first order perturbation theory for the perturbing\n    components of the Hamiltonian. The Schr\\\"odinger equation is then of the following\n    form\n\n    \\begin{equation} \n        \\left[ H_0 + H'_1 + H'_2 + H'_3 \\right] \\psi_{nlm} = E \\psi_{nlm}\n    \\end{equation} \n\n    where $H_0$ corresponds to the unperturbed Hamiltonian used in the previous section,\n    and $H'_1$, $H'_2$ and $H'_3$ correspond to small perturbations involving relativistic\n    corrections to the kinetic energy, the effect of spin-orbit coupling and the Darwin\n    interaction. These three perturbations are described individually below.\n    The process then involves determining the shift in energy to first order for \n    each of the perturbing terms in the Hamiltonian. The unperturbed Schr\\\"odinger \n    equation needs to be slightly modified in order to treat perturbing Hamiltonians\n    which take the spin of the electron into account. The modified `unperturbed`\n    equation is given by\n    \\begin{equation}\n        H_0 \\psi_{nlm_l m_s }^{(0)} = E_{n}^{(0)} = \\psi_{nlm_l m_s}^{(0)} \n    \\end{equation},\n    where $E_{n}^{(0)}$ are the Schr\\\"odinger energy eigenvalues (with $\\mu = m$) and \n    the zero order wave functions $\\psi_{nlm_l m_s}^{(0)}$ are modified two component\n    wave functions (also known as Pauli wave functions or spin-orbitals) given by\n    \\begin{equation}\n        \\psi_{nlm_l m_s}^{(0)}(q) = \\psi_{nlm_l}^{(0)}({\\bf r}) \\chi_{\\frac{1}{2},m_l}\n    \\end{equation}.\n    The parameter $q$ represents the combined spin and space coordinate, and \n    $\\chi_{\\frac{1}{2},m_l}$ are two component spinors (spin eigenfunctions for\n    particle of spin one half). For spin-up ($m_s = +1/2$) and spin-down ($m_s = -1/2$),\n    the normalised spinors are denoted by\n    \\begin{equation}\n        \\chi_+ = \\left( \\begin{array}{c}\n                    1 \\\\ 0\n                 \\end{array} \\right)\n        \\hspace{5mm} \\mathrm{and} \\hspace{5mm}\n        \\chi_- = \\left( \\begin{array}{c}\n                    0 \\\\ 1\n                 \\end{array} \\right)\n    \\end{equation}\n    Since the unperturbed Hamiltonian does not depend on the spin variable, the\n    Pauli wavefunctions are separable in the spin and coordinate variables.\n    To describe the state of an electron in a hydrogenic atom, we now have the four\n    quantum number $n$, $l$, $m_l$ and $m_s$. As a result of this, each of the\n    unperturbed energy levels are $E_n$ are $2n^2$ degenerate.\n\n    Finally the new perturbed energy levels to first order are given by\n    \\begin{equation}\n        E = E_{n}^{(0)} + \\Delta E'_1 + \\Delta E'_2 + \\Delta E'_3\n    \\end{equation}\n    where $\\Delta E'_{(k)}$ is the energy shift resulting from the $k'$th perturbation.\n    \n\t\\subsection{Relativistic Correction to the Kinetic Energy}\n\t\\begin{equation}\n\t\tH'_1 = - \\frac{p^4}{8m^3c^2}\n\t\\end{equation}\n    Since relativistic effects were not taken into account previously, the \n    perturbing Hamiltonian $H'_1$ represents the relativistic correction\n    to the kinetic energy of the electron.\n    Using first order perturbation theory the energy shift is given by\n    \\begin{equation} \n        \\Delta E'_1 = \\left \\langle nl m_l m_s \n                        \\left|\n                            \\frac{-p^4}{8m^3 c^2} \n                        \\right|\n                      nl m_l m_s \\right \\rangle \n    \\end{equation}\n    \\begin{equation}\n        \\Delta E'_1 = -E_n \\frac{Z^2 \\alpha^2}{n^2} \n                        \\left[ \\frac{3}{4}  - \\frac{n}{l + \\frac{1}{2}} \\right]\n    \\end{equation}\n\n\t\\subsection{Spin Orbit Interaction}\n\t\\begin{equation}\n\t\tH'_2 = \\frac{1}{2m^2c^2} \\frac{1}{r} \\frac{dV}{dr} {\\bf L} \\cdot {\\bf S} \n\t\\end{equation}\n    This perturbation corresponds to the shift in the energy as a result of the interaction\n    between the internal spin of the electron and it's orbital angular momentum as it\n    orbits the nucleus. Since the potential $V(r) = -Ze^2/(4 \\pi \\epsilon_0 r)$ for\n    a hydrogenic atom, the perturbing Hamiltonian becomes\n    \\begin{equation}\n        H'_2 = \\frac{1}{2m^2c^2} \\frac{Ze^2}{4\\pi \\epsilon_0 r^3} {\\bf L} \\cdot {\\bf S}\n    \\end{equation}\n    The energy shift for this perturbing Hamiltonian using first order perturbation theory is\n    \\begin{equation}\n        \\Delta E'_2 = -E_n \\frac{Z^2 \\alpha^2}{2nl(l + \\frac{1}{2})(l + 1)}\n        \\left\\{\n            \\begin{array}{ll}\n                l       \\mbox{,} &  j = l + \\frac{1}{2} \\\\\n                -l - 1  \\mbox{,} &  j = l - \\frac{1}{2}\n            \\end{array}\n        \\right.\n    \\end{equation}\n\n\t\\subsection{Darwin Interaction}\n\t\\begin{equation}\n\t\tH'_3 = \\frac{\\pi\\hbar^2}{2m^2c^2} \\left( \\frac{Ze^2}{4\\pi\\epsilon_0} \\right) \\delta(\\bf{r})\n\t\\end{equation}\n    The Darwin term does not act on the spin variable and only applies when\n    the orbital angular moment is zero ($l=0$).\n    The shift energy from the Darwin term is given by\n    \\begin{equation}\n        \\begin{array}{ll}\n        \\Delta E'_3 = -E_n \\frac{Z^2 \\alpha^2}{n} , & l = 0\n        \\end{array}\n    \\end{equation}\n\n    \\subsection{Fine Structure Energy Levels to First Order}\n    Based on the energy levels obtained for hydrogenic atoms from the Schr\\\"odinger equation,\n    and the energy shifts obtained from the three perturbation when relativistic and\n    spin effects are taken into account we get\n    \\begin{equation}\n        E_{nj} = E_n + \\Delta E'_1 + \\Delta E'_2 + \\Delta E'_3.\n    \\end{equation}\n    Now subtracting from the binding energy $E = mc^2 - E_{nj}$ \n    \\begin{equation}\n        E = mc^2 \\left[ 1 - \\frac{(Z \\alpha)^2}{2n^2} - \\frac{(Z \\alpha)^4}{2n^3} \n                        \\left(\n                            \\frac{n}{j + \\frac{1}{2}} - \\frac{3}{4}\n                        \\right)\n                    \\right] \n    \\end{equation}\n    This result is valid if the perturbation is small, and therefore it begins to break down\n    for hydrogenic atoms with large atomic numbers $Z$.\n\n    \\subsection{Dirac Equation}\n    The equation which provides the correct energy eigenvalues and eigenstates for\n    the fine structure of hydrogenic atoms is the Dirac equation. \n    For a Hydrogenic atom that Dirac equation can be written as:\n    \\begin{equation}\n        \\left[ c \\mathbf{\\alpha} \\cdot \\mathbf{p} + \n               \\beta m c^2 - \\frac{Ze^2}{4 \\pi \\epsilon_0 r}\n        \\right] \\psi = E \\psi\n    \\end{equation}\n    where $\\psi$ is a 4-component spinor.\n    The Dirac equation takes special relativistic effects and the spin of the electron\n    (or any spin-$\\frac{1}{2}$ particle) into account, and gives the following solutions for the energy\n    eigenvalues for hydrogenic atoms.\n    \\begin{equation}\n        E_{nj}^{Dirac} = \\frac{mc^2}\n        {\n            \\sqrt\n            { \n                1 + \\frac{(Z \\alpha)^2}\n                {\n                    n - j - \\frac{1}{2} +\n                    \\sqrt\n                    {\n                        \\left(j + \\frac{1}{2}\\right)^2 - (Z \\alpha)^2\n                    }\n                }\n            }\n        }\n    \\end{equation}\n    Expanding the above equation in a series we obtain\n    \\begin{equation}\n        E = mc^2 \\left[ \n            1 - \\frac{(Z\\alpha)^2}{2n^2} - \\frac{(Z\\alpha)^4}{2n^2}\n                    \\left(\n                        \\frac{1}{j + \\frac{1}{2}} - \\frac{3}{4n}\n                    \\right)\n                        - ...\n                 \\right]\n    \\end{equation}\n    This can be seen to agree with the result obtained previously using the perturbation\n    theory for the first few terms.\n\n\\section{Hyperfine Structure}\n    Until now, the nucleus of hydrogenic atoms has been treated as a point charge.\n    effectively of infinite mass. However, precise spectroscopic measurements \n    of hydrogenic atoms reveal some very small effects on the energy levels which\n    cannot be explained if the nucleus is treated in this way. These effects are\n    known as \\emph{hyperfine effects} because they are much smaller then the fine\n    structure effects predicted by the Dirac equation. The hyperfine effects can\n    be grouped into two types.\n\n    \\begin{enumerate}\n        \\item Hyperfine structure effects give rise to splittings in energy levels\n        \\item Isotope shifts slightly shift the energy levels and can usually be \n              detected by observing the differences between two or more \n              different isotopes.\n    \\end{enumerate} \n\n    Hyperfine structure effects arise from the electric multipole moments of the \n    nucleus which can interact with the electromagnetic field produced at the \n    nucleus by the electrons. The two main multipole moments are the magnetic \n    dipole moment associated with the spin of the nucleus and the electric quadrupole\n    moment due to the departure of the spherical charge distribution in the nucleus.\n    Perturbation theory can be used to determine the shift in the energy these\n    two multipole effects will have.\n       \n    \\subsection{Magnetic Dipole Interaction}\n    The perturbation which describes the interaction of the nuclear magnetic dipole \n    moment consists of two expressions depending on the orbital angular momentum $l$.\n    For the case of $l \\neq 0$ we have\n    \\begin{equation}\n        H'_{MD} = \\frac{2\\mu_0}{4 \\pi \\hbar} g_I \\mu_B \\mu_N \\frac{1}{r^3}\n                   {\\bf G} \\cdot {\\bf I}\n    \\end{equation}\n    where\n    \\begin{equation}\n        {\\bf G} = {\\bf L} - {\\bf S} + 3 \\frac{({\\bf S} \\cdot {\\bf r}) {\\bf r}}{r^2}\n    \\end{equation}\n    and the total spin of the atom (nucleus and electron) is given by\n    \\begin{equation}\n        {\\bf F} = {\\bf I} + {\\bf J}.\n    \\end{equation}\n%    This perturbation gives the following first order shift in the energy,\n%    \\begin{equation}\n%        \\Delta E_{MD} = \\frac{C}{2} [ F(F+1) - I(I+1) - j(j+1)]\n%    \\end{equation}\n%    where\n%    \\begin{equation}\n%        C = \\frac{\\mu_0}{4\\pi} 2g_I \\mu_B \\mu_N \\frac{l(l+1)}{j(j+1)}\n%            \\frac{Z^3}{a_{\\mu}^{3} n^3 l (l + l/2)(l+1)}\n%    \\end{equation}\n    For the case when $l = 0$, the perturbation is given by\n    \\begin{equation}\n        H'_{MD}  =  \\frac{\\mu_0}{4\\pi} 2g_I \\mu_B \\mu_N \\frac{8 \\pi}{3} \n               \\delta({\\bf r}) {\\bf S} \\cdot {\\bf I}.\n    \\end{equation}\n\n    \\subsection{Electric Quadrupole Interaction}\n    The interaction Hamiltonian between the electric quadrupole moment of the\n    nucleus and the electrostatic potential create by an electron at the nucleus is \n    given (in atomic units) by\n    \\begin{equation}\n        H'_{EQ} = B \\frac{\\frac{3}{2}{\\bf I} \\cdot {\\bf J} (2{\\bf I}\\cdot {\\bf J} + 1) - \n                        {\\bf I}^2 {\\bf J}^2} {2I(2I-1)j(2j-1)}    \n    \\end{equation}\n\n    \\subsection{Hyperfine Spectrum}\n    The magnetic dipole and electric quadrupole interactions above correspond to \n    a total hyperfine energy shift of\n    \\begin{equation}\n        \\Delta E = \\frac{C}{2}K + \\frac{B}{4} \n                   \\frac{\\frac{3}{2}K(K+1)-2I(I+1)j(j+1)}{I(2I-1)j(2j-1)}\n    \\end{equation}\n    where $B$ is the quadrupole coupling constant given by\n    \\begin{equation}\n        B = Q \\left \\langle \\frac{\\partial^2 V}{\\partial z^2} \\right \\rangle\n    \\end{equation}\n    and\n    \\begin{equation}\n        K = F(F+1) - I(I+1) - j(j+1)\n    \\end{equation}\n    \\begin{equation}\n         C = \\frac{\\mu_0}{4\\pi} 2g_I \\mu_B \\mu_N \\frac{l(l+1)}{j(j+1)}\n            \\frac{Z^3}{a_{\\mu}^{3} n^3 l (l + l/2)(l+1)} \n    \\end{equation}\n\n    \\begin{figure*}[!t]  \n        \\centering\n        \\includegraphics[angle=-90,width=0.7\\textwidth]{all.eps}\n        \\caption{Energy Levels for Hydrogen Atom for $n=1$ and $n=2$}\n        \\label{fig:split} \n    \\end{figure*} \n\n    Figure~\\ref{fig:split} shows the splittings of the different energy\n    in a Hydrogen atom for n = 1 and n = 2. The diagram is not to scale and\n    are magnified form the left to the right. The diagram qualitatively shows\n    the effect on the Bohr/Schr\\\"odinger energy from the various corrections\n    such as the Dirac fine structure, the Lamb Shift (described in the \n    next section) and the hyperfine structure.\n\n    \\subsection{21 cm Line of Atomic Hydrogen}\n    The energy level splitting diagram in Figure~\\ref{fig:split} shows that the ground state of\n    the hydrogen atom splits into two hyperfine levels with the total angular\n    momentum of the atom being $F=0$ and $F=1$.\n    The difference in energy between these two levels is 1420 MHz which corresponds\n    to a wavelength of $\\lambda \\approx $ 21 cm. The probability of a transition\n    occurring between these two levels is very low and occurs on average only \n    once every few million years. However, there is a large amount of hydrogen gas\n    in the galaxy allowing radio telescopes easily detect this 21 cm transition and\n    therefore allow the mapping of hydrogen in the galaxy.\n\n\\section{Lamb Shift}\n    Investigation of the fine structure of hydrogenic atoms using spectroscopic techniques\n    in the 1930's showed that there were small differences between the observed spectra\n    and the theoretical predictions made by the Dirac equation.\n    For example, according to the Dirac equation the $2s_{1/2}$ and the $2p_{1/2}$ states\n    coincide at the same energy level. Observations showed that the $2s_{1/2}$ was shifted \n    slightly upwards by about 0.03 cm$^{-1}$.\n    A very accurate measurement of the shift was made in 1947 by Lamb and Retherford using\n    microwave techniques to stimulate a direct radio-frequency transition between the \n    $2s_{1/2}$ and the $2p_{1/2}$ levels. This small shift of energy levels became known\n    as the Lamb shift.\n\n    \\begin{figure}[!ht] \n        \\centering\n        \\includegraphics[width=\\columnwidth]{lamb.eps}\n        \\caption{The Lamb Shift} \n        \\label{fig:lamb} \n    \\end{figure} \n\n    The physics of the Lamb shift are described in the theory of quantum electrodynamics,\n    in which radiative corrections to the Dirac equation are obtained by taking into\n    account the interaction of a quantised electromagnetic field with an electron.\n    The Lamb shift arises because of the zero point energy of a quantised electromagnetic\n    field is non zero, similar to the zero point energy of a quantum harmonic oscillator.\n    In a vacuum, fluctuations of the zero point energy of the quantised radiation field\n    act on the electron. The effect of the electron is to cause it to oscillate rapidly\n    about some equilibrium position. As a result of this oscillatory motion, the electron\n    does not appear to be point charge -- instead the electron charge is slightly smeared\n    at in a sphere of some small radius. When the electron is bound by an electric field\n    as it is in an atom, the potential it experiences is slightly different to that \n    experienced by the electron in it's mean position. Therefore electrons which are\n    most sensitive to short distance modifications such as those in the ground state\n    are raised in energy with respect to other states to which the shift is much smaller.\n\n    \\section{References}\n    \\begin{enumerate}\n        \\item \\emph{Physics of Atoms and Molecules}, Bransden and Joachain\n        \\item \\emph{Quantum Mechanics of One- and Two-Electron Atoms},\n                    Bethe and Salpeter\n        \\item \\emph{Intermediate Quantum Mechanics}, Bethe\n        \\item \\emph{Advanced Quantum Mechanics}, Sakurai\n        \\item \\emph{The Spectrum of Atomic Hydrogen - Advances}, Series\n        \\item \\emph{Quantum Mechanics}, Merzbacher\n        \\item \\emph{Modern Physics}, Serway, Moses and Moyer\n    \\end{enumerate}\n\n%\\end{multicols}\n\\end{document}\n", "meta": {"hexsha": "0b0606c404ddceefa310a9918d12072f65108cd2", "size": 24895, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hydrogen-article.tex", "max_stars_repo_name": "mikepsn/hydrogenic-atoms", "max_stars_repo_head_hexsha": "455fa93a8f8aa74f9de80e2f44c9baa636fa7e69", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hydrogen-article.tex", "max_issues_repo_name": "mikepsn/hydrogenic-atoms", "max_issues_repo_head_hexsha": "455fa93a8f8aa74f9de80e2f44c9baa636fa7e69", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hydrogen-article.tex", "max_forks_repo_name": "mikepsn/hydrogenic-atoms", "max_forks_repo_head_hexsha": "455fa93a8f8aa74f9de80e2f44c9baa636fa7e69", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7073170732, "max_line_length": 107, "alphanum_fraction": 0.647961438, "num_tokens": 7095, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832805, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.4242802720651166}}
{"text": "\\documentclass{article} % For LaTeX2e\n\\usepackage[a4paper,margin=1.5in]{geometry}\n\\usepackage[mathlines]{lineno}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{bm}\n\\usepackage{hyperref}\n\\usepackage{natbib}\n\\usepackage{latexsym,amsbsy,amssymb,color,xspace, booktabs}\n\n\\include{macros}\n\\include{local_macros}\n\\def\\linenumberfont{\\normalfont\\small\\sffamily}\n\n\\title{Multiple Output Regression}\n\n\\newcommand{\\fix}{\\marginpar{FIX}}\n\\newcommand{\\new}{\\marginpar{NEW}}\n\n%\\nipsfinalcopy % Uncomment for camera-ready version\n\n\\begin{document}\n\\maketitle\n\\linenumbers\n\n\\section{Model Description}\nWe describe a multiple-output regression model.\nSuppose that we have inputs $\\X = \\{\\x_n\\}_{n=1}^N$ and outputs $\\y = \\{\\y_n\\}_{n=1}^N$, with $\\x_n \\in \\calR^D$ and $\\y_n \\in \\calR^P$, i.e. the output is $P$-dimensional.\nFor ease of exposition, we assume that there are no missing values in any output dimension.\nThe most dominant approach in GP-based multiple output regression is to compose the different outputs as some \\textit{linear} mixing (combination) of some basic processes (random functions).\nOur model is also underpinned by this composition approach.\nHowever, to really address the issue of scalability, this model is built upon sparse GPs from the ground up.\n\n\n\\subsection{Prior and Likelihood}\nWe use a simple composition:\n\\begin{align}\nf_i(\\x) = w_i g(\\x) + h_i(\\x), \\quad i = 1 \\hdots P,\n\\end{align}\nwhere each (latent) output is the sum of two functions: one scaled latent function that is shared by all outputs and one latent function unique to the output.\nThis allows the outputs to be correlated via the shared function $g(\\x)$ while still having their own independent processes.\nFurthermore we assume that $g(\\x) \\sim \\GP(0, k_g(\\x,\\x'; \\vectheta_g))$ and $h_i(\\x) \\sim \\GP(0, k_i(\\x,\\x'; \\vectheta_i))$, and that $h_i$ are independent GPs with their own set of hyperparameters. \\\\\n\n\\noindent The auto-variance of the latent output using this composition is\n\\begin{align}\n\\nonumber\ncov[f_i(\\x), f_i(\\x')] \n&= cov \\left[ \\left(w_i g(\\x) + h_i(\\x) \\right) \\left(w_{i} g(\\x') + h_i(\\x') \\right) \\right] \\\\\n&= w_i^2 k_g(\\x, \\x') + k_i(\\x,\\x').\n\\end{align}\n\\\\\n\\noindent The cross-covariance of the latent outputs is\n\\begin{align}\n\\nonumber\ncov[f_i(\\x), f_{i'}(\\x')] \n&= cov \\left[ \\left(w_i g(\\x) + h_i(\\x) \\right) \\left(w_{i'} g(\\x') + h_{i'}(\\x') \\right) \\right] \\\\\n&= w_i w_{i'} k_g(\\x, \\x').\n\\end{align} \n\n\\noindent It can be seen that the induced covariance function of $f_i(\\x)$ is very similar to that in the MTGP model.\nSpecifically, in MTGP the task-correlation matrix is a free-form positive definite matrix $B$ whereas here it is the matrix $\\w \\w^T$ where $\\w = [w_1, \\hdots, w_P]^T$.\nHowever this model is more flexible compared to MTGP because each output is also influenced by its own independent process $h_i(\\x)$.\nNote that we can also use more than one shared function $g(\\x)$, in which case it becomes the semiparametric latent force model (SLFM), again with the addition of independent process in each output dimension. \\\\\n\n\\noindent \n\\textbf{Augmented sparse GPs}\nToward scalable modeling, we replace standard GPs with sparse GPs augmented with \\textit{different} set of inducing inputs.\nThis adds much flexibility to the model as the roles of $g(\\x)$ and $h_i(\\x)$ can be quite different, so it is necessary that each has its own inducing inputs.\nFurthermore, $g(\\x)$ can be seen as a \\textit{global} function operating on the entire input space (of all output dimensions), while each $h_i(\\x)$ operates only on the inputs of the $i$-th output, which can be smaller than that of $g(\\x)$.\nIf more than one $g(\\x)$ is used, each $g(\\x)$ may capture a different pattern so they should also have separate inducing inputs. \\\\\n\n\\noindent\n\\textbf{Prior}\n\\newcommand{\\Zg}{\\Z_g}\n\\newcommand{\\Zi}{\\Z_i}\nLet $\\g = g(\\X), \\h_i = h_i(\\X), \\h = \\{\\h_i \\}_{i=1}^P$. Let $\\Zg$ and $\\mat{Z}^h = \\{\\Zi \\}_{i=1}^P$ be the set of inducing inputs for $g(\\x)$ and $h_i(\\x)$; the corresponding inducing points $\\u_g$ and $\\u^h = \\{\\u_i \\}_{i=1}^P$.\nThe prior of the augmented model is given by:\n\\begin{align}\np(\\g | \\u_g) &= \\Normal(\\g; \\BigMu_g, \\tilde{\\K}_g )\\\\\np(\\u_g) &= \\Normal(\\u_g; \\vec{0}, k_g(\\Zg, \\Zg)) \\\\\np(\\h | \\u^h) &= \\prod_{i=1}^P \\Normal(\\h_i; \\BigMu_i, \\tilde{\\K}_i)\\\\\np(\\u^h) &= \\prod_{i=1}^P \\Normal(\\u_i; \\vec{0}, k_i(\\Zi, \\Zi)),\n\\end{align}\nwhere $\\BigMu_g = k_g(\\X,\\Zg)k(\\Zg,\\Zg)^{-1}\\u_g$ and $\\tilde{\\K}_g = k_g(\\X,\\X) - k(\\X,\\Zg)k(\\Zg,\\Zg)^{-1}k(\\Zg,\\X)$ and $\\BigMu_i, \\tilde{\\K}_i$ are similarly defined.\n\n\\noindent\n\\textbf{Likelihood}\nThe likelihood as usual follows the standard iid Gaussian likelihood,\n\\begin{align}\np(\\y | \\g, \\h ) = \\prod_{i=1}^P p( \\y_i ; \\g, \\h_i) = \\prod_{i=1}^P \\Normal( \\y_i ; w_i \\g + \\h_i, \\beta_i^{-1} \\I).\n\\end{align}\n\n\\subsection{Variational Inference in Sparse GPs Revisited}\nIn this section we review inference in sparse GPs (as presented in Titsias).\nThe posterior in an augmented model is $p(\\f, \\u | \\y) = p(\\f | \\u, \\y) p(\\u | \\y)$.\nThe key property of such augmented GPs  is the notation of \\textit{sufficient statistics}: given the inducing points $\\u$, the latent values $\\f$ are independent with any other set of latent values (e.g. the test set).\nIn the optimal setting when $\\u$ is the sufficient statistics of $\\f$, it should hold that $p(\\f | \\u, \\y) = p(\\f | \\u)$ as $\\y$ is only the noisy version of $\\f$.\nThis leads to choosing a variational approximation of the posterior which factorizes as $q(\\f, \\u | \\y) = p(\\f | \\u) q(\\u | \\y)$.\nSince the conditional $p(\\f | \\u)$ is known, variational inference becomes learning an optimal posterior $q(\\u | \\y)$ only. \\\\\n\n\\noindent Also as a consequence of sufficient statistics, the approximate prediction for test targets $\\vfstar$ at test inputs $\\X_*$ is\n\\begin{align}\n\\nonumber\np(\\vfstar | \\y, \\X_*) &= \\int p(\\vfstar | \\f, \\u, \\X_*) q(\\f, \\u | \\y) \\der \\f \\der \\u \\\\\n\\nonumber\n&= \\int p(\\vfstar | \\u) q(\\u| \\y) p(\\f | \\u) \\der \\f \\der \\u \\\\ \\nonumber\n&= \\int p(\\vfstar | \\u) q(\\u| \\y) \\der \\u \\\\\n\\label{eq:sorprediction}\n&= \\Normal(\\vfstar; \\bs{\\mu_*},\\vec{s_*})\n\\end{align}\nwhere,\n\\begin{align}\n\\nonumber\n\\bs{\\mu_*} &= \\K_{*z} \\K_{zz}^{-1}\\m \\\\ \n\\nonumber\n\\S_* &= \\K_{**} - \\K_{*z} \\left(\\K_{zz}^{-1} - \\K_{zz}^{-1} \\S \\K_{zz}^{-1} \\right) \\K_{*z}^T.\n\\end{align}\n Here $\\K_{*z}$ is the covariance matrix between test and inducing inputs, $\\K_{zz}$ is the covariance matrix of the inducing inputs.\n\n\\subsection{Variational Inference}\n\\newcommand{\\ug}{\\u_g}\n\\newcommand{\\uh}{\\u^h}\nOur goal of inference is to find the posterior $p(\\g, \\h, \\ug, \\uh | \\y)$. \nFollowing the previous discussion, we assume a variational distribution which factorizes as:\n\\begin{align}\n\\nonumber\nq(\\g, \\h, \\ug, \\uh | \\y)\n &= p(\\g | \\ug) q(\\ug | \\y) \\prod_{i=1}^P p(\\h_i | \\u_i) q(\\u_i | \\y) \\\\\n &=  q(\\ug, \\uh) p(\\g | \\ug) \\prod_{i=1}^P p(\\h_i | \\u_i)\n\\end{align}\nSince the conditionals $p(\\g | \\ug)$ and $p(\\h_i | \\u_i)$ are given, we need only to find the optimum $q(\\ug, \\uh) = q(\\ug | \\y) \\prod_{i=1}^P q(\\u_i | \\y)$.\nLet $q(\\ug | \\y) = \\Normal(\\ug; \\m_g, \\S_g)$ and $q(\\u_i | \\y) = \\Normal(\\u_i; \\m_i, \\S_i)$. \\\\\n\n\\noindent\nTo find the optimum $q(\\ug, \\uh)$ we optimize the evidence lowerbound of the log marginal,\n\\begin{align}\n\\nonumber\n\\log p(\\y) \\ge& \\int q(\\ug, \\uh) \\log \\frac{p(\\y | \\ug, \\uh) p(\\ug, \\uh)}{q(\\ug, \\uh)} \\der \\ug \\der \\uh \\\\\n\\nonumber\n=& \\int q(\\ug, \\uh) \\log p(\\y | \\ug, \\uh)  \\der \\ug \\der \\uh \n+ \\int q(\\ug, \\uh) \\log \\frac{p(\\ug, \\uh)}{q(\\ug, \\uh)} \\der \\ug \\der \\uh \\\\\n\\label{eq:elbo}\n=& \\int q(\\ug, \\uh) \\log p(\\y | \\ug, \\uh)  \\der \\ug \\der \\uh \n- \\left( \\KL[q(\\ug) || p(\\ug)] + \\sum_{i=1}^P \\KL[q(\\u_i) || p(\\u_i)] \\right),\n\\end{align}\nwhere the last equality occurs because both of $q(\\ug, \\uh)$ and $p(\\ug, \\uh)$ fully factorize.\nSince $q(\\ug), q(\\u_i), p(\\ug), p(\\u_i)$ are all multivariate Gaussian distribution, the KL divergences are analytically tractable and require $\\calO(M^3)$ computation, where $M$ is the largest number of inducing inputs (recall that $g(\\x)$ and $h_i(\\x)$ use separate set of inducing inputs). \\\\\n\n\\noindent To compute the above equation we first focus on the term:\n\\newcommand{\\llangle}{\\left\\langle}\n\\newcommand{\\rrangle}{\\right\\rangle}\n\\begin{align}\n\\nonumber\n\\log p(\\y | \\ug, \\uh)\n &= \\log \\Eb{p(\\y | \\g, \\h)}_{p(\\g,\\h | \\ug, \\uh)} \\\\\n \\nonumber\n&\\ge \\Eb{\\log p(\\y | \\g, \\h)}_{p(\\g,\\h | \\ug, \\uh)} \\quad &\\text{(Jensen's inequality)} \\\\\n\\nonumber\n&=  \\Eb{\\sum_{i=1}^P \\sum_{n=1}^N \\log p(y_{in} | g_n, h_{in}) }_{p(\\g,\\h | \\ug, \\uh)}  \\quad &\\text{(factorized likelihood)} \\\\\n&= \\sum_{i=1}^P \\sum_{n=1}^N \\Eb{\\log p(y_{in} | g_n, h_{in}) }_{p(\\g,\\h_i | \\ug, \\u_i)} \\quad &\\text{(linear operation)}\n\\end{align}\nObserve that this is very similar to the SVI for standard GP in Hensman et al. \nIn this multiple-output model, the outputs factorize given $\\g$ and $\\h$ hence the lowerbound can be seen as sum of the lowerbounds in the single-output setting.\n\n\\noindent Each individual term $l_{in} = \\llangle \\log p(y_{in} | g_n, h_{in}) \\rrangle_{p(\\g,\\h_i | \\ug, \\u_i)}$ can be computed as follows:\n\\begin{align}\n\\nonumber\nl_{in} &= \\int \\log p(y_{in} | g_n, h_{in}) p(\\g | \\ug) p(\\h_i | \\u_i) \\der \\g \\der \\h_i \\\\\n\\nonumber\n&= \\int \\log \\Normal(y_{in} ; w_i g_n + h_{in}, \\beta_i^{-1}) \n\\Normal(g_n ; \\mu_{gn}, \\tilde{k}_{gnn})\n\\Normal(h_{in} ; \\mu_{in}, (\\tilde{k}_{inn}) \\der g_n \\der h_{in} \\\\\n\\nonumber\n&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} \\int (y_{in} - w_i g_n - h_{in}) \\beta_i (y_{in} - w_i g_n - h_{in})\n\\Normal(g_n ; \\mu_{gn}, \\tilde{k}_{gnn})\n\\Normal(h_{in} ; \\mu_{in}, \\tilde{k}_{inn}) \\der g_n \\der h_{in} \\\\\n\\nonumber\n&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} \\int \\left[(y_{in} - h_{in} - w_i \\mu_{gn}) \\beta_i (y_{in} - h_{in} - w_i \\mu_{gn}) + w_i^2 \\beta_i \\tilde{k}_{gnn} \\right] \n\\Normal(h_{in} ; \\mu_{in}, \\tilde{k}_{inn}) \\der h_{in} \\\\\n\\nonumber\n&= -\\frac{1}{2} \\log 2 \\pi \\beta_i^{-1} - \\frac{1}{2} w_i^2 \\beta_i \\tilde{k}_{gnn}\n- \\frac{1}{2} \\beta_i \\tilde{k}_{inn} - \\frac{1}{2} (y_{in} - w_i \\mu_{gn} - \\mu_{in}) \\beta_i (y_{in} - w_i \\mu_{gn} - \\mu_{in}) \\\\\n&= \\log \\Normal(y_{in}; w_i \\mu_{gn} + \\mu_{in}, \\beta_i^{-1})  - \\frac{1}{2} \\beta_i (w_i^2 \\tilde{k}_{gnn} + \\tilde{k}_{inn}),\n\\end{align}\nwhere $\\tilde{k}_{gnn} = (\\tilde{\\K}_g)_{n,n}, \\tilde{k}_{inn} = (\\tilde{\\K}_i)_{n,n}, \\mu_{gn} = (\\Mu_g)_n, \\text{ and } \\mu_{in} = (\\Mu_i)_n$.\nNotice that the above expression is very similar to the single-output case.\nHence our derivation here can be seen as the \\textit{generalization} of SVI from the standard GP regression to multiple-output regression.\n\n\\noindent Substituting $l_{in}$ into equation \\ref{eq:elbo} and carrying similar integration we get,\n\\begin{align}\n\\nonumber\n\\log p(\\y)\n\\ge& \\sum_{i=1}^P \\sum_{n=1}^N\n \\left( \\log \\Normal(y_{in}; \\tilde{\\mu}_{in}, \\beta^{-1})\n         - \\frac{1}{2} \\beta_i (w_i^2 \\tilde{k}_{gnn} + \\tilde{k}_{inn})\n         - \\frac{1}{2} \\trace \\left( w_i^2 \\S_g \\mat{\\Lambda}_{gn} + \\S_i \\mat{\\Lambda}_{in} \\right)\n\\right) \\\\\n&- \\left( \\KL[q(\\ug) || p(\\ug)] + \\sum_{i=1}^P \\KL[q(\\u_i) || p(\\u_i)] \\right) \\define \\calL,\n\\end{align}\nwhere \n%TODO \\Lambda_gn depends on the output i so need a better notation\n\\begin{align}\n\\tilde{\\mu}_{in}\n&= w_i k_g(\\x_n, \\Zg)k_g(\\Zg,\\Zg)^{-1}\\m_g + k_i(\\x_n, \\Zi)k_i(\\Zi,\\Zi)^{-1}\\m_i \\\\\n\\mat{\\Lambda}_{gn}\n&= \\beta_i k_g(\\Zg,\\Zg)^{-1} k_g(\\Zg, \\x_n) k_g(\\x_n, \\Zg) k_g(\\Zg,\\Zg)^{-1} \\\\\n\\mat{\\Lambda}_{in}\n&= \\beta_i k_i(\\Zi,\\Zi)^{-1} k_i(\\Zi, \\x_n) k_i(\\x_n, \\Zg) k_i(\\Zg,\\Zg)^{-1}.\n\\end{align}\n\n\\noindent Again, this clearly shows that this model generalizes the standard GP regression. This can be verified by setting $P = 1$, $w_i = 1$ and $h_i(\\x) = 0$ to recover the bound in Hensman et al.\nDue to the decomposition of this bound, we can use stochastic gradient descent to learn the variational parameters.\n\n\\subsubsection{Variational Parameters Derivatives}\n\\newcommand{\\oi}{\\vec{o}_i}\n% some notation\nBefore diving into the details, we first define the indexing operator of a matrix: $\\B(\\vec{r},\\vec{c})$ extracts the submatrix in rows $\\vec{r}$ and columns $\\vec{c}$ of $\\B$.\nTo index all columns we use $\\B(\\vec{r},:)$ and similarly for all rows $\\B(:,\\vec{c})$.\nReaders familiar with this operator will recognize that this is the MATLAB indexing operator.\n\nThe optimal posteriors are found by setting the gradients of the lowerbound $\\calL$ wrt to the parameters of $q(\\ug)$ and $q(\\u_i)$.\nRecall that in the model, different outputs can be observed at different inputs (i.e. the case of missing values).\nLet $\\oi$ be the indice of the observed inputs of the output dimension $i$.\nWe denote its set of observed inputs and targets as: $\\X_i = \\X(\\oi,:)$ and $\\y_i = y_{i}(\\oi)$.\n\n\\noindent As a function of the parameters of $q(\\ug)$, the lowerbound $\\calL$ is:\n\\begin{align}\n\\nonumber\n\\calL_g \\define&\n \\sum_{i=1}^P \\log \\Normal(\\y_i; w_i \\A_g(\\oi,:) \\m_g + \\A_i \\m_i, \\beta_i^{-1} \\I)  \\\\\n &- \\frac{1}{2} \\sum_{i=1}^P \\bigg(\\beta_i \\trace w_i^2 \\tilde{\\K}_g(\\oi,\\oi) \n + \\beta_i \\trace w_i^2 \\S_g \\A_g(\\oi,:)^T \\A_g(\\oi,:) \\bigg)\n \\\\\n &- \\frac{1}{2} \\log |k_g(\\Zg,\\Zg) \\S_g^{-1}| -\\frac{1}{2} \\trace k_g(\\Zg,\\Zg)^{-1} (\\m_g \\m_g^T + \\S_g) ,\n\\end{align}\nwhere $\\A_g = k_g(\\X,\\Z_g)k_g(\\Z_g,\\Z_g)^{-1}$, which gives $\\A_g(\\oi,:) = k_g(\\X_i,\\Zg) k_g(\\Z_g,\\Z_g)^{-1}$, and  \n$\\A_i = k_i(\\X_i,\\Z_i)k_i(\\Z_i,\\Z_i)^{-1}$. \\\\\n\n%------------------------------------------\n% derivatives of q(u_g)\n\\noindent The derivatives of $\\calL_q$ wrt $\\m_g$ and $\\S_g$ are given by:\n\\begin{align}\n\\deriv{\\calL_g}{\\m_g}\n& = \\sum_{i=1}^P \\beta_i w_i \\A_g(\\oi,:)^T (\\y_i - \\A_i \\m_i) - \\left[k_g(\\Zg,\\Zg)^{-1} + \\sum_{i=1}^P \\beta_i w_i^2 \\A_g(\\oi,:)^T \\A_g(\\oi,:) \\right] \\m_g \\\\\n\\deriv{\\calL_g}{\\S_g} \n&= \\frac{1}{2} \\S_g^{-1} - \\frac{1}{2} \\left[ k_g(\\Zg,\\Zg)^{-1} + \\sum_{i=1}^P \\beta_i w_i^2 \\A_g(\\oi,:)^T \\A_g(\\oi,:) \\right].\n\\end{align}\n\n%-------------------------------------------\n%  derivatives of q(u_i)\n\\noindent As a function of the parameters of $q(\\u_i)$, the lowerbound $\\calL$ is:\n\\begin{align}\n\\nonumber\n\\calL_i \\define&\n \\log \\Normal(\\y_i; w_i \\A_g(\\oi,:) \\m_g + \\A_i \\m_i, \\beta_i^{-1} \\I)\n - \\frac{1}{2} \\beta_i \\trace \\tilde{\\K}_i(\\oi,\\oi)\n - \\frac{1}{2} \\beta_i \\trace \\S_i \\A_i^T \\A_i\n \\\\\n  &- \\frac{1}{2} \\log |k_i(\\Zi,\\Zi) \\S_i^{-1}| -\\frac{1}{2} \\trace k_i(\\Zi,\\Zi)^{-1} (\\m_i \\m_i^T + \\S_i) ,\n\\end{align}\n\n\\noindent The derivatives of $\\calL_i$ wrt $\\m_i$ and $\\S_i$ are given by:\n\\begin{align}\n\\deriv{\\calL_i}{\\m_i}\n& = \\beta_i \\A_i^T (\\y_i - w_i \\A_g(\\oi,:)^T \\m_g) - \\left[k_i(\\Zi,\\Zi)^{-1} +  \\beta_i \\A_i^T \\A_i \\right] \\m_i \\\\\n\\deriv{\\calL_i}{\\S_i} \n&= \\frac{1}{2} \\S_i^{-1} - \\frac{1}{2} \\left[ k_i(\\Zi,\\Zi)^{-1} + \\beta_i \\A_i^T \\A_i \\right].\n\\end{align}\n\n% comment on computation\n\\noindent It can be seen that the derivatives of the parameters of $q(\\u_i)$ only involve the observations of the output dimension $i$.\nThe derivatives of the parameters of $q(\\u_g)$ involve the observations across all output dimensions but decompose as a sum of contributions from individual outputs.\nTherefore, computation of the derivatives (and hence the update equations) can be distributed or parallelized easily.\nThis attractive property allows the model to scale to a very large number of outputs.\n\n%\\subsubsection{Update Equations}\n% and comment on the intuition of the update equations: e.g. y(x) - g(x) for h(x) \n\\subsection{Prediction}\nThe predictive distribution of the $i$-th output for a test input $\\x_*$ is \n\\begin{align}\np(\\fstar | \\y, \\x_*) = \\int \\Normal(\\fstar; w_i g_* + h_{i*}, 0) p(g_* | \\y, \\x_*) p(h_{i*} | \\y, \\x_*) \\der g_* \\der h_{i*},\n\\end{align}\nwhere $p(g_* | \\y, \\x_*) = \\Normal(g_*; \\mu_{g*}, s_{g*})$ and $p(h_{i*} | \\y, \\x_*) = p(h_{i*}; \\mu_{i*}, s_{i*})$ are the predictive distributions of the sparse GPs as given in \\ref{eq:sorprediction}.\nTherefore we have:\n\\begin{align}\np(\\fstar | \\y, \\x_*) = \\Normal(\\fstar; w_i \\mu_{g*} + \\mu_{i*}, w_i^2 s_{g*} + s_{i*}). \n\\end{align}\n\n%\\begin{linenomath}\n%\\begin{align}\n%\\sum_{i,h} \\lambda_i \\lambda_h cov [f(\\x, \\x')]\n%&= \\sum_{i,h}   \\sum_{j,j'} \\lambda_i g(\\x_i - \\vs_j) k(\\vs_j, \\vs_{j'}) \\lambda_h g(\\x_h - \\vs_j') \\\\\n%\\end{align}\n%\\end{linenomath}\n\n\\section{Toy Experiments}\nThe first toy experiment uses two identical outputs which are noisy version of the same version plus some noise: $y_1(x) = sin(x) + \\epsilon$ and $y_2(x) = sin(x) + \\epsilon$, $\\epsilon \\sim \\Normal(0,0.01)$.\nIn this case the shared function $g(x)$ is $sin(x)$ and the independent processes $h_1(x)$ and $h_2(x)$ are just white noises.\nEach output has missing values in one region of the input space.\nThe predictive distributions of the multiple-gp model compared to that of independent gps are shown in \\ref{fig4}.\n\n\\noindent The second toy experiment uses similar setting as the first one, except that now $y_1(x) = sin(x) + \\epsilon$ and $y_2(x) = -sin(x) + \\epsilon$. \nIn this case the shared function is still $g(x) = sin(x)$, but the weights should be opposite i.e. $w_1 = 1$ and $w_2 = 1$.\nThe learning procedure was indeed able to recovered this relation and learned that $w_1 = 1.2$ and $w_2 = -1.3$.\nThe predictive distributions are shown in \\ref{fig5}.\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{cc}\n\\includegraphics[scale=0.5]{figures/ssvi-y1.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi-svi1.eps} \\\\\n\\includegraphics[scale=0.5]{figures/ssvi-y2.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi-svi2.eps} \\\\\n\\multicolumn{2}{c}{\\includegraphics[scale=0.5]{figures/ssvi-y1byg.eps} }\n\\end{tabular}\n\\label{fig4}\n\\caption{Predictive distributions of the multipe-output gps (left column) and independent gps (right column) for the first toy example. The predictive distribution by $g(x)$ for $y_1(x)$ is shown in the bottom figure.}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{cc}\n\\includegraphics[scale=0.5]{figures/ssvi2-y1.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi2-svi1.eps} \\\\\n\\includegraphics[scale=0.5]{figures/ssvi2-y2.eps} &\n\\includegraphics[scale=0.5]{figures/ssvi2-svi2.eps} \\\\\n\\multicolumn{2}{c}{\\includegraphics[scale=0.5]{figures/ssvi-y1byg.eps} }\n\\end{tabular}\n\\label{fig5}\n\\caption{Predictive distributions of the multipe-output gps (left column) and independent gps (right column) for the second toy experiment. The predictive distribution by $g(x)$ for $y_1(x)$ is shown in the bottom figure.}\n\\end{figure*}\n\n\\section{Appendix}\nHere we derive the gradients of the lower bound wrt the  hyperparameters.\nAs a template, consider the lower bound in Hensman et al (as a function of the hyperparameters):\n\\begin{align}\n\\nonumber\n\\calL\n=& \\log \\Normal(\\y; \\K_{NM} \\K_{MM}^{-1} \\m, \\beta^{-1}\\I)\n - \\frac{1}{2} \\beta \\trace \\tilde{\\K}\n - \\frac{1}{2} \\beta \\trace (\\S\\K_{MM}^{-1} \\K_{MN} \\K_{NM} \\K_{MM}^{-1}) \\\\  \\nonumber\n&- \\frac{1}{2} \\left( \\log |\\K_{MM}| + \\trace(\\K_{MM}^{-1}(\\m \\m^T + \\S)) \\right) \\\\ \\nonumber\n=& \\underbrace{\\log \\Normal(\\y; \\A \\m, \\beta^{-1}\\I)}_{\\calL_1}\n - \\underbrace{\\frac{1}{2} \\beta \\trace (\\K_{NN} - \\A\\K_{MN})}_{\\calL_2}\n - \\underbrace{\\frac{1}{2} \\beta \\trace (\\S\\A^T\\A)}_{\\calL_3} \\\\  \n&- \\underbrace{\\frac{1}{2} \\left( \\log |\\K_{MM}| + \\trace(\\K_{MM}^{-1}(\\m \\m^T + \\S)) \\right)}_{\\calL_4},\n\\end{align}\nwhere $\\A = \\K_{NM} \\K_{MM}^{-1}$.\nNotice that we have re-written the sum of individual terms in matrix form which will make the derivation and also computation easier.\n\n\\subsection{Derivative of the Noise Hyperparameter}\nThe derivative of the noise hyperparameter $\\beta$ is easily computed as:\n\\begin{align}\n\\deriv{\\calL}{\\beta} = \\frac{N}{2\\beta} - \\frac{1}{2} (\\y - \\A\\m)^T (\\y - \\A\\m) - \\frac{\\calL_2}{\\beta} - \\frac{\\calL_3}{\\beta}.\n\\end{align}\n\\subsection{Derivatives of the Covariance Hyperparameters}  \nTo simplify the math, we utilize the matrix $\\A$ defined above.\nFirstly, the derivative of $\\A$ wrt a covariance hyperparameter $t$ is given by:\n\\begin{align}\n\\deriv{\\A}{t} = \\left(\\deriv{\\K_{NM}}{t} - \\A \\deriv{\\K_{MM}}{t}\\right)\\K_{MM}^{-1}.\n\\end{align}\nThe derivatives of $\\calL_1, \\calL_2, \\calL_3 \\text{ and } \\calL_4$ are thus given by:\n\\begin{align}\n\\deriv{\\calL_1}{t} &= \\beta (\\y - \\A\\m)^T \\deriv{\\A}{t} \\m \\\\\n\\deriv{\\calL_2}{t} &= \\frac{1}{2}\\beta \\trace \\left(\\deriv{\\K_{NN}}{t} - \\A \\deriv{\\K_{MN}}{t} - \\deriv{\\A}{t} \\K_{MN}\\right) \\\\\n\\deriv{\\calL_3}{t} &= \\beta \\trace \\left(\\A \\S \\deriv{\\A^T}{t} \\right) \\\\\n\\deriv{\\calL_4}{t} &= \\frac{1}{2}  \\trace \\left(\\K_{MM}^{-1} \\deriv{ \\K_{MM}}{t}\\right) - \\frac{1}{2} \\trace \\left(\\K_{MM}^{-1} \\deriv{\\K_{MM}}{t} \\K_{MM}^{-1} (\\m \\m^T + \\S) \\right) \n\\end{align}\nThe derivatives are then computed by taking the derivatives of the covariance matrices $\\K_{NN} (\\text{the diagonal only}), \\K_{NM} \\text{ and }  \\K_{MM}$, hence the covariance function, wrt the hyperparameters. \n\n\\subsection{Derivatives of the Inducing Inputs}\nTo compute the derivatives of $\\calL$ wrt the inducing inputs, first notice that $\\Z = \\{\\z_m\\}_{m=1}^M$ are also parameters of the covariance matrices $\\K_{NM}$ and $\\K_{MM}$.\nHence the derivative wrt a single dimension of an inducing input, i.e. $z_{mj}$, is the same as that of $\\deriv{ \\calL}{t}$.\n\n%Since $MD$ parameters are needed for the inducing inputs, it appears that the derivatives of all inducing inputs would require $\\calO(MD \\times M^3)$ in computation.\n%However, this complexity can actually be reduced to $\\calO(DM^3)$ using the following lemma. \\\\\n%\n%\\noindent \\textbf{Lemma} Let $A, B$ be two matrices of size $N \\times M$ and $M \\times N$, respectively. Furthermore, $B$ has the property that only one of its rows or columns is non-zero. The complexity of $\\trace(AB)$ is only $\\calO(N)$. \\\\\n%\n%\\noindent \\textbf{Proof} Let $m <= M$ be the non-zero row of $B$. We have\n%\\begin{align}\n%\\trace (AB) = \\sum_{i=1}^N \\sum_{j=1}^M A_{ij} B_{ji} = \\sum_{i=1}^N A_{im} B_{mi},\n%\\end{align}\n%which clearly takes $\\calO(N)$. It is easy to see that the lemma also holds when $B$ is symmetric and only one of its row and the corresponding column is non-zero. \\\\\n%\n%\\noindent To exploit the property in the Lemma, we re-write $\\frac{d \\calL_1}{dt}, \\frac{d \\calL_2}{dt}, \\frac{d \\calL_3}{dt}, \\frac{d \\calL_4}{dt}$ by expanding $\\frac{d\\A}{dt}$ (here $t = z_{mj}$):\n\n\\noindent We re-write $\\deriv{\\calL_1}{t}, \\deriv{\\calL_2}{t}, \\deriv{ \\calL_3}{t}, \\deriv{\\calL_4}{t}$ by expanding $\\deriv{\\A}{t}$ (here $t = z_{mj}$):\n\\begin{align}\n\\nonumber\n% dL1\n\\deriv{\\calL_1}{t}\n &= \\beta \\trace (\\y - \\A\\m)^T \\left(\\deriv{\\K_{NM}}{t} -  \\A \\deriv{ \\K_{MM}}{t}\\right)\\K_{MM}^{-1} \\m \\\\\n&= \\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\deriv{\\K_{NM}}{t} \n-\\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\A \\deriv{\\K_{MM}}{t} \\\\\n%dL2\n\\deriv{\\calL_2}{t}\n&= - \\beta \\trace \\A^T \\deriv{\\K_{NM}}{t}\n + \\frac{1}{2} \\beta \\trace \\A^T \\A \\deriv{\\K_{MM}}{t}  \\\\\n% dL3\n\\deriv{\\calL_3}{t}\n&= \\beta \\trace \\K_{MM}^{-1} \\S \\A^T \\deriv{\\K_{NM}}{t}\n - \\beta \\trace \\K_{MM}^{-1} \\S \\A^T \\A \\deriv{\\K_{MM}}{t}\\\\\n% dL4\n\\deriv{\\calL_4}{t}\n &= \\frac{1}{2}  \\trace \\K_{MM}^{-1} \\deriv{\\K_{MM}}{t}\n  - \\frac{1}{2} \\trace \\K_{MM}^{-1} (\\m \\m^T + \\S) \\K_{MM}^{-1} \\deriv{\\K_{MM}}{t} \n\\end{align}\nFrom the above equations we get,\n\\begin{align}\n\\deriv{\\calL}{t} = \\trace \\D_1 \\deriv{\\K_{NM}}{t} + \\trace \\D_2 \\deriv{ \\K_{MM}}{t},\n\\end{align}\nwhere \n\\begin{align}\n\\D_1 =& \\beta \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T\n + \\beta \\A^T\n - \\beta \\K_{MM}^{-1} \\S \\A^T \\\\ \\nonumber\n\\D_2 =& -\\beta \\trace \\K_{MM}^{-1} \\m (\\y - \\A\\m)^T \\A\n - \\frac{1}{2} \\beta \\A^T \\A\n  + \\beta \\K_{MM}^{-1} \\S \\A^T \\A\t \\\\ \n  &-\\frac{1}{2} \\K_{MM}^{-1} + \\frac{1}{2} \\K_{MM}^{-1} (\\m \\m^T + \\S) \\K_{MM}^{-1}\n\\end{align}\nNotice that $\\D_1$ and $\\D_2$ can be pre-computed with a cost of $\\calO(M^3)$ (or $\\calO(N_bM^2)$ if the minibatch size $N_b > M$).\nThe computational cost of taking derivatives of $MD$ inducing parameters is thus $\\calO(M^3 + MDM) = \\calO(M^3)$ as the cost of the two $\\trace$ operators is $\\calO(M)$ due to the fact that only $\\calO(M)$ elements of $\\deriv{\\K_{MM}}{t}$ or $\\deriv{\\K_{NM}}{t}$ are non-zero.\nThis fact can be further exploited to perform vectorized operation, for e.g. in Matlab, such that the iteration over all inducing inputs can be avoided.\n\n\\subsection{Analysis on Learning of the Inducing Inputs}\nIn this section we present some analysis on learning of the inducing inputs under the stochastic variational inference procedure on some toy problems.\nWe use three real-valued truth functions of scalar inputs: the first one was used in Snelson et al, the second one is a function $f(x) = \\sin(x) + \\cos(x)$, and the third one is a sample function generated from a GP with squared exponential with ARD covariance function with a lengthscale of 2 and signal variance of 1.\n\n\\noindent \\paragraph{Experimental Settings} We use gpsvi to optimize for \\textit{all} of the parameters in the model, i.e. the variational parameters of the posterior, the covariance hyperparameters, the noise hyperparameter, and the inducing inputs.\nFor the hyperparameters, we use a momentum of $0.9$ and a fixed learn rate of $1e-5$. \nFor the variational parameters, we use a learn rate of $0.01$ (no momentum was used).\nWe vary the learn rate of the inducing inputs from $1e{-2}$ to $1e{-6}$.\nUsing momentum for the inducing inputs does not seem to have much effects.\nThe maximum number of iterations is 500, the batch size 5, and the number of inducing values 10.\n\n% effect of learn rate on inducing inputs\n\\noindent \\paragraph{Effects of the Learn Rates }\nIn Figure \\ref{fig1}, \\ref{fig2}, and \\ref{fig3}, we show the lower bounds, predictive distributions, and the learned inducing inputs using stochastic variational inference with varying learn rates for the inducing inputs.\nWe also show the results with FITC for comparison.\nIt can be seen from the figures that, as typical in stochastic optimization, the behavior of GPSVI is very sensitive to the learn rate.\nIn particular, when the rate is slow e.g. $1e{-5}$, almost no progress was made in learning the inducing inputs.\nHowever, when the rate increases to e.g. $1e{-3}$, the inducing inputs are spread out more evenly in the input space compared to the initial locations.\nAlthough not shown the in figures, when the learn rate is too large, e.g. $1e{-02}$, the inducing inputs may spread to regions far outside of the training intervals.\nAn example of this phenomenon can be observed in the top left figure in Figure \\ref{fig1}.\nThe learn rates also affect the evidence lower bound which seems to wiggle more compared to not learning the inducing inputs.\nThe predictive distributions are sensible particularly because the toy functions exhibit sparsity and are easy to learn.  \\\\\n\n\\noindent The results of this qualitative analysis do not seem to suggest that learning of the inducing inputs does not work in GPSVI.\nIts effectiveness perhaps rests upon empirical performance on real datasets.\n\n\\noindent \\paragraph{The Noise Parameter} It seems harder to set the initial value and the learning rate of the noise parameter compared to standard GP. \nWhile a large range of values of noise can be used in standard gp or fitc (e.g. 0.5), a very small value of noise $1e{-02}$, which is the true noise, is required for gpsvi to work well.\nIt appears that an adaptive learning rate may be required for the noise parameter.\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func1-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func1-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the first function. Top row: GPSVI with different learning rates (the rates decreases from left to right). Bottom row: FITC. Magenta dots : training points. Solid blue line: predictive mean. Grey-shaded area and solid black lines: two standard deviations of the predictive distributions. Black (+) crosses: initial locations of inducing inputs. Magenta (+) crosses: learned locations of inducing inputs.  Middle row: the evidence lower bound of gpsvi vs. iteration.}\n\\label{fig1}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func2-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func2-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the second function. The legends are same as in Figure 1.}\n\\label{fig2}\n\\end{figure*}\n\n\\begin{figure*}\n\\centering\n\\begin{tabular}{ccc}\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-03.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-04.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-05.eps} \\\\\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-03-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-04-bound.eps} &\n\\includegraphics[scale=0.3]{figures/func3-svi-lrate1e-05-bound.eps} \\\\ \n(a) learn rate = $1e{-3}$ & (b) learn rate = $1e{-4}$ & (c) learn rate = $1e{-5}$ \\\\\n\\multicolumn{3}{c}{\\includegraphics[scale=0.4]{figures/func3-fitc.eps}}\n\\end{tabular}\n\\caption{Predictive distributions and learned inducing inputs by GPSVI and FITC for the third function. The legends are same as in Figure 1.}\n\\label{fig3}\n\\end{figure*}\n\n\\end{document}\n", "meta": {"hexsha": "2c89e7b8578911bf9495a40e76817d3aa5209632", "size": 30018, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "note/old_paper.tex", "max_stars_repo_name": "fkopsaf/cogp", "max_stars_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2015-05-28T13:46:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T11:02:08.000Z", "max_issues_repo_path": "note/old_paper.tex", "max_issues_repo_name": "fkopsaf/cogp", "max_issues_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-07-30T08:52:36.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-04T01:44:21.000Z", "max_forks_repo_path": "note/old_paper.tex", "max_forks_repo_name": "trungngv/cogp", "max_forks_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2016-04-03T03:18:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-23T13:28:55.000Z", "avg_line_length": 59.0905511811, "max_line_length": 550, "alphanum_fraction": 0.6668998601, "num_tokens": 10637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.424280265810289}}
{"text": "Make sure the \\mintinline[]{text}{rico} directory is in your Matlab\npath.\n\n\\begin{minted}[]{matlab}\naddpath('../rico')\n\\end{minted}\n\n\\hypertarget{phasor-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{phasor}\ndocs}{ docs}}\\label{phasor-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/phasor.m}\n\n\\hypertarget{tf_factor-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{tf_factor}\ndocs}{ docs}}\\label{tf_factor-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/tf_factor.m}\n\n\\hypertarget{usage-and-examples}{%\n\\subsection{Usage and examples}\\label{usage-and-examples}}\n\n\\hypertarget{bode_multi-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{bode_multi}\ndocs}{ docs}}\\label{bode_multi-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/bode_multi.m}\n\n\\hypertarget{usage-and-examples-1}{%\n\\subsection{Usage and examples}\\label{usage-and-examples-1}}\n\n\\begin{minted}[]{matlab}\nsys = tf([5,3,5],[1,6,1,20])\n\\end{minted}\n\n\\begin{minted}[]{text}\nsys =\n \n    5 s^2 + 3 s + 5\n  --------------------\n  s^3 + 6 s^2 + s + 20\n \nContinuous-time transfer function.\n\\end{minted}\n\n\\begin{minted}[]{matlab}\nsys_a = tf_factor(sys)\n\\end{minted}\n\n\\begin{minted}[]{text}\nsys_a(:,:,1,1) =\n \n          3.155\n  ----------------------\n  s^2 - 0.3399 s + 3.155\n \n\nsys_a(:,:,2,1) =\n \n    6.34\n  --------\n  s + 6.34\n \n\nsys_a(:,:,3,1) =\n \n  s^2 + 0.6 s + 1\n \n\nsys_a(:,:,4,1) =\n \n  0.25\n \n4x1 array of continuous-time transfer functions.\n\\end{minted}\n\n\\begin{minted}[]{matlab}\n% [f,ax_mag,ax_phase] = bode_multi(G); % get axis handles\nf = bode_multi(sys_a);\n\nhgsave(f,'figures/temp');\n\\end{minted}\n\n\\begin{figure}\n\\centering\n\\input{figures/bode_multi_docs.tex}\n\\caption{a bode multi example output.}\n\\label{fig:bode_multi_docs}\n\\end{figure}\n\n\\hypertarget{pole-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{pole}\ndocs}{ docs}}\\label{pole-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/pole.m}\n\n\\hypertarget{usage-and-examples-2}{%\n\\subsection{Usage and examples}\\label{usage-and-examples-2}}\n\n\\hypertarget{zero-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{zero}\ndocs}{ docs}}\\label{zero-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/zero.m}\n\n\\hypertarget{usage-and-examples-3}{%\n\\subsection{Usage and examples}\\label{usage-and-examples-3}}\n\n\\hypertarget{tf2latex-docs}{%\n\\section{\\texorpdfstring{\\mintinline[]{text}{tf2latex}\ndocs}{ docs}}\\label{tf2latex-docs}}\n\nThe following is the source code.\n\n\\inputminted{matlab}{../rico/tf2latex.m}\n\n\\hypertarget{usage-and-examples-4}{%\n\\subsection{Usage and examples}\\label{usage-and-examples-4}}\n", "meta": {"hexsha": "da66cb719e31265beac5cbef1e5ca3bb00c36649", "size": 2652, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/_source_and_docs.tex", "max_stars_repo_name": "ricopicone/matlab-rico", "max_stars_repo_head_hexsha": "46dad04d33b18e4e5d0c85c4504ffbf0dc91a1dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-28T21:47:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T17:26:52.000Z", "max_issues_repo_path": "docs/_source_and_docs.tex", "max_issues_repo_name": "ricopicone/matlab-rico", "max_issues_repo_head_hexsha": "46dad04d33b18e4e5d0c85c4504ffbf0dc91a1dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/_source_and_docs.tex", "max_forks_repo_name": "ricopicone/matlab-rico", "max_forks_repo_head_hexsha": "46dad04d33b18e4e5d0c85c4504ffbf0dc91a1dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.5581395349, "max_line_length": 67, "alphanum_fraction": 0.6866515837, "num_tokens": 882, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.4242802620489192}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{March 14, 2014}\n\\maketitle\nvery interesting use of laplace transforms. straight from the text\n\\section*{lesson 14 page 122}\nduhamel's principle.\n\n\\subsubsection*{easy problem}\n\\begin{align*}\n  \\text{PDE}&&w_t&=w_{xx}\\\\\n  \\text{BC}&&w(0,t)&=0\\\\\n  &&w(1,t)&=1\\\\\n  \\text{IC}&&w(x,0)&=0\n\\end{align*}\nsubsubsection*{hard problem}\n\\begin{align*}\n  &&&&&&z&=u+v\\\\\n  \\text{PDE}&&u_t&=u_{xx}&v_t&=v_{xx}\n  &z_t&=z_{xx}\\\\\n  \\text{BC}&&u(0,t)&=0&v(0,t)&=0\n  &z(0,t)&=0\\\\\n  &&u(1,t)&=g(t)&v(1,t)&=0\n  &z(1,t)&=g(t)\\\\\n  \\text{IC}&&u(x,0)&=0&v(x,0)&=\\phi(x)\n  &z(x,0)&=\\phi(x)\\\\\n\\end{align*}\n$\\mathcal{L}$ with respect to time\n\\begin{align*}\n  sW(x,s)-\\underbrace{w(x,0)}_{\\to 0}&=W_{xx}(x,s)\\\\\n  W_{xx}-SW&=0\\text{ on }0<x<1&U_{xx}-sU&=0\\\\\n  W(0,s)&=0 \\text{ and } W(1,s)=\\frac{1}{s}&U(0,s)&=0 \\text{ and }U(1,s)=G(s)\\\\\n  W&=c_1\\sinh(\\sqrt{s}x)+c_2\\cosh(\\sqrt{s}x)\\\\\n  \\frac{\\mathrm{d}^2y}{\\mathrm{d}x^2}-sy&=0&y&=e^{rx}\\\\\n  &&r^2-s&=0&r&=\\pm\\sqrt{s}\\\\\n  y&=a_1e^{-\\sqrt{s}x}+a_2e^{\\sqrt{s}x}\\\\\n  \\sinh(z)&=\\frac{1}{2}(e^z-e^{-z})\\\\\n  \\cosh(z)&=\\frac{1}{2}(e^z+e^{-z})\\\\\n  W&=c_1\\sinh(\\sqrt{s}x)\\\\\n  \\frac{1}{s}&=c_1\\sinh(\\sqrt{s})\\\\\n  W(x,s)&=\\frac{1}{s}\\frac{\\sinh(\\sqrt{s}x)}{\\cosh(\\sqrt{s})}\\\\\n  U&=c_1\\sinh(\\sqrt{s}x)\\\\\n  G(s)&=c_1\\sinh(\\sqrt{s})\\\\\n  U(x,s)&=G(s)\\frac{\\sinh(\\sqrt{s}x}{\\sinh(\\sqrt{s})}=G(s)sW(x,s)\\\\\n  \\text{note: }sW(x,s)-\\underbrace{w(x,0)}_{\\to 0}&=\\mathcal{L}\\{w_t\\}\\\\\n  u(x,t)&=\\int_0^t{g(t-u)w_t(x,u)\\,\\mathrm{d}u}\\\\\n  &=g(t-u)w(x,u)\\mid_0^t-\\int_0^t{(-g'(t-u)w(x,u)\\,\\mathrm{d}u}\n  \\intertext{page 107 (124)}\n  w(x,t)&=x+\\frac{2}{\\pi}\\sum\\limits_{n=1}^\\infty{\\frac{(-1)^n}{n}e^{-(n\\pi)^2t}\\sin(n\\pi x)}\\text{ from eigenfunction expansion}\n\\end{align*}\n\nhomework \\#27\nlesson 14, exercise 4 $g(t)=\\sin(t)$. take $\\alpha^2=1$. due friday, 28 march.\n\\end{document}\n", "meta": {"hexsha": "97b6eae7cd11b998d71e0913af304aeb4fb7655a", "size": 1996, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "partial differential equations/pde-notes-2014-03-14.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "partial differential equations/pde-notes-2014-03-14.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "partial differential equations/pde-notes-2014-03-14.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1875, "max_line_length": 129, "alphanum_fraction": 0.5671342685, "num_tokens": 1013, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4242802582875495}}
{"text": "\\section{Estimator output}\n\\subsection{Estimator definition}\nFor simplicity, consider a local property $O(\\bs{R})$, where $\\bs{R}$ is the collection of all particle coordinates. An \\textit{estimator} for $O(\\bs{R}) $ is a weighted average over walkers:\n\\begin{align}\nE[O] = \\left(\\sum\\limits_{i=1}^{N^{tot}_{walker}} w_i O(\\bs{R}_i) \\right) / \\left( \\sum \\limits_{i=1}^{N^{tot}_{walker}} w_i \\right). \\label{eq:estimator}\n\\end{align}\n$N^{tot}_{walker}$ is the total number of walkers collected in the entire simulation. Notice that $N^{tot}_{walker}$ is typically far larger than the number of walkers held in memory at any given simulation step. $w_i$ is the weight of walker $i$.\n\nIn a VMC simulation, the weight of every walker is 1.0. Further, the number of walkers is constant at each step. Therefore, Equation~\\ref{eq:estimator} simplifies to\n\\begin{align}\nE_{VMC}[O] = \\frac{1}{N_{step}N_{walker}^{ensemble}} \\sum_{s,e} O(\\bs{R}_{s,e})\\:.\n\\end{align}\nEach walker $\\bs{R}_{s,e}$ is labeled by \\textit{step index} s and \\textit{ensemble index} e.\n\nIn a DMC simulation, the weight of each walker is different and may change from step to step. Further, the ensemble size varies from step to step. Therefore, Equation~\\ref{eq:estimator} simplifies to\n\\begin{align}\nE_{DMC}[O] = \\frac{1}{N_{step}} \\sum_{s} \\left\\{ \\left(\\sum_e w_{s,e} O(\\bs{R}_{s,e})  \\right) / \\left( \\sum \\limits_{e} w_{s,e} \\right)  \\right\\}\\:.\n\\end{align}\n\nWe will refer to the average in the $\\{\\}$ as \\textit{ensemble average} and to the remaining averages as \\textit{block average}. The process of calculating $O(\\bs{R})$ is \\textit{evaluate}.\n\n\\subsection{Class relations}\nA large number of classes are involved in the estimator collection process. They often have misleading class or method names. Check out the document gotchas in the following list:\n\\begin{enumerate}\n\\item \\icode{EstimatorManager} is an unused copy of \\icode{EstimatorManagerBase}. \\icode{EstimatorManagerBase} is the class used in the QMC drivers. (PR \\#371 explains this.)\n\\item \\icode{EstimatorManagerBase::Estimators} is completely different from \\icode{QMCDriver::Estimators}, which is subtly different from \\icode{OperatorBase::Estimators}. The first is a list of pointers to \\icode{ScalarEstimatorBase}. The second is the master estimator (one per MPI group). The third is the slave estimator that exists one per OpenMP thread.\n\\item \\icode{QMCHamiltonian} is NOT a parent class of \\icode{OperatorBase}. Instead, \\icode{QMCHamiltonian} owns two lists of \\icode{OperatorBase} named \\icode{H} and \\icode{auxH}.\n\\item \\icode{QMCDriver::H} is NOT the same as \\icode{QMCHamiltonian::H}. The first is a pointer to a \\icode{QMCHamiltonian}. \\icode{QMCHamiltonian::H} is a list.\n\\item \\icode{EstimatorManager::stopBlock(std::vector)} is completely different from \\icode{EstimatorManager::}\n\\icode{stopBlock(RealType)}, which is the same as \\icode{stopBlock(RealType, true)} but that is subtly different from \\icode{stopBlock(RealType, false)}. The first three methods are intended to be called by the master estimator, which exists one per MPI group. The last method is intended to be called by the slave estimator, which exists one per OpenMP thread.\n\\end{enumerate}\n\n\\subsection{Estimator output stages}\n%In QMCPACK, evaluation is done by \\icode{OperatorBase}; ensemble average is done either by a ``CloneDriver'' (e.g. \\icode{VMCSingleOMP}, \\icode{DMCOMP}) or \\icode{ScalarEstimatorBase}; block average is done by \\icode{ScalarEstimatorBase} or \\icode{EstimatorManagerBase}. Walkers can be accessed by ``CloneDriver'' and \\icode{OperatorBase} but not by \\icode{EstimatorManagerBase} or \\icode{ScalarEstimatorBase}. Output files can be accessed by the latter two classes but not the former two. Therefore, in order to output estimators to file, data must be transferred from \\textit{evaluate} classes to \\textit{average} classes.\n\nEstimators take four conceptual stages to propagate to the output files: evaluate, load ensemble, unload ensemble, and collect. They are easier to understand in reverse order.\n\n\\subsubsection{Collect stage}\nFile output is performed by the master \\icode{EstimatorManager} owned by \\icode{QMCDriver}. The first 8+ entries in \\icode{EstimatorManagerBase::AverageCache} will be written to \\icode{scalar.dat}. The remaining entries in \\icode{AverageCache} will be written to \\icode{stat.h5}. File writing is triggered by \\icode{EstimatorManagerBase}\\\\ \\icode{::collectBlockAverages} inside \\icode{EstimatorManagerBase::stopBlock}.\n\n\\begin{lstlisting}\n// In EstimatorManagerBase.cpp::collectBlockAverages\n  if(Archive)\n  {\n    *Archive << std::setw(10) << RecordCount;\n    int maxobjs=std::min(BlockAverages.size(),max4ascii);\n    for(int j=0; j<maxobjs; j++)\n      *Archive << std::setw(FieldWidth) << AverageCache[j];\n    for(int j=0; j<PropertyCache.size(); j++)\n      *Archive << std::setw(FieldWidth) << PropertyCache[j];\n    *Archive << std::endl;\n    for(int o=0; o<h5desc.size(); ++o)\n      h5desc[o]->write(AverageCache.data(),SquaredAverageCache.data());\n    H5Fflush(h_file,H5F_SCOPE_LOCAL);\n  }\n\\end{lstlisting}\n\n\\icode{EstimatorManagerBase::collectBlockAverages} is triggered from the master-thread estimator via either \\icode{stopBlock(std::vector)} or \\icode{stopBlock(RealType, true)}. Notice that file writing is NOT triggered by the slave-thread estimator method \\icode{stopBlock(RealType, false)}.\n\n\\begin{lstlisting}\n// In EstimatorManagerBase.cpp\nvoid EstimatorManagerBase::stopBlock(RealType accept, bool collectall)\n{\n  //take block averages and update properties per block\n  PropertyCache[weightInd]=BlockWeight;\n  PropertyCache[cpuInd] = MyTimer.elapsed();\n  PropertyCache[acceptInd] = accept;\n  for(int i=0; i<Estimators.size(); i++)\n    Estimators[i]->takeBlockAverage(AverageCache.begin(),SquaredAverageCache.begin());\n  if(Collectables)\n  { \n    Collectables->takeBlockAverage(AverageCache.begin(),SquaredAverageCache.begin());\n  }\n  if(collectall)\n    collectBlockAverages(1);\n}\n\\end{lstlisting}\n\n\\begin{lstlisting}\n// In ScalarEstimatorBase.h\ntemplate<typename IT>\ninline void takeBlockAverage(IT first, IT first_sq)\n{\n  first += FirstIndex;\n  first_sq += FirstIndex;\n  for(int i=0; i<scalars.size(); i++)\n  {\n    *first++ = scalars[i].mean();\n    *first_sq++ = scalars[i].mean2();\n    scalars_saved[i]=scalars[i]; //save current block\n    scalars[i].clear();\n  }\n}\n\\end{lstlisting}\n\nAt the collect stage, \\icode{ScalarEstimatorBase::scalars} must be populated with ensemble-averaged data. Two derived classes of \\icode{ScalarEstimatorBase} are crucial: \\icode{LocalEnergyEstimator} will carry \\icode{Properties}, where as \\icode{CollectablesEstimator} will carry \\icode{Collectables}.\n\n\\subsubsection{Unload ensemble stage}\n\\icode{LocalEnergyEstimator::scalars} are populated by\n\\icode{ScalarEstimatorBase::accumulate}, whereas\n\\icode{CollectablesEstimator::scalars} are populated by\n\\icode{CollectablesEstimator::} \\icode{accumulate_all}. Both\naccumulate methods are triggered by\n\\icode{EstimatorManagerBase::accumulate}. One confusing aspect about\nthe unload stage is that \\icode{EstimatorManagerBase::accumulate} has\na master and a slave call signature. A slave estimator such as\n\\icode{QMCUpdateBase::Estimators} should unload a subset of\nwalkers. Thus, the slave estimator should call\n\\icode{accumulate(W,it,it_end)}. However, the master estimator, such\nas \\icode{SimpleFixedNodeBranch::myEstimator}, should unload data from\nthe entire walker ensemble. This is achieved by calling\n\\icode{accumulate(W)}.\n\n\\begin{lstlisting}\nvoid EstimatorManagerBase::accumulate(MCWalkerConfiguration& W)\n{ // intended to be called by master estimator only\n  BlockWeight += W.getActiveWalkers();\n  RealType norm=1.0/W.getGlobalNumWalkers();\n  for(int i=0; i< Estimators.size(); i++)\n    Estimators[i]->accumulate(W,W.begin(),W.end(),norm);\n  if(Collectables)//collectables are normalized by QMC drivers\n    Collectables->accumulate_all(W.Collectables,1.0);\n}\n\\end{lstlisting}\n\n\\begin{lstlisting}\nvoid EstimatorManagerBase::accumulate(MCWalkerConfiguration& W\n , MCWalkerConfiguration::iterator it\n , MCWalkerConfiguration::iterator it_end)\n{ // intended to be called slaveEstimator only\n  BlockWeight += it_end-it;\n  RealType norm=1.0/W.getGlobalNumWalkers();\n  for(int i=0; i< Estimators.size(); i++)\n    Estimators[i]->accumulate(W,it,it_end,norm);\n  if(Collectables)\n    Collectables->accumulate_all(W.Collectables,1.0);\n}\n\\end{lstlisting}\n\n\\begin{lstlisting}\n// In LocalEnergyEstimator.h\ninline void accumulate(const Walker_t& awalker, RealType wgt)\n{ // ensemble average W.Properties\n  // expect ePtr to be W.Properties; expect wgt = 1/GlobalNumberOfWalkers\n  const RealType* restrict ePtr = awalker.getPropertyBase();\n  RealType wwght= wgt* awalker.Weight;\n  scalars[0](ePtr[LOCALENERGY],wwght);\n  scalars[1](ePtr[LOCALENERGY]*ePtr[LOCALENERGY],wwght);\n  scalars[2](ePtr[LOCALPOTENTIAL],wwght);\n  for(int target=3, source=FirstHamiltonian; target<scalars.size(); ++target, ++source)\n    scalars[target](ePtr[source],wwght);\n}\n\\end{lstlisting}\n\n\\begin{lstlisting}\n// In CollectablesEstimator.h\ninline void accumulate_all(const MCWalkerConfiguration::Buffer_t& data, RealType wgt)\n{ // ensemble average W.Collectables\n  // expect data to be W.Collectables; expect wgt = 1.0\n  for(int i=0; i<data.size(); ++i)\n    scalars[i](data[i], wgt);\n}\n\\end{lstlisting}\n\nAt the unload ensemble stage, the data structures \\icode{Properties} and \\icode{Collectables} must be populated by appropriately normalized values so that the ensemble average can be correctly taken. \\icode{QMCDriver} is responsible for the correct loading of data onto the walker ensemble.\n\n\\subsubsection{Load ensemble stage}\n\\icode{Properties} in the MC ensemble of walkers \\icode{QMCDriver::W} is populated by \\icode{QMCHamiltonian}\\\\ \\icode{::saveProperties}. The master \\icode{QMCHamiltonian::LocalEnergy}, \\icode{::KineticEnergy}, and \\icode{::Observables} must be properly populated at the end of the evaluate stage.\n\\begin{lstlisting}\n// In QMCHamiltonian.h\n  template<class IT>\n  inline\n  void saveProperty(IT first)\n  { // expect first to be W.Properties\n    first[LOCALPOTENTIAL]= LocalEnergy-KineticEnergy;\n    copy(Observables.begin(),Observables.end(),first+myIndex);\n  }\n\\end{lstlisting}\n\n\\icode{Collectables}'s load stage is combined with its evaluate stage.\n\n\\subsubsection{Evaluate stage}\n\nThe master \\icode{QMCHamiltonian::Observables} is populated by slave \\icode{OperatorBase}\n\\icode{::setObservables}. However, the call signature must be \\icode{OperatorBase::setObservables}\n\\icode{(QMCHamiltonian::} \\\\\\icode{Observables)}. This call signature is enforced by \\icode{QMCHamiltonian::evaluate} and \\icode{QMCHamiltonian::} \\\\\\icode{auxHevaluate}.\n\n\\begin{lstlisting}\n// In QMCHamiltonian.cpp\nQMCHamiltonian::Return_t\nQMCHamiltonian::evaluate(ParticleSet& P)\n{\n  LocalEnergy = 0.0;\n  for(int i=0; i<H.size(); ++i)\n  {\n    myTimers[i]->start();\n    LocalEnergy += H[i]->evaluate(P);\n    H[i]->setObservables(Observables);\n#if !defined(REMOVE_TRACEMANAGER)\n    H[i]->collect_scalar_traces();\n#endif\n    myTimers[i]->stop();\n    H[i]->setParticlePropertyList(P.PropertyList,myIndex);\n  }\n  KineticEnergy=H[0]->Value;\n  P.PropertyList[LOCALENERGY]=LocalEnergy;\n  P.PropertyList[LOCALPOTENTIAL]=LocalEnergy-KineticEnergy;\n  // auxHevaluate(P);\n  return LocalEnergy;\n}\n\\end{lstlisting}\n\n\\begin{lstlisting}\n// In QMCHamiltonian.cpp\nvoid QMCHamiltonian::auxHevaluate(ParticleSet& P, Walker_t& ThisWalker)\n{\n#if !defined(REMOVE_TRACEMANAGER)\n  collect_walker_traces(ThisWalker,P.current_step);\n#endif\n  for(int i=0; i<auxH.size(); ++i)\n  {\n    auxH[i]->setHistories(ThisWalker);\n    RealType sink = auxH[i]->evaluate(P);\n    auxH[i]->setObservables(Observables);\n#if !defined(REMOVE_TRACEMANAGER)\n    auxH[i]->collect_scalar_traces();\n#endif\n    auxH[i]->setParticlePropertyList(P.PropertyList,myIndex);\n  }\n}\n\\end{lstlisting}\n\n\\subsection{Estimator use cases}\n\n\\subsubsection{VMCSingleOMP pseudo code}\n\\begin{lstlisting}\nbool VMCSingleOMP::run()\n{\n  masterEstimator->start(nBlocks);\n  for (int ip=0; ip<NumThreads; ++ip)\n    Movers[ip]->startRun(nBlocks,false);  // slaveEstimator->start(blocks, record)\n  \n  do // block\n  {\n    #pragma omp parallel\n    {\n      Movers[ip]->startBlock(nSteps);  // slaveEstimator->startBlock(steps)\n      RealType cnorm = 1.0/static_cast<RealType>(wPerNode[ip+1]-wPerNode[ip]);\n      do // step\n      {\n        wClones[ip]->resetCollectables();\n        Movers[ip]->advanceWalkers(wit, wit_end, recompute);\n        wClones[ip]->Collectables *= cnorm;\n        Movers[ip]->accumulate(wit, wit_end);\n      } // end step\n      Movers[ip]->stopBlock(false);  // slaveEstimator->stopBlock(acc, false)\n    } // end omp\n    masterEstimator->stopBlock(estimatorClones);  // write files\n  } // end block\n  masterEstimator->stop(estimatorClones);\n}\n\\end{lstlisting}\n\n\\subsubsection{DMCOMP  pseudo code}\n\\begin{lstlisting}\nbool DMCOMP::run()\n{\n  masterEstimator->setCollectionMode(true);\n  \n  masterEstimator->start(nBlocks);\n  for(int ip=0; ip<NumThreads; ip++)\n    Movers[ip]->startRun(nBlocks,false);  // slaveEstimator->start(blocks, record)\n  \n  do // block\n  {\n    masterEstimator->startBlock(nSteps);\n    for(int ip=0; ip<NumThreads; ip++)\n      Movers[ip]->startBlock(nSteps);  // slaveEstimator->startBlock(steps)\n    \n    do // step\n    {\n      #pragma omp parallel\n      {\n      wClones[ip]->resetCollectables();\n      // advanceWalkers\n      } // end omp\n      \n      //branchEngine->branch\n      { // In WalkerControlMPI.cpp::branch\n      wgt_inv=WalkerController->NumContexts/WalkerController->EnsembleProperty.Weight;\n      walkers.Collectables *= wgt_inv;\n      slaveEstimator->accumulate(walkers);\n      }\n      masterEstimator->stopBlock(acc)  // write files\n    }  // end for step\n  }  // end for block\n  \n  masterEstimator->stop();\n}\n\\end{lstlisting}\n\n\\subsection{Summary}\n\nTwo ensemble-level data structures, \\icode{ParticleSet::Properties} and \\icode{::Collectables}, serve as intermediaries between evaluate classes and output classes to \\icode{scalar.dat} and \\icode{stat.h5}. \\icode{Properties} appears in both \\icode{scalar.dat} and \\icode{stat.h5}, whereas \\icode{Collectables} appears only in \\icode{stat.h5}. \\icode{Properties} is overwritten by \\icode{QMCHamiltonian::Observables} at the end of each step. \\icode{QMCHamiltonian::Observables} is filled upon call to \\icode{QMCHamiltonian::evaluate} and \\icode{::auxHevaluate}. \\icode{Collectables} is zeroed at the beginning of each step and accumulated upon call to \\icode{::auxHevaluate}.\n\nData are output to \\icode{scalar.dat} in four stages: evaluate, load, unload, and collect. In the evaluate stage, \\icode{QMCHamiltonian::Observables} is populated by a list of \\icode{OperatorBase}. In the load stage, \\icode{QMCHamiltonian::Observables} is transfered to \\icode{Properties} by \\icode{QMCDriver}. In the unload stage, \\icode{Properties} is copied to \\icode{LocalEnergyEstimator::scalars}. In the collect stage, \\icode{LocalEnergyEstimator::scalars} is block-averaged to \\icode{EstimatorManagerBase}\\\\ \\icode{::AverageCache} and dumped to file. For \\icode{Collectables}, the evaluate and load stages are combined in a call to \\icode{QMCHamiltonian::auxHevaluate}. In the unload stage, \\icode{Collectables} is copied to \\icode{CollectablesEstimator::scalars}. In the collect stage, \\icode{CollectablesEstimator}\\\\ \\icode{::scalars} is block-averaged to \\icode{EstimatorManagerBase::AverageCache} and dumped to file.\n\n\\subsection{Appendix: dmc.dat}\n\n\\begin{sloppypar}\nThere is an additional data structure, \\icode{ParticleSet::EnsembleProperty}, that is managed by \\icode{WalkerControlBase::EnsembleProperty} and directly dumped to \\icode{dmc.dat} via its own averaging procedure. \\icode{dmc.dat} is written by \\icode{WalkerControlBase::measureProperties}, which is called by \\icode{WalkerControlBase::branch}, which is called by \\icode{SimpleFixedNodeBranch}\\\\ \\icode{::branch}, for example.\n\\end{sloppypar}", "meta": {"hexsha": "1a5088223beec19bba9628eee7e5de87c36f6b54", "size": 15980, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/estimator_manager.tex", "max_stars_repo_name": "prckent/qmcpack", "max_stars_repo_head_hexsha": "127caf219ee99c2449b803821fcc8b1304b66ee1", "max_stars_repo_licenses": ["NCSA"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manual/estimator_manager.tex", "max_issues_repo_name": "prckent/qmcpack", "max_issues_repo_head_hexsha": "127caf219ee99c2449b803821fcc8b1304b66ee1", "max_issues_repo_licenses": ["NCSA"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/estimator_manager.tex", "max_forks_repo_name": "prckent/qmcpack", "max_forks_repo_head_hexsha": "127caf219ee99c2449b803821fcc8b1304b66ee1", "max_forks_repo_licenses": ["NCSA"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2179487179, "max_line_length": 927, "alphanum_fraction": 0.7459949937, "num_tokens": 4396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4242802582875494}}
{"text": "\\documentclass{article}\n\n%% preamble\n\\usepackage{hyperref}\n\\usepackage{verbatim}\n\\usepackage{color}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{cancel}\n\n\\topmargin 0pt\n\\advance \\topmargin by -\\headheight\n\\advance \\topmargin by -\\headsep\n\\textheight 9.in\n\\oddsidemargin 0pt\n\\evensidemargin \\oddsidemargin\n\\marginparwidth 0.5in\n\\textwidth 6.5in\n\\newcommand{\\myhrule}{ \\begin{center}\\rule{.9\\linewidth}{.25mm}\\end{center} }\n\\definecolor{darkgray}{rgb}{0.95,0.95,0.95}\n\\definecolor{heavygray}{rgb}{0.05,0.05,0.05}\n\\definecolor{foo}{rgb}{.8,0,.8}\n\\newcommand{\\pad}{\\vspace{8pt}\\noindent}\n\\newcommand{\\red}[1]{{\\color{red}#1\\color{black}}}\n\\newcommand{\\myhref}[2]{\\href{#1}{\\color{foo}\\underline{#2}\\color{black}}}\n\n\\newcommand{\\Mod}[1]{\\ (\\mathrm{mod}\\ #1)}\n\n\n\\begin{document}\n\n\\title{CMDA 3634 Spring 2018 Homework 01}\n\n%% change this to your name\n\\author{Weichen Li}\n\\vspace{-64pt}\\maketitle\n\\begin{center}\\underline{You must complete the following task by 5pm on Tuesday 02/06/18.}\\end{center}\nYour write up for this homework should be presented in a {\\LaTeX} formatted PDF document. You may copy the \\LaTeX{} used to prepare this report as follows\n\n\\begin{enumerate}\n\\item Sign up for a \\myhref{http://sharelatex.com}{http://sharelatex.com} account.\n\\item Click on this  \\myhref{https://www.sharelatex.com/read/jgjxnrcskhbc}{link} \n\\item Click on Menu/Copy Project.\n\\item Modify the HW01.tex document to respond to the following questions. \n\\item Remember: click the Recompile button to rebuild the document when you have made edits.\n\\item Remember: Change the author. \n\n\\end{enumerate}\n\n\\pad \\emph{Each student} must individually upload the following files to the CMDA 3634 Canvas page at \\myhref{https://canvas.vt.edu}{https://canvas.vt.edu}\n\n\\begin{enumerate}\n\\item \\verb|firstnameLastnameHW01.tex| {\\LaTeX} file.\n\\item Any figure files to be included by \\verb|firstnameLastnameHW01.tex| file.\n\\item \\verb|firstnameLastnameHW01.pdf| PDF file.\n\\item All source code ({\\verb .c }) files.\n\\end{enumerate}\n\n\\pad You must complete this assignment on your own.\n\n\\vspace{16pt}\n\\begin{center}\n\\underline{\\bf 100 points will be awarded for a successful completion.}\n\\vspace{8pt}\\underline{\\bf Extra credit will be awarded as appropriate.}\n\\end{center}\n\n\\newpage\n\n\\section*{ElGamal Public-key Cyptography}\n\nSuppose there are two individuals, lets call them Alice and Bob, who wish to hold a conversation where only they can read the contents of each of their messages. That is, no outside eavesdropper can discern what the contents of each message is. Let's call Eve one such potential eavesdropper. For such a system, Alice and Bob need to agree on a way to encrypt and decrypt their messages in a completely public way such that Eve cannot decyrpt their messages.\n\nLet consider just the case of Bob sending an encrypted message to Alice. A possible cryptographic system that Alice and Bob could agree on is a {\\em public-key cryptographic system}. Such a system would contain the following steps.\n\\begin{enumerate}\n\\item Alice chooses in secret a {\\em secret key} and publicly broadcasts a {\\em public key}.\n\\item Bob uses the public key to encrypt his message and sends to Alice.\n\\item Alice uses her secret key to decrypt Bob's message.\n\\end{enumerate}\nIn this process, Eve has access to the public key that was broadcast by Alice. She can also see the encrypted message send to Alice by Bob. The cryptographic system should therefore be such that \n\\begin{itemize}\n\\item Encryption is easy using the public key.\n\\item Decryption is easy using the secret key.\n\\item Finding the secret key is {\\em really hard}.\n\\end{itemize}\nThe public-key cryptographic system that we will consider in this class is the ElGamal encryption. We begin by introducing some concepts regarding integers modulo prime numbers. \n\n\\pad {\\bf Integers Modulo Primes}: \nWhile ElGamal encryption can work using more exotic mathematical structures, we will focus on integers modulo some prime $p$. We define the set $\\mathbb{Z}_p$ to be the following numbers,\n\\[\n\\mathbb{Z}_p = \\{1,2,3,\\ldots,p-1\\},\n\\]\nfor some prime number $p$. Since $p$ is prime, notice that $\\mathbb{Z}_p$ is closed under multiplication modulo $p$. That is, \n\\[\n\\forall  a, b\\in \\mathbb{Z}_p, \\qquad ab\\Mod{p} \\in \\mathbb{Z}_p.\n\\]\nIn particular, the product $ab$ cannot be zero. We'll drop the $\\Mod{p}$ in products from now on, but note that all products are assumed to be modulo $p$ so that all numbers remain in the set $\\mathbb{Z}_p$.\n\nA less obvious property of $\\mathbb{Z}_p$ is that there will exist at least one number $g$ in $\\mathbb{Z}_p$ such that \n\\[\n\\mathbb{Z}_p = \\left\\{g,g^2,g^3,\\ldots,g^{p-1}\\right\\}.\n\\]\nWe call such a number a {\\em generator} of $\\mathbb{Z}_p$. \n\nAnother less-than-obvious property is that for each number $a$ in $\\mathbb{Z}_p$, we have that $a^{p-1} = 1\\Mod{p}$. This fact is a consequence of a theorem known as Cauchy's Theorem in a field of mathematics called Group Theory. It is especially useful when we notice that, consequently, every number $a$ in $\\mathbb{Z}_p$ has a multiplicative `inverse', denoted $a^{-1}$ in $\\mathbb{Z}_p$, such that $aa^{-1} = 1$. In particular, $a^{-1} = a^{p-2}$. \n\n\\vspace*{0.5em}\n\n\\pad{\\bf Key Generation}:\nThe key generation for ElGamal encryption works as follows.\n\\begin{enumerate}\n\\item Alice chooses prime number $p$.\n\\item Alice selects a generator $g$ of the group $\\mathbb{Z}_p$.\n\\item Alice chooses, in secret, a number $x$ in $\\mathbb{Z}_p$ and computes $h=g^x$.\n\\item Alice publishes the set $(p,g,h)$ as her public key and retains $x$ as her secret key. \n\\end{enumerate}\n\n\\pad{\\bf Encryption}:\nThe ElGamal encryption for a message $m$ works as follows. We'll suppose for simplicity that the message $m$ is already a number in $\\mathbb{Z}_p$ and consider how to cast actual message text into numbers in $\\mathbb{Z}_p$ later. \n\\begin{enumerate}\n\\item Bob chooses a random $y$ in $\\mathbb{Z}_p$.\n\\item Bob computes $a = g^y$ and $s = h^y$.\n\\item Bob computes the cyphertext $\\hat{m}$ as $\\hat{m} = ms$. \n\\item Bob sends the pair $(a,\\hat{m})$ to Alice. \n\\end{enumerate}\n\n\\pad{\\bf Decryption}:\nThe ElGamal decryption of the cyphertext $\\hat{m}$ works as follows. \n\\begin{enumerate}\n\\item Alice uses her secret key $x$ to compute the shared secret $s = a^x = g^{xy}$.\n\\item Alice computes $s^{-1} = s^{p-2}$.\n\\item Alice decrypts the intended message as $\\hat{m}s^{-1} = m ss^{-1} = m$. \n\\end{enumerate}\n\n\\pad{\\bf Security}:\nThe security of the ElGamal encryption algorithm relies on the problem of finding the secret key $x$ being difficult. Since Eve knows both $g$ and $h$ from Alice's public key, this amounts to her finding $x$ such that \n\\[\ng^x = h\\Mod{p}.\n\\]\nThis problem is known as the {\\em discrete logarithm problem} and is considered to be computationally intractable for large prime numbers $p$. Indeed, our goal for the assignments in this class will be to implement our own ElGamal cryptographic system and determine how big the prime number $p$ must be before we simply will not have the computational power to crack it. \n\n\n%\\myhrule\n\\section*{Questions}\n\n\\noindent{\\bf Q1}(5 points) Show that 2, 6, 7, and 11 are all generators of $\\mathbb{Z}_{13}$.\n\\begin{align}\n    \\mathbb{Z}_{13} &= \\{1,2,3,\\ldots,12\\} \\\\\n    2: \\{2, 2^2, 2^3, \\ldots, 2^{12}\\} &= \\{2, 4, 8, \\ldots, 1\\} \\in \\mathbb{Z}_{13} \\\\\n    6: \\{6, 6^2, 6^3, \\ldots, 6^{12}\\} &= \\{6, 10, 8 \\ldots, 1\\} \\in \\mathbb{Z}_{13} \\\\\n    7:  \\{7, 7^2, 7^3, \\ldots, 7^{12}\\} &= \\{7, 10, 5, \\ldots, 1\\} \\in \\mathbb{Z}_{13} \\\\\n    11:  \\{11, 11^2, 11^3, \\ldots, 11^{12}\\} &= \\{11, 4, 5, \\ldots, 1\\} \\in \\mathbb{Z}_{13}\n\\end {align}\n\\vspace*{1em}\n\n\\noindent{\\bf Q2}(5 points) What is $6^{-1}$ in $\\mathbb{Z}_{7}$?\n\\begin{align}\n    6*6^{-1} &= 1 \\\\\n    6^{-1} &= 6^5 \\\\\n    6^{-1} &= 6\n\\end{align}\n\\vspace*{1em}\n\n\\noindent{\\bf Q3.1}(5 points) Given an ElGamal public-key of $(11,2,3)$, that is the prime $p = 11$, the generator $g = 2$, and $h = 3$, encrypt the message $m = 9$ using $y = 2$. \n\\begin{align}\n    a &= g^y = 2^2 = 4 \\\\\n    s &= h^y = 3^2 = 9 \\\\\n    \\hat{m} &= ms = 4 \\\\\n    (a, \\hat{m}) &= (4, 4)\n\\end{align}\n\\vspace*{1em}\n\n\\noindent{\\bf Q3.2}(10 points) Given that the secret key in the ElGamal public key in Q3.1 is $x=8$, decrypt the cyphertext you computed in Q3.1 and confirm that you recover the original message. \n\\begin{align}\n    s &= a^x = 4^8 = 9 = g^{xy} = 2^{8y} = 2^{16} \\\\\n    s^{-1} &= s^{p - 2} = 9^9 = 5 \\\\\n    \\hat{m}s^{-1} &= mss^{-1} = m \\\\\n    m &= 4 \\times 5 = 9\n\\end{align}\n\\vspace*{1em}\n\n\\noindent{\\bf Q4.1}(20 points) In order to write a C program to perform an ElGamal encryption, we'll need a few simple functions to help out with prime numbers. One such function is the greatest common divisor (GCD) of two numbers. This function inputs two numbers $a$ and $b$ and returns the greatest integer $z$ such that $z$ divides both $a$ and $b$. For example $GCD(15,25) = 5$ since 5 divides both 15 and 25. \n\nWithout loss of generality let's assume $a\\geq b$. The algorithm to compute the GCD of $a$ and $b$ can be written compactly as \n\\[\nGCD(a,b) = \\begin{cases}  \nGCD(b, a\\Mod{b}) & \\mathrm{if}\\; b\\neq 0, \\\\\na & \\mathrm{if}\\; b = 0. \\\\\n\\end{cases}\n\\]\nWrite a C program {\\verb gcd.c } which replicates the following functionality.\n\n\\begin{verbatim}\n    >./gcd\n    Enter the first number: 15\n    Enter the second number: 25\n    The greatest common divisor of 15 and 25 is 5.\n\\end{verbatim}\nThat is, your program should read in two values from the user and print the greatest common divisor of the two values. To read in values use the {\\verb scanf } function. \n\nHINT: In C it is legal for functions to call themselves, i.e. make recursive functions.\n\n\\vspace*{1em}\n\\noindent{\\bf Q4.2}(5 points) Another useful function is the least common multiple (LCM) of two numbers. This function inputs two numbers $a$ and $b$ and returns the smallest number $z$ such that both $a$ and $b$ divide $z$. For example $LCM(32,20) = 160$. \n\nThe algorithm to compute the LCM of $a$ and $b$ can be written using the GCD function as follows\n\\[\nLCM(a,b) = \\frac{ab}{GCD(a,b)}.\n\\]\nWrite a C program {\\verb lcm.c } which replicates the following functionality.\n\\begin{verbatim}\n    >./lcm\n    Enter the first number: 32\n    Enter the second number: 20\n    The least common multiple of 32 and 20 is 160.\n\\end{verbatim}\n\n\\vspace*{1em}\n\\noindent{\\bf Q4.3}(5 points) Two numbers $a$ and $b$ are considered coprime if the only positive number which divides both $a$ and $b$ is 1, i.e. $GCD(a,b) =1$. Write a C program {\\verb isCoprime.c } which replicates the following functionality,\n\n\\begin{verbatim}\n    >./isCoprime\n    Enter the first number: 16\n    Enter the second number: 9\n    16 and 9 are coprime.\n\\end{verbatim}\nand \n\\begin{verbatim}\n    >./isCoprime\n    Enter the first number: 32\n    Enter the second number: 12\n    32 and 12 are not coprime.\n\\end{verbatim}\n\n\\vspace*{1em}\n\\noindent{\\bf Q5}(20 points) To generate public keys in the ElGamal encryption we'll need a way to select prime numbers. Write a C program {\\verb isPrime.c } which replicates the following functionality,\n\\begin{verbatim}\n    >./isPrime\n    Enter a number: 32\n    32 is not prime.\n\\end{verbatim}\nand \n\\begin{verbatim}\n    >./isPrime\n    Enter a number: 17\n    17 is prime.\n\\end{verbatim}\nThere are many sophisticated ways to accomplish this but we are only interested in whether your program can correctly operate for the first several hundred prime numbers. Don't worry about being inefficient for now. \n\\vspace*{1em}\n\n\\noindent{\\bf Q6}(25 points) Once we have a prime number, the next task is to find a generator of $\\mathbb{Z}_p$. If you experiment with some other numbers in Q1 you may notice that if $a$ is not a generator of $\\mathbb{Z}_p$ then there will exist a number $r$, where $0<r<p-1$, such that $a^r = 1$. Therefore, for a number $g$ to be a generator of $\\mathbb{Z}_p$ it must satisfy \n\\[\ng^r \\neq 1, \\quad \\forall 0<r<p-1.\n\\]\nWrite a C program {\\verb findGenerator.c } which replicates the following functionality,\n\\begin{verbatim}\n    >./findGenerator\n    Enter a prime number: 11\n    2 is a generator of Z_11.\n\\end{verbatim}\n\n\\vspace*{1em}\n\\noindent{\\bf Bonus}(20 points) We are going to need to examine each part of our code to make sure we don't run into trouble when using very large integers. For each of your codes in this assignment, give some comments on whether you will encounter issues when your inputs become very large numbers. Will your program seem to `hang' due to computational load? Or fail to function correctly at all?\n\\begin{verbatim}\n    >./gcd\n    Enter the first number: 2\n    Enter the second number: 222222222222222222222222222\n    The greatest common divisor of -1 and 2 is -1.\n\\end{verbatim}\ngcd fails to function.\n\\begin{verbatim}\n    >./lcm\n    Enter the first number: 5\n    Enter the second number: 5555555555555555555555555555\n    The least common multiple of 5 and -1 is 5.\n\\end{verbatim}\nlcm has a similar error comparing to gcd.\n\\begin{verbatim}\n    >./isCoprime\n    Enter the first number: 31364\n    Enter the second number: 1346234623465\n    1909859817 and 31364 are coprime.\n\\end{verbatim}\nisCoprime fails as well.\n\\begin{verbatim}\n    >./isPrime\n    Enter a number: 2835768726358764758\n    -809063210 is prime.\n\\end{verbatim}\nisPrime fails to function when the input gets very large. It uses a for loop to check if the number can be divided by from 2 to half of itself, and the efficiency is pretty low. Also when the input gets large.\n\\begin{verbatim}\n    >./findGenerator\n    Enter a prime number: 28374234567293845\n    1277705109 is not prime. You have to enter a prime number\n    >./findGenerator\n    Enter a prime number: 2384523423453245\n    530387005 is not prime. You have to enter a prime number\n    >./findGenerator\n    Enter a prime number: 1273461782634871263478\n\\end{verbatim}\nfindGenerator involves isPrime to check if the input is a prime number, so it is similar to the previous one. If I remove the check and enters a large number, the program hangs.\n%\\myhrule\n\n%\\begin{thebibliography}{9}\n%\\bibitem{gol} Wikipedia -- description of the Game of Life\n%\\url{https://en.wikipedia.org/wiki/Conway's_Game_of_Life}\n \n%\\end{thebibliography}\n\n\n\\end{document}", "meta": {"hexsha": "fa5cb11226c306d9652c733e9ea8e28e4f77bf6f", "size": 14231, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Homework/HW01/weichenLiHW01.tex", "max_stars_repo_name": "liweichen6/CMDA3634", "max_stars_repo_head_hexsha": "d4722b1af264d30d0c92f9ac772f04be918bc105", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Homework/HW01/weichenLiHW01.tex", "max_issues_repo_name": "liweichen6/CMDA3634", "max_issues_repo_head_hexsha": "d4722b1af264d30d0c92f9ac772f04be918bc105", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Homework/HW01/weichenLiHW01.tex", "max_forks_repo_name": "liweichen6/CMDA3634", "max_forks_repo_head_hexsha": "d4722b1af264d30d0c92f9ac772f04be918bc105", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.7588424437, "max_line_length": 458, "alphanum_fraction": 0.710912796, "num_tokens": 4405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792043, "lm_q2_score": 0.8354835452961425, "lm_q1q2_score": 0.4242684567114332}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%               This is the LaTeX2e file for                       %% \n%%                                                                  %% \n%%           Small exotic 4--manifolds with $b_2^+=3$               %%\n%%                                                                  %% \n%%                          by                                      %%\n%%           Andras I. Stipsicz and  Zoltan Szabo                   %%\n%%                      Dec   2004                                  %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n\n\\documentclass[11pt]{gtart}\n\\usepackage{amsmath, amssymb, graphicx, epsfig, verbatim}\n\\usepackage{epic}\n\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{mthm}[thm]{Main Theorem}\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\n\\theoremstyle{definition}\n\\newtheorem{defn}[thm]{Definition}\n\\newtheorem{conj}[thm]{Conjecture}\n\\newtheorem{exa}[thm]{Example}\n%\\theoremstyle{remark}\n\\newtheorem{rem}[thm]{Remark}\n\\newtheorem{rems}[thm]{Remarks}\n\n\\numberwithin{equation}{section}\n\n\n\\mathsurround=1pt\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{1.2ex}\n\n\n%\n%   MACROS\n%\n\n%\n%  Greek letters\n%\n\n\\newcommand{\\al}{\\alpha}\n\\newcommand{\\be}{\\beta}\n\\newcommand{\\ga}{\\gamma}\n\\newcommand{\\Ga}{\\Gamma}\n\\newcommand{\\De}{\\Delta}\n\\newcommand{\\de}{\\delta}\n\\newcommand{\\ep}{\\epsilon}\n\\newcommand{\\et}{\\eta}\n\\newcommand{\\Fi}{\\Phi}\n\\newcommand{\\ka}{\\kappa}\n\\newcommand{\\La}{\\Lambda}\n\\newcommand{\\la}{\\lambda}\n\\newcommand{\\Om}{\\Omega}\n\\newcommand{\\om}{\\omega}\n\\newcommand{\\ro}{\\rho}\n\\newcommand{\\si}{\\sigma}\n\\newcommand{\\Si}{\\Sigma}\n\\renewcommand{\\th}{\\theta}\n\\newcommand{\\Th}{\\Theta}\n\\newcommand{\\Up}{\\Upsilon}\n\\newcommand{\\va}{\\varphi}\n\\newcommand{\\csi}{\\xi}\n\\newcommand{\\ze}{\\zeta}\n\\newcommand{\\bfn}{{\\mathbb {N}}}\n\\newcommand{\\bfz}{{\\mathbb {Z}}}\n\\newcommand{\\J}{{\\mathcal {J}}}\n\\newcommand{\\ot}{{\\overline {\\t}}}\n\\newcommand{\\os}{{\\overline {\\s}}}\n\\newcommand{\\oa}{{\\overline {a}}}\n\\newcommand{\\ob}{{\\overline {b}}}\n\n%\n%    Various operators\n%\n\n\n\n\n\n\\newcommand{\\x}{\\times}\n\\newcommand{\\s}{\\mathbf s}\n\\renewcommand{\\u}{\\mathbf u}\n\\renewcommand{\\t}{\\mathbf t}\n\\newcommand{\\z}{\\mathbf z}\n\\renewcommand{\\L}{{\\mathfrak {L}}}\n\\newcommand{\\D}{\\mathbf D}\n\\newcommand{\\DD}{\\mathcal D}\n\\newcommand{\\EE}{\\mathcal E}\n\\newcommand{\\MM}{\\mathcal M}\n\\newcommand{\\GG}{\\mathcal G}\n\\newcommand{\\FF}{\\mathcal F}\n\\newcommand{\\C}{\\mathbb C}\n\\newcommand{\\Z}{\\mathbb Z}\n\\newcommand{\\N}{\\mathbb N}\n\\newcommand{\\Q}{\\mathbb Q}\n\\newcommand{\\R}{\\mathbb R}\n\\newcommand{\\bfr}{\\mathbb R}\n\\newcommand{\\RP}{{\\mathbb R}{\\mathbb P}}\n\\newcommand{\\CP}{{\\mathbb C}{\\mathbb P}}\n\\newcommand{\\cpkk}{{\\overline {{\\mathbb C}{\\mathbb P}^2}}}\n\\newcommand{\\cpk}{{\\mathbb {CP}}^2}\n\\newcommand{\\cphat}{{\\mathbb {CP}}^2\\# 6{\\overline {{\\mathbb C}{\\mathbb P}^2}}}\n\\newcommand{\\cphet}{{\\mathbb {CP}}^2\\# 7{\\overline {{\\mathbb C}{\\mathbb P}^2}}}\n\\newcommand{\\cpnyolc}{{\\mathbb {CP}}^2\\# 8{\\overline {{\\mathbb C}{\\mathbb P}^2}}}\n\\newcommand{\\eegy}{{\\mathbb {CP}}^2\\# 9{\\overline {{\\mathbb C}{\\mathbb P}^2}}}\n\\newcommand{\\ra}{\\rightarrow}\n\\newcommand{\\del}{\\partial}\n\\newcommand{\\hra}{\\hookrightarrow}\n\\newcommand{\\lra}{\\longrightarrow}\n\\newcommand{\\hf}{{{\\widehat {HF}}}} \n\\newcommand{\\cf}{{\\widehat {CF}}} \n\\newcommand{\\Li}{\\mathbb {L}}\n\n\\DeclareMathOperator{\\Hom}{Hom}\n\\DeclareMathOperator{\\tb}{tb}\n\\DeclareMathOperator{\\rot}{rot}\n\n\\DeclareMathOperator{\\SW}{SW}\n\\DeclareMathOperator{\\Tor}{Tor}\n\\DeclareMathOperator{\\PD}{PD}\n\\DeclareMathOperator{\\Spin}{Spin}\n\\DeclareMathOperator{\\Id}{Id}\n\\DeclareMathOperator{\\End}{End}\n\\DeclareMathOperator{\\Fr}{Fr}\n%\n%   End macros\n%\n\n\\begin{document}\n\n\n\\title{ Small exotic 4--manifolds with $b_2^+=3$}\n\n\\author{Andr\\'{a}s I. Stipsicz}\n\\address{R\\'enyi Institute of Mathematics\\\\\nHungarian Academy of Sciences\\\\\nH-1053 Budapest\\\\ \nRe\\'altanoda utca 13--15, Hungary and\\\\\nInstitute for Advanced Study, Princeton, NJ}\n\n\\email{stipsicz@renyi.hu, stipsicz@math.ias.edu}\n\n\n\\secondauthor{Zolt\\'an Szab\\'o}\n\\secondaddress{Department of Mathematics\\\\\nPrinceton University,\\\\\n Princeton, NJ, 08540}\n\\secondemail{szabo@math.princeton.edu}\n\n\\begin{abstract}\nWe construct an infinite  family of simply connected,\npairwise nondiffeomorphic  4--manifolds,\nall homeomorphic to $3\\cpk \\# 9 \\cpkk$. \nSimilar ideas provide examples of 4--manifolds  with $b_2^+=3$,\n$b_2^-=8$, vanishing first homology and nontrivial Seiberg--Witten\ninvariants.\n\\end{abstract}\n\n\\maketitle\n\n\\section{Introduction}\nMany simply connected, smoothable topological 4--manifolds (with\n$b_2^+$ odd) are known to admit infintely many distinct smooth\nstructures. The existence of such \\emph{exotic} structures are,\nhowever, less clear when the Euler characteristic of the 4--manifold\nis small, for example if the manifold is homeomorphic to the (blow--up\nof the) complex projective plane. Using the rational blow--down\nconstruction \\cite{FS1} together with knot surgery \\cite{FSknot} in\ndouble node neighborhoods \\cite{FSuj}, many new smooth 4--manifolds\nhave been discovered with $b_2^+=1$ and $b_2^-\\geq 5$ \\cite{FSuj, P,\nPSS, SS}. Similar ideas can be applied to get examples of irreducible\nexotic simply connected 4--manifolds with $b_2^+=3$ and relatively\nsmall $b_2^-$.  The study of exotic structures on simply connected\nmanifolds with $b_2^+=3$ has a rich history. Recall that the $K3$\nsurface $E(2)$ is such an example with $b_2^-=19$. Applying\nappropriate logarithmic transformations on $E(2)$ it was shown that\n$3\\cpk \\# 19 \\cpkk$ admits infinitely many smooth structures\n\\cite{FMbook, MO, SSz}. Later works, relying on Gompf's symplectic\nnormal connected sum operation, together with Donaldson theory showed\nthat the topological manifolds $3\\cpk \\# n \\cpkk$ with $n\\geq 14$\nadmit infinitely many smooth structures \\cite{Screll, Sztop}. More\nrecent results of Park \\cite{Doug1, Doug2, Doug3} proved the same\nstatement with $n\\geq 10$. Our main result in this paper improves this\nbound:\n\n\\begin{thm} \\label{t:m1}\nThe simply connected topological 4--manifold $3\\cpk \\# 9 \\cpkk$ admits \ninfinitely many distinct smooth structures.\n\\end{thm}\n\nBy modifying the construction used in the proof of Theorem~\\ref{t:m1},\nwe can define a set of 4--manifolds which still have $b_2^+=3$, but\ntheir Euler characteristic is smaller than the above examples. In\nthese cases, however, we were unable to show that the manifolds are\nsimply connected.\n\n\\begin{thm} \\label{t:m2}\nThere are infinitely many pairwise nondiffeomorphic smooth, closed\n4--manifolds with vanishing first homology, $b_2^+=3$, $b_2^-=8$\nand nontrivial Seiberg--Witten invariants.\n\\end{thm}\n\nThe proof of the results will involve two steps. First we desribe how\nto construct the manifolds claimed and then we use Seiberg--Witten\ntheory in proving that they are nondiffeomorphic. In the construction\nwe will apply mapping class group arguments and the theory of\nLefschetz fibrations.  Using the knot surgery construction then we can\nidentify configurations of curves in the resulting 4--manifolds which\ncan be rationally blown down, leading us to the desired examples.\n\n\\section{Elliptic fibrations and mapping class groups}\n\nRecall that a genus--1 Lefschetz fibration $f\\colon X^4\\to S^2$ can be\ndescribed by the word in the mapping class group $\\Gamma _1$ of the\n2--torus $T^2$ corresponding to the monodromy presentation of\n$f$. More precisely, a point $x\\in X$ where $df$ is not onto (called a\nsingular point of the fibration) gives rise to a singular fiber\n$f^{-1}(f(x))$, and the monodromy of the fibration around such a fiber\ncan be given by the composition of Dehn twists along the circles\ncorresponding to the vanishing cycles of the singular points of the\nfiber. By traversing through the singular fibers in a counterclockwise\nmanner relative to a fixed base point $s_0\\in S^2$, we get the above\nmentioned word describing the fibration.  Notice that we do not assume\nthat $f$ is injective on the set of its singular points, that is, a\nsingular fiber can contain more than one singular points.  The\nassumption that the map $f$ is a Lefschetz fibration implies that the\nvanishing cycles corresponding to the singular points in one fixed\nsingular fiber can be chosen to be disjoint.\n\nIt is known that the mapping class group $\\Gamma _1$ can be generated by \ntwo elements $a,b\\in \\Gamma _1$ which are subject to the two relations\n\\[ \naba=bab \\qquad {\\mbox{ and }} \\qquad (ab)^6=1.\n\\]\nIn fact, $\\Gamma _1$ can be shown to be isomorphic to $SL(2; \\bfz )$ \nby mapping $a$ to \n$\\left(\\begin{smallmatrix}\n 1 & 1 \\\\\n 0 & 1 \n\\end{smallmatrix}\\right)$ and $b$ to\n$\\left(\\begin{smallmatrix}\n 1 & 0 \\\\\n -1 & 1 \n\\end{smallmatrix}\\right)$. \nSince the forgetful map from the mapping class group $\\Gamma _1 ^1$ of the\n2--torus with one marked point to $\\Gamma _1$ is an isomorphism, we get that\nany genus--1 Lefschetz fibration admits a section. \n\nGenus--1 Lefschetz fibrations were classified by Moishezon\n\\cite{Mois}, who showed that after a possible perturbation such a\nfibration over $S^2$ is equivalent to one of the fibrations given by\nthe words $(ab)^{6n}$ ($n\\in \\bfn$) in $\\Gamma _1$. The resulting\n4--manifold is usually called $E(n)$ (the simply connected elliptic\nsurface with section and of holomorphic Euler characteristic $n$), and\n$E(2)$ is the famous $K3$ surface.  It can be shown that a section of\n$E(n)\\to S^2$ has self--intersection $-n$.\n\nFollowing \\cite{HKK} we call a fiber with monodromy conjugate to $a^k$\nof \\emph{type $I_{k}$} ($k\\in \\bfn$).  When $k=1$, the corresponding\nfiber is also called a \\emph{fishtail} fiber.  It is easy to see that\ntopologically a singular fiber of type $I_k$ ($k\\geq 2$) is a plumbing\nof $k$ smooth 2--spheres of self--intersection $-2$ plumbed along a\ncircle (see \\cite[page 35]{HKK}), while a fishtail fiber is an\nimmersed 2--sphere with one positive double point.  Since in $T^2$\nnonisotopic simple closed curves necessarily intersect each other, it is\neasy to see that a genus--1 Lefschetz fibration can have only\n$I_k$--fibers as singular fibers. The fibration $f$ can be perturbed\nnear a singular fiber $F$ of type $I_k$ into a fibration $f'$ which is\nthe same as $f$ outside of $F$ but breaks $F$ into two singular fibers\nof types $I_{k_1}$ and $I_{k_2}$ with $k_1+k_2=k$.  This fact implies\nthat a generic genus--1 Lefschetz fibration admits only fishtail\nfibers. In our study however, we will find it most helpful to\nunderstand what kind of other singular fibers an elliptic fibration\ncan admit.\n\n\n\\section{The construction for $b_2^-=9$}\n\nWe start with a proposition showing the existence of a particular\ngenus--1 fibration on $E(2)$.\n\n\\begin{prop}\\label{p:mcg}\nThere exists an elliptic Lefschetz fibration on the $K3$ surface\n$E(2)$ with a section, a singular fiber $F$ of type $I_{16}$, three\nsingular fibers $F_1, F_2,F_3$ of type $I_2$ and two further fishtail\nfibers.\n\\end{prop}\n\\begin{proof}\nIt is not hard to see that the word $(ab)^{12}$ (defining a genus--1\nLefschetz fibration on the $K3$ surface $E(2)$) in the mapping class\ngroup $\\Gamma _1$ of the torus is equivalent to\n\\[\na^4ba^2b^2a^2b^2a^4ba^2b^2a^2.\n\\]\n(Alternatively, by substituting $a$ and $b$ with the matrices they\ncorrespond to under the map $\\Gamma _1 \\to SL(2; \\bfz )$, we can check\nthat the above product is equal to the identity matrix.)  By\ncollecting the powers of $a$ in the front using conjugation, we get\n$a^{16}$ followed by the product of three squares of some conjugates\nof $b$ and two further conjugates of $b$. Since a conjugate of $b$ by\na word $x\\in \\Gamma _1$ corresponds to the Dehn twist along the image\nunder the diffeomorphism $x$ of the curve inducing $b$, the\nproposition follows.  As we already mentioned, genus--1 Lefschetz\nfibrations always admit sections.\n\\end{proof}\n\nPerturb first the above fibration near the $I_2$ fibers $F_i$ \n($i=1,2,3$) in a way that these give rise to fishtail fibers\n$F_i', F_i ''$ with isotopic vanishing cycles. Let us denote the\nresulting Lefschetz fibration by $f\\colon E(2) \\to S^2$.\n\n%In order to prove Theorem~\\ref{t:m1}, we will apply a further\n%perturbation of $f$ near the $I_{16}$--fiber $F$, resulting a map\n%$f'\\colon E(2)\\to S^2$ with a type $I_{15}$ fiber and nine fishtails,\n%with three pairs $F_i', F_i''$ admitting isotopic vanishing cycles. We\n%will use this fibration in the proof of Theorem~\\ref{t:m1}.\n\nLet $K_1,K_2,K_3$ be three twist knots as depicted in \\cite{FSuj}.\nLet $Z_{K_1,K_2,K_3}$ denote the 4--manifold we get after performing\nthree knot surgeries with knots $K_1,K_2,K_3$ along three regular\nfibers in the fibration on the $K3$ surface found above.  Because of\nthe existence of fishtail fibers in the complement with nonisotopic\nvanishing cycles, we conclude that $\\pi _1(Z_{K_1,K_2,K_2})=1$. If we\nperform the surgeries in the double node neighborhoods near the\nfishtail fibers $F_1',F_1''$, and $F_2',F_2''$ and $F_3',F_3''$\nrespectively, then we can find a 'pseudo--section' $S$ as in\n\\cite{FSuj} which is an immersed sphere of self--intersection $(-2)$\nwith three positive double points, intersecting the further fishtail\nfibers and the $I_{16}$ fiber $F$ transversally. Next smooth the\nintersections of this pesudo--section $S$ with two further fishtail\nfibers. The result is an immersed sphere of self--intersection 2\nhaving 5 positive double points. Now blow up the 4--manifold\n$Z_{K_1,K_2,K_3}$ in the five double points of this sphere, and find\nan embedded sphere of self--intersection $-18$ in $Z_{K_1,K_2,K_3}\\# 5\n\\cpkk$. Let $C$ denote the tubular neighborhood of the linear plumbing\nof spheres given by this $(-18)$--sphere together with 14 of the\n$(-2)$--spheres in the $I_{16}$ fiber $F$. It is not hard to see that\n$C$ is diffeomorphic to $C_{16,1}$ in the notation of \\cite{SS},\ncf. also \\cite{FS1, Pratb}.  It is then easy to show that $\\partial\nC=\\partial C_{16,1}$ can be given as the oriented boundary of the\nrational ball $B_{16,1}$, see \\cite{CH, FS1, SS}.  Define\n$X_{K_1,K_2,K_3}$ as the rational blow--down of $Z_{K_1,K_2,K_3}\\# 5\n\\cpkk$ along $C$, that is,\n\\[\nX_{K_1,K_2,K_3}=(Z_{K_1,K_2,K_3}\\# 5\\cpkk -{\\mbox { int }}C)\\cup B_{16,1}.\n\\]\n\n\n\\begin{prop}\\label{p:hom}\nFor any twist knots $K_1,K_2,K_3$ the 4--manifold $X_{K_1,K_2,K_3}$ is\nhomeomorphic to $3\\cpk \\# 9 \\cpkk$.\n\\end{prop}\n\\begin{proof}\nNotice that $Z_{K_1,K_2,K_3}$ is simply connected, and the complement\nof $C$ in $Z_{K_1,K_2,K_3} \\# 5 \\cpkk$ is simply connected since the\n$(-2)$--sphere in $F$ intersecting the last $(-2)$--sphere of the\nlinear chain $C$ provides a hemisphere which contracts the generator\nof the fundamental group of $\\partial C$.  Since $\\pi _1 (\\partial\nB_{16,1})$ surjects onto $\\pi _1 (B_{16,1})$ under the natural\nembedding, Van Kampen's Theorem implies that $X_{K_1,K_2,K_3}$ is\nsimply connected. Now simple signature and Euler characteristics\ncomputation together with Freedman's Theorem \\cite{Fr} verifies the\nresult.\n\\end{proof}\n\nFor short, let $X_n$ denote the 4--manifold $X_{K_1,K_2,K_3}$ if\n$K_1=K_2=K_3=$ the $n$--twist knot $T_n$. The following proposition is\ntrue in a wider generality, we restrict our attention to the special\ncase $K_1=K_2=K_3$ in order to keep our discussion as simple as possible.\nUsing the results of \\cite{FS1, FSknot} the Seiberg--Witten invariants\nof $X_n$ can be easily computed. This computation immediately shows\n\n\\begin{thm}\\label{t:sw}\nThere are two cohomology classes $\\pm L\\in H^2 (X_n ; \\bfz )$ with the\nproperty that the Seiberg--Witten function $SW_{X_n}$ of $X_n$ is\nequal to zero for all classes $K\\neq \\pm L$ and $SW_{X_n}(\\pm L)=\\pm\nn^3$.\n\\end{thm}\n\\begin{proof}\nBy \\cite[Theorem~1.1]{FSknot} the Seiberg--Witten invariant of\n$Z_n=Z_{T_n,T_n,T_n}$ can be computed to be equal to\n\\[\n(n\\exp (2T)-(2n-1)+n\\exp (-2T))^3\n\\]\n(use the facts that the Seiberg--Witten function of the $K3$ surface\nis equal to 1 and the Alexander polynomial of $T_n$ is $\\Delta\n_{T_n}=nt-(2n-1)+nt^{-1}$). This result, together with the blow--up\nformula shows that the five--fold blow--up $Z_n \\# 5 \\cpkk$ has\nexactly two Seiberg--Witten basic classes $\\pm K$ which evaluate on\nthe $(-18)$--sphere of the configuration $C$ as $\\pm 16$. Moreover,\nthe value of the Seiberg--Witten function on these basic classes is\n$\\pm n^3$.  Now \\cite[Theorem~8.5]{FS1} implies that $X_n$ has two\nbasic classes, on which the value of the Seiberg--Witten function is\nequal to $\\pm n^3$, verifying the result.\n\\end{proof}\n\n\n\\begin{cor}\\label{c:nondiffeo}\nThe 4--manifolds $X_n$ are pairwise nondiffeomorphic irreducible smooth\n4--manifolds. \\qed\n\\end{cor}\n\n\\begin{proof}[Proof of Theorem~\\ref{t:m1}]\nThe 4--manifolds $X_n$ provide an infinite family of smooth\n4--manifolds all homeomorphic to $3\\cpk \\# 9 \\cpkk$ according to\nProposition~\\ref{p:hom}, and by Corollary~\\ref{c:nondiffeo} these\nmanifolds are pairwise nondiffeomorphic. Therefore the set $\\{ X_n\n\\mid n \\in \\bfn \\}$ provides an infinite collection of distinct\nsmooth structures on $3\\cpk \\# 9 \\cpkk$, hence the proof is complete.\n\\end{proof}\n\n\\subsection{4--manifolds with $b_2^+=3$ and $b_2^-=8$}\nUsing a variation of the above procedure, closed 4--manifolds with\n$b_2^+=3$ and $b_2^-=8$ can be constructed as follows. Consider the\nfibration $f\\colon E(2) \\to S^2$ found above, containing a singular\nfiber of type $I_{16}$ and eight fishtail fibers, out of which three\npairs $F_i', F_i''$ ($i=1,2,3$) have isotopic vanishing cycles.\nProceed as before by doing three knot surgeries along three regular\nfibers with twist knots $K_1,K_2,K_3$ and --- using the double node\nneighborhoods provided by the fishtail fibers $F_i',F_i''$ ---\nidentify the 'pseudo--section', which is again an immersed sphere\nwith homological square $-2$ and has three positive double points. As\nbefore, resolve the two positive intersections of this\npseudo--section with the remaining two fishtail fibers, and find the\nimmersed sphere with 5 double point and homological square 2. Blow up\nthe 4--manifold at the double points of the pesudo--section, and\nconsider the resulting sphere of square $-18$ in\n$Z_{K_1,K_2,K_3}$. This sphere intersects the $I_{16}$ fiber $F$\ntransversally in a unique point $P$ which is on the $(-2)$--sphere\n$\\Sigma _0 \\subset F$. Now $\\Sigma _0$ is intersected by two other\nspheres in $F$, let $\\Sigma _1$ be one of them and denote the\nintersection point of $\\Sigma _0$ and $\\Sigma _1$ by $Q$. Apply 17\ninfinitely close blow--ups at $Q$. The resulting plumbing manifold\n$C_{305,17}$ can be given by the linear plumbing\n\\[\n(-18,-19,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-3,-2,-2,\n\\]\n\\[\n-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-2,-2,-2,-2).\n\\] \nAs before, it is routine to see that the boundary\n$\\partial C_{305,17}$ can be given as the boundary of the rational\nball $B_{305,17}$, hence we can blow it down, resulting the \n4--manifold $Y_{K_1,K_2,K_3}$. Since the normal circle of the \npseudo--section (which circle generates the first homology\nof $\\partial C_{305,17}$) vanishes in the homology of the\ncomplement $Z_{K_1,K_2,K_3}\\#22\\cpkk - {\\mbox { int }}C_{305,17}$\n(as it is shown by a regular fiber), the Mayer--Vietoris sequence\nimplies that $H_1(Y_{K_1,K_2,K_3}; \\bfz )$ vanishes. Simple\nEuler characteristic and signature computations now imply\n\\begin{lem}\nThe 4--manifolds $Y_{K_1,K_2,K_3}$ have $b_2^+=3$ and $b_2^-=8$. \\qed\n\\end{lem}\n\nFinally, by computing Seiberg--Witten invariants of these manifolds in\nthe fashion it was done in Theorem~\\ref{t:sw}, we get that the\n4--manifolds $Y_n=Y_{T_n, T_n,T_n}$ are pairwise nondiffeomorphic, all\nwith nonvanishing Seiberg--Witten invariants, verifying the claim of\nTheorem~\\ref{t:m2}.\n\n\n\\begin{thebibliography}[AAA]\n\n%\\bibitem{Bar}\n%{\\bf R. Barlow},\n%{\\it A simply connected surface of general type with $p_g=0$},\n%Invent. Math.  {\\bf79} (1985), 293--301. \n\n%\\bibitem{BK}\n%{\\bf V. Braungardt and D. Kotschick},\n%{\\it Clustering of critical points in Lefschetz fibrations and the\n%symplectic Szpiro inequality}, Trans. AMS {\\bf355} (2003), 3217--3228.\n\n\\bibitem{CH}\n{\\bf A. Casson and J. Harer},\n{\\it Some homology lens spaces which bound rational homology balls},\nPacific J. Math. {\\bf96} (1981), 23--36.\n\n%\\bibitem{D}\n%{\\bf S. Donaldson}, \n%{\\it An application of gauge theory to four dimensional topology},\n%J. Diff. Geom. {\\bf18} (1983), 279--315.\n\n%\\bibitem{D1}\n%{\\bf S. Donaldson},\n%{\\it Irrationality and the h-cobordism conjecture}, J. Diff. Geom.\n%{\\bf 26} (1987), 141-168.\n\n\\bibitem{FS1} {\\bf R. Fintushel and R. Stern},\n{\\it Rational blowdowns of smooth 4--manifolds}, J. Diff. Geom. {\\bf46}\n(1997), 181--235.\n\n\\bibitem{FSknot} {\\bf R. Fintushel and R. Stern},\n{\\it Knots, links and 4--manifolds}, Invent. Math. {\\bf134}\n(1998), 363--400.\n\n\\bibitem{FSuj} {\\bf R. Fintushel and R. Stern},\n{\\it Double node neighborhoods and families of simply connected\n4--manifolds with $b^+=1$}, arXiv:math.GT/0412126\n\n\\bibitem{Fr} {\\bf M. Freedman},\n{\\it The topology of four--dimensional manifolds},\nJ. Diff. Geom. {\\bf17} (1982), 357--453.\n\n%\\bibitem{FM} {\\bf R. Friedman and J. Morgan}, {\\it On the\n%diffeomorphism types of certain algebraic surfaces I., II.}\n%J. Diff. Geom.  {\\bf27} (1988),  297--369. and 371--398.  \n\n\\bibitem{FMbook} {\\bf R. Friedman and J. Morgan}, \n{\\it Smooth 4--manifolds and complex surfaces}, Ergebnisse der Mathematik und\nihrer Grenzgebiete {\\bf27}, Springer--Verlag, 1994.\n\n%\\bibitem{GS}\n%{\\bf R. Gompf and A. Stipsicz},\n%{\\it 4--manifolds and Kirby calculus}, \n%AMS Grad. Studies in Math. {\\bf20}, 1999.\n\n\\bibitem{HKK} {\\bf J. Harer, A. Kas and R. Kirby}, \n{\\it Handlebody decompositions of complex surfaces},\nMemoirs of the AMS, vol. {\\bf62}, 1986.\n\n%\\bibitem{Kod}\n%{\\bf K. Kodaira},\n%{\\it On compact analytic surfaces: II},\n%Ann. Math. {\\bf77} (1963), 563--626.\n\n%\\bibitem{Kot}\n%{\\bf D. Kotschick}, {\\it On manifolds homeomorphic to $\\cpnyolc$}, \n%Invent. Math. {\\bf95} (1989), 591--600.\n\n\\bibitem{Mois} {\\bf B. Moishezon},\n{\\it Complex surfaces and connected sums of complex\nprojective planes}, Lecture Notes in Mathematics {\\bf603}, Springer--Verlag,\n1977.\n\n\\bibitem{MO} \n{\\bf J. Morgan and K. O'Grady}, {\\it Differential topology\nof complex surfaces. Elliptic surfaces with $p_g=1$: smooth\nclassification}, Lecture Notes in Mathematics {\\bf1545},\nSpringer-Verlag 1993.\n\n\\bibitem{Doug1} {\\bf D. Park},\n{\\it Exotic smooth structures on $3\\cpk \\# n \\cpkk$}, Proc. Amer. Math. Soc.\n{\\bf128} (2000), 3057--3065.\n\n\n\\bibitem{Doug2} {\\bf D. Park},\n{\\it Exotic smooth structures on $3\\cpk \\# n \\cpkk$, Part II}, \nProc. Amer. Math. Soc. {\\bf128} (2000), 3067--3073.\n\n\\bibitem{Doug3} {\\bf D. Park},\n{\\it Constructing infinitely many smooth structures on $3\\cpk \\# n \\cpkk$} \nMath. Ann. {\\bf322} (2000), 267--278.\n\n\n\\bibitem{Pratb} {\\bf J. Park},\n{\\it Seiberg--Witten invariants of generalized rational blow--downs},\nBull. Austral. Math. Soc. {\\bf56} (1997), 363--384.\n\n\\bibitem{P} {\\bf J. Park}, \n{\\it Simply connected symplectic 4--manifolds with $b_2^+=1$ and $c^2_1=2$},\nto appear in Invent. Math., arXiv:math.GT/0311395\n\n\\bibitem{PSS} {\\bf J. Park, A. Stipsicz and Z. Szab\\'o},\n{\\it Exotic smooth structures on $\\cpk \\# 5 \\cpkk$}, arXiv.math:GT/0412216\n\n\\bibitem{Screll}\n{\\bf A. Stipsicz},\n{\\it Donaldson series and $(-1)$--tori}, J. Reine Angew. Math. {\\bf465}\n(1995), 133--144.\n\n\\bibitem{SSz} {\\bf A. Stipsicz and Z. Szab\\'o},\n{\\it The smooth classification of elliptic surfaces with $b_2^+>1$},\nDuke Math. J. {\\bf75} (1994), 1--50.\n\n\n\\bibitem{SS} {\\bf A. Stipsicz and Z. Szab\\'o},\n{\\it An exotic smooth structure on $\\cphat$}, arXiv.math:GT/0411258\n\n%\\bibitem{Sym} {\\bf M. Symington},\n%{\\it Generalized symplectic rational blowdowns}, \n%Algebr. Geom. Topol. {\\bf1} (2001), 503--518.\n\n\\bibitem{Sztop} {\\bf Z. Szab\\'o},\n{\\it Irreducible four--manifolds with small Euler characteristics},\nTopology {\\bf35} (1996), 411--426.\n\n%{\\it Exotic 4--manifolds with $b_2^+=1$}, Math. Res. Letters {\\bf3} \n%(1996), 731--741.\n\\end{thebibliography}\n\\end{document}\n\n", "meta": {"hexsha": "1752785f1b878f307920769747af9f21f22e533e", "size": 23905, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "benchmark/src/test-data/0501/math0501273/paper.tex", "max_stars_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_stars_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-23T19:07:01.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-23T19:07:01.000Z", "max_issues_repo_path": "benchmark/src/test-data/0501/math0501273/paper.tex", "max_issues_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_issues_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/src/test-data/0501/math0501273/paper.tex", "max_forks_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_forks_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0418760469, "max_line_length": 81, "alphanum_fraction": 0.7041204769, "num_tokens": 7920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.42423964732572456}}
{"text": "\n\n\nWe study the loop version of the factorial function.\n\n\n\\[\n\t\\begin{array}{l@{\\hspace{0.3em}}c@{\\hspace{1em}}l}\n\t\\hline\n\t\tl_1 & : & \\mathtt{x := 10} \\\\\n\t\tl_2 & : & \\mathtt{f := 1} \\\\\n\t\tl_3 & : & \\mathtt{\\textbf{while } (x\\geq 1) \\textbf{ do }} \\\\\n\t\tl_4 & : & \\mathtt{\\;\\;f = f*x} \\\\\n\t\tl_5 & : & \\mathtt{\\;\\;x=x-1} \\\\ \t\n\t\tl_6 & : & \\mathtt{\\textbf{end while}}\\\\\n\t\tl_7 & : & \\mathtt{\\cdots}\\\\\n\t\\hline\n\t\\end{array}\n\\]\n\\label{simple:example}\n\n\n\n\nWe seek to prove two formulae.\n\n\\[\\varphi_1 \\equiv (l_5 \\orcond l_4 \\to \\mathtt{x}\\geq 1) \\;\\; \\wedge \\;\\; \\varphi_2 \\equiv \\mathtt{x} \\geq 0\\]\n\nFirst, we reduce the program to its \\VC.\n\n\n\\[\n\t\\begin{array}{l}\n\t\t \\tau_1 \\equiv\\pc(T) = l_1 \\andcond \\pc\\prime (T) = l_2 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x}\\prime  = 10\\\\\n\t\t \\tau_2 \\equiv\\pc(T) = l_2 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f}\\prime  = 1 \\andcond x\\prime =x\\\\\n\t\t \\tau_3 \\equiv\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_4 \\andcond \\mathtt{f\\prime =f} \\andcond x\\prime \\geq 1\\\\\n\t\t \\tau_4 \\equiv\\pc(T) = l_4 \\andcond \\pc\\prime (T) = l_5 \\andcond \\mathtt{f}\\prime  = \\mathtt{f*x} \\andcond \\mathtt{x\\prime =x}\\\\\n\t\t \\tau_5 \\equiv\\pc(T) = l_5 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x\\prime =x-1}\\\\\n\t\t \\tau_6 \\equiv\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_7 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x<1}\n\t\\end{array}\n\\]\n\nWe need to prove, for $i=1,2$:\n\n\\[\n\t\\left\\{\n\t\t\\begin{array}{l}\n\t\t\t\\tau_1 \\andcond \\varphi_i \\to \\varphi_i\\prime  \\\\\n\t\t\t\\tau_2 \\andcond \\varphi_i \\to \\varphi_i\\prime \\\\\n\t\t\t\\tau_3 \\andcond \\varphi_i \\to \\varphi_i\\prime  \\\\\n\t\t\t\\tau_4 \\andcond \\varphi_i \\to \\varphi_i\\prime \\\\\n\t\t\t\\tau_5 \\andcond \\varphi_i \\to \\varphi_i\\prime  \\\\\n\t\t\t\\tau_6 \\andcond \\varphi_i \\to \\varphi_i\\prime \n\t\t\\end{array}\n\t\\right.\n\\]\n\n\\begin{center}\\rule{4cm}{0.4pt}  $\\varphi_1$  \\rule{4cm}{0.4pt}\\end{center}\n\t\n\t $\\tau_1 \\andcond \\varphi_1 \\to \\varphi_1\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_1 \\andcond \\pc\\prime (T) = l_2 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x}\\prime  = 10}_{\\tau_1} \\andcond (\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ] \\to \\mathtt{x}\\geq 1}_{\\varphi_1})\n\t\t) \\\\\n\t\t\t\t\\to(\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $\\pc(T) = l_2 \\neq l_5 \\andcond l_2 \\neq l_4$ thus the $\\varphi\\prime _1$ is true.\n\n\t $\\tau_2 \\andcond \\varphi_1 \\to \\varphi_1\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_2 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f}\\prime  = 1 \\andcond x\\prime =x}_{\\tau_2} \\andcond (\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ] \\to \\mathtt{x}\\geq 1}_{\\varphi_1})\n\t\t) \\\\\n\t\t\t\\to(\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $\\pc(T) = l_3 \\neq l_5 \\andcond l_2 \\neq l_4$ thus the $\\varphi\\prime _1$ is true.\n\n\t $\\tau_3 \\andcond \\varphi_1 \\to \\varphi_1\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_4 \\andcond \\mathtt{f\\prime =f} \\andcond \\textcolor{orange}{x\\prime \\geq 1}}_{\\tau_3} \\andcond (\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ] \\to \\mathtt{x}\\geq 1}_{\\varphi_1})\n\t\t) \\\\\n\t\t\t\\to(\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\t\tThe formula is valid because $x\\prime \\geq 1$ thus the $\\varphi\\prime _1$ is true.\n\n\t \\;$\\tau_4 \\andcond \\varphi_1 \\to \\varphi_1\\prime $: \n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_4 \\andcond \\pc\\prime (T) = l_5 \\andcond \\mathtt{f}\\prime  = \\mathtt{f*x} \\andcond \\mathtt{x\\prime =x}}_{\\tau_4} \\andcond (\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ] \\to \\mathtt{x}\\geq 1}_{\\varphi_1})\n\t\t) \\\\\n\t\t\t\\to(\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\tThe formula is equivalent (applying resolution) to\n\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\mathtt{x\\prime =x} \\andcond  \\mathtt{x}\\geq 1\n\t\t) \n\t\t\\to (\\mathtt{x}\\prime \\geq 1)\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\n\tWhich is valid because of equality congruence.\n\n\t $\\tau_5 \\andcond \\varphi_1 \\to \\varphi_1\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ]\\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x\\prime =x-1}}_{\\tau_5} \\andcond (\\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4 ] \\to \\mathtt{x}\\geq 1}_{\\varphi_1})\n\t\t) \\\\\n\t\t\t\\to(\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $\\pc(T) = l_3 \\neq l_5 \\andcond l_2 \\neq l_4$ thus the $\\varphi\\prime _1$ is true.\n\n\t $\\tau_6 \\andcond \\varphi_1 \\to \\varphi_1\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{align*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_7 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x<1}}_{\\tau_6} \\andcond \\underbrace{\\pc(T) = l_5 \\to \\mathtt{x} \\geq 1}_{\\varphi_1}\n\t\t) \\\\\n\t\t\t\\to (\\underbrace{[\\pc\\prime (T) = l_5 \\orcond \\pc\\prime(T) = l_4] \\to \\mathtt{x}\\prime  \\geq 1}_{\\varphi_1\\prime })\\;\\;\\;\\;\n\t\\end{align*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $\\pc(T) = l_7 \\neq l_5$ thus the $\\varphi\\prime _1$ is true.\n\n\n\\paragraph{Conclusion:} we have proven that $\\pc(T) = l_5 \\to x \\geq 1$. \n%\nThis is called an \\concept[Invariant]{invariant} because it is always true in all executions of the program. \n%\nThis invariant has been chosen specially because it is needed in the proof of $\\varphi_2$.\n\n\\begin{center}\\rule{4cm}{0.4pt}  $\\varphi_2$  \\rule{4cm}{0.4pt}\\end{center}\n\n\t\\; $\\tau_1 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\t\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_1 \\andcond \\pc\\prime (T) = l_2 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x}\\prime  = 10}_{\\tau_1} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\t\\to  \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $x\\prime =10 \\to x\\prime \\geq 0$.\n\n\t\\; $\\tau_2 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\t\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_2 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f}\\prime  = 1 \\andcond x\\prime =x}_{\\tau_2} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\n\tThe formula is valid because of the congruence of equality used in  $x\\prime =x \\andcond x\\geq 0 \\to x\\prime \\geq 0$ \n\n\t\\; $\\tau_3 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_4 \\andcond \\mathtt{f\\prime =f} \\andcond x\\prime \\geq 1}_{\\tau_3} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because $x\\prime \\geq 1 \\to x\\prime \\geq 0$.\n\t\\; $\\tau_4 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\t\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_4 \\andcond \\pc\\prime (T) = l_5 \\andcond \\mathtt{f}\\prime  = \\mathtt{f*x} \\andcond \\mathtt{x\\prime =x}}_{\\tau_4} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\tThe formula is valid because of the congruence of equality used in  $x\\prime =x \\andcond x\\geq 0 \\to x\\prime \\geq 0$ \n\n\t\\; $\\tau_5 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\t\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_5 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x\\prime =x-1}}_{\\tau_5} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\tThe formula has some more difficulty. \n\t%\n\tInside the loop $x$ should be greater than 1.\n\t%\n\tHowever, that information is not encoded in the formula.\n\t\n\tThe solution is use some \\concept{support}.\n\t%\n\tA support formula is an invariant formula added to the antecedent of an implication to give more information. \n\t%\n\tThis addition does not change the validity of the formula.\n\t%\n\tWe could equivalently prove\n\n\t\\[\n\t\t(\\tau_5 \\andcond \\varphi_1 \\andcond \\varphi_2 \\to \\varphi_2\\prime ) \\rightarrow (\\varphi_2\\to\\varphi_2\\prime )\n\t\\]\n\n\tAnd this is exactly the solution to proof this \\gls{VC}\n\n\t\n\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_5 \\andcond \\pc\\prime (T) = l_3 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x\\prime =x-1}}_{\\tau_5} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2} \\andcond \\underbrace{[\\pc(T) = l_5 \\orcond \\pc(T) = l_4] \\to \\mathtt{x} \\geq 1}_{\\varphi_1}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\n\n\tAnd this formula is valid. Applying resolution we get an equivalent valid formula:\n\n\t\\[\n\t\t( \\mathtt{x\\prime =x-1} \\andcond \\mathtt{x\\prime }\\geq 1) \\to \\mathtt{x} \\geq 0\n\t\\]\n\n\n\t\\; $\\tau_6 \\andcond \\varphi_2 \\to \\varphi_2\\prime $:\n%\t\\begin{dmath*}[indentstep={0em}]\n\t\\begin{equation*}\n\t\t(\n\t\t\t\\underbrace{\\pc(T) = l_3 \\andcond \\pc\\prime (T) = l_7 \\andcond \\mathtt{f\\prime =f} \\andcond \\mathtt{x<1} \\andcond \\mathtt{x\\prime =x} }_{\\tau_6} \\andcond \\underbrace{\\mathtt{x} \\geq 0}_{\\varphi_2}\n\t\t) \n\t\t\t\\to \\underbrace{\\mathtt{x}\\prime  \\geq 0}_{\\varphi_2\\prime }\\\\\\\\\n\t\\end{equation*}\n%\t\\end{dmath*}\n\t\n\n\t\n\tAnd this formula is valid. Applying resolution we get an equivalent valid formula:\n\n\t\\[\n\t\t(\n\t\t\t\\mathtt{x\\prime =x}  \\andcond \\mathtt{x}\\geq 0 \\to \\mathtt{x\\prime }\\geq 0\n\t\t)\n\t\\]\n\n\\paragraph{Conclusion} We have proof that $\\varphi_1$ and $\\varphi_2$ are invariants.\n", "meta": {"hexsha": "df65d5584694415554eb8595386ff816d981eafc", "size": 10226, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/subsrc/exampleFactorial.tex", "max_stars_repo_name": "VicdeJuan/tfg", "max_stars_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/subsrc/exampleFactorial.tex", "max_issues_repo_name": "VicdeJuan/tfg", "max_issues_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/subsrc/exampleFactorial.tex", "max_forks_repo_name": "VicdeJuan/tfg", "max_forks_repo_head_hexsha": "ee2c372816b111620bf30f470decd60685f15a21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-21T12:44:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T11:14:52.000Z", "avg_line_length": 36.5214285714, "max_line_length": 270, "alphanum_fraction": 0.6309407393, "num_tokens": 4470, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521105, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.4242396427829991}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{setspace}\n\n\\usepackage{amsmath, graphicx, color, fancyhdr, tikz-cd, mdframed, enumitem, framed, adjustbox, bbm, upgreek, xcolor, hyperref, manfnt}\n\\usepackage[framed,thmmarks]{ntheorem}\n\\usepackage[style=alphabetic, bibencoding=utf8]{biblatex}\n%Set the bibliography file\n\\bibliography{sources}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[urw-garamond]{mathdesign}\n\\usepackage{garamondx}\n\n%Replacement for the old geometry package\n\\usepackage{fullpage}\n\n%Input my definitions\n\\input{./mydefs.tex}\n\n%Shade definitions\n\\theoremindent0cm\n\\theoremheaderfont{\\normalfont\\bfseries} \n\\def\\theoremframecommand{\\colorbox[rgb]{0.9,1,.8}}\n\\newshadedtheorem{defn}[thm]{Definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%% Customize Below %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%header stuff\n\\setlength{\\headsep}{24pt}  % space between header and text\n\\pagestyle{fancy}     % set pagestyle for document\n\\lhead{Notes on the Schur-Weyl Functor} % put text in header (left side)\n\\rhead{Nico Courts} % put text in header (right side)\n\\cfoot{\\itshape p. \\thepage}\n\\setlength{\\headheight}{15pt}\n%\\allowdisplaybreaks\n\n% Document-Specific Macros\n\\DeclareMathOperator{\\1}{\\mathbbm{1}}\n\\DeclareMathOperator{\\GL}{GL}\n\n\\begin{document}\n%make the title page\n\\title{Notes on the Schur-Weyl Functor \\vspace{-1ex}}\n\\author{Nico Courts}\n\\date{Summer 2019}\n\\maketitle\n\n\\begin{abstract}\n\tThese notes are my summary of the development of the Schur-Weyl functor from representations of the Schur algebra $S(n,d)$ to \n\trepresentations of $\\frakS_d$. After developing the theory that arose beginning in Schur's 1901 thesis, we will establish that this \n\tfunctor is exact and behaves nicely with respect to simple modules, as well as being a monoidal functor (under the correct monoidal structure).\n\\end{abstract}\n\n\\section{Background and Introduction}\nThe primary reference for this paper is J.A. Green's \\textit{Polynomial Representations of $\\GL_n$} \\cite{green}. Other sources will be used as well, \nand will be introduced as needed.\n\nThe basic idea for this theory begins with Schur's thesis in 1901 \\cite{schur-thesis}. Here he developed the theory underlying\nthe representation theory of the general linear group $\\GL_n$. As a tool, he recognized that the irreducible representations of \n$\\GL_n$ took on a particular form that made them amenable to admitting actions by symmetric groups. Then Schur could rely on \nFrobenius' development of the representation theory for $\\frakS_d$ to say something about $\\GL_n$.\n\n\\subsection{Notation}\nWe always use $\\frakS_d$ to denote the symmetric group on $d$ letters, and let $k$ be an infinite field (unless otherwise noted).\n\n\\subsection{Representations of Semigroups}\nRecall that a \\textbf{semigroup} is a group where we relax the inverse requirement. If we are interested in studying the representation \ntheory of a semigroup $\\Gamma$, there are some natural modules to consider:\n\\begin{ex}\n\t$k\\Gamma=\\bigoplus_{g\\in \\Gamma}kg$, the \\textbf{semigroup algebra} for $\\Gamma$ over $k$. Notice that if $\\Gamma$ is infinite, we only take \n\tthe elements that are supported at finitely many $g$ (that is, only finitely many coefficients are nonzero).\n\\end{ex}\n\\begin{ex}\\label{ex:bimod} $k^\\Gamma$, the set of all maps $\\Gamma\\to k$, which is naturally a commutative $k$-algebra. It inherits a $k\\Gamma$-bimodule structure \n\tby considering the left- and right-translation maps $L_g:k^\\Gamma\\to k$ and $R_g:k^\\Gamma\\to k$ defined for all $g\\in\\Gamma$ by \n\t\\[L_g(f)(h)= f(gh)\\qquad R_g(f)(h)=f(hg)\\]\n\tDue to the fact that $L_g$ defines the \\textit{right} action and $R_g$ the left, we write for simplicity:\n\t\\[g\\circ f=R_g(f)\\quad\\text{and}\\quad f\\circ g=L_g(f).\\]\n\\end{ex}\n\nIt is in the context of the $k\\Gamma$ module $k^\\Gamma$ that we get our first definition:\n\\begin{defn}\\label{defn-finitary}\n\tLet $k^\\Gamma$ be as above. Then an element $f:\\Gamma\\to k$ is called a \\textbf{finitary element} or \\textbf{representative function}\n\tif $f$ satisfies one of the following equivalent conditions:\n\t\\begin{itemize}\n\t\t\\item $k^\\Gamma f$ is finite dimensional over $k$.\n\t\t\\item $f k^\\Gamma$ is finite dimensional over $k$.\n\t\t\\item $\\Delta f\\in k^\\Gamma\\otimes k^\\Gamma$ -- in other words, the comultiplication $\\Delta f$ is finitely supported.\n\t\\end{itemize}\n\\end{defn}\n\\begin{rmk}\n\tThe collection of all finitary elements of $k^\\Gamma$ will be written $F=F(k^\\Gamma)$ and is a $k$-bialgebra -- in particular,\n\ta sub-bialgebra of $k^\\Gamma$.\n\\end{rmk}\n\\begin{rmk}\n\tThe reason such elements are called representative functions is that if we fix a finite dimensional $V$ over $k$ \n\tand a basis $\\calB$ for $V$, we can write down the structure maps of a particular $\\Gamma$ action by noticing \n\t\\[g\\cdot \\alpha=\\sum_{\\beta\\in\\calB}r_{\\alpha\\beta}(g)\\beta\\]\n\twhere $r_{\\alpha\\beta}:\\Gamma\\to k$ are called the \\textbf{coefficient functions} of the representation.\n\n\tThen the $k$-span $\\operatorname{cf}(V)=\\sum_{\\alpha,\\beta}k\\cdot r_{\\alpha\\beta}$ of coefficient functions for a particular (finite-dimensional) representation \n\t$V$ ends up being a subcoalgebra of $k^\\Gamma$ and in fact every finitary function lies in $\\operatorname{cf}(V)$ for some \n\tfinite-dimensional $V$. Here we can just take $V=k^\\Gamma f$ which is finite dimensional by defn~\\ref{defn-finitary}.\n\\end{rmk}\n\nAn important idea that comes from this that one can define an \\textbf{algebraic representation theory} of $\\Gamma$ over $k$. Take any subcoalgebra $A$ of $F=F(k^\\Gamma)$\nand define the $A$\\textbf{-representation theory} of $\\Gamma$ to be the full subcategory $\\mathbf{mod}_A(k\\Gamma)$ of $\\rmod (k\\Gamma)$ to be the one whose \nobjects are the (finite-dimensional) $k\\Gamma$ modules $V$ such that $\\text{cf}(V)\\subseteq A$.\n\nA nice result is that the (left) $A$-rational $k\\Gamma$-modules are equivalent to the category $\\mathbf{com}(A)$ of finite (right) $A$-comodules.\n\\begin{prop}\\label{prop-modcomod}\n\t$\\mathbf{mod}_A(k\\Gamma)\\simeq \\mathbf{com}(A)$\n\\end{prop}\n\\begin{prf}\n\t\\textit{Sketch:} Take an $A$-rational $k\\Gamma$ module $V$ with action $\\tau:\\Gamma\\to V$. Fix a basis $\\{v_i\\}_1^n$\n\tand as before extract the structure maps $r_{\\alpha\\beta}$:\n\t\\[\\tau(v_\\alpha)=\\sum_\\beta r_{\\alpha\\beta} v_\\beta.\\]\n\t\n\tThen define the comodule $(V,\\gamma)$ with coaction $\\gamma$ via \n\t\\[\\gamma(v_\\alpha)=\\sum_\\beta v_\\beta\\otimes r_{\\alpha\\beta}.\\]\n\tOne can check this defines a comodule structure on $V$. \n\n\tThe process reverses very easily, where one extracts the $r_{\\alpha\\beta}$ from the coaction.\n\tBy construction we will have that $r_{\\alpha\\beta}\\in A$, so we get the $A$-rationality for free.\n\n\tSome mopping up shows that these are equivalences of categories, which is pretty believable. \n\\end{prf}\t\n\\begin{rmk}\n\tOne of the most immediate consequences of this realization (it is barely a proof) is that we can define a left $A^\\ast=\\Hom_k(A,k)$-module (note that $A^\\ast$ is a $k$-algebra with the convolution product)\n\tstructure on any right $A$-comodule. We do this by writing for any $f\\in A^\\ast$\n\t\\[f\\cdot v=(\\1_V\\otimes f)(\\gamma(v))\\]\n\tor in coordinates \n\t\\[f\\cdot v_\\alpha=\\sum_\\beta f(r_{\\alpha\\beta})v_\\beta\\]\n\\end{rmk}\n\n\\section{Polynomial representations of \\texorpdfstring{$\\GL_n$}{GLn} and the Schur Algebra}\nFrom now on, we specialize the theory in the section above to the case when $\\Gamma=\\GL_n$ (we can think of this as the group scheme). \n\n\\subsection{Generators and Bases}\nThere are very natural choices of generators (as (co)algebras and as $k$ spaces). Starting off, we can define\n\\[A_k(n)\\cong k[\\omega_{ij}]\\]\nfor $1\\le i,j\\le n$, where we can think of $\\omega_{ij}:\\Gamma\\to k$ as the map that ``extracts'' from $g\\in\\Gamma$ the $(i,j)^{th}$ entry.\n\nThen $A_k(n)$ is the set of \\textbf{polynomial maps} $\\Gamma\\to k$. Then we define $A_k(n,r)$ to be the $k$-space spanned by all homogeneous degree $r$ \npolynomials in $A_k(n)$. A stars-and-bars argument gets us that there are $\\binom{n^2+r-1}{r}$ ways to choose a monomial of degree $r$ from among the $n^2$ generators,\nso this gives us the dimension of $A_k(n,d)$.\n\n\\subsection{Index Notation}\n\\label{subsec:index}\nWe need to use multi-indicies to rigorously discuss monomials so let $I(n,r)$ denote the set of length $r$ multi-indices drawn from $\\underline n$. Then \nwe can impose the equivalence relation: if $\\alpha,\\beta\\in I(n,r)$,\n\\[\\alpha\\sim\\beta \\quad\\Leftrightarrow\\quad \\alpha=(n_{i_1},\\dots,n_{i_r})\\text{ and } \\beta=(n_{i_{\\sigma(1)}},\\dots, n_{i_{\\sigma(r)}})\\]\nfor some $\\sigma\\in\\frakS_r$. That is, two multi-indices are equivalent if they contain the same indicies with the same multiplicities. Sometimes it is useful to think \nof this as a group action of $\\frakS_r$ on $I(n,r)$, and we say two elements are equivalent if they are in the same orbit.\n\nExtend this group action (and thus relation) to $I(n,r)\\times I(n,r)$ where $G$ acts diagonally:\n\\[g\\cdot(i,j)=(g\\cdot i,g\\cdot j).\\]\n\n\\subsection{Module Categories}\nThe module categories\\footnote{Equivalently the appropriate comodule categories in light of prop.~\\ref{prop-modcomod}} $\\mathbf{mod}_{A}(k\\Gamma)$ of \n(homogeneous degree $r$) polynomial representations of $\\GL_n(k)$ (when $A=A_k(n,r)$ and $A=A_k(n)$ respectively) are precisely what you'd think. We will sometimes \nuse the notation $M_k(n)$ and $M_k(n,r)$ following the text.\n\nOne of the big realizations of Schur's was that any polynomial representation of $\\GL_n$ splits into a direct sum of homogeneous polynomial representations:\n\\begin{thm}[{\\cite[p.5]{schur-thesis}}]\n\tLet $V\\in M_k(n)$. Then \n\t\\[V\\cong \\bigoplus_{r\\ge 0} V_r\\]\n\twhere $V_r\\in M_k(n,r)$ for all $r$.\n\\end{thm}\n\\begin{cor}\n\tThe indecomposable modules in $M_k(n)$ are all in $M_k(n,r)$ for some $r$.\n\\end{cor}\n\nBut then if we are interested in the structure of polynomial representations of $\\Gamma$, we can restrict our attention entirely to the homogeneous modules\nof any particular degree. The upshot here is that $A_k(n,r)$ is finite dimensional, so very computationally amenable.\n\n\\subsection{The Schur Algebra}\n\\begin{defn}\n\tThe \\textbf{Schur algebra} $S_k(n,d)$ is the dual of $A=A_k(n,d):$\n\t\\[S_k(n,d)=A^\\ast=\\Hom_k(A(n,d),k).\\]\n\\end{defn}\n\nWe can write down an explicit basis for $S_k(n,r)$ as a dual basis for the basis $\\{c_{ij}|i,j\\in I(n,r)\\}$ for $A_k(n,r)$. We denote this basis $\\xi_{ij}$, where \n\\[\\xi_{ij}(c_{kl})=\\begin{cases}\n\t1,& (i,j)\\sim (k,l)\\\\\n\t0,&\\text{otherwise}\n\\end{cases}\\]\nand we can define multiplication via the coproduct $\\Delta$ on $A_k(s,r)$:\n\\[\\xi\\eta(c)=\\sum \\xi(c_{(1)})\\eta(c_{(2)})\\]\nwhere we recall that $\\Delta(c_{ij})=\\sum_k c_{ik}\\otimes c_{kj}$ and $\\varepsilon(c)=c(I_n)$ are the coalgebra structure inherited on $A_k(n,r)$ \nfrom $A_k(n)$ and thus from $k^\\Gamma$.\n\n\\begin{prop}\n\tThe product of two basis elements in $S_k(n,r)$ is given by \n\t\\[\\xi_{ab}\\xi_{cd}=\\sum_{(p,q)\\in I(n,r)^2}Z_{a,b,c,d,p,q}\\xi_{pq}\\]\n\twhere \n\t\\[Z_{a,b,c,d,p,q}=\\#\\{s\\in I(n,r)|(a,b)\\sim(p,s)\\text{ and }(c,d)\\sim(s,q)\\}\\]\n\\end{prop}\n\\begin{cor}\n\t$\\xi_{ab}\\xi_{cd}=0$ if $b\\not\\sim c$.\n\\end{cor}\n\\begin{cor}\\label{cor:idempotent}\n\t$\\xi_{ab}\\xi_{bb}=\\xi_{ab}=\\xi_{aa}\\xi_{ab}$.\n\\end{cor}\n\nThe last thing here is to notice that $\\varepsilon=\\sum_{I(n,r)^2}\\xi_{ab}$ where equality can be seen by evaluating at the basis $c_{ab}$ of $A_k(n,r)$.\n\n\\subsection{The Evaluation Map}\nThere is a natural map $e:k\\Gamma\\to S_k(n,r)$ defined in the following way: if $f\\in A_k(n,r)\\subset k^\\Gamma$ (which can be uniquely extended $k$-linearly \nto a map on $k\\Gamma$),\n\\[e(\\kappa)(f)=f(\\kappa)\\]\nwhere $\\kappa\\in k\\Gamma$.\n\nThe use of this map is that (since it can be shown to be surjective and that things in the kernel of this map must act by zero on $M_k(n,r)$), that the category\nof $S_k(n,r)$ modules and the category of $A_k(n,r)$-rational $k\\Gamma$ representations are equivalent. The evaluation map gives us a direct translation between \nthe two actions: $\\kappa\\cdot v=e(\\kappa)\\cdot v$ and if $k\\Gamma$ acts on $V$ with structure maps $(r_{ab})$, then for $\\xi\\in S_k(n,r)$,\n\\[\\xi\\cdot v_b=\\sum_a \\xi(r_{ab})v_a\\]\n\n\\subsection{Modular Theory}\nWe can extract the $\\bbZ$ forms $A_\\bbZ(n)$ and $A_\\bbZ(n,r)$ as the $\\bbZ$ span of the basis elements $c_{ij}^\\bbQ$ (the basis with respect to $k=\\bbQ$). These \nare closed under $\\Delta$ and have the further property that for instance $\\varepsilon(A_\\bbZ(n,r))\\subseteq\\bbZ$.\n\nThen we can extend scalars in the way we'd like: there is a $k$-colagebra isomorphism \n\\[A_\\bbZ(n,r)\\otimes_\\bbZ k\\cong A_k(n,r),\\] \nso we can recover the larger algebra from this $\\bbZ$-form. But this actually transfers to the Schur algebra as well!\n\nDefine $S_\\bbZ(n,r)$ to be the collection of $\\xi\\in S_\\bbQ(n,r)$ such that $\\xi(A_\\bbZ(n,r))\\subseteq\\bbZ$. Then we get a $k$-algebra isomorphism\n\\[S_\\bbZ(n,r)\\otimes_\\bbZ k\\cong S_k(n,r).\\]\nThis gives us a $\\bbZ$-form for the scheme $S(n,r)$ -- or that ``the Schur scheme is defined over $\\bbZ$.''\n\nWe can also define a $\\bbZ$-form of a ($A_\\bbQ(n,r)$-rational) $\\bbQ\\Gamma$-module $V$ to be denoted $V_\\bbZ$ and to be the $\\bbZ$-span of a $\\bbQ$-basis for $V$\nand to furthermore be closed under the $S_\\bbZ(n,r)$-action (leveraging the equivalence of categories in the previous section).\n\nThis process of generating $V_k$ modules by extending scalars from a $\\bbZ$-form is called \\textbf{modular reduction}, and has a small caveat:\nthe $\\bbZ$-form we pick needn't be unique and, in general, using different $\\bbZ$-forms will yield non-isomorphic extensions to $k$-modules. The upshot here,\nfollowing the theory developed in \\cite{brauer} and \\cite{green-locFinReps}, is that the multiplicity with which simple modules occur in a composition series of $V_k$\nare not dependent on the choice of $\\bbZ$-form.\n\n\\subsection{The Trick}\nTo do some magic we notice that there is a duality at play between the $A_k(n,r)$-regular representations of $\\GL_n$ and the representations of $\\frakS_r$, \nand to see this we consider the natural action of these groups on $E^{\\otimes r}$, where $E\\cong k^n$. The left action by $\\Gamma$ is just the diagonal action \non each $k^n$ and $\\frakS_r$ acts on $E^{\\otimes r}$ on the right by permuting the tensor factors. The critical thing to notice here is that these two \nactions commute with one another:\n\\[(g\\cdot v)\\cdot\\sigma=g\\cdot(v\\cdot\\sigma),\\ \\forall g\\in\\Gamma, \\sigma\\in\\frakS_r.\\]\n\nThen we get some results from Schur's 1927 paper \\textit{\\\"Uber the rationalen Darstellungen der allgemeinen linearen Gruppe}, a reference to which I am yet to cook up.\n\\begin{thm}[Schur]\n\tLet $\\varphi:S_k(n,r)\\to \\End_k(E^{\\otimes r})$ be the representation afforded by the above action of $S_k(n,r)$. Then \n\t\\begin{itemize}\n\t\t\\item $\\Im \\varphi=\\End_{k\\frakS_r}(E^{\\otimes r})$; and \n\t\t\\item $\\ker\\varphi=0$.\n\t\\end{itemize}\n\tSo $S_k(n,r)\\cong \\End_{k\\frakS_r}(E^{\\otimes r})$.\n\\end{thm}\nThe idea here is to take our $\\xi_{ab}$ basis for $S_k(n,r)$ and determine where the images go. Not too hard, I think.\n\\begin{cor}[Schur]\n\tIf $\\ch k=0$ or $\\ch k>r$, then $S_k(n,r)$ is semisimple. That is every element of $M_k(n,r)$ is completely reducible.\n\\end{cor}\nTo see this, we just use the fact that $k\\frakS_r$ is semisimple as in usual representation theory. Thus $E^{\\otimes r}$ is \ncompletely reducible, but the endomorphism ring of a completely reducible module is semisimple, so by the above theorem, $S_k(n,r)$ is semisimple.\n\n\\subsection{Back to \\texorpdfstring{$\\bbZ$}{Z}-forms}\nIn fact, $E^{\\otimes r}$ is a $\\GL_n$-module (this time regarded as an affine group scheme over $\\bbZ$). Let $\\{V_k\\}$ be a collection \nof $k$-modules for each $k$ in some family of infinite fields. Then we say $\\{V_k\\}$ is \\textbf{defined over $\\bbZ$} if there is a $\\bbZ$-form $V_\\bbZ$\nand a family of isomorphisms $\\delta_k:V_\\bbZ\\otimes k\\to V_k$.\n\nIn particular, the family of modules $E^{\\otimes r}_k$ is defined over $\\bbZ$.\n\n\\subsection{Contravariant Duality}\nIn group theory a usual way to define a dual representation for a $k\\Gamma$-module $V$ is to take the linear \ndual $V^\\ast=\\Hom_k(V,k)$ and define a left action of $\\Gamma$ by \n\\[g\\cdot f(v)=f(g^{-1}v)\\]\nwhich give you another (left) $k\\Gamma$-module. The problem with this process in our case is that the resulting \nmodule may have structure maps $r_{ab}$ that no longer lie in $A_k(n,r)$. To account for this, we instead define the \n\\textbf{contravariant dual} $V^\\circ$, defined using the transpose:\n\\[g\\cdot f=f(g^{\\text{tr}}v).\\]\n\nIt is clear that the map $J:S_k(n,r)\\to S_k(n,r)$ sending $\\xi_{ab}$ to $\\xi_{ba}$ is an involutory antihomomorphism.\nNotice \n\\[J(\\xi)(c_{ab})=\\xi(c_{ba})\\]\nand so by taking $\\xi=e_g$, we get \n\\[J(e_g)(c_{ab})=e_g(c_{ba})=c_{ba}(g)=c_{ab}(g^{\\text{tr}})\\]\nso $J(e_g)=e_{g^{\\text{tr}}}$.\n\nSo given an $A_k(n,r)$-rational $k\\Gamma$ representation $V$, the corresponding $S_k(n,r)$ action on $V^\\circ$ is given by \n\\[\\xi\\cdot f (v)=f(J(\\xi)v).\\]\n\n\\subsection{\\texorpdfstring{$A_k(n,r)$}{Ak(n,r)} as a \\texorpdfstring{$k\\Gamma$}{kGamma}-module}\nRecall from example~\\ref{ex:bimod} the left and right actions by $k\\Gamma$ we put on $k^\\Gamma$. The coproduct $\\Delta$ on $k^\\Gamma$\ndefining multiplication in the usual way, that is\n\\[\\left(\\sum_h f_h\\otimes f_h'\\right)(s,t)=\\Delta(f)(s,t)=f(st)\\]\ngives us a convenient way to write, for any $c\\in A_k(n,r)$, (since $R_tc(g)=c(gt)=\\sum_h f_h(g)\\otimes f_h'(t)=L_g c(t)$)\n\\[t\\circ c= R_t c=\\Delta(c)(-,t)=\\sum_h f_h(-)f_h'(t)=\\sum_h f'_h(t)f_h\\]\nand similarly\n\\[c\\circ t=\\sum_h f_h(t)f'_h.\\]\nThese can be extended linearly from $t\\in\\Gamma$ to $k\\Gamma$, giving us (commuting) left and right actions on $A_k(n,r)$.\n\nThen some results in the book show that these actions on $A_k(n,r)$ by $k^\\Gamma$ descends to ones by $A_k(n,r)$ itself, \nand thus becomes an $A_k(n,r)$- and thus $S_k(n,r)$-bimodule.\n\nOf course this gives us a $k\\Gamma$-bimodule structure on $S_k(n,r)$ as well, and then using the following:\n\\begin{thm}\n\tContravariant bilinear forms $(\\cdot,\\cdot):V\\times W\\to k$ where by contravariant we mean, for all $\\xi\\in S_k(n,r)$,\n\t\\[(\\xi\\cdot v,w)=(v,J(\\xi)\\cdot w)\\]\n\tare in bijection with linear maps $\\Lambda:V\\to W^\\circ$ via the relation \n\t\\[\\Lambda(v)(w)=(v,w).\\]\n\tFurthermore $\\Lambda$ is an isomorphism if and only if its corresponding form under this bijection is non-degenerate.\n\\end{thm}\nThen by letting $(\\cdot,\\cdot):S_k(n,r)\\times A_k(n,r)\\to k$ (a form on $S_k(n,r)$-modules!) be the form given by \n\\[(\\xi, c)=J(\\xi)(c)\\]\none can check that this is indeed bilinear and contravariant, and furthermore non-degenerate, giving us an isomorphism \n\\begin{cor}\n\t\\[A_k(n,r)\\cong S_k(n,r)^\\circ\\]\n\tas $k\\Gamma$-bimodules.\n\\end{cor}\n\\begin{rmk}\n\tThe book is a bit scant on details, but I believe the idea here is that this whole thing can be done in $M'_k(n,r)$, the \n\tcategory of \\textit{right} $S_k(n,r)$-modules, giving us a bimodule (instead of right module) isomorphism.\n\\end{rmk}\n\n\\section{Weights and Characters}\nThe structure theory of representation category $M_k(n,r)$ closely resembles the theory of weights that arises in the study of \nsemisimple Lie algebras. The standard reference is \\cite{humphreys-liereps}, however I have recently been enjoying Fulton \\& Harris' \nlovely set of lectures in \\cite{fulton-harris}. I am going to take some time to make sure I understand their treatment before diving into this fully.\n\n\\begin{defn}\n\tLet $\\Lambda(n,r)$ be the $\\frakS_r$ orbit space of $I(n,r)$ (cf. subsection~\\ref{subsec:index}). This is called the (dimension $r$)\n\tcollection of \\textbf{weights of $\\GL_n$}.\n\n\tNotice that these should be thought of a monomials in the polynomial algebra on $n$ indeterminates.\n\\end{defn}\n\\begin{rmk}\n\tNotice that each element $\\alpha\\in\\Lambda(n,r)$ can be represented as an $n$-tuple where $\\alpha_i$ is the number of times \n\tthat $i$ appears in any multi-index in $\\alpha$. This is essentially the multi-degree.\n\\end{rmk}\n\nThen we can identify $\\frakS_n=W$ as the Weyl group of $\\GL_n$. This acts on the left of $I(n,r)$ not by simply permuting labels, but by applying \na permutation from the bigger $\\frakS_n$:\n\\[\\sigma\\cdot(i_1,\\dots,i_r)=(\\sigma(i_1),\\dots,\\sigma(i_r)).\\]\nThis action commutes with the right action of $\\frakS_r$, so this action we just defined descends to one on $\\Lambda(n,r)$.\n\\begin{defn}\n\tA \\textbf{dominant weight} is a weight $\\lambda=(\\lambda_1,\\dots,\\lambda_r)\\in\\Lambda(n,r)$ such that \n\t\\[\\lambda_1\\ge\\cdots\\ge\\lambda_r.\\]\n\tDenote the set of all dominant weights in $\\Lambda(n,r)$ as $\\Lambda^+(n,r)$.\n\\end{defn}\n\\begin{rmk}\n\tNotice that each $W$-orbit in $\\Lambda(n,r)$ has a unique dominant weight (although it may be achieved multiple times).\n\\end{rmk}\n\\begin{rmk}\n\tElements in $\\Lambda^+(n,r)$ correspond bijectively to partions of $r$ into not more than $n$ parts.\n\\end{rmk}\n\\subsection{Weight Spaces}\nNow notice that corollary~\\ref{cor:idempotent} gave us that $\\xi_{ii}^2=\\xi_{ii}$ and the corollary before gave us $\\xi_{ii}\\xi_{jj}=\\delta_{ij}$. Then the correspondence between $A_k(n,r)$-rational \nrepresentations and $S_k(n,r)$ modules gives us that (for $V\\in M_k(n,r)$):\n\\[\\varepsilon(v)=e(1_\\Gamma)(v)=1_\\Gamma\\cdot v=v\\]\nand the decomposition\\footnote{Note that here we are using that $\\xi_{ii}=\\xi_{jj}$ if and only if $i\\sim j$, so we can represent $\\xi_{ii}$ \nby orbit $\\alpha$ of $i$ under $\\frakS_r$.} $\\varepsilon=\\sum_{\\alpha\\in\\Lambda(n,r)}\\xi_\\alpha$,\n\\[V=\\varepsilon(V)=\\sum_{\\alpha\\in\\Lambda(n,r)}\\xi_{\\alpha}V\\]\ngiving us our decomposition into weight spaces. To see{ this we show that \n\\[\\xi_\\alpha V= V^\\alpha=\\{v\\in V|x(t)v=t_1^{\\alpha_1}\\cdots t_n^{\\alpha_n}v,\\; \\forall x(t)\\in T_n(k)\\}\\]\nwhere $T_n(k)$ is the maximal split torus consisting of diagonal matrices in $\\GL_n(k)$. Here the notation is that \n\\[x(t)=\\operatorname{diag}(t_1,\\dots,t_n).\\]\n\\begin{rmk}\n\tDefine the character $\\chi^\\alpha:T_n(k)\\to k$ via \n\t\\[\\chi^\\alpha(x(t))=t_1^{\\alpha_1}\\cdots t_n^{\\alpha_n}\\]\n\\end{rmk}\nThen we have the result \n\\begin{prop}\n\t\\[\\xi_\\alpha V= V^\\alpha\\]\n\\end{prop}\n\\begin{prf}\n\tTo see this, we begin by computing the image of $c_{i,j}$ under the image of $e_{x(t)}$ and $\\sum_{\\alpha}\\chi^\\alpha(x(t))\\xi_\\alpha$:\n\t\\[e_{x(t)}(c_{i,j})=\\prod_k c_{i_kj_k}(e_{x(t)})\\]\n\twhich is zero unless $i_k=j_k$ for all $k$--in other words, if $i=j$. Then in this case, \n\t\\[e_{x(t)}(c_{i,i})=\\chi^\\alpha(x(t))\\]\n\twhere $\\alpha$ is the weight associated to $i$.\n\n\tComputing from the other end, $\\xi_\\alpha(c_{ij})=0$ unless $\\alpha$ is the weight of $i$ and \n\t$j=i$. If $i=j$, a single term is nonzero--the summand corresponding to $\\alpha$, the weight of $i$, giving us $\\chi^\\alpha(x(t))$.\n\n\tSince the $S_k(n,r)$ action via $e_{x(t)}$ corresponds to the $\\GL_n$ action via $x(t)$. Then take any element $w\\in\\xi_\\alpha V$ and using that the \n\t$\\xi_{i,i}$ are orthogonal idempotents, we can compute the action of $T_k(n)$ on $\\xi_\\alpha V$:\n\t\\[x(t)\\cdot v=e_{x(t)}v=t_1^{\\alpha_1}\\cdots t_n^{\\alpha_n} v\\]\n\tso $v\\in V^\\alpha$.\n\n\tNow if $v\\in V^\\alpha\\cap V^\\beta$, consider the action by $A=\\operatorname{diag}(2,1,1,\\dots,1)$. Then since \n\t\\[A\\cdot v=2^{\\alpha_1}v=2^{\\beta_1}v\\]\n\tthis forces $\\alpha_1=\\beta_1$ and similar arguments show that $\\alpha=\\beta$. Thus the sum of $V^\\alpha$'s are direct and since their sum is all of $V$ (since their sum \n\tcontains the sum of the $\\xi_\\alpha V$), we get that these summands are precisely the $\\xi_\\alpha V$.\n\\end{prf}\n\\begin{rmk}\n\tA very useful consequence here is that we have a subalgebra $D_k(n,r)\\subseteq S_k(n,r)$ spanned over $k$ by the $\\xi_\\alpha$ for $\\alpha\\in\\Lambda(n,r)$\n\tThis is the image of $T_k(n)$ under the evaluation map $e$.\n\\end{rmk}\n\nAnother useful fact: the weight spaces $V^\\alpha$ are stable under the $\\frakS_n$ action (up to isomorphism).\n\\begin{prop}\n\tLet $\\omega\\in\\frakS_n$. Then \n\t\\[V^\\alpha\\cong V^{\\omega(\\alpha)}.\\]\n\\end{prop}\n\\begin{prf}\n\tThe proof of this boils down to noticing that the action of $\\GL_n$ on $V^{\\omega(\\alpha)}$ is the same of a translated \n\tversion of $\\GL_n$. Specifically, let $\\eta_\\omega$ be the permutation matrix taking the standard basis to $\\{e_{\\omega(1)},\\dots,e_{\\omega(n)}\\}$.\n\tThen \n\t\\[x(t_{\\omega(1)},\\dots,t_{\\omega(n)})=\\eta_\\omega^{-1}x(t_1,\\dots,t_n)\\]\n\tso application of $n_\\omega$ yields an isomorphism from $V^\\alpha$ to $V^{\\omega(\\alpha)}$.\n\\end{prf}\nThe restriction to the $\\alpha$-weight elements is an exact functor!\n\\begin{prop}\n\tIf \n\t\\[0\\to A\\to B\\to C\\to 0\\]\n\tis a short exact sequence of elements in $M_k(n,r)$, then so is \n\t\\[0\\to A^\\alpha\\to B^\\alpha\\to C^\\alpha\\to 0\\]\n\tfor all $\\alpha\\in\\Lambda(n,r)$.\n\\end{prop}\n\\begin{prf}\n\tLeft exactness is immediate since this functor acts on morphisms by restriction to a subspace. Right exactness follows since for \n\tany $\\xi^\\alpha c\\in\\xi^\\alpha C$, since the map $g:B\\to C$ is surjective, there is a $b\\in B$ mapping to $c$. But then \n\t$\\xi^\\alpha b\\in\\xi^\\alpha B$ and its image is \n\t\\[g(\\xi^\\alpha b)=\\xi^\\alpha g(b)=(\\xi^\\alpha)^2c=\\xi^\\alpha c\\]\n\tsince $\\xi^\\alpha$ is idempotent.\n\\end{prf}\n\n\\subsubsection{Extending Scalars}\nNotice that a simple computation using linear algebra and counting degrees gets us that \nfor any $V\\in M_k(n,r)$ and $W\\in M_k(n,s)$, we can define the module $V\\otimes W\\in M_k(n,r+s)$ \nwhere if $\\gamma\\in \\Lambda(n,r+s),$ the weight spaces are\n\\[(V\\otimes W)^\\gamma=\\bigoplus_{\\alpha,\\beta}V^\\alpha\\otimes W^\\beta\\]\nwhere the sum is over all $\\alpha$ and $\\beta$ whose sum is $\\gamma$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%  Bibliography %%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\medskip\n\n\\printbibliography\n\n\\end{document}", "meta": {"hexsha": "f4fa454b2e17e061c393a3f8a6acbe1716798a09", "size": 25648, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SW-Functor.tex", "max_stars_repo_name": "NicoCourts/Schur-Weil-Functor", "max_stars_repo_head_hexsha": "11480c1da061ddf57b56f2abf0fb7d3b4aad152d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SW-Functor.tex", "max_issues_repo_name": "NicoCourts/Schur-Weil-Functor", "max_issues_repo_head_hexsha": "11480c1da061ddf57b56f2abf0fb7d3b4aad152d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SW-Functor.tex", "max_forks_repo_name": "NicoCourts/Schur-Weil-Functor", "max_forks_repo_head_hexsha": "11480c1da061ddf57b56f2abf0fb7d3b4aad152d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.1587301587, "max_line_length": 206, "alphanum_fraction": 0.6998986276, "num_tokens": 8238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.42423963859916697}}
{"text": "\\paragraph{}\nIn the traditional approach, geometric design and analysis are treated as separate modules requiring different methods and interpretations.\nFor example, the geometric design module employed non-uniform rational B-splines (NURBS) introduced in Sec.~\\ref{lr_sec:NURBS} to describe the geometry, whilst the analysis module consisted of one of the following\n\\begin{enumerate}\n    \\item Mesh based discrete models, such as the finite element method (FEM) \\citep{doi:10.1111/j.1467-8667.1989.tb00025.x}\n    \\item Boundary based methods, such as the boundary element method (BEM) \\citep{book}, scaled boundary finite element method (SBFEM) \\citep{Son1997}\n    \\item Meshless methods \\citep{article123213eds}\n\\end{enumerate}\nThe approximation space employed in the analysis module to describe both the geometry and the fields is different from that used in the CAD system.\nHence it requires repetitive conversion between the CAD and the analysis and in this process errors are inevitable.\nMoreover, the analysis module employs polynomials that do not lead to exact representation of the geometry, whilst the geometric module employs Bézier representations that use Bernstein polynomials or B-splines and NURBS that employ de Boor polynomials \\citep{Pie1997}.\nThe above representations utilize basis functions and control points to represent the geometry, in addition to this, B-splines and NURBS also utilize a vector\nof knots.\nNURBS further use weights to control points to model intricate shapes.\n\n\\paragraph{}\nAs a consequence, the concept of isogeometric analysis is proposed \\citep{Hug2005}, in which the conventional Lagrange polynomials are replaced with the NURBS basis functions.\nThe concept of isogeometric analysis (IGA) has revolutionized the analysis procedure.\nThe IGA provides a natural link with the CAD model.\nA key feature of this framework is that the geometry is represented exactly by NURBS and the isoparametric concept is invoked to define the field variables.\nSince its inception, the method has been applied to a variety of problems such as plates and shells \\citep{NGUYENTHANH20113410,NGUYENXUAN2014222,HOSSEINI20141}, as\ncohesive elements \\citep{NGUYEN2014193}, for shape optimization \\citep{WALL20082976}, fluid–structure interaction problems \\citep{BAZILEVS201228}, problems with strong discontinuities and singularities \\citep{doi:10.1093/imamat/hxu004, doi:10.1002/nme.4580, BAZILEVS201228}, optimization problems \\citep{GHASEMI2014463} to name a few.\nJia et al. \\citep{JIA2013342} by incorporating reproducing kernel approximation methods, alleviated the instabilities of the conventional triangular B-spline element.\nThe new approach yielded improved convergence rate and accuracy when compared to the conventional triangular B-spline element.\nThis seems to be a promising alternative to NURBS and T-splines where considerable effort is required for local refinements. \nIn the conventional IGA, the surfaces/volumes are represented by the tensor product of the corresponding knot vectors.\nThis requires the domain to be discretized with standard shapes and leads to a restricted number of boundary curves/surfaces.\nAlso, this leads to excessive overhead of control points with refinement.\nThis can be circumvented by adopting local refinement as proposed \\citep{NGUYENTHANH20111892} or by employing T-splines \\citep{Sederberg:2003:TT:882262.882295}.\nRecently, Simpson et al. \\citep{Sim2013, SIMPSON201287} proposed the isogeometric boundary element method (IGABEM), in which the NURBS functions were used to approximate the unknown fields.\nThis framework circumvents the need to discretize the domain, as required by the IGAFEM.\nIt was shown that the IGABEM is more accurate than the conventional BEM with polynomial interpolations.\nFurthermore, Scott et al. \\citep{Sco2013} and Simpson et al. \\citep{SIMPSON2014265} combined the collocated IGABEM with T-splines for linear elastostatics and acoustic analysis, respectively.\nThe concept of IGABEM was further extended to damage tolerance assessment \\citep{PengXuan;AtroshchenkoElena;Bordas2014} and shape sensitivity analysis \\citep{LianHaojie;SimpsonRobert;Bordas2013}.", "meta": {"hexsha": "7704193b4d800f8ed2637510920ad822a22d376a", "size": 4158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "literature/lr_iso.tex", "max_stars_repo_name": "fa93hws/thesis", "max_stars_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-30T12:14:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-30T12:14:47.000Z", "max_issues_repo_path": "literature/lr_iso.tex", "max_issues_repo_name": "fa93hws/thesis", "max_issues_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "literature/lr_iso.tex", "max_forks_repo_name": "fa93hws/thesis", "max_forks_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.2941176471, "max_line_length": 334, "alphanum_fraction": 0.8234728235, "num_tokens": 995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.42423963824027305}}
{"text": "\\section{Many-body definition of Chern number}\nI want to talk about the many-body definition of Chern number.\n\nFor every band you can assign a Chern number.\nAt the face of it,\nit's only a property of band structure,\nof single-particle TI system.s\nThere's 2 pieces of evidence for something more general.\n\n1. The Chern number dictate th Hall conductivity,\nwhich is quantized.\nSo if the Hall conductivity is given by an integer invariant in the free band\ntheory,\nas you slowly turn on interaction,\nthat shouldn't change,\nso there should also be a quantized invariant for that\nbut how do you extract that from the GS wave function.\n2. I had a continuum Dirac theory,\nthat you have a mass term,\nand integrate out the other degrees of freedom.\nIn that field theory,\nyou can have higher order field theory interaction\nand you get a 4-fermion interaction that is irrelevant by RG,\nwhich you ignore,\nso you still have this integer quantity that is still defined if you change\nthe sign of the mass.\n\nSo the Chern number should be well-defined for interacting systems that doesn't\nrequire TI.\n\nI will give you multiple ways of calculating the Chern number fro GS\nwavefunctions.\n\n\nHall conductivity and twisted boundary conditions.\nSuppose we put our system on a torus,\nand we insert flux on both holes of the torus,\nso consider changing the vector potential in the $x$ and $y$ directions.\n\\begin{align}\n    \\delta A_x &=\n    \\frac{\\Phi_0}{L_x} \\frac{\\theta_x}{2\\pi}\\\\\n    \\delta A_y &= \n\\end{align}\nadding these fluxes changes the Hamiltonian,\nand we get a term that looks like the gauge fields coupling to the current\n\\begin{align}\n    \\delta H &=\n    \\int d^2x \\, \\delta A_i J^i\\\\\n    &=\n    - \\sum_{i=x,y} \\frac{\\Phi_0}{L_i} \\frac{\\theta_1}{2\\pi}\n    \\int d^2 x\\, J^i\n\\end{align}\nand $H[\\theta_x, \\theta]$\nTwisted boundary conditions vs flux through the hole of the torus are related by\nsingular gauge transformations.\nGiven this Hamiltonian,\nwe have a ground state wave function of this Hamiltonian\n\\begin{align}\n    \\ket{\\Psi(\\theta_x, \\theta_y)}\n\\end{align}\nfrom which we can construct the Berry connection,\njust like before in momentum space.\n\nSo I can define\n\\begin{align}\n    A_j(\\theta_x, \\theta_y) &=\n    -i \\bra{\\psi(\\theta_x, \\theta_y)}\n    \\frac{\\partial}{\\partial \\theta_j}\n    \\ket{\\psi(\\theta_x, \\theta_y)}\n\\end{align}\nand from this we can define a field strength\n\\begin{align}\n    F_{ij} &= \\partial_i A_j - \\partial_j A_i\n\\end{align}\nAnd here the closed surface is the torus,\nbecause $\\theta_x$ can go from $0$ to $2\\pi$,\nand once it's $2\\pi$,\nwe can do a large gauge transformation\nto relate it to the system without the flux.\nAnd we get\n\\begin{align}\n    C &=\n    \\frac{1}{2\\pi}\\int d^2\\theta\\,\n    F\n    \\in \\mathbb{Z}\n\\end{align}\nAnd this is really an integral over the torus.\n\\begin{align}\n    \\theta_x $\\sim \\theta_x + 2\\pi\\\\\n    \\theta_y $\\sim \\theta_y + 2\\pi\n\\end{align}\nThe BZ was a torus,\nbut here the space is also a torus.\nWe integrate this field strengh over a closed surface,\nit has to be an integer from thes ame argument I gave before.\n\nIf we look at hte $\\theta$-dependence,\n\\begin{align}\n    \\frac{\\delta H}{\\delta \\theta_i} &=\n    \\frac{\\Phi_0}{L_i} \\frac{1}{2\\pi}\n    \\underbrace{%\n    \\int d^2x\\,\n    J_i\n    }_{\\text{0-momentum part of current}}\n\\end{align}\nand so we will be able to relate the Chern number\nto some current-current corelation function,\nwhich shoud be related to the Hall conductivity.\nIn fact,\nyou can prove that the Hall conducivity is\n\\begin{align}\n    \\sigma_H &=\n    \\frac{e^2}{h} \\frac{1}{2\\pi} F_{xy}(\\theta_x, \\theta_y)\n\\end{align}\nThe proof is in the homework.\nThe relation between the Hall conductivity and the Chern number is that if you\naverage the Hall conductivity over the space of wave funtions,\nthe you find\n\\begin{align}\n    \\langle \\sigma_H \\rangle\n    = C \\frac{e^2}{h}\n\\end{align}\nthat is,\nthe average over twisted boundary conditions.\nIn fact,\nyou find\n\\begin{align}\n    \\sigma_H &= \\langle \\sigma_H \\rangle_{BC's}\n\\end{align}\nPeople understood you get thse two formulae\nand you should expect the Hall conducitvity is an average over boudnar\nyconditions,\nand witha gapped system,\nno quantity should care what the flux is thorugh these non-contractible cycles,\nin the infinite system size,\nbecause there is a finite-correlation lngh.\nIf hte cycle is large,\nlocally you need some coherenetnce thorugh the yccle,\nso you need some correlation length that scales with teh size of the system.\nIntuitively,\npeople expected\nbut in a tour-de-force of mathematical physics a decade,\nthis was proven about 2010 by Hastings and Michalakis.\n\nIf you think of inserting flux,\nor you can do a singular gauge transformation,\nremove the flux,\nand do some twisted boundary conditions,\nand the twist is the $\\theta$.\nYou can relate\n\\begin{align}\n    \\psi\\left( r_1, r_2, \\ldots, r_N \\right) &=\n    e^{i\\theta_x}\\psi\\left( r_1 + L_x \\hat{x}, r_2,\\ldots \\right)\n\\end{align}\nand the point is,\nthat this is related by a singular gauge transformation.\nI'm not spelling out the whole story, because I assume you know already.\n\nThe main lesson,\nis that this way of defining Chern number\ngives a way to define an integer invariant in a many-body system.\nWe can define a Chern number for any $U(1)$ symmetry,\nbecause the moment I have a U(1) symmetry,\nI can turn on a background gauge field,\nand insert flux through that torus,\nand define a symmetry associated with it.\nSo every U(1) symmetry can have a  Chern number associated with it,\nand that gives a way to define a U(1) symmetry in a gapped many-body system.\nAnd there's few things I want to emphasize here.\n\nThis thing is intrinsically many-body.\nNot a single free fermions,\nnot assuming translationally invariant.\nSo not band theory.\n\nWe also assumed implicitly that the system has a unique ground state.\n\nThis definition of the Chern number so far assumes you have a unique ground\nstate.\nWe're adiabatically inserting flux,\nbut in some system like fractional quantum hall effect,\nif you insert integer flux,\nyou actually wind to a different ground state,\nso you need many flux quanta to wind up in the same ground state.\nSo here with $2\\pi$ flux,\nyou end up with the same exact ground state.\nWe get this Berry phase by moving around in one direction,\nand if you consider may directions,\nyou get a single ground ate.\n\nWe can still define a Chern number with degenerate ground sates,\nbut there is an index here,\nand this is a non-Abelian gauge field,\nand this field strength because a non-Abelian gauge field,\nand we need some extra fields,\nand the Chern number is the trace of that field strength.\nYou can still define Chern number,\nbut it's not a U(1).\nI won't say anything more.\nYou can do it,\nbut you need to consider non-Abelian Berry gauge fields.\n\n\\begin{question}\n    To go to a non-Abelian symmetry,\n    how would we do that?\n\\end{question}\nSo now you're saying,\nsuppose we have $SU(2)$ symmetry,\ncan you still define a Chern number?\nThe quick way to answer this question is,\nChern number we associated with an effective action\nand the coefficient was the Chern number.o\nWith SU(2),\nyou turn on non-Abelian SU(2) gauge fields,\nthen write down a non-Abelian CS theory,\nand that will also have a coefficient that is also a Chern number.\nThere will be a Chern number,\nbut to define it,\nyou're going to consider.\nThen what you do is insert flux associated with some U(1) subgroup of\nSU(2)\nJust compute it for some U(1) subgroup.\nI said that quickly,\nbecause I didn't explain.\n\n\\begin{question}\n    what about discrete groups instead of U(1)?\n\\end{question}\nWe can write down\n\\begin{align}\n    S_{CS}[A] = \\int \\frac{C}{4\\pi} A\\, dA\n\\end{align}\nbut this doesn't make sense if you have some net flux through your manifold,\nlike a net magnetic monopole,\nyou can't globally define $A$,\nand make sense.\nBut here is a remedy,\nand it is to go to group cohomology.\nI'll just stop there.\nOnce you view the Chern-Simons theory through that more appropriate lens,\nthen that framework you can easily extend to discrete groups.\n\n\\begin{question}\n    Why not glue the state to $SU(2)$ state at the boundary?\n\\end{question}\nLet me say just a bit more about this $SU(2)$ case\nFor $SU(2)$ symmetry\nyou would consider SU(2) gauge fields.\nAnd the effective action would be some integer\n\\begin{align}\n    S_{\\text{eff}} &=\n    \\frac{C}{8\\pi}\n    \\int \\Tr\\left( \n    A\\wedge dA\n    + \\frac{2}{3} A \\wedge A \\wedge A\n    \\right)\n\\end{align}\nIf the goal was just to know $C$,\nyou can pick $A$ to live in some $U(1)$ subgroup,\nevaluate the action,\nand figure out what this coefficient is.\nYou know the whole thing si $SU(2)$ invariatn,\nso you can just pick $A$ to be in a particular $U(1)$ sugroup,\nthen evaluate to figure out what the coefficient is.\n\nIn general,\nyou could imagine you have some $SU(2)$ flux here,\nbut you can do an $SU(2)$ rotation,\nso this $\\theta_x$ lies in some $U(1)$ subgroup,\nbut then you have to wrory about thsi $\\theta_y$.\nIt's not the most general thing to do,\nto figure out Chern number,\njust have $A$ lie in some subgroup,\nand evaluate the subgroup frmo there.\nOnce you figured out hte Chern number,\nthere is only one possible Chern number.\n\nI'm just giving you a trick to calculate the Chern number in the $SU(2)$ case.\nIt doesn't map analogously.\n\nIn general,\nyou could imagien in the $x$ direciton,\nyocuould have a genera l$SU(2)$ matrix,\nand you tyr to cnostruct something like the $A_j(\\theat_x,\\theta_y)$ formula.\nBut I haven't thought about tha procedure.\n\n\\begin{question}\n$C$ here can be any integer,\nbut is it still integer for $SU(2)$?\n\\end{question}\nThe CS theory for $U(1)$,\nwe usually write as\n\\begin{align}\n    S_{eff}^{U(1)} &=\n    \\frac{C_{U(1)}}{4\\pi}\\int A\\, dA\n\\end{align}\nbut for $SU(2)$,\n\\begin{align}\n    S_{\\text{eff}} &=\n    \\frac{C}{8\\pi}\n    \\int \\Tr\\left( \n    A\\wedge dA\n    + \\frac{2}{3} A \\wedge A \\wedge A\n    \\right)\n\\end{align}\nNote the $4\\pi$ vs $8\\pi$.\nFor bosonic systems,\n\\begin{align}\n    C_{U(1)} &\\in 2\\mathbb{Z},\\\\\n    C_{SU(1)} &\\in 2\\mathbb{Z},\n\\end{align}\nBut for fermionic system,s\n\\begin{align}\n    C_{U(1)} &\\in \\mathbb{Z}\\\\\n    C_{SU(1)} &\\in \\mathbb{Z}\n\\end{align}\n\n\\section{Thouless Pond}\nLet's view the Chern number from polarization in 1D.\nRecall if we put our system on a cylinder,\nand insert flux through the cylinder.\nLet's say we have some $\\theta_x = \\Phi$ flux.\nAnd the cyclinder is alnog the $x$ direciton.\nThis causaes an electric field in the $y$ direciton,\nwhich auses a current $j_x$.\nCharge is flooiwng alon the $x$ direciton,\nand if you view htis as 1D system,\nthe polarization is changing with time that gives rise to the current.\nThink about the Chern number in terms of the polarizaiton of this effecively 1D\nsystem.\n\nThat's the perspective,\nand see how it relates to the Chern number in 2D.\n\nLet's start off discussing dimensional reduction of a 2D tight binding model.\nSuppose we have a tight-binding model on a cylinder.\n$x$ is alnog, $y$ is around the cylinder,\nbecause $y$ is periodic, $k_y$ is a good quantum number.\n\nIt's a cylinder in the sense there are boundaries at the two ends\nin the $x$ direction.\nWe can do a fermion operator,\nwith band $\\alpha$.\n\\begin{align}\n    C_{k_{y,\\alpha}} &=\n    \\frac{1}{\\sqrt{L_y}}\n    \\sum_y C_{\\alpha}(x, y)\n    e^{i k_y y}\n\\end{align}\nthe Hamiltonian is\n\\begin{align}\n    H &= -\\sum_{ij} t_{ij} c_i^\\dagger c_j + \\textrm{h.c.}\\\\\n    &= \\sum_{k_y} H_{1D}[k_y]\n\\end{align}\nIt's a sum of independent 1D systems where $k_y$ is just some parameter now.\nYou can think of your system as a bunch of $L_y$ different 1D chains.\nFor this 1D system,\n$k_y$ is effective just some number.\n\nLet's insert flux.\n\\begin{align}\n    A_y &= - E_y t = \\frac{\\Phi(t)}{L_y}\\\\\n    A_x &= 0\n\\end{align}\nwhere $E_y$ is the electric field.\nYou can think of it as.\n\\begin{align}\n    H &= \\sum_{k_y} H_{1D}\\left( k_y + A_y \\right)\n\\end{align}\nand this causes a current,\nand remember the Hamiltonian is decoupled in $k_y$,\n\\begin{align}\n    J_x &=\n    \\sum_{k_y} J_{1D}(k_y).\n\\end{align}\nLet's calculate the charge flowing across the cylinder\n\\begin{align}\n    \\Delta Q &=\n    \\int_{0}^{\\Delta t} dt\\,\n    \\sum_{k_y} J_{1D}(k_y)\n\\end{align}\nNow,\nwhat's happening is,\nyou can think of this $J_{1D}(k_y)$,\nas having some polarization,\nand the current is the time derivative of this 1D system.\n\\begin{align}\n    J_{1D}(k_y) &=\n    \\frac{d P_{1D, x}(k_y)}{dt}\n\\end{align}\nso a changing polarization leads to a current,\ncharged being pumped in that direction.\nAnd this is just\n\\begin{align}\n    \\Delta Q &=\n    \\int_{0}^{\\Delta t} dt\\,\n    \\sum_{k_y} J_{1D}(k_y)\n    =\n    \\left.\\sum_{k_y} \\Delta P_x (k_y)\\right|_{0}^{\\Delta t}\\\\\n    &=\n    \\left.\\frac{L_y}{2\\pi} \\int_{0}^{2\\pi} dk_y\\,\n    \\Delta P_x(k_Y)\\right|_{0}^{\\Delta t}\n\\end{align}\nAnd we're inserting flux in the adiabatic limit,\nand say we insert one flux quanta.\n\\begin{align}\n    E\\, \\Delta t &=\n    \\frac{2\\pi}{L_y}\n\\end{align}\nand here\nI'm assuming all units are 1.\nAnd the change in polarization is just going to be\n\\begin{align}\n    \\Delta P_x (k_y) &=\n    P_x\\left( k_y + \\frac{2\\pi}{L_y} \\right)\n    - P_x(k_y)\n\\end{align}\nand in the limit,\nthis becomes\n\\begin{align}\n    \\Delta P_x (k_y) &=\n    \\frac{dP_x}{dk_y} \\frac{2\\pi}{k_y}\n\\end{align}\nand what we leran is that the $2\\pi/L_y$ factors cancel, so\n\\begin{align}\n    \\Delta Q &=\n    \\int_{0}^{2\\pi} dk_y\\,\n    \\frac{dP_x}{d k_y}\n\\end{align}\nand we can just htink of this as a look integral in the Brilluoin zone.\n\\begin{align}\n    \\Delta Q &=\n    \\oint dk_y\\,\n    \\frac{dP_x}{d k_y}\n\\end{align}\nand you can just think of $\\Delta Q$\nas the winding number of the polarization,\nwhich is equal to the charge pumped across the system.\n\n\\begin{question}\n    Between the time and frequency arguemnts,\n    $\\Delta P$ should be the difference in polarizaiton at different times?\n\\end{question}\nThe current is the change in polarization,\nbut the reason it's change in time is becake $k_y(t)$ is in time.\n\\begin{align}\n    J_{1D}(k_y) &=\n    \\frac{dP_x\\left( k_y(t) \\right)}{dt}\n\\end{align}\n\n\\begin{question}\n    What's the physical meaning of polarization winding?\n\\end{question}\nPhysically,\nthis is what's going on.\nPhysically,\ntake the states in a given Chern band,\nand because our band has a Chern number,\nwe cannot write localized Wannier functions,\nbut they can be paritally localized Wannier functions.\nPhysically, localized wannier functions for the Chern band\n$\\ket{W(k_y, x)}$.\n\nAs $k_y$ increases,\nthese Wannier functions are shifting in position,\nthe states get shifted in $x$,\nspecifically let's look at the expectation values\n\\begin{align}\n    \\bra{W(k_y,x)} \\hat{x} \\ket{W(k_y, x)}\n    = x + P(k_y)\n    = \\bar{x}_{k_y, x}\n\\end{align}\nSome extra steps of algebra area needed to show this.\nwe have partially.\nThe fact the polarization winds\nmeans that if you tried to plot this average\n$\\bar{x}_{k_y, x}$ vs $k_y$,\nit means that if you start at lattice site 0,\nyou end up at lattice site $C$ after $k_y$ goes up by $2\\pi$.\nThere are two ways of saying it.\n\nWhat it's saying is that the average positiion of this partially localized\nWannier function changes by $C$ units\n\\begin{align}\n    \\bar{x}_{k_y + 2\\pi, x} &=\n    \\bar{x}_{k_y, x} + C\n\\end{align}\nAlternatively,\nafter inserting $2\\pi$ flux,\nthis average changes by $C$ windings.\nAt each particular poin,\nthe polizariotn has changed,\nand the net change in polairziaton is just hte net charge that goes from one\nside toe another.\nThis is why you relate $J$ and $P$.\n\n\\begin{question}\n    What's the picture of the winding number of $P$ around $y$?\n\\end{question}\nThe winding\n\\begin{align}\n    \\oint dk_y\\, \\frac{dP}{dk_y}\n    &=\n    p(k_y + 2\\pi) - P(k_y)\n\\end{align} shift by $2\\pi$ and see how much polarization changes.\n\n\n\\begin{question}\n    If $C$ is zero,\n    we expect this to be locallized?\n\\end{question}\nNo,\nif $C=0$,\nthere's no obstruction to write down localied Wannier funcfions,\nbut we can still write paritally lcoalized Wannier functions.\nAs we change $k_y$,\nthese positions would be shifted over by $C$,\nwhich means they don't shift over at all.\n\n\n\\begin{question}\n    These Wannier functions are not deinite combinatinos of Bloch states?\n\\end{question}\nYou cna think of these nsulators as filling some single-articulare stares,\nbut which basis you think in is up to you.\nYou alwasy have the right ot think in the basis they are paritally localized.\nwinding literally means graduatlly\n\n\nA nice exercise is to write down the Wannier functino in terms of the Bloch\nstates of the bands,\nand tune the superpsoitiosn so you maximize the lcoalizeation o the wannier\nfunction.\n\n\\begin{question}\n    Do we have a known quantity for the lcoalization?\n\\end{question}\nFor the moment forget about Chern numbers entirely,\nand just think about 1D systesm.\nMore generally,\nconsider some 1D system that depends on some apramter $\\theta$.\n\\begin{align}\n    H_{1D}(\\theta)\n\\end{align}\nIf $\\theta$ varies with time,\nwe could get some current in this system.\nBecause $\\theta$ is the only thing changing in this setup,\nthe current is going to be some response linear function $G(\\theta)$ times the\nderivative.\n\\begin{align}\n    J(t) &= G(\\theta) \\frac{d\\theta}{dt}\n\\end{align}\nand this is varying adiabatically in time,\nso we can apply linear response,\nas the sytem is always in equilibrim.\nNow the current,\nis almost by definition\n\\begin{align}\n    J(t) &= \\frac{dP}{dt},\n\\end{align}\nbut we can also think of it in terms of\n\\begin{align}\n    J(t) &= \\frac{dP}{dt}\n    = \\frac{\\partial P}{\\partial \\theta} \\frac{d\\theta}{dt}\n\\end{align}\nwhich means\n\\begin{align}\n    G(\\theta) = \\frac{\\partial P}{\\partial \\theta}.\n\\end{align}\nwhat you find for the tight-binding model is that you get a clean expression\n\\begin{align}\n    G(\\theta) &=\n    \\oint \\frac{dk_x}{2\\pi}\\left( \n    \\frac{\\partial A_x}{\\partial \\theta} - \\frac{\\partial A_\\theta}{\\partial k_x}\n    \\right)\n\\end{align}\nwhere this $A_\\theta$ is the Berry connection,\nwith\n\\begin{align}\n    A_x &=\n    -i \\bra{u(k,\\theta)} \\frac{\\partial}{\\partial k_x}\n    \\ket{u(k,\\theta)}\\\\\n    A_\\theta &=\n    -i \\bra{u(k,\\theta)} \\frac{\\partial}{\\partial \\theta}\n    \\ket{u(k,\\theta)}\\\\\n\\end{align}\nand these $u$ are Bloch wave functions.\nIt should look familiar to you.\nThis is just the field strength of this Berry connection in this\n$(k_x,\\theta)$-space.\nNow interestingly,\nif $\\theta$ is a periodic parameter so that\n\\begin{align}\n    H(\\theta + 2\\pi) = H(\\theta)\n\\end{align}\nthen ifwe take the inetegral,\n\\begin{align}\n    \\frac{1}{2\\pi}\\int d\\theta\\, G(\\theta) &=\n    C\n\\end{align}\nwhere $C$ is some integer Chern number.\nThis is an amazing cool thing.\nYou have a family of 1D systems,\nyou try to look at the current floiwng through the system,\nand that current is dteermined by a response function,\nand that respnose fucntion\nis just het integral of the field strength of the Berry connection.\n\nSo to do one mofre thing.\nIf we pick a gauge where $A_\\theta$ is single-valued,\n\\begin{align}\n    G(\\theta) &=\n    \\frac{\\partial}{\\partial\\theta}\n    \\oint \\frac{dk_x}{2\\pi} A_x\n    = \\frac{\\partial P}{\\partial \\theta},\n\\end{align}\nso we learnt something cool:\n$P$ itself is equal to the Berry phase.\n\\begin{align}\n    P &=\n    \\oint \\frac{dk_x}{2\\pi}A_x\n\\end{align}\nThe poliaziaton is taking the Berry conntion,\nand looking at hte holonomy of the Berry gauge field in momentum space.\nThis is the so-called\n\\emph{Berry phase theory of 1D polarization}.\nOnce caveat is that this is only well-defined mod integer.\nBecause,\nI can always do a gauge transformation of my insgle-aprticle gauge funtions,\nwhich chagnes the flux thorugh the BZ by $2\\pi$.\nThat is,\nthis is only well-defined mod $\\mathbb{Z}$,\nadn we can do large gauge transfomrations to chagne\n$\\oint_{k_x} A$ by $2\\pi$.\n\nThis miplies that when $\\theta$ is periodic,\n\\begin{align}\n    \\Delta Q &=\n    \\int J\\, dt\\\\\n    &= \\int G(\\theta) \\frac{d\\hteta}{dt}dt\\\\\n    &=\n    \\int G(\\theta)\\, d\\theta\\\\\n    &= C \\in \\mathbb{Z}\n\\end{align}\nSo if we do a loop in paratere psace,\nwe pump charge,\nand that can be related to the Chern number,\narising frmo the 1 extra dimension $\\theta$.\n\nSo topological pumps in 1D are tightly connected to Chern numbers in 2D.\n\nThe cna also relate the charge density to the polarization.\nThe current is the time derivative of the charge,\nbut if you havet he gradient of the polarization,\nthat means you have some charge density somehwere.\n\nBy the continuity equation,\n\\begin{align}\n    \\frac{d\\rho}{dt} &=\n    -\\frac{dJ}{dx}\n    =\n    -\\frac{\\partial^2 P(\\theta)}{\\partial x\\, \\partial t}\n\\end{align}\nand that tells us the charge density is\n\\begin{align}\n    \\rho &=\n    - \\frac{\\partial P(\\theta)}{\\partial x}\n\\end{align}\nand combining iwth\n\\begin{align}\n    J &= \\frac{\\partial P}{\\partial t},\n\\end{align}\nwe get\n\\begin{align}\n    i_{\\mu} &=\n    \\epsilon_{\\mu\\nu} \\frac{\\partial P}{\\partial x_\\nu}\n\\end{align}\nfrom which we get an effective action\n\\begin{align}\n    S_{\\text{eff}} &=\n    \\int dx\\, dt\\,\n    P e^{\\nu \\mu} \\partial_\\nu A_\\mu\n\\end{align}\nwhich means\n\\begin{align}\n    S_{\\text{eff}} &=\n    \\int P\\, F_{xt}.\n\\end{align}\nIntegrating by parts,\nwe can confirm that\n\\begin{align}\n    j_{\\mu} &=\n    \\frac{\\partial S_{\\text{eff}}}{\\delta A_\\mu}\n    = -\\epsilon^{\\mu\\nu} \\partial_\\nu P\n\\end{align}\nSo the Berry phase of the Bloch wave functions as you go around in momentum\nspace in 1D.\nYou can think of polairziaton in 1D,\nwhere the effective action is literally just the field strength of $A$.\nFinally,\nthere is a tight relation between pumps in 1D and chern numbers in 2D.\n\n\\begin{question}\n    Does the correspondence carry in higher dimesnions?\n\\end{question}\nThere's a Simons cllaboartion caleled ultra-quantum matter.\nThere's an ultra quantum theory of polarizaiton.\nAndy ou can generalize this to higher dimensions,\nubt it's a research topic.\nWhat enters is you need translation gauge fields in higher dimensinos,\nguage fields assocatied with tarnslation symmetry,\nand then there's a natural way of witing down this higher dimnsional verios of\nthis effective action.\n\n\\begin{question}\n    Why don't we need them now for 1D?\n\\end{question}\nI think it's because in 2D you can go around in a loop,\nbut in 1D thereis no loop except for the toal loop,\nso there are no small loops.\nIn some sense,\nyou can get a way with less structure in 1D,\nbecause it just has a lot less structure.\n\n\\begin{question}\n    How to generalize Chern numbers to 3D?\n\\end{question}\nSeveral modern things have happend literally in the last few years.\nify ou want to geliraze the pump 1D to Chern number 2D,\ntherae ra few aperps about amoalies in thespace of coupling constants.\nIfy ou chagne $\\theta$,\nit's not eactly invairatn,\nand that's averison fo an anomaly.\nYou can recase everything that happened here more abstratly.\n\nThere's an orthoagonal set of things happend,\nthat is genralis the theroy of polarization to higher dimesnison.\n\nTher'es not really a connection betwen those two things,\nbut maybe that oculd e a resaerch project.\n\n\\section{Many-body definition of Chern number}\nLet's go back ot the many-body defimtiion of chern number\nusing our knowledge of polarization in 1D.\n\nSuppose we havea torus.\nConsider $\\oint A_y = \\theta_y$.\nThen we have the gorund state $\\ket{\\psi(\\theta_y)}$.\n\nLet me define the exponentiated polarization operator\n\\begin{align}\n    R_x :=\n    \\prod_{x, y}\n    e^{i \\frac{2\\pi x}{L_x} \\hat{n}(x, y)}\n\\end{align}\nand then I want to define\n\\begin{align}\n    \\mathcal{T} &=\n    \\frac{\\bra{\\psi(\\theta_y)} R_x \\ket{\\psi(\\theta_y)}}{%\n    \\braket{\\psi(\\theta_y)}{\\psi(\\theta_y)}\n    }\n\\end{align}\nThe polarization is $\\arg \\mathcal{T}(\\theta_y)$.\nThen the Chern number is\n\\begin{align}\n    C &= \\frac{1}{2\\pi} \\oint d\\hteta_y\\,\n    \\frac{d}{d\\hteta_y} P(\\theta_y)\n\\end{align}\nThis is differnt to twisted boundary conditions defiiton.\nthat was twitisting in x and y,\nconstructing a berry connection, field strength.\nBut here,\nI'm only inserting $\\theta_y$\nand seeing how the polarization winds.\n\nThe important thing to note about this formula is that before knowing the wave\nfunction as a function of both $\\theta_x$ and $\\theta_y$,\nwe only consider the wave function has a function a function of 1 parameter,\n$\\theta_y$.\n\n\\begin{question}\n    What's $R_x$?\n    What's the meaning of it?\n\\end{question}\nIf you write down the formula for polarization in 1D,\nit's just\n\\begin{align}\n    P &\\propto \\sum x n(x)\n\\end{align}\nIf you have a 2D system,\n\\begin{align}\n    P &\\propto  \\sum_{x, y} x n(x, y)\n\\end{align}\nSo this $R_x$ you can think of as an exponentiated polarization\n\\begin{align}\n    P_x :\\propto e^{i P}\n\\end{align}\n\n\\begin{question}\n    What is the minimum number of ground states to find the Chern number?\n\\end{question}\nI'm glad you asked.\nThe original definition uses the wave function in terms of 2 parameters.\nWe dropped than down to 1 parameter here.\nIt turns out you can drop it down to not depend on any parameters.\n\nWe can also extrat many-body Chern numbers fom a single GS wave funtion.\n\nSuppose we have a cylinder iwth axis in $x$,\nwinding in $y$.\nThen we have cylinder regions $R_1$, $R_2$, $R_3$, \\ldots\nand $l_y$ is the lenght in the $y$-direction.\nThis is pretty amazing\n\\begin{align}\n    \\mathcal{T}(\\phi) &=\n    \\bra{0}\n    W_{R_1}^\\dagger(\\phi) \n    \\mathrm{SWAP}_{1, 3}\n    W_{R_1}(\\phi)\n    V_{R_1 \\cup R_2}\n    \\ket{0}\n\\end{align}\nwhere\n\\begin{align}\n    W_R &= \\prod_{(x, y)\\in R} e^{i\\hat{n} (x, y) \\phi}\\\\\n    V_R &=\n    \\prod_{(x, y)\\in R} e^{i \\frac{2\\pi y}{l_y} \\hat{n}(x, y)}\n\\end{align}\nthen the Chern number is\n\\begin{align}\n    C &= \\frac{1}{2\\pi} \\oint d\\phi\\,\n    \\frac{d}{d\\phi} \\arg\\mathcal{T}(\\phi)\n\\end{align}\nWe have a paper on this.\nYou think in terms of TQFT and cutting and gluing.\nThere are open questions about this.\nWe dropped down from 2 params, 1 param, to 0 params.\nBut this only works on a cylinder.o\nCan we get it on justa patch of space?\nEmpriically,\nthis formula works even with patches.\n\nThe question is how much topological can you extract from a single ground state\nwave function on a disc.\nWe don't know how to do it,\ncomplexity,\nalgorithsm,\netc.\n\n\\begin{question}\n    You've transfoered the parameter ot the operator?\n\\end{question}\nWhether this is really a win depends.\nI think it's a win,\nit's a matter of if a single ground state wave functino contains all the\ntopology.\n\nAlso,\nthe homework is due on Monday.\n", "meta": {"hexsha": "182439f65c619f4d19dce4ee16be5d88a2866e11", "size": 26292, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phys733/lecture13.tex", "max_stars_repo_name": "ehua7365/umdphysnotes", "max_stars_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-11T12:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-11T12:53:46.000Z", "max_issues_repo_path": "phys733/lecture13.tex", "max_issues_repo_name": "ehua7365/umdphysnotes", "max_issues_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phys733/lecture13.tex", "max_forks_repo_name": "ehua7365/umdphysnotes", "max_forks_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5720930233, "max_line_length": 81, "alphanum_fraction": 0.7155408489, "num_tokens": 7860, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4241690934066996}}
{"text": "% Template for ICIP-2000 paper; to be used with:\n%          spconf.sty  - ICASSP/ICIP LaTeX style file, and\n%          IEEEbib.bst - IEEE bibliography style file.\n% --------------------------------------------------------------------------\n\\documentclass{article}\n\\usepackage{spconf,amsmath,epsfig}\n\n% Example definitions.\n% --------------------\n\\def\\x{{\\mathbf x}}\n\\def\\L{{\\cal L}}\n\\def\\Reals{\\ensuremath{\\mathbf R}}\n\\newtheorem{theorem}{Theorem}[section]\n\n%    Absolute value notation\n\\newcommand{\\abs}[1]{\\lvert#1\\rvert}\n\n\n%    Rank\n\\DeclareMathOperator{\\rank}{rank}\n\n%    Matroid Union \n\\newcommand{\\munion}{\\lor}\n\n%   Set minus\n\\newcommand{\\sminus}{\\backslash}\n\n\n%   Two matrices horizontally concatenated, space between can be\n%   adjusted here\n%\n\\newcommand{\\hmat}[2]{[#1\\;#2]}\n\n%   Oriented Matroid Pair\n\\newcommand{\\OMP}[2]{#1,\\,#2}\n\n\\newcommand{\\extra}[1]{{\\small{#1}}}\n\n\n% Title.\n% ------\n\\title{\\extra{REPORT:}\n(\\today)\nAN ORIENTED MATROID PAIR MODEL FOR ELECTRICAL AND MECHANICAL NETWORKS\n}\n%\n% Single address.\n% ---------------\n\\name{Seth Chaiken\\thanks{Part of this reseach was done during a Sabbatical\nfrom the University at Albany in 2001.}}\n\\address{University at Albany\\\\\n\tDepartment of Computer Science\\\\\n\tAlbany, NY 12222\\\\\n\t\\texttt{sdc@cs.albany.edu}}\n%\n\\begin{document}\n%\\ninept\n%\n\\maketitle\n%\n\n\\begin{abstract}\nBoth resistive electrical networks and elastic mechanical systems such\nas trusses have a topological or geometric structure together with constitutive\nlaws for the elements prior to their interconnection.\nOriented matroids provide a common discrete mathematical model \nfor such structures in which relationships on the signs of element \nquantities can be expressed.\nPairing of oriented matroids\nenables non-linear monotone constitutive laws to be fit\ninto the abstraction in a way that accomodates port and nullor\ninsertions as well.\n\nThe resulting mathematical model clarifies some mechanical analogies for \nthese \ncircuit theory concepts, enables constraints on the signs of system response \nquantities to be predicted from the structure when this is possible, \nand derives topological solution formulas for linearized mechanical \nsystems in which the analog of a tree-sum is a sum over minimally rigid\ntrusses.  It also enables the theories for existance and uniqueness to\nbe applied to mechanical systems with small displacements.\n\\end{abstract}\n%\n\n\\section{Introduction}\n\\label{sec:intro}\n\nOur work \\cite{sdcOMP} shows that the model and results of \n\\cite{HaslerDApplMath,HaslerNeirynck} generalize from a graph model to a\nlinear subspace pair model\nfor which \na pair of oriented\nmatroids (with a common ground set that generalizes the\nset of resistor and other edges)\nrather than a graph with designated resistor, source, nullator\nand norator edges,\nis the discrete structure \n%in which the topological conditions are expressed \nthat expresses \n%the \ntopological conditions\nfor existance or uniqueness of solutions.  These results, like\nthose of \\cite{HaslerDApplMath,HaslerNeirynck} apply to\nmodels whose non-linearities are monotone.\nEach oriented matroid codes which combinations of \\textit{signs} $\\{+,-,0\\}$\nare feasible as \\textit{signatures} of the real coordinate tuple  members\nof each subspace.\nBachem and Kern's book \\cite{BachemKern}\nmotivates oriented matroids from this direction.  For example, a dual \npair of oriented matroids abstracts an orthogonally complementary pair\nof (finite dim. real) linear subspaces.  Minty's painting property,\nmost popularly known as a theorem about directed graphs, then emerges\nas an excellent \\textit{defining axiom} for oriented matroids.\nThis led us to generalize in \\cite{sdcOMP}\nHasler and Neirynck's notion of a ``pair of \nconjugate trees'' to a ``complementary pair of bases''; and of \na ``non-trivial uniform partial orientation of the resistors''\nto a ``common (non-zero) covector''.   \nTheory valid for all oriented matroid pairs, not just those represented by\na pair of linear subspaces, was presented in \\cite{sdcOMP}.\nWe will clarify below how our \ngeneralizations of Foss\\'{e}prez, Hasler and Neirynck's conditions\nfor unique solvability\nare equivalent to the characterization of $\\mathcal{W}_0$ matrix pairs\nshown by Sandberg and Willson \\cite{SWExistancePf,W0APPLpaper}\nto be the condition for unique solvability\nof a \\textit{common} (not just similar) \nproblem with monotone non-linearities.\n\\extra{\n\nIn the electrical circuit theory literature, the circuit ``topology''\nmeans the network graph (to which Kirchhoff's laws apply)\ntogether with particular kinds of ``device elements''\nsuch as resistors, capacitors, voltage sources (batteries), \ncurrent sources, etc., associated with single graph edges, and possibly\n``multiport'' elements associated with multiple graph edges.\nKirchhoff's current law is that current, a scalar in each directed edge,\nsatisfies conservation of flow.  Kirchhoff's voltage law amounts to the \ncondition that \nthe voltage drop, a scalar in each directed edge, is equal to the \ndifference of the scalar potential values at the endpoints.\nProblems with multiport elements are reduced to \nthose with only single edge elements, in order to apply\nthe theory of  \\cite{HaslerDApplMath},  through the use of \n``nullator'' and ``norator'' elements, discussed below.  \nDetailed exposition of the problems,\nreductions, theory and applications is given in \\cite{HaslerNeirynck}.\n\n}We will introduce our model by using it to demonstrate\nthe analogy between the electrical and mechanical elastic \napplications.   \nThe  subspace \npairs of the latter \nare not graphic cycle and cocycle spaces.  \nUnlike in the electrical case, the structural model is ``inexact'' because\nit depends of the precise sizes and positions of\nthe bars in addition to their interconnection; \nthe constitutive laws describe elastic characteristics of the bars.\n\\extra{\n\nInteresting purely ``discrete'' results (and open problems)\nare known in rigidity theory for \\textit{generic rigidity}, where\nthe positions are assumed to have no algebraic dependencies.  Then,\nthe oriented matroid of the rigidity matrix (defined below)\ndoesn't change with small position perturbations, and the property\nof first order rigidity coincides with local rigidity:  The framework\nembedding is determined up to Euclidean motions by the lengths of the\nbars, when restricted to a neighborhood of the original embedding.\n\n}We believe that our formulation\nhas the advantage over conventional matrix formulations\nof making more explicit the discrete structure model for circuit \ntopology and some conditions when this model determines qualitative\nrelationships among circuit quantity signs independently of \nparticular monotone constitutive laws.\n\n\\section{Basic}\n\\label{sec:Basic}\n\nA \\textit{subspace pair} $(L_V, L_I)$ is a pair of linear subspaces of\n$\\Reals^U$, where the elements of finite set $U$ index the coordinates.\nThe scalar product $v\\cdot w = \\sum_{e\\in U}v_e w_e$ is used to define that\n$v, w \\in \\Reals^U$ are \\textit{orthogonal} when $v\\cdot w = 0$.  An \n\\textit{orthogonal subspace pair}  satisfies $v\\cdot w = 0$ for\nall $v\\in L_V$ and $w\\in L_I$.  A subspace pair has \\textit{full rank} when\n$\\mathrm{rank}(L_V)+\\mathrm{rank}(L_I)= |U|$.  Hence an orthogonal full rank \nsubspace pair is a linear subspace paired with its orthogonal complement.\n\nThe structure of an electrical network is defined \nbeginning with the \\textit{network graph}\n$\\mathcal{N}$ with \\textit{nodes} $N$  and \\textit{arcs} $U$.  \n(The generality obtainable by port, nullator/norator or nullor, and \ndevice characteristic insertions will be treated later.)\nEach arc has \na fixed but arbitrary direction to define the sign of its voltage drop and\ncurrent flow.  The \\textit{incidence matrix} $M_V$, with rows indexed by $N$\nand columns indexed by $U$ is defined so $M_V(n,e)=+1$ when the tail of $e$ is\n$n$, $-1$ if the head of $e$ is $n$, and $0$ if $n$ and $e$ are not incident.\n\nWhen $L_V$ is the row space of $M_V$ and $L_I$ is the orthogonal complement\nof $L_V$, the members of $L_V$ are voltage drop tuples in $\\mathcal{N}$ \nfeasible under Kirchhoff's voltage law and the members of $L_I$ are the \ncurrent flow tuples feasible under Kirchhoff's current law.  These facts \nrestate Kirchhoff's laws and Tellegen's theorem.  Note that we can determine\n$(L_V, L_I)$ from one of these subspaces given and Tellegen's theorem: The\nrole of nodes here is not strictly necessary.\n\nThe definition of mechanical network structure begins with the \n(undirected) \\textit{framework graph} $\\mathcal{F}$ with \\textit{vertices}\n$N$ and \\textit{edges} $U$.  A \\textit{framework} $\\mathcal{F}(\\mathbf{p})$ \nin d $dimentions$ is a framework graph $\\mathcal{F}$ and an \\textit{embedding} \n$\\mathbf{p}:N\\rightarrow \\Reals^d$.  \nThe embedding assigns each vertex to a point in\n$d$-dimensional space.  The \\textit{rigidity matrix} $M_V$ \nhas $d|N|$ rows, each\nindexed by one coordinate in $\\Reals^d$ of the point that embeds one vertex.\nFor edge $e=(i,j)\\in U$, column $M_V(e)$ of the rigidity matrix is defined \n(when vertices are numbered 0 through $|N|-1$):\\\\\n\\begin{minipage}{\\linewidth}\n\\begin{align*}\n(0, \\ldots,0, &\\mathbf{p}(n_i)-\\mathbf{p}(n_j),\\\\\n              &\\mathrm{positions\\ } di\\ldots di+d-1\n\\end{align*}\n\\end{minipage}\n\\hfill\\begin{minipage}{.85\\linewidth}\n\\begin{align*}\n\\hfill 0,\\ldots,0,&\\mathbf{p}(n_j)-\\mathbf{p}(n_i), 0, \\ldots,0)^T\\\\\n                  &\\mathrm{positions\\ } dj\\ldots dj+d-1\n\\end{align*}\n      \\end{minipage}\\\\\nThis definition is echoed from the literature \\cite{RigidityBook} on rigidity theory, except\nwe interchange rows and columns.  Just as we deemphasized nodes of electrical\nnetworks, we will use merely the row space of $M_V$ for most of what follows.\n\n\\extra{\nThe rigidity matrix as a function of the embedding $\\mathbf{p}$ is denoted\n$M_V(\\mathbf{p})$.  The row vector $\\mathbf{p}$ left multiplied with\n$M_V(\\mathbf{p})$\nis the row tuple denoted $\\mathbf{L}=\\mathbf{p}M_V(\\mathbf{p})$  Then, \n$\\mathbf{L}_e$ $=$ \n$(\\mathbf{p}M_V(\\mathbf{p}))_e$ $=$ $|\\mathbf{p}_i-\\mathbf{p}_j|^2$ for\neach edge $e=(i,j)$.  Now if each $\\mathbf{p}_i$ is a differentiable function\nof $t$, $d\\mathbf{L}/dt$ $=$ $2\\mathbf{p}'M_V(\\mathbf{p})$.  Framework\n$\\mathcal{F}(\\mathbf{p})$ is \\textit{first-order rigid} when \n$d\\mathbf{L}/dt$ $=$ $0$ for all $\\mathbf{p}'$ implies \n$|\\mathbf{p}_i-\\mathbf{p}_j|^2$ is constant for all pairs $i$, $j$, not just\nendpoints of edges. \n}%extra\n\nLet $\\mathbf{p}(i)-\\mathbf{p}(j)$ for edge $e=\\{i,j\\}$ be called the\n\\textit{vector from } $j$ \\textit{to} $i$.  \nIt is known that the row space $L_V$ \nof $M_V$ consists of tuples in $\\Reals^{U}$\nsuch that component $v(e)\\in\\Reals$ for $e\\in U$ is the projection of the\nrelative velocity of vertex $i$ with respect to vertex $j$ projected onto\nthe vector from $j$ to $i$, for some combination of vertex velocities \n$\\mathbf{v}:N\\rightarrow\\Reals^d$:\n$v(e)=(\\mathbf{v}(i)-\\mathbf{v}(j))\\cdot(\\mathbf{p}(i)-\\mathbf{p}(j))$.\n\nIt is also known that the $L_I$, the orthogonal complement of $L_V$, \nis comprised of the tuples $\\sigma:U\\rightarrow\\Reals$ \nof scalars for which the framework is in static\nequilibrium when each edge $e$ exerts force \n$\\sigma(e)(\\mathbf{p}(j)-\\mathbf{p}(i))$ on vertex $i$.  By this convention, \n$\\sigma(e)>0$ means $e$ is under tension and $\\sigma(e)<0$ means $e$ is under \ncompression.  Each tuple $\\sigma\\in L_I$ is called a \\textit{self-stress}.\n\nUnder this analogy, \n(1) KVL corresponds to geometric consistancy of first order\nedge length changes under changes in the embedding, (2) KCL corresponds to\nNewton's laws of static equilibrium, and (3) Tellegen's theorem corresponds\nto a virtual work principle, that static equilibrium is\ncharacterized by \nthe internal forces of every virtual embedding change \ndoing zero virtual work.\n\n\\subsection{Independent Variables and Bases}\nKVL, KCL and analogous mechanical structural or geometric laws \nare each formulated above by a constraint of the form \n$v\\in L$ $=$ $\\mbox{row space}(M)$\nwhere $v$ is a tuple of variables indexed by $U$\nand $L\\subset\\Reals^U$ is a linear subspace.  The problem of\nreformulating such a law by a system of linear equations is\nsolved as follows:  A maximal subset $B\\subset U$ corresponding to\na linearly independent set of columns of $M$ is found.  Such a $B$ is\ncalled a \\textit{basis in the matroid} $\\mathcal{M}(L)$ \n\\textit{represented by} the columns of matrix $M$ or the linear subspace\n$L$.  Row operations and possibly deletion of zero rows can transform\n$M$ to $( I\\ ;\\ M^{\\overline{B}} )$ (after column permutation)\nwhere $I$ is the $r\\times r$ identity matrix, where $r$ $=$ \n$\\mbox{rank}(M)$ $=$ $\\mbox{dim}(L)$ $=$ $\\mbox{rank}(L)$\n$=$ $\\mbox{rank}(\\mathcal{M}(L))$.    \nIt is now clear that $v\\in L$ is characterized by \n$v_{\\overline{B}}$ $=$ $v_{B}M^{\\overline{B}}$.\nFor each independently chosen\n$v_{B}\\in\\Reals^B,$ $v=(v_B;v_{\\overline{B}})$ is unique tuple\nfor which the $B$ coordinates equal $v_B$.\n\n\n\\extra{\\section{Elastic Analog of the Nodal Admittance Matrix}\n\nReduced nodal admittance matrix.  Nodal resistance matrix.\nInteraction with a physical framework with it's environment.\nA framework is first order rigid iff it ``resolves all applications of\nstatic equilibrium forces''.  However, every physical bar has some\nelasticity:  An ideal rigid bar is analogous to an ideal voltage \nsource.  Hence, given an elastic framework, for every application\nof static equilibrium forces on the vertices, the vertex positions\nwill change as the bars stretch or shrink under the forces they now\ncarry to resolve the applied force.  These first order vertex position \nchanges are given by $Z\\mathbf{f}$.\n\nThe environment might interact by ``forcing'' some vertices to change position\nrelative to one another.\nIntuitively, the framework will ``push back''.  The other vertices are free\nto move as adjacent vertices move and incident bars change length in\nresponse to the forces developed in them to resolve the forces required\nto hold the framework in its new position.  The position changes of the\nfree vertices $V$ can be calculated by solving for the unknown position changes\nin the system of equations $(Y\\mathbf{v}_V)(V)=0$.\n\nFor our purposes, we insert port elements in order to make interactions \nwith the environment explicit.  This enables a coordinate of an \nenvironmental interaction quantity to correspond to an oriented matroid\nelement, so that its sign can be read off from the corresponding entry\nin a covector.\n\nIt's yet to be done to handle simutaneous application of force to more \nthan 2 vertices....\n\n\n\nto be written..}\n\n\n\\section{THE SUBSPACE PAIR MODEL}\n\nPorts are introduced so the response of an electrical network to current \nand/or voltage sources, and the mechanical analogs, can be formulated.\nAfter modeling device characteristics, questions of existance and \nuniquenss of solution for various kinds of sources can be formulated.\nFamiliar topological conditions on dependencies among source values\npertain to the \\textit{matroids} of the subspaces $L_V$ and $L_I$.\nQuestions about existance and uniqueness of solution\nwill be answered in terms of supplementary subspace pair models\nwhich are obtained by the familiar operations of opening and shorting ports.\nFinally, operations on subspace pairs that model nullor insertion are\ndefined, so that such ideal elements can be modeled combinatorially or\ngeometrically.  \n\nThe supplemental subspace pair derived after nullor \ninsertion will typically not be orthogonal.  One might also choose to\nmodel linearized CCCSs or VCVSs within one of the subspaces.  \nEach port insertion generally increases $\\rank(L_V)+\\rank(L_I)-|U|$;\nsystem behavior for linearized constitutive laws will be shown to be\nrepresented by the intersection of two linear spaces.\nHence we do not assume any rank or orthogonality conditions on subspace \npairs in the definitions below.\n\nGiven a subspace pair $(L_V, L_I)$ and element $p\\in U$ not already a port, \nwe define the \noperation of \\textit{inserting a port at  $p$} \nas follows: A new subspace pair $(L'_V, L'_I)$\nis defined with $U'=U-\\{p\\}\\cup\\{p_V,p_I\\}$, $L'_V=L_V\\oplus\\Reals$ (direct \nsum) with $p_V$ replacing $p$ and $p_I$ indexing the coordinate of the added\nsubspace, and $L'_I=L_I\\oplus\\Reals$ with $p_I$ replacing $p$ and $p_V$ \nindexing the coordinate of the added subspace.  Note (going to \n$(L'_V, L'_I)$) that the ranks of\n$L_V$ and $L_I$ each increase by 1, and $|U'|$ $=$ $|U|+1$.  After $p$ port\ninsertions, we denote the final $U=E\\cup P_V \\cup P_I$ with pairwise disjoint\n$E$, $P_V$ and $P_I$, $|P_V|$ $=$ $|P_I|$ $=$ $p$, $P_V\\cup P_I$ being the \nreplacement elements.  Let $P$ denote $P_V \\cup P_I$.  \n\nThe \\textit{subspace pair model} $\\mathbf{M}$ $=$ \n$(E, \\Gamma, P, (L_V, L_I))$ consists of finite set $E$ of \n\\textit{device elements}, \\textit{constitutive law relations}\n$\\Gamma = \\{\\Gamma_e\\subset\\Reals\\times\\Reals | e \\in E\\}$, a finite set\n$P=P_V \\cup P_I$ that result from inserting ports as defined above, \nand a subspace pair $(L_V, L_I)$ over $\\Reals^U$ with $U=E\\cup P$.\n\nThe \\textit{variables} of $\\mathbf{M}$ are \n$\\{u_{Ve}, u_{Ie} | e \\in E\\}$  $\\cup$ \\\\\n$\\{ u_{Vp}, u_{Ip} | p_I, p_V \\in P \\}$.  \n(For brevity, subscript ``$Vp$'' means port element\n$p_V\\in P_V$, etc.)\nA \\textit{subspace pair model with sources} $S$ \nis a subspace pair model $(E, \\Gamma, P, (L_V, L_I), S)$\ntogether with a subset $S$ of exactly $|P|$ of the $2|P|$ elements\nin $P$.  A \\textit{$V$-driven port} is a port $p\\in P$ for which \n$p_V\\in S$ and $p_I\\not\\in S$, then $u_{Vp}$ is called \nan \\textit{input variable}.   Reverse $V$ and $I$ to define an \n\\textit{$I$-driven port} and its input variable.\n\nA \\textit{solution} of $\\mathbf{M}$ with sources\nis a real valued extension to \\textit{all} variables of $\\mathbf{M}$ \nof a given \\textit{input} assignment to the input variables\nthat satisfies\\\\\n$(u_{VP}, u_{IP}, u_V) \\in L_V$,\n$(u_{VP}, u_{IP}, u_I) \\in L_I$\nand\n$(u_{Ve}, u_{Ie}) \\in \\Gamma_e$ for all\n$e\\in E$.  Note that in this model, the constraint \n$(u_{VP}, u_{IP}, u_V) \\in L_V$ does not (by itself) imply any constraint\non a ``I'' type port variable $u_{Ip}$, similarly, $u_{Vp}$ is not constrained\nby $(u_{VP}, u_{IP}, u_I) \\in L_V$.  Port variables are not constrained\nby the constitutive laws $\\Gamma$ (by themselves) either.\n\nIn the language of matroid theory, we can call the element $p_I$ an \n\\textit{isthmus} of the matroid $\\mathcal{M}(L_V)$; similarly, $p_V$ is\nan isthmus of $\\mathcal{M}(L_I)$.  In general, the matroid represented by\na matrix is characterized by the collection $\\mathcal{I}$ \nof \\textit{independent sets} \nof matrix columns, where a set of columns is called independent when it is\nlinearly independent.  (Matroid theory studies what can be deduced by \nthe following three axioms satisfied by $\\mathcal{I}$: (1) \n$\\mathcal{I}\\neq\\emptyset$. \n(2) If $A\\subset B\\in\\mathcal{I}$ then $A\\in\\mathcal{I}$.  (3) \nIf $A$, $B$ $\\in\\mathcal{I}$ and $|A|<|B|$, then there exists $e\\in B-A$ \nfor which $A\\cup\\{e\\}\\in\\mathcal{I}$.  For example, an isthmus $e$ is \ncharacterized by $A\\cup\\{e\\}\\in\\mathcal{I}$ for all $A\\in\\mathcal{I}$.\nThe \\textit{rank} of a subset $C\\in U$ is the size of the largest independent\nsubset of $C$.  A set $D$ is called \\textit{co-independent} if $\\rank(U-D)$\n$=$ $\\rank(U)$; in other words, removing $D$ does not diminish the original\nmatroid's rank.)\n\nWe say a subspace pair problem with sources $S$ \nis \\textit{well-posed} when for all input assignments there is a unique \nsolution.\n\n\nThe condition that there is no cycle of voltage source branches nor a\ncutset of current source branches is well-known to be necessary for \nan electrical network to have a solution for all choices of source values.\nAssume as usual no branch is taken to be both a current and voltage source.\nOur generalization of the following:\nThe set of elements $p_V$ \nfor ports driven by ``V'' sources\nis an independent set in the matroid $\\mathcal{M}(L_V)$ and \nco-independent set\nin $\\mathcal{M}(L_I)$,\nand the elements $p_I$ for ports driven by ``I'' sources comprise an\nindependent set in $\\mathcal{M}(L_I)$ and a co-independent set in\n$\\mathcal{M}(L_V)$.  \n\nWhen the constitutive laws are linear, the solutions of $\\textbf{M}$ are\nfound from the \\textit{intersection} of two linear subspaces:  Let $G$ \nbe the diagonal matrix with ``conductances'' $g_e$ in its positions\nindexed by $e \\in E$ (so $\\Gamma_e$ $=$ $\\{ (v, g_e v) | v \\in \\Reals \\}$\nand 1 in its other diagonal positions.  The solution set projected onto\nthe $w_I$ variables is $L_VG\\cap L_I$.\n\n\\section{DELETION AND CONTRACTION}\n\nGiven a subspace $L\\subset\\Reals^U$ and $e\\in U$, the subspace $L-e$ \n``$L$ \\textit{with} $e$ \\textit{deleted}'' is the\nsubspace $L-e\\subset\\Reals^{U-\\{e\\}}$ defined by $L-e$ $=$\n$\\{ l(U-e) | l(U)\\in L\\}$, where $l(U-e)$ denotes the tuple $l(U)\\in\\Reals^U$\nwith component labeled by $e$ dropped.  If $L$ is the row space of matrix $M$,\nthen $L-e$ is the row space of $M(U-e)$, which is $M$ with column $e$ deleted.\n\nThe subspace $L/e$ ``$L$ \\textit{with} $e$ \\textit{contracted}'' is the \nsubspace\nof $\\Reals^{\\{U-e\\}}$ defined by \n$L/e$ $=$\n$\\{ l(U-e) | l(U)\\in L \\mathrm{\\ and\\ } l(e)=0\\}$.  \nIn other words, $L/e$ is the \nintersection of $L$ with\nthe (hyperplane) subspace of $\\Reals^U$ with $l(e)=0$ followed by the $e$ \ncoordinate removed.  \n\nWe now define deletion and contraction on subspace pairs:  \n$(L_V, L_I)-e$ $=$ $(L_V-e, L_I/e)$ and \n$(L_V, L_I)/e$ $=$ $(L_V/e, L_I-e)$.  One can recognize that \ndeleting element $e\\in S$ from a subspace pair modeling an electrical network\ncorresponds to \\textit{opening} the corresponding branch.  Dually, \ncontraction corresponds to \\textit{shorting} the branch.  Mechanically,\ndeletion of an edge corresponds to ``breaking'' the corresponding bar:\nignore any distance change between its ends and transmit no force.\nContraction corresponds to \ndeclaring the bar to be rigid, which rules out \nall (first order) distance changes between the endpoints and allows \nthe bar \nto transmit arbitrary force.\n\n\\section{SIMPLE EXAMPLES}\n\n\n\\begin{figure}[htb]\n\n\\begin{minipage}[c]{.48\\linewidth}\n  \\centering\n \\centerline{\\input{2res.pstex_t}}\n%  \\vspace{2.0cm}\n\\end{minipage}\n%\n\\hfill\n\\begin{minipage}[c]{.48\\linewidth}\n\\[\n\\begin{array}{cccc}\n\\multicolumn{4}{c}{\\mbox{($M_V$ matrix)}} \\\\\n0   &  1  &  0  &  0  \\\\\n1   &  0  &  1  &  1  \\\\ \\hline \\hline\np_V & p_I & e_1 & e_2 \\\\ \\hline \\hline\n1   &  0  &  0  &  0  \\\\\n0   &  1  & -1  &  0  \\\\\n0   &  0  &  1  &  -1 \\\\\n\\multicolumn{4}{c}{\\mbox{($M_I$ matrix)}} \\\\\n\\end{array}\n\\]\n\\end{minipage}\n%\n\\begin{minipage}[b]{.48\\linewidth}\n\\[\n\\begin{array}{ccc}\n  1  &  0  &  0  \\\\ \\hline\n p_I & e_1 & e_2 \\\\ \\hline\n  0  &  0  &  0  \\\\\n  1  & -1  &  0  \\\\\n  0  &  1  &  -1\n\\end{array}\n\\]\nZIR analysis for voltage source input:\n$p_V$ contracted.  Zero response (unique solution) even if\nnegative resistances $\\neq 0$ are allowed.\n\\end{minipage}\n\\hfill\n\\begin{minipage}[b]{.48\\linewidth}\n\\[\n\\begin{array}{ccc}\n0   &  0  &  0  \\\\\n1   &  1  &  1  \\\\ \\hline\np_V & e_1 & e_2 \\\\ \\hline\n1   &  0  &  0  \\\\\n0   &  1  &  -1\n\\end{array}\n\\]\nZIR analysis for current source input:\n$p_I$ deleted.\nZero response (unique solution) \\textit{unless}\n$g_1 = -g_2$.  \n\\end{minipage}\n\\caption{Simple Example.}\n\\label{Simple}\n%\n\\end{figure}\n\n\n\\section{NO-COMMON-COVECTOR PROPERTY AND $\\mathcal{W}_0$ PAIRS}\n\n\n\nThe following theorem\ndemonstrates, by means of Sandberg and Willson's theory of \n$\\mathcal{W}_0$ pairs, that any \nsubspace pair model (with  its separation of\ngeometric/topological and constitutive constraints) can be analyzed\nfor unique solvability from the oriented matroid pair it generates.\nConversely, a matrix pair \n$(A,B)\\in\\mathcal{W}_0$ is characterized by a rank condition and a \nno-common-covector property.\n\n\\begin{theorem}\nThe subspace pair model has a unique solution for all source \nvalues when the corresponding oriented matroid pair has a complementary \nbase pair and no common covector.\n\\end{theorem}\n\nProof:  The following matrices must be square and order $|U|$\nfor solutions of (..) to be unique:\n$A$ $=$ $\\left(\\begin{array}{c}M_V\\\\ 0\\end{array}\\right)$ and\n$B$ $=$ $\\left(\\begin{array}{c}0\\\\ -M_I\\end{array}\\right)$.\nThe theorem follows with these matrices used in the equivalance of \n2. and 5. in the theorem below.\n\n\\begin{theorem}\n\\label{sandwillompairtheorem}\nFor a pair \n%\n% EDITdone\n% delete ``order'' --- we understand that when we see \n% ``$n\\times n$'', and this avoids confusing with order as in\n% a linear ordering\n%\nof $n\\times n$ \nmatrices $(A,B)$, the following conditions are \nequivalent.\n%\n% EDITdone\n% period, not colon\n%\n\\begin{enumerate}\n\\item \n$(A,B)\\in {\\mathcal W}_0$ in the sense of \nSandberg and \nWillson~\\cite{SWExistancePf,W0APPLpaper};\ne.g., $|AD+B|\\neq 0$ for all positive diagonal $D$, etc.\n\\item \n$\\rank{\\mathcal M}\\hmat{A}{B}=n$ and \n${\\mathcal L}\\hmat{A}{B} \\cap {\\mathcal L}\\hmat{I}{-I}=\\{0\\}.$\n\\item \n$\\rank{\\mathcal M}\\hmat{A}{B}=n$ and \n${\\mathcal V}\\hmat{A}{B} \\cap {\\mathcal V}\\hmat{I}{-I}=\\{0\\}.$\n\\item \n\\textrm{(}Fundamental theorem of Sandberg and \nWillson~\\cite{SWExistancePf,W0APPLpaper}\\textrm{)}\\ \n%\n% EDITdone\n% use ~ before \\cite so a space is left between the word and the reference\n%\nFor all functions $F:{\\bf R}^n\\rightarrow {\\bf R}^n$ of the form\n$F(x)_k=f_k(x_k)$ where each $f_k$ is a strictly \nmonotone increasing \nfunction from \n${\\bf R}$ {\\em onto} $\\bf R$ and for all $c\\in {\\bf R}^n$, the \nequation\n\\[\nAF(x) + Bx = c\n\\]\nhas a unique solution $x$.% \\cite{W0APPLpaper,W0paper}.\n\\item \nFor all functions $G:{\\bf R}^n\\rightarrow {\\bf R}^n$ of the form\n$G(w)_k=g_k(w_k)$ where each $g_k$ is a strictly monotone increasing \nfunction from ${\\bf R}$ {\\em onto} $\\bf R$ and for all \n$d^{\\prime}, d^{\\prime\\prime}\\in {\\bf R}^n$, the \nequations\n\\begin{equation}\n\\label{W0dualproblem}\nu^t=z^tA+d^{\\prime},\\;\\; w^t=z^tB+d^{\\prime\\prime},\\;\\; u=-G(w)\n\\end{equation}\nhave a unique solution $(u,w,z)$.\n\\end{enumerate}\n\\end{theorem}\n\nNote:  A direct inductive proof is obtainable by generalizing \nthe proofs given in \\cite{HaslerNeirynck}.  This approach has the advantage\nof revealing circuit theoretic concepts that occur.  See also\n\\cite{Fosseprez}.  One of the steps is to prove that if the no-common-covector\nproperty is true for $(M_V,M_I)$, then it is true for the matrix pair \nfrom the system obtained by replacing one of the non-linear elements by a\nsource.\n\n\n\n% References should be produced using the bibtex program from suitable\n% BiBTeX files (here: strings, refs, manuals). The IEEEbib.bst bibliography\n% style file from IEEE produces unsorted bibliography list.\n% -------------------------------------------------------------------------\n\\bibliographystyle{IEEEbib}\n%\\bibliography{strings,refs,manuals}\n\\bibliography{OMPEMech}\n\n\\end{document}\n", "meta": {"hexsha": "3c2cbdfc2f66b91d38c4c8670d076bbe2e83b93d", "size": 26805, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2002/Draft1/oldOMPEMech.tex", "max_stars_repo_name": "chaikens/MathOfElec", "max_stars_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2002/Draft1/oldOMPEMech.tex", "max_issues_repo_name": "chaikens/MathOfElec", "max_issues_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2002/Draft1/oldOMPEMech.tex", "max_forks_repo_name": "chaikens/MathOfElec", "max_forks_repo_head_hexsha": "6292a8cffe1441a557212b0fd23f3fd7769975a7", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0490045942, "max_line_length": 92, "alphanum_fraction": 0.7209848909, "num_tokens": 8084, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.42416909340669956}}
{"text": "\\section{Conclusion}\nIn this section we want to conclude our results and compare them to what we expected.\n\\begin{description}\n\t\\item[Solitons in one spatial dimension.] \n\t\nWe analyzed solitonic solutions of the GPE, discretized on a spatial grid. For the case of a black soliton with $\\nu=0$, \\ we proved, that the distribution does not change over time. At the boundaries of the grid, we could observe some disturbing artefacts, which threaten the stability of our solution after long times.\n\nFor a single grey soliton with $\\nu = 0.8$ we saw the expected movement in positive $z$-direction. Unfortunately the disturbing effects at the boundaries were a lot stronger in this case. Nevertheless we were able  to reproduce the result one would expect from the analytical solution. The analytical time evolution is also included in the corresponding notebook.\n\t\nIn the case of two grey solitons, moving in opposite directions, we saw the overlapping in the center of the grid and after passing past each other the characteristic single movement, not affected by the collision. \n\t\n\t\\item[Perturbed density distributions in two spatial dimensions.]\n\t\nWe tried to perturb the two dimensional grid on two different ways, first by adding some randomized noise and second by adding a periodic, sinusoidal noise structure. Both distributions showed interesting dynamics over time. The randomized noise seems to vanish after long times, i.\\,e. the distribution gets smoother. This was not what we expected intuitively at the beginning , but after playing around with the vortex grids in the third part, it seems that the artificially added defects are not stable at all. The second example showed the same long-term behavior.\n  \n\t\\item[Vortices as topological defects.]\n\t\nIn the first constellation, where we observed the evolution of vortex-antivortex pairs of the same charge, we saw, that the vortices unwind and due to the opposite charges, cancel out each other, such that the density distribution becomes homogeneous after some time. \n\nIn the second case we had a look at single vortices of higher charges. The absence of antivortices prevents the vortices from unwinding/vanishing and therefore, even after a long time, the density distribution is still covered with artefacts of vortices.\n\nThe last situation we observed, was an equidistant positioning of vortices with higher charges. In the density plot, one can still observe the artefacts of the vortices at their initial positions and the phase distribution seems to be more stable than in the first case. In the provided animation we still found the vortices in the density plot after some time, whereas the phase plot became more and more indistinct. \n\\end{description}", "meta": {"hexsha": "c77697eb8daf484655a2776ae171d6322fc86da2", "size": 2725, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Final Project/Report/content/04_conclusion.tex", "max_stars_repo_name": "mathieukaltschmidt/CompQD", "max_stars_repo_head_hexsha": "b31c07614e7821bf76213a1cc1f5e6688fbdffa0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-07-04T17:13:47.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-29T16:56:58.000Z", "max_issues_repo_path": "Final Project/Report/content/04_conclusion.tex", "max_issues_repo_name": "mathieukaltschmidt/CompQD", "max_issues_repo_head_hexsha": "b31c07614e7821bf76213a1cc1f5e6688fbdffa0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Final Project/Report/content/04_conclusion.tex", "max_forks_repo_name": "mathieukaltschmidt/CompQD", "max_forks_repo_head_hexsha": "b31c07614e7821bf76213a1cc1f5e6688fbdffa0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-04-23T19:58:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-26T16:58:06.000Z", "avg_line_length": 118.4782608696, "max_line_length": 568, "alphanum_fraction": 0.8047706422, "num_tokens": 570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.42416909304788114}}
{"text": "\\RequirePackage[l2tabu, orthodox]{nag}\n\\RequirePackage{fixltx2e}\n\\documentclass[twocolumn, 10pt, aps, superscriptaddress, floatfix, showpacs, pra, citeautoscript]{revtex4-1}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{bm}\n\\usepackage[utf8]{inputenc}\n\\usepackage{xcolor}\n\\usepackage[colorlinks, citecolor={blue!50!black}, urlcolor={blue!50!black}, linkcolor={red!50!black}]{hyperref}\n\\usepackage{bookmark}\n\\usepackage{tabularx}\n\\usepackage{mathtools}\n\\usepackage{microtype}\n\n\\setcounter{secnumdepth}{4}\n\\setcounter{tocdepth}{4}\n\n\\DeclareMathOperator{\\e}{e}\n\\DeclareMathOperator{\\de}{d\\!}\n\\DeclareMathOperator{\\Tr}{Tr}\n\\DeclareMathOperator{\\diag}{diag}\n\\DeclareMathOperator{\\Res}{Res}\n\\DeclareMathOperator{\\sgn}{sgn}\n\\DeclareMathOperator{\\Det}{Det}\n\\DeclareMathOperator{\\rank}{rank}\n\\DeclareMathOperator{\\im}{Im}\n\\DeclareMathOperator{\\re}{Re}\n\\newcommand{\\vt}[1]{\\mathbf{#1}}\n\\newcommand{\\ts}{\\textsuperscript}\n\n\\newcommand{\\co}[2]{#2}\n\\renewcommand{\\paragraph}{\\co}\n\n\\DeclarePairedDelimiter\\abs{\\lvert}{\\rvert}%\n\\DeclarePairedDelimiter\\norm{\\lVert}{\\rVert}%\n% Swap the definition of \\abs* and \\norm*, so that \\abs\n% and \\norm resizes the size of the brackets, and the\n% starred version does not.\n\\makeatletter\n\\let\\oldabs\\abs\n\\def\\abs{\\@ifstar{\\oldabs}{\\oldabs*}}\n%\n\\let\\oldnorm\\norm\n\\def\\norm{\\@ifstar{\\oldnorm}{\\oldnorm*}}\n\\makeatother\n\n\\newcommand{\\ev}[1]{\\langle#1\\rangle}\n\\newcommand{\\bra}[1]{\\langle #1|}\n\\newcommand{\\ket}[1]{|#1\\rangle}\n\\newcommand{\\bracket}[2]{\\langle #1|#2\\rangle}\n\n%\\newcommand{\\BibitemShut}[1]{}\n\n\\newcolumntype{L}[1]{>{\\raggedright\\arraybackslash}p{#1}}\n\\newcolumntype{C}[1]{>{\\centering\\arraybackslash}p{#1}}\n\\newcolumntype{R}[1]{>{\\raggedleft\\arraybackslash}p{#1}}\n\n\\graphicspath{{figures/}}\n\n\\newcommand{\\revision}[1]{{\\color{red}#1}}\n\\newcommand{\\iac}[1]{{\\color{red}#1}}\n\\newcommand{\\tom}[1]{{\\color{blue}#1}}\n\n\\begin{document}\n\n\\title{Momentum-space Landau levels in driven-dissipative cavity arrays}\n\n\n\\author{Andrei C. Berceanu}\n\\affiliation{Departamento de F\\'isica Te\\'orica de la Materia\nCondensada \\& Condensed Matter Physics Center (IFIMAC), Universidad\nAut\\'onoma de Madrid, Madrid 28049, Spain}\n\\author{Hannah M. Price}\n\\affiliation{INO-CNR BEC Center and Dipartimento di Fisica,\nUniversit\\`{a} di Trento, I-38123 Povo, Italy}\n\\author{Tomoki Ozawa}\n\\affiliation{INO-CNR BEC Center and Dipartimento di Fisica,\nUniversit\\`{a} di Trento, I-38123 Povo, Italy}\n\\author{Iacopo Carusotto}\n\\affiliation{INO-CNR BEC Center and Dipartimento di Fisica,\nUniversit\\`{a} di Trento, I-38123 Povo, Italy}\n\n\\begin{abstract}\n  We theoretically study the driven-dissipative Harper-Hofstadter model on a\n  2D square lattice in the presence of a weak harmonic trap. Without pumping and loss, the eigenstates of this system can be understood, in certain limits, as momentum-space toroidal Landau levels, where the Berry curvature, a geometrical property of an energy band, acts like a momentum-space magnetic field. We show that key features of these eigenstates can be observed in the  steady-state of the driven-dissipative system under a monochromatic coherent drive, and present a realistic proposal for an optical experiment using state-of-the-art coupled cavity arrays. We discuss how such spectroscopic measurements may be used to probe effects associated both with the off-diagonal elements of the matrix-valued Berry connection and with the synthetic magnetic gauge.\n\\end{abstract}\n\n\\maketitle\n\n\n\\section{Introduction}\n\nA planar system of electrons in a\nstrong magnetic field is the archetypal model for studying phenomena such as the\ninteger and fractional quantum Hall effects. With recent advances in creating\nsynthetic gauge fields, however, new horizons have opened up for simulating such topological phases of matter also with neutral particles, such as photons~\\cite{hafezi2014synthetic} or ultracold atoms~\\cite{dalibardrmp2011, goldman_repprog_2014, Goldman_arxiv_2015}. \nRather than simply replicating previous measurements, experiments with synthetic gauge fields allow for unprecedented access to properties such as the eigenstates or eigenspectrum, while the tunability and controllability of these experiments offer the prospect of simulating novel physics. \n\nIn the presence of a (synthetic) gauge field, the eigenstates making up an energy band can have nontrivial geometrical properties, as encoded in the Berry connection and Berry curvature defined below~\\cite{berry, xiao2010berryreview}. Understanding the geometry of eigenstates in a band is of great importance, not least because the integral of the Berry curvature over the 2D Brillouin zone (BZ) gives the first Chern number: the topological invariant responsible for the integer quantum Hall effect~\\cite{thouless}. Consequently, there has been much work in recent years to develop new techniques with which to probe the properties of energy bands in photonics and ultracold gases. For example, the Berry curvature can be measured in the semiclassical dynamics of a wavepacket in an optical lattice~\\cite{dudarev,1chang, price, cominotti, dauphin, aidelsburger2015measuring, jotzu2014experimental} or in photon transport in a cavity array~\\cite{ozawa2014qhe}. In all these cases, the physics can be most naturally understood by recognising that the Berry curvature acts like a magnetic field in momentum space~\\cite{berry, bliokh2005spin, PhysRevD.12.3845, cooper2012designing}. \n\nThe analogy between Berry curvature and magnetism is most powerful when a geometrical energy band is subjected to an additional weak harmonic potential~\\cite{price2014magnetic}. Then, in the effective momentum-space Hamiltonian, a harmonic potential acts like the kinetic energy of a particle in real space. Just as the physical momentum $\\vt{p}-\\vt{A}({\\bf r})$ is the sum of the canonical momentum $\\vt{p}$ and the magnetic vector potential $\\vt{A} ({\\bf r})$ in the magnetic Hamiltonian, so the physical position $\\vt{r}+\\mathcal{A}_{n,n}({\\bf p})$, is given by the canonical position $\\vt{r}$ and the Berry connection $\\mathcal{A}_{n,n}({\\bf p})$ of band $n$ in the effective Hamiltonian~\\cite{adams1959energy,nagaosa, murakami2003dissipationless, bliokh2005spin, fujita, bliokh2005topological,gosselin2006semiclassical}. The Berry curvature, $\\Omega_n ({\\bf p})= \\nabla \\times \\mathcal{A}_{n,n}({\\bf p})$, is then like a momentum-space magnetic field. For certain models, this analogy leads to a clear analytical understanding of single-particle dynamics~\\cite{price2014magnetic, ozawa2014momhh, price2015sporbit, Claassen_prl_2015}. In particular, we will focus on the small-flux limit of the Harper-Hofstadter Hamiltonian~\\cite{harper1955magnetic,hofstadter1976butterfly}, which is a model that has recently been realized in a multitude of experimental configurations,\nranging from ultracold\ngases~\\cite{aidelsburger2013hh,miyake2013hh,mancini2015edge,stuhl2015edge},\nsolid state superlattices~\\cite{dean2013hofstadter,yu2014hierarchy}\nand silicon photonics~\\cite{hafezi2013imaging} to classical systems\nsuch as coupled pendula~\\cite{susstrunk2015pendula} and oscillating\ncircuits~\\cite{jia2013circuits}. As first shown in Ref.~\\onlinecite{price2014magnetic}, the eigenstates of this model in the presence of a harmonic trap are toroidal Landau levels in momentum space. Not only would an observation of these states constitute the first exploration of analogue magnetic states in momentum space, but also the first experimental study of magnetism on a torus.  \n \nWhile previous theoretical works on momentum-space Landau levels have focused on conservative dynamics~\\cite{price2014magnetic, Claassen_prl_2015}, photonics systems naturally include driving and dissipation~\\cite{carusotto2013fluids}. In this paper, we present a realistic experimental proposal for the observation of these states in a driven-dissipative 2D lattice of cavities, such as the array of coupled silicon ring resonators of Ref.~\\cite{hafezi2013imaging}, where link resonators were used to simulate a synthetic gauge field for photons. In our proposal, we combine this set-up with a harmonic potential, introduced, for example, by a spatial modulation of the resonator size. We demonstrate numerically that the main features of momentum-space Landau levels will be observable spectroscopically in this system for realistic parameters. \n\nIn this paper, we also emphasize how the inherent driving and dissipation in photonics can be a key advantage in probing properties that are otherwise inaccessible. \nFirstly, the spectroscopic measurements discussed here are sensitive to the absolute energy of a state. From this, we show how to extract the energy shift due to the off-diagonal matrix elements of the Berry connection $\\mathcal{A}_{n,n'}({\\bf p})$ relating eigenstates in different bands $n$ and $n'$. Only very recently has the first measurement of such effects been reported in ultracold atomic gases~\\cite{Grusdt2014nonabelian,tracy2015arxiv}, and the approach used in this experiment would be difficult to apply in a photonics set-up. Our scheme may therefore be useful for the characterisation of energy bands in topologically-nontrivial photonic systems.\n\nSecondly, since the photon steady-state depends on the overlap between the (observable) spatial amplitude profile of the drive and of the eigenstates~\\cite{carusotto2013fluids}, the observables will depend on the phase of the eigenfunctions and thus on the specific synthetic magnetic gauge that is implemented in a given experimental realization of the Harper-Hofstadter Hamiltonian using a synthetic gauge field. We note that a related gauge-sensitivity has also recently been of much interest in ultracold gases in suitably designed time-of-flight experiments~\\cite{kennedy2015bec,spielman2011gauge, spielman_gauge, tomoki2015nv}. Experiments on synthetic magnetic fields therefore present the opportunity of straightforwardly probing gauge-dependent physics. \n\nThis paper is organized as follows: in Section \\ref{sec:model} we introduce the trapped Harper-Hofstadter model, before reviewing how the eigenstates can be understood as momentum-space Landau levels in Section \\ref{sec:eigenstates}. We discuss the breakdown of approximations in Section \\ref{sec:berry-shift}, focusing on the energy shift from the off-diagonal matrix elements of the Berry connection. Then in Section \\ref{sec:driven-dissipation}, we add driving and dissipation to the model. In Section \\ref{sec:selection}, we show numerical results highlighting gauge-dependent effects, before presenting a viable proposal for a\nphotonics-based experiment in Section \\ref{sec:experiment}. Finally, we draw conclusions in Section \\ref{sec:conclusion}. \n\n\n\\section{Introduction to the trapped Harper-Hofstadter Model}\n\\label{sec:model}\n\nIn this paper, we study the Harper-Hofstadter Hamiltonian $\\mathcal{H}_0$ in the presence of an external harmonic trap. The full tight-binding Hamiltonian $\\mathcal{H}$ of this system is\n%\n\\begin{eqnarray}\n{\\resizebox{.9\\hsize}{!}{$\\displaystyle{\\mathcal{H}=\\mathcal{H}_0+\\frac{1}{2}\\kappa\n\\sum_{m,n}\\left[(m-m_0)^{2}+(n-n_0)^{2}\\right]\\hat{a}_{m,n}^{\\dagger}\\hat{a}_{m,n},}$}}  \\qquad \\label{eq:model}\\\\\n{\\resizebox{.9\\hsize}{!}{$\\displaystyle{\\mathcal{H}_0=-J\\sum_{m,n}(e^{i \\phi_{m,n}^x}\\hat{a}_{m+1,n}^{\\dagger}\\hat{a}_{m,n} \n+e^{i \\phi_{m,n}^y}\\hat{a}_{m,n+1}^{\\dagger}\\hat{a}_{m,n}) + \\text{h.c.} }$}} \\qquad\\label{eq:hh_hamiltonian}\n\\end{eqnarray}\n%\nwhere $J$ is the real hopping amplitude and $\\hat{a}_{m,n}^{\\dagger}$ ($\\hat{a}_{m,n}$) are the creation (annihilation) operators for a particle on a square lattice at site $(m,n)$. The harmonic trap is of strength $\\kappa$ and is centered at a position $(m_0, n_0)$ which, in general, need not coincide with a lattice site. Throughout, the lattice spacing is set equal to one. \n\nIn the Harper-Hofstadter model $\\mathcal{H}_0$, the hopping phases $\\phi = (\\phi_{m,n}^x, \\phi_{m,n}^y)$ are the Peierls phases gained by a charged particle hopping in the presence of a perpendicular magnetic field~\\cite{harper1955magnetic,hofstadter1976butterfly}. The sum of the phases around a square plaquette of the lattice is therefore equal to $2\\pi\\alpha$, where $\\alpha$ is the number of magnetic flux quanta through the plaquette (with $\\hbar=e=1$). For neutral particles, such as photons, these phases can be imposed artificially to simulate the effects of magnetism, for example, by inserting link resonators into an array of silicon ring resonators as mentioned above~\\cite{hafezi2013imaging}. \n\nAlthough the sum of phases around a plaquette is set by the external (synthetic) flux, the exact form of the hopping phases themselves depends on the choice of magnetic gauge. In the Landau gauge, for example, $\\phi = (0, 2\\pi\\alpha m)$ such that only the hopping amplitude along one direction is modified. Conversely, in the symmetric gauge, $\\phi = (-\\pi\\alpha n, \\pi\\alpha m)$ and so hopping terms along both $x$ and $y$ are affected, preserving the $C_4$ rotational invariance of the lattice. This gauge-dependence of the hopping phases is reflected in the spatial profile of the phase of an eigenstate of $\\mathcal{H}$. In a photonics experiment, this phase is an observable quantity as the intensity response of a system to a given external driving is determined by the overlap of the spatial amplitude distribution of the pump with the eigenstates. Such experiments will therefore be sensitive to the synthetic magnetic gauge as we discuss in Section \\ref{sec:experiment}.\n\n\\subsection{Toroidal Landau Levels in Momentum Space}\\label{sec:eigenstates}\n\nHaving introduced the full Hamiltonian  in Eq. \\refeq{eq:model}, we now review how the eigenstates of this model in an appropriate limit can be understood as toroidal Landau levels in momentum space~\\cite{price2014magnetic}. Throughout the following discussion, we assume that the trap is centered at the origin $(m_0, n_0)= (0,0)$.  \n\nWe begin from the eigenstates of the Harper-Hofstadter model $\\mathcal{H}_0\\ket{\\chi_{n,\\vt{p}}} = E_n ({\\bf p}) \\ket{\\chi_{n,\\vt{p}}}$, where $E_n ({\\bf p}) $ is the energy dispersion of band $n$ at crystal momentum $\\vt{p}$. As the spatially-dependent hopping phases in $\\mathcal{H}_0$ break translational invariance, new magnetic translation operators must be introduced to define a larger magnetic unit cell, containing an integer number of magnetic flux quanta~\\cite{zak1964group, zak1964representations, 1chang}. Then translational symmetry is restored and Bloch's theorem can be applied to write the eigenstates as $\\ket{\\chi_{n,\\vt{p}}} = \\frac{1}{\\sqrt{N}} e^{i\\vt{p}\\cdot \\vt{r}} \\ket{u_{n,\\vt{p}}}$, where $\\ket{u_{n,\\vt{p}}}$ is the periodic Bloch function and $N$ is the number of lattice sites. Thanks to the new larger unit cell, the crystal momentum and the periodic Bloch functions here are defined in the smaller magnetic Brillouin zone (MBZ). For example, hereafter, we take the number of flux quanta per plaquette to be of the form $\\alpha=1/q$, where $q$ is an integer. Then the magnetic unit cell can be chosen to be $q$ times larger than the original unit cell, while the MBZ is $q$ times smaller than the original BZ.\n\nAdding the harmonic trap breaks all translational symmetry of the lattice, but we can use the eigenstates of $\\mathcal{H}_0$ as a basis in which to expand the new wave function \n$\\ket{\\psi} = \\sum_n\\sum_{\\vt{p}} \\psi_n(\\vt{p})\n\\ket{\\chi_{n,\\vt{p}}}$. Substituting this expansion into the full Schr\\\"{o}dinger equation\n$i \\partial_t \\ket{\\psi} = \\mathcal{H} \\ket{\\psi}$, it can be shown that the expansion coefficients $\\psi_n(\\vt{p})$ satisfy~\\cite{price2014magnetic}:\n%\n\\begin{multline} \n  i \\partial_t \\psi_n(\\vt{p}) = E_n(\\vt{p}) + \\frac{\\kappa}{2}\\sum_{n^{'},n^{''}}\\left(\\delta_{n,n^{'}}i \\nabla_{\\vt{p}} + \\mathcal{A}_{n,n^{'}}(\\vt{p})\\right)\\times \\\\ \\times \\left(\\delta_{n^{'},n^{''}}i\\nabla_{\\vt{p}} + \\mathcal{A}_{n^{'},n^{''}}(\\vt{p})\\right) \\psi_{n^{''}}(\\vt{p}) ,  \\label{eq:first}\n\\end{multline}\nwhere $\\mathcal{A}_{n,n^{'}}(\\vt{p}) = i\\bra{u_{n,\\vt{p}}}\\nabla_{\\vt{p}}\\ket{u_{n^{'},\\vt{p}}}$ is the matrix-valued Berry connection. \n\nTo proceed, we consider the harmonic trap to be sufficiently weak compared to the bandgap that we can make a single-band approximation~\\cite{price2014magnetic}. This assumes that only one coefficient $\\psi_n$ is non-negligible and that the external trap does not significantly mix different energy bands. Then Eq. \\ref{eq:first} reduces to\n%\n\\begin{equation}\n  i \\partial_t \\psi_n(\\vt{p}) = \\widetilde{\\mathcal{H}} \\psi_n(\\vt{p}) ,\n\\end{equation}\nwhere we have introduced the effective momentum-space Hamiltonian\n%\n\\begin{equation}\\label{eq:dual}\n  \\widetilde{\\mathcal{H}} = \\frac{\\kappa}{2} [i\\nabla_{\\mathbf{p}} + \\mathcal{A}_{n, n}(\\mathbf{p})]^2 + E_n(\\mathbf{p}) + \\frac{\\kappa}{2}\\sum_{n^{'}\\neq n} \\abs{\\mathcal{A}_{n,n^{'}}(\\vt{p})}^2.\n\\end{equation}\n%\nFor the moment we focus on the first two terms; we discuss the role of the last term, which comes from the off-diagonal matrix elements of the Berry connection, in detail in the next subsection.\nAs can be seen, there is a close analogy between the first two terms in the momentum-space Hamiltonian and that of a charged\nparticle in an electromagnetic field {\\em in real space}:\n%\n\\begin{eqnarray} \\label{eq:mag}\n\\mathcal{H}'= \\frac{\\left[-i\\nabla_{\\vt{r}} - \\vt{A}(\\vt{r})\\right]^2}{2M} +  \\Phi({\\bf r}). \n\\end{eqnarray}\n%\nIn this analogy, the role of the particle mass $M$ is played by $\\kappa^{-1}$, while the scalar potential $ \\Phi({\\bf r})$ is replaced by the energy band dispersion $E_n(\\mathbf{p})$ and the magnetic vector potential $\\vt{A}(\\vt{r})$ by the intra-band Berry connection $\\mathcal{A}_{n, n}(\\mathbf{p})$. We note that both the magnetic vector potential and the Berry connection are gauge-dependent quantities. We hereafter refer to the gauge choice for the Berry connection as the Berry gauge, and the gauge choice for a real-space magnetic vector potential as the magnetic gauge. From the Berry connection, we can also define the geometrical Berry curvature $\\Omega_{n}(\\mathbf{p}) =\\nabla \\times \\mathcal{A}_{n, n}(\\mathbf{p})$, which acts like a momentum-space magnetic field $B(\\vt{r})$. \n\nThe topology of momentum space also plays a crucial role here, as the MBZ is topologically equivalent to a torus. One important consequence of this is of course that the integral of Berry curvature over the whole MBZ is quantised in units of the first Chern number $\\mathcal{C}_n$. In the above analogy with magnetism, this means that the particle is confined to move on the surface of a torus, while the Chern number counts the number of magnetic monopoles contained inside~\\cite{Fang}. \n\nThe above analogy with magnetism is particularly powerful because there are natural limits for our model (\\ref{eq:model}) in which the eigenstates of Eq. \\ref{eq:mag} and hence of Eq. \\ref{eq:dual} are known analytically~\\cite{price2014magnetic, ozawa2014momhh, Claassen_prl_2015}. We will focus on the flat-band limit in which the bandwidth is much smaller than the trapping energy; for the energy bands of $\\mathcal{H}_0$ with $\\alpha = 1/q$, this assumption improves as $\\kappa$ decreases or as $q$ increases. In this limit, we can firstly approximate $\\Omega_{n}(\\mathbf{p}) \\approx \\Omega_n$, so that the first term is analogous to the kinetic energy of a particle in a uniform magnetic field. Secondly, we can approximate\n$E_n(\\vt{p}) \\approx E_n$ so that the second term of $\\widetilde{\\mathcal{H}}$ is just a constant energy shift. Hence, the corresponding eigenstates can be understood as toroidal Landau levels in momentum space. We note that the opposite limit, in which the trapping energy is small compared to the bandwidth, also yields very interesting physics including the realisation of a Harper-Hofstatder model in momentum space~\\cite{ozawa2014momhh, scaffidi2014exact}. \n\nAs shown in Ref.~\\cite{price2014magnetic}, the momentum-space toroidal Landau levels form semi-infinite ladders of states:\n%\n\\begin{equation}\\label{eq:ladders}\n  \\epsilon_{n,\\beta} = E_n  + \\left(\\beta + \\frac{1}{2}\\right) \\kappa |\\Omega_n|  ,\n\\end{equation}\nwhere we have introduced the Landau level quantum number\n$\\beta = 0,1,2,\\dots$, and where $\\kappa |\\Omega_n|$ can be recognised as the analogue of the cyclotron frequency\n$\\omega_c = e |B| /M $. Again, we note that here we have neglected the contribution from the last term in (\\ref{eq:dual}), as this will be discussed in the next subsection. As can be shown from the Diophantine equation for the Hall conductivity, for odd values of $q$, the Chern number of all bands except the middle band is $\\mathcal{C}_n = -1$~\\cite{bernevig2013topological}. Then as the Chern number is related to the uniform Berry curvature as $\\mathcal{C}_n = (1/2\\pi) \\Omega_n A_{\\text{MBZ}}$, where $A_{\\text{MBZ}} = (2\\pi)^2/q$ is the MBZ area, the Berry curvature is given by $|\\Omega_n| = \\frac{1}{2\\pi\\alpha}$~\\cite{price2014magnetic}.  \n\nWhile the above spectrum does not directly depend on the toroidal topology of momentum space, the topology does enter into the eigenstate degeneracy, which is equal to $|\\mathcal{C}_n|$, as well as into the analytical form of the eigenstates in the MBZ. For example, for the bands with $\\mathcal{C}_n = -1$, the eigenstates can be written as~\\cite{price2014magnetic}\n%\n\\begin{eqnarray}\\label{eq:chi}\n \\chi_\\beta (\\vt{p}) &=& \\mathcal{N}_\\beta^{l_{\\Omega_n}} \\sum_{j = -\n \\infty}^{\\infty} e^{- i p_y j } e^{ - ( p_x + j  l_{\\Omega_n}^2 )\n ^2 / 2 l_{\\Omega_n}^2} \\nonumber \\\\ &&\n \\times H_\\beta ( p_x / l_{\\Omega_n} + j \n l_{\\Omega_n})  , \\\\\n \\mathcal{N}_\\beta^{l_{\\Omega_n}} &=& \\left( \\frac{\\sqrt{2/q}} {2^\\beta\n\\beta! \\times 2 \\pi l_{\\Omega_n}^2} \\right)^{1/2} , \n\\end{eqnarray}\n% \nwhere $H_\\beta$ are the Hermite polynomials and $l_{\\Omega_n} = \\sqrt{1/|\\Omega_n|}$ is the analogue of\nthe magnetic length. Here we have taken the Berry gauge to have a Landau form $\\mathcal{A}_n(\\mathbf{p}) = \\Omega_n p_x \\hat{\\vt{p}}_y$ parallel to the $\\hat{\\vt{p}}_y$ unit vector in  momentum space. We have also assumed that the MBZ is of length $2 \\pi$ in one momentum direction, and $2 \\pi / q$ in the other direction, corresponding to a magnetic unit cell of $q$ plaquettes containing one flux quantum. While this choice of MBZ is valid in any magnetic gauge of the underlying Harper-Hofstadter model, it is particularly natural when the hopping phases in $\\mathcal{H}_0$ are in the Landau magnetic gauge $\\phi = (0, 2\\pi\\alpha m)$, as we shall discuss further below. \n\n\n\\subsection{The Berry connection and the breakdown of approximations}\\label{sec:berry-shift}\n\nWe now study the effects of the last term in the momentum-space Hamiltonian~(\\ref{eq:dual}) which comes from the off-diagonal matrix elements of the Berry connection~\\cite{berry}:\n\\begin{align}\n  \\delta E_n(\\vt{p}) &\\equiv \\frac{\\kappa}{2}\\sum_{n^{'}\\neq n} \\abs{\\mathcal{A}_{n,n^{'}}(\\vt{p})}^2\n  \\notag \\\\\n  &=\n  \\frac{\\kappa}{2}\\sum_{n^{'}\\neq n} \\frac{\\abs{\\bra{u_{n,\\vt{p}}}\\nabla_{\\vt{p}}\\mathcal{H}_0(\\vt{p})\\ket{u_{n^{'},\\vt{p}}}}^2}{\\left[E_{n^{'}}(\\vt{p}) - E_{n}(\\vt{p})\\right]^2}.\n  \\label{eq:shift}\n\\end{align}\nThis can be recognised as a momentum-space counterpart of the real-space geometrical scalar potential previously studied in atomic systems~\\cite{dum:1996, dutta:1999, dalibardrmp2011}. In these systems, the scalar potential arises from real-space Berry connections, which can be created, for example, by using spatially-dependent optical fields to dress the atoms. \n \nIn the flat-band limit, we have checked numerically that we can approximate the momentum-space geometrical scalar potential as $\\delta E_n(\\vt{p}) \\approx   \\delta E_n$ and so this contributes only a uniform constant energy shift. This term was not considered in our previous works~\\cite{price2014magnetic, ozawa2014momhh}, as these works focused on systems such as ultracold atomic gases, where the absolute energy is not easily experimentally observable. As we will discuss in the next section, spectroscopic measurements in photonics are sensitive to the energy of a state, and so such corrections may be extracted experimentally. We note that an analogous effect has also been derived for the effective momentum-space magnetic Hamiltonian for a trapped particle in an ideal flat band~\\cite{Claassen_prl_2015}, and predicted for the frequency spectrum associated with excitonic states in transition metal dichalcogenides~\\cite{srivastava:2015}.\n\nTo see under what conditions the off-diagonal elements of the Berry connection are relevant, we compare the energy $E_{\\text{ex}}$ obtained from an exact numerical diagonalization of Eq. \\ref{eq:model} with the analytical eigenenergy $  E_{\\text{an}}$ predicted by Eq.~\\eqref{eq:ladders}. We focus on the lowest ladder of states, associated with band $n=0$ (Eq. \\ref{eq:ladders}), at energies which are below the onset of the second ladder around energy $E_1$. This allow us to easily identify which numerical eigenvalue should correspond to which Landau level quantum number~\\cite{price2014magnetic}. \n\nWe introduce two dimensionless parameters $\\eta_{\\text{zpe}}$ and $\\eta_{\\text{lev}}$ to quantify deviations between the numerics and analytics. The former represents the error in the ``zero-point energy\", and is defined as the energy of the lowest numerical state relative to analytical $n=0, \\beta=0$ Landau level. The latter is the level spacing error, which we define as the difference between the numerical energy spacing between two neighbouring states and the analytical spacing between states with $\\beta$ and $\\beta-1$ quantum numbers.  \n\nConsidering first the ``zero-point energy\" error $\\eta_{\\text{zpe}}$, the analytical energy of the $n=0, \\beta=0$ Landau level is given from Eq. \\ref{eq:ladders} by:\n%\n\\begin{equation}\n  E_{\\text{an}} = \\left<E_0(\\vt{p})\\right>_{\\vt{p}} + \\frac{1}{2}\\frac{\\kappa}{2\\pi\\alpha} ,\n\\end{equation}\n%\nwhere we have used that $|\\Omega_n| = \\frac{1}{2\\pi\\alpha}$ and where we calculate the uniform energy shift $E_0=\\left<E_0(\\vt{p})\\right>_{\\vt{p}}$ as the average band-energy over the MBZ. This definition generalises our flat-band approximation to account for the non-zero bandwidth of the lowest band. \n\nWe then define the dimensionless parameter $\\eta_{\\text{zpe}}$ as \n\\begin{equation}\n\\eta_{\\text{zpe}} = \\frac{4\\pi\\alpha}{\\kappa} (E_{\\text{ex}} -E_{\\text{an}}). \n\\end{equation}\nThis dimensionless error is plotted with a dashed line as a function of $q$ for $\\kappa=0.02 J$ in the top panel of Fig.~\\ref{fig:zpe}. At small $q$, there is a large bandgap between the lowest two Harper-Hofstadter energy bands, but the lowest band also has a large bandwidth. In this regime, the single-band approximation is reasonable, while the flat-band approximation breaks down leading to large errors. This limit requires a different analytical approach as  previously presented in Ref.~\\onlinecite{ozawa2014momhh}.\nTo account for the error at large $q$, we include the shift from the off-diagonal matrix elements of the Berry connection (Eq. \\ref{eq:shift}). We calculate this shift numerically from the eigenstates of the Harper-Hofstadter model, and we incorporate it into a second parameter \n\\begin{equation}\n\\eta_{\\text{zpe}}^{\\text{nab}} = \\frac{4\\pi\\alpha}{\\kappa}(E_{\\text{ex}} - E_{\\text{an}} - \\left<\\delta  E_0(\\vt{p})\\right>_{\\vt{p}}).\n\\end{equation}\nThis is plotted as a solid line in the top panel of Fig.~\\ref{fig:zpe}. As can be seen, this shift dramatically reduces the error in the zero point energy at large $q$. We also calculate this shift considering only the effects of band mixing with the second lowest band $n=1$; this is indistinguishable on this scale from the full shift. This can be understood from the dependence on the bandgaps in Eq.~\\ref{eq:shift}, which shows that the contributions of high-energy bands are suppressed. As discussed further in Section \\ref{sec:experiment}, it would be possible experimentally to extract the energy of the lowest state; this could constitute the first direct measurement of the effects of the off-diagonal matrix elements of the Berry connection in a photonics system.\n\n\\begin{figure}[tb]\\centering\n  \\includegraphics[width=0.9\\linewidth]{nonabcorr} % anc/scripts/nonabelian_fig.jl\n  \\caption{\\emph{Top panel}: ``Zero-point energy\" error, with (solid curve,\n    $\\eta_{\\text{zpe}}^{\\text{nab}}$) and without (dashed line,\n    $\\eta_{\\text{zpe}}$) the shift from the off-diagonal matrix elements of the Berry connection. Including just the\n    first term in the sum Eq.~\\eqref{eq:shift} gives an identical\n    curve to the one of $\\eta_{\\text{zpe}}^{\\text{nab}}$. The chosen\n    trap strength is $\\kappa = 0.02 J$.  \\emph{Bottom panel}: Level-spacing\n    error, for the same trap strength, considering $\\beta = 0,1$\n    (solid curve), $\\beta = 1,2$ (dashed curve), $\\beta = 2,3$\n    (dashed-dotted curve) and $\\beta = 3,4$ (dotted curve).}\n  \\label{fig:zpe}\n\\end{figure}\n\nWe turn now to the level-spacing error $\\eta_{\\text{lev}}$. This can be expressed as \n\\begin{equation}\n\\eta_{\\text{lev}} = \\frac{2\\pi \\alpha}{\\kappa} [E_{\\text{ex}}(\\beta)\n- E_{\\text{ex}}(\\beta - 1)] -1, \n\\end{equation}\nwhere we have used that the analytical level spacing from Eq. \\ref{eq:ladders} is simply $\\kappa / 2\\pi \\alpha$. \nWe plot the level-spacing error in the bottom panel of Fig.~\\ref{fig:zpe} for $\\beta = 1, 2, 3$ and 4. As can be seen here, there is a large variation in the errors at small $q$ due to the large bandwidth~\\cite{ozawa2014momhh}. On the other hand, we see that $\\eta_{\\text{lev}} \\ll 1$, for $q \\gtrsim 6$, where the flat-band approximation improves. In this regime, the level-spacing error is much smaller than the zero-point error. This is because when the shift from the off-diagonal matrix elements of the Berry connection (Eq. \\ref{eq:shift}) is approximately uniform over the MBZ at large $q$, it just acts as a uniform energy shift on all the states in a  ladder with band index $n$. Consequently, this shift drops out of the level spacing error between states, leaving only higher-order band-mixing terms. From perturbation theory, it is expected that mixing with other bands leads to a negative energy shift on states in the lowest band, and indeed this can be seen in both $\\eta_{\\text{zpe}}^{\\text{nab}}$ and $\\eta_{\\text{lev}}$ in the small negative errors found at large $q$. \n\n\\subsection{Driving and dissipation}\\label{sec:driven-dissipation}\n\nWe now include in our model the driving and dissipation that are an integral part of the proposed photonics experiment. We assume there are uniform and local losses\ncharacterized by a loss rate $\\gamma$, and that the pump is\nmonochromatic, with frequency $\\omega_0$ and a spatial profile\n$f_{m,n}$. Following the treatment of Ref.~\\onlinecite{ozawa2014qhe}, we replace the bosonic creation and annihilation operators with their expectation\nvalues, as can be justified for a noninteracting system. The steady state evolution of the photon-field amplitude in a cavity then follows that of\nthe pump as $a_{m,n}(t) = a_{m,n} e^{-i \\omega_0 t}$. Combining Hamiltonian evolution with pumping and losses, one arrives at a set of linear coupled equations that can be solved numerically for the steady-state\\cite{cohen1992atom}:\n%\n\\begin{eqnarray}\\label{eq:linear_problem}\nf_{m,n} =J&&\\left[e^{-i\\phi_{m,n}^x}a_{m+1,n}+e^{i\\phi_{m-1,n}^x}a_{m-1,n} \\right. \\nonumber\\\\ &&\\left. +e^{-i\\phi_{m,n}^y}a_{m,n+1}+e^{i\\phi_{m,n-1}^y}a_{m,n-1}\\right] \\nonumber\\\\\n&&{\\resizebox{.8\\hsize}{!}{${+\\left[\\omega_{0}+i\\gamma-\\frac{1}{2}\\kappa \n\\left((m-m_0)^{2}+(n-n_0)^{2}\\right)\\right]a_{m,n}}$}} \\qquad\n\\end{eqnarray}\nwhere we have reintroduced the position of the harmonic trap centre $(m_0, n_0)$, although unless otherwise specified we set $(m_0, n_0)=(0,0)$ in our simulations.\n\nThe expectation values $\\abs{a_{m,n}}^2$ correspond to the number of photons\nat site $(m,n)$, whereas the intensity spectrum is given by their\ntotal sum $\\sum_{m,n} |a_{m,n}|^2$ as a function of pump frequency\n$\\omega_0$. These observables can be directly related to the eigenstates of the Hamiltonian in Eq. \\ref{eq:model}. Firstly, the different eigenmodes of a driven-dissipative system will appear as peaks in the transmission and/or absorption spectra under a coherent pump~\\cite{carusotto2013fluids}. The resonance peaks will be broadened by the decay rate $\\gamma$, while the area of the peaks will depend on the overlap between the spatial amplitude\nprofile of the pump and the underlying eigenstate of $\\mathcal{H}$ at that energy. \n\nSecondly, when the pump frequency is set on resonance with a given mode, the intensity profiles in both real- and momentum-space reproduce the wave function of that mode~\\cite{carusotto2013fluids}. This corresponds respectively to measuring the near-field and far-field spatial emission of photons from the cavity array. We note that the far-field emission is simply the Fourier-transform of the real-space wave function and so will be a function of crystal momentum defined in the full BZ. To reach the MBZ, a  further processing step is required; for example, if the Harper-Hofstadter Hamiltonian is in the Landau gauge and if we choose a magnetic unit cell of $q$ plaquettes along $\\hat{x}$, the appropriate transformation takes a particularly simple form~\\cite{price2014magnetic}:\n%\n\\begin{equation} \\label{eq:trans}\n  \\sum_n \\abs{\\psi_n(\\vt{p}_\\mathrm{MBZ})}^2 = \\sum_j \\abs{\\psi(\\vt{p}_\\mathrm{BZ} = \\vt{p}_\\mathrm{MBZ}- j\\vt{G})}^2 ,\n\\end{equation}\n%\nwhere $\\psi_n(\\vt{p}_\\mathrm{MBZ})$ is the wave function coefficient in the MBZ, while $\\psi(\\vt{p}_\\mathrm{BZ})$ is that in the original BZ. In this expression, $j$ is an integer, while $\\vt{G} = (2\\pi/q) \\hat{\\vt{p}}_x $ is the magnetic reciprocal lattice vector, where the factor of $q$ is due to the enlarged magnetic unit cell. We note that for other magnetic gauges or for other choices of the magnetic unit cell, this transformation will in general be more complicated. In this sense, we call this choice of magnetic unit cell, a ``natural\" choice when the Harper-Hofstadter Hamiltonian is in the Landau gauge.\nIn the rest of the article, we denote the momentum in the original BZ as $\\mathbf{p}$, and that in the MBZ as $\\mathbf{p}^0$.\n\n\\section{Results and discussion}\n\\label{sec:results}\n\n\\subsection{Pumping \\& gauge-dependent effects}\n\\label{sec:selection}\n\n\\begin{figure}[tb]\\centering\n  \\includegraphics[width=\\linewidth]{selection} % anc/scripts/selection_fig.jl\n  \\caption{(Color online) Intensity spectra for different pumping conditions: (a)\n    pumping the single site (5,5), (b) pumping with a Gaussian\n    profile centered at site (5,5) with width $\\sigma=1$, (c) homogeneous pumping across all lattice sites and (d) pumping with a random\n    phase across all lattice sites. These results were obtained by numerical solving Eq.~\\eqref{eq:linear_problem} for the steady-state in a lattice of\n$N \\times N = 45 \\times 45$ sites, with $\\kappa = 0.02 J$,\n$\\gamma = 0.001 J$ and $\\alpha = 1/11$.   \n    Black (solid) curves correspond to using the Landau gauge while\n    green (dashed) ones to the symmetric gauge. The dotted vertical\n    lines (with labels indicating the value of $\\beta$) mark the\n    states which were selected for later analysis. The spectra in\n    panels (a) and (d) are identical for both gauges.}\n  \\label{fig:pumping_schemes}\n\\end{figure}\n\nAs introduced above, spectroscopic measurements can be used in a driven-dissipative photonics experiment to study the trapped Harper-Hofstadter model and hence toroidal Landau levels in momentum space. In this section, we focus on the effects of the pumping, exploring how different pumping schemes excite the eigenstates with different weights. We find that such spectroscopic measurements are sensitive to the underlying synthetic magnetic gauge chosen in a given implementation of the Harper-Hofstadter Hamiltonian. \n\nTo best illustrate these gauge-dependent effects, we present the results of numerically solving\nEq.~\\eqref{eq:linear_problem} for the steady-state in a large lattice of\n$N \\times N = 45 \\times 45$ sites, with $\\kappa = 0.02 J$,\n$\\gamma = 0.001 J$ and $\\alpha = 1/11$.  These parameters are chosen to highlight the key features of different pumping schemes; we will present numerical results for a more realistic experimental system in Section \\ref{sec:experiment}.  The numerical code was written\nin \\textsc{Julia}~\\cite{bezanson2014julia} and is available in the Supplemental Material~\\footnote{See Supplemental Material.}. \n\nThe intensity spectrum of the steady-state as a function of pump\nfrequency is shown in Fig.~\\ref{fig:pumping_schemes}, where we compare results for both the Landau and symmetric gauge for four pumping\nschemes, discussed in turn below. For simplicity we limit ourselves to pump frequencies located between the two lowest-lying Harper-Hofstadter bands of the untrapped system. This allows us to focus only on states within the first ladder of the trapped system (Eq.~\\eqref{eq:ladders} with $n = 0$). At higher energies, the clear identification of states is more difficult as more than one ladder of toroidal Landau levels can overlap, as shown, for example, in Section \\ref{sec:experiment}. \n\n{\\em{Single-site pumping--}}The first and simplest case that we consider is that of pumping a single site $f_{m,n} = \\delta_{m,m_0} \\delta_{n,n_0}$ at an off-center lattice site. These results are shown in Fig.~\\ref{fig:pumping_schemes} panel (a), where the uniform energy spacing of the toroidal Landau levels can be clearly observed. For this pumping scheme, we find no significant differences between the spectra for the Landau or symmetric gauge. This is to be expected as changing the gauge is equivalent\nto changing the relative phase between different sites, but as we are only pumping one site, this phase difference is unimportant.\n\n Instead, for both magnetic gauges, we see that the peak height is very small for low energy states, rising to a maximum as energy increases, before decreasing once more. This behaviour can be understand by considering the form of the real space wavefunctions of $\\mathcal{H}$. \nIn real space, the eigenstates are rings of finite width which increase in radius as the energy increases (as can be seen in Fig.~\\ref{fig:delta_real_sp}). Analytically, we can predict how the ring radius scales with energy by remembering that the term\n$(\\beta + 1/2) \\kappa |\\Omega_n|$ in Eq. \\ref{eq:ladders} is the momentum-space kinetic energy\n$\\frac{\\kappa}{2}r^2$ where $r = i\\nabla_{\\mathbf{p}} + \\mathcal{A}_{0, 0}(\\mathbf{p})$ is the physical position operator in the lowest band. From this, we deduce that $r^2 \\approx \\frac{1}{\\pi} q \\beta$, as can be confirmed numerically. Therefore, if one pumps an off-center site, there will only be a\nlimited range of rings that will have radii that will overlap with\nthe pump spot and so be excited. Here, we have set the pump spot to be at position $(5,5)$, and from the above scaling, the toroidal Landau level that best overlaps with this pump will have a quantum number $\\beta \\approx 14$, which is in good agreement with the numerical results shown in\nFig.~\\ref{fig:pumping_schemes} (a). \n\n\\begin{figure}[tb]\n  \\centering\n  \\includegraphics[width=0.9\\linewidth]{real} % anc/scripts/selection_fig.jl\n  \\caption{(Color online) Real space reconstruction of the states $\\beta=3$, 6, 15\n    and 26 of Fig.~\\ref{fig:pumping_schemes}(a).}\n  \\label{fig:delta_real_sp}\n\\end{figure}\n\n{\\em{Gaussian pumping--}} We now consider a Gaussian pump as the next logical step up in complexity from a single-site pump. This has the form $f_{m,n} = \\exp- \\frac{1}{2\\sigma^2} \\left[(m-m')^2 + (n-n')^2\n\\right]$, and we choose $\\sigma =1$ and for the pump centre to be at $(m',n') = (5,5)$, as for single-site pumping. The results are shown in Fig.~\\ref{fig:pumping_schemes} (b). The main effect is, as expected, that more states\nbecome visible in both the low- (smaller $\\beta$) and high-energy (larger $\\beta$) sections of the spectrum. This is because the pump has a greater spatial width and so overlaps with a larger range of real-space eigenstates. \n\nHowever, we can also see that the intensity spectrum now depends on the underlying magnetic gauge, as the phase of the eigenstates is important. In particular, more high-energy peaks can be seen for the Landau gauge than for the symmetric gauge. This can be most easily understood by noting that in momentum space, the symmetric-gauge states also have a ring-like structure (see bottom panel of Fig.~\\ref{fig:hom_mom_sp}), where the ring radius increases with $\\beta$. To see this, we note that, in the symmetric gauge, the real-space wavefunctions have a phase which\nwinds around the ring as $e^{i\\beta \\phi}$ where $\\phi$ is the polar angle around the ring. This phase-winding sets the radius of the rings in momentum space as $p^2 \\approx \\pi \\frac{\\beta}{q}$; a scaling that can be confirmed numerically and seen in Fig.~\\ref{fig:hom_mom_sp}, bottom panel. (The white spot close to the edges of the rings in these figures is due to destructive interference with the pump.)  As the Fourier transform of the Gaussian pump is again a Gaussian, it follows that only a limited range of low-energy symmetric-gauge momentum-space states will have a good overlap with the pump. The high energy portion of the spectrum is therefore washed out compared to its Landau gauge\ncounterpart, where states have higher amplitude close to the centre of the BZ and so better overlap with the pump. \n\n\\begin{figure}[tb]\\centering\n  \\includegraphics[width=0.9\\linewidth]{momentum} % anc/scripts/selection_fig.jl\n  \\caption{(Color online) Momentum space reconstruction of the\n    eigenstates. \\emph{Top row}: states corresponding to $\\beta=0$, 2,\n    4 and 6 in Fig.~\\ref{fig:pumping_schemes}(c), using the\n    Landau gauge.  \\emph{Bottom row}: states corresponding to\n    $\\beta=0$, 1, 9 and 20 in Fig.~\\ref{fig:pumping_schemes}(b), using the symmetric gauge.}\n  \\label{fig:hom_mom_sp}\n\\end{figure}\n\nBefore continuing, we also note that for sufficiently large values of $\\beta$ the symmetric-gauge rings in momentum space will increase to the point where they touch the BZ boundaries. When this occurs, self-interference patterns appear in the wave function as shown for example in Fig.~\\ref{fig:torus_edge}. The extra ring-like structures appearing for $\\beta \\geq 30$ in Fig.~\\ref{fig:torus_edge} are due to the close proximity of states pertaining to other ladders with\n$n >0$. Note that in order to excite such high-energy states, we have used a pump with a homogeneous amplitude and a random onsite phase, as will be presented as the fourth pumping case below. \n\n{\\em{Homogeneous pumping with uniform phase--}} If we now take the limit of a very wide Gaussian, we reach a homogeneous pump profile extended over all lattice sites. The results for this pumping scheme are shown in panel (c) of\nFig.~\\ref{fig:pumping_schemes}. Now $f_{m,n} = f$, and we see that the intensity spectrum is strongly magnetic-gauge dependent. In the Landau gauge, firstly, there are visible peaks for only\nhalf of the states. This can be understood by noting that a homogeneous pump in real space is a $\\delta$ function in momentum space centered in the\nmiddle of the BZ. If we consider the Landau-gauge eigenstates in the full BZ, as shown\nin the top row of Fig.~\\ref{fig:hom_mom_sp}, we see that the states with an even\nvalue of $\\beta$ have an even number of nodes, with a lobe at the BZ\ncenter. Conversely, the states with odd values of $\\beta$ have an odd number of nodes, including one at the BZ center. (These feature can be related back to the properties of the Hermite polynomials in the analytical eigenstates in the MBZ (Eq.~\\eqref{eq:chi}).) Consequently, only states with even values of $\\beta$ have a good overlap with the pump, and the intensity spectrum contains half the expected peaks, now separated by twice the toroidal Landau level energy spacing.  \n\nIn the symmetric gauge, secondly, we find only one out of every four\nstates for homogeneous pumping, as can be seen in the inset of Fig.~\\ref{fig:pumping_schemes}\n(c). This is due to the fact that, on a square lattice, the angular\nmomentum is conserved modulo 4, respecting the 4-fold rotational\nsymmetry. The peak intensity gets smaller for larger $\\beta$ because\nof the diminishing overlap of the localized central pump with the\nincreasing momentum-space ring discussed above.\n\n\\begin{figure}[tb]\n  \\centering\n  \\includegraphics[width=0.9\\linewidth]{sym_ring} % anc/scripts/torus_edge_fig.jl\n  \\caption{(Color online) Momentum space reconstruction of the eigenstates in the\n    full BZ, using the symmetric gauge and homogeneous pumping with a random on-site\n    phase. \\emph{Top row}: states corresponding to\n    $\\beta = 9, 20, 30$.  \\emph{Bottom row}: states corresponding to\n    $\\beta = 38, 59, 99$. Parameters are the same as in Fig.~\\ref{fig:pumping_schemes}.}\n  \\label{fig:torus_edge}\n\\end{figure}\n\n\n{\\em{Homogeneous pumping with a random on-site phase --}} As the fourth scheme, we consider a pump with a uniform amplitude over the lattice but a random site-dependent phase $\\phi_{m,n}$:\n$f_{m,n}=fe^{i\\phi_{m,n}}$. The phases are chosen from a random\nuniform distribution, and have values in the interval $[0,2\\pi)$. The\nbottom panel of Fig.~\\ref{fig:pumping_schemes} was obtained by\naveraging over 100 distinct realizations of these random phases. This\nresults in a relatively even intensity distribution, for both gauges, where we can associate a peak to each toroidal Landau level in this energy window. While such a pumping scheme would therefore be the best way to excite all the eigenstates and to fully probe the momentum-space physics, we note that this would also be difficult to achieve in an experiment.\n\nBefore continuing, we give a final example of an interesting gauge-dependent effect that could be studied experimentally in this system. Unlike the physics discussed above, this is not directly related to the pumping but instead to the behaviour of the wave function under a change in the centre of the harmonic trap $(m_0, n_0)$. As derived in Ref. ~\\onlinecite{ozawa2014momhh}, moving the\nharmonic trap in space changes the boundary conditions on the wave function in the MBZ. We note that although this derivation was made explicitly for the magnetic Landau gauge in the MBZ, numerically we observe here that this physics is also observed in the full BZ in both gauges. \nAs shown in Fig.~\\ref{fig:moving_trap}, a shift in the harmonic trap centre in one direction shifts the observed momentum-space pattern in the perpendicular direction. This behaviour can be understood as a realisation of Laughlin's {\\em Gedankenexperiment} for the quantum Hall effect but now in momentum space~\\cite{ozawa2014momhh}. As we observe, the momentum-space wave function returns to itself after the harmonic trap has been moved $q$ lattice sites for the magnetic Landau gauge but $2q$ lattice sites for the magnetic symmetric gauge, reflecting the underlying translational symmetry of $\\mathcal{H}_0$ in the two different gauges. \n\n\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[width=\\linewidth]{fringe_trap} % anc/scripts/torus_edge_fig.jl\n  \\caption{(Color online) Momentum space reconstruction of the eigenstates in the\n    full BZ, using the Landau (top row) and symmetric gauge (middle\n    and bottom row) and a spatially homogeneous pump with\n    a random on-site phase. We have considered the state $\\beta = 4$ for\n    different trap positions $(m_0, n_0)$. For the top and middle\n    rows, we have (from left to right): (0,0) (trap in the center),\n    (2,0), (5.5,0) and (11,0), whereas for the bottom row we chose the\n    positions (0,2), (0,5.5), (0,11) and (11,11). Parameters are the same as in Fig.~\\ref{fig:pumping_schemes}.}\n  \\label{fig:moving_trap}\n\\end{figure}\n\n\\subsection{Results for realistic experimental parameters}\n\\label{sec:experiment}\n\nWe now present numerical results for system parameters within current experimental reach, to demonstrate that the essential characteristics of toroidal Landau levels could be probed experimentally for the first time in photonics. We choose a small\nlattice of only $11 \\times 11$ sites, with losses of $\\gamma = 0.05 J$; this loss rate is in the same range as those present in the experiment of\nRef.~\\onlinecite{hafezi2013imaging}. Such a large loss rate broadens the\npeaks in the intensity spectrum, making closely-spaced eigenenergies harder to resolve. From\nEq.~\\eqref{eq:ladders}, we see that the level spacing is given by\n$\\frac{\\kappa}{2\\pi\\alpha}$, and so we can increase the energy spacing by applying a stronger harmonic potential, chosen here as $\\kappa = 0.2 J$. Increasing the strength of the harmonic trap improves our flat-band approximation, but weakens the single-band approximation. To compensate for this, we consider a larger value of $\\alpha = 1/7$, for which the larger band-gap $(E_1 - E_0)$ reduces band-mixing effects. \n\nAs in the experiment of Ref.~\\onlinecite{hafezi2013imaging}, we work in the Landau gauge for the Harper-Hofstadter Hamiltonian, with hopping phases given by $\\phi = (0, 2\\pi\\alpha m)$. In order to model the experimental pumping scheme where light was injected into a single resonator at the edge of the system via an external integrated waveguide~\\cite{hafezi2013imaging}, we consider a localized pump on a single site situated on the upper border of the system at $(m_0,n_0)= (0,5)$. \nThe corresponding intensity spectrum is shown in the 1st row of Fig.~\\ref{fig:exp}. Apart from the expected\nbroadening due to larger losses, the peaks observed correspond well to the expected eigenenergies. \nAs discussed above, single-site pumping limits the number of visible peaks, as the heights of the peaks at low-energies are suppressed due to the poor overlap of the real-space eigenstate with the pump position. However, as this pumping scheme is closest to that used in experiments, we emphasise that even in this case, enough peaks can be observed to extract quantitative measurements of the toroidal Landau level spacing. We also note that here for frequencies larger\nthan $-1.5 J$, we also start to see states from the second ladder\n$\\epsilon_{1,\\beta}$ (see Eq.~\\eqref{eq:ladders}), which are depicted as green\nvertical dash-dotted lines. Their proximity to the first ladder states\nmeans they cannot be easily resolved as separate peaks in the dissipative\nspectrum.\n\n\n\\begin{figure}[tb]\n  \\centering\n  \\includegraphics[width=\\linewidth]{exp_fig} % anc/scripts/experimental_fig.jl\n  \\caption{(Color online) \\emph{Top row}: Intensity spectrum for a small lattice of $11 \\times 11$ sites, with\n    $\\gamma = 0.05 J$, $\\kappa = 0.2 J$ and $\\alpha=1/7$. The orange vertical (dashed) lines\n    show the first ladder of eigenstates of $\\mathcal{H}$ from Eq.~\\eqref{eq:model}. The second ladder of states is indicated with green vertical dash-dotted lines.\n  \\emph{Second row}: Profile of the $\\beta=7$ state in real space\n    (left), momentum space (center) and the population over bands in the MBZ (right) for the conservative system with no pumping nor decay.\n    \\emph{Third row}: Reconstruction of the $\\beta=7$ mode wavefunction in real space (left), momentum space (center) and the population over bands in the MBZ (right) obtained in the driven-dissipative system by setting the pump frequency at $\\omega_0 = -1.63 J$ on resonance with the desired mode (black dotted line in the top panel).\nThe $\\delta$-like pump at (0,5) is visible as a dark square in the left panel.\n    \\emph{Bottom row}: Slice along the $p_x^0 = 0$ line in the MBZ\n    (solid black line) compared to the analytical prediction of\n    Eq.~\\eqref{eq:chi}, $|\\chi_7(0,p_y)|^2$ (blue dotted line) and to the population over bands for the nondissipative system (dashed orange line).}\n  \\label{fig:exp}\n\\end{figure}\n\n\nSetting the pump frequency at the energy indicated by the black dotted\nline, we plot the numerical near- and far-field emission in the left and center panels of the 3rd row of Fig.~\\ref{fig:exp}. This corresponds to \nthe wave function in real space and in the full\nBZ respectively. By applying the transformation in Eq. \\ref{eq:trans}, we can also map the wave function in the full BZ to the population over bands in the MBZ, as shown in the right panel of the 3rd row of Fig.~\\ref{fig:exp}. For comparison, we plot these\nquantities for the corresponding numerical eigenstate of $\\mathcal{H}$ (Eq.~\\eqref{eq:model})\nin the second row of Fig.~\\ref{fig:exp}, for which there is no pumping and dissipation. \n\nWe find very good qualitative agreement between the numerical results in the MBZ and the analytical toroidal Landau level (\\ref{eq:chi}) with $\\beta=7$ as expected. We can make a quantitative comparison with this analytical eigenstate by taking\na slice along the dash-dotted vertical lines ($p_x^0 = 0$) in the\nright column of rows 2 and 3; these cuts are shown in the bottom panel of Fig.~\\ref{fig:exp} along with a dotted blue curve indicating the analytical eigenstate. As can be seen, there is excellent agreement between the numerics without driving and dissipation and the analytical result. We have checked that reducing $\\kappa$ makes this fit even better, pointing towards band-mixing effects. Introducing pumping and dissipation distorts the eigenstate, but many characteristic features are still clearly observable. \n\nIt is particularly interesting to note that in the driven-dissipative steady-state in real space, shown in the left panel of the 3rd row of Fig.~\\ref{fig:exp}, the photon distribution breaks the rotational symmetry of the ring eigenstate. While this can be physically understood \nas a\ndecaying cyclotron orbit with an inverse lifetime set by $\\gamma$, in terms of eigenmodes the exponential decay (and more generally the breaking of the rotational symmetry) results from the interference of several modes which overlap in frequency due to the relatively large value of $\\gamma$.\nIn the same way that real-space Landau\nlevels give rise to real-space cyclotron orbits under the effect of the magnetic field, the observation of momentum-space\nLandau levels can provide clear evidence of a cyclotron orbit in momentum space under the effect of the Berry curvature, whose effect is indeed that of a momentum-space magnetic field.\n\nFinally, we briefly summarize how one can practically measure the\ncontribution $\\delta E_0$ from the off-diagonal matrix elements of the Berry connection\n (see Eq.~\\eqref{eq:shift}) from the intensity spectrum. Starting from an experimental\nspectrum, one first needs to select a particular peak and determine\nits $\\beta$ label by comparing the MBZ reconstruction with the\nanalytical result. The distance between two neighbouring peaks gives\nthe level spacing $\\kappa \\abs{\\Omega_0}$. Finally, to separate the shift $\\delta E_0$ from the Harper-Hofstadter ground state\nenergy $E_0$ in Eq.~\\eqref{eq:ladders}, one can make use of the fact\nthat the former depends on the trap strength $\\kappa$, while the\nlatter does not. Preparing two otherwise identical samples with different trap\nstrengths and subtracting the ground state energy will then allow for a\ndirect measurement of the contribution from the off-diagonal matrix elements of the Berry connection. \n\n\\section{Conclusion}\n\\label{sec:conclusion}\n\nIn conclusion, we have shown that the observation of toroidal Landau levels in momentum\nspace is within experimental reach for state-of-the-art driven-dissipative photonic\nsystems. Our proposal combines the recent realisation of the Harper-Hofstatder model in an array of silicon-based coupled ring resonators in\nRef.~\\onlinecite{hafezi2013imaging}, with a harmonic potential, which could be introduced through a spatial modulation of the resonator size. We have presented numerical results to show that even for very small lattices, in the presence of driving and strong dissipation, key characteristics of the toroidal Landau levels can still be extracted. This would be a first direct investigation of analogue magnetic eigenstates in momentum space. \n\nWe have also emphasised that the proposed photonics experiment would be able to highlight a momentum-space analog of the cyclotron motion as well as to measure the energy shift due to the off-diagonal matrix elements of the Berry connection, which, as these are inter-band geometrical properties, are hard to access by other means. We have also discussed how the spectroscopic measurements presented here are sensitive to the specific synthetic magnetic gauge implemented in an experiment. \n\nFinally, an interesting outlook would be to include the effect of photon-photon interactions in the model, as the degenerate ground states predicted in~\\cite{ozawa2014momhh} for a weakly-interacting trapped Harper-Hofstadter model may lead to interesting nonlinear dynamical features. In the longer run, when the synthetic gauge field is combined with strong interactions, one can hope to observe the hallmarks of fractional quantum Hall physics~\\cite{umucalilar2012fractional,hafezi2013non}.\n\n\n\\acknowledgments\n\nWe are grateful to Ajit Srivastava, Ata\\c{c} Imamo\\v{g}lu and Germain Rousseaux for stimulating discussions. A.C.B. acknowledges financial support from the ESF through the POLATOM grant 4914. H.M.P., T.O. and I.C. were funded by ERC through the QGBE grant, by the EU-FET Proactive grant AQuS (Project No. 640800), and by Provincia Autonoma di Trento, partially through the project ``On silicon chip quantum optics for quantum computing and secure communications - SiQuro\". H.M.P was also supported by the EC through the H2020 Marie Sklodowska-Curie Action, Individual Fellowship Grant No: 656093 ``SynOptic\".\n\n\\bibliographystyle{apsrev4-1}\n\\bibliography{topo}\n\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "16f96af9a0acf2ffd9cf482ac683c52e2b7c5e44", "size": 57812, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "toroidalphoton.tex", "max_stars_repo_name": "berceanu/topo-photon", "max_stars_repo_head_hexsha": "3cce4709a67ad3fb4e4ca731c16e7e27e47baa66", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "toroidalphoton.tex", "max_issues_repo_name": "berceanu/topo-photon", "max_issues_repo_head_hexsha": "3cce4709a67ad3fb4e4ca731c16e7e27e47baa66", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "toroidalphoton.tex", "max_forks_repo_name": "berceanu/topo-photon", "max_forks_repo_head_hexsha": "3cce4709a67ad3fb4e4ca731c16e7e27e47baa66", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 111.1769230769, "max_line_length": 1375, "alphanum_fraction": 0.7665536567, "num_tokens": 15413, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.4241690889092696}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{subcaption}\n\\usepackage{bm}\n\n\\usepackage{amsthm}\n\\newtheorem{defn}{Definition}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{12cm}\n\\setlength{\\figureheight}{6cm}\n\n\\newlength\\squarefigurewidth\n\\newlength\\squarefigureheight\n\n\\setlength{\\squarefigurewidth}{4cm}\n\\setlength{\\squarefigureheight}{4cm}\n\n\\newlength\\smallsquarefigurewidth\n\\newlength\\smallsquarefigureheight\n\n\\setlength{\\smallsquarefigurewidth}{3.25cm}\n\\setlength{\\smallsquarefigureheight}{3.25cm}\n\n\\newlength\\smallfigurewidth\n\\newlength\\smallfigureheight\n\n\\setlength{\\smallfigurewidth}{6.25cm}\n\\setlength{\\smallfigureheight}{4cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\trans}{^\\top}\n\\newcommand{\\mat}[1]{\\bm{\\mathrm{#1}}}\n\\renewcommand{\\vec}[1]{\\bm{\\mathrm{#1}}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\renewcommand{\\epsilon}{\\varepsilon}\n\\newcommand{\\Exp}{\\mathbb{E}}\n\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\cov}{cov}\n\\DeclareMathOperator{\\diag}{diag}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\begin{document}\n\n\\section*{Dynamical Systems and the Kalman Filter}\n\nSuppose you periodically make noisy observations of an object that you\nwish to track.  We assume that the state of the object is evolving\nunder known dymanics.  This is a reasonable assumption in many\nscenarios, where the dynamics might be known.  For example, the system\nmight be evolving under well-understood Newtonian mechanics.\n\nThe \\emph{Kalman filter} is a probabilistic mechanism for reasoning\nabout a sequence of state variables at discrete time steps:\n\\[\n  \\{\\vec{x}_0, \\vec{x}_1, \\dotsc \\}\n\\]\nevolving (noisily) under known mechanics that are assumed to be\nlinear.  Specifically, the assumption we make is\n\\[\n  \\vec{x}_t = \\mat{F}_t \\vec{x}_{t - 1} + \\vec{w}_t,\n\\]\nwhere $\\mat{F}_t$ is a known, possibly time-dependent matrix and\n$\\vec{w}_t$ is a noise term.  We wish to maintain a probabilistic\nbelief about the state variables $\\{\\vec{x}_t\\}$.\n\nTo inform our beliefs, we assume that we make noisy measurements of\n$\\vec{x}$ at every time step.  Specifically, in the Kalman filter, we\nassume that we make a noisy measurement $\\vec{z}_t$ at time $t$ that\nis related to $\\vec{x}_t$ via a linear transformation and the possible\naddition of more noise:\n\\[\n  \\vec{z}_t = \\mat{H}_t \\vec{x}_t + \\vec{v}_t,\n\\]\nwhere $\\mat{H}_t$ is again a known, possibly time-dependent matrix\nand $\\vec{v}_t$ is a noise term.\n\n\\subsection*{Kalman filter: modeling details}\n\nThe Kalman filter repeatedly applies Gaussian identities to\nreason about the evolution of a hidden state $\\vec{x}$ given\nthe observation sequence $\\{ \\vec{z}_t \\}$.\n\nIn the Kalman filter, we maintain a probabilistic belief about\n$\\vec{x}_t$ that is a multivariate Gaussian distribution.\nSpecifically, we will assume (for the sake of induction) that our\nbelief about the state $\\vec{x}_{t - 1}$ given all observations\nup to time $t - 1$ was a multivariate Gaussian distribution:\n\\[\n  p(\\vec{x}_{t - 1} \\given \\mat{Z}_{t - 1})\n  =\n  \\mc{N}(\\vec{x}_{t - 1};\n  \\hat{\\vec{x}}_{t - 1 \\given t - 1},\n  \\mat{P}_{t - 1 \\given t - 1}\n  ),\n\\]\nwhere we have defined $\\mat{Z}_{t - 1}$ to indicate all observations\nup to time $t - 1$ and have adopted standard Kalman filter notation,\nusing the subscript $t \\given t'$ to indicate our belief about\n$\\vec{x}_t$ given observations $\\mat{Z}_{t'}$.\n\nTo make inference tractable, the Kalman filter additionally assumes\nthat the noise term $\\vec{w}_t$ is independent of $\\vec{x}_t$, with\nzero mean and known covariance $\\vec{Q}_t$:\n\\[\n  p(\\vec{w}_t) = \\mc{N}(\\vec{w_t}; \\mat{0}, \\mat{Q}_t).\n\\]\nRecalling our assumption about the dynamics of $\\vec{x}$:\n\\[\n  \\vec{x}_t = \\mat{F}_t \\vec{x}_{t - 1} + \\vec{w}_t,\n\\]\nwe may derive our belief about $\\vec{x}_t$ given $\\mat{Z}_{t - 1}$; we\nhave simply linearly transformed $\\vec{x}_{t - 1}$ and added\nindependent Gaussian noise.  Applying standard results, we may derive:\n\\[\n  p(\\vec{x}_t \\given \\mat{Z}_{t - 1})\n  =\n  \\mc{N}(\\vec{x}_t;\n  \\hat{\\vec{x}}_{t \\given t - 1},\n  \\mat{P}_{t \\given t - 1}\n  ),\n\\]\nwhere\n\\begin{align*}\n  \\hat{\\vec{x}}_{t \\given t - 1}\n  &=\n  \\mat{F}_t \\hat{\\vec{x}}_{t - 1 \\given t - 1}\n  \\\\\n  \\mat{P}_{t \\given t - 1}\n  &=\n  \\mat{F}_t\n  \\mat{P}_{t - 1 \\given t - 1}\n  \\mat{F}_t\\trans\n  +\n  \\mat{Q}_t.\n\\end{align*}\nAdditionally, we may again apply standard results to derive the joint\ndistribution of $\\vec{x}_t$ and the observation $\\vec{z}_t$\n\\emph{before} we receive observation $\\vec{z}_t$.  This will be a\nmultivariate Gaussian distribution that we will condition on the\ntrue value of the observation, updating our belief about $\\vec{x}_t$\ngiven $\\mat{Z}_t$.\n\nWe recall the linear observation assumption:\n\\[\n  \\vec{z}_t = \\mat{H}_t \\vec{x}_t + \\vec{v}_t.\n\\]\nAgain, the Kalman filter assumes that the observation noise at time\n$t$ is independent and zero-mean with known covariance $\\mat{R}_t$:\n\\[\n  p(\\vec{v}_t) = \\mc{N}(\\vec{v_t}; \\mat{0}, \\mat{R}_t).\n\\]\nNow the joint distribution of $\\vec{x}_t$ and $\\vec{z}_t$ given\nthe previous observations $\\mat{Z}_{t - 1}$ takes a familiar form:\n\\[\n  p(\\vec{x}_t, \\vec{z}_t \\given \\mat{Z}_{t - 1})\n  =\n  \\mc{N}\\biggl(\n  \\begin{bmatrix}\n    \\vec{x}_t\n    \\\\\n    \\vec{z}_t\n  \\end{bmatrix}\n  ;\n  \\begin{bmatrix}\n    \\hat{\\vec{x}}_{t \\given t - 1}\n    \\\\\n    \\mat{H}_t\n    \\hat{\\vec{x}}_{t \\given t - 1}\n  \\end{bmatrix}\n  ,\n  \\begin{bmatrix}\n    \\mat{P}_{t \\given t - 1}\n    &\n    \\mat{P}_{t \\given t - 1}\n    \\mat{H}_t\\trans\n    \\\\\n    \\mat{H}_t \\mat{P}_{t \\given t - 1}\n    &\n    \\mat{H}_t \\mat{P}_{t \\given t - 1} \\mat{H}_t\\trans + \\mat{R}_t\n  \\end{bmatrix}\\biggr).\n\\]\nThis is called the \\emph{predict} step of the Kalman filter, and was\nmade tractable due to the linearity of the state and observation\ndynamics and the multivariate Gaussian assumptions made about the\nprevious state $\\mat{x}_{t - 1}$ and the noise terms $\\vec{w}_t$ and\n$\\vec{v}_t$.\n\nNow we observe the value $\\vec{z}_t$ and condition the above\ndistribution to derive the new belief $p(\\vec{x}_t \\given \\mat{Z}_t)$.\nFirst, we define\n\\begin{align*}\n  \\mat{S}_t &= \\mat{H}_t \\mat{P}_{t \\given t - 1} \\mat{H}_t\\trans + \\mat{R}_t \\\\\n  \\mat{K}_t &= \\mat{P}_{t \\given t - 1} \\mat{H}_t\\trans \\mat{S}_t\\inv.\n\\end{align*}\nThe first term is simply the covariance of $\\vec{z}_t$ given\n$\\mat{Z}_{t - 1}$, and the second term is traditionally called the\n\\emph{Kalman gain.}  The Kalman gain simply falls out from the\nstandard conditioning formula for multivariate Gaussians.\nNow\n\\[\n  p(\\vec{x}_t \\given \\mat{Z}_t)\n  =\n  \\mc{N}(\\vec{x}_t;\n  \\hat{\\vec{x}}_{t \\given t},\n  \\mat{P}_{t \\given t}\n  ),\n\\]\nwhere\n\\begin{align*}\n  \\hat{\\vec{x}}_{t \\given t}\n  &=\n  \\hat{\\vec{x}}_{t \\given t - 1}\n  + \\mat{K}_t (\\mat{z}_t - \\mat{H}_t \\hat{\\vec{x}}_{t - 1 \\given t})\n  \\\\\n  \\mat{P}_{t \\given t}\n  &=\n  (\\mat{I}\n  -\n  \\mat{K}_t\n  \\mat{H}_t\n  )\n  \\mat{P}_{t \\given t - 1}.\n\\end{align*}\nThis is called the \\emph{update} step of the Kalman filter.  Notice\nthat our new belief about $\\vec{x}_t$ given $\\mat{Z}_t$ is once again\na multivariate Gaussian distribution, so we may continue this process\nrecursively.\n\n\\end{document}\n", "meta": {"hexsha": "ab7be9fe60e518b53148b71b16f50dbada6fa2df", "size": 8334, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_notes/The Kalman Filter/notes.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "lecture_notes/The Kalman Filter/notes.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "lecture_notes/The Kalman Filter/notes.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 29.5531914894, "max_line_length": 80, "alphanum_fraction": 0.6863450924, "num_tokens": 2843, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.42416908872986037}}
{"text": "\\section{Model Description}\n\n\\subsection{Problem Statement}\n\nThe formulation assumes that there is a rigid hub, with $N_P$ lumped masses in the tank for the fuel. Subscript $j$ is used to indicate the $j_\\text{th}$ fuel slosh mass, $m_j$. Figure~\\ref{fig:Slosh_Figure} displays the frame and variable definitions used for this formulation.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=13cm]{Figures/spacecraft.pdf}\n\t\\caption{Frame and variable definitions used for formulation}\n\t\\label{fig:Slosh_Figure}\n\\end{figure} \n\nThere are four coordinate frames defined for this formulation. The inertial reference frame is indicated by \\frameDefinition{N}. The body fixed coordinate frame, \\frameDefinition{B}, which is anchored to the hub and can be oriented in any direction. The initial pendulum frame, $\\mathcal{P}_{0,j}:\\{\\hat{\\bm p}_{0_j,1},\\hat{\\bm p}_{0_j,2},\\hat{\\bm p}_{0_j,3}\\}$, is a frame with its origin located at tank geometrical center, $T$. The $\\mathcal{P}_{0,j}$ frame is a fixed frame respect to the body frame, oriented such that $\\hat{\\bm{p}}_{0_j,1}$ points to the fuel slosh mass in its initial position, $P_{j}$. The constant distance from point $T$ to point $P_{j}$ is defined as $l_j$. \n\nThere are a few more key locations that need to be defined. Point $B$ is the origin of the body frame, and can have any location with respect to the hub. Point $B_c$ is the location of the center of mass of the rigid hub. $P_{c,j}$ is the instantaneous position of the fuel slosh mass $m_j$. $\\bm{d}$ is vector from the center of the body reference system to the tank geometrical center. $\\bm{l_j}$ is the vector from $T$ to $P_{c,j}$.\n\nFigure~\\ref{fig:Slosh_Detailed} provides further detail of the fuel slosh parameters and reference frames. As seen in Figure~\\ref{fig:Slosh_Figure}, an individual slosh particle is free to move in every direction while connected by rigid weightless rod to the geometrical center of the tank. A linear damper effect is considered using a damping matrix, $D$. The variables, $\\varphi_j$ and $\\vartheta_j$ are state variables and quantify the angular displacement from initial position for the corresponding slosh mass. \n\n\\begin{figure}[ht]\n\t\\centering\n\t\n\t\\includegraphics[width=13cm]{Figures/referencesystems.pdf}\n\t\\caption{Further detail of fuel slosh and reference frames}\n\t\\label{fig:Slosh_Detailed}\n\\end{figure}\n\nUsing the variables and frames defined, the following section outlines the derivation of equations of motion for the spacecraft.\n\n\\subsection{Derivation of Equations of Motion}\n\n\\subsubsection{Rigid Spacecraft Hub Translational Motion}\n\nThe derivation begins with Newton's first law for the center of mass of the spacecraft.\n\\begin{equation}\n\t\\ddot{\\bm r}_{C/N} = \\frac{\\bm{F}}{m_{\\text{\\text{sc}}}}\n\t\\label{eq:Newtons1Law}\n\\end{equation}\nUltimately the acceleration of the body frame or point $B$ is desired\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = \\ddot{\\bm r}_{C/N}-\\ddot{\\bm c}\n\t\\label{eq:RcRbacc}\n\\end{equation}\nThe definition of $\\bm{c}$ can be seen in Eq. (\\ref{eq:c}).\n\\begin{equation}\n\t\\bm{c} = \\frac{1}{m_{\\text{sc}}}\\Big(m_{\\text{\\text{hub}}}\\bm{r}_{B_{c}/B} +\\sum_{j=1}^{N_{P}}m_j\\bm{r}_{P_{c,j}/B}\\Big)\n\t\\label{eq:c} \n\\end{equation}\nTo find the inertial time derivative of $\\bm{c}$, it is first necessary to find the time derivative of $\\bm{c}$ with respect to the body frame. A time derivative of any vector, $\\bm{v}$, with respect to the body frame is denoted by $\\bm{v}'$; the inertial time derivative is labeled as $\\dot{\\bm{v}}$. The first and second body-relative time derivatives of $\\bm{c}$ can be seen in Eqs. (\\ref{eq:cprime}) and (\\ref{eq:cdprime}).\n\\begin{align}\n\t\\bm{c}' &= \\frac{1}{m_{\\text{sc}}}\\Big(\\sum_{j=1}^{N_{P}}m_j\\bm{r}'_{P_{c,j}/B}\\Big)\n\t\\label{eq:cprime}\n\t\\\\\n\t\\bm{c}'' &= \\frac{1}{m_{\\text{sc}}}\\Big(\\sum_{j=1}^{N_{P}}m_j\\bm{r}''_{P_{c,j}/B}\\Big)\n\t\\label{eq:cdprime}\n\\end{align}\nRemembering that the derivative of $d$ is null respect to the body frame, the first and second body time derivatives of $\\bm{r}_{P_{c,j}/B}$ are\n\\begin{equation}\n\t\\bm{r}_{P_{c,j}/B} = \n\tl_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t\\cos(\\varphi_j)\\cos(\\vartheta_j) \\\\\n\t\t\t\\sin(\\varphi_j)\\cos(\\vartheta_j) \\\\\n\t\t\t-\\sin(\\vartheta_j)\n\t\\end{bmatrix}}\n\t+ d\n\t\\label{eq:rPcjB}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm{r}'_{P_{c,j}/B} \n\t=\n\tl_j \n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\dot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\\\\n\t\t\t\\dot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\\\\n\t\t\t-\\dot{\\vartheta}_j\\cos(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:rPcjBprime}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm{r}''_{P_{c,j}/B} \n\t=\n\tl_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\\\ \\\\\n\t\t\t-\\ddot{\\vartheta}_j\\cos(\\vartheta_j)+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:rPcjBprimeprime}\n\\end{equation}\nEqs.~\\eqref{eq:cprime} and ~\\eqref{eq:cdprime} are next reformulated to include these new definitions:\n\n\n\\begin{multline}\n\t\\bm{c}' = \\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\\Big(-\\dot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)\\Big)\\bm{\\hat{p}}_{0_j,1}+\\\\\n\t\\Big(\\dot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,2}  -\\dot{\\vartheta}_j\\cos(\\vartheta_j) \\bm{\\hat{p}}_{0_j,3} \\bigg]\n\t\\label{eq:cprime2}\n\\end{multline}\n\n\n\\begin{multline}\n\t\\bm{c}'' = \\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)\\\\+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,1} \n\t+\\Big(\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,2}\n\t+\\Big(-\\ddot{\\vartheta}_j\\cos(\\vartheta_j)+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,3}\n\t\\bigg]\n\t\\label{eq:cdprime2}\n\\end{multline}\nUsing the transport theorem yields the following definition for $\\ddot{\\bm c}$\n\\begin{equation}\n\t\\ddot{\\bm c} = \\bm{c}'' + 2\\bm\\omega_{\\cal B/N}\\times\\bm{c}'+\\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c}+\\bm\\omega_{\\cal B/N}\\times\\left(\\bm\\omega_{\\cal B/N}\\times\\bm{c}\\right)\n\t\\label{eq:cddot}\n\\end{equation}\nEq.~\\eqref{eq:RcRbacc} is updated to include Eq.~\\eqref{eq:cddot}\n\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = \\ddot{\\bm r}_{C/N}-\\bm{c}'' - 2\\bm\\omega_{\\cal B/N}\\times\\bm{c}'-\\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c}-\\bm\\omega_{\\cal B/N}\\times\\left(\\bm\\omega_{\\cal B/N}\\times\\bm{c}\\right)\n\t\\label{eq:Rbddot}\n\\end{equation}\nSubstituting Eq.\\eqref{eq:cdprime2} into Eq.\\eqref{eq:Rbddot} results in\n\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N} = \\ddot{\\bm r}_{C/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,1} \n\t+\\Big(\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)\\\\-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,2}\n\t+\\Big(-\\ddot{\\vartheta}_j\\cos(\\vartheta_j)\\\\+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,3}\n\t\\bigg]\n\t- 2\\bm\\omega_{\\cal B/N}\\times\\bm c'\n\t-\\dot{\\bm\\omega}_{\\cal B/N}\\times\\bm{c}-\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times\\bm{c})\n\t\\label{eq:Rbddot2}\n\\end{multline}\nMoving second order terms to the left hand side and introducing the tilde matrix to replace the cross product operators simplifies the equation to\n\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N}-[\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)+\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)\\Big)\\bm{\\hat{p}}_{0_j,1}\\\\ +\\Big(-\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)+\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)\\Big)\\bm{\\hat{p}}_{0_j,2}+\\ddot{\\vartheta}_j\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\n\t\\bigg]= \\ddot{\\bm r}_{C/N} \t- 2[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t\\\\\n\t-[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,1} \\\\\n\t+\\Big(-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,2}\n\t+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\n\t\\bigg]\n\t\\label{eq:Rbddot3}\n\\end{multline}\nRearranging the terms:\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N}-[\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\ddot{\\varphi}_j \\\\+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\ddot{\\vartheta}_j\n\t\\bigg]= \\ddot{\\bm r}_{C/N} \t- 2[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t\\\\-[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t\\\\+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 \\\\+\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t\\bigg]\n\t\\label{eq:Rbddot4}\n\\end{multline}\n\nEquation~\\eqref{eq:Rbddot4} is the translational motion equation and is the first EOM needed to describe the motion of the spacecraft. The following section develops the rotational EOM.\n\n\\subsubsection{Rigid Spacecraft Hub Rotational Motion}\n\nStarting with Euler's equation when the body fixed coordinate frame origin is not coincident with the center of mass of the body\n\\begin{equation}\n\t\\bm{\\dot{H}}_{\\text{sc},B} = \\bm{L}_B+m_{\\text{\\text{sc}}}\\ddot{\\bm r}_{B/N}\\times\\bm{c}\n\t\\label{eq:Euler}\n\\end{equation}\nwhere $\\bm{L}_B$ is the total external torque about point $B$. The definition of the angular momentum vector of the spacecraft about point $B$ is\n\\begin{equation}\n\t\\bm{H}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times\\bm{\\dot{r}}_{B_c/B} + \\sum\\limits_{j=1}^{N_P}m_j \\bm r_{P_{c,j}/B}\\times \\dot{\\bm r}_{P_{c,j}/B}\n\t\\label{eq:Hb2}\n\\end{equation}\n\nNow the inertial time derivative of Eq. \\eqref{eq:Hb2} is taken and yields\n\\begin{equation}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times\\ddot{\\bm r}_{B_c/B}+ \\sum\\limits_{j=1}^{N_P}m_j \\bm r_{P_{c,j}/B}\\times \\ddot{\\bm r}_{P_{c,j}/B}\n\t\\label{eq:Hbdot}\n\\end{equation}\nThe terms $\\ddot{\\bm r}_{B_c/B}$ and $\\ddot{\\bm r}_{P_{c,j}/B}$ are found using the transport theorem and knowing that $\\bm{r}_{B_c/B}$ is fixed with respect to the body frame.\n\\begin{align}\n\t\\ddot{\\bm r}_{B_c/B} &= \\bm{\\dot{\\omega}}_{\\cal B/N} \\times \\bm{r}_{B_c/B} + \\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{B_c/B})\n\t\\label{eq:rbddot}\n\t\\\\\n\t\\ddot{\\bm{r}}_{P_{c,j}/B}  &= \\bm{r}''_{P_{c,j}/B} +2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{P_{c,j}/B} + \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{P_{c,j}/B}  +\\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{P_{c,j}/B})\n\t\\label{eq:rpddot}\n\\end{align}\nIncorporating Eqs.~\\eqref{eq:rbddot} -~\\eqref{eq:rpddot} into Eq.~\\eqref{eq:Hbdot} results in\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} + m_{\\text{hub}} \\bm{r}_{B_c/B}\\times ( \\dot{\\bm\\omega}_{\\cal B/N}\\times \\bm{r}_{B_c/B})+\\\\ +m_{\\text{hub}} \\bm{r}_{B_c/B}\\times \\Bigl[ \\bm\\omega_{\\cal B/N}\\times (\\bm\\omega_{\\cal B/N}\\times \\bm{r}_{B_c/B})\\Bigr] + \\sum\\limits_{j=1}^{N_P}m_j \\bm r_{P_{c,j}/B}\\times \\Bigl[\\bm{r}''_{P_{c,j}/B} +2 \\bm\\omega_{\\cal B/N} \\times \\bm{r}'_{P_{c,j}/B} + \\\\ + \\dot{\\bm\\omega}_{\\cal B/N} \\times \\bm{r}_{P_{c,j}/B} +\\bm\\omega_{\\cal B/N} \\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{P_{c,j}/B})\\Bigr]\n\t\\label{eq:Hbdot2}\n\\end{multline}\nApplying the parallel axis theorem the following inertia tensor terms are defined as\n\\begin{align}\n\t[I_{\\text{hub},B}] &= [I_{\\text{hub},B_c}] + m_{\\text{hub}}[\\bm{\\tilde{r}}_{B_c/B}] [\\bm{\\tilde{r}}_{B_c/B}]^T\n\t\\\\\n\t[I_{\\text{sc},B}] &= [I_{\\text{hub},B}] + \\sum\\limits_{j=1}^{N_P} m_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] [\\tilde{\\bm{r}}_{P_{c,j}/B}]^T\n\t\\label{eq:IscB}\n\\end{align}\nTaking the body-relative time derivative of Equation~\\eqref{eq:IscB} yields\n\\begin{equation}\n\t[I'_{\\text{sc},B}] = - \\sum\\limits_{j=1}^{N_P} m_j \\Bigl(  [\\tilde{\\bm{r}}'_{P_{c,j}/B}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] + [\\tilde{\\bm{r}}_{P_{c,j}/B}] [\\tilde{\\bm{r}}'_{P_{c,j}/B}]  \\Bigr)\n\t\\label{eq:Idotsc}\n\\end{equation}\nThe Jacobi Identity, $(\\bm a \\times \\bm b)\\times \\bm c = \\bm a \\times (\\bm b\\times \\bm c) - \\bm        b \\times (\\bm a\\times \\bm c)$, is applied to the cross products of Eq. \\eqref{eq:Hbdot2}:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{hub},B_c}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N} - m_{\\text{hub}} \\bm{r}_{B_c/B}\\times (\\bm{r}_{B_c/B}\\times \\dot{\\bm\\omega}_{\\cal B/N})+\\\\ +m_{\\text{hub}}  \\bm\\omega_{\\cal B/N}\\times \\Bigl[\\bm{r}_{B_c/B}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{r}_{B_c/B})\\Bigr] + \\sum\\limits_{j=1}^{N_P}m_j \\bigg\\{ \\bm r_{P_{c,j}/B}\\times \\bm{r}''_{P_{c,j}/B} -\\bm r_{P_{c,j}/B}\\times (\\bm{r}'_{P_{c,j}/B}\\times\\bm\\omega_{\\cal B/N} )\\\\-\n\t\\bm{r}'_{P_{c,j}/B}\\times (\\bm r_{P_{c,j}/B}\\times\\bm\\omega_{\\cal B/N})+\\bm\\omega_{\\cal B/N}\\times(\\bm r_{P_{c,j}/B}\\times\\bm{r}'_{P_{c,j}/B})\n\t\\\\ - \\bm r_{P_{c,j}/B}\\times (\\bm{r}_{P_{c,j}/B} \\times \\dot{\\bm\\omega}_{\\cal B/N}) +\\bm\\omega_{\\cal B/N} \\times \\Bigl[\\bm r_{P_{c,j}/B}\\times (\\bm\\omega_{\\cal B/N} \\times \\bm{r}_{P_{c,j}/B})\\Bigl]\\bigg\\}\n\t\\label{eq:Hbdot3_1}\n\\end{multline}\nRearranging the terms in Eq. \\eqref{eq:Hbdot3_1} yields:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = \\left\\{[I_{\\text{hub},B_c}] +m_{\\text{hub}} [\\bm{\\tilde{r}}_{B_c/B}] [\\bm{\\tilde{r}}_{B_c/B}]^T+\\sum\\limits_{j=1}^{N_P}m_j [\\bm{\\tilde{r}}_{P_{c,j}/B}][\\bm{\\tilde{r}}_{P_{c,j}/B}]^T \\right\\} \\dot{\\bm\\omega}_{\\cal B/N} \\\\\n\t+ \\bm\\omega_{\\cal B/N} \\times \\bigg \\{[I_{\\text{hub},B_c}] + m_{\\text{hub}} [\\bm{\\tilde{r}}_{B_c/B}] [\\bm{\\tilde{r}}_{B_c/B}]^T +\\sum\\limits_{j=1}^{N_P}m_j [\\bm{\\tilde{r}}_{P_{c,j}/B}][\\bm{\\tilde{r}}_{P_{c,j}/B}]^T \\bigg\\}\\bm\\omega_{\\cal B/N} \\\\ + \\sum\\limits_{j=1}^{N_P}m_j \\bigg\\{ \\bm r_{P_{c,j}/B}\\times \\bm{r}''_{P_{c,j}/B} -\\bigg[[\\bm{\\tilde{r}}_{P_{c,j}/B}][\\bm{\\tilde{r}}'_{P_{c,j}/B}]+[\\bm{\\tilde{r}}'_{P_{c,j}/B}][\\bm{\\tilde{r}}_{P_{c,j}/B}] \\bigg]\\bm\\omega_{\\cal B/N}\\\\\n\t+\\bm\\omega_{\\cal B/N}\\times(\\bm r_{P_{c,j}/B}\\times\\bm{r}'_{P_{c,j}/B}) \\bigg\\}\n\t\\label{eq:Hbdot3_2}\n\\end{multline}\nUsing Eqs.~\\eqref{eq:IscB} and \\eqref{eq:Idotsc} to simplify results in Eq.~\\eqref{eq:Hbdot3_2}, the following simplified equation is obtained:\n\\begin{multline}\n\t\\dot{\\bm{H}}_{\\text{sc},B} = [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} + [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t+ \\sum\\limits_{j=1}^{N_P}\\biggl[m_j \\bm r_{P_{c,j}/B}\\times\\bm{r}''_{P_{c,j}/B} \\\\\n\t+ m_j \\bm\\omega_{\\cal B/N} \\times \\Bigl(\\bm{r}_{P_{c,j}/B} \\times \\bm{r}'_{P_{c,j}/B}\\Bigr)\\biggr]\n\t\\label{eq:Hbdot4}\n\\end{multline}\nEqs. (\\ref{eq:Euler}) and (\\ref{eq:Hbdot4}) are equated and yield\n\\begin{multline}\n\t\\bm{L}_B+m_{\\text{sc}}\\ddot{\\bm r}_{B/N}\\times\\bm{c} = [I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} + \\bm\\omega_{\\cal B/N} \\times [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} + [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t+ \\sum\\limits_{j=1}^{N_P}\\biggl[m_j \\bm r_{P_{c,j}/B}\\times\\bm{r}''_{P_{c,j}/B}\\\\\n\t+ m_j \\bm\\omega_{\\cal B/N} \\times \\Bigl(\\bm{r}_{P_{c,j}/B} \\times \\bm{r}'_{P_{c,j}/B}\\Bigr)\\biggr]\n\\end{multline}\nFinally, using tilde matrix and simplifying yields the modified Euler equation, which is the second EOM necessary to describe the motion of the spacecraft.\n\\begin{multline}\n\t[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N} = -[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N} - [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\t- \\sum\\limits_{j=1}^{N_P}\\biggl(m_j [\\tilde{\\bm r}_{P_{c,j}/B}]\\bm{r}''_{P_{c,j}/B}\\\\\n\t+ m_j [\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bm{r}'_{P_{c,j}/B}\\biggr) + \\bm{L}_B - m_{\\text{sc}} [\\tilde{\\bm{c}}] \\ddot{\\bm r}_{B/N}\n\t\\label{eq:Final5}\n\\end{multline}\nRearranging Eq.~\\eqref{eq:Final5} to be in the same form as the previous sections results in\n\\begin{multline}\n\tm_{\\text{sc}}[\\tilde{\\bm{c}}]\\ddot{\\bm r}_{B/N}+[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N}  - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\ddot{\\varphi}_j \\\\\n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\ddot{\\vartheta}_j\n\t\\bigg] =\n\t\\bm{L}_B-[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t- [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\\\\ \t- \\sum\\limits_{j=1}^{N_P} m_j \\Big\\{[\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bm{r}'_{P_{c,j}/B}+l_j[\\tilde{\\bm{r}}_{P_{c,j}/B}]\\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2 \\\\\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 +\\\\\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t\\bigg]\\Big\\}\n\t\\label{eq:Final6}\n\\end{multline}\n\n\\subsubsection{Fuel Slosh Motion}\nThe fuel slosh motion is being approximated by a lumped mechanical multi-mode model. Figure~\\ref{fig:Slosh_Figure} shows that a single fuel slosh particle is free to move around the geometrical center of the tank at a fixed distance $l_j$ and this formulation is generalized to include $N_P$ number of fuel slosh particles. The derivation begins with Euler's law for each fuel slosh particle:\n\n\\begin{equation}\n\t\\bm{\\dot{H}}_{T,j}=\\bm{L}_{T,j}+m_{j} \\bm{\\ddot{r}}_{T/N}\\times \\bm{l_j}\n\t\\label{eq:dotH_T}\n\\end{equation}\nWhere the $\\bm{L}_{T,j}$ represents the external torques. It contains the damping term that is modeled as $\\bm{D}$ damping matrix multiplied by the relative velocity between the tank and the fuel, $\\bm{l_j'}$. It takes into account  the torque due to gravity and any other external torque.\n\\begin{equation}\n\t\\bm{L}_{T,j}=\\bm{l_j}\\times \\bm{F_g}-\\bm{D}\\bm{l_j'} + \\bm{\\tau}_{ext,j}\n\\end{equation}\nIt is necessary to express $\\bm{H}_T$ of the fuel slosh particle as:\n\\begin{equation}\n\t\\bm{H}_{T,j}= m_j \\bm{l_j}\\times \\bm{\\dot{l}_j}\n\\end{equation}\nDeriving this equation we obtain: \n\\begin{equation}\n\t\\bm{\\dot{H}}_{T,j}=m_j\\bm{l_j}\\times \\bm{\\ddot{l_j}}\n\t\\label{eq:dotH_T_particle}\n\\end{equation}\nUsing the transport theorem once again:\n\\begin{equation}\n\t\\bm{\\ddot{l_j}}=\\bm{l_j''}+\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{l_j} + 2\\bm\\omega_{\\cal B/N}\\times \\bm{l_j'}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{l_j})\n\t\\label{eq:ddotl_j}\n\\end{equation}\n$\\bm{l_j}$ prime and second derivative are equal to \\eqref{eq:rPcjBprime} and \\eqref{eq:rPcjBprimeprime} because the $\\bm{d}$ vector is constant in body frame. The previous results are reported here:\n\n\\begin{equation}\n\t\\bm{l_j} = \n\tl_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t\\cos(\\varphi_j)\\cos(\\vartheta_j) \\\\\n\t\t\t\\sin(\\varphi_j)\\cos(\\vartheta_j) \\\\\n\t\t\t-\\sin(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:lj}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm{l_j}' \n\t=\n\tl_j \n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\dot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\\\\n\t\t\t\\dot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\\\\n\t\t\t-\\dot{\\vartheta}_j\\cos(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:ljprime}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm{l_j}'' \n\t=\n\tl_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\\\ \\\\\n\t\t\t-\\ddot{\\vartheta}_j\\cos(\\vartheta_j)+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:ljBprimeprime}\n\\end{equation}\nEquating eqs. \\eqref{eq:dotH_T} and \\eqref{eq:dotH_T_particle} and using eq. \\eqref{eq:ddotl_j}, we obtain:\n\\begin{equation}\n\tm_j\\bm{l_j}\\times [\\bm{l_j''}+\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{l_j} + 2\\bm\\omega_{\\cal B/N}\\times \\bm{l_j'}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{l_j})]=\\bm{L}_{T,j}+m_{j} \\bm{\\ddot{r}}_{T/N}\\times \\bm{l_j}\n\t\\label{eq:FSE1}\n\\end{equation}\nSubstituting eq. \\eqref{eq:ljBprimeprime} in eq. \\eqref{eq:FSE1}\n\\begin{multline}\n\tm_j\\bm{l_j}\\times \\bigg[\n\tl_j\\Big(-\\ddot{\\varphi}_j\\sin(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\dot{\\vartheta}_j^2\\cos(\\varphi_j)\\cos(\\vartheta_j)\\\\+2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,1}\n\t+l_j\\Big(\\ddot{\\varphi}_j\\cos(\\varphi_j)\\cos(\\vartheta_j)-\\ddot{\\vartheta}_j\\sin(\\varphi_j)\\sin(\\vartheta_j)-\\dot{\\varphi}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)\\\\-\\dot{\\vartheta}_j^2\\sin(\\varphi_j)\\cos(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_j\\cos(\\varphi_j)\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,2}\n\t+l_j\\Big(-\\ddot{\\vartheta}_j\\cos(\\vartheta_j)+\\dot{\\vartheta}_j^2\\sin(\\vartheta_j) \\Big)\\bm{\\hat{p}}_{0_j,3}\\\\\n\t+\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{l_j} + 2\\bm\\omega_{\\cal B/N}\\times \\bm{l_j'}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{l_j})\\bigg]=\\bm{L}_{T,j}+m_{j} \\bm{\\ddot{r}}_{T/N}\\times \\bm{l_j}\n\t\\label{eq:FSE2}\n\\end{multline}\nExecute separately the following vectorial product, using $C$ and $S$ to indicate $\\cos$ and $\\sin$, respectively.\n\\begin{multline}\n\tl^2_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t0 & S(\\vartheta_j) & S(\\varphi_j)C(\\vartheta_j)\\\\\n\t\t\t-S(\\vartheta_j) & 0 & -C(\\varphi_j)C(\\vartheta_j)\\\\\n\t\t\t-S(\\varphi_j)C(\\vartheta_j) & C(\\varphi_j)C(\\vartheta_j) & 0\n\t\\end{bmatrix}}\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\ddot{\\varphi}_jS(\\varphi_j)C(\\vartheta_j)-\\ddot{\\vartheta}_jC(\\varphi_j)S(\\vartheta_j)\\\\-\\dot{\\varphi}_j^2C(\\varphi_j)C(\\vartheta_j)-\\dot{\\vartheta}_j^2C(\\varphi_j)C(\\vartheta_j)\\\\+2\\dot{\\varphi}_j\\dot{\\vartheta}_jS(\\varphi_j)S(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_jC(\\varphi_j)C(\\vartheta_j)-\\ddot{\\vartheta}_jS(\\varphi_j)S(\\vartheta_j)\\\\-\\dot{\\varphi}_j^2S(\\varphi_j)C(\\vartheta_j)-\\dot{\\vartheta}_j^2S(\\varphi_j)C(\\vartheta_j)\\\\-2\\dot{\\varphi}_j\\dot{\\vartheta}_jC(\\varphi_j)S(\\vartheta_j) \\\\ \\\\\n\t\t\t-\\ddot{\\vartheta}_jC(\\vartheta_j)+\\dot{\\vartheta}_j^2S(\\vartheta_j)\n\t\\end{bmatrix}}\\\\\n\t=\n\tl^2_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t\\ddot{\\varphi}_jC(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-\\ddot{\\vartheta}_jS(\\varphi_j)S^2(\\vartheta_j)-\\dot{\\varphi}_j^2S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-\\dot{\\vartheta}_j^2S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)\\\\-2\\dot{\\varphi}_j\\dot{\\vartheta}_jC(\\varphi_j)S^2(\\vartheta_j)-\\ddot{\\vartheta}_jS(\\varphi_j)C^2(\\vartheta_j)+\\dot{\\vartheta}_j^2S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_jS(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)+\\ddot{\\vartheta}_jC(\\varphi_j)S^2(\\vartheta_j)+\\dot{\\varphi}_j^2C(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)+\\dot{\\vartheta}_j^2C(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)\\\\-2\\dot{\\varphi}_j\\dot{\\vartheta}_jS(\\varphi_j)S^2(\\vartheta_j) +\\ddot{\\vartheta}_jC(\\varphi_j)C^2(\\vartheta_j)-\\dot{\\vartheta}_j^2C(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_jS^2(\\varphi_j)C^2(\\vartheta_j)+\\ddot{\\vartheta}_jC(\\varphi_j)S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)+\\dot{\\varphi}_j^2C(\\varphi_j)S(\\varphi_j)C^2(\\vartheta_j)\\\\+\\dot{\\vartheta}_j^2C(\\varphi_j)S(\\varphi_j)C^2(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_jS^2(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)+\t\\ddot{\\varphi}_jC^2(\\varphi_j)C^2(\\vartheta_j)\\\\-\\ddot{\\vartheta}_jC(\\varphi_j)S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-\\dot{\\varphi}_j^2C(\\varphi_j)S(\\varphi_j)C^2(\\vartheta_j)-\\dot{\\vartheta}_j^2C(\\varphi_j)S(\\varphi_j)C^2(\\vartheta_j)\\\\-2\\dot{\\varphi}_j\\dot{\\vartheta}_jC^2(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)\n\t\\end{bmatrix}}\\\\ \\\\\n\t=\n\tl^2_j\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t\\ddot{\\varphi}_jC(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-\\ddot{\\vartheta}_jS(\\varphi_j)-\\dot{\\varphi}_j^2S(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_jC(\\varphi_j)S^2(\\vartheta_j)\\\\ \\\\\n\t\t\t\\ddot{\\varphi}_jS(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)+\\ddot{\\vartheta}_jC(\\varphi_j)+\\dot{\\varphi}_j^2C(\\varphi_j)C(\\vartheta_j)S(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_jS(\\varphi_j)S^2(\\vartheta_j) \\\\ \\\\\n\t\t\t\\ddot{\\varphi}_jC^2(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}_jC(\\vartheta_j)S(\\vartheta_j)\n\t\\end{bmatrix}}\n\t\\label{eq:FS3}\n\\end{multline}\nUsing the results obtained in eq. \\eqref{eq:FS3}, project eq. \\eqref{eq:FSE2} on the axis of rotation of $\\varphi$ and $\\vartheta$. The $\\varphi$ rotation axis is $\\bm{\\hat{p}}_{0_j,3}$, while we will call $\\bm{\\hat{p}'}_{0_j,2}$ the $\\vartheta$ rotation axis. \n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=8cm]{Figures/rotationaxes.PNG}\n\t\\caption{Rotation Axes}\n\t\\label{fig:Axes_Figure}\n\\end{figure}\n\n\\begin{equation}\n\t\\bm{\\hat{p}}_{0_j,3}=\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t0 \\\\ 0 \\\\ 1\n\t\\end{bmatrix}}\n\\end{equation}\n\n\n\\begin{multline}\n\tm_j l_j^2\\bigg[\\ddot{\\varphi}_j\\cos^2(\\vartheta_j)-2\\dot{\\varphi}_j\\dot{\\vartheta}\\cos(\\vartheta_j)\\sin(\\vartheta_j)\\bigg] + m_j \\bm{\\hat{p}}_{0_j,3}^T \\bm{l_j}\\times \\bigg[\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{l_j} + 2\\bm\\omega_{\\cal B/N}\\times \\bm{l_j'}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{l_j})\\bigg]\\\\\n\t=\\bm{\\hat{p}}_{0_j,3}^T \\bm{L}_{T,j}+m_{j} \\bm{\\hat{p}}_{0_j,3}^T \\bm{\\ddot{r}}_{T/N}\\times \\bm{l_j}\n\t\\label{eq:FSE4}\n\\end{multline}\n\n\\begin{equation}\n\t\\bm{\\hat{p}'}_{0_j,2}=\n\t\\leftidx{^{\\mathcal{P}_{0,j}}}\n\t{\\begin{bmatrix}\n\t\t\t-\\sin(\\varphi) \\\\ \\cos(\\varphi) \\\\ 0\n\t\\end{bmatrix}}\n\\end{equation}\n\n\\begin{multline}\n\tm_j l_j^2\\bigg[\\ddot{\\vartheta}_j+\\dot{\\varphi}_j^2\\cos(\\vartheta_j)\\sin(\\vartheta_j)\\bigg] + m_j \\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{l_j}\\times \\bigg[\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{l_j} + 2\\bm\\omega_{\\cal B/N}\\times \\bm{l_j'}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{l_j})\\bigg]\\\\\n\t=\\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{L}_{T,j}+m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{\\ddot{r}}_{T/N}\\times \\bm{l_j}\n\t\\label{eq:FSE5}\n\\end{multline}\nRemembering that $\\bm{r}_{T/N} = \\bm{r}_{B/N} + \\bm{d}$, and that $\\bm{d}$ is constant in the body frame, we can use once again the transport theorem to write:\n\n\\begin{equation}\n\t\\bm{\\ddot{d}}=\\bm{\\dot{\\omega}}_{B/N}\\times \\bm{d}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{d})\n\\end{equation}\n\\begin{equation}\n\t\\bm{\\ddot{r}}_{T/N} = \\bm{\\ddot{r}}_{B/N} + \\bm{\\dot{\\omega}}_{B/N}\\times \\bm{d}+\\bm\\omega_{\\cal B/N}\\times(\\bm\\omega_{\\cal B/N}\\times \\bm{d})\n\\end{equation}\nRearranging the terms as done in the previous sections\n\\begin{multline}\n\tm_j l_j^2\\ddot{\\varphi}_j\\cos^2(\\vartheta_j) -m_{j} \\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]([\\bm{\\tilde{l}_j}]+ [\\bm{\\tilde{d}}]) \\bm{\\dot{\\omega}}_{B/N} +m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N} =-m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}\\\\+\\bm{\\hat{p}}_{0_j,3}^T \\bm{L}_{T,j}+2m_j l_j^2\\dot{\\varphi}_j\\dot{\\vartheta}\\cos(\\vartheta_j)\\sin(\\vartheta_j)- m_j \\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg]\n\t\\label{eq:FSE6}\n\\end{multline}\n\n\\begin{multline}\n\tm_j l_j^2\\ddot{\\vartheta}_j - m_{j}\\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]( [\\bm{\\tilde{l}_j}] + [\\bm{\\tilde{d}}])\\bm{\\dot{\\omega}}_{B/N}\n\t+m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N}\n\t=-m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T}[\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}\\\\+\\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{L}_{T,j}-m_j l_j^2\\dot{\\varphi}_j^2\\cos(\\vartheta_j)\\sin(\\vartheta_j)- m_j \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg]\n\t\\label{eq:FSE7}\n\\end{multline}\n\nEqs. \\eqref{eq:FSE6} and \\eqref{eq:FSE7} are the Fuel Slosh Particle equations.\n\n\n\\subsection{Back-substitution Method}\n\nThe equations presented in the previous sections result in $2N_P + 6$ coupled differential equations. Therefore, if the EOMs were placed into state space form, a system mass matrix of size $2N_P + 6$ would need to be inverted to numerically integrate the EOMs. This can result in a computationally expensive simulation. The computation effort to numerically invert an $N\\times N$ matrix scales with $N^{3}$. In the following section, the EOMs are manipulated using a back-substitution method to increase the computational efficiency. \n\nThis manipulation involves inverting twice a ($3\\times 3$) matrix, the $A^{-1}$ and $(D-CA^{-1}B)^{-1}$ matrices as it is shown in eqs. \\eqref{eq:finalsystemomega}  and \\eqref{eq:finalsystemr}. Then the system is completely solved back substituting for fuel slosh and translational motions. The derivation of the back-substitution method can be seen in the following sections. \n\\\\\n\n\\subsubsection{Fuel Slosh Motion}\nStarting from eq. \\eqref{eq:FSE6}\n\\begin{multline}\n\t\\ddot{\\varphi}_j  =\\frac{1}{m_j l_j^2 \\cos^2(\\vartheta_j)}\\Big\\{m_{j}\\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]( [\\bm{\\tilde{l}_j}]+[\\bm{\\tilde{d}}]) \\bm{\\dot{\\omega}}_{B/N} -m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N} -m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}\\\\+\\bm{\\hat{p}}_{0_j,3}^T \\bm{L}_{T,j}+2m_j l_j^2\\dot{\\varphi}_j\\dot{\\vartheta}\\cos(\\vartheta_j)\\sin(\\vartheta_j)- m_j \\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg]\\Big\\}\n\t\\label{eq:BSM1}\n\\end{multline}\n\n\\begin{equation}\n\t\\ddot{\\varphi}_j  =\\frac{1}{m_j l_j^2 \\cos^2(\\vartheta_j)}\\Big(m_{j}\\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}](  [\\bm{\\tilde{l}_j}]+ [\\bm{\\tilde{d}}]) \\bm{\\dot{\\omega}}_{B/N} -m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N}+a_{\\varphi_j} \\Big)\n\t\\label{eq:BSM2}\n\\end{equation}\t\nWriting it this way instead\n\\begin{equation}\n\t\\ddot{\\varphi}_j  = \\bm a_{\\varphi_j}^T \\ddot{\\bm{r}}_{B/N} + \\bm b_{\\varphi_j}^T \\dot{\\bm\\omega}_{\\cal B/N} +c_{\\varphi_j}\n\t\\label{eq:BSM3}\n\\end{equation}\nWhere \n\n\\begin{equation}\n\t\\bm a_{\\varphi_j}^{T} = -\\frac{\\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}]}{ l_j^2 \\cos^2(\\vartheta_j)}\n\t\\label{eq:BSM4}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm b_{\\varphi_j}^{T} = \\frac{\\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]( [\\bm{\\tilde{l}_j}]+ [\\bm{\\tilde{d}}])}{ l_j^2 \\cos^2(\\vartheta_j)}\n\t\\label{eq:BSM5}\n\\end{equation}\n\n\\begin{multline}\n\tc_{\\varphi_j} = \\frac{1}{m_j l_j^2 \\cos^2(\\vartheta_j)}\\Big\\{-m_{j} \\bm{\\hat{p}}_{0_j,3}^{T} [\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}+\\bm{\\hat{p}}_{0_j,3}^T \\bm{L}_{T,j}\\\\+2m_j l_j^2\\dot{\\varphi}_j\\dot{\\vartheta}\\cos(\\vartheta_j)\\sin(\\vartheta_j)- m_j \\bm{\\hat{p}}_{0_j,3}^T [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg]\\Big\\}\n\t\\label{eq:BSM6}\n\\end{multline}\t\nDoing the same for eq. \\eqref{eq:FSE7}\n\n\\begin{multline}\n\t\\ddot{\\vartheta}_j \n\t=\\frac{1}{m_j l_j^2}\\Big\\{m_{j}\\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]( [\\bm{\\tilde{l}_j}] + [\\bm{\\tilde{d}}])\\bm{\\dot{\\omega}}_{B/N}\n\t-m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N}-m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T}[\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}\\\\+\\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{L}_{T,j}-m_j l_j^2\\dot{\\varphi}_j^2\\cos(\\vartheta_j)\\sin(\\vartheta_j)- m_j \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg]\\Big\\}\n\t\\label{eq:BSM7}\n\\end{multline}\n\n\\begin{equation}\n\t\\ddot \\vartheta_j =\\frac{1}{m_j l_j^2} \\Big(m_{j}\\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]([\\bm{\\tilde{l}_j}] + [\\bm{\\tilde{d}}])\\bm{\\dot{\\omega}}_{B/N}\n\t-m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}] \\bm{\\ddot{r}}_{B/N} + a_{\\vartheta_j} \\Big)\n\t\\label{eq:BSM8}\n\\end{equation}\nWriting this a different way\n\n\\begin{equation}\n\t\\ddot \\vartheta_j = \\bm a_{\\vartheta_j}^T \\ddot{\\bm r}_{B/N} + \\bm b_{\\vartheta_j}^T \\dot{\\bm\\omega}_{\\cal B/N} + c_{\\vartheta_j}\n\t\\label{eq:BSM9}\n\\end{equation}\nWhere\n\n\\begin{equation}\n\t\\bm a_{\\vartheta_j}^{T} = - \\frac{ \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]}{ l_j^2}\n\t\\label{eq:BSM10}\n\\end{equation}\n\n\\begin{equation}\n\t\\bm b_{\\vartheta_j}^{T} = \\frac{\\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]( [\\bm{\\tilde{l}_j}] + [\\bm{\\tilde{d}}])}{ l_j^2}\n\t\\label{eq:BSM11}\n\\end{equation}\n\n\\begin{multline}\n\tc_{\\vartheta_j} = \\frac{1}{m_j l_j^2}\\Big\\{-m_{j} \\bm{\\hat{p}}_{0_j,2}^{'T}[\\bm{\\tilde{l}_j}][\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{d}+\\bm{\\hat{p}}_{0_j,2}^{'T} \\bm{L}_{T,j}-m_j l_j^2\\dot{\\varphi}_j^2\\cos(\\vartheta_j)\\sin(\\vartheta_j)\\\\- m_j \\bm{\\hat{p}}_{0_j,2}^{'T} [\\bm{\\tilde{l}_j}]\\bigg[2[\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j'}+[\\bm{\\tilde{\\omega}}_{\\cal B/N}][\\bm{\\tilde{\\omega}}_{\\cal B/N}] \\bm{l_j}\\bigg] \\Big\\}\n\t\\label{eq:BSM12}\n\\end{multline}\n\n\\subsubsection{Translation}\n\nPlugging these definitions into the translation equation\n\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N}-[\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\ddot{\\varphi}_j \\\\+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\ddot{\\vartheta}_j\n\t\\bigg]= \\ddot{\\bm r}_{C/N} \t- 2[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t\\\\-[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t\\\\+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 \\\\+\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t\\bigg]\n\t\\label{eq:Rbddot4_bis}\n\\end{multline}\nResults in\n\n\\begin{multline}\n\t\\ddot{\\bm r}_{B/N}-[\\tilde{\\bm{c}}] \\dot{\\bm\\omega}_{\\cal B/N}-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)(\\bm a_{\\varphi_j}^T \\ddot{\\bm{r}}_{B/N} + \\bm b_{\\varphi_j}^T \\dot{\\bm\\omega}_{\\cal B/N} +c_{\\varphi_j}) \\\\ +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)(\\bm a_{\\vartheta_j}^T \\ddot{\\bm r}_{B/N} + \\bm b_{\\vartheta_j}^T \\dot{\\bm\\omega}_{\\cal B/N} + c_{\\vartheta_j})\n\t\\bigg]\n\t\\\\= \\ddot{\\bm r}_{C/N} \t- 2[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t-[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\\\\\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2\\\\ +\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t\\bigg]\n\t\\label{eq:Rbddot5}\n\\end{multline}\nSimplifying\n\n\\begin{multline}\n\t\\Big\\{[I_{3\\times3}] -\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm a_{\\varphi_j}^T +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm a_{\\vartheta_j}^T \\bigg]\\Big\\}\\ddot{\\bm r}_{B/N}\n\t+\\Big\\{-[\\tilde{\\bm{c}}] -\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm b_{\\varphi_j}^T +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm b_{\\vartheta_j}^T \\bigg] \\Big\\}\\dot{\\bm\\omega}_{\\cal B/N}\n\t\\\\= \\ddot{\\bm r}_{C/N} \t- 2[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t-[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\frac{1}{m_{\\text{sc}}}\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[ \n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 \\\\+\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t-\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)c_{\\varphi_j} - \\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big) c_{\\vartheta_j} \n\t\\bigg]\n\t\\label{eq:Rbddot6}\n\\end{multline}\nMultiply both sides by $m_{\\text{sc}}$.\n\n\\begin{multline}\n\t\\Big\\{m_{\\text{sc}}[I_{3\\times3}] -\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm a_{\\varphi_j}^T +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm a_{\\vartheta_j}^T \\bigg]\\Big\\}\\ddot{\\bm r}_{B/N}\n\t+\\Big\\{-m_{\\text{sc}}[\\tilde{\\bm{c}}] -\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm b_{\\varphi_j}^T +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm b_{\\vartheta_j}^T \\bigg] \\Big\\}\\dot{\\bm\\omega}_{\\cal B/N}\n\t\\\\= m_{\\text{sc}}\\ddot{\\bm r}_{C/N} - 2m_{\\text{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t-m_{\\text{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t-\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[ \n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 \\\\+\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t-\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)c_{\\varphi_j} - \\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big) c_{\\vartheta_j} \n\t\\bigg]\n\t\\label{eq:Rbddot7}\n\\end{multline}\n\n\\subsubsection{Rotation}\n\nSame thing for rotation: \n\n\\begin{multline}\n\tm_{\\text{sc}}[\\tilde{\\bm{c}}]\\ddot{\\bm r}_{B/N}+[I_{\\text{sc},B}] \\dot{\\bm\\omega}_{\\cal B/N}  - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)(\\bm a_{\\varphi_j}^T \\ddot{\\bm{r}}_{B/N} + \\bm b_{\\varphi_j}^T \\dot{\\bm\\omega}_{\\cal B/N}+c_{\\varphi_j}) \n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\\\+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)(\\bm a_{\\vartheta_j}^T \\ddot{\\bm r}_{B/N} + \\bm b_{\\vartheta_j}^T \\dot{\\bm\\omega}_{\\cal B/N} + c_{\\vartheta_j})\n\t\\bigg] = \\\\\n\t\\bm{L}_B-[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t- [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}- \\sum\\limits_{j=1}^{N_P} m_j \\Big\\{[\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bm{r}'_{P_{c,j}/B}\\\\\n\t+l_j[\\tilde{\\bm{r}}_{P_{c,j}/B}]\\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 +\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t\\bigg]\\Big\\}\n\t\\label{eq:Final6_1}\n\\end{multline}\nNext\n\n\\begin{multline}\n\t\\Big\\{m_{\\text{sc}}[\\tilde{\\bm{c}}] - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm a_{\\varphi_j}^T\n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\bm a_{\\vartheta_j}^T\n\t\\bigg]\n\t\\Big\\}\\ddot{\\bm r}_{B/N}\n\t+\\Big\\{[I_{\\text{sc},B}] - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm b_{\\varphi_j}^T\n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\n\t+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\bm b_{\\vartheta_j}^T\n\t\\bigg]\n\t\\Big\\}\\dot{\\bm\\omega}_{\\cal B/N}\n\t\\\\= \n\t\\bm{L}_B-[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t- [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}- \\sum\\limits_{j=1}^{N_P} m_j \\Big\\{[\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bm{r}'_{P_{c,j}/B}\n\t\\\\+l_j[\\tilde{\\bm{r}}_{P_{c,j}/B}]\\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 +\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} \\\\-2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t- \\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)c_{\\varphi_j} \\\\-   \\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big) c_{\\vartheta_j}\n\t\\bigg]\\Big\\}\n\t\\label{eq:Final7}\n\\end{multline}\n\n\\subsubsection{Remaining Back-substitution Steps}\n\nThe following definitions can be defined:\n\n\\begin{multline}\n\t[A] = \\Big\\{m_{\\text{sc}}[I_{3\\times3}] -\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm a_{\\varphi_j}^T \\\\ +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm a_{\\vartheta_j}^T \\bigg]\\Big\\}\n\\end{multline}\n\n\\begin{multline}\n\t[B] = \t\\Big\\{-m_{\\text{sc}}[\\tilde{\\bm{c}}] -\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm b_{\\varphi_j}^T\\\\ +\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big)\\bm b_{\\vartheta_j}^T \\bigg] \\Big\\}\n\\end{multline}\n\n\\begin{multline}\n\t[C] = \\Big\\{m_{\\text{sc}}[\\tilde{\\bm{c}}] - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm a_{\\varphi_j}^T \\\\\n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\bm a_{\\vartheta_j}^T\n\t\\bigg]\n\t\\Big\\}\n\\end{multline}\n\n\\begin{multline}\n\t[D] = \\Big\\{[I_{\\text{sc},B}] - \\sum\\limits_{j=1}^{N_P}m_j l_j [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bigg[\n\t\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\bm b_{\\varphi_j}^T \\\\\n\t+\\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\n\t+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\bm b_{\\vartheta_j}^T\n\t\\bigg]\n\t\\Big\\}\n\\end{multline}\n\n\\begin{multline}\n\t\\bm v_{\\text{trans}} = m_{\\text{sc}}\\ddot{\\bm r}_{C/N} - 2m_{\\text{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}] \\bm c'\n\t-m_{\\text{sc}}[\\tilde{\\bm\\omega}_{\\cal B/N}][\\tilde{\\bm\\omega}_{\\cal B/N}]\\bm{c}\n\t\\\\-\\sum_{j=1}^{N_{P}}m_j l_j \\bigg[ \n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 +\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\ -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t-\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)c_{\\varphi_j}\\\\ - \\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big) c_{\\vartheta_j} \n\t\\bigg]\n\\end{multline}\n\n\\begin{multline}\n\t\\bm v_{\\text{rot}} = \t\\bm{L}_B-[\\bm{\\tilde{\\omega}}_{\\cal B/N}] [I_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\n\t- [I'_{\\text{sc},B}] \\bm\\omega_{\\cal B/N}\\\\- \\sum\\limits_{j=1}^{N_P} m_j \\Big\\{[\\tilde{\\bm\\omega}_{\\cal B/N}] [\\tilde{\\bm{r}}_{P_{c,j}/B}] \\bm{r}'_{P_{c,j}/B}\n\t+l_j[\\tilde{\\bm{r}}_{P_{c,j}/B}]\\bigg[\n\t\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j^2\n\t\\\\+\\Big(-\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}-\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3} \\Big)\\dot{\\vartheta}_j^2 +\n\t\\Big(2\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}\\\\ -2\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)\\dot{\\varphi}_j\\dot{\\vartheta}_j\n\t-\\Big(\\sin(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1} -\\cos(\\varphi_j)\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}\\Big)c_{\\varphi_j} \\\\-   \\Big(\\cos(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,1}+\\sin(\\varphi_j)\\sin(\\vartheta_j)\\bm{\\hat{p}}_{0_j,2}+\\cos(\\vartheta_j)\\bm{\\hat{p}}_{0_j,3}\\Big) c_{\\vartheta_j}\n\t\\bigg]\\Big\\}\n\\end{multline}\n\nTherefore the translation and rotation EOMs are written in the following form\n\n\\begin{equation}\n\t\\begin{bmatrix}\n\t\t[A] & [B]\\\\\n\t\t[C] & [D]\n\t\\end{bmatrix} \\begin{bmatrix}\n\t\t\\ddot{\\bm r}_{B/N}\\\\\n\t\t\\dot{\\bm\\omega}_{\\cal B/N}\n\t\\end{bmatrix} = \\begin{bmatrix}\n\t\t\\bm v_{\\text{trans}}\\\\\n\t\t\\bm v_{\\text{rot}}\n\t\\end{bmatrix}\n\\end{equation}\n\nSolving the system-of-equations by\n\n\\begin{equation}\n\t\\dot{\\bm\\omega}_{\\cal B/N} = \\Big([D] - [C]][A]^{-1}[B]\\Big)^{-1}(\\bm v_{\\text{rot}} - [C][A]^{-1}\\bm v_{\\text{trans}})\n\t\\label{eq:finalsystemomega}\n\\end{equation}\n\n\\begin{equation}\n\t\\ddot{\\bm r}_{B/N} = [A]^{-1} (\\bm v_{\\text{trans}} - [B]\\dot{\\bm\\omega}_{\\cal B/N})\n\t\\label{eq:finalsystemr}\n\\end{equation}\n\nNow the other state variables can be solved using Eqs. \\eqref{eq:BSM3} and \\eqref{eq:BSM9}: \n\n\\begin{equation}\n\t\\ddot{\\varphi}_j  = \\bm a_{\\varphi_j}^T \\ddot{\\bm{r}}_{B/N} + \\bm b_{\\varphi_j}^T \\dot{\\bm\\omega}_{\\cal B/N} +c_{\\varphi_j}\n\\end{equation}\n\n\\begin{equation}\n\t\\ddot \\vartheta_j = \\bm a_{\\vartheta_j}^T \\ddot{\\bm r}_{B/N} + \\bm b_{\\vartheta_j}^T \\dot{\\bm\\omega}_{\\cal B/N} + c_{\\vartheta_j}\n\\end{equation}\\\\\n\\subsection{Rotational Kinetic Energy}\nThe total rotational kinetic energy (i.e. kinetic energy about the center of mass) of\nthe spacecraft is:\n\\begin{equation}\n\tT_{rot}=\\frac{1}{2}\\bm\\omega_{\\cal B/N}^T [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+\\frac{1}{2}m_{\\text{hub}}\\bm{\\dot{r}}_{B_c,C}\\cdot\\bm{\\dot{r}}_{B_c,C}+\\sum\\limits_{j=1}^{N_P} \\frac{1}{2} m_j \\bm{\\dot{r}}_{P_{c,j}/C}\\cdot\\bm{\\dot{r}}_{P_{c,j}/C}\n\t\\label{eq:RKE1}\n\\end{equation}\nExpanding these terms results in\n\\begin{equation}\n\tT_{rot}=\\frac{1}{2}\\bm\\omega_{\\cal B/N}^T [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+\\frac{1}{2}m_{\\text{hub}}(\\bm{\\dot{r}}_{B_c,B}-\\bm{\\dot{c}})\\cdot(\\bm{\\dot{r}}_{B_c,B}-\\bm{\\dot{c}})+\\sum\\limits_{j=1}^{N_P} \\frac{1}{2} m_j (\\bm{\\dot{r}}_{P_{c,j}/B}-\\bm{\\dot{c}})\\cdot(\\bm{\\dot{r}}_{P_{c,j}/B}-\\bm{\\dot{c}})\n\t\\label{eq:RKE2}\n\\end{equation}\nExpanding further\n\\begin{multline}\n\tT_{rot}=\\frac{1}{2}\\bm\\omega_{\\cal B/N}^T [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+\\frac{1}{2}m_{\\text{hub}}(\\bm{\\dot{r}}_{B_c,B}\\cdot\\bm{\\dot{r}}_{B_c,B}-2\\bm{\\dot{r}}_{B_c,B}\\cdot\\bm{\\dot{c}}+\\bm{\\dot{c}}\\cdot\\bm{\\dot{c}})\\\\+\\sum\\limits_{j=1}^{N_P} \\frac{1}{2} m_j (\\bm{\\dot{r}}_{P_{c,j}/B}\\cdot\\bm{\\dot{r}}_{P_{c,j}/B}-2\\bm{\\dot{r}}_{P_{c,j}/B}\\cdot\\bm{\\dot{c}}+\\bm{\\dot{c}}\\cdot\\bm{\\dot{c}})\n\t\\label{eq:RKE3}\n\\end{multline}\nCombining like terms results in\n\\begin{multline}\n\tT_{rot}=\\frac{1}{2}\\bm\\omega_{\\cal B/N}^T [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+\\frac{1}{2}m_{\\text{hub}}\\bm{\\dot{r}}_{B_c,B}\\cdot\\bm{\\dot{r}}_{B_c,B}+\\sum\\limits_{j=1}^{N_P} \\frac{1}{2} m_j \\bm{\\dot{r}}_{P_{c,j}/B}\\cdot\\bm{\\dot{r}}_{P_{c,j}/B}\\\\-\\bigg[m_{\\text{hub}}\\bm{\\dot{r}}_{B_c,B}+\\sum\\limits_{j=1}^{N_P} m_j \\bm{\\dot{r}}_{P_{c,j}/B}\\bigg]\\cdot\\bm{\\dot{c}}+\\frac{1}{2}\\bigg[m_{\\text{hub}}+\\sum\\limits_{j=1}^{N_P} m_j \\bigg]\\bm{\\dot{c}}\\cdot\\bm{\\dot{c}}\n\t\\label{eq:RKE3_1}\n\\end{multline}\nPerforming a final simplification yields\n\\begin{equation}\n\tT_{rot}=\\frac{1}{2}\\bm\\omega_{\\cal B/N}^T [I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+\\frac{1}{2}m_{\\text{hub}}\\bm{\\dot{r}}_{B_c,B}\\cdot\\bm{\\dot{r}}_{B_c,B}+\\sum\\limits_{j=1}^{N_P} \\frac{1}{2} m_j \\bm{\\dot{r}}_{P_{c,j}/B}\\cdot\\bm{\\dot{r}}_{P_{c,j}/B}-\\frac{1}{2}m_{SC}\\bm{\\dot{c}}\\cdot\\bm{\\dot{c}}\n\t\\label{eq:RKE4}\n\\end{equation} \\\\\n\\subsection{Rotational Angular Momentum}\nThe total rotational angular momentum of the spacecraft about point C is\n\\begin{equation}\n\t\\bm{H}_{rot,C}=[I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+m_{\\text{hub}}\\bm{r}_{B_c,C}\\times\\bm{\\dot{r}}_{B_c,C}+\\sum\\limits_{j=1}^{N_P}  m_j \\bm{r}_{P_{c,j}/C}\\times\\bm{\\dot{r}}_{P_{c,j}/C}\n\t\\label{eq:RAM1}\n\\end{equation}\nExpanding these terms yields\n\\begin{equation}\n\t\\bm{H}_{rot,C}=[I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+m_{\\text{hub}}(\\bm{r}_{B_c,B}-\\bm{c})\\times(\\bm{\\dot{r}}_{B_c,B}-\\bm{\\dot{c}})+\\sum\\limits_{j=1}^{N_P}  m_j (\\bm{r}_{P_{c,j}/B}-\\bm{c})\\times(\\bm{\\dot{r}}_{P_{c,j}/B}-\\bm{\\dot{c}})\n\t\\label{eq:RAM2}\n\\end{equation}\nDistributing this result\n\\begin{multline}\n\t\\bm{H}_{rot,C}=[I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+m_{\\text{hub}}(\\bm{r}_{B_c,B}\\times\\bm{\\dot{r}}_{B_c,B}-\\bm{r}_{B_c,B}\\times\\bm{\\dot{c}}-\\bm{c}\\times\\bm{\\dot{r}}_{B_c,B}+\\bm{c}\\times\\bm{\\dot{c}})\\\\+\\sum\\limits_{j=1}^{N_P} m_j (\\bm{r}_{P_{c,j}/B}\\times\\bm{\\dot{r}}_{P_{c,j}/B}-\\bm{r}_{P_{c,j}/B}\\times\\bm{\\dot{c}}-\\bm{c}\\times\\bm{\\dot{r}}_{P_{c,j}/B}+\\bm{c}\\times\\bm{\\dot{c}})\n\t\\label{eq:RAM3}\n\\end{multline}\nSimplifying this result yields the final equation\n\\begin{equation}\n\t\\bm{H}_{rot,C}=[I_{\\text{hub},B_c}] \\bm\\omega_{\\cal B/N}+m_{\\text{hub}}\\bm{r}_{B_c,B}\\times\\bm{\\dot{r}}_{B_c,B}+\\sum\\limits_{j=1}^{N_P} m_j \\bm{r}_{P_{c,j}/B}\\times\\bm{\\dot{r}}_{P_{c,j}/B}-m_{SC}\\bm{c}\\times\\bm{\\dot{c}}\n\t\\label{eq:RAM4}\n\\end{equation}\n\\subsection{Reference System Change}\n\nAs we can see in Eqs. \\eqref{eq:BSM4}, \\eqref{eq:BSM5} and \\eqref{eq:BSM6}, the problem is singular for $\\vartheta=\\pi/2+k\\pi, (k=0,1,2...)$. In order to solve this issue, a rotation of the pendulum frame, $\\mathcal{P}_{0,j}$, is necessary. This rotation is performed when $\\vartheta_j$ reaches a value multiple of $\\pi/4$, to remain always far enough from the singularity. The new pendulum frame $\\mathcal{P}_{0,j}^{\\text{new}}$ is obtained with a rotation of the actual value of $\\varphi$ around the $\\bm{\\hat{p}}_{3,j}$ axes, and of $\\vartheta$ around $\\bm{\\hat{p}}_{2,j}'$ axes. This would lead to a new pendulum reference frame with $\\bm{\\hat{p}}_{1,j}^{\\text{new}}$ aligned along the pendulum direction. The Fig. \\ref{fig:newreferencesystem} shows the $\\mathcal{P}_{0,j}^{\\text{new}}$ respect to $\\mathcal{P}_{0,j}$.\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=13cm]{Figures/referencesystemsP0.pdf}\n\t\\caption{$\\mathcal{P}_{0,j}^{\\text{new}}$ frame definition}\n\t\\label{fig:newreferencesystem}\n\\end{figure} \nAt this point is easy to see that the new value of $\\varphi_j$ and $\\vartheta_j$ are equal to 0. To compute the new value of $\\dot{\\varphi}_j$ and $\\dot{\\vartheta}_j$, Eq. \\eqref{eq:ljprime} is reversed and it yields:\n\\begin{equation}\n\t\\dot{\\varphi}=\\frac{\\bm{l}_j[2]}{l_j}\n\t\\label{eq:RSC1}\n\\end{equation}\n\\begin{equation}\n\t\\dot{\\vartheta}=-\\frac{\\bm{l}_j[3]}{l_j}\n\t\\label{eq:RSC2}\n\\end{equation}\nThe integration can continue using these new values and the new reference systems. This would lead to discontinuities on $\\varphi_j$, $\\theta_j$, $\\varphi_j$ and $\\vartheta_j$ but not on the vectors $\\bm{l}_j$ and $\\bm{l}_{j}'$.", "meta": {"hexsha": "88d851b535f44a50d14519aaa0a02d764c6c9251", "size": 56791, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/simulation/dynamics/sphericalPendulum/_Documentation/secModelDescription.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/simulation/dynamics/sphericalPendulum/_Documentation/secModelDescription.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/simulation/dynamics/sphericalPendulum/_Documentation/secModelDescription.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.5634715026, "max_line_length": 822, "alphanum_fraction": 0.6450317832, "num_tokens": 25371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863698, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.42416908441183965}}
{"text": "\n\n\\subsection{Algorithm 1:  Combinatorial Blocking}\n\nThe first algorithm uses additional unmodified delta debugging passes, but\n``blocks'' them from producing the same reduced test.  Given test $t$\nthat reduces to $r$, we compute all subsets of components of $r$,\n$C_r$.  The set of reduced tests is then computed by running delta\ndebugging starting with each $t-c$ that fails, where $c \\in C_r$: $c$\nis the blocked components of $r$.  So long as even one component is\nblocked, it is impossible to reproduce the same $r$.  The intuition\nis that to find a reduced failing test that exhibits a different fault\nthan $r$, we want to run delta debugging in such a way as to produce a\ntest as different as possible from $r$; ideally we would like a\nreduced test sharing no components with $r$.  However, $r$ will likely contain\ncomponents that must appear in any failing test:  for example,\ncalls to {\\tt mount} appear in all useful file system tests,\nand interesting XML files seldom lack the {\\tt <} character.\nTherefore, rather than ``blocking'' all components of $r$, we try\ndelta debugging with different sets of components blocked.\n\nIn practice, iterating through all subsets may be too expensive if $r$\nis large.  We therefore make an assumption:  if $t-c_1$ does not fail,\nand $c_1 \\subset c_2$, then $t-c_2$ also does not fail.  The blocking\nalgorithm begins its search by blocking all single components of $r$,\nthen proceeds to all combinations of 2 components, etc., at each stage\nonly considering combinations that contain no combination that did not\nyield a failing test.  With this optimization, the expense of blocking\nbecomes low enough to also apply the approach to the new\nreduced tests found at each stage.  To block all previously discovered\nreductions, it is neccessary to compute combinations that include at\nleast one component from each reduced test produced thus far.\n\n Algorithm \\ref{comb-block} shows\nthe formal definition of the algorithm, which we refer to as {\\tt\n  comb-block} (combinatorial blocking).  This algorithm depends on a\nfunction {\\tt block-all ($T$,$s$)}, which given a set of tests $T$ and\na combination size $s$,  returns all combinations of components of tests $t\n\\in T$ of size $s$ such that each combination has at least one element\nfrom each $t \\in T$.  We omit the definition of {\\tt block-all} in\nthe interests of space.\n\n\\begin{algorithm}\n\\caption{}\n\\label{comb-block}\n\\begin{algorithmic}[1]\n\\Require{failing test $t$, reduced failing test $r$, search depth\n  $d$, max combinations to consider $m$}\n\\State {reductions = \\{$r$\\}}\n\\State {handled = $\\emptyset$}\n\\State {notfailed = $\\emptyset$}\n\\State {count = 0}\n\\While {$d$ > 0}\n\\State{new = $\\emptyset$}\n\\For {$s$ = 1 to total components in reductions}\n\\For {$c \\in$ {\\tt block-all}(reductions-handled, $s$)}\n\\State {count = count + 1}\n\\If {count > $m$}\n\\Return {reductions}\n\\EndIf\n\\State {handled = handled $\\cup$ \\{$c$\\}}\n\\If {$c \\not\\in$ notfailed}\n\\If {fails($t-c$)}\n\\State{new = new $\\cup$ \\{\\tt{ddmin}($t-c$)\\}}\n\\Else\n\\State{notfailed = notfailed $\\cup$ \\{$c$\\}}\n\\EndIf\n\\EndIf\n\\EndFor\n\\EndFor\n\\State{$d$ = $d - 1$}\n\\State{reductions = reductions $\\cup$ new}\n\\EndWhile\n\\State {return reductions}\n\\end{algorithmic}\n\\end{algorithm}\n", "meta": {"hexsha": "cfd567e8af41849d8ca9ddce7b516276db366adb", "size": 3232, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "deprecated/papers/slippage/jalg.tex", "max_stars_repo_name": "15821361594/python-automated-test", "max_stars_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "deprecated/papers/slippage/jalg.tex", "max_issues_repo_name": "15821361594/python-automated-test", "max_issues_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "deprecated/papers/slippage/jalg.tex", "max_forks_repo_name": "15821361594/python-automated-test", "max_forks_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.974025974, "max_line_length": 78, "alphanum_fraction": 0.7323638614, "num_tokens": 886, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4240515450363802}}
{"text": "%!TEX root = thesis.tex\n\n\\chapter{I-POMDPs for Object Detection}\n\\label{ch:IPOMDP}\nThe problem of object detection can be formulated as an I-POMDP using the game ``Where's Waldo?'' as an example. This example is presented in \\cite{Butko2010b}. The goal of the game is to find a person, Waldo, in an illustrated image full of people and objects that have similar appearance as Waldo himself. For the evaluation we assume we have a detector that recognizes Waldo but the people and objects that are similar to Waldo act as noise in the detector.\n\nFrom the agent's point of view, the goal in the ``Where's Waldo?'' game is to find Waldo in an image by fixating on different parts of the image using as few fixations as possible. To accomplish that the agent needs to learn a good policy. The policy determines which part of the image the agent fixates on in every time step and the number of fixations needed to find Waldo gives a measure of how well the policy performs. The part of the image that Waldo occupies is the state of the world and we assume that Waldo doesn't move so the state never changes. The agent's belief for each state is  the probability of Waldo being in that state, i.e. positioned in that part of the image, given previous observations and actions.\n\nIn this chapter we describe the problem specific models that were implemented and used for evaluation of the ``Where's Waldo?'' problem.\n\n\\section{Observation Model}\n\\label{sec:ObservationModelImpl}\nTwo different observation models are used for the evaluation. The first one is a model where the agent's ability to distinguish between a signal from an object and noise decays exponentially from the point where the agent is focusing. This observation model is\n\\begin{equation}\\label{eq:ObservationModel}\n  \\begin{split}\n    O_t^j &= \\delta (S_t, j) d_{j,k} + Z_t^j \\\\\n          &= \\begin{cases}\n                d_{j,k} + Z_t^j & \\text{if $S_t = j$}\\\\\n                Z_t^j           & \\text{otherwise}\n             \\end{cases}\n  \\end{split}\n\\end{equation}\nwhere $Z_t^j$ is zero mean, unit variance Gaussian random noise (i.e. white noise) and\n\\begin{equation}\n  d_{j,k} = 3 \\cdot e^{-dist(j,k)}\n\\end{equation}\nwhere $dist(j,k)$ is the Euclidean distance between locations $j$ and $k$.\n\nWe will call this model the \\emph{Exponential model}. An example of how this vision system sees an image (without noise) can be seen in Figure \\ref{fig:ObsmodelExp}.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=1\\textwidth]{figures/obsmodel_exp}\n  \\caption{A vision system with an exponential decay of focus. The agent focuses on the center of the image and the the focus point is the most reliable one. The ability to distinguish between noise and a signal from an object decreases with the distance from the agent's focus point.}\n  \\label{fig:ObsmodelExp}\n\\end{figure}\n\nThe second model is a model of the properties of the human eye. This model takes the same form as the exponential model in equation \\eqref{eq:ObservationModel} but now $d_{j,k}$ is as described in \\cite{Najemnik2005}.\n\nWe will call this model the \\emph{Human eye model}. An example of how this vision system sees an image (without noise) can be seen in Figure \\ref{fig:ObsmodelCont}.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=1\\textwidth]{figures/obsmodel_cont}\n  \\caption{A vision system with the characteristics modeled after the human eye. The agent focuses on the center of the image and is able to distinguish between noise and a signal from an object in and around the center. The reliability of the vision drops dramatically in locations further away from the agent's focus point.}\n  \\label{fig:ObsmodelCont}\n\\end{figure}\n\n\\section{Observation Likelihood}\n\\label{sec:ObservationLikelihoodImpl}\nWe assume that given an image, individual observations (i.e. each pixel or cell)\n\\begin{equation}\n  o_t = (o_t^1, \\dotsc, o_t^{|\\mathcal{S}|})\n\\end{equation}\nare conditionally independent. Then we can write the probability of an observation as\n\\begin{subequations}\n  \\begin{align}\n    p(o_t | S_t = i, A_t = k) \n      &= \\prod_j p(o_t^j | S_t = i, A_t = k) \\\\\n      &= p(o_t^i | S_t = i, A_t = k) \\prod_{j \\neq i} p(o_t^j | S_t = i, A_t = k) \\\\\n      \\intertext{Given the observation model from equation \\eqref{eq:ObservationModel} we get}\n      &= \\gaussianexp{o_t^i - d_{i,k}} \\prod_{j \\neq i} \\gaussianexp{o_t^j} \\\\\n      &= \\frac{1}{\\sqrt{2\\pi}} \\frac{\\gaussianexppart{o_t^i - d_{i,k}}}{\\gaussianexppart{o_t^i}} \\prod_j \\gaussianexp{o_t^j} \\\\\n      &= \\frac{\\gaussianexppart{o_t^i - d_{i,k}}}{\\gaussianexppart{o_t^i}} Z \\\\\n      &= \\exp((o_t^i - \\frac{d_{i,k}}{2}) d_{i,k}) K\n  \\end{align}\n\\end{subequations}\nwhere $K$ is a constant. Ignoring the constant $K$ and terms not containing $o_t^i$ we can write\n\\begin{equation}\n\\label{eq:ProportionalObservationLikelihood}\n  p(o_t | S_t = i, A_t = k) \\propto \\exp{(d_{i,k} o_t^i)}\n\\end{equation}\nand this is the way the observation likelihood has been implemented.\n\n\\section{Proportional Belief Updates}\n\\label{sec:ProportinalBeliefUpdates}\nWe can combine equation \\eqref{eq:UpdateBeliefFixedTarget} for the belief updates with equation \\eqref{eq:ProportionalObservationLikelihood} for the proportional observation likelihood and then we get\n\\begin{equation}\n  b_{t+1}^i \\propto \\exp{(d_{i,k} o_t^i)} b_t^i\n\\end{equation}\nwhich enables us to calculate the updated belief proportionally. The belief vector can then be normalized after every update to make sure \n\\begin{equation}\n  \\sum_i{b_{t+1}^i} = 1\n\\end{equation}\nholds.\n", "meta": {"hexsha": "84039c2324a111edd89bfbc9ea9eabd838940e05", "size": 5537, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch_ipomdp.tex", "max_stars_repo_name": "bjorgvino/kth-thesis", "max_stars_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch_ipomdp.tex", "max_issues_repo_name": "bjorgvino/kth-thesis", "max_issues_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch_ipomdp.tex", "max_forks_repo_name": "bjorgvino/kth-thesis", "max_forks_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.3837209302, "max_line_length": 725, "alphanum_fraction": 0.7366805129, "num_tokens": 1566, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.424051535953293}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsubsection{Locking and alignment}\n\nSo far, we have always assumed that the cavity is at resonance. \n\n\\marginpar{Monday\\\\ 2020-5-11, \\\\ compiled \\\\ \\today}\n\nWe have an issue if noise is strong enough to move our mirrors out of lock, even if we do not care to observe GW at the frequency of that noise.\n\nOur cavities have a finesse of \\(\\mathcal{F} \\sim 500\\), and the free spectral range will be of the order of \\(c / 2L \\sim \\SI{50}{kHz}\\). \nThis means that the FWHM of the peaks will be of the order of \\(\\text{FWHM} \\approx \\text{FSR} / \\mathcal{F} \\approx \\SI{100}{Hz} = \\Delta f\\).\n\nIf the variation of the frequency is due to a variation of the length of the cavity then the relative variations will be equal (at least to the linear level): \\(\\Delta L / L = \\Delta f / f\\), which means that, \\emph{at the very least}, we will need to control the length of the cavity to the order of \n%\n\\begin{align}\n\\Delta L = L \\frac{ \\Delta f}{f} \\approx \\SI{e-9}{m}\n\\,.\n\\end{align}\n\nIn reality, we are able to control arm lengths to within \\SI{e-15}{m} (root-mean-square of the position variation). \nThere are many sources of noise in this respect: the seismic motion of the ground, the moon's pull, the intrinsic laser noise. \nFortunately, there is a technique we can use to \\textbf{keep} the cavity locked onto the wavelength of the laser. \n\nThe first thing we might try is to measure the transmitted intensity of the laser light from the FP cavity to check whether the length is the correct one.\nThis has two issues: if the power decreases we cannot tell whether the cavity is slightly too \\emph{long} or too \\emph{short}; also, we cannot distinguish an intensity fluctuation due to a length imperfection from an intrinsic fluctuation of the laser. \n\nThe solution is the \\textbf{Pound-Drever-Hall} technique: an electro-optical modulator is used in order to insert sidebands at \\(\\omega_{l} \\pm \\Omega \\) by doing phase modulation. \nThese can be used as oscillators which detect any departure from resonance: they are \\emph{not} at resonance in the cavity, so while a length fluctuation of the cavity affect the carrier frequency a lot, it leaves them basically unchanged. \nSo, we see a term oscillating at \\(\\Omega \\) whose amplitude is linear in \\(\\Delta \\phi \\), measuring it we can tell the sign of the length variation, and we can distinguish it from a laser power oscillation. \n\nIf we know this, we can then actuate the cavity to follow the laser. \n\nAlso, we need actuators to control the beam position: the angular control we need in order to prevent noise is of the order of \\SI{e-9}{rad}.\n\n\\subsubsection{Antenna pattern}\n\nThe antenna pattern of the interferometer is described by the \\textbf{detector tensor} \\(D_{ij}\\), which transforms the perturbation \\(h_{ij}\\) into the observed time-dependent scalar as \\(h (t) = D_{ij} h_{ij}(t)\\). It is given by \n%\n\\begin{align}\nD_{ij} = \\frac{1}{2} \\qty(\\hat{x}_{i} \\hat{x}_{j} - \\hat{y}_{i} \\hat{y}_{j}) \n\\,,\n\\end{align}\n%\nso the output of the detector will look like\n%\n\\begin{align}\nh(t) = \\frac{1}{2} \\qty(\\ddot{h}_{xx} - \\ddot{h}_{yy})\n\\,,\n\\end{align}\n%\nas long as the arms are aligned with the \\(\\hat{x}\\) and \\(\\hat{y}\\) axes. \nNote that this is similar to the antenna pattern of the resonant bar, but now we have two arms, as opposed to the single ``arm'' we had in that case. \n% The function \\(D_{ij}\\) describes the sensitivity of our detector in different directions. \n\n% These kinds of detectors return a scalar (a timeseries, yes, but a scalar with respect to 3D space). This scalar will be linear in the tensor \\(h_{ij}\\), so we can express the observation as \n% %\n% \\begin{align}\n% h(t) = D_{ij} h_{ij} (t)\n% \\,.\n% \\end{align}\n\nWe must perform a rotation with two angles \\(\\phi \\) and \\(\\theta \\) to go from the orthogonal frame of the source and the orthogonal frame of the detector: it will look like \n%\n\\begin{align}\nR = \\left[\\begin{array}{ccc}\n\\cos \\phi  & \\sin \\phi  & 0 \\\\ \n- \\sin \\phi  & \\cos \\phi  & 0 \\\\ \n0 & 0 & 1\n\\end{array}\\right]\n\\left[\\begin{array}{ccc}\n\\cos \\theta  & 0 & \\sin \\theta  \\\\ \n0 & 1 & 0 \\\\ \n-\\sin \\theta  & 0 & \\cos \\theta \n\\end{array}\\right]\n\\,,\n\\end{align}\n%\n\\todo[inline]{Missing ones in the rotation matrices in the slides.}\nand applying it (twice, once for each index of the perturbation tensor) we will find \n%\n\\begin{align}\nh_{xx} &= h_{+} \\qty(\\cos^2\\theta  \\cos^2\\phi - \\sin^2 \\phi ) + 2 h_{\\times } \\cos \\theta \\sin \\phi \\cos \\phi   \\\\\nh_{yy} &= h_{+} \\qty(\\cos^2\\theta \\cos^2\\phi  - \\cos^2\\phi )\n- 2 h_{\\times}  \\cos \\theta \\sin \\phi \\cos \\phi \n\\,,\n\\end{align}\n%\nso the output timeseries will look like \n%\n\\begin{align}\nh(t) &=  F_{+} (\\theta, \\phi ) h_{+} + F_\\times (\\theta , \\phi ) h_{\\times }  \\\\\nF_{+} (\\theta, \\phi ) &= \\frac{1}{2} \\qty(1 + \\cos^2 \\theta ) \\cos 2 \\phi  \\\\\nF_{\\times} (\\theta, \\phi ) &= \\cos \\theta \\sin 2 \\phi \n\\,.\n\\end{align}\n\nWe have no way to distinguish these two components if we only have one detector; we must compare the outputs of different ones. \n\n\\subsection{The interferometer's noise budget}\n\nThe main sources of noise in the interferometer are \n\\begin{enumerate}\n    \\item \\textbf{quantum noise}: it is not actually fundamental, we can decrease it by clever design;\n    \\item \\textbf{seismic noise}: ground vibrations, this can be suppressed with better suspensions;\n    \\item \\textbf{gravity gradients}: this is also a metric perturbation, so it is the hardest to work around, it is fundamental in a way;\n    \\item \\textbf{thermal noise}, especially in the mirror coatings (which are exposed to hundreds of \\SI{}{kW} of laser power!) is currently a big limiting factor.\n\\end{enumerate}\n\n% The noise is dominated by the quantum noise, quantum fluctuations of the laser light. \n% The other source of noise giving us problems in the \\SI{100}{Hz} region is the coating Brownian noise. \n\nAt high frequencies, the problem is that it is hard to measure small displacements with small integration time. \nAt low frequencies, the problem is that the mirrors move too much. \n\n\\subsubsection{Quantum noise}\n\nThe \\textbf{shot noise} is the error in the count of photons --- this is a Poisson process, since the photon arrivals are uncorrelated (the autocorrelation function is a \\(\\delta (t)\\), the power spectrum is flat).\nThe power seen at the beamsplitter in an observation time \\(T\\) will look like \n%\n\\begin{align}\nP_0  = \\frac{N_\\gamma \\overline{h}\\omega_{L}}{T} = \\frac{\\Delta E}{T}\n\\,.\n\\end{align}\n\nIts square fluctuation will be given by\n%\n\\begin{align}\n\\Delta P^2 = \\frac{\\Delta E^2}{T^2} = \n\\frac{\\Delta N^2 \\hbar^2 \\omega_{l}^2}{T^2}\n= N \\frac{\\hbar^2   \\omega_{l}^2}{T^2}\n= \\frac{P_0 \\hbar \\omega_{l}}{T}\n= \\frac{1}{2} \\int_{0}^{1/T} S_P (\\omega) \\dd{\\omega }\n= \\frac{1}{2} \\frac{S_P(\\omega )}{T}\n\\,,\n\\end{align}\n%\nso we get \\(S_P (\\omega ) = 2 P_0 \\hbar \\omega_{l}\\). \n\\todo[inline]{Wrong factor of 2 in the slides!}\n\nNote that this is a power-PSD: it measures the average square \\emph{power}, so it has the dimensions of a power squared over a frequency (\\(\\SI{}{W^2}/\\SI{}{Hz} = \\SI{}{W J}\\)). \n\nThe output of the detector, \\(\\Delta \\phi \\), is proportional to \\(P_0\\)..\nIt can be shown that the contribution to the noise PSD of the phase due to shot noise will be \n%\n\\begin{align}\n\\sqrt{S_{\\Delta \\phi , \\text{ shot}} (\\omega )}  = \n\\frac{C}{P_0 } \\sqrt{S_{P} (\\omega )} = C \\sqrt{\\frac{2 \\hbar \\omega_{l}}{P_0 }}\n\\,,\n\\end{align}\n%\nwhere \\(C\\) is a dimensionless constant of order 1, accounting for the working point and the photodetector efficiency. \nWe can refer this to the input by making use of the \\(T_{FP}\\) transfer function: we will then have \n%\n\\begin{align}\n\\sqrt{S_{h, \\text{ shot}}} = \\frac{\\sqrt{S_{\\Delta \\phi, \\text{ shot}}}}{T_{FP}} =\n\\frac{c}{8 \\mathcal{F} L} \\sqrt{\\frac{4 \\pi \\hbar c \\lambda_{l}}{P_0 }}\n\\sqrt{1 + \\qty( \\frac{f_{GW}}{f_{p}})^2}\n\\,.\n\\end{align}\n\nThis then diminishes as we increase the effective length of the cavity. \nSo, one might say, why would we build a cavity which is several km long, instead of a tabletop experiment with a very high finesse? We shall answer shortly.\n\nWe also have \\textbf{radiation pressure} noise, which scales differently: it is due to the fact that each photon impacting on the mirror gives it a bump of momentum \\(2 \\omega_{l} \\hbar / c\\). \nWith a reasoning not unlike the previous one we find \n%\n\\begin{align}\n\\sqrt{S_{F, \\text{ rp}}} = 2 \\sqrt{\\frac{2 P_0 \\omega_{l}}{c^2}}\n\\,,\n\\end{align}\n%\nso the spectral density of the displacement of the mirror will be \n%\n\\begin{align}\n\\sqrt{S_{x, \\text{ rp}}} = \\frac{2}{M \\omega^2} \\sqrt{\\frac{2 P_0 \\hbar \\omega_{l}}{c^2}} \n\\,,\n\\end{align}\n%\nwhich means that the amplitude spectral density of the input will be \n%\n\\begin{align}\n\\sqrt{S_{h, \\text{ rp}}} = \\frac{16 \\sqrt{2} \\mathcal{F}}{ML (2 \\pi f_{GW})^2} \\sqrt{\\frac{P_0 \\hbar}{2 \\pi c^2 \\lambda_{l}}} \\frac{1}{\\sqrt{1 + (f_{GW} / f_{p})^2}}\n\\,.\n\\end{align}\n\nThe interesting thing to note here is that this noise scales \\emph{directly} with the finesse. \nThis answers the question: if we try to raise the finesse too much, the power inside the laser increases by a lot, and this creates a huge amount of radiation pressure noise on the mirrors. \nThe fact that we found a factor \\(\\mathcal{F}\\) is due to the fact that a photon makes \\(\\mathcal{F} / 2 \\pi \\) bounces inside the cavity, creating noise for each. \n\nSo, we must reach a compromise for the finesse (or for the circulating power \\(P_0 \\)).\n\n% The shot noise is flat in frequency, the RP noise decreases with frequency. \n% At each frequency, we can define a Standard Quantum Limit, which is the lowest noise we could have at that frequency. \nThe shot noise is proportional to \\(P_0^{-1/2}\\), the radiation pressure noise is proportional to \\(P_0^{1/2}\\). \nTheir sum gives the total quantum noise, whose expression is \n%\n\\begin{align}\n\\sqrt{S_{h, \\text{qn}}} (f) = \\frac{1}{L \\pi f_0 }\n\\sqrt{\\frac{\\hbar}{M}}\n\\sqrt{\\qty(1 + \\frac{f^2}{f_p^2}) + \\frac{f_0^{4}}{f^{4}} \\frac{1}{1 + f^2 / f_p^2}}\n\\,,\n\\end{align}\n%\nwhere \n%\n\\begin{align}\nf_0 = \\frac{4 \\mathcal{F}}{\\pi } \\sqrt{\\frac{P_0 }{\\pi \\lambda_{l} cM}}\n\\,.\n\\end{align}\n\nThe shot noise is flat in frequency (for \\(f < f_p\\)), while the radiation pressure noise decreases when frequency increases. By changing \\(P_0 \\) we can raise one and lower the other; for each frequency we have a minimum for the uantum noise, which is called the \\textbf{Standard Quantum Limit}. This is given by minimizing the noise. \nThe optimal value for the frequency \\(f_0 \\) comes out to be the one satisfying \n%\n\\begin{align}\n1 + \\frac{f^2}{f_p^2} = \\frac{f_0^2}{f^2}\n\\,,\n\\end{align}\n%\nand the result for the SQL is \n%\n\\begin{align}\n\\sqrt{S_{h, \\text{ SQL}}} (f) = \\frac{1}{2 \\pi f L} \\sqrt{\\frac{8 \\hbar}{M}}\n\\,.\n\\end{align}\n\nNote that this limit can be reached for a specific, fixed frequency \\(f\\): we cannot achieve it for all the spectrum.\n\nWe can go below this limit using Quantum Vacuum Squeezing, in which we gain precision in the measurement of one variable (photon number) at the expense of another (phase). \n\n\\subsubsection{Thermal Noise}\n\nWe have contribution from all dissipation sources, be they mechanical or not. \nThere is thermo-elastic noise: as a material bends, the side which compresses heats up a little, while the side which expands cools a little. \n\nThe ultimate limit is the internal dissipation: by the fluctuation-dissipation theorem,\n%\n\\begin{align}\nS_{F, \\text{ th}} = 4 k_B T \\Re[Z(\\omega )]  \n\\,,\n\\end{align}\n%\nwhere \\(Z(\\omega )\\) is the characteristic impedance of the system. \n\nFor the \\textbf{mirror suspensions} we can have loss comparable to the seismic noise. If we use high-loss materials we get lots of noise, so we try to use low-loss materials like fused silica, which can reach quality factors like \\(Q \\sim \\num{e9}\\). \nLowering the temperature is also a thing to do: detectors are going cryogenic. \n\nWe also have \\textbf{mirror coating Browian motion}: unfortunately, the multilayer coating of the dielectric mirrors is relatively high-loss. \n\nThe expression for this kind of noise is \n%\n\\begin{align}\nS_x (f, T) = \\frac{2 k_B T}{\\pi^2f} \\frac{d}{w^2 Y} \\phi \\qty(\\frac{Y'}{Y} + \\frac{Y}{Y'})\n\\,,\n\\end{align}\n%\nwhere \\(w\\) is the beam radius, \\(\\phi \\) is the coating mirror loss and \\(d\\) is the coating thickness.\n\\todo[inline]{what are the other variables? Eh.}\nPeople are investigating techniques which could lower \\(\\phi \\): new materials, heat treatment which could aid with the relaxation of the material, new layer structures, monolithic crystalline coatings. \n\nWe could also try to have larger mirrors and/or materials with higher optical contrast.\n\n\\subsubsection{Seismic noise}\n\nThe ground vibrations have a very large amplitude, of the order of \\SI{e-6}{m}, which is about ten orders of magnitude larger than the precision we need. \nFortunately, most of it has a very low frequency compared to GW: human activity gives vibrations at around \\SI{1}{Hz} to \\SI{10}{Hz}, while the ``oceanic peak'' is at around \\SI{.1}{Hz}. \n\nNevertheless, this pushes the mirrors out of alignment, so we need active stabilization. \n\nThe seismic noise which is in our band is more concerning, although its amplitude is lower than the peak of the seismic noise. \nThis might \\textbf{mimic a signal}: we must suppress it.\n\nWe use a passive approach: a cascade of pendula, for each of them we get a transfer function \n%\n\\begin{align}\nH_{x_{n} \\to x_{n+1}} (f) \\sim \\frac{1}{1 - f^2/f_0^2} \n\\qquad \\text{where} \\qquad\nf_0 \\sim \\sqrt{ \\frac{g}{l} } \\sim \\SI{1}{Hz}\n\\,,\n\\end{align}\n%\nso each pendulum acts as a high-pass filter: if \\(f \\gg f_0 \\) (which is the case for the high-frequency seismic noise we want to eliminate) we get an attenuation \\( \\sim (f / f_0 )^{-2 \\text{\\# pendulums}}\\). We use about 5 pendula, so very roughly this will be \\(100^{2 \\times 5}\\). \n\n\\subsubsection{Newtonian noise}\n\nThis noise is about stochastic variations of the local gravitational field. Its main causes are seismic movements and variations in atmospheric pressure. \nWe cannot shield from it: it is a metric perturbation like the GW, we cannot distinguish them \\emph{a priori}! \n\nThere are two main ways to deal with this: \n\\begin{enumerate}\n    \\item the active approach is to have many sensors detecting ground displacements and atmospheric pressure variations, model the expected disturbances and subtract this from the GW signal;\n    \\item the passive approach is to move the detector underground, where we do not need to worry about surface waves and atmospheric effects are reduced.\n\\end{enumerate}\n\n\\subsubsection{Quantum Vacuum Squeezing}\n\nA good reference for this is Miao's PhD thesis \\cite[sec.\\ 2.8]{miaoExploringMacroscopicQuantum2010}.\n\nWe quantize the electromagnetic field: \n%\n\\begin{align}\n\\hat{E} = u(x,y,z) \\int_{0}^{\\infty } \\frac{ \\dd{\\omega }}{2 \\pi }\n\\sqrt{\\frac{2 \\pi \\hbar \\omega }{\\mathcal{A} c}}\n\\qty[ \\hat{a}_{\\omega } e^{ikz - i \\omega t} + \\hat{a}^\\dag_{\\omega } e^{-ikz + i \\omega t}]\n\\,,\n\\end{align}\n%\nwhere \\(\\mathcal{A}\\) is the beam area. \nWe will need creation and annihilation operators corresponding to the sidebands: \\(\\hat{a}_{\\pm}= \\hat{a}_{\\omega_0 \\pm\\Omega }\\), and we define \n%\n\\begin{align}\n\\hat{a}_{1} = \\frac{\\hat{a}_{+} + \\hat{a}^\\dag_{-}}{\\sqrt{2}}\n\\qquad \\text{and} \\qquad\n\\hat{a}_{2} = \\frac{\\hat{a}_{+} - \\hat{a}^\\dag_{-}}{i \\sqrt{2}}\n\\,.\n\\end{align}\n\nThe state of the laser light is a \\textbf{coherent state}; it is not an eigenstate of photon number, and it can be defined as \n%\n\\begin{align}\n\\ket{\\alpha } = \\exp(\\int \\frac{ \\dd[]{\\Omega }}{2 \\pi } \\qty(\\alpha _{\\Omega } \\hat{a} ^\\dag_{\\Omega } - \\alpha^{*}_{\\Omega } \\hat{a}_{\\Omega })) \\ket{0 }\n\\,.\n\\end{align}\n\nThe \\(\\hat{a}_{1, 2}\\) are the \\emph{quadratures}. The product of their standard deviations \\(S_{\\hat{a}_{1, 2}} (\\Omega )\\) must be larger than a certain constant by Heisenberg, but we need not have a circular distribution: we can squeeze it in one direction and stretch it in the orthogonal one. \n\nThe result for the spectral density at the input is \n%\n\\begin{align}\nS^{h} (\\Omega ) = \\qty[\\frac{S_{\\hat{a}_2 (\\Omega )}}{k} + k S_{\\hat{a}_{1}} (\\Omega )]\\frac{h^2_{SQL}}{2}\n\\,,\n\\end{align}\n%\nwhich still does not allow us to beat the standard quantum limit: the bound is the same, although we can work on it without increasing the power which could be useful. \n\nThe trick comes from the fact that we can do \\textbf{frequency-dependent} squeezing! The relation of \\(\\Delta \\hat{a}_{1, 2}\\) at a specific frequency is independent of that at another! \n\nSo, we can define \n%\n\\begin{align}\n\\frac{\\Delta \\hat{a}_{1}}{\\Delta \\hat{a}_{2}} = k(\\omega )\n\\,,\n\\end{align}\n%\nwhich allows us to get, if we do the rotation optimally:\n%\n\\begin{align}\nS^{h} (\\Omega ) =   e^{-2r} \\qty[ \\frac{1}{k} + k] \\frac{h^2_{SQL}}{2}\n\\,.\n\\end{align}\n\nThe way to \\textbf{generate squeezed light} is through the use of nonlinear crystals (whose polarization has non-negligible terms depending on higher-than-linear powers of the field). \n\nIf we input into a nonlinear crystal a combination of a seed field at a frequency \\(\\omega \\) and a pump field a \\(2 \\omega \\), we can control the squeezing through their relative phase.  \n\nWe can think of squeezing as generating correlations between the sidebands' oscillations. \n\n% Qualitatively, we can say that we can make it so the qu\nWe can describe a fixed-frequency EM signal with two operators in QM, for example amplitude and phase. \n\nA squeezed vacuum is a vacuum state whose fluctuations are asymmetric. \nAt low frequency, we want to squeeze amplitude, so that the radiation pressure is more predictable and we have less test mass motion; at high frequency we want to squeeze phase, so that the number of photons is more predictable. \n\n\\todo[inline]{Hold on though: different \\textbf{GW} frequencies, not different laser frequencies! How can we change what we do for different GW frequencies before seeing the signal?}\n \n\\end{document}\n", "meta": {"hexsha": "a2fb363ef92ece23d816cd038c133486ac2187e2", "size": 17953, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/gravitational_physics/may11.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/gravitational_physics/may11.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/gravitational_physics/may11.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 48.785326087, "max_line_length": 336, "alphanum_fraction": 0.7054531276, "num_tokens": 5360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.42405152740824475}}
{"text": "\\begin{document}\n\t\\chapter{Lightning Network Analysis}\n\t\n\tThe study conducted over the gathered data served for the definition of new metrics to measure the performance and robustness of the Lightning Network and for the formal modeling of two mathematical representation of the Lightning Network, from a static and dynamic point of view. The analysis is carried over a period of one month, one snapshot per day; this observation period will be justified by the results obtained by the analysis of daily behavior of the network that will be shown next.\n\t\n\t\\section{Trends}\n\t\n\tThe following section takes in consideration the most relevant trends of the network which are the nodes and edges variation, the average degree and the diameter of the network on a daily and a monthly basis. The analysis carried over the daily basis data is made to justify the decision of the focus on a larger time window. The reasons behind the following churn rates are out of the scope of this work, but it is likely that they largely depends on protocol changes, client errors and, possibly the popularity of the network itself.\n\t\n\tA full day representation of the Lightning Network consists of 144 snapshots taken at 10 minutes intervals; the 10 minutes intervals were chosen because every channel that is added (or removed) from the network must wait for the funding transaction (settlement transaction in case a channel is being closed) to be included in a block and added to the chain by the miners. The following results matched the expectation because, as stated in the white paper, a Lightning node and its channels are meant to have a long lifespan. The data refers to the date of May 16th, May 21th, May 26th and June 2nd 2018.\n\t\n\t\\subsection{Daily nodes variation}\n\t\n\t\\begin{figure}[htbp!]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.45\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_nodes0}\n\t\t\t\\caption{May 16th 2018}\n\t\t\t\\label{daily_node0}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_nodes1}\n\t\t\t\\caption{May 21th 2018}\n\t\t\t\\label{daily_node1}\n\t\t\\end{subfigure}\n\t\t\t\\begin{subfigure}{0.45\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_nodes2}\n\t\t\t\\caption{May 26th 2018}\n\t\t\t\\label{daily_node2}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_nodes3}\n\t\t\t\\caption{June 2nd 2018}\n\t\t\t\\label{daily_node3}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_nodes_aggregated}\n\t\t\t\\caption{}\n\t\t\\end{subfigure}\n\t\t\n\t\t\\caption{Nodes trends on a daily basis. Every unit on the horizontal axis corresponds to a snapshot taken at 10 minutes intervals.}\n\t\t\\label{daily_nodes_variation}\n\t\\end{figure}\n\n\tDetails on nodes variations on a daily basis are reported in \\ref{daily_nodes_variation}. The figure shows the 144 snapshot of the network for four different days. We can notice a similar behavior between the snapshots pictured in (\\ref{daily_node1}) and (\\ref{daily_node3}), although we can't appreciate the same behavior in (\\ref{daily_node0}) or (\\ref{daily_node2}). \n\t\n\tWhile the plots may present steep slopes, it has to be noticed that the number of nodes that are joining or leaving the network is actually very low. To figure out better the numbers, the following table will show the percentage variation with respect to the initial state of the network and the highest and lowest order the graph reached that day.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C |}\n\t\t\t\\hline\n\t\t\t & May 16th (\\ref{daily_node0}) & May 21th (\\ref{daily_node1}) & May 26th (\\ref{daily_node0}) & June 2nd (\\ref{daily_node3}) \\\\\n\t\t\t\\hline\n\t\t\tStarting nodes & 818 & 731 & 778 & 776 \\\\ \\hline\n\t\t\tFinal nodes & 791 & 726 & 779 & 767 \\\\ \\hline\n\t\t\tVariation(\\%) & -3.30\\% & -0.68\\% & +0.12\\% & -1.15\\% \\\\ \\hline\n\t\t\tMax number of nodes & 818 & 731 & 781 & 778 \\\\ \\hline\n\t\t\tMin number of nodes & 790 & 726 & 776 & 765 \\\\ \\hline\n\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\\subsection{Daily edges variation}\n\n\t\\begin{figure}[htbp!]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_edges0}\n\t\t\t\\caption{May 16th 2018}\n\t\t\t\\label{daily_edges0}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_edges1}\n\t\t\t\\caption{May 21th 2018}\n\t\t\t\\label{daily_edges1}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_edges2}\n\t\t\t\\caption{May 26th 2018}\n\t\t\t\\label{daily_edges2}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_edges3}\n\t\t\t\\caption{June 2nd 2018}\n\t\t\t\\label{daily_edges3}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_number_of_edges_aggregated}\n\t\t\t\\caption{}\n\t\t\\end{subfigure}\t\t\n\t\t\\caption{Edges trends on a daily basis. Every unit on the horizontal axis corresponds to a snapshot taken at 10 minutes intervals}\n\t\t\\label{daily_edges_variation}\n\t\\end{figure}\n\n\tThe trends for edges essentially follow the same behavior of the nodes. It is trivial to see that for each node connecting (disconnecting) to the network, at least one channel is added (removed). The actual number of edges per node will be shown in the next section.\n\t\n\t\\begin{center}\n\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C |}\n\t\t\\hline\n\t\t& May 16th (\\ref{daily_edges0}) & May 21th (\\ref{daily_edges1}) & May 26th (\\ref{daily_edges0}) & June 2nd (\\ref{daily_edges3}) \\\\\n\t\t\\hline\n\t\tStarting edges & 2333 & 2132 & 2416 & 2335 \\\\ \\hline\n\t\tFinal edges & 2292 & 2119 & 2447 & 2305 \\\\ \\hline\n\t\tVariation(\\%) & -1.75\\% & -0.60\\% & +1.28\\% & -1.28\\% \\\\ \\hline\n\t\tMax num. edges & 2333 & 2132 & 2448 & 2337 \\\\ \\hline\n\t\tMin num. edges & 2282 & 2119 & 2411 & 2299 \\\\ \\hline\t\n\t\\end{tabulary}\n\t\\end{center}\n\n\t\\subsection{Daily average degree variation}\n\n\t\\begin{figure}[htbp!]\n\t\\centering\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_average_degree0}\n\t\t\t\\caption{May 16th 2018}\n\t\t\t\\label{daily_degree0}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_average_degree1}\n\t\t\t\\caption{May 21th 2018}\n\t\t\t\\label{daily_degree1}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_average_degree2}\n\t\t\t\\caption{May 26th 2018}\n\t\t\t\\label{daily_degree2}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_average_degree3}\n\t\t\t\\caption{June 2nd 2018}\n\t\t\t\\label{daily_degree3}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_average_degree_aggregated}\n\t\t\t\\caption{}\n\t\t\\end{subfigure}\n\t\\caption{Average degree on a daily basis. Every unit on the horizontal axis corresponds to a snapshot taken at 10 minutes intervals}\n\t\\label{daily_degree _variation}\n\t\\end{figure}\n\n\tThe daily average degree score appears to be confined between an all time highest of 1.59\\% and -0.12\\% among the days in exam and it is coherent with the number of nodes and edges fluctuation. By putting in relation the number of nodes and average degree variation it is possible to learn more about what kind of nodes are joining or leaving the network: for example data from (\\ref{daily_node0}) and (\\ref{daily_edges0}) show a negative edges and nodes fluctuation while the average degree variation of (\\ref{daily_degree0}) is overall increased, suggesting that the nodes that left the network were actually single-channels node.\n\n\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C |}\n\t\t\t\\hline\t\n\t\t\t& May 16th (\\ref{daily_degree0}) & May 21th (\\ref{daily_degree1}) & May 26th (\\ref{daily_degree2}) & June 2nd (\\ref{daily_degree3}) \\\\\n\t\t\t\\hline\n\t\t\tStarting degree & 5.70 & 5.833 & 6.21  & 6.018 \\\\ \\hline\n\t\t\tFinal degree & 5.79 & 5.837 & 6.28 & 6.010 \\\\ \\hline\n\t\t\tVariation (\\%) & +1.59\\% & +0.07\\% & +1.15\\% & -0.12\\% \\\\ \\hline\n\t\t\tMax avg. degree & 5.80 & 5.84 & 6.28 & 6.05 \\\\ \\hline\n\t\t\tMin avg. degree & 5.70 & 5.82 & 6.20 & 5.98 \\\\ \\hline\t\t\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\\subsection{Daily diameter}\n\t\n\t\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_diameter0}\n\t\t\t\\caption{May 16th 2018}\n\t\t\t\\label{daily_diameter0}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_diameter1}\n\t\t\t\\caption{May 21th 2018}\n\t\t\t\\label{daily_diameter1}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_diameter2}\n\t\t\t\\caption{May 26th 2018}\n\t\t\t\\label{daily_diameter2}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_diameter3}\n\t\t\t\\caption{June 2nd 2018}\n\t\t\t\\label{daily_diameter3}\n\t\t\\end{subfigure}\n\t\t\n\t\t\\caption{Diameter trends on a daily basis. Every unit on the horizontal axis corresponds to a snapshot taken at 10 minutes intervals}\n\t\t\\label{daily_diameter}\n\t\\end{figure}\n\t\n\tThe graph diameter is a measures that is derived from the wider notion of \\textit{eccentricity} $\\epsilon$ which is defined as the greatest shortest distance between a vertex \\(v\\) and every other vertex and expresses how much a node \\(v\\) is distant from the farthest node of the graph. The diameter \\(d\\) is the greatest shortest path among all the pair of nodes, i.e. it is the maximum eccentricity of any vertex in the graph.\n\t\n\t\\[d = \\max_{v \\in V} \\epsilon(v)\\]\n\t\n\tThe churn rate of the network in all four snapshots is too low to justify a variation, resulting in a constant behavior along the 144 snapshots. These trends were actually showed to justify a wider period of observation as it is hard to infer any properties from the gathered data. In the following sections, the very same trends will be showed with respect to a 32 days period. \n\n\t\\subsection{Monthly nodes variation}\n\t\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{number_of_nodes}\n\t\t\\caption{Monthly nodes variation. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_nodes}\n\t\\end{figure}\n\t\n\tFigure \\ref{monthly_nodes} displays the trend of the churning nodes from May 25th to June 27th. Differently from what has been observed on the daily trends, here the overall variation at the end of the observation period is, as expected, more pronounced as the size of the network has seen a +13.73\\% joining rate.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C | C |}\n\t\t\t\\hline\t\n\t\t\t& Starting nodes & Final nodes  & Variation(\\%) & Max num. of nodes & Min num. of nodes \\\\ \\hline\n\t\t\tMay 25th - June 27th & 779 & 886 & +13.73\\% & 886 & 682 \\\\ \\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\\subsection{Monthly edges variation}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{number_of_edges}\n\t\t\\caption{Monthly edges variation. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_edges}\n\t\\end{figure}\n\n\tEdges trend follow the same nodes trend as it has been already showed with the daily trends. Here the gap between highs and lows is even more pronounced because, trivially, it is likely that nodes have more than one channel towards other nodes and this is reflected by the variation observed with respect to the nodes, being it +19.25\\%. This graph helps to understand better the dynamic nature of the Lightning Network channels, as the churning rate of edges is higher than the one accounting for the nodes. \n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C | C |}\n\t\t\t\\hline\t\n\t\t\t& Starting channels & Final channels  & Variation(\\%) & Max num. of channels & Min num. of channels \\\\ \\hline\n\t\t\tMay 25th - June 27th & 2420 & 2886 & +19.25\\% & 2886 & 1910 \\\\ \\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\\subsection{Monthly average degree variation}\n\t\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{average_degree}\n\t\t\\caption{Monthly average degree. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_degree}\n\t\\end{figure}\n\t\n\tAs a consequences for these rates, the average degree of the network oscillates between a higher gap with respect to what has been observed during the daily analysis where the fluctuation was on average +0,67\\%. Later it will be showed the actual degree distribution of the graph, and an interesting property that will emerge is that it resembles a power-law distribution. Thanks to this intuition it will be possible to play around this feature in the building of an equivalent model. The following table shows the main characteristics emerged from the overall average degree analysis.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| L | C | C | C | C | C |}\n\t\t\t\\hline\t\n\t\t\t& Starting degree (avg.) & Final degree (avg.)  & Variation(\\%) & Max avg.degree & Min avg. degree \\\\ \\hline\n\t\t\tMay 25th - June 27th & 6.21 & 6.51 & +4.85\\% & 6.56 & 5.60 \\\\ \\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\\subsection{Monthly diameter}\n\t\n\tThe diameter essentially falls within the already known bounds found during their analysis over a daily time window, although, thanks to a wider observation period, it is possible to see how frequent the oscillation between different diameters are. In the case in exam, the plot shows a period in which the network has seen an increase that lasted for 22 days. the importance of this data will be better explained in the next session, but shortly, if a payment uses the geodesic distance as the preferred method to deliver funds, then it would mean that in the worst case there is the need to cross 7 (or 8) channels before reaching the desired peer. Keeping track of this feature may help to balance the network in a way so that new channels can fill the gap between less connected clusters or to be aware of failures of central nodes.\n\t\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{distance}\n\t\t\\caption{Diameter. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_diameter}\n\t\\end{figure}\n\n\t\\section{Betwenness\tcentrality}\n\t\\label{sec:betweenness}\n\t\n\tThe betweenness centrality is a measure of centrality in graph theory based on shortest paths and it was first formalized in 1977 by Freeman, L.\\cite{Freeman1977}. The betweenness centrality indicates how much a node in a graph stand between each other shortest paths, and it is a fundamental tool to evaluate the importance of nodes in several fields: for example, in telecommunication systems, a node with a high betweenness centrality means that a large portion of the traffic passes through it, that is, it effectively controls an appreciable part of the network but it also finds applications in biology, social networks, transport networks and many other research fields. \n\t\n\tSince the Lightning Network is a peer-to-peer payment system, it is crucial to understand which are the main players involved as they fulfill the role of bridges of different parts of the network (thus, their disconnection may cause a temporary denial of service) and entry points for new nodes as they offer guarantees over their reliability given the fact that they already manage a high payment traffic (also known as \\textit{preferential attachment} property from scale-free network), essentially forming the real backbone of the Lightning Network. But before proceeding with the results of the betweenness centrality measurements it is necessary to talk about the metric chosen to evaluate the shortest path.\n\t\n\tThe Lightning Network is a payment system based on routes between peers that delegates the payment task to their neighbors thanks to a special contract called HTLC. However, it may happen that a fund that is being processed may end up kept in hostage by a faulty node; therefore, in order to prevent this disruptive scenario a timelock (namely nLockTime parameter) is applied for each HTLC transactions that occur during the payment in order to have the certainty that, after a fixed amount of time, the payment can be considered valid. The best case scenario occurs when all the nodes of a payment path are cooperative and fulfill their duties (i.e. the payment is resolved almost instantly), while the worst case scenario occurs when each node acts maliciously by waiting until the expiration date of the HTLC approaches and then fulfilling their task, as the fidelity bonds between two parties enforce to adhere to the protocol (penalty, the lose of all the liquidity in the channel in favor of the offended party). \n\t\n\tBy default, the nLockTime parameter is set to 144 blocks which are approximately 24 hours (the Bitcoin blockchain can be seen as a timestamp service, hence the two expressions are mutual) and we've seen so far that the diameter of the network is around 7 and 8 as showed in Figure \\ref{monthly_diameter}. Thus, if the path between two peers has only malicious participant it would mean that a transactions can be considered valid only if 7 days are passed, and the funds gets locked out as well. This is the reason why it is advised to pay only for small amounts of Bitcoins, as larger sums could be locked for several days as they are still considered involved in an open payment operation: if the same situation should happen with larger sums, the consequences would be disruptive for the network as it may prevent peers to fulfill any payment for days; another reason for small payments is that large transfers of money would drain a channel balance instantly, forcing the settlement of the channel after few transactions. A new approach to payments called AMP \\cite{Amp2018} - Atomic Multipaths Payment - has been proposed as a workaround to the latter problem. It should be clear to the reader then that a payer has the necessity to minimize the distance between him and his payee, as it will minimize the time required to process a transaction in case of adversarial nodes along the path and also will minimize the time he has to wait before getting his channel funds unlocked and ready to use for a new transaction.\n\t\n\tIt has been observed that more than 90\\% of nodes policies carried the default timelock delta value of 144. Since the analysis was carried on the testnet environment it is probable that the policies of the remaining 10\\% of the edges were modified for research activities since the Lightning Network authors strongly suggest to stick with the default value for safety reason. After having removed all the edges whose timelock was different from 144, it was safe to assume that the traversal cost of an edge was equal to 1 without loss of generality.\n\t\n\tAs for the algorithm itself that will be used, the Networkx has its own implementation based on the Ulrik Brandes \\cite{Brandes2001} variant that computes the betweenness centrality running in $\\theta(nm)$ and $\\theta(n + m)$ space where $n$ is the number of nodes and $m$ the number of edges whereas the fastest known algorithm at the time required $\\theta(n^3)$ time and $\\theta(n^2)$ space.\tGenerally speaking, the betweenness centrality is evaluated according to the formula \n\t\\begin{equation}\n\t\tg(v) = \\sum_{s \\neq v \\neq t}{\\frac{\\sigma_{st}(v) }{\\sigma_st}}\n\t\\end{equation}\n\twhere $\\sigma_st$ is the total number of shortest paths from node $s$ and node $t$ and $\\sigma_{st}(v)$ is the number of paths that pass through $v$. In order to have $g(v) \\in [0, 1]$ it is necessary to normalize the values by dividing (for undirected graphs) by $(N-1)(N-2)/2$ where $N$ is the total number of nodes.\n\n\t\\begin{figure}[htbp]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.6\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_betweenness_centrality0}\n\t\t\t\\caption{Snapshot, May 16th}\n\t\t\t\\label{daily_beetwenness0}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.6\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_betweenness_centrality1}\n\t\t\t\\caption{Snapshot, May 21th}\n\t\t\t\\label{daily_betweenness1}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.6\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_betweenness_centrality2}\n\t\t\t\\caption{Snapshot, May 26th}\n\t\t\t\\label{daily_betweenness2}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.6\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{daily_betweenness_centrality3}\n\t\t\t\\caption{Snapshot, June 2nd}\n\t\t\t\\label{daily_betweenness3}\n\t\t\\end{subfigure}\n\t\t\n\t\t\\caption{Betweenness centrality of top five nodes for each day observed. Each units on the horizontal axis  corresponds to a snapshot taken at 10 minutes interval. The legend refers to the nodes identifier.}\n\t\t\\label{daily_betweenness}\n\t\\end{figure}\t\n\t\n\tThe data in Figure \\ref{daily_betweenness} picks the top 5 nodes according to their betweenness centrality aggregated score. The aggregated score means that the centrality gets first evaluated for every node of the intersection $V = \\{V_1 \\cap V_2 \\cap \\cdots V_k \\}$, where $k$ is the number of snapshot and $V_i$ being the set of nodes of each snapshot, then\n\t\\begin{equation}\\label{eq:betwenness}\n\t\tB_i(V) = \\{ g_i(v) \\mid \\forall v \\in V \\}\n\t\\end{equation}\n\tis computed, such that $B_i$ is the betweenness centrality score for all the nodes of the $i$-th snapshot. Then the nodes are sorted according to the aggregated score\n\t\\begin{equation}\n\t\tB(V) = sort(\\{ \\sum_{j = 0}^{k}g_j(v) \\mid g_j(v) \\in B_i(V), \\forall i= 0,1,2 \\cdots k\\})\n\t\\end{equation}\n\tand the top five elements by score are picked otherwise it would be impossible to visually put in relation the betweenness centrality scores and the respective nodes. Also, computing the intersection between the set of nodes gives us the opportunity to speculate over a possible backbone structure composed by nodes with higher centrality score and to observe significant events occurred during an observation period over central players.\n\t\n\tAs expected, the scores appear to be constant or with low variations along the 144 snapshots. The nodes are identified by the first five characters of their public key, and by looking at those IDs it emerges that the set is different for all their snapshot meaning that indeed new nodes joined the network during the five days elapsed between each snapshot and attached to already well established nodes. This aspect is even more pronounced if we look at Figure \\ref{monthly_betweenness_centrality} where the monthly behavior is displayed and thanks to this metric is possible to investigate deeper on nodes and events that occurred during the observation period. \n\t\n\t\\begin{figure}[ht!]\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{monthly_betweenness_centrality}\n\t\t\\caption{Betweenness Centrality (Monthly). Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals. The legend refers to the nodes identifier.}\n\t\t\\label{monthly_betweenness_centrality}\n\t\\end{figure}\t\t\n\t\n\tFor example it has been noted that, on average, the total number of neighbors of these five nodes is 486.125, accounting for 62,7\\% of the overall size of network. Such a high centrality score also suggests that a portion of neighbors may only have a single channel that keeps them connected to the rest of the network. To test this hypothesis we removed these five top nodes from the latest snapshot, and the result was that the graph got partitioned into 234 subgraphs: the largest subgraph among these contained 532 nodes (which is the Lightning Network itself) while the number of nodes of the remaining subgraphs is 242. Out of these 242 nodes, 228 were single channel nodes.\n\n\tIt is then possible to investigate over some peculiar events like the one happened during snapshot 10 and 11, where node \\textit{03e5f9} lost suddenly its centrality over 24 hours: \n\tfrom day 0 through day 10 the node was performing first among the others for betweenness centrality score. On day 11, the node dropped from 196 nodes to 37 as it closed channels with 159 peers; out of these 159 peers, 98 (12\\% of the total nodes) of them were single channel nodes, effectively disconnecting them from the rest of the network. Unfortunately it's impossible to determine the causes that led to such a drop as it may be happened because of saturated channel balances, unresponsive nodes or internal errors on their server.\n\t\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\begin{subfigure}{0.8\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=0.8\\linewidth]{scatter_plot_betweenness_centrality}\n\t\t\t\\caption{normal scale}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.8\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=0.8\\linewidth]{scatter_plot_betweenness_centrality_semilog}\n\t\t\t\\caption{semi-log scale}\n\t\t\\end{subfigure}\n\t\t\\caption{Betweenness centrality degree distribution in normal and semi-log plot with normalized betweenness centrality values. }\n\t\t\\label{betweenness_centrality_degree}\n\t\\end{figure}\n\t\n\t\\subsection{Attack strategy on Betweenness Centrality}\n\t\n\tCases like the one observed before suggest that in this network the more a node is connected towards single channel nodes (i.e. nodes with degree equals to 1), the more those nodes will be central since they will act as bridges for every single channel node that is connected to the rest of the network. Figure \\ref{betweenness_centrality_degree} shows the relation between the normalized betweenness centrality score and the degree of each nodes for 4 different time instant of the graph (0, 10, 20, 30): the highest performing nodes are also the ones whose degree his higher as expected because they act as gateways for peripheral nodes. \n\t\n\tThe previous intuition gave us the opportunity to stress the network against an attack strategy based on the removal of central nodes. The focus in this work is on the effect of such an attack rather than the causes, so the attack here is carried under the assumption that every node of the network can be shut down at every instant. It is also worth to stress the fact that while we may hypothetically be able to provoke a DoS over nodes of the network, there's no way to enforce the closure of a channel except by forcing a node to stay offline until the time-lock of a Commitment Transaction runs off, that is because a channel is a cryptographically secure contract exclusively between two parties. The attack is performed by removing from the graph the node that scored the highest betweenness centrality value and all the nodes that got disconnected by such removal from the most connected component of the graph. Afterwards, the betweenness centrality is re-evaluated over the new graph and the process is iterated until there are no more nodes left to remove. \n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.7\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{monthly_betweenness_centrality_attack}\n\t\t\t\\caption{Number of nodes needed to disconnect the network}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.7\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{monthly_betweenness_centrality_attack_percentage}\n\t\t\t\\caption{Percentage of nodes wrt graph size of current snapshot.}\n\t\t\\end{subfigure}\n\t\t\\caption{Number of iterations for each snapshot needed to disconnect every node of the network. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{betweenness_attack}\n\t\\end{figure}\n\t\n\tThe algorithm was performed over every snapshot of the network, and the result exceeded our optimistic previsions as the number of nodes required to completely destroy the network is fairly low compared to its size. Figure \\ref{betweenness_attack} shows\thow many iterations (i.e. nodes to be removed since every iteration removes at least one node) are needed to shut-down the network for each snapshot. The removal of a nodes produces many subgraphs whose size is usually 1, thus it's hard to determine a cut that produces large size partitions. Setting up and perform such an attack should be a feasible task: indeed, to the best of our knowledge, a successful DDoS attack has been already carried over the real network in March 2018, and resulted in 200 nodes disconnected from the network when the network size was of about 1000 nodes, thus disconnecting the 20\\% of the clients which is actually higher than the average of 7.86\\% of nodes found with this method. Details on this attack have not been revealed but is said to be leveraging on \\textit{open-channel requests} in order to open as many TCP/IP connections as possible.\n\t\n\tBy looking at the history of the betweenness centrality score is then possible to understand better the reliability of particular nodes, and to track nodes that get too centralized around hubs, thus making the network more and more similar to the current transaction processors like VISA or Mastercard: the autopilot feature of the Lightning Network might check the whole network betweenness centrality to regulate the new channels establishment process in order to decrease the centralization around greedy players. Another risk factor for centralization is given by the fact that central nodes are subjected to increased computational processing since each routed payment processed has a computational cost associated (albeit being low); collecting Lightning Network fees is less profitable than mining blocks, hence the need to maximize the earnings by reducing the operational costs in terms of energy spent, and this will likely force active members of the Lightning Network to opt for devices with lower performances: overloading such devices with routing tasks may drastically increase the fault probability, thus impacting on the overall network quality of life.\n\t\n\t\\section{\\textit{k}-vertex connectivity}\n\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{monthly_completeness}\n\t\t\\caption{Density of the graphs. Density is calculated as $\\frac{m}{n(n-1)}$. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_completeness}\n\t\\end{figure}\n\t\n\t\\textit{k}-vertex connectivity gives an important outlook when it comes to robustness. In graph theory a graph $G = (V,E)$ is said to be \\textit{k}-vertex connected if for every pair of vertices there are \\textit{k}-vertex indipendent paths connecting these vertices, or in other words, \\textit{k} is the size of the smallest subset of vertices such that the graph becomes disconnected if deleted. Complete graphs do not fall into this definition since a complete graph cannot be disconnected by removing vertices. Furthemore, if a complete graph has n-vertices, then by the above definition it falls in the class of (n-1)-vertex connectivity, but as Figure \\ref{monthly_completeness} shows, the network is far to be complete.\n\n\tComputing the k-vertex connectivity alone over the snapshots is not particularly useful as the Lightning Network, being a connected network, will always be a 1-vertex connected graph. Nonetheless, it's very likely that inside the 1-vertex connected component there may be others, stronger, connected components, i.e. there may exists subgraphs whose k-vertex connectivities are higher than their supergraph. This kind of reasoning can be applied iteratively until it's impossible to find any new subgraph whose k-vertex connectivity is higher than their supergraph.\n\t\n\tThe algorithm used to perform this task has been proposed by James Moody and Douglas R. White \\cite{Moody2003} based on their research over cohesion in social groups. It returns the k-component structure of a graph G, where a k-component is a maximal subgraph of G that has at least node connectivity k. The algorithm works as follow:\n\t\\begin{enumerate}\n\t\t\\item Compute node connectivity k of the input graph.\n\t\t\\item Identify all k-cutsets at the current level of connectivity. \n\t\t\\item Generate new graph components based on the removal of these cutsets. Nodes in a cutset belong to both sides of the induced cut.\n\t\t\\item If the graph is neither complete nor trivial, return to 1; else end.\n\t\\end{enumerate}\n\t\n\tThe algorithm has been running over the 32 snapshots. What emerged is an inherent hierarchical structure of the network where the innermost components shows a high k-vertex connectivity (or cohesive degree) compared to the most peripheral nodes. Trivially, as the connectivity increases, the vulnerability to isolated actions performed unilaterally by some (byzantine) nodes decreases such that the degree of actions of any malicious attacker depends on at least $k$ components of the subgraph.\n\t\n\t\\subsection{Components size}\n\t\n\t\\begin{figure}[ht!]\n\t\t\\includegraphics[width=\\linewidth]{k_connectivity_average_size}\\\\\n\t\t\\caption{Average size for each components for every snapshot taken from May 25th to June 27th.}\n\t\t\\label{monthly_connectivity_average}\n\t\\end{figure}\n\t\n\t\\begin{figure}\n\t\t\\includegraphics[width=\\linewidth]{k_connectivity_max_size}\n\t\t\\caption{Highest connectivity value for each snapshot. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthly_connectivity_max_size}\n\t\\end{figure}\n\t\n\tThe data presented in Figure \\ref{monthly_connectivity_average} represents the average size of each component over the 32 snapshots in exam. The orange bars represent the mean value of every component while the black lines represent their standard deviation.\tThe 1-connected component is trivially the average of the graph sizes over the 32 captures; indeed every 1-connected component size is equal to the graph order of the relative snapshot. More than 50\\% of the network is a biconnected subgraph (2-vertex connected graph) meaning that every node inside it is resilient up to two opportunely selected node failures (that is, nodes selected according to the well-known min-cut criteria) and, as we move right in the plot, the graphs get more and more resistant to node failures. What emerges from the analysis of the k-vertex-connectivity structure is a concentric configuration in which every k-component is included inside the (k-1)-component: this key aspect stresses the resilience to failures typical of scale-free networks as it would be impossible for attackers to disconnect a reasonable number of nodes in order to provoke any serious damage to the network. Figure \\ref{monthly_connectivity_max_size} depicts the highest value k obtained for each snapshot and shows a dynamic behavior of k-connectivity, ranging from a lower bound of 12 to an upper bound of 15.\n\t\n\t\\subsection{Betweenness inclusion}\n\t\n\tIt is interesting to see which nodes belong to the top connected component. The intuition is that nodes that scored best in betweenness centrality will likely to belong to the highest k-component. The results were achieved in the following way:\n\t\\begin{enumerate}\n\t\t\\item Calculate $B_i(V)$ for each snapshot as seen in \\ref{eq:betwenness}. Sort the result in a descending fashion. \n\t\t\\item For each $B_i(V)$ selects the first $s$ elements, where $s = |C_i|$ and $C_i$ being the set of nodes that belong to highest k-vertex component of the snapshot $i$.\n\t\t\\item Compute the intersection between the two sets.\n\t\\end{enumerate}\n\t\n\t\\begin{figure}\n\t\t\\includegraphics[width=\\linewidth]{k_connectivity_beetwenness}\n\t\t\\caption{Blue bars show the size of the maximum k-connected subgraph, orange bars show how many nodes selected among the top betweenness centrality nodes belong to the most connected component. Every unit on the horizontal axis corresponds to a snapshot taken at 24 hours intervals.}\n\t\t\\label{monthyl_k_connectivity_betweenness}\n\t\\end{figure}\n\t\n\tThe results are showed in Figure \\ref{monthyl_k_connectivity_betweenness} and as expected a large portion of the top performing central nodes are inside the innermost connected component. Data shows that on average the 72,34\\% of the current top central nodes by betweenness centrality score belong to the most cohesive group of each snapshot.\n\t\n\tThis aspect has several possible implications: as the network grows in size it will be unfeasible for each nodes to obtain and maintain the evolution of the whole network topology; a solution would be to organize the various Lightning Network nodes in a way similar to the Internet Network where backbone routers, which have a higher capacity, tie together various large subnetworks. Of course such a solution should be implemented according to the Bitcoin \"no-trusted-third-parties\" philosophy in mind. Central nodes inside this subgraph could be elected to actively participate in this backbone, and it is possible to extend this reasoning to lower k-connected components everytime the network grows in size to form a hierarchical structure as seen on computer networks. \n\t\n\tThe downsides in having so many central nodes tied together in such a strong connected component is that they may organize into cartels and decide to offer fast and reliable transaction processing only to nodes who adhere (by paying a fee or by submitting to some conditions) to their payment subnetwork while they act as gateways when it comes to route incoming and outgoing payments, in contrast with the decentralization principles of the network. Also such a scenario would suffer from low fairness with respect to transaction processing as they could refuse to process transaction that don't belong to their cartel.\n\n\t\\section{Lightning Network as a Scale-free network}\n\t\n\tMany features that has been showed so far suggests that the Lightning Network is a complex network: the hierarchical fault tolerance showed in the k-vertex connectivity analysis, a high centrality of some high degree nodes making them hubs, the low diameter of the network compared to its number of nodes and edges are common features in scale-free networks. Such networks are random graphs whose degree distribution follows a power law such that \n\t$$P(k) \\sim k^{-\\gamma}$$\n\twhere $\\gamma$ is a parameter whose value is usually $2 < \\gamma < 3$. For this reason the degree distribution has been evaluated for all the snapshot of the period of observation. Given a graph $G = (V,E)$, $P(k)$ is defined as the probability for a node in V drawn at random of having exactly $k$ edges. Mathematically, it can be expressed as:\n\t$$P(k) = \\frac{|\\{ v_i \\in V : \\deg v_i = k \\}}{|V|}$$\n\twhere $k = \\{0,1 ... n - 1\\}$ and $n = |G|$. \n\t\n\t\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{graph_28_scatter}\n\t\t\\caption{log-log plot of the degree probability.}\n\t\t\\label{graph_28_scatter}\n\t\\end{subfigure}\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{graph_28_fit}\n\t\t\\caption{Curve fitting over the probability distribution.}\n\t\t\\label{graph_28_degree}\n\t\\end{subfigure}\n\t\t\\caption{Degree distributions from snapshot 28 in log-log scale and standard scale}\n\t\\end{figure}\n\t\n\tThe autopilot feature of the Lightning Network shows a preference towards higher degree nodes when it comes to open new payment channels and indeed it uses the Barabàsi-Albert model preferential attachment to perform this task, which assumes $\\gamma=3$ for the degree distribution. However, many nodes of the real network are configured to custom parameters such as the maximum number of channels allowed, therefore introducing a bias in the network structure that makes the system diverge from the ideal representation. It is of interest then to compare different models based on a power-law distribution to see which one fits better the nature of the network. Thus, the first attempt was to generate a new network using the BA-model with 886 nodes and 2649 edges, which is the maximum size of the Lightning Network encountered so far. This will later be put in comparison to another power-law model.\n\t\n\tIn order to build a graph that responds to a power-law degree distribution, it is necessary to first figure out the value of $\\gamma$ from the data gathered so far using the definition of degree distribution $P(k)$ shown above. For the sake of clarity, Figure \\ref{graph_28_scatter} and \\ref{graph_28_degree} shows the degree distribution for a single capture of the graph, in a log-log and normal scale respectively. Unfortunately since the adoption of the network is still low and because the network has been studied on the testnet environment due to size constraints, the amount of data results to be scarce and many outliers occur. As a consequence it has been chosen to use the Bisquare weights regression where weight is given to each data point based on how far the point sits from the fitted curve, thus minimizing the effect of outliers points.\n\t\n\tBy using the curve fit tool from Matlab, it has been possible to evaluate the gamma value of the fitting curve for each snapshot such that $\\Gamma = \\{\\gamma_1, \\gamma_2, ... , \\gamma_d\\}$ where $d$ is the number of snapshots, using Bisquare as robust regression and the Trust-Region algorithm, then mean, variance and standard deviation has been evaluated over $\\Gamma$.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{0.75\\linewidth}{| L | C | C | C | }\n\t\t\t\\hline\n\t\t\t& Mean & Variance & Standard Deviation \\\\ \\hline\n\t\t\t$\\gamma$ & 2.0453 & 0.226 & 0.1503  \\\\ \\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\t\n\t\n\tFrom the $\\gamma$ value, a new graph has been created with a number of nodes in the order of the sizes seen until now, specifically 886 nodes as it has been done with the BA-model: firstly, a degree sequence that follows a power-law distribution with a given exponent has been calculated, then the graph was generated through an algorithm modeled around the preferential attachment property of scale-free networks by W. Aiello, F. Chung and L. Lu, \\cite{Aiello2001} \\cite{Chung2002}, which performed best with respect to the \\textit{configuration model} from M. Newman \\cite{Newman2003}, where graphs with self-loops and parallel edges are a possible outcome of the generative process; manually removing these would cause an important structural bias. The Chung-Lu generative approach doesn't explain why a graph has a particular degree sequence, rather, this model tries to derive the structural properties of a real network, starting from a power-law degree sequence.\n\t\n\tThe features we are interested in are the one that describe the topology of a graph. Because of the random generative process, the data here showed is the average results for each metric gathered by 100 random graphs generated by the BA and Chung-Lu models. An important aspect of scale-free networks is the \\textit{small world} property, where a network is said to be a small world if its diameter is low compared to the total number of nodes. It has already been observed that the current diameter for the Lightning Network is around 7 and 8; results on the generated networks still carries this aspect, as showed on the table below.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary}{\\linewidth}{| C | C | C | C | C |}\n\t\t\t\\hline\n\t\t\t& Radius & Diameter & Eccentricity & Avg. Shortest Path \\\\ \\hline\n\t\t\tReal World & 4.0 & 7.656 & 5.50 & 3.098 \\\\ \\hline\n\t\t\tChung-Lu model & 3.48 & 6.54 &  4.778 &  2.719 \\\\ \\hline\n\t\t\tBA-model & 3.87 & 6 & 4.9188 & 3.487 \\\\ \n\t\t\t\\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\tThe eccentricity and diameters value of the two models here are almost identical, with the Chung-Lu model performing slightly better than the BA-model which shows a shorter diameter but a higher average shortest path length.\n\t\n\t\t\\begin{figure}[htbp]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{scatter_plot_betweenness_centrality_chung_lu}\n\t\t\t\\caption{Chung-Lu model}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{scatter_plot_betweenness_centrality_chung_lu_semilog}\n\t\t\t\\caption{Chung-Lu model (semilog)}\n\t\t\\end{subfigure}\n\t\t\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{scatter_plot_betweenness_centrality_barabasi}\n\t\t\t\\caption{BA model}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.49\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{scatter_plot_betweenness_centrality_barabasi_semilog}\n\t\t\t\\caption{BA model (semilog)}\n\t\t\\end{subfigure}\n\t\t\\caption{Betweenness centrality degree distribution for BA and Chung-Lu generated networks.}\n\t\t\\label{betweenness_centrality_degree_models}\n\t\\end{figure}\n\t\n\tAnother good metric for comparing different networks is the average clustering coefficient, which is a way to measure how close a node and its neighbors are to being a clique and it's defined for undirected graph for every node $i$ of the graph as $$C_i = \\frac{\\lambda_G(v)}{\\tau_G(v)}$$ where $\\lambda_G(v)$ is the number of subgraphs of the graph with 3 vertices (one of which must be $v$) and 3 edges, and $\\tau_G(v)$ is the number of triples, i.e. the number of subgraphs with 3 vertices and 2 edges, in which $v$ is incident to both the edges. The table below shows the results for the real network, the network generated through Chung-Lu algorithm and the BA model.\n\t\\begin{center}\n\t\t\\begin{tabulary}{0.75\\linewidth}{| C | C |}\n\t\t\t\\hline\n\t\t\t& Average Clustering Coefficient \\\\ \\hline\n\t\t\tReal World & 0.20591 \\\\ \\hline\n\t\t\tChung-Lu model & 0.3368 \\\\ \\hline\n\t\t\tBA-model & 0.03322 \\\\\n\t\t\t\\hline\n\t\t\\end{tabulary}\n\t\\end{center}\n\n\tHere the differences between the two models are more pronounced. While the Chung-Lu model shows an average clustering coefficient in line with the real case scenario, the BA-model lacks on catching properly the aspect of centralized hubs which are a fundamental characteristic of the Lightning Network. Furthermore, this aspect is also reflected by degree distribution in relation to the betweenness centrality that we already seen in Section \\ref{sec:betweenness}. Figure \\ref{betweenness_centrality_degree_models} shows degree betweenness centrality distributions of two random generated graphs both in linear and semilogarithmic scale. What emerges is that the betweenness score from BA-model is quite lower than the Chung-Lu and real network, and this was kinda expected given the that the average clustering coefficient has been shown to be low, suggesting that nodes in BA do not model the central hubs as well as in Chung-Lu.\n\t\n\tAs already stated in \\cite{Watts1998}, random graphs clustering coefficients are usually smaller with respect to real network ones because of the inability to describe at best the inevitable unpredictability of some phenomena. Hence a deeper understanding of the probability distribution with the exact $\\gamma$ value was necessary to obtain an equivalent model able to show the same behavior of the real network.\n\t\n\tWith this in mind, it's possible then to generate equivalent models of desired sizes based on the Chung-Lu generative approach, that has been showed to fit better with respect to the BA-model. As the size grows, the properties showed so far grow accordingly to the nature of the network. Testing the generated model against 10'000 nodes produced very interesting results, reported in the table below. Like before, the generated graph produced many isolated nodes and small size components, so it has been necessary to prepare the network  by removing these unnecessary entities before running the evaluation.\n\t\n\t\\begin{center}\n\t\t\\begin{tabulary} {\\linewidth}{| C | C | C | C | C |}\n\t\t\t\\hline\n\t\t\tNum. of nodes & Num. of edges & Clustering Coefficient & Diameter & Avg. shortest path \\\\ \\hline\n\t\t\t8420 & 29969 & 0.1038 & 9 & 3.4679\\\\ \\hline\n\t\t\\end{tabulary}\n\t\\end{center} \n\t\n\tResults show a decreased average clustering coefficient, as the scale-free networks are supposed to perform when they grow in size, and overall the other parameters are in line with the values observed in the real network. It must be reminded however that data are based over the Testnet environment: unfortunately, generating an equivalent network for the Main-Net has been showed to be not accurate, as the average degree of the Main-Net appears to be higher than the one presented here, therefore the $\\gamma$ value discovered so far is only representative of the testing network. However, the methodologies here presented are compatible with the real network environment so it should not be hard to see if they applies for a real world scenario.\n\n\t\\section{Assessing node dynamicity}\n\t\n\t\n\tWe introduce a formalism to describe the dynamic behavior of the network from nodes and edges points of view. The network evolution is described in a time interval defined as a set of integer $\\{t_0, t_1, t_2 .... t_k \\}$. Since the network was observed at fixed time interval  we can assume that for $\\forall \\: 0 < i \\leq k,\\: t_i-t_{i-1} = c$ and specifically in this work $c = 1$, hence we can refer to each time instant either by $t_i$ or its integer $i$ without loss of generality. For every time instant $t$, there is a graph $G_{t}= (V_t,E_t)$ where $V_t$ and $E_t$ represents the set of nodes and edges at time $t$ respectively. Nodes that constantly enter and leave the network are called \\textit{churning nodes}. To characterize these two behaviors with respect to the time parameter we define two functions based on Bonomi's model present in \\cite{Baldoni2010}:\n\t\\begin{definition}\n\t\tJoin function. $\\lambda(t)$ is defined as a discrete time, deterministic function that returns the number of nodes that joined the network at time $t$, i.e. they opened a payment channel with \\textit{at least} one node of the network.\n\t\\end{definition}\n\t\\begin{definition}\n\t\tLeave function. $\\mu(t)$ is defined as a discrete time, deterministic function that returns the number of nodes that left the network at time $t$, i.e. they closed \\textit{every} payment channel with previously connected nodes.\n\t\\end{definition}\n\tThe join and leave rate has been evaluated through set differences between the vertices V of the various instance of the network such that\n\t$$\\lambda(t_i) = |V_{t_i} \\setminus V_{t_{i-1}}|$$\n\t$$\\mu(t_i) = |V_{t_{i-1}} \\setminus V_{t_i}| $$\n\tFor initial time $t_0$ and for every $t \\leq t_0$ the two functions returns 0.\n\t\\begin{figure}[h]\n\t\t\\includegraphics[width=\\linewidth]{churn}\n\t\t\\caption{$\\lambda(t)$ and $\\mu(t)$ functions over the observed time interval}\n\t\t\\label{churn}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\includegraphics[width=\\linewidth]{percentage_static_nodes}\n\t\t\\caption{Percentage of stable nodes inside each $G_t$.}\n\t\t\\label{percentage_static_nodes}\n\t\\end{figure}\n\tFigure \\ref{churn} shows the observed churn rates along the period of observation, putting in evidence a relatively small churning rates with respect to the number of nodes of each snapshot as previously displayed by Figure \\ref{monthly_nodes}.\n\t\n\tIf $\\lambda(t)$, $\\mu(t)$ and $N(t_0)$ are known, with $N(t_0)$ being the number of nodes at time $t_0$, it is then possible to know the size of the network thanks to\n\t\\begin{definition}\n\t\tNodes function. Let $N(t_0) = n_0$, the nodes function returns the number of nodes belonging to the system at time $t$ for every $t \\geq t_0$, such that \n\t\t$$N(t_0) = n_0$$\n\t\t$$N(t) = N(t-1) + \\lambda(t) - \\mu(t)$$\n\t\\end{definition}\n\tWe can proceed to calculate the actual churn rate of the network through\n\t\\begin{definition}\n\t\tJoin churn rate. Let $T = t_k - t_0$ being the interval of observation. The join churn rate is defined as\n\t\t$$\\lambda_{rate} = \\frac{\\sum_{i = 1}^{k}\\frac{\\lambda(t_i)}{N_{t_i}}}{k},$$\n\t\\end{definition} \n\t\\begin{definition}\n\t\tLeave churn rate. Let $T = t_k - t_0$ being the interval of observation. The leave churn rate is defined as\n\t\t$$\\mu_{rate} = \\frac{\\sum_{i = 1}^{k}\\frac{\\lambda(t_i)}{N_{t_{i}}}}{k}.$$\n\t\\end{definition}\n\n\tData shows a modest churn rate being it $\\lambda_{rate}=1.87\\%$ and\n\t$\\lambda_{rate}=1.51\\%$. The largest portion of the network has been observed to be stable throughout the entire time interval. The static nodes of the Lightning Network have been evaluated by computing the intersection between the vertices of the various graph $G_t$, such that\n\t$$N_{static}(T) = |V_{t_0} \\cap V_{t_1} \\cap V_{t_2} ... \\cap V_{t_k}|$$\n\twith $T = t_k - t_0$, defined as the interval of observation.\n\t\n\tThe size has been found to be $N_{static} = 503$ nodes and Figure \\ref{percentage_static_nodes} shows the fraction of nodes that are stable with respect to the total number of nodes for each graph $G_t$ but results may be skewed by two particular event as observed in Figure \\ref{churn}, where we can first appreciate a severe drop in $\\mu(t_{11})$, and that has already been addressed in Section \\ref{sec:betweenness} where we commented on the behavior of the most central node shutting down 159 channels, and second, in $\\lambda(t_{26})$, where 167 new nodes joined the network; the unexpected churn can be explained by a real fact that happened during the observation period where a user tried and succeeded to become the most important node per capacity score in the main-net environment in July 2018\\footnote{https://medium.com/andreas-tries-blockchain/bitcoin-lightning-network-1-can-i-compile-and-run-a-node-cd3138c68c15}, so it is plausible that he performed some test over the testing environment before approaching the real network.\n\t\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\begin{subfigure}{0.7 \\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{edge_churn_plot}\n\t\t\t\\caption{Edges variation with churning nodes.}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.7 \\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{edge_stable_churn_plot}\n\t\t\\caption{Edges variation without churning nodes.}\n\t\\end{subfigure}\n\t\\caption{Edges join and leave variation in both scenarios where churning nodes are included and excluded from each snapshots.}\n\t\\label{fig:edge_churn}\n\t\\end{figure}\n\n\t\\begin{figure}[t]\n\t\t\\includegraphics[width=\\linewidth]{edge_stable_ratio}\n\t\t\\caption{Static edges and number of edges per snapshot ratio.}\n\t\t\\label{fig:edge_stable_ratio}\n\t\\end{figure}\n\t\n\t\\section{Assessing edge dynamicity}\n\t\n\tAs more and more nodes join and leave the network, the channel structures changes accordingly and we can observe from Figure \\ref{fig:edge_churn} that dynamic nodes introduce the most variation when it comes to edges (which is normal as every nodes that connects (disconencts) must open (close) at least one channel). The network is characterized by a stable edge component that accounts for $E_{static} = 1202$ nodes and Figure \\ref{fig:edge_stable_ratio} shows that, on average,  only 52.55\\% of the edges of each snapshot are going to stay through all the observation period.\tTo better capture the dynamic behavior of the network, we introduce a formalism that takes into account the edge variability of a graph with respect to time. This framework is known as TVG or Time Varying Graph, and it is a unified model which is the integration of various existing models and concepts proposed in the literature for dynamic graphs. \\\\\n\tWe define our TVG as a directed graph $\\mathcal{G} = (V, E, \\mathcal{T}, \\rho, \\mathcal{C}, A)$ where:\n\t\\begin{itemize}\n\t\t\\item $V$ and $E$ are the set of nodes of our network respectively. \n\t\t\\item $E: V \\times V$ and each edge has a set of attributes $A(e) = [k_1(e),\\, k_2(e)]$ which maps to <\\textit{balance, htlc}> which is the htlc and balance value for node $i$. $A$ is a matrix of attributes accounting for every edge in $\\mathcal{G}$.\n\t\t\\item $\\mathcal{T} \\subset \\mathbb{T}$ is the lifetime of the model.\n\t\t\\item $\\rho$ is the edge presence function such that $\\rho: E \\times \\mathcal{T} \\to \\{0,1\\}$.\n\t\t\\item $\\mathcal{C}$ is the set of channels: a channel $c_{u,v} = c_{v,u}$ between two nodes $u$ and $v$, is represented as two edges $e_{u,v}$ and $e_{v,u}$ such that $c_{u,v} = (e_{u,v}, e_{v,u})$. Furthermore, an edge $e_{ij}$ from node $i$ to $j$ exists iff there is an edge $e_{ji}$  from node $j$ to $i$.\n\t\\end{itemize}\n\t\n\tThe channel capacity is defined as $cap_{c_{u,v}} = k_1(e_{u,v}) + k_1(e_{v,u})$ and its constant through all the life window of the channel.\n\tThe Time Varying Graph takes place on the \\textit{lifespan} $\\mathcal{T}  \\subset \\mathbb{T}$ where the domain of $\\mathbb{T}$ is assumed to be $\\mathbb{N}$, i.e. the system is discrete-time,and the underlying graph $G = (V, E)$ represents a \\textit{footprint} of the graph in which the time aspect of a node is flatten out. \n\t\n\tFrom a graph-centric point of view the evolution of $\\mathcal{G}$ is described as a sequence of graphs $\\mathcal{S}_{\\mathcal{G}} = G_1, G_2, ... $ where a graph $G_i$ can be seen as a static snapshot of $\\mathcal{G}$ at time $t_i$ and it is easy to see how this model perfectly fits with the data collected for this work, where each characteristic graph of $\\mathcal{S}_{\\mathcal{G}}$ corresponds to the snapshots observed so far. The power of expressiveness of this model resides on the fact that the granularity in which edges appear in the network can be adjusted in order to provide a more punctual information over the dynamic topology of the network: for example we could see how the model evolves when each time instant is considered to be 10 minutes, 30 minutes or 24 hours.\n\n\tIn this model we addressed the problem of performing payments in the worst scenario (i.e. nodes uncooperative until payment expiration). We define an uncooperative payment function as follows:\n\t\\begin{definition}\n\t\t\\textit{uncooperativePayment}(u,v,s). Defines a payment function. A payment can be performed at time instant $t_n$ if:\n\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\\item $\\exists$ a path between node $u$ and $v$, denoted as $\\pi =  \\{c_{u,1}, c_{2,3} ... {c_{m,v}}\\}$.\n\t\t\t\n\t\t\t\\item $l = |\\pi|$ is the number of channels that need to be traversed from $u$ to reach $v$, $\\forall \\, e_i$ s.t. $e_i$ is the i-th edge to be traversed, it must hold that $\\rho(e_i, t_d) = 1, \\, \\forall \\, n < d < n + k$ where $k = \\sum_{j = i}^{l}k_2(e_j)$. That means that an edge must remain open in a decrementing timelock fashion for the duration of the payment.\n\t\t\t\n\t\t\t\\item $\\forall$ edges $e$ in $\\pi$ that connects $u$ to $v$, $k_1(e) >= s$, i.e. an edge carries enough funds to allow the transfer of money.\n\t\t\t\n\t\t\t\\item For every payment operation $\\pi_i$ that is taking place in any instant between $[t_n, t_{n + k_{tot}})$ where $k_{tot} = \\sum_{j = 0}^{l} k_2(e_j)$, it must hold that $\\pi \\cap \\pi_i = \\emptyset$, meaning that there can't be two or more payments occurring on any edges that belong to $\\pi$.\n\t\t\t\n\t\t\t\\item at the end of the payment, $\\forall$ edges $e_{ij}$ in $\\pi$ that connects $u$ to $v$ it must hold that $cap_{i,j} = k_1(e_{i,j}) + k_1(e_{j,i})$ and $k_1(e_{j,i}) = cap_{i,j} - (k_1(e_{i,j}) - s)$.\n\t\t\\end{itemize}\n\t\\end{definition}\n\n\tThe cooperative payment scenario between $u$ and $v$ can be modeled trivially by requiring $\\forall$ edge $e$ that participates to the payment path $\\pi$ to have at time $t_n$ $\\rho(e, t_n) = 1$. The payment is resolved instantly and each channel from $u$ to $v$ updates its balance according to the amount of money transferred. \n\t\n\t\n\n\\end{document}", "meta": {"hexsha": "d055ea7141efaa58a647e97178dcc73112c5f7fb", "size": 59191, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "results/results.tex", "max_stars_repo_name": "randomBEAR/master_thesis", "max_stars_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "results/results.tex", "max_issues_repo_name": "randomBEAR/master_thesis", "max_issues_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "results/results.tex", "max_forks_repo_name": "randomBEAR/master_thesis", "max_forks_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.6903703704, "max_line_length": 1523, "alphanum_fraction": 0.7655048909, "num_tokens": 15211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.661922862511608, "lm_q2_score": 0.640635841117624, "lm_q1q2_score": 0.42405150978010936}}
{"text": "\\chapter*{Nomenclature}\n\\addcontentsline{toc}{chapter}{Nomenclature}\n\n\\section*{Symbols}\n\\begin{tabbing}\n\\hspace*{1.6cm} \\= \\hspace*{8cm} \\= \\kill\n$\\mathbb{R}^n$ \\> set of real column vectors of length n \\\\[0.5ex]\n$\\mathbb{R}^{m \\times n}$ \\> set of real m by n matrices \\\\[0.5ex]\n$\\mathbf{0}_{m \\times n}$ \\> n by m zero matrix \\\\[0.5ex]\n$\\mathbf{I}_n$ \\> identity matrix of dimension n \\\\[0.5ex]\n$\\x$ \\> state of robot \\\\[0.5ex]\n$\\u$ \\> control input of robot \\\\[0.5ex]\n$\\xped[k]$ \\> state of pedestrian k \\\\[0.5ex]\n$\\uped[k]$ \\> control input of pedestrian k \\\\[0.5ex]\n$\\muped[k]$ \\> mean of state $\\xped[k]$ \\\\[0.5ex]\n$\\sigmaped[k]$ \\> variance of state $\\xped[k]$ \\\\[0.5ex]\n$\\piped[k]$ \\> mode importance of state $\\xped[k]$ \\\\[0.5ex]\n$\\goal$ \\> goal state \\\\[0.5ex]\n$\\xset$ \\> set of feasible states \\\\[0.5ex]\n$\\xset_0$ \\> set of initial states \\\\[0.5ex]\n$\\xset_f$ \\> set of terminal/goal states \\\\[0.5ex]\n$\\xset_{rel}$ \\> Hamilton-Jacobi reachability joint states set \\\\[0.5ex]\n$\\xset_{avoid}$ \\> Hamilton-Jacobi reachability avoid set \\\\[0.5ex]\n$\\uset$ \\> set of feasible controls of robot \\\\[0.5ex]\n$\\upedset$ \\> set of feasible controls of pedestrian \\\\[0.5ex]\n$t_0$ \\> initial time of optimization [s] \\\\[0.5ex]\n$t_f$ \\> final time of optimization [s] \\\\[0.5ex]\n$T$ \\> optimization horizon in discrete steps \\\\[0.5ex]\n$\\Delta t$ \\> discretization time of the dynamics [$s$] \\\\[0.5ex]\n$\\dt$ \\> time-step of Runge-Kutta integration method [$s$] \\\\[0.5ex]\n$K$ \\> number of pedestrians \\\\[0.5ex]\n$k$ \\> pedestrian index \\\\[0.5ex]\n$L$ \\> number of pedestrian prediction modes \\\\[0.5ex]\n$l$ \\> prediction mode index \\\\[0.5ex]\n$n$ \\> dimension of state $\\x$ \\\\[0.5ex]\n$m$ \\> dimension of control input $\\u$ \\\\[0.5ex]\n$\\stepssolution$ \\> number of solution time-steps from initial to target state \\\\[0.5ex]\n$\\f(\\cdot)$ \\> system dynamics of robot \\\\[0.5ex]\n$\\frel(\\cdot)$ \\> joint robot-pedestrian system dynamics \\\\[0.5ex]\n$J(\\cdot)$ \\> cost function \\\\[0.5ex]\n$l(\\cdot)$ \\> step cost function \\\\[0.5ex]\n$l_f(\\cdot)$ \\> final cost function \\\\[0.5ex]\n$\\Vrel(\\cdot)$ \\> Hamilton-Jacobi reachability value function \\\\[0.5ex]\n$\\mathcal{N}(\\cdot)$ \\> normal probability distribution \\\\[0.5ex]\n\\end{tabbing}\n\n\\section*{Operators}\n\\begin{tabbing}\n\\hspace*{1.6cm} \\= \\hspace*{8cm} \\= \\kill\n$\\mathbb{E}_Y[\\cdot]$ \\> expectation operator with respect to $Y$ \\\\[0.5ex]\n$\\mathrm{Var}_Y[\\cdot]$ \\> variance operator with respect to $Y$ \\\\[0.5ex]\n$\\max$ \\> maximum operator \\\\[0.5ex]\n$\\min$ \\> minimum operator \\\\[0.5ex]\n$||\\cdot||_1$ \\> L1 norm (absolute value) \\\\[0.5ex]\n$||\\cdot||_2$ \\> L2 norm (euclidean distance) \\\\[0.5ex]\n$||\\cdot||_{\\infty}$ \\> L-infinity norm (maximal value) \\\\[0.5ex]\n\\end{tabbing}\n\n\\section*{Indexing}\n\\begin{tabbing}\n\\hspace*{1.6cm} \\= \\hspace*{8cm} \\= \\kill\n$\\mathbf{a}_i$ \\> element $i$ of vector $\\mathbf{a}$ \\\\[0.5ex]\n$\\mathbf{A}_{ij}$ \\> element in row $i$ and column $j$ of matrix $\\mathbf{A}$ \\\\[0.5ex]\n\\end{tabbing}\n\n\n\\section*{Acronyms and Abbreviations}\n\\begin{acronym}[Bash]\n\\acro{ETH}{Eidgenössische Technische Hochschule}\n\\acro{IDSC}{Institute of Dynamical Systems and Control at ETH Zürich}\n\\acro{ASL}{Autonomous Systems Lab at Stanford University}\n\\acro{NLP}{Non-Linear Program}\n\\acro{IPOPT}{Interior Point Optimiser \\cite{Wachter2006}}\n\\acro{GuSTO}{Guaranteed Sequential Trajectory optimization \\cite{Bonalli2019}}\n\\acro{SQP}{Sequential Quadratic Programs}\n\\acro{IPM}{Interior Point Methods}\n\\acro{GMM}{Gaussian Mixture Model}\n\\acro{PDF}{Probability Density Function}\n\\acro{ELBO}{Evidence-based Lower Bound}\n\\acro{ORCA}{Optimal Reciprocal Collision Avoidance}\n\\acro{RRT}{Rapidly-exploring Random Trees}\n\\acro{MCTS}{Monte-Carlo Tree Search}\n\\acro{SGAN}{Socially Generative Adversarial Network}\n\\acro{HJR}{Hamilton-Jacobi Reachability}\n\\acro{ODE}{Ordinary Differential Equation}\n\\acro{PP}{Probabilistic Programming}\n\\acro{IRL}{Inverse Reinforcement Learning} \n\\acro{LSTM}{Long Short-Term Memory}\n\\acro{GAN}{Generative Adversarial Network}\n\\acro{VAE}{Variational Auto-Encoder}\n\\acro{POMDP}{Partial Observable Markov Decision Process}\n\\acro{GFW}{Goal Focussed Warm-Start}\n\\acro{SCW}{Safety Concerned Warm-Start}\n\\acro{PCBW}{Pre-Computation-Based Warm-Start}\n\\acro{SPMW}{Simplified-Prediction-Model Warm-Start}\n\\acro{RCE}{Robot Control Effort}\n\\acro{MSD}{Minimal Separation Distance}\n\\acro{RTD}{Robot Trajectory Directness}\n\\acro{ETT}{Extra Travel Time}\n\\acro{MPE}{Mean Pedestrian Effort}\n\\acro{TGD}{Terminal Goal Distance}\n\\acro{MSI}{Mean Solving Iterations}\n\\acro{M95OD}{Mean 95 \\% Objective Decay}\n\\acro{MSR}{Mean Solving Runtime}\n\\end{acronym}\n", "meta": {"hexsha": "48f6c9ba65898b4b0a4424677e790847575a9324", "size": 4578, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/nomenclature.tex", "max_stars_repo_name": "simon-schaefer/mantrap", "max_stars_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-05-11T18:13:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:52:48.000Z", "max_issues_repo_path": "report/thesis/nomenclature.tex", "max_issues_repo_name": "StanfordASL/mantrap", "max_issues_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/nomenclature.tex", "max_forks_repo_name": "StanfordASL/mantrap", "max_forks_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-12-09T00:03:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T10:39:03.000Z", "avg_line_length": 43.1886792453, "max_line_length": 88, "alphanum_fraction": 0.6889471385, "num_tokens": 1622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4240079142985897}}
{"text": "\\chapter{Introduction}\nBeamDyn is a time-domain structural-dynamics module for slender structures created by the National Renewable Energy Laboratory (NREL) through support from the U.S.\\ Department of Energy Wind and Water Power Program and the NREL Laboratory Directed Research and Development (LDRD) program through the grant ``High-Fidelity Computational Modeling of Wind-Turbine Structural Dynamics'', see References~\\cite{Wang:SFE2013, Wang:GEBT2013,Wang:GEBT2014,Wang:2015}. The module has been coupled into the FAST aero-hydro-servo-elastic wind turbine multi-physics engineering tool where it used to model blade structural dynamics. \n%BeamDyn is designed to analyze beams that are made of composite materials, allowing for initial curvature and twist, and subject to large displacement and rotation deformations. BeamDyn can also be used for static analysis of beams.\nThe BeamDyn module follows the requirements of the FAST modularization framework, see References~\\cite{Jonkman:2013}; \\cite{Sprague:2013,Sprague:2014,website:FASTModularizationFramework}, couples to FAST version 8, and provides new capabilities for modeling initially curved and twisted composite wind turbine blades undergoing large deformation. \nBeamDyn can also be driven as a stand-alone code to compute the static and dynamic responses of slender structures (blades or otherwise) under prescribed boundary and applied loading conditions uncoupled from FAST.\n\nThe model underlying BeamDyn is the geometrically exact beam theory (GEBT) \\cite{HodgesBeamBook}.   \nGEBT supports full geometric nonlinearity and large deflection, with bending, torsion, shear, and extensional degree-of-freedom (DOFs); anisotropic composite material couplings (using full $6 \\times 6$ mass and stiffness matrices, including bend-twist coupling); and a reference axis that permits blades that are not straight (supporting built-in curve, sweep, and sectional offsets). \nThe GEBT beam equations are discretized in space with Legendre spectral finite elements (LSFEs).  \nLFSEs are {\\it p}-type elements that combine the accuracy of global spectral methods with the geometric modeling flexibility of the {\\it h}-type finite elements (FEs) \\cite{Patera:1984}. \nFor smooth solutions, LSFEs have exponential convergence rates compared to low-order elements that have algebraic convergence \\cite{Sprague:2003,Wang:SFE2013} .\nTwo spatial numerical integration schemes are implemented for the finite element inner products: reduced Gauss quadrature and trapezoidal-rule integration.  \nTrapezoidal-rule integration is appropriate when a large number of sectional properties are specified along the beam axis, for example, in a long wind turbine blade with material properties that vary dramatically over the length.  \nTime integration of the BeamDyn equations of motion is achieved through the implicit generalized-$\\alpha$ solver, with user-specified numerical damping.\nThe combined GEBT-LSFE  approach permits users to model a long, flexible, composite wind turbine blade with a single high-order element.  \nGiven the theoretical foundation and powerful numerical tools introduced above, BeamDyn can solve the complicated nonlinear composite beam problem in an efficient manner. For example, it was recently shown that a grid-independent dynamic solution of a 50-m composite wind turbine blade and with dozens of cross-section stations could be achieved with a \nsingle $7^{th}$-order LSFE \\cite{Wang:2016}.\n\nWhen coupled with FAST, loads and responses are transferred between BeamDyn, ElastoDyn, ServoDyn, and AeroDyn via the FAST driver program (glue code) to enable aero-elasto-servo interaction at each coupling time step. \nThere is a separate instance of BeamDyn for each blade. \nAt the root node, the inputs to BeamDyn are the six displacements (three translations and three rotations), six velocities, and six accelerations; the root node outputs from BeamDyn are the six reaction loads (three translational forces and three moments). \nBeamDyn also outputs the blade displacements, velocities, and accelerations along the beam length, which are used by AeroDyn to calculate the local aerodynamic loads (distributed along the length) that are used as inputs for BeamDyn. \nIn addition, BeamDyn can calculate member internal reaction loads, as requested by the user. \nPlease refers to Figure~\\ref{fig:FlowChart} for the coupled interactions between BeamDyn and other modules in FAST. When coupled to FAST, BeamDyn replaces the more simplified blade structural model of ElastoDyn that is still available as an option, but is only applicable to straight isotropic blades dominated by bending. \nWhen uncoupled from FAST, the root motion (boundary condition) and applied loads are specified via a stand-alone BeamDyn driver code.\n\\begin{figure}\n    \\centering\n    \\includegraphics[width = \\textwidth,angle = 0]{\\directory FlowChart.jpg}\n    \\caption{Coupled interaction between BeamDyn and FAST}\n    \\label{fig:FlowChart}\n\\end{figure}\n\nThe BeamDyn input file defines the blade geometry; cross-sectional material mass, stiffness, and damping properties; FE resolution; and other simulation- and output-control parameters. \nThe blade geometry is defined through a curvilinear blade reference axis by a series of key points in three-dimensional (3D) space along with the initial twist angles at these points. \nEach \\textit{member} contains at least three key points for the cubic spline fit implemented in BeamDyn; each member is discretized with a single LSFE with a parameter defining the order of the element. \nNote that the number of key points defining the member and the order ($N$) of the LSFE are independent.\nLSFE nodes, which are located at the $N+1$ Gauss-Legendre-Lobatto points, are not evenly spaced along the element; node locations are generated by the module based on the mesh information. \nBlade properties are specified in a non-dimensional coordinate ranging from 0.0 to 1.0 along the blade reference axis and are linearly interpolated between two stations if needed by the spatial integration method. \nThe BeamDyn applied loads can be either distributed loads specified at quadrature points,  concentrated loads specified at FE nodes, or a combination of the two.  When BeamDyn is coupled to FAST, the blade analysis node discretization may be independent between BeamDyn and AeroDyn.  \n\nThis document is organized as follows. Section~\\ref{sec:Run} details how to obtain the BeamDyn and FAST software archives and run either the stand-alone version of BeamDyn or BeamDyn coupled to FAST. Section~\\ref{sec:InputFiles} describes the BeamDyn input files. Section~\\ref{sec:OutputFiles} discusses the output files generated by BeamDyn. Section~\\ref{sec:Theory} summarizes the BeamDyn theory. Section~\\ref{sec:FutureWork} outlines potential future work. Example input files are shown in Appendix~\\ref{sec:AppDriver}, \\ref{sec:AppPrimary}, and  \\ref{sec:AppBlade}. A summary of available output channels is found in Appendix~\\ref{sec:AppOutputChannel}.\n", "meta": {"hexsha": "427bbfb981671e063c62c4d2f32bd51d70bacb05", "size": 7014, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Manual/files/Introduction.tex", "max_stars_repo_name": "NWTC/BeamDyn", "max_stars_repo_head_hexsha": "0820e102e69d16ba91221ef8c72a2351fd916190", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-10-11T13:19:21.000Z", "max_stars_repo_stars_event_max_datetime": "2017-07-10T07:53:28.000Z", "max_issues_repo_path": "docs/Manual/files/Introduction.tex", "max_issues_repo_name": "NWTC/BeamDyn", "max_issues_repo_head_hexsha": "0820e102e69d16ba91221ef8c72a2351fd916190", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/Manual/files/Introduction.tex", "max_forks_repo_name": "NWTC/BeamDyn", "max_forks_repo_head_hexsha": "0820e102e69d16ba91221ef8c72a2351fd916190", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-05-06T02:49:10.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-06T02:49:10.000Z", "avg_line_length": 167.0, "max_line_length": 657, "alphanum_fraction": 0.8128029655, "num_tokens": 1519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4240079071065458}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\setlength{\\textheight}{9in}\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\evensidemargin}{0in}\n\\setlength{\\topmargin}{-.5in}\n\\begin{document}\n\\begmath 8.1  Find a Zero of a Univariate Function\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math\n  \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nFind a zero of a univariate function, $f(x).$\n\n\\subsection{Usage}\n\nThis subroutine uses reverse communication, $i.e.$, it returns to the\ncalling program each time it needs to have $f()$ evaluated at a new value of\n$x.$\n\n\\subsubsection{Program Prototype, Single Precision}\n\\begin{description}\n\\item[REAL] \\ {\\bf X1, F1, X2, F2, TOL}\n\\item[INTEGER] \\ {\\bf MODE}\n\\end{description}\nAssign values to X1, X2, and TOL.\n\\begin{tabbing}\n\\hspace{.2in}\\=MODE = 0\\\\\n\\>F2 = The value of $f()$ evaluated at X2.\\\\\n10\\>F1 = The value of $f()$ evaluated at X1.\n\\end{tabbing}\\vspace{-2pt}\n$$\n\\fbox{\\bf CALL SZERO(X1, F1, X2, F2, MODE, TOL)}\n$$\n\\begin{tabbing}\n\\hspace{.2in}IF ( MODE .EQ. 1) go to 10\n\\end{tabbing}\nComputed quantities are returned in MODE, X1, F1, X2, and F2.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\n\\item[X1, F1, X2, F2] \\ [inout] On the initial entry, F1 $= f($X1) and F2\n$= f($X2).  If F1 and F2 are of opposite sign, the zero will be found in\nthe interval spanned by X1 and X2.  If F1$\\times \\text{F2} > 0$, and X2\n$\\neq$ X1 then $|\\text{X2}-\\text{X1}|$ will be used in setting the step\nsize for the initial search.  If X2 = X1 on entry, then one must also have\nF2 = F1, and the search is started as described in Section D.\n\nOn returns with MODE = 1, X1 is a new trial abscissa. The calling program\nmust set F1 $= f($X1) and call SZERO again.\n\nOn return with MODE = 2 or 3, X1 is the abscissa at which $|f()|$ had the\nsmallest value, and F1 $= f($X1). If F1 $\\neq 0$, X2 is the nearest abscissa\nto X1 at which $f()$ was evaluated and found to have the opposite sign from\nF1, and F2 $= f($X2).\n\n\\item[MODE] \\ [inout] Current state of computation. The user must initially set MODE\n= 0, and after that should not change its value, except to control detailed\nprinting as explained in Section D. On each return, MODE will have one of\nthe following values:\n\\begin{itemize}\n\\item[$= 1$] The calling program is to compute F1 $= f($X1) and call SZERO again.\n\n\\item[$= 2$] Normal termination. Error tolerance criterion is satisfied.\n\n\\item[$= 3$] Normal termination. Error tolerance criterion is not satisfied.\n\n\\item[$= 4$] Apparently $f$ has a discontinuity between X1 and X2. No zero has been\nidentified.\n\n\\item[$= 5$] Set when F1$\\times \\text{F2} > 0$, and SZERO was unable to find function\nvalues with different signs.\n\n\\item[$= 6$] SZERO was called with MODE $> 1$, or called initially with MODE $> 0$.\nThis causes execution to stop.\n\\end{itemize}\n\\item[TOL] \\ [in] Error tolerance.\n\\begin{itemize}\n\\item[$>0$] the zero is to be isolated to an interval of length less than TOL.\n\n\\item[$<0$] an $x$ is desired for which $|f(x)|%\n\\leq |\\text{TOL}|.$\n\n\\item[$=0$] the iteration continues until the zero of $f()$ is isolated as\naccurately as possible. In this case SZERO will never set MODE $= 3.$\n\\end{itemize}\n\\end{description}\n\n\\subsubsection{Modifications for Double Precision}\n\nFor double-precision usage change the name SZERO to DZERO, and change the\nREAL declaration to DOUBLE PRECISION.\n\n\\subsection{Examples and Remarks}\n\nThe program DRSZERO illustrates the use of SZERO to compute the root of the\nfunction, $f(x) = 2^x - 8$, for which the exact answer is $x =\n3$. Output is shown in ODSZERO.\n\n\\subsection{Functional Description}\n\nWhen F1$\\times \\text{F2} > 0$ at the initial point, iterates are generated\naccording to the formula $x = x_{\\min } + (x_{\\min } - x_{\\max }) \\times\n\\rho$, where the subscript ``min\" is associated with the $(x, f)$ pair\nthat has the smallest value for $|f|$, and $\\rho $ is 8 if $r = f_{\\min\n}\\:/\\:(f_{\\max } - f_{\\min }) \\geq 8$, else $\\rho = \\max (\\kappa /4, r)$,\nwhere $\\kappa $ is a count of the number of iterations that have been\ntaken without finding $f$'s with opposite signs.  If X1 and X2 have the\nsame value initially (and F1 and F2 equal F(X1)), then the next $x$ is a\ndistance $0.008 + |x_{\\min }|/4$ from $x_{\\min }$ taken toward~0.  (If\nX1 = X2 = 0, the next $x$ is $-$.008.)\n\nLet $x_1$ and $x_2$ denote the first two $x$ values that give $f$ values\nwith different signs. Let $A < B$ be the two values of $x$ that bracket the\nzero as tightly as is known. Thus $A = x_1$ or $A = x_2$ and $B$ is the\nother when computing $x_3$. The next point $x_3$ is generated treating $x$\nas the linear function $q(f)$ that interpolates the points $(f(x_1)$, $x_1)$\nand $(f(x_2)$, $x_2)$, and computing $x_3 = q(0)$, subject to the condition\nthat $A+\\varepsilon  \\leq x_3 \\leq B-\\varepsilon $,\nwhere $\\varepsilon  = 0.875$ times the accuracy to which the root has been\nrequested. (This condition on $x_3$ with updated values for $A$ and $B$\nis also applied to future iterates.)\n\nLet $x_4$, $x_5$, ..., $x_m$ denote the abscissae on the following\niterations. Let $a = x_m$, $b = x_{m-1}$, and $c = x_{m%\n-2}$. Either $A$ or $B$ (defined as above) will coincide with $a$,\nand $B$ will frequently coincide with either $b$ or $c$. Let $p(x)$ be the\nquadratic polynomial in $x$ that passes through the values of $f$ evaluated\nat $a$, $b$, and $c$. Let $q(f)$ be the quadratic polynomial in $f$ that\npasses through the points $(f(a), a)$, $(f(b), b)$, and $(f(c), c).$\n\nLet $C$ = $A$ or $B$, selected so that $C \\neq a$. If the sign of $f$ has\nchanged in the last 4~iterations and $p^{\\prime}(a)\\times q^{\\prime}(f(a))$\nand $p^{\\prime}(C)\\times q^{\\prime}(f(C))$ are both in the interval $[1/4$,\n4], then $x$ is set to $q(0)$. (Note that if $p$ is replaced by $f$ and $q$\nis replaced by $x$, then both products have the value~1.) Otherwise $x$ is\nset to $a - (a - C)(\\varphi /(1+\\varphi ))$, where $%\n\\varphi $ is selected based on past behavior and on the ratio of $f(a)$ with\nvalues of $f()$ having the same sign as $f(a)$, and different sign from $f(a)\n$, evaluated at nearby values of $x$. The method of selecting $\\varphi $ is\nsufficiently complicated that we simply refer interested readers to the\ncode. The algorithm is such that $0 < \\varphi $, and if the sign of $f()$ does\nnot change for an extended period, $\\varphi $ gets large.\n\nReference \\cite{Alefeld:1995:AEZ} compares a number of algorithms for\nfinding a zero of a continuous function.  Dr.\\ Shi has kindly used the\nsame test program, ENCL0FX, on DZERO.  With Dr.\\ Shi's permission, results\nfrom Table II of that paper are given on the next page with an additional\ncolumn added for the results he obtained with DZERO.  With the exception\nof DE and M, all codes solved all of the problems.  See \\refm{1} for more\ndetails.\n\n\\subparagraph{Detailed printing}\n\nBefore the initial call with MODE $= 0$, or at any time during the\niterative process, the user may set a counter for detailed output by\ncalling SZERO with a negative value of MODE.  There is no problem-solving\naction on such a call.  A saved counter is set so detailed output will be\nwritten using the message processor described in Chapter~19.3 on the next\n$|$MODE$|-1$ normal calls.  To resume normal computation with the detailed\nprint on, the calling program must set MODE $= 0$ if a new problem\nsequence is being started or MODE\\ $= 1$ if an iterative sequence is being\ncontinued.  (Detailed print can be turned off by setting MODE $= -1$ as is\nimplied by the above.)\n\nThe detailed output consists of X1, F1, KTYP, DIV, and KS. KTYP is 0 if $\\varphi $\nabove was used on the previous iteration, and KTYP is 1 if $x$ was set to $%\nq(0)$. DIV is the name of the program variable corresponding to $\\varphi $, and\nKS is the number of iterations since there has been a change in the sign of $%\nf().$\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nThe user must initially set MODE $= 0$ and must not alter MODE after that\nwhile iterating on the same problem (except as described in Section D for\ndetailed output.) Entering SZERO with MODE $> 0$ when SZERO has not set MODE\nto~1 results in an error condition and an error message will be issued using\nthe system error handler SMESS (or DMESS). In such a case, if MODE $\\neq 6$,\nSZERO will set MODE $= 6$ and return, whereas if MODE $= 6$, SZERO will STOP.\n\nSZERO uses the Fortran~77 SAVE statement to save values of internal\nvariables between the successive calls needed to solve a problem. Thus SZERO\ncannot be used to work on more than one problem at a time. In particular,\ncalling SZERO with MODE $= 0$ will always initialize it for a new problem\nand no data will be retained from a previous problem (except for the\ninternal detailed print counter described in Section D.)\n\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDZERO & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, DMESS, DZERO, MESS\\rule[-5pt]{0pt}{8pt}}\\\\\nSZERO & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nAMACH, MESS, SMESS, SZERO}\\\\\n\\end{tabular}\n\nAlgorithm and code due to F. T. Krogh, JPL, April~1972. Revised to improve\nportability, April~1974. Name changed from SFABZ/DFABZ to SZERO/DZERO,\nand minor improvements to the algorithm, September~1987.\n\nRevised to allow F1$\\times \\text{F2} > 0$ on initial entry, and to change error\nhandling, November~1991.\n\n\n\\begcodenp\n\n\\begin{center}\n\n\\begin{tabular}{crrrrrrrrrrrrr}\n\\multicolumn{14}{c}{Total Number of Function Evaluations in\nSolving All the Problems Listed in Table I of\n\\refm{1}\\rule[-5pt]{0pt}{10pt}} \\\\\n{\\em tol} &\n\\multicolumn{1}{c}{BR} &\n\n\\multicolumn{1}{c}{DE} &\n\\multicolumn{1}{c}{M} &\n\\multicolumn{1}{c}{R} &\n\\multicolumn{1}{c}{LE} &\n\\multicolumn{1}{c}{2.1} &\n\\multicolumn{1}{c}{2.2} &\n\\multicolumn{1}{c}{2.3} &\n\\multicolumn{1}{c}{2.4} &\n\\multicolumn{1}{c}{2.5} &\n\\multicolumn{1}{c}{4.1} &\n\\multicolumn{1}{c}{4.2} &\n\\multicolumn{1}{c}{DZERO}\\\\\n$10^{-7}$   & 2804 & 2808 & 2839 & 7630 & 2694 & 3154 & 2950 &\n2645 & 2791 & 2687 & 2696 & 2650 & 2100 \\\\\n$10^{-10}$  & 2905 & 2963 & 2992 & 7768 & 2821 & 3338 & 3060 &\n2789 & 2922 & 2819 & 2835 & 2786 & 2177 \\\\\n$10^{-15}$  & 2975 & 3196 & 3261 & 8014 & 3061 & 3448 & 3151 &\n2948 & 3015 & 2914 & 2908 & 2859 & 2236 \\\\\n0           & 3008 & 2998 & 3146 & 8230 & 3165 & 3509 & 3219 &\n3029 & 3060 & 2954 & 2950 & 2884 & 2255\n\\end{tabular}\\\\[.5in]\n\\end{center}\n\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSZERO}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{szero}}\n\n\\vspace{30pt}\\centerline{\\bf \\large ODSZERO}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{szero}}\n\\end{document}\n\n", "meta": {"hexsha": "4a04469e32e539688bfc01b9e8afd9c9dcbb7a3e", "size": 10891, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch08-01.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch08-01.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch08-01.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 41.5687022901, "max_line_length": 85, "alphanum_fraction": 0.7026902947, "num_tokens": 3612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.4240079035105238}}
{"text": "%!TEX root = forallx-ubc.tex\n\\chapter{Soundness and Completeness for SL Trees}\n\\label{ch.SLsoundcomplete}\n\nIn Chapter \\ref{ch.sl.trees} we introduced a proof system for SL. Trees provide a method for answering the question of whether a given set of SL sentences is jointly satisfiable. Our focus last chapter was on \\emph{using} trees to answer those questions; this chapter we turn to the study of the proof system itself. This chapter engages in a project of \\emph{metalogic}. In particular, we aim to first precisify, then answer, this question: is the tree method a good method?\n\nIt might not be obvious at first that there is even a genuine question here. The tree method is a formal method, with precisely defined rules. You might be tempted to think that, \\emph{by definition}, following the rules makes it a good method. There is one sense in which that is right --- the rules laid out last chapter \\emph{tell you} to follow the rules laid out last chapter, so following the rules is doing what the system tells you to do. But there is also a deeper question to be asked. The rules were not selected at random. They were designed to do something in particular: namely, to tell whether a set of sentences is satisfiable. This isn't a question about trees. (Note that we were considering this question back in Chapter \\ref{ch.SLmodels}, before we had even introduced the idea of trees.) So there is a question to be asked about whether the tree method actually does what it's supposed to do.\n\nRecall the distinction between our two turnstiles: we use `$\\metaSetX{}\\models{}\\bot$' to mean that no interpretation satisfies \\metaSetX{}; `$\\metaSetX{}\\vdash{}\\bot$' means that a tree with root \\metaSetX{} closes. We interpret the latter as our proof system \\emph{saying} that nothing satisfies the root. Our question now is, can our proof system be trusted? Is it reliable? The main project of this chapter is to prove in a rigorous way that it can, and is.\n\n\\section{Informal proof}\n\nIn Chapter \\ref{ch.sl.trees} we learned a formal proof system. This chapter, we will prove important results \\emph{about} that system. It is important to emphasize, however, that the formal proof system isn't the only way to `prove' things. In particular, the tree method is \\emph{not} an appropriate methodology for the task of this chapter. When we say we wish to prove that the tree method is good, we don't mean that we will put the negation of that claim --- i.e., that the tree method is not good --- in the root of a tree. That would get us nowhere.\n\nInstead, we will be engaging in an \\emph{informal} proof \\emph{about} the formal system. An informal proof needn't be any less conclusive or compelling than a formal proof is, but evaluating it makes use of our general ability to recognize what follows from what, rather than working through a list of syntactically-defined rules.\n\n\\section{Soundness}\n\nIf a tree with root \\metaSetX{} closes, we interpret that as the system telling us that \\metaSetX{} is unsatisfiable. If our system is a good one, then a tree will never mislead us in this respect. Tree closure should guarantee unsatisfiability. We call this property \\define{soundness}. The soundness of our SL tree system is the first important metalogical theorem we will prove in this chapter. (A `metalogical' theorem is a theorem \\emph{about} logic.)\n\n\\label{definesound}\n\\factoidbox{\n\\define{soundness}: If a tree closes, that guarantees that its root is unsatisfiable. In other words: $$\\metaSetX{}\\vdash{}\\bot\\Rightarrow\\metaSetX{}\\models\\bot{}$$\n}\n\nHere is a way to illustrate that soundness is a substantive result, and to clarify what it is we're trying to prove. Recall the resolution rule for disjunction (see p.\\ \\pageref{subsec.DisjunctionTreeRule}):\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eor\\metaB{}\n\t[\\metaA{}]\n\t[\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nLet's suppose for the purpose of argument that we had a different disjunction rule instead of this one. Suppose, for example, that our rule for disjunction had been this:\n\\label{unsoundrule}\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eor\\metaB{}\n\t[\\metaA{}\n\t[\\metaB{}, grouped]]\n]\n\\end{prooftree}\n\\end{center}\n\nIf this had been our disjunction rule, and all the other rules remained the same, our tree system would have been unsound. It would have been possible for satisfiable roots to result in closed trees. That is to say, there would have been possible sets of sentences \\metaSetX{} such that $\\metaSetX{}\\vdash{}\\bot$, even though $\\metaSetX{}\\not\\models{}\\bot$. Consider for example these sentences:\n\n\\begin{earg}\n\t\\item[] $P$\n\t\\item[] $\\enot P \\eor Q$\n\\end{earg}\n\nThese sentences are obviously jointly satisfiable, by an interpretation that assigns 1 to $P$ and 1 to $Q$. But if we used the tree system with the alternate disjunction rule above, the tree would close:\n\n\\begin{prooftree}\n{\n}\n[P, name={P1}\n\t[\\enot P \\eor Q, grouped, checked, name={disj}\n\t\t[\\enot P, just={alt.\\eor:disj}\n\t\t\t[Q, grouped, close={:P1, !u}]\n\t\t]\n\t]\n]\t\t\n\\end{prooftree}\n\nThis would be a counterexample to the soundness of the SL tree system. This explains what's wrong with the alternate disjunction rule --- it would allow trees to `prove' that a root is unsatisfiable, even if it really is satisfiable. In considering the soundness of our system, we are investigating whether our actual proof system is defective in the same way this hypothetical modification of the system would have been. We will prove that it is not.\n\n\\section{Recursive proofs}\nOur proof of soundness will be a \\emph{recursive} proof. A recursive proof is a proof that proceeds stepwise: one first demonstrates that the claim to be proven holds for some simple case, and then shows that, \\emph{if} it holds for some case, then it also holds for some other, slightly more complicated case. More ways of complicating cases may also be discussed, each along with the assurance that if the claim holds for a simpler case, then it will also hold for each more complex one. Finally, if one can demonstrate that the ways of complicating cases considered are \\emph{exhaustive} --- that is, if these represent the only possible cases --- then this has been shown for every possible case. You may be familiar with recursive proofs already in the context of \\emph{mathematical induction}. (This is a topic that comes up in many high school algebra classes.)\n\nHere is an example illustrating proof by induction. Suppose that Sir Roderic Murgatroyd has been cursed. The curse is subject to the following rules:\n\n\\begin{enumerate}\n\t\\item The only way for someone to escape the curse is to transfer it to someone else.\n\t\\item There are only three ways to transfer the curse to someone else:\n\t\t\\begin{enumerate}\n\t\t\t\\item One may transfer it to one's parent.\n\t\t\t\\item One may transfer it to one's child.\n\t\t\t\\item One may transfer it to one's sibling.\n\t\t\\end{enumerate}\n\\end{enumerate}\n\nGiven these rules, it's not difficult to see that the Murgatroyd curse will never leave the family. We know that Sir Roderic has the curse. He could transfer it to a parent, a child, or a sibling, but none of those actions would remove the curse from the family, since one's parents, one's children, and one's siblings are all family members. And any of \\emph{those} people, if \\emph{they} had the curse, can only transfer it to someone else within the family. No curse transfer can get the curse outside the family. So someone in the family will remain cursed forever.\n\nSlightly more precisely: we're attempting to prove that the curse will always be in the family. Roderic is in the family. And, for any person, if they are in the family, then they cannot get rid of the curse without transferring it to another member of the family. The proof is perfectly general; it applies to Roderic's great-great-great-grandchildren just as well as it applies to Sir Roderic himself. This is a simple example of a recursive proof. The proof of the soundness of the SL tree method is more complex, but it has the same basic structure.\n\n\\section{Proving soundness}\n\nSoundness is the claim that any time a tree closes, the root must be unsatisfiable. This is equivalent to the claim that any time the root \\emph{is} satisfiable, the tree \\emph{won't} close. (Compare: if every new citizen swears loyalty to the Queen, then everyone who \\emph{doesn't} swear loyalty to the Queen must \\emph{not} be a new citizen.) So to prove soundness, we can assume that the root is satisfiable, and show that it follows that the tree doesn't close.\n\nSuppose, then, we have some satisfiable set of sentences \\metaSetX{} in the root of a tree. If the root is satisfiable, then there is some interpretation that satisfies it. (Recall that an interpretation in SL is an assignment of truth values to atomic sentences.) Call this interpretation $\\mathcal{I}$. We will begin by proving that, if our tree follows the rules given in Chapter \\ref{ch.sl.trees}, then $\\mathcal{I}$ doesn't just satisfy the root --- it satisfies every sentence in some branch of the completed tree. Once we establish that claim, it's only a short step to demonstrate that this branch doesn't close. Branches only close when they contain some formula and its negation. But no interpretation can satisfy a formula and its negation; so if $\\mathcal{I}$ satisfies every formula in the branch, that means that branch must not contain any formula along with its negation. So the tree will remain open.\n\nThis is the broad structure of our proof. The key step is in proving that $\\mathcal{I}$ has the property mentioned above --- that it satisfies every sentence in an open branch. We will prove this recursively.\n\n\\subsection{Root}\n\nStart with the root, \\metaSetX{}. This is trivial. We are \\emph{assuming} that our tree begins with a satisfiable root, because we are trying to prove what follows from that assumption. (Namely, that the tree won't close.) $\\mathcal{I}$ is just our name for one of the interpretations we are assuming must exist. So $\\mathcal{I}$ satisfies everything in the root. This is a reasonable thing to assume, when proving soundness, because soundness only tells us what happens when the root is satisfiable: namely, that the tree won't close. Soundness doesn't say anything about what happens if the root is unsatisfiable.\n\nWe want our proof to be perfectly general, so we don't want to make any particular assumptions about what the tree does beyond the root. But, given the resolution rules outlined in \\S\\ref{sec.SLtreerules}, there are only nine possible ways the tree might develop at each step. (Compare the three possible ways the curse might move in the Murgatroyd example.) We will prove, for each of these nine resolution rules, the following: if $\\mathcal{I}$ satisfies all the sentences in the branch \\emph{above}, then $\\mathcal{I}$ also satisfies at least one branch of what comes \\emph{below}. In other words, we'll prove, for each inference rule, that that rule cannot take you from a satisfiable branch to a tree with no satisfiable branches.\n\n\\subsection{Conjunction}\n\\label{sec.sl.soundnessproof.begin}\nSuppose that a tree develops via the conjunction rule: \n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\n}\n[\\metaA{}\\eand\\metaB{}\n\t[\\metaA{}\n\t[\\metaB{}, grouped\n\t]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nWe assume that $\\mathcal{I}$ satisfies the branch above the development. So in particular, $\\mathcal{I}$ must satisfy \\metaA{}\\eand\\metaB{}. We may write this as $$\\mathcal{I}(\\metaA{}\\eand\\metaB{})=1$$ We know from the definition of truth in SL that any interpretation that assigns 1 to a conjunction must assign 1 to each conjunct. (See page \\pageref{truthdefinition}.) So: $$\\mathcal{I}(\\metaA{})=1$$ $$\\mathcal{I}(\\metaB{})=1$$\n\nWhat we've just shown is that, if $\\mathcal{I}$ satisfies the branch above this development, then it also satisfies everything in the new development. The conjunction rule will never take us from a satisfiable branch to an unsatisfiable one. We need to prove that \\emph{every} possible way of developing the tree is like that.\n\n\\subsection{Negated conjunction}\n\nNegated conjunctions develop in our system with a branching rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\enot(\\metaA{}\\eand\\metaB{})\n\t[\\enot\\metaA{}]\n\t[\\enot\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nOnce again, we are assuming for the purpose of argument that our interpretation $\\mathcal{I}$ satisfies everything up until this development. So $\\mathcal{I}(\\enot(\\metaA{}\\eand\\metaB{}))=1$. Since $\\mathcal{I}$ satisfies that negation, $\\mathcal{I}(\\metaA{}\\eand\\metaB{})=0$. Given our definition of truth in SL, any interpretation that assigns 0 to this conjunction must assign 0 to at least one of its conjuncts. So \\emph{either} $\\mathcal{I}(\\metaA{})=0$ \\emph{or} $\\mathcal{I}(\\metaB{})=0$. (It might assign 0 to both, but what we know for sure is that it assigns 0 to at least one.) If $\\mathcal{I}(\\metaA{})=0$, then $\\mathcal{I}(\\enot\\metaA{})=1$, and so the new left branch is satisfied. If $\\mathcal{I}(\\metaB{})=0$, then $\\mathcal{I}(\\enot\\metaB{})=1$, and so the new right branch is satisfied. Since (at least) one of these must be the case, we know that $\\mathcal{I}$ satisfies at least one branch of our extended tree, assuming it satisfied that which came before the extension. So the negated conjunction rule will never take us from a satisfiable branch to an unsatisfiable one.\n\n\\subsection{Disjunction}\n\nDisjunctions branch according to this rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering}\n[\\metaA{}\\eor\\metaB{}\n\t[\\metaA{}]\n\t[\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nAssume $\\mathcal{I}(\\metaA{}\\eor\\metaB{})=1$. Then either $\\mathcal{I}(\\metaA{})=1$ or $\\mathcal{I}(\\metaB{})=1$. If $\\mathcal{I}(\\metaA{})=1$, then $\\mathcal{I}$ satisfies the left branch. If $\\mathcal{I}(\\metaB{})=1$, then $\\mathcal{I}$ satisfies the right branch. So, assuming that $\\mathcal{I}$ satisfies the sentences above this resolution rule, it must satisfy at least one branch below it. So the disjunction rule will never take us from a satisfiable branch to an unsatisfiable one.\n\nHopefully the pattern is becoming clear by now. We've proven, for three of our nine rules, that they cannot take us from a satisfiable branch to an unsatisfiable one. Six resolution rules remain to be considered.\n\nConsider again the variant disjunction rule hypothesized above:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering}\n[\\metaA{}\\eor\\metaB{}\n\t[\\metaA{}\n\t[\\metaB{}, grouped]]\n]\n\\end{prooftree}\n\\end{center}\n\nIf we attempted to go through the same reasoning we've been going through, we'd fail. Assume $\\mathcal{I}(\\metaA{}\\eor\\metaB{})=1$. By the definition of truth in SL, we know that $\\mathcal{I}$ assigns 1 to at least one of \\metaA{} and \\metaB{}, but there is no guarantee that it will satisfy \\emph{both}. So we have no assurance that, if one follows this rule, $\\mathcal{I}$ will satisfy the development of the tree, even if we assume it satisfies the sentences above. We cannot prove that the use of this rule will never lead to an inappropriate tree closure. \\label{soundprooffailure}\n\n\\subsection{Negated Disjunction}\n\nHere is the rule for negated disjunctions:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\enot(\\metaA{}\\eor\\metaB{})\n\t[\\enot\\metaA{}\n\t[\\enot\\metaB{}, grouped\n\t]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nSuppose that $\\mathcal{I}(\\enot(\\metaA{}\\eor\\metaB{}))=1$. Given the definition of negation, this means that $\\mathcal{I}(\\metaA{}\\eor\\metaB{})=0$. This in turn means, given the definition of disjunction, that $\\mathcal{I}$ must assign 0 to both \\metaA{} and \\metaB{}. And so of course, given the definition of negation again, we know that $\\mathcal{I}$ assigns 1 to \\enot\\metaA{}, and also assigns 1 to \\enot\\metaB{}. Therefore, if we began with a satisfiable tree branch, invoking this rule, like the other good rules we've considered, will preserve satisfiability; the negated disjunction rule will never take one from a satisfiable branch to an unsatisfiable one.\n\n\\subsection{Conditional}\n\nThe conditional rule is:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eif\\metaB{}\n\t[\\enot\\metaA{}]\n\t[\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nAs before, assume that the material above the branch is satisfiable; so some interpretation $\\mathcal{I}$ satisfies it. Any interpretation that satisfies a conditional must assign 0 to the antecedent, or 1 to the consequent (or both). If $\\mathcal{I}$ assigns 0 to the antecedent, then it satisfies the left development of the tree. If $\\mathcal{I}$ assigns 1 to the consequent, then it satisfies the right development of the tree. So, given that it satisfies the conditional, $\\mathcal{I}$ is guaranteed to satisfy at least one branch of the tree as developed by the conditional rule.\n\n\\subsection{Negated Conditional}\n\nThe rule given in Chapter \\ref{ch.sl.trees} for negated conditionals was this:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\enot(\\metaA{}\\eif\\metaB{})\n\t[\\metaA{}\n\t[\\enot\\metaB{}, grouped\n\t]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nI hope the procedure is feeling a bit tedious by now. As before, we assume that the negated conditional is satisfiable, and prove that the tree as developed by this rule will remain satisfiable. Since we're assuming that \\enot(\\metaA{}\\eif\\metaB{}) is satisfiable, it follows that some interpretation $\\mathcal{I}$ satisfies it. But $\\mathcal{I}(\\enot(\\metaA{}\\eif\\metaB{}))$ only if $\\mathcal{I}(\\metaA{})=1$ and $\\mathcal{I}(\\metaB{})=0$. So $\\mathcal{I}$ will satisfy \\metaA{} and \\enot\\metaB{}. That is to say, it will satisfy the continuation of the branch given this rule. The negated conditional rule can never take one from a satisfiable root to an unsatisfiable tree.\n\nWe have three more rules to consider.\n\n\\subsection{Biconditional}\n\nHere is the biconditional rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eiff\\metaB{}\n\t[\\metaA{}\n\t\t[\\metaB{}, grouped]\n\t]\n\t[\\enot\\metaA{}\n\t\t[\\enot\\metaB{}, grouped]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nAssuming that $\\mathcal{I}$ satisfies \\metaA{}\\eiff\\metaB{}, it must either assign 1 to both \\metaA{} and \\metaB{}, or it must assign 0 to both \\metaA{} and \\metaB{}. If the former, $\\mathcal{I}$ will satisfy the left branch of the new development from this rule. If the latter, it will satisfy the right branch, since any interpretation that assigns 0 to a sentence must assign 1 to its negation. So this rule too can never take one from a satisfiable root to an unsatisfiable tree.\n\n\\subsection{Negated biconditional}\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\enot(\\metaA{}\\eiff\\metaB{})\n\t[\\metaA{}\n\t\t[\\enot\\metaB{}, grouped]\n\t]\n\t[\\enot\\metaA{}\n\t\t[\\metaB{}, grouped]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nThe reasoning is much as before. If our interpretation satisfies the negated biconditional, then it must assign opposite values to each side; i.e., either $\\mathcal{I}(\\metaA{})=1$ and $\\mathcal{I}(\\metaB{})=0$, or $\\mathcal{I}(\\metaA{})=0$ and $\\mathcal{I}(\\metaB{})=1$. If the former, $\\mathcal{I}$ satisfies the left branch; if the latter, $\\mathcal{I}$ satisfies the right branch. So if the negated biconditional is satisfiable, this rule will never result in an unsatisfiable tree.\n\n\\subsection{Double negation}\n\nHere is our final tree resolution rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering, single branches}\n[\\enot\\enot\\metaA{}\n\t[\\metaA{}]\n]\n\\end{prooftree}\n\\end{center}\n\nOne last time, we assume that we begin with something satisfiable; so we allow that some interpretation $\\mathcal{I}$ assigns 1 to \\enot\\enot\\metaA{}. If it assigns 1 to this negation, then it must assign 0 to its negand, \\enot\\metaA{}. That is to say, $\\mathcal{I}(\\enot\\metaA{})=0$. And since it assigns 0 to \\emph{this} negation, it must assign 1 to \\emph{its} negand: $\\mathcal{I}(\\metaA{})=1$. But this just is the new branch development. So if we began with something satisfiable, this rule will result in \nsomething satisfiable.\n\\label{sec.sl.soundnessproof.end}\n\\subsection{Taking stock}\n\nWe've shown, for the nine resolution rules in our tree system, that they each have the following important feature: if you begin with a satisfiable set of sentences, applying the rule will always result in at least one continuation of the tree that is also satisfiable. And since these nine rules are the only ways one can develop a tree, we've proven that there is no possible way, consistent with the tree rules, for a tree with a satisfiable root to develop into a tree with no satisfiable branches.\n\nBranches can only be closed if they contain a sentence and its negation, which a satisfiable branch will never have. So, assuming we started with a satisfiable root, the rules will never result in a tree with all branches closed. Satisfiable roots will always result in open trees. The tree method will never erroneously ``prove\" that a root is unsatisfiable. Equivalently, tree closure guarantees unsatisfiability of the root. The tree method is sound.\n\n\\factoidbox{\n\\define{soundness}: If a tree closes, that guarantees that its root is unsatisfiable. In other words: $$\\metaSetX{}\\vdash{}\\bot\\Rightarrow\\metaSetX{}\\models{}\\bot$$\n}\n\n\\section{Completeness}\n\nSoundness is the first of two important metalogical theorems considered in this chapter. The second is \\define{completeness}. One can think of soundness as a guarantee against a system proving \\emph{too much}; in proving soundness, we were assuring ourselves that a tree would close \\emph{only if} the root was unsatisfiable. Completeness, as the name suggests, concerns whether our system proves \\emph{enough}. We want our system to be sure to close, if the root is unsatisfiable. Remember, we take open branches in completed trees as an indication that the root is satisfiable. Completeness is about ensuring that this is a warranted conclusion.\n\n\\label{definecomplete}\n\\factoidbox{\n\\define{completeness}: If a root is unsatisfiable, that guarantees that the tree will close. In other words: $$\\metaSetX{}\\models{}\\bot\\Rightarrow\\metaSetX{}\\vdash{}\\bot$$\n}\n\nConsider the unsatisfiable set of sentences, $\\{\\enot Q, P \\eand Q\\}$. Given our conjunction rule, a tree with this root will close:\n\n\\begin{prooftree}\n{\n}\n[\\enot Q, name={q}\n[P \\eand Q, checked, grouped\n\t[P, just={\\eand: !u}\n\t[Q, grouped, close={:q, !c}\n\t]\n\t]\n]\n]\n\\end{prooftree}\n\nIn proving completeness, we wish to demonstrate that this will always be the case: \\emph{whenever} we begin with an unsatisfiable root, the entire tree will eventually close. Notice that if we had a different conjunction rule that called for a branching development instead of a linear one, completeness would fail. Suppose we had this rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eand\\metaB{}\n\t[\\metaA{}]\n\t[\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nUsing this rule, the tree with root $\\{\\enot Q, P \\eand Q\\}$ would remain open:\n\n\n\n\n\\begin{prooftree}\n{\n}\n[\\enot Q, name={q}\n[P \\eand Q, checked, grouped\n\t[P, just={alt.\\ \\eand: !u}, open\n\t]\n\t[Q, close={:q, !c}\n\t]\n]\n]\n\\end{prooftree}\n\nThe right branch closes, but this tree has a left branch that remains open, even though the root is unsatisfiable. So if we modified our proof system by using this rule instead of the linear rule for conjunction, we would have a system that fails completeness. We wish to prove that, given the actual rules, our system is complete.\n\n\\section{Proving completeness}\n\\label{sec.completenessproof}\nCompleteness is the claim that any time a set of sentences is unsatisfiable, a completed tree with that set as its root will close. This is equivalent to the claim that if a completed tree has a branch that remains open, then the root is satisfiable. To prove completeness, we will assume that a completed tree has a branch that remains open, and prove that, on this assumption, the root is satisfiable. In fact, we will prove something stronger than that: we will prove that \\emph{every} formula in a completed open branch is satisfiable, by demonstrating a recipe for constructing an interpretation that satisfies it. Since the root is part of every branch of the tree, this will suffice for proving completeness.\n\nAs in the case of our soundness proof, we will be giving an \\emph{informal} proof \\emph{about} our formal system.\n\nHere is the broad shape of the proof. Suppose that a completed tree has at least one open branch. Then we can construct an interpretation, $\\mathcal{I}$, based on that branch, as follows: if any atomic sentence \\metaA{} is in the branch, then $\\mathcal{I}(\\metaA{})=1$. If any negated atomic sentence \\enot\\metaB{} is in the branch, then $\\mathcal{I}(\\metaB{})=0$. Let these assignments exhaust $\\mathcal{I}$. We can guarantee that there will be a coherent interpretation like this. This recipe for constructing interpretations will fail only if some atomic sentence \\emph{and} its negation are \\emph{both} in the branch. But if a sentence and a negation are both in the branch, then that branch will close; by hypothesis, we're considering a completed branch that remains open. So we know it contains no explicit contradictions of this kind.\n\nNow we want to prove that $\\mathcal{I}$ satisfies every formula in the branch (including the root). We know it satisfies every atomic formula and every negated atomic formula in the branch, given the way it was constructed. We'll now show that it must satisfy every other formula too. We'll exploit the recursive rules for SL grammaticality: there are only a certain number of ways that sentences can be created from simpler sentences. We'll show, for every sentence form, that if $\\mathcal{I}$ satisfies a branch downstream of a sentence of that form in a completed branch, then it satisfies that sentence too.\n\nWe begin with conjunction.\n\n\\subsection{Conjunction}\n\\label{conjunctionsound}\nSuppose our completed, open branch contains a conjunction of the form \\metaA{}\\eand\\metaB{}. Since it is a \\emph{completed} branch, this means that the conjunction resolution rule must have been applied to this conjunction. (Remember, a branch isn't completed until every complex formula has a check mark next to it.) So, given the conjunction rule,\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering}\n[\\metaA{}\\eand\\metaB{}\n\t[\\metaA{}\n\t[\\metaB{}, grouped\n\t]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nwe know that the branch must also contain \\metaA{} and \\metaB{}. If we assume that $\\mathcal{I}$ satisfies both these sentences, then we know from the definition of the truth of a conjunction in SL that $\\mathcal{I}$ satisfies (\\metaA{}\\eand\\metaB{}) too. In other words, there's no way to satisfy the simpler sentences that come after this resolution rule, without also satisfying the conjunction.\n\n\n\n\\subsection{Negated conjunction}\n\nSuppose a negated conjunction appears in the open branch. Since the branch is complete, you know that the negated conjunction rule has been applied:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\enot(\\metaA{}\\eand\\metaB{})\n\t[\\enot\\metaA{}]\n\t[\\enot\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nWe are assuming that the negated conjunction is in an open branch. This is consistent with either one of the branches below closing, but they cannot both close. If they did, the negated conjunction would not be in an open branch. So we know that at least one branch is open. So either $\\mathcal{I}(\\metaA{})=0$ (if the left branch is our open branch) or $\\mathcal{I}(\\metaB{})=0$ (if the right branch is the open branch). Since at least one of these sentences is assigned 0, their conjunction must also be assigned 0, which means the negated conjunction we're considering is assigned 1. So once again, if the material in at least one branch below the resolution rule is satisfied, then the negated conjunction is satisfied too.\n\n\\subsection{Disjunction}\n\nDisjunctions are very similar to negated conjunctions. Since the tree is complete, any disjunction $\\metaA{}\\eor\\metaB{}$ has a branch below it containing \\metaA{}, and one containing \\metaB{}. Whichever of these disjuncts is in the open branch, $\\mathcal{I}$ satisfies that disjunct, and so satisfies the disjunction too.\n\n\\subsection{Negated disjunction}\n\nNegated disjunctions are similar to conjunctions. If a negated disjunction is in an open branch, then the negation of each disjunct is also in that branch. So, suppose that $\\mathcal{I}$ assigns 0 to each disjunct. Then it also assigns 0 to their disjunction. So once again, if the material below the negated disjunction is satisfied, then so is the negated disjunction itself.\n\n\\subsection{Conditional}\n\nIf a conditional is in a completed open branch, then it has been resolved by this branching rule:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eif\\metaB{}\n\t[\\enot\\metaA{}]\n\t[\\metaB{}]\n]\n\\end{prooftree}\n\\end{center}\n\nIf the left development is the open branch, then we suppose that  $\\mathcal{I}(\\metaA{})=0$, which means that $\\mathcal{I}(\\metaA{}\\eif\\metaB{})=1$. If this right development is the open branch, then we suppose that $\\mathcal{I}(\\metaB{})=1$, which \\emph{also} means that $\\mathcal{I}(\\metaA{}\\eif\\metaB{})=1$. So if the material below in at least one branch is satisfied, then the conditional is satisfied too.\n\n\\subsection{Negated conditional}\n\nIf a negated conditional \\enot(\\metaA{}\\eif\\metaB{}) is in the open branch, then so too are \\metaA{} and \\enot\\metaB{}. So $\\mathcal{I}(\\metaA{})=1$ and $\\mathcal{I}(\\metaB{})=0$. So $\\mathcal{I}$ falsifies the conditional, satisfying the negated conditional.\n\nThere are three more kinds of sentences that exist in SL.\n\n\\subsection{Biconditional}\n\nSuppose a biconditional is in an open branch. If the branch is completed, then this rule has been performed:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eiff\\metaB{}\n\t[\\metaA{}\n\t\t[\\metaB{}, grouped]\n\t]\n\t[\\enot\\metaA{}\n\t\t[\\enot\\metaB{}, grouped]\n\t]\n]\n\\end{prooftree}\n\\end{center}\n\nOne of these developments is the open branch. If it's the left branch, then, supposing that $\\mathcal{I}$ assigns 1 to both \\metaA{} and \\metaB{}, $\\mathcal{I}$ must also assign 1 to the biconditional $\\metaA{}\\eiff\\metaB{}$. If it's the right branch, then, supposing that $\\mathcal{I}$ assigns 0 to both \\metaA{} and \\metaB{}, this also means that $\\mathcal{I}$ must also assign 1 to the biconditional $\\metaA{}\\eiff\\metaB{}$. So whichever branch is satisfied by $\\mathcal{I}$, the biconditional is also satisfied.\n\n\\subsection{Negated biconditional}\n\nExactly the same reasoning as above applies to negated biconditionals, except this time, the branches each assign \\emph{opposite} truth values to \\metaA{} and \\metaB{}. So for our interpretation to satisfy either branch, it must falsify the biconditional, thus satisfying the negated biconditional.\n\n\\subsection{Double negation}\n\nFinally, suppose there is a double-negated sentence in our completed open branch. Then this rule has been performed:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering, single branches}\n[\\enot\\enot\\metaA{}\n\t[\\metaA{}]\n]\n\\end{prooftree}\n\\end{center}\n\nIf $\\mathcal{I}(\\metaA{})=1$, then, given the definition of truth in SL, $\\mathcal{I}(\\enot\\metaA{})=0$, and $\\mathcal{I}(\\enot\\enot\\metaA{})=1$. So once again, if our interpretation satisfies what comes below, then it satisfies the double-negation above.\n\n\\subsection{Summarizing the completeness proof}\n\nWhat we've just shown is that, for any sentence of SL, if it has one of the nine structures just canvassed --- if it's a conjunction, a negated conjunction, a disjunction, etc. --- then, if it is in a completed open branch where the sentences below it are satisfied by $\\mathcal{I}$, then it too is satisfied by $\\mathcal{I}$. Given the way that $\\mathcal{I}$ was selected, we know that $\\mathcal{I}$ must satisfy every atomic sentence, and every negated atomic sentence, in the open branch. And since the nine structures considered are the only ways to develop more complex sentences, this implies that \\emph{every} SL sentence in the open branch is satisfied by $\\mathcal{I}$. This includes the root. Since interpretation $\\mathcal{I}$ satisfies the root, this of course means that the root is satisfiable. That is to say, if a completed branch remains open, this guarantees that the root is satisfiable. Equivalently, if the root is unsatisfiable, a completed tree is guaranteed to close. Completeness is proven.\n\n\\section{Testing alternate rules}\n\nWe can use the reasoning involved in the soundness and completeness proofs above to consider various alternative tree rules. We saw one example of this on p.\\ \\pageref{unsoundrule} above, when we observed that an alternate, linear rule for disjunctions would result in an unsound tree system. Here again was the rule we considered:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[\\metaA{}\\eor\\metaB{}\n\t[\\metaA{}\n\t[\\metaB{}, grouped]]\n]\n\\end{prooftree}\n\\end{center}\n\nNote, however, that if we think through the \\emph{completeness} reasoning, we'll find that the completeness proof would still hold. If we assume that some interpretation $\\mathcal{I}$ satisfies both \\metaA{} and \\metaB{}, we can be assured that it also satisfies the disjunction $\\metaA{}\\eor\\metaB{}$. So changing the disjunction rule to this linear one would \\emph{not} interfere with the completeness of our tree system. Our trees would still close any time they began with unsatisfiable roots. But as we saw on p.\\ \\pageref{soundprooffailure}, the soundness proof would fail, which is why a system with this rule could start in a satisfiable root, and result in a closed tree.\n\nWhen either the soundness or the completeness proof fails, you know you are working with an inappropriate rule. To conclusively demonstrate this, you can provide a counterexample to the failed metalogical theorem. A counterexample to soundness would be a tree with a satisfiable root that closes. A counterexample to completeness would be a completed tree, with an unsatisfiable root, that remains open. The rule above violates soundness, so using that rule we can construct a tree with a satisfiable root, that closes. Constructing the right counterexample takes a bit of thought. The rule puts both disjuncts into a single branch below, and we want it to close, despite having a satisfiable root. So adding the negation of just one of the disjuncts to the root will close the tree, without making the root unsatisfiable:\n\n\\begin{center}\n\\begin{prooftree}\n{not line numbering,\nsingle branches}\n[A \\eor B, checked\n[\\enot A, grouped\n\t[A\n\t[B, grouped, close]]\n]\n]\n\\end{prooftree}\n\\end{center}\n\nThis tree is a counterexample to soundness, using the hypothetical rule mentioned above. Note that a counterexample is a tree that uses SL sentences, not the Greek letters \\metaA{} and \\metaB{} that we use in the statements of the rules.\n\nLet's work through one more example. Suppose we changed the conjunction rule to this one:\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eand\\metaB{}\n\t\t[\\metaA{}\n\t\t[\\metaB{}, grouped\n\t\t]\n\t\t]\n\t\t[\\metaB{}]\n\t]\n\\end{prooftree}\n\\end{center}\nWould our system still be sound? To answer this, we assume that the conjunction $\\metaA{}\\eand\\metaB{}$ is satisfiable, and ask whether this guarantees that at least one branch below is also satisfiable. It does. (In fact, both branches are guaranteed to be satisfiable.) So the system will still be sound.\n\nWould the system still be complete? To answer this, we ask whether each branch is such that, if we assume that an interpretation satisfies the developments below, it is guaranteed to satisfy the conjunction above. Begin with the left branch. If some interpretation satisfies both \\metaA{} and \\metaB{}, then it will certainly satisfy the conjunction $\\metaA{}\\eand\\metaB{}$. So that branch looks fine. (Indeed, that branch is exactly the same as the linear development of our actual conjunction rule, so this reasoning is the same as that on p.\\ \\pageref{conjunctionsound}.)\n\nBut what of the right branch? Assume that some interpretation satisfies \\metaB{}; does that guarantee that it satisfies $\\metaA{}\\eand\\metaB{}$? Certainly not. So if the right branch is our open branch, a completed tree using this rule may remain open, even if its root is unsatisfiable. Completeness will be violated. Let's construct a counterexample of that form. We want a tree that includes a conjunction, whose root is unsatisfiable, but whose right branch remains open. Notice that the right branch `ignores' the first conjunct; this is a clue that a good way to construct a counterexample will be to locate the unsatisfiability within that first conjunct. Suppose, for example, that we let \\metaA{} itself stand for a contradiction. If so, any conjunction with \\metaA{} as a conjunct will be unsatisfiable. But if \\metaB{} is not a contradiction, then a tree with root $\\metaA{}\\eand\\metaB{}$ will remain open. Let's develop a tree with this root: $(P \\eiff \\enot P) \\eand Q$. Note that this sentence has a contradictory first conjunct, and a contingent, atomic second conjunct.\n\n\\begin{center}\n\\begin{prooftree}\n\t{not line numbering}\n\t[(P \\eiff \\enot P) \\eand Q, checked\n\t\t[(P \\eiff \\enot P), checked\n\t\t[Q, grouped\n\t\t\t[P\n\t\t\t[\\enot P, grouped, close\n\t\t\t]\n\t\t\t]\n\t\t\t[\\enot P\n\t\t\t[\\enot\\enot P, grouped, close\n\t\t\t]\n\t\t\t]\n\t\t]\n\t\t]\n\t\t[Q, open]\n\t]\n\\end{prooftree}\n\\end{center}\n\nThe left branch closes after we perform the unchanged biconditional rule on the contradictory first conjunct, but the right branch remains open. Since this is a completed tree with an open branch and an unsatisfiable root, it is a counterexample to completeness.\n\nRemember that we are considering a modification to the tree system that uses a different conjunction rule. In this example I used $P \\eiff \\enot P$ as my \\metaA{}, which let me use the unchanged biconditional rule. But if I had used a contradiction that used a conjunction, like $P \\eand \\enot P$, I would have had to have used the revised rule within the left branch too.\n\nIt is also possible to construct counterexamples using simpler sentences if you add to the root. Instead of introducing a contradictory conjunct, we could have simply added to the root, in a way that makes the root unsatisfiable, but leaves the right branch open. Suppose for instance we put both $P \\eand Q$ and $\\enot P$ in the root. Then we'd have an unsatisfiable root, but the right branch would remain open:\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[P\\eand Q, checked\n\t[\\enot P, grouped\n\t\t[P\n\t\t[Q, grouped, close\n\t\t]\n\t\t]\n\t\t[Q, open]\n\t]\n\t]\n\\end{prooftree}\n\\end{center}\n\nThis too is a counterexample to completeness, given the rule in question. So we see here two different kinds of strategies for generating counterexamples to completeness.\n\n\\practiceproblems\n\n\\solutions\n\\problempart\n\\label{pr.SL.soundness-resolutions}\nFollowing are possible modifications to our SL tree system. For each, imagine a system that is like the system laid out in this chapter, except for the indicated change. Would the modified tree system be sound? If so, explain how the proof given in this chapter would extend to a system with this rule; if not, give a tree that is a counterexample to the soundness of the modified system.\n\\begin{earg}\n\\item Change the rule for conjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eand\\metaB{}\n\t\t[\\metaA{}]\n\t\t[\\metaB{}]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for conjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eand\\metaB{}\n\t\t[\\metaA{}]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for conjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eand\\metaB{}\n\t\t[\\metaA{}\n\t\t[\\enot\\metaB{}, grouped\n\t\t]\n\t\t]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for disjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eor\\metaB{}\n\t\t[\\metaA{}\n\t\t[\\metaB{}, grouped\n\t\t]\n\t\t]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for disjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eor\\metaB{}\n\t\t[\\metaA{}]\n\t\t[\\metaB{}]\n\t\t[\\metaA{} \\eand \\metaB{}]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for conditionals to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eif\\metaB{}\n\t\t[\\enot\\metaA{}]\n\t\t[\\metaB{}\\eor\\metaA{}]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for conditionals to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eif\\metaB{}\n\t\t[\\enot\\metaA{}\\eor\\metaB{}]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for biconditionals to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eiff\\metaB{}\n\t\t[\\metaA{}\n\t\t[\\metaB{}, grouped\n\t\t]\n\t\t]\n\t]\n\\end{prooftree}\n\\end{center}\n}\n\n\\item Change the rule for disjunctions to this rule:\n\t\\factoidbox{\n\t\\begin{center}\n\t\\begin{prooftree}\n\t{not line numbering}\n\t[\\metaA{}\\eor\\metaB{}\n\t\t[\\metaA{}]\n\t\t[\\metaB{}]\n\t\t[\\metaC{}]\n\t]\n\\end{prooftree}\n\\end{center}\n(This would mean that one can put whatever SL sentence one likes in the rightmost branch.)\n}\n\n\\end{earg}\n\n\\problempart\n\\label{pr.SL.completenessresolutions}\nFor each of the rule modifications given in Part \\ref{pr.SL.soundness-resolutions}, would the modified tree system be complete? If so, explain how the proof given in this chapter would extend to a system with this rule; if not, give a tree that is a counterexample to the completeness of the modified system.\n", "meta": {"hexsha": "ecffc21ae2ab08bdd0c9f98d2a59fa65826d8901", "size": 41885, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Latex-Files/forallx-ubc-6-SLsoundcomplete.tex", "max_stars_repo_name": "jonathanichikawa/for-all-x", "max_stars_repo_head_hexsha": "b7cc18e497065e45e54af30c615999941941b23d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2019-03-29T14:57:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:58:11.000Z", "max_issues_repo_path": "Latex-Files/forallx-ubc-6-SLsoundcomplete.tex", "max_issues_repo_name": "mavaddat/for-all-x", "max_issues_repo_head_hexsha": "925bfb510101aa77174d977d2b956fc8088950e6", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2019-02-18T21:45:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-13T23:39:59.000Z", "max_forks_repo_path": "Latex-Files/forallx-ubc-6-SLsoundcomplete.tex", "max_forks_repo_name": "lauragreenstreet/for-all-x", "max_forks_repo_head_hexsha": "925bfb510101aa77174d977d2b956fc8088950e6", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-06-19T20:30:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T16:39:29.000Z", "avg_line_length": 58.662464986, "max_line_length": 1094, "alphanum_fraction": 0.7545899487, "num_tokens": 11035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665855647394, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.42400788962002967}}
{"text": "% Created 2015-10-16 Fri 09:57\n\\documentclass{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{fixltx2e}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{float}\n\\usepackage{wrapfig}\n\\usepackage{soul}\n\\usepackage{textcomp}\n\\usepackage{marvosym}\n\\usepackage{wasysym}\n\\usepackage{latexsym}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\tolerance=1000\n\\usepackage[margin=18mm]{geometry}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{gensymb}\n\\usepackage{subfigure}\n\\usepackage{parskip}\n\\usepackage{standalone}\n\\usepackage{tikz,pgf,pgfplots}\n\\usetikzlibrary{decorations.pathmorphing,patterns}\n\\usetikzlibrary{arrows,snakes,backgrounds,patterns,matrix,shapes,fit,calc,shadows,plotmarks,decorations.markings,datavisualization,datavisualization.formats.functions,intersections,external}\n\\usetikzlibrary{decorations.pathmorphing,patterns}\n\\pgfplotsset{compat=1.9}\n\\newcommand*{\\mexp}[1]{\\ensuremath{\\mathrm{e}^{#1}}}\n\\newcommand*{\\laplace}[1]{\\ensuremath{\\mathcal{L} \\{#1\\}}}\n\\newcommand*{\\laplaceinv}[1]{\\ensuremath{\\mathcal{L}^{-1} \\{#1\\}}}\n\\newcommand*{\\realpart}[1]{\\ensuremath{\\operatorname{Re}(#1)}}\n\\newcommand*{\\impart}[1]{\\ensuremath{\\operatorname{Im}(#1)}}\n\\newcommand*{\\vsp}[1]{\\rule{0pt}{#1}}\n\\newcommand*{\\tderiv}[1]{\\ensuremath{\\frac{d^{#1}}{dt^{n}}}}\n\\newcommand*{\\bbm}{\\begin{bmatrix}}\n\\newcommand*{\\ebm}{\\end{bmatrix}}\n\\newcommand*{\\obsmatrix}{\\mathcal{O}}\n\\newcommand*{\\contrmatrix}{\\mathcal{C}}\n\\newcommand*{\\cwh}{\\ensuremath{\\cos \\omega h}}\n\\newcommand*{\\swh}{\\ensuremath{\\sin \\omega h}}\n\\providecommand{\\alert}[1]{\\textbf{#1}}\n\n\\title{Computerized control - homework 4}\n\\author{Kjartan Halvorsen}\n\\date{Due 2015-10-09}\n\\hypersetup{\n  pdfkeywords={},\n  pdfsubject={},\n  pdfcreator={Emacs Org-mode version 7.9.3f}}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\section{PID tuning}\n\\label{sec-1}\n\n  Your task in this homework is to find parameters for the PID controller \n  \\[ u(t) = K_p\\left(e(t) + \\frac{1}{T_i}\\int^te(\\tau)d\\tau + T_d\\frac{de(t)}{dt} \\right). \\]\n\n  Consider the continuous-time system with transfer function\n  \\[ G(s) = \\frac{\\mexp{-0.2s}}{s+2} \\]\n  \n  Use Ziegler-Nichols tuning (ultimate-sensitivity method). In this method, one determines the critical gain of pure proportional control of the system. That means, to determine the value of $K$ for which the closed loop system below gives self-sustained oscillations.\n  \\begin{center}\n  \\includestandalone[mode=buildnew]{feedbackK}\n  \\end{center}\n\\subsection{Analytical solution}\n\\label{sec-1-1}\n\n  Determine the ultimate gain by calculations. \n\\begin{enumerate}\n\\item Determine the frequency $\\omega_p$ for which the nyquist curve for $G(s)$ crosses the negative real axis. That is, solve for $\\omega$ in \n     \\[ \\arg G(i\\omega) = -\\pi. \\]\n     Actually, this leads to a transcendental equation. You can solve this numerically using, for example, the function \\texttt{fsolve} in matlab.\n\\item Determine the gain $K=K_u$ such that the nyquist curve for the open loop system $KG(s)$ passes through the point $(-1,0)$.\n\\end{enumerate}\n\n  This will give you the ultimate gain $K_u$ and period of the oscillations $T_u$ needed to apply the tuning rules.\n\\subsection{Determine by simulation}\n\\label{sec-1-2}\n\n\\begin{enumerate}\n\\item Use matlab (or simulink) to implement the system. To define the transfer function of the plant you can do\n\n\\begin{verbatim}\ns = tf('s');\nG = exp(-0.2*s)/(s+2)\n\\end{verbatim}\n\\item Plot a Bode diagram using \\texttt{margin(G)}. Verify that the phase curve crosses $-180\\degree$ at the frequency $\\omega_p$ that you determined in the previous exercise. Include the bode-diagram in your report.\n\\item Define the closed loop system with proportional feedback, $K$.\n\\item Simulate step-responses for various values of the gain $K$. Increase  $K$ until the system shows sustained (neither increasing nor decaying) oscillations. Note the corresponding value, $K_u$ and the period of the oscillations, $T_u$. Verify that they are the same as (or close to) the values you determined analytically. Include a figure of the step-response for critical gain $K_u$ to your report (plot showing 10-20 periods of oscillations).\n\\end{enumerate}\n \n \n\\subsection{Implement a PID-controller}\n\\label{sec-1-3}\n\n   Use Table 8.3 in Å\\&W to determine the parameters $K_p$, $T_i$ and $T_d$ based on $K_u$ and $\\omega_p$. \n\\begin{enumerate}\n\\item Implement the (continuous-time) controller and the closed loop system.\n\\item Plot the Bode diagram for the closed-loop system and include in your report. What is the bandwidth of the closed-loop system?\n\\item Plot the Bode diagram and Nyquist diagram for the open-loop system $F(s)G(s)$. What is the phase marginal? Include a figure (Bode or Nyquist) in your report, where you indicate the phase marginal.\n\\item Simulate a step response for the closed-loop system and include in your report. You will probably need to use a Padé-approximation of the delay. To get an LTI-system with approximated delays use \\texttt{Gcp = pade(Gc, 4)} for a 4th order Padé approximation. What is the overshoot of the step response in percent of the final value?\n\\end{enumerate}\n\\section{Solution}\n\\label{sec-2}\n\\subsection{Analytical solution}\n\\label{sec-2-1}\n\n\\begin{enumerate}\n\\item The equation to solve to find the phase-crossover frequency is\n      \\[ \\arg G(i\\omega) = -\\pi. \\]\n      Write this as\n      \\[ \\arg \\mexp{-0.2i\\omega} - \\arg (i\\omega + 2) + \\pi = 0, \\]\n      or \n      \\[ -0.2\\omega - \\atan \\frac{\\omega}{2} + \\pi = 0. \\]\n      This can be solved in matlab with the line\n      \\texttt{fsolve(inline('-atan2(x,2) - 0.2*x + pi'), 0)} and gives the answer\n      \\[\\omega_p = 8.953. \\]\n\\item The phase-crossover frequency is the frequency for which the Nyquist curve crosses the negative real axis. Multiplying $G(i\\omega)$ with a real, positive gain $K$ does not change the phase and so the phase-crossover frequency remains the same. $KG(i\\omega)$ will cross the negative real axis at $\\omega_p$. To find the ultimate gain $K_u$ that will cause the Nyquist curve to pass throgh the point (-1,0), solve\n      \\[ |K_uG(i\\omega_p)| = 1, \\]\n      which lead to\n      \\[ K_u = \\frac{1}{|G(i\\omega_p)|} = \\frac{|i\\omega_p + 2|}{|\\mexp{-0.2i\\omega_p}|} = \\sqrt{\\omega_p^2 + 4} \\approx 9.174. \\]\n\\end{enumerate}\n   \n\\subsection{Simulation}\n\\label{sec-2-2}\n\n   Here is example matlab-code for generating the model and simulating a step:\n\n\\begin{verbatim}\nT = 0.2;\ns = tf('s');\nG = exp(-s*T) / (s+2)\nKu = 1/abs(evalfr(G, i*wp))\nGc = feedback(Ku*G, 1);\nstep(Gc)\n\\end{verbatim}\n     The figure below shows the first five seconds of the step response. Clearly, the period of the oscillations is $T_u = 0.702$.\n   \n      \\begin{center}\n      \\includestandalone[mode=buildnew, width=0.6\\linewidth]{ultimate_gain_experiment}\n      \\end{center}\n\n   Bode-diagram of open-loop transfer function with ultimate gain (using \\texttt{margin})\n      \\begin{center}\n      \\includegraphics[width=0.6\\linewidth]{ultimate_margin-crop}\n      \\end{center}\n\n  \n\\subsection{Implement PID}\n\\label{sec-2-3}\n\n   Using table 8.3 from Å\\&W we obtain the PID controller with parameters\n   \\begin{align*}\n   K_p &= 0.6 K_u = 5.5\\\\\n   T_i &= 0.5T_u = 0.35\\\\\n   T_d &= T_u/8 = 0.088\n   \\end{align*}\n\n   The Bode diagram of the closed loop system with the PID controller is given below.\n      \\begin{center}\n      \\includegraphics[width=0.6\\linewidth]{pid_gc_bode-crop}\n      \\end{center}\n   The closed-loop system has bandwidth 17.2 rad/s.\n\n   The Bode diagram of the open-loop system shows a phase margin of 46.4 degrees:\n      \\begin{center}\n      \\includegraphics[width=0.6\\linewidth]{pid_go_margin-crop}\n      \\end{center}\n\n    With a padé approximation of the delay, the step response of the closed loop system is given below\n      \\begin{center}\n      \\includegraphics[width=0.6\\linewidth]{pid_step_pade-crop}\n      \\end{center}\n    The initial response of the close-loop system before the delay of the open-loop system is due to the approximation. It should be exactly zero. The overshoot is about 30\\%.\n\n\\end{document}\n", "meta": {"hexsha": "12c6345ec05564688ab349191a86183c3e62fffe", "size": 8041, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homework/historical/hw4-fall15.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "homework/historical/hw4-fall15.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "homework/historical/hw4-fall15.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 43.9398907104, "max_line_length": 449, "alphanum_fraction": 0.7203084194, "num_tokens": 2461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7981867849406659, "lm_q1q2_score": 0.42400430186354426}}
{"text": "\\documentclass{article}\n\\author{Vaibhav Pujari}\n\\title{Natural Transformation}\n\\begin{document}\n\\section{Definition}\n\nGiven two functors, $F,G : \\zeta_1 \\to \\zeta_2$ which map objects and morphisms\nfrom $\\zeta_1$ to $\\zeta_2$, a natural transformation is a bunch of morphisms in\n$\\zeta_2$ that maps objects and morphism produced by $F$ into objects and\nmorphisms produced by $G$\n\n  \\textsf{\\tiny\n  \\textbf{Notes}\n  \\begin{itemize}\n  \\item It is denoted by greek letters like $\\alpha$ and really represents multiple\n    morphisms under the hood, which live in $\\zeta_2$\n  \\item Since there might not always be morphisms in $\\zeta_2$ that can be\n    utilized for natural transformation, sometimes there is no natural\n    transformation available/possible.\n  \\end{itemize}\n  }\n\n\\section{Constraints}\n\n\\begin{itemize}\n\\item \\textbf{Diagram must commute}\n\n  For each morphism in $\\zeta_1$, there will be two morphisms in $\\zeta_2$ (one\n  due to $F$ and another due to $G$). These two morphism and the components\n  (specific to this morphism) of a candidate natural transformation from $F$ to\n  $G$ create a diagram. This diagram must commute for the candidate natural\n  transformation to be a natural transformation\n\n  \\textsf{\\tiny\n  \\textbf{Notes}\n  \\begin{itemize}\n  \\item One mistake I made initially while trying to understand natural\n    transformations was that I assumed unconditional existence of natural\n    transformations. Now I realize that the existence of natural transformation\n    is subject to availability of morphisms in the target category ($\\zeta_2$)\n    which can be used as components to build a natural transformation. If no\n    such morphisms exist, a natural transformation cannot exist.\n  \\item For programming it means if there is information loss due to\n    abstraction, or the diagram does not commute, then a natural transformation\n    might not exist between two functors.\n  \\end{itemize}\n  }\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "3852675e6b8201849dac7a3ecb6c44cc6af44319", "size": 1951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "04-natural-transformation.tex", "max_stars_repo_name": "vaibhav276/category-theory-notes", "max_stars_repo_head_hexsha": "164285a8ace6bcf86f19a083255c029a2c39cdbe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-natural-transformation.tex", "max_issues_repo_name": "vaibhav276/category-theory-notes", "max_issues_repo_head_hexsha": "164285a8ace6bcf86f19a083255c029a2c39cdbe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-natural-transformation.tex", "max_forks_repo_name": "vaibhav276/category-theory-notes", "max_forks_repo_head_hexsha": "164285a8ace6bcf86f19a083255c029a2c39cdbe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2549019608, "max_line_length": 83, "alphanum_fraction": 0.7570476679, "num_tokens": 502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.42399724247477844}}
{"text": "%\\setcounter{chapter}{6}\n%\\setcounter{page}{700}\n\\chapter{Basic Integration\\label{FirstIntegrationChapter}}\n\nIn this chapter we will consider the problem of recovering \na function from knowledge of its derivative, or, equivalently,\nfor a given function we will try to find another function\nwhose derivative is the given function's.  The general process\nis called  {\\it antidifferentiation}, or\n{\\it integration}.  The meaning of the first term is obvious:\nwe are working backwards from the  derivative to the function.\nThe meaning of the other name for the process\nis mainly left for Chapter~\\ref{AppsDefIntegrals}.\n\nThe main purpose of this chapter is to develop the first, basic\ntechniques for computing antiderivatives $F(x)$ for a given\nfunction $f(x)$, i.e., given $f(x)$ we look for $F(x)$ so that\n\\begin{equation}\nF'(x)=f(x).\\label{IntroducingF(x)}\\end{equation}\nAs we will see early in this chapter and throughout the next, \nantidifferentiation (finding some such $F(x)$), a.k.a.\\ integration,\nis less straightforward than differentiation (finding $f'(x)$).  \nHowever, there are easily as many applications of antidifferentiation \nas there are of differentiation so it is a worthwhile process.  \nIn the first section we will limit ourselves to two applications:\n\\begin{enumerate}\n\\item Given the slope $f'(x)$, find the function $f(x)$\n      by antidifferentiation;\\footnote{%\n%%% FOOTNOTE\nIn this application, the part of $f(x)$ in (\\ref{IntroducingF(x)})\nis played by $f'(x)$, while the part of $F(x)$ is played by $f(x)$.}\n%%% END FOOTNOTE\n\n      Moreover, given $f''(x)$, find $f'(x)$, and then $f(x)$.\n\\item Given velocity $v$, find position $s$. \n\n      Moreover, given\n      acceleration $a$, find $v$ and then $s$.\n\\end{enumerate}\nLater in the chapter\nwe will look at the geometric\nsignificance of antiderivatives $F(x)$ of a function $f(x)$.  \nJust as the geometric meaning of \nslope gave us a useful perspective for arriving at derivative theorems\n(mean value theorem, first derivative test, etc.), so too will the\nantiderivatives benefit from geometric analysis.  To make\nthat analysis will require us to consider another major theoretical device,\nnamely {\\it Riemann sums}, which---together with the \nFundamental Theorem of Calculus---will open the topic of integration\nto innumerable applications.  To illustrate the reasonableness of\nthe Fundamental Theorem of Calculus, we will again look closely at the\nvelocity-position connection as well, in\nChapter~\\ref{AppsDefIntegrals}.\n\n\nIn Chapter~\\ref{AdvancedIntTechniques}\nwe will develop more advanced techniques of\nantidifferentiation, so that we can use all of our integration\ntechniques in Chapter~\\ref{AppsDefIntegrals}, which\nis devoted to applications.\n\nFor now we will concentrate on the actual computation of\nantiderivatives of the more basic types.\nIn the first section we will limit ourselves to those \nwhich arise from our known derivative formulas.  In subsequent\nsections we will then explore the substitution technique, which\nis the antidifferentiation analog to the chain rule\nand is thus arguably the most important\nof the integration techniques.  It will be developed at length.  \n\n\n\n%In Chapter~\\ref{DerivativeChapter} we described how we can take\n%a function such as position $s(t)$, and---using a particular limit\n%which was the derivative---compute the instantaneous rate of change in\n%the position with repsect to time $t$, that instantaneous\n%rate of change for that case being {\\it velocity} $v(t)$.  \n%We did this by looking\n%at the net change in the function over smaller and smaller intervals,\n%such as $[t,t+\\Delta t]$ if $\\Delta t>0$, and $[t+\\Delta t,t]$\n%if $\\Delta t<0$, and dividing by how long it took for\n%those changes to occur (i.e., the directed lengths of the intervals)\n%to get average rates of change of $s$ with respect to $t$ on\n%those intervals. Then we let the lengths of the intervals approach\n%zero in the limit. \n%Thus what we computed was\n%the limit---wherever it existed---of difference quotients:\n%\\begin{equation}\n%\\frac{s(t+\\Delta t)-s(t)}{\\Delta t} \\longto s'(t)=v(t)\n%\\qquad\\text{as}\\qquad\\Delta t\\to0.\\end{equation}\n%Because we started with a function and used quotients of {\\it differences}\n%to find its instantaneous rate of change, the process was called\n%{\\it differentiation} (and for each $t$ at which the limit \n%existed, we called $s(t)$ {\\it differentiable}).\n\n%Next we will be interested in recovering the net change\n%in the function over intervals---for instance\n%the net change of $s(t)$ over the\n%interval $t\\in\\left[t_0,t_f\\right]$, namely $s(t_f)-s(t_0)$---from\n%knowledge of the derivative $s'(t)$ over that interval.  \n%In other words, for this context we are interested in recovering\n%the total change in position, over some time interval, \n%from knowledge of the velocity at each time in the interval.\n%This process of somehow\n%accumulating all these instantaneous changes $s'(t)$ into the total change\n%$s(t_f)-s(t_0)$ is, naturally enough,\n%called  {\\it integration} (as opposed to {\\it differentiation}).\n\n%Perhaps predictably, so-called {\\it antiderivatives} will \n%be central to our discussion\n%here and in subsequent chapters.  In this chapter, we will first\n%develop the idea of antiderivatives, and then pursue\n%the most basic methods of computing them.\n%We will then explore Riemann Sums, and how they arise in\n%very natural ways.  \n%For the climax of the chapter, we will see how the Fundamental Theorem of \n%Calculus connects these things.\\footnote{At this point it \n%can be useful to re-read the introduction to Chapter~\\ref{DerivativeChapter}\n%to recall the previous development to this point.}\n\\newpage\n\\section{First Indefinite \nIntegrals (Antiderivatives)\\label{IndefiniteIntegrals}}\nIn this section we introduce {\\it antiderivatives}, which are \nexactly what the name implies.  These are also called\n{\\it indefinite integrals} for reasons which will eventually\nbecome clear.\n\\subsection{Indefinite Integrals and Constants of Integration}\n\n\\begin{definition}Consider a function $f(x)$ which is defined on an open\ninterval $(a,b)$.  Another function $F(x)$, also defined\non $(a,b)$ is called an {\\bf antiderivative} of $f(x)$ on\nthe same interval if and only if $F'(x)=f(x)$ on $(a,b)$.\n\nIf instead $f(x)$ is defined on a closed interval $[a,b]$, we still call\n$F:[a,b]\\longrightarrow\\Re$ an {\\bf antiderivative} of $f(x)$\non $[a,b]$ if and only if \n\\begin{align*}\nF'(x)&=f(x),\\qquad x\\in(a,b),\\\\\n\\lim_{\\Delta x\\to0^+}\\frac{F(a+\\Delta x)-F(a)}{\\Delta x}&=f(a),\\\\\n\\lim_{\\Delta x\\to0^-}\\frac{F(b+\\Delta x)-F(b)}{\\Delta x}&=f(b).\n\\end{align*}\n\\end{definition}\nIn other words, on an open interval we require $F'(x)=f(x)$,\nwhile on the closed interval we also require the right derivative\nof $F$ to be $f$ at $x=a$, and the left derivative of $F$ to be \n$f$ at $x=b$.\n\nNotice that the definition implies that $F(x)$ is continuous\non the interval in question\n(since $F'=f$ exists implies continuity of $F$).  \nFor a simple example, consider $f(x)=2x+3$ on any open (or nontrivial closed)\ninterval. An antiderivative of $f(x)$ can be\n$F(x)=x^2+3x$, since then $F'(x)=2x+3=f(x)$.  \nHowever, another perfectly good antiderivative\ncan be $F(x)=x^2+3x+5$, or $F(x)=x^2+3x-100,000$, since the\nderivative of the trailing constant term will always be zero.\nIn logical terms we can write\n\\begin{align}\nF(x)=x^2+3x\\implies& F'(x)=2x+3,\\notag\\\\\nF(x)=x^2+3x+5\\implies& F'(x)=2x+3,\\notag\\\\\nF(x)=x^2+3x-100,000\\implies& F'(x)=2x+3,\\notag\\\\\nF(x)=x^2+3x+C,\\text{ some }C\\in\\Re\\iff& F'(x)=2x+3.\n\\label{FirstAntiderivative}\n\\end{align}\nThat the last one (\\ref{FirstAntiderivative})\nis an equivalence we will prove shortly.\nTo signify that equivalence, we write\n\\begin{equation}\n\\int (2x+3)\\,dx=x^2+3x+C,\\qquad C\\in\\Re.\\label{EasyIndefIntegEx}\\end{equation}\nWe call the right hand side of (\\ref{EasyIndefIntegEx})\n{\\it the most general antiderivative}, or just\n{\\it the antiderivative,} of $2x+3$ (with respect to $x$). It is \nalso called the {\\it indefinite integral} \nof $2x+3$ (again with respect to $x$), and we will\neventually migrate to using that term as our default.\\footnote{%\n%%%%%% FOOTNOTE\nThe indefinite integral has a strong connection to the \nvery important {\\it definite integral, }which is a measure\nof accumulated change as computed from the instantaneous\nrate of change.  This computation is our eventual goal and---to\nrestate the introduction to this chapter---the connection \nbetween antiderivatives (indefinite integrals)\nand accumulated change (definite integrals) is precisely the \nsubject of the Fundamental Theorem of Calculus.}\n%%%%%% END FOOTNOTE\nThe constant\n$C$ is called the {\\it constant of integration},\nsince it must be included to achieve all solutions to the question\nof what is an antiderivative of $f(x)=2x+3$.\nOn the left hand side of (\\ref{EasyIndefIntegEx})\nwe have\n\\begin{itemize}\n\\item $\\ds{\\int}$: the {\\it integral sign}, derived from a old style German \n           S for reasons we will discuss later;\n\\item $(2x+3)$: the {\\it integrand}, whose antiderivatives we seek; and\n\\item $dx$: the differential of $x$, which signifies which variable\n            the antiderivative is with respect to.\n\\end{itemize}\nWe now note that, indeed, all antiderivates of $2x+3$\nare necessarily of the form $x^2+3x+C$.  To prove this, on some interval\ndefine $F(x)=x^2+3x$, which we can easily see is an antiderivative\nof $2x+3$ on that interval.\nNext suppose $G(x)$ is another such antiderivative,\ni.e., that $G'(x)=2x+3$, on that same interval.  Then on that interval\n$$\\frac{d}{dx}\\left[G(x)-F(x)\\right]\n=G'(x)-F'(x)=(2x+3)-(2x+3)=0\n\\implies G(x)-F(x)=C,$$\nfor some $C\\in\\Re$.  Thus any antiderivative $G(x)$\nmust be of the form $G(x)=F(x)+C$, q.e.d.\\footnote{%%%%%\n%%%%% FOOTNOTE\nRecall that a function with the zero function for its derivative\non an interval\nmust be constant on that interval: \n$$(\\forall x\\in I)[(F(x)-G(x))'=0]\\implies (\\exists C\\in\\Re)\n      (\\forall x\\in I)[F(x)-G(x)= C].$$}\n%%%%  END FOOTNOTE\nTo be clear on the notation, we now insert the following definition.\n\\begin{definition}\nIf $F(x)$ is an antiderivative of $f(x)$, with respect to $x$,\non the interval $I$, then on that interval we write\n\\begin{equation}\n\\int f(x)\\,dx=F(x)+C,\\label{DefIndefIntegral} \n\\end{equation}\nwhere $C$ is an arbitrary constant of integration.\n\\end{definition}\n\\bex Consider $f(x)=2\\sin x\\cos x$.  One antiderivative\nis $F(x)=\\sin^2x$, since\n$$F'(x)=\\frac{d\\sin^2x}{dx}=\\frac{d(\\sin x)^2}{dx}\n=2\\sin x\\cdot\\frac{d\\sin x}{dx}=2\\sin x\\cos x.$$\nHowever, another antiderivative is $G(x)=-\\cos^2x$, since\n$$G'(x)=\\frac{d(-\\cos^2x)}{dx}\n=-\\,\\frac{d(\\cos x)^2}{dx}\n=-\\left[2\\cos x\\cdot\\frac{d\\cos x}{dx}\\right]\n=-\\left[2\\cos x(-\\sin x)\\right]=2\\sin x\\cos x.$$\nNote that\n$$F(x)-G(x)=\\sin^2x-\\left(-\\cos^2x\\right)=\\sin^2x+\\cos^2x=1,$$\nso we see that $F$ and $G$ do actually differ by a constant.\nTo report the most general antiderivative of $f(x)=2\\sin x\\cos x$,\neither of the following are valid (but understood to \nhave different ``$C$'s''):\n\\begin{align*}\n\\int2\\sin x\\cos x\\,dx&=\\sin^2x+C,\\\\\n\\int2\\sin x\\cos x\\,dx&=-\\cos^2x+C.\n\\end{align*}\n\\eex\n\nEspecially when dealing with trigonometric functions---and\nall their interconnectedness by various identities---it is \ncommon to find very different-looking forms\nof the general antiderivative, all of which differ by\nconstants from each other. It is occasionally important to be \nalert for apparent discrepancies which are explained \nby this nature of the general antiderivative.\n\n\\bex Suppose $f(x)=x+1$.  Then both forms below are\ngeneral antiderivatives:\n\\begin{align*}\n\\int(x+1)\\,dx&=\\frac12x^2+x+C,\\\\\n\\int(x+1)\\,dx&=\\frac12(x+1)^2+C.\n\\end{align*}\nWe can see this by taking derivatives of each.  We can also see\nthat if we label $F(x)=\\frac12x^2+x$ and $G(x)=\\frac12(x+1)^2$, \nso the antiderivatives above are just $F(x)$ and $G(x)$ plus\nconstants, respectively, and then compute\n$$F(x)-G(x)=\\left[\\frac12x^2+x\\right]-\\left[\\frac12\\left(x^2+2x+1\n   \\right)\\right]=-\\,\\frac12,$$\nso these do differ by a constant, as expected.\n\\eex\n\n\n\\subsection{Power Rule for Integrals}\nWhere the rules for computing derivatives were\nstraightforward (which is not to say necessarily ``easy''),\nthose for computing antiderivatives are not so algorithmic.\nIndeed the methods are varied.  Nonetheless, they are necessary\nto learn for a reasonably complete understanding of standard\ncalculus, and we begin with the {\\it power rule for integrals:}\n\\begin{align}\n\\int x^n\\,dx&=\\frac1{n+1}x^{n+1}+C,\\qquad n\\ne-1,\\label{IntegralPowerRule}\\\\\n\\int \\frac1x\\,dx&=\\ln|x|+C.\\label{PwerRuleN=-1}\n\\end{align}\nHere the intervals in question are those upon which $x^n$ is\ndefined.  To check (\\ref{PwerRuleN=-1}), we simply\nnotice $\\frac{d}{dx}\\ln|x|=\\frac1x$.\nFor (\\ref{IntegralPowerRule})\nwe compute:\n$$\\frac{d}{dx}\\left[\\frac1{n+1}x^{n+1}\\right]\n=\\frac1{n+1}\\cdot(n+1)x^{[(n+1)-1]}=x^n,\\qquad\\text{q.e.d.}$$\nIn performing the above computation, \nwe must notice that $n+1$ and $1/(n+1)$ are constants,\nand so are preserved throughout the computation (and do\nnot, for instance, require product/quotient/chain rules since they do not\nvary).\nWe also note that the formula to the right of (\\ref{IntegralPowerRule})\nis meaningless for the case $n=-1$, so we need\n(\\ref{PwerRuleN=-1}) for that case.  \n\nWhen checking any antiderivative by differentiation, it is customary to \nnot include the arbitrary additive constant, since its derivative is zero.\nHowever, it is certainly correct to include it, as in\n$\\frac{d}{dx}\\left[\\ln|x|+C\\right]=\\frac1x+0=\\frac1x$.\n\n\nWe can apply the power rule immediately\nas in the following:\n\\begin{align*}\n\\int x^2\\,dx&=\\frac13x^3+C,\\\\\n\\int x^3\\,dx&=\\frac14x^4+C,\\\\\n\\int\\frac1{x^2}\\,dx&=\\int x^{-2}\\,dx=\\frac1{-1}x^{-1}+C\n=-x^{-1}+C=\\frac{-1}x+C,\\\\\n\\int\\frac{x}{x^2}\\,dx&=\\int\\frac1x\\,dx=\\ln|x|+C.\n\\end{align*}\nWe can check all of these by taking derivatives of our answers,\nwith respect to $x$ (i.e., by applying $d/dx$).\\footnote{\n%%%%%%  FOOTNOTE\nIn fact, it is a very useful exercise to check these antiderivatives\nby quick mental calculations.  Since the derivative formulas have\nbeen used extensively to this point, the processes of computing\nantiderivatives can be well-informed by their connections\nto known derivative techniques.  In particular, mistakes in \ncomputing antiderivatives can often be immediately corrected.\nPerhaps even more importantly, the approximate form of an antiderivative\ncan often be anticipated.  For instance, we know that the derivative\nof a fourth-degree polynomial is necessarily a third-degree polynomial.\nIt should be clear (though some argument is necessary to prove) that\nthe antiderivative of a third-degree polynomial is necessarily a \nfourth-degree polynomial.  Anticipating the final form is also\nvery useful in substitution problems, which are introduced in \nSection~\\ref{FirstSubstitutionSection} and ubiquitous thereafter.\n%%%%%  END FOOTNOTE\n}\nAs with derivatives, many functions which are powers of the variable are\nnot explicitly written as such.  Furthermore as with derivatives,\nthe variable name in antiderivative formulas does not matter as long as \nit is matched in the differential:\n\\begin{align*}\n\\int t^9\\,dt&=\\frac1{10}t^{10}+C,\\\\\n\\int \\sqrt{u}\\,du&=\\int u^{1/2}\\,du=\\frac1{\\frac12+1}u\n             {\\vphantom{X^X}}^{\\left[\\frac12+1\\right]}\n    +C=\\frac23u^{3/2}+C,\\\\\n\\int\\frac{1}{z\\sqrt[4]z}\\,dz&=\\int z^{-5/4}\\,dz\n   =\\frac1{\\frac{-5}4+1}z{\\vphantom{X^X}}^{\\left[\\frac{-5}4+1\\right]}+C\n   =\\frac{z^{-1/4}}{-\\frac14}+C=\\frac{-4}{\\sqrt[4]{z}}+C.\n\\end{align*}\nTo check these, we can apply respectively $d/dt$, $d/du$ and\n$d/dz$.  \nBefore we go on we note that (\\ref{IntegralPowerRule}),\nintepretted formally, applies to the case $n=0$ as well:\n$\\int x^0\\,dx=\\frac{1}{0+1}x^{0+1}+C$, i.e.,\n\\begin{equation}\\int 1\\,dx=x+C.\\label{IntegralOfOne}\\end{equation}\nTaking the derivative of the right-hand side of \n(\\ref{IntegralOfOne}) quickly shows it is in fact true.\nThis integral is often abbreviated\n\\begin{equation}\\int\\,dx=x+C.\\label{IntegralOf_dx}\\end{equation}\nAs with the chain rule computations, the differential $dx$\nis formally treated as a factor as in the following:\\label{UsingdxAsAFactor}\n$$\\int\\frac{dx}{x^3}=\\int x^{-3}\\,dx=\\frac{1}{-2}x^{-2}+C\n=\\frac{-1}{2x^2}+C.$$\nLater we will see this treatment of $dx$ justified and exploited\nin several contexts.\n\nNow we state two very general results which may seem obvious,\nbut are worth exploring with some care because of a technical\nconsideration regarding the constant of integration.\\footnote{%\n%%%%  FOOTNOTE\nMany calculus students become careless about this constant of integration\nand just ``tack it on the end'' when computing antiderivatives.\nHowever, its correct placement is crucial\nin several contexts, so it is useful to be vigilant from the beginning\nof integration study.  Carelessness\nin its placement can cause trouble already in this section,\nbut will be particularly troublesome in subsequent third-semester\ncalculus and in differential equations studies.} %\n%%%%%%%%%% END FOOTNOTE\nThese are also useful to us immediately because they allow to \nuse the power rule multiple times to compute the derivatives of\npolynomials.\n\\begin{theorem}\nSuppose that $F'(x)=f(x)$ and $G'(x)=g(x)$ on some interval in \nconsideration, and that $k\\in\\Re$ is a fixed constant.  Then\n on that same interval we have\n\\begin{align}\n\\int\\left[f(x)+g(x)\\right]\\,dx&=F(x)+G(x)+C,\\label{IntegralOfASum}\\\\\n\\int\\left[k\\cdot f(x)\\right]\\,dx&=kF(x)+C.\\label{k*Integral}\\end{align}\nwhere $C\\in\\Re$ is a constant of integration.\n\\end{theorem}\nThese can be proved by taking derivatives.\nFor instance, $\\frac{d}{dx}[kF(x)]=k\\cdot\\frac{d}{dx}F(x)=kF'(x)=kf(x)$.\n Note that this theorem can  be rewritten\n\\begin{align}\n\\int\\left[f(x)+g(x)\\right]\\,dx&=\\int f(x)\\,dx+\\int g(x)\\,dx,\n   \\label{AltIntegralOfSum}\\\\\n\\int kf(x)\\,dx&=k\\int f(x)\\,dx,\\qquad k\\ne 0,\\label{Alt_k*Integral}\\\\\n\\int 0\\,dx&=C.\\label{IntegralOfZero}\\end{align}\nA moment's reflection shows that  we do need (\\ref{Alt_k*Integral})\nand (\\ref{IntegralOfZero}) to catch both cases summarzied in\n(\\ref{k*Integral}), else we lose the constant of integration if\nwe let $k=0$ in (\\ref{Alt_k*Integral}).  \n(Note that, indeed, $\\frac{d}{dx}C=0$ which\nverifies (\\ref{IntegralOfZero}).)  More importantly, these new\nforms (\\ref{AltIntegralOfSum})--(\\ref{IntegralOfZero})\nare not inconsistent with those of the theorem when\nwe consider the arbitrary constants.  For instance,\nif we assume $F'(x)=f(x)$ and $G'(x)=g(x)$ as in the theorem,\nthen we can write (\\ref{AltIntegralOfSum}) as follows:\n\\begin{align*}\\int f(x)\\,dx+\\int g(x)\\,dx\n&=\\left(F(x)+C_1\\right)+\\left(G(x)+C_2\\right)\\\\\n&=F(x)+G(x)+\\underbrace{\\left(C_1+C_2\\right)}_{\\text{``$C$''}}\n=F(x)+G(x)+C,\\end{align*} \nwhere $C_1$ and $C_2$ are arbitrary constants, and their sum\nwill also be an arbitrary constant which we can name $C$.\n\nWith the above theorem and the power rule, we can now\ncompute the indefinite integrals of polynomials and other\nlinear combinations of powers.\n\\bex Consider the following integrals:\n\n\\begin{enumerate}[(a)]\n\\item $\\ds{\\int\\left(4x^2-9x+7\\right)\\,dx\n  =4\\cdot\\frac{x^3}{3}-9\\frac{x^2}{2}+7\\cdot x+C\n  =\\frac43x^3-\\frac92x^2+7x+C}$,\n\\item $\\ds{\\int\\left(\\frac{3x-9}{x^3}\\right)\\,dx\n=\\int\\left(3x^{-2}-9x^{-3}\\right)\\,dx\n=-3\\cdot\\frac{x^{-1}}{-1}-9\\cdot\\frac{x^{-2}}{-2}+C\n=\\frac3x+\\frac9{2x^2}+C}$,\n\\item$\\ds{\\int\\left(5x^2\\right)^3\\,dx=\\int125x^6\\,dx=125\\cdot\\frac{x^7}7+C}$,\n\\item$\\ds{\\int\\left(x^2+7\\right)^2\\,dx\n=\\int\\left(x^4+14x^2+49\\right)\\,dx\n=\\frac{x^5}5+14\\cdot\\frac{x^3}3+49x+C}$,\n\\item$\\ds{\\int\\sqrt{2x}\\,dx=\\int\\sqrt2\\sqrt{x}\\,dx\n=\\int2^{1/2}x^{1/2}\\,dx\n=2^{1/2}\\cdot\\frac{x^{3/2}}{3/2}+C\n=\\sqrt{2}\\cdot\\frac23x^{3/2}+C}$.\n\\end{enumerate}\n\\eex\nWhen we use an integration rule such as the power rule for\nintegrals,  as with derivatives it is important\nthat the variable which the antiderivative is with respect to \nmatches the variable in the function.  For instance,\n\\begin{align}\n\\int x^3\\,dx&=\\frac14x^4+C,\\\\\n\\int w^3\\,dw&=\\frac14w^3+C,\\\\\n\\int (5x-11)^3\\,dx&\\ne\\frac14(5x-11)^4+C.\\label{BadIntegral1}\n\\end{align}\nWhat goes wrong in (\\ref{BadIntegral1}) is the integral analog\nto what goes wrong  below (which is that we need the chain rule\nto make the variables of differentiation match):\n\\begin{align*}\n\\frac{d}{dx}\\left[(5x-11)^4\\right]&\\ne4(5x-1)^3;\\\\\n\\frac{d}{dx}\\left[(5x-11)^4\\right]\n&=4(5x-11)^3\\cdot\\frac{d(5x-11)}{dx}=4(5x-11)^3\\cdot5\\ne4(5x-11)^3,\\end{align*}\nThe problem is that the differential, $dx$, is that of\n$x$ and not $(5x-11)$.  In the next section we will address\na kind of integral version of the chain rule (commonly known\nas {\\it integration by substitution} for reasons which\nwill be clear later), which would make short work of this\nintegral.  Without it, we may need to expand $(5x-11)^3$\nas a polynomial, or guess the solution and check that it works,\nand possibly make adjustments.\nEither way, it should suffice to \npoint out that we need to take care in using integral formulas\nsuch as the integral power rule,\npage~\\pageref{IntegralPowerRule}.\\footnote{%\n%%% FOOTNOTE\nWithout giving away the substitution technique, we will note here\nthat we can rewrite the integral in (\\ref{BadIntegral1})\nso the differential matches the term $(5x-11)$.  The argument\nwould be the analog of our early chain rule expansions, such as\n(\\ref{ChainRuleDecompFor(x^3+1)^2}), \npage~\\pageref{ChainRuleDecompFor(x^3+1)^2}.\nThe idea is that $d(5x-11)=5dx$ (recall the meaning of $d(5x-11)/dx$),\nand so $dx=d(5x-11)/5$, which allows us to rewrite the integral\nas follows:\n$$\\int(5x-11)^3\\,dx=\\int(5x-11)^3\\frac{d(5x-11)}{5}\n  =\\frac15\\cdot\\frac14\\cdot(5x-11)^4+C=\\frac1{20}(5x-11)^4+C.$$\nExcept for the factor of $\\frac15$ in the second interval, \nthat rewriting had an integral power rule form.\n\nOur integration by substitution method will be more systematic\nthan the above computation.  Consequently it will read\nbetter, and be less error-prone.  That method\nwill then be  called upon extensively from then on.}\n \n\n\n\n\n\\subsection{Finding $C$}\nMany times we are interested in a particular antiderivative.\nSince all antiderivatives (on a particular interval) differ\nby a constant, this means we need to find one antiderivative,\nand then try to ``fix,'' i.e., determine, the  constant.  \n\\bex Find $f(x)$ so that $f'(x)=2x$ and $f(3)=7$.\n\n\\underline{Solution}: For a problem such as this, it is common\nto write\n$$f(x)=\\int f'(x)\\,dx,$$\nwhere it is understood that we will eventually find the exact antiderivative\nso that the function is well-defined.\nFor our particular problem, one might continue to write\n$$f(x)=\\int 2x\\,dx=2\\cdot\\frac{x^2}2+C=x^2+C.$$\nNow we find the particular $C$, and we do this by inputting the\n``datum'' (sometimes called ``data point'') $f(3)=7$.\nGraphically this means that the point $(3,7)$ is on the curve.\nSince $f(x)=x^2+C$, we find $C$ using this datum:\n\\begin{alignat*}{2}\n&&f(3)&=7\\\\\n&\\iff\\qquad\\qquad& 3^2+C&=7\\\\\n&\\iff &9+C&=7\\\\\n&\\iff &C&=-2.\n\\end{alignat*}\nThus $f(x)=x^2-2.$\n\\label{FirstFindCExample}\n\\eex\nA graphical way of interpretting the example above is to realize\nthat all the curves $y=x^2+C$ are parabolas, and in fact are just\nvertical shifts of the curve $y=x^2$.  Our task in \nExample~\\ref{FirstFindCExample} was then to find which shift\nsatisfies both $f'(x)=2x$ and $f(3)=7$.  \nIn Figure~\\ref{FigureForFirstFindCExample}, $y=x^2+C$\nis graphed for various values of $C$.  Once we require\nthe graph to pass through a particular point---in\nthis case the point $(3,7)$, we ``pin down''\na particular curve, i.e., we\ndetermine exactly one\ncurve from the family of curves, as graphed in \nFigure~\\ref{FigureForFirstFindCExample}.\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-5,-1.8)(5,5.4)\n\\psset{xunit=.5cm,yunit=.3cm}\n\\psaxes[Dx=2,Dy=2]{<->}(0,0)(-10,-6)(10,18)\n\\psplot{-4.2426407}{4.2426407}{x dup mul}\n\\psplot{-4}{4}{x dup mul 2 add}\n\\psplot{-3.7416574}{3.7416574}{x dup mul 4 add}\n\\psplot{-3.4641016}{3.4641016}{x dup mul 6 add}\n\\psplot{-3.1622777}{3.1622777}{x dup mul 8 add}\n\\psplot{-2.8284271}{2.8284271}{x dup mul 10 add}\n\\psplot{-2.449497}{2.4494897}{x dup mul 12 add}\n\\psplot{-1.4142136}{1.4142136}{x dup mul 16 add}\n\\psplot{-2}{2}{x dup mul 14 add}\n\\psplot{-4.472136}{4.472136}{x dup mul 2 sub}\n\\psplot{-4.6904158}{4.6904158}{x dup mul 4 sub}\n\\pscircle[fillstyle=solid,fillcolor=black](3,7){.075}\n\\rput(5.4,7.){$(3,7)$}\n\\psline{->}(4.6,7.)(3.14,7)\n%\\psplot{-4}{4}{1 3 div x 3 exp mul}\n\\end{pspicture}\n\n\\end{center}\n\\caption{Partial view of the \nfamily of curves $y=x^2+C$. For Example~\\ref{FirstFindCExample},\nwe needed to find the value of $C$ satisfying $f'(x)=2x$, i.e.,\n$f(x)=x^2+C$, so that $(3,7)$ was on the curve.  Note that\nthe slopes of all curves given above are the same for a given\n$x$-value, but only one passes through $(3,7)$.}  \n\\label{FigureForFirstFindCExample}\\end{figure}\n\nFinding a particular antiderivative is also very useful\nin kinematics.  For instance, if we know the velocity\nfunction $s'(t)=v(t)$, we can find the position function\n$s$ if we are given one position datum to fix the constant. \nWith the understanding that the constant is to be\ndetermined, it is often written:\n\\begin{equation}\ns(t)=\\int s'(t)\\,dt=\\int v(t)\\,dt.\n\\end{equation}\nA common datum to prescribe is that $s(0)=s_0$\n(where $s_0$ is some fixed number), but any data\nwhich ``pins down'' the function will suffice.\n\\bex Suppose $v=t^2+11t-25$, and $s(1)=4$.  Find $s(t)$.\n\n\\underline{Solution}:\n$$s(t)=\\int v(t)\\,dt=\\int\\left(t^2+11t-25\\right)\\,dt\n=\\frac{t^3}3+\\frac{11t^2}2-25t+C.$$\nUsing $s(1)=4$ we get\n$$\\frac{1^3}3+\\frac{11\\cdot1^2}2-25(1)+C=4\n\\iff \\frac13+\\frac{11}2-25+C=4,$$\nand so $C=4+25-\\frac{11}2-\\frac13=29-\\frac{35}6=\\frac{174}6-\\frac{35}6\n=\\frac{139}6.$  Finally, this gives us\n$$s(t)=\\frac{t^3}3+\\frac{11t^2}2-25t+\\frac{139}6.$$\n\\eex\n\nNow we will derive a well-known formula of physics.\n\\bex Suppose that acceleration is given by a constant, \nsay $s''(t)=a$ (where $a$ is fixed).  Suppose further\nthat $s(0)=s_0$ and $v(0)=v_0$.  Now we work ``backwards''\nfrom the acceleration towards the position function as\nfollows:\n$$v(t)=s'(t)=\\int s''(t)\\,dt=\\int a\\,dt=at+C_1.$$\n(Note that the last computation required that acceleration, $a$, be constant.)\nUsing $v(0)=v_0$, we then have \n$$a\\cdot0+C_1=v_0\\iff C_1=v_0.$$\nThis gives us the following equation, which itself is well known\nto physics students:\n\\begin{equation}v(t)=at+v_0.\\label{VelocityWithConstAccel}\\end{equation}\nNow we integrate (\\ref{VelocityWithConstAccel}):\n$$s(t)=\\int s'(t)\\,dt=\n\\underbrace{\\int v(t)\\,dt=\\int\\left(at+v_0\\right)\\,dt}_{\n(\\ref{VelocityWithConstAccel})}\n=a\\cdot\\frac{t^2}2+v_0t+C_2.$$\nFinally, using $s(0)=s_0$, we get\n$$a\\cdot\\frac{0^2}2+v_0(0)+C_2=s_0\\implies C_2=s_0.$$\nThus\n\\begin{equation}s=\\frac12at^2+v_0t+s_0.\\label{PositionWithConstAccel}\n\\end{equation}\n\\eex\nIt is important to note that (\\ref{PositionWithConstAccel})\nfollowed under the special condition that acceleration is \nconstant (such as occurs when an object is\nin freefall in a constant gravitational field, with no other \nresistance).  Nonconstant acceleration will not give\n(\\ref{VelocityWithConstAccel}) or (\\ref{PositionWithConstAccel}).\nHowever, the method for computing $v$ and $s$, given $a$, is\nthe same when $a$ is not constant:\n\\begin{enumerate}\n\\item find $\\ds{v(t)=\\int a(t)\\,dt}$, using one datum regarding velocity\n      at a particular time, to fix the constant\n       of integration;\n\\item find $\\ds{s(t)=\\int v(t)\\,dt}$, using another datum regarding\n      position at a particular time, to fix the\n      second constant of integration.\n\\end{enumerate}\nActually, two position data can fix the constants as well, since\nwe can just carry the first constant into the second calculation,\nand then we will have two equations with two unknowns (the\nconstants of integration), and then solve for both constants.\n\n\\bex Suppose $a(t)=3t^2$, $s(0)=3$ and $s(1)=5$.  Find $v(t)$ and \n$s(t)$.\n\n\n\\underline{Solution}:\nFirst we will find $v(t)$, to the extent that we can:\n$$v(t)=\\int a(t)\\,dt=\\int 3t^2\\,dt =3\\cdot\\frac{t^3}{3}+C_1=t^3+C_1.$$\nNext we find the form of $s(t)$:\n$$s(t)=\\int v(t)\\,dt=\\int\\left(t^3+C_1\\right)\\,dt=\\frac{t^4}4+C_1t+C_2.$$\nSo we know that $s(t)=\\frac14t^4+C_1t+C_2$, for some $C_1,C_2$.\nUsing the facts that $s(0)=3$ and $s(1)=5$, we get the\nfollowing system of two equations in two unknowns:\n$$\\left\\{\\begin{array}{rcrcrcr}\n\\frac{0^4}4&+&C_1(0)&+&C_2&=3\\\\\n\\frac{1^4}4&+&C_1(1)&+&C_2&=5\n\\end{array}\\right.\n\\iff \\left\\{\\begin{array}{rcrcr}&&C_2&=3\\\\ C_1&+&C_2&=\\frac{19}4\n\\end{array}\\right.\n$$\nFrom the second form of the system, we see $C_2=3$,\n and so $C_1=\\frac{19}4-3=\\frac{7}4$.  \nPutting all this together we first get\n$$s(t)=\\frac{t^4}4+\\frac{7t}4+3,$$\nfrom which we can calculate $v(t)=s'(t)$ (or just read $v(t)$\noff of our first integral calculation, inserting $C_1=\\frac74$) to get\n$$v(t)=t^3+\\frac74.$$ \n\\eex \n\\subsection{First Trigonometric Rules\\label{FirstTrigRulesSubsection}}\nWith every derivative formula for functions comes an analogous\nantiderivative formula, which is more or less the derivative\nformula in reverse.  Sometimes the reverse is more obvious than\nother times.  For instance, the power rule formula for derivatives is sometimes\nseen algorithmically as ``{\\it multiply} by the exponent (`bring\nthe power down') and {\\it decrease} the exponent by one,''\nas in\n$$\\frac{d}{dx}\\left[x^n\\right]=n\\cdot x^{n-1}.$$  \nIf we are careful to reverse the process, we need to do\nthe inverse steps in reverse order:  {\\it increase} the exponent\nby one, and then {\\it divide} by the exponent.  That is the\nessence of (\\ref{IntegralPowerRule}):\n$$\\int x^n\\,dx=\\frac{x^{n+1}}{n+1}+C.$$  \nBy other sophisticated arguments, in the next section we\nwill see a kind of reverse chain rule.  A bit later in the text\nwe will also come across what can be loosely called a\nreverse product rule called integration by parts,\nalthough there really is no good analog of the product rule\nwith integrals {\\it per se}.\\footnote{%\n%%%%%%%%%  FOOTNOTE\nIntegration by parts is really an integration technique\nwhich takes advantage of the product rule for derivatives---or\nmore precisely a permutation of the product rule for \nderivatives---but is not itself a product rule for integrals;\nit does not by itself give a formula for\n$\\int f(x)g(x)\\,dx$.\nInstead it gives a formula which can be summarized by\n$$\\int f(x)g'(x)\\,dx=f(x)g(x)-\\int g(x)f'(x)\\,dx,$$\nwhich follows from integrating---i.e., \napplying $\\int(\\cdots)\\,dx$ to both sides of---the following\nrearrangement of the product rule,\n$$f(x)g'(x)=[f(x)g(x)]'-g(x)f'(x).$$\nBecause the product rule for derivatives is what makes the\ntechnique of integration by parts valid, many authors describe\nit as a kind of analog of the product rule, though again,\nit is not a direct formula for the integral of a product\nlike we had for the derivative of a product.\n\nStill, it is a very useful technique which we will spend some time\ndeveloping in a later chapter, when we have other methods to draw upon\nfor the inevitable intermediate computations.\n%%%%%%%%%%%%%%  END FOOTNOTE\n} \\footnote{\nThere will be still several other techniques which are not\nat all simple reverses of derivative rules, and for which checking\nby differentiating (computing the derivative of) the answer\nis as difficult as, or more difficult than, the integration\ntechnique itself.  Those sophisticated techniques are for later chapters.\n}\n\nThe formulas presented in this subsection are immediate\nconsequences of our trigonometric derivative formulas.\nFor instance, we have the following pair of formulas:\n\\begin{align*}\n\\frac{d\\sin x}{dx}=\\cos x&\\iff \\int\\cos x\\,dx=\\sin x+C,\\\\\n\\frac{d\\cos x}{dx}=-\\sin x&\\iff \\int(-\\sin x)\\,dx=\\cos x+C.\\end{align*}\nThis second integration formula is more awkward than necessary,\nsince it is more likely we would like an antiderivative for \n$\\sin x$ directly.  We could multiply both sides by $-1$, and\nrename the new constant $C$, or just notice that\n$\\frac{d}{dx}(-\\cos x)=\\sin x$, to come to the formula\n$$\\int \\sin x\\,dx=-\\cos x+C.$$\nAs before, we can always check these by taking the derivative\nof the right-hand side.  Recalling our six basic trigonometric\nderivative formulas, and making adjustments for negative sign\nplacements as above, we have the following pairs of \nderivative/integral formulas:\n\\begin{alignat}{5}\n\\frac{d\\sin x}{dx}&=\\cos x&\\qquad&\\iff\\qquad&&\\int\\cos x\\,dx&&=\\sin x+C,\n      \\label{IntOfCosine}\\\\\n\\frac{d\\cos x}{dx}&=-\\sin x&&\\iff&&\\int\\sin x\\,dx&&=-\\cos x+C,\n      \\label{IntOfSine}\\\\\n\\frac{d\\tan x}{dx}&=\\sec^2x&&\\iff&&\\int\\sec^2x\\,dx&&=\\tan x+C,\n      \\label{IntOfSecSquared}\\\\\n\\frac{d\\cot x}{dx}&=-\\csc^2x&&\\iff&&\\int\\csc^2x\\,dx&&=-\\cot x+C,\n      \\label{IntOfCscSquared}\\\\\n\\frac{d\\sec x}{dx}&=\\sec x\\tan x&&\\iff&&\\int\\sec x\\tan x\\,dx&&=\\sec x+C,\n      \\label{IntOfSecTan}\\\\\n\\frac{d\\csc x}{dx}&=-\\csc x\\cot x&&\\iff&&\\int\\csc x\\cot x\\,dx\n                                    &&=-\\csc x+C.\n      \\label{IntOfCscCot}\n\\end{alignat}\nWith these and our previous rules, we have some limited\nability to compute integrals involving trigonometric functions.\n\\bex Consider the following integrals:\n\\begin{itemize}\n\\item $\\ds{\\int\\left[x^2+\\sin x-\\frac1x\\right]\\,dx=\\frac{x^3}3-\\cos x+\\ln|x|+C\n            }$\n\\item $\\ds{\\int\\frac{\\sin x}{\\cos^2x}\\,dx\n      =\\int\\left[\\frac1{\\cos x}\\cdot\\frac{\\sin x}{\\cos x}\\right]\\,dx\n      =\\int\\sec x\\tan x\\,dx=\\sec x+C}$\n\\item $\\ds{\\int\\cos w\\,dw=\\sin w+C}$\n\\item $\\ds{\\int\\tan^2x\\,dx=\\int\\left(\\sec^2x-1\\right)\\,dx=\\tan x-x+C}$.\n\\end{itemize}\n\\eex\nIn fact we are fortunate if an integral has the kind of trigonometric\nform which is just the derivative of one of the six basic trigonometric\nfunctions.  When it is the case, it often requires some rewriting,\nas in two of the integrals above.\n\\subsection{Integrals Yielding Inverse Trigonometric Functions}\n\n\n\\begin{align}\n\\int\\frac1{\\sqrt{1-x^2}}\\,dx&=\\sin^{-1}x+C,\\label{IntGivesArcsine}\\\\\n\\int\\frac1{x^2+1}\\,dx&=\\tan^{-1}x+C,\\\\\n\\int\\frac1{x{\\sqrt{x^2-1}}}\\,dx&=\\sec^{-1}|x|+C.\\label{IntGivesArcsecant}\n\\end{align}\nNote how we only employ three of the six arctrigonometric functions\nin (\\ref{IntGivesArcsine})--(\\ref{IntGivesArcsecant}).  In fact\nthese are sufficient.\nRecall for instance\nthat the arccosine and arcsine have derivatives which differ by the \nfactor $-1$.  For simplicity, it is much more commonly written \n$\\int\\frac{-1}{\\sqrt{1-x^2}}\\,dx=-\\sin^{-1}x+C$, rather than\nusing the arccosine function as the antiderivative,\ni.e.,  $\\int\\frac{-1}{\\sqrt{1-x^2}}\\,dx=\\cos^{-1}x+C$\nthough the latter is certainly legitimate.  Indeed,\nsince $\\sin^{-1}x+\\cos^{-1}x=\\frac{\\pi}2$, we see\n$\\cos^{-1}x$ and $-\\sin^{-1}x$ differ by a constant.  In fact\none could rewrite (\\ref{IntGivesArcsine}) as\n$\\int\\frac1{\\sqrt{1-x^2}}\\,dx=-\\cos^{-1}x+C$.  The choice can\nsometimes depend upon which range of angles we wish the antiderivative\nfuction to output, though for this case\nwe can adjust that with the constant $C$.\n\n\n\nSimilarly one usually writes $\\int\\frac{-1}{x^2+1}\\,dx=-\\tan^{-1}x+C$, \nthough $\\cot^{-1}x+C$ (for a ``different'' $C$) is also legitimate.\nAnalogously for arcsecant and arccosecant; we usually avoid the arccosecant\nfunction as an antiderivative.\n  \nBut for these last two there is another small complication.  Note how\nEquation (\\ref{IntGivesArcsecant}) has the absolute value on the \nantiderivative rather than the $x$-term of the denominator in the integrand,\nso it does not appear to be just a restatement of the derivative rule\nfor the arcsecant: $\\frac{d}{dx}\\sec^{-1}x=\\frac1{|x|\\sqrt{x^2-1}}$.\nTo see that (\\ref{IntGivesArcsecant}) is still correct,\nnote that $|x|=x$ if $x>0$, and $|x|=-x$ if $x<0$.  Taking the derivative of\n$\\sec^{-1}|x|$ for those two cases, as we did in the computation\nof $\\frac{d}{dx}\\ln|x|$  (see page~\\pageref{ProofOfDerivLn|X|Stuff})\nwe can see that we do get \n$\\frac1{x\\sqrt{x^2-1}}$ both times.  But it should also be noted that,\nwhile not often seen, it would be legitimate to have the \nabsolute value inside, rather than outside, the integral, as \nin\n$\\int\\frac1{|x|\\sqrt{x^2-1}}\\,dx=\\sec^{-1}x+C$.\\footnote{%\n%%% FOOTNOTE\nTo further complicate things, we could notice that\n$\\sec^{-1}x=\\cos^{-1}\\frac1x$, so it can occur that computational\nsoftware will output an arccosine function, as \nin $\\int\\frac1{x\\sqrt{x^2-1}}\\,dx=\\cos^{-1}\\frac1{|x|}+C$,\nand then this can be rewritten (with a ``different $C$'')\n$\\int\\frac1{x\\sqrt{x^2-1}}\\,dx=-\\sin^{-1}\\frac1{|x|}+C$.\nThe software might also \nomit the absolute values, theoretically assuming $x>0$.\nStill, the standard written\ncomputation would output the expected $\\sec^{-1}|x|+C$.\n%%% END FOOTNOTE\n}\n\nBefore listing some examples, we last make note of the convention\nmentioned earlier (see page~\\pageref{UsingdxAsAFactor}), of\nusing $dx$ as a factor.  So our new integration formulas\nare often written:\n\\begin{align*}\n\\int\\frac{dx}{\\sqrt{1-x^2}}&=\\sin^{-1}x+C,\\\\\n\\int\\frac{dx}{x^2+1}&=\\tan^{-1}x+C,\\\\\n\\int\\frac{dx}{x\\sqrt{x^2-1}}&=\\sec^{-1}|x|+C.\n\\end{align*}\n\nThe above formulas will become much more important in future sections.\nFor now it is important to realize that these particular function forms \ndo have (relatively) simple antiderivatives.  At this point in the \ndevelopment we are not prepared to make full use of these forms, \nbut we need to be aware of them.  Sometimes a simple manipulation\nproduces a function containing one of these forms.\n\n\\bex Compute $\\ds{\\int\\frac{x^2}{x^2+1}\\,dx}$.\n\n\\underline{Solution}: With the aid of long division, we can see that\\footnote{%\n%%% FOOTNOTE\nA popular alternative \ntechnique for a fraction like that in our integrand is to \nstrategically add and subtract a term in the numerator, which\nproduces a term in the numerator identical to (or a multiple of)\nthe denominator,\nand the extra term, from which we can make two fractions:\n$$\\frac{x^2}{x^2+1}=\\frac{x^2+1-1}{x^2+1}\n      =\\frac{x^2+1}{x^2+1}-\\frac1{x^2+1}\n      =1-\\frac1{x^2+1}.$$\nWhile this is a very useful technique for such a simple case, \nit does not easily extend to more complicated cases.  Long division---when\nthe degree of the numerator is at least that of the denominator---is more\nstraightforward.  However, we will eventually have need of a technique\nsimilar to that given above in this footnote, though that setting will be \nmuch more complicated and we will need all other advanced integration\ntechniques to make full use of it.\n%%% END FOOTNOTE\n}\n$$\\frac{x^2}{x^2+1}=1-\\frac1{x^2+1},$$\nand so\n$$\\int\\frac{x^2}{x^2+1}\\,dx\n=\\int\\left[1-\\frac1{x^2+1}\\right]\\,dx\n=x-\\tan^{-1}x+C.$$\n\n\\eex\n\n\\subsection{Integrals Yielding Exponential Functions}\n\nTo finish our list of integrals which arise from differentiation\nformulas, we list those yielding exponential functions.  Below\n$a\\in(0,1)\\cup(1,\\infty)$.\n\n\\begin{alignat}{2}\n&\\int e^x\\,dx&&=e^x+C,\\label{IntOfE^X}\\\\\n&\\int a^x\\,dx&&=\\frac{a^x}{\\ln a}+C.\\label{IntOfA^X}\\end{alignat}\nThe first of these, (\\ref{IntOfE^X}) is the more obvious.\nTo see (\\ref{IntOfA^X}), recall that $\\frac{d\\,a^x}{dx}=a^x\\ln a$,\nand that $\\ln a$ is a constant.\nThus\n$$\\frac{d}{dx}\\left[\\frac{a^x}{\\ln a}\\right]\n=\\frac1{\\ln a}\\cdot\\frac{d\\,a^x}{dx}\n=  \\frac1{\\ln a}\\cdot a^x\\ln a=a^x,\\qquad\\text{q.e.d.}$$\n\\bex We compute some antiderivatives involving these.\n\\begin{itemize}\n\\item $\\ds{\\int\\left[1+x+e^x\\right]\\,dx=x+\\frac{x^2}2+e^x+C}$,\n\\item $\\ds{\\int 2^x\\,dx=\\frac{2^x}{\\ln2}+C}$,\n\\item $\\ds{\\int\\frac{2^x-3^x}{5^x}\\,dx\n        =\\int\\left[\\frac{2^x}{5^x}-\\frac{3^x}{5^x}\\right]\\,dx\n        =\\int\\left[\\left(\\frac25\\right)^x-\\left(\\frac35\\right)^x\\right]\\,dx\n        =\\frac{\\left(\\frac25\\right)^x}{\\ln\\frac25}\n         -\\frac{\\left(\\frac35\\right)^x}{\\ln\\frac35}+C}$,\n\\item $\\ds{\\int\\!\\left(1+3^x\\right)^2\\,dx\n        =\\int\\left[1+2\\cdot3^x+3^{2x}\\right]\\,dx\n        =\\int\\left[1+2\\cdot3^x+9^x\\right]\\,dx\n        =x+\\frac{2\\cdot3^x}{\\ln 3}+\\frac{9^x}{\\ln 9}+C}$.\n\\end{itemize}\nIn the last integral, we used the fact that\n$\\left(3^x\\right)^2=3^{x\\cdot2}=3^{2\\cdot x}=\\left(3^2\\right)^x=9^x$.\n\\eex\n\n\n\n\n\n\n\n\n\n\n\n\\newpage\n\\section{Substitution With Power Rule\\label{FirstSubstitutionSection}}\nSubstitution in general is the most important of the integrating\ntechniques, finding its way into the other techniques as well.\nWhile we introduce it here, for now we limit the scope to power rules.\n\nBefore looking at this method formally, consider the following\nantiderivative statements, each of which refer to the \nsame power rule (perhaps most familiar in the first case):\n\\begin{align}\n\\int x^2\\,dx&=\\frac{x^3}3+C,\\notag\\\\\n\\int u^2\\,du&=\\frac{u^3}3+C,\\notag\\\\\n\\int (\\sin x)^2\\,d(\\sin x)&=\\frac{(\\sin x)^3}3+C.\n     \\label{DumbSubExampleSin^2X--W.R.T.SinX}\n\\end{align}\nThe last integral is simply asking for an antiderivative of\n$(\\sin x)^2$ with respect to $\\sin x$.  Indeed, we can check the\nanswer as before:\n$$\\frac{d}{d\\sin x}\\left[\\frac13(\\sin x)^3\\right]\n    =\\frac13\\cdot 3(\\sin x)^2=(\\sin x)^2,$$\nas we expect.  Of course we usually take derivatives and antiderivatives\nwith respect to a variable, and not a function.  However the\nintegral in (\\ref{DumbSubExampleSin^2X--W.R.T.SinX})\nis not so unlikely to be occur as one might think. \nRecall that $df(x)=f'(x)\\,dx$\nis the definition of the differential (see\n(\\ref{EquationDefiningDifferentials}), \npage~\\pageref{EquationDefiningDifferentials}).  Thus\n$d\\sin x=\\cos x\\,dx$, and the integral\nin (\\ref{DumbSubExampleSin^2X--W.R.T.SinX}) can be written instead\n$$\\int(\\sin x)^2\\cos x\\,dx=\\int(\\sin x)^2\\frac{d\\sin x}{dx}\\,dx\n                          =\\int(\\sin x)^2\\,d\\sin x\n                          =\\frac13(\\sin x)^3+C.$$\nIndeed, it is not hard to see that the chain rule gives\nus $\\frac{d}{dx}\\left[\n\\frac13(\\sin x)^3\\right]=\\frac13\\cdot3(\\sin x)^2\\cos x\n=\\sin^2x\\cos x$. \n\nIn this section we will concentrate on integrals of the form\n\\begin{equation}\\int u^n\\,du=\\left\\{\\begin{array}{lclcl}\n             \\frac1{n+1}\\cdot u^{n+1}&+&C&\\qquad&\\text{if }n\\ne1,\\\\ \\\\\n             \\ln|u|&+&C&&\\text{if }n=-1.\\end{array}\\right.\n             \\label{PowerRuleForIntegrationInU}\n       \\end{equation}\nAs anticipated in the discussion above, the content of the differential\n$du$ may be more expansive than what we may expect from a single variable.\nThe point of this section is to recognize when we have the form\n(\\ref{PowerRuleForIntegrationInU}), and how to go about rewriting the\nintegral into the proper form.  \n\nThe reader should be forwarned:  this method requires a fair amount \nof practice.  It is not a simple algorithm. For each problem, the\nreader has to decide which substitution will produce an integral\nwhich can be computed with known rules.  Here we will limit ourselves\nto the power rule (\\ref{PowerRuleForIntegrationInU}), but\nin subsequent sections we will delve into many other rules, and\nit is not always obvious which rule should be used for a given integral.\nWith practice one learns to look for clues, and anticipate what\nwill occur several steps ahead, to see if there is indeed an\nintegration rule which can apply.\\footnote{%%%\n%%% FOOTNOTE\nIn fact, often there is no rule which will produce an antiderivative,\nand then some approximation scheme will be necessary.  Still, it is most\ndesirable to have an exact antiderivative, and we can find one\noften enough that it is well worth studying these techniques.}\n\n\\subsection{The Technique}\nHere we will look at some of the simpler problems of integration by\nsubstitution.  As we proceed, several observations will be made\nregarding the method.\n\n\\bex Compute the indefinite integral $\\ds{\\int (x^2+1)^7\\cdot2x\\,dx}$.\n\n\\underline{Solution}: The technique is to introduce a new variable,\n$u$, with which we can write the original integral in a simpler form.\nWe also have to take into account what will be the new differential,\nnamely $du$:\n\\begin{align*}\nu&=x^2+1\\\\\n\\implies\\qquad du&=2x\\,dx.\n\\end{align*}\n(Recall that if $u$ is a function of $x$, then $du=u'(x)\\,dx$,\nconsistent with $\\frac{du}{dx}=u'(x)$.)  Using this information, we can\nreplace all the terms in the original integral: the $(x^2+1)^7$\nbecomes $u^7$, and the terms $2x\\,dx$ collectively become $du$\n(see the above implication arrow).  Thus\n$$\\int(x^2+1)^7\\cdot\\underline{2x\\,dx}=\\int u^7\\,\\underline{du}\n=\\frac18\\,u^8+C.$$\nThis is all true, but {\\bf we} introduced $u$, while the\noriginal question asked for an antiderivative with respect to $x$.\nWe only need to replace $u$ in the final answer, using again\n$u=x^2+1$.  Summarizing,\n$$\\int(x^2+1)^7\\cdot{2x\\,dx}\n=\\int u^7\\,{du}=\\frac18\\,u^8+C=\\frac18(x^2+1)^8+C.$$\n\\label{FirstUSubExample}\\eex\n\nNote that we can check our answer in the above example by\ncomputing the derivative of the answer (using the \nchain rule), yielding $\\frac{d}{dx}\\left[\\frac18(x^2+1)^8\\right]=\n\\frac18\\cdot8(x^2+1)^7\\cdot2x=\n(x^2+1)^7\\cdot2x$ as hoped.  \nIn fact, integration by substitution, at least in its\nsimplest forms, is often called a type of reverse chain rule.\nIndeed, we can rewrite (\\ref{PowerRuleForIntegrationInU}) as follows:\n\\begin{equation}\\int u^n\\,du=\\int u^n\\cdot\\left(\\frac{du}{dx}\\right)\\,dx\n            =\\int \\left[u^n\\cdot\\frac{du}{dx}\\right]\\,dx\n=\\left\\{\\begin{array}{lcll}\n             \\frac1{n+1}\\cdot u^{n+1}&+&C\\quad&\\text{if }n\\ne1,\\\\ \\\\\n             \\ln|u|&+&C&\\text{if }n=-1.\\end{array}\\right.\n\\label{IntPowerRuleWithUSubstitution}\\end{equation}\nTo see that this is correct, if we take the derivative of \nthe answers {\\it with respect to $x$}, we see that we do indeed\nget $u^n\\cdot\\frac{du}{dx}$ from the chain rule.    \n\nIn short, with integration by substitution we try to pick some\nfunction we call $u$, so that\n\\begin{enumerate}\n\\item a main part of the integrand can be written as a simple function\n      of $u$---one for which we know the antiderivative with respect to \n      $u$---and, equally crucial, so that\n\\item the remaining variable terms of the integral can be\n      safely absorbed in $du$ (except for multiplicative constants,\n      which we will see add only a slight complication).\n\\end{enumerate}\nIf these are both satisfied, our substitution of $u$ and $du$ terms\ngives us a new, simple integral (entirely in terms of $u$ and $du$!).\n\nWhen working such a problem (as opposed to, say, {\\it publishing} a problem\nand solution for professional consumption),\na useful format is to (1) write the original integral, (2) write the\nsubstitution function $u$, with its differential $du$ both on different\nlines than the original integral, (3) write the new form of\nthe original integral, i.e.,  in $u$ \nand $du$,  (4) compute the antiderivative of this new integral\nin $u$ as a continuation of the first step,\nand (5) resubstitute to arrive at the antiderivative in $x$.\nHence a typical homework-style presentation of \nExample~\\ref{FirstUSubExample}\nmight look like the following (with the choice of\n$u$ and resulting $du$ offset and below the original integral):\n\n\\begin{align*}\n\\int(x^2+1)^7\\cdot\\underline{2x\\,dx}\n         &=\\int u^7\\,\\underline{du}=\\frac18u^8+C=\\frac18(x^2+1)^8+C\\\\\n\\left.\\begin{aligned}\nu&=x^2+1\\\\ du&=\\underline{2x\\,dx}\\end{aligned}\\right|&\\end{align*}\nThat part of the integral which we hope to absorb into $du$ is underlined\nin the original integral, the computation of $du$, and the corresponding\nterm in the new integral.  The rest of the integral was just \n$(x^2+1)^7=u^7$. In fact, when we choose $u$ so that a major\nportion of the integral can be written $u^n$, then any\nother factors which are variable, along with the differential\n$dx$, must be absorbed in $du$ or the substitution will fail\n(because the resulting integral will contain both $x$ and $u$\nand no antiderivative rules will apply).\nWe will continue to use this kind of spatial organization \nwhen we integrate by substitution in the examples below.\n\\bex Compute the indefinite integral $\\ds{\\int\\sin^2x\\cos x\\,dx}$.\n\n\\underline{Solution}: Note that this integral can be written\n$\\ds{\\int(\\sin x)^2\\cos x\\,dx}$.  Now we proceed:\n\\begin{align*}\n\\int\\sin^2x\\ \\underline{\\cos x\\,dx}&=\\int u^2\\,\\underline{du}=\\frac13u^3+C\n                                          =\\frac13\\sin^3x+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\sin x\\\\\n&\\implies&du&=\\underline{\\cos x\\,dx}\n\\end{alignedat}\\right|&\\end{align*}\n\\eex\n\nBefore continuing we will make a very minor change to the integral\nin the first example (Example~\\ref{FirstUSubExample},\npage~\\pageref{FirstUSubExample}), \nand show a simple way to extend our method to handle this.\n\n\\bex Compute $\\ds{\\int x(x^2+1)^7\\,dx}$.\n\n\\underline{Solution}: Here we will make the same substitution\nas before, but the $du$ will have an extra factor of 2.  Since\nconstant factors are relatively easy to handle in derivative\nand antiderivative problems in general, we should not expect\nthis extra factor of 2 to cause much difficulty.  It \nwill simply mean one extra step in the  substitution\ncomputations.\\footnote{%\n%%% FOOTNOTE\nThere is another method used by some texts to handle a \nproblem such as this, which is to simply introduce the\nneeded factor of 2 in the integral to complete the\ndifferential $du=2x\\,dx$, and compensate for the insertion of\nthe new factor by\nsimultaneously inserting a factor of $\\frac12$, which\nis simply carried through the rest of the calculation:\n$$\\int x(x^2+1)^7\\,dx=\\int\\frac12\n \\underbrace{(x^2+1)^7}_{u^7}\\cdot\\underbrace{2x\\,dx}_{du}\n =\\frac12\\int u^7\\,du=\\frac12\\cdot\\frac18u^+C=\\frac1{16}(x^2+1)^8+C,$$\nwhere again $u=x^2+1$, $du=2x\\,dx$.\n\nThis method is appealing because one rewrites the integrand into a form\nwhere it is, more or less, clearly a derivative of a chain rule function\n(perhaps multiplied by a constant, as with $\\frac12$ here).\n\nWe will avoid this method because, though it is not so challenging for\nsimpler problems, it quickly becomes unreasonably difficult if an\nintegral is complicated.  Furthermore, the method presented in this\ntext---in the author's opinion---makes for much \nbetter preparation for more advanced methods,\nsuch as trigonometric substitution and integration by parts.\n%%%% END FOOTNOTE\n}\n\n\\begin{align*}\n\\int \\underline{x}(x^2+1)^7\\,\\underline{dx}\n         &=\\int u^7\\cdot\\underline{\\frac12\\,du}=\\frac12\\cdot\n                \\frac18u^8+C=\\frac1{16}(x^2+1)^8+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=x^2+1\\\\\n&\\implies& du&=2\\,\\underline{x\\,dx}\\\\ &\\implies&\\frac12du&=\\underline{x\\,dx}\n\\end{alignedat}\\right|\\qquad&\\end{align*}\n\\label{IntX(X^2+1)^7dxExample}\\eex\n\nThis time the extra nonconstant and differential terms of the original\nintegral were, collectively, $x\\,dx$.  Though that product is not\nexactly $du$, it is a constant times $du$. In our substitution\nwe took an extra step and solved, again collectively, for $x\\,dx=\\frac12du$.\n\n\nThe preceding example shows that we need to be flexible when looking\nfor a possible power rule application.  Not every integral where\nwe can use the power rule will be of the strict form\n(\\ref{IntPowerRuleWithUSubstitution}), \npage~\\pageref{IntPowerRuleWithUSubstitution}.  Indeed, we need\nto be especially vigilant to notice that an integral may be\nof the form\n\\begin{equation}\n\\int k\\cdot u^n\\,du=\\int k\\cdot u^n\\cdot\\left(\\frac{du}{dx}\\right)\\,dx.\n\\label{IntsWhichAreConstantsTimesChainRuleFormOfPowerRule}\n\\end{equation}\nSo when we make a substitution, we try not to be distracted by\nextra or missing multiplicative \nconstants, as they will work themselves out in\nthe substitution and final integration steps.\n\n\n\n\n\\bex Compute $\\ds{\\int x^3\\cos^5x^4\\sin x^4\\,dx}$.\n\n\\underline{Solution}: It is perhaps more obvious how to proceed\nif we rewrite the integral in the form\n$\\ds{\\int x^3(\\cos x^4)^5\\sin x^4\\,dx}$.  Then we see that\nthe $u^n$ term will be $(\\cos x^4)^5=u^5$, where $u=\\cos x^4$.\nNext we need to see if $du$ can absorb the other nonconstant terms:\n\\begin{align*}\n\\int \\underline{x^3}\\cos^5x^4\\underline{\\sin x^4\\,dx}\n &=\\int u^5\\underline{\\left(-\\frac14\\right)\\,du}\n =-\\frac14\\cdot\\frac16u^6+C=-\\frac1{24}(\\cos x^4)^6+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\cos x^4\\\\\n&\\implies&du&=-\\underline{\\sin x^4}\\cdot 4\\,\\underline{x^3\\,dx}\\\\\n&\\implies&-\\frac14du&=\\underline{x^3\\sin x^4\\,dx}\\end{alignedat}\\right|&\n\\end{align*}\n\\eex\nWe should point out that the method above would not have\nworked without {\\it both} the $x^3$ and the $\\sin x^4$\nterms in the integral, for the $du$ would have \nvariable terms not in the orginal integral.\n\nAlso, it is possible to compute the integral in the previous\nby using two substitution steps instead of one.\nFor instance, a student recognizing that $x^4$, and a multiple\nof its derivative in the form of $x^3$, both appear, might \nfirst make a substitution of the form $u=x^4$:\n\\begin{align*}\n\\int \\underline{x^3}\\cos^5x^4\\sin x^4\\,\\underline{dx}&=\n         \\int\\cos^5u\\,\\sin u\\,\\underline{\\frac14\\,du}\n =\\frac14\\int\\cos^5u\\,\\sin u\\,du.\\\\\n\\left.\\begin{alignedat}{2}\n&& u&=x^4\\\\\n&\\implies&du&=4\\,\\underline{x^3\\,dx}\\\\\n&\\implies&\\frac14du&=\\underline{x^3\\,dx}\\end{alignedat}\\right|&\n\\end{align*}\nAt this point, we have a simpler integral which itself requires a\nsubstitution:\n\\begin{align*}\n\\frac14\\int\\cos^5u\\,\\underline{\\sin u\\,du}&=\\frac14\\int w^5\\underline{(-dw)}\n =-\\frac14\\cdot\\frac16 w^6+C=-\\frac1{24}(\\cos u)^6+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&w&=\\cos u\\\\\n&\\implies&dw&=-\\underline{\\sin u\\,du}\\\\\n&\\implies&-dw&=\\underline{\\sin u\\,du}\\end{alignedat}\\right|&\\end{align*}\nOf course this gives the answer in terms of $u$, so we substitute\nback again, in terms of $x$.  Summarizing,\n$$\\int x^3\\cos^5x^4\\sin x^4\\,dx=\\cdots=\n    -\\frac1{24}w^6+C=-\\frac1{24}\\cos^6u+C\n                =-\\frac1{24}\\cos^6x^4+C.$$\nThe second approach is longer, but it has the advantage that we\nare not trying to rewrite the integral in one, all-encompassing\n(and thus more complicated)\nsubstitution step. Indeed it is sometimes desirable to simplify an \nintegral with substitution even if the resulting integral cannot be \nevaluated immediately.  With most examples we will use the first\nmethod, but the student working problems should be aware that\nthe option of successive substitutions is perfectly valid.\n\nNext we look at a few very common types of examples where the\npower of $n$ is $1/2$, $-1$ and $-2$.  These appear often enough that\nit is worth some effort to remember them specifically.\n\n\\bex Compute $\\ds{\\int\\frac{x}{\\sqrt{x^2-9}}\\,dx}$.\n\n\\underline{Solution} Here we will take $u=x^2-9$, since the $du=2x\\,dx$\ncan absorb both the $dx$ and the extra factor of $x$:\n\\begin{align*}\n\\int\\frac{\\underline{x}}\n  {\\sqrt{x^2-9}}\\,\\underline{dx}&=\\int u^{-1/2}\\cdot\\underline{\\frac12\\,du}\n =\\frac12\\cdot2{u}^{1/2}+C=\\sqrt{x^2+1}+C.  \\\\\n\\left.\\begin{alignedat}{2}&&u&=x^2-9\\\\ &\\implies&du&=2\\,\\underline{x\\,dx}\\\\\n       &\\implies&\\frac12\\,du&=\\underline{x\\,dx}\\end{alignedat}\\right|&\n\\end{align*}\n\\eex\n\\bex Compute $\\ds{\\int\\frac{\\sin x}{\\cos x}\\,dx}$.\n\n\\underline{Solution}:  Here we will take $u=\\cos x$, since\n$du=-\\sin x\\,dx$ will absorb the other terms.  \n\n\\begin{align*}\n\\int\\frac{{\\sin x}\\,dx}{\\cos x}\n &=\\int\\frac1{u}(-du)=-\\ln|u|+C=-\\ln|\\cos x|+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\cos x\\\\\n&\\implies&du&=-\\underline{\\sin x\\,dx}\\\\\n&\\implies&-du&=\\underline{\\sin x\\,dx}\\end{alignedat}\\right|&\n\\end{align*}\n\n\nNote that\nif we instead took $u=\\sin x$, then $du=\\cos x\\,dx$, but $\\cos x$ is not\na {\\bf multiplicative} factor in the original integral; the desired factor is \n$\\frac1{\\cos x}$, which is not contained in the $du$ term\nif $u=\\sin x$.\n\\eex\nIt should be remembered that checking these antiderivatives is as\nsimple as computing the derivative of the answer.  Here\n$$\\frac{d}{dx}\\left[-\\ln|\\cos x|\\right]=\n   -\\frac{1}{\\cos x}\\cdot\\frac{d}{dx}\\cos x\n   =-\\frac{1}{\\cos x}(-\\sin x)=\\frac{\\sin x}{\\cos x},$$\nas we hope. Of course our original integrand, and the\nderivative above, can both be written $\\tan x$.\n\n Note that we can write\n$-\\ln|\\cos x|=\\ln\\left|(\\cos x)^{-1}\\right|=\\ln|\\sec x|$,\nso many calculus books contain the integration formula\n\\begin{equation}\\int\\tan x\\,dx=\\ln|\\sec x|+C.\\label{FirstAntiForTanGiven}\n\\end{equation}\n(It is also interesting to ``fill in the dots''\nfor the computation $\\frac{d}{dx}|\\sec x|=\\cdots=\\tan x$,\nverifying (\\ref{FirstAntiForTanGiven}).\nSee also Exercise~\\ref{IntOfSecXTanX/SecXForFun}, \npage~\\pageref{IntOfSecXTanX/SecXForFun}.)\n\n\\bex Compute $\\ds{\\int\\frac{e^{3x}}{(e^{3x}+4)^2}\\,dx}$.\n\n\\underline{Solution}:\nHere we note that the numerator of the integrand, namely $e^{3x}$, is\nthe derivative of $e^{3x}+4$, except for a multiplicative constant.\nThus we will let $u=e^{3x}+4$:\n\\begin{align*}\n\\int\\frac{e^{3x}}{(e^{3x}+4)^2}\\,dx&\n  =\\int\\frac1{u^2}\\,\\cdot\\frac13\\,du\n  =\\frac13\\int u^{-2}\\,du =\\frac13\\cdot(-1)u^{-1}+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=e^{3x}+4\\\\\n&\\implies&du&=\\underline{e^{3x}}\\cdot3\\underline{dx}\\\\\n&\\implies&\\frac13\\,du&=\\underline{e^{3x}\\,dx}\n\\end{alignedat}\\right|&=-\\frac13(e^{3x}+4)^{-1}+C \n                        =\\frac{-1}{e^{3x}+4}+C.\n\\end{align*}\n\n\n\\eex\n\nAt this point we notice three common forms of integration by\nsubstitution:\n\\begin{align}\n\\int\\frac{u'(x)}{\\sqrt{u(x)}}\\,dx&=2\\sqrt{u(x)}+C,\\\\\n\\int\\frac{u'(x)}{u(x)}\\,dx&=\\ln|u(x)|+C,\\\\\n\\int\\frac{u'(x)}{[u(x)]^2}\\,dx&=\\frac{-1}{u(x)}+C.\n\\end{align}\nIn all three cases, $u'(x)\\,dx=du$, and we have simple power\nrules.  In the first and third cases there are\nmultiplicative constants which occur.  There is no real\nneed to memorize these, but they occur often enough that \ntheir ``mechanics'' should become familiar.  For that\nreason these three results can become, if not memorized, \nthen at least easily cited.\n\nThe method also works for cases where the $du$ term is \njust a constant multiple of $dx$:\n%\\bex Compute $\\ds{\\int\\sec5x\\tan5x\\,dx}$.\n%\n%\\underline{Solution}: Here we will let $u=5x$:\n%\\begin{align*}\n%\\int\\sec5x\\tan5x\\,dx&=\\int\\sec u\\tan u\\,\\frac15\\,du\n%                    =\\frac15\\sec u+C=\\frac15\\sec5x+C.\\\\\n%  \\left.\\begin{alignedat}{2}\n%    && u&=5x\\\\\n%    &\\implies&du&=5\\,\\underline{dx}\\\\\n%    &\\implies&\\frac15\\,du&=\\underline{dx}\n%   \\end{alignedat}\\right\\}&\n%\\end{align*}\n%\n%\\eex\n\n\\bex Compute $\\ds{\\int\\frac1{(6-2x)^5}\\,dx}$.\n\n\\underline{Solution}: \n\\begin{align*}\n\\int\\frac1{(6-2x)^5}\\,dx&=\\int u^{-5}\\cdot\\frac{-1}2\\,du\n   =-\\frac12\\cdot\\frac1{-4}u^{-4}+C\n   =\\frac18(6-2x)^{-4}+C \\\\\n\\left.\\begin{alignedat}{2}\n&&u&=6-2x\\\\\n&\\implies&du&=-2\\,\\underline{dx}\\\\\n&\\implies&\\frac{-1}2\\,du&=\\underline{dx}\\end{alignedat}\\right|&\n=\\frac1{8(6-2x)^4}+C.\n\\end{align*}\n\\eex\n\nIn the case that $du=dx$, this can often be anticipated and the\nexperienced calculus student might omit the middle steps:\n%\\bex Compute $\\ds{\\int\\csc^2(x-\\pi)\\,dx}$.\n%\n%\\underline{Solution}:\n%\\begin{align*}\n%\\int\\csc^2(x-\\pi)\\,\\underline{dx}&=\\int\\csc^2u\\,\\underline{du}\n%       =-\\cot u+C=-\\cot(x-\\pi)+C.\\\\\n%\\left.\\begin{alignedat}{2}\n%  &&u&=x-\\pi\\\\\n%&\\implies&du&=\\underline{dx}\\end{alignedat}\n%\\right\\}&\\end{align*}\n%\\eex\n\\bex Compute $\\ds{\\int(x+9)^4\\,dx}$.\n\n\\underline{Solution}:\n\\begin{align*}\n\\int(x+9)^4&=\\int u^4\\,du=\\frac15u^5+C=\\int\\frac15(x+9)^5+C.\n\\\\\n\\left.\\begin{aligned}\nu&=x+1\\\\\n\\implies du&=dx\\end{aligned}\\right|&\n\\end{align*}\n\\eex\n\n\n\n\n\nAnother way to look at the example above is to realize\nthat $d(x+9)=dx$, so we can write\n$$\\int(x+9)^4\\,dx=\\int(x+9)^4d(x+9)\n                       =\\frac15(x+9)^5+C.$$\nIn other words, $dx$ is the same as $d(x+9)$, so we get the same\nif we interpret the original integral as an antiderivative with \nrespect to $(x+9)$.\\footnote{Note that the {\\it change} in $x+9$ is the\nsame as the change in $x$.}  Indeed this is a shortcut one learns with\npractice---thinking but perhaps not writing the second step---but \nat first it is still best to write out the full substitution,\nas in the example above, at least until one is proficient in the \nmethod as presented here.  Of course this is the analog to \na chain rule where the ``inner'' derivative is 1:\n$$\\frac{d}{dx}\\left[\\frac15(x+9)^5\\right]\n  =\\frac15\\cdot5(x+9)^4\\cdot\\frac{d(x+9)}{dx}\n  =\\frac15\\cdot5(x+9)^4\\cdot1=(x+9)^4,\\text{ q.e.d.}$$\n\n\n\n\\subsection{A Slight Twist on the Method}\n\nRecall our second example, namely Example~\\ref{IntX(X^2+1)^7dxExample}\non page~\\pageref{IntX(X^2+1)^7dxExample}: $\\int x(x^2+1)^7\\,dx$.\nWe used a substitution $u=x^2+1$ because $du=2x\\,dx$ contained the\nextra factor of $x$ in the integrand.  The substitution\neventually gave us $\\int u^7\\cdot\\frac12\\,du$, which was a simple\npower rule.  Of course we could have ``simply'' expanded the\noriginal function\n\\begin{align*}\nx(x^2+1)^7&=x(x^2+7x^4+21x^6+35x^8+35x^{10}+21x^{12}+7x^{14}+1)\\\\\n          &=x^3+7x^5+21x^7+35x^9+35x^{11}+21x^{13}+7x^{15}+x,\n\\end{align*}\nand integrated ``term by term.''  However the substitution method was\narguably easier, and the answer's simple form, \n$\\frac1{16}(x^2+1)^{8}+C$ would\nprobably not be recongnizable from a strategy which expands the\nintegrand first.\n\nNow consider the integral $\\ds{\\int x(x-1)^{3/2}\\,dx}$.\nHere we can not simply ``expand'' the integrand (even\nby brute force, as above), because\nof the fractional power term $(x-1)^{3/2}$, which is algebraically\nmore difficult to deal with than positive integer powers.  Furthermore,\nif we let $u=x-1$, then $du=dx$, but this differential\nterm cannot absorb the extra factor $x$. The key is to then\nnotice that the original substitution offers a way out:\nthat extra factor $x$ can be rewritten $u+1$ (since\n$u=x-1\\iff u+1=x$).\nBelow we show how this can be utilized.\nIndeed we will expand the new integrand, but what is interesting \nis how the algebraic difficulties of the $(x-1)^{3/2}$ term\n(namely that this is of the form $({a+b})^{r}$,\n$r\\not\\in\\mathbb{N}$) is transfered\nto the $x$ term which, being a positive integer power, is \nthen easier to handle.  Below we write this out in the standard\nexample format:\\newpage\n\\bex Compute $\\ds{\\int x(x-1)^{3/2}\\,dx}$.\n\n\\underline{Solution}: Here we substitute for $dx$ {\\bf and} $x$.\nBoth substitutions are calculated below, but separately.\n(This time we underline the substitution for $x$, instead of the\ndifferential part.) Once the substitutions are completed, we can \nperform the multiplication to get two simple power rules:\n\\begin{align*}\n\\int \\underline{{x}}(x-1)^{3/2}\\,dx&=\n\\int\\underline{{(u+1)}}u^{3/2}\\,du\n=\\int\\left(u^{5/2}+u^{3/2}\\right)\\,du\n=\\frac27u^{7/2}+\\frac25u^{5/2}+C\\\\\n\\left.\n{\\begin{alignedat}{2}\n&&u&=x-1\\\\\n&\\implies&du&=dx\\\\\n\\hline\n\\text{Also, } &&u&=x-1\\\\\n&\\iff& u+1&=\\underline{{x}}\\end{alignedat}}\\right|\n&=\\frac27(x-1)^{7/2}-\\frac25(x-1)^{5/2}+C.\\end{align*}\nThough the answer above is correct, one often factors the final \nanswer:\n$$=\\frac2{35}(x-1)^{5/2}[5(x-1)-7]+C=\\frac2{35}(x-1)^{5/2}(5x-12)+C.$$\n\\eex\n\\bex Compute $\\ds{\\int\\frac{x}{\\sqrt{2x+1}}\\,dx}$.\n\n\\underline{Solution}: We will work this problem\ntwice  using two different\nsubstitutions.  The first is perhaps the most obvious, but the\nsecond has some appeal as well.\n\\begin{align*}\n\\int\\frac{x}{\\sqrt{2x+1}}\\,dx&=\\int\\frac{\\frac12(u-1)}{u^{1/2}}\\cdot\\frac12\\,du\n=\\frac14\\int\\left(u^{1/2}-u^{-1/2}\\right)\\,du\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=2x+1\\\\\n&\\implies&du&=2\\,dx\\\\\n&\\implies&\\frac12du&=dx\\\\\n\\hline\n&&u&=2x+1\\\\\n&\\implies&x&=\\frac12(u-1)\n\\end{alignedat}\\right|&=\\frac14\\left(\\frac23u^{3/2}-2u^{1/2}\\right)+C\n=\\frac16(2x+1)^{3/2}-\\frac12(2x+1)^{1/2}+C.\n\\end{align*}\nAgain one might factor, simplify and rearrange the variable parts of the answer\nto arrive at\n$$=\\frac16(2x+1)^{1/2}\\left[(2x+1)-3\\right]+C\n  =\\frac16\\sqrt{2x+1}(2x-2)+C\n  =\\frac13(x-1)\\sqrt{2x+1}+C.$$\nFor the alternative substitiution we let $u=\\sqrt{2x+1}$.  Note how\nmuch of the integrand is then absorbed into $du$ (due to the\nrelationship between the square root and its derivative).\n\\begin{align*}\n\\int\\frac{x}{\\sqrt{2x+1}}\\,dx&=\\int\\underbrace{\\frac12(u^2-1)}_{x}\n\\underbrace{\\,du\\,\\vphantom{\\frac12}}_{\\frac{dx}{\\sqrt{2x+1}}}\n=\\frac12\\left[\\frac13u^3-u\\right]+C\n=\\frac16u^3-\\frac12u+C\n\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\sqrt{2x+1}\\\\\n&\\implies&du&=\\frac1{2\\sqrt{2x+1}}\\cdot2\\,dx\\\\\n&\\implies&du&=\\frac1{\\sqrt{2x+1}}\\,dx\\\\\n\\hline\n&&u&=\\sqrt{2x+1}\\vphantom{\\frac22}\\\\\n&\\implies&u^2&=2x+1\\\\\n&\\implies&\\frac12(u^2-1)&=x\\end{alignedat}\\right|\n&=\\frac16\\left(\\sqrt{2x+1}\\right)^3-\\frac12\\sqrt{2x+1}+C\n\\text{ (as before).}\\end{align*}\n\\eex\n\n\nIt is important to notice that we used {\\it the same} equation\nfor $u$ to calculate $du$, and to calculate $x$, in all of the above.\nAlso the reader should begin to see that we can make some rather \ninteresting substitutions, so long as we are consistent when\nreplacing every term inside the integral.  In doing so, it will\nbecome apparent if (1) it is even possible to use a given substitution\nto rewrite the integral, and (2) even if so, is the new integral\none which we can actually compute.\n\n\n\\bex Compute $\\ds{\\int\\frac{x^3}{\\sqrt{x^2+1}}\\,dx}$.\n\n\n\\eex\n\n\n\n\n\\subsection{Other Miscellaneous Power Rule Substitutions}\nSo far we have concentrated on algebraic (polynomial and\nrational-power), exponential and trigonometric functions in our \nsubstitution problems.  It is also worth examining how power\nrules can arise from integrals involving logarithmic and\narctrigonometric functions, which we do in this subsection.\n\\bex Compute $\\ds{\\int\\frac{(\\ln x)^5}{x}\\,dx}$.\n\n\\underline{Solution}: He we see a factor $\\frac1x$, which is\nthe derivative of $\\ln x$, so the latter will be $u$:\n\\begin{align*}\n\\int\\frac{(\\ln x)^5}{x}\\,dx&=\\int u^5\\,du=\\frac16u^6+C\n       =\\frac{(\\ln x)^6}{6}+C.\\\\\n\\left.\\begin{aligned}\nu&=\\ln x\\\\\ndu&=\\frac1x\\,dx\\end{aligned}\\right|&\\end{align*}\n\\eex\nNote that, as a general rule, if we have a function\n$f(x)$ with antiderivative $F(x)$, then we have\\footnotemark\n\\begin{align}\n\\int\\frac{f(\\ln x)}{x}\\,dx&=\\int f(u)\\,du=F(u)+C=F(\\ln x)+C.\\\\\n\\left.\n\\begin{aligned}\nu&=\\ln x\\\\\n\\implies du&=\\frac1x\\,dx\\end{aligned}\\right|&\\notag\n\\end{align}\n\\footnotetext{%%% FOOTNOTE\nIn fact we can replace $\\ln x$ with $\\ln|x|$ in throughout the above.\n%%% END FOOTNOTE\n}\nSimilar formulas apply to the arctrigonometric functions.\nRather than list and commit to memorize them, it is better\nto look at the general idea that if, say,\n$\\sin^{-1}x$ occurs in an integral, we would look immediately\nto see if its derivative, $\\frac1{\\sqrt{1-x^2}}$, also appears.\nSimilarly for all functions.\n\\bex Compute $\\ds{\\int\\frac1{\\sqrt{1-x^2}\\sin^{-1}x}\\,dx}$.\n\n\\underline{Solution}: Note here that if $u=\\sin^{-1}x$ then\nour $du$ below will account for\n$\\frac1{\\sqrt{1-x^2}}\\,dx$:\n\\begin{align*}\\int\\frac1{\\sqrt{1-x^2}\\sin^{-1}x}\\,dx\n&=\\int\\frac1{u}\\,du=\\ln|u|+C=\\ln\\left|\\sin^{-1}x\\right|+C.\\\\\n\\left.\\begin{aligned}\nu&=\\sin^{-1}x\\\\\n\\implies du&=\\frac1{\\sqrt{1-x^2}}\\,dx\n\\end{aligned}\\right|&\\end{align*}\n\\eex\n\\bex Compute $\\ds{\\int\\frac{\\sec^{-1}x}{x\\sqrt{x^2-1}}\\,dx}$.  Assume $x>0$\n(or more precisely, $x\\ge1$).\n\n\\underline{Solution}:\n\\begin{align*}\n\\int\\frac{\\sec^{-1}x}{x\\sqrt{x^2-1}}\\,dx&=\\int u\\,du\n  =\\frac12u^2+C=\\frac{\\left(\\sec^{-1}x\\right)^2}2+C.\\\\\n\\left.\\begin{aligned}\nu&=\\sec^{-1}x\\\\\ndu&=\\frac1{x\\sqrt{x^2-1}}\\,dx\\end{aligned}\\right|&\\end{align*}\n\\eex\nIn the example above, if instead $x<0$ (actually $x<-1$), \nwe would replace $x$ by $-|x|$ in the denominator of the integrand,\ngiving eventually $-\\frac12(\\sec^{-1}x)+C$ for the antiderivative.\n\n\n\\newpage\n\\begin{center}\n\\underline{\\Large{\\bf Exercises}}\\end{center}\n\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item $\\ds{\\int\\frac{\\sec x\\tan x}{\\sec x}\\,dx}$\n      \\label{IntOfSecXTanX/SecXForFun}\n\\end{enumerate}\n\\end{multicols}\n\n\\newpage\n\\section{Second Trigonometric Rules\\label{SecondTrigRules}}\nWe first looked at the simplest trigonometric integration rules---those\narising from the derivatives of the trignometric functions---in\nSection~\\ref{IndefiniteIntegrals}\n(Subsection~\\ref{FirstTrigRules}, page~\\pageref{FirstTrigRules}\nto be more precise).  Here we will complete the trigonomic rules\nin which one of the six basic trigonometric functions is the ``outer''\nfunction.  In fact we have four of the six antiderivatives we need:\nsine and cosine come quickly from the derivative formulas, and\ntangent and cotangent come from substitution arguments.  As it turns\nout, secant and cosecant require a little more cleverness, and while\nwe will not derive these from first principles, we will show that\nchecking them is a quick and interesting derivative computation.\nUnfortunately (or fortunately, whatever your perspective) there\nare variations of the antiderivatives of tangent, cotangent, secant\nand cosecant.  We will choose one form for each, but the well-informed\nstudent must be aware of the others to be prepared to discuss calculus\ntopics among students with different backgrounds.\\footnote{%\n%%% FOOTNOTE\nIn fact there are no strongly compelling reasons not to use \n\\begin{align*}\n\\int\\tan x\\,dx&=-\\ln|\\cos x|+C,\\\\\n\\int\\cot x\\,dx&=\\ln|\\sin x|+C,\\end{align*}\nwhich afterall have slightly simpler verifications by differentiation than\n(\\ref{AntiDerivTanX}) and (\\ref{AntiDerivCotX}).  Here we have opted to\nuse the latter, \nslightly more difficult formulas for a few reasons.\nFirst, they are themselves\nquite popular.  Second, the reader used to (\\ref{AntiDerivTanX}) and\n(\\ref{AntiDerivCotX}) will be less likely to be confused when presented\nthe simpler alternatives by a colleague (or future professor) with a different\nbackground, while the reader used to those simpler\nalternatives may have some initial difficulty if similarly\npresented our forms here.  Finally, there is so much added\nstructure, both calculus and algebraic, found in the context of the\nsecant and cosecant\nfunctions so  it is important to be familiar and comfortable with them.\n\nAdmittedly, however, if (\\ref{AntiDerivTanX}) and (\\ref{AntiDerivCotX})\nwere not so common we would likely opt for the simpler forms.\n%%% END FOOTNOTE\n}\n\n\\subsection{Antiderivatives of the Six Trigonometric Functions}\nThe antiderivatives of the six basic trigonometric functions\nare as follow:\n\\begin{alignat}{2}\n\\int\\sin x\\,dx&\\ =\\ &-&\\cos x+C,\\label{AntiDerivSinX}\\\\\n\\int\\cos x\\,dx&\\ =\\ &&\\sin x+C,\\label{AntiDerivCosX}\\\\\n\\int\\tan x\\,dx&\\ =\\ &&\\ln|\\sec x|+C,\\label{AntiDerivTanX}\\\\\n\\int\\cot x\\,dx&\\ =\\ &-&\\ln|\\csc x|+C,\\label{AntiDerivCotX}\\\\\n\\int\\sec x\\,dx&\\ =\\ &&\\ln|\\sec x+\\tan x|+C,\\label{AntiDerivSecX}\\\\\n\\int\\csc x\\,dx&\\ =\\ &-&\\ln|\\csc x+\\cot x|+C.\\label{AntiDerivCscX}\n\\end{alignat}\nThe first four of these can be verified mentally through quick derivative\ncomputations if the student is well enough versed in differentiation.\nThe last two require some more care, but are somewhat interesting to check.\nFor instance, we can verify (\\ref{AntiDerivSecX}) as \nfollows:\n\\begin{align*}\n\\frac{d\\,\\ln|\\sec x+\\tan x|}{dx}\n&=\\frac1{\\sec x+\\tan x}\\cdot\\frac{d\\,(\\sec x+\\tan x)}{dx}\\\\\n&=\\frac1{\\sec x+\\tan x}\\cdot(\\sec x\\tan x+\\sec^2x)\\\\\n&=\\frac{\\sec x(\\tan x+\\sec x)}{\\sec x+\\tan x}\\\\\n&=\\frac{\\sec x(\\sec x+\\tan x)}{\\sec x+\\tan x}=\\sec x,\\text{ q.e.d.}\n\\end{align*}\\label{ProofOfIntegralOfSecant}\n\n\nIt is not entirely obvious how one would derive antiderivatives of \nthe secant and cosecant functions, and so it is important to memorize\nthose especially. Indeed it is likely these were discovered through\nexperimentation, and such results are often very time consuming\nto reproduce from first principles if one has to re-invent ``the trick,''\none of which will be explored in the exercise.\n%(The others can be derived by inspection or through\n%fairly simple substitution, recalling for instance that\n%$\\tan x=\\sin x/\\cos x$ and that $-\\ln|\\cos x|=\\ln|\\sec x|$, and so\n%on.)  \nIn fact we will later show a popular alternative antiderivative\nfor the cosecant, and a not-so-popular alternative for the secant.\nThe alternatives for the tangent and cotangent are similar in\npopularity to those we will use for our standards.\n\nThere is little we can do with just \n(\\ref{AntiDerivSinX})--(\\ref{AntiDerivCscX}) as they stand,\nbut we nonetheless explore a few examples quickly.\n\n\\bex Below are two quick antiderivative computations involving our\nbasic trigonmetric integral formulas.\n\\begin{itemize}\n\\item $\\ds{\\int\\frac{\\sin^2 x+\\cos x}{\\sin x}\\,dx\n  =\\int\\left(\\sin x+\\cot x\\right)\\,dx=-\\cos x-\\ln|\\csc x|+C}$.\n\\item $\\ds{\\int\\left(x+\\sec x\\right)\\,dx\n  =\\frac{x^2}2+\\ln|\\sec x+\\tan x|+C}$.\n\\end{itemize}\n\\eex\n\n\\bex Suppose $v(t)=1+\\tan t$, and $s(\\pi/6)=7$.  Find $s(t)$, and\nthe range of $t$ for which the solution is valid.\n\n\\underline{Solution}: We know that $s(t)$ is an antiderivative\nof $v(t)$, so we write the following, realizing that we will use\nour one datum ($s(\\pi/6)=7$) to find the additive constant later.\n$$s(t)=\\int v(t)\\,dt=\\int(1+\\tan t)\\,dt=t+\\ln|\\sec t|+C.$$\nSo far $s(t)=t+\\ln|\\sec t|+C$, and $s({\\pi}/6)=7$, so\n$$7=\\frac{\\pi}6+\\ln\\left|\\sec\\frac{\\pi}6\\right|+C\\iff \n7=\\frac{\\pi}6+\\ln2+C\\iff 7=\\frac{\\pi}6+\\ln2+C,$$\nand so $C=7-\\frac{\\pi}6-\\ln2$.  Hence \n$$v(t)=t+\\ln|\\sec t|+7-\\frac{\\pi}6-\\ln2.$$\n\\eex\n\n\\subsection{Substitution and the Basic Trigonometric Functions, Part I}\n\nA student who uses calculus extensively is likely to eventually\nencounter an antiderivative problem where the form is\nparticularly difficult or obscure, in which case it is common\nto refer to so-called tables of integrals.  These usually\ncontain all the basic forms as well as those which would be\ndifficult enough to warrant a search through such a reference.\\footnote{%\n%%% FOOTNOTE\nIn a typical calculus class, the professor usually\nhas to answer the question of\nwhy students have to learn all of the difficult integration techniques\nwhen there are references available.  The answer is several-fold,\nand we make just a few points addressing it here.\n\nFirst, many problems are simple enough to not require reference,\nand using tables for every problem becomes akin to looking up every word\nin a dictionary as one reads a newspaper, for instance. \nSecond, it is not even possible to use tables for \nevery integration problem simply because \nmany problems which can be accomplished through the techniques\nwill not match what is in the tables.  Third, on occasion there will\nbe a technicality which the editors of the tables did not anticipate\nfor a particular problem, or a mistake they did not catch,\nand so reliance on tables can be problematic.\n(On this last point, the same is true of mathematical software packages\nwhich claim to compute integrals.)\n\nWe will eventually make use of tables to a limited extent, to see what\ntechnicalities need to be addressed when using them, and to give some\nflavor of what kinds of integrals one can find in standard lists.  Indeed,\nevery serious calculus student should eventually posess such a reference, \nthough again it should be used sparingly.\n%%% END FOOTNOTE\n}\nIt is interesting to note that most modern tables of integrals do\nnot use the common variable $x$ in the formulas, but instead use\n$u$, which is the most common variable for substitution type problems.\nThis is because substitution is so ubiquitous that it is assumed\nthe reader might not need a form exactly as it is\nin the table, but rather needs one which becomes one of the forms \n(or a constant multiple of one of the forms) found in the table\nonly after a substitution.  In that spirit, the standard method\nof listing the antiderivatives of the basic six trigonometric\nfunctions is as follows:\n\\begin{alignat}{2}\n\\int\\sin u\\,du&\\ =\\ &-&\\cos u+C,\\label{AntiDerivSinUdU}\\\\\n\\int\\cos u\\,du&\\ =\\ &&\\sin u+C,\\label{AntiDerivCosUdU}\\\\\n\\int\\tan u\\,du&\\ =\\ &&\\ln|\\sec u|+C,\\label{AntiDerivTanUdU}\\\\\n\\int\\cot u\\,du&\\ =\\ &-&\\ln|\\csc u|+C,\\label{AntiDerivCotUdU}\\\\\n\\int\\sec u\\,du&\\ =\\ &&\\ln|\\sec u+\\tan u|+C,\\label{AntiDerivSecUdU}\\\\\n\\int\\csc u\\,du&\\ =\\ &-&\\ln|\\csc u+\\cot u|+C.\\label{AntiDerivCscUdU}\n\\end{alignat}\nOf course these are just our previous formulas\n(\\ref{AntiDerivSinX})--(\\ref{AntiDerivCscX}), \nfrom page~\\pageref{AntiDerivSinX}, but with the entire\nintegral written in the variable $u$\ninstead of $x$.  However, each of these properly interpretted\ncontains a reverse chain\nrule, also known as a substitution-type, form.  So for instance,\nif $u=u(x)$, then $du=u'(x)\\,dx$ and so we can read\n(\\ref{AntiDerivTanUdU}) as\n$$\\int\\underbrace{\\tan u(x)}_{\\tan u}\\,\\underbrace{u'(x)\\,dx}_{du}=\n  \\ln|\\sec u(x)|+C,$$\nverified by differentiation:\n$$\\frac{d}{dx}\\ln|\\sec u(x)|\n =\\frac1{\\sec u(x)}\\cdot\\frac{d\\,\\sec u(x)}{dx}\n =\\frac1{\\sec u(x)}\\cdot\\sec u(x)\\tan u(x)\\cdot\\frac{d\\,u(x)}{dx}\n =\\tan u(x)\\cdot u'(x),$$\nq.e.d.  So forms (\\ref{AntiDerivSinUdU})--(\\ref{AntiDerivCscUdU}) are all\nforms in which a basic trigonometric function of some function\n$u(x)$, and the derivative $u'(x)$, and the differential $dx$\nare the nonconstant factors of the integral.  We now look at several\nexamples.\n%\\newpage\n\\bex Compute $\\ds{\\int x\\sin x^2\\,dx}$.\n\n\\underline{Solution}: As often occurs, the form is not exact but\na constant multiple of one of our forms, this time (\\ref{AntiDerivSinUdU}),\nand furthermore the order of the factors is changed.  Here\nwe see that the factor $x$ is a constant multiple of $u'(x)$ if\n$u(x)=x^2$, so the extra factor of $x$ can be ``absorbed'' in the \ndifferential $du$ after the substitution.  This ultimately leaves\nus with the problem of finding the antiderivative of a sine function.\n\\begin{align*}\n\\int \\underline{x}\\sin x^2\\,\\underline{dx}&=\n      \\int \\sin u\\cdot\\underline{\\frac12\\,du}\n  =-\\frac12\\cos u+C=-\\frac12\\cos x^2+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=x^2\\\\\n&\\implies &du&=2\\,\\underline{x\\,dx}\\\\\n&\\iff&\\frac12\\,du&=\\underline{x\\,dx}\\end{alignedat}\\right|&\\end{align*}\n\\eex\nThe above example can be quickly checked by differentiation.\n\\bex Compute $\\ds{\\int e^x\\cot e^x\\,dx}$.\n\n\\underline{Solution}:  Here we see the derivative of the argument\n$e^x$ of the cotangent function is also present as a multiplicative \nfactor.\n\\begin{align*}\n\\int \\underline{e^x}\\cot e^x\\,\\underline{dx}&=\n      \\int \\cot u\\,\\underline{du}\n  =-\\ln|\\csc u|+C=-\\ln\\left|\\csc e^x\\right|+C.\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=e^x\\\\\n&\\implies &du&=\\underline{e^x\\,dx}\\end{alignedat}\n\\right|&\\end{align*}\n\\eex\n\\bex Compute $\\ds{\\int\\frac{\\sec\\sqrt{x}}{\\sqrt x}\\,dx}$.\n\n\\underline{Solution}: Here the factor $\\frac{1}{\\sqrt{x}}$\nis in fact a constant multiple of the derivative of \n$\\sqrt{x}$, the argument of the trigonometric function.\nThus we take $u=\\sqrt{x}$, and then the resulting $du$ will\nabsorb the $\\frac1{\\sqrt{x}}$ term:\n\\begin{align*}\n\\int\\frac{\\sec\\sqrt{x}}{\\sqrt x}\\,dx&=\n  \\int\\sec\\sqrt{x}\\cdot\\underline{\\frac1{\\sqrt{x}}\\,dx}\n  =\\int \\sec u\\cdot\\underline{2\\,du}\n  =2\\ln|\\sec u+\\tan u|+C\\\\\n\\left.\\begin{alignedat}{2}\n&        &u&=\\sqrt x\\\\\n&\\implies&du&=\\frac1{2\\sqrt{x}}\\,dx\\\\\n&\\iff &2\\,du&=\\underline{\\frac1{\\sqrt{x}}\\,dx}\\end{alignedat}\\right|\n&=2\\ln\\left|\\sec\\sqrt{x}+\\tan\\sqrt{x}\\right|+C.\n\\end{align*}\n\\eex\n\n\\bex Compute $\\ds{\\int\\frac{\\cos(1+4\\ln x)}{x}\\,dx}$.\n\n\\underline{Solution}: Here we see the derivative of $(1+4\\ln x)$ appearing\nas a factor as well, except for a constant factor.\n\\begin{align*}\n\\int\\frac{\\cos(1+4\\ln x)}{x}\\,dx&=\\int\\cos(1+4\\ln x)\\cdot\n               \\underline{\\frac1x\\,dx}\n               =\\int\\cos u\\cdot\\underline{\\frac14\\,du}=\\frac14\\sin u+C\\\\\n\\left.\\begin{alignedat}{2}\n&         &u&=1+4\\ln x\\\\\n&\\implies&du&=4\\cdot\\underline{\\frac1x\\,dx}\\\\\n&\\iff&\\frac14\\cdot du&=\\underline{\\frac1x\\,dx}\n\\end{alignedat}\\right|\n&=\\frac14\\sin(1+4\\ln x)+C.\\end{align*}\n\\eex\n\n\\bex Compute $\\ds{\\int x^2\\csc\\left(\\cos x^3\\right)\\sin x^3\\,dx}$.\n\n\\underline{Solution}:  To be clear, first\nwe note that the integrand is the product of three\nfactors:\n$$x^2\\cdot\\csc\\left(\\cos x^3\\right)\\cdot\\sin x^3,$$\nso the argument of the cosecant is $\\cos x^3$.\nNow we will compute this two different ways.\nThe first method requires two substitions, which is an option that\nstudents must be aware is legitimate, assuming all computations are\nmade carefully and consistently.\n\\begin{description}\n\\item[Method 1.] Here we will first make a substitution $u=x^3$\nto yield a simpler integral without any polynomial factors, \nthough our new integral will still require some\nwork.\n\\begin{align*}\n\\int \\underline{x^2}\\csc\\left(\\cos x^3\\right)\\sin x^3\\,\\underline{dx}\n &=\\int\\csc(\\cos u)\\sin u\\cdot\\frac13\\,du\\\\\n\\left.\\begin{alignedat}{2}\n&          &u&=x^3\\\\\n&\\implies &du&=3\\,\\underline{x^2\\,dx}\\\\\n&\\iff&\\frac13\\,du&=\\underline{x^2\\,dx}\n\\end{alignedat}\\right|&\n\\end{align*}\nSo at this point our problem reduces to computing\n$\\ds{\\int\\csc(\\cos u)\\sin u\\cdot\\frac13\\,du}$.  \nTo do so we use another substitution, noting that\n$\\sin u$ is the derivative---up to a multiplicative constant---of\n$\\cos u$ (with respect to $u$ this time).\nTo remain consistent this second substitution must use a new\nvariable (lest we give one letter two different meanings within the\nsame problem, which would be contradictory!).\nSo we  call our new variable something other than $u$ or $x$.\nA commonly used variable at this stage is $w$:\n\\begin{align*}\n\\frac13\\int\\csc(\\cos u)\\underline{\\sin u\\,du}\n&=\\frac13\\int\\csc w\\underline{(-1)\\,dw}\n=-\\frac13\\left[-\\ln|\\csc w+\\cot w|\\right]+C\\\\\n\\left.\\begin{alignedat}{2}\n           &&w&=\\cos u\\\\\n &\\implies&dw&=-\\underline{\\sin u\\,du}\\\\\n &\\iff&(-1)dw&=\\underline{\\sin u\\,du}\n\\end{alignedat}\\right|\n&=\\frac13\\ln|\\csc w+\\cot w|+C\\\\\n&=\\frac13\\ln\\left|\\csc\\left(\\cos u\\right)\n      +\\cot \\left(\\cos u\\right)\\right|+C\\\\\n&=\\frac13\\ln\\left|\\csc\\left(\\cos x^3\\right)\n      +\\cot \\left(\\cos x^3\\right)\\right|+C.\\end{align*}\nNote how we computed the antiderivative in $w$, which we\nthen replaced by its expression in $u$, and finally by\nthe definition of $u$ in terms of $x$.\n\\item[Method 2.] If we can see far enough ahead, we can combine\nboth substitutions into one.  For clarity we will use a different\nvariable---namely $z$---here (though by convention\none would usually use $u$).  We choose $z=\\cos x^3$, noting\nthat its derivative, requiring the chain rule, will have\na $\\sin x^3$ and a $x^2$ term (ignoring multiplicative constants),\nwhich leaves us with a constant mulitiple of $\\int\\csc z\\,dz$, for\nwhich we have a formula.  \n\\begin{align*}\n\\int \\underline{x^2}\\csc\\left(\\cos x^3\\right)\\underline{\\sin x^3\\,dx}\n &=\\int\\csc z\\cdot\\underline{\\frac{-1}3\\,dz}\n =-\\frac13\\cdot[-\\ln|\\csc z+\\cot z|]+C\\\\\n\\left.\\begin{alignedat}{2}\n& &z&=\\cos x^3\\\\\n&\\implies &dz&=-\\underline{\\sin x^3}\\cdot3\\,\\underline{x^2\\,dx}\\\\\n&\\iff&-\\frac13\\,dz&=\\underline{x^2\\sin x^3\\,dx}\\end{alignedat}\\right|\n&=\\frac13\\ln\\left|\\csc\\left(\\cos x^3\\right)\n                  +\\cot\\left(\\cos x^3\\right)\\right|+C.\\end{align*}\n\\end{description}\n\\eex\n\nIn the previous example, the second method in fact just combines\nthe two substitutions from the first method into one.  Indeed,\nthe formula for $w$ in terms of $x$ is the same as that of \n$z$:\\footnote{%\n%%% FOOTNOTE\nSimilarly, though perhaps not so obviously, when we recall\nthese variables are all functions of $x$ we also have $dw=dz$:\n\\begin{align*}\ndw&=\\frac{dw}{du}\\cdot\\frac{du}{dx}\\cdot dx\\\\\n  &=(-\\sin u)\\cdot\\left(3x^2\\right)\\,dx\\\\\n  &=-\\sin x^3\\cdot 3x^2\\,dx\\\\\n  &=dz.\\end{align*}\nAgain we see the power of the Leibniz notation in what is essentially\na chain rule.  Of course we should expect that $w=z\\implies dw=dz$.\nBut also we see that while there are obvious algebraic consistencies\nin our substitution method, there are also consequent\ncalculus consistencies which, while more subtle, are still correct\nwhen we perform all the computations correctly.\n%%% END FOOTNOTE\n}\n$$w=\\csc(u)=\\csc\\left(\\cos x^3\\right)=z.$$\nWhen one is well practiced in substitution the second method will\nlikely be chosen.  However, it is important also for the student\nto realize that even if a substitution does not achieve an\nintegral that can be immediately computed, that does not mean\nthat the particular substitution need be abandoned.  If the\nnew integral is simpler, then the\nfirst substitution can be worthwhile.  In fact in later sections\nwe will on occasion {\\it require} multiple substitutions.\nOf course it is important that all steps be carried out \ncarefully, accurately and consistently.  \n\nIn this section we concentrated on those integrals which reduce\nto integrals of a single trigonometric function, perhaps with the\naid of a substitution. In \nChapter~\\ref{AdvancedIntTechniques}\n(and more sepcifically Section~\\ref{TrigIntsSection})\nwe will look at the many techniques for computing those integrals \nwhich contain several factors of trigonometric functions, and no\nother factors.  The techniques of our present section will\nbe called upon often, but these are only a small part of the \nneeded knowledge for computing the  ``trignometric integrals''\nof the later sections.  But in fact we have some other techniques\nalready.  For instance, there were the first trigonometric integral\nformulas we had in Section~\\ref{IndefiniteIntegrals},\nSubsection~\\ref{FirstTrigRulesSubsection} which arose from\nthe derivative rules for the six basic trigonometric functions.\nIn fact we had one other technique for dealing with some trigonometric\nintegrals, which was substitution in the case we could rewrite\nthe trigonometric integral as a power-rule type integral.\\footnote{%\n%%% FOOTNOTE\nIn fact there will be several other substitution type arguments we\nwill make for trigonometric integrals besides those which yield power\nrules.\n%%% END FOOTNOTE\n}\n\\bex Compute $\\ds{\\int\\frac{\\sin3x}{\\cos^53x}\\,dx}$.\n\n\\underline{Solution}:  Here we see that we have\nthe derivative of the cosine function is present as a factor,\nand we are left with a power of the cosine:\n\\begin{align*}\n\\int\\frac{\\sin3x}{\\cos^53x}\\,dx\n &=\\int(\\cos3x)^{-5}\\underline{\\sin3x\\,dx}\n  =\\int u^{-5}\\cdot\\underline{\\frac{-1}3\\,du}\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\cos3x\\\\\n&\\implies&du&=-\\underline{\\sin3x}\\cdot3\\,\\underline{dx}\\\\\n&\\iff&\\frac{-1}3\\,du&=\\underline{\\sin3x\\,dx}\n\\end{alignedat}\\right|\n&=-\\frac13\\cdot\\frac{-1}4\\,u^{-4}+C\\\\\n&=\\frac1{12}\\cos^{-4}3x+C\\\\\n&=\\frac1{12}\\sec^{4}3x+C.\n\\end{align*}\n\\eex\nThe integration techniques we encounter throughout the book are\nmany and varied.  We will see later how a slight change in a problem\ncan substantially change the result, its difficulty,\nor the technique used to achieve it.  We have seen this phenomenon\nbefore.  Consider for instance\n\\begin{align*}\n\\int\\frac{x}{x^2+1}\\,dx&=\\frac12\\ln\\left(x^2+1\\right)+C,\\\\\n\\int\\frac{1}{x^2+1}\\,dx&=\\tan^{-1}x+C,\\\\\n\\\\\n\\int\\frac{x}{\\sqrt{1-x^2}}\\,dx&=-\\sqrt{1-x^2}+C,\\\\\n\\int\\frac1{\\sqrt{1-x^2}}\\,dx&=\\sin^{-1}x+C,\\\\\n\\\\\n\\int\\sec x\\,dx&=\\ln|\\sec x+\\tan x|+C,\\\\\n\\int\\sec^2x\\,dx&=\\tan x+C,\\\\\n\\int\\sec^3x\\,dx&=\\frac12(\\sec x\\tan x+\\ln|\\sec x+\\tan x|)+C.\n\\end{align*}\nIn fact this last problem will have to wait until \nChapter~\\ref{AdvancedIntTechniques}, and is quite long and technical.\nEven the verification by differentiation is nontrivial, and\nrequires one to employ some trigonometric identity along the way.\nSuffice for now \nto simply note that the techniques, and results,\nfor even these first three powers of\nthe secant are all very different.\n\nComputing antiderivatives in good time requires \nthe ability to recognize which technique will work for a \nparticular problem.  That in turn requires \na fairly complete knowledge of the techniques, even to the\nextent that one can anticipate the outcomes of several later steps.\nOf course practice is one key to gaining this understanding.\nFor that reason this chapter will contain one\nsection in which the exercises' required\ntechniques are purposely randomized, by method as well as difficulty.\n\\begin{center}\n\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item By differentiation, verify each of our basic six trigonometric\n integrals in the forms we use,\n (\\ref{AntiDerivSinX})--(\\ref{AntiDerivCscX}).  For reference\n see the proof for the secant, page~\\pageref{ProofOfIntegralOfSecant}.\n \\begin{enumerate}\n \\item $\\ds{\\int\\sin x\\,dx=-\\cos x+C}$\n \\item $\\ds{\\int\\cos x\\,dx=\\sin x+C}$\n \\item $\\ds{\\int\\tan x\\,dx=\\ln|\\sec x|+C}$\n \\item $\\ds{\\int\\cot x\\,dx=-\\ln|\\csc x|+C}$\n \\item $\\ds{\\int\\sec x\\,dx=\\ln|\\sec x+\\tan x|+C}$\n \\item $\\ds{\\int\\csc x\\,dx=-\\ln|\\csc x+\\cot x|+C}$\n \\end{enumerate}\n\\item Compute the following integrals.\n \\begin{enumerate}\n \\item $\\ds{\\int x\\sec\\left(x^2+1\\right)\\,dx}$\n \\item $\\ds{\\int \\frac{\\tan(\\ln x)}{x}\\,dx}$\n \\item $\\ds{\\int \\frac{\\cos\\left(\\frac1x\\right)}{x^2}\\,dx}$\n \\item $\\ds{\\int \\sqrt{x}\\csc\\left(x\\sqrt{x}\\right)\\,dx}$\n \\item $\\ds{\\int x^3e^{5x^4}\\cot \\left(6e^{5x^4}\\right)\\,dx}$\n \\end{enumerate}\n\n\n\n\\item Derive our formula (above) for the integral of\n$\\sec x$ by the following algebraic device, namely multiplying\nand dividing by $\\sec x+\\tan x$ within the integral, i.e.,\n$$\\int\\sec x\\,dx\n=\\int\\sec x\\cdot\\frac{\\sec x+\\tan x}{\\sec x+\\tan x}\\,dx,$$\nand then using an appropriate substitution argument.\n\\item By differentiation, verify each of the following alternative\n integration formulas.\n \\begin{enumerate}\n \\item $\\ds{\\int\\tan x\\,dx=-\\ln|\\cos x|+C}$.\n \\item $\\ds{\\int\\cot x\\,dx=\\ln|\\sin x|+C}$.\n \\item $\\ds{\\int\\sec x\\,dx=-\\ln|\\sec x-\\tan x|+C}$.\n \\item $\\ds{\\int\\csc x\\,dx=\\ln|\\csc x-\\cot x|+C}$.\n \\end{enumerate}\n\n\\end{enumerate}\n\\end{multicols}\n\n\n\n\\newpage\n\\section{Substitution with All Basic Forms%\n\\label{SubWithAllForms}}\nIn this section we will add to our forms for substitution\nand recall some rather general guidelines for substitution.\nExcept for our four new trigonometric forms\nfrom Section~\\ref{SecondTrigRules},\nall forms in this chapter derive directly from \nderivative rules.  These comprise\nwhat we call here the {\\it basic} integration rules.  Each\nis based upon a single function specific to the rule. So for\ninstance, we will have in our list the following:\n$$\\int\\frac1{u^2+1}\\,du=\\tan^{-1}u+C.$$\nAs before, the usual variable of integration in the given problem\nwill likely be $x$, but the {\\it form} may be ultimately as\nabove, except for multiplicative constants, where $u=u(x)$ and then\n$du=u'(x)\\,dx$ contains another factor from the original integral.\nSo for instance we might see\n\\begin{align*}\n\\int\\frac{x}{x^4+1}\\,dx&=\\int\\frac1{\\left(x^2\\right)^2+1}\n                            \\cdot\\underline{x\\,dx}\n                        =\\int\\frac{1}{u^2+1}\\cdot\\underline{\\frac12\\,du}\n                        =\\frac12\\tan^{-1}u+C\\\\\n\\left.\\begin{alignedat}{2}\n &&u&=x^2\\\\\n&\\implies&du&=2\\,\\underline{x\\,dx}\\\\\n&\\iff&\\frac12\\,dx&=\\underline{x\\,dx}\\\\\n\\end{alignedat}\\right|\n&=\\frac12\\tan^{-1}x^2+C.\\end{align*}\nOne clue that we might try $u=x^2$ was that its derivative was a factor\nin the integrand in the form of the factor $x$,\nagain excepting multiplicative constants, and so we wrote that\nfactor separately next to the differential $dx$.\nAs it turned out, the rest of the integrand could indeed be written\nas a function of $u=x^2$.  \n\nReading the problem above backwards,\nthe arctangent is the ``outer function'' of a chain\nrule differentiation problem, and $x^2$ was the ``inner function.''\nPut in terms of integration, the {\\it form} was $\\int\\frac1{u^2+1}\\,du$,\nexcepting multiplicative constants, with the ``inner function'' \n$u=x^2$.  The arctangent appeared because of the ultimate form\nof the integral, in terms of $u=x^2$.\n\nBut note that the arctangent can also appear as the ``inner function,''\nwhich we may wish to set equal to $u$. So for instance,\n\\begin{align*}\n\\int\\frac{\\left(\\tan^{-1}x\\right)^2}{x^2+1}\\,dx\n &=\\int\\left(\\tan^{-1}x\\right)^2\\cdot\\underline{\\frac1{x^2+1}\\,dx}\n =\\int u^2\\,\\underline{du}=\\frac{u^3}3+C\\\\\n\\left.\\begin{alignedat}{2}\n &&u&=\\tan^{-1}x\\\\\n&\\implies&du&=\\underline{\\frac1{x^2+1}\\,dx}\\end{alignedat}\\right|\n&=\\frac{\\left(\\tan^{-1}x\\right)^3}3+C.\\end{align*}\n\nIn all these cases, we are looking for some $u=u(x)$ so that\n\\begin{itemize}\n\\item one major (nonconstant) factor of the integral can be simply \n written $f(u)$, i.e., $u$ is an ``inner function'' of some\n composite function $f(u(x))$ which appears in the integrand,\n\\item the remaining factors of the integrand will collectively\n  be a constant multiple of $du=u'(x)\\,dx$, \n\\item and finally, so that $\\int f(u)\\,du$ is an integral we can\n  compute, i.e., we know the antiderivative of $f$.\n\\end{itemize}\nSo of course identifying $u$ is the key, and in doing so we have to\nbe sure its derivative is also present, and finally that we are\nleft with an integral---albeit in $u$---which we can handle.\\footnote{%\n%%% FOOTNOTE\nThis all assumes that there is a substitution which will make\nthe integral into one of these simple forms.  It is not always the\ncase.  One which occurs in probability and other subjects\nis $\\int e^{x^2}\\,dx$, which can not be changed by substitution into\na useful form.  In fact it will not succumb to any of the methods in\nthis or the next chapter.  We will eventually find a way to \ndeal with this integral, in Chapter~\\ref{TaylorSeriesChapter}.\nIn the meantime it is actually a good exercise to see why this\nintegral can not be forced into any of our methods.  Indeed, \nseeing what goes wrong in such a case very well complements\nseeing what goes right in the cases where substitution,\nand later methods, do achieve an answer.%%%\n%%% END FOOTNOTE\n}\n\\subsection{List of Basic Forms}\n\n\\begin{align}\n\\int u^n\\,du&=\\frac{u^{n+1}}{n+1}+C,\\qquad u\\ne-1,\\label{IntPwrRlInU}\\\\\n\\int\\frac1u\\,du&=\\ln|u|+C,\\label{Int1/URl}\\\\\n\\int\\sin u\\,du&=-\\cos u+C,\\label{IntSinURl}\\\\\n\\int\\cos u\\,du&=\\sin u+C,\\label{IntCosURl}\\\\\n\\int\\tan u\\,du&=\\ln|\\sec u|+C,\\label{IntTanURl}\\\\\n\\int\\cot u\\,du&=-\\ln|\\csc u|+C,\\label{IntCotURl}\\\\\n\\int\\sec u\\,du&=\\ln|\\sec u+\\tan u|+C,\\label{IntSecURl}\\\\\n\\int\\csc u\\,du&=-\\ln|\\csc u+\\cot u|+C,\\label{IntCscURl}\\\\\n\\int\\frac1{\\sqrt{1-u^2}}\\,du&=\\sin^{-1}u+C,\\label{IntGivingArcSinURl}\\\\\n\\int\\frac1{u^2+1}\\,du&=\\tan^{-1}u+C,\\label{IntGivingArcTanURl}\\\\\n\\int\\frac1{u\\sqrt{u^2-1}}\\,du&=\\sec^{-1}|u|+C,\\label{IntGivingArcSec|U|Rl}\\\\\n\\int e^u\\,du&=e^u+C,\\label{IntGivingExp(U)Rl}\\\\\n\\int a^u\\,du&=\\frac{a^u}{\\ln a}+C,\\label{IntA^URl}\\\\\n\\int \\sec^2u\\,du&=\\tan u+C,\\label{IntSec^2URl}\\\\\n\\int\\csc^2u\\,du&=-\\cot u+C,\\label{IntCsc^2URl}\\\\\n\\int\\sec u\\tan u\\,du&=\\sec u+C,\\label{IntSecUTanURl}\\\\\n\\int\\csc u\\cot u\\,du&=-\\csc u+C.\\label{IntCscUCotURl}\\end{align}\n\n\nIt can not be stressed too much that each form given assumes that\na substitution may be required.  So again, the following formulas\nsay the same:\n$$\\int e^u\\,du=e^u+C,\\qquad\\qquad \\int e^{u(x)}u'(x)\\,dx=e^{u(x)}+C.$$\nRecognizing when we have such a form is again key to using these formulas.\n\n\\bex Compute $\\ds{\\int x e^{x^2}\\,dx}$.\n\n\\underline{Solution}:  Here we see the derivative of $x^2$ appearing\nas the factor $x$, except for a constant multiple.  Hence we let $u=x^2$,\nand the $du$ will contain the other factor $x$, leaving\nan integral in one of our standard forms, namely (\\ref{IntGivingExp(U)Rl}),\nand nothing else except\na multiplicative constant.\n\\begin{align*}\\int \\underline{x}\\, e^{x^2}\\,\\underline{dx}\n &=\\int e^u\\cdot\\frac12\\,du\n  =\\frac12\\,e^u+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=x^2\\\\\n&\\implies&du&=2\\,\\underline{x\\,dx}\\\\\n&\\iff&\\frac12\\,du&=\\underline{x\\,dx}\n\\end{alignedat}\\right|\n&=\\frac12\\,e^{x^2}+C.\n\\end{align*}\n\\label{IntXE^x^2Example}\\eex\n%\\bex Compute $\\ds{\\int\\frac{\\sqrt{\\tan^{-1}x}}{x^2+1}\\,dx}$.%%\n%\n%\\underline{Solution}:  Here we see the derivative of $\\tan^{-1}x$,\n%namely $\\frac1{x^2+1}$, appearing as a factor, so letting $u=\\tan^{-1}x$\n%will result in $du$ accounting for this other factor.\n%\\begin{align*}\n%\\int\\frac{\\sqrt{\\tan^{-1}x}}{x^2+1}\\,dx\n%&=\\int\\sqrt{\\tan^{-1}x}\\cdot\\underline{\\frac1{x^2+1}\\,dx}\n%=\\int\\sqrt{u}\\,du=\\int u^{1/2}\\,du\\\\\n%\\left.\\begin{alignedat}{2}\n%&&u&=\\tan^{-1}x\\\\\n%&\\implies&du&=\\underline{\\frac1{x^2+1}\\,dx}\\end{alignedat}\n%\\right|&=\n%\\end{align*}\n%\\eex\n\\bex Compute $\\ds{\\int\\frac{x^3}{\\sqrt{1-x^8}}\\,dx}$.\n\n\\underline{Solution}: At first it is tempting to let $u=1-x^8$\nand hope this will become a power rule,\nexcept that such $u$ implies $du=-8x^7$,\n which is very different from a constant\nmultiple of the other factor here, namely $x^3$.  \n\nIn fact, the other factor can be a good source of information\nabout what to set equal to $u$.  Indeed the factor $x^3$ will\nbe part of the differential of $u=x^4$, and then we can recognize\na form which will yield an arcsine ultimately, i.e., form\n(\\ref{IntGivingArcSinURl}).\n\\begin{align*}\n\\int\\frac{x^3}{\\sqrt{1-x^8}}\\,dx\n&=\\int\\frac{1}{\\sqrt{1-\\left(x^4\\right)^2}}\\cdot\\underline{x^3\\,dx}\n=\\int\\frac1{\\sqrt{1-u^2}}\\cdot\\underline{\\frac14\\,du}\n=\\frac14\\,\\sin^{-1}u+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=x^4\\\\\n&\\implies&du&=4\\,\\underline{x^3\\,dx}\\\\\n&\\iff&\\frac14,du&=\\underline{x^3\\,dx}\n\\end{alignedat}\\right|&=\\frac14\\sin^{-1}\\left(x^4\\right)\n                      +C.\n\\end{align*}\n\\eex\n\nAs with the power rule, there are occasions where the derivative\nof our $u$ is a nonzero constant, and thus a constant multiple of every\nother nonzero constant.  While these integrals are arguably easier than\nthe others we encounter here, their relative simplicity can be\na source of confusion.\n\n\\bex Compute $\\ds{\\int\\csc5x\\,dx}$.\n\n\\underline{Solution}: Here we simply let $u=5x$.\n\\begin{align*}\n\\int\\csc5x\\,\\underline{dx}&=\\int\\csc u\\cdot\\underline{\\frac15\\,du}\n      =-\\frac15\\ln|\\csc u+\\cot u|+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=5x\\\\\n&\\implies&du&=d\\,\\underline{dx}\\\\\n&\\iff\\frac15\\,du&=\\underline{dx}\n\\end{alignedat}\\right|&=-\\frac15\\ln|\\csc5x+\\cot 5x|+C.\n\\end{align*}\n\\eex\n\n\\bex Compute $\\ds{\\int 2^{3^x}\\cdot 3^x\\,dx}$.\n\n\\underline{Solution}:  Here we will need (\\ref{IntA^URl}) eventually,\nbut first we simply notice that the factor $3^x$ is \na constant multiple of the exponent in the first factor,\nso we let $u=3^x$.\n\\begin{align*}\n\\int 2^{3^x}\\cdot\\underline{3^x\\,dx}\n&=\\int 2^u\\cdot\\underline{\\frac{1}{\\ln 3}\\,dx}\n=\\frac{1}{\\ln 3}\\cdot\\frac1{\\ln 2}\\cdot 2^u+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=3^x\\\\\n&\\implies&du&=\\underline{3^x}\\,\\ln 3\\,\\underline{dx}\\\\\n&\\iff&\\frac1{\\ln 3}\\,du&=3^x\\,dx\\end{alignedat}\\right|\n&=\\frac{2^{3^x}}{\\ln3\\cdot\\ln2}+C.\n\\end{align*}\n\\eex\nThe example above shows the importance of following the various\nconstant factors through the integration.  Students who rely\nupon guessing the answers, without performing the\nformal substitution steps, are much more likely to misplace\none or more constant factors.\n\nFor further practice we consider more basic examples.\n\n\\bex Compute $\\ds{\\int\\frac{\\sec\\sqrt x}{\\sqrt{x}}\\,dx}$.\n\n\\underline{Solution}: The key here is that the derivative\nof the argument of the secant is also present as a factor.\nRecall $\\frac{d}{dx}\\left(\\sqrt{x}\\right)=\\frac1{2\\sqrt{x}}$,\nwhich is obvious when the radicals are written as 1/2-powers.\n\\begin{align*}\n\\int\\frac{\\sec\\sqrt x}{\\sqrt{x}}\\,dx\n&=\\int\\sec{\\sqrt{x}}\\cdot\\underline{\\frac1{\\sqrt{x}}\\,dx}\n=\\int\\sec u\\cdot\\underline{2\\,du}\n=2\\ln|\\sec u+\\tan u|+C\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\sqrt{x}\\\\\n&\\implies&du&=\\frac12\\cdot\\underline{x^{-1/2}\\,dx}\n\\end{alignedat}\\right|&=2\\ln\\left|\\sec\\sqrt{x}+\\tan\\sqrt{x}\\right|+C.\n\\end{align*}\n\n\n\\eex\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIn the next section we will further explore the arctrigonometric\nantiderivatives by considering further complications.\nFor now we only look at two such complications, first involving the\narctangent (though the arcsine has a similar potential complication),\nand then the arcsecant, which has the same complications as the others\nand then one more.\n\\bex Compute $\\ds{\\int\\frac{x^2}{1+25x^6}\\,dx}$.\n\n\\underline{Solution}: There are two clues directing our choice of $u$.\nFirst, we see the factor $x^2$, which is a multiple of the derivative\nof $x^3$.  Then we see that the denominator can be written\nas $1+\\left(5x^3\\right)^2$, which we can put into the form\nyielding the arctangent, namely (\\ref{IntGivingArcTanURl}).\n\\begin{align*}\n\\int\\frac{x^2}{1+25x^6}\\,dx\n&=\\int\\frac{1}{1+\\left(5x^3\\right)^2}\\cdot\\underline{x^2\\,dx}\n=\\int\\frac1{1+u^2}\\cdot\\underline{\\frac1{15}\\,du}\n=\\frac1{15}\\,\\tan^{-1}u+C\\\\\n\\left.\\begin{alignedat}{2}\n  &&u&=5x^3\\\\\n&\\implies&du&=15\\,\\underline{x^2\\,dx}\\\\\n&\\iff&\\frac1{15}\\,du&=\\underline{x^2\\,dx}\n\\end{alignedat}\\right|&=\\frac1{15}\\tan^{-1}\\left(5x^3\\right)+C.\n\\end{align*}\n\\eex\nThe complication in this example is fairly benign: that the $u$ term\ncontains a multiplicative constant.  Here we wanted $25x^6$ to be\n$u^2$ for the form (\\ref{IntGivingArcTanURl}), so we took \n$u=5x^3$.\\footnote{%%%\n%%% FOOTNOTE\nNote that we could also have used $u=-5x^3$, but then $du=-15x^2\\,dx$,\nand so our\nanswer would ultimately be \n(as the reader should verify) \n$-\\frac{1}{15}\\tan^{-1}\\left(-5x^3\\right)+C$.\nIn fact that is the same as the answer we got, since the arctangent\nis an ``odd'' function, that is, $\\tan^{-1}(-z)=-\\tan^{-1}z$.\n%%% END FOOTNOTE\n}\nFortunately this was consistent with the $du$ containing the $x^2$ term\nof the integrand, and that form (\\ref{IntGivingArcTanURl})\ncould actually be used.  In the next section we will\nsee how to deal with cases where the additive constant in the denominator\nof the integrand is not $1$.  For now we look at another complication\nwhich is somewhat specific to the arcsecant form.\n\n\\bex Compute $\\ds{\\int\\frac1{x\\sqrt{9x^2-1}}\\,dx}$.\n\n\\underline{Solution}: Because a new complication needs to be explained\nwhile the problem is solved, the organization will be slightly different\nthan previous exercises, but every technique used below has appeared\npreviously. Note that we are trying to fit this integral into\nform (\\ref{IntGivingArcSec|U|Rl}).\n\nHere we want $u^2=9x^2$ so we have $\\sqrt{u^2-1}$ as one factor in\nthe denominator of our integrand.  Thus will let \n$u=3x\\implies du=3\\,dx\\iff\\frac13\\,du=dx$.  Our integral so far is then\n$$\\int\\frac1{x\\sqrt{u^2-1}}\\,\\cdot\\frac13\\,du.$$\nNow, all of our integral formulas require just one variable, but\nin fact the integral above makes sense because of the relationship \nbetween $x$ and $u$.  But to use a formula we have to put it all into the\nnew variable, namely $u$.  So there is one term left, which is the \nfactor $x$ on the bottom, which has to be put into $u$-terms.\nFor that we go back to our original substitution and note that\n$u=3x\\iff x=\\frac13\\,u$.  Now we continue:\n\\begin{align*}\n\\int\\frac1{x\\sqrt{9x^2-1}}\\,dx&=\\int\\frac1{x\\sqrt{u^2-1}}\\,\\cdot\\frac13\\,du\\\\\n &=\\int\\frac1{\\frac13\\,u\\sqrt{u^2-1}}\\cdot\\frac13\\,du\\\\\n &=\\int\\frac1{u\\sqrt{u^2-1}}\\,du\\\\\n &=\\sec^{-1}|u|+C\\\\\n &=\\sec^{-1}|3x|+C.\\end{align*}\n\\label{FirstWackySecantU-SubProblem}\\eex\n\n\n\\newpage\n\\begin{center}\n\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item Compute $\\ds{\\int x e^{x^2}\\,dx}$ two ways.\n \\begin{enumerate}\n \\item Let $u=x^2$ (as in Example~\\ref{IntXE^x^2Example}).\n \\item Instead let $u=e^{x^2}$.\n \\end{enumerate}\n\\item In the spirit of the previous exercise,\n      compute $\\ds{\\int\\frac{e^{1/x}}{x^2}\\,dx}$\n      two ways, i.e., using two different substitutions.\n\\item Compute $\\ds{\\int\\sec^2x\\tan x\\,dx}$\n      two different ways.\n \\begin{enumerate}\n \\item Let $u=\\tan x$.\n \\item Instead let $u=\\sec x$.\n \\item Explain why the two answers are equivalent.\n \\end{enumerate}\n\\end{enumerate}\\end{multicols}\n\n\n\\newpage\n\\section{Further Arctrigonometric Forms}\n\nHere we will still use the same arctrigonometric forms\nwe had before, namely\n\\begin{align}\n\\int\\frac1{\\sqrt{1-u^2}}\\,du&=\\sin^{-1}u+C,\\label{IntGivingArcSinUR2}\\\\\n\\int\\frac1{u^2+1}\\,du&=\\tan^{-1}u+C,\\label{IntGivingArcTanUR2}\\\\\n\\int\\frac1{u\\sqrt{u^2-1}}\\,du&=\\sec^{-1}|u|+C.\\label{IntGivingArcSec|U|R2}\n\\end{align}\nWhat is different in this section is that our integrals will\nneed to be algebraically rewritten into these forms, and this will\nrequire more than the previous substitution.\n\nEach of the integrals in (\\ref{IntGivingArcSinUR2}), \n(\\ref{IntGivingArcTanUR2}) and (\\ref{IntGivingArcSec|U|R2})\nneed to be exactly as they are stated.  For instance, replacing\n$1-u^2$ with $1+u^2$ or $u^2-1$ in  (\\ref{IntGivingArcSinUR2})\nwill give completely different antiderivatives.  In fact, even\nthe domain of the integrand would be completely different\nwith any such changes!  Similar changes would substantially alter\nthe results in\n(\\ref{IntGivingArcTanUR2}) and (\\ref{IntGivingArcSec|U|R2}).\n\nIn this section we will have integrands which we can algebraically\nrewrite so they conform to one of the forms (\\ref{IntGivingArcSinUR2}), \n(\\ref{IntGivingArcTanUR2}) or (\\ref{IntGivingArcSec|U|R2}).\nIn fact there are only a couple of algebraic ``tricks'' which we\nintroduce here.  The first of these is to force the denominators\nto have the additive constant $1$, where originally there may\nbe another constant.  This is accomplished through simple factoring\ntechniques.  The second technique is ``completing the square,''\nwhere appropriate, and then using the first technique to \nfinish rewriting the integrand.  With substitution there will\noften be further multiplicative constants to accommodate as well.\n\n\\subsection{Factoring to Achieve ``1''}\nEach of our integrals (\\ref{IntGivingArcSinUR2}), \n(\\ref{IntGivingArcTanUR2}) and (\\ref{IntGivingArcSec|U|R2})\nhave the number $1$ conspicuously appearing in the denominator,\nnear the $u^2$ term.  Any other nonzero {\\it constant} there\nwill have an effect on the vertical and horizontal scaling\nof the function in ways we can not ignore in the formula.\nTo compensate is fairly straightforward: factor the constant,\nand see what should be called ``$u^2$.''\n\n\\bex Compute $\\ds{\\int\\frac1{9+x^2}\\,dx}$.\n\n\\underline{Solution}: Our first priority is to rewrite this so\nwe have a form $1+u^2$ in the denominator.\n$$\\int\\frac1{9+x^2}\\,dx=\\int\\frac1{9\\left(1+\\frac{x^2}9\\right)}\\,dx\n                       =\\int\\frac19\\cdot\\frac1{1+\\frac{x^2}9}\\,dx.$$\nThe factor $\\frac19$ can simply be carried along for the rest of the\ncomputation.  The denominator of the other factor can be\nwritten $1+u^2$  (same as $u^2+1$ in our formula) if we\ntake $u^2=\\frac{x^2}9$, which can be accomplished letting $u=\\frac{x}3$.\n\\begin{align*}\n\\int\\frac1{9+x^2}\\,dx&=\\frac1{9}\\cdot\\int\\frac1{1+\\frac{x^2}9}\\,\\underline{dx}\n                    =\\frac1{9}\\int\\frac{1}{1+u^2}\\cdot\\underline{3\\,du}\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\frac{x}3\\\\\n&\\implies&du&=\\frac13\\,\\underline{dx}\\\\\n&\\iff&3du&=\\underline{dx}\n\\end{alignedat}\\right|\n&=\\frac39\\tan^{-1}u+C=\\frac13\\tan^{-1}\\left(\\frac{x}3\\right)+C.\\end{align*}\n\\eex\nThe above example illustrated much of the process:  algebraically\nmanipulate by factoring to achieve ``$1$'' in the appropriate place,\nand then pick $u$ so the other term is $u^2$.  It is slightly\nmore complicated with the forms yielding arcsine and arcsecant, \ndue to the presence of the radical.  In the next example\nwe will show more detail than one might normally write.\n\n\\bex Compute $\\ds{\\int\\frac1{\\sqrt{25-4x^2}}\\,dx}$.\n\n\\underline{Solution}: Here we must find a way to replace the \nconstant 25 with 1 instead.  We factor as before, but respect\nthe operation of the radical as well.\n$$\\int\\frac1{\\sqrt{25-4x^2}}\\,dx\n=\\int\\frac1{\\sqrt{25\\left(1-\\frac{4x^2}{25}\\right)}}\\,dx\n=\\int\\frac1{\\sqrt{25}\\sqrt{1-\\frac{4x^2}{25}}}\\,dx\n=\\int\\frac15\\cdot\\frac1{\\sqrt{1-\\frac{4x^2}{25}}}\\,dx.$$\nSo the factor 25 under the radical becomes the factor 5 outside\nthe radical.  Otherwise it is the same process as the previous\nexample.  Now we continue, using a substitution which will\nresult in $u^2=\\frac{4x^2}{25}$.  For simplicity we take $u=\\frac{2x}5$.\n\\begin{align*}\n\\int\\frac1{\\sqrt{25-4x^2}}\\,\\underline{dx}\n &=\\frac15\\int\\frac1{\\sqrt{1-\\frac{4x^2}{25}}}\\,\\underline{dx}\n =\\frac15\\int\\frac1{\\sqrt{1-u^2}}\\cdot\\underline{\\frac52\\,du}\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\frac{2x}5\\\\\n&\\implies&du&=\\frac25\\cdot\\underline{dx}\\\\\n&\\iff&\\frac52\\,du&=\\underline{dx}\\end{alignedat}\\right|\n&=\\frac12\\sin^{-1}u+C=\\frac12\\sin^{-1}\\left(\\frac{2x}5\\right)+C.\n\\end{align*}\n\\eex\nThis example above again illustrates the role of the number $1$\nin the denominator, but also\nsuggests a couple of new points that we make here.\nFirst, it is not obvious where the factors $2$ and $5$---being\nthe square roots of the $4$ and $25$ appearing in the original---will\nbe present in the final answer.  There is a pattern for the\narctangent form, and a different one for the arcsine form, but\npatterns can be forgotten if not used often enough, where the logic\nof manipulating the integral algebraically to get one of the\nthree basic arctrigonometric forms should still be reproducible\nafter the patterns---which we will explore at the end of this \nsection---are forgotten.  Second, we are approaching the\nboundary between integrals which are easily checked with \ndifferentiation, and those where the differentiation has at least\nas many algebraic difficulties as the integration.  In such cases,\nit is usually better to have carefully written each integration step so it\ncan be audited for accuracy, rather than risk algebraic error in\ntesting our answer.  Consider a verification of the answer in this\nlatest example (readers' steps may vary):\n\\begin{align*}\n\\frac{d}{dx}\\left[\\frac12\\sin^{-1}\\left(\\frac{2x}5\\right)\\right]\n&=\\frac12\\cdot\\frac1{\\sqrt{1-\\left(\\frac{2x}{5}\\right)^2}}\n \\cdot\\frac{d}{dx}\\left[\\frac{2x}5\\right]\n=\\frac12\\cdot\\frac1{\\sqrt{1-\\frac{4x^2}{25}}}\\cdot\\frac25\\\\\n&=\\frac15\\cdot\\frac1{\\sqrt{1-\\frac{4x^2}{25}}}\n=\\frac1{\\sqrt{25}}\\cdot\\frac1{\\sqrt{1-\\frac{4x^2}{25}}}\n=\\frac1{\\sqrt{25-4x^2}},\\qquad\\text{q.e.d.}\n\\end{align*}\nWhile such a verification is certainly possible, it is not likely one\nto be performed ``mentally'' with much confidence,\nas we may have been able to do with\nmany previous computations.  Indeed \nthere are enough constants to be accommodated\nthat this verification should be done in careful writing.\nIn most of \nChapter~\\ref{AdvancedIntTechniques} we will see much more complicated\nrewritings of integrals, and  verification will usually be much better\naccomplished by checking our individual steps in integration rather than\nby differentiating of our answers.\n\nOur next example just takes this theme one step further.  Recall\nthat substitution in the arcsecant form had a slight complication,\nwhich was that the $u$-variable appeared both inside and outside\nthe radical.  This caused a minor complication in\nExample~\\ref{FirstWackySecantU-SubProblem}, \npage~\\pageref{FirstWackySecantU-SubProblem} for instance.\nA similar problem will occur in this next example.\n\n\\bex Compute $\\ds{\\int\\frac1{x\\sqrt{81x^2-16}}\\,dx}$.\n\n\\underline{Solution}: As with the previous two examples,\nit is necessary to have a $1$ in the place presently\noccupied by $16$, so we will factor the $16$ from the\nradical.  The other algebraic difficulties will be\ntaken care of by the substitution. Indeed, the remaining\nterm under the radical must be $u^2$, and the rest of the\nform will follow, with residual multiplicative constants.\n\\begin{align*}\n\\int\\frac1{x\\sqrt{81x^2-16}}\\,\\underline{dx}\n&=\\int\\frac1{4x\\sqrt{\\frac{81x^2}{16}-1}}\\,\\underline{dx}\n=\\int\\frac1{4\\cdot\\frac{4u}9\\sqrt{u^2-1}}\\cdot\\underline{\\frac49\\,du}\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\frac{9x}4\\\\\n&\\implies&du&=\\frac94\\cdot \\underline{dx}\\\\\n&\\iff&\\frac49\\,du&=\\underline{dx}\\\\\n\\hline\n\\text{also,}&&u&=\\frac{9x}4\\\\\n&\\iff&x&=\\frac{4u}9\\end{alignedat}\n\\right|&=\\int\\frac1{4u\\sqrt{u^2-1}}\\,du\n        =\\frac14\\sec^{-1}|u|+C\n        =\\frac14\\sec^{-1}\\left|\\frac{9x}4\\right|+C.\n\\end{align*}\nNote how the term $\\frac{81x^2}{16}$ under the radical became\nsimply $u^2$, and then the term $x$ outside the \nradical became $\\frac{4u}{9}$, both consistent with\n$u=\\frac{9x}{4}$.  Also note that a factor of\n$\\frac49$ in the denominator canceled with the same\nfactor multiplying the differential $du$.\n\\eex\nThis latest example again illustrates the points made before:\nthat having the $1$-term \nin the denominator is the key to the whole process,\nthat the rest is taken care of by the $u$-substitution which follows\nand finally, that checking by differentiation is nontrivial.\n\nAnother minor complication is that the numbers we must factor might\nnot be perfect squares.  The process is exactly the same,\nthough perhaps some more care is required.\n\n\\bex Compute $\\ds{\\int\\frac1{\\sqrt{5-2x^2}}\\,dx}$.\n\n\\underline{Solution}: The process is exactly the same as before.\nThe key is to factor the denominator to have a $1$ in the place\nof the $5$:\n\\begin{align*}\n\\int\\frac1{\\sqrt{5-2x^2}}\\,dx\n&=\\int\\frac1{\\sqrt{5}\\cdot\\sqrt{1-\\frac{2x^2}5}}\\,dx\n =\\frac1{\\sqrt{5}}\\int\\frac1{\\sqrt{1-u^2}}\n     \\cdot\\underline{\\sqrt{\\frac52}\\cdot du}\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\sqrt{\\frac25}\\cdot x\\\\\n&\\implies&du&=\\sqrt{\\frac25}\\cdot\\underline{dx}\\\\\n&\\iff&\\sqrt{\\frac52}\\cdot du&=\\underline{dx}\n\\end{alignedat}\\right|\n&=\\frac{1}{\\sqrt2}\\,\\sin^{-1}u+C\n =\\frac1{\\sqrt2}\\,\\sin^{-1}\\left(\\sqrt{\\frac25}\\cdot x\\right)+C.\n\\end{align*}\n\n\\eex\n\n\\subsection{Completing the Square}\nIn the previous subsection our first concern after identifying our\ntarget form was to rewrite the integrand to have the number $1$\nin the appropriate place in the denominator.  In this subsection\nour first concern is identifying, except for a multiplicative\nconstant, what will be $u^2$.  We do this by completing the \nsquare first, and then fixing the form to have the number\n$1$ where we need it, and working from there as before.\nAs there are differing levels of difficulty in such problems,\nwe will begin with one of the simplest and continue from there.\nIt should be noted that the completing the square step is\nsometimes needed before determining that one of our three forms,\n(\\ref{IntGivingArcSinUR2}), \n(\\ref{IntGivingArcTanUR2}) or (\\ref{IntGivingArcSec|U|R2}),\ncan even be achieved.  If not, and we are fortunate, another\nearlier method may work, though usually we should notice that\nbefore attempting the method here.  If no earlier method will work,\nthere may be a method available in Chapter~\\ref{AdvancedIntTechniques} \nthat will solve the problem.\n\nRecall that when completing the square, one adds and subtracts\n$(b/2)^2$, where the original polynomial is $x^2+bx$, or \nmore generally $x^2+bx+c$:\n\\begin{align*}\nx^2+bx+c&=x^2+bx+\\left(\\frac{b}2\\right)^2-\\left(\\frac{b}2\\right)^2+c\\\\\n&=\\left(x+\\frac{b}2\\right)^2-\\left(\\frac{b}2\\right)^2+c.\\end{align*}\nAs we will see, the fact that the coefficient of $x^2$ was $1$\nwas key to the computation above.  If not, the leading coefficient \nwill be factored from the $x^2$ and $x$ terms. Our first \nexamples will not require that inititial factoring.\n\n\n\\bex Compute $\\ds{\\int\\frac1{x^2+2x+2}\\,dx}$.\n\n\\underline{Solution}: The hope is that we can somehow write the\ndenominator as $1+u^2$, perhaps multiplied by some nonzero constant,\nwithout introducing any more variable factors.  For this one we\nare unusually fortunate. Note that here ``$b$'' is 2.\n\\begin{align*}\n\\int\\frac1{x^2+2x+2}\\,dx&\n=\\int\\frac1{x^2+2x+\\left(\\frac22\\right)^2-\\left(\\frac22\\right)^2+2}\\,dx\n=\\int\\frac1{x^2+2x+1-1+2}\\,dx\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=x+1\\\\\n&\\implies&du&=dx\n\\end{alignedat}\\right|\n&=\\int\\frac1{(x+1)^2+1}\\,dx\n =\\int\\frac1{u^2+1}\\,du=\\tan^{-1}u+C=\\tan^{-1}(x+1)+C.\n\\end{align*}\n\\eex\nWhat made this last example particularly simple was that the\nadditive constant outside of the perfect square was already $1$,\nwhich is of course key to our arctrigonometric antiderivative forms.\nIf not, we have to perform some division.\n\\bex Compute $\\ds{\\int\\frac1{x^2+6x+17}\\,dx}$.\n\n\\underline{Solution}: Here $b=3$, so we add and subtract\n$\\left(\\frac{b}3\\right)^2=9$.\n\\begin{align*}\n\\int\\frac1{x^2+6x+17}\\,dx\n&=\\int\\frac1{x^2+6x+9-9+17}\\,dx=\\int\\frac1{(x+3)^2+8}\\,dx\n=\\frac18\\int\\frac1{\\frac{(x+3)^2}8+1}\\,dx\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\frac{x+3}{\\sqrt8}\\\\\n&\\implies&du&=\\frac1{\\sqrt8}\\,dx\\\\\n&\\iff&\\sqrt8\\,du&=dx\n\\end{alignedat}\\right|\n&=\\frac18\\int\\frac1{u^2+1}\\cdot\\sqrt8\\,du\n =\\frac1{\\sqrt8}\\tan^{-1}u+C\n =\\frac1{\\sqrt8}\\tan^{-1}\\left(\\frac{x+3}{\\sqrt8}\\right)+C.\n\\end{align*}\n\\eex\nAs this last example illustrates, the final form of the antiderivative\ncan be more complicated when completing the square is required.  While it \nwould be an interesting exercise to verify the answer by differentiation,\nperhaps verifying each individual step in the solution process would\nbe a more efficient means of verifying the answer we derived.\n\nFor simplicity we will continue with arctangent forms for the moment,\nas we look at the next complication, which is that the coefficient of \n$x^2$ is not equal to 1.  In such a case we factor that leading\ncoefficient out of the entire polynomial, or at least out of the\n$x^2$ and $x$ terms.  It is then important to perform\nthe addition and subtraction steps of completing the square\nwithin the factor with the $x^2$ and $x$ terms;  the addition\nand subtraction of the $(b/2)^2$ in the process must occur\nsimultaneously and beside eachother.  Note that such a term\nhas a different effect inside parentheses (or brackets) compared\nto outside, so we must have the addition and subtraction\nsteps together in order that numerically they have no net effect.\n\n\\bex Compute $\\ds{\\int\\frac1{5x^2-4x+9}\\,dx}$.\n\n\\underline{Solution}: Our first priority is to have the \ncoefficient of $x^2$ to be $1$, after which we complete the\nsquare and finish the problem.\n\\begin{align*}\\int\\frac1{5x^2-4x+9}\\,dx\n&=\\int\\frac1{5\\left[x^2-\\frac45\\,x+\\frac95\\right]}\\,dx\n=\\int\\frac1{5\\left[x^2-\\frac45+\\left(\\frac25\\right)^2-\\left(\\frac25\\right)^2\n              +\\frac95\\right]}\\,dx\\\\\n&=\\int\\frac1%\n{5\\left[\\left(x-\\frac25\\right)^2-\\frac4{25}+\\frac{45}{25}\\right]}\\,dx\n=\\frac15\\int\\frac1{\\left[\\left(x-\\frac25\\right)^2+\\frac{41}{25}\\right]}\\,dx\n\\end{align*}\n(Note how we added and subtracted $(2/5)^2$ together, both within the \nbrackets.)\nNow we need to manipulate this integral so there is a $1$ \nin place of the fraction $\\frac{41}{25}$, which we do as before,\nby factoring. Continuing,\n\\begin{align*}\n\\int\\frac1{5x^2-4x+9}\\,dx&=\\cdots\\\\\n&=\\frac15\\int\\frac1{\\left[\\left(x-\\frac25\\right)^2+\\frac{41}{25}\\right]}\\,dx\\\\\n&=\\frac15\\int\\frac1{\\frac{41}{25}\\biggl[\\,\n \\underbrace{\\frac{25}{41}\\left(x-\\frac25\\right)^2}_{\\text{``$u^2$''}}\n +1\\,\\biggr]}\\,dx\\\\\n\\left.\\begin{alignedat}{2}\n&&u&=\\frac5{\\sqrt{41}}\\left(x-\\frac25\\right)\\\\\n&\\implies&du&=\\frac5{\\sqrt{41}}\\,dx\\\\\n&\\iff&\\frac{\\sqrt{41}}5\\,du&=dx\\end{alignedat}\\right|\n&=\\frac15\\cdot\\frac{25}{41}\\int\\frac1{u^2+1}\\cdot\\frac{\\sqrt{41}}5\\,du\\\\\n&=\\frac1{\\sqrt{41}}\\tan^{-1}u+C\n =\\frac1{\\sqrt{41}}\\tan^{-1}\\left[\n           \\frac5{\\sqrt{41}}\\left(x-\\frac25\\right)\\right]+C.\n\\end{align*}\n\n\\eex\n\n\n\n\\newpage\n\\section{Hyperbolic Functions}\nThe algebraic and differential structure embedded in the trigonometric\nfunctions made for some surprising, but useful derivative and integral\nformulas involving the arctrigonometric functions.  As it happens,\nthere is another genre of functions with a similar, yet distinct\nstructure, that genre being the so-called {\\it hyperbolic functions}.\n\nIn fact the hyperbolic functions are somewhat redundant, in that\nthey are based upon exponential functions and the more interesting\nintegration formulas can be arrived at through other methods.  However,\nexploiting these functions can greatly simplify certain types of \nintegration problems, as we will see.\n\nWe will begin with definitions, derivatives and some identities \ninvolving the hyperbolic functions.  We will then \nlook at their graphs, and consider what their ``inverses'' \nwould look like, and how they play out in derivative and integral\nformulas.  Along the way we will compare them to their trigonometric\ncounterparts and see how a sign ($\\pm$) here or there can make\na crucial difference in an integration problem.\n\n\\subsection{Hyperbolic Functions and Their Basic Intrinsic Structures}\nWe begin with the hyperbolic sine and hyperbolic cosine functions.\nThese can be defined geometrically, but unlike their trigonometric\ncounterparts, these also have  straightforward definitions\nin terms of our earlier, familiar functions (though it is not \nobvious from the geometry!):\n\\begin{align}\n\\sinh x&=\\frac12\\left(e^x-e^{-x}\\right)=\\frac{e^x-e^{-x}}{2},\n      \\label{DefSinh}\\\\\n\\cosh x&=\\frac12\\left(e^x+e^{-x}\\right)=\\frac{e^x+e^{-x}}2.\n      \\label{DefCosh}\n\\end{align}\nThe others are defined in terms of these, just as with the\ntrigonometric functions.  Before we define \nthe others, we will notice a couple of relationships which are\nsimilar, though distinct, from what occurs with the trigonometric\nfunctions.  The first result is algebraic:\n\n\\begin{theorem}  For all $x\\in\\Re$, we have\n\\begin{equation}\\cosh^2x-\\sinh^2x=1.\\label{Cosh^2X-Sinh^2X=1}\n\\end{equation}\n\\end{theorem}\nFor the proof, we just expand the left-hand side:\n\\begin{align*}\n\\cosh^2x-\\sinh^2x&=\\left(\\frac{e^x+e^{-x}}2\\right)^2\n                   -\\left(\\frac{e^x-e^{-x}}2\\right)^2\\\\\n                  &=\\frac{e^{2x}+2e^xe^{-x}+e^{-2x}}4\n                   -\\frac{e^{2x}-2e^xe^{-x}+e^{-2x}}4\\\\\n                  &=\\frac{\\not{e^{2x}}+2e^0+\\not{e^{-2x}}-\n                   \\not{e^{2x}}+2e^0-\\not{e^{-2x}}}4\\\\\n                  &=\\frac{2+2}4\\\\\n                  &=1,\\text{ q.e.d.}\\end{align*}\nOf course this is the hyperbolic analog of the basic trigonometric\nidentity $\\cos^2\\theta+\\sin^2\\theta=1$.  As we will see, the \ndifference in the signs between the trigonometric identity\nand (\\ref{Cosh^2X-Sinh^2X=1}) makes for analogous, but significantly\ndistinct results throughout the hyperbolic development.  We next\nlook at the derivatives of these:\n\\begin{theorem} For $x\\in\\Re$, we have\n\\begin{align}\n\\frac{d}{dx}\\sinh x&=\\cosh x, \\label{DerivSinhX}\\\\\n\\frac{d}{dx}\\cosh x&=\\sinh x. \\label{DerivCoshX}\n\\end{align}\n\\end{theorem}\nThese are simple chain rule computations.  For the first\ncase, we have\n$$\n\\frac{d}{dx}\\left[\\frac12\\left(e^x-e^{-x}\\right)\\right]\n=\\frac12\\left(e^x-e^{-x}\\frac{d(-x)}{dx}\\right)\n=\\frac12\\left(e^x-e^{-x}(-1)\\right)\n=\\frac12\\left(e^x+e^{-x}\\right)$$\ni.e., $\\frac{d}{dx}\\sinh x=\\cosh x$.\nThat $\\frac{d}{dx}\\cosh x=\\sinh x$ is similar.  Note\nhow these compare to derivative formulas for $\\sin x$ and\n$\\cos x$.\n", "meta": {"hexsha": "9821828d15b1d14fce1857ebc8759c6729989566", "size": 120980, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "michael.dougherty/chapter06.tex", "max_stars_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_stars_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "michael.dougherty/chapter06.tex", "max_issues_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_issues_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "michael.dougherty/chapter06.tex", "max_forks_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_forks_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6436376454, "max_line_length": 79, "alphanum_fraction": 0.7069102331, "num_tokens": 39977, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.4239972393042189}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[option1, option2]{package}\n\n\\begin{document}\n\n% Here is a comment. Commands in tex are called by backslash: \\command \n\\section{Section head}\n\\subsection{Subsection head}\n\nThis is text, and the following is in-line mathematics: \n$\\mathrm{e}^{-\\pi\\matrhm{i}} = -1$. \nA display-style equation is shown below:\n\n\\begin{equation}\n  E = mc^2\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "184adcc3ea3aad0189680377f5e12a21d3170981", "size": 409, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "templates/vim/vivify/latex.tex", "max_stars_repo_name": "raylu/terminal.sexy", "max_stars_repo_head_hexsha": "161714d140181911b7fa5a618781fb02b8cd3dd9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 836, "max_stars_repo_stars_event_min_datetime": "2015-01-01T17:31:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T12:05:21.000Z", "max_issues_repo_path": "templates/vim/vivify/latex.tex", "max_issues_repo_name": "raylu/terminal.sexy", "max_issues_repo_head_hexsha": "161714d140181911b7fa5a618781fb02b8cd3dd9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 50, "max_issues_repo_issues_event_min_datetime": "2015-01-12T13:26:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T19:25:06.000Z", "max_forks_repo_path": "templates/vim/vivify/latex.tex", "max_forks_repo_name": "raylu/terminal.sexy", "max_forks_repo_head_hexsha": "161714d140181911b7fa5a618781fb02b8cd3dd9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 83, "max_forks_repo_forks_event_min_datetime": "2015-06-20T03:15:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T11:36:23.000Z", "avg_line_length": 20.45, "max_line_length": 71, "alphanum_fraction": 0.7261613692, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4239835136237395}}
{"text": "\\newpage\n\\chapter{Plug flow reactor}\n\n\\section{Introduction}\nThe plug flow reactor model of Camflow simulates a one dimensional plug flow reactor with gas-phase chemistry. The model can handle a number of temperature conditions such as isothermal, non-isothermal, or user defined temperature profiles. \n\n\\section{Fundamentals}\nThe plug flow reactor model solves the governing equations for continuity\n\\begin{equation}\n \\frac{\\rho u A_c}{dz} = 0,\n\\end{equation}\nspecies continuity\n\\begin{equation}\n \\rho u A_c\\frac{dY_k}{dz} = W_kA_c\\dot{\\omega}_k \\quad k=1\\ldots K_g,\n\\end{equation}\nenergy equation\n\\begin{equation}\n \\rho u A_c\\frac{c_pdT}{dz} + \\sum_{k=1}^{K_g} \\dot{\\omega}_kh_kW_kA_c = UA_s(T_w-T),\n\\end{equation}\nand the equation of state\n\\begin{equation}\n p\\bar{W}=\\rho R T.\n\\end{equation}\nIn the above equations, $\\rho$ is the density in kg/m$^3$, $u$ is the velocity in m/s, $A_c$ is the area of cross section in m$^2$, $Y_k$ is the mass fraction of the k\\'th chemical species, $W_k$ is the molecular mass in kg/mol of the k\\'th chemical species, $\\dot{\\omega}_k$ is the molar production rate in mol/m$^3$-s of the k\\'th chemical species, $c_p$ the specific heat at constant pressure in J/mol-K, $T$ the temperature in K, $T_w$ is the temperature of the wall in K, $A_s$ is the surface area per unit volume, and $U$ is the over all heat transfer coefficient in J/m$^2$sK.\n\n\\section{Input file}\nAn example of ``camflow.xml'' is shown below\n{\\scriptsize{\\begin{verbatim}\n<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<camflow>\n   <reactor model=\"plug\">\n    <diameter unit=\"m\">0.015</diameter>\n    <length unit=\"cm\">5</length>\n  </reactor>\n  <op_condition>\n     <step_ignite>10</step_ignite>\n     <temperature>isothermal</temperature>\n     <twall unit=\"K\">1073</twall>\n    <pressure unit=\"Pa\">1e5</pressure>\n  </op_condition>\n  <inlet>\n     <fuel>\n       <velocity unit=\"m/s\">0.1</velocity>\n       <temperature unit=\"C\">800</temperature>\n       <!--flowrate unit=\"cgs\">4.63e-3</flowrate-->\n       <molefrac>\n        <species name=\"NO2\">0.1</species>\n        <species name=\"N2\">*</species>\n       </molefrac>\n     </fuel>\n  </inlet>\n  <solver mode=\"coupled\" solver=\"cvode\">\n     <tols>\n        <species>\n           <aTol>1.e-06</aTol>\n           <rTol>1.e-06</rTol>\n        </species>\n        <temperature>\n           <aTol>1.e-03</aTol>\n           <rTol>1.e-03</rTol>\n        </temperature>\n        <flow>\n           <aTol>1.e-03</aTol>\n           <rTol>1.e-03</rTol>\n        </flow>\n     </tols>\n  </solver>\n  <initialize>    \n    <Tprofile unit_L=\"cm\" unit_T=\"K\">\n      <position x=\"0.0\">373.7</position>\n      <position x=\"0.125\">484.5</position>\n      <position x=\"0.25\">583.7</position>\n      <position x=\"0.375\">672.2</position>\n      <position x=\"0.5\">753.5</position>\n      <position x=\"0.75\">901.4</position>\n      <position x=\"1.0\">1027.0</position>\n      <position x=\"1.25\">1120.0</position>\n      <position x=\"1.5\">1184.0</position>\n      <position x=\"2.0\">1260.0</position>\n      <position x=\"3.0\">1348.0</position>\n      <position x=\"6.0\">1475</position>\n      <position x=\"10.0\">1524.0</position>\n    </Tprofile>\n </initialize>\n <report species=\"mole\">\n </report>\n</camflow>\n\n\\end{verbatim}}\n\n}\n\nThe input file follows xml specification with a number of child elements. Each child element is described in detail below.\n\n\\begin{itemize}\n \\item \\textbf{rector} : The reactor element specifies which reactor models is to be simulated and for a plug flow reactor camflow expects plug as the model attribute value. The reactor element also holds child element for specifying reactor diameter and the reactor length, and each child element is given with the unit attribute. The unit of the value specified can be in ``cm'', ``m'', or in ``in''ches. Appropriate attribute must be specified.\n\n\\item \\textbf{op\\_conditions} : The element op\\_conditions describes the operating conditions for the plug flow reactor. This includes the specification of the pressure and the condition applied to the solution of energy equation. The reactor pressure may be specified in the units of ``Pa'', ``atm'', or ``bar''. The temperature unit can be either in ``K'' or in ``C''. The temperature element can take the values of ``isothermal'', ``adiabatic'', ``userdefined'', or ``nonisothermal''. In the case of isothermal calculation, the energy equation is not solved and the reactor is assumed to be at the same temperature as the incoming fuel. The user may also perform the integration for a pre-calculated or measured temperature profile. In this case the temperature child element must be assigned with the value ``userdefined'' and the user defined temperature profile cane specified (explained later). For adiabatic calculations, provide the temperature element with the value ``adiabatic''. Radiation heat losses from the reactor are completely neglected. For non-isothermal calculation it is mandatory to specify the reactor wall temperature. The heat transfer coefficient is calculated internally as a function of reactor position using the following correlation.\n\\begin{equation}\n Nu= \\frac{hD}{k},\n\\end{equation}\nwhere $Nu$ is the Nusselt number, $h$ the heat transfer coefficient, $D$ the diameter and $k$ the thermal conductivity. The Nusselt number is defined as\n\\begin{equation}\n Nu = 3.657+8.827\\bigg(\\frac{1000}{\\mathrm{Gz}}\\bigg)^{-0.545} \\exp\\bigg(\\frac{-48.2}{\\mathrm{Gz}}\\bigg),\n\\end{equation}\nand the Greatz number Gz is defined as\n\\begin{equation}\n \\mathrm{Gz} = \\frac{D Re Pr}{z}\n\\end{equation}\nwith D the diameter, $Re$ the Reynolds\\'s number, $Pr$ the Prandtl number, and $z$ the axial position of the reactor. In this version, the overall heat transfer coefficient is replaced with the heat transfer coefficient calculated from Nusselt number. Strictly speaking the correlation presented above are valid only for a non-reacting multi-component gas mixture. However, the above correlations are used for reacting case as well due to the non-availability of better formulations.\\\\\n\n\\textbf{step\\_ignite} is an option to evaluate the minimum temperature required to ignite the gas-mixture and is optional. However, if the user is not interested in the ignition temperature, this element should not be present in the inputfile. If its present then \\textbf{step\\_ignite} must specify the step for temperature increment, and the \\textbf{temprature} specification must be ``adiabatic''. The ignition temperature calculated is not printed to the output file, rather only a screen output is generated.\\\\\n\n\\item \\textbf{inlet} : The inlet element holds the information on reactants and the reactant temperature at axial position at z=0, and the flow rate or velocity at z=0; Either the velocity or the flow rate needs to be specified. The velocity may be specified in m/s or in cm/s, while the flow rate may be specified in ``cgs'' units or in ``si'' units. The temperature of the reactants must be specified using the temperature element with the appropriate units. The mass or mole fraction of the reactant species need to be specified within the element molefrac or massfrac. The sum of mass fractions or mole fraction of the reactant species must sum up to 1. Instead of specifying the mass/mole fractions of all species, the last species can be assigned with *. In this case the mole/mass fraction of the last species will be 1-sum of others.\n\n\\item \\textbf{solver}: The solver element holds the solver control specifications. The attributes ``mode'' should always be specified as ``coupled'' for plug flow reactor simulation. The solver name is essentially provided to switch from one solver to another. However, the present version of Camflow uses only CVode as the numerical integrator, and therefore accepts only ``cvode'' as the solver name. The element ``tols'' hold the various tolarences that can be applied to the species, energy, and continuity equations. For species a relative tolarence of at least 10$^{-6}$ should be used. The user may need to adjust the tolarence values for the species in case of solution difficulties.\n\n\\item \\textbf{initialize} The initialize element can be used to specify various initial conditions. However, for plug flow reactor model, the only initial property that can be specified is the user defined temperature profile. The temperature profile can be specified by using the ``Tprofile'' element with two attributes namely ``unit\\_L'' for length unit and ``unit\\_T'' for temperature unit. The length unit can be in ``cm'' or in ``m'', where as the temperature unit can be either in ``K'' or in ``C''. The actual temperature as a function of reactor position is specified with the child elements position with the attribute ``x'', which stands for the position with the reactor. If the length unit is specified as ``cm'' then ``x'' is the position from the reactor inlet in ``cm'', and the value for the position element is the temperature at position ``x''.\n\n\\item \\textbf{report}: The desired output for the species composition must be specified in this element using the species attribute. ``mole'' or ``mass'' may be used as the attribute values, and correspondingly the output will be produced either in mole fraction or mass fractions.\n\n\\end{itemize}\n\n\\section{Executing the binary}\nThe plug reactor model of Camflow expects three input files namely, ``camflow.xml'', ``therm.dat'',  ``chem.inp''. For performing non-isothermal calculation an additional file ``tran.dat'' specifying the transport data of all chemical species present in the system need to be specified. All these files must be present in the working directory. Upon succesful execution the output file ``profile.dat'' containing the axial position (m), density (kg/m$^3$), velocity (m/s), massflow rate (kg/m$^2$s), residence time (1/s) temperature (K), and the species compositions in mass or mole fractions.\n\n\\section{Results}\nThe following figure shows the species profiles and temperature for Hydrogen oxidation reaction \n\\begin{figure*}[h]\n \\centering\n\\includegraphics[scale=0.6]{plug_profile.eps}\n\\caption{Species profiles hydrogen oxidation with user defined temperature profile}\n\\end{figure*}\n\n%===============================================================================================\n%\n%\n%\n%===============================================================================================\n\n", "meta": {"hexsha": "475ef8101dcfa1e2b311650b40468885105c3301", "size": 10335, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/supporting-information/camflow/plug.tex", "max_stars_repo_name": "sm453/MOpS", "max_stars_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-08T14:06:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-04T07:52:19.000Z", "max_issues_repo_path": "doc/supporting-information/camflow/plug.tex", "max_issues_repo_name": "sm453/MOpS", "max_issues_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/supporting-information/camflow/plug.tex", "max_forks_repo_name": "sm453/MOpS", "max_forks_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-11-15T05:18:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T13:51:20.000Z", "avg_line_length": 73.2978723404, "max_line_length": 1266, "alphanum_fraction": 0.7205611998, "num_tokens": 2596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4239506309959036}}
{"text": "\n\\subsection{Cross-price elasticity of demand}\n\nWe have our Marshallian demand function:\n\n\\(x_i=x_{di}(I, \\mathbf p)\\)\n\nThe derivative of this with respect to price is the additional amount consumed after prices increase.\n\n\\(\\dfrac{\\delta }{p_i}x_{di}(I, \\mathbf p)\\)\n\n\\subsection{Complements}\n\n\\subsection{Substitutes}\n", "meta": {"hexsha": "c3671c744de78baca358b78f8ceb9087e44ff88e", "size": 320, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/consumer/03-01-elasticityCross.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/consumer/03-01-elasticityCross.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/consumer/03-01-elasticityCross.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.3333333333, "max_line_length": 101, "alphanum_fraction": 0.746875, "num_tokens": 86, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.42395062427725666}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage[margin=2cm]{geometry}\n\\usepackage[english]{babel}\n\\usepackage{float}\n\\usepackage{amsmath}\n\\usepackage{cite}\n\\usepackage{amssymb}\n\\usepackage{booktabs}\n\\usepackage{tabularx}\n\\usepackage{hyperref}\n\\usepackage{multicol}\n\\usepackage{parskip}\n\\title{Context Attacks on CBSTM-IoT}\n\\author{Cody Lewis}\n\\date{\\today}\n\n\\begin{document}\n    \\maketitle\n\n    We implemented a simulation of the trust model proposed in \\cite{rafey2016cbstm},\n    this trust model managed to mitigate the context attacks.\n\n    \\section{Configurations of the Simulation}\n    Our simulation contained 100 nodes where 30 were adversaries, that is, to\n    show the effects of the attack while still below the Byzantine threshold\n    \\cite{lamport2019byzantine}. Friendships between nodes was determined\n    randomly such that the average amount of friends that each node had was\n    approximately 50, then $frlow$ and $frhigh$ were calculated as a standard\n    deviation below and above that mean respectively.\n\n    We defined the relationship factor with the following function,\n    \\begin{equation}\n        R = \\frac{1}{2^n}\n    \\end{equation}\n    where $n$ is the degree of separation between nodes $i$ and $k$. Where\n    nodes belonging to the same owner have $0$ degrees of separation, and\n    those belonging to different owners have $1$ degree of separation.\n    Owners have at most 7 nodes belonging to them.\n\n    We set the computing power, $CP$, to $1$ in order to maximize malevolent abilities of\n    the adversaries, also to show this trust model's greatest amount of resistance\n    against the attacks.\n\n    We decided that in the case where the sum of direct trust and indirect trust was greater\n    than 1, that only direct trust was used, resulting in following trust weight factors\n    to be calculated as,\n    \\begin{equation}\n        \\alpha = \\begin{cases}\n            1 & : DT + IndT > 1 \\\\\n            \\frac{DT}{DT + IndT} & : 0 < DT + IndT \\leq 1 \\\\\n            0 & : DT + IndT = 0\n        \\end{cases}\n    \\end{equation}\n    and,\n    \\begin{equation}\n        \\beta = 1 - \\alpha\n    \\end{equation}\n\n    where the trust of node $j$ calculated by node $i$ under context $c$ is,\n    \\begin{equation}\n        T_{i,j}^c = \\alpha \\cdot DT_{i,j} + \\beta \\cdot IndT_{i,j}^c,\n    \\end{equation}\n    such that $DT$ is the aggregation of direct trusts for all contexts, and\n    $IndT$ is the aggregation of indirect trusts under context $c$ for recommendations\n    from each other node.\n\n    The effects of this can be seen Figure \\ref{fig:trust_plot}, where after approximately 20\n    transactions, the trust jumps from using a combination of direct and indirect to\n    only using direct.\n\n    Nodes in this simulation were implemented to act benevolent with any context\n    value less than or equal to the their randomly assigned context potential,\n    under contexts above that they will act malevolent. A context, $c_i$ is less than or\n    equal to another context, $c_j$, iff $i \\leq j$. The context setting\n    adversaries attack by always reporting to the other nodes with a bad\n    mouthed recommendation with the target context.\n\n    \\begin{table}\n        \\begin{tabularx}{\\textwidth}{X X}\n            \\toprule\n            \\textbf{Parameter} & \\textbf{Value} \\\\\n            \\midrule\n            $w$ & $\\{0.25, 0.25, 0.25, 0.25\\}$ \\\\\n            \\midrule\n            $w_h$ & $0.50$ \\\\\n            \\midrule\n            $w_d$ & $0.50$ \\\\\n            \\midrule\n            $R$ & $0.5$ \\\\\n            \\midrule\n            $CP$ & $1$ \\\\\n            \\midrule\n            $fb_{max}$ & $10$ \\\\\n            \\midrule\n            $MD$ & $0.1$ \\\\\n            \\midrule\n            Contexts & $\\{c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_{10}\\}$ \\\\\n            \\midrule\n            Total nodes & $ 100 $ \\\\\n            \\midrule\n            Transactions & $ 50 $ \\\\\n            \\midrule\n            Adversaries & $ 30\\% $ \\\\\n            \\bottomrule\n        \\end{tabularx}\n        \\caption{The parameters of CBSTM IoT trust model implementation}\n        \\label{table:sim-params}\n    \\end{table}\n\n    \\newpage\n\n    \\section{Results}\n    This trust model was resistant to the context attacks, due to the split of direct and\n    indirect trusts, where direct trust is calculated as an aggregation of\n    experiences in all contexts. Another factor that allowed for the mitigation\n    of context attacks was the filtration of recommendations based on context,\n    where the contexts themselves do not have any other effect on resulting\n    trust calculation. Since the contexts were only used for the filtration of\n    recommendations, standard bad mouthing mitigation techniques were effective\n    against the context setting attack. The comparison of the context setting\n    attack to a completely benevolent network is shown in Figure \\ref{fig:trust_plot}, where the red\n    line is the trust values where 30\\% of network are context setting adversaries, and\n    the blue line is when there are no adversaries in the network.\n\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=\\textwidth]{../1-trust-eval-on-8-in-context-3.png}\n        \\caption{Comparison of the context setting attack to a benevolent network}\n        \\label{fig:trust_plot}\n    \\end{figure}\n\n\n    \\bibliographystyle{plain}\n    \\bibliography{CBSTM-IoT}\n\\end{document}\n", "meta": {"hexsha": "d210e9af9485e39cce995fafffaf37279640b0be", "size": 5385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cbstm-iot/doc/CBSTM-IoT.tex", "max_stars_repo_name": "codymlewis/cba-on-trust-models-for-IoT-systems", "max_stars_repo_head_hexsha": "04455ee079a73ef4bd39e5c10ab168727a775cb1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cbstm-iot/doc/CBSTM-IoT.tex", "max_issues_repo_name": "codymlewis/cba-on-trust-models-for-IoT-systems", "max_issues_repo_head_hexsha": "04455ee079a73ef4bd39e5c10ab168727a775cb1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cbstm-iot/doc/CBSTM-IoT.tex", "max_forks_repo_name": "codymlewis/cba-on-trust-models-for-IoT-systems", "max_forks_repo_head_hexsha": "04455ee079a73ef4bd39e5c10ab168727a775cb1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.3065693431, "max_line_length": 100, "alphanum_fraction": 0.6627669452, "num_tokens": 1408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4239506242772565}}
{"text": "\\documentclass[letterpaper,11pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{booktabs}\n\\usepackage[hmargin=1.25in,vmargin=1in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{lmodern}\n\\usepackage{microtype}\n\\usepackage{minted}\n\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\n\\author{Philip Pham}\n\\date{\\today}\n\\title{CSE 547 - Assignment 1}\n\n\\begin{document}\n\\maketitle\n\n\\section*{Problem 0}\n\n\\begin{description}\n\\item[List of collaborators:] I have not collaborated with anyone.\n\\item[List of acknowledgements:] None.\n\\item[Certify that you have read the instructions:] Yes.\n\\item[Terms and Conditions to use the dataset:] I accept the terms and\n  conditions to use the COCO dataset.\n\\end{description}\n\n\\section*{Problem 1}\n\nRead the course website, up until ``Lecture Notes and Readings'', so that you\nunderstand the course policies on grading, late policies, projects, requirements\nto pass etc. Write ``I have read and understood these policies'' to certify\nthis. If you have questions, please contact the instructors.\n\n\\subsection*{Solution}\n\nI have read and understood these policies.\n\n\\section*{Problem 2}\n\nConsider the function from class (and the notes):\n\\begin{equation}\n  f\\left(w_1,w_2\\right) = \\left[\\sin\\left(2\\pi\\frac{w_1}{w_2}\\right) + 3\\frac{w_1}{w_2} - \\exp\\left(2w_2\\right)\\right]\\left[3\\frac{w_1}{w_2} - \\exp\\left(2w_2\\right)\\right].\n\\end{equation}\n\nSuppose our program for this function uses the following evaluation trace:\n\n\\begin{description}\n\\item[input:] $z_0 = \\left(w_1,w_2\\right)$\n  \\begin{enumerate}\n  \\item $z_1 = w_1/w_2$\n  \\item $z_2 = \\sin\\left(2\\pi z_1\\right)$\n  \\item $z_3 = \\exp\\left(2w_2\\right)$\n  \\item $z_4 = 3z_1 - z_3$\n  \\item $z_5 = z_2 + z_4$\n  \\item $z_6 = z_4z_5$\n  \\end{enumerate}\n\\item[return:] $z_6$\n\\end{description}\n\n\\subsection*{The Forward Mode of AutoDiff (AD)}\n\nThe forward mode for auto-differentiation is a conceptually simpler\nway to compute the derivative. Let us examine the forward mode to\ncompute the derivative of one variable, $\\frac{df}{dw_1}$. In the\nforward mode, we sequentially compute both $z_t$ and its derviative\n$\\frac{dz_t}{dw_1}$ using the previous variables $z_1,\\ldots,z_{t-1}$\nand the previous derivatives\n$\\frac{dz_1}{dw_1},\\ldots,\\frac{dz_{t-1}}{dw_1}$.\n\nExplicitly write out the forward mode in our example.\n\n\\subsubsection*{Solution}\n\nIn the forward mode, we sequentially compute the values $z_t$ and derivates of\n$z_t$ with respect to $w_1$ in order for $t = 1,2,\\ldots,6$.\n\nSuppose we want to calculate $\\frac{df}{dw_1}(u,v)$. Fix $w_1 = u$ and\n$w_2 = v$.\n\n\\begin{enumerate}\n\\item Compute $z_1 = u/v$.\n\\item Compute $\\frac{dz_1}{w_1} = 1/v$.\n\\item Compute $z_2 = \\sin\\left(2\\pi z_1\\right)$.\n\\item Compute\n  $\\displaystyle\\frac{dz_2}{dw_1} = \\frac{\\partial z_2}{\\partial\n    z_1}\\frac{dz_1}{w_1} = 2\\pi\\cos\\left(2\\pi z_1\\right)\\frac{dz_1}{w_1}$.\n\\item Compute $z_3 = \\exp\\left(2v\\right)$.\n\\item Compute $\\displaystyle \\frac{dz_3}{dw_1} = 0$.\n\\item Compute $z_4 = 3z_1 - z_3$.\n\\item Compute\n  $\\displaystyle \\frac{dz_4}{dw_1}= \\frac{\\partial z_4}{\\partial z_1}\\frac{dz_1}{dw_1} + \\frac{\\partial z_4}{\\partial z_3}\\frac{dz_3}{dw_1} = 3\\frac{dz_1}{dw_1} - \\frac{dz_3}{dw_1}$.\n\\item Compute $z_5 = z_2 + z_4$.\n\\item Compute $\\displaystyle \\frac{dz_5}{dw_1} = \\frac{\\partial z_5}{\\partial z_2}\\frac{dz_2}{dw_1} + \\frac{\\partial z_5}{\\partial z_4}\\frac{dz_4}{dw_1} = \\frac{dz_2}{dw_1} + \\frac{dz_4}{dw_1}$.\n\\item Compute $z_6 = z_4z_5$.\n\\item Compute $\\displaystyle\\frac{dz_6}{dw_1} = \\frac{\\partial z_6}{\\partial z_4}\\frac{dz_4}{dw_1} + \\frac{\\partial z_6}{\\partial z_5}\\frac{dz_5}{dw_1} = z_5\\frac{dz_4}{dw_1} + z_4\\frac{dz_5}{dw_1}$.\n\\end{enumerate}\n\nEach step can be computed by substituting values from the previous steps. The\noutput is $\\displaystyle\\boxed{\\frac{df}{dw_1}(u,v) = \\frac{dz_6}{dw_1}.}$\n\n\\subsection*{The reverse mode of AD}\n\nNow let use consider the reverse mode to compute the derivative\n$\\frac{df}{dw}$, which is a two-dimensional vector.\n\nExplicitly write out the reverse mode in our example with the assumption that\nyou have evaluated the trace and already stored all the $z_t$s in memory\nalready.\n\n\\subsubsection*{Solution}\n\nIn the reverse mode, we compute $\\frac{df}{dz_t} = \\frac{dz_6}{dz_t}$ in order\n$t = 6,5,\\ldots,0$. The general algorithm is\n\\begin{equation}\n  \\frac{dz_6}{dz_t} = \\sum_{\\text{$c$ is a child of $t$}}\n  \\frac{dz_6}{dz_c}\n  \\frac{\\partial z_c}{\\partial z_t}.\n\\end{equation}\n\n\\begin{enumerate}\n\\item Seed $\\displaystyle \\frac{dz_6}{dz_6} = 1$.\n\\item Compute\n  $\\displaystyle \\frac{dz_6}{dz_5} =\n  \\frac{dz_6}{dz_6}\\frac{\\partial z_6}{\\partial z_5} = z_4$.\n\\item Compute\n  $\\displaystyle \\frac{dz_6}{dz_4} = \\frac{dz_6}{d z_5}\\frac{\\partial\n    z_5}{\\partial z_4} + \\frac{d z_6}{d z_6}\\frac{\\partial z_6}{\\partial z_4} =\n  \\frac{dz_6}{d z_5} + \\frac{d z_6}{d z_6}z_5\n  =\n  z_4 + z_5\n  $.\n\\item Compute\n  $\\displaystyle \\frac{dz_6}{dz_3} = \\frac{dz_6}{d z_4}\\frac{\\partial\n    z_4}{\\partial z_3} = -\\frac{dz_6}{d z_4} = -z_4 - z_5$.\n\\item Compute\n  $\\displaystyle \\frac{dz_6}{dz_2} = \\frac{dz_6}{d z_5}\\frac{\\partial\n    z_5}{\\partial z_2} = \\frac{dz_6}{d z_5} = z_4$.\n\\item Compute\n  $\\displaystyle \\frac{dz_6}{dz_1} =\n  \\frac{dz_6}{d z_2}\\frac{\\partial  z_2}{\\partial z_1} +\n  \\frac{dz_6}{d z_4}\\frac{\\partial  z_4}{\\partial z_1} =\n  2\\pi\\cos\\left(2\\pi z_1\\right)\\frac{dz_6}{d z_2} +\n  3\\frac{dz_6}{d z_4}$.\n\\item Compute\n  $\\displaystyle\n  \\frac{dz_6}{dw_1} = \\frac{dz_6}{dz_1}\\frac{\\partial z_2}{\\partial w_1}\n  = \\frac{1}{w_2}\\frac{dz_6}{dz_1}$.\n\\item Compute\n  $\\displaystyle\n  \\frac{dz_6}{dw_2} = \\frac{dz_6}{dz_1}\\frac{\\partial z_1}{\\partial w_2} +\n  \\frac{dz_6}{dz_3}\\frac{\\partial z_3}{\\partial w_2}\n  = -\\frac{w_1}{w_2^2}\\frac{dz_6}{dz_1} + 2\\exp\\left(2w_2\\right)\\frac{dz_6}{dz_3}$.\n\\end{enumerate}\n\nEach step can be computed by substituting the output of one of the previous\nsteps. From the last two steps, we obtain our desired result\n\\begin{equation}\n  \\boxed{\n    \\frac{df}{dw} = \\begin{pmatrix}\n      \\displaystyle\\frac{dz_6}{dw_1} \\\\ \\displaystyle\\frac{dz_6}{dw_2}\n    \\end{pmatrix}.\n  }\n\\end{equation}\n\n\\section*{Problem 3: Computation and Memory in AD}\n\nSuppose we seek to compute the derivative with respect to a real valued function\n$f\\left(w\\right) : \\mathbb{R}^d \\rightarrow \\mathbb{R}$. Let us examine some of\nthe computational and memory issues involved in AD.\n\n\\subsection*{Computation}\n\nLet $T$ be the computation time to compute $f(w)$ using our program.\n\n\\begin{enumerate}\n\\item Suppose we want to find the derivative of one variable $\\frac{df(w)}{dw_1}$\n  with respect to the variable $w_1$. In order notation, how does the\n  computational complexity (the runtime) of the forward mode compare to the\n  reverse mode $\\frac{df(w)}{dw_1}$?\n  \\subsubsection*{Solution}\n\n  For the forward mode, we just do one sweep through our computation graph to\n  compute $\\frac{df(w)}{dw_1}$, so the running time is $O(T)$.\n\n  In the reverse mode, we also just do one sweep through the graph, so the\n  running time is also $O(T)$.\n\n  Both running times are of the same complexity in this case.\n  \n\\item Suppose we want to find the derivative $\\frac{df(w)}{dw}$,which is a\n  $d$-dimensional vector. How would we do this with the forward mode and, in\n  order notation, what is the computational complexity? Again, in order\n  notation, how does the computational complexity (the runtime) of the forward\n  mode compare to the reverse mode to compute $\\frac{df(w)}{dw}$.\n  \\subsubsection*{Solution}\n\n  For the forward mode, we have to do a sweep for each\n  $\\frac{df(w)}{dw_1},\\ldots,\\frac{df(w)}{dw_d}$ that we want to compute, so the\n  runtime complexity is $O(Td)$.\n\n  In the reverse mode, we have to do one sweep. Then, we have enough\n  information to compute each $\\frac{df(w)}{dw_j}$, so the runtime complexity is\n  $O(T + d)$.\n\n  The computational complexity of the reverse mode is smaller than that of the\n  forward mode.\n  \n  \\item If we could easily parallelize our computation (not worrying about\n    communication), do you see a way to speed up the reverse mode? If so, what\n    would be the new serial runtime? If not, why?\n    \\subsubsection*{Solution}\n\n    Only one sweep needs to be done, and sweeping though the graph must be done\n    in a certain order, so there is no easy way to parallelize that part. Once\n    the sweep is done, one could use the computed intermediate derivatives to to\n    calculate each $\\frac{df(w)}{dw_j}$ in a parallel manner. In that case the\n    new runtime complexity is $O(T)$.\n    \n  \\item If we could easily parallelize our computation (not worrying about\n    communication), do you see a way to speed up the forward mode? If so, how so\n    and what would be the new serial runtime? If not, why?\n    \\subsubsection*{Solution}\n\n    Yes. The obvious way is to parallize the forward mode is to have $d$ workers\n    each doing a separate sweep and computing a separate\n    $\\frac{df(w)}{dw_j}$. If we do that, the runtime complexity is also $O(T)$.\n\\end{enumerate}\n\n\\subsection*{Memory}\n\nMemory is often a bottleneck in practice (e.g. we load as much as we can on a\nGPU when doing our computation in batches of data). Let us understand some of\nthese issues.  Suppose our input $w$ is $d$-dimensional and our evaluation trace\nis $T$ steps. Assume one unit of memory is required to store a real\nnumber. Also, assume that we are free to delete variables at any time to free up\nmemory (in practice, this often occurs by overwriting variables).  In this\nquestion, when memory is used to refer to how much ``scratch space'' we need to\nutilize in order to run our program. In this question, order notation is\nsufficient. When stating your answers do not include the memory required to\nstore the parameter $w$ or the program itself. Also, when in your answers, do\nnot include the memory required to write out the programs output (assume we have\nalready allocated this memory). We are interested in how much excess memory the\nprogram needs to have free in order to store its intermediate variables and do\nall its computations.\n\n\\begin{enumerate}\n\\item Suppose that we were just interested in computing $f(w)$. Is it often the\n  case that we can get away with less than $T$ units of memory? How so?\n\n  \\subsection*{Solution}\n  Yes, we can get away with less than $T$ units of memory by discarding\n  unnecessary intermediate variables. \n\n  For example suppose the computation graph was a perfectly balanced tree and\n  $z_T = z_{T - 1} + z_{T-2}$ where the computation traces of\n  $z_{T - 1} + z_{T-2}$ are each $(T - 1)/2$. After computing $z_{T - 1}$, we\n  can free any memory used to compute it.\n  \n\\item Suppose we only need to use $m$ units of memory to compute $f(w)$. If we\n  only wanted to compute $\\frac{df}{dw_1}$, how much memory would we require to\n  compute this using the forward mode? Explain.\n\n  \\subsection*{Solution}\n  We also only need $O(m)$ units of memory to compute $\\frac{df}{dw_1}$. Suppose\n  that we are trying to compute $z_t$. We only need to know the value of its\n  parents. To compute $\\frac{dz_t}{dw_1}$, we only need to know the value of its\n  parents and the derivatives of the of the parents with respect to $w_1$.\n\\item Suppose we only need to use $m$ units of memory to compute $f(w)$. If we\n  only wanted to compute $\\frac{df}{dw_1}$, how much memory would we require to\n  compute this using the reverse mode? Explain.\n\n  \\subsection*{Solution}\n\n  Since we want to avoid blowing up the computation, we need $O(T)$ units of\n  memory. One may think that since the computation of $\\frac{dz_T}{dz_t}$ only\n  requires the children of $z_t$, less units of memory are needed. But since\n  we're working backwards, we may be deep in the graph, so those children have\n  to be computed ahead of time. The first steps require knowing the values near\n  the leaves for instance. If we discarded the intermediate values, we would may\n  to do expensive calculations to recover them when deep in the graph.\n\n\\item Suppose we only need to use $m$ units of memory to compute $f(w)$ and\n  suppose we want to compute $\\frac{df}{dw}$. If we don't care about runtime,\n  what is the most memory efficient algorithm you can come up with? How much\n  memory is needed?\n\n  \\subsection*{Solution}\n\n  We could just repeat the forward pass to compute each $\\frac{df}{dw_j}$. Each\n  pass takes $O(m)$. After we're done the pass, we would discard any\n  intermediate variables and just keep $\\frac{df}{dw_j}$. If $w$ is\n  $d$-dimensional, we only need $O(m + d)$ units of memory.\n  \n\\end{enumerate}\n\n\\section*{Problem 4: PyTorch Can Give Us Some Crazy Answers}\n\nNow you will construct an example in which PyTorch provides derivatives that\nmake no sense. The issue is in understanding when it is ok and when it is not ok\nto use dynamic computation graphs. You are going to find a way code up the same\nfunction in two different ways so that PyTorch will return different derivatives\nat the same point. The purpose of this exercise is to better understand how\ndynamic computation graphs work and to understand what you are doing when you\nusing various AD softwares.\n\n\\subsection*{Two Identical Non-differentiable Functions with Different ``Derivatives''}\n\n\\begin{enumerate}\n\\item Define \\emph{and} plot a one dimensional, real valued function\n  which is not continuous.\n  \n  \\subsubsection*{Solution}\n  Consider the function\n  \\begin{equation}\n    f(x) = \\begin{cases}\n      2x, - 1& x < 0; \\\\\n      0, & x = 0; \\\\\n      2x + 1, & x > 0.\n    \\end{cases}\n    \\label{eqn:problem4}\n  \\end{equation}\n\n  It is implemented in Listings \\ref{lst:f} and \\ref{lst:g} and plotted in\n  Figure \\ref{fig:problem4}.\n\n  \\begin{figure}[h]\n    \\centering\n    \\includegraphics{problem4/problem4.pdf}\n    \\caption{The functions from Listings \\ref{lst:f} and \\ref{lst:g} are plotted\n      along with their PyTorch-computed derivatives.}\n    \\label{fig:problem4}\n  \\end{figure}\n\\item Now write out your function in PyTorch. You should be able to\n  define this function so that PyTorch returns a derivative of $0$ at\n  some point $x_0$.\n  \\subsubsection*{Solution}\n  Equation \\ref{eqn:problem4} is implemented as $f$ in Listing\n  \\ref{lst:f}. In Figure \\ref{fig:problem4}, you can see that PyTorch\n  calculates the derivative as $0$ at $x_0 = 0$ (left plot, blue\n  \\texttt{x}).\n  \n  \\begin{listing}\n\\begin{minted}{python}\ndef f(x: Variable) -> Variable:\n    assert x.requires_grad\n    return (2*x*torch.sign(x) + 1)*torch.sign(x)\n\\end{minted}\n  \\caption{Equation \\ref{eqn:problem4} defined with the sign function factored out.}\n\\label{lst:f}\n\\end{listing}\n\n\\item Now find another way to write out your function in PyTorch; do\n  this so that it is exactly the same function. Do this in a way so\n  that PyTorch now returns a derivative of $2$ at exactly the same\n  point $x_0$ that you obtained a derivative of $0$ in the previous\n  question.\n  \\subsubsection*{Solution}\n  Equation \\ref{eqn:problem4} is implemented as $g$ in Listing\n  \\ref{lst:g}. In Figure \\ref{fig:problem4}, you can see that PyTorch\n  calculates the derivative as $2$ at $x_0 = 0$ (right plot, blue\n  \\texttt{x}).\n  \n\\begin{listing}\n\\begin{minted}{python}\ndef g(x: Variable) -> Variable:\n    def g1d(x: Variable) -> Variable:\n        if x.data[0] > 0:\n            return 2*x + 1\n        elif x.data[0] < 0:\n            return 2*x - 1\n        else:\n            return 2*x\n\n    if x.dim() == 0:\n        return 1*x    \n    if x.size() == torch.Size([1]):\n        return g1d(x)\n\n    return torch.stack([g(sub_x) for sub_x in x])\n\\end{minted}\n  \\caption{Equation \\ref{eqn:problem4} defined element-wise by recursing into the tensor.}\n\\label{lst:g}\n\\end{listing}\n\\item There is a no sane definition of the derivative for your\n  function. Yet, you should not only found a way to get PyTorch to\n  provide a derivative, you should have also found a way to give you\n  two \\emph{different} derivatives at exactly the same point (on the same\n  function). What went wrong?\n\n  \\subsubsection*{Solution}\n\n  PyTorch is just keeping track of the operations and does a pointwise\n  calculation. It's not paying attention to any local behvaior like\n  continuity. In Listing \\ref{lst:g}, by changing the \\texttt{else}\n  arm, we can have it return any arbitrary number for the\n  derivative. For instance, having it return \\texttt{-3*x} would have\n  PyTorch calculating the derivative as $-3$ at $x_0 = 0$.\n\\end{enumerate}\n\n\\subsection*{Extra Credit: Differentiable Functions with Different ``Derivatives''}\n\nProvide a differentiable function, where you can code it up in PyTorch\nin two different ways and where you can get two different derivatives\nat the same point $x_0$.\n\n\\subsubsection*{Solution}\n\nWe can reuse the same idea. PyTorch doesn't correctly compute the\nderivative when squaring the sign function, even though, the sign\nfunction squared is just the identity.\n\nUsing this, I implement the simple, differentiable line $f(x) = 2x$ in\ntwo ways: (1) verbosely using the sign function as $f$ and (2) the\ncanonical way as $g$ in Listing \\ref{lst:fg_diff}.\n\n\\begin{listing}\n\\begin{minted}{python}\ndef f(x: Variable) -> Variable:\n    assert x.requires_grad\n    return 2*x*torch.sign(x)*torch.sign(x)\n\ndef g(x: Variable) -> Variable:\n    assert x.requires_grad\n    return 2*x\n\\end{minted}\n  \\caption{The function $f(x) = 2x$ defined in two different ways.}\n\\label{lst:fg_diff}\n\\end{listing}\n\nThis results in Figure \\ref{fig:problem4_differentiable}. PyTorch\ncomputes $f^\\prime(0) = 0$ despite the true value being $2$.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics{problem4/problem4_differentiable.pdf}\n  \\caption{$f$ and $g$ from Listing \\ref{lst:fg_diff} plotted along with\n    their PyTorch-computed derivatives.}\n  \\label{fig:problem4_differentiable}\n\\end{figure}\n\nThe code for this exercise can be found at \\url{https://gitlab.cs.washington.edu/pmp10/cse547/tree/master/hw1/problem4}.\n\n\\section*{Problem 5: Elementary properties of $l_2$ regularized logisitic regression}\n\n\\subsection*{The binary case}\n\nConsider minimizing\n\\begin{equation}\n  J(\\mathbf{w}) = -l\\left(\\mathbf{w},\\mathcal{D}_\\mathrm{train}\\right) + \\lambda\\left\\lVert\\mathbf{w}\\right\\rVert_2^2,\n\\end{equation}\nwhere\n\\begin{equation}\n  l\\left(\\mathbf{w},\\mathcal{D}\\right) = \\sum_j \\log \\mathbf{P}\\left(\n    y^j \\mid \\mathbf{x}^j, \\mathbf{w}\n  \\right)\n\\end{equation}\nis the log-likelihood on the data set $\\mathcal{D}$ for\n$y^j \\in \\{ \\pm 1 \\}$\n\nState if the following are true or false. Briefly explain your reasoning.\n\n\\begin{enumerate}\n\\item With $\\lambda > 0$ and the features $x^j_k$ linearly separable,\n  $J\\left(\\mathbf{w}\\right)$ has multiple locally optimal solution.\n  \\subsubsection*{Solution}\n  \n  \\emph{False}. When the features are linearly separable, we can push loss\n  unregularized loss arbitrarily close to $0$ but the the loss is\n  still convex. The sum of two convex functions is convex, so there\n  will be global optimum.\n  \n\\item Let\n  $\\hat{\\mathbf{w}} = \\argmin_{\\mathbf{w}} J\\left(\\mathbf{w}\\right)$ be\n    a global optimum. $\\hat{\\mathbf{w}}$ is typically sparse.\n    \n    \\subsubsection*{Solution}\n    \\emph{False}. This may be true with $l_1$ regularization, but is not\n    usually the case with $l_2$ regularization. If one considers the\n    dual Lagrangian problem, $\\hat{\\mathbf{w}}$ will lie on some\n    hypersphere at a point which will not generally have $0$ values.\n  \\item If the training data is linearly separable, then some weights\n    $w_j$ might become infinite if $\\lambda = 0$.\n    \\subsubsection*{Solution}\n\n    \\emph{True}. By making the weights larger and larger we can push the loss\n    to be arbitrarily close to $0$ if $\\lambda = 0.$\n    \n  \\item $l\\left(\\hat{\\mathbf{w}}, \\mathcal{D}_\\mathrm{train}\\right)$\n    always increases as we increase $\\lambda$.\n    \\subsubsection*{Solution}\n\n    \\emph{True}. If one thinks in term of the Lagrangian dual problem\n    increasing $\\lambda$ is contraining the weights further away from\n    the global optimum by restricting them to a smaller hypersphere.\n\n  \\item $l\\left(\\hat{\\mathbf{w}}, \\mathcal{D}_\\mathrm{test}\\right)$\n    always increases as we increase $\\lambda$.\n    \\subsubsection*{Solution}\n\n    \\emph{False}. While the training loss may increase, we could be\n    overfitting. Thus, sometimes increasing $\\lambda$ may decrease\n    test loss.    \n\\end{enumerate}\n\n\\subsection*{Multi-class Logistic Regression}\n\nIn multi-class logistic regression, suppose\n$Y \\in \\left\\{y_1,\\ldots,y_R\\right\\}$. A simplified version (with no\nbias term) is as follows. When $k < R$ the posterior probability is given by:\n\\begin{equation}\n  P\\left( Y = y_k \\mid X\\right) =\n  \\frac{\\exp\\left(\\left\\langle w_k, X\\right\\rangle\\right)}\n  {1 + \\sum_{j=1}^{R-1}\\exp\\left(\\left\\langle w_j, X\\right\\rangle\\right)}.\n  \\label{eqn:multiclass_log_reg}\n\\end{equation}\n\nFor $k = R$, the posterior is\n\\begin{equation}\n  P\\left( Y = y_R \\mid X\\right) =\n  \\frac{1}\n  {1 + \\sum_{j=1}^{R-1}\\exp\\left(\\left\\langle w_j, X\\right\\rangle\\right)}.\n\\end{equation}\n\nTo simplify notation, we can define $w_R = \\mathbf{0}$ as a vector of\nall $0$s. This gives us Equation \\ref{eqn:multiclass_log_reg} for all\n$k$.\n\n\\begin{enumerate}\n\\item How many parameters do we need to estimate? What are these\n  parameters?\n\n  \\subsubsection*{Solution}\n\n  Assume the data is $D$-dimensional. Our parameters are the weights\n  $w_k$ each which is a $D$-dimensional vector. There are\n  $\\boxed{(R - 1)D}$ parameters to estimate.\n\\item Given $N$ training samples\n  $\\left\\{\\left(x^1, y^1\\right),\\left(x^2,\n      y^2\\right),\\ldots,\\left(x^N, y^N\\right)\\right\\}$, write down\n  explicitly the log-likelihood function and simplify it as much as\n  you can:\n  \\begin{equation}\n    L\\left(w_1,\\ldots,w_{R-1}\\right) = \\sum_{j=1}^N \\log\\left(\n      P\\left(y^j \\mid x^j,w\\right)\n    \\right).\n    \\label{eqn:log_likelihood}\n  \\end{equation}\n  \n  \\subsubsection*{Solution}\n\n  Let $y^j = y_{l^j}$, that is, let $l^j$ be the class label of observation\n  $j$. If we use the posterior probability in Equation\n  \\ref{eqn:multiclass_log_reg}, then, we have that\n  \\begin{equation}\n    \\log\\left(\n      P\\left(y^j \\mid x^j,w\\right)\n    \\right)\n    = \\left\\langle w_{l^j}, x^j\\right\\rangle -\n    \\log\\left(\n      1 + \\sum_{k=1}^{R - 1}\\exp\\left(\n        \\left\\langle w_k, x^j\\right\\rangle\n      \\right)\n    \\right).\n    \\label{eqn:log_p}\n  \\end{equation}\n\n  Substituting Equation \\ref{eqn:log_p} into Equation \\ref{eqn:log_likelihood}, we have\n  \\begin{equation}\n    L\\left(w_1,\\ldots,w_{R-1}\\right)\n    = \\sum_{j=1}^N\\left(\n      \\left\\langle w_{l^j}, x^j\\right\\rangle\n      -\n      \\log\\left(\n      1 + \\sum_{k=1}^{R-1}\\exp\\left(\\left\\langle w_k,x^j\\right\\rangle\\right)\n      \\right)\n    \\right).\n    \\label{eqn:log_p_simple}\n  \\end{equation}\n\\item Compute the gradient of $L$ with respect to each $w_k$ and simplify it.\n  \\subsubsection*{Solution}\n\n  $w_k$ is a $D$-dimensional vector so, $\\frac{\\partial L}{\\partial w_k}$ will\n  also be $D$-dimensional. Denote the features for the observations with class\n  label $k$ by $\\mathcal{X}_k = \\left\\{x^j : l^j = k\\right\\}$.\n\n  We have that for $k = 1,2,\\ldots,R-1$:\n  \\begin{align}\n    \\frac{\\partial L}{\\partial w_k}\n    &= \\sum_{x \\in \\mathcal{X}_k} x\n      - \\sum_{j=1}^Nx^j\\frac{\n      \\exp\\left(\\left\\langle w_k,x^j\\right\\rangle\\right)\n      }\n      {1 + \\sum_{m=1}^{R - 1}\\exp\\left(\\left\\langle w_m,x^j\\right\\rangle\\right)}\n      \\label{eqn:log_likelihood_gradient}\\\\   \n    &= \\sum_{x \\in \\mathcal{X}_k} x -\n      \\sum_{j=1}^N x^j P\\left(Y = y_k \\mid X = x^j\\right).\n      \\nonumber\n  \\end{align}\n\\item Now add the regularization term $\\lambda$ and define a new objective\n  function:\n  \\begin{equation}\n    L\\left(w_1,\\ldots,w_{R-1}\\right) = \\sum_{j=1}^N\\log\\left(\n      P\\left(y^j \\mid x^j, w\\right)\n    \\right)\n    +\n    \\frac{\\lambda}{2}\\sum_{l=1}^{R-1}\\left\\lVert w_l\\right\\rVert_2^2.\n    \\label{eqn:log_likelihood_with_penalty}\n  \\end{equation}\n\n  Compute the gradient of this new $L$ with respect to each $w_k$.\n\n  \\subsubsection*{Solution}\n\n  We can just differentiate term by term. The gradeint of the first term comes\n  from Equation \\ref{eqn:log_likelihood_gradient}. We can write\n  $\\left\\lVert w_l\\right\\rVert_2^2 = w_{l1}^2 + w_{l2}^2 + \\cdots + w_{lD}^2$,\n  so we have that\n  \\begin{equation}\n    \\frac{\\partial L}{\\partial w_l}\n    = \\sum_{x \\in \\mathcal{X}_l} x\n      - \\sum_{j=1}^Nx^j\\frac{\n      \\exp\\left(\\left\\langle w_l,x^j\\right\\rangle\\right)\n      }\n      {1 + \\sum_{m=1}^{R - 1}\\exp\\left(\\left\\langle w_m,x^j\\right\\rangle\\right)}\n      + \\lambda w_l.\n  \\end{equation}\n\\end{enumerate}\n\n\\section*{Problem 6: Getting Familiar with Our Dataset}\n\nLet us consider solving a binary classification problem (labels being\n$\\{-1, 1\\}$) with the dataset provided. We will use the square loss and consider\ntraining two models, namely $(i)$ a linear model and $(ii)$ a multi-layer\nperceptron. Note that this the same dataset that we will start branching out on,\nfor the purposes of later assignments and the (default) course project.  The\ndataset contains two supercategories: vehicle and animal, and a number of\ncategories for each supercategory. In the small dataset provided, each image\ncontains objects of a single supercategory, say vehicle, and potentially\nmultiple objects from the supercategory, such as car, boat, etc. In this\nexercise we shall build a classifier that learns to classify between these\nsupercategories, by optimizing a square loss objective with the above\nmodels. For the purposes of learning these classifiers, we shall use features\nfrom a convolutional neural network (as opposed to the raw pixels from these\nimages). We have provided starter code to read these features.\n\n\\subsection*{SGD and Linear Regression}\n\nHere, the objective function we choose to optimize is:\n\\begin{equation}\n  L(w) = \\frac{\\lambda}{2}\\left\\lVert w \\right\\rVert_2^2  + \\frac{1}{n}\\sum_{i=1}^n\\frac{1}{2}\\left(y_i - \\left\\langle w, x_i\\right\\rangle\\right)^2,\n\\end{equation}\nwhere, $y_i \\in \\{-1, 1\\}$ is the label, $x_i \\in \\mathbb{R}^d$ are the\nfeatures, $w \\in \\mathbb{R}^d$ is the linear model that we wish to optimize for\nand $\\lambda > 0$ is the strength of $l_2$ regularization. Now consider running\nstochastic gradient descent on $L(w)$, where the stochastic gradient is computed\nusing a single sample (i.e. a batch size of $1$).\n\n\\begin{enumerate}\n\\item Report the stepsize at which SGD starts to diverge (specified up to, say a\n  factor of $2$ from the actual value). Why would you expect the algorithm to\n  diverge at too large a learning rate?\n\n  \\subsubsection*{Solution}\n\n  I found that my model began to diverge with a learning rate of\n  $2 \\times 10^{-4}$. The misclassification became 50\\% with is essentially a\n  coin flip.\n\n  I'd expect the algorithm to diverge since it's taking too large steps in the\n  parameter space and missing the optima.\n  \n\\item After every $500$ updates (index the first update at $0$), compute $L(w)$\n  evaluated over the training/development/test dataset and make a plot with\n  these values in the $y$-axis and the iteration on the $x$-axis. All three\n  curves should be on one same plot. What value of $\\lambda$ did you use?\n\n  \\subsubsection*{Solution}\n\n  This is plotted in Figure \\ref{fig:linear_loss}. I used $\\lambda = 128$.\n\n  \\begin{figure}\n    \\centering\n    \\includegraphics{problem6/linear_loss.pdf}\n    \\caption{Loss for the linear classifier.}\n    \\label{fig:linear_loss}\n  \\end{figure}\n  \n\\item Compute the misclassification error every $500$ updates and plot these\n  quantities (in a single plot) evaluated over the training, development and\n  test dataset. Here, make sure to start your $x$-axis at a slightly later\n  iteration to make the behavior of the $0/1$ error more easy to view (it is\n  difficult to view the long run behavior if the y-axis is over too large a\n  range). Report the lowest test error.\n\n  \\subsubsection*{Solution}\n\n  This is plotted in Figure \\ref{fig:linear_misclassification}. The linear model\n  performed the best, better than the multi-layer perceptron. From Table\n  \\ref{tab:model_results}, the lowest misclassification rate was 7.2\\% for the\n  test data and 6.4\\% for the validation data.\n\n  \\begin{figure}\n    \\centering\n    \\includegraphics{problem6/linear_misclassification.pdf}\n    \\caption{Misclassification rate for the linear classifier.}\n    \\label{fig:linear_misclassification}\n  \\end{figure}\n\\end{enumerate}\n\n\\subsection*{Implement a Multi-Layer Perceptron (MLP)}\n\nHere, the objective function we choose to optimize is:\n\\begin{equation}\n  L(w) = \\frac{\\lambda}{2}\\left\\lVert w \\right\\rVert_2^2  + \\frac{1}{n}\\sum_{i=1}^n\\frac{1}{2}\\left(y_i - f_i(w)\\right)^2,~\\text{where}~\n  f_i(w) = \\left\\langle w_2, \\operatorname{relu}\\left(w_1^\\intercal x_i\\right)\\right\\rangle.\n\\end{equation}\n$y_i \\in \\{-1, 1\\}$ is the label, $x_i \\in \\mathbb{R}^d$ are the features,\n$w_1 \\in \\mathbb{R}^d \\times \\mathbb{R}^h$, $w_2 \\in \\mathbb{R}^h$, and\n$\\operatorname{relu}(x) = \\max\\left\\{x, 0\\right\\}$, where the max is applied\nelement wise, and $h$ is the number of hidden nodes in our MLP.  Now consider\nrunning stochastic gradient descent on $L(w)$, where the stochastic gradient is\ncomputed using a single sample. In this exercise, answer the questions below\nwith the number of hidden nodes being (a) $10$, (b) $100$, (c) $500$.\n\n\\begin{enumerate}\n\\item Report the stepsize at which SGD starts to diverge (specified up to, say a\n  factor of $2$ from the actual value).\n\n  \\subsubsection*{Solution}\n\n  I started seeing divergence with a learning rate of $0.001$. The algorithm\n  didn't make any progress and got stuck with a 50\\% misclassification rate.\n\n  \\item Compute $L(w)$ evaluated over the training, development, and, test\n    dataset every $500$ updates and plot these values in a single plot. Specify\n    your learning rate scheme if you chose to decay your learning rate.\n\n    \\subsubsection*{Solution}\n    \n    The plots are shown in Figures \\ref{fig:mlp10_loss}, \\ref{fig:mlp100_loss},\n    and \\ref{fig:mlp500_loss}. $\\lambda = 0.0004$ was used as the $l_2$\n    penalty. There appears to overfitting as the test and validation loss are\n    much higher than the training loss. A fixed learning rate was used.\n\n    \\begin{table}\n      \\centering\n      \\begin{tabular}{lrrr|rrr}\n        \\toprule\n        & \\multicolumn{3}{c}{Loss} & \\multicolumn{3}{c}{Accuracy} \\\\\n        \\cmidrule{2-4} \\cmidrule{5-7}\n        Model & Training & Test & Validation & Training & Test & Validation \\\\\n        \\midrule\n        Linear & 0.141587 & 0.342109 & 0.340544 & 0.9945 & 0.928 & 0.936 \\\\\n        MLP (10 units) & 0.202833 & 0.421297 & 0.331022 & 0.9620 & 0.862 & 0.928 \\\\\n        MLP (100 units) & 0.182172&0.394072&0.289352 & 0.9725&0.876&0.926 \\\\\n        MLP (500 units) & 0.160434&0.417597&0.313770&0.9810&0.876&0.936 \\\\\n        \\bottomrule\n      \\end{tabular}\n      \\caption{The smallest loss and highest accuracy obtained by each model.}\n      \\label{tab:model_results}\n    \\end{table}\n\n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp10_loss.pdf}\n      \\caption{Loss for the multi-layer perceptron with 10 hidden units.}\n      \\label{fig:mlp10_loss}\n    \\end{figure}\n    \n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp100_loss.pdf}\n      \\caption{Loss for the multi-layer perceptron with 100 hidden units.}\n      \\label{fig:mlp100_loss}\n    \\end{figure}\n    \n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp500_loss.pdf}\n      \\caption{Loss for the multi-layer perceptron with 500 hidden units.}\n      \\label{fig:mlp500_loss}\n    \\end{figure}\n\n  \\item Compute the misclassification error every $500$ updates and plot these\n    quantities (in a single plot) evaluated over the training, development and\n    test dataset. As in the case of the linear model, make sure to start your\n    $x$-axis at a slightly later iteration so as to make the behavior of the\n    $0/1$ error more easy to view. Report the lowest test error.   \n\n    \\subsubsection*{Solution}\n    \n\n    The plots are shown in Figures \\ref{fig:mlp10_misclassification},\n    \\ref{fig:mlp100_misclassification}, and\n    \\ref{fig:mlp500_misclassification}. These plots mirror the those for loss\n    and show evidence of overfitting. The lowest misclassification rate was was\n    the 12.4\\% achieved by using $100$ and $500$ hidden units. On the validation\n    dataset, the $500$ hidden units model does the best misclassification rate\n    of 6.4\\%.\n\n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp10_misclassification.pdf}\n      \\caption{Misclassification rate for the multi-layer perceptron with 10 hidden units.}\n      \\label{fig:mlp10_misclassification}\n    \\end{figure}\n    \n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp100_misclassification.pdf}\n      \\caption{Misclassification rate for the multi-layer perceptron with 100 hidden units.}\n      \\label{fig:mlp100_misclassification}\n    \\end{figure}\n    \n    \\begin{figure}\n      \\centering\n      \\includegraphics{problem6/mlp500_misclassification.pdf}\n      \\caption{Misclassification rate for the multi-layer perceptron with 500 hidden units.}\n      \\label{fig:mlp500_misclassification}\n    \\end{figure}\n\n  \n\\end{enumerate}\n\n\n\\subsection*{Get Familiar with Amazon Web Services (AWS)}\n\nUse Amazon AWS to run the code developed in previous sections. Attach a\nscreenshot showing the progress of the algorithm (and the result) as viewed in\nthe remote machine. The purpose of this exercise is to get familiar with AWS\nand set yourselves up for future assignments and the course project.\n\n\\subsubsection*{Solution}\n\nI trained the models as AWS Batch jobs. You can see the result of a linear model\nin Figure \\ref{fig:linear_batch} and the result of the multi-layer perceptron\nmodel in Figure \\ref{fig:mlp_batch}.\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=\\textwidth]{linear_screenshot.png}\n  \\caption{Training the linear classifier as an AWS batch job with $\\lambda = 0.0004$.}\n  \\label{fig:linear_batch}\n\\end{figure}\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=\\textwidth]{mlp_10_screenshot.png}\n  \\caption{Training the multi-layer perceptron as an AWS batch job with 10 hidden units.}\n  \\label{fig:mlp_batch}\n\\end{figure}\n\nCode to run this exercise can be found at\n\\url{https://gitlab.cs.washington.edu/pmp10/cse547/blob/master/hw1/run.py}. The\nJupyter Notebook for the plots is in\n\\url{https://gitlab.cs.washington.edu/pmp10/cse547/blob/master/hw1/problem6}.\n\n\\end{document}\n% Local Variables:\n% TeX-command-extra-options: \"-shell-escape\"\n% End:", "meta": {"hexsha": "de852285a5847d46ea918453de649d2aba8579fd", "size": 34483, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw1/writeup.tex", "max_stars_repo_name": "kspathak/cse547", "max_stars_repo_head_hexsha": "2379c6435c871720aa7da53d3c8066a628e81830", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw1/writeup.tex", "max_issues_repo_name": "kspathak/cse547", "max_issues_repo_head_hexsha": "2379c6435c871720aa7da53d3c8066a628e81830", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw1/writeup.tex", "max_forks_repo_name": "kspathak/cse547", "max_forks_repo_head_hexsha": "2379c6435c871720aa7da53d3c8066a628e81830", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-18T01:39:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-18T01:39:20.000Z", "avg_line_length": 39.7727797001, "max_line_length": 199, "alphanum_fraction": 0.7080590436, "num_tokens": 10702, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.8221891327004132, "lm_q1q2_score": 0.4239370913113663}}
{"text": "\\documentclass[Thesis.tex]{subfiles}\n\\begin{document}\n\\chapter{Automatic Differentiation}\n\\label{chp:auto-diff}\n\n\\glsresetall\n\nOne of the central parts of the success of neural networks in machine learning\nis the backpropagation algorithm of\n\\cref{eq:backprop-delta-recursive,eq:backprop-grads-recursive}. The algorithm is able to\ndescribe how parameters should be updated in arbitrary networks by propagating\nthe error estimates backwards through the network. While we could derive these\nequations relatively simply in the case of a pure feed-forward neural network\nsuch as the ones described here, there is a whole world of variants for which\nwe would need to derive different equations, such as recurrent networks,\nresidual networks, convolutional networks etc. Nevertheless, they all still rely\non the basic premise of applying the chain rule.\n\nOne of the perhaps most appealing attributes of \\gls{ml} frameworks such as TensorFlow~\\cite{tensorflow2015-whitepaper}\nis how we can design arbitrary networks \\emph{without} having to manually work\nout the associated derivatives. The way this is done is through \\gls{ad}, an\nalgorithmic application of the chain rule that can compute derivatives of any\nfunction specified by a computer program.\n\nThis is possible by exploiting the fact that any computer program must be built\nup of elementary operations (\\(+,-,*,/\\)) and perhaps some elementary functions\n(\\(\\exp, \\sin\\) etc.). We know how to handle derivatives for all of these, and\nimportantly we know how to combine them in arbitrary ways through the chain\nrule. This allows us to construct a computation for any function which\nwill compute its derivative.\n\n\\Gls{ad} promises a general purpose implementation that can\ncalculate derivatives exactly (within numerical precision) in a manner that uses\nat most a constant factor more operations than the original function. We can\nalso generalize to higher order derivatives by repeated application of the\nalgorithm. That is, viewing the derivative computation as a function in its own\nright we can apply the same trick to construct a computation for the second\nderivative.\n\n\n\\section{Example}\n\nLet the function we wish to differentiate be the following:\\footnote{This example is in large part similar to one found\n    on the \\gls{ad} Wikipedia page, simply because I quite like this explanation.}\n\n\\begin{align}\n  f(x_1, x_2) &= x_1x_2 + \\sin(x_1)\\\\\n              &= w_1w_2 + \\sin(w_1)\\\\\n              &= w_3 + w_4\\\\\n              &= w_5 = y,\n\\end{align}\nwhere we have introduced the temporary variables $w_i$ for later notational brevity.\nAssume that we are interested in $\\pdv*{y}{x_1}$ and $\\pdv*{y}{x_2}$. There are\ntwo main approaches in use: \\emph{forward} and \\emph{reverse} mode.\n\n\\subsection{Forward Mode}\n\nWe first decide on one independent variable to differentiate with respect to,\nsay $x_1$. We then compute $\\dot w_i = \\pdv*{w_i}{x_1}$ in order of increasing\n$i$ (forward through the computation).\n\nWhen we step through the computation of $f(x_1, x_2)$, we can simultaneously\ncompute the derivative we want. By normal rules of differentiation:\n\n\\begin{center}\n  \\begin{tabular}{ll}\n    Value & Derivative (w.r.t. $x_1$)\\\\\\hline\\\\\n    $w_1 = x_1$ & $\\dot w_1 = 1$\\\\\n    $w_2 = x_2$ & $\\dot w_2 = 0$\\\\\n    $w_3 = w_1w_2$ & $\\dot w_2 = \\dot w_1 w_2 + w_1\\dot w_2$\\\\\n    $w_4 = \\sin(w_1)$ & $\\dot w_4 = \\cos(w_1)\\dot w_1$\\\\\n    $w_5 = w_3 + w_4$ & $\\dot w_5 = \\dot w_3 +\\dot w_4$\\\\\n  \\end{tabular}\n\\end{center}\nSubstituting in the values from top to bottom we see that we indeed get\n$\\pdv{y}{x_1}=\\cos(x_1)+x_2$ as one would expect. We can now repeat the process\nonce more for $x_2$. Evidently, we only need to change the initial values $\\dot\nw_1$ and $\\dot w_2$, while the rest remains the same. Because of this, these\n\\say{trivial} first derivatives are sometimes referred to as \\emph{seed} values.\n\n\\subsection{Reverse Mode}\n\nInstead of first fixing the independent variable, we instead fix the dependent\nvariable which should be differentiated (only one in this case, \\(y\\)), and then\ncompute its derivative w.r.t. the different sub expressions $w_i$. We define\n\\(\\bar w_i = \\pdv*{y}{w_i}\\), and construct the following table of operations\n(backwards through the computation):\n\n\\begin{align*}\n  \\bar w_5 &= \\pdv{y}{w_5} = 1\\\\\n  \\bar w_4 &= \\pdv{y}{w_4} = \\bar w_5\\pdv{w_5}{w_4} = \\bar w_5\\\\\n  \\bar w_3 &= \\pdv{y}{w_3} = \\bar w_5\\pdv{w_5}{w_3} = \\bar w_5\\\\\n  \\bar w_2 &= \\pdv{y}{w_2} = \\bar w_3\\pdv{w_3}{w_2} = \\bar w_3 w_1\\\\\n  \\bar w_1 &= \\pdv{y}{w_1} = \\bar w_4\\pdv{w_4}{w_1} + \\bar w_3 \\pdv{w_3}{w_1}= \\bar w_4 \\cos(w_1) + \\bar w_3w_2.\n\\end{align*}\nNotice how reverse mode required only one pass though the algorithm in order to\nfind the derivatives of both independent variables, compared to two passes for\nforward mode.\n\nKeen readers might also recognize backpropagation as a special case of reverse mode \\gls{ad}.\n\n\\section{Forward Mode vs. Reverse Mode}\n\nWhile the two described approaches both obtain the same result, one is generally\npreferable to the other depending on the structure of the computation. Let the\ncomputation be a function $f: \\mathbb{R}^{m}\\to\\mathbb{R}^n$. Forward mode\nrequires $m$ passes (one per input), while reverse mode requires $n$ passes (one\nper output). So in general, if $m \\gg n$ we prefer reverse mode and when $m\\ll\nn$ we prefer forward.\n\nBecause of this, reverse mode automatic differentiation is by far the most\nprevailing choice in \\gls{ml} frameworks. This is because models almost always have\nmore inputs than outputs.\n\n\\section{Automatic Differentiation for VMC}\n\nAs \\gls{vmc} also needs quite a lot of derivatives it is natural to wonder if we\ncan have \\gls{ad} tools work to our advantage also in this area.\n\n\\subsection{First Order Derivatives}\n\nTo see how this could work, we should revisit the list of required operations\nfor wave functions in \\cref{sec:arbitrary-models-as-trial-wave-functions}. In\nthe list we see the need for first order derivatives w.r.t. both the inputs to\nthe wave function and its parameters. Both of these are straightforward to\nobtain in an efficient manner using reverse mode \\gls{ad}. To illustrate why, we can\nconsider the \\emph{Jacobian} matrix, $\\mat J$, which for a function\n$f:\\mathbb{R}^m\\to\\mathbb{R}^n$ looks like:\n\n\\begin{align}\n  \\mat J &=\n  \\begin{pmatrix}\n    \\pdv{f_1}{x_1} & \\pdv{f_1}{x_2} & \\dots & \\pdv{f_1}{x_m}\\\\\n    \\pdv{f_2}{x_2} & \\pdv{f_2}{x_2} & \\dots & \\pdv{f_2}{x_m}\\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\pdv{f_n}{x_1} & \\pdv{f_n}{x_2} & \\dots & \\pdv{f_n}{x_m}\\\\\n  \\end{pmatrix}\\,.\n\\end{align}\nA forward mode sweep calculates a column of $\\mat J$, while a reverse mode sweep\ncalculates a row~\\cite{auto-diff-Berland}. In our case, $f$ is a wave function\nwhich has a scalar output, and $\\mat J$ is really a row vector. Reverse mode is\nclearly superior in this case, requiring only a single pass.\n\n\\subsection{Higher Orders}\n\nReturning to the list of operations, we still have the ominous Laplace\noperator, $\\laplacian$. To see why this will be harder, we can consider the\n\\emph{Hessian} matrix, $\\mat H$:\n\n\\begin{align}\n  \\mat H &=\n  \\begin{pmatrix}\n    \\pdv[2]{f}{x_1} & \\pdv{f}{x_1}{x_2} & \\dots & \\pdv{f}{x_1}{x_m}\\\\\n    \\pdv{f}{x_2}{x_1} & \\pdv[2]{f}{x_2} & \\dots & \\pdv{f}{x_2}{x_m}\\\\\n    \\vdots & \\vdots & \\ddots & \\vdots\\\\\n    \\pdv{f}{x_M}{x_1} & \\pdv{f}{x_M}{x_2} & \\dots & \\pdv[2]{f}{x_m}\\\\\n  \\end{pmatrix}\\,.\n\\end{align}\nWe can compute these second order derivatives by applying \\gls{ad} twice. First we do\na reverse sweep and obtain the Jacobian (the row vector). The act of computing\nthe Jacobian is it self a function, $f: \\mathbb{R}^m\\to\\mathbb{R}^m$, and as\nsuch we can apply \\gls{ad} to it an obtain the elements of $\\mat H$.\n\nComputing the required Laplace operator equates to computing the trace (sum of\ndiagonal) of the Hessian matrix. Remember that a forward/reverse sweep\ncalculates a column/row of the matrix. That means that in order to get the\ndiagonal elements, we actually need $m$ sweeps, regardless of what direction we\ngo. Sadly, the complexity of this operation is so large that we have found it\nunfeasible to use for even a moderate number of inputs.\n\n\n\\section{Why Automatic Differentiation Failed}\n\nBecause \\gls{ad} is so central to most \\gls{ml} frameworks, like TensorFlow and\nPyTorch, a great deal of effort was put in to attempt to make a viable \\gls{vmc}\nimplementation within these. That would give out-of-the-box functionality for\nneural networks, optimization strategies, \\acrshort{gpu} acceleration etc.\nSadly, the inefficiency of the calculation of the Laplacian operator put a stop\nto such a marriage. The time spent by \\gls{ad} to compute $\\laplacian$ was\norders of magnitude worse than the manually coded analytically expressions, and\nscaled significantly worse with increasing number of particles. This severe\ndeficiency of \\gls{ad} resulted in the unfortunate need to depart from the\nexisting \\gls{ml} frameworks and implement everything manually (i.e.\nanalytically expressions for derivatives). This decision was not made lightly,\nand only after a painstaking effort to somehow attempt to defy the above\nmathematical argument. Unfortunately, mathematics was right.\n\nWe sincerely hope that \\gls{ad} can somehow be efficiently incorporated in\nfuture works. Research into how \\gls{ad} can be efficiently applied to higher\norder derivatives is ongoing, see for instance~\\textcite{wang2017}. If nothing\nelse, we could potentially use \\gls{ad} for Hamiltonians which do not include\nthe Laplacian operator.\n\n\n\\end{document}\n", "meta": {"hexsha": "d6969436cb23c0b4ac266c2dab2df615f461acb5", "size": 9542, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writing/AutomaticDifferentiation.tex", "max_stars_repo_name": "johanere/qflow", "max_stars_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-07-24T21:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-11T18:18:24.000Z", "max_issues_repo_path": "writing/AutomaticDifferentiation.tex", "max_issues_repo_name": "johanere/qflow", "max_issues_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2019-02-19T10:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-18T09:42:13.000Z", "max_forks_repo_path": "writing/AutomaticDifferentiation.tex", "max_forks_repo_name": "bsamseth/FYS4411", "max_forks_repo_head_hexsha": "72b879e7978364498c48fc855b5df676c205f211", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-11-04T15:17:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-03T16:37:38.000Z", "avg_line_length": 48.6836734694, "max_line_length": 119, "alphanum_fraction": 0.7407252148, "num_tokens": 2804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623216, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.4238870302915734}}
{"text": "\n\\chapter{Background}\n\\label{chap:background}\n\nThe history of hashing may be as long as the history of computer science. Hashing methods were originally used to implement dynamic sets that support only the dictionary operations such as insert, search, and delete~\\cite{cormen2001book}. Conventionally, people design hash functions which map objects to bins and then construct hash tables. With the hash tables, fast dictionary operations can be performed. For example, the expected time complexity of searching an element in a hash table is only $ O(1) $, although it can be $ \\Theta(N) $ in the worst case. A good hash table should have a low collision rate and use as little storage as possible.\n\nIn recent years, hashing has been introduced in several new problems such as similarity search~\\cite{gionis1999vldb,salakhutdinov2009ijar} and data compression~\\cite{shi2009aistats,weinberger2009icml,li2011nips}. In this thesis, our focus is hashing for similarity search.\nUnlike conventional hashing methods, hashing-based similarity search methods use collision to incorporate similarity. These methods are common in indexing objects using binary codes, making search extremely fast (without much loss of accuracy) even on very large data sets.\n\nDepending on whether or not machine learning techniques are applied to design the hash functions, existing hashing-based methods can be grouped into two categories: locality sensitive hashing (\\aka non-learning based hashing) and hash function learning (\\aka learning based hashing). While locality sensitive hashing methods have enjoyed great success over past decades, most of them are data independent and often generate very long hash codes which are practically inefficient for large-scale applications. On the contrary, hash function learning methods learn from data hash functions which reflect data characteristics more accurately and generate very compact codes. As a result, \\mbox{HFL} methods are more desirable in real applications. \n\nTo provide a solid background for this thesis, in this chapter, we review the literature of hashing-based methods for similarity search, and two machine learning areas, namely, active learning and metric learning, which are closely related to the methods we introduce later. Specifically, in Section~\\ref{background:lsh}, we give a brief introduction of locality sensitive hashing, which is then followed by a survey of hash function learning in Section~\\ref{background:hfl}. Section~\\ref{background:metric} and Section~\\ref{background:active} present a summarization of metric learning and active learning, separately. Finally, we summarize the chapter in Section~\\ref{background:sum}.\n\n%-------------------------------------------------------------------------------\n\\section{Locality Sensitive Hashing}\n\\label{background:lsh}\n\nThe family of \\textit{locality sensitive hashing} (\\mbox{LSH}) algorithms have been a hot research topic since the 1990s. In this section, we briefly introduce some well-known methods. For a detailed review, the readers are referred to~\\cite{andoni2006focs}. \n\nThe concept of \\mbox{LSH} is very simple, that is, it aims to hash objects\\footnote{In this paper, we use objects, points and documents interchangeably.} using a number of hash functions to ensure that, for each function, the collision probability for objects that are close to each other is much higher than that for far apart objects~\\cite{indyk1998stoc}. In other words, given a family of hash functions $\\mathcal{H}$ and two objects $ \\p $ and $ \\q $, \\mbox{LSH}~\\cite{charikar2002stoc} requires that \n$$ P_{\\mathcal{H}}[h(\\p)=h(\\q)] = \\mathit{sim}(\\p, \\q),$$\nwhere $ h $ is a hash function randomly selected from $\\mathcal{H}$, $ P(\\cdot) $ indicates the probability and $ \\mathit{sim}(\\cdot,\\cdot) $ returns a similarity value in the range of $ [0,1] $ based on some metric. Usually, $ h $ has only two hash values $ \\{0,1\\} $ and \\mbox{LSH} uses several hash functions to generate binary codes. Therefore, \\mbox{LSH} actually maps data objects from the original feature space to a Hamming space where the Hamming distance incorporates the similarity. It is very efficient to perform the search in the Hamming space via bit operations or data structures such as dictionaries.\n\n%More specifically,  is called ($R,cR, P_{1}, P_{2}$)-sensitive (locality sensitive) if for any two points $\\p,\\q \\in \\mathbb{R}^{D}$,\n%\\begin{itemize}\n%\\item\n%if $\\|\\p-\\q\\|\\le R$, then $P_{\\mathcal{H}}[h(\\p)=h(\\q)]\\ge P_{1}$,\n%\\item\n%if $\\|\\p-\\q\\|\\ge cR$, then $P_{\\mathcal{H}}[h(\\p)=h(\\q)]\\le P_{2}$.\n%\\end{itemize}\n%\n%In order to be useful, an \\mbox{LSH} algorithm has to satisfy $P_{1}>P_{2}$. Actually, all \\mbox{LSH} algorithms try to amplify the gap between $P_1$ and $P_2$ by constructing hash functions.\n\n\\mbox{LSH} functions are highly dependent on the similarity measures used in the task. Up to now, many \\mbox{LSH} functions have been proposed. In the following subsections, we introduce them separately according to the adopted similarity measures.\n\n%are highly dependent on the similarity measure being adopted. Several \\mbox{LSH} families have been proposed for different similarity measures, such as the Hamming distance, $\\ell_1$ distance, $\\ell_s$ distance, Jaccard coefficient and the angle distance. Some examples for each kind of distance are:\n%\\begin{description}\n%  \\item[Hamming distance] One simple \\mbox{LSH} family is $h_i(\\p) = p_i, i\\in\\{1,\\dots,D\\},\\p\\in\\{0,1\\}^{D}$. The locality-sensitive property is $\\rho = 1/c.$\n%  \n%  \\item[$\\ell_1$ distance] The \\mbox{LSH} hash functions can be constructed as follows, for a fixed real number $w\\gg R$, pick random real numbers $s_1,\\dots,s_D\\in[0,w)$ and define \n%  $$h_{s_1,\\dots,s_D}(\\p) = (\\lfloor(p_1-s_1)/w\\rfloor,\\dots,\\lfloor(p_D-s_D)/w\\rfloor),\\p\\in\\mathbb{R}^D.$$ The locality-sensitive property is $\\rho = 1/c+O(R/w).$\n%  \n%  \\item[$\\ell_s$ distance] The \\mbox{LSH} functions can be constructed as follows, choose a random number $w$ and a random projection vector $\\r\\in \\mathbb{R}^D$ (each of whose coordinates is picked from a Gaussian distribution), then $h_{\\r,b}(\\p) = \\lfloor(\\r\\cdot \\p+b)/w\\rfloor$ where $\\p\\in\\mathbb{R}^D$ and $b\\in[0,w)$ is random. The\n%locality-sensitive property is $\\rho < 1/c$ for some (carefully chosen) finite values of $w$.\n%\n%  \\item[Jaccard coefficient] Jaccard coefficient is defined as a similarity metric between two sets $\\mathcal{A}$ and $\\mathcal{B}$: $s(\\mathcal{A},\\mathcal{B}) = \\frac{|\\mathcal{A}\\cap \\mathcal{B}|}{|\\mathcal{A}\\cup \\mathcal{B}|}$. One \\mbox{LSH} family is $h_{\\pi}(\\mathcal{A}) = \\min\\{\\pi(a)\\mid a\\in \\mathcal{A}\\}$, where $\\pi$ is a random permutation on the ground universe.\n%  \n%  \\item[Angle distance] Angle distance between two points is defined as\n%  $$\\Theta(\\p,\\q) = \\arccos\\left(\\frac{\\p\\cdot \\q}{\\|\\p\\|\\cdot\\|\\q\\|}\\right),\\p,\\q\\in\\mathbb{R}^{D},$$ where $\\|\\cdot\\|$ denotes the vector $\\ell_2$ norm. One \\mbox{LSH} family for this metric can be constructed as follows, pick a random unit vector $\\u$ and define $h_{\\u}(\\p) = \\sgn(\\u\\cdot \\p)$.\n%\\end{description}\n\n\n\n%Actually, we should introduce the methods for different similarities.\n%\\subsection{Hamming Distance}\n%\n%The seminal work of using hashing for similarity search, we call it Bit Sampling.\n%The seminal work is~\\cite{indyk1998stoc}, it is said to be for Hamming distance. and followed by some random projection based methods.\n%\n%What codes does it generate? binary or non-binary?\n\n\\subsection{ $\\ell_s $ Distance}\n\nThe most commonly used distance might be the Euclidean distance (\\aka $\\ell_2 $ distance). In~\\cite{datar2004scg}, \\mbox{LSH} functions for the Euclidean distance can be constructed as follows: choose a random number $w$ and a random projection vector $\\r\\in \\mathbb{R}^D$ (each of whose coordinates is picked from a Gaussian distribution), then $h_{\\r,b}(\\p) = \\lfloor(\\r\\cdot \\p+b)/w\\rfloor$ where $b\\in[0,w)$ is a random threshold and $\\p\\in\\mathbb{R}^D$ is an object to be hashed. There is a publicly available software package which has implemented this algorithm.\\footnote{\\url{http://www.mit.edu/~andoni/LSH/}} Recently, Dasgupta \\etal~\\cite{dasgupta2011kdd} further improved the speed of the hash function construction of \\mbox{LSH} for Euclidean distance using the Hadamard matrix.\n\nAnother common distance is $ \\ell_1 $ distance, for which the \\mbox{LSH} hash functions are defined as~\\cite{andoni2006soda}: for a fixed real number $w\\gg R$,\\footnote{$ R $ is a user specified number controlling the distance between points which are considered as neighbors.} pick random real numbers $s_1,\\dots,s_D\\in[0,w)$ and define $h_{s_1,\\dots,s_D}(\\p) = (\\lfloor(p_1-s_1)/w\\rfloor,\\dots,\\lfloor(p_D-s_D)/w\\rfloor),\\p\\in\\mathbb{R}^D.$  \n\nConstructions of \\mbox{LSH} functions for $ \\ell_s $ distance for any $ s\\in(0,2] $ are also possible~\\cite{datar2004scg}. \n\n\n\n\n\\subsection{Cosine Similarity}\n\nIn the data mining and information retrieval communities, especially for documents, the most commonly used metric is cosine similarity. Its value between two vectors $ \\p  $ and $ \\q  $ is defined as:\n$$\\Theta(\\p,\\q) = \\arccos\\left(\\frac{\\p\\cdot \\q}{\\|\\p\\|\\cdot\\|\\q\\|}\\right),\\p,\\q\\in\\mathbb{R}^{D},$$ where $\\|\\cdot\\|$ denotes the vector $\\ell_2$ norm. For this similarity measure, Charikar \\etal~\\cite{charikar2002stoc} defines the following LSH family: pick a random unit vector $\\u$ and define $h_{\\u}(\\p) = \\sgn(\\u\\cdot \\p)$. The hash function can also be viewed as partitioning the space into two half-spaces by a random hyperplane. The collision probability in this case is $ P[h(\\p )=h(\\q )] = 1-\\Theta(\\p ,\\q )/\\pi $.\n\n%Here you should make clear the search procedure, which is also applied in \\mbox{KLSH}~\\cite{kulis2009iccv}.\n\nManku \\etal~\\cite{manku2007www} applied the above mentioned hash functions with some modifications to document de-duplication and named the algorithm \\mbox{SimHash}. Since then, \\mbox{SimHash} has become one of the most well-known hashing-based methods. \\mbox{SimHash} has also been implemented under the framework of \\mbox{MapReduce} for cross-lingual pairwise similarity~\\cite{ture2011sigir}. Eshghi \\etal~\\cite{eshghi2008kdd} developed a new \\mbox{LSH} family for cosine similarity based on concomitant rank order statistics. \n\n%This group of work was first for cosine similarity and \\mbox{EMD}. They are called SimHash and famous because google used this algorithm.\n%\n%%The procedure for cosine similarity is easy to follow, but for \\mbox{EMD} the procedure is hard to follow. But for uniform case, it can be considered a general form of minwise hashing~\\cite{broder1998stoc}.\n%\n%For cosine similarity and \\mbox{EMD}, we call it SimHash~\\cite{charikar2002stoc}, it generates binary codes. But google used this method for document deduplication~\\cite{manku2007www}, but I don't know whether it is binary.\n\n\\subsection{Jaccard Similarity}\nJaccard coefficient is widely used to measure similarity between sets. The definition of Jaccard Similarity is: $s(\\mathcal{A},\\mathcal{B}) = \\frac{|\\mathcal{A}\\cap \\mathcal{B}|}{|\\mathcal{A}\\cup \\mathcal{B}|}$, which can be approximated by a simple approach based on random permutations~\\cite{broder1997ccs,broder1997www}. Based on this property, Broder \\etal proposed the first \\mbox{LSH} family for Jaccard similarity which is called minwise Hashing or \\mbox{MinHash}~\\cite{broder1998stoc}. The hash functions of \\mbox{MinHash} can be described simply as follows: $h_{\\pi}(\\mathcal{A}) = \\min\\{\\pi(a)\\mid a\\in \\mathcal{A}\\}$, where $\\pi$ is a random permutation on the ground universe. %Actually they come up with a new approximate method for Jaccard similarity. \n\n%Where does hash play a role?\\footnote{Please check~\\cite{broder1998stoc} for details and make this part clear.} \n\nRecently, Li \\etal have extended \\mbox{MinHash} to generate more compact codes~\\cite{li2010www,li2010nips}. Chum \\etal~\\cite{chum2009cvpr} have proposed a geometric \\mbox{MinHash} algorithm and applied it to the image retrieval task. %\\footnote{Please check what does this paper say?}\n\n%And give these two papers more detailed information.\n%This group of work is called Minwise Hashing.\n%For set similarity, it generates non-binary codes. Actually this is Jaccard similarity. The seminal work is, followed by\n\n\\subsection{Kernel Similarity}\n%\\subsubsection{Kernelized LSH}\n\nIn many applications, the similarity metric of interest is defined by means of kernels. As a result, developing hashing-based methods for kernel similarity is also very important. For the Pyrimid match kernel, a widely used kernel in vision problems, Pyrimid match hashing~\\cite{grauman2007cvpr} was developed. The algorithm can be simply summarized as first generating an embedding of the Pyrimid match kernel, and then using the \\mbox{SimHash} to obtain the binary codes for the embedding. Jain \\etal~\\cite{jain2008cvpr} proposed a similar hashing algorithm for a learned \\mbox{Mahalanobis} distance, which is equivalent to a special kernel. More generally, for shift invariant kernels, hash functions can be constructed as follows~\\cite{raginsky2009nips}. First get random features using Fourier transforms~\\cite{rahimi2007nips} and then threshold them randomly to give the binary codes.\n\nKulis \\etal~\\cite{kulis2009iccv} implemented the idea of random projections in the kernel space and formulated \\mbox{KLSH}. In general, \\mbox{KLSH} uses a random set of points to form random projections and can accommodate any kernels. Recently, \\mbox{KLSH} was extended to accept multiple kernels in~\\cite{zhang2011mm}.\n\n\n\n%\\subsection{Special Cases}\n%%\\subsection{Learned Metric}\n%\\subsubsection{Non-metric Distance}\n%\\subsubsection{Asymmetric Distance}\n\\subsection{Summary}\n\nBesides the aforementioned algorithms, \\mbox{LSH} functions have also been extended for some special settings, such as asymmetric Hamming distance~\\cite{dong2008sigir,gordo2011cvpr} and non-metric similarity~\\cite{athitsos2008icde,mu2010aaai}.\n\nAlthough theoretically effective and efficient, \\mbox{LSH} methods have some apparent limitations. Most of all, they are data independent and thus may not reflect the data characteristics accurately. As a result, these methods always generate very long codes which are very inefficient for large-scale data sets and hence of limited practical use. It is this limitation that motivates hash function learning.\n\n\n%LSH families actually do not use bit operations to conduct fast search, they use data structures such as HST~\\cite{indyk1998stoc} or some procedure introduced in~\\cite{charikar2002stoc}.\n\n\n % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\\section{Hash Function Learning}\n\\label{background:hfl}\n\nThe past five years have witnessed increasingly rapid progress in the topic of hash function learning (\\mbox{HFL}), or learning-based hashing. The goal of \\mbox{HFL} is to learn, rather than design, the hash functions from data so that the hash functions can generate very compact (short) hash codes. Despite being a young area, a number of \\mbox{HFL} methods have been proposed up to now. Depending on how the label information or side-information is used in the learning procedures, we roughly classify these methods into three categories: unsupervised, semi-supervised and supervised methods. \n%In the following subsections, we present some representative methods in each category.\n\n%\\subsection{Embedding-based Approach}\n%\\subsubsection{Continuous Embedding Approach}\n%\\subsubsection{Discrete Embedding Approach}\n%\\subsection{Model-based Approach}\n%\\subsubsection{SVM-based}\n%\\subsubsection{Boosting-based}\n\\subsection{Unsupervised Hash Function Learning}\nUnsupervised \\mbox{HFL} methods learn hash functions from unlabeled data only and do not use labels or side-information. Although the model formulations are different from each other, the common idea is to make similar points close to each other and dissimilar points far apart in the Hamming space in which the hash codes live.\\footnote{Note that ``similar'' and ``dissimilar'' are determined by features of unlabeled data.}\n\n\\subsubsection{Spectral hashing}\nThe most well-known unsupervised \\mbox{HFL} algorithm should be \\textit{spectral hashing} (\\mbox{SH}). The objective of \\mbox{SH} is similar to one popular dimensionality reduction method called \\textit{Laplacian Eigenmap}, meaning that points that are similar in the original feature space should have small distance in the embedded space. However, different from \\textit{Laplacian} Eigenmap which embeds data into the Euclidean space, \\mbox{SH} maps data into the Hamming space. For a code to be efficient, the authors require that each bit has a 50\\% chance of being one or zero, and that different bits are independent of each other. \n\nPutting all things together, \\mbox{SH} is formulated as the following optimization problem:\n\\begin{align}\n\\min_{\\y_i}&~\\sum_{ij}W(i,j)\\|\\y_i-\\y_j\\|^2\\nonumber\\\\\n\\subto&~\\y_i\\in\\{+1,-1\\}^{M},~\\sum\\nolimits_i\\nolimits^{N}\\y_i=0,~\\frac{1}{n}\\sum\\nolimits_i\\nolimits^{N}\\y_i\\y_i^T=\\I,\\nonumber\n\\end{align}\nwhere $\\y_i$ is the hash code of the $i$th point, $W(i,j)$ is the similarity between the $i$th and $j$th points, $M$ is the length of each code and $ N $ is the number of points. Note that the authors relax the independence assumption and require the bits to be uncorrelated by constraint $ \\frac{1}{n}\\sum_i\\y_i\\y_i^T=\\I $, because it is hard to enforce independence between bits. Then above problem can be rewritten using matrix notations as follows:\n\\begin{align}\n\\min_{\\Y}&~\\tr(\\Y^T\\mathcal{L}\\Y)\\nonumber\\\\\n\\subto&~Y_{ij}\\in\\{+1,-1\\}^{M},\\Y^T\\1=\\0,\\Y^T\\Y=\\I,\n\\label{problem:sh:original}\n\\end{align}\nwhere $\\Y$ is the $N\\times M$ code matrix, $\\mathcal{L}$ is the graph \\textit{Laplacian} defined on the similarity matrix $\\W$. \n\nActually, the above problem for each single bit is equivalent to a balanced graph partitioning problem and NP-hard, so Problem~(\\ref{problem:sh:original}) is NP-hard. However, if we remove the first two constraints, the problem can easily be solved by finding $K$ eigenvectors corresponding to the smallest eigenvalues of $\\mathcal{L}$ (ignoring the eigenvector $\\1$ corresponding to eigenvalue 0). \n\nThe solution above has two limitations. First, it involves eigen-decomposition which could be very slow when $N$ is large. Moreover, it cannot deal with out-of-sample data points. To overcome these two limitations, the authors use eigenfunctions instead of the eigenvectors. To make the computation tractable, they simply assume that the data points are uniformly distributed in a rectangle and the similarity measure is fixed as $ \\exp(\\|\\x_i-\\x_j\\|^2/\\sigma^2) $. The resultant model is very fast to train and experimental results show that it is superior to \\mbox{LSH}. \n\nRecently, He \\etal~\\cite{he2010kdd} proposed a kernel extension of \\mbox{SH}, which can handle nonvectorial data, incorporate nonlinearity and places no restrictions on the uniform distribution and the fixed similarity measure. Zhang \\etal~\\cite{zhang2010sigir,zhang2010fgsir} used \\mbox{SVM} to enhance \\mbox{SH} with the aim of removing the distribution and similarity assumptions.\n\n\n\\subsubsection{Binary reconstructive embeddings}\nKulis \\etal~\\cite{kulis2009nips} developed another unsupervised \\mbox{HFL} algorithm, namely, \\textit{binary reconstructive embeddings} (\\mbox{BRE}), based on explicitly minimizing the reconstruction error between the original distance and the Hamming distance of the corresponding binary hash codes. \\mbox{BRE} can be easily kernelized and does not require restrictive assumptions about the underlining data distribution.\n\nSpecifically, let $M$ be the number of hash functions (\\aka code length), $N$ be the number of data points, and $Q$ be the number of landmark points. Given a data set $\\mathcal{X}$, \\mbox{BRE} defines the hash function \\wrt (with respect to) the $m$th bit for $\\x\\in\\mathcal{X}$ as:\n\\begin{align}\nh_{m}(\\x) = \\sgn\\left(\\sum\\nolimits_{q=1}\\nolimits^{Q}W(m,q)\\kappa(\\x_q,\\x)\\right),\\nonumber\n\\end{align}\nwhere $\\W$ is an $M\\times Q$ projection matrices, $\\{\\x_q\\}_{q=1}^{Q}\\subset\\mathcal{X}$ are landmark points, and $\\kappa(\\cdot,\\cdot)$ is a user specified kernel function. Note that defining hash functions this way is very common in kernel methods such as \\textit{support vector machines} (\\mbox{SVM}) and gives us the flexibility to work on a wide variety of data types. Therefore, given one point $\\x\\in\\mathcal{X}$, we denote its corresponding binary representation as $\\tilde{\\x}$ such that its $m$th bit can be evaluated by $\\tilde{x}(m) = (1+h_{m}(\\x))/2$.\n\nRather than simply choosing the $ \\W $ matrix based on random hyperplanes, they construct this matrix to achieve good reconstructions. In particular, they minimize the squared error between the original distance and the reconstructed distance \\wrt $ \\W $ as follows,\n\\begin{align}\n\\mathcal{O}\\left(\\W\\right)=\\sum\\nolimits_{(\\x_i,\\x_j)\\in\\mathcal{N}}\\left(d(\\x_i,\\x_j)-\\tilde{d}(\\x_i,\\x_j)\\right)^{2},\\nonumber\n\\end{align}\nwhere $\\mathcal{N}$ is a set of point pairs, $ d(\\cdot,\\cdot) $ is the original distance, $ \\tilde{d}(\\cdot,\\cdot) $ is the Hamming distance. Although the problem is non-convex and hard to optimize, the authors use a heuristic coordinate-descent algorithm to find a locally optimal $ \\W $. Experiments show that \\mbox{BRE} achieves a state-of-the-art performance, but finding a good local optimum is hard and the performance highly depends on the applications at hand.\n\n%%%%%%%%%%%%%%%%%%%\n\\subsection{Semi-Supervised Hash Function Learning}\nIn semi-supervised \\mbox{HFL} methods, both unlabeled and labeled data are used. Different from original unlabeled features, the labels or side-information which often carries semantic information might be very useful for hash function learning. The basic idea of semi-supervised \\mbox{HFL} is to consider both kinds of information to learn the hash functions.\n\n\\subsubsection{Semantic hashing}\nTo learn the hash codes, semantic hashing uses multiple layers of \\textit{restricted Boltzmann machines} (\\mbox{RBM}), which are closely related to one popular dimensionality reduction framework based on neural networks~\\cite{hinton2006science}. An \\mbox{RBM} is an ensemble of binary vectors with a network of stochastic binary units arranged in two layers, one visible and one hidden. Given a layer of visible units $\\v = [v_1, v_2, \\dots, v_M]$, a layer of hidden units $\\h=[h_1, h_2,\\dots, h_N]$, and a symmetric weighting matrix $\\W$ connecting units in different layers, the energy function of the joint configuration of all visible and hidden units is defined as:\n\\begin{align}\nE(\\v, \\h) = -\\sum\\nolimits_{i=1}\\nolimits^{M}b_{i}v_{i}-\\sum\\nolimits_{j=1}\\nolimits^{N}b_{j}h_{j}-\\sum\\nolimits_{i=1}\\nolimits^{M}\\sum\\nolimits_{j=1}\\nolimits^{N}v_i h_i W(i,j),\n\\end{align}\nwhere $v_i$ and $h_j$ are the binary states of visible and hidden units $i$ and $j$, $ W(i,j)$ are the weights and $b_i$ and $b_j$ are bias terms. Using this energy function, a probability can be assigned to a binary vector of the visible\nunits:\n\\begin{align}\nP(\\v) =\\sum\\nolimits_{\\h}\\left(\\left.e^{-E(\\v,\\h)}\\middle/\\left(\\sum\\nolimits_{\\u,\\g}e^{-E(\\u,\\g)}\\right)\\right.\\right).\\nonumber\n\\end{align}\n\nAn \\mbox{RBM} lacks connections between units within a layer, hence the conditional distributions $P(\\h|\\v)$ and $P(\\v|\\h)$ have convenient forms, being products of Bernoulli distributions:\n\\begin{align}\nP(h_j = 1|\\v) = \\sigma\\left(b_j +\\sum\\nolimits_{i}w_{ij}v_i\\right), \\ \\ & \\ \\ P(v_i = 1|\\h) = \\sigma\\left(b_i +\\sum\\nolimits_{j}w_{ij}h_j\\right),\\nonumber\n\\end{align}\nwhere $\\sigma(x) = 1/(1 + e^{-x})$ is the logistic sigmoid function.\n\nRecently, Salakhutdinov \\etal~\\cite{salakhutdinov2009aistats} demonstrated methods for stacking \\mbox{RBM} into multiple layers, creating ``deep networks\" which can capture high order correlations between the visible units at the bottom layer of the network. By choosing an architecture that progressively reduces the number of units in each layer, a high dimensional binary input vector can be mapped to a far smaller binary vector at the output. Thus, at the output each bit maps through multiple layers of nonlinearities to model the complicated subspace of the input data. If the feature values are not binary but real numbers, the first layer of visible units are modified to have a Gaussian distribution. This type of trained networks are capable of capturing higher order correlations between different layers of the network. Since the network structure gradually reduces the number of units in each layer, the high-dimensional input can be projected to a much more compact binary vector space.\n\nA practical implementation of \\mbox{RBM} has two major stages, an unsupervised pre-training stage and a supervised fine-tuning stage. The greedy pre-training stage is progressively executed layer by layer from input to output. After achieving convergence of the parameters of a layer via contrastive divergence, the derived activation probabilities are fixed and treated as input to drive the training of the next layer. During the fine-tuning stage, the labeled data is used to help refine the trained network through back-propagation. Specifically, a cost function is first defined to estimate the number of correctly classified points in the training set. Then, the network weights are refined to maximize this objective function through gradient descent. \n\nSemantic hashing outperforms \\mbox{LSH} methods in applications such as document retrieval, but it involves estimating a large number of weights. As such, it not only involves an extremely costly training procedure, but also demands sufficient labeled training data for fine-tuning.\n\n%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Semi-supervised hashing}\nRather than use unlabeled and labeled data in two separate stages like semantic hashing, Wang \\etal~\\cite{wang2010cvpr} have developed a simple semi-supervised hashing (\\mbox{SSH}) method which uses both kinds of information in a unified framework.\n\nGiven a set of $N$ data points, $\\X \\in \\mathbb{R}^{N\\times D}$, and the $i$th row of $\\X$ corresponds to a $D$-dimensional point that will be denoted by $\\x_i$ in the sequel, the authors want to learn $M$ hash functions leading to a $M$-bit binary codes $\\Y \\in \\{0,1\\}^{N\\times M}$ of $\\X$. In the paper, the $m$th hash function is defined as,\n$$h_{m}(\\x) = \\sgn\\left(\\w^T_{m}\\x+b_{m}\\right),$$\nwhere $\\w$ is a $D$-dimensional projection vector and $b_{m}$ is a scaler.\\footnote{Note that one bit of binary code can be easily obtained by setting $y_m(\\x) = \\left(1+h_{m}(\\x)\\right)/2$.} Without loss of generality, we assume that $\\X$ has zero-mean ($\\sum_{i=1}^{N}\\x_i=\\0$),\\footnote{If this is not the case, preprocessing can be applied on the data.} then the hash function can be simplified as,\n$$h_{m}(\\x) = \\sgn(\\w^T_{m}\\x).$$\n\nBased on the labels or side-information, the authors construct a set of similar point pairs $\\mathcal{S}$ and a set of dissimilar pairs $\\mathcal{D}$. We use $\\mathcal{SD}$ to denote the set of points involved in $\\mathcal{S}$ and $\\mathcal{D}$,  and $\\X_{\\mathcal{SD}}\\in \\mathbb{R}^{l\\times D}$ to denote its matrix form, where $l = |\\mathcal{SD}|<N$.\n\n%Further, suppose there are $l$ points, $l < n$, each of which is associated with at least one of the two groups $\\mathcal{S}$ or $\\mathcal{D}$.\n\nIn \\mbox{SSH}, the hashing functions $\\mathcal{H} = \\{h_m\\}_{m=1}^M$ can be learned by optimizing two objectives. The first objective is to maximize the empirical accuracy on $\\mathcal{S}$ and $\\mathcal{D}$, which is defined as the sum of difference of the total number of correctly classified pairs and that of wrongly classified pairs by each bit as follows:\n\\begin{align}\nJ(\\mathcal{H}) = \\sum\\nolimits_{m=1}\\nolimits^M\\left(\\sum\\nolimits_{(\\x_i,\\x_j)\\in\\mathcal{S}}h_m(\\x_i)h_m(\\x_j) - \\sum\\nolimits_{(\\x_i,\\x_j)\\in\\mathcal{D}}h_m(\\x_i)h_m(\\x_j)\\right).\\nonumber\n\\end{align}\n\nOptimizing the above objective function is difficult, since the hash functions $\\{h_m\\}_{m=1}^M$ are discrete and not differentiable. As such, the $\\sgn(\\cdot)$ operator is dropped and the following approximate objective is used instead,\n\\begin{align}\nJ(\\W) &= \\sum\\nolimits_{m=1}\\nolimits^M\\left(\\sum\\nolimits_{(\\x_i,\\x_j)\\in\\mathcal{S}}\\w_m^T\\x_i\\x_j^{T}\\w_m - \\sum\\nolimits_{(\\x_i,\\x_j)\\in\\mathcal{D}}\\w_m^T\\x_i\\x_j^{T}\\w_m\\right)\\nonumber\\\\\n&= \\frac{1}{2}\\tr\\left(\\W^{T}\\X_{\\mathcal{SD}}^{T}\\S\\X_{\\mathcal{SD}}\\W\\right),\\nonumber\n\\end{align}\nwhere $\\W = [\\w_1,\\dots,\\w_M] \\in \\mathbb{R}^{D \\times M}$ and $\\S\\in \\mathbb{R}^{l\\times l}$ is a relational matrix incorporating pairwise relations,\n\\begin{align}\nS(i,j) = \\left\\{ \\begin{array}{ll}\n+1 & \\mbox{if } (\\x_i,\\x_j)\\in\\mathcal{S}\\\\\n-1 & \\mbox{if } (\\x_i,\\x_j)\\in\\mathcal{D}\\\\\n0 & \\textrm{otherwise}\n\\end{array} \\right..\\nonumber\n\\end{align}\n\nThe other objective is to maximize the information conveyed by each bit of hash codes. From an information-theoretic point of view, a binary bit, which gives a balanced partition (\\textit{maximal entropy partition}) of $\\X$ ($\\sum_{i=1}^{n}h(\\x_i) = 0$), provides the maximum information. Although finding mean-thresholded hash functions that meet the balancing requirement is \\mbox{NP-hard}~\\cite{weiss2008nips}, it is proved that this objective is equivalent to maximizing the variance of a bit~\\cite{wang2010cvpr}, which is lower-bounded by the scaled variance of the projected data. Thus the scaled variance of the projected data is used as the second objective,\n\\begin{align}\nR(\\W) = \\rho\\sum\\nolimits_{k=1}\\nolimits^{K}\\w_m^T\\X^T\\X\\w_m,\\nonumber\n\\end{align}\nwhere $\\rho$ is a scaling parameter.\n\nCombining the two objectives into one, the optimization problem of \\mbox{SSH} is formulated as follows:\n\\begin{align}\n\\label{eqn:ssh}\n\\max_{\\W} & ~\\frac{1}{2}\\tr\\left(\\W^{T}\\left(\\X_{\\mathcal{SD}}^{T}\\S\\X_{\\mathcal{SD}}+\\rho\\X^{T}\\X\\right)\\W\\right)\\\\\n\\subto & ~\\W^T\\W = \\I,\\nonumber\n\\end{align}\nwhere the constraint $\\W^T\\W = \\I$ is commonly used to incorporate the uncorrelatedness of the projection directions~\\cite{weiss2008nips}. Obviously, Problem~(\\ref{eqn:ssh}) can be solved by spectral decomposition of the matrix $\\X_{\\mathcal{SD}}^{T}\\S\\X_{\\mathcal{SD}}+\\rho\\X^{T}\\X$ and $\\W$ is actually the eigenvectors corresponding to the largest eigenvalues.\n\nWang \\etal~\\cite{wang2010icml} argue that it is better to consider the dependence between contiguous bits rather than treat them independently. To this end, they propose a sequential learning algorithm which obtains one bit of codes at a time and updates the relational matrix $ \\S $ before learning the next bit. Experimental studies show that the sequential algorithm achieves much better performance than semantic hashing.\n\n\\subsubsection{Label-regularized max-margin partition}\nMu \\etal have taken the concept of margin into consideration to propose a semi-supervised \\mbox{HFL} method termed \\textit{label-regularized max-margin partition} (\\mbox{LAMP})~\\cite{mu2010cvpr}. Considering each hash function a binary classifier, the authors argue that larger margin between hash-induced partitions usually indicates better generalization ability to out-of-sample data.\n\nFor each hash function, the optimization problem of \\mbox{LAMP} is formulated as follows:\n\\begin{align}\n\\min_{\\omega,b, \\xi,\\zeta,y}&~\\frac{1}{2}\\|\\omega\\|^2+\\frac{\\lambda_1}{N}\\sum_{i}\\xi_i+\\frac{\\lambda_2}{N}\\sum_{(i,j)\\in\\Theta}\\zeta_{ij}\\nonumber\\\\\n\\subto&~y_i(\\omega^T\\x_i+b)+\\xi_i\\ge1,\\xi_i\\ge0, \\forall ~i,\\nonumber\\\\\n&~y_yy_j+\\zeta_{ij}\\ge0,\\zeta_{ij}a\\ge0,\\forall ~(ij)\\in\\Theta\\nonumber,\n\\end{align}\nwhere $ \\omega $ and $ b $ are the parameters of the hash function, $ y $ is the label vector induced by the hash function, $ \\Theta $ denotes the set of constraints which is generated from label or side information. Since $ y_i $ is always set to be $ \\sgn(\\omega^T\\x_i+b) $ in hashing-based methods and $ \\omega $ can be represented by a linear combination of random landmark vectors using the kernel-trick, the modified formulation of the problem is used:\n\\begin{align}\n\\label{SSLTH:LAMP}\n\\min_{\\nu,b, \\xi,\\zeta}&~\\frac{1}{2}\\nu^T\\G\\nu+\\frac{\\lambda_1}{N}\\sum_{i}\\xi_i+\\frac{\\lambda_2}{N}\\sum_{(i,j)\\in\\Theta}\\zeta_{ij}\\\\\n\\subto&~|\\nu^T\\k_i+b)+\\xi_i\\ge1,\\xi_i\\ge0, \\forall ~i,\\nonumber\\\\\n&~(\\nu^T\\kappa_i+b)(\\nu^T\\kappa_j+b)+\\zeta_{ij}\\ge0,\\zeta_{ij}a\\ge0,\\forall ~(ij)\\in\\Theta\\nonumber,\n\\end{align}\nwhere $ \\G $ is a matrix computed from the random landmark vectors and $ \\kappa_i $ denotes the kernel similarity between the $ i $th point and all the landmark vectors.\n\nTo optimize Problem~(\\ref{SSLTH:LAMP}), however, is difficult since it is non-convex and nonlinear. The authors decompose the problem using a \\textit{constrained-concave-convex-procedure} (\\mbox{CCCP})~\\cite{yuille2001nips}, and then solve the relaxed convex sub-problems in each iteration through an efficient cutting-plane based \\mbox{QP} solver.\n\nOn several real data sets, \\mbox{LAMP} outperforms kernelized \\mbox{LSH}~\\cite{kulis2009iccv} by a large margin. However, \\mbox{LAMP} suffers from the local optimality issue and its performance is highly dependent on the quantity and quality of labeled pairs.\n\n\\subsection{Supervised Hash Function Learning}\nIn supervised \\mbox{HFL} methods, only labeled data are used. There are several forms of label information, such as data labels and pairwise constraints, for example, similar pairs or dissimilar pairs.\n\n\\subsubsection{Boosted similarity sensitive coding}\n\\textit{Boosted similarity sensitive coding} (\\mbox{BoostSSC})~\\cite{shakhnarovich2003iccv,shakhnarovich2005thesis} might be, to the best of our knowledge, the first \\mbox{HFL} algorithm for similarity search. Taking an embedding viewpoint, the authors propose to learn the embedding of unlabeled data into the Hamming space in which weighted Hamming distance preserves similarity information in the original input space.\n\nIn their approach, they first construct two kinds of point pairs based on labels or side information. In a positive point pair $( x_i , x_j )$, $ x_j $ is one of $ N $ nearest neighbors of $ x_i $ or vice versa. In a negative pair, two points are not neighbors. After embedding or mapping, each point is represented by an $M$-bit binary vector $\\y_i = [h_{1}(\\x_i), h_{2}(\\x_i), ..., h_{M}(\\x_i)]$, and the weighted Hamming distance between two points is given by $$d(\\y_i, \\y_j) = \\sum^{M}_{m=1}\\alpha_{m}|h_{m}(\\x_i)-h_{m}(\\x_j)|,$$ where the weights $\\alpha_{m}$'s and the functions $h_{m}$'s that map the input vector $\\x_i$ into binary features are learned using Boosting~\\cite{schapire1999ijcai,schapire1999mlj}.\n\nAt each iteration of the learning stage, \\mbox{BoostSSC} selects the parameters to minimize the following squared loss:\n\\begin{align}\n\\sum\\nolimits_{k=1}\\nolimits^{K}w(k)(z(k)-d(k))^2,\\nonumber\n\\end{align}\nwhere $ K $ is the number of training pairs, $ z(k) $ is the neighborhood label ($ z(k) = 1 $ if the points are neighbors and $ z(k) = −1 $ otherwise) of the $ k $th pair, $ w(k) $ is the weight of the $ k $th pair and $ d(k) $ is the weighted Hamming distance of the $ k $th pair computed based on current model parameters. After each iteration, \\mbox{BoostSSC} increases the weights of wrongly classified pairs such that hash functions learned in the next iteration can be improved.\n\nTo summarize, \\mbox{BoostSSC} is simple to code, relatively fast to train and achieves competitive performance in~\\cite{torralba2008cvpr}. However, \\mbox{BoostSSC} might be slow to converge and become trapped in the local optimums.\n\n\\subsubsection{SPEC hashing}\n\nInspired by the idea of distribution matching in metric learning, Lin \\etal~\\cite{lin2010cvpr} have developed another supervised HFL method called \\textit{similarity preserving entropy-based coding} (\\mbox{SPEC}), for which two linear time learning algorithms exist. Given a sparse semantic similarity matrix $ \\S $, the goal of \\mbox{SPEC} hashing is to construct a new matrix $ \\W $, which is evaluated on the Hamming distance of the learned hash codes, to minimize the KL divergence between $ \\S $ and $ \\W $. Each hash function is a decision stump and the hash functions are learned in an incremental manner. Since computing the objective function value is quadratic to the number of objects, the authors proposed two approximated linear time algorithms to learn the hash functions.\n\nExperimental results show that this method is better than spectral hashing. However, it is apparently unclear whether or not \\mbox{SPEC} is better than its supervised or semi-supervised counterparts and whether or not its underlying assumption works well on general data sets. As such, more comparative studies are needed to validate its effectiveness.\n\n\\subsubsection{Minimal loss hashing} \n\nNorouzi \\etal~\\cite{norouzi2011icml} proposed a method called \\textit{minimal loss hashing} (\\mbox{MLH}) to learn hash functions from pairwise constraints. Intuitively speaking, \\mbox{MLH} wants similar training points to be mapped onto binary codes that differ by no more than $ \\rho $ bits, and dissimilar points to be mapped onto codes that differ by no less than $ \\rho $ bits. The objective is represented as follows,\n\\begin{align}\n\\mathcal{O}(\\w)  &=\\sum\\nolimits_{(\\x_{i},\\x_{j})\\in\\mathcal{S}}\\ell_\\rho(\\|\\y_i-\\y_j\\|_{H},S(i,j)),\\nonumber\n\\end{align}\nwhere $ \\mathcal{S} $ is the set of point pairs, $ \\y_i $ and $ \\y_j $ are codes of $ \\x_i $ and $ \\x_j $ respectively, $ S(i,j) $ is the label of the point pair $ (\\x_i, \\x_j) $, and \n\\begin{align}\n\\ell_{\\rho}(m,s) = \\left\\{ \\begin{array}{ll}\n\\max(m-\\rho+1,0) & \\mbox{if } s = 1\\\\\n\\max(\\lambda\\max(\\rho-m+1,0)) & \\mbox{if } s=0,\n\\end{array} \\right.\\nonumber\n\\end{align}\nwhere $ \\rho $ is a user provided hyperparameter that differentiates neighbors from non-neighbors in the Hamming space, and $ \\lambda $ is a loss-hyperparameter controlling the ratio of the slopes of the penalties.\n\nThough the objective is simple to understand, its formulation is discontinuous, non-convex and hence hard to optimize. To solve the optimization problem, the authors borrow the idea of structural \\mbox{SVM}~\\cite{tsochantaridis2004icml} and formulate a piecewise linear upper bound on the objective function. An alternating algorithm is developed to minimize the bound. Extensive experiments show that \\mbox{MLH} achieves a state-of-the-art performance. However, \\mbox{MLH} may still suffer from the local optimality problem.\n\n\\subsection{Summary}\n\n\nBesides existing settings, some more complex \\mbox{HFL} settings have also been explored recently, such as data with multiple similarities~\\cite{zhang2011sigir}, data of multiple modalities~\\cite{bronstein2010cvpr} and optimizing time and accuracy in a unified framework~\\cite{he2011cvpr}.\n\nThe major limitation of \\mbox{HFL} methods is that most of them involve a training procedure with complexity $ O(N^2) $ or $ O(D^2) $, meaning that the training data should not be very large. Although some subsampling approaches can be utilized to reduce the high computational cost, developing some cheaper learning methods is a future research issue very worthwhile studying.\n\n%\\chapter{Related Areas}\n%\\label{chap:relatedareas}\n%In spite of being a new research topic, hash function learning is closely related to many other research topics in the areas of machine learning, data mining and computer vision. In this chapter, we briefly review two closest research areas, i.e., metric learning and active learning.\n\n % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\\section{Metric Learning}\n\\label{background:metric}\nMetric learning is an important problem in the machine learning and pattern recognition communities. The objective is to learn an optimal metric, either linear or nonlinear, in the original feature space or the reproducing kernel Hilbert\nspace, from the training data. According to whether or not the label information or side-information is used to learn the metric, existing methods can be classified into unsupervised metric learning or supervised metric learning. In the following, we briefly review some typical works in each category. For a detailed review, we refer the interested readers to~\\cite{yang2006tech}.\n% the categories of \n\n\\subsection{Unsupervised Metric Learning}\nOne typical case of unsupervised metric learning is linear dimensionality reduction. The most classic methods are \\textit{principal component analysis} (\\mbox{PCA}) and \\textit{multidimensional scaling} (\\mbox{MDS}). While \\mbox{PCA} finds the subspace that best preserves the variance of the data, \\mbox{MDS} finds the projection that best preserves the pairwise distance. The two methods are equivalent when \\mbox{MDS} uses Euclidean distance. Despite being simple, efficient, and guaranteed to optimize their criteria, these linear methods could be very limited because they cannot find the nonlinear structure in the data.\n\nTo reveal the nonlinear structures of data, lots of nonlinear dimensionality reduction algorithms have been proposed. \\mbox{ISOMAP}~\\cite{tenenbaum2000science} assumes that isometric properties should be preserved in both the observation space and the intrinsic embedding space. According to this assumption, \\mbox{ISOMAP} finds the subspace that best preserves the geodesic inter-point distance. Unlike \\mbox{ISOMAP} that tries to preserve the geodesic distance for any pair of data points, \\textit{locally linear embedding} (\\mbox{LLE})~\\cite{Roweis2000science} and \\textit{Laplacian Eigenmap}~\\cite{belkin2003nc} focus on the preservation of the local neighbor structure. As an extension of~\\cite{belkin2003nc}, \\textit{locality preserving projection} (\\mbox{LPP})~\\cite{he2003nips} finds linear projective mappings that optimally preserve the neighborhood structure of the data. Mutual information which measures the difference between probability distributions has also been introduced to dimensionality reduction methods. Related work includes \\textit{stochastic neighbor embedding} (\\mbox{SNE})~\\cite{hinton2002nips} and \\textit{manifold charting}~\\cite{brand2002nips}.\n%It is an optimal linear approximation to the eigenfunctions of the Laplace-Beltrami Operator on the manifold.\n\n\\subsection{Supervised Metric Learning}\nSupervised metric learning algorithms are designed to learn either from the class labels or the side information which is often cast in the form of pairwise constraints (i.e., must-link constraints and cannot-link constraints). In~\\cite{xing2002nips}, Xing \\etal propose to learn a distance metric from the pairwise constraints. The optimal kernel is found to minimize the distance between data points in must-link constraints and simultaneously maximize the distance between data points in cannot-link constraints. \\textit{Relevance component analysis}~\\cite{shental2002eccv} is another popular approach, in which data points in the same classes are grouped in \\textit{chunklets}, and the distance metric is computed based on the covariance matrix estimated from each \\textit{chunklet}. Goldberger \\etal~\\cite{goldberger2004nips} develop an algorithm, abbreviated as \\textit{neighborhood component analysis}, which combines metric learning with $k$-nearest neighbor (KNN) classification. Globerson \\etal~\\cite{globerson2005nips} present an algorithm to collapse data samples in the same class into a single point and make samples belonging to different classes far apart. Recently, an information-theoretic based approach~\\cite{davis2007icml} developed by Davis \\etal has been reported to achieve a state-of-the-art performance.\n\nEmpirical studies show that supervised metric learning algorithms usually outperform the unsupervised ones. However, most of the supervised metric learning algorithms need to solve non-trivial optimization problems, and thus are computationally expensive.\n\n%particularly when the data are in large-scale and with high dimensionality.\n\n\n\\subsection{Relationship with \\mbox{HFL}}\nBoth metric learning and hash function learning try to learn a proper metric from data, but they are different in several aspects. First of all, the learned metric in hash function learning is Hamming distance while that of metric learning is usually the Euclidean distance. Secondly, hash function learning maps data into binary codes whereas metric learning often maps data into real vectors. Last but not least, hash function learning and metric learning have quite different applications. Hash function learning aims to speed up approximate similarity search, but metric learning is usually applied to classification and recognition applications. Therefore, hash function learning puts more focus on local similarity than conventional metric learning.\n\n%have quite different goals. Metric learning aims to learn a similarity metric while is the most propose for tasks at hand, while hash function learning targets at learn hash functions that can generate compact binary codes for similarity search. They are related since both of them defines a metric finally.\n\n % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\\section{Active Learning}\n\\label{background:active}\nAs a research topic originally developed by the machine learning community, active learning has been widely applied in many areas such as computer vision, data mining and information retrieval. The task of active learning is to select the most informative data for experts to label with the goal of reducing the labeling cost, which might be expensive in many tasks. Over the past few decades, a lot of algorithms have been proposed and gained great successes. \n\nThe major challenge of active learning is how to find the most informative data for specific applications effectively and efficiently. In the following, we briefly review some general criteria of data informativeness and corresponding well-known algorithms. The readers are encouraged to read~\\cite{Settles2009survey,tong2001thesis} for detailed reviews. Please also note that we use instance, example and data interchangeably in the sequel.\n\n\\subsection{Uncertainty-based Active Learning}\n\nPerhaps the simplest and the most commonly used approach is \\textit{uncertainty-based active learning} (\\mbox{UAL})~\\cite{lewis1994icml,Lewis1994sigir}. In this approach, the learner selects the instances whose labels it is the most uncertain about for the experts to label. This method is very straightforward for classifiers with probabilistic outputs. Take binary classification problems for example, when the basic learner could predict the labels in a probabilistic way, such as $P(y=+1\\mid \\x)=0.8$, \\mbox{UAL} will select the instance whose posterior probability of being positive (or negative) is nearest to $0.5$. However, this simple method will not be suitable in settings where there are more than two classes. A more general \\mbox{UAL} method selects the data points maximizing the \\textit{entropy} defined as follows:\n$$\\x^*=\\argmax\\nolimits_{\\x} H(\\y\\mid\\x)=\\argmax\\nolimits_{\\x} \\left( -\\sum\\nolimits_i P(y_i\\mid \\x,\\theta)\\log P(y_i\\mid \\x,\\theta)\\right),$$\nwhere $H(\\y\\mid\\x)=-\\sum_i P(y_i\\mid \\x,\\theta)\\log P(y_i\\mid \\x,\\theta)$ is called entropy which measures the uncertainty of label $\\y$ given instance $\\x$, $y_i$ ranges over all possible labels and $\\theta$ is the model parameter. The criterion of entropy can be easily generalized to probabilistic models for more complex structured instances, such as sequences~\\cite{Settles2008emnlp} and trees~\\cite{Hwa2004CL}.\n\nAn alternative to entropy-based \\mbox{UAL} is selecting the instance whose \\textit{most probable} label is the \\textit{least confident}, which can be formulated as follows:\n$$\\x^* = \\argmin\\nolimits_{\\x} P(y^*\\mid \\x,\\theta),$$\nwhere $y^* = \\argmax_{y}P(y\\mid \\x, \\theta)$ is the most probable class label of instance $\\x$. This method has been shown to work especially well for information extraction tasks~\\cite{Culotta2005aaai,Settles2008emnlp}.\n\nFor classifiers without probabilistic outputs, \\mbox{UAL} can also be applied if the outputs could be mapped to probabilities~\\cite{Lindenbaum2004mlj,Fujii1998CL}. Take margin-based classifiers such as \\mbox{SVM} for example, the certainty can be defined as the distance to the decision boundary~\\cite{Tong2002jmlr}.\n\nAnother general \\mbox{UAL} method is \\textit{query-by-committee} (\\mbox{QBC})~\\cite{Seung1992colt}. This approach maintains a group of classifiers, called a \\textit{committee}, which are trained on the current labeled data. Each committee member represents one classifier, and is allowed to vote on any unlabeled instances. The most uncertain data are those whose labels the committee members have the largest disagreement on. Intuitively, the \\mbox{QBC} strategy is to minimize the version space represented by the committee of classifiers.\n\nThe \\mbox{UAL} approaches are not immune to selecting outliers, which have high uncertainty but are not helpful to the learner when labeled and incorporated into the training set. Examples are provided in~\\cite{McCallum1998icml}.\n\n\\subsection{Representativeness-based Active Learning}\nAlthough effective and easy to implement in many applications, \\mbox{UAL} methods are always prone to querying outliers, which are useless, sometimes even harmful, for classifier training. To overcome this limitation, \\textit{representativeness-based active learning} (\\mbox{RAL}) has been proposed. The intuition of \\mbox{RAL} methods is that the most informative data should be the most representative of the unlabeled data.\n\nXu \\etal~\\cite{Xu2003ecir} might be the first to implement the above intuition for \\mbox{SVM} classifiers, using some simple heuristics. Instead of selecting the instances closest to the current \\mbox{SVM} hyperplane, they first cluster the points in the margin of the current model and then query the labels of the cluster centroid. ~\\cite{Nguyen2004icml} first clusters unlabeled instances and tries to avoid querying outliers by propagating label information from cluster centroid to instances in the same cluster. \n\nDensity-based active learning algorithms, which tend to select the instances from dense regions, could also be considered a special case of \\mbox{RAL}, because the denser the region is, the more representative the instances (located in the region) are. These \\mbox{RAL} approaches are always used in combination with \\mbox{UAL} methods~\\cite{Xu2007ecir,Settles2008emnlp}. In \\cite{Xu2007ecir}, data informativeness is measured by relevance, density and diversity in the relevance feedback tasks. Similarly,~\\cite{Settles2008emnlp} develops an information density framework for the sequence labeling task to measure the uncertainty and representativeness of instances.\n\nIn recent years, experimental design originated in statistics has been introduced as a new family of \\mbox{RAL} methods. The seminal work is \\textit{transductive experimental design}~\\cite{Yu2006icml}, which extends traditional experimental design methods to the transductive setting for active learning. Some subsequent work includes convex relaxation of the original problem~\\cite{Yu2008sigir}, and incorporation of \\textit{Laplacian} regularization~\\cite{he2007sigir} or label information~\\cite{zhen2010sigir}.\n\n\n\\subsection{Minimal Loss Active Learning}\n\nIn many real-world applications, the learned classifiers are eventually evaluated on a test set, so a better classifier should make less error on the test set. However, none of previous approaches directly optimize this objective, and this may explain why they do not work well in some circumstances. Intuitively, \\textit{minimal loss active learning} (\\mbox{MLAL}) aims to select the instances, when labeled and incorporated into the training set, leading to the largest error reduction on the test set. To evaluate the test error, we have to know the true labels of test instances. However, the true labels are unknown during the model training phase, as a result, the estimated (or expected) test error is used.\n\nCohn \\etal proposed a statistically optimal solution, which selects the training examples that result in the lowest error on future test examples~\\cite{cohn1996jair}. In their analysis, this goal could be achieved by minimizing the variance of training data. The authors developed two simple algorithms with closed form solutions for regression problems. For classification problems, Roy and McCallum used a sampling approach to estimate the expected error reduction~\\cite{Roy2001icml}. Later, this framework was combined with a supervised learning approach to give a dramatic improvement over conventional \\mbox{UAL} methods~\\cite{Zhu2003icmlws}.\n\n\\mbox{MLAL} has the advantages of being near-optimal and independent of the types of classifiers. However, it may be the most prohibitively expensive strategy, because it requires not only estimating the expected future error over the unlabeled data at each learning iteration, but also retraining the classifier for each possible label of the instance. To reduce the computational cost, some researchers have resorted to subsampling the unlabeled data~\\cite{Roy2001icml} or approximate training techniques~\\cite{guo2007ijcai}.\n\n\\subsection{Relationship with \\mbox{HFL}}\nActive learning and active hashing have in common that both of them aim to find the most informative data for experts to label. As such, the criteria of informativeness might be similar in active learning and active hashing. However, active learning is usually applied to classification, regression and ranking problems, which are very different from the approximate similarity search to which active hashing applies. This may lead to big differences in the definitions of informativeness, the formulations of optimization problems as well as the algorithms.\n\n\\section{Summary}\n\\label{background:sum}\nIn this chapter, we have reviewed hashing-based methods for similarity search, and two machine learning areas related to hash function learning. The central idea of hashing-based methods is to index data using binary codes which have the advantages of highly reduced storage cost and very fast computation speed. Different from locality sensitive hashing which is based on random projections or permutations, hash function learning aims to learn hash functions from data automatically, and thus, as we see later in more detail, has a close relationship with metric learning and active learning.\n\nIn the next chapter, we introduce the framework of active hashing which combines the concepts behind semi-supervised hash function learning and active learning to make \\mbox{HFL} more cost effective.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\subsection{Hashing for Compression}\n%\n%Besides speeding up nearest neighbor search, hashing-based methods has also been applied to data compression, which is of essential importance in many large-scale problems.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\subsubsection{Hash Kernel}\n%\n%%Shi \\etal~\\cite{shi2010cvpr} use hash functions to speed up face recognition.\n%\n%Shi \\etal~\\cite{shi2009aistats,weinberger2009icml} firstly introduce hashing into vector compression. The major idea is to hash variables (\\aka features) into a small number of bins such that linear kernels computed on the old and new feature spaces are guaranteed to be very close to each other .\n%\n%Given a feature mapping function $\\phi(\\x)$ and a hash function $h:\\mathcal{J}\\rightarrow \\{1,\\dots,M\\}$, where $\\mathcal{J}$ is the index set of feature dimension, a hash kernel can be defined as,\n%\\begin{align}\n%\\bar{k}(\\x,\\x') = \\langle\\bar{\\phi}(\\x),\\bar{\\phi}(\\x')\\rangle,\n%\\end{align}\n%where $\\bar{\\phi}_{j}(\\x) = \\sum_{i\\in\\mathcal{J};h(i)=j}\\phi_{i}(\\x)$.\n%\n%The expectation of hash kernel is\n%\\begin{align}\n%\\mathbb{E}_{h}[\\bar{k}^{h}(\\x,\\x')] = (1-\\frac{1}{N})k(\\x,\\x')+\\frac{1}{N}\\sum_{i,i'}\\phi_{i}(\\x)\\phi_{i}(\\x').\\nonumber\n%\\end{align}\n%And the variance of every entry of hash kernel is upper bounded by $O(\\frac{1}{N})$.\n%\n%\n%\\begin{theorem}\n%Assume that the probability of deviation between the hash kernel and its expected value is bounded by an exponential inequality via\n%\\begin{align}\n%p\\left(|\\bar{k}^{h}(\\x,\\x') - \\mathbb{E}_{h}[\\bar{k}^{h}(\\x,\\x')]|>\\epsilon\\right)\\le c \\exp(-c'\\epsilon^2 n),\\nonumber\n%\\end{align}\n%for some constants $c,c'$ depending on the size of the hash and the kernel used. In this case the error $\\epsilon$ arising from ensuring the above inequality for $m$ observations and $M$ classes (for a joint\n%feature map $\\phi(x, y)$ is bounded by (with $c'' = -\\log c - 2\\log 2$)\n%\\begin{align}\n%\\epsilon\\le\\sqrt{(2\\log(m+1)+2\\log(M+1)-\\log\\delta-c'')/c'}.\\nonumber\n%\\end{align}\n%\\end{theorem}\n%\n%Since above hash kernels are biased, an unbiased hash kernel has been proposed~\\cite{weinberger2009icml} and defined as follows,\n%\\begin{align}\n%\\bar{\\phi}_{j}(\\x) = \\sum_{i\\in\\mathcal{J};h(i)=j}\\phi_{i}(\\x)\\xi(i),\\nonumber\n%\\end{align}\n%where $\\xi$ is a hash function with image range $\\{\\pm1\\}$.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\subsubsection{HashCoFi}\n%In previous section, we have introduced an approach to compress vectors, while in this section, we introduce a similar method that compress matrices.\n%\n%In matrix factorization, which has been proved to be a powerful tool for collaborative filtering, the observations are viewed as a sparse matrix $\\Y$ where $Y_{ij}$ indicates the rating user $i$ gave to item $j$. Matrix factorization approaches then\n%approximate this matrix $\\Y$ with a dense matrix $\\F$ and this\n%approximation is modeled as a matrix product between\n%a matrix $\\U\\in\\mathbb{R}^{N\\times D}$ of user factors and a matrix $\\V\\in\\mathbb{R}^{M\\times D}$ of item factors so that $\\F = \\U\\V^T$.\n%\n%One of the key challenges is that storing $\\U$ and $\\V$ quickly becomes infeasible for increasing $N,M,D$. Thus we would like to find approximated compressed representations of $\\U$ and $\\V$ in the form of vectors $\\u$ and $\\v$ respectively.\n%\n%Let $h,h'$ denote two independent hash\n%functions with range $\\{1,\\dots, N\\}$ where $N$ denotes\n%the size of hash table. Moreover, denote by $\\sigma,\\sigma'$ two independent Rademacher functions with range $\\{\\pm1\\}$ with expected value 0 for any argument.\n%\n%The compressed representation $\\u$ and $\\v$ can be constructed as follows,\n%\\begin{align}\n%u_i&= \\sum_{(j,k):h(j,k)=i}U_{jk}\\sigma(j,k),\\nonumber\\\\\n%v_i&= \\sum_{(j,k):h'(j,k)=i}V_{jk}\\sigma'(j,k)\\nonumber.\n%\\end{align}\n%In another word, the entries in $\\U$ and $\\V$ are added randomly into $\\u$ and $\\v$ respectively. The basic assumption of this scheme is that only a small number of matrix entries are significant. We reconstruct $\\U$ and $\\V$ via\n%\\begin{align}\n%\\tilde{U}_{ij} = u_{h(i,j)}\\sigma(i,j),\\tilde{V}_{ij} = v_{h'(i,j)}\\sigma'(i,j).\\nonumber\n%\\end{align}\n%As a result,\n%\\begin{align}\n%\\tilde{F}_{ik} = \\sum_{j=1}^{D}u_{h(i,j)}v_{h'(k,j)}\\sigma(i,j)\\sigma'(k,j).\\nonumber\n%\\end{align}\n%\n%It can be proved that the reconstructed $\\U,\\V,\\F$ are in expectation accurate and the variance of $\\F$ is upper bounded by $O(\\frac{1}{N})$. The expectation and variance are \\wrt $\\sigma,\\sigma'$.\n%\n%Since it could be inefficient to store $\\u$ and $\\v$ separately, a joint compression scheme is proposed,\n%\\begin{align}\n%w_i = \\sum_{(a,b):h(a,b)=i}U_{ab}\\sigma(a,b)+\\sum_{(a,b):h'(a,b)=i}V_{ab}\\sigma'(a,b)\\nonumber,\n%\\end{align}\n%and the reconstruction is,\n%\\begin{align}\n%\\tilde{U}_{ij} &= w_{h(i,j)}\\sigma(i,j)\\nonumber\\\\\n%\\tilde{V}_{ij} &= w_{h'(i,j)}\\sigma'(i,j).\\nonumber\n%\\end{align}\n%\n%The expectation of $\\tilde{F}_{ij}$ has a small correction term and its variance still upper bounded by $O(\\frac{1}{N})$.\n%\n%Given the hash functions, we can learn $\\w$ using stochastic gradient descent method.\n%\n%The advantages of HashCoFi are:\n%\\begin{itemize}\n%  \\item Scales up to very large collaborative filtering problems, since the storage only depends on memory constraints.\n%  \\item The compression of factors is very effective when memory is very limited\n%\\end{itemize}\n%\n%The disadvantages of HashCoFi:\n%\\begin{itemize}\n%  \\item The hash functions, i.e., h, h¡¯, are data-independent, hence N could still be very large\n%  \\item Computational cost becomes larger due to the use of hashing\n%  \\item Performs worse than MF models when their D is large, with same memory constraints\n%      \\item Needs a number of repeats of sigma, sigma¡¯, to achieve good estimation\n%\\end{itemize}\n%\n\n", "meta": {"hexsha": "56fd3c95456f2420f37023044d0a6822b17c9515", "size": 60291, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_zhen/TexFile/2_background.tex", "max_stars_repo_name": "yzhen-li/paper", "max_stars_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis_zhen/TexFile/2_background.tex", "max_issues_repo_name": "yzhen-li/paper", "max_issues_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-19T06:22:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-19T07:15:40.000Z", "max_forks_repo_path": "thesis_zhen/TexFile/2_background.tex", "max_forks_repo_name": "zhenyisx/paper", "max_forks_repo_head_hexsha": "4043ea31f634669c46cc46318778e1a8317ca761", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 119.8628230616, "max_line_length": 1329, "alphanum_fraction": 0.7634638669, "num_tokens": 15867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.665410572017153, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4238870253477332}}
{"text": "\\section{Introduction}\n\\label{sec:introduction}\n\nAt the time of writing this paper, Covid-19 is a current and serious threat to humans, which has killed $4.860.014$ out of $224.989.641$ \\footnote{http://www.worldometers.info/coronavirus/} infected people around the globe. Given this, researchers have been assigned the duty of using intelligent ways to fight this illness. With access to patient data combined with considerable computing power, analysts and researchers can employ statistics, machine learning, and neural networks to find vital answers that can save people's lives.\n\nIn this paper, we propose and apply an experimental methodology to gain relevant knowledge in the understanding treatments and risk factors with Covid-19 illness. In particular, we investigate the population's age, gender, income, comorbidities, and any specific genome pattern predisposition to develop greater disease severity. Additionally, we analyze the efficacy of vaccination, its side effects, and the effectiveness of treatments to avoid death related to the Covid-19 illness. Finally, we will also discuss privacy issues that may arise with the data set.\n\nIn order to establish a \\textbf{\\textit{ground truth}} and determine that our model is appropriate to the task, we generate synthetic data-bases. This will allow us to understand what information we can reliably extract via our model, i.e., basic feature correlations, probabilities, and descriptive statistics. With these considerations, we will be able to formulate a more precise approach to the following exact tasks:\n\n\\label{Tasks and Questions}\n\\begin{itemize}\n    \\item[1a.] Questions:\n    \\begin{itemize}\n        \\item[i.] Can we predict death rate given age, gender, income, genes and comorbidities?\n        \\item[ii.] Which explanatory features are best to predict death?\n    \\label{task1}\n    \\end{itemize}\n    \n    \\item[1b.] Questions:\n    \\begin{itemize}\n        \\item[i.] Can we predict death rate (efficacy) of a vaccine?\n        \\item[ii.] Which vaccine is most effective?\n    \\end{itemize}\n    \n    \\item[1c.] Questions:\n    \\begin{itemize}\n        \\item[i.] Can we predict a specific symptom(s) (side-effect(s)) of a vaccine?\n        \\item[ii.] Which side-effect(s) each vaccine produce?\n    \\end{itemize}\n    \n    \\item[2.] Questions:\n    \\begin{itemize}\n        \\item[i.] Can we predict death rate given a specific treatment?\n        \\item[ii.] Which treatment is the most effective?\n        \\item[iii.] Can we predict a precise symptom(s) (side-effect(s)) given a specific treatment?\n        \\item[iv.] Which side-effect(s) does each treatment produce?\n    \\label{task2}\n    \\end{itemize}\n\\end{itemize}\n\nTo investigate each of these questions, we perform three automated methodologies. Our first methodology is to compute the autocorrelation matrix of the features of the data, in order to establish a high-level understanding of the data. The second approach is to evaluate the conditional probability of an outcome (e.g. $\\mathbf{P}(Symptom | Vaccine)$ or $\\mathbf{P}(Death | Vaccine)$). The third automated methodology is to model each question with a machine learning model, specifically \\emph{Logistic Regression}. To this end we develop a pipeline to train a logistic regression model on the data, starting again with a synthetic data set generated to establish the effectiveness of the model for modelling that question. Finally, we train a logistic regression model with cross-validation which then learns to predict an outcome based on input features.\n\n%We start by performing this calculation on the synthetic data to establish that our process correctly calculates the probability. Next, we calculate the conditional probabilities on the observational and treatment data to determine which features affect the outcomes. We note that this calculation does \\emph{not} model joint probability distributions, because the number of features makes it infeasible to model all combinations of them.\n\n", "meta": {"hexsha": "fb82d54bc2a9cda7747dd45ca7e0a4522c4aa435", "size": 3976, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "project1/report/content/introduction.tex", "max_stars_repo_name": "fabiorodp/IN_STK5000_Adaptive_methods_for_data_based_decision_making", "max_stars_repo_head_hexsha": "f8c049ceed6e3123e8676bcd9b29afaba9bd1f9b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "project1/report/content/introduction.tex", "max_issues_repo_name": "fabiorodp/IN_STK5000_Adaptive_methods_for_data_based_decision_making", "max_issues_repo_head_hexsha": "f8c049ceed6e3123e8676bcd9b29afaba9bd1f9b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project1/report/content/introduction.tex", "max_forks_repo_name": "fabiorodp/IN_STK5000_Adaptive_methods_for_data_based_decision_making", "max_forks_repo_head_hexsha": "f8c049ceed6e3123e8676bcd9b29afaba9bd1f9b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-25T14:45:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-25T14:45:41.000Z", "avg_line_length": 88.3555555556, "max_line_length": 856, "alphanum_fraction": 0.7650905433, "num_tokens": 852, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.42388702112092597}}
{"text": "\\section[Description of Statistics]{Description of Statistics Used in this Report}\nThis report provides a concise statistical summary of BMP performance data\ncontained in the International Stormwater BMP Database.  The analysis focuses\non the distribution of effluent water quality from individual events by BMP\ncategory, thereby providing greater weight to those BMPs for which there are a\nlarger number of data points reported. In other words, the performance analysis\npresented in this technical summary is ``storm-weighted'', as opposed to\n``BMP weighted''\\footnotemark[1].\n\nThe statistical summaries have been organized by BMP and then by constituent.\nFor each data set, influent and effluent summary statistics are presented in a\ntable followed by graphical summaries.\n\n\\subsection{Tabular Summaries}\nThe summary tables include both parametric and non-parametric statistics.\nParametric statistics operate under the assumption that data arise from a\nsingle statistical distribution that can be described mathematically using\ncoefficients, or parameters, of that distribution.  The mean and standard\ndeviation are example parameters of the normal, or Gaussian, distribution.\nNon-parametric statistics are fundamentally based on the ranks\\footnotemark[2]\nof the data with no need to assume an underlying distribution.  Non-parametric\nstatistics do not depend on the magnitude of the data and are therefore\nresistant to the occurrence of a few extreme values (i.e., high or low values\nrelative to other data points do not significantly alter the statistic)\n\\footnotemark[3].\n\nTable ~\\ref{tab:StatList} summarizes the parametric and non-parametric\nstatistics commonly used to describe data sets. Definitions for each summary\nstatistic included in the tables are provided in Table ~\\ref{tab:StatDescr}.\n\n\\begin{table}[b!ht]\n    \\caption{Example Common Parametric and Non-Parametric Descriptive Statistics}\n    \\label{tab:StatList}\n    \\centering\n    \\begin{tabular}{p{1.5in} p{1.5in} p{1.5in}}\n    \\toprule\n    \\textbf{Statistic Category} & \\textbf{Parametric} & \\textbf{Non-Parametric} \\\\\n    \\toprule\n    Measures of Location & Mean & Median \\\\\n    \\midrule\n    Measures of Spread & Variance, Standard Deviation & Interquartile Range, Median Absolute Deviation \\\\\n    \\midrule\n    Measures of Skew & Coefficient of Skewness & Quartile Skew Coefficient \\\\\n    \\bottomrule\n    \\end{tabular}\n\\end{table}\n\n\\footnotetext[1]{\n    There are several viable approaches to evaluating the BMP Database.  Two\n    general approaches that have been presented in the past (Geosyntec and WWE\n    2008) are the ``BMP-weighted'' and ``storm-weighted'' approaches. The\n    BMP-weighted approach represents each BMP with one value representing the\n    central tendency of the BMP study, whereas the storm-weighted approach\n    combines all of the storm events for the BMPs in each category and analyzes\n    the overall storm-based data set. The storm-weighted approach has been\n    selected for this report.\n}\n\n\\footnotetext[2]{\n    In this context, ranks refer to the positions of the data after being\n    sorted by magnitude.\n}\n\n\n\\footnotetext[3]{\n    Helsel, D.R. and R. M. Hirsch, 2002. Statistical Methods in Water\n    Resources Techniques of Water Resources Investigations, Book 4, Chapter A3.\n    U.S. Geological Survey. 522 pages.\n    \\url{http://pubs.usgs.gov/twri/twri4a3/}\n    }\n\n\\subsection{Graphical Summaries}\nIn addition to the summary tables provided for each BMP/constituent\ncombination, influent/effluent box plots and non-exceedance probability\nplots are provided. Box plots (or box and whisker plots) provide a schematic\nrepresentation of the central tendency and spread of the influent and effluent\ndata sets. Box plots can also be used to indicate whether the influent median\nis statistically different than the effluent median. A key for the box plots\nis provided in Figure ~\\ref{fig:bpLeg}.\n\nProbability plots illustrate the empirical distribution of the data.  A\ncomparison of the influent and effluent probability plots indicates whether\nthere may be differences among all percentiles (not just the median) and\nwhether the influent and effluent data sets are similarly distributed.\nProbability plots also provide a quick method of identifying the probability\nthat an individual sample would be less than or equal to a particular value.\nFor example, the effluent probability plot may be used to identify the\nprobability that a particular water quality threshold would be met (e.g., 40\\%\nchance that effluent concentration would be less than or equal to 1 mg/L). It\nshould be noted, however, that there is not a one-to-one correlation between\nthe percentiles in the influent data and the percentiles in the effluent data.\nFor example, the median influent concentration and the median effluent\nconcentrations may not occur in the EMC samples collected during the same\nstorm. Although the influent and effluent concentrations in a probability plot\nare not paired values, the relative position and slope of the two populations\nare a good indication of the effectiveness of the BMP. When generating the\nprobability plots, the detection limits were used for non-detect values (i.e.,\nROS estimates or half the DL were not used).  Non-detects are depicted as\ntriangles pointing down for influent data and pointing up for effluent data.\n\nInfluent vs. effluent scatterplots depict paired data to provide an indication\nof how effluent concentrations may be related to the influent concentrations.\nData points below the 45 degree line indicate removals whereas data points\nabove the 45 degree line indicate increases.  Detection limits are shown for\nnon-detect values. If both the influent and effluent are non-detect, then a\ndiamond symbol is used.  If only the effluent is non-detect then a triangle\nsymbol pointing up is used.  If only the influent is non-detect, then a\ntriangle symbol pointing down is used.\n\n\\begin{longtable}[pt]{p{1.5in} p{4in}}\n    \\caption{Common Parametric and Non-Parametric Descriptive Statistics}\n    \\label{tab:StatDescr} \\\\\n\n    % header for first page of table\n    \\toprule\n    \\multicolumn{1}{c}{\\textbf{Statistic}} &\n    \\multicolumn{1}{c}{\\textbf{Definition/Description}} \\\\\n    \\toprule\n    \\endfirsthead\n\n    % header for all subsequent pages of table\n    \\multicolumn{2}{c}{{\n        \\tablename\\ \\thetable{} -- continued from previous page\n    }} \\\\\n\n    \\toprule\n    \\multicolumn{1}{c}{\\textbf{Statistic}} &\n    \\multicolumn{1}{c}{\\textbf{Definition/Description}} \\\\\n    \\toprule\n    \\endhead\n\n    % footer for 1st thru (n-1)th page of table\n    \\multicolumn{2}{r}{{Continued on next page}} \\\\\n    \\endfoot\n\n    % footer for last (nth) page of table\n    \\bottomrule\n    \\endlastfoot\n\n    Count & Total number of data points analyzed.  Most BMP data sets include\n    only event mean concentrations (EMCs).  The exception includes BMPs with\n    permanent pools (retention ponds and wetland basins) where grab samples\n    were also included.  \\\\\n\n    \\midrule\n    Number of Non-detects & The number of censored values that were reported\n    below the analytical detection limits. Laboratory estimated values (i.e.,\n    ``J'' values) were treated as detected values. The plotting position, or\n    regression-on-order statistics (ROS), method described in Helsel and Cohn\n    (1988)\\footnotemark[4] was used to estimate censored values using the\n    distribution of uncensored values for each study.   \\\\\n\n    \\midrule\n    Mean (95\\% conf. interval) & The mean of the data points and the 95\\%\n    confidence interval (CI) about the mean.  Provides a parametric measure of\n    the central tendency. The confidence interval was computed using the\n    bias-corrected and accelerated (BCa) bootstrap method described by\n    Efron and Tibishirani (1993)\\footnotemark[5].\\\\\n\n    \\midrule\n    Std. Dev. & The standard deviation of the data points. \\\\\n\n    \\midrule\n    Coeff. of Variation & The ratio of the standard deviation to the absolute\n    value of the mean. \\\\\n\n    \\midrule\n    Skewness & The coefficient of skewness of the data points.  \\\\\n\n    \\midrule\n    Median (95\\% conf. interval)  & The median of the data points and the 95\\%\n    confidence interval (CI) about the median. The confidence interval was\n    computed using the bias corrected and accelerated (BCa) bootstrap method\n    described by Efron and Tibishirani (1993)\\footnotemark[5].   \\\\\n\n    \\midrule\n    $25^{\\mathrm{th}}$ and $75{\\mathrm{th}}$ percentiles & The difference\n    between the 25th and 75th percentiles is the inter-quartile range, which is\n    a non-parametric measure of the spread of the data.  \\\\\n\n    \\midrule\n    Number of paired data & The number of storm events where influent and\n    effluent samples were simultaneously collected.\\\\\n\n    \\midrule\n    Wilcoxon p-value & The statistical significance value for the signed-rank\n    test, which is based on the alternative hypothesis that the median of the\n    paired influent/effluent differences is not equal to zero.  This\n    non-parametric test applies only to paired data sets and is performed on\n    log-transformed data (base 10) to improve the symmetry of the distribution\n    of the differences between the data pairs.  A p-value less than 0.05\n    indicates that the influent and effluent concentrations are statistically\n    significantly different at the 95\\% confidence level. \\\\\n\n    \\midrule\n    Mann-Whitney p-value & The statistical significance value for the rank-sum\n    test, which is based on the alternative hypothesis that the influent and\n    effluent medians differ. This non-parametric test applies to two\n    independent data sets.  A p-value less than 0.05 indicates that the\n    influent and effluent median concentrations are statistically significantly\n    different at the 95\\% confidence level.\\\\\n\n    % \\midrule\n    % p-values, detects (normal, log-normal) & Shapiro-Wilk goodness-of-fit\n    % p-values for testing the null hypothesis that the data (or log of the data)\n    % arise from the normal distribution.  A p-value greater than 0.05 indicates\n    % the null hypothesis cannot be rejected at the 95\\% confidence level.\n    % A p-value less than 0.05 indicates the null hypothesis can be rejected at\n    % the 95\\% confidence level.  The test was only applied to the detected\n    % values in their original units as well as the log of the values.  The\n    % former tests whether the data arise from normal distribution whereas the\n    % latter tests whether the data arise from the log-normal distribution. \\\\\n\\end{longtable}\n\n\\footnotetext[4]{\n    Helsel, D.R. and T. A. Cohn (1988).  ``Estimation of descriptive statistics\n    for multiply censored water quality data'', \\textit{Wat. Resour. Res.}\n    24, 1997-2004.\n}\n\n\\footnotetext[5]{\n    Efron, B. and R. Tibishirani (1993). \\textit{An Introduction to the\n    Bootstrap}. Chapman \\& Hall, New York.\n}\n\n\n\\begin{figure}[t!]\n    \\centering\n    \\includegraphics[scale=1.25]{figures/boxplotlegend.pdf}\n    \\caption{Graphical explanation of box and whisker plots}\n    \\label{fig:bpLeg}\n\\end{figure}\n\\clearpage\n\n", "meta": {"hexsha": "e645f92c6353991beaec6981766530cc994f7cad", "size": 11071, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pybmpdb/tex/chapter1.tex", "max_stars_repo_name": "phobson/pybmpdb", "max_stars_repo_head_hexsha": "78636fccc98535174eace88407f0bc5629157b0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pybmpdb/tex/chapter1.tex", "max_issues_repo_name": "phobson/pybmpdb", "max_issues_repo_head_hexsha": "78636fccc98535174eace88407f0bc5629157b0b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 33, "max_issues_repo_issues_event_min_datetime": "2016-06-02T00:13:30.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-03T21:03:39.000Z", "max_forks_repo_path": "pybmpdb/tex/chapter1.tex", "max_forks_repo_name": "phobson/pybmpdb", "max_forks_repo_head_hexsha": "78636fccc98535174eace88407f0bc5629157b0b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-09-09T15:51:54.000Z", "max_forks_repo_forks_event_max_datetime": "2015-09-09T15:51:54.000Z", "avg_line_length": 47.1106382979, "max_line_length": 105, "alphanum_fraction": 0.7553969831, "num_tokens": 2719, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.42388701617708546}}
{"text": "\\ifpdf\n\\graphicspath{{Chapter3/Figs/}}\n\\else\n\\graphicspath{{Chapter3/Figs/}}\n\\fi\n\n\\chapter{Analysis of Zerocoin}\n\\label{ch:Analysis of Zerocoin}\nThis chapter delves into the data structures and algorithms of Zerocoin and analyses the reasons behind some of its key weaknesses. A basic understanding of Zerocoin and the issues of privacy detailed in Chapter \\ref{ch:Privacy in Bitcoin} and \\ref{ch:Methods to Improve Privacy in Digital Currencies} are needed to appreciate the rest of this chapter. Unless otherwise stated, all technical information on Zerocoin is obtained from the original Zerocoin paper \\cite{Miers2013}.\n\n\\section{Construction of Zerocoin}\n\\subsection{Coin as a Pederson Commitment}\n\\label{sec:3-Coin as a Pederson Commitment}\nThe key element in Zerocoin is the \\kwCoin{} that is minted and redeemed in Mint and \\kwTransaction{Spend }{s}. A \\kwCoin{} $c$ is a Pedersen commitment \\cite{Pedersen1992} of a serial number $S\\in\\expIntGroup{\\varQComm}$ and a random trapdoor $r\\in\\expIntGroup{\\varQComm}$ in the form $c=\\expPedCommCoin\\bmod{\\varPComm}$. $\\varPComm$ and $\\varQComm$ are large primes and $\\varGComm$ and $\\varHComm$ are generators of the sub-group of $\\expIntGroup{\\varQComm}$ multiplicative group $\\expMulGroup{\\varPComm}$. That is to say $\\varGComm^0,\\varGComm^1,...,\\varGComm^{\\varQComm}\\bmod{\\varPComm}$ and $\\varHComm^0,\\varHComm^1,...,\\varHComm^{\\varQComm}\\bmod{\\varPComm}$ produce two sequences of distinct numbers. To satisfy this property, $\\varGComm^{\\varQComm} \\bmod{\\varPComm}=1$ and $\\varHComm^{\\varQComm} \\bmod{\\varPComm}=1$ and thus $\\varQComm$ divides $\\varPComm-1$ by Fermat’s Little Theorem. In Zerocoin, $\\varPComm$ and $\\varQComm$ are prime numbers of 1024 and 256 bits respectively \\footnote{Based on the security recommendations in Section VI(B) of the Zerocoin paper \\cite{Miers2013}.}, and $\\varGComm$ and $\\varHComm$ are computed based using the algorithm defined in the Federal Information Processing Standards (FIPS) 186-34 \\cite{InformationTechnologyLaboratory2009}. For simplicity of presentation, the Pedersen commitment will be written as $c=\\expPedCommCoin$, where modulus $\\varPComm$ is implied for generators $\\varGComm$ and $\\varHComm$. \n\nIn Zerocoin, a single set of $\\varGComm,\\varHComm,\\varPComm,\\varQComm$ is generated once as public parameters during set up, and is subsequently used by all users. To mint a \\kwCoin{}, a user generates a random serial number $S\\in\\expIntGroup{\\varQComm}$ and another random trapdoor $r\\in\\expIntGroup{\\varQComm}$, computes a Pedersen commitment $c=\\expPedCommCoin$ and include $c$ in the \\kwTransaction{Mint }{}. $S$ is kept secret when the \\kwTransaction{Mint }{} is created and is subsequently revealed in the \\kwTransaction{Spend }{} to prove the ownership of $c$ (\\S\\ref{sec:3-Serial Number Signature of Knowledge}), while $r$ is always secret to the creator of the \\kwTransaction{Mint }{}. \n\nAfter the \\kwTransaction{Mint }{} is verified and published on the Blockchain, everyone can see that the creator of the transaction has minted $c$. Theoretically, an adversary can “steal” a \\kwCoin{} by obtaining $S$ and $r$ from the public $c$ and creating a valid \\kwTransaction{Spend }{} using $S$ and $r$. However the adversary can only succeed with negligible probability in practice as solving $S$ and $r$ from a known $c$ where $c=\\expPedCommCoin$ is believed to be hard under the Discrete Logarithm assumption \\cite{Paar2010}. Due to this property, it is also hard to solve $c$ from $S$ without the knowledge of $r$. Since $r$ is secret to the owner of the \\kwCoin{} at all times, an adversary is also unable to attribute the $S$ in the \\kwTransaction{Spend }{s} to a $c$ in the \\kwTransaction{Mint }{s} on the Blockchain. This preserves the anonymity property that the redeemer (payee) of a \\kwCoin{} cannot be linked to its creator (payer).\n\n\\subsection{Public Accumulator}\n\\label{sec:3-Public Accumulator}\nAn accumulator “summarises” a large number of values into one value, and given a short witness a specific value can be proven to be accumulated in the accumulator. The accumulator in Zerocoin is a public data structure that contains every minted \\kwCoin{} in history. As such, given a witness any nodes in the peer-to-peer network can verify that a \\kwCoin{} has been minted using the accumulator. The size of the accumulator remains constant as more \\kwCoin{s} are accumulated, thus it can be distributed and stored efficiently by the peer-to-peer network. The accumulator used in Zerocoin is a dynamic accumulator proposed by Camenisch and Lysyanskaya \\cite{JanCamenisch12002} that extends the study by Baric and Pfitzmann \\cite{BariC1997}. The 3 main functions provided by this accumulator scheme are explained below. \n\n$\\eqnAccum{u}{C}$ accumulates a set of \\kwCoin{s} $C=\\lbrace \\expOneToN{c}{n} \\mid c_i \\in [A,B] \\wedge c_i \\: is \\: prime \\rbrace$ using parameters $(N,u)$ to produce an accumulator $A=u^{\\expOneToN{c}{n}}\\bmod{N}$. Like the parameters used in the Pedersen commitment for \\kwCoin{s} (\\S\\ref{sec:3-Coin as a Pederson Commitment}), $(N,u)$ are public parameters that are generated once during set up. $N$ is a product of 2 large primes while $u$ is a quadratic residue modulo $N$ \\footnote{A quadratic residue modulo N is the square of any integer modulo N.}. $N$ is recommended is to be 3072 bits long \\footnote{Based on the security recommendations in Section VI(B) of the Zerocoin paper \\cite{Miers2013}.}. $\\mathfrak{A}$ and $\\mathfrak{B}$ \\footnote{$\\expAFrak,\\expBFrak$. $k'$ and $k''$ are set at 160 and 128 respectively. The reasons behind these values can be found in \\cite{Miers2013} and \\cite{JanCamenisch12002}.} defines the range of the values that an accumulated \\kwCoin{} $c$ can take. In addition, $c$ must be prime before it can be accumulated. Hence when minting a new \\kwCoin{}, different $S$ and $r$ must be tried until $c=\\expPedCommCoin$ satisfies the above constraints. \n\nEvery time a new \\kwCoin{} is successfully minted, nodes will accumulate the new \\kwCoin{} into the public accumulator. Due to the construction of the dynamic accumulator, a new \\kwCoin{} $c_{new}$ can be incrementally accumulated \\cite{JanCamenisch12002} into the previous accumulator $A$ using $\\eqnAccum{A}{\\{c_{new}\\}}$. Thus when updating the accumulator, one do not need to recompute $u^{\\expOneToN{c}{n}c_{new}}\\bmod{N}$ but simply compute $A^{c_{new}}\\bmod{N}$ using the latest $A$, making accumulation efficient. Zerocoin proposes that each \\kwBlock{} contains an accumulator called the accumulator checkpoint that contains all the \\kwCoin{s} minted up till that \\kwBlock{}. This way nodes do not need to compute the accumulator from scratch, and can choose an accumulator checkpoint from any \\kwBlock{} and incrementally accumulate the \\kwCoin{s} minted after that \\kwBlock{} to obtain the latest accumulator value.\n\nFor a \\kwCoin{} $c\\in C$, $\\eqnGenWit{c}{w}$ produces a witness $w=\\eqnAccum{u}{C\\setminus\\{c\\}}$. That is, $is$ an accumulation of all the \\kwCoin{s} in $C$ except $c$. In Zerocoin, $C$ is the set of all minted \\kwCoin{s} in history. With $w$, one can verify that that $c$ is in $C$ using $\\eqnAccVer{c}$, where $A=\\eqnAccum{u}{C}$. $AccVerify$ returns 1 if and only if $A=w^{c}\\bmod{N}$ and $c$ is a valid \\kwCoin{} ($c$ is prime and $c\\in[\\mathfrak{A},\\mathfrak{B}]$). It can be seen that $A=w^{c}\\bmod{N}$ is the correct verification equation as $A=\\eqnAccum{u}{C}=u^{\\expOneToN{c}{n}c}\\bmod{N}=(u^{\\expOneToN{c}{n}})^c\\bmod{N}=w^{c}\\bmod{N}$. To ensure security, $A$ should be independently computed by each verifier, which can be achieved efficiently using the incremental method described in the previous paragraph.\n\nIn Zerocoin, $GenWitness$ is used by the creator of a \\kwTransaction{Spend }{} to create a witness to prove that the redeemed \\kwCoin{} is in the accumulator. $AccVerify$ is used by nodes in the Zerocoin network to verify that claim when validating the \\kwTransaction{Spend }{}. However $AccVerify$ is used only in principle and not directly, because $w$ and $c$ are not revealed to the verifier in a \\kwTransaction{Spend }{} in order to keep $c$ unkown. Why and how the \\kwTransaction{Spend }{} is verified without the knowledge of $w$ and $c$ is discussed in \\S\\ref{sec:3-Accumulator Proof of Knowledge}.\n\n\\subsection{Non-Interactive Zero Knowledge (NIZK) Proofs}\n\\label{sec:3-Non-Interactive Zero Knowledge (NIZK) Proofs}\n\\subsubsection{Interactive Zero Knowledge Proofs}\n\\label{sec:3-Interactive Zero Knowledge Proofs}\nZerocoin relies heavily on NIZK proofs, which are a subset of zero-knowledge (ZK) proofs. ZK proof is a proof of the knowledge of an element without disclosing any information beyond the legitimacy of the proof \\cite{Kiayias} The formal notation of ZK proof introduced by Camenisch and Stadler \\cite{Camenisch1997a} is as follow:\n\n$$ZKPoK\\{(w):statement\\ proving\\ knowledge\\ of\\ w\\}$$\n\n$ZKPoK$ refers to Zero-Knowledge Proof of Knowledge. The proof statement is enclosed in the curly brackets. The element in parenthesis is the information that the prover wishes to show knowledge of, but cannot be disclosed. This notation will be used for all zero knowledge proofs in this paper. \n\nZK proofs often surrounds an NP-hard problem. In general, a prover wants to prove that he has a secret solution $w$ to the NP-hard problem $y$. The prover first sends a random problem $t$ that has a solution $v$ that is unrelated to $w$. The verifier then sends a random challenge $\\varChallenge$ to the prover, and the prover replies with a response $s$ that looks random but in fact is a combination of $v$, $w$ and $\\varChallenge$. The verifier verifies the proof by composing $s$ with $\\varChallenge$ and the original problem $y$. $s$ is constructed in a way such that if the prover knows $w$, it will cancel out $y$, leaving behind only the random problem $t$. Hence by checking that the result of the proof is $t$ the verifier is able to verify the proof, but does not learn anything about $w$ since all he sees are random values. The above is a form of interactive ZK proof which involves the verifier communicating the challenge $\\varChallenge$ to the prover. A simple example of an interactive ZK proof for the knowledge of discrete logarithm can be found online \\cite{Unknown2016}. This proof is chosen as an example as it is closely related to the proofs used in the Zerocoin protocol.\n\n\\subsubsection{Transforming Interactive Zero Knowledge Proofs to NIZK Proofs}\n\\label{sec:3-Transforming Interactive Zero Knowledge Proofs to NIZK Proofs}\nNIZK proof is a special kind of ZK proof that removes the need for the verifier to interact with the prover. The prover can achieve this by a generating a challenge $\\varChallenge$ from $y$ and $t$ using a random oracle \\footnote{A theoretical black box that responds to every unique query with a truly random response chosen uniformly from its output domain. If a query is repeated it responds the same way every time that query is submitted. \\cite{Unknown2016a}}, and treat this $\\varChallenge$ as the challenge that the verifier sends in the interactive version the ZK proof. The prover then computes $s$ based on the generated $\\varChallenge$ and sends the proof containing $y$, $t$ and $s$ to the verifier. Upon receiving the proof, the verifier recomputes $\\varChallenge$ from the received $y$ and $t$ using the random oracle, and verifies the proof in the same way as the interactive version of the ZK proof. Since there is no interaction between the prover and the verifier, the NIZK is achieved. \n\nThe Fiat-Shamir heuristics \\cite{Fiat1987} is a popular technique to transform interactive ZK proofs into NIZK proofs. Using the Fiat-Shamir heuristics, the random oracle is implemented as a cryptographic hash function \\cite{Bellare1993}, and $\\varChallenge$ is obtained by hashing $y$ and $t$ together with and other parameters. The NIZK proofs used in Zerocoin and the proofs proposed by this research all use the Fiat-Shamir heuristics in one way or another. The same online resource that illustrates interactive ZK proof for the knowledge of discrete logarithm also shows how the proof can be modified into a NIZK form using the Fiat-Shamir heuristics \\cite{Unknown2016}. \n\n\\subsubsection{Properties of Zero-Knowledge Proofs}\n\\label{sec:3-Properties of Zero-Knowledge Proofs}\nAll ZK proofs (NIZK proofs included) need to fulfil the below properties \\cite{Kiayias}:\n\\begin{enumerate}\n\t\\item \\textbf{\\textit{Completeness}}: If the prover indeed knows the secret $w$, and both the prover and verifier follow the procedures of the proof, then the proof will always be verified.\n\t\\item \\textbf{\\textit{Soundness}}: If the prover does not know the secret $w$, and both the prover and verifier follow the procedures of the proof, then the proof will not be verified. This property can be proven if a hypothetical program called the knowledge extractor that can extract $w$ from the prover using two accepting proofs that uses the same $t$ but different $\\varChallenge$ and $s$. In order to do this, the knowledge extractor has access to the prover’s program (but not the $w$ itself) and can “rewind” the proof to obtain another set of $\\varChallenge$ and $s$. The success of the knowledge extractor is needed to prove for soundness because if a prover who does not know $w$ manages to prove the knowledge of $w$, there is no way that a knowledge extractor can extract a $w$ that is non-existent in the proof.\n\t\\item \\textbf{\\textit{Statistical Zero-Knowledge}}: The verifier does not gain any knowledge after interacting with the prover. This can be proven if a hypothetical program called a simulator with no knowledge of the secret $w$, is able to generate a response $s'$ to the challenge $\\varChallenge$, such that $s'$ is statistically indistinguishable from the actual response $s$ generated by the prover. In this way the verifier does not learn anything more from the $s$ sent by the prover than from the $s$ sent by the simulator.\n\\end{enumerate}\n\n\\subsubsection{NIZK Proofs in Zerocoin}\n\\label{sec:3-NIZK Proofs in Zerocoin}\nNIZK proofs are used in Zerocoin to prove the ownership of a valid unredeemed \\kwCoin{} in a \\kwTransaction{Spend }{}. The proof needs to be zero-knowledge so that the verifier or anyone who sees the \\kwTransaction{Spend }{} does not know which \\kwCoin{} is being spent. The proof also needs to be non-interactive because a \\kwTransaction{Spend }{} can be verified by any node in the Zerocoin network at any time, and it is not possible for a verifier to interact with the creator of the transaction. The three NIZK proofs in a \\kwTransaction{Spend }{} are:\n\n\\begin{enumerate}\n\t\\item \\textbf{\\textit{Accumulator Proof of Knowledge (AccPoK)}}: Proves that a \\kwCoin{} $c$ has been minted, without disclosing $c$. This is achieved by proving that $c$ is contained in the public accumulator in which every \\kwCoin{} that has been minted should have been included in. Details of this proof is discussed in \\S\\ref{sec:3-Accumulator Proof of Knowledge}.\n\t\\item \\textbf{\\textit{Serial Number Signature Proof of Knowledge (SNSoK)}}: Proves the knowledge of the serial number $S$ and the secret trapdoor $r$ that are committed in the redeemed \\kwCoin{} $c$, without disclosing $r$ and $c$. Since only the owner of a \\kwCoin{} knows its $S$ and $r$, this proof shows that the prover owns the \\kwCoin{} being proven for. This proof also acts as a digital signature for the \\kwTransaction{Spend }{}. A digital signature is needed to prevent the contents of the \\kwTransaction{Spend }{}, which contains the public key address that the redeemed \\kwCoin{} should be paid to, from being tampered with. Details of this proof is discussed in \\S\\ref{sec:3-Serial Number Signature of Knowledge}. \n\t\\item \\textbf{\\textit{Commitment Proof of Knowledge (CommPoK)}}: Proves that the \\kwCoin{} being proven for in the accumulator Proof of Knowledge and the \\kwCoin{} being proven for in the Serial Number Signature of Knowledge are the same \\kwCoin{}. This ensures the \\kwCoin{} which the prover is proving to be minted is the same \\kwCoin{} that he is proving ownership for. With this proof, one cannot redeem a minted \\kwCoin{} that he does not own. Details of this proof is discussed in \\S\\ref{sec:3-Commitment Proof of Knowledge}. \n\\end{enumerate}\n\n\\subsubsection{Accumulator Proof of Knowledge}\n\\label{sec:3-Accumulator Proof of Knowledge}\nFor a \\kwCoin{} to be spent, it must first be proven that the \\kwCoin{} has been minted. The Accumulator Proof of Knowledge (AccPoK) proves this claim using the public accumulator which contains all the minted \\kwCoin{s} in history.\n\nAs seen in \\S\\ref{sec:3-Public Accumulator}, the claim that a \\kwCoin{} $c$ is in the set of minted \\kwCoin{s} can be verified by presenting $AccVerify$ with the witness $w$. However this cannot be done directly in Zerocoin as $c$ needs to be secret in order to preserve unlinkability between the minter and the redeemer of $c$. In addition, $w$ also needs to be secret as it can be used to obtain $c$. This is possible because all the minted \\kwCoin{s} in history are publicly available in the \\kwTransaction{Mint }{s} on the Blockchain. An adversary can run $\\eqnGenWit{c'}{w'}$ repeatedly using all $c'\\in C$, where $C$ is all the minted \\kwCoin{s} in history, and the $c'$ that produced a $w=w'$ is the \\kwCoin{} that is being proven for. Hence to hide $c$ and $w$, the AccPoK is as such:\n\n$$\\eqnAccPoK$$\n\nThe implementation of the AccPoK is adapted from an interactive version of the proof by Camenisch and Lysyanskaya \\cite{JanCamenisch12002} and modified to a non-interactive form using the Fiat-Shamir heuristics. The rest of the section describes the implementation details. \n\nIn order to hide $c$ and $w$, the prover creates the following commitments of $c$ and $w$ using random trapdoors:\n\n\\begin{enumerate}\n\t\\item $\\varAccPoKCoinComm$, a commitment of $c$ with a random trapdoor $ \\varphi\\in\\expIntGroup{\\lfloor N/4 \\rfloor}$ such that $\\varAccPoKCoinComm=\\varAccPoKGComm^{c}\\varAccPoKHComm^{\\varphi}\\bmod{\\varAccPoKPComm}$. $\\varAccPoKGComm$ and $\\varAccPoKHComm$ are generators for sub-group $\\expIntGroup{\\varAccPoKQComm}$ of multiplicative group $\\expIntGroup{\\varAccPoKPComm}^{*}$, where $\\varAccPoKQComm >2\\mathfrak{B}$.\n\t\\item $\\varAccPoKProofComm{c}$, another commitment of $c$ with a random trapdoor $ \\eta\\in\\expIntGroup{\\lfloor N/4 \\rfloor}$ such that $\\varAccPoKProofComm{c}=\\varAccPoKGProof^{c}\\varAccPoKHProof^{\\eta}\\bmod{N}$. $\\varAccPoKGProof$ and $\\varAccPoKHProof$ are quadratic residues modulo $N$.\n\t\\item $\\varAccPoKProofComm{w}$, a commitment of the witness $w$ with a random trapdoor $ \\epsilon\\in\\expIntGroup{\\lfloor N/4 \\rfloor}$ such that $\\varAccPoKProofComm{w}=w\\varAccPoKHProof^{\\epsilon}\\bmod{N}$.\n\t\\item $\\varAccPoKProofComm{r}$, a commitment of $\\epsilon$ with a random trapdoor $\\zeta\\in\\expIntGroup{\\lfloor N/4 \\rfloor}$ such that $\\varAccPoKProofComm{r}=\\varAccPoKGProof^{\\epsilon}\\varAccPoKHProof^{\\zeta}\\bmod{N}$.\n\\end{enumerate}\n\nLike the parameters used in the accumulator (\\S\\ref{sec:3-Public Accumulator}), $\\varAccPoKGComm,\\varAccPoKHComm,\\varAccPoKGProof,\\varAccPoKHProof,\\varAccPoKPComm,\\varAccPoKQComm$ are public parameters that are generated once during set up. For simplicity of presentation, the modulus of the above commitments are omitted and implied. With these commitments, the prover implements the AccPoK by constructing a NIZK proof that shows that $\\varAccPoKCoinComm$ and the accumulator $A$ contains the same $c$ in the following form:\n\n\\eqnAccPoKActual\n\nThe proof follows the standard flow of a NIZK proof described in \\S\\ref{sec:3-Transforming Interactive Zero Knowledge Proofs to NIZK Proofs}. Since there are 8 sub proofs in the NIZK proof, the prover first commits some random values $v_i$ to create commitments $\\varAccPoKCoinComm,\\varAccPoKProofComm{c},\\varAccPoKProofComm{w},\\varAccPoKProofComm{r}$ that are not related to,for each of the sub-proof. Following the principle of the Fiat-Shamir heuristics, the prover computes the challenge string $\\varChallenge=H(\\expConcatAccPoK)$ \\footnote{$H$ denotes the SHA-256 hash function used by Zerocoin. $\\|$ denotes a concatenation operation} and further computes $s_i$ that correspond to each $t_i$ using $\\varChallenge$. The final $\\varAccPoKCoinComm,\\varAccPoKProofComm{c},\\varAccPoKProofComm{w},\\varAccPoKProofComm{r},t_i,s_i$ are written into the \\kwTransaction{Spend }{} and broadcasted to the Zerocoin network to be verified. Upon receiving the \\kwTransaction{Spend }{}, the nodes re-computes $\\varChallenge=H(\\expConcatAccPoK)$ using the received $\\varAccPoKCoinComm,\\varAccPoKProofComm{c},\\varAccPoKProofComm{w},\\varAccPoKProofComm{r},t_i,s_i$ and the public parameters $\\varAccPoKGComm,\\varAccPoKHComm,\\varAccPoKGProof,\\varAccPoKHProof$,. The verifier then verifies the proof by checking if each received $t_i$ equals to the $t'_i$ computed from $\\varChallenge$ and $s_i$ using some verification formulas. The verification formulas are detailed in Appendix A of \\cite{JanCamenisch12002}. The completeness, soundness and statistical zero-knowledge properties of the proof are also detailed in the \\S3.3 of the same study.\n\n\\subsubsection{Serial Number Signature of Knowledge}\n\\label{sec:3-Serial Number Signature of Knowledge}\nProving that a \\kwCoin{} has been accumulated in the public accumulator only shows that the prover knows some \\kwCoin{} has been minted, but does not legitimise his ownership of the \\kwCoin{}. Anyone who looks at the Blockchain can simply take a \\kwCoin{} from any past \\kwTransaction{Mint }{s}, obtain a witness for the \\kwCoin{} using $GenWitness$ and construct a valid AccPoK for that \\kwCoin{}. Hence, the creator of a \\kwTransaction{Spend }{} must also prove that he owns the redeemed \\kwCoin{}. This is done using the Serial Number Signature of Knowledge (SNSoK) where the prover proves that he knows the serial number $S$ and the random trapdoor $r$ that are committed a \\kwCoin{} $c$ without disclosing $r$ and $c$. Since $r$ is secret to the owner of $c$ at all times, only the owner of the $c$ can produce a valid proof. This proof is a “signature” because it binds to the other contents of the \\kwTransaction{Spend }{} such as the public key address of the payee. As the SNSoK becomes invalid once the contents of the \\kwTransaction{Spend }{} changes, adversaries cannot tamper with the \\kwTransaction{Spend }{}. Given the above objectives and constraints, the SNSoK in Zerocoin is as such:\n\n$$\\eqnSNSoK$$\n\nThe $m$ enclosed in the square brackets denotes the contents in the \\kwTransaction{Spend }{} to be signed. As the serial number $S$ of the redeemed $c$ is disclosed in the proof, the trapdoor $r$ must be kept secret to prevent $c$ from being computed by observers of the Blockchain. The implementation of the SNSoK is adapted from the proof by Camenisch \\cite{No1998}.\n\nIn order to hide $c$, the prover creates $y$, a Pedersen commitment of $c$ using a random trapdoor $z\\in\\expIntGroup{\\varQSok}$, such that $y=\\expSoKCoinComm{c}\\bmod{\\varPSok}=\\expSoKCoinComm{\\expPedCommCoin}\\bmod{\\varPSok}$. As per Pedersen commitment scheme, $\\varGSok$ and $\\varHSok$ are generators of the sub-group $\\expIntGroup{\\varQSok}$ of multiplicative group $\\expMulGroup{\\varPSok}$, and $\\varQSok|\\varPSok-1$. As the exponent in a Pederson commitment must be an element of $\\expIntGroup{q}$ \\cite{Pedersen1992}, $c\\in\\expIntGroup{\\varQSok}$ and since $c$ is a value modulo $\\varPComm$ (\\S\\ref{sec:3-Coin as a Pederson Commitment}), it is required that $\\varQSok=\\varPComm$. Like the parameters used in the Pedersen commitment for \\kwCoin{s} (\\S\\ref{sec:3-Coin as a Pederson Commitment}), $\\varGSok,\\varHSok,\\varPSok,\\varQSok$ are public parameters that are generated once during set up. For simplicity of presentation, the modulus $\\varPSok$ is omitted and implied for $\\varGSok$ and $\\varHSok$. With $y$, the prover implements the SNSoK by constructing a NIZK proof that shows that $y$ contains a $c$ that is a commitment to the serial number $S$ and trapdoor $r$ in the following form:\n\n$$\\eqnSNSoKActual$$\n\nThe flow of the NIZK proof is largely similar to the standard NIZK proof under the Fiat-Shamir heuristics described in \\S\\ref{sec:3-Non-Interactive Zero Knowledge (NIZK) Proofs}, but has a slightly different way of computing and using the challenge $\\varChallenge$. The prover first creates $t_i$ for $i$ from 0 to $\\varLambdaSec$ using random numbers $u_i\\in\\expIntGroup{\\varQComm}$ and $v_i\\in\\expIntGroup{\\varQSok}$ such that $t_i=\\varGSok^{\\varGComm^{S}\\varHComm^{u_i}}\\varHSok^{v_i}$. To ensure security, the Zerocoin paper recommends that $\\varLambdaSec=80$ \\footnote{Based on the security recommendations in Section VI(B) of the Zerocoin paper \\cite{Miers2013}.}. Following the principle of the Fiat-Shamir heuristics, the prover then computes the challenge string $\\varChallenge=H(\\expConcatSNSoK)$. The inclusion of $m$ in the hash $\\varChallenge$ ensures that the contents of the \\kwTransaction{Spend }{} is bound to the challenge string. Any tampering with $m$ will cause $\\varChallenge$ to be invalid and the proof fail. Thus $\\varChallenge$ also serves as the signature for $m$. Using $\\varChallenge$ the prover then computes $s_i$ and $s'_i$ in the following manner:\n\n\\begin{algorithm}\n\t\\begin{algorithmic}[H]\n\t\t\\For{$i\\gets 1, \\varLambdaSec$}\n\t\t\\If{$i^{th}$ bit in $\\varChallenge=0$}\n\t\t\\State $s_i=(u_i-r)$; $s'_i=(v_i-z\\varHComm^{u_i-r})$ \n\t\t\\Else\n\t\t\\State $s_i=u_i$; $s'_i=v_i$\n\t\t\\EndIf\n\t\t\\EndFor\n\t\\end{algorithmic}\n\\end{algorithm}\t\n\nThe prover writes $y,\\varChallenge,t_1,\\cdots,t_{\\varLambdaSec},s_1,\\cdots,s_{\\varLambdaSec},s'_1,\\cdots,s'_{\\varLambdaSec}$ and the transaction content $m$ into the \\kwTransaction{Spend }{} and broadcast it to the Zerocoin network to be verified. Upon receiving the \\kwTransaction{Spend }{}, the nodes computes $\\varChallenge'=H(\\expConcatPrimeSNSoK)$ where:\n\n\\begin{algorithm}\n\t\\begin{algorithmic}[H]\n\t\t\\For{$i\\gets 1, \\varLambdaSec$}\n\t\t\\If{$i^{th}$ bit in $\\varChallenge'=0$}\n\t\t\\State $t'_i=y^{\\varHComm^{s_i}}\\varHSok^{s'_i}$ \n\t\t\\Else\n\t\t\\State $t_i=\\varGSok^{\\varGComm^{S}\\varHComm^{s_i}}\\varHSok^{s'_i}$\n\t\t\\EndIf\n\t\t\\EndFor\n\t\\end{algorithmic}\n\\end{algorithm}\t\n\nThe proof is verified if and only if $\\varChallenge'$ equals to the $\\varChallenge$ received. In order for $\\varChallenge'=\\varChallenge$, it must be the case that $t_i=t'_i$ for $i$ from 1 to $\\varLambdaSec$. In addition, the $m$ used to compute $\\varChallenge'$ must also be the original $m$ used to compute $\\varChallenge$, and thus $\\varChallenge$ acts as the signature that preserves the integrity of $m$. The details of the SNSoK are taken from Appendix B of the Zerocoin paper. The completeness, soundness and statistical zero-knowledge properties of the proof are also detailed in the same paper.\n\n\\subsubsection{Commitment Proof of Knowledge}\n\\label{sec:3-Commitment Proof of Knowledge}\nThe AccPoK and SNSoK independently proves a certain property of a \\kwCoin{}. However with only these two proofs, nothing is stopping one from constructing an AccPoK and a SNSoK for two different \\kwCoin{s}. A dishonest user can exploit this by constructing a valid SNSoK for an arbitrary \\kwCoin{} using an arbitrary serial number and secret trapdoor, and a valid AccPoK for any minted \\kwCoin{} on the Blockchain (\\S\\ref{sec:3-Accumulator Proof of Knowledge}). Since the \\kwCoin{s} in the two proofs are not known to the verifying nodes, the dishonest user is able to spend the arbitrary \\kwCoin{}, and claim that it is the minted \\kwCoin{} without being found out. This is analogous to the ability to printing money in real life. Hence there must be some way to ensure that the \\kwCoin{s} being proven for in the AccPoK and SNSoK are the same \\kwCoin{}. This is achieved using the Commitment Proof of Knowledge (CommPoK), where the prover proves that that commitment of the \\kwCoin{} $\\varAccPoKCoinComm=\\varAccPoKGComm^{c}\\varAccPoKHComm^{\\varphi}$ used in the AccPoK contains the same $c$ as the commitment of the \\kwCoin{} $y=\\expSoKCoinComm{c}$ used in the SNSoK. Hence the CommPoK is implemented in the following form:\n\n$$\\eqnCommPoK$$\n\nThe CommPoK is an extension of the proof by Camenisch to prove for the equality of two secret keys \\cite{No1998}. The proof follows the standard flow of a NIZK proof described in \\S\\ref{sec:3-Transforming Interactive Zero Knowledge Proofs to NIZK Proofs}. The prover first creates commitments $t_1=\\varAccPoKGComm^{v_1}\\varAccPoKHComm^{v_2}$ and $t_2=\\varGSok^{v_1}\\varHSok^{v_3}$ using random numbers $v_1,v_2,v_3$. Following the principle of the Fiat-Shamir heuristics, the prover computes the challenge string $\\varChallenge=H(\\expConcatCommPoK)$ and further computes $s_1=v_1+c\\varChallenge$, $s_2=v_2+\\varphi\\varChallenge$ and $s_3=v_3+z\\varChallenge$. The prover then includes $\\varAccPoKCoinComm,y,t_1,t_2,s_1,s_2,s_3$ in the \\kwTransaction{Spend }{} together with the other proofs and broadcasts the transaction to the Zerocoin network. Upon receiving the proof in the \\kwTransaction{Spend }{}, the verifying nodes re-compute $\\varChallenge=H(\\expConcatCommPoK)$ using the received $\\varAccPoKCoinComm,y,t_1,t_2$ and the public parameters $\\varAccPoKGComm,\\varAccPoKHComm,\\varGSok,\\varHSok$. The verifier then verifies the proof by checking if both equalities $t_1=\\varAccPoKGComm^{s_1}\\varAccPoKHComm^{s_2}\\varAccPoKCoinComm^{-\\varChallenge}$ and $t_2=\\varGSok^{s_1}\\varHSok^{s3}y^{-\\varChallenge}$ are true. The completeness, soundness and statistical zero-knowledge properties of the proof are detailed in the study by Camenisch \\cite{No1998}.\n\n\\subsubsection{Public Parameters}\n\\label{sec:3-Public Parameters}\nA summary of the public parameters used in the Zerocoin protocol is listed in Table~\\ref{tab:pub_params}. These parameters only need to be generated once during the setup of the Zerocoin system, and are subsequently used by all nodes for creating and verifying transactions. \n\n\\begin{table}[H]\n\t\\centering \\small\n\t\\begin{tabular}{ l | m{2cm} | m{2.5cm} | m{5.5cm} }\n\t\t\n\t\t& \\textbf{Public Parameter} & \\textbf{Recommended value/size} & \\textbf{Properties}\\\\ \t\t\n\t\t\\hline\n\t\t\\hline\n\t\t\\multirow{4}{*}{\\textbf{Coin commitment}} \n\t\t& $\\varPComm$ & 1024 bits & $\\varQComm|\\varPComm-1$ \\\\\n\t\t& $\\varQComm$ & 256 bits & $\\varQComm|\\varPComm-1$ \\\\\n\t\t& $\\varGComm$ & N.A. & Generator for sub-group $\\expIntGroup{\\varQComm}$ of multiplicative group $\\expMulGroup{\\varPComm}$ \\\\\n\t\t& $\\varHComm$ & N.A. & Generator for sub-group $\\expIntGroup{\\varQComm}$ of multiplicative group $\\expMulGroup{\\varPComm}$ \\\\\n\t\t\\hline\n\t\t\\multirow{4}{*}{\\textbf{Public Accumulator}}\n\t\t& $N$ & 3072 bits & Product of two large primes \\\\\n\t\t& $[\\mathfrak{A},\\mathfrak{B}]$ & N.A. & $[-\\varPComm2^{k'+k''+2},\\varPComm2^{k'+k''+2}]$ \\\\\n\t\t& $k$ & 160 & \\\\\n\t\t& $k'$ & 128 & \\\\\n\t\t\\hline\n\t\t\\multirow{6}{*}{\\textbf{AccPoK/CommPoK}} \n\t\t& $\\varAccPoKPComm$ & N.A.& $\\varAccPoKQComm|\\varAccPoKPComm-1$ \\\\\n\t\t& $\\varAccPoKQComm$ & $>2\\mathfrak{B}$ & $\\varAccPoKQComm|\\varAccPoKPComm-1$ \\\\\n\t\t& $\\varAccPoKGComm$ & N.A. & Generator for sub-group $\\expIntGroup{\\varAccPoKQComm}$ of multiplicative group $\\expMulGroup{\\varAccPoKPComm}$ \\\\\n\t\t& $\\varAccPoKHComm$ & N.A. & Generator for sub-group $\\expIntGroup{\\varAccPoKQComm}$ of multiplicative group $\\expMulGroup{\\varAccPoKPComm}$ \\\\\n\t\t& $\\varAccPoKGProof$ & N.A. & Quadratic residue modulo $N$ \\\\\n\t\t& $\\varAccPoKHProof$ & N.A. & Quadratic residue modulo $N$ \\\\\n\t\t\\hline\n\t\t\\multirow{5}{*}{\\textbf{SNSoK/CommPoK}}\n\t\t& $\\varLambdaSec$ & 80 & \\\\\n\t\t& $\\varPSok$ & N.A. & $\\varQSok|\\varPSok-1$\\\\\n\t\t& $\\varQSok$ & N.A. & Equals $\\varPComm$ \\\\\n\t\t& $\\varGSok$ & N.A. & Generator for sub-group $\\expIntGroup{\\varQSok}$ of multiplicative group $\\expMulGroup{\\varPSok}$\\\\\n\t\t& $\\varHSok$ & N.A. & Generator for sub-group $\\expIntGroup{\\varAccPoKQComm}$ of multiplicative group $\\expMulGroup{\\varAccPoKPComm}$\\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Public parameters used in Zerocoin}\n\t\\label{tab:pub_params}\n\\end{table}\n\n\\section{Zerocoin Implementation: libzerocoin}\n\\label{sec:3-Zerocoin Implementation: libzerocoin}\nThe main protocols in Zerocoin have been implemented in C++ by the Zerocoin authors and the source code is publicly available on Github under the name of libzerocoin \\footnote{Code repository can be accessed at https://github.com/Zerocoin/libzerocoin}. libzerocoin is not a full-fledged digital currency system. Instead, it is a library that provides the functions of setting up Zerocoin public parameters (\\S\\ref{sec:3-Public Parameters}), creating (\\S\\ref{sec:3-Coin as a Pederson Commitment}) and accumulating \\kwCoin{s} (\\S\\ref{sec:3-Public Accumulator}) and constructing and verifying the various zero-knowledge proofs (\\S\\ref{sec:3-NIZK Proofs in Zerocoin}). Since libzerocoin has implemented all of the key elements of Zerocoin, it can be used to analyse the performance of the Zerocoin in isolation. More importantly, libzerocoin provides a comprehensive set of functions to generate protocol parameters and perform cryptography-related computations such as SHA-256 and modulo arithmetic on large numbers. This allows the high level protocol of Zerocoin to be modified without the need to meddle with the details, and makes implementing improvements convenient. Hence this research builds on the code base of libzerocoin to conduct tests and make potential improvements.\n \n\\section{Performance of Zerocoin and Areas for Improvement}\n\\label{sec:3-Performance of Zerocoin and Areas for Improvement}\nlibzerocoin has been modified to test the computational and storage requirements of the key data structures and algorithms in Zerocoin. The tests are conducted using the public parameter values and sizes recommended by the Zerocoin paper (Table \\ref{tab:pub_params}). The machine used to run the tests is a \\_\\_\\_\\_. The results of the tests are shown in Table~\\ref{tab:zerocoin_comp_storage}.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{ l | c | c }\n\t\t\\multirow{2}{*}{} & \\multicolumn{2}{c}{\\textit{Average over 50 iterations}} \\\\\n\t\t& \\textbf{Time taken} & \\textbf{Size of output} \\\\ \t\t\n\t\t\\hline \n\t\t\\hline\n\t\tGeneration of public parameters & 849ms & 2578 bytes \\\\\n\t\t\\hline\n\t\tCreation of one \\kwCoin{} & 324ms & 199 bytes \\\\\n\t\tAccumulation of one \\kwCoin{} & 39ms & 391 bytes (accumulator size) \\\\\n\t\t\\hline\n\t\tConstruction of one AccPoK & 146ms & \\textbf{6,974 bytes} \\\\\n\t\tConstruction of one SNSoK & 146ms & \\textbf{17,420 bytes} \\\\\n\t\tConstruction of one CommPoK & 5ms & 714 bytes \\\\\n\t\t\\hline\n\t\tVerification of one AccPoK & \\textbf{100ms} & N.A. \\\\\n\t\tVerification of one SNSoK & \\textbf{163ms} & N.A. \\\\\n\t\tVerification of one CommPoK & 4ms & N.A. \\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Computational and storage requirements of Zerocoin}\n\t\\label{tab:zerocoin_comp_storage}\n\\end{table}\n\nThe results highlighted in bold are identified as the performance weaknesses of Zerocoin which this research aims to address. With reference to Table \\ref{tab:zerocoin_comp_storage}, the next two sections elaborate on why these weaknesses are identified. \n\n\\subsubsection{Computational Performance}\n\\label{sec:3-Computational Performance}\nThe computations that affect the performance of Zerocoin the most are those which need to be carried out by the Zerocoin peer-to-peer network. For the generation of public parameters, the Zerocoin network does no incur any computational costs since the parameters are generated once by the trusted party that sets up the system. Thus the cost of generating public parameters is not considered a performance issue. The creation of \\kwCoin{s} and the construction of the NIZK proofs are carried out by Zerocoin users whenever they want to make a transaction. Even though the time taken for these operations is in the order of hundreds of milliseconds, the computation requirement is contained within the individual users. As such \\kwCoin{} creation and proofs construction do not impose on the peer-to-peer network, and its relatively high computation requirement is still acceptable.\n\nThe accumulation of \\kwCoin{s} is performed by all nodes in the Zerocoin network as they need the most updated accumulator value to verify \\kwTransaction{Spend }{s}. Although the 39ms taken to accumulate a \\kwCoin{} is not small, nodes only need to accumulate the newly minted \\kwCoin{s} to the previous accumulator each time a new \\kwBlock{} is received since the accumulator can be incrementally computed (\\S\\ref{sec:3-Public Accumulator}). As blocks are only added to the Blockchain every 10 minutes (as per Bitcoin), nodes only need to periodically accumulate a small subset of the minted \\kwCoin{s} in history. With this optimisation, the computational requirement to accumulate a \\kwCoin{} is acceptable. \n\nOn the other hand, verification of NIZK proofs is done by all nodes in the Zerocoin network whenever they receive a \\kwTransaction{Spend }{}. Thus the time needed to verify \\kwTransaction{Spend }{s} grows linearly with the number of \\kwTransaction{Spend }{s} received. The verification time of the AccPoK (100ms) and the SNSoK (163ms), which make up the bulk of the verification time of a \\kwTransaction{Spend }{}, is an area of concern. In fact, the Zerocoin paper showed that the rate at which nodes verify transactions decreases by about half when only 12.5\\% of all transactions in the network are \\kwTransaction{Spend }{s} and the other 12.5\\% and 75\\% are \\kwTransaction{Mint }{s} and standard Bitcoin transactions respectively \\cite{Miers2013}. In addition, a node may need to verify the same \\kwTransaction{Spend }{s} twice – once before it forwards the \\kwTransaction{Spend }{} to its peers, and another time when a new \\kwBlock{} containing the \\kwTransaction{Spend }{} is received. The longer time taken by nodes to verify \\kwTransaction{Spend }{s} increases the time taken for transactions to reach mining nodes and make it to the Blockchain, and slows the Zerocoin entire network. Thus, the inefficiency in verifying the AccPoK and the SNSoK is a serious limiting factor to Zerocoin’s performance, and this research aims to reduce the time taken to verify these proofs.\n\n\\subsubsection{Storage Requirements}\n\\label{sec:3-Storage Requirements}\nEach node in Zerocoin stores a single copy of the public parameters, thus the 2.5KB of storage required by the public parameters is negligible. The other Zerocoin data structures need to be stored by nodes on a \\kwTransaction{}{} or \\kwBlock{} basis as part of the Blockchain, and their sizes affect the storage requirements of Zerocoin significantly. The rest this section uses Bitcoin as a point of reference to demonstrate the storage implications of Zerocoin.\n\nThe accumulator is stored on a \\kwBlock{} level. As of October 2016, the average size of one \\kwBlock{} in Bitcoin is about 0.8MB \\cite{Blockchain.info2016}. Thus an additional accumulator of 391 bytes for each \\kwBlock{} has negligible effect on the \\kwBlock{} size. On the other hand, a \\kwCoin{} is stored in each \\kwTransaction{Mint }{}, while the AccPoK, SNSoK and CommPoK are stored in each \\kwTransaction{Spend }{}. As of 2015, the average size of one standard Bitcoin \\kwTransaction{}{} in is 566 bytes \\cite{TradeBlock2015}. For simplicity of analysis, the Zerocoin data structures are added to the standard Bitcoin \\kwTransaction{}{} to estimate the size of Zerocoin transactions. As such, a \\kwTransaction{Mint }{} is bigger than a Bitcoin \\kwTransaction{}{} by the size of a \\kwCoin{} (199 bytes), and a \\kwTransaction{Spend }{} is bigger than a Bitcoin \\kwTransaction{}{} by the total size of the AccPoK, SNSoK and CommPoK (25KB). This means that a \\kwTransaction{Mint }{} increases transaction size by 35\\% while a \\kwTransaction{Spend }{} increases transaction size by 4,400\\%. \n\nWhile a 35\\% increase in size for a \\kwTransaction{Mint }{} is still reasonable, a 44-fold increase in size for a \\kwTransaction{Spend }{} is undesirable. To illustrate, if \\kwTransaction{Spend }{s} make up just 10\\% of all the transactions on the Blockchain, the total size of the transactions on the Blockchain will increase by 4.4 times. Since transactions make up the bulk of Blockchain stored in every node, the Zerocoin protocol imposes an enormous storage requirement compared to Bitcoin. In addition, the large size of the Zerocoin transaction also slows down the propagation of transactions in the network. As a result, Zerocoin transactions takes longer to reach the mining nodes and make it to the Blockchain, and slows down the entire Zerocoin network. Since the \\kwTransaction{Spend }{} contributes significantly the storage requirements and the AccPoK (6974 bytes) and the SNSoK (17,420 bytes) make up the bulk of a \\kwTransaction{Spend }{}, this research aims to reduce the size of the AccPoK and SNSoK to improve the overall performance of Zerocoin.\n\n", "meta": {"hexsha": "c615abeeaba5a477ad866684a5c61e720fd70702", "size": 40797, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "shaofeinus/fyp-report", "max_stars_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "shaofeinus/fyp-report", "max_issues_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "shaofeinus/fyp-report", "max_forks_repo_head_hexsha": "e92555f9b6007b4256a1f00b2c8cfba0b46852c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 171.4159663866, "max_line_length": 1628, "alphanum_fraction": 0.7657180675, "num_tokens": 11357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.42388701266731127}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\begin{document}\n\n\\title{Markov Chains}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Markov Chain}\nThe notes taken during the first lecture was unfortunately lost.\n\n\\begin{thm} (Extended Markov Property) Let $X$ be a Markov chain, and $n \\geq 0$. Let $H$ be an event defined in terms of $X_0,...,X_{n-1}$ (the history), and let $F$ be an event defined in terms of $X_{n+1},X_{n+2},...$ (the future). Then\n\\begin{equation*}\n\\begin{aligned}\n\\P \\left(F|H,X_n = i\\right) = \\P \\left(F|X_n = i\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{thm}\n\n\\newpage\n\n\\section{Transition Probabilities}\nWe've known that $p_{i,j}$ is the one-step transition probability, \n\\begin{equation*}\n\\begin{aligned}\n\\P\\left(X_{n+1} = j|X_n = i\\right) = \\P\\left(X_1 = j|X_0 = i\\right)\n\\end{aligned}\n\\end{equation*}\nNow it's natural to discuss the $n$-step transition probabilities\n\\begin{equation*}\n\\begin{aligned}\n\\P\\left(X_n = j| X_0 = i\\right) = p_{i,j}\\left(n\\right)\n\\end{aligned}\n\\end{equation*}\n\n\\begin{thm} (Chapman-Kolmogorov Equations)\n\\begin{equation*}\n\\begin{aligned}\np_{i,j}\\left(m+n\\right) = \\sum_{k \\in S} p_{i,k}\\left(m\\right)p_{k,j}\\left(n\\right)\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\n\\begin{equation*}\n\\begin{aligned}\np_{i,j}\\left(m+n\\right) &= \\sum_{k\\in S} \\P\\left(X_{m+n} = j|X_m=k\\right) \\P\\left(X_m=k\\right)\\\\\n&= \\sum_{k\\in S} p_{k,j} \\left(n\\right) p_{i,k} \\left(m\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{proof}\n\\end{thm}\n\nNow let $P\\left(1\\right) = P = p_{i,j}$, $P\\left(n\\right) = p_{i,j}\\left(n\\right)$. Then this is just matrix multiplication: $P\\left(n\\right) = P^n$. To find $P\\left(n\\right)$ we can diagonalize the matrix. (or matrix mult + qpower!)\n\n\\begin{eg}\nLet $S=\\left\\{1,2\\right\\}$,\n\\begin{equation*}\n\\begin{aligned}\nP= \\left(\\begin{matrix}\n1-\\alpha & \\alpha\\\\\n\\beta & 1-\\beta\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\nans assume that $0<\\alpha,\\beta<1$ (non-trivial).\\\\\nThen solve $|P-\\kappa I|=0$, we get $\\kappa = 1$ or $\\kappa = 1-\\alpha - \\beta$. So\n\\begin{equation*}\n\\begin{aligned}\nP^n = U^{-1}\\left(\\begin{matrix}\n1^n & 0\\\\\n0 & \\left(1-\\alpha-\\beta\\right)^n\n\\end{matrix}\\right)U\n\\end{aligned}\n\\end{equation*}\nfor some invertible $U$. Then\n\\begin{equation*}\n\\begin{aligned}\np_{1,1}\\left(n\\right) = A \\cdot 1^n + B\\left(1-\\alpha-\\beta\\right)^n\n\\end{aligned}\n\\end{equation*}\nfor some $A,B$. We know that $p_{1,1}\\left(1\\right) = 1-\\alpha$, $p_{1,1}\\left(0\\right) = 1$. Then we can solve for $A$ and $B$ and get\n\\begin{equation*}\n\\begin{aligned}\nA=\\frac{\\beta}{\\alpha+\\beta},B=\\frac{\\alpha}{\\alpha+\\beta}\n\\end{aligned}\n\\end{equation*}\nBy symmetry we can get\n\\begin{equation*}\n\\begin{aligned}\nP^n = \\frac{1}{\\alpha+\\beta} \\left(\\begin{matrix}\n\\beta+\\alpha\\left(1-\\alpha-\\beta\\right)^n & \\alpha-\\alpha\\left(1-\\alpha-\\beta\\right)^n\\\\\n\\beta-\\beta\\left(1-\\alpha-\\beta\\right)^n & \\alpha+\\beta\\left(1-\\alpha-\\beta\\right)^n\n\\end{matrix}\\right)\n\\end{aligned}\n\\end{equation*}\n\nAnother method is to use difference equations:\n\\begin{equation*}\n\\begin{aligned}\np_{1,1}\\left(n+1\\right) &= \\P \\left(X_{n+1} = 1|X_0=1\\right)\\\\\n&= \\P \\left(X_{n+1} = 1|X_n = 1,X_0=1\\right) \\P\\left(X_n=1|X_0=1\\right) + \\\\&\\P\\left(X_{n+1}=1|X_n=2,X_0=1\\right) \\P\\left(X_n = 2|X_0=1\\right)\\\\\n&= \\left(1-\\alpha\\right) P_{1,1}\\left(n\\right) + \\beta p_{1,2}\\left(n\\right)\n\\end{aligned}\n\\end{equation*}\nwhich is a difference equation for the sequence for $\\left(p_{1,1}\\left(n\\right)\\right)$ (note $p_{1,2}\\left(n\\right) = 1-p_{1,1}\\left(n\\right)$) solved in the normal way, subject to boundary conditions.\n\\end{eg}\n\nThe distributions of a Markov chain is somewhat related to linear algebra. Let $\\lambda$ be the initial distribution of $X_0$, i.e. $\\lambda_i = \\P \\left(X_0 = i\\right)$. Then\n\\begin{equation*}\n\\begin{aligned}\n\\P\\left(X_1=j\\right) = \\sum_i \\lambda_i p_{i,j}\n\\end{aligned}\n\\end{equation*}\nSo the distribution of $X_1$ is $\\lambda P$, and similarly $X_n$ has distribution $\\lambda P^n$.\n\n\\newpage\n\n\\section{Class Structure}\nWe write \"$i$ leads to $j$\", or $i \\to j$, if there exists $n \\geq 0$ s.t. $p_{i,j}\\left(n\\right) > 0$. Write $i \\leftrightarrow j$ if $i\\to j$ and $j\\to i$, and say that $i$ and $j$ \\emph{communicate}.\n\n\\begin{prop}\n$\\leftrightarrow$ is an equivalence relation.\n\\begin{proof}\n$\\bullet$ $i \\leftrightarrow i$ since $p_{i,i}\\left(0\\right) = 1 > 0$.\\\\\n$\\bullet$ $i \\leftrightarrow j \\to j \\leftrightarrow i$ is trivial.\\\\\n$\\bullet$ If $i \\leftrightarrow j$ and $j \\leftrightarrow i$, in particular $i\\to j$ and $j\\to k$. Then there exists $m,k$ such that $p_{i,j}\\left(m\\right) > 0$ and $p_{j,k}\\left(n\\right) > 0$. Then\n\\begin{equation*}\n\\begin{aligned}\np_{i,k}\\left(m+n\\right) \\geq p_{i,j}\\left(m\\right) p_{j,k}\\left(n\\right) > 0\n\\end{aligned}\n\\end{equation*}\nBy C-K equation (since each term in the sum is non-negative). So $i\\to k$. Similarly $k\\to i$. So $i \\leftrightarrow k$.\n\\end{proof}\n\\end{prop}\n\n\\begin{defi}\nNow $S$, the set of all states, has equivalence classes under $\\leftrightarrow$. We call them \\emph{communicating classes}, and define\n\\begin{equation*}\n\\begin{aligned}\nC_i = \\left\\{ j \\in S: i \\leftrightarrow j\\right\\}\n\\end{aligned}\n\\end{equation*}\n\nThe space $S$, or the chain $X$, is called \\emph{irreducible} if there exists a unique communicating class (which is $S$).\n\n$C \\subset S$ is called \\emph{closed} if\n\\begin{equation*}\n\\begin{aligned}\ni\\in C, i\\to j \\implies j \\to C\n\\end{aligned}\n\\end{equation*}\nif $\\left\\{i\\right\\}$ is closed, then $i$ is called \\emph{absorbing}.\n\\end{defi}\n\n\\begin{prop}\nA set $C$ is closed if and only if $p_{i,j} = 0$ for all $i \\in C, j \\not\\in C$.\n\\begin{proof}\nSuppose the above condition does not hold. Then $\\exists i \\in C, j \\not\\in C$ with $p_{i,j} > 0$. But then $C$ is not closed by definition since $i \\to j$.\\\\\nNow suppose the above condition hold. Let $i \\in C,i \\to j$. There exists several $k_0 = i, k_1,...,k_n = j$ such that\n\\begin{equation*}\n\\begin{aligned}\np_{k_0,k_1} p_{k_1,k_2}...p_{k_{n-1},k_n} > 0\n\\end{aligned}\n\\end{equation*}\nwhich requires $i=k_0 \\to k_1$, $k_1 \\to k_2$, ... $k_{n-1} \\to k_n=j$. Then $k_1 \\in C, k_2 \\in C,... k_n = j\\in C$. So $C$ is closed.\n\\end{proof}\n\\end{prop}\n\n\\begin{eg}\nLet $S = \\left\\{1,2,...,6\\right\\}$, and\n\\begin{equation*}\n\\begin{aligned}\nP = \\left(\n\\begin{matrix}\n\\frac{1}{2} & \\frac{1}{2} & 0 & 0 & 0 & 0\\\\\n0 & 0 & 1 & 0 & 0 & 0\\\\\n\\frac{1}{3} & 0 & 0 & \\frac{1}{3} & \\frac{1}{3} & 0\\\\\n0 & 0 & 0 & \\frac{1}{2} & \\frac{1}{2} & 0\\\\\n0 & 0 & 0 & 0 & 0 & 1\\\\\n0 & 0 & 0 & 0 & 1 & 0\n\\end{matrix}\n\\right)\n\\end{aligned}\n\\end{equation*}\nHere $\\left\\{1,2,3\\right\\}$, $\\left\\{4\\right\\}$, $\\left\\{5,6\\right\\}$ are communicating classes.\n\\end{eg}\n\n\\newpage\n\n\\section{Recurrence and Transience}\nWe write $\\P\\left( \\cdot | X_0 = i\\right) = \\P_i \\left(\\cdot\\right)$, and similarly for expectation.\n\n\\begin{defi}\nThe \\emph{first-passage time} of $j \\in S$ is\n\\begin{equation*}\n\\begin{aligned}\nT_j = \\inf\\left\\{n \\geq 1: X_n = j\\right\\}\n\\end{aligned}\n\\end{equation*}\n\nThe \\emph{first-passage probabilities} are\n\\begin{equation*}\n\\begin{aligned}\nf_{i,j}\\left(n\\right) = \\P_i \\left(T_j=n\\right)\n\\end{aligned}\n\\end{equation*}\n\\end{defi}\n\n\\begin{defi}\nThe state $i \\in S$ is \\emph{recurrent} (or \\emph{persistent}) if $\\P_i\\left(T_i < \\infty\\right) = 1$, and \\emph{transient} otherwise.\n\\end{defi}\n\n\\begin{thm}\nThe state $i$ is recurrent if and only if\n\\begin{equation*}\n\\begin{aligned}\n\\sum_n p_{ii}\\left(n\\right) \\to \\infty.\n\\end{aligned}\n\\end{equation*}\n\\begin{proof}\nWe have\n\\begin{equation*}\n\\begin{aligned}\np_{ij}\\left(n\\right) = \\P_i\\left(x_n=j\\right) &= \\sum_m \\P_i\\left(x_n=j | T_j = m\\right) \\P_i\\left(T_j=m\\right)\\\\\n&= \\sum_{m \\leq n} \\P_i \\left(x_n = j|x_m=j\\right) \\P_i\\left(T_j=m\\right)\\\\\n&=\\sum_{m=1}^n f_{i,j}\\left(m\\right) p_{jj}\\left(n-m\\right)\n\\end{aligned}\n\\end{equation*}\n(which looks like a \\emph{convolution} of $f_{i,j}$ and $p_{jj}$).\n\nNow consider generating sequences\n\\begin{equation*}\n\\begin{aligned}\nF_{ij}\\left(s\\right) = \\sum_{n=0}^\\infty f_{ij}\\left(n\\right) s^n\\\\\nP_{ij}\\left(s\\right) = \\sum_{n=0}^\\infty p_{ij}\\left(n\\right) s^n\n\\end{aligned}\n\\end{equation*}\nwith $f_{ij}\\left(0\\right)=0$,$p_{ij}\\left(0\\right) = \\delta_{ij}$.\n\nThen\n\\begin{equation*}\n\\begin{aligned}\n\\sum_{n\\geq 1} p_{ij}\\left(n\\right)s^n = \\sum_{n\\geq 1} \\sum_{m=1}^n f_{ij}\\left(m\\right)s^m p_{jj}\\left(n-m\\right)s^{n-m}\n\\end{aligned}\n\\end{equation*}\nSo by reversing the order of the sums,\n\\begin{equation*}\n\\begin{aligned}\nP_{ij}\\left(s\\right) - \\delta_{ij} = \\sum_{m=0}^\\infty f_{ij}\\left(m\\right) s^m \\sum_{n=m}^\\infty p_{jj}\\left(n-m\\right)s^{n-m} = F_{ij}\\left(s\\right)P_{jj}\\left(s\\right)\n\\end{aligned}\n\\end{equation*}\nSo we've derived\n\\begin{thm}\n$P_{ij}\\left(s\\right) = \\delta_{ij} + F_{ij}\\left(s\\right)P_{jj}\\left(s\\right)$. ($1 < s \\leq 1$, since we need the series to converge)\\\\\nWhen $i=j$,\n\\begin{equation*}\n\\begin{aligned}\nP_{ii}\\left(s\\right) = \\frac{1}{1-F_{ii}\\left(s\\right)}\n\\end{aligned}\n\\end{equation*}\nif $0\\leq s < 1$.\\\\\nNow let $s \\to 1$, then\n\\begin{equation*}\n\\begin{aligned}\nF_{ii}\\left(s\\right) \\to \\sum_n f_{ii}\\left(n\\right) = \\P_i\\left(T_i < \\infty\\right),\\\\\nP_{ii}\\left(s\\right) \\to \\sum_n p_{ii}\\left(n\\right)\n\\end{aligned}\n\\end{equation*}\nTherefore $i$ is recurrent iff $F_{ij}\\left(s\\right) = 1$, i.e. $\\sum_n p_{ii}\\left(n\\right) \\to \\infty$.\n\\end{thm}\n\\end{proof}\n\\end{thm}\n\n\\begin{thm}\nLet $C$ be a communicating class.\\\\\n(a) For $i,j \\in C$, either both of them are recurrent, or both are transient (i.e. recurrence is a class property).\\\\\n(b) If $i\\in C$ is recurrent, then $C$ is closed (i.e. a recurrent communicating class is closed).\n\\begin{proof}\n(a) Let $i \\leftrightarrow j$. Then\n\\begin{equation*}\n\\begin{aligned}\np_{ii}\\left(m+k+n\\right) \\geq p_{ij}\\left(m\\right)p_{jj}\\left(k\\right)p_{ji}\\left(n\\right)\n\\end{aligned}\n\\end{equation*}\nPick $m$ s.t. $p_{ij}\\left(m\\right)>0$, and $n$ s.t. $p_{ji}\\left(n\\right)>0$. Then\n\\begin{equation*}\n\\begin{aligned}\n\\sum_k p_{ii}\\left(m+k+n\\right) \\geq \\alpha\\sum_k p_{jj}\\left(k\\right)\n\\end{aligned}\n\\end{equation*}\nfor $\\alpha > 0$.\\\\\nThen if $j$ is recurrent, then $\\sum_k p_{jj}\\left(k\\right) \\to \\infty$, and hence $\\sum_k p_{ii}\\left(k\\right) \\to \\infty$, i.e. $i$ is recurrent, and vice versa.\n\n(b) Suppose $C$ is not closed. So $\\exists j \\in C$, $k \\not\\in C$ with $p_{jk} > 0$.\\\\\nIf $i$ is recurrent, so is $j$ by (a). Then\n\\begin{equation*}\n\\begin{aligned}\n1 - \\P_j\\left(T_j<\\infty\\right) = \\P_j \\left(\\text{no return to } j\\right) \\geq p_{jk}\n\\end{aligned}\n\\end{equation*}\nSince $k \\not\\in C$. However that implies $p_{jk} \\leq 1-1 = 0$. Contradiction.\n\\end{proof}\n\\end{thm}\n\n\\begin{prop}\nLet $i,j\\in S$. If $j$ is transient, then $p_{ij}\\left(n\\right) \\to 0$ as $n \\to \\infty$.\n\\begin{proof}\n$P_{ij}\\left(s\\right) = \\delta_{ij} + F_{ij}\\left(s\\right) P_{jj}\\left(s\\right)$ for $-1 <s<1$.\\\\\nNow let $i \\neq j$, and $s \\to 1$. Then\n\\begin{equation*}\n\\begin{aligned}\nP_{ij}\\left(1\\right) = F_{ij}\\left(1\\right) P_{jj}\\left(1\\right)\n\\end{aligned}\n\\end{equation*}\nSince $j$ is transient, $F_{ij}\\left(1\\right) < \\infty$ and $P_{jj}\\left(1\\right) < \\infty$.\\\\\nSo $P_{ij}\\left(n\\right) < \\infty$, and hence $p_{ij}\\left(n\\right) \\to 0$ as $n \\to \\infty$.\\\\\nThe argument is similar when $i=j$.\n\\end{proof}\n\\end{prop}\n\n\\begin{thm}\nIf $S$ is finite, then there exists at least one recurrent state. Therefore, if the chain is irreducible, every state is recurrent.\n\\begin{proof}\nSuppose otherwise, that every $j$ is transient. Then we have\n\\begin{equation*}\n\\begin{aligned}\n1 = \\sum_{j \\in S} p_{ij}\\left(n\\right) \\to 0\n\\end{aligned}\n\\end{equation*}\nas $n \\to \\infty$. Contradiction.\n\\end{proof}\n\\end{thm}\n\n\\newpage\n\n\\section{Random walks on $\\Z^d$ with $d \\geq 1$}\n\nWe consider random walks on\n\\begin{equation*}\n\\begin{aligned}\n\\Z^d = \\left\\{\\left(x_1,...,x_d\\right):x_i \\in \\Z\\right\\}\n\\end{aligned}\n\\end{equation*}\n\nDefine two points $x,y\\in\\Z^d$: $x = \\left(x_1,...,x_d\\right)$, $y=\\left(y_1,...,y_d\\right)$ to be \\emph{adjacent} if \n\\begin{equation*}\n\\begin{aligned}\n\\sum_{i=1}^d \\left|x_i-y_i\\right| = 1\n\\end{aligned}\n\\end{equation*}\n\nThe \\emph{Random walk} on $\\Z^d$ is a Markov chain with state space $\\Z^d$; a walker lives at $X_n$ at time $n$, with\n\\begin{equation*}\n\\begin{aligned}\n\\P\\left(X_{n+1}=y\\right) | X_n = x,X_0 = x\\left(0\\right),...,X_{n-1} = x\\left(n-1\\right) = \\left\\{ \\begin{array}{ll} 0 & x,y \\text{ are not adjacent}\\\\\n\\frac{1}{2d} & x,y \\text{ are adjacent}\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\n\nClearly RW is irreducible and has an infinite state space.\n\n\\begin{thm}\nThe random walk is recurrent if $d = 1,2$, and transient if $d \\geq 3$.\n\\begin{proof}\n$\\bullet$ $d=1$: $p_{0,0}\\left(2n\\right) = \\left(\\frac{1}{2}\\right)^{2n} {2n \\choose n} = \\left(\\frac{1}{2}\\right)^{2n} \\frac{2n!}{\\left(n!\\right)^2} \\sim \\frac{1}{\\sqrt{\\pi n}}$ by Stirling formula.\\\\\nHence $\\sum_n p_{0,0}\\left(n\\right) \\to \\infty$, i.e. $0$ is recurrent.\n\n$\\bullet$ $d=2$: Suppose we walked $m$ steps towards L/R, and $n-m$ steps towards U/D.\n\\begin{equation*}\n\\begin{aligned}\np_{0,0} \\left(2n\\right) &= \\sum_{m=0}^n \\left(\\frac{1}{4}\\right)^{2n} \\frac{\\left(2n\\right)!}{m!m!\\left(n-m\\right)!\\left(n-m\\right)!}\\\\\n&= \\left(\\frac{1}{4}\\right)^{2n} {2n \\choose n} \\sum_{m=0}^n {n \\choose m}^2\\\\\n&= \\left(\\frac{1}{4}\\right)^{2n} {2n \\choose n}\\\\\n&\\sim \\frac{1}{\\pi n}\n\\end{aligned}\n\\end{equation*}\nSo $\\left(0,0\\right)$ is recurrent.\n\n$\\bullet$ $d=3$ (and similarly $d \\geq 3$):\\\\\n\\begin{equation*}\n\\begin{aligned}\np_{0,0}\\left(2n\\right) &= \\sum_{i+j+k=n} \\left(\\frac{1}{6}\\right)^{2n} \\frac{\\left(2n\\right)!}{\\left(i!j!k!\\right)^2}\\\\\n&\\leq \\left(\\frac{1}{2}\\right)^{2n} {2n \\choose n} \\sum_{i+j+k=n} \\left(\\frac{n!}{3^n i!j!k!}\\right)^2\\\\\n&\\leq \\left(\\frac{1}{2}\\right)^{2n} {2n \\choose n} M_n \\sum_{i+j+k=n} \\frac{n!}{3^n i!k!l!}\n\\end{aligned}\n\\end{equation*}\nwhere\n\\begin{equation*}\n\\begin{aligned}\nM_n=\\max\\left\\{\\frac{n!}{3^n i!j!k!} | i+j+k=n\\right\\}\n\\end{aligned}\n\\end{equation*}\nThe sum in the last line is $1$, since each term in the sum is the probability of $n$ balls goes in to 3 boxes, with $i,j,k$ balls in each box.\\\\\nWe see that $M_n$ is achieved when $i,j,k$ are 'as equal as possible. Then\n\\begin{equation*}\n\\begin{aligned}\np_{0,0}\\left(2n\\right) &\\leq \\left(\\frac{1}{2}\\right)^2n {2n \\choose n} \\frac{n!}{3^n \\left(\\lfloor n/3\\rfloor !\\right)^3}\\\\\n&\\sim \\frac{c}{n^{3/2}}\n\\end{aligned}\n\\end{equation*}\nBut this sum now converges. So $\\left(0,0,0\\right)$ is transient.\n\\end{proof}\n\\end{thm}\n\n\\newpage\n\n\\section{Hitting probabilities}\n\n\\subsection{Gambler's Ruin}\nWhat is the hitting probability for gambler's ruin, $h_i = h_i^{\\left\\{0\\right\\}}$?\n\n$h_0=1$, $h_i = ph_{i+1} + qh_{i-1}$ for $i \\geq 1$.\n\nThen guess a solution $h_i = \\theta^i$, so $\\theta = q/p,1$. So the general solution is\n\\begin{equation*}\n\\begin{aligned}\nh_i = A+B\\left(q/p\\right)^i\n\\end{aligned}\n\\end{equation*}\nfor all $i$.\n\nSince $h_0=1$, $A+B=1$.\n\nIf $p<q$: since the $h_i$ are probability, $B=0$, $A=1$. So $h_i = 1-\\left(q/p\\right)^i$ for all $i$.\n\nIf $p>q$, since$h_i \\geq 0$ for all $i$, we have $A \\geq 0$. By minimality of $\\left(h_i\\right)$, $A=0$. So $h_i = \\left(q/p\\right)^i$.\n\nWhen $p=q$: by the above arguments, $h_i \\equiv 1$.\n\nExtension: let $p_i = 1-q_i \\in \\left(0,1\\right)$.\n\nSo $h_0=1$, $\\left(p_i+q_i\\right)h_i = p_i h_{i+1} + q_i h_{i-1}$. $p_i\\left(h_{i+1} - h_i\\right) = q_i \\left(h_i-h_{i-1}\\right)$.\n\nLet $u_i = h_{i-1} - h_i$. Then $p_i u_{i+1} = q_i u_i$. So $u_{i+1} = \\left(q_i/p_i\\right)u_i$.\n\nTherefore $u_{i+1}\\gamma_i u_1$, where\n\\begin{equation*}\n\\begin{aligned}\n\\gamma_i = \\frac{q_1 q_2...q_i}{p_1 p_2 ... p_i}\n\\end{aligned}\n\\end{equation*}\nfor $i \\geq 1$, and $\\gamma_0 = 1$. Then\n\\begin{equation*}\n\\begin{aligned}\nu_1+u_2+...+u_i = \\left(h_0-h_i\\right)\\\\\nh_i = 1-\\left(u_1+...+u_i\\right)=1-u_1\\left(\\gamma_0+\\gamma_1+...+\\gamma_{i-1}\\right)\n\\end{aligned}\n\\end{equation*}\n\nLet $S = \\sum_{i=0}^\\infty \\gamma_i$. If $S=\\infty$, since $h_1\\geq 0$ we have $u_1 = 0$, and hence $h_i \\equiv 1$.\n\nIf $S < \\infty$, $u_1$ is maximised when $1-u_1 S = 0$, i.e. $u_1 = 1/S$.\n\n\\newpage\n\n\\section{Stopping times}\n\nConsider Markov chain $X$.\n\n\\begin{defi}\nA random variable $T$ taking values in $\\left\\{0,1,2,...,\\right\\}\\cup\\left\\{\\infty\\right\\}$ is a \\emph{stopping time} (for $X$) if for $n\\geq 0$, the event $\\left\\{T=n\\right\\}$ is given 'in terms of' $X_0$, $X_1$,...,$X_n$ only.\n\\end{defi}\n\nHitting times are stopping times: $\\left\\{H^A = n\\right\\} = \\left\\{X_n \\in A \\right\\} \\cap \\left(\\cap_{0\\leq m< n} \\left\\{x_m \\not\\in A\\right\\}\\right)$.\n\n$H^A+1$ is a stopping times is a stopping time, $H^A-1$ is not in general a stopping time.\n\n\\begin{defi} (Strong Markov Property) Let $X$ be a Markov chain with transition matrix $P$, and let $T$ be a stopping time for $X$. Given $T<\\infty$ and $X_T = i$, then $Y=\\left(X_T,X_{T+1},...\\right)$ is a Markov chain with transition matrix $P$ and initial state $Y_0 = i$, and $Y$ is independent of $\\left(X_0,...,X_{T-1}\\right)$.\n\\end{defi}\n\n\\begin{eg}\nConsider a random walk with an absorbing wall at $0$,with probability $p$ going right and $q=1-p$ going left. Assume particle starts at $1$, and let $H$ be the hitting time of $0$. What is the mass function and mean of $H$?\n\nLet\n\\begin{equation*}\n\\begin{aligned}\nG\\left(s\\right) = \\E_1\\left(s^H\\right) = \\sum_{n=0}^\\infty s^n \\P_1\\left(H=n\\right)\n\\end{aligned}\n\\end{equation*}\nif $|s|<1$.\n\nBy assuming $|s|<1$ (and using Abel's lemma when needed) we include the possibility $\\P_1\\left(H=\\infty\\right)>0$. Then\n\\begin{equation*}\n\\begin{aligned}\nG\\left(s\\right) &= \\E_1\\left(s^H\\right)\\\\\n&= \\E_1\\left(s^H | X_1=2\\right)p + \\E_1\\left(s^H | X_1 = 0\\right)q\\\\\n&= p\\E_1\\left(s^{1+H_1+H_0}\\right)+qs\\\\\n&= psG\\left(s\\right)^2(=\\E_1\\left(s^{H_1}\\right)\\E_1\\left(s^{H_2}\\right)) + qs\n\\end{aligned}\n\\end{equation*}\nwhere $H_i$ is the time to go from $i+1$ to $i$.\n\nSo\n\\begin{equation*}\n\\begin{aligned}\nG\\left(s\\right) = \\frac{1 \\pm \\sqrt{1-4pqs^2}}{2ps}\n\\end{aligned}\n\\end{equation*}\nfor $|s|<1$.\n\nSince $G$ is continuous, the $\\pm$ sign is the same for all $s$. Since $G$ has to remain regular at $s=0$, the $\\pm$ sign has to be $-$ for all $s$. So\n\\begin{equation*}\n\\begin{aligned}\nG\\left(s\\right) = \\frac{1-\\sqrt{1-4pqs^2}}{2ps}\n\\end{aligned}\n\\end{equation*}\nSo\n\\begin{equation*}\n\\begin{aligned}\n\\P_1\\left(H=2k-1\\right)=\\frac{\\left(2k-2\\right)!}{k!\\left(k-1\\right)!} \\frac{\\left(pq\\right)^k}{p}\n\\end{aligned}\n\\end{equation*}\nwhere $k \\geq 1$.\n\nWe can also get\n\\begin{equation*}\n\\begin{aligned}\nP\\left(H<\\infty\\right) &= \\lim_{s \\to 1} G\\left(s\\right)\\\\\n&= \\frac{1-\\sqrt{1-4pq}}{2p}\\\\\n&= \\frac{1-|q-p|}{2p}\\\\\n&= \\left\\{\\begin{array}{ll}\n1 & p\\leq q\\\\\nq/p & p>q\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\n\nNow let $p\\leq q$. We want to find $\\E_1\\left(H\\right)$. Differentiate $G$,\n\n\\begin{equation*}\n\\begin{aligned}\nG'=pG^2+2psGG'+q\\\\\n\\implies G'\\left(s\\right) = \\frac{pG^2+q}{1-2psG}\n\\end{aligned}\n\\end{equation*}\n\nTake the limit $s \\to 1$,\n\\begin{equation*}\n\\begin{aligned}\nG'\\left(s\\right) \\to \\left\\{ \\begin{array}{ll}\n\\infty & p=q\\\\\n\\frac{1}{q-p} & p<q\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\n\n\\end{eg}\n\n\\newpage\n\n\\section{Classification of states}\n\n\\begin{defi}\n(a) The \\emph{mean recurrence time} of $i\\in S$ is \n\\begin{equation*}\n\\begin{aligned}\n\\mu_i &= \\E_i\\left(T_i\\right)\\\\\n&=\\left\\{\\begin{array}{ll}\n\\infty & i \\text{ is transient}\\\\\n\\sum_{n\\geq 1} n f_{i,i}\\left(n\\right) & i \\text{ is recurrent}\n\\end{array}\n\\right.\n\\end{aligned}\n\\end{equation*}\n\n(b) We call $i$ \\emph{null} if $\\mu_i = \\infty$, and \\emph{non-null} or \\emph{positive} if $\\mu_i < \\infty$.\n\n(c) The \\emph{period} $d_i$ of $i \\in S$ is $d_i = \\gcd\\left\\{ n \\geq 1 : p_{i,i} \\left(n\\right) > 0\\right\\}$.\\\\\nWe call $i$ \\emph{aperiodic} if $d_i = 1$.\n\n(d) A state $i \\in S$ ie \\emph{ergodic} if it is aperiodic and non-null recurrent.\n\\end{defi}\n\n\\begin{thm}\nIf $i \\leftrightarrow j$ then\\\\\n(a) they have the same period;\\\\\n(b) if one is recurrent, so is the other;\\\\\n(c) if one is positive recurrent, so is the other;\\\\\n(d) if one is ergodic, so is the other.\n\\end{thm}\n\n\\end{document}", "meta": {"hexsha": "011db46f13e84231dde34bee1cc1eb76e1e3a470", "size": 19958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Markov Chains.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/Markov Chains.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Markov Chains.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6559865093, "max_line_length": 333, "alphanum_fraction": 0.644904299, "num_tokens": 8221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.42388701266731116}}
{"text": "\\author{Florian Müller}\n\\graphicspath{ {./src/chapters/developer/media/ld_live/} }\n\\section {opencv}\n\nopencv can be installed via pip and used via \\texttt{import cv2}.\nFor the scripts here, the \\texttt{opencv-contrib-python} package was loaded and imported as cv.\n\nAll examples are thus called only with cv and not with cv2.\n\n\\subsection {Blur}\n\n\\texttt{image = cv.blur(img, kernel)}\n\nThe function \\texttt{blur()} is used to soften an image.\nA kernel is applied to each pixel in the image and computed.\n\nThis kernel is a normalized matrix filled with ones.\nAs an example a 3x3 normalized matrix can be considered here:\n\n$$Kernel = \\frac{1}{9}\n\\begin{bmatrix}\n1 &1 &1 \\\\\n1 &1 &1 \\\\\n1 &1 &1\n\\end{bmatrix}\n$$\n\n\n\\subsection {Dilate and Erode}\n\n\\texttt{kernal = cv.getStructuringElement(cv.MORPH\\_ELLIPSE, (x-size, y-size))}\n\n\\texttt{dilated\\_image = cv.dilate(image, kernel)}\n\n\\texttt{eroded\\_image = cv.erode(image, kernel)}\n\nDilation and erosion are very similar to describe.\nIn both operations an image $A$ will be convolved with a kernel $B$.\nThe usage of both functions are removing noise, isolate individual elements, closing gaps in images.\n\nThe dilation or grow function is used to let an image grow in the directions of the kernel.\nBut it is also possible to set the anchor of the kernal not to the centre but to a different point.\nThen it is possible to let the picture grow or shrink in a specific direction.\ne.g.:\n\n\\texttt{cv.dilate(image, kernel, anchor = (1,1))}\n\nFor the erosion the same kernel can be used.\nAnd instead of letting the image grow, with an erosion the image will shrink.\nThis can be used to eliminate noise or separate elements which are barely touching.\n\nThe function itself is passed two parameters and then returns a modified image.\n\nThe opencv docs contain a good explanation\\\\\n\\url{https://docs.opencv.org/3.4/db/df6/tutorial\\_erosion\\_dilatation.html}\n\n\\subsection{Convert Color}\n\n\\texttt{image = cv.cvtColor(image, flag)}\n\nDuring the color conversion the function receive two arguments and returns the converted picture.\nThe first argument is the image to convert.\nThe second argument is the flag which conversion shall be used.\nFor this project only the \\texttt{BGR2GRAY} and \\texttt{RGB2BGR} flags are used.\n\n\\subsection{Threshold}\n\n\\texttt{threshold, image = cv.threshold(image, min, max, flag)}\n\nThreshold is used to remove some noise and to convert the image to a binary format.\nThis function receive four arguments and returns two outputs.\nThe first output is the used threshold and the second is the thresholded picture.\n\nThe first input is the image to be thresholded, which should be already converted to grayscale.\n\\texttt{min} is the actual threshold which determines if a pixel is set to zero or to the \\texttt{max} value.\nThe flags will determine which threshold algorithm will be used.\nThe two mainly used flags are \\texttt{cv.THRESH\\_OTSU} and \\texttt{cv.THRESH\\_BINARY\\_INV}.\n\n\\texttt{cv.THRESH\\_BINARY\\_INV} is the simpler one of both.\nAfter calculating the threshold for each pixel the resulting image will be inverted.\nThis kind of image can be used for further processing.\n\n\\texttt{cv.THRESH\\_OTSU} is a more complex algorithm.\nDuring the thresholding process the \\texttt{min} value will be calculated automatically.\nThe \\texttt{cv.THRESH\\_OTSU} flag has to be set as an extra flag to the already given flag.\nNow the \\texttt{min} value will be substitued by the Otsu's calculated value.\n\n\\subsection{Find Contours}\n\n\\texttt{contours, hirachy = cv.findContours(image, return\\_flag, approximation\\_flag)}\n\nA contour can be understood as a curve joining all pixels of the same value like color or intensity.\nThe function receives three arguments and returns two outputs.\nFor the outputs the first is a list with points for the contours.\nThe second one is a list with the same length as the first one with values determing the neighbours and the depth of the contour.\n\nThe fist argument is the image in with the contours will be searched.\nFor best computing time it is recommended to use a grayscale or binary image.\nThe second argument determine which kind of list of contours will be returned.\nThe three recommended flags are \\texttt{cv.RETR\\_LIST}, \\texttt{cv.RETR\\_TREE} and \\texttt{cv.RETR\\_EXTERNAL}.\nFor this project the \\texttt{cv.RETR\\_EXTERNAL} flag is the mostly used.\nWith this flag only the top level contours will be returned without inner contours.\nThe third argument determines how many points will be used for the contour.\nThe flag \\texttt{cv.CHAIN\\_APPROX\\_NONE} is the commonly used to detect all points of a contour.\nThis makes it possible to draw a perfect mask for each found symbol.\n% TODO an example would be nice\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{line10000.png}\n    \\includegraphics[width=.8\\textwidth]{mask10005.png}\n    \\includegraphics[width=.8\\textwidth]{01result.png}\n    \\caption{Example for masking one letter}\n\\end{figure}\n\n\\subsection{Bounding Rectangle}\n\n\\texttt{x, y, w, h = cv.boundingRect(contour)}\n\nFor each contour this function will output the bounding rectangle.\nIt is possible to draw the rectangle or cut the area.\nFor letterdetection this is used to cut out the individual charakters after the masking process.\n\n\\subsection{arcLength and approxPolyDP}\n\n\\texttt{epsilon = value * cv.arcLength(contour, bool)}\n\n\\texttt{approximation = cv.approxPolyDP(contour, epsilon, bool)}\n\nThese functions are used to approximate a contour which isn't in a perfect shape.\nFor example a square which isn't detected correctly can be found with this approximation.\nThe \\texttt{cv.arcLength()} function returns the length of a contour.\nThe bool values dertermine if the contour is closed or just a curve.\nThe \\texttt{cv.approxPolyDP()} function is an implementation of the Ramer-Douglas-Peucker algorithm.\nIn a nutshell it will calculate a contour with lesser points than the original given contour.\nFor more information about this algorithm please visit \\url{https://en.wikipedia.org/wiki/Ramer\\_Douglas\\_Peucker\\_algorithm}.\n\n", "meta": {"hexsha": "e293eaeef0d627838a57a85595794d9db9ab5438", "size": 6044, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/chapters/developer/subsections/opencv.tex", "max_stars_repo_name": "Nauheimer/swtp-ocr", "max_stars_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/src/chapters/developer/subsections/opencv.tex", "max_issues_repo_name": "Nauheimer/swtp-ocr", "max_issues_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/src/chapters/developer/subsections/opencv.tex", "max_forks_repo_name": "Nauheimer/swtp-ocr", "max_forks_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7971014493, "max_line_length": 129, "alphanum_fraction": 0.7796161482, "num_tokens": 1463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4236756220905029}}
{"text": "\n\\chapter{Case Study}\n\\label{chapter4}\n\n\\graphicspath{{Chapter4/figs/}}\n\nThis chapter focuses on discussing about a possible analysis path with MLExplore.js for one real-world dataset. In general terms, this path consist of two stages: (1) Load the dataset and perform a first overview for gaining a general understanding about this, (2) iteratively navigate the data and perform attribute selection and train multiple t-SNE and K-Means models for identifying local and global structural changes (cluster formation) in the data, and (3) explain the results in terms of the original attributes by observing their distribution among clusters or predefined classes and selecting some data instances of interest for perform neighbors analysis.\n\nThe SALURBAL dataset is introduced in \\ref{section1.1}. An additional detail about this dataset is the complexity of the attributes reflecting Urban Landscape, Street Design and Transportation domains for the 1.433 Latin American sub-cities included in the study. Researchers currently have used Finite Mixture Models for the Urban Landscape and Street Design domains to determine profiles emerging from the sub-cities. The first challenge consist of determining the set of hyper-parameters that enables the identification of representative profiles based on entropy and Bayesian Information Criterion. The second challenge is about determining differences among profiles and naming them.\n\nFigure \\ref{fig:salurbal-case-study-1} shows MLExplore.js after the user loads the SALURBAL dataset and by default a t-SNE model is trained using all numerical attributes. Thanks to Navio, it is possible to evidence that many attributes are highly correlated and some others have a high missing value ratio. TRANS\\_PROF is the categorical attribute automatically selected for color encoding. This attribute represents the Street Design profile previously obtained using the Finite Mixture Models. User can also use URBAN\\_PROF (Urban Landscape profile) for color encoding selecting this attribute in the upper-right combobox of the Attribute Selection component.\n\n\\begin{figure}[ht]\n \\centering\n \\includegraphics[width=0.9\\textwidth]{salurbal-case-study-1.png}\n \\caption{First iteration in MLExplore.js for the SALURBAL dataset.}\n \\label{fig:salurbal-case-study-1}\n\\end{figure}\n\nFor both domains, just a subset of attribute are selected for training the models: Street density, Intersection density, Streets per node average, Street length average and circuity average, for Street Density, and Number of urban patches, Patch density, Area-weighted mean patch size, Effective mesh size, Area-weighted mean shape index and Area-weighted mean nearest neighbor distance, for Urban Landscape. MLExplore.js is updated for including in each case only these attributes and training again the t-SNE models with the same hyper-parameters: 20 for perplexity and 5 for learning rate. Figure \\ref{fig:salurbal-case-study-2} evidences the embedding results for this interaction with the Attribute Selection component.\n\n\\begin{figure}[ht]\n \\centering\n \\includegraphics[width=1.0\\textwidth]{salurbal-case-study-2.png}\n \\caption{t-SNE for Street Design (left) and Urban Landscape (right) selected attributes.}\n \\label{fig:salurbal-case-study-2}\n\\end{figure}\n\nBecause the visually identified clusters for both domains seems to be so granularized, dominating local data structure, perplexity t-SNE hyper-parameter can be increased to obtain a more compact group. According to Figure \\ref{fig:salurbal-case-study-3}, for perplexity equal to 50, the resulting embedding is able to locate instances of the same cluster near, as the case of the red cluster in the Street Design embedding (left) and the brown cluster in the Urban Landscape embedding (right). Reasons behind the difficulty of finding an embedding that better reflects the profiles could be that Finite Mixture Models and t-SNE optimize in a different way and the same domain complexity. While Finite Mixture Models is a probabilistic model, t-SNE learns from similarity metrics such as euclidean distance. Maybe, K-Means could works better with the t-SNE for producing clusters that can be visually identified in a more clear way.  \n\n\\begin{figure}[ht]\n \\centering\n \\includegraphics[width=1.0\\textwidth]{salurbal-case-study-3.png}\n \\caption{t-SNE for Street Design (left) and Urban Landscape (right) selected attributes when increasing perplexity to 50.}\n \\label{fig:salurbal-case-study-3}\n\\end{figure}\n\nTwo new t-SNE and K-Means models for Street Design and Urban Landscape domains are trained. Figure \\ref{fig:salurbal-case-study-4} shows the result for the Street Design profile where K-Means clusters are better identified in the t-SNE embedding with less cluster overlapping in comparison with profiles from the Finite Mixture Models. In Attribute Distribution component is possible to observe that the cluster orange characterizes by high values of Street density while the cluster green by high values in Intersection density and Streets per node average. Unfortunately, K-Means evidences some limitations when instances have outlier values tending to create an independent cluster for that few instances. In this case, Colon, Panama, having a very high Circuity average. Urban Landscape domain, Figure \\ref{fig:salurbal-case-study-5}, have a similar problem creating two clusters with very few sub-units.\n\n\\begin{figure}[ht]\n \\centering\n \\includegraphics[width=0.8\\textwidth]{salurbal-case-study-4.png}\n \\caption{t-SNE and K-Means for Street Design selected attributes and clustering results in the Attribute Distribution panel.}\n \\label{fig:salurbal-case-study-4}\n\\end{figure}\n\n\\begin{figure}[ht]\n \\centering\n \\includegraphics[width=0.8\\textwidth]{salurbal-case-study-5.png}\n \\caption{t-SNE and K-Means for Urban Landscape selected attributes and clustering results in the Attribute Distribution panel.}\n \\label{fig:salurbal-case-study-5}\n\\end{figure}", "meta": {"hexsha": "a25f2e83676093ddc15277c8720f198b981d900f", "size": 5934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4/chapter4.tex", "max_stars_repo_name": "fabiancpl/master-thesis", "max_stars_repo_head_hexsha": "b256173eeda51b36d708536343dda6ea29c54470", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-26T21:45:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-26T21:45:55.000Z", "max_issues_repo_path": "Chapter4/chapter4.tex", "max_issues_repo_name": "fabiancpl/master-thesis", "max_issues_repo_head_hexsha": "b256173eeda51b36d708536343dda6ea29c54470", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4/chapter4.tex", "max_forks_repo_name": "fabiancpl/master-thesis", "max_forks_repo_head_hexsha": "b256173eeda51b36d708536343dda6ea29c54470", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 114.1153846154, "max_line_length": 933, "alphanum_fraction": 0.8110886417, "num_tokens": 1308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4236756220905029}}
{"text": "\n\n    \\filetitle{hpf}{Hodrick-Prescott filter with tunes (aka LRX filter)}{tseries/hpf}\n\n\t\\paragraph{Syntax}\\label{syntax}\n\n\\begin{verbatim}\n[T,C,CutOff,Lambda] = hpf(X)\n[T,C,CutOff,Lambda] = hpf(X,Range,...)\n\\end{verbatim}\n\n\\paragraph{Syntax with output arguments\nswapped}\\label{syntax-with-output-arguments-swapped}\n\n\\begin{verbatim}\n[C,T,CutOff,Lambda] = hpf2(X)\n[C,T,CutOff,Lambda] = hpf2(X,Range,...)\n\\end{verbatim}\n\n\\paragraph{Input arguments}\\label{input-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{X} {[} tseries {]} - Input tseries object that will be\n  filtered.\n\\item\n  \\texttt{Range} {[} numeric {]} - Date Range on which the input data\n  will be filtered; \\texttt{Range} can be \\texttt{Inf},\n  \\texttt{{[}startdata,Inf{]}}, or \\texttt{{[}-Inf,enddate{]}}; if not\n  specifired, \\texttt{Inf} (i.e.~the entire available Range of the input\n  series) is used.\n\\end{itemize}\n\n\\paragraph{Output arguments}\\label{output-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{T} {[} tseries {]} - Low-frequency (trend) component.\n\\item\n  \\texttt{C} {[} tseries {]} - High-frequency (cyclical or gap)\n  component.\n\\item\n  \\texttt{CutOff} {[} numeric {]} - Cut-off periodicity; periodicities\n  above the cut-off are attributed to trends, periodicities below the\n  cut-off are attributed to gaps.\n\\item\n  \\texttt{Lambda} {[} numeric {]} - Smoothing parameter actually used;\n  this output argument is useful when the option \\texttt{'cutoff='} is\n  used instead of \\texttt{'lambda='}.\n\\end{itemize}\n\n\\paragraph{Options}\\label{options}\n\n\\begin{itemize}\n\\item\n  \\texttt{'cutoff='} {[} numeric \\textbar{} \\emph{empty} {]} - Cut-off\n  periodicity in periods (depending on the time series frequency); this\n  option can be specified instead of \\texttt{'lambda='}; the smoothing\n  parameter will be then determined based on the cut-off periodicity.\n\\item\n  \\texttt{'cutoffYear='} {[} numeric \\textbar{} \\emph{empty} {]} -\n  Cut-off periodicity in years; this option can be specified instead of\n  \\texttt{'lambda='}; the smoothing parameter will be then determined\n  based on the cut-off periodicity.\n\\item\n  \\texttt{'gamma='} {[} numeric \\textbar{} tseries \\textbar{} \\emph{1}\n  {]} - Weight or weights on the deviations of the trend from\n  observations; it only makes sense to use this option to make the\n  signal-to-noise ratio time-varying; see the optimisation problem\n  below.\n\\end{itemize}\n\n\\texttt{'infoSet='} {[} \\texttt{1} \\textbar{} \\emph{\\texttt{2}} {]} -\nInformation set assumption used in the filter: \\texttt{1} runs a\none-sided filter, \\texttt{2} runs a two-sided filter.\n\n\\begin{itemize}\n\\item\n  \\texttt{'lambda='} {[} numeric \\textbar{} \\emph{\\texttt{@auto}} {]} -\n  Smoothing parameter; needs to be specified for tseries objects with\n  indeterminate frequency. See Description for default values.\n\\item\n  \\texttt{'level='} {[} tseries {]} - Time series with hard tunes and\n  soft tunes on the level of the trend.\n\\item\n  \\texttt{'change='} {[} tseries {]} - Time series with hard tunes and\n  soft tunes on the change in the trend.\n\\item\n  \\texttt{'log='} {[} \\texttt{true} \\textbar{} \\emph{\\texttt{false}} {]}\n  - Logarithmise the data before filtering, de-logarithmise afterwards.\n\\end{itemize}\n\n\\paragraph{Description}\\label{description}\n\n\\subparagraph{The underlying optimisation\nproblem}\\label{the-underlying-optimisation-problem}\n\nThe function \\texttt{hpf} solves a constrained optimisation problem\ndescribed by the following Lagrangian\n\n\\[\\min_{\\bar y_t, \\omega_t, \\sigma_t}\n\\underbrace{\n\\tsum \\lambda \\left( \\Delta \\bar y_t - \\Delta \\bar y_{t-1} \\right)^2\n+ \\tsum \\gamma_t \\left( \\bar y_t - y_t \\right)^2}_\\text{Plain HP with\ntime-varying signal-to-noise ratio} + \\cdots\\] \\[\\cdots +\n\\underbrace{\\tsum u_t \\left( \\bar y_t - a_t \\right)^2}_\\text{Soft level tunes}\n+ \\underbrace{\\tsum v_t \\left( \\Delta \\bar y_t - b_t\n\\right)^2}_\\text{Soft growth tunes} +\n\\underbrace{\\tsum \\omega_t \\left( \\bar y_t - c_t \\right)}_\\text{Hard level tunes}\n+ \\underbrace{\\tsum \\sigma_t \\left( \\Delta \\bar y_t - d_t\n\\right)}_\\text{Hard growth tunes},\\]\n\nwhere\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  $\\Delta$ is the first-difference operator;\n\\item\n  $\\lambda$ is a (scalar) smoothing parameter;\n\\item\n  $y_t$ are user-supplied observations;\n\\item\n  $\\bar y_t$ is the fitted trend;\n\\item\n  $\\gamma_t$ are user-supplied weights to modify the basic\n  signal-to-noise ratio over time (the default setting is $\\gamma_t=1$),\n  entered in the option \\texttt{'gamma='};\n\\item\n  $a_t$ and $u_t$ are soft tunes on the level of the trend and the\n  weights associated with these soft level tunes, respectively, entered\n  together as complex numbers in the option \\texttt{'level='};\n\\item\n  $b_t$ and $v_t$ are soft tunes on the change in the level of the trend\n  and the weights associated with these soft growth tunes, respectively,\n  entered together as complex numbers in the option \\texttt{'growth='};\n\\item\n  $c_t$ are hard tunes on the level of the trend, entered as real\n  numbers in the option \\texttt{'level='};\n\\item\n  $d_t$ are hard tunes on the change in the level of the trend, entered\n  as real numbers in the option \\texttt{'growth='};\n\\item\n  $\\omega_t$ are lagRange multipliers on the hard level tunes (note that\n  these are computed as part of the optimisation problem, not entered by\n  the user);\n\\item\n  $\\sigma_t$ are lagRange multipliers on the hard growth tunes (note\n  that these are computed as part of the optimisation problem, not\n  entered by the user).\n\\end{itemize}\n\nEach of the summations in the above Lagrangian goes over those periods\nin which the respective bracketed terms are defined (observations or\ntunes exist). You can combine any number of any tunes in one run of\n\\texttt{hpf}, including out-of-sample tunes (see below).\n\n\\subparagraph{How to enter the tunes}\\label{how-to-enter-the-tunes}\n\n\\begin{itemize}\n\\item\n  The hard tunes and soft tunes on the level of the trend are entered as\n  time series through the option \\texttt{'level='}.\n\\item\n  The hard tunes and soft tunes on the change in the trend are entered\n  as time series through the option \\texttt{'change='}.\n\\item\n  In the tseries objects entered through \\texttt{'level='} and/or\n  \\texttt{'change='}, you can combine any number of hard and soft tune.\n  In each particular period, you can obviously specify only a hard tune\n  or only a soft tune. You can think of hard tunes as a special case of\n  soft tunes with infinitely large weights.\n\\item\n  A hard tune is specified as a plain real number (i.e.~a number with a\n  zero complex part).\n\\item\n  A soft tune must be entered as a complex number whose real part\n  specifies the tune itself, and the imaginary part specifies the\n  \\emph{inverse} of the weight, i.e. $1/v_t$ or $1/u_t$, on that tune in\n  that period. Note that if the weight goes to infinity, the imaginary\n  part becomes zero and the tune becomes a hard tune.\n\\end{itemize}\n\n\\subparagraph{Out-of-sample tunes}\\label{out-of-sample-tunes}\n\nTunes can be imposed also at dates before the first observation of the\ninput series, or after the last observation. In other words, the time\nseries in \\texttt{'level='} and/or \\texttt{'growth='} can have a more\nextended Range (at either side) than the filtered input series.\n\n\\subparagraph{Default smoothing\nparameters}\\label{default-smoothing-parameters}\n\nIf the user does not specify the smoothing parameter using the\n\\texttt{'lambda='} option (or reassigns the default \\texttt{@auto}), a\ndefault value is used. The default value is based on common practice and\ncan be calculated using the date frequency of the input time series as\n$\\lambda = 100 \\cdot f^2$, where $f$ is the frequency (yearly=1,\nhalf-yearly=2, quarterly=4, bi-monthly=6, monthly=12). This gives the\nfollowing default values:\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  100 for yearly time series (cut-off periodicity of 19.79 years);\n\\item\n  400 for half-yearly time series (cut-off periodicity of 14.02 years);\n\\item\n  1,600 for quarterly time series (cut-off periodicity of 9.92 years);\n\\item\n  3,600 for bi-monthly time series (cut-off periodicity of 8.11 years);\n\\item\n  14,400 for monthly time series (cut-off periodicity of 5.73 years).\n\\end{itemize}\n\nNote that there is no default value for data with indeterminate or daily\nfrequency: for these types of time series, you must always use the\noption ``lambda=''.\n\n\\paragraph{Example}\\label{example}\n\n\n", "meta": {"hexsha": "7d5e56da4774a405efef3f9fc420d44e74327ff0", "size": 8389, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/tseries/hpf.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/tseries/hpf.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/tseries/hpf.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 37.6188340807, "max_line_length": 85, "alphanum_fraction": 0.7307187984, "num_tokens": 2428, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.6688802669716106, "lm_q1q2_score": 0.42367561701388845}}
{"text": "%! TEX program = xelatex\n%! TEX root = lecture2_slide.tex\n\n\\title{Programming Language Theory}\n\\subtitle{Higher-Order Functions}\n\\begin{document}\n\n{\\usebackgroundtemplate{\\includegraphics[width=\\paperwidth]{image.png}}\n\\begin{frame}\\maketitle\\end{frame}}\n\n\\section{Simply Typed $\\lambda$-Calculus: Statics}\n\n\\begin{frame}{Typing judgement}\n  A \\alert{typing judgement} is of the form\n  \\[\n    \\Gamma \\vdash M : \\sigma\n  \\]\n  saying the \\emph{term $M$ is of type $\\sigma$ under the context $\\Gamma$}\n  where \n  \\begin{description}\n    \\item[context $\\Gamma$] free variables $x : \\tau$ available in $M$\n    \\item[term $M$] possibly with free variables in $\\Gamma$,\n    \\item[type $\\sigma$] for $M$\n  \\end{description}\n\n  \\[\n    x_1:\\tau_1, x_2: \\tau_2 \\vdash x_1 : \\tau_1\n  \\]\n  `\\emph{Under the context consisting of variables $x_1:\\tau_1, x_2:\\tau_2$, the term $x_1$ is of type $\\tau_1$.}'\n\\end{frame}\n\n\\begin{frame}{Context}\n  \n\\begin{definition}\n    A \\emph{typing context}~$\\Gamma$\n    is a sequence\n    \\[\n      \\Gamma \\equiv x_1 : \\sigma_1,\\; x_2 : \\sigma_2,\\; \\ldots,\\; x_n : \\sigma_n\n    \\]\n    of \\alert{\\emph{distinct variables}} $x_i$ of type $\\sigma_i$.\n\\end{definition}\n\n\\begin{definition}\n  The membership judgement $\\Gamma \\ni (x : \\sigma)$ is defined inductively as follows.\n  \n  \\begin{multicols}{2}\n    \\begin{prooftree}\n      \\AXC{$\\vphantom{\\Gamma}$}\n      \\RightLabel{(here)}\n      \\UIC{$\\Gamma, x : \\sigma \\ni (x : \\sigma)$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$\\Gamma \\ni (x : \\sigma)$}\n      \\RightLabel{(there)}\n      \\UIC{$\\Gamma, y : \\tau \\ni (x : \\sigma)$}\n    \\end{prooftree}\n  \\end{multicols}\n\\end{definition}\n\\end{frame}\n\n\n\\begin{frame}{Higher-order function type}\n\n  \n\\begin{definition}\n  Define the judgement $\\tau : \\type$ by\n  \\begin{multicols}{2}\n    \\begin{prooftree}\n      \\AXC{$\\sigma$ is a type variable}\n      \\RightLabel{(tvar)}\n      \\UIC{$\\sigma : \\type$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$\\sigma : \\type$}\n      \\AXC{$\\tau   : \\type$}\n      \\RightLabel{(fun)}\n      \\BIC{$\\sigma \\to \\tau : \\type$}\n    \\end{prooftree}\n  \\end{multicols}\n  where $\\sigma\\to\\tau$ represents a function type from $\\sigma$ to $\\tau$.\n\n  Also $\\sigma_1 \\to \\tau_1 = \\sigma_2 \\to \\tau_2$ if and only if $\\sigma_1 = \\sigma_2 \\text{ and } \\tau_1 = \\tau_2$.\n\\end{definition}\n\\mode<presentation>{\\vfill}\n\\begin{block}{Convention}\n\\[\n  \\sigma_1 \\to \\sigma_2 \\to \\dots \\sigma_n \\quad  \\defeq\\quad \\sigma_1 \\to\n  (\\sigma_2 \\to ( \\dots \\to (\\sigma_{n-1} \\to \\sigma_n)\\dots))\n\\]\n\\end{block}\n\n\\end{frame}\n\n\\begin{frame}\n  The function type is \\alert{higher-order}, because\n  \\begin{enumerate}\n    \\item functions can be arguments of another function;\n    \\item functions can be the result of a computation.\n  \\end{enumerate}\n  \\begin{example}\n    \\begin{description}\n      \\item[$\\;(\\sigma_1 \\to \\sigma_2) \\to \\tau$] a function type whose argument is of type $\\sigma_1 \\to \\sigma_2$; \n      \\item[$\\;\\sigma_1 \\to (\\sigma_2 \\to \\tau)$] a function whose return type is $\\sigma_2 \\to \\tau$. \n    \\end{description}\n  \\end{example}\n    \n\\mode<presentation>{\\vfill}\nFor a term $M$, how to construct a \\emph{typing judgement}\n\\[\n  \\Gamma \\vdash M : \\sigma \\to \\tau\n\\]\n\\end{frame}\n\n%\\begin{frame}{Hypothetical judgement}\n%  A \\emph{hypothetical judgement} (or, an inference rule) is of the form\n%  \\begin{prooftree}\n%    \\AXC{$J_1$}\n%    \\AXC{$J_2$}\n%    \\AXC{$\\dots$}\n%    \\AXC{$J_n$}\n%    \\RightLabel{(rule)}\n%    \\QuaternaryInfC{$J$}\n%  \\end{prooftree}\n%  consisting of \n%  \\begin{description}\n%    \\item[hypothesis] a set of judgements $J_i$, for $1 \\leq i \\leq n$\n%    \\item[name] the name for the reason why $J_i$'s imply $J$\n%    \\item[conclusion] a single judgement $J$\n%  \\end{description}\n%  Examples include\n%  \\begin{enumerate}\n%    \\item The formation of $\\lambda$-terms (var), (app), and (abs).\n%    \\item The formation of $\\alpha$-equivalence $=_\\alpha$.\n%    \\item The formation of simple types $\\mathbb{T}$.\n%  \\end{enumerate}\n%\\end{frame}\n\n\\begin{frame}{Typing rule -- Curry-style typing system}\n  A \\emph{typing rule} is an inference rule with its conclusion a\n  typing judgement.\n  \n  \\begin{prooftree}\n    \\AXC{$\\Gamma \\ni (x : \\sigma)$}\n    \\RightLabel{(var)}\n    \\UIC{$\\Gamma \\vdash_i x : \\sigma$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Gamma, x : \\sigma \\vdash_i M : \\tau$}\n    \\RightLabel{(abs)}\n    \\UIC{$\\Gamma \\vdash_i \\lambda x.\\; M : \\sigma \\to \\tau$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Gamma \\vdash_i M : \\sigma \\to \\tau$}\n    \\AXC{$\\Gamma \\vdash_i N : \\sigma$}\n    \\RightLabel{(app)}\n    \\BIC{$\\Gamma \\vdash_i M\\;N : \\tau$}\n  \\end{prooftree}\n\n\\mode<presentation>{\\vfill}\nIt is known as the \\alert{implicit typing} system since the typing information is an add-on to the term.\n\\end{frame}\n\n\n%\\begin{frame}{Derivation}\n%  Given a set $\\mathcal{R}$ of hypothetical judgements, a \\emph{derivation} of\n%  \\begin{prooftree}\n%    \\AXC{$J_1$}\n%    \\AXC{$J_2$}\n%    \\AXC{$\\dots$}\n%    \\AXC{$J_n$}\n%    \\QuaternaryInfC{$J$}\n%  \\end{prooftree}\n%  is a tree of instances of rules in $\\mathcal{R}$ composed with $J_i$'s as the top-level hypothesises.\n%\n%  A judgement $J$ is \\emph{derivable} (with assumptions $J_i$'s) if there is derivation whose root is $J$ (with assumptions $J_i$'s).\n%\n%  \\begin{example}\n%    The fact that\n%    \\[\n%      \\lambda x\\,y.\\, y\n%    \\]\n%    is a $\\lambda$-term means the judgement $\\lambda x\\,y.\\, y$ is derivable\n%    from the formation rules of $\\lambda$-terms without any assumption.\n%  \\end{example}\n%\\end{frame}\n\n\\begin{frame}{Typing derivation}\n  The judgement $\\vdash \\lambda x.\\, x : \\sigma \\to \\sigma$, for all $\\sigma\n  \\in \\mathbb{T}$ has a derivation\n  \\begin{prooftree}\n    \\AXC{}\n    \\RightLabel{(var)}\n    \\UIC{$x : \\sigma \\vdash_i x : \\sigma$}\n    \\RightLabel{(abs)}\n    \\UIC{$\\vdash_i \\lambda x.\\; x : (\\sigma \\to \\sigma)$}\n  \\end{prooftree}\n\n  The judgement $ \\vdash \\lambda x\\,y.\\, x : \\sigma \\to \\tau \\to \\sigma$\n  has a derivation\n\\begin{prooftree}\n  \\AXC{}\n  \\RightLabel{(var)}\n  \\UIC{$x : \\sigma, y: \\tau \\vdash_i x : \\sigma$}\n  \\RightLabel{(abs)}\n  \\UIC{$x : \\sigma \\vdash_i \\lambda y.\\, x : \\tau \\to \\sigma$}\n  \\RightLabel{(abs)}\n  \\UIC{$\\vdash_i \\lambda x\\,y.\\, x : \\sigma \\to \\tau \\to \\sigma$}\n\\end{prooftree}\n\n  Not every $\\lambda$-term has a type: \n  \\[\n    \\lambda x.\\, x\\,x\n  \\]\n  there is no $\\tau$ satisfying $\\vdash \\lambda x.\\, x\\;x : \\tau$.\n\\end{frame}\n\n\\begin{frame}{Syntax-directedness}\n  A typing system is \\emph{syntax-directed} if it has \\emph{exactly} one typing rule\n  for each term construct. Therefore, \n  \n  \\begin{lemma}[Typing inversion]\n    Suppose \n    \\[\n      \\Gamma \\vdash_i M : \\tau\n    \\]\n    is derivable. If \n    \\begin{description}\n      \\item[$M \\equiv x$] then $x : \\tau$ occurs in $\\Gamma$.\n      \\item[$M \\equiv \\lambda x.\\, M'$] then $\\tau = \\sigma \\to \\tau'$ for some $\\sigma$ and $\\Gamma, x:\\sigma \\vdash_i M' : \\tau'$.\n      \\item[$M \\equiv L\\;N$] there is some $\\sigma$ such that $\\Gamma \\vdash_i L : \\sigma \\to \\tau$ and $\\Gamma \\vdash_i N : \\sigma$.\n    \\end{description}\n  \\end{lemma}\n\\end{frame}\n\n\n\n\\begin{frame}{Explicit typing: Typed terms}\n\\begin{definition}[Typed terms]\n  The formation $M : \\term_{\\lambda_\\to}$ of typed terms is defined by\n    \\begin{prooftree}\n      \\AXC{$x \\in V$}\n      \\UIC{$x : \\term_{\\lambda_\\to}$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$M : \\term_{\\lambda_\\to}$}\n      \\AXC{$N : \\term_{\\lambda_\\to}$}\n      \\BIC{$M\\, N : \\term_{\\lambda_\\to}$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$M : \\term_{\\lambda_\\to}$}\n      \\AXC{$x \\in V$}\n      \\AXC{$\\tau : \\type$}\n      \\TIC{$\\lambda {\\color{red}x:\\tau}.\\; M : \\term_{\\lambda_\\to}$}\n    \\end{prooftree}\n\\end{definition}\n\\end{frame}\n\n\\begin{frame}{Explicit typing: Typing rules}\n\\begin{definition}[Typing Rules]\n  Typing derivations on \\emph{typed terms} are defined by \n  \\begin{prooftree}\n    \\AXC{$\\Gamma \\ni (x : \\sigma)$}\n    \\RightLabel{(var)}\n    \\UIC{$\\Gamma \\vdash_e x : \\sigma$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Gamma \\vdash_e M : \\sigma \\to \\tau$}\n    \\AXC{$\\Gamma \\vdash_e N : \\sigma$}\n    \\RightLabel{(app)}\n    \\BIC{$\\Gamma \\vdash_e M\\;N : \\tau$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Gamma, {\\color{red}x : \\sigma} \\vdash_e M : \\tau$}\n    \\RightLabel{(abs)}\n    \\UIC{$\\Gamma \\vdash_e \\lambda {\\color{red}x : \\sigma} .\\; M : \\sigma \\to \\tau$}\n  \\end{prooftree}\n\\end{definition}\n\n\\end{frame}\n\\begin{frame}{Explicit typing: Unicity}\n\\begin{proposition}\n  For every typed term $M$, context~$\\Gamma$, and types $\\sigma_i$, \n  \\[\n    \\Gamma \\vdash_e M : \\sigma_1\n    \\quad\\text{and}\\quad\n    \\Gamma \\vdash_e M : \\sigma_2\n    \\implies\n    \\sigma_1 = \\sigma_2\n  \\]\n\\end{proposition}\n\\begin{proof}[Proof sketch]\n  Use the inversion lemma and the structural induction on $M$.\n\n  E.g., suppose that $M$ is of the form\n  \\[\n    L\\;M'\n  \\]\n  By inversion there are $\\tau_i$ such that $\\Gamma \\vdash_e L: \\tau_i \\to\n  \\sigma_i$ and $\\Gamma \\vdash_e M': \\tau_i$. By induction hypothesis, $\\tau_1 \\to\n  \\sigma_1 = \\tau_2 \\to \\sigma_2$, so $\\sigma_1 = \\sigma_2$.\n\\end{proof}\n\\end{frame}\n\n\\begin{frame}{Exercise}\n  \\begin{enumerate}\n    \\item Derive the judgement\n      \\[\n        \\vdash \\lambda f\\,g\\,x.\\, f\\,x\\, (g\\,x) : (\\sigma \\to \\tau \\to \\rho) \\to\n        (\\sigma\\to\\tau) \\to \\sigma\\to\\rho \n      \\]\n      for every $\\sigma, \\tau, \\rho \\in \\mathbb{T}$.\n\n    \\item Describe all possible types for Church numeral $\\bc_{n}$.\n\n    \n  \\end{enumerate}\n\n\\end{frame}\n\n\n\\begin{frame}{Type erasure}\n  An \\emph{erasing map} $|-|\\colon \\term_{\\lambda_\\to} \\to \\term_{\\lambda}$ is defined by\n  \\begin{align*}\n    |x| & = x \\\\\n    |M\\; N| & = |M|\\;|N| \\\\\n    |\\lambda x:\\sigma.\\, M| & = \\lambda x.\\, |M|\n  \\end{align*}\n  \\begin{example}\n    \\begin{enumerate}\n      \\item $|\\lambda (f: \\sigma \\to \\tau)\\,(x: \\sigma).\\, f\\;x| = \\lambda f\\, x.\\, f\\;x$\n      \\item $|(\\lambda (x: \\sigma)\\,(y: \\tau). y)\\;z| = (\\lambda x\\,y.\\, y)\\; z$\n    \\end{enumerate}\n  \\end{example}\n\n  $|-|$ is an translation from $\\term_{\\lambda_\\to}$ to $\\term_{\\lambda}$.\n  Does $|-|$ respect the behaviour of $\\term_{\\lambda_\\to}$?\n\\end{frame}\n\\begin{frame}{From typed terms to untyped and back}\n\\begin{proposition}\n  Let $M$ and $N$ be typed $\\lambda$-terms in~$\\term_{\\lambda_\\to}$. Then, \n  \\begin{align*}\n    \\Gamma  \\vdash_e M : \\sigma & \\text{ implies } \\Gamma \\vdash_i |M| :\n    \\sigma \\\\ \n    M \\reduce N & \\text{ implies } |M| \\reduce |N|\n  \\end{align*}\n\\end{proposition}\n\n\\begin{proposition}\n  Let $M$ and $N$ be $\\lambda$-terms in~$\\term_{\\lambda}$. Then, \n  \\begin{enumerate}\n  \\item If $\\Gamma \\vdash_i M : \\sigma$, then there is $M' : \\term_{\\lambda_\\to}$ with \n        $|M'| = M\n        \\quad\\text{and}\\quad\n        \\Gamma \\vdash_e M' : \\sigma$\n      \\item If $M \\reduce N$ and $M = |M'|$ for some $M' : \\term_{\\lambda_\\to}$,\n      then there exists $N'$ with $|N'| = N$ and $M' \\reduce N'$.\n    \\end{enumerate}\n\\end{proposition}\n\\end{frame}\n\n\\begin{frame}{Type inference}\n  Can we answer the following questions\n  \\begin{description}\n    \\item[Typability] Given a closed term $M$, is there a type $\\sigma$\n      such that $\\vdash M : \\sigma$? \n    \\item[Type checking] Given $\\Gamma$ and $\\sigma$, is $\\Gamma \\vdash M : \\sigma$ derivable?\n  \\end{description}\n  algorithmically?\n  \n  Typability is reducible to type checking problem of\n  \\[\n    x_0: \\tau \\vdash \\textbf{K}_1\\;x_0\\;M : \\tau\n  \\]\n\n  \\begin{theorem}\n    Type checking is \\emph{decidable}\n    in simply typed $\\lambda$-calculus.\n  \\end{theorem}\n\n\\mode<presentation>{\\vfill}\nCheck \\emph{bidirectional type inference}.\n\\subsection*{Exercise}\n  \n\\end{frame}\n\n\\section{Programming in Simply Typed $\\lambda$-Calculus}\n\n\\begin{frame}[allowframebreaks]{Church encodings of natural numbers}\nThe type of natural numbers is of the form\n\\[\n  \\nat_\\tau \\defeq (\\tau \\to \\tau) \\to \\tau \\to \\tau\n\\]\nfor every type $\\tau \\in \\T$.\n  \n  \\begin{description}\n    \\item[Church numerals]\n      \\begin{align*}\n        & \\bc_n \\defeq \\lambda f\\,x.\\,\n        f^n x \\\\\n        \\vdash{} & \\bc_n : \\nat_\\tau\n      \\end{align*}\n    \\item[Successor]\n      \\begin{align*}\n        & \\suc \\defeq \\lambda n \\,f\\,x\\,.\\;f\\;(n\\;f\\;x) \\\\\n        \\vdash{} & \\suc : \\nat_\\tau \\to \\nat_\\tau\n      \\end{align*}\n    \\item[Addition]\n      \\begin{align*}\n        & \\add \\defeq \\lambda n\\,m\\,f\\,x.\\; (m\\;f)\\;(n\\;f\\;x) \\\\\n        \\vdash{} & \\add : \\nat_\\tau \\to \\nat_\\tau \\to \\nat_\\tau\n      \\end{align*}\n    \\item[Muliplication] \n      \\begin{align*}\n        & \\mul \\defeq \\lambda n\\,m\\,f\\,x.\\, (m\\;(n\\;f))\\;x\\\\\n      \\vdash{} & \\mul : \\nat_\\tau \\to \\nat_\\tau \\to \\nat_\\tau\n      \\end{align*}\n    \\item[Conditional]\n      \\begin{align*}\n        & \\ifz \\defeq \\lambda n\\,x\\,y.\\, n\\;(\\lambda z.\\, x)\\;y\\\\\n        \\vdash {} & \\ifz : ?\n      \\end{align*}\n  \\end{description}\nThe type of~$\\ifz$ may not be as obvious as you may expect.\nTry to find one as general as possible and justify your guess.\n\n\\end{frame}\n\\begin{frame}{Church encodings of boolean values}\nWe can also define the type of Boolean values \nfor each type variable as\n\\[\n  \\bool_\\tau \\defeq \\tau \\to \\tau \\to \\tau\n\\]\n\\begin{description}\n  \\item[Boolean values]\n      \\[\n        \\true \\defeq \\lambda x\\,y.\\,x \n        \\quad\\text{and}\\quad\n        \\false \\defeq \\lambda x\\,y.\\,y \n      \\]\n  \\item[Conditional]\n    \\begin{align*}\n      & \\cond \\defeq \\lambda b\\,x\\,y.\\, b\\,x\\,y\\\\\n      \\vdash {} & \\cond : \\bool_{\\tau} \\to \\tau \\to \\tau \\to \\tau\n    \\end{align*}\n\\end{description}\n\\end{frame}\n\n\\begin{frame}{Exercise}\n  \\begin{enumerate}\n    \\item Define conjunction $\\mathtt{and}$, disjunction $\\mathtt{or}$, and\n      negation $\\mathtt{not}$ in simply typed lambda calculus.\n\n    \\item Prove that $\\mathtt{and}$, $\\mathtt{or}$, and $\\mathtt{not}$ are well-typed.\n  \\end{enumerate}\n  \n\\end{frame}\n\n\n\\section{Properties of Simply Typed $\\lambda$-Calculus}\n\n\n\\begin{frame}[c]{Type safety = Preservation + Progress}\n\n\\begin{quote}\n  ``Well-typed programs cannot `go wrong'.''\\\\\n  \\hfill ---(Milner, 1978)\n\\end{quote}\n\n\\begin{description}\n  \\item[Preservation] If $\\Gamma \\vdash M : \\sigma$ is derivable and $M \\onereduce N$, then $\\Gamma \\vdash N : \\sigma$.\n  \\item[Progress] If $\\Gamma \\vdash M : \\sigma$ is derivable, then either $M$ is in \\emph{normal form} or there is $N$ with $M \\onereduce N$.\n\\end{description}\n\n\\end{frame}\n\n\\begin{frame}[allowframebreaks]{Converse of Preservation}\n\\begin{example}\n  Recall that \n  \\begin{enumerate}\n    \\item $\\mathbf{I} = \\lambda x.\\, x$\n    \\item $\\mathbf{K}_1 = \\lambda x\\,y.\\, x$\n    \\item $\\Omega = (\\lambda x.\\, x\\,x)\\,(\\lambda x.\\, x\\,x)$\n  \\end{enumerate}\n  and $\\mathbf{K}_1\\,\\mathbf{I}\\,\\Omega \\reduce \\mathbf{I}$. However, \n  \\[\n    \\vdash \\mathbf{I} : \\sigma \\to \\sigma\n    \\notimplies\n    \\vdash \\mathbf{K}_1\\;\\mathbf{I}\\;\\Omega : \\sigma \\to \\sigma.\n  \\]\n\\end{example}\nHow to prove it?\n\\framebreak\n\\begin{lemma}[Typability of subterms]\n  Let $M$ be a term with $\\Gamma \\vdash M : \\tau$ derivable. Then, for every\n  subterm $M'$ of~$M$ there exists $\\Gamma'$ such that\n  \\[\n    \\Gamma' \\vdash M' : \\sigma'.\n  \\]\n\\end{lemma}\n\\begin{proof}\n  By induction on $\\Gamma \\vdash M : \\sigma$.\n\\end{proof}\n  $\\Omega$ is not typable, so $\\mathbf{K}_1\\,\\mathbf{I}\\,\\Omega$ is not typable.\n\\end{frame}\n\n\\begin{frame}{A prelude to the preservation proof}\n    \\begin{description}\n      \\item[Weakening] If $\\Gamma \\vdash M : \\tau$ and $x \\not\\in \\Gamma$, then\n        $\\Gamma, x : \\sigma \\vdash M : \\tau$. \n      \\item[Substitution] If $\\Gamma, x : \\tau \\vdash M : \\sigma$ and $\\Gamma\n        \\vdash N : \\tau$ then $\\Gamma \\vdash M\\subst{N}{x} : \\sigma$.\n    \\end{description}\n\n  \\begin{corollary}[Variable renaming]\n    If $\\Gamma, x : \\tau \\vdash M :\\sigma$ and $y \\not\\in \\mathrm{dom}(\\Gamma)$, then $ \\Gamma, y : \\tau \\vdash M\\subst{y}{x} :\n    \\sigma$\n    where $\\mathrm{dom}(\\Gamma)$\n    denotes the set of variables which occur in $\\Gamma$.\n  \\end{corollary}\n  \\begin{proof}\n    $y$ is not in $\\Gamma$, so \n      $\\Gamma, y : \\tau, x : \\tau \\vdash M$\n    by weakening and by definition $\\Gamma, y : \\tau \\vdash y : \\tau$.\n    Thus, by substitution, we have\n    \\[\n      \\Gamma, y : \\tau \\vdash M\\subst{x}{y} : \\sigma\n    \\]\n  \\end{proof}\n\\end{frame}\n\n\\begin{frame}{Preservation Theorem}\n  \\begin{theorem}\n    If $\\Gamma \\vdash M : \\sigma$ is derivable and $M \\onereduce N$, then $\\Gamma \\vdash N : \\sigma$. \n  \\end{theorem}\n  \\begin{proof}[Proof sketch]\n  By induction on both the derivation of $\\Gamma \\vdash M :\n  \\sigma$ and $M \\onereduce N$.\n\n  The only non-trivial case is\n  \\[\n    \\Gamma \\vdash (\\lambda  x_1 : \\tau .\\, M_1)\\; N : \\sigma%    \\quad\\text{and}\\quad %    (\\lambda (x_1 : \\tau).\\, M_1)\\;N \\onereduce M_2\\subst{x_2}{N}\n  \\]\n  with the substitution lemma applied to\n  \\[\n    \\Gamma, x_1 : \\tau \\vdash M_1 : \\sigma\n    \\quad\\text{and}\\quad\n    \\Gamma \\vdash N : \\tau.\n  \\]\n\\end{proof}\n  \n\\end{frame}\n\n\\begin{frame}{Normal form}\n  The notion of normal form can be characterised syntactically:\n  \\begin{definition}\n    Define judgements $\\texttt{Neutral}\\;M$ and $\\texttt{Normal}\\;M$ mutually by\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{\\Gamma}$}\n        \\UIC{$\\texttt{Neutral}\\;x$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\neutral\\;M$}\n        \\AXC{$\\normal\\;N$}\n        \\BIC{$\\neutral\\;M\\;N$}\n      \\end{prooftree}\n      \\columnbreak\n      \\begin{prooftree}\n        \\AXC{$\\neutral\\;M$}\n        \\UIC{$\\normal\\;M$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\normal\\;M$}\n        \\UIC{$\\normal\\;\\lambda x.\\,M$}\n      \\end{prooftree}\n    \\end{multicols}\n  \\end{definition}\n  \\textbf{Idea.} $\\neutral\\;M$ (resp.\\, $\\normal\\;M$) is derivable\n  iff \n  \\[\n    M \\equiv x\\;N_1 \\cdots N_k\n    \\quad\\text{and}\\quad\n    M \\equiv \\lambda x_1 \\cdots x_n .\\, x\\;N_1 \\cdots N_k\n  \\]\n  respectively where $N_i$'s are in normal form.\n\\end{frame}\n\n\\begin{frame}{Soundness and completeness of the inductive characterisation}\n  \\begin{lemma}\n    Let $M$ be an untyped term.\n    \\begin{description}\n      \\item[Soundness] If $\\normal\\;M$ (resp.\\ $\\neutral\\;M$) is derivable, then $M$ is in normal form.\n      \\item[Completeness]\n        If $M$ is in normal form, then $\\normal\\;M$ is derivable.\n    \\end{description}\n  \\end{lemma}\n  \\begin{proof}[Proof sketch.]\n    \\begin{description}\n      \\item[Soundness] By mutual induction on the derivation of\n    $\\normal\\;M$ and $\\neutral\\;M$.\n      \\item[Completeness] By induction on the formation of $M$.\n    \\end{description}\n  \\end{proof}\n\n  \n\\end{frame}\n\\begin{frame}{Progress}\n  \\begin{theorem}\n    If $\\Gamma \\vdash M : \\sigma$ is derivable, then $\\normal\\;M$ or there is $N$ with $M \\onereduce N$.\n  \\end{theorem}\n  \\begin{proof}[Proof sketch]\n    By induction on the derivation of $\\Gamma \\vdash M : \\sigma$. \n  \\end{proof}\n\\end{frame}\n\n\n\\begin{frame}{Weak normalisation}\n  \\begin{definition}\n    $M$ is \\emph{weakly normalising} denoted by $M\\downarrow$ if \n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\normal\\; M$}\n        \\UIC{$M \\downarrow$}\n      \\end{prooftree}\n      \\columnbreak\n      \\begin{prooftree}\n        \\AXC{$M \\onereduce N$}\n        \\AXC{$N \\downarrow$}\n        \\BIC{$M \\downarrow$}\n      \\end{prooftree}\n    \\end{multicols}\n  \\end{definition}\n  That is, $M$ is weakly normalising if there is a sequence\n  \\[\n    M \\onereduce M_1 \\onereduce M_2 \\onereduce \\dots N \\notonereduce \n  \\]\n  \\begin{theorem}[Weak normalisation]\n    Every term $M$ with $\\Gamma \\vdash M : \\tau$ is weakly normalising.\n  \\end{theorem}\n\n\\end{frame}\n\n\\begin{frame}{Strong normalisation}\n  \\begin{definition}\n    $M$ is \\emph{strongly normalising} denoted by $M \\Downarrow$ if \n    \\begin{prooftree}\n      \\AXC{$\\forall N.\\, (M \\onereduce N \\implies N \\Downarrow)$}\n      \\UIC{$M \\Downarrow$}\n    \\end{prooftree}\n    \n  \\end{definition}\n  Intuitively, \\emph{strong normalisation} says every sequence\n    \\[\n      M \\onereduce M_1 \\onereduce M_2 \\cdots\n    \\]\n  terminates.\n  \\begin{theorem}\n    Every term $M$ with $\\Gamma \\vdash M : \\tau$ is strongly normalising.\n  \\end{theorem}\n  \n\\end{frame}\n\n\\begin{frame}{Definability}\n%Within simply typed lambda calculus, we wonder how many computable functions can\n%be defined, as it excludes non-terminating $\\lambda$-terms. \n  A function $f\\colon \\mathbb{N}^k \\to \\mathbb{N}$ is called\n  \\alert{\\emph{$\\lambda_\\to$-definable}} if there is a $\\lambda$-term $F$ of\n  type $\\nat \\to \\nat \\to \\dots \\nat \\to \\nat$ such that\n  \\[\n    F\\,\\bc_{n_1}\\ldots\\bc_{n_k} \\reduce \\bc_{f(n_1, \\dots, n_k)}\n  \\]\n  for every sequence $(n_1, n_2, \\ldots, n_k) \\in \\mathbb{N}^k$.\n  Diagrammatically, \n\n\\[\n  \\xymatrix{\n    (n_1, n_2, \\ldots, n_k) \\ar@{|->}[rr] \\ar@{|->}[d]_{(\\bc_{-})^k} & & f(n_1,\n    n_2, \\ldots, n_k) \\ar@{|->}[d]^{\\bc_{-}}\\\\\n    (\\bc_{n_1}, \\bc_{n_2}, \\ldots, \\bc_{n_k}) \\ar@{|->}[rr] & & \n    F\\;\\bc_{n_1}\\; \\bc_{n_2}\\; \\ldots\\;\\bc_{n_k}\n    = \\bc_{f(n_1, n_2, \\ldots, n_k)}\n  }\n\\]\n\\end{frame}\n\\begin{frame}{The limit of $\\lambda_\\to$}\n\\begin{theorem}\n  The $\\lambda_\\to$-definable functions are the class of functions\n  of the form $f\\colon \\mathbb{N}^k \\to \\mathbb{N}$ closed under \n  compositions\n  which contains\n  \\begin{itemize}\n    \\item the constant functions,\n    \\item projections,\n    \\item additions,\n    \\item multiplications,\n    \\item and the conditional \n  \\[\n    \\mathrm{ifz}(n_0, n_1, n_2) = \n    \\begin{cases}\n      n_1 & \\text{if } n_0 = 0\\\\\n      n_2 & \\text{otherwise.}\n    \\end{cases}\n  \\]\n  \\end{itemize}\n\\end{theorem}\n\\end{frame}\n\n%\\subsection{System T}\n%It is also convenient to add some primitive types to our typed lambda calculus (or\n%so-called built-in types in programming languages used in practice) as well as\n%\\emph{primitive terms}. For example, for a system with natural numbers, we\n%include numerals in the generation of syntax:\n%  \\begin{multicols}{2}\n%    \\begin{prooftree}\n%      \\AXC{$x \\in V$}\n%      \\UIC{$x \\in \\Lambda_{\\T, \\nat}$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{\\phantom{$n \\in \\mathbb{N}$}}\n%      \\UIC{$\\zero\\in \\Lambda_{\\T, \\nat}$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$M \\in \\Lambda_{\\T, \\nat}$}\n%      \\UIC{$\\suc\\;M\\in \\Lambda_{\\T, \\nat}$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$M \\in \\Lambda_{\\T,\\nat}$}\n%      \\AXC{$N \\in \\Lambda_{\\T,\\nat}$}\n%      \\BIC{$(M\\, N) \\in \\Lambda_{\\T, \\nat}$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$M \\in \\Lambda_{\\T, \\nat}$}\n%      \\AXC{$x \\in V$}\n%      \\AXC{$\\tau \\in \\mathbb{T}$}\n%      \\TIC{$\\lambda (x:\\tau).\\; M \\in \\Lambda_{\\T, \\nat}$}\n%    \\end{prooftree}\n%  \\end{multicols}\n%\\noindent and let $\\mathbb{G} \\defeq \\{\\nat\\}$ with an addition set of typing\n%rules:\n%\\begin{multicols}{2}\n%\\begin{prooftree}\n%  \\AXC{\\phantom{$\\Gamma$}}\n%  \\UIC{$\\Gamma \\vdash \\zero : \\nat$}\n%\\end{prooftree}\n%\\begin{prooftree}\n%  \\AXC{$\\Gamma \\vdash M : \\nat$}\n%  \\UIC{$\\Gamma \\vdash \\suc\\:M : \\nat$}\n%\\end{prooftree}\n%\\end{multicols}\n%\\noindent In this way, we can derive that every $\\underline{n} \\defeq\n%\\suc^n\\;\\zero$ has the type of $\\nat$:\n%\\[\n%  \\Gamma \\vdash \\underline{n} : \\nat\n%\\]\n%\n%However, it still remains to add primitive operations such as addition,\n%multiplication, division, and so on with a proper set of reduction rules. As we\n%have seen that recursions on natural numbers in untyped lambda calculus can be\n%defined with the fixpoint operator. Something similar can be done:\n%\\begin{definition}\n%  In addition to typing rules introduced so far, we add the following\n%  \\begin{prooftree}\n%    \\AXC{$\\Gamma \\vdash M : \\nat$}\n%    \\AXC{$\\Gamma \\vdash M_0 : \\sigma$}\n%    \\AXC{$\\Gamma \\vdash F : \\nat \\to (\\sigma \\to \\sigma)$}\n%    \\TIC{$\\Gamma \\vdash \\fold\\;M_0\\;F : \\nat \\to \\sigma $}\n%  \\end{prooftree}\n%  with additional reductions\n%  \\[\n%    \\fold\\;M_0\\;F\\;\\zero\n%    \\xrightarrow{\\beta}\n%    M_0\n%    \\quad\\text{and}\\quad\n%    \\fold\\;M_0\\;F\\;(\\suc\\;M)\n%    \\xrightarrow{\\beta}\n%    F\\;M\\;(\\fold\\;F\\;M).\n%  \\]\n%\\end{definition}\n%\\begin{definition}\n%  \\todo[inline]{define addition, multiplication using $\\fold$}\n%\\end{definition}\n%\\begin{frame}{Remark}\n%With the decidability of type checking, Preservation Theorem, Progress Theorem\n%(a well-typed term is either a ``value'' or a reducible term), and the strong\n%normalisation, we actually have exhibited a decidable evaluator of simply typed\n%lambda calculus that always reduce a well-typed term of type~$\\sigma$ to a value\n%of type~$\\sigma$.\n%\\end{frame}\n\n\\begin{frame}{Homework}\n  \\begin{enumerate}\n    \\item (2.5\\%) Show the Preservation Theorem. \\\\\n      \\textbf{Hint.} Apply the Substitution Lemma if applicable. \n    \\item (2.5\\%) Show the Progress Theorem.\n    \\item (2.5\\%) Show that if $M$ is in normal form then $\\normal\\;M$ is derivable.\n  \\end{enumerate}\n  \n\\end{frame}\n\n%\\begin{frame}{References}\n%\n%\\bibliographystyle{amsalpha}\n%\\bibliography{library} \n%\n%\\end{frame}\n\n\\appendix\n\\section{Appendix Takahashi's Proof of confluence}\n\n\\begin{frame}{Confluence: Parallel reduction}\n  Consider untyped $\\lambda$-calculus. \n\n  Let $M \\parreduce N$ denote the \\emph{parallel reduction} defined by\n  \\begin{multicols}{2}\n    \\begin{prooftree}\n      \\AXC{$\\vphantom{M\\reduce M}$}\n      \\UIC{$x \\parreduce x$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$M \\parreduce N$}\n      \\UIC{$\\lambda x.\\, M \\parreduce \\lambda x.\\, N$}\n    \\end{prooftree}\n    \\columnbreak\n    \\begin{prooftree}\n      \\AXC{$M \\parreduce M'$}\n      \\AXC{$N \\parreduce N'$}\n      \\BIC{$M\\;N \\parreduce M'\\;N'$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$M \\parreduce M'$}\n      \\AXC{$N \\parreduce N'$}\n      \\BIC{$(\\lambda x.\\, M)\\;N \\parreduce M'\\subst{N'}{x}$}\n    \\end{prooftree}\n  \\end{multicols}\n  For example, \n  \\[\n    \\underline{(\\lambda x.\\, (\\lambda y.\\, y)\\;x)}\\;\\underline{((\\lambda x.\\, x)\\;\\false)}\n    \\parreduce\n    \\false\n  \\]\n  because $(\\lambda y.\\,y)\\;x \\parreduce x$ and $(\\lambda x.\\,x)\\;\\false \\parreduce \\false$.\n\\end{frame}\n\n\\begin{frame}{Confluence: Properties of parallel reduction}\n  \\begin{lemma}\n    \\begin{enumerate}\n      \\item $M \\parreduce M$ holds for any term~$M$, \n      \\item $M \\onereduce N$ implies $M \\parreduce N$, and\n      \\item $M \\parreduce N$ implies $M \\reduce N$.\n    \\end{enumerate}\n  \\end{lemma}\n  Therefore, $M \\parreduce^* N$ is equivalent to $M \\reduce N$. \n  \\begin{lemma}[Substitution respects parallel reduction]\n      $M \\parreduce M'$ and $N \\parreduce N'$ imply $M\\subst{N}{x} \\parreduce\n      M'\\subst{N'}{x}$. \n  \\end{lemma}\n  \\begin{proof}[Proof sketch]\n    By induction on the derivation of $M \\parreduce M'$.\n    \n  \\end{proof}\n\n\\end{frame}\n\n\\begin{frame}{Complete development}\n  The \\emph{complete development} $M^*$ of a $\\lambda$-term $M$ is defined by\n  \\begin{align*}\n    x^*      & = x \\\\\n    (\\lambda x.\\, M)^* & = \\lambda x.\\, M^* \\\\\n    \\left((\\lambda x.\\, M)\\;N\\right)^* & = M^*\\subst{N^*}{x} \\\\\n    (M\\;N)^* & = M^*\\;N^* && \\text{ if $M \\not\\equiv \\lambda x.\\,M'$ } \n  \\end{align*}\n  \\begin{theorem}[Triangle property]\n    If $M \\parreduce N$, then $N \\parreduce M^*$.\n  \\end{theorem}\n  \\begin{proof}[Proof sketch]\n    By induction on $M \\parreduce N$.\n    \n  \\end{proof}\n\\end{frame}\n\n\\begin{frame}{Strip Lemma}\n  \\begin{theorem}\n    If $L \\parreduce^* M_1$ and $L \\parreduce M_2$, then there exists $N$\n    satisfying that $M_1 \\parreduce N$ and $M_2 \\parreduce^* N$, i.e.\\\n    \\[\n      \\xymatrix{\n        & L \\ar@{=>}[rd] \\ar@{=>}[ld]^(.8){*}_(.8){\\beta} \\\\\n        M_1 \\ar@{=>}[rd] & & M_2 \\ar@{=>}[ld]^(.8){*}_(.8){\\beta} \\\\\n            & N\n      }\n    \\]\n  \\end{theorem}\n  \\begin{proof}[Proof sketch]\n    By induction on $L \\parreduce^* M_1$. \n  \\end{proof}\n\\end{frame}\n\n\\begin{frame}{Confluence}\n  \\begin{theorem}\n    If $L \\parreduce^* M_1$ and $L \\parreduce^* M_2$, then there exists $N$ such that $M_1 \\parreduce^* N$ and $M_2 \\parreduce^* N$.\n    \\[\n      \\xymatrix{\n        & L \\ar@{=>}[rd]^(.8){*}_(.8){\\beta} \\ar@{=>}[ld]^(.8){*}_(.8){\\beta} \\\\\n        M_1 \\ar@{=>}[rd]^(.8){*}_(.8){\\beta} & & M_2 \\ar@{=>}[ld]^(.8){*}_(.8){\\beta} \\\\\n            & N\n      }\n    \\]\n  \\end{theorem}\n  \\begin{corollary}\n    The confluence of $\\reduce$ holds. \n    \n  \\end{corollary}\n  \n\\end{frame}\n\\end{document}\n", "meta": {"hexsha": "230e9c10aec26a59d3012ebf7b07d5f774089fed", "size": 28076, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/lecture2.tex", "max_stars_repo_name": "L-TChen/Type-Theory", "max_stars_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2018-06-11T04:47:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T12:16:55.000Z", "max_issues_repo_path": "tex/lecture2.tex", "max_issues_repo_name": "xcycl/FLOLAC16-Lambda", "max_issues_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-06-14T20:57:59.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-15T10:10:37.000Z", "max_forks_repo_path": "tex/lecture2.tex", "max_forks_repo_name": "L-TChen/Type-Theory", "max_forks_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-09T02:37:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-15T05:34:52.000Z", "avg_line_length": 30.6506550218, "max_line_length": 152, "alphanum_fraction": 0.6057130645, "num_tokens": 10175, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4236756137287244}}
{"text": "% !TEX root = ../../../proposal.tex\n\n\n\n%\\section{Introduction}\n%\n%Diffie-Hellman key exchange is one of the most common public-key cryptographic\n%methods in use in the Internet. It is a fundamental building block for IPsec,\n%SSH, and TLS\\@. In the textbook presentation of finite field Diffie-Hellman,\n%Alice and Bob agree on a large prime $p$ and an integer $g$ modulo $p$. Alice\n%chooses a secret integer $x_a$ and transmits a public value $g^{x_a} \\bmod p$;\n%Bob chooses a secret integer $x_b$ and transmits his public value $g^{x_b}\n%\\bmod p$. Both Alice and Bob can reconstruct a shared secret $g^{x_a x_b} \\bmod\n%p$, but the best known way for a passive eavesdropper to reconstruct this\n%secret is to compute the discrete log of either Alice or Bob's public value.\n%Specifically, given $g$, $p$, and $g^x \\bmod p$, an attacker must calculate\n%$x$.\n\nThis chapter is adapted from a joint publication with Valenta et al.\\ that\noriginally appeared in the proceedings of the 21st Network and Distributed\nSystem Security Symposium (NDSS '17)~\\cite{subgroup-2017}.\n\nIn order for the discrete log problem $\\bmod p$ to be hard, Diffie-Hellman parameters\nmust be chosen carefully. A typical recommendation is that $p$ should be a\n``safe'' prime, that is, that $p = 2q+1$ for some prime $q$, and that $g$\nshould generate the group of order $q$ modulo $p$. For $p$ that are not safe,\nthe group order $q$ can be much smaller than $p$. For security, $q$ must still\nbe large enough to thwart known attacks, which for prime $q$ run in time\n$O(\\sqrt{q})$. A common parameter choice is to use a 160-bit $q$ with a\n1024-bit $p$ or a 224-bit $q$ with a 2048-bit $p$, to match the security level\nunder different cryptanalytic attacks. Diffie-Hellman parameters with $p$ and\n$q$ of these sizes were suggested for use and standardized in DSA\nsignatures~\\cite{fips186}. For brevity, we will refer to these non-safe primes as\nDSA primes, and to groups using DSA primes with smaller values of $q$ as  DSA\ngroups.\n\nA downside of using DSA primes instead of safe primes for Diffie-Hellman is\nthat implementations must perform additional validation checks to ensure the\nkey exchange values they receive from the other party are contained in the\ncorrect subgroup modulo $p$. The validation consists of performing an extra\nexponentiation step. If implementations fail to validate, a 1997 attack of Lim\nand Lee~\\cite{lim-1997} can allow an attacker to recover a static exponent by\nrepeatedly sending key exchange values that are in very small subgroups. We\ndescribe several variants of small subgroup confinement attacks that allow an\nattacker with access to authentication secrets to mount a much more efficient\nman-in-the-middle attack against clients and servers that do not validate group\norders. Despite the risks posed by these well-known attacks on DSA groups, NIST SP 800-56A, ``Recommendations\nfor Pair-Wise Key Establishment Schemes Using Discrete Logarithm\nCryptography''~\\cite{sp800} specifically recommends DSA group parameters\nfor Diffie-Hellman, rather than recommending using safe primes. RFC\n5114~\\cite{rfc5114} includes several DSA groups for use in IETF standards.\n\nWe observe\nthat few Diffie-Hellman implementations actually validate subgroup orders, in spite of the fact\nthat small subgroup attacks and countermeasures are well-known and specified\nin every standard suggesting the use of DSA groups for Diffie-Hellman, and DSA\ngroups are commonly implemented and supported in popular protocols. For some protocols, including\nTLS and SSH, that enable the server to unilaterally specify the group used for\nkey exchange, this validation step is not possible for clients to perform with\nDSA primes---there is no way for the server to communicate to the client the\nintended order of the group. Many standards involving DSA groups further\nsuggest that the order of the subgroup should be matched to the length of the\nprivate exponent.  Using shorter private exponents yields faster exponentiation\ntimes, and is a commonly implemented optimization. However, these standards\nprovide no security justification for decreasing the size of the subgroup to\nmatch the size of the exponents, rather than using as large a subgroup as\npossible. We discuss possible motivations for these recommendations\nlater in the paper.\n\nWe conclude that adopting the Diffie-Hellman group recommendations from RFC\n5114 and NIST SP 800-56A may create vulnerabilities for organizations using\nexisting cryptographic implementations, as many libraries allow\nuser-configurable groups but have unsafe default behaviors.  This highlights the\nneed to consider developer usability and implementation fragility when designing\nor updating cryptographic standards.\n\n\\paragraph{Our Contributions}\nWe study the implementation landscape of Diffie-Hellman from several\nperspectives and measure the security impact of the widespread\nfailure of implementations to follow best security practices:\n\\begin{itemize}\n\\item We summarize the concrete impact of small-subgroup confinement attacks\n    and small subgroup key recovery attacks on TLS, IKE, and SSH handshakes.\n\\item We examined the code of a wide variety of cryptographic libraries to\n  understand their implementation choices. We find feasible full private\n  exponent recovery vulnerabilities in OpenSSL and the Unbound DNS resolver,\n  and a partial private exponent recovery vulnerability for the parameters used\n  by the Amazon Elastic Load Balancer. We observe that \\emph{no} implementation\n  that we examined validated group order for subgroups of order larger than two\n  by default prior to January 2016, leaving users potentially vulnerable to\n  small subgroup confinement attacks.\n  %In addition, we observed that nearly every implementation uses short\n  %exponents by default, and several use ephemeral-static keys.\n\\item We performed Internet-wide scans of HTTPS, POP3S, SMTP with STARTTLS,\n  SSH, IKEv1, and IKEv2, to provide a snapshot of the deployment of DSA groups\n  and other non-``safe'' primes for Diffie-Hellman, quantify the incidence of\n  repeated public exponents in the wild, and quantify the lack of validation\n  checks even for safe primes.\n  %Our work adds to the growing literature of empirical\n  %studies of cryptographic implementation behavior on the Internet.\n%\\item We surveyed the protocol-level susceptibility to small subgroup attack\n%    scenarios for TLS, IKE, and SSH.  While several of these attacks are well\n%    known or have been described elsewhere, we are unaware of a comprehensive\n%    reference that summarizes the state of protocol landscape from this\n%    perspective. We describe variants of these attacks that we have not\n%    seen elsewhere.\n\\item We performed a best-effort attempt to factor $p-1$ for all non-safe primes that we found in the\n    wild, using \\textasciitilde100,000 core-hours\n    of computation. Group 23 from RFC 5114, a 2048-bit prime, is particularly vulnerable\n    to small subgroup key recovery attacks; for TLS a full key recovery\n    requires $2^{33}$ online work and $2^{47}$ offline work to recover a\n    224-bit exponent.\n\\end{itemize}\n\n\\paragraph{Disclosure and Mitigations}\nWe reported the small subgroup key recovery vulnerability to OpenSSL in January\n2016~\\cite{asanso-unredacted}. OpenSSL issued a patch to add additional\nvalidation checks and generate single-use private exponents by\ndefault~\\cite{cve-2016-0701}. We reported the Amazon load balancer\nvulnerability in November 2015. Amazon responded to our report informing us\nthat they have removed Diffie-Hellman from their recommmended ELB security\npolicy, and have reached out to their customers to recommend that they use\nthese latest policies. Based on scans performed in February and May 2016, 88\\%\nof the affected hosts appear to have corrected their exponent generation\nbehavior. We found several libraries that had vulnerable combinations of\nbehaviours, including Unbound DNS, GnuTLS, LibTomCrypt, and Exim. We disclosed\nto the developers of these libraries. Unbound issued a patch, GnuTLS\nacknowledged the report but did not patch, and LibTomCrypt did not respond.\nExim responded to our bug report stating that they would use their own\ngenerated Diffie-Hellman groups by default, without specifying subgroup order\nfor validation~\\cite{exim-blog,exim-bug-report}.  We found products from Cisco,\nMicrosoft, and VMWare lacking validation that key exchange values were in\nthe range $(1,p-1)$. We informed these companies, and discuss their responses\nin Section~\\ref{sec:tls-measurements}.\n\n%In May 2016, we submitted bug reports to the developers\n%of several applications and libraries that had vulnerable combinations of\n%behaviours, including the Unbound DNS resolver, the Exim mail server, and the\n%LibTomCrypt and GnuTLS libraries.  Developers of the Unbound DNS resolver\n%informed us that a fix would be included in the next release. The GnuTLS\n%developers acknowledged the issue but have not yet applied patches. In October\n%2016, Exim responded to our bug report stating that they would use their own\n%generated Diffie-Hellman groups by default, without specifying subgroup order\n%for validation~\\cite{exim-blog,exim-bug-report}.  There was no response from\n%LibTomCrypt. We found that products of several noteworthy companies, including\n%Microsoft, Cisco, and VMWare, do not validate that a key exchange value is in\n%the range $(1, p-1)$.  We informed these companies and others about this\n%missing check, and discuss their responses in\n%Section~\\ref{sec:tls-measurements}.\n", "meta": {"hexsha": "5fb371c6db180c79fbf6905be980bbda2d3ce0b3", "size": 9528, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/subgroup/paper/intro.tex", "max_stars_repo_name": "dadrian/dissertation", "max_stars_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "papers/subgroup/paper/intro.tex", "max_issues_repo_name": "dadrian/dissertation", "max_issues_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/subgroup/paper/intro.tex", "max_forks_repo_name": "dadrian/dissertation", "max_forks_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.52, "max_line_length": 109, "alphanum_fraction": 0.79670445, "num_tokens": 2210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.42360396527647803}}
{"text": "\\documentclass{article}\r\n\\usepackage{amsmath}\r\n%\\usepackage{geometry}\r\n\\usepackage[utf8]{inputenc}\r\n\r\n\r\n\\setlength{\\parindent}{0pt}\r\n\\setlength{\\parskip}{1em}\r\n\r\n\\begin{document}\r\n\r\n\\section{Power of point}\r\nThe power of point $P$ with respect to circle with centre $O$ and radius $r$ is defined as\r\n$$ p= PO^2-r^2 $$\r\n\r\n\\textbf{Theorem 1: } \r\nFor any line through point $P$ which intersects the circle at points $A$ and $B$ \r\n$$p= PA \\times PB$$\r\n\r\n\\textbf{Theorem 2: }\r\nFor tangent $PC$ where $C$ is tangent point\r\n$$p=PC^2$$  \r\n\r\n\\begin{enumerate}\r\n\\item \r\nSquare $ABCD$ of side length $a$ has a circle inscribed in it. Let $M$ be the midpoint of $AB$ Find the length of that portion of the segment $MC$ that lies outside of the circle.\r\n\r\n\\item  % Prasolov 3.11\r\nLine $OA$ is tangent to a circle at point $A$ and chord $BC$ is parallel to $OA$. Lines\t$OB$ and $OC$ intersect the circle for the second time at points $K$ and $L$, respectively. Prove\r\nthat line $KL$ divides segment $OA$ in halves.\r\n\r\n\\item % LP 2003 XI-3\r\nWe have a triangle $ABC$. Points $K$, $L$ and $M$ are chosen on the sides $BC$, $AC$ and $AB$, such that $AK$, $BL$ and $CM$ intersect in one point. We know that $ALKB$ and $BMLC$ are cyclic quadrilaterals. Show that $AMKC$ is also a cyclic quadrilateral.\r\n\r\n\\item % Prasolov 3.12\r\nOn the longer diagonal $AC$ of parallelogram $ABCD$ point $M$ is chosen, such that $BCDM$ is a cyclic quadrilateral. Show that $BD$ is tangent to circumcircles of triangles $AMD$ and $AMB$.\r\n\r\n\\item % IMO shortlist 2013\r\nLet $ABC$ be a triangle with $\\angle B > \\angle C$. Let $P$ and $Q$ be two different points on line $AC$ such that $\\angle PBA = \\angle QBA = \\angle ACB$ and $A$ is located between $P$ and $C$. Suppose that there exists an interior point $D$ of segment $BQ$ for which $PD=PB$. Let the ray $AD$ intersect the circle $ABC$ at $R \\ne A$. Prove that $QB = QR$.\r\n\\end{enumerate}\r\n\r\n\r\n\\newpage\r\n\\section{Radical axis}\r\nRadical axis is the locus of points at which tangents drawn to both circles are equal.\r\n\r\n\\textbf{Theorem 1: }\r\nThe power of points on radical axis is equal with respect to both circles.\r\n\r\n\\textbf{Theorem 2: }\r\nRadical axis is a line.\r\n\r\n\\textbf{Theorem 3: }\r\nThe three radical axes for three circles intersect in one point called the radical centre. \r\n\r\n\\begin{enumerate}\r\n\r\n\\item %Prasolov 3.58a\r\nProve that the midpoints of the four common tangents to two non-intersecting circles lie on one line.\r\n\r\n\\item %puutujakuusnurga diagonaalid Prasolov 3.66\r\nProve that the diagonals $AD$, $BE$ and $CF$ of circumscribed hexagon $ABCDEF$ intersect in one point. (Brianchon theorem)\r\n\r\n\\item % TVV\t2016 6\r\nCircles $k_1$ and $k_2$ intersect at points  $M$ and $N$. Line $l$ intersects circle $k_1$ at points $A$ and $C$ and circle $k_2$ at points $B$ and $D$, such that points $A$,  $B$, $C$ and $D$ lie on the line $l$ in that order. Let $X$ be such point on line $MN$ that $M$ lies between $X$ and $N$. Rays $AX$ and $BM$ intersect at point $P$, rays $DX$ and $CM$ at point $Q$. Prove that $PQ \\parallel l$.\r\n\r\n\\item % BT treening 2009-5\r\nPoint $E$ is chosen on the median $CD$ of triangle $ABC$. Line $AB$ is tangent to circle $c_1$ at point $A$ and to circle $c_2$ at point $B$ such that both circles go through point $E$. The second intersection of $c_1$ and  $AC$ is $M$. The second intersection of $c_1$ and $BC$ is $N$. Prove that tangent lines to circles $c_1$ and $c_2$ at points $M$ and $N$ respectively intersect on line $CD$.\r\n\r\n\r\n\\item % 3.6l\r\nThree circles intersect pairwise at points $A_1$ and $A_2$, $B_1$ and $B_2$, $C_1$ and $C_2$. Prove that $A_1B_2 \\times B_1C_2 \\times C_1A_2 = A_2B_1 \\times B_2C_1 \\times C_2A_1$.\r\n\r\n\r\n\\item % Prasolov 3.60\r\nThe extensions of sides $AB$ and $CD$ of quadrilateral $ABCD$ meet at point $F$ and\r\nthe extensions of sides $BC$ and $AD$ meet at point $E$. Prove that the circles with diameters\r\n$AC$, $BD$ and $EF$ have a common radical axis and the orthocenters of triangles $ABE$, $CDE$,\r\n$ADF$ and $BCF$ lie on it.\r\n\r\n\\end{enumerate}\r\n\r\n\\newpage\r\n\\section*{Hints}\r\n\r\n\\textbf{Power of point}\r\n\r\n\\begin{enumerate}\r\n\t\\item Write down power of point $C$.\r\n\t\\item Identify similar triangles and write down power of the intersection of $KL$ and $AB$\r\n\t\\item Write down the power of the intersection for each circle\r\n\t\\item Write down the power of the intersection of the diagonals\r\n\t\\item Prove that quadrilateral $DRCQ$ is cyclic\r\n\\end{enumerate}\r\n\r\n \\noindent\r\n \\textbf{Radical axis}\r\n\r\n\\begin{enumerate}\r\n\t\\item \r\n\t\\item Find three circles for which the diagonals are radical lines for.\r\n\t\\item What's the power of $X$ with respect to each circle? What other points lie on the circle $PQM$?\r\n\t\\item Prove that quadrilateral $ABNM$ is cyclic.\r\n\t\\item Where's the radical centre? Find 3 pairs of similar triangles.\r\n\t\\item For each triangle, what's the power of orthocentre with respect to each circles?\r\n\\end{enumerate}\r\n\r\n\\end{document}", "meta": {"hexsha": "c78e175590a2479e487974184acda03237a3f9a0", "size": 4925, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "02_powerofpoint.tex", "max_stars_repo_name": "ZhaoWanLong/maths-olympiad", "max_stars_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-21T21:57:43.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-21T21:57:43.000Z", "max_issues_repo_path": "02_powerofpoint.tex", "max_issues_repo_name": "kauraare/maths-olympiad", "max_issues_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "02_powerofpoint.tex", "max_forks_repo_name": "kauraare/maths-olympiad", "max_forks_repo_head_hexsha": "0dcacba8a6d1769bbccfedda89d08fa22c3f55a1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-05-26T15:18:18.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-26T15:18:18.000Z", "avg_line_length": 45.6018518519, "max_line_length": 403, "alphanum_fraction": 0.6996954315, "num_tokens": 1549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.42360396156219593}}
{"text": "\\chapter{Specifying your geometry with a Z-Matrix}\n\nA Z-Matrix is a convenient way to specify the geometry of a molecule or\ncrystal in terms of bond lengths, bond angles, and dihedral angles.\nThere are several styles of Z-matrix used in various programs,\n\\calcprog\\ uses a format similar to that used in Gaussian.\nThis is intended to be a brief introduction to how a Z-matrix works.\n\nIf you already know how to use a Z-matrix, here's all you need to know\nabout the implementation in \\calcprog:\n\\begin{itemize}\n\\item The first atom is put at the origin.\n\\item The second atom is put along the Z axis.\n\\item The third atom is in the XZ plane.\n\\item Dihedrals are evaluated using the right hand rule.\n\\end{itemize}\n\nThe easiest way to explain a Z-matrix is to show one and then explain\nit, so that's what we'll do.  Before we start, however, we need to\nbriefly define a dihedral angle.  A dihedral is specified by 4\natoms, we'll call them A, B, C, and D.  The dihedral A--B--C--D is the\nangle between the plane defined by A--B--C and the plane defined by\nB--C--D.\nHere's an alternative explanation: the dihedral A--B--C--D is the angle\nbetween the lines C--D and B--A if you are looking down the line C--B.\nThere's one more piece of information we need to fully understand the\ndihedral: there is a handedness associate with them.  If you think\nabout it, looking down the line C--B there are two different angles\nbetween lines C--D and B--A: $\\theta$ and 360-$\\theta$.  The dihedrals\nin \\calcprog\\ are defined using the right hand rule:  Take your right\nhand and point the thumb down the line C--B, now align your fingers\nwith the line C--D, curling your fingers shows the direction in which\nthe dihedral angle is measured.\n%\nThis is all about a million times easier to understand using a\npicture, here's a picture demonstrating both views of dihedrals and\ntheir handedness. \n%\n\\begin{center}\n\\epsfig{file=dihedral.eps,width=5.0in}\n\\end{center}\n%\n\nWith that definition under our belt, here's the Geometry specification for a \nsquare pyramidal (CH$_3$)BiI$_4$ fragment, where the CH$_3$ group is\nalong the Z axis and the Bi and four I's lie in the XY plane:\n\n\\shrinkspacing\n\\begin{verbatim}\nGeometry Z Matrix\n9\n1 Bi\n2 C 1 2.1\n3 I 1 2.7  2  90.0\n4 I 1 2.7  2  90.0  3  90.0\n5 I 1 2.7  2  90.0  3 180.0\n6 I 1 2.7  2  90.0  3 270.0\n7 H 2 1.1  1 109.5  3   0.0\n8 H 2 1.1  1 109.5  3 120.0\n9 H 2 1.1  1 109.5  3 240.0\n\\end{verbatim}\n\\resumespacing\n\nLet's look at the first few entries in more detail.\n\\begin{enumerate}\n\\item The first atom is a Bi and it's placed at the origin.\nCartesian:  (0 0 0).  \n\n\\item Atom two is a C.  It's placed on the Z axis, 2.1 \\AA\\ away from\natom 1. Cartesian: (0 0 2.1).\n\n\\item Atom three is an I.  It's placed 2.7 \\AA\\ away from atom 1 and\nthe angle between atoms 3--1--2 in the XZ plane is 90.0 degrees.  \nCartesian: (2.7 0 0).\n\n\\item Atom four is an I.  It's placed 2.7 \\AA\\ away from atom 1, the\nangle 4--1--2 is 90 degrees.  This angle puts us in the XY plane.  At\nthis point we know that atom 4 lies on a circle in the XY plane with\nradius 2.7 \\AA. The\ndihedral 4--1--2--3 (90 degrees) tells us where on the circle we are. \nThis dihedral is particularly easy to see:  if we look down the bond\n2--1 (which is looking down the Z axis), the angle between the bond\n3--1 and the bond 4--1 is 90 degrees.  So atom 4 lies on the Y axis.\nTaking the right-handedness of dihedrals into account, we know that\natom 4 lies on the negative Y axis.  Cartesian (0 -2.7 0).\n\n\\item Atom five is an I.  It's 2.7 \\AA\\ away from atom 1, making an\nangle of 90 degrees with 2 and a dihedral of 180 with 3.  This puts us\non the negative X axis.  Cartesian (-2.7 0 0).\n\n\\end{enumerate}\n\nIf you find the handedness of dihedrals confusing, just play around\nwith a couple of molecules defined using Z matrices, you'll get the\nhang of it fairly quickly.\n\n", "meta": {"hexsha": "5a2436f5da3f67a718fd050bbc00d9c8697a0523", "size": 3854, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Zmat_appendix.tex", "max_stars_repo_name": "richardjgowers/yaehmop", "max_stars_repo_head_hexsha": "d8c7e437b949af4868f7d79c68faf77433081549", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2016-08-07T05:17:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-19T16:57:28.000Z", "max_issues_repo_path": "docs/Zmat_appendix.tex", "max_issues_repo_name": "richardjgowers/yaehmop", "max_issues_repo_head_hexsha": "d8c7e437b949af4868f7d79c68faf77433081549", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2016-07-28T18:59:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-22T13:03:01.000Z", "max_forks_repo_path": "docs/Zmat_appendix.tex", "max_forks_repo_name": "richardjgowers/yaehmop", "max_forks_repo_head_hexsha": "d8c7e437b949af4868f7d79c68faf77433081549", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-07-28T18:57:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T17:07:25.000Z", "avg_line_length": 39.7319587629, "max_line_length": 77, "alphanum_fraction": 0.729372081, "num_tokens": 1253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.4236039605140988}}
{"text": "%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[twoside,english]{paper}\n\\usepackage{lmodern}\n\\renewcommand{\\ttdefault}{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage[a4paper]{geometry}\n\\geometry{verbose,tmargin=3cm,bmargin=2.5cm,lmargin=2cm,rmargin=2cm}\n\\usepackage{color}\n\\usepackage{babel}\n\\usepackage{float}\n\\usepackage{bm}\n\\usepackage{amsthm}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{esint}\n\\usepackage[unicode=true,pdfusetitle,\n bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,\n breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]\n {hyperref}\n\\usepackage{breakurl}\n\\usepackage{mathrsfs}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n%% Because html converters don't know tabularnewline\n\\providecommand{\\tabularnewline}{\\\\}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{babel}\n\n\\@ifundefined{showcaptionsetup}{}{%\n \\PassOptionsToPackage{caption=false}{subfig}}\n\\usepackage{subfig}\n\\makeatother\n\n\\begin{document}\n\n\\title{Combining evolution and DIS operators}\n\n\\maketitle\n\n\\section{The structure of the observables}\n\nIn all cases the inclusive DIS structure functions are conveniently\nexpressed in terms of PDF combinations in the so-called physical basis\n$\\{q_i^\\pm\\}$, with $q_i^\\mp = q_i\\pm\\overline{q}_i$, where $q_i$ and\n$\\overline{q}_i$ are the PDFs of the $i-th$ quark-flavour, with\n$i=u,d,s,c,b,t$, and its antiflavour, respectively. Schematically, a\nDIS structure function can be written as:\n\\begin{equation}\nF = C_g g + \\sum_{i}\\left(C_i^+q_i^++C_i^-q_i^-\\right)\\,,\n\\end{equation}\nbeing $C$ the appropriate coefficient functions. Conversely, the\nevolution of PDFs is usually compute in the so-called QCD evolution\nbasis $\\{d_i^\\pm\\}$, with $d^+_1=\\Sigma$, $d^+_2=-T_3$, $d^+_3=T_8$,\n$d^+_4=T_{15}$, $d^+_5=T_{24}$, and $d^+_6=T_{35}$ and $d^-_1=V$,\n$d^-_2=-V_3$, $d^-_3=V_8$, $d^-_4=V_{15}$, $d^-_5=V_{24}$, and\n$d^-_6=V_{35}$. The gluon remains unchanged.\n\\begin{equation}\ng = \\Gamma_{gg}g_0 + \\Gamma_{gq}d_{1,0}^+\n\\end{equation}\nwhile:\n\\begin{equation}\n\\begin{array}{rcl}\nd_i^\\pm&=&\\displaystyle \\theta_{i2}\\theta(Q-m_i)\\Gamma^{\\pm}d_{i,0}^\\pm+\\theta(m_i-Q)\n\\left\\{\\begin{array}{ll}\n\\Gamma_{qq}d_{1,0}^++\\Gamma_{qg}g_0&\\quad\\mbox{for }+\\\\\n\\Gamma^vd_{1,0}^-&\\quad\\mbox{for }-\n\\end{array}\\right.\\\\\n\\\\\n&=&\\left\\{\\begin{array}{l}\n\\Gamma_{qq}d_{1,0}^++\\Gamma_{qg}g_0\\\\\n\\Gamma^vd_{1,0}^-\n\\end{array}\\right.+\\theta(Q-m_i) \\left[\\theta_{i2}\\Gamma^{\\pm}d_{i,0}^\\pm-\n\\left\\{\\begin{array}{l}\n\\Gamma_{qq}d_{1,0}^++\\Gamma_{qg}g_0\\\\\n\\Gamma^vd_{1,0}^-\n\\end{array}\\right.\\right]\\,.\n\\end{array}\n\\end{equation}\nso that:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle  q_i^- &=& \\displaystyle \\delta_{i1}\n  \\Gamma^vd_{1,0}^-+\\Gamma^{\\pm}\\sum_{j=2}^6\n  \\theta_{ji}\\frac{1-\\delta_{ij}j}{j(j-1)} \n  \\theta(Q-m_j)d_{j,0}^\\pm\n\\end{array}\n\\end{equation}\n\nTherefore, we need to relate these two bases. This is done through the\nlinear transformation:\n\\begin{equation}\\label{TranformationBella}\nq_i^\\pm = \\sum_{j=1}^6M_{ij}d^\\pm_j\\,,\n\\end{equation}\nwhere the trasformation matrix $M_{ij}$ can be written as:\n\\begin{equation}\\label{TransDef}\n\\begin{array}{l}\n\\displaystyle M_{ij}=\\theta_{ji}\\frac{1-\\delta_{ij}j}{j(j-1)}\\quad j\\geq 2\\,,\\\\\n\\\\\n\\displaystyle M_{i1} = \\frac{1}{6}\\,,\n\\end{array}\n\\end{equation}\nwith $\\theta_{ji}=1$ for $j\\geq i$ and zero otherwise. \n\n\nUsing eq.~(\\ref{TranformationBella}) we can make the following\nidentifications:\n\\begin{equation}\nD^{\\pm} = q_{2j-1}^\\pm\\quad\\mbox{and}\\quad U^{\\pm} =\nq_{2j}^\\pm\\,,\\quad j=1,2,3\\,,\n\\end{equation}\nso that we can write:\n\\begin{equation}\nF^\\pm=\n\\frac12\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2\\left[C_\\pm\\left(q_{2j-1}^\\pm\n    \\pm q_{2i}^\\pm\\right) + 4P^{\\pm} C_g g\\right]\\,.\n\\end{equation}\nUsing the definition of $M_{ij}$ in eq.~(\\ref{TransDef}), we can\nrewrite $F^{\\pm}$ in terms of PDFs in the evolution basis as:\n\\begin{equation}\\label{eq:decompF2L}\nF^\\pm=\n\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 F_{ij}^\\pm\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{F2Ldef}\nF_{ij}^\\pm=\nC_g 2P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\pm \\frac16 d_1^\\pm\n+ C_\\pm\\sum_{k=2}^6\\frac{\\theta_{k,2j-1}(1-\\delta_{2j-1,k}k)\\pm \\theta_{k,2i}(1-\\delta_{2i,k}k) }{2k(k-1)}d_k^\\pm\\,.\n\\end{equation}\n\nEq.~(\\ref{F2Ldef}) is valid only for $F_2$ and $F_3$. In order to\nobtain a similar equation also for $F_3$, one needs to change sign to\nthe antiquark distributions, $i.e.$\n$\\overline{q}_i\\rightarrow - \\overline{q}_i$. In the QCD evolution\nbasis, this has the consequence of exchanging the $T$-like\ndistributions with the $V$-like ones, that is to say\n$d_k^+\\leftrightarrow d_k^-$. It is the easy to see that:\n\\begin{equation}\nF_3^\\pm=\n\\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 F_{3,ij}^\\pm\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{F3def}\nF_{3,ij}^\\pm=\nC_g 2P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\mp \\frac16 d_1^\\pm\n+ C_\\pm\\sum_{k=2}^6\\frac{\\theta_{k,2j-1}(1-\\delta_{2j-1,k}k)\\mp \\theta_{k,2i}(1-\\delta_{2i,k}k) }{2k(k-1)}d_k^\\pm\\,.\n\\end{equation}\n\nIt is now useful to consider the inclusive structure functions and\nexploit the unitarity of the CKM matrix elements $V_{UD}$:\n\\begin{equation}\n\\sum_{i=1}^3|V_{2i,(2j-1)}|^2 = \\sum_{j=1}^3|V_{2i,(2j-1)}|^2 = 1\\quad\\Rightarrow\\quad \\sum_{i=1}^3\\sum_{j=1}^3|V_{2i,(2j-1)}|^2 = 3\\,.\n\\end{equation}\nSumming over $i$ and $j$ in eq.~(\\ref{eq:decompF2L}) and using\neq.~(\\ref{F2Ldef}), one obtains:\n\\begin{equation}\nF^\\pm=\nC_g 6P^\\pm g\n+\nC_\\pm^{\\rm S} P^\\pm \\frac12 d_1^\\pm\n+ \\frac12 C_\\pm\\sum_{k=2}^6 d_k^\\pm\\sum_{l=1}^6(\\pm 1)^{l+1}M_{lk}\\,.\n\\end{equation}\nConsidering separately $F^+$ and $F^-$ and using\neq.~(\\ref{eq:properties}), one finds:\n\\begin{equation}\nF^+= C_g 6g + C_+^{\\rm S} \\frac12 d_1^+\n\\end{equation}\nand:\n\\begin{equation}\nF^-= \\frac12 C_-\\sum_{k=2}^6\\left[\\frac{P^+}{k-1}-\\frac{P^-}{k}\\right]d_k^-\\,,\n\\end{equation}\nwith the even/odd projectors defined as:\n\\begin{equation}\nP_k^{\\pm} = \\frac{1\\pm(-1)^k}{2}\\,.\n\\end{equation}\n\nIt should be pointed out that such simple expressions (independent of\nthe CMK matrix elements) is achievable only if it is possible to\nfactorize the non-singlet coefficient functions as implicitly done in\neqs.~(\\ref{F2Ldef}) and~(\\ref{F3def}). In fact, this is possible only\nin the ZM case in which the coefficient functions of each PDF\ncombination is the same.\n\nFor $F_3$ we find:\n\\begin{equation}\nF_3^+= C_g 6g + C_-^{\\rm S} \\frac12 d_1^-\n\\end{equation}\nand:\n\\begin{equation}\nF_3^-= \\frac12 C_+\\sum_{k=2}^6\\left[\\frac{P_k^+}{k-1}-\\frac{P_k^-}{k}\\right]d_k^+\\,.\n\\end{equation}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "9fabb564cca6e533a5c678fce1efa8987fa71e79", "size": 6777, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/EvolDIS.tex", "max_stars_repo_name": "intrepid42/apfelxx", "max_stars_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/EvolDIS.tex", "max_issues_repo_name": "intrepid42/apfelxx", "max_issues_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/EvolDIS.tex", "max_forks_repo_name": "intrepid42/apfelxx", "max_forks_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.9452054795, "max_line_length": 135, "alphanum_fraction": 0.6764054892, "num_tokens": 2716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4236039578479138}}
{"text": "\\chapter{Introduction}\n\\label{ch_msvst_intro}\n\nSeveral techniques have been proposed in the literature to estimate Poisson intensity in 2D. A major class of methods adopt a multiscale bayesian framework specifically tailored for Poisson data~\\citep{Nowak2000}, independently initiated by \\citet{wave:timmermann99} and \\citet{Kolaczyk1999}. \\citet{Lefkimmiatis} proposed an improved bayesian framework for analyzing Poisson processes, based on a multiscale representation of the Poisson process in which the ratios of the underlying Poisson intensities in adjacent scales are modeled as mixtures of conjugate parametric distributions. Another approach includes preprocessing the count data by a variance stabilizing transform (VST) such as the Anscombe \\citep{rest:anscombe48} and the Fisz \\citep{rest:nason04} transforms, applied respectively \nin the spatial~\\citep{rest:donoho93_2} or in the wavelet domain~\\citep{Fryzlewicz2004}. The transform reforms the data so that the noise approximately becomes Gaussian with a constant variance. Standard techniques for independant identically distributed Gaussian noise are then used for denoising. \\citet{starck:zhang07} proposed a powerful method called Multi-Scale Variance Stabilizing Tranform (MS-VST). It consists in combining a VST with a multiscale transform (wavelets, ridgelets or curvelets), yielding asymptotically normally distributed coefficients with known variances. The choice of the multi-scale method depends on the morphology of the data. Wavelets represent more efficiently regular structures and isotropic singularities, whereas ridgelets are designed to represent global lines in an image, and curvelets represent efficiently curvilinear contours. Significant coefficients are then detected with binary hypothesis testing, and the final estimate is reconstructed with an iterative scheme. In \\citet{Starck09:fermi3d}, it was shown that sources can be detected in 3D FERMI LAT data (2D+time or 2D+energy) using a specific 3D extension of the MS-VST.\n \\citet{Schmitt} proposed a method for Poisson intensity estimation on spherical data called Multi-Scale Variance Stabilizing Transform on the Sphere (MS-VSTS). This MS-VSTS (Multi-Scale Variance Stabilizing Transform on the Sphere) package offers a Poisson denoising method on the sphere, designed for Fermi photon counts maps.\nThis method is based on the MS-VST~\\citep{starck:zhang07} and on multi-scale transforms on the sphere \\citep{starck2006,inpainting:abrial06,starck:abrial08}.\n Chapter~\\ref{ch_msvsts} introduces the MS-VSTS. \n Chapter~\\ref{ch_denoising} applies the MS-VSTS to spherical data restoration. Chapter~\\ref{ch_inpainting} applies the MS-VSTS to inpainting. Chapter~\\ref{ch_background} applies the MS-VSTS to background extraction. An accurate description of the IDL routines that makeup this package is given in Chapter~\\ref{ch_idlproc}. An extension to multichannel denoising and deconvolution is given in Chapter~\\ref{ch_multichannel} Conclusions are drawn in Chapter~\\ref{ch_conclusion}. All experiments were performed on HEALPix maps with $nside=128$~\\citep{pixel:healpix}, which corresponds to a good pixelisation choice for  data such as the GLAST/FERMI resolution. The performance of the method is not dependent on the nside parameter. For a given data set, if nside is small, it just means that we don't want to investigate the finest scales. If nside is large, the number of counts per pixel will be very small, and we may not have enough statistics to get any information at the finest resolution levels. But it will not have any bad effect on the solution. Indeed,  the finest scales\nwill be smoothed, since our algorithm will not detect any significant wavelet coefficients in the finest scales. Hence, starting with a fine pixelisation (i.e. large nside), our method will provide a kind of automatic binning, by thresholding wavelets coefficients at scales and at spatial positions where the number of counts is not sufficient.\n\n\n\n\n% \\newpage\n", "meta": {"hexsha": "56e3887d9e8f9564a06db9587b386011ec37683b", "size": 3993, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_isap/msvst_intro.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_isap/msvst_intro.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_isap/msvst_intro.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 249.5625, "max_line_length": 1170, "alphanum_fraction": 0.8201853243, "num_tokens": 937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4236039514674462}}
{"text": "Plasma Cash is a plasma construction with much less user data checking \\cite{plasma_cash}. It\nutilizes Non-Fungible-Tokens (NFTs) to reduce the\nuser checking requirements to only the NFTs that they own\\footnote{Plasma-MVP requires users to be constantly monitoring the plasmachain for fraudulent state transitions, while Plasma Cash requires that users only watch the mainchain about fraudulent exits of coins that they own}. The system's security relies on users fully authenticating a coin's history before accepting it as a payment by utilizing Sparse Merkle Trees, which allow the efficient verification of inclusion and non-inclusion of a transaction in a block, as explained in the next subsection.\n\n\\subsection{Sparse Merkle Trees} \n\nA Merkle Tree is a data structure which allows to succinctly commit to a dataset and prove the inclusion of a part of the committed dataset in $O(log_2(N))$ steps instead of $O(N)$, where $N$ is the number of elements in the dataset, via \\textit{Merkle Proofs}. The committed value is called a \\textit{Merkle Root}. A Sparse Merkle Tree (SMTs) \\cite{sparse_merkle_trees} is an ordered merkle tree, where each element of the dataset is placed at the leaf with the index corresponding the element's index in the dataset. If an element of the dataset was not included in the Merkle Root, its leaf is set to a special default value. \n\nThe inclusion of a transaction spending a coin in a block can be efficiently proven through a Merkle Proof. The same method can be used to prove the non-inclusion of a spend of a coin in a block. A coin can only be spent once per block because only 1 transaction at its slot can ever exist. If a coin was not spent, the leaf is set to the hash of 0. A visual representation of the above is given in Figure \\ref{fig:smt}.\n\n\\input{figures/smt}\n\nFurther optimizations can be done to the verifier\nas suggested in \\cite{smt_compact_proofs} by precomputing the default values of\nthe SMT and by introducing a bitfield in the proof which acts as a\nswitch between choosing the next 32 bytes during the verification from the\nproof or from the SMT's default hashes. A reasonable estimation for a block\ncontaining 2378 transactions results in proof sizes being 320 bytes, compared\nto normal proofs which would be 2048 (64 * 32) bytes, for a SMT of size 64.\n\n\\subsection{Periodic Merkle Commitments}\nAll Plasma designs rely on a plasmachain operator that commits the\nMerkle Root of each generated block to the mainchain. If a Proof of Stake system is used, publishing a block must be accompanied by a number of validator signatures, exceeding a pre-agreed threshold. \nWhenever a Plasma Block's root is committed to the rootchain, all valid\ntransactions in that given block can be considered finalized upon availability of the related witness data\\footnote{By witness data we refer to the merkle proof of inclusion of that coin in the specified block} for the inclusion of these transactions. Since only the\nblock root is committed to the mainchain instead of all the included\ntransactions, plasma can bundle together any number of transactions, the only limit to the number of included transactions being the size of the plasma block. The minimum finality time that\ncan be achieved is the block time of the rootchain (15 seconds in Ethereum).\nGiven that every block must be published to the mainchain, the operational costs for this process can become large. Operators can be expected to trade bigger finality time for less maintenance costs by committing block roots less often.\n\n\n\\subsection{Non Fungible Tokens and Depositing a Coin}\n\nWhen value gets deposited in the plasma smart contract, a unique id and metadata key-value pair gets generated for that token and is saved in the contract's storage. The id is the unique serial number of the coin, and is what makes the deposited coin non-fungible. As a result, depositing 5 ETH two times creates two coins which have their own unique transaction history and are independent from each other. The unique id can also be thought of as a serial number, compared to fiat cash money.\n\nAfter the coin gets saved in the smart contract, a block containing only the deposit transaction is appended to the plasmachain\\footnote{Deposit blocks including only one transaction is an optimization, https://ethresear.ch/t/one-plasma-cash-block-per-deposit-why/2674/}.\n\n% Figure \\ref{fig:plasma_cash_deposit} illustrates the process for depositing a\n% coin (Ether, ERC20, ERC721, or any other standard) to a Plasma Cash chain. \n% \n% \\input{protocols/prot_deposit}\n\\subsection{Transferring a Coin and Verifying its History}\n\\label{verify_coin_history}\nEach coin in Plasma Cash has its own unique coin history. A coin receiver  must\nverify that the coin they are receiving has a valid history in order to accept \nit. A coin with invalid history is counterfeit\nand cannot be withdrawn safely. In order to validate a coin's\nhistory, a set of merkle proofs of inclusion\nand non-inclusion for the coin since its initial deposit must be sent to the receiver. The receiver can then\nproceed to verify that there were no invalid spends of the coin in the coin's\nhistory. This is done by verifying that the proofs of inclusion and non-inclusion are valid\nagainst the plasma block merkle roots that were published to the mainchain.\n\nThis imposes a heavy storage and bandwith burden on senders that \nwant to transfer a coin. Specifically, the proofs required to send a coin are \n$O(t * log_{2}(N))$ where $t$ is the number of blocks since a coin's deposit and $N$ is the number\nof coins the Plasma Cash chain supports.\n\nIn a real world scenario where a buyer wants to buy a product from a vendor the\nfollowing is expected to happen, in a non-fraudulent case:\n\\begin{enumerate}\n    \\item Buyer broadcasts transaction giving ownership of their coin to the\n        seller\n    \\item Transaction gets included in a block and witness data about its inclusion is made available\n    \\item Buyer verifies that the transaction was included in the block\n    \\item Buyer sends the proofs of inclusion and non-inclusion to the vendor.\n    \\item Vendor verifies the history of the coin along with the correct inclusion of the coin's transaction in the block.\n    \\item Vendor gives the product to buyer\n\\end{enumerate}\n\nA transaction is a tuple: \\texttt{Tx(slot, parentBlock, newOwner, prevOwnerSignature)}. A transaction that was included in a block is a combination of the previous tuple and a merkle proof for the block: \\texttt{IncludedTx(tx, blkNumber, proof)}.\n\nThe algorithm for verifying the history of a coin is given in Figure \\ref{fig:transfer_coin}\n\n\\input{protocols/prot_transfer_coin}\n\n\\subsection{Exiting and Withdrawing a Coin} \\label{exiting_withdrawing}\nAs described in Section \\ref{ch2:classic_plasma}, exits are the mechanism by\nwhich a coin can be withdrawn from the plasmachain, and allow it to be\ntransferred back to its owner's account on the mainchain. \n\nStarting an exit for a coin requires providing the transaction that gave the\nexitor ownership of the coin signed by the previous owner in the coin's history, \\textbf{tx}, as well\nas a direct ancestor of that transaction (the reason the parent transaction must also be provided is explained in Section 4). Merkle proofs of inclusion need to also be provided for both transactions.\n\n\\begin{figure}[H]\n\t\\makebox[\\linewidth]{\n\t\t\\scalebox{0.6}{\n\t\t\\includegraphics[width=\\linewidth]{figures/coin_exit.pdf}\n\t\t}\n\t\t}\n\t\\caption{\n        Alice deposits a coin from the mainchain to the plasmachain in Block 1. Alice sends the coin to Bob in Block 2. Bob verifies the inclusion of the coin in Block 2. Block 3 gets submitted, without including the coin. Bob sends the coin to Charlie in Block 4. Charlie has to verify the inclusion of the coin in Block 1 and 2, and the non-inclusion of the coin in Block 3. \n        In order for Charlie to exit the coin received by Bob he has to provide\n        the signed transaction from Bob as well as a direct ancestor, in this\n        case the transaction from Alice to Bob. Charlie also needs to supply\n        merkle proofs of inclusion for both of these transactions at their\n        respective blocks. \n\t}\n    \\label{fig:exit_lifetime}\n\\end{figure}\n\nA coin can be modelled by a state machine. After starting an exit, the coin transitions to the \\texttt{EXITING} \nstate. After the challenge (or maturity) period passes, \nthe coin's exit can be finalized and it can transition to the \\texttt{EXITED} \nstate, from which it can be withdrawn to a user's wallet, \nas shown in Figure\n\\ref{fig:exit_state_machine}. Figure \\ref{fig:exit_lifetime} illustrates the \nlifetime of an exit from its initialization to its finalization. \nWe further discuss challenges in Section \\ref{ch:attacks}.\n\\begin{figure}[H]\n\t\\makebox[\\linewidth]{\n\t\t\\scalebox{0.7}{\n\t\t\\includegraphics[width=\\linewidth]{figures/exit_state_machine.pdf}\n\t\t}\n\t\t}\n\t\\caption{\n        The stages of an exit. After a coin transitions to the \\texttt{EXITED}\n        state, it can be withdrawn to its owner's wallet.\n\t}\n    \\label{fig:exit_state_machine}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\t\\makebox[\\linewidth]{\n\t\t\\scalebox{0.8}{\n\t\t\\includegraphics[width=\\linewidth]{figures/exit_lifetime.pdf}\n\t\t}\n\t\t}\n\t\\caption{\n\t\tDuring its lifetime, an exit can be challenged during the maturity period. After its maturity period is over, it can be\n        finalized and the exiting coin can be withdrawn.\n\t}\n    \\label{fig:exit_lifetime}\n\\end{figure}\n", "meta": {"hexsha": "8defdb04fcb920ce0c31c7141ba3a670d893581c", "size": 9464, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/plasma_cash.tex", "max_stars_repo_name": "loomnetwork/plasma-paper", "max_stars_repo_head_hexsha": "f7fd67b834ba25ef7b2659b15edcb4ebc9ea9749", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 49, "max_stars_repo_stars_event_min_datetime": "2018-10-17T09:43:43.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-17T20:58:11.000Z", "max_issues_repo_path": "sections/plasma_cash.tex", "max_issues_repo_name": "gakonst/plasma-cash-paper", "max_issues_repo_head_hexsha": "f7fd67b834ba25ef7b2659b15edcb4ebc9ea9749", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-12-03T16:17:48.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-16T18:09:28.000Z", "max_forks_repo_path": "sections/plasma_cash.tex", "max_forks_repo_name": "gakonst/plasma-cash-paper", "max_forks_repo_head_hexsha": "f7fd67b834ba25ef7b2659b15edcb4ebc9ea9749", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-10-27T23:54:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-16T18:00:06.000Z", "avg_line_length": 69.0802919708, "max_line_length": 629, "alphanum_fraction": 0.7827557058, "num_tokens": 2207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4236039504193495}}
{"text": "\\documentclass[a4paper, 11pt]{article}\n\\usepackage{comment} % enables the use of multi-line comments (\\ifx \\fi)  \n\\usepackage{fullpage} % changes the margin\n\\usepackage{graphicx}\n\\begin{document}\n%Header-Make sure you update this information!!!!\n\\noindent\n\\large\\textbf{Homework Assignment X} \\hfill \\textbf{Anirudh Ganesh} \\\\\n\\normalsize Computer Vision for HCI \\hfill CSE5524 (Au `18) \\\\\nProf. Jim Davis \\hfill Score: \\_\\_\\_/12 \\\\\nTA: Sayan Mandal \\hfill Due Date: 11/13/18\n\n\\section*{PART A: Back Propagation}\n\n\\begin{figure}[h]\n\\centering\n  \\includegraphics[scale=0.4]{backprop.png}\n  \\caption{The given network.}\n\\end{figure}\n\n\nGoal is to determine the new weight parameter $w_5$ after one cycle of Gradient Descent using the single example given to us.\n\n$$\\frac{\\partial E_{total}}{\\partial w_5} = \\frac{\\partial E_{total}}{\\partial out_{01}} * \\frac{\\partial out_{01}}{\\partial net_{01}} * \\frac{\\partial net_{01}}{\\partial w_5}$$\n\n\\subsection*{Calculating gradient of error}\n\nThe error function is given as,\n\n$$ E_{total} = \\frac{1}{2}(target_{01} - out_{01})^2 + \\frac{1}{2}(target_{02} - out_{02})^2$$\n\n\\noindent Thus, the gradient of error is given as,\n\n$$ \\frac{\\partial E_{total}}{\\partial out_{01}} =  -(target_{01} - out_{01}) = -(0.5 - 0.624) = 0.124$$\n\n\\subsection*{Calculating $\\Delta out_{01}$}\n\nOutput layer is given by,\n\n$$ out_{01} = \\frac{1}{1+e^{-net_{01}}}$$\n\n\\noindent Thus the $\\Delta out_{01}$ is given by,\n\n$$ \\frac{\\partial out_{01}}{\\partial net_{01}} = out_{01} * (1 - out_{01}) = (0.624) * (1 - 0.624) = 0.235$$\n\n\\subsection*{Calculating $\\Delta net_{01}$}\n\nNet activation for the layer is given by,\n\n$$ net_{01} = w_5 * out_{h1} + w_6 * out_{h2} + b_2$$\n\n\\noindent Thus the $\\Delta net_{01}$ can be computed as,\n\n$$ \\frac{\\partial net_{01}}{\\partial w_5} = out_{h1} $$\n\n\\noindent In order to compute $out_{h1}$, we need $net_{h1}$,\n\n$$ net_{h1} = i_1*w_1 + i_2 * w_2 + b_1 = (0.4*0.1) + (0.6*0.2) + 0.4 = 0.04 + 0.12 + 0.4 = 0.56$$\n\n\\noindent From this we compute $out_{h1}$ as,\n\n$$ out_{h1} = \\frac{1}{1+e^{-net_{h1}}} = \\frac{1}{1+e^{-0.56}} = 0.636$$\n\n\\noindent Coming back to our $\\Delta net_{01}$,\n\n$$ \\frac{\\partial net_{01}}{\\partial w_5} = out_{h1} = 0.636$$\n\n\\subsection*{Compute the step for gradient descent}\n\n$$\\frac{\\partial E_{total}}{\\partial w_5} = \\frac{\\partial E_{total}}{\\partial out_{01}} * \\frac{\\partial out_{01}}{\\partial net_{01}} * \\frac{\\partial net_{01}}{\\partial w_5} = 0.124 * 0.235 * 0.636 = 0.019$$\n\n\\subsection*{Update the weight, $\\alpha = 0.3$}\n\n$$w_5 = w_5 - \\alpha \\frac{\\partial E_{total}}{\\partial w_5} = 0.3 - 0.3 * 0.019 = 0.294$$\n\n\\section*{PART B: Convolutional Neural Networks}\n\nSo we start off straight off the shelf with a pretty good baseline of $96.76\\%$. In-order to improve the accuracy from the baseline, I tried a couple of things. \n\nFirst of all was experimenting the the different filter size of the first convolutional layer. After some tweaking a filter size of 3, and a filter number of 32 was found to be the optimal. This change bumped up the models performance to $96.96\\%$.\n\nThe next major change was to add a fully connected layer of 128 nodes before the classifying layer. To mitigate the slowdown in training, batch size was bumped up to 512. These changes give us our best performance of $97.98\\%$.\n\nNow, in-order to further increase performance, it was clear that I had to incorporate multiple convolutional layers. But try as I might, in different orders and combinations, the code given utilized the convolutional layer in a format that was unfamiliar to me. So I re-created the similar model with a similar performance in Keras and Python using a Tensorflow backend with a new baseline of $95.48\\%$. After this, I was able to add two sets of 64,3 2d convolutional layer, followed by a maxpool of 2x2, followed by two convolution of 128, 3 followed by another maxpool of 2x2. Finally a dense network of 256 and a softmax (all with ReLU activation by default). This gives the best performance of $99.73\\%$. I then converted these weights from Keras's h5 format to mat format. Though I don't know how grader is going to utilize this hence this model is submitted separately.\n\n\\end{document}\n", "meta": {"hexsha": "e9688b55cfdc0f2e304ea31ae911d576f0f1c0d8", "size": 4191, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hwX/tex/documentation.tex", "max_stars_repo_name": "TheAnig/computer-vision", "max_stars_repo_head_hexsha": "8305de003896cb1b9a8c7302fa832c5b8f271477", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hwX/tex/documentation.tex", "max_issues_repo_name": "TheAnig/computer-vision", "max_issues_repo_head_hexsha": "8305de003896cb1b9a8c7302fa832c5b8f271477", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hwX/tex/documentation.tex", "max_forks_repo_name": "TheAnig/computer-vision", "max_forks_repo_head_hexsha": "8305de003896cb1b9a8c7302fa832c5b8f271477", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1724137931, "max_line_length": 875, "alphanum_fraction": 0.7007874016, "num_tokens": 1335, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.4236039504193495}}
{"text": "% !TeX root = constructions.tex\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Trisecting an Angle}\\label{c.trisection}\n\n\n\\section{Abe's trisection of an angle}\\label{s.tri1}\n\nThis construction is based upon the presentation in \\cite{newton}. The second proof is based upon \\cite{oriah}.\n\n\\subsection{The construction}\n\n\\begin{center}\n\\begin{tikzpicture}[scale=1]\n\n% Place points P, Q, R\n\\coordinate (P) at (60:10cm); %(5,8.67);\n\\coordinate (Q) at (0,0);\n\\coordinate (R) at (10,0);\n\\fill (P) circle (2pt) node[below right] {$P$};\n\\fill (Q) circle (2pt) node[left] {$Q$};\n\\fill (R) circle (2pt) node[right] {$R$};\n\n% Draw PQR\n\\draw [very thick] (P)  -- (Q) -- (R);\n\n% Draw perpendicular to QR\n\\draw [thick] (Q) -- node[left,very near end] {$p$} +(0,11);\n\n% Draw parallel to QR and parallel halfway\n\\coordinate (A) at (0,5);\n\\coordinate (B) at (0,2.5);\n\\draw [thick] (A) -- node[above,very near end] {$q$} +(10,0);\n\\draw [thick] (B) -- node[above,very near end] {$r$} +(10,0);\n\\fill (A) circle (1.5pt) node[left] {$A$};\n\\fill (B) circle (1.5pt) node[left] {$B$};\n\\path (Q) -- node[left] {$a$} (B) -- node[left] {$a$} (A);\n\\draw (A) rectangle +(8pt,8pt);\n\\draw (B) rectangle +(8pt,8pt);\n\n% Tangent line y = -2.75x + 10.69\n\n% Draw fold\n\\coordinate (D) at (0,10.69);\n\\coordinate (fold-x) at (3.89,0);\n\\coordinate (AP) at (3.65,6.33);\n\\coordinate (QP) at (6.87,2.5);\n\\coordinate (BP) at (5.26,4.42);\n\\fill (D) circle (1.5pt) node[left] {$D$};\n\\fill (AP) circle (1.5pt) node[above,yshift=6pt] {$A'$};\n\\fill (QP) circle (1.5pt) node[above,yshift=6pt] {$Q'$};\n\\fill (BP) circle (1.5pt) node[above,xshift=2pt,yshift=2pt] {$B'$};\n\\draw [very thick,dashed] (D) -- node[left,near start] {$l$} (fold-x);\n\n% Draw line of reflections\n\\draw [very thick, dotted] (D) -- (QP);\n\n% Draw trisecting lines\n\\draw [very thick,dotted] (Q) -- ($(Q)!1.3!(QP)$);\n\\draw [very thick,dotted] (Q) -- ($(Q)!1.3!(BP)$);\n\n% Complete triangle\n\\draw [very thick,dotted] (A) -- (QP);\n\n\\end{tikzpicture}\n\\end{center}\n\nGiven an acute angle $\\angle PQR$, let $p$ be the perpendicular to $\\overline{QR}$ at $Q$. Let $q$ be a perpendicular to $p$ that intersects $\\overline{PQ}$ at point $A$, and let $r$ be the perpendicular to $p$ at $B$ that is halfway between $Q$ and $A$.\n\nUsing Axiom~6, construct a fold $l$ that places $A$ at $A'$ on $\\overline{PQ}$ and $Q$ at $Q'$ on $r$. Let $B'$ be the reflection of $B$ around $l$.\n\nDraw the lines $\\overline{QB'}$ and $QQ'$. We claim that $\\angle PQB'$, $\\angle B'QQ'$ and $\\angle Q'QR$ are a trisection of $\\angle PQR$.\n\n\\subsection{First proof}\n\n\\begin{center}\n\\begin{tikzpicture}[scale=1]\n\n% Place points P, Q, R\n\\coordinate (P) at (60:10cm);\n\\coordinate (Q) at (0,0);\n\\coordinate (R) at (10,0);\n\\fill (P) circle (1.5pt) node[below right] {$P$};\n\\fill (Q) circle (1.5pt) node[left,xshift=-4pt] {$Q$};\n\\fill (R) circle (1.5pt) node[right] {$R$};\n\n% Draw PQR\n\\draw [very thick] (Q) -- (R);\n\n% Draw perpendicular to QR\n\\draw [thick] (Q) -- node[left,very near end] {$p$} +(0,11);\n\n% Draw parallel to QR and parallel halfway\n\\coordinate (A) at (0,5);\n\\coordinate (B) at (0,2.5);\n\\draw [thick] (A) -- node[above,very near end] {$q$} +(10,0);\n\\draw [thick] (B) -- node[above,very near end] {$r$} +(10,0);\n\\fill (A) circle (1.5pt) node[left,xshift=-4pt] {$A$};\n\\fill (B) circle (1.5pt) node[left,xshift=-4pt] {$B$};\n\\path (Q) -- node[left,xshift=-4pt] {$a$} (B) -- node[left,xshift=-4pt] {$a$} (A);\n\\draw (A) rectangle +(8pt,8pt);\n\\draw (B) rectangle +(8pt,8pt);\n\n% Tangent line y = -2.75x + 10.69\n\n% Draw fold\n\\coordinate (D) at (0,10.69);\n\\coordinate (fold-x) at (3.89,0);\n\\coordinate (AP) at (3.65,6.33);\n\\coordinate (QP) at (6.87,2.5);\n\\coordinate (BP) at (5.26,4.42);\n\\fill (D) circle (1.5pt) node[left] {$D$};\n\\fill (AP) circle (1.5pt) node[above,yshift=6pt] {$A'$};\n\\fill (QP) circle (1.5pt) node[above,xshift=2pt,yshift=6pt] {$Q'$};\n\\fill (BP) circle (1.5pt) node[above,xshift=4pt,yshift=2pt] {$B'$};\n\\draw [very thick,dashed] (D) -- node[left,near start] {$l$} (fold-x);\n\t\n% Draw line of reflections\n\\draw [very thick, dotted] (D) -- (AP);\n\n% Draw trisecting lines\n\\draw [very thick,dotted] (Q) -- ($(Q)!1.3!(BP)$);\n\n\\draw [very thick,loosely dash dot,red] (Q) -- (QP);\n\\draw [very thick,loosely dash dot,red] (QP) -- (AP);\n\\draw [very thick,loosely dash dot,red] (AP) -- (Q);\n\\draw [very thick,loosely dash dot dot,blue] ($(Q)+(0,-4pt)$) -- ($(QP)+(0,-4pt)$);\n\\draw [very thick,dash dot dot,blue] ($(QP)+(0,-4pt)$) -- ($(A)+(0,-4pt)$);\n\\draw [very thick,dash dot dot,blue] ($(A)+(-4pt,0)$) -- ($(Q)+(-4pt,0)$);\n\n\\draw [thick,dotted] (A) -- (AP);\n\n\\node[left,xshift=-40pt,yshift=7pt] at (QP) {$\\alpha$};\n\\node[left,xshift=-40pt,yshift=-6pt] at (QP) {$\\alpha$};\n\\node[right,xshift=40pt,yshift=6pt] at (Q) {$\\alpha$};\n\\node[right,xshift=40pt,yshift=28pt] at (Q) {$\\alpha$};\n\\node[right,xshift=30pt,yshift=42pt] at (Q) {$\\alpha$};\n\n\\end{tikzpicture}\n\\end{center}\n\n\nSince $A', B', Q'$ are all reflections around the same line $l$ of the points $A,B,Q$ on one line $DQ$, they are all on one line $\\overline{DQ'}$. By construction, $\\overline{AB}=\\overline{BQ}$, $\\overline{BQ'}$ is perpendicular to $AQ$; $\\overline{BQ'}$ is a common side, so $\\triangle ABQ'\\cong \\triangle QBQ'$ by side-angle-side. Therefore, $\\angle AQ'B=\\angle QQ'B=\\alpha$, since $\\overline{Q'B}$ is the perpendicular bisector of the isoceles triangle $\\triangle AQ'Q$.\n\nBy alternating interior angles, $\\angle Q'QR=\\angle QQ'B=\\alpha$.\n\nBy reflection, $\\triangle AQ'Q\\cong \\triangle A'QQ'$.\\footnote{The two triangles have been emphasized using different patterns of dashes and dots, as well as using color.}\n\\begin{quote}\nThe fold $l$ is the perpendicular bisector of both $\\overline{AA'}$ and $\\overline{QQ'}$; drop perpendiculars from $A$ and $A'$ to $\\overline{QQ'}$; then $\\overline{AQ}=\\overline{A'Q'}$ follows by congruent right triangles. $\\overline{AA'Q'Q}$ is an isoceles trapezoid so its diagonals are equal $\\overline{AQ'}=\\overline{A'Q}$.\n\\end{quote}\nTherefore, $\\overline{QB'}$, the reflection of $\\overline{Q'B}$, is the perpendicular bisector of an isoceles triangle and $\\angle A'QB'=\\angle B'QQ'=\\angle QQ'B=\\angle Q'QR=\\alpha$.\n\n\n\\subsection{Second proof}\n\n\\begin{center}\n\\begin{tikzpicture}[scale=1]\n\n% Place points P, Q, R\n\\coordinate (P) at (60:10cm); %(5,8.67);\n\\coordinate (Q) at (0,0);\n\\coordinate (R) at (10,0);\n\\fill (P) circle (1.5pt) node[below right] {$P$};\n\\fill (Q) circle (1.5pt) node[left] {$Q$};\n\\fill (R) circle (1.5pt) node[right] {$R$};\n\n% Draw PQR\n\\draw [very thick] (P)  -- (Q) -- (R);\n\n% Draw perpendicular to QR\n\\draw [thick] (Q) -- node[left,very near end] {$p$} +(0,11);\n\n% Draw parallel to QR and parallel halfway\n\\coordinate (A) at (0,5);\n\\coordinate (B) at (0,2.5);\n\\draw [thick] (A) -- node[above,very near end] {$q$} +(10,0);\n\\draw [thick] (B) -- node[above,very near end] {$r$} +(10,0);\n\\fill (A) circle (1.5pt) node[left] {$A$};\n\\fill (B) circle (1.5pt) node[left] {$B$};\n\\path (Q) -- node[left] {$a$} (B) -- node[left] {$a$} (A);\n\\draw (A) rectangle +(8pt,8pt);\n\\draw (B) rectangle +(8pt,8pt);\n\n% Tangent line y = -2.75x + 10.69\n\n% Draw fold\n\\coordinate (D) at (0,10.69);\n\\coordinate (fold-x) at (3.89,0);\n\\coordinate (AP) at (3.65,6.33);\n\\coordinate (QP) at (6.87,2.5);\n\\coordinate (BP) at (5.26,4.42);\n\\fill (D) circle (1.5pt) node[left] {$D$};\n\\fill (AP) circle (1.5pt) node[above,yshift=6pt] {$A'$};\n\\fill (QP) circle (1.5pt) node[above,yshift=6pt] {$Q'$};\n\\fill (BP) circle (1.5pt) node[above,xshift=2pt,yshift=2pt] {$B'$};\n\\draw [very thick,dashed,name path=fold] (D) -- node[left,near start] {$l$} (fold-x);\n\n% Draw line of reflections\n\\draw [very thick, dotted] (D) -- (QP);\n\n% Draw trisecting lines\n\\draw [very thick,dotted,name path=Qr] (Q) -- ($(Q)!1.3!(QP)$);\n\\draw [very thick,dotted,name path=Qq] (Q) -- ($(Q)!1.3!(BP)$);\n\n% Draw indications of right angles\n\\draw[rotate=-140] (BP) rectangle +(8pt,8pt);\n\\path [name intersections = {of = fold and Qr, by = {U}}];\n\\fill (U) circle (1.5pt) node[above left,xshift=-2pt,yshift=-2pt] {$U$};\n\\draw[rotate=20] (U) rectangle +(8pt,8pt);\n\\path [name intersections = {of = fold and Qq, by = {V}}];\n\\fill (V) circle (1.5pt) node[above left,xshift=-2pt,yshift=-2pt] {$V$};\n\n\\path (Q) -- node[below,near end] {$b$} (U);\n\\path (U) -- node[below] {$b$} (QP);\n\n\\node[left,xshift=-40pt,yshift=-6pt] at (QP) {$\\alpha$};\n\\node[right,xshift=40pt,yshift=6pt] at (Q) {$\\alpha$};\n\\node[right,xshift=40pt,yshift=28pt] at (Q) {$\\alpha$};\n\\node[right,xshift=30pt,yshift=42pt] at (Q) {$\\alpha$};\n\\end{tikzpicture}\n\\end{center}\n\n\nSince $l$ is a fold, it is the perpendicular bisector of $\\overline{QQ'}$. Denote the intersection of $l$ with $\\overline{QQ'}$ by $U$, and its intersection with $\\overline{QB'}$ by $V$. $\\triangle VUQ\\cong \\triangle VUQ'$ by side-angle-side since $\\overline{VU}$ is a common side,  the angles at $U$ are right angles and $\\overline{QU}=\\overline{Q'U}=b$. Therefore, $\\angle VQU=\\angle VQ'U=\\alpha$ and then $\\angle Q'QR=\\angle VQ'U=\\alpha$ by alternating interior angles.\n\nAs in Proof 1, $A', B', Q'$ are all reflections around $l$, so they are all on one line $\\overline{DQ'}$, and $\\overline{A'B'}=\\overline{AB}=\\overline{BQ}=\\overline{B'Q'}=a$. Then $\\triangle A'B'Q\\cong\\triangle Q'B'Q$ and $\\angle A'QB'=\\angle Q'QB'=\\alpha$.\n\n\n\\newpage\n\n\\section{Martin's trisection of an angle}\\label{s.tri2}\n\n\\subsection{The construction}\n\n\\begin{center}\n\\begin{tikzpicture}[scale=.9]\n\n% Place points P, Q, R\n\\coordinate (P) at (60:10cm); %(5,8.67);\n\\coordinate (Q) at (0,0);\n\\coordinate (R) at (10,0);\n\\fill (P) circle (2pt) node[below right] {$P$};\n\\fill (Q) circle (2pt) node[above left] {$Q$};\n\\fill (R) circle (2pt) node[right] {$R$};\n\n% Draw PQR\n\\draw [very thick] (R)  -- (Q);\n\\draw [very thick,name path=pq] (Q) -- (P);\n\n% M is the midpoint of PQ\n\\coordinate (M) at (2.5, 4.33);\n\\fill (M) circle (2pt) node[above left,xshift=2pt] {$M$};\n\\draw [rotate=-90] (M) rectangle +(8pt,8pt);\n\n% Drop a perpendicular from M to QR and extend the line upwards\n% This is the given line p\n\\coordinate (pQR) at (M |- Q);\n\\draw [thick,name path=p] (pQR) --\n   node[left, very near end,yshift=28pt] {$p$}\n   ($(pQR)!2!(M)$);\n\\draw (pQR) rectangle +(8pt,8pt);\n\n% Construct q perpendicular to p through M\n\\draw [thick,name path=q] ($(M)+(-2,0)$) --\n   node[above, very near start,xshift=-30pt] {$q$}\n   ($(M)+(10,0)$);\n\n% Construct the fold line t\n% Its equation is y = -2.75x + 18.51, as obtained from Geogebra\n\\coordinate (t1) at (6.7,.085);\n\\coordinate (t2) at (3.5,8.89);\n\\draw [very thick,dashed,name path=t] (t1) --\n   node[very near end,left] {$l$}\n   (t2);\n\n% Construct a perpendicular to t through P\n\\coordinate (perp-p) at ($(t1)!(P)!(t2)$);\n\\path [name path=perp-p] (P) -- ($(P)!2.5!(perp-p)$);\n\n% Get its intersection with t denoted Pt\n% and its intersection with p named PP\n\\path [name intersections = {of = t and perp-p, by = {Pt}}];\n\\path [name intersections = {of = p and perp-p, by = {PP}}];\n\\fill (PP) circle(2pt) node[left] {$P'$};\n\\draw [rotate=22] (Pt) rectangle +(8pt,8pt);\n\n% Draw PT\n\\draw [very thick,dotted] (P) -- (PP);\n\n% Construct a perpendicular to t through Q\n\\coordinate (perp-q) at ($(t1)!(Q)!(t2)$);\n\\path[name path=perp-q] (Q) -- ($(Q)!2.1!(perp-q)$);\n\n% Get its intersection with t denoted V\n% and its intersection with q denoted S=Q'\n\\path [name intersections = {of = t and perp-q, by = {V}}];\n\\path [name intersections = {of = q and perp-q, by = {QP}}];\n\\fill (QP) circle(2pt) node[above,yshift=4pt] {$Q'$};\n\\fill (V) circle(2pt) node[above left,xshift=-4pt,yshift=-2pt] {$V$};\n\\draw [rotate=22] (V) rectangle +(8pt,8pt);\n\n% Draw Q QP\n\\draw [very thick,dotted,name path=qs] (Q) -- (QP);\n\n% Get the intersection of QS with p denoted U\n\\path [name intersections = {of = p and qs, by = {U}}];\n\\fill (U) circle(2pt) node[above left] {$U$};\n\n% Draw PP QP\n\\draw [very thick,dotted,name path=ts] (PP) -- (QP);\n\n% Get its intersection with QP denoted W\n\\path [name intersections = {of = ts and pq, by = {W}}];\n\\fill (W) circle(2pt) node[right,xshift=4pt,yshift=4pt] {$W$};\n\n% Label line segments\n\\path (P) -- node[left] {$a$} (M);\n\\path (M) -- node[left]  {$a$} (Q);\n\\path (PP) -- node[left]  {$b$} (M);\n\\path (M) -- node[right] {$b$} (U);\n\\path (Q) -- node[below,near end] {$c$} (V);\n\\path (V) -- node[below] {$c$} (QP);\n\n% Label angles\n\\node [xshift=5pt,yshift=20pt]        at (M) {$\\gamma$};\n\\node [xshift=-5pt,yshift=-20pt]      at (M) {$\\gamma$};\n\\node [xshift=18pt,yshift=15pt]       at (Q) {$\\beta$};\n\\node [xshift=-18pt,yshift=-15pt]     at (P) {$\\beta$};\n\\node [left,xshift=-30pt,yshift=7pt]  at (QP) {$\\alpha$};\n\\node [left,xshift=-30pt,yshift=-7pt] at (QP) {$\\alpha$};\n\\node [right,xshift=34pt,yshift=7pt]  at (Q) {$\\alpha$};\n\\end{tikzpicture}\n\\end{center}\n\n\nGiven the acute angle $\\angle PQR$, let $M$ be the midpoint of $\\overline{PQ}$. Construct $p$ the perpendicular to $\\overline{QR}$ through $M$ and construct $q$ perpendicular to $p$ through $M$. $q$ is parallel to $\\overline{QR}$.\n\nUsing Axiom 6, construct a fold $l$ that places $P$ at $P'$ on $p$ and $Q$ at $Q'$ on $q$. More than one fold may be possible; choose the one that intersects $\\overline{PM}$.\n\nDraw the lines $\\overline{PP'}$ and $\\overline{QQ'}$. Denote the intersection of $\\overline{QQ'}$ with $p$ by $U$ and its intersection with $l$ by $V$. Denote the intersection of $\\overline{PQ}$ and $P'Q'$ with $l$ by $W$.\\footnote{It is not immediate that both $\\overline{PQ}$ and $P'Q'$ intersect $l$ at the same point. $\\triangle PP'W \\sim \\triangle QQ'W$ so the altitudes divide the vertical angles $\\angle PWP', \\angle QWQ'$ similarly and thus must be on the same line.}\n\n\\subsection{Proof}\n\n$\\triangle QMU\\cong \\triangle PMP'$ by angle-side-angle:  $\\angle P'PM=\\angle UQM=\\beta$ by alternate interior angles; $\\overline{QM}=\\overline{MP}=a$ since $M$ is the midpoint of $\\overline{PQ}$; $\\angle QMU=\\angle PMP'$ are vertical angles. Therefore, $\\overline{P'M}=\\overline{MU}=b$.\n\n$\\triangle P'MQ'\\cong \\triangle UMQ'$ by side-angle-side: we have shown that $\\overline{P'M}=\\overline{MU}=b$; the angles at $M$ are right angles; $\\overline{MQ'}$ is a common side. Since the altitude of the isoceles triangle $\\triangle P'Q'U$ is the bisector of $\\angle P'Q'U$, so $\\angle P'Q'M=\\angle UQ'M=\\alpha$.\n\n$\\triangle QWV\\cong\\triangle Q'WV$ by side-angle-side: $\\overline{QV}=\\overline{VQ'}=c$; the angles at $V$ are right angles since the fold is the perpendicular bisector of $\\overline{QQ'}$; $\\overline{VW}$ is a common side. Therefore, $\\angle WQV=\\beta=\\angle WQ'V=2\\alpha$. By alternate interior angles $\\angle Q'QR=\\angle MQ'Q=\\alpha$. We have $\\angle PQR = \\beta + \\alpha = 2\\alpha+\\alpha=3\\alpha$ so $\\angle Q'QR$ is one-third of $\\angle PQR$.\n", "meta": {"hexsha": "19aef4d0a1b6e995d82e9fa4bd0cca7906404f22", "size": 14659, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "trisection.tex", "max_stars_repo_name": "motib/constructions", "max_stars_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-07T15:57:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-07T15:57:52.000Z", "max_issues_repo_path": "trisection.tex", "max_issues_repo_name": "motib/constructions", "max_issues_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "trisection.tex", "max_forks_repo_name": "motib/constructions", "max_forks_repo_head_hexsha": "8f8f4f25a91abb31b8392b83802e7f5ed42462c7", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.0028653295, "max_line_length": 475, "alphanum_fraction": 0.6307387953, "num_tokens": 5433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.4235268114801331}}
{"text": "\\label{s:appendix:intrinsic}\n\\section{Interaction in the effective model}\n\nNote that for the effective low-energy, dual-valley model,\n\\cref{eq:interaction:tight-binding:final}\nis oversimplified.\nWe must first split up each integral into\na region about each valley center.\nThe allowed transitions are still constrained\nby global conservation of momentum.\n\nStarting with\n\\cref{eq:interaction:tight-binding:momentum},\nthe integral over $\\vc{q}$ is unchanged,\n\\begin{equation}\n  V\n  = \\frac{1}{2} \\frac{Ω}{N}\n    ∑_{\\substack{ν, ν' \\\\ σ, σ'}}\n    ∑_{\\vK', \\bar{\\vK}}\n    ∑_{\\vK, \\bar{\\vK}'}\n    \\tilde{v}^{ν ν'}_{\\vK - \\bar{\\vK}}\n    δ \\left[ % chktex 19\n      \\left(\\bar{\\vK}' - \\vK' \\right) - \\left(\\vK - \\bar{\\vK} \\right)\n    \\right]\n    a_{\\bar{\\vK} ν σ}^† a_{\\bar{\\vK}' ν' σ'}^†\n    a_{\\vK' ν' σ'} a_{\\vK ν σ}.\n\\end{equation}\nWe now split up the integral over the global momentum coordinates\ninto integrals over relative coordinates centered about each valley;\nthis introduces an additional overall factor of $2^{-4}$\n(two valley centers per momentum integral with\nfour independent momentum-space coordinates).\nWe then restrict each integral to a suitable region about each valley\n(indicated by a prime on the summation).\nThe relative coordinates are thus introduced by the substitution\n$\\vK → \\vK + τ \\vc{K}$.\n\nGlobal conservation of momentum, represented by the $δ$-function, % chktex 19\nnow requires\n\\begin{equation}\n  \\vK - \\bar{\\vK} + \\left( τ - \\bar{τ} \\right) \\vc{K}\n  = \\bar{\\vK}' - \\vK' + \\left( \\bar{τ}' - τ' \\right) \\vc{K}.\n\\end{equation}\nSince $\\abs{\\vK} ≪ \\abs{\\vc{K}}$,\nthe above is actually the two independent conditions,\n\\begin{subequations}\n  \\begin{align}\n    \\vK - \\bar{\\vK}\n    & = \\bar{\\vK}' - \\vK', \\\\\n    τ - \\bar{τ}\n    & = \\bar{τ}' - τ'.\n  \\end{align}\n\\end{subequations}\nThere are three allowed cases for the sum over the valley indexes:\nintravalley scattering with $τ = \\bar{τ}$ and $τ' = \\bar{τ}'$;\nintervalley scattering with $τ = - τ'$ and $\\bar{τ} = - \\bar{τ}'$;\nand exchange with $τ = \\bar{τ}'$ and $\\bar{τ} = τ'$.\nWe indicate summation over the allowed cases\nby adding a prime to the sum.\nThus, we obtain\n\\begin{equation}\n  V\n  = \\frac{1}{2^5}\n    \\sideset{}{'} ∑_{\\vK, \\vK', \\vc{q}}\n    ∑_{\\substack{ν, ν' \\\\ σ, σ'}}\n    \\sideset{}{'} ∑_{\\substack{τ, \\bar{τ}, \\\\ τ', \\bar{τ}'}}\n    \\tilde{v}^{ν' ν}_{\\vc{q} + \\left( \\bar{τ} - τ \\right) \\vc{K}}\n    {a_{\\bar{τ} σ}^ν} ^† \\of{\\vK + \\vc{q}}\n    {a_{\\bar{τ}' σ'}^{ν'}}^† \\of{\\vK' - \\vc{q}}\n    a_{τ' σ'}^{ν'} \\ofKP\n    a_{τ σ}^ν \\ofK.\n\\end{equation}\n\nThe expected BCS instability is strongest for scattering\nwith $\\vK = - \\vK'$.\nRestricting the sum over $\\vK'$ to this condition,\nrelabeling the momentum indexes,\nand defining $v_{\\vc{q}}^{ν ν'} = 2^{-4} \\tilde{v}_{\\vc{q}}^{ν' ν}$ gives\n\\begin{equation}\n  V\n  = \\frac{1}{2}\n    \\sideset{}{'} ∑_{\\vK, \\vK'}\n    ∑_{\\substack{ν, ν' \\\\ σ, σ'}}\n    \\sideset{}{'} ∑_{\\substack{τ, \\bar{τ}, \\\\ τ', \\bar{τ}'}}\n    v^{ν ν'}_{\\vK' - \\vK + \\left( \\bar{τ} - τ \\right) \\vc{K}}\n    {a_{\\bar{τ} σ}^ν}^† \\ofKP\n    {a_{\\bar{τ}' σ'}^{ν'}}^† \\ofMKP\n    a_{τ' σ'}^{ν'} \\ofMK\n    a_{τ σ}^ν \\ofK.\n\\end{equation}\nExpanding the sum over the valley indexes gives\n\\begin{subequations}\n  \\begin{align}\n    V\n    & = \\frac{1}{2}\n      \\sideset{}{'} ∑_{\\vK, \\vK'}\n      ∑_{τ, τ',}\n      ∑_{ν, ν'}\n      ∑_{σ, σ'}\n      \\Big[\n      v^{ν ν'}_{\\vK' - \\vK}\n      {a_{τ σ}^ν}^† \\ofKP\n      {a_{τ' σ'}^{ν'}}^† \\ofMKP\n      a_{τ' σ'}^{ν'} \\ofMK\n      a_{τ σ}^ν \\ofK\n      \\\\\n    & +\n      v^{ν ν'}_{\\vK' - \\vK + \\left( τ' - τ \\right) \\vc{K}}\n      {a_{τ' σ}^ν}^† \\ofKP\n      {a_{-τ' σ'}^{ν'}}^† \\ofMKP\n      a_{-τ σ'}^{ν'} \\ofMK\n      a_{τ σ}^ν \\ofK\n      \\\\\n    & +\n      v^{ν ν'}_{\\vK' - \\vK + \\left( τ' - τ \\right) \\vc{K}}\n      {a_{τ' σ}^ν}^† \\ofKP\n      {a_{τ σ'}^{ν'}}^† \\ofMKP\n      a_{τ' σ'}^{ν'} \\ofMK\n      a_{τ σ}^ν \\ofK\n      \\Big].\n  \\end{align}\n\\end{subequations}\nProjecting to bands with $α = τ = σ$,\n\\begin{subequations}\n  \\begin{align}\n    V\n    & = \\frac{1}{2}\n      \\sideset{}{'} ∑_{\\vK, \\vK'}\n      ∑_{ν, ν'}\n      ∑_α\n      v^{ν ν'}_{\\vK' - \\vK}\n      \\Big[\n      {a^ν_α}^† \\ofKP\n      {a^{ν'}_α}^† \\ofMKP\n      a^{ν'}_α \\ofMK\n      a^ν_α \\ofK\n      \\\\\n    & +\n      {a^ν_α}^† \\ofKP\n      {a^{ν'}_{-α}}^† \\ofMKP\n      a^{ν'}_{-α} \\ofMK\n      a^ν_α \\ofK\n      \\\\\n    & +\n      ∑_{α'}\n      {a^ν_{α}}^† \\ofKP\n      {a^{ν'}_{α'}}^† \\ofMKP\n      a^{ν'}_{α'} \\ofMK\n      a^ν_α \\ofK\n      \\Big].\n  \\end{align}\n\\end{subequations}\nThis simplifies into explicit intervalley and intravalley terms,\n\\begin{multline}\n  \\label{eq:interaction:tight-binding:superconducting}\n  V\n  = \\sideset{}{'} ∑_{\\vK, \\vK'}\n    ∑_{ν, ν'}\n    ∑_α\n    v^{ν ν'}_{\\vK' - \\vK}\n    \\Big[\n    {a^ν_α}^† \\ofKP\n    {a^{ν'}_α}^† \\ofMKP\n    a^{ν'}_α \\ofMK\n    a^ν_α \\ofK\n    \\\\ +\n    {a^ν_α}^† \\ofKP\n    {a^{ν'}_{-α}}^† \\ofMKP\n    a^{ν'}_{-α} \\ofMK\n    a^ν_α \\ofK\n    \\Big].\n\\end{multline}\n\n\\section{Superconducting channels}\n\nAssuming the interaction is real-valued and orbital-independent,%\n\\footnote{%\n  As noted in \\cref{s:dichalcogenides:intrinsic},\n  this choice forbids the intravalley pairing.\n  However, for the complex-valued case, only the intravalley pairing\n  term survives.\n  For completeness, we still consider the intravalley terms in this appendix.\n}\n\\begin{equation}\n  v^{ν ν'}_{\\vK' - \\vK} = v \\of{\\vK' - \\vK} = v \\of{\\vK - \\vK'},\n\\end{equation}\n\\cref{eq:interaction:tight-binding:superconducting}\nprojected to the upper $n = -1$ bands with $τ = σ$ is\n\\begin{multline}\n  \\label{eq:intrinsic:projected}\n  P_{τ = σ}^{n = -} \\left( H^V \\right)\n  = \\sumKK v \\of{\\vK' - \\vK}\n    \\left(\n    2 \\abs{A_{\\vK \\vK'}}^2\n    c_{\\vK' ↑}^† c_{-\\vK' ↓}^† c_{-\\vK ↓} c_{\\vK ↑}\n    \\right. \\\\ \\left.\n  + A_{\\vK \\vK'}^2 c_{\\vK' ↑}^†\n    c_{-\\vK' ↑}^† c_{-\\vK ↑} c_{\\vK ↑}\n  + A_{\\vK' \\vK}^2 c_{\\vK' ↓}^†\n    c_{-\\vK' ↓}^† c_{-\\vK ↓} c_{\\vK ↓}\n    \\vphantom{%\n      2 \\abs{A_{\\vK \\vK'}}^2\n      c_{\\vK' ↑}^† c_{-\\vK' ↓}^† c_{-\\vK ↓} c_{\\vK ↑}}\n    \\right),\n\\end{multline}\nwhere\n\\begin{equation}\n  A_{\\vK \\vK'}\n  = e^{i \\left( ϕ_{\\vK'} - ϕ_{\\vK} \\right)}\n    \\sin{\\frac{θ_{\\vK'}}{2}} \\sin{\\frac{θ_{\\vK}}{2}}\n  + \\cos{\\frac{θ_{\\vK'}}{2}} \\cos{\\frac{θ_{\\vK}}{2}}.\n\\end{equation}\n\nFor the intravalley channels, the coefficient can be expanded as\n\\begin{equation}\n  A_{\\vK \\vK'}^2\n  = \\sum_{m = 0}^2 \\cc{f}_{\\vK}^m · g_{\\vK'}^m,\n\\end{equation}\nwith $f_{\\vK}^m = g_{\\vK'}^m$ and\n\\begin{subequations}\n  \\begin{align}\n    f_{\\vK}^0\n    & = \\cos^2{\\frac{θ_{\\vK}}{2}}\n      = \\frac{1}{2} P_0 \\of{\\cos{θ_{\\vK}}}\n      + \\frac{1}{2} P_1 \\of{\\cos{θ_{\\vK}}}, \\\\\n    e^{-i ϕ_{\\vK}} f_{\\vK}^1\n    & = \\sqrt{2} \\sin{\\frac{θ_{\\vK}}{2}} \\cos{\\frac{θ_{\\vK}}{2}}\n      = \\frac{1}{\\sqrt{2}} P_1 \\of{\\sin{θ_{\\vK}}}, \\\\\n    e^{-2 i ϕ_{\\vK}} f_{\\vK}^2\n    & = \\sin^2{\\frac{θ_{\\vK}}{2}}\n      = \\frac{1}{2} P_0 \\of{\\cos{θ_{\\vK}}}\n      - \\frac{1}{2} P_1 \\of{\\cos{θ_{\\vK}}}.\n  \\end{align}\n\\end{subequations}\nHere, $P_l$ are the Legendre polynomials:\n$P_0 \\of{x} = 1$ and $P_1 \\of{x} = x$.\n\nFor the intervalley channels, the coefficient can be expanded as\n\\begin{equation}\n  2 \\abs{A_{\\vK \\vK'}}^2\n  = \\sum_{l = 0}^1 \\cc{f}_{\\vK}^l · g_{\\vK'}^l\n  + \\cc{f}_{\\vK} · g_{\\vK'},\n\\end{equation}\nwith $f_{\\vK}^l = g_{\\vK'}^l$,\n$f_{\\vK} = g_{\\vK'}$, and\n\\begin{subequations}\n  \\begin{align}\n    f_{\\vK}^0\n    & = \\sqrt{2} P_0 \\of{\\cos{θ_{\\vK}}}, \\\\\n    f_{\\vK}^1\n    & = \\sqrt{2} P_1 \\of{\\cos{θ_{\\vK}}}, \\\\\n    f_{\\vK}\n    & = \\sqrt{2} P_1 \\of{\\sin{θ_{\\vK}}} \\vc{\\hat{k}}.\n  \\end{align}\n\\end{subequations}\n\n\\subsection{Mean field approximation}\n\nUsing the mean field approximation, we make replacements of the form\n$A B = A \\ev{B} + \\ev{A} B - \\ev{A} \\ev{B}$,\nwhere $A$ ($B$) is the product of two creation (annihilation) operators.\nThe expectation value is taken in the superconducting ground state.\nWe assume $v \\of{ \\vK - \\vK'} = - v_0$ is a constant attractive interaction,\npossibly with some effective interaction range\nwhich further restricts the summation.\n\\Cref{eq:intrinsic:projected} thus reduces to a sum of terms of the form\n\\begin{equation}\n  - \\sumK \\left(\n    \\cc{Δ}_{\\vK}^{γ γ'} c_{-\\vK γ'} c_{\\vK γ}\n    + \\frac{ε_{γ γ'}}{2}\n  \\right) + \\hc,\n\\end{equation}\nwhere $γ = γ' = ±1$ ($γ = - γ' = 1$) corresponds to the\nintravalley (intervalley) scattering channels,\n\\begin{equation}\n  Δ_{\\vK}^{γ γ'}\n  = - \\sideset{}{'}∑_{\\vK'}\n    \\cc{v}_{\\vK \\vK'}^{γ γ'} \\ev{c_{-\\vK' γ'} c_{\\vK' γ}},\n\\end{equation}\nand\n\\begin{equation}\n  ε_{γ γ'}\n  = - \\sumKK v_{\\vK \\vK'}^{γ γ'}\n    \\ev{c_{\\vK' γ}^† c_{-\\vK' γ'}^†} \\ev{c_{-\\vK γ'} c_{\\vK γ}}\n  = \\sumK Δ_{\\vK}^{γ γ'} \\ev{c_{\\vK γ}^† c_{-\\vK γ'}^†}.\n\\end{equation}\nProjected to a single superconducting channel, the Hamiltonian is\n\\begin{equation}\n  \\begin{aligned}\n    \\label{eq:intrinsic:projected:channel}\n    P_{γ γ'}^{-} \\left( H^0 + H^V - μ N \\right)\n      = ε_{γ γ'}\n    & + \\sumK \\left(\n        ξ_{\\vK} c_{\\vK γ}^† c_{\\vK γ}\n      + δ_{γ, -γ'} ξ_{\\vK} c_{\\vK γ'}^† c_{\\vK γ'} % chktex 19\n        \\right) \\\\\n    & - \\sumK \\left(\n        \\cc{Δ}_{\\vK}^{γ γ'} c_{-\\vK γ'} c_{\\vK γ}\n      + Δ_{\\vK}^{γ γ'} c_{\\vK γ}^† c_{-\\vK γ'}^†\n      \\right).\n  \\end{aligned}\n\\end{equation}\n\n\\subsection{Channel solutions}\n\nAn interaction for a given channel may be written as\n\\begin{equation}\n  v_{\\vK \\vK'} = \\cc{v}_{\\vK' \\vK} = - v_0 \\cc{f}_{\\vK} · g_{\\vK'},\n\\end{equation}\nwhere we suppress the channel and band indexes here and in the following\nwhen there is no ambiguity.\nThe channels are further split according to angular momentum,\nand the individual channels and their weights are summarized below.\nThe order parameter is\n\\begin{equation}\n  \\label{eq:intrinsic:gap}\n  χ_0 = v_0 \\sumK \\cc{g}_{\\vK} \\ev{c_{-\\vK γ'} c_{\\vK γ}},\n\\end{equation}\nthus $Δ_{\\vK} = f_{\\vK} · χ_0$.\nNote that we allow $f_{\\vK}$, $g_{\\vK}$, and $χ_0$\nto be either scalar or vector quantities.\n\nThe Hamiltonian in \\cref{eq:intrinsic:projected:channel}\nis again identical in structure to the BCS Hamiltonian,\nhowever the parameter $Δ_{\\vK}$ must be allowed complex\nas multiple channels may differ by relative phases\nwhich cannot be removed by a global unitary transformation.\nThe solutions for each channel all share an identical form;\nhowever, for the intravalley channels,\nthe expression for the eigenvalues $λ_{\\vK}$\nand other associated expressions\nis modified according to $ξ → ξ / 2$,\nsince the kinetic energy is split between each valley.\nTo keep track of the two cases, we will write $ξ'$,\nwhere $ξ' = ξ$ for intervalley channels and\n$ξ' = ξ / 2$ for intravalley channels.\n\nThe diagonalized form is\n\\begin{equation}\n  P \\left( H^0 + H^V - μ N \\right)\n  = \\sumK ∑_{α = γ, γ'} λ_{\\vK} b_{\\vK α}^† b_{\\vK α}\n  + \\sumK \\left( ξ_{\\vK}' - λ_{\\vK} \\right) + ε,\n\\end{equation}\nwith eigenvalues\n\\begin{equation}\n  λ_{\\vK} = \\sqrt{ξ_{\\vK}'^2 + \\abs{Δ_{\\vK}}^2}.\n\\end{equation}\nThe Bogoliubov transformation for complex $Δ_{\\vK}$ is\n\\begin{subequations}\n  \\begin{align}\n    c_{\\vK γ}\n    & = e^{-i δ_{\\vK}} \\cos{β_{\\vK}} b_{\\vK γ}       % chktex 19\n      + e^{i δ_{\\vK}'} \\sin{β_{\\vK}} b_{-\\vK γ'}^†, \\\\ % chktex 19\n    c_{-\\vK γ'}\n    & = e^{i δ_{\\vK}'} \\sin{β_{\\vK}} b_{\\vK γ}^† % chktex 19\n      - e^{-i δ_{\\vK}} \\cos{β_{\\vK}} b_{-\\vK γ'},  % chktex 19\n  \\end{align}\n\\end{subequations}\nwhere $δ_{\\vK}' - δ_{\\vK} = \\arg{Δ_{\\vK}}$ and % chktex 19\n\\begin{subequations}\n  \\begin{alignat}{3}\n    \\sin{2 β_{\\vK}} & = && {}-{} && \\abs{Δ_{\\vK}} / λ_{\\vK}, \\\\\n    \\cos{2 β_{\\vK}} & = && {} {} && ξ_{\\vK}' / λ_{\\vK}.\n  \\end{alignat}\n\\end{subequations}\nNote also the inverse,\n\\begin{subequations}\n  \\begin{align}\n    b_{\\vK γ}\n    & = e^{i δ_{\\vK}} \\cos{β_{\\vK}} c_{\\vK γ}       % chktex 19\n      + e^{i δ_{\\vK}'} \\sin{β_{\\vK}} c_{-\\vK γ'}^†, \\\\ % chktex 19\n    b_{-\\vK γ'}\n    & = e^{i δ_{\\vK}'} \\sin{β_{\\vK}} c_{\\vK γ}^† % chktex 19\n      - e^{i δ_{\\vK}} \\cos{β_{\\vK}} c_{-\\vK γ'}.  % chktex 19\n  \\end{align}\n\\end{subequations}\nWith this, \\Cref{eq:intrinsic:gap} becomes\n\\begin{equation}\n  \\label{eq:intrinsic:gap:general}\n  \\begin{aligned}\n    χ_0\n    & = v_0 \\sumK \\cc{g}_{\\vK}\n        \\left( - \\frac{1}{2} e^{i \\arg{Δ_{\\vK}}} \\sin{2 β_{\\vK}} \\right), \\\\\n    & = \\frac{v_0}{2} \\sumK \\cc{g}_{\\vK}\n        \\frac{\\abs{Δ_{\\vK}} e^{i \\arg{Δ_{\\vK}}}}{λ_{\\vK}}, \\\\\n    & = \\frac{v_0}{2} \\sumK \\cc{g}_{\\vK}\n        \\frac{Δ_{\\vK}}{λ_{\\vK}}, \\\\\n    & = \\frac{v_0}{2} \\sumK \\cc{g}_{\\vK}\n        \\frac{f_{\\vK} · χ_0}{λ_{\\vK}}.\n  \\end{aligned}\n\\end{equation}\n\n\\subsection{Gap equation}\n\nWe now derive the gap equation for each symmetry channel.\nThese are reduced to an integral which may be solved numerically.\n\n\\subsection{Scalar channels}\n\nFor scalar channels, $f_{\\vK} = g_{\\vK}$.\nWe replace the sum by an integral,\nand since $\\abs{f_{\\vK}}^2$ and $λ_{\\vK}$ depend only on $\\abs{\\vK}$,\nthe integral over $ϕ$ is trivial and yields a factor of $2 π$.\n\\Cref{eq:intrinsic:gap:general} becomes\n\\begin{equation}\n  1\n  = π v_0 ∫_{-ω}^{ω}\n  \\frac{\\abs{f \\of{ξ}}^2 \\abs{ρ \\of{ξ}} \\dif ξ}\n  {\\sqrt{ξ'^2 + \\abs{f \\of{ξ}}^2 \\abs{χ_0}^2}},\n\\end{equation}\nwhere $ω < λ$ is the energy cutoff around the chemical potential\nand the density of states is\n\\begin{equation}\n  ρ \\of{ξ}\n  = k \\pderiv{k}{ξ}\n  = \\frac{2 \\left( ξ + μ \\right) - λ}{{\\left( a t \\right)}^2}.\n\\end{equation}\n\n\\subsection{Vector channels}\n\nFor the intervalley vector channels,\n\\begin{subequations}\n\\begin{align}\n  f_{\\vK}\n  & = g_{\\vK} = \\sqrt{2} \\sin{θ_{\\vK} \\vc{\\hat{k}}}, \\\\\n  χ_0\n  & = \\left( \\abs{χ_0} / \\sqrt{2} \\right) \\left( \\hat{e}_1\n    + i \\hat{e}_2 \\right),\n\\end{align}\n\\end{subequations}\nfor some fixed unit vectors $\\hat{e}_1$ and $\\hat{e}_2$.\nWe consider two cases:\n$\\hat{e}_1 ∥ \\hat{e}_2$ or $\\hat{e}_1 ⊥ \\hat{e}_2$.\n\nWhen $\\hat{e}_1 ∥ \\hat{e}_2$,\nwrite $χ_0 = \\abs{χ_0} \\hat{e} e^{i ϕ_0}$\nand $\\vc{\\hat{k}} · \\hat{e} = \\cos{\\left( ϕ_{\\vK} - ϕ_e \\right)}$,\nso \\cref{eq:intrinsic:gap:general} reads\n\\begin{equation}\n  \\begin{aligned}\n    \\hat{e}\n    & = \\frac{v_0}{2} \\sumK \\frac{\\abs{f_{\\vK}}^2}{λ_{\\vK}}\n        \\left( \\hat{e} · \\vc{\\hat{k}} \\right) \\vc{\\hat{k}}.\n  \\end{aligned}\n\\end{equation}\nDotting both sides with $\\hat{e}$ and converting to integral form,\n\\begin{equation}\n  1\n  = \\frac{v_0}{2} ∫_{-ω}^{ω} ∫_{0}^{2 π}\n  \\frac{\\abs{f \\of{ξ}}^2 \\cos^2{ϕ} \\abs{ρ \\of{ξ}} \\dif ϕ \\dif ξ}\n  {\\sqrt{ξ^2 + \\abs{f \\of{ξ}}^2 \\abs{χ_0}^2 \\cos^2{ϕ}}},\n\\end{equation}\nwhere as expected by symmetry,\nthe integral has been made independent of the direction of $\\hat{e}$\nthrough the substitution $ϕ → ϕ + ϕ_e$.\nThe integral over $ϕ$ can be\nwritten in terms of elliptical functions using the identity\n\\begin{multline}\n  \\frac{a^2}{2} ∫_{0}^{2 π}\n  \\frac{\\cos^2{ϕ} \\dif ϕ}{\\sqrt{1 + a^2 \\cos^2{ϕ}}}\n  = E \\of{-a^2} - K \\of{-a^2} \\\\\n  + \\sqrt{1 + a^2} E \\of{\\frac{a^2}{1 + a^2}}\n  - \\frac{1}{\\sqrt{1 + a^2}} K \\of{\\frac{a^2}{1 + a^2}}.\n\\end{multline}\n\nWhen $\\hat{e}_1 ⊥ \\hat{e}_2$, then we may write\n$\\hat{e}_1 · \\vc{\\hat{k}} = \\cos{\\left( ϕ_{\\vK} - ϕ_1 \\right)}$\nand $\\hat{e}_2 · \\vc{\\hat{k}} = \\sin{\\left( ϕ_{\\vK} - ϕ_1 \\right)}$,\nthus\n\\begin{equation}\n  \\hat{e}_1 + i \\hat{e}_2\n  = \\frac{v_0}{2} \\sumK \\frac{\\abs{f_{\\vK}}^2}{λ_{\\vK}}\n    \\left[ \\left( \\hat{e}_1 + i \\hat{e}_2 \\right) · \\vc{\\hat{k}}\n    \\right] \\vc{\\hat{k}},\n\\end{equation}\nand dotting both sides by $\\hat{e}_1 - i \\hat{e}_2$ gives\n\\begin{equation}\n  2\n  = \\frac{v_0}{2} \\sumK \\frac{\\abs{f_{\\vK}}^2}\n    {\\sqrt{ξ_{\\vK}^2 + \\left( 1 / 2 \\right) \\abs{f_{\\vK}}^2 \\abs{χ_0}^2}}.\n\\end{equation}\nConverting to integral form,\n\\begin{equation}\n  1\n  = \\frac{π v_0}{2} ∫_{-ω}^{ω}\n  \\frac{\\abs{f \\of{ξ}}^2 \\abs{ρ \\of{ξ}} \\dif ξ}\n  {\\sqrt{ξ^2 + \\left( 1 / 2 \\right) \\abs{f \\of{ξ}}^2 \\abs{χ_0}^2}}.\n\\end{equation}\n\n\\section{Spin expectation values}\n\nThe full ground state in the superconducting system is\n\\begin{equation}\n  ∏_{\\vK} c_{\\vK \\bar{↑}}^† c_{\\vK \\bar{↓}}^† \\Ket{Ω},\n\\end{equation}\nwhere the bar notation denotes states in the lower valance band, i.e.,\nif $α = (τ, σ)$ then $\\bar{α} = (-τ, σ)$.\nThe total spin operator is\n\\begin{equation}\n  \\vc{S}\n  = \\sumK \\vc{s} \\ofK\n  = \\frac{1}{2} \\sumK\n    \\left[ \\vc{s} \\ofK + \\vc{s} \\ofMK \\right],\n\\end{equation}\nwhere\n\\begin{equation}\n  \\vc{s} \\ofK\n  = \\frac{1}{2}\n    ∑_{\\substack{n, τ \\\\ σ, σ'}}\n    \\vc{σ}_{σ σ'} {c_{τ σ}^n}^† \\ofK c_{τ σ'}^n \\ofK\n\\end{equation}\nis the spin operator for a given $\\vK$,\nwith $\\vc{σ}_{σ σ'} = \\left( σ^x_{σ σ'}, σ^y_{σ σ'}, σ^z_{σ σ'} \\right)$.\n\nWe wish to compute $\\ev{\\vc{S}}$ and $\\ev{\\vc{S}^2}$\nin the intervalley pairing state.\nThe former follows from the value of $\\ev{\\vc{s} \\ofK}$,\nand the latter from the spin of Cooper pairs,\n$\\ev{{\\left[ \\vc{s} \\ofK + \\vc{s} \\ofMK \\right]}^2}$.\nTo see this, note that only cross terms with the same or opposite $\\vK$\ncontribute, so that\n\\begin{equation}\n  \\ev{\\vc{S}^2}\n  = \\frac{1}{2} \\sumK\n    \\ev{{\\left[ \\vc{s} \\ofK + \\vc{s} \\ofMK \\right]}^2}.\n\\end{equation}\nThus, we must compute\n$\\ev{\\vc{s} \\ofK}$,\n$\\ev{{\\left[ \\vc{s} \\ofK \\right]}^2}$,\nand $\\ev{\\vc{s} \\ofK \\cdot \\vc{s} \\ofMK}$.\nIn the remainder of this section,\nequality for the operator $\\vc{s} \\ofK$ will denote\nequality of operators which have equivalent values\non all three of these expectation values.\n\nOnly terms with $n = -1$ will contribute\nto the expectation value, thus we write\n\\begin{equation}\n  \\vc{s} \\ofK\n  = \\frac{1}{2} ∑_α\n    \\vc{σ}_{α α} c_{\\vK α}^† c_{\\vK α}\n  + \\vc{σ}_{α α} c_{\\vK \\bar{α}}^† c_{\\vK \\bar{α}}\n  + \\vc{σ}_{α, -α} c_{\\vK α}^† c_{\\vK, - \\bar{α}}\n  + \\vc{σ}_{α, -α} c_{\\vK \\bar{α}}^† c_{\\vK, -α},\n\\end{equation}\nand obtain\n\\begin{equation}\n  \\ev{\\vc{s} \\ofK}\n    = \\frac{1}{2} \\left( 1 + \\sin^2 {β_{\\vK}} \\right) \\Tr{\\vc{σ}}\n    = \\vc{0}.\n\\end{equation}\nNext, we compute\n\\begin{equation}\n  \\begin{aligned}\n    \\ev{\\vc{s} \\ofK · \\vc{s} \\ofKP}\n    & = \\frac{1}{4} ∑_{α α'}\n        \\vc{σ}_{α α} · \\vc{σ}_{α' α'}\n        \\left( 1 + \\sin^2 {β_{\\vK}} + \\sin^2 {β_{\\vK'}} \\right) \\\\\n    & + \\frac{1}{4} ∑_{α α'}\n        \\vc{σ}_{α α} · \\vc{σ}_{α' α'}\n        \\ev{c_{\\vK α}^† c_{\\vK α} c_{\\vK' α'}^† c_{\\vK' α'}} \\\\\n    & + \\frac{1}{4} ∑_{α α'}\n        \\vc{σ}_{α, -α} · \\vc{σ}_{α', -α'}\n        \\ev{c_{\\vK \\bar{α}}^† c_{\\vK, -α} c_{\\vK' α'}^† c_{\\vK', -\\bar{α}'}}.\n  \\end{aligned}\n\\end{equation}\nThe above expectation values are readily simplified using Wick's theorem,\n\\begin{equation}\n\\begin{aligned}\n    \\ev{\\vc{s} \\ofK · \\vc{s} \\ofKP}\n    & = \\frac{1}{4} ∑_{α α'}\n        \\vc{σ}_{α α} · \\vc{σ}_{α' α'}\n        \\frac{1}{4} \\sin^2 {2 β_{\\vK}}\n        \\left( δ_{\\vK, \\vK'} δ_{α, α'} + δ_{\\vK, -\\vK'} δ_{α, -α'} \\right) \\\\\n    & + \\frac{1}{4} ∑_α\n        \\vc{σ}_{α, -α} · \\vc{σ}_{-α, α}\n        δ_{\\vK, \\vK'}\n        \\cos^2 {β_{\\vK}}.\n\\end{aligned}\n\\end{equation}\nEvaluating the sum gives,\n\\begin{equation}\n  \\ev{\\vc{s} \\ofK · \\vc{s} \\ofKP}\n  = \\frac{1}{8} \\sin^2 {2 β_{\\vK}}\n    \\left( δ_{\\vK, \\vK'} - δ_{\\vK, -\\vK'} \\right)\n  + δ_{\\vK, \\vK'}\n    \\cos^2 {β_{\\vK}},\n\\end{equation}\nwhich shows\n\\begin{subequations}\n  \\begin{align}\n    \\ev{{\\left[ \\vc{s} \\ofK + \\vc{s} \\ofMK \\right]}^2}\n    & = 2 \\ev{\\vc{s} \\ofK · \\vc{s} \\ofMK}\n      + 2 \\ev{{\\vc{s} \\ofK}^2}, \\\\\n    & = 2 \\cos^2 {β_{\\vK}}\n      - \\frac{δ_{\\vK, \\vc{0}}}{4} \\sin^2 {2 β_{\\vK}}.\n  \\end{align}\n\\end{subequations}\nFar from the chemical potential (where $\\vK = 0$),\n$\\sin^2 {2 β_{\\vK}}$ approaches zero while $\\cos^2 {β_{\\vK}}$\napproaches unity.\nThus, we neglect the second term above and obtain\n\\begin{equation}\n  \\ev{\\vc{S}^2} = \\sumK \\cos^2 {β_{\\vK}}.\n\\end{equation}\n\n\\section{Berry curvature}\n\\label{s:appendix:intrinsic:berry_curvature}\n\n\\subsection{Normal states}\n\nIn the non-interacting system, the band resolved Berry curvature is\n\\begin{equation}\n  \\vc{Ω}_{τ σ}^n \\ofK\n  = i ∇_{\\vK} ⨯\n    \\Braket{u_{τ σ}^n \\ofK | ∇_{\\vK} | u_{τ σ}^n \\ofK}.\n\\end{equation}\nThis can be computed directly by first considering\n\\begin{equation}\n  \\begin{aligned}\n    \\Braket{u_{τ σ}^n \\ofK | ∇_{\\vK} | u_{τ σ}^n \\ofK}\n    & = ∑_ν\n        \\cc{M}_{τ σ}^{ν n} \\ofK\n        ∇_{\\vK} M_{τ σ}^{ν n} \\ofK \\\\\n    & + ∑_{ν, ν'}\n        \\cc{M}_{τ σ}^{ν n} \\ofK\n        M_{τ σ}^{ν' n} \\ofK\n        \\Braket{v_{τ σ}^ν \\ofK | ∇_{\\vK} | v_{τ σ}^{ν'} \\ofK}.\n  \\end{aligned}\n\\end{equation}\nThe second term is effectively zero by an argument\nsimilar to the one given below in\n\\cref{s:appendix:optical:d-orbital}.\nUsing the identities\n\\begin{subequations}\n  \\begin{align}\n    \\pderiv{}{k} M_{τ σ}^{ν n} \\ofK\n    & = n τ \\pderiv{}{k} \\fnThetaApx{n}, \\\\\n    \\pderiv{}{ϕ} M_{τ σ}^{ν n} \\ofK\n    & = i τ M_{τ σ}^{ν n} \\ofK δ_{ν, -1},\n  \\end{align}\n\\end{subequations}\ngives the $z$-component of the curvature,\n\\begin{subequations}\n  \\begin{align}\n    Ω_{τ σ}^n \\of{k}\n    & = \\vc{\\hat{z}} · \\vc{Ω}_{τ σ}^n \\ofK \\\\\n    & = - n τ\n      \\left[ \\frac{1}{2 k} \\pderiv{}{k} \\fnThetaApx{n} \\right]\n      \\sin{\\fnThetaApx{n}}, \\\\\n    & = - n τ\n      \\frac{2 {(a t)}^2 (Δ - λ τ σ)}\n      {{\\left[{(2 a t k)}^2 + {(Δ - λ τ σ)}^2 \\right]}^{3/2}}.\n  \\end{align}\n\\end{subequations}\nThe Berry curvature of left and right circularly polarized\n($\\vc{ϵ_±}$) optical excitations for a given $\\vK$\nthen follows to be $± 2 Ω_{+ ↑}^+ \\of{k}$.\n\n\\subsection{BCS States}\n\nWe again consider the intervalley pairing state.\nThe BCS ground state is%\n\\footnote{%\n  Note that the full ground state\n  also contains the lower two filled bands,\n  but those contribute zero net Berry curvature and may be ignored.\n}\n\\begin{subequations}\n  \\begin{align}\n    \\Ket{Ω}\n    & = ∏_{\\vK} \\csc{β_{\\vK}} b_{\\vK ↑} b_{-\\vK ↓} \\Ket{0}, \\\\\n    & = ∏_{\\vK} \\left( \\cos{β_{\\vK}} - \\sin{β_{\\vK}}\n        c_{\\vK ↑}^† c_{-\\vK ↓}^† \\right) \\Ket{0}.\n  \\end{align}\n\\end{subequations}\nThis may be viewed as built up\nfrom the single-quasiparticle eigenstates,\n\\begin{equation}\n  \\Ket{\\vK}\n  = \\csc{β_{\\vK}} b_{\\vK ↑} b_{-\\vK ↓} \\Ket{0},\n\\end{equation}\nof the $\\vK$ dependent Hamiltonian\n$λ_{\\vK} b_{\\vK ↑}^† b_{\\vK ↑}\n- λ_{\\vK} b_{-\\vK ↓} b_{-\\vK ↓}^†$.\nThus, consider the $z$-component of the Berry curvature of this state,\n\\begin{subequations}\n  \\begin{align}\n    \\label{eq:berry_curvature.1}\n    Ω_{\\vK}\n    & = \\vc{\\hat{z}} · i ∇_{\\vK} ⨯\n    \\Braket{\\vK | ∇_{\\vK} | \\vK}, \\\\\n    \\label{eq:berry_curvature.2}\n    & = \\vc{\\hat{z}} · i ∇_{\\vK} ⨯\n    \\Braket{0 | c_{-\\vK ↓} c_{\\vK ↑}\n      ∇_{\\vK} \\left( c_{\\vK ↑}^† c_{-\\vK ↓}^† \\right) |0}, \\\\\n    \\label{eq:berry_curvature.3}\n    & = Ω_{+ ↑}^- \\of{k} + Ω_{- ↓}^- \\of{-k} = 0.\n  \\end{align}\n\\end{subequations}\nTo see why \\cref{eq:berry_curvature.2} follows from \\cref{eq:berry_curvature.1},\nwrite $\\Ket{\\vK} = \\cos{β_{\\vK}} - \\sin{β_{\\vK}} c_{\\vK ↑}^† c_{-\\vK ↓}^†$\nand consider each of the resulting four cross terms:\none contains no operators, will be proportional to $\\vK$,\nindependent of $ϕ_{\\vK}$, and thus have vanishing curl;\nthe two terms with a pair of either creation or annihilation operators\nhave zero expectation value; this leaves only the term given in\n\\cref{eq:berry_curvature.2}.\n\\Cref{eq:berry_curvature.3} now follows since $\\Ket{0}$ is independent of $\\vK$\nand the Berry curvature is additive over non-interacting states.\n\n\\subsubsection{Optical excitations}\n\nA single optically excited state in the left valley\nfor a given $\\vK$ is\n\\begin{subequations}\n  \\begin{align}\n    & {c_{+ ↑}^+}^† \\ofK c_{\\vK ↑} \\Ket{\\vK}, \\\\\n    & = {c_{+ ↑}^+}^† \\ofK\n      \\left( \\cos{β_{\\vK}} b_{\\vK ↑} + \\sin{β_{\\vK}} b_{-\\vK ↓}^† \\right)\n      \\Ket{\\vK}, \\\\\n    & = \\sin{β_{\\vK}} {c_{+ ↑}^+}^† \\ofK b_{-\\vK ↓}^† \\Ket{\\vK}, \\\\\n    & = {c_{+ ↑}^+}^† \\ofK b_{-\\vK ↓}^† b_{\\vK ↑} b_{-\\vK ↓} \\Ket{0}, \\\\\n    & = - \\sin^2 {β_{\\vK}} {c_{+ ↑}^+}^† \\ofK b_{\\vK ↑} \\Ket{0}, \\\\\n    & = - \\sin^3 {β_{\\vK}} {c_{+ ↑}^+}^† \\ofK {c_{- ↓}^-}^† \\ofMK \\Ket{0},\n  \\end{align}\n\\end{subequations}\nwhich has corresponding Berry Curvature\n\\begin{subequations}\n  \\begin{align}\n    Ω_{\\vK}^L\n    & = \\sin^6 {β_{\\vK}}\n        \\left[ Ω_{+ ↑}^+ \\of{k} + Ω_{- ↓}^- \\of{-k} \\right], \\\\\n    & = 2 \\sin^6 {β_{\\vK}} Ω_{+ ↑}^+ \\of{k}.\n  \\end{align}\n\\end{subequations}\nA single optically excited state in the right valley\nfor a given $\\vK$ is\n\\begin{subequations}\n  \\begin{align}\n    & {c_{- ↓}^+}^† \\ofMK c_{-\\vK ↓} \\Ket{\\vK}, \\\\\n    & = {c_{- ↓}^+}^† \\ofK\n      \\left( - \\cos{β_{\\vK}} b_{-\\vK ↓} + \\sin{β_{\\vK}} b_{\\vK ↑}^† \\right)\n      \\Ket{\\vK}, \\\\\n    & = \\sin{β_{\\vK}} {c_{- ↓}^+}^† \\ofK b_{\\vK ↑}^† \\Ket{\\vK}, \\\\\n    & = {c_{- ↓}^+}^† \\ofK b_{\\vK ↑}^† b_{\\vK ↑} b_{-\\vK ↓} \\Ket{0}, \\\\\n    & = \\sin^2 {β_{\\vK}} {c_{- ↓}^+}^† \\ofK b_{-\\vK ↓}\\Ket{0}, \\\\\n    & = \\sin^3 {β_{\\vK}} {c_{- ↓}^+}^† \\ofK {c_{+ ↑}^-}^† \\ofK \\Ket{0},\n  \\end{align}\n\\end{subequations}\nwhich has corresponding Berry Curvature\n\\begin{subequations}\n  \\begin{align}\n    Ω_{\\vK}^R\n    & = \\sin^6 {β_{\\vK}}\n        \\left[ Ω_{- ↓}^+ \\of{k} + Ω_{+ ↑}^- \\of{k} \\right], \\\\\n    & = - 2 \\sin^6 {β_{\\vK}} Ω_{+ ↑}^+ \\of{k}, \\\\\n    & = - Ω_{\\vK}^L.\n  \\end{align}\n\\end{subequations}\n", "meta": {"hexsha": "8d64279de7790ed62a8584218c7e43ae1650d1b7", "size": 24501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/_appendix-intrinsic.tex", "max_stars_repo_name": "razor-x/doctoral-thesis", "max_stars_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-25T23:01:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-25T23:01:11.000Z", "max_issues_repo_path": "tex/_appendix-intrinsic.tex", "max_issues_repo_name": "evansosenko/doctoral-thesis", "max_issues_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/_appendix-intrinsic.tex", "max_forks_repo_name": "evansosenko/doctoral-thesis", "max_forks_repo_head_hexsha": "b48dd021d3b796537f2582967a790ca323b9f86d", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1957950066, "max_line_length": 80, "alphanum_fraction": 0.5588343333, "num_tokens": 10841, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.42352680899577644}}
{"text": "\\problemname{A Different Problem}\n\nWrite a program that computes the difference between non-negative integers.\n\n\\section*{Input}\n\nThe input consists of multiple test cases (at least $1$ and at most\n$40$), one per line.  Each test case consists of a pair of integers,\nbetween $0$ and $10^{15}$ (inclusive).  The input is terminated by\nend of file.\n\n\\section*{Output}\n\nFor each pair of integers in the input, output one line, containing the absolute value of their difference.\n", "meta": {"hexsha": "60b2dffa5d8073fb1152ecac73fc204c5ada3a64", "size": 475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples/different/problem_statement/problem.en.tex", "max_stars_repo_name": "Tyilo/problemtools", "max_stars_repo_head_hexsha": "307bcbf2c90e75db6513ee6e4daa41590d988906", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 84, "max_stars_repo_stars_event_min_datetime": "2015-03-25T19:13:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T18:19:01.000Z", "max_issues_repo_path": "examples/different/problem_statement/problem.en.tex", "max_issues_repo_name": "godmar/problemtools", "max_issues_repo_head_hexsha": "4e2b2d7797d8f15e5536a9d2b35d251476bef79c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 151, "max_issues_repo_issues_event_min_datetime": "2015-03-29T18:28:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-10T21:35:04.000Z", "max_forks_repo_path": "examples/different/problem_statement/problem.en.tex", "max_forks_repo_name": "godmar/problemtools", "max_forks_repo_head_hexsha": "4e2b2d7797d8f15e5536a9d2b35d251476bef79c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 60, "max_forks_repo_forks_event_min_datetime": "2015-01-20T21:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T10:00:07.000Z", "avg_line_length": 31.6666666667, "max_line_length": 107, "alphanum_fraction": 0.7578947368, "num_tokens": 113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.42346883612325054}}
{"text": "\\documentclass{beamer}\n\\newtheorem{prop}{Proposition}\n\\newtheorem{assumption}{Assumption}\n\\newtheorem{thm}{Thereom}\n\\newtheorem{corr}{Corollary}\n\n\\title[Lanczos and CG]{Lanczos Algorithm and Conjugate Gradient}\n\\author[Hongda Li, UW]{Hongda Li}\n\\vspace{-1cm}\n\\institute[]\n{\n    {\n        \\small Applied Mathematics, University of Washington\n    }\\\\\n        \\vspace{1cm}\n    {\n        \\small {\\color{blue}Presented for Something}\n    }\\\\\n        \\vspace{1cm}\n        Still a Draft\n}\n\n\n\\date[May ??th 2022]\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>{Outline}\n    \\tableofcontents[currentsection,currentsubsection]\n  \\end{frame}\n}\n\n\\usepackage{biblatex}\n\\addbibresource{refs.bib}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n    \\begin{frame}{Introduction Frame 1}\n        \\par\n        The subjects of discussion are: \n        \\begin{itemize}\n            \\item The Lanczos Algorithm which is used for Tridiagonalizing Sparse Symmetric Matrix $A$, producing the factorizations $Q_k^TAQ_k = T_k$. \n            \\item The Conjugate Gradient which is used for solve Positive Definite linear system: $Ax = b$. \n            \\item The connections between them and their behaviors under floating point arithematic. \n        \\end{itemize}\n    \\end{frame}\n\n\n    \\begin{frame}{Basics:Krylov Subspace}\n        \\begin{definition}[Krylov Subspace]\n            $$\n            \\mathcal{K}_k(A|b) = \\text{span}( b, Ab, A^2b, \\cdots A^{k - 1}b)\n            $$\n            \\begin{itemize}\n                \\item [1.)] All vectors in the span can be represented in the form of the product matrix polynomial with degree $k - 1$ with vector $b$. \n                \\item [2.)] Once the vectors: $b, Ab, A^2b, \\cdots A^{k - 1}b$ becomes linearly dependent, the subspace becomes invariant under $A$. \n            \\end{itemize}\n        \\end{definition}\n        \\begin{definition}[The Grade of Krylov Subspace]\n            If the vectors in $\\mathcal K_{k}(A|b)$ are linearly dependent and $k$ is the smallest, then the grade of this Krylov Subspace is $k - 1$, denoted as $\\text{grade}(A|b)$. \n            \\\\\n            Definition taken from Y. Saad's Textbook: Iterative Methods for Sparse Linear System \\cite{book:saad_sparse_linear}\n        \\end{definition}\n    \\end{frame}\n    \n    \\begin{frame}{Basics: Projector}\n        \\begin{definition}[Projectors]\n            A matrix $P$ is a projector when $P^2 = P$, we call this property idempotent.    \n        \\end{definition}\n        \\begin{itemize}\n            \\item [1.)] When $P$ is Hermitian, it's an orthogonal projector. \n            \\item [2.)] When $P$ is not Hermitian, it's an Oblique projectors\n            \\item [3.)] The projector $I - P$ projects onto the null space of $P$ and vice versa. \n        \\end{itemize}\n        \n    \\end{frame}\n    \n    \\begin{frame}{Basic: Subspace Projection Framework}\n        \\begin{definition}\n            We will choose approximate solutions to our linear system $Ax=b$ from $\\mathcal{K}$, and we will orthogonalize the residual $b-A \\tilde{x}$ against $\\mathcal{L}$.\n            \\begin{align}\n                \\text{choose }\\tilde{x} \\in x_0 + \\mathcal{K} \\text{ s.t: } b - A\\tilde{x} \\perp \\mathcal{L}.\n            \\end{align}\n            \\begin{itemize}\n                \\item  Characterizes subspace projection methods, such as GMRes, FOM, Bi-CG and CG\n            \\end{itemize}\n        \\end{definition}\n    \\end{frame}\n    \n    \\begin{frame}{Basic: Subspace Projection Framework in Matrix Form}\n        \\begin{definition}[SPM: Matrix Form]\n            Let the columns of $V \\in \\mathbb{R}^{n \\times m}$ be a basis for $\\mathcal{K}$ and let the columns of $W \\in \\mathbb{R}^{n \\times m}$ be a basis for $\\mathcal{L}$. \n            \\begin{align}\n                \\tilde{x} &= x_0 + Vy\n                    \\\\\n                    \\text{choose } x \\text{ s.t: } b - A\\tilde{x}  &\\perp \\text{ran}(W)\n                    \\\\\n                    \\implies W^T(b - Ax_0 - AVy) &= \\mathbf{0}\n                    \\\\\n                    W^Tr_0 - W^TAVy&= \\mathbf{0}\n                    \\\\\n                    W^TAVy &= W^Tr_0\n            \\end{align}\n        \\end{definition}\n        \n    \\end{frame}\n    \n    \\begin{frame}{Basic: Subspace Projection Framework in Matrix Form}\n        \\begin{definition}[SPM: Matrix Form]\n            Let the columns of $V \\in \\mathbb{R}^{n \\times m}$ be a basis for $\\mathcal{K}$ and let the columns of $W \\in \\mathbb{R}^{n \\times m}$ be a basis for $\\mathcal{L}$. \n            \\begin{align}\n                \\tilde{x} &= x_0 + Vy\n                    \\\\\n                    \\text{choose } x \\text{ s.t: } b - A\\tilde{x}  &\\perp \\text{ran}(W)\n                    \\\\\n                    \\implies W^T(b - Ax_0 - AVy) &= \\mathbf{0}\n                    \\\\\n                    W^Tr_0 - W^TAVy&= \\mathbf{0}\n                    \\\\\n                    W^TAVy &= W^Tr_0\n            \\end{align}\n        \\end{definition}\n        Observe: \n        \\begin{align}\n            & \\tilde{r} = b - A \\tilde{x} = b - A x_0 - AVy = r_0 - AV ( W^T A V )^{-1} W^T r_0\n            \\\\\n            & [ A V ( W^T A V )^{-1} W^T ] [ A V ( W^T A V )^{-1} W^T ] = A V ( W^T A V )^{-1} W^T \n        \\end{align}\n    \\end{frame}\n    \n    \\begin{frame}{Basic: Energy Norm Minimizations}\n        Alternatively, for some symmetric positive definite matrix $B$, one might choose $\\tilde{x} = x_0 + Vy$ to minimize \n            the $B$-norm of the residual $\\| r_0 - A V y \\|_B = \\langle r_0 - A V y , B ( r_0 - A V y ) \\rangle^{1/2}$.  Setting the gradient of this function to zero leads to the normal equations:\n            \\begin{align}\n                V^T A^T BAVy = V^T A^T B r_0\n            \\end{align}\n            If $A$ itself is symmetric and positive definite, then we can take $B = A^{-1}$ and minimize the $A^{-1}$-norm of the \n            residual or, equivalently, the $A$-norm of the error $\\langle A^{-1} b - \\tilde{x} , A ( A^{-1} b - \\tilde{x} ) \\rangle$.\n            The formula for $y$ then becomes\n            \\begin{align}\\label{eqn:Energy_Norm_Minimization_Conditions}\n                V^T A V y = V^T r_0\n            \\end{align}\n    \\end{frame}\n    \n    \\begin{frame}{Basic: Energy Norm Minimizations}\n            Alternatively, for some symmetric positive definite matrix $B$, one might choose $\\tilde{x} = x_0 + Vy$ to minimize \n            the $B$-norm of the residual $\\| r_0 - A V y \\|_B = \\langle r_0 - A V y , B ( r_0 - A V y ) \\rangle^{1/2}$.  Setting the gradient of this function to zero leads to the normal equations:\n            \\begin{align}\n                V^T A^T BAVy = V^T A^T B r_0\n            \\end{align}\n            If $A$ itself is symmetric and positive definite, then we can take $B = A^{-1}$ and minimize the $A^{-1}$-norm of the \n            residual or, equivalently, the $A$-norm of the error $\\langle A^{-1} b - \\tilde{x} , A ( A^{-1} b - \\tilde{x} ) \\rangle$.\n            The formula for $y$ then becomes\n            \\begin{align}\\label{eqn:Energy_Norm_Minimization_Conditions}\n                V^T A V y = V^T r_0\n            \\end{align}\n            \\begin{align}\n                & \\tilde{r} = r_0 - A V ( V^T A V )^{-1} V^T r_0\n                \\\\\n                & [A V (V^T A V )^{-1} V^T ] [ A V ( V^T A V )^{-1} V^T ] = A V ( V^T A V )^{-1} V^T\n            \\end{align}\n    \\end{frame}\n\n\\section{Driving CG Via CDM}\n\n    \\begin{frame}{CG, Lanczos}\n        \\begin{itemize}\n            \\item The conjugate direction method can produced applying the subspace projection framework.\n            \\item The CG method is a special case of the conjugate direction method. \n        \\end{itemize}\n        Through out the rest of the presentation, we assume: \n        \\begin{itemize}\n            \\item [1)] The matrix $A$ is symmetric positive definite.  \n            \\item [2)] There is a matrix $P_k = [p_0 \\;p_1\\;\\cdots p_{k-1}]$ whose columns form a basis for the space over which we are minimizing.\n        \\end{itemize}\n    \\end{frame}\n    \n    \\begin{frame}{Conjugate Direction Method}\n        To solve for $w$, we wish to make $P_k^TAP_k$ to be an easy-to-solve matrix. Let the easy-to-solve matrix be a diagonal matrix and hence we let $P_k$ be a \\textit{matrix whose columns are A-Orthogonal vectors}. It's also referred to as \\textit{conjugate vectors}. \n        \\begin{align}\n            P^T_kAP_k &= D_k \\text{ where: } (D_k)_{i,i} = \\langle p_{i - 1}, Ap_{i - 1}\\rangle\n            \\\\\n            P_k^T r_0 &= P^T_kAP_kw = D_kw\n            \\\\\n            w &= D^{-1}_kP_k^Tr_0\n        \\end{align}\n        Resulting in: \n        \\begin{align}\n            \\begin{cases}\n                x_k = x_0 + P_kD^{-1}_kP^T_kr_0\n                \\\\\n                r_k = r_0 - AP_kD^{-1}_kP^T_k r_0\n            \\end{cases}\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{Conjugate Direction Method}\n        Importantly, $P_kD_k^{-1}P_k^Tr_0, AP_kD_k^{-1}P_k^Tr_0$ are oblique pojectors.\n        \\\\\n        For convenience, we denote $\\overline{P}_k = P_kD_k^{-1}P_k^{T}$; So we can simply denotes them by $A\\overline{P}_k, \\overline{P}_kA$. Observe that: \n        \\begin{align}\n            & \\text{ran}(I - A\\overline{P}_k )\\perp \\text{ran}(P_k)\n            \\\\\n            & \\text{ran}(I - \\overline{P}_kA) \\perp \\text{ran}(AP_k)\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{Generating Orthogonal Vector}\n        \\begin{prop}[Generating $A$-Orthogonal Vectors]\n            Given any set of linearly independent vectors, for example $\\{u_i\\}_{i = 0}^{n - 1}$, one can generate a set of A-Orthogonal vectors from it. More specifically:\n            \\begin{align}\n                p_k &= (I - \\overline{P}_kA)u_k \\implies p_k \\perp \\text{ran}(AP_k)\n            \\end{align}\n        \\end{prop}\n        \n    \\end{frame}\n    \\begin{frame}{Conjugate Direction Method}\n        The method is acually mentioned by Hestenes, Steifel back in 1952\\cite{paper:cg_original}. \n        \\begin{definition}[Conjugate Direction Method]\n            \\begin{align}\\small\n                \\begin{cases}\n                    \\overline{P}_k = P_kD^{-1}_kP_k^T\n                    \\\\\n                    x_k = x_0 + \\overline{P}_k r_0\n                    \\\\\n                    r_k = (I - A\\overline{P}_k) r_0\n                    \\\\\n                    P^T_kAP_k = D_k\n                    \\\\\n                    p_k = (I - \\overline{P}_kA)u_k & \\{u_i\\}_{i = 0}^{n - 1} \\text{ linearly independent vectors}\n                \\end{cases}\n            \\end{align}\n        \\end{definition}\n        \\begin{itemize}\\small\n            \\item With the assistance of a set of basis vectors that span the whole space, this algorithm can achieve the objective Improvement can be made \n            \\item Would be great if we could update $x_k$, $r_k$, and $p_k$ using results from previous iterations.\n            \\item When $\\{u_i\\}_0^{n - 1}$ is the set of standard basis vector, the method is equivalent to the Gauss Eliminations\n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{CDM Update: }\n        I did some math and here is the update: \n        \\begin{align}\n            r_k - r_{k - 1} &= r_0 - A\\overline{P}_kr_0 - (r_0 - A\\overline{P}_{k - 1}r_0)\n            \\\\\n            x_{k} - x_{k - 1} &= \n                    p_{k - 1}\\frac{\\langle p_{k - 1}, r_0\\rangle}{\\langle p_{k - 1}, Ap_{k - 1}\\rangle}\n            \\\\\n            a_{k - 1} &:= \\frac{\\langle p_{k - 1}, r_0\\rangle}{\n                        \\langle p_{k - 1}, Ap_{k - 1}\\rangle\n                    } = \n                    \\frac{\\langle p_{k - 1}, r_{k - 1}\\rangle}{\n                        \\langle p_{k - 1}, Ap_{k - 1}\\rangle\n                    }\n            \\\\\n            p_k &= (I - \\overline{P}_kA)u_k\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{Conjugate Gradient}\n        By setting $\\{u_i\\}_{i = 0}^{n - 1}$ we derive the conjugate gradient algorithm. To get the magic, we introduce these lemmas: \n        \\begin{lemma}[CG Lemma 1]\\small\n            \\begin{align}\n                    \\langle p_{j}, Ap_k\\rangle\n                    &=\\langle r_k, Ap_{j}\\rangle\n                    = \\langle p_{j}, Ar_k\\rangle \\quad 0 \\le j \\le k \n            \\end{align}\n        \\end{lemma}\n        \\begin{lemma}[CG Lemma 2]\\small\n            \\begin{align}\n                \\langle r_k, p_k\\rangle &= \\langle r_k, r_k\\rangle\n            \\end{align}\n        \\end{lemma}\n        \n    \\end{frame}\n    \\begin{frame}{Conjugate Gradient}\n        \\begin{prop}[CG Generates Orthogonal Residuals]\\small\n            \\begin{align}\n                \\langle r_k , r_j \\rangle = 0 \\quad \\forall\\; 0 \\le j \\le k - 1 \n            \\end{align}\n        \\end{prop}\n        We skip the proof for the presentation. \n    \\end{frame}\n    \\begin{frame}{CG: Recurrence}\n        \\begin{prop}[CG Recurrences]\n            \\begin{align}\n                p_k &= r_k + b_{k - 1}p_{k - 1} \\quad b_{k - 1} = \\frac{\\Vert r_k\\Vert_2^2}\n                {\\Vert r_{k - 1}\\Vert_2^2}\n            \\end{align}\n        \\end{prop}\n    \\end{frame}\n    \\begin{frame}{CG: Recurrence Proof}\n        \\begin{align}\n            p_k &= (I - \\overline{P}_kA)r_k \n            \\\\\n            &= r_k - \\overline{P}_kAr_k = \n            r_k - P_kD^{-1}_kP^T_kAr_k\n            \\\\\n            &= r_k - P_kD^{-1}_k(AP_k)^Tr_k\n            \\\\\n            (AP_k)^Tr_k &= \n            \\begin{bmatrix}\n                \\langle p_0, Ar_k\\rangle\n                \\\\\n                \\langle p_1, Ar_k\\rangle\n                \\\\\n                \\vdots\n                \\\\\n                \\langle p_{k - 1}, Ar_k\\rangle\n            \\end{bmatrix}\n        \\end{align}\n        \n    \\end{frame}\n    \\begin{frame}{CG Recurrence Proof}\n        \\begin{align}\n            \\langle p_j, Ar_k\\rangle& \\quad \\forall\\; 0 \\le j \\le k -2 \n            \\\\\n            \\langle p_j, Ar_k\\rangle&= \\langle r_k, Ap_j\\rangle\n            \\\\\n            &= \\langle r_k, a_j^{-1}(r_j - r_{j + 1})\\rangle\n            \\\\\n            &= a_j^{-1}\\langle r_k, (r_j - r_{j + 1})\\rangle = 0\n        \\end{align}\n        \\begin{itemize}\n            \\item[(41)] By the second lemma. \n            \\item[(42)] By the CDM Recurrences\n            \\item[(43)] By the orthogonality of the residual vectors \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{CG Recurrence Proof}\n        \\begin{align}\n            (AP_k)^Tr_k &= \n            \\begin{bmatrix}\n                \\langle p_0, Ar_k\\rangle\n                \\\\\n                \\langle p_1, Ar_k\\rangle\n                \\\\\n                \\vdots\n                \\\\\n                \\langle p_{k - 1}, Ar_k\\rangle\n            \\end{bmatrix}\n            = \n            a_{k - 1}^{-1}\\langle r_k, (r_{k - 1} - r_{k})\\rangle \\xi_k\n        \\end{align}\n        $\\xi_k$ is the $k$th standard basis vector in $\\mathbb R^k$. We are almost there. \n    \\end{frame}\n    \\begin{frame}{CG Recurrence Proof}\n        \\begin{align}\n            p_k &= r_k - P_kD^{-1}_k(AP_k)^Tr_k\n            \\\\\n            &= r_k - P_kD_k^{-1}a_{k - 1}^{-1}(\\langle r_k, (r_{k - 1} - r_{k})\\rangle) \\xi_k\n            \\\\\n            &= \n            r_k - \\frac{a_{k -1}^{-1}\\langle -r_k, r_k\\rangle}\n            {\\langle p_{k - 1}, Ap_{k - 1}\\rangle}p_k\n            \\\\\n            &= r_k + \\frac{a_{k -1}^{-1}\\langle r_k, r_k\\rangle}\n            {\\langle p_{k - 1}, Ap_{k - 1}\\rangle}p_k\n            \\\\\n            &= r_k + \n            \\left(\n                \\frac{\\langle r_{k - 1}, r_{k - 1}\\rangle}{\\langle p_{k - 1}, Ap_{k - 1}\\rangle}\n            \\right)^{-1}\n            \\frac{\\langle r_k, r_k\\rangle}{\\langle p_{k - 1}, Ap_{k - 1}\\rangle}p_k\n            \\\\\n            &= \n            r_k + \\frac{\\langle r_k, r_k\\rangle}{\\langle r_{k - 1}, r_{k - 1}\\rangle}p_k\n        \\end{align}\n        Done. This is presented because it will be useful for partially orthgonalized CG later. \n    \\end{frame}\n    \\begin{frame}{The CG Algorithm}\n        \\begin{definition}[CG]\\label{def:CG}\n                \\begin{align}\n                    & p^{(0)} = b - Ax^{(0)} \n                    \\\\&\n                    \\text{For } i = 0,1, \\cdots\n                    \\\\&\\hspace{1.1em}\n                    \\begin{aligned}\n                        & a_{i} = \\frac{\\Vert r^{(i)}\\Vert^2}{\\Vert p^{(i)}\\Vert^2_A}\n                        \\\\\n                        & x^{(i + 1)} = x^{(i)} + a_i p^{(i)}\n                        \\\\\n                        & r^{(i + 1)} = r^{(i)} - a_iAp^{(i)}\n                        \\\\\n                        & b_{i} = \\frac{\\Vert r^{(i + 1)}\\Vert_2^2}{\\Vert r^{(i)}\\Vert_2^2}\n                        \\\\\n                        & p^{(i + 1)} = r^{(i + 1)} + b_{i}p^{(i)}\n                    \\end{aligned}\n                \\end{align}\n            \\end{definition}\n    \\end{frame}\n    \\begin{frame}{CG and Krylov Subspace}\n        \\begin{theorem}[CG and Krylov Subspace]\\label{theorem:CG_and_Krylov_Subspace}\n                    \\begin{align}\n                        \\text{choose: } x_k\\in x_0 + \\mathcal K_{k}(A|r_0) \\text{ s.t: } r_k \\perp \\mathcal K_{k}(A|r_0)\n                    \\end{align}    \n        \\end{theorem}\n        Take note that, $\\text{ran}(P_k) = \\mathcal K_k(A|r_0)$ because the index starts with zero for the gonjugate vectors.\n        \\begin{itemize}\n            \\item The number of iterations before termination is just the grade of Krylov Subspace. \n            \\item Something that is special unique compare to CDM. \n            \\item Provides connections to the Lanczos Algorithm.\n        \\end{itemize}\n    \\end{frame}\n\\section{Lanczos iterations as a Symmetric case of Arnoldi iterations}\n    \\begin{frame}{The Arnoldi Iteration}\n        This is a matrix of upper Hessenberg form: \n        \\begin{align}\n            \\tilde{H}_k = \n            \\begin{bmatrix}\n                h_{1, 1} & h_{1, 2} & \\cdots & h_{1, k} \n                \\\\\n                h_{1, 2} & h_{2, 2} & \\cdots & h_{2, k}\n                \\\\\n                \\\\\n                & \\ddots & &\\vdots\n                \\\\\n                & & h_{k, k - 1}& h_{k, k}\n                \\\\\n                & & & h_{k + 1, k}\n            \\end{bmatrix}\n        \\end{align}\n        \\begin{align}\n                Q_1 &= q_1\n                \\\\\n                (\\tilde{H}_k)_{j + 1, k}q_{j + 1}&= (I - Q_jQ_j^H)Aq_j\n                \\\\\n                (\\tilde{H}_j)_{1:j, j} &= Q_jQ_j^HAq_j\n        \\end{align}\n        Usually when implementing, the subdiagonal of $H_k$ are chosen to be \n        \\begin{align}\n            \\tilde H_{k + 1, k} := \\Vert (I - Q_kQ_k^T)Aq_k\\Vert\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{Arnoldi Recurrence}\n        \\begin{align}\n                AQ_{k} &= Q_{k + 1}\\tilde{H}_k\n                \\\\\n                Q_{k}^HAQ_{k} &=: H_k\n        \\end{align}\n        We define $H_k$ to be the principal submatrix of $\\tilde{H}_k$. Please observe that, if $A$ is symmetric, then $Q^H_kAQ_k$ is also symmetric, which makes $H_k$ symmetric, implying $H_k$ is a symmetric tridiagonal Matrix, giving us the tridiagonal factorization of $A$. \n        \\begin{itemize}\n            \\item The characteristic polynomial of $H$, minimizes $\\Vert p(A|w)q_1\\Vert_2$ among all monic polynomials\\cite{book:trefethen}.\n            \\item $\\text{ran}(Q_k) = \\mathcal K_k(A|q_1)$. Range of $Q_k$ spans $\\mathcal K_k(A|q_1)$.\n            \\item Terminates when $k = \\text{grade}(A|q_1)$. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Lanczos Recurrences}\n        \\begin{theorem}[Lanczos Recurrences]\n            $T_k$ is a symmetric tridiagonal matrix with $a_i, 1\\le i\\le k$ on the diagonal and $\\beta_i, 1 \\le i \\le k -1$ on the sub/super diagonal. \n            \\begin{align}\n                AQ_k &= Q_kT_k + \\beta_k q_{k + 1}\\xi_k^T = Q_{k + 1}\\tilde{T}_k\n                \\\\\n                \\implies Aq_j\n                &= \\beta_{j - 1}q_{j - 1} + \\alpha_j q_j + \\beta_{j}q_{j + 1} \\quad \\forall\\; 2\\le j\\le k\n                \\\\\n                \\implies Aq_1 &= \\alpha_1q_1 + \\beta_1 q_2\n            \\end{align}    \n        \\end{theorem}\n    \\end{frame}\n    \\begin{frame}{Minimal Monic of Lanczos}\n        We use the property minimal monic property of Arnoldi, and the eigen decomposition for $A$. \n         \\begin{align}\n                & \\min_{p_{k - 1}:\\text{monic}} \\Vert p(A)q_1\\Vert_2\n                \\\\\n                & =\\Vert \\overline{p}_{k - 1}(A)q_1\\Vert_2\n                \\\\\n                & = \\Vert V \\bar{p}_{k - 1}(\\Lambda)V^Tq_1\\Vert_2\n                \\\\\n                & = \\Vert \\bar{p}_{k - 1}(\\Lambda)V^Tq_1\\Vert_2\n                \\\\\n                &= \\sqrt{\n                    \\sum_{i = 1}^n p_{k - 1}(\\lambda_i)^2(V^Tq_1)^2_1\n                }\n            \\end{align}\n            The last line is saying the characteristic polynomial for $T_k$ from the Lanczos iterations is minimizing a weighted squared sum at the eigenvalues of the matrix $A$. \n    \\end{frame}\n    \\begin{frame}{Extra Useful Facts}\n        \\begin{itemize}\n            \\item [1.)] $q_k$ generated by Lanczos, which is a polynomial under $\\mathcal K_k(A|q_1)$, is orthogonal under the weighted discrete measure defined by a weighted inner product at eigenvalues of $A$. \n            \\item [2.)] The characteristic polynomial of $T_k$ is a scaled version of the polynomial for $q_k$, which means they are also orthogonal. \n            \\item [3.)] Lanczos produces a symmetric tridiagonal matrix with non zero on the sub/super diagonal, that matrix has no repeated eigenvalues. \n        \\end{itemize}\n    \\end{frame}\n\\section{CG Exact Convergence}\n    \\begin{frame}{CG Exact Convergence Rate}\n        {\\footnotesize\n        \\begin{align}\n            \\Vert e_k\\Vert_A^2 & =\n            \\min_{x_k \\in x_0 + \\mathcal K_k(A|r_0)}\n            \\Vert \n                x^+ - x_k\n            \\Vert_A^2\n            \\\\\n            x_k \\in x_0 + \\mathcal K_k(A|r_0) \n            & \\implies\n            e_k = e_0 + p_{k - 1}(A|w)r_0\n            \\\\\n            \\implies  &=\n            \\min_{w\\in \\mathbb R^k}\n            \\Vert \n                e_0 + p_{k - 1}(A|w)r_0\n            \\Vert_A^2\n            \\\\\n            &= \\min_{w\\in \\mathbb R^k}\n            \\Vert \n                e_0 + Ap_{k - 1}(A|w)e_0\n            \\Vert_A^2\n            \\\\\n            &= \\min_{w\\in \\mathbb R^k}\n            \\Vert \n                A^{1/2}(I + Ap_{k - 1}(A|w))e_0\n            \\Vert_2^2\n            \\\\\n            &\\le\n            \\min_{w\\in \\mathbb R^k}\n            \\Vert \n                I + Ap_{k - 1}(A|w)\n            \\Vert_2^2\\Vert e_0\\Vert_A^2 \\quad \n            \\\\\n            & = \n            \\min_{w\\in \\mathbb R^k}\n            \\left(\n                \\max_{i = 1, \\dots, n}\n                |1 + \\lambda_i p_{k - 1}(\\lambda_i|w)|^2\n            \\right)\\Vert e_0\\Vert_A^2\n            \\quad\n            \\\\\n            & \\le \n            \\min_{w\\in \\mathbb R^k}\n            \\left(\n                \\max_{x\\in [\\lambda_{\\min}, \\lambda_{\\max}]}\n                |1 + \\lambda_i p_{k - 1}(\\lambda_i|w)|^2\n            \\right)\\Vert e_0\\Vert_A^2\n            \\quad \n            \\\\\n            &= \n            \\min_{p_{k}: p_{k}(0) = 1}\n            \\max_{x\\in [\\lambda_{\\min}, \\lambda_{\\max}]}\n            | p_{k}(x)|^2 \\Vert e\\Vert_A^2\n            \\\\\n            \\implies\n            \\frac{\\Vert e_k\\Vert_A}{\\Vert e_0\\Vert_A} &\\le \n            \\min_{p_{k}: p_{k}(0) = 1}\\max_{x\\in [\\lambda_{\\text{min}}, \\lambda_{\\text{max}}]} |p_{k}(x)|   \n        \\end{align}\n        }\n    \\end{frame}\n    \\begin{frame}{CG Exact Convergence Rate}\n        \\begin{itemize}\n            \\item It's minimizing the using a polynomial $p_k(x)$ that has $p(0) = 1$. \n            \\item To bound it, one can use the inf norm minimization property of Chebyshev Polynomial.\n            \\item Similar to what was taught in AMATH 585 2022 Winter. \n        \\end{itemize}\n        Using chebyshev polynomial, one can derive the bound: \n        \\begin{align}\n            \\frac{\\Vert e_k\\Vert_A}{\\Vert e_k\\Vert_A}\n            \\le 2 \\left(\n                    \\frac{\\sqrt{\\kappa} + 1}{\\sqrt{\\kappa} - 1}\n            \\right)^k\n        \\end{align}\n        \\begin{itemize}\n            \\item Bound can be improved if we assume single outlier eigenvalues, or a cluster of outlier eigenvalues away from the origin. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Lanczos Conjugate Equivalence}\n        We had been brewing the fact that the Iterative Lanczos Algorithm and the Conjugate gradient algorithm are related. From the previous discussion we can observe that: \n        \\begin{enumerate}\n            \\item [1.)] Both Lanczos and CG terminates when the grade of Krylov subspace is reached. For Lanczos it's $\\mathcal K_k(A|q_1)$ and for CG it's $\\mathcal K_k(A|r_0)$.\n            \\item [2.)] Both Lanczos and CG generate orthogonal vectors, for Lanczos they are the $q_i$ vector and for CG they are the $r_i$ vectors. \n        \\end{enumerate}\n    \\end{frame}\n    \\begin{frame}{Lanczos Vectors and Residuals of CG}\n        Lanczos Vectors are residuals of CG, but unit length and pointing at opposite directions at every other iterations. \n        \\begin{align}\n                q_1 &= \\hat r_0\\\\\n                q_2 &= -\\hat r_1\n                \\\\\n                \\vdots\n                \\\\\n                q_j &= (-1)^{j + 1}\\hat r_{j + 1}\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{Generatin Tridiagonal Matrix of Lanczos from CG Parameters}\n        The tridiagonal matrix of the equivalent Lanczos can be obtained from the CG parameters. \n        \\begin{align}\n            \\begin{cases}\n                \\alpha_{j + 1} = \\frac{1}{a_j} + \\frac{b_{j - 1}}{a_{j - 1}}\n                & \\forall 1 \\le j \\le k - 1\n                \\\\\n                \\beta_{j} = \\frac{\\sqrt{b_{j - 1}}}{a_{j - 1}}\n                & \\forall 2 \\le j \\le k - 2 \n                \\\\\n                \\alpha_1 = a_0^{-1} & \n                \\\\\n                \\beta_1 = \\frac{\\sqrt{b_0}}{\\alpha_0}\n            \\end{cases}\n        \\end{align}\n        \\begin{itemize}\n            \\item Still works fine even if $A$ is indefinite, if we have the luck of $a_j$ being non zero. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{From Lanczos to CG}\n         CG is a special case of applying the Lanczos Iterations with $q_1 = r_0$ to a positive definite matrix. However there are still questions left. \n        \\begin{enumerate}\n            \\item [1.)] How are the solutions $x_k$ generated by CG related to the Lanczos Iterations? \n            \\item [2.)] How are the A-Orthogonal vectors $p_k$ from CG related to Lanczos?\n        \\end{enumerate}\n        To answer it we need to derive CG using the Lanczos iterations. \n    \\end{frame}\n    \\begin{frame}{From Lanczos to CG}\n         we initialize $q_1 = \\hat{r}_0$, then the following relationship between Lanczos and CG occurs between their parameters: \n        \\begin{align}\n            \\begin{cases}\n                y_k = T^{-1}_k \\beta\\xi_1\n                \\\\\n                x_k = x_0 + Q_k y_k\n                \\\\\n                r_k = -\\beta_{k}\\xi_k^T y_k q_{k +1}\n            \\end{cases}\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{From Lanczos to CG}\n        To start recall that the Lanczos Algorithm Asserts the following recurrences:\n        \\begin{align}\n            AQ_k = Q_{k + 1} \\begin{bmatrix}\n                T_k\n                \\\\\n                \\beta_k \\xi_k^T\n            \\end{bmatrix}\n        \\end{align}\n        we know that: $p_k \\in \\mathcal K_{k + 1}(A|r_0)$, the matrix $P_k, Q_k$ spans the same subspace, and that means: \n        \\begin{align}\n            x_{k + 1} &= x_0 + Q_ky_k\n            \\\\\n            r_{k + 1} &= r_0 - AQ_k y_k\n            \\\\\n            Q^H_kr_{k + 1} &= Q_k^H r_0 - Q_k^HAQ_k y_k\n            \\\\\n            \\implies\n            0 &= \\beta\\xi_1 - T_k y_k\n            \\\\\n            y_k &= T_k^{-1}\\beta \\xi_1\n        \\end{align}\n    \\end{frame}\n    \\begin{frame}{From Lanczos to CG}\n        \\begin{align}\n            r_{k + 1} &= r_0 - AQ_k y_k\n            \\\\\n            &= r_0 - AQ_k T_k^{-1}\\beta \\xi_1\n            \\\\\n            \\implies\n            &= \\beta q_1 - AQ_k T_k^{-1} \\beta\\xi_1\n            \\\\\n            &= \\beta q_1 - Q_{k + 1}\\begin{bmatrix}\n                T_k \\\\ \\beta_k \\xi_k^T\n            \\end{bmatrix}T_k^{-1} \\beta\\xi_1\n            \\\\\n            &= \\beta q_1 - \n            (Q_k T_k + \\beta_k q_{k + 1}\\xi_k^T)T_k^{-1} \\beta\\xi_1\n            \\\\\n            &= \n            \\beta q_1 - (Q_k \\beta \\xi_1 + \\beta_k q_{k + 1}\\xi_{k + 1}T_k^{-1}\\beta \\xi_1)\n            \\\\\n            &= -\\beta_k q_{k + 1}\\xi_k^TT_k^{-1} \\beta \\xi_1\n        \\end{align}\n        \\begin{itemize}\n            \\item To represent $a_k, b_k, p_k$ of CG using lanczos, one must consider a $LU$ decomposition of $T_k$ for $T_k^{-1}$. \n            \\item Which is too excessive for the presentations. \n        \\end{itemize}\n        \n    \\end{frame}\n    \\begin{frame}{Moral of the Stories}\n        \\begin{itemize}\n            \\item Lanczos Iterations is CG but doesn't have $T_k^{-1}$. \n            \\item CG is a special case of Lanczos that solves $T_k^{-1}$ with $A$ being symmetric definite.\n        \\end{itemize}\n        The SYMMLQ algorithm is an algorithm for sparse indefinite system. It can factorize $T_k$ effectively even when $T_k$ is singular\\cite{paper:SYMLQ}. It exploits the fact that $T_k$ is only singular on any other iterations\\cite{paper:greenbaum_indefinite_lanczos}.\n    \\end{frame}\n\\section{Affects of Floating Point Arithmetic}\n    \\begin{frame}{Partial Orthogonalization and Full Orthogonalization of CG}\n        We apply the CDM method to adjust $p_k$ and then reorthogonalize $\\overline r_k$. \n        \\begin{align}\n            p_k &:= \\overline{r}_k + b_kp_k - \n                \\frac{\\langle \\overline{r}_k, r_{k -1}\\rangle}{\\langle r_{k - 1}, r_{k - 1}\\rangle}p_k\n            - \\sum_{j = 0}^{k - 1}\\frac{\\langle p_j, A\\overline{r}_k\\rangle}{\\langle p_k, Ap_k\\rangle}p_j\n            \\\\\n            r_k &:= \\overline{r}_k - \\sum_{j = 0}^{k - 1} \\langle \\hat{r}_j,\\overline{r}_k\\rangle \\hat{r}_j\n        \\end{align}\n        \\begin{itemize}\n            \\item It's not as good as as other mitigations for floating point round off error (such as pre-conditioner)\n            \\item It can delay the effect when we choose to partially orthogonalize $p_k, \\overline r_k$. \n            \\item It can emulate exact arithmetic when full re-orthogonalization is used. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Experiment}\n        We use a diagonal matrix whose elements are given as (taken from Greenbaum's book\\cite{book:greenbaum}): \n        \\begin{align}\\label{eqn:paramaterized_experiment_matrix}\n            \\lambda_{\\min} + \\left(\n                \\frac{j}{N - 1}\n            \\right)(\\lambda_{\\max} - \\lambda_{\\min})\\rho^{N - j + 1}\\quad \\forall\\; 1 \\le j \\le N - 1, \\; 0 \\le \\rho \\le 1\n        \\end{align}\n        \\begin{itemize}\n            \\item When $\\rho = 1$, the eigenvalues are uniform points on $[\\lambda_{\\min}, \\lambda_{\\max}]$\n            \\item When $\\rho = 0.9$, the eigenvalues are denser around $\\lambda_{\\min}$, sparser around $\\lambda_{\\max}$. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Experiment}\n        \\begin{itemize}\n             \\item $\\lambda_{\\min} = 1e-4, \\lambda_{\\max} = 1$\n             \\item we use float16 (16 digits binary digits).\n             \\item $x_0 = b + \\epsilon$ ($\\epsilon$ is some tiny random vector as noise)\n             \\item $A \\in \\mathbb R^{256\\times 256}$ Tolerance is 10e-3. \n        \\end{itemize}\n         \n        \\begin{figure}[H]\n                \\centering\n                \\includegraphics[width=20em]{cg_convergence_0.9.png}\n                \\caption{$\\rho = 0.9$}\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Experiment}\n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=20em]{cg_convergence_1.png}\n            \\caption{$\\rho = 1$}\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Lost of Orthogonality}\n        \\begin{itemize}\n            \\item Floats caused CG $p_k, r_k$ to lose conjugacy and orthogonality. \n            \\item What is happening to the equivalent Lanczos algorithm when CG's convergence is slowing down?\n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Lanczos and Ghost Eigenvalues}\n        We consider the following spectrum of $A$ for an experiment on Lanczos: \n        \\begin{align}\n            \\lambda_i = \\left(-1 + \\frac{2(i - 1)}{(n - 1)}\\right)^3\n            \\quad 1\\le i \\le n\n        \\end{align}\\label{eqn:the_ill_conditioned_matrix}\n        \\begin{itemize}\n            \\item Symmetric spectrum around origin. \n            \\item Tightly clustered eigenvalues around origin, sparse around the boundary. \n            \\item $A\\in \\mathbb R^{64 \\times 64}$ and Float64 is used. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Ghost Eigenvalues Plot}\n        \\begin{figure}[H]\n            \\centering\n            \\includegraphics[width=8cm]{ritz_trajectory_plot_floats.png}\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Ghost Eigenvalues Plot}\n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=8cm]{ritz_trajectory_plot_exact.png}\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Lost of Orthogonality}\n        \\begin{figure}[H]\n            \\centering\n            \\includegraphics[width=12em]{fig3.png}\n            \\includegraphics[width=12em]{fig4.png}\n             \\caption{left: The heatmap of the plot of the absolute values of the matrix $Q^T_kQ_k$. right: The plot of $Q_k^TAQ_k$ from floating-point Lanczos iterations}\n        \\end{figure}\n        \\begin{itemize}\n            \\item Ghost eigenvalues effects doesn't imply lost of orthogonality!\n            \\item It's possible that the trajectory stays stable and then suddenly shifted away, it's called misconvergence. (Reliable Numerical Computations ch1\\cite{book:reliable_computation})\n        \\end{itemize}\n    \\end{frame}\n\\section{Diving Deeeeper}\n    \\begin{frame}{Good news}\n        C.C Paige 1980\\cite{paper:paige1980} Showed that: \n        \\begin{align}\n            AQ_k = Q_{k + 1} \n            \\begin{bmatrix}\n                    T_k\n                    \\\\\n                    \\beta_k \\xi_k^T\n            \\end{bmatrix} + F_k\n        \\end{align}\n        Still holds good under floating point arithematic, and $F_k$ is a matrix having $\\mathcal O(\\Vert A \\Vert)$ condition numbers. \n    \\end{frame}\n    \\begin{frame}{CG Float Bound}\n        Big idea is: \n        \\par\n        if we were to perform an CG on the $T_{k + 1}$ produced by the finite precision algorithm with the initial Lanczos vector $q_1$ being $\\xi_1^{(n)}$, then its residual $\\overline{r}_{k}$ of equivalent CG would be exact and it's given as $-\\beta_kT_{k}^{-1}\\xi_kq_{k + 1}$, but with $q_{k + 1} = \\xi_{k + 1}^{(n)}$, the $k + 1$ th standard basis vector in $\\mathbb R^{n}$, and $T_k = (T_{k + 1})_{1:k, 1:k}$. \n        \\begin{itemize}\n            \\item We use exact convergence to bound that quantity. \n            \\item $-\\beta_kT_{k}^{-1}\\xi_kq_{k + 1}$ shows up as the residual of CG using Lanczos under floating point arithematic.\n            \\item It's also how we show that: \"Ghost eigenvalue effects doesn't neccessarily imply lost of orthogonality\". \n            \\item Paige used this idea (and his 1980 paper on Lanczos iterations) to give a convergence rate for CG under floating point arithematic as well. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Losting orthogonality On Ritzvectors}\n        Firstly, we need to know what we expect when eigenvalues of $T_k$ is close to an eigenvalue of $A$. \n        \\begin{align}\n            AQ_k &= Q_k T_k + q_{k + 1}\\beta_k\\xi_k^T\n            \\\\\n            AQ_ks_i^{(k)} &= \\theta_j^{(k)} Q_k s_i^{(k)} + q_{k + 1}\\beta_k \\xi_k^Tv\n            \\\\\n            AQ_ks_i^{(k)} &= \\theta_j^{(k)} Q_k s_i^{(k)} + \\beta_kq_{k + 1}(s_i^{(k)})_k\n            \\\\\n            AQ_ks_i^{(k)} - \\theta_j^{(k)} Q_k s_i^{(k)} &=   \\beta_kq_{k + 1}(s_i^{(k)})_k\n        \\end{align}\n        Note, $q_k^TQ_ks_i^{(k)} = (s_i^{(k)})_k$ under exact arithematic. $Q_ks_i^{(k)}$ Approximates eigenvector of $A$ (it's exact under the subspace spanned by $Q_k$), it's called the Ritzvectors. How does this work in floating point arithematic? \n    \\end{frame}\n    \\begin{frame}{Losing Orthogoality on Ritzvectors}\n        \\begin{figure}[H]\n            \\centering\n            \\includegraphics[width=20em]{lanczos_proj_on_ritz_float.png}\n            \\caption{Projection of floating-point Lanczos vector $q_k$ onto 3 of the largest Ritz vectors: $Q_ks_i^{(k)}$, for $i = k, k - 1, k - 2$\n            }\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Losing Orthogoality on Ritzvectors}\n        \\begin{figure}[H]\n            \\centering\n            \\includegraphics[width=20em]{lanczos_proj_on_ritz_exact.png}\n            \\caption{projection of the exact Lanczos vector $q_k$ onto 3 of the largest Ritz vectors: $Q_ks_i^{(k)}$, for $i = k, k - 1, k - 2$}\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Losing Orthogonality on Ritzvectors}\n        \\begin{figure}[H]\n            \\centering \n            \\includegraphics[width=20em]{ritz_proj_tridiagonal.png}\n            \\caption{The projection of most recent Lanczos vector $q_k$ onto the first 3 Ritzvectors: $Q_ks_i^{(k)}$ for $1\\le i \\le 3$, it's performed on a Tridiagonal matrix $T_k$ generated by finite precision lanczos with $q_1 = \\xi_1$. }\n        \\end{figure}\n    \\end{frame}\n    \\begin{frame}{Losing Orthogonality on Ritzvectors: Final Remark}\n        \\begin{itemize}\n            \\item The Lanczos recurrences are not affected by much due to floating point error, which it's exploited for matrix function approximations. \n            \\item The $Q_k$ generated are not orthogonal any more and it creates ghost eigenvalues. But we know it's losing orthogonality against ritzvectors. \n            \\item Ritzvalues can converge several times. \n        \\end{itemize}\n    \\end{frame}\n    \\begin{frame}{Tiny Intervals}\n        Take advantage of the clustering of the ghost eigenvalues and think of them as the eigenvalues of a potentially a larger matrix, denoted as $\\tilde{A}$ whose eigenvalues are clustered around the eigenvalues of $A$ within a tiny interval. Due to the effect of round of errors, the floating-point Lanczos iterations can't see the spectrum of $A$ clearly and instead, it sees $\\tilde{A}$ whose eigenvalues are smeared out version of $A$, and there are many of them clustered around. More specifically, assuming $A$ has eigenvalues: $\\lambda_1, \\cdots, \\lambda_n$, the eigenvalues of $\\tilde{A}$ lies in: \n        \\begin{align}\n            \\bigcup_{n = 1}^n[\\lambda_i - \\delta, \\lambda_i + \\delta]\n        \\end{align}\n    \\end{frame}\n    \n    \\begin{frame}{Tiny Intervals}\n        Experiments of tiny intervals were carried out by Greenbaum, Strakos\\cite{paper:greenbaum_tiny_interval_experiments}. We replicate the experiment here for CG. \n        \\begin{itemize}\n            \\item $\\delta = \\text{2e-5}\\Vert A\\Vert \\epsilon$ \n            \\item 100 equally spaced eigenvalues on the spectrum for the matrix $\\tilde A$\n            \\item $A\\in \\mathbb R^{64\\times 64}$\n        \\end{itemize}\n    \\end{frame}\n% \\section{Problem Setup}\n%     \\begin{frame}{MDP from Susceptible-Exposed-Infectious-Recovered (SEIR) model}\n%         \\begin{itemize}\n%             \\item \\textbf{States}: $\\mathcal{S} = \\{(p_S, p_E, p_I) \\in \\mathbb{R}_+^3 \\hspace{1mm} | \\hspace{1mm}  p_S + p_E + p_I \\le 1 \\}$, where:\n%             \\begin{itemize}\n%                 \\item $p_S,p_E,p_I$ are the proportion of susceptible, exposed, and infectious individuals, respectively\n%             \\end{itemize}\n%             \\item \\textbf{Actions:} $\\mathcal{A} = \\{(y_V, y_R) \\in \\mathbb{N}^2 | y_V \\le L, y_R \\le M\\}$\n%             \\begin{itemize}\n%                 \\item $y_V(t) = i$ amount of vaccines distributed vaccines to susceptibles at stage $t$. \n%                 \\item $y_R$ is the scale of transmission-reducing interventions\n%             \\end{itemize}\n%         \\end{itemize}\n%     \\end{frame}\n\n\\end{document}", "meta": {"hexsha": "8cbab4ef370148cf6543e068cefc321dfff86dfe", "size": 39985, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis3/presentation.tex", "max_stars_repo_name": "iluvjava/Subspace_Projection_Method", "max_stars_repo_head_hexsha": "0728d708b18a2f0bca763c1061eb729eb0b79c3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis3/presentation.tex", "max_issues_repo_name": "iluvjava/Subspace_Projection_Method", "max_issues_repo_head_hexsha": "0728d708b18a2f0bca763c1061eb729eb0b79c3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis3/presentation.tex", "max_forks_repo_name": "iluvjava/Subspace_Projection_Method", "max_forks_repo_head_hexsha": "0728d708b18a2f0bca763c1061eb729eb0b79c3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.225433526, "max_line_length": 609, "alphanum_fraction": 0.5332499687, "num_tokens": 12177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4234688283653162}}
{"text": "\\newpage\n\\section{Particle characterization and particle tracking using interference properties}\n\t\t\\label{sec:chapter2}\n\n\\subsection{Introduction}\n\nProperties of coherent light to produce interference is widely use in metrology for a long time with, for example, the famous Fabry-Pérot  \\cite{fabry_theorie_1899, perot_application_1899} and Michelson interferometers \\cite{michelson_relative_1887}. The latter was initially used to measure earth's rotation and is still used today, in particular, for the recent measurement of gravitational waves\n\\cite{ligo_scientific_collaboration_and_virgo_collaboration_gw151226_2016}. \nSince the beginning of the century, interest on tracking and characterizing colloidal particles risen thanks to the democratization of micro fluidics and lab-on-a-chip technologies. In the following I will provide some insights on the three most used :\n\n\\begin{itemize}\n\t\\item Reflection Interference Contrast Microscopy (\\gls{RICM})\n\t\\item Lorenz-Mie fit\n\t\\item Rayleigh-Sommerfeld back-propagation\n\\end{itemize}\n\nThe first one, \\gls{RICM}, uses the principle of optical difference path as a Michelson interferometer. The other two, uses the interference between the light scattered by the colloid and the incident light. Generally, both of the sources  are colinear, thus, speak of in-line holography. \n\n\n\n\\subsection{Reflection Interference Contrast Microscopy}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[scale=1]{02_body/chapter2/images/RICM.png}\n\t\\caption{Figure from \\cite{davies_elastohydrodynamic_2018} representing \\gls{RICM} with two wavelengths. (a) Left: interference patterns created with a wavelength $\\lambda_1 = 532$ nm (scale bar $ 5~\\mathrm{\\mu m}$). \n\t\tRight: radial intensity profile (black dots) extracted from the image, azimuthally averaged (magenta line) and fitted with Eq.\\ref{Eq.RICM} to measure the height of the particle (here $h$). (b) Same as (a) with a wavelength $\\lambda_2 = 635$ nm. (c) Time series of the height of a particle $h$ (green: $ \\lambda_1$, magenta: $\\lambda_2$) and the particle velocity measured along the flow in blue. }\n\t\\label{fig.RICM}\n\\end{figure}\n\n\nReflection Interference Contrast Microscopy was first introduced in cell biology by Curtis to study embryonic chick heart fibroblast \\cite{curtis_mechanism_1964} in 1964. \\gls{RICM} gained in popularity 40 years after both in biology and physics \\cite{filler_reflection_2000, siver_use_2000, weber_2_2003, limozin_quantitative_2009, nadal_probing_2002, raedler_measurement_1992}. It was also used recently in soft matter physics to study elastohydrodynamic lift at a soft wall \\cite{davies_elastohydrodynamic_2018}.\n\nWhen we illuminate a colloid with a plane wave from the bottom, a part of the light is reflected at the surface of the glass substrate and at the colloid's surface. The difference of optical path between two reflection create interference patterns. Let's take an interest at the mathematical description of this phenomenon. In the far field, we can describe two different one-dimensional electric field vectors of the same pulsation $\\omega$ \\cite{f_bohren_absorption_1998} as:\n\n\\begin{equation}\n\t\\vec{E}_1(\\vec{r}, t) = \\vec{E}_{0_1} \\cos(\\vec{k}_1 \\cdot \\vec{r} - \\omega t + \\epsilon_1) ~,\n\\end{equation}\nand\n\\begin{equation}\n\t\\vec{E}_2(\\vec{r}, t) = \\vec{E}_{0_2} \\cos (\\vec{k}_2 \\cdot \\vec{r} - \\omega t + \\epsilon_2) ~.\n\\end{equation}\n\n\n\\nomenclature{$\\vec{E}$}{Electrical field}\n\\nomenclature{$k$}{Wave number}\n\\nomenclature{$\\omega$}{Pulsation}\n\nWhere the $k$ is the wave number $k=2\\pi n_{\\mathrm{m}}/\\lambda$, $\\lambda$ denoting the illumination wavelength, $n_\\mathrm{m}$ the optical index of the medium, $\\epsilon_{1,2}$ the initial phase of each wave and $\\vec{r}$ the position from the source. Here, the origin ($\\vec{r} = \\vec{0}$) could be taken at the position of the first reflection (on the glass slide) thus at the particle, $\\vec{r}$ would be given by the particle's height such that $|r| = z$ the particle-subtract distance. Experimentally, we measure the intensity of the interference patterns, those can be computed from the time averaged squared sum of the electric field $\\vec{E} = \\vec{E}_1 + \\vec{E}_2$. The measured intensity is thus given by:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\tI & = \\langle \\vec{E}^2 \\rangle = \\langle \\vec{E}_1^2 + \\vec{E}_2^2 + 2\\vec{E}_1 \\cdot \\vec{E}_2 \\rangle \n\t\t= \\langle \\vec{E}_1^2 \\rangle + \\langle \\vec{E}_2^2 \\rangle  + 2 \\langle \\vec{E}_1 \\cdot \\vec{E}_2 \\rangle \\\\\n\t\\end{aligned}\n\\end{equation} \n\nwhere $ \\langle \\vec{E}_1^2 \\rangle $ and  $\\langle \\vec{E}_2^2 \\rangle$ are respectively given by $I_1$ and $I_2$, the incident light intensities. Using the trigonometric formula $2 \\cos (a)\\cos (b) = \\cos (a+b) + \\cos (a-b) $ we have:\n\n\\begin{equation}\n\t\\langle  \n\t\\vec{E}_1 \\cdot \\vec{E}_2 \\rangle = \n\t\\langle\n\t\\frac{1}{2} \\vec{E}_{0_1}  \\vec{E}_{0_2} \n\t\\left[\n\t\t\\cos \n\t\t\\left(\n\t\t\t\\vec{k}_1 \\cdot \\vec{r} - \\vec{k}_1 \\cdot \\vec{r} + \\phi\t\n\t\t\\right)\t\n\t\t+ \n\t\t\\cos\n\t\t\\left(\n\t\t\t2\\omega t + \\phi'\n\t\t\\right)\n\t\\right]\n\t\\rangle~.\n\\end{equation}\n\nAs we average over the time, the second $\\cos$ will vanish since in general $\\langle \\cos(at + b) \\rangle_ t = 0$ thus:\n\n\\begin{equation}\n\t\\langle \\vec{E}_1 \\cdot \\vec{E}_2 \\rangle = \\frac{1}{2} \\langle  \\vec{E}_{0_1}  \\vec{E}_{0_2} \\rangle\n\t\\cos \n\t\\left(\n\t\\vec{k}_1 \\cdot \\vec{r} - \\vec{k}_2 \\cdot \\vec{r} + \\phi\t\n\t\\right)\t\n\\end{equation}\n\nwith $\\phi$ the phase difference between the two fields, which is generally equal to $\\pi$ due to the reflection properties on a higher index. Indeed, a colloid has generally a greater optical index than the dilution medium.  Finally, the total intensity can be read as:\n\n\n\\begin{equation}\n\tI = I_1 + I_2 + 2 \\sqrt{I_1 I_2} \n\t\\cos \n\t\\left(\n\t\\vec{k}_1 \\cdot \\vec{r} - \\vec{k}_2 \\cdot \\vec{r} + \\phi\t\n\t\\right)\n\\end{equation}\n\nBy taking $k_1 = - k_2$ due to the reflection properties, we have:\n\n\n\\begin{equation}\n\tI = I_1 + I_2 + 2 \\sqrt{I_1 I_2} \n\t\\cos \n\t\\left(\n\t\\frac{4 \\pi n_{\\mathrm{m}}}{\\lambda} z + \\phi\t\n\t\\right)\n\\end{equation}\n\n\nIf we now suppose that we have a spherical particle at a height $z$ we can develop the radial interference intensity $I(x)$ as \\cite{ raedler_measurement_1992}:\n\n\\begin{equation}\n\tI(x) = A_0 + A_1 \\mathrm{e}^{-b_1 x^2} + A_2^{-b_2 x^2} \\cos \\left[ \\frac{4\\pi n_m}{\\lambda}\\left( g(x) + z \\right) + \\phi \\right]\n\t\\label{Eq.RICM}\n\\end{equation}\n\nWhere $A_i$ and $b_i$ are fit parameters and $g(x)$ denotes the contour of the sphere.\nFinally, this method is great because the equation is computationally light and permits to have a quick tracking of particles. However, as we can see on Eq.\\ref{Eq.RICM}, due to the periodicity of the cosinus, the interference pattern will be the same for all heights $z$ separated by a distance $\\lambda / 2n_\\mathrm{m} \\approx 200 $ nm (for $\\lambda = 532$ nm and $n_{\\mathrm{m}} = 1.33$). It is possible to extend this limitation by using 2 different wavelength to $\\approx 1.2 ~ \\mathrm{\\mu m}$ as used in \\cite{davies_elastohydrodynamic_2018}. Despite the precision of this method which can reach the $10$ nm spatial resolution; the measurement ambiguity is not compatible with the study of  micro-particle Brownian motion, hence, \\gls{RICM} is not usable for our context. As a matter of fact, we experimentally reach height span of a few microns. \n\n\n\n\\subsection{Lorenz-Mie Fit}\n\\label{chap:LM_fit}\n\nWhen a colloid is illuminated with a plane wave, a part of the light is scattered. In consequence, the superimposition of the incident field $\\vec{E}_0$ and scattered field $\\vec{E}_s$ interferes. The interference patterns thus obtained are called holograms. If the particle size is at the same order of magnitude or greater than the illumination wavelength, it is not possible to use Rayleigh approximations \\cite{strutt_lviii_1871}. Indeed, we would need to use what we call  the Lorenz-Mie theory which describes the scattering of dielectric spheres; this theory was found by Lorenz and independently by Mie in 1880 and 1908 \\cite{lorenz_lysbevaegelsen_1890, mie_beitrage_1908}. \n\nIt is in the early 2000 that the Lorenz-Mie theory was first used in order to track and characterize particles \\cite{ovryn_imaging_2000, lee_characterizing_2007}. Since then, a lot of studies has been realized with this method \\cite{katz_applications_2010}. In the following I will describe the Lorenz-Mie Fit method. In in this part, the height of the particle $z$ is the distance between the particle's center and the focal plane of the objective lens.\n\nLet the incident field be a plane wave uniformly polarized along the axis $ \\hat{e}$, with an amplitude $E_0$ and propagating along the $\\hat{z}$ direction :\n\\begin{equation}\n\t\\vec{E}_0(\\vec{r},z) = E_0(\\vec{r}) \\mathrm{e}^{ikz}\\hat{e}\n\\end{equation}\n\nLet's consider a particle of radius $a$ at a position $\\vec{r}_p $, the scattered field can be written using the Lorenz-Mie theory \\cite{f_bohren_absorption_1998} as:\n\n\\begin{equation}\n\t\\vec{E}_s(\\vec{r}, z) =  \\vec{f}_s(k(\\vec{r} - \\vec{r}_p))E_0(\\vec{r}) \\exp \\left(-ikz\\right) \n\\end{equation} \n\nWith $\\vec{f}_s$ the Lorenz-Mie scattering function \\cite{f_bohren_absorption_1998}. The intensity $I$ that we measure at $\\vec{r}$ is given by the superimposition of incident and scattered waves. Since the measurements are done at the focal plane, $I$ is given by:\n\n\\begin{equation}\n\t\\begin{aligned}\n\tI(\\vec{r}) & = |\\vec{E}_s(\\vec{r}, 0) + \\vec{E}_0(\\vec{r}, 0)|^2 \\\\\n\t& = E_0^2(\\vec{r}) + 2 E_0^2\\operatorname{Re} \\left(\\vec{f}_s(k(\\vec{r}- \\vec{r}_p)) \\hat{e}\\right) + | \\vec{f}_s(k(\\vec{r}- \\vec{r}_p)) |^2\n\t\\end{aligned}\n\\end{equation}\n\nThe most of the experimental defects on the images are due to spacial illumination variation caused by dust particle and such. It can be corrected by normalizing the image by the background. In another word, we normalize  $I(\\vec{r})$ by the intensity of the incident field $I_0 = E_0(\\vec{r})^2$ which is the experimental background. It can be measured by different methods, one is to have an empty field of view and the other one, which is more convenient is to take the median of a stack of images. Naturally, for having the latter to work, the movie should be long enough to have the particle diffuse enough, if not a ghost of the particle will appear on the background. This process also permits getting rid of the immobile particle that could generate any additional noise. An example of hologram before and after the normalization is shown in Fig.\\ref{fig.Lorenz_mie_demo} a-c). We write the normalized intensity $I/I_0$:\n\n\\begin{equation}\n\t\\frac{I(\\vec{r})}{I_0(\\vec{r})} = 1 + 2 \\operatorname{Re} \n\t\\left(  \n\t\t\\vec{f}_s(k(\\vec{r}- \\vec{r}_p)) \\hat{e}\n\t\\right)\n\t+\n\t|\n\t\t\\vec{f}_s(k(\\vec{r}- \\vec{r}_p))\n\t|^2\n\t\\label{Eq.normalized_Mie}\t\n\\end{equation}\n\n\nNow that we have the analytical form of the holograms' intensity, it is possible to fit an experimental one to Eq.\\ref{Eq.normalized_Mie} as shown in Fig.\\ref{fig.Lorenz_mie_demo} d-e). For the sake of completeness, I will detail the Lorenz-Mie scattering function, $\\vec{f}_s(k\\vec{r})$ which is given by the series:\n\n\\begin{equation}\n\t\\vec{f}_s(k \\vec{r}) = \\sum _{n=1} ^{n_c} \n\t\\frac\n\t{\n\t\ti^n (2n +1)\n\t}\n\t{\n\t\tn(n+1)\n\t}\n\t\\left(\n\t\ti a_n \\vec{N}^{(3)}_{eln}(k\\vec{r})\n\t\t-\n\t\tb_n \\vec{M}^{(3)}_{oln}(k\\vec{r})\n\t\\right)\n\t\\label{Eq.Lorenz-Mie-function}\n\\end{equation} \n\n\nwhere $\\vec{N}^{(3)}_{eln}(k\\vec{r})$ and $\\vec{M}^{(3)}_{oln}(k\\vec{r})$ are the vector spherical harmonics. $a_n$ and $b_n$ are some coefficients that depend on the particle and illumination properties. For a spherical and isotropic particle of radius $a$ and refractive index $n_\\mathrm{p}$, which is illuminated by a linearly polarized plane wave, the $a_n$ and $b_n$ coefficients are expressed in terms of spherical Bessel $j_n$ and Hankel $h_n$ functions as \\cite{f_bohren_absorption_1998}:\n\n\\begin{equation}\n\ta_n = \n\t\\frac\n\t{\n\t\t\\zeta^2 j_n (\\zeta k a)k a j_n' (k a) - j_n(ka)[\\zeta kaj_n(\\zeta ka)]'\n\t}\n\t{\n\t\t\\zeta^2 j_n (\\zeta k a)k a h_n^{(1)'} (k a) - h_n^{(1)}(ka)\\zeta kaj_n'(\\zeta ka)\n\t} ~,\n\t\\label{Eq:an}\n\\end{equation}\n\nand\n\n\\begin{equation}\n\tb_n =\n\t\\frac\n\t{\n\t\tj_n(\\zeta k a) kaj_n'(ka) - j_n (ka) \\zeta kaj_n'(mka)\n\t}\n\t{\n\t\tj_n(\\zeta k a) kah_n^{(1)'}(ka) - h_n^{(1)} (ka) \\zeta kaj_n '(mka)\n\t} ~,\n\t\\label{Eq:bn}\n\\end{equation}\n\n\n\twhere $\\zeta = n_\\mathrm{p} / n_m $ and the prime notation denotes differentiation with respect to the argument. As we can see, the holograms will depends on Eq.\\ref{Eq.Lorenz-Mie-function} and will vary with a lot of parameters ($\\lambda$, $n_m$, $n_\\mathrm{p}$, $a$ and $\\vec{r}_\\mathrm{p}$) which can all be fitted. In general, the illumination wavelength $\\lambda$ and medium index $n_\\mathrm{m}$ are known and do not need to me fitted. From only one hologram it is could thus be possible to measure precisely the position of the particle $\\vec{r}_\\mathrm{p}$ and in the same time characterize the radius and optical index of the colloid. As a side note, it is even possible to characterize a particle without a priori knowledge of its characteristics using Bayesian approach \\cite{gregory_bayesian_2005, dimiduk_bayesian_2016}.\n\nComputing Eq.\\ref{Eq.Lorenz-Mie-function} numerically brings another interesting question, as it is analytically written as a sum over $n$; one could ask after which number of terms $n_c$ the series will converge. It has actually been found that the series converge after a number of terms \\cite{lentz_generating_1976}\n\\begin{equation}\n\tn_c = k a + 4.05 (k a)^{1/3} + 2 ~.\n\\end{equation}\n\nConsequently, larger particles' holograms will need more terms to converge and, hence, are longer to fit. As an example, the largest particles used during my thesis have a radius $a = 2.5 ~ \\mathrm{\\mu m}$ leading to a number of terms $ n_c = 55$ in water and $\\lambda = 532$ nm, for the smallest ones, where $a = 0.5 ~ \\mathrm{\\mu m}$ we find $n_c = 18$ which makes a huge difference in practice.\n\nIf a reader wants to evaluate an hologram given by the Lorenz-Mie theory for a peculiar particle and position, it can be done in a few lines with the \\mintinline{python}{holopy} module using the following Python snippet which was used to make Fig.\\ref{fig.holo_fix_n} and \\ref{fig.holo_fix_z}:\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\nimport holopy as hp\nfrom holopy.scattering import calc_holo, Sphere\n\nsphere = Sphere(n=1.59, r=1.5, center=(4/0.1, 4/0.1, 10))\n# n is the optical index of the particle, r it's radius in microns\n# center is its center position in microns.\n\nmedium_index = 1.33\nillum_wavelen = 0.532\nillum_polarization = (1, 0)\ndetector = hp.detector_grid(shape=100, spacing=0.1)\n# shape is the size in pixel of the camera and the spacing is the pixel's size in microns.\n\nholo = calc_holo(\n\tdetector, sphere, medium_index, illum_wavelen, illum_polarization, theory=\"auto\"\n)\n#the hologram can be directly be plotted using:\nhp.show(holo)\n\\end{minted}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[scale=1]{02_body/chapter2/images/lorenz_mie_fit_demo/plot_lorenz_mie.pdf}\n\t\\caption{a) Raw hologram of a $2.5 ~ \\mathrm{\\mu m}$ polystyrene particle measured experimentally with the setup detailed in the chapter \\ref{chap:exp-setup}. b) Background obtained by taking the median value of the time series of images of the diffusing particle. c) Normalized hologram given by dividing a) by b). d) Result of the fit of c) using Eq.{\\ref{Eq.normalized_Mie}} the particle is found to be at a height $z = 14.77 ~ \\mathrm{\\mu m}$. e) Comparison of the normalized radial intensity, obtained experimentally form c) and theoretically from d).}\n\t\\label{fig.Lorenz_mie_demo}\n\\end{figure}\n\n\\subsubsection{Hologram dependance on the particule characteristics}\n\n\n\nAs we can see with the Eq.\\ref{Eq.Lorenz-Mie-function}, the in-line holograms vary with the that position, radius and optical index of the particle. For in-line holograms, since the incident and scattered field, the $x$ and $y$ position of the particle will simply be given by the center of the hologram. Thus, it is possible to track only movement of the particle only in 2 dimensions by using algorithm such as the hough transform to find the center. As a side note, in that case, it would be optimal to place the particle just above the focal plane to have an airy disk like hologram, as shown in Fig.\\ref{fig.holo_fix_n} for $a = 2.5 ~ \\mathrm{\\mu m}$ and $z = 5 ~\\mathrm{\\mu m}$.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/holos_only_z.pdf}\n\t\\caption{Radial intensity profile stack as a function of the distance between the particle center and the focal place of the objective lens, generated for a particle of radius $a = 1.5 ~\\mathrm{\\mu m}$ and optical index $n = 1.59$.}\n\t\\label{fig:holo_onlyz}\n\\end{figure}\n\nIn order to gain some insights on how the holograms vary with the different parameters, one can to compute holograms for particles of different size and height. We will start by looking at the a particle of a radius $a = 1.5 ~ \\mathrm{\\mu m} $ and $n = 1.59 $ as shown in the Fig.\\ref{fig:holo_onlyz}. In this case, one can observe that as the distance between the particle and the focal plane $z$ increases, the hologram's rings gets larger. Unlike a Michelson interferometer or \\gls{RICM} we do not observe the rings scrolling. Additionally, this thickening of the rings can also be observed on the Fig.\\ref{fig:holo_z_fit}, where hologram's intensity profile are plot as a function of the height $z$ both theoretically and experimentally in the for a polystyrene colloidal particle of radius  $a = 1.5 ~ \\mathrm{\\mu m} $, and, for different couples of parameters on the Fig.\\ref{fig.holo_fix_n}. Also, we can note that if $z$ is not large enough compared to the radius of the particle, the center of an hologram can be so bright that if the camera does not have a large enough dynamic range, the rings could not be seen.  Thus, for having an optimal condition for the fits, one should take care to defocus the enough the objective lens to have $z >> a$.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/smallparticles.pdf}\n\t\\caption{Radial intensity profile for of the particle radius $a << \\lambda$ , generated for a particles of optical index $n = 1.59$ with a distance between the particle center and the focal place of the objective lens $z = 15 ~\\mathrm{\\mu m}$ and $\\lambda = 532 ~ \\mathrm{nm}$.}\n\t\\label{fig:small_part_holo}\n\\end{figure}\n\n\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/holos_only_r.pdf}\n\t\\caption{Radial intensity profile stack as a function of the particle radius, generated for a particle of optical index $n = 1.59$ with a distance between the particle center and the focal place of the objective lens $z = 15 ~\\mathrm{\\mu m}$.}\n\t\\label{fig:holo_onlyr}\n\\end{figure}\n\n\n\n\nWe can now take a look at the variation with respect to the radius of the particle as shown on the Fig.\\ref{fig:holo_onlyr} for a particle of optical index $n = 1.59$ and at a distance $z = 15 ~\\mathrm{\\mu m }$. One can observe that for small particles compared to the wavelength $a << \\lambda$ we do not observe the rings this is due to the fact that for the small particles, the scattering can be approximated using the Reyleigh theory which tells us that the scattering is isotropic. Thus, the variation of intensity around $I_0$ will be smaller for small particle. Also, in this small particle regime, the particle size will not affect the general shape of the hologram but just the intensity of the hologram as it can be seen on the Fig.\\ref{fig:small_part_holo}, for particle of radius $a = 0.02 ~\\mathrm{\\mu m}$ to $a = 0.07 ~\\mathrm{\\mu m}$ for a wavelength $\\lambda = 0.532 ~\\mathrm{\\mu m}$. Additionally, since the noise to signal ratio will be lower than for bigger particles, it will be less precise to characterize small colloids compared to the wavelength.\n\n\n\n\n\n As the particle gets bigger, the scattering become anisotropic and it mostly towards the incident plane wave direction. This effects leads to an increase of the amplitude of the rings $I/I_0$, as one can see on the Fig.\\ref{fig:holo_onlyr}. Thus, the noise to signal ratio is high enough to easily discern the hologram on top of the noise as one can see on the experimental picture fig.\\ref{fig.Lorenz_mie_demo}-a). One who wants to use this method should thus take care to use large enough particle for the holograms' intensity to be greater than the camera noise level.\n\n\n\n\n\n\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/holos_only_n.pdf}\n\t\\caption{Radial intensity profile stack as a function of the particle optical index, generated for a particle of radius $a = 1.5 ~ \\mathrm{\\mu m}$ with a distance between the particle center and the focal place of the objective lens $z = 15 ~\\mathrm{\\mu m}$.}\n\t\\label{fig:holo_onlyn}\n\\end{figure}\n\n\nFinally, one can also check how the holograms are varying with the optical index a particle. In this case it is not the particle's optical index $n_\\mathrm{p}$ which will matter the most but the ratio $\\zeta = n_\\mathrm{p} / n_\\mathrm{m} $ which can be found in the $a_n$ and $b_n$ formulas, Eq.\\ref{Eq:an} and \\ref{Eq:bn}. Indeed, for the scatter to happen, the optical index $n_\\mathrm{p}$ of the colloid needs to be different from the optical index of the surrounding medium $n_\\mathrm{m}$. Additionally, the numerical solution of the Lorenz-Mie scattering is not stable for $n_\\mathrm{p} \\simeq n_\\mathrm{m}$. In the Fig.\\ref{fig:holo_onlyn}, we can observe holograms of a particle of radius $a = 1.5 ~ \\mathrm{\\mu m}$ at fix distance between the particle and the focal plane of the objective lens $z=15 ~ \\mathrm{\\mu m}$ with a varying colloid's optical index, in water $n_\\mathrm{m} = 1.33$. On the Fig.\\ref{fig:holo_onlyn} one can thus observe than for  $n_\\mathrm{p} \\simeq n_\\mathrm{m}$ we do not oberve any holograms.  Additionally, one can observe that the noise to signal ratio gradually increases as $n_\\mathrm{p}$ became different from $n_\\mathrm{m}$. One who wants to use this method should thus take care to the particle material or the solvent to have $n_\\mathrm{m}$ different enough to  $n_\\mathrm{p}$ for the holograms' intensity to be greater than the camera noise level.\n\n\n\n\n\n\n\\subsubsection{Lorenz-Mie conclusion}\n\nThe combination of the height, optical index and radius of colloid thus gives unique holograms. This uniqueness of the holograms permits extracting precisely the position, optical index and radius an a colloid. In order to see how holograms are for different couples for parameter on the Figs.\\ref{fig:holo_fix_z} and \\ref{fig:holo_fix_n}, one can see possible holograms for different size and height. Additionally, one can use the the Jupyter Notebook on my github repository in order to plot any hologram \\href{https://github.com/eXpensia/Ma-these/blob/main/02_body/chapter2/images/holo_size_exemple/holosize_variation.ipynb}{\\faGithub}.  Finally, Lorenz-Mie is the most versatile in-line holographic method, indeed, it permits tracking and characterize unique particles even without a priori knowledge. Besides, it is possible to write the Lorenz-Mie function $\\vec{f}_s$ for particular cases such as anisotropic \\cite{fung_holographic_2013}, non-spherical particles \\cite{wang_using_2014} or particle clusters \\cite{fung_holographic_2013, perry_real-space_2013} to name a few; such possibilities open the door to a lot of experimental studies. Additionally, it can reach really high precision as the tenth of nanometer on the position and radius as well as $10^{-3}$ on the optical index \\cite{lee_characterizing_2007}. Unfortunately, the Lorenz-Mie fitting suffer from a major drawback which is the time needed to fit one image. For example, a 200 by 200 pixels image, of a $2.5 ~ \\mathrm{\\mu m}$ particle's hologram, can take up to two minutes to be fitted using a pure and straightforward python algorithm. A lot of work as been done to have faster tracking, such as random-subset fitting \\cite{dimiduk_random-subset_2014}, GPU (graphical processing unit) acceleration, machine-learning \\cite{yevick_machine-learning_2014, hannel_machine-learning_2018} and deep neural networks \\cite{altman_catch_2020}.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/test_tableau2.pdf}\n\t\\caption{On the left, experimentally measured  holograms' radial intensity profile stack, generated from a polystyrene bead of nominal radius $a = 1.5 \\pm 0.035 ~ \\mathrm{\\mu m} $ using the experimental setup explained in chapter \\ref{chap:exp-setup}. The calibration of this particle radius and optical index is shown in Fig.\\ref{fig:KDErn}. On the right, the corresponding theoretical stack using the result of each individual hologram's fit.}\n\t\\label{fig:holo_z_fit}\n\\end{figure}\n\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/holos_fix_z.pdf}\n\t\\caption{On the left, experimentally measured  holograms' radial intensity profile stack, generated from a polystyrene bead of nominal radius $a = 1.5 \\pm 0.035 ~ \\mathrm{\\mu m} $ using the experimental setup explained in chapter \\ref{chap:exp-setup}. The calibration of this particle radius and optical index is shown in Fig.\\ref{fig:KDErn}. On the right, the corresponding theoretical stack using the result of each individual hologram's fit.}\n\t\\label{fig:holo_fix_z}\n\\end{figure}\n\n\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/holo_size_exemple/holos_fix_n.pdf}\n\t\\caption{On the left, experimentally measured  holograms' radial intensity profile stack, generated from a polystyrene bead of nominal radius $a = 1.5 \\pm 0.035 ~ \\mathrm{\\mu m} $ using the experimental setup explained in chapter \\ref{chap:exp-setup}. The calibration of this particle radius and optical index is shown in Fig.\\ref{fig:KDErn}. On the right, the corresponding theoretical stack using the result of each individual hologram's fit.}\n\t\\label{fig:holo_fix_n}\n\\end{figure}\n\n\\clearpage\n\\newpage\n\n\\subsection{Rayleigh-Sommerfeld back-propagation}\n\n\n\n\n\nRayleigh-Sommerfeld back-propagation \\cite{wilson_3d_2012} works on the same principle as the Lorenz-Mie fitting but assumes that we have small scatterers., such as :\n\n\\begin{equation}\n\t|\\zeta - 1| << 1 \\text{ and } ka|\\zeta - 1| << 1 ~.\n\\end{equation}\n\nIn this case, at the focal plane, the intensity of the scattered field is smaller than the incident field, hence, the term $|\\vec{E}_s|^2$ can be ignored. Thus, the normalized intensity, Eq.\\ref{Eq.normalized_Mie} can be rewritten as:\n\n\\begin{equation}\n\\frac{I(\\vec{r})}{I_0(\\vec{r})}= 1 + 2\\operatorname{Re}\\left( \\frac{E_s(\\vec{r},0)}{E_0(\\vec{r})} \\right) ~.\n\\end{equation}\n\nIf one can retrieve completely the scattered field from an image, it is possible to reconstruct it above the focal plane by convolution using the Rayleigh-Sommerfeld propagator \\cite{goodman_introduction_2005}:\n\n\\begin{equation}\n\th_{-z}(\\vec{r}) = \\frac{1}{2 \\pi} \\frac{\\partial}{\\partial z} \\frac{\\mathrm{e}^{ikR}}{R} ~,\n\t\\label{Eq:propagator}\n\\end{equation}\n\nwhere $ R^2 = r^2 + z^2 $ and the sign convention on the propagator indicates if the particle is below or above the focal plane. Using this propagator we have:\n\n\\begin{equation}\n\tE_s(\\vec{r}, z) = E_z(\\vec{r}, 0) \\otimes h_{-z}(\\vec{r})\n\\end{equation}\n\nBy using the convolution theorem \\cite{cheong_strategies_2010, goodman_introduction_2005, sherman_application_1967,schnars_digital_1994} and supposing a uniform illumination, one can write the reconstructed scattered field at a height $z$ as:\n\n\\begin{equation}\n\tE_s(\\vec{r}, z) \\approx \\frac{\\mathrm{e}^{ikz}}{4\\pi ^2}\n\t\\int ^\\infty _{- \\infty}\n\tB(\\vec{q}) H(\\vec{q}, -z) \\mathrm{e}^{i \\vec{q} \\cdot \\vec{r}} d^2 q\n\t\\label{Eq.RS} ~,\n\\end{equation}\n\nwhere $B(\\vec{q})$ is the Fourier transform of $I/I_0$ and $H(\\vec{q}, -z)$ is given by\n\n\\begin{equation}\n\tH(\\vec{q}, -z) = \\mathrm{e}^{iz \\sqrt{k^2 - q^2}} ~.\n\\end{equation}\n\nFinally, using Eq.\\ref{Eq.RS} one can reconstruct the scattered field and intensity since $I(\\vec{r}) = |E_s(\\vec{r})|^2$ as shown in Fig.\\ref{fig.sommerfeld}. Moreover, by finding the position where the field is the brightest as shown in red the Fig.\\ref{fig.sommerfeld}, we measure the position of the particle.\nThose equations are way less computational intensive than the Lorenz-Mie function Eq.\\ref{Eq.Lorenz-Mie-function}. Thus tracking can be way faster, moreover, Fourier transforms can be largely accelerated using GPU. Additionally, as the propagator Eq.\\ref{Eq:propagator} take only into account the intensity of the image, this method does not require any information on the particle and number of particles. As a matter of fact,   to write Eq.\\ref{Eq.RS} one just need to assume that we have spherical colloids. Thus, this method is great to reconstruct the 3D position of a lot of particles or clusters formations. However, the major drawback is that it is the less precise of the presented measurements and that we can't use it to characterize the particles generating the holograms.\n\n\n\n\n\\subsubsection{Numerical Rayleigh-Sommerfeld back-propagation}\n\nThe \\mintinline{python}{holopy} Python module also provide a set of method that permits to user the Rayleigh-Sommerfed back-propagation. Given the \\mintinline{python}{hologram} variable containing all the needed metadata about the hologram such as the pixel size, medium index $n_\\mathrm{n}$ and wavelength $\\lambda$ and the actual image, one can then use the \\mintinline{python}{propagate} method to back-propagate an hologram over a set of height \\mintinline{python}{zstack} using the following Python snippet.\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\n\timport holopy as hp\n\timport numpy as np\n\t\n\tzstack = np.linspace(0, 20, 11)\n\trec_vol = hp.propagate(holo, zstack)\n\\end{minted}\n\nPlease note that using the \\mintinline{python}{propagate} this each propagation will be done by performing a convolution of the reference hologram over the distance to be propagated. However, better reconstruction can be obtained iteratively propagating holograms over short distance. The latter method is called Cascaded Free Space Propagation, and is particularly useful when the reconstructions have fine features or when propagating over large distances \\cite{kreis_frequency_2002}. It can be done by specifying the argument \\mintinline{python}{cfsp} to the  \\mintinline{python}{propagate} method. For example, to propagate three steps over each distance, we can use \\mintinline{python}{hp.propagate(holo, zstack, cfsp=3)}.\n\n\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=2]{02_body/chapter2/images/sommerfel_demo.jpg}\n\t\\caption{Figure from \\cite{cheong_strategies_2010} a) Volumetric reconstruction using Eq.\\ref{Eq.RS} of the scattered intensity of single colloidal sphere, colored by intensity. b) Volumetric reconstructions of $22$ individual $1.58 ~ \\mathrm{\\mu m}$ diameter silica spheres organized in bcc lattice using holographic optical tweezers in distilled water. Colored regions indicate the isosurface of the brightest 1 percent of reconstructed voxels.}\n\t\\label{fig.sommerfeld}\n\\end{figure}\n\n\n\n\\subsubsection{Conclusion}\n\nFinally, the method we choose is the Lorenz-Mie fitting method, since this it permits the characterization of single particles. Indeed, since we are interested to fine effects near the surface, we need to know perfectly the radius of the particle we have recorded. This feature also make our all process calibration free, as we don't need to assume any physical properties. In the following, the experimental setup is going to be detailed.\n\n\n\\subsection{Experimental setup}\n\\label{chap:exp-setup}\nIn order to observe the holograms we use an homemade inverted microscope as shown on the Fig.\\ref{fig:picture} and shematized in Fig.\\ref{fig:schema}. A sample consists of a parallelepipedic chamber ($1.5 ~ \\text{cm} ~ \\times ~ 1.5 ~ \\text{cm} ~ \\times ~ 150 ~ \\mathrm{\\mu m} $), made from two glass covers, a parafilm spacer, and sealed with vacuum grease, containing a dilute suspension of spherical polystyrene beads. We used 3 different sizes, of nominal radii $0.56 ~ \\mathrm{\\mu m}, ~ 1.5 ~ \\mathrm{\\mu m} \\text{ and } 2.5 ~ \\mathrm{\\mu m} $, at room temperature $T$, in distilled water (type 1, MilliQ device) of viscosity $\\eta = 1 ~ \\mathrm{mPa.s}$. The sample is illuminated by a collimated laser beam with a $521 ~ \\mathrm{\\mu m}$ wavelength. As depicted in the chapter \\ref{chap:LM_fit}, the light scattered by one colloidal particle at a given time $t$ interferes with the incident beam. An oil-immersion objective lens (x60 magnification, $1.30$ numerical aperture) collects the resulting instantaneous interference pattern, and relays it to a camera (Basler acA1920-155um) with a $51.6$ nm/pixel resolution (see Fig.\\ref{fig.Lorenz_mie_demo}a)). The exposure time of the camera is set to $\\tau_{\\mathrm{expo}} = 3$ ms to avoid motion-induced blurring of the image, as a general rule, the particle should not diffuse more than the pixel size during that time such that here $2D\\tau_{\\mathrm{expo}} < 51.6$ nm.\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/figures_setup/photo_setup.pdf}\n\t\\caption{Photo of the custom build microscope used along my thesis. It is mainly composed of Thorlabs cage system. The camera used is a Basler acA1920-155um, we use a x60 magnification and $1.30$ numerical aperture oil-immersion objective lens. The light source is a colimated  $521 ~ \\mathrm{\\mu m}$ wavelength laser.}\n\t\\label{fig:picture}\n\\end{figure}\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[scale=0.9]{02_body/chapter2/images/figures_setup/schema_setup.pdf}\n\t\\caption{Schematic of the experimental setup. A laser plane wave of intensity $I_0$ illuminates the chamber containing a dilute suspension of micro-spheres in water. The light scattered by a particle interferes with the incident beam onto the focal plane of an objective lens, that magnifies the interference patten and relays it to a camera.}\n\t\\label{fig:schema}\n\\end{figure}\n\n\n\\subsection{Hologram fitting strategy}\n\n\\subsubsection{How to fasten the process ?}\n\nAs presented in the section \\ref{chap:LM_fit} about the Lorenz-Mie fitting, the main drawback is the time to fit an image, from $30$ seconds for the images of $100 \\times  100$ pixels to a few minutes for the $500\\times 500$ pixels. We can directly see a bottleneck, indeed, if we want to track one trajectory made of $100~000$ images we would need to wait a minimum of $\\approx 70$ days; for a series of images that need only a few minutes to be shot experimentaly. When I started my PhD, two groups, the Grier's lab and the Manoharan's lab, had already introduced python packages, respectively, Pylorenzmie and Holopy in order to inverse holograms. They had introduced ways to only fit a set of randomly chosen pixels, and demonstrated that taking only $1\\%$ of the image pixels, could lead to similar precision and improve considerably the fit's execution time \\cite{dimiduk_random-subset_2014}. Unfortunately, even if this is faster, it leads to a few images per second and still is too long for the amount of data we wanted to have. Ironically, this part of my project is certainly the one where I spent the most my time, and I actually learned a lot of things on code optimization and computer cluster usage. It's around the half of my thesis, that Pylorenzmie got a new commit on their github repository which was telling that they succeeded on using GPU acceleration using CUDA. This was not an easy task since they needed to reconstruct the Bessel functions in an understandable way for the GPU, fortunately it is possible to do so by using continued fractions \\cite{lentz_generating_1976}. This humongous update permits fitting whole images at a whooping speed improvement of 20 fps. At this speed, we fit the tridimension position of the particle, the radius and optical index. To have a more reliable and fast tracking, what we do is that we fit with all free parameters the first $10~000$ images of a movie. We then determine the physical properties of the colloidal particle and then fit the whole movie with only the position as a free parameter.\n\n\\subsubsection{Radius and optical index characterization}\n\n\nOnce the data of the radius and optical index retrieved, the quantity we can look at is the the distribution of measurements. Using $10 ~ 000$ measurements we can plot the histograms of the measured $a$ and $n_\\mathrm{p}$.\n\n\n\n\nThis simple histogram could suffice to measure the physical properties of the colloidal particle. However, we can go a bit further and look at the 2D histogram of the $a$ and $n_\\mathrm{p}$ as presented in the fig.\\ref{fig:KDErn} here smoothed using a Gaussian kernel density estimator. As we can see it is not isotropic, and it seems that the measurement of $n_\\mathrm{p}$ and $a$ are correlated.\n \n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter2/images/KDErn.pdf}\n\t\\caption{2D Probability density function of the measurements of the optical index $n_\\mathrm{p}$ and radius $a$. Black lines indicate iso-probability. Taking the $10\\% $ top probability, we measure $n_\\mathrm{p} = 1.585 \\pm 0.002$ and $a=1.514 \\pm 0.003 ~ \\mathrm{\\mu m}$. }\n\t\\label{fig:KDErn}\n\\end{figure}", "meta": {"hexsha": "6c4110f5e5cd63c086d0c291a570811963dc5038", "size": 37381, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "02_body/chapter2/.ipynb_checkpoints/chapter2-checkpoint.tex", "max_stars_repo_name": "eXpensia/Confined-Brownian-Motion", "max_stars_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "02_body/chapter2/.ipynb_checkpoints/chapter2-checkpoint.tex", "max_issues_repo_name": "eXpensia/Confined-Brownian-Motion", "max_issues_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "02_body/chapter2/.ipynb_checkpoints/chapter2-checkpoint.tex", "max_forks_repo_name": "eXpensia/Confined-Brownian-Motion", "max_forks_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.4437627812, "max_line_length": 2061, "alphanum_fraction": 0.7542066825, "num_tokens": 10632, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4234688224352891}}
{"text": "\\chapter{Risk}\n\n\\begin{multicols}{2}[\\subsubsection*{Contents of this chapter}]\n   \\printcontents{}{1}{\\setcounter{tocdepth}{2}}\n\\end{multicols}\n\n\n\\section{Checklist}\n\nTen sequential steps to model, assess and improve a portfolio.\n\n\\begin{itemize}\n\\item Data Processing: Steps 1-5\n\\item Risk Management: Steps 6-8\n\\item Portfolio Management: Steps 9-10\n\\end{itemize}\n\nThe model comes first, and the data comes after. There are two core components in modern quantitative finance. The first is the checklist, and the second is linear factor models. Linear factor models are the core for anything you need to know in econometrics, machine learning, estimation risk, etc.. \n\nThe temptation might be to take the data and train some deep neural network on it, but you will not get anything out of that. You have to extract a repetitive behavior from the past that will repeat in the future. For equities, this turns out to be true for the log values. The changes in the log values are more or less i.i.d.. \n\n\n\\subsection{Step 1: Risk Drivers Identification}\n\nThe identification of risk drivers is more of an art than a science. \n\nRisk drivers are random processes that (1) behave homogenously as time evolves, similar to a random walk, and (2) completely determine the P\\&L of the financial instruments at hand. Log-values for equity (i.e. stock prices), yield curve in fixed income, implied volatility surfaces for derivatives, number of defaults for credit, activity time for high frequency and cumulative P\\&L for strategies. \n\nTranslate from a product specific to a product agnostic time series. \n\nThe risk driver will be multivariate stochastic process that should behave homogeneously as time as time evolves. It should also be solely responsible for the P\\&L of the financial instrument. I.e., knowing the risk driver at all times would mean knowing the value of the financial instrument at all times.\n\n\\subparagraph{Example: Equities} The data available for two stocks is simply their stocks value over several business days. The values themselves do not evolve homogenously, but the log of the stock values do. Hence the log-value is a risk driver. This example is probably too simple to really be helpful.\n\n\\subsubsection{Equities}\nlog Values\n\n\\subsubsection{Fixed Income}\nZero coupon bond is a (imaginary) bond that does not give coupons. The value of a bond is the discounted values of the coupons until maturity plus the zero coupon bond.\n\t\n\nLog rolling price of a zero coupon bond, i.e. at each time look at the price of a product that expires (for example) one year ahead. \n\nYou can normalize by dividing by time to maturity. I.e. 2 year forwards less volatile than 10 year forwards.\n\nYield to maturity: rolling value Vzcb(t+tau) ==> log Vzcb ==> rescale by diving by tau ==> opposite sign \n\nStandardization process, previously and art, now standard.\n\nAnnualized compounded return of the zero-coupon bond from generic time t to $t_{end} = t+\\tau$. \n\nYt = 1/tau ln(vzcb/Vzcb)\n\nSwap / yield curve -- times to maturitiy and rate. Infinite dimensional parameters. Lower dimensional representation possible by fitting the curve.\n\nFixed-income parsimonious representations: Nelson-Siegel parametrization. Fit a parametric shape through the yield curve. Level, slope (steepness) curvature, decay. Four parameters. Therefore, 4 risk drivers. Parametrization extremely close to empirical yield.\n\nMeucci: feeling that Nelson-Siegel perfectly good, though not necessarily arbitrage-free. Provides alternative (Vasicek).\n\nCovers fixed income modeling through zero coupon bond. \n\n\\subsubsection{Derivatives}\n\nFocus on European style derivatives, call options. Payoff is hockeystick. Different profiles (as long as european) vcan be expressed through call options. \n\nMoneyness:\n\n\\begin{equation}\nm = \\frac{1}{\\tau}ln (S_t / k^{strk})\n\\end{equation}\n\nIf price is above strike price then options are in the money, if price is below strike price then it is out of the money.\n\nRolling value is decent risk driver, avoiding implied volatility surface.\n\nImplied volatility via Black-Scholes-Merton function, gives the price of a call option. Five inputs, four of which are observed. Remaining one is sigma, volatility, the implied volatility.\n\nLong horizons you assume changes proportional of the level. Short horizons you assume changes identical to the level (i.e. geometric vs arithmetic brownian motion).\n\n\nHeston arbitrage-free implied volatility surface is derivative counterpart to Vasicek in fixed income. \n\nThere is so much uncertainty in forecasting the future that it's better to just stick to the simple stuff, because the uncertainty will swamp out any benifit from being finniky.  \n\n\n\\subsubsection{Credit}\nCredit risk has to do with not being able to trust the counterparty. \n\nImportant concepts: \n\nTime of default \n\nDefault indicator\n\nExposure at default \n\nLoss given default \n\nCredit ratings give categorical distribution, rather than binary default/not default. Loss given default often in terms of Beta distribution.\n\nRisk drivers, when they are too many then you perform dimensionality reduction.\n\nKey metric is cumulative number of transitions between credit ratings. \n\n\n\\subsection{Step 2: Quest for Invariance}\nThe invariants are shocks that, together with information available at the previous time step, fully determine the current risk drivers. They are i.i.d. across time (\"white noise\"). The unpredictable element. Once identified, they can be extracted from the past time series. The invariants introduce the stochastic element, which allows prediction of the future via estimation.\n\nWhat is the white noise behind the risk drivers? The quest for invariance is the quest for i.i.d. components in the time series data.\n\n\\subparagraph{Example: Equities} Assuming the daily compounded returns are i.i.d., the risk driver can be written as:\n\n\\begin{equation}\nX_{n,t} = X_{n,t-1} + \\ln\\frac{V_{n,t}}{V_{n,t-1}}\n\\end{equation}\n\nSo the invariant is $\\epsilon_{n,t} = \\ln\\frac{V_{n,t}}{V_{n,t-1}}$.\n\nRisk drivers display empirical features that deviate from the random walk. Efficiency, mean reversion, long memory, and volatility clustering.\n\n\n\\subsubsection{Efficiency}\n\nRandom walk as model for efficiency. Kolmogorov Smirnoff test can test for i.i.d.ness. Also, ellipsoid invariance test. \n\n\n\\subsubsection{Mean-reversion}\n\nAR(1) processes, for example. Exponentially decaying autocorrelation. Markov Chains\n\n\n\n\\subsubsection{Volatility Clustering}\n\nModeled with GARCH. Stochastic mean and stochastic volatility. \n\nGARCH models as random walk, except innovations have variance that undergoes an autocorrelated random walk. \n\nGARCH has been used for stocks, yield, etc., model the increment and it applies across all asset classes. \n\nEstimate via maximum likelihood. \n\nExtensions of GARCH: generalize dispersion, or change market to which it's applied.\n\nGARCH, EGARCH, ACD, \n\n\n\n\n\n\\subsection{Step 3: Estimation}\n\nEstimating the joint distribution of the invariants from their past realizations. This can be done because of the i.i.d. property of the invariants. Often this involves assigning different weights to different observations. For example, emphasizing more recent observations or emphasizing observations is more similar market environments.\n\nEstimating the i.i.d. components in the risk drivers.\n\n\n\n\n\n\n\n\n\\subsection{Step 4: Projection}\n\nBased on the distribution of the invariants, project the distribution of the process of the risk drivers for a set of future times. For example, write down the distribution of the risk driver at the horizon, conditioned on information available now, based on square-root rule (assuming normally distributed innovations). \n\n\\subsection{Step 5: Pricing at the horizon}\n\nThe previous step had to do with projecting the risk driver. This step projects the actual value. If in step 4, the probability distribution of the risk driver at some point in the future was calculated, in this step there is a transformation of the random variable to obtain the probability distribution of the value at some point in the future. \n\n\\subsection{Step 6: Aggregation}\nSteps 1-5 treated markets. In this step, the portfolio and the allocation policy are introduced. The goal is the ex-ante market performance of a portfolio stemming from an allocation policy. \n\nThis includes portfolio value, ex-ante performance and stress test. Stress test is a projection conditioned on extreme events, so for example: what would the returns be if the market went down 10\\%.\n\n\\subsection{Step 7: Ex-ante Evaluation}\nA risk or satisfaction measure is assigned to the ex-ante performance of the allocation policy, as calculated by step 6. Satisfaction measures are mainly of three types:\n\n\\begin{itemize}\n\\item expected utility / certainty-equivalent, including mean-variance trade-off\n\\item spectral / distortion measures, which include VaR, cVaR and actuarial measures\n\\item Sharpe and other non-dimensional ratios\n\\end{itemize}\n\nOne very simple example for a satisfaction measure is negative standard deviation. Analogous to the loss function in machine learning, there is a measure assigned to the quality of the distribution.\n\n\\subsection{Step 8: Ex-ante Attribution}\n\nAttribution is attribution of the risk to different risk factors.\n\nExpress the ex-ante performance $\\mathbf{Y}$ as a linear combination of relevant risk factors $\\mathbf{Z} = (Z_1,...,Z_{\\overline{k}}$ with exposures $\\mathbf{\\beta}$ plus a shift term $\\alpha$ and a zero-center residual $U$. \n\n\\begin{equation}\n\\mathbf{Y} = \\mathbf{\\alpha} + \\mathbf{\\beta Z} + \\mathbf{U}\n\\end{equation}\n\nAttribution models can be constructed bottom-up, by starting from exposures of each financial instrument to pre-defined factors, or top-down, extracting surprise factors from the attribution model.\n\nAn example for a risk factor may be the return over the same future interval of some stock market index (i.e. SP500). The ex-ante performance metric may simply be the normally distributed ex-ante return $\\mathbf{Y}_{h(\\cdot)} = \\mathbf{R}_{\\mathbf{w},t_{now}\\rightarrow t_{hor}}$. The attribution model reads:\n\n\\begin{equation}\n\\mathbf{R} = \\mathbf{\\alpha} + \\mathbf{\\beta Z} + \\mathbf{U}\n\\end{equation}\n\n\n\n\\subsection{Step 9: Construction}\n\nOptimal portfolio, optimal policy.\n\n\\subsection{Step 10: Execution}\n\n\n\n\n\n\n\\section{Distributions}\n\n\\subsection{Univariate distributions}\nCDF, pdf, and characteristic function. Characteristic function is the expected value of $e^{i\\omega X}}$, which is the fourier transform of the pdf. Similarly, there is the moment generating function, but the moment generating function may not be defined (for example for the student-t distribution). The Quantile function is the inverse of the CDF, basically, giving the value of $X$ that is bigger than $c$ of the data. There's also the sub-quantile function, which is the integral of the quantile function, which is the cvar, the conditional value at risk. There's also the Lorenz curve. Are all representations of the univariate variable. \n\n\\subsection{Multivariate Distributions}\nCDF, pdf, characteristic function and moment generating function genrealize as expected to multivariate random variables. Quantile function doesn't really exist. \n \n\n\n\\subsection{Elliptical Distributions}\n\nA market that is jointly elliptical has portfolios that are also jointly elliptical. Any elliptical distribution can be represented in terms of $X = \\mu + R \\sigma Y$. \n\nThe important property is affine equivariance. Elliptical distributions are very significant for analytical approaches. Elliptical distributions can be factored,via transformation, to a uniform distribution on the unit sphere and a radial distrubtion.\n\n\\subsection{Scenario Probability Distributions}\n\n\n\\subsection{Exponential Family Distributions}\n\n\n\n\\section{Expectation and Variance}\n\n\n\\subsection{Affine Equivariance}\n\n\\subsection{Variational Principle}\n\n", "meta": {"hexsha": "5b5f604e731bf36062b0366c4ca94b9633d0ab14", "size": 11887, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/finance.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/finance.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/finance.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7389558233, "max_line_length": 643, "alphanum_fraction": 0.7886767056, "num_tokens": 2670, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.423468818556322}}
{"text": "\\section{Our method}\n\nOur method uses a \\emph{break table} just like the method by Haddon\nand Waite \\cite{Haddon:1967}, but instead of building, moving, and\nsorting the table while objects are moved, we first move the objects\nand then construct the table.  For that, additional space in the form\nof a bitmap is required.  The bitmap has one bit per word of\nmemory in the heap, which amounts to less than $2$\\% additional memory\non a $64$-bit machine.  The bits in the bitmap are set by the\n\\emph{mark} phase of the garbage collector.\n\n\\refFig{fig-example-a} shows a heap in which shaded areas indicate\nlive objects and white areas indicate dead objects.  The heap contains\n16 word as shown by the addresses.  At the bottom of the figure is\nshown the bitmap after the mark phase (phase 1) is complete.\n\n\\begin{figure}\n\\begin{center}\n\\inputfig{fig-example-a.pdf_t}\n\\end{center}\n\\caption{\\label{fig-example-a}\nExample of initial heap.}\n\\end{figure}\n\nIn phase 2, the heap is compacted by sliding the live objects to the\nbeginning of the heap.  In this phase, two pointers are used, a\n\\emph{source} pointer pointing to words containing live objects, and a\n\\emph{destination} pointer pointing to words containing dead objects,\nas illustrated by \\refFig{fig-example-b}.  Words are copied from the\nsource location to the destination location.  In each iteration, the\ndestination location is incremented by one unit, whereas the source\nlocation is incremented until either it reaches the end of the heap,\nor a word containing a live object as indicated by the bitmap\ncontaining a $1$.\n\n\\begin{figure}\n\\begin{center}\n\\inputfig{fig-example-b.pdf_t}\n\\end{center}\n\\caption{\\label{fig-example-b}\nPointers to source and destination locations.}\n\\end{figure}\n\n\\refFig{fig-example-c} shows the situation when phase 2 is complete. \n\n\\begin{figure}\n\\begin{center}\n\\inputfig{fig-example-c.pdf_t}\n\\end{center}\n\\caption{\\label{fig-example-c}\nHeap after compaction.}\n\\end{figure}\n\nIn phase 3, a \\emph{break table} is built at the position of the\ndestination pointer.  The break table consists of a sequence $a_0,\nd_0, a_1, d_1, \\ldots, a_n, d_n, a_{n+1}$ of alternating\n\\emph{addresses} and \\emph{deltas}.  The value $a_0$ is always $0$.\nThe table has an odd number of elements, because it both starts and\nends with an address.  Each $a_i$ (except possibly $a_0$ and\n$a_{n+1}$) is the index of the beginning of a zone of dead objects.\nEach $d_i$ is the sum of the sizes of the dead zones preceding\n$a_{i+1}$.\n\n\\refFig{fig-example-d} shows the break table of the example heap in\n\\refFig{fig-example-a}.\n\n\\begin{figure}\n\\begin{center}\n\\inputfig{fig-example-d.pdf_t}\n\\end{center}\n\\caption{\\label{fig-example-d}\nBreak table.}\n\\end{figure}\n\nNotice that if both the bottom zone and the top zone of the heap\ncontain live objects, then our break table may require three additional\nwords of storage compared to the total number of free words available.\nThe reason for this additional requirement is that our table contains\n\\emph{sentinels} (the first two words and the last word) that are not\nstrictly required, but by including them, we avoid special cases in\nour procedure for searching the table.  We can easily make sure that\nthree additional words are available by triggering a collection when\ngranting a request for memory would leave fewer than three free words\nat the end of the heap.  Haddon and Waite \\cite{Haddon:1967} did not\nhave this luxury, because they assumed an existing mark-and-sweep\ncollector.  For that reason, their paper contains an extensive\nargument that their break table can fit in the available space.\n\nThe break table is built by scanning the bitmap from start to end.  In\npractice, since the heap is likely to contain fairly large contiguous\nzones, the bitmap will contain long runs of $0$s and long runs of\n$1$s.  It is therefore advantageous to scan the bitmap a word at a\ntime, making this phase quite efficient. \n\nIn phase 4, the lower part of the heap is traversed word by word in\norder to adjust the pointers according to the contents of the break\ntable.  For each pointer value $p$, the table is searched for values \n$a_i, d_i, a_{i+1}$ such that $a_i \\le p < a_{i+1}$.  The\npointer value $p$ is adjusted by subtracting $d_i$ from it.  To find\nthe entry, the break table is search using \\emph{binary search}.\n\nWhile the overhead of the binary search may seem unacceptably high,\ntwo properties contribute to keeping this overhead low:\n\n\\begin{enumerate}\n\\item While the break table could contain as many as $N/4$ entries,\n  where $N$ is the number of words in the heap, in practice, it\n  contains far fewer than that, again because the heap is likely to\n  contain relatively few relatively large zones.\n\\item It is very likely that the entry in the break table required to\n  adjust a particular pointer is the same as the entry required to\n  adjust the pointer immediately preceding it.  By testing this case\n  first, the vast majority of full binary searches can be avoided.\n\\end{enumerate}\n", "meta": {"hexsha": "4bbd309f6e39d30157d65593fcb05baf5b3d7d42", "size": 4996, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Papers/Sliding-GC/sec-our-method.tex", "max_stars_repo_name": "gwerbin/SICL", "max_stars_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 842, "max_stars_repo_stars_event_min_datetime": "2015-01-12T15:44:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T14:03:04.000Z", "max_issues_repo_path": "Papers/Sliding-GC/sec-our-method.tex", "max_issues_repo_name": "gwerbin/SICL", "max_issues_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 85, "max_issues_repo_issues_event_min_datetime": "2015-03-25T00:31:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-18T11:06:19.000Z", "max_forks_repo_path": "Papers/Sliding-GC/sec-our-method.tex", "max_forks_repo_name": "gwerbin/SICL", "max_forks_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 80, "max_forks_repo_forks_event_min_datetime": "2015-03-06T12:52:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T05:30:33.000Z", "avg_line_length": 43.4434782609, "max_line_length": 71, "alphanum_fraction": 0.7702161729, "num_tokens": 1288, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.42346881467735487}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n%\\makeindex\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on \n\n\\section{Properties of Ideals}\n\\label{sec:properties_of_ideals}\n\n\\begin{defn}\n\tLet \\(A\\leq R\\) be a subset of a ring \\(R\\).\n\t\\begin{itemize}\n\t\t\\item  The \\textbf{ideal generated by \\(A\\)} is the  smallest ideal of \\(R\\) containing \\(A\\), written by \\((A)\\).\n\t\t\\item \n\t\t\t\\begin{align*}\n\t\t\t\tRA = \\left\\{r_1a_1 + r_2a_2 + \\ldots + r_na_n \\mid r_i \\in R,\\, a_i \\in A,\\, n \\in \\Z_+ \\right\\} \\\\\n\t\t\t\tAR = \\left\\{a_1r_1 + a_2r_2 + \\ldots + a_nr_n \\mid a_i \\in A,\\,r_i \\in R,\\,  n \\in \\Z_+ \\right\\} \\\\\n\t\t\t\tRAR = \\left\\{r_1a_1r'_1 + r_2a_2r_2' + \\ldots + r_na_nr_n' \\mid r_i,r'_i \\in R,\\, a_i \\in A,\\, n \\in \\Z_+ \\right\\}\n\t\t\t\\end{align*}\n\t\t\tare the \\textbf{left, right, and two-sided ideal generated by \\(A\\)}.\n\t\t\\item If \\(\\left| A \\right| = n < \\infty\\), then \\((A)\\) is a \\textbf{finitely generated ideal}.\n\t\t\\item If \\(\\left| A \\right| =1\\) then \\((A)\\) is a \\textbf{principal ideal}.\n\t\\end{itemize}\n\\end{defn}\nIf \\(A = \\left\\{ a_1,a_2,\\ldots \\right\\} \\) then we write \\((A) = (a_1,a_2,\\ldots)\\) for simplicity. Notice that \\(b\\in R\\) is in \\((a)\\) if and only if \\(b = ra\\) for some \\(r \\in R\\), which is equivalent to \\((b) \\subset (a)\\).\n\n\\begin{prop}\n\tLet \\(I \\triangleleft R\\). Then \\(I = R\\) if and only if there exists a unit \\(u \\in I\\).\\\\\n\n\tIf \\(R\\) is commutative, then \\(R\\) is a field if and only if the only ideals of \\(R\\) are \\(0\\) and \\(R\\).\n\\end{prop}\n\n\\begin{cor}\n\tIf \\(R\\) is a field and \\(R'\\) an arbitrary ring, then any nonzero ring homomorphism \\(\\varphi :R\\to R'\\) is injective.\n\\end{cor}\n\n\\begin{defn}[Maximal Ideal]\n\tA proper ideal \\(M\\) of a ring \\(R\\) is a \\textbf{maximal ideal} of \\(R\\) if there does not exist another ideal of \\(R\\) that contains \\(M\\) besides \\(R\\) itself.\n\\end{defn}\nEvery proper ideal is containd in a maximal ideal.\n\n\\begin{anki}\nTARGET DECK\nCurrent Math::Abstract Algebra II\n\n% Up to 5 consequences\nSTART\nDefinition\nName: Maximal Ideal\nPremise 1: \\(M\\) is a proper ideal of ring \\(R\\)\nConsequence 1: \\(M\\) is maximal if there does not exist another ideal of \\(R\\) that contains \\(M\\) besides \\(R\\) itself\nTags: ring_ideals\n<!--ID: 1611701297894-->\nEND\n\\end{anki}\n\n\\begin{thm}[Classification of Maximal Ideals]\n\tLet \\(R\\) be a commutative ring with identity and \\(M\\) an ideal in \\(R\\). Then \\(M\\) is a maximal ideal of \\(R\\) if and only if \\(R / M\\) is a field.\n\\end{thm}\n\n\\begin{anki}\n% Up to 4 premises\n% Up to 4 equivalences\nSTART\nTheorem\nName: Classification of Maximal Ideals\nPremise 1: \\(R\\) commutative ring with identity\nPremise 2: \\(M\\) ideal in \\(R\\)\nConsequence 1: \\(M\\) maximal ideal \\(\\iff\\) \\(R/M\\) is a field\nTags: ring_ideals\n<!--ID: 1611701297914-->\nEND\n\\end{anki}\n\n\\begin{defn}[Prime Ideal]\n\tA proper ideal \\(P\\) in a commutative ring \\(R\\) is a \\textbf{prime ideal} if whenever \\(ab \\in P\\), then either \\(a \\in P\\) or \\(b \\in P\\).\n\\end{defn}\nNote that it is possible to define prime ideals in a noncommutative setting.\n\n\\begin{anki}\n% Up to 5 consequences\nSTART\nDefinition\nName: Prime Ideal\nPremise 1: Proper ideal \\(P\\) in commutative ring \\(R\\)\nConsequence 1: \\(P\\) prime ideal iff \\(ab \\in P \\implies a \\in P\\) or \\(b \\in P\\)\nTags: rings_ideals\n<!--ID: 1611701297931-->\nEND\n\\end{anki}\n\n\\begin{prop}\n\tLet \\(R\\) be a commutative ring with identity \\(1_R\\neq 0\\). Then \\(P\\) is a prime ideal in \\(R\\) if and only if \\(R / P\\) is an integral domain.\n\\end{prop}\n\n\\begin{anki}\n% Up to 4 premises\n% Up to 4 equivalences\nSTART\nTheorem\nPremise 1: \\(R\\) commutative ring w identity\nConsequence 1: \\(P\\) prime ideal in \\(R\\) iff \\(R / P\\) integral domain\nTags: rings_ideals\n<!--ID: 1611701297949-->\nEND\n\\end{anki}\n\nAs an example, note that every ideal in \\(\\Z\\) is of the form \\(n\\Z\\), and that \\(\\Z_n\\) is an integral domain only when \\(n\\) is prime. This is why ideals of the form \\(\\Z_p\\) are viewed as prime ideals.\n\\begin{cor}\n\tEvery maximal ideal in a commutative ring with identity is also a prime ideal.\n\\end{cor}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Every maximal ideal in a commutative ring with identity is also a {{c1::prime ideal}}. \nTags: rings_ideals\n<!--ID: 1611701297965-->\nEND\n\\end{anki}\n% \\printindex\n\\end{document}\n", "meta": {"hexsha": "d7a5a14cdbce43e779e3ef36f53c209eb47c49cb", "size": 4568, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ring Theory/Notes/source/Ideals.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Ring Theory/Notes/source/Ideals.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Ring Theory/Notes/source/Ideals.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8633093525, "max_line_length": 229, "alphanum_fraction": 0.6633099825, "num_tokens": 1606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7690802423634961, "lm_q1q2_score": 0.42346124613296876}}
{"text": "\\documentclass[12pt]{article}  %%%,twocolumn is too scrunched. decrease margin, increase column seperation\r\n\r\n%%% \r\n%%% Composition of formulas for MST Qualifying Exam\r\n%%% All mistakes are mine, all work is cited by Author\r\n%%% Creative Commons:\r\n%%% Attribution-Noncommercial-Share Alike 3.0 Unported\r\n%%% http://creativecommons.org/licenses/by-nc-sa/3.0/\r\n%%% \r\n\r\n\\usepackage{verbatim} %%% multi-line comments\r\n\\usepackage[pdftitle={equations for the qualifying exam}, pdfauthor={Ben Payne}, pdfsubject={equations}, pdfkeywords={maxwell, lagrange}]{hyperref}\r\n\\usepackage{times}\r\n\r\n%%% AMS packages and font files\r\n\\usepackage{amsmath} %%% necessary for gathered equations\r\n\\usepackage{amsfonts}\r\n%%% For figures\r\n%%%\\usepackage[dvipdfm,colorlinks=true]{hyperref}\r\n\\usepackage[dvips]{graphicx}\r\n\\usepackage[usenames,dvipsnames]{color}\r\n\\usepackage{setspace}\r\n\r\n%%% screws up the paragraph formatting\r\n%%%\\raggedright\r\n\r\n\\begin{comment}\r\n\\setlength{\\topmargin}{-.5in}\r\n\\setlength{\\textheight}{9.5in}\r\n\\setlength{\\oddsidemargin}{0in}\r\n\\setlength{\\textwidth}{6.5in}\r\n\\end{comment}\r\n\\setlength{\\topmargin}{-1in}\r\n\\setlength{\\textheight}{10in}\r\n\\setlength{\\oddsidemargin}{-.5in}\r\n\\setlength{\\textwidth}{7.5in}\r\n\r\n\r\n%%% Commonly used macros\r\n%%% from https://facetsproject.org/facets/browser/trunk/docs/gsdocs/nondimtf2hall.tex\r\n\\newcommand{\\pfrac}[2]{\\frac{\\partial #1}{\\partial #2}}\r\n\\newcommand{\\pfraca}[1]{\\frac{\\partial}{\\partial #1}}\r\n\\newcommand{\\pfracb}[2]{\\partial #1/\\partial #2}\r\n\r\n\\def\\includeSchaums{T} \r\n\\def\\qualifyingyear{F}\r\n\r\n\\setlength{\\columnsep}{.5in} \r\n\\begin{document}\r\n%%%\\twocolumn\r\n%%% or you can put it in \\documentclass[11pt,twocolumn]{article}\r\n\r\n%%% don't hyphenate so much - default = 200, max (never hyphenate) = 10,000\r\n\\hyphenpenalty=800\r\n\r\n\\title{Physics equations}\r\n\\author{Ben~Payne\\footnote{Electronic address: ben.is.located@gmail.com}}\r\n%%%\\affiliation{Department~of~Physics, Missouri~University~of~Science~\\&~Technology, Rolla,~MO~65409}\r\n\\date{\\today}\r\n\r\n\\thispagestyle{empty}  %%% hides page number of the title page\r\n\\pagestyle{empty} %%% no page numbers on the following pages\r\n%%%\\begin{abstract}\r\n%%%equations for the qualifying exam\r\n%%%\\end{abstract}\r\n\r\nversion 0.64, 20090308\r\n\r\n%%% http://clarku.edu/~djoyce/trig/identities.html\r\n\\if\\includeSchaums T\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{coordinate systems}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n(from cover of \\cite{GriffithED}.) Most can be found in Schaum's.\r\n%%%\\begin{comment}\r\n the following is in Schaum's, pg 120\r\n\\subsection{cartesian}\r\n%%%\\Huge\r\n\\begin{equation}\r\ndV = \tdx\\cdot dy\\cdot dz\r\n\\label{eq:cartesian_dV}\r\n\\end{equation}\r\n%%%\\normalsize\r\ngradient: \r\n%%%\\Huge\r\n\\begin{equation}\r\n\\vec{\\nabla} t = \\widehat{x} \\pfrac{t}{x}  + \\widehat{y} \\pfrac{t}{y} + \\widehat{z} \\pfrac{t}{z}  %%% can't seem to get \\hat to work\r\n\\label{eq:cartesian_gradient}\r\n\\end{equation}\r\n%%%\\normalsize\r\ndivergence (equ 1.40, page 17 \\cite{GriffithED})\r\n%%%\\Huge\r\n\\begin{equation}\r\n \\vec{\\nabla} \\cdot v = \\pfrac{v_x}{x} + \\pfrac{v_y}{y} + \\pfrac{v_z}{z}\r\n\\label{eq:cartesian_divergence}\r\n\\end{equation}\r\n%%%\\normalsize\r\nlaplacian\r\n\\begin{equation}\r\n\\nabla^2 f = \\pfrac{^2 f}{x^2} + \\pfrac{^2 f}{y^2} + \\pfrac{^2 f}{z^2}\r\n\\label{eq:cartesian_laplacian}\r\n\\end{equation}\r\n%%%\\end{comment}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{spherical}\r\n\r\n\\begin{equation}\r\ndV = \tr^2 \\ \\sin \\theta \\ dr \\ d\\theta \\ d\\phi\r\n\\label{eq:spherical_dV}\r\n\\end{equation}\r\n\r\npage 40, \\cite{GriffithED}\r\n\\begin{equation}\r\n  d \\vec{a} = \\hat{r} \\ r^2 \\sin \\theta \\ d\\theta \\ d\\phi\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\vec{\\nabla} = \\hat{r}\\pfraca{r}+ \\hat{\\theta}\\frac{1}{r}\\pfraca{\\theta}+\\hat{\\phi}\\frac{1}{r\\sin\\theta}\\pfraca{\\phi}\r\n\\label{eq:spherical_gradient}\r\n\\end{equation}\r\n\r\n%%%\\begin{comment}\r\n Schaum's, pg 126\r\nlaplacian. See \\htmladdnormallink{planetMath laplacian rectangualr to cartesian}{http://planetmath.org/encyclopedia/DerivationOfTheLaplacianFromRectangularToSphericalCoordinates.html}\r\nand \\htmladdnormallink{planetMath laplacian}{http://planetmath.org/?method=l2h&from=collab&id=76&op=getobj}\r\n(equ 3.53, page 137 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\nabla^2 f = {1 \\over r^2} {\\partial \\over \\partial r}  \\left( r^2 {\\partial f \\over \\partial r} \\right) \r\n+ {1 \\over r^2 \\sin \\theta} {\\partial \\over \\partial \\theta}  \\left( \\sin \\theta {\\partial f \\over \\partial \\theta} \\right) \r\n+ {1 \\over r^2 \\sin^2 \\theta} {\\partial^2 f \\over \\partial \\phi^2}\r\n\\label{eq:spherical_laplacian}\r\n\\end{equation}\r\n%%%\\end{comment}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{cylindrical}\r\n\r\n\\begin{equation}\r\ndV = \ts \\ ds \\ d\\phi \\ d\\theta\r\n\\label{eq:cylindrical_dV}\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\vec{\\nabla} = \\hat{s}\\pfraca{s} + \\hat{\\phi}\\frac{1}{s} \\pfraca{\\phi} + \\hat{z}\\pfraca{a}\r\n\\label{eq:cylindrical_gradient}\r\n\\end{equation}\r\n\r\n%%%\\begin{comment}\r\n\\begin{equation}\r\n\\nabla^2 f = {1 \\over \\rho} {\\partial \\over \\partial \\rho}  \\left( \\rho {\\partial f \\over \\partial \\rho} \\right) \r\n+ {1 \\over \\rho^2} {\\partial^2 f \\over \\partial \\theta^2} + {\\partial^2 f \\over \\partial z^2 }\r\n\\label{eq:cylindrical_laplacian}\r\n\\end{equation}\r\n%%%\\end{comment}\r\n\\fi\r\n\\section{formulas}\r\n\r\nmaterial in this section can NOT be found in Schaum's \\htmladdnormallink{mathematical handbook of formulas}{http://site.ebrary.com/lib/umr/Doc?id=10015341}, which is allowed on the day of the exam.\r\n%%%\\begin{comment}\r\n Schaum's, 123 \\\\ \r\nStoke's thm (equ 1.57, page 34 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\int_{surface} (\\vec{\\nabla}\\cdot\\vec{v})\\cdot d\\vec{a} = \\oint_{volume}\\vec{v}\\cdot d\\vec{l}\r\n\\label{eq:stokesThm}\r\n\\end{equation}\r\n%%%\\end{comment}\r\n\r\nGreene's thm (equ 1.56, page 31 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\int_{volume}(\\vec{\\nabla}\\cdot\\vec{v}) d\\tau = \\oint_{surface} \\vec{v}\\cdot d\\vec{a}\r\n\\label{eq:greenesThm}\r\n\\end{equation}\r\n\r\nTaylor series expansion is in Schaum's, but the easy approximation is not. (assuming small x)\r\n\\begin{equation}\r\n(1+x)^n \\approx 1 + n x\r\n\\label{eq:TaylorSeriesApprox}\r\n\\end{equation}\r\n\r\n%%%\\begin{comment}\r\n in Schuam's \\\\ \r\nTaylor series expansion\r\n%%% \\begin{widetext} %%% not recognized\r\n%%%\\begin{multicols}{2}%%% not recognized\r\n\\begin{equation}\r\nf(x) = f(a) + f'(x)|_a (x-a) + \\frac{1}{2!} f''(x)|_a (x-a)^2 + \\cdots\r\n\\label{eq:TaylorSeries}\r\n\\end{equation}\r\n%%%\\end{multicols}%%% not recognized\r\n%%%\\end{widetext} %%% not recognized\r\n%%%\\end{comment}\r\n\r\n\r\n\\section{Math}\r\n\\begin{equation}\r\n\\left[ \\begin{array}{cc}\r\n  \\cos \\theta & \\sin \\theta \\\\\r\n-\\sin \\theta  & \\cos \\theta \\\\\r\n \\end{array} \\right]\r\n\\left[ \\begin{array}{c}\r\nA_x\\\\\r\nA_y\r\n\\end{array}\\right]\r\n=\r\n\\left[ \\begin{array}{c}\r\nA_{x'}\\\\\r\nA_{y'}\r\n\\end{array}\\right]\r\n\\end{equation}\r\n\\begin{center}\r\n \\includegraphics[scale=0.3]{pictures/coordinate_rotation}\r\n\\end{center}\r\n\r\n\r\nVariance\r\n\\begin{equation}\r\n(\\Delta A)^2 = \\langle A^2 \\rangle - \\langle A \\rangle^2 \r\n\\end{equation}\r\n\r\nQuadratic equation\r\n\\begin{equation}\r\n x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\r\n\\end{equation}\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Electromagnetics} %%\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{Maxwell equations} %%\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n%%% see http://hyperphysics.phy-astr.gsu.edu/HBASE/electric/maxeq.html\r\nSee also page 22, \\cite{ReifThermo}; page 2, \\cite{JacksonED} \\\\ \r\n%%%\\begin{align} %%% utilizes the \"&\"\r\n\\underline{Faraday}'s law (equation 7.16, page 302, \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{\\nabla}\\times \\vec{E} = -\\pfrac{\\vec{B}}{t} \r\n  \\label{eq:maxwellEcurl}\r\n\\end{equation}\r\n\r\n\\underline{Ampere}'s law (equation 5.54, page 225 and equation 5.44, page 222 \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{\\nabla}\\times \\vec{B} =  \\mu_0\\vec{J}+\\frac{1}{c^2}\\pfrac{\\vec{E}}{t} \r\n  \\label{eq:maxwellBcurl}\r\n\\end{equation}\r\nwhere\r\n\\begin{equation}\r\n c = \\frac{1}{\\sqrt{\\epsilon_0 \\mu_0}}\r\n\\end{equation}\r\n\r\n\\underline{Gauss}'s law, electricity (equation 2.14, page 69 \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{\\nabla}\\cdot\\vec{E} = \\frac{\\rho}{\\varepsilon_0} \r\n  \\label{eq:maxwellEdiv} \r\n\\end{equation}\r\n\r\n\\underline{Guass}'s law, magnetism (equation 5.48, page 223 \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{\\nabla}\\cdot\\vec{B} = 0  \r\n  \\label{eq:maxwellBdiv}\r\n\\end{equation}\r\n%%%\\end{align}\r\nIntegral forms:\r\n\r\nflux of electric field (equation 2.11, page 67 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\Phi_E = \\int_{any\\ surface} \\vec{E} \\cdot d\\vec{a}\r\n\\end{equation}\r\n\r\n\\underline{Gauss}'s law, electricity. (equation 2.13, page 68 \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\oint_{closed\\ surface} \\vec{E}\\cdot d\\vec{a} = \\frac{Q_{enclosed}}{\\epsilon_0}\r\n\t\\label{eq:GaussLaw}\r\n\\end{equation}\r\n\r\n\\underline{Faraday}'s Law (equation 7.18, page 306 \\cite{GriffithED}) \r\n\\if\\qualifyingyear T\r\n(2008 A3)\r\n\\fi\r\n\\begin{equation}\r\n  \\oint \\vec{E} \\cdot d\\vec{l} = - \\frac{d\\Phi _B}{dt}\r\n\t\\label{eq:Faraday_law}\r\n\\end{equation}\r\n\r\n\\underline{Ampere}'s law (equation 5.55, page 225 and 5.42, page 222 \\cite{GriffithED}) \r\n\\if\\qualifyingyear T\r\n(2008 A3)\r\n\\fi\r\n\\begin{equation}\r\n  \\oint \\vec{B} \\cdot d\\vec{l} = \\mu_0 I_{enclosed}\r\n\t\\label{eq:Ampere}\r\n\\end{equation}\r\n\r\n\\underline{Ampere}'s law (page 306, \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\oint \\vec{B} \\cdot d\\vec{l} = \\mu_0 I_{enclosed} + \\mu_0 \\epsilon_0 \\int \\left( \\frac{d}{dt}\\vec{E}\\right) \\cdot d\\vec{a}\r\n\t\\label{eq:Ampere_large}\r\n\\end{equation}\r\n\r\n\\underline{Lorentz} force law (equation 5.2, page 204 \\cite{GriffithED}). Also equation 1-61, page 22 \\cite{GoldsteinCM}\r\n\\begin{equation}\r\n\\vec{F} = q (\\vec{E} + \\vec{v}\\times \\vec{B})\r\n\\end{equation}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%% end maxwell %%%%%%%%%%\r\n\\subsection{general EM}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nequation 1-62, page 22 \\cite{GoldsteinCM}\r\n\\begin{equation}\r\n\\vec{B} = \\vec{\\nabla} \\times \\vec{A}\r\n\\end{equation}\r\n\r\nCoulomb's Law\r\n\\begin{equation}\r\n\\vec{F} =\\frac{1}{4\\pi \\epsilon _{0} } \\frac{q_{1} q_{2} }{r^{2} } \\hat{r}\r\n\\end{equation}\r\n where $q_{2} $ is the test charge\r\n\r\n\\begin{equation}\r\n\\vec{E}=\\frac{1}{4\\pi \\epsilon_0} \\int_v \\frac{\\rho}{r^2} d \\tau \\hat{r}\r\n\\end{equation}\r\n\r\nelectric displacement (see also eq \\ref{eq:electricDisplacementwithPolarization})\r\n\\begin{equation}\r\n\\vec{D} = \\epsilon_0 \\vec{E}\r\n\t\\label{eq:electricDisplacement}\r\n\\end{equation}\r\n\r\nElectric field due to point charge (equation 2.4, page 60 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\vec{E} = \\frac{1}{4 \\pi \\epsilon_0} \\sum_i \\frac{q_i}{r_i^2} \\hat{r}_i\r\n%%%\\label{eq:another}\r\n\\end{equation}\r\n\r\n\r\nelectrostatic potential (equ 2.21, page 78 and equ 7.10, page 293\\cite{GriffithED})\r\n\\begin{equation}\r\nV = - \\int^r_{\\infty} \\vec{E}\\cdot d\\vec{l}\r\n%%%\\label{eq:another}\r\n\\end{equation}\r\n\r\nelectric field and electrostatic potential (equation 2.23, page 78,  \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{E} = -\\vec{\\nabla}V\r\n\t\\label{eq:electric_field_potential}\r\n\\end{equation}\r\n\r\nelectrostatic potential (equation 2.27, page 84 \\cite{GriffithED})\r\n\\begin{equation}\r\n V = \\frac{1}{4 \\pi \\epsilon_0} \\sum_i \\frac{q_i}{r_i}\r\n\\end{equation}\r\n\r\nelectrostatic potential (equation 2.29, page 84 \\cite{GriffithED})\r\n\\begin{equation}\r\n V = \\frac{1}{4 \\pi \\epsilon_0} \\int \\frac{\\rho}{r} d \\tau\r\n\\end{equation}\r\n\r\nwork (equation 2.42, page 92  \\cite{GriffithED})\r\n\\begin{equation}\r\n  W = \\frac{1}{2} \\sum q_i V(r_i)\r\n%%%\\label{eq:}\r\n\\end{equation}\r\n\r\nwork and electrostatic potential (equ 2.45, page 94 \\cite{GriffithED})\r\n\\begin{equation}\r\n  W = \\frac{\\epsilon_0}{2} \\int_{all space} E^2 d \\tau\r\n\\label{eq:work_in_electric_field}\r\n\\end{equation}\r\n\r\nsurface charge density and electrostatic potential (where $n$ is the normal direction \\\\ (equation 2.49, page 102  \\cite{GriffithED})\r\n\\begin{equation}\r\n\\sigma = -\\epsilon_0 \\frac{\\partial V}{\\partial n}\r\n\\label{eq:surfacechargedensity}\r\n\\end{equation}\r\n\r\nequation 2.48, page 102 \\cite{GriffithED}\r\n\\begin{equation}\r\n\\vec{E} = \\frac{\\sigma}{\\epsilon} \\hat{n}\r\n\\end{equation}\r\n\r\n\r\nelectric displacement, including polarization (equ 4.21, page 175 \\cite{GriffithED})\r\n(see also eq \\ref{eq:electricDisplacement})\r\n\\begin{equation}\r\n\\vec{D} = \\epsilon_0 \\vec{E} + \\vec{P}\r\n\\label{eq:electricDisplacementwithPolarization}\r\n\\end{equation}\r\n\r\nwork and electrostatic potential (equ 2.55, page 106, \\cite{GriffithED})\r\n\\begin{equation}\r\n  W = \\frac{1}{2} C V^2\r\n\t\\label{eq:workCapacitor}\r\n\\end{equation}\r\n\r\nelectrostatic potential due to a monopole (equation 3.97, page 149  \\cite{GriffithED})\r\n\\begin{equation}\r\nV_{monopole} = \\frac{1}{4 \\pi \\epsilon_0} \\frac{Q}{r}\r\n\\end{equation}\r\n\r\nelectrostatic potential due to a dipole (equation 3.99, page 149  \\cite{GriffithED})\r\n\\begin{equation}\r\nV_{dipole} = \\frac{1}{4 \\pi \\epsilon_0} \\frac{\\vec{p}\\cdot \\hat{r}}{r^2}\r\n\\end{equation}\r\n\r\nwhere dipole moment (which points from the (-) charge to the (+) is \\\\ \r\n(equation 3.98, page 149  \\cite{GriffithED}) (equation 3.100, page 150  \\cite{GriffithED})\r\n\\begin{equation}\r\n\\vec{p} = \\int \\vec{r} \\; ' \\rho ( \\vec{r}\\;' ) d \\tau \\;' = \\sum_i q_i r_i\r\n\\end{equation}\r\n\r\nNote: $E_{dipole}$, equation 3.104, page 155; is given on 2002 B10,\r\nbut as a derivation (see also problem 3.33).\r\n\r\nTorque ($N$) is on a dipole ($\\vec{p}=q\\vec{d}$) due to E field (equation 4.4, page 164, \\cite{GriffithED})\r\n\\begin{equation}\r\n\\vec{N} = \\vec{p} \\times \\vec{E}\r\n\\end{equation}\r\n\r\npotential energy of a dipole (problem 4.7) (equation 4.6, page 165, \\cite{GriffithED})\r\n\\begin{equation}\r\nU = -\\vec{p} \\cdot \\vec{E}\r\n\\end{equation}\r\n\r\nSimilarly for magnetic moment ($\\vec{\\mu} = (\\vec{I} \\cdot \\vec{A})\\hat{n}$) \\\\ \r\n(equation 6.1, page 257, \\cite{GriffithED}) \r\n\\begin{equation}\r\n\\vec{N} = \\vec{\\mu} \\times \\vec{B} \\\\ \r\n\\end{equation}\r\n\r\npotential energy (equation 6.34, page 281, \\cite{GriffithED}) \r\n\\begin{equation}\r\nU = -\\vec{\\mu} \\cdot \\vec{B}\r\n\\end{equation}\r\n\r\nforce due to magnetic field (equ 5.16, page 205 \\cite{GriffithED})\r\n\\if\\qualifyingyear T\r\n(1997 A4)\r\n\\fi\r\n\\begin{equation}\r\n F_{magnetic} = I \\int d\\vec{l} \\times \\vec{B}\r\n\\end{equation}\r\n\r\n(equ 6.31, page 275 \\cite{GriffithED})\r\n\\begin{equation}\r\n \\vec{B} = \\mu \\vec{H}\r\n\\end{equation}\r\n\r\n(equ 6.32, page 275 \\cite{GriffithED}) \r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\n \\mu = \\mu_0 (1+\\chi_m)\r\n\\end{equation}\r\n\r\n(equ 7.3, page 285 \\cite{GriffithED})\r\n\\begin{equation}\r\n \\vec{J} = \\sigma \\vec{E}\r\n\\end{equation}\r\n\r\nflux (equ 7.12, page 295 \\cite{GriffithED}) \r\n\\if\\qualifyingyear T\r\n(1997 A4, 2009 A)\r\n\\fi\r\n\\begin{equation}\r\n \\Phi = \\int \\vec{B} \\cdot d\\vec{a}\r\n\\end{equation}\r\n\r\nwork (equ 7.29, page 317 \\cite{GriffithED}). Used in problems 7.26, 7.27. \r\n\\if\\qualifyingyear T\r\n(2008 A3)\r\n\\fi\r\n\\begin{equation}\r\n  W = \\frac{1}{2} L I^2\r\n\t\\label{eq:work_self_inductance}\r\n\\end{equation}\r\n\r\nwork (equ 7.34, page 317 \\cite{GriffithED}) \r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\n  W = \\frac{1}{2 \\mu_0} \\int_{all space} B^2 d \\tau\r\n\t\\label{eq:work_in_magnetic_field}\r\n\\end{equation}\r\n\r\nflux, inductance (equ 7.25, page 313 \\cite{GriffithED})\r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\n \\Phi = L I\r\n\\end{equation}\r\n\r\n\r\nPower (equ 8.11, page 347 \\cite{GriffithED}), positive on page 349\r\n\\begin{equation}\r\n  Power = \\int \\vec{S} \\cdot d\\vec{a}\r\n\t\\label{eq:power_fields}\r\n\\end{equation}\r\n\r\ntotal potential energy in a field (equation 8.5, page 346 \\cite{GriffithED}) (combines \\ref{eq:work_in_magnetic_field} and \\ref{eq:work_in_electric_field})\r\n\\begin{equation}\r\nU_{em} = \\frac{1}{2} \\int ( \\epsilon_0 E^2 + \\frac{1}{\\mu_0} B^2 ) d \\tau\r\n\\end{equation}\r\n\r\n\r\nPoynting vector (equation 8.10, page 347 \\cite{GriffithED})\r\n\\begin{equation}\r\n  \\vec{S} = \\frac{1}{\\mu} \\vec{E}\\times\\vec{B}\r\n\t\\label{eq:Poynting_vector}\r\n\\end{equation}\r\n\r\nPower and Poynting vector (equation 8.11, page 347 \\cite{GriffithED})\r\n\\begin{equation}\r\nP = \\frac{dW}{dt} = - \\frac{dU_{em}}{dt}- \\oint \\vec{S} \\cdot d\\vec{a}\r\n\\end{equation}\r\n\r\n\\subsection{circuits}\r\n\r\ncapacitance (equ 2.53, page 104, \\cite{GriffithED})\r\n\\begin{equation}\r\n  C \\equiv \\frac{Q}{V}\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n P=I^2 R\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n V=IR\r\n\\end{equation}\r\n\r\n\r\nPower and electrostatic potential ($P=I^2 R$ can be derived from $V=IR$) \\\\ \r\n(equation 7.7, page 290, \\cite{GriffithED})\r\n\\begin{equation}\r\n  Power = I V\r\n\t\\label{eq:power_current}\r\n\\end{equation}\r\n\r\ncircuit sum (equation 7.4, page 290, \\cite{GriffithED}) [resistor, capacitor, inductor]\r\n\\begin{equation}\r\nV = IR + \\frac{Q}{C} + L \\frac{dI}{dt}\r\n\\end{equation}\r\n \\begin{center}\r\n  \\includegraphics[scale=0.3]{pictures/V_R_C_L}\r\n \\end{center}\r\n\r\n\\begin{equation}\r\nI = \\frac{dQ}{dt}\r\n\\end{equation}\r\n\r\ncapacitance, A is the area, d is the seperation (equation 2.54, page 105 \\cite{GriffithED})\r\n\\begin{equation}\r\nC = \\frac{A \\epsilon_0}{d}\r\n\\end{equation}\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{relativity}\r\n\r\nLorentz factor, [$\\gamma > 1$](equation 12.6, page 486 \\cite{GriffithED})\r\n\\begin{equation}\r\n\\gamma = \\frac{1}{\\sqrt{1-(\\frac{v}{c})^2}}\r\n\\label{eq:gamma}\r\n\\end{equation}\r\n\\if\\qualifyingyear T\r\nGIVEN on 2008 A1, not given on 2001 A6\\\\ \r\n\\fi\r\n total relativistic energy for free particle (equation 12.55, page 551 \\cite{GriffithED})\r\n\\begin{equation}\r\n  E = \\sqrt{m^2 c^4 + p^2 c^2}\r\n\t\\label{eq:relativistic_energy}\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n  E = \\gamma m c^2\r\n\t\\label{eq:Einsteins_energy}\r\n\\end{equation}\r\n\r\n\r\nrelativistic momentum (equation 2-7, page 71 \\cite{TiplerMP}) \r\n\\if\\qualifyingyear T\r\n\\\\ \r\n2001 A5 d\r\n\\fi\r\n\\begin{equation}\r\n  p = \\gamma m v\r\n  \\label{eq:relativistic_momentum}\r\n\\end{equation}\r\n\r\n\\subsection{EM concepts}\r\n\\begin{itemize}\r\n\t\\item hollow charged conductors have no interior electric field (page 97, \\cite{GriffithED})\r\n\t\\item solid evenly-charged spheres have linearly increasing electric field inside;\r\n\toutside E field falls of as $\\frac{1}{r^2}$\r\n\t\\item potential of a charge falls off as $\\frac{1}{r}$\r\n\t\\item length contraction, time dilations (chapter 12, \\cite{GriffithED})\r\n\t\\item images above an $\\infty$ grounded conducting plane $\\rightarrow$ use method of images \r\n\t(section 3.2, see also problem 4.6 in \\cite{GriffithED})\r\n\t\\item changing electric field induces a magnetic field (page 323, \\cite{GriffithED})\r\n\t\\item magnetic forces do no work (page 207, \\cite{GriffithED})\r\n\t\\item $E_{tangential}$ is continuous, $E_{normal}$ is discontinuous\r\n\t\\item to solve Laplace's equation ($\\nabla^2 V = 0$) with V specified on the\r\n\tboundaries, use seperation of variables (Chapter 3, \\cite{GriffithED})\r\n\t\\item magnetic forces do no work (page 207, \\cite{GriffithED})\r\n\\end{itemize}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Thermodynamics}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nmost generally, specific heat is \r\n\\begin{equation}\r\nC_x = \\frac{dQ}{dT}|_x\r\n\\end{equation}\r\nwhere x is the variable that is held constant. \r\n\\begin{equation}\r\n \\frac{1}{T} = \\pfrac{S}{E} |_v\r\n\\end{equation}\r\nThen from equation  $5 \\cdot 6 \\cdot 1$ page 164; page 153; \\cite{ReifThermo}\r\n\\begin{equation}\r\nT \\cdot dS = dE + p \\cdot dV\r\n\\label{eq:TdS}\r\n\\end{equation}\r\nsolve for $dE$, which is $dQ$, and hold V constant to get \\\\ \r\nspecific heat, constant volume; \r\n\\if\\qualifyingyear T\r\ngiven on 2002 A6\r\n\\fi\r\n\\begin{equation}\r\nC_V = \\pfrac{E}{T}|_v\r\n\\end{equation}\r\nusing the definition of enthalpy, add $d(pV)$ to Eq.~\\ref{eq:TdS} to get\r\n\\begin{equation}\r\ndH = T \\cdot dS + V \\cdot dp\r\n\\end{equation}\r\nand hold pressure p constant to get \\\\ \r\nspecific heat, constant pressure\r\n\\begin{equation}\r\nC_p = \\pfrac{H}{T}|_p\r\n\\end{equation}\r\n\\begin{equation}\r\n C_P = C_V + N K_{Boltzmann} = C_V + \\nu R\r\n\\end{equation}\r\n$C_P > C_V$ always\r\n\\begin{equation}\r\n pV = \\nu R T\r\n\\end{equation}\r\nwhere $\\nu$ is the number of moles, $\\frac{N}{N_{Av}}$ and $R=N_{Av} K_{Boltzmann}$.\r\n\r\nequations $3 \\cdot 3 \\cdot 12$; $3 \\cdot 11 \\cdot 6$, page 123; \\cite{ReifThermo}\r\n\\if\\qualifyingyear T\r\n \\\\ \r\ngiven on 2002 B6, 2006 A6\r\n\\fi\r\n\\begin{equation}\r\nS = k \\ln \\Omega\r\n\\end{equation}\r\n\r\nideal gas; relating average pressure, Volume, Temperature (equations  $3 \\cdot 12 \\cdot 8$ page 125; $7 \\cdot 2 \\cdot 8$ page 241; \\cite{ReifThermo})\r\n\\begin{equation}\r\n\\overline{p} V = N k_{Boltzmann} T\r\n\\end{equation}\r\n$pV = nRT$ \\\\ \r\nideal gas; relating to average Kinetic energy\r\n\\begin{equation}\r\n\\overline{p} V = \\frac{2}{3} N \\overline{K}\r\n\\end{equation}\r\n\r\nwhere number density $ n = \\frac{N}{V}$ is number of molecules per volume. \r\n\r\nmean kinetic energy per particle; applies to fluids in closed systems\r\n\\begin{equation}\r\n\\overline{K} = \\frac{3}{2} k_{boltzmann} T\r\n\\end{equation}\r\n\r\npartition function for a single particle (equation $6 \\cdot 5 \\cdot 3$ page 213; \\cite{ReifThermo}) \r\n\\if\\qualifyingyear T\r\n\\\\ \r\ngiven 2002 A6\r\n\\fi\r\n\\begin{equation}\r\nz \\equiv \\sum_r^\\infty e^{-\\beta E_r}\r\n\\end{equation}\r\nand total partition function $Z = z^{3N}$ \\\\ \r\npartition function and energy (equation $6 \\cdot 5 \\cdot 4$ page 213; \\cite{ReifThermo})\r\n\\if\\qualifyingyear T\r\n\\\\ \r\ngiven 2002 A6\r\n\\fi\r\n\\begin{equation}\r\nE = - \\frac{\\partial (\\ln Z)}{\\partial \\beta} |_V\r\n\\end{equation}\r\n\r\nFermi-Dirac distribution  (equation $9 \\cdot 3 \\cdot 14$ page 341; \\cite{ReifThermo}) \\\\ \r\nmean occupation number; number of particles with energy $\\epsilon_s$\r\n\\begin{equation}\r\nn = \\frac{1}{e^{\\alpha + \\beta \\epsilon_s} +1}\r\n\\end{equation}\r\n\r\nBose-Einstein distribution  (equation $9 \\cdot 3 \\cdot 22$ page 342; \\cite{ReifThermo})\r\n\\begin{equation}\r\nn = \\frac{1}{e^{\\alpha + \\beta \\epsilon_s}-1} \r\n\\end{equation}\r\nsince when the exponent is 0, then $n \\rightarrow \\infty$, so all the particles form a BEC.\\\\ \r\nMaxwell-Boltzmann distribution  (equation $9 \\cdot 4 \\cdot 7$ page 345; \\cite{ReifThermo})\r\n(see also page 133, \\cite{TiplerMP})\r\n\\begin{equation}\r\nn = N \\frac{ e^{-\\beta \\epsilon_s }}{ \\sum_r e^{-\\beta \\epsilon_r} }\r\n\\end{equation}\r\n\r\n\\subsection{Thermodynamics concepts}\r\n\\begin{itemize}\r\n\t\\item good review of basics on page 122 of \\cite{ReifThermo}, including the laws \r\n\t\\item second law: $\\Delta S \\geq 0$\r\n\t\\item classical equipartition theorm: each squared term of the Hamiltonian\r\n\thas $E=\\frac{1}{2}k_b T$ \\\\ (equation $7 \\cdot 5 \\cdot 7$ page 249; \\cite{ReifThermo})\r\n\t\\item entropy is maximum for a closed, isolated system at equilibrium\r\n\t\\item all states are equally probable. Equilibrium is the most probable configuration -- the largest number of states sharing the same configuration\r\n\\end{itemize}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Classical Mechanics}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nthe ``basics:'' \\\\ \r\nForce and potential energy, (page 20, \\cite{GoldsteinCM})\r\n\\begin{equation}\r\n\\vec{F} = - \\vec{\\nabla} V\r\n\\end{equation}\r\n\\begin{equation}\r\n T = \\frac{1}{2} I \\omega^2\r\n\\end{equation}\r\n\r\nfor circular motion, tangential velocity is\r\n\\begin{equation}\r\nv = \\omega r\r\n\\end{equation}\r\nand centripital acceleration (also circular motion)\r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\n\\frac{v^2}{R}\r\n\\end{equation}\r\n\r\nAngular momentum $\\vec{L}$\r\n\\begin{equation}\r\n\\vec{L} = \\vec{r} \\times \\vec{p}\r\n\\end{equation}\r\n\r\nTorque $\\vec{N}$\r\n\\begin{equation}\r\n \\vec{N} = \\vec{r}\\times \\vec{F} = \\pfrac{\\vec{L}}{t}\r\n\\end{equation}\r\n\r\nForce $F$, potential $V$, momentum $p$\r\n\\begin{equation}\r\n \\vec{F} = -\\vec{\\nabla} V = \\pfrac{p}{t}\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\begin{gathered}\r\nF_{spring} = -k \\ x \\\\ \r\nV_{spring} = \\frac{1}{2}k \\ x^2\r\n\\end{gathered}\r\n\\end{equation}\r\n\r\n\\subsection{Lagrange's Equations of Motion}\r\n\r\nkinetic energy (cartesian, cylindrical)\r\n\\begin{equation}\r\nT = \\frac{1}{2} m v^2 = \\frac{1}{2} m ( \\dot{x}^2 + \\dot{y}^2 + \\dot{z}^2) = \r\n\\frac{1}{2} m (\\dot{r}^2 + r^2 \\dot{\\theta}^2 + \\dot{z}^2)\r\n\\end{equation}\r\n\r\nLagrangian\r\n$L=L\\left( q_{j} ,\\dot{q} _{j} ,t\\right) =T-U$ (equation 1-56, page 20 \\cite{GoldsteinCM}). \\\\ \r\n(equation 1-57, page 21 \\cite{GoldsteinCM})\r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\n\\frac{d}{dt} \\left( \\frac{\\partial L}{\\partial \\dot{q} _{j} } \\right) -\\frac{\\partial L}{\\partial q_{j} } = 0\r\n\\end{equation}\r\n\r\n\\subsection{Hamilton's Equations of Motion}\r\n$H=H\\left( q_{j} ,p_{j} ,t\\right) $ \\\\ \r\nusually $ H = T+V$ \\\\ \r\n(equation 8-8, page 341 \\cite{GoldsteinCM})\r\n\\begin{equation}\r\nH=\\sum\\limits_{j}p_{j}  \\dot{q} _{j} -L\r\n\\end{equation}\r\n\r\nOnce Lagrangian is found, get canonical momentum\r\n\\begin{equation}\r\np_j \\equiv \\frac{\\partial L}{\\partial \\dot{q}_j }\r\n\\label{eq:canonical_momentum}\r\n\\end{equation}\r\n\r\nand solve for $\\dot{q}_j$ for later\r\n\r\n\\begin{equation}\r\nh = \\left( \\sum \\dot{q_j} \\frac{\\partial L}{\\partial \\dot{q} _{j} } \\right) - L\r\n\\end{equation}\r\n\r\nthen substitue in $\\dot{q}$ to get H. \\\\ \r\nFinally, get Hamilton Equations of motion by \\\\ \r\n(equation 8-12, page 342 \\cite{GoldsteinCM})\r\n\\begin{equation}\r\n\\begin{gathered}\r\n\\dot{q} _{j} =\\frac{\\partial H}{\\partial p_{j} } \\\\ \r\n\\dot{p} _{j} = - \\left( \\frac{\\partial H}{\\partial q_{j} } \\right) \r\n\\end{gathered}\r\n\\end{equation}\r\n\r\nthen integrate to get $q$ and $p$\r\n\r\n\\subsection{2-body central force}\r\nstandard orbit is Counter Clock-Wise (CCW). \\\\ \r\nGiven the Lagrangian in polar coordinates, one derives the canonical angular momentum \\\\ \r\n(equation 3-8, page 73 \\cite{GoldsteinCM}) (see eq \\ref{eq:canonical_momentum})\r\n\\begin{equation}\r\nl = \\mu r^2 \\dot{\\theta}\r\n\\end{equation}\r\nfor perturbed orbits, $ \\tau > \\tau_c$ implies CCW (positive $\\Delta\\theta$) motion (forward orbital motion)\r\n\\begin{equation}\r\n\\Delta \\theta = \\frac{l}{m r^2}(\\tau - \\tau_c)\r\n\\end{equation}\r\n\r\ncircular orbit condition (equation 3-12, page 74  \\cite{GoldsteinCM})\r\n\\begin{equation}\r\nf^{effective}(r_c) = 0 = f(r_c) + \\frac{l^2}{\\mu r_c^3}\r\n\\end{equation}\r\nwhere for the kepler problem $f(r) = -\\frac{k}{r^2}$\r\n\r\nsmall oscillations of orbit\r\n\\if\\qualifyingyear T\r\n(2009 A)\r\n\\fi\r\n\\begin{equation}\r\nr = r_c + \\epsilon\r\n\\end{equation}\r\n\r\nnot included: small oscillation (chapter 6 of  \\cite{GoldsteinCM}).\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Quantum}\r\n\r\nexpectation value, average, mean\r\n\\begin{equation}\r\n\\langle A \\rangle = \\langle \\psi | A | \\psi \\rangle = \\int_{-\\infty}^{\\infty} \\psi^* A \\psi \\ dx\r\n\\end{equation}\r\n\r\nprobability amplitude ( \\cite{LiboffQM} page 118 calls this the \r\nadd-mixture coefficient $|C_n|^2$)\r\n\\begin{equation}\r\n| \\psi | ^2 = \\langle \\psi | \\psi \\rangle = \\int \\langle \\psi | x \\rangle \\langle x | \\psi \\rangle dx\r\n\\end{equation}\r\n\r\nEhrenfest Theorem\r\n\\begin{equation}\r\n \\frac{d}{dt} \\langle a\\rangle = \\left\\langle \\pfrac{a}{t} \\right\\rangle + i \\hbar \\left\\langle [a,H] \\right\\rangle\r\n\\end{equation}\r\n\r\nand for sudden change, from the ground state (1) to the first excited state (2), probability of transition is\r\n\\begin{equation}\r\n\\left| \\langle \\phi_2 | \\psi_1 \\rangle \\right| ^2\r\n\\end{equation}\r\n\r\nuncertianty\r\n\\begin{equation}\r\n\\Delta x = \\sqrt{ \\langle x^2 \\rangle - \\langle x \\rangle ^2 }\r\n\\end{equation}\r\n\r\ncommutator (equation 7.24, page 194 \\cite{LiboffQM})\r\n\\begin{equation}\r\n\\left[ x,p\\right] =i\\hbar \r\n\\end{equation}\r\n\r\n\\if\\qualifyingyear T\r\nGIVEN on 2005, A5: \r\n\\fi\r\nfrequency \r\n\\begin{equation}\r\n  \\omega = \\sqrt{\\frac{k}{m}}\r\n\t\\label{eq:frequency_wavenum}\r\n\\end{equation}\r\n\r\ntime evolution (equ 2.490, page 98, \\cite{ParrisQM})\r\n\\begin{equation}\r\n  |\\Psi (t)\\rangle = e^{-i \\frac{H}{\\hbar} t} |\\Psi_0\\rangle\r\n%%%\\label{eq:frequency_wavenum}\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n  |\\Psi (t)\\rangle = \\sum_n e^{-i \\frac{E_n}{\\hbar} t} \\Psi_n(0) |n\\rangle\r\n%%%\\label{eq:frequency_wavenum}\r\n\\end{equation}\r\n\r\n\r\n%\\begin{comment}\r\n%%% second semester graduate quantum\r\ntotal spin number\r\n\\begin{equation}\r\nm_{total} = m_1 + m_2\r\n\\end{equation}\r\nwhere $m = -j,\\ldots,j$\r\n\r\ntotal momentum\r\n\\begin{equation}\r\ns_{total} = (s_1 + s_2),(s_1 + s_2 -1),\\ldots,| s_1 - s_2 |\r\n\\end{equation}\r\nwhere $s_{total} \\geq 0$\r\n%\\end{comment}\r\n\r\n\\subsection{energy eigenvalue equation}\r\n\r\nIn position representation, derive the energy eigenvalue equation from\r\n\\begin{equation}\r\n  \\vec{K} = -i \\vec{\\nabla}\r\n\t\\label{eq:wavenumberinpositionspace}\r\n\\end{equation}\r\nin position representation, (equation 130)\r\n\\begin{equation}\r\n  \\vec{P} = \\hbar \\vec{K}\r\n\t\\label{eq:momentumwavenumber}\r\n\\end{equation}\r\n\r\nthus momentum (page 14, \\cite{ParrisQM}) (equation 3.2, page 69 \\cite{LiboffQM}\r\n\\begin{equation}\r\n  \\vec{P} = - i \\hbar \\vec{\\nabla}\r\n\t\\label{eq:momentumtopositionspace}\r\n\\end{equation}\r\nFrom eq \\ref{eq:momentumtopositionspace}, knowing the Hamiltonian is $H = T+V$\r\n\\begin{equation}\r\n  \\hat{H} = \\frac{p^2}{2 m} + V\r\n\t\\label{eq:hamiltonian_energy}\r\n\\end{equation}\r\nThen plug \\ref{eq:momentumtopositionspace} into \\ref{eq:hamiltonian_energy} and use \r\n\\begin{equation}\r\nH \\psi = E \\psi\r\n\\end{equation}\r\n to get the energy eigenvalue equation,\r\n\\begin{equation}\r\n  \\hat{H} = \\frac{-\\hbar ^2 \\nabla ^2}{2 m}\\Psi + V\\Psi = E \\Psi\r\n\t\\label{eq:energy_eigenvalue}\r\n\\end{equation}\r\n\r\nSchrodinger Equation\r\n\\begin{equation}\r\n  i \\hbar \\frac{d}{dt}|\\Psi \\rangle = H |\\Psi \\rangle\r\n\t\\label{eq:schrodinger_equ}\r\n\\end{equation}\r\n\r\nequation 9.19, page 358 \\cite{LiboffQM}\r\n\\begin{equation}\r\n\\begin{gathered}\r\nJ_+ = J_x + i J_y \\\\ \r\nJ_- = J_x - i J_y\r\n\\end{gathered}\r\n\\end{equation}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{harmonic oscillator}\r\n\r\n\\if\\qualifyingyear T\r\nGIVEN on 2005, A5: \r\n\\fi\r\nSHO energy levels\r\n\\begin{equation}\r\n  E_n = (n+\\frac{1}{2})\\hbar \\omega\r\n\t\\label{eq:SHO_energy}\r\n\\end{equation}\r\n\r\nharmonic oscillator Hamiltonian (equation 3.2, page 103  \\cite{ParrisQM})\r\n\\begin{equation}\r\nH = \\frac{p^2}{2 m}+ \\frac{1}{2} m \\omega^2 x^2\r\n\\label{eq:H_p_x}\r\n\\end{equation}\r\nfactor out $\\frac{\\hbar \\omega}{2}$ to derive harmonic oscillator Hamiltonian in dimensionless operators \\\\ \r\nNote: $\\hat{P}$ and $\\hat{Q}$ are dimensionless, whereas $\\hat{p}$ and $\\hat{q}$ are dimensional\r\n(equation 3.18, page 105 \\cite{ParrisQM})\r\n\\begin{equation}\r\nH = \\frac{\\hbar \\omega}{2} (\\hat{P}^2 + \\hat{Q}^2)\r\n\\label{eq:H_p_q}\r\n\\end{equation}\r\nby comparing \\ref{eq:H_p_q} and \\ref{eq:H_p_x} the relationship between\r\ndimensionless q,p and dimensional x,p can be found.\r\n\r\nin terms of energy operators, harmonic oscillator Hamiltonian (equation 3.34, page 107  \\cite{ParrisQM})\r\n\\begin{equation}\r\nH = \\hbar \\omega (N+ \\frac{1}{2})\r\n\\end{equation}\r\nwhere $N = a^+ a$ (equation 3.33)\r\n\r\n\\if\\qualifyingyear T\r\nGIVEN on 2006 A4, 1998 A3, 2009 A1. \r\n\\fi \r\nLowering, raising operators\r\n\\begin{equation}\r\n\\begin{gathered}\r\n a|n\\rangle =\\sqrt{n}|n-1 \\rangle \\\\ \r\n a^+|n\\rangle =\\sqrt{n+1}|n+1 \\rangle \r\n  \\label{eq:raising_lowering}\r\n\\end{gathered}\r\n\\end{equation}\r\n\r\ndimensionless position, momentum (equation 3.29, page 106 \\cite{ParrisQM})\r\n\\begin{equation}\r\n\\begin{gathered}\r\n\\hat{q} = \\frac{1}{\\sqrt{2}} (\\hat{a}^+ + \\hat{a}) \\\\ \r\n\\hat{p} = \\frac{i}{\\sqrt{2}} (\\hat{a}^+ - \\hat{a})\r\n\\label{eq:q_p_dimensionless}\r\n\\end{gathered}\r\n\\end{equation}\r\n\r\n\\subsection{time independent non-degenerate perturbation theory}\r\nperturbation theory says the exact solution can be approximated as\r\n\\begin{equation}\r\nE \\cong E^{(0)} + E^{(1)} + E^{(2)} + \\ldots\r\n\\end{equation}\r\n\r\n(eq. \\ref{eq:first_order_correction_to_energy} through \\ref{eq:second_order_correction_to_energy} \r\n\\if\\qualifyingyear T\r\ngiven on 1998 A3, not given on 2002 A2) \\\\ \r\n\\fi\r\nfirst order correction to energy (equ 5.41, page 138, \\cite{ParrisQM}), (page 685 \\cite{LiboffQM})\r\n\\begin{equation}\r\nE^{(1)}_n = \\langle n^{(0)} |V|n^{(0)}\\rangle\r\n\\label{eq:first_order_correction_to_energy}\r\n\\end{equation}\r\n\r\nfirst order correction to state (equ 5.42, page 138, \\cite{ParrisQM}), (equation 13.8, page 685 \\cite{LiboffQM})\r\n\\begin{equation}\r\n|n^{(1)}\\rangle = \\sum_{m \\neq n} | m^{(0)}\\rangle \\langle m^{(0)} |n^{(1)}\\rangle\r\n\\end{equation}\r\nwhere (equation 5.43, page 138, \\cite{ParrisQM})\r\n\\begin{equation}\r\n\\langle m^{(0)} |n^{(1)}\\rangle = -\\frac{\\langle m^{(0)}|V|n^{(0)}\\rangle}{E_m^{(0)} - E_n^{(0)}}\r\n\\end{equation}\r\nwhere $m\\neq n$\r\n\r\nsecond order correction to energy \r\n\\begin{equation}\r\nE_n^{(2)} = \\sum_{m\\neq n} \\frac{ | \\langle m^{(0)}|V|n^{(0)}\\rangle |^2 }{E_m^{(0)} - E_n^{(0)}}\r\n\\label{eq:second_order_correction_to_energy}\r\n\\end{equation}\r\n\r\n\\subsection{time-independent degenerate perturbation theory}\r\ncharacteristic equation\r\n\\begin{equation}\r\ndet(H - \\lambda I) = 0\r\n\\label{eq:characteristic_equation}\r\n\\end{equation}\r\nwhere $\\lambda$ are eigenvalues\r\n\r\n\\subsection{particle in a box}\r\ninfinite square well of size L, $0 \\leq x \\leq L$ (equation 4.15, page 93 \\cite{LiboffQM})\r\n\\begin{equation}\r\n\\psi_n(x) = \\sqrt{\\frac{2}{L}} sin \\left( \\frac{n \\pi x}{L} \\right)\r\n\\label{eq:particle_in_box_wavefuction}\r\n\\end{equation}\r\nwhere $n = 1,2,3, \\ldots$ (equation 4.14, page 93 \\cite{LiboffQM})\r\n\\begin{equation}\r\nE_n = \\frac{n^2 \\pi^2 \\hbar^2}{2 m L^2}\r\n\\label{eq:particle_in_box_energy}\r\n\\end{equation}\r\nWhereas if $\\frac{-L}{2} \\leq x \\leq \\frac{L}{2}$\r\n\\begin{equation}\r\n\\begin{gathered}\r\n\\psi_m(x) = \\sqrt{\\frac{2}{L}} cos \\left( \\frac{m \\pi x}{L} \\right) \\\\ \r\n\\psi_n(x) = \\sqrt{\\frac{2}{L}} sin \\left( \\frac{n \\pi x}{L} \\right)\r\n\\end{gathered}\r\n\\end{equation}\r\nwhere $m = 1,3, \\ldots$ and $n = 2,4, \\ldots$\\\\ \r\nthis can also be derived by shifting eq. \\ref{eq:particle_in_box_wavefuction} by $\\frac{L}{2}$.\r\n\r\n\\subsection{free particle}\r\nfor a free particle, assume $V=0$, then $H = \\frac{p^2}{2m}$. The wave function is\r\n\\begin{equation}\r\n\\phi_k(r) = \\frac{1}{(2 \\pi)^{3/2}} e^{i \\vec{k} \\cdot \\vec{r}}\r\n\\label{eq:free_particle_wave}\r\n\\end{equation}\r\nand the energy is (equation 3.19, page 71 \\cite{LiboffQM})\r\n\\begin{equation}\r\nE_k = \\frac{\\hbar^2 k^2}{2m}\r\n\\label{eq:energy_free_particle_wave}\r\n\\end{equation}\r\nand since $E = \\hbar \\omega$, then\r\n\\begin{equation}\r\n\\omega_k = \\frac{\\hbar k^2}{2m}\r\n\\end{equation}\r\ntime dependent wave function\r\n\\begin{equation}\r\n\\psi(\\vec{r},t) = \\langle \\vec{r} | \\psi(t) \\rangle = \\langle \\vec{r} | \\int d^3 k \\ e^{-i \\omega_k t} \\psi(\\vec{k},0) | \\vec{k} \\rangle\r\n\\label{eq:time_dependent_free_particle_wave_function}\r\n\\end{equation}\r\n\r\n\\subsection{quantum concepts}\r\n\\begin{itemize}\r\n\t\\item the same spectrum (eigenvalues) occur in any basis\r\n\t\\item Q: when is perturbation valid? A: when the perturbation term is \r\n\tmuch smaller than the unperturbed term\r\n\t\\item a $\\delta(x)$ perturbation in the middle of an $\\infty$ square well\r\n\thas no effect on even states\r\n\\end{itemize}\r\n\r\n\\begin{tabular}{l|l}\r\nBosons                &     Fermions \\\\\\hline\r\nzero or integer spin  &  half-integer spin\\\\\r\nsymmetric wave functions & anti-symmetric wave functions\\\\\r\nExample: photons         & Example: electrons, proton, neutron\\\\\r\nmore than one particle may occupy the same quantum state & Pauli exclusion principle: one particle per state\\\\\r\nBose-Einstien statistics & Fermi-Dirac statistics\\\\\r\n\\end{tabular}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{modern}\r\n\r\n\\begin{equation}\r\n\\frac{h}{2 \\pi} = \\hbar\r\n\\end{equation}\r\n\r\nperiod and frequency\r\n\\begin{equation}\r\nT = \\frac{1}{f}\r\n\\end{equation}\r\n\r\nBragg condition (equation 3-38, page 144 \\cite{TiplerMP}; equ 1 page 25 {KittelSS})\r\n\\begin{equation}\r\n2 d \\ sin \\theta  = m \\lambda\r\n\\end{equation}\r\nwhere m is an integer.\r\n\r\nangular frequency (equation 5-13a, page 211 \\cite{TiplerMP})\r\n\\begin{equation}\r\n\\omega = 2 \\pi f\r\n\\end{equation}\r\n\r\nde~Broglie relations (equation 5-1, page 198 \\cite{TiplerMP})\r\n\\begin{equation}\r\nE = h f\r\n\\end{equation}\r\n\r\nde Broglie wavelength (equation 5-2, page 198  \\cite{TiplerMP}) (equation 3.10, page 70  \\cite{LiboffQM})\r\n\\begin{equation}\r\n\\lambda = \\frac{h}{p}\r\n\\end{equation}\r\n\r\nfrequency\r\n\\begin{equation}\r\nf = \\frac{c}{\\lambda}\r\n\\end{equation}\r\n\r\n(page 199,  \\cite{TiplerMP})\r\n\\begin{equation}\r\nE = pc = hf = \\frac{hc}{\\lambda}\r\n\\end{equation}\r\n\r\nwavenumber (equation 5-13b, page 211  \\cite{TiplerMP}) (equation 3.9, page 70  \\cite{LiboffQM})\r\n\\begin{equation}\r\nk = \\frac{2 \\pi}{\\lambda}\r\n\\end{equation}\r\n\r\nphase velocity (equation 5-14, page 211 \\cite{TiplerMP})\r\n\\begin{equation}\r\nv_{phase} = f \\lambda\r\n\\end{equation}\r\n\r\ngroup velocity (equation 5-22, page 211 \\cite{TiplerMP}) (equation 3.62, page 83 \\cite{LiboffQM})\r\n\\begin{equation}\r\nv_{group} = \\frac{d\\omega}{dk}\r\n\\end{equation}\r\n\r\nenergy and frequency (equation 5-24, page 218  \\cite{TiplerMP})\r\n\\begin{equation}\r\nE = \\hbar \\omega\r\n\\end{equation}\r\n\r\nmomentum (equation 5-25, page 218  \\cite{TiplerMP})\r\n\\begin{equation}\r\np = \\hbar k\r\n\\end{equation}\r\n\r\nuncertainty (equation 5-29, page 223  \\cite{TiplerMP}) \r\n(problem 5.28, page 143 \\cite{LiboffQM})\r\n\\begin{equation}\r\n\\begin{gathered}\r\n\\Delta x \\Delta p \\geq \\frac{\\hbar}{2} \\\\ \r\n\\Delta E \\Delta t \\geq \\frac{\\hbar}{2} \r\n\\end{gathered}\r\n\\end{equation}\r\n\r\nwork function: energy need to remove an electron\r\n(equation 3-37, page 139 \\cite{TiplerMP}) \r\n\\if\\qualifyingyear T\r\n(1999 A4b)\r\n\\fi\r\n\\begin{equation}\r\n\\phi = h f_{threshold} = \\frac{h c}{\\lambda_{threshold}}\r\n\\end{equation}\r\n\r\n\\subsection{Modern concepts}\r\n\\begin{itemize}\r\n\\item The mass of a bound system is greater than that of the individual\r\nconstituent particles due to contribution of binding energy. For\r\ninstance, $E_{hydrogen} = 13.6 eV$ is the binding energy for\r\nhydrogen. (see page 86, \\cite{TiplerMP})\r\n\\item 4 forces in order of decreasing strength and [force carrier particle] \r\n\\if\\qualifyingyear T\r\n(2007 B6)\r\n\\fi\r\n%%% http://en.wikipedia.org/wiki/Fundamental_interaction#Overview\r\n%%% http://hyperphysics.phy-astr.gsu.edu/hbase/forces/funfor.html\r\n\\begin{enumerate}\r\n\t\\item strong [gluons]\r\n\t\\item electromagnetic [photon]\r\n\t\\item weak [W and Z bosons]\r\n\t\\item gravity [graviton]\r\n\\end{enumerate}\r\n\\end{itemize}\r\n\r\n\\subsection{constants}\r\n\\begin{itemize}\r\n\\item radius of a simple atom is $\\approx .5 \\dot{A}$ (half an angstrom).\r\n(Bohr radius, page 173 \\cite{TiplerMP})\r\n\\item $hc = 1240 \\ eV \\ nm$\r\n\\end{itemize}\r\n\r\n%\\begin{comment}\r\n\\section{optics}\r\n\r\nsnell's law\r\n\\begin{equation}\r\nn_1 sin(\\theta_1)=n_2 sin(\\theta_2)\r\n\\end{equation}\r\n%\\end{comment}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\section{Symbol notations}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nSee page 631-642 of \\cite{ReifThermo}\r\n\r\n$C_v \\equiv$ specific heat for constant volume\r\n\r\n$k_b \\equiv$ Boltzmann constant\r\n\r\n$\\vec{E} \\equiv$ electric field\r\n\r\n$\\vec{B} \\equiv$ magnetic field\r\n\r\n$\\vec{D} \\equiv$ electric displacement, equ 4.21, page 175 \\cite{GriffithED}\r\n\r\n$\\vec{N} \\equiv$ torque\r\n\r\n$W \\equiv$ work\r\n\r\n$\\vec{v} \\equiv$ velocity\r\n\r\n$V \\equiv$ electrostatic potential [Volts]\r\n\r\n$V \\equiv$ volume\r\n\r\n$U \\equiv$ potential energy [Volts]\r\n\r\n$\\vec{P} \\equiv$ polarization, page 166 \\cite{GriffithED}\r\n\r\n$I \\equiv$ current [Amps]\r\n\r\n$\\vec{F} \\equiv$ force [Newtons, $\\frac{kg \\cdot m}{s^2}$]\r\n\r\n$E \\equiv$ energy\r\n\r\n$T \\equiv$ kinetic energy\r\n\r\n$T \\equiv$ temperature\r\n\r\n$L \\equiv$ lagrangian\r\n\r\n$L \\equiv$ capacitance\r\n\r\n$\\vec{L} \\equiv$ classical (orbital) angular momentum\r\n\r\n$l \\equiv$ quantum (orbital) angular momentum\r\n\r\n$\\vec{p} \\equiv$ linear momentum\r\n\r\n$\\omega \\equiv$ angular frequency\r\n\r\n$z \\equiv$ single particle partition function\r\n\r\n$Z \\equiv$ total partition function\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{thebibliography}{99}\r\n\r\n\\bibitem{GriffithED}\r\nGriffith \\textit{Intro to Electrodynamics}, (1999)\r\n\r\n\\bibitem{JacksonED}\r\nJackson \\textit{Classical Electrodynamics}, (1999)\r\n\r\n\\bibitem{GoldsteinCM}\r\nGoldstein \\textit{Classical Mechanics}, (1980) (second edition)\\\\ \r\nAvailable from Aaron\r\n\r\n\\bibitem{ReifThermo}\r\nReif \\textit{Fundamentals of statistical and thermal physics}, (1965)\r\n\r\n\\bibitem{KittelSS}\r\nKittel \\textit{Solit State, Eigth edition}, (19)\r\n\r\n\\bibitem{ParrisQM}\r\nParris's book on \\textit{Quantum mechanics}, (2008) \\\\ \r\n\\htmladdnormallink{463 course page}{http://physics.mst.edu/classes/class_463notes.html}\r\n\r\n\\bibitem{LiboffQM}\r\nLiboff \\textit{Introduction to Quantum mechanics}, (2003) Fourth edition\r\n\r\n\\bibitem{MarionCM}\r\nMarion \\textit{Classical Dynamics of Particles and systems}, (1970) Second edition. \\\\ \r\nAvailable from Prof Waddill, Elizabeth\r\n\r\n\\bibitem{TiplerMP}\r\nTipler, Llewellyn \\textit{Modern Physics}, (1999)\r\n\r\n\\end{thebibliography}\r\n\r\n\\end{document}", "meta": {"hexsha": "339dad5cece980e15f46f877f97c46e8b1b7c4e5", "size": 40398, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "equations_template.tex", "max_stars_repo_name": "bhpayne/physics_equations_reference", "max_stars_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-09-05T00:38:21.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-05T00:38:21.000Z", "max_issues_repo_path": "equations_template.tex", "max_issues_repo_name": "bhpayne/physics_equations_reference", "max_issues_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "equations_template.tex", "max_forks_repo_name": "bhpayne/physics_equations_reference", "max_forks_repo_head_hexsha": "4dbd489d7085d0097b9442c1f66aad56ed9b09e9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2380239521, "max_line_length": 198, "alphanum_fraction": 0.6508738056, "num_tokens": 14181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7690802317779601, "lm_q1q2_score": 0.42346124030449467}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{January 16, 2015}\n\\maketitle\n\\section*{error fixup}\nneighborhood is $N_G(V_i)=\\{V_j|(v_i,v_j)\\in E(G)\\}$\n\\section*{degree sequences}\nthese will be ascending, book is descending\n\n\\subsubsection*{definitionn}\nif $G$ is finite with $V(G)=\\{v_1,\\dots,v_n\\}$ such that $d_i=\\deg(v_i)\\le \\deg(v_j)$ for $i\\le j$ then $(d_1,\\dots,d_n)$ is the degree sequence of $G$.\n\n\\begin{tikzpicture}[main_node/.style={circle,fill=blue!60,minimum size=1em,inner sep=3pt]}]\n    \\node[main_node] (1) at (-1,1) {1};\n    \\node[main_node] (2) at (-1, -1)  {2};\n    \\node[main_node] (3) at (1, -1) {3};\n    \\node[main_node] (4) at (1, 1) {4};\n    \\draw (1) -- (2) -- (3) -- (4) -- (1) -- (3) -- (2) -- (4);\n\\end{tikzpicture}$=k_4$\n\n$d=(3,3,3,3)$\nthree regular graph\n\n\\begin{tikzpicture}[main_node/.style={circle,fill=blue!60,minimum size=1em,inner sep=3pt]}]\n    \\node[main_node] (1) at (-1,1) {};\n    \\node[main_node] (2) at (-1, -1)  {};\n    \\node[main_node] (3) at (1, -1) {};\n    \\node[main_node] (4) at (1, 1) {};\n    \\node[main_node] (5) at (0, 2) {};\n    \\node[main_node] (6) at (0, -2) {};\n    \\draw (1) -- (2) -- (3) -- (4) -- (1) -- (2) -- (4) -- (5) -- (1);\n    \\draw (5) -- (6) -- (2) ;\n\\end{tikzpicture}\n\n$d=(2,3,3,3,3,4)$\n\n\\section*{Havel, Hakimi thm}\nif $(d_1,\\dots,d_n)$ is a non decreasing sequence with $d_n\\ge 1$ (avoid the empty graph) it is a degree sequence iff $(d_1,\\dots,d_{n-d_n-1},d_{n-d_n}-1,\\dots,d_{n-1}-1)$ is a degree sequence\n\\subsubsection*{example}\ngiven \n\n\\begin{tikzpicture}[main_node/.style={circle,fill=blue!60,minimum size=1em,inner sep=3pt]}]\n    \\node[main_node] (1) at (-1,1) {};\n    \\node[main_node] (2) at (-1, -1)  {};\n    \\node[main_node] (3) at (1, -1) {};\n    \\node[main_node] (4) at (1, 1) {};\n    \\node[main_node] (5) at (0, 0) {};\n    \\node[main_node] (6) at (0, 2) {};\n\n    \\draw (1) -- (4) -- (5) -- (2) -- (3) -- (5) -- (1) -- (6) -- (4);\n\\end{tikzpicture}\n\n$\\to(2,2,2,3,3,4)\\to(2,1,1,2,2)$\n\n\\begin{tikzpicture}[main_node/.style={circle,fill=blue!60,minimum size=1em,inner sep=3pt]}]\n    \\node[main_node] (1) at (-1,1) {};\n    \\node[main_node] (2) at (-1, -1)  {};\n    \\node[main_node] (3) at (1, -1) {};\n    \\node[main_node] (4) at (1, 1) {};\n    %\\node[main_node] (5) at (0, 0) {};\n    \\node[main_node] (6) at (0, 2) {};\n\n    \\draw (2) -- (3);\n    \\draw (1) -- (6) -- (4) -- (1);\n\\end{tikzpicture}\n\n$(1,1,2,2,2)$\n\n\\subsection*{proof}\n\n$\\Rightarrow$ careful vertex deletion\n\n$\\Leftarrow$ let G have a degree sequeence $*$ then $\\deg(v_i)=\\begin{cases}d_i&i=1,\\dots,n-d_n-1\\\\d_i-1&i=n-d_n,\\dots,n-1\\end{cases}$\n\nadd a vertex to $G$ and add edges between the new vertex and all vertices of degree $d_i-1$\n\nthe degree of the new vertex is $n-1-(n-d_n)+1=d_n$\n\nthe new graph has degree sequence $(d_1,\\dots,d_n)\\Box$\n\n\\subsection*{claim}\nhavel-hakimi can be used to verify, refute the degree sequenceness of any nondecreasing sequence of integers\n\ni.e. we can say rather quickly that (polynomial time) if $(2,3,3,5,5,5,5,5,5,6)$ is graphical \n\n$n=10, 10-6-1=3, d_3=3, n-d_n=4,d_4-1=4,d_9-1=5$\n$(2,3,3,4,4,4,4,4,4)\\dots\\to\\dots (1,1,2,2,2,2)$\n\nquestion, if two degree sequences are the same, are the graphs isomorphic? no!\n\n\\subsection*{homework 1.2}\n6a,b,7,10,15\n\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n  graph [tree layout] { 1 -- 2; 2 -- 3; 3 -- 4 --2 }\n  [shift=(0:1)];\n  %graph { 1 -- 2; 3 -- 4; 1 -- 4;  2 -- 3 };\n\\tikz\\path [graphs/.cd, nodes={shape=circle, fill=blue!40, draw=none, outer sep=0pt}]\n  graph [tree layout] { 1 -- {2 -- 3} -- 1 }\n  [shift=(0:1)];\n\\end{document}\n", "meta": {"hexsha": "948b86b549ba0e9df53fe07fc245e00768d00257", "size": 3872, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-01-16.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-01-16.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-01-16.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.094017094, "max_line_length": 192, "alphanum_fraction": 0.5996900826, "num_tokens": 1617, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073507867328, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.42346123770442}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Free Dirac field theory}\n\n\\subsection{The Dirac Lagrangian}\n\n\\marginpar{Sunday\\\\ 2020-6-7, \\\\ compiled \\\\ \\today}\n\nOur ansatz for the Lagrangian of a theory whose EOM is the Dirac equation is: \n%\n\\begin{align}\n\\mathscr{L} = \\frac{i}{2} \\qty[\\overline{\\psi} \\gamma^{\\mu } \\qty(\\partial_{\\mu } \\psi )\n- \\qty(\\partial_{\\mu } \\overline{\\psi}) \\gamma^{\\mu } \\psi ]\n- m \\overline{\\psi} \\psi \n\\,,\n\\end{align}\n%\nsince the Dirac equation is linear in the derivatives.\n\n\\begin{claim}\nThis Lagrangian is \\begin{enumerate}\n    \\item real; \n    \\item invariant under Lorentz transformation (which act on \\(\\psi \\) as \\(\\psi \\to S(\\Lambda ) \\psi \\));\n    \\item equivalent to the Lagrangian density \\(\\mathscr{L} = \\overline{\\psi} \\qty(i \\slashed{\\partial} - m) \\psi \\). \n\\end{enumerate}\n\\end{claim}\n\n\\begin{proof}\nTo see that the Lagrangian is real, we need to show that \\(\\mathscr{L} = \\mathscr{L} ^\\dag\\). For the mass term we have: \n%\n\\begin{align}\n\\qty(m \\overline{\\psi} \\psi ) ^\\dag &= m \\psi ^\\dag \\qty(\\gamma^{0} )^\\dag \\psi = m \\overline{\\psi} \\psi \n\\,,\n\\end{align}\n%\nsince \\(\\gamma^{0}\\) is self-adjoint. Now, the kinetic terms are mapped into each other --- because of the \\(i\\) in front, this means that the Lagrangian is conserved. Let us show it for one of them: \n%\n\\begin{subequations}\n\\begin{align}\n\\qty(\\overline{\\psi} \\gamma^{\\mu } \\partial_{\\mu } \\psi )^\\dag &=\n\\qty(\\partial_{\\mu } \\psi ) ^\\dag \\qty(\\gamma^{\\mu })^\\dag \\qty(\\gamma^{0})^\\dag \\psi  \\\\\n&= \\partial_{\\mu } \\psi ^\\dag \\gamma^{0} \\gamma^{0} \\qty(\\gamma^{\\mu }) ^\\dag \\gamma^{0} \\psi  \\\\\n&= \\partial_{\\mu } \\psi ^\\dag \\gamma^{0} \\gamma^{\\mu } \\psi  \\marginnote{Used \\eqref{eq:gamma-matrices-identity}}\\\\\n&= \\qty(\\partial_{\\mu } \\overline{\\psi}) \\gamma^{\\mu } \\psi \n\\,.\n\\end{align}\n\\end{subequations}\n\nThe fact that the Lagrangian is invariant under Lorentz transformations follows directly from the fact that, while \\(\\psi \\to S \\psi \\), the conjugate spinor transforms as \\(\\overline{\\psi} \\to \\overline{\\psi} S^{-1}\\) (see \\eqref{eq:dirac-conjugate-spinor-transformation}). \n\nAs for the equivalence: certain terms in the two Lagrangians are equal, the difference lies in the fact that one of them has a term \n%\n\\begin{align}\n\\frac{i}{2} \\overline{\\psi} \\gamma^{\\mu } \\partial_{\\mu } \\psi \n\\,,\n\\end{align}\n%\nwhile the other has a term \n%\n\\begin{align}\n- \\frac{i}{2} \\qty(\\partial_{\\mu } \\overline{\\psi}) \\gamma^{\\mu } \\psi  \n\\,.\n\\end{align}\n\nTo see that they are equivalent, we can show that their difference is a 4-divergence: \n%\n\\begin{align}\n\\frac{i}{2} \\overline{\\psi} \\gamma^{\\mu } \\partial_{\\mu } \\psi + (-)^2 \\frac{i}{2} \\qty(\\partial_{\\mu } \\overline{\\psi} )\\gamma^{\\mu } \\psi \n= \\frac{i}{2} \\gamma^{\\mu } \\partial_{\\mu } \\qty(\\overline{\\psi} \\psi )\n\\,.\n\\end{align}\n\nBasically, the difference lies in an integration by parts. \n\\end{proof}\n\nThe dimension of the Lagrangian density must be that of a length to the fourth, so the wavefunction's is \\([\\psi ] \\sim M^{3/2}\\).\n\n\\subsection{The Euler-Lagrange equations}\n\nIn order to get the equations for \\(\\psi \\) we differentiate with respect to \\(\\overline{\\psi}\\), and vice versa. We can write the Lagrangian as \n%\n\\begin{align}\n\\mathscr{L} = \\frac{i}{2} \\qty[ \\overline{\\psi} \\overset{\\rightarrow}{\\slashed{\\partial}} \\psi - \\overline{\\psi} \\overset{\\leftarrow}{\\slashed{\\partial}} \\psi  ] - m \\overline{\\psi} \\psi \n\\,,\n\\end{align}\n%\nso that it is easier to compute the derivatives: let us compute the EOM for \\(\\psi \\), using \n%\n\\begin{align}\n\\pdv{\\mathscr{L}}{\\overline{\\psi}} = \\frac{i}{2} \\overset{\\rightarrow}{\\slashed{\\partial}} \\psi - m \\psi \n\\,\n\\end{align}\n%\nand \n%\n\\begin{align}\n\\pdv{\\mathscr{L}}{\\partial_{\\mu } \\overline{\\psi}}\n= \\frac{i}{2} \\gamma^{\\mu } \\psi \n\\,,\n\\end{align}\n%\nso the EL equations read \n%\n\\begin{align}\n(i \\overset{\\rightarrow}{\\slashed{\\partial}} - m) \\psi = 0\n\\,.\n\\end{align}\n\nThe equations for the conjugate spinor are derived similarly; they read \n%\n\\begin{align}\n- \\overline{\\psi} \\qty(i \\overset{\\leftarrow}{\\slashed{\\partial}} + m) = 0\n\\,.\n\\end{align}\n\n\\begin{claim}\nThese can also be derived from the alternate formulation of the Lagrangian; \\(\\mathscr{L} = \\overline{\\psi} (i \\slashed{\\partial} - m) \\psi \\). \n\\end{claim}\n\n\\subsection{General solution}\n\nThe general solution reads \n%\n\\begin{subequations}\n\\begin{align} \\label{eq:dirac-general-solution}\n\\psi (x) &= \\frac{1}{(2 \\pi )^{3/2}}\n\\int \\frac{ \\dd[3]{k}}{\\sqrt{2 \\omega_{k}}}\n\\qty(c_r (k) u_r (k) e^{-ikx} + d^{*}_{r} (k) v_r (k) e^{ikx})_{k_0 = \\omega_{k}}  \\\\\n\\psi ^\\dag (x) &= \\frac{1}{(2 \\pi )^{3/2}}\n\\int \\frac{ \\dd[3]{k}}{\\sqrt{2 \\omega_{k}}}\n\\qty(d_r (k) v_r ^\\dag (k) e^{-ikx} + c ^\\dag_{r} (k) u_r ^\\dag (k) e^{ikx})_{k_0 = \\omega_{k}}  \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere a sum over \\(r\\) is implied: we account for both of the polarization states. \n\\(c\\) and \\(d\\) are coefficients, \\(u\\) and \\(v\\) are unit vectors in spinor space.\n\n\\subsection{Nöther currents}\n\nThe current associated with translation invariance is given by \n%\n\\begin{align}\n\\widetilde{T}^{\\mu }_{\\nu } =\n\\pdv{\\mathscr{L}}{\\partial_{\\mu } \\psi } \\partial_{\\nu } \\psi \n+ \n\\partial_{\\nu } \\overline{\\psi} \n\\pdv{\\mathscr{L}}{\\partial_{\\mu } \\overline{\\psi}} \n- \\delta^{\\mu }_{\\nu } \\mathscr{L}\n\\,,\n\\end{align}\n%\nbut if we impose the equations of motion we find \\(\\mathscr{L} = 0\\); so we can neglect that term.\nNotice the order of operations in the contractions: \\(\\psi \\) is a spinor, \\(\\overline{\\psi}\\) is a dual spinor, the derivative of the Lagrangian with respect to an object is of dual type to that object (so, \\(\\pdv*{\\mathscr{L}}{\\partial_{\\mu } \\psi }\\) is a dual spinor), and the conserved quantity must be a scalar in spinor space. \n\nExplicitly, this current reads \n%\n\\begin{align}\n\\widetilde{T}^{\\mu }_{\\nu } \n= i \\overline{\\psi} \\gamma^{\\mu }\\partial_{\\nu } \\psi \n\\sim\n\\frac{i}{2} \\qty(\\overline{\\psi} \\gamma^{\\mu }\\partial_{\\nu } \\psi - \\qty(\\partial_{\\nu } \\overline{\\psi}) \\gamma^{\\mu } \\psi )\n\\,;\n\\end{align}\n%\nthe two ways of writing it are equivalent (which one we get depends on which formulation of the Lagrangian we choose), they differ by a divergence.\n\nLet us check that this is indeed conserved: \n%\n\\begin{subequations}\n\\begin{align}\n\\partial_{\\mu } \\widetilde{T}^{\\mu \\nu } &= i\\partial_{\\mu }\n\\qty(\\overline{\\psi} \\gamma^{\\mu } \\partial^{\\nu } \\psi )  \\\\\n&= i \\overline{\\psi} \\overset{\\leftarrow}{\\slashed{\\partial}} \\partial^{\\nu } \\psi \n+ i \\overline{\\psi} \\overset{\\rightarrow}{\\slashed{\\partial}}\\partial^{\\nu} \\psi  \\\\\n&= -m \\overline{\\psi} \\partial^{\\nu } \\psi + \\overline{\\psi} \\partial^{\\nu } (m \\psi ) = 0 \\marginnote{Used the EOM for both \\(\\psi \\) and \\(\\overline{\\psi}\\).}\n\\,. \n\\end{align}\n\\end{subequations}\n\nNow, it is the case that we also have the conservation law \\(\\partial_{\\nu } \\widetilde{T}^{\\mu \\nu } = 0\\) --- it can be proven if we choose the other formulation of the stress-energy tensor:\n%\n\\begin{subequations}\n\\begin{align}\n\\partial_{\\nu } \\qty[\\frac{i}{2} \\qty(\\overline{\\psi} \\gamma^{\\mu }\\partial{\\nu } \\psi - \\qty(\\partial^{\\nu } \\overline{\\psi}) \\gamma^{\\mu } \\psi )]\n&= \\frac{i}{2} \\qty[\\qty(\\partial_{\\nu } \\overline{\\psi}) \\gamma^{\\mu } \\partial^{\\nu } \\psi \n+ \\overline{\\psi} \\gamma^{\\mu } \\partial_{\\nu } \\partial^{\\nu } \\psi \n- \\qty(\\partial_{\\nu } \\overline{\\psi}) \\gamma^{\\mu } \\partial^{\\nu } \\psi \n- \\qty(\\partial^{\\nu } \\partial_{\\nu } \\overline{\\psi}) \\gamma^{\\mu } \\psi  ]  \\\\\n&= \\frac{i}{2} \n\\qty[ \\overline{\\psi} \\gamma^{\\mu }\\square \\psi - \\square \\overline{\\psi} \\gamma^{\\mu } \\psi ] = 0\n\\,.\n\\end{align}\n\\end{subequations}\n\nThe result follows from the fact that a spinor satisfying the Dirac equation must also satisfy the Klein-Gordon one, \\(\\square \\psi  +m^2 \\psi = 0\\), and so must its conjugate. \n\nSo, the symmetrized stress-energy tensor \\(T^{\\mu \\nu } = \\widetilde{T}^{(\\mu \\nu )}\\) is conserved. \n\nThe conserved charge --- the total 4-momentum --- is given by \n%\n\\begin{align}\nP_{\\mu } = \\int \\dd[3]{x} \\widetilde{T}^{0}_{\\mu } = \\frac{i}{2} \n\\int \\dd[3]{x} \\psi ^\\dag \\overset{\\leftrightarrow}{\\partial}_{\\mu }\\psi   \n\\,.\n\\end{align}\n\nNotice the dagger instead of the bar: when we set the first index to zero we get a \\(\\gamma^{0}\\) matrix, which simplifies the one in the definition of \\(\\overline{\\psi}\\). \n\n\\subsection{Lorentz invariance}\n\nFor an infinitesimal Lorentz transformation defined by the antisymmtric tensor \\(\\omega_{\\mu \\nu }\\) the position and spinor change with: \n%\n\\begin{align}\nx^{\\prime \\mu } = x^{\\mu } + \\omega^{\\mu }_{\\nu } x^{\\nu }\n\\qquad \\text{and} \\qquad\n\\psi^{\\prime }( x') \n= \\qty(1 - \\frac{i}{2} \\omega^{\\rho \\sigma } \\Sigma_{\\rho \\sigma }) \\psi (x)\n\\,,\n\\end{align}\n%\nso the generators of their variations are \\(X\\) and \\(Y\\), defined by \n%\n\\begin{align}\n\\delta x^{\\mu } = \\frac{1}{2} \\omega^{\\rho \\sigma } Y^{\\mu }_{\\rho \\sigma }\n\\qquad \\text{and} \\qquad\n\\delta \\psi = \\frac{1}{2} \\omega^{\\rho \\sigma } X_{\\mu \\nu }\n\\,.\n\\end{align}\n\nExplicitly, they can be expressed as \n%\n\\begin{align}\nY^{\\mu }_{\\rho \\sigma } = 2 \\delta^{\\mu }_{[\\rho \\sigma ]}\n\\qquad \\text{and} \\qquad\nX_{\\rho \\sigma } = -i \\Sigma_{\\rho \\sigma } \\psi \n\\,;\n\\end{align}\n%\nbesides, we can conjugate \\(X\\) to get an expression for the generators of the variation of the conjugate spinor: \n%\n\\begin{align}\n\\overline{X}_{\\rho \\sigma } = i \\overline{\\psi} \\Sigma_{\\rho \\sigma }\n\\,.\n\\end{align}\n\nThe conserved currents read (see section \\ref{sec:poincare-invariance-noether}): \n%\n\\begin{align}\nJ^{\\mu }_{\\rho \\sigma } = 2 x_{[\\rho }\\widetilde{T}^{\\mu }_{\\sigma ]}\n+ \\overline{\\psi} \\gamma^{\\mu } \\Sigma_{\\rho \\sigma } \\psi \n\\,,\n\\end{align}\n%\nwith the corresponding charges: \n%\n\\begin{align}\nQ_{ \\rho \\sigma }\n= \\int \\dd[3]{x} \\qty(x_{[\\rho } p_{\\sigma ]}\n+ \\psi ^\\dag \\Sigma_{\\rho \\sigma } \\psi )\n= L_{ \\rho \\sigma } + S_{ \\rho \\sigma }\n\\,.\n\\end{align}\n\nThe fact that we can distinguish a regular angular momentum part as well as a spin part means that we have a spin 1/2 field. \n\n\\subsection{Global \\(U(1)\\) invariance}\n\nAnother symmetry of the Dirac field is an internal one, which leaves the position unchanged and acts on the field as \n%\n\\begin{align}\n\\psi'(x) = e^{i \\alpha } \\psi (x)\n\\,,\n\\end{align}\n%\nso its generator is \\(X = i \\alpha \\psi \\). The corresponding current is \n%\n\\begin{subequations}\n\\begin{align}\nJ^{\\mu } &= \\pdv{\\mathscr{L}}{\\partial_{\\mu }\\psi } X + \\overline{X} \\pdv{\\mathscr{L}}{\\partial_{\\mu } \\overline{\\psi}} = i \\overline{\\psi} \\gamma^{\\mu } i \\alpha \\psi   \\\\\n&= - \\alpha \\overline{\\psi} \\gamma^{\\mu } \\psi \\propto \\overline{\\psi} \\gamma^{\\mu } \\psi \n\\,. \n\\end{align}\n\\end{subequations}\n\nThe corresponding conserved charge is \n%\n\\begin{align}\nQ = \\int \\dd[3]{x} J^{0} = \\int \\dd[3]{x} \\psi ^\\dag \\gamma^{0} \\gamma^{0} \\psi = \\int \\dd[3]{x} \\psi ^\\dag \\psi \n\\,.\n\\end{align}\n\n\\subsection{Hamiltonian description}\n\nThe conjugate fields are: \n%\n\\begin{align}\n\\pi = \\pdv{\\mathscr{L}}{\\partial_0 \\psi } = \\pdv{}{\\partial_0 \\psi} \\qty(\\psi ^\\dag \\gamma^{0} \\frac{i}{2} \\gamma^{\\mu } \\partial_{\\mu } \\psi )= \n\\frac{i}{2} \\psi ^\\dag\n\\qquad \\text{and} \\qquad\n\\pi ^\\dag = \\pdv{\\mathscr{L}}{\\partial_0 \\psi ^\\dag} = - \\frac{i}{2} \\psi \n\\,,\n\\end{align}\n%\nand with these we can write the Hamiltonian density: \n%\n\\begin{subequations}\n\\begin{align}\n\\mathscr{H} &= \\pi \\partial_0 \\psi + \\qty(\\partial_0 \\psi ^\\dag) \\pi ^\\dag - \\mathscr{L}  \\\\\n&= \\frac{i}{2} \\qty[ \\psi ^\\dag \\partial_0 \\psi - \\partial_0 \\psi ^\\dag \\psi - \\overline{\\psi} \\gamma^{\\mu } \\partial_{\\mu } \\psi + \\qty(\\partial_{\\mu } \\overline{\\psi})\\gamma^{\\mu } \\psi ]\n+m \\overline{\\psi} \\psi   \\\\\n&= \\frac{i}{2} \\qty[\n\\psi ^\\dag \\overset{\\leftrightarrow}{\\partial_0 } -\n\\psi ^\\dag \\qty(\\gamma^{0})^2 \\overset{\\leftrightarrow}{\\partial_0 }\n\\psi \n- \\overline{\\psi}  \\gamma^{i}\\overset{\\leftrightarrow}{\\partial_i }\n\\psi\n]\n+m \\overline{\\psi} \\psi   \\\\\n&= -\\frac{i}{2} \\overline{\\psi}  \\gamma^{i}\\overset{\\leftrightarrow}{\\partial_i }\n\\psi\n+ m \\overline{\\psi} \\psi  \\\\\n&= \\frac{i}{2} \\psi ^\\dag \\overset{\\leftrightarrow}{\\partial_0 } \\psi \n\\,,\n\\end{align}\n\\end{subequations}\n%\nthe last step uses the Dirac equation, \\(\\qty(i \\slashed{\\partial} -m) \\psi =0\\).\n\nThe Hamiltonian is given by \n%\n\\begin{align}\nH = \\int \\dd[3]{x} \\mathscr{H} = i \\int \\dd[3]{x} \\psi ^\\dag \\partial_0 \\psi \n\\,,\n\\end{align}\n%\nup to global constants like \\(\\int \\psi ^\\dag \\psi \\dd[3]{x}\\). \n\nIt is not manifestly positive definite. \n\n\\subsection{Hamilton equations}\n\nHamilton's equations in terms of the fields and conjugate fields read: \n%\n\\begin{subequations}\n\\begin{align}\n\\dot{\\psi}_{\\alpha } (\\vec{x}) &= \\fdv{H}{\\pi_{\\alpha }(\\vec{x})} = \\qty{\\psi_{\\alpha }, H} = \\partial_0 \\psi_{\\alpha } (\\vec{x}, t)\\\\\n\\dot{\\pi }_{\\alpha } (\\vec{x}) &= - \\fdv{H}{\\psi _{\\alpha }(\\vec{x})} = \\qty{\\pi_{\\alpha }, H} \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere \\(\\alpha \\) is a spinorial index. \nThe equal-time Poisson brackets between the fields are \n%\n\\begin{subequations}\n\\begin{align}\n\\qty{\\psi_{\\alpha } (\\vec{x}), \\pi_{\\beta } (\\vec{y})} &= \\delta_{\\alpha \\beta } \\delta^{(3)} (\\vec{x}-\\vec{y})  \\\\\n\\qty{\\psi_{\\alpha }(\\vec{x}), \\psi_{\\beta }(\\vec{y})} \n&= 0 = \n\\qty{\\pi_{\\alpha }(\\vec{x}), \\pi_{\\beta }(\\vec{y})} \n\\,.\n\\end{align}\n\\end{subequations}\n\nDo note that the Hamiltonian description is redundant: between the fields \\(\\psi \\), \\(\\psi ^\\dag\\), \\(\\pi \\) and \\(\\pi ^\\dag\\) there are actually only two degrees of freedom. \n\nWe now show the EOM for the conjugate field: it reads \n%\n\\begin{subequations}\n\\begin{align}\n\\dot{\\pi}_{\\alpha } (\\vec{x}, t)\n&= - \\fdv{}{\\psi_{\\alpha }(\\vec{x}, t)}\n\\qty(\\int \\dd[3]{y} \\psi ^\\dag(\\vec{y}, t) \\partial_0 \\psi (\\vec{y}, t))  \\\\\n&= - \\fdv{}{\\psi_{\\alpha }(\\vec{x}, t)}\n\\qty(\\dv{}{t} \\int \\dd[3]{y} \\psi ^\\dag(\\vec{y}, t) \\psi (\\vec{y}, t)\n- \\int \\dd[3]{y} \\qty(\\partial_0 \\psi ^\\dag (\\vec{y},t) ) \\psi (\\vec{y}, t)\n)  \\\\\n&= \\partial_0 \\psi ^\\dag_{\\alpha } (\\vec{x}, t)\n\\,.\n\\end{align}\n\\end{subequations}\n\nThe total derivative term vanishes because of the global \\(U(1)\\) symmetry. \n\n\\section{Quantization of the Dirac field}\n\n\nWe start from the general solution of the Dirac equation \\eqref{eq:dirac-general-solution}. We can invert it to get the expressions for the coefficients \\(c_r\\) and \\(d_r\\) in momentum space: \n%\n\\begin{subequations}\n\\begin{align}\nc_r (k) &= \\frac{1}{(2\\pi )^{3/2}} \\int \\eval{\\frac{ \\dd[3]{x}}{\\sqrt{2 \\omega_{k}}} \nu_{r} ^\\dag (k) \\psi (\\vec{x}, t) e^{ikx}}_{k_0 = \\omega_{k}}  \\\\\nd_r (k) &= \\frac{1}{(2\\pi )^{3/2}} \\int \\eval{\\frac{ \\dd[3]{x}}{\\sqrt{2 \\omega_{k}}} \n\\psi ^\\dag (\\vec{x}, t) v_{r} ^\\dag (k)  e^{ikx}}_{k_0 = \\omega_{k}}\n\\,.\n\\end{align}\n\\end{subequations}\n\n\\begin{claim}\nThe Hamiltonian \\(H\\) and the \\(U(1)\\) charge \\(Q\\) are given by:\n%\n\\begin{subequations}\n\\begin{align}\n    H &= \\int \\dd[3]{x} \\psi ^\\dag \\partial_0 \\psi  = \\int \\dd[3]{k} \\omega_{k} \\qty(c_r ^\\dag c_r - d_r  d_r ^\\dag)  \\\\\n    Q &= \\int \\dd[3]{x} \\psi ^\\dag \\psi = \\int \\dd[3]{k} \\qty(c_r ^\\dag c_r  + d_r d_r ^\\dag) \n    \\,.\n\\end{align}   \n\\end{subequations}\n\\end{claim}\n\n\\begin{proof}\n\\todo[inline]{Still to do. Probably direct substitution works.}\n\\end{proof}\n\n\\subsection{Canonical quantization with commutators}\n\nWe try to quantize our theory of a Dirac field substituting commutators (divided by \\(i \\hbar\\)) for Poisson brackets. So, the time evolution will become (in  the Heisenberg picture): \n%\n\\begin{subequations}\n\\begin{align}\n\\dot{\\psi}_{\\alpha } (\\vec{x}, t) =- i \\qty[ \\psi_{\\alpha } (\\vec{x}, t), H] \\\\\n\\dot{\\pi}_{\\alpha } (\\vec{x}, t) =- i \\qty[ \\pi_{\\alpha } (\\vec{x}, t), H]\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand the commutators between the fields will be \n%\n\\begin{align}\n\\qty[\\psi_{\\alpha }(\\vec{x}, t), \\pi_{\\beta } (\\vec{y}, t)] = i \\delta^{(3)} (\\vec{x} - \\vec{y}) \\delta_{\\alpha \\beta }\n\\,,\n\\end{align}\n%\nwhile those of \\(\\psi \\) and \\(\\pi \\) with themselves vanish. \nSince \\(\\pi  = i \\psi ^\\dag\\), we also have \n%\n\\begin{align}\n\\qty[ \\psi_{\\alpha } (\\vec{x}, t), \\psi ^\\dag_{\\beta} (\\vec{y}, t)] = \\delta^{(3)} (\\vec{x}- \\vec{y}) \\delta_{\\alpha \\beta }\n\\,.\n\\end{align}\n\nWe have similar relations in momentum space: \n%\n\\begin{align}\n\\qty[c_r (k), c_s ^\\dag (p)] = \\delta^{(3)} (\\vec{k} - \\vec{p}) \\delta_{rs} = - \\qty[d_r (k), d_r ^\\dag (p)]\n\\,,\n\\end{align}\n%\nand the others vanish. Notice the minus sign! \nBecause of it, we define the \\(d\\) number operator in the opposite order: \n%\n\\begin{align}\nN_c^{r} (k) = c_r ^\\dag (k) c_r (k)\n\\qquad \\text{and} \\qquad\nN_d^{r} (k) = d_r (k) d_r  ^\\dag (k)\n\\,,\n\\end{align}\n%\nas usual the total number operators are their integrals over momentum space. \nThe commutation relations read: \n%\n\\begin{subequations}\n\\begin{align}\n\\qty[N_c^{r}, c_s ^{(\\dag)} (k)] &= \\pm c_s ^{(\\dag)} (k) \\delta_{rs} \\\\\n\\qty[N_d^{r}, d_s ^{(\\dag)} (k)] &= \\mp d_s ^{(\\dag)} (k) \\delta_{rs}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere the dagger in parentheses means that the relations hold both with it and without it. \n\nSo, we have an opposite sign in the \\(d\\) operator relations. This may bee fixed with some redefinitions of the wavefunction, but is an indication of a larger problem: this type of quantization of Dirac theory is inconsistent. \n\nThis can be seen in two ways. First of all, \\textbf{the Hamiltonian is not positive definite}: it depends on an integral of \\(N_c - N_d\\); on the other hand the charge \\(Q\\) is positive!\n\nSecondly, the Fock space can be constructed much like we did for the scalar field, and therefore it will \\textbf{contain identical particle states}. But we know that fermions' wavefunction is antisymmetric under exchange of particles, so this is wrong. \n\nThe way to solve this issue is to quantize the theory using \\textbf{anticommutators}. \n\n\\subsection{Anticommutator quantization}\n\nWe do everything as we did before, except for the fact that we substitute Poisson brackets for \\textbf{anticommutators} divided by \\(i \\hbar\\).\n\nThe anticommutators of the fields will then read \n%\n\\begin{subequations}\n\\begin{align}\n\\qty{\\psi_{\\alpha } (\\vec{x}), \\pi_{\\beta } (\\vec{y})} &= i \\delta_{\\alpha \\beta } \\delta^{(3)} (\\vec{x}-\\vec{y})  \\\\\n\\qty{\\psi_{\\alpha }(\\vec{x}), \\psi_{\\beta }(\\vec{y})} \n&= 0 = \n\\qty{\\pi_{\\alpha }(\\vec{x}), \\pi_{\\beta }(\\vec{y})} \n\\,,\n\\end{align}\n\\end{subequations}\n%\nas before the first line is equivalent to \\(\\qty{\\psi, \\psi ^\\dag} = \\delta^{(3)} \\delta_{\\alpha \\beta }\\).\nIn momentum space, this corresponds to \n%\n\\begin{align}\n\\qty{c_r (k), c_s ^\\dag (p)} = \\delta^{(3)} (k-p) \\delta_{rs} = \\qty{d_r (k), d_s ^\\dag (p)}\n\\,,\n\\end{align}\n%\nwhereas the other anticommutators vanish. \n\n\\todo[inline]{``So we have obtained the anticommutator algebra for the harmonic oscillator'' --- ok, but we never described the HO with anticommutators, right? Are we just saying that it's the same thing with anticommutators instad of commutators?}\n\nNow, we can define all of our objects of interest. The number density operators are given by\n%\n\\begin{align}\n\\mathscr{N}^{r}_{c} (k) = c ^\\dag_{r} (k) c_r (k) \\qquad \\text{and} \\qquad\n\\mathscr{N}^{r}_{d} (k) = d ^\\dag_{r} (k) d_r (k)\n\\,,\n\\end{align}\n%\nand as usual the total number is given by their integral over momentum space. \n\nThe rules that these need to follow in order to be proper number operators are still written in terms of commutators: in order to verify them, we can write them in terms of the anticommutators, which we know. \n\nWe start with \n%\n\\begin{subequations}\n\\begin{align}\n\\qty[N_c^{r} (k), c_s (p)] &= c_r ^\\dag (k) c_r (k) c_s (p) -  c_s (p) c_r ^\\dag (k) c_r (k)  \\\\\n&= c_r ^\\dag (k) c_r (k) c_s (p) + c_r ^\\dag (k) c_s (p) c_r (k)\n- c_r ^\\dag (k) c_s (p) c_r (k) -  c_s (p) c_r ^\\dag (k) c_r (k)  \\\\\n&= c_r ^\\dag (k) \\qty{c_r (k), c_s (p)} - \\qty{c_r ^\\dag (k), c_s (p)} c_r (k)  \\\\\n&= - c_r (k) \\delta_{rk} \\delta^{(3)} (\\vec{k} - \\vec{p})\n\\,.\n\\end{align}\n\\end{subequations}\n\nSimilarly we get \n%\n\\begin{subequations}\n\\begin{align}\n\\qty[N_c^{r} (k), c_s ^\\dag (p)] &= c_r ^\\dag (k) \\delta_{rs} \\delta^{(3)} (\\vec{k} - \\vec{p})  \\\\\n\\qty[N_c^{r} (k), d_s (p)] &= - d_r (k) \\delta_{rk} \\delta^{(3)} (\\vec{k} - \\vec{p}) \\\\\n\\qty[N_c^{r} (k), d_s ^\\dag (p)] &= d_r ^\\dag (k) \\delta_{rs} \\delta^{(3)} (\\vec{k} - \\vec{p}) \n\\,,\n\\end{align}\n\\end{subequations}\n%\nso all the harmonic oscillator properties we have found still hold. \n\nThe Hamiltonian density operator can now be normal-ordered as usual: the density is \\(\\mathscr{H} = \\frac{i}{2} \\overline{\\psi} \\overset{\\leftrightarrow}{\\partial_0 } \\psi \\), so we find\n%\n\\begin{subequations}\n\\begin{align}\nH &= \\int \\dd[3]{k} \\omega_{k} \\qty(c_r ^\\dag c_r - d_r d_r ^\\dag)  \\\\\n&= \\int \\dd[3]{k} \\omega_{k} \\sum _{r} \\qty(N_c^{r} + N_d^{r}) + \\int \\dd[3]{k} \\omega_{k} \\sum_{r} \\delta^{(3)} (0)\n\\,.\n\\end{align}\n\\end{subequations}\n\nThe conserved charge reads \n%\n\\begin{subequations}\n\\begin{align}\nQ &= \\int \\dd[3]{k}  \\qty(c_r ^\\dag c_r + d_r d_r ^\\dag)  \\\\\n&= \\int \\dd[3]{k}  \\sum _{r} \\qty(N_c^{r} - N_d^{r}) + \\int \\dd[3]{k} \\omega_{k} \\sum_{r} \\delta^{(3)} (0) \n\\,,\n\\end{align}\n\\end{subequations}\n%\nso we have recovered the physically meaningful conditions \\(H \\geq 0\\), \\(Q \\lessgtr 0\\). \nAs before, we ignore the infinite energy of the vacuum. \n\n\\subsection{Normal ordering for fermions}\n\nAs opposed to the bosonic case, for fermions normal ordering does not just mean putting the operators in the right order (annihilation first, creation later). Since we are dealing with anticommutation, we have to insert an additional \\textbf{sign}, which is \\((-1)^{n}\\), where \\(n\\) is the number of pair swaps needed to reach the final configuration. \n\nSo, inside the normal ordering sign, operators anticommute.\n\n\\subsection{Fock space for fermions}\n\nAs before, we define the vacuum by \\(c_r \\ket{0} = d_r \\ket{0} = 0\\) for any \\(k\\) and add particles with \\(c_r ^\\dag\\) and \\(d_r ^\\dag\\).\n\nThe one-particle states have exactly the properties we'd expect for number, Hamiltonian and charge \\eqref{eq:fock-one-particle-state-properties}: the proof follows the same steps, the only difference is that instead of a commutator we insert an anticommutator. \n\nSo, we can indeed interpret \\(c_r ^\\dag\\) as creating a particle, while \\(d_r ^\\dag\\) creates its antiparticle. \n\nThe algebra we have does not modify the properties of one-particle states, but it very much affects two-particle states: specifically, the anticommutation rules enforce \\textbf{Fermi-Dirac statistics}. If we try to create a state with two identical particles, we get \n%\n\\begin{align}\n\\ket{2(p)} \\propto \\qty(c_r ^\\dag)^2 \\ket{0} = \\frac{1}{2} \\qty{c_r ^\\dag, c_r ^\\dag} \\ket{0} = 0\n\\,.\n\\end{align}\n\nIn general, it can be stated that there is only one consistent way to quantize a relativistic field theory: \n\\begin{enumerate}\n    \\item with commutators for bosonic (iteger-spin) fields;\n    \\item with anticommutators for fermionic (half-integer spin) fields.\n\\end{enumerate}\n\nFor our scalar (spin-0) theory, if we had tried to use anticommutators we would have gotten an inconsistency: when we normal-order the operators in the Hamiltonian we would have gotten \\(N_a - N_b\\), making it non-positive definite. \n\n\\subsection{Covariant anticommutators}\n\n\\begin{claim}\nJust like the complex scalar field, same-field anticommutators vanish: \n%\n\\begin{align}\n\\qty{\\psi_{\\alpha }(\\vec{x}), \\psi_{\\beta }(\\vec{y})} = 0 = \\qty{\\overline{\\psi}_{\\alpha }(\\vec{x}), \\overline{\\psi}_{\\beta }(\\vec{y})}\n\\,.\n\\end{align}\n\\end{claim}\n\n\\begin{proof}\nThe only nonvanishing anticommutators are \\(\\qty{c_r , c_r ^\\dag}\\) and \\(\\qty{d_r, d_r ^\\dag}\\). In the expression for the anticommutator between \\(\\psi \\), \\(\\psi \\) or any same-field anticommutator we cannot get these, so the whole thing vanishes. \n\\end{proof}\n\nSo, we consider \n%\n\\begin{subequations}\n\\begin{align}\nS_{\\alpha \\beta } (x-y) &= \\qty{ \\psi_{\\alpha }(x), \\overline{\\psi}_{\\beta }(y)}  \\\\\n&= \\qty{\\psi_{+}(x), \\overline{\\psi}_{-}(y)}_{\\alpha \\beta } + \n\\qty{\\psi_{-}(x), \\overline{\\psi}_{+}(y)}_{\\alpha \\beta }  \\\\\n&= S_{\\alpha \\beta }^{+}(x-y) + S_{\\alpha \\beta }^{-} (x-y)\n\\,.\n\\end{align}\n\\end{subequations}\n\nWith the anticommutation relations we can write \n%\n\\begin{subequations}\n\\begin{align}\nS^{+}_{\\alpha \\beta }(x-y) &= \\frac{1}{(2 \\pi )^3}\n\\int \\frac{ \\dd[3]{k}}{2 \\omega_{k}}\n\\qty(\\slashed{k} + m)_{\\alpha \\beta } \\eval{e^{-ik(x-y)} }_{k_0 = \\omega_{k}} = \\qty(i \\slashed{\\partial} + m) D_+ (x-y)\\\\\nS^{-}_{\\alpha \\beta }(x-y) &= \\frac{1}{(2 \\pi )^3}\n\\int \\frac{ \\dd[3]{k}}{2 \\omega_{k}}\n\\qty(\\slashed{k} - m)_{\\alpha \\beta } \\eval{e^{ik(x-y)} }_{k_0 = \\omega_{k}}\n=\\qty(i \\slashed{\\partial} + m) D_- (x-y)\n\\,,\n\\end{align}\n\\end{subequations}\n%\nso \\(S(x-y) = \\qty(i \\slashed{\\partial} + m )D(x-y) \\); everything we proved for \\(D(x-y)\\) in section \\ref{sec:covariance-microcausality} will still hold --- specifically, we still have Lorentz \\textbf{covariance} and \\textbf{microcausality}. \n\nNote that \\(\\slashed{\\partial}\\) is implicitly \\(\\slashed{\\partial_{(x)}}\\). \n\n\\end{document}\n", "meta": {"hexsha": "e646eb85e36cdc9a48642046a8b6be8fab2fd622", "size": 24759, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/theoretical_physics/may04.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/theoretical_physics/may04.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/theoretical_physics/may04.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 38.2083333333, "max_line_length": 353, "alphanum_fraction": 0.6410194273, "num_tokens": 8878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4234174360309652}}
{"text": "%!TEX root = ../Thesis.tex\n\\chapter{Time and Node Distributions}\\label{cha:dists}\n%\n\nThe distribution of solution times and number of nodes is central to the evaluation of the variable selection algorithms. In this thesis, the mean and standard deviation are calculated under the assumption of both of these variables having a distribution that can be approximated as a Gaussian (normal) distribution. This is in contrast with the main sources of this thesis (Gasse et al. (2019) \\cite{gasse2019exact}, Gupta et al. (2020) \\cite{gupta2020hybrid}), which use shifted geometric means. The choice of distribution in this thesis is based on uncertainty in the distribution parameters and configurations in the previous works. An example of a time and node distribution with a superimposed normal distribution approximation is shown in \\Cref{fig:histogram_time} and \\Cref{fig:histogram_nodes}. Some discrepancy is found for the time distribution, and more considerably for the number of nodes. The discrepancy is considered of little importance in the comparison of the models, particularly as the node number comparison is devoted little attention in this thesis. Further researchers are encourage to standardize the statistical side of branching comparison in larger detail. \n\n% https://tex.stackexchange.com/questions/237085/histogram-with-overlaying-gauss-curve-pgfplots\n\\newcommand\\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}\n\n\\begin{figure}[ht]\n\\centering\n    \\begin{tikzpicture}\n        \\begin{axis}[\n            height=7cm,\n            width=12cm,\n            xmin=0.0,\n            xmax=4.5,\n            xlabel = {Solution time [s]},\n            ylabel = Frequency\n    ]\n    \n        \\addplot[\n            black,\n            fill=lightgray,\n            hist,\n            hist/bins=40,\n        ] table[\n            y=time,\n        ] {dat/soltime_gnn1_cauctions.dat};\n    \n        \\addplot[domain={0.0:4.5},yscale=28,samples=250] {\\gauss{1.68}{0.48}}; %23.2\n    \n        \\end{axis}\n    \\end{tikzpicture}\n    \\caption{Solution time for GNN1 on combinatorial auctions problems with a normal distribution approximation.}\n    \\label{fig:histogram_time}\n\\end{figure}\n\n\\begin{figure}[ht]\n\\centering\n    \\begin{tikzpicture}\n        \\begin{axis}[\n            height=7cm,\n            width=12cm,\n            xmin=0.0,\n            xmax=500,\n            xlabel = {Solution time [s]},\n            ylabel = Frequency\n    ]\n    \n        \\addplot[\n            black,\n            fill=lightgray,\n            hist,\n            hist/bins=40,\n        ] table[\n            y=nodes,\n        ] {dat/nodes_gnn1_cauctions.dat};\n    \n        \\addplot[domain={0.0:500},yscale=3400,samples=250] {\\gauss{95}{78}}; %2800\n    \n        \\end{axis}\n    \\end{tikzpicture}\n    \\caption{Number of nodes after solving for GNN1 on combinatorial auctions problems with a normal distribution approximation.}\n    \\label{fig:histogram_nodes}\n\\end{figure}\n\n", "meta": {"hexsha": "65562f8bbaca61490640445b1f872a21490df548", "size": 2925, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/A-distributions.tex", "max_stars_repo_name": "Sandbergo/master-thesis", "max_stars_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-25T10:42:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-25T10:42:49.000Z", "max_issues_repo_path": "tex/A-distributions.tex", "max_issues_repo_name": "Sandbergo/master-thesis", "max_issues_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/A-distributions.tex", "max_forks_repo_name": "Sandbergo/master-thesis", "max_forks_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0147058824, "max_line_length": 1187, "alphanum_fraction": 0.6601709402, "num_tokens": 739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.42341742668734783}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Double Weighted Moving Averages (Integers)} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{\nThis trading rules is a linear combination of four moving averages: short price average, long price average, short research average, long research average. The parameters accepted are the length of each average and coefficients for each average's weighting contribution. The total sum is divided by the current price to calculate a (dimensionless) position size. \\\\\n\n\\noindent Due to the linear summation this rule is only valid for research series of the same dimensionality as the price series (e.g. a research series representing a price target).\\\\\n\n\\noindent The last available value is included. As such if the short average is ``1\" and the long average is ``1\" then the short average is today's price and the long average is the average of today and yesterday's prices.}\n\n\\ruleparameters\n{Short price average length}{2}{Number of days in the short price average.}{$\\averagelengthshort^{\\price}$}\n{Long price average length}{5}{Number of additional days in the longer price average (added to the number in the short price average).}{$\\averagelengthlong^{\\price}$}\n{Short research average length}{2}{Number of days in the short research average.}{$\\averagelengthshort^{\\research}$}\n{Long research average length}{5}{Number of additional days in the longer research average (added to the number in the short price average).}{$\\averagelengthlong^{\\research}$}\n{Amplitude of short price average}{1.0}{Weighting coefficient for the short term average of price.}{$\\amplitudecoefficientone^{\\price}$}\n{Amplitude of long price average}{1.0}{Weighting coefficient for the long term average of price.}{$\\amplitudecoefficienttwo^{\\price}$}\n{Amplitude of short research average}{1.0}{Weighting coefficient for the short term average of research.}{$\\amplitudecoefficientone^{\\research}$}\n{Amplitude of long research average}{1.0}{Weighting coefficient for the long term average of research.}{$\\amplitudecoefficienttwo^{\\research}$}\n\\stoptable\n\n\n\\section{Equation}\n\n\\begin{equation}\n\\bigcontribution(\\currenttime, \\averagelength, \\amplitudecoefficient, \\genericfunction) = \\frac{\\amplitudecoefficient}{\\averagelength} \\sum_{\\dummyiterator=0}^{\\averagelength-1} \\genericfunction(\\currenttime - \\dummyiterator)\n\\end{equation}\n\n\\begin{equation}\n\\position(\\currenttime) = \\frac{\\bigcontribution(\\currenttime, \\averagelengthshort^{\\price}, \\amplitudecoefficientone^{\\price}, \\price)+\\bigcontribution(\\currenttime, (\\averagelengthshort^{\\price} + \\averagelengthlong^{\\price}), \\amplitudecoefficienttwo^{\\price},\\price)+\\bigcontribution(\\currenttime, \\averagelengthshort^{\\research}, \\amplitudecoefficientone^{\\research}, \\research)+\\bigcontribution(\\currenttime, (\\averagelengthshort^{\\research} + \\averagelengthlong^{\\research}), \\amplitudecoefficienttwo^{\\research}, \\research)}{\\price(\\currenttime)}\n\\end{equation}\\\\\n\n\\noindent where $\\position_\\currenttime$ is the portfolio allocation at time $\\currenttime$, $\\price = \\price(\\currenttime)$ is the value of the price series and $\\research = \\research(\\currenttime)$ is the value of the research series.\n\n\\hspace{200mm}\n\\hspace{200mm}\n\n\\keyterms\n\\furtherlinks\n\n\\end{document}\n", "meta": {"hexsha": "090bc8de8fc9fcff3365906051dc212eb9381ba5", "size": 3383, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/DoubleWeightedMovingAverages.tex", "max_stars_repo_name": "pawkw/infertrade", "max_stars_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/DoubleWeightedMovingAverages.tex", "max_issues_repo_name": "pawkw/infertrade", "max_issues_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/DoubleWeightedMovingAverages.tex", "max_forks_repo_name": "pawkw/infertrade", "max_forks_repo_head_hexsha": "48231c2c026b4163291e299cd938969401ca6a4a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 69.0408163265, "max_line_length": 554, "alphanum_fraction": 0.7824416199, "num_tokens": 865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.42341742255255976}}
{"text": "\\documentclass{pset_template}\n\n\\title{Bit-String Flicking}\n\\date{January 17, 2019}\n\\editorOne{Alexander Sun}\n\\editorTwo{Sanjit Bhat}\n\\lectureNum{2}\n\\contestMonth{January}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction/Lecture}\nBit String Flicking is a general term to denote operations that can be done to bit strings/ binary strings. They can involve multiple strings or just a single string. There are 3 general types of operations, your basic truth operators, shifts, and circulates.\n\\subsection{Truth Operations}\nBit String flicking only involves 4 main operations(they should seem familiar), AND, OR, NOT, EXOR, and all the inverses of them. In contest AND $\\rightarrow$ $\\&$, OR $\\rightarrow$ $\\mid$, NOT $\\rightarrow$ $\\sim$,  EXOR $\\rightarrow$ $\\oplus$.\n\nE.X. 101 | 010 = 111\n\\subsection{Shift}\nShifting is very straight forward involving 2 operations. You can shift right or left. A shift, literally shifts the digits the specified amount in the specified direction, while maintaining the same amount of digits, filling in 0's fordigits shifted out of the number.\n\\\\\n\\\\\nE.X. LSHIFT-3 100010 =  010000, RSHIFT-3 100010 = 000100\n\\\\\n\\\\\nThe trick to solving these problems, is to cover up the amount of digits specified on the right or left side, then just fill in 0's for the rest of the digits.\n\\subsection{Circulate}\nCirculating is extremely similar to shifting, except no digits will be deleted by getting shifted out of the number. Instead they are added back (or circulated) on to the other end of the number, either in the right or left direction, a specified amount.\n\\\\\n\\\\\nE.X. RCIRC-3    10111 = 11110         LCIRC-3   10111 = 11101\n\\\\\n\\\\\nThe method to solving these problems, are to take the number of digits on the specified side and shifting them directly behind the remaining digits on the other side.\n\\subsection{Miscellaneous/General Tips}\nOrder of Operations: NOT, SHIFT / CIRC, AND, XOR, OR\n\\\\\nSolving problems with variables often have more then one solution. Some questions will ask you to list out all values, and others will ask for the amount of possible values. Generally just work from the outside in, and if necessary assign values abced. for each digit the expression is equivalent to, and use that to help you.\n\\section{Exercises}\nSome borrowed from \\href{http://minich.com/education/wyo/acsl/bitstringflicking/bitstringwksht1.htm}{here}.\n\\begin{enumerate}\n\\item 10010 OR 11101\n\\item 10001 AND 11011 OR 11001\n\\item 11100 OR 10101 AND 10111\n\\item NOT 101 AND 100\n\\item 101011 XOR 110101\n\\item 101011 OR 100111 XOR 100010\n\\item NOT (11101 XNOR 10100)\n\\item 1011 OR 1101 XOR 1000 AND 1010 OR 1110 AND NOT 1000\n\\item Find all possible values of x: (RCIRC-2(LSHIFT-1 (NOT X)))=00101\n\\item List all possible unique values of x that solve the following equation: \\\\\n(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100\n\\item (RSHIFT-1 (LCIRC-4 (RCIRC-2 01101)))\n\\item ((RCIRC-14 (LCIRC-23 01101)) $\\mid$ (LSHIFT-1 10011) $\\&$ (RSHIFT-2 10111)) \\\\\nHint: Order of operations, generally parenthesis dictate order\n\\end{enumerate}\n\\end{document}\n", "meta": {"hexsha": "69c1805e32b2ddd3088b9adcb496f698f26a6388", "size": 3073, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bit-string-flicking.tex", "max_stars_repo_name": "sanjit-bhat/AB-ACSL", "max_stars_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-12T03:01:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-12T03:01:29.000Z", "max_issues_repo_path": "bit-string-flicking.tex", "max_issues_repo_name": "sanjit-bhat/AB-ACSL", "max_issues_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bit-string-flicking.tex", "max_forks_repo_name": "sanjit-bhat/AB-ACSL", "max_forks_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.9827586207, "max_line_length": 326, "alphanum_fraction": 0.7611454605, "num_tokens": 872, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704502361149, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.4233291831419775}}
{"text": "%*******************************************************************************\n%********************************* Appendix A **********************************\n%*******************************************************************************\n\\chapter{Appendix A}\n\\chaptermark{Appendix A}\n\\label{AppendixA}\n\n\\section{Introduction}\n\nNumber theory is a field of mathematics that studies integers, it subsumes the branch of combinatorics concerned with counting the number of combinations and permutations of finite sets \\citep{Laplace1820}. The Stirling numbers of first, second and third kind play an important role in combinatorial mathematics, they find applications for different analytic and combinatorial problems and they can all be used to express the coefficient of sequences of polynomials. All these numbers are linked by the fact that they can express the number of partitions of a set with $n$ elements into $k$ non-empty non-overlapping subsets. This appendix aims at introducing the Stirling numbers as well as how they can be computed. Also, a presentation of some of their properties as well as the link between them is also provided.\n\n\\section{Stirling Numbers of the First Kind}\n\nThe Stirling numbers of the first kind are linked to the number of cycles within a finite discrete set. These numbers can be unsigned or signed and are defined by the coefficients of the rising and falling factorials as follows,\n\n\\begin{equation} \\label{eqnA.1}\nx^{(n)} = \\prod_{k=0}^{n-1} (x+k) = \\sum_{k=0}^{n} \\genfrac{[}{]}{0pt}{0}{n}{k} x^{k}.\n\\end{equation}\n\nThe equation \\eqref{eqnA.1} defines the rising factorial and its relation with the unsigned Stirling numbers of the first kind, whereas the equation \\eqref{eqnA.2} defines the falling factorial along with its relation with the unsigned Stirling numbers of the first kind. The signed Stirling numbers of the first kind are obtained by combining the sign in the sum of \\eqref{eqnA.2} with the unsigned Stirling numbers of the first kind.\n\n\\begin{equation} \\label{eqnA.2}\n(x)_{n} = \\prod_{k=0}^{n-1} (x-k) = \\sum_{k=0}^{n} (-1)^{n-k} \\genfrac{[}{]}{0pt}{0}{n}{k} x^{k} \n\\end{equation}\n\nThe unsigned Stirling numbers of the first kind correspond to the number of permutations of a set of $n$ elements with $k$ disjoint cycles. These numbers can also be computed using the following recurrence relation,\n\n\\begin{subequations} \\label{eqnA.3}\n\\begin{align}\n\\forall (n,k) \\in \\mathbb{N}^{*} \\times \\mathbb{N}^{*} ,\\, & \\genfrac{[}{]}{0pt}{0}{0}{0} = 1 ,\\, \\genfrac{[}{]}{0pt}{0}{n}{0} = \\genfrac{[}{]}{0pt}{0}{0}{n} = 0, \\label{eqnA.3a} \\\\\n& \\genfrac{[}{]}{0pt}{0}{n+1}{k} = \\genfrac{[}{]}{0pt}{0}{n}{k-1} + n \\genfrac{[}{]}{0pt}{0}{n}{k}. \\label{eqnA.3b}\n\\end{align}\n\\end{subequations}\n\nIt is possible to show this recurrence relation using either the definition of the Stirling numbers of first kind based on the rising or falling factorials or by using their combinatorial definition based on permutations. The first few Stirling numbers of the first kind are presented within Table \\ref{tabA.1}.\n\n\\begin{table}[!htbp]\n\\centering\n\\caption{Stirling numbers of the first kind.}\n\\label{tabA.1}\n\\begin{tabular}{ccccccc}\n\\toprule\n$n \\backslash k$ & 0 & 1 & 2 & 3 & 4 & 5 \\\\\n\\cmidrule(lr){1-7}\n0 & 1 & & & & & \\\\\n1 & 0 & 1 & & & & \\\\\n2 & 0 & 1 & 1 & & & \\\\\n3 & 0 & 2 & 3 & 1 & & \\\\\n4 & 0 & 6 & 11 & 6 & 1 & \\\\\n5 & 0 & 24 & 50 & 35 & 10 & 1 \\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\nFor a fixed value of $n$, the sum of all the Stirling numbers of the first kind over $k$ from $0$ to $n$ yields factorial $n$, which can be computed from the rising factorial with $x$ equal $1$.\n\n\\begin{equation} \\label{eqnA.4}\n\\forall n \\in \\mathbb{N} ,\\, \\sum_{k=0}^{n} \\genfrac{[}{]}{0pt}{0}{n}{k} = n! = \\genfrac{[}{]}{0pt}{0}{n+1}{1}\n\\end{equation}\n\nUsing the recursive relation \\eqref{eqnA.3}, it is trivial to show that the right side equality of \\eqref{eqnA.4} holds.\n\n\\begin{figure}[!htbp]\n\\centering\n\\begin{tikzpicture}\n% Set left\n\\draw (-4,+0) node(n11)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n12)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n13)[circle,draw=black,inner sep=1pt] {$3$};\n% Set middle\n\\draw (+0,+0) node(n21)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n22)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n23)[circle,draw=black,inner sep=1pt] {$3$};\n% Set right\n\\draw (+4,+0) node(n31)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n32)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n33)[circle,draw=black,inner sep=1pt] {$3$};\n% Arrows set 1\n\\draw[->] (n11) edge [bend left] (n12);\n\\draw[->] (n12) edge [bend left] (n11);\n\\draw[->] (n13) edge [loop,out=105,in=75,looseness=11] (n13);\n% Arrows set 2\n\\draw[->] (n22) edge [bend left] (n23);\n\\draw[->] (n23) edge [bend left] (n22);\n\\draw[->] (n21) edge [loop,out=105,in=75,looseness=11] (n21);\n% Arrows set 3\n\\draw[->] (n33) edge [bend left] (n31);\n\\draw[->] (n31) edge [bend left] (n33);\n\\draw[->] (n32) edge [loop,out=105,in=75,looseness=11] (n32);\n\\end{tikzpicture}\n\\caption{Cycle representations of the Stirling number of the first kind with $n=3$ and $k=2$.}\n\\label{figA.1}\n\\end{figure}\n\nFigure \\ref{figA.1} represents the different cycles linked to the Stirling number of the first kind with a set of $n=3$ elements and $k=2$ cycles. The total number of ways to partition the set is $3$. In this case, all three partitions have a cycle composed of $2$ elements and a cycle of a single element.\n\n\\section{Stirling Numbers of the Second Kind}\n\nThe Stirling numbers of the second kind represent the number of ways to partition a set of $n$ elements into $k$ non-empty non-overlapping subsets. These numbers are the inverse to the Stirling numbers of the first kind. Similarly to the Stirling number of the first kind, they can be computed based on the generating function consisting of the rising and falling factorials \\eqref{eqnA.5}, such that,\n\n\\begin{equation} \\label{eqnA.5}\n\\forall n \\in \\mathbb{N} ,\\, x^{n} = \\sum_{k=0}^{n} \\genfrac{\\{}{\\}}{0pt}{0}{n}{k} (x)_{k} = \\sum_{k=0}^{n} (-1)^{n-k}\\genfrac{\\{}{\\}}{0pt}{0}{n}{k} x^{(k)}\n\\end{equation}\n\nIt can be proved that there exists a recurrence relation between the Stirling number of the second kind based on their definition from the falling factorial. The recurrence relation is as follows,\n\n\\begin{subequations} \\label{eqnA.6}\n\\begin{align}\n\\forall (n,k) \\in \\mathbb{N}^{*} \\times \\mathbb{N}^{*} ,\\, & \\genfrac{\\{}{\\}}{0pt}{0}{0}{0} = 1 ,\\, \\genfrac{\\{}{\\}}{0pt}{0}{n}{0} = \\genfrac{\\{}{\\}}{0pt}{0}{0}{n} = 0, \\label{eqnA.6a} \\\\\n& \\genfrac{\\{}{\\}}{0pt}{0}{n+1}{k} = k \\genfrac{\\{}{\\}}{0pt}{0}{n}{k} + \\genfrac{\\{}{\\}}{0pt}{0}{n}{k-1}. \\label{eqnA.6b}\n\\end{align}\n\\end{subequations}\n\nTable \\ref{tabA.2} presents the first few Stirling numbers of the second kind which highlights the recurrence relation presented previously.\n\n\\begin{table}[!htbp]\n\\centering\n\\caption{Stirling numbers of the second kind.}\n\\label{tabA.2}\n\\begin{tabular}{ccccccc}\n\\toprule\n$n \\backslash k$ & 0 & 1 & 2 & 3 & 4 & 5 \\\\\n\\cmidrule(lr){1-7}\n0 & 1 & & & & & \\\\\n1 & 0 & 1 & & & & \\\\\n2 & 0 & 1 & 1 & & & \\\\\n3 & 0 & 1 & 3 & 1 & & \\\\\n4 & 0 & 1 & 7 & 6 & 1 & \\\\\n5 & 0 & 1 & 15 & 25 & 10 & 1 \\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\nThere is an explicit formula used to compute the Stirling numbers of the second kind relying on factorials, this formula is as follows,\n\n\\begin{equation} \\label{eqnA.7}\n\\genfrac{\\{}{\\}}{0pt}{0}{n}{k} = \\frac{1}{k!} \\sum_{i=0}^{k} (-1)^{k-i} \\genfrac{(}{)}{0pt}{0}{k}{i} i^{n}.\n\\end{equation}\n\nThe total number of ways to partition a set with $n$ elements into non-empty non-overlapping subsets is defined by the Bell number. Consequently, the $n$-th Bell number $B_{n}$ is equal to the sum of the Stirling numbers of the second kind such that,\n\n\\begin{equation} \\label{eqnA.8}\n\\forall n \\in \\mathbb{N} ,\\, \\sum_{k=0}^{n} \\genfrac{\\{}{\\}}{0pt}{0}{n}{k} = B_{n}.\n\\end{equation}\n\nIn order to have an idea of the distinct ways to partition a set of $n$ elements into $k$ non-empty non-overlapping subsets, the Figure \\ref{figA.2} illustrates all the different partitioning ways with $n=4$ and $k=2$. In this case, there are $6$ possible ways the partition the set of four elements, each one is composed of a subset composed of two elements as well as two subsets with a single element.\n\n\\begin{figure}[!htbp]\n\\centering\n\\begin{tikzpicture}[every node/.style={outer sep=8pt}]\n% Set top left\n\\draw (-4,+2.5) node(n11)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n12)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n13)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n14)[circle,draw=black,inner sep=1pt] {$4$};\n% Set top middle\n\\draw (+0,+2.5) node(n21)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n22)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n23)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n24)[circle,draw=black,inner sep=1pt] {$4$};\n% Set top right\n\\draw (+4,+2.5) node(n31)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n32)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n33)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n34)[circle,draw=black,inner sep=1pt] {$4$};\n% Set bottom left\n\\draw (-4,+0) node(n41)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n42)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n43)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n44)[circle,draw=black,inner sep=1pt] {$4$};\n% Set bottom middle\n\\draw (+0,+0) node(n51)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n52)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n53)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n54)[circle,draw=black,inner sep=1pt] {$4$};\n% Set bottom right\n\\draw (+4,+0) node(n61)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n62)[circle,draw=black,inner sep=1pt] {$2$} +(1,1) node(n63)[circle,draw=black,inner sep=1pt] {$3$} +(0,1) node(n64)[circle,draw=black,inner sep=1pt] {$4$};\n% Subsets\n\\path[draw=black,rounded corners=10pt] (n11.south east) -- (n14.north east) -- (n14.north west) -- (n11.south west) -- cycle;\n\\path[draw=black,rounded corners=10pt] (n21.south) -- (n23.east) -- (n23.north) -- (n21.west) -- cycle;\n\\path[draw=black,rounded corners=10pt] (n31.south west) -- (n32.south east) -- (n32.north east) -- (n31.north west) -- cycle;\n\\path[draw=black,rounded corners=10pt] (n42.south east) -- (n43.north east) -- (n43.north west) -- (n42.south west) -- cycle;\n\\path[draw=black,rounded corners=10pt] (n52.east) -- (n54.north) -- (n54.west) -- (n52.south) -- cycle;\n\\path[draw=black,rounded corners=10pt] (n64.south west) -- (n63.south east) -- (n63.north east) -- (n64.north west) -- cycle;\n\\end{tikzpicture}\n\\caption{Set partitions representing the Stirling number of the second kind with $n=4$ and $k=3$.}\n\\label{figA.2}\n\\end{figure}\n\n\\section{Lah Numbers}\n\nThe Lah numbers, also sometimes called the Stirling numbers of the third kind, represent the number of ways to partition a set of $n$ elements into $k$ non-empty non-overlapping ordered subsets. Similarly to the Stirling number of the first and second kinds, the Lah numbers can be generated using the rising factorial as follows,\n\n\\begin{equation} \\label{eqnA.9}\nx^{(n)} = \\sum_{k=1}^{n} \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k} (x)_{k}.\n\\end{equation}\n\nIn the same fashion as for the Stirling numbers of the first and second kinds, the Lah numbers are linked to the falling factorial, the relation is as follows,\n\n\\begin{equation} \\label{eqnA.10}\n(x)_{n} = \\sum_{k=1}^{n} (-1)^{n-k} \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k} x^{(k)}.\n\\end{equation}\n\nThe Lah numbers can be calculated by using the following recurrence relation,\n\n\\begin{subequations} \\label{eqnA.11}\n\\begin{align}\n\\forall (n,k) \\in \\mathbb{N}^{*} \\times \\mathbb{N}^{*} ,\\, & \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{0}{0} = 1 ,\\, \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{0} = \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{0}{n} = 0, \\label{eqnA.11a} \\\\\n& \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n+1}{k} = (n+k)\\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k} + \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k-1}. \\label{eqnA.11b}\n\\end{align}\n\\end{subequations}\n\nHowever, in this case, an explicit formula to compute these numbers exists based on binomial coefficients and factorials exists and is given by,\n\n\\begin{equation} \\label{eqnA.12}\n\\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k} = \\genfrac{(}{)}{0pt}{0}{n-1}{k-1} \\frac{n!}{k!}.\n\\end{equation}\n\nSome properties of the Lah numbers can be proved by recurrence, for example,\n\n\\begin{subequations} \\label{eqnA.13}\n\\begin{align}\n\\forall n \\in \\mathbb{N}^{*} ,\\, & \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{1} = n!, \\label{eqnA.13a} \\\\\n& \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{n} = 1, \\label{eqnA.13b} \\\\\n& \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{n-1} = n(n-1). \\label{eqnA.13c}\n\\end{align}\n\\end{subequations}\n\nFinally, Table \\ref{tabA.3} presents the first Lah numbers for $n$ less or equal to $5$. The distinct ways to partition a set of $n=3$ elements into $k=2$ non-empty non-overlapping ordered subsets is represented Figure \\ref{figA.3}. In this case, there are $6$ different partitions possible, every partition is composed of an ordered subset including two elements and a subset composed of a single element.\n\n\\begin{table}[!htbp]\n\\centering\n\\caption{Lah numbers.}\n\\label{tabA.3}\n\\begin{tabular}{ccccccc}\n\\toprule\n$n \\backslash k$ & 0 & 1 & 2 & 3 & 4 & 5 \\\\\n\\cmidrule(lr){1-7}\n0 & 1 & & & & & \\\\\n1 & 0 & 1 & & & & \\\\\n2 & 0 & 2 & 1 & & & \\\\\n3 & 0 & 6 & 6 & 1 & & \\\\\n4 & 0 & 24 & 36 & 12 & 1 & \\\\\n5 & 0 & 120 & 240 & 120 & 20 & 1 \\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\n\\begin{figure}[!htbp]\n\\centering\n\\begin{tikzpicture}\n% Set top left\n\\draw (-4,+2.25) node(n11)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n12)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n13)[circle,draw=black,inner sep=1pt] {$3$};\n% Set top middle\n\\draw (+0,+2.25) node(n21)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n22)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n23)[circle,draw=black,inner sep=1pt] {$3$};\n% Set top right\n\\draw (+4,+2.25) node(n31)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n32)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n33)[circle,draw=black,inner sep=1pt] {$3$};\n% Set bottom left\n\\draw (-4,+0) node(n41)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n42)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n43)[circle,draw=black,inner sep=1pt] {$3$};\n% Set bottom middle\n\\draw (+0,+0) node(n51)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n52)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n53)[circle,draw=black,inner sep=1pt] {$3$};\n% Set bottom right\n\\draw (+4,+0) node(n61)[circle,draw=black,inner sep=1pt] {$1$} +(1,0) node(n62)[circle,draw=black,inner sep=1pt] {$2$} +(0.5,1) node(n63)[circle,draw=black,inner sep=1pt] {$3$};\n% Arrows set 1\n\\draw[->] (n11) -- (n12);\n% Arrows set 2\n\\draw[->] (n22) -- (n23);\n% Arrows set 3\n\\draw[->] (n33) -- (n31);\n% Arrows set 4\n\\draw[->] (n42) -- (n41);\n% Arrows set 5\n\\draw[->] (n53) -- (n52);\n% Arrows set 6\n\\draw[->] (n61) -- (n63);\n\\end{tikzpicture}\n\\caption{Ordered subsets representing the Lah number with $n=3$ and $k=2$.}\n\\label{figA.3}\n\\end{figure}\n\n\\section{Relations Between the Stirling and Lah Numbers}\n\nThe three different combinatorial numbers presented within the previous sections of this appendix are related. It can be seen that they represent a change in basis for polynomial functions as it is pictured by Figure \\ref{figA.4}. A Polynomial function can be expressed uniquely with the canonical polynomial basis or with the polynomial basis generated from the rising and the falling factorials. The Figure \\ref{figA.4} presents how these numbers connect the three polynomial basis mentioned previously. Therefore, it means that the Stirling number of the first and second kind can be considered as inverses when they form lower triangular matrices whose entries are the Stirling numbers with corresponding row and column indexes. Similarly, as it can be seen Figure \\ref{figA.4}, the Lah numbers and the Lah numbers multiplied by $(-1)^{n-k}$ can be seen as inverses when they compose the entries of lower triangular matrices. Finally, since these three combinatorial numbers represent different ways to partition a set of $n$ elements into $k$ subsets being respectively unordered, cyclically ordered and linearly ordered, the following inequalities naturally arise,\n\n\\begin{equation} \\label{eqnA.14}\n\\forall (n,k) \\in \\mathbb{N} \\times \\mathbb{N} ,\\, \\genfrac{\\{}{\\}}{0pt}{0}{n}{k} \\leq \\genfrac{[}{]}{0pt}{0}{n}{k} \\leq \\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k}\n\\end{equation}\n\n\\begin{figure}[!htbp]\n\\centering\n\\begin{tikzpicture}\n% Nodes basis\n\\node (n1) at (0,5) {$x^{n}$};\n\\node (n2) at (-3,0) {$x^{(n)}$};\n\\node (n3) at (3,0) {$(x)_{n}$};\n% Arrows\n\\draw[->] (n1) -- node[anchor=north east]{$\\genfrac{\\{}{\\}}{0pt}{0}{n}{k}$} (n3);\n\\draw (n3) edge[bend right,->] node[anchor=south west]{$(-1)^{n-k}\\genfrac{[}{]}{0pt}{0}{n}{k}$} (n1);\n\\draw[->] (n3) -- node[anchor=south]{$\\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k}$} (n2);\n\\draw (n2) edge[bend right,->] node[anchor=north]{$(-1)^{n-k}\\genfrac{\\lfloor}{\\rfloor}{0pt}{0}{n}{k}$} (n3);\n\\draw[->] (n2) -- node[anchor=north west]{$\\genfrac{[}{]}{0pt}{0}{n}{k}$} (n1);\n\\draw (n1) edge[bend right,->] node[anchor=south east]{$(-1)^{n-k}\\genfrac{\\{}{\\}}{0pt}{0}{n}{k}$} (n2);\n\\end{tikzpicture}\n\\caption{Relations between the Stirling and Lah numbers.}\n\\label{figA.4}\n\\end{figure}", "meta": {"hexsha": "00243f0eb2ab17c1ffe8fa42d74b4758d1c3d5b1", "size": 17417, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Appendices/appendixA.tex", "max_stars_repo_name": "RockyRock/ThesisTexTemplate", "max_stars_repo_head_hexsha": "542ac874bdedd3eb6961da8f4211da4b099bff50", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-02-10T11:07:18.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-28T16:45:20.000Z", "max_issues_repo_path": "Appendices/appendixA.tex", "max_issues_repo_name": "RockyRock/ThesisTexTemplate", "max_issues_repo_head_hexsha": "542ac874bdedd3eb6961da8f4211da4b099bff50", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Appendices/appendixA.tex", "max_forks_repo_name": "RockyRock/ThesisTexTemplate", "max_forks_repo_head_hexsha": "542ac874bdedd3eb6961da8f4211da4b099bff50", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.1122807018, "max_line_length": 1170, "alphanum_fraction": 0.6636045243, "num_tokens": 6295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832354982645, "lm_q2_score": 0.7853085808877581, "lm_q1q2_score": 0.42326815979143445}}
{"text": "\\subsection{Combining transformation functions}\n\\label{subsec:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions}\n\nThe previous sections discussed the combination of instance models and instance graphs. In this section, the combination of transformation functions between instance models and instance graphs is discussed. This combination is the last key element shown in \\cref{fig:transformation_framework:instance_models_and_instance_graphs:structure_instance_models_graphs}. If it is possible to combine $f_A$ and $f_B$ into $f_{A} \\sqcup f_{B}$, then it is possible to build transformation functions between instance models and instance graphs iteratively.\n\nBefore it is possible to define a definition for the combination of two transformation functions, it is essential to define what functions are considered to be transformation functions.\n\n\\begin{defin}[Transformation function from an instance model to an instance graph]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}\nLet $f$ be a function from instance models to instance graphs, $Im$ be an instance model and $IG$ the corresponding instance graph. $f$ is a transformation function iff:\n\\begin{itemize}\n    \\item $f$ projects $Im$ onto $IG$: $f(Im) = IG$;\n    \\item After combination with another instance model, $f$ preserves the type graph;\n    \\item After combination with another instance model, $f$ preserves the nodes:\\\\$\\forall Im_x\\!: N_{f(Im)} \\subseteq N_{f(\\mathrm{combine}(Im, Im_x))}$;\n    \\item After combination with another instance model, $f$ preserves the edges:\\\\$\\forall Im_x\\!: E_{f(Im)} \\subseteq E_{f(\\mathrm{combine}(Im, Im_x))}$;\n    \\item For all identities in the projected instance graph, $f$ preserves the value of the identity if the instance model is combined with another instance model:\\\\$\\forall Im_x\\!: \\forall i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f(Tm)}\\!: \\mathrm{ident}_{f(Im)}(i) = \\mathrm{ident}_{f(\\mathrm{combine}(Im, Im_x))}(i)$.\n\\end{itemize}\n\\isabellelref{ig_combine_mapping_function}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\nAs expected, a transformation must project some instance model $Im$ to its corresponding instance graph $IG$. Furthermore, it has to preserve properties of the projection, even after $Im$ is combined with some other instance model. The rationale behind these properties is that after combining $Im$ with some other instance model, there must still be a way to transform the elements that originated from $Im$. If that is possible, it is possible to use the transformation function as the basis for the combined transformation function, which can transform the combined instance model to a combined instance graph.\n\nThe following definition will describe how two transformation functions from instance models to instance graphs can be combined into a new transformation function, which projects the combination of two instance models onto the combination of the two corresponding instance graphs.\n\n\\begin{defin}[Combination of transformation functions from an instance model to an instance graph]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_model_instance_graph}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. $f_A$ projects an instance model $Im_A$ onto instance graph $IG_A$. $f_B$ projects an instance model $Im_B$ onto instance graph $IG_B$. Then the combination of $f_A$ and $f_B$ is defined as:\n\\begin{align*}\nf_{A} \\sqcup f_{B}(Im) =\\ &\\langle&\nN =\\ &\\{n \\mid n \\in N_{f_{A}(Im)} \\land n \\in N_{IG_A} \\} \\cup \\{n \\mid n \\in N_{f_{B}(Im)} \\land n \\in N_{IG_B} \\} \\\\&&\nE =\\ &\\{e \\mid e \\in E_{f_{A}(Im)} \\land e \\in E_{IG_A} \\} \\cup \\{e \\mid e \\in E_{f_{B}(Im)} \\land e \\in E_{IG_B} \\} \\\\&&\n\\mathrm{ident} =\\ &\\mathrm{ident\\_\\!mapping}(f_A, IG_A, f_B, IG_B, Im)\n\\rangle\n\\end{align*}\nIn which $\\mathrm{ident\\_\\!mapping}$ is given as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ident_mapping}\n\\isabellelref{ig_combine_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\nLike the combination of transformations functions from a type model to a type graph, the combination of transformations functions from an instance model to an instance graph follows the combination of instance graphs closely. The definition is an alternation of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:combine}. As shown for type models and type graphs, this is the desired behaviour, as the combination of the transformation functions should be able to transform the combination of two instance models to the combination of the two corresponding instance graphs.\n\nUnsurprisingly, the definition of the identity function of $f_{A} \\sqcup f_{B}$ is very similar to \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ident_combine}.\n\n\\begin{defin}[Combination of the identity function for two transformation functions]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ident_mapping}\n$\\mathrm{ident\\_\\!mapping}(f_A, IG_A, f_B, IG_B, Im)$ is a partial function on two transformation functions $f_A$ and $f_B$, their corresponding projections $IG_A$ and $IG_B$ and an instance model $Im$ which returns a new function \\\\$Id \\Rightarrow (N_{f_{A} \\sqcup f_{B}(Im)} \\cap Node_t)$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{ident\\_\\!combine}(f_A, IG_A, f_B, IG_B, Im, i) = \\\\\n    \\begin{cases}\n        \\mathrm{ident}_{f_A(Im)}(i) & \\mathrm{if }\\ i \\in \\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\}\\ \\cap\\\\&\\quad \\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\} \\land \\mathrm{ident}_{f_A(Im)}(i) = \\mathrm{ident}_{IG_B}(i) \\\\\n        \\mathrm{ident}_{f_A(Im)}(i) & \\mathrm{if }\\ i \\in \\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\}\\ \\setminus\\\\&\\quad\\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\} \\\\\n        \\mathrm{ident}_{f_B(Im)}(i) & \\mathrm{if }\\ i \\in \\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\}\\ \\setminus\\\\&\\quad\\{i \\mid i \\in \\mathrm{dom}\\ \\mathrm{ident}_{f_{A}(Im)} \\land i \\in \\mathrm{dom}\\ \\mathrm{ident}_{IG_A} \\}\n    \\end{cases}\n\\end{multline*}\n\\end{defin}\n\nWith these definitions in place, it is possible to provide the necessary theorems for the correctness of the combined function $f_{A} \\sqcup f_{B}$.\n\n\\begin{thm}[The projection of a combined transformation function from an instance model to an instance graph]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ig_combine_mapping_correct}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. $f_A$ projects an instance model $Im_A$ onto instance graph $IG_A$. $f_B$ projects an instance model $Im_B$ onto instance graph $IG_B$. Then the combination of $f_A$ and $f_B$, $f_{A} \\sqcup f_{B}$ projects $\\mathrm{combine}(Im_A, Im_B)$ onto $\\mathrm{combine}(IG_A, IG_B)$, so:\n\\begin{equation*}\n    f_{A} \\sqcup f_{B}(\\mathrm{combine}(Im_A, Im_B)) = \\mathrm{combine}(IG_A, IG_B)\n\\end{equation*}\n\\isabellelref{ig_combine_mapping_correct}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{thm}\n\n\\begin{proof}\nThe corresponding proof follows directly from \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_model_instance_graph} as well as \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. Since the individual transformation functions $f_A$ and $f_B$ preserve the elements of their instance graphs when the instance model is combined with another one, we can establish that the definition of $f_{A} \\sqcup f_{B}$ is equal to the definition of $\\mathrm{combine}(IG_A, IG_B)$. Therefore, $f_{A} \\sqcup f_{B}(\\mathrm{combine}(Im_A, Im_B)) = \\mathrm{combine}(IG_A, IG_B)$.\n\\end{proof}\n\nAlthough the presented theorem is a large step towards being able to build transformation functions from instance models to instance graphs iteratively, there is still one key element missing. It should be formally argued that $f_{A} \\sqcup f_{B}$ is once again an transformation function in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. If this is formally argued, it becomes possible to easily combine $f_{A} \\sqcup f_{B}$ with yet another transformation function. The following theorem states this property.\n\n\\begin{thm}[A combined transformation function from an instance model to an instance graph is a transformation function]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:ig_combine_mapping_function_correct}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. $f_A$ projects an instance model $Im_A$ onto instance graph $IG_A$. $f_B$ projects an instance model $Im_B$ onto instance graph $IG_B$. Then the combination of $f_A$ and $f_B$, $f_{A} \\sqcup f_{B}$ is again a transformation function in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph} which projects $\\mathrm{combine}(Im_A, Im_B)$ onto $\\mathrm{combine}(IG_A, IG_B)$.\n\\isabellelref{ig_combine_mapping_function_correct}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{thm}\n\n\\begin{proof}\nUse \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}. Since the individual transformation functions $f_A$ and $f_B$ preserve the elements of their instance graphs when the instance model is combined with another one, we can establish that the definition of $f_{A} \\sqcup f_{B}$ will also preserve these elements. This can be shown using the commutativity and associativity of the combination of instance models, see \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_commute} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_assoc} respectively.\n\\end{proof}\n\nThis last theorem completes the recursive behaviour of combining transformation functions and therefore allows for building transformation functions from instance models to instance graphs iteratively.\n\nThe definitions and theorems that are presented so far only work in one direction: for transforming instance models into instance graphs. As visually shown in \\cref{fig:transformation_framework:instance_models_and_instance_graphs:structure_instance_models_graphs}, it must also be possible to transform instance graphs back into instance models. The definitions and theorems needed for this transformation are similar and will be presented in the remaining part of this section.\n\n\\begin{defin}[Transformation function from an instance graph to an instance model]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}\nLet $f$ be a function from instance graphs to instance models, $IG$ be an instance graph and $Im$ the corresponding instance model. $f$ is a transformation function iff:\n\\begin{itemize}\n    \\item $f$ projects $IG$ onto $Im$: $f(IG) = Im$;\n    \\item After combination with another instance graph, $f$ preserves the type model;\n    \\item After combination with another instance graph, $f$ preserves the objects:\\\\$\\forall IG_x\\!: Object_{f(IG)} \\subseteq Object_{f(\\mathrm{combine}(IG, IG_x))}$;\n    \\item For all objects in the projected instance model, $f$ preserves the object class if the instance graph is combined with another instance graph:\\\\$\\forall IG_x\\!: \\forall o \\in Object_{f(IG)}\\!: \\mathrm{ObjectClass}_{f(IG)}(o) = \\mathrm{ObjectClass}_{f(\\mathrm{combine}(IG, IG_x))}(o)$;\n    \\item For all objects in the projected instance model, $f$ preserves the object identifier if the instance graph is combined with another instance graph:\\\\$\\forall IG_x\\!: \\forall o \\in Object_{f(IG)}\\!: \\mathrm{ObjectId}_{f(IG)}(o) = \\mathrm{ObjectId}_{f(\\mathrm{combine}(IG, IG_x))}(o)$;\n    \\item For all objects in the projected instance model and all fields in the type model corresponding to the projected instance model, $f$ preserves the field value if the instance graph is combined with another instance graph:\\\\$\\forall IG_x\\!: \\forall o \\in Object_{f(IG)}\\!: \\forall d \\in Field_{Tm_{f(IG)}}\\!:$\\\\$ \\mathrm{FieldValue}_{f(IG)}(( o, d )) = \\mathrm{FieldValue}_{f(\\mathrm{combine}(IG, IG_x))}(( o, d ))$;\n    \\item For all constants in the type model corresponding to the projected instance model, $f$ preserves the default value if the instance graph is combined with another instance graph:\\\\$\\forall IG_x\\!: \\forall c \\in Constant_{Tm_{f(IG)}}\\!: \\mathrm{DefaultValue}_{f(IG)}(c) = \\mathrm{DefaultValue}_{f(\\mathrm{combine}(IG, IG_x))}(c)$;\n\\end{itemize}\n\\isabellelref{imod_combine_mapping_function}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\nJust like \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph}, the definition of transformation functions from an instance graph to an instance model preserves all elements if the instance graph is combined with another instance graph. This will once more be the key to having the property of iterative building of transformation functions.\n\nThe following definition will describe how two transformation functions from instance graphs to instance models can be combined into a new transformation function, which projects the combination of two instance graphs onto the combination of the two corresponding instance models.\n\n\\begin{defin}[Combination of transformation functions from an instance graph to an instance model]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_graph_instance_model}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. $f_A$ projects an instance graph $IG_A$ onto instance model $Im_A$. $f_B$ projects an instance graph $IG_B$ onto instance model $Im_B$. Then the combination of $f_A$ and $f_B$ is defined as:\n\\begin{align*}\nf_{A} \\sqcup f_{B}(IG) =\\ &\\langle&\nObject =\\ &\\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\cup\\\\&&&\n\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\} \\\\&&\n\\mathrm{ObjectClass} =\\ &\\mathrm{objectclass\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG) \\\\&&\n\\mathrm{ObjectId} =\\ &\\mathrm{objectid\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG) \\\\&&\n\\mathrm{FieldValue} =\\ &\\mathrm{fieldvalue\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG) \\\\&&\n\\mathrm{ConstType} =\\ &\\mathrm{consttype\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG) \\\\&\n\\rangle\n\\end{align*}\nIn which $\\mathrm{objectclass\\_\\!mapping}$ is given as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:objectclass_mapping}, $\\mathrm{objectid\\_\\!mapping}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:objectid_mapping}, $\\mathrm{fieldvalue\\_\\!mapping}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:fieldvalue_mapping} and $\\mathrm{defaultvalue\\_\\!mapping}$ as part of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:defaultvalue_mapping}.\n\\isabellelref{imod_combine_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\nAs expected, the definition for the combination of transformation functions from an instance graph to an instance model is an alternation of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:combine}. This alternation will once more allow the combined transformation function to project the combination of the instance graphs to the combination of the corresponding instance models.\n\nThe following four definitions will provide the remaining functions, which will closely follow their counterparts from \\cref{subsec:transformation_framework:instance_models_and_instance_graphs:combining_instance_models}.\n\n\\begin{defin}[Combination of the object class function for two transformation functions]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:objectclass_mapping}\n$\\mathrm{objectclass\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG)$ is a partial function on two transformation functions $f_A$ and $f_B$, their corresponding projections $Im_A$ and $Im_B$ and an instance model $IG$ which returns a new function $Object_{f_{A} \\sqcup f_{B}(IG)} \\Rightarrow Class_{Tm_{f_{A} \\sqcup f_{B}(IG)}}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{objectclass\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG, o) = \\\\\n    \\begin{cases}\n        \\mathrm{ObjectClass}_{f_{A}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\cap \\\\&\\qquad\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\land \\\\&\\quad \\mathrm{ObjectClass}_{f_{A}(IG)}(o) = \\mathrm{ObjectClass}_{f_{B}(IG)}(o) \\\\\n        \\mathrm{ObjectClass}_{f_{A}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\setminus \\\\&\\qquad\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\} \\\\\n        \\mathrm{ObjectClass}_{f_{B}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\setminus \\\\&\\qquad\\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_object_class_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\n\\begin{defin}[Combination of the object identifier function for two transformation functions]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:objectid_mapping}\n$\\mathrm{objectid\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG)$ is a partial function on two transformation functions $f_A$ and $f_B$, their corresponding projections $Im_A$ and $Im_B$ and an instance model $IG$ which returns a new function $Object_{f_{A} \\sqcup f_{B}(IG)} \\Rightarrow Name$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{objectid\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG, o) = \\\\\n    \\begin{cases}\n        \\mathrm{ObjectId}_{f_{A}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\cap \\\\&\\qquad\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\land \\\\&\\quad \\mathrm{ObjectId}_{f_{A}(IG)}(o) = \\mathrm{ObjectId}_{f_{B}(IG)}(o) \\\\\n        \\mathrm{ObjectId}_{f_{A}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\setminus \\\\&\\qquad\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\} \\\\\n        \\mathrm{ObjectId}_{f_{B}(IG)}(o) & \\mathrm{if }\\ o \\in \\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\setminus \\\\&\\qquad\\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_object_id_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\n\\begin{defin}[Combination of the default value function for two transformation functions]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:defaultvalue_mapping}\n$\\mathrm{defaultvalue\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG)$ is a partial function on two transformation functions $f_A$ and $f_B$, their corresponding projections $Im_A$ and $Im_B$ and an instance model $IG$ which returns a new function $Constant_{Tm_{f_{A} \\sqcup f_{B}(IG)}} \\Rightarrow Value_{f_{A} \\sqcup f_{B}(IG)}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{defaultvalue\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG, c) = \\\\\n    \\begin{cases}\n        \\mathrm{DefaultValue}_{f_{A}(IG)}(c) & \\mathrm{if }\\ c \\in \\{c \\mid c \\in Constant_{Tm_{f_{A}(IG)}} \\land c \\in Constant_{Tm_A} \\}\\ \\cap \\\\&\\qquad \\{c \\mid c \\in Constant_{Tm_{f_{B}(IG)}} \\land c \\in Constant_{Tm_B} \\}\\ \\land\\\\&\\quad \\mathrm{DefaultValue}_{f_{A}(IG)}(c) = \\mathrm{DefaultValue}_{f_{B}(IG)}(c) \\\\\n        \\mathrm{DefaultValue}_{f_{A}(IG)}(c) & \\mathrm{if }\\ c \\in \\{c \\mid c \\in Constant_{Tm_{f_{A}(IG)}} \\land c \\in Constant_{Tm_A} \\}\\ \\setminus \\\\&\\qquad \\{c \\mid c \\in Constant_{Tm_{f_{B}(IG)}} \\land c \\in Constant_{Tm_B} \\} \\\\\n        \\mathrm{DefaultValue}_{f_{B}(IG)}(c) & \\mathrm{if }\\ c \\in \\{c \\mid c \\in Constant_{Tm_{f_{B}(IG)}} \\land c \\in Constant_{Tm_B} \\}\\ \\setminus \\\\&\\qquad \\{c \\mid c \\in Constant_{Tm_{f_{A}(IG)}} \\land c \\in Constant_{Tm_A} \\}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_default_value_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\n\\begin{defin}[Combination of the field value function for two transformation functions]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:fieldvalue_mapping}\n$\\mathrm{fieldvalue\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG)$ is a partial function on two transformation functions $f_A$ and $f_B$, their corresponding projections $Im_A$ and $Im_B$ and an instance model $IG$ which returns a new function $(Object_{f_{A} \\sqcup f_{B}(IG)} \\times Field_{Tm_{f_{A} \\sqcup f_{B}(IG)}}) \\Rightarrow Value_{f_{A} \\sqcup f_{B}(IG)}$. It is defined as follows:\n\\begin{multline*}\n    \\mathrm{fieldvalue\\_\\!mapping}(f_A, Im_A, f_B, Im_B, IG, ( o, d )) = \\\\\n    \\begin{cases}\n        \\mathrm{FieldValue}_{f_{A}(IG)}(( o, d )) & \\mathrm{if}\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\cap \\\\&\\qquad\\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\land\\\\&\\quad d \\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{A}(IG)}}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o)) \\}\\ \\land\\\\&\\quad d \\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{B}(IG)}}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o)) \\}\\ \\land\\\\&\\quad \\mathrm{FieldValue}_{f_{A}(IG)}(( o, d )) = \\mathrm{FieldValue}_{f_{B}(IG)}(( o, d )) \\\\\n        \\mathrm{FieldValue}_{f_{A}(IG)}(( o, d )) & \\mathrm{if}\\ o \\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\land \\\\&\\quad d \\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{A}(IG)}}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o)) \\}\\ \\land\\\\&\\quad (o \\not\\in \\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\lor \\\\&\\quad d \\not\\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{B}(IG)}}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o)) \\} \\\\\n        \\mathrm{FieldValue}_{f_{B}(IG)}(( o, d )) & \\mathrm{if}\\ o \\in \\{o \\mid o \\in Object_{f_{B}(IG)} \\land o \\in Object_{Im_B} \\}\\ \\land \\\\&\\quad d \\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{B}(IG)}}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_B}(\\mathrm{ObjectClass}_{f_{B}(IG)}(o)) \\}\\ \\land\\\\&\\quad (o \\not\\in \\{o \\mid o \\in Object_{f_{A}(IG)} \\land o \\in Object_{Im_A} \\}\\ \\lor \\\\&\\quad d \\not\\in \\{d \\mid d \\in \\mathrm{fields}_{Tm_{f_{A}(IG)}}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o))\\ \\land \\\\&\\qquad\\quad d \\in \\mathrm{fields}_{Tm_A}(\\mathrm{ObjectClass}_{f_{A}(IG)}(o)) \\}\n    \\end{cases}\n\\end{multline*}\n\\isabellelref{imod_combine_field_value_mapping}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{defin}\n\nThe definitions of most of these combination functions are straightforward. Only the $\\mathrm{fieldvalue\\_\\!mapping}$ seems significantly more complicated. However, a careful ready will still be able to see that the definition is an alternation of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:fieldvalue_combine}. The definition seems more complicated because of the combination of objects and fields in the domain of the function.\n\nWith these definitions in place, it is possible to provide the necessary theorems for the correctness of the combined function $f_{A} \\sqcup f_{B}$.\n\n\\begin{thm}[The projection of a combined transformation function from an instance graph to an instance model]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:imod_combine_mapping_correct}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. $f_A$ projects an instance graph $IG_A$ onto instance model $Im_A$. $f_B$ projects an instance model $IG_B$ onto instance graph $Im_B$. Then the combination of $f_A$ and $f_B$, $f_{A} \\sqcup f_{B}$ projects $\\mathrm{combine}(IG_A, IG_B)$ onto $\\mathrm{combine}(Im_A, Im_B)$, so:\n\\begin{equation*}\n    f_{A} \\sqcup f_{B}(\\mathrm{combine}(IG_A, IG_B)) = \\mathrm{combine}(Im_A, Im_B)\n\\end{equation*}\n\\isabellelref{imod_combine_mapping_correct}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{thm}\n\n\\begin{proof}\nThe corresponding proof follows directly from \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:combination_transformation_function_instance_graph_instance_model} as well as \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. Since the individual transformation functions $f_A$ and $f_B$ preserve the elements of their instance models when the instance graph is combined with another one, we can establish that the definition of $f_{A} \\sqcup f_{B}$ is equal to the definition of $\\mathrm{combine}(Im_A, Im_B)$. Therefore, $f_{A} \\sqcup f_{B}(\\mathrm{combine}(IG_A, IG_B)) = \\mathrm{combine}(Im_A, Im_B)$.\n\\end{proof}\n\nLike the combined transformation function from instance models to instance graphs, the combined transformation function from instance graphs to instance models is also a transformation function, but in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. This is stated in the following theorem.\n\n\\begin{thm}[A combined transformation function from an instance graph to an instance model is a transformation function]\n\\label{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:imod_combine_mapping_function_correct}\nLet $f_A$ and $f_B$ be a transformation functions in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. $f_A$ projects an instance graph $IG_A$ onto instance model $Im_A$. $f_B$ projects an instance graph $IG_B$ onto instance model $Im_B$. Then the combination of $f_A$ and $f_B$, $f_{A} \\sqcup f_{B}$ is again a transformation function in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model} which projects $\\mathrm{combine}(IG_A, IG_B)$ onto $\\mathrm{combine}(Im_A, Im_B)$.\n\\isabellelref{imod_combine_mapping_function_correct}{Ecore-GROOVE-Mapping.Instance_Model_Graph_Mapping}\n\\end{thm}\n\n\\begin{proof}\nUse \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model}. Since the individual transformation functions $f_A$ and $f_B$ preserve the elements of their instance models when the instance graph is combined with another one, we can establish that the definition of $f_{A} \\sqcup f_{B}$ will also preserve these elements. This can be shown using the commutativity and associativity of the combination of instance graphs, see \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_commute} and \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_assoc} respectively.\n\\end{proof}", "meta": {"hexsha": "010ca9ed4e5880926ec7097aed550a158f378fff", "size": 29998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/03_combining_transformation_functions.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/03_combining_transformation_functions.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/04_transformation_framework/04_instance_models_and_instance_graphs/03_combining_transformation_functions.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 142.8476190476, "max_line_length": 787, "alphanum_fraction": 0.7706847123, "num_tokens": 8311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.538983220687684, "lm_q1q2_score": 0.4232681481605584}}
{"text": "\\documentclass[twocolumn,10pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{geometry}\n\n\\geometry{left=2cm,right=2cm,top=3cm,bottom=2.5cm}\n\n\\renewcommand{\\vec}[1]{\\mathbf{#1}}\n\\newcommand{\\omegap}{\\omega_{\\mathrm{pe}}}\n\\newcommand{\\ncrit}{n_{\\mathrm{cr}}}\n\\newcommand{\\vth}{v_{\\mathrm{th}}}\n\\newcommand{\\ldebye}{\\lambda_{\\mathrm{D}}}\n\n\\title{Units in VPIC}\n\\author{A.~G.~Seaton \\& S.~V.~Luedtke}\n\\begin{document}\n\\maketitle\n\n\n\nUnits in \\textsc{vpic} can be confusing.\nThey are user-defined, which can make inheriting a deck confusing for new users.\nThe reason for this flexibility is that common unit systems, such as SI, are not suitable for use in \\textsc{vpic} because of its use of IEEE 754 single precision floating point numbers.\nIn single precision, the smallest number representable with full precision is $2^{-126} \\approx 1.2\\times 10^{-38}$.\nAs an example, the SI value for $\\hbar$, $1.05\\times 10^{-34}$, is only four orders of magnitude away from losing precision.  Multiply it by the electron mass, and you are hopelessly lost.\n%\n%\t\\begin{itemize}\n%\t\t\\item $l_{\\mathrm{deck}}$: an implicit unit of length for the spatial grid\n%\t\t\\item $c_{\\mathrm{deck}}$: the speed of light in vacuum\n%\t\t\\item $\\varepsilon_{0,\\mathrm{deck}}$: the vacuum permittivity\n%\t\t\\item $r_{\\alpha,\\mathrm{deck}} \\equiv (q_{\\alpha}/m_{\\alpha})_{\\mathrm{deck}}$: The charge/mass ratio of species $\\alpha$.\n%\t\\end{itemize}\n\n\nTo set up a simulation, the user provides \\textsc{vpic} with values for the time step, cell dimensions, speed of light in vacuum, and vacuum permittivity.\nThis is either done by directly assigning to the \\texttt{grid} struct or by using the functions \\texttt{define\\_units}, \\texttt{define\\_timestep}, and (for example) \\texttt{define\\_periodic\\_grid}.\nUsually one or more species are defined too, which each require values for the species mass and charge.\nThese are normally set using the \\texttt{define\\_species} function.\nIt is important to understand that \\textsc{vpic} solves the same equations regardless of which values it is given and the chosen unit system.\n\n\nWe will assume here that two unit systems are in use.\nThe first of these we will refer to as the `user' unit system, and is the user's preferred unit system.\nThis is often used initially to define parameters of interest to the user, such as the temperature and density of the plasma.\nThe second we will refer to as the `code' unit system, which is used for values passed to \\textsc{vpic} itself.\nThis document is concerned primarily with the code unit system.\n\n\nWe will list some common unit systems for values supplied to \\textsc{vpic} later, but for now the primary concerns for choosing a system of units are twofold:\n\\begin{enumerate}\n\t\\item The units must be compatible with the SI \\emph{equation form} that is solved by \\textsc{vpic}, meaning that Gaussian units cannot be used.\n    \\item Values used by the code (including within calculations) should never exceed $\\pm1.7\\times 10^{38}$, and a value smaller than $\\pm1.2\\times 10^{-38}$ should not be meaningfully different from zero.\n\\end{enumerate}\n\n\n\n\\section{Unit Conversions}\n\nIn order to calculate values in the code unit system to supply to \\textsc{vpic}, we need to know the unit conversions.\nTaking the base units as length, time, mass, and charge, we define conversion factors $L$, $T$, $M$, and $Q$ so that a quantity $f_c$ in the code unit system is converted to a value $f_u$ in the user unit system using $f_u = Ff_c$.\n\nEach value supplied to \\textsc{vpic} can be used to constrain the unit system by writing an equation for its conversion from the user unit system to code units in terms of the base unit conversion factors.\nTherefore by picking a subset of these values, we can fully determine the unit system.\n\nTo determine what the four base unit conversion factors are, we need four constraining equations.\nThere are multiple sets of values we could choose.\nGiven the base units, a straightforward choice would be the timestep, cell size, and species mass and charge.\nHere instead we pick the cell size $h$, speed of light $c$, vacuum permittivity $\\varepsilon_0$, and the charge-mass ratio $r_{\\alpha}$ of some species $\\alpha$.\nThis is motivated by many common unit systems setting $\\varepsilon_{0,\\mathrm{c}} = 1$ or $c_{\\mathrm{c}} = 1$, as will be seen later.\n\nThe constraining equations are then:\n\n\\begin{align*}\n\th_{\\mathrm{c}}L                               &= h_{\\mathrm{u}},             &\n\tc_{\\mathrm{c}}\\frac{L}{T}                     &= c_{\\textrm{u}},             \\\\\n    \\varepsilon_{0,\\mathrm{c}}\\frac{Q^2T^2}{ML^3} &= \\varepsilon_{0,\\textrm{u}}, &\n    r_{\\alpha,\\mathrm{c}}\\frac{Q}{M}              &= r_{\\alpha,\\textrm{u}}.\n\\end{align*}\n\n\\noindent Solving for the conversion factors we find:\n\\begin{align}\n\tL &= \\frac{h_{\\mathrm{u}}}{h_{\\mathrm{c}}}, \\\\\n\tT &= \\frac{h_{\\mathrm{u}}}{h_{\\mathrm{c}}}\\frac{c_{\\mathrm{c}}}{c_{\\mathrm{u}}}, \\\\\n\tM &= \\frac{h_{\\mathrm{u}}}{h_{\\mathrm{c}}}\\left(\\frac{c_{\\mathrm{u}}}{c_{\\mathrm{c}}}\\right)^2\\frac{\\varepsilon_{0,\\mathrm{u}}}{\\varepsilon_{0,\\mathrm{c}}}\\left(\\frac{r_{\\alpha,\\mathrm{c}}}{r_{\\alpha,\\mathrm{u}}}\\right)^2, \\\\\n\tQ &= \\frac{h_{\\mathrm{u}}}{h_{\\mathrm{c}}}\\left(\\frac{c_{\\mathrm{u}}}{c_{\\mathrm{c}}}\\right)^2\\frac{\\varepsilon_{0,\\mathrm{u}}}{\\varepsilon_{0,\\mathrm{c}}}\\frac{r_{\\alpha,\\mathrm{c}}}{r_{\\alpha,\\mathrm{u}}}.\n\\end{align}\n\n\\noindent These can then be combined into factors for other quantities.\nFor example, the electric and magnetic field conversion factors $E$ and $B$ are given by\n\\begin{align}\n\tE &= \\frac{ML}{QT^2} = \\frac{h_{\\mathrm{c}}}{h_{\\mathrm{u}}}\\frac{r_{\\alpha,\\mathrm{c}}}{r_{\\alpha}}\\left(\\frac{c_{\\mathrm{u}}}{c_{\\mathrm{c}}}\\right)^2, \\\\\n\tB &= E\\frac{T}{L} = \\frac{h_{\\mathrm{c}}}{h_{\\mathrm{u}}}\\frac{r_{\\alpha,\\mathrm{c}}}{r_{\\alpha,\\mathrm{u}}}\\frac{c_{\\mathrm{u}}}{c_{\\mathrm{c}}}.\n\\end{align}\n\n\n\n\\subsection{Exceptions}\n\nIn addition to calculating the above conversion factors, the user should be aware of how \\textsc{vpic} normalises variables internally.\n\n\\subsubsection{Particle Momenta}\n\n\\textsc{vpic} stores relativistic momentum rather than velocity (which would cause numerical issues) for each particle.\nThe momentum is stored in dimensionless form given by\n\\begin{equation}\n    p_{\\textrm{norm}} = \\frac{p}{m_\\alpha c},\n\\end{equation}\nwhere $m_\\alpha$ is the mass assigned to species $\\alpha$ and $c$ is the speed of light in a vacuum.\nThis is what must be supplied by the user when performing the particle load.\n\n\\subsubsection{Magnetic Fields}\n\nFor performance reasons, and due to the use of single-precision floating point numbers, \\textsc{vpic} stores the scaled magnetic field $c\\vec{B}$ rather than $\\vec{B}$.\n\n\\section{Species \\& Particle Weighting}\n\nTo define a particle species in \\textsc{vpic}, the user specifies the species mass $m_{\\mathrm{s}}$ and charge $q_{\\mathrm{s}}$. Additionally, each particle is individually assigned a weighting factor $w$. These must be consistent with each other and the above unit system to produce the desired behavior.\n\n\\subsection{Choosing Charge Mass Ratio}\n\nThe motion of a physical particle with charge $q_{\\mathrm{p}}$ and mass $m_{\\mathrm{p}}$ in the EM fields only has explicit dependence on the charge-to-mass ratio $r \\equiv q_{\\mathrm{p}}/m_{\\mathrm{p}}$. This is also the case for macroparticles in \\textsc{vpic}'s particle push. Therefore the corresponding macroparticle species must be defined such that its charge $q_{\\mathrm{s}}$ and mass $m_{\\mathrm{s}}$ satisfy $q_{\\mathrm{s}}/m_{\\mathrm{s}}=r$.\n\n\\subsection{Choosing Macroparticle Weight}\nWhen calculating the fields generated by a macroparticle, the code uses the species charge and macroparticle weight to calculate a total charge for the macroparticle:\n\\begin{equation}\n\tq_{\\mathrm{MP}} = wq_{\\mathrm{s}}.\n\\end{equation}\nFor this to result in an amount of current deposition consistent with the desired physical particle density, the macroparticle weight should be defined such that the charge contained in volume $V$ is the same for the macroparticles as for physical particles, i.e.\n\\begin{align*}\n\tq_{\\mathrm{p}}n_{\\mathrm{p}}V &= q_{\\mathrm{MP}}n_{\\mathrm{MP}}V \\\\\n\t\t&= wq_{\\mathrm{s}}n_{\\mathrm{MP}}V,\n\\end{align*}\nwhere $n_{\\mathrm{p}}$ and $n_{\\mathrm{MP}}$ are the physical particle and macroparticle number densities (macroparticles per unit volume) respectively. So, the particle weight must satisfy\n\\begin{align}\n\tw = \\frac{q_{\\mathrm{p}}n_{\\mathrm{p}}}{q_{\\mathrm{s}}n_{\\mathrm{MP}}} = \\frac{\\rho_{\\mathrm{p}}}{\\rho_{\\mathrm{s}}}.\n\\end{align}\nThis illustrates that there is a degree of freedom available in that the species charge defined in the deck does not have to be the same as the physical species charge.\n\n\\subsection{Consequences of $q_{\\mathrm{s}} \\neq q_{\\mathrm{p}}$}\n\nThe possibility of $q_{\\mathrm{s}} \\neq q_{\\mathrm{p}}$ means that the code has no way of calculating numbers of physical particles since it doesn't store the true particle charge.\nThis for example is why the hydro dumps contain charge density rather than number density.\nUsers should therefore also ensure that any custom diagnostics do not assume $q_{\\mathrm{s}} = q_{\\mathrm{p}}$.\n\n\n\n\\section{Examples of Common Unit Systems}\n\nVarious choices are often made for the unit system, and we discuss a few of them here.\nIn general, aside from ensuring that values do not exceed the limits for single-precision floating point numbers, it is often desirable to choose a unit system that eases interpretation of simulation results.\nMany of these unit systems allow the governing equations to be written in simpler form, which are convenient in theoretical analysis, and we will illustrate some of these cases here.\nAs discussed above, the unit system has no bearing on the calculations performed by \\textsc{vpic} -- it always solves the full system of equations.\n\n\\subsection{Electrostatic Plasma Units}\n\nIn an electrostatic problem simulating an electron plasma, the natural length and time-scales are the Debye length $\\ldebye$ and inverse plasma frequency $\\omegap^{-1}$.\nThese are also the typical scales for the grid and time-step.\nThen choosing the electron charge/mass ratio so that $e/m_e$ becomes unity reduces the equation of motion of an electron to\n\\begin{equation*}\n\t\\ddot{\\vec{r}} = \\vec{E}.\n\\end{equation*}\nFinally setting $\\varepsilon_0=1$ means that Gauss' law is also simplified\n\\begin{equation*}\n\t\\nabla \\cdot \\vec{E} = \\rho.\n\\end{equation*}\n\n\\noindent In the deck we would specify\n\\begin{align*}\n\th_{\\mathrm{c}}             &= \\frac{h_{\\mathrm{u}}}{\\ldebye}, &\n\tc_{\\mathrm{c}}             &= \\frac{c}{\\vth},    \\\\\n\t\\varepsilon_{0,\\mathrm{c}} &= 1,                              &\n\tr_{e,\\mathrm{c}}           &= -1,\n\\end{align*}\n\n\\noindent giving the unit conversions as\n\\begin{align*}\n\tL &= \\ldebye,                  &\n\tT &= \\omegap^{-1},             &\n\tM &= N_{\\mathrm{D}}m_e,        \\\\\n\tQ &= N_{\\mathrm{D}}e,          &\n\tE &= \\frac{m_e}{e}\\vth\\omegap, &\n\tB &= \\frac{m_e}{e}\\omegap,\n\\end{align*}\n\n\\noindent where $N_{\\mathrm{D}} \\equiv n_e\\ldebye^3$ is the number of electrons in a `Debye cube'.\n\nThis unit system allows for some convenient sanity checks.\nAs mentioned above, the cell size and time-step must be around $1$.\nAdditionally, if the electron mass in these units is not significantly smaller than 1, then the plasma is not ideal, and simulating it with \\textsc{vpic} is not appropriate.\nInterpretation of simulation results may also be more convenient.\nFor example, the normalized electric field $E_c$ is the electron quiver velocity in a plasma wave divided by the thermal velocity -- an important parameter for determining whether wavebreaking will occur.\nSimilarly, the wavenumber of a plasma wave is normalised such that $k_c = k\\ldebye$, which determines the Landau damping rate.\n\n\\subsection{Electromagnetic Plasma Units}\n\nFor an electromagnetic problem, the electrostatic units above might be modified so that the length scale becomes the electron skin depth $l_e=c/\\omegap$.\nThe Lorentz force and Maxwell's equations become\n\\begin{equation*}\n\t\\ddot{\\vec{r}} = \\vec{E} + \\vec{v} \\times \\vec{B},\n\\end{equation*}\n\n\\noindent and\n\\begin{align*}\n\t\\nabla \\times \\vec{E} &= -\\partial_t \\vec{B}, \\\\\n\t\\nabla \\times \\vec{B} &= \\left(\\vec{J} + \\partial_t \\vec{E}\\right).\n\\end{align*}\n\n\\noindent The deck assignments become:\n\\begin{align*}\n\th_{\\mathrm{c}}             &= h_{\\mathrm{u}}\\frac{\\omegap}{c}, &\n\tc_{\\mathrm{c}}             &= 1, \\\\\n\t\\varepsilon_{0,\\mathrm{c}} &= 1, &\n\tr_{e,\\mathrm{c}}           &= -1,\n\\end{align*}\n\n\\noindent so that the conversion factors are now\n\\begin{align*}\n\tL &= \\frac{c}{\\omega_{\\mathrm{pe}}}, &\n\tT &= \\frac{1}{\\omega_{\\mathrm{pe}}}, \\\\\n\tM &= n_e\\frac{c^3}{\\omegap^3}m_e,    &\n\tQ &= n_e\\frac{c^3}{\\omegap^3}e,      \\\\\n\tE &= \\frac{m_e}{e}\\omegap c,         &\n\tB &= \\frac{m_e}{e}\\omegap.\n\\end{align*}\n\n\\noindent Note that by removing $\\ldebye$ from the unit system, there is no longer any dependence on the electron temperature used to calculate it.\n\n\\subsection{Laser-Plasma Units}\n\nFor laser-plasma interaction problems, the unit system can again be modified by replacing the time-scale with the inverse laser frequency, so that the unit system no longer depends on the electron density used to calculate $\\omega_{\\mathrm{pe}}$ and is instead dependent purely on the laser frequency.\nIn the deck the assignments are\n\\begin{align*}\n\th_{\\mathrm{c}}             &= h_{\\mathrm{u}}k_0, &\n\tc_{\\mathrm{c}}             &= 1,             \\\\\n\t\\varepsilon_{0,\\mathrm{c}} &= 1,             &\n\tr_{e,\\mathrm{c}}           &= -1,\n\\end{align*}\n\n\\noindent where $k_0 \\equiv \\omega_0/c$ is the vacuum laser wavenumber.\n\nThe conversion factors then become\n\\begin{align*}\n\tL &= \\frac{1}{k_0},           &\n\tT &= \\frac{1}{\\omega_0},      \\\\\n\tM &= \\frac{\\ncrit}{k_0^3}m_e, &\n\tQ &= \\frac{\\ncrit}{k_0^3}e,   \\\\\n\tE &= \\frac{m_e}{e}\\omega_0 c, &\n\tB &= \\frac{m_e}{e}\\omega_0,\n\\end{align*}\n\nwhere $\\ncrit \\equiv m_e\\varepsilon_0\\omega_0^2/e^2$ is the critical density.\nIn this unit system the simulation cell size and time step should satisfy $\\Delta x \\ll 1$ and $\\Delta t \\ll 1$ in order for the field solver to accurately model the laser.\nIt is also necessary to verify that the cell size resolves the Debye length, which is often a more restrictive condition.\nAdditionally, the normalized electric (or magnetic) field is the parameter $a_0$.\nFor $a_0 \\ll 1$, this is the electron quiver velocity divided by the speed of light, while $a_0 \\gtrsim 1$ indicates a relativistic field intensity which will lead to effects such as relativistically induced transparency and relativistic self-focusing.\n\n\\end{document}\n", "meta": {"hexsha": "662811c10ca638daf74b2b17c9e56000065c11bb", "size": 14658, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/vpicUnits.tex", "max_stars_repo_name": "tnakaicode/vpic", "max_stars_repo_head_hexsha": "44c5c1f89de0ba57d54e4109176ba0a1714ce7e5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 110, "max_stars_repo_stars_event_min_datetime": "2017-02-14T20:02:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T17:27:23.000Z", "max_issues_repo_path": "doc/src/vpicUnits.tex", "max_issues_repo_name": "tnakaicode/vpic", "max_issues_repo_head_hexsha": "44c5c1f89de0ba57d54e4109176ba0a1714ce7e5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 124, "max_issues_repo_issues_event_min_datetime": "2017-02-03T17:00:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T20:47:36.000Z", "max_forks_repo_path": "doc/src/vpicUnits.tex", "max_forks_repo_name": "tnakaicode/vpic", "max_forks_repo_head_hexsha": "44c5c1f89de0ba57d54e4109176ba0a1714ce7e5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2017-01-19T19:15:12.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-09T12:56:14.000Z", "avg_line_length": 56.3769230769, "max_line_length": 452, "alphanum_fraction": 0.71414927, "num_tokens": 4196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.42326814274416286}}
{"text": "\\section{Introduction}\n\\label{sec:intro}\n\nIn this paper we design numerical methods to solve a two-moment model that governs the transport of particles obeying Fermi-Dirac statistics (e.g., neutrinos), with the ultimate target being nuclear astrophysics applications (e.g., neutrino transport in core-collapse supernovae and compact binary mergers).  \nThe numerical method is based on the discontinuous Galerkin (DG) method for spatial discretization and implicit-explicit (IMEX) methods for time integration, and it is designed to preserve certain physical constraints of the underlying model.  \nThe latter property is achieved by considering the spatial and temporal discretization together with the closure procedure for the two-moment model.  \n\nIn many applications, the particle mean free path is comparable to or exceeds other characteristic length scales in the system under consideration, and non-equilibrium effects may become important.  \nIn these situations, a kinetic description based on a particle distribution function may be required.  \nThe distribution function, a phase space density $f$ depending on momentum $\\vect{p}\\in\\bbR^{3}$ and position $\\vect{x}\\in\\bbR^{3}$, is defined such that $f(\\vect{p},\\vect{x},t)$ gives at time $t\\in\\bbR^{+}$ the number of particles in the phase space volume element $d\\vect{p}\\,d\\vect{x}$ (i.e., $d\\cN=f\\,d\\vect{p}\\,d\\vect{x}$).  \nThe evolution of the distribution function is governed by the Boltzmann equation, which states a balance between phase space advection and particle collisions (see, e.g., \\cite{braginskii_1965,chapmanCowling_1970,lifshitzPitaevskii_1981}).  \n\nSolving the Boltzmann equation numerically for $f$ is challenging, in part due to the high dimensionality of phase space.  \nTo reduce the dimensionality of the problem and make it more computationally tractable, one may instead solve (approximately) for a finite number of angular moments $\\vect{m}_{N}=(m^{(0)},m^{(1)},\\ldots,m^{(N)})^{T}$ of the distribution function, defined as\n\\begin{equation}\n  m^{(k)}(\\varepsilon,\\vect{x},t)=\\f{1}{4\\pi}\\int_{\\bbS^{2}}f(\\omega,\\varepsilon,\\vect{x},t)\\,g^{(k)}(\\omega)\\,d\\omega,\n\\end{equation}\nwhere $\\varepsilon=|\\vect{p}|$ is the particle energy, $\\omega$ is a point on the unit sphere $\\bbS^{2}$ indicating the particle propagation direction, and $g^{(k)}$ are momentum space angular weighing functions.  \nIn problems where collisions are sufficiently frequent, solving a \\emph{truncated moment problem} can provide significant reductions in computational cost since only a few moments are needed to represent the solution accurately.  \nOn the other hand, in problems where collisions do not sufficiently isotropize the distribution function, more moments may be needed.  \nIn the two-moment model considered here ($N=1$), angular moments representing the particle density and flux (or energy density and momentum) are solved for.  \nTwo-moment models for relativistic systems appropriate for nuclear astrophysics applications have been discussed in, e.g., \\cite{lindquist_1966,andersonSpiegel_1972,thorne_1981,shibata_etal_2011,cardall_etal_2013a}.  \nHowever, in this paper, for simplicity (and clarity), we consider a non-relativistic model, leaving extensions to relativistic systems for future work.  \n\nIn a truncated moment model, the equation governing the evolution of the \\mbox{$N$-th} moment $m^{(N)}$ contains higher moments $\\{m^{(k)}\\}_{k=N+1}^{M}$ ($M>N$), which must be specified in order to form a closed system of equations.  \nFor the two-moment model, the symmetric rank-two Eddington tensor (proportional to the pressure tensor) must be specified.  \nApproaches to this \\emph{closure problem} include setting $m^{(k)}=0$, for $k>N$ ($P_N$ equations \\cite{brunnerHolloway_2005} and filtered versions thereof \\cite{mcclarrenHauck_2010,laboure_etal_2016}), Eddington approximation (when $N=0$) \\cite{mihalasMihalas_1999}, Kershaw-type closure \\cite{kershaw_1976}, and maximum entropy closure \\cite{minerbo_1978,cernohorskyBludman_1994,olbrant_etal_2013}.  \nThe closure procedure often results in a system of nonlinear hyperbolic conservation laws, which can be solved using suitable numerical methods (e.g., \\cite{leveque_1992}).  \n\nOne challenge in solving the closure problem is constructing a sequence of moments that are consistent with a positive distribution function, which typically implies algebraic constraints on the moments \\cite{kershaw_1976,levermore_1984}.  \nMoments satisfying these constraints are called \\emph{realizable moments} (e.g., \\cite{levermore_1996}).  \nWhen evolving a truncated moment model numerically, maintaining realizable moments is challenging, but necessary in order to ensure the well-posedness of the closure procedure \\cite{levermore_1996,junk_1998,hauck_2008}.  \nIn addition to putting the validity of the numerical results into question, failure to maintain moment realizability in a numerical model may, in order to continue a simulation, require ad hoc post-processing steps with undesirable consequences such as loss of conservation.  \n\nHere we consider a two-moment model for particles governed by Fermi-Dirac statistics.  \nIt is well known from the two-moment model for particles governed by Maxwell-Boltzmann statistics (``classical'' particles with $f\\ge0$), that the particle density is nonnegative and the magnitude of the flux vector is bounded by the particle density.  \n(There are further constraints on the components of the Eddington tensor \\cite{levermore_1984}.)  \nFurthermore, the set of realizable moments generated by the particle density and flux vector constitutes a convex cone \\cite{olbrant_etal_2012}.  \nIn the fermionic case, there is also an upper bound on the distribution function (e.g., $f\\le1$) because Pauli's exclusion principle prevents particles from occupying the same microscopic state.  \nThe fermionic two-moment model has recently been studied theoretically in the context of maximum entropy closures \\cite{lareckiBanach_2011,banachLarecki_2013,banachLarecki_2017b} and Kershaw-type closures \\cite{banachLarecki_2017a}.  \nBecause of the upper bound on the distribution function, the algebraic constraints on realizable moments differ from the classical case with no upper bound, and can lead to significantly different dynamics when the occupancy is high (i.e., when $f$ is close to its upper bound).  \nIn the fermionic case, the set of realizable moments generated by the particle density and flux vector is also convex. \nIt is ``eye-shaped'' (as will be shown later; cf. Figure~\\ref{fig:RealizableSetFermionic} in Section~\\ref{sec:realizability}) and tangent to the classical realizability cone on the end representing low occupancy, but is much more restricted for high occupancy.  \n\nIn this paper, the two-moment model is discretized in space using high-order Discontinuous Galerkin (DG) methods (e.g., \\cite{cockburnShu_2001,hesthavenWarburton_2008}).  \nDG methods combine elements from both spectral and finite volume methods and are an attractive option for solving hyperbolic partial differential equations (PDEs).  \nThey achieve high-order accuracy on a compact stencil; i.e., data is only communicated with nearest neighbors, regardless of the formal order of accuracy, which can lead to a high computation to communication ratio, and favorable parallel scalability on heterogeneous architectures has been demonstrated \\cite{klockner_etal_2009}.  \nFurthermore, they can easily be applied to problems involving curvilinear coordinates (e.g., beneficial in numerical relativity \\cite{teukolsky_2016}).  \nImportantly, DG methods exhibit favorable properties when collisions with a background are included, as they recover the correct asymptotic behavior in the diffusion limit, characterized by frequent collisions (e.g., \\cite{larsenMorel_1989,adams_2001,guermondKanschat_2010}).  \nThe DG method was introduced in the 1970s by Reed \\& Hill \\cite{reedHill_1973} to solve the neutron transport equation, and has undergone remarkable developments since then (see, e.g., \\cite{shu_2016} and references therein).  \n\nWe are concerned with the development and application of DG methods for the fermionic two-moment model that can preserve the aforementioned algebraic constraints and ensure realizable moments, provided the initial condition is realizable.  \nOur approach is based on the constraint-preserving (CP) framework introduced in \\cite{zhangShu_2010a}, and later extended to the Euler equations of gas dynamics in \\cite{zhangShu_2010b}.  \n(See, e.g., \\cite{xing_etal_2010,zhangShu_2011,olbrant_etal_2012,cheng_etal_2013,zhang_etal_2013,endeve_etal_2015,wuTang_2015} for extensions and applications to other systems.)  \nThe main ingredients include (1) a realizability-preserving update for the cell averaged moments based on forward Euler time stepping, which evaluates the polynomial representation of the DG method in a finite number of quadrature points in the local elements and results in a Courant-Friedrichs-Lewy (CFL) condition on the time step; (2) a limiter to modify the polynomial representation to ensure that the algebraic constraints are satisfied point-wise without changing the cell average of the moments; and (3) a time stepping method that can be expressed as a convex combination of Euler steps and therefore preserves the algebraic constraints (possibly with a modified CFL condition).  \nAs such, our method is an extension of the realizability-preserving scheme developed by Olbrant el al. \\cite{olbrant_etal_2012} for the classical two-moment model.  \n\nThe DG discretization leaves the temporal dimension continuous.  \nThis semi-discretization leads to a system of ordinary differential equations (ODEs), which can be integrated with standard ODE solvers (i.e., the method of lines approach to solving PDEs).  \nWe use implicit-explicit (IMEX) Runge-Kutta (RK) methods \\cite{ascher_etal_1997,pareschiRusso_2005} to integrate the two-moment model forward in time.  \nThis approach is motivated by the fact that we can resolve time scales associated with particle streaming terms in the moment equations, which will be integrated with explicit methods, while terms associated with collisional interactions with the background induce fast time scales that we do not wish to resolve, and will be integrated with implicit methods.  \nThis splitting has some advantages when solving kinetic equations since the collisional interactions may couple across momentum space, but are local in position space, and are easier to parallelize than a fully implicit approach.  \n\nThe CP framework of \\cite{zhangShu_2010a} achieves high-order (i.e., greater than first-order) accuracy in time by employing strong stability-preserving explicit Runge-Kutta (SSP-RK) methods \\cite{shuOsher_1988,gottlieb_etal_2001}, which can be written as a convex combination of forward Euler steps.  \nUnfortunately, this strategy to achieve high-order temporal accuracy does not work as straightforwardly for standard IMEX Runge-Kutta (IMEX-RK) methods because implicit SSP Runge-Kutta methods with greater than first-order accuracy have time step restrictions similar to explicit methods \\cite{gottlieb_etal_2001}.  \nTo break this ``barrier,'' recently proposed IMEX-RK schemes \\cite{chertock_etal_2015,hu_etal_2018} have resorted to first-order accuracy in favor of the SSP property in the standard IMEX-RK scheme, and recover second-order accuracy with a correction step.  \n\nWe consider the application of the correction approach to the two-moment model.  \nHowever, with the correction step from \\cite{chertock_etal_2015} we are unable to prove the realizability-preserving property without invoking an overly restrictive time step.  \nWith the correction step from \\cite{hu_etal_2018} the realizability-preserving property is guaranteed with a time step comparable to that of the forward Euler method applied to the explicit part of the scheme, but the resulting scheme performs poorly in the asymptotic diffusion limit.  \nBecause of these challenges, we resort to first-order temporal accuracy, and propose IMEX-RK schemes that are convex-invariant with a time step equal to that of forward Euler on the explicit part, perform well in the diffusion limit, and reduce to a second-order SSP-RK scheme in the streaming limit (no collisions with the background material).  \n\nThe realizability-preserving property of the DG-IMEX scheme depends sensitively on the adopted closure procedure.  \nThe explicit update of the cell average can, after employing the simple Lax-Friedrichs flux and imposing a suitable CFL condition on the time step, be written as a convex combination.  \nRealizability of the updated cell average is then guaranteed from convexity arguments \\cite{zhangShu_2010a}, provided all the elements in the convex combination are realizable.  \nRealizability of individual elements in the convex combination is conditional on the closure procedure (components of the Eddington tensor must be computed to evaluate numerical fluxes).  \nWe prove that each element in the convex combination is realizable provided the moments involved in expressing the elements are moments of a distribution function satisfying the bounds implied by Fermi-Dirac statistics (i.e., $0\\le f \\le 1$).  \nFor algebraic two-moment closures, which we consider, the so-called Eddington factor is given by an algebraic expression depending on the evolved moments and completely determines the components of the Eddington tensor.  \nRealizable components of the Eddington tensor demand that the Eddington factor satisfies strict lower and upper bounds (e.g., \\cite{levermore_1984,lareckiBanach_2011}).  \nWe discuss algebraic closures derived from Fermi-Dirac statistics that satisfy these bounds, and demonstrate with numerical experiments that the DG-IMEX scheme preserves realizability of the moments when these closures are used.  \nWe also demonstrate that further approximations to algebraic two-moment closures for modeling particle systems governed by Fermi-Dirac statistics may give results that are incompatible with a bounded distribution and, therefore, unphysical.  \nThe example we consider is the Minerbo closure \\cite{minerbo_1978}, which can be obtained as the low occupancy limit of the maximum entropy closure of Cernohorsky \\& Bludman \\cite{cernohorskyBludman_1994}.  \n\nThe paper is organized as follows.  \nIn Section~\\ref{sec:model} we present the two-moment model.  \nIn Section~\\ref{sec:realizability} we discuss moment realizability for the fermionic two-moment model, while algebraic moment closures are discussed in Section~\\ref{sec:algebraicClosure}.  \nIn Section~\\ref{sec:dg} we briefly introduce the DG method for the two-moment model, while the (convex-invariant) IMEX time stepping methods we use are discussed in Section~\\ref{sec:imex}.  \nThe main results on the realizability-preserving DG-IMEX method for the fermionic two-moment model are worked out in Sections~\\ref{sec:realizableDGIMEX} and \\ref{sec:limiter}.  \nIn Section~\\ref{sec:limiter} we also discuss the realizability-enforcing limiter.  \nNumerical results are presented in Section~\\ref{sec:numerical}, and summary and conclusions are given in Section~\\ref{sec:conclusions}.  \nAdditional details on the IMEX schemes are provided in Appendices.  ", "meta": {"hexsha": "d4390dd10280dafe76e6f8d9747dd1ecb4e149fd", "size": 15270, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/realizableFermionicM1/sections/intro.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/realizableFermionicM1/sections/intro.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/realizableFermionicM1/sections/intro.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 167.8021978022, "max_line_length": 690, "alphanum_fraction": 0.8055664702, "num_tokens": 3576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4231743783622261}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** Fourth Chapter *****************************\n%*******************************************************************************\n\n\\chapter{Functional Time Series Modelling For EO Data \\label{cha:ftsm}}  %Title of the Fourtht Chapter\n\\nomenclature[z-FTSM]{FTSM}{Functional Time Series Model}\n\\nomenclature[z-FPCA]{FPCA}{Functional Principal Components Analysis}\n\\nomenclature[z-PACE]{PACE}{Principal components Analysis through Conditional Expectation}\n\\nomenclature[z-MAFR]{MAFR}{Maximum Autocorrelation Factor Rotations}\n\\nomenclature[z-SSIM]{SSIM}{Structured Similarity Index Measure}\n\\nomenclature[z-SSIM]{SSIM}{Structured Similarity Index Measure}\n\\nomenclature[z-PSNR]{PSNR}{Peak Signal to Noise Ratio}\n\n\n\n\\ifpdf\n    \\graphicspath{{Chapter4/Figs/Raster/}{Chapter4/Figs/PDF/}{Chapter4/Figs/}}\n\\else\n    \\graphicspath{{Chapter4/Figs/Vector/}{Chapter4/Figs/}}\n\\fi\n\nEO data sets, as alluded to in Chapter~\\ref{cha:Into}, are often the primary source of information relating to a large spatial range.\nThey may often be used when in situ measurements are not physically possible, or that in person collection is to dangerous.\nEO data is then often used to provide assistance to some monitoring or response effort.\nFor example, \\citeauthor{singha_satellite_2013} uses such remotely sensed data to detect oil spills in oceans where in-situ measurements are not feasible, \\citep{singha_satellite_2013}.\nIn such a scenarios, a major draw back of EO data is often the limited acquisition times.\nThere are two main problems with having limited acquisition times for EO data.\nFirstly, we may be observing a process where we are interested in the values of our data in between acquisitions.\nHere, ideally, we would be able to capture another acquisition and thus increase our temporal resolution of the data.\nHowever, this may not be possible.\nSo the problem at hand is how can we artificially increase the temporal resolution of the data set.\nThis is commonly referred to as interpolation, and our goal would be to interpolate the image that would be acquired say at a time between two observed images for the whole spatial domain.\nSecondly, we may be observing a process where we are interested in future values of our data. That is we are interested in the forecasted image based on our observations to date, and again we suppose we are interested in forecasting the imagery for the whole spatial domain.\nIn this Chapter, we discuss one such approach to both the interpolation and forecasting problems mentioned. In particular, we consider treating our functional dimension as space and using a combination of functional decomposition and functional time series modelling to aid in the interpolation and forecasting. To the authors knowledge this application of functional techniques, as described below, to EO data with the focus on space as the functional domain  is a novel contribution. \n\n\\section{Change Of Representation \\label{sec:representation}}\nTo describe our proposed model in this Chapter, we make a change to our representation of EO data.\nIn this Chapter we will focus on viewing the EO data as a collection of images over space where we will index the images over time.\nTo make this concrete we propose the following representation of our data which is adjusted from the discussion in Section~\\ref{sec:fr}.\nThat is: \n\n\\begin{equation}\n\t\\bar{\\ve{Y}} = \\{ \\bar{y}_{ij}; i=1, 2, \\cdots, N, j = 1, 2, ... ,J\\}\n\\end{equation}\nwhere $\\bar{y}_{ij}$ is the $i^\\text{th}$ spatial observation of the $j^\\text{th}$ acquisition in time.\nHere we represent $\\bar{y}_{ij}$ as follows:\n\\begin{equation}\n\t\\bar{y}_{ij} = \\bar{\\chi}_j(\\ve{s}_{ij})  + \\bar{\\varepsilon}_{ij}\n\t\\label{eqn:space_obs}\n\\end{equation}\nwhere $\\bar{\\chi}_j$ corresponds to the $j^\\text{th}$  functional variable over now the spatial domain, $\\mathcal{S}$ and $\\vesub{s}{ij}$ is the $i^\\text{th}$ spatial observation for the $j^\\text{th}$ acquisition.\nWe use the $\\bar{\\cdot}$ notation to make explicit the change of representation from that discussed in Section~\\ref{sec:fr} where time was our functional domain.\nWe have also assumed here that we observe the same spatial observations for every acquisition by fixing $J_i = J$ for all $i=1, 2, \\cdots, N$.\nAs we will see this is an assumption for notational simplicity only and the model set out in this chapter will work in the setting of sparsely observed data as well. \n\nThe change of representation facilitates the model described below and helps to emphasise that in this chapter we are interested in interpolation and forecasting the whole spatial domain through time.\nWe note that the methodology discussed in Chapter~\\ref{cha:background} all equally applies in the setting of space being the functional domain with some extensions needed for penalised regression splines which have been discussed.\n\nTherefore, our goals of this Chapter is then to estimate $\\bar{\\chi}$ for some unobserved acquisition time $t_{j^*}$.\nIf $t_{j^*} \\in \\mathcal{T}$ this corresponds to interpolation, and likewise if $t_{j^*} \\not \\in \\mathcal{T}$ this corresponds to forecasting.\n\n\\section{Modelling \\label{sec:ftsm_model}}\nThe following model aims to combine a functional representation of the spatial surfaces using regularised spline smoothing with functional time series modelling as the technique to interpolate and forecast. We will use the term Functional Time Series Model (FTSM) to denote the model described below. \nThe motivation of such an approach is that we wish to use a functional technique to reduce the dimensionality of the problem in the spatial domain, and then use relatively standard time series forecasting techniques for the interpolation and forecasting in the reduced domain.\nWe describe this in two steps.\nWe first describe the approach taken to reduce the dimensionality of the imagery then we describe our approach to forecasting and interpolation in the reduced domain.\n\n\\subsection{Decomposition}\nAs discussed in Chapter~\\ref{cha:background}, a common form of functional decomposition is the functional principal components analysis (FPCA) (See Section~\\ref{sec:fpca}).\nRe-framing this decomposition in the case of a spatial functional variable is simple, and extends in the natural way.\nThat is we have the following representation of the centred functional process which is the equivalent to Equation~\\ref{eqn:fpca} but for our functional random variable $\\bar{\\mathcal{X}}\\left(\\ve{s}\\right)$ which is a surface over the spatial domain $\\mathcal{S}$.\n\\begin{equation}\n\t\\bar{\\mathcal{X}}\\left(\\ve{s}\\right) -\\bar{\\mu}\\left(\\ve{s}\\right) = \\sum_{k=1}^{\\infty} \\bar{\\zeta}_k \\bar{\\phi}_k \\left( \\ve{s} \\right)\n\t\\label{eqn:space_fpca}\n\\end{equation}\nwhere $\\bar{\\mu}, \\bar{\\zeta}_k, \\bar{\\phi}\\left(\\ve{s}\\right)$ are the natural extensions to the mean function, principal component score, and principal components respectively. \n\nThe determination of such components from our observed data $\\bar{\\ve{Y}}$ can be achieved in principal through the PACE framework as discussed in Section~\\ref{sec:pace}.\nHowever, one runs into difficulty in this setting as we would have to form a variety of spatial covariance matrices to estimate the covariance function $G: \\mathcal{S} \\times \\mathcal{S} \\to \\mathbb{R}$ and perform matrix inversion of these matrices to estimate the principal component scores, as can be seen through Equation~\\ref{eqn:fpc_est} in the one dimensional case.\nThis can quickly become prohibitive in the spatial setting where even a small observed grid can lead to relatively large covariance matrices. \n\nOne method for overcoming such an obstacle is to estimate the functional variables $\\bar{\\chi}_j\\left(\\ve{s}\\right), j=1,2,...,J$ directly though a basis expansion.\nThat is we assume the following form for $\\bar{\\chi}_j\\left(\\ve{s}\\right)$:\n\\begin{equation}\n\t\\bar{\\chi}_j\\left(\\ve{s}\\right)  = \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) \\bar{\\ve{c}}_j\n\t\\label{eqn:basis_expansion_space}\n\\end{equation}\nwhere $\\ve{\\bar{B}}$ is the known basis system over two dimensions and $ \\bar{\\ve{c}}_j$ corresponds to the coefficient matrix that is to be estimated directly. \n\nWe have discussed an approach to estimating the coefficients using penalised regression splines in Section~\\ref{ssec:spline_reg} where the basis system formed of a Kronecker product of B-spline bases over each dimension.\nThe form of Equation~\\ref{eqn:basis_expansion_space} is comparable to that given in Equation~\\ref{eqn:kron_expansion} but we now include an explicit form $\\bar{c}$ of the vectorised coefficient matrix of Equation~\\ref{eqn:kron_expansion}.\n\nWe can then use an appropriate method for estimating $\\bar{\\vesub{c}{j}}$ from our observed data $\\bar{\\ve{Y}}$ for each $j=1, 2, \\cdots, J$ such as penalised regression splines as discussed in Section~\\ref{ssec:spline_reg}.\nThe approach described above; discussed in detail in \\citep{ramsay_functional_2010}, is a single step in estimating the FPCA decomposition.\nTherefore, we only use the observations corresponding to the $j^\\text{th}$ functional variable, $\\bar{\\vesub{y}{j}}=\\{\\bar{y}_{ij}; i=1, 2, \\cdots, N\\}$ to estimate the basis expansion coefficients $\\bar{\\vesub{c}{j}}$.\nHere we can also see that assuming we observe densely each functional variable is only a convenience since sparsely observed functional variables will impact the estimation of the coefficients of the expansion but it will still admit such a representation. \n\nGiven a basis expansion form of our functional variable, the formation of the functional principal components can be applied in coefficient space, as discussed in \\citep[Chapter~8]{ramsay_functional_2010}.\nExpressing the simultaneous expansion of all $J$ surfaces by:\n\\begin{equation}\n\t\\ve{\\chi}(\\ve{s}) = \\ve{C}  \\ve{\\bar{B}}(\\ve{s})\n\t\\label{eqn:simul_exp}\n\\end{equation}\nwhere $\\ve{C}$ is the stacked matrix of $J$ coefficient vectors of each basis expansion.\nThe covariance function $G$ is then given by:\n\\begin{equation}\n\tG(\\ve{s}, \\vesup{s}{\\prime}) = J^{-1}  \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) \\vesup{C}{\\transpose}\\ve{C}  \\ve{\\bar{B}}(\\vesup{s}{\\prime})\n\\end{equation}\n\nAs discussed in Section~\\ref{sec:fpca} we are interested in the eigenfunctions of $G$.\nAgain, following \\citep[Chapter~8]{ramsay_functional_2010},  we suppose the eigenfunctions of $G$ have a basis expansion.\n\\begin{equation}\n\t\\bar{\\phi}(\\ve{s}) = \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) \\bar{\\ve{b}}\n\t\\label{eqn:space_eigen} \n\\end{equation}\n\nNow, following the discussion on FPCA in Section~\\ref{eqn:fpca}, we can find such eigenfunction by solving the Fredholm integral equations of the second kind, \\citep{yao_functional_2005}.\nThe form of these are simplified by the basis expansion as:\n\\begin{equation}\n\t\t\\langle G(\\cdot, \\vesup{s}{\\prime}), \\bar{\\phi} \\rangle =  J^{-1}  \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) \\vesup{C}{\\transpose}\\ve{C}  \\ve{W} \\ve{b} = \\lambda \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) \\bar{\\ve{b}}\n\t\t\\label{eqn:eigeneqn}\n\\end{equation}\nwhere $\\ve{W} = \\int_\\mathcal{S} \\ve{\\bar{B}}(\\vesup{s}{\\prime}) \\vesup{\\bar{B}}{\\transpose}(\\ve{s}) d\\ve{s}$ is the symmetric matrix of pairwise inner products of the basis functions in our basis system.\nSince Equation~\\ref{eqn:eigeneqn} must hold for all $\\ve{s} \\in \\mathcal{S}$ it implies a purely matrix equation of: \n\\begin{equation}\n\tJ^{-1} \\vesup{C}{\\transpose}\\ve{C} \\ve{W} \\ve{b} = \\lambda \\bar{\\ve{b}}\n\t\\label{eqn:eigeneqn_matrix} \n\\end{equation}\nThe solutions of which can be obtained using standard procedures.\nIn particular, this gives a methodology for obtaining the eigenfunctions of $G$ utilising a matrix equation which is of the dimension of the basis system rather than that of the observed data.\nThe associated score to the $k^\\text{th}$ principal components $\\bar{\\phi}_k(\\ve{s})$ can be found similarly using matrix equation only as:\n\\begin{equation}\n\t\\bar{\\zeta}_{jk} = \\left(\\vesub{c}{j} - \\vesub{c}{\\mu}\\right) W \\vesub{b}{k}\n\\end{equation}\nwhere $\\vesub{c}{\\mu}$ is the coefficient vector of the mean function in its basis expansion, or simply the mean of the coefficient matrix $\\ve{C}$ in Equation~\\ref{eqn:simul_exp}.\n\nThe above FPCA using basis expansion, as proposed in \\citep[Chapter~8]{ramsay_functional_2010}, gives a reduced dimension representation of our observed functional variables where we have overcome the issue of high spatial resolution making the PACE analysis unfeasible.\nAs discussed in Section~\\ref{sec:fpca} these principal components will describe a maximum amount of variation in the data set, however the aim of our modelling in this Chapter is to achieve good interpolation and forecasting to unobserved time points.\nWe note that the score process in our above representation encodes the temporal evolution of the observed imagery. \nHence we would ideally like to produce a decomposition of our observed data that makes the score process as easy to interpolate and forecast as possible. \nThere is no reason to believe therefore that the FPCA decomposition is the best for achieving this aim.\nTo this end we will also consider a rotation to these principal components, known as Maximum Autocorrelation Factor Rotations (MAFR).\n\n\\subsubsection{Maximal autocorrelation factor rotations \\label{ssec:mafr}}\nRotations to multivariate principal component analysis have long been studied.\nMost often rotations are designed to emphasise a particular quality of the principal components. \nFor example the Varimax rotation, \\citep{kaiser_varimax_1958}, was established in \\citeyear{kaiser_varimax_1958} by \\citeauthor{kaiser_varimax_1958}.\nIt places an emphasis on producing components which focus on particular ranges of the domain which often aids interpretability of the resulting components.\nSimilar approaches to helping the interpretability of functional principal components have been studies.\n\\citeauthor{ramsay_functional_2010} considers the extension of the Varimax rotation for FPCA, \\citep{ramsay_functional_2010}. \n\nMAFR was proposed by \\citeauthor{hooker_maximal_2015} and developed in relation to functional observation with time as the functional domain in \\citep{hooker_maximal_2016}.\nHere, they build on top of the multivariate rotation known as Maximum Autocorrelation Factors (MAF), \\citep{switzer_minmax_1984}.\nMAF focused on finding a rotation which selects components which have minimum autocorrelation. \n\\citeauthor{hooker_maximal_2016} shows that this can be extended to the functional domain by considering searching for components that have smallest integrated first derivative, \\citep{hooker_maximal_2016}. \nThey then highlight that this can be extended to any notion of smoothness given by some linear differential operator, such as those discussed in Section~\\ref{ssec:spline_reg}. \n\nWe detail the calculation of such MAFR rotations following the methodology proposed in \\citep{hooker_maximal_2016}.\nFor more details on the derivation of the rotations see \\citep{hooker_maximal_2016}.\n\nAssume that we have a set of principal components $\\{\\bar{\\phi}_k; k=1,2,\\cdots,K\\}$ obtained from the data.\nWe collect this set into a vector notation as before, giving $\\bar{\\ve{\\phi}}(\\ve{s}) = \\left(\\bar{\\phi}_1(\\ve{s}), \\bar{\\phi}_2(\\ve{s}), \\cdots, \\bar{\\phi}_K(\\ve{s})\\right)^\\transpose$.  \nThe MAFR rotation corresponds to, \\citep{hooker_maximal_2016}:\n\\begin{equation}\n\t\\argmin_{\\ve{u}} \\vesup{u}{\\transpose} \\langle L\\bar{\\ve{\\phi}}, L\\bar{\\ve{\\phi}} \\rangle \\ve{u}\n\t\\label{eqn:mafr_min}\n\\end{equation}\nsubject to $\\vesup{u}{\\transpose}\\ve{u} = 1$. Defining successive rotations in the standard way by minimising Equation~\\ref{eqn:mafr_min} whilst being orthogonal to proceeding rotations.\nBy standard arguments these can be found by the succeeding columns of $U$ in the Eigen-decomposition of $P$. \nThat is:\n\\begin{equation}\n\tP = \\ve{U} \\ve{D} \\vesup{U}{\\transpose}\n\\end{equation}\n\nThe new rotated principal components are given by:\n\\begin{equation}\n \\vesup{U}{\\transpose} \\ve{\\bar{\\phi}}(\\ve{s})\n\\end{equation} \nAs noted in \\citep{hooker_maximal_2016} if the diagonal matrix $D$ is ordered from largest to smallest eigenvalues, the final components of $\\vesub{\\bar{\\phi}}{\\text{MAFR}}$ will be the smoothest with respect to the operator $L$. A similar rotation to the scores gives the mafr scores. \n\nBoth FPCA decomposition and the MAFR decomposition give principal components which are orthonormal and can seeming be used interchangeably in the following. The idea is that the MAFR rotation will result in a score processes that is easier to interpolate and forecast as it has been encourage to be smooth by the operator $L$.\n\n\\subsection{Interpolation and forecasting \\label{sec:ftsm_forecast}}\n\nFollowing the decomposition of our observed data into either FPCA or the MAFR components we have a series of principal components. \nThese capture the various spatial structures present.\nThe corresponding scores capture the temporal process of each component.\nModelling such scores then paves the way for interpolating and forecasting the full imagery through this decomposition.\nThis is exactly the same setup as formulated for functional time series methodology, \\citep{hyndman_forecasting_2009}.\nWe have previously discussed the approach to forecasting using functional time series methodology in Section~\\ref{sec:fts} and we use the same methodology as previously discussed for interpolation and forecasting in this scenario.\nThat is this methodology treats each principal component score as a univariate time series independently of the others.\nHowever, the MAFR scores will in fact be correlated by the rotation matrix $U$ which would lend itself to possibly introducing a more complex modelling of the multivariate score processes.\nWe choose not too and apply the same independent forecasting methodology for both FPCA and MAFR decompositions. \n\nAs mentioned in \\citep{hyndman_forecasting_2009} any univariate time series model could be used for forecasting and interpolation. \nFor our model we choose to model each score process $\\zeta_{jk}(t)$ by a Gaussian process for $j=1,2,\\cdots, J, k=1,2,\\cdots,K$.\nWe have discussed Gaussian process regression in the general sense in Section~\\ref{sec:gp} where are domain of interest in space.\nIn this case we have a univariate temporal domain. \nThat is our score process $\\zeta(t)$ (we drop the component indexing notation as we have the same structure on all components) is represented as:\n\\begin{equation}\n\t\\zeta(t) \\sim \\mathcal{GP}\\left( m(t), k(t, t^\\prime)\\right)\n\\end{equation}\nwhere $m(t)$ is our mean function and $k(t, t^\\prime)$ is the covariance function of the process.\nHere we choose the mean and covariance function which are tailored for forecasting.\n\nIn particular, we choose a linear mean function.\nThat is:\n\\begin{equation}\n\tm(t) = at + b\n\\end{equation}\nfor all $t \\in \\mathcal{T}$, where $a, b$ are unknown hyper parameters to be estimated for the mean function.\nThe value of $a$ and $b$ are chosen through maximum likelihood estimation of the Gaussian process on the observed score process. \nWe choose a non-zero mean to act as an aid in forecasting so that the Gaussian process will not be reverting back to zero at large forecast steps but will revert to the value of the mean function, \\citep{williams_gaussian_2006}. \n\nAs we choose a simple mean function for our model of the score process, we encode the possible complexity in the time series with a covariance kernel which is designed for pattern discovery. \nWe choose to use a two component kernel function with an additive structure. \nThat is our covariance function has the following form:\n\\begin{equation}\n\tk(t, t^\\prime) = k_\\text{trend}(t, t^\\prime) + k_\\text{med}(t, t^\\prime)\n\\end{equation}\nwhere we choose $k_{\\text{trend}}$ to be a Gaussian kernel function that is designed to capture long term smooth trends of the functions.\nWe choose $k_{\\text{med}}$ to be a Rational Quadratic kernel which is designed to capture medium and short term variations in the function.\nBoth these kernels are standard in Gaussian process regression and are discussed in detail in \\citep{williams_gaussian_2006}. \nEach of $k_{\\text{trend}}$ and $k_{\\text{med}}$ has a collection of hyper parameters which control their behaviour, these hyper parameters are chosen again through maximum likelihood estimation of the observed process.\nUsing such a covariance function should provide an expressive tool for both interpolating and forecasting our score processes.\nA final remark is that we have an independent Gaussian process for each score process.\nThey all have a common structure of the same mean and covariance function but the hyper parameters for each component score process will be separately estimated.\nThis is in line with the methodology described in \\citep{hyndman_forecasting_2009}. \n\n\\section{Simulation Experiment \\label{sec:ftsm_sim}}\nTo demonstrate the effectiveness of our model proposed in Section~\\ref{sec:ftsm_model} we consider its application to a series of simulated data sets.\nWe specify the data generating process for our simulations below. \n\n\\subsection{Data generating process \\label{ftsm_sim_dgp}}\nWe propose simulating data on a spatio-temporal grid.\nWe do so as this is typically how EO data observed (See Section~\\ref{sec:eo}).\nWe define the grid by specifying the spatial domain as $\\mathcal{S} = \\left[0, 1\\right] \\times \\left[0, 1\\right]$ and assume we have $64 \\times 96$ spatial locations arranged in a grid as our observation locations.\nThe temporal domain we define simply as $\\mathcal{T} = \\left[0, 1\\right]$ with possible $60$ possible temporal observations evenly spaced within $\\mathcal{T}$. \nThis gives a full simulated data dimension of $64 \\times 96 \\times 60$. \n\nTo generate data on such a grid we assume our functional variables are generated as Equation~\\ref{eqn:space_fpca} where we truncate to only $3$ principal components.\nThese correspond to three different modes of variation which captures the spatial variation in our observed process.\nThe corresponding score processes will capture the temporal variation of each principal component in the observed process.\nFinally, the sum-product of the score process with the principal components will then result in a fully spatial-temporal process. \n\nWe therefore need to simulate the $3$ principal components which are two dimensional surfaces over the grid of our domain $\\mathcal{S}$ and the $3$ score proecesses which are one dimensional surfaces over our temporal grid $\\mathcal{T}$.\nTo do so we utilise a Gaussian process simulation for both.\nFor simplicity we restrict our simulations to coming from a zero mean Gaussian processes.\nWe simulate the principal components using an isotropic stationary Mat\\`{e}rn covariance function and we generate the scores from a Gaussian covariance function.\nBoth of which are standard covariance functions used in Gaussian process regression, more details of which can be found in \\citep{williams_gaussian_2006} and the references within.\nThe form of the Mat\\`{e}rn covariance function is given in Equation~\\ref{eqn:mat}. \n\nTo simulate our $3$ principal components we specify separate length scale hyper parameters for each component. \nWe keep the shape parameter for the Mat\\`{e}rn covariance function fixed for all three components at $2.5$. \nWe do so because we wish to simulate data which is smooth across space and we can adequately adjust the amount of spatial variation by changing the length scale of the process whilst maintaining this smoothness by keeping the shape parameter fixed.\nWe also note that the principal component variances parameters are fixed to 1.0, this is because the scale is set in the score process as described in Equation~\\ref{eqn:space_fpca}.\nThe length scale parameters used in the simulation study are given in Table~\\ref{tab:fpc_params}.\n\n\\begin{table}[htbp!] \n\t\\caption[Parameters for simulating functional principal component processes.]{The varying length scale parameter in the Mat\\`{e}rn covariance function which is used to simulate the $3$ functional principal components in the data generating process.}\n\t\\centering\n\t\\label{tab:fpc_params}\n\t\\begin{tabular}{l c c }\n\t\t\\toprule\n\t\t& \\multicolumn{1}{c}{Parameter} \\\\ \n\t\tComponent  & $\\rho$ \\\\\n\t\t\\midrule\n\t\t1 & 0.5 \\\\\n\t\t2 & 0.4 \\\\\n\t\t3 & 0.2 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\nAn example of the $3$ functional principal components simulated is given in Figure~\\ref{fig:ftsm_example_fpc}.\nAs can be noted from the decreasing length scales for the each component, the succeeding components are increasingly spatially variable.\n\n\\begin{figure}[htbp!] \n\t\\centering    \n\t\\includegraphics[width=1.0\\textwidth]{sim_fpc_example}\n\t\\caption[Example functional principle component simulation]{Example of the 3 simulated principal component surfaces from the isotropic stationary Mat\\`{e}rn covariance function. Notice the reduced spatial correlation in succeeding components. The simulation study is designed this way to provide difficulty for recovering the true functional principal components. }\n\t\\label{fig:ftsm_example_fpc}\n\\end{figure}\n\nTo simulate the three corresponding score processes we let the variance and length scale parameters vary with component.\nThese hyper parameters are given in Table~\\ref{tab:zeta_params}.\nAgain we choose these parameters to emphasise the smoothness  and contribution of the leading components to the whole processes.\nThat is the succeeding score processes are more variable, becoming more difficult to distinguish and forecast. \n\n\\begin{table}[htbp!] \n\t\\caption[Parameters for simulating functional principal component score processes]{The varying length scale and noise parameters in the Gaussian covariance function which is used to simulate the $3$ functional principal component scores in the data generating process.}\n\t\\centering\n\t\\label{tab:zeta_params}\n\t\\begin{tabular}{l c c }\n\t\t\\toprule\n\t\t& \\multicolumn{2}{c}{Parameter} \\\\ \n\t\tComponent  & $\\sigma$ &$\\rho$ \\\\\n\t\t\\midrule\n\t\t1 & 1.0 & 0.5 \\\\\n\t\t2 & 0.8 & 0.3 \\\\\n\t\t3 & 0.5 & 0.1 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\nAn example of the $3$ functional principal component score processes is given in Figure~\\ref{fig:ftsm_example_zeta}. \nThis highlights the decreasing correlation and the impact of the variance parameter on the score processes. \n\n\\begin{figure}[htbp!] \n\t\\centering    \n\t\\includegraphics[width=1.0\\textwidth]{sim_zeta_example}\n\t\\caption[Example functional principle component score simulation]{Example of the 3 simulated principal component score functions from the stationary Mat\\`{e}rn covariance function. Notice the reduced temporal correlation in succeeding components. The simulation study is designed this way to provide difficulty for interpolation and forecasting such components. }\n\t\\label{fig:ftsm_example_zeta}\n\\end{figure}\n\nCombining the simulated principal components with their appropriate weightings given by the simulated principal component scores then gives us a simulation from a truncated version of the model given in Equation~\\ref{eqn:space_fpca}.\nFigure~\\ref{fig:ftsm_chi_example} displays a selection of time points of the corresponding functional variable simulations from the components and scores displayed in Figures~\\ref{fig:ftsm_example_fpc},~\\ref{fig:ftsm_example_zeta} respectively. \n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_001}\n\t\t\\caption{$t=0.00$}\n\t\t\\label{fig:ftsm_chi_example_0}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_002}\n\t\t\\caption{$t=0.17$}\n\t\\end{subfigure}\n\t\\vfill       \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_003}\n\t\t\\caption{$t=0.34$}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_004}\n\t\t\\caption{$t=0.51$}\n\t\\end{subfigure}  \n\t\\vfill           \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_005}\n\t\t\\caption{$t=0.68$}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_chi_example_006}\n\t\t\\caption{$t=0.85$}\n\t\\end{subfigure}\n\t\\caption{Example simulated functional variables $\\bar{\\chi}_j$ for various time points, $t_j$. These correspond to the simulated functional components and scores in Figures~\\ref{fig:ftsm_example_fpc},~\\ref{fig:ftsm_example_zeta} respectively. Notice how we see the third principal component prominently at the beginning then fade and reappear in line with its associated score, whereas the first two components are more consistent over time.}\n\t\\label{fig:ftsm_chi_example}\n\\end{figure}\n\nAs given in Equation~\\ref{eqn:space_obs} we do not observe the simulated functional variable directly but rather with an additive noise process $\\bar{\\varepsilon_{ij}}$ for $i=1,2,\\cdots, N$, $j=1,2,\\cdots, J$.\nFor our simulation experiments we will consider 4 different types of observational noise; low variance independent noise (LN), high variance independent noise (HN), low variance isotropic spatially correlated noise with short range (LSN), and low variance isotropic spatially correlated noise with long range (HSN).\nIn all cases we assume the noise process is independent over time. \nWe consider the first two (LN and HS) as corresponding to experiments to discuss how the model deals with typical measurement error. \nThe second two noise models (LSN and HSN) correspond to an additional challenge to our models by testing their ability to recover the imagery even when there is spatially correlated noise which may look similar to that of a single functional variable. \nThis is of especially importance in some EO data, such as satellite imagery, where often noise corresponds to atmospheric interference which is spatially correlated, \\citep{oliver_understanding_2004}. \nWe consider two cases where the range of the spatial correlation changes, between short range in the LSN noise and long range\n dependency in the HSN noise. \nIn these two noise process they correspond to the noise process being spatially similar to the last and first functional principal component respectively.\n In both case we simulate the noise process using a Gaussian process with zero mean and  Mat\\`{e}rn covariance function. \n We modulate the smoothness of the spatially dependent noise processes by modifying  the length scale parameter of the generating covariance function.\n Table~\\ref{tab:ftsm_sim_noise_params} displays the noise process variance and shape parameters where applicable. \n \n\\begin{table}[htbp!] \n\t\\caption[Parameters for noise process in simulations for FTSM]{Variance, length scale and structure parameters for the four different simulated noise processes. Independent noise over space corresponds to a blank $\\nu$ and $\\rho$ parameters. }\n\t\\centering\n\t\\label{tab:ftsm_sim_noise_params}\n\t\\begin{tabular}{l c c  c}\n\t\t\\toprule\n\t\t& \\multicolumn{3}{c}{Parameter} \\\\ \n\t\tNoise Type & $\\sigma$ & $\\rho$& $\\nu$ \\\\\n\t\t\\midrule\n\t\tLN & 0.2 & - & - \\\\\n\t\tHN & 1.0 & - & -\\\\\n\t\tLSN & 0.2 & 0.2 & 2.5 \\\\\n\t\tHSN & 0.2 & 0.5 & 2.5 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\nThe impact of such noise can be see in Figure~\\ref{fig:ftsm_noise_example} which displays the imagery observed after adding the various noise types to the unobserved functional variable displayed in Figure~\\ref{fig:ftsm_chi_example_0}. \n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_noise_example_lin}\n\t\t\\caption{$LN$}\n\t\t\\label{fig:ftsm_noise_example_0}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_noise_example_hin}\n\t\t\\caption{$HN$}\n\t\\end{subfigure}\n\t\\vfill       \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_noise_example_lsn}\n\t\t\\caption{$LSN$}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{sim_noise_example_hsn}\n\t\t\\caption{$HSN$}\n\t\\end{subfigure}  \n\t\\caption{Example of the impact of the various noise structures to the observed simulated data. Each figure highlights adding a noise process to the unobserved functional variable displayed in Figure~\\ref{fig:ftsm_chi_example_0}.}\n\t\\label{fig:ftsm_noise_example}\n\\end{figure}\n\n\\subsection{Model parameters \\label{ssec:sim_params}}\nThe model described in Section~\\ref{sec:ftsm_model} has various hyper-parameter which control exactly how the model acts.\nWe specify these in the below, along with justification for such choices where needed.\n\nThe first set of hyper-parameters correspond to those of the basis system used for the basis expansion of the functional variables.\nIn our case we limit ourselves to B-spline basis system of order $4$, as described in Section~\\ref{ssec:basis_splines}.\nWe choose order $4$ b-spline functions as cubic functions are the standard in many applications, \\citep{de_boor_practical_2001}. \nWe choose $16$ basis functions across each dimension of our surfaces, giving a total number of $256$ basis functions for the tensor product basis system, as described in Section~\\ref{ssec:spline_reg}. \nThis is chosen as a trade off between flexibility to fit the surface and computational constraints. \nObviously the higher number of basis functions the closer we can recreate the observed data, however the additional computational cost in estimating these coefficients quickly grows as the number of basis functions in each dimension is increased.\nTo penalise the fitting, as described in Section~\\ref{ssec:spline_reg}, we use the GCV fitting procedure given in \\citep{wahba_spline_1990} with the tensor product penalty given by \\citep{wood_p-splines_2017}.\nWe choose the penalty order to be $1$ which essentially places first derivative smoothness over the marginal basis, again such a choice is standard in spline fitting. \n\nThe next set of hyper-parameters relates to the functional decomposition.\nWe choose to examine a maximum of $4$ principal components in our decomposition.\nThat is we set $K = 4$. \nThis is chosen as to be a fairly substantive dimensionality reduction whilst maintaining a degree representativeness as we know through our simulation that the first $3$ components should capture the majority of the variation.\nNext we set our MAFR operator $L$ to be the first order derivative.\nThis will again set out preference for smooth surfaces. \nAgain the first order derivative is chosen as it is often a standard in functional data analysis, \\citep{ramsay_functional_2010}. \n\nWe have already stated we choose the hyper-parameters to these processes by maximum likelihood estimation of the Gaussian process.\nThis estimation process is discussed in detail in \\citep{williams_gaussian_2006}.\n\nThe final set of simulation hyper-parameters refers to how we split between training and testing data.\nThe training and test data split depends on our objective of either interpolation or forecasting.\nFor interpolation we randomly select $30$ points of our time domain $\\mathcal{T}$ as training points and observe the noisy simulated data at these points.\nThe remaining time points then represent the test data which we will evaluate our model performance against.\nFor forecasting we split the time domain at the $54^\\text{th}$ time point.\nAny observation before this point becomes our training data with any point after being the test data which we will forecast for. \nThis gives a possibility of testing long range forecasting whilst maintaining enough training data to possibly infer patterns using the score process models.\n\n\\subsection{Results \\label{ssec:ftsm_sim_res}}\nWe present the results for interpolation and forecasting the simulated data in this Section separately, as they correspond to two separate objectives.\nWe repeat the simulation $100$ times for both interpolation and forecasting.\nThe simulation results are presented separately for each of our proposed models named FPCA and MAFR.\nThe details of such models are described in Section~\\ref{sec:ftsm_model} and the references within.\n\nAs a comparison to these methods we use a traditional PACE model using time as our functional variable.\nThe details of the PACE approach are set out in Section~\\ref{sec:pace}.\n\nThis is a typical model for such data.\nFor example, \\cite{hooker_maximal_2016} uses such an approach on a similar styled data set. \nHowever, this approach completely ignores any spatial dependency by instead treating each pixel as independent.\nInterpolation and forecasting using this methodology is performed by interpolating and extrapolating the spline basis functions in the model in standard ways, \\citep{de_boor_practical_2001}.\nTherefore it is mainly tailored towards interpolation as spline regression is well known to interpolate well but extrapolate poorly, \\citep{de_boor_practical_2001}.\nWe will denote this model by the term PACE for the following results. \n\n\nTo compare these models we use four metrics. \nWe use two standard measure of mean square error (RMSE) and mean absolute error (MAE).\nThese two are chosen to contrast the influence of any particularly large discrepancies between reconstruction and actual functional variables. \nThe next metric we use is the structure similarity index (SSIM), \\citep{wang_image_2004}.\nThe SSIM metric introduce by \\citeauthor{wang_image_2004} in \\citeyear{wang_image_2004} and enhanced in \\citeyear{wang_mean_2009} considers the case that standard metrics such as RMSE and MAE are not indicative of perceived similarity.\nFor example taking an grey-scale image and adding a constant value to the whole image will increase its RMSE and MAE however to the observer the image will only look brighter. \nSSIM tries to incorporate structural similarity when comparing imagery to highlight perceived similarity, \\citep{wang_mean_2009}. \nFor the SSIM metric a value of $1$ represents perfect similarity, the value of $-1$ represent perfect negative similarity, hence the close to $1$ the better for this metric.\nFor implementation details of such a metric we refer the reader to \\citep{wang_mean_2009}. \nThe final metric we employ is the Peak Signal to Noise Ration (PSNR). \nPSNR is commonly used to quantify image reconstruction quality. \nIt has been used extensively in medical imaging applications.\nFor the PSNR metric a higher value is better. \n\n\\subsubsection{Interpolation results}\nHere we present the metric results for interpolation across our test data set as described in Section~\\ref{ssec:sim_params}.\nThe results given are the metric value across all unobserved functional variables in the test set which we have interpolated.\nWe present both the average across simulations as well as the standard deviation of the metric values across simulations.\n\nTables~\\ref{tab:ftsm_sim_interp} displays the reconstruction results for interpolation from the various observations with the different noise processes structures. \nDiscussion of these results can be found in Section~\\ref{ssec:ftsm_sim_disc}. \n\n\\begin{table}[htbp!] \n\t\\caption[Simulation results for interpolation by noise scenario with the three models under consideration.]{Simulation results for interpolation by noise scenario for each model; PACE, FPCA, and MAFR. Bracketed values correspond to the standard deviation. Bold values illustrate best in class.}\n\t\\centering\n\t\\label{tab:ftsm_sim_interp}\n\t\\begin{tabular}{l l c c c c}\n\t\t\\toprule\n\t\t& & \\multicolumn{4}{c}{Metric} \\\\ \n\t\tNoise & Model & RMSE & MAE & SSIM & PSNR \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{LIN}& PACE & 0.25 (0.05) & 0.20 (0.04) & 0.80 (0.07) & 28.15 (3.37) \\\\\n\t\t& FPCA  & \\textbf{0.10 (0.05)} & \\textbf{0.08 (0.04)} & \\textbf{0.98 (0.02)} & \\textbf{35.27 (4.59)} \\\\\n\t\t& MAFR  & 0.12 (0.10) & 0.10 (0.08) & 0.97 (0.02)  & 34.66 (5.08) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{HIN} & PACE & 0.40 (0.06) & 0.32 (0.05) & 0.58 (0.09) & 24.26 (2.93) \\\\\n\t\t& FPCA  & \\textbf{0.16 (0.05)} & \\textbf{0.13 (0.04)} & \\textbf{0.95 (0.03)} & \\textbf{31.78 (4.23)} \\\\\n\t\t& MAFR  & 0.19 (0.07) & 0.15 (0.06) & 0.94 (0.03)  & 31.06 (4.30) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{LSN} & PACE & 0.50 (0.08) & 0.41 (0.07) & 0.88 (0.04) & 23.49 (2.59) \\\\\n\t\t& FPCA  & \\textbf{0.46 (0.07)} & \\textbf{0.38 (0.06)} & \\textbf{0.88 (0.05)} & \\textbf{23.56 (2.77)} \\\\\n\t\t& MAFR  & 0.48 (0.08) & 0.39 (0.06) & \\textbf{0.88 (0.05)}  & 23.45 (2.56)\\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{HSN} & PACE & 0.50 (0.10) & 0.42 (0.09) & \\textbf{0.93 (0.04)} & \\textbf{23.65 (3.12)}  \\\\\n\t\t& FPCA  & 0.51 (0.10) & 0.42 (0.09) & 0.90 (0.05) & 22.61 (2.72) \\\\\n\t\t& MAFR  & \\textbf{0.48 (0.10)} & \\textbf{0.40 (0.09)} & 0.92 (0.04) & 23.61 (2.71) \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\subsubsection{Forecasting results}\nHere we present the metric results for the forecasting ability of our models for our test data set as described in Section~\\ref{ssec:sim_params}.\nThe results given are the metric value at $h$-step ahead forecasts for the unobserved functional variables in the test set where $h$ is one of $1, 3, 6$.\nA single step ahead corresponds to observing the next image on our temporal grid $\\mathcal{T}$ constructed in our data generating process. \nThese correspond loosely to short, medium, and long range forecasts. \nThis provides an overview of the abilities of the model to forecast over various ranges.\nThese $h$ step ahead comparisons are standard in time series forecasting, \\citep{hyndman_forecasting_2018}. \nWe present both the average across simulations as well as the standard deviation of the metric values across simulations.\n\nTables~\\ref{tab:ftsm_sim_for} displays the reconstruction results for each model in our simulation studies under our forecasting scenario. \nDiscussion of these results can be found in Section~\\ref{ssec:ftsm_sim_disc}. \n\n\\begin{landscape}\n\\begin{table}\n\t\\caption[Simulation results for forecasting by noise scenario with the three models under consideration.]{Simulation results for the models ability to forecast unseen functional variables under the FTSM model at $1, 3, 6$ time steps ahead. Bracketed values correspond to the standard deviation. Bold values illustrate best in class.}\n\t\\centering\n\t\t\n\t\\label{tab:ftsm_sim_for}\n\t\\resizebox{1.6\\textwidth}{!}{\\begin{tabular}{l l c c c c c c c c c c c c}\n\t\t\\toprule\n\t\t& & \\multicolumn{12}{c}{Metric} \\\\ \n\t\t & & \\multicolumn{3}{c}{RMSE} &  \\multicolumn{3}{c}{MAE} &  \\multicolumn{3}{c}{SSIM} &  \\multicolumn{3}{c}{PSNR} \\\\\n\t\tNoise & Model & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$\\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{LIN} & PACE & 0.35 (0.12) & 0.68 (0.27) & 1.14 (0.49)) & 0.28 (0.09) & 0.54 (0.22) & 0.92 (0.40) & 0.60 (0.14) & 0.41 (0.17) & 0.29 (0.19) & 20.21 (3.60) & 19.18 (2.98) & 17.28 (4.03)  \\\\\n\t\t& FPCA  & 0.10 (0.05) & 0.28 (0.17) & \\textbf{0.59 (0.33)} & \\textbf{0.08 (0.04)} & 0.23 (0.14) & \\textbf{0.48 (0.27)} & \\textbf{0.94 (0.06)} & \\textbf{0.90 (0.14)} & \\textbf{0.74 (0.27)} & \\textbf{28.42 (7.01)} & \\textbf{25.72 (5.97)} & \\textbf{20.38 (6.07)} \\\\\n\t\t& MAFR  & \\textbf{0.10 (0.05)} & \\textbf{0.28 (0.16)} & 0.60 (0.36) & \\textbf{0.08 (0.04)} & \\textbf{0.23 (0.13)} & 0.49 (0.29) & \\textbf{0.94 (0.06)} & 0.88 (0.15) & 0.73 (0.27) & 28.04 (6.46) & 25.39 (5.60) & 20.21 (5.74) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{HIN} & PACE& 0.53 (0.18) & 0.90 (0.35) & 1.36 (0.54) & 0.43 (0.14) & 0.72 (0.28) & 1.09 (0.43) & 0.44 (0.11) & 0.29 (0.12) & 0.19 (0.13)  & 18.37 (2.76) & 17.62 (2.36) & 16.17 (3.28) \\\\\n\t\t& FPCA  & \\textbf{0.17 (0.08)} & \\textbf{0.34 (0.19)} & \\textbf{0.63 (0.32)} & \\textbf{0.14 (0.06)} & \\textbf{0.28 (0.16)} & \\textbf{0.52 (0.27)} & \\textbf{0.90 (0.11)} & \\textbf{0.86 (0.15)} & \\textbf{0.72 (0.27)} & \\textbf{25.62 (5.60)} & \\textbf{23.81 (5.34)} & \\textbf{19.47 (5.58)}  \\\\\n\t\t& MAFR  & \\textbf{0.17 (0.08)} & 0.36 (0.19) & 0.69 (0.37) & 0.14 (0.07) & 0.29 (0.15) & 0.57 (0.31) & 0.88 (0.12) & 0.83 (0.17) & 0.70 (0.25) & 24.72 (5.61) & 22.64 (4.88) & 18.68 (5.42)  \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{LSN} & PACE & 0.74 (0.26) & 1.21 (0.49) & 1.72 (0.64) & 0.61 (0.22) & 1.00 (0.42) & 1.42 (0.54) & 0.76 (0.13) & 0.63 (0.19) & 0.47 (0.26)  & 18.37 (3.28) & 16.54 (3.21) & 14.12 (3.57) \\\\\n\t\t& FPCA  & \\textbf{0.54 (0.24)} & \\textbf{0.70 (0.35)} & \\textbf{0.90 (0.45)} & \\textbf{0.44 (0.19)} & \\textbf{0.58 (0.28)} & \\textbf{0.74 (0.38)} & 0.77 (0.20) & 0.70 (0.25) & 0.59 (0.31) & \\textbf{19.86 (4.72)} & \\textbf{18.52 (4.56)} & \\textbf{16.53 (4.96)}  \\\\\n\t\t& MAFR  & 0.56 (0.20) & 0.74 (0.30) & 0.97 (0.44) & 0.47 (0.16) & 0.61 (0.25) & 0.80 (0.37) & \\textbf{0.78 (0.17)} & \\textbf{0.72 (0.21)} & \\textbf{0.61 (0.28)} & 19.54 (4.32) & 18.29 (4.21) & 16.22 (4.42) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{HSN} & PACE & 0.74 (0.29) & 1.21 (0.47) & 1.71 (0.68) & 0.62 (0.25) & 1.01 (0.42) & 1.43 (0.60) & \\textbf{0.82 (0.13)} & 0.70 (0.21) & 0.54 (0.32) & 18.45 (3.34) & 17.01 (3.37) & 14.86 (4.17)  \\\\\n\t\t& FPCA  & 0.60 (0.23) & 0.75 (0.34) & \\textbf{0.94 (0.46)} & 0.50 (0.19) & \\textbf{0.62 (0.29)} & \\textbf{0.78 (0.39)} & 0.79 (0.20) & \\textbf{0.74 (0.22)} & 0.62 (0.29) & 19.87 (4.97) & 18.83 (4.89) & 16.43 (4.75)  \\\\\n\t\t& MAFR  & \\textbf{0.59 (0.24)} & \\textbf{0.75 (0.33)} & 0.97 (0.46) & \\textbf{0.49 (0.21)} & 0.63 (0.28) & 0.81 (0.40) & 0.82 (0.17) & 0.76 (0.21) & \\textbf{0.64 (0.30)}  & \\textbf{20.22 (4.83)} & \\textbf{18.98 (4.66)} & \\textbf{16.65 (4.85)} \\\\\n\t\t\\bottomrule\n\t\\end{tabular}}\n\\end{table}\n\\end{landscape}\n\n\\subsection{Discussion \\label{ssec:ftsm_sim_disc}}\n\nWe discuss the preceding results for the FPCA and MAFR models in the following section.\nWe discuss the results relative to the PACE model as described in Section~\\ref{ssec:ftsm_sim_res} under both the interpolation and forecasting objectives.\n\nTable~\\ref{tab:ftsm_sim_interp} states the mean and standard deviations of the estimation error under the various metrics discussed in Section~\\ref{ssec:ftsm_sim_res} for the interpolation metric.\nWe can see clearly an advantage of using the FPCA model over the PACE model under most metrics in nearly all noise process scenarios.\nThe only exception to this being nuder the highly structured spatial noise process, denoted by HSN, where the FPCA model is inferior to the MAFR and PACE models. \nThis advantage is most prominent under the independent noise scenarios where it seems that the additional spatial smoothness constraints that the model enforces nullifies the impact of the spatially independent noise.\nSimilarly, the relative deterioration in the FPCA model under structured noise agrees with this effect.\nIn fact it is possible that due to the noise process being highly similar to the leading functional principal components in the HSN scenario that the FPCA model may conflate the two, hence giving reduced performance.\n\nThe MAFR model has similar performance to that of the FPCA model; as expected, due to it being a rotated version of the FPCA model.\nIt is narrowly but consistently beaten on most noise scenarios, except for the HSN.\nHere, the fact that the MAFR model prioritises smoothness in its components, \\citep{hooker_maximal_2016}, has meant that we have overcome some of the trouble that the FPCA model faced of conflating the noise and signal processes. \nWe can see this effect by examining the second functional principal component for both the FPCA and MAFR model for a single simulation under the HSN noise scenario as an example.\nFigure~\\ref{fig:ftsm_res_example_fpc} shows exactly this.\nThe actual functional principal components for this simulation are given in Figure~\\ref{fig:ftsm_example_fpc}.\n\n\\begin{figure}[!htbp]\n\t\\centering\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_fpc_example_fpca}\n\t\t\\caption{FPCA}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_fpc_example_mafr}\n\t\t\\caption{MAFR}\n\t\\end{subfigure}\n\t\\caption[Comparison of the second functional principal component under FPCA and MAFR models.]{Comparison of the second functional principal component recovered under the FPCA model and the MAFR model for an example simulation under the HSN noise scenario. Notice how the MAFR component is much smoother over the domain.}\n\t\\label{fig:ftsm_res_example_fpc}\n\\end{figure}\n\nIn addition, this rotation has caused the score processes to be correlated to the point that leading components will have smoother scores, aiding in removing the noise process which will have random walk like behaviour in the scores process due to it being independent over time.\nThis is illustrated in Figure~\\ref{fig:ftsm_res_example_zeta} where we can see hat although both score processes aren't particularly smooth the MAFR process exhibits less variation. \n\n\\begin{figure}[htbp!] \n\t\\centering    \n\t\\includegraphics[width=1.0\\textwidth]{ftsm_res_zeta_example}\n\t\\caption{Comparison of the second score process corresponding to the second functional principal component given in Figure~\\ref{fig:ftsm_res_example_fpc}. Notice how the MAFR score process exhibits less variation over time compared to the FPCA process.}\n\t\\label{fig:ftsm_res_example_zeta}\n\\end{figure}\n\nThe result for the forecasting objective are given in Table~\\ref{tab:ftsm_sim_for}.\nHere, we see similar results to that which were observed in the interpolation objective.\nWe see both the FPCA and MAFR models outperform the PACE model under most noise scenarios.\nSimilarly to the interpolation results we see the most improvement under spatially independent noise processes.\nAgain, this is due to the added ability of the FPCA and MAFR models to filter out any process which isn't particularly smooth over space. \nInterestingly, we also see a greater improvement in reconstruction for the long term forecast rather than the one step ahead short term forecast relative to the PACE model.\nThis is good as it suggests that the FPCA and MAFR approaches capture the spatio-temporal process in such a way that is easier to forecast. \nFigure~\\ref{fig:ftsm_res_recon} highlights this ability by illustrating the unobserved surface and estimated surfaces for each model under the LIN noise scenario at three time steps ahead.\n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_recon_example_unob}\n\t\t\\caption{$Unobserved$}\n\t\t\\label{fig:ftsm_res_recon_unob}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_recon_example_pace}\n\t\t\\caption{$PACE$}\n\t\t\\label{fig:ftsm_res_recon_pace}\n\t\\end{subfigure}\n\t\\vfill       \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_recon_example_fpca}\n\t\t\\caption{$FPCA$}\n\t\t\\label{fig:ftsm_res_recon_fpca}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_recon_example_mafr}\n\t\t\\caption{$MAFR$}\n\t\t\\label{fig:ftsm_res_recon_mafr}\n\t\\end{subfigure}  \n\t\\caption[Example of the impact of the various models to reconstruct the unobserved surface at three steps ahead.]{Example of the impact of the various models to reconstruct the unobserved surface at three steps ahead. The observed process was corrupted by the LN noise process. We note how the PACE model is easily overfitting to the independent noise process whereas the FPCA and MAFR models do not suffer this effect.}\n\t\\label{fig:ftsm_res_recon}\n\\end{figure}\n\nAgain the FPCA and MAFR approaches result in similar results, with the FPCA model edging the results for the majority of the noise processes.\nSimilarly to the interpolation results we see that the MAFR model tends to perform better under the HSN noise scenario. \nThis is due to the same reasons as the interpolation results described above. \n\nThese results offer a good indication that including spatial information into the model for such data sets can have a material impact on both interpolating and forecasting objectives. \nThe next test for such models is then to see how this improvement translates to data sets not necessarily coming from the data generating procedure.\nWe consider this by applying these model to our EO dataset as discussed in Chapter~\\ref{cha:data} in the next section. \n\n\\section{EO Application \\label{sec:ftsm_eo}}\nWe apply the same models as used in the simulation model to our CESM-LE data set as described in Chapter~\\ref{cha:data}.\nThis data set acts as an example to highlight the performance of the various models described above on a real world data set. \nWe perform the exact same analysis as in the simulation study but this time apply it to the $40$ replications of the CESM-LE data for the various atmospheric variable. \n\nWe use the exact same model parameter setup as described in Section~\\ref{ssec:sim_params} to setup the models for the EO application study.\nWe detail the results of the study in Section~\\ref{ssec:ftsm_eo_res}.\n\n\\subsection{Results \\label{ssec:ftsm_eo_res}}\nWe present the reconstruction results for the objectives of interpolation and forecasting separately. \nWe repeat the model fitting and reconstruction procedure independently for the $40$ realisations of the CESM-LE data set and provide both the mean metric measures as well as their standard deviations across these realisations. \nWe use the same $4$ metrics as used in the simulation study for consistency. \n\n\\subsubsection{Interpolation results}\nHere we present the metric results for interpolation for our test data set from our CESM-LE EO observations, as described in Chapter~\\ref{cha:data}.\nSee Section~\\ref{ssec:sim_params} for the construction methodology of the test and training data sets. \nThe results given are the metric value across all unobserved functional variables in the test set which we have interpolated.\nWe present both the average across simulations as well as the standard deviation of metric values across simulations.\n\nTable~\\ref{tab:ftsm_eo_interp} displays the reconstruction results for interpolation from the various atmospheric variables.\nDiscussion of these results can be found in Section~\\ref{ssec:ftsm_eo_disc}.\n\n\\begin{table}[htbp!] \n\t\\caption[CESM-LE results for interpolation by atmospheric components with various FTSM models]{CESM-LE results for interpolation by atmospheric components with various FTSM models. Bracketed values correspond to the standard deviation.}\n\t\\centering\n\t\\label{tab:ftsm_eo_interp}\n\t\\resizebox{\\textwidth}{!}{\\begin{tabular}{l l c c c c}\n\t\t\\toprule\n\t\t& & \\multicolumn{4}{c}{Metric} \\\\ \n\t\tComponent & Model & RMSE & MAE & SSIM & PSNR \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{TMQ}&PACE & \\textbf{5.60 (0.52)} & \\textbf{4.31 (0.47)} & \\textbf{0.73 (0.05)} & \\textbf{18.61 (1.49)} \\\\\n\t\t& FPCA  & 6.08 (0.30) & 4.56 (0.25) & 0.70 (0.01) & 18.19 (0.52) \\\\\n\t\t& MAFR  &6.03 (0.30) & 4.52 (0.25) & 0.70 (0.01)  & 18.39 (0.75) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{PS} & PACE & \\textbf{511.40 (30.69)} & \\textbf{374.56 (22.04)} & \\textbf{0.99 (0.00)} & \\textbf{33.83 (3.35)} \\\\\n\t\t& FPCA  & 2976.61 (4.81) & 1814.34 (6.92) & 0.70 (0.00) & 21.50 (0.49) \\\\\n\t\t& MAFR  & 2977.02 (5.68) & 1815.04 (7.44) & 0.70 (0.00)  & 21.51 (0.52) \\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{TREFHT} & PACE & \\textbf{6.80 (1.05)} & \\textbf{5.05 (0.84)} & \\textbf{0.90 (0.02)} & \\textbf{23.69 (2.58)} \\\\\n\t\t& FPCA  & 7.45 (0.35) & 5.33 (0.25) & 0.84 (0.00) & 20.43 (0.44) \\\\\n\t\t& MAFR  & 7.48 (0.47) & 5.38 (0.37) & 0.83 (0.00)  & 20.39 (0.36)\\\\\n\t\t\\midrule\n\t\t\\multirow{3}{*}{U10} & PACE & \\textbf{1.25 (0.12)} & \\textbf{0.92 (0.08)} & \\textbf{0.76 (0.03)} & \\textbf{19.27 (1.70)}  \\\\\n\t\t& FPCA  & 1.55 (0.03) & 1.20 (0.02) & 0.55 (0.00) & 16.33 (0.77) \\\\\n\t\t& MAFR  &1.55 (0.03) & 1.19 (0.02) & 0.55 (0.00) & 16.32 (0.81) \\\\\n\t\t\\bottomrule\n\t\\end{tabular}}\n\\end{table}\n\n\\subsubsection{Forecasting results}\nHere we present the metric results for the forecasting ability of our models for our test data set from our CESM-LE EO observations, as described in Chapter~\\ref{cha:data}.\nSee Section~\\ref{ssec:sim_params} for the construction methodology of the test and training data sets. \nThe results given are the metric value at $h$-step ahead forecasts for the unobserved functional variables in the test set where $h$ is one of $1, 3, 6$. \nThese correspond to short, medium, and long range forecasts.\nIn the CESM-LE data set each step corresponds to a month interval.\nThis provides an overview of the abilities of the model to forecast over various ranges.\nWe present both the average across simulations as well as the standard deviation of the metric values across simulations.\n\nTables~\\ref{tab:ftsm_eo_for} displays the reconstruction results for each model in our simulation studies under our forecasting scenario. \nDiscussion of these results can be found in Section~\\ref{ssec:ftsm_eo_disc}.\n\n\\begin{landscape}\n\t\\begin{table}\n\t\t\\caption[CESM-LE results for forecasting by variable with various FTSM model]{CESM-LE results for the models ability to forecast unseen functional variables under the FTSM models at $1, 3, 6$ time steps ahead. Bracketed values correspond to the standard deviation. Bold represents best in class.}\n\t\t\\centering\n\t\t\\label{tab:ftsm_eo_for}\n\t\t\\resizebox{1.6\\textwidth}{!}{\\begin{tabular}{l l c c c c c c c c c c c c}\n\t\t\t\\toprule\n\t\t\t& & \\multicolumn{12}{c}{Metric} \\\\ \n\t\t\t& & \\multicolumn{3}{c}{RMSE} &  \\multicolumn{3}{c}{MAE} &  \\multicolumn{3}{c}{SSIM} &  \\multicolumn{3}{c}{PSNR} \\\\\n\t\t\tNoise & Model & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$ & $h=1$ & $h=3$ & $h=6$\\\\\n\t\t\t\\midrule\n\t\t\t\\multirow{3}{*}{TMQ} & PACE & \\textbf{3.50 (0.67)} & \\textbf{5.92 (1.34)} & 5.81 (2.20) & \\textbf{2.41 (0.54)} & \\textbf{4.71 (1.04)} & 4.17 (1.72) & 0.45 (0.02) & 0.51 (0.03) & 0.39 (0.03) & 12.22 (0.50) & 13.30 (0.48) & 11.78 (0.46)  \\\\\n\t\t\t& FPCA  & 4.11 (0.46) & 9.62 (1.17) & 5.16 (0.86) & 2.71 (0.36) & 7.48 (0.99) & 3.65 (0.67) & \\textbf{0.77 (0.01)} & \\textbf{0.60 (0.05)} & \\textbf{0.72 (0.03)} & 20.30 (0.89) & \\textbf{16.27 (1.10)} & 18.96 (1.03)  \\\\\n\t\t\t& MAFR  & 4.12 (0.52) & 9.61 (1.20) & \\textbf{5.12 (0.98)} & 2.75 (0.42) & 7.46 (1.02) & \\textbf{3.62 (0.77)} & 0.77 (0.02) & \\textbf{0.60 (0.05)} & \\textbf{0.72 (0.03)} & \\textbf{20.33 (0.84)} & 16.24 (1.11) & \\textbf{19.00 (0.86)} \\\\\n\t\t\t\\midrule\n\t\t\t\\multirow{3}{*}{PS} & PACE & \\textbf{572.92 (254.02)} & \\textbf{1416.61 (3179.94)} & 4167.61 (19882.51) & \\textbf{440.70 (243.79)} & \\textbf{1176.94 (3209.63)} & 3919.64 (19920.73) & \\textbf{0.98 (0.06)} & \\textbf{0.98 (0.06)}  & \\textbf{0.97 (0.07)} & \\textbf{32.54 (5.30)} & \\textbf{33.17 (5.42)} & \\textbf{33.09 (5.88)}\\\\\n\t\t\t& FPCA  & 2963.55 (16.73) & 2962.08 (13.00) & 2967.76 (11.98) & 1801.39 (26.40) & 1800.56 (20.45) & 1810.16 (24.96) & 0.70 (0.00) & 0.70 (0.00) & 0.69 (0.00) & 20.96 (0.46) & 21.03 (0.46) & 21.16 (0.44)  \\\\\n\t\t\t& MAFR  & 2962.67 (17.11) & 2962.55 (15.21) & \\textbf{2965.04 (9.17)} & 1800.63 (27.52) & 1802.48 (25.31) & \\textbf{1804.88 (20.88)} & 0.70 (0.00) & 0.70 (0.00) & 0.69 (0.00) & 20.96 (0.36) & 21.03 (0.38) & 21.17 (0.35)  \\\\\n\t\t\t\\midrule\n\t\t\t\\multirow{3}{*}{TREFHT} &PACE & 10.13 (0.59) & 27.36 (1.16) & 30.60 (1.13) & 6.90 (0.36) & 18.52 (0.80) & 20.17 (0.79) & 0.81 (0.01) & \\textbf{0.81 (0.01)} & 0.59 (0.01)  & 17.48 (0.54) & 18.04 (0.68) & 17.03 (0.49)  \\\\\n\t\t\t& FPCA  & \\textbf{5.87 (1.31)} & \\textbf{10.75 (1.66)} & \\textbf{4.42 (1.05)} & \\textbf{4.03 (0.89)} & \\textbf{7.66 (1.28)} & \\textbf{3.34 (0.83)} & \\textbf{0.85 (0.02)} & 0.77 (0.03) & \\textbf{0.85 (0.01)} & \\textbf{21.59 (1.39)} & \\textbf{18.80 (1.59)} & \\textbf{21.56 (0.77)}  \\\\\n\t\t\t& MAFR  & 6.29 (1.05) & 11.30 (1.36) & 4.65 (1.18) & 4.36 (0.73) & 8.12 (1.15) & 3.56 (1.01) & 0.84 (0.01) & 0.76 (0.02) & 0.84 (0.02) & 21.19 (1.00) & 18.26 (1.15) & 21.40 (0.85) \\\\\n\t\t\t\\midrule\n\t\t\t\\multirow{3}{*}{U10} & PACE & \\textbf{1.21 (0.07)} & \\textbf{1.51 (0.12)} & \\textbf{1.27 (0.11)} & \\textbf{0.91 (0.06)} & \\textbf{1.11 (0.10)} & \\textbf{0.92 (0.08)} & \\textbf{0.78 (0.02)} & \\textbf{0.71 (0.03)} & \\textbf{0.74 (0.03)} & \\textbf{21.47 (0.74)} & \\textbf{19.84 (0.88)} & \\textbf{21.31 (0.82)}  \\\\\n\t\t\t& FPCA  & 1.43 (0.06) & 1.75 (0.11) & 1.41 (0.06) & 1.12 (0.05) & 1.34 (0.09) & 1.10 (0.05) & 0.56 (0.02) & 0.50 (0.03) & 0.56 (0.02) & 16.50 (0.83) & 16.05 (0.85) & 17.03 (0.74)  \\\\\n\t\t\t& MAFR  & 1.43 (0.05) & 1.75 (0.09) & 1.41 (0.04) & 1.12 (0.05) & 1.34 (0.08) & 1.10 (0.04) & 0.56 (0.02) & 0.49 (0.02) & 0.56 (0.02)  & 16.37 (0.61) & 15.93 (0.59) & 16.91 (0.53) \\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}}\n\t\\end{table}\n\\end{landscape}\n\n\\subsection{Discussion \\label{ssec:ftsm_eo_disc}}\nWe discuss the preceding results for the FPCA and MAFR models with application on the CESM-LE data set in the following section.\nWe discuss the results relative to the PACE model as described in Section~\\ref{ssec:ftsm_sim_res} under both the interpolation and forecasting objectives.\n\nEvidently, from Table~\\ref{tab:ftsm_eo_interp}, the PACE model outperforms both the FPCA and MAFR models for all atmospheric variables studied across all metrics.\nThis is particularly the case for the PS and U10 variables. \nThe reason for this divergence from the PACE model can be seen by considering an example from the PS variable.\nFigure~\\ref{fig:ftsm_res_ps} gives the unobserved surface and the estimated surfaces from the PACE, FPCA, and MAFR models.\nWe can clearly see from this that the FPCA and MAFR models, although they capture large scale spatial patterns, fail to capture the small scale spatial variation.\nIn this case this causes very divergent results as seen by the metrics in Table~\\ref{tab:ftsm_eo_interp}. \nThe reason for this lack of flexibility of the FPCA and MAFR models is that the number of basis functions to represent the surface is not high enough to capture such spatial variability. \nTherefore, an obvious way to perhaps alleviate this problem is to simply increase the dimension of the spline representation of these surfaces. \nHowever, this comes with additional computation cost.\nAnother possibility is to just consider the FPCA and MAFR models on smaller sections of the domain which may vary less.\nIt is reassuring however to see that the FPCA and MAFR models do capture the large scale spatial variation well.\nIn fact, as the FPCA and MAFR metric values tend to vary less than those of the PACE model, if one is interested in large scale variation these models may well still be preferred.\n\n \\begin{figure}\n \t\\centering\n \t\\begin{subfigure}[b]{0.45\\textwidth}\n \t\t\\includegraphics[width=\\textwidth]{ftsm_res_ps_example_unob}\n \t\t\\caption{$Unobserved$}\n \t\t\\label{fig:ftsm_res_ps_unob}\n \t\\end{subfigure}             \n \t\\begin{subfigure}[b]{0.45\\textwidth}\n \t\t\\includegraphics[width=\\textwidth]{ftsm_res_ps_example_pace}\n \t\t\\caption{$PACE$}\n \t\t\\label{fig:ftsm_res_ps_pace}\n \t\\end{subfigure}\n \t\\vfill       \n \t\\begin{subfigure}[b]{0.45\\textwidth}\n \t\t\\includegraphics[width=\\textwidth]{ftsm_res_ps_example_fpca}\n \t\t\\caption{$FPCA$}\n \t\t\\label{fig:ftsm_res_ps_fpca}\n \t\\end{subfigure}\n \t\\begin{subfigure}[b]{0.45\\textwidth}\n \t\t\\includegraphics[width=\\textwidth]{ftsm_res_ps_example_mafr}\n \t\t\\caption{$MAFR$}\n \t\t\\label{fig:ftsm_res_ps_mafr}\n \t\\end{subfigure}  \n \t\\caption[Example of the reconstruction ability of the various models for the PS atmospheric variable component of the CESM-LE data set.]{Example of the reconstruction ability of the various models for the PS atmospheric variable component of the CESM-LE data set. Notice how the FPCA and MAFR models miss the small scale spatial variation present in the unobserved surface. They have particular issue in recreating the abrupt changes at the sea-land boundary.}\n \t\\label{fig:ftsm_res_ps}\n \\end{figure}\n\nThe forecasting results, given in Table~\\ref{tab:ftsm_eo_for}, show similar results.\nHowever, here we see the increasing impact of the FPCA and MAFR models. \nEspecially in the atmospheric variables of TMQ and TREFHT we see an advantage in using the FPCA and MAFR models.\nHere we see, slightly inverse to the interpolation results, that although the PACE model can deal with small scale spatial variation it struggles to model coherence through time using the spline extrapolation.\nWhereas, the FPCA and MAFR models produce score processes which can evidently be more easily forecast using the Gaussian process methodology outlined in Section~\\ref{sec:ftsm_forecast}.\nAgain, we see little difference between the FPCA and MAFR models in both the interpolation and forecasting objectives. \n\n\\section{Summary \\label{sec:ftsm_summary}}\nIn this chapter we have considered a model for EO data sets based on the FTSM technique discussed in Section~\\ref{sec:fts}.\nWe have considered, relatively uniquely, the idea that we consider our data set as a time series of surfaces over our spatial domain and use the functional time series methodology discussed by \\citep{hyndman_forecasting_2009} to provide a elegant way to forecast such data sets.\nWe also have considered an rotation to such models which, as discussed in Section~\\ref{ssec:mafr}, may perhaps promote better forecasting ability.\nThis is compared against standard techniques that treat the data as a collection of independent functions over time, with each function corresponding to a spatial location. \n\n\nWe have seen in Section~\\ref{ssec:ftsm_sim_res} that on simulated data sets this technique works well.\nWe have compared these techniques under a variety of noise processes, including spatially structured noise which is often more realistic than independent noise processes in EO data.\nWe find on the whole they work equally well as the standard methodology which ignores spatial dependency between observations for interpolation, and outperforms this technique when forecasting.\n\nHowever, on the CESM-LE data this technique falls down due to its difficulty in recreating small spatial scale variation.\nAs discussed in Section~\\ref{ssec:ftsm_eo_disc} this is due to our smoothing methodology to represent each observed surface using b-spline basis functions.\nGiven ample computation time this can be relieved by extending the dimension of this basis system.\nHowever this is not always possible, and represents a real limitation of such methodologies.\n\nA final advantage of such FTSM techniques for EO data is their ability to reduce the data set dimension by introducing functional principal components which have a spatial domain.\nThese components can help to inform about modes of variation that are occurring over space.\nSuch dissections of the data can be incredibly useful in understanding the processes under examination. \nFor example, Figure~\\ref{fig:ftsm_res_TREFHT_fpc} gives the first two components for the TREFHT atmospheric variable of the CESM-LE data set.\nWe can see clearly how the first corresponds to large scale variation between regions in the northern hemisphere whilst the second contains more localised areas of variation. \nWe have further seen how the MAFR rotation can help to promote smooth functional principal components which may aide interpretability. \n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_TREFHT_fpc_0}\n\t\t\\caption{$\\vesub{\\bar{\\phi}}{1}$}\n\t\t\\label{fig:ftsm_res_TREFHT_fpc_1}\n\t\\end{subfigure}             \n\t\\begin{subfigure}[b]{0.45\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{ftsm_res_TREFHT_fpc_1}\n\t\t\\caption{$\\vesub{\\bar{\\phi}}{2}$}\n\t\t\\label{fig:ftsm_res_TREFHT_fpc_2}\n\t\\end{subfigure}\n\t\\caption[Example of the functional principal components generated by the FPCA model with the TREFHT variable.]{Example of the functional principal components generated by the FPCA model with the TREFHT variable of the CESM-LE data set. Notice how each component shows a different mode of spatial variation present in the process. Such decompositions like these can be incredibly useful to understanding the process as a whole.}\n\t\\label{fig:ftsm_res_TREFHT_fpc}\n\\end{figure}\n\nThe standard PACE methodology can be seen to do well on real world EO data set due to its ability to capture small scale variations.\nThis occurs essentially because we treat each spatial location independently.\nHowever, we have seen from both the FPCA and MAFR models that incorporating spatial information can be useful in recovering unobserved surfaces.\nUtilising spatial dependency also has the added benefit of helping to ignore unstructured noise processes. \nA combination of both methodologies may then be desirable; that is to incorporate spatial information into the PACE model.\nThe challenge is then to do so in such a way that keeps the model performing well where there exists small scale spatial variation.\nIn the following chapters we consider such a model. ", "meta": {"hexsha": "fc1caffaae9d917c2785a955d52cba3cce258af2", "size": 68456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter4/chapter4.tex", "max_stars_repo_name": "JulianAustin1993/thesis", "max_stars_repo_head_hexsha": "8b8cc587fbcd9a86a6d3834ddd38823799797b70", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter4/chapter4.tex", "max_issues_repo_name": "JulianAustin1993/thesis", "max_issues_repo_head_hexsha": "8b8cc587fbcd9a86a6d3834ddd38823799797b70", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter4/chapter4.tex", "max_forks_repo_name": "JulianAustin1993/thesis", "max_forks_repo_head_hexsha": "8b8cc587fbcd9a86a6d3834ddd38823799797b70", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 82.6763285024, "max_line_length": 486, "alphanum_fraction": 0.7483493047, "num_tokens": 19696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.5888891307678319, "lm_q1q2_score": 0.42317242721568965}}
{"text": "% Template source: University of Florida Department of Physics, https://www.phys.ufl.edu/courses/phy4803L/sample-paper.zip\n\n\\documentclass[aps,twocolumn,secnumarabic,nobalancelastpage,amsmath,amssymb,nofootinbib,letterpaper]{revtex4}\n\n% Documentclass Options\n    % aps, prl, rmp stand for American Physical Society, Physical Review Letters, and Reviews of Modern Physics, respectively\n    % twocolumn permits two columns, of course\n    % nobalancelastpage doesn't attempt to equalize the lengths of the two columns on the last page\n        % as might be desired in a journal where articles follow one another closely\n    % amsmath and amssymb are necessary for the subequations environment among others\n    % secnumarabic identifies sections by number to aid electronic review and commentary.\n    % nofootinbib forces footnotes to occur on the page where they are first referenced\n        % and not in the bibliography\n    % REVTeX 4 is a set of macro packages designed to be used with LaTeX 2e.\n        % REVTeX is well-suited for preparing manuscripts for submission to APS journals.\n\n\n\\usepackage{chapterbib}    % allows a bibliography for each chapter (each labguide has it's own)\n\\usepackage{color}         % produces boxes or entire pages with colored backgrounds\n\\usepackage{graphics}      % standard graphics specifications\n\\usepackage[pdftex]{graphicx}      % alternative graphics specifications\n\\usepackage{longtable}     % helps with long table options\n\\usepackage{epsf}          % old package handles encapsulated post script issues\n\\usepackage{bm}            % special 'bold-math' package\n\\usepackage{verbatim}\t\t\t% for comment environment\n\\usepackage[colorlinks=true]{hyperref}  % this package should be added after all others\n                                        % use as follows: \\url{https://urldefense.proofpoint.com/v2/url?u=http-3A__web.mit.edu_8.13&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=D88uS55Tats-jlFQAC1XryFUYq8B7Lk3StFbXzgsiB4&m=Vjrc9Wj5n5rkIDMPJ5VsRj2GyXC3yXmN_zDHey6dVio&s=_byqsJfgO464rVIugNWFPmbBeIYfNiJcGS1fgIwc0m4&e= }\n\\usepackage{siunitx}\n\\usepackage{textcomp}\n\\usepackage{gensymb}\n\n\\usepackage[english]{babel}\n\\usepackage[autostyle, english=american]{csquotes}\n\\MakeOuterQuote{\"}\n\n%\\addtolength\\topmargin{-.5\\topmargin} %cuts the top margin in half.\n\n%\n% And now, begin the document...\n% Students should not have to alter anything above this line\n%\n\n\\begin{document}\n\\title{Lab 1: Calculating the \\(Q\\) Value of a Pendulum}\n\\author{Tyler Tian}\n\\noaffiliation\n\\date{\\today}\n\n\n\\begin{abstract}\nIn this experiment, a simple pendulum is constructed out of readily available materials, and its motion is tracked using\na computer vision algorithm in order to measure its \\(Q\\) factor. \\(Q\\) is measured using two methods: using a\nleast-squares fit of the theoretical model to the data, and counting the number of oscillations until it decays to some\nfactor of the initial amplitude. The two methods produced \\(Q\\) values that were different, but could still be in\nagreement due to uncertainties.\n\nSome interesting observations were made: 1. the measured \\(Q\\) value through oscillation counting depends on the\nfraction of \\(Q\\) being measured, 2. the model does not fit the data very well, especially for large time values, and 3.\nthe period of the pendulum appears to decrease slightly with time.\n\\end{abstract}\n\n\\maketitle\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Introduction}\n\nFor this experiment, a simple pendulum is constructed and its \\(Q\\) factor is measured using two methods:\nfitting data collected from it to a mathematical model, and through counting oscillations.\n\nThe mathematical model used for this lab is\n\\begin{equation}\n    \\theta(t) = \\theta_0 e^{-\\frac{t}{\\tau}}\\cos\\left(2\\pi\\frac{t}{T} + \\phi_0\\right)\n    \\label{eqn:model}\n\\end{equation}\nwhere $\\theta(t)$ is the angle of the pendulum in radians at time $t$, $\\theta_0$ is the initial amplitude at release,\n$\\tau$ is the time constant of decay, $T$ is the period and $\\phi_0$ is the phase shift.\n\nThe \\(Q\\) factor is then defined as\n\\begin{equation}\n    Q = \\pi\\frac{\\tau}{T}\n    \\label{eqn:q}\n\\end{equation}\n\nMeasuring \\(Q\\) using oscillation counting relies on the mathematical property that after \\(\\frac{Q}{n}\\) oscillations\n(i.e. \\(t = T\\frac{Q}{n}\\)), the amplitude becomes\n\\begin{equation}\n    \\theta_0 e^{-\\frac{t}{\\tau}} = \\theta_0 e^{-\\frac{T\\frac{Q}{n}}{\\tau}} = \\theta_0 e^{-\\frac{T\\frac{\\pi\\frac{\\tau}{T}}{n}}{\\tau}} = \\theta_0 e^{-\\frac{\\pi}{n}}\n\\end{equation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Method}\n\n\\subsection{Pendulum Construction}\n\n\\begin{figure}[htb]\n    \\includegraphics[width=0.6\\linewidth]{pendulum.png}\n    \\caption{The pendulum constructed for this experiment.}\n\\end{figure}\n\nThe main support structure of the pendulum consists of two pieces of wood, attached together with screws and an\nL-bracket. This was chosen because the material was readily available, and could be substituted for any material of\nsimilar size and suitable strength.\n\nThe string of the pendulum is a thin, braided string, specifically chosen for visibility and to minimize twisting in\norder to keep the motion of the pendulum in the same plane. The string is wound around a screw at the top, with a piece\nof green reflective tape on it for tracking.\n\nThe string is attached to a bob consisting of a small, red plastic cup with coins inside for weight. The colour of the\ncup is deliberately chosen to allow for computer-vision (CV) based tracking. Coins are used for added weight because\nthey have known masses and are readily available.\n\nThe string length and bob mass are adjustable, but for this experiment, the distance from the pivot to the centre of the\nmass is fixed at \\(65\\si{cm} \\pm 1\\si{cm}\\), and the mass is fixed at 6 Canadian \\$2 coins (about \\(41.52\\si{g}\\)\nassuming cup mass is negligible).\n\n\\subsection{Data Collection}\n\\label{section:method:data_collection}\n\n\\begin{figure}[htb]\n    \\includegraphics[width=\\linewidth]{cv_track.png}\n    \\caption{CV-based tracking of the pendulum.}\n\\end{figure}\n\nVideos of the pendulum are shot on a phone camera in FHD 60fps and then passed to a program to determine the angles.\nThe pendulum is released at a fixed starting amplitude each time, always starting on the right and swinging in the plane\nof the camera.\n\nThe pendulum's angle is tracked using a Python program written with OpenCV (see Appendix \\ref{appendix:code}).\nThe locations of the bob and pivot are determined by thresholding the image and then taking the average of the pixels to\nfind the centres. After the pixel coordinates have been determined, the ratio of the difference between the \\(x\\) and\n\\(y\\) coordinates are used to compute the angle for each frame.\n\nOne data point is collected per 3 frames for 20 data points per second. Data collection starts as soon as the bob is\nreleased, which is defined to be \\(t = 0\\).\n\n\\subsection{Data Analysis}\n\nIn total, 7 trials were conducted.\nFor each trial, the \\(Q\\) factor is determined using two independent methods as outlined below:\n\n\\subsubsection{Curve Fitting}\n\nIn the first method, \\(Q\\) is computed using Equation \\ref{eqn:q} with values of \\(\\tau\\) and \\(T\\) computed by fitting\nEquation \\ref{eqn:model} to the experimental data.\n\nThe data is passed to a Python program (see Appendix \\ref{appendix:code}) that fits the model using a nonlinear\nleast-squares method, which determines the optimal values for \\(\\tau\\) and \\(T\\) among others, and the standard\ndeviations of both, which is used as the uncertainty.\n\n\\subsubsection{Oscillation Counting}\n\\label{section:method:oscillation}\n\nIn the second method, the number of oscillations until the amplitude decays to \\(e^{-\\pi/3}\\) of the original is\ncounted, which corresponds to \\(\\frac{Q}{3}\\). The counting is again done with a Python program (see Appendix\n\\ref{appendix:code}).\n\nNote that here an \"oscillation\" is defined as one complete period of the pendulum's swing. \"Half-oscillations\" are\ncounted if the amplitude first reaches the target value without completing a full period. For example, if the pendulum\nstarts at all the way to the right, and first reaches the target amplitude when it is swinging all the way to the left,\nthen a half-oscillation will be counted for the last cycle.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Observations}\n\n\\subsection{Curve Fitting}\n\n\\begin{figure*}[htb]\n    \\includegraphics[width=0.725\\linewidth]{fit1.png}\n    \\caption{Result of fitting Equation \\ref{eqn:model} to the data. For this particular fit, \\(A = 0.653\\),\n    \\(\\tau = 77.9\\), \\(T = 1.65\\), \\(\\phi = -0.439\\). Uncertainty bars are omitted to improve readability.}\n    \\label{fig:fit}\n    \\includegraphics[width=0.725\\linewidth]{fit2.png}\n    \\caption{Zoomed in view of the first 15 seconds.}\n    \\label{fig:fitzoom}\n\\end{figure*}\n\n\\(Q\\) values computed using this method are shown in Table \\ref{table:fit}:\n\\begin{table}[h]\n    \\begin{tabular}{c|c|c|c}\n        Trial & \\(Q\\) & Uncertainty & \\% Uncertainty \\\\\n        \\hline\n        1   & 153.23    & \\(\\pm 3.65\\) & 2.38 \\\\\n        2   & 147.89    & \\(\\pm 3.95\\) & 2.67 \\\\\n        3\t& 140.96\t& \\(\\pm 3.53\\) & 2.51 \\\\\n        4\t& 151.12\t& \\(\\pm 3.81\\) & 2.52 \\\\\n        5\t& 130.24\t& \\(\\pm 3.86\\) & 2.96 \\\\\n        6\t& 131.31\t& \\(\\pm 3.76\\) & 2.86 \\\\\n        7\t& 138.04\t& \\(\\pm 3.70\\) & 2.68 \\\\\n        \\hline\n        \\multicolumn{3}{l}{Mean} & 141.83 \\\\\n        \\multicolumn{3}{l}{Standard Deviation} & 9.24 \\\\\n        \\multicolumn{3}{l}{Uncertainty of the Mean} & 3.49\n    \\end{tabular}\n    \\caption{Raw data from curve fitting; values are \\textbf{unrounded}. For final uncertainties see Section\n        \\ref{section:uncertainty}.}\n    \\label{table:fit}\n\\end{table}\n\nA graph of the data and curve fit for one trial is shown in Figure \\ref{fig:fit} and Figure \\ref{fig:fitzoom}.\n\n\\subsection{Oscillation Counting}\n\n\\(Q\\) values computed using this method are shown in Table \\ref{table:oscillation}:\n\\begin{table}[h]\n    \\begin{tabular}{c|c|c|c}\n        Trial & \\(Q\\) & Uncertainty & \\% Uncertainty \\\\\n        \\hline\n        1   & 148.5 & \\(\\pm 1.5\\) & 1.01 \\\\\n        2   & 151.5 & \\(\\pm 1.5\\) & 0.99 \\\\\n        3\t& 148.5 & \\(\\pm 1.5\\) & 1.01 \\\\\n        4\t& 154.5 & \\(\\pm 1.5\\) & 0.97 \\\\\n        5\t& 139.5 & \\(\\pm 1.5\\) & 1.08 \\\\\n        6\t& 142.5 & \\(\\pm 1.5\\) & 1.05 \\\\\n        7\t& 148.5 & \\(\\pm 1.5\\) & 1.01 \\\\\n        \\hline\n        \\multicolumn{3}{l}{Mean} & 147.6 \\\\\n        \\multicolumn{3}{l}{Standard Deviation} & 5.11 \\\\\n        \\multicolumn{3}{l}{Uncertainty of the Mean} & 1.93\n    \\end{tabular}\n    \\caption{Raw data from oscillation counting; values are \\textbf{unrounded}. For final uncertainties see Section\n        \\ref{section:uncertainty}.}\n    \\label{table:oscillation}\n\\end{table}\n\nIt was chosen to measure for \\(\\frac{Q}{3} \\rightarrow e^{-\\pi/3} \\approx 0.3509\\) because of the very high \\(Q\\)\nfactor of the pendulum. The data collected only covers a time range enough for \\(\\frac{Q}{3}\\).\n\nHowever, an interesting phenomenon can be observed by varying the fraction of \\(Q\\) to measure for.\nFor example, by measuring for \\(\\frac{Q}{4}\\) instead, the data in Table \\ref{table:oscillation4} is obtained.\n\\begin{table}[h]\n    \\begin{tabular}{c|c|c|c}\n        Trial & \\(Q\\) & Uncertainty & \\% Uncertainty \\\\\n        \\hline\n        1   & 126.0 & \\(\\pm 2\\) & 1.59 \\\\\n        2   & 138.0 & \\(\\pm 2\\) & 1.45 \\\\\n        3\t& 134.0 & \\(\\pm 2\\) & 1.49 \\\\\n        4\t& 144.0 & \\(\\pm 2\\) & 1.39 \\\\\n        5\t& 128.0 & \\(\\pm 2\\) & 1.56 \\\\\n        6\t& 126.0 & \\(\\pm 2\\) & 1.59 \\\\\n        7\t& 134.0 & \\(\\pm 2\\) & 1.49 \\\\\n        \\hline\n        \\multicolumn{3}{l}{Mean} & 132.9 \\\\\n        \\multicolumn{3}{l}{Standard Deviation} & 6.72 \\\\\n        \\multicolumn{3}{l}{Uncertainty of the Mean} & 2.54\n    \\end{tabular}\n    \\caption{Data obtained from measuring \\(\\frac{Q}{4}\\)} instead.\n    \\label{table:oscillation4}\n\\end{table}\n\nAfter more trials, it can be observed that the value of \\(Q\\) observed through counting oscillations is dependent on the\nfraction of \\(Q\\) that was measured for. Moreover, as the denominator increases, the observed \\(Q\\) value seems to\ndecrease, while according to the mathematical model the value of \\(Q\\) should be independent of the fraction measured.\nThis is likely because the model is not an accurate approximation of the actual system. (More details in Section\n\\ref{section:analysis}.)\n\n\\subsection{Uncertainty Analysis}\n\\label{section:uncertainty}\n\n\\subsubsection{Measurement Uncertainty}\n\nThere are two sources of measurement uncertainty during the data collection process that can be easily quantified:\n\\begin{enumerate}\n    \\item \\textbf{Time measurement uncertainty from the camera's frame rate and shutter speed.} Because the camera only\n          captures a set number of frames per second, this creates a small uncertainty about the exact time that data\n          points occurred. An upper bound for this uncertainty can be obtained by taking the time between two frames and\n          dividing by 2. For a 60fps camera, this results in an uncertainty of \\(\\pm 0.008\\si{s}\\).\n    \\item \\textbf{Angle measurement uncertainty from motion blur and imperfect tracking.} Motion blur caused by a\n          fast-moving bob can make the angle hard to measure, and imperfect computer vision tracking of the bob and\n          pivot may also result in an incorrect angle. To estimate an upper bound of this uncertainty, a frame is taken\n          from when the pendulum has its maximum velocity to maximize motion blur. Two lines are drawn representing the\n          worst possible cases for tracking, and the angle between them is taken. The result is a range of about\n          \\(5\\degree\\), or an uncertainty of \\(\\pm 3\\degree\\)/\\(\\pm 0.05\\si{rad}\\).\n\\end{enumerate}\n\\begin{figure}[h]\n    \\includegraphics[width=0.3\\linewidth]{uncert1.png}\n    \\caption{Worst-case scenarios for angle uncertainty. Blue lines are drawn to indicate the greatest and least\n        possible angle.}\n\\end{figure}\n\nThese uncertainties are shown in the graphs in Figures \\ref{fig:fit} and \\ref{fig:fitzoom}. They are very small when\ncompared to the uncertainties later in the experiment, and so they will be ignored as only the largest uncertainty is\nconsidered for this lab. Furthermore, their random nature means that these uncertainties would already be included in\nthe uncertainty of the mean.\n\nThere are also other sources of measurement uncertainty that are much harder to quantify:\n\\begin{enumerate}\n    \\item Perspective distortion\n    \\item Tilted camera\n    \\item Pendulum not swinging perfectly in the plane of the camera\n\\end{enumerate}\nThese uncertainties are assumed to be smaller and random, and thus incorporated in the uncertainty of the mean and other\nsources described below.\n\n\\subsubsection{Uncertainties From Curve Fitting}\n\nFor each trial, the standard deviation obtained from the least squares fit is used as uncertainty values for \\(\\tau\\)\nand \\(T\\) and used to calculate uncertainty for \\(Q\\). From Table \\ref{table:fit}, the greatest percentage uncertainty\nis trial 5 with an uncertainty of 2.96\\%. When multiplied by the mean, this corresponds to an uncertainty of\n\\(\\pm 4.20\\), which is greater than the uncertainty of the mean.\n\n\\textbf{The final value as determined by this method is \\(Q = 142 \\pm 4\\).}\n\n\\subsubsection{Uncertainties From Oscillation Counting}\n\nSince the amplitude can only be determined at the top of a peak or bottom of a trough, this method yields a maximum\nresolution of 0.5 oscillations (half oscillations are allowed as described in Section \\ref{section:method:oscillation}).\n\nBecause oscillations are counted until the amplitude first decays to less than the target instead of finding the cycle\nwith amplitude closest to the target, this yields an uncertainty of \\(\\pm 0.5\\) oscillations, which corresponds to\n\\(\\pm 1.5\\) for the final \\(Q\\) value.\n\nFrom Table \\ref{table:oscillation}, the greatest percentage uncertainty is trial 5 with an uncertainty of 1.08\\%, which\ncorresponds to an uncertainty of \\(\\pm 1.59\\) in \\(Q\\), less than the uncertainty of the mean.\n\n\\textbf{The final value as determined by this method is \\(Q = 148 \\pm 2\\).}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Analysis and Conclusion}\n\\label{section:analysis}\n\n\\subsection{\\texorpdfstring{\\(Q\\)}{Q} Factor}\n\nThe \\(Q\\) value obtained by oscillation counting is within 1.5 times the uncertainty of the \\(Q\\) value obtained by\ncurve fitting. If values follow a normal distribution, there is a 13.4\\% chance for values to be more than 1.5 times the\nuncertainty away. From this we conclude that \\textbf{while there is a discrepancy between the two \\(Q\\) values, there is\na chance that they are in agreement.} From the \\(Q\\) values and uncertainties alone, it can be concluded that the actual\n\\(Q\\) value is between 142 and 148 and closer to the latter (since it has a lower uncertainty).\n\nHowever, as shown in Table \\ref{table:oscillation4}, by measuring for \\(\\frac{Q}{4}\\) a \\(Q\\) value of \\(133 \\pm 3\\) is\nobtained instead. This value is 2.25 times the uncertainty away from the \\(Q\\) value obtained by curve fitting, and 5\ntimes the uncertainty away from the \\(Q\\) value obtained by counting for \\(\\frac{Q}{3}\\). The probability for a value to\nlie outside 2.25 times the uncertainty is about 2.44\\%, so this value is not in agreement with either \\(Q\\) value found\nabove.\n\nFurthermore, as the fraction of \\(Q\\) measured for gets smaller, the measured \\(Q\\) value gets even further from the\nvalues obtained previously. It can be concluded that, at least for this particular pendulum, \\textbf{oscillation\ncounting is not a reliable way for obtaining \\(Q\\)}.\n\n\\subsection{Model Accuracy}\n\nAn inspection of the residuals in Figure \\ref{fig:fit} shows a clear pattern, which would not be present if the fit\nrepresented the data well. At many points, the residuals reach a value of 0.2, which is over 25\\% of the actual\namplitude of the data, 0.8. The amplitude of the fit also deviates significantly from the actual amplitude of the data\n(0.6 versus 0.8), but adjusting the conditions of the fit does not improve it.\n\nThe two possible reasons for this happening are either that the fit was not done well, or the model does not reflect the\nreal data well. The data is inconclusive for determining which is the dominant effect, but there is likely \\textbf{a mix\nof both}.\n\nThe amplitudes obtained from fit seems to be systematically smaller than the actual peak amplitudes in the\ndata, which suggests an incorrect fit. However, it is also likely that the model itself is inaccurate: Due to the\nexperimental setup (see Section \\ref{section:method:data_collection}), the theoretical value of \\(\\phi_0\\) should\nalways be 0. However, all the trials have produced a nonzero value for \\(\\phi_0\\).\n\nFigure \\ref{fig:fit_nophi} is the result of modifying the code to fix \\(\\phi\\) at 0 (see Appendix \\ref{appendix:code}).\n\\begin{figure}[htb]\n    \\includegraphics[width=0.9\\linewidth]{fit3.png}\n    \\caption{Result of fitting Equation \\ref{eqn:model} with \\(\\phi = 0\\). For this particular fit, \\(A = 0.686\\),\n    \\(\\tau = 63.16\\), \\(T = 1.66\\). Uncertainty bars are omitted to improve readability.}\n    \\label{fig:fit_nophi}\n\\end{figure}\n\nCompared to Figure \\ref{fig:fit}, this time the fit is much worse, with the fit curve visibly deviating from the data in\nboth magnitude and phase near the end. The residuals seem to keep on increasing at the end, which allows us to conclude\nthat \\textbf{Equation \\ref{eqn:model} is likely not a very accurate model of this pendulum for large values of \\(t\\)}.\n\nThis might be because Equation \\ref{eqn:model} is derived with the simplifying assumption of \\(\\sin x \\approx x\\) for\nsmall angles and a damping force proportional to the velocity, while in reality drag is closer to quadratic.\nThis would cause the damping force to be stronger for smaller velocities, resulting in a rate of decay that is too fast\nas shown in Figure \\ref{fig:fit_nophi}.\n\nFor the fit in Figure \\ref{fig:fit_nophi}, the largest percentage uncertainty was for the value of \\(\\tau\\), which is\n3.00\\%. Assuming the 3.00\\% carries over to the final value of \\(\\theta(t)\\), this represents an uncertainty in the\nworst case of \\(\\pm 0.0240\\si{rad}\\) (for a \\(\\theta\\) value of 0.8). Comparing this to the residual graphs in Figures\n\\ref{fig:fit} and \\ref{fig:fit_nophi}, the residuals easily exceed it by many times, even in regions where the\nresiduals are small.\n\nAnother reason for the large residuals could be that \\textbf{the period of this pendulum appears to be non-constant}.\nObserving the data more closely shows that the period of the pendulum appears to decrease slightly as time progresses.\nIn particular, for the trial in Figure \\ref{fig:fit}, the initial period shortly after release is about\n\\(1.67\\si{s} \\pm 0.01\\si{s}\\), while the final period near the end of the video is about \\(1.64\\si{s} \\pm 0.01\\si{s}\\).\nAlthough the difference is small, it is consistently present throughout multiple trials and is too large to be explained\nby uncertainties. This represents a slight deviation from the model, since Equation \\ref{eqn:model} has a constant\nperiod.\n\n\\subsection{Implications for Future Data Collection}\n\nThe findings have the following implications for data collection in future labs:\n\\begin{enumerate}\n    \\item The \\(Q\\) value was measured to be greater than 140, which means for every oscillation the amplitude decays to\n          greater than \\(e^{-\\frac{\\pi}{Q}} \\approx 0.978 = 97.8\\%\\) of the previous oscillation. The high \\(Q\\) factor\n          combined with a reasonably high period of about \\(1.6\\si{s}\\) makes it very easy to measure multiple periods\n          to get more accurate data, so in subsequent experiments more periods should be measured to improve accuracy.\n    \\item The slight change in period, although small (less than 2\\%), means that results may differ depending on the\n          when measurements are taken (specifically for measuring the period later in Lab 2). Therefore, special care\n          should be taken to ensure that all period measurements are taken right at the beginning of the experiment so\n          they could be compared.\n\\end{enumerate}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\appendix\n\\section{Source Code}\n\nA comprehensive list of all source code, as well as the \\LaTeX{} source for this report, can be found on GitHub at\n\\url{https://github.com/tylertian123/phy180_lab}, in particular:\n\\label{appendix:code}\n\\begin{enumerate}\n    \\item For tracking the pendulum and generating time-angle data: \\url{https://github.com/tylertian123/phy180_lab/tree/lab1/cvtrack.py}\n    \\item For fitting the model to experimental data: \\url{https://github.com/tylertian123/phy180_lab/tree/lab1/fit.py}\n    \\item For measuring \\(Q\\) by counting oscillations: \\url{https://github.com/tylertian123/phy180_lab/tree/lab1/find_q.py}\n    \\item For fitting the model with \\(\\phi\\) fixed at 0: \\url{https://github.com/tylertian123/phy180_lab/tree/lab1/fit_nophi.py}\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "f82cdb2f1d2ec87df44d668eea120e4429b7910e", "size": 23140, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lab1/report/report.tex", "max_stars_repo_name": "tylertian123/phys180_lab", "max_stars_repo_head_hexsha": "8dca975a27db1c488d3e34f7a921b2b7f967a957", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-23T02:03:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-23T02:03:55.000Z", "max_issues_repo_path": "lab1/report/report.tex", "max_issues_repo_name": "tylertian123/phys180_lab", "max_issues_repo_head_hexsha": "8dca975a27db1c488d3e34f7a921b2b7f967a957", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab1/report/report.tex", "max_forks_repo_name": "tylertian123/phys180_lab", "max_forks_repo_head_hexsha": "8dca975a27db1c488d3e34f7a921b2b7f967a957", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.0952380952, "max_line_length": 308, "alphanum_fraction": 0.7168539326, "num_tokens": 6200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.42317242366673696}}
{"text": "\n\\section{Program Logic}\n\\label{sec:program-logic}\n\nThis section describes how to build a program logic for an arbitrary language (\\cf \\Sref{sec:language}) on top of the base logic.\nSo in the following, we assume that some language $\\Lang$ was fixed.\nFurthermore, we work in the logic with higher-order ghost state as described in \\Sref{sec:composeable-resources}.\n\n\n\\subsection{World Satisfaction, Invariants, Fancy Updates}\n\\label{sec:invariants}\n\nTo introduce invariants into our logic, we will define weakest precondition to explicitly thread through the proof that all the invariants are maintained throughout program execution.\nHowever, in order to be able to access invariants, we will also have to provide a way to \\emph{temporarily disable} (or ``open'') them.\nTo this end, we use tokens that manage which invariants are currently enabled.\n\nWe assume to have the following four cameras available:\n\\begin{align*}\n  \\InvName \\eqdef{}& \\nat \\\\\n  \\textmon{Inv} \\eqdef{}& \\authm(\\InvName \\fpfn \\agm(\\latert \\iPreProp)) \\\\\n  \\textmon{En} \\eqdef{}& \\pset{\\InvName} \\\\\n  \\textmon{Dis} \\eqdef{}& \\finpset{\\InvName}\n\\end{align*}\nThe last two are the tokens used for managing invariants, $\\textmon{Inv}$ is the monoid used to manage the invariants themselves.\n\nWe assume that at the beginning of the verification, instances named $\\gname_{\\textmon{State}}$, $\\gname_{\\textmon{Inv}}$, $\\gname_{\\textmon{En}}$ and $\\gname_{\\textmon{Dis}}$ of these cameras have been created, such that these names are globally known.\n\n\\paragraph{World Satisfaction.}\nWe can now define the proposition $W$ (\\emph{world satisfaction}) which ensures that the enabled invariants are actually maintained:\n\\begin{align*}\n  W \\eqdef{}& \\Exists I : \\InvName \\fpfn \\Prop.\n  \\begin{array}[t]{@{} l}\n    \\ownGhost{\\gname_{\\textmon{Inv}}}{\\authfull\n      \\mapComp {\\iname}\n        {\\aginj(\\latertinj(\\wIso(I(\\iname))))}\n        {\\iname \\in \\dom(I)}} * \\\\\n    \\Sep_{\\iname \\in \\dom(I)} \\left( \\later I(\\iname) * \\ownGhost{\\gname_{\\textmon{Dis}}}{\\set{\\iname}} \\lor \\ownGhost{\\gname_{\\textmon{En}}}{\\set{\\iname}} \\right)\n  \\end{array}\n\\end{align*}\n\n\\paragraph{Invariants.}\nThe following proposition states that an invariant with name $\\iname$ exists and maintains proposition $\\prop$:\n\\[ \\knowInv\\iname\\prop \\eqdef \\ownGhost{\\gname_{\\textmon{Inv}}}\n  {\\authfrag \\mapsingleton \\iname {\\aginj(\\latertinj(\\wIso(\\prop)))}} \\]\n\n\\paragraph{Fancy Updates and View Shifts.}\nNext, we define \\emph{fancy updates}, which are essentially the same as the basic updates of the base logic ($\\Sref{sec:base-logic}$), except that they also have access to world satisfaction and can enable and disable invariants:\n\\[ \\pvs[\\mask_1][\\mask_2] \\prop \\eqdef W * \\ownGhost{\\gname_{\\textmon{En}}}{\\mask_1} \\wand \\upd\\diamond (W * \\ownGhost{\\gname_{\\textmon{En}}}{\\mask_2} * \\prop) \\]\nHere, $\\mask_1$ and $\\mask_2$ are the \\emph{masks} of the view update, defining which invariants have to be (at least!) available before and after the update.\nWe use $\\top$ as symbol for the largest possible mask, $\\nat$, and $\\bot$ for the smallest possible mask $\\emptyset$.\nWe will write $\\pvs[\\mask] \\prop$ for $\\pvs[\\mask][\\mask]\\prop$.\n%\nFancy updates satisfy the following basic proof rules:\n\\begin{mathparpagebreakable}\n\\infer[fup-mono]\n{\\prop \\proves \\propB}\n{\\pvs[\\mask_1][\\mask_2] \\prop \\proves \\pvs[\\mask_1][\\mask_2] \\propB}\n\n\\infer[fup-intro-mask]\n{\\mask_2 \\subseteq \\mask_1}\n{\\prop \\proves \\pvs[\\mask_1][\\mask_2]\\pvs[\\mask_2][\\mask_1] \\prop}\n\n\\infer[fup-trans]\n{}\n{\\pvs[\\mask_1][\\mask_2] \\pvs[\\mask_2][\\mask_3] \\prop \\proves \\pvs[\\mask_1][\\mask_3] \\prop}\n\n\\infer[fup-upd]\n{}{\\upd\\prop \\proves \\pvs[\\mask] \\prop}\n\n\\infer[fup-frame]\n{}{\\propB * \\pvs[\\mask_1][\\mask_2]\\prop \\proves \\pvs[\\mask_1 \\uplus \\mask_\\f][\\mask_2 \\uplus \\mask_\\f] \\propB * \\prop}\n\n\\inferH{fup-update}\n{\\melt \\mupd \\meltsB}\n{\\ownM\\melt \\proves \\pvs[\\mask] \\Exists\\meltB\\in\\meltsB. \\ownM\\meltB}\n\n\\infer[fup-timeless]\n{\\timeless\\prop}\n{\\later\\prop \\proves \\pvs[\\mask] \\prop}\n%\n% \\inferH{fup-allocI}\n% {\\text{$\\mask$ is infinite}}\n% {\\later\\prop \\proves \\pvs[\\mask] \\Exists \\iname \\in \\mask. \\knowInv\\iname\\prop}\n%gov\n% \\inferH{fup-openI}\n% {}{\\knowInv\\iname\\prop \\proves \\pvs[\\set\\iname][\\emptyset] \\later\\prop}\n%\n% \\inferH{fup-closeI}\n% {}{\\knowInv\\iname\\prop \\land \\later\\prop \\proves \\pvs[\\emptyset][\\set\\iname] \\TRUE}\n\\end{mathparpagebreakable}\n(There are no rules related to invariants here. Those rules will be discussed later, in \\Sref{sec:namespaces}.)\n\nWe can further define the notions of \\emph{view shifts} and \\emph{linear view shifts}:\n\\begin{align*}\n  \\prop \\vsW[\\mask_1][\\mask_2] \\propB \\eqdef{}& \\prop \\wand \\pvs[\\mask_1][\\mask_2] \\propB \\\\\n  \\prop \\vs[\\mask_1][\\mask_2] \\propB \\eqdef{}& \\always(\\prop \\wand \\pvs[\\mask_1][\\mask_2] \\propB) \\\\\n  \\prop \\vs[\\mask] \\propB \\eqdef{}& \\prop \\vs[\\mask][\\mask] \\propB\n\\end{align*}\nThese two are useful when writing down specifications and for comparing with previous versions of Iris, but for reasoning, it is typically easier to just work directly with fancy updates.\nStill, just to give an idea of what view shifts ``are'', here are some proof rules for them:\n\\begin{mathparpagebreakable}\n\\inferH{vs-update}\n  {\\melt \\mupd \\meltsB}\n  {\\ownGhost\\gname{\\melt} \\vs[\\emptyset] \\exists \\meltB \\in \\meltsB.\\; \\ownGhost\\gname{\\meltB}}\n\\and\n\\inferH{vs-trans}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB \\and \\propB \\vs[\\mask_2][\\mask_3] \\propC}\n  {\\prop \\vs[\\mask_1][\\mask_3] \\propC}\n\\and\n\\inferH{vs-imp}\n  {\\always{(\\prop \\Ra \\propB)}}\n  {\\prop \\vs[\\emptyset] \\propB}\n\\and\n\\inferH{vs-mask-frame}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB}\n  {\\prop \\vs[\\mask_1 \\uplus \\mask'][\\mask_2 \\uplus \\mask'] \\propB}\n\\and\n\\inferH{vs-frame}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB}\n  {\\prop * \\propC \\vs[\\mask_1][\\mask_2] \\propB * \\propC}\n\\and\n\\inferH{vs-timeless}\n  {\\timeless{\\prop}}\n  {\\later \\prop \\vs[\\emptyset] \\prop}\n\n% \\inferH{vs-allocI}\n%   {\\infinite(\\mask)}\n%   {\\later{\\prop} \\vs[\\mask] \\exists \\iname\\in\\mask.\\; \\knowInv{\\iname}{\\prop}}\n% \\and\n% \\axiomH{vs-openI}\n%   {\\knowInv{\\iname}{\\prop} \\proves \\TRUE \\vs[\\{ \\iname \\} ][\\emptyset] \\later \\prop}\n% \\and\n% \\axiomH{vs-closeI}\n%   {\\knowInv{\\iname}{\\prop} \\proves \\later \\prop \\vs[\\emptyset][\\{ \\iname \\} ] \\TRUE }\n%\n\\inferHB{vs-disj}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propC \\and \\propB \\vs[\\mask_1][\\mask_2] \\propC}\n  {\\prop \\lor \\propB \\vs[\\mask_1][\\mask_2] \\propC}\n\\and\n\\inferHB{vs-exist}\n  {\\All \\var. (\\prop \\vs[\\mask_1][\\mask_2] \\propB)}\n  {(\\Exists \\var. \\prop) \\vs[\\mask_1][\\mask_2] \\propB}\n\\and\n\\inferHB{vs-always}\n  {\\always\\propB \\proves \\prop \\vs[\\mask_1][\\mask_2] \\propC}\n  {\\prop \\land \\always{\\propB} \\vs[\\mask_1][\\mask_2] \\propC}\n \\and\n\\inferH{vs-false}\n  {}\n  {\\FALSE \\vs[\\mask_1][\\mask_2] \\prop }\n\\end{mathparpagebreakable}\n\n\\subsection{Weakest Precondition}\n\nFinally, we can define the core piece of the program logic, the proposition that reasons about program behavior: Weakest precondition, from which Hoare triples will be derived.\n\n\\paragraph{Defining weakest precondition.}\nWe assume that everything making up the definition of the language, \\ie values, expressions, states, the conversion functions, reduction relation and all their properties, are suitably reflected into the logic (\\ie they are part of the signature $\\Sig$).\nWe further assume (as a parameter) a predicate $\\stateinterp : \\State \\to \\iProp$ that interprets the physical state as an Iris proposition.\nThis can be instantiated, for example, with ownership of an authoritative RA to tie the physical state to fragments that are used for user-level proofs.\nFinally, weakest precondition takes a parameter $\\stuckness \\in \\set{\\NotStuck, \\MaybeStuck}$ indicating whether program execution is allowed to get stuck.\n\n\\begin{align*}\n  \\textdom{wp}(\\stateinterp, \\stuckness) \\eqdef{}& \\MU \\textdom{wp\\any rec}. \\Lam \\mask, \\expr, \\pred. \\\\\n        & (\\Exists\\val. \\toval(\\expr) = \\val \\land \\pvs[\\mask] \\pred(\\val)) \\lor {}\\\\\n        & \\Bigl(\\toval(\\expr) = \\bot \\land \\All \\state. \\stateinterp(\\state) \\vsW[\\mask][\\emptyset] {}\\\\\n        &\\qquad (s = \\NotStuck \\Ra \\red(\\expr, \\state)) * \\later\\All \\expr', \\state', \\vec\\expr. (\\expr, \\state \\step \\expr', \\state', \\vec\\expr) \\vsW[\\emptyset][\\mask] {}\\\\\n        &\\qquad\\qquad \\stateinterp(\\state') * \\textdom{wp\\any rec}(\\mask, \\expr', \\pred) * \\Sep_{\\expr'' \\in \\vec\\expr} \\textdom{wp\\any rec}(\\top, \\expr'', \\Lam \\any. \\TRUE)\\Bigr) \\\\\n%  (* value case *)\n  \\wpre[\\stateinterp]\\expr[\\stuckness;\\mask]{\\Ret\\val. \\prop} \\eqdef{}& \\textdom{wp}(\\stateinterp,\\stuckness)(\\mask, \\expr, \\Lam\\val.\\prop)\n\\end{align*}\nThe $\\stateinterp$ will always be set by the context; typically, when instantiating Iris with a language, we also pick the corresponding state interpretation $\\stateinterp$.\nAll proof rules leave $\\stateinterp$ unchanged.\nIf we leave away the mask $\\mask$, we assume it to default to $\\top$.\nIf we leave away the stuckness $\\stuckness$, it defaults to $\\NotStuck$.\n\n\\paragraph{Laws of weakest precondition.}\nThe following rules can all be derived:\n\\begin{mathpar}\n\\infer[wp-value]\n{}{\\prop[\\val/\\var] \\proves \\wpre{\\val}[\\stuckness;\\mask]{\\Ret\\var.\\prop}}\n\n\\infer[wp-mono]\n{\\mask_1 \\subseteq \\mask_2 \\and \\vctx,\\var:\\textlog{val}\\mid\\prop \\proves \\propB \\and (\\stuckness_2 = \\MaybeStuck \\lor \\stuckness_1 = \\stuckness_2)}\n{\\vctx\\mid\\wpre\\expr[\\stuckness_1;\\mask_1]{\\Ret\\var.\\prop} \\proves \\wpre\\expr[\\stuckness_2;\\mask_2]{\\Ret\\var.\\propB}}\n\n\\infer[fup-wp]\n{}{\\pvs[\\mask] \\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\prop} \\proves \\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\prop}}\n\n\\infer[wp-fup]\n{}{\\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\pvs[\\stuckness;\\mask] \\prop} \\proves \\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\prop}}\n\n\\infer[wp-atomic]\n{\\stuckness = \\NotStuck \\Ra \\atomic(\\expr) \\and\n \\stuckness = \\MaybeStuck \\Ra \\stronglyAtomic(\\expr)}\n{\\pvs[\\mask_1][\\mask_2] \\wpre\\expr[\\stuckness;\\mask_2]{\\Ret\\var. \\pvs[\\mask_2][\\mask_1]\\prop}\n \\proves \\wpre\\expr[\\stuckness;\\mask_1]{\\Ret\\var.\\prop}}\n\n\\infer[wp-frame]\n{}{\\propB * \\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\prop} \\proves \\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var.\\propB*\\prop}}\n\n\\infer[wp-frame-step]\n{\\toval(\\expr) = \\bot \\and \\mask_2 \\subseteq \\mask_1}\n{\\wpre\\expr[\\stuckness;\\mask_2]{\\Ret\\var.\\prop} * \\pvs[\\mask_1][\\mask_2]\\later\\pvs[\\mask_2][\\mask_1]\\propB \\proves \\wpre\\expr[\\stuckness;\\mask_1]{\\Ret\\var.\\propB*\\prop}}\n\n\\infer[wp-bind]\n{\\text{$\\lctx$ is a context}}\n{\\wpre\\expr[\\stuckness;\\mask]{\\Ret\\var. \\wpre{\\lctx(\\ofval(\\var))}[\\stuckness;\\mask]{\\Ret\\varB.\\prop}} \\proves \\wpre{\\lctx(\\expr)}[\\stuckness;\\mask]{\\Ret\\varB.\\prop}}\n\\end{mathpar}\n\nWe will also want a rule that connect weakest preconditions to the operational semantics of the language.\n\\begin{mathpar}\n  \\infer[wp-lift-step]\n  {\\toval(\\expr_1) = \\bot}\n  { {\\begin{inbox} % for some crazy reason, LaTeX is actually sensitive to the space between the \"{ {\" here and the \"} }\" below...\n        ~~\\All \\state_1. \\stateinterp(\\state_1) \\vsW[\\mask][\\emptyset] (\\stuckness = \\NotStuck \\Ra \\red(\\expr_1,\\state_1)) * {}\\\\\\qquad~~ \\later\\All \\expr_2, \\state_2, \\vec\\expr.  (\\expr_1, \\state_1 \\step \\expr_2, \\state_2, \\vec\\expr)  \\vsW[\\emptyset][\\mask] \\Bigl(\\stateinterp(\\state_2) * \\wpre[\\stateinterp]{\\expr_2}[\\stuckness;\\mask]{\\Ret\\var.\\prop} * \\Sep_{\\expr_\\f \\in \\vec\\expr} \\wpre[\\stateinterp]{\\expr_\\f}[\\stuckness;\\top]{\\Ret\\any.\\TRUE}\\Bigr)  {}\\\\\\proves \\wpre[\\stateinterp]{\\expr_1}[\\stuckness;\\mask]{\\Ret\\var.\\prop}\n      \\end{inbox}} }\n\\end{mathpar}\n\n% We can further derive some slightly simpler rules for special cases.\n% \\begin{mathparpagebreakable}\n%   \\infer[wp-lift-pure-step]\n%   {\\All \\state_1. \\red(\\expr_1, \\state_1) \\and\n%    \\All \\state_1, \\expr_2, \\state_2, \\vec\\expr. \\expr_1,\\state_1 \\step \\expr_2,\\state_2,\\vec\\expr \\Ra \\state_1 = \\state_2 }\n%   {\\later\\All \\state, \\expr_2, \\vec\\expr. (\\expr_1,\\state \\step \\expr_2, \\state,\\vec\\expr)  \\Ra \\wpre{\\expr_2}[\\mask]{\\Ret\\var.\\prop} * \\Sep_{\\expr_\\f \\in \\vec\\expr} \\wpre{\\expr_\\f}[\\top]{\\Ret\\any.\\TRUE} \\proves \\wpre{\\expr_1}[\\mask]{\\Ret\\var.\\prop}}\n\n%   \\infer[wp-lift-atomic-step]\n%   {\\atomic(\\expr_1) \\and\n%    \\red(\\expr_1, \\state_1)}\n%   { {\\begin{inbox}~~\\later\\ownPhys{\\state_1} * \\later\\All \\val_2, \\state_2, \\vec\\expr. (\\expr_1,\\state_1 \\step \\ofval(\\val),\\state_2,\\vec\\expr)  * \\ownPhys{\\state_2} \\wand \\prop[\\val_2/\\var] * \\Sep_{\\expr_\\f \\in \\vec\\expr} \\wpre{\\expr_\\f}[\\top]{\\Ret\\any.\\TRUE} {}\\\\ \\proves  \\wpre{\\expr_1}[\\mask_1]{\\Ret\\var.\\prop}\n%   \\end{inbox}} }\n\n%   \\infer[wp-lift-atomic-det-step]\n%   {\\atomic(\\expr_1) \\and\n%    \\red(\\expr_1, \\state_1) \\and\n%    \\All \\expr'_2, \\state'_2, \\vec\\expr'. \\expr_1,\\state_1 \\step \\expr'_2,\\state'_2,\\vec\\expr' \\Ra \\state_2 = \\state_2' \\land \\toval(\\expr_2') = \\val_2 \\land \\vec\\expr = \\vec\\expr'}\n%   {\\later\\ownPhys{\\state_1} * \\later \\Bigl(\\ownPhys{\\state_2} \\wand \\prop[\\val_2/\\var] * \\Sep_{\\expr_\\f \\in \\vec\\expr} \\wpre{\\expr_\\f}[\\top]{\\Ret\\any.\\TRUE} \\Bigr) \\proves \\wpre{\\expr_1}[\\mask_1]{\\Ret\\var.\\prop}}\n\n%   \\infer[wp-lift-pure-det-step]\n%   {\\All \\state_1. \\red(\\expr_1, \\state_1) \\\\\n%    \\All \\state_1, \\expr_2', \\state'_2, \\vec\\expr'. \\expr_1,\\state_1 \\step \\expr'_2,\\state'_2,\\vec\\expr' \\Ra \\state_1 = \\state'_2 \\land \\expr_2 = \\expr_2' \\land \\vec\\expr = \\vec\\expr'}\n%   {\\later \\Bigl( \\wpre{\\expr_2}[\\mask_1]{\\Ret\\var.\\prop} * \\Sep_{\\expr_\\f \\in \\vec\\expr} \\wpre{\\expr_\\f}[\\top]{\\Ret\\any.\\TRUE} \\Bigr) \\proves \\wpre{\\expr_1}[\\mask_1]{\\Ret\\var.\\prop}}\n% \\end{mathparpagebreakable}\n\n\n\\paragraph{Adequacy of weakest precondition.}\n\nThe purpose of the adequacy statement is to show that our notion of weakest preconditions is \\emph{realistic} in the sense that it actually has anything to do with the actual behavior of the program.\nThere are two properties we are looking for: First of all, the postcondition should reflect actual properties of the values the program can terminate with.\nSecond, a proof of a weakest precondition with any postcondition should imply that the program is \\emph{safe}, \\ie that it does not get stuck.\n\n\\begin{defn}[Adequacy]\n  A program $\\expr$ in some initial state $\\state$ is \\emph{adequate} for stuckness  $\\stuckness$ and a set $V \\subseteq \\Val$ of legal return values ($\\expr, \\state \\vDash_\\stuckness V$) if for all $\\tpool', \\state'$ such that $([\\expr], \\state) \\tpstep^\\ast (\\tpool', \\state')$ we have\n\\begin{enumerate}\n\\item Safety: If $\\stuckness = \\NotStuck$, then for any $\\expr' \\in \\tpool'$ we have that either $\\expr'$ is a\n  value, or \\(\\red(\\expr'_i,\\state')\\):\n  \\[ \\stuckness = \\NotStuck \\Ra \\All\\expr'\\in\\tpool'. \\toval(\\expr') \\neq \\bot \\lor \\red(\\expr', \\state') \\]\n  Notice that this is stronger than saying that the thread pool can reduce; we actually assert that \\emph{every} non-finished thread can take a step.\n\\item Legal return value: If $\\tpool'_1$ (the main thread) is a value $\\val'$, then $\\val' \\in V$:\n  \\[ \\All \\val',\\tpool''. \\tpool' = [\\val'] \\dplus \\tpool'' \\Ra \\val' \\in V \\]\n\\end{enumerate}\n\\end{defn}\n\nTo express the adequacy statement for functional correctness, we assume that the signature $\\Sig$ adds a predicate $\\pred$ to the logic:\n\\[ \\pred : \\Val \\to \\Prop \\in \\SigFn \\]\nFurthermore, we assume that the \\emph{interpretation} $\\Sem\\pred$ of $\\pred$ reflects some set $V$ of legal return values into the logic (also see \\Sref{sec:model}):\n\\[\\begin{array}{rMcMl}\n  \\Sem\\pred &:& \\Sem{\\Val\\,} \\nfn \\Sem\\Prop \\\\\n  \\Sem\\pred &\\eqdef& \\Lam \\val. \\Lam \\any. \\setComp{n}{v \\in V}\n\\end{array}\\]\nThe signature can of course state arbitrary additional properties of $\\pred$, as long as they are proven sound.\nThe adequacy statement now reads as follows:\n\\begin{align*}\n &\\All \\mask, \\expr, \\val, \\state.\n \\\\&( \\TRUE \\proves \\pvs[\\mask] \\Exists \\stateinterp. \\stateinterp(\\state) * \\wpre[\\stateinterp]{\\expr}[\\stuckness;\\mask]{x.\\; \\pred(x)}) \\Ra\n \\\\&\\expr, \\state \\vDash_\\stuckness V\n\\end{align*}\nNotice that the state invariant $S$ used by the weakest precondition is chosen \\emph{after} doing a fancy update, which allows it to depend on the names of ghost variables that are picked in that initial fancy update.\n\n\\paragraph{Hoare triples.}\nIt turns out that weakest precondition is actually quite convenient to work with, in particular when performing these proofs in Coq.\nStill, for a more traditional presentation, we can easily derive the notion of a Hoare triple:\n\\[\n\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask] \\eqdef \\always{(\\prop \\wand \\wpre{\\expr}[\\mask]{\\Ret\\val.\\propB})}\n\\]\nWe assume the state interpretation $\\stateinterp$ to be fixed by the context.\n\nWe only give some of the proof rules for Hoare triples here, since we usually do all our reasoning directly with weakest preconditions and use Hoare triples only to write specifications.\n\\begin{mathparpagebreakable}\n\\inferH{Ht-ret}\n  {}\n  {\\hoare{\\TRUE}{\\valB}{\\Ret\\val. \\val = \\valB}[\\mask]}\n\\and\n\\inferH{Ht-bind}\n  {\\text{$\\lctx$ is a context} \\and \\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask] \\\\\n   \\All \\val. \\hoare{\\propB}{\\lctx(\\val)}{\\Ret\\valB.\\propC}[\\mask]}\n  {\\hoare{\\prop}{\\lctx(\\expr)}{\\Ret\\valB.\\propC}[\\mask]}\n\\and\n\\inferH{Ht-csq}\n  {\\prop \\vs \\prop' \\\\\n    \\hoare{\\prop'}{\\expr}{\\Ret\\val.\\propB'}[\\mask] \\\\   \n   \\All \\val. \\propB' \\vs \\propB}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n\\and\n% \\inferH{Ht-mask-weaken}\n%   {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask]}\n%   {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask \\uplus \\mask']}\n% \\\\\\\\\n\\inferH{Ht-frame}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask]}\n  {\\hoare{\\prop * \\propC}{\\expr}{\\Ret\\val. \\propB * \\propC}[\\mask]}\n\\and\n% \\inferH{Ht-frame-step}\n%   {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask] \\and \\toval(\\expr) = \\bot \\and \\mask_2 \\subseteq \\mask_2 \\\\\\\\ \\propC_1 \\vs[\\mask_1][\\mask_2] \\later\\propC_2 \\and \\propC_2 \\vs[\\mask_2][\\mask_1] \\propC_3}\n%   {\\hoare{\\prop * \\propC_1}{\\expr}{\\Ret\\val. \\propB * \\propC_3}[\\mask \\uplus \\mask_1]}\n% \\and\n\\inferH{Ht-atomic}\n  {\\prop \\vs[\\mask \\uplus \\mask'][\\mask] \\prop' \\\\\n    \\hoare{\\prop'}{\\expr}{\\Ret\\val.\\propB'}[\\mask] \\\\   \n   \\All\\val. \\propB' \\vs[\\mask][\\mask \\uplus \\mask'] \\propB \\\\\n   \\atomic(\\expr)\n  }\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask \\uplus \\mask']}\n\\and\n\\inferH{Ht-false}\n  {}\n  {\\hoare{\\FALSE}{\\expr}{\\Ret \\val. \\prop}[\\mask]}\n\\and\n\\inferHB{Ht-disj}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propC}[\\mask] \\and \\hoare{\\propB}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n  {\\hoare{\\prop \\lor \\propB}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n\\and\n\\inferHB{Ht-exist}\n  {\\All \\var. \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n  {\\hoare{\\Exists \\var. \\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n\\and\n\\inferHB{Ht-box}\n  {\\always\\propB \\proves \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n  {\\hoare{\\prop \\land \\always{\\propB}}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n% \\and\n% \\inferH{Ht-inv}\n%   {\\hoare{\\later\\propC*\\prop}{\\expr}{\\Ret\\val.\\later\\propC*\\propB}[\\mask] \\and\n%    \\physatomic{\\expr}\n%   }\n%   {\\knowInv\\iname\\propC \\proves \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask \\uplus \\set\\iname]}\n% \\and\n% \\inferH{Ht-inv-timeless}\n%   {\\hoare{\\propC*\\prop}{\\expr}{\\Ret\\val.\\propC*\\propB}[\\mask] \\and\n%    \\physatomic{\\expr} \\and \\timeless\\propC\n%   }\n%   {\\knowInv\\iname\\propC \\proves \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask \\uplus \\set\\iname]}\n\\end{mathparpagebreakable}\n\n\\subsection{Invariant Namespaces}\n\\label{sec:namespaces}\n\nIn \\Sref{sec:invariants}, we defined a proposition $\\knowInv\\iname\\prop$ expressing knowledge (\\ie the proposition is persistent) that $\\prop$ is maintained as invariant with name $\\iname$.\nThe concrete name $\\iname$ is picked when the invariant is allocated, so it cannot possibly be statically known -- it will always be a variable that's threaded through everything.\nHowever, we hardly care about the actual, concrete name.\nAll we need to know is that this name is \\emph{different} from the names of other invariants that we want to open at the same time.\nKeeping track of the $n^2$ mutual inequalities that arise with $n$ invariants quickly gets in the way of the actual proof.\n\nTo solve this issue, instead of remembering the exact name picked for an invariant, we will keep track of the \\emph{namespace} the invariant was allocated in.\nNamespaces are sets of invariants, following a tree-like structure:\nThink of the name of an invariant as a sequence of identifiers, much like a fully qualified Java class name.\nA \\emph{namespace} $\\namesp$ then is like a Java package: it is a sequence of identifiers that we think of as \\emph{containing} all invariant names that begin with this sequence. For example, \\texttt{org.mpi-sws.iris} is a namespace containing the invariant name \\texttt{org.mpi-sws.iris.heap}.\n\nThe crux is that all namespaces contain infinitely many invariants, and hence we can \\emph{freely pick} the namespace an invariant is allocated in -- no further, unpredictable choice has to be made.\nFurthermore, we will often know that namespaces are \\emph{disjoint} just by looking at them.\nThe namespaces $\\namesp.\\texttt{iris}$ and $\\namesp.\\texttt{gps}$ are disjoint no matter the choice of $\\namesp$.\nAs a result, there is often no need to track disjointness of namespaces, we just have to pick the namespaces that we allocate our invariants in accordingly.\n\nFormally speaking, let $\\namesp \\in \\textlog{InvNamesp} \\eqdef \\List(\\nat)$ be the type of \\emph{invariant namespaces}.\nWe use the notation $\\namesp.\\iname$ for the namespace $[\\iname] \\dplus \\namesp$.\n(In other words, the list is ``backwards''. This is because cons-ing to the list, like the dot does above, is easier to deal with in Coq than appending at the end.)\n\nThe elements of a namespaces are \\emph{structured invariant names} (think: Java fully qualified class name).\nThey, too, are lists of $\\nat$, the same type as namespaces.\nIn order to connect this up to the definitions of \\Sref{sec:invariants}, we need a way to map structued invariant names to $\\InvName$, the type of ``plain'' invariant names.\nAny injective mapping $\\textlog{namesp\\_inj}$ will do; and such a mapping has to exist because $\\List(\\nat)$ is countable and $\\InvName$ is infinite.\nWhenever needed, we (usually implicitly) coerce $\\namesp$ to its encoded suffix-closure, \\ie to the set of encoded structured invariant names contained in the namespace: \\[\\namecl\\namesp \\eqdef \\setComp{\\iname}{\\Exists \\namesp'. \\iname = \\textlog{namesp\\_inj}(\\namesp' \\dplus \\namesp)}\\]\n\nWe will overload the notation for invariant propositions for using namespaces instead of names:\n\\[ \\knowInv\\namesp\\prop \\eqdef \\Exists \\iname \\in \\namecl\\namesp. \\knowInv\\iname{\\prop} \\]\nWe can now derive the following rules (this involves unfolding the definition of fancy updates):\n\\begin{mathpar}\n  \\axiomH{inv-persist}{\\knowInv\\namesp\\prop \\proves \\always\\knowInv\\namesp\\prop}\n\n  \\axiomH{inv-alloc}{\\later\\prop \\proves \\pvs[\\emptyset] \\knowInv\\namesp\\prop}\n\n  \\inferH{inv-open}\n  {\\namesp \\subseteq \\mask}\n  {\\knowInv\\namesp\\prop \\vs[\\mask][\\mask\\setminus\\namesp] \\later\\prop * (\\later\\prop \\vsW[\\mask\\setminus\\namesp][\\mask] \\TRUE)}\n\n  \\inferH{inv-open-timeless}\n  {\\namesp \\subseteq \\mask \\and \\timeless\\prop}\n  {\\knowInv\\namesp\\prop \\vs[\\mask][\\mask\\setminus\\namesp] \\prop * (\\prop \\vsW[\\mask\\setminus\\namesp][\\mask] \\TRUE)}\n\\end{mathpar}\n\n\\subsection{Accessors}\n\nThe two rules \\ruleref{inv-open} and \\ruleref{inv-open-timeless} above may look a little surprising, in the sense that it is not clear on first sight how they would be applied.\nThe rules are the first \\emph{accessors} that show up in this document.\nAccessors are propositions of the form\n\\[ \\prop \\vs[\\mask_1][\\mask_2] \\Exists\\var. \\propB * (\\All\\varB. \\propB' \\vsW[\\mask_2][\\mask_1] \\propC) \\]\n\nOne way to think about such propositions is as follows:\nGiven some accessor, if during our verification we have the proposition $\\prop$ and the mask $\\mask_1$ available, we can use the accessor to \\emph{access} $\\propB$ and obtain the witness $\\var$.\nWe call this \\emph{opening} the accessor, and it changes the mask to $\\mask_2$.\nAdditionally, opening the accessor provides us with $\\All\\varB. \\propB' \\vsW[\\mask_2][\\mask_1] \\propC$, a \\emph{linear view shift} (\\ie a view shift that can only be used once).\nThis linear view shift tells us that in order to \\emph{close} the accessor again and go back to mask $\\mask_1$, we have to pick some $\\varB$ and establish the corresponding $\\propB'$.\nAfter closing, we will obtain $\\propC$.\n\nUsing \\ruleref{vs-trans} and \\ruleref{Ht-atomic} (or the corresponding proof rules for fancy updates and weakest preconditions), we can show that it is possible to open an accessor around any view shift and any \\emph{atomic} expression:\n\\begin{mathpar}\n  \\inferH{Acc-vs}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\Exists\\var. \\propB * (\\All\\varB. \\propB' \\vsW[\\mask_2][\\mask_1] \\propC) \\and\n   \\All\\var. \\propB * \\prop_F \\vs[\\mask_2] \\Exists\\varB. \\propB' * \\prop_F}\n  {\\prop * \\prop_F \\vs[\\mask_1] \\propC * \\prop_F}\n\n  \\inferH{Acc-Ht}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\Exists\\var. \\propB * (\\All\\varB. \\propB' \\vsW[\\mask_2][\\mask_1] \\propC) \\and\n   \\All\\var. \\hoare{\\propB * \\prop_F}\\expr{\\Exists\\varB. \\propB' * \\prop_F}[\\mask_2] \\and\n   \\atomic(\\expr)}\n  {\\hoare{\\prop * \\prop_F}\\expr{\\propC * \\prop_F}[\\mask_1]}\n\\end{mathpar}\n\nFurthermore, in the special case that $\\mask_1 = \\mask_2$, the accessor can be opened around \\emph{any} expression.\nFor this reason, we also call such accessors \\emph{non-atomic}.\n\nThe reasons accessors are useful is that they let us talk about ``opening X'' (\\eg ``opening invariants'') without having to care what X is opened around.\nFurthermore, as we construct more sophisticated and more interesting things that can be opened (\\eg invariants that can be ``cancelled'', or STSs), accessors become a useful interface that allows us to mix and match different abstractions in arbitrary ways.\n\nFor the special case that $\\prop = \\propC$ and $\\propB = \\propB'$, we use the following notation that avoids repetition:\n\\[ \\Acc[\\mask_1][\\mask_2]\\prop{\\Ret x. \\propB} \\eqdef \\prop \\vs[\\mask_1][\\mask_2] \\Exists\\var. \\propB * (\\propB \\vsW[\\mask_2][\\mask_1] \\prop)  \\]\nThis accessor is ``idempotent'' in the sense that it does not actually change the state.  After applying it, we get our $\\prop$ back so we end up where we started.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"iris\"\n%%% End:\n", "meta": {"hexsha": "9ae6f66389489ece875d795f12a1b523e0d08d4f", "size": 26125, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/program-logic.tex", "max_stars_repo_name": "resource-reasoning/iris-coq", "max_stars_repo_head_hexsha": "f891015e2ab48926cec9618b0eadf0c0fec9ba1b", "max_stars_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-11-24T19:28:49.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-18T06:28:02.000Z", "max_issues_repo_path": "docs/program-logic.tex", "max_issues_repo_name": "resource-reasoning/iris-coq", "max_issues_repo_head_hexsha": "f891015e2ab48926cec9618b0eadf0c0fec9ba1b", "max_issues_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-11-01T08:35:12.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-01T08:35:12.000Z", "max_forks_repo_path": "docs/program-logic.tex", "max_forks_repo_name": "resource-reasoning/iris-coq", "max_forks_repo_head_hexsha": "f891015e2ab48926cec9618b0eadf0c0fec9ba1b", "max_forks_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2018-11-01T08:13:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-31T09:26:24.000Z", "avg_line_length": 59.1063348416, "max_line_length": 529, "alphanum_fraction": 0.6941244019, "num_tokens": 8844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4231724201177841}}
{"text": "\\documentclass[10pt]{report}\n\n\\usepackage{verbatim}\n\\usepackage{subcaption} % for subfigures\n%\\usepackage{amsthm} % for QED\n%\\usepackage{algpseudocode} % for pseudo-code\n\\usepackage{mathtools} % for \\xRightarrow\n\n\\usepackage{listings} % for code\n\\lstset\n{\n\tlanguage=Matlab,\n\tframe=single,\n\tbasicstyle=\\footnotesize,\n\tnumbers=left,\n\tstepnumber=1,\n\tshowstringspaces=false,\n\ttabsize=4,\n\tbreaklines=true,\n\tbreakatwhitespace=false,\n}\n\n\\usepackage{siunitx} % for scientific notation\n% for `e' in scientific notation\n\\sisetup{output-exponent-marker=\\ensuremath{\\mathrm{e}}}\n\n\\usepackage{float} % for figure [H]\n\\usepackage{booktabs} % for tabular\n\\usepackage{caption} % for \\caption*\n\\usepackage[export]{adjustbox} % for valign=t\n\\usepackage{array} % for column type m\n\\usepackage{verbatim}\n\\usepackage{graphicx}\n\\graphicspath{ {imgs/} }\n\\usepackage{fancyhdr}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n%%%%%% Pagination\n\\setlength{\\topmargin}{-.3 in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\evensidemargin}{0in}\n\\setlength{\\textheight}{9.in}\n\\setlength{\\textwidth}{6.5in}\n\n%Title page\n\\newcommand{\\hwTitle}{Homework \\#5}\n\\newcommand{\\hwCourse}{Introduction to Computational Mathematics}\n\\newcommand{\\hmwkClassInstructor}{Professor Shuwang Li}\n\n\\title{\n\t\\vspace{2in}\n\t\\textmd{\\textbf{\\hwCourse\\\\\\hwTitle}}\\\\\n\t\\vspace{0.3in}\\large{\\textit{\\hmwkClassInstructor}}\n\t\\vspace{3in}\n}\n\n%\\title{Homework 1}\n\\author{\\textbf{Zhihao Ai}}\n\\date{}\n\n%Header setting.\n\\pagestyle{fancy}\n\\fancyhead[L]{Zhihao Ai}\n\\fancyhead[C]{Math 350}\n\\fancyhead[R]{Homework 5}\n%%%%%%\n\n%Custom commands.\n\\newcommand{\\ds}{\\displaystyle}\n\\newcommand{\\eva}[2] {\\left. #1 \\right|_{#2}}\n\\newcommand{\\dintt}[4] {\\int_{#1}^{#2} #3 d#4}\n\n\\newcolumntype{C}{ >{\\centering\\arraybackslash} m{3em} }\n\\newcolumntype{D}{ >{\\centering\\arraybackslash} m{4em} }\n\\newcolumntype{N}{ >$ c <$}\n\n\\newcommand{\\abs}[1] {\\left| #1 \\right|}\n\\newcommand{\\norm}[2][\\infty] {\\left\\Vert \\mathbf{#2} \\right\\Vert_#1}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Part 1. Reading Assignment}\n%Read chapter 5.\n\n\\section*{Part 2. Fundamental Concepts/Ideas}\n\\begin{enumerate}\n\t\\item \n\tGiven data\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{*{6}{N}} \\toprule\n\t\t\ti & 1 & 2 & 3 & 4 & 5 \\\\ \\midrule\n\t\t\tx_i & 1.0 & 1.4 & 1.8 & 2.2 & 2.6\\\\\n\t\t\ty_i & 0.931 & 0.473 & 0.297 & 0.224 & 0.618\\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}\n\t\\end{table}\n\tWe can fit these data using a curve $y=p(x)=\\frac{1}{a+bx}$ in the least square sense.\n\t\\begin{enumerate}\n\t\t\\item \n\t\tFind coefficients $a$ and $b$. Hint: you can let $Y(x)=1/p(x)=a+bx$.\n\t\t\n\t\tLet $Y(x) = 1/p(x) = a + bx$, then $Y_i = 1/y_i$. To minimize $I(a, b) = \\sum_i [(a+bx) - Y_i]^2$, let both $\\partial{I}/\\partial{a} = \\partial{I}/\\partial{b} = 0$ and we have\n\t\t\\[\n\t\t\\begin{cases}\n\t\t2\\sum_i [(a + b x_i) - Y_i] \\cdot 1 = 0\\\\\n\t\t2\\sum_i [(a + b x_i) - Y_i] \\cdot x_i = 0\n\t\t\\end{cases}\n\t\t\\Rightarrow\n\t\t\\begin{cases}\n\t\t\\sum_i a + (\\sum_i x_i)b = \\sum_i Y_i\\\\\n\t\t(\\sum_i x_i)a + (\\sum_i x_i^2)b = \\sum_i x_i Y_i\\\\\n\t\t\\end{cases}\n\t\t\\]\n\t\tBelow is the script that solves the equations:\n\t\t\\lstinputlisting{hw5p1.m}\n\t\tThe coefficients outputed is $a\\approx 0.980376, b\\approx 0.859535$.\n\t\t\n\t\t\\item \n\t\tCompute the residual $E = \\sum_{i=1}^{5} [p(x_i) - y_i]^2$.\n\t\t\n\t\tThe script above produces $E\\approx 0.269785$.\n\t\t\n\t\t\\item \n\t\tUse Matlab to plot the curve $y=p(x)$ and $(x_i, y_i)$ on the same plot.\n\t\t\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.5\\linewidth]{hw5p1}\n\t\t\\end{figure}\n\t\\end{enumerate}\n\t\\textit{Things learned:} Data fitting is about minimizing the error between the calculated curve and the data points. By setting the partial derivatives of each parameter to 0, we are able to minimize the error function. We can transform the curve function like $p(x) = \\frac{1}{a+bx}$ into a form that is easy to take partial derivatives of. In the meantime, we also need to apply the same function to the original $y_i$'s to make the transformed question equivalent to the original one. In this question there is a outliner so the curve doesn't fit the first four well enough.\n\n\t\\item \n\tGiven data\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{*{8}{N}} \\toprule\n\t\t\ti & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\\ \\midrule\n\t\t\tx_i & 0.2 & 0.3 & 0.4 & 0.5 & 0.6 & 0.7 & 0.8\\\\\n\t\t\ty_i & 3.16 & 2.38 & 1.75 & 1.34 & 1.00 & 0.74 & 0.56\\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}\n\t\\end{table}\n\tWe can fit these data using a curve $y=q(x)=\\beta e^{-\\alpha x}$ in the least square sense.\n\t\\begin{enumerate}\n\t\t\\item \n\t\tFind coefficients $\\alpha$ and $\\beta$. Hint: you can let $Y(x)=\\ln y=\\ln \\beta - \\alpha x$.\n\t\t\n\t\tLet $Y(x) = \\ln{q(x)} = \\ln{\\beta} - \\alpha x$, then $Y_i = \\ln {y_i}$. To minimize $I(\\alpha, \\beta) = \\sum_i [(\\ln{\\beta} - \\alpha x_i) - Y_i]^2$, let both $\\partial{I}/\\partial{\\alpha} = \\partial{I}/\\partial{\\beta} = 0$ and we have\n\t\t\\[\n\t\t\\begin{cases}\n\t\t2\\sum_i [(\\ln{\\beta} - \\alpha x_i) - Y_i] \\cdot x_i = 0\\\\\n\t\t2\\sum_i [(\\ln{\\beta} - \\alpha x_i) - Y_i] / \\beta = 0\n\t\t\\end{cases}\n\t\t\\Rightarrow\n\t\t\\begin{cases}\n\t\t(\\sum_i x_i)\\ln{\\beta} - (\\sum_i x_i^2)\\alpha = \\sum_i x_i Y_i\\\\\n\t\t\\sum_i \\ln{\\beta} - (\\sum_i x_i)\\alpha = \\sum_i Y_i\n\t\t\\end{cases}\n\t\t\\]\n\t\tBelow is the script that solves the equations:\n\t\t\\lstinputlisting{hw5p2.m}\n\t\tThe coefficients outputed is $a\\approx 2.888285, b\\approx 5.631019$.\n\t\t\n\t\t\\item \n\t\tCompute the residual $E = \\sum_{i=1}^{7} [q(x_i) - y_i]^2$.\n\t\t\n\t\tThe script above produces $E\\approx 0.000897$.\n\t\t\n\t\t\\item \n\t\tUse Matlab to plot the curve $y=q(x)$ and $(x_i, y_i)$ on the same plot.\n\t\t\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.5\\linewidth]{hw5p2}\n\t\t\\end{figure}\n\t\\end{enumerate}\n\t\\textit{Things learned:} The procedure is similar to problem 1. We need to set the partial derivatives to 0 and solve the equations to get the parameters. Since there is no outliner in this problem, the curve fits the data points well so the residual is quite small.\n\\end{enumerate}\n\n\\newpage\n\n\\section*{Part 3. Computer Assignments}\n(Problem 5.8 @ Page 22) Given 25 observations, $y_k$, taken at equally spaced values of $t$.\n\\begin{enumerate}\n\t\\item [(a)]\n\tFit the data with a straight line, $y(t) = \\beta_1 + \\beta_2 t$, and plot the residuals, $y(t_k)-y_k$. You should observe that one of the data points has a much larger residual than the others. This is probably an \\textit{outlier}.\n\t\n\t\\lstinputlisting{hw5ca1a.m}\n\t\\begin{figure}[H]\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1a_fit}\n\t\t\t\\caption*{$y(t) = 4.012692 + 0.532643t$}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1a_residual} \n\t\t\t\\caption*{$y(t_k)-y_k$}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\t\n\t\\item [(b)]\n\tDiscard the outlier, and fit the data again by a straight line. Plot the residuals again. Do you see any pattern in the residuals?\n\t\n\t\\begin{figure}[H]\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1b_fit}\n\t\t\t\\caption*{$y(t) = 3.500757 + 0.556271t$}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1b_residual} \n\t\t\t\\caption*{$y(t_k)-y_k$}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\tThe residuals show a pattern of sin function.\n\t\n\t\\item [(c)]\n\tFit the data, with the outlier excluded, by a model of the form\n\t\\[\n\ty(t) = \\beta_1 + \\beta_2 t + \\beta_3 \\sin t\n\t\\]\n\t\n\t\\lstinputlisting{hw5ca1c.m}\n\tAccording to the outputs, $y(t) = 3.289994 + 0.574871 t + 1.198019 \\sin t$.\n\t\n\t\\item [(d)]\n\tEvaluate the third fit on a finer grid over the interval $[0,26]$. Plot the fitted curve, using line style '-', together with the data, using line style 'o'. Include the outlier, using a different marker, '*'.\n\t\n\t\\begin{figure}[H]\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1c_fit}\n\t\t\t\\caption*{$y(t) = 3.289994 + 0.574871 t + 1.198019 \\sin t$}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{hw5ca1c_residual} \n\t\t\t\\caption*{$y(t_k)-y_k$}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\tExcluding the outliner, the residual $E = \\sum_{i=1}^{24} [y(t_i) - y_i]^2 \\approx 9.682834$.\n\\end{enumerate}\n\\end{document}\n\n\n", "meta": {"hexsha": "eaaca181454ff64ccc048090b98cfd92f4a91bf4", "size": 8180, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW5/Math-350-HW5.tex", "max_stars_repo_name": "ZhihaoAi/MATH-350-Assignments", "max_stars_repo_head_hexsha": "d1645141525f88b3f937d96406848a7b0c714abe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW5/Math-350-HW5.tex", "max_issues_repo_name": "ZhihaoAi/MATH-350-Assignments", "max_issues_repo_head_hexsha": "d1645141525f88b3f937d96406848a7b0c714abe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW5/Math-350-HW5.tex", "max_forks_repo_name": "ZhihaoAi/MATH-350-Assignments", "max_forks_repo_head_hexsha": "d1645141525f88b3f937d96406848a7b0c714abe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3320158103, "max_line_length": 579, "alphanum_fraction": 0.6710268949, "num_tokens": 3063, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.8333245911726382, "lm_q1q2_score": 0.4231721141930833}}
{"text": "% !TeX root = ../main.tex\n% Add the above to each chapter to make compiling the PDF easier in some editors.\n\\graphicspath{{./figures/ch2/}}\n\n\\chapter{Auction Theory}\\label{chapter:theory}\nIn this chapter I will establish a basis of auction theory developed by academia. At first I will describe what an auction is and introduce basic auction formats like the First Price and Second Price Auction. Afterwards I will describe the exposure problem. To get an understanding of the auction formats used in the simulation (see \\autoref{chapter:simulation}) I will introduce the Simultaneous Multi-Round Auction (SMRA) and Hierarchical Package Bidding (HPB). %TODO abbreviations\n\n\n\\section{What is an Auction?}\nAuctions have become a well-established tool for answering a fundamental question in markets: \"Who gets what to which price?\". Having themselves proven as an effective tool to sell goods and implement public policies, auctions are now being used in a wide variety of settings, from effectively allocating radio spectrum to mobile network operators, trading electricity and pollution permits, governmental procurement and many more. Auction theory has been studied by academia for decades mostly by economists. With the rise of new auction types like combinatorial formats, where bidders can place bids on packages of items, auction theory became increasingly an interdisciplinary field of economics, operation research and computer science.\n\nAuctions are concerned with an allocation problem, meaning which bidder gets a good at what price. They are micro-foundations of markets, that try to answer this question \\cite{Cramton2006}. %TODO\n\n\\paragraph{The Independent Private Value (IPV) model.}\nAuctions can be defined using different perspectives, e. g. a game theoretic, a contract and mechanism design theory or market microstructure approach. For the following formulations, I will use the game theoretic perspective. A basic auction environment comprises of the following characteristics (based on \\cite[p. 1]{Levin2004}):\n\n\\begin{itemize}\n\t\\item A number of bidders $ i = 1,...,n $\n\t\\item the object to be auctioned, called \\textit{item}\n\t\\item the signal $ S_i $ observed by bidder $ i $ with a realization $ s_i \\in [\\bar{s}, \\underbar{s}] $\n\t\\item independence of bidder's signals $ S_1, ..., S_n $\n\t\\item Bidder \\textit{i} has a valuation function $ v_i(s_i) = s_i $\n\\end{itemize}\nThe IPV\\footnote{The simulation in this thesis will be based on the IPV.} can be extended to fit the needs for combinatorial auctions, where not only one item, but $ m $ indivisible items are simultaneously being auctioned among the $ n $ bidders \\cite[p. 267]{Nisan2007}. Also, the valuation function now maps from a subset $ S $ of the $ m $ items to their valuation  $ v(S) \\to \\mathbb{R} $, which the bidder $ i $ obtains upon winning this specific bundle of items and where the valuation function is monotone and \"normalized\", meaning $ v(\\emptyset) = 0 $ \\cite[p. 268]{Nisan2007}. \nThis formulation is necessary as the valuation of these subsets does not necessarily equal the sum of its containing items. Furthermore, two types of subsets can be defined, where subsets S and T with $ S \\cap T = \\emptyset $ are called \\textit{complements} if $ v(S \\cup T) > v(S) + v(T) $ (also called \\textit{super-additive}) and \\textit{substitutes} if $ v(S \\cup T) < v(S) + v(T) $  \\cite[p. 268]{Nisan2007}. Assuming the non-existence of \\textit{externalities}, meaning the bidder's valuation is not dependent on the allocation of items to other bidders, the \\textit{utility} or \\textit{payoff} $ \\pi_i $ of bidder $ i $ can be described as $ \\pi_i = v_i(S) - p $, where $ p $ is the price for the current subset $ S$ \\cite[p. 268]{Nisan2007}.\n\nThe mapping of items to bidders is called \\textit{allocation} and is written $ S_1, ..., S_n $ with $ S_i \\cap S_j = \\emptyset $ for every $ i \\neq j $. Summing all valuations over the allocation  $ \\sum_i v_i(S_i) $ is called \\textit{social welfare}. One goal of an auction can be to maximize this metric in its equilibrium. \\cite[p. 268]{Nisan2007}.\n\n\\paragraph{Common Value Auctions.}\nItem valuations do not have to be bound by its private valuation, but can also be influenced by the overall allocation of the items. In those cases, bidder $ i $ can learn about bidder $ j $'s information and might be forced to re-evaluate its valuation for the object \\cite[p. 8]{Levin2004}. Therefore, the signals and information from bidder $ i $ and $ j $ are dependent. Examples for auctions incorporating this behaviour can be initial public offerings or spectrum auctions. In \\textit{common value auctions}, the signals from other bidders influence a bidder's valuation by $ v_i(s_i, s_{-i}) $. Note, that the IPV is a special case of this formulation with $ v_i(s_i, s_{-i}) = s_i $, where the signals $ S_1,..., S_n $ are independent \\cite[p. 8]{Levin2004}.\n\n\\paragraph{Bayesian Nash Equilibrium.}\nOften, auctions are described by the equilibria they create, meaning the \"convergence\" of strategies used by the bidders that is induced by the auction format. If a bidder would know every strategy its competitors were following, he could easily deduce a payoff-maximizing action, which is called \\textit{best response}. Let $ s = (s_i, s_{-i}) $ be the \\textit{strategy profile} of the game, where $ s_i $ is bidder's $ i $ strategy and $ s_{-i} $  the strategies of its competitors. Bidder's $ i $ best response $ s_i^* $ to the strategy profile of its competitors $ s_{-i} $ is a mixed strategy $ s_i^* \\in S_i $ where $ \\pi_i (s_i^*, s_{-i}) \\geq \\pi_i (s_i, s_{-i}) \\quad \\forall s_i \\in S_i $ \\cite[p. 62]{Leyton-Brown2008}. When considering all the bidder's strategies, the strategy profile $ s = (s_1, ..., s_n) $ is a \\textit{Nash equilibrium} if for all agents $ i $, $ s_i $ is the best response to their competitors' strategies $ s_{-i} $ \\cite[p. 62]{Leyton-Brown2008}. Therefore, the Nash equilibrium describes the \\textit{stable} balance between the different bidder's strategies, where no bidder wants to change his strategy if he knew the strategies its competitors.\nThe \\textit{Bayesian Nash equilibrium} takes into account the assumption a bidder makes about the strategies of its competitors. With $ I = \\{1, 2, ..., n\\} $ being the set of players, $ X_i $ the set of possible types of agent $ i \\in I $ and $ F(\\cdot) $ the probability distribution over the set $ X = X_1 \\times X_2 \\times ... \\times X_n $ each player can choose a strategy $ s_i \\in S_i $ where $ s_i: X_i \\to S_i $ \\cite[p. 6 f.]{Menezes2005}. The \\textit{Bayesian Nash equilibrium} concerning the best responses $ s_1^*, ..., s_n^*$ and $ \\forall i \\in I, \\forall x_i \\in X $ and $ \\forall s_i \\in S_i $ can then be described as\n\n$$ \\int_{x_{-i} \\in X_{_i}} \\pi_i(s_i^*, s_{-i}^*, x_i, x_{-i}) d\\hat{F_i}(x_{-i}|x_i) \\geq \\int_{x_{-i} \\in X_{_i}} \\pi_i(s_i, s_{-i}^*, x_i, x_{-i}) d\\hat{F_i}(x_{-i}|x_i)  $$\n\t\t\nwhere $ \\hat{F_i}(x_{-i}|x_i) $ describes probability distribution over agent $ i $'s competitors' types, given that agent $ i $ knows his own type $ x_i $. The agent continuously updates his prior information on the distribution using Bayes rule, when he learned that his type is $ x_i $ \\cite[p. 6 f.]{Menezes2005}.\n\n\\subsection{Sealed Bid Auction - First Price Auction}\nThe sealed bid or first price auction is easy to imagine. Each bidder places sealed bids $ b_1, ..., b_n $ and the bidder with the highest bid wins, \\textit{paying the amount he bid}. Because of the nature of this rule, bidders have an incentive to not bid their true valuation of the object, because this would result in $ \\pi_i = v(s_i) -b_i = 0 $ \\cite[p. 3]{Levin2004}. To circumvent that, bidders might bid below their actual valuation to potentially increase their profit. Interestingly, it can be shown that the equilibrium for the sealed-bid first price auction with $ n $ bidders can be described as $$ b(v(s_i)) = \\Big( \\dfrac{n - 1}{n} \\Big) v(s_i)   $$ e. g. in a sealed bid auction with two bidders, each bidder would bid half its valuation of the object \\cite{Vickrey1961}.\n\n\\subsection{Vickrey Auction - Second Price Auction}\nThe Vickrey auction is a special case of the sealed bid auction, where bidders submit sealed bids $ b_1,...b_n $ and the bidder with the highest bids wins, but only \\textit{pays the amount of the second highest bid}. It can be shown, that in equilibrium, each bidder will bid its valuation of the object $ b_i(s_i) = s_i $ \\cite[p. 2]{Levin2004}. \nThe Nash equilibria of the Vickrey auction and the open English auction are the same. When auctioning items in an open and ascending (English) manner, the equilibrium will settle at the second highest valuation \\cite[p. 2]{Levin2004}. With the item prices rising from zero upwards, bidders can drop out of the auction when they reached their valuation of the object. The winner will have to pay the amount of the second highest valuation as its bidder will have dropped out as the price reached its valuation, making it the last bidder in the auction.\n\n\\section{SAA - Simultaneous Ascending Auctions}\nIn contrast to the normal English auction, were one item is sold at the same time using an ascending price system, spectrum auctions sell many goods. When selling items sequentially, bidders' available information and responding possibilities are limited and thus bidders might risk missing the opportunity to buy items at low prices early or even being forced to buy them at a much higher prices later on. Also they might fail to bundle desired packages of items together, which would be more valuable to them. Bidders are forced to make good predictions about the outcome of the auction and bid accordingly. Most times this leads to less efficient auctions, meaning less frequently bidders achieve to acquire the items or item combinations they value the most \\cite[p. 185]{Cramton2006}.\n\n\\paragraph{Characteristics.}\nTo reduce the amount of exposure bidders will be subjected to, simultaneous ascending auctions were introduced. In this format, many items are sold, were each item can be bid on simultaneously. Bidders can not submit bids on packages of items, but have to place bids on single objects. Like in an English auction, prices rise with each valid bid placed until the auction is finished, e.g. when each bidder stopped raising bids or when times runs out. \nIf certain item combination are complementarities, meaning their combination has super-additive valuation, bidders in SAA tend to suffer from bidder exposure \\cite[p. 209]{Cramton2006}. To mitigate this effect, withdrawal of standing bids can be implemented, that enables bidders to back out of failed item aggregations.\n\n\\paragraph{Conclusion and discussion.}\nSAA are a well established format used in high-stake auctions like spectrum, energy or pollution permit auctions. With mild complementarities, SAA yield in competitive equilibria, that also hold stand in practical usage \\cite[p. 209]{Cramton2006}. While SAA manage to successfully combine auctioning of multiple items with simple mechanism design, SAA can incentivise bidders to expose themselves in order to achieve certain item combinations when complementarities exist. In those environments, package bids should be used to increase efficiency of the auction\\cite[p. 185]{Cramton2006}. Also, revenue-reducing strategies and bidder collusion can occur in markets with weak competition, as well as bid-signalling to cooperatively split items between competing bidders \\cite[p. 187., p. 209]{Cramton2006}.\n\n\n\\section{The Exposure Problem}\\label{subsection:exposure-problem}\nDuring an auction with many offered items, bidders often try to acquire certain item combinations, because those packages of items might have super-additive valuation, meaning their package valuation is higher than the sum of the valuation of each item. In the field of spectrum auctions these might be a specific number of blocks obtained in a certain frequency band that enables better technology, e.g. LTE instead of GSM, or the clustering of adjacent geographical regions that allows a bidder to provide service for a bigger market while reducing costs by optimally placing transmission towers in the regions.\nWhen auction formats only allow bidders to place bids on single items, not packages of items, they run into the risk of failing to achieve the desired item combination. In order to acquire those bundles, bidders might have to bid above the valuation of a particular item but might not be able to acquire the remaining items in the bundle. This is called the exposure problem.\n\n\n\\paragraph{A simple example.} A bidder tries to acquire the synergistic combination of items $ A $ and $ B $. The bidder's valuation for each single item is $ v(A) = v(B) = 10 $, but when combining both, let's say because it enables the bidder to use more cost-effective technology, the valuation of both items together is $ v(AB) = 40 $, so twice the summed valuation of the single items. \n\nNow, let's consider the following situation: The current prices are $ p(A) = 9 $ and $ p(B) = 14 $. Normally, the bidder would set its bid for item A with $ bid(A, B) = (10, 0) $, thus excluding item B from its bid, because the current price already exceeds the bidder's internal valuation of the item. However, because the sum of both prices are still less than the combined valuation of the items, hence, the bidder has an incentive to also bid on B. For the sake of the argument, our bidder now placed its bid with $ bid(A, B) = (10, 15) $, the auction finished, but a competitor achieved to acquire item A with a higher price. Now, our bidder bought item B with $ p(B) = 15 $ and let's remember that the single item internal valuation of item B was $ v(B) = 10 $. Instead of gaining a surplus through obtaining one of the auctioned items, our bidder now made a loss (example based on \\cite{Levin2009}).\n\nIn auctions with many items and thus a high number of item combinations it is hard to keep track of the dependencies. Academia tackles the exposure problem by researching new auction formats or mechanisms that try to mitigate the exposure subjected to the bidders. One mechanism is the possibility to retract bids like they are offered in implementations of the SMRA %TODO abbr\n(see \\autoref{subsection:smra_theory}), where \"failed bids\", e.g. bids that failed to aggregate a desired item combination, can be withdrawn to free up budget, which the bidder can then focus on other valuation maximizing bids. This is a well establish mechanism, even though according to Cramton, this can lead to \"undesirable gaming behavior\" within the auction and has to be constrained to effectively control such behaviour \\cite{Cramton2006}.\nOther efforts strive to reduce exposure of bidders by enabling them to bid on (pre-)defined packages, like the HPB format (more on that in \\autoref{subsection:hpb_theory}). \n\n\\section{What is the Advantage of Round Based Auctions?}\nIn standard auction models, like in sealed bid auctions, it is assumed that each bidder knows its valuation for each possible package a priori \\cite{Cramton2006}. In fact, determining valuation is a costly process, because it can depend on information of other bidders and especially when a high number of items are involved, create a solution space of combinatorial magnitude. \n\nRound based auctions try to mitigate this problem as each round, bidding information is released and bidders can identify target licenses more easily \\cite{Levin2009}. The extent of the information range depends on the model and its implementation, but exemplary might contain price information like the highest winning bid and all bids placed by competitors. With the newly revealed information at hand, bidder's uncertainty is reduced so that they can set their future bids more aggressively and can focus on the valuation maximazing parts of the item space, which improves efficieny according to Cramton \\cite{Cramton2006}. Over time, bidders increasingly get an understanding of what the overall allocation and prices at the end of the auction might look like and can bid according to this judgement.\n\nUsing this advantage, round based formats were used in national spectrum auctions in the U.S. (and later on in Europe) since 1994 when it was proposed to the U.S. Federal Communication Commission by Milgrom, Wilsen and McAfee.\n\n\\section{Auction Formats used in Spectrum Auctions}\nEven though the success of simultaneous ascending auction formats in national spectrum auctions led to a widespread use of formats like the SMRA, %TODO abbr\na number of other formats were used in recent times or new formats were proposed by academia. In the following section I will describe the auction processes and rules for the Simultaneous Multi-Round Auction (SMRA). %TODO abbr\nand the Hierarchical Package Bidding Auction (HBP). Both formats will be compared in the simulation (see \\autoref{chapter:simulation}). %TODO abbr\n \n\\subsection{SMRA - Simultaneous Multi-Round Auction}\\label{subsection:smra_theory}\nThe Simultaneous Multi-Round Auction (SMRA) is most commonly used auction format used for selling spectrum world wide. Since its development in the early 90's for the US Federal Communications Commission its usage has become wide spread, making it the de facto standard. Its success stems from the fact, that it often leads to good allocations \\cite{BichlerLecture2016}, but it suffers from strategic challenges for bidder when used in an environment where complementarities exist.\n\n\\paragraph{Characteristics.}\nThe SMRA extends the SAA, by adding a round based system. Multiple items are auctioned at the same time - in contrast to the English auction - in a round based fashion, where each round has a time limit in which bidders can place bids.  When a round is finished, bidding data is published that contains the \\textit{current} winner of each item, which corresponds with the highest bid placed on each item \\cite{BichlerLecture2016}. The degree of transparency provided by the auctioneer depends on the implementation, e.g. the German auction in 2015 provided very high transparency by showing all bids placed by each participant \\cite{Bundesnetzagentur2015}. Often, only highest bid submitted is published.\nIn each round, bidders have to exceed the provisional prices of the previous round by a pre-defined \\textit{increment} if they wish to claim the item. In the German auction, bidders could submit bids using a \\textit{clickbox} system, which offered pre-defined multiples of the current increment. The increment can change over time, depending on the current \\textit{phase} of the auction. The auction ends, when no new bids are being submitted. Each bidders than acquire the items where he possesses the highest active bid and pays the prices accordingly. \n\nTo incentivise bidding right from the start, SMRA makes use of \\textit{activity rules}. This is often realised by \\textit{eligibility points (EP)} that corresponds to a bidder's bidding extent. Each bidder starts with a pre-defined number of EP - often comprising of the maximum number of licenses allowed to bid on - and each item can be matched to a certain number of EP necessary to bid on them. If the EP from the items won in the previous round and the bids submitted in the new round are less than the current \\textit{activity level}, a bidder's EP gets deducted by the amount it \"under-bid\". An example for an activity level can be 65\\% of the starting EP, as used in the German auction in the first bidding phase. From then on, the activity level subsequently rose to 80\\% and 100\\% \\cite[p. 15]{Bundesnetzagentur2015}.\nAdditionally, auctioneers using SMRA can use a wide range of tools to influence the outcome of the auction. These can include:\n\\begin{itemize}\n\t\\item \\textit{minimum prices} for the items\n\t\\item \\textit{bid increments} and how their value changes over the course of the auction\n\t\\item \\textit{bid withdrawals} and \\textit{waivers}, which allow the bidder to either withdraw a bid submitted in a previous round or to suspend himself from bidding for a round (without consequences)\n\t\\item \\textit{bidding floors} and \\textit{caps} which regulate how many items a bidders is allowed to obtain in a specific frequency band to prevent monopolies or businesses to drop out of the market due to insufficient supply.\n\\end{itemize}\n\n\\paragraph{Conclusion and discussion.}\nThe SMRA is an easy to implement auction format which clear and simple rules which often realises efficient allocations. In environments where complementarities exist (such as synergetic values between items), the SMRA fails to resolve at a Walrasian equilibrium \\cite{BichlerLecture2016}. Due to its lack of package bidding, bidders might be incentivised to expose themselves in order to acquire certain item combinations, making the exposure problem a central challenge in SMRA strategies. The activity rules have shown to be fairly similar world wide, but the degree of transparency differs widely, as well as the rules in procurement, which have impact on the performance of the auction. Nevertheless, the SMRA is a well established and frequently used format for spectrum auctions and other common value auctions. \n\n\\subsection{HPB - Hierarchical Package Bidding}\\label{subsection:hpb_theory}\nWhile the Hierarchical Package Bidding Auction (HPB) has never been used in a national spectrum auction before, this thesis will run simulations using this format to explore indicators of its eligibility as basis for further research. The implementation used in this thesis is based on the propositions of \\citeauthor{Goeree2010} from 2007.\n\nThe paper hypothesised that HPB might help mitigating the exposure problem (see \\autoref{subsection:exposure-problem}) by pre-packaging bidding items into bundles inside a tree like hierarchy structure. This allows bidders to bid on packages, signalling a desired allocation. By that, the bidder can bid on a certain package until its valuation, without the need to possibly strategically bid over the valuation of single items in that package. In the end, the bidder either manages to acquire every item in the package and combining them to realise super-additive valuation or does not win any of the items. Of course, bidders are still able to bid on single items. \n\nCombinatorial auctions try to solve the problem by allowing bidders to bid on any desired item combinations. Determining the provisional allocation after each round shows to be an intricate and computationally expensive problem in the magnitude of \\textit{NP-hard} \\cite{Goeree2010}, meaning non-deterministic polynomial-time hard, because the number of possible arrangements growth exponentially with the number of objects. Thus, it is not guaranteed to find the optimal solution within a reasonable amount of time and mostly the best current solution yielded within a pre-defined time frame will be chosen. This approach is problematic as price calculations seem non-transparent and even experts claim the ability to rig auctions based on this computational downside  \\cite{Goeree2010}.\n\n\\paragraph{The HPB idea.} \\citeauthor{Rothkopf1998} proposed a hierarchical pre-packaging of items to avoid the issues of computational expensiveness of combinational auctions in 1998 \\cite{Rothkopf1998}. The work of \\citeauthor{Goeree2010} was based on this proposition and extended it by developing a recursive pricing formula for combinatorial auctions using the pre-defined hierarchies. The basic idea of the pricing formula is that prices for single items would be increased by \\textit{\"lump-sum taxes\"} handed down from packages in the higher hierarchy levels. In the case a package bid is winning, the excess prices will be proportionally propagated down towards the single item level of the hierarchy. The goal is to create a transparent and computationally inexpensive way to calculate the prices.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\input{./figures/ch2/hpb_hierarchy_example.tikz}\n\t\\caption{Example of an HPB Hierarchy for spectrum auctions}\n\t\\label{fig:hpb-hierarchy-example}\n\\end{figure}\n\n\\paragraph{The mathematical formulation.}\nAn example for a HPB hierarchy can be seen in \\autoref{fig:hpb-hierarchy-example}, which subsequently unites items to regional and finally a nation wide package. Formulated in \\cite{Goeree2010}, a hierarchy has $ H \\geq 1 $ hierarchy levels which are subsequently labeled $ h = 1, ..., H $ and each level $h$ contains $ I_h $ packages. The single items can be found as leaves in the tree in $ h = 1 $, from there the package grow bottom up. Packages in level $ h $ are written as $ P_{i_h}^h \\text{ for } i_h = 1,..., I_h $. Each of the packages consists of $ \\alpha_{i_h}^h $ bidding items and the number of packages in a level falls while propagating upward in the hierarchy. As an important note, all packages in a hierarchy are non-overlapping, meaning $ \\forall \\text{ level-h packages } P_{i_h}^h \\neq P_{i_h}^h \\implies P_{i_h}^h \\cap P_{i_h}^h = \\emptyset $. Therefore, each package is contained in only one package in the following upper level $ h' > h $ and there is only one unique level-$h'$ package $ P_{j_{h'}}^{h'} $ with $ P_{j_{h'}^{h'}} \\supset P_{i_h}^h  $. This results in the number of items being contained in a package is the sum of items it covers in level-1.\n\\begin{align}\n\t\\sum_{P_{i_1}^1 \\subset P_{i_h}^h} \\alpha_{i_1}^1 = \\alpha_{i_h}^h\n\\end{align}\nEvery hierarchy level contains all items from level-1: $ \\sum_{i_h = 1}^{I_h} \\alpha_{i_h}^h = \\alpha \\text{ } \\forall \\text{ h in h } = 1,...,H $ with $ \\alpha $ being the\n total number of \\textit{(level-1)} items in the auction.\nAfter defining the hierarchy and its properties, \\citeauthor{Goeree2010} devised two recursive algorithms for calculating the \\textit{revenues} $ R(P_{i_h}^h) $ and \\textit{prices} $ p(P_{i_1}^1) $.\n\n\\textbf{Revenues and the assignment problem:} To assign items to bidders, first the highest bid $ b^{max}(P_{i_h}^h)$ on the packages have to be found. Finding the optimal assignment and revenue can be describes as follows:\n\\begin{enumerate}\n\t\\item Set $ h = 1 $, for this level set revenues to $ R(P_{i_1}^1) = b^{max}(P_{i_1}^1)$ for $ i_1 = 1, ..., I_1 $, those bids are marked as \\textit{\"provisionally winning\"}\n\t\\item if $ h < H \\implies h = h+1$ and continue with step \\textit{3}, otherwise \\textit{stop}\n\t\\item if $ b^{max}(P_{i_h}^h) > \\sum_{P_{i_{h-1}}^{h-1} \\subset P_{i_h}^h} R(P_{i_{h-1}}^{h-1}) \\implies R(P_{i_h}^h) = b^{max}(P_{i_h}^h)$ and label $ b^{max}(P_{i_h}^h) $ as \\textit{provisionally winning}, bids from all lower levels on packages that overlap with $ P_{i_h}^h $ are unmarked. Otherwise, $ R(P_{i_h}^h) = \\sum_{P_{i_{h-1}}^{h-1} \\subset P_{i_h}^h}  R(P_{i_{h-1}}^{h-1})$ and \\textit{return to step 2}.\n\\end{enumerate}\n\n\\textbf{Prices:} Now, with the assignment set, the prices have to be updated. They are assigned to the level-1 items in the hierarchy by adding \\textit{\"lump sum tax\"} to the items if the revenue of package is less than the one the next level upwards. With $ p(P_{i_1}^1) $ being the price of level-1 package $ P_{i_1}^1 $:\n\\begin{enumerate}\n\t\\item Set $ h = 1 $ and define prices for all packages in this level as $ p(P_{i_1 }^1) = b^{max}(P_{i_1}^1) $  $\\forall i_1 = 1, ..., I_1 $\n\t\\item if $ h < H  \\implies h = h + 1 $ and continue with \\textit{step 3}, otherwise \\textit{stop}\n\t\\item For each package $ P_{i_h}^h $ in level-$h$ calculate $$ \\tau^h(P_{i_1}^1) = \\dfrac{\\alpha_{i_1}^1}{\\alpha_{i_h}^h} \\Big( R(P_{i_h}^h) \\quad - \\sum_{P_{i_{h-1}}^{h-1} \\subset P_{i_h}^h} R(P_{i_{h-1}}^{h-1}) \\Big) \\geq 0 $$ and add $ \\tau^h(P_{i_1}^1) $ to the price $ p(P_{i_1}^1) $ of each level-1 package $ P_{i_1}^1 $ contained in $ P_{i_h}^h $. Return to \\textit{step 2}\n\\end{enumerate}\n\nIn comparison to the calculations needed in other combinatorial auction formats, the computations done in the two formulations above are computationally inexpensive. This is one of the advantages of HPB. \\citeauthor{Goeree2010} derived a calculation of the level-1 prices as follows:\n\\begin{align}\n\tp(P_{i_1}^1) = b^{max}(P_{i_1}^1) + \\sum_{P_{i_h}^h \\supset P_{i_1}^1} \\dfrac{\\alpha_{i_1}^1}{\\alpha_{i_h}^h} \\Big( R(P_{i_h}^h) \\quad - \\sum_{P_{i_{h-1}}^{h-1} \\subset P_{i_h}^h} R(P_{i_{h-1}^{h-1}}) \\Big)\n\\end{align}\n\n%TODO include simple example?\n\n\\paragraph{Summary and discussion.}\nHPB shows to be less computationally expensive as other combinatorial auction formats but maintains the possibility for bidders to bid on \\textit{pre-defined} packages within a hierarchy that is built bottom up from the single items upwards. The assignment problem as well as the price calculations can be done using a recursive function, where the number of comparisons needed is only linear in relation to the pre-defined packages \\cite{Goeree2010}. \n\n\\citeauthor{Goeree2010} also mention in their paper that the pre-packaging will disadvantage small bidders who also contribute to finding optimal allocations. The impact of this needs to be researched in further studies. Also, \\citeauthor{Goeree2010} argue that non-overlapping package structures may not always be able to reflect the interests of the participating bidders. It still needs to be verified to what extent the hierarchy influences auction outcomes. Also, for each auction there might be an array of alternative hierarchies. To choose the appropriate hierarchy seems to be key in using HPB efficiently.\n\n\\subsection{Other Auction Formats}\nIn spectrum auctions world wide a variety of different auctions formats are used. The reason for that are different performance properties of efficiently allocating items to bidders as well as maximizing revenue or social welfare. \nFor example, Canada used a the combinatorial clock auction (CCA) format to sell the 2500 MHz spectrum in the 2014 . It used an OR-bidding language, where bidders were able to express that they want to acquire a license for a certain price \\textit{and / or} a different license for a different price \\cite{FCCCanada}. The auction involved a price discovery stage that was similar to the SMRA auction format, but the CCA allowed bidders to submit bids on packages rather than only on single items. This was necessary due to the regional nature of the licenses being auctioned and the complementarities that existed between them \\cite{FCCCanada}.\n\nDespite the fact that combinatorial auction allows bidding on packages, it still inherits a lot of issues like non-linear price progressions that makes it hard for bidders to compare prices, as well as computational issues \\cite[p. 290]{Nisan2007}, which results in combinatorial auction not being frequently used in spectrum auctions.\n\nIn 2015, the French 700 MHz spectrum auction was even conducted in a sealed bid manner \\cite{FranceSealed2015}, raising EUR 2.8bn in the process. The sealed bid part in the auction was used to decide where in the spectrum band auctioned blocks should be placed.", "meta": {"hexsha": "1ea13be24cdbae2c819bc3e35c224e0358c519ad", "size": 30943, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/03_theory.tex", "max_stars_repo_name": "timbrgr/auction-simulation-SMRA-HPB-BA-thesis", "max_stars_repo_head_hexsha": "4b34b0ab019ebf969b91dc2f8ee755a1cc8aba02", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chapters/03_theory.tex", "max_issues_repo_name": "timbrgr/auction-simulation-SMRA-HPB-BA-thesis", "max_issues_repo_head_hexsha": "4b34b0ab019ebf969b91dc2f8ee755a1cc8aba02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapters/03_theory.tex", "max_forks_repo_name": "timbrgr/auction-simulation-SMRA-HPB-BA-thesis", "max_forks_repo_head_hexsha": "4b34b0ab019ebf969b91dc2f8ee755a1cc8aba02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 194.6100628931, "max_line_length": 1183, "alphanum_fraction": 0.7720970817, "num_tokens": 7674, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.42311254663601766}}
{"text": "\\section{Simplified Higher-Order Closure (SHOC)}\n\n\\subsection{Introduction}\n\nSimplified Higher Order Closure \\citep[SHOC;][]{Bogenschutz_Krueger13} is a parameterization of subgrid-scale (SGS) clouds and turbulence.  It is formulated to parameterize SGS shallow cumulus, stratiform cloud, and boundary layer turbulence in models that can either resolve deep convection or has an existing deep convection parameterization.  SHOC is an assumed-PDF based parameterization and uses a double Gaussian PDF to diagnose cloud fraction, cloud water, and higher-order turbulence moments.  SHOC is only a liquid cloud parameterization, thus it is assumed that any model SHOC is implemented in can treat the ice cloud phase. \n\nTable~\\ref{table:prognostic} describes the SHOC prognostic variables and their nomenclature to be used throughout this document.  \n\n\\begin{table}[b]\n\\caption{Prognostic Variables in SHOC}\n\\centering\n\\begin{tabular}{c c c}\n\\hline\\hline\nvariable & description & units \\\\\n\\hline\n$\\theta_{l}$ & Liquid water potential temperature & K \\\\\n$q_{t}$ & Total water mixing ratio (vapor + cloud liquid) & kg/kg \\\\\n$e$ & Turbulent kinetic energy & m$^2$/s$^2$ \\\\\n$u$ & Zonal wind component & m/s \\\\\n$v$ & Meridional wind component & m/s \\\\\n$c$ & Tracer constituent & varies \\\\\n\\hline\n\\end{tabular}\n\\label{table:prognostic}\n\\end{table}\n\nThe liquid water potential temperature, $\\theta_{l}$, is defined as:\n%\n\\begin{equation}\n  \\theta_{l} \\approx \\theta - \\frac{L_{v}}{c_{pd}}q_{l}\n  \\label{thetal}\n\\end{equation}\n%\nwhere $\\theta$ is potential temperature, $L_{v}$ is the latent heat of vaporization, $c_{pd}$ the specific heat of dry air at constant pressure, $q_{l}$ the liquid water mixing ratio.  The turbulent kinetic energy ($\\overline{e}$) is defined as\n%\n\\begin{equation}\n  \\overline{e} = 0.5(\\overline{u^{'2}}+\\overline{v^{'2}}+\\overline{w^{'2}}) , \n  \\label{tke}\n\\end{equation}  \n%\nwhere $\\overline{u^{'2}}$, $\\overline{v^{'2}}$, and $\\overline{w^{'2}}$ represent the SGS zonal, meridional, and vertical wind variances, respectively.  \n\nIn the SHOC parameterization, all prognostic variables are defined vertically at the mid-point of the grid box.  \n\nTable~\\ref{table:diagnostic} describes key diagnostic variables used throughout the SHOC parameterization, and their respective locations on the vertical grid.  Note that many diagnostic variables are defined at the interfaces of the grid box.  This is because many diagnostic variables are the result of centered vertical differences of the prognostic variables.  \n\n\\begin{table}[ht]\n\\caption{Key Diagnostic Variables in SHOC.  M in the location column indicates that the variable is located vertically in the mid-point of the grid box, while I indicates that the variable is located at the grid interfaces.}\n\\centering\n\\begin{tabular}{c c c c}\n\\hline\\hline\nvariable & description & units & location \\\\\n\\hline\n$L$ & Turbulent Length Scale & m & M \\\\\n$\\overline{\\theta_{l}^{'2}}$ & Temperature variance & K$^2$ & I \\\\\n$\\overline{q_{t}^{'2}}$ & Moisture variance & kg$^2$/kg$^2$ & I \\\\\n$\\overline{w^{'2}}$ & Vertical velocity variance & m$^2$/s$^2$ & M \\\\\n$\\overline{w^{'}\\theta_{l}^{'}}$ & Vertical temperature flux & K m/s & I \\\\\n$\\overline{w^{'}q_{t}^{'}}$ & Vertical moisture flux & m/s kg/kg & I \\\\\n$\\overline{q_{t}^{'}\\theta_{l}^{'}}$ & Temperature and moisture covariance & K kg/kg & I \\\\\n$\\overline{w^{'3}}$ & Third moment of vertical velocity &  m$^3$/s$^3$ & I \\\\\n$\\overline{w^{'}\\theta_{v}^{'}}$ & Buoyancy flux & K m/s & M \\\\\n$K_{m}$ & Eddy diffusivity for momentum & m$^2$/s & M \\\\\n$K_{h}$ & Eddy diffusivity for heat & m$^2$/s & M \\\\\n\\hline\n\\end{tabular}\n\\label{table:diagnostic}\n\\end{table}  \n\nThe code for SHOC breaks down each process into a separate subroutine.  Briefly, the order of operations of SHOC is described below.  Each process is then expanded upon with its own section.\n\nSHOC order of operations:\n\\begin{enumerate}\n  \\item \\textbf{Diagnose Turbulence Length Scale} (section~\\ref{turb_scale}): The length scale represents the size of unresolved large eddies in a column.  This is needed to close the TKE equation and to diagnose several second order moments.\n  \\item \\textbf{Solve the Turbulence Kinetic Energy Equation} (section~\\ref{tke_equation}): Advance the TKE equation (due to shear production, buoyant production, and dissipation processes) one time step.  Note that advection of TKE is performed by the host model, while turbulent transport of TKE is done by SHOC turbulence diffusion.    \n  \\item \\textbf{Perform Turbulence Diffusion} (section~\\ref{turb_diffusion}): Using eddy coefficients derived from TKE, advance $\\overline{u}$, $\\overline{v}$, $\\overline{\\theta_{l}}$, $\\overline{q_{t}}$ , $\\overline{e}$, and any tracers ($\\overline{c}$) one time step using an implicit diffusion solver.  \n  \\item \\textbf{Diagnose the Second Order Moments} (section~\\ref{diag_second}): Diagnose $\\overline{q_{t}^{'2}}$, $\\overline{\\theta_{l}^{'2}}$, $\\overline{q_{t}^{'}\\theta_{l}^{'}}$, $\\overline{w^{'2}}$, $\\overline{w^{'}\\theta_{l}^{'}}$, and $\\overline{w^{'}q_{t}^{'}}$.  These are the second order moments needed to close the assumed PDF.\n  \\item \\textbf{Diagnose the Third Order Moment} (section~\\ref{diag_third}):  Diagnose the third moment of vertical velocity ($\\overline{w^{'3}}$), needed to parameterize vertical velocity skewness in the assumed PDF\n  \\item \\textbf{Compute Assumed PDF} (section~\\ref{assumed_pdf}): Use the Assumed PDF to compute SGS cloud water, cloud fraction, and the buoyancy flux ($\\overline{w^{'}\\theta_{v}^{'}}$).\n\\end{enumerate}\n\nIn SHOC the order of operations is chosen deliberately so that the prognostic variables are updated first and the clouds are diagnosed last.  This is to prevent supersaturation from occurring when SHOC is complete, to avoid any potential conflicts with a microphysics scheme which may be called in the host model. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% TURBULENCE LENGTH SCALE\n\\subsection{Turbulence Length Scale}\n\\label{turb_scale}\n\nThe empirical formulation is based on the finding that the turbulent length scale is highly correlated with the distance from the wall, strength of the turbulence, boundary layer depth, and local thermal stability (Bogenschutz et al. 2010).  Within the turbulent boundary layer, the length scale definition is set equal to an asymptotic shape, similar to that of \\cite{Blackadar_62}.  However it is weighted more strongly by the strength of the turbulence.  This reflects the behavior that as the grid size increases, the SGS TKE increases and so does the mixing length.  The effects of thermal stability are also included to reduce the length scale where the local stability is large.  \n\nThe formulation in (\\ref{thelength}) is empirically determined from LES data and essentially represents a geometric average between the strength of the SGS TKE (as suggested by Texieria et al. 2004) and an asymptote length scale, with a contribution due to stability effects.  The geometric average assures that in close proximity to the surface, the length scale will be small.  \n%\n\\begin{equation}\n  L=\\sqrt[]{8\\left[\\frac{1}{\\tau\\sqrt[]{e}kz}+\\frac{1}{\\tau\\sqrt[]{e}L_{\\infty}}+0.01\\delta\\frac{N^{2}}{\\overline{e}}\\right]^{-1}}\n  \\label{thelength}\n\\end{equation}\n\nAbove, $k$ is the von Karman constant.  $L_{\\infty}$ is the asymptotic value of the length scale as defined in Blackadar (1962) as\n%\n \\begin{equation}\n  L_{\\infty}=0.1\\frac{\\int_{0}^{\\infty}\\overline{e}^{1/2}z dz}{\\int_{0}^{\\infty} \\overline{e}^{1/2} dz}. \n  \\end{equation}\n %\n   In equation~\\ref{thelength} $\\delta$ is defined as:\n\\[\n\\delta = \\left\\{ \n\\begin{array}{l l}\n  1 & \\quad \\text{if} \\quad N^{2} > 0 \\\\\n  0 & \\quad \\text{if} \\quad N^{2} \\le 0 \\\\\n\\end{array} \\right.\n\\]     \n%\nwhere $N^{2}$ is the moist Brunt Vaisala Frequency.  In SHOC $N^{2}$ is defined as:\n%\n\\begin{equation}\n  N^{2} = \\frac{g}{\\overline{\\theta_{v}}}\\frac{\\partial{\\overline{\\theta_{v}}}}{\\partial{z}}\n  \\label{brunt}\n\\end{equation}\n%\nwhere $\\theta_{v}$ is the virtual potential temperature defined as:\n%\n\\begin{equation}\n  \\theta_{v}=\\theta(1 + 0.61q_{v} - q_{l}) , \n  \\label{thetav}\n\\end{equation}\n%\nwhere $q_{v}$ is the water vapor mixing ratio. \n%\nFinally, $\\tau$ in equation~\\ref{thelength} represents the eddy turnover timescale and is defined as\n%\n\\begin{equation}\n  \\tau = \\frac{D_{b}}{w_{*}},\n  \\label{conv_scale}\n\\end{equation} \n\nwhere $D_{b}$ is the boundary layer depth and is computed according to that of Holtslag and Boville (1993).  $w_{*}$ represents the convective velocity scale, integrated from the surface to the height of the boundary layer depth, and is defined as:\n%\n\\begin{equation}\n  w_{*}^{3}=2.5\\frac{g}{\\overline{\\theta_{v}}} \\int_{0}^{z_{D_{b}}} \\overline{w^{'}\\theta_{v}^{'}} dz .   \n  \\label{wstar_pbl}\n\\end{equation}\n\nIn the event that $w_{*}^{3} < 0$, which is indicative of a stable boundary layer, then $\\tau$ is set to a default value of 100 s.  \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% TURBULENT KINETIC ENERGY\n\\subsection{Turbulent Kinetic Energy Equation}\n\\label{tke_equation}\n\nIn SHOC, the turbulent kinetic energy (TKE) equation to be solved is given by:\n%\n\\begin{equation}\n  \\frac{\\partial{\\overline{e}}}{\\partial{t}}=\\underbrace{-\\overline{u_{j}}\\frac{\\partial{\\overline{e}}}{\\partial{x_{j}}}}_\\text{advection}+\\underbrace{\\frac{g}{\\overline{\\theta_{v}}}\\left(\\overline{w^{'}\\theta_{v}^{'}}\\right)}_\\text{buoyant production}-\\underbrace{P_{s}}_\\text{shear production}-\\underbrace{\\frac{\\partial{\\overline{w^{'}e}}}{\\partial{z}}}_\\text{turbulent transport}-\\underbrace{C_{ee}\\frac{\\overline{e}^{3/2}}{L}}_\\text{dissipation} .  \n  \\label{sgstke}\n\\end{equation}\n\nThe first term on the RHS of equation~\\ref{sgstke} is advection, which is performed by the host model (i.e. SCREAM dynamics) and not SHOC.  \n\nThe second term is the buoyant production of TKE.  The buoyancy flux term ($\\overline{w^{'}\\theta_{v}^{'}}$) is closed by integrating over the assumed PDF (see section~\\ref{assumed_pdf}) using equation~\\ref{buoyancy}.  Thus, $\\overline{w^{'}\\theta_{v}^{'}}$ from the previous SHOC time step is used to close this term.  \n\nThe shear production term is computed according to \\cite{bretherton2009_moist}:\n%\n\\begin{equation}\n  -P_{s}= -\\overline{w^{'}u^{'}}\\frac{\\partial{\\overline{u}}}{\\partial{z}}-\\overline{w^{'}v^{'}}\\frac{\\partial{\\overline{v}}}{\\partial{z}} = K_{M}S^{2} , \n  \\label{shearprod}\n\\end{equation}\n%\nwhere\n\\begin{equation}\n  S^{2} = \\left(\\frac{\\partial{\\overline{u}}}{\\partial{z}}\\right)^2+\\left(\\frac{\\partial{\\overline{v}}}{\\partial{z}}\\right)^2 . \n  \\label{tke_Sterm}\n\\end{equation}\n%\nSince $\\overline{u}$ and $\\overline{v}$ are located vertically in the mid-points, $S^{2}$ is computed on the interface grid, then interpolated onto the mid-point grid.  After the shear production term is calculated on the interface grid, it is interpolated to the mid-point grid to be consistent with the location of $\\overline{e}$. \n\nThe boundary surface value of $K_{M}S^{2}$ is set to zero as the boundary fluxes for TKE are applied in the diffusion solver.  \n\nThe fourth term on the RHS of equation~\\ref{sgstke} represents the turbulent transport of TKE.  This term is computed in the turbulent diffusion (section~\\ref{turb_diffusion}) of SHOC.  \n\nThe last term on the RHS of equation~\\ref{sgstke} represents the turbulent dissipation of TKE.  Here $C_{ee}$ is a turbulent constant, which is defined in \\cite{Deardorff_80} as $C_{ee}=C_{e1}+C_{e2}$, where $C_{e1} = C_{e}/0.133$ and $C_{e1} = C_{e}/0.357$ and $C_{e}=C_{k}^{3}/C_{s}^{4}$.  Finally, $C_{k} = 0.1$ and $C_{s} = 0.15$.  \n\n\\subsubsection{Eddy Diffusivities}\n\n\\paragraph{Default Formulation}\n\nAfter TKE is updated due to buoyant production, shear production, and dissipation processes, the eddy diffusivity parameters for heat and momentum, to be used in turbulence diffusion, are respectively defined in the TKE module as:\n\\begin{equation}\n  K_{H}=C_{Kh} \\tau_{v} \\overline{e}\n  \\label{diffusivity_heat}\n\\end{equation}\n%\n\\begin{equation}\n  K_{M}=C_{Km} \\tau_{v} \\overline{e}\n  \\label{diffusivity_momentum}\n\\end{equation}\n%\nwhere $C_{Kh}$ and $C_{Km}$ are tunable constants.  $C_{Kh}$ and $C_{Km}$ could be tuned independently, but as a starting point we set them equal to 0.1.  In equations~\\ref{diffusivity_heat} and~\\ref{diffusivity_momentum} $\\tau_{v}$ represents a damped return to isotropic timescale where $\\tau=2\\overline{e}/\\epsilon$ and\n%\n\\begin{equation}\n  \\tau_{v}=\\tau\\left[1+\\lambda_{0}N^{2}\\tau^{2}\\right]^{-1}\n  \\label{tauv}\n\\end{equation}\n% \nwhere $\\lambda_{0}=0$ if $N^{2} < 0$ and $\\epsilon$ is the turbulence dissipation rate (last term of equation~\\ref{sgstke}).  If $N^{2} > 0$ then $\\lambda_{0}$ is set as a ramp function in terms of the integrated column stability in the lower troposphere ($N_{\\infty}^{2}$): \n%\n\\begin{equation}\n  \\lambda_{0} = \\lambda_{min} + \\lambda_{slope}*(\\frac{N_{\\infty}^{2}}{g} - N_{low}), \n  \\label{lambda0}\n\\end{equation}\n% \n%\n\\begin{equation}\n  N_{\\infty}^{2} = \\int_{1000 hPa}^{800 hPa} N^{2} dz . \n  \\label{int_N}\n\\end{equation}\n%\n\nWhere $\\lambda_{min} = 0.001$, $\\lambda_{slope}$ = 0.35, and $N_{low}$ = 0.037.  Here, $\\lambda_{slope}$ is an adjustable parameter.  $\\lambda_{0}$ has a minimum threshold of 0.001 and a maximum threshold of 0.04.   \n\n\\paragraph{Stable Boundary Layer}\n\nFor the case of a moderate to very stable boundary layer, the formulation of the eddy diffusivities are revised to promote sufficient mixing, as they are based primarily on turbulence shear production, and prevent runaway cooling.  We use the dimensionless Obukov length, $z/L$ to determine when to trigger the stable boundary layer eddy diffusivities, where $z$ is the height of the lowest mid-point grid height and L the Monin-Obukhov length defined as\n%\n\\begin{equation}\n  L=-\\frac{u_{*}^{3}\\overline{\\theta_{v}}}{kg\\left(\\overline{w^{'}\\theta^{'}_{v}}\\right)_{s}}. \n  \\label{monin}\n\\end{equation}\n%\nThe stable boundary layer formulation for the eddy diffusivities triggers when $z/L$ is greater than 100, which signifies a moderately or very stable boundary layer.  These stable boundary layer diffusivities are applied for the PBL depth within this column and are defined as:\n%\n\\begin{equation}\n  K_{H}=C_{Khs} L^{2} S\n  \\label{stable_diffusivity_heat}\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n  K_{M}=C_{Kms} L^{2} S , \n  \\label{stable_diffusivity_momentum}\n\\end{equation}\n%\nwhere $C_{Khs}$ and $C_{Kms}$ are the stable boundary eddy coefficients for heat and momentum, respectively.  By default these values are set to 1. \n \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% TURBULENCE DIFFUSION\n\\subsection{Turbulence Diffusion}\n\\label{turb_diffusion}\n\nThe prognostic variables for SHOC (table~\\ref{table:prognostic}) are updated due to turbulence diffusion via:\n%\n\\begin{equation}\n  \\frac{\\partial{\\overline{\\chi}}}{\\partial{t}}= - \\frac{\\partial{\\overline{w^{'}\\chi^{'}}}}{\\partial{z}} . \n  \\label{turb_gov}\n\\end{equation}\n%\nWhere $\\chi$ represents any of SHOC's prognostic variables ($\\theta_{l}$, $q_{t}$, $u$, $v$, $e$, or $c$).  SHOC uses downgradient diffusion to represent the vertical flux of turbulence using:\n%\n\\begin{equation}\n  \\overline{w^{'}\\chi^{'}} = -K_{\\chi}\\frac{\\partial{\\chi}}{\\partial{z}}, \n  \\label{vert_diffusion}\n\\end{equation}\n%\nwhere $K_{\\chi}$ represents either $K_{H}$ or $K_{M}$.   \n\nTo preserve numerical stability equations~\\ref{turb_gov} and~\\ref{vert_diffusion} are solved using an implicit backward Euler scheme for the diffusion of $\\theta_{l}$, $q_{t}$, $u$, $v$, $e$, or $c$.  Given an input state $\\chi^{*}$ and diffusivity profile:\n%\n\\begin{equation}\n  \\frac{\\chi(t+\\Delta{t}) - \\chi^{*}}{\\Delta{t}} = \\frac{\\partial}{\\partial{z}}\\left(K_{\\chi}(z)\\frac{\\partial}{\\partial{z}}\\chi(t+\\Delta{t})\\right) . \n  \\label{euler_step}\n\\end{equation}\n%\nIn SHOC the surface fluxes for heat, moisture, TKE, and tracers are explicitly deposited into the lowest model layer and then implicit diffusion is performed.  For TKE the bottom surface flux is defined as \n\\begin{equation}\n  u_{*}^{3} = max(\\sqrt((\\overline{u^{'}w^{'}}_{sfc}+\\overline{v^{'}w^{'}}_{sfc})^{0.5}),0.01) . \n  \\label{ustar_tke}\n\\end{equation}\n\nHowever, the method of explicit surface fluxes results in a numerically unstable solution for momentum since such explicit adding can flip the direction of the lowest model layer wind ($\\overline{u}_{s}^{*}$, $\\overline{v}_{s}^{*}$), especially when the lowest model layer is thin.    Thus, the surface momentum fluxes ($\\tau_{x}^{*}$ = $\\overline{u^{'}w^{'}}_{s}$,$\\tau_{y}^{*}$ = $\\overline{v^{'}w^{'}}_{s}$) in SHOC are added in an implicit way.  This is done by computing the total momentum surface stress and applying this as a boundary condition in equation~\\ref{euler_step}: \n%\n\\begin{equation}\n  k_{tot} = max[\\sqrt((\\tau_{x}^{*})^{2}+(\\tau_{y}^{*})^{2}) /max(\\sqrt((\\overline{u}_{s}^{*})^{2}+(\\overline{u}_{s}^{*})^{2}),1),10^{-4}] . \n  \\label{k_tot}\n\\end{equation}\n%\nThe procedure for the solution of the implicit equation~\\ref{euler_step} follows that of \\cite{Richtmyer_Morton67} pages 198-200.  \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% SECOND ORDER MOMENTS\n\\subsection{Diagnosis of Second Order Moments}\n\\label{diag_second}\n\nIn order to close the assumed PDF (section~\\ref{assumed_pdf}) we need to diagnose several second order moments.  Namely, we need to determine, $\\overline{w^{'}\\theta_{l}^{'}}$, $\\overline{w^{'}q_{t}^{'}}$, $\\overline{q_{w}^{'}\\theta_{l}^{'}}$, $\\overline{q_{t}^{'2}}$, $\\overline{\\theta_{l}^{'2}}$, and $\\overline{q_{w}^{'}\\theta_{l}^{'}}$. \n\nThe expression we use to determine $\\overline{w^{'}\\theta_{l}^{'}}$ and $\\overline{w^{'}q_{t}^{'}}$ is based on downgradient diffusion as:\n%\n\\begin{equation}\n \\begin{split}\n    \\overline{w^{'}C^{'}}=-K_{H}\\frac{\\partial{\\overline{C}}}{\\partial{z}} \\\\\n  \\end{split}\n  \\label{downgradient4}\n\\end{equation}\n%   \nwhere $C$ is interchanged for $\\theta_{l}$ and $q_{t}$.  \n\nFor the scalar variances and covariances, SHOC diagnoses these terms as:\n%\n\\begin{equation}\n  \\overline{q_{t}^{'2}}=C_{q_{t}}S_{m}\\left(\\frac{\\partial{\\overline{q_{t}}}}{\\partial{z}}\\right)^{2}\n  \\label{bogen_qw2}\n\\end{equation}\n%  \n\\begin{equation}\n  \\overline{\\theta_{l}^{'2}}=C_{\\theta_{l}}S_{m}\\left(\\frac{\\partial{\\overline{\\theta_{l}}}}{\\partial{z}}\\right)^{2}\n  \\label{bogen_thl2}\n\\end{equation}\n%  \n\\begin{equation}\n  \\overline{q_{t}^{'}\\theta_{l}^{'}}=C_{q_{t}\\theta_{l}}S_{m}\\frac{\\partial{\\overline{q_{t}}}}{\\partial{z}}\\frac{\\partial{\\overline{\\theta_{l}}}}{\\partial{z}} , \n  \\label{bogen_qwhl2}\n\\end{equation}\n%  \nwhere $S_{m}=\\tau_{v} K_{H}$.  $C_{q_{t}}$, $C_{\\theta_{l}}$, and $C_{q_{t}\\theta_{l}}$ are tunable coefficients to adjust the strength of diagnosed variances and covariances.  Default setting for these coefficients are $C_{q_{t}}$, $C_{\\theta_{l}}$, and $C_{q_{t}\\theta_{l}}= 1.0$.\n\nNote that $\\overline{w^{'}\\theta_{l}^{'}}$, $\\overline{w^{'}q_{t}^{'}}$, $\\overline{q_{w}^{'}\\theta_{l}^{'}}$, $\\overline{q_{t}^{'2}}$, $\\overline{\\theta_{l}^{'2}}$, and $\\overline{q_{t}^{'}\\theta_{l}^{'}}$ are all computed on the interface grid.  Thus, before the computation of these terms $K_{H}$ and $\\tau_{v}$ are linearly interpolated to the interface grid.   \n\nThe expression for $\\overline{w^{'2}}$ is:\n%\n\\begin{equation}\n  \\overline{w^{'2}}=\\frac{2}{3}\\overline{e}\n  \\label{w2_param_2}\n\\end{equation}\n%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% THIRD MOMENT OF VERTICAL VELOCITY\n\\subsection{Third Moment of Vertical Velocity}\n\\label{diag_third}\n\nThe final term needed to close the assumed PDF is the third order moment of vertical velocity ($\\overline{w^{'3}}$), which is parameterized following that of \\citep{Canuto_et01}. \\cite{Canuto_et01} provides expressions for several third-order moments, but we are only interested in $\\overline{w^{'3}}$.  \n\nThe expressions provided by \\cite{Canuto_et01} were originally derived for the dry convective boundary layer and we simply replace potential temperature with liquid water potential temperature ($\\overline{\\theta_{l}}$) to make the expressions valid in moist convection. The original dynamic equations for the third order moment can be found in \\cite{Canuto_92} and these equations entail fourth-order moments that can be written as\n%\n\\begin{equation}\n  \\overline{a^{'}b^{'}c^{'}d^{'}}=\\left(\\overline{a^{'}b^{'}}\\hspace{0.1cm}\\overline{c^{'}d^{'}}+\\overline{a^{'}c^{'}}\\hspace{0.1cm}\\overline{b^{'}d^{'}}+\\overline{a^{'}d^{'}}\\hspace{0.1cm}\\overline{b^{'}c^{'}}\\right)F . \n  \\label{fourth}\n\\end{equation}\n%\nIf function $F$ is taken to be unity then the above expression reduces to the quasi-normal approximation.  This was done in \\cite{Canuto_et94} but the results of some of their third-order moments were not satisfactory when compared to LES data.   \n\nThe expression for $\\overline{w^{'3}}$ is as follows:\n%\n\\begin{equation}\n\\overline{w^{'3}}=\\left(\\Omega_{1}-1.2X_{1}-\\frac{3}{2}f_{5}\\right)\\left(c-1.2X_{0}+\\Omega_{0}\\right)^{-1},\n  \\label{w3_z}\n\\end{equation}\n%\nwith the functions $X$ and $\\Omega_{0}$ defined as\n%\n\\begin{equation}\n  \\label{Xomega_func}\n  \\begin{split}\n    X_{0}=\\gamma_{2}\\tilde{N}^{2}\\left(1-\\gamma_{3}\\tilde{N}^{2}\\right)\\left[1-\\left(\\gamma_{1}+\\gamma_{3}\\right)\\tilde{N}^{2}\\right]^{-1}\\\\\n    X_{1}=\\left[\\gamma_{0}f_{0}+\\gamma_{1}f_{1}+\\gamma_{2}\\left(1-\\gamma_{3}\\tilde{N}^{2}\\right)f_{2}\\right]\\left[1-\\left(\\gamma_{1}+\\gamma_{3}\\right)\\tilde{N}^{2}\\right]^{-1}\\\\\n    \\Omega_{0}=\\omega_{0}X_{0}+\\omega_{1}Y_{0}\\\\\n    \\Omega_{1}=\\omega_{o}X_{1}+\\omega_{1}Y_{1}+\\omega_{2}.\n  \\end{split}\n\\end{equation}\n%\nThe $\\omega$ function's are given by\n%\n\\begin{equation}\n  \\label{omegas}\n  \\begin{split}\n  \\omega_{0}=\\gamma_{4}\\left(1-\\gamma_{5}\\tilde{N}^{2}\\right)^{-1}\\\\\n  \\omega_{1}=\\left(2c\\right)^{-1}\\omega_{0}\\\\\n  \\omega_{2}=\\omega_{1}f_{3}+\\frac{5}{4}\\omega_{0}f_{4}.\n  \\end{split}\n\\end{equation}\n%\nThe $\\gamma$'s are constants which depend on the adjustable parameter $c$.  Canuto et al. (2001) and previous work found that $c=7$, although small variations are allowed.  The $\\gamma$ constants are given by:\n%\n\\begin{equation}\n  \\label{gammas}\n  \\begin{split}\n  \\gamma_{0}=0.52c^{-2}\\left(c-2\\right)^{-1}\\\\\n  \\gamma_{1}=0.87c^{-2}\\\\\n  \\gamma_{2}=0.5c^{-1}\\\\\n  \\gamma_{3}=0.60c^{-1}\\left(c-2\\right)^{-1}\\\\\n  \\gamma_{4}=2.4\\left(3c+5\\right)^{-1}\\\\\n  \\gamma_{5}=0.6c^{-1}\\left(3c+5\\right)^{-1}.\n  \\end{split}\n\\end{equation}\n%\nFinally, the functions are introduced which incorporate the second-order moments of $\\overline{w^{'2}}$, $\\overline{w^{'}\\theta_{l}^{'}}$, $\\overline{\\theta_{l}^{'}}$, and $\\overline{e}$.  These are defined as follows:\n%\n\\begin{equation}\n  \\label{f_functions}\n  \\begin{split}\n  f_{0}=\\left(g\\alpha\\right)^{3}\\tau_{v}^{4}\\overline{w^{'}\\theta_{l}^{'}}\\frac{\\partial{\\overline{\\theta_{l}^{'2}}}}{\\partial{z}}\\\\\n  f_{1}=\\left(g\\alpha\\right)^{2}\\tau_{v}^{3}\\left(\\overline{w^{'}\\theta_{l}^{'}}\\frac{\\partial{\\overline{w^{'}\\theta_{l}^{'}}}}{\\partial{z}}+\\frac{1}{2}\\overline{w^{'2}}\\frac{\\partial{\\overline{\\theta_{l}^{'}}}}{\\partial{z}}\\right)\\\\\n  f_{2}=g\\alpha\\tau_{v}^{2}\\overline{w^{'}\\theta_{l}^{'}}\\frac{\\partial{\\overline{w^{'2}}}}{\\partial{z}}+2g\\alpha\\tau_{v}^{2}\\overline{w^{'2}}\\frac{\\partial{\\overline{w^{'}\\theta_{l}^{'}}}}{\\partial{z}}\\\\\n  f_{3}=g\\alpha\\tau_{v}^{2}\\left(\\overline{w^{'2}}\\frac{\\partial{\\overline{w^{'}\\theta_{l}^{'}}}}{\\partial{z}}+\\overline{w^{'}\\theta_{l}^{'}}\\frac{\\partial{\\overline{e}}}{\\partial{z}}\\right)\\\\\n  f_{4}=\\tau_{v}\\overline{w^{'2}}\\left(\\frac{\\partial{\\overline{w^{'2}}}}{\\partial{z}}+\\frac{\\partial{\\overline{e}}}{\\partial{z}}\\right)\\\\\n  f_{5}=\\tau_{v}\\overline{w^{'2}}\\frac{\\partial{\\overline{w^{'2}}}}{\\partial{z}}.\n  \\end{split}\n\\end{equation}\n%\nAll of the above $f$ functions have the dimensions of velocity cubed.  In addition, we define $\\tilde{N}^{2}=\\tau_{v}^{2}N^{2}$.\n\nOnce $\\overline{w^{'3}}$ is determined we perform clipping to ensure that this calculation does not produce unrealistically large values.  $\\mid\\overline{w^{'3}}\\mid$ is constrained by $ w3_{clip} \\sqrt{2.0 \\overline{w^{'2}}} $.  Where $w3_{clip}$ is an adjustable parameter with a default value of 1.2.   \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% ASSUMED PDF\n\\subsection{Assumed PDF}\n\\label{assumed_pdf}\n%\nHere details of the Analytic Double Gaussian (ADG) 1 PDF (as referred to in \\cite{Larson_et02}, which is the PDF used in SHOC, are presented.  The input moments for this PDF are $\\overline{\\theta_{l}}$, $\\overline{q_{t}}$, $\\overline{w^{'2}}$, $\\overline{w^{'}\\theta_{l}^{'}}$, $\\overline{w^{'}q_{t}^{'}}$, $\\overline{q_{w}^{'}\\theta_{l}^{'}}$, $\\overline{q_{t}^{'2}}$, $\\overline{\\theta_{l}^{'2}}$, $\\overline{q_{w}^{'}\\theta_{l}^{'}}$, and $\\overline{w^{'3}}$.  Note that at the beginning of this module $\\overline{w^{'}\\theta_{l}^{'}}$, $\\overline{w^{'}q_{t}^{'}}$, $\\overline{q_{w}^{'}\\theta_{l}^{'}}$, $\\overline{q_{t}^{'2}}$, $\\overline{\\theta_{l}^{'2}}$, $\\overline{w^{'3}}$ are interpolated to the mid-point grid.  \n\nThis PDF, as the name suggests, is based on the double Gaussian form as\n%\n\\begin{equation}\n  P_{adg1}(w^{'},\\theta_{l}^{'},q_{t}^{'})=aG_{1}(w^{'},\\theta_{l}^{'},q_{t}^{'})+(1-a)G_{2}(w^{'},\\theta_{l}^{'},q_{t}^{'}).\n  \\label{adg1}\n\\end{equation}\n%\nHere $G_{1}$ and $G_{2}$ are the individual Gaussians and the parameters for the ADG 1 can be found analytically.  To do this, some assumptions have to be made.  The first assumption is that the subplume variations in $w$ are uncorrelated with those in $q_{t}$ and $\\theta_{l}$.  Letting $i$ = 1 or 2, the individual Gaussians in equation~\\ref{adg1} are then given by\n%\n\\begin{equation}\n  \\label{ind_gaus}\n  \\begin{split}\n    G_{i}(w^{'},\\theta_{l}^{'},q_{t}^{'})=\\frac{1}{(2\\pi)^{3/2}\\sigma_{wi}\\sigma_{q_{t}i}\\sigma_{\\theta_{l}i}(1-r_{q_{t}\\theta_{l}i}^{2})^{1/2}}\\exp\\left[-\\frac{1}{2}\\left(\\frac{w^{'}-(w_{i}-\\overline{w})}{\\sigma_{wi}}\\right)^{2}\\right] \\\\\n    \\times \\exp\\left(-\\frac{1}{2(1-r_{q_{t}\\theta_{l}i}^{2})}\\left\\{\\left[\\frac{q_{t}^{'}-(q_{ti}-\\overline{q_{t}})}{\\sigma_{q_{t}i}}\\right]^{2}+\\left[\\frac{\\theta_{l}^{'}-(\\theta_{li}-\\overline{\\theta_{l}})}{\\sigma_{\\theta_{l}i}}\\right]^{2} \\right. \\right. \\\\\n    -\\left.\\left.2r_{q_{t}\\theta_{l}i}\\left[\\frac{q_{t}^{'}-(q_{ti}-\\overline{q_{t}})}{\\sigma_{q_{t}i}}\\right]\\left[\\frac{\\theta_{l}^{'}-(\\theta_{li}-\\overline{\\theta_{l}})}{\\sigma_{\\theta_{l}i}}\\right]\\right\\}\\right).\n  \\end{split}\n\\end{equation}\n%\nNow we must define the PDF parameters.  The PDF parameters are based on the equations of \\cite{Lewellen_Yoh93} and are found by integrating over the 12 relevant input moments over the double Gaussian PDF.  Four of these equations are (the rest are analogous):\n%\n\\begin{eqnarray}\n%  \\begin{split}\n    \\overline{w} &=& aw_{1}+(1-a)w_{2}  \\label{mom_equations} \\\\\n    \\overline{w^{'2}} &=& a[(w_{1}-\\overline{w})^{2}+\\sigma_{w1}^{2}]+(1-a)[(w_{2}-\\overline{w})^{2}+\\sigma_{w2}^{2}] \\nonumber \\\\\n    \\overline{w^{'3}} &=& a[(w_{1}-\\overline{w})^{3}+3(w_{1}-\\overline{w})\\sigma_{w1}^{2}]+(1-a)[(w_{2}-\\overline{w})^{3}+3(w_{2}-\\overline{w})\\sigma_{w2}^{2}] \\nonumber \\\\\n    \\overline{w^{'}q_{t}^{'}} &=& a[(w_{1}-\\overline{w})(q_{t1}-\\overline{q_{t}})+r_{wq_{t}1}\\sigma_{w1}\\sigma_{q_{t1}}]+(1-a)[(w_{2}-\\overline{w})(q_{t2}-\\overline{q_{t}})+r_{wq_{t}2}\\sigma_{w2}\\sigma_{q_{t2}}]. \\nonumber\n%  \\end{split}\n\\end{eqnarray}\n%\nwith the relative amplitude of the Gaussian $a$ is defined as\n%\n\\begin{equation}\n  a=\\frac{1}{2}\\left\\{1-Sk_{w}\\left[\\frac{1}{4(1-\\tilde{\\sigma}_{w}^{2})^{3}+Sk_{w}^{2}}\\right]^{1/2}\\right\\}.\n  \\label{adg_a}\n\\end{equation}\n%\nThis is obtained by assuming that the standard deviations of the two Gaussians are equal in $w$ and integrating over the PDF.  Here $Sk_{w}\\equiv \\overline{w^{'3}}/(\\overline{w^{'2}}^{3/2})$, represents the skewness of vertical velocity.  In the case of $\\overline{w^{'2}}$=0 it is assumed that the PDF reduces to a single delta function.  The parameters for $w_{1}$ and $w_{2}$ are given by:\n%\n\\begin{equation}\n  \\tilde{w}_{1}\\equiv\\frac{w_{1}-\\overline{w}}{\\sqrt[]{\\overline{w^{'2}}}}=\\left(\\frac{1-a}{a}\\right)^{1/2}(1-\\tilde{\\sigma}_{w}^{2})^{1/2}\n  \\label{tildew_1}\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n  \\tilde{w}_{2}\\equiv\\frac{w_{2}-\\overline{w}}{\\sqrt[]{\\overline{w^{'2}}}}=\\left(\\frac{a}{1-a}\\right)^{1/2}(1-\\tilde{\\sigma}_{w}^{2})^{1/2} . \n  \\label{tildew_2}\n\\end{equation}\n%\nTo avoid numerical instabilities in the model a threshold for $a$ must be defined as 0.01 $\\le$ $a$ $\\le$ 0.99.  We also have the definitions of $\\tilde{\\sigma}_{w}\\equiv\\sigma_{w1}/ \\sqrt[]{\\overline{w^{'2}}} = \\sigma_{w2}/\\sqrt[]{\\overline{w^{'2}}}$ and $\\tilde{\\sigma}_{w}^{2}=0.4$.  \n\nNow to define terms for $\\theta_{l1}$ and $\\theta_{l2}$ we get:\n%\n\\begin{equation}\n  \\tilde{\\theta}_{l1}\\equiv\\frac{\\theta_{l1}-\\overline{\\theta_{l}}}{\\sqrt[]{\\overline{\\theta_{l}^{'2}}}}=-\\frac{\\overline{w^{'}\\theta_{l}^{'}}/(\\sqrt[]{\\overline{w^{'2}}}\\sqrt[]{\\overline{\\theta_{l}^{'2}}})}{\\tilde{w}_{2}}\n  \\label{tildethl_1}\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n  \\tilde{\\theta}_{l2}\\equiv\\frac{\\theta_{l2}-\\overline{\\theta_{l}}}{\\sqrt[]{\\overline{\\theta_{l}^{'2}}}}=-\\frac{\\overline{w^{'}\\theta_{l}^{'}}/(\\sqrt[]{\\overline{w^{'2}}}\\sqrt[]{\\overline{\\theta_{l}^{'2}}})}{\\tilde{w}_{1}} .  \n  \\label{tildethl_2}\n\\end{equation}\n%\nShould there be no variability in $\\theta_{l}$ then the means of the Gaussians are set equal so that $\\theta_{l1}$ = $\\theta_{l2}$ = $\\overline{\\theta_{l}}$ and the widths of the Gaussians in the $\\theta_{l}$ direction are set to zero.  \n\nUnlike vertical velocity, the widths in the $\\theta_{l}$ direction are allowed to differ.  These are found by integrating over the PDF and defined as:\n%\n\\begin{equation}\n  \\frac{\\sigma_{\\theta_{l}1}^{2}}{\\overline{\\theta_{l}^{'2}}}=\\frac{3\\tilde{\\theta}_{l2}[1-a\\tilde{\\theta}_{l1}^{2}-(1-a)\\tilde{\\theta}_{l2}^{2}]-[Sk_{\\theta_{l}}-a\\tilde{\\theta}_{l1}^{3}-(1-a)\\tilde{\\theta}_{l2}^{3}]}{3a(\\tilde{\\theta}_{l2}-\\tilde{\\theta}_{l1})}\n  \\label{sig_thl1}\n\\end{equation}\n%\nand\n%\n\\begin{equation}\n    \\frac{\\sigma_{\\theta_{l}2}^{2}}{\\overline{\\theta_{l}^{'2}}}=\\frac{3\\tilde{\\theta}_{l1}[1-a\\tilde{\\theta}_{l1}^{2}-(1-a)\\tilde{\\theta}_{l2}^{2}]-[Sk_{\\theta_{l}}-a\\tilde{\\theta}_{l1}^{3}-(1-a)\\tilde{\\theta}_{l2}^{3}]}{3(1-a)(\\tilde{\\theta}_{l2}-\\tilde{\\theta}_{l1})}.\n  \\label{sig_thl2}\n\\end{equation}\n%\nTo prevent unrealistic solutions the following condition is set\n%\n\\begin{equation}\n  0 \\le \\frac{\\sigma_{\\theta_{l}1,2}^{2}}{\\overline{\\theta_{l}^{'2}}} \\le 100.\n  \\label{cond}\n\\end{equation}\n%  \nAnalogous equations are used to find $\\tilde{q}_{t1,2}$ and $\\sigma_{qt1,2}^{2}$.  \n\nThe equations above make clear that SHOC is dependent on the skewness of $\\theta_{l}$ and $q_{t}$.  For the ADG 1 PDF, neither $\\overline{\\theta_{l}^{'3}}$ and $\\overline{q_{t}^{'3}}$ are input moments, therefore diagnostic assumptions must be made.  $Sk_{\\theta_{l}}$ is simply set to zero for the ADG 1 PDF as it is found that this value prevents numerical instabilities from being introduced.  To represent skewness in cumulus layers the following conditions are set for $Sk_{q_{t}}$:  When $|\\tilde{q}_{t2}-\\tilde{q}_{t1}| >$ 0.4 we set $Sk_{q_{t}}$ = 1.2$Sk_{w}$.  When $|\\tilde{q}_{t2}-\\tilde{q}_{t1}| \\le$ 0.2 we set $Sk_{q_{t}}$ = 0.  Between these two extremes $Sk_{q_{t}}$ is linearly interpolated.    \n\nThe within-plume correlations are computed by setting $r_{q_{t}\\theta_{l}1}$ = $r_{q_{t}\\theta_{l}2}$ and integrating over the PDF to obtain an equation for $\\overline{q_{t}^{'}\\theta_{l}^{'}}$ and hence: \n%\n\\begin{equation}\n  r_{q_{t}\\theta_{l}1,2}=\\frac{\\overline{q_{t}^{'}\\theta_{l}^{'}}-a(q_{t1}-\\overline{q_{t}})(\\theta_{l1}-\\overline{\\theta_{l}})-(1-a)(q_{t2}-\\overline{q_{t}})(\\theta_{l2}-\\overline{\\theta_{l}})}{a\\sigma_{q_{t}1}\\sigma_{\\theta_{l}1}+(1-a)\\sigma_{q_{t}2}\\sigma_{\\theta_{l2}}}\n \\label{corr_eq}\n\\end{equation}\n% \nwith the condition that\n%\n\\begin{equation}\n-1 \\le  r_{q_{t}\\theta_{l}1,2} \\le 1\n\\end{equation}\n%\nbecause correlations must lie between -1 and 1.  \n\nNow that we have defined the PDF parameters, we can now diagnose SGS cloud and turbulence terms.  Cloud fraction, liquid water content, and liquid water flux are all given by:\n%\n\\begin{eqnarray}\n  C &=& a(C)_{1}+(1-a)(C)_{2} \\label{turb_terms}\\\\\n  \\overline{q_{l}} &=& a(\\overline{q_{l}})_{1}+(1-a)(\\overline{q_{l}})_{2} \\nonumber \\\\\n  \\overline{w^{'}q_{l}^{'}} &=& a[(w_{1}-\\overline{w})(\\overline{q_{l}})+(\\overline{w^{'}q_{l}^{'}})_{1}]+(1-a)[(w_{2}-\\overline{w})(\\overline{q_{l}})_{2}+(\\overline{w^{'}q_{l}^{'}})_{2}] . \\nonumber\n\\end{eqnarray}\n%\nIn addition, the buoyancy flux can be closed using the expression:\n%\n\\begin{equation}\n  \\overline{w^{'}\\theta_{v}^{'}}=\\overline{w^{'}\\theta_{l}^{'}}+\\frac{1-\\epsilon_{o}}{\\epsilon_{o}}\\theta_{o}\\overline{w^{'}q_{t}^{'}}+\\left[\\frac{L_{v}}{c_{p}}\\left(\\frac{p_{o}}{p}\\right)^{R_{d}/c_{p}}-\\frac{1}{\\epsilon_{o}}\\theta_{o}\\right]\\overline{w^{'}q_{l}^{'}}\n  \\label{buoyancy}\n\\end{equation}\n%\nThe individual cloud fraction $C$ and mean specific liquid water content $\\overline{q_{l}}$ are calculated by linearizing the variability in $\\theta_{l}$ and $q_{t}$ (with analogous expressions for the Gaussian 1 and 2 for equations~\\ref{cld_fracadg} though~\\ref{wql_s}): \n%\n\\begin{equation}\n C=\\frac{1}{2}\\left[1+\\operatorname{erf}\\left(\\frac{s}{\\sqrt[]{2}\\sigma_{s}}\\right)\\right]\n  \\label{cld_fracadg}\n\\end{equation}\n% \nand\n% \n\\begin{equation}\n  \\overline{q_{l}}=sC+\\frac{\\sigma_{s}}{\\sqrt[]{2\\pi}}\\exp\\left[-\\frac{1}{2}\\left(\\frac{s}{\\sigma_{s}}\\right)^{2}\\right].\n  \\label{ql_adg}\n\\end{equation}\n%\nHere $\\operatorname{erf}$ is the error function and $\\sigma_{s}$ is the standard deviation of $s$, which is equal to the liquid water content when $s$ is greater than zero, but can also be negative and is conserved under condensation.  These two terms are defined as \\citep{Lewellen_Yoh93}:\n%\n\\begin{equation}\n  \\begin{split}\n    s=q_{t}-q_{s}(T_{l},p)\\frac{(1+\\beta q_{t})}{[1+\\beta q_{s}(T_{l},p)]}\\\\\n  \\sigma_{s}^{2}=c_{\\theta_{l}}^{2}\\sigma_{\\theta_{l}}^{2}+c_{q_{t}}^{2}\\sigma_{q_{t}}^{2}-2c_{\\theta_{l}}\\sigma_{\\theta_{l}}c_{q_{t}}\\sigma_{q_{t}}r_{q_{t}\\theta_{l}}\n  \\end{split}\n  \\label{sterms}\n\\end{equation}\n%\nwhere $q_{s}$ is the saturation mixing ratio with respect to either water or ice or a hybrid of the two depending on the temperature, and $\\beta$ is defined as:\n%\n\\begin{equation}\n  \\beta=\\beta(T_{l})=\\frac{R_{d}}{R_{v}}\\left(\\frac{L_{v}}{R_{d}T_{l}}\\right)\\left(\\frac{L_{v}}{c_{p}T_{l}}\\right).\n  \\label{beta_equation}\n\\end{equation}\n%\nAlso defined are the following terms:\n%\n\\begin{equation}\n  c_{q_{t}}=\\frac{1}{1+\\beta (T_{l})q_{s}(\\overline{T_{l}},p)}\\\\\n  \\label{cqt_term}\n\\end{equation}\n%\nand\n%\n\\begin{equation}  \n  c_{\\theta_{l}}=\\frac{1+ \\beta (\\overline{T_{l}})\\overline{q_{t}}}{[1+\\beta (\\overline{T_{l}})q_{s}(\\overline{T_{l}},p)]^{2}}\\frac{c_{p}}{L_{v}}\\beta (\\overline{T_{l}}) q_{s}(\\overline{T_{l}},p)\\left(\\frac{p}{p_{o}}\\right)^{R_{d}/C_{p}}\n  \\label{cthl_term}\n\\end{equation}\n%\nFinally, the flux of liquid water is given by:\n%\n\\begin{equation}\n  \\overline{w^{'}q_{l}^{'}}=C\\overline{w^{'}s^{'}}\n  \\label{wql_equation}\n\\end{equation}\n%\nwhere\n%\n\\begin{equation}\n  \\overline{w^{'}s^{'}}=c_{q_{t}}\\sigma_{w}\\sigma_{q_{t}}r_{wq_{t}}-c_{\\theta_{l}}\\sigma_{w}\\sigma_{\\theta_{l}}r_{w\\theta_{l}} .\n  \\label{wql_s}\n\\end{equation}\n% \nIn the above expressions $q_{s}$ is defined as:\n%\n\\begin{equation}\n  q_s (T_{l},P) = \\frac{R_{d}}{R_{v}}\\frac{e_{s}(T_{l})}{p-[1-(R_{d}/R_{v})]e_{s}(T_{l})}.\n  \\label{qs_equation}\n\\end{equation}\n%\nHere $q_{s}$ is the saturation specific humidity, $e_{s}$ is the saturation vapor pressure over liquid, $p$ is pressure, $c_{p}$ is the specific heat at constant pressure, and $R_{d}$ and $R_{v}$ are the gas constants for dry air and water vapor.  In addition, we define $T_{l}$ as the liquid water temperature:\n%\n\\begin{equation}\n  T_{l} = T - \\frac{L_{v}}{c_{p}}q_{l}\n  \\label{T_liq}\n\\end{equation}\n% \nwhere $T$ is temperature.  In SHOC, $e_{s}$ is computed based on \\cite{Flatau_et92}.  \n\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% IMPLICIT DIFFUSION NUMERICS\n", "meta": {"hexsha": "66ae8b7baaccf5921f057c719a74af2e1dab5622", "size": 36669, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "components/scream/docs/physics/shoc/shoc_doc.tex", "max_stars_repo_name": "ambrad/scream", "max_stars_repo_head_hexsha": "52da60f65e870b8a3994bdbf4a6022fdcac7cab5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "components/scream/docs/physics/shoc/shoc_doc.tex", "max_issues_repo_name": "ambrad/scream", "max_issues_repo_head_hexsha": "52da60f65e870b8a3994bdbf4a6022fdcac7cab5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "components/scream/docs/physics/shoc/shoc_doc.tex", "max_forks_repo_name": "ambrad/scream", "max_forks_repo_head_hexsha": "52da60f65e870b8a3994bdbf4a6022fdcac7cab5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.3901273885, "max_line_length": 723, "alphanum_fraction": 0.6563309608, "num_tokens": 12683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4230970536380349}}
{"text": "\\vssub\n\\subsection{~The \\ws\\ Modeling Framework}\n\\vssub\n\n\\ww\\ is a community wave modeling framework that includes the latest scientific advancements in the field of \nwind-wave modeling and dynamics.\n\nThe core of the framework consists of the \\ws\\ third-generation wave model, developed at the \nUS National Centers for Environmental Prediction (NOAA/NCEP) in the spirit of the WAM model \\citep{bk:WAM94}. \nThe current framework evolved from earlier WAVEWATCH I \\& II model packages \\citep{tol:JPO91b, tol:JPO92}, and differs from its predecessors \nin many important points such as governing equations, model structure, numerical methods and physical parameterizations.\n\n\\ws\\ solves the random phase spectral action density balance equation for wavenumber-direction spectra. The implicit \nassumption of this equation is that properties of medium (water depth and current) as well as the wave field itself \nvary on time and space scales that are much larger than the variation scales of a single wave. The model includes options \nfor shallow-water (surf zone) applications, as well as wetting and drying of grid points. Propagation of a wave spectrum \ncan be solved using regular (rectilinear or curvilinear) and unstructured (triangular) grids, individually or combined into\nmulti-grid mosaics.\n\nSource terms for physical processes (source terms) include parameterizations for wave growth due to the actions of wind, exact and parametrized \nforms accounting for nonlinear resonant wave-wave interactions, scattering due to wave-bottom interactions, triad interactions, \nand dissipation due to whitecapping, bottom friction, surf-breaking, and interactions with mud and ice. The model includes several \nalleviation methods for the Garden Sprinkler Effect, and computes other transofrmation processes\nsuch as the effects of surface currents to wind and wave fields, and sub-grid blocking due to unresolved islands. \n\nInputs to \\ws\\ may be provided via external files or via coupling using the OASIS or ESMF/NUOPC frameworks. Input data is\ndynamically updated within the wave model driver, and may include ice coverage, mud, current fields, bottom properties for dissipation \non a moveable bed, and data for assimilation within a data assimilation placeholder module that may be developed by users.\n\n\\ws\\ is written in ANSI standard FORTRAN 90, fully modular and fully allocatable. The model is set up for traditional one-way nesting, \nand also using a `mosaic' or multiple-grid approach, where an arbitrary number of grids can be considered with full two-way interactions \nbetween all grids. Individual or multi-grid mosaics can be used as moving frame of reference that allows high-resolution \nmodeling of hurricanes away from the coast. \n\nWave energy spectra are discretized using a constant directional increment (covering all directions), and a spatially varying wavenumber grid.  \nFirst-, second- and third-order accurate numerical schemes are available to describe wave propagation. Source terms are integrated \nin time using a dynamically adjusted time stepping algorithm, which concentrates computational efforts in conditions with rapid spectral \nchanges. \\ws\\ can optionally be compiled to include shared memory parallelisms using OpenMP compiler directives, \nand/or for a distributed memory environment using the Message Passing Interface.\n\n\n\n\n%, spectral partitioning is now available for post-processing of\n%        point output, or for the entire wave model grid using the Vincent and Soille\n%        (1991) algorithm (Hanson and Jenssen, 2004; Hanson <I> et al </I>, 2006,\n%        2009).  <span style=\"COLOR:#007f00;\"> New in model version 3.14</span> </li>\n", "meta": {"hexsha": "c2dde397d5736596892b98a7fe7cf524ceb23ad6", "size": 3671, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/intro/ww3.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/intro/ww3.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/intro/ww3.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 76.4791666667, "max_line_length": 144, "alphanum_fraction": 0.8016889131, "num_tokens": 781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4230970536380348}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{September 8, 2014}\n\\maketitle\n\\section*{exercises}\nsecond part of chinese remainder theorem\nSection 1.3: exercises \\# 4, 6, 12, 18, 20, 24.\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item\n\\begin{align*}\n  20x\\equiv12\\mod 72\\\\\n  \\gcd(20,12)=4\\\\\n  4|12\\\\\n  ax=b+qn\\\\\n  20x=12+q72\n  20=4a_1,12=4b_1,72=4m\\\\\n  a_1x=b_1=qm\\\\\n  a_1x\\equiv b_1\\mod m\\\\\n  5x\\equiv 3\\mod 18\\\\\n  ca_1\\equiv1\\mod m\\\\\n  c5\\equiv1\\mod 18\\\\\n  55=18*3+1\\\\\n\\end{align*}\n\\setcounter{enumi}{23}\n\\item\nclaim:remainder of integer when divided by 9. \n\nproof:\n\\begin{align*}\n  n_0\\equiv r\\mod 9\\\\\n  n_0=10^na_n+10^{n-1}a_{n-1}+\\dots+a_0\\\\\n  a\\equiv b\\mod n\\\\\n  c\\equiv d\\mod n\\\\\n  ac\\equiv bd\\mod n\\\\\n  a\\equiv b\\mod n\\to a^k\\equiv b^k\\mod n\\\\\n  10\\equiv1\\mod 9\\\\\n  10^k\\equiv 1\\mod 9\\\\\n  n_0\\equiv a_n+a_{n-1}+\\dots+a_0\\mod 9\n\\end{align*}\nsimilar to 25\n\\end{enumerate}\n\\section*{section 2.1}\n$f:S\\longrightarrow T$ and $S$ is domain, $T$ is codomain.\n\n$f':S'\\longrightarrow T'$\n\n$f=f'\\Leftrightarrow S=S',T=T'$ and $f(x)=f'(x)\\forall x\\in S$\n\nThe image of $f$ is $f(s)=\\{f(t)|x\\in S\\}$\n\n\\section*{example}\n\\begin{align*}\n  f:R\\to R\\\\\n  f(x)=x^2\\\\\n  \\text{Im} f=f(R)=[0,\\infty)\n\\end{align*}\none to one (injective functions) $f:S\\to T$ $f(x_1)=f(x_2)\\Rightarrow x_1=x_2$\n\nonto (surjective) $f:S\\to T$ $f(S)=T$\n\none to one correspondences (bijective) satisfy both  injective and surjective (one-to-one and onto)\n\ninverse function $f:S\\to  T$ $f^{-1}:T\\to S$. $f(f^{-1}(x))=x\\forall x\\in T$ and $f^{-1}(f(x))=x\\forall x\\in S$. defined iff $f$ is bijective\n\\section*{section 2.2 equivalence relations}\n$S$ set\n\nan equivalence relation is a subset $R\\subseteq S\\times S$ with the properties\n\\begin{enumerate}\n\\item\nfor all $x\\in S$ we have that $(x,x)\\in R$\n\\item\n$\\forall x,y\\in S$ if $(x,y)\\in R$ then $(y,x)\\in R$\n\\item\n$\\forall x,y,z\\in S$ if $(x,y)\\in R$ and $(y,z)\\in R$ then $(x,z)\\in R$\n\\end{enumerate}\n\\subsection*{notation}\nwe write $a\\sim{ }b$ to indicate that $a,b\\in R$\n\\subsection*{example}\n\\begin{align*}\n  S=\\mathbb{Z}\\\\\n  n\\in\\mathbb{Z}\\\\\n  n>0\\\\\n  \\intertext{we say  that $x\\sim y$ iff}\n  x\\equiv y\\mod n\n\\end{align*}\n\\subsection*{example}\n\\begin{align*}\n  S=\\mathbb{R}\n\\end{align*}\n$x\\sim y$ iff $x+y\\ge 0$. is this equivalence? no $x+x$ might be negative\n\\subsection*{example}\n\\begin{align*}\n  S=[0,\\infty)\n\\end{align*}\n$x\\sim y$ iff $x+y\\ge 0$. is this equivalence? yes\n\n\\subsubsection*{note}\nequality  is always equivalence relation, the trivial case\n\n\\section*{equivalence class}\n$S$ is a set and $~$ is and equivalence relation. let $a\\in S$, $[a]=\\{x\\in S|a\\sim x\\}$ where $[a]$ is equivalence class of $a$. $S/\\sim$ is the set of all equivalence classes\n\\subsection*{example}\n$S=\\mathbb{Z}$ and $\\sim$ is the congruence modulo n, then the set $\\mathbb{Z}/\\sim$ has $n$ elements: $[0],[1],\\dots,[n-1]$\n\\subsection*{observation}\n\\begin{enumerate}\n\\item\n\nlet $\\sim$ be an equivalence relation on the set $S$. take two elements $a,b\\in S$ then $a\\sim b\\Leftrightarrow [a]=[b]$\n\\item\nif $a\\not\\sim b$ then $[a]\\cap[b]=\\emptyset$\n\\item\n$S=\\cup_{a\\in S}[a]$. each element of S belongs to exactly one equivalence class. the equivalence classes form a partition of S.\n\\subsection*{question}\nif we have a partition of S, can we ``naturally'' define an equivalence on S? yes, two way relation $x\\sim y$ iff $x,y$ belong to the same subset of the partition.\n\\end{enumerate}\n\\subsection*{observation}\nlet $\\sim$ be an equiv relation on $S$. then we can define a function $\\pi:S\\to S/\\sim$. $\\pi(x)=[x]$. aside (call $S/\\sim$ factor set from now on). is this function surjective? $S/\\sim$ is the set of all possible equiv classes, so $\\pi$ (the natural projection) is always surjective. it is injective iff every equiv classes has one element (itself) and is therefore the trivial equality relation.\n\\end{document}\n", "meta": {"hexsha": "0e7c5845540b0a26ac0dc6da3713f3052e82e12e", "size": 4014, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "abstract algebra/abstract-notes-2014-09-08.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "abstract algebra/abstract-notes-2014-09-08.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "abstract algebra/abstract-notes-2014-09-08.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8769230769, "max_line_length": 397, "alphanum_fraction": 0.6711509716, "num_tokens": 1543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369904, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.4230970455537194}}
{"text": "\\section{Statistical analysis}\n\\label{sec:stat_analysis}\n\nThe final discriminant distributions across all analysis regions considered are jointly analysed to test for the \npresence of a signal. The statistical analysis uses a binned likelihood function ${\\cal L}(\\mu,\\theta)$ constructed as\na product of Poisson probability terms over all bins considered in the search. This function depends\non the signal-strength parameter $\\mu$, defined as a factor multiplying the expected yield of $tH$ and $tt(Hq)$ signal events\nnormalised to a reference branching ratio $\\BR_{\\mathrm{ref}}(t\\to Hq)=0.1\\%$,\nand $\\theta$, a set of nuisance parameters that encode the effect of systematic uncertainties on the signal and background expectations. \nTherefore, the expected total number of events in a given bin depends on $\\mu$ and $\\theta$. \nAll nuisance parameters are subject to Gaussian constraints in the likelihood.\nFor a given value of $\\mu$, the nuisance parameters $\\theta$ allow variations of the expectations for signal and background\naccording to the corresponding systematic uncertainties, and their fitted values result in the deviations from\nthe nominal expectations that globally provide the best fit to the data.\nThis procedure allows a reduction of the impact of systematic uncertainties on \nthe search sensitivity by taking advantage of the highly populated background-dominated bins included in the likelihood fit.\n%To verify the improved background prediction, fits under the background-only hypothesis are performed, \n%and differences between the data and the post-fit background prediction are checked \n%using kinematic variables other than the ones used in the fit. \nStatistical uncertainties in each bin of the predicted final discriminant distributions are taken into account by dedicated parameters in the fit.     \nThe best-fit $\\BR(t\\to Hq)$ is obtained by performing a binned likelihood fit to the data under the signal-plus-background\nhypothesis, maximising the likelihood function ${\\cal L}(\\mu,\\theta)$ over $\\mu$ and $\\theta$.\n\nThe fitting procedure was initially validated through extensive studies using mock data, defined as the sum of all predicted backgrounds \nplus an injected signal of variable strength, as well as by performing fits to real data where bins of the final discriminant variable with \na signal contamination above 10\\% are excluded (referred to as blinding requirements).\nIn both cases, the robustness of the model for systematic uncertainties is established by verifying the stability of the fitted background \nwhen varying assumptions about some of the leading sources of uncertainty. \nAfter this, the blinding requirements\nare removed in the data and a fit under the signal-plus-background hypothesis is performed. Further checks involve the comparison of the fitted \nnuisance parameters before and after removal of the blinding requirements, and their values are found to be consistent. In addition, it is verified that the \nfit is able to correctly determine the strength of a simulated signal injected into the real data.\n\nThe test statistic $q_\\mu$ is defined as the profile likelihood ratio, \n$q_\\mu = -2\\ln({\\cal L}(\\mu,{\\hat{\\theta}}_\\mu)/{\\cal L}(\\hat{\\mu},\\hat{\\theta}))$,\nwhere $\\hat{\\mu}$ and $\\hat{\\theta}$ are the values of the parameters that\nmaximise the likelihood function (subject to the constraint $0\\leq \\hat{\\mu} \\leq \\mu$), and ${\\hat{\\theta}}_\\mu$ are the values of the\nnuisance parameters that maximise the likelihood function for a given value of $\\mu$. \nThe test statistic $q_\\mu$ is evaluated with the {\\textsc RooFit} package~\\cite{Verkerke:2003ir,RooFitManual}.\n%A related statistic is used to determine whether the observed data is compatible with the background-only hypothesis (the so-called discovery test)  \n%by setting $\\mu=0$ in the profile likelihood ratio and leaving $\\hat{\\mu}$ unconstrained: $q_0 = -2\\ln({\\cal L}(0,{\\hat{\\theta}}_0)/{\\cal L}(\\hat{\\mu},\\hat{\\theta}))$.\n%The $p$-value (referred to as $p_0$), representing the level of agreement between the data and the background-only hypothesis, is estimated by integrating\n%%representing the probability of the data being compatible with the background-only hypothesis is estimated by integrating\n%%the distribution of $q_0$ obtained from background-only pseudo-experiments, approximated using the asymptotic formulae given in Refs.~\\cite{Cowan:2010js}, \n%the distribution of $q_0$ based on the asymptotic formulae in Ref.~\\cite{Cowan:2010js}, \n%above the observed value of $q_0$ in the data. \n%%The observed $p_0$-value is checked for each explored signal scenario.\n%%In the case of the data being compatible with the background-only hypothesis, \n%Upper limits on $\\mu$, and thus on \n%$\\BR(t\\to Hq)$, are derived by using $q_\\mu$ in the CL$_{\\textrm{s}}$ method~\\cite{Junk:1999kv,Read:2002hq}.\n%For a given signal scenario, values of the $\\BR(t\\to Hq)$ yielding CL$_{\\textrm{s}} < 0.05$, \n%where CL$_{\\textrm{s}}$ is computed using the asymptotic approximation~\\cite{Cowan:2010js}, are excluded at $\\geq 95\\%$ CL.\n\nIn the absence of signal, exclusion limits are set on $\\mu$ , and thus on\n$\\BR(t\\to Hq)$, are derived by using $q_\\mu$ in the CL$_{\\textrm{s}}$ method~\\cite{Junk:1999kv,Read:2002hq}.\nFor a given signal scenario, values of the $\\BR(t\\to Hq)$ yielding CL$_{\\textrm{s}} < 0.05$,\nwhere CL$_{\\textrm{s}}$ is computed using the asymptotic approximation~\\cite{Cowan:2010js}, are excluded at $\\geq 95\\%$ CL.\n", "meta": {"hexsha": "5333fd5067580d7f0166d4ceabd1d272bf85ebf1", "size": 5455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/statistical_analysis.tex", "max_stars_repo_name": "liboyang0112/fcnc-paper", "max_stars_repo_head_hexsha": "08cb3a976aa4274b7bf414401b627ed84f50d926", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/statistical_analysis.tex", "max_issues_repo_name": "liboyang0112/fcnc-paper", "max_issues_repo_head_hexsha": "08cb3a976aa4274b7bf414401b627ed84f50d926", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/statistical_analysis.tex", "max_forks_repo_name": "liboyang0112/fcnc-paper", "max_forks_repo_head_hexsha": "08cb3a976aa4274b7bf414401b627ed84f50d926", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 94.0517241379, "max_line_length": 168, "alphanum_fraction": 0.7737855179, "num_tokens": 1321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8267117855317474, "lm_q2_score": 0.5117166047041654, "lm_q1q2_score": 0.4230421479612239}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{tikz}\n\\setlength{\\parindent}{0pt}\n\n\\newtheorem*{theorem}{Theorem}\n\\newtheorem*{definition}{Definition}\n\\newtheorem*{lemma}{Lemma}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{example}{Example}\n\\newtheorem{trick}{Trick}\n\\newtheorem{question}{Question}\n\n\\title{Problem Set 1}\n\\author{}\n\\date{}\n\n\\begin{document}\n\n\\begin{center}\n{\\rmfamily\\bfseries\\Large 18.02 EXERCISES}\n\n\\vspace{25px}\n\n{\\rmfamily\\bfseries\\LARGE Problem Set 1: Vectors, Determinants and Planes}\n\\end{center}\n\n\\begin{center}\n\\section*{Part I}\n\\end{center}\n\n\\subsection*{Unit 1 Vectors}\n\n1. Find the magnitude and direction of the vectors \\\\\na) $\\vec{i} + \\vec{j} + \\vec{k}$ \\\\\nb) $2\\vec{i} - \\vec{j} + 2\\vec{k}$ \\\\\nc) $3\\vec{i} - 6\\vec{j} - 2\\vec{k}$\n\nSolution:\n\na) Suppose $\\vec{A} = \\vec{i} + \\vec{j} + \\vec{k}$, then\n\\[\n  \\begin{split}\n    |\\vec{A}| &= \\sqrt{1^2 + 1^2 + 1^2} \\\\\n              &= \\sqrt{3}\n  \\end{split}\n\\]\n\\[\n  \\begin{split}\n    dir \\vec{A} &= \\frac{\\vec{A}}{|\\vec{A}|} \\\\\n                &= \\frac{\\vec{i} + \\vec{j} + \\vec{k}}{\\sqrt{3}} \\\\\n                &= \\frac{\\sqrt{3}}{3}\\vec{i} + \\frac{\\sqrt{3}}{3}\\vec{j} + \\frac{\\sqrt{3}}{3}\\vec{k}\n  \\end{split}\n\\]\n\nb) Suppose $\\vec{A} = 2\\vec{i} - \\vec{j} + 2\\vec{k}$, then\n\\[\n  \\begin{split}\n    |\\vec{A}| &= \\sqrt{2^2 + (-1)^2 + 2^2} \\\\\n              &= \\sqrt{9} \\\\\n              &= 3\n  \\end{split}\n  |\\vec{A}| = \\sqrt{2^2 + (-1)^2 + 2^2} = \\sqrt{9} = 3\n\\]\n\\[\n  \\begin{split}\n    dir \\vec{A} &= \\frac{\\vec{A}}{|\\vec{A}|} \\\\\n                &= \\frac{2\\vec{i} - \\vec{j} + 2\\vec{k}}{3} \\\\\n                &= \\frac{2}{3}\\vec{i} - \\frac{1}{3}\\vec{j} + \\frac{2}{3}\\vec{k}\n  \\end{split}\n\\]\n\nc) Suppose $\\vec{A} = 3\\vec{i} - 6\\vec{j} - 2\\vec{k}$, then\n\\[\n  \\begin{split}\n    |\\vec{A}| &= \\sqrt{3^2 + (-6)^2 + (-2)^2} \\\\\n              &= \\sqrt{49} \\\\\n              &= 7\n  \\end{split}\n\\]\n\\[\n  \\begin{split}\n    dir \\vec{A} &= \\frac{\\vec{A}}{|\\vec{A}|} \\\\\n                &= \\frac{3\\vec{i} - 6\\vec{j} - 2\\vec{k}}{7} \\\\\n                &= \\frac{3}{7}\\vec{i} - \\frac{6}{7}\\vec{j} - \\frac{2}{7}\\vec{k}\n  \\end{split}\n\\]\n\n2. a) Let $P$ and $Q$ be two points in space, and X the midpoint of the line\nsegment $PQ$. Let $O$ be an arbitrary fixed point; show that as vectors, $OX =\n\\frac{1}{2}(OP + OQ)$.\\\\\nb) With the notation of part (a), assume that X divides the line segment $PQ$\nin the ratio $r:s$, where $r + s = 1$. Derive an expression for $OX$ in terms\nof $OP$ and $OQ$.\n\nSolution:\n\na) Suppose $P = (a_1, b_1, c_1)$, $Q = (a_2, b_2, c_2)$, and $O = (a_0, b_0, c_0)$.\\\\\nSince $X$ is the midpoint of the line segment $PQ$, then\n\\[\n    X = (\\frac{a_1 + a_2}{2}, \\frac{b_1 + b_2}{2}, \\frac{c_1 + c_2}{2})\n\\]\nTherefore,\n\\[\n  \\vec{OP} = <a_1 - a_0, b_1 - b_0, c_1 - c_0>\n\\]\n\\[\n  \\vec{OQ} = <a_2 - a_0, b_2 - b_0, c_2 - c_0>\n\\]\n\\[\n  \\begin{split}\n    \\vec{OX} &= <\\frac{a_1 + a_2}{2} - a_0, \\frac{b_1 + b_2}{2} - b_0, \\frac{c_1 + c_2}{2} - c_0> \\\\\n             &= \\frac{1}{2}<a_1 + a_2 - 2a_0, b_1 + b_2 - 2b_0, c_1 + c_2 - 2c_0> \\\\\n             &= \\frac{1}{2}(\\vec{OP} + \\vec{OQ})\n  \\end{split}\n\\]\n\nb) Since $X$ divides the line segment $PQ$ in the ratio $r : s$, where\n$r + s = 1$,\n\\[\n  \\vec{PX} = \\frac{r}{r + s}\\vec{PQ}\n\\]\nThen we also know\n\\[\n  \\vec{PQ} = \\vec{OQ} - \\vec{OP}\n\\]\n\\[\n  \\vec{OX} = \\vec{OP} + \\vec{PX}\n\\]\nTherefore,\n\\[\n  \\begin{split}\n    \\vec{OX} &= \\vec{OP} + \\vec{PX} \\\\\n             &= \\vec{OP} + \\frac{r}{r + s}\\vec{PQ} \\\\\n             &= \\vec{OP} + \\frac{r}{r + s}(\\vec{OQ} - \\vec{OP}) \\\\\n             &= \\frac{s}{r + s}\\vec{OP} + \\frac{r}{r + s}\\vec{OQ} \\\\\n  \\end{split}\n\\]\n\n3. What are the $\\vec{i} \\vec{j}$-components of a plane vector $\\vec{A}$ of\nlength 3, if it makes an angle of $30^{\\circ}$ with $\\vec{i}$ and $60^{\\circ}$\nwith $\\vec{j}$. Is the second condition redundant?\n\nSolution:\n\n\\begin{tikzpicture}\n  [help lines/.style={dashed}]\n  \\draw[->] (-3, 0, 0) -- (3, 0, 0) node[anchor=south] {x};\n  \\draw[->] (0, 0, 0) -- (1, 0, 0) node[anchor=south] {$\\vec{i}$};\n  \\draw[->] (0, -3, 0) -- (0, 3, 0) node[anchor=east] {y};\n  \\draw[->] (0, 0, 0) -- (0, 1, 0) node[anchor=east] {$\\vec{j}$};\n  \\draw[->] (0, 0, 0) -- (2.6, 1.5, 0) node[anchor=south] {$\\vec{A}$};\n  \\draw (0.2, 0) arc [start angle=0, end angle=30, radius=0.2] \n    node[anchor=west] {$30^{\\circ}$};\n  \\draw[->, help lines] (0, 0, 0) -- (2.6, -1.5, 0) node[anchor=north] {$\\vec{A'}$};\n\\end{tikzpicture}\n\nApparently\n\\[\n  \\begin{split}\n    \\vec{A} &= <|\\vec{A}|\\cos(30^{\\circ}), |\\vec{A}|\\sin(30^{\\circ})> \\\\\n            &= <3 \\cdot \\frac{\\sqrt{3}}{2}, 3 \\cdot \\frac{1}{2}> \\\\\n            &= <\\frac{3\\sqrt{3}}{2}, \\frac{3}{2}> \\\\\n            &= \\frac{3\\sqrt{3}}{2}\\vec{i} + \\frac{3}{2} \\vec{j} \\\\\n  \\end{split}\n\\]\nThe second condition that the vector $\\vec{A}$ makes an angle of $60^{\\circ}$\nwith $\\vec{j}$ is not redundant, otherwise the referred vector can be $\\vec{A}$\nor $\\vec{A'}$ in the above diagram.\n\n4. A small plane wishes to fly due north at 200 mph (as seen from the ground),\nin a wind blowing from the northeast at 50 mph. Tell with what vector velocity\nin the air it should travel (given the $\\vec{i} \\vec{j}$-components).\n\nSolution:\n\nSuppose that $\\vec{i}$ represents east, then $\\vec{j}$ represents north, and\n$-\\vec{i}$ represents west, and $-\\vec{j}$ represents south. Let $\\vec{V_w}$\ndenote the velocity of the wind, $\\vec{V_p}$ denote the velocity of the plane in\nthe air, and $\\vec{V}$ denote the velocity of plane seen from the ground. \\\\\n$\\vec{V}$ should be the result of $\\vec{V_p}$ and $\\vec{V_w}$ applied together,\ntherefore\n\\[\n  \\vec{V} = \\vec{V_p} + \\vec{V_w}\n\\]\nAccording to the problem description,\n\\[\n  \\begin{split}\n    \\vec{V_w} &= <50\\cos45^{\\circ}, 50\\sin45^{\\circ}> \\\\\n              &= <25\\sqrt{2}, 25\\sqrt{2}> \\\\\n  \\end{split}\n\\]\n\\[\n  \\vec{V} = <0, 200>\n\\]\nTherefore\n\\[\n  \\begin{split}\n    \\vec{V_p} &= \\vec{V} - \\vec{V_w} \\\\\n              &= <0, 200> - <25\\sqrt{2}, 25\\sqrt{2}> \\\\\n              &= <-25\\sqrt{2}, 200 - 25\\sqrt{2}> \\\\\n  \\end{split}\n\\]\n\n5. Let $\\vec{A} = a \\vec{i} + b \\vec{j}$ be a plane vector; find in terms of\n$a$ and $b$ the vectors $\\vec{A'}$ and $\\vec{A''}$ resulting from rotating\n$\\vec{A}$ by $90^{\\circ}$ \\hspace{10px} a) clockwise \\hspace{10px} b)\ncounterclockwise.\\\\\nc) Let $\\vec{i'} = (3 \\vec{i} + 4 \\vec{j}) / 5$. Show that $\\vec{i'}$ is a unit\nvector, and use the first part of the exercise to find a vector $\\vec{j'}$ such\nthat $\\vec{i'}$, $\\vec{j'}$ forms a right-handed coordinate system.\n\nSolution:\n\na) According to the problem description, $\\vec{A'}$ is the result of rotating\n$\\vec{A}$ clockwise by $90^{\\circ}$. Therefore, the $\\vec{i} \\vec{j}$-components\nof $\\vec{A}$ should be rotated the same way to get the corresponding components\nof $\\vec{A'}$. After being rotated in the mentioned way, $\\vec{i}$ becomes\n$-\\vec{j}$, and $\\vec{j}$ becomes $\\vec{i}$. Therefore,\n\\[\n  \\vec{A'} = b \\cdot \\vec{i} - a \\cdot \\vec{j}\n\\]\n\nb) Similar to a), after being rotated counterclockwise by $90^{\\circ}$,\n$\\vec{i}$ becomes $\\vec{j}$, and $\\vec{j}$ becomes $-\\vec{i}$. Therefore,\n\\[\n  \\vec{A''} = -b \\cdot \\vec{i} + a \\cdot \\vec{j}\n\\]\n\nc) To prove $\\vec{i'}$ is a unit vector,\n\\[\n  \\begin{split}\n    |\\vec{i'}| &= \\sqrt{(\\frac{3}{5})^2 + (\\frac{4}{5})^2} \\\\\n               &= 1\n  \\end{split}\n\\]\nTo form a right-handed coordinate system, $\\vec{j'}$ should be the result of\nrotating $\\vec{i'}$ counterclockwise by $90^{\\circ}$. According the part b),\nwe can derive that\n\\[\n  \\vec{j'} = -\\frac{4}{5} \\cdot \\vec{i} + \\frac{3}{5} \\cdot \\vec{j}\n\\]\n\n6. The direction of a space vector is in engineering practice often given by\nits \\textbf{direction cosines}. To describe these, let \n$\\vec{A} = a \\vec{i} + b \\vec{j} + c \\vec{k}$ be a space vector, represented as \nan origin vector, and let $\\alpha$, $\\beta$, and $\\gamma$ be the three angles \n($\\le \\pi$) that $\\vec{A}$ makes respectively with $\\vec{i}$, $\\vec{j}$, and \n$\\vec{k}$.\\\\\na) Show that $dir \\vec{A} = \\cos\\alpha \\vec{i} + \\cos\\beta \\vec{j} +\n\\cos\\gamma \\vec{k}$. (The three coefficients are called the \\emph{direction\ncosines} of $\\vec{A}$.)\\\\\nb) Express the direction cosines of $\\vec{A}$ in terms of $a$, $b$, $c$; find\nthe direction cosines of the vector $-\\vec{i} + 2\\vec{j} + 2\\vec{k}$.\\\\\nc) Prove that three numbers $t$, $u$, $v$ are the direction cosines of a vector\nin space if and only if they satisfy $t^{2} + u^{2} + v^{2} = 1$.\n\nSolution:\n\na) According to the definition, $dir \\vec{A}$ is the unit vector with the same\ndirection as $\\vec{A}$, hence $dir \\vec{A}$ makes the same angles with\n$\\vec{i}$, $\\vec{j}$, $\\vec{k}$ as $\\vec{A}$, i.e. $\\alpha$, $\\beta$, and \n$\\gamma$ respectively. Then according to the definition of component vectors, \ni.e. the cast on a specific directions, we can derive that\n\\[\n  dir \\vec{A} = \\cos\\alpha \\cdot \\vec{i} + \\cos\\beta \\cdot \\vec{j} + \\cos\\gamma \\cdot \\vec{k}\n\\]\n\nb) According to the definition of vector directions, \n\\[\n  \\begin{split}\n    dir \\vec{A} &= \\frac{\\vec{A}}{|\\vec{A}|} \\\\\n                &= \\frac{a \\vec{i} + b \\vec{j} + c \\vec{k}}{\\sqrt{a^2 + b^2 + c^2}} \\\\\n                &= \\frac{a}{\\sqrt{a^2 + b^2 + c^2}} \\vec{i} + \\frac{b}{\\sqrt{a^2 + b^2 + c^2}} \\vec{j} + \\frac{c}{\\sqrt{a^2 + b^2 + c^2}} \\vec{k} \\\\\n                &= \\cos\\alpha \\cdot \\vec{i} + \\cos\\beta \\cdot \\vec{j} + \\cos\\gamma \\cdot \\vec{k}\n  \\end{split}\n\\]\nTherefore,\n\\begin{gather*}\n  \\cos\\alpha = \\frac{a}{\\sqrt{a^2 + b^2 + c^2}} \\\\\n  \\cos\\beta = \\frac{b}{\\sqrt{a^2 + b^2 + c^2}} \\\\\n  \\cos\\gamma = \\frac{c}{\\sqrt{a^2 + b^2 + c^2}} \\\\\n\\end{gather*}\nHence for the vector $-\\vec{i} + 2\\vec{j} + 2\\vec{k}$,\n\\begin{gather*}\n  \\begin{split}\n    \\cos\\alpha &= \\frac{-1}{\\sqrt{(-1)^2 + 2^2 + 2^2}} \\\\\n               &= -\\frac{1}{3} \\\\\n  \\end{split} \\\\\n  \\begin{split}\n    \\cos\\beta &= \\frac{2}{\\sqrt{(-1)^2 + 2^2 + 2^2}} \\\\\n              &= \\frac{2}{3} \\\\\n  \\end{split} \\\\\n  \\begin{split}\n    \\cos\\gamma &= \\frac{2}{\\sqrt{(-1)^2 + 2^2 + 2^2}} \\\\\n              &= \\frac{2}{3} \\\\\n  \\end{split} \\\\\n\\end{gather*}\n\nc) Proof: \\\\\nIf $t$, $u$, $v$ are the direction cosines of a vector $\\vec{A}$ in space, then \nthey are the components of its direction:\n\\[\n  dir \\vec{A} = t \\cdot \\vec{i} + u \\cdot \\vec{j} + v \\cdot \\vec{k}\n\\]\nSince $dir \\vec{A}$ is a unit vector, then\n\\[\n  |dir \\vec{A}| = \\sqrt{t^2 + u^2 + v^2} = 1\n\\]\n\\[\n  t^2 + u^2 + v^2 = 1\n\\]\nIf $t$, $u$, $v$ satisfy $t^2 + u^2 + v^2 = 1$, then we can construct a unit \nvector $\\vec{D} = t \\cdot \\vec{i} + u \\cdot \\vec{j} + v \\cdot \\vec{k}$. Then \n$t$, $u$, $v$ are the direction cosines of the constructed space vector.\n\n7. Prove using vector methods (without components) that the line segment\njoining the midpoints of two sides of a triangle is parallel to the third side\nand half its length. (Call the two sides $\\vec{A}$ and $\\vec{B}$.)\n\nProof:\n\nSuppose that the two sides are $\\vec{A}$ and $\\vec{B}$, the third side is \n$\\vec{C}$, and the line segment joining the midpoints of the two sides is\n$\\vec{C'}$. Then\n\\[\n  \\vec{C} = \\vec{A} - \\vec{B}\n\\]\nor\n\\[\n  \\vec{C} = -(\\vec{A} - \\vec{B})\n\\]\nAnd\n\\[\n  \\begin{split}\n    \\vec{C'} &= \\frac{1}{2}\\vec{A} - \\frac{1}{2}\\vec{B} \\\\\n             &= \\frac{1}{2}(\\vec{A} - \\vec{B}) \\\\\n  \\end{split}\n\\]\nor\n\\[\n  \\begin{split}\n    \\vec{C'} &= -(\\frac{1}{2}\\vec{A} - \\frac{1}{2}\\vec{B}) \\\\\n             &= -\\frac{1}{2}(\\vec{A} - \\vec{B}) \\\\\n  \\end{split}\n\\]\nTherefore, either of the following equations must hold:\n\\[\n  \\vec{C'} = \\frac{1}{2}\\vec{C}\n\\]\nor\n\\[\n  \\vec{C'} = -\\frac{1}{2}\\vec{C}\n\\]\nTherefore, $\\vec{C'}$ is parallel to $\\vec{C}$ and the magnitude of $\\vec{C'}$ \nis the half of the one of $\\vec{C}$.\n\n8. Prove using vector methods (without components) that the diagonals of a\nparallelogram bisect each other. (One way: let $X$ and $Y$ be the midpoints of\nthe two diagonals; show $X$ = $Y$.)\n\nProof:\n\n\\begin{tikzpicture}\n  [help lines/.style={dashed}]\n  \\draw[-] (-2, 0) node[anchor=north] {A} -- (2, 0) node[anchor=north] {B} -- \n    (4, 2) node[anchor=south] {C} -- (0, 2) node[anchor=south] {D} -- (-2, 0);\n  \\draw[-, help lines] (-2, 0) -- (1, 1) node[anchor=north] {X} -- (4, 2);\n  \\draw[-, help lines] (2, 0) -- (1, 1) node[anchor=south] {Y} -- (0, 2);\n\\end{tikzpicture}\n\nAs shown in the diagram, suppose that the four endpoints of a parallelogram are \n$A$, $B$, $C$, $D$, and the midpoint of the diagonal $AC$ is $X$, and the \nmidpoint of the diagonal $BD$ is $Y$. Then\n\\[\n  \\begin{split}\n    \\vec{AX} &= \\frac{1}{2}\\vec{AC} \\\\\n             &= \\frac{1}{2}(\\vec{AB} + \\vec{AD}) \\\\\n             &= \\frac{1}{2}\\vec{AB} + \\frac{1}{2}\\vec{AD} \\\\\n  \\end{split}\n\\]\n\\[\n  \\begin{split}\n    \\vec{AY} &= \\vec{AB} + \\vec{BY} \\\\\n             &= \\vec{AB} + \\frac{1}{2}\\vec{BD} \\\\\n             &= \\vec{AB} + \\frac{1}{2}(\\vec{AD} - \\vec{AB}) \\\\\n             &= \\frac{1}{2}\\vec{AB} + \\frac{1}{2}\\vec{AD} \\\\\n  \\end{split}\n\\]\nTherefore, $\\vec{AX} = \\vec{AY}$, which means the midpoints of the two \ndiagonals are the same point. Hence, the two diagonals of a parallelogram \nbisect each other.\n\n\\subsection*{Unit 2 Dot Product}\n\n1. Tell for what values of $c$ the vectors $c \\vec{i} + 2 \\vec{j} - \\vec{k}$\nand $\\vec{i} - \\vec{j} + 2 \\vec{k}$ will \\\\\na) be orthogonal \\hspace{10px} b) form an acute angle\n\nSolution:\n\na) The vectors $c \\vec{i} + 2 \\vec{j} - \\vec{k}$ and \n$\\vec{i} - \\vec{j} + 2 \\vec{k}$ are orthogonal if and only if\n\\[\n  (c \\vec{i} + 2 \\vec{j} - \\vec{k}) \\cdot (\\vec{i} - \\vec{j} + 2 \\vec{k}) = 0\n\\]\n\\[\n  c - 2 - 2 = 0\n\\]\n\\[\n  c = 4\n\\]\n\nb) The vectors $c \\vec{i} + 2 \\vec{j} - \\vec{k}$ and \n$\\vec{i} - \\vec{j} + 2 \\vec{k}$ form an acute angle if and only if\n\\[\n  (c \\vec{i} + 2 \\vec{j} - \\vec{k}) \\cdot (\\vec{i} - \\vec{j} + 2 \\vec{k}) > 0\n\\]\n\\[\n  c - 2 - 2 > 0\n\\]\n\\[\n  c > 4\n\\]\n\n2. Using vectors, find the angle between a longest diagonal $PQ$ of a cube,\nand \\\\\na) a diagonal $PR$ of one of its faces; \\hspace{10px} b) an edge $PS$ of the\ncube. \\\\\n(Choose a size and position for the cube that makes calculation easiest.)\n\nSolution:\n\na) Suppose that $P = (0, 0, 0)$, $Q = (1, 1, 1)$, and $R = (1, 1, 0)$. \nTherefore, $\\vec{PQ} = <1, 1, 1>$, and $\\vec{PR} = <1, 1, 0>$. Then, the angle\n$\\theta$ between $PQ$ and $PR$ satisfies\n\\[\n  \\begin{split}\n    \\cos\\theta &= \\frac{\\vec{PQ} \\cdot \\vec{PR}}{|\\vec{PQ}| \\cdot |\\vec{PR}|} \\\\\n               &= \\frac{1 \\times 1 + 1 \\times 1 + 1 \\times 0}{\\sqrt{1^2 + 1^2 + 1^2} \\times \\sqrt{1^2 + 1^2 + 0^2}} \\\\\n               &= \\frac{2}{\\sqrt{3} \\times \\sqrt{2}} \\\\\n               &= \\frac{\\sqrt{6}}{3} \\\\\n  \\end{split}\n\\]\n\nb) Suppose that $P = (0, 0, 0)$, $Q = (1, 1, 1)$, and $S = (1, 0, 0)$. \nTherefore, $\\vec{PQ} = <1, 1, 1>$, and $\\vec{PS} = <1, 0, 0>$. Then, the angle\n$\\theta$ between $PQ$ and $PS$ satisfies\n\\[\n  \\begin{split}\n    \\cos\\theta &= \\frac{\\vec{PQ} \\cdot \\vec{PS}}{|\\vec{PQ}| \\cdot |\\vec{PS}|} \\\\\n               &= \\frac{1 \\times 1 + 1 \\times 0 + 1 \\times 0}{\\sqrt{1^2 + 1^2 + 1^2} \\times \\sqrt{1^2 + 0^2 + 0^2}} \\\\\n               &= \\frac{1}{\\sqrt{3} \\times 1} \\\\\n               &= \\frac{\\sqrt{3}}{3} \\\\\n  \\end{split}\n\\]\n\n3. Three points in space are $P:(a,1,-1)$, $Q:(0,1,1)$, $R:(a,-1,3)$. For what\nvalue(s) of $a$ will $PQR$ be\\\\\na) a right angle \\hspace{10px} b) an acute angle\n\nSolution:\n\na) $PQR$ will be a right angle $\\iff$ $\\vec{PQ} \\cdot \\vec{QR} = 0$\n\\begin{gather*}\n  \\vec{PQ} = <-a, 0, 2> \\\\\n  \\vec{QR} = <a, -2, 2> \\\\\n  \\vec{PQ} \\cdot \\vec{QR} = 0 \\\\\n  <-a, 0, 2> \\cdot <a, -2, 2> = 0 \\\\\n  -a^2 + 4 = 0 \\\\\n  a = \\pm 2 \\\\\n\\end{gather*}\n\nb) $PQR$ will be an acute angle $\\iff$ $\\vec{PQ} \\cdot \\vec{QR} > 0$\n\\begin{gather*}\n  \\vec{PQ} \\cdot \\vec{QR} > 0 \\\\\n  <-a, 0, 2> \\cdot <a, -2, 2> > 0 \\\\\n  -a^2 + 4 > 0 \\\\\n  a^2 < 4 \\\\\n  -2 < a < 2 \\\\\n\\end{gather*}\n\n4. Find the component of the force $\\vec{F} = 2 \\vec{i} - 2 \\vec{j} + \\vec{k}$\nin\\\\\na) the direction $\\frac{\\vec{i} + \\vec{j} - \\vec{k}}{\\sqrt{3}}$ \\hspace{10px}\nb) the direction of the vector $3 \\vec{i} + 2 \\vec{j} - 6 \\vec{k}$.\n\nSolution:\n\na) To get the component of a vector along a certain direction, we can calculate \nthe dot product of the vector and the direction. Since dot product satisfies the \ndistributive property, the dot product of a vector and a direction is equivalent \nto the dot product of the direction and the component vector of the vector along \nthe direction, plus the dot product of the direction and the other component \nvector, which is perpendicular to the direction. Therefore, the result is only \nthe dot product of the direction and the component vector of the vector along \nthe direction, which is the component value.\n\\begin{equation*}\n\\begin{split}\n  c &= (2\\vec{i} - 2\\vec{j} + \\vec{k}) \\cdot (\\frac{\\vec{i} + \\vec{j} - \\vec{k}}{\\sqrt{3}}) \\\\\n    &= <2, -2, 1> \\cdot <\\frac{\\sqrt{3}}{3}, \\frac{\\sqrt{3}}{3}, -\\frac{\\sqrt{3}}{3}> \\\\\n    &= -\\frac{\\sqrt{3}}{3} \\\\\n\\end{split}\n\\end{equation*}\n\nb) Similar to a),\n\\begin{gather*}\n\\begin{split}\n  dir(3\\vec{i} + 2\\vec{j} - 6\\vec{k}) &= \\frac{3\\vec{i} + 2\\vec{j} - 6\\vec{k}}{|3\\vec{i} + 2\\vec{j} - 6\\vec{k}|} \\\\\n                                      &= \\frac{3\\vec{i} + 2\\vec{j} - 6\\vec{k}}{7} \\\\\n                                      &= <\\frac{3}{7}, \\frac{2}{7}, -\\frac{6}{7}> \\\\\n\\end{split} \\\\\n\\begin{split}\n  c &= (2\\vec{i} - 2\\vec{j} + \\vec{k}) \\cdot dir(3\\vec{i} + 2\\vec{j} - 6\\vec{k}) \\\\\n    &= <2, -2, 1> \\cdot <\\frac{3}{7}, \\frac{2}{7}, -\\frac{6}{7}> \\\\\n    &= -\\frac{4}{7} \\\\\n\\end{split} \\\\\n\\end{gather*}\n\n5. Prove using vector methods (without components) that the diagonals of a\nparallelogram have equal lengths if and only if it is a rectangle.\n\nProof:\n\nLet $\\vec{A}$ and $\\vec{B}$ denote the vectors of two adjecent sides of a parallelogram,\nand $\\vec{D_1}$ and $\\vec{D_2}$ denote the two diagonals of the parallelogram.\n\\begin{gather*}\n  \\vec{D_1} = \\vec{A} + \\vec{B} \\\\\n  \\vec{D_2} = \\vec{A} - \\vec{B} \\\\\n\\end{gather*}\nThe two diagonals have equal lengths is equivalent to\n\\begin{gather*}\n  |\\vec{D_1}| = |\\vec{D_2}| \\\\\n  \\iff |\\vec{A} + \\vec{B}| = |\\vec{A} - \\vec{B}| \\\\\n  \\iff |\\vec{A} + \\vec{B}|^2 = |\\vec{A} - \\vec{B}|^2 \\\\\n  \\iff (\\vec{A} + \\vec{B}) \\cdot (\\vec{A} + \\vec{B}) = (\\vec{A} - \\vec{B}) \\cdot (\\vec{A} - \\vec{B}) \\\\\n  \\iff |\\vec{A}|^2 + |\\vec{B}|^2 + 2\\vec{A} \\cdot \\vec{B} = |\\vec{A}|^2 + |\\vec{B}|^2 - 2\\vec{A} \\cdot \\vec{B} \\\\\n  \\iff 4\\vec{A} \\cdot \\vec{B} = 0 \\\\\n  \\iff \\vec{A} \\cdot \\vec{B} = 0 \\\\\n  \\iff \\vec{A} \\perp \\vec{B} \\\\\n\\end{gather*}\nwhich is equivalent to the parallelogram is a rectangle.\n\nTherefore, it is proved that the diagonals of a parallelogram have equal lengths \nif and only if it is a rectangle.\n\n6. Prove using vector methods (without components) that the diagonals of a\nparallelogram are perpendicular if and only if it is a rhombus, i.e., its four\nsides are equal.\n\nProof:\n\nLet $\\vec{A}$ and $\\vec{B}$ denote the vectors of two adjecent sides of a parallelogram,\nand $\\vec{D_1}$ and $\\vec{D_2}$ denote the two diagonals of the parallelogram.\n\\begin{gather*}\n  \\vec{D_1} = \\vec{A} + \\vec{B} \\\\\n  \\vec{D_2} = \\vec{A} - \\vec{B} \\\\\n\\end{gather*}\nThe two diagonals are perpendicular is equivalent to \n\\begin{gather*}\n  \\vec{D_1} \\perp \\vec{D_2} \\\\\n  \\iff \\vec{D_1} \\cdot \\vec{D_2} = 0 \\\\\n  \\iff (\\vec{A} + \\vec{B}) \\cdot (\\vec{A} - \\vec{B}) = 0 \\\\\n  \\iff |\\vec{A}|^2 - |\\vec{B}|^2 = 0 \\\\\n  \\iff |\\vec{A}|^2 = |\\vec{B}|^2 \\\\\n  \\iff |\\vec{A}| = |\\vec{B}| \\\\\n\\end{gather*}\nwhich is equivalent to the four sides of the parallelogram are equal.\n\nTherefore, it is proved that the diagonals of a parallelogram are perpendicular \nif and only if it is a rhombus, i.e., its four sides are equal.\n\n7. Prove using vector methods (without components) that an angle inscribed in\na semicircle is a right angle.\n\nProof:\n\n\\begin{tikzpicture}\n  [help lines/.style={dashed}]\n  \\draw (-2, 0) .. controls (-2, 1.11) and (-1.11, 2) .. (0, 2)\n                .. controls (1.11, 2) and (2, 1.11) .. (2, 0);\n  \\draw[-] (-2, 0) node[anchor=north]{A} -- (2, 0) node[anchor=north]{B};\n  \\draw[-] (-1.414, 1.414) node[anchor=south]{P} -- (-2, 0);\n  \\draw[-] (-1.414, 1.414) -- (2, 0);\n  \\draw[-] (-1.414, 1.414) -- (0, 0) node[anchor=north]{O};\n\\end{tikzpicture}\n\nSuppose $P$ is a random point on the semicircle, then $APB$ is an angle \ninscribed in a semicircle.\n\\begin{equation*}\n\\begin{split}\n  \\vec{PA} \\cdot \\vec{PB} &= (\\vec{OA} - \\vec{OP}) \\cdot (\\vec{OB} - \\vec{OP}) \\\\\n                          &= \\vec{OA} \\cdot \\vec{OB} + |\\vec{OP}|^2 - \\vec{OA} \\cdot \\vec{OP} - \\vec{OB} \\cdot \\vec{OP} \\\\\n                          &= -|\\vec{OA}|^2 + |\\vec{OP}|^2 - (\\vec{OA} + \\vec{OB}) \\cdot \\vec{OP} \\\\\n\\end{split}\n\\end{equation*}\nGiven that $APB$ is inscribed in a semicircle, \n$|\\vec{OA}| = |\\vec{OB}| = |\\vec{OP}|$, and $\\vec{OA} = -\\vec{OB}$.\n\\begin{gather*}\n  \\begin{split}\n    \\vec{PA} \\cdot \\vec{PB} &= -|\\vec{OA}|^2 + |\\vec{OP}|^2 - (\\vec{OA} + \\vec{OB}) \\cdot \\vec{OP} \\\\ \n                            &= -|\\vec{OP}|^2 + |\\vec{OP}|^2 - \\vec{0} \\cdot \\vec{OP} \\\\\n                            &= 0 \\\\\n  \\end{split} \\\\\n  \\vec{PA} \\perp \\vec{PB}\n\\end{gather*}\nTherefore, it is proved that an angle inscribed in a semicircle is a right \nangle.\n\n8. Prove the trigonometric formula: \n$\\cos(\\theta_1 - \\theta_2) = \\cos\\theta_1\\cos\\theta_2 + \\sin\\theta_1\\sin\\theta_2$.\n\nProof:\n\nSuppose the angle between the unit vector $\\vec{u_1}$ and $\\vec{i}$ is \n$\\theta_1$, and the angle between the unit vector $\\vec{u_2}$ and $\\vec{i}$ is \n$\\theta_2$.\n\\begin{gather*}\n  \\vec{u_1} = <\\cos\\theta_1, \\sin\\theta_1> \\\\\n  \\vec{u_2} = <\\cos\\theta_2, \\sin\\theta_2> \\\\\n\\end{gather*}\nThe angle between $\\vec{u_1}$ and $\\vec{u_2}$ is $|\\theta_1 - \\theta_2|$. Hence,\n\\begin{gather*}\n  \\begin{split}\n    \\vec{u_1} \\cdot \\vec{u_2} &= |\\vec{u_1}| \\cdot |\\vec{u_2}| \\cdot \\cos(|\\theta_1 - \\theta_2|) \\\\\n                              &= |\\vec{u_1}| \\cdot |\\vec{u_2}| \\cdot \\cos(\\theta_1 - \\theta_2) \\\\\n                              &= \\cos(\\theta_1 - \\theta_2) \\\\\n  \\end{split} \\\\\n  \\begin{split}\n    \\vec{u_1} \\cdot \\vec{u_2} &= <\\cos\\theta_1, \\sin\\theta_1> \\cdot <\\cos\\theta_2, \\sin\\theta_2> \\\\\n                              &= \\cos\\theta_1\\cos\\theta_2 + \\sin\\theta_1\\sin\\theta_2 \\\\\n  \\end{split} \\\\\n  \\cos(\\theta_1 - \\theta_2) = \\cos\\theta_1\\cos\\theta_2 + \\sin\\theta_1\\sin\\theta_2 \\\\\n\\end{gather*}\n\nTherefore, it is proved that \n$\\cos(\\theta_1 - \\theta_2) = \\cos\\theta_1\\cos\\theta_2 + \\sin\\theta_1\\sin\\theta_2$.\n\n\\subsection*{Unit 3 Determinants}\n\n1. Calculate the value of the determinants\\\\\na) $\\begin{vmatrix}\n    1 & 4 \\\\\n    2 & -1 \\\\\n\\end{vmatrix}$\n\nb) $\\begin{vmatrix}\n    3 & -4 \\\\\n    -1 & -2 \\\\\n\\end{vmatrix}$\n\nSolution:\n\na)\n\\[\n  \\begin{vmatrix}\n    1 & 4 \\\\\n    2 & -1 \\\\\n  \\end{vmatrix} = (1 \\times (-1)) - (4 \\times 2) = -9\n\\]\n\nb)\n\\[\n  \\begin{vmatrix}\n    3 & -4 \\\\\n    -1 & -2 \\\\\n  \\end{vmatrix} = (3 \\times (-2)) - ((-4) \\times (-1)) = -10\n\\]\n\n2. Calculate \n$\\begin{vmatrix}\n  -1 & 0 & 4 \\\\\n  1 & 2 & 2 \\\\\n  3 & -2 & -1 \\\\\n\\end{vmatrix}$ using the Laplace expansion by the cofactors of:\\\\\na) the first row \\hspace{10px} b) the first column\n\nSolution:\n\na)\n\\begin{equation*}\n\\begin{split}\n  \\begin{vmatrix}\n    -1 & 0 & 4 \\\\\n    1 & 2 & 2 \\\\\n    3 & -2 & -1 \\\\\n  \\end{vmatrix} \n  &= (-1) \\cdot \\begin{vmatrix}\n                  2 & 2 \\\\\n                  -2 & -1 \\\\ \n                \\end{vmatrix} -\n     0 \\cdot \\begin{vmatrix}\n               1 & 2 \\\\\n               3 & -1 \\\\ \n             \\end{vmatrix} +\n     4 \\cdot \\begin{vmatrix}\n               1 & 2 \\\\\n               3 & -2 \\\\ \n             \\end{vmatrix} \\\\ \n  &= (-1) \\times 2 - 0 \\times (-7) + 4 \\times (-8) \\\\\n  &= -34 \\\\\n\\end{split}\n\\end{equation*}\n\nb)\n\\begin{equation*}\n\\begin{split}\n  \\begin{vmatrix}\n    -1 & 0 & 4 \\\\\n    1 & 2 & 2 \\\\\n    3 & -2 & -1 \\\\\n  \\end{vmatrix} \n  &= (-1) \\cdot \\begin{vmatrix}\n                  2 & 2 \\\\\n                  -2 & -1 \\\\ \n                \\end{vmatrix} -\n     1 \\cdot \\begin{vmatrix}\n               0 & 4 \\\\\n               -2 & -1 \\\\ \n             \\end{vmatrix} +\n     3 \\cdot \\begin{vmatrix}\n               0 & 4 \\\\\n               2 & 2 \\\\ \n             \\end{vmatrix} \\\\ \n  &= (-1) \\times 2 - 1 \\times (8) + 3 \\times (-8) \\\\\n  &= -34 \\\\\n\\end{split}\n\\end{equation*}\n\n3. Find the area of the plane triangle whose vertices lie at\\\\\na) $(0, 0), (1, 2), (1, -1)$ \\hspace{10px} b) $(1, 2), (1, -1), (2, 3)$\n\nSolution:\n\na) The vectors of the two edges of the plane triangle are $<1, 2>$ and \n$<1, -1>$. The area of the plane triangle $A$ can be calculated as\n\\begin{gather*}\n  \\begin{split}\n    det(<1, 2>, <1, -1>) &= \\begin{vmatrix}\n                              1 & 2 \\\\\n                              1 & -1 \\\\ \n                            \\end{vmatrix} \\\\\n                         &= -3\n  \\end{split} \\\\\n  A = |det(<1, 2>, <1, -1>)| = 3 \\\\\n\\end{gather*}\n\nb) The vectors of the two edges of the plane triangle are $<0, -3>$ and \n$<1, 1>$. The area of the plane triangle $A$ can be calculated as\n\\begin{gather*}\n  \\begin{split}\n    det(<0, -3>, <1, 1>) &= \\begin{vmatrix}\n                              0 & -3 \\\\\n                              1 & 1 \\\\ \n                            \\end{vmatrix} \\\\\n                         &= 3\n  \\end{split} \\\\\n  A = |det(<1, 2>, <1, -1>)| = 3 \\\\\n\\end{gather*}\n\n4. a) Show that the value of a $2 \\times 2$ determinants is unchanged if you add\nto the second row a scalar multiple of the first row.\\\\\n   b) Show that the value of a $2 \\times 2$ determinants is unchanged if you add\nto the second column a scalar multiple of the first column.\n\nSolution:\n\na)\n\\begin{gather*}\n  \\begin{vmatrix}\n    a_1 & a_2 \\\\\n    b_1 & b_2 \\\\\n  \\end{vmatrix} = a_1b_2 - a_2b_1 \\\\\n  \\begin{split}\n    \\begin{vmatrix}\n      a_1 & a_2 \\\\\n      b_1 + c \\cdot a_1 & b_2 + c \\cdot a_2 \\\\\n    \\end{vmatrix} &= \n    a_1 \\cdot (b_2 + c \\cdot a_2) - a_2 \\cdot (b_1 + c \\cdot a_1) \\\\\n    &= a_1b_2 + c \\cdot a_1a_2 - a_2b_1 - c \\cdot a_1a_2 \\\\\n    &= a_1b_2 - a_2b_1 \\\\\n  \\end{split} \\\\\n\\end{gather*}\n\nb)\n\\begin{gather*}\n  \\begin{vmatrix}\n    a_1 & a_2 \\\\\n    b_1 & b_2 \\\\\n  \\end{vmatrix} = a_1b_2 - a_2b_1 \\\\\n  \\begin{split}\n    \\begin{vmatrix}\n      a_1 & c \\cdot a_1 + a_2 \\\\\n      b_1 & c \\cdot b_1 + b_2 \\\\\n    \\end{vmatrix} &= \n    a_1 \\cdot (c \\cdot b_1 + b_2) - b_1 \\cdot (c \\cdot a_1 + a_2) \\\\\n    &= c \\cdot a_1b_1 + a_1b_2 - c \\cdot a_1b_1 - a_2b_1\\\\\n    &= a_1b_2 - a_2b_1 \\\\\n  \\end{split} \\\\\n\\end{gather*}\n\n5. Use a Laplace expansion and Exercise 4a to show the value of a $3 \\times 3$\ndeterminants is unchanged if you add to the second row a scalar multiple of the\nthird row.\n\nSolution:\n\n\\begin{gather*}\n  \\begin{vmatrix}\n    a_1 & a_2 & a_3 \\\\\n    b_1 & b_2 & b_3 \\\\\n    c_1 & c_2 & c_3 \\\\\n  \\end{vmatrix} = \n  a_1 \\cdot \\begin{vmatrix}\n              b_2 & b_3 \\\\\n              c_2 & c_3 \\\\ \n            \\end{vmatrix} -\n  a_2 \\cdot \\begin{vmatrix}\n              b_1 & b_3 \\\\\n              c_1 & c_3 \\\\\n            \\end{vmatrix} + \n  a_3 \\cdot \\begin{vmatrix}\n              b_1 & b_2 \\\\\n              c_1 & c_2 \\\\ \n            \\end{vmatrix} \\\\\n  \\begin{vmatrix}\n    a_1 & a_2 & a_3 \\\\\n    b_1 + k \\cdot c_1 & b_2 + k \\cdot c_2 & b_3 + k \\cdot c_3 \\\\\n    c_1 & c_2 & c_3 \\\\\n  \\end{vmatrix} = \n  a_1 \\cdot \\begin{vmatrix}\n              b_2 + k \\cdot c_2 & b_3 + k \\cdot c_3 \\\\\n              c_2 & c_3 \\\\ \n            \\end{vmatrix} - \\\\\n  a_2 \\cdot \\begin{vmatrix}\n              b_1 + k \\cdot c_1 & b_3 + k \\cdot c_3 \\\\\n              c_1 & c_3 \\\\\n            \\end{vmatrix} + \n  a_3 \\cdot \\begin{vmatrix}\n              b_1 + k \\cdot c_1 & b_2 + k \\cdot c_2 \\\\\n              c_1 & c_2 \\\\ \n            \\end{vmatrix} \\\\\n\\end{gather*}\nAccording to the result of Exercise 4a,\n\\begin{gather*}\n  \\begin{vmatrix}\n    b_2 + k \\cdot c_2 & b_3 + k \\cdot c_3 \\\\\n    c_2 & c_3 \\\\ \n  \\end{vmatrix} = \n  \\begin{vmatrix}\n    b_2 & b_3 \\\\\n    c_2 & c_3 \\\\ \n  \\end{vmatrix} \\\\\n  \\begin{vmatrix}\n    b_1 + k \\cdot c_1 & b_3 + k \\cdot c_3 \\\\\n    c_1 & c_3 \\\\ \n  \\end{vmatrix} = \n  \\begin{vmatrix}\n    b_1 & b_3 \\\\\n    c_1 & c_3 \\\\ \n  \\end{vmatrix} \\\\\n  \\begin{vmatrix}\n    b_1 + k \\cdot c_1 & b_2 + k \\cdot c_2 \\\\\n    c_1 & c_2 \\\\ \n  \\end{vmatrix} = \n  \\begin{vmatrix}\n    b_1 & b_2 \\\\\n    c_1 & c_2 \\\\ \n  \\end{vmatrix} \\\\\n\\end{gather*}\nTherefore,\n\\begin{equation*}\n\\begin{split}\n  \\begin{vmatrix}\n    a_1 & a_2 & a_3 \\\\\n    b_1 + k \\cdot c_1 & b_2 + k \\cdot c_2 & b_3 + k \\cdot c_3 \\\\\n    c_1 & c_2 & c_3 \\\\\n  \\end{vmatrix} \n  &= a_1 \\cdot \\begin{vmatrix}\n                 b_2 + k \\cdot c_2 & b_3 + k \\cdot c_3 \\\\\n                 c_2 & c_3 \\\\ \n               \\end{vmatrix} -\n     a_2 \\cdot \\begin{vmatrix}\n                 b_1 + k \\cdot c_1 & b_3 + k \\cdot c_3 \\\\\n                 c_1 & c_3 \\\\\n               \\end{vmatrix} + \\\\\n     a_3 \\cdot \\begin{vmatrix}\n                 b_1 + k \\cdot c_1 & b_2 + k \\cdot c_2 \\\\\n                 c_1 & c_2 \\\\ \n               \\end{vmatrix} \\\\\n  &= a_1 \\cdot \\begin{vmatrix}\n                 b_2 & b_3 \\\\\n                 c_2 & c_3 \\\\ \n               \\end{vmatrix} -\n     a_2 \\cdot \\begin{vmatrix}\n                 b_1 & b_3 \\\\\n                 c_1 & c_3 \\\\\n               \\end{vmatrix} + \n     a_3 \\cdot \\begin{vmatrix}\n                 b_1 & b_2 \\\\\n                 c_1 & c_2 \\\\ \n               \\end{vmatrix} \\\\\n  &= \\begin{vmatrix}\n       a_1 & a_2 & a_3 \\\\\n       b_1 & b_2 & b_3 \\\\\n       c_1 & c_2 & c_3 \\\\\n     \\end{vmatrix} \\\\\n\\end{split}\n\\end{equation*}\n\n6. Let $(x_{1}, y_{1})$ and $(x_{2}, y_{2})$ both range over all unit vectors.\nFind the maximum value of the function $f(x_{1}, x_{2}, y_{1}, y_{2}) =\n\\begin{vmatrix}\nx_{1} & y_{1} \\\\\nx_{2} & y_{2} \\\\\n\\end{vmatrix}$.\n\nSolution:\n\nAccording to the geometric interpretation of $2 \\times 2$ determinants, the \nvalue of the function $f(x_{1}, x_{2}, y_{1}, y_{2}) =\n\\begin{vmatrix}\nx_{1} & y_{1} \\\\\nx_{2} & y_{2} \\\\\n\\end{vmatrix}$ is the positive or negative value of the parallelogram formed by \nthe two unit vectors $(x_1, y_1)$ and $(x_2, y_2)$. The area of the \nparallelogram formed by these two vectors can be calculated as\n\\begin{equation*}\n\\begin{split}\n  A &= |<x_1, y_1>| \\cdot |<x_2, y_2>| \\cdot \\sin\\theta \\\\\n    &= \\sin\\theta \\\\\n\\end{split}\n\\end{equation*}\nwhere $\\theta$ is the angle between these two vectors.\n\nApparently, the maximum value of the area of the parallelogram formed by these \ntwo vectors is $1$, which is achieved when $\\theta = \\frac{\\pi}{2}$, i.e. the \ntwo unit vectors are perpendicular to each other.\n\n\\subsection*{Unit 4 Cross Product}\n\n1. Find $\\vec{A} \\times \\vec{B}$ if\\\\\na) $\\vec{A} = \\vec{i} - 2 \\vec{j} + \\vec{k}$, $\\vec{B} = 2 \\vec{i} - \\vec{j} -\n\\vec{k}$ \\\\\nb) $\\vec{A} = 2 \\vec{i} - 3 \\vec{k}$, $\\vec{B} = \\vec{i} + \\vec{j} - \\vec{k}$\n\nSolution:\n\na)\n\\begin{equation*}\n\\begin{split}\n  \\vec{A} \\times \\vec{B} \n  &= \\begin{vmatrix}\n       \\vec{i} & \\vec{j} & \\vec{k} \\\\\n       1 & -2 & 1 \\\\\n       2 & -1 & -1 \\\\\n     \\end{vmatrix} \\\\\n  &= \\vec{i} \\cdot \\begin{vmatrix}\n                     -2 & 1 \\\\\n                     -1 & -1 \\\\\n                   \\end{vmatrix} - \n     \\vec{j} \\cdot \\begin{vmatrix}\n                     1 & 1 \\\\\n                     2 & -1 \\\\    \n                   \\end{vmatrix} + \n     \\vec{k} \\cdot \\begin{vmatrix}\n                     1 & -2 \\\\\n                     2 & -1 \\\\ \n                   \\end{vmatrix} \\\\\n  &= 3\\vec{i} + 3\\vec{j} + 3\\vec{k} \\\\\n\\end{split}\n\\end{equation*}\n\nb)\n\\begin{equation*}\n\\begin{split}\n  \\vec{A} \\times \\vec{B} \n  &= \\begin{vmatrix}\n       \\vec{i} & \\vec{j} & \\vec{k} \\\\\n       2 & 0 & -3 \\\\\n       2 & 1 & -1 \\\\\n     \\end{vmatrix} \\\\\n  &= \\vec{i} \\cdot \\begin{vmatrix}\n                     0 & -3 \\\\\n                     1 & -1 \\\\\n                   \\end{vmatrix} - \n     \\vec{j} \\cdot \\begin{vmatrix}\n                     2 & -3 \\\\\n                     2 & -1 \\\\    \n                   \\end{vmatrix} + \n     \\vec{k} \\cdot \\begin{vmatrix}\n                     2 & 0 \\\\\n                     2 & 1 \\\\ \n                   \\end{vmatrix} \\\\\n  &= 3\\vec{i} - 4\\vec{j} + 2\\vec{k} \\\\\n\\end{split}\n\\end{equation*}\n\n2. Find the area of the triangle in space having its vertices at the points\n\\[ P:(2,0,1), Q:(3,1,0), R:(-1,1,-1).\\]\n\nSolution:\n\n\\begin{gather*}\n  \\vec{PQ} = <1, 1, -1> \\\\\n  \\vec{PR} = <-3, 1, -2> \\\\\n  \\begin{split}\n    \\vec{PQ} \\times \\vec{PR} \n    &= \\begin{vmatrix}\n         \\vec{i} & \\vec{j} & \\vec{k} \\\\\n         1 & 1 & -1 \\\\\n         -3 & 1 & -2 \\\\\n       \\end{vmatrix} \\\\\n    &= <-1, 5, 4> \\\\\n  \\end{split} \\\\\n  \\begin{split}\n    A &= \\frac{|\\vec{PQ} \\times \\vec{PR}|}{2} \\\\\n      &= \\frac{\\sqrt{(-1)^2 + 5^2 + 4^2}}{2} \\\\\n      &= \\frac{\\sqrt{42}}{2} \\\\\n  \\end{split} \\\\\n\\end{gather*}\nTherefore, the area of the described triangle is $\\frac{\\sqrt{42}}{2}$.\n\n3. Two vectors $\\vec{i'}$ and $\\vec{j'}$ of a right-handed coordinate system are \nto have the directions respectively of the vectors $\\vec{A} = 2\\vec{i} - \\vec{j}$ \nand $\\vec{B} = \\vec{i} + 2\\vec{j} + \\vec{k}$. Find all three vectors\n$\\vec{i'}$, $\\vec{j'}$, $\\vec{k'}$.\n\nSolution:\n\nAccording to the problem description, $\\vec{i'}$ is the direction of the vector \n$\\vec{A} = 2\\vec{i} - \\vec{j}$, hence\n\\begin{equation*}\n\\begin{split}\n  \\vec{i'} &= \\frac{\\vec{A}}{|\\vec{A}|} \\\\\n           &= \\frac{<2, -1, 0>}{\\sqrt{5}} \\\\\n           &= <\\frac{2\\sqrt{5}}{5}, -\\frac{\\sqrt{5}}{5}, 0> \\\\\n\\end{split}\n\\end{equation*}\n\nSimilarly, since $\\vec{j'}$ is the direction of the vector \n$\\vec{B} = \\vec{i} + 2\\vec{j} + \\vec{k}$,\n\\begin{equation*}\n\\begin{split}\n  \\vec{j'} &= \\frac{\\vec{B}}{|\\vec{B}|} \\\\\n           &= \\frac{<1, 2, 1>}{\\sqrt{6}} \\\\\n           &= <\\frac{\\sqrt{6}}{6}, \\frac{2\\sqrt{6}}{6}, \\frac{\\sqrt{6}}{6}> \\\\\n\\end{split}\n\\end{equation*}\nAccording to the geometric interpretation of cross product,\n\\begin{gather*}\n  \\begin{split}\n    \\vec{A} \\times \\vec{B}\n    &= \\begin{vmatrix}\n         \\vec{i} & \\vec{j} & \\vec{k} \\\\\n         2 & -1 & 0 \\\\\n         1 & 2 & 1 \\\\\n       \\end{vmatrix} \\\\\n    &= <-1, -2, 5>\n  \\end{split} \\\\\n  \\begin{split}\n    \\vec{k'} &= dir(\\vec{A} \\times \\vec{B}) \\\\\n             &= \\frac{\\vec{A} \\times \\vec{B}}{|\\vec{A} \\times \\vec{B}|} \\\\\n             &= \\frac{<-1, -2, 5>}{\\sqrt{30}} \\\\\n             &= <-\\frac{\\sqrt{30}}{30}, -\\frac{\\sqrt{30}}{15}, \\frac{\\sqrt{30}}{6}> \\\\\n  \\end{split}\n\\end{gather*}\n\n4. Verify that the cross product $\\times$ does not in general satisfy the\nassociative law, by showing that for the particular vectors $\\vec{i}$,\n$\\vec{j}$, $\\vec{k}$, we have $(\\vec{i} \\times \\vec{j}) \\times \\vec{k} \\neq\n\\vec{i} \\times (\\vec{j} \\times \\vec{k})$.\n\nSolution:\n\nSuppose that $\\vec{i} = <1, 0, 1>$, $\\vec{j} = <1, 1, 0>$, and \n$\\vec{k} = <0, 1, 1>$.\nThen\n\\begin{gather*}\n  (\\vec{i} \\times \\vec{j}) \\times \\vec{k} = <0, 1, -1> \\\\\n  \\vec{i} \\times (\\vec{j} \\times \\vec{k}) = <1, 0, -1> \\\\\n\\end{gather*}\nHence, the cross product does not in general satisfy the associative law.\n\n5. What can you conclude about $\\vec{A}$ and $\\vec{B}$\\\\\na) if $|\\vec{A} \\times \\vec{B}| = |\\vec{A}| |\\vec{B}|$;\\\\\nb) if $|\\vec{A} \\times \\vec{B}| = \\vec{A} \\cdot \\vec{B}$.\n\nSolution:\n\na) According to the geometric interpretation of cross product, \n$|\\vec{A} \\times \\vec{B}|$ is the area of the parallelogram formed by the \nvectors $\\vec{A}$ and $\\vec{B}$. Therefore,\n\\[\n  |\\vec{A} \\times \\vec{B}| = |\\vec{A}| |\\vec{B}| \\sin\\theta\n\\]\nwhere $\\theta$ is the angle between the vectors $\\vec{A}$ and $\\vec{B}$.\n\nThen if $|\\vec{A} \\times \\vec{B}| = |\\vec{A}| |\\vec{B}|$,\n\\begin{gather*}\n  |\\vec{A} \\times \\vec{B}| = |\\vec{A}| |\\vec{B}| \\\\\n  |\\vec{A}| |\\vec{B}| \\sin\\theta = |\\vec{A}| |\\vec{B}| \\\\\n  \\sin\\theta = 1 \\\\\n  \\theta = \\frac{\\pi}{2} \\\\\n\\end{gather*}\nWe can conclude that the angle between the vectors $\\vec{A}$ and $\\vec{B}$ is \n$\\frac{\\pi}{2}$.\n\nb) Similar to Exercise a), if \n$|\\vec{A} \\times \\vec{B}| = \\vec{A} \\cdot \\vec{B}$,\n\\begin{gather*}\n  |\\vec{A} \\times \\vec{B}| = \\vec{A} \\cdot \\vec{B} \\\\\n  |\\vec{A}| |\\vec{B}| \\sin\\theta = |\\vec{A}| |\\vec{B}| \\cos\\theta \\\\\n  \\sin\\theta = \\cos\\theta \\\\\n  \\theta = \\frac{pi}{4} \\\\\n\\end{gather*}\nWe can conclude that the angle between the vectors $\\vec{A}$ and $\\vec{B}$ is \n$\\frac{\\pi}{4}$.\n\n6. Find the volume of the tetrahedron having vertices at the four points\n\\[ P:(1,0,1), Q:(-1,1,2), R:(0,0,2), S:(3,1,-1).\\]\n\nSolution:\n\n\\begin{gather*}\n  \\vec{PQ} = <-2, 1, 1> \\\\\n  \\vec{PR} = <-1, 0, 1> \\\\\n  \\vec{PS} = <2, 1, -2> \\\\\n\\end{gather*}\n\nAccording to the geometric interpretation of $3 \\times 3$ determinants, the \nvolume of the tetrahedron with the described vertices can be calculated as\n\\begin{gather*}\n  \\begin{split}\n    det(\\vec{PQ}, \\vec{PR}, \\vec{PS}) \n    &= \\begin{vmatrix}\n         -2 & 1 & 1 \\\\\n         -1 & 0 & 1 \\\\\n         2 & 1 & -2 \\\\\n       \\end{vmatrix} \\\\\n    &= -2 \\times (-1) - 1 \\times 0 + 1 \\times (-1) \\\\\n    &= 1\n  \\end{split} \\\\\n  \\begin{split}\n    V &= |det(\\vec{PQ}, \\vec{PR}, \\vec{PS})| \\\\\n      &= 1 \\\\\n  \\end{split} \\\\\n\\end{gather*}\nTherefore, the volume of the described tetrahedron is 1.\n\n\\begin{center}\n\\section*{Part II}\n\\end{center}\n\n1. Find the dihedral angle between two faces of a regular tetrahedron.\n\nSolution:\n\n\\begin{definition}\n  A dihedral angle is the angle between two intersecting planes or half-planes.\n\\end{definition}\n\n\\begin{definition}\n  A regular tetrahedron is a tetrahedron in which all four faces are equilateral \n  triangles.\n\\end{definition}\n\n\\begin{definition}\n  In geometry, an equilateral triangle is a triangle in which all three sides \n  have the same length.\n\\end{definition}\n\n\\begin{tikzpicture}\n  [help line/.style={dashed}]\n  \\draw[->] (-3, 0, 0) -- (3, 0, 0) node[below right] {x};\n  \\draw[->] (0, -1, 0) -- (0, 3, 0) node[right] {y};\n  \\draw (0, 0) node[below right] {O};\n  \\draw[-] (-1, 0, 0) -- (1, 0, 0);\n  \\draw[-] (-1, 0, 0) -- (0, 1.732, 0);\n  \\draw[-] (1, 0, 0) -- (0, 1.732, 0);\n  \\draw (0, 1.732) node[above] {A};\n  \\draw (-1, 0) node[left] {B};\n  \\draw (1, 0) node[right] {C};\n  \\draw[help line] (0, 1.732, 0) -- (0, 0, 0);\n  \\draw[help line] (-1, 0, 0) -- (0.5, 0.866, 0);\n  \\draw[help line] (1, 0, 0) -- (-0.5, 0.866, 0);\n  \\draw (0, 0.577) node[below right] {S'};\n\\end{tikzpicture}\n\nSuppose that there is a regular tetrahedron whose length is 2. Let A, B, C, S \ndenote the four vertices of the tetrahedron, and we'll build a Cartesian \ncoordinate system as shown in the diagram.\n\nAccording to the geometric property of a regular tetrahedron, we can get \nthe coordinates of the four vertices:\n\\[ A = (0, \\sqrt{3}, 0), B = (-1, 0, 0), C = (1, 0, 0), S = (0, \\frac{\\sqrt{3}}{3}, \\frac{2\\sqrt{3}}{3})\\]\n\nTo calculate the dihedral angle between two planes, we can find a point on the \nintersection line, and from that point find two lines in two planes respectively \nwhich is perpendicular to the intersection line. \n\nIn this case, we 'll try to find the dihedral angle between the plane $ABC$ and \n$SBC$, using the point $O$ as the starting point and hence $BC$ as the \nintersection line. According to the geometric property of equilateral triangles:\n\\[ OA \\perp BC, OS \\perp BC \\]\nTherefore, the dihedral angle between the plane $ABC$ and $SBC$ is the angle \n$\\angle{AOS}$ between the line $OA$ and $OS$.\n\\begin{gather*}\n  \\vec{OA} = <0, \\sqrt{3}, 0> \\\\\n  \\vec{OS} = <0, \\frac{\\sqrt{3}}{3}, \\frac{2\\sqrt{3}}{3}> \\\\\n  \\begin{split}\n    \\cos\\angle{AOS} &= \\frac{\\vec{OA} \\cdot \\vec{OS}}{|\\vec{OA}| \\cdot |\\vec{OS}|} \\\\\n                    &= \\frac{0 \\times 0 + \\sqrt{3} \\times \\frac{\\sqrt{3}}{3} + 0 \\times \\frac{2\\sqrt{3}}{3}}{\\sqrt{3} \\times \\sqrt{(\\frac{\\sqrt{3}}{3})^2 + (\\frac{2\\sqrt{3}}{3})^2}} \\\\\n                    &= \\frac{\\sqrt{5}}{5} \\\\\n  \\end{split} \\\\\n  \\angle{AOS} = cos^{-1}(\\frac{\\sqrt{5}}{5}) \\\\\n\\end{gather*}\nTherefore, the dihedral angle between two faces of a regular tetrahedron is \n$cos^{-1}(\\frac{\\sqrt{5}}{5})$.\n\n2. a) Show that the 'polarization identity'\n$\\frac{1}{4}(|\\vec{u} + \\vec{v}|^{2} - |\\vec{u} - \\vec{v}|^{2}) = \\vec{u} \\cdot \\vec{v}$ \nholds for any two n-vectors $\\vec{u}$ and $\\vec{v}$. (Use vector algebra, not \ncomponents.) \\\\\nb) Given two non-zero vectors $\\vec{u}$ and $\\vec{v}$, give the formula for the\nunit vector which bisects the (smaller) angle between $\\vec{u}$ and $\\vec{v}$.\n(Use the notation $\\hat{\\vec{u}}$ for the unit vector in the $\\vec{u}$ -\ndirection.)\n\nSolution:\n\na) Proof:\n\\begin{gather*}\n  \\begin{split}\n    \\frac{1}{4}(|\\vec{u} + \\vec{v}|^{2} - |\\vec{u} - \\vec{v}|^{2}) &= \\frac{1}{4}((\\vec{u} + \\vec{v})^2 - (\\vec{u} - \\vec{v})^2) \\\\\n                                                                   &= \\frac{1}{4}((\\vec{u}^2 + \\vec{v}^2 + 2\\vec{u} \\cdot \\vec{v}) - (\\vec{u}^2 + \\vec{v}^2 - 2\\vec{u} \\cdot \\vec{v})) \\\\\n                                                                   &= \\frac{1}{4}(4\\vec{u} \\cdot \\vec{v}) \\\\\n                                                                   &= \\vec{u} \\cdot \\vec{v} \\\\\n  \\end{split} \\\\\n\\end{gather*}\n\nb) According to the geometric interpretation of the addition of vectors, for two \nunit vectors $\\vec{a}$ and $\\vec{b}$, the vector $\\vec{a} + \\vec{b}$ bisects the \n(smaller) angle between $\\vec{a}$ and $\\vec{b}$ because $\\vec{a}$, $\\vec{b}$, \nand $\\vec{a} + \\vec{b}$ would form an isosceles triangle where the $\\vec{a}$ and \n$\\vec{b}$ are the two side that have equal lengths.\n\nTherefore, to find the unit vector which bisects the (smaller) angle between \n$\\vec{u}$ and $\\vec{v}$, we can find the unit vector which bisects the (smaller) \nangle between $\\hat{\\vec{u}}$ and $\\hat{\\vec{v}}$, which is\n\\begin{gather*}\n  \\begin{split}\n    \\vec{w} &= \\frac{\\hat{\\vec{u}} + \\hat{\\vec{v}}}{|\\hat{\\vec{u}} + \\hat{\\vec{v}}|} \\\\\n            &= \\frac{\\frac{\\vec{u}}{|\\vec{u}|} + \\frac{\\vec{v}}{|\\vec{v}|}}{\\sqrt{(\\frac{\\vec{u}}{|\\vec{u}|} + \\frac{\\vec{v}}{|\\vec{v}|})^2}} \\\\\n            &= \\frac{\\frac{|\\vec{v}| \\cdot \\vec{u} + |\\vec{u}| \\cdot \\vec{v}}{|\\vec{u}| \\cdot |\\vec{v}|}}{\\sqrt{2 + 2\\frac{\\vec{u} \\cdot \\vec{v}}{|\\vec{u} \\cdot |\\vec{v}|}}} \\\\\n            &= \\frac{|\\vec{v}| \\cdot \\vec{u} + |\\vec{u}| \\cdot \\vec{v}}{\\sqrt{2|\\vec{u}|^2 \\cdot |\\vec{v}|^2 + 2|\\vec{u}||\\vec{v}|\\vec{u} \\cdot \\vec{v}}}\n  \\end{split} \\\\\n\\end{gather*}\n\n3. In this problem we examine tacking, which is the process sailboats use to\ntravel against the wind. Sails are a familar tool to harness the energy of the\nwind for transportation over the sea. Early ships had large fixed sails which\nwould capture the wind blowing from behind to propel the ship forward. Even if\nthe wind is blowing behind at an (acute) angle the component of the wind vector\nperpendicular to the sail will push on the sail and hence on the boat. However,\nthese early fixed sail ships had no way to go against the wind and had to rely\non oarsmen if the wind was blowing in the wrong direction.\n\nA great advance that allowed boats to sail against the wind was the invention\nof movable sails in combination with a rudder and a keel. By carefully\npositioning the sail the boat can be made to sail into the wind - this process\nis called \\emph{tacking}.\n\nAs noted before, the component of the wind perpendicular to the sail pushes on\nthe sail and, through it, the boat. The keel only allows the boat to move along\nits axis. (The rudder is used to turn the boat.) That is, for any force on the\nboat, only the component along the boat's axis actually pushes the boat.\n\nDescribed mathematically, the wind vector is first projected on the\nperpendicular to the sail to get the direction of the force on the sail. This\nresultant force is projected on the axis of the boat to find the direction the\nboat is being pushed. By orienting the sail correctly this double projection\ncan result in a vector with a component pointing into the wind.\n\n\\begin{tikzpicture}\n  [help line/.style={dashed}]\n  \\draw[help line] (-3, 0, 0) -- (3, 0, 0) node[right] {x};\n  \\draw[help line] (0, -3, 0) -- (0, 3, 0) node[above] {y};\n  \\draw[->] (0, 0, 0) -- (2, 0, 0) node[below] {$\\vec{w} = a\\vec{i}$};\n  \\draw[-] (-1, -1.732, 0) -- (1, 1.732, 0) node[above right] {$l_s$};\n  \\draw[-] (1, -1.732, 0) -- (-1, 1.732, 0) node[above left] {$l_B$};\n  \\draw (0, 0, 0) node[above right] {$\\alpha$};\n  \\draw (0, 0, 0) node[above] {$\\beta$};\n\\end{tikzpicture}\n\nIn the picture $\\vec{w} = a \\vec{i}$ is the wind direction. The line $l_s$ is \nperpendicular to the sail (with $0 \\leq \\alpha \\leq \\frac{\\pi}{2}$). And the \nline $l_B$ is along the boat's axis (with $0 \\leq \\beta \\leq \\frac{\\pi}{2}$).\n\na) Let $\\vec{w_1}$ be the projection of $\\vec{w}$ onto the line $l_s$. Show that \n$\\vec{w_1}$ does not have a non-zero component in the direction opposite \n$\\vec{w}$. (It is sufficient to show the projections on the sketch.)\n\nb) Find the projection of $\\vec{w_{1}}$ onto $l_{B}$. (Give an explicit formula\nin terms of $\\alpha$ and $\\beta$.) What is the condition on $\\alpha$ and $\\beta$\nthat this projection has a component in the $-\\vec{i}$ direction? (For warmup\nyou might try the specific case $\\alpha = \\frac{\\pi}{3} = \\beta$.)\n\nSolution:\n\na) According to the definition of additions and decomposition of vectors, the \nprojection $\\vec{w_1}$ of $\\vec{w}$ along the line $l_s$ must have an acute \nangle, which is $\\alpha$, with $\\vec{w}$. Therefore, $\\vec{w_1}$ has an obtuse \nangle with the reverse direction of $\\vec{w}$. Therefore, according to the rule \nof vector decomopsition, $\\vec{w_1}$ cannot have a non-zero component on the \nreverse direction of $\\vec{w}$. \n\nb) Let $\\vec{w_B}$ denote the projection vector of $\\vec{w_1}$ onto $l_B$. Then\n\\begin{gather*}\n  \\begin{split}\n    |\\vec{w_B}| &= |\\vec{w_1}| \\cos\\beta \\\\\n                &= |\\vec{w}| \\cos\\alpha \\cos\\beta \\\\\n                &= a \\cos\\alpha \\cos\\beta \\\\\n  \\end{split} \\\\\n\\end{gather*}\nFrom geometric point of view, for the projection of $\\vec{w_B}$ on the x axis, \nwe can see from the diagram that if $l_B$ passes the second quadrant, \n$\\vec{w_B}$ would has a non-zero component along the reverse direction of \n$\\vec{i}$. Therefore, the condition is that $\\alpha + \\beta > \\frac{\\pi}{2}$.\n\nFrom analytical point of view, the component of $\\vec{w_B}$ on the $-\\vec{i}$ \ndirection can be calculated as\n\\begin{gather*}\n  \\begin{split}\n    |\\vec{w_B}| \\cos(\\pi - \\alpha - \\beta) = -|\\vec{w_B}| \\cos(\\alpha + \\beta)\n  \\end{split}\n\\end{gather*}\nTherefore, to make sure the component on the $-\\vec{i}$ direction is non-zero, \nthe condition is:\n\\begin{itemize}\n  \\item $|\\vec{w_B}|$ is non-zero, which is guaranteed by the values of $a$, \n    $\\alpha$ and $\\beta$.\n  \\item $\\cos(\\alpha + \\beta) < 0$, which is equivalent to \n    $\\alpha + \\beta > \\frac{\\pi}{2}$.\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "607a27fe334695a2a76f0eb4bcf2fcfff11c5526", "size": 46060, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pset1.tex", "max_stars_repo_name": "jinxinwangstd/multivariable-calculus-mit", "max_stars_repo_head_hexsha": "d165ef6ff085fafd0fb89b8027fc5f5e0dbfa1e9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pset1.tex", "max_issues_repo_name": "jinxinwangstd/multivariable-calculus-mit", "max_issues_repo_head_hexsha": "d165ef6ff085fafd0fb89b8027fc5f5e0dbfa1e9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pset1.tex", "max_forks_repo_name": "jinxinwangstd/multivariable-calculus-mit", "max_forks_repo_head_hexsha": "d165ef6ff085fafd0fb89b8027fc5f5e0dbfa1e9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1185185185, "max_line_length": 185, "alphanum_fraction": 0.5450282241, "num_tokens": 17684, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.42301153394256424}}
{"text": "% this file is called up by thesis.tex\n% content in this file will be fed into the main document\n\n\\chapter{Compression model}\n\\label{ch:exprlang}\n\n\n% ----------------------- paths to graphics ------------------------\n\n\\graphicspath{{4_expression_language/images/}}\n\n% ----------------------- contents from here ------------------------\n% \n\n\\textit{Whitebox compression} is a compression model for columnar database systems. Its purpose is to represent data more compactly through elementary operator expressions. These operators---chained together into expression trees---form the expression language used for data representation. This chapter describes the \\textit{whitebox compression} model, its expression language and operators, the structure of expression trees and their evaluation.\n\n\\section{Expression language}\n\\label{sec:exprlang:exprlang}\n\nThe \\textit{whitebox} compression model represents logical columns as composite functions of physical columns. We refer to these functions as \\textit{operators}. With respect to databases, logical columns are columns as seen by the database user, containing the data in its original format. Physical columns contain the physical representation of the data as it is stored on disk, in a different format.\n\nFormally, we define an operator as a function \\(o\\) that takes as input zero or more columns and optional metadata information and outputs a column: \n\\begin{equation}\n\\label{eq:exprlang:exprlang:operator}\n    o \\colon [C \\times C \\times ...] \\times [M] \\to C\n\\end{equation}\n\nThe domain of \\(o\\) is composed of columns and metadata and the codomain is columns. A column is defined by its datatype \\(d\\) and the values that it contains \\(V\\). The metadata is structured information of any type.\n\nWe defined our expression language based on a set of elementary column representation types, each having an associated operator. They are listed in Table~\\ref{tab:exprlang:exprlang_1}.\n\n\\input{4_expression_language/expression_language-table_1.tex}\n\nThe concatenation of two string columns \\(c_a\\) and \\(c_b\\) is the concatenation of each pair of values \\(v_a\\) and \\(v_b\\). E.g. \\(\\verb|\"123abc\"| = \\mathit{concat}(\\verb|\"123\"|, \\verb|\"abc\"|)\\), where \\(v_a = \\verb|\"123\"|\\) and \\(v_b = \\verb|\"abc\"|\\). The representation of a string column \\(c_a\\) as a formatted non-string column \\(c_b\\) consists of the individual values \\(v_b\\) formatted as strings based on the format string metadata \\(m_{\\mathit{format}}\\). This can be seen as datatype change. E.g. \n\\(\\verb|\"-12000\"| = \\mathit{format}(\\verb|-12000|, \\verb|\"%d\"|)\\), where \\(v_b = \\verb|-12000|\\)\nand \n\\(m_{\\mathit{format}} = \\verb|\"%d\"|\\)\n. The direct mapping representation of a column \\(c_a\\) as a column \\(c_b\\) through the mapping \\(m_{map}\\) is a key-value lookup in a dictionary-like data structure. E.g. \\(\\verb|\"valueoncolumnA\"| = dict[\\verb|\"valueoncolumnB\"|]\\), where \\verb|valueoncolumnB| is the key and \\verb|\"valueoncolumnA\"| is the value in the dictionary \\verb|dict|. The constant representation of a column indicates that all its values are equal to the constant value \\(m_{\\mathit{const}}\\). The \\(\\mathit{const}\\) operator just returns \\(m_{\\mathit{const}}\\).\n\nThese operators and transformations can be composed, resulting in operator expressions. For example, the logical columns \\(A\\) and \\(B\\) in Table~\\ref{tab:exprlang:exprlang_2}, can be represented as composite functions of the physical columns in Table~\\ref{tab:exprlang:exprlang_2}, through the following expressions:\n\\begin{equation}\n\\label{eq:exprlang:exprlang:example}\n\\begin{array}{ll}\n    A &= \\mathit{concat}(\\mathit{map}(P, {dict_{AP}}), \\mathit{const}(\\verb|\"_\"|), \\mathit{format}(Q, \\verb|\"%d\"|))\\\\\n    B &= \\mathit{map}(P, {dict_{BP}})\n\\end{array}\n\\end{equation}\n\n\\input{4_expression_language/expression_language-table_2_3.tex}\n\nWe observe that column \\(A\\) has the following structure: a dictionary compressible prefix and a numeric suffix, separated by a the '\\verb|_|' character. If we store these logical parts separated into 3 columns \\(C_{\\mathit{prefix}}\\), \\(C_{\\mathit{delim}}\\), \\(C_{\\mathit{suffix}}\\), we can represent column \\(A\\) as their concatenation. Since \\(C_{\\mathit{prefix}}\\) has repeated values, we can represent it more compactly as the mapping of column \\(P\\)---containing dictionary keys---and the dictionary \\(dict_{AP}\\)---presented in Table~\\ref{tab:exprlang:exprlang_3}. We can represent \\(C_{\\mathit{delim}}\\) through the \\textit{const} operator since all its values are equal to '\\verb|_|'. \\(C_{\\mathit{suffix}}\\) contains numbers stored in strings. We can store these values more compactly as numbers, by changing the column datatype. Therefore, we represent \\(C_{\\mathit(suffix)}\\) based on the numeric column \\(Q\\), through the \\(format\\) operator, with the format string \\verb|\"%d\"|. We move our attention to column \\(B\\) and observe that it is correlated with column \\(C_{\\mathit{prefix}}\\)---and implicitly also to column \\(P\\). We can therefore represent \\(B\\) as the mapping of column \\(P\\) and the dictionary \\(dict_{BP}\\)---presented in Table~\\ref{tab:exprlang:exprlang_3}. In the end, we store only the physical columns \\(P\\) and \\(Q\\) and the metadata: \\(dict_{AP}\\), \\(dict_{BP}\\) and the constant string \\verb|\"_\"|. The original values on the logical columns \\(A\\) and \\(B\\) can be reconstructed by evaluating the expressions in Equation~\\ref{eq:exprlang:exprlang:example}.\n\nSo far, we described 4 column representation types and their associated operators: \\(concat\\), \\(format\\), \\(map\\) and \\(const\\). The \\textit{whitebox compression} model does not limit itself to these representation types. It is a generic model and supports any type of column operators (e.g. mathematical operators like addition or multiplication). A practical example is the \\textit{whitebox} version of the Frame of Reference compression method: \\(const(\\mathit{reference}) + C_{\\mathit{diff}}\\), where \\(+\\) is the numeric addition/sum operator, \\(\\mathit{reference}\\) is the reference value and \\(C_{\\mathit{diff}}\\) is the physical column containing the differences between the original values and \\(\\mathit{reference}\\).\n\nThe purpose of \\textit{whitebox compression} is to represent data more compactly through elementary operator expressions similar to the ones presented above. However, there are a multitude of different possible representations of the same logical columns, each one giving a different result. We will describe the optimization problem of finding the best representation for a set of columns in \\ref{subsec:learningprocess:optimizationproblem}~\\nameref{subsec:learningprocess:optimizationproblem}.\n\nThese operator expressions create more compact representations of logical columns, exploiting the underlying compression opportunities in the data. We showed how we can remove redundancy from data by representing columns as functions of other columns through the \\(map\\) operator and how we can store numeric values in more suitable datatypes through the \\(format\\) operator. We are able to decompose string columns into subcolumns with values from different distributions, thus enabling independent representations. Finally, the key factor of the \\textit{whitebox} model is that it allows recursive representation of columns, ultimately leading to improved compression ratios.\n\n\\section{Expression tree}\n\\label{sec:exprlang:exprtree}\n\nThe operators presented so far are useful for describing the data representation and for transforming the physical data into its original logical format. We call this process \\textit{decompression}. In practice, we need to transform the logical data into its physical format first---\\textit{compression}. The compression process requires a different expression, one that represents the physical columns as functions of the logical columns, through the inverse operators of the ones presented until now. Table~\\ref{tab:exprlang:exprlang_4} presents the compression operators types.\n\n\\input{4_expression_language/expression_language-table_4.tex}\n\nAll these operator types and their practical implementations will be discussed in detail in \\ref{sec:pd}~\\nameref{sec:pd}. For now, we are interested in their definition. We notice how the formal definition of the compression operator is different from the one of the compression operators:\n\\begin{equation}\n\\label{eq:exprlang:exprtree:operator:comp}\n    o \\colon C \\times [M] \\to [C \\times C \\times ...]\n\\end{equation}\n\nThe compression operators take as input a single column and compression metadata information and output 0 or more columns. Because of the multiple column output, representing physical columns as composite functions of logical columns is not straightforward. Therefore, we introduce the concept of \\textit{expression trees}, as an alternative representation instead of the nested operator expressions.\n\n\\textit{Expression trees} are tree-like structures with 2 types of nodes: \\textit{column nodes} and \\textit{operator nodes}. We also use the term \\textit{expression node} to refer to the \\textit{operator nodes}---they are interchangeable. An \\textit{expression tree} is composed of alternating levels of \\textit{column} and \\textit{operator} nodes. Root nodes are always \\textit{column nodes}. Leaf nodes can be either \\textit{column nodes} or \\textit{operator nodes}---in the case of operators that do not output any column. An \\textit{operator node} in an \\textit{expression tree} is the equivalent of and operator in an operator expression: it has input columns---connected through incoming edges---and output columns---connected through outgoing edges. \\textit{Expression trees} are used in the compression and decompression processes as more practical alternatives to the operator expressions. To better understand the similarities between the two, we created the equivalent \\textit{expression tree} of the operator expressions for columns \\(A\\) and \\(B\\) in Equation~\\ref{eq:exprlang:exprlang:example}. Recall the expressions: \\(A = \\mathit{concat}(\\mathit{map}(P, {dict_{AP}}), \\mathit{const}(\\verb|\"_\"|), \\mathit{format}(Q, \\verb|\"%d\"|))\\) and \\(B = \\mathit{map}(P, {dict_{BP}})\\). The equivalent \\textit{expression tree} is presented in Figure~\\ref{fig:exprlang:exprtree:tree_1}.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width={0.9\\linewidth}]{expression_language-tree_1_1.pdf}\n  \\caption{Expression tree representation}\n  \\label{fig:exprlang:exprtree:tree_1}\n\\end{figure}\n\nThe first thing to notice is that the \\textit{expression tree} is not actually a tree, but a directed acyclic graph (DAG) with 2 root nodes. However, we chose to stick to the term \\textit{expression tree} instead of graph, since it is more intuitive. In this case the graph is connected, but in other cases it can have multiple connected components. For example, imagine that in our example we had an additional logical column \\(C\\) that is represented as a function of a physical column \\(S\\), without any connection with the columns or operators used to represent columns \\(A\\) and \\(B\\). Then, our graph will have 2 connected components. \n\nBesides the graph-like structure, the \\textit{expression tree} is an equivalent representation of the operator expressions. We notice the similarities between the operator nodes and the operators in the nested expressions and the alternating levels of columns and operators. A noticeable difference is the additional columns \\(A_{\\mathit{prefix}}\\), \\(A_{\\mathit{delim}}\\) and \\(A_{\\mathit{suffix}}\\). These are non-materialized internal columns that make the recursive representation possible. In terms of representation type, this is a \\textit{decompression tree}, since the root nodes are the physical columns \\(P\\) and \\(Q\\) and the expression nodes are decompression operators. The \\textit{compression tree} will have the same structure, only that the root nodes will be the logical columns \\(A\\) and \\(B\\) and the expression nodes will be compression operators---the inverse functions of the decompression operators. The metadata will also differ. The \\textit{compression tree} can be derived from the \\textit{decompression tree} and vice versa, by using the inverse operators and transforming the metadata where it is necessary.\n\nThere is the case that different subsets of the values on a column come from different distributions and cannot be represented through the same expression. E.g. a string column where odd rows contain the same constant value and even rows are numbers. These situations are common in real data, as we have seen in the Public BI benchmark, where there are not many columns for which a single representation perfectly fits all the values. One option to accommodate these cases is to allow a single column to have multiple representations. The representation of the column is then the union of its multiple representations. In terms of \\textit{decompression trees}, the column will have multiple incoming edges, each one from a different operator. These multi-representation structures need to be explicitly handled in the \\textit{expression tree} evaluation process (described in \\ref{sec:exprlang:compdecomp}~\\nameref{sec:exprlang:compdecomp}). The second option of handling these cases is through recursive representation of \\textit{exception columns}, which is discussed in \\ref{sec:exprlang:exceptions}~\\nameref{sec:exprlang:exceptions}.\n\n\\section{Exception handling}\n\\label{sec:exprlang:exceptions}\n\nWhile analyzing the Public BI benchmark in search for patterns and \\textit{whitebox compression} opportunities we noticed that columns where all values perfectly fit the same pattern/representation are not very common. Instead there is a smaller or larger subset of values that do not fit the dominant pattern of the column. Let us take for example the data in Table~\\ref{tab:exprlang:exprlang_2}. Image that a few values on column \\(A\\) did not have the \\verb|prefix-delim-suffix| structure and instead they were just arbitrary strings. Then, the representation in Figure~\\ref{fig:exprlang:exprtree:tree_1} could not be applied on the entire column. We call these values that do not match the representation: \\textit{exceptions}. In the \\textit{whitebox compression} model \\textit{exceptions} are stored on separate \\textit{exception columns}. These are nullable columns that contain \\verb|null| on positions where the value was not an exception and the original values otherwise. Conversely, the non-exception columns are also nullable and contain null on the positions of exceptions.\n\nWe defined 2 ways of handling \\textit{exceptions}: 1) through the multi-representation approach mentioned in \\ref{sec:exprlang:exprlang}~\\nameref{sec:exprlang:exprlang}; 2) through recursive representation of \\textit{exception columns}. The first option implies having an operator expression for each subset of values that requires a separate representation. The second option implies choosing a single representation, storing \\textit{exceptions} on a separate \\textit{exception column} and then recursively applying the same process on the \\textit{exceptions}. The two options are equivalent from the physical data perspective. Only the shape of the tree differs: flat and wide trees in the first case and deeper trees in the second case. An additional difference between the two options is the number of \\textit{exception columns}: the first option requires at most one \\textit{exception column} for every logical column (to store values that do not fit any pattern), while the second option implies having a separate \\textit{exception column} for each operator node in the expression tree. The two approaches are illustrated in Figure~\\ref{fig:exprlang:exceptions}.\n\n\\begin{figure}[h]\n\\centering\n\\makebox[\\textwidth][c]{\n\\begin{subfigure}[t]{0.49\\linewidth}\n  \\centering\n  \\includegraphics[width={1.0\\linewidth}]{4_expression_language/images/expression_language-exceptions_1_option_1.pdf}\n  \\caption{Multi-representation}\n  \\label{fig:exprlang:exceptions:option1}\n\\end{subfigure}\n\\hspace{3em}\n\\begin{subfigure}[t]{0.31\\linewidth}\n  \\centering\n  \\includegraphics[width={1.0\\linewidth}]{4_expression_language/images/expression_language-exceptions_1_option_2.pdf}\n  \\caption{Recursive exception representation}\n  \\label{fig:exprlang:exceptions:option2}\n\\end{subfigure}\n}\n\\caption{Representation options \\& exception handling}\n\\label{fig:exprlang:exceptions}\n\\end{figure}\n\nFigure~\\ref{fig:exprlang:exceptions} shows the 2 equivalent representations of a string column \\(A\\), which has 2 major subsets of values: one containing numeric values and the other one a constant value. The figure on the left shows the multi-representation approach: the 2 operators are on the same level of the tree and the exceptions---i.e. the values that do not fit any of the 2 representations---are stored separately in the \\(A_{\\mathit{exception}}\\) column. \\(A_{\\mathit{numeric}}\\) and \\(A_{\\mathit{exception}}\\) are both physical columns. The figure on the right shows the recursive exception representation: the subset of numeric values are represented through the \\(format\\) operator and the rest are rejected to the \\textit{exception column} \\(X_{\\mathit{format}}\\). \\(X_{\\mathit{format}}\\) now contains the subset of constant values, and is represented through the \\(const\\) operator. The remaining values which are not constant are stored in the \\(X_{\\mathit{const}}\\) \\textit{exception column}. The physical columns in this case are \\(A_{\\mathit{numeric}}\\) and \\(X_{\\mathit{const}}\\), while \\(A_{\\mathit{format}}\\) is just an intermediate non-materialized \\textit{exception column}. The 2 representations are equivalent in terms of the physical data structure: the numeric values are stored in \\(A_{\\mathit{numeric}}\\) and the exceptions---values that are neither numeric nor constant---are stored in the \\(A_{\\mathit{exception}}\\) respectively \\(X_{\\mathit{const}}\\) column.\n\nIn our implementation we used a combination of the 2 approaches: select the dominant patterns in the data and represent each column through multi-representation expressions and then store the rest of the values---which do not fit the representations---in \\textit{exception columns}. If there are more opportunities left in the exceptions, recursive representation of the \\textit{exception columns} is implicitly performed by the compression learning algorithm, since they are treated as normal columns.\n\n\\iffalse\n- exceptions can also contain patterns; can be recursively compressed with other methods\n- 2 options: 1) a single exception column per logical column (unable to recursively compress exceptions, thus we need multi-representation structures in the tree); 2) an exception column for each operator: allowing recursive compression of exceptions and implicitly used multiple representations for the same column\n\\fi\n\n\\section{Compression and decompression}\n\\label{sec:exprlang:compdecomp}\n\nThe evaluation of a \\textit{compression tree} on a set of logical columns---i.e. \\textit{compression}---means applying the operators on the logical values in order to generate the physical values that will be stored in the physical columns. Conversely, the evaluation of a \\textit{decompression tree} on a set of physical columns---i.e. \\textit{decompression}---is the process of applying the operators on the physical values to obtain the original data. The 2 process are similar and we will further discuss only \\textit{decompression}.\n\nGiven a table with multiple logical columns, its expression tree (graph) will have 1 or more connected components. Each component can be evaluated independently from the other components. The decompression process starts from the root nodes and evaluates the operators on the path to the target logical/physical column, in topological order. In the case of \\textit{decompression}, exceptions are handled by checking for \\verb|null| values on the \\textit{exception column}. If the value at a given position on the \\textit{exception column} is not \\verb|null| then it was an exception, otherwise the operator needs to be evaluated. A special case is when a logical data value is \\verb|null| and also an exception. For this case we use a bitmap indicating which values were \\verb|null| in the first place. In the case of \\textit{compression}, the operators are responsible for deciding which values are exceptions and which are not: if an operator throws an exception then the value is stored on the \\textit{exception column}. The \\textit{compression} and \\textit{decompression} processes are similar for the multi-representation structures defined in the previous sections. For \\textit{compression}, the decision upon which representation fits a given value is determined by the (first) operator that does not raise an exception. If all operators raise an exception then the value is stored on the \\textit{exception column}. For \\textit{decompression}, the physical columns that do not contain \\verb|null| values indicate the representation of each value. This process is similar to the SQL \\verb|COALESCE| function \\cite{sqlcoalesce}, which returns the first non-null value in a list of expressions.\n\nThe process of evaluating \\textit{expression trees} in topological order is suitable for vectorized execution \\cite{kersten2018everything} and SIMD instructions since the elementary operators can be evaluated in the same order for blocks of data, generating intermediate results which fit in the cache. Alternatively, JIT compilation \\cite{kersten2018everything} can be used to generate compiled code for each component of the expression tree during compression time, which is then executed for each query. However, the scope of this thesis does not cover fast evaluation of expression trees. We leave this topic for future work.\n\n\n% \\section{Representation example}\n% \\label{sec:exprlang:repexamples}\n\n% TODO-1: give example from PBIB with compression ratio and compressed execution opportunity (the one in the presentation)\n\n% \\iffalse\n% - expression tree examples & compression ratio calculation + compressed execution potential; also mention thesis focus (not compressed execution)\n% \\fi\n\n\n% ---------------------------------------------------------------------------\n% ----------------------- end of thesis sub-document ------------------------\n% ---------------------------------------------------------------------------\n\n\\iffalse\nwhere:\n\\begin{itemize}\n    \\item[] \\(n\\) = total number of expression nodes\n    \\item[] \\(c_{in}\\) = number of input columns\n    \\item[] \\(p\\) = number of pattern detectors\n    \\item[] \\(n_{p}\\) = number of expression nodes returned by a pattern detector\n    \\item[] \\(b\\) = branching factor of the compression tree\n    \\item[] \\(h\\) = height of the compression tree\n    \\item[] \\(c_{out}\\) = number of output columns of an expression node\n\\end{itemize}\n\\fi", "meta": {"hexsha": "4bb0b1d89c9f4b118dd7f3e6ff2f8434d8049251", "size": 22809, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/4_expression_language/expression_language.tex", "max_stars_repo_name": "bogdanghita/master-thesis", "max_stars_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-16T08:58:07.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-16T08:58:07.000Z", "max_issues_repo_path": "src/4_expression_language/expression_language.tex", "max_issues_repo_name": "bogdanghita/master-thesis", "max_issues_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/4_expression_language/expression_language.tex", "max_forks_repo_name": "bogdanghita/master-thesis", "max_forks_repo_head_hexsha": "f271ceb09960a5cf332fde3603244616069724fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 141.6708074534, "max_line_length": 1698, "alphanum_fraction": 0.7719759744, "num_tokens": 5161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.42290824952548606}}
{"text": "\\documentclass{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage{natbib}\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{color}\n\\usepackage{commath}\n\\usepackage{enumerate}\n\\usepackage{algpseudocode}\n\n\\bibliographystyle{plainnat}  % use the plainnat instead of plain\n\n\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\minimize}{minimize}\n\\DeclareMathOperator*{\\prox}{prox}\n\\DeclareMathOperator*{\\loss}{loss}\n\\DeclareMathOperator*{\\reg}{reg}\n\\def\\RR{{\\mathbb R}}\n\\newcommand{\\blue}{\\color{blue}}\n\n\\newtheorem{example}{Example}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}[theorem]{Lemma} \n\\newtheorem{proposition}[theorem]{Proposition} \n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\\newtheorem{axiom}[theorem]{Axiom}\n\n\\newcommand{\\SAGA}{\\textsc{Saga}}\n\\newcommand{\\SAG}{\\textsc{Sag}}\n\\newcommand{\\LASSO}{\\textsc{Lasso}}\n\n\\title{Large-scale optimization with the \\textsc{SAGA} algorithm}\n\\author{Fabian Pedregosa \\qquad Arnaud Rachez \\qquad Mathieu Blondel \\\\\\\\\n   % \\emph{Chaire Havas-Dauphine  \\'Economie des Nouvelles Donn\\'ees} \\\\\n   % \\emph{Universit\\'e Paris-Dauphine, PSL Research University} \\\\\n   %  \\emph{INRIA - Sierra project-team}\n}\n\\date{\\today} % {November 2015}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\begin{abstract}\nIn this technical report we describe the implementation of the \\SAGA\\ algorithm in the lightning\\footnote{\\url{http://www.mblondel.org/lightning/}} python library. We discuss implementation details such as the use of lazy or lagged updates for squared $\\ell_2$ and $\\ell_1$ regularization.\n\\end{abstract}\n\n\\section{Introduction}\n\nA large class of optimization problems in machine learning can be expressed as the minimization of a finite sum of the form\n$$\n\\argmin_{x \\in \\RR^p} \\left\\{ \\sum_{i=1}^n f_i(x) + \\lambda \\norm{x}^2 + \\mu \\Omega(x)\\right\\} \\quad,\n$$\nwhere $\\mu, \\lambda$ are real constants, each $f_i: \\RR^p \\to \\RR$ is convex and has Lipschitz continuous derivatives with constant $L$. $\\Omega: \\RR^p \\to \\RR$ is also assumed to be convex but potentially non-differentiable. We will further assume that we have acces to its proximal operator, denoted $\\text{Prox}_{\\mu}$.\n\nThese problems arise often in machine learning, where the cost function is a misfit over a large number of data points. The \\SAGA\\ algorithm~\\citep{defazio2014saga} is a recently proposed algorithm to solve optimization problems of this type. As other iterative methods, this algorithm creates a sequence of iterates $w_1, w_2, \\ldots$ that converge towards the desired solution $x^*$. The updates of \\SAGA\\ take the form\n\\begin{equation} \\label{eq:update_rule}\nx_{k+1} = \\text{Prox}_{\\gamma \\mu}((1 - \\gamma \\lambda)x_k - \\gamma (\\nabla f_i(x_k) - {\\alpha}_i + \\bar{\\alpha})) \\quad,\n\\end{equation}\nwhere $\\bar{\\alpha} = \\sum_{i=1}^n \\alpha_i$ and $\\alpha_i$ is a table (memory) of historical gradients, $\\gamma$ is the step size and $i$ is an index selected uniformly at random. The update rule for the historical gradients is $\\alpha_i = f_i(x)$ for the selected $i$. The corrections will be used the next time the same index $i$ gets sampled. The \\SAGA\\ algorithm is further described in~\\citep{defazio2014saga,hofmann2015variance}.\n\n\nWe will focus in the case in which the smooth term is linearly-parametrized, that is, $f_i(x)$ is of the form $g(a_i^T x)$ for all $i$. In this setting $\\nabla f_i(x) = a_i g'(a_i^T x)$, so since each $a_i$ is constant we only need to store the scalar $g'(a_i^T x)$. This reduces the storage cost from $\\mathcal{O}(n p)$ down to $\\mathcal{O}(n)$.\n\nThe values of $\\Omega$ that we will examine are the cases of $\\ell_1$-regularization and $\\ell_1/\\ell_2$-regularization. $\\ell_1$ regularization, known as \\LASSO\\ when the smooth term is a least squares loss, is a popular penalty that is commonly used to promote sparsity within the vector of coefficients. It is denoted $\\norm{\\cdot}_1$ and defined as the absolute sum of its components, \n$\n\\norm{x}_1 = \\sum_{i=1}^p |x_i|\n$. Its proximal operator is the \\emph{soft-thresholding} operator, and is defined component-wise as\n\\begin{equation}\\label{eq:soft_thresholding}\n\\left[\\text{Prox}_{\\mu \\norm{\\cdot}_1}(x)\\right]_j = \\left(1 - \\frac{\\mu}{|x_j|}\\right)_+ x_j = \n\\begin{cases}\nx_j - \\mu \\text{ if } \\mu \\leq x_j \\\\\n0 \\text{ if } -\\mu \\leq x_j \\leq \\mu \\\\\n\\mu - x_j \\text{ if }  x_j \\leq - \\mu \\\\\n\\end{cases}\n\\end{equation}\n\nA practical implementation of \\SAGA\\ relies on a number of non-trivial techniques that need to be used. In this technical report we detail the techniques that we found where essential to obtain a practical implementation of this algorithm. These are:\n\\begin{itemize}\n% \\item {\\bf Adaptive step size}. The SAGA algorithm relies on a particular choice of the step size $\\gamma$. While in theory this step size can be estimated from the data, we found that much faster convergence can be achieved by choosing an \\emph{adaptive} step size. We will detail this choice in Section~\\ref{scs:step_size}.\n\\item {\\bf Lagged updates}. Even if the gradients $\\nabla f_i(x)$ are sparse, the vector $\\bar{\\alpha}$ is typically dense and so update rule~\\eqref{eq:update_rule} involves dense vector operations. However, a technique known as implicit updates, lagged updates~\\citep{defazio2014saga} or just-in-time updates~\\citep{schmidt2013minimizing} can be used in order to reduce the vector update to sparse operations. \nWe extend this technique to the case of an $\\ell_1$ penalty term.\n\\item {\\bf Step size}. The theory of \\SAGA\\ is developed for a step-size that is sub-optimal. In particular, \n\\end{itemize}\n\n\\section{Impicit updates}\n\nWhen the vectors $a_i$ are sparse (recall that we assume $f_i$ is of the form $f_i(x) = g(a_i^T x)$, an individual gradient $\\nabla f_i$ will inherit the sparsity pattern of the corresponding $a_i$. However, the update rule~\\eqref{eq:update_rule} appears unappealing since in general $\\bar{\\alpha}$ will be dense. Nevertheless, we can use the following technique to obtain iterations with a cost that is proportional to the number of non-zeros in $a_i$.\n\nThis technique consists in not explicitly storing the full vector $x_k$ after each iteration. Instead, on each iteration we only compute the elements corresponding to non-zero elements of $a_i$ and at the same time storing a record of when was the last time that a given feature or coordinate was updated. We denote the vector that keeps track of this $m$, such that $m_i$ returns the last iteration in which $x_i$ was updated.\n\nWe will first present the technique in its general form and then see how this simplifies for some common choice of the regularizers such as $\\ell_2$ or $\\ell_1$. The technique can be defined recursively as follows (assumes the prox is computed element-wise):\n\n\\begin{enumerate}[(i)]\n\\item In the first iteration, perform the update rule only on the support of $a_1$, which we denote $J$, and we updated the vector $m$.\n$$\n\\begin{aligned}\n(x^1)_J &\\leftarrow \\text{Prox}_{\\gamma \\mu}((1 - \\gamma^k \\lambda)x_k - \\gamma^k (\\nabla f_i(x_k) - {\\alpha}_i + \\bar{\\alpha}))_J \\\\\nm_J &\\leftarrow 1\n\\end{aligned}\n$$\n\\item At iteration $k$, we update the vector of coefficients $x_k$ to ensure that it is up-to-date on the support of $a_k$. That is, for all indices $j$ in the support of $a_i$: \n\\begin{algorithmic}\n\\For{$j \\text{ in the support of }a_i$}\n\\For{$l \\gets m_j,k$ }\n\\State $x_j \\gets \\text{Prox}_{\\gamma^k \\mu}((1 - \\gamma^k \\lambda)x_j - \\gamma^k \\bar{\\alpha}_j)$\n\\EndFor\n\\State $m_j \\gets k$ \\Comment{ Mark the $j$-th variable as updated }\n\\EndFor\n\\end{algorithmic}\n\\item Perform the $k$-th update on the support of $a_i$:\n\\begin{algorithmic}\n\\For{$j \\in \\text{ support of }a_i$}\n\\State $(x_k)_j \\gets \\text{Prox}_{\\gamma^k \\mu}((1 - \\gamma^k \\lambda)x_k - \\gamma^k (\\nabla f_i(x_k) - {\\alpha}_i + \\bar{\\alpha}))_j$\n\\EndFor\n\\end{algorithmic}\n% $$\n% \\begin{aligned}\n% (x_k)_j &\\leftarrow \\text{Prox}_{\\gamma \\mu}((1 - \\gamma \\lambda)x_k - \\gamma (\\nabla f_i(x_k) - {\\alpha}_i + \\bar{\\alpha}))_j \\\\\n% \\alpha_i &\\leftarrow \\nabla f_i(x_k) (XXX)\n% \\end{aligned}\n% $$\n\\end{enumerate}\n\nThe technique of implicit (or lagged) updates consists in finding a shortcut for the update in step $(ii)$. As we will see, this can be done for the case of $\\ell_2$ regularization and (to a certain extend) for the case of $\\ell_1$ regularization. For simplicity we define the following function $P$ which represents the update of a single coordinate. Given arbitrary real numbers $s, t$ this is defined as follows:\n$$\nU_t(s) = \\text{{Prox}}_{\\gamma \\mu}((1 - \\gamma \\lambda)s - \\gamma t) \\quad,\n$$\nThe update in step $(ii)$ can be written in this notation as $x \\leftarrow U_{\\bar{\\alpha_j}}(x_j)$. The for loop in this step can be interpreted as the composition of $U$ with itself. Hence, the efficiency of the lagged update will depend on how fast we are able to compute $U^m$, where the exponent denotes composition with itself.\n\n\\subsection{Implicit updates with $\\ell_2$ regularization}\n\nWe start with the simple case in which there is no non-smooth penalty term, i.e. $\\Omega$ is zero. This setting is described in~\\citep{defazio2014saga} and in ~\\citep{schmidt2013minimizing} (in this case of the \\SAG\\ algorithm instead of \\SAGA).\n\n\nIn this case, the updates in step (ii) take a simple form. Supposing $k-m_j = 1$ then the update for coordinate $j$ is simply\n$$\nx^+_j \\gets (1 - \\gamma \\lambda)x_j - \\gamma \\bar{\\alpha}_j \\quad.\n$$\nIf $k-m_j=2$ then the update becomes\n$$\n\\begin{aligned}\nx^+_j &\\gets (1 - \\gamma^{k} \\lambda)((1 - \\gamma^{k-1} \\lambda)x_j - \\gamma^{k-1} \\bar{\\alpha}_j) - \\gamma^k \\bar{\\alpha}_j \\quad. \\\\\n&= (1 - \\gamma^{k} \\lambda)(1 - \\gamma^{k-1} \\lambda) x_j - \\gamma^k \\bar{\\alpha} (1 + (1 - \\gamma^{k-1} \\lambda))\n\\end{aligned}\n$$\n\nFrom this it is easy to generalize to an arbitrary value of $k-m_j$. The full update in this case becomes:\n\\begin{algorithmic}\n\\For{$j \\in \\text{ support of }a_i$}\n\\State $x_j \\gets \\left(\\prod_{i=1}^{k-m_j} (1 - \\gamma^{k-i+1} \\lambda )\\right) x_j + \\gamma^k \\bar{\\alpha} \\left(1 + \\sum_{i=1}^{k-m_j} \\prod_{j=1}^i (1 - \\gamma^{k-j} \\lambda) \\right)$\n\\State $m_j \\gets k$\n\\EndFor\n\\end{algorithmic}\n\nThat this is indeed equivalent to the update rule in in (ii) can be easily proven by induction on $k - m_j$.\n\n\n\\subsection{Implicit updates for $\\ell_2 + \\ell_1$ regularization}\n\nThrough this section $\\text{Prox}$ denotes the proximal operator for the $\\ell_1$ norm, defined in Eq.~\\eqref{eq:soft_thresholding}. Our update scheme is based upon the following lemma. \n\n\n\\begin{lemma}\\label{lemma:update_l1}\nLet $s, t$ be arbitrary real numbers and $P$ be a function defined as follows:\nwhere $j$ is an arbitrary index. Let $P^m$ denote the composition of $P$ with itself $m$ times. Then, if $|\\bar{\\alpha}_j| \\leq \\mu$ or if $\\bar{\\alpha}_j x_j \\leq 0$, then it is verified that\n$$\nP^m(s, t) = \n\\text{\\emph{Prox}}_{m \\gamma \\mu}\\left((1 - \\gamma \\lambda)^{m} x_j + \\gamma \\bar{\\alpha}_j \\sum_{i=1}^{m} (1 - \\gamma \\lambda)^{i-1}\\right)\n$$\n\\end{lemma}\n\\begin{proof}\n% Take first the case of $k - m_j = 1$. The update in (ii) takes the following form\n% $$\n% x_j \\gets \\text{Prox}_{\\gamma \\mu}((1 - \\gamma \\lambda)x_j - \\gamma \\bar{\\alpha}_j)\n% $$\nWe first consider the case in which $\\abs{\\bar{\\alpha}_j} \\leq \\mu$. Make make the following distinction of cases:\n\\begin{itemize}\n\\item $x_j = 0$. In this case $P(x_j) = \\text{{Prox}}_{\\gamma \\mu}(- \\gamma \\bar{\\alpha}_j)$ and the assumption $\\abs{\\bar{\\alpha}_j} \\leq \\mu$ implies that $T(x_j) = \\text{{Prox}}_{\\gamma \\mu}(- \\gamma \\bar{\\alpha}_j) = 0$.\n\\end{itemize}\n% and $(1 - \\gamma \\lambda)x_j - \\gamma \\bar{\\alpha}_j \\geq \\gamma \\mu$\n. Then by the definition of soft-thresholding we have the update\n$$\nT(x) = \n$$\nXXX\n$$\nx_j^+ \\gets (1 - \\gamma \\lambda)x_j - \\gamma \\bar{\\alpha}_j - \\gamma \\mu\n$$\n\\end{proof}\n\n\nThis proximal function also features a homogeneous property, namely that if $x = \\tau w$, then \n$$\n\\text{Prox}_\\lambda(x) = \\tau \\text{Prox}_{\\lambda /\\tau}(w_k) \\quad.\n$$\n\nThis, together with Lemma~\\ref{lemma:update_l1}, yield the following lagged update rule for the $\\ell_1$ regularization.\n\n\n\n% \\section{Adaptive step size} \\label{scs:step_size}\n\n% Following~\\citep{schmidt2013minimizing,schmidt2015non}, we take the step size to be $\\gamma = 1 / L$, where $L$ is an approximation to the maximum Lipschitz constant of the gradients. This is the smallest number such that\n% $$\n% \\norm{\\nabla f_i(w) - \\nabla f_i(v)} \\leq L \\norm{w - v}\\quad,\n% $$\n% for all $i, w$ and $v$. A classical result on quadratic upper bounds for $L$-smooth functions (see e.g.~\\citep[Lemma 1.2.3]{nesterov2004introductory}) states that the following inequality is verified:\n% \\begin{equation*}\n% f_{i}(x_k - \\frac{1}{L}\\nabla f_{i}(x_k)) \\leq f_{i}(x_k) - \\frac{1}{2 L} \\norm{\\nabla f_{i}(x_k)}^2\n% \\end{equation*}\n% The adaptive step size strategy is the following: at the current iterate, compute the above inequality for the current value of $i$ and $k$. If the inequality is satisfied, use the step size $1 / L$. Otherwise, double the value of $L$ until the inequality is verified.\n\n\\subsection{Experiments}\n\nSome convergence plots.\n\n\n\\section{Choice of step size}\n\n\n\n\n\\section{Feedback}\n\n\n\\bibliography{biblio}{}\n\\end{document}\n", "meta": {"hexsha": "ba4396e39840aca48b04360de150a0a43ecc2502", "size": 13347, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/index.tex", "max_stars_repo_name": "fabianp/saga_report", "max_stars_repo_head_hexsha": "36a70f1f2f525ac2e4e836801858e9564a2743c6", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/index.tex", "max_issues_repo_name": "fabianp/saga_report", "max_issues_repo_head_hexsha": "36a70f1f2f525ac2e4e836801858e9564a2743c6", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/index.tex", "max_forks_repo_name": "fabianp/saga_report", "max_forks_repo_head_hexsha": "36a70f1f2f525ac2e4e836801858e9564a2743c6", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.5550847458, "max_line_length": 453, "alphanum_fraction": 0.717539522, "num_tokens": 4168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4229082418614177}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{exercises}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% --------------------------------------------------------------------------------------------\n\\section*{Exercise 4.3 Polynomial products}\n\n\\begin{cadabra}\n\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   def get_term (poly,n):\n\n       x^{a}::Weight(label=xnum).     # assign weights to x^{a}\n\n       foo := @(poly).                # make a copy of poly\n       bah  = Ex(\"xnum = \" + str(n))  # choose a target\n       keep_weight (foo,bah)          # extract the target\n\n       return foo\n\n   def poly_product (p,q,n):\n\n       pq = Ex(\"0\")\n\n       for i in range (0,n+1):\n          for j in range (0,i+1):\n             termA = get_term (p,j)\n             termB = get_term (q,i-j)\n             termAB := @(termA) @(termB).\n             pq = pq + termAB\n\n       sort_product   (pq)\n       rename_dummies (pq)\n       factor_out     (pq,$x^{a?}$)\n\n       return pq\n\n   # ---------------------------------------------------------------\n\n   # two polynomials\n\n   polyA := c^{a}\n          + c^{a}_{b} x^b\n          + c^{a}_{b c} x^b x^c\n          + c^{a}_{b c d} x^b x^c x^d\n          + c^{a}_{b c d e} x^b x^c x^d x^e.    # cdb(ex-0403.100,polyA)\n\n   polyB := d^{f}\n          + d^{f}_{b} x^b\n          + d^{f}_{b c} x^b x^c\n          + d^{f}_{b c d} x^b x^c x^d\n          + d^{f}_{b c d e} x^b x^c x^d x^e.    # cdb(ex-0403.101,polyB)\n\n   # multiply polynomials and truncate\n\n   polyAB = poly_product (polyA,polyB,3)        # cdb(ex-0403.102,polyAB)\n\n\\end{cadabra}\n\n\\begin{dgroup*}\n   \\Dmath*{  p = \\Cdb*{ex-0403.100} }\n   \\Dmath*{  q = \\Cdb*{ex-0403.101} }\n   \\Dmath*{ pq = \\Cdb*[\\hskip1cm\\hfill]{ex-0403.102} }\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "05cb47c2a21063e5b1c701fdcb80ed108f3b8491", "size": 1791, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/exercises/ex-0403.tex", "max_stars_repo_name": "leo-brewin/cadabra-tutorial", "max_stars_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2019-12-20T07:49:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T22:55:47.000Z", "max_issues_repo_path": "source/cadabra/exercises/ex-0403.tex", "max_issues_repo_name": "leo-brewin/cadabra-tutorial", "max_issues_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/exercises/ex-0403.tex", "max_forks_repo_name": "leo-brewin/cadabra-tutorial", "max_forks_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-22T13:52:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-22T13:52:19.000Z", "avg_line_length": 25.2253521127, "max_line_length": 94, "alphanum_fraction": 0.4572864322, "num_tokens": 615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.42290823802938343}}
{"text": "\\chapter{Introduction}\n\n\\section{Knowledge Discovery in Database, KDD}\n\nThe overall process of non-trivial extraction of implicit, previously unknown and potentially useful knowledge from large amounts of data\n\n\\begin{align*}\n    Database &\\xrightarrow{Data\\ Cleaning} Data Warehouse \\\\ \n    &\\xrightarrow{Selection\\ Transformation} Task relevant\\ Data \\\\\n    &\\xrightarrow{Data\\ Mining} Pattern \\\\\n    &\\xrightarrow{Pattern\\ Evaluation\\ and\\ Visualisation} Knowledge\n\\end{align*}\n\n\\section{Data Mining}\n\n\\begin{description}\n  \\item[Prediction\\ Methods] Classification, Outlier Detection, Regression\n  \\item[Description Methods] Clustering, Association Rule, Sequence Pattern\n\\end{description}", "meta": {"hexsha": "ecc1215ea7bfbeb2785e65dcb0f11d5830614531", "size": 693, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter1.tex", "max_stars_repo_name": "Andyccs/data-mining-summary", "max_stars_repo_head_hexsha": "27ffac528e9e225c8a15ff44fbf2ed3e1c6b9f7a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter1.tex", "max_issues_repo_name": "Andyccs/data-mining-summary", "max_issues_repo_head_hexsha": "27ffac528e9e225c8a15ff44fbf2ed3e1c6b9f7a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter1.tex", "max_forks_repo_name": "Andyccs/data-mining-summary", "max_forks_repo_head_hexsha": "27ffac528e9e225c8a15ff44fbf2ed3e1c6b9f7a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4736842105, "max_line_length": 137, "alphanum_fraction": 0.7748917749, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.42290823419734924}}
{"text": "\\input{../tex/headerfile}\n\\input{../tex/mathdefs}\n\\setcounter{MaxMatrixCols}{20}\n\\usepackage{enumerate}\n\\usepackage{Sweave}\n\\begin{document}\n\\input{basic-matrix-math-key-concordance}\n\n\n\\chapter*{Solutions Chapter \\ref{chap:basicmat}}\n\\addcontentsline{toc}{chapter}{Solutions Chapter \\ref{chap:basicmat}}\n\n%######################################\n%# Basic Matrix Math\n%# Homework Questions\n%######################################\n\n\\begin{enumerate}\n\\item \n\\begin{Schunk}\n\\begin{Sinput}\n A=matrix(1:4,4,3)\n\\end{Sinput}\n\\end{Schunk}\n\\item \n\\begin{Schunk}\n\\begin{Sinput}\n A[1:2,1:2]\n\\end{Sinput}\n\\end{Schunk}\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n A=matrix(1:12,4,3, byrow=TRUE)\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n #end up with a vector\n A[3,]\n #end up with a matrix\n A[3,,drop=FALSE]\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n B=matrix(1,4,3)\n B[2,3]=2\n\\end{Sinput}\n\\end{Schunk}\n\n\\item \n\\begin{Schunk}\n\\begin{Sinput}\n t(B)\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n diag(1:4)\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n B=diag(1,5)\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n diag(B)=2\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n diag(1,4)+1\n #or\n B=matrix(1,4,4)\n diag(B)=2\n B\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n solve(B)\n #or this but only works because B is symmetric\n chol2inv(chol(B))\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n B=matrix(letters[1:9],3,3)\n B\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n diag(B)=\"cat\"\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n A=matrix(1,4,3)\n B=matrix(2,3,4)\n A%*%B\n #or\n B%*%A\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n # A%*%A #throws an error\n A%*%t(A) #works\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n #this is an example where you use B to select values in A\n A=matrix(1:9,3,3)\n B=matrix(0,3,3)\n B[1,1]=1\n B[2,3]=1\n B[3,2]=1\n C=A%*%B\n diag(C)\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n #this shows one of the uses of diagonal matrices\n B=diag(2,3)\n C=A%*%B\n C\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n #this shows how to use a column vector (matrix with 1 col) \n #to compute row sums\n B=matrix(1,3,1)\n C=A%*%B\n C\n\\end{Sinput}\n\\end{Schunk}\n\n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n #this shows how to use a row vector (matrix with one row) \n #to compute column sums\n B=matrix(1,1,3)\n C=B%*%A\n C\n\\end{Sinput}\n\\end{Schunk}\n \n\\item\n\\begin{Schunk}\n\\begin{Sinput}\n A=diag(1,3)+1\n C=matrix(3,3,1)\n #AB=C\n #B=inv(A)%*%C\n B=solve(A)%*%C\n B\n\\end{Sinput}\n\\end{Schunk}\n\n\\end{enumerate}\n\n\n\n\\bibliography{../tex/Fish507}\n\n\\end{document}\n", "meta": {"hexsha": "4c29b53dffaf919ebc987335bd3082081f9dc909", "size": 2761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Labs/Week 0 basic matrix/basic-matrix-math-key.tex", "max_stars_repo_name": "atsa-es/atsa2021", "max_stars_repo_head_hexsha": "50d16e728a6c9ea8b5705161350f69e7ddedcf1f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-11-21T18:58:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T11:50:46.000Z", "max_issues_repo_path": "Labs/Week 0 basic matrix/basic-matrix-math-key.tex", "max_issues_repo_name": "atsa-es/atsa", "max_issues_repo_head_hexsha": "df240ea10d69b4731d0121523ab6acd2d05f6898", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-10-20T20:58:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-20T20:58:14.000Z", "max_forks_repo_path": "docs/Labs/Week 0 basic matrix/basic-matrix-math-key.tex", "max_forks_repo_name": "atsa-es/atsa2021", "max_forks_repo_head_hexsha": "50d16e728a6c9ea8b5705161350f69e7ddedcf1f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.6009852217, "max_line_length": 69, "alphanum_fraction": 0.652662079, "num_tokens": 1136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301064, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.42289173483607223}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\noindent\nName: \\rule[-1ex]{0.55\\textwidth}{0.1pt}\nNetID: \\rule[-1ex]{0.2\\textwidth}{0.1pt}\n\n\\section*{NYU Physics I---Term Exam 2}\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from Lecture on 2018-09-27)\nA roller-coaster cart is at the top of a loop-the-loop (and therefore\nupside-down). The trajectory of the center of mass of the cart has a\nradius of curvature $R=5\\,\\m$. How fast does the roller-coaster have\nto be moving in $\\mps$ to stay on it's proper path (that is, on the\ntracks)?  Assume the mass is $M=1000\\,\\kg$ and the acceleration due to\ngravity is $g=10\\,\\mpss$.\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from Lecture on 2018-09-25)\nIn \\emph{16 words or fewer} tell me why the mass flying off the\n(not a) aki jump didn't fly\nall the way back up to the release height. Put a box around your answer,\nso I can count the words!\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from Problem Set 3)\nIf a runner, starting at rest, accelerates at $5\\,\\mpss$ for $2\\,\\s$\nand then continues at constant speed for $19\\,s$ more, how far will\nshe have run at the end of that $21\\,\\s$?\n\n\\vfill\n~\n\n\\clearpage\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from Problem Set 4)\nWhat is your kinetic energy when you are walking along the street?\nState your assumptions, and make sure they are \\emph{reasonable.}\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from the blocks-and-pulleys worksheet)\nA massless pulley hangs from the ceiling from a string which is at\ntension $T_1$. Over this pulley is another string at tension $T_2$, on\nthe ends of which are massive blocks attached. What is the\nrelationship between $T_1$ and $T_2$? If you have to assume additional\nthings to solve this problem, state them.\n\n\\vfill\n\n\\paragraph{\\problemname~\\theproblem:}\\refstepcounter{problem}%\n(from the friction worksheet)\nYou have a block of mass $m$ on an inclined plane, inclined at an\nangle $\\theta=15\\,\\deg$ to the horizontal. The coefficient of friction\nis $\\mu=0.9$. What is the magnitude of the frictional force on the\nblock? The acceleration due to gravity is $g$.\nYou can leave your answer in terms of $\\mu$, $m$, $g$, $\\theta$, or\nwhatever you need to deliver a correct answer.\nOnce again, state any assumptions you need to make.\n\n\\vfill\n~\n\\end{document}\n", "meta": {"hexsha": "3a4e89ffb45a322a7b7e549b1ccf46032855c36a", "size": 2433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/physics1_exam2.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/physics1_exam2.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/physics1_exam2.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2676056338, "max_line_length": 72, "alphanum_fraction": 0.7464036169, "num_tokens": 719, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.4228917207774412}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[a4paper, bindingoffset=0.2in, %\n\t\t\t\t\t\t\tleft=0.5in,right=0.5in,top=0.5in,bottom=0.5in,%\n\t\t\t\t\t\t\tfootskip=.25in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{physics}\n\\usepackage{hyperref}\n\n\n\\title{Midterm Report}\n\\author{Ali Abolhassanzadeh Mahani\\\\ 97110863}\n\n\\begin{document}\n\t\\maketitle\n\t\\section{Problem 1 (3D Site Percolation)}\n\t\\subsection{Part a}\n\tI made a class \\texttt{PercMatrix} that takes the length $L$ as the size of the arrays, and $p$, the probability with which I fill the cells with zero and on.\n\tThen, I go on and generate random binary numbers, and store shared poiters to them in the cells. I use smart pointers (\\texttt{std::shared\\_ptr<int>}) to make the clustering process faster.\n\t\\subsection{Part b}\n\tFirst I make a $L\\times L$ matrix called \\texttt{frontier} that stores the color codes through out the clustering and coloring process. Then, I add a surface matrix called \\texttt{init} to the beginning of the \n\tcube that contains pointers to the cells in \\texttt{frontier}. Then, I go through the cube cells and check if they are adjacent. If so, I form clusters, If more than one neighbors is on, I merge the cluster to the one with the lowest color code, since that cluster was made first.\\\\\n\tIn the end, I check the ending surface of cube to see if any of the color code are between $1, L\\times L +1$. If so, Percolation has occured. Otherwise, no percolation.\n\tIn order to find the gyro radius, first, I find the color code of the biggest non-percolating cluster. Then, I \n\tfind the geometric center of that cluster and then, I can calculate the gyro radius.\n\t\n\t\\section{Problem 2 (Erdos Renyi Graph)}\n\t\\subsection{Part a (clustering)}\n\tI made the graph using \\texttt{nx.erdos\\_renyi\\_graph(n, p)}. Here $p$ is the probablity of an edge to exist which is $\\frac{<k>}{n}$ with $n$ being the number of nodes.\\\\\n\tI used the \\texttt{nx.clustering(G)} module to calculate the clustering of each edge and then\n\tused a trick to store them in a \\texttt{numpy array}. Then I plotted them using \\texttt{plt.hist()}. (Fig\\ref{fig:clust})\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=.4\\linewidth]{../p2/clust1.jpg}\n\t\t\\includegraphics[width=.4\\linewidth]{../p2/clust8.jpg}\n\t\t\\includegraphics[width=.4\\linewidth]{../p2/clust64.jpg}\n\t\t\\includegraphics[width=.4\\linewidth]{../p2/clust512.jpg}\n\t\t\\label{fig:clust}\n\t\t\\caption{clustering distribution for mean degrees of $\\{1, 8, 64, 512\\}$}\n\t\\end{figure}\n\t\\subsection{Part b (poisson dist. of degrees)}\n\tFirst I plot the histogram of degrees using \\texttt{plt.hist()}, which gives me \\texttt{counts}\n\tand \\texttt{bins}, then I make a function that returns the probability using the poisson distribution. (basically made that function). Then, I found the poisson distribution of the \\texttt{bins} and compared them to the actual \\texttt{counts}. \\\\\n\tThen \\texttt{np.sum} over them to find the cultivated error. The error is of order $\\mathcal{O}(10^{-5})$ for $<k> = 64$\n\t\n\tThis means that the poisson distribution function fits the degree distribution fairly well.\n\t\\section{Problem 3 (Random Generation)}\n\t\\subsection{Part a (generating function)}\n\tThe function that generates this distribution is the inverse of $g(x)$. It is as follows:\n\t\\begin{equation}\n\t\tg^{-1}(x) = \\left(\\frac{\\alpha x_m^\\alpha}{x}\\right)^{\\frac{1}{\\alpha + 1}}\n\t\\end{equation}\n\tIn order to generate from $x_m$ to $\\infty$, we need the input to be a uniform distribution\n\tfrom $0$ to $g^{-1}(x_m)$.\\\\\n\tI created this function and called it \\texttt{target\\_dist()}; then I made a random set of size \n\t$100000$ and plotted the histogram as seen below.(Fig\\ref{fig:reverse})\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=.4\\linewidth]{../p3/reverse.jpg}\n\t\t\\includegraphics[width=.4\\linewidth]{../p3/reverseplot.jpg}\n\t\t\\label{fig:reverse}\n\t\t\\caption{Distribution of $g(x)$ by 1000 samples and by ideal plot}\n\t\\end{figure}\n\t\n\t\\subsection{Part b (metropolis algorithm)}\n\tIn the metropolis algorithm, first, I defined the function $g(x)$ to return it's value as states in the previous \n\tsubsection, and to return $0$ if $x \\le 1$. Then, I made a function \\texttt{gen\\_dist(step, size)} which takes\n\tin the \\texttt{step} and \\texttt{size} and returns an array of random numbers as expected.\n\tInside the function, I used two counters, one to count acceptances and one to count the whole process.\n\tUsing the first, I can get the acceptance rate. I also stored all the numbers generated (whether or not they \n\twere same)and using the second counter, I hand-picked the random samples.\n\t\n\tThen, I made a function \\texttt{corr\\_len()} that takes in all the numbers, calculates the auto correlation\n\tfor values of $j = \\{0, 10, 20, 30, \\dots, 5000\\}$. Then, I look to see at which point, the auto correlation becomes less than $e^{-1}$. That value of $j$ is our correlation (gyro) length.\n\tThe results are in Table\\ref{tab:gyro}\n\t\\begin{table}[h]\n\t\t\\centering\n\t\t\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}\n\t\t\t\\hline\nstep size& $0.2$& $0.49$ & $0.9$ & $1.5$ & $2.45$ & $4$ & $6.4$ & $13.5$ & $33$ \\\\\n \\hline\nacceptance rate & $0.9$ & $0.8$ & $0.7$ & $0.6$ & $0.5$ & $0.4$ & $0.3$ & $0.2$ & $0.1$ \\\\\n \\hline\ncorrelation length & $5000$ & $1190$ & $3530$ & $430$ & $440$ & $290$ & $110$ & $1310$ & $90$ \\\\\n \\hline\n\t\t\\end{tabular}\n\t\\label{tab:gyro}\n\t\\caption{step size, and gyro length for different values of acceptance rate. The error for gyro length is 10.\n\tThe first with gyro length 5000 suggests that the gyro is actually more for that acceptance rate since 5000\n\tis the maximum value in my calculations.}\n\t\\end{table}\n\n\t\\section{Problem 4 (simulation)}\n\t\\textbf{List of group members:} \\emph{Ali Abolhassanzadeh Mahani}, \\emph{Abbas Shojakani}, \\emph{Mohadeseh Asgari}\n\t\\subsection{Stating the Problem}\n\tA blind /drunk person wants to cross a street using nothing but random process.\\\\\n\tWe want to find his/her success rate relative to the degree of which how crowded the street is.\\\\\n\tWe also want to find his/her mean lifetime for the times that he/she does not succeed and dies in a crash.\n\t\\subsection{Simulation}\n\tThe man is on the left side of the street at first, but then, It starts moving randomly with time.\n\tThe boundary conditions are walls on the sides of the street. Meaning that if the man staeps to the left of the street, it stays there. If he reaches the right side, he succeeds.\n\t\n\tWe took a mean of the car speeds and decided for it to be twice the speed of the blind/drunk person.\n\tThe width of the street is fixed to size $L$ and the number of cars that are randomly generated and put on\n\tthe street is our independent variable. The length of the cars is 1 unit area and the  \n\tcars move from bottom up. If in a time step, the position of the\n\trandom walker and a car are interfered, the person is rendered dead, and is reset to be on the left side again. This cycle continues for the rest of the ensemble.\\\\\n\tWe have also omitted the will of the drivers to hit the brake before hitting the person. So we have kind of assumed that the drivers are drunk too, which is a bit absurd or that the drivers' response time is not low enough to avoid a crash, which can be more reasonable.\n\t\n\tA better approximation of to set a condition to lower the speed if the driver sees the drunk person or that it\n\tshift the car to a new lane. Implementing these conditions can yield better, more accurate results. (We don't have time for that ;-) )\n\t\\subsection{The Simulation Code}\n\tI made a random walker in 1 Dimension that randomly crosses the street. And every time it makes a choice, its lifetime is incremented by 1 unit time. This method \\texttt{next()} that contains the decision making,\n\treturns 0 if the person is still in the street and returns 1 if the person has reached the right side (success).\\\\\n\t\\emph{Mohadeseh} made the street and the cars that are randomly generated at the bottom of the street and move upwards with speed 40 unit length.\\\\\n\t\\emph{Abbas} simulated using our code and got the statistics. The conditions of death and taking the mean are of his work. The precedence of time step evolution is with the random walker. Meaning first, the\n\trandom walker takes a step, then the cars move with their speed. If the cars hit the man in their evolution\n\tprocess, the man dies, else, the loop continues until either the man reaches the other side of the street,\n\tor he dies in a crash.\\\\\n\tI also added a some code to get the mean life span for the times that the drunk person dies.\n\tAfterwards, I spent time refining the code, commenting it and making it pretty :)\n\tThe results are below.\n\t\n\tIn our work, the evolution of the cars up the street is a cellular automata and the person crossing the\n\tstreet is obviously a random walk simulation.\n\t\\subsection{Results}\n\t We simulated for the car speed $v = 40$ and the man's speed $V_p = 2$ and the street width $L = 10$.\n\t Then, we plotted the success rate vs. the number of cars and the mean life span vs. the number of cars.\n\t Fig\\ref{fig:drunk}\n\t \\begin{figure}[h]\n\t \t\\centering\n\t\t\\includegraphics[width=.4\\linewidth]{../p4/success.jpg}\n\t\t\\includegraphics[width=.4\\linewidth]{../p4/meanlife.jpg}\n\t\t\\label{fig:drunk}\n\t\t\\caption{On the left we have the success rate vs. the number of cars, and on the right we have\n\t\tthe mean life time vs. the number of cars}\n\t \\end{figure}\n \tAs one can observe, the \\emph{success rate} decays fast with \\emph{number of cars}, the mean life time\n \talso decays fast but a bit smoother than the success rate. The moral lesson here is that one shall not try crossing a street while drunk.\n \t\n \tThe results show that for example, for a mean degree of crowd about 1 car per 100 unit area, the success rate is about $0.20$ and the mean lifetime for the unsuccessful times, it roughly 8 time steps.\n \tfor 10 cars per 100 unit area, those numbers decay to about $0$ and $1.5$ respectively.\n \tIn the ladder case, the drunk person dies after taking about $1.5$ steps in the street.\\\\\n \tThis threshold of $10$ can be due to the fact that the width of our street is 10 and since the \\texttt{death\\_check}'s conditions are perdiodic, for a velocity of 40 unit length per unit time, the entire street becomes full and the drunk person gets hit in just 1 or steps.\n\\end{document}\n", "meta": {"hexsha": "40d38817ba0d2f4b30a902fc18734b3a5a7091e9", "size": 10281, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Midterm/report/report.tex", "max_stars_repo_name": "alpha-leo/ComputationalPhysics-Fall2020", "max_stars_repo_head_hexsha": "737769d4a046b4ecea885cafeaf26e26075f7320", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-10T14:33:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T14:33:35.000Z", "max_issues_repo_path": "Midterm/report/report.tex", "max_issues_repo_name": "alpha-leo/ComputationalPhysics-Fall2020", "max_issues_repo_head_hexsha": "737769d4a046b4ecea885cafeaf26e26075f7320", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Midterm/report/report.tex", "max_forks_repo_name": "alpha-leo/ComputationalPhysics-Fall2020", "max_forks_repo_head_hexsha": "737769d4a046b4ecea885cafeaf26e26075f7320", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.4178082192, "max_line_length": 283, "alphanum_fraction": 0.7379632331, "num_tokens": 2911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.4228825200596569}}
{"text": "\\section{MAC network and our proposed simplification}\n\n\\begin{wrapfigure}{r}[5pt]{0.4\\textwidth}\n\t\\vspace{-15pt}\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{../img/mac_cell.pdf}\n\t\\caption{The MAC cell, reproduced on the basis of~\\cite{hudson2018compositional}.}\n\t\\label{fig:mac_cell}\n\t\\vspace{-5pt}\n\\end{wrapfigure}\n\nThe MAC network~\\cite{hudson2018compositional} is a recurrent model that performs sequential reasoning, where each step involves analyzing a part of the question followed by shifting the attention over the image.\nThe core of the model is the MAC cell, supported with an input unit that processes the question and image pair, and output unit which produces the answer.\nThe input unit  uses an LSTM~\\cite{hochreiter1997long} to process the question in a word-by-word manner producing a sequence of \\emph{contextual words} and a final \\emph{question representation}.\nAdditionally, the input unit uses a pre-trained ResNet~\\cite{he2016resnet} followed by two CNN layers to extract a feature map (referred to as \\emph{knowledge base}) from the image.\n\n\t\nThe MAC cell consists of a control unit, a read unit and a write unit (\\Fig{fig:mac_cell}).\nThe control unit is updating the control state $c_i$ and drives the attention over the list of \\emph{contextual words} $\\cw$ taking into account the \\emph{question representation} $q$.\nGuided by $c_i$,  the read unit extracts information from the \\emph{knowledge base} $\\kb$ and combines it with the previous memory state $m_{i-1}$  to produce the \\emph{read vector} $r_i$.\nFinally, the write unit integrates $r_i$ and $m_{i-1}$ to update the memory state. Detailed equations are described in the next section.\n\n%\\begin{figure}[htbp]\n%\t\\centering\n%\t\\includegraphics[width=0.4\\textwidth]{img/mac_cell.pdf}\n%\t\\caption{The MAC cell~\\cite{hudsonManning18}}\n%\t\\label{fig:mac_cell}\n%\\end{figure}\n", "meta": {"hexsha": "96adcba1f84214a2041a0e4023c860ecbc046d0e", "size": 1852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MAC_publications/2018_nips_vigil/mac.tex", "max_stars_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_stars_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MAC_publications/2018_nips_vigil/mac.tex", "max_issues_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_issues_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MAC_publications/2018_nips_vigil/mac.tex", "max_forks_repo_name": "Bhaskers-Blu-Org1/mi-visual-reasoning-pubs", "max_forks_repo_head_hexsha": "4c5c503cb3976186d6eda4628f7c45914feba9fa", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-30T10:13:26.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-30T10:13:26.000Z", "avg_line_length": 63.8620689655, "max_line_length": 212, "alphanum_fraction": 0.7726781857, "num_tokens": 505, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4228825127252626}}
{"text": "\\input{mmd-article-header}\n\\def\\mytitle{MultiMarkdown Math Example}\n\\input{mmd-article-begin-doc}\n\n\\part{Math}\n\\label{math}\n\nAn example of math within a paragraph --- ${e}^{i\\pi }+1=0$ --- easy\nenough.\n\nAnd an equation on it's own:\n\n\\[ {x}_{1,2}=\\frac{-b\\pm \\sqrt{{b}^{2}-4ac}}{2a} \\]\n\nThat's it.\n\n\\chapter{``DollarMath''}\n\\label{dollarmath}\n\nAn example of math within a paragraph --- ${e}^{i\\pi }+1=0$ --- easy\nenough.\n\nAn example of math within a paragraph, ${e}^{i\\pi }+1=0$, easy\nenough.\n\nAnd an equation on it's own:\n\n$${x}_{1,2}=\\frac{-b\\pm \\sqrt{{b}^{2}-4ac}}{2a}$$\n\n\\chapter{Not Math}\n\\label{notmath}\n\nAn example of math within a paragraph --- \\$ \\{e\\}\\textsuperscript{{i}\\textbackslash{}pi \\}+1=0\\$ --- easy\nenough.\n\nAnd an equation on it's own:\n\n\\$\\$ \\{x\\}\\_\\{1,2\\}=\\textbackslash{}frac\\{-b\\textbackslash{}pm \\textbackslash{}sqrt\\{\\{b\\}\\textsuperscript{{2}}--4ac\\}\\}\\{2a\\}\\$\\$\n\nAn example of math within a paragraph --- \\$\\{e\\}\\textsuperscript{{i}\\textbackslash{}pi \\}+1=0 \\$ --- easy\nenough.\n\nAnd an equation on it's own:\n\n\\$\\$\\{x\\}\\_\\{1,2\\}=\\textbackslash{}frac\\{-b\\textbackslash{}pm \\textbackslash{}sqrt\\{\\{b\\}\\textsuperscript{{2}}--4ac\\}\\}\\{2a\\} \\$\\$\n\nAn example of math within a paragraph --- a\\$\\{e\\}\\textsuperscript{{i}\\textbackslash{}pi \\}+1=0\\$ --- easy\nenough.\n\nAnd an equation on it's own:\n\na\\$\\$\\{x\\}\\_\\{1,2\\}=\\textbackslash{}frac\\{-b\\textbackslash{}pm \\textbackslash{}sqrt\\{\\{b\\}\\textsuperscript{{2}}--4ac\\}\\}\\{2a\\}\\$\\$\n\nAn example of math within a paragraph --- \\$\\{e\\}\\textsuperscript{{i}\\textbackslash{}pi \\}+1=0\\$b --- easy\nenough.\n\nAnd an equation on it's own:\n\n\\$\\$\\{x\\}\\_\\{1,2\\}=\\textbackslash{}frac\\{-b\\textbackslash{}pm \\textbackslash{}sqrt\\{\\{b\\}\\textsuperscript{{2}}--4ac\\}\\}\\{2a\\}\\$\\$b\n\n\\input{mmd-memoir-footer}\n\n\\end{document}\n", "meta": {"hexsha": "0c2f7030564386d053efb338a86879b6b9703e77", "size": 1764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "deps/mmd4/MarkdownTest/MultiMarkdownTests/Math.tex", "max_stars_repo_name": "dtjm/go-multimarkdown", "max_stars_repo_head_hexsha": "98abc383e38bbd310f61d322ca31e675cacac4fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-02-05T07:18:40.000Z", "max_stars_repo_stars_event_max_datetime": "2015-02-05T07:18:40.000Z", "max_issues_repo_path": "deps/mmd4/MarkdownTest/MultiMarkdownTests/Math.tex", "max_issues_repo_name": "dtjm/go-multimarkdown", "max_issues_repo_head_hexsha": "98abc383e38bbd310f61d322ca31e675cacac4fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "deps/mmd4/MarkdownTest/MultiMarkdownTests/Math.tex", "max_forks_repo_name": "dtjm/go-multimarkdown", "max_forks_repo_head_hexsha": "98abc383e38bbd310f61d322ca31e675cacac4fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5625, "max_line_length": 130, "alphanum_fraction": 0.6292517007, "num_tokens": 682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.42288251272526256}}
{"text": "% !TeX root = ../phd-1st-year-presentation.tex\n% !TeX encoding = UTF-8\n% !TeX spellcheck = en_GB\n\n\\section{A hybrid technique for MRP transient analysis}\n  \\begin{frame}{A hybrid technique for MRP transient analysis}\n    Transient analysis of Markov Regenerative Processes (MRP)\\\\\n    employing different techniques for different regenerative epochs\n    \n    \\vspace{1em}\n    The basics:\n    \\begin{itemize}\n      \\item Exact techniques require specific conditions to be met\n      \\begin{itemize}\n        \\item different techniques require different conditions\n      \\end{itemize}\n      \\item Kernel rows of different epochs can be evaluated independently\n    \\end{itemize}\n    \n    \\vspace{1em}\n    The idea:\n    \\begin{itemize}\n      \\item Evaluate each kernel row with a different technique\n      \\begin{itemize}\n        \\item corresponding to the condition enabled in that epoch\n        \\item eventually with an approximate technique, if no conditions are met\n      \\end{itemize}\n      \\item Compute transient probabilities with Markov Renewal Equations\n    \\end{itemize}\n  \\end{frame}\n  \n  \\subsection{Techniques for MRP transient analysis}\n    \\begin{frame}{Techniques for MRP transient analysis}\n      \\begin{minipage}{0.6\\textwidth}\n        \\textbf{Analysis under enabling restriction}\\footnotemark\n        \\begin{itemize}\n          \\item at most one GEN enabled in each state\n        \\end{itemize}\n      \\end{minipage}\n      \\begin{minipage}{0.35\\textwidth}\n        \\begin{center}\\scalebox{0.45}{\\input{img/pn_enabling_restriction}}\\end{center}\n      \\end{minipage}\n      \n      \\begin{minipage}{0.6\\textwidth}\n        \\textbf{Analysis with stochastic state classes}\\footnotemark\n        \\begin{itemize}\n          \\item a regeneration is always reached\\\\\n            within a bounded number of events\n          \\begin{itemize}\n            \\item i.e. no cycles without regenerations\n          \\end{itemize}\n          \\item a.k.a. bounded regeneration\n        \\end{itemize}\n      \\end{minipage}\n      \\begin{minipage}{0.35\\textwidth}\n        \\begin{center}\\scalebox{0.45}{\\input{img/pn_bounded_regeneration}}\\end{center}\n      \\end{minipage}\n      \n      \\begin{minipage}{0.6\\textwidth}\n        \\textbf{Approximate analysis}\n        \\begin{itemize}\n          \\item usable when no conditions are met\n        \\end{itemize}\n      \\end{minipage}\n      \\begin{minipage}{0.35\\textwidth}\n        \\begin{center}\\scalebox{0.45}{\\input{img/pn_no_restriction}}\\end{center}\n      \\end{minipage}\n      \n      \\addtocounter{footnote}{-1}\n      \\footnotetext{German, R., Logothetis, D., \\& Trivedi, K. S. (1995, October). Transient analysis of Markov regenerative stochastic Petri nets: A comparison of approaches. In Petri Nets and Performance Models, 1995., Proceedings of the Sixth International Workshop on (pp. 103-112). IEEE.}\n      \\stepcounter{footnote}\n      \\footnotetext{Horváth, A., Paolieri, M., Ridi, L., \\& Vicario, E. (2012). Transient analysis of non-Markovian models using stochastic state classes. Performance Evaluation, 69(7), 315-335.}\n    \\end{frame}\n  \n  \\subsection{Classification of epochs}\n    \\begin{frame}{Classification of epochs}\n      Through \\textbf{non-deterministic analysis}\n      \\begin{itemize}\n        \\item State Class Graphs (SCG) are built\n        \\item for each regenerative epoch\n      \\end{itemize}\n      \n      \\vspace{2em}\n      By visiting each SCG, epochs are classified\n      \\begin{itemize}\n        \\item enabling restriction\n        \\begin{itemize}\n          \\item if at most one GEN is enabled in any state\n        \\end{itemize}\n        \\item bounded regeneration\n        \\begin{itemize}\n          \\item if no cycle is present\n        \\end{itemize}\n      \\end{itemize}\n    \\end{frame}\n    \n  \\subsection{Iterative approximate technique}\n    \\begin{frame}{Iterative approximate technique}\n      Based on analysis with stochastic state classes\n      \\begin{itemize}\n        \\item truncated after enough precision is met\n      \\end{itemize}\n      \n      \\vspace{2em}\n      Improvement with heuristics\n      \\begin{enumerate}\n        \\item expand at most $\\nu_{start}$ nodes for non restricted epochs\n        \\item identify the truncated node $\\Phi$ with highest reaching probability\n        \\begin{itemize}\n          \\item based on steady-state analysis of the embedded DTMC\n        \\end{itemize}\n        \\item expand at most $\\nu_{iter}$ nodes from $\\Phi$\n        \\item if at least $\\nu_{max}$ nodes expanded, stop\n        \\begin{itemize}\n          \\item otherwise, return to step 2\n        \\end{itemize}\n      \\end{enumerate}\n    \\end{frame}\n", "meta": {"hexsha": "6f87a34de86b0d9f153d6c0a7de7df782a64888c", "size": 4586, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd/committee/first-year/presentation/body/hybrid_analysis.tex", "max_stars_repo_name": "oddlord/uni", "max_stars_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "phd/committee/first-year/presentation/body/hybrid_analysis.tex", "max_issues_repo_name": "oddlord/uni", "max_issues_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd/committee/first-year/presentation/body/hybrid_analysis.tex", "max_forks_repo_name": "oddlord/uni", "max_forks_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5378151261, "max_line_length": 293, "alphanum_fraction": 0.6567815089, "num_tokens": 1220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879992, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4228825053908681}}
{"text": "\\documentclass[10pt]{beamer}\n\\usetheme{metropolis}\n% all imports\n\\input{all_imports}\n\n\\AtBeginEnvironment{quote}{\\singlespacing}\n\n% new commands\n\\input{all_new_commands}\n\n% definitions\n\\input{definitions/colors}\n\\input{definitions/styles}\n\n\\input{header}\n\n\\begin{document}\n\n\n\\maketitle\n\n\n\\begin{frame}{Research problem}\n\\begin{itemize}\n\\item Create a set of tasks that incorporate logic reasoning to boost performance of the current dialog agents.\n\\item Perform a stress test in the existing \\textit{neural network based end-to-end dialog systems}.\n\\item Integrate linguistic reasoning with visual references to create a new set of visual question answering (VQA) tasks.\n\\item Define new models to achieve better results in the tasks proposed above. \n\\end{itemize}\n\\end{frame}\n\n\n\\section{Background}\n\n\\begin{frame}{Neural network based language model}\nWe call \\alert{language model} a probability distribution over sequences of tokens in a natural language.\n\\begin{equation}\nP(x_1,x_2,x_3,x_4) = p\n\\end{equation}\n\nSince \\cite{Mikolov11}, we use a \\alert{Recurrent Neural Network (RNN)} to estimate the probability distribution   \\\\\n\n\\begin{equation}\nP(x_{n} = \\text{word}_{j^{*}} | x_{1}, \\dots ,x_{n-1})\n\\end{equation}\n\nfor any $(n-1)$-sequence of words $x_{1}, \\dots ,x_{n-1}$.\n\\end{frame}\n\n\\begin{frame}{Neural network based language model}\n\\input{tikzfiles/LanguageModelUnfolded}\n\\end{frame}\n\n\n\n\\begin{frame}{GRU: Gated Recurrent Units}\n\\begin{equation}\n\\vect{\\widetilde{h}}^{(t)} = tahn(\\vect{W} (\\vect{h}^{(t-1)} \\odot  \\vect{r}^{(t)}) + \\vect{U} \\vect{x}^{(t)} + \\vect{b})\n\\end{equation}\n\n\\begin{equation}\n\\vect{r}^{(t)} = \\sigma(\\vect{W}_{r} \\vect{h}^{(t-1)} + \\vect{U}_{r} \\vect{x}^{(t)} + \\vect{b}_{r})\n\\end{equation}\n\n\n\\begin{equation}\n\\vect{u}^{(t)} = \\sigma(\\vect{W}_{u} \\vect{h}^{(t-1)} + \\vect{U}_{u} \\vect{x}^{(t)} + \\vect{b}_{u})\n\\end{equation}\n\n\\begin{equation}\n\\vect{h}^{(t)} = \\vect{u}^{(t)} \\odot \\vect{\\widetilde{h}}^{(t)} + (1 - \\vect{u}^{(t)}) \\odot \\vect{h}^{(t-1)} \n\\end{equation}\n\n\\end{frame}\n\n\\begin{frame}{LSTM: Long Short Term Memory}\n\\begin{equation}\n\\vect{f}^{(t)} = \\sigma(\\vect{W}_{f} \\vect{h}^{(t-1)} + \\vect{U}_{f} \\vect{x}^{(t)} + \\vect{b}_{f})\n\\end{equation}\n\n\\begin{equation}\n\\vect{i}^{(t)} = \\sigma(\\vect{W}_{i} \\vect{h}^{(t-1)} + \\vect{U}_{i} \\vect{x}^{(t)} + \\vect{b}_{i})\n\\end{equation}\n\n\\begin{equation}\n\\vect{o}^{(t)} = \\sigma(\\vect{W}_{o} \\vect{h}^{(t-1)} + \\vect{U}_{o} \\vect{x}^{(t)} + \\vect{b}_{o})\n\\end{equation}\n\n\n\\begin{equation}\n\\tilde{\\vect{c}}^{(t)} = tahn(\\vect{W} \\vect{h}^{(t-1)} + \\vect{U} \\vect{x}^{(t)} + \\vect{b})\n\\end{equation}\n\n\\begin{equation}\n\\vect{c}^{(t)} = \\vect{f}^{(t)} \\odot \\vect{c}^{(t-1)} + \\vect{i}^{(t)} \\odot \\tilde{\\vect{c}}^{(t)}\n\\end{equation}\n\n\\begin{equation}\n\\vect{h}^{(t)} = \\vect{o}^{(t)} \\odot tanh(\\vect{c}^{(t)})\n\\end{equation}\n\n\\end{frame}\n\n\\begin{frame}{Sequence-to-sequence}\n\\begin{itemize}\n\\item $\\vect{x}^{(1)}, \\dots, \\vect{x}^{(n)}$, source sentence\n\\item $\\vect{y}^{(1)}, \\dots, \\vect{y}^{(m)}$, target sentence\n\\item $f_{enc}$ (the \\textit{encoder}), a RNN\n\\item $f_{dec}$ (the \\textit{encoder}), a language model\n\\end{itemize}\n\n\n\\begin{equation}\n\\vect{s} = f_{enc}(\\vect{x}^{(n)}, \\vect{h}^{(n-1)})\n\\end{equation}\n\n\\begin{equation}\n\\vect{\\tilde{h}}^{(t)} = f_{dec}(\\vect{y}^{(t)}, \\vect{\\tilde{h}}^{(t-1)})\n\\end{equation}\n\n\\begin{equation}\np(y_t | y_1, \\dots, y_{t-1}, x_1, \\dots, x_{n}) = softmax(\\vect{W}_{s}  \\vect{\\tilde{h}}^{(t)} + \\vect{b}_s)\n\\end{equation}\n\n\n\\end{frame}\n\n\\begin{frame}{Attention}\n\n\\begin{equation}\n\\vect{a}_{ts} = \\frac{exp(score(\\vect{\\tilde{h}}^{(t)},\\vect{h}^{(s)}))}{\\sum_j exp(score(\\vect{\\tilde{h}}^{(t)},\\vect{h}^{(j)}))}\n\\end{equation}\n\n\\begin{equation}\nscore(\\vect{\\tilde{h}}^{(t)},\\vect{h}^{(s)}) = \\begin{cases}\n{\\vect{\\tilde{h}}^{(t)}} .^{\\top} \\vect{h}^{(s)}\\\\\n\\vect{\\tilde{h}}^{(t)} .^{\\top}\\vect{W}_a \\vect{h}^{(s)}\\\\\n\\vect{v}_a ^{\\top}tahn(\\vect{W}_a[\\vect{\\tilde{h}}^{(t)};\\vect{h}^{(s)}])\\\\\n\\end{cases}\n\\end{equation}\n\n\\begin{equation}\n\\vect{c}^{(t)} = \\sum_{s} \\vect{a}_{ts}\\vect{h}^{(s)}\n\\end{equation}\n\n\\begin{equation}\n\\vect{\\tilde{h}}^{(t)}_{out} = tahn(\\vect{W}_c[\\vect{c}^{(t)};\\vect{h}^{(t)}])\n\\end{equation}\n\n\\begin{equation}\np(y_t | y_1, \\dots, y_{t-1}, x_1, \\dots, x_{n}) = softmax(\\vect{W}_{s}  \\vect{\\tilde{h}}^{(t)}_{out} + \\vect{b}_s)\n\\end{equation}\n\n\\end{frame}\n\n\n\n\n\\begin{frame}{Attention general formulation}\n\n\\begin{equation}\nf(\\vect{Q},\\vect{K}_i) = \\begin{cases}\n\\vect{Q} .^{\\top} \\vect{K}_i\\;\\;\\;\\; \\text{dot}\\\\\n\\vect{Q} .^{\\top}\\vect{W}_{a} \\vect{K}_i\\;\\;\\;\\; \\text{general}\\\\\n\\vect{W}_{a}[\\vect{Q};\\vect{K}_i] \\;\\;\\;\\; \\text{concat}\\\\\n\\vect{v}_{a}.^{\\top} tahn(\\vect{W}_{a}\\vect{Q} + \\vect{U}_{a}\\vect{K}_i)\\;\\;\\;\\; \\text{perceptron}\\\\\n\\end{cases}\n\\end{equation}\n\n% softmax figure\n\\begin{figure}[ht!]\n\\centering\n\\scalebox{1.1}{\n\\begin{tikzpicture}[auto]\n\\node[textonly] (logits) {$\\begin{bmatrix}f(\\vect{Q},\\vect{K}_1)\\\\f(\\vect{Q},\\vect{K}_2)\\\\\\vdots\\\\f(\\vect{Q},\\vect{K}_n)\\end{bmatrix}$};\n\\node[textonly, right=60pt of logits] (softmax) {$\\begin{bmatrix}a_1\\\\a_2\\\\\\vdots\\\\a_n\\end{bmatrix}$};\n\\path[tedge] (logits) edge node[above=1pt] {{\\Large softmax}} (softmax);\n\\end{tikzpicture}\n}\n\\end{figure}\n\n\\begin{equation}\nAttention(\\vect{Q},\\vect{K}, \\vect{V})= \\sum_{i} \\vect{a}_{i}\\vect{V}_i\n\\end{equation}\n\n\n\\end{frame}\n\n\n\n\n\n\n\n\\section{Neural network based dialog systems}\n\n\\begin{frame}{Seq2seq applied to translation}\n\\input{tikzfiles/Translation}\n\\end{frame}\n\n\\begin{frame}{Seq2seq applied to dialog \\cite{DBLP:journals/corr/VinyalsL15}}\n\\input{tikzfiles/seq2seq_dialog}\n\\end{frame}\n\n\n\\begin{frame}{MemNN}\n\\begin{itemize}\n\\item $U_1, \\dots, U_n$ context\n\\item $q$ question\n\\item $a$ answer\n\\end{itemize}\n\nWe have $k = 1, \\dots, K$ memory layers: \n\n\\begin{itemize}\n\\item $\\{ {\\vect{m}^{(k)}}_i\\}$, memory vectors\n\\item $\\vect{u}^{(k)}$, input vector\n\\item $\\vect{p}^{(k)}$,  match between $\\vect{u}^{(k)}$ and each $\\vect{m}^{(k)}_i$\n\\item $\\{ {\\vect{c}^{(k)}}_i\\}$, another representation of the context $U_1, ..., U_n$\n\\item $\\vect{o}^{(k)}$, output.\n\\item $\\vect{\\hat{a}}= softmax(\\vect{W}(\\vect{o}^{K}))$, candidate answer\n\\end{itemize}\n\\end{frame}\n\n\n\n\\section{How to evaluate dialogs?}\n\n\n\\begin{frame}{Human evaluation  \\cite{Lowe:2016}}\n\\begin{center}\n\\includegraphics[scale=0.2]{images/exemploEval1.png}\n\\end{center}\n\n\\begin{enumerate}\n\\item \\alert{Adequacy}: the meaning equivalence between the generated and control sentence. \n\\item \\alert{Fluency}: the syntactic correctness of the generated sequence.\n\\item \\alert{Readability}: efficacy of the generated sentence in a particular context.\n\\end{enumerate}\n\n\\end{frame}\n\n\\begin{frame}{BLEU (bilingual evaluation understudy)}\n\\begin{equation}\nP_n = \\frac{\\text{number of } n\\text{-grams in both } \\hat{y} \\text{ and } y}{\\text{number of } n\\text{-grams appearing in } \\hat{y}}\n\\end{equation}    \n\\vspace{0.2cm}\n\n\\begin{equation}\nBP=\n\\begin{cases}\n1 & \\text{if } len(\\hat{y}) > len(y) \\\\\n\\exp\\left( 1 - \\frac{len(y)}{len(\\hat{y})} \\right) & \\text{otherwise}\n\\end{cases}\n\\end{equation} \n\\vspace{0.2cm}\n\n\\begin{equation}\nBLEU = BP \\; \\exp \\left(\\frac{1}{N}  \\sum_{n=1}^{N} \\log P_n \\right)\n\\end{equation}\n\\end{frame}\n\n\n\\begin{frame}{METEOR (Metric for Evaluation of Translation with Explicit ORdering)}\n\\begin{equation}\nP = \\frac{\\text{number of } \\text{unigrams in both } \\hat{y} \\text{ and } y}{\\text{number of } \\text{unigrams appearing in } \\hat{y}}\n\\end{equation}    \n\n\n\\begin{equation}\nR = \\frac{\\text{number of } \\text{unigrams in both } \\hat{y} \\text{ and } y}{\\text{number of } \\text{unigrams appearing in } y}\n\\end{equation}    \n\n\n\\begin{equation}\nF_{mean} = \\frac{10 P R}{R + 9P}\n\\end{equation}\n\n\\begin{equation}\nMETEOR = F_{mean} (1 - penalty)\n\\end{equation}\n\\end{frame}\n\n\\begin{frame}{ROUGE (Recall Oriented Understudy for Gisting Evaluation)}\n\\begin{equation}\nP_{lcs} = \\frac{lcs(\\hat{y}, y)}{len(\\hat{y})}\n\\end{equation}    \n\n\n\\begin{equation}\nR_{lcs} = \\frac{lcs(\\hat{y}, y)}{len(y)}\n\\end{equation}\n\n\\begin{equation}\nROUGE_L = \\frac{(1 + \\beta^2) P_{lcs} R_{lcs}}{R_{lcs} + \\beta^{2}P_{lcs}}\n\\end{equation}\n\nwhere $\\beta$ is usually set to favour recal ($\\beta = 1.2$).\n\\end{frame}\n\n\n\\begin{frame}{Problems \\cite{LiuLSNCP16}}\n\n\\begin{table}[h]\n\\centering\n\\label{hownottable}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n\\cellcolor{blue!50} metric & \\cellcolor{blue!50} Spearman & \\cellcolor{blue!50} $p$-value & \\cellcolor{blue!50} Pearson &  \\cellcolor{blue!50} $p$-value \\\\ \\hline\nBLEU   & $0.34$   & $< 0.01$  & $0.14$  & $0.17$ \\\\ \\hline\nMETEOR & $0.19$   & $0.06$    & $0.19$  & $0.05$ \\\\ \\hline\nROUGE  & $0.12$   & $0.22$    & $0.1$   & $0.34$ \\\\ \\hline  \n\\end{tabular}\n\\caption{Correlation between automatic metrics and human judgments based on dialog generated on Twitter}\n\\end{table}\n\n\\begin{table}[h]\n\\centering\n\\label{hownottable}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n\\cellcolor{blue!50} metric & \\cellcolor{blue!50} Spearman & \\cellcolor{blue!50} $p$-value & \\cellcolor{blue!50} Pearson &  \\cellcolor{blue!50} $p$-value \\\\ \\hline\nBLEU & $0.12$   & $0.23$    & $0.11$  & $0.26$    \\\\ \\hline\nMETEOR & $0.06$   & $0.53$    & $0.14$  & $0.16$     \\\\ \\hline\nROUGE & $0.05$   & $0.59$    & $0.06$  & $0.53$    \\\\ \\hline\n\\end{tabular}\n\\caption{Correlation between automatic metrics and human judgments based on dialog generated on Ubuntu}\n\\end{table}\n\\end{frame}\n\n\\section{Creating simplified tasks as tests}\n\n\\begin{frame}{bAbI \\cite{WestonBCM15}}\nOne solution is to create a set of QA synthetic tasks to test different capabilities of a dialog agent.\n\n\n\\begin{center}\n\\includegraphics[scale=0.25]{images/babi.png}\n\\end{center}\n\\end{frame}\n\n\n\n\\begin{frame}{ParlAI \\\\ \\url{https://github.com/facebookresearch/ParlAI}}\n\n\\begin{center}\n\\includegraphics[scale=0.84]{images/parlai.png}\n\\end{center}\n\n\"ParlAI (pronounced 'par-lay') is a framework for dialog AI research, implemented in Python.\n\nIts goal is to provide researchers:\n\n\\begin{itemize}\n\\item a unified framework for sharing, training and testing dialog models\n\\item many popular datasets available all in one place, with the ability to multi-task over them\n\\item seamless integration of Amazon Mechanical Turk for data collection and human evaluation\"\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}{Sanity check experiments}\n\\begin{center}\n\\includegraphics[scale=0.34]{images/comparative_results_babi1.png}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Sanity check experiments}\n\\begin{center}\n\\includegraphics[scale=0.34]{images/comparative_results_babi2.png}\n\\end{center}\n\\end{frame}\n\n\\section{Entailment-QA}\n\n\\begin{frame}{bAbI: task 15}\n\n\\alert{Basic Deduction}\n\n\\begin{center}\n\\includegraphics[scale=0.28]{images/babi15.png}\n\\end{center}\n\\begin{quote} \n\\centering \n$P^{1}$ are afraid of $Q^{1}$\\\\\n$P^{2}$ are afraid of $Q^{2}$\\\\\n$P^{3}$ are afraid of $Q^{3}$\\\\\n$P^{4}$ are afraid of $Q^{4}$\\\\\n$c^{1}$ is a $P^{1}$\\\\\n$c^{2}$ is a $P^{2}$\\\\\n$c^{3}$ is a $P^{3}$\\\\\n$c^{4}$ is a $P^{4}$\\\\\nWhat is $c^j$ afraid of? \\alert{A: $Q^j$}\\\\\n\\end{quote}\n\n\n\\end{frame}\n\n\n\\begin{frame}{bAbI: task 16}\n\n\\alert{Basic Induction}\n\n\\begin{center}\n\\includegraphics[scale=0.28]{images/babi16.png}\n\\end{center}\n\\begin{quote} \n\\centering \n$c^{1}$ is a $P^{1}$\\\\\n$c^{1}$ is $C^{1}$\\\\\n$c^{2}$ is a $P^{2}$\\\\\n$c^{2}$ is $C^{2}$\\\\\n$c^{3}$ is a $P^{3}$\\\\\n$c^{3}$ is $C^{3}$\\\\\n$c^{4}$ is a $P^{4}$\\\\\n$c^{4}$ is $C^{4}$\\\\\n$c$ is a $P^{j}$\\\\\nWhat color is $c$? \\alert{A: $C^j$}\\\\\n\\end{quote}\n\n\\end{frame}\n\n\n\n\n\\begin{frame}{Entailment-QA}\n\n\\begin{enumerate}\n\\item \\textbf{Boolean Connectives}\n\\item[]\n\\item \\textbf{First-Order Quantifiers}\n\\item[]\n\\item \\textbf{Synonymy}\n\\item[]\n\\item \\textbf{Antinomy}\n\\item[]\n\\item \\textbf{Hypernymy}\n\\item[]\n\\item \\textbf{Active/Passive voice}\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{Entailment-QA: task 1}\n\\begin{itemize}\n\\item \\alert{Entailment} ($s_1$ implies $s_2$)\n\\begin{itemize}\n\\item $\\underbrace{P^{1}a^1 \\land \\dots \\land P^{n}a^n}_{s_1}, \\underbrace{P^{j}a^j}_{s_2}$ \n\\item $\\underbrace{P^{j}a^j}_{s_1}, \\underbrace{P^{1}a^1 \\lor \\dots \\lor P^{n}a^n}_{s_2}$\n\\item $\\underbrace{Pa}_{s_1}, \\underbrace{\\lnot \\lnot Pa}_{s_2}$\n\\end{itemize}\n\n\\vspace{0.4cm}\n\\item \\alert{Not entailment} ($s_1$ does not imply $s_2$)\n\\begin{itemize}\n\\item $\\underbrace{P^{j}a^j}_{s_1}, \\underbrace{P^{1}a^1 \\land \\dots \\land P^{n}a^n}_{s_2}$ \n\\item $\\underbrace{P^{1}a^1 \\lor \\dots \\lor P^{n}a^n}_{s_1}, \\underbrace{P^{j}a^j}_{s_2}$\n\\item $\\underbrace{Pa}_{s_1}, \\underbrace{\\lnot Pa}_{s_2}$\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Entailment-QA: task 1}\n\\begin{itemize} \n\\item[] Ashley is fit\n\\item[] Ashley is not fit\n\\item[] The first sentence implies the second sentence? \\alert{A: no}\n\\end{itemize}\n\n\\vspace{0.3cm}\n\n\n\\begin{itemize} \n\\item[]Avery is nice and Avery is obedient\n\\item[]Avery is nice\n\\item[]The first sentence implies the second sentence? \\alert{A: yes}\n\\end{itemize}\n\n\\vspace{0.3cm}\n\n\\begin{itemize} \n\\item[]Elbert is handsome or Elbert is long\n\\item[]Elbert is handsome\n\\item[]The first sentence implies the second sentence? \\alert{A: no}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Entailment-QA: task 2}\n\n\\begin{itemize}\n\\item \\alert{Entailment}\n\\begin{itemize}\n\\item $\\forall x Px, Pa$ \n\\item $Pa, \\exists x Px$ \n\\end{itemize}\n\\item []\n\\item \\alert{Contradiction}\n\\begin{itemize}\n\\item $\\forall x Px, \\lnot Pa$ \n\\item $\\forall x Px, \\exists x \\lnot Px$ \n\\end{itemize}\n\\item []\n\\item \\alert{Neutral}\n\\begin{itemize}\n\\item $Pa,Qa$ \n\\item $\\forall x Px, \\lnot Qa$ \n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Entailment-QA: task 2}\n\n\\begin{itemize} \n\\item[] Every person is lively\n\\item[] Belden is lively\n\\item[] What is the semantic relation? \\alert{A: entailment}\n\\end{itemize}\n\n\\begin{itemize} \n\\item[] Every person is short\n\\item[] There is one person that is not short\n\\item[] What is the semantic relation?  \\alert{A: contradiction}\n\\end{itemize}\n\n\\begin{itemize} \n\\item[] Every person is beautiful\n\\item[] Abilene is not blue\n\\item[] What is the semantic relation? \\alert{A: neutral}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Entailment-QA: task proxy}\n\nSICK (Sentences Involving Compositional Knowledge) \\cite{Marelli14}\n\n\\begin{center}\n\\includegraphics[scale=0.25]{images/sick.png}\n\\end{center}\n\n\\end{frame}\n\n\n\\begin{frame}{Entailment-QA: task proxy}\n\n\\begin{itemize} \n\\item[] There is no dog leaping in the air\n\\item[] A dog is leaping high in the air and another is watching\n\\item[] What is the semantic relation? \\alert{A: contradiction}\n\\end{itemize}\n\n\\begin{itemize} \n\\item[] A man is exercising\n\\item[] A baby is laughing\n\\item[] What is the semantic relation? \\alert{A: neutral}\n\\end{itemize}\n\n\\begin{itemize} \n\\item[] Some dogs are playing in a river\n\\item[] Some dogs are playing in a stream\n\\item[] What is the semantic relation? \\alert{A: entailment}\n\\end{itemize}\n\\end{frame}\n\n\n\n\\begin{frame}{Preliminary Results}\n\\begin{center}\n\\includegraphics[scale=0.42]{images/comparative_results.png}\n\\end{center}\n\\end{frame}\n\n\n\n\\begin{frame}{Preliminary Results}\n\\begin{center}\n\\includegraphics[scale=0.28]{images/training_acc_EntailQA_mem.png}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}{Preliminary Results}\n\\begin{center}\n\\includegraphics[scale=0.42]{images/cm_mem_EntailQA2.png}\n\\end{center}\n\\end{frame}\n\n\n\\begin{frame}{Future Steps}\n\\begin{itemize}\n\\item Try to overcome the reported overfitting problem. \n\\item Finish the Entailment-QA corpus.\n\\item Explore new models not mentioned here, like \\alert{Dynamic Memory Networks} \\cite{KumarISBEPOGS15} and  \\alert{Memory Attention and Composition (MAC) cell} \\cite{Manning18}.\n\\item Create a visual version of the Entailment-QA to test logical inference with images.\n\\item Check the reinforcement learning on dialog.\n\\item Review the literature on the theory of comparing models \\cite{BenavoliCDZ17}.\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Schedule}\n\\begin{center}\n\\includegraphics[scale=0.24]{images/workplan.png}\n\\end{center}\n\\end{frame}\n\n\n\n\\begin{frame}[allowframebreaks]{References}\n\n  \\bibliography{my_references}\n  \\bibliographystyle{abbrv}\n\n\\end{frame}\n\n\\end{document}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "0fc03be84659e313921fe1593fca8f107dc3b4ec", "size": 15982, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/main.tex", "max_stars_repo_name": "felipessalvatore/quali", "max_stars_repo_head_hexsha": "500dc69a10ccd0320cc90c8c51dc13bb8097584e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentation/main.tex", "max_issues_repo_name": "felipessalvatore/quali", "max_issues_repo_head_hexsha": "500dc69a10ccd0320cc90c8c51dc13bb8097584e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/main.tex", "max_forks_repo_name": "felipessalvatore/quali", "max_forks_repo_head_hexsha": "500dc69a10ccd0320cc90c8c51dc13bb8097584e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6945337621, "max_line_length": 179, "alphanum_fraction": 0.6639344262, "num_tokens": 6006, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4228824988858553}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{February 19, 2014}\n\\maketitle\n\n\\section*{leftover}\nsine integral transform (evaluating integrals explicitly)\n\nfind:\n\\begin{align*}\n  I&=\\int_0^\\infty{\\frac{\\sin(x\\omega }{\\omega }e^{-\\alpha ^2t\\omega ^2}\\,\\mathrm{d}\\omega },& &&x&>0\\\\\n  \\intertext{convert to}\n  I=I(\\beta )&=\\int_0^\\infty{\\frac{\\sin(\\beta s}{s}e^{-s^2}\\,\\mathrm{d}s}&&&\\text{write }\\beta =\\frac{x}{\\alpha \\sqrt{t}}&>0\\\\\n  \\intertext{note}\n  I(\\beta )&=\\int_0^\\infty{\\frac{\\sin(s)}{s}e^{-s^2/\\beta ^2}\\,\\mathrm{d}s}\n  &\\to&& 0 \\text{ as }\\beta &\\to 0\\\\\n  &&\\to&&\\frac{\\pi }{2}\\text{ as }\\beta &\\to+\\infty\\\\\n  \\intertext{end note}\n  I'(\\beta )&=\\frac{\\mathrm{d}}{\\mathrm{d}\\beta }\\int_0^\\infty{\\cos(\\beta s)e^{-s^2}\\,\\mathrm{d}s}&u&=e^{-s^2}&\\mathrm{d}v&=\\cos(\\beta s)\\mathrm{d}s\\\\\n  &&\\mathrm{d}u&=-2se^{-s^2}\\mathrm{d}s&v&=\\frac{1}{\\beta }\\sin(\\beta s)\\\\\n  I'(\\beta )&=\\left.e^{-s^2}\\frac{1}{\\beta }\\sin(\\beta s)\\right\\rvert_0^\\infty-\\int_0^\\infty{\\frac{\\sin(\\beta s)}{\\beta }(-2se^{-s^2})\\,\\mathrm{d}s}\\\\\n  &=+\\frac{2}{\\beta }\\int_0^\\infty{\\sin(\\beta s)se^{-s^2}\\,\\mathrm{d}s}\\\\\n  &=\\frac{2}{\\beta }\\left(-I''(\\beta )\\right)\\\\\n  I''(\\beta )&=\\int_0^\\infty{\\sin(\\beta s)se^{-s^2}\\,\\mathrm{d}s}=-\\frac{\\beta }{2}I'(\\beta )\\\\\n  I'(\\beta )&=c_1e^{-\\beta^2 /4}\\\\\n  I(\\beta )&=c_2-c_1\\int_\\beta^\\infty{e^{t^2/4}\\,\\mathrm{d}t}\\text{ note the integration starting at }\\beta \\\\\n  &=c_2-0\\\\\n  &=\\frac{\\pi }{2}-c_1\\int_\\beta^\\infty{e^{-t^2/4}\\,\\mathrm{d}t}\\\\\n  I(0)&=\\frac{\\pi }{2}-c_1\\int_0^\\infty{e^{-t^2/4}\\,\\mathrm{d}t}\\\\\n  \\intertext{fact $\\int_0^\\infty{e^{-x^2}\\,\\mathrm{d}x}=\\frac{\\sqrt{\\pi }}{2}$}\n  \\frac{1}{2}\\int_0^\\infty{e^{-t^4}\\,\\mathrm{d}t}&=\\frac{\\sqrt{\\pi }}{2}\\\\\n  I(\\beta )&=\\frac{\\pi }{2}-\\frac{\\sqrt{\\pi }}{2}\\int_x^\\infty{e^{-x^2/4}\\,\\mathrm{d}x}\\\\\n  \\intertext{note error function (erf)}\n  \\text{erf}(x)&=\\frac{2}{\\sqrt{\\pi }}\\int_0^\\infty{e^{-t^2}\\,\\mathrm{d}t}\\to1 \\text{ as }x\\to\\infty\\\\\n  \\text{erfc}(x)&=1-\\text{erf}(x)=\\frac{2}{\\sqrt{\\pi }}\\int_x^\\infty{e^{-t^2}\\,\\mathrm{d}t}\\\\\n  \\intertext{graph on page 79}\n  \\intertext{end note}\n  x&=2t&\\mathrm{d}x&=2\\mathrm{d}t\\\\\n  0&=\\frac{\\pi }{2}-c_2\\sqrt{\\pi }&\\frac{\\sqrt{\\pi }}{2}&=c_1\\\\\n  I(\\beta )&=\\frac{\\pi }{2}-\\frac{\\sqrt{\\pi} }{2}\\int_{t/2\\cdot2t?}^\\infty{2e^{-t^2}\\,\\mathrm{d}t}\\\\\n  &=\\frac{\\pi }{2}-\\frac{\\sqrt{\\pi }}{2}\\cdot2\\cdot\\frac{\\sqrt{\\pi }}{2}\\left(\\frac{2}{\\sqrt{\\pi }}\\int_{2t}^\\infty{e^{-u^2}\\,\\mathrm{d}u}\\right)\\\\\n  &=\\frac{\\pi }{2}-\\frac{\\pi }{2}\\text{erfc}\\left(\\frac{\\beta }{2}\\right)\\\\\n  \\intertext{solution on p79}\n  u(x,t)&=A\\text{erfc}\\left(\\frac{x}{2\\alpha \\sqrt{t}}\\right)\n\\end{align*}\n\\section*{last homework problem (hw09)}\nwe can do this without paying attention to formula's at all because the idea is so simple.\n\\begin{align*}\n  u_x(0,t)&=0=f(t)\\\\\n  u_x(1,t)+hu(1,t)&=1=g(t)\n\\end{align*}\nintroduce $u(x,t)=\\omega (x,t)+\\text{adjustment}$. This adjustment is chosen to obtain hetorgeneous boundary conditions ($f(t)=g(t)=0$). Take adjustment to be $+a(t)+bt)x$ because original boundary values (0 and 1) lie on a line.\n\\begin{align*}\n  u&=\\omega +a(t)+b(t)x\\\\\n  \\omega_x(0,t)+b(t)+0&=f(t)\\\\\n  (\\omega_x(1,t)+b(t))+h(\\omega (1,t)+a(t)+b(t)\\cdot1)&=g(t)\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "fbd1ed0ea087ad0bfc563470168d3e8fa5b96cf7", "size": 3345, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "partial differential equations/pde-notes-2014-02-19.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "partial differential equations/pde-notes-2014-02-19.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "partial differential equations/pde-notes-2014-02-19.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.9253731343, "max_line_length": 229, "alphanum_fraction": 0.5886397608, "num_tokens": 1513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.42276381149546144}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[super,square]{natbib}\n\\usepackage{tabularx}\n\\usepackage{parskip}\n\\usepackage[margin=1.4in]{geometry}\n\\usepackage{csquotes}\n\\usepackage{mathrsfs}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\usepackage{mdframed}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{subcaption}\n\n% Book headers\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\fancyhead[L]{\\rightmark}\n\\fancyhead[R]{\\thepage}\n\\renewcommand{\\headrulewidth}{0pt}\n\n\n\\definecolor{blueish}{HTML}{CAC8FA}\n\n\\newcommand{\\comment}[1]{}\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{proposition}{Proposition}[theorem]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{identity}[theorem]{Identity}\n\n\\theoremstyle{definition}\n\\newtheorem{defn}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\\newenvironment{definition}\n  {\\vspace{8pt}\\begin{mdframed}[backgroundcolor=blueish,innertopmargin=4]\\begin{defn}}\n  {\\end{defn}\\end{mdframed}\\vspace{4pt}}\n\n\n\\title{\\vspace{-3cm} Fiber Bundles, Gauges, and Connections}\n\\author{}\n\\date{}\n\n\n\\begin{document}\n\\maketitle\n\\vspace{-1.5cm}\n\\tableofcontents\n\\newpage\n\n\\section{Bundles}\n\\subsection{Fiber Bundles}\n    \n    \n    % \\begin{figure}[h]\n    % \\begin{subfigure}{0.5\\textwidth}\n    %     \\includegraphics[width=8cm]{fiber-bundle.png}\n    % \\end{subfigure}\n    \n    % \\begin{subfigure}{0.5\\textwidth}\n    %     \\includegraphics[width=5cm]{fiber-bundle-mobius.png}\n    % \\end{subfigure}\n    % \\end{figure}\n    \n    \n    \n    A fiber bundle makes precise the idea of one topological space (called a fiber) being ``parameterized'' by another topological space (called a base). A fiber bundle also comes with a group action on the fiber. This group action represents the different ways the fiber can be viewed as equivalent. Formally, a fibre bundle is a structure ${\\displaystyle (E,\\,B,\\,\\pi ,\\,F)}$. The topological space $E$ is known as the \\textit{total space} of the fibre bundle, $B$ as the \\textit{base space}, and $F$ the standard or template \\textit{fiber}. The map ${\\displaystyle \\pi :E\\rightarrow B}$, called the \\textit{projection map} or \\textit{submersion} of the bundle, is a continuous surjection satisfying a \\textit{local triviality condition}. This condition enables a local section of a manifold to be interpreted as a trivial i.e. as cartesian product space ($B\\times F$), despite global topology possibly being more complicated, i.e. twisted or non-orientable.\n    \n    For any $p \\in B$, the pre-image ${\\displaystyle \\pi ^{-1}(\\{p\\})}$ is homeomorphic to $F$ and is called a \\textit{fiber} over $p$. Recall, a homeomorphism is a kind of topological isomorphism, i.e. it is a continuous bijective (invertible) function between topological spaces. Every fibre bundle ${\\displaystyle \\pi :E\\rightarrow B}$ is an open map, since projections of products are open maps. Specifically, we require that for every $p \\in B$, there is an open neighborhood ${\\displaystyle U\\subset B}$ of $p$ (a trivializing neighborhood) such that there is a homeomorphism ${\\displaystyle \\varphi :\\pi ^{-1}(U)\\rightarrow U\\times F}$ (where ${\\displaystyle U\\times F}$ is the product space) in such a way that $\\pi$ agrees with the projection onto the first factor.  \n    \n    % Therefore $B$ carries the quotient topology determined by the map $\\pi$.\n    \n    % the fiber at each point of the base space consists of possible coordinate bases for use when describing the values of objects at that poin\n\n    \n    The canonical example of a nontrivial bundle $E$ is the Möbius strip. It has the circle that runs lengthwise along the center of the strip as a base $B$ and a line segment for the fiber $F$. A neighborhood $U$ of ${\\displaystyle \\pi (x)\\in B}$ (where $x \\in E$) is an arc. The preimage $\\pi ^{-1}(U)$ is a partially twisted slice of the strip four squares wide and one long. A homeomorphism $\\varphi$ exists that maps the preimage of $U$ to a slice of a cylinder: curved, but not twisted. This pair locally trivializes the strip, with the corresponding trivial bundle $\\displaystyle B\\times F$ being a cylinder whereas the Möbius strip has an overall twist that is only visible globally.\n\n    A \\textit{section} (or cross section) of a fiber bundle $E$ is a continuous right inverse of the projection function $\\pi$. In other words, if $E$ is a fiber bundle over a base space, $B$, then a section of that fiber bundle is a continuous map, ${\\displaystyle \\sigma \\colon B\\to E}$ such that $\\pi (\\sigma (x))=x$ for all ${\\displaystyle x\\in B}$. \n    \n    \n    Additional structures on $F$ give rise to special types of fiber bundles, e.g. vector bundles or group bundles.  Associated bundles allow derivation of bundles in which the typical fiber of a bundle changes from $F_{1}$ to $F_{2}$, which are both topological spaces with a group action of $G$, e.g. adjoint bundles, frame bundles, determinant bundles, dual bundles. \n\n\\subsection{Vector Bundles}\n\n    If $F = V$ is a vector space, one defines a \\textit{vector bundle} with standard fiber $V$ to be a fiber bundle $\\pi : E \\rightarrow B$ where all fibers $\\pi^{-1} (b)$ are vector spaces and the local trivializations $\\phi_\\alpha$ can be chosen to be fiberwise linear. A homomorphism of two vector bundles is a fiber bundle homomorphism that is fiberwise linear. The fibered product of vector bundles $E_1; E_2$ is a vector bundle (also called Whitney sum and denoted $E1 \\oplus E2$).\n\n\n\\subsection{Group Bundle}\n\n    Recall, a Lie group is a group that is also a differentiable manifold where points can be multiplied together, they have inverses, and these operations are defined to be smooth (differentiable). If $F = G$ has the structure of a Lie group, one defines a \\textit{group bundle}, $\\mathcal G \\rightarrow B$ with standard fiber $G$ to be a fiber bundle where all fibers carry group structures and the local trivializations can be chosen to be a fiberwise group homomorphisms. A group bundle homomorphism is a fiber bundle homomorphism which is fiberwise a group homomorphism. The fibered product of group bundles is a group bundle. One has natural bundle maps $\\mathcal G \\times^B \\mathcal G \\rightarrow \\mathcal G$ (fiberwise group multiplication) and $\\mathcal G \\rightarrow \\mathcal G $ (fiberwise inversion). Similarly, one defines algebra bundles, Lie algebra bundle as well as fiberwise linear actions of group or algebra bundles on vector bundle\n\n\n\\subsection{Principal Bundle}\n     A principal $G$-bundle (also called a G-torsor over X) share similar properties to the resulting space of a Cartesian product of a space with a group. They are a fiber bundle $\\pi: \\mathcal P \\rightarrow X$ together with a continuous right action $\\mathcal P \\times G \\rightarrow \\mathcal P$ such that $G$ preserves the fibers of $\\mathcal P$ (i.e. if $y \\in \\mathcal P_x$ then $yg \\in \\mathcal P_x$ for all $g \\in G$) and acts freely and transitively (i.e. regularly) on them in such a way that for each $x\\in X$ and $y \\in \\mathcal P_x$, the map $G \\rightarrow \\mathcal P_x$ sending $g$ to $yg$ is a homeomorphism. In particular each fiber of the bundle is homeomorphic to the group $G$ itself. One can also define principal $G$-bundles in the category of smooth manifolds. Here $\\pi : \\mathcal P \\rightarrow X$ is required to be a smooth map between smooth manifolds, $G$ is required to be a Lie group, and the corresponding action on $\\mathcal P$ should be smooth. \n\n\\subsubsection{Associated Bundles}\n    Recall, associated bundles allow derivation of bundles in which the typical fiber of a bundle changes from $F_{1}$ to $F_{2}$, which are both topological spaces with a group action of $G$, e.g. adjoint bundles, frame bundles, determinant bundles, dual bundles. \n    \n    Let $\\pi : \\mathcal P \\rightarrow B$ be a principal $G$-bundle. Given a\n    $G$-manifold $F$, one defines the associated fiber bundle by\n    \\[\n    F (\\mathcal P) \\equiv \\mathcal P \\times_G F := (\\mathcal P \\times F) / G:\n    \\]\n    The space $\\mathcal P \\times_G F$ is a fiber bundle over $B = \\mathcal P=G$ with standard fiber $F$. The sections  $\\Gamma^\\infty(\\mathcal B, \\mathcal P \\times_G F )$ of this fiber bundle are naturally identified with the space $C^\\infty (\\mathcal P, F )^G$ of equivariant maps $\\mathcal P \\rightarrow F$.\n\n\\subsubsection{Adjoint Bundle} \n\n    An adjoint bundle is a vector bundle naturally associated to any principal bundle. The fibers of the adjoint bundle carry a Lie algebra structure making the adjoint bundle into a (nonassociative) algebra bundle. If $V$ is a vector space on which $G$ acts linearly, then $P \\times_G V$ is a vector bundle. Taking $V = g$ with the adjoint representation one obtains the adjoint bundle $\\mathfrak g(\\mathcal P ) := \\mathcal P \\times_G \\mathfrak g$.\n    \n    If $K$ is a Lie group on which $G$ acts by automorphisms, $\\mathcal P \\times_G K$ is a group bundle. Taking $K = G$ with $G$ acting by the adjoint action, one obtains a group bundle $G( \\mathcal P) := \\mathcal P \\times_G G$ which is also called the adjoint bundle. It has $\\mathfrak g( \\mathcal P)$ as its Lie algebra bundle.   \n\n\\subsection{Fibrations}\n    Fibrations do not necessarily have the local Cartesian product structure that defines the more restricted fiber bundle case, but something weaker that still allows ``sideways'' movement from fiber to fiber. A fibration is like a fiber bundle, except that the fibers need not be the same space, nor even homeomorphic; rather, they are just homotopy equivalent.  Recall, homotopy equivalent implies that if $X$ and $Y$ are a pair of continuous maps $f : X \\rightarrow Y$ and $g : Y \\rightarrow X$, such that $g \\circ f$ is homotopic to the identity map $id_X$ and $f \\circ g$ is homotopic to $id_Y$. Intuitively, two spaces $X$ and $Y$ are homotopy equivalent if they can be transformed into one another by bending, shrinking and expanding operations\n    \n    \n    A fibration satisfies an additional condition (the homotopy lifting property) guaranteeing that it will behave like a fiber bundle from the point of view of homotopy theory. Weak fibrations discard even this equivalence for a more technical property. Every vector bundle is a fiber bundle with a fiber homotopy equivalent to a point.  Fibrations are dual to cofibrations, with a correspondingly dual notion of the homotopy extension property; this is loosely known as Eckmann–Hilton duality.\n    \n\n\\section{Connections}\n    The notion of a \\textit{connection} defines the idea of transporting data along a curve or family of curves in a parallel and consistent manner. A \\textit{covariant derivative} is a linear differential operator which takes the directional derivative of a section of a vector bundle in a covariant manner. It also allows one to formulate a notion of a parallel section of a bundle in the direction of a vector: a \\textit{section} $s$ is parallel along a vector $X$ if $\\nabla _{X}s=0$. \n\n\\subsection{Ehresmann and Principal Connections}\n    An \\textit{Ehresmann connection} is a connection in a fibre bundle or a principal bundle made by specifying the allowed directions of motion of the field. Specifically, it singles out a vector subspace of each tangent space to the total space of the fiber bundle, called the horizontal space. A section $s$ is then horizontal (i.e., parallel) in the direction $X$ if $\\rm {d}s(X)$ lies in a horizontal space.\n\n    For any fiber bundle $\\pi : E \\rightarrow B$ the tangent bundle $T E$ of the total space has a distinguished subbundle, the vertical bundle $V E \\hookrightarrow T E$. The fiber $V_xE$ for $\\pi(x) = b$ is the image of $T_x(F_b)$ under the natural inclusion $T F_b \\hookrightarrow T E$. An Ehresmann connection on $E$ is the choice of a complementary horizontal subbundle $HE$ such that $T E = V E \\oplus HE$. Equivalently, a connection is a bundle projection $T E \\rightarrow V E$ which is left-inverse to the inclusion $V E \\rightarrow T E$; one defines $HE$ as the kernel of this projection. \n    \n    The Ehresmann connection has the immediate benefit of being definable on a much broader class of structures than vector bundles and is well-defined on a general fiber bundle. Many of the features of the covariant derivative still remain: parallel transport, curvature, and holonomy. With the classical covariant derivatives, covariance is an a posteriori feature of the derivative. However, for an Ehresmann connection, it is possible to impose a generalized covariance principle from the beginning by introducing a Lie group acting on the fibers of the fiber bundle. The appropriate condition is to require that the horizontal spaces be equivariant with respect to the group action.\n\n    If the standard object $F$ has additional structure, one is interested in connections such that parallel transport preserves that structure. For example, if $E$ is a vector bundle, each parallel transport operation, $\\Pi^\\gamma$, should be a linear map, and for group bundles it should be a fiberwise group homomorphism, and so on.\n    An important special case of Ehresmann connections are principal connections on principal bundles, which are required to be equivariant in the principal Lie group action.   A principal connection on a fiber bundle is an equivariant Lie algebra valued 1-form $\\theta \\in \\Gamma^1 (\\mathcal P, \\mathfrak g)^G$ such that $\\iota(\\xi_{\\mathcal P})\\theta = \\xi$ (where $\\iota$ is an inclusion embedding) for all $\\xi \\in \\mathfrak g$, the Lie algebra.  \n    \n    The space of principal connections will be denoted $\\mathcal A(P)$. The space $\\mathcal A(P)$  has a natural affine structure, with underlying vector space the space $\\Gamma^1 (B, \\mathfrak g( \\mathcal P))$ of 1-forms on $B$ with values in the adjoint bundle.\n\n\\subsection{Cartan Connections}\n    TODO\n\n\\section{Gauges}\n    \n    A gauge can be thought of as a coordinate system that varies depending on one’s location with respect to some base space or parameter space. A gauge transform is a change of coordinates applied to each such location, and a gauge theory is a model for some physical or mathematical system to which gauge transforms can be applied and is typically gauge invariant, in that all physically meaningful quantities are left unchanged or transform naturally under gauge. A principal bundle automorphism is a $G$-equivariant diffeomorphism $\\phi : \\mathcal P \\rightarrow \\mathcal P$ taking fibers to fibers. The group of principal bundle automorphisms will be denoted $\\hbox{Aut}( \\mathcal P)$. \n    \n    The space of \"coordinate systems\" is (non-canonically) identifiable with the isomorphism group $\\hbox{Isom}(G)$ of template $G$.  This isomorphism group is called the structure group or gauge group of the class of geometric objects. The gauge group $\\hbox{Gau}( \\mathcal P) \\subseteq \\hbox{Aut}(\\mathcal P)$ consists of automorphisms $ \\phi : \\mathcal P \\rightarrow \\mathcal P$ inducing the identity map on the base $B$. That is, $\\hbox{Gau}( \\mathcal P)$ is defned by an \\textit{exact sequence} of groups\n    \\[\n        1 \\longrightarrow \\hbox{Gau}( \\mathcal P) \\longrightarrow \\hbox{Aut}( \\mathcal P) \\longrightarrow \\hbox{Diff} B)\n    \\]\n    Let $\\theta$ be a principal connection on $\\pi : \\mathcal P \\rightarrow B$. For any path $\\gamma : [t_0, t_1] \\rightarrow B$, let \n    \\[\n        \\Pi^\\theta_\\gamma : P_{\\gamma(t_0)} \\rightarrow P_{(t_1)} \n    \\]\n    denote parallel transport with respect to $\\theta$. For all $\\phi \\in \\hbox{Gau}(\\mathcal P)$,\n    \\[\n        \\Pi_{\\gamma}^{\\phi,\\theta} = \\phi(\\gamma(t_1)) \\circ  \\Pi_{\\gamma}^{\\theta} \\circ  \\phi(\\gamma(t_0))^{-1}\n    \\]\n    The group of automorphisms $\\hbox{Aut}( \\mathcal P)$ acts on the space $\\mathcal A( \\mathcal P)$ of principal connections by pull-back by the inverse. This can be understood as the gauge transformations of connections. We can interpret $\\mathcal A( \\mathcal P)$ as an infinite dimensional manifold, equipped with an action of an infinite-dimensional Lie Group. \n\n\n\\section{Moduli Spaces}\n    \\subsection{Review of differential forms}\n    Recall from differential geometry notebook \\footnote{\\url{https://github.com/lukepereira/notebooks}} the definitions of differential forms, wedge products and the hodge star operations:\n    \n        \\begin{itemize}\n            \\item A differential \\textit{$k$-form }on an open subset $U \\subseteq \\mathbb R^m$ is an expression of the form \n            \\[\n                \\omega = \\sum_{i_1 \\dots i_k} \\omega i_1\\dots i_k dx^{i_1} \\wedge \\dots \\wedge  dx^{i_k}\n            \\] \n            where $\\omega_{i_1\\dots i_k} \\in C^\\infty(U)$ are functions, and the indices are numbers $1 \\leq i_1 < \\dots < i_k \\leq m$. The symbol $\\wedge$ denotes the exterior product of two differential forms.\n            \n            \\item The \\textit{exterior product} or \\textit{wedge product} is the product operator in an exterior algebra. If $\\alpha$ and $\\beta$ are differential $k$-forms of degrees $p$ and $q$, respectively, then\n            \\[\n                \\alpha \\wedge \\beta=(-1)^{pq} \\beta \\wedge \\alpha. \t\n            \\]\n            It is not (in general) commutative, but it is associative, and bilinear. \n            \n            Let $\\alpha, \\beta \\in \\Omega^1(M)$. Then we define a wedge product $\\alpha \\wedge \\beta \\in \\Omega^2 (M)$, as follows:\n            \\[\n                (\\alpha \\wedge \\beta)(X,Y) = \\alpha (X)\\beta(Y)-\\alpha(Y)\\beta(X).\n            \\]\n            \n            \\item Let $V$ be an n-dimensional vector space with basis $\\{ e_1, \\cdots, e_n \\}$ and with unit vector given by $\\omega := e_1 \\wedge \\cdots \\wedge e_n$ . Note, the dual of $\\omega$ is the volume form, $\\hbox{det}$.\n            \n            An inner product $\\langle \\cdot,\\cdot \\rangle$ induces pairs of k-vectors $\\alpha, \\beta \\wedge^k V$ and has the Gram determinant:\n            \\[\n            {\\displaystyle \\langle \\alpha ,\\beta \\rangle =\\det \\left(\\left\\langle \\alpha _{i},\\beta _{j}\\right\\rangle \\right)_{i,j=1}^{k}}\n            \\]\n            For all pairs of k-vectors, the \\textit{Hodge Star operator} can be defined as having property, \n            \\[\n                \\alpha \\wedge (* \\beta ) = \\langle \\alpha, \\beta \\rangle \\omega.\n            \\]\n            Applying ${\\displaystyle \\det }$ to the above equation, we obtain the dual definition:\n            \\[\n                {\\displaystyle \\det(\\alpha \\wedge {\\star }\\beta )=\\langle \\alpha ,\\beta \\rangle .}\n            \\]\n            \n        \\end{itemize}\n    \n\n    \\subsection{Moduli Space of Connections}\n    The quotient space of the space of principal connections and the Gauge  $\\mathcal A(P) / \\hbox{Gau}(P)$ is called the moduli space of connections. It is still infnite-dimensional. To obtain a finite dimensional moduli spaces, one has to impose additional gauge-invariant constraints on $\\theta$: e.g. that it is a flat connection, or more generally a Yang-Mills connection. \n    \n    \\subsection{Moduli Space of Yang-Mills Connections}\n    \n    On a principal bundle, we want to choose a canonical connection so that curvature $F_\\theta$ vanishes. But not every principal bundle can have a flat connection, and the best one can hope for is that the bundle has curvature as small as possible. On a bundle of connections, a connection is defined by its local forms ${\\displaystyle \\theta_{\\alpha }\\in \\Omega ^{1}(U_{\\alpha },\\operatorname {ad} (P))}$. The Yang-Mills action functional $YM(\\theta)$ is precisely the square of the ${\\displaystyle L^{2}}$-norm of the curvature which has critical points, i.e. local minima, that minimize curvature called Yang-mills connections. These Yang-mills connections, $\\mathcal M$, are a finite subset of the moduli space of connections that was originally sought after, i.e. $\\mathcal M \\subset \\mathcal A(P) / \\hbox{Gau}(P)$. This is more rigoursly described below. As a side note, in physics the gauge field strength is given by curvature of connections, $F^\\theta$, and the energy of the gauge field is the Yang-mills functional.\n    \n    \n    Suppose $\\pi : \\mathcal P \\rightarrow B$ is a principal $G$-bundle over a compact, oriented, Riemannian manifold $B$. The inner product on $T B$ gives rise to an inner product on $T M$ and on all $ \\wedge^k T^*M$. Taking the inner product of the differential form, followed by integration over $B$ with respect to the Riemannian volume form, defines an inner product on $\\Omega^* (B)$. In terms of the Hodge star operator, \n    \\[\n        \\langle \\alpha, \\beta \\rangle = \\int_B \\alpha \\wedge  * \\beta\n    \\]\n    Let $|| \\cdot ||$ be the norm corresponding to $\\langle \\cdot, \\cdot \\rangle$. The Yang-Mills functional on $\\mathcal A(\\mathcal P)$ is the functional \n    \\[\n        \\hbox{YM}(\\theta) = ||F ||^2 = \\int_B (F^\\theta, * F^\\theta)\n    \\]\n    The Yang-Mills functional is invariant under the action of the gauge group, i.e. $YM(\\theta) = YM(\\phi,\\theta)$, hence all its critical points (called Yang-Mills connections) are invariant as well. A connection $\\theta$ is a critical point of the Yang-Mills functional if and only if it satisfies the Yang-Mills equation, $d^\\theta * F^\\theta = 0$. The quotient of the space of Yang-Mills connections by the action of the gauge group is called the Yang-Mills moduli space. In this context, the term ``moduli'' is used synonymously with ``parameter''. \n    \n    \n    Moduli of Yang–Mills connections have been most studied when the dimension of the base manifold X is four. Here the Yang–Mills equations admit a simplification from a second-order PDE to a first-order PDE, known as the anti-self-duality equations. The Yang-Mills equations depend upon the Riemannian metric on $B$ only via the star operator on $\\Gamma^2 (B)$. The case $\\dim B = 4$ is special in that it takes $\\Gamma^2 (B)$ to itself, since $4 - 2 = 2$. We mentioned already that in this case the Yang-Mills equations are conformally invariant: Multiplying the metric by a positive function does not change the star operator in middle dimension, hence does not change the Yang-Mills equations. A special type of Yang-Mills connections in $4$ dimensions are those satisfying one of the equations \n    \\[\n        *F^\\theta = F^\\theta \\text{\\ \\ or \\ \\  }  *F^\\theta = - F^\\theta \n    \\]\n    (self-duality and anti-self-duality respectively) because for such connections, the Yang-Mills equations are a consequence of the Bianchy identity $d^\\theta F^\\theta = 0$. A change of orientation of $B$ changes the sign of the  operator, and therefore exchanges the notion of duality and anti-self duality. For certain principal bundles ($\\theta$ is a multiple of the second Chern number), ASD connections give the absolute minimum of the Yang-Mills functional.\n    \n    % Anti-self dual connections over S4 are also called instantons.\n    \n    % The moduli space for anti-self dual YM-connections for G = SU(2) is the starting point for Donaldson theory of 4-manifolds. As realized by Donaldson, they contain information not only about the topology but also the differentiable structure of 4-manifolds.\n    \n\n\\section{Examples}\n\n% \\subsection{Review: Lagrangian and Hamiltonian}\n%     - The Lagrangian L = K - V is big when most of the energy is in kinetic form, and small when most of the energy is in potential form\n%     - Lagrangian measures something we could vaguely refer to as the ‘activity’ or ‘liveliness’ of a system: the higher the kinetic energy the more lively the system, the higher the potential energy the less lively. So, we’re being told that nature likes to minimize the total of ‘liveliness’ over time: that is, the total action. (Principle of Least Action)\n\n%     Hamiltonian:\n%     - The simplest interpretation of the Hamilton equations is as follows, applying them to a one-dimensional system consisting of one particle of mass m under time-independent boundary conditions: The Hamiltonian H represents the energy of the system (provided that there are NO external forces, or additional energy added to the system), which is the sum of kinetic and potential energy, traditionally denoted T and V, respectively.\n%     - e very careful about making the assumption that H = T + V. You should always default to the definition of H which is H = Sum\\_i(qdot\\_i * partial L/partial qdot\\_i) - L\n    \n\\subsection{Relativity}\n\n    In gauge theories, physicists begin with a Lagrangian $L[\\phi, \\phi']$. The claim is that this $L$ is invariant under the action of some group. What is a bit tricky is that to make this statement a bit more precise requires that we have two fiber bundles at once, namely the principal-$G$ bundle and its associated vector bundle. For each patch of spacetime, $U_i$ where $M$ is base manifold, we pick a map $S:U_i \\rightarrow G$ (this will later be the gauge group). Then we pick a certain representation of the group, i.e $\\rho :G \\rightarrow V$ where $V$ is a vector space. We now define what will later be a section $\\psi : U_i \\rightarrow[x,\\phi]$ where $x$ is a point on the manifold. In this context, gauge invariance means that $[x,\\phi] \\sim [x,\\rho (g^{-1})\\phi]$. \n    \n    Recall, we have the spacetime patch $U_i$ with the map $S$. With this, we construct the cartesian product $U_i \\times G$. If we happen to find two overlapping open sets $U_i$ and $U_j$ then for the sets of points in the intersection we have to make sure things are consistent and so we define functions $t_{ij} : U_i \\cap U_j \\rightarrow G$ that will act on $G$ i.e $(x,G) \\rightarrow (x, t_{ij}(x)G)$. Doing this for the whole manifold $M$ gives us another manifold $P$ that is locally $U_i \\times G$. This the principal-G bundle.\n    \n    Requiring local gauge invariance in the first step meets a snag. The problem involves the map $S$; as we go around on the manifold $M$ we need a method to go from one fiber to another fiber on the principal-G bundle. To do this requires we introduce a connection $\\Omega$ on the principal-G bundle. But physicists always work on the base manifold, so we need to pull back $\\Omega$ to the base manifold by some section $\\sigma$ i.e calculate $\\sigma^*\\Omega \\equiv A$. Since these are locally defined sections, when we are in intersection of two spacetime patches, $U_i \\cap U_j$, we will have two sections, $\\sigma,\\sigma'$. This means we will get $\\sigma^*\\Omega=A$ and $\\sigma'^*\\Omega=A'$. The two sections are related by the map $S$ i.e $\\sigma'=R_{S(x)}\\sigma=\\sigma_{S(x)}=\\sigma g$. That is, the group acts by a right action.\n    \n    To calculate $\\sigma^*\\Omega$ we note that $\\langle \\sigma^*\\Omega, v \\rangle = \\langle \\Omega, \\sigma_* v\\rangle$ where $v$ is a vector on the principal bundle. A tricky calculation shows $\\sigma'_*v = R_{g*}(\\sigma_{*}v)+\\eta_x(p)$ where $\\eta X$ is a fundamental vector field, $X = \\langle S^*\\theta,v \\rangle$ and $\\theta$ is the Maurer-Cartan form and $g$ is the image of $S$. To show this works we do the calculation \n    \\begin{align*}\n            (\\sigma'^* \\omega)(v) & = <\\Omega,\\sigma'v> \\\\\n            &= <\\Omega,R_{g*}(\\sigma_*v)>+<\\Omega,\\eta_X(pg)\\\\\n            &= <R^*_g\\Omega,\\sigma_*v> +X \\\\\n            &= <Ad_{g^-1}\\Omega,\\sigma_*v>+X=<Ad_{g^{-1}}A + S^*\\theta,v>\n    \\end{align*}\n    This is the usual transformation rule for the gauge field on the base manifold. We can now state the fact that we have an associated bundle $\\mathcal A$ which is $\\mathcal{P}\\times_G V = (\\mathcal{P}\\times V)/G$ and is locally $U_i \\times V$ with sections as defined in the first step. The sections on this bundle are what physicists call the fields.\n\n\n\\begin{thebibliography}{}\n\n\\bibitem[]{}\nTao, T. What is a gauge? (2008).\\\\ \\url{https://terrytao.wordpress.com/2008/09/27/what-is-a-gauge/}\n% https://terrytao.wordpress.com/2008/09/27/what-is-a-gauge/\n\n\\bibitem[]{}\nEckhard Meinrenken, Principal bundles and connections.\\\\ \\url{http://www.math.toronto.edu/mein/teaching/moduli.pdf}\n\n\n\\bibitem[]{}\nKobayaschi, S. Theory of connections. Annali di Matematica 43, 119–194 (1957).\n% file:///home/luke/Downloads/Kobayaschi1957_Article_TheoryOfConnections.pdf\n\n\\end{thebibliography}\n\n\n\\end{document}\n", "meta": {"hexsha": "51d7fd521fae6f5f4b8c9c720863e3ebd2268178", "size": 28098, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/2021-gauge-theory/main.tex", "max_stars_repo_name": "lukepereira/latex-ci", "max_stars_repo_head_hexsha": "4390a2da344ec00a3f651f464c79b7e097cbabe6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-09-04T20:32:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T21:30:32.000Z", "max_issues_repo_path": "documents/2021-gauge-theory/main.tex", "max_issues_repo_name": "lukepereira/latex-ci", "max_issues_repo_head_hexsha": "4390a2da344ec00a3f651f464c79b7e097cbabe6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-07-13T01:21:22.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-13T02:09:19.000Z", "max_forks_repo_path": "documents/2021-gauge-theory/main.tex", "max_forks_repo_name": "lukepereira/latex-ci", "max_forks_repo_head_hexsha": "4390a2da344ec00a3f651f464c79b7e097cbabe6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.071942446, "max_line_length": 1028, "alphanum_fraction": 0.723147555, "num_tokens": 7366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.4227637942139273}}
{"text": "%\\subsubsection{(TODO) The Carnot Engine, Revisited}\n%Before moving onto the statistical definition of entropy, let's answer a question about Carnot engines that might have arose as we learned about entropy; \n%\\textit{How can Carnot Engines run reversibly if macroscopic processes are not truly reversible?}The answer is twofold. First, as we mentioned before the Carnot process is an idealization. It involves two isothermal steps, and as we've discussed no process is truly isothermal, unless it ran for an infinitely long time. Second, you need to be careful what system your considering when you say a process is reversible. The heat engine has zero change in entropy. However, when it interacts with its surroundings it inevitably changes the surrounding's entropy as well. Actually modelling this change in entropy would be fiendishly difficult \\textbf{Rio Help I'm not sure this is right}, but we'd expect a high level of idealization to be necessary to actually make it zero, and otherwise for it to be positive. We could try to get around this problem by isolating the engine, but the efficiency of the engine is less than 100\\%, so it needs a source of energy outside the system.\n\n\\subsubsection{(Optional) The Carnot Efficiency, Revisited}\nTo finish off this section, I want to show you a neat proof of Carnot's theorem; This theorem tells us that the maximum efficiency of a heat engine is given by $\\eta = 1- \\frac{T_C}{T_H}$ (the efficiency of the Carnot engine), where $T_C$ is the coldest temperature within the cycle, and $T_H$ is the hottest temperature within the cycle. We will explore in this section how this follows from the second law of thermodynamics. This section is completely optional, and just for your curiosity\\footnote{Like seriously, this is completely out of the scope of Science One}, though you have all the tools you need to prove it yourself. To review how a heat engine fundamentally works, it takes in some heat $Q_H$ from a hot reservoir at temperature $T_H$, does some work $W$ with that energy, and then throws away waste heat $Q_C$ into a cold reservoir at temperature $T_C$, before returning to its initial state. This is pictured below:\n\\begin{center}\n    \\begin{tikzpicture}[scale=3]\n    \\filldraw[fill=pink] (0,0) rectangle (1,1);\n    \\draw (1.75,0.25) rectangle (2.25,0.75);\n    \\filldraw[fill=blue!50] (3,0) rectangle (4,1);\n    \\draw[->] (1.15,0.5) -- (1.6,0.5);\n    \\draw[->] (2.4,0.5) -- (2.85,0.5);\n    \\draw[->] (2,0.2) -- (2,0);\n    \\node[above] at (1.375,0.5) {$Q_H$};\n    \\node[above] at (2.625,0.5) {$Q_C$};\n    \\node[left] at (2,0.1) {$W$};\n    \\draw (2,0.5) node {Engine};\n    \\draw (0.5,0.5) node {Hot bath at $T_H$};\n    \\draw (3.5,0.5) node {Cold bath at $T_C$};=\n    \\end{tikzpicture}\n\\end{center}\n\n\nNow, let's consider the entropy of the hot reservoir, the engine, and the cold reservoir at the end of one cycle (in other words, we consider the change in entropy of the universe after one cycle). We recall that entropy is a function of state, and therefore at the end of a single cycle, the entropy of the heat engine itself must be the same as when it started. That is, $\\Delta S_{engine} = 0$ for one full cycle. By the second law of thermodynamics $dS \\geq \\frac{Q}{T}$, the entropy of the hot reservoir decreases by the amount of heat $Q_H$ divided by its temperature $T_H$, so the entropy of the hot reservoir decreases by $\\Delta S_{hot} \\geq \\frac{-Q_H}{T_H}$. Conversely, the cold reservoir increases in one cycle by $\\Delta S_{cold} \\geq \\frac{Q_C}{T_C}$ (as it receives $Q_C$ heat at temperature $T_C$. Putting these together, we obtain the change in entropy of the universe for a single cycle:\n\\[\\Delta S_{universe} \\geq \\frac{Q_C}{T_C} - \\frac{Q_H}{T_H} \\]\nNow, the second law of thermodynamics tells us that the entropy of the universe must increase (or, to phrase it another way, if we treat the two reservoirs and the heat engine as an isolated system, the entropy of the total system must increase. This allows us to conclude that:\n\\[\\Delta S_{universe} \\geq \\frac{Q_C}{T_C} - \\frac{Q_H}{T_H} \\geq 0 \\]\nSo we obtain the important inequality:\n\\[\\frac{Q_C}{T_C} - \\frac{Q_H}{T_H} \\geq 0 \\]\nWhich we can rearrange to obtain:\n\\begin{equation}\n    \\label{eqn:(37)}\n    \\frac{T_H}{T_C} \\geq \\frac{Q_C}{Q_H}\n\\end{equation}\nNote that to derive inequality \\ref{eqn:(37)}, I have made no assumptions whatsoever about what my heat engine actually looks like; this is a completely general statement, based on the amounts of heat gained/lost from the hot/cold reservoirs, and the maximum/minimum hot/cold reservoir temperatures. Now, let us consider out definition of efficiency:\n\\begin{equation}\n    \\label{eqn:(38)}\n    \\eta = \\frac{W}{Q_H}\n\\end{equation}\nWhere $W$ is the work done by the engine (what we get out), and $Q_H$ is the heat that we inject into the engine in one cycle from the hot reservoir (what we put in). By energy conservation, we find that:\n\\begin{equation}\n    \\label{eqn:(39)}\n    W = Q_H-Q_C\n\\end{equation}\nThis might look like it came out of nowhere, so let's think about it a bit further. Just like entropy, internal energy is also a function of state; the energy something has doesn't care about how that energy got there! With this consideration, since the heat engine returns to the original state at the end of one cycle, just like the entropy change of the heat engine is zero in a single cycle, so must be the total internal energy; in other words, the heat engine must have the same energy it began with. With this consideration, we realize that the sum of the work done on the system and the heat given to the system must be 0, leading to equation \\ref{eqn:(39)} above (work this out using the first law of thermodynamics if it's still unclear!). Now, we can substitute equation \\ref{eqn:(39)} into equation \\ref{eqn:(38)}, giving us:\n\\begin{align*}\n    \\eta = \\frac{Q_H-Q_C}{Q_H} = 1 - \\frac{Q_C}{Q_H}\n\\end{align*}\nAnd now applying inequality \\ref{eqn:(37)}, we have:\n\\begin{align*}\n    1 - \\frac{Q_C}{Q_H} \\leq 1 - \\frac{T_H}{T_C}\n\\end{align*}\nAnd therefore:\n\\begin{equation}\n    \\eta \\leq 1 - \\frac{T_H}{T_C}\n\\end{equation}\nWe have hence proven Carnot's theorem, and can see that for any arbitrary heat engine, the efficiency is bounded by the Carnot efficiency. \n", "meta": {"hexsha": "0110db76625889596bfc19a1b4c6980a4b863fba", "size": 6273, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Entropy/carnotrevisited.tex", "max_stars_repo_name": "RioWeil/SCIE001-thermo-notes", "max_stars_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Entropy/carnotrevisited.tex", "max_issues_repo_name": "RioWeil/SCIE001-thermo-notes", "max_issues_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Entropy/carnotrevisited.tex", "max_forks_repo_name": "RioWeil/SCIE001-thermo-notes", "max_forks_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-30T05:36:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-30T05:36:50.000Z", "avg_line_length": 106.3220338983, "max_line_length": 980, "alphanum_fraction": 0.7360114778, "num_tokens": 1741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4227611283687291}}
{"text": "\\newpage\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       SPECIAL RELATIVITY SECTION      %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Special Relativity}\n\\label{sec:specrel}\nThe special relativity subject matter in the qualifying exam is primarily at the level of \\cite{ohanianModernPhysics1995}, a common, upper-level undergraduate modern physics text. The main innovation in special relativity is Einstein's second postulate:\n\\quotebox{\n\\begin{enumerate}[label=\\Roman*.]\n\t\\item Only the relative motion of inertial frames can be measured; the laws of physics are the same in all inertial reference frames. The concept of \"absolute rest\" is meaningless.\n\t\\item The velocity of light is a universal constant, independent of any relative motion of the source and observer\n\\end{enumerate}}\n\n\\section{Lorentz Invariance}\n% Galilean Invariance\nNewtonian mechanics, which underlies all of classical mechanics, assumes a universal background space and time, such that the time is shared by all inertial reference frames. Thus a transformation from one Newtonian frame $K$ to another $K'$, separated by velocity $v$ in the $x_1$ dimension, called a \\textit{Galilean} transformation takes the form $x_1'=x_1-vt$, $x_2'=x_2$, $x_3'=x_3$, $t'=t$. The fact that Newtonian mechanics is invariant under these transformations is called \\textit{Galilean invariance}.\\\\\n% Lorentz Transforms\n\\indent Galilean invariance isn't compatible with the second postulate of special relativity, so the symmetries of spacetime in special relativity must be different. The \\textit{Lorentz transformation} can be derived from the second postulate. Keeping the speed of light $c$ constant, and computing the distance traveled by a pulse of light in two frames, $K$ and $K'$ separated by a boost of speed $v$ on the $x_1$-axis the resulting transformation is defined:\n\\eqn{\\begin{split}\n\tx_1' &= \\gamma\\wrap{x_1 - vt} \\\\\n\tx_2' &= x_2 \\\\\n\tx_3' &= x_3 \\\\\n\tt' &= \\gamma\\wrap{t - x_1}\n\\end{split}\\ \\Vast{\\}}\n\t\\quad\\quad\\quad\\quad\n\\gamma=\\frac{1}{\\sqrt{1-\\wrap{\\frac{v}{c}}^2}}\n}\n% Lorentz Group (boosts + rotations)\nAny physical system preserved under Lorentz transformations is said to be \\textit{Lorentz invariant}. Maxwell's equations of electrodynamics possess Lorentz invariance, and were a major source of motivation for the development of special relativity.\n\n\n\\section{Space-Time and Four-Vectors}\n% 4-vectors\nSince special relativity deals with transformations in 4-dimensional spacetime, it is helpful to introduce the concept more formally. We adopt the concept of \\textit{four-vectors}, such as $x^\\mu$ to represent a point in spacetime, where $x^0=ct$, $x^1=x$, $x^2=y$, $x^3=z$. We also define the square of the spacetime interval between two points to be an invariant:\n\\eqn{\\Delta s^2 = -\\wrap{c\\Delta t}^2 + \\wrap{\\Delta x}^2 + \\wrap{\\Delta y}^2 + \\wrap{\\Delta z}^2}\nWe can also define the invariant in terms of the \\textit{Minkowski metric} $\\eta_{\\mu\\nu}$ which defines a flat Lorentzian manifold. Further, we adopt the \\textit{Einstein summation notation} whereby the $\\sum$ symbol is omitted in favor of matching a lower and upper index. For instance, computing the invariant interval for two points $x^\\mu$ and $x'^\\mu$, where $\\Delta x^\\mu = \\wrap{x^0-x'^0, x^1-x'^1, x^2-x'^2, x^3-x'^3}$.\n\\eqn{\\eta_{\\mu\\nu}=\\begin{pmatrix}\n\t-1 & 0 & 0 & 0 \\\\\n\t0 & 1 & 0 & 0 \\\\\n\t0 & 0 & 1 & 0 \\\\\n\t0 & 0 & 0 & 1 \n\\end{pmatrix}\\quad\\quad\\quad\n\\Delta s^2=\\eta_{\\mu\\nu}\\wrap{\\Delta x}^\\mu\\wrap{\\Delta x}^\\nu}\n% Metric, Causality\nAt this point it's worth noting that Lorentz transformations $\\Lambda$ are those that leave the metric unchanged $\\Lambda \\eta \\Lambda^{T}$, which implies that $\\Lambda^T = \\Lambda^{-1}$ or that the Lorentz transformations are \\textit{orthogonal}. We define causal relationships between two points $x^\\mu$ and $x'^\\mu$ in the following way:\n\\eqn{\\begin{split}\n\t\\Delta s^2 &< 0\\quad \\text{\\textit{timelike}, possible causal dependence} \\\\\n\t\\Delta s^2 &= 0\\quad \\text{\\textit{lightlike}, boundary between causal dependence and independence} \\\\\n\t\\Delta s^2 &> 0\\quad \\text{\\textit{spacelike}, causal independence} \\\\\n\\end{split}}\nFor the case of lightlike separation, we define the \\textit{proper time} $\\Delta \\tau$ to be the negative of the interval such that $\\Delta \\tau = - \\Delta s$. For a parametric path $x^\\mu(\\lambda)$ in spacetime such that the velocity is timelike at every point, the proper time defines the time experienced by an observer moving along the path:\n\\eqn{\\tau=\\int_{\\lambda_0}^{\\lambda_1}\\sqrt{-\\eta_{\\mu\\nu}\\frac{dx^\\mu}{d\\lambda}\\frac{dx^\\nu}{d\\lambda}}d\\lambda}\n\n\n\\section{Momentum and Energy}\nIn special relativity, we extend the relativistic 3-dimensional velocity $\\vec{p}=\\gamma m \\vec{v}$ to be a four-vector, called the \\textit{four momentum} $p^\\mu$ by adding the \\textit{relativistic energy} $E=\\gamma mc^2$ as the time coordinate such that $p^\\mu=\\wrap{E/c, \\vec{p}}$. The four-momentum is conserved, as is the relativistic momentum $\\vec{p}$. The total energy $E=p^0 c$ is conserved as well. The kinetic energy can be defined:\n\\eqn{p^\\mu = \\wrap{\\gamma mc, \\gamma m v_x, \\gamma m v_y, \\gamma m v_z}}\n\\eqn{T=\\sqrt{p^2 c^2 + m^2 c^4} - mc^2 = E - mc^2 = \\wrap{\\gamma - 1}mc^2}\nNote that for $v << c$ the classical, Newtonian expressions are recovered for both momentum and kinetic energy. Using the expansion for $1/\\sqrt{1-x^2}\\approx 1 + x^2/2$, the Lorentz coefficient $\\gamma$ can be expanded to $\\gamma \\approx 1 + v^2/2c^2$, therefore $E\\approx mc^2 + mv^2/2$ and $p\\approx mv$.\n\n\\section{Relativistic Effects}\n% Length Contraction & Time dilation\nSome common effects of special relativity are the shortening and lengthening of conventional Newtonian measurements due to changes in reference frame. Consider two frames $K$ and $K'$, where $K'$ is related to $K$ by a boost along the $x$ axis. The Lorentz transformation relating $K'$ to $K$ is given:\n\\eqn{\\Lambda^{\\mu'}{}_{\\nu}=\\begin{pmatrix}\n\t\\cosh\\phi & -\\sinh\\phi & 0 & 0 \\\\\n\t-\\sinh\\phi & \\cosh\\phi & 0 & 0 \\\\\n\t0 & 0 & 1 & 0 \\\\\n\t0 & 0 & 0 & 1 \\\\\n\\end{pmatrix}=\\begin{pmatrix}\n\t\\gamma & -\\gamma\\beta & 0 & 0 \\\\\n\t-\\gamma\\beta & \\gamma & 0 & 0 \\\\\n\t0 & 0 & 1 & 0 \\\\\n\t0 & 0 & 0 & 1 \\\\\n\\end{pmatrix}\\quad\\quad\n\\beta = \\frac{v}{c} = \\tanh\\phi}\nUsing this transformation on a set of two points $A^\\mu$ and $B^\\mu$, we observe two primary phenomena in terms of the spatial separation $\\Delta x = B^1 - A^1 = B_x - A_x$ and the temporal separation between $A$ and $B$, $\\Delta t = B^0 - A^0 = B_t - A_t$. Applying the transformation matrix we observe the following:\n\\eqn{\\begin{split}\n\t\\Delta x &= \\gamma \\Delta x'\\quad\\quad \\text{Length Contraction} \\\\\n\t\\Delta t' &= \\gamma \\Delta t\\quad\\quad \\text{Time Dilation}\n\\end{split}}\n% Paradoxes? (Bard-pole + Twin Paradox)\n% Doppler & Addition of velocities\nLet us now say that an object has a velocity $u'$ in frame $K'$, it is natural to ask what the velocity $u$ is measured in frame $K$. For that, we need to use the relativistic addition of velocities formula:\n\\eqn{u = \\frac{v+u'}{1 + \\wrap{vu'/c^2}}}\nLastly, note that for an electromagnetic wave propagating at speed $c$ in frame $K$, the Lorentz transformation implies a change in frequency in frame $K'$ according to the below. Note that the sign of the numerator is the same as $\\ddt\\Delta x$, (positive/negative for diverging/converging observers).\n\\eqn{\\frac{\\lambda_r}{\\lambda_s}=\\frac{f_s}{f_r}=\\sqrt{\\frac{1+\\beta}{1-\\beta}}}\n\n%\\section{Relativistic Kinematics} \n% OMITTED - can include if relevant for qual exams\n% Lagrangian\n% Collisions\n\n\n\\section{Experimental Verification}\nWe briefly summarize some of the experimental evidence for the special theory of relativity. \n% Muon decay\nMuon decay experiments have shown that fastly-moving particles take longer to decay in the LAB frame than stationary ones, but the proper time is equal. \n% Atomic clock\nAtomic clock experiments have shown measurable differences between fast-moving clocks in airplanes or satellites and slow-moving clocks. \n", "meta": {"hexsha": "cf1407979d317639960793f1d5c2f6377fafdc62", "size": 7994, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/sec-2-special-relativity.tex", "max_stars_repo_name": "JWKennington/QualPrepNotes", "max_stars_repo_head_hexsha": "d080bc57a2bf1c243962e153f5baefd839974445", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/sec-2-special-relativity.tex", "max_issues_repo_name": "JWKennington/QualPrepNotes", "max_issues_repo_head_hexsha": "d080bc57a2bf1c243962e153f5baefd839974445", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/sec-2-special-relativity.tex", "max_forks_repo_name": "JWKennington/QualPrepNotes", "max_forks_repo_head_hexsha": "d080bc57a2bf1c243962e153f5baefd839974445", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.94, "max_line_length": 513, "alphanum_fraction": 0.7176632474, "num_tokens": 2370, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.42276111885526063}}
{"text": "\\chapter[Model Exploration by Confidence]{Model Exploration by Confidence\\\\ with\n  Completely Specified Counterexamples}\n\\label{cha:model-expl-conf}\n\nWe have seen how we can extend attribute exploration to explore implications which enjoy a\nhigh confidence in some given formal context.  In this chapter we want to extend this\ngeneralization of attribute exploration even further to be able to explore GCIs with high\nconfidence in finite interpretations.  The basis for this extension will be the\n\\emph{model exploration} algorithm from~\\cite{Diss-Felix}, an extension of attribute\nexploration to explore valid GCIs of finite interpretations.\n\nModel exploration, similarly to attribute exploration, assumes that a certain domain of\ninterest is representable by a finite interpretation $\\mathcal{I}_{\\mathsf{back}}$, which\nwe shall call the \\emph{background interpretation} of the exploration process.  However,\nwe assume that this interpretation is not directly accessible, but instead an expert is\ngiven that allows us to decide whether certain GCIs are valid in\n$\\mathcal{I}_{\\mathsf{back}}$.  In addition, if a given GCI $C \\sqsubseteq D$ is not valid\nin $\\mathcal{I}_{\\mathsf{back}}$, then the expert can provide counterexamples for $C\n\\sqsubseteq D$ in a suitable way.\n\nThe principal way how model exploration works is again very akin to attribute exploration.\nGiven a finite \\emph{connected subinterpretation} $\\mathcal{I}$ of\n$\\mathcal{I}_{\\mathsf{back}}$ and a set $\\mathcal{B}$ of valid GCIs of\n$\\mathcal{I}_{\\mathsf{back}}$, the algorithm successively generates valid GCIs $C\n\\sqsubseteq D$ of $\\mathcal{I}$, which do not follow from $\\mathcal{B}$, and presents them\nto some expert.  If the expert confirms $C \\sqsubseteq D$, then it is added to\n$\\mathcal{B}$.  If the expert rejects $C \\sqsubseteq D$, then she provides a\ncounterexample in the form of a connected subinterpretation of\n$\\mathcal{I}_{\\mathsf{back}}$, which is added to $\\mathcal{I}$.  Since $\\mathcal{I}$ and\n$\\mathcal{B}$ play the same role as the working context and the set of known implications\nduring attribute exploration, we shall refer to them as the \\emph{working interpretation}\nand the \\emph{set of known GCIs}, respectively.  If no more GCIs can be generated to be\nasked to the expert, the algorithm stops.  It can be shown that at this point, the set\n$\\mathcal{B}$ is a finite base of $\\mathcal{I}_{\\mathsf{back}}$.\n\nThe foregone description already suggests that there are some difficulties in transferring\nattribute exploration to the setting of GCIs and finite interpretations.  The most\napparent is that the set of GCIs we potentially have to cover is infinite, as the set of\nvalid GCIs of $\\mathcal{I}_{\\mathsf{back}}$ is infinite.\n\nAnother problem is that validity of GCIs in interpretations deploys a \\emph{closed-world}\nsemantics: if an element $x \\in \\Delta^{\\mathcal{I}}$ of a (finite) interpretation\n$\\mathcal{I} = (\\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{I}})$ does not have an $r$-successor\nin $\\mathcal{I}$ for some $r \\in N_{R}$, then it is assumed that $x$ does not have\n$r$-successors $\\mathcal{I}_{\\mathsf{back}}$.  Therefore, if we add an element $x$ of\n$\\mathcal{I}_{\\mathsf{back}}$ as a counterexample for a GCI to our working interpretation\n$\\mathcal{I}$, then we also have to include \\emph{all} its role successors (and their role\nsuccessors, and so on) in $\\mathcal{I}_{\\mathsf{back}}$, nevertheless they may not be\nnecessary for the counterexample; otherwise, elements in $\\mathcal{I}$ may serve as\ncounterexamples to GCIs which are valid in $\\mathcal{I}_{\\mathsf{back}}$, because missing\ninformation is considered as false information.  The approach followed by Baader and\nDistel to account for this problem is to let the expert provide \\emph{connected\n  subinterpretations} of $\\mathcal{I}_{\\mathsf{back}}$ as counterexamples for GCIs.\n\nWe shall discuss the details of model exploration in \\Cref{sec:model-expl-with}.  Based on\nthis discussion, we shall develop a model exploration algorithm that also includes GCIs\nwith high confidence among those proposed to the expert.  This algorithm, which we shall\ncall \\emph{model exploration by confidence}, will be introduced in\n\\Cref{sec:model-expl-with-1}, and its construction will mimic the argumentation used by\nBaader and Distel for their model exploration algorithm.\n\nThe results presented in this section have been published previously in\n\\cite{Borc-LTCS-13-11}.\n\n\\section{Model Exploration with Valid GCIs}\n\\label{sec:model-expl-with}\n\nIn this section we shall review the argumentation used to develop model exploration, as\ngiven in~\\cite[Chapter~6]{Diss-Felix}.  In the next section, we shall use this\nargumentation presented here and generalize it to the setting of GCIs with high confidence\nin finite interpretations.\n\nModel exploration is based on the result that bases of finite interpretations\n$\\mathcal{I}$ can be obtained from bases of their corresponding induced formal context\n$\\con K_{\\mathcal{I}}$ (\\Cref{thm:Felix-base-B3}).  Since attribute exploration arises\nfrom the computation of the canonical base by adding suitable expert interaction (see\n\\Cref{sec:attr-expl}), one could think of obtaining an algorithm for model exploration by\nadding suitable expert interaction during the computation of bases of $\\con\nK_{\\mathcal{I}}$.  It shall turn out that this is indeed correct.\n\nHowever, there is a technical problem which does not arise in attribute exploration: when\nwe add counterexamples to our current working interpretation $\\mathcal{I}$ during model\nexploration, then the attribute set $M_{\\mathcal{I}}$ of the corresponding induced context\n$\\con K_{\\mathcal{I}}$ may change, since it depends on the elements of $\\mathcal{I}$.\nRecall that $M_{\\mathcal{I}}$ was defined as\n\\begin{equation*}\n  M_{\\mathcal{I}} = N_{C} \\cup \\set{ \\bot } \\cup \\set{ \\exists r. X^{\\mathcal{I}} \\mid r\n    \\in N_{R}, X \\subseteq \\Delta^{\\mathcal{I}}, X \\neq \\emptyset }.\n\\end{equation*}\n\nThus, to allow to use attribute exploration as a basis for model exploration, we need to\nfix the attribute set, and the best way for this would be to use\n$M_{\\mathcal{I}_{\\mathsf{back}}}$.  However, since we cannot access the background\ninterpretation $\\mathcal{I}_{\\mathsf{back}}$ directly, we cannot compute this set\ncompletely.  On the other hand, it can be shown that we can compute the set\n$M_{\\mathcal{I}_{\\mathsf{back}}}$ \\emph{incrementally}, using the fact that the expert\nconfirms certain types of GCIs, and then use the parts of\n$M_{\\mathcal{I}_{\\mathsf{back}}}$ we already know for the exploration process.\n\nTo explain how this can be done, we shall first discuss in \\Cref{sec:grow-sets-attr} how\nwe can compute bases of formal contexts where the set of attributes is allowed to grow\nduring the computation.  Thereafter, we shall see in \\Cref{sec:comp-bases-given} how we\ncan transfer this algorithm to the setting of computing finite bases of finite\ninterpretations $\\mathcal{I}$, thus allowing the set $M_{\\mathcal{I}}$ to be computed\nsuccessively during the computation.  Finally, we shall see in \\Cref{sec:an-algor-expl}\nhow we can add expert interaction to avoid direct access to the underlying interpretation,\nthus obtaining the model exploration algorithm.\n\n\\subsection{Growing Sets of Attributes}\n\\label{sec:grow-sets-attr}\n\nWe want to find an algorithm that allows us to compute bases of formal contexts where the\nattribute set is allowed to grow during the computation.  We can think of this situation\nas follows: we want to compute a base of a formal context, which we cannot access\ncompletely, in the sense that some of the attributes in this formal context are\n\\enquote{hidden}.  However, during the computation of the base, hidden attributes are\nuncovered incrementally.  The goal is then to find an algorithm which allows us to compute\nbases in such a setting.\n\nObtaining such an algorithm is actually not that difficult.  For this let us consider how\n\\Cref{alg:canonical-base} computes the canonical base.  There, we use the Next-Closure\nalgorithm to enumerate the premises of the canonical base of a given formal context $\\con\nK = (G, M, I)$, using some linear order $\\leq_{M}$ on $M$.  If $M = \\set{ m_{1}, \\dots,\n  m_{n} }$ and\n\\begin{equation*}\n  m_{n} \\leq_{M} m_{n-1} \\leq_{M} \\dots \\leq_{M} m_{1},\n\\end{equation*}\nthen the Next Closure algorithm firstly enumerates all premises which are subsets of\n$\\emptyset$, then those which are subsets of $\\set{ m_{1} }$, then those of $\\set{ m_{1},\n  m_{2} }$, and so on.  In particular, it will not consider an element $m_{k} \\in M$\nbefore it has enumerated all premises which are subsets of $\\set{ m_{1}, \\dots, m_{k-1}\n}$.\n\nWe can exploit this idea for our purpose of computing bases with growing sets of\nattributes: if the attribute set in iteration $i$ is $M_{i}$, ordered by $\\leq_{M_{i}}$,\nand we are about to add some new attributes $m_{1}, \\dots, m_{n}$ to $M_{i}$ to obtain\n\\begin{equation*}\n  M_{i+1} := M_{i} \\cup \\set{ m_{1}, \\dots, m_{n} },\n\\end{equation*}\nthen we define the linear order $\\leq_{M_{i+1}}$ on $M_{i+1}$ by ordering the elements in\n$M_{i} \\subseteq M_{i+1}$ as before, \\ie\n\\begin{equation}\n  \\label{eq:48}\n  {\\leq_{M_{i}}} = {\\leq_{M_{i+1}}} \\cap M_{i} \\times M_{i},\n\\end{equation}\nand requiring in addition that\n\\begin{equation}\n  \\label{eq:49}\n  m_{j} \\leq_{M_{i+1}} x\n\\end{equation}\nis true for all $j \\in \\set{ 1, \\dots, n }$ and $x \\in M_{i}$.  In other words, we just\nput the new elements \\emph{before} the old elements.  In that way, the Next-Closure\nbehaves as if the elements would have been there from the start, and computes the base as\ndesired.\n\n\\addfunctionname{base/growing-set-of-attributes}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm}[Algorithm 8 from~\\cite{Diss-Felix}]~ Computing a Base of a Formal\n    Context with Growing Sets of Attributes and Background Knowledge%\n    \\label{alg:base/growing-set-of-attributes}\n\\begin{lstlisting}\ndefine base/growing-set-of-attributes($\\con K = (G, M, I)$, $\\leq_{M}$, $\\mathcal{S} \\subseteq \\Th(\\con K)$)\n  $i$ := 0\n  $P_i$ := $\\emptyset$\n  $\\mathcal{K}_i$ := $\\emptyset$\n  $\\con K_i$ := $\\con K$\n  $M_i$ := $M$\n  $\\mathcal{S}_i$ := $\\mathcal{S}$\n  $\\leq_{M_i}$ := $\\leq_{M}$\n\n  forever do\n    read $\\con K_{i+1} = (G, M_{i+1}, I_{i+1}) \\text{ such that } M_i \\subseteq M_{i+1}\n\\text{ and } I_i = I_{i+1} \\cap M_i \\times M_i$\n    read $\\mathcal{S}_{i+1} \\text{ such that } \\mathcal{S}_i \\subseteq \\mathcal{S}_{i+1} \\subseteq \\Th(\\con K_{i+1})$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold.}$\n\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_r \\to (P_r)_{\\con K_{i+1}}'' \\mid P_r \\neq\n      (P_r)_{\\con K_{i+1}}'', r \\in \\set{ 0, \\ldots, i } }$\n\n    $P_{i+1}$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_{i}$, $\\mathcal{K}_{i+1} \\cup \\mathcal{S}_{i+1})$\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$  \n  end\n\n  return $\\mathcal{K}_i$  \nend    \n\\end{lstlisting}  \n  \\end{Algorithm}\n\\end{figure}\n\nAn implementation of this idea is shown in \\Cref{alg:base/growing-set-of-attributes}.\nThere we start with some initial formal context $\\con K_{0} = \\con K = (G, M, I)$ and some\nbackground knowledge $\\mathcal{S}_{0} = \\mathcal{S} \\subseteq \\Th(\\con K)$.  Then, in\nevery iteration we allow to extend the current context $\\con K_{i} = (G, M_{i}, I_{i})$ by\nproviding a new set $M_{i+1} \\supseteq M_{i}$ of attributes and a new incidence relation\n$I_{i+1} \\subseteq M_{i+1} \\times M_{i+1}$ which satisfies\n\\begin{equation*}\n  I_{i} = I_{i+1} \\cap M_{i} \\times M_{i}.\n\\end{equation*}\nThis corresponds to our perception that at the beginning of the run of the algorithm, some\nof the attributes are hidden, and are uncovered during the run.\n\nFor this algorithm to make sense, we of course require that at a certain point everything\nfrom the formal context has been uncovered, \\ie that for some $\\ell \\in \\NN_{\\geq 0}$ it\nis true that $M_{\\ell} = M_{i}$ for all $i \\geq \\ell$.  From this point on,\n\\Cref{alg:base/growing-set-of-attributes} behaves like \\Cref{alg:canonical-base} for\ncomputing the canonical base of a given formal context.\n\n\\begin{Theorem}[Theorems~6.2 and~6.3 from~\\cite{Diss-Felix}]\n  \\label{thm:base-with-growing-set-of-attributes}\n  Let $\\con K = (G, M, I)$ be a finite formal context, $\\leq_{M}$ a linear order on $M$,\n  and $\\mathcal{S} \\subseteq \\Th(\\con K)$.  Then in a run of\n  \\Cref{alg:base/growing-set-of-attributes}, let $\\ell \\in \\NN_{\\ge 0}$ be such that\n  $M_{\\ell} = M_{i}$ for all $i \\geq \\ell$.  Then this run terminates.  If $n$ is the last\n  iteration of this run, then $\\mathcal{K}_{n}$ is a base of $\\con K_{n}$ with background\n  knowledge $\\mathcal{S}_{n}$.\n\\end{Theorem}\n\nA difference to the classical computation of the canonical base as shown in\n\\Cref{alg:canonical-base} is that in the latter we only consider sets $P$ as premises for\nimplications which are closed under the currently known implications, but are not intents\nof the given formal context.  In contrast to this,\n\\Cref{alg:base/growing-set-of-attributes} considers all sets $P_{i}$ which are closed\nunder the currently known implications, no matter whether they are intents of $\\con\nK_{i}$.  The reason for this is that even if $P_{i}$ is an intent of $\\con K_{i}$, it\ncould very well be that $P_{i}$ is not an intent of $\\con K_{n}$ (where $n$ is the number\nof iterations of the algorithm) because of attributes which have been introduced in $\\con\nK_{n}$, but were not present in $\\con K_{i}$.  Since we cannot know whether $P_{i}$ will\nbe an intent of $\\con K_{n}$ or not, when we compute it, we have to consider it as well.\nOtherwise, we cannot guarantee that $\\mathcal{K}_{n}$ will be a base of $\\con K_{n}$.\n\nUnfortunately, the fact that we have to keep all those sets $P_{i}$ may lead to\n$\\mathcal{K}_{n}$ not being irredundant anymore.  This has been illustrated\nin~\\cite{Diss-Felix} by the following example.\n\n\\begin{Example}[Example~6.1 from~\\cite{Diss-Felix}]\n  \\label{exp:non-redundant-bases}\n  %\n  \\begin{figure}[tp]\n    \\centering\n    \\begin{equation*}\n      \\con K_0 = \\con K_1 =\n      \\begin{array}{c | c}\n        ~ & \\mathsf{A} \\\\\n        \\midrule\n        1 & \\times \\\\\n        2 & \n      \\end{array}\n      \\qquad\n      \\con K_2 = \\con K_3 =\n      \\begin{array}{c|cc}\n        ~ & \\mathsf{A} & \\mathsf{B} \\\\\n        \\midrule\n        1 & \\times & \\\\\n        2 &        & \\times\n      \\end{array}\n      \\qquad\n      \\con K_3 = \\con K_4 = \\con K_5 =\n      \\begin{array}{c|ccc}\n        ~ & \\mathsf{A} & \\mathsf{B} & \\mathsf{C}\\\\\n        \\midrule\n        1 & \\times & & \\times \\\\\n        2 & & \\times &\n      \\end{array}\n    \\end{equation*}\n    \\caption{Formal Contexts for \\Cref{exp:non-redundant-bases}}\n    \\label{fig:example-context-1}\n  \\end{figure}\n  %\n  We consider the following run of \\Cref{alg:base/growing-set-of-attributes} with input\n  $\\con K = \\con K_0$ as shown in \\Cref{fig:example-context-1}, and $\\mathcal{S} =\n  \\mathcal{S}_0 = \\emptyset = \\mathcal{S}_1 = \\ldots = \\mathcal{S}_6$:\n  \\begin{equation*}\n    \\begin{array}{c|ccc}\n      k & M_{k+1} \\setminus M_k & \\mathcal{L}_k & P_k \\\\\n      \\midrule\n      0 & \\emptyset      & \\emptyset & \\emptyset         \\\\\n      1 & \\emptyset      & \\emptyset & \\set{\\mathsf{A}}    \\\\\n      2 & \\set{\\mathsf{B}} & \\emptyset & \\set{\\mathsf{B}}    \\\\\n      3 & \\emptyset      & \\emptyset & \\set{\\mathsf{A}, \\mathsf{B}} \\\\\n      4 & \\set{\\mathsf{C}} & \\set{\\set{\\mathsf{A}} \\to \\set{\\mathsf{A},\\mathsf{C}},\n        \\set{\\mathsf{A},\\mathsf{B}} \\to \\set{\\mathsf{A}, \\mathsf{B}, \\mathsf{C}}} & \\set{\\mathsf{C}}\\\\\n      5 & \\emptyset      & \\set{\\set{\\mathsf{A}} \\to \\set{\\mathsf{A},\\mathsf{C}},\n        \\set{\\mathsf{A},\\mathsf{B}} \\to \\set{\\mathsf{A}, \\mathsf{B}, \\mathsf{C}}, \\set{\\mathsf{C}} \\to\n        \\set{\\mathsf{A},\\mathsf{C}}} & \\set{\\mathsf{A}, \\mathsf{B}, \\mathsf{C}}\\\\\n      6 & \\emptyset & \\set{\\set{\\mathsf{A}} \\to \\set{\\mathsf{A},\\mathsf{C}},\n        \\set{\\mathsf{A},\\mathsf{B}} \\to \\set{\\mathsf{A}, \\mathsf{B}, \\mathsf{C}}, \\set{\\mathsf{C}} \\to\n        \\set{\\mathsf{A},\\mathsf{C}}} & \\text{\\textbf{nil}}\n    \\end{array}\n  \\end{equation*}\n  In iterations 2 and 4, the new attributes B and C are added, as shown in\n  Figure~\\ref{fig:example-context-1}.  The algorithm terminates in iteration 6 with output\n  $\\mathcal{L}_6$, which is clearly non-redundant: the implication $\\set{\\mathsf{A},\n    \\mathsf{B}} \\to \\set{\\mathsf{A}, \\mathsf{B}, \\mathsf{C}}$ is entailed by\n  $\\set{\\mathsf{A}} \\to \\set{\\mathsf{A}, \\mathsf{C}}$.\n\\end{Example}\n\n\\subsection{Computing Bases of Given Finite Interpretations}\n\\label{sec:comp-bases-given}\n\nWe now want to use \\Cref{alg:base/growing-set-of-attributes} to devise an algorithm that\nallows us to compute bases of finite interpretations $\\mathcal{I}$ without computing\n$M_{\\mathcal{I}}$ first.  Instead, we want that the elements of the set $M_{\\mathcal{I}}$\nare computed successively during the run of the algorithm.  In this way, we can\nimmediately start with computing valid GCIs of $\\mathcal{I}$, and do not have to wait for\n$M_{\\mathcal{I}}$ to be computed completely.\n\nThe successive computation of the elements of $M_{\\mathcal{I}}$ is achieved in\n\\Cref{alg:base/growing-set-of-attributes} by defining the sets $M_{i}$ as follows.  For $i\n= 0$, we define\n\\begin{equation*}\n  M_{0} = N_{C} \\cup \\set{ \\bot }.\n\\end{equation*}\nThen, during the run of the algorithm, we add elements of the form $\\exists\nr. X^{\\mathcal{I}}$ for $r \\in N_{R}$ and $X \\subseteq \\Delta^{\\mathcal{I}}, X \\neq\n\\emptyset$.  More precisely, whenever we compute a set $P_{i}$ in\n\\Cref{alg:base/growing-set-of-attributes}, we define\n\\begin{equation*}\n  M_{i+1} := M_{i} \\cup \\set{ \\exists r. (\\bigsqcap P_{i})^{\\mathcal{I}\\mathcal{I}} \\mid r\n    \\in N_{R} },\n\\end{equation*}\nwhere the union is only up to equivalence, \\ie if for some $C:= \\exists r. (\\bigsqcap\nP_{i})^{\\mathcal{I}\\mathcal{I}}$ there already exists a $D \\in M_{i}$ such that $C \\equiv\nD$, then we do not add $C$ in the definition of $M_{i+1}$.\n\nWe also need to specify how we define the formal contexts $\\con K_{i}$ and the sets\n$\\mathcal{S}_{i}$ of background knowledge.  We set $\\con K_{i}$ to be the induced formal\ncontext of $M_{i}$ and $\\mathcal{I}$, and we define\n\\begin{equation*}\n  \\mathcal{S}_{i+1} = \\set{ \\set{A} \\to \\set{B} \\mid A, B \\in M_{i}, A \\sqsubseteq B }.\n\\end{equation*}\nThe resulting algorithm is shown in \\Cref{alg:base-of-interpretation}.\n\n\\addfunctionname{base-of-interpretation,induced-context}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm}[Algorithm 9 from~\\cite{Diss-Felix}]~ Computing a Base of a Given\n    Interpretation with Incremental Computation of $M_{\\mathcal{I}}$%\n    \\label{alg:base-of-interpretation}\n    \\begin{lstlisting}\ndefine base-of-interpretation($\\mathcal{I} = (\\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{I}})\n\\text{ over } N_{C} \\text{ and } N_{R}$)\n  $i$ := 0\n  $P_i$ := $\\emptyset$\n  $M_i$ := $N_C \\cup \\set{\\bot}$\n  $\\mathcal{K}_i$ := $\\emptyset$\n  $\\mathcal{S}_i$ := $\\set{\\set{\\bot} \\to \\set{A} \\mid A \\in N_C}$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n\n  forever do\n    $M_{i+1}$ := $M_i \\cup \\set{ \\exists r.(\\bigsqcap P_i)^{\\mathcal{I}\\mathcal{I}} \\mid r \\in N_R}\\label{lst:base-of-interpretation-1}$\n    $\\con K_{i+1}$ := induced-context($\\mathcal{I}$, $M_{i+1}$)$\\label{lst:base-of-interpretation-2}$\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_r \\to (P_r)_{\\con K_{i+1}}'' \\mid P_r \\neq\n      (P_r)_{\\con K_{i+1}}'', r \\in \\set{ 0, \\ldots, i} }$\n    $\\mathcal{S}_{i+1}$ := $\\set{ \\set{A} \\to \\set{B} \\mid A, B \\in M_{i+1}, A \\sqsubseteq\n      B }$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold.}$\n\n    $P_{i+1}$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\mathcal{K}_{i+1} \\cup \\mathcal{S}_{i+1}$)\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$  \n  end\n\n  return $\\set{ \\bigsqcap P \\sqsubseteq (\\bigsqcap P)^{\\mathcal{I}\\mathcal{I}} \\mid (P \\to\n    P_{\\con K_{i+1}}'') \\in \\mathcal{K}_{i+1} }$\nend    \n    \\end{lstlisting}  \n  \\end{Algorithm}\n\\end{figure}\n\nNote that \\Cref{alg:base-of-interpretation} has the form of\n\\Cref{alg:base/growing-set-of-attributes}, and thus we can argue that a run of\n\\Cref{alg:base-of-interpretation} terminates with finite sets $N_{C}, N_{R}$ and a finite\ninterpretation $\\mathcal{I}$ as input.  In this case, all concept descriptions which are\nadded to the set of attributes during the run of the algorithm are, up to equivalence,\nelements of $M_{\\mathcal{I}}$, which is finite.  Thus, there exists a number $\\ell \\in\n\\NN_{\\ge 0}$ such that for all $i \\geq \\ell$ it is true that $M_{i} = M_{\\ell}$.  Then, by\n\\Cref{thm:base-with-growing-set-of-attributes}, \\Cref{alg:base-of-interpretation} has to\nterminate.\n\nTo see that the definition of $M_{i}$ will eventually yield all elements of\n$M_{\\mathcal{I}}$, up to equivalence, we first observe that $M_{i} \\subseteq\nM_{\\mathcal{I}}$ is true up to equivalence for all iterations $i$ of\n\\Cref{alg:base-of-interpretation}.  On the other hand, if $\\exists r. X^{\\mathcal{I}} \\in\nM_{\\mathcal{I}}$, then $X^{\\mathcal{I}} \\equiv X^{\\mathcal{I}\\mathcal{I}\\mathcal{I}} =\n(X^{\\mathcal{I}})^{\\mathcal{I}\\mathcal{I}}$, and $X^{\\mathcal{I}}$ is expressible in terms\nof $M_{\\mathcal{I}}$ by \\Cref{lem:mmsc-are-expressible-in-terms-of-M_I}.  Therefore, there\nexists $U \\subseteq M_{\\mathcal{I}}$ such that\n\\begin{equation*}\n  X^{\\mathcal{I}} \\equiv \\bigsqcap U.\n\\end{equation*}\nIf $n$ is the number of iterations of the algorithm, and if $\\con K_{n}$ denotes the\ninduced context of $M_{n}$ and $\\mathcal{I}$, then we find\n\\begin{equation*}\n  (\\bigsqcap U_{\\con K_{n}}'')^{\\mathcal{I}} = U_{\\con K_{n}}''' = U_{\\con K_{n}}' =\n  (\\bigsqcap U)^{\\mathcal{I}}\n\\end{equation*}\nusing \\Cref{prop:connection-I-prime-2}.  Then\n\\begin{equation*}\n  \\exists r. X^{\\mathcal{I}} \\equiv \\exists r. (X^{\\mathcal{I}})^{\\mathcal{I}\\mathcal{I}}\n  \\equiv \\exists r.(\\bigsqcap U_{\\con K_{n}}'')^{\\mathcal{I}\\mathcal{I}}.\n\\end{equation*}\nThus, it suffices to consider only intents of the final context $\\con K_{n}$.  The\nfollowing result shows that these intents are among the sets $P_{i}$.\n\n\\begin{Lemma}[Partly Lemma~6.3 from~\\cite{Diss-Felix}]\n  \\label{lem:Felix-6.3}\n  Consider a terminating run of \\Cref{alg:base-of-interpretation} with $n$ iterations, and\n  let $Q \\subseteq M_{n}$.  Then if $Q = Q_{\\con K_{n}}''$, then $Q = P_{i}$ for some $i\n  \\in \\set{ 0, \\dots, n }$.\n\\end{Lemma}\n\nUsing this lemma we can show that $M_{n}$ is, up to equivalence, equal to\n$M_{\\mathcal{I}}$.  It can then be shown that a base of the induced context of\n$\\mathcal{I}$ and $M_{n}$ yields a base of $\\mathcal{I}$ as\nwell~\\cite[Corollary~5.14]{Diss-Felix}.  From this, we immediately obtain the correctness\nof \\Cref{alg:base-of-interpretation}.\n\n\\begin{Theorem}[Theorem~6.9 from~\\cite{Diss-Felix}]\n  \\label{thm:Felix-6.9}\n  Let $\\mathcal{I}$ be a finite interpretation over $N_{C}$ and $N_{R}$.  Then the set\n  \\begin{equation*}\n    \\mathcal{K} = \\text{\\lstinline{base-of-interpretation}}(\\mathcal{I})\n  \\end{equation*}\n  is a finite base of $\\mathcal{I}$.\n\\end{Theorem}\n\n\\subsection{An Algorithm for Exploring Interpretations}\n\\label{sec:an-algor-expl}\n\nBased on \\Cref{alg:base-of-interpretation}, we now want to discuss an algorithm for model\nexploration.  For this, recall that during model exploration we suppose that our domain of\ninterest can be represented by a finite interpretation $\\mathcal{I}_{\\mathsf{back}}$, the\nbackground interpretation of the exploration.  If we could access\n$\\mathcal{I}_{\\mathsf{back}}$ directly, then to explore $\\mathcal{I}_{\\mathsf{back}}$\nwould just mean to compute a base of it, which we could achieve by using\n\\Cref{alg:base-of-interpretation}.  However, as already discussed, we assume that\n$\\mathcal{I}_{\\mathsf{back}}$ cannot be accessed directly, but instead is represented by\nan expert.\n\nTo turn \\Cref{alg:base-of-interpretation} into an algorithm that allows us to compute a\nbase of $\\mathcal{I}_{\\mathsf{back}}$ using only the expert as a means to access this\ninterpretation, we want to replace every direct access to $\\mathcal{I}_{\\mathsf{back}}$ in\n\\Cref{alg:base-of-interpretation} by a suitable expert interaction.  For this we observe\nthat there are two places in \\Cref{alg:base-of-interpretation} that directly access the\ngiven interpretation:\n\\begin{enumerate}[i. ]\n\\item when computing concept descriptions of the form $\\exists r.(\\bigsqcap\n  P_{i})^{\\mathcal{I}_{\\mathsf{back}}}$ (line~\\ref{lst:base-of-interpretation-1} of\n  \\Cref{alg:base-of-interpretation}),\n\\item when computing $\\con K_{i}$ as induced context of $M_{i}$ and\n  $\\mathcal{I}_{\\mathsf{back}}$ (line~\\ref{lst:base-of-interpretation-2} of\n  \\Cref{alg:base-of-interpretation}).\n\\end{enumerate}\nThe computation of $\\con K_{i}$ we can fix easily if instead of computing the induced\ncontext of $M_{i}$ and $\\mathcal{I}_{\\mathsf{back}}$, we just compute the induced context\n$M_{i}$ and the current working interpretation of the exploration process.  For computing\n$\\exists r. (\\bigsqcap P_{i})^{\\mathcal{I}_{\\mathsf{back}}}$, however, we need to use the\nexpert.\n\nFor this, we need to consider another issue first, which we have already talked about in\nthe introduction, namely the way the experts specifies counterexamples during the\nexploration.  We had argued that if the expert gives an element $x \\in\n\\Delta^{\\mathcal{I}_{\\mathsf{back}}}$ from the background interpretation as a\ncounterexample, then she also has to include all corresponding concept names and role\nsuccessors $x$ has in $\\mathcal{I}_{\\mathsf{back}}$.  Otherwise, there is the risk that\nthe provided counterexamples invalidate GCIs which are actually valid in the background\ninterpretation $\\mathcal{I}_{\\mathsf{back}}$.\n\nTo make this more formal, Distel introduced the notion of a \\emph{connected\n  subinterpretation}.\n\n\\begin{Definition}[Connected Subinterpretations; Definition~6.1 from~\\cite{Diss-Felix}]\n  \\label{def:connected-subinterpretations}\n  Let $\\mathcal{I} = (\\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{I}})$ be a finite\n  interpretation over $N_{C}$ and $N_{R}$.  Define%\n  \\def\\succop{\\operatorname{succ}}%\n  \\def\\nameop{\\operatorname{names}}%\n  \\begin{align*}\n    \\nameop_{\\mathcal{I}}(x) &:= \\set{ C \\in N_{C} \\mid x \\in C^{\\mathcal{I}} },\\\\\n    \\succop_{\\mathcal{I}}(x, r) &:= \\set{ y \\in \\Delta^{\\mathcal{I}} \\mid (x, y) \\in\n      r^{\\mathcal{I}} },\n  \\end{align*}\n  for $x \\in \\Delta^{\\mathcal{I}}$ and $r \\in N_{R}$.  An interpretation $\\mathcal{J} =\n  (\\Delta^{\\mathcal{J}}, \\cdot^{\\mathcal{J}})$ over $N_{C}$ and $N_{R}$ is called a\n  \\emph{subinterpretation} of $\\mathcal{I}$ if and only if\n  \\begin{enumerate}[i. ]\n  \\item $\\Delta^{\\mathcal{J}} \\subseteq \\Delta^{\\mathcal{I}}$,\n  \\item $\\nameop_{\\mathcal{I}}(x) = \\nameop_{\\mathcal{J}}(x)$ for all $x \\in\n    \\Delta^{\\mathcal{J}}$, and\n  \\item $\\succop_{\\mathcal{J}}(x,r) \\subseteq \\succop_{\\mathcal{I}}(x,r)$ for all $x \\in\n    \\Delta^{\\mathcal{J}}, r \\in N_{R}$.\n  \\end{enumerate}\n  $\\mathcal{J}$ is called a \\emph{connected subinterpretation} of $\\mathcal{I}$ if\n  $\\mathcal{J}$ is a subinterpretation of $\\mathcal{I}$, and in addition it is true that\n  \\begin{equation*}\n    \\succop_{\\mathcal{J}}(x, r) = \\succop_{\\mathcal{I}}(x, r)\n  \\end{equation*}\n  is true for all $x \\in \\Delta^{\\mathcal{J}}, r \\in N_{R}$.  In this case we shall say\n  that $\\mathcal{I}$ \\emph{extends} $\\mathcal{J}$.\n\\end{Definition}\n\nIf we now ensure that during the exploration process the current working interpretation is\na connected subinterpretation of the background interpretation\n$\\mathcal{I}_{\\mathsf{back}}$, then we can guarantee that counterexamples provided by the\nexpert do not accidentally invalidate valid GCIs.  This can be achieved by adding\ncounterexamples only as connected subinterpretations of $\\mathcal{I}_{\\mathsf{back}}$ to\nour current working interpretation.\n\n\\begin{Lemma}[Lemma~6.12 from~\\cite{Diss-Felix}]\n  \\label{lem:Felix-6.12}\n  Let $\\mathcal{J} = (\\Delta^{\\mathcal{J}}, \\cdot^{\\mathcal{J}})$ be an interpretation\n  over $N_{C}$ and $N_{R}$ which is a connected subinterpretation of the interpretation\n  $\\mathcal{I}$.  Then for all $\\ELgfpbot$ concept descriptions $C$ over $N_{C}$ and\n  $N_{R}$ it is true that\n  \\begin{equation*}\n    C^{\\mathcal{J}} = C^{\\mathcal{I}} \\cap \\Delta^{\\mathcal{J}}.\n  \\end{equation*}\n\\end{Lemma}\n\n\\begin{Theorem}[Corollary~6.13 from~\\cite{Diss-Felix}]\n  \\label{thm:GCIs-valid-in-interpretations-are-also-valid-in-connected-subinterpretations}\n  Let $\\mathcal{I} = (\\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{I}})$ be a finite\n  interpretation over $N_{C}$ and $N_{R}$, and let $\\mathcal{J} = (\\Delta^{\\mathcal{J}},\n  \\cdot^{\\mathcal{J}})$ be a connected subinterpretation of $\\mathcal{I}$.  Let $C, D$ be\n  two $\\ELgfpbot$ concept descriptions over $N_{C}$ and $N_{R}$.  Then if $C \\sqsubseteq\n  D$ is valid in $\\mathcal{I}$, then $C \\sqsubseteq D$ is also valid in $\\mathcal{J}$.\n\\end{Theorem}\n\\begin{Proof}\n  Since $C \\sqsubseteq D$ holds in $\\mathcal{I}$, it is true that $C^{\\mathcal{I}}\n  \\subseteq D^{\\mathcal{I}}$.  Using \\Cref{lem:Felix-6.12} we thus obtain\n  \\begin{equation*}\n    C^{\\mathcal{J}} = C^{\\mathcal{I}} \\cap \\Delta^{\\mathcal{J}} \\subseteq D^{\\mathcal{I}}\n    \\cap \\Delta^{\\mathcal{J}} = D^{\\mathcal{J}},\n  \\end{equation*}\n  \\ie $C \\sqsubseteq D$ holds in $\\mathcal{J}$, as it was claimed.\n\\end{Proof}\n\nNow that we know how the expert should provide counterexamples to proposed GCIs, let us\nreconsider the question of how to compute concept descriptions of the form $\\exists\nr. (\\bigsqcap P_{i})^{\\mathcal{I}_{\\mathsf{back}}\\mathcal{I}_{\\mathsf{back}}}$.  Recall\nthat since we cannot access $\\mathcal{I}_{\\mathsf{back}}$, we cannot compute this concept\ndescription directly.  What we can compute is the concept description $\\exists\nr. (\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}}$, where $\\mathcal{I}_{\\ell}$\nis the currently known interpretation.  The good thing is that the expert can ensure that\n$\\exists r. (\\bigsqcap P_{i})^{\\mathcal{I}_{\\mathsf{back}}\\mathcal{I}_{\\mathsf{back}}}$\nand $\\exists r. (\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}}$ are equivalent.\n\n\\begin{Lemma}[Lemma~6.14 from~\\cite{Diss-Felix}]\n  \\label{lem:Felix-6.14}\n  Let $\\mathcal{I}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let\n  $\\mathcal{J}$ be a connected subinterpretation of $\\mathcal{I}$.  Then for all\n  $\\ELgfpbot$ concept descriptions $C$ over $N_{C}$ and $N_{R}$, it is true that if $C\n  \\sqsubseteq C^{\\mathcal{J}\\mathcal{J}}$ is valid in $\\mathcal{I}$, then\n  $C^{\\mathcal{I}\\mathcal{I}} \\equiv C^{\\mathcal{J}\\mathcal{J}}$.\n\\end{Lemma}\n\nIf we choose $\\mathcal{I} = \\mathcal{I}_{\\mathsf{back}}$, $\\mathcal{J} =\n\\mathcal{I}_{\\ell}$ and $C = \\bigsqcap P_{i}$ in the previous lemma we see that if the\nexpert confirms the GCI\n\\begin{equation*}\n  \\bigsqcap P_{i} \\sqsubseteq (\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}},\n\\end{equation*}\nthen $(\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}} \\equiv (\\bigsqcap\nP_{i})^{\\mathcal{I}_{\\mathsf{back}}\\mathcal{I}_{\\mathsf{back}}}$, just as we need it.\n\nOn the other hand, if the expert rejects $\\bigsqcap P_{i} \\sqsubseteq (\\bigsqcap\nP_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}}$, then she adds counterexamples to the\ncurrent working interpretation $\\mathcal{I}_{\\ell}$ to yield a new working interpretation\n$\\mathcal{I}_{\\ell+1}$.  If $\\bigsqcap P_{i} \\not\\sqsubseteq (\\bigsqcap\nP_{i})^{\\mathcal{I}_{\\ell+1}\\mathcal{I}_{\\ell+1}}$, then the GCI\n\\begin{equation*}\n  \\bigsqcap P_{i} \\sqsubseteq (\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell+1}\\mathcal{I}_{\\ell+1}}\n\\end{equation*}\nis again proposed to the expert.  If $\\bigsqcap P_{i} \\sqsubseteq (\\bigsqcap\nP_{i})^{\\mathcal{I}_{\\ell+1}\\mathcal{I}_{\\ell+1}}$, \\ie $\\bigsqcap P_{i} \\equiv (\\bigsqcap\nP_{i})^{\\mathcal{I}_{\\ell+1}\\mathcal{I}_{\\ell+1}}$, then the next set $P_{i+1}$ is\nconsidered.\n\n\\addfunctionname{model-exploration}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm}[Algorithm 11 from~\\cite{Diss-Felix}]~ A Model Exploration Algorithm%\n    \\label{alg:model-exploration}\n    \\begin{lstlisting}\ndefine model-exploration($\\mathcal{I} = (\\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{I}}) \\text{ over } N_{C} \\text{ and } N_{R}$)\n  $i$ := 0\n  $P_i$ := $\\emptyset$\n  $M_i$ := $N_C \\cup \\set{\\bot}$\n  $\\mathcal{K}_i$ := $\\emptyset$\n  $\\mathcal{S}_i$ := $\\set{\\set{\\bot} \\to \\set{A} \\mid A \\in N_C}$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n  $\\ell$ := 0\n  $\\mathcal{I}_{\\ell}$ := $\\mathcal{I}$\n  \n  forever do\n    ;; expert interaction\n    while $\\text{expert refutes } \\bigsqcap P_i \\sqsubseteq (\\bigsqcap P_i)^{\\mathcal{I}_\\ell\\mathcal{I}_\\ell}$ do\n      $\\mathcal{I}_{\\ell+1}$ := $\\text{new interpretation such that }$\n        - $\\mathcal{I}_{\\ell+1} \\text{ extends } \\mathcal{I}_\\ell$\n        - $\\mathcal{I}_{\\ell+1} \\text{ contains counterexamples for } \\bigsqcap P_i \\sqsubseteq\n        (\\bigsqcap P_i)^{\\mathcal{I}_\\ell\\mathcal{I}_\\ell}$\n      $\\ell$ := $\\ell + 1$\n    end\n\n    ;; add new attributes (up to equivalence)\n    $M_{i+1}$ := $M_i \\cup \\set{ \\exists r.(\\bigsqcap P_i)^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}} \\mid r \\in N_R}$\n\n    ;; update $\\con K_{i+1}, \\mathcal{S}_{i+1}$ and $\\mathcal{L}_{i+1}$\n    $\\con K_{i+1}$ := induced-context($\\mathcal{I}_{\\ell}$, $M_{i+1}$)\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_r \\to (P_r)_{\\con K_{i+1}}'' \\mid P_r \\neq\n      (P_r)_{\\con K_{i+1}}'', r \\in \\set{ 0, \\ldots, i} }$\n    $\\mathcal{S}_{i+1}$ := $\\set{ \\set{A} \\to \\set{B} \\mid A, B \\in M_{i+1}, A \\sqsubseteq\n      B }$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold}$\n\n    ;; next closed set\n    $P_{i+1}$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\mathcal{K}_{i+1} \\cup \\mathcal{S}_{i+1}$)\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$\n  end\n\n  return $\\set{ \\bigsqcap P \\sqsubseteq (\\bigsqcap P)^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}} \\mid (P \\to\n    P_{\\con K_{i+1}}'') \\in \\mathcal{K}_{i+1} }$\nend    \n    \\end{lstlisting}  \n  \\end{Algorithm}\n\\end{figure}\n\nWe are now able to adapt \\Cref{alg:base-of-interpretation} by replacing all references to\nthe background interpretation by expert interactions.  The result is shown in\n\\Cref{alg:model-exploration}.  From our previous discussion we now easily obtain the\nfollowing result.\n\n\\begin{Theorem}[Theorem~6.16 from~\\cite{Diss-Felix}]\n  \\label{thm:Felix-6.16}\n  Let $\\mathcal{I}_{\\mathsf{back}}$ be a finite interpretation, and let $\\mathcal{I}$ be a\n  connected subinterpretation of $\\mathcal{I}_{\\mathsf{back}}$.  Then\n  \\Cref{alg:model-exploration} applied to $\\mathcal{I}$, using\n  $\\mathcal{I}_{\\mathsf{back}}$ as background interpretation, terminates after finitely\n  many steps.  If $n$ is the number of iterations in this run, and if $\\mathcal{I}_{\\ell}$\n  is the final working interpretation, then the set\n  \\begin{equation*}\n    \\set{ \\bigsqcap P \\sqsubseteq (\\bigsqcap P)^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}}\n      \\mid (P \\to P_{\\con K_{n+1}}'') \\in \\mathcal{K}_{n+1} }\n  \\end{equation*}\n  is a finite base of $\\mathcal{I}_{\\mathsf{back}}$.\n\\end{Theorem}\n\n\\section{Model Exploration with Confident GCIs}\n\\label{sec:model-expl-with-1}\n\nIn the previous section we have seen how we can obtain an algorithm for model exploration\nby extending Baader and Distel's results on computing finite bases of finite\ninterpretations.  In this section we want to generalize this argumentation to the setting\nof GCIs with high confidence, \\ie we want to obtain an algorithm for model exploration\nwhich not only asks GCIs which are valid in the current working interpretation, but which\nis also allowed to ask GCIs whose confidence in the original data is just high enough.\nThis process we shall call \\emph{model exploration by confidence}.\n\nThe argumentation used for this model exploration algorithm essentially consists of\namending the computation of finite bases of finite interpretations by suitable expert\ninteraction.  Consequently, the argumentation we shall develop for model exploration by\nconfidence will be based on the computation of bases of GCIs with high confidence.\nHowever, the interpretation we consider during the exploration process contains a\nconnected subinterpretation consisting of the counterexamples given by the expert, and all\nGCIs which are not valid within this subinterpretation should not be considered further,\neven if they have a confidence above $c$ in the initial working interpretation.\n\nWe can thus think of $\\mathcal{I}_{\\ell}$ as consisting of two parts: the initial working\ninterpretation $\\mathcal{I}$, which may contain errors and where we apply our confidence\nheuristics, and a connected subinterpretation $\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}$,\nconsisting of the counterexamples given by the expert, where we only consider valid GCIs.\nWe can think of all elements of $\\mathcal{I}$ as \\emph{untrusted}, and of all elements of\n$\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}$ as \\emph{trusted}.\n\nTo generalize the argumentation for model exploration to GCIs with high confidence, we\nshall thus start by devising an algorithm that allows us to compute finite bases of finite\ninterpretations containing trusted and untrusted elements, \\ie that computes bases of\n\\begin{equation*}\n  \\Th_{c}(\\mathcal{I}) \\cap \\Th(\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}).\n\\end{equation*}\nWe shall do this in \\Cref{sec:trust-untr-indiv}.\n\nThereafter, we shall follow the argumentation of the previous section.  This means that in\n\\Cref{sec:grow-sets-attr-1} we shall discuss an algorithm that computes bases of formal\ncontexts containing trusted and untrusted objects, and where the attribute set is allowed\nto grow during the computation.  Thereafter, we shall discuss in\n\\Cref{sec:grow-sets-attr-1} how we can adapt this algorithm to compute bases of finite\ninterpretations that contain trusted and untrusted individuals, and where the set\n$M_{\\mathcal{I}}$ is computed incrementally during the run of the algorithm.  Finally, we\nshall see in \\Cref{sec:expl-conf-gcis} how we can introduce suitable expert interaction to\nobtain an algorithm for model exploration by confidence.\n\n\\subsection{Bases of Finite Interpretations with Untrusted Elements}\n\\label{sec:trust-untr-indiv}\n\nLet $\\mathcal{J}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let\n$\\mathcal{I}$ be a subinterpretation of $\\mathcal{J}$.  As already discussed, we want to\nthink of $\\mathcal{I}$ as the interpretation of \\emph{untrusted} elements, and of the\ninterpretation\n\\begin{equation*}\n  \\mathcal{J} \\setminus \\mathcal{I} := (\\Delta^{\\mathcal{J}} \\setminus\n  \\Delta^{\\mathcal{I}}, \\cdot^{\\mathcal{J} \\setminus \\mathcal{I}})\n\\end{equation*}\nas the interpretation of \\emph{trusted} elements (provided by the expert), where we define\n\\begin{align*}\n  A^{\\mathcal{J} \\setminus \\mathcal{I}} &:= A^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{J}}\n  \\setminus \\Delta^{\\mathcal{I}} = A^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}},\\\\\n  r^{\\mathcal{J} \\setminus \\mathcal{I}} &:= r^{\\mathcal{J}} \\cap (\\Delta^{\\mathcal{J}}\n  \\setminus \\Delta^{\\mathcal{I}}) \\times (\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}})\n\\end{align*}\nfor $A \\in N_{C}$ and $r \\in N_{R}$.\n\nThe aim of this section is to obtain a method to find finite bases of $\\mathcal{J}$ with\nuntrusted elements $\\mathcal{I}$.  More precisely, let us define for $c \\in [0,1]$ the set\n\\begin{multline*}\n  \\Th_{c}(\\mathcal{J}, \\mathcal{I}) := \\{\\, C \\sqsubseteq D\n    \\mid C, D \\in \\ELgfpbot(N_{C}, N_{R}), \\\\C^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}\n    \\subseteq D^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}, \\abs{ (C \\sqcap\n      D)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} } \\ge c \\cdot \\abs{ C^{\\mathcal{J}} \\cap\n      \\Delta^{\\mathcal{I}} } \\,\\}.\n\\end{multline*}\nWe then want to describe a finite base of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\nThe results of this section have been published previously\nin~\\cite{conf/dlog/Borchmann13}.\n\nNote that we have given the confidence constraint in the form of\n\\begin{equation}\n  \\label{eq:50}\n  \\abs{ (C \\sqsubseteq D)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} } \\ge c \\cdot \\abs{\n    C^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} },\n\\end{equation}\nwhich is the suitable formulation for our setting of $\\mathcal{I}$ being a\nsubinterpretation of $\\mathcal{J}$.  On the other hand, in our later considerations, both\n$\\mathcal{I}$ and $\\mathcal{J} \\setminus \\mathcal{I}$ will be connected subinterpretations\nof $\\mathcal{J}$, and in this case the definition of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$\ncan be simplified as follows: recall that in the case that $\\mathcal{I}$ is a connected\nsubinterpretation of $\\mathcal{J}$, \\Cref{lem:Felix-6.12} yields that for all $C, D \\in\n\\ELgfpbot(N_{C}, N_{R})$\n\\begin{align*}\n  C^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} &= C^{\\mathcal{I}}, \\\\\n  (C \\sqcap D)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} &= (C \\sqcap D)^{\\mathcal{I}}.\n\\end{align*}\nThus, \\Cref{eq:50} simplifies to\n\\begin{equation*}\n  \\abs{ (C \\sqcap D)^{\\mathcal{I}} } \\ge c \\cdot \\abs{ C^{\\mathcal{I}} },\n\\end{equation*}\nwhich is equivalent to $\\conf_{\\mathcal{I}}( C \\sqsubseteq D ) \\ge c$.  Furthermore, since\n$\\mathcal{J} \\setminus \\mathcal{I}$ is a connected subinterpretation of $\\mathcal{J}$, we\nobtain again by \\Cref{lem:Felix-6.12} that\n\\begin{equation*}\n  C^{\\mathcal{J} \\setminus \\mathcal{I}} = C^{\\mathcal{J}} \\cap (\\Delta^{\\mathcal{J}}\n  \\setminus \\Delta^{\\mathcal{I}}) = C^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}\n\\end{equation*}\nfor all $C \\in \\ELgfpbot(N_{C}, N_{R})$.  Therefore, $C^{\\mathcal{J}} \\setminus\n\\Delta^{\\mathcal{I}} \\subseteq D^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}$ is\nequivalent to $C^{\\mathcal{J}\\setminus\\mathcal{I}} \\subseteq\nD^{\\mathcal{J}\\setminus\\mathcal{I}}$, \\ie $(C \\sqsubseteq D) \\in \\Th(\\mathcal{J} \\setminus\n\\mathcal{I})$.  Thus, the definition of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$ can be\nrewritten as\n\\begin{align*}\n  \\Th_{c}(\\mathcal{J}, \\mathcal{I})\n  &= \\{\\, C \\sqsubseteq D \\mid C, D \\in \\ELgfpbot(N_{C}, N_{R}),\n  C^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}} \\subseteq D^{\\mathcal{J}}\n  \\setminus \\Delta^{\\mathcal{I}}, \\conf_{\\mathcal{I}}( C \\sqsubseteq D ) \\ge c \\,\\} \\\\\n  &= \\set{ (C \\sqsubseteq D) \\in \\Th(\\mathcal{J} \\setminus \\mathcal{I}) \\mid\n    \\conf_{\\mathcal{I}} (C \\sqsubseteq D) \\ge c } \\\\\n  &= \\Th(\\mathcal{J} \\setminus \\mathcal{I}) \\cap \\Th_{c}(\\mathcal{I}),\n\\end{align*}\nwhich corresponds to our intention of finding a finite base of all GCIs which are valid in\n$\\mathcal{J} \\setminus \\mathcal{I}$ and have high confidence in $\\mathcal{I}$.\n\nLet us return to the general case that $\\mathcal{I}$ is just a subinterpretation of\n$\\mathcal{J}$.  To find a base for the set $\\Th_{c}(\\mathcal{J} \\setminus \\mathcal{I})$,\nwe make use of the ideas we have already used to find finite confident bases of\n$\\Th_{c}(\\mathcal{I})$.  More precisely, we first observe that\n\\begin{equation*}\n  \\Th(\\mathcal{J}) \\subseteq \\Th_{c}(\\mathcal{J}, \\mathcal{I}).\n\\end{equation*}\nSince we can find bases of $\\Th(\\mathcal{J})$ using the results of Baader and Distel, we\nagain concentrate on finding bases of the set $\\Th_{c}(\\mathcal{J}, \\mathcal{I}) \\setminus\n\\Th(\\mathcal{J})$.  In other words, if $\\mathcal{B}$ is a base of $\\Th(\\mathcal{J})$, then\nwe seek a set $\\mathcal{C} \\subseteq \\Th_{c}(\\mathcal{J}, \\mathcal{I}) \\setminus\n\\Th(\\mathcal{J})$ which is complete for $\\Th_{c}(\\mathcal{J}, \\mathcal{I}) \\setminus\n\\Th(\\mathcal{J})$.  In this case, $\\mathcal{B} \\cup \\mathcal{C}$ is a base of\n$\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\nTo find such a set $\\mathcal{C}$ we first observe that\n\\begin{equation*}\n  (C \\sqsubseteq D) \\in \\Th_{c}(\\mathcal{J}, \\mathcal{I}) \\iff (C^{\\mathcal{J}\\mathcal{J}}\n  \\sqsubseteq D^{\\mathcal{J}\\mathcal{J}}) \\in \\Th_{c}(\\mathcal{J}, \\mathcal{I}).\n\\end{equation*}\nThis is because\n\\begin{align*}\n  C^{\\mathcal{J}} &= C^{\\mathcal{J}\\mathcal{J}\\mathcal{J}},\\\\\n  (C \\sqcap D)^{\\mathcal{J}} &= (C \\sqcap D)^{\\mathcal{J}\\mathcal{J}\\mathcal{J}}\n\\end{align*}\nis true, thus\n\\begin{equation*}\n  C^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}} \\subseteq D^{\\mathcal{J}} \\setminus\n  \\Delta^{\\mathcal{I}} \\iff C^{\\mathcal{J}\\mathcal{J}\\mathcal{J}} \\setminus\n  \\Delta^{\\mathcal{I}} \\subseteq D^{\\mathcal{J}\\mathcal{J}\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}},\n\\end{equation*}\nand \\Cref{eq:50} is true if and only if\n\\begin{equation*}\n  \\abs{ (C \\sqsubseteq D)^{\\mathcal{J}\\mathcal{J}\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }\n  \\ge c \\cdot \\abs{ C^{\\mathcal{J}\\mathcal{J}\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }.\n\\end{equation*}\n\nIf now $\\mathcal{B}$ is a base of $\\Th(\\mathcal{J})$, then it is true that\n\\begin{equation*}\n  \\mathcal{B} \\cup \\set{ C^{\\mathcal{J}\\mathcal{J}} \\sqsubseteq D^{\\mathcal{J}\\mathcal{J}}\n  } \\models (C \\sqsubseteq D).\n\\end{equation*}\nThis is because $\\mathcal{B} \\models (C \\sqsubseteq C^{\\mathcal{J}\\mathcal{J}})$, since $C\n\\sqsubseteq C^{\\mathcal{J}\\mathcal{J}}$ is valid in $\\mathcal{J}$.  Furthermore,\n$D^{\\mathcal{J}\\mathcal{J}} \\sqsubseteq D$, and thus\n\\begin{equation*}\n  \\mathcal{B} \\cup \\set{ C^{\\mathcal{J}\\mathcal{J}} \\sqsubseteq D^{\\mathcal{J}\\mathcal{J}}\n  } \\models (C \\sqsubseteq C^{\\mathcal{J}\\mathcal{J}} \\sqsubseteq\n  D^{\\mathcal{J}\\mathcal{J}} \\sqsubseteq D).\n\\end{equation*}\n\nHaving these two considerations in mind we define\n\\begin{equation*}\n  \\Conf(\\mathcal{J}, c, \\mathcal{I}) := \\set{ X^{\\mathcal{J}} \\sqsubseteq\n    Y^{\\mathcal{J}} \\mid Y \\subseteq X \\subseteq \\Delta^{\\mathcal{J}}, (X^{\\mathcal{J}}\n\\sqsubseteq Y^{\\mathcal{J}}) \\in \\Th_{c}(\\mathcal{J}, \\mathcal{I}) }.\n\\end{equation*}\nSince $\\mathcal{J}$ is a finite interpretation, $\\Delta^{\\mathcal{J}}$ is finite.  We\ntherefore obtain the following result.\n\n\\begin{Theorem}\n  \\label{thm:finite-base-of-interpretation-with-untrusted-individuals}\n  Let $\\mathcal{J}$ be a finite interpretation, let $\\mathcal{I}$ be a\n  subinterpretation of $\\mathcal{J}$, and let $c \\in [0,1]$.  Then if $\\mathcal{B}$ is a\n  finite base of $\\mathcal{J}$, then the set\n  \\begin{equation*}\n    \\mathcal{B} \\cup \\Conf(\\mathcal{J}, c, \\mathcal{I})\n  \\end{equation*}\n  is a finite base of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\\end{Theorem}\n\nThis result already solves our initial problem of finding a finite base of\n$\\Th_{c}(\\mathcal{J} \\setminus \\mathcal{I})$.  In the following, we want to extend this\nresult in the direction of computing finite bases of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$\nby computing suitable bases in the corresponding induced contexts.  This will be helpful\nlater when we develop our algorithm for model exploration by confidence.\n\n\\def\\restricted{\\mathord{\\upharpoonright}}\n\nTo this end, we first need to introduce some extra notation.  Let $X \\subseteq\n\\Delta^{\\mathcal{J}}$.  Then we shall denote with $\\con K_{\\mathcal{J}}\\restricted_{X}$\nthe formal context whose set of objects is restricted to $X$, \\ie\n\\begin{equation*}\n  \\con K_{\\mathcal{J}}\\restricted_{X} := (X, M_{\\mathcal{J}}, \\nabla),\n\\end{equation*}\nwhere $(x, C) \\in \\nabla \\iff x \\in C^{\\mathcal{J}}$ for $x \\in X, C \\in M_{\\mathcal{J}}$\nas before.\n\nWe can now formulate a result that allows to find bases of interpretations with untrusted\nelements from bases of corresponding induced contexts.\n\n\\begin{Theorem}\n  \\label{thm:bases-of-untrusted-interpretations-from-bases-of-contexts}\n  Let $\\mathcal{J}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let\n  $\\mathcal{I}$ be a subinterpretation of $\\mathcal{J}$.  Let $c \\in [0,1]$, and define\n  \\begin{equation*}\n    \\mathcal{T} := \\Th_{c}(\\con K_{\\mathcal{J}}\\restricted_{\\Delta^{\\mathcal{I}}}) \\cap\n    \\Th(\\con K_{\\mathcal{J}}\\restricted_{\\Delta^{\\mathcal{J}}\\setminus\\Delta^{\\mathcal{I}}}).\n  \\end{equation*}\n  Let $\\mathcal{L} \\subseteq \\mathcal{T}$ be complete for $\\mathcal{T}$.  Then $\\bigsqcap\n  \\mathcal{L} \\subseteq \\Th_{c}(\\mathcal{J}, \\mathcal{I})$ and $\\bigsqcap \\mathcal{L}$ is\n  complete for $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\\end{Theorem}\n\n\\begin{Proof}\n  We first show $\\bigsqcap \\mathcal{L} \\subseteq \\Th_{c}(\\mathcal{J}, \\mathcal{I})$.  For\n  this we need to show that for each $(\\bigsqcap X \\sqsubseteq \\bigsqcap Y) \\in \\bigsqcap\n  \\mathcal{L}$ it is true that\n  \\begin{enumerate}[i. ]\n  \\item $\\abs{ (\\bigsqcap X \\sqcap \\bigsqcap Y)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }\n    \\ge c \\cdot \\abs{ (\\bigsqcap X)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }$, and\n  \\item $(\\bigsqcap X)^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}} \\subseteq (\\bigsqcap\n    Y)^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}$.\n  \\end{enumerate}\n  For the first subclaim we observe that $\\conf_{\\con\n    K_{\\mathcal{J}}\\restricted_{\\Delta^{\\mathcal{I}}}}(X \\to Y) \\ge c$, \\ie\n  \\begin{equation*}\n    \\abs{ (X \\cup Y)' \\cap \\Delta^{\\mathcal{I}} } \\ge c \\cdot \\abs{ X' \\cap\n      \\Delta^{\\mathcal{I}} }.\n  \\end{equation*}\n  Since $X' = (\\bigsqcap X)^{\\mathcal{J}}$ and $Y' = (\\bigsqcap Y)^{\\mathcal{J}}$ by\n  \\Cref{prop:connection-I-prime-2}, we obtain\n  \\begin{equation*}\n    \\abs{ (\\bigsqcap (X \\cup Y))^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} } \\ge c \\cdot\n    \\abs{ (\\bigsqcap X)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} },\n  \\end{equation*}\n  and since $\\bigsqcap (X \\cup Y) = \\bigsqcap X \\sqcap \\bigsqcap Y$ we finally get\n  \\begin{equation*}\n    \\abs{ (\\bigsqcap X \\sqcap \\bigsqcap Y)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} } \\ge\n    c \\cdot \\abs{ (\\bigsqcap X)^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} },\n  \\end{equation*}\n  as required.\n\n  For the second subclaim we observe that $X' \\setminus \\Delta^{\\mathcal{I}} \\subseteq Y'\n  \\setminus \\Delta^{\\mathcal{I}}$, because $X \\to Y$ is valid in $\\con\n  K_{\\mathcal{J}}\\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}}$.\n  Since $X' = (\\bigsqcap X)^{\\mathcal{J}}$ and $Y' = (\\bigsqcap Y)^{\\mathcal{J}}$, we\n  obtain\n  \\begin{equation*}\n    (\\bigsqcap X)^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}} \\subseteq (\\bigsqcap\n    Y)^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}},\n  \\end{equation*}\n  as required.\n\n  We have thus shown that $\\bigsqcap \\mathcal{L} \\subseteq \\Th_{c}(\\mathcal{J},\n  \\mathcal{I})$.  We shall now consider the completeness of $\\bigsqcap \\mathcal{L}$ for\n  $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\n  To this end, we shall show the following two subclaims\n  \\begin{enumerate}[i. ]\n  \\item $\\bigsqcap \\mathcal{L} \\models (\\bigsqcap U \\sqsubseteq (\\bigsqcap\n    U)^{\\mathcal{J}\\mathcal{J}})$ for all $U \\subseteq M_{\\mathcal{J}}$, and\n  \\item $\\bigsqcap \\mathcal{L} \\models \\Conf(\\mathcal{J}, c, \\mathcal{I})$.\n  \\end{enumerate}\n  Since\n  \\begin{equation*}\n    \\set{ \\bigsqcap U \\sqsubseteq (\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}} \\mid U \\subseteq\n      M_{\\mathcal{J}} }\n  \\end{equation*}\n  is a base of $\\mathcal{J}$, the completeness of $\\bigsqcap \\mathcal{L}$ for\n  $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$ then follows immediately from\n  \\Cref{thm:finite-base-of-interpretation-with-untrusted-individuals}.\n\n  For the first subclaim let $U \\subseteq M_{\\mathcal{J}}$.  Because\n  \\begin{equation*}\n    \\Th(\\con K_{\\mathcal{J}}) \\subseteq \\Th_{c}(\\con K_{\\mathcal{J}}\n    \\restricted_{\\Delta^{\\mathcal{I}}}) \\cap \\Th(\\con K_{\\mathcal{J}}\n    \\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}})\n  \\end{equation*}\n  it follows that $\\mathcal{L}$ is complete for $\\con K_{\\mathcal{J}}$.  Therefore,\n  \\begin{equation*}\n    \\mathcal{L} \\models (U \\to U'').\n  \\end{equation*}\n  By \\Cref{lem:implicational-entailment-implies-gci-entailment} we obtain\n  \\begin{equation*}\n    \\bigsqcap \\mathcal{L} \\models (\\bigsqcap U \\sqsubseteq \\bigsqcap U''),\n  \\end{equation*}\n  and since $\\bigsqcap U'' \\equiv (\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}}$,  we obtain\n  \\begin{equation*}\n    \\bigsqcap \\mathcal{L} \\models (\\bigsqcap U \\sqsubseteq (\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}})\n  \\end{equation*}\n  as required.\n\n  For the second subclaim let $(X^{\\mathcal{J}} \\sqsubseteq Y^{\\mathcal{J}}) \\in\n  \\Conf(\\mathcal{J}, c, \\mathcal{I})$.  Then by \\Cref{prop:connection-I-prime-2} it is\n  true that\n  \\begin{equation*}\n    X^{\\mathcal{J}} \\equiv \\bigsqcap X',\\, Y^{\\mathcal{J}} \\equiv \\bigsqcap Y'.\n  \\end{equation*}\n  Therefore,\n  \\begin{equation}\n    \\label{eq:51}\n    \\bigsqcap \\mathcal{L} \\models (X^{\\mathcal{J}} \\sqsubseteq Y^{\\mathcal{J}}) \\iff \\bigsqcap\n    \\mathcal{L} \\models (\\bigsqcap X' \\sqsubseteq \\bigsqcap Y').\n  \\end{equation}\n  Therefore, to show $\\bigsqcap \\mathcal{L} \\models (X^{\\mathcal{J}} \\sqsubseteq\n  Y^{\\mathcal{J}})$ it suffices to show $\\mathcal{L} \\models (X' \\to Y')$.\n\n  Recall that since $(X^{\\mathcal{J}} \\sqsubseteq Y^{\\mathcal{J}}) \\in \\Conf(\\mathcal{J},\n  c, \\mathcal{I})$, it is true that\n  \\begin{equation*}\n    \\abs{ (X^{\\mathcal{J}} \\sqcap Y^{\\mathcal{J}})^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}}\n      } \\ge c \\cdot \\abs{ X^{\\mathcal{J}\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }.\n  \\end{equation*}\n  This implies\n  \\begin{equation*}\n    \\abs{ (\\bigsqcap (X' \\cup Y'))^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}}\n      } \\ge c \\cdot \\abs{ (\\bigsqcap X')^{\\mathcal{J}} \\cap \\Delta^{\\mathcal{I}} }.\n  \\end{equation*}\n  and thus\n  \\begin{equation*}\n    \\abs{ ((X' \\cup Y')' \\cap \\Delta^{\\mathcal{I}} } \\ge c \\cdot \\abs{ X''\n      \\cap \\Delta^{\\mathcal{I}}},\n  \\end{equation*}\n  \\ie $(X' \\to Y') \\in \\Th_{c}(\\con K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{I}}})$.\n\n  Furthermore, it is true that\n  \\begin{equation*}\n    X^{\\mathcal{J}\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}} \\subseteq Y^{\\mathcal{J}\\mathcal{J}} \\setminus\n    \\Delta^{\\mathcal{I}},\n  \\end{equation*}\n  and by \\Cref{prop:connection-I-prime-2} we have $X^{\\mathcal{J}\\mathcal{J}} = X'',\n  Y^{\\mathcal{J}\\mathcal{J}} = Y''$, thus\n  \\begin{equation*}\n    X'' \\setminus \\Delta^{\\mathcal{I}} \\subseteq Y'' \\setminus \\Delta^{\\mathcal{I}},\n  \\end{equation*}\n  \\ie $(X' \\to Y') \\in \\Th(\\con K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{J}} \\setminus\n    \\Delta^{\\mathcal{I}}})$.\n\n  Since $\\mathcal{L}$ is complete for $\\mathcal{T}$, we thus obtain that\n  \\begin{equation*}\n    \\mathcal{L} \\models (X' \\to Y'),\n  \\end{equation*}\n  and thus $\\bigsqcap \\mathcal{L} \\models (\\bigsqcap X' \\sqsubseteq \\bigsqcap Y')$ by\n  \\Cref{lem:implicational-entailment-implies-gci-entailment}, and $\\bigsqcap \\mathcal{L}\n  \\models (X^{\\mathcal{J}} \\sqsubseteq Y^{\\mathcal{J}})$ by \\Cref{eq:51}.\n\\end{Proof}\n\n\\subsection{Computing Bases of Formal Contexts with Growing Sets of Attributes}\n\\label{sec:grow-sets-attr-1}\n\nWe have seen how we can obtain finite bases of interpretations containing untrusted\nelements.  In the following two sections we want to devise an algorithm that allows us to\ncompute this base in a manner which is suitable for being adapted towards model\nexploration by confidence.  In particular, we shall see in this section how we can compute\nbases of\n\\begin{equation}\n  \\label{eq:52}\n  \\Th_{c}(\\con K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{I}}}) \\cap \\Th(\\con\n  K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}}),\n\\end{equation}\nwhere we compute the set $M_{\\mathcal{J}}$ incrementally during the run of the algorithm.\nThen, in the next section we shall see how we can use this algorithm and\n\\Cref{thm:bases-of-untrusted-interpretations-from-bases-of-contexts} to compute finite\nbases of interpretations that contain untrusted elements.\n\nLet us consider the problem of finding an algorithm that allows us to compute bases of the\nset given in \\Cref{eq:52} from a more abstract point of view.  More precisely, let us\nconsider two formal contexts $\\con K_{1}$ and $\\con K_{2}$ with the same attribute set\n$M$.  Then we want to find an algorithm that computes a base of\n\\begin{equation}\n  \\label{eq:53}\n  \\Th_{c}(\\con K_{1}) \\cap \\Th(\\con K_{2}),\n\\end{equation}\nand which allows us to incrementally supply the elements of $M$ as the computation\nproceeds.\n\nAs a special case of \\Cref{eq:53} we first consider the case that $\\con K_{2} =\n(\\emptyset, M, \\emptyset)$, \\ie we want to devise the algorithm such that it computes a\nbase of $\\Th_{c}(\\con K_{1})$.  As in \\Cref{sec:grow-sets-attr}, we want to obtain such an\nalgorithm by adapting the classical algorithm for computing the canonical base of a formal\ncontext.  Indeed, we could simply obtain such an algorithm if we would replace in\n\\Cref{alg:base/growing-set-of-attributes} every occurrence of $(\\cdot)_{\\con K_{i+1}}''$\nby a call to the closure operator induced by $\\Th_{c}(\\con K_{i+1})$.  However, as we had\nalready argued in \\Cref{sec:expl-conf-1}, computing closures under $\\Th_{c}(\\con K_{i+1})$\nmay be infeasible.\n\nTo avoid this, we shall make use of the ideas we have developed in\n\\Cref{sec:poss-fast-expl}, when we devised an algorithm for exploration by confidence that\navoids computing closures under $\\Th_{c}(\\con K)$.  Indeed, we can just take\n\\Cref{alg:exploration-by-confidence-without-Th_c(K)-closures}, and instantiate it with an\nexpert that confirms all implications.\n\nRecall that in this algorithm there were two cases of implications asked to the expert:\nimplications were either of the form $P_{i+1} \\to \\set{m}$, where $\\conf_{\\con K}(P_{i+1}\n\\to \\set{m}) \\ge c$ and $c \\notin \\mathcal{K}_{i}(P_{i+1})$, or $P_{i+1} \\to\n(P_{i+1})_{\\con K \\div \\con L_{i}}''$.  We can simplify these two cases into one case by\ndefining for $P \\subseteq M$ and $c \\in [0,1]$\n\\begin{equation*}\n  P^{\\con K, c} := \\set{ m \\in M \\mid \\conf_{\\con K}(P \\to \\set{m}) \\ge c }.\n\\end{equation*}\nThen we only ask implications of the form\n\\begin{equation*}\n  P_{i+1} \\to (P_{i+1})^{\\con K, c},\n\\end{equation*}\nand this then covers both cases.\n\nTo make this algorithm into an algorithm that allows the set of attributes to grow during\nthe computation, we use the ideas of \\Cref{sec:grow-sets-attr}: whenever there are new\nelements to be added to the current set of attributes, we add them as the smallest\nelements.  In this way, the underlying Next Closure algorithm behaves as if those elements\nwould have been present right from the start of the run, and thus behaves as desired.\n\n\\addfunctionname{confident-base}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm} Axiomatize Confident Implications with Growing Sets of Attributes\n    \\hspace*{0cm}\n    \\label{alg:confident-base/growing-attributes}\n    \\begin{lstlisting}\ndefine confident-base($\\con K = (G, M, I)$, $c \\in [0,1]$)\n  $i$ := $0$\n  $M_i$ := $M$\n  $I_i$ := $I$\n  $\\mathcal{S}_i$ := $P_i$ := $\\mathcal{K}_i$ := $\\emptyset$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n  \n  forever do\n    read $\\con K_{i+1} = (G, M_{i+1}, I_{i+1}) \\text{ such that } M_i \\subseteq M_{i+1}\n\\text{ and } I_i = (G \\times M_i) \\cap I_{i+1}$\n    read $\\mathcal{S}_{i+1} \\text{ such that } \\mathcal{S}_i \\subseteq \\mathcal{S}_{i+1}\n\\subseteq \\Th_{c}(\\con K_{i+1})$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold}$\n\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_k \\to P_k^{\\con K_{i+1}, c} \\mid k \\in \\set{0, \\ldots,\n        i}, P_k \\neq P_k^{\\con K_{i+1}, c} }$\n\n    $P_{i+1}^1$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\con K_{i+1}$)\n    $P_{i+1}^2$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1}$)\n\n    $P_{i+1}$ := $\\min\\nolimits_{\\preceq}(P_{i+1}^1, P_{i+1}^2)$.\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$\n  end\n\n  return $\\mathcal{K}_{i+1}$  \nend\n    \\end{lstlisting}\n  \\end{Algorithm}\n\\end{figure}\n\nThe algorithm that we obtain from these considerations is shown in\n\\Cref{alg:confident-base/growing-attributes}.  Note that as in the case of\n\\Cref{alg:base/growing-set-of-attributes}, we cannot discard sets $P_{i}$ which are closed\nunder $(\\cdot)^{\\con K_{i+1}, c}$, \\ie which satisfy $P_{i} = P_{i}^{\\con K_{i+1}, c}$, as\n$P_{i}$ may not be closed under $(\\cdot)^{\\con K_{j}, c}$ for some later iteration $j$.\n\nWe can argue termination of \\Cref{alg:confident-base/growing-attributes} as we did before\nfor \\Cref{alg:base/growing-set-of-attributes}: if at a certain iteration $\\ell$ it is true\nfor all iterations $k \\geq \\ell$ that $M_{k} = M_{\\ell}$, then\n\\Cref{alg:confident-base/growing-attributes} must terminate.  This is in particular the\ncase if we want to compute a base of $\\Th_{c}(\\con K)$ where $\\con K$ is a finite formal\ncontext, and where the attributes of $\\con K$ are supplied incrementally during the run of\nthe algorithm.\n\nTo show that upon termination, the set $\\mathcal{K}_{n}$ of implications, where $n$ is the\nnumber of iterations of \\Cref{alg:confident-base/growing-attributes}, is indeed a base of\n$\\Th_{c}(\\con K_{n})$, we adapt the argumentation of \\Cref{sec:grow-sets-attr} and\n\\Cref{sec:comp-bases-given} accordingly.  The following result and its proof are a\ngeneralization of~\\cite[Lemma~6.3]{Diss-Felix}.\n\n\\begin{Proposition}\n  \\label{prop:property-of-confident-bases-with-growing-sets-of-attributes}\n  Consider a terminating run of \\Cref{alg:confident-base/growing-attributes}, and let $n$\n  be the number of iterations of this run.  Let $Q \\subseteq M_{n}$.   Then the following\n  statements hold.\n  \\begin{enumerate}[i. ]\n  \\item If $Q \\neq Q_{\\con K_{n}}''$, then $Q$ is not $(\\mathcal{S}_{n} \\cup\n    \\mathcal{K}_{n})$-closed.\n  \\item If $Q = Q_{\\con K_{n}}''$, then $Q = P_{k}$ for some $k \\in \\set{ 0, \\dots, n }$.\n  \\end{enumerate}\n\\end{Proposition}\n\\begin{Proof}\n  The case $Q = \\emptyset = P_{0}$ can be handled quite easily: if $Q \\neq Q_{\\con\n    K_{n}}''$, then $Q \\neq Q^{\\con K_{n}, c}$, since $Q_{\\con K_{n}}'' \\subseteq Q^{\\con\n    K_{n}, c}$.  Therefore, $(Q \\to Q^{\\con K_{n}, c}) \\in \\mathcal{K}_{n}$ and thus $Q$\n  is not $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed.  If on the other hand $Q =\n  Q_{\\con K_{n}}''$, then $Q = P_{0}$ shows the claim.\n\n  Now suppose that $Q \\neq \\emptyset$.  Then there exists $k \\in \\set{0, \\dots, n}$ such that\n  \\begin{equation*}\n    P_{k-1} \\precneq Q \\preceq P_{k}.\n  \\end{equation*}\n  We first argue that $Q \\subseteq M_{k}$.  To this end, suppose by contradiction that\n  this is not the case, and let $m \\in Q \\setminus M_{k}$.  Since $m \\notin M_{k}$, it is\n  smaller than every element of $M_{k}$, by construction of the linear order\n  $\\leq_{M_{n}}$ on $M_{n}$.  Thus, $M_{k} \\precneq \\set{m}$, and since $\\set{m} \\subseteq\n  Q$, we obtain\n  \\begin{equation*}\n    M_{k} \\precneq \\set{m} \\preceq Q,\n  \\end{equation*}\n  contradicting the fact that $Q \\preceq P_{k} \\preceq M_{k}$.  Therefore, $Q \\subseteq\n  M_{k}$.\n\n  Let us first consider the case $Q \\neq Q_{\\con K_{n}}''$, and assume by contradiction\n  that $Q$ is $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed.  Then by construction\n  \\begin{equation*}\n    P_{k}^{2} \\preceq Q \\preceq P_{k} \\preceq P_{k}^{2},\n  \\end{equation*}\n  and thus $Q = P_{k}$.  Then $Q \\neq Q_{\\con K_{n}}''$ means $P_{k} \\neq (P_{k})_{\\con\n    K_{n}}''$, thus $P_{k} \\neq P_{k}^{\\con K_{n}, c}$, and therefore\n  \\begin{equation*}\n    (P_{k} \\to P_{k}^{\\con K_{n}, c}) \\in \\mathcal{K}_{n}.\n  \\end{equation*}\n  But $Q$ is not $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed, a contradiction.\n  Therefore, $Q$ is not $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed, as it was\n  claimed.\n\n  Let us now consider the case that $Q = Q_{\\con K_{n}}''$, and we have to show that $Q =\n  P_{\\ell}$ for $\\ell \\in \\set{ 0, \\dots, n }$.  Since $Q = Q_{\\con K_{n}}''$, it is also\n  true that $Q = Q_{\\con K_{k}}''$, since\n  \\begin{equation*}\n    I_{k} = (G \\times M_{k}) \\cap I_{n}.\n  \\end{equation*}\n  But then $P_{k}^{1} \\preceq Q \\preceq P_{k}$, and thus $Q = P_{k}$, as required.\n\\end{Proof}\n\n\\begin{Theorem}\n  \\label{thm:confident-bases-with-growing-sets-of-attributes}\n  Let $\\con K$ be a finite formal context, $c \\in [0,1]$, and suppose that\n  \\Cref{alg:confident-base/growing-attributes} applied to $\\con K$ and $c$ terminates\n  after $n$ iterations.  Then $\\mathcal{K}_{n}$ is a base for $\\Th_{c}(\\con K_{n})$ with\n  background knowledge $\\mathcal{S}_{n}$.\n\\end{Theorem}\n\\begin{Proof}\n  The fact that $\\mathcal{K}_{n} \\cup \\mathcal{S}_{n} \\subseteq \\Cn(\\Th_{c}(\\con K_{n}))$\n  is clear from the definition of $\\mathcal{K}_{n}$ and $\\mathcal{S}_{n}$, and we thus\n  only need to show that $\\mathcal{S}_{n} \\cup \\mathcal{K}_{n}$ is complete for\n  $\\Th_{c}(\\con K_{n})$.  For this we shall use\n  \\Cref{lem:characterization-of-completeness} and show that every set $Q \\subseteq M_{n}$\n  which is $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed is also $\\Th_{c}(\\con\n  K_{n})$-closed.\n\n  To this end, let us assume by contradiction that $Q$ is $(\\mathcal{S}_{n} \\cup\n  \\mathcal{K}_{n})$-closed, but not $\\Th_{c}(\\con K_{n})$-closed.  Then there exists an\n  implication $(P \\to \\set{m}) \\in \\Th_{c}(\\con K_{n})$ such that $P \\subseteq Q$ and $m\n  \\notin Q$.  Furthermore, since $Q$ is $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed,\n  it follows from \\Cref{prop:property-of-confident-bases-with-growing-sets-of-attributes}\n  that $Q = Q_{\\con K_{n}}''$.  Then since\n  \\begin{equation*}\n    \\conf_{\\con K_{n}}(P \\to \\set{m}) = \\conf_{\\con K_{n}}(P_{\\con K_{n}}'' \\to \\set{m}),\n  \\end{equation*}\n  we can assume that $P = P_{\\con K_{n}}''$.  But then, using\n  \\Cref{prop:property-of-confident-bases-with-growing-sets-of-attributes} again, we obtain\n  that $P = P_{k}$ for some $k \\in \\set{ 0, \\dots, n }$, and thus\n  \\begin{equation*}\n    (P \\to P^{\\con K_{n}, c}) = (P_{k} \\to P_{k}^{\\con K_{n}, c}) \\in \\mathcal{K}_{n},\n  \\end{equation*}\n  because $P_{k} \\neq P_{k}^{\\con K_{n}, c}$, since $m \\notin P_{k} \\subseteq Q$, but $m\n  \\in P_{k}^{\\con K_{n}, c}$.  Now since $Q$ is $\\mathcal{K}_{n}$-closed, $P_{k} \\subseteq\n  Q$ implies $P_{k}^{\\con K_{n}, c} \\subseteq Q$, and since $m \\in P_{k}^{\\con K_{n}, c}$,\n  we obtain $m \\in Q$, a contradiction.\n\n  Therefore, every set $Q$ that is $(\\mathcal{S}_{n} \\cup \\mathcal{K}_{n})$-closed is also\n  $\\Th_{c}(\\con K_{n})$-closed, and thus $\\mathcal{S}_{n} \\cup \\mathcal{K}_{n}$ is\n  complete for $\\Th_{c}(\\con K_{n})$, as it was claimed.\n\\end{Proof}\n\nIn this theorem, the set $\\mathcal{K}_{n}$ does not necessarily contain implications whose\nconfidence is at least $c$, \\ie $\\mathcal{K}_{n} \\subseteq \\Th_{c}(\\con K)$ is not\nnecessarily true.  However, a simple modification of\n\\Cref{alg:confident-base/growing-attributes} achieves that the computed base is indeed a\nconfident base of $\\Th_{c}(\\con K)$.  For this we define the return value of\n\\Cref{alg:confident-base/growing-attributes} as\n\\begin{equation*}\n  \\hat{\\mathcal{K}} := \\set{ P \\to \\set{m} \\mid (P \\to P^{\\con K, c}) \\in \\mathcal{K}_{n},\n    m \\in P^{\\con K, c} }.\n\\end{equation*}\nThen, by definition of $P^{\\con K, c}$, it is true that $\\hat{\\mathcal{K}} \\subseteq\n\\Th_{c}(\\con K)$.  Of course, instead of choosing $m$ in $P^{\\con K, c}$, it also suffices\nto consider only $m \\in P^{\\con K, c} \\setminus \\mathcal{S}_{n}(P)$.\n\nWith \\Cref{alg:confident-base/growing-attributes} we have now obtained an algorithm that\nallows us to compute bases of $\\Th_{c}(\\con K)$, where the attribute set can be added\nincrementally during the computation.  Based on this algorithm, we now want to turn back\nto our initial problem of finding bases of $\\Th_{c}(\\con K_{1}) \\cap \\Th(\\con K_{2})$,\nwhere both formal contexts $\\con K_{1}$ and $\\con K_{2}$ have the same attribute set $M$.\n\nThe main idea to adapt \\Cref{alg:confident-base/growing-attributes} to this setting is to\n\\emph{divide} the working context into two formal contexts $\\con K_{i+1}$ and $\\con\nL_{i+1}$, such that in $\\con K_{i+1}$ (the \\emph{untrusted} part) we apply the usual\nconfidence heuristics, and in $\\con L_{i+1}$ (the \\emph{trusted} part) we consider only\nvalid implications.  Then instead of computing the sets $P^{\\con K_{i+1}, c}$, we consider\n\\begin{equation*}\n  P^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}'' = \\set{ m \\in P_{\\con L_{i+1}}'' \\mid\n    \\conf_{\\con K_{i+1}}(P \\to \\set{m}) \\ge c }.\n\\end{equation*}\nThe division of the working context into $\\con K_{i+1}$ and $\\con L_{i+1}$ can be\nrepresented by using the subposition $\\con K_{i+1} \\div \\con L_{i+1}$ as the working\ncontext.  Then clearly\n\\begin{equation}\n  \\label{eq:54}\n  P_{\\con K_{i+1} \\div \\con L_{i+1}}'' = P_{\\con K_{i+1}}'' \\cap P_{\\con L_{i+1}}''\n  \\subseteq P^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}''.\n\\end{equation}\nThe resulting algorithm is shown in\n\\Cref{alg:confident-base/growing-attributes-trusted-objects}.\n\n\\addfunctionname{confident-base/trusted-objects}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm} Axiomatize Confident Implications with Trusted Objects\n    \\hspace*{0cm}\n    \\label{alg:confident-base/growing-attributes-trusted-objects}\n    \\begin{lstlisting}\ndefine confident-base/trusted-objects($\\con K = (G_{1}, M, I)$, $\\con L = (G_{2}, M, J)$, $c \\in [0,1]$)\n  $i$ := $0$\n  $M_i$ := $M$\n  $I_i$ := $I$\n  $J_{i}$ := $J$\n  $\\mathcal{S}_i$ := $P_i$ := $\\mathcal{K}_i$ := $\\emptyset$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n  \n  forever do\n    read $M_{i+1} \\text{ such that } M_{i} \\subseteq M_{i+1}$\n    read $I_{i+1} \\text{ such that } I_{i} = (G_{1} \\times M_{i}) \\cap I_{i+1}$\n    read $J_{i+1} \\text{ such that } J_{i} = (G_{2} \\times M_{i}) \\cap J_{i+1}$\n    $\\con K_{i+1}$ := $(G_{1}, M_{i+1}, I_{i+1})$\n    $\\con L_{i+1}$ := $(G_{2}, M_{i+1}, J_{i+1})$\n    read $\\mathcal{S}_{i+1} \\text{ such that } \\mathcal{S}_i \\subseteq \\mathcal{S}_{i+1}\n\\subseteq \\Th_{c}(\\con K_{i+1}) \\cap \\Th(\\con L_{i+1})$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold}$\n\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_k \\to P_k^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}'' \\mid k \\in \\set{0, \\ldots, i}, P_k \\neq P_k^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}''}$\n\n    $P_{i+1}^1$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\con K_{i+1} \\div \\con L_{i+1}$)\n    $P_{i+1}^2$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1}$)\n\n    $P_{i+1}$ := $\\min\\nolimits_{\\preceq}(P_{i+1}^1, P_{i+1}^2)$.\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$\n  end\n\n  return $\\mathcal{K}_{i+1}$  \nend\n    \\end{lstlisting}\n  \\end{Algorithm}\n\\end{figure}\n\nBecause of \\Cref{eq:54} the proofs of\n\\Cref{prop:property-of-confident-bases-with-growing-sets-of-attributes} and\n\\Cref{thm:confident-bases-with-growing-sets-of-attributes} can be carried over to\n\\Cref{alg:confident-base/growing-attributes-trusted-objects} almost literally, essentially\nby replacing every occurrence of $(\\cdot)_{\\con K_{i}}''$ by $(\\cdot)_{\\con K_{i} \\div\n  \\con L_{i}}''$, and by replacing every expression of the form $P^{\\con K_{i}, c}$ by\n$P^{\\con K_{i}, c} \\cap P_{\\con L_{i}}''$.  From this we obtain the validity of the\nfollowing results.\n\n\\begin{Proposition}\n  Consider a terminating run of\n  \\Cref{alg:confident-base/growing-attributes-trusted-objects}, and let $n$ be the number\n  of iterations of this run.  Let $Q \\subseteq M_{n}$.  Then the following statements\n  hold.\n  \\begin{enumerate}[i. ]\n  \\item If $Q \\neq Q_{\\con K_{n} \\div \\con L_{n}}''$, then $Q$ is not $(\\mathcal{S}_{n} \\cup\n    \\mathcal{K}_{n})$-closed.\n  \\item If $Q = Q_{\\con K_{n} \\div \\con L_{n}}''$, then $Q = P_{k}$ for some $k \\in \\set{\n      0, \\dots, n }$.\n  \\end{enumerate}\n\\end{Proposition}\n\\begin{Theorem}\n  \\label{thm:confident-bases-with-growing-sets-of-attributes-and-trusted-objects}\n  Let $\\con K, \\con L$ be two finite formal contexts with attribute set $M$ and disjoint\n  sets of objects, $c \\in [0,1]$, and suppose that\n  \\Cref{alg:confident-base/growing-attributes-trusted-objects} applied to $\\con K$, $\\con\n  L$ and $c$ terminates after $n$ iterations.  Then $\\mathcal{K}_{n}$ is a base for\n  $\\Th_{c}(\\con K_{n}) \\cap \\Th(\\con L_{n})$ with background knowledge $\\mathcal{S}_{n}$.\n\\end{Theorem}\n\n\\subsection{Computing Bases of Finite Interpretations with Untrusted Elements}\n\\label{sec:expl-conf-gcis}\n\nWe shall now use the results of the previous section to devise an algorithm that allows us\nto compute bases of interpretations with untrusted elements.  More precisely, let\n$\\mathcal{J}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let $\\mathcal{I}$\nbe a finite, connected subinterpretation of $\\mathcal{J}$, such that $\\mathcal{J}\n\\setminus \\mathcal{I}$ is also a connected subinterpretation of $\\mathcal{J}$.  We then\nwant to adapt \\Cref{alg:confident-base/growing-attributes-trusted-objects} to compute a\nfinite base of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\nTo this end, we consider as input for\n\\Cref{alg:confident-base/growing-attributes-trusted-objects} the induced formal context\n$\\con K_{\\mathcal{J}}$, represented as the subposition of $\\con K_{\\mathcal{J}}\n\\restricted_{\\Delta^{\\mathcal{I}}}$ and $\\con K_{\\mathcal{J}}\n\\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}}$, where the common\nattribute set $M_{\\mathcal{I}}$ is computed incrementally as in\n\\Cref{alg:base-of-interpretation}.  The result is shown in\n\\Cref{alg:confident-base-gcis/trusted-objects}.  Note that in this algorithm we again\nutilize the idea of using\n\\begin{equation*}\n  \\mathcal{S}_{i+1} = \\set{ \\set{ C } \\to \\set{ D } \\mid C, D \\in M_{i+1}, C \\sqsubseteq D }\n\\end{equation*}\nas background knowledge, because the resulting set $\\bigsqcap \\mathcal{S}_{i+1}$ of GCIs\nis trivial, but the set $\\mathcal{S}_{i+1}$ of implications is not.\n\n\\addfunctionname{confident-base-gcis/trusted-elements}\n\n\\begin{figure}[tp]\n  \\begin{Algorithm} Axiomatize Confident GCIs in the Presence of Trusted Elements\n    \\hspace*{0cm}\n    \\label{alg:confident-base-gcis/trusted-objects}\n    \\begin{lstlisting}\ndefine confident-base-gcis/trusted-elements($\\mathcal{J}$, $\\mathcal{I}$, $c \\in [0,1]$)\n  $i$ := $0$\n  $M_i$ := $N_{C} \\cup \\set{ \\bot }$\n  $\\mathcal{S}_i$ := $\\set{ \\set{ \\bot } \\to \\set{ A } \\mid A \\in N_{C}}$\n  $P_i$ := $\\mathcal{K}_i$ := $\\emptyset$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n  \n  forever do\n    $M_{i+1}$ := $M_{i} \\cup \\set{ \\exists r. (\\bigsqcap P_{i})^{\\mathcal{J}\\mathcal{J}} \\mid r \\in N_{R} }$ ;; union up to equivalence $\\label{lst:confident-base-gcis-line-1}$\n    $\\con K_{i+1}$ := induced-context($\\mathcal{I}$, $M_{i+1}$)\n    $\\con L_{i+1}$ := induced-context($\\mathcal{J} \\setminus \\mathcal{I}$, $M_{i+1}$) $\\label{lst:confident-base-gcis-line-2}$\n    $\\mathcal{S}_{i+1}$ := $\\set{ \\set{ C } \\to \\set{ D } \\mid C, D \\in M_{i+1}, C\n\\sqsubseteq D }$.\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold}$\n\n    $\\mathcal{K}_{i+1}$ := $\\set{ P_k \\to P_k^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}'' \\mid k \\in \\set{0, \\ldots, i}, P_k \\neq P_k^{\\con K_{i+1}, c} \\cap P_{\\con L_{i+1}}''}$\n\n    $P_{i+1}^1$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\con K_{i+1} \\div \\con L_{i+1}$)\n    $P_{i+1}^2$ := next-closure($M_{i+1}$, $\\leq_{M_{i+1}}$, $P_i$, $\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1}$)\n\n    $P_{i+1}$ := $\\min\\nolimits_{\\preceq}(P_{i+1}^1, P_{i+1}^2)$.\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$\n  end\n\n  return $\\mathcal{K}_{i+1}$  \nend\n    \\end{lstlisting}\n  \\end{Algorithm}\n\\end{figure}\n\nTo see that \\Cref{alg:confident-base-gcis/trusted-objects} indeed computes a base of\n$\\Th_{c}(\\mathcal{J}, \\mathcal{I})$, we shall first argue that it is of the form of\n\\Cref{alg:confident-base/growing-attributes-trusted-objects}.  Thereafter, we shall show\nthat when \\Cref{alg:confident-base-gcis/trusted-objects} is applied to $\\mathcal{J}$,\n$\\mathcal{I}$, and $c \\in [0,1]$, and terminates after $n$ iterations, then $M_{n} =\nM_{\\mathcal{J}}$ up to equivalence.  Thus, by\n\\Cref{thm:confident-bases-with-growing-sets-of-attributes-and-trusted-objects}, the\nalgorithm computes a base $\\mathcal{K}_{n}$ of $\\Th_{c}(\\con K_{\\mathcal{J}}\n\\restricted_{\\Delta^{\\mathcal{I}}}) \\cap \\Th(\\con K_{\\mathcal{J}}\n\\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}})$, and then\n\\Cref{thm:bases-of-untrusted-interpretations-from-bases-of-contexts} yields that\n$\\bigsqcap \\mathcal{K}_{n}$ is a base of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\nTo argue that \\Cref{alg:confident-base-gcis/trusted-objects} is of the form of\n\\Cref{alg:confident-base/growing-attributes-trusted-objects} we need to show that the\nvariables $M_{i+1}, \\con K_{i+1}, \\con L_{i+1}, \\mathcal{S}_{i+1}$ computed in\n\\Cref{alg:confident-base-gcis/trusted-objects} satisfy the constraints given in\n\\Cref{alg:confident-base/growing-attributes-trusted-objects}.  However, this is quite\nclear from the definition of these variables: it is obvious that $M_{i} \\subseteq\nM_{i+1}$, and that the incidence relations of $\\con K_{i+1}$ and $\\con L_{i+1}$ restricted\nto $M_{i}$ are the incidence relations of $\\con K_{i}$ and $\\con L_{i}$, respectively.\nFurthermore, $\\mathcal{S}_{i+1} \\subseteq \\Th_{c}(\\con K_{i+1}) \\cap \\Th(\\con L_{i+1})$,\nbecause $\\mathcal{S}_{i+1}$ is even valid in $\\con K_{i+1} \\div \\con L_{i+1}$.\n\nNote that since $\\mathcal{J}$ is a finite interpretation, the set $M_{\\mathcal{J}}$ is\nfinite.  Since $M_{i} \\subseteq M_{\\mathcal{J}}$ holds for all iterations $i$, up to\nequivalence, it is true that from a certain iteration $\\ell$ on, $M_{\\ell} = M_{k}$ is\ntrue for all $k \\geq \\ell$.  Thus, \\Cref{alg:confident-base-gcis/trusted-objects}\nterminates on input $\\mathcal{J}$, $\\mathcal{I}$, and $c$.\n\nTo show that upon termination of \\Cref{alg:confident-base-gcis/trusted-objects}, $M_{n} =\nM_{\\mathcal{J}}$ is true up to equivalence, we start with the following result, which is\nan adaption of \\cite[Lemma~6.7]{Diss-Felix}.\n\n\\begin{Proposition}\n  \\label{prop:Felix-6.7-adapted}\n  Consider a terminating run of \\Cref{alg:confident-base-gcis/trusted-objects}, and let\n  $n$ be the number of iterations.  Then for every $U \\subseteq M_{n}$ and $r \\in N_{R}$\n  it is true that\n  \\begin{equation*}\n    \\exists r.(\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}} \\in M_{n}\n  \\end{equation*}\n  up to equivalence.\n\\end{Proposition}\n\\begin{Proof}\n  Note that because both $\\mathcal{I}$ and $\\mathcal{J} \\setminus \\mathcal{I}$ are\n  connected subinterpretations of $\\mathcal{J}$, \\Cref{lem:Felix-6.12} shows that $\\con\n  K_{n} \\div \\con L_{n}$ is indeed the induced context of $\\mathcal{J}$ and $M_{n}$.\n  Thus, we obtain from \\Cref{prop:connection-I-prime-2} that\n  \\begin{equation*}\n    (\\bigsqcap U_{\\con K_{n} \\div \\con L_{n}}'')^{\\mathcal{J}} = U_{\\con K_{n} \\div \\con\n      L_{n}}''' = U_{\\con K_{n} \\div \\con L_{n}}' = (\\bigsqcap U)^{\\mathcal{J}}.\n  \\end{equation*}\n  Therefore, it is true that\n  \\begin{equation*}\n    \\exists r. (\\bigsqcap U_{\\con K_{n} \\div \\con L_{n}}'')^{\\mathcal{J}\\mathcal{J}}\n    \\equiv \\exists r. (\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}}.\n  \\end{equation*}\n  Since \\Cref{alg:confident-base-gcis/trusted-objects} is a special case of\n  \\Cref{alg:confident-base/growing-attributes-trusted-objects},\n  \\Cref{prop:property-of-confident-bases-with-growing-sets-of-attributes} is also\n  applicable to \\Cref{alg:confident-base-gcis/trusted-objects}, and we thus obtain a $k\n  \\in \\set{ 0, \\dots, n }$ such that $U_{\\con K_{n} \\div \\con L_{n}}'' = P_{k}$.  Since\n  $\\exists r. (\\bigsqcap P_{k})^{\\mathcal{J}\\mathcal{J}} \\in M_{k+1} \\subseteq M_{n}$, we obtain\n  \\begin{equation*}\n    \\exists r. (\\bigsqcap U)^{\\mathcal{J}\\mathcal{J}} \\equiv \\exists r. (\\bigsqcap U_{\\con\n      K_{n} \\div \\con L_{n}}'')^{\\mathcal{J}\\mathcal{J}} \\equiv \\exists r. (\\bigsqcap\n    P_{k})^{\\mathcal{J}\\mathcal{J}} \\in M_{n},\n  \\end{equation*}\n  as desired.\n\\end{Proof}\n\nUsing this proposition, we shall now show the correctness of\n\\Cref{alg:confident-base-gcis/trusted-objects}.\n\n\\begin{Theorem}\n  \\label{thm:confident-base-gcis-trusted-objects-is-correct}\n  Let $\\mathcal{J}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let\n  $\\mathcal{I}$ be a connected subinterpretation of $\\mathcal{J}$ such that $\\mathcal{J}\n  \\setminus \\mathcal{I}$ is also a connected subinterpretation of $\\mathcal{J}$.  Let $c\n  \\in [0,1]$, and let $n$ be the number of iterations of\n  \\Cref{alg:confident-base-gcis/trusted-objects} when applied to $\\mathcal{J}$,\n  $\\mathcal{I}$, and $c \\in [0,1]$.  Then $\\bigsqcap \\mathcal{K}_{n}$ is a base of\n  $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$.\n\\end{Theorem}\n\nThe proof of this theorem, which is an adaption of the proofs of~\\cite[Lemma~6.8,\nTheorem~6.9]{Diss-Felix}, uses induction over the role depth of concept descriptions.\nSince $\\bigsqcap \\mathcal{K}_{n}$ may contain proper $\\ELgfpbot$ concept descriptions, it\nmay not be immediately obvious how this can be done, and we need an extra result that\nallows us to use this argumentation.\n\n\\begin{Lemma}[Lemma~5.6 from~\\cite{Diss-Felix}]\n  \\label{lem:Felix-5.6}\n  Let $\\mathcal{I}$ be a finite interpretation over $N_{C}$ and $N_{R}$, and let $C$ be an\n  $\\ELgfpbot$ concept description over $N_{C}$ and $N_{R}$.  Then there exists an $\\ELbot$\n  concept description over $N_{C}$ and $N_{R}$ such that\n  \\begin{equation*}\n    C^{\\mathcal{I}} = D^{\\mathcal{I}} \\quad\\text{and}\\quad C \\sqsubseteq D.\n  \\end{equation*}\n\\end{Lemma}\n\nWe now prove \\Cref{thm:confident-base-gcis-trusted-objects-is-correct}.\n\n\\begin{Proof}[\\Cref{thm:confident-base-gcis-trusted-objects-is-correct}]\n  We first show that $M_{n} = M_{\\mathcal{J}}$ is true up to equivalence, \\ie every\n  element of $M_{n}$ is equivalent to some element in $M_{\\mathcal{J}}$ and vice versa.\n  Since $M_{n} \\subseteq M_{\\mathcal{J}}$ up to equivalence by definition of $M_{n}$, it\n  suffices to show that every element of $M_{\\mathcal{J}}$ is equivalent to some element\n  in $M_{n}$.\n\n  To show that $M_{\\mathcal{J}} \\subseteq M_{n}$ holds up to equivalence, we shall show\n  that for each $r \\in N_{R}$ and $X \\subseteq \\Delta^{\\mathcal{J}}$ there exists $C \\in\n  M_{n}$ such that $C \\equiv \\exists r. X^{\\mathcal{J}}$.  To this end, we observe that by\n  \\Cref{lem:Felix-5.6} there exists an $\\ELbot$ concept description $D$ over $N_{C}$ and\n  $N_{R}$ such that\n  \\begin{equation*}\n    D^{\\mathcal{J}} = X^{\\mathcal{J}\\mathcal{J}}.\n  \\end{equation*}\n  Since $D^{\\mathcal{J}\\mathcal{J}} = X^{\\mathcal{J}\\mathcal{J}\\mathcal{J}} =\n  X^{\\mathcal{J}}$, it is sufficient to show that for each $\\ELbot$ concept description\n  $D$ and each $r \\in N_{R}$ it is true that\n  \\begin{equation*}\n    \\exists r. D^{\\mathcal{J}\\mathcal{J}} \\in M_{n}\n  \\end{equation*}\n  up to equivalence.  We shall show this claim by induction over the role-depth of $D$.\n\n  The \\textit{base case} is $D = \\bot$, or $D$ being a conjunction of concept names from\n  $N_{C}$.  The case $D = \\bot$ is trivial, as $\\exists r. \\bot^{\\mathcal{J}\\mathcal{J}}\n  \\equiv \\bot \\in M_{n}$ for all $r \\in N_{R}$.  If $D = \\bigsqcap S$ for some $S\n  \\subseteq N_{C}$, then since $S \\subseteq M_{n}$, \\Cref{prop:Felix-6.7-adapted} implies\n  for all $r \\in N_{R}$ that\n  \\begin{equation*}\n    \\exists r. D^{\\mathcal{J}\\mathcal{J}} = \\exists r. (\\bigsqcap\n    S)^{\\mathcal{J}\\mathcal{J}} \\in M_{n}\n  \\end{equation*}\n  up to equivalence.\n\n  For the \\textit{step case} let $D$ be an $\\ELbot$ concept description with role-depth $d\n  > 0$, and let $r \\in N_{R}$.  Assume by induction for all $\\ELbot$ concept descriptions\n  $E$ over $N_{C}$ and $N_{R}$ with role depth smaller than $d$ that\n  \\begin{equation}\n    \\label{eq:55}\n    \\exists s. E^{\\mathcal{J}\\mathcal{J}} \\in M_{n}\n  \\end{equation}\n  is true up to equivalence for all $s \\in N_{R}$.\n\n  Since $D$ is an $\\ELbot$ concept description, there exist $U \\subseteq N_{C}$, $r_{1},\n  \\dots, r_{k} \\in N_{R}$ and $E_{1}, \\dots, E_{k} \\in \\ELbot(N_{C}, N_{R})$ such that\n  \\begin{equation*}\n    D \\equiv \\bigsqcap U \\sqcap \\bigsqcap_{i=1}^{k} \\exists r_{i}. E_{i}.\n  \\end{equation*}\n  Then by \\Cref{prop:double-II-under-I}\n  \\begin{align*}\n    D^{\\mathcal{J}\\mathcal{J}}\n    &\\equiv \\bigl( \\bigsqcap U \\sqcap \\bigsqcap_{i=1}^{k} \\exists r_{i}. E_{i}\n    \\bigr)^{\\mathcal{J}\\mathcal{J}} \\\\\n    &\\equiv \\bigl( \\bigsqcap U \\sqcap \\bigsqcap_{i=1}^{k} \\exists\n    r_{i}. E_{i}^{\\mathcal{J}\\mathcal{J}} \\bigr)^{\\mathcal{J}\\mathcal{J}}.\n  \\end{align*}\n  By induction hypothesis \\Cref{eq:55}, $\\exists r_{i}. E_{i}^{\\mathcal{J}\\mathcal{J}} \\in\n  M_{n}$ up to equivalence, for all $i = 1, \\dots, k$.  But then\n  \\begin{equation*}\n    V := U \\cup \\set{ \\exists r_{i}. E_{i}^{\\mathcal{J}\\mathcal{J}} \\mid i = 1, \\dots, k }\n    \\subseteq M_{n},\n  \\end{equation*}\n  and \\Cref{prop:Felix-6.7-adapted} implies that\n  \\begin{equation*}\n    \\exists r. D^{\\mathcal{J}\\mathcal{J}} \\equiv \\exists r. (\\bigsqcap\n    V)^{\\mathcal{J}\\mathcal{J}} \\in M_{n}\n  \\end{equation*}\n  up to equivalence.  This completes the induction step and shows that $M_{\\mathcal{J}} =\n  M_{n}$ holds up to equivalence.\n\n  By \\Cref{thm:confident-bases-with-growing-sets-of-attributes-and-trusted-objects} we\n  know that $\\mathcal{K}_{n}$ is a base of\n  \\begin{equation*}\n    \\Th_{c}(\\con K_{n}) \\cap \\Th(\\con L_{n})\n  \\end{equation*}\n  with background knowledge $\\mathcal{S}_{n} = \\set{ \\set{ C } \\to \\set{ D } \\mid C, D \\in\n    M_{n}, C \\sqsubseteq D }$.  Since $M_{n} = M_{\\mathcal{J}}$ up to equivalence,\n  $\\mathcal{K}_{n}$ is, up to equivalence, also a base of\n  \\begin{equation*}\n    \\Th_{c}(\\con K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{I}}}) \\cap \\Th(\\con\n    K_{\\mathcal{J}} \\restricted_{\\Delta^{\\mathcal{J}} \\setminus \\Delta^{\\mathcal{I}}})\n  \\end{equation*}\n  with background knowledge $\\mathcal{S}_{n}$.  By\n  \\Cref{thm:bases-of-untrusted-interpretations-from-bases-of-contexts}, $\\bigsqcap\n  (\\mathcal{K}_{n} \\cup \\mathcal{S}_{n})$ is a base of $\\Th_{c}(\\mathcal{J},\n  \\mathcal{I})$, and since $\\bigsqcap (\\mathcal{K}_{n} \\cup \\mathcal{S}_{n})$ is\n  element-wise equivalent to $\\bigsqcap \\mathcal{K}_{n}$, we obtain that $\\bigsqcap\n  \\mathcal{K}_{n}$ is a base of $\\Th_{c}(\\mathcal{J}, \\mathcal{I})$, as required.\n\\end{Proof}\n\n\\subsection{Exploring Confident GCIs with Expert Interaction}\n\\label{sec:expl-conf-gcis-1}\n\nWe are now prepared to devise an algorithm for model exploration by confidence.  We shall\nachieve this by replacing in \\Cref{alg:confident-base-gcis/trusted-objects} every explicit\naccess to the interpretation $\\mathcal{J}$ by suitable expert interaction.  Recall that we\nwant to do this because we now consider $\\mathcal{J}$ as the background interpretation of\nthe exploration process, which we cannot access directly.\n\nTo conduct this adaption of \\Cref{alg:confident-base-gcis/trusted-objects}, we observe\nthat there are two lines in this algorithm where $\\mathcal{J}$ is accessed directly,\nnamely\n\\begin{enumerate}[i. ]\n\\item\\label{item:21} in the computation of $M_{i+1}$\n  (line~\\ref{lst:confident-base-gcis-line-1}), more precisely in the computation of the\n  concept description $\\exists r.(\\bigsqcap P_{i})^{\\mathcal{J}\\mathcal{J}}$, and\n\\item\\label{item:22} in the computation of the formal context $\\con L_{i+1}$\n  (line~\\ref{lst:confident-base-gcis-line-2}) as the induced context of $\\mathcal{J}\n  \\setminus \\mathcal{I}$ and $M_{i+1}$.\n\\end{enumerate}\n\nFor (\\ref{item:21}) we can argue as in \\Cref{sec:an-algor-expl}, using\n\\Cref{lem:Felix-6.14}: if $\\mathcal{I}_{\\ell}$ denotes the current working interpretation,\nwhich is a connected subinterpretation of the background interpretation $\\mathcal{J}$,\nthen if the expert confirms the GCI\n\\begin{equation*}\n  \\bigsqcap P_{i} \\sqsubseteq (\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}},\n\\end{equation*}\nthen $(\\bigsqcap P_{i})^{\\mathcal{I}_{\\ell}\\mathcal{I}_{\\ell}} \\equiv (\\bigsqcap\nP_{i})^{\\mathcal{J}\\mathcal{J}}$ is true.\n\nHandling (\\ref{item:22}) is a bit more problematic, though.  A first approach would be to\ncompute $\\con L_{i+1}$ as the induced context of $\\mathcal{I}_{\\ell} \\setminus\n\\mathcal{I}$ and $M_{i+1}$, where $\\mathcal{I}_{\\ell}$ is the current working\ninterpretation.  This approach, however, does not work completely: the formal context\n$\\bar{\\con L}_{i+1}$ is used for the computation of the next candidate set $P_{i+1}^{1}$.\nAs such, we need to ensure that all objects from $\\con L_{i+1}$ which are\n\\enquote{relevant} for this computation are contained in $\\bar{\\con L}_{i+1}$.  The\nproblem is that those objects are not necessarily counterexamples to GCIs proposed to the\nexpert so far, and thus they may not be contained in $\\mathcal{I}_{\\ell}$.  Thus, we may\nneed to query the expert again to provide those missing objects.\n\nLet us consider this in more detail: we observe that the computation of $P_{i+1}^{1}$ in\nour hypothetical adaption of \\Cref{alg:confident-base-gcis/trusted-objects} would\n\\emph{not} be correct if the lectically next intent after $P_{i}$ of the current working\ncontext $\\con K_{i+1} \\div \\con L_{i+1}$ in \\Cref{alg:confident-base-gcis/trusted-objects}\nis not an intent of the working context of $\\con K_{i+1} \\div \\bar{\\con L}_{i+1}$.  In\nother words\n\\begin{align*}\n  P_{i+1}^{1} &= (P_{i+1}^{1})_{\\con K_{i+1} \\div \\con L_{i+1}}''\\\\\n  P_{i+1}^{1} &\\neq (P_{i+1}^{1})_{\\con K_{i+1} \\div \\bar{\\con L}_{i+1}}''.\n\\end{align*}\nIf $\\bar{\\mathcal{S}}_{i+1}$ denotes the currently known implications and\n$\\bar{\\mathcal{K}}_{i+1}$ the currently confirmed implications in our hypothetical\nadaption, then we know that $\\bar{\\mathcal{S}}_{i+1} \\cup \\bar{\\mathcal{K}}_{i+1}$ is\nvalid in $\\bar{\\con L}_{i+1}$, and from this we obtain\n\\begin{align*}\n  (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1})\n  &= (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1})_{\\con L_{i+1}}''\\\\\n  (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1})\n  &\\neq (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1})_{\\bar{\\con L}_{i+1}}''.\n\\end{align*}\nTherefore, the implication\n\\begin{equation*}\n  (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1}) \\to\n  (\\mathcal{S}_{i+1} \\cup \\mathcal{K}_{i+1})(P_{i+1}^{1})_{\\bar{\\con L}_{i+1}}''\n\\end{equation*}\nmust be rejected by the expert, because it does not hold in $\\con L_{i+1}$, and upon\nrejection all necessary counterexamples are added to $\\bar{\\con L}_{i+1}$.  Thus, if we\nask all implications, or their corresponding GCIs, we can ensure that the computation of\nthe set $P_{i+1}^{1}$ is done as required in\n\\Cref{alg:confident-base-gcis/trusted-objects}.\n\n\\addfunctionname{model-exploration-by-confidence}\n\n\\begin{figure}[tp]\n  \\thisfloatpagestyle{empty}\n  \\vspace*{-\\headheight}\n  \\vspace*{-\\headsep}\n  \\begin{Algorithm}\n    \\label{alg:model-exploration-by-confidence} Model Exploration by Confidence\n    \\begin{lstlisting}\ndefine model-exploration-by-confidence($\\mathcal{I}$, $c$)\n  $i$ := $\\ell$ := $0$\n  $\\mathcal{I}_\\ell$ := $\\mathcal{I}$\n  $\\bar P_i$ := $\\bar{\\mathcal{K}}_i$ := $\\emptyset$\n  $\\bar M_i$ := $N_{C} \\cup \\set{ \\bot }$\n  $\\bar{\\mathcal{S}}_i$ := $\\set{ \\set{ \\bot } \\to \\set{ A } \\mid A \\in N_{C} }$\n  choose ${\\leq_{M_{i}}} \\text{ as a linear order on } M_{i}$\n\n  forever do\n    while $\\text{expert rejects } \\bigsqcap \\bar P_i \\sqsubseteq (\\bigsqcap \\bar P_i) ^{\\mathcal{I}_\\ell\\mathcal{I}_\\ell}$ do\n      $\\mathcal{I}_{\\ell + 1}$ := $\\text{expert-defined extension of } \\mathcal{I}_\\ell$\n      $\\ell$ := $\\ell$ + 1\n    end\n\n    $\\bar M_{i+1}$ := $\\bar M_i \\cup \\set{ \\exists r. (\\bigsqcap P_i)^{\\mathcal{I}_\\ell\\mathcal{I}_\\ell} \\mid r \\in N_R}$ ;; union up to equivalence $\\label{item:23}$\n    choose ${\\leq_{M_{i+1}}} \\text{ such that (\\ref{eq:48}) and (\\ref{eq:49}) hold}$\n\n    ;; ensure relevant counterexamples for already known GCIs\n    while $\\text{expert rejects } \\bigsqcap \\bar P_k \\sqsubseteq \\bigsqcap ( \\bar P_k^{\\con K_{\\mathcal{I}, \\bar M_{i+1}}, c} \\cap (\\bar P_k)^{\\prime\\prime_{\\con K_{\\mathcal{I}_\\ell \\setminus \\mathcal{I}, \\bar M_{i+1}}}}) \\text{ for some } k \\in \\set{ 0, \\dots, n }\\label{item:26}$ do\n      $\\mathcal{I}_{\\ell+1}$ := $\\text{expert-defined extension of } \\mathcal{I}_\\ell$\n      $\\ell$ := $\\ell$ + 1\n    end\n\n    $\\bar{\\con K}_{i+1}$ := induced-context($\\mathcal{I}$, $\\bar M_{i+1}$)$\\label{item:24}$\n    $\\bar{\\con L}_{i+1}$ := induced-context($\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}$, $\\bar M_{i+1}$)  \n    $\\bar{\\mathcal{S}}_{i+1}$ := $\\set{ \\set{C} \\to \\set{D} \\mid C, D \\in \\bar M_{i+1}, C \\sqsubseteq D }$\n\n    $\\bar{\\mathcal{K}}_{i+1}$ := $\\set{ \\bar P_k \\to \\bar P_k^{\\bar{\\con K}_{i+1}, c} \\cap\n      (\\bar P_k)^{\\prime\\prime_{\\bar{\\con L}_{i+1}}} \\mid k \\in \\set{0, \\ldots, i}, \\bar P_k \\neq\n      \\bar P_k^{\\bar{\\con K}_{i+1}, c} \\cap (\\bar P_k)^{\\prime\\prime_{\\bar{\\con L}_{i+1}}} }$\n\n    ;; additional expert interaction $\\label{item:25}$\n    forall $Q \\succeq P$ being $(\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})\\text{-closed}$ do $\\label{ask-many-1}$\n      while $\\text{expert rejects } \\bigsqcap Q \\sqsubseteq \\bigsqcap Q^{\\prime\\prime_{\\bar{\\con L}_{i+1}}}$ do\n        $\\mathcal{I}_{\\ell+1}$ := $\\text{expert-defined extension of } \\mathcal{I}_\\ell$\n        $\\ell$ := $\\ell$ + 1\n        $\\bar{\\con L}_{i+1}$ := induced-context($\\mathcal{I}_\\ell \\setminus \\mathcal{I}$, $\\bar M_{i+1}$)\n      end\n    end $\\label{ask-many-2}$\n\n    $\\bar P_{i+1}^1$ := next-closure($\\bar M_{i+1}$, $\\leq_{M_{i+1}}$, $\\bar P_i$, ${\\bar{\\con K}_{i+1}} \\div {\\bar{\\con L}_{i+1}}$)\n    $\\bar P_{i+1}^2$ := next-closure($\\bar M_{i+1}$, $\\leq_{M_{i+1}}$, $\\bar P_i$, $\\bar{\\mathcal{S}}_{i+1} \\cup \\bar{\\mathcal{K}}_{i+1}$)\n\n    $P_{i+1}$ := $\\min\\nolimits_{\\preceq}(P_{i+1}^1, P_{i+1}^2)$.\n    if $P_{i+1} =$ nil exit\n\n    $i$ := $i + 1$\n  end\n\n  return $\\bigsqcap \\bar{\\mathcal{K}}_{i+1}$\nend\n    \\end{lstlisting}\n  \\end{Algorithm}\n\\end{figure}\n\nLet us make this argumentation more concrete, and consider\n\\Cref{alg:model-exploration-by-confidence} as an adaption of\n\\Cref{alg:confident-base-gcis/trusted-objects} to provide an algorithm for model\nexploration by confidence.  Observe that in \\Cref{alg:model-exploration-by-confidence}, as\nin \\Cref{alg:model-exploration}, counterexamples collected into the current working\ninterpretation $\\mathcal{I}_{\\ell}$ are supposed to be connected subinterpretations of the\nbackground interpretation.  Furthermore, since required by\n\\Cref{thm:confident-base-gcis-trusted-objects-is-correct}, we also need to ensure that\n$\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}$ is a connected subinterpretation of\n$\\mathcal{I}_{\\ell}$, \\ie the expert is not allowed to add role-successors from elements\nof $\\mathcal{I}_{\\ell} \\setminus \\mathcal{I}$ to elements of $\\mathcal{I}$ when adding\ncounterexamples.  These constraints are supposed to be satisfied in every line of the form\n\\begin{equation*}\n  \\mathcal{I}_{\\ell+1} := \\text{expert-defined extension of } \\mathcal{I}_\\ell.\n\\end{equation*}\n\nTo prove that \\Cref{alg:model-exploration-by-confidence} indeed provides an algorithm for\nmodel exploration, we shall show that this algorithm computes, when applied to\n$\\mathcal{I}$ and using an expert that represents a background interpretation\n$\\mathcal{I}_{\\mathsf{back}}$, up to equivalence the same intermediate values as\n\\Cref{alg:confident-base-gcis/trusted-objects} when directly applied to $\\mathcal{I}$ and\n$\\mathcal{I}_{\\mathsf{back}}$.  Then, since \\Cref{alg:confident-base-gcis/trusted-objects}\nterminates, \\Cref{alg:model-exploration-by-confidence} will also terminate and returns a\nbase of $\\Th_{c}(\\mathcal{I}_{\\mathsf{back}}, \\mathcal{I})$.\n\n\\begin{Theorem}\n  \\label{thm:model-exploration-by-confidence}\n  Let $\\mathcal{I}_{\\mathsf{back}}$ be a finite interpretation over $N_{C}$ and $N_{R}$,\n  and let $\\mathcal{I}$ be a connected subinterpretation of $\\mathcal{I}_{\\mathsf{back}}$\n  such that $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$ is also a connected\n  subinterpretation of $\\mathcal{I}_{\\mathsf{back}}$.  Let $c \\in [0,1]$.\n\n  Then \\Cref{alg:model-exploration-by-confidence} applied to $\\mathcal{I}$, $c$ and using\n  an expert that represents $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$\n  terminates.  If $n$ is the number of iterations of this run, then $\\bigsqcap\n  \\bar{\\mathcal{K}}_{n}$ is a base of $\\Th_{c}(\\mathcal{I}_{\\mathsf{back}}, \\mathcal{I}) =\n  \\Th_{c}(\\mathcal{I}) \\cap \\Th(\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I})$.\n\\end{Theorem}\n\\begin{Proof}\n  We show that \\Cref{alg:model-exploration-by-confidence} with the input\n  $\\mathcal{I}_{\\mathsf{back}}$, $\\mathcal{I}$ and $c$ has the same output as\n  \\Cref{alg:confident-base-gcis/trusted-objects}.  Then the claim follows from\n  \\Cref{thm:confident-base-gcis-trusted-objects-is-correct}.\n\n  To this end, we shall show that for all $i \\in \\set{ 0, \\dots, n }$ it is true that\n  $\\bar P_{i} = P_{i}, \\bar M_{i} = M_{i}, \\bar{\\mathcal{K}}_{i} = \\mathcal{K}$ and\n  $\\bar{\\mathcal{S}}_{i} = \\mathcal{S}_{i}$ is true up to equivalence.  In other words, we\n  shall show that every element of $\\bar P_{i}$ is equivalent to some element in $P_{i}$,\n  and vice versa; likewise for $\\bar M_{i}$ and $M_{i}$.  Furthermore, we shall show that\n  for each implication $(\\bar A \\to \\bar B) \\in \\bar{\\mathcal{K}}_{i}$ there exists an\n  implication $(A \\to B) \\in \\mathcal{K}_{i}$ such that $\\bar A = A$ and $\\bar B = B$ is\n  true up to equivalence, and vice versa; likewise for $\\bar{\\mathcal{S}}_{i}$ and\n  $\\mathcal{S}_{i}$.\n\n  We shall show these claims by induction over $i$.\n\n  In the following argumentation, we shall not mention the linear orders we choose on the\n  sets $\\bar M_{i+1}$ and $M_{i+1}$ explicitly.  However, we shall\n  choose the linear orders $\\leq_{\\bar M_{i+1}}$ and $\\leq_{M_{i+1}}$ on $\\bar M_{i+1}$\n  and $M_{i+1}$ such that\n  \\begin{equation*}\n    \\bar C \\leq_{\\bar M_{i+1}} \\bar D \\iff C \\leq_{M_{i+1}} D\n  \\end{equation*}\n  for $\\bar C, \\bar D \\in \\bar M_{i+1}, C, D \\in M_{i+1}$ and $\\bar C \\equiv C, \\bar D\n  \\equiv D$.\n\n  \\textit{Base Case: }  For $i = 0$, it is true that $\\bar P_{i} = \\emptyset = P_{i}$,\n  $\\bar M_{i} = N_{C} \\cup \\set{ \\bot } = M_{i}$, $\\bar{\\mathcal{K}}_{i} = \\emptyset =\n  \\mathcal{K}_{i}$ and $\\bar{\\mathcal{S}}_{i} = \\set{ \\set{ \\bot } \\to \\set{ A } \\mid A\n    \\in N_{C} } = \\mathcal{S}_{i}$.  Thus, the claim holds for $i = 0$.\n\n  \\textit{Step Case: } Let us assume that $0 < i < n$ and that the claim holds for all $m\n  \\leq i$.\n\n  Denote with $\\mathcal{I}_{l}$ the current working interpretation when the algorithm has\n  reached line~\\ref{item:23}.  The algorithm can only reach this line if the expert has\n  confirmed $\\bigsqcap \\bar P_{i} \\sqsubseteq (\\bigsqcap \\bar\n  P_{i})^{\\mathcal{I}_{l}\\mathcal{I}_{l}}$.  Since $\\mathcal{I}_{l}$ is a connected\n  subinterpretation of $\\mathcal{I}_{\\mathsf{back}}$, \\Cref{lem:Felix-6.14} implies that\n  $(\\bigsqcap \\bar P_{i})^{\\mathcal{I}_{l}\\mathcal{I}_{l}} = (\\bigsqcap \\bar\n  P_{i})^{\\mathcal{I}_{\\mathsf{back}}\\mathcal{I}_{\\mathsf{back}}}$.  Since $\\bar M_{i} =\n  M_{i}$ holds up to equivalence by induction hypothesis, it is true that $\\bar M_{i+1} =\n  M_{i+1}$ up to equivalence.  This also implies $\\bar{\\mathcal{S}}_{i} = \\mathcal{S}_{i}$\n  up to equivalence, since the definition of these sets only depends on $\\bar M_{i+1}$ and\n  $M_{i}$, respectively.\n\n  To show $\\bar{\\mathcal{K}}_{i} = \\mathcal{K}$, it is sufficient to verify that\n  \\begin{equation}\n    \\label{eq:56}\n    \\bar P_{k}^{\\bar{\\con K}_{i+1}, c} \\cap (\\bar P_{k})_{\\bar{\\con L}_{i+1}}'' =\n    P_{k}^{\\con K_{i+1}, c} \\cap (P_{k})_{\\con L_{i+1}}''\n  \\end{equation}\n  is true up to equivalence for all $k \\in \\set{ 0, \\dots, i }$.  To this end, we first\n  observe that $\\bar{\\con K}_{i+1}$ is the induced context of $\\mathcal{I}$ and $\\bar\n  M_{i+1}$, and $\\con K_{i+1}$ is the induced context of $\\mathcal{I}$ and $M_{i+1}$.  In\n  particular, since $\\bar M_{i+1} = M_{i+1}$ and $\\bar P_{k} = P_{k}$ up to equivalence\n  for all $0 \\leq k \\leq i$, we obtain\n  \\begin{equation*}\n    \\bar P_{k}^{\\bar{\\con K}_{i+1}, c} = P_{k}^{\\con K_{i+1}, c}\n  \\end{equation*}\n  up to equivalence for all $k \\in \\set{ 0, \\dots, i }$.\n\n  Let $\\mathcal{I}_{m}$ be the current working interpretation in iteration $i$ when\n  line~\\ref{item:24} is reached.  Recall that $\\bar{\\con L}_{i+1}$ is the induced context\n  of $\\mathcal{I}_{m} \\setminus \\mathcal{I}$ and $\\bar M_{i+1}$, and that $\\con L_{i+1}$\n  is the induced context of $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$ and\n  $M_{i+1}$.  Since $\\mathcal{I}_{m} \\setminus \\mathcal{I}$ is a connected\n  subinterpretation of $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$, we can\n  consider $\\bar{\\con L}_{i+1}$ as a subcontext of $\\con L_{i+1}$, and thus obtain\n  \\begin{equation*}\n    (\\bar P_{k})_{\\bar{\\con L}_{i+1}}'' \\supseteq (P_{k})_{\\con L_{i+1}}''\n  \\end{equation*}\n  up to equivalence for all $k \\in \\set{ 0, \\dots, i }$.\n\n  Assume now by contradiction that\n  \\begin{equation*}\n    \\bar P_{k}^{\\bar{\\con K}_{i+1}, c} \\cap (\\bar P_{k})_{\\con L_{i+1}}'' \\neq\n    P_{k}^{\\con K_{i+1}, c} \\cap (P_{k})_{\\con L_{i+1}}''\n  \\end{equation*}\n  is true for some $k \\in \\set{ 0, \\dots, i }$.  By the above considerations, this means\n  that there exists a concept description $\\bar C \\in \\bar P_{k}^{\\bar{\\con K}_{i+1}, c}\n  \\cap (\\bar P_{k})_{\\bar{\\con L}_{i+1}}''$ that is not equivalent to any element in\n  $P_{k}^{\\con K_{i+1}, c} \\cap (P_{k})_{\\con L_{i+1}}''$.  Then\n  \\begin{enumerate}[i. ]\n  \\item the expert has confirmed the implication\n    \\begin{equation*}\n      \\bigsqcap \\bar P_{k} \\sqsubseteq \\bigsqcap \\bar P_{k}^{\\bar{\\con K}_{i+1}, c} \\cap\n      (\\bar P_{k})_{\\bar{\\con L}_{i+1}}''\n    \\end{equation*}\n    since it was proposed to her in line~\\ref{item:26}.  In particular, the GCI $\\bigsqcap\n    \\bar P_{k} \\sqsubseteq \\bar C$ is valid in $\\mathcal{I}_{\\mathsf{back}} \\setminus\n    \\mathcal{I}$.\n  \\item The GCI $\\bigsqcap P_{k} \\sqsubseteq \\bar C$ is not confirmed by the expert.  To\n    see this, observe that since $\\bar C \\in M_{i+1}$, there exists $C \\in M_{i+1}$ such\n    that $\\bar C \\equiv C$.  Then if $\\bigsqcap P_{k} \\sqsubseteq \\bar C$ were confirmed\n    by the expert, it would be true that $C \\in (P_{k})_{\\con L_{i+1}}''$.  Furthermore,\n    it is true that $\\conf_{\\bar{\\con K}_{i+1}}(\\bar P_{k} \\to \\set{ \\bar C }) =\n    \\conf_{\\con K_{i+1}}(P_{k} \\to \\set{ C })$ because of $\\bar P_{k} = P_{k}, \\bar\n    M_{i+1} = M_{i+1}$ up to equivalence, and $\\bar C \\equiv C$.  Since $\\bar C \\in \\bar\n    P_{k}^{\\bar{\\con K}_{i+1}, c}$, it is true that $\\conf_{\\bar{\\con K}_{i+1}}(\\bar P_{k}\n    \\to \\set{ \\bar C }) \\ge c$, and thus $\\conf_{\\con K_{i+1}}(P_{k} \\to \\set{ C }) \\ge\n    c$, and hence $C \\in P_{k}^{\\con K_{i+1}, c}$.  Thus, we obtain\n    \\begin{equation*}\n      \\bar C \\equiv C \\quad\\text{and}\\quad C \\in P_{k}^{\\con K_{i+1}, c} \\cap\n      (P_{k})_{\\con L_{i+1}}'',\n    \\end{equation*}\n    contradicting our choice of $\\bar C$.  Therefore, $\\bigsqcap P_{k} \\sqsubseteq \\bar C$\n    is not confirmed by the expert, and in particular is not valid in\n    $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$.\n  \\end{enumerate}\n  However, since $\\bar P_{k} = P_{k}$ up to equivalence, the fact that $\\bigsqcap \\bar\n  P_{k} \\sqsubseteq \\bar C$ is valid in $\\mathcal{I}_{\\mathsf{back}} \\setminus\n  \\mathcal{I}$ but $\\bigsqcap P_{k} \\sqsubseteq \\bar C$ is not, yields the desired\n  contradiction.  Therefore, we have established the validity of \\Cref{eq:56}, and thus\n  can infer that $\\bar{\\mathcal{K}}_{k} = \\mathcal{K}_{k}$ is true up to equivalence.\n\n  It remains to be shown that\n  \\begin{equation}\n    \\label{eq:57}\n    \\bar P_{i+1} = P_{i+1}\n  \\end{equation}\n  is true up to equivalence.  To this end, we observe that $\\bar P_{i+1}^{2} =\n  P_{i+1}^{2}$ is true up to equivalence, since $\\bar P_{i} = P_{i}$ and\n  $\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1} = \\mathcal{K}_{i+1} \\cup\n  \\mathcal{S}_{i+1}$ up to equivalence, and the linear orders on $\\bar M_{i+1}$ and\n  $M_{i}$ are chosen suitably.  Thus, to show \\Cref{eq:57} it suffices to verify that\n  \\begin{equation}\n    \\label{eq:58}\n    \\bar P_{i+1}^{1} = P_{i+1}^{1}.\n  \\end{equation}\n  For this recall that the formal contexts $\\bar{\\con K}_{i+1}$ and $\\con K_{i+1}$ can be\n  considered the same, because $\\bar M_{i+1} = M_{i+1}$ up to equivalence.  Also recall\n  that we can consider $\\bar{\\con L}_{i+1}$ as a subcontext of $\\con L_{i+1}$, again up to\n  equivalence.  Therefore, we obtain $\\bar P_{i+1}^{1} \\succeq P_{i+1}^{1}$ up to\n  equivalence.\n\n  Suppose by contradiction that $\\bar P_{i+1}^{1} \\succneq P_{i+1}^{1}$.  Then\n  $P_{i+1}^{1}$, viewed as a subset of $\\bar M_{i+1}$, is not an intent of $\\bar{\\con\n    K}_{i+1} \\div \\bar{\\con L}_{i+1}$, as otherwise $\\bar P_{i+1}^{1} \\preceq\n  P_{i+1}^{1}$.  Since $P_{i+1}^{1}$ is an intent of $\\con K_{i+1} \\div \\con L_{i+1}$, we\n  can thus infer that\n  \\begin{equation*}\n    (P_{i+1}^{1})_{\\bar{\\con L}_{i+1}}'' \\setminus (P_{i+1}^{1})_{\\con L_{i+1}}'' \\neq \\emptyset.\n  \\end{equation*}\n  Let $D \\in (P_{i+1}^{1})_{\\bar{\\con L}_{i+1}}'' \\setminus (P_{i+1}^{1})_{\\con\n    L_{i+1}}''$.  Since $\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1}$ is sound\n  for $\\con L_{i+1}$ up to equivalence, we obtain that\n  \\begin{equation*}\n    ((\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\con L_{i+1}}''\n    = (P_{i+1}^{1})_{\\con L_{i+1}}''\n  \\end{equation*}\n  and thus\n  \\begin{equation*}\n    D \\not\\in ((\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\con L_{i+1}}''.\n  \\end{equation*}\n  Therefore, the corresponding implication\n  \\begin{equation*}\n    (\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1})\n    \\to ((\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\bar{\\con L}_{i+1}}''\n  \\end{equation*}\n  does not hold in $\\con L_{i+1}$, because\n  \\begin{equation*}\n    ((\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\bar{\\con L}_{i+1}}''\n    \\not\\subseteq ((\\bar{\\mathcal{K}}_{i+1} \\cup\n    \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\con L_{i+1}}''.\n  \\end{equation*}\n  Therefore, the corresponding GCI\n  \\begin{equation}\n    \\label{eq:59}\n    \\bigsqcap(\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1})\n    \\sqsubseteq \\bigsqcap ((\\bar{\\mathcal{K}}_{i+1} \\cup\n    \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}))_{\\bar{\\con L}_{i+1}}''\n  \\end{equation}\n  will be rejected by the expert, since $\\con L_{i+1}$ is the induced context of\n  $\\mathcal{I}_{\\mathsf{back}} \\setminus \\mathcal{I}$.\n\n  However, when computing $P_{i+1}^{1}$, we have passed the lines~\\ref{ask-many-1} up\n  to~\\ref{ask-many-2}, and the expert has confirmed the GCI given in\n  \\Cref{eq:59}. Therefore, our initial assumption that $\\bar P_{i+1}^{1} \\succneq\n  P_{i+1}^{1}$ is not true, and thus we obtain $\\bar P_{i+1}^{1} = P_{i+1}^{1}$ up to\n  equivalence.  This finishes the proof.\n\\end{Proof}\n\n% Note that in the proof we have\n% \\begin{equation*}\n%   (\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1})(P_{i+1}^{1}) = P_{i+1}^{1},\n% \\end{equation*}\n% since $P_{i+1}^{1}$ is an intent of $\\con K_{i+1} \\div \\con L_{i+1}$ and\n% $\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1}$ is sound for $\\con K_{i+1} \\cup\n% \\con L_{i+1}$ up to equivalence.  Therefore, it suffices in line~\\ref{ask-many-1} in\n% \\Cref{alg:model-exploration-by-confidence} to ask only those GCIs\n% \\begin{equation*}\n%   \\bigsqcap Q \\sqsubseteq \\bigsqcap Q_{\\bar{\\con L}_{i+1}}''\n% \\end{equation*}\n% where $Q$ is $\\bar{\\mathcal{K}}_{i+1} \\cup \\bar{\\mathcal{S}}_{i+1}$-closed and $Q$ is\n% lectically smaller or equal to the smallest intent of $\\bar{\\con K}_{i+1} \\div \\bar{\\con\n%   L}_{i+1}$, which is greater or equal to $\\bar P_{i}$.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../main\"\n%%% End: \n\n%  LocalWords:  gcis\n", "meta": {"hexsha": "13f38d4e5e6f84994af0b753ed9eb7ae21f68755", "size": 106652, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/model-exploration-by-confidence.tex", "max_stars_repo_name": "exot/thesis", "max_stars_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/model-exploration-by-confidence.tex", "max_issues_repo_name": "exot/thesis", "max_issues_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/model-exploration-by-confidence.tex", "max_forks_repo_name": "exot/thesis", "max_forks_repo_head_hexsha": "5cda9bc3011e0c5697b8a5aede9525d0001058ca", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.5939698492, "max_line_length": 284, "alphanum_fraction": 0.6645069947, "num_tokens": 38328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786991753929, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.42276111885526063}}
{"text": "\\documentclass[a4paper,10pt, notitlepage]{report}\n\\usepackage{geometry}\n\\geometry{verbose,tmargin=30mm,bmargin=25mm,lmargin=25mm,rmargin=25mm}\n\\usepackage[utf8]{inputenc}\n\\usepackage[sectionbib]{natbib}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{enumitem}\n\\usepackage{xcolor}\n\\usepackage{cancel}\n\\usepackage{mathtools}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\PassOptionsToPackage{hyphens}{url}\\usepackage{hyperref}\n\\hypersetup{colorlinks=true,citecolor=blue}\n\n\n\\newtheorem{thm}{Theorem}\n\\newtheorem{lemma}[thm]{Lemma}\n\\newtheorem{proposition}[thm]{Proposition}\n\\newtheorem{remark}[thm]{Remark}\n\\newtheorem{defn}[thm]{Definition}\n\n%%%%%%%%%%%%%%%%%%%% Notation stuff\n\\newcommand{\\pr}{\\operatorname{Pr}} %% probability\n\\newcommand{\\vr}{\\operatorname{Var}} %% variance\n\\newcommand{\\rs}{X_1, X_2, \\ldots, X_n} %%  random sample\n\\newcommand{\\irs}{X_1, X_2, \\ldots} %% infinite random sample\n\\newcommand{\\rsd}{x_1, x_2, \\ldots, x_n} %%  random sample, realised\n\\newcommand{\\bX}{\\boldsymbol{X}} %%  random sample, contracted form (bold)\n\\newcommand{\\bx}{\\boldsymbol{x}} %%  random sample, realised, contracted form (bold)\n\\newcommand{\\bT}{\\boldsymbol{T}} %%  Statistic, vector form (bold)\n\\newcommand{\\bt}{\\boldsymbol{t}} %%  Statistic, realised, vector form (bold)\n\\newcommand{\\emv}{\\hat{\\theta}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n% Title Page\n\\title{Exam 2 (A2)}\n\\author{Class: Bayesian Statistics \\\\ Instructor: Luiz Max Carvalho}\n\\date{02/06/2021}\n\n\\begin{document}\n\\maketitle\n\n\\textbf{Turn in date: until 16/06/2021 at 23:59h Brasilia Time.}\n\n\\begin{center}\n\\fbox{\\fbox{\\parbox{1.0\\textwidth}{\\textsf{\n    \\begin{itemize}\n    \\item Please read through the whole exam before starting to answer;\n    \\item State and prove all non-trivial mathematical results necessary to substantiate your arguments;\n    \\item Do not forget to add appropriate scholarly references~\\textit{at the end} of the document;\n    \\item Mathematical expressions also receive punctuation;\n    \\item You can write your answer to a question as a point-by-point response or in ``essay'' form, your call;\n    \\item Please hand in a single, \\textbf{typeset} ( \\LaTeX) PDF file as your final main document.\n Code appendices are welcome,~\\textit{in addition} to the main PDF document.\n    \\item You may consult any sources, provided you cite \\textbf{ALL} of your sources (books, papers, blog posts, videos);\n    \\item You may use symbolic algebra programs such as Sympy or Wolfram Alpha to help you get through the hairier calculations, provided you cite the tools you have used.\n    \\item The exam is worth 100 %$\\min\\left\\{\\text{your\\:score}, 100\\right\\}$\n    marks.\n    \\end{itemize}}\n}}}\n\\end{center}\n% \\newpage\n% \\section*{Hints}\n% \\begin{itemize}\n%  \\item a\n%  \\item b\n% \\end{itemize}\n% \n\\newpage\n\n\\section*{Background}\n\nThis exam covers applications, namely estimation, prior sensitivity and prediction.\nYou will need a working knowledge of basic computing tools, and knowledge of MCMC is highly valuable.\nChapter 6 in \\cite{Robert2007} gives an overview of computational techniques for Bayesian statistics.\n\n\\section*{Inferring population sizes -- theory}\n\nConsider the model\n\\begin{equation*}\n x_i \\sim \\operatorname{Binomial}(N, \\theta),\n\\end{equation*}\nwith \\textbf{both} $N$ and $\\theta$ unknown and suppose one observes $\\boldsymbol{x} = \\{x_1, x_2, \\ldots, x_K\\}$.\nHere, we will write $\\xi = (N, \\theta)$.\n\n\\begin{enumerate}[label=\\alph*)]\n \\item (10 marks) Formulate a hierarchical prior ($\\pi_1$) for $N$, i.e., elicit $F$ such that $N \\mid \\alpha \\sim F(\\alpha)$ and $\\alpha  \\sim \\Pi_A$.\n Justify your choice; \n \\item (5 marks) Using the prior from the previous item, write out the full joint posterior kernel for all unknown quantities in the model, $p(\\xi \\mid \\boldsymbol{x})$. \\textit{Hint:} do not forget to include the appropriate indicator functions!;\n \\item (5 marks) Is your model identifiable?\n \\item (5 marks) Exhibit the marginal posterior density for $N$, $p_1(N \\mid \\boldsymbol{x})$;\n \\item (5 marks) Return to point (a) above and consider an alternative, uninformative prior structure for $\\xi$, $\\pi_2$.\n Then, derive $p_2(N \\mid \\boldsymbol{x})$;\n \\item (10 marks) Formulate a third prior structure on $\\xi$, $\\pi_3$, that allows for the closed-form marginalisation over the hyperparameters $\\alpha$ -- see (a) -- and write out $p_3(N \\mid \\boldsymbol{x})$;\n \\item (10 marks) Show whether each of the marginal posteriors considered is proper.\n Then, derive the posterior predictive distribution, $g_i(\\tilde{x} \\mid \\boldsymbol{x})$, for each of the posteriors considered ($i = 1, 2, 3$).\n \\item (5 marks) Consider the loss function\n \\begin{equation}\n \\label{eq:relative_loss}\n  L(\\delta(\\boldsymbol{x}), N) = \\left(\\frac{\\delta(\\boldsymbol{x})-N}{N} \\right)^2.\n \\end{equation}\n Derive the Bayes estimator under this loss.\n\\end{enumerate}\n\n\\section*{Inferring population sizes -- practice}\nConsider the problem of inferring the population sizes of major herbivores~\\citep{Carroll1985}.\nIn the first case, one is interested in estimating the number of impala (\\textit{Aepyceros melampus}) herds in the Kruger National Park, in northeastern South Africa.\nIn an initial survey collected the following numbers of herds: $\\boldsymbol{x}_{\\text{impala}} = \\{15, 20, 21, 23, 26\\}$.\nAnother scientific question is the number of individual waterbuck (\\textit{Kobus ellipsiprymnus}) in the same park.\nThe observed numbers of waterbuck in separate sightings were $\\boldsymbol{x}_{\\text{waterbuck}} = \\{53, 57, 66, 67, 72\\}$ and may be regarded (for simplicity) as independent and identically distributed.\n\n\\begin{figure}[H]\n     \\centering\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[scale=0.75]{figures/impala.jpeg}\n         \\caption{Impala}\n     \\end{subfigure}\n     \\begin{subfigure}[b]{0.45\\textwidth}\n         \\centering\n         \\includegraphics[scale=0.75]{figures/waterbuck.jpeg}\n         \\caption{Waterbuck}\n     \\end{subfigure}\n        \\caption{Two antelope species whose population sizes we want to estimate.}\n        \\label{fig:antelopes}\n\\end{figure}\n\n\n\\begin{enumerate}[label=\\alph*)]\n\\setcounter{enumi}{8}\n \\item (20 marks) For each data set, sketch the marginal posterior distributions $p_1(N \\mid \\boldsymbol{x})$, $p_2(N \\mid \\boldsymbol{x})$ and $p_3(N \\mid \\boldsymbol{x})$.\n Moreover, under each posterior,  provide (i) the Bayes estimator under quadratic loss and under the loss in (\\ref{eq:relative_loss}) and (ii) a 95\\% credibility interval for $N$.\n Discuss the differences and similarities between these distributions and estimates: do the prior modelling choices substantially impact the final inferences? If so, how?\n \\item (25 marks) Let $\\bar{x} = K^{-1}\\sum_{k =1}^K x_k$ and $s^2 = K^{-1}\\sum_{k =1}^K (x_k-\\bar{x})^2$.\n For this problem, a sample is said to be \\textit{stable} if $\\bar{x}/s^2 \\geq (\\sqrt{2} + 1)/\\sqrt{2}$ and \\textit{unstable} otherwise.\n Devise a simple method of moments estimator (MME) for $N$.\n Then, using a Monte Carlo simulation, compare the MME to the three Bayes estimators under quadratic loss (\\ref{eq:relative_loss}) in terms of relative mean squared error. \n How do the Bayes estimators compare to MME in terms of the statibility of the generated samples? \n \\textit{Hint}: You may want to follow the simulation setup of~\\cite{Carroll1985}. \n\\end{enumerate}\n\n\\bibliographystyle{apalike}\n\\bibliography{a2}\n\\end{document}          \n", "meta": {"hexsha": "7db6a742b0bbfe7cf01035be4172d628a69a9fd1", "size": 7522, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignments/A2.tex", "max_stars_repo_name": "lucasmoschen/BayesianStatisticsCourse", "max_stars_repo_head_hexsha": "79fe17dd71fa9638ae4865c8e75eeb0f814d2ccb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-03-17T17:39:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T23:40:56.000Z", "max_issues_repo_path": "assignments/A2.tex", "max_issues_repo_name": "anhnguyendepocen/BayesianStatisticsCourse", "max_issues_repo_head_hexsha": "79fe17dd71fa9638ae4865c8e75eeb0f814d2ccb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-24T01:28:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T20:49:10.000Z", "max_forks_repo_path": "assignments/A2.tex", "max_forks_repo_name": "anhnguyendepocen/BayesianStatisticsCourse", "max_forks_repo_head_hexsha": "79fe17dd71fa9638ae4865c8e75eeb0f814d2ccb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-05-26T16:28:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T12:33:26.000Z", "avg_line_length": 50.4832214765, "max_line_length": 247, "alphanum_fraction": 0.7273331561, "num_tokens": 2200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.679178686187839, "lm_q1q2_score": 0.42276110125756816}}
{"text": "%\\documentclass[11pt]{article}\n\\documentclass[smallextended]{svjour3}       % onecolumn (second format)\n\\RequirePackage{fix-cm}\n\\smartqed  % flush right qed marks, e.g. at end of proof\n\\usepackage{natbib}\n\n\\usepackage[utf8]{inputenc} % allow utf-8 input\n\\usepackage[T1]{fontenc}    % use 8-bit T1 fonts\n\\usepackage{enumitem}\n\\usepackage{amsmath}\n\\usepackage{color}\n\\usepackage[toc,page]{appendix}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\usepackage{hyperref}\n\\usepackage{alltt}\n\\usepackage{listings}\n\\usepackage{array}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{sparklines}\n\\bibliographystyle{spbasic}\n\\usepackage{geometry}\n\n\\newcommand{\\secref}[1]{Section~\\ref{#1}}\n\\newcommand{\\appdxref}[1]{Appendix~\\ref{#1}}\n\\newcommand{\\tblref}[1]{Table~\\ref{#1}}\n\\newcommand{\\figref}[1]{Figure~\\ref{#1}}\n\\newcommand{\\thmref}[1]{Theorem~\\ref{#1}}\n\\newcommand{\\algref}[1]{Algorithm~\\ref{#1}}\n\\newcommand{\\funref}[1]{Function~\\ref{#1}}\n\\newcommand{\\eqnref}[1]{Equation~\\ref{#1}}\n\\newcommand{\\listingref}[1]{Listing~\\ref{#1}}\n\n\\newcommand{\\eg}{{\\em e.g.}}\n\\newcommand{\\ith}{$i^{th}$}\n\\newcommand{\\cut}[1]{}\n\\newcommand{\\todo}[1]{{{\\small\\color{red}{[#1]}}}}\n\\renewcommand{\\slash}{\\texttt{\\char`\\\\}}\n\n%\\newcommand{\\Ex}{\\mathop{\\mathbb{E}}}\n\\DeclareMathOperator{\\Ex}{\\mathbb{E}}\n\n\\newcommand{\\Imp}{\\fontfamily{cmr}\\textsc{Impact}}\n\\newcommand{\\Impo}{\\fontfamily{cmr}\\textsc{Import}}\n\\newcommand{\\CImp}{\\fontfamily{cmr}\\textsc{CatImpact}}\n\\newcommand{\\CImpo}{\\fontfamily{cmr}\\textsc{CatImport}}\n\\newcommand{\\simp}{\\fontfamily{cmr}\\textsc{\\small StratImpact}}\n%\\newcommand{\\Impo}{\\fontfamily{cmr}\\textsc{\\small StratImport}}\n\n\\newcommand{\\spd}{\\fontfamily{cmr}\\textsc{\\small StratPD}}\n\\newcommand{\\cspd}{\\fontfamily{cmr}\\textsc{\\small CatStratPD}}\n\\newcommand{\\xnc}{$x_{\\overline{c}}$}\n\\renewcommand{\\xi}{x^{(i)}}\n\\newcommand{\\xnC}{$x_{\\overline{C}}$}\n\n\\setlist[enumerate]{itemsep=-1mm}\n\n\\journalname{PREPRINT}\n\n\\begin{document}\n\n\\title{\\bf Nonparametric Feature Impact and Importance}\n\n% PREPRINT\n\\cut{\n\\author{Terence Parr \\email parrt@cs.usfca.edu\n\\addr University of San Francisco\\\\\n\\AND James D. Wilson \\email jdwilson4@usfca.edu\n\\addr University of San Francisco\\\\\n\\AND Jeff Hamrick \\email jhamrick@usfca.edu\n      \\addr University of San Francisco}\n}\n\n% for Springer Verlag\n\\author{Terence Parr \\and James D. Wilson* \\and Jeff Hamrick}\n\\institute{Terence Parr \\at\n  University of San Francisco, \n  \\email{{\\tt parrt@cs.usfca.edu}}\n  \\and\n  James D. Wilson \\at\n  University of San Francisco\n  \\email{{\\tt jdwilson4@usfca.edu}}\n  \\and\n  Jeff Hamrick \\at\n  University of San Francisco\n  \\email{{\\tt jhamrick@usfca.edu}} \n}\n\n%\\date{}\n\n\\maketitle\n\n\\begin{abstract}%\nPractitioners use feature importance to rank and eliminate weak predictors during model development in an effort to simplify models and improve generality.  Unfortunately, they also routinely conflate such feature importance measures with feature impact, the isolated effect of an explanatory variable on the response variable. This can lead to real-world consequences when importance is inappropriately interpreted as impact in applications like medicine and business. The dominant approach for computing feature importance is through interrogation of a fitted model, which works well for feature selection, but gives distorted measures of feature impact. For example, the same method applied to the same data set can yield different feature importances, depending on the model, leading us to conclude that impact should be computed directly from the data.  While there are nonparametric feature selection algorithms, they typically provide feature rankings, rather than direct measures of impact or importance. They also often focus on single-variable associations with the response. In this paper, we provide mathematical definitions of feature impact and importance, derived from partial dependence curves, that operate directly on the data. We develop two methods, StratImpact and StratImp, that estimate feature impact and importance from partial dependence measures using stratification of the explanatory variables. We show that features ranked by these definitions are competitive with, and often better than, existing feature selection techniques. We validate our methods through a comparison with contemporary methods using three real data sets and a testbed of simulated data.\n\\end{abstract}\n\n\\keywords{\nfeature importance \\and partial dependence \\and model interpretability \\and machine learning}\n\n\\section{Introduction}\n\\label{sec:intro}\n\nAmong data analysis techniques, feature importance is one of the most widely applied and practitioners use it for two key purposes: (1) to select features for predictive models, dropping the least predictive features to simplify and potentially increase the generality of the model and (2) to gain business, medical, or other insights, such as product characteristics valued by customers or treatments contributing to patient recovery.  To distinguish the two use cases, we will refer to feature predictiveness for modeling purposes as {\\em importance} (the usual meaning) and the effect of features on business or medical response variables as {\\em impact}. \n\nWhile some feature importance approaches work directly on the data, such as minimal-redundancy-maximal-relevance (mRMR) by \\cite{mRMR}, almost all algorithms used in practice rank features by interrogating a fitted model provided by the user.  Examples include permutation importance by \\cite{RF}, drop column importance, and SHAP by \\cite{shap}; LIME by \\cite{lime} interrogates subsidiary models to analyze such fitted models. It is accepted as self-evident that identifying the most predictive features for a model is best done through interrogation of that  model, but this is not always the case.  For example, when asked to identify the single most important feature of a real dataset \\citep{bulldozer} for a random forest (RF), the features selected by model-based techniques get twice the validation error of the nonparametric technique proposed in this paper; see \\figref{fig:topk}c. Still, model interrogation is generally very effective in practice for feature importance purposes.\n\nFeature importance should not, however, be interpreted as feature impact for several reasons. First, predictive features do not always coincide with impactful features; e.g., models unable to capture complex nonlinear feature-response relationships rank such features as unimportant, even if they have large impacts on the response. Next, practitioners must develop models accurate enough to yield meaningful feature importances, but there is no definition of ``accurate enough.'' Finally, it is possible to get very different feature importances (and hence impacts) running the same algorithm on the same data, just by choosing a different model. This is despite the fact that feature impacts are relationships that exist in the data, with or without a model.\n\nConsider the feature importance charts in \\figref{fig:diff-models} derived from four different models on the same well-known Boston toy data set, as computed by SHAP. The linear model (a) struggles to capture the relationship between features and response variable (validation $R^2$=0.73), so those importances are less trustworthy.  In contrast, the (b) RF, (c) boosted trees, and (d) support vector machine (SVM) models capture the relationship well (each with $R^2 > 0.85$). The problem is that SHAP derives meaningfully different feature importances from each model, as most model-based techniques would. The differences arise because feature impact is distorted by the lens' of the models (yielding importances). The differences might be appropriate for model feature selection, but it is unclear which ranking, if any, gives the feature impacts. \n\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[scale=0.58]{images/diff-models.pdf}\n\\vspace{-3mm}\n\\caption{\\small Ranking and relative predictiveness of the top 8 of 13 Boston data set features determined by SHAP interrogating four different models.  There is considerable variation between plots even in the two most important features. For example, while RF and XGBoost rank {\\tt LSTAT} and {\\tt RM} first but the RF gives {\\tt RM} much more weight. The SVM reverses that ranking. Model hyperparameters were tuned with 5-fold cross-validation grid search on a variety of hyperparameters over an 80\\% training set.  SHAP explains the 20\\% validation set.}\n\\label{fig:diff-models}\n\\end{center}\n\\end{figure}\n\nAlthough feature importance has long been explored in the statistics and machine learning literature, feature impact is, to date, not well-defined and is often misunderstood. Furthermore, practitioners routinely conflate model-based feature importance with impact and have, consequently, likely made business or medical decisions based upon faulty information. Despite the potentially serious real-world consequences resulting from inappropriate application of importances, research attention has focused primarily on feature importance rather than feature impact. \n\nIn this paper, we address this deficiency by contributing (1) a straightforward nonparametric definition as an ideal for computing feature impact, and related feature importance, and (2) a prototype implementation called \\simp{} that yields plausible feature impacts. Our definitions make feature impact methods accessible to the vast community of business analysts and scientists that lack the expertise to choose, tune, and evaluate usual parametric models. To assess \\simp{} quality, we use importance as a proxy to show that it is competitive on real data with existing importance techniques, as measured by validation errors on models trained using the top $k$ feature importances.  \n\nWe measure feature impact as a function of its partial dependence curve, as \\cite{pdvim} did, because partial dependences (ideally) isolate the effect of a single variable on the response. In contrast to \\cite{pdvim}, we use a nonparametric method called \\spd{} (\\citealt{stratpd}) to estimate partial dependences without predictions from a fitted model, which allows us to compute feature impact not just feature importance. \\spd{} also isolates partial dependence curves in the presence of strong codependencies between features. The partial dependence approach is flexible in that it opens up the possibility of computing importances using any partial dependence method, such as Friedman's original definition (\\citealt{PDP}) and ALE (\\citealt{ALE}). (We will refer to Friedman's original definition as FPD to distinguish it from the general notion of partial dependence.) SHAP also fits into this perspective since the average SHAP value at any single feature value forms a point on a mean-centered partial dependence curve. Our prototype is currently limited to regression but accepts numerical and label-encoded categorical explanatory variables; a similar approach should work for classification. The software is available via Python package {\\tt stratx} with source at {\\tt github.com/parrt/stratx}. \n\nWe begin by giving definitions of feature impact and importance in \\secref{sec:def}, then survey existing nonparametric and other model-dependent techniques in \\secref{sec:existing}. \\secref{sec:experiments} assesses the quality of \\simp{} importance values by examining how well they rank model features in terms of predictiveness. We finish in \\secref{sec:discussion} with a discussion of the proposed technique's effectiveness and future work.\n\n\\section{Definitions of impact and importance}\\label{sec:def}\n\n\\cut{Practitioners loosely define feature importance as feature predictiveness, which presupposes a fitted predictive model, probably because importances are so often used for feature selection during model development.  Research  focuses on more accurately identifying the impact of features upon model predictions.  But, relying on a fitted model makes it difficult to tease apart the true feature importance from the ability of the model to exploit that feature for prediction purposes. Rather than measuring feature impact on {\\em model predictions}, we propose avoiding the model completely to define feature importance as the average impact of a feature on the {\\em data set response values}.}\n\nWhen the true relationship between a set of features and the response is linear, we know the precise impact of each feature $x_j$. Assume we are given the training data pair ($\\bf X, y$) where ${\\bf X} = [x^{(1)}, \\ldots, x^{(n)}]$ is an $n \\times p$ matrix whose $p$ columns represent observed features and ${\\bf y}$ is the $n \\times 1$ vector of responses; ${\\bf X}_j$ is the $n \\times 1$ column of data associated with feature $x_j$.  If a data set is generated using a linear function, $y = \\beta_0 + \\sum_{j=1}^p \\beta_j x_j$, then coefficient $\\beta_j$ corresponds  to the impact of $x_j$ for $j=1,..,p$.  $\\beta_j$ is the impact on $y$ for a unit change in feature $x_j$, holding other features constant.\n\nTo hold features constant for any smooth and continuous generator function $f:\\mathbb{R}^{p} \\rightarrow \\mathbb{R}$ that precisely maps each $\\xi$ to $y^{(i)}$, ${y^{(i)}} = f(\\xi)$, we can take the partial derivatives of $f$ with respect to each feature $x_j$; e.g., for linear functions, ${\\partial y}/{\\partial x_j}=\\beta_j$. Integrating the partial derivative then gives the {\\em idealized partial dependence} (\\citealt{stratpd}) of $y$ on $x_j$, the isolated contribution of $x_j$ at $z$ to $y$:\n\n\\begin{equation}\\label{eq:pd}\n\\text{\\it PD}_j(x_j = z) = \\int_{min(x_j)}^z \\frac{\\partial f}{\\partial x_j} dx_j\n\\end{equation}\n\nUsing partial derivatives to isolate the effect of variables on the response was used prior to \\spd{} by ALE (\\citealt{ALE}) and {\\em Integrated Gradients} (IG) (\\citealt{intgrad}). The key distinction is that  \\spd{} integrates over the derivative of the generator function, ${\\partial f}/{\\partial x_j}$, estimated from the raw training data, whereas, previous techniques integrate over the derivative of model $\\hat{f}$ that estimates $f$: ${\\partial \\hat{f}}/{\\partial x_j}$. While there are advantages to using models, such as their ability to smooth over noise, properly choosing and tuning a machine learning model presents a barrier to many user communities, such as business analysts, scientists, and medical researchers. Further, without potential distortions from a model, \\spd{} supports the measurement of impact, not just importance.\n\n\\subsection{Impact and importance for numerical features}\n\nTo go from the idealized partial dependence of $x_j$ to feature impact, we assume that the larger the ``mass'' under $x_j$'s partial dependence curve, the larger $x_j$'s impact on $y$.\n\n~\\\\\n\\noindent {\\bf Definition 1} The (non-normalized) {\\em nonparametric feature impact} of $x_j$ is the area under the magnitude of $x_j$'s idealized partial dependence:\n\n\\begin{equation}\n\\Imp_j = \\int_{\\min({\\bf X}_j)}^{\\max({\\bf X}_j)} |PD_j(x_j)| dx_j\n\\end{equation}\n\n\\noindent In practice, we approximate the integral with a Riemann sum of rectangular regions:\n\n\\begin{equation}\n\\Imp_j \\approx \\sum_{x_j \\in \\{{\\bf X}_j\\}} |PD_j(x_j)| \\Delta x_j\n\\end{equation}\n\n\\noindent  where $\\{{\\bf X}_j\\}$ is the set of unique ${\\bf X}_j$ values ($\\{{\\bf X}_j^{(i)}\\}_{i=1..n}$) and $n_j$ is the number of unique ${\\bf X}_j$. \nThe usual definition of region width, $\\Delta x_j = {(\\max({\\bf X}_j) - \\min({\\bf X}_j))}/{n_j}$, is inappropriate in practice because ${\\bf X}_j$ often has large gaps in $x_j$ space and impact units would include $x_j$'s units (e.g., $rent \\times bedrooms$ or $rent \\times hasparking$). That would make impact scores incomparable across features. By defining $\\Delta x_j = 1/n_j$, the fraction of unique ${\\bf X}_j$ values covered by one $PD_j$ value, widths are not skewed by empty $x_j$ gaps and impact units become those of $y$. That reduces $x_j$'s impact estimate to the average magnitude of $PD_j$:\n\n\\[\n\\Imp_j \\approx  \\sum_{x_j \\in \\{{\\bf X}_j\\}} |PD_j(x_j)| \\times \\frac{1}{n_j} = \\overline{|PD_j|}\n\\]\n\n\\noindent This formula works for any partial dependence curve, either by examining output from a fitted model, $\\hat{f}$, or by estimating the partial derivative of $f$ directly from the data and then integrating, as \\spd{} does. Dividing $x_j$'s impact by the sum of all impacts, converts impact units from $y$'s units to [0,1], leading to the following definition.\n\n~\\\\\n\\noindent {\\bf Definition 2} The {\\em normalized nonparametric feature impact} of $x_j$ is the ratio of the average magnitude of $x_j$'s partial dependence to the total for all variables:\n\n\\begin{equation}\\label{eq:Epd2a}\n\\Imp_j^{*} = \\frac{\\overline{|\\text{\\it PD}_j|}}{\\sum_{k=1}^p \\overline{|\\text{\\it PD}_k|}}\n\\end{equation}\n\nIntuitively, the impact of $x_j$ is how much, on average, the values of $x_j$ are expected to push $y$ away from a zero baseline. We deliberately chose this  definition instead of measuring how much $x_j$ pushes $y$ away from the average response, $\\overline{y}$, as SHAP does.  The average response includes the effects of all $x_j$, which hinders isolation of individual feature impacts. For example, the impact of $x_1$ on quadratic $y = x_1^2+x_2+100$ is $x_1^2$, not $|\\overline{y} - x_1^2|$.  \n\n\\figref{fig:quad-area} illustrates how the area under the $x_1^2$ and $x_2$ PD curves differ from the area straddling the means for $x_1, x_2 \\sim U(0,3)$. The area under-the-curve ratio of $x_1$-to-$x_2$ is 2-to-1 (9/4.5), whereas the ratio of the area straddling the mean has roughly a 3-to-1 ratio (6.95/2.26).  The symbolic partial derivatives are ${\\partial y}/{\\partial x_1} = 2 x_1$ and ${\\partial y}/{\\partial x_2} = 1$, so $\\text{\\it PD}_1 = x_1^2$ and $\\text{\\it PD}_2 = x_2$. Integrating those gives $\\Imp_1 = \\int_0^3 x_1^2 dx_1 = \\frac{x_1^3}{3} \\big |_0^3 = 9$ and $\\Imp_2 = \\int_0^3 x_2^2 dx_2 = \\frac{x_2^2}{2} \\big |_0^3 = 4.5$; $\\Imp_1^{*} = 0.\\overline{66}$ and $\\Imp_2^{*} = 0.\\overline{33}$.\n\n\\begin{figure}\n\\centering\n\\begin{minipage}{.56\\textwidth}\n  \\centering\n\\includegraphics[scale=0.57]{images/quadratic-auc.pdf}\n\\vspace{-3mm}\n  \\captionof{figure}{\\small The area under $x_1$ and $x_2$ PD curves represent $\\simp_1$, $\\simp_2$ for $y = x_1^2 + x_2 + 100$ in range $[0,3]$. Compare the areas straddling the means and the areas under the partial dependence curves.}\n\\label{fig:quad-area}\n\\end{minipage}\n\\hfill\n\\begin{minipage}{.41\\textwidth}\n  \\centering\n\\includegraphics[scale=0.5]{images/bulldozer-YearMade.pdf}  \\vspace{-3mm}\n\\captionof{figure}{\\small \\simp{} curve for bulldozer {\\tt SalePrice} on {\\tt YearMade} including the histogram used to weight the partial dependence to obtain feature importances. A 20k sample of all 363k records; \\textasciitilde0.5\\% of samples stratified into regions with single {\\tt YearMade} values.}\n\\label{fig:yearmade}\n\\end{minipage}\n\\end{figure}\n\nThe $PD_j$ curve represents how $x_j$ effects $y$, but does not take into consideration the distribution of $x_j$ in ${\\bf X}_j$.  Consider the \\spd{} curve and $x_j$ histogram in \\figref{fig:yearmade} for feature {\\tt\\small YearMade} from the bulldozer auction data set \\citep{bulldozer}. The colored curves represent ten bootstraps from the same training set and the black dots give the average curve.   From a business perspective, knowing that increases in bulldozer age continue to reduce price is useful, but new bulldozers will represent the bulk of any model validation set.  Because model feature selection is often assessed using  validation error, feature selection is sensitive to the distribution of $x_j$. This suggests that feature importance should take into consideration the distribution of $x_j$, leading to the following importance definition:\n\n~\\\\\n\\noindent {\\bf Definition 3} The {\\em normalized nonparametric feature importance} of $x_j$ is the ratio of $x_j$'s average partial dependence magnitude, weighted by $x_j$'s distribution, to the total of all weighted averages:\n\n%\\begin{equation}\\label{eq:Epd3b}\n%\\Impo_j^{*} = \\frac{\\Ex[|\\text{\\it PD}_j|]}{\\sum_{k=1}^p \\Ex[|\\text{\\it PD}_k|]}\n%\\end{equation}\n\n\\begin{equation}\\label{eq:Epd3b}\n\\Impo_j^{*} = \\frac{\\Impo_j}{\\sum_{k=1}^p \\Impo_k}\n\\end{equation}\n\n\\noindent where\n\n\\begin{equation}\\label{eq:Epd3c}\n\\Impo_j \\approx \\sum_{x_j \\in \\{{\\bf X}_j\\}} \\frac{n_{x_j}}{n} \\times |PD_j(x_j)|\n\\end{equation}\n\n\\noindent and $n_{x_j}$ is the number of $x_j$ values in ${\\bf X}_j$; i.e., $(x_j, n_{x_j})_{x_j \\in \\{{\\bf X}_j\\}}$ is the histogram of ${\\bf X}_j$.\n\n%\\begin{equation}\\label{eq:Epd3c}\n%\\Ex[|\\text{\\it PD}_j|] = \\sum_{x_j \\in \\{{\\bf X}_j\\}} |\\text{\\it PD}_j(x_j)| \\times P(x_j)\n%\\end{equation}\n\nMeasuring impact as the average partial dependence generalizes to non-ordinal categorical explanatory features encoded as unique integers, with a small modification.  \n\n\\subsection{Impact and importance for categorical features}\n\nPartial dependence curves for numerical features use the leftmost $x_j$ value as the zero reference point, but nominal categorical features have no meaningful order. That implies we can choose any category as the zero reference category, which shifts the partial dependence plot up or down, but does not alter the relative $y$ values among the category levels. For example, consider relative $y$ values for four categories (0, 1, 1, 1) where the first category is the reference.  Choosing the second category as the reference yields relative $y$ values (-1, 0, 0, 0). The impacts (average magnitude) for these two variations are 3/4 versus 1/4, respectively, but the choice of reference category should not affect the impact metric computed on the same partial dependence data. Worse, picking a category level whose $y$ is an outlier strongly biases the impact because the outlier pushes up (or down) all category $y$ values by a biased amount.  Instead of picking a specific level as the reference, therefore, we use that feature's partial dependence average value as the reference zero:\\\\\n\n\\noindent {\\bf Definition 4} The {\\em normalized nonparametric categorical feature impact} of $x_j$ is the ratio of the average magnitude of $x_j$'s mean-centered partial dependence to the total for all variables:\n\n\\begin{equation}\\label{eq:Cpd4a}\n\\CImp_j^{*} = \\frac{\\overline{|\\text{\\it PD}_j - \\overline{\\text{\\it PD}_j}|}}{\\sum_{k=1}^p \\overline{|\\text{\\it PD}_k - \\overline{\\text{\\it PD}_j}|}}\n\\end{equation}\n\n~\\\\\n\n\\noindent The definition of categorical variable importance mirrors the definition for numerical variables, which weights impact by the distribution of the $x_j$'s:\n\n~\\\\\n\n\\noindent {\\bf Definition 5} The {\\em normalized nonparametric categorical feature importance} of $x_j$ is the ratio of $x_j$'s expected mean-centered partial dependence magnitude to the total of all:\n\n\\begin{equation}\\label{eq:Epd2b}\n\\CImpo_j^{*} = \\frac{\\CImpo_j}{\\sum_{k=1}^p \\CImpo_k}\n\\end{equation}\n\n\\noindent where\n\n\\begin{equation}\\label{eq:Epd2c}\n\\CImpo_j \\approx \\sum_{x_j \\in \\{{\\bf X}_j\\}} \\frac{n_{x_j}}{n} \\times |PD_j(x_j)- \\overline{\\text{\\it PD}_j}|\n\\end{equation}\n\nBy choosing $\\overline{\\text{\\it PD}_j}$ as the reference value (instead of a specific category's $\\text{\\it PD}_j$ value), our definition moves closer to SHAP's mean-centered approach, which we disagreed with above, but only out of necessity for categorical variables. A key difference is that $\\CImpo_j$ centers on $\\overline{\\text{\\it PD}_j}$ rather than the overall average, $\\bar{y}$, that includes the effect of all features. With these definitions in mind, we make a more detailed comparison to related work in the next section.\n\n\\section{Existing methods}\\label{sec:existing}\n\nIn this paper, we are primarily concerned with identifying the most impactful features, such as needed in business or medical applications. But, because virtually all related research focuses on feature importance and, because practitioners commonly assume feature importance is the same as feature impact, it is appropriate to compare \\simp{} to  feature importance methods. Feature importance methods for labeled data sets (with both $\\bf X$ and $\\bf y$) are broadly categorized into data analysis and model analysis techniques, sometimes called {\\em filter} and {\\em wrapper} methods \\citep{tsanas}. Data analysis techniques analyze the data directly to identify important features, whereas model analysis techniques rely on predictions from fitted models.\n\n\\subsection{Data analysis techniques}\n\nThe simplest technique to identify important or relevant regression features is to rank them by their Spearman's rank correlation coefficient \\citep{spearmans}; the feature with the largest coefficient is taken to be the most important. This method works well for independent features, but suffers in the presence of codependent features.   Groups of features with similar relationships to the response variable receive the same or similar ranks, even though just one should be considered important.\n\nAnother possibility is to use principle component analysis (PCA), which operates on just the $\\bf X$ explanatory matrix. PCA transforms data into a new space characterized by eigenvectors of $\\bf X$ and identifies features that explain the most variance in the new space. If the first principal component covers a large percentage of the variance, the ``loads'' associated with that component can indicate importance of features in the original $\\bf X$ space. PCA is limited to linear relationships, however, and ``most variation'' is not always the same thing as ``most important.''\n\nFor classification data sets, the Relief algorithm \\citep{relief} tries to identify features that distinguish between classes through repeated sampling of the data. For a sampled observation $\\xi$, the algorithm finds the nearest observation with the same class (hit) and the nearest observation with the other class (miss). The score of each attribute, $x_j$, is then updated according to the distance from the selected $\\xi$ to the hit and miss observations'  $x_j$ values. ReliefF \\citep{ReliefF} extended Relief to work on multiclass problems and RReliefF \\citep{RReliefF} adapted the technique to regression problems by ``...introduc[ing] a kind of probability that the predicted values of two instances are different.''\n\nIn an effort to deal with codependencies, data analysis techniques can rank features not just by {\\em relevance} (correlation with the response variable) but also by low {\\em redundancy}, the amount of information shared between codependent features, which is the idea behind minimal-redundancy-maximal-relevance (mRMR) by \\citet{mRMR}. mRMR selects features in order according to the following score.\n\n\\[\nJ_{\\text{mRMR}}(x_k) = I(x_k, y) - \\frac{1}{|S|} \\sum_{x_j \\in S} I(x_k, x_j)\n\\]\n\n\\noindent where $I(x_k, x_j)$ is some measure of mutual information between $x_k$ and $x_j$, $S$ is the growing set of selected features, and $x_k$ is the candidate feature. mRMR only considers single-feature relationships with the response variable, and is limited to classification. See \\cite{ubermRMR} for a recent application of mRMR at Uber Technologies.  For more on model-free feature importances, see the survey by \\cite{survey}.  \\citet{tsanas} suggests using Spearman's rank and not mutual information. \\citet{meyer-microarray} looks for pairs of features to response variable associations as an improvement, while retaining reasonable efficiency. See \\citet{filter-benchmark} for benchmarks comparing data analysis methods.\n\nThe fundamental problem faced by these data analysis techniques is that they measure relevance by the strength of the association between (typically) a single feature to response $y$, but $y$ contains the impact of all $x_j$ variables. Some analysis techniques, such as mRMR, only rank features and do not provide a numerical feature impact. Computing an appropriate association metric between categorical and numerical values also presents a challenge.\n\n\\subsection{Model-based techniques}\n\nTurning to model-based techniques, feature importance methods are typically variations on one of two themes:  (1) tweaking a model and measuring the tweak's effect on model prediction accuracy or expected model output or (2) examining the parameters of a fitted model. The simplest approach following the first theme is {\\em drop-column importance}, which defines $x_j$ importance as the difference in some accuracy metric between a model with all features (the baseline) and a model with $x_j$ removed. The model must be retrained $p$ times and highly-correlated features yield low or zero importances because codependent features cover for the dropped column.\n\nTo avoid retraining the model, $x_j$ can be permuted instead of dropped for {\\em permutation importance} (\\citealt{RF}). This approach is faster but can introduce nonsensical observations by permuting invalid values into records, as discussed in \\cite{stopperm}; e.g., shifting a true {\\tt\\small pregnant} value into a male's record. Codependent features tend to share importance, at least when permutation importance is applied to RF models. To avoid nonsensical records for the RF case, \\cite{rfimp} proposed a {\\em conditional permutation importance} using the feature space partition created by node splitting during tree construction.  \n\nRather than removing or permuting entire columns of data, LIME \\citep{lime} focuses on model behavior at the observation level. For an observation of interest, $\\bf x$, LIME trains an interpretable linear model, on a small neighborhood of data around $\\bf x$ to explain the relationship between variables and the response locally. SHAP was shown to subsume the LIME technique in \\cite{shap}. \n\nSHAP has its roots in {\\em Shapley regression values} \\citep{shapley-regression} where (linear) models were trained on all possible subsets of features. Let $\\hat{f}_S$ be the model trained on feature subset $x_S$ for $S \\subset F = \\{1, 2, .., p\\}$. Each possible model pair differing in a single feature $x_j$ contributes the difference in model pair output towards the Shapley value for $x_j$. The complete Shapley value is the average model-pair difference weighted by the number of possible pairs differing in just $x_j$:\n\\vspace{-1mm}\n\n\\begin{equation}\\label{eq:shap}\n\\phi_j(\\hat{f},x_F) = \\sum_{S \\subseteq F \\slash \\{j\\}}\\\n\\frac{|S|!(|F|-|S|-1)!}{|F|!}\\\n ( \\hat{f}_{S \\cup \\{j\\}}(x_{S \\cup \\{j\\}}) - \\hat{f}_S(x_S) )\n\\end{equation}\\vspace{-1mm}\n\n\\noindent The SHAP importance for feature $x_j$ is the average magnitude of all $\\phi_j$ values.  \n\nTo avoid training a combinatorial explosion of models with the various feature subsets, SHAP approximates $\\hat{f}_S(x_S)$, with $\\Ex[\\hat{f}(x_{S},{\\bf X}_{\\slash S}') | {\\bf X}_S' = x_S]$ where ${\\bf X'}$ is called the {\\em background set} (in ``interventional'' mode) and users can pass in, for example, a single vector with ${\\bf X}_{\\slash S}$ column averages or even the entire training set, ${\\bf X}_{\\slash S}$.  SHAP's implementation further approximates $\\Ex[\\hat{f}(x_{S},{\\bf X}_{\\slash S}') | {\\bf X}_S' = x_S]$ with $\\Ex[\\hat{f}(x_{S},{\\bf X}_{\\slash S}')]$, which assumes feature independence and allows extrapolation of $\\hat{f}$ to nonsensical records like permutation importance. By removing the expectation condition, the inner difference of equation \\eqref{eq:shap} reduces to a function of FPDs, which means SHAP can have biased results in the presence of codependent features, as shown in \\cite{stratpd}.  As implemented, then, the average SHAP value at any $x_j$ value is a point on the $FPD_j - \\bar{y}$ curve and so $\\overline{|FPD_j-\\bar{y}|}$ = $\\overline{|\\phi_j(\\hat{f},x)|}$. \n\n\\cut{\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[scale=0.53]{images/FPD-SHAP-PD.pdf}\\vspace{-3mm}\n\\caption{\\small Partial dependence plots of $n=1000$ data generated from noiseless $y = x_1^2 + x_1 x_2 + 5 x_1 sin(3 x_2) + 10$ where $x_1,x_2,x_3 \\sim U(0,10)$ and $x_3$ does not affect $y$. The model is a RF with 30 trees trained on all data (training $R^2=0.997$, Out-of-bag $R^2=0.968$). SHAP used all $\\bf X$ as background data.}\n\\label{fig:FPD_vs_SHAP}\n\\end{figure}\n\nIf we assume for the moment that all features are independent, there is a simple relationship between SHAP and mean-centered FPDs, the partial dependence curves as originally defined by Friedman.  \\figref{fig:FPD_vs_SHAP}a and \\figref{fig:FPD_vs_SHAP}b illustrate a clear similarity between FPD-$\\bar{y}$ and a plot of SHAP values $(x_j^{(i)}, \\phi(\\hat{f},x_j^{(i)}))$. \n}\n\nThat observation begs the question of whether measuring the area under a simple mean-centered FPD curve would be just as effective as the current SHAP implementation.  \\figref{fig:fpd_imp} compares feature importances derived from FPD curves and SHAP values for two real data sets, rent from \\cite{rent} and bulldozer from \\cite{bulldozer}. The rank and magnitude of the feature importances are very similar between the techniques for the top  $p=8$ features. At least for these examples, the complex machinery of SHAP is unnecessary because nearly the same answer is available using a simple FPD. \n\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[scale=0.5]{images/rent-pdp-vs-shap.pdf}\\includegraphics[scale=0.5]{images/bulldozer-pdp-vs-shap.pdf}\\\\\n\\vspace{-3mm}\n\\caption[short]{\\small  Importance ranking of top 8 features for rent and bulldozer data sets demonstrating strong similarity between average magnitude of Friedman's partial dependence curves, (a) and (c), and average magnitude of SHAP values, (b) and (d). 20,000/5,000 training/validation records were sampled to tune an RF model by 5-fold cross validation grid search. Rent validation $R^2 = 0.857$, bulldozer $R^2 = 0.856$. The FPD curve and SHAP values were computed using 300 records from the validation set; SHAP used 100 backing records from the training data.}\n\\label{fig:fpd_imp}\n\\end{center}\n\\end{figure}\n\nThere are two methods used heavily in practice that define importance in terms of model parameters. The first operates on linear models and divides $\\beta$ coefficients by their standard errors and the second examines the decision nodes in tree-based methods. The most well-known tree-based method is ``mean drop in impurity'' (also called ``gini drop'') by \\cite{CART}, but there are a number of variations, such as the technique for gradient boosting machines (GBMs) described by \\cite{PDP}.  The importance of $x_j$ is the average drop in $y$ impurity, entropy (classification) or variance (regression), for all nodes testing $x_j$, weighted by the fraction of test samples that reach those nodes. Such importance measures are known to be biased towards continuous or high cardinality explanatory variables (see \\citealt{permbias} and \\citealt{RFunbiased}).\n\nDeriving feature importances from partial dependences as \\simp{} does was previously proposed by \\cite{pdvim}, and is implemented in an R package called {\\tt vip}, but they defined $x_j$'s importance as ${\\it PD}_j$'s ``flatness'' rather than the area under the ideal ${\\it PD}_j$ curve, as we have in equation \\eqref{eq:pd}.  To measure flatness, they suggest standard deviation for numerical variables and category level range divided by four for categorical variables (as an estimate of standard deviation).  Because standard deviation measures the average squared-difference from the average response, {\\tt vip} would likely be more sensitive to partial dependence curve spikes than the area under the curve.  Using the idealized partial dependence, {\\tt vip} would measure importance as $\\overline{(PD_j - \\overline{PD_j})^2}$ akin to SHAP's mass-straddling-the-mean approach, whereas we suggest the average magnitude weighted by $x_j$'s distribution.  Another difference between {\\tt vip} and \\simp{} is that {\\tt vip} computes partial dependence curves by measuring changes in model $\\hat{f}$, rather than directly from the data as we do. Any technique that computes partial dependence curves, directly or indirectly, fits neatly into {\\tt vip} or the ``area under the PD curve'' framework described in this paper. FPD, ALE, SHAP, and \\spd{} are four such techniques.\n\n\\citet{intgrad} introduced a technique called {\\em integrated gradients} (IG) for deep learning classifiers that can also be seen as a kind of partial dependence. To attribute a classifier prediction to the elements of an input vector, $\\bf x$, IG integrates over the gradient of the model output function at points along the straight-line path from a baseline vector, $\\bf x'$, to $\\bf x$. IG estimates the integral by averaging the gradient computed at $m$ points and multiplying by the difference between ${\\bf x}'_j$ and ${\\bf x}_j$:\n\n\\begin{equation}\\label{eq:IG}\n\\text{IntegratedGradient}_j(\\hat{f}, {\\bf x},{\\bf x'}) = (x_j - x'_j) \\times \\frac{1}{m} \\sum_{k=1}^{m} \\frac{\\partial \\hat{f}({\\bf x}' + \\frac{k}{m}({\\bf x}-{\\bf x}'))}{\\partial x_j}\n\\end{equation}\n\n\\noindent  Because IG integrates the partial derivative like ALE and \\spd,  equation \\eqref{eq:IG} can be interpreted as the $x_j$ partial dependence curve evaluated at $\\bf x$ weighted by the range in $x_j$ space. Alternatively, the average gradient within an $x_j$ range times the range of $x_j$ is equivalent to the area under the $x_j$ gradient curve in that range (by the mean value theorem for integrals). In that sense, \\cite{intgrad} is also similar to \\simp, except that we integrate the gradient twice, once to get the partial dependence curve and a second time to get the area under the partial dependence curve.\n\n\\simp{} is neither a model-based technique nor a model-free technique. It does not use model predictions but does rely on \\spd, which internally uses a decision tree model to stratify feature space. \\simp{}, therefore, has a lot in common with the ``mean drop in impurity'' technique. The  differences are that users do not provide a fitted tree-based model to \\simp{} and \\simp{} examines leaf observations rather than decision nodes. Unlike techniques relying on model predictions, \\simp{} can compute feature impact rather than feature importance. Unlike model-free techniques (such as mRMR), \\simp{} is able to provide impacts not just feature rankings and can consider the relationship between multiple features and the response.   \\simp{} (via \\spd) also performs well in the presence of codependent variables, unlike many model-based techniques. In the next section, we demonstrate that \\simp{} is effective and efficient enough for practical use.\n\n\\section{Experimental results}\\label{sec:experiments}\n\nAssessing the quality of feature impact and importance is challenging because, even with domain expertise, humans are unreliable estimators (which is why we need data analysis algorithms in the first place).  The simplest approach is to examine impacts and importances computed from synthetic data for which the answers are known.  For real data sets, we can train a predictive model on the most impactful or most important $k$ features, as identified by the methods of interests, and then compare model prediction errors; we will refer to this as top-$k$. (\\citealt{mRMR} and \\citealt{tsanas} also used this approach.) The method that accurately identifies the most impactful features without getting confused by codependent features should yield lower prediction errors for a given $k$.  \n\nIn this section, we present the results of several experiments using the toy Boston data set and three real data sets: NYC rent prices \\citep{rent}, bulldozer auction sales \\citep{bulldozer}, and flight delays \\citep{flights}. Rent has $p=20$ features, bulldozer has 14, and flight has 17. We draw $n$=25,000 samples from each data set population, except for Boston which only has 506 records, and split into 80\\% training / 20\\% validation sets. Each point on an error curve represents the validation set mean absolute error (MAE) for a given model, feature ranking, and data set. All models used to rank features or measure top-$k$ errors were tuned with 5-fold cross-validation grid search across a variety of hyperparameters using just the training records. (Tuned hyperparameters can be found at the start of file {\\tt\\small genfigs/support.py} in the repo.) The same \\spd{} and \\cspd{} hyperparameters were used across all simulations and datasets.\\footnote{\nThe entire \\simp{} code base is available at {\\tt\\small https://github.com/parrt/stratx} and running {\\tt\\small articles/imp/genfigs/RUNME.py} will regenerate all figures in this paper, after downloading the three Kaggle data sets.  \\spd{} and \\cspd{} calls always used {\\tt\\small min\\_samples\\_leaf=20}. Simulations were run on a 4.0 Ghz 32G RAM machine running OS X 10.13.6 with SHAP 0.35, scikit-learn 0.21.3, XGBoost 0.90, and Python 3.7.4. The same random seed of 1 was set for each simulation for graph reproducibility.}\n\nWe begin with a baseline comparison of \\Impo{} to principal component analysis' (PCA) ranking (``loads'' associated with the first component) and to Spearman's R coefficients computed between each $x_j$ and the response variable $y$.  \\figref{fig:baseline} shows the MAE curve for an RF model trained using the top-$k$ features as ranked by PCA, Spearman, and \\Impo. Spearman's R does a good job for all but the bulldozer data set, while PCA performs poorly on all four data sets. \\Impo{} is competitive with or surpasses these baseline techniques. \n\n\\cut{\n\\figref{fig:baseline} also shows the error curve for the features ranked by ordinary least squares (OLS); a feature's score is its $\\beta$ coefficient divided by its standard error. (OLS is not applicable to the bulldozer data set because it has many high-cardinality categorical explanatory variables, which would create tens of thousands of dummy variables.) \n\nOLS curves are similar to \\Impo's except for rent in \\figref{fig:baseline}d and are included as a common reference curve on subsequent graphs.\n}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.43]{images/boston-topk-RF-baseline.pdf}\n\\vspace{-2mm}\n\\subcaption{}\n\\end{subfigure}%\n%\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.43]{images/flights-topk-RF-baseline.pdf}\n\\vspace{-2mm}\n\\subcaption{}\n\\end{subfigure}\n%\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.43]{images/bulldozer-topk-RF-baseline.pdf}\n\\vspace{-2mm}\n\\subcaption{}\n\\end{subfigure}\n%\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.43]{images/rent-topk-RF-baseline.pdf}\n\\vspace{-2mm}\n\\subcaption{}\n\\end{subfigure} \n\\vspace{-3mm}\n\\caption{\\small {\\bf RF MAE curves from \\underline{baseline} rankings} computed using RF models trained on Boston, flight, bulldozer, and rent data sets. Error curves represent 5-fold cross validation using the top-$k$ features as ranked by Spearman's R, PCA ``loads'' associated with the first component, and \\Impo{}.}\n\\label{fig:baseline}\n\\end{figure}\n\nNext, in \\figref{fig:topk}, we compare \\Impo{}'s rankings to those of ordinary least squares (OLS), RF-based permutation importance, and SHAP interrogating OLS and RF models. A feature's OLS ranking score is its $\\beta$ coefficient divided by its standard error. (OLS is not very useful for the bulldozer data set because there are important label-encoded categorical explanatory variables.) OLS and OLS SHAP analyzed all $n$ records for each data set, but RF-based permutation importance and RF-based SHAP trained on 80\\% then used the remaining 20\\% validation set to rank features. We deliberately restricted \\simp{} to analyzing just the 80\\% training data, to see how it would fare. RF-based SHAP and permutation importance, therefore, have two clear advantages: (1) they use the same kind of model (RF) for both feature ranking and for computing top-$k$ error curves and (2) they are able to select features using 100\\% of the data, but \\simp{} selects features using just the  training data.\n\nThe error curves for \\simp, RF SHAP, and permutation importance are roughly the same for Boston in \\figref{fig:topk}a and flight in \\figref{fig:topk}b. For bulldozer in \\figref{fig:topk}c, \\simp's error curve suggests it selected a more predictive feature than RF SHAP or RF permutation importance for $k=1$: {\\tt ModelID}  followed by high-cardinality categorical {\\tt YearMade}. RF permutation importance chose {\\tt ProductSize} as most important followed by {\\tt ModelID} and RF SHAP chose {\\tt ProductSize} followed by {\\tt YearMade}. For the rent data set in \\figref{fig:topk}d, \\simp{} selects {\\tt brooklynheights} (L1 distance from the apartment to that neighborhood) as the most predictive feature followed by {\\tt bedrooms}.  RF SHAP and permutation importance selected {\\tt bedrooms} followed by {\\tt bathrooms}.  The \\simp{} curve is very similar to the RF permutation curve.   The second row in \\figref{fig:topk} shows that the plain impact, unweighted by $x_j$'s  distribution, can also work well for model feature selection purposes.  The impact error curves match the importance error curves closely, indicating that $x_j$ density is not critical for these data sets.\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/boston-topk-RF-Importance.pdf}\n%\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/flights-topk-RF-Importance.pdf}\n%\\subcaption{}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/bulldozer-topk-RF-Importance.pdf}\n%\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/rent-topk-RF-Importance.pdf}\n%\\subcaption{}\n\\end{subfigure}\n\n\\vspace{1mm}\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/boston-topk-RF-Impact.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.25\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/flights-topk-RF-Impact.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}{.25\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/bulldozer-topk-RF-Impact.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/rent-topk-RF-Impact.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}\n\\vspace{-3mm}\n\\caption[short]{\\small {\\bf RF MAE curves from {\\bf importance} rankings on top and {\\bf impact} rankings on bottom}. The mean absolute error curves from 40-tree RF models trained on boston, flight, bulldozer, and rent data sets. Error curves represent 5-fold cross validation using the top-$k$ features from the following feature rankings: OLS as in \\figref{fig:baseline}, SHAP interrogating OLS, SHAP interrogating 40-tree RF, permutation importance interrogating 40-tree RF, and \\simp{}. All methods had access to 80\\% training data from $n=25,000$ random sample (Boston has just 506 records).  All methods except \\simp{} had access to the 20\\% validation set.}\n\\label{fig:topk}\n\\end{figure}\n\nThe OLS-derived feature rankings present an interesting story here (the circular markers). For Boston, flight, and rent, OLS feature rankings give error curves that are fairly similar to those of RF SHAP and RF permutation importance.  Please keep in mind that, while the features were chosen by interrogating a linear model, the error curves were  computed using predictions from a (stronger) RF model.  Perhaps most surprising is that OLS chooses the best single most-predictive feature for both flight and rent data sets, choosing {\\tt TAXI\\_OUT} and {\\tt bathrooms}, respectively; RF SHAP and RF permutation rank {\\tt DEPARTURE\\_TIME} and {\\tt bedrooms} as most predictive. The circle markers representing OLS in \\figref{fig:topk}b and \\figref{fig:topk}d have the lowest $k=1$ error curve value,  suggesting that, for example, the number of bathrooms is more predictive of rent price than bedrooms in New York. The error curve derived from the OLS SHAP feature rankings differs from the OLS curve because the OLS coefficients are divided by the standard error. An error curve using raw OLS coefficients is the same as OLS SHAP's curve.\n\n\\cut{\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/boston-topk-RF-Impact.pdf}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/flights-topk-RF-Impact.pdf}\n\\subcaption{}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/bulldozer-topk-RF-Impact.pdf}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/rent-topk-RF-Impact.pdf}\n\\subcaption{}\n\\end{subfigure}\n\\caption[short]{\\small MAE curves as in \\figref{fig:topk} except using \\simp{} {\\em impact} rather than {\\em importance}. \\todo{merge with previous importance graphs?}}\n\\label{fig:topk-impact}\n\\end{figure}\n}\n\nFeatures that are predictive in one model are not necessarily predictive in another model.  To determine how well the feature rankings from the various methods ``export'' to another model, we trained gradient boosting machines (GBM) on the OLS-based, RF-based, and \\simp{} feature rankings.  \\figref{fig:topk-gbm} shows that the \\simp{} error curves generated using GBM models are similar to those resulting from RF models, except for the \\figref{fig:topk-gbm}(b) flight delay curve, which does not improve much after feature $k=5$, while the other feature rankings do improve. \n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/boston-topk-GBM-Importance.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/flights-topk-GBM-Importance.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/bulldozer-topk-GBM-Importance.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.245\\textwidth}\n    \\centering\n\\includegraphics[scale=0.45]{images/rent-topk-GBM-Importance.pdf}\n\\vspace{-5mm}\n\\subcaption{}\n\\end{subfigure}\n\\vspace{-3mm}\n\\caption[short]{\\small MAE curves as in \\figref{fig:topk} except measuring {\\tt xgboost} predictions, rather than RF; hyperparameters were tuned via 5-fold cross validation.}\n\\label{fig:topk-gbm}\n\\end{figure}\n\nTo check feature exportation to a very different model, we computed error curves for the Boston, flight, and rent data sets using OLS regressors, as shown in \\figref{fig:OLS}, again using the \\simp, OLS-derived, and RF-derived rankings.  The error curves derived from OLS model predictions are all higher than those from RFs, as expected since OLS is weaker than GBM, but feature rankings from all technique export reasonably well, with the exception of \\simp's rankings for rent.  The poor performance could be due to OLS' inability to leverage the \\simp{} ranking or could be poor feature ranking on \\simp's part.  The former is more likely, given that more sophisticated methods get low error curves using \\simp's ranking.\n\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[scale=0.5]{images/boston-topk-OLS-Importance.pdf}~~~\n\\includegraphics[scale=0.5]{images/flights-topk-OLS-Importance.pdf}~~~\\includegraphics[scale=0.5]{images/rent-topk-OLS-Importance.pdf}\n\\vspace{-3mm}\n\\caption{\\small MAE curves as in \\figref{fig:topk-gbm} but measuring OLS rather than RF predictions.}\n\\label{fig:OLS}\n\\end{center}\n\\end{figure}\n\nTo compute the \\simp{} feature rankings described thus far, we used a single 80/20 training and validation sample in order to get reproducible figures.  But, different subsets of the data set can yield very different impacts, depending on the variability of the data set. \\simp{} supports multiple trials via bootstrapping or subsampling on the $(\\bf X, y)$ data set to obtain impact and importance standard deviations.  As an example, \\figref{fig:stability} shows the  feature rankings of \\Imp{} and \\Impo{}, averaged from 30 trials using 75\\% subsamples selected randomly from the complete (cleaned) 49,352 records of the rent data set. The error bars show two standard deviations above and below the average (a red error bar indicates it reaches 0 and was sifted to the bottom).  The high variances of the neighborhood features, such as {\\tt brooklynheights} and {\\tt Evillage}, arise because many distance-to-neighborhood features have similar impacts; selection will depend on vagaries of the subsample.\n \n\\setcounter{figure}{7} % wth? i had to set this to get fig 9 not 10\n\\begin{figure}\n\\begin{subfigure}{.49\\textwidth}\n    \\centering\n\\includegraphics[scale=0.6]{images/rent-stability-importance.pdf}\n\\vspace{-2mm}\n\\subcaption{\\simp{} Rent Importance}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{.49\\textwidth}\n    \\centering\n\\includegraphics[scale=0.6]{images/rent-stability-impact.pdf}\n\\vspace{-2mm}\n\\subcaption{\\simp{} Rent Impact}\n\\end{subfigure}%\n\\vspace{-3mm}\n\\captionof{figure}{\\small Average feature importance and impact across 30 trials on the rent data set, with 75\\% subsamples from 49,352 total records.  Error bars show two standard deviations. Red indicates two standard deviations reach zero.}\n\\label{fig:stability}\n\\end{figure}\n\nPerformance is important for practitioners so it is worthwhile analyzing \\simp{} time complexity and demonstrating that it operates in a reasonable amount of time.  The cost of computing each $x_j$'s impact is dominated by the cost of computing the partial dependence but includes a pass over the $x_j$ values to compute the mean. Computing the importance costs an extra pass through the data to get a histogram. The upper bound  complexity for both \\spd{} and \\cspd{} partial dependences is $O(n^2)$ in the worst case, which is  similar to FPD's $O(nm)$ for $n$ records and $m$ curve evaluation points.  In practice, \\spd{} typically performs linearly while \\cspd{} exhibits mildly quadratic behavior.  The overall worst case behavior for \\simp{} is then $O(p n^2)$ to get $p$ impacts and importances.   For comparison purposes, ALE is the most efficient at $O(n)$ per feature and SHAP has the hardest time with efficiency due to the combinatorial problem of feature subsetting. SHAP has model-type-dependent optimizations for linear regression, deep learning, and decision-tree based models, but other models are prohibitively expensive. For example, SHAP applied to a support vector machine trained on the 80\\% Boston training set takes four minutes to explain the 101 records in the 20\\% validation set.\n\n\\begin{table}\\small\n\\centering\n\\begin{tabular}{r r r r r r r r r}\n{\\bf dataset} & $p$ & catvars & {\\small $n$=1,000} & {\\small 10,000} & {\\small 20,000} & {\\small 30,000} & time versus $n$~~ & $R^2$\\\\\n\\hline\n{\\tt\\small flight} & 17 & 6 & 5.7s & 8.9s & 35.5s & 76.0s & {\\small $-0.360 n + 0.095 n^2$} & {\\small 0.9945}\\\\\n{\\tt\\small bulldozer} & 14 & 3 & 0.8s & 3.0s & 11.4s & 24.6s & {\\small $-0.063 n + 0.029 n^2$} & {\\small 0.9961}\\\\\n{\\tt\\small rent} & 20 & 0 & 0.4s & 4.0s & 8.5s & 12.9s & {\\small $0.424 n + 0.000 n^2$} & {\\small 0.9995}\\\\\n\\end{tabular}\n\\vspace{-3mm}\n\\caption{\\small  Execution time for subsets of size 1,000 to 30,000 for rent, bulldozer, flight data sets.  There are a total of 40 numerical and 9 categorical variables: rent, bulldozer, and flight have $p=20$, $p=14$, and $p=17$. Rent has no categorical variables and exhibits linear performance, whereas categorical variables introduce mildly quadratic behavior. Final two columns describe how data fits to quadratic equations. Time does not include Numba just-in-time compiler warm-up, but users do experience this warm-up time.}\n\\label{fig:timing}\n\\end{table}\n\n\\tblref{fig:timing} summarizes the empirical time in seconds to compute importances for a range of subset sizes for the three Kaggle data sets. The ``time versus $n$'' and $R^2$ columns describe a quadratic fit to the curve representing the time (in seconds) required to compute subsets from $n=1$ to 30,000 stepping by 1,000. The rent data set has no categorical variables and grows linearly with $n$. The flight data set, on the other hand, shows quadratic behavior due to the (six) categorical variables. Despite the worst-case complexity, \\tblref{fig:timing} suggests our Python-only \\simp{} prototype is fast enough for use on real data sets of sizes in the tens of thousands. When the cost of training and tuning a model is counted, \\simp{} would likely outperform other techniques.\n\nEach of the $p$ feature impact computations is independent and could proceed in parallel. Unfortunately, our casual attempts at parallelizing the algorithm across multiple CPU cores was thwarted by Python's dreaded ``global interpreter lock'' (threading) or data-passing costs between processes (process-based threading).  We did, however, get increased performance using the Numba just-in-time compiler ({\\tt\\small http://numba.pydata.org}) on algorithm hotspots (at the cost of 5 seconds of compiler warmup time at runtime).\n\n\\cut{\ncost of \\spd{} is cost to train RF then cost to walk leaves and perform piecewise linear approximation for each leaf. Then average the slope-ranges.  piecewise linear approximation is a function of elements in leaf but in total, we are computing differences on all n elements. to average the slopes together, it's a function of how many slopes, which could be n If all values are unique. There are roughly unique x by n slopes in a matrix of values that we collapse to get average slope in a range.  Integrating the slopes, the partial derivatives, is O(unique x). \nBulldozer:\nX.shape=(362781, 14)\nuniq x = 5 slopes.shape = (8112,) x ranges.shape (8112, 2)\nuniq x = 59 slopes.shape = (8242,) x ranges.shape (8242, 2)\nuniq x = 22 slopes.shape = (10145,) x ranges.shape (10145, 2)\nuniq x = 10887 slopes.shape = (23200,) x ranges.shape (23200, 2)\nuniq x = 59 slopes.shape = (8587,) x ranges.shape (8587, 2)\nuniq x = 6 slopes.shape = (2641,) x ranges.shape (2641, 2)\nuniq x = 2 slopes.shape = (3265,) x ranges.shape (3265, 2)\nuniq x = 2 slopes.shape = (3177,) x ranges.shape (3177, 2)\nuniq x = 12 slopes.shape = (15967,) x ranges.shape (15967, 2)\nuniq x = 31 slopes.shape = (28357,) x ranges.shape (28357, 2)\nuniq x = 7 slopes.shape = (11874,) x ranges.shape (11874, 2)\nuniq x = 293 slopes.shape = (32103,) x ranges.shape (32103, 2)\nImpact importance time 61s\n\nRent:\nX.shape=(48299, 20)\nuniq x = 8 slopes.shape = (3436,) x ranges.shape (3436, 2)\nuniq x = 9 slopes.shape = (1027,) x ranges.shape (1027, 2)\nuniq x = 1933 slopes.shape = (11814,) x ranges.shape (11814, 2)\nuniq x = 1364 slopes.shape = (11759,) x ranges.shape (11759, 2)\nuniq x = 3 slopes.shape = (2139,) x ranges.shape (2139, 2)\nuniq x = 3374 slopes.shape = (12159,) x ranges.shape (12159, 2)\nuniq x = 4091 slopes.shape = (12098,) x ranges.shape (12098, 2)\nuniq x = 4585 slopes.shape = (12034,) x ranges.shape (12034, 2)\nuniq x = 4452 slopes.shape = (11968,) x ranges.shape (11968, 2)\nuniq x = 4506 slopes.shape = (12020,) x ranges.shape (12020, 2)\nuniq x = 4473 slopes.shape = (12088,) x ranges.shape (12088, 2)\nuniq x = 4194 slopes.shape = (12029,) x ranges.shape (12029, 2)\nuniq x = 3141 slopes.shape = (12003,) x ranges.shape (12003, 2)\nuniq x = 3440 slopes.shape = (11996,) x ranges.shape (11996, 2)\nuniq x = 4234 slopes.shape = (12005,) x ranges.shape (12005, 2)\nuniq x = 4389 slopes.shape = (12089,) x ranges.shape (12089, 2)\nuniq x = 3598 slopes.shape = (12082,) x ranges.shape (12082, 2)\nuniq x = 42 slopes.shape = (8551,) x ranges.shape (8551, 2)\nuniq x = 355 slopes.shape = (16019,) x ranges.shape (16019, 2)\nuniq x = 29 slopes.shape = (9204,) x ranges.shape (9204, 2)\nImpact importance time 13s\n\nflight has 5,819,080 records.\n}\n\n\n\n\n\\section{Discussion and future work}\\label{sec:discussion}\n\nIn this paper, we propose a nonparametric approach to measuring numerical and categorical feature $x_j$'s impact upon the response variable, $y$, based upon a mathematical definition of impact: the area under $x_j$'s ideal $PD_j$ curve (numerical) or mean-centered $PD_j$ curve (categorical). By weighting $x_j$'s  partial dependence curve with $x_j$'s distribution, we arrive at a mathematical definition of feature importance.  Our goal is not to claim that existing feature selection techniques are incorrect or fail in practice; they very often work well. Instead, we hope to:\n\n\\begin{enumerate}\n\\item Bring attention to the fact that feature importance is not the same as feature impact, because of potential distortions from peering through model $\\hat{f}$. The same importance algorithm applied to the same data can get meaningfully different answers from different fitted models.   For the purpose of gaining insights into the behavior of objects under consideration (such as customers or patients) or the impact of their features, the ideal impact metric would avoid $\\hat{f}$ predictions and operate directly on the data.\\vspace{2mm}\n\n\\item Demonstrate it is possible to compute impacts without relying on predictions from a fitted model, by estimating partial derivatives of the unknown generator function $f$. This approach is valuable because there are large prospective industrial and scientific communities that lack the expertise to choose and tune machine learning models. Model-free importance techniques do exist, but they usually provide just a ranking, rather than meaningful impact values, and often consider associations of the response with just one or two features at a time.\n\\end{enumerate}\n \nTo assess the quality of \\simp's feature impacts, we compared \\simp's recommended feature importance rankings to those of other techniques as a proxy. Despite not having access to predictions from a fitted model nor access to the entire data set, \\simp{} feature rankings are competitive with other rankings from other commonly-used techniques on Boston and three real data sets.  \\figref{fig:topk}c illustrates a case in which \\simp's most important feature choice yields half the error rate of the top features recommended by the other methods.  One would expect model-based techniques to easily identify the single most important model feature, or at least to do so more readily than an approach not using model predictions.  Even if such results are rare, misidentifying this top feature indicates that there is room for improvement in the feature importance research area. \n\nAn interesting and unanticipated result is that simple expedient approaches, such as ranking features by Spearman's R coefficient or permutation importance, perform well at least for the first eight important features in our experiments. (We did not perform experiments on the least important features.) Also, the error curves for SHAP and permutation importance generally mirror each other for the first eight features.  Both techniques introduce potentially nonsensical records to avoid retraining models, but this does not appear to affect their ability to rank features for feature selection purposes.\n\nOur proposed approach relies on accurate partial dependences, and considerable effort has gone into refining the \\spd{} and \\cspd{} partial dependence algorithms currently used by \\simp.  Any improvement in the accuracy of estimation techniques for partial dependence curves would be useful in their own right and particularly helpful for \\simp.  The current prototype is limited to regression and so, next, we hope to develop suitable model-free partial dependence and impact algorithms for classification.\n\n\\cut{\n\\begin{figure}\n\\centering\n\\begin{subfigure}{1\\textwidth}\n    \\centering\n\\includegraphics[scale=0.5]{images/boston-features.pdf}\n\\includegraphics[scale=0.5]{images/boston-features-shap-rf.pdf}\n\\vspace{-2mm}\\subcaption{\\footnotesize Note LSTAT/RM order is diff than in original figure as their is high variance}\\vspace{3mm}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{1\\textwidth}\n    \\centering\n\\includegraphics[scale=0.5]{images/flights-features.pdf}\n\\includegraphics[scale=0.5]{images/flights-features-shap-rf.pdf}\n\\vspace{-2mm}\\subcaption{\\footnotesize 5.8M records}\\vspace{3mm}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}{1\\textwidth}\n    \\centering\n\\includegraphics[scale=0.5]{images/bulldozer-features.pdf}\n\\includegraphics[scale=0.5]{images/bulldozer-features-shap-rf.pdf}\n\\vspace{-2mm}\\subcaption{\\footnotesize foo}\\vspace{3mm}\n\\end{subfigure}%\n\\hfill\n\\begin{subfigure}{1\\textwidth}\n    \\centering\n\\includegraphics[scale=0.5]{images/rent-features.pdf}\n\\includegraphics[scale=0.5]{images/rent-features-shap-rf.pdf}\n\\vspace{-2mm}\\subcaption{\\footnotesize foo}\\vspace{3mm}\n\\end{subfigure}\n\\caption[short]{blorttttt}\n\\label{fig:features}\n\\end{figure}\n}\n\n\\section{Compliance with Ethical Standards}\nFunding: JDW acknowledges partial support by the National Science Foundation grant NSF DMS - 1830547. Conflict of Interest: The authors declare that they have no conflict of interest.\n\\bibliography{pdimp}\n\\end{document}", "meta": {"hexsha": "e56b695af9c077c62c58f4a00af1a89634527c7c", "size": 65136, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "articles/imp/pdimp.tex", "max_stars_repo_name": "parrt/stratx", "max_stars_repo_head_hexsha": "c190ecc32ac7b8dd3f5532a5d5b0de34a3693a22", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 54, "max_stars_repo_stars_event_min_datetime": "2019-07-17T04:59:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T15:25:00.000Z", "max_issues_repo_path": "articles/imp/pdimp.tex", "max_issues_repo_name": "parrt/stratx", "max_issues_repo_head_hexsha": "c190ecc32ac7b8dd3f5532a5d5b0de34a3693a22", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-07-27T16:18:37.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-02T20:16:49.000Z", "max_forks_repo_path": "articles/imp/pdimp.tex", "max_forks_repo_name": "parrt/stratx", "max_forks_repo_head_hexsha": "c190ecc32ac7b8dd3f5532a5d5b0de34a3693a22", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2019-08-08T22:17:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T10:19:23.000Z", "avg_line_length": 96.9285714286, "max_line_length": 1688, "alphanum_fraction": 0.767025915, "num_tokens": 16989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7956581097540519, "lm_q1q2_score": 0.42266104590219733}}
{"text": "We estimate that had states that did not expand Medicaid in 2014 instead expanded their programs, they would have seen a -2.33 (-3.49, -1.16) percentage point change in the adult uninsurance rate. Existing estimates place the ETT between -3 and -6 percentage points. These estimates vary depending on the targeted sub-population of interest, the data used, the level of modeling (individuals or regions), and the modeling approach (see, e.g., \\cite{courtemanche2017early}, \\cite{kaestner2017effects}, \\cite{frean2017premium}). We find that our estimate of the ETC is closer to zero than these ETT estimates. This difference may be a function of these different modeling strategies, or it may suggest that the ETC is smaller in absolute magnitude than the ETC. Regardless, due to the potential for effect heterogeneity, we emphasize the importance of directly estimating the targeted counterfactual of interest (e.g. the ETT or ETC), and being explicit about the assumptions used to estimate these quantities. We now consider our methodological contributions, study limitations, and we conclude by considering the policy implications of these findings.\n\n\\subsection{Methodological considerations}\n\nOur study makes several methodological contributions to the literature on synthetic controls and balancing weights. First, we clarify some of the assumptions required to extend the synthetic controls literature to estimate the treatment effect on the controls. The key challenge is that we need to predict treatment response rather than the outcome absent treatment. We argue that we cannot use pre-treatment outcomes to conduct variable selection or optimally determine relative covariate importance without strong assumptions about the relationship between the counterfactual outcome models. In brief, estimating the ETC is an arguably more difficult problem because it requires a priori understanding of which covariates likely predict treatment response. We emphasize there may exist covariates that are not strong confounders of the outcome absent treatment, but that may be important confounders of the outcome under treatment. Using pre-treatment outcomes to conduct variable selection or determine relative variable importance can result in biased treatment effect estimates. As an example, we consider the role of Republican governance in our application: \\cite{kaestner2017effects} and \\cite{courtemanche2017early} do not balance on these factors when generating their synthetic control weights in their estimates of the effect of Medicaid expansion on uninsurance rates among treated states. By contrast we show that failing to control for this factor in our models leads to substantially larger treatment effect estimates, indicating their confounding role in our counterfactual model.\\footnote{We caution that in actuality these covariates may also be confounders of the outcome absent treatment; we do not directly investigate this.} While perhaps obvious, these points do not seem to have yet been appreciated in the applied literature. For example, \\cite{born2020lockdowns} recently used synthetic controls to estimate Sweden's COVID cases and deaths had they instituted a lockdown. The authors balance on pre-treatment infections, urbanization rate, and population size. Yet they do not explicitly argue why these covariates are the most relevant determinants of the potential outcome model under treatment, or what assumptions they are relying on such that this procedure should produce a good counterfactual estimate.\n\nSecond, our estimation procedure introduces and illustrates the H-SBW objective, which can improve upon the SBW objective when using hierarchical data. Assuming the errors in the outcome model follow the covariance structure posited by \\cite{kloek1981ols}, H-SBW produces a lower variance estimator by more evenly dispersing weights across states. The assumption underlying the particular structure of our objective is that our model errors have constant variance and constant within-state correlation $\\rho$. However, our procedure requires assuming the covariance structure and $\\rho$ in advance. We choose $\\rho = 0.2$ for this application; however, it would be interesting to identify a data-driven approach to choose this tuning parameter (or perhaps for the covariance structure in general). \n\nThird, our estimation procedure accounts for measurement error in our covariates. We modify the constraint set to balance on a linear approximation to the true covariate values by adapting regression-calibration techniques (\\cite{gleser1992importance}) to the balancing weights context. In Table~\\ref{tab:balcomp} we show that the weights calculated on the unadjusted dataset fail to achieve the desired level of covariate balance on the adjusted dataset. Specifically, we find that the weighted pre-treatment outcomes may be lower than we wanted, which we speculate may bias our treatment effect downward. When we compared our estimates using the adjusted covariates to the unadjusted covariates, we find that our point estimates decrease (although often only slightly) in absolute magnitude. Essentially, when we generate weights on the unadjusted data to estimate the 2014 counterfactual outcome, they are likely fitting to noise. This causes the observed level of balance to appear better than it truly is. Meanwhile, the re-weighted region may suffer from regression to the mean in the post-treatment period, making our treatment effect estimates appear larger in absolute magnitude than the truth. Once we adjust for the measurement error, our point estimates decrease in absolute magnitude (see also \\cite{daw2018matching}, who discuss this phenomenon in more detail in the context of difference-in-differences designs). Overall, our study provides a roadmap for future studies that may wish to correct for potential measurement error while using balancing weights. \n\nOne direction for further work is to calibrate this procedure to determine an optimal bias-variance tradeoff with respect to the measurement error. It is possible that the procedure we implemented was sub-optimal with respect to the mean-square error of our estimator. In particular, the bias induced by the measurement error decreases with square root of the sample size used to calculate each CPUMAs covariate values, the minimum of which were over three hundred. Meanwhile, the variance of our counterfactual estimate should decrease with the square root of the number of treated states (of which there are 21). From a theoretical perspective, the variance is of a larger order than the bias; moreover, adjusting for the bias will further increase the variance of the estimator. These concerns are consistent with our observed results: we find that the change in our point estimates from the unadjusted data to the adjusted data are of smaller absolute magnitude than our variance estimate on our point estimate on the unadjusted data. Moreover, once we adjust for the measurement error, our confidence intervals increase more widely than the point estimates change.\n\n\\subsection{Limitations}\n\nOur study is not without methodological limitations. We first caution that we required strong modeling assumptions throughout. In particular, we require SUTVA, no anticipatory treatment effects, no unmeasured confounding conditional on the true covariates, and several parametric assumptions about both the outcome and measurement error models. We were able to address some concerns about possible violations of these assumptions. For example, our results were qualitatively similar whether we excluded possible ``early expansion states,'' or used different weighting strategies (including relaxing the positivity restrictions and changing the tuning parameter $\\rho$). We also examined two versions of our covariate adjustment and found similar results with either.  However, we do not attempt to address concerns about SUTVA violations, particularly the impact of spillovers across regions. And while we believe that no unmeasured confounding is reasonable for this problem, we did not conduct any sensitivity analyses with respect to this assumption.\n\nA second limitation pertains to interpreting our results against the existing literature. As we noted above, prior studies differ with respect to the data used, the targeted population of interest, the modeling choices, and unit level of analysis. To attempt to make our study comparable with existing work, we follow the covariates, study period, and data used most closely by \\cite{courtemanche2017early}, who calculate an ETT estimate of -3.1 percentage points. However, we note two key differences between our studies. First, \\cite{courtemanche2017early} modeled individual-level data, while we model CPUMA-level aggregates. Second, we exclude several states from our expansion pool while \\cite{courtemanche2017early} include all states and DC in their analysis. As a result we do not make any formal statistical claims about the differences between our estimates, or between our estimates and any other specific paper, as they could also be a function of any of these other differences in our study. Relatedly, we caution against committing the ``ecological fallacy:'' specifically, we cannot directly infer individual-level behavior from the ecological correlations in our study without much stronger assumptions (see, e.g., \\cite{subramanian2009revisiting}).\n\n\\subsection{Policy considerations}\n\nWe find that our point estimates for the ETC are  somewhat smaller in absolute magnitude than existing estimates of the ETT. While we make no formal statistical claims about these differences, this finding nevertheless highlights the importance of caution when using estimates of the ETT to make inferences about the ETC. Because almost every outcome of interest is mediated through increasing the number of insured individuals, if the ETC is in fact different than the ETT, then projecting findings from an estimate of the ETT to the ETC may lead to inaccurate inference. For example, \\cite{miller2019medicaid} study the effect of Medicaid expansion on mortality. Using their estimate of the ETT they project that had all states expanded Medicaid, 15,600 deaths would have been avoided during their study's time-period. If we believe that this number increases monotonically with the number of uninsured individuals, this estimate may be an overestimate if the ETC is less than the ETT, or an underestimate if the ETC is greater than the ETT. Directly estimating the ETC can therefore also help us better model policy relevant downstream effects mediated through decreasing the uninsurance rate. \n\nMedicaid expansion is still an ongoing policy debate in the United States. Following the passage of the American Rescue Plan, state legislatures in Wyoming, Alabama, and North Carolina are reportedly considering expanding their programs. Our study estimates the effect of Medicaid expansion on adult uninsurance rates; however, this effect is only interesting because Medicaid enrollment is not automatic for eligible individuals. Different state policies may therefore make it easier or harder to enroll in Medicaid. We again emphasize that if the goal of Medicaid expansion is to increase insurance access for low-income adults, state policy-makers also make wish to make Medicaid enrollment easier. \n\n\\section{Conclusion}\n\nThis is the first study we are aware of that directly estimates the foregone coverage expansions of Medicaid expansion on states that did not expand Medicaid in 2014. Our estimation approach contributes to the methodological literature on synthetic controls by outlining a set of identifying assumptions to estimate the ETC rather than the ETT, and to the balancing weights literature by using an estimation procedure that account for hierarchical data structure and covariates measured with error. We estimate that had states that did not expand their Medicaid eligibility requirements in 2014 done so, they would have seen a -2.33 (-3.49, -1.16) percentage point change in their uninsurance rate. This point estimate is closer to zero than existing estimates of the ETT, which range between -3 and -6 percentage points (\\cite{frean2017premium}). From a practical standpoint, we caution against using using existing estimates of the ETT to make inferences about the ETC. From a policy standpoint, if the goal of Medicaid expansion is to increase access to insurance for low-income adults, state and federal policy-makers may wish to consider policies that make Medicaid enrollment easier if not automatic in addition to eligibility changes.", "meta": {"hexsha": "90c8a4ceb191a404bcfd84ea32edc67cd49fcff8", "size": 12631, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "03_Paper/05-discussion.tex", "max_stars_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_stars_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "03_Paper/05-discussion.tex", "max_issues_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_issues_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "03_Paper/05-discussion.tex", "max_forks_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_forks_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 467.8148148148, "max_line_length": 2336, "alphanum_fraction": 0.8258253503, "num_tokens": 2417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.4226610407543016}}
{"text": "\\documentclass[11pt, oneside]{article}\n\n\\usepackage{../shared/preamble}\n%\\addbibresource{../shared/references.bib}\n\n\\usepackage{minimax}\n\n\\title{The Minimax Algorithm}\n\\author{Arthur Ryman, {\\tt arthur.ryman@gmail.com}}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThis article formalizes the minimax algorithm for playing 2-person games.\nEach player searches graph of moves for an optimal move.\nThis article also formalizes the alpha-beta pruning heuristic for speeding up the search.\n\\end{abstract}\n\n\\section{Games}\n\nFor the purposes of this article, a game is an activity engaged in by one or more players\nwho attempt to win by making moves that lead to a winning state.\n\n\\subsection{Game States $State$}\n\nLet $State$ denote the set of all game states.\n\n\\begin{zed}\n[State]\n\\end{zed}\n\n\\subsection{The Game is Finite and Non-Empty $game\\_is\\_finite$}\n\nWe assume that there are a finite, non-zero number of game states.\nLet $game\\_is\\_finite$ denote this constraint.\n\n\\begin{zed}\nState \\in \\finset_1 State\n\\end{zed}\n\n\\subsection{Start State $start$}\n\nThe game has a unique, distinguished starting state.\nLet $start$ denote the starting game state.\n\n\\begin{axdef}\nstart: State\n\\end{axdef} \n\n\\subsection{Moves $moves$}\n\nA player can select from zero or more moves that are available in any given game state.\nLet $moves$ denote the binary relation on the set of game states that relates a given game state to another\nif and only if the player can move from the given game state to the other.\n\n\\begin{axdef}\nmoves: State \\rel State\n\\end{axdef}\n\n\\subsection{Children $children$}\n\nThe set of all games states that can be reached in one move from a given state\nare called the children of that state.\nLet $children$ denote the mapping from a game state to its children.\n\n\\begin{zed}\nchildren == (\\lambda p: State @ \\{~ c: State | p \\mapsto c \\in moves ~\\}) \n\\end{zed}\n\n\\subsection{Terminal States $terminal$}\n\nA state that has no children is  called a terminal state.\nLet $terminal$ denote the set of all terminal states.\n\n\\begin{zed}\nterminal == \\{~ x: State | children(x)  = \\emptyset ~\\}\n\\end{zed}\n\nThe game terminates when a terminal state is reached.\n\n\\subsection{Terminal Score $terminal\\_score$}\n\nEvery terminal state is assigned a numeric score.\nEach player makes moves that they think will lead to a terminal state that optimizes their score.\n\n\\begin{axdef}\nterminal\\_score: terminal \\fun \\num\n\\end{axdef}\n\n\\subsection{Parents $parents$}\n\nThe set of all games states that a given game state can be reached from in one move\nare called the parents of the given state.\nLet $parents$ denote that mapping from a game state to its parents,\n\n\\begin{zed}\nparents == (\\lambda c: State @ \\{~ p: State | p \\mapsto c \\in moves~\\})\n\\end{zed}\n\n\\subsection{Initial States $initial$}\n\nA state that has no parents is called an initial state.\nLet $initial$ denote the set of initial states.\n\n\\begin{zed}\ninitial == \\{~ x: State | parents(x) = \\emptyset ~\\}\n\\end{zed}\n\n\\subsection{The Start State is an Initial State $start\\_is\\_initial$}\n\nWe assume that the start state has no parents.\nLet $start\\_is\\_initial$ denote this constraint.\n\n\\begin{zed}\nstart \\in initial\n\\end{zed}\n\n\\subsection{Paths $paths$}\n\nA path is a sequence of two or more game states such each pair of successive states are\nrelated by a move.\n\n\\begin{zed}\npaths == \\\\\n\\t1\t\\{~ p: \\seq State | \\# p \\geq 2  \\land \\\\\n\\t2\t\t(\\forall i: 1 \\upto \\# p - 1 @ \\\\\n\\t3\t\t\tp(i) \\mapsto p(i + 1) \\in moves) ~\\}\n\\end{zed}\n\n\\subsection{The Game is Connected $game\\_is\\_connected$}\n\nWe assume that every game state, other than the start state, is connected to the start state\nby a path.\nLet $game\\_is\\_connected$ denote this constraint.\n\n\\begin{zed}\n\\forall s: State | s \\neq start @ \\\\\n\\t1\t\\exists path: paths @ \\\\\n\\t2\t\tpath(1) = start \\land \\\\\n\\t2\t\tpath(\\# path) = s\n\\end{zed}\n\n\\subsection{Cycles $cycles$}\n\nA path that begins and ends on the same state is called a cycle.\nLet $cycle$ denote the set of all cycles.\n\n\\begin{zed}\ncycles == \\{~ p: paths | p(1) = p(\\# p) ~\\}\n\\end{zed}\n\n\\subsection{The Game Has No Cycles $game\\_is\\_acyclic$}\n\nWe assume that the game has no cycles.\nLet $game\\_is\\_acyclic$ denote this constraint.\n\n\\begin{zed}\ncycles = \\emptyset\n\\end{zed}\n\n\\section{2-Person Games}\n\nGames such as tic-tac-toe and chess are played by two players who take turns moving.\n\n\\subsection{Players $Player$}\n\nLet $Player$ denote the set of players.\n\n\\begin{zed}\nPlayer ::= A | B\n\\end{zed}\n\nThe players are denoted by $A$ and $B$ who we can think of as being Alice and Bob.\n\n\\subsection{Who Moves $player$}\n\nThe players take turns moving.\nThe game state determines who moves next.\nLet $player$ denote the mapping from the game state to the player who moves next.\n\n\\begin{axdef}\nplayer: State \\fun Player\n\\end{axdef}\n\n\\subsection{Player $A$ Starts $player\\_A\\_starts$}\n\nWithout loss of generality, we can assume that Alice moves first.\nLet $player\\_A\\_starts$ denote this constraint.\n\n\\begin{zed}\nplayer(start) = A\n\\end{zed}\n\n\\subsection{Players Alternate $players\\_alternate$}\n\nThe players take turns moving.\nLet $players\\_alternate$ denote this constraint.\n\n\\begin{zed}\n\\forall x, y: State | x \\mapsto y \\in moves @ player(x) \\neq player(y)\n\\end{zed}\n\n\\subsection{Optimal Score $optimal\\_score$}\n\nWe assume that the players are playing for money or some other fungible objects.\nThe terminal score of a terminal game state is the amount that Alice wins and Bob loses.\nEquivalently, the negative of a terminal score is the amount that Bob wins and Alice loses.\nEach player tries to optimize their score.\nThus, Alice tries to reach a terminal state that has the highest score while\nBob tries to reach one with the lowest score.\n\nWe can therefore define the optimal score for each state by working backwards from the\nterminal states.\nLet $optimal\\_score$ denote the function that assigns the optimal score to each state.\n\n\\begin{axdef}\noptimal\\_score: State \\fun \\num\n\\where\n\\forall x: terminal @ \\\\\n\\t1\toptimal\\_score(x) = terminal\\_score(x)\n\\also\n\\forall x: State \\setminus terminal | player(x) = A @ \\\\\n\\t1\toptimal\\_score(x) = max \\{~ y: children(x) @ optimal\\_score(y) ~\\}\n\\also\n\\forall x: State \\setminus terminal | player(x) = B @ \\\\\n\\t1\toptimal\\_score(x) = min \\{~ y: children(x) @ optimal\\_score(y) ~\\}\n\\end{axdef}\n\nThis axiomatic description is recursive. \nThe dependency graph of $optimal\\_score$ is the same as the game moves graph.\nHowever, the game is acyclic so we can compute $optimal\\_score$ bottom-up using \na topological sort of the game graph.\nTherefore, $optimal\\_score$ is uniquely defined.\n\n%\\printbibliography\n\n\\end{document}  ", "meta": {"hexsha": "7f0b4153fb370944df18934e327e545befc05238", "size": 6604, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tictactoe_project/docs/minimax/minimax.tex", "max_stars_repo_name": "agryman/sean", "max_stars_repo_head_hexsha": "11baf69c6eb9308266126bf9c8b1c67c6fd33afc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-28T18:17:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-28T18:17:52.000Z", "max_issues_repo_path": "tictactoe_project/docs/minimax/minimax.tex", "max_issues_repo_name": "agryman/sean", "max_issues_repo_head_hexsha": "11baf69c6eb9308266126bf9c8b1c67c6fd33afc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-21T21:33:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-21T21:33:00.000Z", "max_forks_repo_path": "tictactoe_project/docs/minimax/minimax.tex", "max_forks_repo_name": "agryman/sean", "max_forks_repo_head_hexsha": "11baf69c6eb9308266126bf9c8b1c67c6fd33afc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5166666667, "max_line_length": 107, "alphanum_fraction": 0.7342519685, "num_tokens": 1799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438502, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.4223632714418175}}
{"text": "\\documentclass{article}\n\\newsavebox{\\oldepsilon}\n\\savebox{\\oldepsilon}{\\ensuremath{\\epsilon}}\n\\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit\n\\renewcommand*{\\epsilon}{\\usebox{\\oldepsilon}}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx} % For .eps inclusion\n%\\usepackage{indentfirst} % Controls indentation\n\\usepackage[compact]{titlesec} % For regulating spacing before section titles\n\\usepackage{adjustbox} % For vertically-aligned side-by-side minipages\n\\usepackage{array, amsmath,  mhchem}\n\\usepackage{hyper ref}\n\\usepackage{courier, subcaption}\n\\usepackage{multirow, color}\n\\usepackage[autolinebreaks,framed,numbered]{mcode}\n\n\\usepackage{float}\n\\restylefloat{table}\n\n\\pagenumbering{gobble} \n\\setlength\\parindent{0 cm}\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{document}\n\\large\n\n\\section*{Positive feedback}\n\nAll systems that exhibit bistability implement positive feedback. In the mutual repression example, this positive feedback is indirect: protein X increases its own production rate by alleviating repression from Y. The result is that $X$ causes its own \\textit{derepression} -- a form of positive feedback.\\\\\n\nIt's possible to make a bistable switch from a single transcription factor by utilizing positive feedback. Suppose X is a transcriptional activator with a maximum expression rate $\\alpha$ and degradation rate $\\beta$. As previously, the general expression for the rate of change in $x$ is:\n\n\\[ \\frac{dx}{dt} = \\alpha h(x) - \\beta x \\]\n\nwhere $0<h(x)<1$. We'll assume that $x$ binds its own promoter and that production of $x$ scales with the likelihood that $x$ is bound there, which in turn is determined by a Hill curve:\n\n\\[ h(x) = \\frac{x^n}{K + x^n} \\rightarrow  \\frac{x^n}{1 + x^n} \\textrm{  on appropriate choice of units for [X]} \\]\n\nThen the equation for our system is:\n\n\\[ \\frac{dx}{dt} = \\frac{\\alpha x^n}{1 + x^n} - \\beta x \\]\n\nThe fixed points of this system satisfy:\n\n\\[ x = \\frac{\\alpha x^{n}/\\beta }{1 + x^{n}} \\]\n\nBy plotting both the left-hand and right-hand side on one axis, we can see that when $n=1$ and the right-hand side is hyperbolic, then there are two intersections, one at the origin and another at a positive value of x. Only the right-most fixed point is stable.\\\\\n\nIf the right-hand side has a sigmoidal shape (i.e. $n>1$), then it is possible to have one, two, or three points of intersection. Notice that as we increase $\\alpha/\\beta$ from a low value, where we have only one intersection at the origin, a new fixed point appears ``out of the clear blue sky\" at a positive value of $x$. This point is half-stable and quickly gives way to two fixed points, one of which is stable and the other unstable. This is called a \\textit{saddle-node} (or sometimes, ``blue sky\") bifurcation.\n\n\\begin{figure}[htp] \\centering{\n\\includegraphics[width=1 \\textwidth]{pfb1.pdf}}\n\\caption{Illustration of the emergence of a new fixed point as $\\alpha/\\beta$ increases. Hill coefficient $n=2$.} \\label{fig:pfb}\n\\end{figure}\n\nAt this point it may be tempting to conclude that we are done analyzing this system, but as $\\alpha/\\beta$ continues to increase, the middle fixed point slides arbitrarily close to the origin so that (assuming any noise is present) the origin becomes functionally unstable. (Bifurcation diagram.) Systems of this type exhibit hysteresis (review this term).\n\n\n\\section*{The lac operon}\n\nBistable switches like this one were among the first identified in real biological systems. Bacterial cells use it to switch between two gene expression states based on the food sources available. \\textit{E. coli}, for example, are capable of using lactose (a sugar in milk) as a carbon source. To do this, they must invest energy in making transporters that carry lactose (LacY) into the cell as well as enzymes (LacZ) that break lactose into its component simple sugars, glucose and galactose. LacZ and LacY proteins are not useful the vast majority of the time, since lactose is not bacteria's preferred carbon source. However, when lactose is present, the cell must be able to turn on these genes. How does the cell achieve this?\\\\\n\nIn bacteria, genes of related function are often transcribed together on the same mRNA (i.e. in an \\textit{operon}). This means that their expression is regulated by the same promoter. \\textit{lacZ} and \\textit{lacY} are part of the \\textit{lac} operon, which is regulated by a transcriptional repressor called LacI. LacI is bound to the \\textit{lac} operon's promoter most of the time, so that these genes are not expressed. (You may recall that LacI was the first example we used when discussing how transcription factors can bind cooperatively when there are multiple nearby sites.) However, when lactose is present inside the cell, it can bind to LacI and cause this repressor to fall of the \\textit{lac} promoter, allowing LacZ and LacY to be expressed. The lac operon system uses a repressor: does it display positive feedback, and if so, can we shoehorn it into our model?\\\\\n\nThe positive feedback in this system is the result of the lactose transporter, LacY. Suppose a bacterial cell has been growing for a long time in medium without lactose, so that very little LacZ or LacY are being expressed. We add a little lactose to the medium: what happens? With no LacY present, the lactose is impeded from entering the cell. We must add a high enough concentration of lactose that it is able to ``seep in\" before LacI is inhibited and LacZ/Y get expressed. Now LacY will let more lactose into the cell, so more and more LacY will be expressed. Similarly, if we start at a high concentration of lactose and decrease, the \\textit{lac} operon will tend to maintain its expression until [lactose] is very low. (Draw the hysteresis and compare to the positive feedback above.)\\\\\n\nThis is all well and good, but is the Hill equation an appropriate production term for [LacY], i.e.\n\n\\[ \\frac{d\\left[ \\textrm{LacY}\\right]}{dt} = \\alpha h \\left( \\left[ \\textrm{LacY} \\right] \\right) - \\beta \\left[ \\textrm{LacY} \\right]  \\stackrel{?}{=} \\frac{\\alpha \\left[ \\textrm{LacY}\\right]^n}{1 + \\left[ \\textrm{LacY}\\right]^n} - \\beta \\left[ \\textrm{LacY}\\right]\\]\n\nThe easiest way to understand this is to interpret the production term for LacY as a function of the concentration of active repressor, which in turn depends on how much lactose is being admitted by the cell (i.e. [LacY] and [lactose]).\\\\\n\nWe'll assume, as we did on Friday, that the production function $h$ has domain $[0,1]$. It will be one when none of the repressor is active and zero when all of the repressor is bound, hence:\n\n\\[ h \\left( \\left[ \\textrm{LacY} \\right] \\right) = 1 - P\\left( \\textrm{LacI is bound }\\right) =  \\frac{K_i}{K_i + \\left[\\textrm{LacI}_{\\textrm{active}} \\right]} \\]\n\nTechnically we would be well within our rights to assume that this binding of LacI to its operator is cooperative. We know that LacI is a tetramer and that it has multiple binding sites in/near the \\textit{lac} operon's promoter. (Recall that we used it in the ball-and-cup analogy earlier in the course.) However we will see that this cooperativity in LacI binding is not essential for bistability in the lactose response. \\\\\n\nWhat fraction of LacI is active? LacI is a tetramer that becomes inactivated when lactose\\footnote{Technically it is not lactose that inhibits the repressor, but rather one of its metabolic derivatives, allolactose.} binds allosterically to any one of its subunits. For an appropriate choice of lactose concentration units,\n\n\\begin{eqnarray*}\n \\frac{\\left[\\textrm{LacI}_{\\textrm{active}} \\right]}{\\left[\\textrm{LacI}_{\\textrm{total}} \\right]} & = & P\\left( \\textrm{lactose not bound to any subunit} \\right)\\\\\n & = & \\left[ P\\left( \\textrm{lactose not bound to one subunit} \\right) \\right]^4\\\\\n  & = & \\left( \\frac{K_r}{K_r + \\left[ \\textrm{lactose}_{\\textrm{int}} \\right]} \\right)^4\n  \\end{eqnarray*}\n\nThe subscript indicates the \\textit{internal} concentration of lactose. To understand what the internal concentration of lactose will be, we consider how fast lactose is entering the cell and how fast it is being consumed:\n\n\\begin{eqnarray*}\n \\frac{d \\left[ \\textrm{lactose}_{\\textrm{int}} \\right]}{dt} & = & \\frac{k_{\\textrm{cat}} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}} \\right]}{K_m +  \\left[ \\textrm{lactose}_{\\textrm{ext}} \\right]} - \\beta_s  \\left[ \\textrm{lactose}_{\\textrm{int}} \\right]\\\\\n & \\approx & \\frac{k_{\\textrm{cat}}}{K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}} \\right] - \\beta_s  \\left[ \\textrm{lactose}_{\\textrm{int}} \\right]\n \\end{eqnarray*}\n \n Here we have used an approximation that $\\left[ \\textrm{lactose}_{\\textrm{ext}} \\right] \\ll K_m$, i.e., LacY is operating in its first-order regime. If we assume that the internal concentration of lactose is at quasi-steady-state, then we have [lactose$_{\\textrm{int}}$] as a function of [LacY] and [lactose$_{\\textrm{ext}}$]:\n \n \\begin{eqnarray*}\n \\left[ \\textrm{lactose}_{\\textrm{int}} \\right] & = & \\frac{k_{\\textrm{cat}}}{\\beta_s K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}} \\right]\\\\\n \\left[\\textrm{LacI}_{\\textrm{active}} \\right] & = & \\left[\\textrm{LacI}_{\\textrm{total}} \\right] \\left( \\frac{K_r}{K_r + \\left[ \\textrm{lactose}_{\\textrm{int}} \\right]} \\right)^4\\\\\n& = &  \\left[\\textrm{LacI}_{\\textrm{total}} \\right] \\left( \\frac{K_r}{K_r + \\frac{k_{\\textrm{cat}}}{\\beta_s K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}}  \\right]} \\right)^4\\\\\nh \\left( \\left[ \\textrm{LacY} \\right] \\right) & = & \\frac{K_i}{K_i + \\left[\\textrm{LacI}_{\\textrm{active}} \\right]}\\\\\n& = & \\frac{K_i}{K_i + \\left[\\textrm{LacI}_{\\textrm{total}} \\right] \\left( \\frac{K_r}{K_r + \\frac{k_{\\textrm{cat}}}{\\beta_s K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}}  \\right]} \\right)^4}\\\\\n& = & \\frac{K_i \\left( K_r + \\frac{k_{\\textrm{cat}}}{\\beta_s K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}}  \\right] \\right)^4}{K_i \\left( K_r + \\frac{k_{\\textrm{cat}}}{\\beta_s K_m} \\left[ \\textrm{LacY} \\right]  \\left[ \\textrm{lactose}_{\\textrm{ext}}  \\right] \\right)^4 + \\left[\\textrm{LacI}_{\\textrm{total}} \\right] K_r^4  }\n \\end{eqnarray*}\n\nThis is not a Hill function of [LacY]; however, it does have sigmoidal character. Notice that the production level of LacY is never precisely zero, even when there is no external lactose:\n\n\\[ \\left[ \\textrm{lactose}_{\\textrm{ext}}  \\right] \\to 0: \\hspace{2 cm} h\\left(  \\left[\\textrm{LacY}\\right] \\right) \\to  \\frac{K_i}{K_i + \\left[\\textrm{LacI}_{\\textrm{total}} \\right]} \\]\n\nIt turns out to make a big difference that the intercept is positive. Recall that at any fixed point $ \\left[\\textrm{LacY}\\right]_{s-s}$,\n\n\\[  y_1 \\equiv \\left[ \\textrm{LacY} \\right]_{ss} = \\frac{\\alpha}{\\beta} h \\left( \\left[\\textrm{LacY}\\right]_{ss} \\right) \\equiv y_2 \\]\n\nso that the fixed points occur at intersections of $y_1$ and $y_2$. As we increase [lactose$_{\\textrm{ex}}$] from zero, we go from a single intersection (at a low LacY concentration) to two, to three, back to two, and finally to a single steady-state (at a high LacY concentration).  (Draw sample intersections and finally the bifurcation curve.) Unlike when the production term was a Hill function, it is now possible to truly, not just functionally, lose the lower stable state. (Discussion of hysteresis in this system.)\\\\\n\nAlthough this is a canonical result in molecular biology (dating to Novick and Weiner's 1957 paper), the system is still under theoretical consideration (see Ozbudak 2004, Santill\\'{a}n 2007).\\\\\n\n\\section*{Collins Toggle Switch}\n\n\\begin{itemize}\n\n\\item Want to build a mutual repression system with a means for switching between the two states.\n\n\\item Knew that they needed $n>1$ and $\\alpha/\\beta$ greater than a threshold value in order to get bistability.\n\n\\item ``What I cannot build, I do not understand.'' -- Feynman; unclear whether these simplifications of gene regulation would apply generally.\n\n\\item At the time of publication (Gardner 2000), the number of well-characterized repressors, promoters, and RBSes was limited. Needed to try multiple options.\n\n\\item The repressors and the promoters that contain their binding sites are:\n\\begin{itemize}\n\\item LacI binds to P$_{\\textrm{trc2}}$\n\\item The lambda phage repressor cI (``see-one\") binds to P$_{Ls1con}$ \n\\end{itemize}\n\n\\item New genetic constructs are often designed and introduced into hosts on plasmids: small (3-10kb) circular pieces of double-stranded DNA.\n\n\\item Elements of a bacterial plasmid:\n\n\\begin{itemize}\n\\item Origin of replication (tricks host into amplifying the plasmid as if it were its own genome)\n\\item Often no explicit means of segregation between daughter cells (relying on high copy number)\n\\item A marker for selection (e.g. encoding antibiotic resistance, so that only bacteria that maintain a copy of the plasmid can survive in media containing the antiobitic)\n\\item For each gene, a transcriptional promoter, ribosome binding site (not required in eukaryotes), the gene's open reading frame (i.e. the codons that should actually be translated into amino acids), a stop codon, and a transcriptional terminator.\n\\item Optionally in bacteria: multiple RBSes and ORFs per transcriptional promoter/terminator (because operons can encode multiple proteins). A similar approach using ``internal ribosome entry sites\" sort-of works in eukaryotes where IRESes are well-defined.\n\\item Ribosomes have a greater affinity for some RBSes than others. One straightforward way to change the production rate of a protein is to swap out the RBS.\n\\item It is also possible to change a protein's effective expression level by using a temperature-sensitive variant. Essentially these are proteins that contain mutations which place them on the cusp of not folding properly. When the temperature increases above a threshold, they unfold cease to function. (This is true for all proteins, but temperature-sensitive variants undergo this transition at a temperature where most of the organism is still functional.)\n\\end{itemize}\n\n\\item Can add IPTG (isopropyl-$\\beta$-D-1-thiogalactopyranoside, an allolactose analog) to make LacI stop binding. Raising the temperature inactivates cI.\n\n\\item Difference in off rates explained by mechanism (temperaure-induced instability of cI vs. slow dilution of LacI following IPTG addition)\n\n\\end{itemize}\n\\end{document}", "meta": {"hexsha": "fbf021ad8170e3e79b57defcaa5c3fd32646159e", "size": 14432, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/Lecture 11 - Genetic Switches, Natural and Engineered/lecture 11 notes.tex", "max_stars_repo_name": "mewahl/intro-systems-biology", "max_stars_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-01-20T17:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-31T17:23:09.000Z", "max_issues_repo_path": "lectures/Lecture 11 - Genetic Switches, Natural and Engineered/lecture 11 notes.tex", "max_issues_repo_name": "mewahl/intro-systems-biology", "max_issues_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/Lecture 11 - Genetic Switches, Natural and Engineered/lecture 11 notes.tex", "max_forks_repo_name": "mewahl/intro-systems-biology", "max_forks_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-01-20T17:43:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T14:42:10.000Z", "avg_line_length": 94.3267973856, "max_line_length": 881, "alphanum_fraction": 0.7461197339, "num_tokens": 4234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.42236326664325186}}
{"text": "%!TEX root = thesis.tex\n\n\\chapter{Evaluation}\n\\label{ch:Evaluation}\nThe implementation of the I-POMDP framework was evaluated by training a policy for the \\emph{``Where's Waldo?''} game described in Chapter \\ref{ch:IPOMDP} and comparing the performance of the resulting policy to the performance of a greedy policy, a random policy, and a policy that always focuses on the center of the image. \n\nThe policies were trained on a $7 \\times 7$ grid where the grid represents the image and each grid location represents a state and an action, i.e. a location where Waldo can be found in and a location the agent can fixate on. The number of actions available to the agent are therefore equal to the number of states, namely $49$.\n\nBoth observation models mentioned in Section \\ref{sec:ObservationModelImpl} were used to train policies and the default values presented in Section \\ref{sec:PolicyTraining} were used in both cases.\n\n\\section{Training a Policy Using the Exponential Model}\n\\label{sec:PolicyExp}\nThe policy parameters for the policy learned when training with the exponential model for observations can be seen in Figure \\ref{fig:ExpPolicyTheta}. This policy favors fixating on locations where the agent's belief is strong, since the values on the diagonal of the policy parameter matrix\\footnote{See Section \\ref{sec:LogisticPolicies} for an explanation of the policy parameter matrix} are relatively large. An agent using this policy would therefore with a high probability fixate on locations where it beliefs the target is located -- in other words, act greedy.\n\nOn both sides of the diagonal we again notice large parameter values, but not as large as on the diagonal itself. This can be interpreted as the second best choice of fixation. Fixating on locations close to the location where the belief is highest will therefore occur with a high probability. This policy could therefore be interpreted as a greedy policy with a slight tendency for curiosity.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=1\\textwidth]{figures/exp_policy_theta}\n  \\caption{The $49 \\times 49$ policy parameter matrix $\\theta$ trained using the exponential model for observations. \\textbf{Left:} Relatively large values on the diagonal, slightly lower values on both sides of the diagonal. \\textbf{Right:} The heat map shows clearly the two off-diagonal lines and the relatively large diagonal values.}\n  \\label{fig:ExpPolicyTheta}\n\\end{figure}\n\\FloatBarrier\n\n\\noindent\nThe learning curve for the policy can be seen in Figure \\ref{fig:AverageRewardsExp}. It shows that the policy improves fast the first 200 training iterations, as the average rewards in each training iteration get higher and higher (less negative). The policy improvement continues slowly until after around 800 iterations where the learning converges.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{figures/average_rewards_exp_2x}\n  \\caption{Average rewards per training iteration while training a policy using the exponential model for observations.}\n  \\label{fig:AverageRewardsExp}\n\\end{figure}\n\n\\section{Training a Policy Using the Human Eye Model}\nThe policy parameters for the policy learned when training with the human eye model for observations are very different from the parameters learned in Section \\ref{sec:PolicyExp}. Instead of relatively large values on the diagonal, this policy's parameter matrix has less variance in the parameter values but a clear horizontal band of higher values across the middle of it. See Figure \\ref{fig:EyePolicyTheta}.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=1\\textwidth]{figures/eye_policy_theta}\n  \\caption{The $49 \\times 49$ policy parameter matrix $\\theta$ trained using the human eye model for observations. \\textbf{Left:} Relatively large values across the middle part of the parameter matrix and low values near the top and bottom. \\textbf{Right:} Difference between the smallest and largest values not as evident as for the exponential model. Larger values across the center of the matrix.}\n  \\label{fig:EyePolicyTheta}\n\\end{figure}\n\\FloatBarrier\n\n\\noindent\nTo interpret this policy's parameter matrix we first note that on a $7 \\times 7$ grid, location number $25$ would be in the center of the grid. With that in mind we can assume that this policy favors fixating on locations around the center of the image.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{figures/average_rewards_eye_2x}\n  \\caption{Average rewards per training iteration while training a policy using the human eye model for observations.}\n  \\label{fig:AverageRewardsEye}\n\\end{figure}\n\n\\noindent\nThe learning curve for the policy can be seen in Figure \\ref{fig:AverageRewardsEye}. The first thing we notice is that the average rewards per training iteration are higher than during training of the policy in \\ref{sec:PolicyExp}. This comes from the fact that the human eye model for observations has a wider field of view than the exponential model, which only sees a small part of the image very clearly.\n\nThe policy improves steadily for around 1600 iterations and after that the learning converges.\n\n\\section{Performance Comparison}\nThe performance of both learned policies was compared to the performance of a greedy policy, a random policy, and a policy that always focuses on the center of the image. The comparison was performed by simulating the search for ``Waldo'' with each policy $4,900$ times and recording each time how many fixations it took before the agent's highest belief matched the true location of ``Waldo''.\n\n\\subsection{Policy Using an Exponential Model}\nAll the policies perform similarly for the first 5 fixations, with the trained policy performing slightly better than the others, but after 6 fixations the random policy performs best. The exponential model for observations has a very narrow view and therefore does not fully exploit the potential of the I-POMDP algorithm. For each fixation the agent can only obtain reliable information about the image from the exact location it is fixating on, while the information in the surrounding locations is very noisy. This can make the agent's belief unreliable. As mentioned in Section \\ref{sec:PolicyExp} this policy is very similar to the greedy policy and using a greedy policy when the belief is unreliable will result in poor performance. The trained policy is however a stochastic policy and therefore performs better than the greedy policy. The random policy benefits from the fact that it is not dependent on the noisy belief. It should also be noted that a policy that does not fixate on every location will eventually perform worse than random.\n\nThe comparison of the policies using the exponential model for observations can be seen in Figure \\ref{fig:PolicyComparisonExp}.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{figures/policy_comparison_exp2}\n  \\caption{Performance comparison of policies using the exponential model for observations.}\n  \\label{fig:PolicyComparisonExp}\n\\end{figure}\n\n\\subsection{Policy Using a Human Eye Model}\nThe human eye model for observations has a wider view than the exponential model and therefore the agent can not only obtain reliable information about the image from the location it fixates on, but also the locations surrounding it. This gives the trained policy an advantage because it exploits the potential of the I-POMDP algorithm. For this reason the trained policy outperforms the other policies as can be seen in Figure \\ref{fig:PolicyComparisonEye}.\n\n\\begin{figure}[!htp]\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{figures/policy_comparison_eye2}\n  \\caption{Performance comparison of policies using the human eye model for observations.}\n  \\label{fig:PolicyComparisonEye}\n\\end{figure}\n\n\\noindent\nThe greedy policy proves to be a poor strategy in this case as well.\n", "meta": {"hexsha": "4c120fc8d84480d9022c41d571581d8f499ad240", "size": 7909, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch_evaluation.tex", "max_stars_repo_name": "bjorgvino/kth-thesis", "max_stars_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch_evaluation.tex", "max_issues_repo_name": "bjorgvino/kth-thesis", "max_issues_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch_evaluation.tex", "max_forks_repo_name": "bjorgvino/kth-thesis", "max_forks_repo_head_hexsha": "8d8063c119e8472ae6db503d9534a7147cc180ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.875, "max_line_length": 1051, "alphanum_fraction": 0.8035149829, "num_tokens": 1743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.42236326664325186}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx,caption}\n\\graphicspath{ {./images/} }\n\\usepackage{float}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage[unicode]{hyperref}\n\\usepackage{amsmath}\n\n\\title{Homework 1 - Theory}\n\\author{Dainese Fabio, 857661}\n\\date{March 15, 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Exercise 1}\n    \\begin{figure}[H]\n        \\centering\n        \\begin{minipage}[b]{0.25\\textwidth}\n            \\includegraphics[width=\\textwidth]{1.png}\n            \\subcaption{Undirected graph}\n            \\label{fig:figure-1-a}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.5\\textwidth}\n            \\includegraphics[width=\\textwidth]{2.png}\n            \\subcaption{Undirected graph}\n            \\label{fig:figure-1-b}\n        \\end{minipage}\n        \\label{fig:figure-1}\n    \\end{figure}\n    \n    \\subsection{Answers About Graph 'a'}\n    The degree of each vertex is:\n    \\begin{align*}\n    d(v_{1}) &= |N(v_{1})|-1 =|\\{v_{1},v_{2},v_{3},v_{4}\\}|-1 = 4 - 1 = 3\\\\\n    d(v_{2}) &= |N(v_{2})|-1 =|\\{v_{1},v_{2},v_{3}\\}|-1 = 3 - 1 = 2\\\\\n    d(v_{3}) &= |N(v_{3})|-1 =|\\{v_{1},v_{2},v_{3}\\}|-1 = 3 - 1 = 2 \\\\\n    d(v_{4}) &= |N(v_{4})|-1 =|\\{v_{1},v_{4}\\}|-1 = 2 - 1 = 1\n    \\end{align*}\n\n    \\par\\noindent The even vertices are \\(\\{v_{2},v_{3}\\}\\).\\newline\n    \n    \\par\\noindent The average degree is:\n    \\[\n    Ad(G) = \\frac{1}{|V|} \\sum_{v \\in V} d(v) = \\frac{1}{4} \\cdot (3+2+2+1) = \\frac{1}{4} \\cdot 8 = 2\n    \\]\n    \n    \\subsection{Answers About Graph 'b'}\n    The degree of each vertex is:\n    \\begin{align*}\n    d(v_{1}) &= |N(v_{1})|-1 =|\\{v_{1},v_{2},v_{4}\\}|-1 = 3 - 1 = 2\\\\\n    d(v_{2}) &= |N(v_{2})|-1 =|\\{v_{1},v_{2},v_{3},v_{4},v_{5}\\}|-1 = 5 - 1 = 4\\\\\n    d(v_{3}) &= |N(v_{3})|-1 =|\\{v_{2},v_{3}\\}|-1 = 2 - 1 = 1 \\\\\n    d(v_{4}) &= |N(v_{4})|-1 =|\\{v_{1},v_{2},v_{4},v_{5}\\}|-1 = 4 - 1 = 3 \\\\\n    d(v_{5}) &= |N(v_{5})|-1 =|\\{v_{2},v_{4},v_{5}\\}|-1 = 3 - 1 = 2 \\\\\n    d(v_{6}) &= 0\n    \\end{align*}\n\n    \\par\\noindent The even vertices are \\(\\{v_{1},v_{2},v_{5},v_{6}\\}\\).\\newline\n    \n    \\par\\noindent The average degree is:\n    \\[\n    Ad(G) = \\frac{1}{|V|} \\sum_{v \\in V} d(v) = \\frac{1}{6} \\cdot (2+4+1+3+2+0) = \\frac{1}{6} \\cdot 12 = 2\n    \\]\n    \n\\section{Exercise 2}\n    \\begin{figure}[H]\n        \\centering\n        \\begin{minipage}[b]{0.3\\textwidth}\n            \\includegraphics[width=\\textwidth]{3.png}\n            \\subcaption{Undirected graph}\n            \\label{fig:figure-2-a}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.5\\textwidth}\n            \\includegraphics[width=\\textwidth]{4.png}\n            \\subcaption{Undirected graph}\n            \\label{fig:figure-2-b}\n        \\end{minipage}\n        \\label{fig:figure-2}\n    \\end{figure}\n    \n    \\subsection{Answers About Graph 'a'}\n    There aren't isolated vertices (i.e. vertices with \\(d(v)=0\\)).\\newline\n    \n    \\par\\noindent The graph is not complete (proof by counterexample: \\(v_{2}\\) and \\(v_{5}\\) are not adjacent).\\newline\n    \n    \\par\\noindent A path from \\(v_{1}\\) to \\(v_{5}\\) is \\{\\(e_{1}\\)\\}, where \\(e_{1} = \\{v_{1},v_{5}\\}\\).\\newline\n    \n    \\par\\noindent The graphs is connected since there exists a path from \\(v\\) to \\(w\\), \\(\\forall v,w \\in V\\).\\newline\n    \n    \\par\\noindent The connected components of \\(v_{1}\\) and \\(v_{3}\\) are:\n    \\[\n    C_{v_{1}} = C_{v_{3}} = \\{v_{1},v_{2},v_{3},v_{4},v_{5}\\}\n    \\]\n    \\newline\n    \n    \\par\\noindent The adjacent matrix associated to the graph is:\n    \\begin{equation*}\n    A =\n        \\begin{bmatrix}\n        0 & 1 & 1 & 1 & 1\\\\\n        1 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0\\\\\n        \\end{bmatrix}\n    \\end{equation*}\n    \n    \\subsection{Answers About Graph 'b'}\n    There's only one isolated vertex and that is \\(v_{4}\\), since \\(d(v_{4})=0\\).\\newline\n    \n    \\par\\noindent The graph is not complete (proof by counterexample: \\(v_{1}\\) and \\(v_{5}\\) are not adjacent).\\newline\n    \n    \\par\\noindent A path from \\(v_{1}\\) to \\(v_{5}\\) is \\{\\(e_{1},e_{2}\\)\\}, where \\(e_{1} = \\{v_{1},v_{2}\\}\\) and \\(e_{2} = \\{v_{2},v_{5}\\}\\).\\newline\n    \n    \\par\\noindent The graphs is not connected since there's not exists a path from \\(v\\) to \\(w\\), \\(\\forall v,w \\in V\\), for example from \\(v_{2}\\) and \\(v_{3}\\).\\newline\n    \n    \\par\\noindent The connected components of \\(v_{1}\\) and \\(v_{3}\\) are:\n    \\begin{align*}\n    C_{v_{1}} &= \\{v_{1},v_{2},v_{5},v_{6}\\} \\\\\n    C_{v_{3}} &= \\{v_{3},v_{7}\\}\n    \\end{align*}\n    \n    \\par\\noindent The adjacent matrix associated to the graph is:\n    \\begin{equation*}\n    A =\n        \\begin{bmatrix}\n        0 & 1 & 0 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 1 & 1 & 0\\\\\n        0 & 0 & 0 & 0 & 0 & 0 & 1\\\\\n        0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n        0 & 1 & 0 & 0 & 0 & 1 & 0\\\\\n        0 & 1 & 0 & 0 & 1 & 0 & 0\\\\\n        0 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n        \\end{bmatrix}\n    \\end{equation*}\n    \n\\section{Exercise 3}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.3\\textwidth]{5.png}\n        \\caption{Directed graph}\n        \\label{fig:figure-3}\n    \\end{figure}\n    \n    The vertex set of the graph is: \\[V=\\{v_{1},v_{2},v_{3},v_{4}\\}\\]\n    \n    \\par\\noindent The edge set of the graph is:\n    \\[E=\\{(v_{1},v_{2}),(v_{2},v_{3}),(v_{3},v_{1}),(v_{3},v_{4}),(v_{4},v_{3})\\}\\]\n    \n    \\par\\noindent The adjacent matrix associated to the graph is:\n    \\begin{equation*}\n    A =\n        \\begin{bmatrix}\n        0 & 1 & 0 & 0\\\\\n        0 & 0 & 1 & 0\\\\\n        1 & 0 & 0 & 1\\\\\n        0 & 0 & 1 & 0\\\\\n        \\end{bmatrix}\n    \\end{equation*}\n    \n    \\par\\noindent The in (\\(d^{+}(v)\\)), out (\\(d^{-}(v)\\)) and total degree (\\(d(v)\\)) of each node is:\n    \\begin{align*}\n    d^{+}(v_{1}) &= |N^{+}(v_{1})|-1 = |\\{v_{1},v_{3}\\}|-1 = 2-1 = 1\\\\\n    d^{-}(v_{1}) &= |N^{-}(v_{1})|-1 = |\\{v_{1},v_{2}\\}|-1 = 2-1 = 1\\\\\n    d(v_{1}) &= d^{+}(v_{1}) + d^{-}(v_{1}) = 1+1 = 2\\\\\\\\\n    d^{+}(v_{2}) &= |N^{+}(v_{2})|-1 = |\\{v_{1},v_{2}\\}|-1 = 2-1 = 1\\\\\n    d^{-}(v_{2}) &= |N^{-}(v_{2})|-1 = |\\{v_{2},v_{3}\\}|-1 = 2-1 = 1\\\\\n    d(v_{2}) &= d^{+}(v_{2}) + d^{-}(v_{2}) = 1+1 = 2\\\\\\\\\n    \\end{align*}\n    \\begin{align*}\n    d^{+}(v_{3}) &= |N^{+}(v_{3})|-1 = |\\{v_{2},v_{3},v_{4}\\}|-1 = 3-1 = 2\\\\\n    d^{-}(v_{3}) &= |N^{-}(v_{3})|-1 = |\\{v_{1},v_{3},v_{4}\\}|-1 = 3-1 = 2\\\\\n    d(v_{3}) &= d^{+}(v_{3}) + d^{-}(v_{3}) = 2+2 = 4\\\\\\\\\n    d^{+}(v_{4}) &= |N^{+}(v_{4})|-1 = |\\{v_{3},v_{4}\\}|-1 = 2-1 = 1\\\\\n    d^{-}(v_{4}) &= |N^{-}(v_{4})|-1 = |\\{v_{3},v_{4}\\}|-1 = 2-1 = 1\\\\\n    d(v_{4}) &= d^{+}(v_{4}) + d^{-}(v_{4}) = 1+1 = 2\\\\\\\\\n    \\end{align*}\n    \n    \\par\\noindent One of many possible paths that can be found in the graph is for example the one from \\(v_{1}\\) to \\(v_{3}\\) defined as \\((e_{1},e_{2})\\), where \\(e_{1}=(v_{1},v_{2})\\) and \\(e_{2}=(v_{2},v_{3})\\).\n\n\\section{Exercise 4}\n    \\begin{figure}[H]\n        \\centering\n        \\begin{minipage}[b]{0.5\\textwidth}\n            \\includegraphics[width=\\textwidth]{6.png}\n            \\label{fig:figure-4-a}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.4\\textwidth}\n            \\includegraphics[width=\\textwidth]{7.png}\n            \\label{fig:figure-4-b}\n        \\end{minipage}\n        \\label{fig:figure-1}\n    \\end{figure}\n    \n    These two graphs are not isomorphic. In this case a simple way to prove it is to compare the list of vertex degree of the two given graphs.\n    \n    \\begin{align*}\n        G_{1} &= \\{2,2,3,3,3,3,4\\}\\\\\n        G_{2} &= \\{2,3,3,3,3,4,4\\}\n    \\end{align*}\n    \n    \\noindent As you can see \\(G_{1}\\) and \\(G_{2}\\) are not identical, thus the two graphs are not isomorphic.\\newline\n    Another simpler way to prove it is to compare the cardinalities of the two edge sets, i.e. \\(|E_{1}| \\neq |E_{2}| \\implies\\) No isomorphic.\n    \n\\section{Exercise 5}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.35\\textwidth]{8.png}\n        \\label{fig:figure-5}\n    \\end{figure}\n    \n    The distances, i.e. the minimum path length between two vertices, of \\(d(v_{1},v_{2})\\), \\(d(v_{1},v_{3})\\) and \\(d(v_{1},v_{4})\\) are all equal to 2.\\newline\n    \n    \\par\\noindent The diameter of the given graph is equals to 3, recalling that the diameter is the maximum between all the possible distances of the graph's vertices.\\newline\n    \n    \\par\\noindent The centers of the given graphs are \\(v_{1}\\), \\(v_{3}\\) and the middle vertex (the 'inside' vertex), recalling that a vertex \\(u\\) is a centre of a graph \\(G\\) if its maximum distance from any other vertex \\(v\\) is minimum.\\newline\n    \n    \\par\\noindent The radius of this graph is equals to 2 (maximum distance between the centers and the rest of the vertices).\n    \n\\section{Exercise 6}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.7\\textwidth]{9.png}\n        \\label{fig:figure-6}\n    \\end{figure}\n    \n    In the given graph there are three cut points as shown in the following images (red vertices):\n    \n    \\begin{figure}[H]\n        \\centering\n        \\begin{minipage}[b]{0.4\\textwidth}\n            \\includegraphics[width=\\textwidth]{9.1.png}\n            \\label{fig:figure-6-1}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.4\\textwidth}\n            \\includegraphics[width=\\textwidth]{9.2.png}\n            \\label{fig:figure-6-2}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.4\\textwidth}\n            \\includegraphics[width=\\textwidth]{9.3.png}\n            \\label{fig:figure-6-3}\n        \\end{minipage}\n    \\end{figure}\n    \n    \\noindent By removing the first cut point, we obtain the following situation:\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{9.4.png}\n        \\label{fig:figure-6-4}\n    \\end{figure}\n    \\noindent In this configuration the connected component of \\(v\\) and \\(w\\) are:\n    \\begin{align*}\n        C_{v} &= \\{A,V\\}\\\\\n        C_{w} &= \\{C,D,E,F,G,W\\}\n    \\end{align*}\n    \n    \\noindent Meanwhile if we remove the second cut point, we obtain the following situation:\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{9.5.png}\n        \\label{fig:figure-6-5}\n    \\end{figure}\n    \\noindent In this configuration the connected component of \\(v\\) and \\(w\\) are:\n    \\begin{align*}\n        C_{v} &= \\{A,B,V\\}\\\\\n        C_{w} &= \\{D,E,F,G,W\\}\n    \\end{align*}\n    \n    \\noindent Finally if we remove the third cut point, we obtain the following situation:\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{9.6.png}\n        \\label{fig:figure-6-6}\n    \\end{figure}\n    \\noindent In this configuration the connected component of \\(v\\) and \\(w\\) are:\n    \\begin{align*}\n        C_{v} &= \\{A,B,C,V\\}\\\\\n        C_{w} &= \\{W\\}\n    \\end{align*}\n    \n\\section{Exercise 7}\n    \\begin{figure}[H]\n        \\centering\n        \\begin{minipage}[b]{0.2\\textwidth}\n            \\includegraphics[width=\\textwidth]{10.1.png}\n            \\subcaption{}\n            \\label{fig:figure-7-1}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.3\\textwidth}\n            \\includegraphics[width=\\textwidth]{10.2.png}\n            \\subcaption{}\n            \\label{fig:figure-7-2}\n        \\end{minipage}\n        \\hfill\n        \\begin{minipage}[b]{0.4\\textwidth}\n            \\includegraphics[width=\\textwidth]{10.3.png}\n            \\subcaption{}\n            \\label{fig:figure-7-3}\n        \\end{minipage}\n    \\end{figure}\n    \n    The \\(a\\) and \\(b\\) graphs are trees.\\newline\n    \\par\\noindent The \\(a\\),\\(b\\) and \\(c\\) graphs are forests.\\newline\n    \\par\\noindent The \\(b\\) graph is a binary tree. Also \\(a\\) can be a binary three if we consider as a root the middle node.\\newline\n    \n\\section{Exercise 8}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.35\\textwidth]{11.png}\n        \\label{fig:figure-8}\n    \\end{figure}\n    \n    The adjacent matrix of the graph is:\n    \\begin{equation*}\n    A =\n        \\begin{bmatrix}\n        0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n        0 & 0 & 0 & 0 & 1 & 1 & 0 & 0\\\\\n        0 & 1 & 0 & 0 & 1 & 0 & 0 & 0\\\\\n        0 & 0 & 1 & 1 & 0 & 0 & 1 & 0\\\\\n        0 & 0 & 1 & 0 & 0 & 0 & 1 & 1\\\\\n        0 & 0 & 0 & 0 & 1 & 1 & 0 & 1\\\\\n        0 & 0 & 0 & 0 & 0 & 1 & 1 & 0\\\\\n        \\end{bmatrix}\n    \\end{equation*}\n    \n    \\noindent The number of chains of length 2 and 4 are:\n    \\begin{align*}\n        A^{2} = A \\cdot A &= \n        \\begin{bmatrix}\n        1 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n        0 & 2 & 0 & 0 & 1 & 0 & 0 & 0\\\\\n        0 & 0 & 2 & 1 & 0 & 0 & 2 & 1\\\\\n        1 & 0 & 1 & 2 & 0 & 0 & 1 & 0\\\\\n        0 & 1 & 0 & 0 & 3 & 2 & 0 & 1\\\\\n        0 & 0 & 0 & 0 & 2 & 3 & 1 & 1\\\\\n        0 & 0 & 2 & 1 & 0 & 1 & 3 & 1\\\\\n        0 & 0 & 1 & 0 & 1 & 1 & 1 & 2\n        \\end{bmatrix}\\\\\n        A^{4} = A \\cdot A \\cdot A \\cdot A &= \n        \\begin{bmatrix}\n        2 & 0 & 1 & 3 & 0 & 0 & 1 & 0\\\\\n        0 & 5 & 0 & 0 & 5 & 2 & 0 & 1\\\\\n        1 & 0 & 10 & 6 & 1 & 3 & 12 & 6\\\\\n        3 & 0 & 6 & 7 & 0 & 1 & 7 & 2\\\\\n        0 & 5 & 1 & 0 & 15 & 13 & 3 & 7\\\\\n        0 & 2 & 3 & 1 & 13 & 15 & 7 & 8\\\\\n        1 & 0 & 12 & 7 & 3 & 7 & 16 & 8\\\\\n        0 & 1 & 6 & 2 & 7 & 8 & 8 & 8\n        \\end{bmatrix}\n    \\end{align*}\n    \n    \\noindent Which, by summing all the elements of \\(A^{2}\\) gives 44 possible chains of length 2, meanwhile by summing all the elements of \\(A^{4}\\) gives 272 possible chains of length 4.\\newline\n    \n    \\par\\noindent Assuming the given bijection \\(\\phi\\) of the task, the resulting permutation matrix \\(P_{\\phi}\\) is:\n    \n    \\[\n    P_{\\phi}=\n    \\begin{bmatrix}\n        0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n        0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\\\\n        0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n        0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\\\\n        0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\\\\n        0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\\\\n        0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\\\\n    \\end{bmatrix}\n    \\]\n    \n    \\noindent As before to calculate the chains of length 2 and 4 of the relabelled graph we need to perform \\(\\widetilde{A^{2}}\\) and \\(\\widetilde{A^{4}}\\), which gives 44 possible chains of length 2 and 272 of length 4 (as before). To recall that now the adjacent matrix is: \n    \\[\n    \\widetilde{A}=\n    \\begin{bmatrix}\n        0 & 1 & 0 & 1 & 0 & 0 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n        0 & 0 & 0 & 0 & 1 & 1 & 0 & 0\\\\\n        1 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\\\\n        0 & 0 & 1 & 0 & 0 & 0 & 1 & 1\\\\\n        0 & 0 & 1 & 1 & 0 & 0 & 1 & 0\\\\\n        0 & 0 & 0 & 0 & 1 & 1 & 0 & 1\\\\\n        0 & 0 & 0 & 0 & 1 & 0 & 1 & 0\\\\\n    \\end{bmatrix}\n    \\]\n    \n\\section{Exercise 9}\nBy defining a \"Null Graph\" as a graph \\(G=(V,E)\\) with \\(n\\) vertices and \\(E = \\O\\), we have:\n\n\\begin{itemize}\n    \\item The number of edges equal to zero (\\(|E|=0\\));\n    \\item Only 1 face (outer face/region);\n    \\item A graph that can be drawn on a plane without edges crossing is called planar, meaning that also our \"null graph\" is a planar graph;\n    \\item The value of \\(|V|-|E|+|F|\\) is equals to \\(n+1\\), since \\(|V|=n\\),\\(|E|=0\\) and \\(|F|=1\\);\n    \\item The Euler's formula (\\(|V|-|E|+|F|= 2\\)) can't be applied to the \"null graph\" since it's not connected (unless \\(|V|=1\\)).\n\\end{itemize}\n\n\\section{Exercise 10}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{12.png}\n        \\label{fig:figure-9}\n    \\end{figure}\n    \n    The leaves of the previous graph, with \\(r\\) as root, are \\(\\{v_{2},v_{3},v_{7},v_{8},v_{11},v_{12}\\}\\).\n    \n\\end{document}\n", "meta": {"hexsha": "bf8a22b89dbf252baba347489352df49d868a0b7", "size": 15566, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignments/Task 1/Source Solution/main.tex", "max_stars_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_stars_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-27T13:28:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-26T15:53:47.000Z", "max_issues_repo_path": "Assignments/Task 1/Source Solution/main.tex", "max_issues_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_issues_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignments/Task 1/Source Solution/main.tex", "max_forks_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_forks_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2392344498, "max_line_length": 277, "alphanum_fraction": 0.5014133368, "num_tokens": 6176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.422328506278337}}
{"text": "\\subsubsection{Variables}\r\nHere we describe the variables used in this section. \r\n\r\n\\begin{center}\r\n\t\\begin{tabular}{lp{14cm}}\r\n    $A, B$      & Participants Alice and Bob.\\\\\r\n    \\\\\r\n    $pk_A$      & The public key belonging to Alice.\\\\\r\n    $sk_A$      & The secret key belonging to Alice.\\\\\r\n                & Note: there are several (secret key, public key) pairs in this protocol)\\\\\r\n    \\\\\r\n\t\t$E_A$       & The Ethereum address of Alice.\\\\\r\n\t\t$\\Xi_{A,i}$ & An `anonymous' Ethereum address belonging to Alice, where $i\\in\\mathbb{N}$ is an index, for distinguishing between multiple anonymous addresses. \\\\\r\n    \\\\\r\n    $\\alpha$    & A unique representation of some non-fungible asset e.g. a tokenId in ERC-721.\\\\\r\n                & Note that in respect of non-fungible tokens, Nightfall currently focusses solely ERC-721 tokens.\r\n                  It would be relatively simple to adapt Nightfall's application to deal with other non-fungible token standards.\\\\\r\n    $\\alpha_A$  & A non-fungible asset $\\alpha$ that is in Alice's possession. \\\\\r\n    \\\\\r\n\t\t$\\sigma$      & A salt used to provide uniqueness to commitment preimages.\\\\\r\n\t\t$\\sigma_{\\vec{AB}}$ & Stresses that a salt is being shared privately from Alice to Bob.\\\\\r\n    \\\\\r\n\t\t$Z$         & An ERC-721 commitment; a zero-knowledge commitment representing ownership of some underlying ERC-721 asset. \\\\\r\n    $Z_A$       & Stresses that an ERC-721 commitment belongs to Alice.\\\\\r\n    $Z_{\\alpha}$ & Stresses that an ERC-721 commitment represents the asset $\\alpha$.\\\\\r\n    $Z_{l}$     & Stresses that an ERC-721 commitment is the $l^{th}$ leaf of a Merkle Tree (see below for $M$).\\\\\r\n                & Note that the meaning of these (seemingly colliding or ambiguous) subscripts will be clear from context.\\\\\r\n    \\\\\r\n    $N$         & A nullifier for an ERC-721 commitment $Z$.\\\\\r\n    $N_A$       & A nullifier for the ERC-721 commitment $Z_A$.\\\\\r\n    $N_{\\alpha}$ & A nullifier for the ERC-721 commitment $Z_{\\alpha}$.\\\\\r\n    \\\\\r\n\t\t$M$         & A binary Merkle Tree.\\\\\r\n    $M_l$       & A binary Merkle Tree with $l$ non-zero leaves (where leaves are populated in order `from left to right').\\\\\r\n    $\\roott_l$    & The root of $M_l$ (`$M$' is omitted because context will be clear).\\\\\r\n    \\\\\r\n    $\\phi_{L}$  & $[\\phi_{L}(d-1), \\phi_{L}(d-2),..., \\phi_{L}(1), \\phi_{L}(0)]$ - The path from a leaf $L$ to the root of a Merkle Tree $M$, where $\\phi_L(0) = \\roott$.\\\\\r\n    $\\phi$      & $[\\phi_{d-1}, \\phi_{d-2},..., \\phi_{1}, \\phi_0]$ - Alternative notation for the path from a leaf, where the leaf $L$ is clear from the context. $\\phi_0 = \\roott$.\\\\\r\n    $\\psi_{L}$  & $[\\psi_{L}(d-1), \\psi_{L}(d-2),..., \\psi_{L}(1), \\psi_{L}(0)]$ - The sister-path from a leaf $L$ to the root of a Merkle Tree $M$, where $\\psi_L(0) = \\phi_L(0) = \\roott$.\\\\\r\n    $\\psi$      &  $[\\psi_{d-1}, \\psi_{d-2},..., \\psi_{1}, \\psi_0]$ - Alternative notation for the sister-path from a leaf, where the leaf $L$ is clear from the context. $\\psi_0 = \\roott$.\\\\\r\n    \\\\\r\n\t\t$x$         & Public inputs to a zk-SNARK. \\\\\r\n\t\t$\\omega$    & Private inputs to a zk-SNARK.\\\\\r\n\t\t$C$         &  An arithmetic circuit $C: (\\omega, x) \\to \\{0,1\\}$.\\\\\r\n\t\t$p_C$       & A proving key for the circuit $C$. (Not to be confused with $pk$ which denotes a public key). \\\\\r\n\t\t$vk_C$      & A verification key for the circuit $C$. \\\\\r\n    $\\pi(p_C, x, \\omega)$ & A proof for the circuit $C$, public inputs $x$, and private inputs $\\omega$ \\\\\r\n    $\\pi_{C, x, \\omega}$ & An abbreviation of the above. \\\\\r\n    $\\pi$       & An abbreviation of the above, when the context of the proof is clear. \\\\\r\n    \\\\\r\n    $h()$       & A one-way hashing function. Nightfall currently uses sha256 hashing throughout.\\\\\r\n\t\\end{tabular}\r\n\\end{center}", "meta": {"hexsha": "9848fa7c1a2f1cfa050d50834f3bfdc3c6c73a9c", "size": 3756, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/whitepaper/protocols/ERC721/variables721.tex", "max_stars_repo_name": "roggerJose/nightfall", "max_stars_repo_head_hexsha": "59d7d83bcaf920bbf7c7427d14b5fcdb7e53843c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 893, "max_stars_repo_stars_event_min_datetime": "2019-04-16T18:49:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T20:02:38.000Z", "max_issues_repo_path": "doc/whitepaper/protocols/ERC721/variables721.tex", "max_issues_repo_name": "roggerJose/nightfall", "max_issues_repo_head_hexsha": "59d7d83bcaf920bbf7c7427d14b5fcdb7e53843c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 292, "max_issues_repo_issues_event_min_datetime": "2019-05-06T12:08:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T11:16:49.000Z", "max_forks_repo_path": "doc/whitepaper/protocols/ERC721/variables721.tex", "max_forks_repo_name": "roggerJose/nightfall", "max_forks_repo_head_hexsha": "59d7d83bcaf920bbf7c7427d14b5fcdb7e53843c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 161, "max_forks_repo_forks_event_min_datetime": "2019-05-28T15:33:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T10:29:50.000Z", "avg_line_length": 70.8679245283, "max_line_length": 191, "alphanum_fraction": 0.6017039404, "num_tokens": 1154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4223020047509994}}
{"text": "%==============================================================================\n\\chapter{Model emulation, fitting and uncertainty \nquantification}\\label{cha:chapter3}\n%==============================================================================\n%\n%\n%\n\\begin{remark}{Outline}\n    In this chapter, we describe the methods we used for model emulation, fitting and uncertainty quantification. First, the full multi-scale $3$D biventricular rat heart contraction model is represented as a nonlinear mapping between selected input parameters and scalar output features of interest (Section~\\ref{sec:ch3multiscalemap}). Second, the nonlinear mapping is emulated using probabilistic surrogates based on Gaussian process emulation (Section~\\ref{sec:ch3gaussianprocessemulation}). Finally, two applications of emulators are presented: the Bayesian history matching technique for model fitting (Section~\\ref{sec:ch3historymatching}) and the emulation-based Sobol' global sensitivity analysis for model uncertainty quantification (Section~\\ref{sec:ch3globalsensitivityanalysis}). We conclude with a brief summary (Section~\\ref{sec:ch3summary}).\n\\end{remark}\n\nWe want to create a quantitative link of the cell, tissue and haemodynamic properties to whole heart function. To do this, we first need to define quantities of interest that will vary to reflect model properties and quantities of interest that will consequently vary to reflect model behaviour. The quantitative mapping that will result from this work is summarised in Figure~\\ref{fig:simulatorframework}, and it is progressively constructed in Sections~\\ref{sec:ch3modelinputparameters}--\\ref{sec:ch3modeloutputfeatures}--\\ref{sec:ch3multiscalemap}.\n\n\\begin{figure}[ht!]\n    \\myfloatalign\n    \\includegraphics[width=\\textwidth]{figures/chapter03/simulator_framework.pdf}\n    \\caption{Multi-scale $3$D biventricular rat heart contraction model. Given a fixed calcium transient (a) and mesh with fibres (b), parameters representing cell, tissue and haemodynamics properties (left grey column, described in Table~\\ref{tab:paramswithdef}) constitute the input for the model. LV volume and pressure transients and PV loop are obtained after a four-beats model run. The LV features (right grey column, described in Table~\\ref{tab:lvfeatures}), extracted from the $4$th-beat curves (c1-c2), constitute the output for the model.}\n    \\label{fig:simulatorframework}\n\\end{figure}\n\n\n%\n%\n%\n\\section{Model input parameters}\\label{sec:ch3modelinputparameters}\nThe presented multi-scale rat heart contraction model (Chapter~\\ref{cha:chapter02}) is regulated by $71$, $17$, $18$ parameters for the ionic, cell contraction, tissue $+$ boundary components, respectively. We selected specific parameters as representative regulators of each of these three sub-models for a total of $8$ parameters. Specifically, $2$ parameters ($\\Caif$, $\\koff$) described the thin filament kinetics, $2$ parameters ($\\kxb$, $\\tref$) described the thick filament kinetics, and $4$ parameters ($\\p$, $\\pao$, $\\Z$, $\\Cone$) described boundary conditions and tissue properties. The $8$ parameters considered are described in Table~\\ref{tab:paramswithdef}. A fixed calcium transient simulated using the adopted ionic model was used as the sarcomere activation signal for the whole heart.\n\n\\begin{table}[ht!]\n    \\myfloatalign\n    \\begin{tabularx}{\\textwidth}{llX}\n    \\toprule\n    \\tableheadline{Parameter} & \\tableheadline{Units}                   & \\tableheadline{Definition} \\\\\n    \\midrule\n    $\\Caif$                   & $\\SI{}{\\micro\\Molar}$ & reference $\\Ca$ thin filament sensitivity \\\\\n    $\\koff$                   & $\\SI{}{\\per\\milli\\second}$              & unbinding rate of $\\Ca$ from TnC \\\\\n    $\\kxb$                    & $\\SI{}{\\per\\milli\\second}$              & cross-bridges cycling rate \\\\\n    $\\tref$                   & $\\SI{}{\\kilo\\pascal}$                   & maximal reference tension \\\\\n    $\\p$                      & $\\SI{}{\\kilo\\pascal}$                   & end-diastolic pressure \\\\\n    $\\pao$                    & $\\SI{}{\\kilo\\pascal}$                   & aortic systolic pressure \\\\\n    $\\Z$                      & $\\SI{}{\\mmHg\\second\\per\\milli\\liter}$   & aortic characteristic impedance \\\\\n    $\\Cone$                   & $\\SI{}{kPa}$                            & tissue stiffness \\\\\n    \\bottomrule\n    \\end{tabularx}\n    \\caption{Model parameters and their definitions.}\n    \\label{tab:paramswithdef}\n\\end{table}\n\n\n%\n%\n%\n\\section{Model output features}\\label{sec:ch3modeloutputfeatures}\nWe are interested in characterising the LV contractile function in the rat model. A typical full rat heart contraction mechanics model output consists in LV volume (\\acs{LVV}) and LV pressure (\\acs{LVP}) transients (i.e. the blood volume and pressure variations within the LV chamber during time), along with the corresponding \\textit{pressure-volume} (\\acs{PV}) \\textit{loop}. Multiple-beats simulations are commonly run to reach a more numerically stable \\textit{limit cycle}, and only the last-beat curves are analysed. In Figure~\\ref{fig:examplepvloop}, an example $4$-beat simulation is shown with the limit cycle curves highlighted.\n\n\\begin{figure}[ht!]\n    \\myfloatalign\n    \\includegraphics[width=\\textwidth]{figures/chapter03/a_typical_model_output.pdf}\n    \\caption{Rat heart contraction mechanics model $4$-beat simulation output. LVV and LVP transients (left panel) are drawn with a thin blue line, and their last-beat parts, along with the corresponding PV loop (right panel), are drawn with a thick blue line.}\n    \\label{fig:examplepvloop}\n\\end{figure}\n\n\\vspace{0.2cm}\nTo quantitatively describe the LV behaviour, we extracted from the last-beat curves $12$ scalar features of clinical interest and commonly used to characterise the LV systolic and diastolic functions:\n%\n\\begin{align}\n    &\\text{EDV}= \\max_{t>0}{v_{\\textrm{LV}}(t)} \\\\\n    &\\text{ESV}= \\min_{t>0}{v_{\\textrm{LV}}(t)} \\\\\n    &\\text{EF}= 100\\times\\frac{\\text{EDV}-\\text{ESV}}{\\text{EDV}} \\\\\n    &\\text{IVCT}= t_1-t_0 \\\\\n    &\\text{ET}= t_2-t_1 \\\\\n    &\\text{IVRT}= t_3-t_2 \\\\\n    &\\text{Tdiast}= t_4-t_2 \\\\\n    &\\text{PeakP}= \\max_{t>0}{p_{\\textrm{LV}}(t)} = p_{\\textrm{LV}}(t_5) \\\\\n    &\\text{Tpeak}= \\argmax_{t>0}{p_{\\textrm{LV}}(t)} = t_5 \\\\\n    &\\text{ESP}= p_{\\textrm{LV}}(t_2) \\\\\n    &\\text{maxdP}= \\max_{t>0}{\\frac{dp_{\\textrm{LV}}(t)}{dt}} \\\\\n    &\\text{mindP}= \\min_{t>t_2}{\\frac{dp_{\\textrm{LV}}(t)}{dt}}\n\\end{align}\n\n\\noindent\nwhere\n\n\\vspace{0.2cm}\n\\begin{tabular}{ll}\n    $t_i,\\,\\text{for}\\,\\,i=0,\\,\\dots,\\,5$ & positive time points (explained in Figure~\\ref{fig:lvfeatsextraction}) \\\\\n    $v_{\\textrm{LV}}(t)$ & LV volume transient \\\\\n    $p_{\\textrm{LV}}(t)$ & LV pressure transient\n\\end{tabular}\n\n\\vspace{0.2cm}\\noindent\nThe process of LV output features extraction is illustrated in Figure~\\ref{fig:lvfeatsextraction}, while features' definitions are provided in Table~\\ref{tab:lvfeatures}.\n\n\\begin{figure}[ht!]\n    \\myfloatalign\n    \\includegraphics[width=0.6\\textwidth]{figures/chapter03/lvv_lvp_features_explained_together.pdf}\n    \\caption{The $12$ LV features of interest are extracted from the LV volume and pressure curves (EF feature not showed as it is a derived quantity).}\n    \\label{fig:lvfeatsextraction}\n\\end{figure}\n    \n\\begin{table}[ht!]\n    \\myfloatalign\n    \\begin{tabularx}{\\textwidth}{XXl}\n    \\toprule\n    \\tableheadline{LV feature}                  & \\tableheadline{Units}                         & \\tableheadline{Definition} \\\\ \\midrule\n    $\\textrm{EDV}$                  & $\\SI{}{\\micro\\liter}$                  & end-diastolic volume \\\\         \n    $\\textrm{ESV}$                  & $\\SI{}{\\micro\\liter}$                  & end-systolic volume \\\\\n    $\\textrm{EF}$                   & $\\SI{}{\\percent}$                      & ejection fraction \\\\              \n    $\\textrm{IVCT}$                 & $\\SI{}{\\milli\\second}$                 & isovolumetric contraction time \\\\\n    $\\textrm{ET}$                   & $\\SI{}{\\milli\\second}$                 & systolic ejection time \\\\                  \n    $\\textrm{IVRT}$                 & $\\SI{}{\\milli\\second}$                 & isovolumetric relaxation time \\\\\n    $\\textrm{Tdiast}$               & $\\SI{}{\\milli\\second}$                 & diastolic filling time \\\\\n    $\\textrm{PeakP}$                & $\\SI{}{\\kilo\\pascal}$                  & peak systolic pressure \\\\\n    $\\textrm{Tpeak}$                & $\\SI{}{\\milli\\second}$                 & time to peak systolic pressure \\\\\n    $\\textrm{ESP}$                  & $\\SI{}{\\kilo\\pascal}$                  & end-systolic pressure \\\\\n    $\\textrm{maxdP}$ & $\\SI{}{\\kilo\\pascal\\per\\milli\\second}$ & maximum pressure rise rate \\\\\n    $\\textrm{mindP}$ & $\\SI{}{\\kilo\\pascal\\per\\milli\\second}$ & maximum pressure decay rate \\\\ \\bottomrule\n    \\end{tabularx}\n    \\caption{Indexes of LV systolic and diastolic functions.}\n    \\label{tab:lvfeatures}\n\\end{table}\n\n\n%\n%\n%\n\\section{Multi-scale map}\\label{sec:ch3multiscalemap}\nFor a given fixed $\\Ca$ transient, cubic-Hermite finite element heart mesh and fibre orientation, we can use the cardiac mathematical model described above, solved using the nonlinear finite element method, to map every set of $8$ input parameters $\\mathbf{x}$ used to initialise the model to a set of $12$ scalar output LV features $(y_1,\\,\\dots,\\,y_{12})$:\n%\n\\begin{align}\\label{eq:fsimul}\n    f_{simul}\\colon\\mathbb{R}^{8} &\\to\\underbrace{\\mathbb{R}\\times\\cdots\\times\\mathbb{R}}_{12\\,\\text{times}} \\\\\n    \\mathbf{x} &\\mapsto (y_1,\\,\\dots,\\,y_{12}) \\nonumber\n\\end{align}\n\n\\noindent\nEquation~\\eqref{eq:fsimul} effectively constitutes a quantitative link between cellular, tissue and haemodynamic properties to whole-organ function. The multi-scale mapping $f_{simul}$ takes the name of \\textit{simulator}.\n\n\\vspace{0.2cm}\nOne simulator evaluation at a new input parameter set requires the full-forward model of rat heart contraction mechanics to be run. However, this is computationally expensive ($\\sim 4$-$10$ CPU hours per evaluation). We overcome the computational burden of running such a complex model by replacing it with a probabilistic surrogate based on \\textit{Gaussian process emulation}, as we shall see in the next section. We will adopt the mathematical formalism of the standard textbook of Gaussian processes for machine learning by Rasmussen and Williams~\\cite{Rasmussen:2006}.\n\n\n%\n%\n%\n\\section{Gaussian process emulation}\\label{sec:ch3gaussianprocessemulation}\nLet's consider $N$ realisations $y^{(i)},\\,i=1,\\,\\dots,\\,N$ of a computer code $f$ ($=f_{simul}$) for $N$ different input parameter points $\\mathbf{x}^{(i)},\\,i=1,\\,\\dots,\\,N$ each one with dimension $D$: $\\mathbf{x}^{(i)}=(x_{1}^{(i)},\\,\\dots,\\,x_{D}^{(i)})^\\mathsf{T}$. More concisely, this can be written as $f(X)$ (or $\\mathbf{f}$) where $X=(\\mathbf{x}^{(1)},\\,\\dots,\\,\\mathbf{x}^{(N)})$ is the input matrix. The pair $(X,\\,f(X))$ is called the \\textit{learning sample}. A \\textit{Gaussian process emulator} (\\acs{GPE}) treats the deterministic response $f(\\mathbf{x})$ as a realisation of a random function $f(\\mathbf{x},\\,\\omega)$ which can be written as the sum of a regression model and a stochastic process~\\cite{OHagan:2006}:\n\\begin{equation}\n    f(\\mathbf{x},\\,\\omega) = h(\\mathbf{x}) + Z(\\mathbf{x},\\,\\omega), \\quad (\\mathbf{x},\\,\\omega)\\in\\mathbb{R}^D\\times\\Omega\n\\end{equation}\n\n\\noindent\nwhere $\\Omega$ is a probability sample space, commonly the Lebesgue-measurable set of real numbers.\n\n\\vspace{0.2cm}\nThe regression part $h(\\mathbf{x})$ provides a mean approximation to the computer code. We will only consider the parametric case where $h$ is given as a linear combination of elementary basis functions, namely $(D+1)$ one-degree polynomials:\n%\n\\begin{equation}\n    h(\\mathbf{x}):=\\sum_{i=0}^D\\beta_i\\,h_i(\\mathbf{x}) = \\mathbf{h}(\\mathbf{x})^\\mathsf{T}\\,\\boldsymbol{\\beta}\n\\end{equation}\n\n\\noindent\nwhere $\\boldsymbol{\\beta} = (\\beta_0,\\dots,\\beta_d)^\\mathsf{T}$ is the regression parameter vector and $\\mathbf{h}(\\mathbf{x}) = (h_0(\\mathbf{x}),\\dots,h_d(\\mathbf{x}))$ is the basis function vector with\n%\n\\begin{equation}\n    h_i(\\mathbf{x}):=\\begin{cases}\n        1 \\quad\\text{if}\\quad i = 0 \\\\\n        x_i \\quad\\text{if}\\quad i=1,\\dots,D\n    \\end{cases}\n\\end{equation}\n\nThe stochastic part $Z(\\mathbf{x},\\,\\omega)$ is a centred (zero-mean) Gaussian process (\\acs{GP}), completely and uniquely determined by it covariance function (or \\textit{kernel}) $k$:\n%\n\\begin{equation}\n    Z(\\mathbf{x},\\,\\omega):= \\mathcal{GP}(\\mathbf{0},\\,k(\\mathbf{x},\\mathbf{x'}))\n\\end{equation}\n\n\\noindent\nThe covariance function specifies the covariance between pairs of random variables:\n%\n\\begin{align}\n    k\\colon\\mathbb{R}^{D}\\times\\mathbb{R}^{D}&\\to\\mathbb{R}\\,,\\quad\\text{with} \\\\\n    (\\mathbf{x},\\,\\mathbf{x}')&\\mapsto k(\\mathbf{x},\\,\\mathbf{x}') = \\text{Cov}(Z(\\mathbf{x},\\,\\omega),\\, Z(\\mathbf{x}',\\,\\omega))\n\\end{align}\n\n\\noindent\nWe can notice that the covariance between the outputs is written as a function of the inputs. We will only consider the case of a \\textit{stationary} stochastic process, where the covariance is a function of the difference $\\mathbf{x}-\\mathbf{x}'$ and is thus invariant to translations in the input space. We will adopt the infinitely differentiable, stationary \\textit{squared exponential} (\\acs{SE}) kernel defined as:\n%\n\\begin{align}\n     &k_{\\text{SE}}(d(\\mathbf{x},\\,\\mathbf{x}')) := \\sigma_f^2\\, e^{-\\frac{1}{2}\\,d(\\mathbf{x},\\,\\mathbf{x}')} \\\\\n     &d(\\mathbf{x},\\,\\mathbf{x}') := (\\mathbf{x}-\\mathbf{x}')^\\mathsf{T}\\,\\Lambda\\,(\\mathbf{x}-\\mathbf{x}')\n\\end{align}\n\n\\noindent\nwhere $\\sigma_f^2\\in\\mathbb{R}_{+}$ is the noise-free signal variance and $\\Lambda=\\text{diag}(\\ell_1^2,\\dots,\\ell_D^2)$, $\\ell_i\\in\\mathbb{R}_{+}\\,\\,\\text{for}\\,\\,i=1,\\dots,D$ are the \\textit{characteristic length-scales} of the process. This formulation of the covariance function implements an \\textit{automatic relevance determination}, since the inverse of each length-scale determines how relevant the corresponding input component is: if the length-scale has a very large value, the covariance will become almost independent of that component, effectively removing it from the inference.\n\n\\vspace{0.2cm}\nChoosing the GP covariance structure which best captures the nature of the underlying data is important because, by the principle of \\textit{similarity}, it is assumed that the target value $\\mathbf{f}(\\mathbf{x})$ of a point $\\mathbf{x}$ can be informative on the prediction for a test point close to it. In the context of Gaussian processes, the selection of the covariance function can formally be achieved through the process of \\textit{model selection}. The smoothness of the squared exponential kernel we have adopted could represent a very strong assumption as some argue it is unrealistic for modelling many physical processes. However, a preliminary model selection through \\textit{k-fold cross-validation} was run on data generated by our cardiac mechanics forward model, and estimated a similar to SE kernel generalisation error for other different, rougher kernels such as Mat\\'{e}rn$_{\\nu=3/2}$ (once differentiable) and Mat\\'{e}rn$_{\\nu=5/2}$ (twice differentiable).\n\n\\vspace{0.2cm}\nUnder the assumption of a GP model, the learning sample follows a multivariate normal distribution:\n%\n\\begin{equation}\n    \\mathbf{f}\\;\\vert\\; X \\,\\,\\sim\\,\\, \\mathcal{N}(H_{X}\\boldsymbol{\\beta},\\,\\Sigma_{XX})\n\\end{equation}\n\n\\noindent\nwhere $H_{X}:=(\\mathbf{h}(\\mathbf{x}^{(1)})^\\mathsf{T},\\dots,\\mathbf{h}(\\mathbf{x}^{(N)})^\\mathsf{T})$ is the regression matrix and $\\Sigma_{XX}$ is the \\textit{Gram} covariance \\textit{matrix} obtained by evaluating the covariance function at all the pairs of input points in $X$:\n%\n\\begin{equation}\n    X\\xrightarrow{k_{\\text{SE}}(\\cdot,\\cdot)}\\Sigma_{XX},\\qquad \\left(\\Sigma_{XX}\\right)_{ij} = k_{\\text{SE}}(\\mathbf{x}_i,\\,\\mathbf{x}_j)\\quad\\text{for}\\quad i,\\,j=1,\\dots,N\n\\end{equation}\n\n\\noindent\nLet's suppose we have a new set of points $X_{*}=(\\mathbf{x}_{*}^{(1)},\\,\\dots,\\,\\mathbf{x}_{*}^{(M)})$. We do not know $f(X_{*})$ (or $\\mathbf{f}_{*}$) values because we have not observed them yet. However, we can put a \\textit{prior distribution} on $\\mathbf{f}_{*}$ of the same type as the learning sample's one:\n%\n\\begin{equation}\n    \\mathbf{f}_{*}\\;\\vert\\; X_{*} \\,\\,\\sim\\,\\, \\mathcal{N}(H_{X_{*}}\\boldsymbol{\\beta},\\,\\Sigma_{X_{*}X_{*}})\n\\end{equation}\n\n\\noindent\nTheir joint probability distribution will be:\n%\n\\begin{equation}\n    \\begin{bmatrix}\n    \\mathbf{f} \\\\ \\mathbf{f}_{*}\n    \\end{bmatrix}\\;\\vert\\; X,\\,X_{*} \\sim \\mathcal{N}\\left([H_{X}\\boldsymbol{\\beta},\\,H_{X_{*}}\\boldsymbol{\\beta}],\\,\\begin{bmatrix}\n    \\Sigma_{XX} & \\Sigma_{XX_{*}} \\\\\n    \\Sigma_{X_{*}X} & \\Sigma_{X_{*}X_{*}}\n    \\end{bmatrix}\n    \\right)\n\\end{equation}\n\n\\noindent\nTo incorporate the knowledge that the observations provide about the function $f$, we condition this distribution on the learning sample. Because multivariate Gaussian distributions are closed under conditioning, the conditional distribution (also called \\textit{posterior distribution}) we get is again normally distributed:\n%\n\\begin{equation}\\label{eq:gpepostdistrnonoise}\n    \\mathbf{f}_{*}\\;\\vert\\; X_{*},\\,X,\\,\\mathbf{f}\\,\\,\\sim\\,\\,\\mathcal{N}(\\boldsymbol{\\mu},\\Sigma)\n\\end{equation}\n    \n\\noindent\nwhere\n%\n\\begin{align}\n    &\\boldsymbol{\\mu} := H_{X_{*}}\\boldsymbol{\\beta} + \\Sigma_{X_{*}X}\\Sigma_{XX}^{-1}(\\mathbf{f} - H_{X}\\boldsymbol{\\beta}) \\\\\n    &\\Sigma := \\Sigma_{X_{*}X_{*}}-\\Sigma_{X_{*}X}\\Sigma_{XX}^{-1}\\Sigma_{XX_{*}}\n\\end{align}\n\nWe will additionally model the learning sample observations to be affected by noise:\n%\n\\begin{equation}\n    y^{(i)}:=f(\\mathbf{x}^{(i)}) + \\varepsilon,\\qquad \\varepsilon\\sim\\mathcal{N}(0,\\,\\sigma_n^2)\n\\end{equation}\n\n\\noindent\nwhere $\\sigma_n^2\\in\\mathbb{R}^{+}$ is the noise variance, and the noise is assumed to be additive, independent and identically distributed. The use of a noise term (or \\textit{nugget}) might seem counter-intuitive as the learning sample is the result of a deterministic model run (i.e., for the same input you always get the same output). However, it has been previously shown~\\cite{Andrianakis:2012} that it is beneficial to include it even when emulating deterministic models. From a technical point of view, having a noisy representation of the learning sample results in adding a diagonal matrix to the latent function $\\mathbf{f}$ covariance matrix:\n%\n\\begin{equation}\n    k_{\\text{SE}}(\\mathbf{x},\\,\\mathbf{x}') = k_{\\text{SE}}(\\mathbf{x},\\,\\mathbf{x}') + \\sigma_n^2\\delta_{\\mathbf{x},\\,\\mathbf{x}'} \\quad\\Rightarrow\\quad \\text{Cov}(\\mathbf{y})=\\Sigma_{XX}+\\sigma_n^2 I\n\\end{equation}\n\n\\noindent\nwhere $\\delta_{\\mathbf{x},\\,\\mathbf{x}'}$ is the \\textit{Kronecker delta} (equals $1$ when $\\mathbf{x} = \\mathbf{x}'$ and $0$ when otherwise). This in turn ensures that the GP covariance matrix is always invertible, even in the case when the latent function covariance matrix ($\\Sigma_{XX}$) is ill-conditioned. Apart from the numerical stabilisation purpose, the use of the nugget can account for discrepancies between the GP emulator and the simulator and, since it modifies the shape of the GP model likelihood, it corresponds to modelling the variability which is not explained by the simulator inputs.\n\n\\vspace{0.2cm}\nThe joint probability distribution associated to the noisy formulation becomes:\n%\n\\begin{equation}\n    \\begin{bmatrix}\n    \\mathbf{y} \\\\ \\mathbf{f}_{*}\n    \\end{bmatrix}\\;\\vert\\; X,\\,X_{*} \\sim \\mathcal{N}\\left([H_{X}\\boldsymbol{\\beta},\\,H_{X_{*}}\\boldsymbol{\\beta}],\\,\\begin{bmatrix}\n    \\Sigma_{XX}+\\sigma_n^2 I & \\Sigma_{XX_{*}} \\\\\n    \\Sigma_{X_{*}X} & \\Sigma_{X_{*}X_{*}}\n    \\end{bmatrix}\n    \\right)\n\\end{equation}\n\n\\noindent\nand the GPE posterior distribution is therefore:\n%\n\\begin{equation}\\label{eq:gpepostdistr}\n    \\mathbf{f}_{*}\\;\\vert\\; X_{*},\\,X,\\,\\mathbf{y}\\,\\,\\sim\\,\\,\\mathcal{N}(\\boldsymbol{\\mu},\\Sigma)\n\\end{equation}\n    \n\\noindent\nwhere\n%\n\\begin{align}\n    &\\boldsymbol{\\mu} := H_{X_{*}}\\boldsymbol{\\beta} + \\Sigma_{X_{*}X}(\\Sigma_{XX}+\\sigma_n^2)^{-1}(\\mathbf{y} - H_{X}\\boldsymbol{\\beta}) \\\\\n    &\\Sigma := \\Sigma_{X_{*}X_{*}}-\\Sigma_{X_{*}X}(\\Sigma_{XX}+\\sigma_n^2)^{-1}\\Sigma_{XX_{*}}\n\\end{align}\n\n\\noindent\nIt is worth noticing that the most computational expensive operation that needs to be performed when assembling the posterior distribution (both the noise-free~\\eqref{eq:gpepostdistrnonoise} and the noisy~\\eqref{eq:gpepostdistr} ones) is the inversion of a symmetric, positive definite $N\\times N$ matrix (the kernel-induced covariance matrices $\\Sigma_{XX}$ and $\\Sigma_{XX}+\\sigma_n^2$, respectively). This operation is commonly performed by using a \\textit{Cholesky factorisation} of the matrix to be inverted, with a total cost $\\mathcal{O}(N^3)$, and by solving the resulting triangular system given by the obtained Cholesky factor, with a total cost $\\mathcal{O}(N^2)$~\\cite{Rasmussen:2006}. From an algorithmic viewpoint, if the learning sample does not change (matrix $X$ used to assemble the covariance matrix $\\Sigma_{XX}$), its Cholesky factor can be stored so that making inference on many different new sets of test points $X_{*}$ will every time only cost $\\mathcal{O}(N^2)$. This feature of Gaussian process emulators being fast to be evaluated will prove crucial for the applications we shall present in the next two sections.\n\n\\vspace{0.2cm}\nSo far we have introduced many free-parameters which belong to the non-parametric part of the model. They can be summarised in the so-called vector of \\textit{hyperparameters}:\n%\n\\begin{equation}\n    \\boldsymbol{\\theta}:=(\\{\\Lambda\\},\\,\\sigma_f^2,\\,\\sigma_n^2)    \n\\end{equation}\n\n\\noindent\nwhere $\\{\\Lambda\\}$ denotes the elements of matrix $\\Lambda$ (all the length-scales). In order to make the GPE a practical tool in an application, we need to specify values for the otherwise unspecified hyperparameters: this is done through a process of \\textit{fitting} also known as \\textit{training}.\n\n\\vspace{0.2cm}\nWe will use a Bayesian approach to model training, where inference is performed by applying rules of probability theory. A Gaussian process model is non-parametric; however, the latent function $\\mathbf{f}$ values at the training points can be considered as model parameters: the more training points, the more parameters. We start from the Bayes' rule to model the posterior distribution of model parameters $\\mathbf{f}$:\n%\n\\begin{equation}\\label{eq:paramspostdistr}\n    p(\\mathbf{f}\\;\\vert\\; \\mathbf{y},\\,X,\\,\\boldsymbol{\\theta}) = \\frac{p(\\mathbf{y}\\;\\vert\\; X,\\,\\mathbf{f})\\,p(\\mathbf{f}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})}{p(\\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})}    \n\\end{equation}\n\n\\noindent\nwhere $p(\\mathbf{y}\\;\\vert\\; X,\\,\\mathbf{f})$ is the \\textit{likelihood} and $p(\\mathbf{f}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})$ is the parameters \\textit{prior}. The term at the denominator is a normalisation constant and is called \\textit{marginal likelihood}. It does not depend on parameters $\\mathbf{f}$ and is defined as:\n%\n\\begin{equation}\\label{eq:paramsmarglike}\n    p(\\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta}) := \\int p(\\mathbf{y}\\;\\vert\\; X,\\,\\mathbf{f})\\,p(\\mathbf{f}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})\\,\\text{d}\\mathbf{f}\n\\end{equation}\n\n\\noindent\nUnder the assumption of Gaussian noise this integral can be solved analytically. By recalling that\n%\n\\begin{align}\n    &\\mathbf{y}\\;\\vert\\; X,\\,\\mathbf{f}\\,\\,\\sim\\,\\,\\mathcal{N}(\\mathbf{f},\\,\\sigma_n^2I) \\\\\n    &\\mathbf{f}\\;\\vert\\; X,\\,\\boldsymbol{\\theta} \\,\\,\\sim\\,\\,\\mathcal{N}(H_{X}\\boldsymbol{\\beta},\\,\\Sigma_{XX})\n\\end{align}\n\n\\noindent\nwe obtain:\n%\n\\begin{equation}\n    \\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta}\\,\\,\\sim\\,\\,\\mathcal{N}(H_{X}\\boldsymbol{\\beta},\\,\\Sigma_{XX}+\\sigma_n^2I)\n\\end{equation}\n\n\\noindent\nWe can notice that the convolution of two Gaussian distributions is still Gaussian. It is common to take the logarithm of the obtained distribution: this is the \\textit{log marginal likelihood}\n%\n\\begin{equation}\\label{eq:logmarginallikelihood}\n    \\begin{split}\n        \\log{p(\\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta}}) = -\\frac{1}{2}(\\mathbf{y}-H_X\\boldsymbol{\\beta})^\\mathsf{T}(\\Sigma_{XX}+\\sigma_n^2I)^{-1}(\\mathbf{y}-H_X\\boldsymbol{\\beta}) + \\\\ -\\frac{1}{2}\\log{\\;\\vert\\; \\Sigma_{XX}+\\sigma_n^2I\\;\\vert\\; } - \\frac{N}{2}\\log{2\\pi}\n    \\end{split}\n\\end{equation}\n\n\\noindent\nThis equation has three terms which can be interpreted as follows. The first term is large when the data fit the model well; the second term is a complexity penalty and is large when the model is simple; the last term is a normalisation constant.\n\n\\vspace{0.2cm}\nAt this point, a fully Bayesian approach would involve assigning a prior distribution to the hyperparameters and deriving a posterior distribution in the same manner as done in equation~\\eqref{eq:paramspostdistr}, using the marginal likelihood of equation~\\eqref{eq:paramsmarglike} as likelihood. However, as the resulting integrals cannot be solved analytically and require numerical strategies to be estimated, to maintain computational tractability we opt for a simpler approach where a single value is estimated for each hyperparameter and considered as the true value. A drawback to this technique is a possible underestimation of the simulator variability, but this is outweighed by savings in the computational effort. This approach takes the name of \\textit{maximum likelihood-II} type of inference, and consists in maximising the log marginal likelihood with respect to the model hyperparameters:\n%\n\\begin{equation}\n    \\hat{\\boldsymbol{\\theta}} := \\textrm{arg\\,max}_{\\boldsymbol{\\theta}\\in\\R}{\\log{p(\\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})}}\n\\end{equation}\n\n\\noindent\nGradient descent optimisation algorithms are commonly used~\\cite{Ruder:2016} to minimise an objective function (or \\textit{loss function}), which in this case is simply the log marginal likelihood with inverted sign:\n%\n\\begin{equation}\n    J(\\boldsymbol{\\theta}) := -\\log{p(\\mathbf{y}\\;\\vert\\; X,\\,\\boldsymbol{\\theta})}\n\\end{equation}\n\n\\noindent\nThis is done iteratively by updating at every step (or \\textit{epoch}) the parameters in the opposite direction of the gradient of the objective function with respect to the parameters ($\\nabla_{\\boldsymbol{\\theta}}J(\\boldsymbol{\\theta})$).\n\n\n%\n%\n%\n\\subsection{Regression accuracy}\\label{sec:ch3regressionaccuracy}\nThe accuracy of each \\textit{univariate} GPE for regression tasks is evaluated using a $k$-fold cross-validation process. At each split, a GPE is trained on the current $(k-1)/k$ fraction of the entire dataset, and it is then evaluated in all the points $\\mathbf{x}_i,\\,i=1,\\,\\dots,\\,M$ of the held-out $1/k$ fraction of the dataset, with dimensions $M\\times D$. The obtained point-wise predictions $y_{i}^{\\textrm{mean}}\\,i=1,\\,\\dots,\\,M$ (corresponding to the posterior distribution mean values) are then compared with the true function output values $y_{i}^{\\textrm{true}}\\,i=1,\\,\\dots,\\,M$. We use the \\textit{coefficient of determination} (or $R^2$-score) to measure how well the regression predictions approximate the real data points. This is defined as:\n%\n\\begin{align}\n    & R^2 := 1 - \\frac{\\sum_{i=1}^M(y_{i}^{\\textrm{true}}-y_{i}^{\\textrm{mean}})^2}{\\sum_{i=1}^M(y_{i}^{\\textrm{true}} - \\bar{y})^2}\\,,\\quad\\text{with} \\\\\n    & \\bar{y}:=\\frac{1}{M}\\sum_{i=1}^M y_{i}^{\\textrm{true}}\n\\end{align}\n\n\\noindent\nWe additionally use the GPE predicted posterior variance values $y_{i}^{\\textrm{var}},\\,i=1,\\,\\dots,\\,M$ to calculate the percentage of points which have an \\textit{independent standard error} (\\acs{ISE}) smaller than $2$. This quantity, which we call $ISE_2$, is a diagnostic used to assess the emulator's adequacy as a surrogate of the true deterministic function~\\cite{Bastos:2009}, as it measures how well the emulator uncertainty is accounting for the mean predictions' departure from the observed data and is defined as:\n%\n\\begin{equation}\n    ISE_2 := \\frac{100}{M}\\cdot \\sum_{i=1}^M\\left(\\frac{\\vert y_{i}^{\\textrm{true}}-y_{i}^{\\textrm{mean}}\\vert}{\\sqrt{y_{i}^{\\textrm{var}}}} < 2\\right)\n\\end{equation}\n\n\\noindent\nThe Boolean result inside the parentheses is encoded with either $0$ (false) or $1$ (true). The GPE accuracy can be finally described by the $R^2$-score and $ISE_2$ obtained by averaging the same metrics calculated when testing the emulator on the respective left-out parts of each dataset splitting during cross-validation.\n\n\\vspace{0.2cm}\nFor each scalar feature of interest $y_j$ we will train one univariate GPE $f_{emul,\\,j}$ as a surrogate of the simulator restricted map:\n%\n\\begin{align}\\label{eq:univariatesimulator}\n    f_{simul,\\,j}\\colon\\mathbb{R}^{D} &\\to \\mathbb{R} \\\\\n    \\mathbf{x} &\\mapsto y_j \\nonumber\n\\end{align}\n\n\\noindent\nHaving available trained $f_{emul,\\,j}$ emulators is powerful as they enable performing model exploration, fitting and uncertainty quantification. These tasks, in fact, normally require a large number of model evaluations, which is prohibitive when the simulator is computationally intensive to be solved.\n\n\n%\n%\n%\n\\section{History matching}\\label{sec:ch3historymatching}\nA first application of emulators is in the \\textit{history matching} (\\acs{HM}) technique. In the case where real system observations are available, HM can be used to learn about the input space characterising the simulator $f_{simul}$, which is being used to describe the real system.\n\n\\vspace{0.2cm}\nLet $y$ be a scalar, \\textit{real system value}. First, we can assume that the \\textit{observation} $z$ that we make of the real system value is affected by a \\textit{measurement error} $e$:\n%\n\\begin{equation}\nz = y + e\n\\end{equation}\n\n\\noindent\nWe also assume that the measurement error is uncorrelated with $y$. As the simulator is only an \\textit{in silico} representation of the real system, for each given input $\\mathbf{x}$ such that the corresponding simulator output $f_{simul}(\\mathbf{x})$ is at its closest to the real system value, a \\textit{model discrepancy} will still exist between the simulator output and the real system value:\n%\n\\begin{equation}\ny = f_{simul}(\\mathbf{x}) + d\n\\end{equation}\n\n\\noindent\nso that:\n%\n\\begin{equation}\\label{eq:modeldiscrerr}\nz = f_{simul}(\\mathbf{x}) + d + e\n\\end{equation}\n\n\\noindent\nThe model discrepancy term $d$ was formally introduced in~\\cite{Kennedy:2001} as an additional source of uncertainty in simulator predictions (referred to as \\textit{model inadequacy}) and the correct characterisation of it often requires experts' knowledge. Here we assume that $d$ is independent of $\\mathbf{x}$ and uncorrelated with $f$.\n\n\\vspace{0.2cm}\nHM is an iterative process that allows to thoroughly explore the input space by discarding regions of input points that are unlikely to yield a simulator output match with real system observations. In order to do that, it makes use of emulators $f_{emul}$ to approximate the simulator output at many input points where the simulator would be too computationally expensive to be run. HM relies on the so-called \\textit{implausibility measure}, which is calculated for each test point $\\mathbf{x}$ in the input space:\n%\n\\begin{equation}\\label{eq:implmeasure}\n    I(\\mathbf{x}) := \\frac{\\lvert\\mathbb{E}[f_{emul}(\\mathbf{x})]-z\\rvert}{\\sqrt{\\mathbb{V}[\\mathbb{E}[f_{emul}(\\mathbf{x})]-z]}} = \\frac{\\lvert\\mathbb{E}[f_{emul}(\\mathbf{x})]-z\\rvert}{\\sqrt{\\mathbb{V}[f_{emul}(\\mathbf{x})] + \\mathbb{V}[d] + \\mathbb{V}[e]}}\n\\end{equation}\n\n\\noindent\nThe implausibility measure is then compared against a pre-defined cutoff value $I_{\\,\\text{cutoff}}$ to assess whether the corresponding input point will be likely to produce an acceptable match to the real system observation. A common choice (e.g.~\\cite{Vernon:2010,Andrianakis:2015,Coveney:2018}) is to take a cutoff value of $3$, by following the Pukelsheim's $3$-sigma rule~\\cite{Pukelsheim:1994}. By assuming the distribution $(\\mathbb{E}[f_{emul}(\\mathbf{x})]-z)$ to be unimodal, the rule states that the probability of $I(\\mathbf{x})>3$ is at most $\\sim\\SI{5}{\\percent}$. In HM context, large implausibility measures (i.e. values above the chosen cutoff) will deem the associated points \\textit{implausible}, while points with an implausibility measure below the cutoff value will be deemed \\textit{non-implausible}. \n\n\\vspace{0.2cm}\nAs one might have available observations $z_j$ for more than one feature of interest $y_j$, the implausibility measure can be naturally extended to take into account individual implausibility measures $I_j(\\mathbf{x})$, each one obtained using the corresponding univariate emulator $f_{emul,\\,j}$ of feature $y_j$. A simple way to do this is to take the maximum across all the implausibility measures: \n%\n\\begin{equation}\\label{eq:maximplmeasure}\n    I_{M}(\\mathbf{x}) := \\max_{j\\in\\{1,\\,\\dots,\\,\\#\\textrm{features}\\}}{I_j(\\mathbf{x}})\n\\end{equation}\n\n\\noindent\nIt follows that the parameter space will be constrained according to the worst (in terms of high implausibility value) observation match predicted by one of the emulators. As a wrong prediction from one emulator can lead to rejecting points that would have otherwise been kept according to their other individual implausibility measures, the joint implausibility measure $I_{\\text{M}}$ can be modified to take the second to last or the third to last highest implausibility measure value to be compared against the cutoff value.\n\n\n%\n%\n%\n\\subsection{Refocusing}\\label{sec:ch3refocusing}\nAfter having evaluated the first initial set of test points (sampled in the high-dimensional input parameter space) with consequent space reduction according to the implausibility criterion, we do not have to stop immediately. Instead, we can continue performing the same operation iteratively where now the initial space where we sample test points is the obtained non-implausible space from the first or previous iteration (or \\textit{wave}). In the context of HM, this operation is called \\textit{refocusing}.\n\n\\vspace{0.2cm}\\noindent\nAt each HM wave, we will perform the following operations.\n\n\\begin{description}\n    \\item[\\textsc{Step 1.}] If this is the first wave, sample many points from the input parameter space $X$; if this is not the first wave, sample many points from the current non-implausible space $X_{NIMP}$. Points are commonly sampled using a space-filling design and constitute the so-called \\textit{not-ruled-out-yet} ($NROY$) space:\n    % \n    \\begin{align*}\n        & NROY\\subset\\begin{cases}\n        X &\\text{if}\\quad \\text{wave}=1 \\\\\n        X_{NIMP} &\\text{if}\\quad \\text{wave}>1\n        \\end{cases}\n    \\end{align*} \n    \\item[\\textsc{step 2.}] Calculate the implausibility measure for each point in the NROY space and test it against the chosen cutoff value $I_{\\,\\text{cutoff}}$ to rule-out the NROY space into implausible $X_{IMP}$ and non-implausible $X_{NIMP}$ spaces:\n    %\n    \\begin{align*}\n        & X_{IMP} := \\{\\mathbf{x}\\in NROY\\;\\vert\\;I_{M}(\\mathbf{x}) > I_{\\,\\text{cutoff}}\\} \\\\\n        & X_{NIMP} := \\{\\mathbf{x}\\in NROY\\;\\vert\\;I_{M}(\\mathbf{x}) \\le I_{\\,\\text{cutoff}}\\}\n    \\end{align*}\n    \\item[\\textsc{step 3.}] Determine the non-implausible part $T_{NIMP}$ of the training dataset $T$ and augment it with newly simulated points $T^{+}$ from the current $X_{NIMP}$ space:\n    %\n    \\begin{align*}\n        & T_{NIMP} := \\{(\\mathbf{x},\\,f_{simul}(\\mathbf{x}))\\in T\\;\\vert\\;I_{M}(\\mathbf{x}) \\le I_{\\,\\text{cutoff}}\\} \\\\\n        & T^{+} := \\{(\\mathbf{x},\\,f_{simul}(\\mathbf{x})),\\,\\mathbf{x}\\in X_{NIMP}\\} \\\\\n        & T = T_{NIMP}\\cup T^{+}\n    \\end{align*}\n    \\item[\\textsc{step 4.}] Cut the $X_{IMP}$ space out of the investigated parameter space and retain only the $X_{NIMP}$ space.\n    \\item[\\textsc{step 5.}] Unless a stopping criterion has been reached, refocus on the $X_{NIMP}$ space, i.e. repeat from \\textsc{step 1} using emulators trained on the new training dataset $T$, being these now more accurate in the non-implausible parameter region.\n\\end{description}\n\n\\vspace{0.2cm}\nIn \\textsc{step 1}, we have seen that NROY points are sampled such that they uniformly cover the high-dimensional input parameter space. This is a relatively trivial task for the first wave's space where, for example, a Latin hypercube design (\\acs{LHD})~\\cite{Iman:1981} can be used. In fact, the initial space is normally given as a $D$-dimensional hypercube, i.e. given as the Cartesian product of $D$ $1$-dimensional intervals. However, the situation is more complicated starting from wave $2$, as this time NROY points are to be sampled such that they uniformly cover the $X_{NIMP}$ space, which in general has a not well defined topological structure. Let's suppose that the number of NROY points we want to sample over the current $X_{NIMP}$ space is $m$, and that the number of $X_{NIMP}$ points defining the $X_{NIMP}$ space is $n$. Then, for wave $2$ and successive waves we will perform the following operations.\n\n\\begin{description}\n    \\item[(i)] If $m > n$:\n        \\begin{enumerate}\n            \\item Build a multivariate normal distribution centred in all $X_{NIMP}$ points and scaled by the current \\textit{min-max} range of the known $X_{NIMP}$ space. The spread of this distribution can be further scaled by a factor (e.g. $\\SI{10}{\\percent}$ of the initial standard deviation) in order to sample closer to the mean values ($X_{NIMP}$ points).\n            \\item Sample points from the built multivariate normal distribution, test them against the implausibility condition using the emulators of the current wave, and retain only the points that are deemed non-implausible.\n            \\item Append the newly generated non-implausible points to the current $X_{NIMP}$ set and re-calculate $n=\\vert X_{NIMP}\\vert$.\n            \\item Repeat block \\textsc{(I)} until $m < n$.\n        \\end{enumerate}\n \n    \\item[(ii)]\n        Select $m$ well-spread points from the set of $n$ candidate $X_{NIMP}$ points to be the best representatives of the $X_{NIMP}$ space and thus the new NROY points.\n\\end{description}\n\n\\noindent\nThe operations described in block \\textsc{(I)} are known as the \\textit{cloud technique}, previously adopted in~\\cite{Coveney:2018}. For what concerns the operation in \\textsc{(II)}, we employed the \\textit{part-and-select} algorithm~\\cite{Salomon:2013} to tackle the point selection problem. Briefly, the $n$ candidate points are partitioned into $m$ clusters, and the most representative point of each cluster is returned. $m - 1$ divisions of a single set into two sets are iteratively performed to obtain the $m$ clusters. At each step, the set with the greatest dissimilarity among its members is the one that is divided, where the dissimilarity is computed as the set diameter in the Chebyshev metric. To finally select the most representative member of a set, the point which is\nclosest in Euclidean metric to the centre of the hyper-rectangle circumscribing the set itself is chosen.\n\n\\vspace{0.2cm}\nIn \\textsc{step 5}, refocusing on the $X_{NIMP}$ space will not take place if a stopping criterion is reached. The HM process can be stopped by observing at each wave the proportion of volumes of space that are cut-out of/retained in the current $NROY$ space. If the percentage of $X_{NIMP}$ space volume out of the total $NROY$ space volume does not decrease in consecutive waves, this means that we have reached \\textit{convergence of the non-implausible space}, and we can stop. A more advanced stopping criterion consists in looking at the emulator variance for each $X_{NIMP}$ point and comparing it with the sum of the observation error and model discrepancy variances: if the former is significantly smaller than this sum, and the same trend is observed throughout the entire $X_{NIMP}$ space, this means that increasing the accuracy of the emulators for the next wave will not be of any use and the space will not be cut, so that we can stop. Finally, a combination of the percentage of $X_{NIMP}$ space's volume reduction analysis and of variance analysis can be used to create arbitrarily complex stopping criteria.\n\n\n%\n%\n%\n\\section{Global sensitivity analysis}\\label{sec:ch3globalsensitivityanalysis}\nIn order to assess the contribution of the model input parameters' uncertainty into explaining the model output features' total variance, a global sensitivity analysis (\\acs{GSA}) can be performed. In the next paragraphs, we shall see how having fast-evaluating trained emulators enable characterisation of model sensitivities even for complex, computationally expensive simulators.\n\n\\vspace{0.2cm}\nBy assuming that for our specific biophysical system model $f$ (=$f_{simul}$) only low order correlations between input variables $\\mathbf{X}:=(X_1,\\,\\dots,\\,X_D)$ have an impact on the output ($Y=f(\\mathbf{X})$) variance, we can make use of the \\textit{high-dimensional model representation}~\\cite{Rabitz:1999} to introduce a functional decomposition of our simulator of the form:\n%\n\\begin{equation}\\label{eq:hdmr}\n    f(\\mathbf{X}) := f_{0} + \\sum_{i}f_{i}(X_{i}) + \\sum_{i}\\sum_{j>i}f_{ij}(X_{i},\\,X_{j}) + \\cdots + f_{i\\cdots D}(X_1,\\,\\dots,\\,X_D)\n\\end{equation}\n\n\\noindent\nIf $f$ is square integrable over the unit hypercube $\\Omega := [0,\\,1]^{D}$, the decomposition~\\eqref{eq:hdmr} is unique given that~\\cite{Sobol:2003}:\n%\n\\begin{align}\\label{eq:integralformfi}\n    & \\int_0^1 f_{i_1,\\,i_2,\\,\\dots,\\,i_s}(X_{i_1},\\,X_{i_2},\\,\\dots,\\,X_{i_s})\\,dX_{i_{w}} = 0\\,,\\quad\\text{with} \\\\\n    & 1 \\le i_1 < i_2 < \\cdots < i_s \\le D \\\\\n    & i_{w} \\in \\{i_1,\\,i_2,\\,\\dots,\\,i_s\\}\n\\end{align}\n\n\\noindent\nNow, let's assume $\\mathbf{X} = (X_1,\\,\\dots,\\,X_D)$ to be a random vector of independent and uniformly distributed random variables over $\\Omega$, then using the integrals in equation~\\eqref{eq:integralformfi}, we can express each element in equation~\\eqref{eq:hdmr} as:\n%\n\\begin{align}\n    & f_{0} = \\mathbb{E}[Y] \\label{eq:f0var}\\\\\n    & f_{i} = \\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i] - \\mathbb{E}[Y] \\\\\n    & f_{ij} = \\mathbb{E}_{\\mathbf{X}_{\\sim ij}}[Y|(X_i,\\,X_j)] - f_i - f_j - f_0 \\\\\n    &\\dots\n\\end{align}\n \n\\noindent\nand so forth for higher orders, where $\\mathbf{X}_{\\sim i}$ indicates all components of $\\mathbf{X}$ but the $i$-th component. As $f$ is square-integrable, we can apply the variance operator to every element of~\\eqref{eq:hdmr}\n%\n\\begin{align}\n    & V_{i} = \\mathbb{V}[f_{i}] = \\mathbb{V}_{X_i}[\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]] \\\\\n    \\begin{split}\n        & V_{ij} = \\mathbb{V}[f_{ij}] = \\mathbb{V}_{X_iX_j}[\\mathbb{E}_{\\mathbf{X}_{\\sim ij}}[Y|(X_i,\\,X_j)]]\\,\\,+ \\\\\n        & - \\mathbb{V}_{X_i}[\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]] - \\mathbb{V}_{X_j}[\\mathbb{E}_{\\mathbf{X}\\sim j}[Y|X_i]]\n    \\end{split} \\label{eq:varelements}\\\\\n    &\\dots\n\\end{align}\n\n\\noindent\nand so forth for higher orders, giving:\n%\n\\begin{equation}\\label{eq:anovadecomp}\n    \\mathbb{V}[Y] = \\sum_{i}V_{i} + \\sum_{i}\\sum_{j>i}V_{ij} + \\cdots + V_{i\\cdots D}\n\\end{equation}\n\n\\noindent\nEquation~\\eqref{eq:anovadecomp} takes the name of \\textit{ANOVA decomposition} of the variance. Dividing both sides by $\\mathbb{V}[Y]$ yields the relationship existing between the so-called \\textit{Sobol' sensitivity indices}:\n%\n\\begin{equation}\\label{eq:sumofsobolindexes}\n    1 = \\sum_{i}S_{i} + \\sum_{i}\\sum_{j>i}S_{ij} + \\cdots + S_{i\\cdots D}\n\\end{equation}\n\n\\noindent\nThe Sobol' \\textit{main effect} (first-order sensitivity index) is defined as:\n%\n\\begin{equation}\\label{eq:maineffect}\n    S_{i} := \\frac{\\mathbb{V}_{X_i}[\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]]}{\\mathbb{V}[Y]}\\,,\\quad\\text{for}\\,\\,i=1,\\,\\dots,\\,D\n\\end{equation}\n\n\\noindent\nand it is a global sensitivity measure representing the amount of model output variance reduction that we would obtain if parameter $X_i$ were to be fixed. Another important global sensitivity measure is the Sobol' \\textit{total effect}, defined as:\n%\n\\begin{align}\\label{eq:totaleffect}\n    & S_{Ti} := \\frac{\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[\\mathbb{V}_{X_i}[Y|\\mathbf{X}_{\\sim i}]]}{\\mathbb{V}[Y]} = 1 - \\frac{\\mathbb{V}_{\\mathbf{X}_{\\sim i}}[\\mathbb{E}_{X_i}[Y|\\mathbf{X}_{\\sim i}]]}{\\mathbb{V}[Y]}\\,, \\\\\n    & \\text{for}\\,\\,i=1,\\,\\dots,\\,D\n\\end{align}\n\n\\noindent\nand represents the total contribution of parameter $X_i$ and all its higher-order interactions to the model output variance reduction. An intuitive description of the total effect index can be obtained from equation~\\eqref{eq:totaleffect}, by regarding $\\mathbb{V}_{\\mathbf{X}_{\\sim i}}[\\mathbb{E}_{X_i}[Y|\\mathbf{X}_{\\sim i}]]\\,/\\,\\mathbb{V}[Y]$ as the main effect of $\\mathbf{X}_{\\sim i}$. Therefore, because of equation~\\eqref{eq:sumofsobolindexes}, subtraction of this term from $1$ must leave only all the terms that include $X_i$ component.\n\n%\n%\n%\n\\subsection{Estimating Sobol' sensitivity indices}\\label{sec:ch3estimatingsobolsensitivityindices}\n\\textit{Monte Carlo} (\\acs{MC}) simulations can be used to estimate both the main and the total effects directly. However, a simple brute force approach that uses two nested \\enquote{for} loops to calculate the conditional variance and expectation appearing in both equations~\\eqref{eq:maineffect}--\\eqref{eq:totaleffect} would cost $N^2$ model evaluations per Sobol' index, which will become prohibitively expensive as $N$ is typically taken to be between $10^2$ and $10^4$ for reliable estimates. For this reason, several integral estimators have been developed to reduce as much as possible the number of model runs needed to calculate Sobol' sensitivity indices. Here, we discuss the particular approach followed by Saltelli et al.~\\cite{Saltelli:2010}.\n\n\\vspace{0.2cm}\nBecause of the known identity $\\mathbb{V}[Y] = \\mathbb{E}[Y^2] - \\mathbb{E}^2[Y]$, the numerator in equations~\\eqref{eq:maineffect} can be written as:\n%\n\\begin{equation}\n    \\mathbb{V}_{X_i}[\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]] = \\int \\mathbb{E}^2_{\\mathbf{X}_{\\sim i}}[Y|X_i]dX_i - \\left(\\int \\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]dX_i\\right)^2\n\\end{equation}\n\n\\noindent\nwhere the second term is equal to $\\mathbb{E}^2[Y]$, while the first term can be rewritten by expressing the integral argument as an integral in $2(D - 1)$ dimensions:\n%\n\\begin{align}\n    \\mathbb{E}^2_{\\mathbf{X}_{\\sim i}}[Y|X_i] &= \\int f(\\mathbf{X}_{\\sim i},\\, X_i)d\\mathbf{X}_{\\sim i}\\,\\cdot\\,\\int f(\\mathbf{X}_{\\sim i},\\, X_i)d\\mathbf{X}_{\\sim i} \\\\\n    &= \\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X'}_{\\sim i},\\, X_i)d\\mathbf{X}_{\\sim i}d\\mathbf{X'}_{\\sim i}\n\\end{align}\n\n\\noindent\nso that\n%\n\\begin{equation}\n    \\int \\mathbb{E}^2_{\\mathbf{X}_{\\sim i}}[Y|X_i]dX_i = \\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X'}_{\\sim i},\\, X_i)d\\mathbf{X}d\\mathbf{X'}_{\\sim i}\n\\end{equation}\n\n\\noindent\nis an integral in $2D - 1$ dimensions. The integral form of the main effect is therefore given by:\n%\n\\begin{equation}\\label{eq:mainintform}\n    S_{i} = \\frac{\\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X'}_{\\sim i},\\, X_i)d\\mathbf{X}d\\mathbf{X'}_{\\sim i} - \\mathbb{E}^2[Y]}{\\mathbb{V}[Y]}\n\\end{equation}\n\n\\noindent\nSimilarly, an integral form for the total effect can be obtained:\n%\n\\begin{equation}\\label{eq:totalintform}\n    S_{Ti} = \\frac{\\mathbb{E}[Y^2] - \\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X}_{\\sim i},\\, X_i')d\\mathbf{X}dX'}{\\mathbb{V}[Y]}\n\\end{equation}\n\n\\vspace{0.2cm}\nEstimators that have been developed to replace the brute force MC estimator commonly make use of the so-called \\textit{sampling and resampling approach} to generate the input space where to evaluate the model to eventually estimate the Sobol' sensitivity indices. This consists in generating a random matrix $\\mathbf{M}$ of size $N\\times 2D$, uniformly sampled in the unit hypercube $\\Omega$. Matrices $\\mathbf{A}$ and $\\mathbf{B}$, each one of size $N\\times D$, are then extracted from the first and second halves of the matrix $\\mathbf{M}$, respectively:\n%\n\\begin{equation}\n    \\mathbf{M} =  [\\mathbf{A}\\,|\\,\\mathbf{B}]\\in [0,\\,1]^{N\\times 2D}\n\\end{equation}\n\n\\noindent\nFinally, additional $D$ matrices of size $N\\times D$ are also built starting from matrix $\\mathbf{A}$, by replacing each time a different $i$-th column with the $i$-th column from matrix $\\mathbf{B}$:\n%\n\\begin{align}\n    & \\mathbf{A}_{\\mathbf{B}}^{(i)} := [A_1,\\,\\dots,\\,A_{i-1},\\,B_i,\\,A_{i+1},\\,\\dots,\\,A_{D}]\\,, \\\\\n    & \\text{for}\\,\\,i=1,\\,\\dots,\\,D\n\\end{align}\n\n\\noindent\nIn total, only $N\\times (D + 2)$ model evaluations, corresponding to $f(\\mathbf{A})$, $f(\\mathbf{B})$ and $f(\\mathbf{A}_{\\mathbf{B}}^{(i)}),\\,i=1,\\dots,D$, will be needed to estimate the Sobol' sensitivity indices, compared to the $2\\times D\\times N^2$ for the brute force approach. In fact, the two integrals appearing in the numerator of equations~\\eqref{eq:mainintform}--\\eqref{eq:totalintform} can be approximated by:\n%\n\\begin{align}\n    & (S_{i})\\quad \\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X'}_{\\sim i},\\, X_i)d\\mathbf{X}d\\mathbf{X'}_{\\sim i} \\approx \\frac{1}{N}\\sum_{j=1}^{N} f(\\mathbf{B})_{j}f(\\mathbf{A}_{\\mathbf{B}}^{(i)})_{j} \\\\\n    & (S_{Ti})\\quad \\int\\int f(\\mathbf{X}_{\\sim i},\\, X_i)f(\\mathbf{X}_{\\sim i},\\, X_i')d\\mathbf{X}dX' \\approx \\frac{1}{N}\\sum_{j=1}^{N} f(\\mathbf{A})_{j}f(\\mathbf{A}_{\\mathbf{B}}^{(i)})_{j}\n\\end{align}\n\n\\vspace{0.2cm}\nWe will make use of the Sobol'-Saltelli~\\cite{Saltelli:2010} estimator for the main effect's and of the Jansen~\\cite{Jansen:1999} estimator for the total effect's numerators calculation:\n%\n\\begin{align}\\label{eq:gsaestimators}\n    & \\mathbb{V}_{X_i}[\\mathbb{E}_{\\mathbf{X}_{\\sim i}}[Y|X_i]] \\approx \\frac{1}{N}\\sum_{j=1}^{N}f(\\mathbf{B})_j\\,(f(\\mathbf{A}_{\\mathbf{B}}^{(i)})_j - f(\\mathbf{A})_j) \\\\\n    & \\mathbb{E}_{\\mathbf{X}_{\\sim i}}[\\mathbb{V}_{X_i}[Y|\\mathbf{X}_{\\sim i}]] \\approx \\frac{1}{2N}\\sum_{j=1}^{N}(f(\\mathbf{A})_j-f(\\mathbf{A}_{\\mathbf{B}}^{(i)})_j)^2 \\\\\n    & \\text{for}\\,\\,i=1,\\,\\dots,\\,D\n\\end{align}\n\n\\noindent\nwhile for both the effects' denominators, we will use the following estimate:\n%\n\\begin{equation}\\label{eq:varianceestimate}\n    \\mathbb{V}[Y] \\approx \\frac{1}{2N} \\sum_{j=1}^{2N} f([\\mathbf{A}^\\mathsf{T}\\,|\\,\\mathbf{B}^\\mathsf{T}]^\\mathsf{T})_j\n\\end{equation}\n\n\\noindent\nIn addition, the initial matrix $\\mathbf{M}$ will not be sampled uniformly in the unit hypercube $\\Omega$, but it will be sampled in the same space using a low-discrepancy, quasi-random Sobol' sequence~\\cite{Sobol:1967}, in order to obtain better estimates as described in~\\cite{Saltelli:2010}. It is worth mentioning that every column of the obtained matrices $\\mathbf{A}$ and $\\mathbf{B}$ will be rescaled to the respective original interval $[p_i^{inf}, p_i^{sup}]$ of the component $X_i$ it represents, before calculating $f(\\mathbf{A})$, $f(\\mathbf{B})$ and $f(\\mathbf{A}_{\\mathbf{B}}^{(i)})s$. This is done by using the simple bijection:\n%\n\\begin{align}\n    b \\colon [0,\\,1] &\\to [p_i^{inf}, p_i^{sup}] \\\\\n    X_i &\\mapsto (1 - X_i)\\,p_i^{inf} + X_i\\,p_i^{sup}\n\\end{align}\n\n\\vspace{0.2cm}\nModel components' second-order interactions are often of interest as well. These can be analysed by calculating Sobol' second-order effects, which, by recalling equation~\\eqref{eq:varelements}, are defined as:\n%\n\\begin{align}\\label{eq:secondordereffects}\n    S_{ij} := \\frac{V_{ij}}{\\mathbb{V}[Y]}\\,,\\quad\\text{for}\\,\\,i,j=1,\\,\\dots,\\,D\n\\end{align}\n\n\\noindent\nThe numerator in~\\eqref{eq:secondordereffects} will be calculated using the Saltelli estimator proposed in~\\cite{Saltelli:2002}:\n%\n\\begin{equation}\\label{eq:secondorderestimator}\n   V_{ij} \\approx \\frac{1}{N}\\sum_{k}^{N}f(\\mathbf{B}_{\\mathbf{A}}^{(i)})_k\\,f(\\mathbf{A}_{\\mathbf{B}}^{(j)})_k - f(\\mathbf{A})_k\\,f(\\mathbf{B})_k\n\\end{equation}\n\n\\noindent\nwhile the denominator will be estimated using again~\\eqref{eq:varianceestimate}. Notice that the cost for calculating Sobol' second-order sensitivity indices is $N\\times (2D + 2)$ model evaluations, as we additionally need to calculate $f(\\mathbf{B}_{\\mathbf{A}}^{(i)})$ for $i=1,\\,\\dots,\\,D$.\n\n\n%\n%\n%\n\\subsection{Emulator-based estimates}\\label{sec:ch3emulatorbasedestimates}\nLet's suppose that the considered estimators for Sobol' first- and second-order and total effects~\\eqref{eq:gsaestimators}--\\eqref{eq:varianceestimate}--\\eqref{eq:secondorderestimator} can all be recapitulated in a single function $\\mathcal{S}$ that takes as an input simulator $f_{simul}$ evaluations $Y$ at specific points $X$ ($Y=f_{simul}(X)$) and gives as an output the Sobol' sensitivity indices $S_i,\\,S_{ij},\\,S_{T}$:\n%\n\\begin{equation}\\label{eq:modelevalsgsa}\n    Y\\xrightarrow[]{\\mathcal{S}(\\cdot)} S_i,\\,S_{ij},\\,S_{Ti}\n\\end{equation}\n\n\\noindent\nIn this study, we use the full GPE posterior distribution $f_{emul}(X)$ as given in equation~\\eqref{eq:gpepostdistr} to replace $f_{simul}$ for Sobol' indices estimates calculation. In particular, we will adopt two approaches. The first (and simpler) one consists in using the point-wise predictions given by the GPE posterior distribution expectation for estimating the Sobol' indices:\n%\n\\begin{equation}\\label{eq:emulmeangsa}\n    \\mathbb{E}[f_{emul}(X)]\\xrightarrow[]{\\mathcal{S}(\\cdot)} S_i,\\,S_{ij},\\,S_{Ti}\n\\end{equation}\n\n\\noindent\nThe second approach instead consists in randomly sampling points $\\hat{Y}$ from $f_{emul}(X)$, which is a multivariate normal distribution, and use them to obtain many estimates of the Sobol' indices. This operation will take into account also the GPE posterior distribution covariance structure, and the resulting Sobol' sensitivity indices will be given as random variables:\n%\n\\begin{equation}\\label{eq:emulpostsamplesgsa1}\n    \\left.\n        \\begin{array}{ll}\n            & f_{emul}(X)\\sim\\hat{Y}_1\\xrightarrow[]{\\mathcal{S}(\\cdot)} S_{i}^{1},\\,S_{ij}^{1},\\,S_{Ti}^{1} \\\\\n            & f_{emul}(X)\\sim\\hat{Y}_2\\xrightarrow[]{\\mathcal{S}(\\cdot)} S_{i}^{2},\\,S_{ij}^{2},\\,S_{Ti}^{2} \\\\\n            & \\vdots\n        \\end{array}\n    \\right\\}S_i(\\omega),\\,S_{ij}(\\omega),\\,S_{Ti}(\\omega)\n\\end{equation}\n\n\\noindent\nwith sample space $\\omega\\in [0,\\,1]$. We can finally use the expectation of these random variables as a sensitivity index in its common definition:\n%\n\\begin{equation}\\label{eq:emulpostsamplesgsa2}\n    S_{i} = \\mathbb{E}[S_i(\\omega)],\\quad S_{ij} = \\mathbb{E}[S_{ij}(\\omega)],\\quad S_{Ti} = \\mathbb{E}[S_{Ti}(\\omega)]\n\\end{equation}\n\n\\noindent\nand the variance (and more generally the entire distribution) as an indicator of the sensitivity index accuracy~\\cite{Marrel:2009}.\n\n\\vspace{0.2cm}\nSo far, we have considered Sobol' indices estimates without taking into account the numerical error which is present when expectation and variance integrals are approximated using quadrature formulae. This uncertainty in the Sobol' indices estimates is commonly quantified using the \\textit{bootstrapping} technique~\\cite{Archer:1997}. This consists in resampling (i.e. sampling with replacement) a number of times the MC points from the unit hypercube $\\Omega$, and each time re-calculating the Sobol' indices. A \\textit{moment method} is then used to construct confidence intervals from the bootstrap distribution, giving a symmetric distribution around the mean estimate of the Sobol' index value. It is worth noticing that the number of resamples used can be easily increased to improve the accuracy of bootstrap confidence intervals since the most expensive part will still reside in the model evaluation process rather than in the resampling process.\n\n\\vspace{0.2cm}\\noindent\nIn the case when either full simulator evaluations (equation~\\eqref{eq:modelevalsgsa}) or emulator posterior distribution mean point-wise predictions (equation~\\eqref{eq:emulmeangsa}) are used to estimate the Sobol' indices, the bootstrapping approach can be easily applied to derive estimates' confidence intervals. The situation changes when we make use of emulator posterior distribution samples to estimate the Sobol' indices (equation~\\eqref{eq:emulpostsamplesgsa1}). In fact, quantifying how the uncertainty of the emulator predictions propagates into the uncertainty of the integral estimates is a non-trivial task and also an actively researched topic of probabilistic numerics~\\cite{Hennig:2015,Oates:2017,Cockayne:2019,Fisher:2019}. As further analyses on the topic are out of the scope for this project, we neglected the uncertainty arising from the integral estimates and only considered the uncertainty arising from the fact that we are using an emulator to replace the true forward model. This choice is consistent with the assumption that as the number of MC samples $N$ grows, the numerical error of the quadrature formulae will converge to $0$, and what is left will be only the uncertainty of the emulator, which does not change with $N$ for a fixed learning sample (training dataset).\n\n\n%\n%\n%\n\\section{Summary}\\label{sec:ch3summary}\nWe have shown how the complex $3$D biophysically-detailed model of rat heart contraction mechanics can be seen as a multi-scale function that maps a multi-dimensional input parameter vector to a one-dimensional output feature scalar. We have presented the main probabilistic tools to replace this map with a fast-evaluating surrogate model, which in turn enables the performance of expensive analysis such as model fitting through HM technique and uncertainty quantification through Sobol' GSA.", "meta": {"hexsha": "faa02c129fb082bbf2c43c24068893202d344062", "size": 57176, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd-thesis/chapters/chapter03.tex", "max_stars_repo_name": "stelong/phd-thesis", "max_stars_repo_head_hexsha": "25a2c45d359403bde916b9bcfb9485402b4d2a8a", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "phd-thesis/chapters/chapter03.tex", "max_issues_repo_name": "stelong/phd-thesis", "max_issues_repo_head_hexsha": "25a2c45d359403bde916b9bcfb9485402b4d2a8a", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd-thesis/chapters/chapter03.tex", "max_forks_repo_name": "stelong/phd-thesis", "max_forks_repo_head_hexsha": "25a2c45d359403bde916b9bcfb9485402b4d2a8a", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.2648648649, "max_line_length": 1303, "alphanum_fraction": 0.7093885546, "num_tokens": 17103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4223020047509993}}
{"text": "\\documentclass{article} \n\n% the purpose of this particular document is to serve as a staging area potential blog posts, for the purpose of editing, revision, and review. \n\n% packages \n\t\\usepackage{amsmath, amsthm, mathtools}\n\t\\usepackage{mdframed}  \n\t\\usepackage{geometry, enumerate} \n\t\\usepackage{parskip}\n\t\\usepackage{graphicx}\n\n% theorems and such \n  \t\\newtheorem{theorem}{Theorem}\n  \t\\newtheorem{corollary}{Corollary}\n  \t\\newtheorem{lemma}[theorem]{Lemma} \n  \t\\newtheorem*{remark}{Remark}\n  \t\\newtheorem*{exe}{Exercise}\n  \t\\newtheorem{prop}{Proposition} \n  \t\n% custom commands \n\t\\newcommand{\\ceil}[1]{\\left \\lceil #1 \\right \\rceil}\n\t\\newcommand{\\floor}[1]{\\lfloor #1 \\rfloor}\n\t\\newcommand{\\X}[1]{\\, \\text{mod} \\, #1}\n\t\\newcommand{\\divv}{\\,|\\,}\n\t\\newcommand{\\GCD}[2]{GCD\\,(#1, #2)}\n\t\\newcommand{\\LCM}[2]{LCM\\,(#1, #2)}\n\n\\begin{document} \n\n\\title{Elementary Number Theory : \\S 1} \n\\author{Henry Slayer $|$ University of California, Santa Cruz} \n\\date{}\n\\maketitle\n\n\\section*{The Euclidean Algorithm} \nThe first scientific study of the numbers is typically attributed to the Greeks, who began classifying and categorizing the numbers (odd, even, etc…) in around 600 BC. It is Euclid, however, who transformed the theory of numbers into a deductive science. His \\textit{Elements} was truly a master work of geometry and number theory, and in Book VII, the Euclidean Algorithm was born. Euclid's algorithm is an iterated process of division with remainder on two positive integers. Though simple, it is the foundation upon which much of number theory stands. For more on the \\textit{Elements}, David Joyce has an interactive (albeit dated) browser version of the text, with Java applets to boot. \n\\begin{verbatim} https://mathcs.clarku.edu/~djoyce/java/elements/elements.html \n\\end{verbatim} \n\nFor what follows, we’ll take a leaf out of Weissman’s book, and start by exploring the dynamic nature of numbers in pairs. In other words, if we treat numbers as moves or units of measure, where can we go? What can we scale? The answer will lead us right into the hands of Euclid’s numerical disassembly.  \n\\subsubsection*{Compound Moves} \nThe dynamic interpretation of division with remainder is best served by an example. Suppose we have two measuring sticks, one that measures 61 units, and another that measures 39 units. Using only these two rulers, what can we measure? All multiples of 39 and 61, surely, but we can do better. How? We build a new measuring stick out of our first two. Lining up the two side-by-side, we can measure out a new ruler, from the difference, which is 61 - 39 = 22 units long. Nice! Now, we can measure anything that’s 61, 39, or 22 units long. What if we did it again? Taking the smaller of our two original numbers, we could use the difference of the 39-unit rule and the 22-unit rule to measure out lengths of 17. \n\n\\begin{figure}[h!]\n%\\begin{mdframed} \n\t\\center{\\includegraphics[width=.8\\textwidth]\n\t\t{figEA.png}}\n%\\end{mdframed} \n\\end{figure}\nAnd again, taking the 22 unit rule and the 17 unit rule, we get down to a precision of 5. If we take 3 of our new 5-unit rulers, we can compare the three stacked together to the 17 unit rule and measure lengths of 2. Taking two of the two unit rules with 5 gets us down to a single unit. Scaling our single-unit ruler allows us to measure anything that we want.  \n\nFundamentally, the Euclidean algorithm is no different. It is an iterative process of division with remainder. The steps that we took above are the same steps as the Euclidean algorithm, just written down a bit differently. In fact, if we wanted to formalize our process above, we would write\n\\begin{align*} \n\t61 &= 1(39) + 22\\\\\n\t39 &= 1(22) + 17 \\\\\n\t22 &= 1(17) + 5 \\\\\n\t17 &= 3(5) + 2 \\\\\n\t5 &= 2(2) + 1\n\\end{align*} \n\n\\subsubsection*{The Euclidean Algorithm} \n\nThe Euclidean algorithm starts with two positive integers, $a$ and $b$. Assuming $a > b$, our first line step is to break down $a$ using division with remainder.  \n\\[a = q(b) + r\\] \nWhere $r$ is a whole remainder, and $0 \\leq r < b$. The only rule that we follow, for now, is that $r$ is the least possible remainder. (The Euclidean algorithm actually comes in two flavors, as we’ll see, but for now, we assume that our remainders are whole, positive numbers). \nThen, we swap. The divisor ($b$) becomes the dividend (formerly $a$), and we divide our new divisor by the previous remainder. \nThat can be a little tricky in words, but it’s swingin’ in practice. \nIn equations: \n\n\\begin{align*} \na &= q_1(b) + r_1 \\\\\nb &= q_2(r_1) + r_2 \\\\\nr_1 &= q_3(r_2) + r_3)\\\\\n&\\vdots \\\\\nr_{f-2} &= q_{f}(r_{f-1}) + r_f \\\\\nr_{f-1} &= q_{f+1}(r_f) + 0  \n\\end{align*} \n\nWhen the remainder is zero (and we always reach zero because of the well-ordering principle) the process is over, and we stop. \n\n% provide another example here… maybe one with small numbers and one with large numbers  \n\n\\subsubsection*{The Euclidean Algorithm and the GCD} \n\nThe Euclidean Algorithm is a powerful tool for systematically obtaining the greatest common divisor of two integers.\nWe mentioned the greatest common divisor last time, but to review, the GCD of two integers a and b is another number g with the following properties:\n\\begin{enumerate}[(i)] \n\\item g is a common divisor of a and b \n\\item if a and b have any other common divisors, those divisors also divide g \n\\end{enumerate} \nWe can make several observations about the greatest common divisor. \n\\begin{mdframed} \n\\begin{lemma} Let $a$ be an integer. Then \n\\[GCD(a, 0) = a\\]\n\\end{lemma}  \n\\begin{proof} Everything divides zero. That is to say, zero is a multiple of anything (we just multiply by zero). The greatest divisor of a is a itself. So, the greatest divisor of any integer a and 0 will be a itself. \n\\end{proof}\n\\end{mdframed} \n\\begin{mdframed} \n\\begin{lemma}Suppose a, b, q, r are integers such that a = q(b) + r. Let g be another number. Then, g is the greatest common divisor of a and b if and only if g is the greatest common divisor of b and r.\n\\end{lemma} \n\\begin{proof}\nFill in. \n\\end{proof} \n\\end{mdframed} \nThese two lemmas tie the Euclidean algorithm to the greatest common divisor.\n\\begin{mdframed}\n\\begin{theorem}\nAssume a and b are natural numbers, at least one of which is nonzero. Then, the final nonzero remainder produced by applying the Euclidean algorithm to a and b is the greatest common divisor of a and b. \n\\end{theorem}\n\\begin{proof} In the terminal line of the euclidean algorithm, we see something of the sort \n\\[a_n = q_n(b_n) + 0\\] \nwhere $b_n$ is the final nonzero remainder. By what we’ve shown previously, $GCD(b_n, 0) = 0$. So, we walk up a line, which gives \n\\[a_{n-1} = q_{n-1}(a_n) + b_n\\]\nThen, by the second lemma, the \\(GCD(a_{n-1}, a_n) = GCD(a_n, b_n) = GCD(b_n, 0) = b_n\\). \nIterating this up our chain of divisions, we find that \\(GCD(a, b) = \\cdots = GCD(b_n, 0) = b_n\\), the final nonzero remainder. \n\\end{proof} \n\\end{mdframed} \n\\subsubsection*{GCD / LCM Product Formula} \n\nWe’ll close by examining some of the properties of the greatest common divisor, as well as the least common multiple. \nThe least common multiple ($LCM$) of two integers is another integer $l$, such that $l$ is a multiple of both $a$ and $b$ ($b\\divv l$, $a\\divv l$), such that any other multiple of $a$ and $b$ is larger. That is, if there exists some other multiple $m$, $l\\divv m$. \n\nThe greatest common divisor, the least common multiple, and the numbers that they’re defined by are all intimately related. \n\\begin{mdframed} \n\\begin{theorem} Let a and b be positive integers. Then \n\t\\[GCD(a, b) \\cdot LCM(a, b) = ab\\] \n\\end{theorem} \n\\begin{proof}  Let $GCD$ and $LCM$ denote the greatest common divisor and least common multiple, respectively, of a and b. The $GCD$ is a divisor of both $a$ and $b$, and the $LCM$ is a multiple of both $a$ and $b$, so \n\\begin{align*} \na = n\\cdot GCD \\quad&\\quad b = m \\cdot GCD \\\\  \nLCM = x \\cdot a \\quad&\\quad LCM = y \\cdot b \\\\\n\\end{align*}\nThe $LCM$ is a multiple of $a$ and $b$, so it must be a multiple of $ab$ for some integer $g$. Similarly, we see that the $GCD$ of $a$ and $b$ is also a multiple of $ab$. So, with $g$ and $l$ as integers, \n\\begin{align*}  \nab &= nm \\cdot GCD = l \\cdot GCD \\\\ \nab &= LCM \\cdot g \n\\end{align*}\nUsing these  6 relations, we can deduce the following: \n\\begin{align*}\nab = LCM \\cdot g &= x \\cdot a \\cdot g  \\quad \\Rightarrow \\quad  b = gx \\\\\nab = LCM \\cdot g &= y \\cdot b \\cdot g  \\quad \\Rightarrow \\quad  a = gy\n\\end{align*} \nSo, $g\\divv a$, $g\\divv b$, and by definition, $g\\divv GCD$. \nSecondly, we can observe that \n\\[ab = l \\cdot GCD \\quad\\Rightarrow am = l\\] \n\\[ab = l \\cdot GCD \\quad\\Rightarrow  bn = l\\] \nSo, l is a common multiple of both a and b. By definition, then, $a\\divv l$, $b\\divv l$, and $LCM\\divv l$. \nNow, we can assemble a tower of divisibilities.\n\\begin{enumerate}[] \n\\item $a = g \\cdot LCM$ and $g\\divv GCD$, so, $a = (g \\cdot LCM) \\divv (GCD \\cdot LCM)$  \n\\item Similarly, the $LCM\\divv l$ as $l$ is a common multiple of $a$ and $b$, and $GCD\\cdot l = ab$\n\\end{enumerate}\nThus: \n\\[ab = (g \\cdot LCM) \\divv (GCD \\cdot LCM) \\divv (GCD \\cdot l) = ab\\]\nThe $ab$ bookends tell us that all of the terms in the middle must be equal, and  $ab = LCM \\cdot GCD$, as desired. \n\\end{proof} \n*Note* For the greatest common divisor, $\\GCD{a}{b} = \\GCD{|a|}{|b|}$\n\\end{mdframed}  \n\n\\subsubsection*{Other GCD / LCM Properties} \nThe $GCD$ and $LCM$ are relatively predictable under uniform scaling, which leads us to the next two results. We’ll be able to say even more about the $GCD$ and $LCM$ after we study prime factorization.\n\n\\begin{mdframed} \n\\begin{prop} Let $g$, $a$, and $b$ be integers, with $g > 0$. Then\n\\[\\GCD{ga}{gb} = g\\cdot\\GCD{a}{b}\\]\n\\end{prop}\n\\begin{proof} Clearly, $g$ is a common divisor of both $ga$ and $gb$. Consequently, the \\textit{greatest} common divisor of $ga$ and $gb$ must take the form $g\\cdot d$, where $d$ is a common divisor of $a$ and $b$. $g\\cdot d$ will reach a maximum value when $d$ is the greatest divisor shared between $a$ and $b$, which is precisely $\\GCD{a}{b}$. So, \n\\[\\GCD{ga}{gb} = g\\cdot\\GCD{a}{b}\\]\nWe can verify this with the $GCD/LCM$ product theorem.  \n\\end{proof} \n\\end{mdframed} \n\n\\begin{mdframed} \n\\begin{corollary} \nSuppose that $a$ and $b$ are nonzero integers, and $g = \\GCD{a}{b}$. Then \n\\[GCD \\bigg(\\frac{a}{g}\\,, \\,\\frac{b}{g}\\bigg) = 1\\]\n\\end{corollary} \n\\begin{proof}\nApply $g$ to each side. The rest follows from Proposition 1. \n\\[g\\cdot GCD \\bigg(\\frac{a}{g}\\,, \\,\\frac{b}{g}\\bigg) = 1\\cdot g \\]\n\\[GCD \\bigg(\\frac{a\\cdot g}{g}\\,, \\,\\frac{b\\cdot g}{g}\\bigg) = g\\]\n\\[\\GCD{a}{b} = g \\]  \n\\end{proof} \n\\end{mdframed} \n\n% need to cite weissman's source here \n\\begin{mdframed} \n\\begin{exe} Let $a$ and $b$ be nonzero positive integers. Then, $\\GCD{a}{b} = 1$ if and only if $\\GCD{a^2}{b^2} = 1$.\n\\end{exe}\n\\begin{proof} \n\\end{proof}   \n\\end{mdframed} \n\n\\end{document} \n\t\n\t", "meta": {"hexsha": "4cde6354beef84b33666e742817bcf75d9021e2d", "size": 10876, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ENT1.tex", "max_stars_repo_name": "hcslayer/Elementary-Number-Theory", "max_stars_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ENT1.tex", "max_issues_repo_name": "hcslayer/Elementary-Number-Theory", "max_issues_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ENT1.tex", "max_forks_repo_name": "hcslayer/Elementary-Number-Theory", "max_forks_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.2081218274, "max_line_length": 711, "alphanum_fraction": 0.7019124678, "num_tokens": 3461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.42230200096594167}}
{"text": "% Created 2017-02-22 Wed 11:51\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usetheme{Madrid}\n\\author{Clarissa Littler}\n\\date{\\today}\n\\title{If all math was computable\\ldots{}}\n\\hypersetup{\n pdfauthor={Clarissa Littler},\n pdftitle={If all math was computable\\ldots{}},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 24.5.1 (Org mode 9.0.3)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\n\\section{Talk}\n\\label{sec:org2e66927}\n\n\\begin{frame}[label={sec:orge0c899c}]{You wake up}\n\\end{frame}\n\\begin{frame}[label={sec:org6560e10}]{Programming class}\n\\begin{block}{}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orgbc548ad}]{Anti-virus}\n\\begin{block}{A virus is a self-replicating program}\n\\end{block}\n\\end{frame}\n\n\\begin{frame}[label={sec:org66acbfc}]{The new Hello World}\n\\begin{block}{Travelling Salesman}\n\\begin{center}\n\\includegraphics[width=.9\\linewidth]{2000px-Hamiltonian_path.svg.png}\n\\end{center}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orge85e13e}]{Banking}\n\\begin{block}{Dedicated lines}\n\\begin{center}\n\\includegraphics[width=.9\\linewidth]{Telegraph_Cable_Office.jpg}\n\\end{center}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org3aa09b8}]{Who uses passwords?}\n\\begin{block}{}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org7667ee8}]{Choice}\n\\end{frame}\n\\begin{frame}[label={sec:org7047978}]{Reverse engineering}\n\\end{frame}\n\\begin{frame}[label={sec:org275239c}]{Intellectual property}\n\\begin{center}\n\\includegraphics[width=.9\\linewidth]{Felix_3D_Printer_-_Printing_Head.JPG}\n\\end{center}\n\\end{frame}\n\\begin{frame}[label={sec:org0e6d1fc}]{\\ldots{}wait?}\n\\begin{block}{}\nSomething occurs to you\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orge643353}]{Finite programs}\n\\begin{block}{}\nFinite keyboards + finite length = countable number of programs\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orgadc44d3}]{Reals and Integers}\n\\begin{block}{All the real numbers between 0 and 1}\n\\begin{center}\n\\begin{tabular}{lllll}\n\\(a_1\\) & \\(a_2\\) & \\(a_3\\) & \\(a_4\\) & \\ldots{}\\\\\n\\(b_1\\) & \\(b_2\\) & \\(b_3\\) & \\(b_4\\) & \\ldots{}\\\\\n\\(c_1\\) & \\(c_2\\) & \\(c_3\\) & \\(c_4\\) & \\ldots{}\\\\\n\\(d_1\\) & \\(d_2\\) & \\(d_3\\) & \\(d_4\\) & \\ldots{}\\\\\n\\ldots{} & \\ldots{} & \\ldots{} & \\ldots{} & \\ldots{}\\\\\n\\end{tabular}\n\\end{center}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orga059993}]{A table of programs}\n\\end{frame}\n\\begin{frame}[label={sec:org31e98b8}]{If we fuss with the diagonal}\n\\end{frame}\n\\begin{frame}[label={sec:orgd75fb14}]{A program that can't exist}\n\\end{frame}\n\\begin{frame}[label={sec:org2489ca5}]{You wake up}\n\\end{frame}\n\\begin{frame}[label={sec:org75bb20e}]{The Real World: Programming is \\alert{hard}}\n\\end{frame}\n\\begin{frame}[label={sec:org88b31cc}]{The Real World: Programming is \\alert{finite}}\n\\begin{block}{The finite nature of}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org1c34829}]{Thank you}\n\\begin{block}{}\n{\\Huge\nThank you for coming out!\n}\n\\end{block}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "9d34babb92cf9a62821d1c81af2ab3b0a509100e", "size": 3270, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "IfMath.tex", "max_stars_repo_name": "clarissalittler/talks", "max_stars_repo_head_hexsha": "ea80d8ab203775d8ab65c462d325008d62a3b623", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-06-24T03:20:44.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-24T03:20:44.000Z", "max_issues_repo_path": "IfMath.tex", "max_issues_repo_name": "clarissalittler/talks", "max_issues_repo_head_hexsha": "ea80d8ab203775d8ab65c462d325008d62a3b623", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "IfMath.tex", "max_forks_repo_name": "clarissalittler/talks", "max_forks_repo_head_hexsha": "ea80d8ab203775d8ab65c462d325008d62a3b623", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7118644068, "max_line_length": 84, "alphanum_fraction": 0.7155963303, "num_tokens": 1195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318194686359, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.4223019985665613}}
{"text": "\\chapter{Orthorectification and Map Projection}\\label{sec:Ortho}\n\n\n\\begin{figure}[h]\n  \\begin{tikzpicture}[scale=0.25]\n    \\tiny\n    \\draw[fill=black!10] (-1,-12) rectangle (53,17);\n     \\foreach \\x in {5,...,1}\n       \\draw[fill=red] (\\x,\\x) rectangle +(4,4);\n     \\node[fill=black!10, text width= 1.2cm] (InputSeries) at\n       (3,-1) {Input Series};\n\n     \\draw[->,thick] (9,5) --  +(3,0);\n\n     \\draw[fill=black!30,rounded corners=2pt] (12.2,3) rectangle +(6,4);\n     \\node[text width= 0.7cm] (SensorModel) at (15,5) {Sensor Model};\n\n     \\draw[fill=red!30] (1,-10) rectangle +(4,4);\n     \\node[fill=black!10, text width= 1.2cm] (DEM) at\n       (5,-11) {DEM};\n\n     \\draw[->,thick] (3,-5.5) --  ++(0,3) -- ++(12,0) -- ++(0,5);\n\n     \\draw[->,thick] (18.5,5) --  +(3,0);\n\n     \\foreach \\x in {5,...,1}\n       \\draw[fill=blue,xshift=600pt] (\\x,\\x) rectangle +(4,4);\n     \\node[fill=black!10, text width= 2.8cm] (GeographicGeometry) at\n       (28,-1) {Geographic Geometry};\n\n\n\n       \\draw[->,thick] (25.5,8.5) --  +(0,3);\n\n     \\draw[fill=black!30,rounded corners=2pt] (22,12) rectangle +(6.5,4);\n     \\node[text width= 0.7cm] (HomPoExtr) at (24,14) {Homologous\n     Points};\n\n     \\draw[->,thick] (21.5,14) --  +(-2.5,0);\n\n     \\draw[fill=black!30,rounded corners=2pt] (12,12) rectangle +(6.5,4);\n     \\node[text width= 1.3cm] (BBAdj) at (15.5,14) {Bundle-block\n     Adjustment};\n\n     \\draw[->,thick] (15,11.5) --  +(0,-4);\n\n\n      \\draw[->,thick] (30,5) --  +(3,0);\n\n     \\draw[fill=black!30,rounded corners=2pt] (33.2,3) rectangle +(6,4);\n     \\node[text width= 0.7cm] (MapProjection) at (36,5) {Map Projections};\n\n\n\n     \\draw[->,thick] (39.5,5) --  +(3,0);\n\n     \\foreach \\x in {5,...,1}\n       \\draw[fill=green,xshift=1200pt] (\\x,\\x) rectangle +(4,4);\n     \\node[fill=black!10, text width= 1.8cm] (CartographicGeometry) at\n       (47,-1) {Cartographic Geometry};\n\n     %\\draw[->,thick] (36,2) --  ++(0,-10) -- ++(-30,0);\n\n  \\end{tikzpicture}\n  \\itkcaption[Image Ortho-registration Procedure]{Image Ortho-registration Procedure.}\n\\label{fig:ImageOrtho-registrationProcedure}\n\\end{figure}\n\nThis chapter introduces the functionnalities available in OTB for\nimage ortho-registration. We define ortho-registration as the\nprocedure allowing to transform an image in sensor geometry to a\ngeographic or cartographic projection.\\\\\n\nFigure \\ref{fig:ImageOrtho-registrationProcedure} shows a synoptic\nview of the different steps involved in a classical ortho-registration\nprocessing chain able to deal with image series. These steps are the following:\n\\begin{itemize}\n  \\item Sensor modelling: the geometric sensor model allows to convert\n  image coordinates (line, column) into geographic coordinates\n  (latitude, longitude); a rigorous modelling needs a digital\n  elevation model (DEM) in order to take into account the terrain\n  topography.\n  \\item Bundle-block adjustment: in the case of image series, the\n  geometric models and their parameters can be refined by using\n  homologous points between the images. This is an optional step and\n  not currently implemented in OTB.\n  \\item Map projection: this step allows to go from geographic\n  coordinates to some specific cartographic projection as Lambert,\n  Mercator or UTM.\n\\end{itemize}\n\n\n\\section{Sensor Models}\n\\ifitkFullVersion\n\\label{sec:SensorModels}\n\\fi\n\nA sensor model is a set of equations giving the relationship between\nimage pixel $(l,c)$ coordinates and ground $(X,Y)$ coordinates for every\npixel in the image. Typically, the ground coordinates are given in a\ngeographic projection (latitude, longitude). The sensor model\ncan be expressed either from image to ground -- forward model -- or\nfrom ground to image -- inverse model. This can be written as follows:\n\n\\begin{displaymath}\n  \\begin{array}{cc}\n    Forward & \\\\\n    X = f_x(l,c,h,\\vec\\theta) & Y = f_y(l,c,h,\\vec\\theta)\\\\\n     & \\\\\n    Inverse & \\\\\n    l = g_l(X,Y,h,\\vec\\theta) & c = g_c(X,Y,h,\\vec\\theta)\n  \\end{array}\n\\end{displaymath}\n\nWhere $\\vec\\theta$ is the set of parameters which describe the sensor\nand the acquisition geometry (platform altitude, viewing angle, focal\nlength for optical sensors, doppler centroid for SAR images, etc.).\\\\\n\nIn OTB, sensor models are implemented as \\doxygen{itk}{Transform}s\n(see section \\ref{sec:Transforms} for details), which is the\nappropriate way to express coordinate changes. The base class for\nsensor models is \\doxygen{otb}{SensorModelBase} from which the classes\n\\doxygen{otb}{InverseSensorModel} and\n\\doxygen{otb}{ForwardSensorModel} inherit.\\\\\n\nAs one may note from the model equations, the height of the ground, $h$,\nmust be known. Usually, it means that a Digital Elevation Model,\nDEM, will be used.\\\\\n\n\n\\subsection{Types of Sensor Models}\n\\label{sec:TypesofSensorModels}\nThere exists two main types of sensor models. On one hand, we have the\nso-called {\\em physical models}, which are rigorous, complex,\neventually highly non-linear equations of the sensor geometry. As\nsuch, they are difficult to inverse (obtain the inverse model from the\nforward one and vice-versa). They have the significant advantage of having\nparameters with physical meaning (angles, distances, etc.). They are\nspecific of each sensor, which means that a library of models is\nrequired in the software. A library which has to be updated every time a new\nsensor is available.\\\\\n\nOn the other hand, we have general analytical models, which\napproximate the physical models. These models can take the form of\npolynomials or ratios of polynomials, the so-called rational\npolynomial functions or Rational Polynomial Coefficients, RPC, also\nknown as {\\em Rapid Positioning Capability}.\nSince they are approximations, they are less accurate than the\nphysical models. However, the achieved accuracy is usually high: in\nthe case of Pl\\'eiades, RPC models have errors lower than 0.02 pixels\nwith respect to the physical model. Since these models have a standard\nform they are easier to use and implement. However, they have the\ndrawback of having parameters (coefficients, actually) without\nphysical meaning.\\\\\n\nOTB, through the use of the OSSIM library --\n\\url{http://www.ossim.org} -- offers models for most of current\nsensors either through a physical or an analytical approach. This is\ntransparent for the user, since the geometrical model for a given\nimage is instantiated using the information stored in its meta-data. The \nsearch for a sensor model is not straightforward. It is done in 3 steps :\n\\begin{enumerate}\n  \\item Search in the OSSIM plugin factory for a suitable model \n(\\code{ossimplugins::ossimPluginProjectionFactory}). For instance, this\nfactory contains Pl\\'eiades and TerraSar sensor models.\n  \\item If no model was found, search in the OSSIM projection factory \n(\\code{ossimProjectionFactoryRegistry}). For instance this factory contains\nSpot5, Landsat and Quickbird sensor models.\n  \\item If still no model was found, search for a valid sensor model defined\n in an external \\code{.geom} file. If no model is found, check if there are \nany RPC tags embedded within the image (GDAL is used to detect those RPC \ntags). When the tags are present, an \\code{ossimRpcModel} is created.\n\\end{enumerate}\n\n\n\\subsection{Using Sensor Models}\n\\label{sec:UsingSensorModels}\n\nThe transformation of an image in sensor geometry to geographic\ngeometry can be done using the following steps.\n  \\begin{enumerate}\n    \\item Read image meta-data and instantiate the model with the\n    given parameters.\n  \\item Define the ROI in ground coordinates (this is your output\n  pixel array)\n  \\item Iterate through the pixels of coordinates $(X,Y)$:\n    \\begin{enumerate}\n      \\item Get $h$ from the DEM\n      \\item Compute $(c,l) = G(X,Y,h,\\vec\\theta)$\n      \\item Interpolate pixel values if $(c,l)$ are not grid coordinates.\n    \\end{enumerate}\n  \\end{enumerate}\n\nActually, in OTB, you don't have to manually instantiate the sensor\nmodel which is appropriate to your image. That is, you don't have to\nmanually choose a SPOT5 or a Quickbird sensor model. This task is\nautomatically performed by the \\doxygen{otb}{ImageFileReader} class in\na similar way as the image format recognition is done. The appropriate\nsensor model will then be included in the image meta-data, so you can\naccess it when needed.\n\n\\ifitkFullVersion\n\\input{SensorModelExample.tex}\n\\fi\n\n\\subsection{Evaluating Sensor Model}\n\\label{sec:EvaluatingSensorModels}\n\nIf no appropriate sensor model is available in the image meta-data,\nOTB offers the possibility to estimate a sensor model from the image.\n\n\\input{EstimateRPCSensorModelExample.tex}\n\n\n\\subsection{Limits of the Approach}\n\\label{LimitsoftheApproach}\n\nAs you may understand by now, accurate geo-referencing needs accurate\nDEM and also accurate sensor models and parameters. In the case where\nwe have several images acquired over the same area by different\nsensors or different geometric configurations, geo-referencing (geographical coordinates) or ortho-rectification\n(cartographic coordinates) is not usually enough. Indeed, when working\nwith image series we usually want to compare them (fusion, change\ndetection, etc.) at the pixel level.\\\\\n\nSince common DEM and sensor parameters do not allow for such an\naccuracy, we have to use clever strategies to improve the\nco-registration of the images. The classical one consists in refining\nthe sensor parameters by taking homologous points between the images\nto co-register. This is called bundle block adjustment and will be\nimplemented in coming versions of OTB.\n\nEven if the model parameters are refined, errors due to DEM accuracy\ncan not be eliminated. In this case, image to image registration can\nbe applied. These approaches are presented in chapters\n\\ref{chap:ImageRegistration} and \\ref{sec:DisparityMapEstimation}.\n\n%% \\section{Bundle-block adjustment}\n%% Problem position\n%%   \\begin{itemize}\n%%     \\item The image series is geo-referenced (using the available DEM,\n%%     and the prior sensor parameters).\n%%     \\item We assume that homologous points (GCPs, etc.) can be easily\n%%     obtained from the geo-referenced series : $HP_i = (X_i,Y_i,h_i)$\n%%     \\item For each image, and each point, we can write:\n%%     $(l_{ij},c_{ij}) = G_j(X_i,Y_i,h_i,\\vec\\theta_j)$\n%%   \\end{itemize}\n\n%% \\begin{tikzpicture}[scale=0.15]\n%% \\draw[fill=yellow!20] (-5.5,-15.5) rectangle (5.5,-5.5);\n%%     \\draw[step=0.5, gray, very thin] (-5.5,-15.5) grid (5.5,-5.5);\n\n%%     \\draw[fill=green!20,rotate=10] (-15.5,0.5) rectangle (-5.5,10.5);\n%%     \\draw[step=0.5, gray, very thin,rotate=10] (-15.5,0.5) grid>\n%%     (-5.5,10.5);\n\n%%     \\draw[fill=blue!20,rotate=-10] (5.5,0.5) rectangle (15.5,10.5);\n%%     \\draw[step=0.5, gray, very thin,rotate=-10] (5.5,0.5) grid\n%%     (15.5,10.5);\n\n\n%%     \\draw[fill=red!70] (1,-11) circle (0.2);\n\n%%     \\draw (1,-11) .. controls +(30:1cm) and +(60:1cm) .. (-10,7);\n\n%%     \\draw[fill=red!70] (-10,7) circle (0.2);\n\n%%     \\node (eq1) at (-12.2,-4) {$\\scriptstyle{G_1(X_i,Y_i,h_i,\\vec\\theta_1)}$};\n\n%%     \\draw (1,-11) .. controls +(-30:1cm) and +(-60:1cm) .. (10,7);\n\n%%     \\draw[fill=red!70] (10,7) circle (0.2);\n\n%%     \\node (eq2) at (7.2,-3) {$\\scriptstyle{G_2(X_i,Y_i,h_i,\\vec\\theta_2)}$};\n\n%% \\end{tikzpicture}\n%% \\begin{itemize}\n%%       \\item Everything is known.\n%% \\end{itemize}\n\n\n\n%% Model refinement\n%%   \\begin{itemize}\n%%     \\item If we define $\\vec\\theta_j^R = \\vec\\theta_j +\n%%     \\vec{\\Delta\\theta_j}$ as the refined parameters,\n%%     $\\vec{\\Delta\\theta_j}$ are the unknowns of the model refinement\n%%     problem.\n%%     \\item We have much more equations than unknowns if enough HPs are\n%%     found.\n%%     \\item We solve using non-linear least squares estimation.\n%%       \\begin{itemize}\n%% \t\\item The derivatives of the sensor model with respect to its\n%% \tparameters are needed.\n%%       \\end{itemize}\n%%   \\end{itemize}\n\n\n%% Homologous point extraction\n%% From manual to automatic procedures\n%% \\begin{itemize}\n%%   \\item Manual extraction can be used for a few images and for a few\n%%   points\n%%   \\item We are interested in many images (long time series) and many\n%%   points (in order to reduce registration errors)\n%%   \\item Proposed procedure\n%%     \\begin{enumerate}\n%%       \\item Choose candidate points\n%%       \\item Define a similarity measure\n%%       \\item Optimize the measure\n%%     \\end{enumerate}\n%% \\end{itemize}\n\n%% Salient points\n%% Similarity measures\n\n\n\\section{Map Projections}\n\\ifitkFullVersion\n\\label{sec:MapProjections}\n\\fi\n\nMap projections describe the link between geographic coordinates and\ncartographic ones. So map projections allow to represent a 2-dimensional manifold of a\n3-dimensional space (the Earth surface) in a 2-dimensional space (a\nmap which used to be a sheet of paper!). This geometrical\ntransformation doesn't have a unique solution, so over the cartography\nhistory, every country or region in the world has been able to express\nthe belief of being the center of the universe. In other words, every\ncartographic projection tries to minimize the distortions of the 3D to\n2D transformation for a given point of the Earth surface\\footnote{We\n  proposed to optimize an OTB map projection for Toulouse, but we\n  didn't get any help from OTB users.}.\n\nIn OTB the \\doxygen{otb}{MapProjection} class is derived from the\n\\doxygen{itk}{Transform} class, so the coordinate transformation\npoints are overloaded with map projection equations. The\n\\doxygen{otb}{MapProjection} class is templated over the type of\ncartographic projection, which is provided by the OSSIM library. In\norder to hide the complexity of the approach, some type definitions\nfor the more common projections are given in the file\n\\code{otbMapProjections.h} file.\n\nSometimes, you don't know at compile time what map projection you will need in\nyour application. In this case, the \\doxygen{otb}{GenericMapProjection}\nallow you to set the map projection at run-time by passing the WKT identification\nfor the projection.\n\n\\input{MapProjectionExample.tex}\n\nYou will seldom use a map projection by itself, but rather in an\northo-rectification framework. An example is given in the next section.\n\n\n\n\n\\section{Orthorectification with OTB}\n\\ifitkFullVersion\n\\label{sec:OrthorectificationwithOTB}\n\\fi\n\\input{OrthoRectificationExample.tex}\n\n\\section{Vector data projection manipulation}\n\\ifitkFullVersion\n\\label{sec:VectorDataProjection}\n\\fi\n\\input{VectorDataProjectionExample.tex}\n\n\\section{Geometries projection manipulation}\n\\ifitkFullVersion\n\\label{sec:GeometriesProjection}\n\\fi\n\\input{GeometriesProjectionExample.tex}\n\n\\section{Elevation management with OTB}\n\\input{DEMHandlerExample.tex}\n\n\\section{Vector data area extraction}\n\\ifitkFullVersion\n\\label{sec:VectorDataAreaExtraction}\n\\fi\n\\input{VectorDataExtractROIExample.tex}\n", "meta": {"hexsha": "f372d4eb5269db49b1f96e341434f7b1a6ea4d55", "size": 14714, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/SoftwareGuide/Latex/OrthoRectification.tex", "max_stars_repo_name": "lfyater/Orfeo", "max_stars_repo_head_hexsha": "eb3d4d56089065b99641d8ae7338d2ed0358d28a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-02-13T14:48:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-03T02:54:28.000Z", "max_issues_repo_path": "Documentation/SoftwareGuide/Latex/OrthoRectification.tex", "max_issues_repo_name": "lfyater/Orfeo", "max_issues_repo_head_hexsha": "eb3d4d56089065b99641d8ae7338d2ed0358d28a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-10-14T10:11:38.000Z", "max_issues_repo_issues_event_max_datetime": "2015-10-15T08:26:23.000Z", "max_forks_repo_path": "Documentation/SoftwareGuide/Latex/OrthoRectification.tex", "max_forks_repo_name": "lfyater/Orfeo", "max_forks_repo_head_hexsha": "eb3d4d56089065b99641d8ae7338d2ed0358d28a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-01-17T10:36:14.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-03T02:54:36.000Z", "avg_line_length": 38.4177545692, "max_line_length": 112, "alphanum_fraction": 0.7257713742, "num_tokens": 4107, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.42230199718088396}}
{"text": "\\documentclass[]{article}   % list options between brackets\n\\usepackage{verbatim}\n\\usepackage{graphicx}\n\\usepackage[margin=0.75in]{geometry}            % list packages between braces\n\n% type user-defined commands here\n\n\\begin{document}\n\n\\title{infer\\_sde user manual}   % type title between braces\n\\author{Cyril Galitzine}         % type author(s) between braces\n\\date{\\today}    % type date between braces\n\\maketitle\n\n\n\\section{Introduction}     % section \n\ninfer\\_sde is a Python code that allows the inference of the distribution of the rates of a stochastic differential equation (SDE) from a single or multiple noisy observation(s) of its trajectory. It is based on a Markov chain Monte Carlo (MCMC) method which samples from the posterior rate distribution. The likelihood of the data is estimated via a particle filter method. Further details about the inference method can be found in \\cite{Galitzine}\n\n It was initially created to infer the rates governing peroxisome dynamics \\cite{Galitzine}. In such situation, we are interested in inferring three rates $k_{d}, k_{f}, \\gamma$ and the standard deviation of the measurement error $\\sigma$. The peroxisome count $X_{t}$ at time $t$ is governed by the following SDE:\n\\begin{equation}\nd X_{t} = \\left[k_{d} + \\left(k_{f} - \\gamma\\right) X_{t} \\right] dt + \\left[k_{d} + \\left(k_{f} + \\gamma\\right) X_{t} \\right]^{1/2} d W_{t}\n\\label{BDI} \n\\end{equation}\nwhich corresponds to a birth-death-immigration (BDI) stochastic process.\nWe simultaneously observe multiple \\emph{realizations} of this SDE by measuring the $X_{t}$ time course in multiple cells. Each realization of the stochastic process is called a \\emph{replicate} in the following the biology terminology.\n\nThe code can readily be extended to other types of SDEs because of its modular object oriented design.\n\n\\section{Running the code}     % section 2.1\n\\subsection{Input files}    \n\t\\subsubsection{sim.dat}\n\tThis file is used to simulate data which is then stored the data.csv file. A typical sim.dat file is reproduced below:\n\t\\verbatiminput{sim.dat}\nThe different lines of the file are described below:\t\n\\begin{itemize}\n\\item {\\tt{Equation\\_sim}}: Name of the SDE to simulate. Currently the following SDE are available:\n\\begin{description}\n \\item {\\tt BDI}: Eq.~(\\ref{BDI}) with parameters $k_{d},k_{f} \\textrm{ and } \\gamma$ (in that order). In this case the equivalent master equation is simulated via the Gillespie algorithm. This potentially avoid any error in the simulation of the SDE.\n\\end{description}\n\\item {\\tt{Error\\_model\\_sim}}: Error model to use to simulate data. Currently the following models are available:\n\\begin{description}\n \\item {\\tt Normal}: Measured values $x_{\\textrm{measured}}$ are obtained from the true hidden values, $x_{\\textrm{hidden}}$ following $x_{\\textrm{measured}} \\sim \\textrm{Normal}\\left(\\mu =  x_{\\textrm{hidden}}, \\sigma = \\mathtt{error\\_sim} \\right)$. The standard deviation is assumed to be constant with time and the same for all replicates.\n\\end{description}\n\\item {\\tt{Nrep\\_sim}}: Number of replicates to simulate\n\\item {\\tt{param\\_sim}}: Value of the parameters used to simulate data. The order of the parameters has to correspond to that required by the SDE type.\n\\item {\\tt{Rate\\_heterogeneity\\_model\\_sim}}:\nHeterogeneity model for the rates between replicates\n\\begin{description}\n\\item{\\tt{Homogeneous}}: The data of all replicates is generated with the exact same rates\n\\item{\\tt{Heterogeneous}}: Rates vary between replicates following a gamma distribution for each rate. When this option is used {\\tt param\\_sim} does not specify directly the rates of the SDE but instead the mean and standard deviation of the gamma distribution of each rate. Assuming that the standard deviation is 10\\% of the rate mean, {\\tt param\\_sim} would become instead {\\tt [7.75e-4,7.75e-5,4.0e-5,4.0e-6,4.0e-5,4.0e-6]} of {\\tt [7.75e-4,4.0e-5,4.0e-5} for {\\tt Homogeneous} rate model.\n\\end{description}\n\\item {\\tt{Error\\_heterogeneity\\_model\\_sim}}:\n\\begin{description}\n\\item{\\tt{Homogeneous}}: The data of all replicates is generated with the same error standard deviation.\n\\end{description}\n\\item {\\tt{X0\\_sim}}: Initial value at time $t=0$. This value should be specified for each {\\tt N\\_rep\\_sim} replicate. If it is not the initial value is determined via Poisson distribution with $\\lambda=$ {\\tt X0\\_sim}.\n\\item {\\tt{Ntime\\_sim}}: Number of time points (A constant $\\Delta t$ is used)\n\\item {\\tt{T\\_sim}}: Overall simulation time (has to be in the same time unit as the rate specified with {\\tt{param\\_sim}}).\n \\end{itemize}\n\t\t\n\t\n      \\subsubsection{data.csv}\n      data.csv contains the time course data that is used for the inference. It can be either generated by simulation or obtained through experimental measurement. The first few lines of typical data.csv file are reproduced below:\n\t\\verbatiminput{data.csv}\n      The first column corresponds to the index of the DataFrame is not important. It does not need to be specified. The following comma separated columns: {\\tt replicate, t, x} should always be present. The number of replicate starts at 0 and should always be specified even if there is only a single replicate.\n\\newpage      \n  \\subsubsection{inference.dat}\n  \n  The inference.dat file controls the inference procedure. A typical inference.dat file (the one used in example BDI\\_4rep\\_homogeneous\\_rates\\_parallel) is detailed below:\n        \\verbatiminput{inference.dat}\n\n\\begin{itemize}\n\\item {\\tt{Simulate\\_data}}: 0: Read existing data.csv file (if it exists), 1: Simulate new data \n\\item {\\tt{Equation}}: Name of the SDE to simulate. Currently the following SDE(s) are available:\n\\begin{description}\n \\item {\\tt BDI}: Eq.~(\\ref{BDI}) with parameters $k_{d},k_{f} \\textrm{ and } \\gamma$ (in that order).\n\\end{description}\n\\item {\\tt{Error\\_model}}: Error model for the data. Currently the following models are available:\n\\begin{description}\n \\item {\\tt Normal}: Measured values $x_{\\textrm{measured}}$ are obtained from the true hidden values, $x_{\\textrm{hidden}}$ following $x_{\\textrm{measured}} \\sim \\textrm{Normal}\\left(\\mu =  x_{\\textrm{hidden}}, \\sigma = \\mathtt{error\\_sim} \\right)$. The standard deviation is assumed to be constant with time for each replicate.\n\\end{description}\n\\item {\\tt{Nsamp}}: Number of accepted MCMC samples to calculate. MCMC sample proposals that are not accepted are not counted.\n\\item {\\tt{Npart}}: Number of particles to use for the particle filter\n\\item {\\tt{param}}: Initial starting value for the parameters at step 0. The parameters have to be in the correct order dictated by {\\tt Equation}.\n\\item {\\tt{param\\_infer}}: Infer parameter of {\\tt param} 0/1 = Yes/No. In case param\\_infer=0 for a particular parameter, its value is assumed constant and equal to that specified in {\\tt param}.\n\\item {\\tt{param\\_error}}: Initial starting value for the error parameter at step 0. The names specified for the error parameters do not matter. Typically one error parameter is inferred for each replicate such as here.\n\\item {\\tt{param\\_error\\_infer}}: Infer parameter of {\\tt param\\_error} 0/1 = Yes/No. In case param\\_error\\_infer=0 for a particular parameter, its value is assumed constant and equal to that specified in {\\tt param\\_error}.\n\\item {\\tt{Rate\\_heterogeneity\\_model}}:\nHeterogeneity model for the rates between replicates\n\\begin{description}\n\\item{\\tt{Homogeneous}}: Assume that all replicates are governed by the exact same rates.\n\\item{\\tt{Heterogeneous}}: Assume that rates vary between replicates following a gamma distribution for each rate. When this option is used {\\tt param} does not specify directly the initial rate values of the SDE but instead the initial mean and standard deviation of the gamma distribution of each rate. Assuming that initially the standard deviation is 10\\% of the rate mean, {\\tt param\\_sim} would become instead\n\n {\\tt [7.75e-4,7.75e-5,4.0e-5,4.0e-6,4.0e-5,4.0e-6]} of {\\tt [7.75e-4,4.0e-5,4.0e-5} for {\\tt Homogeneous} rate model.\n\\end{description}\n \\item {\\tt{Error\\_heterogeneity\\_model}}:\n Heterogeneity model for the measurement error between replicates\n \\begin{description}\n\\item{\\tt{Homogeneous}}: Assumes that each replicate has a different error standard deviation. This terminology might be misleading but it used for consistency with the rate heterogeneity model. When this model is used, {\\tt param\\_error} needs to contain one error standard deviation for each replicate.\n\\end{description}\n \\item {\\tt{sd\\_MH}}:\nParameter controlling the step size of the Metropolis Hastings algorithm. It should be adjusted so that the average acceptance rate is around 0.3.\n \\item {\\tt{MH\\_step\\_scaling}}: Metropolis Hasting stepping method. The following methods are available:\n\\begin{description}\n\\item{\\tt{exponential}}: New samples are generated following a log-normal distribution centered on the current value, i.e.~$x^{n+1} = x^{n}\\exp\\left(Z\\right)$ with $Z \\sim \\mathcal{N}\\left(0,\\sigma_{\\textrm{MH\\_step\\_scaling}}\\right)$. This stepping method ensures that each rate step is always properly scaled that the rates remains positive (rates are always defined to be positive).\n\\end{description}\n \\end{itemize}\n\n\n\\subsection{Output files}\n\n\\subsubsection{out.dat}\n\nThis file contains the accepted MCMC samples (rejected samples are not recorded) for each of the parameter listed in the inference.dat file. It also contains the overall likelihood of the data. The out.dat file obtained with the inference.dat file shown above looks like this: (in small fonts to show everything...)\n{\\tiny \\verbatiminput{out.dat}}\nThe columns correspond to the samples for rates specified in {\\tt parama} and {\\tt param\\_error} (in the same order). The last column is the log likelihood calculated for that particular set of parameters.\n\n\\section{Running the code}\n\n\\subsection{Overall workflow} \n\n\\subsection{Simulating data with infer\\_sde\\_serial.py}\n\nTo simulate data, remove any existing data.csv file and run the serial inference code: {\\tt python infer\\_sde\\_serial.py} . You should have all the *.py files in the directory where you execute this command as well as the following required input files: {\\tt sim.dat}, {\\tt inference.dat}. \n If you do not wish to perform inference simply stop the executing of the code after a few steps once you are sure that data.csv has been generated. \n\nYou can plot the trajectories that you just generated in the {\\tt data.csv} file by running {\\tt python plot\\_traj.py} which will produce a plot: {\\tt data.png}\n\nIt is also likely that you will have to modify the code in time\\_series.py to generate simulated data that conforms to your desired specifications This is because simulating data according to sim.dat can only produce a very narrow set of data types. For instance, it cannot generate replicates with different numbers of time points or overall times.\n\n\\subsection{Running the serial inference code with infer\\_sde\\_serial.py}\n\nThe inference code is executed by typing {\\tt python infer\\_sde\\_serial.py}\nYou should have all the *.py files in the directory where you execute this command as well as the following required input files: {\\tt sim.dat}, {\\tt inference.dat} of course the data file {\\tt data.csv}. When the code runs, it will output for each accepted sample the value of the parameters and measurement errors, the log likelihood (L), the max log likelihood (called Lmin) and the average acceptance ratio AR. The value of {\\tt sd\\_MH} in {\\tt inference.dat} should be adjusted so that the acceptance ratio is around 0.3 (i.e.~the optimum acceptance ratio for the Metropolis Hastings algorithm).\n\n\\subsection{Running the parallel inference code with infer\\_sde\\_parallel.py}\n\nThe inference code was parallelized across replicates using a python version of the MPI library mpi4py. This allows us to split the calculation of the overall log likelihood across multiple CPUs to speed up the sampling procedure (but only when multiple replicates are considered). The $N_{\\textrm{rep}}$ replicates are distributed as uniformly as possible across CPUs. Each CPU then calculates the sum of the log likelihoods of all the replicates that are assigned to it. The log likelihoods sums are then summed again across cpus to calculate the overall log likelihood. When using $N_{\\textrm{CPU}}$ to run the inference, one CPU (the master CPU) will not be performing calculations. As such the calculation will be distributed among the remaining $N_{\\textrm{CPU}} -1$ CPUs. For instance, if want to infer the rates for $N_{\\textrm{rep}} = 4$ replicates and use  $N_{\\textrm{CPU}}=5$, each CPU will calculate the likelihood of one replicate which leads to the optimal speedup. If $N_{\\textrm{CPU}}=4$ are used for the same 4 replicates, the replicates will be split as follows across CPUs: $\\overbrace{\\textrm{Rep1}}^{\\textrm{CPU 2}} \\vert \\overbrace{\\textrm{Rep2}}^{\\textrm{CPU 3}} \\vert \\overbrace{\\textrm{Rep3},\\textrm{Rep4}}^{\\textrm{CPU 4}}$ The fourth CPU will calculate the likelihood of two replicates) while CPU 1, the master CPU, is not involved in the calculation of likelihoods. If $N_{\\textrm{CPU}}=3$, we would obtain the following: $\\overbrace{\\textrm{Rep1},\\textrm{Rep2}}^{\\textrm{CPU 2}} \\vert \\overbrace{\\textrm{Rep3},\\textrm{Rep4}}^{\\textrm{CPU 3}}$. $N_{\\textrm{CPU}}=2$ should not be employed since the it will less efficient than the serial code the due to the master CPU.\\\\\n\n\nTo run the inference with, e.g. NCPUS = 4 the following should be executed:\\\\\n{\\tt mpirun -np 4 python3 infer\\_sde\\_parallel.py}\n\n\nThe inputs and outputs of the parallel code are identical to those of the serial code.\n\n\\subsection{Analyzing results with analyze\\_mcmc.py}\n\nThe inference code (serial or parallel) produces an {\\tt out.dat} file with the posterior rate samples. Plots of the distribution of the rates can be obtained by running {\\tt python analyze\\_mcmc.py}. This produces density (*\\_density.pdf) and correlation (*\\_corr.pdf) plots for the inferred parameters. The sampling frequency of the parameters ({\\tt frequency} variable) in {analyze\\_mcmc.py} should be adjusted so that the consecutive samples are not too correlated which otherwise results in an inaccurate estimation of the densities.\n\n\\newpage\n\\section{Test cases}\n\\subsection{BDI {(\\small birth death immigration)} SDE: $dX_{t} =  \\left[k_{d} + \\left(k_{f} - \\gamma\\right) X_{t} \\right] dt + \\left[k_{d} + \\left(k_{f} + \\gamma\\right) X_{t} \\right]^{1/2} d W_{t}$}\n\n\\subsubsection{1 replicate, serial (EXAMPLES/BDI\\_1rep)}\n\nAll the input, output files and results of the inference can be found in folder EXAMPLES/BDI\\_1rep. Data was simulated according to the following sim.dat for a single replicate:\n\\verbatiminput{../EXAMPLES/BDI_1rep/sim.dat}\nThe serial inference code, {\\tt infer\\_sde\\_serial.py}, was run for 24 hours and the results were analyzed with {\\tt analyze\\_mcmc.py}.\n\n\n\\subsubsection{4 replicates, Homogeneous rates, serial (EXAMPLES/BDI\\_4rep\\_homogeneous\\_rates\\_serial)}\n\nAll the input, output files and results of the inference can be found in folder EXAMPLES/BDI\\_1rep. \nData was simulated according to the following sim.dat for 4 replicates (homogeneous rates):\n\\verbatiminput{../EXAMPLES/BDI_4rep_homogeneous_rates_serial/sim.dat}\nThe serial inference code, {\\tt infer\\_sde\\_serial.py}, was run for 24 hours and the results were analyzed with {\\tt analyze\\_mcmc.py}.\n\n\n\\subsubsection{4 replicates, Homogeneous rates, parallel (EXAMPLES/BDI\\_4rep\\_homogeneous\\_rates\\_parallel)}\nThe same data as for case BDI\\_4rep\\_homogeneous\\_rates\\_serial was used. The parallel inference code was run for 24 hours using 5 CPUs with {\\tt mpirun -np 5 python infer\\_sde\\_parallel.py}. Results were then analyzed with {\\tt analyze\\_mcmc.py}.\n\n\\subsubsection{4 replicates, Heterogeneous rates, parallel (EXAMPLES/BDI\\_4rep\\_heterogeneous\\_rates\\_parallel)}\nAll the input, output files and results of the inference can be found in folder EXAMPLES/BDI\\_4rep\\_heterogeneous\\_rates\\_parallel. \nData was simulated according to the following sim.dat for 4 replicates (heterogeneous rates between replicates):\n\\verbatiminput{../EXAMPLES/BDI_4rep_heterogeneous_rates_parallel/sim.dat}\n\n\\bibliography{bib.bib}\n\n\\bibliographystyle{plain}\n\\end{document}", "meta": {"hexsha": "3f552ce0d386e105ebb30f3e36a84d25c4c71e4c", "size": 16232, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DOCS/manual.tex", "max_stars_repo_name": "cyrilgalitzine/SDE_inference", "max_stars_repo_head_hexsha": "e64e9c5cdf4c13bf3ba67071949c71b0a1b6d8fe", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-28T19:17:36.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-28T19:17:36.000Z", "max_issues_repo_path": "DOCS/manual.tex", "max_issues_repo_name": "cyrilgalitzine/SDE_inference", "max_issues_repo_head_hexsha": "e64e9c5cdf4c13bf3ba67071949c71b0a1b6d8fe", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DOCS/manual.tex", "max_forks_repo_name": "cyrilgalitzine/SDE_inference", "max_forks_repo_head_hexsha": "e64e9c5cdf4c13bf3ba67071949c71b0a1b6d8fe", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.1868131868, "max_line_length": 1700, "alphanum_fraction": 0.7656481025, "num_tokens": 4224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4222927900469588}}
{"text": "\\subsection{Sliding Window Filter} \\label{sliding_window_filter}\nThis section explains a sliding window filter and the way to embed the filter into a sliding window application as\ndescribed in section \\ref{sliding_window_technique}. A time series filter is in general a function that takes a time\nseries as argument and returns true or false. One possible underlying inner functionality approach of the filter is\npresented later in this section. The previous version of a sliding window application is extracting the current time\nseries window and passes it directly to a time series classificator. This approach is extended by embedding a time\nseries filter directly after the extraction and ahead of the time series classificator. The time series filter has the\ntask to prune the amount of time series windows that reach the classificator. Time series windows which would be\nassessed as unclassifiable by the classificator should be blocked by the filter as much as possible. Figure\n\\ref{fig:swf} illustrates the way of embedding the time series filter into the workflow of a sliding window application.\n\\clearpage\n\\begin{figure}\n    \\begin{center}\n        \\resizebox {\\textwidth} {!} {\n            {\\tiny\n                \\begin{tikzpicture}[node distance = 1.5cm, auto]\n                    \\node [block] (sod) {sensors or devices};\n                    \\node [block, right of=sod, node distance=6cm, text width=2cm] (extract) {Extract last subsequence from Q of size $w$, $Q[t-w,t]$};\n                    \\node [block, draw=blue, right of=extract, node distance=4cm, text width=2cm] (filter) {Time series filter};\n                    \\node [decision, draw=blue, below of=filter] (filterdecide) {$Q[t-w,t]$ can pass?};\n                    \\node [block, below of=filterdecide, node distance=2cm, text width=2cm] (nnc) {Time series classificator};\n                    \\node [decision, below of=nnc] (decide) {$Q[t-w,t]$ classifiable?};\n                    \\node [block, left of=decide, node distance=3cm] (sleeps) {Sleep for $s$ time};\n                    \\node [block, below of=decide, node distance=2cm, text width=2cm] (action) {Trigger event that $Q[t-w,t]$ has been classified and sleep for $w$ time};\n\n                    \\path [line,dashed] (sod) -- node (ctss) {Continuous time series stream $Q$} (extract);\n                    \\path [line] (extract) -- node {$Q[t-w,t]$} (filter);\n                    \\path [line] (filter) -- (filterdecide);\n                    \\path [line] (filterdecide) -- node {yes} (nnc);\n                    \\path [line] (filterdecide) -| node [near start] {no} (sleeps);\n                    \\path [line] (nnc) -- (decide);\n                    \\path [line] (decide) -- node {no} (sleeps);\n                    \\path [line,dashed] (sleeps) -| (ctss);\n                    \\path [line] (decide) -- node {yes} (action);\n                    \\path [line,dashed] (action) -| (ctss);\n                \\end{tikzpicture}\n            }\n        }\n    \\end{center}\n    \\caption{Extended design for a sliding window application as in figure \\ref{fig:swt}, plus the additional filter\n    highlighted in blue. The current time is stored in variable $c$. The variables $w$ for the window size and $s$ for\n    the step size are predefined.}\n    \\label{fig:swf}\n\\end{figure}\n\nThe integration of the time series filter into a sliding window application is described above. An underlying inner\nfunctionality approach of a time series filter is the usage of a simple time series measures function. The argument of\nsuch a time series measure function should be one time series and the result should be an element of $\\mathbb{R}$.\nLinear time and memory complexity are basic requirements for a measure to ensure an acceptable performance of the\nfilter. A filter instance based on a suitable time series measure has access to the same training set of time series as\nthe classificator. The measure executed on every time series in the training set results in a maximum and a minimum\nvalue. Both values together are creating an interval. This interval is called filter interval. Every measure value of the\ntraining set is inside of the boundaries of the filter interval. The approach of a measure based filter is that many\nclassifiable time series windows should have a measure value inside of the interval and many unclassifiable time series\nwindows should have a measure value outside of the interval boundaries. Incoming time series windows with a measure\nfunction value inside the interval boundaries can pass to the classification. All other windows are blocked by the\nfilter. A factor can expand the filter interval to avoid the mistakenly blocking of classifiable time series windows.\nThis factor is called blur factor and is expressed as a percentage number. Assumed is a simple example, the left\nboundary of the filter interval is 10 and the right boundary is 20. A blur factor of 160\\% will result in a new filter\ninterval of 7 and 23. The filter interval will be expanded artificially on the left and the right side. Possible time\nseries measure functions are mentioned in \\ref{complexity_estimate} and \\ref{sample_variance}.\n", "meta": {"hexsha": "35c889e65672ed8ed59449fd08af43c3045e27f3", "size": 5139, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bachelor-thesis/background_and_notation/sliding_window_filter.tex", "max_stars_repo_name": "GordonLesti/SlidingWindowFilter", "max_stars_repo_head_hexsha": "22c11f2912a5c523ae8ad85a849e2d0b123536ec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-22T09:37:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-14T11:43:53.000Z", "max_issues_repo_path": "bachelor-thesis/background_and_notation/sliding_window_filter.tex", "max_issues_repo_name": "GordonLesti/SlidingWindowFilter", "max_issues_repo_head_hexsha": "22c11f2912a5c523ae8ad85a849e2d0b123536ec", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bachelor-thesis/background_and_notation/sliding_window_filter.tex", "max_forks_repo_name": "GordonLesti/SlidingWindowFilter", "max_forks_repo_head_hexsha": "22c11f2912a5c523ae8ad85a849e2d0b123536ec", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-01-11T23:15:57.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-11T23:15:57.000Z", "avg_line_length": 82.8870967742, "max_line_length": 170, "alphanum_fraction": 0.7028604787, "num_tokens": 1202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.42229278998437597}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[pdftex]{graphicx}\n\n\\usepackage{qtree}\n\n\n\\usepackage{xspace}\n\n\\usepackage{setspace} \n\\usepackage{float}\n\n\\usepackage{stmaryrd}\n\\usepackage{mathptmx}% http://ctan.org/pkg/mathptmx\n\\usepackage{times}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem{thm}{Theorem}[section]\n\n\n\\usepackage{natbib}\n\n\\title{The math of the \\textsc{cath}}\n\\author{Meaghan ``geitje'' Fowlie and Floris ``konijntje'' van Vugt}\n\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Definitions}\n\n\n\n%\\newcommand\\STATES{\\mathcal{S}}\n\\newcommand\\STATES{\\ensuremath{\\mathbb{S}}\\xspace}\n%\\newcommand\\OPS{\\mathcal{O}}\n\\newcommand\\OPS{\\ensuremath{\\mathbb{O}}\\xspace}\n%\\newcommand\\BIGR{\\mathcal{B}}\n\\newcommand\\BIGR{\\ensuremath{\\mathbb{B}}\\xspace}\n\\newcommand\\FSA{\\textsc{FSA}\\xspace}\n%\\newcommand\\PARSES{\\mathcal{P}}\n\\newcommand\\PARSES{\\ensuremath{\\mathbb{P}}}\n\\newcommand\\SC{\\text{\\textsc{sc}}}\n\\newcommand\\TC{\\text{\\textsc{tc}}}\n\\newcommand\\UC{\\text{\\textsc{uc}}}\n\\newcommand\\BC{\\text{\\textsc{bc}}}\n\\newcommand\\N{\\ensuremath{\\mathbb{N}}}\n\\newcommand\\sg{\\ensuremath{\\Sigma}\\xspace}\n\\newcommand\\la{\\ensuremath{\\langle}\\xspace}\n\\newcommand\\ra{\\ensuremath{\\rangle}\\xspace}\n\\newcommand\\arr{\\ensuremath{\\rightarrow}\\xspace}\n\\newcommand\\emp{\\ensuremath{\\epsilon}\\xspace}\n\n\\newcommand\\op{\\text{\\textsl{op}}\\xspace}\n\\newcommand\\mg{\\text{\\textsl{mg}}\\xspace}\n\\newcommand\\cp{\\text{\\textsl{copy}}\\xspace}\n\\newcommand\\cl{\\text{\\textsl{clear}}\\xspace}\n\\newcommand\\ed{\\text{\\textsl{end}}\\xspace}\n\\newcommand\\start{\\text{\\textsl{start}}\\xspace}\n\n\n\\newcommand\\expr{\\text{\\textsl{expr}}\\xspace}\n\\newcommand\\Lex{\\text{\\textsl{Lex}}\\xspace}\n\\newcommand\\fea[1]{\\text{\\texttt{#1}}\\xspace}\n\\newcommand\\LBOUND{\\ensuremath{\\rtimes}}\n\\newcommand\\RBOUND{\\ensuremath{\\ltimes}}\n\\newcommand\\OURG{\\text{\\textsc{cath}}\\xspace}\n\n\n\\newcommand\\llb{\\ensuremath{\\llbracket}}\n\\newcommand\\rrb{\\ensuremath{\\rrbracket}}\n\n\\newcommand\\IF{\\text{ if }\\xspace}\n\\newcommand\\der{\\leftarrow}\n%\\newcommand\\der{\\text{:-}}\n\n\nWe define a deterministic finite state automaton over operations and a Markov chain over the alphabet. these two components make up the grammar. \\\\\n\n\\noindent\\textbf{Notation} the size of a set or sequence $A$ is notated $|A|$ or $\\#A$. The \\textit{i}th member of a sequence $A$ is notated $A(i)$, the last member $A(-1)$, and all but the first $A(1:)$. $\\emp$ is the empty sequence.\n\n\n\\subsection{The Grammar}\n\\label{sec:grammar}\n\n\n\n\\begin{definition}[Deterministic Finite State Automaton]\n  A deterministic finite state automaton (DFSA) is a five-tuple \n\\[\\la \\sg, Q, q_0, F, \\delta  \\ra  \\]\nwhere:\n\n\\noindent $\\sg$ is an alphabet\\\\\n$Q$ is a finite set (\\textit{states})\\\\\n$q_0\\in Q$ is the designated \\textit{start state}\\\\\n$F\\subseteq Q$ is the set of \\textit{final states}\\\\\n$\\delta: Q\\times \\sg \\arr Q$ is the \\textit{transition function} \n\nA string $s\\in\\sg^*$ is accepted/generated by a DFSA $A$ iff\n$\\exists \\mathbf{q} \\in Q_A^*$ such that $\\mathbf{q}(0)=q_0$, $\\mathbf{q}(-1)\\in F_A$, and $\\forall i<|s|$, $\\delta(\\mathbf{q}(i),s(i))=\\mathbf{q}(i+1)$\n\\label{def:dfsa}\n\\end{definition}\n\n\\begin{definition}\n  We say a triple $(q,e,q')$ where $q,q'\\in Q$ and $e\\in\\sg$ is a \\textit{transition} of an\n  FSA iff $\\delta(q,e)=q'$.\n\\end{definition}\n\nWe define a grammar which generates a language \\textit{surface strings} over an alphabet \\sg by application of operations $\\OPS=\\{\\mg,\\cl,\\cp,\\ed\\}$. The choice of operation is governed by a DFSA in which the operations are the emissions of transitions.\n\nIn our operations FSA \\OPS, the set of all possible states is \\STATES=\\{S,NotCL,CL$_S$,CL,F\\} and the alphabet is the set of all operations is $O=\\{\\mg,\\cl,\\cp,\\ed\\}$. The bigram set or transition set, is $\\BIGR\\subseteq\\sg^*$.\n\n\n\\begin{definition}[Operations FSA]\n  The operations FSA is a deterministic finite state automaton over states \\STATES and alphabet \\OPS.\n\\end{definition}\n\n\\begin{definition}[Transition Probabilities]\n   \n  A probability assignment $\\phi$ is a function from transitions of the operations FSA to [0,1] such that\n\n$$\\forall q\\in \\STATES,~~\\sum_{e\\in\\OPS,q'\\in \\STATES} \\phi(q,e,q') = 1 $$\n\n\\end{definition}\n\n\\begin{definition}[Markov Chain]\n  A Markov chain is a 4-tuple $\\la \\sg, S, B, \\phi  \\ra $ where \n\n\\sg  is a finite alphabet of symbols, \n\n$S\\subseteq \\sg$ is a set of start categories,\n \n$B\\subseteq \\sg\\times\\sg$ is a set of transitions between members of \\sg, and\n\n$\\phi: \\sg \\times \\sg \\arr [0,1]$ is a probability distribution over transitions such that\n\n$$\\forall a\\in \\sg,~~\\sum_{b\\in\\sg} \\phi(a,b) = 1 $$\n\n\nA sequence $s$ is accepted/generated by the chain iff $s$ is a sequence of alphabet items such that $s(0) \\in S$ and $\\forall i<|s|$, $\\phi(s(i),s(i+1))>0$ \n\n\\end{definition}\n\n\\begin{definition}[route]\n  A \\emph{route} is a route through the $\\FSA$ of say $n$ steps, defined as a tuple $(Q,E)$ where $Q$ is the sequence of states visited, i.e.\n%  $Q=\\la q_i\\in\\STATES|i<n\\ra$, and $E$ is the sequence of emissions.\n $E=\\la e_i\\in\\OPS|i<n-1\\ra$ such that $\\forall i<n,~ \\delta(q_i,e_i)=q_{i+1}$.\n\n\\end{definition}\n\n \n\n\\begin{definition}[\\OURG]\n  \\OURG = \\la \\OPS,\\BIGR\\ra  where\n\n  $\\OPS = \\la \\{\\mg,\\cp,\\cl,\\ed\\}, \\{S,NotCL,CL_S,CL,F\\}, S, \\{F\\}, \\phi_\\OPS\\ra$ is the DFSA given in Figure \\ref{fig:ops}\n\n  $\\BIGR = \\la \\sg\\cup\\{{\\LBOUND}\\}, \\{\\LBOUND\\}, B, \\phi_\\BIGR \\ra$ is a Markov Chain  for some alphabet \\sg and a left boundary marker \\LBOUND.\n  \n\\end{definition}\n\n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=5in]{ops.png}\n  \\caption{\\OPS}\n  \\label{fig:ops}\n\\end{figure}\n\n\n\\begin{definition}[Derivation of \\OURG]\n  A \\textit{derivation} of a grammar \\OURG = \\la\\OPS,\\BIGR\\ra is a pair (ops,bis) where $ops\\in\n  L(\\OPS)^*$ and $bis\\in L(\\BIGR)$, and  $|bis|=|ops\\restriction\\mg| $\n\\end{definition}\n\n\\begin{thm}\n  A derivation (ops,bis) is valid iff:\n\n  \\begin{enumerate}\n  \\item ops[0]=\\mg\n  \\item There is exactly one \\ed and it is the last element of ops.\n  \\item $(ops\\restriction \\{\\cp,cl\\})[-1]\\neq\\cl$\n  \\item $(ops\\restriction \\{\\cp,cl\\})$ has no contiguous subsequence \\cl \\cl\n\\end{enumerate}\n\n\\label{thm:valid-properties}\n\\end{thm}\n\n\n\n\\begin{definition}[Derivation Tree grammar]\n  The derivation tree grammar for \\OURG is defined by the following CFG. Note that this overgenerates, in that there are dts for invalid derivations among the parse trees.\n  \\begin{itemize}\n  \\item \\cp \\arr \\cp $|$ \\mg\n  \\item \\cl \\arr \\cp $|$ \\mg\n  \\item \\ed \\arr \\cp $|$ \\mg\n  \\item \\mg \\arr \\op a ~~~~~~ $\\forall \\op\\in O\\cup\\{\\start\\}, \\forall a\\in\\sg$\n  \\end{itemize}\n\n  The set of parse trees for this grammar is $T_{O\\cup\\sg\\cup\\start}$.\n  \n\\end{definition}\n\n\n\\begin{definition}[Derivation trees of \\OURG (DT(\\OURG))]\n  The derivation tree for a derivation (ops,bis) is defined by the function $D:O^* \\times \\sg^* \\times T_{O\\cup\\sg\\cup\\start} \\arr (O^* \\times \\sg^* \\times T_{O\\cup\\sg\\cup\\start}) \\cup T_{O\\cup\\sg\\cup\\start}$ as follows:\\\\\n\n  $D(ops,bis,t)=  \n  \\begin{cases}\n    t & \\text{ if } ops=bis=\\emp\\\\\n    D(ops(1:),bis(1:),\\mg(t,bis(0))) & \\text{ if } ops(0)=\\mg ~\\&~ bis\\neq\\emp\\\\\n    D(ops(1:),bis,\\op(t)) & \\text{ if } ops(0)\\neq\\mg\\\\\n    \\text{undefined} & \\text{ otherwise}\n  \\end{cases}\n  $\n  \n  We say t is the derivation tree for the derivation (ops,bis) iff D(ops,bis,\\start) = t.\n\\end{definition}\n\nAt this point we just need to interpret t as string-pair operations, but I will add an intermediate step to ease our proof that \\OURG is context-sensitive.\n\nWe define a tree homomorphism from DT to a set of string derivation trees in\n\n\\begin{definition}[string derivation trees (ST)]\n  The parse trees of this grammar form ST.\\\\\n  \n\\noindent  \\cp \\arr \\cp $|$ $\\bullet$\\\\\n  \\cl \\arr \\cp $|$ $\\bullet$\\\\\n  \\ed \\arr \\cp $|$ $\\bullet$\\\\\n  $\\bullet$ \\arr \\op a ~~~~ $\\forall \\op\\in \\{\\bullet,\\cp,\\cl,(\\emp,\\emp)\\}, \\forall a\\in\\sg$\n\\end{definition}\n\n\n\\begin{definition}[Tree homomorphism for ST ($h_s$)]\n\n  For $t\\in DT$, \n  \n  $\n  h_s(t) =\n  \\begin{cases}\n    (\\emp,\\emp) & \\text{ if } t = \\start\\\\\n    t & \\text{ if } t\\in\\sg\\\\\n    \\op(h_s(t')) & \\text{ if } \\exists \\op \\in \\{\\cp,\\cl,\\ed\\}, \\exists t'\\in DT (t=\\op(t'))\\\\\n    \\bullet(h_s(t'), h_s(a)) & \\text{ if } \\exists t'\\in DT \\exists a\\in\\sg (t=\\mg(t',a))\\\\\n  \\end{cases}\n  $\n\\end{definition}\n\n\n\\begin{definition}[\\OURG algebra]\n  A \\OURG algebra is an algebra with signature $\\la (\\sg^*\\times\\sg^*)\\cup\\{\\sg^*\\},\\bullet,\\cp,\\cl,\\ed\\ra$\n  \n  If $t\\in ST$, we define its interpretation into the string pair algebra as follows:\n\n   $\n  \\llb t \\rrb_s =\n  \\begin{cases}\n    t & \\text{ if } t = t()\\\\\n    \\llb\\op\\rrb(s,b)(\\llb t'\\rrb) & \\text{ if } \\exists \\op \\in \\{\\cp,\\cl,\\ed\\}, \\exists t'\\in ST (t=\\op(t'))\\\\\n    \\llb\\bullet\\rrb(\\llb t'\\rrb), \\llb a\\rrb) & \\text{ if } \\exists t'\\in ST \\exists a\\in\\sg (t=\\mg(t',a))\\\\\n  \\end{cases}\n  $\n\n  where the operations are interpreted as the following functions in the algebra:\n  \n\\noindent  $\\llb\\bullet((s,b),a)\\rrb_s = (sa,ba)$\\\\  \n  $\\llb\\cp((s,b))\\rrb_s = (sb,bb)$\\\\\n  $\\llb\\cl((s,b))\\rrb_s = (s,\\emp)$\\\\\n  $\\llb\\ed((s,b))\\rrb_s = s$\\\\\n\n  \n\\end{definition}\n\n\n\\textbf{Example:}  let d = (\\ed \\cp \\mg \\mg, a b) be a derivation in \\OURG.\n\n  D(d) = \\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ \\start~ a ] b ]]]\\\\\\\\\n\n  $h_s(D(d))$ = \\Tree[.\\ed~ [.\\cp~ [.$\\bullet$ [.$\\bullet$ (\\emp,\\emp) a ] b ]]]\n\n  $\\llb h_s(D(d)) \\rrb_s = abab$\\\\\n  \nIn full:\n  \n  \\begin{align*}\n    \\llb h_s(D(d)) \\rrb_s & = \\llb \\ed(\\cp(\\bullet(\\bullet((\\emp,\\emp),~a),~b))) \\rrb \\\\\n    & = \\llb \\ed\\rrb (\\llb\\cp(\\bullet(\\bullet((\\emp,\\emp),~a),~b)) \\rrb)\\\\\n    &  = \\llb \\ed\\rrb(\\llb\\cp\\rrb(\\llb\\bullet(\\bullet((\\emp,\\emp),~a),~b)\\rrb))\\\\\n    &  = \\llb \\ed\\rrb(\\llb\\cp\\rrb(\\llb\\bullet\\rrb(\\llb\\bullet((\\emp,\\emp),a)\\rrb,~b)))\\\\\n    &  = \\llb \\ed\\rrb(\\llb\\cp\\rrb(\\llb\\bullet\\rrb(\\llb\\bullet\\rrb((\\emp,\\emp),~a),~b)))\\\\\n    &  = \\llb \\ed\\rrb(\\llb\\cp\\rrb(\\llb\\bullet\\rrb((a,a),~b)))\\\\\n    &  = \\llb \\ed\\rrb(\\llb\\cp\\rrb((ab,ab)))\\\\\n    &  = \\llb \\ed\\rrb((abab,abab))\\\\\n    & = abab\n  \\end{align*}\n\n\n\\subsection{PMCFG}\n\\label{sec:pmcfg}\n\nWhy did we bother with both $h_s$ and $\\llb\\cdot\\rrb_s$ instead of interpreting the derivation tree directly in the string algebra? In order to facilitate the proof that \\OURG is mildly context sensitive; specifically that it is weakly equivalent to a parallel multiple context free grammar. We define a second tree homomorphism $h_p$ into the derivations of a PMCFG and show that the homomorphism is in fact an isomorphism.\n\n\\begin{definition}[PMCFG $P$]\n\n  Let $a,c$ be metavariables over \\sg. The PMCFG P(g) for (\\OPS,\\BIGR) for some \\OURG g is defined as follows:\n\n  $P(g)=\\la \\{C^{(2)},T^{(3)},S^{(1)},W^{(1)}\\}, \\sg^{(0)}, S, V=\\{x,y,z\\}, R \\ra$\n\nWhere the productions rules R given below. For our convenience, each rule is given a (not necessarily unique) name; this is used in the proof below.\\\\\n\nThese are called Horn clauses.\n\n$R=  \\begin{array}{r | r c l l}\n       \\text{name} & rules\\\\\n       \\hline\n       \\cl & C(s,x) &\\der& T(s,b,x)\\\\\n       \\cp & T(sb,bb,x) &\\der& T(s,b,x)\\\\\n       \\mg & T(sa,ba,a) &\\der& T(s,b,c), a & \\forall (c,a)\\in\\BIGR\\\\\n       \\mg & T(sa,a,a) &\\der& C(s,c), a & \\forall (c,a)\\in\\BIGR\\\\\n       \\ed & S(s) &\\der& T(s,b,x)\\\\\n       \\text{\\textsl{start}} & C(\\emp,\\LBOUND) &\\der&\\\\\n                   & W(a) &\\der& &\\forall a\\in\\sg\\\\\n       \n     \\end{array}$\n\n     The set of parse trees for this grammar is PT.\n     \n \\end{definition}\n\n\n\n \\textbf{Example:} abab\n\n \\Tree[.S(abab) [.T(abab,abab,b) [.T(ab,ab,b) [.T(a,a,a) C(\\emp,\\LBOUND) W(a) ] W(b) ]]]   \n\n \\textbf{Example:} abb\n\n \\Tree[.S(abab) [.T(abb,abb,b) [.T(ab,b,b) [.C(a,a) [.T(a,a,a) C(\\emp,\\LBOUND) W(a) ] ] W(b) ]]]   \\\\\n \n\n \\begin{definition}[derivation tree of an MCFG \\citep{makoto-kanazawa-lecture-notes-2016}]\n   In order to get derivation trees of an MCFG that are defined over a finite alphabet, we label our internal nodes with the rules themselves. For each node p, if p is labelled $B(\\alpha_1,...,\\alpha_n)\\der B_1(\\mathbf{x_{11},...x_{1r_1}}),\\dots,B_n(\\mathbf{x_{n1},...x_{nr_n}})$\n   then p has n daughters, and $\\forall i\\leq n$, the $i$th daughter is $B_i(t_1,\\dots, t_{r_i})$, $t$s trees.\n \\end{definition}\n\n\n \n \\begin{definition}\n   The derived string of a derivation tree $B(\\alpha_1,...,\\alpha_n)\\der daughters (t_1,\\dots t_n)$  is calculates as follows: For every $t_i$, if $derstr(t_i) = (s_{i1},\\dots,s_{ir_i})$ then $derstr(t)=(\\alpha_1,\\dots,\\alpha_n)\\sigma$, where $\\sigma$ is the substitution $[\\mathbf{x}_{ij}\\der w_{ij}]$\n \\end{definition}\n \nWe can simplify our rule names as follows, making the trees easier to read, and making the relationship between the MCFG dt and the \\OURG dt clear:\n\n$R=  \\begin{array}{r | r c l l}\n       \\text{name} & rules\\\\\n       \\hline\n       \\cl & C(s,x) &\\der& T(s,b,x)\\\\\n       \\cp & T(sb,bb,x) &\\der& T(s,b,x)\\\\\n       \\mg_{Tca} & T(sa,ba,a) &\\der& T(s,b,c), a & \\forall (c,a)\\in\\BIGR\\\\\n       \\mg_{Cca} & T(sa,a,a) &\\der& C(s,c), a & \\forall (c,a)\\in\\BIGR\\\\\n       \\ed & S(s) &\\der& T(s,b,x)\\\\\n       \\text{\\textsl{start}} & C(\\emp,\\LBOUND) &\\der&\\\\\n       & W(a) &\\der & &\\forall a\\in\\sg\\\\\n     \\end{array}$\\\\\n\n \\textbf{Example:} abab parse tree, derivation tree, more readable derivation tree\n\n {\\small\n \\Tree[.S(abab) [.T(abab,abab,b) [.T(ab,ab,b) [.T(a,a,a) C(\\emp,\\LBOUND) W(a) ] W(b) ]]]   \n \\Tree[.{S(\\textbf{x})$\\der$ T(\\textbf{x,y,z})} [.{T(\\textbf{xy,yy,z})$\\der$ T(\\textbf{x,y,z})} [.{T(\\textbf{x}b,\\textbf{y}b,b)$\\der$ T(\\textbf{x,y},a), W(a)} [.{T(\\textbf{x}a,a,a)$\\der$ C(x,\\LBOUND),W(a)} C(\\emp,\\LBOUND) W(a) ] {W(b)} ]]]   \n \\Tree[.\\ed~ [.\\cp~ [.$\\mg_{Tab}$ [.$\\mg_{C\\LBOUND a}$ {C(\\emp,\\LBOUND)} W(a) ] W(b) ]]]   \n}\\\\\\\\\n\nWe define a tree transducer $h_p$ from the derivation trees of \\OURG DT to the derivation trees of the equivalent MCFG PDT as follows:\n\n\\begin{definition}[Tree transducer from DT to PDT]\n\n  $T=\\la Q, O\\cup\\sg, PO\\cup\\sg, Q_f, \\delta \\ra$\n  \n  Where PO is the set of rule names in table \\ref{tab:mcfg-names}, Q is the set of states defiuned below, $Q_F = \\{q_f\\}$ and $\\delta$ is the transition function defined as follows:\n\n  $\\begin{array}[H]{r c l l}\n     \\delta(a) & = & q_a(W(a)) & \\forall a\\in\\sg\\\\\n     \\delta(\\start) & = & q_{C\\LBOUND}(C(\\emp,\\LBOUND))\\\\\n     \\delta(\\ed(q(t))) & = & q_f(\\ed(t)) & \\forall q\\in Q\\\\\n     \\delta(\\cp(q(t)) & = & q(\\cp(t)) & \\forall q\\in Q\\\\\n     \\delta(\\cl(q(t)) & = & q_{Cx}(\\cl(t)) & \\IF \\exists x\\in\\sg (q=q_{Tx})\\\\\n     \\delta(\\mg(q_1(t_1),q_2(t_2))) & = & q_{Ty}(\\mg_{Zxy}(t_1,t_2)) & \\IF \\exists Z\\in\\{T,C\\} \\exists x,y\\in\\sg (q_1=q_{Zx} \\& q_2=q_{Zy})\n  \\end{array}\n$\\\\\n\n$Q=\\{q_x | x\\in\\sg\\}\\cup \\{q_{Zx} | x\\in\\sg ~\\&~ Z\\in\\{T,C\\}\\}\\cup\\{q_f\\} $\n  \n\\end{definition}\n\nSince we rely on the states to get the right \\mg functions, this is not a tree homomorphism, since a tree homomorphism is a tree transducer with only one state \\citep{schieber-2004-TAG+}. I don't think this is a problem though because T generates derivation trees isomorphic to their preimage.\n\nExample:\n\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ \\start~ a ] b ]]] $\\Rightarrow$\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ [.$q_{C\\LBOUND}$ C(\\emp,\\LBOUND) ] [.$q_a$ W(a) ] ] [.$q_b$ W(b) ]]]] $\\Rightarrow$\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.$q_{Ta}$ [.$\\mg_{C\\LBOUND a}$ C(\\emp,\\LBOUND)   W(a)  ]] [.$q_b$ W(b) ]]]]  $\\Rightarrow$\n\\Tree[.\\ed~ [.\\cp~ [.$q_{Tb}$ [.$\\mg_{Tab}$ [.$\\mg_{C\\LBOUND a}$ C(\\emp,\\LBOUND)   W(a)  ] W(b) ]]]]\n$\\Rightarrow$\n\\Tree[.\\ed~ [.$q_{Tb}$ [.\\cp~  [.$\\mg_{Tab}$ [.$\\mg_{C\\LBOUND a}$ C(\\emp,\\LBOUND)   W(a)  ] W(b) ]]]]\n$\\Rightarrow$\n\\Tree[.$q_{f}$ [.\\ed~  [.\\cp~  [.$\\mg_{Tab}$ [.$\\mg_{C\\LBOUND a}$ C(\\emp,\\LBOUND)   W(a)  ] W(b) ]]]]\\\\\\\\\n\nNote that this transducer doesn't enforce all the rules of the grammar. If there are bad derivation trees they'll be interpreted as uninterpretable dts in the PMCFG. I think right now I havne't distinguished the co-domain from the yield. Haffoo do that.\n\n\n% \\begin{definition}\n%   $h_p(t) =\\\\\n%   \\begin{cases}\n%     C(\\emp,\\LBOUND) & \\IF t=\\start\\\\\n%     t & \\IF t\\in\\sg\\\\\n%     S(x)((T(x,y,z)(h_p(t''))) &\\IF \\exists t'\\in DT (t=\\ed(t')) ~\\&~ \\exists x,y,z\\in V ~\\&\\\\\n%     &~~~~~\\exists t''\\in PT~ (h_p(t') = T(x,y,z)(t'')))\\\\\n%     C(x,z)((T(x,y,z)(h_p(t''))) &\\IF \\exists t'\\in DT (t=\\cl(t')) ~\\&~ \\exists x,y,z\\in V ~\\&\\\\\n%     &~~~~~\\exists t''\\in PT~ (h_p(t') = T(x,y,z)(t'')))\\\\\n%     T(xy,yy,z)((T(x,y,z)(h_p(t''))) &\\IF \\exists t'\\in DT (t=\\cp(t')) ~\\&~ \\exists x,y,z\\in V ~\\&\\\\\n%     &~~~~~\\exists t''\\in PT~ (h_p(t') = T(x,y,z)(t'')))\\\\\n%     T(xa,ya,a)((T(x,y,c)(h_p(t'')), a) &\\IF \\exists t'\\in DT \\exists a\\in\\sg (t=\\mg(t'),a) ~\\&~ \\exists x,y,z\\in V ~\\&\\\\\n%     &~~~~~\\exists t''\\in PT~ (h_p(t') = T(x,y,z)(t'')))\\\\\n%     T(xa,ya,a)((C(x,c)(h_p(t'')), a) &\\IF \\exists t'\\in DT \\exists a\\in\\sg (t=\\mg(t'),a) ~\\&~ \\exists x,z\\in V ~\\&\\\\\n%     &~~~~~\\exists t''\\in PT~ (h_p(t') = C(x,z)(t'')))\\\\\n\n%   \\end{cases}\n% $\n% \\end{definition}\n\n\n% OK, I think this is not a tree homomorphism because the internal node labels do not form a finite set. However, it should be easy to see that the trees are isomorphic modulo labelling. Which should give us homomorphism anyway, assuming $h_p$ is defined for every DT. Is it rather that you can't have a tree homomorphism between a tree language over a finite alphabet and one over an infinite alphabet?\n\n\n\n\n\n\n%Probably then everything is fine anyway. We want to show that the two tree languages are isomorphic:\n\n\\begin{thm}[$DT \\simeq PT$]\n  The set of derivation trees for a given \\OURG is isomorphic to the\n  set of derivation trees of $P(\\OURG)$. Moreover, if the isomorphism\n  maps $t_1$ to $t_2$, $\\llb t_1 \\rrb = \\llb t_2 \\rrb$.\n\\end{thm}\n\n\\begin{proof}\n\n\n  Let $G$ be a \\OURG grammar, and let  $t\\in DT(G)$. Let\n  $t'=\\mathbb{A}(t)$. We show by induction on the tree depth that\n  $t\\simeq t'$ and $\\llb t \\rrb = \\llb t' \\rrb$ . \n\n  \\begin{enumerate}\n  \\item $t$ has depth 0 or 1 or whatever. Then t=\\start or\n    $t\\in\\sg$. If t=\\start, $t'=C(\\LBOUND,\\emp)$ by the definition of\n    $\\mathbb{A}$. If $t\\in\\sg$, $t'=W(t)$, so the trees are\n    isomorphic. $\\llb t \\rrb t = \\llb W(t) \\rrb$\n  \\item Suppose $t$ has depth $i$ and $\\mathbb{A}(t)\\simeq t$.\n    \\begin{description}\n    \\item[\\ed] $\\mathbb{A}(\\ed(t)) = \\ed(\\mathbb{A}(t))$ by definition\n      of A. \n    \\end{description}\n  \\end{enumerate}\n  \n  \n\\end{proof}\n\n\n\n\n\n\n\n\n\n\n\n\n\\subsection{Alexander's way}\n\\label{sec:alexanders-way}\n\n\\begin{enumerate}\n\\item Define IRTG with \\OURG algebra\n\\item algebra homomorphism H:'OURG \\arr DSTA(G) = Dumb ...? an algegra of simple rules for putting together pairs of sets of strings etc like concatenate and wrap (TAGs)\n\\item see if IRTGs with DSTA(G) (which requires a non-linear homomorphism) are $\\subset$ PMCFG\n\\item \\OURG \\arr DT \\arr$_{hom}$ \\OURG algebra \\arr$_{H}$ DSTA(G) $\\subset$ L(PMCFG) \n\\end{enumerate}\n\n\\subsubsection{IRTG}\n\\label{sec:irtg}\n\nDerivation tree language is regular.\\footnote{It occurs to me that\n  in a way it makes more sense to make the right daughters of \\mg be\n  bigrams. Then (a) the automaton is regular and (b) every node is\n  labelled by a transition from one of the FSAs.}\n\nLet  $\\Gamma = \\{\\ed^{(1)},\\cp^{(1)},\\cl^{(1)},\\mg^{(2)}\\}\\cup\\sg^{(0)}\\cup\\{(\\emp,\\emp)^{(0)}\\}$\n\n$DT \\subset T(\\Gamma)$ (Terms over a ranked alphabet).\n\nFor a given \\BIGR, given $t\\in T(\\Gamma)$, $t\\in DT$ iff $t$ is accepted by the non-deterministic BUTA $\\mathbb{A}$, defined below.\n\n\\begin{definition}[Tree automaton for \\OURG with bigrams \\BIGR ($\\mathbb{A_{\\BIGR}}$)]\n  $\\mathbb{A} = \\la \\Gamma, Q, q_f, \\Delta\\ra$ where:\n  \\begin{description}\n\n    \n  \\item[alphabet] $\\Gamma = \\{\\ed^{(1)},\\cp^{(1)},\\cl^{(1)},\\mg^{(2)}\\}\\cup\\sg^{(0)}\\cup\\{(\\emp,\\emp)^{(0)}\\}$\n    \n  \\item[states]\n    $Q = \\left\\{\n    \\begin{array}[H]{c l l}\n      & \\{\\fea{F} , (\\LBOUND,\\fea{-cl},\\fea{-buf})\\} & \\ed, \\start\\\\\n    \\cup & \\{\\fea{=ab} | (a,b)\\in\\BIGR \\} & \\text{lexicon}\\\\\n    \\cup & \\{(\\fea{x},\\alpha\\fea{cl}, \\beta\\fea{buf}) ~|~  x\\in\\sg, \\alpha,\\beta\\in\\{+,-\\}& \\text{internal nodes}\\\\\n    \\end{array}\n\\right\\}$\n\n  \n  \\item[Final state] $q_f=\\fea{F}$\n\n  \n  \\item[Transitions]\\\n\n    $\n  \\begin{array}[H]{r c l l}\n    \\Delta & = & \\{\\la \\ed(\\fea{(x,-cl,+buf)}), \\fea{F}\\ra | \\fea{x}\\in\\sg\\} & \\ed\\\\\n           & \\cup & \\{\\la b, \\fea{=ab}\\ra | ((a,b)\\in\\BIGR)\\}& \\text{lexical rules}\\\\\n           & \\cup & \\{\\la (\\emp,\\emp),((\\fea{\\LBOUND,-cl,-buf)}) \\ra\\}& \\start\\\\\n           & \\cup & \\{\\la \\cl(\\fea{(x,-cl,+buf)}), (\\fea{(x,+cl,-buf)})\\ra | \\fea{x}\\in\\sg\\} & \\cl\\\\\n           & \\cup & \\{\\la \\cp((\\fea{x},\\alpha\\fea{cl,+buf})), (\\fea{(x,-cl,+buf)}) \\ra | \\fea{x}\\in\\sg, \\alpha\\in\\{+,-\\} \\} & \\cp\\\\\n           & \\cup & \\{\\la \\mg((\\fea{x},\\alpha\\fea{cl},\\beta\\fea{buf}), \\fea{=xy}),(\\fea{y},\\alpha\\fea{cl},+\\fea{buf})\\ra | \\fea{x,y}\\in\\sg, \\alpha,\\beta\\in\\{+,-\\} \\} & \\mg\\\\\n  \\end{array}\n  $\n\\end{description}\n\n\n  \n\\end{definition}\n\n\nExample run:\n\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ (\\emp,\\emp) a ] b ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ \\fea{(\\LBOUND,-cl,-buf)} \\fea{=\\LBOUND a} ] \\fea{=ab} ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ \\fea{(a,-cl,+buf)}  \\fea{=ab} ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cp~ \\fea{(b,-cl,+buf)} ]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ \\fea{(b,-cl,+buf)} ] \n$\\Rightarrow$ \n\\Tree[.\\fea{F} ] \n\nExample 2: nondeterminism can lead to bad state choices. We can't get past the lower \\mg node.\n\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ (\\emp,\\emp) a ] b ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ [.\\mg~ \\fea{(\\LBOUND,-cl,-buf)} \\fea{=b a} ] \\fea{=ab} ]]] \n\n\nExample 3: pointless \\cl\n\n\\Tree[.\\ed~ [.\\cp~ [.\\mg~ (\\emp,\\emp) a ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cl~ [.\\mg~ \\fea{(\\LBOUND,-cl,-buf)} \\fea{=\\LBOUND a} ]]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ [.\\cl~  \\fea{(a,-cl,+buf)} ]] \n$\\Rightarrow$ \n\\Tree[.\\ed~ \\fea{(a,+cl,-buf)} ] \n\nIf we show this is in fact a BUTA, and this is in fact the set of derivation trees of \\OURG, we've shown the language of derivation trees is regular.\n\n\\begin{thm}\n  D is 1-1 so D restricted to \n\\end{thm}\n\n\\begin{thm}[Equivalence of $\\mathbb{A}$ and \\OURG]\n  $L(\\mathbb{A}_\\BIGR)=\\{D(ops,bis,\\start) ~|~  (ops,bis)\\in L(\\OURG)\\}$\n\\end{thm}\n\n\\begin{proof}\n  \\begin{enumerate}\n  \\item\n    $L(\\mathbb{A}_\\BIGR)\\subseteq\\{D(ops,bis,\\start) ~|~ (ops,bis)\\in L(\\OURG)\\}$: \n\n    Let $t\\in L(\\mathbb{A}_\\BIGR)$. Every internal node has arity 1 or is \\mg. For all transitions in which the first element is $\\mg(q_1,q_2)$, $\\exists \\fea{x,y}\\in\\sg$ such that  $(q_2=\\fea{=xy}$. The only transitions that have such a state as their second element are the lexical rules, so the second daughter of \\mg is always from \\sg.\n\n    For all transitions in which the first element is \\op(q) for some $\\op\\in O$, q is a triple. Similarly, for the transitions in which the first element is $\\mg(q_1,q_2)$, $q_1$ is a triple. The only transitions that have a triple as their second element are those whose first element is \\op(q') for some q' or (\\start,\\fea{(\\LBOUND,-cl,-buf)}). Therefore every element on the path down the only and left daughters is an operation or \\start. The only transition in which \\start is the first element is a lexical rule, and the only lexical transition in which the second element is a triple is (\\start,\\fea{(\\LBOUND,-cl,-buf)}). Therefore, the path down the only and left daughters is a sequence which consists of all the operations in the tree, followed by \\start.\n    All of the right daughters proper are lexical items.\n\n    $t$ is therefore in the domain of $D^{-1}$. \n\n    $D^{-1}(x) =\n    \\begin{cases}\n      (ops,bis) & \\IF x=(ops,bis,\\start)\\\\\n      D^{-1}(\\emp,\\emp,x) & \\IF x\\in DT\\\\\n      D^{-1}(\\op::ops,bis,t') & \\IF x = (\\op(t'),ops,bis) \\& \\op\\neq\\mg\\\\\n      D^{-1}(\\mg::ops,a::bis,t') & \\IF x = (\\mg(t',a),ops,bis)\\\\\n    \\end{cases}\n    $\n    \n    $D^{-1}(t) = (ops,bis)$ for some $ops\\in O^*, bis\\in\\sg^*$:\n\n    $D^{-1}(t) = D^{-1}(\\emp,\\emp,t))$. We already saw that every subtree of $t$ is of the form $\\op(t') (\\op\\in\\{\\ed,\\cp,\\cl\\})$, or $\\mg(t',a) (a\\in\\sg)$, or $a\\in\\sg$, or \\start, so  $D^{-1}$ is defined for every subtree. Internal nodes are always labelled with operations, so only operations will be added to ops. Items are added to bis when they occur as the second daughter of \\mg, which we have seen is always a lexical item. The one and only left daughter that is a leaf is \\start, and when that leaf is reached it is the complete tree, triggering the first case, which returns (ops, bis) without adding \\start to the list.\n\n    Now we show $(ops,bis)\\in L(\\OPS)\\times L(\\BIGR)$ such that $|ops\\restriction\\mg|=|bis|$. \n\n    $|ops\\restriction\\mg|=|bis|$ is clearly true.\n\n    To show that $ops\\in L(\\OPS)$, note that the feature configurations $\\pm\\fea{cl}, \\pm\\fea{buf}$ correspond to states in \\OPS.\n\n    \\begin{figure}[H]\n      \\centering\n      \\includegraphics[width=4in]{ops.png}\n      \\caption{\\OPS}\n      \\label{fig:ops}\n    \\end{figure}\n    \n    We designed the grammar so that we never copy or clear vacuously. This means that we only copy or clear if there is something in the buffer to copy or clear, and also that we only clear if that act of clearing will define the start of a copy. The former is accomplished by adding a state for when the buffer is empty, from which we can only Merge. The latter is done by adding a new state that we move to when we clear, and from which we can't clear again, nor can we end without first actually copying. When we put these strategies together, we have five states. The start state has no buffer so we can only Merge. From there we go to NotCL, because we have not recently cleared. From here we can do anything, but if we clear, we move to CL$_S$ in which we have cleared (so we can't clear or end) but we also have no buffer so we can't copy either. We Merge and move to CL from which we can't clear or end. If we copy, we move back to NotCL.\n\nIn other words, our states are \\fea{F} plus the full complement of $\\pm$buffer, $\\pm$cleared:\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}[H]{c|c  c}\n  & \\fea{+clear} &  \\fea{-clear}\\\\\n\\hline\n \\fea{+buffer}& CL  & NotCL\\\\\n \\fea{-buffer}& CL$_S$ & S\\\\\n\\end{tabular}\n\\end{table}\n    \nops[0]=\\mg because the only $\\mathbb{A}$ transitions with \\fea{-buf} in their first element are \\mg transitions. $\\forall o\\in L(\\OPS)$, o[0] = \\mg since that's the only transition out of the start state S.\n\nops[-1] = \\ed because the only $\\mathbb{A}$-transitions to F are for\n\\ed-rooted trees. No other nodes are labelled \\ed because there are no\ntransitions in which \\texttt{F} occurs in the first element.\n\nLet $C=ops\\restriction \\{\\cp,\\cl\\}$\n\nObserve the following:\n\n\\begin{enumerate}\n\\item Only \\cl changes \\fea{-cl} to \\fea{+cl}, meaning the only $\\mathbb{A}$-transitions whose first element \n\\end{enumerate}\n\n$C[-1] \\neq \\cl$: the only $\\mathbb{A}$-transitions to F are from states \\fea{(x,-cl,+buf)}. \\fea{-cl} is only changed to \\fea{+cl} by transitions for \\cl-rooted trees.  \\mg-rooted trees always keep their \\fea{cl} value, and \\cp-rooted trees always transition to a state with \\fea{-cl}. We already saw that every tree has a \\start node as its only left leaf, and the state for \\start has \\fea{-cl}. Therefore any sequence of operations in $t$ that ends with a state with \\fea{-cl} either has no \\cl nodes -- so the original \\fea{-cl} is kept --, or all \\cl nodes have a later \\cp node that changes the state to \\fea{-cl}.\n\n$ \\not\\exists i<|C|$ s.t. $C[i]=C[i+1]=\\cl$: the transition rules for \\cl-rooted trees are defined only from states with \\fea{-cl}. \\mg does not change the value of \\fea{cl}, and \\cl transitions always end with a \\fea{+cl} state. Only \\cp higher in the tree can change the \\fea{+cl} to \\fea{-cl}, making a \\cl node possible again.\n\nBy Theorem \\ref{thm:valid-properties} these are the valid derivations.\n\n\\item  $\\{D(ops,bis,\\start) | ops\\in L(\\OPS),bis\\in\n    L(\\BIGR)\\} \\subseteq L(\\mathbb{A}_\\BIGR) $: \n\n    \n\n\n\\end{enumerate}\n\\end{proof}\n\n\\end{document}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "ae1c8e5f9da2d225cc5a9faed9abe4a1b32266b3", "size": 27951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "the_math.tex", "max_stars_repo_name": "megodoonch/birdsong", "max_stars_repo_head_hexsha": "582e7ddecf6c9c1b75f17418097f7bcbf6784d31", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "the_math.tex", "max_issues_repo_name": "megodoonch/birdsong", "max_issues_repo_head_hexsha": "582e7ddecf6c9c1b75f17418097f7bcbf6784d31", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "the_math.tex", "max_forks_repo_name": "megodoonch/birdsong", "max_forks_repo_head_hexsha": "582e7ddecf6c9c1b75f17418097f7bcbf6784d31", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.1649484536, "max_line_length": 946, "alphanum_fraction": 0.6236986154, "num_tokens": 10154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011397337391, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4222927761017544}}
{"text": "\\documentclass[amsmath,\n               amssymb,\n               superscriptaddress,\n               %groupedaddress,\n               %unsortedaddress,\n               %runinaddress,\n               %frontmatterverbose, \n               %showpacs,preprintnumbers,\n               %nofootinbib,\n               %nobibnotes,\n               %bibnotes,\n               aps,\n               %prl,\n               %jcp,\n               %pra,\n               %prb,\n               %rmp,\n               %prstab,\n               %prstper,\n               %longbibliography,\n               floats,\n               %floatfix,\n               %lengthcheck,%\n               showkeys,\n               %preprint,\n               %reprint,\n               notitlepage, % remove page break after title\n               ]{revtex4-1}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{indentfirst}\n\n\\usepackage{graphicx}% Include figure files\n\\usepackage{dcolumn}% Align table columns on decimal point\n\\usepackage{bm}% bold math\n%\\usepackage[mathlines]{lineno}% Enable numbering of text and display math\n%\\linenumbers\\relax % Commence numbering lines\n\n\\usepackage{latexsym}\n\\usepackage{pstricks}\n\\usepackage{graphics}\n\\usepackage{epsfig}\n\\usepackage{longtable}\n\\usepackage{enumerate}\n\\usepackage{subfigure}\n\\usepackage{cancel}\n%\\usepackage{float}\n\n\\newcommand{\\ud}{\\mathrm{d}}\n\\newcommand{\\Nat}{\\mathbb{N}}\n\\newcommand{\\Reals}{\\mathbb{R}}\n\\newcommand{\\du}{\\partial}\n\\newcommand{\\Energy}{\\mathcal{E}}\n\\newcommand{\\Acal}{\\mathcal{A}}\n\\newcommand{\\Bcal}{\\mathcal{B}}\n\\newcommand{\\Ccal}{\\mathcal{C}}\n\\newcommand{\\Ecal}{\\mathcal{E}}\n\\newcommand{\\Kcal}{\\mathcal{K}}\n\\newcommand{\\Lcal}{\\mathcal{L}}\n\\newcommand{\\Wcal}{\\mathcal{W}}\n\\newcommand{\\eqspace}{\\phantom{=}\\,\\,\\,\\:\\!}\n\\newcommand{\\half}{\\frac{1}{2}}\n\\newcommand{\\thalf}{\\tfrac{1}{2}}\n\\newcommand{\\abs}[1]{\\lvert#1\\rvert}\n\\newcommand{\\expo}[1]{\\mathrm{e}^{#1}}\n\\newcommand{\\dt}[1]{\\left|#1\\right|}\n\\newcommand{\\bas}[1]{\\left\\lbrace{\\text{#1}}\\right\\rbrace}\n\\newcommand{\\mint}[2]{\\left[{#1}\\middle|{#2}\\right]}\n\n%bold symbols\n\\newcommand{\\mb}[1]{\\boldsymbol{#1}}\n\\newcommand{\\br}{\\mb{r}}\n\\newcommand{\\bx}{\\mb{x}}\n\n%creation and annihilation operators\n\\newcommand{\\crea}[1]{\\hat{#1}^{\\dagger}}\n\\newcommand{\\anni}[1]{\\hat{#1}^{\\vphantom{\\dagger}}}\n\n%Extra operators\n\\DeclareMathOperator{\\Fourier}{\\mathcal{F}}\n\\DeclareMathOperator{\\Imag}{Im}\n\\DeclareMathOperator{\\Real}{Re}\n\\DeclareMathOperator*{\\Residual}{\\mathrm{Res}}\n\\DeclareMathOperator{\\sgn}{sgn}\n\\DeclareMathOperator{\\Time}{\\mathcal{T}}\n\\DeclareMathOperator{\\Trace}{\\mathrm{Tr}}\n\n%Integral operators\n\\newcommand{\\integ}[1]{\\int\\!\\!\\!\\:\\ud{#1}\\:}\n\\newcommand{\\iinteg}[2]{\\integ{#1}\\!\\!\\!\\integ{#2}}\n\\newcommand{\\iiinteg}[3]{\\integ{#1}\\!\\!\\!\\integ{#2}\\!\\!\\!\\integ{#3}}\n\n%Brakets\n\\newcommand{\\bra}[1]{\\langle{#1}|}\n\\newcommand{\\ket}[1]{|{#1}\\rangle}\n\n\\newcommand{\\abraket}[2]{\\left\\langle{#1}\\middle|{#2}\\right\\rangle}\n\\newcommand{\\braket}[2]{\\langle{#1}|{#2}\\rangle}\n\\newcommand{\\bigbraket}[2]{\\bigl\\langle{#1}\\big|{#2}\\bigr\\rangle}\n\\newcommand{\\abrakket}[3]{\\left\\langle {#1}\\middle|{#2}\\middle|{#3} \\right\\rangle}\n\\newcommand{\\brakket}[3]{\\langle{#1}|{#2}|{#3}\\rangle}\n\\newcommand{\\bigbrakket}[3]{\\bigl\\langle{#1}\\big|{#2}\\big|{#3}\\bigr\\rangle}\n\n%sqrt not scaling with the superscript\n\\newlength{\\back}\n\\newcommand{\\tsqrt}[2]{%\n\\settowidth{\\back}{${#1}^{#2}$}%\n\\sqrt{\\vphantom{#1}\\hphantom{{#1}^{#2}}}\\hskip-\\back{#1}^{#2}%\n}\n\n%temporary counters\n\\newcounter{saveCounter1}\n\\newcounter{saveCounter2}\n\\newcounter{backupCounter}\n\n%allow page breaks for equations (\\\\* prevents them at that line)\n%\\allowdisplaybreaks[2]\n\n%figure directory\n\\def\\figdir{../figures}\n\n% change the section numbering to roman\n%\\renewcommand \\thesection{\\Roman{section}}\n\n% thick line for tabular header and foot \n\\newcommand{\\thline}{\\noalign{\\hrule height 1.0pt}}\n\n% abbreviations for the spin components\n\\newcommand{\\aaaa}{\\alpha\\alpha\\alpha\\alpha}\n\\newcommand{\\abab}{\\alpha\\beta\\alpha\\beta}\n\\newcommand{\\baba}{\\beta\\alpha\\beta\\alpha}\n\\newcommand{\\abba}{\\alpha\\beta\\beta\\alpha}\n\\newcommand{\\baab}{\\beta\\alpha\\alpha\\beta}\n\\newcommand{\\bbbb}{\\beta\\beta\\beta\\beta}\n\\newcommand{\\aabb}{\\alpha\\alpha\\beta\\beta}\n\\newcommand{\\bbaa}{\\beta\\beta\\alpha\\alpha}\n\n\\definecolor{zgreen}{RGB}{134, 164, 57}\n\\definecolor{zred}{RGB}{206, 46, 41}\n\n\\begin{document}\n\\title{}\n\\thanks{}\n\\author{\\L{}. M. Mentel}\n\\email{Email: l.m.mentel@vu.nl}\n\\affiliation{Section Theoretical Chemistry, VU University, Amsterdam, The Netherlands}\n\\affiliation{Pohang University of Science and Technology, Pohang, South Korea}\n\n\\date{\\today}\n\n\\begin{abstract}\nabstract\n\\end{abstract}\n\n\\keywords{keywords}%Use showkeys class option if keyword display desired\n\\maketitle\n\n\\section{intro}\n\n\\begin{align}\\notag\n{\\color{zred}n_{\\textrm{Na}_2\\textrm{O}}} &= w^{\\textrm{Na}_2\\textrm{O}}_{\\textrm{NaOH}} \\cdot {\\color{zgreen}x_{\\textrm{NaOH}}} \\\\ \\notag\n{\\color{zred}n_{\\textrm{K}_2\\textrm{O}}} &= w^{\\textrm{K}_2\\textrm{O}}_{\\textrm{KOH}} \\cdot {\\color{zgreen}x_{\\textrm{KOH}}} \\\\ \\notag\n{\\color{zred}n_{\\textrm{Al}_{2}\\textrm{O}_{3}}} &= w^{\\textrm{Al}_{2}\\textrm{O}_{3}}_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}} \\cdot {\\color{zgreen}x_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}}} \\\\ \\notag\n{\\color{zred}n_{\\textrm{SiO}_{2}}} &= w^{\\textrm{SiO}_{2}}_{\\textrm{SiO}_{2}} \\cdot {\\color{zgreen}x_{\\textrm{SiO}_{2}}} \\\\ \\notag\n{\\color{zred}n_{\\textrm{H}_2\\textrm{O}}} &= \nw^{\\textrm{H}_2\\textrm{O}}_{\\textrm{NaOH}} \\cdot {\\color{zgreen}x_{\\textrm{NaOH}}}\n+ w^{\\textrm{H}_2\\textrm{O}}_{\\textrm{KOH}} \\cdot {\\color{zgreen}x_{\\textrm{KOH}}}\n+ w^{\\textrm{H}_{2}\\textrm{O}}_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}} \\cdot {\\color{zgreen}x_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}}}\n+ w^{\\textrm{H}_2\\textrm{O}}_{\\textrm{H}_2\\textrm{O}} \\cdot {\\color{zgreen}x_{\\textrm{H}_2\\textrm{O}}}  \\\\ \\notag\n%{\\color{zred}n_{\\textrm{TMACl}}} &= w^{\\textrm{TMACl}}_{\\textrm{TMACl}} \\cdot {\\color{zgreen}x_{\\textrm{TMACl}}} \\\\ \\notag\n\\end{align}\n\n$$\n\\begin{bmatrix}\nw^{\\textrm{Na}_2\\textrm{O}}_{\\textrm{NaOH}} & 0 & 0 & 0 & 0 \\\\\n0 & w^{\\textrm{K}_2\\textrm{O}}_{\\textrm{KOH}} & 0 & 0 & 0 \\\\\n0 & 0 & w^{\\textrm{Al}_{2}\\textrm{O}_{3}}_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}} & 0 & 0\\\\\n0 & 0 & 0 & w^{\\textrm{SiO}_{2}}_{\\textrm{SiO}_{2}} & 0 \\\\\nw^{\\textrm{H}_2\\textrm{O}}_{\\textrm{NaOH}} & w^{\\textrm{H}_2\\textrm{O}}_{\\textrm{KOH}} & w^{\\textrm{H}_{2}\\textrm{O}}_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}} & 0 & w^{\\textrm{H}_2\\textrm{O}}_{\\textrm{H}_2\\textrm{O}}\\\\\n\\end{bmatrix}\n\\cdot\n\\begin{bmatrix}\n{\\color{zgreen}x_{\\textrm{NaOH}}} \\\\\n{\\color{zgreen}x_{\\textrm{KOH}}} \\\\\n{\\color{zgreen}x_{\\textrm{Al(OC}_{3}\\textrm{H}_{7}\\textrm{)}_{3}}} \\\\\n{\\color{zgreen}x_{\\textrm{SiO}_{2}}} \\\\\n{\\color{zgreen}x_{\\textrm{H}_2\\textrm{O}}} \\\\\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n{\\color{zred}n_{\\textrm{Na}_2\\textrm{O}}} \\\\\n{\\color{zred}n_{\\textrm{K}_2\\textrm{O}}} \\\\\n{\\color{zred}n_{\\textrm{Al}_{2}\\textrm{O}_{3}}} \\\\\n{\\color{zred}n_{\\textrm{SiO}_{2}}} \\\\\n{\\color{zred}n_{\\textrm{H}_2\\textrm{O}}} \\\\\n\\end{bmatrix}\n$$\n\n\\section{first section}\n\n$$\n\\begin{bmatrix}\nB_{11} & B_{12} & B_{13} & \\cdots & B_{1m}\\\\\nB_{21} & B_{22} & B_{23} & \\cdots & B_{2m}\\\\\nB_{31} & B_{32} & B_{33} & \\cdots & B_{3m}\\\\\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\nB_{n1} & B_{n2} & B_{n3} & \\cdots & B_{nm}\\\\\n\\end{bmatrix}\n\\cdot\n\\begin{bmatrix}\nr_{1} \\\\\nr_{2} \\\\\nr_{3} \\\\\n\\vdots \\\\\nr_{m} \\\\\n\\end{bmatrix}\n=\n\\begin{bmatrix}\nz_{1} \\\\\nz_{2} \\\\\nz_{3} \\\\\n\\vdots \\\\\nz_{n} \\\\\n\\end{bmatrix}\n$$\n\n$$\n\\mathbf{B}\\mathbf{r}=\\mathbf{z}\n$$\n\n$$\n\\mathbf{r}=\\mathbf{B}^{-1}\\mathbf{z}\n$$\n\n$$\n\\mathbf{r}=\\left(\\mathbf{B}^{\\textrm{T}}\\mathbf{B}\\right)^{-1}\\mathbf{B}^{\\textrm{T}}\\mathbf{z}\n$$\n\n$$\\mathbf{r}_{i},\\quad\\mathbf{z}_{i}$$\n\n$$\\mathbf{r}=\\left(\\mathbf{B}\\mathbf{B}^{\\textrm{T}}\\right)^{-1}\n\\mathbf{B}^{\\textrm{T}}\\mathbf{z}$$\n\n\n\n\\begin{acknowledgments}\n acknowledgements\n\\end{acknowledgments}\n\n\\appendix\n\\section{appendix section title}\n\n\n\n\\bibliography{libraryfile}\n\n\\end{document}\n   \n", "meta": {"hexsha": "d008cb8e4795fd3ecec4bf2455afece3971f8457", "size": 7934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/slides/formulas.tex", "max_stars_repo_name": "lmmentel/batchcalculator", "max_stars_repo_head_hexsha": "6bdb083126af20863ea87ccceeb4c68da8b6bc3d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2017-09-26T23:49:43.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-03T12:30:07.000Z", "max_issues_repo_path": "doc/slides/formulas.tex", "max_issues_repo_name": "lmmentel/batchcalculator", "max_issues_repo_head_hexsha": "6bdb083126af20863ea87ccceeb4c68da8b6bc3d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-01-29T10:57:15.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-06T15:30:53.000Z", "max_forks_repo_path": "doc/slides/formulas.tex", "max_forks_repo_name": "lmmentel/batchcalculator", "max_forks_repo_head_hexsha": "6bdb083126af20863ea87ccceeb4c68da8b6bc3d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-03-24T08:10:31.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-28T01:37:35.000Z", "avg_line_length": 30.6332046332, "max_line_length": 226, "alphanum_fraction": 0.6301991429, "num_tokens": 3217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.42229277603917165}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage{array}\n\\usepackage{gensymb}\n\\usepackage{graphicx}\n\\usepackage{pgfplots}\n\\usepackage{siunitx}\n\n\\title{Determining the Effect of Ramp Incline on Acceleration}\n\\date{3 October 2014}\n\\author{Tarik Onalan}\n\n\\begin{filecontents}{data.dat}\n    xVal   yVal     xDel  yDel\n    0.6016 0.034414 0.075 0.003536\n    1.249  0.1666   0.075 0.0019\n    2.057  0.30314  0.075 0.00964\n    2.981  0.4459   0.075 0.0048\n    3.750  0.58386  0.075 0.00484\n\\end{filecontents}\n\n\\begin{document}\n    \\maketitle\n    \\section{Introduction}\n        The goal of this lab was to determine the effect of ramp incline on the\n        acceleration of a cart. I predict that as ramp incline increases, acceleration\n        of the cart will increase linearly.\n    \\section{Materials}\n        \\begin{enumerate}\n            \\item 1 Cart\n            \\item 1 Ramp\n            \\item 1 Ruler\n            \\item 1 Vernier Logger\n            \\item 1 Position Tracker\n            \\item 1 Computer\n            \\item 5 Books\n        \\end{enumerate}\n    \\section{Procedure}\n        \\begin{enumerate}\n            \\item Set up Vernier box with position logger\n            \\item Place one book on a flat surface\n            \\item Indicate a constant distance on the ramp\n            \\item Lay one end of the ramp on the book\n            \\item Place position logger on the elevated end of the ramp\n            \\item Place cart at beginning of indicated distance\n            \\item Let go of cart, track acceleration of cart\n            \\item Record average acceleration for the cart\n            \\item Repeat steps 2-7, iterating the book count (\\(1\\to5\\))\n        \\end{enumerate}\n    \\section{Data}\n        \\noindent\\resizebox{\\textwidth}{!}{\n            \\Huge\n            \\begin{tabular}{|c|c||c|c|c|c|c|c|} \\hline\n                Height & Slope & Trial 1 & Trial 2 & Trial 3 & Trial 4 & Trial 5 & Average \\\\\\hline\n                \\SI{1.5}{\\cm} & \\(0.6016\\degree\\) & \\SI{0.03172}{\\m\\per\\second\\squared} & \\SI{0.03257}{\\m\\per\\second\\squared} & \\SI{0.03346}{\\m\\per\\second\\squared} & \\SI{0.03795}{\\m\\per\\second\\squared} & \\SI{0.03637}{\\m\\per\\second\\squared} & \\SI{0.034414}{\\m\\per\\second\\squared} \\\\\\hline\n                \\SI{3.1}{\\cm} & \\(1.249\\degree\\) & \\SI{0.1659}{\\m\\per\\second\\squared} & \\SI{0.1670}{\\m\\per\\second\\squared} & \\SI{0.1683}{\\m\\per\\second\\squared} & \\SI{0.1647}{\\m\\per\\second\\squared} & \\SI{0.1671}{\\m\\per\\second\\squared} & \\SI{0.1666}{\\m\\per\\second\\squared} \\\\\\hline\n                \\SI{5.1}{\\cm} & \\(2.057\\degree\\) & \\SI{0.3036}{\\m\\per\\second\\squared} & \\SI{0.3099}{\\m\\per\\second\\squared} & \\SI{0.3007}{\\m\\per\\second\\squared} & \\SI{0.3080}{\\m\\per\\second\\squared} & \\SI{0.2935}{\\m\\per\\second\\squared} & \\SI{0.30314}{\\m\\per\\second\\squared} \\\\\\hline\n                \\SI{7.4}{\\cm} & \\(2.981\\degree\\) & \\SI{0.4492}{\\m\\per\\second\\squared} & \\SI{0.4431}{\\m\\per\\second\\squared} & \\SI{0.4485}{\\m\\per\\second\\squared} & \\SI{0.4476}{\\m\\per\\second\\squared} & \\SI{0.4411}{\\m\\per\\second\\squared} & \\SI{0.4459}{\\m\\per\\second\\squared} \\\\\\hline\n                \\SI{9.3}{\\cm} & \\(3.750\\degree\\) & \\SI{0.5887}{\\m\\per\\second\\squared} & \\SI{0.5813}{\\m\\per\\second\\squared} & \\SI{0.5839}{\\m\\per\\second\\squared} & \\SI{0.5808}{\\m\\per\\second\\squared} & \\SI{0.5846}{\\m\\per\\second\\squared} & \\SI{0.58386}{\\m\\per\\second\\squared} \\\\\\hline\\hline\n                \\multicolumn{8}{|c|}{Uncertainty}\\\\\\hline\n                \\SI{0.05}{\\cm} & \\(0.075\\degree\\) & \\SI{0.003536}{\\m\\per\\second\\squared} & \\SI{0.0019}{\\m\\per\\second\\squared} & \\SI{0.00964}{\\m\\per\\second\\squared} & \\SI{0.0048}{\\m\\per\\second\\squared} & \\SI{0.00484}{\\m\\per\\second\\squared} &\\\\\\hline\n            \\end{tabular}\n        }\\\\\n\n        \\begin{tabular}{|c|c|c|c|}\n            \\hline\n            Start Point & End Point & Length of Track & Uncertainty \\\\\\hline\n            \\SI{50}{\\cm} & \\SI{192.2}{\\cm} & \\SI{142.2}{\\cm} & \\SI{0.1}{\\cm} \\\\\n            \\hline\n        \\end{tabular}\n\n        \\begin{tikzpicture}\n            \\begin{axis}[\n                scale=1.75,\n                title={Acceleration Relative to Ramp Incline},\n                xlabel={Slope [\\(\\degree\\)]},\n                ylabel={Acceleration [\\si{\\m\\per\\second\\squared}]},\n                xmin=0.0, xmax=4.0,\n                ymin=0.0, ymax=0.75,\n                legend pos=north west,\n                ymajorgrids=true,\n                grid style=dashed\n            ]\n                \\addplot [\n                    color=blue,\n                    mark=*\n                ] plot [\n                    error bars/.cd,\n                        x dir=both,\n                        y dir=both,\n                        x explicit,\n                        y explicit\n                ] table [\n                    x=xVal,\n                    y=yVal,\n                    x error=xDel,\n                    y error=yDel\n                ]{data.dat};\n\n                \\addplot [\n                    color=red,\n                    mark=none,\n                    domain=0:4\n                ]{0.171249*x-0.0575874};\n\n                \\draw [\n                    red,\n                    thin\n                ] (axis cs:0.5266,0.030878) rectangle (axis cs:0.6766,0.03795);\n\n                \\draw [\n                    red,\n                    thin\n                ] (axis cs:1.174,0.1647) rectangle (axis cs:1.324,0.1685);\n\n                \\draw [\n                    red,\n                    thin\n                ] (axis cs:1.982,0.2935) rectangle (axis cs:2.132,0.31278);\n\n                \\draw [\n                    red,\n                    thin\n                ] (axis cs:2.906,0.4411) rectangle (axis cs:3.056,0.4507);\n\n                \\draw [\n                    red,\n                    thin\n                ] (axis cs:3.675,0.57902) rectangle (axis cs:3.825,0.5887);\n\n                \\addlegendentry{Average}\n                \\addlegendentry{0.171249x-0.0575874}\n            \\end{axis}\n        \\end{tikzpicture}\n    \\section{Analysis}\n        The collected data was remarkably consistent with the linear approximation\n        of the acceleration, with an \\(R^{2}\\) value of \\(0.998\\). However, there\n        is one error with the data: the acceleration is predicted to be zero when\n        the angle of the ramp is \\(0.3363\\degree\\), when the expected value would\n        be \\(0\\degree\\). This could be caused by human error at cart launch (pushing\n        the cart forward at launch), of which there were many during data collection,\n        requiring that we repeated some trials. Obviously not all errors were\n        corrected, but this is expected with human uncertainty in data collection.\n        The simple fact is, however, that acceleration increases as ramp incline\n        increases, which supports my prediction.\n\\end{document}\n", "meta": {"hexsha": "b0e3b9a158c07cabf779bd0306f84c872935be56", "size": 6735, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2014-2015/Physics/Kinematics/Ramp_Acceleration_Lab.tex", "max_stars_repo_name": "QuantumPhi/school", "max_stars_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2014-2015/Physics/Kinematics/Ramp_Acceleration_Lab.tex", "max_issues_repo_name": "QuantumPhi/school", "max_issues_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-04-10T07:28:17.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-10T07:30:10.000Z", "max_forks_repo_path": "2014-2015/Physics/Kinematics/Ramp_Acceleration_Lab.tex", "max_forks_repo_name": "QuantumPhi/school", "max_forks_repo_head_hexsha": "a1bec6b1ed4ea843cb291babf7b7b9925e370749", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8163265306, "max_line_length": 287, "alphanum_fraction": 0.5327394209, "num_tokens": 2106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953797290153, "lm_q2_score": 0.7310585903489892, "lm_q1q2_score": 0.4221829582377482}}
{"text": "\\par\n\\section{Prototypes and descriptions of methods in the {\\tt\nMisc} directory}\n\\label{section:Misc:proto}\n\\par\nThis section contains brief descriptions including prototypes\nof all methods in the {\\tt Misc} directory.\n\\par\n%=======================================================================\n\\subsection{Theoretical nested dissection methods}\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid mkNDperm ( int n1, int n2, int n3, int newToOld[], int west, \n                int east, int south, int north, int bottom, int top ) ;\n\\end{verbatim}\n\\index{mkNDperm@{\\tt mkNDperm()}}\nThis method this vector fills a permutation vector with the\nnested dissection\nnew-to-old ordering of the vertices for the subgrid defined by\nnodes whose coordinates lie in\n\\begin{verbatim}\n[west, east] x [south, north] x [bottom, top].\n\\end{verbatim}\nThe method calls itself recursively.\nTo find the permutation for an {\\tt n1 x n2 x n3} grid, call\n\\begin{verbatim}\nmkNDperm(n1, n2, n3, newToOld, 0, n1-1, 0, n2-1, 0, n3-1) ;\n\\end{verbatim}\nfrom a driver program.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1}, {\\tt n2} or {\\tt n3} are less than or equal to zero,\nor if {\\tt newToOld} is {\\tt NULL},\nor if {\\tt west}, {\\tt south} or {\\tt bottom} \nare less than or equal to zero,\nof if ${\\tt east} \\ge {\\tt n1}$,\nof if ${\\tt north} \\ge {\\tt n2}$,\nof if ${\\tt top} \\ge {\\tt n3}$,\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid mkNDperm2 ( int n1, int n2, int n3, int newToOld[], int west, \n                 int east, int south, int north, int bottom, int top ) ;\n\\end{verbatim}\n\\index{mkNDperm2@{\\tt mkNDperm2()}}\nThis method this vector fills a permutation vector with the\nnested dissection\nnew-to-old ordering of the vertices for the subgrid defined by\nnodes whose coordinates lie in\n\\begin{verbatim}\n[west, east] x [south, north] x [bottom, top].\n\\end{verbatim}\nThere is one important difference between this method and {\\tt\nmkNDperm()} above; this method finds {\\it double-wide} separators,\nnecessary for an operator with more than nearest neighbor grid\npoint coupling.\nThe method calls itself recursively.\nTo find the permutation for an {\\tt n1 x n2 x n3} grid, call\n\\begin{verbatim}\nmkNDperm(n1, n2, n3, newToOld, 0, n1-1, 0, n2-1, 0, n3-1) ;\n\\end{verbatim}\nfrom a driver program.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1}, {\\tt n2} or {\\tt n3} are less than or equal to zero,\nor if {\\tt newToOld} is {\\tt NULL},\nor if {\\tt west}, {\\tt south} or {\\tt bottom} \nare less than or equal to zero,\nof if ${\\tt east} \\ge {\\tt n1}$,\nof if ${\\tt north} \\ge {\\tt n2}$,\nof if ${\\tt top} \\ge {\\tt n3}$,\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid localND2D ( int n1, int n2, int p1, int p2, \n                 int dsizes1[], int dsizes2[], int oldToNew[] ) ;\n\\end{verbatim}\n\\index{localND2D@{\\tt localND2D()}}\nThis method finds a local nested dissection ordering \n\\cite{bha93-localND} for an {\\tt n1 x n2} 2-D grid.\nThere are {\\tt p1 x p2} domains in the grid.\nThe {\\tt dsizes1[]} and {\\tt dsizes2[]} vectors are optional;\nthey allow the user to explicitly input domain sizes.\nIf {\\tt dsizes1[]} and {\\tt dsizes2[]} are not {\\tt NULL},\nthe {\\tt q = q1 + q2*p1}'th domain contains a\n{\\tt dsizes1[q1] x dsizes2[q2]} subgrid of points.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1} or {\\tt n2} are less than or equal to zero,\nor if {\\tt p1} or {\\tt p2} are less than or equal to zero,\nor if $2{\\tt p1} - 1 > {\\tt n1}$,\nor if $2{\\tt p2} - 1 > {\\tt n2}$,\nor if {\\tt oldToNew} is {\\tt NULL},\nor if {\\tt dsizes1[]} and {\\tt dsizes2[]} are not {\\tt NULL} \nbut have invalid entries (all entries must be positive, \nentries in {\\tt dsizes1[]} must sum to {\\tt n1 - p1 + 1},\nand\nentries in {\\tt dsizes2[]} must sum to {\\tt n2 - p2 + 1},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid localND3D ( int n1, int n2, int n3, int p1, int p2, int p3,\n                 int dsizes1[], int dsizes2[], int dsizes3[],\n                 int oldToNew[] ) ;\n\\end{verbatim}\n\\index{localND3D@{\\tt localND3D()}}\nThis method finds a local nested dissection ordering \n\\cite{bha93-localND} for an {\\tt n1 x n2 x n3} 3-D grid.\nThere are {\\tt p1 x p2 x p3} domains in the grid.\nThe {\\tt q}'th domain contains a\n{\\tt dsizes1[q] x dsizes2[q] x dsizes3[q]} \nsubgrid of points.\nThe {\\tt dsizes1[]}, {\\tt dsizes2[]} and {\\tt dsizes3[]} vectors \nare optional;\nthey allow the user to explicitly input domain sizes.\nIf {\\tt dsizes1[]}, {\\tt dsizes2[]} and {\\tt dsizes3[]} \nare not {\\tt NULL},\nthe {\\tt q = q1 + q2*p1+ q3*p1*p2}'th domain contains a\n{\\tt dsizes1[q1] x dsizes2[q2] x disizes3[q3]} subgrid of points.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1}, {\\tt n2} or {\\tt n3} are less than or equal to zero,\nor if {\\tt p1}, {\\tt p2} or {\\tt p3} are less than or equal to zero,\nor if $2{\\tt p1} - 1 > {\\tt n1}$,\nor if $2{\\tt p2} - 1 > {\\tt n2}$,\nor if $2{\\tt p3} - 1 > {\\tt n3}$,\nor if {\\tt oldToNew} is {\\tt NULL},\nor if {\\tt dsizes1[]}, {\\tt disizes2[]} and {\\tt dsizes3[]} \nare not {\\tt NULL} \nbut have invalid entries (all entries must be positive, \nentries in {\\tt dsizes1[]} must sum to {\\tt n1 - p1 + 1},\nentries in {\\tt dsizes2[]} must sum to {\\tt n2 - p2 + 1},\nand\nentries in {\\tt dsizes3[]} must sum to {\\tt n3 - p3 + 1},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid fp2DGrid ( int n1, int n2, int ivec[], FILE *fp ) ;\n\\end{verbatim}\n\\index{fp2DGrid@{\\tt fp2DGrid()}}\nThis method writes the {\\tt ivec[]} vector onto an {\\tt n1 x n2}\ngrid to file {\\tt fp}.\nThis is useful to visualize an ordering or a metric on a grid.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1} or {\\tt n2} are less than or equal to zero,\nor if {\\tt ivec} or {\\tt fp} are {\\tt NULL},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid fp3DGrid ( int n1, int n2, int n3, int ivec[], FILE *fp ) ;\n\\end{verbatim}\n\\index{fp3DGrid@{\\tt fp3DGrid()}}\nThis method writes the {\\tt ivec[]} vector onto an {\\tt n1 x n2 x n3}\ngrid to file {\\tt fp}.\nThis is useful to visualize an ordering or a metric on a grid.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt n1}, {\\tt n2} or {\\tt n3} are less than or equal to zero, \nor if {\\tt ivec} or {\\tt fp} are {\\tt NULL},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n%=======================================================================\n\\subsection{Multiple minimum degree, Nested dissection \n            and multisection wrapper methods}\n\\par\nThere are three simple methods to find minimum degree, nested\ndissection and multisection orderings.\nIn addition, there is one method that finds the better of two\nmethods -- nested dissection and multisection.\n(Much of the work to find either nested dissection or multisection\nis identical, so this method takes little more time than either of\nthe two separately.)\n\\par\nTo properly specify these methods there are many parameters\n--- these three wrapper methods insulate the user from all but one\nor two of the parameters.\nAs a result, the quality of the ordering may not be as good as can\nbe found by using non-default settings of the parameters.\n\\par\nOne wrapper method computes a minimum degree ordering --- the only\ninput parameter is a random number seed.\nTwo wrappers methods compute the nested dissection and multisection\norderings --- in addition to a random number seed there is a upper\nbound on the subgraph size used during the graph partition.\nThis is the most sensitive of the parameters.\n\\par\nThe user interested in more customized orderings should consult the\nchapters on the \nthe {\\tt GPart}, {\\tt DSTree} and {\\tt MSMD} objects\nthat perform the three steps of the ordering process:\nperform an incomplete nested dissection of the graph,\nconstruct the map from vertices to stages in which they will be\neliminated, and perform the multi-stage minimum degree ordering.\nThe driver programs in the {\\tt GPart} and {\\tt MSMD} directories\nfully exercise the graph partition and ordering strategies by\ngiving the user access to all input parameters.\n\\par\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nETree * orderViaMMD ( Graph *graph, int seed, int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{orderViaMMD@{\\tt orderViaMMD()}}\nThis method returns a front tree {\\tt ETree} object for a multiple\nminimum degree ordering of the graph {\\tt graph}.\nThe {\\tt seed} parameter is a random number seed.\nThe {\\tt msglvl} and {\\tt msgFile} parameters govern the\ndiagnostics output.\nUse {\\tt msglvl = 0} for no output, {\\tt msglvl = 1} for timings\nand scalar statistics, and use {\\tt msglvl > 1} with care, for it\ncan generate huge amounts of output.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt graph} is {\\tt NULL},\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL}, \nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nETree * orderViaND ( Graph *graph, int maxdomainsize, int seed, \n                     int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{orderViaND@{\\tt orderViaND()}}\nThis method returns a front tree {\\tt ETree} object for a nested\ndissection ordering of the graph {\\tt graph}.\nIf a subgraph has more vertices than the {\\tt maxdomainsize} parameter,\nit is split.\nThe {\\tt seed} parameter is a random number seed.\nThe {\\tt msglvl} and {\\tt msgFile} parameters govern the\ndiagnostics output.\nUse {\\tt msglvl = 0} for no output, {\\tt msglvl = 1} for timings\nand scalar statistics, and use {\\tt msglvl > 1} with care, for it\ncan generate huge amounts of output.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt graph} is {\\tt NULL},\nor if ${\\tt maxdomainsize} \\le 0$,\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL}, \nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nETree * orderViaMS ( Graph *graph, int maxdomainsize, int seed, \n                     int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{orderViaMS@{\\tt orderViaMS()}}\nThis method returns a front tree {\\tt ETree} object for a \nmultisection ordering of the graph {\\tt graph}.\nIf a subgraph has more vertices than the {\\tt maxdomainsize} parameter,\nit is split.\nThe {\\tt seed} parameter is a random number seed.\nThe {\\tt msglvl} and {\\tt msgFile} parameters govern the\ndiagnostics output.\nUse {\\tt msglvl = 0} for no output, {\\tt msglvl = 1} for timings\nand scalar statistics, and use {\\tt msglvl > 1} with care, for it\ncan generate huge amounts of output.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt graph} is {\\tt NULL},\nor if ${\\tt maxdomainsize} \\le 0$,\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL}, \nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nETree * orderViaBestOfNDandMS ( Graph *graph, int maxdomainsize, int maxzeros,\n                                int maxsize, int seed, int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{orderViaBestOfNDandMS@{\\tt orderViaBestOfNDandMS()}}\nThis method returns a front tree {\\tt ETree} object for a \nbetter of two orderings, a nested dissection \nand multisection ordering.\nIf a subgraph has more vertices than the {\\tt maxdomainsize} parameter,\nit is split.\nThe {\\tt seed} parameter is a random number seed.\nThis method also transforms the front tree using the {\\tt maxzeros}\nand {\\tt maxsize} parameters.\nSee the {\\tt ETree\\_transform()} method \nin Section~\\ref{subsection:ETree:proto:transformation}.\nThe {\\tt msglvl} and {\\tt msgFile} parameters govern the\ndiagnostics output.\nUse {\\tt msglvl = 0} for no output, {\\tt msglvl = 1} for timings\nand scalar statistics, and use {\\tt msglvl > 1} with care, for it\ncan generate huge amounts of output.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt graph} is {\\tt NULL},\nor if ${\\tt maxdomainsize} \\le 0$,\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL}, \nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n%=======================================================================\n\\subsection{Graph drawing method}\n\\par\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid drawGraphEPS ( Graph *graph, Coords *coords, IV *tagsIV, \n                    double bbox[4], double rect[4], double linewidth1,\n                    double linewidth2, double radius, char *epsFileName,\n                    int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{drawGraphEPS@{\\tt drawGraphEPS()}}\nThis method is used to create an EPS (Encapsulated Postscript) file\nthat contains a picture of a graph in two dimensions.\nWe use this to visualize separators and domain decompositions,\nmostly of regular grids and triangulations of a planar region.\n\\par\nThe {\\tt graph} object defines the connectivity of the\nvertices.\nThe {\\tt coords} object defines the locations of the vertices.\nThe {\\tt tagsIV} object is used to define whether or not an edge\nis drawn between two vertices adjacent in the graph.\nWhen {\\tt tagsIV} is not {\\tt NULL}, \nif there is an edge {\\tt (u,v)} in the graph and \n{\\tt tags[u] = tags[v]}, then the edge with width {\\tt linewidth1}\nis drawn.\nFor edges {\\tt (u,v)} in the graph and \n{\\tt tags[u] != tags[v]}, then the edge with width {\\tt linewidth2}\nis drawn, assuming ${\\tt linewidth2} > 0$.\nIf {\\tt tagsIV} is {\\tt NULL}, than all edges are drawn with \nwidth {\\tt linewidth1}.\nEach vertex is draw with a filled circle with radius {\\tt radius}.\n\\par\nThe graph and its {\\tt Coords} object occupy a certain area in 2-D\nspace.\nWe try to plot the graph inside the area defined by the {\\tt\nrect[]} array in such a manner that the relative scales are\npreserved (the graph is not stretched in either the $x$ or $y$\ndirection) and that the larger of the width and height of the graph\nfills the area defined by the {\\tt rect[]} rectangle.\n{\\it Note}: hacking postscript is {\\it not} an area of expertise of\neither author.\nSome Postscript viewers give us messages that we are not obeying\nthe format conventions (this we do not doubt), but we have never\nfailed to view or print one of these files.\n\\par \\noindent {\\it Error checking:}\nIf the method is unable to open the file, \nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n%=======================================================================\n\\subsection{Linear system construction}\n\\par\nOur driver programs test linear systems where the matrices come\nfrom regular grids using nested dissection orderings.\nThere are two methods that generate linear systems of this form\nalong with the front tree and symbolic factorization.\n\\par\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid mkNDlinsys ( int n1, int n2, int n3, int maxzeros, int maxsize,\n                  int type, int symmetryflag, int nrhs, int seed, int msglvl, \n                  FILE *msgFile, ETree **pfrontETree, IVL **psymbfacIVL, \n                  InpMtx **pmtxA, DenseMtx **pmtxX, DenseMtx **pmtxB ) ;\n\\end{verbatim}\n\\index{mkNDlinsys@{\\tt mkNDlinsys()}}\nThis method creates a linear system $AX = B$ for a\n${\\tt n1} \\times {\\tt n2} \\times {\\tt n3}$ grid.\nThe entries in $A$ and $X$ are random numbers,\n$B$ is computed as the product of $A$ with $X$.\n$A$ can be real ({\\tt type = 1}) or complex ({\\tt type = 2}),\nand can be symmetric ({\\tt symmetryflag = 0}),\nHermitian ({\\tt symmetryflag = 1}) or\nnonsymmetric ({\\tt symmetryflag = 2}).\nThe number of columns of $X$ is given by {\\tt nrhs}.\nThe linear system is ordered using theoretical nested dissection,\nand the front tree is transformed using the {\\tt maxzeros} and {\\tt\nmaxsize} parameters.\nThe addresses of the front tree, symbolic factorization, and three\nmatrix objects are returned in the last five arguments of the\ncalling sequence.\n\\par \\noindent {\\it Error checking:}\nNone presently.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid mkNDlinsysQR ( int n1, int n2, int n3, int type, int nrhs, int seed,\n               int msglvl, FILE *msgFile, ETree **pfrontETree, IVL **psymbfacIVL, \n               InpMtx **pmtxA, DenseMtx **pmtxX, DenseMtx **pmtxB ) ;\n\\end{verbatim}\n\\index{mkNDlinsysQR@{\\tt mkNDlinsysQR()}}\nThis method creates a linear system $AX = B$ for a\nnatural factor formulation of a\n${\\tt n1} \\times {\\tt n2} \\times {\\tt n3}$ grid.\nIf {\\tt n1}, {\\tt n2} and {\\tt n3} are all greater than 1,\nthe grid is formed of linear hexahedral elements and\nthe matrix $A$ has {\\tt 8*n1*n2*n3} rows.\nIf one of {\\tt n1}, {\\tt n2} and {\\tt n3} is equal to 1,\nthe grid is formed of linear quadrilateral elements and\nthe matrix $A$ has {\\tt 4*n1*n2*n3} rows.\nThe entries in $A$ and $X$ are random numbers,\n$B$ is computed as the product of $A$ with $X$.\n$A$ can be real ({\\tt type = 1}) or complex ({\\tt type = 2}).\nThe number of columns of $X$ is given by {\\tt nrhs}.\nThe linear system is ordered using theoretical nested dissection,\nand the front tree is transformed using the {\\tt maxzeros} and {\\tt\nmaxsize} parameters.\nThe addresses of the front tree, symbolic factorization, and three\nmatrix objects are returned in the last five arguments of the\ncalling sequence.\n\\par \\noindent {\\it Error checking:}\nNone presently.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n", "meta": {"hexsha": "67fa0ca677679b0033b418dc4bcf5e2c0bbd7b0b", "size": 18132, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/proto.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/proto.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/misc/doc/proto.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 43.9031476998, "max_line_length": 84, "alphanum_fraction": 0.6469777189, "num_tokens": 4922, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.42218294083815516}}
{"text": "\\documentclass[namecite, fleqn]{goose-article}\n\n\\title{Isotropic elasto-plasticity}\n\n\\author{Tom W.J.\\ de Geus}\n\n\\hypersetup{pdfauthor={T.W.J. de Geus}}\n\n\\newcommand\\leftstar[1]{\\hspace*{-.3em}~^\\star\\!#1}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\\noindent\nHistory dependent elasto-plastic material.\nThis corresponds to a non-linear relation between the Cauchy stress, $\\bm{\\sigma}$,\nand the linear strain increment, $\\bm{\\varepsilon}_\\Delta$,\ndepending on the equivalent plastic strain, $\\varepsilon_\\mathrm{p}$.\nI.e.\n\\begin{equation*}\n    \\bm{\\sigma}\n    = f ( \\bm{\\varepsilon}_\\Delta , \\varepsilon_\\mathrm{p} )\n\\end{equation*}\nThe plasticity follows power-law hardening\n\\begin{equation*}\n    \\sigma_\\mathrm{y} (\\varepsilon_\\mathrm{p})\n    = \\sigma_\\mathrm{y0} + \\varepsilon_\\mathrm{p}^n\n\\end{equation*}\nThe model is implemented in 3-D, hence it can directly be used for either 3-D\nor 2-D plane strain problems.\n\\end{abstract}\n\n\\section{Constitutive model}\n\nThe model consists of the following ingredients:\n\\begin{enumerate}[(i)]\n\n    \\item The strain, $\\bm{\\varepsilon}$, is additively split in an elastic part,\n    $\\bm{\\varepsilon}_\\mathrm{e}$, and a plastic plastic, $\\bm{\\varepsilon}_\\mathrm{p}$.\n    I.e.\n    \\begin{equation}\n        \\bm{\\varepsilon} \\equiv \\bm{\\varepsilon}_\\mathrm{e} + \\bm{\\varepsilon}_\\mathrm{p}\n    \\end{equation}\n\n    \\item The stress, $\\bm{\\sigma}$, is set by to the elastic strain,\n    $\\bm{\\varepsilon}_\\mathrm{e}$, through the following linear relation:\n    \\begin{equation}\n        \\bm{\\sigma} \\equiv \\mathbb{C}_\\mathrm{e} : \\bm{\\varepsilon}_\\mathrm{e}\n    \\end{equation}\n    wherein $\\mathbb{C}_\\mathrm{e}$ is the elastic stiffness, which reads:\n    \\begin{align}\n        \\mathbb{C}_\\mathrm{e}\n        &\\equiv K \\bm{I} \\otimes \\bm{I}\n        + 2 G (\\mathbb{I}_\\mathrm{s} - \\tfrac{1}{3} \\bm{I} \\otimes \\bm{I} )\n        \\\\\n        &= K \\bm{I} \\otimes \\bm{I}\n        + 2 G \\, \\mathbb{I}_\\mathrm{d}\n    \\end{align}\n    with $K$ and $G$ the bulk and shear modulus respectively.\n    See \\cref{sec:ap:nomenclature} for nomenclature,\n    including definitions of the unit tensors.\n\n    \\item The elastic domain is bounded by the following yield function\n    \\begin{equation}\n        \\Phi( \\bm{\\sigma} , \\varepsilon_\\mathrm{p} )\n        \\equiv \\sigma_\\mathrm{eq} - \\sigma_\\mathrm{y} (\\varepsilon_\\mathrm{p}) \\leq 0\n    \\end{equation}\n    where $\\sigma_\\mathrm{eq}$ the equivalent stress (see \\cref{sec:ap:stress}),\n    and $\\sigma_\\mathrm{y}$ the yield stress which is a non-linear function of\n    the equivalent plastic strain, $\\varepsilon_\\mathrm{p}$.\n\n    \\item To determine the direction of plastic flow, normality is assumed.\n    This corresponds to the following associative flow rule:\n    \\begin{equation}\n        \\dot{\\bm{\\varepsilon}}_\\mathrm{p} \\equiv \\dot{\\gamma} \\bm{N}\n    \\end{equation}\n    where $\\dot{\\gamma}$ is the plastic multiplier, and $\\bm{N}$ is the Prandtl--Reuss flow vector,\n    which is defined through normality:\n    \\begin{equation}\n        \\bm{N} \\equiv \\frac{\\partial \\Phi}{\\partial \\bm{\\sigma}}\n        = \\sqrt{\\frac{3}{2}} \\;\n        \\frac{\\bm{\\sigma}_\\mathrm{d}}{|| \\bm{\\sigma}_\\mathrm{d} ||}\n        = \\frac{3}{2}\n        \\frac{\\bm{\\sigma}_\\mathrm{d}}{\\sigma_\\mathrm{eq}}\n    \\end{equation}\n\n    \\item Finally, associative hardening is assumed:\n    \\begin{equation}\n        \\dot{\\varepsilon}_\\mathrm{p}\n        \\equiv \\sqrt{\\tfrac{2}{3}} \\; \\big|\\big| \\dot{\\bm{\\varepsilon}}_\\mathrm{p} \\big|\\big|\n        = \\dot{\\gamma}\n    \\end{equation}\n    The equivalent plastic strain then reads\n    \\begin{equation}\n        \\varepsilon_\\mathrm{p}\n        = \\int\\limits_0^t \\dot{\\varepsilon}_\\mathrm{p} ~\\mathrm{d}\\tau\n    \\end{equation}\n\n\\end{enumerate}\nFor a more detailed description the reader is referred to \\citet[][p.\\ 216-234]{DeSouzaNeto2008}.\n\n\\section{Numerical implementation: implicit}\n\nFor the numerical implementation, first of all\na numerical time integration scheme has to be selected.\nHere, an implicit time discretisation is used, which has the\nfavourable property of being unconditionally stable.\nThe numerical implementation of it is done by the commonly used return-map algorithm,\nin which an increment in strain is first assumed fully elastic (elastic predictor).\nThen, if needed, a return-map is utilized to return to a physically admissible state\n(plastic corrector).\n\n\\subsection{Elastic predictor}\n\nGiven an increment in strain\n\\begin{equation}\n    \\bm{\\varepsilon}_\\Delta\n    = \\bm{\\varepsilon} - \\bm{\\varepsilon}^{(t)}\n\\end{equation}\nand the state variables, evaluate the \\emph{elastic trial state}:\n\\begin{align}\n    \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n    &= \\bm{\\varepsilon}_\\mathrm{e}^{(t)} + \\bm{\\varepsilon}_\\Delta\n    \\\\\n    \\leftstar{\\varepsilon}_\\mathrm{p}\n    &= \\varepsilon_\\mathrm{p}^{(t)}\n\\end{align}\nThe corresponding trial stress is computed by\n\\begin{equation}\n    \\leftstar{\\bm{\\sigma}}\n    = \\mathbb{C}_\\mathrm{e} : \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n\\end{equation}\nFinally the trial value of the yield function follows as\n\\begin{equation}\n    \\leftstar{\\Phi}\n    = \\Phi( \\leftstar{\\bm{\\sigma}} , \\leftstar{\\varepsilon}_\\mathrm{p} )\n    = \\leftstar{\\sigma}_\\mathrm{eq}\n    - \\sigma_\\mathrm{y} (\\leftstar{\\varepsilon}_\\mathrm{p})\n\\end{equation}\n\n\\subsection{Trial state: elastic}\n\nIf the trial state is within the (current) yield surface, i.e.\\ when\n\\begin{equation}\n    \\leftstar{\\Phi} \\leq 0\n\\end{equation}\nthe trial state coincides with the actual state, and:\n\\begin{align}\n    \\bm{\\varepsilon}_\\mathrm{e}\n    &= \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n    = \\bm{\\varepsilon}_\\mathrm{e}^{(t)} + \\bm{\\varepsilon}_\\Delta\n    \\\\\n    \\varepsilon_\\mathrm{p}\n    &= \\leftstar{\\varepsilon}_\\mathrm{p}\n    = \\varepsilon_\\mathrm{p}^{(t)}\n    \\\\\n    \\bm{\\sigma}\n    &= \\leftstar{\\bm{\\sigma}}\n\\end{align}\n\nOtherwise a return-map is needed (see below).\n\n\\subsection{Trial state elasto-plastic: return-map}\n\nIf the trial state is outside the (current) yield surface, i.e.\\ when\n\\begin{equation}\n    \\leftstar{\\Phi} > 0\n\\end{equation}\nplastic flow occurs in the increment.\nA return-map is needed to return to the admissible state.\nThe admissible state has to satisfy the following system of equations:\n\\begin{equation}\n    \\begin{cases}\n        \\; \\bm{\\varepsilon}_\\mathrm{e}\n        &= \\leftstar\\bm{\\varepsilon}_\\mathrm{e}\n        - \\Delta \\gamma \\; \\bm{N}\n        \\\\[2mm]\n        \\; \\varepsilon_\\mathrm{p}\n        &= \\varepsilon_\\mathrm{p}^{(t)} + \\Delta \\gamma\n        \\\\[2mm]\n        \\; \\Phi\n        &= \\sigma_\\mathrm{eq}\n        - \\sigma_\\mathrm{y} \\big( \\varepsilon_\\mathrm{p}^{(t)} + \\Delta\\gamma \\big)\n        = 0\n    \\end{cases}\n\\end{equation}\n\n\\subsubsection{Scalar equation return-map}\n\nThis can be reduced by using that\n\\begin{align}\n    \\bm{\\sigma}_\\mathrm{d}\n    &= \\leftstar{\\bm{\\sigma}}_\\mathrm{d}\n     - 2 G \\Delta \\gamma \\; \\bm{N}\n    \\\\\n    &= \\leftstar{\\bm{\\sigma}}_\\mathrm{d}\n    - 3 G \\Delta \\gamma \\;\n    \\frac{\n        \\bm{\\sigma}_\\mathrm{d}\n    }{\n        \\sigma_\\mathrm{eq}\n    }\n\\end{align}\nFrom this is follows that:\n\\begin{equation}\n    \\frac{\\bm{\\sigma}_\\mathrm{d}}{\\sigma_\\mathrm{eq}}\n    = \\frac{\\leftstar{\\bm{\\sigma}}_\\mathrm{d}}{\\leftstar{\\sigma}_\\mathrm{eq}}\n    \\qquad\n    \\text{or}\n    \\qquad\n    \\bm{N}\n    = \\leftstar{\\bm{N}}\n\\end{equation}\nAnd thus\n\\begin{equation}\n    \\bm{\\sigma}_\\mathrm{d}\n    = \\left( 1 - \\frac{3 G \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} \\right)\n    \\leftstar{\\bm{\\sigma}}_\\mathrm{d}\n\\end{equation}\nwhereby the equivalent stress trivially follows as\n\\begin{equation}\n    \\sigma_\\mathrm{eq} =\n    \\leftstar{\\sigma}_\\mathrm{eq} - 3 G \\Delta \\gamma\n\\end{equation}\nIn stead of the system return the plastic multiplier $\\Delta \\gamma$ can directly\nbe found by enforcing the yield surface\n\\begin{equation}\n\\label{eq:return-scalar}\n    \\Phi\n    = \\leftstar{\\sigma}_\\mathrm{eq}\n    - 3 G \\Delta \\gamma\n    - \\sigma_\\mathrm{y} \\big( \\varepsilon_\\mathrm{p}^{(t)} + \\Delta \\gamma \\big)\n    = 0\n\\end{equation}\nThis (non-linear) equation has to be solved for the unknown plastic multiplier $\\Delta \\gamma$.\n\n\\subsubsection{Linear hardening}\n\nLinear hardening reads\n\\begin{equation}\n    \\sigma_\\mathrm{y} = \\sigma_\\mathrm{y0} + H \\varepsilon_\\mathrm{p}\n\\end{equation}\nIn this case \\cref{eq:return-scalar} can be solved analytically.\nThe solution reads\n\\begin{equation}\n    \\Delta \\gamma\n    = \\frac{ \\leftstar{\\Phi} }{ 3G + H }\n\\end{equation}\n\n\\subsubsection{Non-linear hardening}\n\n\\begin{enumerate}[(1)]\n\n    \\item Initial guess:\n    \\begin{equation}\n        \\Delta \\gamma\n        := 0\n    \\end{equation}\n    and evaluate\n    \\begin{equation}\n        \\tilde{\\Phi}\n        := \\leftstar{\\Phi}\n    \\end{equation}\n\n    \\item Perform Newton-Raphson iteration:\n    \\begin{itemize}\n\n    \\item Hardening slope\n    \\begin{equation}\n        H\n        := \\left.\n        \\frac{\n            \\mathrm{d} \\sigma_\\mathrm{y}\n        }{\n            \\mathrm{d} \\varepsilon_\\mathrm{p}\n        }\n        \\right|_{\\varepsilon_\\mathrm{p}^{(t)} + \\Delta \\gamma}\n    \\end{equation}\n\n    \\item Residual derivative:\n    \\begin{equation}\n        d := \\frac{\\mathrm{d} \\tilde{\\Phi}}{\\mathrm{d} \\Delta \\gamma}\n        = -3G - H\n    \\end{equation}\n\n    \\item Update guess for the plastic multiplier:\n    \\begin{equation}\n        \\Delta \\gamma := \\Delta \\gamma - \\frac{\\tilde{\\Phi}}{d}\n    \\end{equation}\n    \\end{itemize}\n\n    \\item Check for convergence:\n    \\begin{equation}\n        \\tilde{\\Phi}\n        := \\leftstar{\\sigma}_\\mathrm{eq}\n        - 3 G \\Delta \\gamma\n        - \\sigma_\\mathrm{y} ( \\varepsilon_\\mathrm{p}^{(t)} + \\Delta \\gamma )\n    \\end{equation}\n    Stop if:\n    \\begin{equation}\n        \\big| \\tilde{\\Phi} \\big| \\leq \\epsilon_\\mathrm{tol}\n    \\end{equation}\n    Otherwise continue with (2)\n\n\\end{enumerate}\n\n\\subsubsection{Trial state update}\n\nFinally, the trial state is updated:\n\\begin{itemize}\n\n    \\item The updated stress tensor\n    \\begin{equation}\n        \\bm{\\sigma}\n        = \\sigma_\\mathrm{m} \\bm{I}\n        + \\bm{\\sigma}_\\mathrm{d}\n    \\end{equation}\n    with\n    \\begin{align}\n        \\sigma_\\mathrm{m}\n        &= \\leftstar{\\sigma}_\\mathrm{m}\n        \\\\\n        \\bm{\\sigma}_\\mathrm{d}\n        &= \\left(\n            1 - \\frac{3 G \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}}\n        \\right) \\leftstar{\\bm{\\sigma}}_\\mathrm{d}\n    \\end{align}\n\n    \\item The updated elastic strain tensor\n    \\begin{equation}\n        \\bm{\\varepsilon}_\\mathrm{e}\n        = \\frac{1}{2G} \\bm{\\sigma}_\\mathrm{d}\n        + \\tfrac{1}{3} \\;\\mathrm{tr} (\\leftstar{\\bm{\\varepsilon}}) \\bm{I}\n    \\end{equation}\n\n    \\item The updated equivalent plastic strain:\n    \\begin{equation}\n        \\varepsilon_\\mathrm{p}\n        = \\varepsilon_\\mathrm{p}^{(t)}\n        + \\Delta \\gamma\n    \\end{equation}\n\n\\end{itemize}\n\n\\section{Consistent tangent}\n\nTo derive the consistent tangent, the first step is to combine the above to an explicit\nrelation between the (actual) stress $\\bm{\\sigma}$ and the trial elastic strain\n$\\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}$.\n\\begin{itemize}\n\n    \\item If elastic:\n    \\begin{equation}\n        \\bm{\\sigma}\n        = \\leftstar{\\bm{\\sigma}}\n        = \\mathbb{C}_\\mathrm{e} : \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n    \\end{equation}\n    The tangent then trivially follows:\n    \\begin{equation}\n        \\mathbb{C}_\\mathrm{ep}\n        =\n        \\frac{\n            \\partial  \\bm{\\sigma} \\hfill\n        }{\n            \\partial \\bm{\\varepsilon} \\hfill\n        }\n        =\n        \\frac{\n            \\partial ~\\bm{\\sigma} \\hfill\n        }{\n            \\partial \\;\\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n        }\n        =\n        \\mathbb{C}_\\mathrm{e}\n    \\end{equation}\n\n    \\item If plastic:\n    \\begin{align}\n        \\bm{\\sigma}\n        &= \\sigma_\\mathrm{m} \\bm{I}\n        + \\bm{\\sigma}_\\mathrm{d}\n        \\\\\n        &= \\leftstar{\\sigma}_\\mathrm{m} \\bm{I}\n        + \\left( 1- \\frac{3 G \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} \\right)\n        \\leftstar{\\bm{\\sigma}}_\\mathrm{d}\n        \\\\\n        &= \\leftstar{\\sigma}_\\mathrm{m} \\bm{I}\n        + \\left( 1-\\frac{3 G \\Delta\\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} \\right)\n        2 G \\; \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}^\\mathrm{d}\n        \\\\\n        &=\n        \\left[\n        \\mathbb{C}_\\mathrm{e} -\n        \\frac{6 G^2 \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} \\, \\mathbb{I}_\\mathrm{d}\n        \\right] : \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n    \\end{align}\n    The tangent then follows from\n    \\begin{align}\n        \\mathbb{C}_\\mathrm{ep} &=\n        \\frac{\n            \\partial  \\bm{\\sigma} \\hfill\n        }{\n            \\partial \\bm{\\varepsilon} \\hfill\n        } =\n        \\frac{\n            \\partial ~\\bm{\\sigma} \\hfill\n        }{\n            \\partial \\;\\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n        }\n        \\\\\n        &=\n        \\mathbb{C}_\\mathrm{e} -\n        \\frac{6 G^2 \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}}\n        \\mathbb{I}_\\mathrm{d}\n        + 4 G^2\n        \\left[\n            \\frac{\\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} -\n            \\frac{1}{3 G + H}\n        \\right]\n        \\leftstar{\\bm{N}} \\otimes \\leftstar{\\bm{N}}\n    \\end{align}\n\n\\end{itemize}\n\n\\subsection{Derivation}\n\n\\begin{align}\n    \\frac{\n        \\partial \\bm{\\sigma} \\hfill\n    }{\n        \\partial \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n    } =\n    \\mathbb{C}^e\n    - \\frac{6 G^2 \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}} \\mathbb{I}^d\n    - \\frac{6 G^2}{\\leftstar{\\sigma}_\\mathrm{eq}} \\;\n    \\left( \\frac{\n        \\partial ~\\Delta \\gamma \\hfill\n    }{\n        \\partial \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n    } \\right) \\otimes\n    \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}^d\n    + \\frac{6 G^2 \\Delta \\gamma}{\\leftstar{\\sigma}_\\mathrm{eq}^2} \\;\n    \\left( \\frac{\n        \\partial \\leftstar{\\sigma}_\\mathrm{eq} \\hfill\n    }{\n        \\partial \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n    } \\right) \\otimes\n    \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}^d\n\\end{align}\nApply the following:\n\\begin{itemize}\n\n\\item for the equivalent stress\n\\begin{equation}\n    \\frac{\\partial \\sigma_\\mathrm{eq}}{\\partial \\bm{\\sigma}}\n    = \\frac{\\partial \\sigma_\\mathrm{eq}}{\\partial \\bm{\\sigma}^d}\n    = \\frac{\\partial}{\\partial \\bm{\\sigma}^d }\n    \\left( \\sqrt{ \\tfrac{3}{2} \\bm{\\sigma}^d : \\bm{\\sigma}^d } \\right)\n    = \\frac{1}{2 \\sigma_\\mathrm{eq} } \\frac{\\partial}{\\partial \\bm{\\sigma}^d}\n    \\left( \\tfrac{3}{2} \\bm{\\sigma}^d : \\bm{\\sigma}^d \\right)\n    = \\frac{3}{2} \\frac{\\bm{\\sigma}^d}{\\sigma_\\mathrm{eq}} = \\bm{N} = \\leftstar{\\bm{N}}\n\\end{equation}\nhence:\n\\begin{equation}\n    \\frac{\n        \\partial \\leftstar{\\sigma}_\\mathrm{eq}\n    }{\n        \\partial \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}\n    } =\n    2 G \\, \\leftstar{\\bm{N}}\n\\end{equation}\n\n\\item for the plastic multiplier\n\\begin{align}\n    \\frac{\n        \\partial ~\\Delta \\gamma \\hfill\n    }{\n        \\partial  \\leftstar{\\bm{\\varepsilon}}_\\mathrm{e}  \\hfill\n    }\n    =\n    \\left( \\frac{\n        \\partial ~\\Delta \\gamma \\hfill\n    }{\n        \\partial ~\\Phi \\hfill\n    } \\right) \\;\n    \\left( \\frac{\n        \\partial \\,~\\Phi \\hfill\n    }{\n        \\partial  \\,\\leftstar{\\sigma}_\\mathrm{eq} \\hfill\n    } \\right) \\;\n    \\left( \\frac{\n        \\partial \\,\\leftstar{\\sigma}_\\mathrm{eq} \\hfill\n    }{\n        \\partial \\,\\leftstar{\\bm{\\varepsilon}}_\\mathrm{e} \\hfill\n    } \\right) \\;\n    &= \\frac{2 G}{3 G + H} \\, \\leftstar{\\bm{N}}\n\\end{align}\n\\end{itemize}\n\n\\appendix\n\n\\section{Nomenclature}\n\\label{sec:ap:nomenclature}\n\n\\paragraph{Tensor products}\n\\vspace*{.5eM}\n\n\\begin{itemize}\n\n    \\item Dyadic tensor product\n    \\begin{align}\n        \\mathbb{C} &= \\bm{A} \\otimes \\bm{B} \\\\\n        C_{ijkl} &= A_{ij} \\, B_{kl}\n    \\end{align}\n\n    \\item Double tensor contraction\n    \\begin{align}\n        C &= \\bm{A} : \\bm{B} \\\\\n        &= A_{ij} \\, B_{ji}\n    \\end{align}\n\n\\end{itemize}\n\n\\paragraph{Tensor decomposition}\n\\vspace*{.5eM}\n\n\\begin{itemize}\n\n    \\item Deviatoric part $\\bm{A}_\\mathrm{d}$ of an arbitrary tensor $\\bm{A}$:\n    \\begin{equation}\n        \\mathrm{tr}\\left( \\bm{A}_\\mathrm{d} \\right) \\equiv 0\n    \\end{equation}\n    and thus\n    \\begin{equation}\n      \\bm{A}_\\mathrm{d} = \\bm{A} - \\tfrac{1}{3} \\mathrm{tr}\\left( \\bm{A} \\right)\n    \\end{equation}\n\n\\end{itemize}\n\n\\paragraph{Fourth order unit tensors}\n\\vspace*{.5eM}\n\n\\begin{itemize}\n\n    \\item Unit tensor:\n    \\begin{equation}\n        \\bm{A} \\equiv \\mathbb{I} : \\bm{A}\n    \\end{equation}\n    and thus\n    \\begin{equation}\n        \\mathbb{I} = \\delta_{il} \\delta{jk}\n    \\end{equation}\n\n    \\item Right-transposition tensor:\n    \\begin{equation}\n        \\bm{A}^T \\equiv \\mathbb{I}^{RT} : \\bm{A} = \\bm{A} : \\mathbb{I}^{RT}\n    \\end{equation}\n    and thus\n    \\begin{equation}\n        \\mathbb{I}^{RT} = \\delta_{ik} \\delta_{jl}\n    \\end{equation}\n\n    \\item Symmetrisation tensor:\n    \\begin{equation}\n        \\mathrm{sym} \\left( \\bm{A} \\right) \\equiv \\mathbb{I}_\\mathrm{s} : \\bm{A}\n    \\end{equation}\n    whereby\n    \\begin{equation}\n        \\mathbb{I}_\\mathrm{s} = \\tfrac{1}{2} \\left( \\mathbb{I} + \\mathbb{I}^{RT} \\right)\n    \\end{equation}\n    This follows from the following derivation:\n    \\begin{align}\n        \\mathrm{sym} \\left( \\bm{A} \\right) &= \\tfrac{1}{2} \\left( \\bm{A} + \\bm{A}^T \\right)\n        \\\\\n        &= \\tfrac{1}{2} \\left( \\mathbb{I} : \\bm{A} + \\mathbb{I}^{RT} : \\bm{A} \\right)\n        \\\\\n        &= \\tfrac{1}{2} \\left( \\mathbb{I} + \\mathbb{I}^{RT} \\right) : \\bm{A}\n        \\\\\n        &= \\mathbb{I}_\\mathrm{s} : \\bm{A}\n    \\end{align}\n\n    \\item Deviatoric and symmetric projection tensor\n    \\begin{equation}\n        \\mathrm{dev} \\left( \\mathrm{sym}\n        \\left( \\bm{A} \\right) \\right) \\equiv \\mathbb{I}_\\mathrm{d} : \\bm{A}\n    \\end{equation}\n    from which it follows that:\n    \\begin{equation}\n        \\mathbb{I}_\\mathrm{d}\n        = \\mathbb{I}_\\mathrm{s} - \\tfrac{1}{3} \\bm{I} \\otimes \\bm{I}\n    \\end{equation}\n\n\\end{itemize}\n\n\\section{Stress measures}\n\\label{sec:ap:stress}\n\n\\begin{itemize}\n\n    \\item Mean stress\n    \\begin{equation}\n        \\sigma_\\mathrm{m}\n        = \\tfrac{1}{3} \\, \\mathrm{tr} ( \\bm{\\sigma} )\n        = \\tfrac{1}{3} \\, \\bm{\\sigma} : \\bm{I}\n    \\end{equation}\n\n    \\item Stress deviator\n    \\begin{equation}\n        \\bm{\\sigma}_\\mathrm{d}\n        = \\bm{\\sigma} - \\sigma_\\mathrm{m} \\, \\bm{I}\n        = \\mathbb{I}_\\mathrm{d} : \\bm{\\sigma}\n    \\end{equation}\n\n    \\item Von Mises equivalent stress\n    \\begin{align}\n        \\sigma_\\mathrm{eq}\n        = \\sqrt{ \\tfrac{3}{2} \\, \\bm{\\sigma}_\\mathrm{d} : \\bm{\\sigma}_\\mathrm{d} }\n        = \\sqrt{ 3 J_2(\\bm{\\sigma}) }\n    \\end{align}\n    where the second-stress invariant\n    \\begin{align}\n        J_2 = \\tfrac{1}{2} \\, || \\, \\bm{\\sigma}_\\mathrm{d} \\, ||^2\n        = \\tfrac{1}{2} \\, \\bm{\\sigma}_\\mathrm{d} : \\bm{\\sigma}_\\mathrm{d}\n    \\end{align}\n\n\\end{itemize}\n\n\\scriptsize\n\\bibliography{library}\n\n\\end{document}\n", "meta": {"hexsha": "d27059fc4ba62a285c4761f55fabfc0e8a0009f4", "size": 18737, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/readme.tex", "max_stars_repo_name": "tdegeus/GMatElastoPlastic", "max_stars_repo_head_hexsha": "ace74265f46fbc83af16d237db84d147c57598fb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/readme.tex", "max_issues_repo_name": "tdegeus/GMatElastoPlastic", "max_issues_repo_head_hexsha": "ace74265f46fbc83af16d237db84d147c57598fb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 15, "max_issues_repo_issues_event_min_datetime": "2019-04-11T14:17:01.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-30T07:10:09.000Z", "max_forks_repo_path": "docs/readme.tex", "max_forks_repo_name": "tdegeus/GMatElastoPlastic", "max_forks_repo_head_hexsha": "ace74265f46fbc83af16d237db84d147c57598fb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-12T12:09:25.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-12T12:09:25.000Z", "avg_line_length": 29.5536277603, "max_line_length": 99, "alphanum_fraction": 0.5972674388, "num_tokens": 6364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4221829408381551}}
{"text": "\\section{Comparison with Dijkstra}\\label{sec:comparison}\n\nThe Dijkstra algorithm tries to find a minimum \\emph{spanning} tree (to be more\nprecise, a shortest path tree) which contains links that connect a set of target\nnodes.\n\nDifferently from that, a minimum \\emph{Steiner} tree algorithm, as the dual\nascent is, considers also other non-target nodes to compute the solution. So in\nthis way the lower bound of the optimal solution is less or equal than the\nresult provided by a \\emph{spanning} tree algorithm (as we can see in\n\\figref{fig:steiner}). The price to pay is in term of time and computational\npower, because the algorithm has to visit all the possible links and not the\nsubset that involves only the target nodes, so this solution has a limited\nscalability.\n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{img/steiner-topology}\n\t\t\\caption{An example of a network topology where black nodes are\n\t\ttarget nodes}\\label{subfig:steiner-topology}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{img/steiner-minspanning}\n\t\t\\caption{The result of a minimum spanning tree algorithm on the\n\t\texample network topology. The result only contains links that\n\t\tinvolve target nodes. Its cost is\n\t\t4}\\label{subfig:steiner-minspanning}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{img/steiner-minsteiner}\n\t\t\\caption{The result of a minimum Steiner tree algorithm on the\n\t\texample network topology. It includes also non-target nodes to\n\t\tbuild the tree. Its cost is 3}\\label{subfig:steiner-minsteiner}\n\t\\end{subfigure}\n\t\\caption{An example of application of a minimum spanning tree algorithm\n\t\tand a minimum Steiner tree algorithm on the same\n\t\ttopology}\\label{fig:steiner}\n\\end{figure}\n", "meta": {"hexsha": "203018623a5fdbd6ecbc3fbe657d2460096ee206", "size": 1863, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/chapters/dualascent/comparison.tex", "max_stars_repo_name": "SpeedJack/anaws", "max_stars_repo_head_hexsha": "ea7e3b5f81e252705f11577977a88b357a4efd55", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/chapters/dualascent/comparison.tex", "max_issues_repo_name": "SpeedJack/anaws", "max_issues_repo_head_hexsha": "ea7e3b5f81e252705f11577977a88b357a4efd55", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/chapters/dualascent/comparison.tex", "max_forks_repo_name": "SpeedJack/anaws", "max_forks_repo_head_hexsha": "ea7e3b5f81e252705f11577977a88b357a4efd55", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3255813953, "max_line_length": 80, "alphanum_fraction": 0.7799248524, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.42218293745432556}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{September 5, 2014}\n\\maketitle\n\\section*{7}\n$680=2^3\\cdot5\\cdot17, 2^3\\cdot5+17=57, m,n=40,17$\n\\section*{8}\n\\begin{align*}\n  (h,k)=m\\\\\n  m|dh\\rightarrow m|a\\\\\n  m|dk\\rightarrow m|b\\\\\n\\end{align*}\n\\section*{12}\n\\begin{align*}\n  (a,b)=1\\\\\n  (a,c)=1\\\\\n  \\Leftrightarrow\\\\\n  (a,[b,c])=1\n\\end{align*}\n\\section*{19}\np,q are twin primes, provethat pq+1 is square iff p,q are twin primes\n\n\\begin{align*}\n  q=p+2\\\\\n  pq+1=p(p+2)+1=p^2+2p+1=(p+1)^2\\\\\n  m^2=pq+1\\\\\n  mm-1=pq\n  (m+1)(m-1)=pq\\\\\n  (a+1)=pq, or 1 or p\n  (a-1)=1, or pq, or q\n\\end{align*}\n\\section*{23}\n$x^m-1=(x-1)(x^{m-1}+x^{m-2}+...+x+1)$\n\n$x^{2k+1}+1=(x+1)(x^{2k}-x^{2k-1}+x^{2k-2}-...+x^2-x+1)$\n\n$2^n+1$ is prime is given. n is a power of two iff prime factorization of n is $2^m$. prove by contradiction. assume there exists $p=2k+1$ that divides n. $n=(2k+1)\\cdot q$.\n  \n\\begin{align*}\n  2^n+1=2^{q(2k+1)}\\\\\n  =(2^{q})^{2k+1}=(2^q+1)(2^{q2k}-2^{q(2k-1)}+...+1)\n\\end{align*}\nnow $2^n+1$ is not prime unless $p=1$ and $p$ is prime\n\\section*{last time}\n$a,n\\in\\mathbb{Z}, n>1$ the equation $ax\\equiv 1 \\mod n$ has a solution iff $(a,n)=1$.\n\n\\section*{thm}\n$a,b,n\\in\\mathbb{Z},n>1$\n\\begin{enumerate}\n\\item\nthe only eq $ax\\equiv b\\mod n$ has a solution iff $d|b$ where $d=\\gcd(a,n)$.\n\\item\nassume that $d|b$ then the integer solutions of the equation are of the form $...x-\\frac{2n}{d},x-\\frac{n}{d},x,x+\\frac{n}{d},x+\\frac{2n}{d},...$, in particular modulo n, there exist exactly d distinct solutions,namely $x,x+\\frac{n}{d},x+\\frac{2n}{d},...,x+\\frac{(d-1)n}{d}$\n\\end{enumerate}\n\\subsection*{proof}\nassume that $ax\\equiv  b\\mod n$ has a solutionn. then there exist $\\alpha,q\\in\\mathbb{Z}$ such that $a\\alpha-b=nq$. this implies that $b=a\\alpha-nq\\rightarrow d|b$ because $d|a\\alpha$ and $d|nq$\n\n\nassume $d|b$. then $b=d\\beta$ for some $\\beta\\in\\mathbb{Z}$\n\\begin{align*}\n  b=(as+nt)\\beta, s,t\\in\\mathbb{Z}\\\\\n  as\\beta\\equiv b\\mod n\\rightarrow s\\beta\\text{ is a solution}\n\\end{align*}\n\nassume $d|b$, let $m=\\frac{n}{d}$. claim $\\alpha$ solution $\\rightarrow\\alpha+km$ solution for all $k\\in\\mathbb{Z}$.\n\\subsubsection*{proof of claim}\n$\\alpha$ solution$\\Rightarrow a\\alpha\\equiv b\\mod n$ but $a(\\alpha+km)=a\\alpha+akm$ and $akm=ak\\frac{n}{d}=n\\frac{a}{d}k\\in\\mathbb{Z}$ so $akm\\equiv a\\alpha\\equiv b \\mod n$\n\nto finish we need to prove the following:\n\nif $\\alpha,\\beta$  are solutions then $\\beta-\\alpha$ is a multiple of m.\n\\begin{align*}\n  a\\alpha\\equiv b\\mod n\\\\\n  a\\beta\\equiv b\\mod n\\\\\n  a\\alpha \\equiv a\\beta\\mod n\\\\\n  n|a(\\beta-\\alpha)\\\\\n  n=md\\\\\n  md|a(\\beta-\\alpha)\\\\\n  a=a'd\\\\\n  md|a'd(\\beta-\\alpha)\\\\\n  m|a'(\\beta-\\alpha)\n\\end{align*}\nif we know that gcd of $m$ and $a'$ is one then $m|(\\beta-\\alpha)$. we know it is because $md=n$  and $a=a'd$ and d is gcd of $a,n$ so if there were another divisor then d wouldn't be the gcd, it would be pd.\n\n\\section*{chinese remainder theorem}\n$m,n\\in\\mathbb{Z}^+$ then the system $x\\equiv a\\mod n, x\\equiv b\\mod m$ has an integer solution iff m and n are relatively prime. moreover, any two solutions are congruent modulo mn.\n\n\\subsection*{proof}\nm,n are relatively prime, write $m\\alpha+\\beta n=1$, let $x=a\\alpha m+b\\beta n$ then $x\\equiv a\\alpha m\\equiv a\\mod n$ because $\\alpha m$ is congruent to 1. and $x\\equiv b\\beta n\\equiv b\\mod m$\n\\section*{exercises}\nsecond part of chinese remainder theorem\n\\end{document}\n", "meta": {"hexsha": "2ccff7cfb6bc3c9fcab633e057cef3b13a6e97af", "size": 3554, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "abstract algebra/abstract-notes-2014-09-05.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "abstract algebra/abstract-notes-2014-09-05.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "abstract algebra/abstract-notes-2014-09-05.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5048543689, "max_line_length": 274, "alphanum_fraction": 0.6454698931, "num_tokens": 1459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.4221829268223917}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 05/10/21\n\n\\begin{thm}\n\tLet \\(K / \\mathbb{F}_p\\) be a field extension of the prime subfield \\(\\mathbb{F}_p\\).\n\t\\begin{itemize}\n\t\t\\item If \\(K\\) is finite, then \\(\\left| K \\right| = p^{n}\\) for some positive integer \\(n\\).\n\t\t\\item \\(\\left| K \\right| = p^{n}\\) if and only if \\(K\\) is the splitting field of \\(x^{p^{n}}-x\\) over \\(\\mathbb{F}_p\\).\n\t\\end{itemize}\n\tBy the uniqueness of splitting fields, we can simply denote \\(K\\) by \\(\\mathbb{F}_{p^{n}}\\).\n\\end{thm}\nThis theorem gives us a complete characterization of finite fields. The first part is proven in Dummitt-Foote 13.2 \\#1.\n\n\\begin{cor}\n\tFor all prime \\(p\\), for all \\(n \\in \\Z_+\\), there exists a field of cardinality \\(p^{n}\\). Furthermore, any two finite fields of the same cardinality are isomorphic.\n\\end{cor}\n\n\\section{Simple Extensions}\n\\label{sec:simple_extensions}\n\n\\begin{thm}\n\tIf \\(\\left| F \\right| < \\infty\\), and \\(K / F\\) is a finite extension of \\(F\\), then \\(K = F(\\alpha )\\) for some \\(\\alpha  \\in K\\).\t\n\\end{thm}\n\nThis holds because \\(K^{\\times }\\) is a cyclic group, and so there must exist \\(\\alpha \\) so \\(\\langle \\alpha  \\rangle = K^{\\times }\\), and hence \\(K = F(\\alpha )\\).\n\n\\begin{thm}\n\tIf \\(F\\) is an infinite field, and \\(K / F\\) is a finite separable extension, then \\(K = F(\\alpha )\\) for some \\(\\alpha  \\in K\\).\n\\end{thm}\nEvery field extension can be written by appending a sequence of elements, and we can reduce the elements to one by the combination \\(\\alpha  = \\beta + \\gamma  \\delta \\), where \\((\\beta ,\\gamma )\\) is the two additional elements, and \\(\\delta \\neq \\frac{\\beta_i - \\beta }{\\gamma  - \\gamma_j}\\). Often we can simply choose \\(\\delta =1\\) if we are lucky.\n\n\\end{document}\n", "meta": {"hexsha": "2a382ba4e4a0204a2206b6907ecbbb7c56994785", "size": 2136, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture24 - Finite_Fields_Simple_Extensions.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture24 - Finite_Fields_Simple_Extensions.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture24 - Finite_Fields_Simple_Extensions.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.72, "max_line_length": 351, "alphanum_fraction": 0.6676029963, "num_tokens": 681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.4221162342510207}}
{"text": "\\section{Estimating the Footprints of Conferences}\n\\label{sec:footprint}\n\n{\\em Carbon footprint} is the key metric that we ultimately seek to reduce\nand hence also the starting point of our analysis.  We introduce in this\nsection the methodology we used and tool we built to conduct all of our\nanalyses, and we describe the first results from our dataset.\n\n\\subsection{Methodology for Evaluating Carbon Footprint}\n\\label{sec:methodo}\n\nWe conduct all our analyses through a \\python{} script,\\footnote{Publicly available at\n  \\url{https://github.com/YaZko/sigplan-carbon-analysis}} described in more detail in Section~\\ref{sec:software}.\n%\nThroughout, we make the following assumptions:\n\\begin{itemize}\n\\item we assume that participant travel accounts for the entire carbon\nfootprint of a conference;\n\\item we assume that {all} conference participants travel by plane, in economy\nclass;\n\\item we assume that the airports in the conference city and in each\nparticipant's home city are close enough to the actual end points of their\ntravel for their locations to be assimilated;\n\\item we assume that all flights are direct;\n\\item we assume that the geodesic distance is the one taken by planes.\n\\end{itemize}\nEstimating the errors introduced by these assumptions and refining the\nanalysis to make more realistic assumptions would obviously be very\nworthwhile.\n%\nBut, for this first effort, we are mainly aiming to get a\n{\\em relative} evaluation of different potential strategies for reducing\nfootprints; for this purpose, we believe these assumptions are good enough.\n\nThe distance traveled by each participant is converted to an amount of\nemissions expressed in \\gaz. To do this conversion, we use a standard model\nintroduced as part of the \\texttt{DEFRA 16} report on Greenhouse gas\n\\footnote{\\url{https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2016}}\n\\footnote{\\url{https://co2calculator.acm.org/methodology.pdf}} conducted by\nthe British Government.\n\nThe model distinguishes three classes of flight, depending on their length\n(short, medium, or long haul). Each class is associated with a linear\ncoefficient relating the distance of travel to the amount of \\gaz{}\nemitted.\n\nA second linear coefficient, identical for all flights, is the so-called\n\\emph{radiative forcing index}; this is used to account for the difference\nin radiative forcing between the same emissions at ground level compared to\nhigh in the atmosphere.  We use the value $1.891$ for this coefficient, as\nsuggested by R. Sausen et al.~\\cite{Sausen05}\n\nWe thus obtain the following piecewise-linear model of emissions for a\nflight covering $d$ kms:\n\n\\begin{center}\n\\gazunit \\quad=\\quad\n\\begin{tabular}{@{}lll}\n$1.891 * 0.14735 * d$ & if $d < 785$ \\\\\n$1.891 * 0.08728 * d$ & if $785 \\leq d < 3700$ \\\\\n$1.891 * 0.077610 * d$ & if $3700\\leq d  $\n\\end{tabular}\n\\end{center}\n% \\begin{itemize}\n% \\item $1.8& * 0.14735 * d$ \\gazunit if $d < 785$\n% \\item $1.891 * 0.08728 * d$ \\gazunit if $785 \\leq d < 3700$\n% \\item $1.891 * 0.077610 * d$ \\gazunit if $3700\\leq d  $\n% \\end{itemize}\n\n%% It should be noted that experiments with other models show significant variance\n%% in absolute value, but resilience in relative values.\\bcp{Maybe worth\n%%   showing some numbers justifying these statements?}\\yz{I agree, will\n%%   do}\\bcp{Assuming that we can get our numbers to agree with CoolEffect's,\n%%   we could also mention this!} Once again, refining the\n%% model would hence be a valuable work, but using this simple standard and\n%% well-established one appears appropriate to draw conclusion in terms of\n%% \\emph{relative} impact of different measures.\n\n%% This first pass of the script therefore give us an estimation of the footprint\n%% of our conferences. We have implemented on top of it several analyses aiming to\n%% estimate the correlation some concrete factors upon which conference organizers\n%% can act may have with this footprint.\n%% The description of these analyses will cover Section~\\ref{sec:community} to \\ref{sec:speculate}.\n\n\\subsection{Conference Footprints}\n\n\n\\begin{table}\n  \\centering\n  \\csvreader[%\n    head to column names,\n    tabular={|l|l|c|c|c|},\n    table head=\\hline \\bfseries Event & \\bfseries Location & \\bfseries \\# Participants & \\bfseries Total footprint & \\bfseries Average footprint\\\\\\hline,\n    late after line=\\\\,\n    table foot = \\hline,\n  ]{../../output/sigplan/footprint_confs.csv}{}{%\n    \\conf\\ \\year & \\location & \\csvcoliv & \\csvcolv & \\csvcolvi\n  }\n  \\caption{For each \\event: location, number of participants and carbon footprint,\n    total and average per participant, in \\gazunitbis. }\n  \\label{table:footprint}\n\\end{table}\n\nWe now turn to the estimation of footprints in our dataset.\nTable~\\ref{table:footprint} depicts the total and average carbon footprint per participant of\nall conferences analyzed. This footprint is estimated in terms of \\gazunitbis{}\n(metric tons of CO$_2$-equivalent) of emissions.\n\nThe main figure of interest is arguably the last column, depicting the\naverage footprint per participant.  The lowest average per-participant footprint of\nour dataset are tied ICFP'12 and ICFP'14 at 0.88\\gazunitbis, while the\nhighest one is ICFP'16 at 1.93\\gazunitbis.\n\n\\begin{obs}\nThe average per-participant carbon footprint due to air travel varies across\nconferences in our dataset by around a factor of 2.\n\\label{obs:footprint}\n\\end{obs}\n", "meta": {"hexsha": "e58d82ebfff7377c5ed45addbf96ffde6bd3a202", "size": 5400, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/sigplan_climate/footprint.tex", "max_stars_repo_name": "YaZko/sigplan-carbon-analysis", "max_stars_repo_head_hexsha": "92eaefd046da9b79ee5a0436c51327a3149c1717", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-11-08T13:53:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-13T18:58:39.000Z", "max_issues_repo_path": "paper/sigplan_climate/footprint.tex", "max_issues_repo_name": "YaZko/sigplan-carbon-analysis", "max_issues_repo_head_hexsha": "92eaefd046da9b79ee5a0436c51327a3149c1717", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2020-02-04T10:37:01.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-14T08:32:18.000Z", "max_forks_repo_path": "paper/sigplan_climate/footprint.tex", "max_forks_repo_name": "YaZko/sigplan-carbon-analysis", "max_forks_repo_head_hexsha": "92eaefd046da9b79ee5a0436c51327a3149c1717", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-05T13:31:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-05T13:31:54.000Z", "avg_line_length": 45.3781512605, "max_line_length": 153, "alphanum_fraction": 0.7633333333, "num_tokens": 1410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553656, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.42211623425102063}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{Relationship between logD, logP and p$K_a$}\n\\author{Dhiman Ray}\n\\date{\\today}\n\n\\usepackage{natbib}\n\\usepackage{graphicx}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Derivation for monoprotic acid/base}\nIonization of a solute \n\\begin{equation}\n    X + H^+ \\rightleftharpoons XH^+\n\\end{equation}\nPartition coefficients\n\\begin{equation}\n    P^0 = \\frac{[X]_{octanol}}{[X]_{water}}, \\;\\;\\;\\; \n    P^1 = \\frac{[XH^+]_{octanol}}{[XH^+]_{water}}, \\;\\;\\;\\;\n    D = \\frac{[X]_{octanol} + [XH^+]_{octanol}}{[X]_{water} + [XH^+]_{water}}\n\\end{equation}\nUsing this equation we can write\n\\begin{equation}\n    D = \\frac{P^0[X]_{water} + P^1[XH^+]_{water}}{[X]_{water} + [XH^+]_{water}}\n    \\label{eqn:D}\n\\end{equation}\nFrom Henderson Equation\n\\begin{equation}\n    pH = pK_a + \\log \\left(\\frac{[X]_{water}}{[XH^+]_{water}}\\right)\n\\end{equation}\nwe can write \n\\begin{equation}\n    [X]_{water} = [XH^+]_{water} \\times 10^{pH - pK_a} = [XH^+]_{water} \\frac{10^{- pK_a}}{10^{-pH}} = [XH^+]_{water} \\frac{K_a}{[H]}\n\\end{equation}\nSubstituting in Eq. \\ref{eqn:D}\n\\begin{equation}\n    D = \\frac{P^0 [XH^+]_{water} \\frac{K_a}{[H]} + P^1[XH^+]_{water}}{[XH^+]_{water} \\frac{K_a}{[H]} + [XH^+]_{water}}\n\\end{equation}\nCanceling out the $[XH^+]_{water}$ and rearranging\n\\begin{equation}\n    D = \\frac{P^0 K_a + P^1 [H]}{K_a + [H]}\n    \\label{eqn:Dexact}\n\\end{equation}\nThis is the equation which accurately represents the relation between logD, log$P^0$, log$P^1$ and $pK_a$, if we use the relation $K_a = 10^{- pK_a}$ and $[H] = 10^{- pH}$\n\n\\section{Approximation}\nIf we assume that the charged species never goes into octanol phase we can derive simple approximate relations between logP and logD. \n\\subsection{Weak Acid}\nFor weak acids $X$ is ionized and $XH^+$ is neutral. So we can consider $P^0 = 0$ and $P = P^1$. So Eq. \\ref{eqn:Dexact} becomes\n\\begin{equation}\n    D = \\frac{P^1 [H]}{K_a + [H]}\n\\end{equation}\nRearranging\n\\begin{equation}\n    \\frac{D}{P} = \\frac{1}{1+\\frac{K_a}{[H]}} \\;\\;\\; => \\;\\;\\; \\log D = \\log P - \\log(1+10^{pH-pK_a})\n\\end{equation}\n\\subsection{Weak Base}\nFor weak base $XH^+$ is ionized and $X$ is neutral. So we can consider $P^1 = 0$ and $P = P^0$. So Eq. \\ref{eqn:Dexact} becomes\n\\begin{equation}\n    D = \\frac{P^0 K_a}{K_a + [H]}\n\\end{equation}\nRearranging\n\\begin{equation}\n    \\frac{D}{P} = \\frac{1}{1+\\frac{[H]}{K_a}} \\;\\;\\; => \\;\\;\\; \\log D = \\log P - \\log(1+10^{pK_a-pH})\n\\end{equation}\n\\subsection{Limitations of the approximation}\nThis approximation will break down at high pH for weak acids and at low pH for weak base. In that situation a large fraction of the base/acid will be in ionized form. Although the partition coefficient for ionic species is low, some ions will still enter the octanol phase. In that case this approximation will break down and we need to use the Eq. \\ref{eqn:Dexact} to calculate logD.\n%\\bibliographystyle{plain}\n%\\bibliography{references}\n\\end{document}\n", "meta": {"hexsha": "e3bb22b332c0cb16820e1ac1de87933bbf7ce921", "size": 2958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "physical_property/logD/theory/logD_logP_pKa.tex", "max_stars_repo_name": "samplchallenges/SAMPL7", "max_stars_repo_head_hexsha": "1feed16ed8502a3519559fbdcc23812f21c64be1", "max_stars_repo_licenses": ["CC-BY-4.0", "MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-10-23T17:59:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T18:42:14.000Z", "max_issues_repo_path": "physical_property/logD/theory/logD_logP_pKa.tex", "max_issues_repo_name": "samplchallenges/SAMPL7", "max_issues_repo_head_hexsha": "1feed16ed8502a3519559fbdcc23812f21c64be1", "max_issues_repo_licenses": ["CC-BY-4.0", "MIT"], "max_issues_count": 39, "max_issues_repo_issues_event_min_datetime": "2019-10-16T18:42:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-05T23:28:04.000Z", "max_forks_repo_path": "physical_property/logD/theory/logD_logP_pKa.tex", "max_forks_repo_name": "samplchallenges/SAMPL7", "max_forks_repo_head_hexsha": "1feed16ed8502a3519559fbdcc23812f21c64be1", "max_forks_repo_licenses": ["CC-BY-4.0", "MIT"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2019-10-07T08:47:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T14:15:07.000Z", "avg_line_length": 39.44, "max_line_length": 384, "alphanum_fraction": 0.6565246788, "num_tokens": 1113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.42211623363916945}}
{"text": "\\documentclass[11pt, oneside]{article}\n\n\\usepackage{../shared/preamble}\n\\addbibresource{../shared/references.bib}\n\n\\usepackage{proofs}\n\n\\title{Proofs}\n\\author{Arthur Ryman, {\\tt arthur.ryman@gmail.com}}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThis article is a Z Notation specification for proofs and proof checking.\nIt has been type checked by \\fuzz.\nThe definitions that appear here are taken from Lemmon's book, {\\it Beginning Logic}.\nThe purpose of this specification is to guide the development of a proof checker\naimed at Z specifications\n\\end{abstract}\n\n\\section{Introduction}\n\nFor a long time I have thought that it would be extremely useful to be able to write formal proofs\nconcerning the mathematical objects defined in Z specifications.\nThere are some very mature proof assistants available.\nI know something about Coq, but unfortunately it's style of proof is very different from that one finds in mathematical\npapers.\n\nA Coq proof consists of applications of so-called {\\it tactics}.\nEach tactic represents a higher level aggregate of deductions.\nThis makes sense for a proof assistant since its job is to help the user discover proofs.\nTactics are like macros and as such they alleviate the user from much low-level tedium.\nHowever, the analog of a macro in normal mathematical writing is a lemma.\nPerhaps tactics are more useful for proving formal properties of programming languages where the mathematical\nobjects of interest are complex, but finite, recursive structures.\n\nWhile a proof assistant might make sense is some contexts, proper development of a mathematical paper\nconsists of a gradual introduction of concepts and lemmas leading to the main results.\nThe proofs should, in some sense, write themselves.\nThe focus of a mathematical paper should be on explanation and clarity.\nThe proofs should be easy to read.\nI'd therefore really like something that would let me write and check natural looking proofs.\n\nIn contrast to Coq, the style of proof presented by Lemmon is very clear and explicit.\nHowever, the task of checking such a proof could easily be delegated to a program,\nmuch the same way that \\fuzz\\ type checks Z.\nIn fact Lemmon makes that point that, although there is no mechanical way to discover proofs,\nthey can be mechanically checked.\n\nI believe that the kernel of a proof checker could be very small.\nIt is basically an engine driven by a set of deduction rules.\nThe engine simply needs to check that each deduction rule gets applied correctly.\nEven if it turns out that writing such an engine is too much work, the exercise of developing\nat least a simple version should give me a greater appreciation of tools like Coq and enable me to\nuse them more productively.\n\nMy plan of attack is to formalize the concept of proof as described by Lemmon, starting with\nthe propositional calculus, and then move on to predicate calculus.\n\n\\section{Propositions}\n\nThe {\\it propositional calculus} defines a set of formal {\\it statements} or {\\it propositions}\nwithout being concerned about the subject matter described by those statements.\nThe only restriction on these statements is that, in any given context, \nthey possess a {\\it truth value} of either {\\it true} or {\\it false}.\n\nA proposition is also referred to as a {\\it well-formed formula} or {\\it wff} for short.\nThis terminology stems from the traditional development of the propositional calculus in terms of\na language of sentences over an alphabet with rules that prescribe when a given sentence is {\\it well-formed}.\nHowever, here we will dispense with the language viewpoint, and its associated parsing issues, and move directly\nto the end result of parsing, namely the creation of {\\it abstract syntax trees} or {\\it ASTs} for short.\nThis approach corresponds to Lemmon's Chapter 1.\nHe returns to the issue of formal languages in Chapter 2.\n\n\\subsection{$Prop$}\n\n\nZ notation has a convenient mechanism for specifying the structure of ASTs, namely that of {\\it free types}.\nMy first impulse was to use that mechanism to define propositions.\nHowever, the problem with free types is that they are {it closed} in the sense that all ways of constructing members of a free type\nmust be specified when the free type is defined.\nLemmon's book gradually introduces ways of constructing propositions, so in the interest of following his development of the subject\nas closely as possible, I won't define propositions that way.\n\nOn closer examination of free types in Z, it will be observed that they are merely syntactic sugar for introducing a new given set\nalong with an exhaustive set of constructors for its elements.\nThe constraint expressing the condition that the constructors are exhaustive is equivalent to saying that the domains of the constructors\npartition the set of propositions.\n\nTherefore, given any subset of constructors, one can define the corresponding set of propositions that can be constructed from them.\nThis allows new constructors to be gradually introduced.\nI'll take that approach.\n\nLet $Prop$ denote the set of all propositions.\n\n\\begin{zed}\n\t[Prop]\n\\end{zed}\n\n\\subsection{$PropVar$}\n\nSeparating of the form of a statement from its content with respect to any given subject matter is accomplished by \nthe use of {\\it propositional variables}. \nA propositional variable stands for an arbitrary statement that is either true or false.\nLet $PropVar$ denote the set of all propositional variables.\n\n\\begin{axdef}\n\tPropVar: \\power Prop\n\\end{axdef}\n\n\\subsection{\\zcmd{propP}, \\zcmd{propQ}, \\zcmd{propR}, \\zcmd{propS}, and \\zcmd{propT}}\n\nTraditionally, arbitrary statements are represented by single letters such as\n$\\propP$, $\\propQ$, $\\propR$, $\\propS$, and $\\propT$ which represent distinct propositions.\n\n\\begin{axdef}\n\t\\propP, \\propQ, \\propR, \\propS, \\propT: PropVar\n\\where\n\t\\disjoint \\langle \\{\\propP\\}, \\{\\propQ\\}, \\{\\propR\\}, \\{\\propS\\}, \\{\\propT\\} \\rangle\n\\end{axdef}\n\n\\subsection{$PropLetter$}\n\nLet $PropLetter$ denote the set of all proposition letters.\n\n\\begin{zed}\n\tPropLetter == \\{ \\propP, \\propQ, \\propR, \\propS, \\propT \\}\n\\end{zed}\n\n\\subsection{\\zcmd{propPrime}}\n\nTypical propositions contain a small number of distinct statements, in which case the letters can be used.\nIf more statements occur then the letters are decorated with one or more primes, \ne.g. $\\propP \\propPrime$, $\\propQ \\propPrime \\propPrime$.\nAppending a prime to a propositional variable is an injection from $PropVar$ to $PropVar$.\n\n\\begin{axdef}\n\t\\_ \\propPrime: PropVar \\inj PropVar\n\\end{axdef}\n\n\\begin{example}\n$\\propP \\propPrime$ and $\\propQ \\propPrime \\propPrime$ are propositional variables.\n\\begin{zed}\n\t\\propP \\propPrime \\in PropVar\n\\also\n\t\\propQ \\propPrime \\propPrime \\in PropVar\n\\end{zed}\n\n\\end{example}\n\nA propositional variable is either a letter or is primed.\n\n\\begin{zed}\n\t\\langle PropLetter, \\ran (\\_ \\propPrime) \\rangle \\partition PropVar\n\\end{zed}\n\n\\subsection{\\zcmd{notProp} and $Negation$}\n\nLet $A$ be a proposition.\nLet $\\notProp A$ denote the {\\it negation} of $A$.\n\n\\begin{axdef}\n\t\\notProp: Prop \\inj Prop\n\\end{axdef}\n\n\\begin{example}\n$\\notProp \\propP$ is a negation.\n\n\\begin{zed}\n\t\\notProp \\propP \\in Prop\n\\end{zed}\n\n\\end{example}\n\nLet $Negation$ denote the set of all negations.\n\n\\begin{zed}\n\tNegation == \\ran \\notProp\n\\end{zed}\n\n\\subsection{\\zcmd{andProp} and $Conjunction$}\n\nLet $A$ and $B$ be propositions.\nLet $A \\andProp B$ denote the {\\it conjunction} of $A$ and $B$.\nThe conjunction $A \\andProp B$ is said to have $A$ and $B$ as its {\\it conjuncts}.\n\n\\begin{axdef}\n\t\\_ \\andProp \\_: Prop \\cross Prop \\inj Prop\n\\end{axdef}\n\nLet $Conjunction$ denote the set of all conjunctions.\n\n\\begin{zed}\n\tConjunction == \\ran (\\_ \\andProp \\_)\n\\end{zed}\n\n\\subsection{\\zcmd{orProp} and $Disjunction$}\n\nLet $A$ and $B$ be propositions.\nLet $A \\orProp B$ denote the {\\it disjunction} of $A$ and $B$.\nThe disjunction $A \\orProp B$ is said to have $A$ and $B$ as its {\\it disjuncts}.\n\n\\begin{axdef}\n\t\\_ \\orProp \\_: Prop \\cross Prop \\inj Prop\n\\end{axdef}\n\nLet $Disjunction$ denote the set of all disjunctions.\n\n\\begin{zed}\n\tDisjunction == \\ran (\\_ \\orProp \\_)\n\\end{zed}\n\n\\subsection{\\zcmd{impliesProp} and $Conditional$}\n\nLet $A$ and $B$ be propositions.\nLet $A \\impliesProp B$ denote the {\\it conditional} of $A$ and $B$.\nThe conditional $A \\impliesProp B$ is said to have $A$ as its  {\\it antecedent} and $B$ as its {\\it consequent}.\n\n\\begin{axdef}\n\t\\_ \\impliesProp \\_: Prop \\cross Prop \\inj Prop\n\\end{axdef}\n\nLet $Conditional$ denote the set of all conditionals.\n\n\\begin{zed}\n\tConditional == \\ran (\\_ \\impliesProp \\_)\n\\end{zed}\n\n\\subsection{\\zcmd{equivProp} and $Biconditional$}\n\nLet $A$ and $B$ be propositions.\nLet $A \\equivProp B$ denote the {\\it biconditional} of $A$ and $B$.\n\n\\begin{axdef}\n\t\\_ \\equivProp \\_: Prop \\cross Prop \\inj Prop\n\\where\n\t\\forall A, B: Prop @ \\\\\n\t\\t1\tA \\equivProp B = (A \\impliesProp B) \\andProp (B \\impliesProp A)\n\\end{axdef}\n\nLet $Biconditional$ denote the set of all biconditionals.\n\n\\begin{zed}\n\tBiconditional == \\ran (\\_ \\equivProp \\_)\n\\end{zed}\n\n\\section{Proofs}\n\nLemmon has a nice way of presenting proofs.\nHere's an example.\n\n\\vspace{1ex}\n\n$\\mathbf{1}\\ \\propP \\impliesProp \\propQ, \\propP \\vdash \\propQ$\n\n\\vspace{1ex}\n\n\\begin{tabular}{l l r l l}\n&\t1\t&\t(1)\t&\t$\\propP \\impliesProp \\propQ$\t&\t$\\ruleA$ \\\\\n&\t2\t&\t(2)\t&\t$\\propP$\t\t\t\t\t&\t$\\ruleA$ \\\\\n&\t1,2\t&\t(3)\t&\t$\\propQ$\t\t\t\t\t&\t1,2 $\\ruleMPP$\n\\end{tabular}\n\n\\vspace{1ex}\n\nA proof consists of a {\\it sequent} to be proved and a finite sequence of one or more {\\it lines}.\nThe lines are labelled by consecutive natural numbers, starting at $1$.\n\nThe sequent contains a, possible empty, sequence of assumptions followed by a conclusion.\nThe sequence of lines that follow show how the conclusion is derived from the assumptions using\nvarious rules of derivation.\n\nEach line of the argument contains an inference.\n\nEach line contains a proposition and the application of the {\\it proof rule} used to add it to the proof. \nA proof rule is either an {\\it assumption} or a {\\it derivation}.\nThe {\\it rule of assumption} allows the addition of any proposition.\nThe {\\it rules of derivation} allow the addition of a {\\it conclusion} derived from {\\it premises} that have been\npreviously added.\nA premise is therefore either an assumption or the conclusion of a previous deduction.\nEvery line of the proof can therefore be traced back to a finite, possibly empty, set of assumptions upon\nwhich it ultimately {\\it depends}.\n\n\\subsection{$Sequent$ and \\zcmd{sequent}}\n\nA {\\it sequent} consists of a sequence of assumptions and a conclusion.\nLet $Sequent$ denote the set of all sequents.\n\n\\begin{schema}{Sequent}\n\tassumptions: \\seq Prop \\\\\n\tconclusion: Prop\n\\end{schema}\n\nLet $\\sequent$ denote the binary operator that takes assumptions and a conclusion and forms a sequent.\n\n\\begin{axdef}\n\t\\_ \\sequent \\_: \\seq Prop \\cross Prop \\fun Sequent\n\\where\n\t\\forall Sequent @ \\\\\n\t\\t1\tassumptions \\sequent conclusion = \\theta Sequent\n\\end{axdef}\n\n\\subsection{$RuleOfDerivation$}\n\nLet $RuleOfDerivation$ denote the set of applications of rules of derviation.\nIn the preceeding example, $\\ruleA$ and $\\ruleMPP$ are names of rules of derivation.\n\n\\begin{zed}\n\t[RuleOfDerivation]\n\\end{zed}\n\n\\subsection{$Deduction$}\n\nA {\\it deduction} consists of a proposition, an application of a rule of derivation that justifies the proposition,\nand a finite, possibly empty, set of assumptions on which the proposition depends.\nLet $Deduction$ denote the set of all deduction.\n\n\\begin{schema}{Deduction}\n\tassumptions: \\finset \\nat_1 \\\\\n\tprop: Prop \\\\\n\trule: RuleOfDerivation\n\\end{schema}\n\n\\subsection{$DeductionTuple$}\n\nLet $DeductionTuple$ denote the tuple formed by the components of a deduction.\n\n\\begin{zed}\n\tDeductionTuple == \\finset \\nat_1 \\cross Prop \\cross RuleOfDerivation\n\\end{zed}\n\n\\subsection{\\zcmd{deductionTuple}}\n\nLet $\\deductionTuple$ denote the function that maps a deduction to its tuple.\n\n\\begin{zed}\n\t\\deductionTuple == (\\lambda Deduction @ (assumptions, prop, rule))\n\\end{zed}\n\n\\begin{remark}\nThe mapping from deductions to tuples is a bijection.\n\n\\begin{zed}\n\t\\deductionTuple \\in Deduction \\bij DeductionTuple\n\\end{zed}\n\n\\end{remark}\n\n\\subsection{\\zcmd{deductionProp}}\n\nLet $\\deductionProp$ denote the function that maps a deduction tuple to its $prop$ component.\n\n\\begin{zed}\n\t\\deductionProp == \\{~ Deduction @ (assumptions, prop, rule) \\mapsto prop ~\\}\n\\end{zed}\n\n\\subsection{$Argument$}\n\nAn {\\it argument} is a finite sequence of deductions.\nLet $Argument$ denote the set of all arguments.\n\n\\begin{zed}\n\tArgument == \\seq DeductionTuple\n\\end{zed}\n\n\\subsection{$ArgumentDeduction$}\n\nWhen determining the soundness of an argument, we need to check of the soundness of each deduction.\nEach deduction within an argument is uniquely identified by its line number.\nLet $ArgumentDeduction$ denote the set of all arguments and valid line numbers in them.\n\n\\begin{schema}{ArgumentDeduction}\n\targument: Argument \\\\\n\tlineNumber: \\nat_1 \\\\\n\tDeduction\n\\where\n\tlineNumber \\in \\dom argument\n\\also\n\targument(lineNumber) = (assumptions, prop, rule)\n\\end{schema}\n\\begin{itemize}\n\t\\item The deduction is identified by its line number within the argument.\n\t\\item The deduction has a tuple of components.\n\\end{itemize}\n\n\\subsection{$SoundDeduction$}\n\nA deduction within an argument is sound if it adheres to one of the rules of derivation.\nThe rules of derivation will be described below.\nLet $SoundDeduction$ denote the set of all sound deductions.\n\n\\begin{axdef}\n\tSoundDeduction: \\power ArgumentDeduction\n\\end{axdef}\n\n\\subsection{$SoundArgument$}\n\nAn argument is sound precisely when all of its deductions are sound.\nLet $SoundArgument$ denote the set of all sound arguments.\n\n\\begin{axdef}\n\tSoundArgument: \\power Argument\n\\end{axdef}\n\n\\subsection{\\zcmd{deductionSequent}}\n\nEvery deduction in an argument defines a sequent.\nLet $\\deductionSequent$ denote the mapping from deductions to sequents.\n\n\\begin{axdef}\n\t\\deductionSequent: ArgumentDeduction \\fun Sequent\n\\where\n\t\\forall ArgumentDeduction @ \\\\\n\t\\t1\t\\deductionSequent(\\theta ArgumentDeduction) = \\\\\n\t\\t2\t\tassumptions \\extract (argument \\comp \\deductionProp) \\sequent prop\n\\end{axdef}\n\n\\subsection{$ArgumentProvesSequent$}\n\nA sound argument proves a sequent if the final deduction of the argument defines the given sequent.\nLet $ArgumentProvesSequent$ denote this situation.\n\n\\begin{schema}{ArgumentProvesSequent}\n\tArgumentDeduction \\\\\n\ts: Sequent\n\\where\n\targument \\in SoundArgument\n\\also\n\tlineNumber = \\# argument\n\\also\n\ts = \\deductionSequent(\\theta ArgumentDeduction)\n\\end{schema}\n\n\\subsection{$Proof$}\n\nA proof is a sequent and a sound argument whose last deduction proves the sequent.\nLet $Proof$ denote the set of proofs.\n\n\\begin{axdef}\n\tProof: Sequent \\rel SoundArgument\n\\where\n\tProof = \\{~ ArgumentDeduction | \\\\\n\t\\t1\t(lineNumber = \\# argument \\land \\\\\n\t\\t1\targument \\in SoundArgument) @ \\\\\n\t\\t2\t\t\\deductionSequent(\\theta ArgumentDeduction) \\mapsto argument ~\\}\n\\end{axdef}\n\n\n\\subsection{\\zcmd{ruleA}}\n\nLet $\\ruleA$ denote the rule of assumption.\nThe rule of assumption is used to introduce an arbitrary assumption at any point in the argument.\n\n\\begin{axdef}\n\t\\ruleA: RuleOfDerivation\n\\end{axdef}\n\n\\subsection{$RuleOfAssumptionDetail$}\n\nA deduction uses the rule of assumption $\\ruleA$ in an argument is sound if it introduces some arbitrary proposition $P$ and\nit depends only on itself.\nLet $RuleOfAssumptionDetail$ denote the set of all deductions, along with their details, that use the rule of assumption soundly.\n\n\\begin{schema}{RuleOfAssumptionDetail}\n\tArgumentDeduction \\\\\n\tP: Prop\n\\where\n\tassumptions = \\{ lineNumber \\}\n\\also\n\tprop = P\n\\also\n\trule = \\ruleA\n\\end{schema}\n\n\\begin{itemize}\n\t\\item The deduction depends only on itself.\n\t\\item The deduction introduces an arbitrary proposition $P$.\n\t\\item The deduction is justified by the rule of assumption $\\ruleA$.\n\\end{itemize}\n\n\\subsection{$RuleOfAssumption$}\n\nLet $RuleOfAssumption$ denote the set of all deductions that use the rule of assumption with the detail hidden.\n\n\\begin{zed}\n\tRuleOfAssumption \\defs RuleOfAssumptionDetail \\project ArgumentDeduction\n\\end{zed}\n\nThe rule of assumption is sound.\n\n\\begin{zed}\n\tRuleOfAssumption \\subset SoundDeduction\n\\end{zed}\n\n\\subsection{\\zcmd{ruleMPP}}\n\nLet $\\ruleMPP$ denote the MPP rule.\nThe MPP rule is used to deduce the consequent of a conditional given its antecedent.\nThe rule specifies the conditional and antecedent as its premises.\n\n\\begin{axdef}\n\t\\ruleMPP: \\nat_1 \\cross \\nat_1 \\fun RuleOfDerivation\n\\end{axdef}\n\n\\subsection{$RuleOfMPPDetail$}\n\nA deduction that uses the rule $\\ruleMPP(i, j)$ in an argument is sound if $i$ and $j$ are lines\nthat precede it, the proposition on line $i$ is an implication, the proposition on line $j$ is the antecedent\nof the implication, the proposition of the proof line is the consequent of the implication,\nand the proof line's assumptions is the union of the assumptions of lines $i$ and $j$.\nLet $RuleOfMPPDetail$ denote the set of all deductions, along with their detail, that use the rule of MPP soundly.\n\n\\begin{schema}{RuleOfMPPDetail}\n\tArgumentDeduction \\\\\n\ti, j: \\nat_1 \\\\\n\tDeduction_1 \\\\\n\tDeduction_2 \\\\\n\tP, Q: Prop\n\\where\n\trule =  \\ruleMPP(i, j)\n\\also\n\ti < lineNumber \\land j < lineNumber\n\\also\n\targument(i) = (assumptions_1, P \\impliesProp Q, rule_1)\n\\also\n\targument(j) = (assumptions_2, P, rule_2)\n\\also\n\tassumptions = assumptions_1 \\cup assumptions_2\n\\also\n\tprop = Q\n\\end{schema}\n\n\\begin{itemize}\n\t\\item The rule of derivation is $\\ruleMPP$ which specifies the premise line numbers $i$ of a conditional and $j$ of its antecedent.\n\t\\item The line numbers of the conditional and its antecedent must precede the deduction in the argument.\n\t\\item Line number $i$ contains a conditional of the form $P \\impliesProp Q$.\n\t\\item Line number $j$ contains the antecedent $P$ of the conditional.\n\t\\item The deduction depends on the union of the assumptions that the premises depend on.\n\t\\item The deduction introduces the consequent $Q$ as the conclusion of the premises.\n\\end{itemize}\n\n\\subsection{$RuleOfMPP$}\n\nLet $RuleOfMPP$ denote the set of all deductions that use the rule of MPP with the detail hidden.\n\n\\begin{zed}\n\tRuleOfMPP \\defs RuleOfMPPDetail \\project ArgumentDeduction\n\\end{zed}\n\nThe rule of MPP is sound.\n\n\\begin{zed}\n\tRuleOfMPP \\subset SoundDeduction\n\\end{zed}\n\n\\subsection{$argument_1$}\n\nLet $argument_1$ denote the argument defined by proof $\\mathbf{1}$.\n\n\\begin{zed}\n\targument_1 == \\\\\n\t\\t1\t\\{ 1 \\mapsto (\\{ 1\\}, \\propP \\impliesProp \\propQ, \\ruleA), \\\\\n\t\\t1\t2 \\mapsto (\\{ 2 \\}, \\propP, \\ruleA), \\\\\n\t\\t1\t3 \\mapsto (\\{ 1, 2 \\}, \\propQ, \\ruleMPP(1,2)) \\}\n\\end{zed}\n\n\\begin{example}\n$argument_1$ is an argument.\n\n\\begin{zed}\n\targument_1 \\in Argument\n\\end{zed}\n\n\\end{example}\n\n\\begin{example}\nLine 3 of proof $\\mathbf{1}$ corresponds to the following deduction tuple.\n\n\\begin{zed}\n\t(\\{ 1, 2 \\}, \\propQ, \\ruleMPP(1,2)) \\in DeductionTuple\n\\end{zed}\n\n\\end{example}\n\n\\subsection{$proof_2$}\n\nHere is Lemmon's proof $\\mathbf{2}$.\n\n\\vspace{1ex}\n\n$\\mathbf{2}\\ \\notProp \\propQ \\impliesProp (\\notProp \\propP \\impliesProp \\propQ), \\notProp \\propQ \\vdash \\notProp \\propP \\impliesProp \\propQ$\n\n\\vspace{1ex}\n\n\\begin{tabular}{l l r l l}\n&\t1\t&\t(1)\t&\t$\\notProp \\propQ \\impliesProp (\\notProp \\propP \\impliesProp \\propQ)$\t&\t$\\ruleA$ \\\\\n&\t2\t&\t(2)\t&\t$\\notProp \\propQ$\t\t\t\t\t\t\t\t\t\t\t&\t$\\ruleA$ \\\\\n&\t1,2\t&\t(3)\t&\t$ \\notProp \\propP \\impliesProp \\propQ$\t\t\t\t\t\t\t&\t1,2 $\\ruleMPP$\n\\end{tabular}\n\n\\vspace{1ex}\n\nLet $sequent_2$ denote the sequent of this proof.\n\n\\begin{zed}\n\tsequent_2 == \\langle \\notProp \\propQ \\impliesProp (\\notProp \\propP \\impliesProp \\propQ),  \\notProp \\propQ \\rangle \\sequent \\notProp \\propP \\impliesProp \\propQ\n\\end{zed}\n\nLet $argument_2$ denote the argument of this proof.\n\n\\begin{zed}\n\targument_2 == \\\\\n\t\\t1\t\\{ 1 \\mapsto (\\{ 1\\}, \\notProp \\propQ \\impliesProp (\\notProp \\propP \\impliesProp \\propQ), \\ruleA), \\\\\n\t\\t1\t2 \\mapsto (\\{ 2 \\}, \\notProp \\propQ, \\ruleA), \\\\\n\t\\t1\t3 \\mapsto (\\{ 1, 2 \\}, \\notProp \\propP \\impliesProp \\propQ, \\ruleMPP(1,2)) \\}\n\\end{zed}\n\nLet $proof_2$ denote this proof.\n\n\\begin{zed}\n\tproof_2 ==  (sequent_2, argument_2)\n\\end{zed}\n\n\\begin{example}\n$proof_2$ is a proof.\n\n\\begin{zed}\n\tproof_2 \\in Proof\n\\end{zed}\n\n\\end{example}\n\n\\section{The Curry-Howard Correspondence}\n\nThe {\\it Curry-Howard Correspondence} is an interpretation of propositions and proofs in terms of types.\nTo each proposition there correspondences a type.\nThe inhabitants of the type that corresponds to a proposition are proofs of that proposition.\nThe logical connectives that build up propositions correspond to type constructors.\n\nTo illustrate the correspondence, consider the implication logical connective $P \\implies Q$.\nIt corresponds to the type constructor $P \\fun Q$.\nA proof $f$ of $P \\implies Q$ corresponds to a function that maps any proof of $P$ to some proof of $Q$.\n\nOf course, $P \\fun Q$ is not a type in Z. \nIt is a subset of the type $\\power(P \\cross Q)$.\nNevertheless, we'll press on and pretend that it is a Z type for now.\n\nThe rules of derivation correspond to the construction of a proof from assumptions.\nFor example the rule of MPP corresponds to function application.\nConsider $Proof_1$.\nIt corresponds to the following.\n\n\\begin{schema}{CHProof1}[P,Q]\n\tf: P \\fun Q \\\\\n\tx: P \\\\\n\ty: Q\n\\where\n\ty = f(x)\n\\end{schema}\n\n\\printbibliography\n\n\\end{document}", "meta": {"hexsha": "e83b0464783d2910f06c4d095f818a65ceb1a4c0", "size": 21260, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "specification/proofs/proofs.tex", "max_stars_repo_name": "agryman/lemmon", "max_stars_repo_head_hexsha": "b46c6b959bd1e03c9599b756fdce454c2de0ffa5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "specification/proofs/proofs.tex", "max_issues_repo_name": "agryman/lemmon", "max_issues_repo_head_hexsha": "b46c6b959bd1e03c9599b756fdce454c2de0ffa5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "specification/proofs/proofs.tex", "max_forks_repo_name": "agryman/lemmon", "max_forks_repo_head_hexsha": "b46c6b959bd1e03c9599b756fdce454c2de0ffa5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.9219219219, "max_line_length": 159, "alphanum_fraction": 0.7479303857, "num_tokens": 5927, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.42211623063088893}}
{"text": "\\subsubsection{Forward Bond}\n\\label{ss:forwardbond}\n\nA Forward Bond (or Bond Forward) is a contract that establishes an agreement to buy or sell (determined by\n\\lstinline!LongInForward!) an underlying bond at a future point in time (the {\\tt ForwardMaturityDate}) at an agreed\nprice (the settlement {\\tt Amount}).\n\nA T-Lock is a Forward Bond with a US Treasury Bond as underlying, whereas a J-Lock is a Forward Bond with a Japanese\nGovernment Bond as underlying. T-Locks can be specified in terms of a lock-in yield rather then a settlement\namount. The cash settlement amount is given by (bond yield at maturity - lock rate) x DV01 in this case.\n\nListing \\ref{lst:forward_bond} shows an example for a physically settled forward bond. Listing\n\\ref{lst:forward_bond_tlock} shows an example for a cash settled T-Lock transaction specified by a lock-in yield.\n\nA Forward Bond is set up using a {\\tt ForwardBondData} block as shown below and the trade type is\n\\emph{ForwardBond}. The specific elements are\n\n\\begin{itemize}\n   \\item BondData: A {\\tt BondData} block specifying the underlying bond as described in section~\\ref{ss:bond}. A long\n     position must be taken in the bond, i.e.~({\\tt Payer}) flag must be set to ({\\tt true}). The bond data block\n     contains an additional field for forward bonds\n     \\begin{itemize}\n     \\item IncomeCurveId: The benchmark curve to be used for compounding, this must match a name of a curve in the yield\n       curves or index curve block in {\\tt todaysmarket.xml}. It is optional to provide this curve. If left out the\n       market reference yield curve from {\\tt todaysmarket.xml} is used for compounding.\n     \\end{itemize}\n   \\item SettlementData: The entity defining the terms of settlement:\n   \\begin{itemize}\n       \\item ForwardMaturityDate: The date of maturity of the forward contract. \\\\\n         Allowable values: See \\lstinline!Date! in Table \\ref{tab:allow_stand_data}.\n       \\item Settlement [Optional]: Cash or Physical. Option, defaults to Physcial, except in case the settlement is\n         defined by LockRate, in which case it defaults to Cash. \\\\\n         Allowable values: Cash, Physical\n       \\item Amount [Optional]: The settlement amount (also called strike) transferred at forward maturity in return for\n         the bond (physical delivery) or a cash amount equal to the dirty price of the bond (cash settlement). This is\n         transferred from the party that is long to the party that is short (determined by \\lstinline!LongInForward!)\n         and cannot be a negative amount. It is assumed to be in the same currency as the underlying bond. Exactly one\n         of the fields Amount, LockRate must be given. \\\\\n         Allowable values: Any non-negative real number.\n       \\item LockRate [Optional]: The payoff is given by (yield at forward maturity - LockRate) x DV01 (LongInForward =\n         true). Exactly one of the fields Amount, LockRate must be given. In case the LockRate is given, the Settlement\n         must be set to Cash. If Settlement is not given, it defaults to Cash in this case. \\\\\n         Allowable values: Any non-negative real number.\n       \\item LockRateDayCounter [Optional]: The day counter w.r.t. which the lock rate is expressed. Optional, defaults to A360. \\\\\n         Allowable values: see table \\ref{tab:daycount}\n       \\item SettlementDirty [Optional]: A flag that determines whether the settlement amount {({\\tt Amount})} reflects\n         a clean (\\emph{false}) or dirty (\\emph{true}) price. In either case, the dirty amount is actually paid on the\n         forward maturity date, i.e. if SettlementDirty = \\emph{false}, the (forward) accruals are computed internally\n         and added to the given amount to get the actual settlement amount. Optional, defaults to true. \\\\\n         Allowable values: \\emph{true}, \\emph{false}\n   \\end{itemize}\n   \\item PremiumData: The entity defining the terms of a potential premium payment. This node is optional. If left out it is assumed that no premium is paid.\n   \\begin{itemize}\n       \\item Date: The date when a premium is paid. \\\\\n       Allowable values: See \\lstinline!Date! in Table \\ref{tab:allow_stand_data}.\n       \\item Amount: The amount transferred as a premium. This is transferred from the party that is long to the party\n         that is short (determined by \\lstinline!LongInForward!) and cannot be a negative amount. It is assumed to be in\n         the same currency as the underlying bond.\\\\\n       Allowable values: Any non-negative real number.\n   \\end{itemize}\n   \\item LongInForward: A flag that determines whether the forward contract is entered in long (\\emph{true}) or short\n     (\\emph{false}) position. \\\\\n       Allowable values: \\emph{true}, \\emph{false}\n \\end{itemize}\n\n\\begin{listing}[H]\n  \\begin{minted}[fontsize=\\small]{xml}\n   <ForwardBondData>\n     <BondData>\n      ...\n      <IncomeCurveId>BENCHMARKINCOME-EUR<IncomeCurveId>\n     </BondData>\n     <SettlementData>\n       <ForwardMaturityDate>20160808</ForwardMaturityDate>\n       <Settlement>Physcial</Settlement>\n       <ForwardSettlementDate>20160810</ForwardSettlementDate>\n       <Amount>1000000.00</Amount>\n       <SettlementDirty>true</SettlementDirty>\n     </SettlementData>\n     <PremiumData>\n       <Amount>1000.00</Amount>\n       <Date>20160808</Date>\n     </PremiumData>\n     <LongInForward>true</LongInForward>\n   </ForwardBondData>\n  \\end{minted}\n\\caption{Forward Bond Data}\n\\label{lst:forward_bond}\n\\end{listing}\n\n\\begin{listing}[H]\n   \\begin{minted}[fontsize=\\small]{xml}\n   <ForwardBondData>\n     <BondData>\n      ...\n     </BondData>\n     <SettlementData>\n       <ForwardMaturityDate>20160808</ForwardMaturityDate>\n       <ForwardSettlementDate>20160810</ForwardSettlementDate>\n       <LockRate>0.02365</LockRate>\n     </SettlementData>\n     <LongInForward>true</LongInForward>\n   </ForwardBondData>\n\\end{minted}\n\\caption{Forward Bond Date (T-Lock)}\n\\label{lst:forward_bond_tlock}\n\\end{listing}\n\nAs for the ordinary bond the forward bond pricing requires a recovery rate that can be specified in ORE per SecurityId.\n\n\\subsubsection*{Forward Bond - Pricing Engine configuration}\n\nThe configuration for the pricing engine of the forward bond is identical to the ordinary bond.%, cf.~Section~\\ref{BondEngineConfig}.\nThe pricing engine called by forward bond products is the {\\tt DiscountingForwardBondEngine}, see below for a configuration example.\n\n%\\hrule\\medskip\n   \\begin{minted}[fontsize=\\small]{xml}\n   <Product type=\"ForwardBond\">\n   <Model>DiscountedCashflows</Model>\n   <ModelParameters></ModelParameters>\n   <Engine>DiscountingForwardBondEngine</Engine>\n   <EngineParameters>\n    <Parameter name=\"TimestepPeriod\">3M</Parameter>\n   </EngineParameters>\n   </Product>\n   \\end{minted}\n%\\caption{Bond Data}\n", "meta": {"hexsha": "dba183d268788192908ef15178e784cb494c84fe", "size": 6770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/UserGuide/tradedata/forwardbond.tex", "max_stars_repo_name": "mrslezak/Engine", "max_stars_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 335, "max_stars_repo_stars_event_min_datetime": "2016-10-07T16:31:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T07:12:03.000Z", "max_issues_repo_path": "Docs/UserGuide/tradedata/forwardbond.tex", "max_issues_repo_name": "mrslezak/Engine", "max_issues_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-10-31T04:20:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T16:39:57.000Z", "max_forks_repo_path": "Docs/UserGuide/tradedata/forwardbond.tex", "max_forks_repo_name": "mrslezak/Engine", "max_forks_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 180, "max_forks_repo_forks_event_min_datetime": "2016-10-08T14:23:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T10:43:05.000Z", "avg_line_length": 52.890625, "max_line_length": 157, "alphanum_fraction": 0.723633678, "num_tokens": 1682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.42211622701075724}}
{"text": "\\documentclass[.\\jobname.tex]{subfiles}\n\\begin{document}\n\n\\chapter{Differential Evolution Pseudocodes}\n\n\\section{JADE Pseudocode}\n\\label{chap:pscode_jade}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FJADE}{JADE}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FJADE{$\\mathbf{X}_{g=0}$, $p$, $c$, $function$, $minError$, $maxFE$}}{\n\t\t$fValue_{g=0} \\gets function(\\mathbf{x}_{g=0})$\\;\n\t\t$\\mu_{CR} \\gets 0.5$\\;\n\t\t$\\mu_{F}  \\gets 0.5$\\;\n\t\t$A        \\gets \\emptyset$\\;\n\t\t\\While {$fe \\leq maxFE$}{\n\t\t\t$g \\gets g + 1$\\;\n\t\t\t$S_F \\gets \\emptyset$\\;\n\t\t\t$S_{CR} \\gets \\emptyset$\\; \n\t\t\t\\For {$i = 1$ to $NP$} {\n\t\t\t\t$F_i  \\gets randc_i(\\mu_{F},0.1)$\\;\n\t\t\t\t$v_i \\gets mutationCurrentToPBest1(\\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\\;\n\t\t\t\t\n\t\t\t\t$CR_i \\gets randn_i(\\mu_{CR},0.1)$\\;\n\t\t\t\t$u_i  \\gets crossoverBIN(\\mathbf{x}_{i,g}, v_i, CR_i)$\\;\n\t\t\t\t\n\t\t\t\t\\If {$function(\\mathbf{x}_{i,g}) \\geq function(\\mathbf{u}_{i,g})$} {\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets \\mathbf{x}_{i,g}$\\;\n\t\t\t\t}\n\t\t\t\t\\Else\n\t\t\t\t{\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets \\mathbf{u}_{i,g}$\\;\n\t\t\t\t\t$fValue_{i,g+1} \\gets function(\\mathbf{u}_{i,g})$\\;\n\t\t\t\t\t$\\mathbf{x}_{i,g} \\rightarrow \\mathbf{A}$\\;\n\t\t\t\t\t$CR_i \\rightarrow S_{CR}$\\;\n\t\t\t\t\t$F_i \\rightarrow S_F$\\;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\tcp{resize $A$ to size of $\\mathbf{x}_g$}\n\t\t\t\\If{$|A| > NP$} {\n\t\t\t\t$A \\gets A \\setminus A_{rand_i}$\n\t\t\t}\n\t\t\t$fe \\gets fe + size(\\mathbf{X})$\\;\n\t\t\t$\\mu_{CR} \\gets (1-c) \\cdot \\mu_{CR} + c \\cdot arithmeticMean(S_{CR})$\\;\n\t\t\t$\\mu_{F} \\gets (1-c) \\cdot \\mu_{F} + c \\cdot lehmerMean(S_{F})$\\;\n\t\t}\t\n\t}\n\t\\unterschrift{JADE Pseudocode}{}{}\n\t\\label{algo: jade}\n\\end{algorithm}\n\n\\section{SHADE Pseudocode}\n\\label{chap:pscode_shade}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FSHADE}{SHADE}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FSHADE{$\\mathbf{x}_{G=0}$, $p$, $H$, $function$, $minError$, $maxFE$}}{\n\t\t$M_{CR} \\gets 0.5 \\text{; } M_{F} \\gets 0.5 \\text{; } A \\gets \\emptyset \\text{; } G \\gets 0 \\text{; }k \\gets 1$\\;\n\t\t$fValue_{G=0} \\gets function(\\mathbf{x}_{G=0})$\\;\n\t\t\\While{termination condition not met}\n\t\t{\n\t\t\t$S_{CR} \\gets \\emptyset \\text{; } S_F \\gets \\emptyset$\\;   \n\t\t\t\\For{$i = 1$ to $N$}{\n\t\t\t\t$r_i \\gets rand_{int}(1,H)$\\;\n\t\t\t\t$CR_{i,G} \\gets randn_i(M_{CR,r_i},0.1) \\text{; }F_{i,G}  \\gets randc_i(M_{F,r_i},0.1)$\\;\n\t\t\t\t$v_i \\gets mutationCurrentToPBest1(\\mathbf{x}_{i,G}, A, fValue_G, F_i, p)$\\;\n\t\t\t\t$u_i  \\gets crossoverBIN(pop, v_i, CR)$\\;\n\t\t\t}\n\t\t\t\\For{$i = 1$ to $N$}{\n\t\t\t\t\\If{$function(u_{i,G}) \\leq function(x_{i,G})$} {\n\t\t\t\t\t$x_{i,G+1} \\gets u_{i,G} \\text{; } fValue_{i,G+1} \\gets function(\\mathbf{u}_{i,G})$\\;\n\t\t\t\t}\n\t\t\t\t\\Else{\n\t\t\t\t\t$x_{i,G+1} \\gets x_{i,G}$\\;\n\t\t\t\t}\n\t\t\t\t\\If{$function(u_{i,G}) < function(x_{i,G})$} {\n\t\t\t\t\t$x_{i,G} \\rightarrow A \\text{; } CR_{i,G} \\rightarrow S_{CR} \\text{; } F_{i,G} \\rightarrow S_{F}$\\;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\If{$|A| > N$} {\n\t\t\t\t$A \\gets A \\setminus A_{rand_i}$\n\t\t\t}\n\t\t\t\\If{$S_{CR} \\neq \\emptyset \\land S_F \\neq \\emptyset$} {\n\t\t\t\t\n\t\t\t\t$M_{CR,k,G+1} = \\begin{cases}\n\t\t\t\tarithmeticMean(S_{CR}) & \\text{if $S_{CR} \\neq \\emptyset$}\\\\\n\t\t\t\tM_{CR,k,G}             & otherwise\n\t\t\t\t\\end{cases}$\\;\n\t\t\t\t\n\t\t\t\t$M_{F,k,G+1} = \\text{ } \\begin{cases}\n\t\t\t\tlehmerMean(S_{F}) & \\text{if $S_{F} \\neq \\emptyset$}\\\\\n\t\t\t\tM_{F,k,G}             & otherwise\n\t\t\t\t\\end{cases}$\\;\n\t\t\t\t\n\t\t\t\t$k \\gets k + 1$\\;\n\t\t\t\t\\If{$k > H$} {$k \\gets 1$\\;}\n\t\t\t}\n\t\t\t$G \\gets G + 1$\\;\n\t\t}\n\t}\n\t\\unterschrift{SHADE Pseudocode}{}{}\n\t\\label{algo: shade}\n\\end{algorithm}\n\n\\section{L-SHADE Pseudocode}\n\\label{chap:pscode_lshade}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FLSHADE}{LSHADE}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FLSHADE{$\\mathbf{x}_{G=0}$, $p$, $H$, $function$, $minError$, $maxFE$}}{\n\t\t$M_{CR} \\gets 0.5 \\text{; } M_{F} \\gets 0.5 \\text{; } A \\gets \\emptyset \\text{; } G \\gets 0 \\text{; }k \\gets 1$\\;\n\t\t$fValue_{G=0} \\gets function(\\mathbf{x}_{G=0}) \\text{; } NG_{init} \\gets size(\\mathbf{x}_{G=0}) \\text{; }NG_{min} = \\lceil 1/p \\rceil$\\;\n\t\t\\While{termination condition not met}\n\t\t{\n\t\t\t$S_{CR} \\gets \\emptyset \\text{; } S_F \\gets \\emptyset$\\;   \n\t\t\t\\For{$i = 1$ to $N$}{\n\t\t\t\t$r_i \\gets rand_{int}(1,H)$\\;\n\t\t\t\t$CR_{i,G} \\gets randn_i(M_{CR,r_i},0.1) \\text{; }F_{i,G}  \\gets randc_i(M_{F,r_i},0.1)$\\;\n\t\t\t\t$v_i \\gets mutationCurrentToPBest1(\\mathbf{x}_{i,G}, A, fValue_G, F_i, p)$\\;\n\t\t\t\t$u_i  \\gets crossoverBIN(pop, v_i, CR)$\\;\n\t\t\t}\n\t\t\t\\For{$i = 1$ to $N$}{\n\t\t\t\t\\If{$function(u_{i,G}) \\leq function(x_{i,G})$} {\n\t\t\t\t\t$x_{i,G+1} \\gets u_{i,G} \\text{; } fValue_{i,G+1} \\gets function(\\mathbf{u}_{i,G})$\\;\n\t\t\t\t}\n\t\t\t\t\\Else{\n\t\t\t\t\t$x_{i,G+1} \\gets x_{i,G}$\\;\n\t\t\t\t}\n\t\t\t\t\\If{$function(u_{i,G}) < function(x_{i,G})$} {\n\t\t\t\t\t$x_{i,G} \\rightarrow A \\text{; } CR_{i,G} \\rightarrow S_{CR} \\text{; } F_{i,G} \\rightarrow S_{F}$\\;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\If{$|A| > N$} {\n\t\t\t\t$A \\gets A \\setminus A_{rand_i}$\n\t\t\t}\n\t\t\t\\If{$S_{CR} \\neq \\emptyset \\land S_F \\neq \\emptyset$} {\n\t\t\t\t\n\t\t\t\t$M_{CR,k,G+1} = \\begin{cases}\n\t\t\t\tarithmeticMean(S_{CR}) & \\text{if $S_{CR} \\neq \\emptyset$}\\\\\n\t\t\t\tM_{CR,k,G}             & otherwise\n\t\t\t\t\\end{cases}$\\;\n\t\t\t\t\n\t\t\t\t$M_{F,k,G+1} = \\text{ } \\begin{cases}\n\t\t\t\tlehmerMean(S_{F}) & \\text{if $S_{F} \\neq \\emptyset$}\\\\\n\t\t\t\tM_{F,k,G}             & otherwise\n\t\t\t\t\\end{cases}$\\;\n\t\t\t\t\n\t\t\t\t$k \\gets k + 1$\\;\n\t\t\t\t\\If{$k > H$} {$k \\gets 1$\\;}\n\t\t\t}\n\t\t\t$\\mathbf{x}_{G+1} \\gets popSizeRed(\\mathbf{x}_{G+1}, fValue, G, maxGen, NG_{init}, NGmin)$\\;\n\t\t\t$G \\gets G + 1$\\;\n\t\t}\n\t}\n\t\\unterschrift{L-SHADE Pseudocode}{}{}\n\t\\label{algo: lshade}\n\\end{algorithm}\n\n\n\n\\chapter{Testbed}\n\\label{chap:testbed}\n\nThe following pages describe the testbed that is used for all experiments. The problems are structured in these major points: \n\\begin{itemize}\n\t\\item differential equation\n\t\\begin{itemize}\n\t\t\\item differential equation\n\t\t\\item domain $\\Omega$\n\t\t\\item Dirichlet bounday condition obtained by evaluating the solution on the boundary\n\t\\end{itemize}\n\t\\item solution\n\t\\item plot of the solution over the domain\n\\end{itemize}\n\n\\newpage\n\n\\underline{\\textbf{PDE 0A: Gauss Kernel}}\n\n\\underline{Problem PDE: }\n\\begin{equation}\n\\label{eq:pde0a}\n\\begin{split}\n\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = (18x^2-6)e^{-1.5(x^2 + y^2)} + (18y^2-6)e^{-1.5(x^2 + y^2)} \\\\\n+6(6x^2+12x+5)e^{-3((x+1)^2+(y+1)^2)} + 6(6y^2+12y+5)e^{-3((x+1)^2+(y+1)^2)} \\\\\n+6(6x^2-12x+5)e^{-3((x-1)^2+(y+1)^2)} + 6(6y^2+12y+5)e^{-3((x-1)^2+(y+1)^2)} \\\\\n+6(6x^2+12x+5)e^{-3((x+1)^2+(y-1)^2)} + 6(6y^2-12y+5)e^{-3((x+1)^2+(y-1)^2)} \\\\\n+6(6x^2-12x+5)e^{-3((x-1)^2+(y-1)^2)} + 6(6y^2-12y+5)e^{-3((x-1)^2+(y-1)^2)} \\\\\n\\text{on the domain } \\Omega : x, y \\in [-2,2] \\\\\n\\text{subjected to: } \\\\\nu(x,2) = 2e^{-1.5(x^2 + 4)} + e^{-3((x+1)^2 + 9)} + e^{-3((x+1)^2 + 1)} + e^{-3((x-1)^2 + 9)} + e^{-3((x-1)^2 + 1)} \\\\\nu(x,-2)= 2e^{-1.5(x^2 + 4)} + e^{-3((x+1)^2 + 1)} + e^{-3((x+1)^2 + 9)} + e^{-3((x-1)^2 + 1)} + e^{-3((x-1)^2 + 9)} \\\\\nu(2,y) = 2e^{-1.5(4 + y^2)} + e^{-3(9 + (y+1)^2)} + e^{-3(9 + (y-1)^2)} + e^{-3(1 + (y+1)^2)} + e^{-3(1 + (y-1)^2)} \\\\\nu(-2,y)= 2e^{-1.5(4 + y^2)} + e^{-3(1 + (y+1)^2)} + e^{-3(1 + (y-1)^2)} + e^{-3(9 + (y+1)^2)} + e^{-3(9 + (y-1)^2)} \\\\\n\\end{split}\n\\end{equation}\n\n\\underline{Solution: }\n\\begin{equation}\n\\label{eq:sol0A}\n\\begin{split}\nu_{ext}(x,y) = 2e^{-1.5(x^2 + y^2)} & + e^{-3((x+1)^2 + (y+1)^2)} + e^{-3((x+1)^2 + (y-1)^2)} \\\\\n                              & + e^{-3((x-1)^2 + (y+1)^2)} + e^{-3((x-1)^2 + (y-1)^2)} \\\\\n\\end{split}\n\\end{equation}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.5\\textwidth]{../../code/testbed/pde0A/sol_pde_0a.pdf}\n\t}\n\t\\unterschrift{PDE 0A Gauss Kernel solution plot}{}{}\n\t\\label{fig:sol_plot_0A}\n\\end{figure}\n\n\n\n\n\n\\underline{\\textbf{PDE 0B: Gauss Sine Kernel}}\n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde0b}\n\\begin{split}\n\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = \\\\\n2 e^{-2   (x^2 + y^2)} (2   sin(-2   (x^2 + y^2)) + 2   (1-8   x^2) cos(-2   (x^2 + y^2))) + \\\\\n2 e^{-2   (x^2 + y^2)} (2   sin(-2   (x^2 + y^2)) + 2   (1-8   y^2) cos(-2   (x^2 + y^2))) + \\\\\n2 e^{-1   (x^2 + y^2)} (1   sin(-1   (x^2 + y^2)) + 1   (1-4   x^2) cos(-1   (x^2 + y^2))) + \\\\\n2 e^{-1   (x^2 + y^2)} (1   sin(-1   (x^2 + y^2)) + 1   (1-4   y^2) cos(-1   (x^2 + y^2))) + \\\\\n2 e^{-0.1 (x^2 + y^2)} (0.1 sin(-0.1 (x^2 + y^2)) + 0.1 (1-0.4 x^2) cos(-0.1 (x^2 + y^2))) + \\\\\n2 e^{-0.1 (x^2 + y^2)} (0.1 sin(-0.1 (x^2 + y^2)) + 0.1 (1-0.4 y^2) cos(-0.1 (x^2 + y^2))) \\\\\n\\text{on the domain } \\Omega : x, y \\in [-2,2] \\\\\n\\text{subjected to: } \\\\\nu(x,2) =\t e^{-2  (x^2 + 4  )}  sin(2  ((x^2 + 4  ))) + e^{-1  (x^2 + 4  )}  sin(1  ((x^2 + 4  ))) + e^{-0.1(x^2 + 4  )}  sin(0.1((x^2 + 4  ))) \\\\\t\t\t\tu(x,-2)= \t e^{-2  (x^2 + 4  )}  sin(2  ((x^2 + 4  ))) + e^{-1  (x^2 + 4  )}  sin(1  ((x^2 + 4  ))) + e^{-0.1(x^2 + 4  )}  sin(0.1((x^2 + 4  ))) \\\\\t\t\t\tu(2,y) = \t e^{-2  (4   + y^2)}  sin(2  ((4   + y^2))) + e^{-1  (4   + y^2)}  sin(1  ((4   + y^2))) + e^{-0.1(4   + y^2)}  sin(0.1((4   + y^2))) \\\\\nu(-2,y)= \t e^{-2  (4   + y^2)}  sin(2  ((4   + y^2))) + e^{-1  (4   + y^2)}  sin(1  ((4   + y^2))) + e^{-0.1(4   + y^2)}  sin(0.1((4   + y^2))) \\\\\n\\end{split}\n\\end{equation}\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol0B}\n\\begin{split}\nu_{ext}(x,y) = & e^{-2  (x^2 + y^2)}  sin(2  ((x^2 + y^2))) + e^{-1  (x^2 + y^2)}  sin(1  ((x^2 + y^2))) \\\\ + & e^{-0.1(x^2 + y^2)}  sin(0.1((x^2 + y^2))) \\\\\n\\end{split}\n\\end{equation}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.46\\textwidth]{../../code/testbed/pde0B/sol_pde_0b.pdf}\n\t}\n\t\\unterschrift{PDE 0B Gauss Sine Kernel solution plot}{}{}\n\t\\label{fig:sol_plot_0B}\n\\end{figure}\n\n\n\n\\newpage\n\n\n\\underline{\\textbf{PDE 1: Polynomial 2D}} \n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde1}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = \\\\\n-2^{40}y^{10}(1-y)^{10}[90x^8(1-x)^{10} -200x^9(1-x)^9 + 90x^{10}(1-x)^8] \\\\\n-2^{40}x^{10}(1-x)^{10}[90y^8(1-y)^{10} -200y^9(1-y)^9 + 90y^{10}(1-y)^8] \\\\\n\\text{on the domain } \\Omega: x,y \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,1) = 0 \\\\\nu(x,0) = 0 \\\\\nu(1,y) = 0 \\\\\nu(0,y) = 0 \\\\\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution:} \n\\begin{equation}\n\\label{eq:sol1}\nu_{ext}(x,y) = 2^{40}x^{10}(1-x)^{10}y^{10}(1-y)^{10}\n\\end{equation}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde1/sol_pde_1.pdf}\n\t}\n\t\\unterschrift{PDE 1 Polynomial 2D solution plot}{}{}\n\t\\label{fig:sol_plot_1}\n\\end{figure}\n\n\n\n\\newpage\n\n\n\\underline{\\textbf{PDE 2: Chaquet PDE 1}}\n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde2}\n\\begin{split}\n\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = e^{-x} (x-2 + y^3 + 6y) \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = xe^{-x}\nu(x,1) = (x + 1)e^{-x}\nu(0,y) = y^3 \\\\\nu(1,y) = (1 + y^3) e^{-1}\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol2}\nu_{ext}(x,y) = (x + y^3) e^{-x}\n\\end{equation}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde2/sol_pde_2.pdf}\n\t}\n\t\\unterschrift{PDE 2 Chaquet PDE 1 solution plot}{}{}\n\t\\label{fig:sol_plot_2}\n\\end{figure}\n\n\n\n\n\\newpage\n\n\n\n\\underline{\\textbf{PDE 3: Chaquet PDE 3}}\n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde3}\n\\begin{split}\n\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = 4 \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = x^2 + x + 1 \\\\\nu(x,1) = x^2 + x + 3 \\\\\nu(1,y) = y^2 + y + 3 \\\\\nu(0,y) = y^2 + y + 1 \\\\\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution}\n\\begin{equation}\n\\label{eq:sol3}\nu_{ext}(x,y) = x^2 + y^2 + x + y + 1\n\\end{equation}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde3/sol_pde_3.pdf}\n\t}\n\t\\unterschrift{PDE 3 Chaquet PDE 3 solution plot}{}{}\n\t\\label{fig:sol_plot_3}\n\\end{figure}\n\n\n\n\\newpage\n\n\n\n\n\\underline{\\textbf{PDE 4: Sine Bump 2D}} \n\n\\underline{Problem PDE:}\n\\begin{equation}\n\\label{eq:pde4}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = 2\\pi^2 sin(\\pi x) sin(\\pi y) \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = 0 \\\\\nu(x,1) = 0 \\\\\nu(0,y) = 0 \\\\\nu(1,y) = 0 \\\\\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol4}\nu_{ext}(x,y) = sin(\\pi x)sin(\\pi y)\n\\end{equation}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde4/sol_pde_4.pdf}\n\t}\n\t\\unterschrift{PDE 4 Sine Bump 2D solution plot}{}{}\n\t\\label{fig:sol_plot_4}\n\\end{figure}\n\n\n\n\n\\newpage\n\n\n\n\n\n\n\n\\underline{\\textbf{PDE 5: Arctan Circular Wave Front}} \n\n\\underline{Problem PDE:}\n\\begin{equation}\n\\label{eq:pde5}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = \\frac{16000(\\sqrt{(x - 0.05)^2 + (y - 0.05)^2} -0.7)}{(1 + 400 (-0.7 + \\sqrt{(x - 0.05)^2 + (y - 0.05)^2})^2)^2} \\\\\n+ \\frac{20 (x - 0.05)^2 + 20 (y - 0.05)^2}{(1 + 400 (\\sqrt{(x - 0.05)^2 + (y - 0.05)^2} -0.7)^2) ((x - 0.05)^2 + (y - 0.05)^2)^{3/2}} \\\\\n- \\frac{40}{(1 + 400 (\\sqrt{(y - 0.05)^2 + (x - 0.05)^2} -0.7)^2) \\sqrt{(y - 0.05)^2 + (x - 0.05)^2}} \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = tan^{-1}\\left(20 \\left(\\sqrt{(x-0.05)^2 + 0.0025} -0.7\\right)\\right) \\\\\nu(x,1) = tan^{-1}\\left(20 \\left(\\sqrt{(x-0.05)^2 + 0.9025} -0.7\\right)\\right) \\\\\nu(0,y) = tan^{-1}\\left(20 \\left(\\sqrt{0.0025 + (y-0.05)^2} -0.7\\right)\\right) \\\\\nu(1,y) = tan^{-1}\\left(20 \\left(\\sqrt{0.9025 + (y-0.05)^2} -0.7\\right)\\right) \\\\\n\\end{split}\n\\end{equation}\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol5}\nu_{ext}(x,y) = tan^{-1}\\left(20 \\left(\\sqrt{(x-0.05)^2 + (y-0.05)^2} -0.7\\right)\\right)\n\\end{equation}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.58\\textwidth]{../../code/testbed/pde5/sol_pde_5.pdf}\n\t}\n\t\\unterschrift{PDE 5 Arctan Circular Wave Front solution plot}{}{}\n\t\\label{fig:sol_plot_5}\n\\end{figure}\n\n\n\n\n\\newpage\n\n\n\n\n\\underline{\\textbf{PDE 6: Peak 2D}} \n\n\\underline{Problem PDE:}\n\\begin{equation}\n\\label{eq:pde6}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = \\\\\n-(4 \\cdot 10^6 x^2 -4 \\cdot 10^6 x + 998 \\cdot 10^3)e^{-1000((x-0.5)^2 + (y-0.5)^2)} \\\\\n-(4 \\cdot 10^6 y^2 -4 \\cdot 10^6 y + 998 \\cdot 10^3)e^{-1000((x-0.5)^2 + (y-0.5)^2)} \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = e^{-1000((x-0.5)^{2} + 0.25)} \\\\\nu(x,1) = e^{-1000((x-0.5)^{2} + 0.25)} \\\\\nu(0,y) = e^{-1000(0.25 + (y-0.5)^{2})} \\\\\nu(1,y) = e^{-1000(0.25 + (y-0.5)^{2})} \\\\\n\\end{split}\n\\end{equation}\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol6}\nu_{ext}(x,y) = e^{-1000((x-0.5)^{2} + (y-0.5)^{2})}\n\\end{equation}\n\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde6/sol_pde_6.pdf}\n\t}\n\t\\unterschrift{PDE 6 Peak 2D solution plot}{}{}\n\t\\label{fig:sol_plot_6}\n\\end{figure}\n\n\n\n\n\\newpage\n\n\n\n\n\n\\underline{\\textbf{PDE 7: Boundary Line Singularity}} \n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde7}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = 0.24 x^{-1.4}\\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = x^{0.6} \\\\\nu(x,1) = x^{0.6} \\\\\nu(0,y) = 0 \\\\\nu(1,y) = 1^{0.6} \\\\\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution:} \n\\begin{equation}\n\\label{eq:sol7}\nu_{ext}(x,y) = x^{0.6}\n\\end{equation}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde7/sol_pde_7.pdf}\n\t}\n\t\\unterschrift{PDE 7 Boundary Line Singularity solution plot}{}{}\n\t\\label{fig:sol_plot_7}\n\\end{figure}\n\n\n\n\n\\newpage\n\n\n\n\n\n\\underline{\\textbf{PDE 8: Interior Point Singularity}} \n\n\\underline{Problem PDE:} \n\\begin{equation}\n\\label{eq:pde8}\n\\begin{split}\n\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = \\frac{1}{\\sqrt{x^2 - x + y^2 - y + 0.5}} \\\\\n\\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{on the domain } \\text{subjected to: } \\\\\nu(x,0) = \\sqrt{(x-0.5)^2 + 0.25} \\\\\nu(x,1) =  \\sqrt{(x-0.5)^2 + 0.25} \\\\\nu(0,y) = \\sqrt{0.25 + (y-0.5)^2} \\\\\nu(1,y) =  \\sqrt{0.25 + (y-0.5)^2} \\\\\n\\end{split}\n\\end{equation}\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol8}\nu_{ext}(x,y) = \\sqrt{(x-0.5)^2 + (y-0.5)^2}\n\\end{equation}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{../../code/testbed/pde8/sol_pde_8.pdf}\n\t}\n\t\\unterschrift{PDE 8 Interior Point Singularity solution plot}{}{}\n\t\\label{fig:sol_plot_8}\n\\end{figure}\n\n\n\n\n\n\\newpage\n\n\n\n\n\\underline{\\textbf{PDE 9: Arctan Wave Front Homogeneous Boundary Conditions 2D}} \n\n\\underline{Problem PDE:}\n\\begin{equation}\n\\label{eq:pde9}\n\\begin{split}\n-\\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^2 u}{\\partial y^2} = \\\\\n\\frac{20\\sqrt{2}(x^2 + y^2 -2x^2y - 2xy^2 + 4xy - x - y)}{400(\\frac{x+y}{\\sqrt{2}}-0.8)^2+1} \\\\\n+\\frac{16000(1-x)x(1-y)y(\\frac{x+y}{\\sqrt{2}}-0.8)}{(400(\\frac{x+y}{\\sqrt{2}}-0.8)^2+1)^2} \\\\\n+ tan^{-1}\\left(20\\left(\\frac{x+y}{\\sqrt{2}}-0.8\\right)\\right)(2(1-y)y + 2(1-x)x)  \\\\\n\\text{on the domain } \\Omega: \\mathbf{x} \\in [0,1] \\\\\n\\text{subjected to: } \\\\\nu(x,0) = 0 \\\\\nu(x,1) = 0 \\\\\nu(0,y) = 0 \\\\\nu(1,y) = 0 \\\\\n\\end{split}\n\\end{equation}\n\n\n\\underline{Solution:}\n\\begin{equation}\n\\label{eq:sol9}\nu_{ext}(x,y) = tan^{-1}\\left(20\\left(\\frac{(x + y)}{\\sqrt{2}} -0.8\\right)\\right)x(1-x)y(1-y)\n\\end{equation}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.54\\textwidth]{../../code/testbed/pde9/sol_pde_9.pdf}\n\t}\n\t\\unterschrift{PDE 9 Arctan Wave Front Homogeneous Boundary Conditions 2D solution plot}{}{}\n\t\\label{fig:sol_plot_9}\n\\end{figure}\n\n\n\n\n\n\\chapter{Software Architecture}\n\\label{chap:appendix_software_architecture}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\\includegraphics[width=0.9\\textwidth]{../../code/uml_diag/testbench_uml_class.pdf}\n\t}\n\t\\unterschrift{This \\gls{uml} class diagram describes the software architecture defined to prepare, run and evaluate the experiments. }{}{}\n\t\\label{fig:software_architecture}\n\\end{figure}\n\n\n\\chapter{Post-Processing Module Description}\n\\label{chap:apendix_post_proc}\nThe post-processing module includes these functions. Their implementation is described in the following list. These functions are used to interpret the results in the experiments chapters.  \n\n\\begin{itemize}\n\t\\item \n\t\\inlinecode{bool saveExpObj(obj, filename)} \\\\\n\tSave an \\inlinecode{CiPdeN} object as a \\gls{json} file. The filename parameter can include a path, but it must end with .json. The results execution time, memory usage, solution quality and all intergenerational data of the optimisation algorithm are stored in the file. \n\t\\item \\inlinecode{dict loadExpObject(filename)} \\\\\n\tLoads the \\gls{json} file located at the specified filename, which again can include a path. A dictionary with the saved \\inlinecode{CiPdeN} parameters is returned. \n\t\\item \n\t\\inlinecode{dict loadExpObjectFast(filename)} \\\\\n\tWhen solving a \\gls{pde} with more function evaluation, the result file can become very large (>400Mb @ $10^6$ \\#FE). For evaluating such large files, this function can be used. It does not load the generation data (meaning population, function value, F and CR). Since the standard \\gls{json} interpreter in Python loads files in a serial manner, a new interpreter is needed. To that extent, \\textit{bigjson} from \\cite{heino_henubigjson_2020} is used. This package accesses only the parts of a \\gls{json} file that are actually needed.\n\t\\item \\inlinecode{bool drawGaussKernel(parameter, ggb)} \\\\\n\tDraws a solution approximated by Gauss kernels and with the specified parameters to a GeoGebra file. If the filename provided in the \\textit{ggb} argument does not exist, the function searches for a template and prints to a copy of that file. \n\t\\item \\inlinecode{bool drawGSinKernel(parameter, ggb)} \\\\\n\tThis is similar to the \\inlinecode{drawGaussKernel} method - but it takes parameters for a Gauss Sine kernel. \n\t\\item \n\t\\inlinecode{float calcRSME(solve_dict)} \\\\\n\tTo compare the obtained results with previous works, the \\gls{rmse} quality metric (as described in the chapter \\ref{chap:metric_quality}) must be computed. This is done from a single dictionary, as obtained by the functions \\inlinecode{loadExpObject} or \\inlinecode{loadExpObjectFast}.\n\t\\item \n\t\\inlinecode{None plotApprox3D(kernel, parameter, lD, uD, name=None)} \\\\\n\tThe approximate solution of a \\gls{pde} can be plotted over the domain with this function. Only square sized domains are accepted, as specified by the lower and the upper domain parameters \\inlinecode{lD} and \\inlinecode{uD}. If \\textit{name} is of type string, the plot is saved as this file.\n\t\\item \n\t\\inlinecode{string statsWilcoxon(a, b, alpha=0.05)} \\\\\n\tThis function is a wrapper for the \\inlinecode{scipy.stats.wilcoxon} (\\cite{scipy_scipystatswilcoxon_2020}). The default significance level is set to 0.05. A string is returned that describes if the mean and median of \\inlinecode{a} is significantly smaller than the mean and median of \\inlinecode{b}. The result is one of these strings: \n\t\\begin{itemize}\n\t\t\\item sig. worse: the distributions are different; the mean and the median of \\inlinecode{a} are larger than the mean and the median of \\inlinecode{b}\n\t\t\\item sig. better: the distributions are different; the mean and the median of \\inlinecode{a} are smaller than the mean and the median of \\inlinecode{b}\n\t\t\\item unsig. worse: the distributions are similar; the mean and the median of \\inlinecode{a} are larger than the mean and the median of \\inlinecode{b} \n\t\t\\item unsig. better: the distributions are similar; the mean and the median of \\inlinecode{a} are smaller than the mean and the median of \\inlinecode{b}\n\t\t\\item unsig. undecided: the distributions are similar; the mean is larger, the median is smaller or vice versa\n\t\\end{itemize} \n\tExample distributions with the corresponding results are shown in figure \\ref{fig:stats_wilcoxon_examples} below.\n\t\\item \\inlinecode{None plotFEDynamic(FEDynamic, name=None)} \\\\\n\tThis method plots the function value dynamic of the population on a y-axis logarithmic plot. It can also cope with a varying population size. The plot can be saved with an optional argument. \n\t\\item \\inlinecode{None plotError3D(kernel, parameter, pdeName, lD, uD, name=None)} \\\\\n\tSimilar to the \t\\inlinecode{plotApprox3D} method, a 3D graph of the solution is plotted. Instead of the function value, the error is shown. The error is calculated by $E  = u_{apx}(x,y) - u_{ext}(x,y) \\forall x,y \\in \\Omega$. \n\t\\item \\inlinecode{None plotABSError3D(kernel, parameter, pdeName, lD, uD, name=None)} \\\\\n\tSimilar to the \t\\inlinecode{plotError3D} method, a 3D graph of the solution is plotted. The absolute error is shown. The error is calculated by $E_{abs}  = \\left| u_{apx}(x,y) - u_{ext}(x,y) \\right| \\forall x,y \\in \\Omega$. \n\t\\item \\inlinecode{None plotKernelAdaption(obj_dict, title, 'green', 'red', name=None)} \\\\\n\tThis function plot the fitness difference over all generations. Additionally, it marks if the number of kernels (and thus the search dimension) is increased or reduced. \n\t\\item \\inlinecode{(float, float) calcSingleERT(rundata, target)} \\\\\n\tCalculates the expected running time and the success probability for a single target value. The expected running time is corrected by the success probability. \n\\end{itemize}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\textwidth]{../img/pdf/sig_better.pdf}\n\t\t\\caption{A is significantly better than B}\n\t\t\\label{fig:stats_wilcoxon_examples_sigificantly_better}\n\t\\end{subfigure}% \n\t%\n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\textwidth]{../img/pdf/sig_worse.pdf}\n\t\t\\caption{A is sigificantly worse than B}\n\t\t\\label{fig:stats_wilcoxon_examples_sigificantly_worse}\n\t\\end{subfigure}% \n\t\\\\\n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\textwidth]{../img/pdf/unsig_better.pdf}\n\t\t\\caption{A is unsignificantly better than B}\n\t\t\\label{fig:stats_wilcoxon_examples_insigificantly_better}\n\t\\end{subfigure}% \n\t%\n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\textwidth]{../img/pdf/unsig_worse.pdf}\n\t\t\\caption{A is unsignificatnly worse than B}\n\t\t\\label{fig:stats_wilcoxon_examples_insigificantly_worse}\n\t\\end{subfigure}% \n\t\\unterschrift{Example distributions for different results of the statsWilcoxon method.}{}{}%\n\t\\label{fig:stats_wilcoxon_examples}\n\\end{figure}\n\n\n\\chapter{Solve Method}\n\\label{chap:solve_function}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{Fsolve}{solve}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\Fsolve{}}{\n\t\t$gc.disable()$\\;\n\t\t\\While{$gc.isenabled()$} {\n\t\t\t$time.sleep(0.1)$\\;\n\t\t}\t\n\t\t$process = psutil.Process()$\\;\n\t\t$memstart = process.memory\\text{\\textunderscore}info().vms$\\;\n\t\t$t\\text{\\textunderscore}start = time.time()$\\;\n\t\t\\tcp{perform solver steps}\n\t\t\\tcp{that are particular}\n\t\t\\tcp{to FEM or CI solver}\n\t\t$self.\\text{\\textunderscore}exec\\text{\\textunderscore}time = time.time() - t\\text{\\textunderscore}{start}$\\;\n\t\t$memstop = process.memory\\text{\\textunderscore}info().vms - memstart$\\;\n\t\t$gc.enable()$\\;\n\t\t$gc.collect()$\\;\n\t}\n\t\\unterschrift{Solve Method Pseudocode}{}{}\n\t\\label{algo: solve}\n\\end{algorithm}\n\n\n\n\\chapter{pJADE}\n\\label{chap:pseudocode_pjade}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FpJADE}{pJADE}\n\t\\SetKwFor{PFor}{for}{do parallel}{end}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FpJADE{$\\mathbf{X}_{g=0}$, $p$, $c$, $function$, $minError$, $maxFE$}}{\n\t\t$fValue_{g=0} \\gets function(\\mathbf{x}_{g=0})$\\;\n\t\t$\\mu_{CR} \\gets 0.5$\\;\n\t\t$\\mu_{F}  \\gets 0.5$\\;\n\t\t$A        \\gets \\emptyset$\\;\n\t\t\\While {$fe \\leq maxFE$}{\n\t\t\t$g \\gets g+1$\\;\n\t\t\t$S_F \\gets \\emptyset$\\;\n\t\t\t$S_{CR} \\gets \\emptyset$\\; \n\t\t\t$pResults \\gets \\emptyset$\\;\n\t\t\t\\PFor {$i = 1$ to $NP$} {\n\t\t\t\t$F_i  \\gets randc_i(\\mu_{F},0.1)$\\;\n\t\t\t\t$v_i \\gets mutationCurrentToPBest1(\\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\\;\n\t\t\t\t\n\t\t\t\t$CR_i \\gets randn_i(\\mu_{CR},0.1)$\\;\n\t\t\t\t$u_i  \\gets crossoverBIN(\\mathbf{x}_{i,g}, v_i, CR_i)$\\;\n\t\t\t\t$(u_i, function(u_i)) \\rightarrow pResults$\n\t\t\t}\n\t\t\t\\For {$i = 1$ to $NP$} {\t\n\t\t\t\t\\If {$function(\\mathbf{x}_{i,g}) \\geq pResults_{i,f,g}$} {\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets \\mathbf{x}_{i,g}$\\;\n\t\t\t\t}\n\t\t\t\t\\Else\n\t\t\t\t{\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets pResults_{i,u,g}$\\;\n\t\t\t\t\t$fValue_{i,g+1} \\gets pResults_{i,f,g}$\\;\n\t\t\t\t\t$\\mathbf{x}_{i,g} \\rightarrow \\mathbf{A}$\\;\n\t\t\t\t\t$CR_i \\rightarrow S_{CR}$\\;\n\t\t\t\t\t$F_i \\rightarrow S_F$\\;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\tcp{resize $A$ to size of $\\mathbf{x}_g$}\n\t\t\t\\If{$|A| > NP$} {\n\t\t\t\t$A \\gets A \\setminus A_{rand_i}$\n\t\t\t}\n\t\t\t$fe \\gets fe + size(\\mathbf{X})$\\;\n\t\t\t$\\mu_{CR} \\gets (1-c) \\cdot \\mu_{CR} + c \\cdot arithmeticMean(S_{CR})$\\;\n\t\t\t$\\mu_{F} \\gets (1-c) \\cdot \\mu_{F} + c \\cdot lehmerMean(S_{F})$\\;\n\t\t}\t\n\t}\n\t\\unterschrift{Pseudocode of pJADE}{}{}\n\t\\label{algo: pjade}\n\\end{algorithm}\n\n\n\n\n\n\n\\chapter{paJADE}\n\\label{chap:pseudocode_pajade}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FpaJADE}{paJADE}\n\t\\SetKwFor{PFor}{for}{do parallel}{end}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FpaJADE{$\\mathbf{X}_{g=0}$, $p$, $c$, $dT$, $function$, $minError$, $maxFE$}}{\n\t\t$fValue_{g=0} \\gets function(\\mathbf{x}_{g=0})$\\;\n\t\t$\\mu_{CR} \\gets 0.5$\\;\n\t\t$\\mu_{F}  \\gets 0.5$\\;\n\t\t$A        \\gets \\emptyset$\\;\n\t\t\\While {$fe \\leq maxFE$}{\n\t\t\t$g \\gets g+1$\\;\n\t\t\t$S_F \\gets \\emptyset$\\;\n\t\t\t$S_{CR} \\gets \\emptyset$\\; \n\t\t\t$pResults \\gets \\emptyset$\\;\n\t\t\t\\PFor {$i = 1$ to $NP$} {\n\t\t\t\t$F_i  \\gets randc_i(\\mu_{F},0.1)$\\;\n\t\t\t\t$v_i \\gets mutationCurrentToPBest1(\\mathbf{x}_{i,g}, A, fValue_g, F_i, p)$\\;\n\t\t\t\t\n\t\t\t\t$CR_i \\gets randn_i(\\mu_{CR},0.1)$\\;\n\t\t\t\t$u_i  \\gets crossoverBIN(\\mathbf{x}_{i,g}, v_i, CR_i)$\\;\n\t\t\t\t$(u_i, function(u_i)) \\rightarrow pResults$\n\t\t\t}\n\t\t\t\\For {$i = 1$ to $NP$} {\t\n\t\t\t\t\\If {$function(\\mathbf{x}_{i,g}) \\geq pResults_{i,f,g}$} {\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets \\mathbf{x}_{i,g}$\\;\n\t\t\t\t}\n\t\t\t\t\\Else\n\t\t\t\t{\n\t\t\t\t\t$\\mathbf{x}_{i,g+1} \\gets pResults_{i,u,g}$\\;\n\t\t\t\t\t$fValue_{i,g+1} \\gets pResults_{i,f,g}$\\;\n\t\t\t\t\t$\\mathbf{x}_{i,g} \\rightarrow \\mathbf{A}$\\;\n\t\t\t\t\t$CR_i \\rightarrow S_{CR}$\\;\n\t\t\t\t\t$F_i \\rightarrow S_F$\\;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\tcp{resize $A$ to size of $\\mathbf{x}_g$}\n\t\t\t\\If{$|A| > NP$} {\n\t\t\t\t$A \\gets A \\setminus A_{rand_i}$\n\t\t\t}\n\t\t\t$fe \\gets fe + size(\\mathbf{X})$\\;\n\t\t\t$\\mu_{CR} \\gets (1-c) \\cdot \\mu_{CR} + c \\cdot arithmeticMean(S_{CR})$\\;\n\t\t\t$\\mu_{F} \\gets (1-c) \\cdot \\mu_{F} + c \\cdot lehmerMean(S_{F})$\\;\n\t\t\t\n\t\t\t\\tcp{state detector}\n\t\t\t\\If {$min(function(\\mathbf{X}_{g-dT}) - function(\\mathbf{X}_g)) < minError$} {\n\t\t\t\tbreak\\;\n\t\t\t}\n\t\t}\t\n\t}\n\t\\unterschrift{Pseudocode of paJADE}{}{}\n\t\\label{algo: pajade}\n\\end{algorithm}\n\n\\chapter{Adaptive Kernel Scheme}\n\\label{chap:appendix_adaptive_scheme}\n\n\\begin{algorithm}[H]\n\t\\SetAlgoNoLine\n\t\\DontPrintSemicolon\n\t\\SetKwFunction{FmpaJADE}{memeticpJADEadaptive}\n\t\\SetKwProg{Fn}{Function}{:}{}\n\t\\Fn{\\FmpaJADE{$\\mathbf{X}$, $func$, $kSize$, $minErr$, $maxFE$}}{\n\t\t$dim$, $popsize$ $\\gets size(\\mathbf{X})$\\;\n\t\t\\tcp{number of kernels}\n\t\t$\\kappa$ $\\gets$ $dim/kSize$ \\;\n\t\t$p \\gets 0.3$\\;\n\t\t$c \\gets 0.5$\\;\n\t\t$dT$ $\\gets 100$\\;\n\t\t$fecounter \\gets 0$\\;\n\t\t$bestFE \\gets \\infty$\\;\n\t\t$\\mathbf{\\mathbf{bestPop}} \\gets \\emptyset$\\;\n\t\t$popFactor$ $\\gets$ $popsize/dim$\\;\n\t\t\\While{$fecounter < maxFE$}{\n\t\t\t$\\mathbf{pop}$, $\\mathbf{FE}$, $F$, $CR$ $\\gets paJADE($$\\mathbf{X}$, $p$, $c$, $dT$, $func$, $minErr$, $maxFE - 2 \\cdot dim$ $)$\\;\n\t\t\t$fecounter \\gets fecounter + len(F)\\cdot popsize$\\;\n\t\t\t$bestIndex \\gets argmin(\\mathbf{FE})$\\;\n\t\t\t$bestSol \\gets \\mathbf{pop}[bestIndex]$\\;\n\t\t\t$\\mathbf{pop}$, $\\mathbf{FE}$ $ \\gets ds$($func$, $bestSol$, $minErr$, $2 \\cdot dim)$\\;\n\t\t\t$fecounter \\gets fecounter + 2 \\cdot dim$\\;\n\t\t\t\\If{$min(\\mathbf{FE}) < bestFE$}{\n\t\t\t\t\\tcp{increase dimension}\n\t\t\t\t$\\mathbf{X} \\gets appendRndKernel(\\mathbf{pop}, popsize, kSize)$\\;\n\t\t\t\t$\\kappa \\gets \\kappa+1$ \\;\n\t\t\t\t\\tcp{adapt population size to dimension}\n\t\t\t\t$\\mathbf{X} \\gets appendRndPop(\\mathbf{X}, popFactor, kSize)$\\;\n\t\t\t\t$bestFE \\gets min(\\mathbf{FE})$\\;\n\t\t\t\t$\\mathbf{bestPop} \\gets \\mathbf{pop}$\\;\n\t\t\t\t$dim$, $popsize$ $\\gets size(\\mathbf{X})$\\;\n\t\t\t}\n\t\t\t\\Else {\n\t\t\t\t\\tcp{reduce dimension}\n\t\t\t\t\\tcp{restart around previous best}\n\t\t\t\t$\\mathbf{X} \\gets \\mathbf{bestPop} + \\mathbf{\\mathcal{N}}(size(\\mathbf{bestPop}))$\\;\n\t\t\t\t$\\kappa \\gets \\kappa - 1$ \\;\n\t\t\t\t$dim$, $popsize$ $\\gets size(\\mathbf{X})$ \\;\n\t\t\t}\n\t\t}\n\t\t\\Return $\\mathbf{pop}$, $\\mathbf{FE}$, $F$, $CR$\n\t}\n\t\\unterschrift{Pseudocode of memetic parallel JADE with adaptive kernels}{}{}\n\t\\label{algo: memeticpJADEadaptive}\n\\end{algorithm}\n\n\\chapter{PDE 2 3 4 and 7 Kernel Adaption}\n\\label{chap: appendix kernel bar plot}\n\nThe following plots show the fitness difference in relation to the kernel adaption. Darker grey and black areas represent a strong decline of the fitness value over multiple generations, while lighter areas mean that the fitness value is stagnating. Following lighter areas, often comes a green bar, which means that a new kernel is introduced. Similarly, red lines represent the reduction by one kernel. The plots compare the best and the worst replications with $minError = 0$ produced in the experiment chapter \\ref{chap:experimet_2}. \n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde2_worst_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the worst result of \\gls{pde}2 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde2_worst_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde2_best_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the best result of \\gls{pde}2 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde2_best_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde3_worst_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the worst result of \\gls{pde}3 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde3_worst_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde3_best_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the best result of \\gls{pde}3 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde3_best_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde4_worst_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the worst result of \\gls{pde}4 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde4_worst_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde4_best_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the best result of \\gls{pde}4 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde4_best_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde7_worst_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the worst result of \\gls{pde}7 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde7_worst_kernelbars}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=1\\linewidth}{\n\t\t\\includegraphics[width=\\textwidth]{../../code/experiments/experiment_2/pde7_best_result_kernelbars.pdf}\n\t}\n\t\\unterschrift{Kernel Bars Plot on the best result of \\gls{pde}7 in experiment 2.}{}{}\n\t\\label{fig:pajade_pde7_best_kernelbars}\n\\end{figure} \n\n\n\n\\end{document}", "meta": {"hexsha": "782786883199e614b631e8500b599aadb81b2037", "size": 34241, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "master_thesis_doc/tex/Appendix.tex", "max_stars_repo_name": "nicolai-schwartze/Masterthesis", "max_stars_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-13T10:02:02.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-13T10:02:02.000Z", "max_issues_repo_path": "master_thesis_paper/tex/Appendix.tex", "max_issues_repo_name": "nicolai-schwartze/Masterthesis", "max_issues_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "master_thesis_paper/tex/Appendix.tex", "max_forks_repo_name": "nicolai-schwartze/Masterthesis", "max_forks_repo_head_hexsha": "7857af20c6b233901ab3cedc325bd64704111e16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5696078431, "max_line_length": 538, "alphanum_fraction": 0.6256242516, "num_tokens": 13811, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.42211622701075724}}
{"text": "\\documentclass[12pt,a4paper,twosided]{article}\n\\usepackage{amsmath,bm} \n%\\usepackage[T1]{fontenc}\n%\\usepackage[QX]{fontenc}\n%\\usepackage[normalsections]{savetrees}\n\\usepackage{tgschola}\n\\usepackage[latin1]{inputenc}\n\\usepackage{paralist}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\\usepackage{xspace}\n\\usepackage{booktabs}\n\\usepackage{listings}\n\\usepackage[per=frac,fraction=nice]{siunitx}\n\\usepackage[colorlinks=true,linkcolor=black,urlcolor=black,hyperfootnotes=false]{hyperref}\n\\pdfpagewidth=210mm\n\\pdfpageheight=297mm\n% +++++++++++++++++++++++++++++++++++++++++++\n\\newcommand{\\wnat}{\\omega_\\text{n}}\n\\newcommand{\\fmax}{f_\\text{max}}\n\\newenvironment{enumin}%\n% {\\begin{inparaenum}[\\hspace{1em}(1)]\\hspace{-1em}\\ignorespaces}%\n   {\\begin{inparaenum}[\\hspace{0.6em}(1)]}%\n   {\\end{inparaenum}}\n%%%\n\\graphicspath{{xfig/}}\n\\title{Dynamics of Structures 2010-2011\\\\\\large 1st home assignment\n  due on Tuesday 2011-06-17\\\\\\huge Solutions}\n\\date{}\n\\setcounter{tocdepth}{1}\n%%%\n\\begin{document}\n\\lstset{\n  basicstyle=\\ttfamily\\small,\n  backgroundcolor=\\color[rgb]{1.00,0.98,0.95},\n  language=python,\n  showstringspaces= false\n}\n\\maketitle{}\n\\tableofcontents{}\n% +++++++++++++++++++++++++++++++++++++++++++\n\\section{Impact}\n\\[\\input{xfig/impact.pdf_t}\\]\n\\noindent A body of mass $m_1=\\SI{120}{\\kilogram}$ hits an undamped\n\\emph{SDOF} system, of unknown characteristics $k$ and $m_2$, with\nvelocity $\\dot{x}_1=\\SI{50}{\\meter\\per\\second}$.\n\nThe collision is anelastic, i.e., the two masses are \\emph{glued} together\nand a measurement of the ensuing free oscillations gives the following\nresults:\n\\[ x_\\text{max} =\\SI{30}{\\milli\\meter},\\qquad\n   \\dot{x}_\\text{max}=\\SI{60}{\\milli\\meter\\per\\second}.\\]\n%\nCompute:\n\\begin{enumerate}\n\\item the total mass $m=m_1+m_2$\n\\item the mass $m_2$ of the impacted body,\n\\item the circular frequency of the insuing motion,\n\\item the spring stiffness $k$.\n\\end{enumerate}\n\n\\subsection{Solution}\n\nAfter the collision the two \\emph{glued} bodies have the same\nvelocity, so that by the law of conservation of the momentum we can\nwrite\n\\[m_1\\times\\dot x_1 + m_2\\times0 = (m_1+m_2)\\times\\dot x_0,\\]\nwhere we have denoted the initial velocity of the compound body with\n$\\dot x_0$. \n\nObserving that the initial conditions for the compound are $x(0)=0$\nand $\\dot x(0)=\\dot x_0$ we can write\n\\begin{align*}\n  x(t)&=\\frac{\\dot x_0}{\\wnat}\\,\\sin\\wnat t,\\,&\\dot x(t)&=\\dot x_0\\,\\cos\\wnat t.\\\\\n  x_\\text{max} &= \\frac{\\dot x_0}{\\wnat} = \\SI{30}{\\mm},&\n  \\dot x_\\text{max} &=\\dot x_0=\\SI{60}{\\milli\\meter\\per\\second}\\\\\n  \\intertext{and hence}\n  \\dot x_0&=\\SI{60}{\\milli\\meter\\per\\second},&\n  \\wnat&=\\frac{\\dot x_\\text{max}}{x_\\text{max}}={\\color{red}\\SI{2}{\\rad\\per\\second}}.\n\\end{align*}\n\nSubstituting $\\dot x_0=\\SI{60}{\\mm\\per\\second}$ in\n$m_1\\times\\dot x_1 + m_2\\times0 = (m_1+m_2)\\times\\dot x_0$ we have\n\\[\\SI{120}{\\kg}\\times\\SI{50000}{\\mm\\per\\second} = \n(\\SI{120}{\\kg}+m_2)\\times\\SI{60}{\\mm\\per\\second}\n\\Rightarrow {\\color{red}m=\\SI{100000}\\kg}\n\\Rightarrow {\\color{red}m_2=\\SI{99880}\\kg}.\\]\n\nAs for the last question, it is $k=\\wnat^2\\,m$ and substituting we find\n\\[{\\color{red}k=(\\SI{2}{\\rad\\per\\second})^2\\,\\SI{100000}{\\kg}=\\SI{400000}{\\newton\\per\\meter}.}\\]\n\\section{Vibration Isolation --- Numerical Integration} \nA rotating machine, its mass $M=\\SI{35000}{\\kg}$, is rigidly connected\nto the floor.\n\nDue to unbalances, during steady-state regime the machine is subjected\nto a harmonic force $p(t)=\\SI{1}{\\kilo\\newton}\\,\\sin(2\\pi\\,\\SI{5}\\hertz\\, t)$.\n\n\\subsection{Vibration Isolation}\nConsidering the floor fixed, design an appropriate suspension system\nsuch that the steady-state transmitted force is reduced to \n\\SI{300}{\\newton}.\n\\subsection{Numerical Integration}\nWhen the machine is turned on, its full velocity is reached in\n\\SI{6}{\\second}.  The angular velocity and the unbalanced load vary\nlinearly, from $0$ to their respective maximum values, i.e.,\n\\[p(t)=\n\\begin{cases}\n  \\SI{1}{\\kilo\\newton}\\,\\frac{t}{\\SI{6}\\second}\\;\n  \\sin\\left(2\\pi\\,\\SI{2.5}{\\hertz}\\,\\frac{t^2}{\\SI{6}{\\second}}\\right) &  \\SI{0}\\second \\le t \\le \\SI{6}\\second,\\\\\n  \\SI{1}{\\kilo\\newton}\\;\\sin(2\\pi\\,\\SI{5}{\\hertz}\\, t) &  \\SI{6}\\second\\le t.\n\\end{cases}\\]\\[\n\\includegraphics{02/p_of_t}\n\\]\n\n\\bigskip\\noindent Using the stiffness computed in the previous step,\nfind  the maximum absolute value of the displacement using either\nthe constant or the linear acceleration method and plot the response\nin the interval $\\SI{0}\\second \\le t \\le \\SI{10}\\second$.\n\n\\subsection{Solution}\n\\subsubsection{Vibration Isolation}\nWith $\\wnat$ being the natural frequency of the system composed by the\nmachine and the suspension springs, $\\beta=\\frac\\omega\\wnat$ the\nfrequency ratio, the condition on the maximum tranmitted load is\n\\[\\fmax=\\frac{p_0}{\\beta^2-1}\\le\\SI{300}{\\newton}.\\]\n\nSubstituting $p_0=\\SI{1000}{\\newton}$ in the equation above, we have \n\\[ \\beta^2 =\\frac{\\omega^2}{k/m} \\ge \\frac{13}{3}\n\\quad\\Rightarrow\\quad\nk\\le\\frac{3}{13}(\\pi\\,\\SI{10}{\\rad\\per\\second})^2\\SI{35000}\\kg=\\SI{7971603.}{\\newton\\per\\metre}\\]\n\nIf we accept a small damping, it must be\n\\[\\text{TR} =\n\\frac{\\sqrt{1^2+(2\\beta\\zeta)^2}}{\\sqrt{(1-\\beta^2)^2+(2\\beta\\zeta)^2}}\n=\n\\frac{\\sqrt{1+4\\beta^2\\zeta^2}}{\\sqrt{(1-\\beta^2)^2+4\\beta^2\\zeta^2}}\\le0.4\\]\nwith $\\omega=2\\pi\\SI{5}{\\rad\\per\\second}$ and $\\wnat^2=k/m$,\nsubstituting the actual value of $m$, solving the quadratic equation\nin $k$ and discarding the negative root, it is finally found\n\\[k\\le \\left( \\sqrt{\\left(182 \\zeta^2 + 9\\right)^2 + 819} - \\left(182\n    \\zeta^2 + 9\\right) \\right) \\frac{\\pi^2}\n{26}\\si{\\mega\\newton\\per\\metre}\\]\n\\[\\includegraphics{02/stif_from_z}\\]\n\n\\subsubsection{Numerical Integration}\nThe response can be computed and printed with the following program\n\\lstinputlisting{02/integ.py}\nand the response time history is\n\\[\\includegraphics{02/displacement}\\]\nbut these displacements are a bit meaningless, let's try to plot\n$f_\\text{S}=k\\,x$\n\\[\\includegraphics{02/force}\\]\noh my, it's $f_\\text{S}\\approx\\SI{5}{\\kilo\\newton}$! just a moment,\nthe machine weight is about \\SI{350}{\\kilo\\newton} so this harmonic\nforce is less than 1/70 of the weight, it shouldn't be a structural\nproblem... on the other hand, there is no dissipation and the effects\nof the transient become permanent, it should be obvious that we have to\nuse a dissipative device.\n\nTo get an appreciation of the problem, I have  modified the previous\nprogram so that the integration is run for different values of $t_0$,\nthe duration of transient, and different values of the damping ratio\n$\\zeta$; for each value of $\\zeta$ $k$ is given by the formula we have\nseen before, \n\\[k\\le \\left( \\sqrt{\\left(182 \\zeta^2 + 9\\right)^2 + 819} - \\left(182 \\zeta^2 + 9\\right) \\right) \\frac{\\pi^2} {26}\\si{\\mega\\newton\\per\\metre}\\]\nand the damping coefficient is computed by\n\\[\\wnat=\\sqrt{k/m},\\qquad c=2\\zeta\\wnat m.\\]\n\nFor each iteration on $\\zeta,\\;t_0$ the program prints the peak value\nof the transmitted force, and finally the results are plotted as a\ncolour map\n\\[\\includegraphics{02/map}\\]\n% +++++++++++++++++++++++++++++++++++++++++++\n%\n\\section{Estimation of damping ratio}\nYou want to determine the mass $m$, the stiffness $k$ and the damping\nratio $\\zeta$ of a one storey building that can be modeled as a single\ndegree of freedom system.\n\nA series of 4 dynamical test is performed, loading the building with a\nvibrodyne and measuring the amplitude $\\rho$ and the phase difference\n$\\theta$ of the steady state motion (note that the measures of $\\rho$\nand $\\theta$ are affected by a random measurement error).\n\nIn each test the load amplitude is $p_0=\\SI{600}{\\newton}$, while\nthe excitation frequencies $\\omega_n$ (with $n=1,\\ldots,4$) are\ndifferent.\n\nThe relevant data is summarized in the following table\n\\begin{center}\n  \\begin{tabular}{rcrr}\n    \\toprule \n    $n$ & \n    $\\omega_n (\\si{\\rad\\per\\second})$ & \n    $\\rho_n (\\si{\\micro\\metre})$  &\n    $\\theta_n (\\si{\\deg})$\\\\\n    \\midrule\n    1 & 40 & 12.39062 &   7.58258 \\\\\n    2 & 50 & 41.09556 &  33.33505 \\\\\n    3 & 60 & 18.07490 & 163.21210 \\\\\n    4 & 70 &  7.11246 & 171.69968 \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{center}\nGive your best estimate of $m$, $\\zeta$ and $k$.\n\n\\subsection{Solution}\n\nWhen you have a linear system $\\bm A\\,\\bm x=\\bm b$ with more equations\nthan unknowns, it is usually solved under the hypotesis that the\n\\emph{best} solution is the solution that minimises the sum of the\nsquares of the residuals $\\bm r = \\bm b - \\bm A\\,\\bm x$. In a vector\nnotation, the sum of the\nsquares of the residuals is\n\\begin{align*}\n  \\bm r^T\\cdot\\bm r & = (\\bm b^T - \\bm x^T \\bm A^T)(\\bm b - \\bm A\\,\\bm x )\\\\\n  &=\\bm b^T\\bm b+ \\bm x^T\\bm A^T\\bm A\\,\\bm x -\\bm x^T \\bm  A^T\\bm b -\\bm b^T\\bm A\\,\\bm x\\\\\n\\intertext{the last term is the transpose of the previous one, both\n  are scalars, so we can write}\n  \\bm r^T\\cdot\\bm r &=\\bm b^T\\bm b+ \\bm x^T\\bm A^T\\bm A\\,\\bm x -2\\bm x^T \\bm  A^T\\bm b.\n\\end{align*}\n\nThe square of the residual is positive definite, and its minimum is\nachieved when all the partial derivatives with respect to the $x_i$\nare equal to zero,\n\\[\\frac{\\partial (\\bm r^T\\cdot\\bm r)}{\\partial x_i}=0,\\qquad\ni=1,\\ldots,N.\\]\n\nThese $N$ equations can be conveniently be expressed in matrix format,\n\\[2(\\bm A^T\\bm A\\,\\bm x - \\bm A^T  \\bm b)=0\\quad\\Rightarrow\\quad \\bm\nA^T\\bm A\\,\\bm x = \\bm A^T  \\bm b.\\]\n\nIn our case, it is\n\\[1\\cdot k - \\omega^2_n\\,m=p_0\\frac{\\cos\\theta_n}{\\rho_n},\\qquad\nn=1,\\ldots,4\\]\nor, matricially\n\\[\n\\begin{bmatrix}  1&-1600\\\\1&-2500\\\\1&-3600\\\\1&-4900\\end{bmatrix}\\,\n\\begin{Bmatrix}k\\\\m\\end{Bmatrix}=\n\\begin{Bmatrix} +48.000\\\\+12.198\\\\-31.780\\\\-83.475\\end{Bmatrix}\\,\\si{\\mega\\newton\\per\\metre}\n\\]\n(note that the coefficients of $m$ are, dimensionally, a square\nfrequency) premultiplying both members by the transpose of the\ncoefficient matrix we write\n\\[\\left\\{\n  \\begin{matrix}\n    +4 \\cdot k & -\\SI{2600}{\\per\\second\\squared} \\cdot m &=&\n    \\SI{-55.058e6}{\\newton\\per\\metre}\\\\\n     - \\SI{2600}\\cdot k &+ \\SI{45780000}{\\per\\second\\squared} \\cdot m &=&\\SI[retainplus]{+416.14e+9}{\\newton\\per\\metre}\n  \\end{matrix}\n\\right.,\\]\nwhere the second equation was multiplied by \\si{\\second\\squared}.\n\nSolving the previos linear system gives the best estimates\n${\\color{red}k=\\SI{111.78e6}{\\newton\\per\\metre}}$ and\n${\\color{red}m={39854}{\\kg}}$, in good agrement with the data entered in\nthe simulation. The damping ratio, computations omitted, is\n${\\color{red}\\zeta\\approx3.8\\%}$.\n% +++++++++++++++++++++++++++++++++++++++++++\n\\section{Generalised Coordinates (rigid bodies)}\n\n%\\[\\resizebox{0.8\\textwidth}{!}{\\input{xfig/newtrab.pdf_t}}\\]\n\\[\\input{xfig/newtrab.pdf_t}\\]\n\n\\renewcommand{\\ss}{\\textsf}\n\\noindent The articulated system in figure, composed by\n\\begin{itemize}\n\\item two rigid bars, \\begin{enumin}\\item \\textsf{ABC} and\n  \\item\\textsf{CDE},\n  \\end{enumin}\n\\item three fixed constraints,\n  \\begin{enumin}\n  \\item a horizontal roller in \\textsf{A},\n  \\item an internal hinge in \\textsf{C} and\n  \\item a hinge in \\textsf{E},\n  \\end{enumin}\n\\item two deformable constraints,\n  \\begin{enumin}\n  \\item a horizontal spring in \\textsf{A}, its stiffness${}=k$ and\n  \\item a vertical dashpot in \\textsf{C}, its damping\n    coefficient${}=c$,\n  \\end{enumin}\n\\end{itemize}\nis excited by a horizontal harmonic  force applied in \\textsf{B},\n\\(p(t)=p_0\\,\\sin\\omega t.\\)\n\nThe vertical parts of the two bars, \\textsf{AB} and \\textsf{ED}, are\nmassless while both the horizontal parts, \\textsf{BC} and \\textsf{CD},\nhave a constant unit mass $\\overline m$, with $\\overline m\\,L=m$.\n\n\\medskip\\noindent Using $u_\\textsf{A}$ (the horizontal displacement of\n\\textsf{A}) as the generalised coordinate\n\\begin{enumerate}\n\\item compute the generalised parameters $m^*$,  $c^*$ and $k^*$,\n\\item compute the generalised loading $p^*(t)$ and\n\\item write the equation of dynamic equilibrium.\n\\end{enumerate}\n\\subsection{Solution}\nOur sistem of reference will be centred in \\textsf A, so that the\npositions of the Center of Instantaneous Rotation (CIR) for the two\nrigid bodies are $\\Omega_1=(0,3L)$ and\n$\\Omega_2=(3L,0)\\equiv\\textsf{E}$. Using $Z=u_\\ss A$ as our free\ncoordinate, the rotation about $\\Omega_1$ is $\\theta_1=+1/3\\,Z/L$, the\nrotation about $\\Omega_2$ is $\\theta_2=-2/3\\,Z/L$ (anticlockwise\nrotations are positive), and then we can compute the relevant\ndisplacements\n\n\\medskip\n\\centerline{\\begin{tabular}{ccc}\n  \\toprule\n  & $u/Z$ & $v/Z$\\\\\n  \\midrule\n  \\ss A           & 1 & 0\\\\\n  \\ss B           & 2/3 & 0\\\\\n  \\ss C           & 2/3 & 2/3\\\\\n  $\\ss G_1$  & 2/3 & 1/3\\\\\n  $\\ss G_2$  & 2/3 & 1/3\\\\\n  \\bottomrule\n\\end{tabular}}\n\n\\medskip For equilibrium, the external virtual work $\\delta W_\\text E$ (work of\nthe external, spring, damper and inertial forces) equals to the\ninternal virtual work, $\\delta W_\\text I$ but for a rigid system it is\n$\\delta W_\\text I = 0$, hence our equilibrium equation is\n\\[\\delta W_\\text E = 0.\\]\n\nIn detail,\n\\begin{multline*}\n  p(t)\\,\\frac23\\delta Z + (-kZ)\\,\\delta Z + (-c\\frac23\\dot Z)\\,(\\frac23\\delta Z) +\\\\\n  (-(2m)\\frac23\\ddot Z)\\,(\\frac23\\delta Z) + (-(2m)\\frac13\\ddot Z)\\,(\\frac13\\delta Z) +\n  (-\\frac{2m(2L)^2}{12}\\frac{\\ddot Z}{3L})\\,(\\frac{1}{3L}\\delta Z) +\\\\\n  (-m\\frac23\\ddot Z)\\,(\\frac23\\delta Z) + (-m\\frac13\\ddot Z)\\,(\\frac13\\delta Z) +\n  (\\frac{mL^2}{12}\\frac{2\\ddot Z}{3L})\\,(-\\frac2{3L}\\delta Z) = 0\n\\end{multline*}\nsimplyfying $\\delta Z$, collecting $Z$ and its derivatives, moving\n$Z$'s on the right side of the equation, it is\n\\begin{align*}\n  \\frac23 p(t) &= k\\,Z + \\frac49c\\,\\dot Z + (\\frac89+\\frac29+\\frac2{27}+\\frac49+\\frac19+\\frac1{27})m\\,\\ddot Z\\\\\n               &= \\frac{16}9m\\,\\ddot Z + \\frac49c\\,\\dot Z + k\\,Z\n\\end{align*}\n\nThe required answers are \n\\[\\color{red}\nm^*=\\frac{16}9m,\\quad c^*=\\frac49c,\\quad k^*=k,\\quad p^*=\\frac23p(t),\n\\] and\n\\[\\color{red} \\frac{16}9m\\,\\ddot Z + \\frac49c\\,\\dot Z + k\\,Z =\n\\frac23p(t)\\]\n% +++++++++++++++++++++++++++++++++++++++++++\n\\section{Rayleigh quotient}\n\\label{sec:rayleigh}\n\\[\\input{xfig/newtrab2.pdf_t}\\]\n\\noindent The undamped 3 \\emph{DOF} system in figure is composed of 3\nidentical rigid bars, their masses $m_i=m$, and three vertical\nsprings, their stiffnesses as detailed in figure.  Starting with a\ntrial shape $\\bm{\\phi}= \\begin{Bmatrix} 1 & 1 & 1\n\\end{Bmatrix}^T$ so that $u_1=u_2=u_3=Z_0\\,\\sin\\omega t$, give the successive\nRayleigh estimates of (squared) free vibration circular frequency\n$R_{00}$, $R_{01}$ and $R_{11}$. \n\nNote\n\\begin{enumin}\n\\item that the bars have a not negligible rotatory inertia:\n  $J_i=mL^2/12$, that you must take into account and\n\\item that the free coordinates are not referred to the centres of\n  mass of the bars (hence a non-diagonal mass matrix).\n\\end{enumin}\n\n\\smallskip\\noindent\\textsc{Hint:} {\\small\n %\n  the nodal inertial forces are $\\bm f_\\text{I}=\\bm M\\,\\ddot{\\bm u}$,\n  the mass matrix's coefficients can be deduced comparing an explicit\n  derivation of the kinetic energy $T$ in terms of the velocities\n  $\\dot u_i$, the mass $m$ and the inertia $J$ to the matrix\n  expression $T=\\frac12 \\dot{\\bm u}^T \\bm M\\,\\dot{\\bm u} = \\frac12\n  \\left( m_{11}\\, \\dot x_1^2 +\\cdots+(m_{12}+m_{21})\\,\\dot x_1 \\dot x_2 +\n    \\cdots \\right)$, where $m_{ij}=m_{ji}$.}\n\n\\subsection{Solution}\n\nThe displacements $x_i$ of the 3 centres of mass are \n\\begin{align*}\n  x_1&=u_1/2,      &x_2&=(u_2+u_1)/2&x_3&=(u_3+u_2)/2),\\\\\n  \\intertext{the rotations $\\theta_i$ are}\n  \\theta_1&=u_1/L, &\\theta_2&=(x_2-x_1)/L&\\theta_3&=(x_3-x_2)/L. \n\\end{align*}\n\nThe kinetic energy is, summing the contributions from the three\nidentical bars,\n\\begin{align*}\n  T&=\\frac12\\left(m(\\dot x_1^2 + \\dot x_2^2 + \\dot\n    x_3^2)+\\frac{mL^2}{12}(\\dot\\theta_1^2 + \\dot\\theta_2^2 +\n    \\dot\\theta_3^2)\\right).\\\\\n  \\intertext{Substituting the free coordinates, simplifying and\n    collecting the similar terms, it is}\n  T&=\\frac12\\,\\left(8\\,\\dot u_1^2 + 8\\,\\dot u_2^2 + 4\\,\\dot u_3^2 +\n    4\\, \\dot u_1 \\dot u_2 + 4\\, \\dot u_2 \\dot u_3 + 0\\, \\dot u_3 \\dot\n    u_1\\right)\\,\\frac m{12}.\n\\end{align*}\n\nThe kinetic energy can be expressed also by a matrix product,\n\\[T=\\frac12\\,\\bm u^T\\bm M\\,\\bm u=\\frac12\\left(m_{11}\\dot u_1^2\n  +\\cdots+2\\,m_{12}\\dot u_1 \\dot u_2 + \\cdots\\right),\\]\n\nequating the two right members term by term, we deduce that the mass\nmatrix coefficients are as in\n\\[\\bm M =\\frac m6 \\begin{bmatrix}  4&1&0\\\\1&4&1\\\\0&1&2 \\end{bmatrix}.\\]\n\nThe stiffness matrix, simply, is\n\\[\\bm K = k \\begin{bmatrix} 1&0&0\\\\0&2&0\\\\0&0&3 \\end{bmatrix}.\\]\n\nThe Rayleigh procedure starts writing\n\\begin{align*}\n  \\bm{u}(t)&=\\bm{\\phi} Z_0 \\sin\\omega t,&\\dot{\\bm u}(t)&=\\omega\\bm\\phi Z_0 \\cos\\omega t,\\\\\n  V&=\\frac12\\bm\\phi^T\\bm{K}\\,\\bm\\phi\\,Z_0^2\\sin^2\\omega{}t,&\n  T&=\\frac12\\omega^2\\bm\\phi^T\\bm{M}\\,\\bm\\phi\\,Z_0^2\\cos^2\\omega{}t,\n\\end{align*}\nso that, by equating the maximum values of energies $V$ and $T$ and\nsubstituting $\\bm\\phi=\\begin{Bmatrix}1&1&1\\end{Bmatrix}^T$ we have\n\\[\\omega^2=\\frac{\\bm\\phi^T\\bm{K}\\,\\bm\\phi}{\\bm\\phi^T\\bm{M}\\,\\bm\\phi}=\\frac{6k}{7/3\\;m}=\\frac{18}7\\frac\nkm=\\color{red}2.5714\\frac km.\\]\n\nA better approximation of the strain energy is given by\n\\[V=\\frac12\\bm{u}_\\text{I}^T\\bm{f}_\\text{I}^{},\\] where\n\\(\\bm{f}_\\text{I}=-\\omega^2\\bm{M}\\bm{\\phi}Z_0\\sin\\omega{t}\\) is the\nvector of the inertial forces and\n\\(\\bm{u}_\\text{I}=\\bm{K}^{-1}\\bm{f}_\\text{I}=-\\omega^2\\bm{K}^{-1}\\bm{M}\\bm{\\phi}Z_0\\sin\\omega{t}\\)\nis the vector of displacements produced by $\\bm{f}\\text{I}$.\n\nEquating the new maximum value of the strain energy to the old kinetic\nenergy maximum, it is\n\\[\\omega^2=\\frac{\\bm\\phi^T\\bm{M}\\,\\bm\\phi}{\\bm\\phi^T\\bm{M}\\,\\bm{K}^{-1}\\bm{M}\\bm\\phi}=\n\\frac{7/3\\;m}{23/18\\;m^2/k}=\\frac{42}{23}\\frac\nkm=\\color{red}1.8261\\frac km.\\]\n\nA better approximation to the kinetic energy is given by\n\\[T=\\frac12 \\dot{\\bm{u}}_\\text{I}^T\\bm{M}\\,\\dot{\\bm{u}}_\\text{I},\\]\nwhere \\(\\dot{\\bm{u}}_\\text{I}=-\\omega^3\\bm{K}^{-1}\\bm{M}\\bm{\\phi}Z_0\\cos\\omega{t}\\)\nis the velocity due to  application of the inertial\nforces, equating the new max of $T$ to the new max of $V$ we have\n\\[\\omega^2=\\frac{\\bm\\phi^T\\bm{M}\\,\\bm{K}^{-1}\\bm{M}\\bm\\phi}{\\bm\\phi^T\\bm{M}\\,\\bm{K}^{-1}\\bm{M}\\,\\bm{K}^{-1}\\bm{M}\\bm\\phi}\n  =\\frac{23/18\\;m^2/k}{29/36\\;m^3/k^2}=\\frac{46}{29}\\frac\n  km=\\color{red}1.5862\\frac km.\\]\n% +++++++++++++++++++++++++++++++++++++++++++\n\\section{3 DOF System}\nWith reference to the system of problem \\ref{sec:rayleigh}, using the\nposition \\(\\omega_0^2=\\displaystyle\\frac km\\)\n\\begin{enumerate}\n\\item compute the three eigenvalues of the system and the\n  corresponding eigenvectors,\n\\item normalize the eigenvectors with respect to the mass matrix $\\bm\n  M$ (it must be $\\bm\\psi^T\\,\\bm M\\,\\bm\\psi = m$).\n\\end{enumerate}\nConsidering that the system is at rest for $t=0$ and is then loaded by\na load vector \\(\\bm p(t)\\),\n\\[\\bm p(t) = \\frac{kL}{200}\n\\begin{Bmatrix}\n  0\\\\-1\\\\+1\n\\end{Bmatrix}\n  \\sin(7\\omega_0 t),\n\\]\n\\begin{enumerate}[resume]\n\\item find the analytical expression of $u_3=u_3(t)$, showing your\n  intermediate results and\n\\item plot $u_3$ in the interval $0 \\le \\omega_0\\,t \\le 6$.\n\\end{enumerate}\n\n\\subsection{Solution}\n\nUsing the previously computed structural matrices, the eigenvalues are\nthe roots of the equation\n\\[\\det\\left(k \\begin{bmatrix} 1&0&0\\\\0&2&0\\\\0&0&3 \\end{bmatrix}\n- \\omega^2\\frac m6 \\begin{bmatrix}  4&1&0\\\\1&4&1\\\\0&1&2\\end{bmatrix}\\right)=0\\]\nwith the position $\\omega^2=\\Lambda\\omega^2_0$, developing the\ndeterminant, simplifying etc it is\n\\[13\\Lambda^3-204\\Lambda^2+720\\Lambda-648=0,\\]\nsolving for the $\\Lambda_i$ and substituting it is\n\\[\\color{red}\n\\omega^2_1=1.4185\\omega^2_0,\\quad \\omega^2_2=3.1619\\omega^2_0,\\quad \\omega^2_3=11.112\\omega^2_0.\\]\n\nFor algebraic manipulations, it is often convenient to collect the\neigenvalues in a diagonal matrix\n\\[\\bm\\Lambda=\\omega^2_0\\begin{bmatrix}1.4185&0&0\\\\0&3.1619&0\\\\0&0&11.112\\end{bmatrix}.\\]\n\nThe eigenvectors are given by solving the following linear systems\n\\[\\left(k \\begin{bmatrix} 1&0&0\\\\0&2&0\\\\0&0&3 \\end{bmatrix}\n- \\omega^2_i\\frac m6 \\begin{bmatrix}\n  4&1&0\\\\1&4&1\\\\0&1&2\\end{bmatrix}\\right)\\,\\bm\\psi_i=0,\\quad\ni=1,2,3.\\]\n\nNormalising and collecting the eigenvectors in an eigenvector matrix\n$\\bm\\Psi$, \n\\[\\color{red}\\bm\\Psi=\n\\begin{bmatrix}\n  +1.1324&-0.5408&+0.2015\\\\\n  +0.2594&+1.1369&-0.6973\\\\\n  +0.0243&+0.3079&+1.8347\n\\end{bmatrix}.\\]\n\nThe steady state response, $\\bm{x}_\\text{s-s}(t) = \\bm\\xi\\,\n\\sin\\omega{t}$, can be computed directly in terms of nodal coordinates\n\\[(\\bm K - \\omega^2\\bm{M})\\,\\bm\\xi\\,\\sin\\omega{t} =\n\\bm{p}\\,\\sin\\omega{t}\\quad\\Rightarrow\\quad\n\\bm{\\xi} = (\\bm K - \\omega^2\\bm{M})^{-1}\\bm{p}\\]\n\nSubstituting $\\omega^2=49\\omega_0^2$ let us write\n\\[\n\\left(k \\begin{bmatrix} 1&0&0\\\\0&2&0\\\\0&0&3 \\end{bmatrix}\n- \\frac{49}{6}\\omega^2_0 m \\begin{bmatrix}\n  4&1&0\\\\1&4&1\\\\0&1&2\\end{bmatrix}\\right)\\,\\bm\\xi\\sin(7\\omega_0 t)=\\frac{kL}{200}\n\\begin{Bmatrix}\n  0\\\\-1\\\\+1\n\\end{Bmatrix}\n  \\sin(7\\omega_0 t)\n\\]\ndividing all terms by $k$, simplifying $\\sin(7\\omega_0 t)$ and\n$\\omega_0^2\\frac mk=1$ and solving for $\\bm\\xi$ gives\n\\[\\bm\\xi=\\frac L{200}\\begin{bmatrix}\n -0.01765207\\\\\n +0.06844680\\\\\n -0.11692366\n\\end{bmatrix},\\qquad\n\\bm{x}_\\text{s-s}(t) =\\frac L{200}\\begin{bmatrix}\n -0.01765207\\\\\n +0.06844680\\\\\n -0.11692366\n\\end{bmatrix}\\,\\sin\\omega{t}.\n\\]\n\nNow, write the integral of the homogeneous problem as\n\\begin{align*}\n  \\bm{q}(t)&=\\begin{bmatrix}\\sin\\omega_1t&0&0\\\\0&\\sin\\omega_2t&0\\\\0&0&\\sin\\omega_3t\\end{bmatrix}\\,\\bm{a}\n  +\\begin{bmatrix}\\cos\\omega_1t&0&0\\\\0&\\cos\\omega_2t&0\\\\0&0&\\cos\\omega_3t\\end{bmatrix}\\,\\bm{b}\\\\\n  \\bm\\Lambda^{-\\frac12}\\,\\dot{\\bm{q}}(t)&=\\begin{bmatrix}\\cos\\omega_1t&0&0\\\\0&\\cos\\omega_2t&0\\\\0&0&\\cos\\omega_3t\\end{bmatrix}\\,\\bm{a}\n  -\\begin{bmatrix}\\sin\\omega_1t&0&0\\\\0&\\sin\\omega_2t&0\\\\0&0&\\sin\\omega_3t\\end{bmatrix}\\,\\bm{b}\n\\end{align*}\nand evaluate modal displacements and modal velocities at $t=0$\n\\begin{align*}\n  \\bm{q}_0&=\\bm{b},&\\dot{\\bm{q}}_0&=\\bm\\Lambda^{\\frac12}\\,\\bm{a}.\n\\end{align*}\n\nThe initial conditons in terms of nodal displacements, for a system\nstarting from rest conditions, are\n\\begin{align*}\n  \\bm{x}_0&=\\bm\\Psi\\,\\bm{q}_0+\\bm\\xi\\,\\sin\\omega0=\\bm0,&\n  \\dot{\\bm{x}}_0&=\\bm\\Psi\\,\\dot{\\bm{q}}_0+\\omega\\bm\\xi\\,\\cos\\omega0=\\bm0,\\\\\n  \\intertext{substituting the initial values of the modal coordinates}\n  \\bm\\Psi\\,\\bm{q}_0&=\\bm\\Psi\\,\\bm{b}=\\bm{0},&\n  \\bm\\Psi\\,\\dot{\\bm{q}}_0&=\\bm\\Psi\\,\\bm\\Lambda^{\\frac12}\\,\\bm{a}=-\\omega\\bm\\xi,\\\\\n  \\intertext{solving for $\\bm{a}$ and $\\bm{b}$}\n  \\bm{b}&=\\bm{0},   &    \\bm{a}&=-\\bm{\\Lambda}^{-\\frac12}\\omega\\left(\\bm{\\Psi}^T\\frac{\\bm{M}}{m}\\,\\bm\\xi\\right).\n\\end{align*}\n\nSubstituting the numerical values into the last equation we find\n\\[\\bm{a} = \\frac{L}{200}\n\\begin{Bmatrix}\n -0.02904676\\\\\n -0.07119805\\\\\n +0.14033766\n\\end{Bmatrix}.\\]\n\nFinally, $x_3(t)$ is a linear combination of the modal responses by the\nthird elements of the three eigenvectors, plus the steady state\nresponse $\\xi_3\\sin7\\omega_0$\n\\begin{align*}\n  {\\color{red} 200\\,x_3(t)/L}\n  & = \\psi_{31}a_1\\sin\\omega_1 t +  \\psi_{32}a_2\\sin\\omega_2 t\n  +  \\psi_{33}a_3\\sin\\omega_3 t +  \\xi_3\\sin\\omega t \\\\\n  & = (-0.0243\\cdot0.0290)\\,\\sin\\omega_1 t + (-0.3079\\cdot0.0712)\\,\\sin\\omega_2  t + \\\\\n  &\\qquad(+1.8347\\cdot0.1403)\\,\\sin\\omega_3 t -0.1169\\,\\sin\\omega t \\\\\n  & \\color{red} =\n  -0.000705\\,\\sin1.1911\\omega_0 -0.02192\\,\\sin1.7782\\omega_0 t +\\\\\n  & \\color{red}\n  \\qquad +0.2574789\\,\\sin3.3334\\omega_0 -0.11692366\\,\\sin7\\omega_0 t.\n\\end{align*}\n\nThe following short Python program computes and prints the response\nusing the linear acceleration algorithm, note that it is almost identical\nto the program used for the \\emph{SDOF} system of problem 2, except\nthe use of vectors and matrices and the adimensionalisation of all\nphysical quantities.\n\\lstinputlisting{06/numeric.py}\nIn the plot below, you can compare the results of the numerical\nintegration with the results of the analytical derivation and gain\nsome confidence in the correctness of both  derivations.\n%\n%\\smallskip\n\\begin{center}%\n\\makebox[\\textwidth]{\\includegraphics{06/comparison}}%\n\\end{center}\\end{document}\n%%% Local Variables: \n%%% mode: latex \n%%% TeX-master: t\n%%% End: \n", "meta": {"hexsha": "94c05a49417c719ab73d43bfa5668e49a5401a5f", "size": 23879, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "dati_2011/ha01/hasol.tex", "max_stars_repo_name": "shishitao/boffi_dynamics", "max_stars_repo_head_hexsha": "365f16d047fb2dbfc21a2874790f8bef563e0947", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dati_2011/ha01/hasol.tex", "max_issues_repo_name": "shishitao/boffi_dynamics", "max_issues_repo_head_hexsha": "365f16d047fb2dbfc21a2874790f8bef563e0947", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dati_2011/ha01/hasol.tex", "max_forks_repo_name": "shishitao/boffi_dynamics", "max_forks_repo_head_hexsha": "365f16d047fb2dbfc21a2874790f8bef563e0947", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-23T12:32:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-15T18:33:55.000Z", "avg_line_length": 40.1327731092, "max_line_length": 143, "alphanum_fraction": 0.6733531555, "num_tokens": 9060, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665855647395, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.4221162095219497}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{amsfonts}\n%\\usepackage{mathptmx}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{comment}\n\n%\\usepackage{pgfplots}\n%\\pgfplotsset{width=10cm, compat=1.9}\n%\\documentclass[border=2mm,tikz]{standalone}\n%\\usetikzlibrary{datavisualization}\n\n\\usepackage[onehalfspacing]{setspace}\n\\usepackage{fancyhdr}\n\\usepackage{comment}\n\\usepackage[a4paper, top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]%\n{geometry}\n\\usepackage{times}\n\\usepackage{amsmath}\n\\usepackage{changepage}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\\setcounter{MaxMatrixCols}{30}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{acknowledgement}[theorem]{Acknowledgement}\n\\newtheorem{algorithm}[theorem]{Algorithm}\n\\newtheorem{axiom}{Axiom}\n\\newtheorem{case}[theorem]{Case}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{conclusion}[theorem]{Conclusion}\n\\newtheorem{condition}[theorem]{Condition}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{criterion}[theorem]{Criterion}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{exercise}[theorem]{Exercise}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{notation}[theorem]{Notation}\n\\newtheorem{problem}[theorem]{Problem}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{solution}[theorem]{Solution}\n\\newtheorem{summary}[theorem]{Summary}\n\\newenvironment{proof}[1][Proof]{\\textbf{#1.} }{\\ \\rule{0.5em}{0.5em}}\n\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\n\\begin{document}\n\n\\title{MAT120: Integral Calculus and\nDifferential Equations \\\\\nBRAC University}\n\n\\author{Syed Zuhair Hossain \\\\ St. ID - 19101573 \\\\ Section - 07 \\\\ Set-Q \\\\ Assignment - 04}\n\\date{\\today}\n\\maketitle\n\n%%%%%%%%%%%Starting Point%%%%%%%%%%%%%%%\n\n%%%%%MATH 01%%%%%%%%%%%%\n\\section{Evaluate the integral \\\\[5mm]\n        $\\int_{1}^{2} \\int_{z}^{2} \\int_{0}^{\\sqrt{3}y} \\frac{y}{x^2 + y^2} \\ dx \\ dy \\ dz$\n        }\n\n\\textbf{Solution \\ :}\n\\begin{align*}\n    Let,\\\\\n    &u = \\frac{x}{y} & \\Rightarrow x^2 = y^2 u^2\\\\\n    &du = \\frac{1}{y} dx\\\\\n    \\therefore \\ &dx = y \\ du\n\\end{align*}\n\n\\begin{align*}\n    \\therefore \\ \\int \\frac{y}{x^2 + y^2} \\ dx &= \\int \\frac{y^2}{y^2 u^2 + y^2 } du \\\\\n    &= \\int \\frac{y^2}{u^2 + 1} du\\\\\n    &= \\int \\frac{1}{u^2 +1} du\\\\\n    &= tan^{-1}(u)\\\\\n    &= tan^{-1}\\frac{x}{y}\n\\end{align*}\n\n\\begin{align*}\n    &\\int_{1}^{2} \\int_{2}^{3} (\\frac{\\pi}{3}) dy dx\\\\[3mm]\n    &= \\int_{1}^{2} \\frac{\\pi}{3} \\times [y]_{z}^{2} \\ dz\\\\[3mm]\n    &= \\int_{1}^{2} \\frac{\\pi}{3} (2-z) dz\\\\[3mm]\n    &= \\int_{1}^{2} \\frac{2\\pi}{3} dz - \\int_{1}^{2} \\frac{\\pi}{3} z dz\\\\[3mm]\n    &= \\frac{2\\pi}{3} \\int_{1}^{2} dz - \\frac{\\pi}{3} \\int_{1}^{2} z dz\\\\[3mm]\n    &= \\frac{2\\pi}{3} \\int_{1}^{2} dz - \\left[ \\frac{\\pi}{3} \\times \\frac{z^2}{2}\\right]_{1}^{2}\\\\\n    &= \\frac{2\\pi}{3} \\int_{1}^{2} dz + (- \\frac{4 \\pi}{6} + \\frac{1 \\cdot \\pi }{6})\\\\[3mm]\n    &= \\frac{2\\pi}{3} \\int_{1}^{2} dz - \\frac{\\pi}{2}\\\\[3mm]\n    &= \\frac{2 \\pi \\times 2}{3} - \\frac{2\\pi \\cdot 1}{3} - \\frac{\\pi}{2}\\\\[3mm]\n    &= \\frac{2\\pi}{3} - \\frac{\\pi}{2}\\\\[3mm]\n    &= \\frac{4\\pi-3\\pi}{6}\\\\[3mm]\n    &= \\frac{\\pi}{6} &[Answer]\n\\end{align*}\n%%%%%%%%%%%%%%%%%%%%%%%\n\\pagebreak \n\\section{Solve}\n\\centering $(x+1) \\frac{dy}{dx} + y = lnx, y(1) = 10$\n\n\\renewcommand{\\baselinestretch}{2.0}\n\\begin{align*}\n    \\textbf{Converting into standard form:}&\\\\\n    & \\frac{dy}{dx} + \\left(\\frac{1}{x+1}\\right) y = \\frac{ln(x)}{(x+1)} \\ \\ \\ \\ \\ \\ \\ \\ \\ [\\textit{dividing by (x+1) in both side}]\\\\\n    \\textbf{according to the formula}&\\\\\n    &y{'} + \\rho (t) y = g(t)\\\\\n    \\therefore \\rho(x) &= e^{\\int \\frac{1}{x+1}dx}\\\\\n    &= e^{ln(x+1)}\\\\\n    &= (x+1)\\\\\\\\\n    \\raggedright\\therefore (x+1) y &= \\int ln(x)dx\\\\\n    \\Rightarrow(x+1)y &= xln(x) - x + c\\\\\n    \\therefore y &= \\frac{x(ln(x)-x+c)}{x+1}\\\\\n    \\textbf{apply the given condition,}\\\\\n    &y(1) = 10\\qquad  x=1\\\\\n    &\\Rightarrow \\frac{1\\times ln(1)-1+c}{1+1} = 10\\\\\n    &\\Rightarrow \\frac{0-1+c}{2} = 0\\\\\n    &c = 21\\\\\n    &\\therefore y = \\frac{xln(x) - x + 21}{(x+1)}\\qquad \\textbf{[Answer]}\n\\end{align*}\n\\pagebreak\n\n\\raggedright\\section{Evaluate \\qquad $\\int_{1}^{4} \\int_{0}^{\\sqrt{x}}\\frac{3}{2} e^{\\frac{y}{\\sqrt{x}}} dy dx$}\n\n\\begin{align*}\n    &= \\int_{1}^{4} \\frac{3}{2} \\left[e^{\\frac{y}{\\sqrt{x}} \\times \\sqrt{x}}\\right]_{0}^{\\sqrt{x}} dx\\\\\n    &= \\int_{1}^{4} \\frac{3}{2} \\left[e^1 \\cdot \\sqrt{x} - e^0 \\cdot \\sqrt{x}\\right] dx\\\\\n    &= \\int_{1}^{4} \\frac{3}{2} (e\\sqrt{x} - \\sqrt{x}) dx\\\\\n    &= \\int_{1}^{4} \\frac{3}{2} \\times \\sqrt{x} \\times (e-1) dx\\\\\n    &= \\frac{3}{2} \\int_{1}^{4} \\sqrt{x} (e-1) dx\\\\\n    &= \\frac{3}{2} \\times (e-1) \\int_{1}^{4}\\sqrt{x} dx\\\\\n    &= \\frac{3}{2}(e-1) [\\frac{2x^\\frac{3}{2}}{3}]_{1}^{4}\\\\\n    &= (e-1) [x^{\\frac{3}{2}}]_{1}^{4}\\\\\n    &= (e-1) [4^{\\frac{3}{2}}-1]\\\\\n    &= 7(e-1)\\\\\n    &\\approx 12.0279728 \\hspace{100} \\textbf{[Answer]}\n\\end{align*}\n\\pagebreak\n\n\\section{Solve the differential equation using variables separable method : \\qquad x^{2} \\frac{dy}{dx} =y-xy; y(-1) = -1.}\n\n\\begin{align*}\n    &\\Rightarrow x^2 \\frac{dx}{dy} = y(1-x)\\\\\n    &\\Rightarrow \\frac{1}{y} \\frac{dy}{dx} = \\frac{1-x}{x*2} = \\frac{1}{x^2} - \\frac{1}{x}\\\\\n    &\\Rightarrow \\int y^{-1} dy = \\int \\frac{(1-x)}{x^2} dx\\\\\n    \\textit{Now, integrating both sides,}\\\\\n    &\\int \\frac{dy}{y} = \\int \\frac{1}{x^2}dx - \\int \\frac{1}{x} dx\\\\\n    &\\Rightarrow ln(y) = - \\frac{1}{x} - ln(x) + c\\\\\\\\\n    \\textbf{Given that,}\\\\\n    &y=-1 \\hspace{20} x=-1\\\\\n    &\\therefore ln|-1| = \\frac{-1}{-1} - ln|-1| + c\\\\\n    &\\Rightarrowln(1) = 1- ln(1) + c\\\\\n    &\\therefore c=0\\\\\\\\\n    &\\therefore log y = \\frac{1}{x} - log(x)-1\\\\\n    &\\Rightarrow log(y) + log(x) = - \\frac{1}{x} - 1\\\\\n    &\\Rightarrow log(yx) = - \\frac{1}{x} -1\\\\\n    &\\Rightarrow yx = e^{-\\frac{1}{x} -1}\\\\\n    &\\Rightarrow yx = e^{\\frac{-1}{x}} e^{-1}\\\\\n    &\\Rightarrow y = \\frac{e^{\\frac{-1}{x}}}{e^{x}}\\hspace{25} \\textbf{[Answer]}\n\\end{align*}\n\n\\newpage\n\n\\section{Evaluate the integral: \\qquad \\int_{0}^{\\frac{\\pi}{4}} \\int_{0}^{1} \\int_{0}^{x^2} x cosy \\ dz \\ dx \\ dy }\n\n\\begin{align*}\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\int_{0}^{1} [x z cos y]_{0}^{x^2} dx dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\int_{0}^{1} (x \\cdot x^2 cosy - x \\cdot 0 \\cdot cosy) dx dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\int_{0}^{1} x^3 cosy dx dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} cosy \\int_{0}^{1} x^3 dx dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\left[\\frac{x^4}{4} cos(y)\\right]_{0}^{1}dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\left[\\frac{x^4}{4} cos(y) - \\frac{0}{4} cos(y) \\right]dy\\\\\n    &= \\int_{0}^{\\frac{\\pi}{4}} \\frac{cosy}{4} dy\\\\\n    &= \\frac{1}{4} \\int_{0}^{\\frac{\\pi}{4}} cos \\ y \\ dy\\\\\n    &= \\left[\\frac{1}{4} \\times sin y\\right]_{0}^{\\frac{\\pi}{4}}\\\\\n    &= \\left[\\frac{1}{4} \\times sin y \\right]_{0}^{\\frac{\\pi}{4}}\\\\\n    &=(\\frac{1}{4} sin \\frac{\\pi}{4} - \\frac{1}{4} sin(0))\\\\\n    &= \\frac{1}{4} \\times \\frac{1}{\\sqrt{2}} -0\\\\\n    &= \\frac{1}{4\\sqrt{2}}\\\\\n    \\bigbreak\n    &\\hspace{200} \\textbf{[Answer]}\n\\end{align*}\n\n\\pagebreak\n\n\\section{Solve the system for x and y in terms of u and v then find the Jacobian $\\frac{\\partial(x,y)}{\\partial(u,v)} .$} \n\\centering \\bigtitle{\\textbf{u = x-y; v = 2x+y}}\n\n\\begin{align*}\n    Here,\\\\\n    &u = x-y............(1)\\\\\n    &v = 2x+y...........(2)\n\\end{align*}\n\n\\begin{align*}\n    \\textit{adding equation (1) and (2) we get,}&\\\\\n    & u + v = 3x\\\\\n    & x = \\frac{u+v}{3}\\\\\n    & x = \\frac{u}{3} + \\frac{v}{3}\\\\\n\\end{align*}\n\n\\begin{align*}\n    \\textit{Again, extracting equation (2) from (1) we get,}&\\\\\n    & v-u = 2y -x\\\\\n    & 2y = v-u +x\\\\\n    & 2y = v - u + \\frac{u}{3} + \\frac{v}{3}\\\\\n    & y = \\frac{3v-3u+u+v}{3 \\times 2}\\\\\n    & y = \\frac{4v-2u}{6}\\\\\n    & y = \\frac{2v}{3} - \\frac{1\\cdot u}{3}\n\\end{align*}\n\\pagebreak\n\\begin{align*}\n    &\\frac{\\partial x}{\\partial u} =\\frac{1}{3} & \\frac{\\partial y}{\\partial u} = -\\frac{2}{3}\\\\\n    &\\frac{\\partial x}{\\partial v} =\\frac{1}{3} & \\frac{\\partial y}{\\partial u} = \\frac{1}{3}\\\\\n\\end{align*}\n\n\\begin{equation*}\n    \\textbf{Jacobian,J}\n    =\\frac{\\partial(x,y)}{\\partial(u,v)} \n    = \\begin{vmatrix}\n    \\frac{\\partial x}{\\partial u} & \\frac{\\partial y}{\\partial u}\\\\ \n    \\frac{\\partial x}{\\partial v} & \\frac{\\partial y}{\\partial u}\n    \\end{vmatrix}\n    = \n    \\begin{vmatrix}\n    \\frac{1}{3} & -\\frac{2}{3}\\\\ \n    \\frac{1}{3} & \\frac{1}{3}\n    \\end{vmatrix}\n    = \\frac{1}{3} \\times \\frac{1}{3} - \\left(-\\frac{2}{3} \\right) \\times \\frac{1}{3}\n    =\\frac{1}{9} + \\frac{2}{9} = \\frac{1}{3}\n\\end{equation*}\n\\bigbreak\n\\centering \\title{\\textbf{[Answer]}}\n\\end{document}\n", "meta": {"hexsha": "c156248034e4a549097e8c2d00b2fabe5000a985", "size": 8578, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MAT120 Assignments/Assignment-04/main.tex", "max_stars_repo_name": "ZuhairHossain/LaTeX-Projects", "max_stars_repo_head_hexsha": "cf8279293abae776cb9d022e04a201e39302310c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MAT120 Assignments/Assignment-04/main.tex", "max_issues_repo_name": "ZuhairHossain/LaTeX-Projects", "max_issues_repo_head_hexsha": "cf8279293abae776cb9d022e04a201e39302310c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MAT120 Assignments/Assignment-04/main.tex", "max_forks_repo_name": "ZuhairHossain/LaTeX-Projects", "max_forks_repo_head_hexsha": "cf8279293abae776cb9d022e04a201e39302310c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.0420168067, "max_line_length": 134, "alphanum_fraction": 0.5486127302, "num_tokens": 3693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555714, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.4219962932919367}}
{"text": "\\documentclass[a4paper]{article}\n\n%% Language and font encodings\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[T1]{fontenc}\n\n%% Sets page size and margins\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=1.75cm,right=2cm,marginparwidth=1.75cm]{geometry}\n\n%% Useful packages\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{braket}\n\\usepackage{scalerel}\n\n\n\n\\title{\\vspace{-2.0cm}Notes about VSVB energy}\n\\author{\\vspace{-2.0cm}Colleen Bertoni, Graham Fletcher}\n\n\\begin{document}\n\\maketitle\n\n\n\n\\section{Implemented energy calculation}\n\nWithout giving too much detail, for a VSVB wave function with $N$ electrons,  $N_p$ spin coupled pairs, and $N_{sc}$ spin couplings, the VSVB energy can be written:\n\\begin{equation}\n \\begin{aligned}\n E &= \\\\\n =& \\frac{ \n  \\begin{aligned} &\\sum_{ij}^{N} (\\sum_q^{M_{sc}} d^1_{q,ij} w_{q,ij} ) h_{s,ij}                                                                                                                                               \n    + \\sum_i^{N}\\sum_{j<i}\\sum_k^{N}\\sum_{l<k}                                                                                                                                                                               \n         \\left(\\sum_q^{M_{sc}} d^2_{q,ikjl}                                                                                                                                                                                          \n          (  w_{q,ikjl} \\left< \\phi_i(1) \\phi_j(2) | \\phi_k(1) \\phi_l(2) \\right>_s                                                                                                                                                                                  \n           - w_{q,iljk} \\left< \\phi_i(1) \\phi_j(2) | \\phi_l(1) \\phi_k(2) \\right>_s \\right) \n            \\end{aligned}\n     }\n     { \\displaystyle \\sum_{ij}^{N} (\\sum_q^{M_{sc}} d^1_{q,ij} w_{q,ij} ) \\left< \\phi_i(1) | \\phi_j(1) \\right>_s / N}                                                                                                                                                             \n \\end{aligned}\n \\end{equation}\n\nwhere \n\\begin{itemize}\n\\item $M_{sc} = N_{sc}^2 2^{2N_p}$ if there are spin couplings, $M_{sc} = 1$ if there are no spin couplings\n\\item $\\phi$ is a one-electron spin orbital\n\\item $h_{s,ij} = \\left< \\phi_i(1) | h_s | \\phi_j(1) \\right>  $ where h is the standard one-electron integral. The s subscript is meant to denote that this integral does not include spin. ($w_{q,ij}$ contains the corresponding spin function integration)\n\\item $d^1_{q,ij} $ is the first-order cofactor of the matrix of overlap integrals between spin orbitals. That is, it is the determinant of the overlap matrix with row i and column j removed, multiplied by $(-1)^{i+j}$ . $q$ denotes the term in the spin coupling/pairs expansion \n\\item $w_{q,ij}$ is the spin function integration, where the spin functions are $\\alpha$ or $\\beta$, whichever are associated with spin orbital $\\phi_i(1)$ and $\\phi_j(1)$. $q$ denotes the term in the spin coupling/pairs expansion\n\\item $ \\left< \\phi_i(1) \\phi_j(2) | \\phi_k(1) \\phi_l(2) \\right>_s$ is the electron-electron repulsion integral. the s subscript is meant to denote that this integral does not include spin integration (this is in the \"w\" variable)\n\\item $d^2_{q,ikjl} $ is the second-order cofactor of the matrix of overlap integrals between the spin orbitals. That is, it is the determinant of the overlap matrix with row i, column k, row j, and column l removed multiplied by $(-1)^{i+j+k+l}$. $q$ denotes the term in the spin coupling/pairs expansion\n\\item $ w_{q,ijkl} $ is the spin function integration, where the spin functions are alpha or beta, whichever are associated with spin orbitals $\\phi_i(1),\\phi_k(1),\\phi_j(2),\\phi_l(2)$. $q$ denotes the term in the spin coupling/pairs expansion\n\\end{itemize}\n\nThe rest of the notes show where this expression comes from.\n\n\\section{General energy expression}\n\nThe VSVB wave function with one spin coupling is defined as an antisymmetrized product of orbitals, where some are double occupied, some contain spin coupled electron pairs, and some contain unpaired electrons:\n\n\\begin{equation}\n \\begin{aligned}\n \\Psi_{VSVB} = &\\hat{A} \\{ \\Xi_{(docc+unpaired)}\\Phi_{sc} \\} \n \\label{init_wave}\n \\end{aligned}\n \\end{equation}\n     \n     \\begin{itemize}\n     \\item $\\Xi_{(docc+unpaired)} $ is a product of double occupied orbitals and singly occupied orbitals with unpaired electrons.\n     \n     Expanding, $\\Xi_{(docc+unpaired)} = \\phi_1(1)\\alpha(1)\\phi_1(2) \\beta(2)\\phi_2(3)\\alpha(3)\\phi_2(2) \\beta(4)...$.\n     \n     where $\\phi$ is a spatial orbital with no spin coordinates\n     \n     \\item $\\Phi_{sc}$ is the weighted sum of products of spin-coupled pairs of spin orbitals. \n     That is, for $N_{sc}$ spin couplings and $N_p$ spin coupled pairs (so $2*N_p$ total orbitals) , \n     \n     $\\displaystyle \\Phi_{sc} = \\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...\\sum_m^{N_{sc}} C_m \\Theta_m(i,j,k,l,...)  $,\n     where $C_m$ is an expansion coefficient, $\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...$ is the product of $2*N_p$ spatial orbitals, and each $\\Theta_m$ is a spin eigenfunction which couples the $N_p$ electron pairs.\n     For example,\n     \n     $\\Theta_1(i,j,k,l...) = \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big] \\big[\\alpha(k)\\beta(l)-\\alpha(l)\\beta(k)\\big]... $ ( $i$ is coupled to $j$ and $k$ is coupled to $l$)\n     \n     $\\Theta_2(i,j,k,l...) = \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] \\big[\\alpha(j)\\beta(l)-\\alpha(l)\\beta(j)\\big]... $ ( $i$ is coupled to $k$ and $i$ is coupled to $l$)\n     \n     ...\n     \n     See other resources, such as \"A Chemist's Guide to Valence Bond Theory\" for more information about spin eigenfunctions. Each $\\Theta_m$ will have $2^{N_p}$ terms if it is expanded out.\n     \n     \n      Expanding and collecting related terms,  $\\displaystyle \\Phi_{sc} = C_1 \\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...  \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big] \\big[\\alpha(k)\\beta(l)-\\alpha(l)\\beta(k)\\big]... + C_2 \\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l) \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] \\big[\\alpha(j)\\beta(l)-\\alpha(l)\\beta(j)\\big]... + C_3... $\n     \\end{itemize}\n     \nExpanding out Eq. \\ref{init_wave} :\n      \n \\begin{equation}\n \\begin{aligned}\n \\Psi_{VSVB} = &\\hat{A} \\{ \\Xi_{(docc+unpaired)}\\Phi_{sc} \\} \\\\\n = &\\hat{A} \\{\\phi_1(1)\\alpha(1)\\phi_1(2) \\beta(2)... \\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...\\sum_m^{N_{sc}} C_m \\Theta_m(i,j,k,l,...)  \\} \\\\\n =& \\hat{A} \\{ \\phi_1(1)\\alpha(1)\\phi_1(2) \\beta(2)... C_1 \\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...  \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]\\big[\\alpha(k)\\beta(l)-\\alpha(l)\\beta(k)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)\\phi_1(2) \\beta(2)... C_2\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] \\big[\\alpha(j)\\beta(l)-\\alpha(l)\\beta(j)\\big]... \\\\ &+  ... \\} \n \\label{exp_init_wave}\n \\end{aligned}\n \\end{equation}\n \n If Eq. \\ref{exp_init_wave} is expanded out, there will be $N_{sc}2^{N_p}$ total terms in the wavefunction if there are spin couplings. If there are no spin couplings, there is only 1 term (the docc+unpaired term).\n\n\n\nThe general energy expression is \\[E = \\frac{\\Braket{\\Psi|\\hat{H}|\\Psi}}{\\Braket{\\Psi|\\Psi}} \\]\n\n\nSubbing in the VSVB wave function:\n\n \\begin{equation}\n \\begin{aligned}\n     E &= \\frac{    \\Braket{\\Psi_{VSVB}|H|\\Psi_{VSVB}} }{\\Braket{\\Psi_{VSVB}|\\Psi_{VSVB}}} \\\\\n     &= \\frac{   \\Braket{   \\begin{aligned} \n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\} \n       \\end{aligned}\n       |H|\n  \\begin{aligned}\n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j) ... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\}\n       \\end{aligned}\n         }}\n       {\\Braket{  \\begin{aligned}\n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\} \n       \\end{aligned}\n              |\n               \\begin{aligned}\n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\} \n       \\end{aligned}\n       }} \n     \\end{aligned}\n     \\end{equation}\n\nSince $\\hat{A}$ is Hermitian, commutes with the Hamiltonian, and $\\hat{A}\\hat{A}\\phi = \\sqrt{N!}\\hat{A}\\phi$, this can be written as\n\n \\begin{equation}\n \\begin{aligned}\n     &= \\frac{  \\Braket{   \\begin{aligned}\n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\} \n       \\end{aligned}\n       |H|\n  \\begin{aligned}\n     &  \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j) ... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ... \n       \\end{aligned}\n         }}\n       {\\Braket{  \\begin{aligned}\n     \\hat{A}& \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ...\\} \n       \\end{aligned}\n              |\n               \\begin{aligned}\n     & \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i)\\big]... \\\\ &\n + \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\big[\\alpha(i)\\beta(k)-\\alpha(k)\\beta(i)\\big] ... \\\\ &+ ... \n       \\end{aligned}\n       }} \n     \\end{aligned}\n     \\end{equation}\n     \nTo shed light on the expression, we can expand the spin coupled pairs in each spin coupling term. This results in a sum of $2^{N_p}$ terms \n(where each spatial function is associated with one spin function) for each $N_{sc}$ spin coupling (so $N_{sc}2^{N_{p}}$ total terms if there are spin couplings. If there are no spin couplings, there is only 1 term) .\n\nFor the first spin coupling (associated with $C_1$) this is:\n\n\\begin{equation}\n \\begin{aligned}\n     =& \\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)... \\big[\\alpha(i)\\beta(j)-\\alpha(j)\\beta(i) \\big] \\big[\\alpha(k)\\beta(l)-\\alpha(l)\\beta(k) \\big]... \\} \\\\\n     =& \\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)... \\alpha(i)\\beta(j) \\alpha(k)\\beta(l)... \\\\\n     &- \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...\\alpha(j)\\beta(i) \\alpha(k)\\beta(l)... \\\\\n     &+...\n     \\}\n     \\end{aligned}\n     \\end{equation}\n\nSince $\\hat{A}$ is a linear operator, each term in the sum can be written separately with $\\hat{A}$ operating on it:\n\n\\begin{equation}\n \\begin{aligned}\n     =& \\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)... \\alpha(i)\\beta(j) \\alpha(k)\\beta(l)... \\} \\\\\n     &- \\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) \\phi_k(k) \\phi_l(l)...\\alpha(j)\\beta(i) \\alpha(k)\\beta(l)... \\} \\\\\n     &+...\n     \\end{aligned}\n     \\end{equation}\n\nSo the wave function is a sum of antisymmetrized products of spin orbitals.\n\nWe can plug this back into the energy expression to get:\n\n\n \\begin{equation}\n \\begin{aligned}\n  E &= \\\\\n     &= \\frac{    \\Braket{   \n     \\begin{aligned} \n     &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j) ... \\alpha(i)\\beta(j)\\alpha(k)\\beta(l)... \\}   \\\\ \n - &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) ...  \\alpha(j)\\beta(i)\\alpha(k)\\beta(l) ... \\}\\\\ \n  +    &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_2 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(k)\\alpha(j)\\beta(l)... \\} \\\\ \n - &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\alpha(k)\\beta(i)\\alpha(j)\\beta(l)... \\}\\\\ \n +& ...\n       \\end{aligned} \n       |H|\n   \\begin{aligned} \n     & \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(j)\\alpha(k)\\beta(l)...    \\\\ \n - & \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) ...  \\alpha(j)\\beta(i)\\alpha(k)\\beta(l) ... \\\\ \n  +    & \\phi_1(1)\\alpha(1)... C_2 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(k)\\alpha(j)\\beta(l)...  \\\\ \n - &\\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\alpha(k)\\beta(i)\\alpha(j)\\beta(l)... \\\\ \n +& ...\n       \\end{aligned} \n         }   }\n       {\\Braket{   \\begin{aligned} \n&\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j) ... \\alpha(i)\\beta(j)\\alpha(k)\\beta(l)... \\}   \\\\ \n - &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) ...  \\alpha(j)\\beta(i)\\alpha(k)\\beta(l) ... \\}\\\\ \n  +    &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_2 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(k)\\alpha(j)\\beta(l)... \\} \\\\ \n - &\\hat{A} \\{ \\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\alpha(k)\\beta(i)\\alpha(j)\\beta(l)... \\}\\\\ \n +& ...\n       \\end{aligned}\n              |\n   \\begin{aligned} \n      & \\phi_1(1)\\alpha(1)... C_1 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(j)\\alpha(k)\\beta(l)...    \\\\ \n - & \\phi_1(1)\\alpha(1)... C_1\\phi_i(i) \\phi_j(j) ...  \\alpha(j)\\beta(i)\\alpha(k)\\beta(l) ... \\\\ \n  +    & \\phi_1(1)\\alpha(1)... C_2 \\phi_i(i) \\phi_j(j)... \\alpha(i)\\beta(k)\\alpha(j)\\beta(l)...  \\\\ \n - &\\phi_1(1)\\alpha(1)... C_2\\phi_i(i) \\phi_j(j) ...  \\alpha(k)\\beta(i)\\alpha(j)\\beta(l)... \\\\ \n +& ...\n       \\end{aligned}\n       }} \n     \\label{gen_energy}\n     \\end{aligned}\n     \\end{equation}\n\n\nwhere the kets have been expanded as well.\n\nSince $\\hat{H}$ is linear, we can look at one term at a time. If there are spin couplings, there will be $N_{sc}^22^{2N_{p}}$ total terms, since the wavefunction in the bra contains $N_{sc}2^{N_{p}}$ terms, and the ket also has  $N_{sc}2^{N_{p}}$ terms. If there are no spin couplings, there is only 1 term in the bra and ket. We will come back to the full expression later.\n\n\\section{Single term in the energy expansion}\n\n\\begin{equation}\n \\begin{aligned}\n T_1 = \\frac{\\Braket{\\hat{A} \\{ \\phi_1(1)\\alpha(1)... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)... \\}\n     |H|  ( \\phi_1(1)\\alpha(1)... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)...)\n     }}{\\Braket{\\hat{A} \\{ \\phi_1(1)\\alpha(1)... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)... \\}\n     |  ( \\phi_1(1)\\alpha(1)... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)...)\n    }} \n    \\label{t1}\n     \\end{aligned}\n     \\end{equation}\n\nLet $T_1$ arbitrarily be one of the terms in the expansion in \\ref{gen_energy}. (Leaving the $C_m$ out for simplicity.) First, let's combine the spatial and spin parts associated with each electron, and replace them with spin orbitals, $\\psi$. \nAlso, note that an antisymmetrized product of spin orbitals can be written as a Slater determinant.\n\n\\begin{equation}\n \\begin{aligned}\n  &=\\frac{\\Braket{\\hat{A} \\{ \\psi_1(1)\\psi_2(2)...\\psi_N(N) \\}\n     |H|  (\\psi_1(1)\\psi_2(2)...\\psi_N(N))\n     }}{\\Braket{\\hat{A} \\{ \\psi_1(1)\\psi_2(2)...\\psi_N(N) \\}\n     |  ( \\psi_1(1)\\psi_2(2)...\\phi_N(N))\n    }} \\\\\n    &=\\frac{\\Braket{ \n    \\begin{vmatrix} \\psi_1(1) & \\psi_1(2) & ... \\\\\n    \\psi_2(1) & \\psi_2(2) & ... \\\\\n    ... & ... & ...\\\\\n    \\psi_N(1) & ... & \\psi_N(N)\\\\\n    \\end{vmatrix}\n     |H|  (\\psi_1(1)\\psi_2(2)...\\psi_N(N))\n     }}{\\Braket{ \\begin{vmatrix} \\psi_1(1) & \\psi_1(2) & ... \\\\\n    \\psi_2(1) & \\psi_2(2) & ... \\\\\n    ... & ... & ...\\\\\n    \\psi_N(1) & ... & \\psi_N(N)\\\\\n    \\end{vmatrix}\n     |  ( \\psi_1(1)\\psi_2(2)...\\psi_N(N))\n    }}\n     \\end{aligned}\n     \\end{equation}\n\nwhere there are $N$ electrons.\n\nThis can be written as the equation below, using derivations carried out in \"Handbook of Computational Quantum Chemistry\" by Cook, \"Method of Molecular Quantum Mechanics\" by McWeeney, or in the section \"Calculating matrix elements\" below. The section below also discusses how the cofactors are calculated in the code. (Note that this is different than Hartree-Fock, since we do not assume that orbitals are orthogonal.) \n\n\\begin{equation}\n \\begin{aligned}\n  &=\\frac{\\displaystyle \\sum_{ij}^{N} d^1_{ij} h_{ij}                                                                                                                                                            \n     + \\sum_i^{N}\\sum_{j<i}\\sum_k^{N}\\sum_{l<k}                                                                                                                                                     \n          d^2_{ikjl} \\big(\\Braket{  \\psi_i(1) \\psi_j(2) | \\psi_k(1) \\psi_l(2) }-\\Braket{  \\psi_i(1) \\psi_j(2) | \\psi_l(1) \\psi_k(2) } \\big) }{\\displaystyle \\sum_{j}^{N}  d^1_{1j} \\Braket{\\psi_1(1) | \\psi_j(1)}  }\n          \\label{spin_orb_form}\n     \\end{aligned}\n     \\end{equation}\n\nNote that the nuclear repulsion term is being neglected for clarity.\n\n\\subsection{Terms in \\ref{spin_orb_form} }\n\\subsubsection{One electron term}\n    The first term in the numerator is the one electron term.                                                                                                                                                                 \n                                                                                                                                                                                                             \n    $h_{ij} = \\Braket{ \\psi_i(1) | \\hat{h} | \\psi_j(1) }$ where $\\hat{h}$ is the standard one-electron kinetic and nuclei-electron attraction operator.                                                                                                                                                                  \n                                                                                                                                                                                                             \n    $d^1_{ij}$ is the first-order cofactor of the matrix of overlap integrals                                                                                                                                  \n    between the spin orbitals. That is, it is the determinant of the                                                                                                                                 \n    matrix of overlap integrals between spin functions with row i and column j removed, multiplied by $(-1)^{i+j}$.                                                                                                                                          \n\nTo be explicit, the matrix of overlap integrals between spin functions for $N$ electrons is a $N \\times N$ matrix shown in Eq. \\ref{overlap}:\n\n\\begin{equation}\n \\begin{aligned}\n    \\begin{vmatrix} \n    \\Braket{ \\psi_1(1)| \\psi_1(1) }  &  \\Braket{ \\psi_1(2) | \\psi_2(2) } & \\Braket{ \\psi_1(3) | \\psi_3(3) } & ... &  \\Braket{ \\psi_1(N) | \\psi_N(N) } \\\\\n    \\Braket{ \\psi_2(1) |\\psi_1(1) }  &  \\Braket{ \\psi_2(2) | \\psi_2(2) } & \\Braket{ \\psi_2(3) | \\psi_3(3) } & ... &  \\Braket{ \\psi_2(N) | \\psi_N(N) } \\\\\n    \\Braket{ \\psi_3(1)|  \\psi_1(1) }  &  \\Braket{ \\psi_3(2) | \\psi_2(2) } & \\Braket{ \\psi_3(3) | \\psi_3(3) } &... &  \\Braket{ \\psi_3(N) | \\psi_N(N) } \\\\\n    ... & ... & ... & ...& ...\\\\\n     \\Braket{ \\psi_N(1)|  \\psi_1(1) } &  \\Braket{ \\psi_N(2)|  \\psi_2(2) }& \\Braket{ \\psi_N(3) | \\psi_3(3) } & ...&  \\Braket{ \\psi_N(N) | \\psi_N(N) }\\\\\n    \\end{vmatrix}\n    \\label{overlap}\n         \\end{aligned}\n     \\end{equation}\n\nThen $d^1_{21}$ is a $(N-1) \\times (N-1)$ matrix below:\n\n\\begin{equation}\n \\begin{aligned}\n   (-1)^{2+1} \\begin{vmatrix} \n    \\Braket{ \\psi_1(2) | \\psi_2(2) } & \\Braket{ \\psi_1(3) | \\psi_3(3) } & ... &  \\Braket{ \\psi_1(N) | \\psi_N(N) } \\\\\n      \\Braket{ \\psi_3(2) | \\psi_2(2) } & \\Braket{ \\psi_3(3) | \\psi_3(3) } &... &  \\Braket{ \\psi_3(N) | \\psi_N(N) } \\\\\n     ... & ... & ...& ...\\\\\n      \\Braket{ \\psi_N(2)|  \\psi_2(2) }& \\Braket{ \\psi_N(3) | \\psi_3(3) } & ...&  \\Braket{ \\psi_N(N) | \\psi_N(N) }\\\\\n    \\end{vmatrix}\n    \\label{cof}\n         \\end{aligned}\n     \\end{equation}\n\nNote that by the definition of determinants, Eq. \\ref{cof} is equivalent to computing:\n\n\n\\begin{equation}\n \\begin{aligned}\n    \\begin{vmatrix} \n   0  &  \\Braket{ \\psi_1(2) | \\psi_2(2) } & \\Braket{ \\psi_1(3) | \\psi_3(3) } & ... &  \\Braket{ \\psi_1(N) | \\psi_N(N) } \\\\\n   1 & 0& 0 & ... & 0 \\\\\n   0  &  \\Braket{ \\psi_3(2) | \\psi_2(2) } & \\Braket{ \\psi_3(3) | \\psi_3(3) } &... &  \\Braket{ \\psi_3(N) | \\psi_N(N) } \\\\\n    ... & ... & ... & ...& ...\\\\\n    0&  \\Braket{ \\psi_N(2)|  \\psi_2(2) }& \\Braket{ \\psi_N(3) | \\psi_3(3) } & ...&  \\Braket{ \\psi_N(N) | \\psi_N(N) }\\\\\n    \\end{vmatrix}\n         \\end{aligned}\n     \\end{equation}\n\n\\subsubsection{Normalization integral}\n\n    The denominator is the normalization integral. It is the determinant of the matrix of overlap integrals between spin orbitals, and can be expressed as in \\ref{spin_orb_form}. \n\n\n\\subsubsection{Two electron term}\n    The second term in the numerator is the two electron term.                                                                                                                                                                \n                                                                                                                                                                                                             \n    $\\Braket{ i(1) j(2) | k(1) l(2) }$ is the electron-electron repulsion integral.                                                                                                                                                                                                                                                                               \n                                                                                                                                                                                                             \n    $d^2_{ikjl}$ is the second-order cofactor of the matrix of overlap integrals                                                                                                                               \n    between the spin orbitals. That is, it is the determinant of the overlap                                                                                                                                 \n    matrix with row i, column k, row j, and column l removed,                                                                                                                                                \n    multipled by $(-1)^{i+j+k+l}$. \n\n\\subsection{ Switching to spatial orbitals }\nThen we pull the spin functions out of the spin orbitals, since spin integration should help remove a lot of terms. \n\n\\subsubsection{One electron term}\n\nFirst we expand the spin orbitals into spatial and spin parts:\n\n\\begin{equation}\n \\begin{aligned}\n  & \\displaystyle \\sum_{ij}^{N} d^1_{ij,T_1} h_{ij,T_1}                \\\\                                                                                                                                             \n &=  \\displaystyle \\sum_{ij}^{N} d^1_{ij,T_1} \\Braket{ \\psi_{i}(1)  | \\hat{h}| \\psi_{j}(1)  }      \\\\                                                                                                                                             \n &=  \\displaystyle \\sum_{ij}^{N} d^1_{ij,T_1}  w_{T_1}( i(1) j(1) ) \\Braket{ \\phi_{i}(1)  | \\hat{h}| \\phi_{j}(1)  } \n \\label{onee}\n     \\end{aligned}\n     \\end{equation}\n\nWhere $w_{T_1}( i(1) j(1) )$ is a function containing the integrated spins of spin orbitals $i,j$. As used above, $\\phi_i$, is the spatial portion of the spin orbital $\\psi_i$. The $T_1$ subscript is to be clear which term in \\ref{gen_energy} this refers to. Note that each each will only differ in spin, so will only affect $d^1_{ij, T_1}$ and  $w_{T_1}( i(1) j(1) )$, not the integration over spatial orbitals.\n\nLetting \n\\begin{equation}\n \\begin{aligned}\n \t\\text{D}_{T_1, ij}^1 = d^1_{ij,T_1}  w_{T_1}( i(1) j(1) )                                                          \n     \\end{aligned}\n     \\end{equation}\n     \n     Eq. \\ref{onee} can be written as \n     \n \\begin{equation}\n \\begin{aligned}                                                                                                                                         \n &=  \\displaystyle \\sum_{ij}^{N}\\text{D}_{T_1, ij}^1 \\Braket{ \\phi_{i}(1)  | \\hat{h}| \\phi_{j}(1)  } \n \\label{final_onee}\n     \\end{aligned}\n     \\end{equation}\n\nThis form, looping over spin orbitals, is used in the code. Note that the sum is over spin orbitals. This means that if there are doubly occupied orbitals, this form could compute the spatial orbital integral twice--once when both spins are alpha and once when both are beta. However, one-electron integrals are not too expensive, so this is not important. \n\n\n\\subsubsection{Normalization integral}\n\nSimilar to the one-electron term, we split the spin orbitals to the spin and spatial forms:\n\n\\begin{equation}\n \\begin{aligned}\n  & \\displaystyle \\sum_{j}^{N}  d^1_{1j,T_1} \\Braket{\\psi_1(1) | \\psi_j(1)}_{T_1} \\\\\n  &= \\displaystyle \\sum_{j}^{N}  d^1_{1j} w_{T_1}( i(1) j(1) ) \\Braket{\\phi_1(1) | \\phi_j(1)}\\\\\n  &= \\displaystyle \\sum_{j}^{N}  \\text{D}_{T_1, 1j}^1 \\Braket{\\phi_1(1) | \\phi_j(1)}\n \\label{norm}\n     \\end{aligned}\n     \\end{equation}\n     \n using the same density as in the one-electron term.\n \n Note that the normalization integral is the determinant of the spin orbital overlap matrix (Eq. \\ref{overlap} ). The expression in Eq. \\ref{norm} is an expansion in terms of cofactors along the first row. Calculating the determinant by expanding along any over row is equivalent (the cofactor provides the appropriate sign change). That is,  $\\displaystyle \\sum_{j}^{N}  \\text{D}_{T_1, 1j}^1 \\Braket{\\phi_1(1) | \\phi_j(1)}$ = $ \\displaystyle \\sum_{j}^{N}  \\text{D}_{T_1, 2j}^1 \\Braket{\\phi_2(1) | \\phi_j(1)}$ = $ \\displaystyle\\sum_{j}^{N}  \\text{D}_{T_1, 3j}^1 \\Braket{\\phi_3(1) | \\phi_j(1)}$ and so on.\n     \nThus, we can write \\ref{norm} as\n\n\\begin{equation}\n \\begin{aligned}\n  &=  \\frac{\\displaystyle \\sum_{ij}^{N}  \\text{D}_{T_1, ij}^1 \\Braket{\\phi_i(1) | \\phi_j(1)}}{N}\n    \\label{final_norm}\n     \\end{aligned}\n     \\end{equation}\n     \n\nThis form is used in the code, in the same place as the one-electron term.\n \n\\subsubsection{Two electron term}\n\nSince two electron integrals are expensive, we don't want to recompute the integral between spatial orbitals if we already computed them. \nSo this time the loops are over spatial orbitals only, not spin orbitals. \n\n\\begin{equation}\n \\begin{aligned}\n  &  \\displaystyle \\sum_i^{N}  \\sum_{j<i}\\sum_k^{N}\\sum_{l<k}                                                                                                                                                     \n          d^2_{ikjl, T_1} \\big(\\Braket{  \\psi_i(1) \\psi_j(2) | \\psi_k(1) \\psi_l(2) }_{T_1}-\\Braket{  \\psi_i(1) \\psi_j(2) | \\psi_l(1) \\psi_k(2) }_{T_1} \\big) \\\\\n          =& \\sum_{io}^{orbitals}\\sum_{jo\\leq io}\\sum_{ko}^{orbitals}\\sum_{lo\\leq ko}        \n          \\sum_l^{\\substack{spins \\\\ \\in lo<ko}}                                                                                                                                  \n \\sum_i^{\\substack{spins \\\\ \\in io}}\\sum_j^{\\substack{spins \\\\ \\in jo<io}}\\sum_k^{\\substack{spins \\\\ \\in ko}} \n  d^2_{io+i,ko+k,jo+j,lo+l,T_1}      \\\\                                                                                                                                                  \n    & \\Big(  w_{T_1}( i(1) j(2), k(1) l(2) ) \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{ko}(1) \\phi_{lo}(2) }                                                                                                                                              \n    - w_{T_1}( i(1) j(2), l(1) k(2) ) \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{lo}(1) \\phi_{ko}(2) } \\Big) \n    \\label{spat}\n     \\end{aligned}\n     \\end{equation}\n\nwhere $io,jo,ko,lo$ are indexes which run over spatial orbitals, not spin functions.\n\n($io,jo,ko,lo$ are what they are called in the code, so I'm trying to match notation.)\n\n\n$w_{T_1}( i(1) j(2), l(1) k(2) )$ is a function containing the integrated spins of spin orbitals $i,j,l,k$. The possible spins depend on the associated spatial orbital, since in VSVB some are doubly occupied, and can be $\\alpha$ or $\\beta$, and some can be unpaired or spin coupled. For the spin coupled orbitals, the spin depends on which term in the sum in Eq.\\ref{gen_energy} we're evaluating. Since \\ref{t1} is called $T_1$, there is a $T_1$ subscript.\n\nEq. \\ref{spat} can be rearranged:\n\n\\begin{equation}\n \\begin{aligned}\n          =& \\sum_{io}^{orbitals}\\sum_{jo\\leq io}\\sum_{ko}^{orbitals}\\sum_{lo\\leq ko}                                                                                                                                         \n   \\sum_i^{\\substack{spins \\\\ \\in io}}\\sum_j^{\\substack{spins \\\\ \\in jo<io}}\\sum_k^{\\substack{spins \\\\ \\in ko}}  \n   \\sum_l^{\\substack{spins \\\\ \\in lo<ko}}      \\\\                                                                                                                                                  \n    & \\Big( \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{ko}(1) \\phi_{lo}(2) }d^2_{io+i,ko+k,jo+j,lo+l,T_1} w_{T_1}( i(1) j(2), k(1) l(2) )        \\\\                                                                                                                                       \n    &-  \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{lo}(1) \\phi_{ko}(2) } d^2_{io+i,ko+k,jo+j,lo+l,T_1} w_{T_1}( i(1) j(2), l(1) k(2) )  \\Big)\n\\label{rearr_single}\n    \\end{aligned}\n     \\end{equation}\n\nLetting \n\\begin{equation}\n \\begin{aligned}\n \t\\text{D}_{T_1, io,ko,jo,lo}^2 =                                                                                                                                                                 \n       \\sum_i^{\\substack{spins \\\\ \\in io}}\\sum_j^{\\substack{spins \\\\ \\in jo<io}}\\sum_k^{\\substack{spins \\\\ \\in ko}}                                                                                                                                            \n   \\sum_l^{\\substack{spins \\\\ \\in lo<ko}} d^2_{io+i,ko+k,jo+j,lo+l,T_1} w_{T_1}(i(1) j(2) k(1) l(2))\n     \\end{aligned}\n     \\end{equation}\n     \n     and\n      \n\\begin{equation}\n \\begin{aligned}\n \t\\text{D}_{T_1,exch, io,ko,jo,lo}^2 =                                                                                                                                                                 \n       \\sum_i^{\\substack{spins \\\\ \\in io}}\\sum_j^{\\substack{spins \\\\ \\in jo<io}}\\sum_k^{\\substack{spins \\\\ \\in ko}}                                                                                                                                           \n   \\sum_l^{\\substack{spins \\\\ \\in lo<ko}}  d^2_{io+i,ko+k,jo+j,lo+l,T_1} w_{T_1}(i(1) j(2) l(1) k(2))\n     \\end{aligned}\n     \\end{equation}\n\n     \nThe two electron part of Eq.\\ref{rearr_single}  can be written as\n\n\\begin{equation}\n \\begin{aligned}\n          & \\sum_{io}^{orbitals}\\sum_{jo\\leq io}\\sum_{ko}^{orbitals}\\sum_{lo\\leq ko}                                                                                                                                                \n    \\Big( \\text{D}_{T_1, io,ko,jo,lo}^2 \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{ko}(1) \\phi_{lo}(2) }   -  \\text{D}_{T_1,exch, io,ko,jo,lo}^2\\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{lo}(1) \\phi_{ko}(2) } \\Big)\n    \\label{final_twoe}\n    \\end{aligned}\n     \\end{equation}\n\n     \n     Note that the only differences between $\\text{D}_{T_1, io,ko,jo,lo}^2$ and $\\text{D}_{T_1,exch, io,ko,jo,lo}^2)$ are in the spin integration ($w_{T}$).  The cofactor ($d^2_{io+i,ko+k,jo+j,lo+l,T_1}$) is the same for both, so it only needs to be calculated once.\n\n\n\\section{Final expressions for the three terms}\n\nFor a single determinant wave function (that is, one that has no spin couplings), Eq. \\ref{final_onee}, \\ref{final_norm}, and \\ref{final_twoe} are those which are calculated in the code.\n\nFor a muti-determinant wave function with multiple spin coupling, there is the expansion of terms as in  Eq.\\ref{gen_energy}. However, the only thing that will differ between the $M_{sc} = {N_{sc}^22^{2N_p}}$ terms in Eq.\\ref{gen_energy} is the cofactors and the spin, not the spatial functions. \nThat is, if we let Eq.\\ref{gen_energy} be $T_1 + T_2 + ...+T_{M_{sc}}$, then the following expressions can be written:\n\n\\subsection{One electron term}\n\n \\begin{equation}\n \\begin{aligned}                                                                                                                            \n &=  \\displaystyle \\sum_{ij}^{N}  \\big( \\text{D}_{T_1, ij}^1 + \\text{D}_{T_1, ij}^1 + \\text{D}_{T_1, ij}^1 +...\\big) \\Braket{ \\phi_{i}(1)  | \\hat{h}| \\phi_{j}(1)  }   \\\\                                                                                                                                \n &=  \\displaystyle \\sum_{ij}^{N}  \\text{D}_{ij}^1 \\Braket{ \\phi_{i}(1)  | \\hat{h}| \\phi_{j}(1)  } \n \\label{total_onee}\n     \\end{aligned}\n     \\end{equation}\n\nwhere we let $\\text{D}_{ij}^1 = \\text{D}_{T_1, ij}^1 + \\text{D}_{T_1, ij}^1 + \\text{D}_{T_1, ij}^1 +...+\\text{D}_{T_{M_{sc}}, ij}^1$\n\n\\subsection{Normalization integral}\n\nSimilarly, the normalization integral can be written as:\n\n \\begin{equation}\n \\begin{aligned}                                                                                                                          \n &=  \\frac{\\displaystyle \\sum_{ij}^{N}  \\text{D}_{ij}^1 \\Braket{ \\phi_{i}(1)  |  \\phi_{j}(1)  }}{N} \n \\label{total_norm}\n     \\end{aligned}\n     \\end{equation}\n\n\\subsection{Two electron term}\n\nThe expression for the two electron integral is similar:\n\n\n\\begin{equation}\n \\begin{aligned}\n         =& \\sum_{io}^{orbitals}\\sum_{jo\\leq io}\\sum_{ko}^{orbitals}\\sum_{lo\\leq ko}                                                                                                                                                \n     \\Big( \\big(\\text{D}_{T_1, io,ko,jo,lo}^2 + \\text{D}_{T_2, io,ko,jo,lo}^2 +...\\big) \\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{ko}(1) \\phi_{lo}(2) }        \\\\                                                                                                                                       \n    &-  \\big(\\text{D}_{T_1,exch, io,ko,jo,lo}^2+\\text{D}_{T_2,exch, io,ko,jo,lo}^2+...\\big)\\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{lo}(1) \\phi_{ko}(2) } \\Big) \\\\\n    =&  \\sum_{io}^{orbitals}\\sum_{jo\\leq io}\\sum_{ko}^{orbitals}\\sum_{lo\\leq ko}                                                                                                                                                \n    \\Big(\\text{D}_{io,ko,jo,lo}^2\\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{ko}(1) \\phi_{lo}(2) }    -  \\text{D}_{exch,io,ko,jo,lo}^2\\Braket{ \\phi_{io}(1) \\phi_{jo}(2) | \\phi_{lo}(1) \\phi_{ko}(2) } \\Big)\n    \\label{total_twoe}\n    \\end{aligned}\n     \\end{equation}\n\n\nwhere we let $\\displaystyle \\text{D}_{io,ko,jo,lo}^2 = \\sum_q^{M_{sc}} \\text{D}_{T_q, io,ko,jo,lo}^2$\n\n\\section{Calculating the matrix elements} \n\nIn general, $\\hat{H}$ can be split into a one-electron operator, which sums over all electrons in the system ($\\displaystyle \\sum_i^N\\hat{O}(i)$) and a two-electron operator, which sums over all pairs of electrons in the system\n($ \\displaystyle  \\sum_i^N  \\sum_{j<i} \\hat{O}(i,j)$). \n\nTo give an idea of how the integrals are calculated, here we go over the evaluation of the normalization integral, a generic one-electron operator, and the electron repulsion operator. This is only shown for a single determinant wave function, but it could be made more general.\n\n\\subsection{Normalization integral}\n \n \\begin{equation}\n \\begin{aligned}\n &= \\Braket{  \\psi_1(1)\\psi_2(2)...\\psi_N(N)  |\n \\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n    \\Braket{ \n     \\begin{vmatrix} \\psi_1(1) &0 & 0&... & 0 \\\\\n    0 & \\psi_2(2) & 0& ...& 0\\\\\n    0 & 0 & \\psi_3(3)& ...& 0\\\\\n    ... & ... & ... & ... &...\\\\\n    0 & 0 & 0&...& \\psi_N(N)\\\\\n    \\end{vmatrix}  \n    |\n   \\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n      \\Braket{ \n    \\begin{vmatrix} \n    \\psi_1(1) \\psi_1(1) & \\psi_1(1)\\psi_2(1)& \\psi_1(1)\\psi_3(1) & ... & \\psi_1(1) \\psi_N(1) \\\\\n    \\psi_2(2) \\psi_1(2) & \\psi_2(2)\\psi_2(2) & \\psi_2(2) \\psi_3(2) &...& \\psi_2(2)\\psi_N(2) \\\\\n    \\psi_3(3) \\psi_1(3) & \\psi_3(3)\\psi_2(3) & \\psi_3(3) \\psi_3(3) &...& \\psi_3(3)\\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_N(N) \\psi_1(N) &\\psi_N(N) \\psi_2(N) & \\psi_N(N) \\psi_3(N) &...& \\psi_N(N)\\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n        &= \n    \\begin{vmatrix}  \n     \\Braket{\\psi_1(1) \\psi_1(1) }&  \\Braket{\\psi_1(1)\\psi_2(1)}& \\Braket{\\psi_1(1)\\psi_3(1) }& ... &  \\Braket{\\psi_1(1) \\psi_N(1) }\\\\\n     \\Braket{\\psi_2(2) \\psi_1(2) }&  \\Braket{\\psi_2(2)\\psi_2(2)} &  \\Braket{\\psi_2(2) \\psi_3(2) }&...& \\Braket{ \\psi_2(2)\\psi_N(2)} \\\\\n     \\Braket{\\psi_3(3) \\psi_1(3)} &  \\Braket{\\psi_3(3)\\psi_2(3) }&  \\Braket{\\psi_3(3) \\psi_3(3)} &...& \\Braket{ \\psi_3(3)\\psi_N(3) }\\\\\n    ... & ... & ... & ...& ... \\\\\n    \\Braket{ \\psi_N(N) \\psi_1(N) }& \\Braket{\\psi_N(N) \\psi_2(N) }&  \\Braket{\\psi_N(N) \\psi_3(N)} &...&  \\Braket{\\psi_N(N)\\psi_N(N)}\\\\\n    \\end{vmatrix}  \n    \\label{deriv_overlap}\n \\end{aligned}\n \\end{equation}\n \n \n \n Where we used the fact that the determinant of a diagonal matrix is the product of the terms in the diagonal, that det(A)det(B)=det(AB), and since each row depends on a different electron, and the integration is over electrons, the integration can be pulled into the determinant.\n\nThus, the normalization integral is the determinant of the matrix of overlap integrals between spin orbitals.\n\n\\subsection{One electron integral}\n\nThe one electron term is $\\displaystyle \\sum_i^N\\hat{h}(i)$. First we start with $\\hat{h}(1)$ and generalize from there.\n\n \\begin{equation}\n \\begin{aligned}\n &= \\Braket{  \\psi_1(1)\\psi_2(2)...\\psi_N(N)  | \\hat{h}(1) |\n\\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n    \\Braket{ \n     \\begin{vmatrix} \\psi_1(1) &0 & 0&... & 0 \\\\\n    0 & \\psi_2(2) & 0& ...& 0\\\\\n    0 & 0 & \\psi_3(3)& ...& 0\\\\\n    ... & ... & ... & ... &...\\\\\n    0 & 0 & 0&...& \\psi_N(N)\\\\\n    \\end{vmatrix}  \n    |\\hat{h}(1) |\n    \\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n      \\Braket{ \n     \\begin{vmatrix} \n    \\psi_1(1)\\hat{h}(1) \\psi_1(1) & \\psi_1(1)\\hat{h}(1)\\psi_2(1)& \\psi_1(1)\\hat{h}(1)\\psi_3(1) & ... & \\psi_1(1) \\hat{h}(1)\\psi_N(1) \\\\\n    \\psi_2(2) \\psi_1(2) & \\psi_2(2)\\psi_2(2) & \\psi_2(2) \\psi_3(2) &...& \\psi_2(2)\\psi_N(2) \\\\\n    \\psi_3(3) \\psi_1(3) & \\psi_3(3)\\psi_2(3) & \\psi_3(3) \\psi_3(3) &...& \\psi_3(3)\\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_N(N) \\psi_1(N) &\\psi_N(N) \\psi_2(N) & \\psi_N(N) \\psi_3(N) &...& \\psi_N(N)\\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n        &= \n   \\begin{vmatrix}  \n     \\Braket{\\psi_1(1) \\hat{h}(1)\\psi_1(1) }&  \\Braket{\\psi_1(1)\\hat{h}(1)\\psi_2(1)}& \\Braket{\\psi_1(1)\\hat{h}(1)\\psi_3(1) }& ... &  \\Braket{\\psi_1(1)\\hat{h}(1) \\psi_N(1) }\\\\\n     \\Braket{\\psi_2(2) \\psi_1(2) }&  \\Braket{\\psi_2(2)\\psi_2(2)} &  \\Braket{\\psi_2(2) \\psi_3(2) }&...& \\Braket{ \\psi_2(2)\\psi_N(2)} \\\\\n     \\Braket{\\psi_3(3) \\psi_1(3)} &  \\Braket{\\psi_3(3)\\psi_2(3) }&  \\Braket{\\psi_3(3) \\psi_3(3)} &...& \\Braket{ \\psi_3(3)\\psi_N(3) }\\\\\n    ... & ... & ... & ...& ... \\\\\n    \\Braket{ \\psi_N(N) \\psi_1(N) }& \\Braket{\\psi_N(N) \\psi_2(N) }&  \\Braket{\\psi_N(N) \\psi_3(N)} &...&  \\Braket{\\psi_N(N)\\psi_N(N)}\\\\\n    \\end{vmatrix}  \n     \\\\   &= \n     \\sum_j^N d^1_{1j}h_{1j} \n    \\label{deriv_onee}\n \\end{aligned}\n \\end{equation}\n\nwhere $d^1_{ij}$ is a first-order cofactor of the matrix of overlap integrals between spin orbitals, and $h_{1j} = \\Braket{ \\psi_1(1) \\hat{h}(1)\\psi_j(1) }$. \n\n(Again we used the fact that the determinant of a diagonal matrix is the product of the terms in the diagonal, that det(A)det(B)=det(AB), and since each column depends on a different electron, and the integration is over electrons, the integration can be pulled into the determinant. Also that multiplying a determinant is the same as multiplying down one row or column.)\n\nThe same thing can be done for all $\\hat{h}(i)$ in the one-electron term, which leads to $\\Braket{\\Phi| \\sum_i^N\\hat{h}(i) |\\Phi} =  \\sum_{ij}^{N} d^1_{ij} h_{ij} $.\n\n\n\\subsection{Two electron integral}\n\nThe two electron term is $\\displaystyle \\sum_i^N\\sum_{j<i} \\hat{g}(i,j)$. First we start with $\\hat{g}(1,2)$ and generalize from there.\n\n\n \\begin{equation}\n \\begin{aligned}\n &= \\Braket{  \\psi_1(1)\\psi_2(2)...\\psi_N(N)  | \\hat{g}(1,2) |\n\\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n    \\Braket{ \n     \\begin{vmatrix} \\psi_1(1) &0 & 0&... & 0 \\\\\n    0 & \\psi_2(2) & 0& ...& 0\\\\\n    0 & 0 & \\psi_3(3)& ...& 0\\\\\n    ... & ... & ... & ... &...\\\\\n    0 & 0 & 0&...& \\psi_N(N)\\\\\n    \\end{vmatrix}  \n    |\\hat{g}(1,2) |\n    \\begin{vmatrix} \\psi_1(1) & \\psi_2(1)& \\psi_3(1) & ... & \\psi_N(1) \\\\\n    \\psi_1(2) & \\psi_2(2) & \\psi_3(2) &...& \\psi_N(2) \\\\\n    \\psi_1(3) & \\psi_2(3) & \\psi_3(3) &...& \\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_1(N) & \\psi_2(N) & \\psi_3(N) &...& \\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n    &=\n      \\Braket{ \n     \\begin{vmatrix} \n    \\psi_1(1)\\hat{g}(1,2) \\psi_1(1) & \\psi_1(1) \\hat{g}(1,2) \\psi_2(1)& \\psi_1(1) \\hat{g}(1,2) \\psi_3(1) & ... & \\psi_1(1)\\hat{g}(1,2)\\psi_N(1) \\\\\n    \\psi_2(2) \\psi_1(2) & \\psi_2(2)\\psi_2(2) & \\psi_2(2) \\psi_3(2) &...& \\psi_2(2)\\psi_N(2) \\\\\n    \\psi_3(3) \\psi_1(3) & \\psi_3(3)\\psi_2(3) & \\psi_3(3) \\psi_3(3) &...& \\psi_3(3)\\psi_N(3) \\\\\n    ... & ... & ... & ...& ... \\\\\n    \\psi_N(N) \\psi_1(N) &\\psi_N(N) \\psi_2(N) & \\psi_N(N) \\psi_3(N) &...& \\psi_N(N)\\psi_N(N)\\\\\n    \\end{vmatrix} } \\\\\n        &=  \\int  \\int  d1d2\n   \\begin{vmatrix}  \n      \\psi_1(1)\\hat{g}(1,2) \\psi_1(1) & \\psi_1(1) \\hat{g}(1,2) \\psi_2(1)& \\psi_1(1) \\hat{g}(1,2) \\psi_3(1) & ... & \\psi_1(1)\\hat{g}(1,2)\\psi_N(1) \\\\\n    \\psi_2(2) \\psi_1(2) & \\psi_2(2)\\psi_2(2) & \\psi_2(2) \\psi_3(2) &...& \\psi_2(2)\\psi_N(2) \\\\\n     \\Braket{\\psi_3(3) \\psi_1(3)} &  \\Braket{\\psi_3(3)\\psi_2(3) }&  \\Braket{\\psi_3(3) \\psi_3(3)} &...& \\Braket{ \\psi_3(3)\\psi_N(3) }\\\\\n    ... & ... & ... & ...& ... \\\\\n    \\Braket{ \\psi_N(N) \\psi_1(N) }& \\Braket{\\psi_N(N) \\psi_2(N) }&  \\Braket{\\psi_N(N) \\psi_3(N)} &...&  \\Braket{\\psi_N(N)\\psi_N(N)}\\\\\n    \\end{vmatrix}  \n     \\\\   &= \n     \\sum_k^N\\sum_{l \\neq k}^N d^2_{12kl}m_{kl}g_{12kl} \n    \\label{deriv_twoe}\n \\end{aligned}\n \\end{equation}\n\n\nwhere $d^2_{ijkl}$ is a second-order cofactor of the matrix of overlap integrals between spin orbitals. $m_{kl}$ gets the proper sign, which comes from evaluating the determinant.\n\nWe used the techniques from before, but can't pull the integration for electrons 1 and 2 inside the determinant because of the $\\hat{g}(1,2)$ operator, which acts on electrons 1 and 2. \nHowever, we can still calculate the determinant using the cofactor and sign fix. \n\nThe same thing can be done for all $\\hat{g}(i,j)$ in the two-electron term, which leads to \n\n$\\displaystyle \\Braket{\\Phi| \\sum_i^N\\sum_{j<i} \\hat{g}(i,j) |\\Phi } =   \\sum_i^N\\sum_{j<i} \\sum_k^N\\sum_{l \\neq k}^N d^2_{ijkl}m_{kl}g_{ijkl}  $.\n\nWe can use symmetry of the cofactor in $k$ and $l$ to get the form in \\ref{spin_orb_form}.\n\n\\section{Code} \n\nIn \\emph{VALENCE}, routine vsvb\\_energy calculates the one electron term, two electron term, and normalization integral. The one electron term and normalization terms are done in a loop over electrons (spin orbitals), and the two electron term is done in a loop over spatial orbitals.\n\nThe one electron term, normalization integral, and two electron term are calculated as in Eq. \\ref{total_onee}, \\ref{total_norm}, and \\ref{total_twoe}. \n\nThe density cofactors $\\text{D}_{io,ko,jo,lo}^2$ and $\\text{D}_{ij}^1$ are split into alpha and beta blocks, so two determinants of half the size are calculated for each cofactor in the equations above.\n \n%\\section{Notes} \n\n% Need to add more about how the determinant is calculated--split into alpha and beta blocks, 0s and 1s the rows/columns.\n\n\n\n\\end{document}\n\n\\begin{equation}\n \\begin{aligned}\n   E &= \\\\\n     =& \\frac{\\Braket{ \\begin{aligned}\n        &\\hat{A} \\{ ... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)... \\}\n     \\\\ &-\n     \\hat{A} \\{  ... \\phi_i(i) \\phi_j(j) \\alpha(j)\\beta(i)...\\} \n     +... \\end{aligned} |\n     H\n     |  \\begin{aligned} &( ... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)...)\n     \\\\ &-\n     ( ... \\phi_i(i) \\phi_j(j) \\alpha(j)\\beta(i)...)\n     +... \\end{aligned}\n     }}{\\Braket{\\hat{A} \\{ ... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)... \\}\n     -\\hat{A} \\{ ... \\phi_i(i) \\phi_j(j) \\alpha(j)\\beta(i)...\\} \n     +...|  ( ... \\phi_i(i) \\phi_j(j) \\alpha(i)\\beta(j)...)\n     -(  ... \\phi_i(i) \\phi_j(j) \\alpha(j)\\beta(i)...)\n     +...}} \n     \\label{gen_energy}\n     \\end{aligned}\n     \\end{equation}\n", "meta": {"hexsha": "e473e32f252b32aa76fbdc2e1219d2da13790966", "size": 46296, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/notes-vsvb-energy.tex", "max_stars_repo_name": "keceli/VALENCE", "max_stars_repo_head_hexsha": "941eefb493c764d0ed4d60c9c95183a74154c606", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2018-11-16T21:30:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-10T11:37:25.000Z", "max_issues_repo_path": "doc/notes-vsvb-energy.tex", "max_issues_repo_name": "keceli/VALENCE", "max_issues_repo_head_hexsha": "941eefb493c764d0ed4d60c9c95183a74154c606", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-11-27T13:21:24.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-05T03:17:52.000Z", "max_forks_repo_path": "doc/notes-vsvb-energy.tex", "max_forks_repo_name": "keceli/VALENCE", "max_forks_repo_head_hexsha": "941eefb493c764d0ed4d60c9c95183a74154c606", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-11-22T05:04:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-01T12:41:48.000Z", "avg_line_length": 59.5064267352, "max_line_length": 604, "alphanum_fraction": 0.5042552272, "num_tokens": 15755, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435030872968, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4219962904992792}}
{"text": "\\vspace{-0\\baselineskip}\n\\section{Geometry estimation with edge-aware depth-normal consistency}\n\\label{sec:approach}\n\\vspace{-0\\baselineskip}\n\nIn our scenario, given a target image $I$, we aim at learning to estimate both depths and normals simultaneously. Formally, let $N$ be the predicted normals from our model, we embed it into the training pipeline and make it a regularization for depths estimation $D$, which helps to train a more robust model.\n\n\\vspace{-0\\baselineskip}\n\\subsection{Framework}\n\\label{sub:framework}\n\\vspace{-0\\baselineskip}\n\n\\figref{fig:pipeline} illustrates an overview of our approach. For training, we apply supervision from view synthesis following \\cite{zhou2017unsupervised}. Specifically, the depth network (middle) takes only the target view as input, and\noutputs a per-pixel depth map $D_t$, based on which a normal map $N_t$ is generated by the depth-to-normal layer. Then, given the $D_t$ and $N_t$, a new depth map $D_t^n$ is estimated from the normal-to-depth layer using local orthogonal compatibility between depth and normals. Both of the layers takes in image gradient to avoid non-compatible pixels involving in depth and normal conversion (detailed in \\secref{sub:depth_and_normal_orthogonality}).\nThen, the new depth map $D_t^n$, combined with poses and mask predicted from the motion network (left), are then used to inversely warp the source views to reconstruct the target view, and errors are back propagated through both networks. Here the normal representation naturally serves as a regularization for depth estimation. Finally, for training loss, additional to the usually used photometric reconstruction loss, we also add in smoothness over normals, which induces higher order interaction between pixels (\\secref{sub:training_losses})\n\nWith the trained model, given a new image,  we infer per-pixel depth value and then compute the normal value, yielding consistent results between the two predictions.\n\n\\vspace{-0\\baselineskip}\n\\subsection{Depth and normal orthogonality.}\n\\label{sub:depth_and_normal_orthogonality}\n\\vspace{-0\\baselineskip}\n\nIn reconstruction, depth and normal are two strongly correlated information, which follows locally linear orthogonality. Formally, for each pixel $x_i$, such a correlation can be written as a quadratic minimization for a set of linear equations,\n\\begin{align}\n\\label{eq:orthognal}\n&\\scr{L}_{x_i}(D, N) = ||[\\cdots,\\omega_{ji}(\\phi(x_j) - \\phi(x_i)), \\cdots]^T  N(x_i)||^2, \\nonumber \\\\\n&~\\text{where~} \\phi(x) = D(x)\\ve{K}^{-1}h(x), \\text{~} \\|N(x_i)\\|_2 = 1, \\nonumber\\\\\n&~\\text{~~~~~~~~} \\omega_{ji} > 0 \\text{~~if~~} x_j \\in \\hua{N}(x_i)\n\\end{align}\nwhere $\\scr{N}(x_i)$ is a set of predefined neighborhood pixels of $x_i$, and $N(x_i)$ is a $3 \\times 1$ vector. $\\phi(x)$ is the back projected 3D point from 2D coordinate $x$. $\\phi(x_j) - \\phi(x_i)$ is a difference vector in 3D, and $\\omega_{ji}$ is used to weight the equation for pixel $x_j$ \\wrt $x_i$ which we will elaborate later.\n\nAs discussed in Sec. \\ref{sec:related}, most previous works try to predict the two information independently without considering such a correlation, while only SURGE~\\cite{peng2016depth} proposes to apply the consistency by a post CRF processing only over large planar regions. In our case, we enforce the consistency over the full image, and directly apply it to regularize the network to help the model learning. Specifically, to model their consistency, we developed two layers by solving \\equref{eq:orthognal}, \\ie a depth-to-normal layer and a normal-to-depth layer. \n\n\\textbf{Infer normals from depths.} \n\\label{chap:d2n}\nGiven a depth map $D$, for each point $x_i$, in order to get $N(x_i)$. From \\equref{eq:orthognal}, we need to firstly define neighbors $\\hua{N}(x_i)$ and weights $\\omega_{ji}$, and then solve the set of linear equations. To deal with the first issue, we choose to use the 8-neighbor convention to compute normal directions, which considerably more robust than the 4-neighbor convention. \nHowever, it is not always good to equally weight all pixels due to depth discontinuity or dramatic normal changes may occur nearby. Thus, for computing $\\omega_{ji}$, we weight more for neighboring pixels $x_j$ having similar color with $x_i$, while weight less otherwise. Formally, in our case, it is computed as $\\omega_{ji} = \\exp\\{-\\alpha|I(x_j) - I(x_i)|\\}$ and $\\alpha = 0.1$. \n\nFor minimizing \\equref{eq:orthognal}, one may apply a standard singular value decomposition (SVD) to obtain the solution. However, in our case, we need to embed such an operation in the network for training, and back-propagate the gradient respect to input depths. SVD is computationally non-efficient for back-propagation. Thus, we choose to use mean cross-product to approximate the minimization~\\cite{jia2006using}, which is simpler and more efficient. \nSpecifically, from the 8 neighbor pixels around $x_i = [m, n]$, we split them to 4 pairs, where each pair of pixels is perpendicular at 2D coordinate \\wrt $x_i$, and in a counter clock-wise order, \\ie $\\hua{P}(x_i) = \\{([m-1, n], [m, n+1]), \\cdot, ([m+1, n-1], [m-1, n-1])\\}$. \nThen, for each pair, cross product of their difference vector \\wrt $x_i$ is computed, and the mean direction of the computed vectors is set as the normal direction of $x_i$. Formally, the solver for normals is written as, \n\\begin{align}\n\\label{eq:cross}\n&\\ve{n} = \\sum_{p\\in\\hua{P}}(\\omega_{p_{0}, x_i}(\\phi(p_{0}) - \\phi(x_i)) \\times \\omega_{p_{1}, x_i}(\\phi(p_{1}) - \\phi(x_i))), \\nonumber \\\\\n&N(x_i) = \\ve{n} / \\|\\ve{n}\\|_2\n\\end{align}\nThe process of calculating the normal direction for $x_i$ using one pair of pixels is in Fig. \\ref{fig:d2n}. \n\n%for each $q\\in\\theta(p)$, $R_q$ satisfies $(q-p)\\cdot(r-p) = 0, \\quad r \\in R_q$.\n% The normal direction of each point is computed based on the neighboring points after projecting to 3D space. The process of calculating normal direction of point $p$ is shown in Figure \\ref{fig:d2n}. $\\theta(p)$ is a set of neighboring (8) points of $p$. \n% Take point $q \\in \\theta(p)$ for example. $R_{q}$ is a set of points that satisfy the requirement: when projecting to 3D space, for $\\hat{q} \\in \\hat{\\theta}(p)$ and for $\\hat{r} \\in \\hat{R}_{q}$, $(\\hat(q)-\\hat(p) \\cdot (\\hat{r} - \\hat(p)) \\neq 0)$. Symbols with hat represent corresponding points in 3D space. Theoretically, the cross-product of any two non-collinear (in 3D space) vectors connecting $\\hat{p}$ and $\\hat{\\theta}(p)$ is the normal direction $N(p)$. To reduce the possiblity that the two vectors being collinear in 3D space, we require the vectors to be perpendicular when projected in 2D plane. The normal directions are averaged when iterating $q \\in \\theta(p)$, and then $l_2$ normalized to make it a unit vector. The normal direction is calculated as:\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.5\\textwidth]{figures/d2n.pdf}\n\\caption{Illustration of computing normal base on a pair of neighboring pixels. $x_i, x_{i1}, x_{i2}$ are 2D points, and \n$\\phi(x_i), \\phi(x_{i1}), \\phi(x_{i2})$ are corresponding points projected to 3D space. \nThe normal direction $N(x_i)$ is computed with cross product between $\\phi(x_{i1}) - \\phi(x_i)$ and $\\phi(x_{i2}) - \\phi(x_i)$.}\n\\vspace{-0.3\\baselineskip}\n\\label{fig:d2n}\n\\end{figure}\n\n\\textbf{Compute depths from normals.} \nDue to the fact that we do not have ground truth normals for supervision, it is necessary to recover depths from normals to receive the supervision from photometric error as discussed in Sec.~\\ref{sec:preliminaries}.\nTo recover depths, given normal map $N$, we still need to solve \\equref{eq:orthognal}. However, there is no unique solution. Thus, to make it solvable, we provide an initial depth map $D_o$ as input, which might lack normal smoothness, \\eg depth map from network output. Then, given $D_o(x_i)$, the depth solution for each neighboring pixel of $x_i$ is unique and can be easily computed. Formally, let $D_e(x_j | x_i) = \\psi(D_o(x_i), N(x_i))$ be the solved depth value calculated for a neighbor pixel $x_j$ \\wrt $x_i$. \nHowever, when computing over the full image, we still need to solve 8 equations jointly for each pixel of the 8 neighbors. Finally, by minimum square estimation (MSE), the solution for depth of $x_i$ is,\n\\begin{align}\n\\label{eq:depth}\nD_n(x_j) = \\sum_{i\\in\\hua{N}}\\hat{\\omega}_{ij}D_e(x_j | x_i), \\text{~~}\n\\hat{\\omega}_{ij} = \\omega_{ij} / \\sum_i{\\omega_{ij}}\n\\end{align}\n\n %ormal2depth layer takes depth map and normal map as input and outputs a ``shifted\" depth map. Take Figure \\ref{fig:d2n} for example, the depth values of points $\\theta(p)$ can be calcuated with the depth and normal direction of point $p$ known. From the calculation of normal direction, $(\\hat{p} - \\hat{q}) \\cdot N(p) = 0$. When projecting points from 2D plane to 3D space, $\\hat{p} = K^{-1}p$. $\\hat{p} = (\\hat{x}_p),\\hat{y}_p,\\hat{z}_p$, $p = (x_p, y_p, z_p)$ is a homogeneous 2D point and $z_p$ is the depth value of point $p$. $K^{-1}$ is the inverse of intrinsic matrix, which is determined by the camera. In linear the equation between depth and normal direction, $(K^{-1}(x_p, y_p, z_p) - K^{-1}(x_q, y_q, z_q))\\cdot N(p) = 0, q\\in\\theta(p)$, the only unknown $z_q$, \\ie  depth value of point $q$, has a unique solution. \n\n%As there are multiple points in the set $\\theta(p)$, multiple depth maps can be recovered corresponding to each point $q \\in \\theta(p)$. In our pratice, the $\\theta(p)$ includes 8 nearest points around point $p$. The 8 depth maps are weighted averaged to produce a reasonable depth output. As depth and normal discontinuity often happens where image gradients are large, similar to using image gradient in smoothness loss term, the image gradients are also calculated as weights to determine how much of each depth map contribute to final output. The output depth map is calculated as:\n% $$z_p = \\sum_{\\theta(p)}z_q\\frac{e^{(-\\alpha|\\partial_{\\overrightarrow{p-q}}I_p|)}}{\\sum_{\\theta(p)}e^{(-\\alpha|\\partial_{\\overrightarrow{p-q}}I_p|)}}, q\\in\\theta(p)$$\n% In which, $\\partial_{|\\overrightarrow{p-q}}I_p|$ is the image gradient value along the $\\overrightarrow{p-q}$ direction.\n\\vspace{-0\\baselineskip}\n\\subsection{Training losses}\n\\label{sub:training_losses}\n\\vspace{-0.\\baselineskip}\n\nGiven the consistency, in this section, we describe our training strategy. In order to supervise both the depth and normal predictions, we can directly apply the loss in \\equref{eqn:full} by replacing the output from depth network $D_o$ with the output after our normal-to-depth layer $D_n$ to train the model. We show in our experiments (\\secref{sec:experiments}), by doing this, we already outperform the previous state-of-the-art by around 10$\\%$ in depth estimation using the same network architecture.\n\nAdditionally, with normal representation, we apply smoothness over neighboring normal values, which provides higher order interactive between pixels. Formally, the smoothness for normal has the same form as $\\scr{L}_{s}$ in \\equref{eqn:regular} for depth, while the first order gradient is applied, \\ie $~\\scr{L}_{s}(N, 1)$. \n\nLast but not the least, matching corresponding pixels between frames is another central factor to find correct geometry. Additional to the photometric error from matching pixel colors, matching image gradient is more robust to lighting variations, which was frequently applied in computing optical flow~\\cite{li2017pyramidal}. \nIn our case, we compute a gradient map of the target image and synthesized target images, and include the gradient matching error to our loss function. Formally, the loss is represented as,\n\\begin{equation}\n\\label{equ:gradient}\n\\scr{L}_{g}(D_n, \\hua{T}, \\hua{M}) = \\sum_{s=1}^{S}\\sum_{x_t}\\ve{M}_s(x_t)\\|\\nabla I_t(x_t) - \\nabla \\hat{I_s}(x_t)\\|_1, \\nonumber\n\\end{equation}\n%In the future, we hope to investigate more in matching criteria such as with stronger descriptors like SIFT~\\cite{liu2011sift} or higher level convolutional features.\n\nIn summary, our final learning objective for multi-scale learning is,\n\\begin{align}\n\\label{eq:full_loss}\n&\\scr{L}(\\hua{D}, \\hua{N}, \\hua{T}, \\hua{M}) = \\scr{L}_{o}(\\{D_{nl}\\}, \\hua{T}, \\hua{M}) + \\nonumber\\\\\n&\\text{~~~~~~~~~}\\sum_l\\{\\lambda_g\\scr{L}_{g}(D_{nl},\\hua{T},\\hua{M}) + \\lambda_n\\scr{L}_{s}(N_l, 1)\\}\n\\end{align}\nwhere $\\hua{D} = \\{D_{nl}\\}$ and $\\hua{N} = \\{N_{l}\\}$ are the set of depth maps and normal maps for the target view.\n\n%Our intuition is to train a CNN that is capable of modeling the geometry consistency of a mostly rigid scene. To facilitate the learning of the network, we explicitly propose to model the constraint between depth and normal. The training samples of the framework consist of frame sequences captured by a monocular moving camera.normalsize\n\n\\textbf{Model training.} For network architecture, similar to \\cite{zhou2017unsupervised} and \\cite{godard2016unsupervised}, we adopt the DispNet \\cite{mayer2016large} architecture with skip connections as in \\cite{zhou2017unsupervised}. All \\textit{conv} layers are followed by a ReLU activation except for the top prediction layer. We train the network from scratch; since too many losses at beginning could be hard to optimize, we choose a two stage training strategy by first train the network with $\\scr{L}_{o}$ with 5 epochs and then fine-tune it with the full loss for 1 epoch. We provide ablation study of each term in our experiments.\n\n\n% To model a reasonable geometrical consistency, we propose the overall objective function as in Equation \\ref{equ:1}.\n% \\begin{equation}\n% \\label{equ:1}\n% \\begin{split}\n% L(D, I, Rt, \\lambda) = L_{warp}(D, I, Rt) + L_{smooth}(D, N, I) \\\\\n%  +  L_{grad}(D, I, Rt) + \\lambda(L_{dn}(D, N))\n% \\end{split}\n% \\end{equation}\n% Where\n\n% This objective function is a Lagrange fuction aiming to minimize the loss term $L_{warp}(D, I, Rt) + L_{smooth}(D, N, I) \\\\\n%  +  L_{grad}(D, I, Rt)$ subject to the constraint of geometrical constraint between depth map and normal map $L_dn(D, N) = 0$. The loss term consists of three components: photometric warping loss $L_{warp}(D, I, Rt)$, smoothness loss $L_{smooth}(D, N, I)$, image gradient matching loss $L_{grad}(D, I, Rt)$.\n\n% By understanding the depth and normal \n \n% \\subsection{Geometry consistency}\n\n% As depth and surface normal are not independent under the same scene, \n% thus we model the 3D geometry consistency by explicitly incorporating the relationship of depth and normal into the training procedure and use the relationship as a regularization in the objective function. The regularization term $L_{dn}(D,N) = 0$ is realized by two layers in our framework: depth2normal layer and normal2depth layer.\n\n\n% \\subsection{Implementation details}\n", "meta": {"hexsha": "18c35faac6ef43b506be83a4ebe9745eaa0664bc", "size": 14674, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tech_report/approach.tex", "max_stars_repo_name": "zhenheny/unsp_depth_normal", "max_stars_repo_head_hexsha": "d9574d8e1f155667a475b85bd68b86c24a32a3db", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-26T10:42:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T10:42:15.000Z", "max_issues_repo_path": "tech_report/approach.tex", "max_issues_repo_name": "zhenheny/unsp_depth_normal", "max_issues_repo_head_hexsha": "d9574d8e1f155667a475b85bd68b86c24a32a3db", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tech_report/approach.tex", "max_forks_repo_name": "zhenheny/unsp_depth_normal", "max_forks_repo_head_hexsha": "d9574d8e1f155667a475b85bd68b86c24a32a3db", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 112.0152671756, "max_line_length": 831, "alphanum_fraction": 0.7427422652, "num_tokens": 4075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4219962818910693}}
{"text": "\t\\documentclass[a4paper]{article}\n\\newcommand{\\dd}[1]{\\mathrm{d}#1}\n%% Language and font encodings\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[T1]{fontenc}\n\n%% Sets page size and margins\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\n\n%% Useful packages\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{braket}\n\\usepackage{amssymb}\n\\usepackage{subcaption}\n\\usepackage[section]{placeins}\n\\usepackage{float}\n\\usepackage{color}\n\\restylefloat{table}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\DeclareMathOperator*{\\argmin}{argmin}\n\n\\title{Gaussian Mixture Models and K-means Clustering}\n\\author{Shreyas Bapat, Bhavya Bhatt, GaganDeep Tomar}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nThe following discussion revolves around the modelling of data classifier in accordance with the bayesian decision theory. Unlike previous assignment here we do not assume class conditional probablity to be normal but instead we assume that the distribution is in the form of function that can be approximated as the linear combination\\footnote{refer to the appendix for more discussion on functional vector space} of many gaussians(precisly k-gaussians).\n\\end{abstract}\n\n\\section{Introduction}\n\nThe Bayesian Decision Theory is a probablistic theory for classifying the data points on the basics of pre-known prior and class conditional probabilities(which in real scenario is not known in any closed form expression). We give below the basics of gaussian mixture models which we would use to estimate our class conditional probability and thereby applying bayesian decision rule to estimate the class of the data points. We also introduce the K-means clustering method which we would use to get the initial parameters for the GMM model.\n\\subsection{Gaussian Mixture Model}\nIn previous assignment we assumed that the class conditional probability is of the gaussian form and we there after derived the decision boundary. But in real scenario our data statistically may not be coming from such a well behaved closed form probability distribution(which here we considered normal distribution). So to make our probability distribution more general we write our class conditional probablity density as linear combination of linearly independent function vectors in infinite dimensional functional space as follows\\footnote{complete discussion is given in appendix}\n\\begin{equation}\np(\\bar{x}) = \\sum_{k=1}^{K}\\Pi_{k}G_{k}\n\\end{equation}where $K$ is number of clusters which we are using to approximate our true probability distribution\\footnote{In principle we should take infinite number of such gaussians to exactly extract the true probability distribution from which data points are coming}. Now here $G_{k}$ represents gaussian distribution function with parameters as $\\left(\\mu_{k}, \\sigma_{k}\\right)$ and $\\Pi_{k}$ represents the coefficients of $G_{k}$. Now to fit the above probability distribution such that it optimize the cost function we estimate the parameter vector $\\bar{\\theta}=\\left[\\Pi_{k}, \\mu_{k}, \\sigma_{k}\\right] \\forall k$ which would do this job.\n\\subsection{Maximum Loglikelihood Estimate of GMM and Clustering}\nWe know that to estimate the parameters we optimize the total loglikelihood which is as follows\n\\begin{equation}\np(D|\\bar{\\theta})=\\prod_{n=1}^{N}p(\\bar{x_{n}}|\\bar{\\theta})p(\\bar{\\theta})\n\\end{equation}Now we optimize the log likelihood function $l(\\bar{\\theta})$ to estimate the unknown parameter vector $\\bar{\\theta}$\n\\[\n\\begin{split}\nl(\\bar{\\theta})&=\\sum_{n=1}^{N}\\ln(p(\\bar{x_{n}}|\\bar{\\theta})p(\\bar{\\theta})) \\\\\n               &=\\sum_{n=1}^{N}\\ln(\\sum_{k=1}^{K}\\Pi_{k}G_{k}(\\bar{x_{n}}))\n\\end{split}\n\\]But Now we cannot apply our conventional approach as it would be too complex to evaluate, the reason behind is that we don't know how different data points are distributed under different gaussians in the summation. If we would know that then we can separately apply optimization for each gaussian considering only those data points which are coming from that gaussain itself. This problem of dividing the data points based on some distance measure is what we call clustering of the data set into $K$ clusters. We mention below the most common algorithm used for clustering, K-means clustering.\n\\subsection{K-means Clustering}\nThe cost function considered here is measure of distortion which is defined as follows\n\\begin{equation}\nJ=\\sum_{n=1}^{N}\\sum_{k=1}^{K}z_{nk}\\left|\\bar{x_{n}}-\\bar{\\mu_{k}}\\right|^2\n\\end{equation}where $z_{nk}$ is $kth$ component of one-hot encoded vector $\\bar{z_{n}}=\\left[0\\dots1\\dots0\\right]$ where one is at the position equal to the number of cluster to which $\\bar{x_{n}}$ data points belong to. Now during optimization we have now an additional latent information variable $\\bar{z}$ which is also a parameter to be optimized. But how we define that a particular data point belong to some particular cluster? the following is the criteria to assign the cluster number and thus vector $\\bar{z}$ to a data point\n\\[\ncluster\\ to\\ which\\ x_{n}\\ belongs\\ to = \\argmin_{k}\\left|\\bar{x_{n}}-\\mu_{k}\\right|\n\\]Now this is somewhat similar to chicken-egg problem because of the interdependence of $\\bar{z}$ and $\\mu_{k}$. So to deal with this kind of optimization\\footnote{this type of optimization problems are called ill-posed optimization problem} we employ EM method of optimization. The algorithm is given below\n\\begin{algorithm}\n\\caption{Euclid’s algorithm}\\label{alg:euclid}\n\\begin{algorithmic}[1]\n\\Procedure{Euclid}{$a,b$}\\Comment{The g.c.d. of a and b}\n\\State $r\\gets a\\bmod b$\n\\While{$r\\not=0$}\\Comment{We have the answer if r is 0}\n\\State $a\\gets b$\n\\State $b\\gets r$\n\\State $r\\gets a\\bmod b$\n\\EndWhile\\label{euclidendwhile}\n\\State \\textbf{return} $b$\\Comment{The gcd is b}\n\\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n\\section{Coutour Curves and Covariance Matrix}\\label{appendix}\nIn this section\\footnote{for a complete discussion refer to the appendix} we discuss the relation between the shape of the cross section produced by slicing the bivariate gaussian distribution with a hyperplane parallel to the 2D-feature plane and covariance matrix. The bivariate gaussian distribution is a follows\n\\begin{equation}\nP(\\bar{x}|C_{i}) = \\frac{1}{\\sqrt{det(2\\pi\\mathbf{\\Sigma_{i}})}}exp\\{\\frac{-1}{2}(\\bar{x}-\\bar{\\mu_{i}})^{\\intercal}\\mathbf{\\Sigma_{i}}^{-1}(\\bar{x}-\\bar{\\mu_{i}})\\}\n\\end{equation}with $mu_{i}$ be a $2\\times1$ mean column vector and $\\Sigma_{i}$ be $2\\times2$ covariance matrix. So we assume the covariance matrix in its expanded form as\n\\[\n\\mathbf{\\Sigma} = \\left[ {\\begin{array}{cc}\n\\Sigma_{11} & \\Sigma_{12} \\\\\n\\Sigma_{12} & \\Sigma_{22} \\\\\n\\end{array}} \\right]\n\\]\nwhere diagonal terms are variance of the features and off-diagonal terms are covariance bewteen feature-1 and feature-2. The above matrix is symmetric precisly due to the fact that $cov(x_{i}, x_{j})=cov(x_{j}, x_{i})$. Now we set the above distribution function to some constant $k$ and find the resultant curve projected on the feature space which is called constant contour curve.\n\\[\n\\frac{1}{\\sqrt{det(2\\pi\\mathbf{\\Sigma_{i}})}}exp\\{\\frac{-1}{2}(\\bar{x}-\\bar{\\mu_{i}})^{\\intercal}\\mathbf{\\Sigma_{i}}^{-1}(\\bar{x}-\\bar{\\mu_{i}})\\} = k\n\\]after some manupilation and taking log both sides we get\n\\[\n(\\bar{x}-\\bar{\\mu})^{\\intercal}\\mathbf{\\Sigma}^{-1}(\\bar{x}-\\bar{\\mu})=-2\\ln(\\sqrt{2\\pi\\left|\\mathbf{\\Sigma}\\right|}k)\n\\]where we have dropped the index $i$ for simplicity and the whole analysis can be done without the loss of generality. Now writing the matrix in full and evaluating the required operation on the column vector we get finally\n\\begin{equation}\\label{cov}\n\\Sigma_{22}X_{1}^{2} + \\Sigma_{11}X_{2}^{2} - 2\\Sigma_{12}X_{1}X_{2} + 2\\ln(\\sqrt{2\\pi\\left|\\mathbf{\\Sigma}\\right|}k)=0\n\\end{equation}where $\\bar{x}=\\left[x_{1}x_{2}\\right]^{\\intercal}$, $\\bar{\\mu}=\\left[\\mu_{1} \\mu_{2}\\right]^{\\intercal}$, $X_{1}=x_{1}-\\mu_{1}$ and $X_{2}=x_{2}-\\mu_{2}$. This equation is in the form of general equation for conic section\n\\begin{equation}\nax^{2}+by^{2}+cxy+d=0\n\\end{equation}Now in our case the coefficients $a$ and $b$ are $\\Sigma_{22}$ and $\\Sigma_{11}$ respectively. The above equation thus represents an ellipse in our case as variances are always positive values. Now from the elementary analysis of conics we know that the coefficient of $xy$ represent the extend to which the ellipse is titled w.r.t to the axis. Also the coefficients of $x^{2}$ and $y^{2}$ represents the length of major and minor axis respectively. Now we consider $\\Sigma_{12}=0$ (covariance matrix is diagonal) then the we recover the familiar equation of ellipse with major and minor axis parallel to the x-y axis. The equation is\n\\begin{equation}\n\\frac{X_{1}^{2}}{\\left(\\frac{-2\\ln(\\sqrt{2\\pi\\left|\\mathbf{\\Sigma}\\right|}k)}{\\Sigma_{22}}\\right)}+\\frac{X_{2}^{2}}{\\left(\\frac{-2\\ln(\\sqrt{2\\pi\\left|\\mathbf{\\Sigma}\\right|}k)}{\\Sigma_{11}}\\right)}=1\n\\end{equation}which is of the form\n\\[\n\\frac{x^{2}}{A^{2}}+\\frac{y^{2}}{B^{2}}=1\n\\]the above is the equation of countour curve projected in the feature space. Now we consider following three cases\n\\bibliographystyle{alpha}\n\\bibliography{sample}\n\\end{document}", "meta": {"hexsha": "1d4196b857f53b58c7bd4ae854b785e69cd828e7", "size": 9328, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment-2/report.tex", "max_stars_repo_name": "spino17/Pattern-Recognition-Course", "max_stars_repo_head_hexsha": "8e600ea0ce66391df5564237bb9bf1203f2c82ab", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assignment-2/report.tex", "max_issues_repo_name": "spino17/Pattern-Recognition-Course", "max_issues_repo_head_hexsha": "8e600ea0ce66391df5564237bb9bf1203f2c82ab", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment-2/report.tex", "max_forks_repo_name": "spino17/Pattern-Recognition-Course", "max_forks_repo_head_hexsha": "8e600ea0ce66391df5564237bb9bf1203f2c82ab", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.8, "max_line_length": 651, "alphanum_fraction": 0.7535377358, "num_tokens": 2605, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4219465293535234}}
{"text": "\\section{Fourier}%\n\\label{fourier.detailed}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Fourier folder}%\n\\label{fourier.folder}\n\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FFolder.eps}$$\n\\caption{The ``Fourier'' folder}\n\\end{figure}\n\nThis folder shows all the necessary information that has to do with \nFourier transformation.\n\nThe basic idea behind this folder is that different Fourier calculations \ncan be kept in memory simultaneously and that the setting for each of these \n{\\it Fourier sets} can be restored with a click of the mouse.\n\nBecause of this possibility there is a need for a {\\bf Title} for \nidentification by the user.\nThen there are {\\bf From} and {\\bf To}, which define the frequency range,\nfor which the Fourier spectrum should be calculated.\nAs with the \\helpref{fit module}{period.folder} there is the possibility\nto use weighted data for the Fourier calculations.\n\n In the next line the Nyquist frequency\nis displayed. This value should be a good\nestimate for the upper limiting frequency due to the sampling pattern in\nthe currently selected time string.\nThis frequency value given does {\\it not} depend only on the time base \nand the number of points in the currently selected time string, \nbut uses a more sophisticated algorithm, estimating the average \ntime gap between neighboring points, ignoring large gaps.\n\nWith the choice item {\\bf Step rate} it is possible to change the accuracy \nof the Fourier calculation. This means, that the step at which the frequency \nrange is sampled can be changed. {\\bf High, medium and low} are good \nestimates (High uses most time to calculate).\nWith {\\bf Custom} a user defined value can be chosen \nin the text item next to it.\nFor the other 3 possibilities the text item can not be edited and\nwill contain the value that would be used in this case.\n\nNext the {\\bf highest peak} line gives the highest peak that was \nfound during the calculation with the coresponding frequency and amplitude.\n\nWith {\\bf Calculations based on} it is possible to select different data types\nfor the calculation. These correspond to the values that can be displayed in\nthe \\helpref{Time string graph}{timestring.graph} and\n\\helpref{Time string table}{timestring.table}%\n. {\\bf Spectral window }allows the calculation of the spectral window centered\nat zero frequency for the currently selected time string.\n\nThe {\\bf Compact} option allows to limit the - often very massive - output \nof Fourier, because with {\\bf Peaks only} only the local minima and maxima\nare kept.\n\nThe \\button{Calculate} takes all the settings above and \ncalculates a new Fourier spectrum with this. (See\n\\helpref{Fourier calculate}{fourier.calculate}\nfor more details.\n\nIn the list box below the \\button{Calculate}, all the previous\nFourier calculations are listed with their title. Selecting one of these will\nupdate all the values above to the values used for that specific\ncalculation.\n\nWith the \\button{Delete} the currently selected Fourier calculation\ncan be removed from memory - only the log file entries will remain.\nThe \\button{Rename} allows to change the title for the currently\nselected Fourier calculation. To do so, the\n\\helpfigref{rename title dialog}{fourier.rename.dialog} is opened.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FRename.eps}$$%\n\\caption{The ``rename title'' dialog}%\n\\label{fourier.rename.dialog}\n\\end{figure}\n\nThe \\button{Display data} opens up the \n\\helpref{Fourier data window}{fourier.table}\nand allows examination of the output of the calculation.\n\nNext the \\button{Export} allows the output to be written to a file.\n(See \\helpref{Fourier export}{fourier.export} for details.)\n\nFinally the \\button{Display graph} opens up the\n\\helpref{Fourier graph window}{fourier.graph}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Fourier calculate}%\n\\label{fourier.calculate}\nWhen starting a Fourier calculation with the \\button{Calculate} in\nthe \\helpref{Fourier folder}{fourier.folder}%\n, the main window will change\nto represent the \n\\helpfigref{current status of calculation}{fourier.calculate.dialog}%\n. In this case it will give the percentage of the calculations completed.\nAgain the \\button{Cancel} can stop the calculations.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FCalculate.eps}$$%\n\\caption{The ``Fourier calculate'' window}%\n\\label{fourier.calculate.dialog}\n\\end{figure}\n\nIn the case of {\\bf observed} or {\\bf adjusted} values selected \nfor calculations, the user will first be\nasked if the average zero point should be subtracted with the\n\\helpref{zero point dialog}{fourier.zeropoint}%\n.\n\nAfter the calculation has finished, the\n\\helpfigref{include dialog}{fourier.include.dialog}\nwill show up and ask, if the currently found highest peak\nshould be included in the list of frequencies of the\n\\helpref{Fit module}{period.folder}%\n.\n\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FInclude.eps}$$%\n\\caption{The ``include'' dialog}%\n\\label{fourier.include.dialog}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Zero point}%\n\\label{fourier.zeropoint}\nThe Fourier transform has the property, that if the mean amplitude\nof the currently selected time string for calculation is {\\it not Zero}\nadditional features in the low frequency range will show up.\nThis is due to this Zero point shift and the features showing up are \ncomparable to a scaled spectral window centered at frequency 0.\nThis feature may even dominate the whole spectrum.\n\nTo overcome this problem \\period will ask with the\n\\helpfigref{zero point dialog}{fourier.zeropoint.dialog}, if\nit should subtract a (calculated) zero point, when the calculations\nare based on {\\bf Original} or {\\bf Adjusted} data.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FZeropoint.eps}$$%\n\\caption{The ``zero point'' dialog}%\n\\label{fourier.zeropoint.dialog}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Fourier export}%\n\\label{fourier.export}\n\n\\subsection{Fourier table}%\n\\label{fourier.table}\nThis \\helpfigref{window}{fourier.table.window},\nwhich shows up, when the \\button{Display data} in the\n\\helpref{Fourier folder}{fourier.folder} has been pressed,\nshows a table of {\\bf frequencies, Fourier amplitudes and Fourier power},\nof the currently active Fourier calculation.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FTable.eps}$$%\n\\caption{The ``Fourier table'' window}%\n\\label{fourier.table.window}\n\\end{figure}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Fourier graph}%\n\\label{fourier.graph}\nThe \\helpfigref{Fourier graph window}{fourier.graph.window} will show up,\nwhen the \\button{Display Graph} in the\n\\helpref{Fourier folder}{fourier.folder} has been pressed.\nIt will show the graph of the currently active Fourier calculation.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FGraph.eps}$$%\n\\caption{The ``Fourier graph'' window}%\n\\label{fourier.graph.window}\n\\end{figure}\n\nActually many of the menus are the same as for the\n\\helpref{time string graph}{timestring.graph}.\n\nThe only new feature is the \\menu{display}, in which it is\npossible to change the graph to display {\\it power} instead of {\\it amplitude}\nwith the \\menuentry{Use power}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Noise}%\n\\label{fourier.noise}\nSadly observations are not perfect and usually contaminated with noise.\nThis noise may come from many sources: Observations, instrumentation,\nthe object itself, modes (frequencies) not yet found in the spectra, etc\\ldots\n\nAs this noise is thus only pseudo-random there is no way to eliminate \nit during data reduction.\nThus all the noise produces some unpredictable pattern in the Fourier spectrum.\nSo it is possible, that some peaks in the Fourier spectrum are found that\nare not present in the object observed.\n\nBut how can noise be separated from a real signal?\nThere is never a guarantee for a sure identification, \nbut observational\n(\\urlref{Breger et al., 1993}{A\\&A 271,482})\nand numerical simulations\n(\\urlref{Kuschnig et al.,1997}{A\\&A 328,544})\nhave shown, that the {\\it ratio} between {\\it signal} and {\\it noise} in \namplitude should at least be 4.0 to give good confidence.\n\nSo {\\bf signal} is defined as either \nthe amplitude in the {\\bf Fourier spectrum}\nor the amplitude of the {\\bf least square fit solution}\nfor a certain peak, and {\\bf noise} is defined as the average amplitude\nin a close frequency range to the peak unde consideration\nafter subtracting the frequency with the \n\\helpref{fit module}{period.folder}\nand using the resulting residuals for the calculation of noise.\nThe \\helpref{Fourier module}{fourier.folder} offers two options \nto calculate noise.\nThese are:\n\\helpref{Noise at frequency}{fourier.noisefrequency}\nand\n\\helpref{Noise spectrum}{fourier.noisespectrum},\nwhich both can be reached from the \\menu{Fourier}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Noise at frequency}%\n\\label{fourier.noisefrequency}\nWhen the \\menuentry{Noise at frequency} in the \\menu{Fourier}\nhas been selected, the\n\\helpfigref{noise at frequency dialog}{fourier.noisefrequency.dialog}\nwill show up.\n\\begin{figure}[h]%\n\\label{fourier.noisefrequency.dialog}\n$$\\image{0cm;0cm}{FNoise.eps}$$%\n\\caption{The ``noise at frequency'' dialog}%\n\\end{figure}\n\nMost of the contents of this dialog are similar to that of the\n\\helpref{Fourier folder}{fourier.folder}.\n\nThe only difference is that the frequency at which the noise\ncalculations should be centered can be entered as well as\nthe extent of the range.\n\nAfter the \\button{OK} has been pressed and the calculation has finished\na window will pop up and show the result.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Noise spectrum}%\n\\label{fourier.noisespectrum}\nThe noiselevel is not necessarily constant in the whole frequency spectrum.\nThe {\\bf Fourier module} also supports the possibility to calculate a\n{\\bf noise spectrum}.\n\nThis is basically the same procedure as for\n\\helpref{noise at frequency}{fourier.noisefrequency}, but the calculation\nis repeated at different parts of the frequency range.\n\nWhen the \\menuentry{Noise spectrum} in the \\menu{Fourier}\nhas been selected, the\n\\helpfigref{noise spectrum dialog}{fourier.noisespectrum.dialog}\nwill show up.\n\\begin{figure}[h]\n$$\\image{0cm;0cm}{FNoiseSpectrum.eps}$$%\n\\caption{The ``noise spectrum'' dialog}%\n\\label{fourier.noisespectrum.dialog}\n\\end{figure}\n\nThe dialog is very similar to that of \n\\helpref{noise at frequency}{fourier.noisefrequency}.\nThe main difference is that the frequency range {\\bf from} and {\\bf to}\nhas to be entered as well as the spacing between consecutive\nnoise values centered at frequencies of interest.\nAfter the \\button{OK} has been pressed and the calculation has finished,\na window will pop up and show the results.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"period98\"\n%%% End: \n", "meta": {"hexsha": "a5e5594d521ce667284c16a3a3293483ede63e1e", "size": 11030, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/d_fourier.tex", "max_stars_repo_name": "msperl/Period", "max_stars_repo_head_hexsha": "da4b4364e8228852cc2b82639470dab0b3579055", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-10T20:13:11.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-10T20:13:11.000Z", "max_issues_repo_path": "doc/src/d_fourier.tex", "max_issues_repo_name": "msperl/Period", "max_issues_repo_head_hexsha": "da4b4364e8228852cc2b82639470dab0b3579055", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/d_fourier.tex", "max_forks_repo_name": "msperl/Period", "max_forks_repo_head_hexsha": "da4b4364e8228852cc2b82639470dab0b3579055", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9637681159, "max_line_length": 79, "alphanum_fraction": 0.7327289211, "num_tokens": 2609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4219465293535234}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Chapter: Introduction to Algorithms \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[../main.tex]{subfiles}\n\\begin{document}\n\\begin{chapquote}\n{Niklaus Wirth, \\textit{Algorithms + Data Structures = Programs, 1976}}\n``We problem modeling with data structures and problem solving with algorithms, Data structures often influence the details of an algorithm. Because of this the two often go hand in hand.''\n\\end{chapquote} % this is a fake quote, need to change later\n\nIn this chapter, we build up a global picture of algorithmic problem solving  to guide the reader through the whole ``ride''.\n%\n% ``Problem modeling'' are about understanding the problem and followed by ``problem solving''--set up a series of operations on data structures that can get the output from the input. The quote might not be totally true; when we are modeling/understanding a problem, the importance of data structure is highly dependable on the complexity of a problem--for simple problems, fixing its data structures might help you come up with a solution right away, whereas, in a more complex scenario where it seems no data structures or classical algorithms can fit in to solve it, data structures will be the last element to worry about. In all, it tells us the inseparable relation between data structures and algorithms. \n\\section{Introduction}\n\\label{sec_introduction_introduction}\nIn the past, a person who is capable of solving  complex math/physics computation problem faster than the ordinaries stands out and is highly seek out. For example, during world war two, Alen Turing hired engineer who was fast solving the Sudoku problems. These kind of stories die with the rise of powerful machines, with which the magic sticks are handed over to ones--programmers who are able to harness the continually growing computation power of the hardwares to solve those once only a handful or none of people that can solve, with algorithms. \n\nThere are many kinds of programmers. Some of them code  the real-world, obvious and easy rules to implement applications, some others challenge more computational problems with  knowledge in math, calculus, geometry, physics, and so. We give a universal definition of algorithmic problem solving--information processing. Three essential parts include: Data structures, algorithms, and programming languages. Knowing some basic data structures, some types of programming languages and some basic algorithms are enough for the first type of programmers. They might focus more on the front-end, such as mobile design, webpage design. The second type of programmers, however, need to be equipped with more advanced data structures and algorithm design and analysis techniques. Sadly, it is all just a start, the real powerful lie in the combination of these algorithm design methodologies and the other subjects. Math among all is the most important, for both design and analysis, as we will see in this book. Still a candidate with strong algorithmic skills is off a good start, at least with some basic math knowledge, we can almost always manage to solve problems with brutal force searching, and some others with dynamic programming. \n\nLet us continue to define the  algorithmic problem solving as information processing, just \\textbf{what} it is, and not \\textbf{how} at this moment.  \n\\subsection{What?}\n\\paragraph{Introduction to Data Structure} Information is the data we care about, which needs to be structured. And we can think of data structure as our low-level file manager, what it needs to do is to support four basic operations--'find' a file belongs to Bob, 'Add' Emily's file, 'Delete' Shown's file, 'Modify' Bod's file. Why structured? If you are the file manager, would you just throw all the hundreds of files over the floor or just throwing over in the drawer? Nope, you line them up in the drawer, or you even put a name on top of each file and order them by their first name. The way data is structured in program is similar to real-world system, simply lining up, or organize like a tree structure if there is some belonging and hierarchical ordering which appears in institutions and companies. \n\n\n\\paragraph{Introduction to Algorithms} Algorithms further process  data with a series of basic operations--searching, modifying, inserting, deleting, and so--that come with input data's structures or even auxiliary data's  structures if  necessary. How to design and analyze this series of operations are the field of algorithmic problem solving. \n\nSame problem can be solved with different level of complexities in time and storing space. Deep down, algorithm designers \n\nWith this information processing step, we get our task done--computing our high school math, sorting the student ids in order, searching a word in a document, you name it. \n\n\\paragraph{Programming Language} A programming language especially higher level of language such as Python would come with data structures that might already have the basic operations: search, modify, insert, delete. For example, the \\texttt{list} module in Python, it is used to store an array of items, it comes with \\texttt{append()}, \\texttt{insert()}, \\texttt{remove}, \\texttt{pop} that you can operate your data, thus, a \\texttt{list} can be viewed as a data structure. If we know what data structure we save our input instance, what algorithms to use to operate the data, we can code these rules with a certain programming language and let the computer take over and if it won't demands billions of operations, it will get the result way more faster than humans are capable of, this is why we need computers anyway.\n\n\n\n\\subsection{How?} \nKnowing what it is, now, you would ask how.  How can we know how to organize our data, how to design and analysis our algorithm? how to program it?  We need to study existing and well-designed data structures, algorithm design principle and algorithm analysis techniques, understand and analyze our problems, and study classical algorithms that our predecessors invented for solving a classical problem, only then when we are seeing a problem, old or new, we are prepared, we compare it with problems we know how to solve: if it is exact the same same, congratulations, we would solve our problem; if it is similar to a certain category of problems, at least we start from a direction and not from scratch; if it is totally new, at least we have our algorithm design principle and analysis techniques, we design one after understanding the problem and relate it to all our skills. Of course, there are problems that no body has been able to solve it yet. We will study it in the book so that you would identify when the problem you are solving is too hard. \n\n\\paragraph{The Tree of Algorithmic  Problem Solving} Back to the question,how? We study and build up our knowledge and skill base. A well-organized and explained knowledge base will surely ease our nerves and make things easier.  The field of algorithms and computer science is highly flexible. Assuming the knowledge of computer science is a tree, and assume that each leaf is a specific algorithm to solve a specific type of problem. What would be the root of the tree? The main trunk, branches? It is impossible for us to check or even count the number of leaves. But, we can understand the tree by knowing its structures. This book is fascinated with this belief and shows a lot of effort into organizing the algorithm design and analysis methodologies, data structures, and problem patterns. It starts with  the rooting algorithm design and analysis principle, and we study classical leaves by relating it and explained with our principle rather than treating each one individually. \n\nThe algorithm design and analysis principles comprise the trunk of the algorithm tree. A branch would be applying a type of algorithm design principle on a certain type of data structure, for example, algorithms related to tree structures, to graph structures, to string, to list, to set, to stack, to priority queue and so on. \n\n\n\\subsection{Organization of the Contents}\nBased on our understanding of what is algorithmic problem solving and how to solve it, we organize the content of the book as:\n\\begin{itemize}\n    \\item Part~\\ref{} includes the abstract commonly used data structures in computer science, the math tools for design, correctness prove, and some geometry knowledge that we need to solve geometry problems that are still often seen in the interviews.\n    \\item Part~\\ref{}  strengthens the programming skills by implementing data structures and some basic coding.\n    \\item Part~\\ref{} is our main trunk of the algorithmic programming solving.\n    \\item Part~\\ref{} to Part~\\ref{} takes us to different branches and showcases classical algorithms within that branch. One or many algorithm design principles can be applied to solve these problems. \n    \\item Part.~\\ref{} is the problem patterns. Actually, if we have a good grasp of the sections before, this section is more of a review and exercises section. The finding of the patterns are to ease our coding interview preparation. \n\\end{itemize}\n\n% \\begin{itemize}\n%     \\item Data Structures: Algorithms are like the brain of an animal, and the data structures are like the skeletons. Data structures decide where and how the data is saved and accessed. And algorithms need to be shaped in a way to fit on the skeletons. For example, if you are given a skeleton of a dog, your brain needs to manage to walk and run by coordinating the four legs instead of two legs that comes with a human skeleton. We introduce each type of data structure in Part.~\\ref{part_data_structure}.\n    \n\n%     \\item Algorithm Design and Analysis: With the problem at hand, we need algorithm design methodologies to derive some sets of rule and actions that can fully or partially solve our problems with all the knowledge we can -- common sense, instinct, math, physics, and you name it! Analyzing the algorithms is like estimating or evaluating its performance. In realty, a problem can be solved with multiple different algorithms, which makes algorithm analysis an essential tool we live upon to make the best choice among options. We introduce the principle of algorithm design and analysis in Part.~\\ref{part_algorithm_design_and_analysis}, searching in Part.~\\ref{part_complete_searching} and optimization methods in Part.~\\ref{part_dp_greedy}\n\n%     \\item Programming Language: At this step, we have all of our solutions derived and analyzed on paper! With a programming language such as Python that we use in this book, we are able to put it into construction and followed by execution to get real solution for complex problems that would be infeasible to compute by us humans. \n\n% \\end{itemize}\n\n%  I'm not going to expand anything about algorithm design principle or analysis skills, data structures or classical algorithms or problems, cause that is the content of the book! Here, we focus on the approaches; we separate the algorithmic problem solving into two steps: Problem Modeling and Problem Solving. Dont' worry that your knowledge base is not large enough, just focus on how to solve our problem with your limited knowledge base.  We will extend the content of problem modeling and problem solving in the next two sections. \n\nAs a part of the introduction part,  As I always believe, setting up the big picture should be be very first part of any technical book; it helps to know how each part  plays its role global-wise with  more details comes from the preface. The organization of this chapter follows the global picture and each element of algorithmic problem solving is further briefed on in each section: \n\\begin{itemize}\n    \\item Problem Modeling (Section.~\\ref{sec_problem_modeling}), includes Data structures, hands-on examples. \n    \\item Problem Solving (Section.~\\ref{sec_problem_solving}), includes Algorithm Design and Analysis Methodologies (Section.~\\ref{sec_algorithm_design})  and Programming Language(Section.~\\ref{sec_programming_languages}).\n\\end{itemize}\n\n\\section{Introduction}\n\\label{sec_history_computer_science}\n\\paragraph{Algorithms are Not New} Algorithms should not be considered purely abstract and obscure. It origins from real-life problem solving including time before there even exist computers (machines).  The recurrence were studied as early as 1202 by L. Fibonacci, for whom the fibinocci number is named. Algorithms, as a set of rules/actions to solve a problem, they leverage any form of knowledge -- math, physics. Math stands out among all, as it is our tool to understand problems, present relations, solve problems, and analyze complexity. In this book, we use math in the most practical way and only at places where it really matters.  The difference is, with computer program written in a certain computer language to execute the algorithm is way more efficient generally than doing it in person.   \n\n\\paragraph{Algorithms are Everywhere} in our daily life.   Assume you are given a group of people, your task is to find if there is a person in the group that is born on a certain day.  The most intuitive way to do is to check each of them and see if his/her birthday matches with the target, this needs you to go a full-round of this group of people. If you observed that this group of people is grouped by the months, then you can nail down the times of checking by checking the subgroup that matches the month of your target day. The first way is the easiest and most straightforward way to solve a problem, which is called brute force. The second one is involves more observation and might takes less time to get the answer.  However, they both have one thing in common, need us to nail down the possibilities; in the first way, we nail it down one by one, and in the second, we nail it down by almost 11/12 of the original possibility. We can say solving the problem is to find its solution  in solution space, and different way of finding the solution is called different algorithm. \n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Problem Modeling}\n\\label{sec_problem_modeling}\n The very first thing is to find or be given a problem exist in the world and solving it can bring practical value and hopefully make some good effect on the mother natural or humanity. In problem modeling, we analyze the characteristics of problem and relate it on certain data structures. %This element is the most difficult to abstract since it is highly dependable on problems and might require multi-disciplined knowledge. We will try to offer some guideline in this chapter, however, mostly we will rely on learning classical problems and its corresponding algorithms to improve our instinct or feeling of the algorithm problem solving.\n \n \n% The meaning of existence of computer science is to solve real-world problems. Understanding how to extract from real-world problems and restate them using a computer science languages and terminologies is the main purpose of this section. \n\nIn the stage of problem modeling, we define the problem and model our problems with data structures. In this section, we first answer the question, ``what is a problem in computer science?'' Then, we introduce the ``skeleton'' --Data Structures to prepare for our next step --problem solving. Then, we give hands-on Examples about how to model a problem with data structures.%of the algorithms, In order to do this,  the We answer three questions here: (1)  \n\nIf you are a zoologist, these are how you define a species: describe the fresh and appearance, put together its skeletons, search similar well-studied species from dataset, match observed behaviors,  and induce the unknown ones from similar species.   There are two key steps to problem modeling:\n\\begin{enumerate}\n    \\item Understand the problems (Section.~\\ref{sec_problem_statement}): We give the definition of problems, followed by the problem categories which categorizing problems without the context of data structures. This is like describe the fresh of a species\n    \\item Apply data structures to the problems (Section.~\\ref{sec_data_structures}): We then describe our problem in terms of data structures; connecting the fresh and the skeletons. We also analyze the the problem by exploring its solution space and simulating the process; finding the series of actions between the input and output instance. \n\\end{enumerate}\n\n\\subsection{Understand Problems}\n\\label{sec_problem_statement}\n\\subsubsection{Problem Formulation} A problem can be a task or something to be done according to the definition of ``problem'' in English dictionary, such as finding a ball numbered $11$ from a pool of numbered balls,  sorting the list of students by their IDs. The first thing we need to understand should be \\textit{problem formulation} and the closest knowledge we need to define a problem comes from the field of math. The intuitive definition of a problem is that it is a set of related tasks, usually infinite. \n\nThe formal definition of problems: A problem is characterized by:\n\\begin{enumerate}\n    \\item \\textbf{A set of input instances:} The \\textit{instance} represents some real examples of this type of problems. And input instances are data, which needed to be saved and accessed from the machine. This mostly requires us to define a data structure, however, different data structures can be used to define.\n    \\item \\textbf{A task to be preformed on the input instances:} The problem definition should usually comes with examples to better explain how the task decides the output of the exemplary input instances.\n\\end{enumerate}\n\nFor example, we formulate the problem of drawing a call from the pool as: Given a list of unsorted integers, find if the number $11$ is in the list, return true or false.\n\\begin{lstlisting}[numbers=none]\nExample: \nGiven the list: [1, 34, 8, 15, 0, 7]\nReturn False because 11 does not appear in the list.\n\\end{lstlisting}\n\n\n\\subsubsection{Problem Categories} Now, to better understand what computer science deals with, we categorize problems commonly solved in the field. \n\n\\paragraph{Continuous or Discrete?}\nBased on whether the variables are continuous or discrete, we have two categories of problems:\n\\begin{enumerate}\n    \\item \\textbf{Continuous problems:} relates to continuous solution spaces.\n    \\item \\textbf{Discrete problems:} relates to discrete solution spaces. \n\\end{enumerate}\nThe field of algorithmic problem solving is highly correlated to \\textit{Discrete Mathematics}, which covers topics such as arithmetic and geometric sequence, recurrence relations, inductions, graph theory, generating functions, number theory, combinatorics, and so. Through this book. some important parts are detailed (recurrence relation, induction, combinatorics, graph theory) which serves as powerful tools to do good job in computer science.  \n\\paragraph{What do They Ask?}\nWe may be asked to answer four types of questions:\n\\begin{enumerate}\n    \\item \\textbf{YES/No Decision Problems:} answering whether a number is prime, odd or even are examples of such decision problems. \n    \\item \\textbf{Search problems:} Find one/all \\textit{feasible solutions} that meets problem requirement, which requires the identification of a solution from within a potentially infinite set of possible solutions. For example, finding the $n^{th}$ prime number. Almost all problems are or can be converted to a search problem in some way. Further, search problems can be divided into:\n    \\begin{itemize}\n    \\item \\textbf{Counting Problems:} Count all feasible solutions to a search problem, such as answering, `how many of the 100 integers are prime?'.\n    \\item \\textbf{Optimization Problems:} Find the \\textit{best solution} among all feasible solutions to a search problem.  In addition to the search problem, optimization problems answers the decision, `is the solution the best among all feasible ones?'. \n    \\end{itemize}\n\\end{enumerate}\n\n\\paragraph{Combinatorics}\nWhen discrete problems are asked with counting or optimization questions, in computer science we further have combinatorial problems, which is also widely called \\textit{combinatorics}.  \n\nCombinatorics originates from discrete mathematics and become part of computer science. As the name suggested, combinatorics is about combining things; it answers questions: \"How many ways can these items be combined?\", and \"Whether a certain combination is possible, or what combination is the `best' in some sense?\" \n\nThrough this book, permutations, combinations, subsets, strings, points in the linear order, and trees, graphs, polygons in the non-linear ordering will be examined (suggest contents in the book). We will have some briefy study on this topic in Chapter~\\ref{part_combinatorial_problems}.\n% \\begin{enumerate}\n%     \\item Combinatorial problems: such as permutations, subsets, strings, trees, graphs, points, polygons. \n%     \\item Combinatorial optimization problems, aka \\textit{discrete optimization}: combinatorial optimization problems are a subset of the combinatorial problems. \\textcolor{red}{This subject originally grew out of graph theoretic concerns like edge colorings in undirected graphs and matchings in bipartite graphs. Much of the initial progress is due entirely to theorems in graph theory and their duals. With the advent of linear programming, these methods were applied to problems including assignment, maximal flow, and transportation. In the modern era, combinatorial optimization is useful for the study of algorithms, with special relevance to artificial intelligence, machine learning, and operations research.}\n% \\end{enumerate} \n\\paragraph{Tractable or Intractable?}\nThe complexity of a problem is normally described in relation with the size of the input instance. If a problem is algorithmic and computable, being able to produce a solution may depend on the size of the input or the limitations of the hardware used to implement it. Based on if  a problem can be possibly solved by existing machines we have:\n\\begin{enumerate}\n    \\item \\textbf{Tractable problems:} If a problem has reasonable solution, that it can be solved in no more than polynomial time complexity, it is said to be tractable. \n    \\item \\textbf{Intractable problems:} Some problems can only be solved with algorithms whose execution time grows too quickly in relation to their input size, say exponential, then these problems are considered to be intractable. For example, the classical Traveling Salesperson Problem. \n\\end{enumerate}\n\nProblems can also be categorized as:\n\\begin{enumerate}\n    \\item \\textbf{P Problems:} \n    \\item \\textbf{NP Problems:}\n\\end{enumerate}\nThere are more types, such as \\textit{undecidable problems} and \\textit{the halting problems}, feel free to look them up if interested. \n\\subsection{Understand Solution Space}\n\\label{sec_data_structures}\nA data structure is a specialized format of organizing, storing, processing, and  retrieving data. As Dr. Wirth states in the chapter quote, we problem modeling with data structures and the data structures often influence the details of an algorithm: the input/output instances, and the intermediate results in the process of an algorithms all associates to data structures.\n\nIn this section, we do not intend to get into details of data structures, but rather pointing out directions. Quickly skim the first section of Part.~\\ref{} and get a sense of the categories of data structures. When a problem is modeled with data structures, the problems can further be classified based on its data structures. At this stage, we should try to model our input on a data structure, and analyze the following five components to even better understand our problem.  \n\n\n\\paragraph{Five Components} There are generally five components of a problem that we can define and depends on to correlate the problem to data structures, and to algorithms--searching, divide and conquer, dynamic programming, and greedy algorithms. We introduce the five components with a dummy example:\n\\begin{lstlisting}[numbers=none]\nGiven a list of items A=[1, 2, 3, 4, 5, 6], find the position of item with value 4. \n\\end{lstlisting}\n\\begin{figure}[!ht]\n    \\centering\n     \\includegraphics[width=0.7\\columnwidth]{fig/problem_formulation_2.png}\n    \\caption{The State Space Graph. This may appears as a tree, but we can redraw it as a graph. }\n    \\label{fig:problem_formulation}\n\\end{figure}\n \n\\begin{enumerate}\n    \\item \\textbf{Initial State:} state that where our algorithm starts. In our example, we can scan the whole list starting from leftmost position 0, we denote it as $S(0)$. Note that a state does not equal to a point on the input instance, it can be a range --such as from position 0 to 5, or from 0 to 2, or any state you define. \n    \\item \\textbf{Actions or MOVES:} describe possible actions relating to a state. Now, given position 1 with 2 as value, we can move only one step forward and get to position 2 or we can move 2, 3, 4, 5 steps and so. Thus, we should find all possible actions or moves that we can take to progress to next state. We can denote it as ACTIONS(1)={MOVE(1), MOVE(2), MOVE(3), MOVE(4), MOVE(5)}. \n    \n    \\item \\textbf{State transfer Model}: decides the state results from doing an action $a$ at state $s$. We denote it as $T(a, s)$. For example, if we are at position 1 and move one step, MOVE(1), then we can reach to state 2, which can be denote as $2=T(MOVE(1), 1)$. %We also use the term \\textit{successor} to refer to any state reachable from a given state by a single action. \n    \n   \\item \\textbf{State Space:} is the set of all states reachable from the initial state by any sequence of actions, in our case, it can be {0, 1, 2, 3, 4, 5}. We can infer state space of the problem from the initial state, actions, and transfer model. The state space forms a directed network or \\textit{graph} in which the nodes are states and the links between nodes are actions. Graph, with all its flexibity, is a universal and natural way to represent relations. For example, if we limit the maximum moves we can make at each state to two, the state space will be formed as follows in Fig.~\\ref{fig:problem_formulation}. In practice, draw the graph as a tree structure is another option; in the tree, we observe repeat states due to the expansion of nodes in graph with multiple ingoing links.  A \\textit{path} in the state space is a sequence of states connected by a sequence of actions. \n    \n    \n   \\item  \\textbf{Goal Test:} the determines whether a given state is a goal state. %Sometimes there is an explicit set of possible goal states, and the test simply checks whether the given state is one of them. \n   Such as in this example, the goal state is $4$. The goal is not limited to such enumerated sets of states, it can also be specified by an abstract property. For example, in the constraint state problems(CSP) such as the n-queen, the goal is to reach to a state that not a single pair of queens will attack each other. \n\\end{enumerate}\n\nIn this example, the space graph is an analysis tool; we use it to represent the transition relationship between different states not the exact data structure that we use to operate and define algorithms on. \n\n\\paragraph{Apply Data Structures}\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.9\\columnwidth]{fig/problem_formulation_1.png}\n    \\caption{State Transfer process on a linear structure }\n    \\label{fig:problem_formulation_1}\n\\end{figure}\n\nWith the state space graph, our problem is abstracted to finding a node with value 4 and graph algorithms--more specifically, graph search--can be applied to solve the problem. It does not take an expert to tell us, \"This graph just complicated the situation, because our intuition can lead us to a much simpler and straightforward solution: scan the items from the leftmost to the rightmost one by one\". True! As is depicted in Fig.~\\ref{fig:problem_formulation_1}, the problem can be modeled using a linear structure, possiblly a list or linked list, and we only need to consider one action out of all options, MOVE(1), then our searching covers the whole state space, which makes the algorithm we designed \\textit{complete}~\\footnote{Check complexity analysis}. On the other side, in the state space graph, if we insist on moving two steps each time, we would not be able to cover the whole state space, and might end up not finding our target, which indicates this algorithm is \\textit{incomplete}.\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{fig/problem_formulation_3.png}\n    % \\includegraphics[width=0.7\\columnwidth]{fig/problem_formulation_4.png}\n    \\caption{State Transfer Process on the tree}\n    \\label{fig:problem_formulation_2}\n\\end{figure}\n\n\n\nInstead of using linear data structure, we can restructure the states as a tree if we refine the state as a range of items. The initial state  is the possible subarray the target can be found, denote as $S(0, 5)$. Start from initial state, each time, we divide the space into two halves: $S(s, m)$ and $S(m, e)$, where $s, e$ is the start and end index respectively, and $m=(s+e)//2$, meaning the integer part of $s+e$ divided by 2. We do this to all nodes repeatedly, and we will have another state transfer graph shown in Fig.~\\ref{fig:problem_formulation_2}.From this graph we can see, the last node will be where we can not divide further, that is when $s=e$. From state $0-5$ to $3-5$ needs an action--move to the right. Similarly, from $0-5$ to $0-3$ needs the action of moving to the left.  We use {MOVE(L), MOVE(R)} to denote the whole set of possible actions to take.\n\nIn this example, we showed how to same simple problem can be modeled using two different data structures--linked list and tree. \n\n\n\n\n%we introduce the definition and the type of data structures; and demonstrate how it can be used to model our problems.   of data structures as a way to demonstrate our organization of part.~\\ref{part_data_structure} and a premise knowledge for the next section where we examine and discuss the problem modeling with real examples.\n\n% \\subsubsection{Data Structures Definition}\n\n% \\subsubsection{Data Structures Categorizes} Put figures here for visualization and comparison. \n% \\begin{enumerate}\n%     \\item Linear Data Structure: such as arrays, strings, heaps, priority queue.\n%     \\item Non-linear Data structure: such as tree, graph\n%     \\item Sturcutual: points, polygons. \n% \\end{enumerate}\n\n% Throughout this book, we will see that all problems are associated with fundamental data structures such as array, strings, trees, graphs, points, polygons. With different data structure, specific algorithms will be applied to solve these two problems. Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. \\textit{In practice, data structures are utilized to model a problem so that it can be solved with a corresponding algorithm. }\n\n% \\textit{Data strutures and algorithms are inseparable in computer programming. }\n\n% In order to do comparison between all possible devised algorithms for our problem, we need to learn how to  evaluate their performance with time complexity and space complexity. There are some techniques we will introduce before we dive into the four problem solving paradigm and Cracking LeetCode Problems (Part~\\ref{part_cracking_leetcode_problem}), we will learn how to do complexity analysis of algorithms in Section~\\ref{sec_complexity_analysis}. \n\n\n\n\n% The above example is to show us, how learning and practice using the data structures and four problem solving paradigms can help us making smarter decision about problem modeling and problem solving. \n\n\\section{Problem Solving}\n\\label{sec_problem_solving}\nIn this section, we will first demonstrate how algorithm can be applied on these two data structures with its corresponding state transfer process. Following this, we introduce the four fundamental algorithm design and analysis methodologies--the ``soul/brain''.\n We end this section by briefing on categorizing algorithms. \n \n \\subsection{Apply Design Principle} \n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.9\\columnwidth]{fig/problem_formulation_1_1.png}\n    \\caption{Linear Search on explicit linear data structure }\n    \\label{fig:problem_formulation_3}\n\\end{figure}\nGiven the state transfer graph in Fig.~\\ref{fig:problem_formulation_1}, we simply iterate each state and compare each item with our target to see if it equals; if true, we find our target and return, if not, we continue to the end. This simple search method is depicted in Fig.~\\ref{fig:problem_formulation_3}.\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{fig/problem_formulation_4.png}\n    \\caption{Binary Search on an implicit Tree Structure}\n    \\label{fig:problem_formulation_4}\n\\end{figure}\nWhat if we know that the data is already organized in ascending order? With the tree data structure, when given a specific target, we only need to choose one action from the actions set; either move to left or right to search with a condition: if target is larger or smaller than the item in the middle of the state. When 4 is target, we have the search process depicted in  Fig.~\\ref{fig:problem_formulation_4}. \n\nAll these state space, data structure, algorithm, and analysis might appear overwhelming to you for now. But as you learn, some of these steps are not necessary, but knowing these elements are good for you to analyze and learn new algorithms, think of it more gathering terminologies into your language base. \n\n\\subsection{Algorithm Design and Analysis Principles}\n\\subsubsection{Algorithm Design}\n\\label{sec_algorithm_design}\nMore of the time, the most naive and inefficient solution -- \\textit{brute-force solution} would strike us right away, which is simply searching a feasible solution  to the problem in its solution space using the massive computation power of the hardware. Although the naive solution is not preferred by your boss nor it will be incorporated into the real product, it offers the baseline for your complexity comparison and to showcase how good your well-designed algorithm is.\n\nIn the dummy example, we actually used two different searching algorithms--linear search and binary search. The process of looking for a sequence of actions that reaches the goal is called search. Therefore, \\textit{searching} is the fundamental strategy and and the very first step to problem-solving. How could it not be? Algorithms are about to find answers to problems, if and assuming we can define out potential state/solution space, then a naive/exhuastive searching would do the magic and solve the problem. However, back to reality, we are limited by computation resource and speed, we comprise by:\n\\begin{enumerate}\n    \\item being smarter that we can be decrease the cost, increase the speed, and yet still gives out the exact solution we are looking for. This comes down to \\textit{optimization}, which we have \\textit{divide and conquer}(Chapter~\\ref{}), \\textit{dynamic programming}(Chapter~\\ref{}), and \\textit{greedy algorithms}(Chapter~\\ref{}). What are the commonality between them? They all in some way need us to get \\textit{recurrence relation}((Chapter~\\ref{}), which is essentially \\textit{mathematical induction}(Chapter~\\ref{}), which I generalized from another book, \\textit{Introduction to Algorithms: A Creative Approach}, by Udi Manber. Explain it in another way, these principles are using recurrence relation to find the relation of a problem with its smaller instance. Why is it smarter? First, smaller problems are just easier to solve than larger problems. Second, the cost of assembling the answer to smaller problems to answers to the larger problems is possibly smaller.\n    \\item by approximating the answer. Instead of trying to get the exact answer, we find one that is good enough. Here goes to all heuristic search, machine learning, artificial intelligence. Guess, currently my limited knowledge is not enough for me to give more context that this.\n\\end{enumerate}\nEqually, we can say all algorithms can be described and categorized as searching algorithms. Yet, there are three algorithm design paradigms-- \\textit{Divide and Conquer}, \\textit{Dynamic Programming}, and \\textit{greedy Algorithms}, can be applied in the searching process for faster speed or using less space. \nDon't worry, this is just the introduction chapter, all these concepts and algorithm design principles will be explained later.\n\n% \\subsubsection{Algorithm Design Methodologies}\n% In this section we will briefly offer a glimpse into their concepts and discerns. \n% \\begin{figure}[h]\n%     \\centering\n%     \\includegraphics[width=0.6\\columnwidth]{fig/divide_dynamic.png}\n%     \\caption{The dividing of problems of Divide and Conquer VS Dynamic programming. (Note: the left side in the red box is the Divide and Conquer, and the blue box is the dynamic programming.) }\n%     \\label{fig:divide_conquer_vs_dynamic_programming}\n% \\end{figure}\n\n% \\paragraph{Divide and Conquer} is the most fundamental programming philosopy.  It first recursively break a problem into smaller non-overlapping subproblems till a small base subproblem which can be solved easilty, and then combining the results of the subproblems into the solution to its superme problem in some way. The process is demonstrated in Fig~\\ref{fig:divide_conquer_vs_dynamic_programming}, and it usually be implemented with recursive function. It usually decrease the time complexity of logarithm level. For instance, it optimize a $O(n^2)$ time complexity to $O(n\\log n)$.\n\n\n% \\paragraph{Dynamic programming} follows the same philosophy of Divide and Conquer and commonly used to tackle optimization problems. It also first break a problem into subproblems. But instead of the non-overlapping subproblems, their subproblems overlaps in a way as demonstrated in Fig~\\ref{fig:divide_conquer_vs_dynamic_programming}, which means a larger size subproblem grows from smaller previous subproblems. The solution to current subproblem can depends on any number of previous smaller subproblems.  With dynamic programming, intermediate results are cached and can be used in subsequent operations. \n% %Second, we use the knowledge we learned from normal algorithm books with algorithm methodology like divide and conquer, dynamic programming, greedy algorithms and so on. This normally be more efficient, if we are pick the right method. There methods will be introduced in details in Part~\\ref{part_algorithms}. \n\n% \\paragraph{Greedy algorithms} often involve optimization and combinatorial problems; the classic example is applying it to the traveling salesperson problem, where a greedy approach always chooses the closest destination first. This shortest path strategy involves finding the best solution to a local problem in the hope that this will lead to a global solution.\n\n% \\textcolor{red}{\\paragraph{Complete Search} Complete search, also known as brute force or recursive backtracking, is a method for approaching a problem by naively searching through the whole solution spaces to obtain the required solution. Optimization is through pruning the searching space by ending invalid searching early. Complete search is used when there is clearly no clever algorithms available ( algorithms that use one of previous three paradigms), for instance with permutation and combination stated in Section~\\ref{sec_combination}, or when such clever algorithms exist, but overkill when the input size happen to be small for complete search. }\n\n% On the LeetCode, a lot of times, complete search should be the first considered soltion that come to mind. With bug-free complete search solution, we should never receive Wrong Answer response, but we might get Time Limited Error (TLE) instead due to its high time complexity. \n\n\\subsubsection{Algorithm Analysis of Performance}\nHow to measure problem-solving performance? Up till now, we have some basic ways to solve the problem, we need to consider the criteria that might be used to measure them. We can evaluate an algorithm's performance in four ways:\n\\begin{enumerate}\n    \\item \\textbf{Completeness:} Is the algorithm guaranteed to find a solution when there is one?\n    \\item \\textbf{Optimality:} Does the stategy find the optimal solution, as defined?\n    \\item \\textbf{Time Complexity:} How long does it take to find a solution?\n    \\item \\textbf{Space Complexity:} How much memory is needed to perform the search?\n\\end{enumerate}\n\nTime and space complexity are always considered with respect to some measure of the problem difficulty. In theoretical computer science, the typical measure is the size of the state space graph, |V | + |E|, where V is the set of vertices (nodes) of the graph and E is the set of edges (links). This is appropriate when the graph is an explicit data structure that is input to the search program. However, in reality, it is better to describe the search tree that applied to search for our solutions. For this reason, complexity can be expressed in terms of three quantities: $b$, the \\textbf{branching factor} or a maximum number of successors of any node; $d$, the \\textbf{depth} if the shallowest goal node ; and $m$, the maximum length of any path in the state space. Time is often measured in terms of the number of nodes in the search tree, and the space are in terms of the maximum number of nodes stored in memory. \n\nFor the most part we describe time and space complexity for search on a tree; for a graph, the answer depends on how ``redundant\" paths  or ``loops\" in the state space are.\n\n\n\\subsection{Algorithm Categorization}\nThere are countless algorithms invented, however, these traditional data-independent algorithms (not the current data-oriented deep learning models which are trained with data), it is important for us to be able to categorize the algorithms and understand the similarities and characteristics of each type and also be able to compare each type: \n\\begin{itemize}\n    \\item By implementation: the most useful in our book is recursive and iterative. Understand the difference of these two, and the special usage of recursion (Chapter~\\ref{chapter_iteration_recursion}) is fundamental to the further study of algorithm design.  We can also have serial and parallel/distributed, deterministic and non-deterministic algorithms. In our book, all the algorithms we learn are  serial and deterministic algorithms. \n    \\item By design: algorithms can be interpreted to one or several of the four fundamental problem solving paradigms, Divide and Conquer (Part~\\ref{part_divide_conquer}), Dynamic Programming and Greedy (Part~\\ref{part_dp_greedy}).  In Section~\\ref{four_paradigm}, we will briefly introduce and compare these four problem solving paradigms to gain a global picture of the spirit of algorithms. \n    \\item By complexity: mostly algorithms can be categorized by its time complexity. Given an input size of $n$, we normally have categories of $O(1)$, $O(\\log n)$, $O(n\\log n)$, $O(n^2)$, $O(n^3)$, $O(2^n)$, and $O(n!)$. More details and the comparison is given in Section~\\ref{complexity_subsec_cheat_sheet}.\n\\end{itemize}\n% \\subsubsection{Searching Algorithms}\n% After the problem formulation, we will have a sense of state spaces, and to reach to the goal state, we need to search a path to reach to this state or a sequence of actions. Searching algorithms will be the most fundamental footstone of all algorithms. Essentially our state spaces are graphs. Under certain limitations, we can simplify it to linear data structure or tree structures.  \n\n% \\paragraph{How searching works?} We start from the initial state and form a \\textit{search tree} with the initial state as root; the branches are actions and the nodes corresponds to states in the state space of the problem. We search by \\textit{expanding} current state; that is, applying each legal action to the current state, thereby reaching to a new set of states. The nodes available for expansion at any given point is called the \\textbf{frontiers} (also called open list). There are fundamentally three types searching techniques:\n% \\begin{enumerate}\n%     \\item Breath-first Search: for example, if we are at 1, then our next sets of states are {2, 3}. Then we expand the states of 2, then states of 3, and save them to a data structures to expand later, they will be {3, 4, 4, 5}. So first, the frontier is {1}, then it becomes {2, 3}, then at node 2, we expand 3, 4, will end up with {3, 3, 4}. This is called breath-first search which expand the frontier in a First-in, first out or FIFO fashion (FIFO queue). Breath-first search is usually implemented iteratively. \n    \n%     \\item Depth-first Search: similarily at state 1, we get our frontiers to be {2, 3}. But if we deal with the nodes in the frontier in a last-in, first out or LIFO fashion (LIFO queue and also known as stack). At node 1, our generated frontier will be [2, 3], then we go to state 3, and expand more states here, the resulting frontier will be [2, 4, 5]. Then move to state 5, with resulting frontier [2, 4, 6]. Depth-first search can either be implemented iteratively or recursively. \n    \n%     \\item Priority based Search: if we pop the elements of the queue with the highest priority according to some ordering function, this is called proprity based search, this can be implemented with a priority queue. \n% \\end{enumerate}\n\n\n\nThe intractable problems are still get solved by computer. We can limit our input instance size. However, it is not very practical, when the size of the input size is large and we are still hoping to get solutions, maybe not the best, but are good enough in a a reasonable(polynomial) time.   \\textit{Approximate algorithms} comes into our hand,  such as \\textit{heuristic algorithm}. In this book, we focus more on the non-approximate algorithmic methods to solve problems in \\textit{discrete} solution spaces, and only brief on the part of approximate algorithms. \n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Programming Languages}\n\\label{sec_programming_languages}\n \n\n\n\nhird, for certain type of problems, there are algorithms specically designed and tuned to optimize that type of question. This wil be introduced in Part~\\ref{part_specific_algorithms}. Which might give us almost the best efficiency we can find.\n\n% The fourth level, is the ''clever'' way. For some problems, if you are creative enough, and you comprehensively analyze the problem and think about each case, we might come up with a very brilliant solution that beats all the previous solutions in both efficiency and code elegancy. This will not be systematically introduced in this book, because it varies problem to problem. But we will put some ``clever'' solutions to some problems either in examples or exercises used in this book. \n% \\subsection{Complete Search}\n\n% \\subsection{Divide and Conquer}\n% \\subsection{Dynamic Programming}\n% \\subsection{Greedy Algorithm}\n\n\\section{Tips for Algorithm Design}\n\\paragraph{Principle} \n\\begin{enumerate}\n    \\item Understand the problem, analyze with searching and combinatorics to get the complexity of the naive solution.\n    \\item If it is a exponential problem, check if the dynamic programming applies. If not, we have to stick to a search algorithm. If it applies, we can decrease the complexity to polynomial. \n    \\item If it is polynomial already or polynomial after the dynamic programming applied, check if the greedy approach or the divide and conquer can be applied to further decrease the polynomial complexity. For example, if it is $O(n^2)$, divide and conquer might decrease it to $O(n\\log n)$, and the greedy approach might end up with $O(n)$. \n    \\item If none of these design principle applies: we stick to the searching and try to optimize with better searching techniques--such as backtracking, bidirectional search, $A^{*}$, sliding window and so on. \n\\end{enumerate}\nThis process can be generalized with ``BUD''--bottleneck, unncessary work, and D. \n\n\n\n\\section{Exercise}\n\\subsection{Knowledge Check}\n\\paragraph{Longest Increasing Subsequence} \n\n\n\\begin{bclogo}[couleur = blue!30, arrondi=0.1,logo=\\bccrayon,ombre=true]{Practice first before you check up the solution. (put the solution at next page)}\n\\end{bclogo}\n\\begin{figure}[!ht]\n    \\centering\n    \\includegraphics[width=0.9\\columnwidth]{fig/problem_formulation_1.png}\n    \n     \\includegraphics[width=0.7\\columnwidth]{fig/problem_formulation_2.png}\n    \\caption{The State Spaces Graph }\n    \\label{fig:problem_formulation}\n\\end{figure}\n Given a list of items $A=[1, 2, 3, 4, 5, 6]$, find the position of item with value $4$. \n\\begin{enumerate}\n    \\item \\textbf{Initial State:} state that where our algorithm starts. In our example, we can scan the whole list starting from leftmost position 1. $S(0)$\n    \\item \\textbf{Actions or MOVES:} A description of possible actions available at a state. If we are at position 1, we can have different possible actions, we can move only one step forward and get to position 2. Or we can move 2, 3, 4, 5 steps. We can denote it as ACTIONS(1)={MOVE(1), MOVE(2), MOVE(3), MOVE(4), MOVE(5)}. \n    \n    \\item \\textbf{State transfer or transition model}: It returns the state results from doing an action $a$ at state $s$. We denote it as T(a, s). For example, if we are at position 1 and take action that move one step, MOVE(1), then we can reach to state 2, denote as $2=T(MOVE(1), 1)$. We also use the term \\textbf{successor} to refer to any state reachable from a given state by a single action. \n    \n  \\item \\textbf{State Space:} Together, the initial state,  actions, and transition model implicitly define the state space of the problem--the set of all states reachable from the initial state by any sequence of actions. The state space forms a directed network or \\textbf{graph} in which the nodes are states and the links between nodes are actions. For example, if we limit the maximum moves we can make at each state to be one and two, the state space will be formed as follows in Fig.~\\ref{fig:problem_formulation}. A \\textbf{path} in the state space is a sequence of states connected by a sequence of actions. \n    \n    \n  \\item  \\textbf{Goal Test:} the goal test determines whether a given state is a goal state. Sometimes there is an explicit set of possible goal states, and the test simply checks whether the given state is one of them. Such as in this example, the goal state is $4$. Sometimes the goal is specified by an abstract property rather than explicitly enumerated sets of states. For example, in the constraint state problems(CSP) such as the n-queen, the goal is to reach to a state that not a single pair of queens will attack each other. \n\\end{enumerate}\n\n\nIn practice, analyzing and solving a problem is not answering a yes or no question. There are always mutiple angels to model a problem, the way to model and formalize a problem decides the corresponding algorithm that can be used to solve this problem. And it might also decide the efficiency and difficulty to solve the problem. For example, using the Longest Increasing Subsequence:\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{fig/LIS_tree.png}\n    \\caption{State Transfer Tree Structure for LIS, each path represents a possible solution. Each arrow represents an move: find an element in the following elements that's larger than the current node.}\n    \\label{fig:tree_lis}\n\\end{figure}\n\\textbf{Ways to model the problem.} There are different ways to model this LIS problem, including:\n\\begin{enumerate}\n    \\item Model the problem as a directed graph, where each node is the elements of the array, and an edge $\\mu$ to $v$ means node $v>\\mu$. The problem now becomes finding the longest path from any node to any node in this directed graph.  \n    \\item Model the problem as a tree. The tree starts from empty root node, at each level i, the tree has n-i possible children: nums[i+1], nums[i+2], ..., nums[n-1]. There will only be an edge if the child's value is larger than its parent. Or we can model the tree as a multi-choice tree: for combination problem, each element can either be chosen or not chosen. We would end up with two branch, and the nodes would become a path of the LIS, therefore, the longest LIS exist at the leaf nodes which has the longest length.\n    \\item Model it with divide and conquer and optimal substructure. \n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "6939822c02429de9f7563012beebac8124265f17", "size": 52861, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Easy-Book/chapters/chapter_2_introduction_algo.tex", "max_stars_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_stars_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Easy-Book/chapters/chapter_2_introduction_algo.tex", "max_issues_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_issues_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Easy-Book/chapters/chapter_2_introduction_algo.tex", "max_forks_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_forks_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 130.8440594059, "max_line_length": 1234, "alphanum_fraction": 0.7802349558, "num_tokens": 11696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4219465250140405}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsection{Matter effects in neutrino oscillations}\n\n\\marginpar{Wednesday\\\\ 2021-12-15}\n\nThis is also called the MSW effect. \nNeutrinos interact weakly with matter, meaning that they are rarely absorbed;\nhowever, neutrinos may feel the presence of matter even without changing direction. \n\nThrough some interaction, a propagating neutrino may feel the presence of background fermions (matter).\nThis idea is called ``coherent forward scattering''. \n\nThe full Hamiltonian will include a neutrino ``interaction energy potential''\n%\n\\begin{align}\nH = \\frac{1}{2E} U M^2 U ^\\dag + \\left[\\begin{array}{ccc}\nV_{ee} & V_{e \\mu } & V_{e \\tau } \\\\ \nV_{\\mu e} & V_{\\mu \\mu } & V_{\\mu \\tau } \\\\ \nV_{\\tau e} & V_{\\tau \\mu } & V_{\\tau \\tau }\n\\end{array}\\right]\n+ \\text{terms proportional to } \\mathbb{1}_3\n\\,.\n\\end{align}\n\nPictorially, this matrix \\(V\\) has a diagonal term driven by neutral current interactions,\nwith any neutrino interacting through a \\(Z\\) boson. \nThe coupling of the \\(Z\\) does not depend on the flavor, so that component is \nproportional to \\(\\mathbb{1}\\), meaning it does not affect oscillations. \n\nA second term is the one corresponding to the \\(W\\) boson: for this, we only have\nan effect for electron neutrinos, in the \\(V_{ee}\\) component. \n\nAt tree level, this is proportional to the Fermi constant \\(G_F\\). \nAlso, it will linearly depend on the electron number density. \n\nThe calculation yields \n%\n\\begin{align}\nV_{ee} &= \\sqrt{2} G_F N_e \n\\qquad \\text{for neutrinos}  \\\\\nV_{ee} &= -\\sqrt{2} G_F N_e \n\\qquad \\text{for antineutrinos}  \n\\,.\n\\end{align}\n\nThis effect is quite analogous to the propagation of light within a medium with a \nnon-1 index of refraction. \nIt alters the oscillation pattern both in amplitude and in frequency.\n\nThe main oscillation channel for atmospheric neutrinos is \\(\\nu _\\mu \\to \\nu _\\tau \\), \nmeaning that these matter effect did not need to be included to study it. \n\nIt is convenient to introduce a term \\(A = 2 E V_{ee} = 2 \\sqrt{2} G_F N_e E\\); then the Hamiltonian reads \n%\n\\begin{align}\nH = \\frac{1}{2E} \\left( U M^2 U ^\\dag + \\left[\\begin{array}{ccc}\nA & 0 & 0 \\\\ \n0 & 0 & 0 \\\\ \n0 & 0 & 0\n\\end{array}\\right] \\right)\n\\,.\n\\end{align}\n%\n\nQualitatively, we can understand that this term will be important when \\(A\\) \nis \\(\\gtrsim \\delta m^2\\) or \\(\\Delta m^2\\). \n\nIt turns out that \n%\n\\begin{align}\n\\frac{A}{\\Delta m^2_{ij}} \\approx \\num{1.526e-7} \\left( \\frac{N_e}{\\SI{}{mol/cm^3}}\\right) \n\\left( \\frac{E}{\\SI{}{MeV}}\\right)\n\\left( \\frac{\\SI{}{eV^2}}{\\Delta m^2_{ij}} \\right)\n\\,.\n\\end{align}\n\nFor the Sun, in the core, \\(N_e \\sim \\SI{e2}{mol/cm^3}\\), so we get that as an order of magnitude \\(A \\sim \\delta m^2\\). \n\nSince the number density of neutrinos depends on position, we need to integrate the Schrödinger equation numerically. \n\nIntegrating these oscillatory functions, however, can be tricky! \nErrors accumulate. \n\nFor the crust of the Earth, say, the LHC to LNGS beam, approximating the density as constant can work quite well. \n\nLet us consider a two-neutrino case: \n%\n\\begin{align}\nH = \\frac{1}{2E} U \\left[\\begin{array}{cc}\nm_1^2 & 0 \\\\ \n0 & m_2 ^2\n\\end{array}\\right]\nU ^\\dag\n+ \\frac{1}{2E}\n\\left[\\begin{array}{cc}\nA & 0 \\\\ \n0 & 0\n\\end{array}\\right]\n= \\frac{1}{2E} \\widetilde{U} \\widetilde{M}^2 \\widetilde{U} ^\\dag\n\\,,\n\\end{align}\n%\nso we find a corrected diagonal matrix \\(\\widetilde{M}^2\\) as well as corrected mixing angles! \nThey read:\n%\n\\begin{align}\n\\sin 2 \\widetilde{\\theta}_{12} &= \\frac{\\sin 2 \\theta_{12} }{\\sqrt{(\\cos 2 \\theta_{12} - A / \\delta m^2)^2 + \\sin^2 2 \\theta_{12} }}  \\\\\n\\widetilde{\\delta m}^2 &= \\delta m^2 \\frac{\\sin 2 \\theta_{12} }{\\sin 2 \\widetilde{\\theta}_{12}}\n\\,,\n\\end{align}\n%\nwhich looks like a Breit-Wigner resonance.\n\nThe corrected \\(\\sin 2 \\widetilde{\\theta}_{12}\\) has a maximum when \\(\\cos 2 \\theta_{12} = A / \\delta m^2 \\), at which point we also have a minimum for \\(\\widetilde{\\delta m}^2\\). \n\nThis resonance does not happen for antineutrinos, which have a different sign for \\(A\\). \n\nFor the Sun, we make two approximations: the density is slowly changing, \\(\\dv*{N_e}{x} \\) is nonzero but small, and there are many oscillations. \n\nThe transition is ``adiabatic'', so everything will only depend on the initial and final mixing angles, not on \\(\\delta m^2\\). \n\nThe result is \n%\n\\begin{align}\nP_{ee}^{2 \\nu } ( \\text{solar}) \\approx \\cos^2 \\widetilde{\\theta}_i \\cos^2 \\theta + \\sin^2 \\widetilde{\\theta}_i \\sin^2 \\theta \n\\,.\n\\end{align}\n\nThis probability has been tested! \nIt looks a bit like a decreasing ``sigmoid'', with a transition at few \\SI{}{MeV}. \n\nThis oscillation probability is no longer octant symmetric! \nIt solves the degeneracy of the mixing angles in the KamLand experiment. \n\nUncertainties in the solar model do not really create problems in this regard; our models work well enough. \n\n\\end{document}", "meta": {"hexsha": "fc53c2ed5d23d6a80051a138481a0179e4881fac", "size": 4870, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd_courses/theoretical_low_energy_astroparticle/dec15.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "phd_courses/theoretical_low_energy_astroparticle/dec15.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd_courses/theoretical_low_energy_astroparticle/dec15.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 35.035971223, "max_line_length": 180, "alphanum_fraction": 0.6928131417, "num_tokens": 1573, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.42194652496931573}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% This work is licensed under the Creative Commons Attribution 4.0 International %\n% License. To view a copy of this license, visit                                 %\n% http://creativecommons.org/licenses/by/4.0/.                                   %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[11pt]{article}\n\\usepackage[cm]{fullpage}\n%%AVC PACKAGES\n\\usepackage{avcgreek}\n\\usepackage{avcfonts}\n\\usepackage{avcmath}\n\\usepackage[numberby=section]{avcthm}\n\\usepackage{qcmacros}\n\\usepackage{goldstone}\n%%MACROS FOR THIS DOCUMENT\n\\numberwithin{equation}{section}\n\\usepackage[\n  margin=1.5cm,\n  includefoot,\n  footskip=30pt,\n  headsep=0.2cm,headheight=1.3cm\n]{geometry}\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\fancyhead[LE,RO]{Quiz 1, Handout 2: Second Quantization}\n\\fancyfoot[CE,CO]{\\thepage}\n\\usepackage{url}\n\n\\begin{document}\n\n\\setlength{\\abovedisplayskip}{3pt}\n\\setlength{\\belowdisplayskip}{3pt}\n\n\\section{Second Quantization}\n\n\n\\begin{dfn}\\label{dfn:slater-determinant}\n\\thmtitle{Slater determinant}\nA \\textit{Slater determinant} is a normalized antisymmetric product of spin-orbitals\n\\begin{align}\\label{eq:slater-determinant-position-representation}\n  \\F_{(p_1\\cd p_n)}(1,\\ld,n)\n=\n  \\tfr{1}{\\sqrt{n!}}\n  \\sum_{\\pi}^{\\mr{S}_n}\n  \\e_{\\pi}\n  \\y_{p_{\\pi(1)}}(1)\\cd\\y_{p_{\\pi(n)}}(n)\n\\end{align}\nwhere $\\pi\\in\\mr{S}_n$ is a permutation of $(1,\\cd, n)$ with signature $\\e_{\\pi}$.\\footnote{The signature of a permutation is $(-)^{\\text{\\# transpositions}}$.  See \\url{https://en.wikipedia.org/wiki/Symmetric_group} for more on $\\mr{S}_n$.}\n\\end{dfn}\n\n\\subsection{Deriving the second-quantized Hamiltonian from first quantization}\\label{ssec:direct-derivation-of-second-quantization}\n\n\nLet $\\mc{F}_n$ denote the span of $n$-electron determinants and consider the integral operator $\\op{a}_p:\\mc{F}_n\\rightarrow \\mc{F}_{n-1}$ given by\n\\begin{align}\n  (\\op{a}_p\\Y)(2,\\cd,n)\n\\equiv\n  \\sqrt{n}\\int d(1) \\y_p^*(1)\\Y(1,2,\\cd,n)\\,.\n\\end{align}\nThis operator acts on Slater determinants as follows.\n\\begin{align}\n  (\\op{a}_p\\F_{(p_1\\cd p_n)})(2,\\cd,n)\n=\n\\left\\{\n\\ar{\n  (-)^{k-1}\\F_{(p_1\\cd \\cancel{p_k}\\cd p_n)}(2,\\ld,n) & p=p_k\\in(p_1\\cd p_n)\\\\[5pt]\n  0 & \\text{otherwise}\n}\n\\right.\n\\end{align}\nIn words, it deletes $\\y_p$ from $\\F_{(p_1\\cd p_n)}$ if present, otherwise killing the determinant.\nThe restriction to an antisymmetric space makes these operators anticommute, $\\op{a}_p\\op{a}_q=-\\op{a}_q\\op{a}_p$, since it can be shown that for $\\Y\\in\\mc{F}_n$\n\\begin{align*}\n  \\int d(1)d(2)\\y_p^*(1)\\y_q^*(2)\\Y(1,2,\\cd,n)\n=&\\\n-\n  \\int d(1)d(2)\\y_q^*(1)\\y_p^*(2)\\Y(1,2,\\cd,n)\n\\end{align*}\nby swapping integration variables.\nThese operators can be used to generate the following decompositions.\\footnote{These follow from substituting in the definition of $\\op{a}_p$ and applying resolution of the identity to each argument.}\n\\begin{align}\n  \\Y(1,\\cd,n)\n=&\\\n  \\tfr{1}{\\sqrt{n}}\n  \\sum_p^\\infty\\y_p(1)\\pr{\\op{a}_p\\Y}(2,\\cd,n)\n\\\\=&\\\n  \\tfr{1}{\\sqrt{n(n-1)}}\n  \\sum_{pq}^\\infty\n  \\y_p(1)\\y_q(2)(\\op{a}_q\\op{a}_p\\Y)(3,\\cd,n)\n\\end{align}\nTherefore, matrix elements of the electronic Hamiltonian with respect to $\\Y,\\Y'\\in \\mc{F}_n$ can be expressed as\n\\begin{align*}\n  \\ip{\\Y|\\op{H}\\Y'}\n=\n  \\sum_{i=1}^n\\ip{\\Y|\\op{h}(i)\\Y'}\n+\n  \\sum_{i<j}^n\\ip{\\Y|\\op{g}(i,j)\\Y'}\n=&\\\n  n\\ip{\\Y|\\op{h}(1)\\Y'}\n+\n  \\tfr{n(n-1)}{2}\n  \\ip{\\Y|\\op{g}(1,2)\\Y'}\n\\\\=&\\\n  \\sum_{pq}^\\infty\n  h_{pq}\\ip{\\op{a}_p\\Y|\\op{a}_q\\Y'}\n+\n  \\tfr{1}{2}\n  \\sum_{pqrs}^\\infty\n  \\ip{pq|rs}\\ip{\\op{a}_q\\op{a}_p\\Y|\\op{a}_s\\op{a}_r\\Y'}\n\\end{align*}\nin terms of the usual one- and two-electron integrals.\nSince $\\Y$ and $\\Y'$ are arbitrary elements of $\\mc{F}_n$, this implies\n\\begin{align}\\label{eq:second-quantized-hamiltonian}\n  \\left.\n  \\op{H}\n  \\right|_{\\mc{F}_n}\n=\n  \\sum_{pq}^\\infty\n  h_{pq}\n  \\op{a}_p\\dg \\op{a}_q\n+\n  \\tfr{1}{2}\n  \\sum_{pqrs}^\\infty\n  \\ip{pq|rs}\n  \\op{a}_p\\dg\\op{a}_q\\dg\\op{a}_s\\op{a}_r\n\\end{align}\nwhich is the \\textit{second quantized} form of the Hamiltonian, as opposed to the \\textit{first quantized} form which is not restricted to antisymmetric functions.\nA defining feature of the second quantization formalism is that $\\op{H}$ is independent of the number of electrons, because \\cref{eq:second-quantized-hamiltonian} holds for all $n$.\n\n\n\n\\subsection{Formal treatment of second quantization}\n\n\\begin{dfn}\\label{dfn:direct-sum-and-direct-product}\n\\thmtitle{Direct sums and products}\n\\begin{samepage}\nThe \\textit{direct sum}, $\\oplus$, and \\textit{direct product}\\footnote{Also known as a \\textit{tensor product}}, $\\otimes$, are operations defining two different ways of combining vector spaces.\nEach operation takes a vector from one space and a vector the other to form an ordered pair, but they behave differently under vector addition and scalar multiplication.\nIn a direct sum space $V\\oplus V'\\equiv\\{v\\oplus v'\\,|\\,v\\in V,\\,v'\\in V'\\}$,\nvector addition and scalar multiplication are defined by\n\\begin{align}\n  v_1\\oplus v_1'\n+\n  v_2\\oplus v_2'\n=\n  (v_1 + v_2)\n\\oplus\n  (v_1' + v_2')\n&&\n  c(v\\oplus v')\n=\n  cv\\oplus cv'\\,,\n\\end{align}\nwhereas, in a direct product space $V\\otimes V'\\equiv\\{\\sum v\\otimes v'\\,|\\,v\\in V,\\,v'\\in V'\\}$, they are defined as follows.\n\\begin{align}\n  v_1\\otimes v'\n+\n  v_2\\otimes v'\n=\n  (v_1 + v_2)\\otimes v'\n&&\n  v\\otimes v_1'\n+\n  v\\otimes v_2'\n=\n  v\\otimes(v_1' + v_2')\n&&\n  c(v\\otimes v')\n=\n  (cv)\\otimes v'\n=\n  v\\otimes(cv')\n\\end{align}\nNote that $\\oplus$ behaves like addition and $\\otimes$ behaves like multiplication.\nIf $\\{e_i\\}$ and $\\{e_{i'}'\\}$ are basis sets for $V$ and $V'$, respectively, then $\\{e_i\\oplus0'\\}\\cup\\{0\\oplus e_{i'}'\\}$ is a basis for their direct sum and $\\{e_i\\otimes e_{i'}'\\}$ is a basis for their direct product.\nThe dimension of the direct sum space is the sum of their dimensions,\n$\\dim V+\\dim V'$,\nand that of the direct product space is the product of their dimensions,\n$\\dim V\\cdot \\,\\dim V'$.\nFinally, if $\\ip{\\cdot|\\cdot}_V$ and $\\ip{\\cdot|\\cdot}_{V'}$ are inner products on $V$ and $V'$, then the following are inner products on the combined spaces.\n\\begin{align}\n  \\ip{v\\oplus v'|w\\oplus w'}_{V\\oplus V'}\n\\equiv\n  \\ip{v|w}_V\n+\n  \\ip{v'|w'}_{V'}\n&&\n  \\ip{v\\otimes v'|w\\otimes w'}_{V\\otimes V'}\n\\equiv\n  \\ip{v|w}_V\n\\cdot\n  \\ip{v'|w'}_{V'}\n\\end{align}\n\\end{samepage}\n\\end{dfn}\n\n\n\\begin{dfn}\n\\thmtitle{Hilbert space}\nIf $\\mc{H}$ is a one-electron Hilbert space spanned by a set of spin-orbitals $\\{\\y_p\\}$, then $\\mc{H}^{\\otimes n}=\\mc{H}\\otimes\\cd\\otimes\\mc{H}=\\spn\\{\\y_{p_1}{}\\otimes\\cd\\otimes\\y_{p_n}\\}$ is an \\textit{$n$-electron Hilbert space}.\\footnote{These basis vectors are abstract representations spin-orbital product functions, $\\ip{1\\otimes\\cd\\otimes n|\\y_{p_1}\\otimes\\cd\\otimes\\y_{p_n}}=\\y_{p_1}(1)\\cd\\y_{p_n}(n)$, which are known as \\textit{Hartree products}.}\n\\end{dfn}\n\n\n\\begin{dfn}\\label{dfn:fock-space}\n\\thmtitle{Fock space}\nLet $\\mc{F}_n(\\mc{H})$ denote $\\spn\\{\\F_{(p_1\\cd p_n)}\\}$,\\footnote{%\nThese basis vectors are Slater determinants, abstracted from position space:\n$\n  \\F_{(p_1\\cd p_n)}\n=\n  \\fr{1}{\\sqrt{n!}}\n  \\sum_{\\pi\\in\\mr{S}_n}\n  \\y_{p_{\\pi(1)}}\\otimes\\cd\\otimes\n  \\y_{p_{\\pi(n)}}\n$.\nEquation~\\ref{eq:slater-determinant-position-representation} corresponds to\n$\n  \\ip{1\\otimes\\cd\\otimes n|\\F_{(p_1\\cd p_n)}}= \\F_{(p_1\\cd p_n)}(1,\\ld,n)\n$.\n}\nthe antisymmetric subspace of $\\mc{H}^{\\otimes n}$.\n\\textit{Fock space} is the union of these spaces, $\\mc{F}(\\mc{H})=\\mc{F}_0(\\mc{H})\\oplus \\mc{F}_1(\\mc{H})\\oplus \\mc{F}_2(\\mc{H})\\oplus\\cd\\oplus \\mc{F}_{\\infty}(\\mc{H})$, comprising all possible electronic wavefunctions.\n\\end{dfn}\n\n\\begin{dfn}\\label{occupation-number-representation}\n\\thmtitle{Occupation vectors}\nIn the \\textit{occupation number formalism}, Fock space basis states are represented as \\textit{occupation vectors}.\nThese are denoted by a series of bits,\n$\n  \\kt{\\bo{n}}\n\\equiv\n  \\kt{n_1,n_2,n_3,\\cd,n_\\infty}\n$,\nwhere $n_p=1$ when $\\y_p$ is occupied and $n_p=0$ when it isn't.\nThe fully unoccupied state is called the \\textit{vacuum}, denoted $\\kt{\\vac}$, which spans $\\mc{F}_0(\\mc{H})$.\n\\end{dfn}\n\n\\begin{dfn}\\label{dfn:particle-hole-operators}\n\\thmtitle{Particle-hole operators}\n\\textit{Particle-hole operators} change the occupation numbers of one-particle states.\nThe \\textit{annihilation operator} of $\\y_p$ is a linear mapping $a_p:\\mc{F}_n(\\mc{H})\\rightarrow \\mc{F}_{n-1}(\\mc{H})$ defined by\n\\begin{align}\\label{eq:occ-num-annihilation-operator-action}\n  a_p\\kt{\\cd n_p\\cd}\n=\n  (-)^{n_1+\\cd+n_{p-1}}\n  \\kt{\\cd n_p-1\\cd}\n\\ \\ \\ \\text{if $n_p=1$}\n&&\n  a_p\\kt{\\cd n_p\\cd}\n=\n  0\n\\ \\ \\ \\text{if $n_p=0$}\n\\end{align}\nand the \\textit{creation operator} of $\\y_p$ is a linear mapping $c_p:\\mc{F}_n(\\mc{H})\\rightarrow \\mc{F}_{n+1}(\\mc{H})$ defined by\n\\begin{align}\\label{eq:occ-num-creation-operator-action}\n  c_p\\kt{\\cd n_p\\cd}\n=\n  (-)^{n_1+\\cd+n_{p-1}}\n  \\kt{\\cd n_p+1\\cd}\n\\ \\ \\ \\text{if $n_p=0$\\ }\n&&\n  c_p\\kt{\\cd n_p\\cd}\n=\n  0\n\\ \\ \\ \\text{if $n_p=1$.}\n\\end{align}\n\\end{dfn}\n\n\\begin{prop}\n\\thmtitle{$c_p=a_p\\dg$}\n\\thmstatement{Creation and annihilation operators of the same state $\\y_p$ are adjoints of each other.}\n\\thmproof{\n  $\\ip{n_1'n_2'\\cd|a_p[n_1n_2\\cd]}$ vanishes unless $n_p'=0$, $n_p=1$, and $n_q'=n_q\\ \\forall q\\neq p$.\n  Likewise for $\\ip{c_p[n_1'n_2'\\cd]|n_1n_2\\cd}$.\n  Therefore, $\\ip{\\Y|a_p\\Y'}=\\ip{c_p\\Y|\\Y'}$ for all $\\Y,\\Y'\\in \\mc{F}(\\mc{H})$ and $c_p=a_p\\dg$ by the definition of adjoint.\n}\n\\end{prop}\n\n\\begin{prop}\\label{prop:particle-hole-operator-anticommutator}\n\\thmtitle{$[q,q']_+=\\d_{q'q\\dg}$}\n\\thmstatement{Particle-hole operators $q$ and $q'$ anticommute unless $q'=q\\dg$, for which $[q,q\\dg]_+=1$.}~\\footnote{These are anticommutator brackets, $[q, q']_+ \\equiv qq' + q'q$.}\n\\thmproof{\n  Let $q$ and $q'$ be arbitrary particle-hole operators acting on $\\y_p$ and $\\y_{p'}$, respectively.\n  First, suppose $p\\neq p'$. Then\n  \\begin{align*}\n  &\n    qq'\\kt{\\cd n_p\\cd n_{p'}\\cd}\n  =\n    (-)^{n_p+\\sum_{r=p+1}^{p'}n_r}\n    \\kt{\\cd\\ol{n_p}\\cd\\ol{n_{p'}}\\cd}\n  \\,\\text{, and}\n  \\\\\n  &\n    q'q\\kt{\\cd n_p\\cd n_{p'}\\cd}\n  =\n    (-)^{\\ol{n_p}+\\sum_{r=p+1}^{p'}n_r}\n    \\kt{\\cd\\ol{n_p}\\cd\\ol{n_{p'}}\\cd}\n  \\end{align*}\n  where $\\ol{n_p}$ and $\\ol{n_{p'}}$ are the occupations after applying $q$ and $q'$.\n  Since $n_p$ and $\\ol{n_p}$ differ by one, $qq'=-q'q$.\n  The second case, $p=p'$, implies $q'\\in\\{q,q\\dg\\}$.\n  If $q'=q$, then $qq'=-q'q=0$.\n  If $q'=q\\dg$, either $n_p=1\\implies(a_p\\dg a_p + a_pa_p\\dg)\\kt{\\cd n_p\\cd}=(1+0)\\kt{\\cd n_p\\cd}$ or $n_p=0\\implies(a_p\\dg a_p + a_pa_p\\dg)\\kt{\\cd n_p\\cd}=(0+1)\\kt{\\cd n_p\\cd}$.\n  Either way, $q'=q\\dg\\implies(qq' + q'q)=1$.\n}\n\\end{prop}\n\n\\begin{rmk}\n\\thmtitle{Relating the determinant and occupation number formalisms}\nWhen $p_1<\\cd<p_n$, $\\F_{(p_1\\cd p_n)}$ is equivalent to the occupation vector $\\kt{\\bo{n}_{(p_1\\cd p_n)}}$ with ones at $p_1,\\cd,p_n$.\nOtherwise, this determinant is equivalent to $\\e_{\\pi}\\kt{\\bo{n}_{(p_1\\cd p_n)}}$ for $\\pi\\in\\mr{S}_n$ such that $p_{\\pi(1)}<\\cd<p_{\\pi(n)}$.\nThe actions of $a_p$ and $a_p\\dg$ on $\\F_{(p_1\\cd p_n)}$ are given by\n\\begin{align}\\label{eq:abstract-annihilation-operator-action}\n  a_p\\F_{(p_1\\cd p_n)}\n=\n  (-)^{k-1}\\F_{(p_1\\cd\\cancel{p_k}\\cd p_n)}\n  \\ \\text{if $p=p_k\\in(p_1\\cd p_n)$}\n&&\n  a_p\\F_{(p_1\\cd p_n)}\n=\n  0\n  \\ \\text{if $p\\notin(p_1\\cd p_n)$}\n\\\\\\label{eq:abstract-creation-operator-action}\n  a_p\\dg\\F_{(p_1\\cd p_n)}\n=\n  (-)^{k-1}\\F_{(p_1\\cd p_{k-1}pp_k\\cd p_n)}\n  \\ \\text{if $p\\notin(p_1\\cd p_n)$}\n&&\n  a_p\\dg\\F_{(p_1\\cd p_n)}\n=\n  0\n  \\ \\text{if $p\\in(p_1\\cd p_n)$}\n\\end{align}\nwhich follows directly from \\Cref{eq:occ-num-annihilation-operator-action,eq:occ-num-creation-operator-action} when $p_1<\\cd<p_n$.\nOther cases follow from the fact that any sign factors for permuting $(p_1\\cd p_n)$ cancel on both sides of the equation, including the position of insertion or deletion, $p_k$, whose phase is tracked by $(-)^{k-1}$ on the right.\nThat is, both sides of the equation are antisymmetric to permutations of $(1\\cd n)$.\nNote that \\Cref{eq:abstract-annihilation-operator-action} was also derived in \\Cref{ssec:direct-derivation-of-second-quantization} using the position-space representation of $a_p$.\nOne advantage of the determinant basis is that, unlike occupation vectors, determinants translate directly into strings of creations operators\n\\begin{align}\n  \\kt{\\F_{(p_1\\cd p_n)}}\n=\n  a_{p_1}\\dg\\cd a_{p_n}\\dg\\kt{\\vac}\n\\end{align}\nwithout any phase ambiguity.\nTogether with the second quantized form of the electronic Hamiltonian, this boils much of the grunt work of electronic structure theory down to particle-hole operator algebra.\n\\end{rmk}\n\n\\begin{dfn}\n\\thmtitle{Excitation operators and excited determinants}\nOperator strings of the form $a_{p_1}\\dg\\cd a_{p_m}\\dg a_{q_m}\\cd a_{q_1}$ are called \\textit{excitation operators}.\nFor a given reference determinant $\\F$, excited determinants can be constructed as\n\\begin{align}\n  \\F_{i_1\\cd i_m}^{a_1\\cd a_m}\n=\n  a_{a_1}\\dg\\cd a_{a_m}\\dg a_{i_m}\\cd a_{i_1}\\F\n=\n  a_{a_1}\\dg a_{i_1}\\cd a_{a_m}\\dg a_{i_m}\\F\n\\end{align}\nwhere $i_1,\\cd,i_m$ are occupied and $a_1,\\cd,a_m$ are virtual indices with respect to $\\F$.\n\\end{dfn}\n\n\\begin{dfn}\\label{dfn:particle-hole-isomorphism}\n\\thmtitle{Particle-hole isomorphism}\nThe \\textit{particle-hole isomorphism} with respect to the reference determinant $\\kt{\\F}=\\kt{\\underset{\\text{$n$ times}}{1\\cd1}\\,0\\,0\\cd}$ is a mapping $F(\\mc{H})\\rightarrow F(\\mc{H})$ that inverts the bits occupied in $\\F$:\n\\begin{align*}\n  \\kt{k_1\\cd k_nk_{n+1}k_{n+2}\\cd}\n\\mapsto\n  \\kt{\\ol{k}_1\\cd \\ol{k}_nk_{n+1}k_{n+2}\\cd}\n\\sp\n  \\text{where $\\ol{k}_i=1-k_i$.}\n\\end{align*}\nPhysically, this corresponds to shift in perspective from the \\textit{particle frame} to a \\textit{quasiparticle frame}, where the first $n$ states are viewed as \\textit{holes} rather than \\textit{particles}.\nThis makes $\\kt{\\vac}\\mapsto\\kt{\\underset{\\text{$n$ times}}{\\ol{1}\\cd\\ol{1}}\\,0\\,0\\cd}$ a state of $n$ holes and no particles.  $\\kt{\\F}\\mapsto\\kt{\\underset{\\text{$n$ times}}{\\ol{0}\\cd\\ol{0}}\\,0\\,0\\cd}$ becomes the \\textit{quasiparticle vacuum state}, in which all hole and particle states are unoccupied.\n\\end{dfn}\n\n\\begin{dfn}\n\\thmtitle{Quasiparticle creation and annihilation operators}\nIf we apply \\Cref{dfn:particle-hole-operators} to the new quasiparticle Fock space, we end up with a new system of \\textit{quasi-particle-hole operators} $\\{b_p\\}\\cup\\{b_p\\dg\\}$, related to the old set via\n\\begin{align}\n&&\n  a_i\n\\mapsto\n  b_i\\dg\n&&\n  a_i\\dg\n\\mapsto\n  b_i\n&&\n  a_a\n\\mapsto\n  b_a\n&&\n  a_a\\dg\n\\mapsto\n  b_a\\dg\n\\end{align}\nwhere $i$ and $a$ are occupied and virtual indices with respect to the reference determinant $\\F$.\n$\\{a_i\\dg\\}\\cup\\{a_a\\}\\mapsto\\{b_p\\}$ are therefore \\textit{quasiparticle annihilation operators} and $\\{a_i\\}\\cup\\{a_a\\dg\\}\\mapsto\\{b_p\\dg\\}$ are \\textit{quasiparticle creation operators}.\n\\end{dfn}\n\n\\begin{rmk}\nThe standard expression for the second-quantized Hamiltonian is\n\\begin{align}\n  H\n=\n  \\sum_{pq}\n  h_{pq}\\,\n  a_p\\dg a_q\n+\n  \\tfr{1}{4}\n  \\sum_{pqrs}\n  \\ip{pq||rs}\\,\n  a_p\\dg a_q\\dg a_sa_r\n\\end{align}\nwhere the summations run over the full set of spin-orbitals.\nNote that this matches \\Cref{eq:second-quantized-hamiltonian}, except that we have rearranged the second term to express it in terms of antisymmetrized integrals.\nIn terms of quasi-particle-hole operators,\n\\begin{align}\n\\nonumber\n  H\n=&\\\n  \\sum_{ab}\n  h_{ab}\\,\n  b_a\\dg b_b\n+\n  \\sum_{ai}\n  h_{ai}\\,\n  b_a\\dg b_i\\dg\n+\n  \\sum_{ia}\n  h_{ia}\\,\n  b_i b_a\n+\n  \\sum_{ij}\n  h_{ij}\n  b_i b_j\\dg\n\\\\\\nonumber&\\\n+\n  \\tfr{1}{4}\n  \\sum_{abcd}\n  \\ip{ab||cd}\\,\n  b_a\\dg b_b\\dg b_d b_c\n+\n  \\tfr{1}{2}\n  \\sum_{abci}\n  \\ip{ab||ci}\\,\n  b_a\\dg b_b\\dg b_i\\dg b_c\n+\n  \\tfr{1}{2}\n  \\sum_{aibc}\n  \\ip{ai||bc}\\,\n  b_a\\dg b_i b_c b_b\n+\n  \\tfr{1}{4}\n  \\sum_{abij}\n  \\ip{ab||ij}\\,\n  b_a\\dg b_b\\dg b_j\\dg b_i\\dg\n+\n  \\sum_{aibj}\n  \\ip{ai||bj}\\,\n  b_a\\dg b_i b_j\\dg b_b\n\\\\&\\\n+\n  \\tfr{1}{4}\n  \\sum_{ijab}\n  \\ip{ij||ab}\\,\n  b_i b_j b_b b_a\n+\n  \\tfr{1}{2}\n  \\sum_{iajk}\n  \\ip{ia||jk}\\,\n  b_i b_a\\dg b_k\\dg b_j\\dg\n+\n  \\tfr{1}{2}\n  \\sum_{ijka}\n  \\ip{ij||ka}\\,\n  b_i b_j b_a b_k\\dg\n+\n  \\tfr{1}{4}\n  \\sum_{ijkl}\n  \\ip{ij||kl}\\,\n  b_i b_j b_l\\dg b_k\\dg\n\\end{align}\nwhere we have split the full summations above into summations over occupied and virtual orbitals and grouped like terms.\n\\end{rmk}\n\n\\begin{dfn}\n\\thmtitle{Normal order}\nA string $q_1\\cd q_n$ of particle-hole operators is in \\textit{normal order} when all of its creation operators sit to the left of its annihilation operators.\nThat is, when the string has the form $a_{p_1}\\dg\\cd a_{p_m}\\dg a_{r_1}\\cd a_{r_{m'}}$.\nThis guarantees that its vacuum expectation value vanishes, $\\ip{\\vac|q_1\\cd q_n|\\vac}=0$.\nMore generally, we say that $q_1\\cd q_n$ is in \\textit{$\\F$-normal order} if it maps into a string of the form $b_{p_1}\\dg\\cd b_{p_m}\\dg b_{r_1}\\cd b_{r_{m'}}$ under particle-hole isomorphism referenced to $\\F$, since this guarantees that\n$\\ip{\\F|q_1\\cd q_n|\\F}=0$.\n\\end{dfn}\n\n\\begin{ex}\nIn second quantization, any operator string can be expanded as a linear combination of strings which are in normal order.\nThe expectation value of a string is always equal to the constant term in this expansion.\nFor example:\n\\begin{align*}\n  a_p a_q\\dg\n=\n-\n  a_q\\dg a_p\n+\n  \\d_{pq}\n&\\implies\n  \\ip{\\vac|a_p a_q\\dg|\\vac}\n=\n  \\d_{pq}\n\\\\\n  a_p a_q a_s\\dg a_r\\dg\n=\n  a_r\\dg a_s\\dg a_q a_p\n+\n  \\d_{ps}\n  a_r\\dg a_q\n-\n  \\d_{pr}\n  a_s\\dg a_q\n-\n  \\d_{qs}\n  a_r\\dg a_p\n+\n  \\d_{qr}\n  a_s\\dg a_p\n-\n  \\d_{ps}\\d_{qr}\n+\n  \\d_{pr}\\d_{qs}\n&\\implies\n  \\ip{\\vac|a_p a_q a_s\\dg a_r\\dg|\\vac}\n=\n  \\d_{pr}\\d_{qs}\n-\n  \\d_{ps}\\d_{qr}\n\\end{align*}\nwhere we have made repeated use of \\Cref{prop:particle-hole-operator-anticommutator} to arrive at these expansions.\nThis strategy becomes unwieldy for expectation values of a reference determinant $\\F$, in which case it is more convenient to use particle-hole isomorphism.\nFor example, consider the following matrix element of the core Hamiltonian.\n\\begin{align*}\n  \\sum_{pq}\n  h_{pq}\n  \\ip{\\F|a_p\\dg a_q|\\F_i^a}\n=\n  \\sum_{bc}\n  h_{bc}\\,\n  \\cancel{\\ip{\\F|b_b\\dg b_c b_a\\dg b_i\\dg|\\F}}\n+\n  \\sum_{bj}\n  h_{bj}\\,\n  \\cancel{\\ip{\\F|b_b\\dg b_j\\dg b_a\\dg b_i\\dg|\\F}}\n+\n  \\sum_{jb}\n  h_{jb}\\,\n  \\cancelto{\\d_{ab}\\d_{ij}}{\\ip{\\F|b_j b_b b_a\\dg b_i\\dg|\\F}}\n+\n  \\sum_{jk}\n  h_{jk}\n  \\cancel{\\ip{\\F|b_j b_k\\dg b_a\\dg b_i\\dg|\\F}}\n=\n  h_{ia}\n\\end{align*}\nOnly the third term survives, because the others generate a ket state with a different number of quasi-particles from the bra state.\n\\end{ex}\n\n\n\\end{document}\n", "meta": {"hexsha": "e12055830a81351983b877871a1362d581f6098f", "size": 18443, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2017/tex/1q-2h-second-quantization.tex", "max_stars_repo_name": "GQCG-edu/chem-8950", "max_stars_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2017-09-29T20:25:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:40:32.000Z", "max_issues_repo_path": "2017/tex/1q-2h-second-quantization.tex", "max_issues_repo_name": "GQCG-edu/chem-8950", "max_issues_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-07-13T12:11:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-13T15:31:47.000Z", "max_forks_repo_path": "2017/tex/1q-2h-second-quantization.tex", "max_forks_repo_name": "GQCG-edu/chem-8950", "max_forks_repo_head_hexsha": "a5f58a5feacbae16b02fddd2c74723da1486b8d2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2017-09-10T10:33:28.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-05T07:39:50.000Z", "avg_line_length": 32.3561403509, "max_line_length": 458, "alphanum_fraction": 0.6620940194, "num_tokens": 7125, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6513548578981939, "lm_q1q2_score": 0.42194651620090007}}
{"text": "\\documentclass[twocolumn]{article}\n\n\\usepackage{abstract}\n\\usepackage{algorithm}\n\\usepackage{appendix}\n\\usepackage{amsmath}\n\\usepackage{amsfonts} % \\mathbb\n\\usepackage[margin=0.6in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{mathtools} % \\multlined\n\\usepackage{multirow}\n\\usepackage{siunitx}  % use \\si{\\angstrom} for Angstrom\n\n\\usepackage{subfig}\n\\usepackage{xspace}\n\n\\newcommand*\\samethanks[1][\\value{footnote}]{\\footnotemark[#1]}\n\\newcommand{\\pygbe}{\\texttt{PyGBe}\\xspace}\n\\newcommand{\\gmres}{\\textsc{gmres}\\xspace}\n\\newcommand{\\bem}{\\textsc{bem}\\xspace}\n\\newcommand{\\fmm}{\\textsc{fmm}\\xspace}\n\\newcommand{\\kifmm}{\\textsc{kifmm}\\xspace}\n\\newcommand{\\ncrit}{n_{\\mathrm{crit}}}  % number of particles per leaf\n\\newcommand{\\ses}{\\textsc{ses}\\xspace}\n\\newcommand{\\msms}{\\texttt{\\textsc{msms}}\\xspace}\n\\newcommand{\\ie}{\\textit{i}.\\textit{e}., }\n\n\\graphicspath{{figs/}}\n\n\\title{High-productivity, high-performance workflow for virus-scale electrostatic simulations with Bempp-Exafmm}\n\n\\author{%\n    Tingyu Wang\\thanks{Department of Mechanical and Aerospace Engineering, The George Washington University, Washington, DC, USA}%\n    \\and Christopher D. Cooper\\thanks{Department of Mechanical Engineering and Centro Cient\\'ifico Tecnol\\'ogico de Valpara\\'iso, Universidad T\\'ecnica Federico Santa Mar\\'ia, Valpara\\'iso, Chile}%\n    \\and Timo Betcke\\thanks{Department of Mathematics, University College London, UK}%\n    \\and Lorena A. Barba\\samethanks[1]%\n}\n\n\\date{}\n\n\\begin{document}\n\n\\twocolumn[\n\\maketitle\n\n%% abstract\n\\begin{onecolabstract}\nBiomolecular electrostatics is key in protein function and the chemical processes affecting it.\nImplicit-solvent models via the Poisson-Boltzmann (PB) equation provide insights with less computational cost than atomistic models, making large-system studies---at the scale of viruses---accessible to more researchers.\n    Here we present a high-productivity and high-performance PB solver based on Exafmm, a fast multipole method library, and Bempp, a Galerkin boundary element method package.\n    The workflow integrates an easy-to-use Python interface with optimized computational kernels, and\n    can be run interactively via Jupyter notebooks, for faster prototyping.\n    Our results show the capability of the software, confirm code correctness, and assess performance with between 8,000 and 2 million elements.\n    Showcasing the power of this interactive computing platform, we study the conditioning of two variants of the boundary integral formulation with just a few lines of code.\n    Mesh-refinement studies confirm convergence as $1/N$, for $N$ boundary elements, and\n    a comparison with results from the trusted APBS code using various proteins shows agreement.\n    Performance results include timings, breakdowns, and computational complexity.\n    Exafmm offers evaluation speeds of just a few seconds for tens of millions of points, and $\\mathcal{O}(N)$ scaling.\n    Computing the solvation free energy of a Zika virus, represented by 1.6 million atoms and 10 million boundary elements, took 80-min runtime on a single compute node (dual 20-core).\n\n\\end{onecolabstract}\n]\n%% keyword\n%\\begin{keyword}\n%    boundary integral equation \\sep boundary element method \\sep Galerkin method \\sep fast multipole method \\sep\n%    Python \\sep biomolecular electrostatics \\sep implicit solvent \\sep Poisson-Boltzmann \\sep solvation free energy\n%\\end{keyword}\n\n% body of paper\n\\section{Introduction}\\label{sec:intro}\n\\input{introduction}\n\n\\section{Results}\\label{sec:results}\n\\input{results}\n\n\\section{Discussion} \\label{sec:discussion}\n\\input{discussion}\n\n\\small{\n\\section{Methods}\\label{sec:methods}\n\\input{methods_formulation}\n\\input{methods_bempp}\n\\input{methods_exafmm}\n}\n\n\\section{Data availability}\nWe deposited the meshes and \\texttt{pqr} files on the Zenodo service: \\href{http://doi.org/10.5281/zenodo.4568768}{doi:10.5281/zenodo.4568768}.\nThe raw and secondary data for all results are available in the archival deposit of our paper’s GitHub repository: \\href{http://doi.org/10.5281/zenodo.4568951}{doi:10.5281/zenodo.4568951}.\n\n\\section{Code availability}\nExafmm is available at \\href{https://github.com/exafmm/exafmm-t}{https://github.com/exafmm/exafmm-t} under the BSD 3 license.\nBempp-cl is available at \\href{https://github.com/bempp/bempp-cl}{https://github.com/bempp/bempp-cl} under the MIT license.\nThe scripts for plotting and rerunning our experiments are available in the archival deposit of our paper’s GitHub repository: \\href{http://doi.org/10.5281/zenodo.4568951}{doi:10.5281/zenodo.4568951}.\n\n\\bibliography{./reference}{}\n\\bibliographystyle{elsarticle-num}\n\n\\section*{Acknowledgments}\nWe thank Dr. Sergio Pantano for providing us with the parameterized structure of the Zika virus capsid.\nCDC acknowledges support by ANID (Agencia Nacional de Investigaci\\'{o}n y Desarrollo) through PIA/APOYO AFB180002.\nTB was supported by Engineering and Physical Sciences Research Council Grant EP/V001531/1.\nLAB acknowledges funding from the National Science Foundation via award \\#1747669.\n\n\\section*{Author contributions}\nLAB and TB conceived this project. \nTW wrote the version of the Exafmm code used in this work, the Python bindings and the Bempp integration. \nTB gave technical support on Bempp usage and wrote code to aid the integration.\nCDC gave conceptual advice and helped set up computational experiments.\nTW ran the calculations and prepared the figures.\nTW, CDC, TB, and LAB discussed and guided the conduct of the research, and interpreted the results.\nTW wrote the first draft of the manuscript, and all authors contributed materially to the writing and revising.\nLAB guided the data management and guarantees the preservation of the full research compendium for this work. \nAll authors confirm that the figures and conclusions accurately reflect the research.\n\n\n\\section*{Competing interests}\nThe authors declare no competing interests.\n\n\\appendix\n\\input{appendix}\n\n\\end{document}", "meta": {"hexsha": "845d5838e8dd8839fc79cb202ab1e5985912436c", "size": 5975, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/main.tex", "max_stars_repo_name": "barbagroup/bempp_exafmm_paper", "max_stars_repo_head_hexsha": "d628305aa7a7713d8d37234e80260e2a4160b9c8", "max_stars_repo_licenses": ["MIT", "BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-06-21T04:11:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T03:18:36.000Z", "max_issues_repo_path": "tex/main.tex", "max_issues_repo_name": "barbagroup/bempp_exafmm_paper", "max_issues_repo_head_hexsha": "d628305aa7a7713d8d37234e80260e2a4160b9c8", "max_issues_repo_licenses": ["MIT", "BSD-3-Clause"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2021-02-06T19:28:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T20:09:48.000Z", "max_forks_repo_path": "tex/main.tex", "max_forks_repo_name": "barbagroup/bempp_exafmm_paper", "max_forks_repo_head_hexsha": "d628305aa7a7713d8d37234e80260e2a4160b9c8", "max_forks_repo_licenses": ["MIT", "BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-01T03:24:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-01T03:24:03.000Z", "avg_line_length": 48.5772357724, "max_line_length": 220, "alphanum_fraction": 0.7854393305, "num_tokens": 1546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.42194651615617534}}
{"text": "\\chapter{BDS test for independence}\n\n\\section{Name}\n\nbdstest --- BDS test for independence\n\n\\section{Synopsis}\n\n{\\small \\begin{verbatim}\n#include \"shg/bdstest.h\"\nusing namespace SHG;\nclass BDS_test {\npublic:\n     struct Result {\n          double stat;\n          double pval;\n     };\n     BDS_test(const std::vector<double>& u,\n              int maxm,\n              const std::vector<double>& eps);\n     BDS_test(const std::vector<double>& u);\n     inline int maxm() const;\n     inline const std::vector<double>& eps() const;\n     inline const std::vector<std::vector<Result>>& res() const;\nprivate:\n     /* ... */\n};\n\nstd::ostream& operator<<(std::ostream& stream, const BDS_test& b);\n\\end{verbatim}}\n\n\\section{Description}\n\nThe class performs the BDS test for independence~\\cite\n{brock-dechert-scheinkman-lebaron-1996}.\n\nLet $(u_t)_{t = 1}^n$ be a time series. The BDS test statistic for an\nembedding dimension $m \\geq 1$ and a threshold $\\epsilon > 0$ is\ndefined as\n\\begin{equation} \\label{eq:statistic}\n  W(m, \\epsilon) = \\sqrt{n} \\, \\frac{C_{m, n}(\\epsilon) - [C_{1,\n        n}(\\epsilon)]^m} {V_{m, n}(\\epsilon)},\n\\end{equation}\nwhere\\footnote{$\\chi_{\\epsilon}$ is the characteristic function of the\n  interval $[0, \\epsilon)$.}\n\\begin{equation} \\label{eq:Cmn}\n  C_{m, n}(\\epsilon) = \\frac{2}{(n - m + 1)(n - m)} \\sum_{1 \\leq s < t\n    \\leq n - m + 1} \\chi_{\\epsilon} \\left( \\max_{0 \\leq i < m} |u_{s +\n    i} - u_{t + i}| \\right)\n\\end{equation}\nis the correlation integral\\footnote{Cf.~\\cite [p.~120]\n  {baker-gollub-1998}.} and\n\\begin{equation} \\label{eq:bds2.11}\n  \\begin{split}\n  \\frac{1}{4}V_{m, n}^2(\\epsilon) &= m(m - 2) C^{2m - 2} (K - C^2) +\n  K^m - C^{2m} + \\\\\n  & \\quad + 2 \\sum_{j = 1}^{m - 1} \\left[ C^{2j} (K^{m - j} - C^{2m -\n      2j}) - mC^{2m -2} (K - C^2) \\right],\n  \\end{split}\n\\end{equation}\nwhere\n\\begin{align} \\label{eq:bds2.12}\n  C &= C_n(\\epsilon) = \\frac{1}{n^2} \\sum_{s = 1}^n \\sum_{t = 1}^n\n  \\chi_{\\epsilon}(|u_s - u_t|), \\\\\n  \\label{eq:bds2.13}\n  K &= K_n(\\epsilon) = \\frac{1}{n^3} \\sum_{r = 1}^n \\sum_{s = 1}^n\n  \\sum_{t = 1}^n \\chi_{\\epsilon}(|u_r - u_s|) \\chi_{\\epsilon}(|u_s -\n  u_t|).\n\\end{align}\nIf $(u_t)_{t = 1}^n$ is a series of independent identically\ndistributed random variables, then for $m \\geq 2$ the\nstatistic~(\\ref{eq:statistic}) converges in distribution to the\nstandard normal distribution.\n\nThe first constructor requires the time series $(u_t)_{t = 1}^{n}$,\narranged in a vector with index running from 0 to $n - 1$, the maximum\nembedding dimension $\\mathit{maxm}$ and the vector of thresholds\n$\\mathit{eps}$. The second constructor requires only the time series\nand arbitrarily sets $\\mathit{maxm} = 8$ and \\[ \\mathit{eps}\n= \\begin{bmatrix} 0.5s & 0.75s & s & 1.25s & 1.5s & 1.75s &\n  2s \\end{bmatrix}, \\] where\n\\begin{equation} \\label{eq:mean_var}\n  s^2 = \\frac{1}{n} \\sum_{t = 1}^n (u_t - \\bar{u})^2, \\quad\n  \\bar{u} = \\frac{1}{n} \\sum_{t = 1}^n u_t.\n\\end{equation}\n\nAfter successful construction, the function \\verb|res()| returns an\narray of structures of type \\verb|BDS_test::Result|, whose member\n\\verb|res()[m][i].stat| reports the value of the statistic $W(m,\n\\epsilon)$ defined by~(\\ref{eq:statistic}) for the embedding dimension\n$2 \\leq m \\leq \\mathit{maxm}$ and the $i$-th threshold in\n$\\mathit{eps}$. The member \\verb|res()[m][i].pval| reports the\nprobability\n\\[ \\left\\{ \\begin{array}{ll}\n  \\Phi(W(m, \\epsilon)) & \\mbox{if $W(m, \\epsilon) < 0$,} \\\\\n  1 - \\Phi(W(m, \\epsilon)) & \\mbox{if $W(m, \\epsilon) \\geq 0$,}\n\\end{array} \\right. \\]\nwhere $\\Phi$ is the cumulative distribution function of the standard\nnormal distribution. The values of \\verb|res()[m][i]| are undefined\nfor $m = 0, 1$.\n\nThe functions \\verb|maxm()| and \\verb|eps()| return $\\mathit{maxm}$\nand the vector $\\mathit{eps}$ used during construction, respectively.\n\nThe operator \\verb|<<| outputs the four-column plain table of results\nwith $\\mathit{\\epsilon}$, $m$, $W(m, \\epsilon)$ and the p-value on\neach row.\n\n\\section{Implementation}\n\nIn the implementation,~(\\ref{eq:bds2.11}) is simplified to\n\\begin{equation} \\label{eq:simpleV}\n  \\frac{1}{4}V_{m, n}^2(\\epsilon) = K^m + (m - 1)^2 C^{2m} - m^2 K\n  C^{2m -2} + 2 \\sum_{j = 1}^{m - 1} C^{2j} K^{m - j}\n\\end{equation}\nand~(\\ref{eq:bds2.13}) is simplified to\n\\begin{equation} \\label{eq:bds2.13s}\n  K = \\frac{1}{n^3} \\sum_{s = 1}^n \\left[ \\sum_{t = 1}^n\n    \\chi_{\\epsilon}(|u_s - u_t|) \\right]^2.\n\\end{equation}\n\n\\section{Errors}\n\nThe constructors can throw \\verb|std::invalid_argument| if $n < 1$ or\n$n$ is too big or $\\mathit{maxm} < 2$ or $\\mathit{maxm} \\geq n$. They\ncan also throw \\verb|std::range_error| if due to rounding errors\n$V_{m, n}^2(\\epsilon) / n$, required to\ncalculate~(\\ref{eq:statistic}), is negative or too small or the\nvariance in~(\\ref{eq:mean_var}) is negative or too small.\n\n\\section{Example}\n\nThe following program:\n\n{\\footnotesize \\begin{verbatim}\n#include <iostream>\n#include <iomanip>\n#include \"shg/bdstest.h\"\n\n/** Borosh-Niederreiter random number generator. See Donald E. Knuth,\n    Sztuka programowania. Tom 2. Algorytmy seminumeryczne, WNT,\n    Warszawa 2002, p. 113. */\ndouble bn() {\n     static unsigned long int x = 1ul;\n     x = (1812433253ul * x) & 0xfffffffful;\n     return x / 4294967296.0;\n}\n\nusing namespace std;\nusing SHG::BDS_test;\n\nint main() {\n     vector<double> u(1000);\n     cout << fixed << setprecision(5);\n\n     for (vector<double>::size_type i = 0; i < u.size(); i++)\n          u[i] = bn();\n     /** eps is the standard deviation of U(0, 1). */\n     cout << BDS_test(u, 8, {sqrt(1.0 / 12.0)}) << '\\n';\n\n     for (vector<double>::size_type i = 0; i < u.size(); i++)\n          u[i] = i % 2 ? 2.0 * bn() : bn();\n     /** eps is the standard deviation of the mixture of U(0, 1) and\n         U(0, 2) with mixing weights 0.5. */\n     cout << BDS_test(u, 8, {sqrt(13.0 / 48.0)});\n}\n\\end{verbatim}}\n\\noindent produces:\n{\\footnotesize \\begin{verbatim}\n0.28868 2 0.27392 0.39207\n0.28868 3 0.26732 0.39461\n0.28868 4 -0.33474 0.36891\n0.28868 5 -0.97089 0.16580\n0.28868 6 -1.83736 0.03308\n0.28868 7 -2.35252 0.00932\n0.28868 8 -2.16494 0.01520\n\n0.52042 2 -3.96242 0.00004\n0.52042 3 0.39043 0.34811\n0.52042 4 -0.07102 0.47169\n0.52042 5 1.30413 0.09609\n0.52042 6 1.26937 0.10215\n0.52042 7 2.17663 0.01475\n0.52042 8 2.04631 0.02036\n\\end{verbatim}}\n", "meta": {"hexsha": "1fd481af981135386eab1585534b5900a04aecb0", "size": 6266, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/bdstest.tex", "max_stars_repo_name": "shgalus/shg", "max_stars_repo_head_hexsha": "0318d0126cf12c3236183447d130969c468a02fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2015-05-21T04:14:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-31T17:15:15.000Z", "max_issues_repo_path": "doc/bdstest.tex", "max_issues_repo_name": "shgalus/shg", "max_issues_repo_head_hexsha": "0318d0126cf12c3236183447d130969c468a02fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-05-21T05:31:04.000Z", "max_issues_repo_issues_event_max_datetime": "2015-05-21T05:31:04.000Z", "max_forks_repo_path": "doc/bdstest.tex", "max_forks_repo_name": "shgalus/shg", "max_forks_repo_head_hexsha": "0318d0126cf12c3236183447d130969c468a02fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-05-21T04:14:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-18T12:35:22.000Z", "avg_line_length": 33.688172043, "max_line_length": 70, "alphanum_fraction": 0.6348547718, "num_tokens": 2391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.42194651181669235}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{mathrsfs}\n\\usepackage{amssymb} % for \"\\mathbb\" macro\n\\usepackage[round]{natbib}\n\\usepackage{url}\n\\usepackage{hyperref}\n\\usepackage[toc,page]{appendix}\n\n\\title{Three Factor Seasonal Commodity Price Process}\n\\author{Jake C. Fowler}\n\\date{December 2020}\n\n\\begin{document}\n\\newcommand{\\+}[1]{\\ensuremath{\\mathbf{#1}}}\n\n\\maketitle\n\nWARNING: THIS DOCUMENT IS CURRENTLY WORK IN PROGRESS\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Introduction}\nThis paper presents a specific set for parameters for the multi-factor model presented in \\cite{Fowler}\nsuch that the model should have similar statistical properties to the three-factor spot price\nmodel presented in \\cite{Boogert} the model used in the commercial KyStore gas storage valuation model. \n\n\n\\section{Forward Price SDE}\nThe starting point is the SDE (stochastic differential equation) for the forward\nprice process:\n\n\\begin{align}\n    \\label{eq:forward_sde}\n    \\frac{dF(t, T)^l}{F(t, T)^l}=\\sum_{i=1}^{n^l} \\sigma_i^l(T)e^{-\\alpha_i^l(T-t)}dz_i^l(t) \\\\\n    \\nonumber\n    \\alpha_i^l \\in \\mathbb{R}_{\\ge 0} \\\\\n    \\nonumber\n    t \\in \\mathbb{R}_{\\ge 0} \\\\\n    \\nonumber\n    T \\in \\{ T_0^l, T_1^l, T_2^l, \\hdots | T_j^l \\ge t  \\} \\\\\n    \\nonumber\n    \\sigma_i^l : \\mathbb{R}_{\\ge 0} \\rightarrow \\mathbb{R} \\\\\n    \\nonumber\n    l \\in [1, m]\n\\end{align}\n\nWhere $z_i^l(t)$ follow correlated Wiener processes with correlation $\\rho_{i, j}^{x, y}$, i.e.\n\n\\begin{equation}\n    \\mathbb{E}[dz_i^x(t)dz_j^y(t)] = \\rho_{i, j}^{x, y}dt\n\\end{equation}\n\n$F(t, T_j)^l$ is the forward price observed at time $t$, for delivery over the time \ninterval $[T_j, T_{j+1})$ of the $l^{\\text{th}}$ of $m$ commodity underlyings.\n\n\\section{Three Factor Seasonal Form}\nThe three factor seasonal parameters clearly has parameter $n=3$. The first factor is\nthe spot or short-term factor. For this factor there is a constant volatity and mean\nreversion, i.e. $\\sigma_1(T) = \\sigma_{spot}$ and as this is the only factor with\nnon-zero mean reversion $\\alpha_1 = \\alpha$. This factor has the heuristic interpretation\nas random shocks which move the forward curve in an exponentially decaying (as function of\ntime to maturity) manner, with the biggest effect being on the spot price. It can also % TODO reference clewlow strickland for SDE of spot price\nbe interpreted as driving random shocks to the spot price which then mean revert.\n\nAs mentioned above the remaining two factors have zero mean reversion, i.e. \n$\\alpha_2 = \\alpha_3 = 0$. TODO seasonal factor \n\nThe third factor, the long-term factor, has constant volatility, $\\sigma_2 = \\sigma_{long}$,\nand represents parallel movement which effect the whole forward curve in a maturity \nindependent manner.\n\nFinally, it is assumed that the three Brownian Motions are independent. Putting this \ntogether, and using the subscripts $spot$, $seas$ and $long$ the Brownian Motions\nof the spot, seasonal, and long-term factors we get the following.\n\n\\begin{equation}\n    \\frac{dF(t, T)}{F(t, T)}= \\sigma_{spot} e^{-\\alpha(T - t)} dz_{spot}(t) + \\\\\n        \\sigma_{seas}(T) dz_{seas}(t) + \\sigma_{long} dz_{long}(t)\n\\end{equation}\n\nRefer back to \\cite{Fowler} for the statistical properties of the forward and spot\nprice assumed by just substituting the parameters in \\cite{Fowler} with the specific\none given above.\n\n\\section{Critique of Three Factor Seasonal Model}\nThe strength of the three-factor seasonal model is it's parsimony. \nBeing able to specify the gas price dynamics using only four parameters is of great help\nin allowing users to intuitively see what is driving the extrinsic value of gas storage\nbeing valued. Traders can easily adjust the input\nparameters based on their view of the market. For example if a trader take a view that \nthe future summer-winter spread volatility is going to be higher than in the historical\nperiod used to calibrate the parameters they can easily bump up the seasonal volatility\nparameter when valuing a potential storage deal. For a non-parsimonious model with many parameters\nsome of which are completely abstract (for example correlation between factors), such\nusage would not be practical.\n\nAnother example of the is that risk managers can \ncreate scenario matrices containing storage facility (or portfolio) P\\&L based on scenarios \napplied to any of the four parameters. \n\n% Quote Taleb and compare to Black-Scholes as a parameterisation?\n\nIt also allows for a relatively simple and intuitive way of calibrating\nmodel parameters from historic spot and forward prices. This is of particular importance\nfor gas storage where there is generally a lack of liquid traded instruments which can be used\nto calibrate model volatility and correlation parameters to\n\\footnote[1]{For many natural gas markets, there are European options traded, for which the\nimplied volatility can be used to calibrate price dynamics. However, the extrinsic value\nof storage is mostly derived from the relative movement of different delivery points\non the forward curve, i.e. by calendar spreads. The European option volatility curve\ndoes convey some information about calendar spread volatility (e.g. a big difference\nin implied vol for two forward contracts implies that one contract will move by much\nmore than another, hence higher calendar spread volatility) but not enough to fully \ncalibrate the joint price dynamics of the whole forward curve.}.\n\n% TODO cite other Kyos paper\nThe KyStore product is clearly a popular one and The Author believes that this is at least partially due \nto the parsimony of the underlying price process model.\n\n\\bigskip\nThe big downside of this model is that the forward volatility seasonality structure is unrealistic.\nIt is well known that, adjusting for time-to-maturity effects, the volatility of winter periods \nwill generally be higher than those in summer. Figure \\ref{fig:seasonal_vol} plots the forward\nvolatility implied by the model, with mean reversion set to zero in order to remove any t\ntime-to-maturity effect. This chart shows that the model implies two volatility peaks a\nyear, once in February, as expected, but the other around August.\n\n\\begin{figure}\n    \\includegraphics{vol_seasonality.png}\n    \\caption{Forward Volatility By Delivery Date}\n    \\label{fig:seasonal_vol}\n\\end{figure}\n\n\n\\bibliographystyle{plainnat}\n\\bibliography{three_factor_seasonal_model}\n\n\\end{document}", "meta": {"hexsha": "3f95e9f530bb96f0efb1ec424ac296ee501b719a", "size": 6396, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/three_factor_seasonal_model/three_factor_seasonal_model.tex", "max_stars_repo_name": "dtrader007/core", "max_stars_repo_head_hexsha": "a9bad1847c5d861eaa794df12d465af61cae6259", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-11-27T05:09:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-08T13:36:33.000Z", "max_issues_repo_path": "docs/three_factor_seasonal_model/three_factor_seasonal_model.tex", "max_issues_repo_name": "dtrader007/core", "max_issues_repo_head_hexsha": "a9bad1847c5d861eaa794df12d465af61cae6259", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/three_factor_seasonal_model/three_factor_seasonal_model.tex", "max_forks_repo_name": "dtrader007/core", "max_forks_repo_head_hexsha": "a9bad1847c5d861eaa794df12d465af61cae6259", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-20T10:53:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-30T13:46:51.000Z", "avg_line_length": 45.0422535211, "max_line_length": 144, "alphanum_fraction": 0.7667292058, "num_tokens": 1648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529716, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.42194651172724273}}
{"text": "\\documentclass[11pt,oneside,a4paper]{article}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{stmaryrd}\n\\usepackage{listings}\n\n\\lstset{\n  language = Java,\n  breaklines = true,\n  captionpos = b,\n  basicstyle = \\footnotesize,\n  frame = leftline,\n  morekeywords = {skip,then},\n}\n\n\\newenvironment{changemargin}[2]{%\n\\begin{list}{}{%\n\\setlength{\\topsep}{0pt}%\n\\setlength{\\leftmargin}{#1}% \\setlength{\\rightmargin}{#2}%\n\\setlength{\\listparindent}{\\parindent}%\n\\setlength{\\itemindent}{\\parindent}%\n\\setlength{\\parsep}{\\parskip}%\n}%\n\\item[]}{\\end{list}}\n\n\\newcommand{\\SExp}[2]{\\mathcal{#1}\\llbracket #2 \\rrbracket}\n\\newcommand{\\AExp}[2]{\\SExp{A}{#1}(#2)}\n\\newcommand{\\BExp}[2]{\\SExp{B}{#1}(#2)}\n\\newcommand{\\AMIns}[1]{\\textsc{#1}}\n\\newcommand{\\AMConf}[3]{\\langle #1, #2, #3 \\rangle}\n\\newcommand{\\AMArrow}{\\: &\\triangleright&\\:\\;}\n\\newcommand{\\sign}{\\textbf{Sign}_{\\bot}}\n\\newcommand{\\TT}{\\textbf{TT}_{\\bot}}\n\\newcommand{\\abs}[2]{\\textbf{abs}_{\\,#1_{\\bot}} #2 }\n\\begin{document}\n\\title{Report for Lab Assignment 2, DD2457 Program Semantics and Analysis}\n\\author{Erik Helin \\& Oskar Arvidsson}\n\\date{\\today}\n\\maketitle\n\\section*{Operational semantics for AM}\n\\begin{align*}\n&\\AMConf{\\AMIns{push-}n:c}{e}{s} \\AMArrow \n \\AMConf{c}{\\abs{Z}{\\SExp{N}{n}}:e}{s} \\\\\n&\\AMConf{\\AMIns{add}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 +_{SE} v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{sub}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 -_{SE} v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{mul}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 \\star_{SE} v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{div}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 \\: /_{SE}\\: v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{true}:c}{e}{s} \\AMArrow\n \\AMConf{c}{\\abs{T}{\\textbf{tt}}:e}{s}& \\\\\n&\\AMConf{\\AMIns{false}:c}{e}{s} \\AMArrow\n \\AMConf{c}{\\abs{T}{\\textbf{ff}}:e}{s}& \\\\\n&\\AMConf{\\AMIns{eq}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 =_{SE} v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{le}:c}{v_1:v_2:e}{s} \\AMArrow\n \\AMConf{c}{v_1 \\leq_{SE} v_2:e}{s}& \\text{ if } v_1, v_2 \\in \\:& \\sign \\\\\n&\\AMConf{\\AMIns{and}:c}{t_1:t_2:e}{s} \\AMArrow\n \\AMConf{c}{t_1 \\land_{SE} t_2:e}{s}& \\text{ if } t_1, t_2 \\in \\:& \\TT \\\\\n&\\AMConf{\\AMIns{neg}:c}{t_1:t_2:e}{s} \\AMArrow\n \\AMConf{c}{t_1 \\: \\neg_{SE}\\: t_2:e}{s}& \\text{ if } t_1, t_2 \\in \\:& \\TT \\\\\n&\\AMConf{\\AMIns{fetch-}x:c}{e}{s} \\AMArrow \n \\AMConf{c}{(s\\;x):e}{s} \\\\\n&\\AMConf{\\AMIns{store-}x:c}{v:e}{s} \\AMArrow\n \\begin{cases}\n    \\AMConf{c}{e}{s[x \\mapsto v]} & \\text{ if } v \\sqsubseteq_{SE} Z \\\\\n    \\AMConf{c}{e}{\\hat{s}} & \\text{ if } ERR_A \\sqsubseteq_{SE} v \\\\\n    \\AMConf{c}{e}{s[x \\mapsto v \\underset{SE}{\\sqcap} Z]} & \n    \\text{ if } Z \\sqsubseteq_{SE} v \\\\\n \\end{cases}& \\\\\n&\\AMConf{\\AMIns{noop}:c}{e}{s} \\AMArrow \n \\AMConf{c}{e}{s} \\\\\n&\\AMConf{\\AMIns{branch}(c_1,c_2):c}{v:e}{s} \\AMArrow\n \\begin{cases}\n    \\AMConf{c_1:c}{e}{s} & \\text{ if } TT \\sqsubseteq_{TE} v \\\\\n    \\AMConf{c_2:c}{e}{s} & \\text{ if } FF \\sqsubseteq_{TE} v \\\\\n    \\AMConf{c}{e}{\\hat{s}} & \\text{ if } ERR_B \\sqsubseteq_{TE} v \\\\\n \\end{cases}& \\\\\n&\\AMConf{\\AMIns{loop}(c_1,c_2):c}{e}{s} \\AMArrow \n \\AMConf{c_1:\\AMIns{branch}(c_2:\\AMIns{loop}(c_1, c_2), \\AMIns{noop}):c}{e}{s}\\\\\n&\\AMConf{\\AMIns{try}(c_1, c_2):c}{e}{s} \\AMArrow\n \\AMConf{c_1:\\AMIns{catch}(c_2):c}{e}{s}& \\\\\n&\\AMConf{\\AMIns{catch}(c_1):c}{e}{s} \\AMArrow\n \\AMConf{c}{e}{s}& \\\\\n&\\AMConf{\\AMIns{catch}(c_1):c}{e}{\\hat{s}} \\AMArrow\n \\AMConf{c_1:c}{e}{s}& \\\\\n&\\AMConf{c_1:c}{e}{\\hat{s}} \\AMArrow \\AMConf{c}{e}{\\hat{s}}\n\\end{align*}\nIn the rule for \\textsc{store}, \\(\\underset{SE}{\\sqcap}\\) means the greatest \nlower bound in the \\(\\sign\\) lattice.\nNote that, in the rule for \\textsc{store}, if \\(x\\) equals \\(Z\\), the \nconfiguration returned from the first and third case will be equivalent.\nTherefore the result becomes only one configuration. Also note that\n\\textsc{store} and \\textsc{branch} are the only nondeterministic rules.\n\n\\section*{Analysis}\n  Under the right conditions the analysis is able to show a number of\n  interesting features of the analysed program, such as:\n\n  \\begin{description}\n    \\item[Variables values] Features of the variables values in the\n      configuration states throughout the program. E.g.\\ a variable may always\n      be positive at a control point in the program.\n    \\item[Exceptional states] Control points where an exception may occur.\n    \\item[Unreachable code] Control points in the program that cannot be\n      reached in the given context.\n    \\item[Unneeded try-catch constructs] For example if an exceptional state\n      impossibly can occur in a try block.\n    \\item[Termination] The analysis can tell if the program will terminate\n      normally if it terminates or if the termination may be exceptional. In\n      some cases the analysis is able to tell that the program won't terminate.\n  \\end{description}\n\n  \\subsection*{Examples}\n    Below follows a number of results obtained from the analysis.\n\n    \\subsubsection*{Infinite looping}\n      In listing \\ref{lst:inf} the analysis is able to capture that the program\n      won't terminate. If the line $y := y - 1$ had been interchanged with $y\n      := y + 1$ though, the analysis wouldn't have catched this although the\n      program wouldn't have terminated in this case either.\n\n      \\lstinputlisting[\n        caption={Analysis of a non-terminating program},\n        label=lst:inf]{analysis/infinite.analysis}\n\n    \\subsubsection*{Catch}\n      In listing \\ref{lst:catch-1} the analysis comes to the result that the\n      catch block is unneeded. Correspondingly, in listing \\ref{lst:catch-2}\n      the analysis discovers that the program will always go through the catch\n      block.\n\n      \\lstinputlisting[\n        caption={Analysis of a program with an unneeded catch block},\n        label=lst:catch-1]{analysis/unneeded_catch.analysis}\n\n      \\lstinputlisting[\n        caption={Analysis of a program where the catch block is always reached},\n        label=lst:catch-2]{analysis/always_catch.analysis}\n\n\\section*{Discussion}\n  Alas, the analysis is not very good for all but very simple programs. For\n  example, in the program given below $x$ is clearly evaluated to $0$, but the\n  analysis will evaluate it to a non error value -- that is either positive,\n  negative or zero which is pretty much useless for further analysis.\n\n  \\[\n    x := 5-5\n  \\]\n\n  A better analysis for example given above is pretty easy to incorporate in\n  the analyzer. For a better analysis it would be useful with more discrete\n  possible values. Many loops operate over quite small ranges of integer\n  values, e.g.\\ $x \\in [0,255]$. It would be quite easy to add more discrete\n  values to the analyzer although the analyzing process would take more time.\n\n  Another example of a feature that's missing in the analyzer is that simple\n  conditions that always hold are not captured. For example, in listing\n  \\ref{lst:invariant}, $x > y$ always holds. Thus the else block will never be\n  executed, but the analyzer will not capture this.\n\n  \\begin{lstlisting}[\n      caption={A program where $y > x$ always holds},\n      label=lst:invariant,\n      gobble=4\n    ]\n    x := 0 ;\n    y := 2 ;\n    i := 0 ;\n\n    (while i <= 10 do\n      x := x + 1 ;\n      y := y + 1 ;\n      i := i + 1\n    ) ;\n\n    if x <= y then\n      x := 0\n    else\n      x := 1\n  \\end{lstlisting}\n\n\\end{document}\n", "meta": {"hexsha": "942fd3dca8e2dead719e2055883ffc9fe491f435", "size": 7405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/report2.tex", "max_stars_repo_name": "edvbld/wham", "max_stars_repo_head_hexsha": "4ee1c8dbe968f659bb084f5cacc90e66480f9bf8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/report2.tex", "max_issues_repo_name": "edvbld/wham", "max_issues_repo_head_hexsha": "4ee1c8dbe968f659bb084f5cacc90e66480f9bf8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/report2.tex", "max_forks_repo_name": "edvbld/wham", "max_forks_repo_head_hexsha": "4ee1c8dbe968f659bb084f5cacc90e66480f9bf8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.811827957, "max_line_length": 80, "alphanum_fraction": 0.6538825118, "num_tokens": 2610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4219465117272427}}
{"text": "\\documentclass{discussion}\n\n\\usepackage{framed}\n\\usepackage[position=b]{subcaption}\n\\DeclareMathOperator{\\Parents}{Parents}\n\\DeclareMathOperator{\\NonDesc}{NonDesc}\n\\newcommand{\\G}{\\mathcal{G}}\n\\newcommand{\\I}{\\mathcal{I}}\n\\linespread{1.0}\n\\begin{document}\n\n% Lecture Info\n\\lecture{9}{Explaining Away}{Benjamin R. Bray and Chansoo Lee}\n\n\n%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Probabilistic influence}\n\nRecall the HW5 Problem 3. \n\n\\begin{lemma} \n\\(P(t_1 | d_1) < P(t_1 | d_0)\\)\n\\end{lemma}\nIntuitively, this statement is kind of obvious. The person is on good diet $(d_1)$ should be less likely to test for high cholesterol $(t_1)$\n\\begin{proof}\nFrom the factorization theorem, $T$ is independent of all variables other than $C$ given $D$. So, \n\\begin{equation}\n\\label{eq:t_d_ind}\n\tP(T | D, u) = P(T | D)\n\\end{equation} for all values of $u$.\n\nNow from the definition, we have that\n\\begin{equation}\n\tP(c_1 | d_1) < P(c_1 | d_0)\n\\end{equation}\nmeaning people with good diet is less likely to have a high cholesterol than those with bad diet. We were able to eliminate the conditioning on $u$ because of \\eqref{eq:t_d_ind}.\nSimilarly,\n\\[P(t_1 | c_1) > P(t_1 | c_0).\\]\n\nBecause $T$ and $D$ are independent given $C$, we can write\n\\[P(T | D) = \\sum_{c} P(T, C = c | D) = \\sum_{c} P(T| C = c) P(C = c | D).\n\\]\n\nNow,\n\\[\nP(t_1 | d_1) = P(t_1 | c_1) P(c_1 | d_1) +P(t_1 | c_0) P(c_0 | d_1)\n\\] \nand\n\\[P(t_1 | d_0) = P(t_1 | c_1) P(c_1 | d_0)\n+P(t_1 | c_0) P(c_0 | d_0)\n\\]\n\nWe compute the difference:\n\\begin{align*}\nP(t_1 | d_0) - P(t_1 | d_1) \n&= P(t_1 | c_1) (P(c_1 | d_0) - P(c_1 | d_1))\n+ P(t_1 | c_0) (P(c_0 | d_0) - P(c_0 | d_1)) \\\\\n&= P(t_1 | c_1) (P(c_1 | d_0) - P(c_1 | d_1))\n+ P(t_1 | c_0) \\big(1 - P(c_1 | d_0) - (1 - P(c_1 | d_1))\\big) \\\\\n& = \\big(P(t_1 | c_1) - P(t_1 | c_0)\\big) \\big(P(c_1 | d_0) - P(c_1 | d_1)\\big)\n\\end{align*}\nwhich is positive because both terms in the parentheses are positive.\n\\end{proof}\n\n\\begin{corollary}\n\\[\tP(t_1 | d_1) < P(t_1)\\]\n\\end{corollary}\n\\begin{proof}\n\tNote that \n\t\\[P(t_1) = P(t_1 | d_1) p(d_1) + p(t_1 | d_0) p(d_0) > P(t_1 | d_1) p(d_1) + p(t_1 | d_1) p(d_0) = P(t_1 | d_1)\\qedhere\\]\n\\end{proof}\n\n% \\begin{lemma}\n% \\[\tP(d_1 | e_1, m_1) < P(d_1 | m_1)\\]\n% \\end{lemma}\n% \\begin{proof}\n% \\[\tP(d_1 | e_1, m_1)\n%  = P(m_1 | d_1, e_1) P(d_1) / P(m_1)\n%  > P(m_1 | d_1, e_0) P(d_1) / P(m_1)\n%  = P(d_1 | e_0, m_1).\n% \\]\n% So,\n% \\[P(d_1 | m_1) = P(d_1 | m_1, e_0) P(e_0) + P(d_1 | m_1, e_1)P(e_1) < P(d_1 | m_1, e_1) P(e_0) + P(d_1 | m_1, e_1)P(e_1) = P(d_1 | m_1,e_1)\\]\n% \\end{proof}\n\n\\section{Explaining Away}\nThe explaining away is the following phenomenon:\n\\begin{equation}\n\\label{eq:explainaway}\n\tP(h_1 | b_0, e_1) < P(h_1 | b_1, e_1).\n\\end{equation}\nIt follows that\n\\[P(h_1 | b_0, e_1) < P(h_1 | e_1)< P(h_1 | b_1, e_1).\\]\nLet's explore the sufficient and necessary condition for this to happen.\n\nBy the Bayes rule,\n\\[P(h_1 | e_1, B) = P(e_1 | h_1, B) \\frac{P(h_1 | B)}{P(e_1 | B)} = P(e_1 | h_1, B) \\frac{P(h_1)}{P(e_1 | B)}\\]\nsince $H$ and $B$ are independent.\n\n\n%  \\eqref{eq:explainaway} is equivalent to \t\n% \\[\\frac{P(e_1 | h_1, b_0)}{P(e_1 | b_0)} < \\frac{P(e_1 | h_1, b_1)}{P(e_1 | b_1)}\t\\]\n% which is also equivalent to\n% \\begin{equation}\n% \\label{eq:explainaway_ratio}\n% \\frac{P(e_1 | b_0)}{P(e_1 | h_1, b_0)} > \\frac{P(e_1 | b_1)}{P(e_1 | h_1, b_1)}\n% \\end{equation}\n\nNote that\n\\[P(e_1 | B) = P(e_1 | h_1, B)P(h_1) + P(e_1 | h_0, B)P(h_0)\\]\n\nSo, \n\\[\\frac{1}{P(h_1|e_1,B)}\n= 1 + \\frac{P(e_1 | h_0, B)P(h_0)}{P(e_1|h_1,B)P(h_1)}\\]\n\nHence, an equivalent statement of \\eqref{eq:explainaway}\n\\[\t1/P(h_1 | b_0, e_1) > 1/P(h_1 | b_1, e_1)\n\\]\nis equivalent to \n\\[1 + \\frac{P(e_1 | h_0, b_0)P(h_0)}{P(e_1|h_1,b_0)P(h_1)} > 1 + \\frac{P(e_1 | h_0, b_1)P(h_0)}{P(e_1|h_1,b_1)P(h_1)}\n\\]\nwhich simplifies to\n\\[\\frac{P(e_1 | h_0, b_0)}{P(e_1|h_1,b_0)} > \\frac{P(e_1 | h_0, b_1)}{P(e_1|h_1,b_1)}.\\]\n% and similarly,\n% \\[P(e_1 | b_1) = P(e_1 | h_1, b_1)P(h_1) + P(e_1 | h_0, b_1)P(h_0)\\]\n\nFinally, we rearrange this:\n\\begin{equation}\n\\label{eq:explainaway_condition}\n\t\\frac{P(e_1 | h_0, b_0)}{P(e_1 | h_0, b_1)} > \\frac{P(e_1|h_1,b_0)}{P(e_1|h_1,b_1)}.\n\\end{equation}\n\nSo, the time constraint has more dramatic effect on the people that are not health-conscious. Health-conscious people are less likely to exercise if they are busy, but this probability drop is much less severe because they try to make time for exercise.\n\n\\begin{exercise}\n\tGive a realistic example where \\eqref{eq:explainaway_condition} fails to hold.\n\\end{exercise}\n\n\\paragraph{Answer.}\tIn the same graphical structure as $H,E,B$ but replace $H$ with horrible weather, $B$ with road block (due to construction) and $E$ with extremely long commute. \n\n\tSuppose the road can't handle traffic given either of the bad conditions. The difference between $P(e_1| h_0, b_0)$ and $P(e_1 | h_0, b_1)$ is big, making the LHS small. But if the road is already hit with horrible weather, then the additional effect of road block is small, so the RHS is big.\n\n\\end{document}\n", "meta": {"hexsha": "016079652cbd19f368a7a2b7b8ac09db8532ad6c", "size": 5030, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "discussion09-explain-away/discussion09-draft2.tex", "max_stars_repo_name": "xipengwang/umich-eecs445-f16", "max_stars_repo_head_hexsha": "298407af9fd417c1b6daa6127b17cb2c34c2c772", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 97, "max_stars_repo_stars_event_min_datetime": "2016-09-11T23:15:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T08:03:24.000Z", "max_issues_repo_path": "discussion09-explain-away/discussion09-draft2.tex", "max_issues_repo_name": "eecs445-f16/umich-eecs445-f16", "max_issues_repo_head_hexsha": "298407af9fd417c1b6daa6127b17cb2c34c2c772", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "discussion09-explain-away/discussion09-draft2.tex", "max_forks_repo_name": "eecs445-f16/umich-eecs445-f16", "max_forks_repo_head_hexsha": "298407af9fd417c1b6daa6127b17cb2c34c2c772", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 77, "max_forks_repo_forks_event_min_datetime": "2016-09-12T20:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-03T14:41:23.000Z", "avg_line_length": 34.9305555556, "max_line_length": 294, "alphanum_fraction": 0.6290258449, "num_tokens": 2177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7662936324115012, "lm_q1q2_score": 0.42192691816852657}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{II}\n\n\\def\\ntitle{Dynamical Systems}\n\\def\\nlecturer{J.\\ R.\\ Lister}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2017}\n\n\\input{header}\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\section{Stability}\n\nIt is clear what we mean by \\emph{hyperbolic nodel focii} begin stable/unstable. We need to be more careful with other kinds of fixed points or other invariant sets because there are at least two distinct types of stabilities, i.e. saddle and centre.\n\n\\subsection{Definitions}\n\nConsider a flow \\(\\phi_t(x)\\),\n\\begin{definition}[Lyapunov Stability]\n A fixed point \\(x_0\\) is \\emph{Lyapunov stable} if \\(\\forall\\varepsilon>0, \\exists\\delta>0\\) such that\n\\[\n  |\\phi_t(x)-x_0| < \\varepsilon \\, \\forall t>0.\n\\]\n\\end{definition}\n\n\\begin{slogan}\n  If it starts near, it stays near.\n\\end{slogan}\n\n\\begin{definition}[Quasi-asymptotic stability]\n  A fixed point \\(x_0\\) is \\emph{quasi-symptotically stable} if for all \\(\\varepsilon>0\\) such that \\(|x-x_0|<\\delta\\) imples that \\(\\phi(x)\\to x_0\\) as \\(t\\to \\infty\\).\n\\end{definition}\n\n\\begin{slogan}\n  It tends to the fixed point eventually.\n\\end{slogan}\n\n\\begin{eg}\\leavevmode\n  \\begin{itemize}\n  \\item \\(\\dot r = 0, dot \\theta = 1\\): \\(\\V 0\\) is Lyapunov stable (take \\(\\varepsilon = \\delta\\)) but not quasi-asymptotic stable.\n  \\item \\(\\dot r = r(a-r^2), \\dot \\theta = \\sin^2(\\theta/2)\\): \\(\\theta=0,r=1\\) is quasi-aymptotically stable but not Lyapunov stable.\n  \\end{itemize}\n\\end{eg}\n    \n\\begin{definition}[Asymptotic stability]\n  A fixed piont \\(x_0\\) is \\emph{asymptotically stable} if it is both Lyapunov stable and quasi-asymptotically stable.\n\\end{definition}\n\n\\begin{eg}\n  A sink (all \\(\\lambda_i\\) have \\(\\Re \\lambda_i<0\\)) is asymptotically stable (just take \\(\\delta\\) small that the linear terms dominate), and clearly sources/saddles are not Lyapunov stable.\n\\end{eg}\n\nTo describe the stability of other invariant sets \\(\\Lambda\\) we define\n\\[\n  N_\\delta(\\Lambda) := \\{x: \\exists y\\in\\Lambda, |x-y|<\\delta \\}\n\\]\nand say \\(\\phi_t(x)\\to \\Lambda\\) if\n\\[\n  \\inf_{y\\in \\Lambda}\\{|\\phi_t(x)-y|\\}\\to 0 \\text{ as } t\\to \\infty.\n\\]\n\n\\begin{definition}[Stability for an invariant set]\n  \\(\\Lambda\\) is Lyapunov stable if for all \\(\\varepsilon>0\\) exists \\(\\delta>0\\) such that \\(x\\in N_\\varepsilon(\\Lambda)\\), \\(\\phi_t(x) \\in N_\\varepsilon(\\Lambda)\\) for all \\(t>0\\).\n\n  \\(\\Lambda\\) is quasi-asymptotically stable if exists \\(\\delta>0\\) such that \\(x\\in N_\\delta(\\Lambda)\\) such that \\(\\phi_t(x)\\to \\Lambda\\) as \\(t\\to \\infty\\).\n\n  \\(\\Lambda\\) is aymptotically stable if it is both Lyapunov and quasi-asymptotically stable.\n\\end{definition}\n\n\\subsection{Lyapunov Functions}\n\nLyapounov functions allow us to say more about the stability of a fixed point which, without loss of generality, we may take to be at \\(x=0\\).\n\n\\begin{definition}[Lyapunov function]\n  A continuously differentiable function \\(V:\\R^n\\to \\R\\) is a \\emph{Lyapunov function} for \\(\\dot{x} = f(x)\\) on a domain \\(D\\) containing \\(\\V 0\\) if it is\n  \\begin{itemize}\n  \\item positive-definite: \\(V(\\V 0) = 0\\) and \\(V(x) >0\\) for all \\(x\\neq 0\\) in \\(D\\). Informally, \\(\\V 0\\) is the lowest point.\n  \\item non-increasing: \\(\\dot{V} = f\\cdot\\nabla V \\leq 0\\) for all \\(x\\in D\\). Informally, it means all trajectories in \\(D\\) head ``downhill'' or level, but never ``uphill''.\n  \\end{itemize}\n\\end{definition}\n\nThese properties allow us to prove\n\n\\begin{theorem}[Lyapunov's First Theorem]\n  If a Lyapunov function exists then \\(x=0\\) is Lyaponov stable.\n\\end{theorem}\n\n\\begin{proof}\n  Wlog assume \\(\\varepsilon\\) is sufficiently small that \\(\\{|x|\\leq\\varepsilon\\} \\subset D\\). Let\n  \\[\n    m = \\inf \\{V(x): |x| = \\varepsilon\\}.\n  \\]\n  Since \\(|x|=\\varepsilon\\) is compact, the infimum is attained and by the first property above, \\(m>0\\).\n\n  Let \\(C_{m,\\varepsilon} = \\{x: V(x)<m, |x| < \\varepsilon \\}\\). Then for all \\(x\\in C_{m,\\varepsilon}\\), \\(\\phi_t(x) \\in C_{m,\\varepsilon}\\) for all \\(t>0\\) as \\(V\\geq m\\) on the boundary.\n\n  Choose \\(\\delta\\) such that \\(\\{|x|< \\delta\\} \\subseteq C_{m,\\varepsilon}\\).\n\\end{proof}\n\nNote that a trajectory can head ``downhill'' and not end up at \\(x=0\\). But there is a very important constraint:\n\n\\begin{theorem}[La Salle's Invariance Principle]\n  If \\(V\\) is a Lyapunov function on a bounded domain \\(D\\) and \\(\\mathcal O^+(x) \\subseteq D\\), then \\(\\phi_t(x)\\) tends to an \\emph{invariant} subset of \\(\\{x: \\dot{V} = 0\\} \\cap D\\).\n\\end{theorem}\n\n\\begin{proof}\n  \\(V(\\phi_t(x))\\) is monotonically decreasing and bounded below by \\(0\\). Therefore \\(V\\to \\alpha\\) for some \\(\\alpha\\geq0\\). \\(D\\) is compact so the limit set \\(\\omega(x)\\) is non-empty. \\(\\forall y\\in \\omega(x)\\), \\(\\exists\\{t_n\\}\\) such that \\(\\phi_{t_n}(x)\\to y\\) so \\(V(y) = \\alpha\\) by continuity of \\(V\\). So \\(V(\\phi_t(y))=\\alpha\\) as \\(\\phi_t(y)\\in \\omega(x)\\). Thus \\(\\dot{V}(y) = 0\\) for all \\(y\\in\\omega(x)\\).\n\n  Hence \\(\\omega(x) \\subseteq \\{ \\dot{V} = 0\\}\\) and \\(\\omega(x)\\) is invariant (c.f. section 1.4).\n\\end{proof}\n\n\\begin{corollary}\n  If \\(V\\) is a Lyapunov function on a domain \\(D\\) and the only invariant subset of \\(\\{\\dot{V}=0\\}\\) is \\(\\{\\V 0\\}\\) then \\(x=0\\) is aymptotically stable.\n\\end{corollary}\n\n\\end{document}", "meta": {"hexsha": "95462e73c6bfda38aa5b15b32d5d86916f759b7a", "size": 5184, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "II/dynamical_systems.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "II/dynamical_systems.tex", "max_issues_repo_name": "b-mehta/tripos", "max_issues_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "II/dynamical_systems.tex", "max_forks_repo_name": "b-mehta/tripos", "max_forks_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 42.8429752066, "max_line_length": 422, "alphanum_fraction": 0.6624228395, "num_tokens": 1811, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.42192691816852645}}
{"text": "% ---\n% title: Phase and the Hilbert Transform\n% description: A remix of my 2014 TLE tutorial on computing phase responses and\n%   how to use them\n% short_title: Phase and the Hilbert Transform\n% authors:\n%   - name: Steve Purves\n%     affiliation: curvenote\n%     location: La Orotava, Spain\n%     curvenote: https://curvenote.com/@stevejpurves\n%     is_corresponding: false\n% date:\n%   year: 2020\n%   month: 9\n%   day: 8\n% tags:\n%   - tutorial\n%   - exploration\n%   - seismic-attributes\n%   - phase\n%   - python\n% oxalink: https://curvenote.com/oxa:RkW3EUemHJbWfgejvqYu/BAflQTB9BBGlfSVT40RN.53\n% jtex:\n%   version: 1\n%   template: null\n%   strict: false\n%   input:\n%     references: main.bib\n%     tagged: {}\n%   output:\n%     path: _build\n%     filename: main.tex\n%     copy_images: true\n%     single_file: false\n%   options: {}\n% ---\n\n%% https://curvenote.com/oxa:RkW3EUemHJbWfgejvqYu/j4p2ktrUnpNLTYJxNZAq.5\n\nPhase is a useful underlying property of the analytic trace model of seismic data that can be used as both an interpretation aid and a means to calibrate and check interpretations on a given seismic dataset. We introduce the analytical trace model and demonstrate some of its usages. We provide working code in python for computation of the Hilbert Transform using a robust FFT-based method and explore 2 use cases for such computed quantities. Jupyter notebooks used for computation and generation of the figures are included in this project.\n\n%% https://curvenote.com/oxa:RkW3EUemHJbWfgejvqYu/nxoOOSUIjwn60BZbKluN.15\n\n\\subsection*{Introduction}\n\nThe concept of phase permeates seismic data processing and signal processing in general, but it can be awkward to understand, and manipulating it directly can lead to surprising results. It doesn't help that the word phase is used to mean a variety of things, depending on whether we refer to the propagating wavelet, the observed wavelet, post-stack seismic attributes, or an entire seismic data set. Several publications have discussed the concepts and ambiguities \\citep{Roden1999significance, Liner2002Phase, 2002Tutorial}.\n\n%% https://curvenote.com/oxa:RkW3EUemHJbWfgejvqYu/ihBcaiMuiszbc8xSI8bd.20\n\n\\begin{figure}[!htbp]\n  \\centering\n  \\includegraphics[width=0.7\\linewidth]{images/RkW3EUemHJbWfgejvqYu-ihBcaiMuiszbc8xSI8bd-v20.png}\n\n  \\caption*{\n\n  }\n\\end{figure}", "meta": {"hexsha": "4ac6cb429d1139d4dba4be1150b078d0ab42ae60", "size": 2329, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "jtex/tests/data/content.tex", "max_stars_repo_name": "datalayer-externals/curvenote-jtex", "max_stars_repo_head_hexsha": "2778c9fc51cd2cbbe8d4b7deedd637e9dd59f662", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2021-11-08T14:49:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T10:16:51.000Z", "max_issues_repo_path": "jtex/tests/data/content.tex", "max_issues_repo_name": "datalayer-externals/curvenote-jtex", "max_issues_repo_head_hexsha": "2778c9fc51cd2cbbe8d4b7deedd637e9dd59f662", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2021-11-08T14:36:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T22:19:23.000Z", "max_forks_repo_path": "jtex/tests/data/content.tex", "max_forks_repo_name": "datalayer-externals/curvenote-jtex", "max_forks_repo_head_hexsha": "2778c9fc51cd2cbbe8d4b7deedd637e9dd59f662", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-08T14:11:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T10:11:00.000Z", "avg_line_length": 40.8596491228, "max_line_length": 543, "alphanum_fraction": 0.7552597681, "num_tokens": 710, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4219191832223291}}
{"text": "\\subsection{Example \\#2: dependence model between two time series}\n\\label{S:ExampleDispTemp}\n\n\\subsubsection{Data description}\n\nThis example uses two synthetic time series that mimics the displacement and temperature data measured on a bridge.\nThe  Figure~\\ref{fig:DataSummaryRaw2}a shows that data points exist between August 2013 and October 2015.\nThe timestep in the original data is non-uniform; it varies from 1 hour to 25 hours (see Figure~\\ref{fig:DataSummaryRaw2}b). \nThe timestep vector is not identical on each time series. \nIt means that the time series are not synchronized between each other.\nThe most frequent (i.e referent) time step is 1 hour for both time series (Section~\\ref{SS:NonUniform}).\nThere is no missing data (\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!NaN!) on the displacement time series, but there are missing data on the temperature time series as indicated by the red crosses on the Figure~\\ref{fig:DataSummaryRaw2}c.\nEach red cross indicates the presence of a Not a Number (\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!NaN!) value in the time series.\nAfter data synchronization, the time step vectors are identical on each time series (Figure~\\ref{fig:DataSummaryDefaultPreProcessed2}).\nBoth time series are stationary, and they exhibit a level, a yearly and daily periodic pattern as well as an autoregressive pattern.\nThe periodic patterns observed on the displacement time series is due to the temperature variations observed in the temperature time series.\n\nIn this example, we choose to resample the original data in order to have timesteps of 6h instead of 1h. \n\n\\begin{figure*}[h!]\n\\centering\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/raw/ALL_AMPLITUDES.pdf} \n\\caption{Amplitude}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/raw/ALL_TIMESTEPS.pdf}\n\\caption{Timestep}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/raw/AVAILABILITY.pdf}\n\\caption{Availability}\n\\end{subfigure}\n\\caption{Raw data in the example \\#2 where the reference timestep is 1h.}\n\\label{fig:DataSummaryRaw2}\n\\end{figure*}\n\n\n\\begin{figure*}[h!]\n\\centering\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/preprocessed_default/ALL_AMPLITUDES.pdf} \n\\caption{Amplitude}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/preprocessed_default/ALL_TIMESTEPS.pdf}\n\\caption{Timestep}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/preprocessed_default/AVAILABILITY.pdf}\n\\caption{Availability}\n\\end{subfigure}\n\\caption{Data used in example \\#2 after resampling to obtain a reference timestep of 6h.}\n\\label{fig:DataSummaryDefaultPreProcessed2}\n\\end{figure*}\n\n\n\n\\subsubsection{Model description}\n\\label{SS:ModelConstructionExample2}\n\nThe model includes one model class, and the hidden state variables are \n\\begin{gather*}\n\\textbf{x}=[x^{\\mathtt{LL}}_{\\mathtt{D}}, x^{\\mathtt{AR}}_{\\mathtt{D}}, x^{\\mathtt{LL}}_{\\mathtt{T}}, x^{\\mathtt{P1}\\text{,yearly}}_{\\mathtt{T}}, x^{\\mathtt{P2}\\text{,yearly}}_{\\mathtt{T}}, x^{\\mathtt{P1}\\text{,daily}}_{\\mathtt{T}} , x^{\\mathtt{P2}\\text{,daily}}_{T}, x^{\\mathtt{AR}}_{\\mathtt{T}}],\n\\end{gather*}\nwhere $\\mathtt{D}$ and $\\mathtt{T}$ refer to the displacement and temperature time series, respectively.\nThe periodic patterns observed on the displacement are considered through a dependency of the displacement on the hidden state variables of the periodic  and autoregressive components of the temperature time series (Section~\\ref{S:Dependencies}).\nThe associated model parameters are\n\\begin{align*}\n\\bm\\theta & =[\\sigma_{w, \\mathtt{D}}^{\\mathtt{LL}}, \\phi^{\\mathtt{AR}}_{D}, \\sigma_{w, \\mathtt{D}}^{\\mathtt{AR}}, \\sigma_{v, \\mathtt{D}},  \\\\\n&  \\sigma_{w, \\mathtt{T}}^{\\mathtt{LL}},  p^{\\mathtt{P}, \\text{yearly}}_{\\mathtt{T}}, \\sigma_{w, \\mathtt{T}}^{\\mathtt{P}, \\text{yearly}} , p^{\\mathtt{P}, \\text{daily}}_{\\mathtt{T}} , \\sigma_{w, \\mathtt{T}}^{\\mathtt{P}, \\text{daily}}, \\phi^{\\mathtt{AR}}_{\\mathtt{T}}, \\sigma_{w, \\mathtt{T}}^{\\mathtt{AR}}, \\sigma_{v, \\mathtt{T}},\\phi^{\\mathtt{D}|\\mathtt{T}}_{\\mathtt{P}_{y}},\\phi^{\\mathtt{D}|\\mathtt{T}}_{\\mathtt{P}_{d}},\\phi^{\\mathtt{D}|\\mathtt{T}}_{\\mathtt{AR}}].\n\\end{align*}\nThe optimized model parameters values computed using the Newton-Raphson algorithm (see~\\ref{SS:THModelParameterEstimation}) with a training period of 180 days are\n\\begin{align*}\n \\bm\\theta^{\\text{*}}& =[0, 0.90, 0.037, 1.94\\times10^{-5},  \\\\\n & 0, 365.2422, 0, 1, 0, 0.98, 0.86, 1.14\\times10^{-4}, -0.013, 0.0706, 0.00073 ].\n\\end{align*}\nThe estimated initial hidden states mean and covariance values are \n\\begin{align*}\n\\bm \\mu^{*}_{0} & = [\t25.9,-2.55\\times10^{-5},5.53,16.3,-0.999,0.263,0.669,3.77 ]^{\\intercal}, \\text{and} \\\\\n\\bm\\Sigma^{*}_{0} & = \\text{diag}([4.27\\times10^{-5},1.68\\times10^{-3},0.715,0.338,0.341,6.73\\times10^{-5},6.73\\times10^{-5},1.81]).\n \\end{align*}\nThe hidden states computed using the estimated model parameters and initial hidden states are presented in Figure~\\ref{fig:DISPTEMPSIMOptimizedOptimizedExample2}.\n\n\n\\subsubsection{Run the example from the pre-existing configuration file}\n\\label{SS:LoadConfigFileEx2}\nThere is a configuration file CFG\\_Example\\_DISPTEMP\\_optim.m which is located in the ``config\\_files'' folder of the OpenBDLM package.\nCFG\\_Example\\_DISPTEMP\\_optim.m contains the optimized model parameters and optimized initial hidden states values.\nThere is also a data file DATA\\_Example\\_DISPTEMP\\_optim.mat that is located in the ``data/mat'' subfolder.\nTherefore, it is possible to run the example \\#2 by following the steps below while interacting with the \\MATLAB{} command line:\n\\begin{enumerate}\n\\item Start OpenBDLM. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISPTEMP_optim.m');!}.\n\\item Access hidden states estimation menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}.\n\\item Run the Kalman filter to estimate the hidden states. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}.\n\\item Save and quit. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Q!}.\n\\end{enumerate}\n\n\n\\subsubsection{Run the example from command line interaction}\n\nThe analysis of a new dataset usually requires to start from scratch.\nThis section explains how to run the example \\#2 from scratch, that is, how to load  and resample the data presented in Figure~\\ref{fig:DataSummaryRaw2}, configure the model, estimate the model parameters and estimate the hidden states.\nThis may be done by following steps below while interacting with the \\MATLAB{} command line:\n\\begin{enumerate}\n\\item Start OpenBDLM. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main;!}.\n\\item Choose the interactive tool. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!0!}.\n\\item Enter the project name. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Example_DISPTEMP!}. \n\\item Disregard generating synthetic data. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!no!}. \n\\item Load new data. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!0!}.\n\\item Select from the graphical user interface the data files located in the ``/data/csv/Example\\_DISPTEMP/'' folder. The Figure~\\ref{fig:DataSummaryRaw2} that represents the raw data should popup on screen.\n\\item Access the resampling menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!4!}. \n\n\\item Resample data to obtain timesteps of 6h (0.25 day). Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!0.25!}. The Figure \\ref{fig:DataSummaryDefaultPreProcessed2} should popup on the screen this time for the resampled data.\n\n\\item Save and continue. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!7!}. The same figures should popup on the screen again.\n\\item Select dependency for the time series \\#1. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![2]!}.\n\\item Select dependency for the time series \\#2. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![0]!}.\n\\item Select the number of model classes. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. \n\\item Select the model block components for time series \\#1. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![11 41]!}.\n\\item Select the model block components for time series \\#2. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![11 31 31 41]!}.\n\n\\item Access the training period modification menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!13!}. \n\n\\item Modify the training period. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. \n\n\\item Choose the starting time (day). Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. \n\n\\item Choose the end time (day). Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!180!}. \n\n%\\item Access hidden states estimation menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}. \n%\\item Change the state estimation method to UD\\footnote{The UD computation is required in this case because of the presence of missing data. See Section~\\ref{SS:KFUD} for more details.}. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}. \n%\\item Return to the main menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!R!}.\n\\item Access model parameter estimation menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. \n\\item Start the Newton-Raphson algorithm. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. Once the algorithm has converged, the optimized model parameters values should be close to the values presented in \\S\\ref{SS:ModelConstructionExample2}. Note also that it is possible to get slightly different parameter values\\footnote{Keep in mind that the optimization may take several minutes. It is possible to abort the analysis here and to load the configuration file called CFG\\_Example\\_DISPTEMP\\_optim.m to load pre-computed values of model parameters, as presented in Section~\\ref{SS:LoadConfigFileEx2}.}.\n\\item Estimate the initial hidden states values. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!2!}.\n\\item Estimate the hidden states using the Kalman filter. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}. The estimation should be similar to the results presented in Figure~\\ref{fig:DISPTEMPSIMOptimizedOptimizedExample2}.\n\\item Access export menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!17!}. \n\\item Export the current project in a configuration file. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}.\n\\item Save and quit OpenBDLM. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Q!}.\n\\end{enumerate}\n\n\n\n\n%\\subsection{Step 4: configure the model}\n%\n%The next step is to configure the model.\n%First, the program requests the number of model class.\n%In this exemple, the time series data looks stationary and we are not interested in anomaly detection, and therefore we type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}.\n%Secondly, because there are several time series, OpenBDLM needs to know if there are dependencies between the time series.\n%Typing \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!2!} for the first time series, and \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!0!} for the second time series means that the model will consider the irreversible components (if any) of the second (temperature) time series as covariates to describe the irreversible patterns observed in the first (displacement) time series.\n%Then, OpenBDLM asks for the type of block component for each time series. \n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![11 41]!} for the displacement time series and \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]![11 31 31 41]!} for the temperature time series.\n%The yearly and daily periodic patterns observed in the displacement time series are modelled using the dependence on the periodic components defined for modelling the temperature time series data.\n%Note that because an autoregressive component is chosen for the displacement time series data, the time-dependent model error on the displacement is modelled using a dependence on the autoregressive component of the temperature time series data, as well as an independent autoregressive component.\n%The  output on \\MATLAB{} command window during interactive model configuration is presented in Listing~\\ref{LST:OpenBDLMModelConfigureExample2}.\n%Type $\\dlsh$ to valid.\n%The model is then built, a \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!DATA_DISPTEMP.mat! binary data file, a \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!CFG_DISPTEMP.m! configuration file, as well as a \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!PROJ_DISPTEMP.mat! project file are created.\n%The OpenBLDM main menu must appear on the \\MATLAB{} command window (see Listing~\\ref{LST:OpenBDLMMainMenu}).\n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Q!} to save and quit.\n\n\n\n% \\begin{lstlisting}[ frame = single, basicstyle = \\mlttfamily \\small, caption = { \\MATLAB{} command window output during model configuration}, label = LST:OpenBDLMModelConfigureExample2,  float =h!, linewidth=\\linewidth, captionpos=b, breaklines=true]\n%- Identifies dependence between time series; use [0] to indicate no dependence\n%    time serie #1 depends on time series # >> [2]\n%\n%- Identifies dependence between time series; use [0] to indicate no dependence\n%    time serie #2 depends on time series # >> [0]\n%\n%- How many model classes do you want for each time series? \n%     choice >> 1\n%     \n%     ------------------------------------\n%          BDLM Component reference numbers\n%     ------------------------------------\n%     11: Local level \n%     12: Local trend \n%     13: Local acceleration \n%     21: Local level compatible with local trend \n%     22: Local level compatible with local acceleration \n%     23: Local trend compatible with local acceleration \n%     31: Periodic \n%     41: Autoregressive process (AR(1)) \n%     51: Kernel regression \n%     61: Level Intervention \n%     --------------------------------------\n%\n%- Identify components for time series #1; e.g. [11 31 41]\n%     choice >> [11 41]\n%\n%- Identify components for time series #2; e.g. [11 31 41]\n%     choice >> [11 31 31 41]\n%\n%     Building model...\n%     Saving project...\n%     Project saved in saved_projects/PROJ_Example_DISPTEMP.mat. \n%     Printing configuration file...\n%     Saving data...\n%     Database saved in data/mat/DATA_Example_DISPTEMP.mat \n%     Configuration file saved in config_files/CFG_Example_DISPTEMP.m. \n%\\end{lstlisting}\n\n\n%\\subsection{Step 5: open the configuration file}\n%\n%After the data loading and the model configuration, a configuration file named \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!CFG_Example_DISPTEMP.m! configuration file is automatically created and saved in ``config\\_files'' folder.\n%Open the configuration file from \\MATLAB{} command line by typing  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!edit CFG_Example_DISPTEMP.m!}.\n%%The first part of this configuration file as it should appear on the \\MATLAB{} editor is shown in Listing~\\ref{LST:CFGFileExample1}.\n%The Model parameters section of the configuration file shows that the model totalizes 15 model parameters, that is \n%\\begin{gather*}\n%\\bm\\theta=\\{\\sigma_{w, \\mathtt{D}}^{LL},  \\phi^{AR}_{\\mathtt{D}}, \\sigma_{w,\\mathtt{D}}^{AR} ,\\sigma_{v,\\mathtt{D}},  \\\\\n% \\sigma_{w, \\mathtt{T}}^{LL}, p^{\\text{PD1}}_{\\mathtt{T}}, \\sigma_{w,\\mathtt{T}}^{\\text{PD1}} , p^{\\text{PD2}}_{T}, \\sigma_{w, \\mathtt{T}}^{\\text{PD2}}, \\phi^{AR}_{T}, \\sigma_{w, \\mathtt{T}}^{AR}, \\sigma_{v,\\mathtt{T}}, \\phi^{\\mathtt{D}|\\mathtt{T}}_{PD1}, \\phi^{\\mathtt{D}|\\mathtt{T}}_{PD2},  \\phi^{\\mathtt{D}|\\mathtt{T}}_{AR}\\}.\n%\\end{gather*}\n%%The default value of the model parameters are assigned  using heuristic knowledge or computed from the data using statistics on the data.\n%The default model parameters values are \n%\\begin{gather*}\n%\\bm\\theta^{\\text{default}}=\\{0, 0.75, 0.017, 0.0087, \\\\\n%0, 365.24, 0, 1, 0, 0.75, 1.2905, 0.64526, 0.5, 0.5, 0.5 \\}.\n%\\end{gather*}\n%%In the same manner, default value for the initial hidden states are assigned using heuristic knowledge or computed using statistics on the data.\n%The default initial hidden states mean  and covariance values are \n%\\begin{align*}\n% \\bm \\mu^{\\text{default}}_{0} & = [\t25.7  ,\t0  ,   \t16.7  \t, 5     ,\t0   ,  \t5   ,  \t0    , \t0        ]^{\\intercal}, \\text{and} \\\\\n% \\text{diag}(\\bm\\Sigma^{\\text{default}}_{0})  & = [\t0.122, \t0.0305,\t666,   \t666,   \t666,   \t666,   \t666 ,  \t167     ],\n%\\end{align*}\n%respectively.\n%%$\\bm \\mu^{\\text{default}}_{0} = [\t25.7  ,\t0  ,   \t16.7  \t, 5     ,\t0   ,  \t5   ,  \t0    , \t0        ]$, and $\\text{diag}(\\bm\\Sigma^{\\text{default}}_{0}) = [\t0.122, \t0.0305,\t666,   \t666,   \t666,   \t666,   \t666 ,  \t167     ]$, respectively.\n%In the Options section, change \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc.options.MethodStateEstimation='kalman'! to \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!misc.options.MethodStateEstimation='UD'!. \n%In this specific example, the presence of missing data requires the use of UD computations instead of the standard, default, Kalman computation.\n%Note that the choice about UD or Kalman is problem dependent. \n%\n%\\subsection{Step 6: estimate the hidden states}\n%\n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISPTEMP.m');!} in the \\MATLAB{} command line.\n%Once, the main menu appears, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}, then \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} to estimate the filtered hidden states using the default model parameters and default initial hidden states values.\n%The value of the log-likelihood is $-3800091$.\n%The estimated hidden states are presented in Figure~\\ref{fig:DISPTEMPSIMDefaultDefaultExample2}.\n\n\n%\\subsection{Step 7: estimate the model parameters from the data}\n%\n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISPTEMP.m');!} in the \\MATLAB{} command line.\n%Once, the main menu appears, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}, then \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} to estimate the model parameters using Newton-Raphson (type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} to use the Stochastic Gradient instead).\n%The model parameters learning procedure should start (see for example Listing~\\ref{LST:OpenBLDMModelParameterLearning}).\n%Note that, by default, OpenBDLM considers that the parameters $\\sigma_{w, \\mathtt{D}}^{LL}$, $\\sigma_{w, \\mathtt{T}}^{LL}$, $p^{\\text{PD1}}_{\\mathtt{T}}$, $\\sigma_{w, \\mathtt{T}}^{\\text{PD1}}$ , $p^{\\text{PD2}}_{\\mathtt{T}}$, $\\sigma_{w,\\mathtt{T}}^{\\text{PD2}}$ are known.\n%Therefore, there are nine model parameters to be learned from the data in this example.\n%The estimation of the model parameters may take several hours.\n%Therefore, press combinations \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Ctrl!} + \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!c!} to abort the process.\n%Once the algorithm is converged, the optimized model parameters values should be close to  \\footnote{Note that it is possible to get slightly different value of parameters with the same performance.}\n%\\begin{gather*}\n% \\bm\\theta^{\\text{*}}=\\{0, 0.97, 0.019, 7.42\\times10^{-7}, 0, 365.2422, 0, 1, 0, 0.99, 0.43, 2.67\\times10^{-5},  \\\\\n% -0.011, 0.0711, 0.000292 \\}\n%\\end{gather*}\n\n\n%\\subsection{Step 8: estimate the hidden states using the optimized model parameters. values}\n%\n%In the ``examples/Example\\_DISPTEMP'' folder, there is a configuration file named \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!CFG_Example_DISPTEMP_optim.m! that contains optimized model parameters estimated using the Newton-Raphson algorithm.\n%Copy and paste \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!CFG_Example_DISPTEMP_optim.m! from  the ``examples/Example\\_DISPTEMP'' subfolder  to the ``config\\_files'' folder.\n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISPTEMP_optim.m');!} in the \\MATLAB{} command line to load the configuration file  \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!CFG_Example_DISPTEMP_optim.m!.\n%Once the main menu appears, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}, then \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} to estimate the filtered hidden states using the optimized model parameters and default initial hidden states values.\n%The value of the log-likelihood is now $38085$.\n%The estimated hidden states are presented in Figure~\\ref{fig:DISPTEMPSIMOptimizedDefaultExample2}.\n\n%\\subsection{Step 9: estimate the initial hidden states}\n%\n%Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISPTEMP_optim.m');!} in the \\MATLAB{} command line.\n%Then, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!2!}, to optimize the initial hidden states value.\n%The estimated initial hidden states mean and covariance values are \n%\\begin{align*}\n%\\bm \\mu^{*}_{0} & = [\t 25.9  ,\t-0.0595\t, 5.45  \t, 17.6  ,\t-0.934\t, 0.678 ,\t0.41  ,\t2.1]^{\\intercal}, \\text{and} \\\\\n% \\text{diag}(\\bm\\Sigma^{*}_{0}) & = [\t3.71\\times10^{-5},\t0.000457\t, 0.287 \t, 0.263 ,\t0.265 \t,8.14\\times10^{-5}\t, \\\\\n% & 8.14\\times10^{-5}\t, 0.71    ], \n% \\end{align*}\n% respectively.\n%Once it is done, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}, and then  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} to compute the filtered hidden states using the optimized model parameters and optimized initial hidden states.\n%The value of the log-likelihood is $38120$.\n%The estimated hidden states are presented in Figure~\\ref{fig:DISPTEMPSIMOptimizedOptimizedExample2}.\n\n\n%\\begin{figure*}[h!]\n%\\centering\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/DISP_ObservedPredicted.pdf}\n%\\caption{Observed and estimated displacement data} \n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/DISP_LL_1.pdf}\n%\\caption{Estimated displacement local level component.}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/DISP_AR_2.pdf}\n%\\caption{Estimated displacement autoregressive component.}\n%\\end{subfigure}\n%\\end{figure*}\n%\\begin{figure*}[h!]\n%\\ContinuedFloat\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/TEMP_ObservedPredicted.pdf} \n%\\caption{Observed and estimated temperature data}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/TEMP_LL_1.pdf} \n%\\caption{Estimated temperature local level component.}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/TEMP_S1_2.pdf} \n%\\caption{Estimated temperature yearly component (first hidden state)}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/TEMP_S1_4.pdf} \n%\\caption{Estimated temperature daily component (first hidden state)}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/default/TEMP_AR_6.pdf} \n%\\caption{Estimated temperature autoregressive component}\n%\\end{subfigure}\n%\\caption{Estimated results using OpenBDLM default model parameters and default initial hidden states. The hidden states are estimated from the data presented in Figure~\\ref{fig:DataSummaryDefaultPreProcessed2}a. The solid line and shaded area represent the mean and standard deviation of the estimated hidden states, respectively.}\n%\\label{fig:DISPTEMPSIMDefaultDefaultExample2}\n%\\end{figure*}\n\n%\\begin{figure*}[h!]\n%\\centering\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/DISP_ObservedPredicted.pdf}\n%\\caption{Observed and estimated displacement data} \n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/DISP_LL_1.pdf}\n%\\caption{Estimated displacement local level component.}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/DISP_AR_2.pdf}\n%\\caption{Estimated displacement autoregressive component.}\n%\\end{subfigure}\n%\\end{figure*}\n%\\begin{figure*}[h!]\n%\\ContinuedFloat\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/TEMP_ObservedPredicted.pdf} \n%\\caption{Observed and estimated temperature data}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/TEMP_LL_1.pdf} \n%\\caption{Estimated temperature local level component.}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/TEMP_S1_2.pdf} \n%\\caption{Estimated temperature yearly component (first hidden state)}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/TEMP_S1_4.pdf} \n%\\caption{Estimated temperature daily component (first hidden state)}\n%\\end{subfigure}\n%\\begin{subfigure}{\\linewidth}\n%\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_default_initialhiddenstate/TEMP_AR_6.pdf} \n%\\caption{Estimated temperature autoregressive component}\n%\\end{subfigure}\n%\\caption{Estimated results using OpenBDLM optimized model parameters and default initial hidden states. The hidden states are estimated from the data presented in Figure~\\ref{fig:DataSummaryDefaultPreProcessed2}a. The solid line and shaded area represent the mean and standard deviation of the estimated hidden states, respectively.}\n%\\label{fig:DISPTEMPSIMOptimizedDefaultExample2}\n%\\end{figure*}\n\n\\begin{figure*}[h!]\n\\centering\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/DISP_ObservedPredicted.pdf}\n\\caption{Observed and estimated displacement data} \n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/DISP_LL_1.pdf}\n\\caption{Estimated displacement local level component.}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/DISP_AR_2.pdf}\n\\caption{Estimated displacement autoregressive component.}\n\\end{subfigure}\n\\end{figure*}\n\\begin{figure*}[h!]\n\\ContinuedFloat\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/TEMP_ObservedPredicted.pdf} \n\\caption{Observed and estimated temperature data}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/TEMP_LL_1.pdf} \n\\caption{Estimated temperature local level component.}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/TEMP_S1_2.pdf} \n\\caption{Estimated temperature yearly component (first hidden state)}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/TEMP_S1_4.pdf} \n\\caption{Estimated temperature daily component (first hidden state)}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISPTEMPSIM/optim_param_optim_initialhiddenstate/TEMP_AR_6.pdf} \n\\caption{Estimated temperature autoregressive component}\n\\end{subfigure}\n\\caption{Estimated results using OpenBDLM with the optimized model parameters and initial hidden states. The hidden states are estimated from the data presented in Figure~\\ref{fig:DataSummaryDefaultPreProcessed2}a. The solid line and shaded area represent the mean and standard deviation of the estimated hidden states, respectively.}\n\\label{fig:DISPTEMPSIMOptimizedOptimizedExample2}\n\\end{figure*}", "meta": {"hexsha": "6aa9aba2868f3849786604478ba151762c3064e7", "size": 32105, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pdf_doc/section/OpenBDLMExampleDependenceModel.tex", "max_stars_repo_name": "CivML-PolyMtl/OpenBDLM", "max_stars_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-19T23:42:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T17:32:11.000Z", "max_issues_repo_path": "doc/pdf_doc/section/OpenBDLMExampleDependenceModel.tex", "max_issues_repo_name": "bhargobdeka/OpenBDLM", "max_issues_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pdf_doc/section/OpenBDLMExampleDependenceModel.tex", "max_forks_repo_name": "bhargobdeka/OpenBDLM", "max_forks_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-10-18T07:18:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:26:06.000Z", "avg_line_length": 78.3048780488, "max_line_length": 670, "alphanum_fraction": 0.7582931008, "num_tokens": 9197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.42191917927340367}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{fullpage}\n\\usepackage{amsmath, amssymb}\n\n\\title{An Overview of \\\\\n      \\textbf{Fiber Orientation Tools} \\\\\n      { \\normalsize \\texttt{http://github.com/charlestucker3/Fiber-Orientation-Tools}} }\n\n\\author{Charles L.~Tucker III \\\\\n       Department of Mechanical Science and Engineering \\\\\n        University of Illinois at Urbana-Champaign \\\\\n        1206 W.~Green St. \\\\\n        Urbana, IL 61801 \\\\\n        }\n\\include{defs}  % Macro definitions\n\n\\begin{document}\n\\maketitle\n\nThis document summarizes \\textbf{Fiber Orientation Tools}, a set of \\matlab\\ functions for modeling flow-induced fiber orientation in discontinuous fiber composites, and for predicting the resulting mechanical properties.  \n\nThe tools accompany the book \\textit{Fundamentals of Fiber Orientation: Description, Measurement and Prediction} by C. L. Tucker III (Hanser, Munich, 2022), and references to sections, figures, and equations indicate items in the book.  \n\n \\matlab\\ live scripts that demonstrate the use of various tools are described first, followed by a list of the functions in the toolkit, organized by category.  To see the details of any function, type \\texttt{help} followed by the function name in the \\matlab\\ command window.\n\n\n\n\\section{Live Scripts with Example Calculations}\n\nThe live scripts are arranged topically, following the chapters of the book.  \n\n\\subsection*{Chapter 2.  Describing Fiber Orientation and Length}\n\n\\begin{description}\n    \n    \\item[OrientationDistributionFunctions.mlx]{creates 3-D orientation distribution functions $\\psi(\\pv)$ using the Jeffery distribution function, as in Fig.~2.5.  Uses \\texttt{A2F} and \\texttt{drawPsi}.}\n    \n    \\item[OrientationTensorExamples.mlx]{calculates orientation tensors for various combinations of $\\pv$ vectors.  Uses \\texttt{p2A} and follows the examples in Sections~2.3.1 and 2.3.5.}\n\n    \\item[EigenvaluesEigenvectors.mlx]{finds eigenvalues and eigenvectors of a second-order orientation tensor, and compares the standard \\matlab\\ function \\texttt{eig} with the \\texttt{eigsort} function from this toolkit.}\n    \n    \\item[ReconstructDiscreteDistributionFcn.mlx]{shows how to find a set of orientation vectors $\\pv^i$ and weighting factors $f_i$ to form a discrete approximation of an orientation distribution function, using the Jeffery distribution function, Eqn.~(2.103).  Uses \\texttt{A2F} and \\texttt{matchA}. }\n\n        \\item[A2Faccuracy.mlx]{explains how to control the accuracy of \\texttt{A2F}, which finds the deformation gradient tensor $\\F$ that will transform an initially isotropic orientation state to a given second-order tensor $\\A$, using the deformation form of Jeffery's equation.  \\texttt{F2A} does the reverse calculation.}    \n        \n\\end{description}\n\n\\subsection*{Chapter 3.  Measuring Fiber Orientation and Length}\n\n\\begin{description}\n    \n    \\item[PlanarSectionMeasurement.mlx]{uses \\texttt{thetaphi2A} to compute orientation information for data from a planar section.  Follows Example~3.1.1.}\n      \n\\end{description}\n\n\\subsection*{Chapter 4. Flow Orientation of Single Fibers}\n\n\\begin{description}\n\n    \\item[JefferyFiberMotion.mlx]{calculates the motion of a single fiber following Jeffery's equation using \\texttt{pDot} and \\texttt{ode45} (Section~4.2.3).   Jeffery orbits are illustrated, as in Fig.~4.14.}\n\n    \\item[JefferyDeformationForm.mlx]{illustrates the use of \\texttt{changep}, which implements the deformation form of Jeffery's equation.  Also uses \\texttt{randomfibers} to generate a set of $\\pv$ vectors that are randomly distributed in all directions, and \\texttt{p2A} to determine the initial and final orientation tensors.}\n        \n\\end{description}\n\n\n\\subsection*{Chapter 5. Flow Orientation of Groups of Fibers} \n\n\\begin{description}    \n\n        \\item[JefferyTensorEqn.mlx]{illustrates the numerical solution of the orientation tensor equation when every fiber follows Jeffery's equation.  This is the example from Section 5.1.2, and uses \\texttt{AdotJeffQuad}.}    \n\n        \\item[SolvePlanarDistnFcn.mlx]{shows how to solve for the planar orientation distribution function $\\psi_\\phi (\\phi, t)$ using \\texttt{solvePsi2D}.  See Sections~5.2.1 and 5.3.1.  This script produces Fig.~5.5(a), and illustrates the control of `wiggles' in the finite difference solution using power-law upwinding and/or grid refinement.}    \n\n        \\item[Solve3DdistnFcn.mlx]{shows how to solve for the 3-D orientation distribution function $\\psi (\\pv, t)$  using \\texttt{solvePsi3D}.  See Sections~5.2.2 and 5.3.2.  This script produces the tensor history in Fig.~5.7, and shows how to display distribution functions as in Fig. 5.6.  This script also shows how to calculate $\\psi(\\pv, t)$ for anisotropic rotary diffusion models using \\texttt{solvePsiARD} (Section~ 5.6).  }    \n\n        \\item[OrientationTensorEqns.mlx]{uses \\texttt{Adot2} together with \\texttt{ode45} to solve tensor equations for flow-induced fiber orientation.  The script shows solutions to the Folgar-Tucker equation (Sections~5.3 and 5.4), anisotropic rotary diffusion models (Section~5.6), and slow kinetics models (Section~5.7).}    \n \n        \\item[FitCI.mlx]{illustrates the use of \\texttt{fitCI} to find the interaction coefficient $C_I$ that produces a given steady-state value of $A_{11}$ in simple shear flow for the Folgar-Tucker model.  This script also demonstrates that the choice of closure approximation affects the value of $C_I$.}   \n \n        \\item[FitARDparams.mlx]{uses \\texttt{fitARD} to obtain the ARD parameters that give desired steady-state values of $A_{11}$ and $A_{33}$ in simple shear flow.  Also demonstrates that the steady-state orientation is independent of the kinetic parameter $\\kappa$ when an RSC or RPR model is used together with anisotropic rotary diffusion.}   \n        \n\\end{description}\n\n\\subsection*{Chapter 6. Suspension Rheology and Flow-Orientation Coupling}\n\n\\begin{description}\n\n    \\item[FiberSuspensionStress.mlx]{demonstrates the use of \\texttt{tauFiber} to find the orientation-dependent stress in a fiber suspension.  Shows how to do the calculations used to generate Fig.~6.4.}\n    \n\\end{description}\n\n\\subsection*{Chapter 7. Fiber Length Degradation during Processing}\n\n\\begin{description}\n\n    \\item[FiberLengthModel.mlx]{explains the dimensionless version of the Phelps-Tucker fiber length model as implemented in \\texttt{solveFLDstar}, and shows the calculations for the example in Fig. 7.4.}\n\n\\end{description}\n\n\\subsection*{Chapter 8. Mechanical Properties and Orientation}\n\n\\begin{description}\n\n    \\item[UnidirectionalProperties.mlx]{shows how to calculate the stiffness and thermal expansion of composites with unidirectional fiber orientation using mean-field theories.  The main functions for this are \\texttt{mori} for the Mori-Tanaka model, \\texttt{lielens} for the Lienlens/double-inclusion model, and \\texttt{halpin} for the Halpin-Tsai model.  The functions \\texttt{iso2C}, \\texttt{C2eng}, and \\texttt{inv4} are also used.}\n    \n    \\item[OrientationAveragedProperties.mlx]{applies orientation averaging to find the properties of a composite with a distribution of fiber orientation.  Both stiffness and thermal expansion are considered, and Voigt averages are computed.  The main functions are \\texttt{oravg4} and \\texttt{oravg2}.  The script reproduces Fig.~8.5(a) showing elastic modulus vs.\\ orientation, and creates a plot of thermal expansion vs.\\ orientation similar to Fig.~8.8(a).}\n        \n    \\item[LaminatedPlateProperties.mlx]{uses classical lamination theory, as implemented in \\break \\texttt{Clayer2laminate}, to find the tensile and flexural moduli of an injection molded composite whose orientation varies across the thickness.  Partial results from Table~8.4 are reproduced.  A summary of the underlying theory is given in \\textbf{LaminationTheory.pdf} in the Documentation folder.}\n\\end{description}\n\n\\section{Functions Listed by Category}\n\n\\subsection{Operations on Orientation Tensors}\n\n\\begin{description}\n\n    \\item[eigsort]{returns the eigenvalues and eigenvectors of a tensor, sorted from largest eigenvalue to smallest.}\n\n    \\item[inv4]{finds the tensor inverse of a fourth-order tensor in $6 \\times 6$ matrix form.}\n\n    \\item[p2A]{converts a set of $\\pv$ vectors to second-order and fourth-order orientation tensors, with or without weighting factors.}\n\n    \\item[rotate4]{performs a coordinate transformation on a fourth-order tensor.  See Section~A.4.5.}\n\n    \\item[tens2vec]{converts a symmetric second-order tensor from $3 \\times 3$ matrix form to $6 \\times 1$ column vector (contracted) form.  See Section~2.3.5.1.}\n\n    \\item[tens2vec4]{converts a symmetric fourth-order tensor from $6 \\times 6$ matrix form to $15 \\times 1$ column vector form.  This is not discussed in the book, but is used by \\texttt{matchA}.}\n\n    \\item[thetaphi2A]{returns the second-order orientation tensor corresponding to a set of angles $(\\theta, \\phi)$ measured from planar section data (Section~3.1.1).  Either the Bay or Konicek weighting functions can be used.}\n\n    \\item[transisoA]{returns the full second-order orientation tensor $\\A$ and fourth-order orientation tensor $\\Afour$ for a transversely isotropic orientation state with given values of $A_{11}$ and $\\Afour_{1111}$.}\n\n    \\item[vec2tens]{converts a symmetric second-order tensor from $6 \\times 1$ column vector form to $3 \\times 3$ matrix form.  See Section~2.3.5.1.}\n\n    \\item[vec2tens4]{converts a symmetric fourth-order tensor from $15 \\times 1$ column vector form to $6 \\times 6$ matrix form.  This is not discussed in the book, but is the inverse of \\texttt{tens2vec4}.  It can be used to convert fourth-order tensor results from \\texttt{solvePsi3D} and \\texttt{solvePsiARD} to matrix form.}\n    \n\\end{description}\n\n\\subsection{Flow-Induced Orientation Models}\n\n\\begin{description}\n\n    \\item[Adot2]{gives the time derivative $\\dot{\\A}$ as a function of $\\A$, $\\mathbf{L}$ and orientation model parameters, for a wide range of orientation models.  This is the principal tool used to predict flow-induced orientation.}\n    \n    \\item[AdotJeffQuad]{gives the time derivative $\\dot{\\A}$ for the Jeffery model using the quadratic closure.  This is a simplified version of \\texttt{Adot2}, used in Section~5.1.2 and Fig.~5.1.}\n    \n    \\item[Asteady]{finds the steady-state orientation tensor $\\A$ for a given velocity gradient $\\mathbf{L}$, for any orientation model in \\texttt{Adot2}.}\n    \n    \\item[changep]{finds a set of current orientation vectors $\\pv$ using the deformation form of Jeffery's equation, for a given set of initial vectors $\\pv'$ and deformation gradient tensor $\\F$.}\n    \n    \\item[closeA4]{uses any of several closure approximations to find the fourth-order orientation tensor $\\Afour$ corresponding to a second-order tensor $\\A$.  See Section~ 5.4.}  \n    \n    \\item[fitARD]{finds the anisotropic rotary diffusion (ARD) model parameters that achieve given steady-state values of $A_{11}$ and $A_{33}$ in 1--3 simple shear flow.}  \n    \n    \\item[fitCI]{finds the interaction coefficient $C_I$ for the Folgar-Tucker model that achieves a given steady-state value of $A_{11}$ in simple shear flow.}\n    \n    \\item[pDot]{gives the time derivative $\\dot{ \\pv}$ of an orientation vector $\\pv$ using Jeffery's equation.  See Section~4.2.3.}\n    \n    \\item[solvePsi2D]{solves for the orientation distribution function $\\psi_\\phi ( \\phi, t)$ for the 2-D version of the Folgar-Tucker model.  See Sections~5.2.1 and 5.3.21}\n    \n    \\item[solvePsi3D]{solves for the orientation distribution function $\\psi( \\theta, \\phi, t)$ for the 3-D version of the Folgar-Tucker model.  See Sections~5.2.2 and 5.3.2.}\n    \n    \\item[solvePsiARD]{solves for the orientation distribution function $\\psi( \\theta, \\phi, t)$ for 3-D anisotropic rotary diffusion models.  See Section~5.6.}\n    \n    \\item[tauFiber]{finds the extra-stress tensor $\\btau$ for a fiber suspension, for a given orientation tensor $\\A$ and rate of deformation $\\D$, Eqn.~(6.29).}\n    \n\\end{description}\n\n\\subsection{Fiber Length Prediction}\n\n\\begin{description}\n\n    \\item[fldRstar]{returns a matrix $[R^*]$ used in the non-dimensional version of the Phelps-Tucker fiber length model.  This function is not used directly, but is required by \\texttt{solveFLDstar}.}\n    \n    \\item[solveFLDstar]{solves a non-dimensional version of the Phelps-Tucker fiber length model.}\n    \n\\end{description}\n\n\\subsection{Mechanical Property Prediction}\n\n\\begin{description}\n\n    \\item[C2eng]{finds the engineering constants for a given stiffness tensor $\\Cfour$.}\n\n    \\item[Clayer2laminate]{finds the laminate stiffness matrices $[A]$, $[B]$, and $[D]$ for a laminate, given the stiffness tensor $\\Cfour$ for each layer and the layer thicknesses.  This is used to compute the tensile and bending properties of a composite where the orientation varies across the thickness; see Section~8.4.5.}\n    \n    \\item[diluteEshelby]{finds the stiffness tensor $\\Cfour$ for a dilute composite with unidirectional alignment using Eshelby's equivalent inclusion.  This model is primarily of theoretical interest, and is used in Fig.~8.3.}    \n    \n    \\item[eng2C]{converts the engineering constants for an orthotropic material into a stiffness tensor $\\Cfour$.}    \n    \n    \\item[eshtens]{returns the Eshelby tensor $\\Efour$ for a spheroidal particle in an isotropic matrix.  The particle can be prolate (fiber-like), spherical, or oblate (disk-like).}\n    \n    \\item[halpin]{finds the engineering constants, stiffness tensor $\\Cfour$, and thermal stress tensor $\\bbeta$ for a discontinuous fiber composite with unidirectional fibers using the Halpin-Tsai equations.}    \n    \n    \\item[iso2C]{finds the stiffness tensor $\\Cfour$ for an isotropic material with Young's modulus $E$ and Poisson ratio $\\nu$.}    \n    \n    \\item[lielens]{returns the stiffness tensor $\\Cfour$ and thermal stress tensor $\\bbeta$ for a unidirectional composite using the Lielens/double-inclusion model.}    \n    \n    \\item[mori]{returns the stiffness tensor $\\Cfour$ and thermal stress tensor $\\bbeta$ for a unidirectional composite using the Mori-Tanaka model.}   \n    \n    \\item[oravg2]{computes the orientation average of a transversely isotropic second-order tensor, Eqn.~(8.81).}   \n    \n    \\item[oravg4]{computes the orientation average of a transversely isotropic fourth-order tensor, Eqn.~(8.77).}   \n    \n\\end{description}\n\n\\subsection{Reconstruction of Orientation Distribution Functions}\n\n\\begin{description}\n\n    \\item[A2F]{find the orientation tensor $\\A$ for any deformation gradient tensor $\\F$ using the deformation form of Jeffery's equation.}\n    \n    \\item[F2A]{returns the orientation tensor $\\A$ for a given deformation gradient tensor $\\F$ using Jeffery's model.}\n    \n    \\item[matchA,]{given a set of orientation vectors $\\pv^i$ and weights $f^i$, adjusts the weights to exactly match a given second-order or fourth-order orientation tensor, while minimizing the mean square difference between the original and adjusted weights.  WARNING: This function can return negative values for some weights, usually when the orientation state is highly aligned.  See \\texttt{RecontructDiscreteDistributionFcn.mlx} for examples.}    \n    \n\\end{description}\n\n\\subsection{Graphics and Utility Functions}\n\n\\begin{description}\n    \n    \\item[drawPsi]{draws a sphere colored by the Jeffery orientation distribution function for a given deformation gradient tensor $\\F$.}\n\n    \\item[fill3elt]{draws a triangular mesh in three dimensions, colored according to element values.}\n\n    \\item[fill3mesh]{draws a triangular mesh in three dimensions, colored according to nodal values.}\n\n    \\item[meshcon]{builds the edge connectivity information for a triangular mesh, as needed by \\texttt{refinemesh}.}\n\n    \\item[p2sph]{converts a set of $\\pv$ vectors to the angles $(\\theta, \\phi)$ in a spherical coordinate system.}\n\n    \\item[plot3mesh]{draws the elements of a triangular mesh in three dimensions.}\n\n    \\item[plot3nodes]{draws the nodes of a mesh in three dimensions.}\n    \n    \\item[randomfibers]{generates a set of fiber orientation vectors $\\pv$, randomly oriented in three dimensions.}\n\n    \\item[refinemesh]{refines a triangular mesh by dividing each initial element into $n^2$ smaller ones.}\n\n    \\item[sph2p]{converts a set angles $(\\theta, \\phi)$ in a spherical coordinate system into unit vectors $\\pv$.}\n\n    \\item[spheremesh]{generates different types of triangular meshes on a unit sphere, or on half of a sphere.}\n\n    \\item[sphTriArea]{finds the area of each triangle in a mesh on the unit sphere.  Each element is treated as a spherical triangle, rather than a planar triangle.}\n\n    \\item[surfPsi3D]{colors the surface of a unit sphere according to an orientation distribution function $\\psi (\\pv)$.  This function is designed to display distribution functions calculated by \\texttt{solvePsi3D} and \\texttt{solvePsiARD}.}\n\n    \\item[weightFrac2volFrac]{converts fiber weight fraction to fiber volume fraction for a two-phase composite.}\n    \n    \n\\end{description}\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "27a426c045e6641a9dadf4cc6e282d6e8d703393", "size": 17100, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/LaTeX Source Files/FiberOrientationToolsDoc.tex", "max_stars_repo_name": "charlestucker3/Fiber-Orientation-Tools", "max_stars_repo_head_hexsha": "4047e06f2bf88f349be494c7078a7101e61f57b8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-19T20:38:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-19T20:38:27.000Z", "max_issues_repo_path": "Documentation/LaTeX Source Files/FiberOrientationToolsDoc.tex", "max_issues_repo_name": "charlestucker3/Fiber-Orientation-Tools", "max_issues_repo_head_hexsha": "4047e06f2bf88f349be494c7078a7101e61f57b8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/LaTeX Source Files/FiberOrientationToolsDoc.tex", "max_forks_repo_name": "charlestucker3/Fiber-Orientation-Tools", "max_forks_repo_head_hexsha": "4047e06f2bf88f349be494c7078a7101e61f57b8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.0231660232, "max_line_length": 461, "alphanum_fraction": 0.7497660819, "num_tokens": 4410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.42191917137555285}}
{"text": "\\chapter{Introduction}\n\\todo{regroup into old structure}\nWe are interested in constructive notions of finiteness, formalised in Cubical\nType Theory~\\cite{cohenCubicalTypeTheory2016}.\nIn this paper we will explore five such notions of finiteness, including their\ncategorical interpretation, and use them to build a simple proof-search library\nfacilitated in a fundamental way by univalence.\nAlong the way we will use the Countdown\nproblem~\\cite{huttonCountdownProblem2002} as an example, and provide a program\nwhich produces verified solutions to the puzzle.\nWe will also briefly examine countability, and demonstrate its parallels and\ndifferences with finiteness.\n\\section{The Varieties of Finiteness}\n\\todo{Make all references parenthetical}\nIn Section~\\ref{finiteness-predicates} we will explore a number of different\npredicates for finiteness.\nIn contrast to classical finiteness, in a constructive setting there are many\npredicates which all have some claim to being the formal interpretation of\n``finiteness''~\\cite{coquandConstructivelyFinite2010}.\nThe particular predicates we are interested in are organised in\nFigure~\\ref{finite-classification}: each arrow in the diagram represents a proof\nthat one predicate can be derived from another.\nEach arrow in Figure~\\ref{finite-classification} corresponds to a proof of\nimplication: cardinal finiteness, for instance, with a strict total order,\nimplies split enumerability (Theorem~\\ref{cardinal-to-manifest-bishop}).\n\n\\input{figures/finite-classification}\n\nThese finiteness predicates differ along two main axes: informativeness, and\nrestrictiveness.\nMore ``informative'' predicates have proofs which contain extraneous information\nother than the finiteness of the underlying type: a proof of split enumerability\n(Section~\\ref{split-enumerability}), for instance, comes with a strict total\norder on the underlying type.\n\nThe ``restrictiveness'' of a predicate refers to how many types it admits into\nits notion of ``finite''.\nThere are strictly more Kuratowski finite (Section~\\ref{kuratowski}) types than\nthere are Cardinally finite (Section~\\ref{cardinal-finiteness}).\n\nProofs coming with extra information is a common theme in constructive\nmathematics: often this extra information is in the form of an algorithm which\ncan do something useful related to the proof itself.\nIndeed, our proofs of finiteness here will provide an algorithm to solve the\ncountdown puzzle.\nOccasionally, however, the extra information is undesirable: we may want to\nassert the existence of some value \\(x : A\\) which satisfies a predicate \\(P\\)\nwithout revealing \\emph{which} \\(A\\) we're referring to.\nMore concretely, we will need in this paper to prove that two types are in\nbijection without specifying a particular bijection.\nThis facility is provided by Homotopy Type Theory~\\cite{hottbook} in the form of\npropositional truncation, and it is what allows us to prove the bulk of\npropositions in this paper.\n\nFor each predicate we will also prove its closure properties (i.e.\\ that the\nproduct of two finite sets is finite).\nThe most significant of these closure proofs is that of closure under \\(\\Pi\\)\n(dependent functions) (Theorem~\\ref{split-enum-pi}).\n\\section{Toposes and Finite Sets}\nIn Section~\\ref{topos}, we will explore the categorical interpretation of\ndecidable Kuratowski finite sets.\nThe motivation here is partially a practical one: by the end of this work we\nwill have provided a library for proof search over finite types, and the\n``language'' of a topos is a reasonable choice for a principled language for\nconstructing proofs of finiteness in the style of\nQuickCheck~\\cite{claessenQuickCheckLightweightTool2011} generators.\n\nTheoretically speaking, showing that sets in Homotopy Type Theory form a topos\n(with some caveats) is an important step in characterising the categorical\nimplications of Homotopy Type Theory, first proven\nin~\\cite{rijkeSetsHomotopyType2015}. \\todo{This reference should be citet not citep}\nOur work is a formalisation of this result (and the first such formalisation\nthat we are aware of).\nThe proof that decidable Kuratowski finite sets form a \\(\\Pi\\)-pretopos is\nadditional to that.\n\\section{Countability Predicates}\nAfter the finite predicates, we will briefly look at the infinite countable\ntypes, and classify them in a parallel way to the finite predicates\n(Section~\\ref{infinite}).\nWe will see that we lose closure under function arrows, but we gain it under the\nKleene star (Theorem~\\ref{split-countability-sigma}).\n\\section{Search}\nAll of our work is formalised in Cubical\nAgda~\\cite{vezzosiCubicalAgdaDependently2019}: as a result, the constructive\ninterpretation of each proof is actually a program which can be run on a\ncomputer.\nIn finiteness in particular, these programs are particularly useful for\nexhaustive search.\n\nWe will use the countdown problem as a running example throughout the paper: we\nwill show how to prove that any given puzzle has a finite number of solutions,\nand from that we will show how to enumerate those solutions, thereby solving the\npuzzle in a verified way.\n\nIn Section~\\ref{search} we will package up the ``search'' aspect of finiteness\ninto a library for proof search: similar libraries have been built\nin~\\cite{fruminFiniteSetsHomotopy2018}\nand~\\cite{firsovDependentlyTypedProgramming2015}.\nOur library differs from those in three important ways: firstly, it is strictly\nmore powerful, as it allows for search over function types.\nSecondly, finiteness proofs also provide equivalence proofs to any other finite\ntype: this allows transport of proofs between types of the same cardinality.\nFinally, through generic programming we provide a simple syntax for stating\nproperties which mimics that of QuickCheck.\nWe also ground the library in the theoretical notions of omniscience.\n\\section{Notation and Background}\nWe work in Cubical Type Theory~\\cite{cohenCubicalTypeTheory2016}, specifically\nCubical Agda~\\cite{vezzosiCubicalAgdaDependently2019}.\nCubical Agda is a dependently-typed functional programming language, based on\nMartin-Löf Intuitionistic Type Theory, with a Haskell-like syntax.\n\nBeing a dependently-typed language, we'll have to be clear about what we mean\nwhen we say ``type'' in Agda.\n\\begin{definition}[Type]\n  We use \\(\\AgdaDatatype{Type}\\) to denote the universe of (small) types.\n  The universe level is denoted with a subscript number, starting at 0.\n  ``Type families'' are functions into \\(\\AgdaDatatype{Type}\\).\n\\end{definition}\n\nThe are two broad ways to define types in Agda: as an inductive\n\\(\\AgdaKeyword{data}\\) type, similar to data type definitions in Haskell, or as\na \\(\\AgdaKeyword{record}\\).\nHere we'll define the basic type formers used in MLTT.\\@\n\\begin{definition}[Basic Types]\n  The three basic types---often called 0, 1, and 2 in MLTT---here will be\n  denoted with their more common names: \\(\\bot\\), \\(\\top\\), and\n  \\(\\mathbf{Bool}\\), respectively.\n  \\begin{multicols}{3}\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{bot}\n    \\end{agdalisting}\n\n\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{top}\n    \\end{agdalisting}\n\n\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{bool}\n    \\end{agdalisting}\n  \\end{multicols}\n\\end{definition}\n\\begin{definition}[The Dependent Sum]\n  Dependent sums are denoted with the usual \\(\\Sigma\\) symbol, and has the\n  following definition in Agda:\n\n  \\begin{center}\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{sigma}\n    \\end{agdalisting}\n  \\end{center}\n  We will use different notations to refer to this type depending on the\n  setting.\n  The following four expressions all denote the same type:\n  \\begin{multicols}{4}\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{sigma-syntax-1}\n    \\end{agdalisting} \\columnbreak\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{sigma-syntax-3}\n    \\end{agdalisting} \\columnbreak\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{sigma-syntax-4}\n    \\end{agdalisting} \\columnbreak\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{sigma-syntax-2}\n    \\end{agdalisting}\n  \\end{multicols}\\vspace{-1.5\\baselineskip}%\n  The non-dependent product is a special instance of the dependent.\n  We denote a simple pair of types \\(A\\) and \\(B\\) as \\(A \\times B\\).\n\\end{definition}\n\\begin{definition}[Dependent Product]\n  Dependent products (dependent functions) use the \\(\\Pi\\) symbol.\n  The three following expressions all denote the same type:\n  \\begin{multicols}{3}\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{pi-syntax-1}\n    \\end{agdalisting} \\columnbreak\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{pi-syntax-2}\n    \\end{agdalisting} \\columnbreak\n    \\begin{agdalisting}\n      \\ExecuteMetaData[agda/Snippets/Introduction.tex]{pi-syntax-3}\n    \\end{agdalisting}\n  \\end{multicols}\\vspace{-1.5\\baselineskip}\n  Non-dependent functions are denoted with the arrow (\\(\\rightarrow\\)).\n\\end{definition}\n\nAt this point, as a quick example, we can define the first of our objects for\nthe countdown transformation: the vector of Booleans for selection.\nA vector is relatively simple to define: a vector of zero elements is simply a\nunit, a vector of \\(n+1\\) elements is the product of an element and a vector of\n\\(n\\) elements.\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Data/Vec/Iterated.tex]{vec-def}\n\\end{agdalisting}\nFrom this we can see that a vector of \\(n\\) Booleans has the type\n\\(\\AgdaDatatype{Vec} \\; \\AgdaDatatype{Bool} \\; n\\)\n\nFinally, there is one last thing we must define before moving on to the\nfiniteness predicates: paths.\n\\begin{definition}[Path Types]\\label{path-types}\n  The equality type (which we denote with \\(\\equiv\\)) in CuTT is the type of\n  Paths\\footnotemark.\n  The nature and internal structure of Paths is complex and central to how\n  Cubical Type Theory ``implements'' Homotopy Type Theory, but those details are\n  not relevant to us here.\n  Instead, we only need to know that univalence holds for paths, and path types\n  do indeed compute in Cubical Agda.\n\\end{definition}\n\n\\footnotetext{%\n  Actually, CuTT does have an identity type with similar semantics to the\n  identity type in MLTT.\\@\n  We do not use this type anywhere in our work, however, so we will not consider\n  it here.\n}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../paper\"\n%%% End:\n", "meta": {"hexsha": "c3141f2f110f32b38e4dcd79d62678f731f1d7f6", "size": 10529, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/introduction.tex", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/introduction.tex", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/introduction.tex", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0044642857, "max_line_length": 84, "alphanum_fraction": 0.7789913572, "num_tokens": 2683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.42189964417968473}}
{"text": "\\section{Soundness of Refinement Reflection}\n\nWe prove Theorem~\\ref{thm:safety}\nof \\S~\\ref{sec:types-reflection}\nby reduction to Soundness of \\undeclang~\\citep{Vazou14}. \n\n\\begin{theorem}{[Denotations]}~\\label{tech:thm:denotations}\nIf $\\hastype{\\env}{\\prog}{\\typ}$ then\n$\\forall \\sto\\in \\interp{\\env}. \\applysub{\\sto}{\\prog} \\in \\interp{\\applysub{\\sto}{\\typ}}$.\n\\end{theorem}\n\\begin{proof}\nWe use the proof from~\\citep{Vazou14-tech} and specifically Lemma 4\nthat is identical to the statement we need to prove. \n%\nSince the proof proceeds by induction in the type derivation, \nwe need to ensure that all the modified rules satisfy the statement. \n\\begin{itemize}\n\\item\\rtexact\n Assume \n \t\\hastype{\\env}{e}{\\tref{v}{\\btyp}{\\reft_r\\land v = e}}.\n By inversion\n\t\\hastype{\\env}{e}{\\tref{v}{\\btyp}{\\reft_r}}(1). \n By (1) and IH we get \n $\\forall \\sto\\in \\interp{\\env}. \n   \\applysub{\\sto}{e} \\in \\interp{\\applysub{\\sto}{\\tref{v}{\\btyp}{\\reft_r}}}$.\n We fix a $\\sto\\in \\interp{\\env}$\n We get that if \\evalsto{\\applysub{\\sto}{e}}{w}, \n then $\\evalsto{\\applysub{\\sto}{\\reft_r}\\subst{v}{w}}{\\etrue}$.  \n By the Definition of $=$ we get that \n $\\evalsto{w = w}{\\etrue}$. \n Since $\\evalsto{\\applysub{\\sto}{(v = e)}\\subst{v}{w}}{w = w}$, \n then $\\evalsto{\\applysub{\\sto}{(\\reft_r\\land v = e)}\\subst{v}{w}}{\\etrue}$.  \n Thus\n   $\\applysub{\\sto}{e} \\in \\interp{\\applysub{\\sto}{\\tref{v}{\\btyp}{\\reft_r\\land v = e}}}$\n  and since this holds for any fixed $\\sto$,  \n $\\forall \\sto\\in \\interp{\\env}. \n   \\applysub{\\sto}{e} \\in \\interp{\\applysub{\\sto}{\\tref{v}{\\btyp}{\\reft_r\\land v = e}}}$.\n\\item\\rtlet\n  Assume \n\t\\hastype{\\env}{\\eletb{x}{\\gtyp_x}{e_x}{\\prog}}{\\typ}.  \n  By inversion\n\t\\hastype{\\env, \\tbind{x}{\\gtyp_x}}{e_x}{\\gtyp_x} (1), \n\t\\hastype{\\env, \\tbind{x}{\\gtyp_x}}{\\prog}{\\gtyp} (2), and\n    \\iswellformed{\\env}{\\typ} (3). \n By IH \n\t$\\forall \\sto\\in \\interp{\\env, \\tbind{x}{\\gtyp_x}}. \n\t\\applysub{\\sto}{e_x} \\in \\interp{\\applysub{\\sto}{\\gtyp_x}}$ (1')\n\t$\\forall \\sto\\in \\interp{\\env, \\tbind{x}{\\gtyp_x}}. \n\t\\applysub{\\sto}{\\prog} \\in \\interp{\\applysub{\\sto}{\\gtyp}}$ (2'). \n By (1') and by the type of $\\efix{}$ \n\t$\\forall \\sto\\in \\interp{\\env, \\tbind{x}{\\gtyp_x}}. \n\t\\applysub{\\sto}{\\efix{x}\\ e_x} \\in \\interp{\\applysub{\\sto}{\\gtyp_x}}$. \n By which,  (2') and (3)\n\t$\\forall \\sto\\in \\interp{\\env}. \n\t\\applysub{\\sto}{\\SUBST{\\prog}{x}{\\efix{x}\\ {e_x}}} \\in \\interp{\\applysub{\\sto}{\\gtyp}}$.  \n%% \\NV{CHECK}\n\\item\\rtreflect\n  Assume \n  \\hastype{\\env}{\\erefb{f}{\\gtyp_f}{e}{\\prog}}\n\t\t\t    {\\typ}. \n  By inversion, \n    \\hastype{\\env}{\\eletb{f}{\\exacttype{\\gtyp_f}{e}}{e}{\\prog}}\n\t\t\t     {\\typ}. \n  By IH, \n \t$\\forall \\sto\\in \\interp{\\env}. \n\t\\applysub{\\sto}{\\eletb{f}{\\exacttype{\\gtyp_f}{e}}{e}{\\prog}} \\in \\interp{\\applysub{\\sto}{\\gtyp}}$.  \n  Since denotations are closed under evaluation, \n\t$\\forall \\sto\\in \\interp{\\env}. \n\t\\applysub{\\sto}{\\erefb{f}{\\exacttype{\\gtyp_f}{e}}{e}{\\prog}} \\in \\interp{\\applysub{\\sto}{\\gtyp}}$.  \n\n\\item\\rtfix\n  In Theorem 8.3 from~\\citep{Vazou14-tech} (and using the textbook proofs from~\\citep{PLC})\n  we proved that for each type $\\typ$, $\\efix{}_\\typ \\in \\interp{(\\typ \\rightarrow \\typ) \\rightarrow \\typ}$.\n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}{[Preservation]}\nIf \\hastype{\\emptyset}{\\prog}{\\typ}\n       and $\\evalsto{\\prog}{w}$ then $\\hastype{\\emptyset}{w}{\\typ}$.\n\\end{theorem}\n\\begin{proof}\nIn~\\citep{Vazou14-tech} proof proceeds by iterative application \nof Type Preservation Lemma 7. \n%\nThus, it suffices to ensure Type Preservation in \\corelan, which \nit true by the following Lemma.\n\\end{proof}\n\n\\begin{lemma}\nIf \\hastype{\\emptyset}{\\prog}{\\typ}\n       and $\\evals{\\prog}{\\prog'}$ then $\\hastype{\\emptyset}{\\prog'}{\\typ}$.\n\\end{lemma}\n\\begin{proof}\nSince Type Preservation in \\undeclang is proved by induction on the type derivation tree, \nwe need to ensure that all the modified rules satisfy the statement. \n\\begin{itemize}\n\\item\\rtexact\n Assume \n \t\\hastype{\\emptyset}{\\prog}{\\tref{v}{\\btyp}{\\reft_r\\land v = \\prog}}.\n By inversion\n\t\\hastype{\\emptyset}{\\prog}{\\tref{v}{\\btyp}{\\reft_r}}.\n By IH we get \n\t\\hastype{\\emptyset}{\\prog'}{\\tref{v}{\\btyp}{\\reft_r}}.\n By rule \\rtexact we get \n \t\\hastype{\\emptyset}{\\prog'}{\\tref{v}{\\btyp}{\\reft_r\\land v = \\prog'}}.\n Since subtyping is closed under evaluation, we get \n \t\\issubtype{\\emptyset}{\\tref{v}{\\btyp}{\\reft_r\\land v = \\prog'}}\n \t                {\\tref{v}{\\btyp}{\\reft_r\\land v = \\prog}}.\n By rule \\rtsub we get \n \t\\hastype{\\emptyset}{\\prog'}{\\tref{v}{\\btyp}{\\reft_r\\land v = \\prog}}.\n\n\\item\\rtlet\n  Assume \n\t\\hastype{\\emptyset}{\\eletb{x}{\\gtyp_x}{e_x}{\\prog}}{\\typ}.\n By inversion, \n   \\hastype{\\tbind{x}{\\gtyp_x}}{e_x}{\\gtyp_x}  (1), \n   \\hastype{\\tbind{x}{\\gtyp_x}}{\\prog}{\\gtyp} (2), and\n   \\iswellformed{\\env}{\\typ} (3). \n By rule \\rtfix\n   \\hastype{\\tbind{x}{\\gtyp_x}}{\\efix{x}\\ {e_x}}{\\gtyp_x}  (1').\n By (1'), (2) and Lemma 6 of~\\citep{Vazou14-tech}, we get \n   \\hastype{}{\\SUBST{\\prog}{x}{\\efix{x}\\ {e_x}}}{\\SUBST{\\gtyp}{x}{\\efix{x}\\ e_x}}. \n By (3)\n   $ \\SUBST{\\gtyp}{x}{\\efix{x}\\ e_x} \\equiv \\gtyp$.    \n Since \n   $\\prog' \\equiv \\SUBST{\\prog}{x}{\\efix{x}\\ {e_x}}$, \n we have \n \\hastype{\\emptyset}{\\prog'}{\\gtyp}. \n\n\\item\\rtreflect\n  Assume \n\t\\hastype{\\emptyset}{\\erefb{x}{\\gtyp_x}{e_x}{\\prog}}{\\typ}.\n By double inversion, with $\\gtyp_x' \\equiv \\exacttype{\\gtyp_x}{e_x} $; \n   \\hastype{\\tbind{x}{\\gtyp_x'}}{e_x}{\\gtyp_x'}  (1), \n   \\hastype{\\tbind{x}{\\gtyp_x'}}{\\prog}{\\gtyp} (2), and\n   \\iswellformed{\\env}{\\typ} (3). \n By rule \\rtfix\n   \\hastype{\\tbind{x}{\\gtyp_x'}}{\\efix{x}\\ {e_x}}{\\gtyp_x'}  (1').\n By (1'), (2) and Lemma 6 of~\\citep{Vazou14-tech}, we get \n   \\hastype{}{\\SUBST{\\prog}{x}{\\efix{x}\\ {e_x}}}{\\SUBST{\\gtyp}{x}{\\efix{x}\\ e_x}}. \n By (3)\n   $ \\SUBST{\\gtyp}{x}{\\efix{x}\\ e_x} \\equiv \\gtyp$.    \n Since \n   $\\prog' \\equiv \\SUBST{\\prog}{x}{\\efix{x}\\ {e_x}}$, \n we have \n \\hastype{\\emptyset}{\\prog'}{\\gtyp}. \n\n\\item\\rtfix\n  This case cannot occur, as $\\efix{}$ does not evaluate to any program. \n\\end{itemize}\n\\end{proof}\n", "meta": {"hexsha": "e2365b5689dc820d1f1052b93957ff609da9f2b3", "size": 5934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/refinementreflection/soundness.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/refinementreflection/soundness.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/refinementreflection/soundness.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 39.0394736842, "max_line_length": 108, "alphanum_fraction": 0.6226828446, "num_tokens": 2347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4218996398404729}}
{"text": "\\chapter{Conclusions and Recommendations}\\label{chap:conclusions}\n\\section{Summary}\nIn this thesis we investigated new methods for computing the target photometric variables based on \\textit{phase space ray tracing}. The aim was to understand how light propagates through non-imaging optical systems in order to calculate the target photometric variables, e.g., luminance and intensity. \nThe core of this work was to use the \\textit{phase space} (PS) which provides a full description of geometric optics. In this thesis we restricted ourselves to two-dimensional optical systems, the PS of which is a two-dimensional space. For every ray traced inside the system its path can be considered where a path is the sequence of the optical lines that it encounters. The PS representation of the optical system shows that all the rays that follow the same path are located inside the same region in PS which is therefore divided into patches. \nThose parts of the target PS that are illuminated by the source are the positive luminance regions, on the others parts the luminance is equal to zero. Our idea was to determine the boundaries of the positive luminance regions to reduce the number of rays needed for obtaining the photometric variables. In particular, assuming a Lambertian source, the coordinates of the rays located on the boundaries give all the information needed to compute the output luminance and therefore the intensity.\nTo this purpose, we developed two methods: \\emph{PS ray tracing} and \\emph{backward ray mapping} in PS. The goal of both is to trace only the rays close to the boundaries reducing the total number of rays traced compared to existing methods, for example Monte Carlo (MC) and Quasi-Monte Carlo (QMC) ray tracing.\n\\\\ \\\\ \\indent \\emph{PS ray tracing} exploits the PS of the source and the target of the optical system. %In Chapter \\ref{chap:PS} \nWe introduced an accurate procedure to construct a triangulation on source PS which allows tracing most of the rays close to the boundaries of the positive luminance regions. \nThe boundaries of those regions were approximated using two different approaches: the $\\alpha$-shapes method and a technique based on triangulation refinement. \\\\ \\indent \nThe $\\alpha$-shapes method relies on a parameter $\\alpha$ which establishes which triangles have to be kept in the PS triangulation and which have to be removed to approximate the boundaries correctly. We developed a procedure based on \\'{e}tendue conservation to determine the value of $\\alpha$ that gives a good approximation of the boundaries.\n%The $\\alpha$-shape method was explained in Chapter \\ref{chap:boundaries_alpha} and \nNumerical results were provided for two different kinds of TIR-collimators showing that PS ray tracing using $\\alpha$-shapes is much faster and more accurate than MC ray tracing. However, we observed that the speed of convergence depends on the smoothness of the shape of the regions in target PS and, therefore, on the optical system. \\\\ \\indent To eliminate the parameter $\\alpha$ from the calculation of the boundaries, we developed a new approach for the boundaries computation based on triangulation refinement. \n%explained in Chapter \\ref{chap:triangulation}. \nThis technique is able to determine the boundary triangles (triangles crossed by at least one boundary) of a given triangulation. Connecting the vertices of the boundary triangles corresponding to rays that follow the same path, a good approximation of all the boundaries is obtained. Tracing more rays leads to smaller triangles resulting in a better accuracy of the boundary computation. The stopping criterion employs \\'{e}tendue conservation. \nThe method was applied to several optical systems with reflective and refractive optical lines. The results show that the boundaries of all the regions with positive luminance in target PS are calculated correctly even for complicated systems such as the parabolic reflector for which multiple reflections of the rays with the mirrors can occur. \n\nAssuming a Lambertian source, the intensity was computed from the coordinates of the rays on the boundaries. \nThe intensity profile obtained using PS ray tracing based on the triangulation refinement is compared to the two intensities found with MC and QMC ray tracing. PS ray tracing allows us tracing far less rays compared to MC ray tracing resulting in a significant reduction of the computational time. Our method has an order of convergence proportional to the reciprocal of the number of rays traced versus an error convergence proportional to the inverse of the square root of the number of rays traced for MC ray tracing. The results showed that PS ray tracing and QMC ray tracing are comparable in terms of the computational time, indeed the corresponding convergence errors are proportional to the inverse of the number of rays traced. For the TIR-collimator, for example, PS ray tracing outperforms also QMC ray tracing while it is slower than QMC for some other systems as, for example, the parabolic reflector. However, we demonstrated in simulations that PS ray tracing is bin-free while MC and QMC errors depend on the number of bins in which the target is divided.\nIn order to further improve PS ray tracing we developed a second method, \\emph{backward ray mapping}, which allows tracing only the rays located \\emph{exactly} on the boundaries of the regions with positive luminance. \n\\\\ \\\\ \\indent The key idea of this method is to construct an inverse map from target to source connecting the coordinates of the rays on the PS of each optical line encountered. \\\\ \\indent \n%In Chapter \\ref{chap:raymapping1} \nWe presented \\emph{concatenated backward ray mapping} applicable to systems formed by straight line segments. It considers \\textit{all} the lines that form the system. We showed that the boundaries of the regions in every PS can be calculated \\textit{analytically}. Therefore, assuming a Lambertian source, concatenated backward ray mapping calculates the intensity \\textit{exactly}. Compared to QMC ray tracing the new method is much more accurate and also faster. \n\n%In Chapter \\ref{chap:raymapping2} \nNext, we introduced direct backward ray mapping which is a modification of concatenated backward ray mapping to systems formed by curved lines. In this case the boundaries of the positive luminance regions in all the phase spaces cannot be calculated analytically, therefore a bisection procedure combined with backward ray tracing is developed. As a consequence the \\textit{exact} target intensity cannot be obtained for systems formed by curved lines. Nevertheless, the method remains very accurate and numerical results showed that it is also able to detect \\textit{unphysical} paths due to numerical error, where we referred to physical paths as those from the source to the target. Direct backward ray mapping provides a more accurate intensity distribution in less time compared to QMC ray tracing. To achieve an error of around $10^{-6}$, direct backward ray mapping is approximately $10^3$ times faster than QMC ray tracing for the TIR-collimator and $10^2$ times faster for the parabolic reflector. In Figure \\ref{fig:error_comparison} we show an error comparison between all the methods applied to the TIR-collimator (left figure) and the parabolic reflector (right figure). \nWe remark that while MC and QMC ray tracing are binning procedures, thus, the averaged intensity is computed, PS ray tracing and direct backward ray mapping compute the intensity point-wise. To compare the methods we calculated the averaged intensities also for PS ray tracing and direct backward ray mapping. Therefore, also for the PS procedures the target was divided into bins and the mean value of the intensity over every bin was computed. This mean value was given by the integral of the intensity over every bin divided by the size of the bin. In the simulations showed in this thesis, the integral was approximated by the trapezoidal rule discretizing the bin into $10$ sub-intervals of equal length. The CPU-times of the PS methods shown in Figure \\ref{fig:error_comparison}, is divided by $10$ to obtain the real CPU-time when the PS methods are not compared with binning procedures.\n\\begin{figure}[t]\n\\label{fig:error_comparison}\n \\begin{subfigure}[t]{0.49\\textwidth}\n\\centering\n    \\includegraphics[width = \\textwidth]{error_time_tir_all_methods}\n    \\caption{Error plot for the TIR-collimator.}\n\\end{subfigure}\n\\hfill\n\\begin{subfigure}[t]{0.49\\textwidth}\n\\centering\n    \\includegraphics[width = \\textwidth]{error_time_pr_all_methods}\n    \\caption{Error plot for the parabolic reflector.}\n\\end{subfigure}\n\\caption{\\textbf{Comparison between MC, QMC, PS ray tracing and direct backward ray mapping.}}\n\\label{fig:error_comparison}\n\\end{figure}\n\\\\ \\indent\n%in Chapter \\ref{chap:fresnel}\nFinally, we investigated systems where also Fresnel reflections are involved. Fresnel reflection leads to multiple paths due to the fact that, at every interaction with a line, each ray is split in two rays (the reflected and the transmitted) each of them carries a fraction of the energy transported by the incident ray. Direct backward ray mapping is able to detect \\textit{all} the possible paths that can occur. Moreover, we showed that only the rays located on the boundaries of the positive luminance regions in target PS related to the \\textit{physical} paths are traced from target to source. To validate our method we traced forward a set of rays using MC ray tracing and we showed that the boundaries found with direct backward ray mapping enclose all the rays traced. The power associated to each ray on the boundary is calculated. For Fresnel systems the output luminance is not constant as it depends on the angles of incidence of every line and on the path followed. Therefore a sample of rays inside the positive luminance regions needs to be traced back to compute the luminance and the intensity.\n\\\\ \\\\ \\indent To conclude we claim that PS methods might constitute alternative approaches to conventional ray tracing. The advantages are that far less rays are needed for computing the target photometric variables resulting in a reduction of the computational time. In particular, PS ray tracing is easy to implement and faster than MC ray tracing. For some systems it outperforms also QMC ray tracing while for some others the boundaries of the positive luminance regions could be difficult to approximate and more rays are required. Because of this, in some cases PS ray tracing can be slightly slower than QMC ray tracing. Direct backward ray mapping can be seen as an improvement of PS ray tracing as it is much more accurate. It allows tracing far less rays compared to MC, QMC and PS ray tracing, directly determining the rays on the boundaries of the positive luminance regions. Direct backward ray mapping is a very elegant method and, compared to MC and QMC ray tracing it is faster and much more accurate. This method could be used also to detect and minimize ghost stray light. \n\\section{Recommendations}\n%For every boundary and along every direction, a sample of rays with position coordinates located between the rays on the boundaries need to be traced back in order to obtain the profile of the partial luminance along every direction. The total luminance is the sum of all the partial luminance related to each path. Finally the intensity cou \n%\\\\ \\\\ \\indent In this thesis we showed that phase space is a powerful concept that fully characterize the optical systems. We presented two new methods based on phase space which allow traced far less rays than existing procedures to obtain the desired accuracy. This results in a significant reduction of the computational time. We evaluated the method for several optical systems in two-dimensions.\nThis work is far from finished. In the future, it might be useful to investigate in more details the two-dimensional case. The two-dimensional case is particularly relevant because it is a good test for new methods. Moreover it gives a complete analysis of three-dimensional rotationally symmetric systems as it fully describe of the meridional plane.\\\\ \\indent \nRegarding PS ray tracing, it could be interesting to analyze systems with a non-Lambertian source. Our proposal is to calculate the boundaries as we have done for a Lambertian source. Next, the profile of the luminance can be obtained by tracing a sample of rays with corresponding coordinates in the interior of the boundaries found. The intensity can be obtained by merely integrating the luminance over all the possible positions. \\\\ \\indent \nRegarding direct backward ray mapping, we are interested in providing simulations for systems with Fresnel reflection. The results shown in Chapter \\ref{chap:fresnel} give the expectation that the direct backward ray mapping method is suitable also for such systems and that it is much more precise and faster than both MC and QMC ray tracing. Scattering phenomena could be described by generalizing direct backward ray mapping for Fresnel systems. More paths would occur because, at every intersection, each ray can be split in more than two rays as it scatters in multiple directions. The range of possible directions can be discretized and a path can be associated to each direction. We expect that the same algorithm used for Fresnel's reflections can be applied to every single path in case of scattering.\n%Furthermore colour\n \\\\ \\indent \nFuture research should address the three-dimensional case. The first step could be to consider rotationally symmetric optical systems, i.e., systems invariant under rotations around the optical axis. Such systems are often used in illumination optics as they are easy to manufacture. They can be described by only considering the meridional rays, that is rays that propagate inside the plane containing the optical axis. This reduces the three-dimensional case to the two-dimensional one. \nFor rotationally symmetric systems PS ray tracing and backward ray mapping might constitute design tool for optical designers, greatly reducing the time to design the optical systems. \n\\\\ \\indent  Next, it can be useful to analyze asymmetric optical systems \\cite{ries1997performance}. Every ray is described by three position and two direction coordinates. The corresponding PS is therefore a four dimensional space described by two of the position coordinates $\\variabile{q}_1$ and $\\variabile{q}_2$ of the intersection point between the ray and the optical surface and two direction coordinates $\\variabile{p}_1$ and $\\variabile{p}_2$, expressed with respect to the normal of the surface. \nThe target luminance in PS is a function of all these coordinates, while the intensity only depends on the direction coordinates and is given by a two-dimensional integral of the luminance over all the position coordinates $\\variabile{q}_1$ and $\\variabile{q}_2$. \nTherefore, for fixed directions $\\variabile{p}_1$ and $\\variabile{p}_2$, we need to compute the boundaries of the positive luminance regions in the $(\\variabile{q}_1, \\variabile{q}_2)$-plane. \n%In PS line in the two-dimensional case will become a surface in the three-dimensional case. \n\nTo clarify our idea, we report a picture of the structure of the target of a three-dimensional system showed in \\cite{winston2005nonimaging} by Winston, Mi\\~nano and Benitez.\nIn particular, they show the target of a CPC seen from above (constant direction). For example, Figure \\ref{fig:melettaC} shows the regions in the $(\\variabile{q}_1, \\variabile{q}_2)$-plane at the target of rays that leave the source with given angular coordinates. The regions labeled $0, 1, 2,$... correspond to the regions that arrive at the target after after $0, 1, 2, \\cdots$ reflections; $F2, F3,$... indicate the regions of the rays that begin to turn back after two, three, $\\cdots$ reflections. The blank regions are formed by the rays that\nstill be traveling toward the exit aperture after five reflections. \n\\begin{figure}[h]\n\\centering\n    \\includegraphics[width = 0.6\\textwidth]{MelettaD}\n    \\caption{Regions at the target of a CPC of rays that leave the source with a fixed direction found using ray tracing. \\cite{winston2005nonimaging}.}\n\\label{fig:melettaC}\n\\end{figure}\n%In target PS the luminance is positive inside four dimensional objects. Hence the $2$D positive luminance regions at the target PS of two-dimensional systems become $4$D objects at the target PS of three-dimensional systems. The intensity along fixed directions $(\\variabile{p}_1, \\variabile{p}_2)$ is given by the integral of the luminance over all the possible positions $(\\variabile{q}_1, \\variabile{q}_2)$. Assuming a Lambertian source, we only need to compute the rays located on the boundaries of the $4$D positive luminance regions. Those boundaries are now surfaces instead of lines. Phase space ray tracing should deal with $5$-cell, that is a four-dimensional object bounded by $5$ tetrahedra cells. The boundaries of the regions with positive luminance (now triangular faces instead of lines) can be approximated either using four-dimensional $\\alpha$-shapes (see for instance \\cite{cazals2005conformal, teichmann1998surface}) or considering those triangular faces of each tethraedron located on one side of the boundaries of the region corresponding to a given path. Using the edge-ray principle the target boundaries are found and, therefore, the target photometric variables can be computed. Although the three-dimensional case will imply a more complicated structure of the PS and of the algorithm for surface reconstruction, we believe that phase space ray tracing is suitable in three dimensions. \n%We expect that for the boundaries reconstruction based on the triangulation refinement the speed of convergence will remain proportional to the inverse of the square root of the number of rays traced as every time that the tethraeda are halved the difference between the approximated \\'{e}tendue at the target and the real \\'{e}tendue should half.\n%%\n%\\\\ \\indent \n%On the other hand, direct backward ray mapping extended to three-dimensional systems would be more complicated in a four dimensional target PS. Our idea is to discretize the hypercube into planes fixing both direction coordinates. Next, the bisection procedure can be applied fixing one of the two position $\\variabile{q}_2$ coordinates and varying the other $\\variabile{q}_1$. Repeating the procedure for all the possible values of $\\variabile{q}_2$ would allow tracing back the rays located on the boundaries of the regions with positive luminance in the plane $(\\variabile{q}_1, \\variabile{q}_2)$ for fixed directions. In case of non Lambertian source, the luminance along those directions can be obtained tracing back a sample of rays inside those regions. Varying the direction coordinates $(\\variabile{p}_1, \\variabile{p}_2)$ and repeating the procedure for all the possible directions, the luminance can be calculated. The intensity profile is finally obtained by a two-dimensional integral over all the possible position coordinates. \n%\\\\ \\indent \n\nWe expect that both methods presented in this thesis can be extended to the three-dimensional case. PS ray tracing will be based on a triangulation reconstruction on the $(\\variabile{q}_1, \\variabile{q}_2)$-plane. The same procedure applied for the two-dimensional case in the $(\\variabile{q}_1, \\variabile{p}_1)$-plane can be applied to the $(\\variabile{q}_1, \\variabile{q}_2)$-plane for the three-dimensional case. This will allow to detect the boundaries of the positive luminance regions along the fixed directions $\\variabile{p}_1$ and $\\variabile{p}_2$. Repeating the triangulation refinement procedure for all the possible directions, all the boundaries can be determined. Also, for the direct backward ray mapping in three-dimensions, we can apply the same bisection procedure combined with the backward ray mapping used for the two-dimensional case. The only difference is that in $2$D we detected the boundaries of the positive luminance regions in the $(\\variabile{q}_1, \\variabile{p}_1)$-plane, while in $3$D we need to compute those boundaries in the $(\\variabile{q}_1, \\variabile{q}_2)$-plane and repeat the procedure for every $\\variabile{p}_1$ and $\\variabile{p}_2$.\n\nAlthough, the results showed for the two-dimensional case are very promising, we cannot predict the speed of convergence for the three-dimensional asymmetric optical systems. We expect that this would depend on the complexity of optical devices and of the corresponding regions in target PS. More research should be oriented on this topic.\n", "meta": {"hexsha": "80527e102343b6f325b196e606c14a31489255be", "size": 20629, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/Conclusions.tex", "max_stars_repo_name": "melaniafilosa/ps_raytracing", "max_stars_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/Conclusions.tex", "max_issues_repo_name": "melaniafilosa/ps_raytracing", "max_issues_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/Conclusions.tex", "max_forks_repo_name": "melaniafilosa/ps_raytracing", "max_forks_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 254.6790123457, "max_line_length": 1415, "alphanum_fraction": 0.8048378496, "num_tokens": 4384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.4218996308937386}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsubsection{FCN-DenseNet model}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\r\nFCN-DenseNet which was introduced in~\\cite{Jegou} was applied in our previous work~\\cite{Ijjeh2021} for image segmentation.\r\nThe results were promising since it outperformed the conventional damage detection technique i.e (adaptive wavenumber filtering method). \r\nFCN-DenseNet has a U-shape of the encoder-decoder scheme with skip connections between the downsampling and the upsampling paths to increase the resolution to the final feature map.\r\nThe main component in FCN-DenseNet is the dense block.\r\nThe dense block is constructed from \\(n\\) varying number of layers, each layer consists of a series of operations as shown in Table~\\ref{layers}.\r\nThe purpose of the dense block is to concatenate the input (\\(x\\)) (feature maps) of a layer with its output (feature maps) to emphasize spatial details information.\r\nIn this work, we have updated the FCN-DenseNet model by increasing the number of dense blocks and the learnable parameters (filters).\r\nThe architecture of the dense block is presented in Fig.~\\ref{dense_block}. \r\n\\begin{figure} [h!]\r\n\t\\begin{center}\r\n\t\t\\includegraphics[scale=1.0,angle=-90]{DenseBlock_layer.png}\r\n\t\\end{center}\r\n\t\\caption{Dense block architecture.} \r\n\t\\label{dense_block}\r\n\\end{figure}\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nTo reduce the spatial dimensionality of the produced feature maps, a transition down layer was added to perform a (\\(1\\times 1\\)) convolution followed by (\\(2\\times2\\)) Maxpooling operation. \r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nConsequently, to recover the spatial resolution, a transition-up layer was added. \r\nIt applies a transpose convolution operation to upsample feature maps from the previous layer.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nFeature maps emerging from upsampling are concatenated with the ones resulting from the skip connection forming the input to a new dense block.\r\nDuring the upsampling, the input to the dense block is not concatenated with its output to overcome the overhead of memory shortage since the upsampling path expands the spatial resolution of the feature maps. \r\n%(hint:- We can refer to previous paper and say that the same architecture was applied here. Than we can skip Fig.~\\ref{fcn}).\r\n%\\begin{figure} [h!]\r\n%\t\\begin{center}\r\n%\t\t\\includegraphics[scale=1.0]{FCN_dense_net.png}\r\n%\t\\end{center}\r\n%\t\\caption{FCN-DenseNet architecture.} \r\n%\t\\label{fcn}\r\n%\\end{figure}\r\nTable~\\ref{layers} presents the architecture of a single layer, the transition down  and transition up layers in details.\r\n%Figure~\\ref{fcn} illustrates the FCN-DenseNet architecture for image segmentation used for delamination detection.\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{table}[h!]\r\n\t\\renewcommand{\\arraystretch}{1.3}\r\n\t\\centering\r\n\t\\scriptsize\r\n\t\\resizebox{\\textwidth}{!}\r\n\t{\r\n\t\\begin{tabular}{ccccc}\r\n\t\t\\hline\r\n\t\tLayer &  &  Transition Down &  &  Transition Up \\\\ \r\n\t\t\\hline\r\n\t\tBatch Normalization &  & Batch Normalization &  &  \\(3\\times 3\\) Transposed Convolution  \\\\ \r\n\t\tRelu &  & Relu &  & strides = (\\(2\\times2\\))  \\\\ \r\n\t\t(\\(3\\times3\\)) Convolution &  & (\\(1\\times1\\)) Convolution &  &  \\\\ \r\n%\t\t&  &   \\\\ \r\n\t\tDropout \\(p=0.2\\) &  &Dropout \\(p=0.2\\)  &  &  \\\\ \r\n\t\t &  & (\\(2\\times2\\)) Maxpooling &  &  \\\\ \r\n\t    \\hline\r\n\t\\end{tabular}\r\n\t}\r\n\t\\caption{Layer, Transition Down and Transition Up layers.} \r\n\t\\label{layers}\r\n\t\r\n\\end{table}\\\\\r\n", "meta": {"hexsha": "156963aa9a5a361c80d009c23a7ff8a3fde3e441", "size": 3602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/journal_papers/MSSP_2/fcn_densenet_model.tex", "max_stars_repo_name": "IFFM-PAS-MISD/aidd", "max_stars_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-03T05:36:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:36:07.000Z", "max_issues_repo_path": "reports/journal_papers/MSSP_2/fcn_densenet_model.tex", "max_issues_repo_name": "IFFM-PAS-MISD/aidd", "max_issues_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/journal_papers/MSSP_2/fcn_densenet_model.tex", "max_forks_repo_name": "IFFM-PAS-MISD/aidd", "max_forks_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.0491803279, "max_line_length": 211, "alphanum_fraction": 0.6524153248, "num_tokens": 893, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4218996308937385}}
{"text": "\\chapter{Einleitung}\\label{einleitung}\nEs ist oft möglich, Probleme als eine Sequenz $x_{1}, x_{2}, x_{3} \\dots x_{n}$, für \nwelche die Bedingung $P_{n}(x_{1}, x_{2}, x_{3} \\dots x_{n})$ gelten soll, darzustellen.\nDamit Backtracking zu deren Lösung eingesetzt werden kann, müssen außerdem noch\nUntereigenschaften $P_{v}(x_{1}, x_{2}, x_{3} \\dots x_{v})$ für alle $v \\in [ \\, 0, n) \\,$ \nmit folgenden Eigenschaften existieren:\n\\begin{enumerate}\n  \\item $P_{0}()$ gilt immer\n  \\item $P_{v + 1}(x_{1}, x_{2}, x_{3} \\dots x_{v + 1})$ gilt nur, wenn $P_{v}(x_{1}, x_{2}, x_{3} \\dots x_{v})$ gilt\n  \\item wenn $P_{v}(x_{1}, x_{2}, x_{3} \\dots x_{v})$ gilt, ist $P_{v + 1}(x_{1}, x_{2}, x_{3} \\dots x_{v+1})$ einfach zu testen\n\\end{enumerate}\n\nSomit kann man alle Sequenzen $x_{1}, x_{2}, x_{3} \\dots x_{v} \\dots x_{q}$ mit $q > v$ ignorieren,\nfalls $P_{v}(x_{1}, x_{2}, x_{3} \\dots x_{v})$ nicht gilt.\nDer darauf basierende Backtracking Algorithmus \\textbf{B} kann nun wie folgt implementiert werden:\n\\begin{minted}[linenos, fontsize=\\small]{rust}\npub fn b<T: Sequence>(initial: T, n: usize) -> Vec<T> {\n    if !initial.satisfies_condition() {\n        return Vec::new();\n    } else if n == 0 {\n        return vec![initial];\n    }\n\n    // all sequences of length n which satisfy the condition\n    let mut results = Vec::new();\n\n    // the current sequence, starts with just the initial state\n    let mut states = Vec::new();\n\n    let steps = initial.next_steps().into_iter();\n    states.push((initial, steps));\n\n    // run while there is still a state with an unchecked next step\n    while let Some((state, steps)) = states.last_mut() {\n        // take the next unchecked possible step of the current state,\n        // in case there are no unchecked steps left,\n        // simply discard the current state as all possible\n        // sequences have already been tried.\n        if let Some(step) = steps.next() {\n            // compute the result of this step\n            let next_state = state.apply_step(step);\n            // does this new state still satisfy the condition,\n            // if not we can simply discard it\n            if next_state.satisfies_condition() {\n                // if the sequence is already n elements long,\n                // it is correct and can be added to results.\n                // Otherwise we push it onto the stack.\n                if states.len() < n {\n                    let next_steps = next_state.next_steps().into_iter();\n                    states.push((next_state, next_steps));\n                } else {\n                    results.push(next_state);\n                }\n            }\n        } else {\n            states.pop();\n        }\n    }\n\n    results\n}\n\\end{minted}\n\nUm ein Problem mit diesem Algorithmus lösen zu können, benötigt man einen Datentyp, welcher den momentanen Zustand\nder Sequenz speichern kann und das folgende Interface implementiert:\n\\begin{minted}[linenos, fontsize=\\small]{rust}\n/// A required set of methods needed for the generic backtracking algorithms.\npub trait Sequence {\n    type Step;\n    type Steps: IntoIterator<Item = Self::Step>;\n\n    /// Checks if this sequence satisfies its condition.\n    ///\n    /// This function can assume that the  parent of `self` satisfied this condition.\n    fn satisfies_condition(&self) -> bool;\n\n    /// generates all possible next steps at this current state.\n    fn next_steps(&self) -> Self::Steps;\n\n    /// applies a `step` to `self`, returning the resulting sequence.\n    ///\n    /// this function will only be called if `self.satisfies_condition() == true`.\n    fn apply_step(&self, step: Self::Step) -> Self;\n}\n\\end{minted}", "meta": {"hexsha": "e8c949993b9d0b9e85d066a5c3401f2423744fbb", "size": 3632, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/demoFile_einleitung.tex", "max_stars_repo_name": "lcnr/backtracking", "max_stars_repo_head_hexsha": "3ea6c1e913aa61b43b7bd5a106410c1aa2d7c3df", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/demoFile_einleitung.tex", "max_issues_repo_name": "lcnr/backtracking", "max_issues_repo_head_hexsha": "3ea6c1e913aa61b43b7bd5a106410c1aa2d7c3df", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/demoFile_einleitung.tex", "max_forks_repo_name": "lcnr/backtracking", "max_forks_repo_head_hexsha": "3ea6c1e913aa61b43b7bd5a106410c1aa2d7c3df", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.7294117647, "max_line_length": 128, "alphanum_fraction": 0.6258259912, "num_tokens": 982, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6442251064863695, "lm_q1q2_score": 0.42189962655452673}}
{"text": "\\documentclass[notes,11pt, aspectratio=169]{beamer}\n\\usepackage[default]{lato}\n\n\n\\input{lec_style.tex}\n\n\n%----------------------------------------------------------------------------------------\n  %\tTITLE PAGE\n%----------------------------------------------------------------------------------------\n\\title[DAR]{Data Analytics with R}  % The short title appears at the bottom of \n\\author{Sumit Mishra} % Your name\n\\institute[IFMR] % Your institution as it will appear on the bottom of every slide, may be shorthand to save space\n{\n  Institute for Financial Management and Research, Sri City \\\\ % Your institution for the title page\n  \\medskip\n  \\medskip\n  \\textbf{Linear Regression} % Your email address\n}\n\\date{23 December 2020} % Date, can be changed to a custom date\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n  % Begin document\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Title page\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n  \n {\n    \\addtocounter{framenumber}{-1} \n    {\\removepagenumbers \n      %\\usebackgroundtemplate{\\includegraphics[width=\\paperwidth]{../OpenIntro_Grid_4_3-01.jpg}}\n      \\begin{frame}\n      \n      %\\hfill \\includegraphics[width=20mm]{../oiLogo_highres}\n      \n      \\titlepage\n      \n      \\end{frame}\n    }\n  }\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Sections\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Line fitting, residuals, and correlation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Fitting a line to data}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Modeling numerical variables}\n\nIn this unit we will learn to quantify the relationship between two numerical variables, as well as modeling numerical response variables using a numerical or categorical explanatory variable.\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Asset Poverty vs. Literacy Rate}\n\nThe \\hl{scatterplot} below shows the relationship between literacy rate in all 640 Indian districts and the \\% of households who don't own any assets.\n\n\\twocol{0.55}{0.45}{\n\\begin{center}\n\\includegraphics[width=\\textwidth]{graphs/l08f01}\n\\end{center}\n}\n{\n\\dq{Outcome variable?}\n\\pause\n\\soln{proportion of households without any assets}\n\\pause\n\\dq{Predictor variable?}\n\\pause\n\\soln{literacy proportion}\n\\pause\n\\dq{Relationship?}\n\\pause\n\\soln{linear, negative, moderately strong}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Using a linear regression to predict poverty}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\nThe linear model for predicting asset-poverty from literacy rate in India is\n\n\\[ \\hat{\\text{poverty}} = 0.618 - 0.66 * prop_{Lit} \\]\n\nThe ``hat\" is used to signify that this is an estimate.\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\n\\dq{The literacy rate in Akola is 77.8\\%. What asset-poverty level does the model predict for this district?}\n\n\\pause\n\n\\[ 0.618 - 0.66 * 0.778 = 0.102 \\]\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Eyeballing the line}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Eyeballing the line}\n\n\\twocol{0.3}{0.7}\n{\n\\pq{Which of the following appears to be the line that best fits the linear relationship between \\% in poverty and \\% literate? Choose one.}\n\\soln{\\only<2>{\\orange{\n(a)\n}}}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/l08f02}\n\\end{center}\n}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Residuals}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Residuals}\n\n\\hl{Residuals} are the leftovers from the model fit: Data = Fit + Residual\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{graphs/l08f03}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Residuals (cont.)}\n\n\\formula{Residual}{\nResidual is the difference between the observed ($y_i$) and predicted $\\hat{y}_i$. \n\\[ e_i = y_i - \\hat{y}_i \\]\n}\n\\vspace{-0.5cm}\n\\twocol{0.6}{0.4}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/l08f04}\n\\end{center}\n}\n{\n\\pause\n\\begin{itemize}\n\\item \\% living in poverty in Akola is 21\\% more than predicted.\n\\pause\n\\item \\% living in poverty in Nashik is 4\\% less than predicted.\n\\end{itemize}\n}\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Describing linear relationships with correlation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Quantifying the relationship}\n\n\\begin{itemize}\n\n\\item \\hl{Correlation} describes the strength of the \\orange{linear} association between two variables.\n\n\\pause\n\n\\item It takes values between -1 (perfect negative) and +1 (perfect positive).\n\n\\pause\n\n\\item A value of 0 indicates no linear association.\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Guessing the correlation}\n\n\\pq{Which of the following is the best guess for the correlation between propn in asset poverty and propn literate?}\n\\twocol{0.4}{0.6}\n{\n\\begin{enumerate}[(a)]\n\\item 0.6\n\\solnMult{-0.54}\n\\item -0.1\n\\item 0.02\n\\item -1.5\n\\end{enumerate}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/l08f05}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Guessing the correlation}\n\n\\pq{Which of the following is the best guess for the correlation between propn in asset poverty and propn of SC-ST in a district?}\n\n\\twocol{0.4}{0.6}\n{\n\\begin{enumerate}[(a)]\n\\item 0.1\n\\item -0.6\n\\item -0.4\n\\item 0.9\n\\solnMult{0.55}\n\\end{enumerate}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/l08f06.pdf}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Assessing the correlation}\n\n\\pq{Which of the following is has the strongest correlation, i.e. correlation coefficient closest to +1 or -1?}\n\n\\twocol{0.8}{0.2}\n{\n\\begin{center}\n\\includegraphics[width=0.65\\textwidth]{graphs/l08f07}\n\\end{center}\n}\n{\n\\soln{\\only<2>{\\orange{\n(b) $\\rightarrow$ correlation means \\underline{linear} association\n}}}\n}\n\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Fitting a line by least squares regression}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{An objective measure for finding the best line}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{An objective measure for finding the best line}\n\n\\begin{itemize}\n\n\\item We want a line that has small residuals:\n\\pause\n\\begin{enumerate}\n\\item Option 1: Minimize the sum of magnitudes (absolute values) of residuals\n\\[ |e_1| + |e_2| + \\cdots + |e_n| \\]\n\\pause\n\\item Option 2: Minimize the sum of squared residuals -- \\hl{least squares}\n\\[ e_1^2 + e_2^2 + \\cdots + e_n^2 \\]\n\\end{enumerate}\n\n\\pause\n\n\\item Why least squares?\n\\pause\n\\begin{enumerate}\n\\item Most commonly used\n\\pause\n\\item Easier to compute by hand and using software\n\\pause\n\\item In many applications, a residual twice as large as another is usually more than twice as bad\n\\end{enumerate}\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{The least squares line}\n\n\\[ \\mathhl{ \\hat{y} = \\beta_0 + \\beta_1 x } \\]\n\n\\begin{itemize}\n\\item $\\hat{y}$: Predicted value of the outcome variable, $y$\n\\item $\\beta_0$: Intercept, parameter\n\\begin{itemize}\n\\item $b_0$: Intercept, point estimate\n\\end{itemize}\n\\item $\\beta_1$: Slope, parameter\n\\begin{itemize}\n\\item $b_1$: Slope, point estimate\n\\end{itemize}\n\\item $x$: Predictor variable\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Conditions for the least squares line}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Conditions for the least squares line}\n\n\\begin{enumerate}\n\n\\item Linearity\n\n\\pause\n\n\\item Nearly normal residuals\n\n\\pause\n\n\\item Constant variability\n\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Conditions: (1) Linearity}\n\n\\begin{itemize}\n\n\\item The relationship between the predictor and the outcome variable should be linear. \n\n\\pause\n\n\\item Methods for fitting a model to non-linear relationships exist, but are beyond the scope of this class. If this topic is of interest, an \\href{http://www.openintro.org/download.php?file=os2_extra_nonlinear_relationships&referrer=/stat/textbook.php}{Online Extra is available on openintro.org} covering new techniques.\n\n\\pause\n\n\\item Check using a scatterplot of the data, or a \\hl{residuals plot}.\n\n\\end{itemize}\n\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{graphs/l08f08}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Anatomy of a residuals plot}\n\n\\twocol{0.5}{0.5}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/l08f09}\n\\end{center}\n}\n{\n\\textcolor{red}{{\\LARGE $\\blacksquare$}} \\hl{Akola:}\n\\begin{align*}\npLit &= 0.778 \\qquad pNoAssets = 0.318 \\\\\n\\widehat{pNoAssets} &= 0.619 - 0.664 * 0.778 = 0.102 \\\\\ne &= pNoAssets - \\widehat{pNoAssets} \\\\\n&= 0.318 - 0.108 = \\textcolor{red}{0.217}\n\\end{align*}\n$\\:$\n\\pause\n\\textcolor{green}{{\\Large $\\blacktriangle$}} \\hl{Nashik:}\n\\begin{align*}\npLit &= 0.761 \\qquad pNoAssets = 0.071 \\\\\n\\widehat{pNoAssets} &= 0.619 - 0.664 * 0.761 = 0.113 \\\\\ne &= pNoAssets - \\widehat{pNoAssets} \\\\\n&= 0.071 - 0.113 = \\textcolor{green}{-0.042}\n\\end{align*}\n}\n\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Conditions: (2) Nearly normal residuals}\n\n\\begin{itemize}\n\n\\item The residuals should be nearly normal.\n\n\\pause\n\n\\item This condition may not be satisfied when there are unusual observations that don't follow the trend of the rest of the data.\n\n\\pause\n\n\\item Check using a histogram.\n\n\\end{itemize}\n\n\\begin{center}\n\\includegraphics[width=0.35\\textwidth]{graphs/l08f10}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Conditions: (3) Constant variability}\n\n\\twocol{0.5}{0.5}\n{\n\\begin{center}\n\\includegraphics[width=\\textwidth]{graphs/l08f11}\n\\end{center}\n}\n{\n\\begin{itemize}\n\n\\item The variability of points around the least squares line should be roughly constant.\n\n\\pause\n\n\\item This implies that the variability of residuals around the 0 line should be roughly constant as well.\n\n\\pause\n\n\\item Also called \\hl{homoscedasticity}.\n\n\\pause\n\n\\item Check using a residuals plot.\n\n\\end{itemize}\n}\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Checking conditions}\n\n\\twocol{0.5}{0.5}\n{\n\\pq{What condition is this linear model obviously violating?}\n\\begin{enumerate}[(a)]\n\\item Constant variability\n\\solnMult{Linear relationship}\n\\item Normal residuals\n\\item No extreme outliers\n\\end{enumerate}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{graphs/nonlinear}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Checking conditions}\n\n\\twocol{0.5}{0.5}\n{\n\\pq{What condition is this linear model obviously violating?}\n\\begin{enumerate}[(a)]\n\\solnMult{ Constant variability}\n\\item Linear relationship\n\\item Normal residuals\n\\item No extreme outliers\n\\end{enumerate}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{graphs/heteroscedastic}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Finding the least squares line}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Given...}\n\n\\twocol{0.5}{0.5}\n{\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{graphs/l08f01}\n\\end{center}\n}\n{\n\\begin{tabular}{l r r}\n\\hline\n\t\t& propn literate\t\t& propn in poverty \\\\\n\t\t& $(x)$\t\t\t& $(y)$ \\\\\n\\hline\nmean\t& $\\bar{x} = 0.6248 $\t& $\\bar{y} = 0.2036$  \\\\\nsd\t\t& $s_x = 0.105$\t\t& $s_y = 0.129$ \\\\\n\\hline\n\t\t& correlation\t\t& $R = -0.54$ \\\\\n\\hline\n\\end{tabular}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Interpreting regression model parameter estimates}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Slope}\n\n\\formula{Slope}\n{The slope of the regression can be calculated as \n\\[ b_1 = \\frac{s_y}{s_x} R \\]\n}\n\n\\pause\n\n\\hl{In context...}\n\\[ b_1 = \\frac{0.129}{0.105} \\times -0.54 = -0.664 \\]\n\n\\pause\n$\\:$ \\\\\n\\hl{Interpretation} \\\\\nFor each additional percentage point in literacy rate, the asset poor rate would be lower on average by 0.66\\% points.\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Intercept}\n\n\\formula{Intercept}\n{The intercept is where the regression line intersects the $y$-axis. The calculation of the intercept uses the fact the a regression line always passes through $(\\bar{x},\\bar{y})$.\n\\[ b_0 = \\bar{y} - b_1 \\bar{x} \\]\n}\n\n\\pause\n\n\\begin{align*}\nb_0 &= 0.2036 - (-0.664) \\times 0.6248 \\\\\n&= 0.619\n\\end{align*}\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{}\n\n\\pq{Which of the following is the correct interpretation of the intercept?}\n\n\\begin{enumerate}[(a)]\n\\item For each \\% point increase in literacy rate, \\% living in poverty is expected to increase on average by 61.9\\%.\n\\item For each \\% point decrease in literacy rate, \\% living in poverty is expected to increase on average by 61.9\\%.\n\\item Having no literate person leads to 61.9\\% of households living without any assets.\n\\solnMult{Districts with no literate population are expected on average to have 61.9\\% of households living in asset-poverty.}\n\\item In districts with no literate population \\% living in asset-poverty is expected to increase on average by 61.9\\%.\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{More on the intercept}\n\nSince there are no districts in the dataset with no literate population, the intercept is of no interest, not very useful, and also not reliable since the predicted value of the intercept is so far from the bulk of the data.\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Regression line}\n\n\\[ \\widehat{pNoAssets} = 0.619 - 0.664\\times pLit \\]\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{graphs/l08f05}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Recap: Interpreting the slope and the intercept}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Interpretation of slope and intercept}\n\n\\twocol{0.5}{0.5}{\n\\begin{itemize}\n\n\\item \\hl{Intercept:} When {$x = 0$}, {$y$} is expected to equal {the intercept}. \\\\\n\n$\\:$ \\\\\n\n\\item \\hl{Slope:} For each {unit} in {$x$}, {$y$} is expected to {increase / decrease} on average by {the slope}.\n\n\\end{itemize}\n}\n{\n\\begin{center}\n\\includegraphics[width=\\textwidth]{graphs/diagram}\n\\end{center}\n}\n\n\\vspace{1cm}\n\n\\Note{These statements are not causal, unless the study is a randomized controlled experiment.}\n\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Prediction}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\begin{frame}\n\\frametitle{Prediction}\n\n\\begin{itemize}\n\n\\item Using the linear model to predict the value of the response variable for a given value of the explanatory variable is called \\hl{prediction}, simply by plugging in the value of $x$ in the linear model equation.\n\n\\item There will be some uncertainty associated with the predicted value.\n\n\\end{itemize}\n\n\\begin{center}\n\\includegraphics[width=0.9\\textwidth]{graphs/l08f12}\n\\end{center}\n\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Using $R^2$ to describe the strength of a fit}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{$R^2$}\n\n\\begin{itemize}\n\n\\item The strength of the fit of a linear model is most commonly evaluated using \\mathhl{R^2}.\n\n\\pause\n\n\\item $R^2$ is calculated as the square of the correlation coefficient.\n\n\\pause\n\n\\item It tells us what percent of variability in the response variable is explained by the model.\n\n\\pause\n\n\\item The remainder of the variability is explained by variables not included in the model or by inherent randomness in the data.\n\n\\pause\n\n\\item For the model we've been working with, $R^2 = -0.54^2 = 0.29$.\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Interpretation of $R^2$}\n\n\\pq{{\\small Which of the below is the correct interpretation of $R = -0.54$, $R^2 = 0.29$?}}\n\n\\twocol{0.65}{0.35}{\n\\begin{enumerate}[(a)]\n\n\\item 29\\% of the variability in the \\% of literates among the 640 districts is explained by the model.\n\n\\solnMult{ 29\\% of the variability in the \\% of households living in assets poverty among the 640 districts is explained by the model.}\n\n\\item 29\\% of the time \\% literates predict \\% living in asset poverty correctly.\n\n\\item 71\\% of the variability in the \\% of households living in poverty among the 640 districts is explained by the model.\n\n\\end{enumerate}\n}{\n\\begin{center}\n\\includegraphics[width=\\textwidth]{graphs/l08f01}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Types of outliers in linear regression}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Types of outliers}\n\n\\twocol{0.5}{0.5}\n{\n\\dq{How do outliers influence the least squares line in this plot?}\n\nTo answer this question think of where the regression line would be with and without the outlier(s). Without the outliers the regression line would be steeper, and lie closer to the larger group of observations. With the outliers the line is pulled up and away from some of the observations in the larger group. \n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/out4}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Types of outliers}\n\n\\twocol{0.4}{0.6}\n{\n\\dq{How do outliers influence the least squares line in this plot?} \\\\\n\\soln{\\only<2>{Without the outlier there is no evident relationship between $x$ and $y$.}}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/out5}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Some terminology}\n \n\\begin{itemize}\n\n\\item \\hl{Outliers} are points that lie away from the cloud  of points.\n\n\\pause\n\n\\item Outliers that lie horizontally away from the center of the cloud are called \\hl{high leverage} points.\n\n\\pause\n\n\\item High leverage points that actually influence the \\underline{slope} of the regression line are called \\hl{influential} points.\n\n\\pause\n\n\\item In order to determine if a point is influential, visualize the regression line with and without the point. Does the slope of the line change considerably? If so, then the point is influential. If not, then it's not an influential point.\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Influential points}\n\nData are available on the log of the surface temperature and the log of the light intensity of 47 stars in the star cluster CYG OB1.\n\n\\twocol{0.7}{0.3}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/star}\n\\end{center}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/cyg}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Types of outliers}\n\n\\twocol{0.4}{0.6}\n{\n\\pq{Which of the below best describes the outlier?}\n\\begin{enumerate}[(a)]\n\\item influential\n\\solnMult{high leverage}\n\\item none of the above\n\\item there are no outliers\n\\end{enumerate}\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/out6}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Types of outliers}\n\n\\twocol{0.4}{0.6}\n{\n\\dq{Does this outlier influence the slope of the regression line?}\n\\soln{\\only<2>{Not much...}}\n\n}\n{\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{graphs/out1}\n\\end{center}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Recap}\n\n\\pq{Which of following is \\underline{true}?}\n\n\\begin{enumerate}[(a)]\n\\item Influential points always change the intercept of the regression line.\n\\item Influential points always reduce $R^2$.\n\\item It is much more likely for a low leverage point to be influential, than a high leverage point.\n\\item When the data set includes an influential point, the relationship between the explanatory variable and the response variable is always nonlinear.\n\\solnMult{None of the above.}\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Recap (cont.)}\n\n\\vspace{-1cm}\n\n\\twocol{0.5}{0.5}\n{\n\\begin{center}\n\\[ R = 0.08, R^2 = 0.0064 \\]\n\\includegraphics[width=0.75\\textwidth]{graphs/out5-1}\n\\end{center}\n}\n{\n\\begin{center}\n\\[ R = 0.79, R^2 = 0.6241 \\]\n\\includegraphics[width=0.75\\textwidth]{graphs/out5}\n\\end{center}\n}\n\n\\end{frame}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Inference for linear regression}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Understanding regression output from software}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Nature or nurture?}\n\n{\\small In 1966 Cyril Burt published a paper called ``The genetic determination of differences in intelligence: A study of monozygotic twins reared apart?\" The data consist of IQ scores for [an assumed random sample of] 27 identical twins, one raised by foster parents, the other by the biological parents.}\n\n\\begin{center}\n\\includegraphics[width=0.55\\textwidth]{graphs/twins_IQ}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}[fragile]\n\\frametitle{}\n\n\\pq{Which of the following is \\underline{false}?}\n\n{\\footnotesize\n\\begin{verbatim}\nCoefficients:\n                 Estimate Std. Error t value Pr(>|t|)    \n(Intercept)       9.20760    9.29990   0.990    0.332    \nbioIQ             0.90144    0.09633   9.358  1.2e-09\n\nResidual standard error: 7.729 on 25 degrees of freedom\nMultiple R-squared: 0.7779,\tAdjusted R-squared: 0.769 \nF-statistic: 87.56 on 1 and 25 DF,  p-value: 1.204e-09 \n\\end{verbatim}\n}\n\n\\begin{enumerate}[(a)]\n\\item Additional 10 points in the biological twin's IQ is associated with additional 9 points in the foster twin's IQ, on average.\n\\solnMult{Roughly 78\\% of the foster twins' IQs can be accurately predicted by the model.}\n\\item The linear model is $\\widehat{fosterIQ} = 9.2 + 0.9 \\times bioIQ$.\n\\item Foster twins with IQs higher than average IQs tend to have biological twins with higher than average IQs as well.\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Testing for the slope}\n\n\\pq{Assuming that these 27 twins comprise a representative sample of all twins separated at birth, we would like to test if these data provide convincing evidence that the IQ of the biological twin is a significant predictor of IQ of the foster twin. What are the appropriate hypotheses?}\n\n\\begin{enumerate}[(a)]\n\\item \\mathhl{H_0:} $b_0 = 0$; \\mathhl{H_A:} $b_0 \\ne 0$ \n\\item \\mathhl{H_0:} $\\beta_0 = 0$; \\mathhl{H_A:} $\\beta_0 \\ne 0$ \n\\item \\mathhl{H_0:} $b_1 = 0$; \\mathhl{H_A:} $b_1 \\ne 0$ \n\\solnMult{ \\mathhl{H_0:} $\\beta_1 = 0$; \\mathhl{H_A:} $\\beta_1 \\ne 0$ }\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Testing for the slope (cont.)}\n\n{\\footnotesize\n\\begin{center}\n\\begin{tabular}{rrrrr}\n  \\hline\n & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\\\ \n  \\hline\n(Intercept) & 9.2076 & 9.2999 & 0.99 & 0.3316 \\\\ \n  bioIQ & 0.9014 & 0.0963 & 9.36 & 0.0000 \\\\ \n   \\hline\n\\end{tabular}\n\\end{center}\n}\n\n\\pause\n\n\\begin{itemize}\n\n\\item We always use a $t$-test in inference for regression. $\\:$ \\\\\n\n\\pause\n\n\\Remember{Test statistic, $T = \\frac{point~estimate - null~value}{SE}$}\n\n\\pause\n\n\\item Point estimate = $b_1$ is the observed slope.\n\n\\pause\n\n\\item $SE_{b_1}$ is the standard error associated with the slope.\n\n\\pause\n\n\\item Degrees of freedom associated with the slope is $df = n - 2$, where $n$ is the sample size. $\\:$ \\\\\n\\pause\n\\Remember{We lose 1 degree of freedom for each parameter we estimate, and in simple linear regression we estimate 2 parameters, $\\beta_0$ and $\\beta_1$.}\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Testing for the slope (cont.)}\n\n{\\small\n\\begin{center}\n\\begin{tabular}{rrrrr}\n  \\hline\n & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\\\ \n  \\hline\n(Intercept) &  9.2076 & 9.2999 & 0.99 & 0.3316 \\\\ \n  bioIQ & \\orange{0.9014}  &   \\green{0.0963} & \\orange{9.36} & \\textcolor{blue}{0.0000} \\\\ \n   \\hline\n\\end{tabular}\n\\end{center}\n}\n\n\\pause\n\n\\begin{eqnarray*}\nT &=& \\frac{\\orange{0.9014} - 0}{\\green{0.0963}} = \\orange{9.36} \\\\\n\\pause\ndf &=& 27 - 2 = 25 \\\\\n\\pause\np-value &=& P(|T| > \\orange{9.36}) < \\textcolor{blue}{0.01}\n\\end{eqnarray*}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{\\% in Poverty vs. \\% SC-ST}\n\n\n\\dq{What can you say about the relationship between \\% in poverty and \\% SC-ST in a sample of 100 districts in India?}\n\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{graphs/l08f13.pdf}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{\\% in Poverty vs \\% SC-ST - linear model}\n\n\\pq{Which of the below is the best interpretation of the slope?}\n\n{\\small\n\\begin{center}\n\\begin{tabular}{rlrrrr}\n  \\hline\n & term & estimate & std.error & statistic & p.value \\\\ \n  \\hline\n1 & (Intercept) & 0.10 & 0.02 & 5.75 & 0.00 \\\\ \n  2 & pSCST & 0.03 & 0.06 & 0.50 & 0.62 \\\\ \n   \\hline\n\\end{tabular}\n\\end{center}\n}\n\n\\begin{enumerate}[(a)]\n\\item A 1\\% increase in SC-ST population in a district is associated with a 3\\% increase in \\% of asset poor.\n\\solnMult{A 1\\% increase in SC-ST population in a district is associated with a 0\\% increase in \\% of asset poverty.}\n\\item An additional 1\\% of SC-ST population increases the \\% of asset poor in a district by 10\\%.\n\\item In districts with zero SC-ST population, \\% of asset poor is expected to be 75\\%.\n\\end{enumerate}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{\\% in Poverty vs. \\% SC-ST - linear model}\n\n\\dq{Do these data provide convincing evidence that there is a statistically significant relationship between \\% SC-ST and \\% asset poor in randomly chosen Indian districts?}\n\n{\\small\n\\begin{center}\n\\begin{tabular}{rrrrr}\n  \\hline\n & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\\\ \n  \\hline\n(Intercept) & 0.1049 & 0.0182 & 5.75 & 0.0000 \\\\ \n  pSCST & 0.0301 & 0.0602 & 0.50 & 0.6179 \\\\ \n   \\hline\n\\end{tabular}\n\\end{center}\n}\n\\soln{\\only<2->{No, the p-value for \\% SCST is low, indicating that the data does not provide convincing evidence that the slope parameter is different than 0.\n}}\n\n$\\:$ \\\\\n\n\\dq{How reliable is this p-value if these zip code areas are not randomly selected?}\n\\soln{\\only<3->{Not very...\n}}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{CI for the slope}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Confidence interval for the slope}\n\n\\pq{{\\small Remember that a confidence interval is calculated as $point~estimate \\pm ME$ and the degrees of freedom associated with the slope in a simple linear regression is $n - 2$. Which of the below is the correct 95\\% confidence interval for the slope parameter? Note that the model is based on observations from 27 twins.}}\n\n{\\footnotesize\n\\begin{center}\n\\begin{tabular}{rrrrr}\n  \\hline\n & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\\\ \n  \\hline\n(Intercept) & 9.2076 & 9.2999 & 0.99 & 0.3316 \\\\ \n  bioIQ & 0.9014 & 0.0963 & 9.36 & 0.0000 \\\\ \n   \\hline\n\\end{tabular}\n\\end{center}\n}\n\n\\vspace{-0.5cm}\n\n\\twocol{0.4}{0.6}\n{\n\\begin{enumerate}[(a)]\n\\item $9.2076 \\pm 1.65 \\times 9.2999$\n\\solnMult{ $0.9014 \\pm 2.06 \\times 0.0963$}\n\\item $0.9014 \\pm 1.96 \\times 0.0963$\n\\item $9.2076 \\pm 1.96 \\times 0.0963$\n\\end{enumerate}\n}\n{\n\\soln{\\onslide<2->{\\orange{\n\\begin{eqnarray*}\n\\pause\nn &=& 27 \\qquad df = 27 - 2 = 25 \\\\\n\\pause\n95\\%:~t^\\star_{25} &=& 2.06 \\\\\n\\pause\n0.9014 &\\pm& 2.06 \\times 0.0963 \\\\\n\\pause\n(0.7 &,& 1.1)\n\\end{eqnarray*}\n}}}}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Recap}\n\n\\begin{itemize}\n\n\\item Inference for the slope for a single-predictor linear regression model:\n\\pause\n\\begin{itemize}\n\\item Hypothesis test:\n\\[ T = \\frac{b_1 - null~value}{SE_{b_1}} \\qquad df = n - 2 \\]\n\\pause\n\\item Confidence interval:\n\\[ b_1 \\pm t^\\star_{df = n - 2} SE_{b_1} \\]\n\\end{itemize}\n\n\\pause\n\n\\item The null value is often 0 since we are usually checking for \\hl{any} relationship between the explanatory and the response variable.\n\n\\pause\n\n\\item The regression output gives $b_1$, $SE_{b_1}$, and \\hl{two-tailed} p-value for the $t$-test for the slope where the null value is 0.\n\n\\pause\n\n\\item We rarely do inference on the intercept, so we'll be focusing on the estimates and inference for the slope.\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\begin{frame}\n\\frametitle{Caution}\n\n\\begin{itemize}\n\n\\item Always be aware of the type of data you're working with: random sample, non-random sample, or population.\n\n\\pause\n\n\\item Statistical inference, and the resulting p-values, are meaningless when you already have population data.\n\n\\pause\n\n\\item If you have a sample that is non-random (biased), inference on the results will be unreliable.\n\n\\pause\n\n\\item The ultimate goal is to have independent observations.\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\end{document}", "meta": {"hexsha": "5248e7c01e8b7f9ee58e3a2636191f88fbeaf67d", "size": 29142, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/Topic08(2020).tex", "max_stars_repo_name": "sumitrmishra/data504", "max_stars_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/Topic08(2020).tex", "max_issues_repo_name": "sumitrmishra/data504", "max_issues_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/Topic08(2020).tex", "max_forks_repo_name": "sumitrmishra/data504", "max_forks_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-10-20T07:26:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-20T07:26:35.000Z", "avg_line_length": 22.8028169014, "max_line_length": 329, "alphanum_fraction": 0.6420286871, "num_tokens": 8439, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863695, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.421899622215315}}
{"text": "%!TEX root = ../main.tex\n\n\n\\section{Math problems}\n\\label{sec:math_problems}\n\t\n\tWe've now reached the first section of problems in this book.\n\tThe purpose of these problems is to give you a way to comprehensively practice your math fundamentals.\n\n\t\n{\\small \n\t \n\\begin{problems}{ch1}\n\n\t\\vspace*{3mm}\n\n\n\t%%%  SOLVING EQUATIONS     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\t\n\t\\begin{problem}\n\t\tSolve for $x$ in the equation $x^2-9=7$.\n\t\t\\begin{answer}$x=\\pm 4$.\\end{answer}\n\t\\end{problem}\n\n\t\\begin{problem}\n\t\tSolve for $x$ in the equation $\\cos^{-1}\\!\\left( \\frac{x}{A} \\right) - \\phi = \\omega t$.\n\t\t\\begin{answer}$x=A\\cos(\\omega t+\\phi)$.\\end{answer}\n\t\\end{problem}\n\n\t\\begin{problem}\t\t\\label{mathprob:ch1:fractions2}\n\t\tSolve for $x$ in the equation $\\frac{1}{x}=\\frac{1}{a}+\\frac{1}{b}$.\t\n\t\t\\begin{answer}$x=\\frac{ab}{a+b}$.\\end{answer}\n\t\\end{problem}\n\n\t\\begin{problem}\n\t\tUse a calculator to find the values of the following expressions:\n\t\t\\fourcol\n\t\t\t\\textbf{a)}~$\\sqrt[4]{3^3}$\n\t\t\t\n\t\t\t\\textbf{b)}~$2^{10}$\n\t\t\t\n\t\t\t\\textbf{c)}~$7^{^{\\frac{1}{4}}}-10$\n\t\t\t\n\t\t\t\\textbf{d)}~$\\frac{1}{2}\\ln(e^{22})$\n\t\t\\endfourcol\n\t\t%\\begin{hint}\n\t\t%\\end{hint}\n\t\t\\begin{answer}\\textbf{a)}~$2.2795$.\n\t\t\t\t\t\\textbf{b)}~$1024$.\n\t\t\t\t\t\\textbf{c)}~$-8.373$.\n\t\t\t\t\t\\textbf{d)}~$11$.\\end{answer}\n\t\t%\\begin{solution}\n\t\t%\\end{solution}\n\t\\end{problem}\n\n\n\t%% FRACTIONS    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\t\\begin{problem} \n\t\tCompute the following expressions involving fractions:\n\t\t\\threecol\n\t\t\t\\textbf{a)}~$\\dfrac{1}{2} + \\dfrac{1}{4}$\n\t\t\t\n\t\t\t\\textbf{b)}~$\\dfrac{4}{7} - \\dfrac{23}{5}$\n\t\t\t\n\t\t\t\\textbf{c)}~$1\\frac{3}{4} + 1\\frac{31}{32}$\n\t\t\\endthreecol\n\t\t\\begin{answer}\\textbf{a)}~$\\frac{3}{4}$.\n\t\t\t\t\t\\textbf{b)}~$\\frac{-141}{35}$.\n\t\t\t\t\t\\textbf{c)}~$3\\frac{23}{32}$.\\end{answer}\n\t\t\\begin{solution}\n\t\t\tFor \\textbf{c)}, \n\t\t\t$1\\frac{3}{4} + 1\\frac{31}{32} \n\t\t\t\t= \\frac{7}{4} + \\frac{63}{32} \n\t\t\t\t= \\frac{56}{32} + \\frac{63}{32} = \\frac{119}{32}=3\\frac{23}{32}$.\n\t\t\\end{solution}\n\t\\end{problem}\n\n\t\n\\end{problems}\n\n\n} %/small\n\n\n\n\n", "meta": {"hexsha": "610590d1ac1f6dad32dd7a17bb5609694cef40ed", "size": 1988, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sources/original/problems/chapter1_problems.tex", "max_stars_repo_name": "minireference/sample-book", "max_stars_repo_head_hexsha": "83e827d7e0c3f5fea1d08815810f0b08bef503e3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2020-10-19T21:21:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T16:42:13.000Z", "max_issues_repo_path": "sources/original/problems/chapter1_problems.tex", "max_issues_repo_name": "minireference/sample-book", "max_issues_repo_head_hexsha": "83e827d7e0c3f5fea1d08815810f0b08bef503e3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sources/original/problems/chapter1_problems.tex", "max_forks_repo_name": "minireference/sample-book", "max_forks_repo_head_hexsha": "83e827d7e0c3f5fea1d08815810f0b08bef503e3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-12T19:03:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-12T19:03:04.000Z", "avg_line_length": 22.5909090909, "max_line_length": 103, "alphanum_fraction": 0.5663983903, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.42180586690180943}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Friday\\\\ 2020-4-10, \\\\ compiled \\\\ \\today}\n\nWe define the \\textbf{ellipticity} \\(\\epsilon = (I_1 - I_2 ) / I_3 \\). Typical values of this parameter for astrophysical objects are at most of the order of \\num{e-6}, which can be calculated as \\(\\epsilon \\sim ( \\delta R / R_0 )^2\\), where \\(\\delta R\\) is the scale of the radial anomaly while  \\(R_0 \\) is the scale of the radius of the object.\nFor a neutron star this corresponds to ``mountains'' of about \\(\\delta R \\sim \\SI{10}{m}\\).\n\nThen, we can define a typical amplitude \\(h_0 \\) as: \n%\n\\begin{align} \\label{eq:typical-amplitude-rigid-nonprecessing-body}\nh_0 = \\frac{4 \\pi^2G}{c^{4}} \\frac{f_{GW}^2}{r} I_3 \\epsilon \n\\,,\n\\end{align}\n%\nwhere, as usual, \\(f_{GW} = \\omega_{r} / \\pi = 2 f _{\\text{rotation}}\\).\n\nIn terms of typical orders of magnitude, this variable looks like\n%\n\\begin{align}\nh_0 \\sim \\num{e-25} \\qty(\\frac{\\epsilon }{\\num{e-6}})\n\\qty( \\frac{I_3}{\\SI{e38}{kg m^2}})\n\\qty( \\frac{\\SI{10}{kpc}}{r})\n\\qty( \\frac{f_{GW}}{\\SI{1}{kHz}})^2\n\\,.\n\\end{align}\n\nWith this, we can rewrite the amplitudes in the two polarizations as \n%\n\\boxalign{\n\\begin{align}\nh_{+} &= h_0 \\frac{1 + \\cos^2 \\iota }{2} \\cos(2 \\pi f_{GW} t) \\\\\nh_{ \\times } &= h_0 \\cos \\iota  \\sin(2 \\pi f_{GW} t) \n\\,.\n\\end{align}}\n\nTo find the radiated power by this mechanism we can use the quadrupole formula \\eqref{eq:radiated-power-GW}: \n%\n\\begin{align}\n\\dv{E_{GW}}{t} &= \\frac{G}{5 c^{5}} \\expval{\n    \\dot{\\ddot{M}}_{ij} \\dot{\\ddot{M}}_{ij} - \\frac{1}{3} \\underbrace{\\qty(\\dot{\\ddot{M}}_{kk})^2}_{= 0}\n}  \\\\\n&= \\frac{G}{5c^{5}} 2 \\expval{ \\dot{\\ddot{M}}_{11}^2 + \\dot{\\ddot{M}}_{12}^2}  \\\\\n&= \\frac{2G}{5c^{5}} \\qty(4 \\omega_{r}^3 (I_1 - I_2 ))^2 \\underbrace{\\expval{ \\cos^2(2 \\omega_{r}t) + \\sin^2(2 \\omega_{r}t)}}_{= 1/2 + 1/2}  \\\\\n&= \\frac{32 G}{5 c^{5}} \\omega_{r}^{6} \\epsilon^2 I_3^2\n\\,,\n\\end{align}\n%\nso by conservation of energy the neutron star will lose just as much energy. \nThe rotational energy is given by \\(E _{\\text{rot}} = I_{3} \\omega_{r}^2 / 2\\), so we have \n%\n\\begin{align}\n\\dv{E _{\\text{rot}}}{t} = - \\dv{E_{GW}}{t} &= I_3 \\omega_{r} \\dot{\\omega}_{r}  \\\\\n- \\frac{32 G}{5 c^{5}} \\omega_{r}^{6} \\epsilon^2 I_3^2 &= I_3 \\omega_{r} \\dot{\\omega}_{r}  \\\\\n\\dot{\\omega}_{r} &= - \\frac{32G}{5 c^{5}} \\omega_{r}^{5} \\epsilon^2 I_3 <0\n\\,,\n\\end{align}\n%\nso, \\emph{as opposed to binaries}, the orbit \\textbf{slows down} because of GW emission.\nObservations of binaries show \\(\\dot{\\omega} \\sim - \\omega^{n} \\) with \\(n < 5\\), meaning that there probably is another breaking mechanism contributing.   \n\n\\subsection{Precession}\n\nNow, let us consider a body whose angular momentum \\(\\vec{J}\\) is \\emph{not aligned} with its axes of inertia \\cite[sec.\\ 4.2.2]{maggioreGravitationalWavesVolume2007}. \n\nWe want to proceed like we did before, so we will need two reference frames. \nThe first reference, \\(S\\), is a frame in which \\(\\vec{J} = J \\hat{z}\\); this will be at least approximately an inertial reference frame, so \\(\\vec{J}\\) will be conserved.  \nThe second reference, \\(S'\\), is the \\emph{body frame} of the object, in which it is stationary, and whose axes coincide with the principal axes of rotation. \n\nThe transformation between these two frames will be a rotation matrix \\(R\\) (such that \\(x' = R x\\)), which we decompose as \n%\n\\begin{align}\nR = R_{\\gamma }^{(z)} R_{\\alpha }^{(x)} R_{\\beta }^{(z)} \n= \\left[\\begin{array}{ccc}\n\\cos \\gamma  & \\sin \\gamma  & 0 \\\\ \n- \\sin \\gamma  & \\cos \\gamma  & 0 \\\\ \n0 & 0 & 1\n\\end{array}\\right]\n\\left[\\begin{array}{ccc}\n1 & 0 & 0 \\\\ \n0 & \\cos \\alpha  & \\sin \\alpha  \\\\ \n0 & -\\sin \\alpha  & \\cos \\alpha \n\\end{array}\\right]\n\\left[\\begin{array}{ccc}\n\\cos \\beta  & \\sin \\beta  & 0 \\\\ \n- \\sin \\beta  & \\cos \\beta  & 0 \\\\ \n0 & 0 & 1\n\\end{array}\\right]\n\\,.\n\\end{align}\n\nWe call the \\emph{line of nodes} the intersection between the plane orthogonal to \\(x_3 \\) and that orthogonal to \\(x_3'\\).\nThe \\(\\beta \\) rotation brings \\(x_1 \\) on the line of nodes, the \\(\\alpha \\) rotation brings \\(x_3 \\) onto \\(x_3'\\), the \\(\\gamma \\) rotation aligns \\(x_1 \\) with \\(x_1'\\). \nIn order to understand this, it is customary to look at the figure \\cite[fig.\\ 4.15]{maggioreGravitationalWavesVolume2007} and fiddle around with your fingers in the ``right-hand-rule'' position. \n\nAll three of these angles will in general be time-dependent, and their time evolution will completely determine the motion of the body.\n\nWe can recover the angular velocity vector \\(\\vec{\\omega}\\) by looking at the components of the three angular velocity vectors in the body frame:\n%\n\\begin{align}\n\\dv{\\vec{\\alpha}}{t} &= \\dot{\\alpha} \\left[\\begin{array}{ccc}\n\\cos \\gamma  &  - \\sin \\gamma  &  0 \n\\end{array}\\right]^{\\top}  \\\\\n\\dv{\\vec{\\beta}}{t} &= \\dot{\\beta} \n\\left[\\begin{array}{ccc}\n\\sin \\alpha \\sin \\gamma  & \\sin \\alpha \\cos \\gamma  & \\cos \\alpha \n\\end{array}\\right]^{\\top} \\\\\n\\dv{\\vec{\\gamma}}{t} &= \\dot{\\gamma} \\left[\\begin{array}{ccc}\n0 & 0 & 1\n\\end{array}\\right]^{\\top}\n\\,,\n\\end{align}\n%\nso that then  \\(\\vec{\\omega} = \\vec{\\dot{\\alpha}} + \\vec{\\dot{\\beta}} + \\vec{\\dot{\\gamma}}\\).\nThese expressions can be derived geometrically by looking at the figure. \nSo, in the body frame the components of the angular velocity are \n%\n\\begin{align}\n\\vec{\\omega} = \\left[\\begin{array}{c}\n\\dot{\\alpha} \\cos \\gamma + \\dot{\\beta} \\sin \\alpha \\sin \\gamma  \\\\ \n- \\dot{\\alpha} \\sin \\gamma + \\dot{\\beta} \\sin \\alpha \\cos \\gamma  \\\\ \n\\dot{\\gamma} + \\dot{\\beta}\\cos \\alpha \n\\end{array}\\right]\n\\,.\n\\end{align}\n\nIn the body frame the angular momentum \\(\\vec{J}\\) is \\emph{not} conserved: we can recover its time-dependent expression in the body frame \\(J'\\) by applying a rotation, and then we can use \\(J'_i = I_i \\omega'_i\\): this gives us \n%\n\\begin{align}\nJ'_1 &= I_1 \\omega_1' &&\\implies & J \\sin \\alpha \\sin \\gamma &= I_1 \\qty(\\dot{\\alpha} \\cos \\gamma + \\dot{\\beta} \\sin \\alpha \\sin \\gamma ) \\\\\nJ'_2 &= I_2 \\omega_2' &&\\implies & J \\sin \\alpha \\cos \\gamma &= I_2 \\qty(- \\dot{\\alpha} \\sin \\gamma + \\dot{\\beta} \\sin \\alpha \\cos \\gamma) \\\\\nJ'_3 &= I_3 \\omega_3' &&\\implies & J \\cos \\alpha  &= I_3 \\qty(\\dot{\\gamma} + \\dot{\\beta} \\cos \\alpha ) \n\\,.\n\\end{align}\n\nNow we make the assumption that \\(I_1 = I_2 \\): we consider an \\textbf{axisymmetric body}.\nAn astrophysical example of this will usually look like an ellipsoid.\n\nThen, we perform the following manipulation (written in a formally peculiar way, which should make it easier to remember --- we are ``applying a rotation matrix to the system of equations''): \n%\n\\begin{align}\n&\\left[\\begin{array}{cc}\n\\cos \\gamma  & \\sin \\gamma  \\\\ \n- \\sin \\gamma  & \\cos \\gamma \n\\end{array}\\right]\n\\left[\\begin{array}{c}\nJ \\sin \\alpha \\sin \\gamma = I_1 \\qty(\\dot{\\alpha} \\cos \\gamma + \\dot{\\beta} \\sin \\alpha \\sin \\gamma ) \\\\ \nJ \\sin \\alpha \\cos \\gamma = I_2 \\qty(- \\dot{\\alpha} \\sin \\gamma + \\dot{\\beta} \\sin \\alpha \\cos \\gamma)\n\\end{array}\\right] = \\\\\n&= \\left[\\begin{array}{c}\nI_1 \\dot{\\alpha} \\qty(\\cos^2 \\gamma + \\sin^2 \\gamma ) = 0 \\\\ \nJ \\sin \\alpha \\qty(\\cos^2\\gamma + \\sin^2 \\gamma ) = \\dot{\\beta} I_1 \\sin \\alpha \\qty(\\sin^2\\gamma + \\cos^2\\gamma ) \n\\end{array}\\right] = \n\\left[\\begin{array}{c}\n\\dot{\\alpha} = 0 \\\\ \n\\dot{\\beta} = J / I_1 \\overset{\\text{def}}{=} \\Omega \n\\end{array}\\right]\n\\,.\n\\end{align}\n\nSo, \\(\\alpha \\) is constant while \\(\\beta \\) changes linearly. We can substitute these relations into the third equation to get \n%\n\\begin{align}\nJ \\cos \\alpha &= I_3 \\qty(\\dot{\\gamma} + \\frac{J \\cos \\alpha }{I_1 }) \\\\\n\\dot{\\gamma} &= \\frac{J \\cos \\alpha }{I_3 } - \\frac{J \\cos \\alpha }{I_1 }\n= J \\cos \\alpha \\frac{I_1 - I_3 }{I_1 I_3 } = \\Omega \\cos \\alpha \\frac{I_1 - I_3 }{I_3 } \\overset{\\text{def}}{=} - \\omega_{p}\n\\,,\n\\end{align}\n%\nwhere the sign is a convention, such that when \\(I_3 > I_1 \\) (an oblate object, like a grapefruit or a coin) we have \\(\\omega_{p} > 0\\).\n\nNow, what do these represent? The fact that \\(\\dot{\\alpha} = 0\\) means that the angle between \\(x_3 \\) and \\(x_3'\\) stays the same. \nThe rotation around \\(\\beta \\) is the ``main'' one, as \\(\\vec{\\beta} \\) is aligned with \\(\\vec{J}\\), and \\(\\dot{\\beta}= \\Omega \\gg \\abs{\\omega_{p}} = \\abs{\\dot{\\gamma}}\\) typically. \n\nThe rotation around \\(\\vec{\\gamma}\\) corresponds to a \\emph{precession} of the angular velocity vector around the \\(x_3'\\) axis: the body's rotation axis precesses around its third principal axis.\n\nNot that this is not the same as the precession of the body axis around the angular momentum. \nWe should ``clean our minds'' from the idea of a spinning spintop precessing, this is not what is happening here.\nThis wobbling motion is similar to the one of a coin thrown on a table, although this is a \\emph{free} wobble, happening without any external torque. \n\n% Here, the axis going around is the faster motion, the rotation of the body around its axis is slower. \n\nThe time evolution of the inertia tensor reads \n%\n\\begin{align}\nI (t) = R^{\\top} I' R = \nR_{\\beta }^{\\top} R_{\\alpha }^{\\top} R_{\\gamma }^{\\top} I' \nR_{\\gamma } R_{\\alpha } R_{\\beta }\n\\,,\n\\end{align}\n%\nbut the matrices \\(R_{\\gamma }\\) and \\(R_{\\gamma }^{\\top}\\) rotate the \\(xy\\) components of a matrix between each other: if \\(I_1 = I_2 \\) the components \\(I'_{11} = I'_{22}\\), so we have \\(R_{\\gamma }^{\\top} I' = I' = I' R_{\\gamma }\\). So, we can write the expression as \n%\n\\begin{align}\nI (t) = \nR_{\\beta }^{\\top} R_{\\alpha }^{\\top}  I' \nR_{\\alpha } R_{\\beta }\n\\,,\n\\end{align}\n%\nso the only time dependence which is left is inside \\(\\beta (t) = \\Omega t\\). \nWe can expand the calculation, the result is given by Maggiore \\cite[eq.\\ 4.245]{maggioreGravitationalWavesVolume2007}. \nWe are only interested in the projection of this variation onto the plane orthogonal to the direction of a propagation. \nThe amplitudes in the two GW polarizations are also given by Maggiore \\cite[eq.\\ 4.246 -- 252]{maggioreGravitationalWavesVolume2007}.\n\n% If we compute the evolution of the inertial tensor, we get terms both at \\(\\omega \\) and at \\(2 \\omega \\). \n\nWhat we find is both emission at \\(\\Omega \\) and at \\(2 \\Omega \\), while the frequency corresponding to the precession \\(\\omega_{p}\\) does not appear: \n%\n\\boxalign{\n\\begin{align}\nh_{+} &= h_0' \\qty[ \\sin (2 \\alpha) \\sin \\iota \\cos \\iota \\cos(\\Omega t) \n+ 2 \\sin^2\\alpha \\qty(1 + \\cos^2\\iota ) \\cos(2\\Omega t)]  \\\\\nh_{ \\times } &= h_0' \\qty[\\sin(2 \\alpha  ) \\sin \\iota \\sin(\\Omega t)\n+ 4 \\sin^2 \\alpha \\cos \\iota \\sin(2 \\Omega t)]  \\\\\nh_0' &= - \\frac{G}{c^{4}} \\frac{I_3 - I_1 }{r} \\Omega^2\n\\,,\n\\end{align}}\n%\nwhere this \\(h_0'\\) should be compared with \\eqref{eq:typical-amplitude-rigid-nonprecessing-body}. \n\n\\todo[inline]{Not sure about what comparison should be drawn: the formulas are the same with \\(\\omega_{s} \\to \\Omega \\) and \\(I_2 \\to I_3 \\)\\dots}\n\nWe have four measurable amplitudes (corresponding to two polarizations and two frequencies), and we need to reconstruct the unknowns \\(\\alpha \\), \\(\\iota \\), \\(r\\) and \\(I_3 - I_1 \\).\nThis would in general be possible, however because of correlations we need to measure one more parameter externally (like the distance \\(r\\)).\n\nTo get an \\textbf{intuition} for the biperiodicity: if we have a distribution which looks like a coin (\\(I_1 \\sim I_2 \\ll I_3 \\)) then it looks to us like a binary if we look at it from the top (in terms of periodicity at least), so we expect \\(2 \\omega \\) emission, since the system looks the same to us after a rotation of \\(\\pi \\). \n\nIf, instead, we look at it from the side, the periodicity is the full period: after half a rotation the coin is edge-on (and this happens every \\(\\pi \\)), but it will appear at two different angles with respect to the vertical direction, so the real periodicity is \\(2 \\pi \\).\nTherefore, we both have \\(\\omega \\) and \\(2 \\omega \\) emission. \n\n% If we were able to determine the amplitude at different inclinations, we would be able to determine the inclination \\(\\iota \\). \n\n\\subsubsection{Backreaction}\n\n% [formula for back reaction is wrong!]\n\n% In order to calculate the backreaction we assume that the motion is approximately constant during a single period. \nThe radiated power is given by \\cite[eq.\\ 4.254]{maggioreGravitationalWavesVolume2007}: \n%\n\\begin{align}\n\\dv{E _{\\text{rot}}}{t} &= - \\frac{G}{5c^{5}} \n\\expval{\\dot{\\ddot{M}}_{ij} \\dot{\\ddot{M}}_{ij}}  \\\\\n&= - \\frac{2G}{5c^{5}} \n(I_1 - I_3 )^2 \\Omega^{6}\n\\sin^2\\alpha  \\qty(\\underbrace{\\cos^2\\alpha}_{\\mathclap{\\text{at } \\Omega }}  +\\underbrace{16 \\sin^2\\alpha}_{\\mathclap{\\text{at }2 \\Omega }} )\n\\,.\n\\end{align}\n%\n\\todo[inline]{Wrong sign in the slides! }\n\nSo, we can see that the emission at \\(\\Omega \\) is dominant for \\(\\alpha \\sim 0\\) (systems for which \\(x_3\\) and \\(x_3'\\) are almost aligned --- the ``coin seen head-on''), while the emission at \\(2 \\Omega \\) is dominant for larger \\(\\alpha \\) (the ``coin seen edge-on'').\n\nThe radiated angular momentum is instead given by \n%\n\\begin{align}\n\\dv{J}{t} &= - \\frac{2G}{5c^{5}} \\epsilon_{3jk}\\expval{\\ddot{Q}_{jl} \\dot{\\ddot{Q}}_{kl}}  \\\\\n&= - \\frac{4G}{5c^{5}} \\expval{\\ddot{M}_{1a} \\dot{\\ddot{M}}_{2a}}  \\\\\n&= - \\frac{2G}{5c^{5}} (I_1 - I_3 )^2 \\Omega^{5} \\sin^2\\alpha \\qty(\\cos^2\\alpha  + 16 \\sin^2\\alpha ) = \\frac{1}{\\Omega } \\dv{E _{\\text{rot}}}{t}\n\\,,\n\\end{align}\n%\nwhere we swapped \\(Q\\) for \\(M\\) since the terms \\(\\epsilon^{3kl} \\delta_{ka} Q_{la} \\) and \\(\\epsilon^{3kl} Q_{kl}\\) do not contribute (by symmetry and tracelessness of \\(Q\\) respectively); also we integrated by parts.\\footnote{To move from \\(\\expval{\\ddot{M}_{1a} \\dot{\\ddot{M}}_{2a} - \\ddot{M}_{2a} \\dot{\\ddot{M}}_{1a}}\\) to \\(2 \\expval{\\ddot{M}_{1a} \\dot{\\ddot{M}}_{2a}}\\).} \n\nIn order to understand how the rotation decays we need to express this in terms of the angles: recall the definition of \\(\\Omega = \\dot{\\beta} = J / I_1 \\). This means that \n%\n\\begin{align}\n\\ddot{\\beta} = \\frac{1}{I_1 } \\dv{J}{t} = \n- \\frac{2G}{5c^{5}} \\frac{(I_1-I_3)^2}{I_1 } \\dot{\\beta}^{5} \\sin^2\\alpha \\qty(\\cos^2\\alpha  + 16 \\sin^2\\alpha )\n\\,,\n\\end{align}\n%\nwhich tells us that \\(\\dot{\\beta} = \\Omega \\) is decreasing. \n\nTo find the evolution of \\(\\alpha \\) we need to write the rotational energy as \n%\n\\begin{align}\nE _{\\text{rot}} &= \\frac{1}{2} I'_i \\omega_{i}^{\\prime 2} = \\frac{1}{2} \\frac{J_i^{\\prime 2}}{I_i} \n= \\frac{J^2}{2} \\qty(\\frac{\\sin^2\\alpha \\sin^2 \\gamma }{I_1 }\n+ \\frac{\\sin^2 \\alpha \\sin^2 \\gamma }{I_2 } + \\frac{\\cos^2 \\alpha }{I_3 } ) \\\\\n&= \\frac{J^2}{2} \\qty(\\frac{\\sin^2\\alpha }{I_1 } + \\frac{\\cos^2 \\alpha }{I_3 }) \\marginnote{\\(I_1 = I_2 \\).}\n\\,,\n\\end{align}\n%\nwhich can be differentiated to yield \n%\n\\begin{align}\n\\dot{\\alpha} = - \\frac{2G}{5c^{5}} \\frac{(I_1 - I_3 )^2}{I_1 } \n\\dot{\\beta}^{4} \\sin \\alpha \\cos \\alpha \\qty(\\cos^2\\alpha + 16 \\sin^2 \\alpha )\n\\,,\n\\end{align}\n%\nso \\(\\alpha \\) also decreases due to GW emission. \nThis means that the wobble is decreasing, the rotation is aligning with the angular momentum. \n\nHowever, the combination \\(J \\cos \\alpha \\) is constant: \n%\n\\begin{align}\n\\dv{}{t} \\qty(J \\cos \\alpha ) &= \\dv{J}{t} \\cos \\alpha - J \\dot{\\alpha} \\sin \\alpha   \\\\\n\\begin{split}\n&= - \\frac{2G}{5c^{5}} (I_1-I_3)^2 \\dot{\\beta}^{5} \\sin^2\\alpha \\qty(\\cos^2\\alpha  + 16 \\sin^2\\alpha ) \\cos \\alpha + \\\\\n&\\phantom{=}\\ \n- \\dot{\\beta} I_1 \\sin \\alpha \\qty(- \\frac{2G}{5c^{5}} \\frac{(I_1 - I_3 )^2}{I_1 } \n\\dot{\\beta}^{4} \\sin \\alpha \\cos \\alpha \\qty(\\cos^2\\alpha + 16 \\sin^2 \\alpha ))\n\\end{split}  \\\\\n&= 0\n\\,,\n\\end{align}\n%\nwhich means that \\(\\omega_{3}' = J \\cos \\alpha  / I_3 \\) is a constant: this is the rotation speed of the body around its axis; \\(J \\cos \\alpha \\) is the projection of the angular momentum of the body around its axis \\(x_3'\\).\n\n% We find differential equations telling us that \\(\\dot{\\beta}\n% \\) and \\(\\alpha \\) both decrease: the first means that the motion is slowing down; the second means that the wobbling is decreasing, as the rotation is aligning with the angular momentum.\n\n\\subsubsection{Backreaction}\n\nIn order to study the differential equations for \\(\\ddot{\\beta}\\) and \\(\\dot{\\alpha}\\) we can define the parameter \\(u(t) = \\dot{\\beta} / \\dot{\\beta}_{0}\\), and a characteristic time \\(\\tau_0 \\): \n%\n\\begin{align}\n\\tau_0  = \\qty( \\frac{2G}{5 c^{5}} \\frac{(I_1 - I_3 )^2}{I_1  } \\dot{\\beta}_{0}^{4})^{-1}\n\\,,\n\\end{align}\n%\nwhich has a typical value of \n%\n\\begin{align}\n\\tau_0 = \\SI{1.8e6}{yr} \\qty(\\num{e-7} \\frac{I_3 }{I_1 - I_3 })^2 \\qty( \\frac{ \\SI{1}{kHz}}{f_0 })^{4} \\qty(\\frac{\\SI{e38}{kg m^2}}{I_1 })\n\\,,\n\\end{align}\n%\nand we can write differential equations for \\(\\dot{u}\\) and \\(\\dot{\\alpha}\\) as \n%\n\\begin{align}\n\\dot{u} &= - \\frac{u^{5}}{\\tau_0 } \\sin^2\\alpha  \\qty(\\cos^2 \\alpha + 16 \\sin^2\\alpha ) \\\\\n\\dot{\\alpha} &= - \\frac{ u^{4}}{\\tau_0 } \\sin \\alpha \\cos \\alpha \n\\qty(\\cos^2 \\alpha + 16 \\sin^2\\alpha )\n\\,,\n\\end{align}\n%\nwith initial conditions at the origin \\(u(0) = 1\\) (meaning \\(\\beta = \\beta_0 \\)) and \\(\\alpha(0) = \\alpha_0 \\). \n\nWe have shown that \\(J \\cos \\alpha \\) is a constant: this means that we must have \\(\\dot{\\beta} \\cos(\\alpha ) = \\const\\). \nThis can aid us in the search of a steady state, by providing a constraint. The constant can be calculated at any time, so we compute it at \\(t = 0\\): then we get \\(\\dot{\\beta}_{0} \\cos(\\alpha_0 ) = \\cos(\\alpha_0 )=  \\const\\).\n\nThis implies that the boundary condition at infinity must satisfy \\(u_{ \\infty } \\cos(\\alpha_{ \\infty }) = \\cos \\alpha_0 \\), which in general is different from 0 (unless \\(\\alpha_0 = \\pi /2\\), but it can be shown that this is an unstable equilibrium).\n\nHaving a steady state means that we require \\(\\dot{\\alpha} = \\dot{u} = 0\\).\nSince the factor \\(\\cos^2 + 16 \\sin^2 \\) is always positive for \\(\\alpha \\in [0, \\pi ]\\) this can be either satisfied by \\(u = 0\\) or \\(\\sin \\alpha = 0\\), meaning \\(\\alpha = 0\\) or \\(\\pi \\).\n\nThe condition \\(u = 0\\) cannot in general obey the \\(J \\cos \\alpha \\) constraint, so we are left with \\(\\alpha = 0, \\pi \\).\n\n\\todo[inline]{Can we discard \\(\\alpha > \\pi /2\\) because otherwise we could just flip the axes until it became \\(\\alpha < \\pi /2\\)?}\n\nSo, we get the asymptotic state \n%\n\\begin{align}\n\\alpha_{ \\infty } = 0 \n\\qquad \\text{and} \\qquad\nu_{ \\infty } = \\cos \\alpha_0 \n\\,,\n\\end{align}\n%\nand the way \\(\\alpha \\) approaches this value asymptotically is \n%\n\\begin{align}\n\\dot{\\alpha} \\sim \\alpha \\frac{ u^{4}_{ \\infty }  }{\\tau_0 }\n\\qquad \\text{as} \\qquad\nt \\to \\infty \n\\,,\n\\end{align}\n%\nso asymptotically the decay is exponential, with a timescale \\(\\sim \\tau_0 / u_{ \\infty }^{4} \\gtrsim \\tau_0 \\). \n\n\\subsection{Observations}\n\nThe conditions we discussed do not apply in general: first of all, neutron stars are not truly rigid bodies since they have an internal structure. \nEven if they were, a generic rigid body's principal axes are all different. Maggiore discusses the triaxial case briefly \\cite[pagg.\\ 211--214]{maggioreGravitationalWavesVolume2007}.\n\nIn the triaxial case we will have emission at different frequencies, for example \\(2 \\omega_{r} \\), \\(2 \\omega_{r} + \\omega_{p} \\), \\(2 (\\omega_{r} + \\omega_{p})\\).\nThere are even more: for each base frequency \\(\\omega \\), radiation is emitted with decreasing amplitude for \\(\\omega + n \\omega_{p}\\), \\(n \\in \\mathbb{N}\\).\n\nWe have not seen pulsars yet in GW, but we can put upper bounds to the amplitude of their emission. \nWhat we do is to search for \\textbf{quasi-stationary} GW signals close to known pulsars, accounting for the modulations due to the proper motion of the Earth, of the source etc.\nThere are about 400 pulsars in the LIGO-Virgo bandwidth which would be eligible for this kind of observation.\n\n``Beating the spin-down limit'' means that we know that we would be able to see the GW emission in a certain case if the spin-down was only due to GW.\nWe have beaten it by a factor 10 for the Crab and Vela pulsars: a very tiny fraction \\(\\lesssim \\SI{1}{\\percent}\\) of the rotational energy is lost to GW. \n\n\\emph{Scorpius X-1} is low-mass X-ray binary: we see X-ray emission caused by accretion of the NS from the companion. \nThis is a plausible mechanism for the deformation of the NS. \nWe know its position and orbital period, not its spin frequency! \nThe amplitude of its GW emission is expected to be of the order of \\(h_0 \\sim \\num{5e-25}\\).\n\n\\todo[inline]{What is this bit about? It does not seem really relevant.}\n\nCould we differentiate a pulsar rotating and seen head-on and a binary system? \nSurely they are phenomena which happen in different frequency ranges, and last for different times. \nIf the binary is spinning at those frequencies it's evolving very rapidly, instead a pulsar can give out a stable signal. \n\nAlso, in full numerical relativity the waveform looks different. \n\n\\end{document}\n", "meta": {"hexsha": "3fde59ed80f522184142270ad4155cdacb10c8ac", "size": 20551, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/gravitational_physics/apr10.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/gravitational_physics/apr10.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/gravitational_physics/apr10.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 50.9950372208, "max_line_length": 379, "alphanum_fraction": 0.6560264707, "num_tokens": 7122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.42180585831388284}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{fullpage}\n\\usepackage{framelab}\n\\usepackage{verbatim}\n\n\n\n\\title{FrameLab: Development Guide}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\section{Overall Design}\nFrameLab 1.0 is designed to have an object-oriented, user friendly scripting interface with compute intensive routines written in compiled languages such as C and CUDA/C.  The current scripting language is Matlab, using MEX as an interface mechanism to pull in compiled libraries.  In the future we plan to implement Python/iPython as an alternative to Matlab, to keep the entire code open-source.\n\n\\section{Matlab Object Oriented System}\nThe current goal of Framelab is to solve approximate versions of linear inverse problems of the sort \n\\begin{align}\n\\mathcal{A}u = f \\label{IDLIP}\n\\end{align}Through some discretization, \\eqref{IDLIP} is approximated by a finite dimensional linear system \n\\begin{align}\nA\\textbf{u} = \\textbf{f}\\label{FDLIP}\n\\end{align}To handle more general and complicated problems of this type, we define an object-oriented system where $A$, $\\textbf{u}$ and $\\textbf{f}$ are \\textbf{abstract} data types instead of simply matrices and vectors.  \n\\begin{enumerate}\n\\item DataTypes: To allow for a flexible modeling system, for each problem of type \\eqref{IDLIP},\\eqref{FDLIP} we create an abstract data type for both $\\textbf{u}$ and $\\textbf{f}$.  \n\\item Operators: To model the linear operator $A$, we again use abstract data types.  Thus we define a class for each $A$, for example the ConeBeamScanner transform class.\n\\end{enumerate}\n\n\n\n\n\\section{Compute Kernels}\n\\subsection{Computed Tomography}\nFrom \\cite{gaocode}\n\n\\paragraph{Compiling MEX Libraries}\n\n\\begin{verbatim}\nmex -L\"/usr/local/cuda/lib64\" -lcudart -I\"./\" Ax_fan_mf.cpp Ax_fan_mf_cpu_siddon.cpp\n Ax_fan_mf_cpu_new.cpp Ax_fan_mf_cpu_new_fb.cpp Ax_fan_mf_gpu_siddon.cu \n Ax_fan_mf_gpu_new.cu Ax_fan_mf_gpu_new_fb.cu find_area.cpp sort_alpha.cpp\n\\end{verbatim}\n\nPossible error message about invalid conversion fron int to mxComplexity: change \n\n\\begin{verbatim}\nplhs[0]=mxCreateNumericMatrix(nx*ny*nt,1,mxSINGLE_CLASS,0);\n\\end{verbatim} \n\nto \n\n\\begin{verbatim}\nplhs[0]=mxCreateNumericMatrix(nx*ny*nt,1,mxSINGLE_CLASS,mxREAL);\n\\end{verbatim}\n\nin any mex interface files\n\n\\paragraph{Alternating Direction Method of Multipliers}\nRecall that ADMM is designed to solve problems of the sort \n\\begin{align}\n(x^*,y^*) : = \\argmin_{x,y} F(x)+G(y)\\quad \\st\\quad  Ax+By = b \\tag{$\\mathcal{P}$}\n\\end{align} The approach is to consider the Augmented Lagrangian: \n\\begin{align*}\n\\L_\\rho(x,y,\\lambda) : = F(x)+G(y) + \\left\\langle \\lambda, Ax+By-b\\right \\rangle +\\frac{\\rho}{2}\\|Ax+By-b\\|_2^2\n\\end{align*} We then consider the saddle point problem \n\\begin{align}\n(x^*,y^*,\\lambda^*)_\\rho = \\argmin_{(x,y)}\\argmax_\\lambda \\L_\\rho(x,y,\\lambda)\\label{saddlept} \n\\end{align}  Since we are interested in the saddle point itself and not the value of the functionals, we may complete the square in the definition of $\\L_\\rho$ to obtain \n\\begin{align*}\n\\eqref{saddlept} = \\argmin_{(x,y)}\\argmax_\\lambda F(x) + G(y) +\\frac{\\rho}{2}\\|Ax+By-(b-\\lambda/\\rho)\\|_2^2\n\\end{align*}For notational convenience, we define\n\\begin{align*}\n\\L_\\rho^*(x,y,\\lambda): =  F(x) + G(y) +\\frac{\\rho}{2}\\|Ax+By-(b-\\lambda/\\rho)\\|_2^2\n\\end{align*}\n\n If we then perform coordinate descent/ascent, we arrive at the 3-step ADMM scheme: \n\\begin{align*}\n\\left\\{\\begin{array}{ll}\nx^{(k+1)} &= \\argmin_x \\L_\\rho^*(x,y^{(k)},\\lambda^{(k)}) \\\\\ny^{(k+1)} &= \\argmin_y \\L_\\rho^*(x^{(k+1)},y,\\lambda^{(k)})\\\\\n\\lambda^{(k+1)} &= \\argmax_\\lambda \\L_{\\rho}^*(x^{(k+1)},y^{(k+1)},\\lambda)\n\\end{array}\\right. \n\\end{align*} The method can be generalized in the particular case that $F(x)+G(y)$ is further separable, e.g. $F(x)+G(y) = F_1(x_1)+F_2(x_2)+\\ldots+F_n(x_n)$, with $A\\textbf{x}=\\textbf{b}$, where $\\textbf{x} = (x_1,\\ldots,x_n)^T$.  The augmented Lagrangian then takes the form \n\\begin{align*}\n\\L_\\rho (\\textbf{x},\\Lambda) : = \\sum F_i(x_i) + \\left\\langle \\Lambda,A\\textbf{x}-\\textbf{b}\\right\\rangle +\\frac{\\rho}{2}\\|A\\textbf{x}-\\textbf{b}\\|_2^2 \n\\end{align*} where $\\Lambda = (\\lambda_1,\\ldots,\\lambda_n)^T$. \n\nIn FrameLab, we have implemented an ADMM object designed to solve problems of the type $\\mathcal{P}$.\n\\section{Another Section}\n\n\n\\bibliographystyle{plain}\n\\bibliography{/home/nick/Documents/research/bib}\n\n\\end{document}\n", "meta": {"hexsha": "b3572dd2ba067c9739564dc60aee3d3ad9f343e7", "size": 4369, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/development.tex", "max_stars_repo_name": "nhenscheid/FrameLab", "max_stars_repo_head_hexsha": "dcc96cb950d15d9d4c40e4d2c451d5c9ff737ad8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/development.tex", "max_issues_repo_name": "nhenscheid/FrameLab", "max_issues_repo_head_hexsha": "dcc96cb950d15d9d4c40e4d2c451d5c9ff737ad8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/development.tex", "max_forks_repo_name": "nhenscheid/FrameLab", "max_forks_repo_head_hexsha": "dcc96cb950d15d9d4c40e4d2c451d5c9ff737ad8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-23T07:14:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-23T07:14:02.000Z", "avg_line_length": 45.0412371134, "max_line_length": 397, "alphanum_fraction": 0.7257953765, "num_tokens": 1416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.42180585786682373}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage[utf8]{inputenc}\n\\usepackage{booktabs}\n\\usepackage{pgfplotstable}\n\\usepackage{siunitx}\n\\begin{document}\n\\title{Verification of SINR Values for Path Gain in the METIS Simulation}\n\\author{Michael Meier\\\\ Research Group Computer Networks\\\\ University of Paderborn}\n\\maketitle\n\n\\section{Introductory Notes}\n\tThe following sections document the verification process for the \\emph{Path Gain} computations in the METIS simulation. The goal is testing whether SINR values are computed correctly for uplink as well as downlink computations for a small scenario with only the path gain/path loss equations of the METIS model. \n\t\\subsection{Simulations}\n\tThe simulations were run with the slighly modified code from the \\texttt{verify\\_pathloss} branch of the simulator repository. In this branch, all compuations safe the path loss are commented out. Additionally, all BS/MS pairs are considered to have \\emph{Line of Sight}.\n\t\\subsection{Scenario}\n\tThe scenario consists of two cells with one base station and two mobile stations each. Table \\ref{trans:positions} shows the positioning of base and mobile stations. Multiple, randomized simulation runs were not necessary because all path loss based SINR compuations are deterministic.\n\t\\begin{table}\n\t\t\\centering\n\t\t\\label{trans:positions}\n\t\t\\caption{Transmitter positions in the simulated scenario.}\n\t\t\\begin{tabular}{ccc}\n\t\t\t\\toprule\n\t\t\tTransmitter & X & Y\\\\\n\t\t\t\\midrule\n\t\t\t$BS_{0}$ & $30.0$ & $30.0$ \\\\\n\t\t\t$BS_{1}$ & $75.0$ & $75.0$ \\\\\n\t\t\t$MS_{00}$ & $30.0$ & $44.0$ \\\\\n\t\t\t$MS_{01}$ & $30.0$ & $49.0$ \\\\\n\t\t\t$MS_{10}$ & $75.0$ & $89.0$ \\\\\n\t\t\t$MS_{11}$ & $75.0$ & $94.0$ \\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}\n\t\\end{table}\n\tAlso important to note is the carrier frequency $f_c=\\SI{3.5}{\\giga \\hertz}$ \n\t\n\t\\subsection{Equations}\n\tDistances between senders and receivers were computed using the \\emph{Pythagorean theorem}. The path loss calculations themselves were conducted manually using the equations given for the METIS model in Table 7-11 in \\cite{METIS1.2}. \n\t\n\tSince the simulation software uses path gain instead of loss internally, the path loss values $P_l$ computed by hand had to be changed like this:\n\t\\begin{equation}\n\t\\label{gaineq}\n\tP_g = \\frac{1}{10^{\\frac{P_l}{10}}}\n\t\\end{equation}\n\t\n\tTo arrive at the interference value for a particular sender/receiver pair, the \\emph{Johnson-Nyqist} noise of $7.4555035\\cdot10^{-16}$ was added to the path gain values of all possible interferers. For the uplink, this would be the path gain between the base station and all mobile stations from neighbouring cells. Here, we assume all transmissions occur in the same frequency block and thus interference will always occur. For the downlink, the interference is equal to the path gain between the receiving mobile station and all base stations in neighbouring cells.\n\t\n\tThe results of the computations can be found in tables \\ref{downlink} and \\ref{uplink}. Here, the \\emph{SINR} column contains the manually computed values, while the \\emph{SINR Simulation} column contains the values from the simulation run.  \n\n\\begin{table}[h!]\n  \\begin{center}\n    \\caption{Verification of simulation values against manual computations for path gain on the downlink.}\n    \\label{downlink}\n    \\pgfplotstabletypeset[\n      multicolumn names, \n      col sep=tab,\n      %skip first n=1, \n\t  %columns={MS,BS,d2d,d3d,},\t\n\t  columns/MS/.style={verb string type},\n      every head row/.style={\n\t\tbefore row={\\toprule},\n\t\tafter row={\\midrule}}, % have a rule at top\n\t  every last row/.style={after row=\\bottomrule} % rule at bottom\n    ]{computation_tables_down.txt} % filename/path to file\n  \\end{center}\n\\end{table}\n\n\\begin{table}[h!]\n  \\begin{center}\n    \\caption{Verification of simulation values against manual computations for path gain on the uplink.}\n    \\label{uplink}\n    \\pgfplotstabletypeset[\n      multicolumn names, \n      col sep=tab,\n      %skip first n=1, \n\t  %columns={MS,BS,d2d,d3d,},\t\n\t  columns/MS/.style={verb string type},\n      every head row/.style={\n\t\tbefore row={\\toprule},\n\t\tafter row={\\midrule}}, % have a rule at top\n\t  every last row/.style={after row=\\bottomrule} % rule at bottom\n    ]{computation_tables_up.txt} % filename/path to file\n  \\end{center}\n\\end{table}\n\n\\begin{thebibliography}{9}\n\n\n\\bibitem{METIS1.2}\n  METIS Project,\n  Deliverable D1.2: Initial Channel Models Based on Measurements,\n  2014.\n\n\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "867d318af025da659b52f441572ba02832a705c7", "size": 4450, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "verification_pathloss/verification_pathloss.tex", "max_stars_repo_name": "CN-UPB/koi-simulator", "max_stars_repo_head_hexsha": "ca4ddc5019f423a8e901ebed25b44dc5fa165cf0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "verification_pathloss/verification_pathloss.tex", "max_issues_repo_name": "CN-UPB/koi-simulator", "max_issues_repo_head_hexsha": "ca4ddc5019f423a8e901ebed25b44dc5fa165cf0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "verification_pathloss/verification_pathloss.tex", "max_forks_repo_name": "CN-UPB/koi-simulator", "max_forks_repo_head_hexsha": "ca4ddc5019f423a8e901ebed25b44dc5fa165cf0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.8421052632, "max_line_length": 568, "alphanum_fraction": 0.7337078652, "num_tokens": 1247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.42180584972595614}}
{"text": "\\section{Digital Signal Processing}\r\nDigital Signal processing (DSP) is an engineering field focused on analyzing and altering digital signals. It takes real-world signals like voice, audio, video and then mathematically manipulates them~\\cite{dsp}. \\par\r\n\r\nSignals need to be processed so that the information they contain can be displayed, analyzed or converted to another type of signal. Analog-to-Digital converters take signals from the real-world and turn them into binary digital format. At this point, the DSP takes over by capturing the digitized information and processes it, later to be fed back for use in the real-world. \\par\r\n\r\n\\subsection{Sound}\r\n\\par\r\nSound is produced when something vibrates. The vibration causes the medium around it to vibrate as well. Vibrations propagated through air are called traveling longitudinal waves~\\cite{physics_of_sound}, which we can hear.\r\nA sound wave is made out of two areas of high and low pressure called compressions and rarefactions (figure 3). \\par\r\n\r\nThe pattern of the wave repeats after one wavelength. The height of the wave is called \\textbf{amplitude}. It is what determines how loud the sound will be (the greater the amplitude, the louder the sound).\r\n\r\nThe wavelength and the speed of the wave determine the pitch (frequency of the sound). \\par \r\n\r\n\r\n\\begin{equation}\r\nc = f \\cdot \\lambda \\textnormal{, where $c=speed$, $f=frequency$, $\\lambda=wavelength$}\r\n\\end{equation}\r\n\r\n\\begin{figure}[h]\r\n\t\\caption[Traveling Wave]{\r\n\t\tTraveling wave components~\\cite{traveling_wave} }\r\n\t\\centering\r\n\t\\includegraphics[width=1\\textwidth, height=\\textheight, keepaspectratio]{Wavelength}\r\n\\end{figure}\r\n\r\n\\subsection{Pitch}\r\nIn music, the pitch tells how low or high a note is. In physics, it is measured in a unit called Hertz (Hz) and it is known as frequency. A note that vibrates at 256Hz will be caused by a sound wave vibrating at 256 times/second. \\par\r\n\r\nThe speed is influenced by the medium in which the sound wave travels. Under standard conditions of temperature and pressure, sound is speed is 343 meters per second~\\cite{speed_of_sound}.\r\n\r\nThe equation (5) can be rewritten as:\r\n\\begin{equation}\r\nf = \\dfrac{c}{\\lambda} \\textnormal{, where $c=speed$, $f=frequency$, $\\lambda=wavelength$}\r\n\\end{equation}\r\n\r\n\r\n\\subsection{Discrete Fourier transformation}\r\nThe Discrete Fourier Transformation (DFT) is one of the most important operation of DSP. It is any quantity or signal that varies over time, such as the pressure of a sound wave, sampled over a finite time interval (often defined by a window function)~\\cite{discrete}.\r\n\\par\r\n\r\n\\begin{equation}\r\nX[k] = \\dfrac{1}{N} \\sum_{j=0}^{N-1}(x[j] \\cdot e^ {-j \\cdot( \\dfrac{2\\pi}{N}) ) \\cdot n \\cdot k }  \\text{ for $k = 0...N$-1}\r\n\\end{equation}\r\n\r\nThe DFT shows what frequencies are present in your signal and in what proportions.\r\n\\par\r\nIt has a complexity of $O(n^2)$ so in practice, the Fast Fourier Transform (FFT) algorithm is used instead. FFT runs in $O(n\\cdot log(n))$.\r\n\r\n\\subsection{Fast Fourier transform}\r\nThe fast Fourier transform(FFT) computes the DFT of a sequence, or its inverse (IDFT)~\\cite{FFT}. It rapidly computes such transformations by factorizing the DFT matrix into a product of sparse factors. As a result, it manages to reduce the complexity of computing the DFT from $O(n^2)$ to $O(n\\cdot log(n))$, where n is the data size. The difference in speed can be huge, especially for large data sets where n can reach thousands of millions. Because of this, FFTs are widely used for applications in engineering, science and mathematics.\r\n\r\n\\subsection{Short-Term Fourier transform}\r\nWhile DFT is really good by itself, if used on an entire song it would only tell what frequencies exist, but not when they occur. This is where Short-Term Fourier Transform (STFT) comes in handy. It computes DFT over a full signal but in small segments. Because of this, we can see how frequencies change over time, which makes it a good way to compute spectrograms. (Figure 4) \r\n\r\n\\begin{figure}[h]\r\n\t\\caption[Spectrogram using Short-Term Fourier Transform]{ Spectrogram using STFT~\\cite{stft_fig}}\r\n\t\\centering\r\n\t\\includegraphics[width=1\\textwidth, height=\\textheight, keepaspectratio]{\"resources/STFT_spectrogram\"}\r\n\\end{figure}\r\n\r\n\r\n\\subsection{Constant-Q transform}\r\nIn general, the transform is well suited to musical data, and this can be seen in some of its advantages compared to the fast Fourier transform. As the output of the transform is effectively amplitude/phase against log frequency, fewer frequency bins are required to cover a given range effectively, and this proves useful where frequencies span over several octaves. As the range of human hearing covers approximately ten octaves from 20 Hz to around 20 kHz, this reduction in output data is significant~\\cite{constant_q}. \\par\r\n See Figure 5 for a comparison between the Constant-Q transform and STFT.\r\n%work on this more\r\n\r\n\r\n%maybe change this later\r\n\\begin{figure}[h]\r\n\t\\caption[Constant Q vs STFT spectrogram of C major scale]{ Constant Q (left) vs STFT (right) spectrogram of C major scale}\r\n\t\\centering\r\n\t\\label{fig:cq_vs_stft}\r\n\t\\includegraphics[width=1\\textwidth, height=\\textheight, keepaspectratio]{\"resources/Q_vs_STFT\"}\r\n\\end{figure}", "meta": {"hexsha": "46423a80b105496cf19e5875d3785adf3d80ec9e", "size": 5243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Resources/licenta/chapters/digital_processing.tex", "max_stars_repo_name": "CotaCalin/AutomatedMusicTranscription", "max_stars_repo_head_hexsha": "02ea0d2f48f614f8a929f687a112e8b309599d63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-18T16:06:49.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-18T16:06:49.000Z", "max_issues_repo_path": "Resources/licenta/chapters/digital_processing.tex", "max_issues_repo_name": "CotaCalin/AutomatedMusicTranscription", "max_issues_repo_head_hexsha": "02ea0d2f48f614f8a929f687a112e8b309599d63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Resources/licenta/chapters/digital_processing.tex", "max_forks_repo_name": "CotaCalin/AutomatedMusicTranscription", "max_forks_repo_head_hexsha": "02ea0d2f48f614f8a929f687a112e8b309599d63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.9066666667, "max_line_length": 541, "alphanum_fraction": 0.7654014877, "num_tokens": 1298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.42180584972595614}}
{"text": "\\chapter{Abstract Refinement Types}\\label{chapter:abstractrefinements}\n\\makequote\n{The purpose of abstraction is not to be vague,\\\\\nbut to create a new semantic level in which one can be absolutely precise.}\n{Edsger W. Dijkstra}\n\n\n\\renewcommand{\\reft}{\\ensuremath{e}\\xspace}\n\\renewcommand\\tref[2]{\\ensuremath{\\left\\lbrace \\vref : #1\\mid #2\\right\\rbrace}}\n\\renewcommand\\tref[2]{\\ensuremath{\\left\\lbrace \\vref : #1\\mid #2\\right\\rbrace}}\n\n\\renewcommand\\subt{\\preceq}\n\\renewcommand\\corelan{$\\lambda_\\downarrow$\\xspace}\n\\renewcommand\\sub[2]{\\ensuremath{ \\left[ #1 \\mapsto #2 \\right] }}\n\\renewcommand\\shape{\\ensuremath{\\text{shape}}\\xspace}\n\\renewcommand\\tfun[3]{\\ensuremath{{(#1:#2)} \\rightarrow #3}}\n\n\n\\renewcommand\\ecase[5]{\\ensuremath{\n\t\\mathtt{case}\\ #5 = #1\\ \\mathtt{of}\\ \\{ #2\\ #3 \\rightarrow #4\\}\n}}\n\n\\renewcommand\\corelan{$\\lambda_{P}$\\xspace}\n\n\n\\input{text/abstractrefinements/intro}\n\\input{text/abstractrefinements/overview}\n\\input{text/abstractrefinements/typechecking}\n\\input{text/abstractrefinements/experiments}\n\\input{text/abstractrefinements/conclusion}\n\n\\mypara{Acknowledgments}\nThe material of this chapter are adapted from the following publication:\n\\noindent N. Vazou, P. Rondon, and R. Jhala,\n``Abstract Refinement Types'', \nESOP, 2013.\n", "meta": {"hexsha": "4f130f20e51ae42faa27bcf1f60a755618d73b62", "size": 1253, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/abstractrefinements.tex", "max_stars_repo_name": "nikivazou/thesis", "max_stars_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-12-02T00:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T07:04:01.000Z", "max_issues_repo_path": "text/abstractrefinements.tex", "max_issues_repo_name": "nikivazou/thesis", "max_issues_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text/abstractrefinements.tex", "max_forks_repo_name": "nikivazou/thesis", "max_forks_repo_head_hexsha": "a12f2e857a358e3cc08b657bb6b029ac2d500c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-12-02T00:46:51.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T00:46:51.000Z", "avg_line_length": 33.8648648649, "max_line_length": 79, "alphanum_fraction": 0.7501995211, "num_tokens": 407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4217903292489042}}
{"text": "\\section{Pauli blocking simulation.}\n\n\\hspace{1.0em}A free particle interaction \ncross section is reduced to an effective cross section\nby the Pauli-blocking due to Fermi statistics. For each \ncollision the phase-space densities $f_i$, where $i$ means fermion, in\nthe final states should be checked in order to assure that the final\ndistribution in phase space is in agreement with the Pauli principle,\nwhich rules out the posibility of finding more than one fermion in a\nsingle quantum state. There are two different Pauli blocking procedures: \nthe cascade Pauli blocking procedure, which can be applied for final state \nnucleons in case of hadron--nucleus interaction and the Quantum Molecular \nDynamics (QMD) Pauli blocking procedure, which can be applied for any \nfinal state fermions.\n\n\\subsection{The cascade Pauli blocking procedure.}\n\n\\hspace{1.0em}In this procedure, a  nucleus with atomic number $A$ and\ncharge $Z$ is treated as an ideal local completely degenerate Fermi gas\nof nucleons with coordinates ${\\bf r}$, momenta ${\\bf p}$.  The nucleon\nphase-space density is approximated by\n\\begin{equation}\n\\label{PBS1} f_{i}({\\bf r}, {\\bf p}) = \\Theta \n({\\bf p}_{i}^F({\\bf r}) - {\\bf p}).\n\\end{equation}\nBecause all states below Fermi-level are already occupyied, after each\ninteraction one should check that the momenta ${\\bf p^{\\prime}}_i$ of\nall secondary nucleons are above the Fermi-level, i. e.\n\\begin{equation}\n\\label{PBS2} p^{\\prime}_i > p_{i}^F(r).\n\\end{equation}\nIf among the secondary nucleons there is a nucleon with momentum lower\nthe the Fermi-level, then this collision is considered as prohibited\n(Pauli-blocked).\n\n\n\\subsection{ The QMD Pauli blocking procedure.} \n\n\\hspace{1.0em}We consider nucleons (and other fermions)\nare not points in phase space. They are represented by Gaussian shaped\ndensity distributions \\cite{URQMD97}:\n\\begin{equation}\n\\label{PBS3}\\phi({\\bf x_i}, t) = (\\frac{2\\alpha}{\\pi})^{3/4}\n\\exp{\\{-\\alpha ({\\bf x_i}\n- {\\bf r_i} (t))^2 + \\frac{i}{\\hbar}{\\bf p_i} (t) {\\bf x_i}\\}}, \n\\end{equation}\nwhere $\\alpha=0.25$ \\ fm$^{-2}$ is a model parameter and $\\hbar =\n197.327$ \\ MeVfm is the conversion constant. .  The total wave function\nis assumed to be a direct product of these functions.  The phase-space\ndensity can be obtained by the Wigner transform of the wave function:\n\\begin{equation}\n\\label{PBS4} f({\\bf r}, {\\bf p})=\\sum_{i}f_i({\\bf r}, {\\bf p}),\n\\end{equation}\nwhere\n\\begin{equation}\n\\label{PBS5} f_i({\\bf r}, {\\bf p})= \\frac{1}{(\\pi\\hbar)^3}\\exp{\\{-2\\alpha ({\\bf r}\n- {\\bf r}_i(t) )^2 - \\frac{1}{2\\alpha {\\hbar}^2}({\\bf p}-{\\bf p}_i(t))^2 \\}}\n\\end{equation} \nwith normalization\n\\begin{equation}\n\\label{PBS6} \\int d{\\bf r}d{\\bf p}f_i({\\bf r}, {\\bf p})=1.\n\\end{equation}\nThe normalised on the number of particles density is\n\\begin{equation}\n\\label{PBS7} \\rho({\\bf r})=\\sum_{i}\\rho_i({\\bf r}),\n\\end{equation}\nwhere\n\\begin{equation}\n\\label{PBS8} \\rho_i({\\bf r})=\\int \\frac{d{\\bf p}}{(\\pi\\hbar)^3}f_i({\\bf r},{\\bf p})=\n(\\frac{\\pi}{2\\alpha})^{-3/2}\\exp{\\{-2\\alpha ({\\bf r}-{\\bf r}_i)^2\\}}.\n\\end{equation}\n\nThe normalised on the number of particles momentum density is\n\\begin{equation}\n\\label{PBS9} g({\\bf p})=\\sum_{i}g_i({\\bf p}),\n\\end{equation}\nwhere\n\\begin{equation}\n\\label{PBS10} g_i({\\bf p})=\\int \\frac{d{\\bf r}}{(\\pi\\hbar)^3}f_i({\\bf r},{\\bf p})=\n\\hbar^{-3}(2\\pi\\alpha )^{-3/2}\\exp{\\{-\\frac{1}{2\\alpha \\hbar^2} ({\\bf p}-{\\bf p}_i)^2\\}}.\n\\end{equation}\n\nThe overlap phase-space density $f^{ovp}_i$ and particle density\n$\\rho^{ovp}_i$ of particle $i$ with other particles are given by\n\\begin{equation}\n\\begin{array}{c}\n\\label{PBS11} f^{ovp}_i = \\sum_{j\\neq i}\n\\int d{\\bf r}d{\\bf p} f_i({\\bf r},{\\bf p})f_j({\\bf r},{\\bf p})= \\\\\n= \\frac{1}{8(\\pi \\hbar)^{3}}\\sum_{j\\neq i}\n\\exp{\\{-\\alpha ({\\bf r}_i-{\\bf r}_j)^2-\\frac{1}{4\\alpha \\hbar^2}({\\bf p}_i-{\\bf p}_j)^2\\}}\n\\end{array}\n\\end{equation}\nand\n\\begin{equation}\n\\label{PBS12} \\rho^{ovp}_i = \\sum_{j\\neq i}\n\\int d{\\bf r} \\rho_i({\\bf r})\\rho_j({\\bf r})\n= \\sum_{j\\neq i}(\\frac{\\pi}{\\alpha})^{-3/2}\n\\exp{\\{-\\alpha ({\\bf r}_i-{\\bf r}_j)^2\\}}.\n\\end{equation}\n\nThus the phase-space fermion overlaping densities $f^{ovp}_i$ at the\nfinal states can be directly calculated and used for simulation of\nPauli-blocking.\nFor two indistinguishable nucleons $i$ and $j$ the  function\n\\begin{equation}\n\\begin{array}{c}\n\\label{PBS13}\nF^{block}_{i}=\\sum_{j\\neq i} 8(\\pi \\hbar)^3 \\delta_{\\sigma_i\\sigma_j}\n\\delta_{\\tau_i\\tau_j}\n\\int d{\\bf r}d{\\bf p} f_i({\\bf r},{\\bf p})f_j({\\bf r},{\\bf p})]= \\\\\n=\\delta_{\\sigma_i\\sigma_j}\\delta_{\\tau_i\\tau_j}\n\\exp{\\{-\\alpha ({\\bf r}_i-{\\bf r}_j)^2-\\frac{1}{4\\alpha \\hbar^2}\n({\\bf p}_i-{\\bf p}_j)^2\\}}\n\\end{array}\n\\end{equation}\ncan be interpreted as the Pauli-blocking probability.\n  Here\n$\\sigma_{i,j}=\\pm 1$ and $\\tau_{i,j}=\\pm 1$ denote spin and isospin\nindices of nucleons, respectively.\nFor example the Pauli-blocking of the two-body collisions can be checked by the\nblocking-probability $1- (1-F^{block}_i)(1-F^{block}_j)$.\n\n\\subsection{The QMD Pauli-blocking algorithm.}\n\\hspace{1.0em}For each produced baryon, which is located at position\n${\\bf r}$ and has momentum ${\\bf p}$, the value of\n$F^{block}_i$\nand at the same time the value of \n\\begin{equation}\n\\label{PBS14}\nd_i=\\sum_{j\\neq i}\\exp{\\{-2\\alpha ({\\bf r}-{\\bf r}_i)^2\\}}\n\\end{equation}\nare calculated.  As was found in \\cite{Konopka96}, there is an\napproximately straight line dependence:\n\\begin{equation}\n\\label{PBS15}\nF^{block}_i = a_{fit} + b_{fit}d_i,\n\\end{equation}\nwhere $a_{fit}=1.49641$ and $b_{fit}=0.208736$, which divides\n$(F^{block}_i-d_i)$-plane into two the Pauli-blocked and the\nPauli-allowed domains.\n\nThen a collision is only allowed, if computed values fulfill the\nconditions:\n\\begin{equation}\n\\label{PBS16} F^{block}_i \\leq a_{fit} + b_{fit}d_i\n\\end{equation}  \nfor each outgoing baryon $i$.\n", "meta": {"hexsha": "a44215d45704625745e34ee0956093a069ab7224", "size": 5789, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant4/hadronic/theory_driven/HadronKinetic/PauliBlockingSimulation.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant4/hadronic/theory_driven/HadronKinetic/PauliBlockingSimulation.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant4/hadronic/theory_driven/HadronKinetic/PauliBlockingSimulation.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1148648649, "max_line_length": 90, "alphanum_fraction": 0.688201762, "num_tokens": 2060, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4217903292489042}}
{"text": "\\newpage\n\\chapter{Batch Reactor}\n\n\\section{Introduction}\nThe batch reactor model of Camflow has limited features. The limitation of the batch reactor models is that it is a constant volume batch reactor model and does not solve the energy equation. Only isothermal calculations can be performed with the batch reactor model of Camflow. \n\n\\section{Fundamentals}\nThe following governing equation is solved\n\\begin{equation}\n \\rho \\frac{dY_k}{dt} = \\dot{s}_k \\bar{W}, \\quad k=1\\ldots K_g.\n\\end{equation}\nHere $\\rho$ is the density of the fluid, $Y_k$ is the mass fraction of the k\\'th species, $\\dot{s}_k$ is the molar production rate of the k\\'th chemical species in mol/m$^3$, and $\\bar{W}$ is the average molecular weight of the mixture in kg/mol.\n\n\n\\section{Input file}\nA complete input file (camflow.xml) for a batch reactor simulation is shown below\n{\\scriptsize{\n \\begin{verbatim}\n<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<camflow>\n   <reactor model=\"batch_cv\">\n   </reactor>\n   <op_condition>\n      <temperature>isothermal</temperature>\t  \n      <pressure unit=\"Pa\">1e5</pressure>\n   </op_condition>\n   <inlet>\n     <fuel>       \n       <temperature unit=\"C\">800</temperature>       \n       <molefrac>\n         <species name=\"NO2\">0.1</species>\n         <species name=\"N2\">*</species>\n       </molefrac>\n     </fuel>\n   </inlet>\n   <solver mode=\"coupled\" solver=\"cvode\">\n     <tols>\n       <species>\n         <aTol>1.e-10</aTol>\n         <rTol>1.e-08</rTol>\t  \n       </species>\n       <temperature>\n         <aTol>1.e-03</aTol>\n         <rTol>1.e-03</rTol>\t  \n       </temperature>\n       <flow>\n         <aTol>1.e-03</aTol>\n         <rTol>1.e-03</rTol>\t  \n       </flow>\n     </tols>\n   </solver>\n <report species=\"mole\">\n </report>\n</camflow>\n\n\\end{verbatim}}\n}\nThe input file follows xml specifications, with camflow as the root element and a number of child elements.\nEach child element and its purpose is described below\n\\begin{itemize}\n \\item \\textbf{rector} : The reactor element specifies which reactor models is to be simulated and for a constant volume batch reactor camflow expects batch\\_cv as the model attribute value.\n\n\\item \\textbf{op\\_conditions} : The element op\\_conditions describes the operating conditions for the batch reactor. This includes the specification of the pressure and the condition applied to the solution of energy equation. Currently this model support only isothermal condition, and therefore temperature element should be assigned with isothermal condition.\n\\item \\textbf{inlet} : The inlet element holds the information on reactants and the reactant temperature at time t=0. The temperature of the reactants must be specified using the temperature element with the appropriate units. The mass or mole fraction of the reactant species need to be specified within the element molefrac or massfrac. The sum of mass fractions or mole fraction of the reactant species must sum up to 1. Instead of specifying the mass/mole fractions of all species, the last species can be assigned with *. In this case the mole/mass fraction of the last species will be 1-sum of others.\n\n\\item \\textbf{solver}: The solver element holds the solver control specifications. The attributes ``mode'' should always be specified as ``coupled'' for batch reactor simulation. The solver name is essentially provided to switch from one solver to another. However, the present version of Camflow uses only CVode as the numerical integrator, and therefore accepts only ``cvode'' as the solver name. The element tols hold the various tolarences that can be applied to the species, energy, and continuity equations. For species a relative tolarence of at least 10$^{-6}$ should be used. The user may need to adjust the tolarence values for the species in case of solution difficulties.\n\n\\item \\textbf{report}: The desired output for the species composition must be specified in this element using the species attribute. ``mole'' or ``mass'' may be used as the attribute values, and correspondingly the output will be produced either in mole fraction or mass fractions.\n\n\\section{Executing the binary}\nThe batch reactor model of Camflow expects three input files namely, ``camflow.xml'', ``therm.dat'', and ``chem.inp''. All these files must be present in the working directory. Upon succesful execution the output file ``profile.dat'' containing the integration time(s), pressure (Pa), density (kg/m$^3$), temperature (K), and the species compositions in mass or mole fractions.\n\\end{itemize}\n\n\\section{Results}\nThe following figure shows the major species that results from the batch reactor model using ABF mechanism with a fuel composition of 50 \\% O$_2$ and 50 \\%C$_2$H$_4$\n\\begin{figure*}[h]\n \\centering\n\\includegraphics[scale=0.8]{batch_profile.eps}\n\\caption{Species profiles for ABF mechanism at isothermal condition of 1500 K}\n\\end{figure*}\n\n%===============================================================================================\n%\n%\n%\n%===============================================================================================\n", "meta": {"hexsha": "4a6d9cb1e2a29e824e568ee89d6f2282e09498ad", "size": 5062, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/supporting-information/camflow/batch.tex", "max_stars_repo_name": "sm453/MOpS", "max_stars_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-08T14:06:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-04T07:52:19.000Z", "max_issues_repo_path": "doc/supporting-information/camflow/batch.tex", "max_issues_repo_name": "sm453/MOpS", "max_issues_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/supporting-information/camflow/batch.tex", "max_forks_repo_name": "sm453/MOpS", "max_forks_repo_head_hexsha": "f1a706c6552bbdf3ceab504121a02391a1b51ede", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-11-15T05:18:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T13:51:20.000Z", "avg_line_length": 58.183908046, "max_line_length": 683, "alphanum_fraction": 0.706835243, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.42179032271671574}}
{"text": "\\chapter{Calibration procedure}\n\\label{chapter:calibration}\n\n\n\\section{Processing pipeline}\n\nRaw science and house-keeping data are downloaded at\nEsrange and transferred to a data archive housed by the Parallel\nData Centre (PDC) at the Royal Institute of Technology (KTH)\nin Stockholm. The data processing for the calibration \\smr\\\nmeasurements is performed at the Dept. of Earth and Space\nSciences at Chalmers University of Technology (Chalmers) in Gothenburg.\nA file system at Chalmers is synchronized with the Level0-file archive \nat KTH. The KTH archive also contains files with reconstructed attitude\ninformation.  Science and house-keeping data within those files\nare imported into Level0 tables of an Odin calibration database. \nDedicated algorithms to process and combine new Level0 to Level1B\ndata are executed on a regular basis and are described in this\nchapter. Level1B data are stored in tables of the Odin calibration database.  \nChapter 3 describes its format and how to access the Level1B data.\n\n\n\\section{Radiometric calibration algorithm}\n\n\\subsection{Auto-correlator data}\n\nData from the ACs must be transformed to spectra in the frequency domain\nprior to the radiometric calibration.\nThis preparation of AC data basically involves a quantisation correction and the application\nof a Fourier transform.\nIn the spectrometer hardware, the input signal is quantized into three levels: \nhigh positive, high negative, and low amplitude. The input signal is furthermore delayed, \ncross multiplied and integrated to obtain a measure of the auto-correlation function of the \ninput signal \\(s(t)\\). Below is given an overview of the applied processing steps that \ntransforms the measure of the auto-correlation function to a spectrum in the frequency \ndomain:\n\n\\begin{itemize}\n\n\\item Accurate quantization correction requires accurate knowledge of the threshold\n levels used at quantization. The quantization correction used is only valid \nif the absolute values of the the positive and negative threshold levels are equal. \nThe \\smr\\ correlators provide monitor channels to check the\nassumption of equal absolute values of the positive and negative threshold levels.\nOnly when this condition is fulfilled the data will be further processed,\notherwise the data will be blanked (filled with zeros).\n\n\\item The estimation of the true correlation \\(\\rho\\) from the measured correlation\ncoefficient \\(r\\) at lag \\(\\tau\\) is then achieved by performing a quantization correction using\nKulkarni and Heiles approximation described in \\citet{ohlberg:theod:03}.\n\n\\item A Hanning smoothing is applied, which results in that the obtained resolution \nof the spectra is 2\\,MHz although the channel spacing is 1\\,MHz\n\n\\item The Fourier transform of the auto correlation function gives the\npower spectral density, or a spectrum in the frequency domain.\n\n\n\\end{itemize}\n\n\n\\subsection{Radiances}\n\n\nThe radiance emitted by a blackbody per frequency unit is\n\\begin{equation}\n B_{\\nu} = \\frac{2h\\nu^{3}}{c^{2}}\\frac{1}{\\exp(\\frac{h\\nu}{kT})-1},\n\\end{equation}   \nwhere \\(\\nu\\) is frequency, \\(h\\) is Planck's constant, \\(k\\) is Boltzmann's constant,\n\\(c\\) is the speed of light, and \\(T\\) is the physical temperature of the\nblackbody.\nThe Rayleigh--Jeans correspondence (valid when \\(h\\nu/kT\\)<<1) reads\n\\begin{equation}\n B_{v}=\\frac{2\\nu^{2}kT}{c^{2}}.\n\\end{equation}\n\nThe \\smr\\ radiometers are heterodyne systems which receive a power (\\(P_{\\nu}\\))\nper unit frequency range (spectral power density),\n\\begin{equation}\nP_{\\nu} = \\frac{c^{2}}{2\\nu^{2}}B_{\\nu}\n\\end{equation} \nwhere \\(\\nu\\) is frequency, \\(h\\) is Planck's constant, \\(k\\) is Boltzmann's constant,\nwhen viewing a blackbody source at temperature (\\(T\\)) that completely\nfills the antenna field of view. \nIf the Rayleigh--Jeans approximation is valid, we then have that\n\\begin{equation}\nP_{\\nu} = kT.\n\\end{equation}\nFor a theoretical receiver and channel of bandwidth \\(\\Delta \\nu\\), with zero loss and gain \nand a unit frequency response, the received power is\n\\begin{equation}\n P = kT\\Delta \\nu.\n\\end{equation}   \n\nBrightness temperature (\\(T_{b}\\)) and antenna temperature (\\(T_{a}\\))\nare two closely related quantities. They are both defined with respect to a \nmatching blackbody temperature. However, they differ in that \\(T_{b}\\) corresponds \nto radiance while \\(T_{a}\\) must be seen as a measure on power.\nThe brightness temperature is defined as the physical temperature \na blackbody would have to generate the same radiance as the one of concern.\nThat is, for a given radiance \\(I\\), \\(T_{b}\\) is defined as\n\\begin{equation}\n I = B_{v}(T_{b}),\n\\end{equation}\nand in the Rayleigh--Jeans approximation this gives\n\\begin{equation}\n T_{b} = \\frac{c^{2}I}{2kv^{2}}.\n\\end{equation}\nHence, the Rayleigh--Jeans temperature of a blackbody can be written as \n\\begin{equation}\n T_{b} = \\frac{h\\nu}{k}\\frac{1}{\\exp(\\frac{h\\nu}{kT})-1}.  \n\\label{eq:tbrj}\n\\end{equation}\n\n\nThe antenna temperature is defined as the temperature of an ideal black\nbody that would result in the same received power at the antenna aperture \nas in the actual case, which gives that (using Rayleigh--Jeans approximation)\n\\begin{equation}\nT_{a} = \\frac{P}{k\\Delta \\nu}\n\\end{equation}\n\nA radiometer detects radiant power but the measured power can be converted to an\nantenna or brightness temperature or a radiance, but it should be\nremembered that it is only power that can actually be measured.\n \n\n\\subsection{\\smr\\ observation sequence and measured signals} \n\\label{sec:smrobs}\n\n\\begin{figure}[t]\n\\includegraphics[width=14cm]{cal_signals.png}\n\\caption{ The upper panel shows the tangent altitude of the main beam\nfor a number of scans.\nThe middle panel shows the internal load temperature.\nThe lower panel shows intensity variation, \nof one of the sub-bands of freqmode~1,\nfor the three types of signals (described in text) involved\nin the intensity calibration scheme.}\n\\label{fig:intensityvar}\n\\end{figure}\n\n\n\nFor calibration purposes, Odin/SMR performs areonomy observation in a switching\nmode, i.e. switching between the main beam and an unfocused sky beam. \nIn nominal operation every other recorded signal comes from an unfocused cold sky\nbeam, except around the lower and upper turning points of the scan where the reference\nbeam is directed towards the internal load, typically three consecutive load spectra are\nrecorded. The internal load acts as a blackbody emitter at an ambient temperature of around 285\nK. \n\nThe intensity calibration of \\smr\\ is thus performed by using\ninformation from three types of signals (see Fig~\\ref{fig:intensityvar}), \ni.e. the cold sky beam signal (\\(c_{s}\\)), the load signal (\\(c_{l}\\)), \nand the main beam signal (\\(c_{a}\\)).\nThe calibration scheme is based on the assumption that the\ndigital value (e.g. \\(c_{a,i}\\)) read out from channel \\(i\\) of the\nspectrometer is proportional to the power of the\nobserved signal. The contributions to the three signals\ncan be expressed as:\n\n\\begin{equation}\nc_{a,i}=g_{i}\\left(\\eta_{a} T_{a,i} + T_{rec,i} + (1-\\eta_{a})T_{amb,i} \\right) = \ng_{i}\\left(\\eta_{a} T_{a,i} + T_{rec,i} + T_{sp} \\right) ,\n\\end{equation}\n\\begin{equation}\n\\label{eq:skybeam}\nc_{s,i}=g_{i}\\left(T_{s,i}+T_{rec,i}\\right) \\approx g_{i}\\left(T_{rec,i}\\right),\n\\end{equation}\n\\begin{equation}\nc_{l,i}=g_{i}\\left(T_{l,i}+T_{rec,i}\\right),\n\\end{equation}\nwhere \\(g_{i}\\) is the receiver gain, \\(\\eta_{a}\\) is the main beam\nefficiency (it is assumed that beam efficiencies for\nboth the sky beam and load signals are unity),\n\\(T_{amb,i}\\) is the receiver ambient temperature,\nand \\(T_{rec,i}\\) is the receiver noise temperature.\n\\(T_{a,i}\\), \\(T_{s,i}\\), and \\(T_{l,i}\\) are the antenna temperature,\ncosmic background temperature, and load temperature, all expressed\nas equivalent Rayleigh--Jeans brightness temperatures (\\(T_{b}\\)).\nThe Rayleigh--Jeans brightness temperature of the cosmic background radiation\nat 500 GHz is only 0.003\\,K, (Eq.~\\ref{eq:tbrj}) and typical \\(T_{rec}\\) value of \\smr\\ is 3000\\,K,\nthus the approximation in eq.~\\ref{eq:skybeam} results in negligible error.\n\nThe main beam signal is always at a higher level than the cold sky signal\n(Fig.~\\ref{fig:intensityvar}), which is due \nto thermal emission from a baffle which only affects the main beam signal.\nThus, the main beam intercepts with the baffle\nand the spill over contribution (\\(T_{sp}\\)):\n\\begin{equation}\n\\label{eq:tspill1}\nT_{sp}=(1-\\eta_{a})T_{amb}.\n\\end{equation}\n\n\\subsection{Calibration: basic equations}\n\\label{sec:caleq}\nThe aim of the calibration process is to use  \ninformation from the signals described in Sect.~\\ref{sec:smrobs}\nin order to derive an estimate of the antenna temperature.\nHere we derive expressions for how the unknown \\(T_{rec,i}\\),\n\\(g_{i}\\), \\(T_{sp}\\), \\(n_{a}\\), and \\(T_{a,i}\\) can be derived.\nIn Sect.~\\ref{sec:calscheme} the actual \\smr\\ calibration is described. \n\nEq.~\\ref{eq:skybeam} gives that\n\\begin{equation}\n\\label{eq:trec}\nT_{rec,i}=\\frac{c_{s,i}}{g_{i}},\n\\end{equation}\nand \\(g_{i}\\) can be obtained from the difference between \\(c_{l,i}\\) and\n \\(c_{s,i}\\), i.e.\n\\begin{equation}\n\\label{eq:gain}\ng_{i}=\\frac{c_{l,i}-c_{s,i}}{T_{l,i}-T_{s,i}}.\n\\end{equation}\nBy combining Eq.~\\ref{eq:trec} and~\\ref{eq:gain} we obtain\n\\begin{equation}\n\\label{eq:trec2}\nT_{rec,i}=c_{s,i}\\frac{{T_{l,i}-T_{s,i}}}{c_{l,i}-c_{s,i}}.\n\\end{equation}\n\n\\(T_{a,i}\\) can be obtained from the difference between between\n\\(c_{a,i}\\) and \\(c_{s,i}\\), i.e.\n\\begin{eqnarray}\n\\label{eq:ta}\nT_{a,i} &=& \\frac{1}{\\eta_{a}}\\left(\\frac{c_{a,i}-c_{s,i}}{g_{i}} - T_{sp}\\right) \\nonumber\\\\\n &=& \\frac{1}{\\eta_{a}}\\left( \\left(c_{a,i} - c_{s,i}\\right)\\frac{T_{rec,i}}{c_{s,i}} -T_{sp} \\right). \n\\end{eqnarray}\n\nFor measurements at tangent altitude above the atmosphere,\n\\(T_{a,i}\\) = 0. Thus, we have that for these measurements\nto a very good approximation\n\n\\begin{equation}\n\\label{eq:tspill2}\nT_{sp,i}= \\left(c_{a,i}-c_{s,i}\\right)\\frac{T_{rec,i}}{c_{s,i}}.\n\\end{equation}\n\nCombining Eq.~\\ref{eq:tspill1} and~\\ref{eq:tspill2} gives that\n\\begin{equation}\n\\label{eq:eta}\n\\eta_{a}=1-\\frac{T_{sp}}{T_{amb}}=1-\\frac{\\left(c_{a,i}-c_{s,i}\\right)\\frac{T_{rec,i}}{c_{s,i}}}{T_{amb}}.\n\\end{equation}\n\n\\subsection{Ripple}\n\\label{sec:ripples}\nEquation~\\ref{eq:ta} can be thought of as the main intensity\ncalibration equation for the \\smr\\ calibration scheme.\nIn the derivation of Eq.~\\ref{eq:ta}\nthe reference signals are assumed to be ``clean''.\nIn practice, there seems to be a small imbalance between \nmeasurements and references for \\smr. \nSmall perturbations of the sky and load signals will\nresult in undesired features in calibrated\nspectra (which we denote as ``ripple'') \nif not taken into account (see Fig.~\\ref{fig:ripple1}).\nThe sensitivity of calibrated \\(T_{a,i}\\) \nto small perturbations on \\(T_{s,i}\\) and \\(T_{l,i}\\) are:\n\\begin{equation}\n\\frac{dT_{a,i}}{dT_{s,i}}=\\frac{1}{\\eta_{a}}\\left(1-\\frac{c_{a,i}-c_{s,i}}{c_{l,i}-c_{s,i}}\\right)\\approx \\frac{1}{\\eta_{a}}\\left(1-\\frac{T_{a,i}}{T_{l,i}}\\right)\n\\end{equation}\nand\n\\begin{equation}\n\\frac{dT_{a,i}}{dT_{l,i}}=\\frac{1}{\\eta_{a}}\\left(\\frac{c_{a,i}-c_{s,i}}{c_{l,i}-c_{s,i}}\\right)\\approx \\frac{1}{\\eta_{a}}\\left(\\frac{T_{a,i}}{T_{l,i}}\\right).\n\\end{equation}\nThus, the sensitivity is linearly proportional to \\(T_{a,i}\\).\nWhen \\(T_{a,i}\\) is close to or 0 K (as it is for measurements at high\ntangent altitudes) the sensitivity to perturbations of\nthe sky beam signal is at its maximum.\nOn the other hand, perturbations on the load signal then have practically\nno impact on \\(T_{a,i}\\).\nIf \\(T_{a,i}\\) were equal to the load temperature the situation would be reversed,\nthough this is never the case in practice.\n\nA model for the removal of the effects of ripple on the reference signals\non estimated \\(T_{a,i}\\) (from Eq.~\\ref{eq:ta}) to achieve a new\nbetter estimate \\(T^{'}_{a,i}\\) of the antenna temperature then reads\n\\begin{equation}\n\\label{correction}\nT^{'}_{a,i}=T_{a,i}-\\frac{1}{\\eta_{a}}\\left(1-\\frac{T_{a,i}}{T_{l,i}}\\right) s_{0,i}-\n \\frac{1}{\\eta_{a}}\\left(\\frac{T_{a,i}}{T_{l,i}}\\right) s_{1,i},\n\\end{equation}\nwhere \\(s_{0,i}\\) and \\(s_{1,i}\\) can be seen as spectra that contain\nthe ripple induced features for \\(T_{a,i}\\)=0\\,K and \\(T_{a,i}\\)=\\emph{load~temperature}\nrespectively.\n\n\\subsection{Intensity calibration scheme} \n\\label{sec:calscheme}\n\nThe intensity calibration scheme can be divided into two parts. The first part can be\nseen as a scan based calibration scheme, in which the Equations of Sect.~\\ref{sec:caleq} are applied.\nThe second part takes ripples (\\ref{sec:ripples}) into account and uses the results\n(for a long period of time of measurements) from the first part of the calibration.\n\n\n\\subsection*{Part 1}\n\nThe Odin calibration scheme (version 8) is scan-based, as will be described below, and\nthis is one of the main differences to previous verisons. \n\nEquation~\\ref{eq:ta} is the key equation of the calibration.\nFrom this equation we see that to calibrate a given target signal\nwe need to determine \\(T_{rec,i}\\), \\(T_{sp}\\), \\(\\eta_{a}\\),\nand \\(c_{s,i}\\). The variables \\(T_{rec,i}\\), \\(T_{sp}\\), and \\(\\eta_{a}\\)\nare assumed to be fairly stable over short time scales.\nCommon values of all these parameters are used for\nthe calibration of all \\(c_{a}\\) signals within a given scan.\n\\(g\\) can vary significant over short time-scales,\nand this is taken into account by the division of \\(c_{a}\\) with\n\\(c_{s}\\) (with a unique \\(c_{s}\\) for each \\(c_{a}\\)\nsignal of the scan). The intensity calibration scheme (version 8)\nfor a given scan can be summarized as:\n\\begin{itemize}\n\\item collect all relevant level0 and level1 data for the scan and for an\nadditional time-period of \\(\\pm\\)45 minutes.\nIt is assured that only data with ssb attenuator settings\nas in the first load signal of the scan is used.\nFurthermore, only data where calibrated sky frequencies changes by less\nthan 1 MHz from one signal to another is used.\n\n\\item filter data, i.e. remove untrusted reference signals:\\newline\nOnly sky beam signals from Sky Beam 1 (SK1) are used.\nAn SK1 signal is only used if the previous\nreference signal was from SK1.\nSK1 signals with skybeamhit flags EARTH1, MOON1, and SUN1 are not used.\nOnly the second load signal is used for each sequence of load signals\nobservation.\n\n\\item estimate an average \\(T_{rec}\\) spectrum:\\newline\nEquation~\\ref{eq:trec2} is applied to calculate \\(T_{rec}\\)\nfor all kept \\(c_{l}\\) signals, where\nthe two nearest \\(c_{s}\\) signals are linearly interpolated\nin time to \\(c_{l}\\).\nThe mean value of all \\(T_{rec}\\) is used as the\ncommon \\(T_{rec}\\) spectrum within a given scan.\n\\item estimation of a scalar \\(T_{sp}\\):\\newline\n\\(T_{sp}\\) is estimated from measurements at high tangent altitude\nby applying Eq.~\\ref{eq:tspill2}.\nThe median of the median\nfrom all \\(c_{a}\\) signals, measured within the top 10 km\nof the range of tangent altitudes, is used as a common scalar \\(T_{sp}\\).\n\\item estimation of \\(\\eta_{a}\\):\\newline\n\\(\\eta_{a}\\) is estimated by applying Eq.~\\ref{eq:eta},\nusing the estimated \\(T_{sp}\\) described above, and an\nassumed \\(T_{amb}\\) of 300 K.\n\\item estimate \\(T_{a}\\): \\newline\napply Eq.~\\ref{eq:ta}, using the estimated parameters as described\nabove and\nthe two nearest \\(c_{s}\\) signals are linearly interpolated\nin time to \\(c_{a}\\).\n\\end{itemize}\n\n\n\n\\subsection*{Part 2}\n\n\\begin{figure}[t]\n\\includegraphics[width=14cm]{calibration_step2_fig.png}\n\\caption{Schematic of part 2 of the intensity calibration.\nThe upper panel shows uncorrected average spectra for frequency mode 2 observations\nwith tangent points between 80 and 120\\,km. The color-coding corresponds\nto ambient temperature of the satellite (hotload temperature).\nThe middle panel shows fits of the ripple of the spectra in the \nupper panel. The lower panel shows the residual.}\n\\label{fig:ripple1}\n\\end{figure}\n\n\n\nPart 2 of the calibration deals with the removal\nof the effects of ripple on the sky signal on calibrated\nspectra from part 1, which neglects this effect.\nThe removal of the artifacts introduced by the sky signal\nripple is a fairly straight-forward task, as the artifacts\ncan be estimated from high tangent point measurements\nwhere we know that the intensity of a calibrated spectrum should be 0 K.\n\nRipple on the load signal is more complicated from\na calibration perspective. The artifacts, in calibrated\natmospheric spectra, from ripple on the\nload signal can be seen as weak signal on top of a strong\natmospheric signal, and thus not easy to detect.\nFor this reason, we leave this effect unresolved.\n\nFigure~\\ref{fig:ripple1} shows median spectra of calibrated (Part 1) spectra\nfrom measurements at high tangent altitudes for one of the\nobservation mode of AC1 (for the further discussion on this figure\nignore the left-most part of the spectra, which comes from two \nproblematic bands of AC1 that should not be used). \nThese spectra are expected to be \ncentered around 0~K (except for the ozone line between 544.8--544.9~GHz), \nbut due to ripple in the sky signal we can see a wave pattern in the spectra.\nFigure~\\ref{fig:ripple1} also indicates that the phase of the wave pattern\ndepends on the measurement conditions, and the temperature of\nthe load (ambient temperature) is used in Fig~\\ref{fig:ripple1}\nto describe the measurement condition.\n\n\nThe calibration scheme (Part 2) is as follows:\n\\begin{itemize}\n\\item Extract median spectra of calibrated spectra \n(from Part 1:ac\\underline{ }level1b table) \nfrom measurements at tangent altitudes above 80 km for a range of hot load \ntemperatures ([277--278~K, 278--279~K, ..., 289--290~K]) \nfor each observation mode, and import the spectra\ninto the ac\\underline{ }level1b\\underline{ }average table\n\\item Estimate a fit to the median spectrum for each mode by\n\\begin{enumerate}\n\\item applying a filter that removes channels which are contaminated by \natmospheric information or lines from the median spectrum \n\\item using the target fitting function  \n\\begin{equation}\ny=a+ b\\sin(cf+d)\n\\end{equation}\nwhere \\(f\\) is the frequency and \\(a,b,c,d\\) parameters to estimate,\nin order to fit the spectrum for each of the four modules of AC1 or AC2.\nThe fitting is performed in such a way that \\(c\\) is forced \nto be equal for all of the four modules. \nImport the fit into the ac\\underline{ }cal\\underline{ }level1c\ntable\n\\end{enumerate}\n\\item Apply the correction.\\\\\nEquation~\\ref{correction} is applied to correct a given calibrated \nspectrum (from part~1), where the fit of the median spectrum\nwith matching hot load temperature range is used as the \\(s_{0}\\)\nspectrum. \n\\end{itemize}\n\n\n\n\\section{Radiometric performance and uncertainties}\n\\label{sec:radper}\n\n\n\\begin{table}\n\\caption{ Average \\(T_{rec}\\), \\(T_{sp}\\), and radiometric noise (for 1.8 sec. integration time) for the various frequency modes }\n\\label{table:config5}\n\\begin{tabular}{|l|l|l|l|l|l|l|}\n  \\hline\n  \\textbf{Backend} & \\textbf{Frontend} & \\textbf{LO freq {[}GHz{]}} & \\textbf{FM} & \\textbf{\\(T_{rec}\\) {[}K{]}} & \\textbf{\\(T_{sp}\\) {[}K{]}} & \\textbf{\\(\\Delta T [K]\\)} \\\\\n  \\hline\n  AC1              & 495 A2            & 492.750                    & 23          & 3000                  & 7.0  & 2.0\\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                   &                    & 499.698                   & 25          & 3500 *                & 6.2  & -\\\\\n  \\cline{2-2}\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                   & 549 A1             & 548.502                  & 2            & 2800 *                & 8.0 & 1.8 \\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                  &                     & 553.050                  & 19           & 2900 *                & 7.3 & 1.9 \\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                  &                     & 547.752                  & 21           & 3100 *                & 8.6 & 2.0 \\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                  &                     & 553.302                  & 23           & 3200                  & 6.8 & 2.1 \\\\\n  \\cline{2-2}\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                 & 555 B2              & 553.298                   & 13           & 3200                  & 14.0 & 2.1 \\\\\n  \\cline{2-2}\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                & 572 B1               & 572.762                   & 24           & 3200 *                & 9.4 & 2.1 \\\\\n  \\hline\n  AC2           & 495 A2               & 497.880                   & 1            & 3200                  & 6.1 & 2.1\\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                &                      & 492.750                   & 8            & 3200                  & 7.4 & 2.1\\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                &                      & 494.750                   & 17           & 3200                  & 6.7 & 2.1\\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                &                      & 499.698                   & 25           & 3200                 & 7.6 & 2.1\\\\\n  \\cline{2-2}\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                & 572 B1              & 572.762                    & 14           & 3700 *              & 9.9 & 2.4\\\\\n  \\cline{3-3}\n  \\cline{4-4}\n  \\cline{5-5}\n  \\cline{6-6}\n  \\cline{7-7}\n                &                     & 572.964                    & 22           & 3700 *              & 10.0 & 2.4\\\\\n  \\hline\n\\end{tabular}\n\\end{table}\n\nIn this section we deal with uncertainties that are related to calibrated \\smr\\ spectra. \nIn Sect.~\\ref{sec:radnoise} we describe uncertainties related to radiometric noise.\nIn Sect.~\\ref{sec:gainvar} we describe uncertainties related to rapid gain fluctuations.\nIn Sect.~\\ref{sec:otheruncer} we describe uncertatinties that are related to imperfect knowledge\nof load temperature and main beam efficiency.\nIn Sect.~\\ref{sec:trends} trend uncertainties are explored.\nIn Sect.~\\ref{notesoncorr} we describe the noise correlations. \nIn Sect.~\\ref{sec:caluncer} we describe the noise estimate output from the calibration routine.  \n\n\n\\subsection{Uncertainties related to radiometric noise}\n\\label{sec:radnoise}\n\nIn the \\smr\\ calibration process three types of signals are used (all of them containing radiometric noise)\nand the obtained noise in calibrated spectra is sensitive to noise in\nall of these measurements. \nThe noise contribution can be divided into three terms\n(1) the radiometer noise contribution,\n(2) interpolated reference noise contribution, and (3) interpolated gain noise contribution\n\\cite{jarnot:04}.\n\nThese contributions (derived in the following sub-sections) gives that the noise on an individual channel \\(\\Delta T_{i}\\) of a \ncalibrated \\smr\\ spectrum using the calibration scheme described in Sect.~\\ref{sec:calscheme}. \nThe noise can be described by\n\\begin{equation}\n\\Delta T_{i}^{2} =  \\frac{1}{B\\tau} \\left( (T_{rec,i}+T_{a,i})^2 + \\frac{T_{rec,i}^2}{2} +\n   \\frac{T_{a,i}^{2}}{n} \\left( \\left( \\frac{T_{rec,i} + T_{l,i}}{T_{l,i}} \\right)^2 + \n   \\left( \\frac{T_{rec,i} }{T_{l,i}} \\right)^2 \\right) \\right).\n\\label{eq:raderror}\n\\end{equation}\nFor measurements with a nearly blank background (i.e. \\(T_{a,i}\\approx\\)0), uncertainties in the gain estimate \nhave low impact and the noise expression reduces to\n\\begin{equation}\n\\Delta T_{i} =  T_{rec,i}\\sqrt{\\frac{3}{2}\\frac{1}{B\\tau}}.\n\\label{eq:higaltnoise}\n\\end{equation}\nIn Table~\\ref{table:config5} typical \\(T_{rec}\\) values and radiometric noise levels\n(for measurements having high tangent points)\nof the main frequency modes of \\smr\\ are listed.\n\n\nAs a starting point to derive Eq.~\\ref{eq:raderror} we take the derivative of \\(T_{a,i}\\) \nwith respect to \\(c_{a,i}\\), \\(c_{s,i}\\), and \\(g_{i}\\):\n\n\\begin{equation}\n\\frac{\\partial T_{a,i}}{\\partial c_{a,i}} \\approx \\frac{1}{g_i}, \n\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial T_{a,i}}{\\partial c_{s,i}} \\approx \\frac{1}{g_i}, \n\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial T_{a,i}}{\\partial g_{i}} \\approx -\\frac{c_{a,i}-c_{s,i}}{g_{i}^{2}} \\approx \\frac{T_{a,i}}{g_i}, \n\\end{equation}\nwhich implies:\n\n\\begin{equation}\n\\Delta T_{i}^{2} = \\frac{\\Delta c_{a,i}^{2}}{g_{i}^2} + \\frac{\\Delta c_{s,i}^{2}}{g_{i}^2} + T_{a,i}^{2}\\frac{\\Delta g_{i}^{2}}{g_{i}^2},\n\\end{equation}\nwhere the terms on the right hand side is (1) the radiometer noise contribution,\n(2) interpolated reference noise contribution, and (3) interpolated gain noise contribution.  \nIn the following sections these terms are described in more detail.\n\n\\subsection*{Precision: radiometer noise contribution}\nThe radiometer noise contribution induced noise variance in calibrated \\(T_{a,i}\\) is simply\n\\begin{equation}\n\\frac{\\Delta c_{a,i}^{2}}{g_{i}^2} = \\frac{T_{sys}^{2}}{B\\tau}.\n\\end{equation}\n\n\n\\subsection*{Precision: interpolated reference noise contribution}\nIn the \\smr\\ calibration scheme, and for the nominal situation, the sky beam interpolated\nreference signal can be written\n\\begin{equation}\n\\hat{c}_{s,i}(t_{j+1}) = \\frac{1}{2}c_{s,i}(t_{j}) + \\frac{1}{2}c_{s,i}(t_{j+2}), \n\\end{equation}\nwhere \\(t_{j}\\) represent time.  \nIf the gain fluctuations are small or follow a linear variation during the\nobservation sequence, the noise in \\(\\hat{c}_{s,i}(t_{j+1})\\) is only due to radiometric\nnoise and induced noise variance in calibrated \\(T_{a,i}\\) is\n\\begin{equation}\n\\frac{\\Delta c_{s,i}^{2}}{g_{i}^2} = \\frac{T_{rec}^{2}}{2B\\tau}.\n\\end{equation}\n\nIn practice there is also a finite error due to non-linear and non-captured\ngain variation and this is described in Sect~\\ref{sec:gainvar}.\n\n   \n\\subsection*{Precision: interpolated gain noise contribution}\n\nIn the calibration scheme, the gain is estimated as\n\\begin{equation}\ng_{i}(t_{j+k}) = \\frac{\\hat{c}_{s,i}(t_{j+k})}{\\overline{T}_{rec,i}} = \\hat{c}_{s,i}(t_{j+k})\\left(\\frac{1}{n}\\sum_{j=1}^{n}T_{rec,i}(t_{j})\\right)^{-1}, \n\\end{equation}\nwhere\n\\begin{equation}\nT_{rec,i}(t_{j}) = \\hat{c}_{s,i}(t_{j}) \\frac{ T_{l} - T_{s} }{  c_{l,i}(t_{j})- \\hat{c}_{s,i}(t_{j})  }.\n\\end{equation}\nThat is, the precision of the interpolated gain depends on the precision of an interpolated\nreference measurement and on an average \\(T_{rec}\\). \n\nWe first note that\n\\begin{equation}\n\\frac{\\partial g_{i}}{\\partial \\hat{c}_{s,i}(t_{j+k})} = \\frac{1}{\\overline{T}_{rec,i}}\n\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial g_{i}}{\\partial T_{rec,i}} = - \\frac{\\hat{c}_{s,i}(t_{j+k})}{\\overline{T}_{rec,i}^2}.\n\\end{equation}\n\nFor an individual \\(T_{rec}\\) estimate, we have that\n\\begin{equation}\n \\frac{\\partial T_{rec,i}}{\\partial c_{s,i}(t_{j})} = \\frac{(T_{l}-T_{s})(c_{l,i}-c_{s,i}) + c_{s,i}(T_{l}-T_{s})}\n{(c_{l,i}-c_{s,i})^2} \\approx \\frac{T_{rec,i}}{g_{i}T_{l}}\n\\end{equation}\n\n\\begin{equation}\n \\frac{\\partial T_{rec,i}}{\\partial c_{l,i}} = \\frac{-c_{s,i}(T_{l}-T_{s})}{(c_{l,i}-c_{s,i})^2} \\approx -\\frac{T_{rec,i}}{g_{i}T_{l}}\n\\end{equation}\nThus, we have\n\n\\begin{equation}\n \\frac{\\partial g_{i}}{\\partial c_{l,i}} = \\frac{\\partial g_{i}}{\\partial T_{rec,i}}\\frac{\\partial T_{rec_{i}}}{\\partial c_{l,i}}=\n\\frac{1}{T_{l,i}-T_{s,i}} \n\\end{equation}\n\n\\begin{equation}\n \\frac{\\partial g_{i}}{\\partial c_{s,i}} = \\frac{\\partial g_{i}}{\\partial T_{rec,i}}\\frac{\\partial T_{rec_{i}}}{\\partial c_{s,i}} =\n\\frac{-1}{T_{l,i}-T_{s,i}} \n\\end{equation}\nwhich implies:\n\n\\begin{equation}\n\\Delta g_{i}^{2} =  \\frac{\\Delta c_{l,i}^{2} + \\Delta c_{s,i}^{2}}{(T_{l,i}-T_{s,i})^2} + \\frac{ \\Delta c_{i}^{2}(t_{j+1})}{T_{rec,i}^{2}}\n\\approx \\frac{\\Delta c_{l,i}^{2} + \\Delta c_{s,i}^{2}}{T_{l,i}^2}\n\\end{equation}\nand\n\n\\begin{equation}\nT_{a,i}^{2}\\frac{\\Delta g_{i}^{2}}{g_{i}^2} = \\frac{T_{a,i}^{2}}{T_{l,i}^2} \\frac{\\Delta c_{l,i}^{2} + \\Delta c_{s,i}^{2}}{g_{i}^{2}},\n\\end{equation}\nor, if we take into account that \\(T_{rec}\\) spectrum is an average from \\(n\\) measurements\n\n\\begin{equation}\n T_{a,i}^{2}\\frac{\\Delta g_{i}^{2}}{g_{i}^2} =  \\frac{1}{B\\tau} \\left(\n   \\frac{T_{a,i}^{2}}{n} \\left( \\left( \\frac{T_{rec,i} + T_{l,i}}{T_{l,i}} \\right)^2 + \\left( \\frac{T_{rec,i} }{T_{l,i}} \\right)^2 \\right) \\right).\n\\end{equation}\n\n\n\\subsection{Uncertainties related to rapid gain fluctuations}\n\\label{sec:gainvar}\nIn the preceding section we derived an error for reference noise contribution.\nGain fluctuations on a small time scale (between reference-target-reference\nobservation sequence) not captured by the interpolation of reference signals\ngive rise to errors.\nIn practice there is also a finite error due to non-linear gain variation \ni.e. there is a broadband-offset between the estimated and true reference signal\n\\begin{equation}\n\\hat{c_{s}}(t_{j+1}) - c_{s}(t_{j+1}) = \\Delta c_{s} = \\Delta g' T_{rec},\n\\end{equation}\nwhere \\(\\Delta g'\\) represents the non-captured variation in gain\ndue to non-linear gain fluctuations.\n\nThis error can be described as\n\\begin{equation}\n\\Delta T_{i,gain}^2 = T_{rec}^{2}\\left(\\frac{\\Delta g'}{g}\\right)^{2}.\n\\label{eq:gainvar}\n\\end{equation}\n\nFor a given \\smr\\ spectrum \\(\\Delta T_{i}\\)\\(\\approx\\)2\\,K due to this effect,\nbut when averaging many spectra this effect goes to 0.\n\n\n\\subsection{Other uncertainties}\n\\label{sec:otheruncer}\n\nThere are also errors in calibrated \\smr\\ spectra due to imperfect knowledge of\nthe calibration target temperature and main beam efficiency. \n\n\\begin{itemize}\n\n\\item The accuracy of temperature information of the calibration target\n is (\\(\\Delta T_{l}\\)) around 0.2\\,K. The related calibration error (\\(\\Delta T_{a}\\)) is\n \\begin{equation}\n  \\Delta T_{a} \\approx \\frac{T_{a}}{T_{l}} \\Delta T_{l},\n \\end{equation}\n which gives that for observations against a blank background the error\n is close to 0, while if \\(T_{a}\\)=200\\,K \\(\\Delta T_{a}\\)\\(\\approx\\)\\,0.14 K.\n\n\\item Main beam efficiency uncertainty. The main beam efficiency is estimated\n for each scan and this estimate introduces a finite error to calibrated spectrum.\n We have that\n \\begin{equation}\n  \\Delta T_{a} = \\frac{\\Delta n_{a}}{n_{a}}T_{a},\n \\end{equation}\n and\n\n \\begin{equation}\n  \\Delta n_{a}^{2} = \\left(\\frac{T_{sp}\\Delta T_{amb}}{T_{amb}^{2}}\\right)^{2} + \n                     \\left( \\frac{\\Delta T_{sp}}{T_{amb}} \\right)^2.\n \\end{equation}\n\nThus, error in estimated main beam effciency is sensitive to errors in both assumed \n\\(T_{amb}\\) and estimated \\(T_{sp}\\), and \n\n\\begin{equation}\n  \\Delta T_{a} = \\sqrt{ \\left(\\frac{T_{sp}\\Delta T_{amb}}{T_{amb}^{2}}\\right)^{2} +\n                     \\left( \\frac{\\Delta T_{sp}}{T_{amb}} \\right)^2 } \\frac{T_{a}}{n_a}\n\\label{eq:tanaerr}\n\\end{equation}\n\nFor the moment we assume that \\(\\Delta T_{sp}\\)=0 (see Sect.~\\ref{sec:trends} for further\nanalysis), and focus on the \\(\\Delta T_{amb}\\) term.\nThere is no temperature sensor on \\smr\\ that measure the baffle temperature, and a constant\nvalue of 300\\,K is used in calibration process.\nAnyhow, for  observations against a blank backgrund the error\nis close to 0, while if \\(T_{a}\\)=200\\,K, \\(T_{amb}\\)=300\\,K, \\(T_{sp}\\)=8\\,K,\nand \\(\\Delta T_{amb}\\)=10\\,K, than \\(\\Delta T_{a}\\)\\(\\approx\\)\\,0.18 K.\n\n\n\\end{itemize}\n\n\n\\subsection{Trend uncertainties}\n\\label{sec:trends}\nIt can not be ruled out that calibrated \\smr\\ spectra\ncontain artificial trends that are related to a\npossible error in the estimation of main beam efficiency.\n\nThe main beam efficiency is determined based on an estimated\n\\(T_{sp}\\) value (see Eq.~\\ref{eq:eta}).\nThe estimation of \\(T_{sp}\\) (see Eq.~\\ref{eq:tspill2}) \nis done under the assumption that reference signals are ``clean''.\nIt has been noted that there is a slight mismatch between\nmain beam and reference signals (see Sect.~\\ref{sec:ripples}).\nIf we assume that the reference signal contains a time varying\nbroadband offset (\\(c_{s}=g(T_{rec}+\\Delta T_{off}(t))\\)) \nwe have that Eq.~\\ref{eq:tspill2} reads\n\\begin{equation}\n T_{sp}=(c_{a}-c_{s})\\frac{T_{rec}}{c_{s}}\\approx(1-\\eta_{a})T_{amb}-\\Delta T_{off}(t),\n\\end{equation}\nthus, \\(T_{sp}\\) is made up of two contributions and the error\nin ``true'' \\(T_{sp}\\) is \\(\\Delta T_{off}(t)\\).\nEquation~\\ref{eq:tanaerr} then tells us how this related\nerror introduces an error in estimated \\(T_{a}\\) within the calibration algorithm.\nSince main beam efficiency error is proportional to \\(T_{a}\\) it has low impact\non weak signals. However, if \\(\\Delta T_{off}(t)\\) has changed by 1.5\\,K\nduring the mission, one would see an artificial change in strong \nsignals (around 200\\,K) of about 1\\,K. \n\n\n\n\\subsection{Notes on noise correlations}\n\\label{notesoncorr}\n\nNoise on calibrated \\smr\\ has correlations of the following type/reason:\n\n\\begin{itemize}\n\n\\item Radiometric noise from the target signal is correlated between \nneighboring channels of a given spectrum (due to Hanning smoothing).\n\n\\item The gain variation term (Eq.~\\ref{eq:gainvar}) has been found to be correlated \nbetween channels for \\smr.\nThis gain variation has been estimated to give rise to a constant\nshift in the brightness temperature across the band (that is, it can \nbe seen as a flat baseline ripple), where the shift\nhas a standard deviation of about 2 K and is uncorrelated\nbetween tangent altitudes and front-ends.\n\n\\item Noise of two neighboring spectra is correlated due to\nthe fact that they share one cold sky reference measurements. \nThe noise linear correlation coefficient from a given channel\nfrom two neighboring spectra should be \\(\\sim\\)\\,0.17 due to this\nfact. This value was derived from simulations for an ideal\ncase, in which simulated measurements and references were \ngiven noise of equal magnitude, and the calibration\nprocess replicated.\n\n\\item All spectra in a scan share a common (noisy) \\(T_{rec}\\)\nspectrum. \n\n\\end{itemize}\n\n\\subsection{Precision: estimates from calibration process}\n\\label{sec:caluncer}\n\n\\(T_{rec}\\) and obtained random uncorrelated noise level is estimated within the \ncalibration processing for each scan.\n\n\nThis random noise level is estimated as an effective integration time\n(\\(\\tau_{eff}\\)) from calibrated spectra of the upper part of a scan \n(with a blank background). Each spectrum of a scan is given an effective\nintegration time, but it is determined from all spectra within a time\nwindow of \\(\\pm\\)45\\,minutes. \nWithin the calibration algorithm, the noise of each sub-band of\nthe considered spectrum is calculated as the bias corrected variance, i.e.\n\\begin{equation}\n\\Delta T^{2} = \\frac{1}{n-1}\\sum_{i=1}^{n}(T_{b,i}-\\left<T_{b}\\right>)^{2}\n\\end{equation}\n\nAn efficiency factor \\(\\eta\\) for each sub-band is then calculated (from the radiometer noise equation) as\n\\begin{equation}\n\\eta = \\frac{T_{rec}^2}{B\\Delta T^{2}\\tau}.\n\\end{equation}\n\nAn efficiency factor for the scan is then determined from the sub-band\nwith the highest average efficiency factor. The alternative option\nto use the result from the sub-band with lowest efficiency factor\nis not wise. The reason is that even for spectra of the upper part\nof the scan, some sub-bands may contain the signature of an emission \nline which would be treated as noise here.\n\nThe effective integration time associated with a given spectrum\nin the Level1B data should then be treated as a \nvariable that can be plugged into the radiometer noise equation,\ni.e.\n\\begin{equation}\n\\Delta T = T_{rec}\\frac{1}{\\sqrt{B\\tau_{eff}}},\n\\end{equation}\nto obtain a measure of the noise level of the spectrum\n(and \\(B\\) should be set to 100\\,MHz although this is not\nthe resolution of a channel after calibration).\nThis obtained noise level should be comparable to the noise \nof Eq.~\\ref{eq:higaltnoise}.\n\n\n\\section{Frequency calibration}\n\n\\subsection{Local oscillator frequency drift}\n\n\\begin{table}\n\\caption{Fitting parameters for the frequency drift correction.}\n\\label{table:freqcorr}\n\\begin{tabular}{|l|l|l|l|}\n  \\hline\n  \\textbf{Frontend} & \\textbf{Constant}  & \\textbf{Time Dependence}      & \\textbf{Temperature dependence} \\\\\n                    & \\textbf{\\(c_{0}\\)} & \\textbf{\\(c_{0}\\)}            & \\textbf{\\(c_{0}\\)}              \\\\\n  \\hline\n        555         & 1.00007687         & -9.881469\\(\\cdot10^{-10}\\)    &  -7.20429255\\(\\cdot10^-{8}\\)    \\\\\n  \\hline \n        495         & 1.00004369         & -3.049353\\(\\cdot10^{-10}\\)    &  -9.77071337\\(\\cdot10^-{8}\\)    \\\\\n  \\hline\n        549         & 1.00005847         & -6.275934*\\(\\cdot10^{-10}\\)   &  -3.89089138\\(\\cdot10^-{8}\\)    \\\\\n  \\hline\n        572         & N/A                & N/A                           & N/A                             \\\\\n  \\hline\n\\end{tabular}\n\\end{table}  \n\nFirstly, the operating local oscillator (LO) frequency is calculated\nfrom harmonic reference oscillator and phase locked loop (PLL) \nreference oscillator frequencies from the housekeeping level0 data.\nA second step is then to account for drifts in the LO frequency.\nIt has been previously noted that a spectral shift exists in \nthe current level 1 dataset (version 6 and 7) and that this shift \nhas been changing over time.\nA new model, based on Version 2-0 and Verison 2-1 Level2 data,\nis applied for calibration version 8 data that takes into\naccount of a temperature dependency and a temporal term\nof the LO frequency drift.\nThe correction factor \\(k\\) and frequency drift corrected\nLO frequency \\(\\hat{f}_{lo,sky}\\) is estimated as\n\\begin{equation}\n  \\label{eq:freqcorr}\n  k = c_{0} + c_{1} \\cdot mjd + c_{2} \\cdot T_{pll}\n\\end{equation}\nand\n\\begin{equation}\n \\label{eq:freqest}\n \\hat{f}_{lo,sky}= k f_{lo,sky},\n\\end{equation}\nwhere \\(T_{pll}\\) is the temperature of image load b-side,\nand the \\(c_{0}\\), \\(c_{1}\\), and \\(c_{2}\\) terms have been found\nto depend on the applied frontend and the applied values are\ndisplayed in Table~\\ref{table:freqcorr}. Another correction\nis applied for data from the 572 GHz frontend. Due to a PLL\nfailure of this radiometer, which in practice means\nthat the LO frequency is noticeably offset from the commanded \nfrequency, a special correction is applied in the Level1 processing, which is described in Appendix \\ref{chapter:freqCorrCO}.  \nThis model keeps the frequency error within \\(\\pm\\)\\,0.5\\,MHz\n(except for data from the 572 GHz radiometer).\n\n%End of paragraph updated with reference to Appendox {chapter:freqCorrCO} by Julia R, 2016-05-30.\n\n\\subsection{Doppler correction}\n\nA Doppler correction is applied.\nThe relative velocity \\(v_{geo}\\) of the satellite in the direction\nof the tangent point is used to translate the LO frequency to an \nearth-fixed reference frame. i.e.\n\\begin{equation}\n\\hat{f}_{lo} = \\hat{f}_{lo,sky}/(1.0 - v_{geo}/c),\n\\end{equation}\nwhere \\(c\\) is the speed of light.\n\n\\section{Pointing and attitude data processing}\n\nThe vertical scanning is achieved by rotation of the satellite\nplatform by an advanced attitude control system (ACS). \nThe ACS uses star trackers as the main sensors with backup from gyros, \nmagnetometers, and Sun sensors. Reaction wheels and magnetic coils serve as \nactuators. The ACS pointing accuracy in limb-scanning mode is 5\\(^{'}\\) in\nreal time knowledge, and better than 1\\(^{'}\\) in reconstructed knowledge\n(which translates to a \\(\\sim\\)800\\,m accuracy in tangent point).\n\nThe reconstructed attitude data files contain the estimated\nachieved attitude given as a quaternion, and the satellite position   \nand velocity from GPS receiver on-board of Odin.\n\nIn the calibration software at Chalmers, this data is used to calculate\nthe geographical position of the tangent point, the satellite relative velocity \n\\(v_{geo}\\) of the satellite in the direction of the tangent point.\nThe hit of the target and sky beams with various objects (e.g. Earth, Moon) \nare also tested (using a low precision ephemeris)\nand reported as quality indicators.\n\n", "meta": {"hexsha": "68b7e07f11b89eec9110fe41be73a2ab5640d58f", "size": 39656, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "L1_ATBD/calibration.tex", "max_stars_repo_name": "Odin-SMR/docs", "max_stars_repo_head_hexsha": "19a7fea949a8839897f511bc8ddc6abbb52e9cb0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "L1_ATBD/calibration.tex", "max_issues_repo_name": "Odin-SMR/docs", "max_issues_repo_head_hexsha": "19a7fea949a8839897f511bc8ddc6abbb52e9cb0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-09-28T09:28:13.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-12T13:45:33.000Z", "max_forks_repo_path": "L1_ATBD/calibration.tex", "max_forks_repo_name": "Odin-SMR/docs", "max_forks_repo_head_hexsha": "19a7fea949a8839897f511bc8ddc6abbb52e9cb0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-18T15:26:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-18T15:26:54.000Z", "avg_line_length": 42.0084745763, "max_line_length": 173, "alphanum_fraction": 0.6941194271, "num_tokens": 11906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4217903227167157}}
{"text": "\\documentclass[letterpaper, twoside, 12pt]{book}\n\\usepackage{packet}\n\n\n\\begin{document}\n\n\\setcounter{chapter}{10}\n\\setcounter{section}{3}\n\n\n\\section{The Cross Product}\n\n\\begin{definition}\n  For any two non-parallel and non-zero vectors $\\harpvec{u}$, $\\harpvec{v}$\n  in $\\mathbb R^3$,\n  the \\textbf{Right-Hand Rule} gives a specific direction orthogonal to both:\n  position both vectors at the origin, and draw a line orthogonal to the\n  plane containing both vectors. Then place your right thumb near\n  $\\harpvec{u}$ and your right index finger near $\\harpvec{v}$.\n  The direction on the orthogonal line given by extending your middle\n  finger is the direction given by the RHR.\n\\end{definition}\n\n\\begin{definition}\n  Let \\(\\harpvec u,\\harpvec v\\) be vectors.\n  Their \\textbf{cross product} $\\harpvec{u}\\times\\harpvec{v}$ is the vector\n  constructed as follows:\n  \\begin{enumerate}\n    \\item If either of \\(\\harpvec u,\\harpvec v\\) is the zero vector\n      \\(\\harpvec 0\\), then \\(\\harpvec u\\times\\harpvec v=\\harpvec 0\\).\n    \\item If \\(\\harpvec u,\\harpvec v\\) are parallel,\n      then \\(\\harpvec u\\times\\harpvec v=\\harpvec 0\\).\n    \\item Otherwise, let \\(\\harpvec n\\) be the unit vector given by the\n     vectors \\(\\harpvec u,\\harpvec v\\) and the RHR, and let \\(a\\) be the area\n     of the parallelogram determined by the vectors \\(\\harpvec u,\\harpvec v\\).\n     Then \\(\\harpvec u\\times\\harpvec v=a\\harpvec n\\).\n  \\end{enumerate}\n  % Let $\\theta$ be the angle between two non-zero vectors $\\harpvec{u}$,\n  % $\\harpvec{v}$ in $\\mathbb{R}^3$, and let $\\harpvec{n}$ be the direction\n  % given by the Right-Hand Rule.\n\n  %  to both which follows the Right-Hand Rule and has magnitude\n  % equal to the area of the parallelogram formed from both.\n  % \\[\n  %   \\harpvec{u}\\times\\harpvec{v}\n  %     =\n  %   (|\\harpvec{u}||\\harpvec{v}|\\sin\\theta)\\harpvec{n}\n  % \\]\n  % \\[\n  %   |\\harpvec{u}\\times\\harpvec{v}|\n  %     =\n  %   |\\harpvec{u}||\\harpvec{v}|\\sin\\theta\n  % \\]\n\\end{definition}\n\n\\begin{theorem}\n  The cross products of the standard unit vectors are given as follows:\n  \\begin{itemize}\n    \\item $\\veci \\times \\vecj = \\veck$\n    \\item $\\vecj \\times \\veci = -\\veck$\n    \\item $\\vecj \\times \\veck = \\veci$\n    \\item $\\veck \\times \\vecj = -\\veci$\n    \\item $\\veck \\times \\veci = \\vecj$\n    \\item $\\veci \\times \\veck = -\\vecj$\n    \\item $\\veci \\times \\veci = \\harpvec 0$\n    \\item $\\vecj \\times \\vecj = \\harpvec 0$\n    \\item $\\veck \\times \\veck = \\harpvec 0$\n  \\end{itemize}\n\\end{theorem}\n\n\\begin{theorem}\n  The following properties hold for any three vectors $\\harpvec{u}$, $\\harpvec{v}$,\n  $\\harpvec{w}$ and scalars $a$,$b$.\n  \\begin{itemize}\n  \\item $\\harpvec{v} \\times \\harpvec{u} = -(\\harpvec{u} \\times \\harpvec{v})$\n  \\item $(a\\harpvec{u}) \\times (b\\harpvec{v}) = (ab)(\\harpvec{u} \\times \\harpvec{v})$\n  \\item\n    $\\harpvec{u} \\times (\\harpvec{v} + \\harpvec{w}) =\n    \\harpvec{u} \\times \\harpvec{v} + \\harpvec{u} \\times \\harpvec{w}$\n  \\item\n    $(\\harpvec{v} + \\harpvec{w}) \\times \\harpvec{u} =\n    \\harpvec{v} \\times \\harpvec{u} + \\harpvec{w} \\times \\harpvec{u}$\n  \\end{itemize}\n\\end{theorem}\n\n\\begin{problem}\n  Compute \\((3\\veci-4\\vecj)\\times(\\vecj+2\\veck)\\).\n\\end{problem}\n\n\\begin{definition}\n  A \\textbf{determinant} is shorthand for writing the following\n  algebraic expressions:\n    \\[\n      \\begin{array}{|c c|}\n      a_1 & a_2 \\\\\n      b_1 & b_2 \\\\\n      \\end{array}\n        =\n      a_1b_2 - a_2b_1\n    \\]\n    \\[\n      \\begin{array}{|c c c|}\n      a_1 & a_2 & a_3 \\\\\n      b_1 & b_2 & b_3 \\\\\n      c_1 & c_2 & c_3 \\\\\n      \\end{array}\n        =\n      a_1 \\,\n      \\begin{array}{|c c|}\n      b_2 & b_3 \\\\\n      c_2 & c_3 \\\\\n      \\end{array}\n        -\n      a_2 \\,\n      \\begin{array}{|c c|}\n      b_1 & b_3 \\\\\n      c_1 & c_3 \\\\\n      \\end{array}\n        +\n      a_3 \\,\n      \\begin{array}{|c c|}\n      b_1 & b_2 \\\\\n      c_1 & c_2 \\\\\n      \\end{array}\n    \\]\n\\end{definition}\n\n\\begin{theorem}\n  The area of a parallelogram determined by two\n  vectors \\(\\harpvec u,\\harpvec v\\) with angle \\(\\theta\\) is given by\n  \\(\n    \\|\\harpvec u\\|\\|\\harpvec v\\|\\sin\\theta\n  \\).\n\\end{theorem}\n\n\\begin{problem}\n  Find the area of the parallelogram determined by the vectors\n  \\(\\<0,3\\>\\) and \\(\\<2,2\\>\\)\n\\end{problem}\n\n\\begin{theorem}\n  The area of a parallelogram determined by two \\(2D\\)\n  vectors \\(\\harpvec u,\\harpvec v\\) with angle \\(\\theta\\) is given by\n  the absolute value of the determinant\n  \\(\n    \\begin{array}{|c c|}\n    u_1 & u_2 \\\\\n    v_1 & v_2 \\\\\n    \\end{array}\n  \\).\n\\end{theorem}\n\n\\begin{problem}\n  Use this to resolve the previous problem.\n\\end{problem}\n\n\\begin{problem}\n  Find the area of the triangle with vertices at \\((2,3)\\), \\((-1,4)\\),\n  and \\((1,1)\\)\n\\end{problem}\n\n\\begin{theorem}\n  The volume of a parallelepiped determined by three three-dimensional\n  vectors \\(\\harpvec u,\\harpvec v,\\harpvec w\\) is given by the absolute\n  value of their\n  \\textbf{triple scalar product}, the determinant\n  \\(\n    \\begin{array}{|c c c|}\n    u_1 & u_2 & u_3 \\\\\n    v_1 & v_2 & v_3 \\\\\n    w_1 & w_2 & w_3 \\\\\n    \\end{array}\n  \\).\n\\end{theorem}\n\n\\begin{problem}\n  Find the volume of the parallelepiped determined by the vectors\n  \\(\\<1,2,3\\>\\), \\(\\<0,-1,4\\>\\), and \\(\\<2,2,0\\>\\).\n\\end{problem}\n\n\n\n\\begin{theorem}\n  By breaking up $\\harpvec{u}$, $\\harpvec{v}$ into standard unit vectors:\n  \\[\n  \\harpvec{u} \\times \\harpvec{v}\n    =\n  \\begin{array}{|c c c|}\n  \\veci & \\vecj & \\veck \\\\\n  u_1 & u_2 & u_3 \\\\\n  v_1 & v_2 & v_3 \\\\\n  \\end{array}\n    =\n  \\begin{array}{|c c|}\n  u_2 & u_3 \\\\\n  v_2 & v_3 \\\\\n  \\end{array}\n  ~\\veci-\n  \\begin{array}{|c c|}\n  u_1 & u_3 \\\\\n  v_1 & v_3 \\\\\n  \\end{array}\n  ~\\vecj+\n  \\begin{array}{|c c|}\n  u_1 & u_2 \\\\\n  v_1 & v_2 \\\\\n  \\end{array}\n  ~\\veck\n  \\]\n\\end{theorem}\n\n\\begin{problem}\n  Recompute \\((3\\veci-4\\vecj)\\times(\\vecj+2\\veck)\\).\n\\end{problem}\n\n\\begin{problem}\n  Find the area of the parallelogram determined by $\\harpvec{u}=\\<4,-3,0\\>$\n  and $\\harpvec{v}=\\<2,6,-3\\>$.\n\\end{problem}\n\n\\begin{problem}\n  Find a unit vector orthogonal to both $\\harpvec{u}=\\<4,-3,0\\>$\n  and $\\harpvec{v}=\\<2,6,-3\\>$.\n\\end{problem}\n\n\\begin{theorem}\n  The triple scalar product of three vectors is also given by\n    \\[\n      \\harpvec{w}\\cdot(\\harpvec{u}\\times\\harpvec{v}) =\n      (\\harpvec{u}\\times\\harpvec{v})\\cdot\\harpvec{w} =\n      \\begin{array}{|c c c|}\n      u_1 & u_2 & u_3 \\\\\n      v_1 & v_2 & v_3 \\\\\n      w_1 & w_2 & w_3 \\\\\n      \\end{array}\n    \\]\n\\end{theorem}\n\n\n\\begin{definition}\n  The torque $\\tau$ done by a force vector $\\harpvec{F}$ on an arm given by\n  $\\harpvec{D}$ is given by\n  \\[\n    \\tau = |\\harpvec{F} \\times \\harpvec{D}|\n      =\n    |\\harpvec{F}||\\harpvec{D}|\\sin \\theta\n  \\]\n\\end{definition}\n\n\\begin{problem}\n  Find the torque enacted by the force \\(\\<2,2,-2\\>\\) on a wrench at the point\n  \\((4,3,2)\\) and bolt centered at the point \\((1,0,-2)\\).\n\\end{problem}\n\n\n\\end{document}", "meta": {"hexsha": "e65e09e173ddcc519d9f25e6c3a54e385fd9c63c", "size": 6821, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packet1.tex", "max_stars_repo_name": "StevenClontz/gordon-lecture-notes", "max_stars_repo_head_hexsha": "ae65e67c57f038e196f0ddaed5ac4a423d6c8529", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packet1.tex", "max_issues_repo_name": "StevenClontz/gordon-lecture-notes", "max_issues_repo_head_hexsha": "ae65e67c57f038e196f0ddaed5ac4a423d6c8529", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packet1.tex", "max_forks_repo_name": "StevenClontz/gordon-lecture-notes", "max_forks_repo_head_hexsha": "ae65e67c57f038e196f0ddaed5ac4a423d6c8529", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.64453125, "max_line_length": 85, "alphanum_fraction": 0.6006450667, "num_tokens": 2586, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.42179031618452695}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[vmargin=1in,hmargin=1in]{geometry}\n\\usepackage{amsmath}\n\\usepackage[parfill]{parskip}\n\\usepackage{hyperref}\n\\usepackage{natbib}\n\\usepackage{bm}\n\\usepackage{amsfonts}\n\\usepackage{graphicx}\n\\usepackage{abstract}\n\\usepackage{lineno}\n\\usepackage{setspace}\n\n\\hypersetup{pdfstartview={Fit},hidelinks}\n\n\n\\newcommand{\\bs}{{\\bf s}}\n\\newcommand{\\bsi}{{\\bf s}_i}\n\\newcommand{\\bx}{{\\bf x}}\n\\newcommand{\\bxj}{{\\bf x}_j}\n\\newcommand{\\by}{{\\bf y}}\n\\newcommand{\\bu}{{\\bf u}}\n\\newcommand{\\bui}{{\\bf u}_i}\n\\newcommand{\\but}{{\\bf u}_{t}}\n\\newcommand{\\buit}{{\\bf u}_{it}}\n\\newcommand{\\buip}{{\\bf u}_{i,t-1}}\n\\newcommand{\\ed}{\\|\\bx - \\bx'\\|}\n\\newcommand{\\cS}{\\mathcal{S} }\n\n\n\\title{Ecology Appendix S1 \\\\ Posterior distribution and Gibbs sampler \\\\ \\it Modeling abundance, distribution, movement, and space\n  use with camera and telemetry data}\n\\author{Richard B. Chandler$^1$\\footnote{Corresponding author: rchandler@warnell.uga.edu}, Daniel A. Crawford$^2$, Elina P. Garrison$^3$, \\\\\n  Karl V. Miller$^1$, Michael J. Cherry$^2$}\n\n\\begin{document}\n\n\n\n\\maketitle\n\n\\vspace{12pt}\n\n\\begin{description}%[labelindent=1pt]%[leftmargin=1cm]%,labelwidth=\\widthof{\\bfseries Example:}]\n%  \\large\n\\item[$^1$] Warnell School of Forestry and Natural Resources, University of Georgia %\\\\\n\\item[$^2$] Caesar Kleberg Wildlife Research Institute at Texas A\\&M University-Kingsville %\\\\\n\\item[$^3$] Florida Fish and Wildlife Conservation Commission %\\\\\n\\end{description}\n\n\\clearpage\n\n\\section*{Posterior distribution}\n\nThe posterior distribution of the joint spatial capture-recapture\nmovement model (with constant $\\sigma$ and data augmentation) is  \n\n\\begin{multline}\n  p(p, \\lambda_0, \\sigma_{\\mathrm det}, \\rho, \\sigma, \\{\\bu_{it}\\}, \\{\\bs_i\\}, \\{z_i\\}, \\psi | {\\bm y}^{\\rm cap},{\\bm y}) \\propto \\\\\n  \\left\\{\\prod_{i=1}^M p(y_i^{\\rm cap}|z_i, p)\n    \\left\\{\\prod_{t=1}^T\\left\\{\\prod_{j=1}^Jp(y_{ijt}|z_i,\\lambda_0,\\sigma_{\\rm det},\\buit)\n    \\right\\}p(\\buit|\\bu_{i,t-1},\\bsi,\\rho,\\sigma)\\right\\} %\\times \\\\\n  p(\\bsi)p(z_i|\\psi)\\right\\} \\times \\\\\np(p)p(\\lambda_0)p(\\sigma_{\\rm det})p(\\rho)p(\\sigma)p(\\psi) \\\\\n%  \\label{eq:post}\n%  \\tag{S1}\n\\end{multline}\n\nwhere\n\\[\n  p(y_i^{\\rm cap}|z_i, p) = \\mathrm{Bern}(y_i|z_i\\times p)\n\\]\n\\[\n  p(y_{ijt}|z_i,\\lambda_0,\\sigma_{\\rm det},\\buit) = \\mathrm{Pois}(y_{ijt}|z_i \\times \\lambda^{\\rm det}_{ijt})\n\\]\n\\[\n  p(\\buit|\\bu_{i,t-1},\\bsi,\\rho,\\sigma) =\n  \\begin{cases}\n    \\mathrm{Norm}(\\buit|\\bsi+(\\buip-\\bsi)\\rho, \\mathrm{diag}(\\sigma^2\n    - \\sigma^2\\rho^2)) & \\mathrm{for}\\quad t>1 \\\\\n    \\mathrm{Norm}(\\buit|\\bsi, \\mathrm{diag}(\\sigma^2)) & \\mathrm{for}\\quad t=1 \\\\\n  \\end {cases}\n\\]\n\\[\n  p(\\bsi) = \\mathrm{Unif}(\\mathcal M)\n\\]\n\\[\n  p(z_i|\\psi) = \\mathrm{Bern}(z_i|\\psi)\n\\]\nand the other probability distributions are priors for the\nparameters. Note that some or all of the $\\buit$ locations could be\nobserved.  \n\n\\clearpage\n\n\\section*{Gibbs sampler}\n\nSampling from the joint posterior is computationally challenging\nbecause of the latent movement paths for the $M-n$ augmented\nindividuals. The burden can be reduced by marginalizing these latent\npaths while retaining the activity centers $\\{\\bsi\\}$. This is\naccomplished using Eq. 6 in the manuscript and the probability density:\n\\[\n  p(0|\\lambda_0,\\sigma_{\\rm det},\\rho,\\sigma,\\bsi,z_i) = \\mathrm{Bern}(0|\\tilde{p}_i)\n\\]\nThe Gibbs sampler begins by initializing the unknown parameters and\nthen sampling from the following full conditional distributions.\n\nUse Metropolis-Hastings (MH) to sample from:\n\\[\n  p(\\rho,\\sigma|\\cdot) \\propto \\left\\{\\prod_{i=1}^n\\prod_{t=1}^T\n    p(\\buit|\\bu_{i,t-1},\\bsi,\\rho,\\sigma)\\right\\}\\left\\{\\prod_{i=n+1}^M p(0|\\lambda_0,\\sigma_{\\rm det},\\rho,\\sigma,\\bsi,z_i)\\right\\}p(\\rho)p(\\sigma)\n\\]\n\nUse MH to sample from:\n\\[\n  p(\\lambda_0,\\sigma_{\\rm det}|\\cdot) \\propto \\left\\{\\prod_{i=1}^n\\prod_{j=1}^J\\prod_{t=1}^T\n    p(y_{ijt}|z_i,\\lambda_0,\\sigma_{\\rm det},\\buit)\\right\\}\\left\\{\\prod_{i=n+1}^M\n    p(0|\\lambda_0,\\sigma_{\\rm det},\\rho,\\sigma,\\bsi,z_i)\\right\\}p(\\lambda_0)p(\\sigma_{\\rm det})\n\\]\n\nSample directly from\n\\[\n  p(\\psi|{\\bm z}) = \\mathrm{Beta}\\left(1+\\sum_{i=1}^M z_i, 1+M-\\sum_{i=1}^M z_i\\right)\n\\]\n\nFor $i=n+1,\\dots,M$, use MH to sample from\n\\[\n  p(z_i|\\cdot) \\propto p(y^{\\rm cap}_i|z_i,p)\n    \\left\\{\\prod_{j=1}^J\\prod_{t=1}^T p(y_{ijt}|z_i,\\lambda_0,\\sigma_{\\rm\n      det},\\buit)\\right\\}\n  p(0|\\lambda_0,\\sigma_{\\rm det},\\rho,\\sigma,\\bsi,z_i)p(z_i|\\psi)\n\\]\n\nUse MH (or direct draw from beta full conditional) to sample from\n\\[\n  p(p|\\cdot) \\propto \\prod_{i=1}^M p(y^{\\rm cap}_i|z_i \\times p)p(p)\n\\]\n\nFor $i=1,\\dots,n$, use MH to sample from\n\\[\n  p(\\bsi|\\cdot) \\propto p(\\buit|\\rho,\\sigma,\\bsi)p(\\bsi)\n\\]\n\nFor $i=n+1,\\dots,M$, use MH to sample from\n\\[\n  p(\\bsi|\\cdot) \\propto p(0|\\lambda_0,\\sigma_{\\rm det},\\rho,\\sigma,\\bsi,z_i)p(\\bsi)\n\\]\n\nFor $i=1,\\dots,n$ and for cases where $\\buit$ is not observed, use MH to sample from\n\\[\n  p(\\buit|\\cdot) \\propto\n  p(\\bu_{i,t+1}|\\bu_{i,t},\\bsi,\\rho,\\sigma)p(\\bu_{i,t}|\\bu_{i,t-1},\\bsi,\\rho,\\sigma)\\prod_{j=1}^J\n  p(y_{ijt}|\\lambda_0,\\sigma_{\\rm det},\\buit)\n\\]\n\n\\end{document}\n\n\n", "meta": {"hexsha": "f956529ca468576aeb7bb7261379b8142b6aabbc", "size": 5058, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "supp/Appendix-S1.tex", "max_stars_repo_name": "rbchan/scr-move", "max_stars_repo_head_hexsha": "30d3ed9f8c3f554b6867f6dc923a6fa143de4551", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-08-08T20:07:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-25T06:45:50.000Z", "max_issues_repo_path": "supp/Appendix-S1.tex", "max_issues_repo_name": "rbchan/scr-move", "max_issues_repo_head_hexsha": "30d3ed9f8c3f554b6867f6dc923a6fa143de4551", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "supp/Appendix-S1.tex", "max_forks_repo_name": "rbchan/scr-move", "max_forks_repo_head_hexsha": "30d3ed9f8c3f554b6867f6dc923a6fa143de4551", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4161490683, "max_line_length": 148, "alphanum_fraction": 0.6607354686, "num_tokens": 1931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4217583150454839}}
{"text": "\\chapter{Terrain-following Coordinates}\r\n\\label{chap:terrain-following}\r\n{\\bf \\Large \r\n\\begin{tabular}{ccc}\r\n\\hline\r\n  Corresponding author & : & Hisashi Yashiro\\\\\r\n\\hline\r\n\\end{tabular}\r\n}\r\n\r\n\\section{Geometry and Definitions}\r\nWe introduce a terrain following coordinate system with a new vertical coordinate $\\xi$. \r\n$\\xi$-coordinate system is not deformable system. We use the relation between z and $\\xi$ as\r\n\r\n\\begin{eqnarray}\r\n \\xi = \\frac{z_{toa}(z-z_{sfc})}{z_{toa}-z_{sfc}},\r\n\\end{eqnarray}\r\nWhere $z_{toa}$ is the top of the model domain and $z_{sfc}$ is the surface height, \r\nwhich depends on the horizontal location.\r\n\r\nThe metrics are defined as\r\n\\begin{align}\r\n G^{\\frac{1}{2}} &= \\frac{\\partial z}{\\partial \\xi}, \\\\\r\n J^{\\xi}_{13} &= \\left(\\frac{\\partial \\xi}{\\partial x}\\right)_{z} = -\\frac{J^{z}_{13}}{J^{z}_{33}},\\\\\r\n J^{\\xi}_{23} &= \\left(\\frac{\\partial \\xi}{\\partial y}\\right)_{z} = -\\frac{J^{z}_{23}}{J^{z}_{33}},\\\\\r\n J^{\\xi}_{33} &=       \\frac{\\partial \\xi}{\\partial z}            =  \\frac{1}         {J^{z}_{33}},\r\n\\end{align}\r\nwhere\r\n\\begin{align}\r\n J^{z}_{13} &= \\left(\\frac{\\partial z}{\\partial x}\\right)_{\\xi},\\\\\r\n J^{z}_{23} &= \\left(\\frac{\\partial z}{\\partial y}\\right)_{\\xi},\\\\\r\n J^{z}_{33} &= -{G^{\\frac{1}{2}}}\r\n\\end{align}\r\n\r\nIf we use the Eqs.(5.2)-(5.5), we obtain following equations:\r\n\\begin{align}\r\n \\nabla \\cdot (G^{\\frac{1}{2}} \\phi) &= \\left(\\frac{\\partial G^{\\frac{1}{2}} \\phi}{\\partial x}\\right)_{\\xi}\r\n                                      + \\left(\\frac{\\partial G^{\\frac{1}{2}} \\phi}{\\partial y}\\right)_{\\xi}\r\n                                      + (J^{\\xi}_{13}+J^{\\xi}_{23}+J^{\\xi}_{33}) \\frac{\\partial G^{\\frac{1}{2}} \\phi}{\\partial \\xi}, \\\\\r\n \\nabla \\cdot (G^{\\frac{1}{2}} \\bf u) &= \\frac{\\partial G^{\\frac{1}{2}} u}{\\partial x}\r\n                                       + \\frac{\\partial G^{\\frac{1}{2}} v}{\\partial y}\r\n                                       + \\frac{\\partial}{\\partial \\xi}\r\n                                         \\left(J^{\\xi}_{13} {G^{\\frac{1}{2}}} u\r\n                                              +J^{\\xi}_{23} {G^{\\frac{1}{2}}} v\r\n                                              +J^{\\xi}_{33} {G^{\\frac{1}{2}}} w\r\n                                         \\right).\r\n\\end{align}\r\n\r\n\\section{Summary of modified equations in the dynamical process}\r\n\r\nPrognostic variables by multiplying $G^{\\frac{1}{2}}$ are defined as\r\n\\begin{align}\r\n (\\rho Q_v)_{i,j,k}           &= G^{\\frac{1}{2}}_{i,j,k}             (\\rho Q_v)_{i,j,k},        \\\\\r\n (\\rho Q_l)_{i,j,k}           &= G^{\\frac{1}{2}}_{i,j,k}             (\\rho Q_l)_{i,j,k},        \\\\\r\n (\\rho Q_s)_{i,j,k}           &= G^{\\frac{1}{2}}_{i,j,k}             (\\rho Q_s)_{i,j,k},        \\\\\r\n R_{i,j,k}                    &= G^{\\frac{1}{2}}_{i,j,k}              \\rho_{i,j,k},                \\\\\r\n (\\rho U)_{i+\\frac{1}{2},j,k} &= G^{\\frac{1}{2}}_{i+\\frac{1}{2},j,k} (\\rho u)_{i+\\frac{1}{2},j,k}, \\\\\r\n (\\rho V)_{i,j+\\frac{1}{2},k} &= G^{\\frac{1}{2}}_{i,j+\\frac{1}{2},k} (\\rho v)_{i,j+\\frac{1}{2},k}, \\\\\r\n (\\rho W)_{i,j,k+\\frac{1}{2}} &= G^{\\frac{1}{2}}_{i,j,k+\\frac{1}{2}} (\\rho w)_{i,j,k+\\frac{1}{2}}, \\\\\r\n (\\rho \\Theta)_{i,j,k}        &= G^{\\frac{1}{2}}_{i,j,k}             (\\rho \\theta)_{i,j,k},        \\\\\r\n P_{i,j,k}                    &= G^{\\frac{1}{2}}_{i,j,k}              p_{i,j,k}\r\n\\end{align}\r\n\r\nand Eqs.(2.67)-(2.72) are modified using Eqs.(5.2)-(5.5).\r\n\r\n\\begin{align}\r\n \\frac{\\partial \\rho Q_v     }{\\partial t} + \\nabla \\cdot \\left( \\rho Q_v             {\\bf u}\\right) &= 0 \\\\\r\n \\frac{\\partial \\rho Q_l     }{\\partial t} + \\nabla \\cdot \\left( \\rho Q_l             {\\bf u}\\right) &= 0 \\\\\r\n \\frac{\\partial \\rho Q_s     }{\\partial t} + \\nabla \\cdot \\left( \\rho Q_s             {\\bf u}\\right) &= 0 \\\\\r\n \\frac{\\partial R            }{\\partial t} + \\nabla \\cdot \\left( R                    {\\bf u}\\right) &= 0 \\\\\r\n \\frac{\\partial \\rho {\\bf U} }{\\partial t} + \\nabla \\cdot \\left( \\rho {\\bf U} \\otimes {\\bf u}\\right) &= -\\nabla P - Rg {\\bf e_z} \\\\\r\n \\frac{\\partial \\rho \\Theta  }{\\partial t} + \\nabla \\cdot \\left( \\rho \\Theta          {\\bf u}\\right) &= 0\r\n\\end{align}\r\n\r\n\\section{Spatial descretization}\r\n\\subsection{Continuity equation}\r\n\\begin{align}\r\n \\left(\\frac{\\partial R}{\\partial t}\\right)_{i,j,k}\r\n = - &\\Bigg[ \\frac{ (\\rho U)_{i+\\frac{1}{2},j,k}\r\n                  - (\\rho U)_{i-\\frac{1}{2},j,k}\r\n                  } {\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ (\\rho V)_{i,j+\\frac{1}{2},k}\r\n                  - (\\rho V)_{i,j-\\frac{1}{2},k}\r\n                  } {\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i,j,k+\\frac{1}{2}} \\overline{\\widetilde{(\\rho U)}^x}^z_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{13})_{i,j,k-\\frac{1}{2}} \\overline{\\widetilde{(\\rho U)}^x}^z_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i,j,k+\\frac{1}{2}} \\overline{\\widetilde{(\\rho V)}^x}^z_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{23})_{i,j,k-\\frac{1}{2}} \\overline{\\widetilde{(\\rho V)}^x}^z_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i,j,k+\\frac{1}{2}} (\\rho W)_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{33})_{i,j,k+\\frac{1}{2}} (\\rho W)_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\Bigg]\r\n\\end{align}\r\nwhere\r\n\\begin{align}\r\n \\overline{\\widetilde{(\\rho U)}^x}^z_{i,j,k+\\frac{1}{2}}\r\n &= G^{\\frac{1}{2}}_{i,j,k+\\frac{1}{2}} \\frac{ \\widetilde{(\\rho u)}^x_{i,j,k+1}\r\n                                             + \\widetilde{(\\rho u)}^x_{i,j,k  }\r\n                                             } {2}, \\\\\r\n \\overline{\\widetilde{(\\rho V)}^x}^z_{i,j,k+\\frac{1}{2}}\r\n &= G^{\\frac{1}{2}}_{i,j,k+\\frac{1}{2}} \\frac{ \\widetilde{(\\rho v)}^x_{i,j,k+1}\r\n                                             + \\widetilde{(\\rho v)}^x_{i,j,k  }\r\n                                             } {2},\r\n\\end{align}\r\n$\\widetilde{(\\rho u)}^x_{i,j,k}$ and $\\widetilde{(\\rho v)}^x_{i,j,k}$ are obtained by same manner in eq.(3.20)\r\n\r\n\\subsection{Momentum equations}\r\n\\begin{align}\r\n \\left(\\frac{\\partial \\rho U}{\\partial t}\\right)_{i+\\frac{1}{2},j,k}\r\n = - &\\Bigg[ \\frac{ \\widetilde{(\\rho U)}^x_{i+1,j,k} \\overline{u}_{i+1,j,k}\r\n                  - \\widetilde{(\\rho U)}^x_{i  ,j,k} \\overline{u}_{i  ,j,k}\r\n                  } {\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ \\widetilde{(\\rho U)}^y_{i+\\frac{1}{2},j+\\frac{1}{2},k} \\overline{v}_{i+\\frac{1}{2},j+\\frac{1}{2},k}\r\n                  - \\widetilde{(\\rho U)}^y_{i+\\frac{1}{2},j-\\frac{1}{2},k} \\overline{v}_{i+\\frac{1}{2},j-\\frac{1}{2},k}\r\n                  } {\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{\\overline{u}}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{13})_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\overline{\\overline{u}}^z_{i+\\frac{1}{2},j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{\\overline{v}^y}^{xz}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{23})_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\overline{\\overline{v}^y}^{xz}_{i+\\frac{1}{2},j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{\\overline{w}}^x_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{33})_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\overline{\\overline{w}}^x_{i+\\frac{1}{2},j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ P_{i+1,j,k}-P_{i,j,k}}{\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{P}^{xz}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{13})_{i+\\frac{1}{2},j,k-\\frac{1}{2}} \\overline{P}^{xz}_{i+\\frac{1}{2},j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi},\r\n\\end{align}\r\n\r\nwhere $\\widetilde{(\\rho U)}^x_{i,j,k}$, $\\widetilde{(\\rho U)}^y_{i+\\frac{1}{2},j+\\frac{1}{2},k}$ \r\nand $\\widetilde{(\\rho U)}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}}$ is obtained according to the method of eq(3.20)-(3.22).\r\nThe velocities at the cell wall for the staggered control volume to x direction are defined by eq(3.23)-(3.25).\r\n$\\overline{\\overline{u}}^z$ and $\\overline{\\overline{v}^y}^{xz}$ are defined as\r\n\r\n\\begin{align}\r\n \\overline{\\overline{u}}^z_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n &= \\frac{ \\overline{u}_{i+\\frac{1}{2},j,k+1}\r\n         + \\overline{u}_{i+\\frac{1}{2},j,k  }\r\n         } {2}, \\\\\r\n \\overline{\\overline{v}^y}^{xz}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n &= \\frac{ \\overline{v}^y_{i+1,j,k+1}\r\n         + \\overline{v}^y_{i+1,j,k  }\r\n         + \\overline{v}^y_{i  ,j,k+1}\r\n         + \\overline{v}^y_{i  ,j,k  }\r\n         } {4}.\r\n\\end{align}\r\n\r\n$\\overline{P}^{xz}$ is defined as\r\n\\begin{align}\r\n \\overline{P}^{xz}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n &=  G^{\\frac{1}{2}}_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\frac{ p_{i+1,j,k+1}\r\n                                                          + p_{i+1,j,k  }\r\n                                                          + p_{i  ,j,k+1}\r\n                                                          + p_{i  ,j,k  }\r\n                                                          } {4}.\r\n\\end{align}\r\n\r\nThe momentum equations in the $y$ and $z$ directions are descretized \r\nin the same way:\r\n\\begin{align}\r\n \\left(\\frac{\\partial \\rho V}{\\partial t}\\right)_{i,j+\\frac{1}{2},k}\r\n = - &\\Bigg[ \\frac{ \\widetilde{(\\rho V)}^x_{i+\\frac{1}{2},j+\\frac{1}{2},k} \\overline{u}_{i-\\frac{1}{2},j+\\frac{1}{2},k}\r\n                  - \\widetilde{(\\rho V)}^x_{i+\\frac{1}{2},j+\\frac{1}{2},k} \\overline{u}_{i-\\frac{1}{2},j+\\frac{1}{2},k}\r\n                  } {\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ \\widetilde{(\\rho V)}^y_{i,j+1,k} \\overline{v}_{i,j+1,k}\r\n                  - \\widetilde{(\\rho V)}^y_{i,j  ,k} \\overline{v}_{i,j  ,k}\r\n                  } {\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\overline{\\overline{u}^x}^{yz}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{13})_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\overline{\\overline{u}^x}^{yz}_{i,j+\\frac{1}{2},k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\overline{\\overline{v}}^z_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{23})_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\overline{\\overline{v}}^z_{i,j+\\frac{1}{2},k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\overline{\\overline{w}}^y_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{33})_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\widetilde{(\\rho V)}^z_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\overline{\\overline{w}}^y_{i,j+\\frac{1}{2},k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ P_{i,j+1,k}-P_{i,j,k}}{\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\overline{P}^{yz}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{23})_{i,j+\\frac{1}{2},k-\\frac{1}{2}} \\overline{P}^{yz}_{i,j+\\frac{1}{2},k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi},\r\n\\end{align}\r\n\r\n\\begin{align}\r\n \\left(\\frac{\\partial \\rho W}{\\partial t}\\right)_{i,j,k+\\frac{1}{2}}\r\n = - &\\Bigg[ \\frac{ \\widetilde{(\\rho W)}^x_{i+\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{u}_{i+\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  - \\widetilde{(\\rho W)}^x_{i-\\frac{1}{2},j,k+\\frac{1}{2}} \\overline{u}_{i-\\frac{1}{2},j,k+\\frac{1}{2}}\r\n                  } {\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ \\widetilde{(\\rho W)}^y_{i,j+\\frac{1}{2},k+\\frac{1}{2}} \\overline{v}_{i,j+\\frac{1}{2},k+\\frac{1}{2}}\r\n                  - \\widetilde{(\\rho W)}^y_{i,j-\\frac{1}{2},k+\\frac{1}{2}} \\overline{v}_{i,j-\\frac{1}{2},k+\\frac{1}{2}}\r\n                  } {\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i,j,k+1} \\widetilde{(\\rho W)}^z_{i,j,k+1} \\overline{u}^x_{i,j,k+1}\r\n                  - (J^{\\xi}_{13})_{i,j,k  } \\widetilde{(\\rho W)}^z_{i,j,k  } \\overline{u}^x_{i,j,k  }\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i,j,k+1} \\widetilde{(\\rho W)}^z_{i,j,k+1} \\overline{v}^y_{i,j,k+1}\r\n                  - (J^{\\xi}_{23})_{i,j,k  } \\widetilde{(\\rho W)}^z_{i,j,k  } \\overline{v}^y_{i,j,k  }\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i,j,k+1} \\widetilde{(\\rho W)}^z_{i,j,k+1} \\overline{w}^z_{i,j,k+1}\r\n                  - (J^{\\xi}_{33})_{i,j,k  } \\widetilde{(\\rho W)}^z_{i,j,k  } \\overline{w}^z_{i,j,k  }\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i,j,k+1} P_{i,j,k+1}\r\n                  - (J^{\\xi}_{33})_{i,j,k  } P_{i,j,k  }\r\n                  } {\\Delta \\xi}\r\n\\end{align}\r\n\r\n\\subsection{Energy equation}\r\n\r\n\\begin{align}\r\n \\left(\\frac{\\partial \\rho \\Theta}{\\partial t}\\right)_{i,j,k}\r\n = - &\\Bigg[ \\frac{ (\\rho U)_{i+\\frac{1}{2},j,k} \\overline{\\theta}_{i+\\frac{1}{2},j,k}\r\n                  - (\\rho U)_{i-\\frac{1}{2},j,k} \\overline{\\theta}_{i-\\frac{1}{2},j,k}\r\n                  } {\\Delta x} \\nonumber \\\\\r\n          &+ \\frac{ (\\rho V)_{i,j+\\frac{1}{2},k} \\overline{\\theta}_{i,j+\\frac{1}{2},k}\r\n                  - (\\rho V)_{i,j-\\frac{1}{2},k} \\overline{\\theta}_{i,j-\\frac{1}{2},k}\r\n                  } {\\Delta y} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{13})_{i,j,k+\\frac{1}{2}} \\overline{\\widetilde{(\\rho U)}^x}^z_{i,j,k+\\frac{1}{2}} \\overline{\\theta}_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{13})_{i,j,k-\\frac{1}{2}} \\overline{\\widetilde{(\\rho U)}^x}^z_{i,j,k-\\frac{1}{2}} \\overline{\\theta}_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{23})_{i,j,k+\\frac{1}{2}} \\overline{\\widetilde{(\\rho V)}^x}^z_{i,j,k+\\frac{1}{2}} \\overline{\\theta}_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{23})_{i,j,k-\\frac{1}{2}} \\overline{\\widetilde{(\\rho V)}^x}^z_{i,j,k-\\frac{1}{2}} \\overline{\\theta}_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\nonumber \\\\\r\n          &+ \\frac{ (J^{\\xi}_{33})_{i,j,k+\\frac{1}{2}} (\\rho W)_{i,j,k+\\frac{1}{2}} \\overline{\\theta}_{i,j,k+\\frac{1}{2}}\r\n                  - (J^{\\xi}_{33})_{i,j,k+\\frac{1}{2}} (\\rho W)_{i,j,k-\\frac{1}{2}} \\overline{\\theta}_{i,j,k-\\frac{1}{2}}\r\n                  } {\\Delta \\xi} \\Bigg]\r\n\\end{align}\r\nwhere $\\overline{\\theta}_{i+\\frac{1}{2},j,k}$, $\\overline{\\theta}_{i,j+\\frac{1}{2},k}$ and \r\n$\\overline{\\theta}_{i,j,k+\\frac{1}{2}}$ are is obtained according to the method of eq(3.29)-(3.31).\r\n", "meta": {"hexsha": "e2867494e54f8a5521f68acddc28c7de43ee6282", "size": 15087, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "scalelib/doc/descriptions/dynamical_process_terrainfollowing.tex", "max_stars_repo_name": "Shima-Lab/SCALE-SDM_mixed-phase_Shima2019", "max_stars_repo_head_hexsha": "4eaf4f74aa03d091d9778eff373b816f178a962f", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:06:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-17T06:05:39.000Z", "max_issues_repo_path": "scalelib/doc/descriptions/dynamical_process_terrainfollowing.tex", "max_issues_repo_name": "Shima-Lab/SCALE-SDM_BOMEX_Sato2018", "max_issues_repo_head_hexsha": "6d7f66f36d00b64df0b93088eba8fe38a1bb1926", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scalelib/doc/descriptions/dynamical_process_terrainfollowing.tex", "max_forks_repo_name": "Shima-Lab/SCALE-SDM_BOMEX_Sato2018", "max_forks_repo_head_hexsha": "6d7f66f36d00b64df0b93088eba8fe38a1bb1926", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-01-07T16:28:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-07T16:28:49.000Z", "avg_line_length": 65.8820960699, "max_line_length": 185, "alphanum_fraction": 0.4569496918, "num_tokens": 6034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8705972583359805, "lm_q2_score": 0.48438008427698437, "lm_q1q2_score": 0.42169997336409376}}
{"text": "\\documentclass{article}\n\n\\usepackage{mathtools}\n\\usepackage{tikz}\n\n\\newtheorem{theorem}{Example}\n\n\\begin{document}\n\\section*{Composite Materials}\n\nComposite materials are mixtures of two or more components without any chemical reactions.\n\n\\subsection*{Composition}\n\\begin{itemize}\n    \\item Matrix Phase\n          \\begin{itemize}\n              \\item Polymers, Ceramics, Metals or Alloys\n          \\end{itemize}\n    \\item Dispersed phase\n          \\begin{itemize}\n              \\item Powders or fibers\n          \\end{itemize}\n\\end{itemize}\n\nConcrete:\n\\begin{itemize}\n    \\item Matrix Phase is cement\n    \\item Dispersed phase is sand\n\\end{itemize}\n\n\\section*{Particulate Composites}\nContain large amounts of coarse particles\n\nDensity of a particualte composite:\n\n\\begin{equation*}\n    \\rho_c = \\sum_{i=1}^n f_i \\rho_i\n\\end{equation*}\n\n\n\\begin{theorem}\n    If 5 wt SiC particles are added to a Co matrix, calculate how many particles are present per $cm^3$ of obtained composite material. Assume that SiC particles are spherical with diameter 5nm.\n\n    \\begin{equation*}\n        \\begin{aligned}\n            V_{Co} + V_{SiC}                                   & = V_{comp}                    \\\\\n            \\frac{V_{Co}}{V_{Comp}} + \\frac{V_{SiC}}{V_{Comp}} & = 1                           \\\\\n            f_{SiC} = 1- f_{Co}                                & = 1 - \\frac{V_{Co}}{V_{Comp}} \\\\\n            f_{SiC} = 1 - \\frac{\\frac{m_Co}{S_Co}}{\\frac{m_Co}{S_Co}+\\frac{m_SiC}{\\rho_SiC}}   \\\\\n            \\rho_{SiC} = 3 g/cm^3\n        \\end{aligned}\n    \\end{equation*}\n    Concentration of SiC Particles\n    \\begin{equation*}\n        \\begin{aligned}\n            f_{SiC}/ V_SiC = 2.56x10^17 parts/cm^2\n            V= 4/3 pi r^2 = 5.24x10^-19cm^3\n        \\end{aligned}\n    \\end{equation*}\n\n\\end{theorem}\n\\begin{theorem}\n    A silver-tungsten composite for an electrical contact is produced first making a porous tungsten powder metallurgy compact, then infiltrating pure silver into pores. THe density of tungsten compact before infiltration is $14.5 g/cm^3$. Calculate the volume fraction of porosity and the final weight percent of silver in the compact after infiltration.\n\n    \\begin{equation*}\n        \\begin{aligned}\n            \\rho_{Ag} = 10.49 \\\\\n            \\rho_{W} = 19.39\n        \\end{aligned}\n    \\end{equation*}\n\\end{theorem}\n\n\\section*{Material Examples}\n\\begin{itemize}\n    \\item Cemented Carbides\n    \\begin{itemize}\n        \\item Ceramic particles dispersed into metallic matrix (WC dispersed into Co-matrix for cutting tools)\n    \\end{itemize}\n    \\item Abrasives\n    \\begin{itemize}\n        \\item $Al_2O_3$, $SiC$ and cubic $BN$ bonded by glass, polymer or metallic matrix\n    \\end{itemize}\n    \\item Electrical Contacts\n    \\begin{itemize}\n        \\item Switches and relays (wear resistance and electrical conductivity)\n        \\item Ag-W electrical composite.\n    \\end{itemize}\n\\end{itemize}\n\n\\section*{Laminar Composite Materials}\n\\begin{itemize}\n    \\item Thin or thick protective coatings\n    \\item Claddings\n    \\item Bimetallics\n    \\item Laminates\n\\end{itemize}\n\n\\section*{Fiber Reinforced Composites}\n\\begin{itemize}\n    \\item Carbon Fibers\n    \\item Glass Fibers\n    \\item Aramid Fibers\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "3d14ca00a040e1469ae790ea3e1b49ad66d96cfd", "size": 3237, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/MATE201/Chapter17.tex", "max_stars_repo_name": "n30phyte/SchoolDocuments", "max_stars_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/MATE201/Chapter17.tex", "max_issues_repo_name": "n30phyte/SchoolDocuments", "max_issues_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/MATE201/Chapter17.tex", "max_forks_repo_name": "n30phyte/SchoolDocuments", "max_forks_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8285714286, "max_line_length": 355, "alphanum_fraction": 0.6379363608, "num_tokens": 942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.42166526885852357}}
{"text": "% Experimental evaluation\n\\section{ Experimental Evaluation} \n\\label{sec:results}\n\nWe ran experiments on real world datasets to\nevaluate the performance of the algorithm. All the experiments were run\non an 4GB Intel Core i7 machine with a clock speed of $2.67$ GHz running\nUbuntu Linux 10.04. The code was written in C++ and \ncompiled using g++ version $4.4$ with -O3\noptimization flag. The default number of random walks is $K=500$.\n\n\\begin{comment}\n\\begin{table}[!h]\n  \\centering\n    \\begin{tabular}{|c|c|c|c|c|}\n      \\hline\n      Dataset & $|V|$ & $|E|$ & $|\\Sigma|$ & \\small{Preprocessing time(sec)} \\\\\n      \\hline\n      CMDB & $10466$ & $15122$ & $84$ & $329.31$ \\\\\n      SCOP & $39256$ & $154328$ & $20$ & $17.377$ \\\\\n      PPI & $4950$ & $16515$ & $4950$ & $339.45 $\\\\\n      %Synthetic & $2755$ & $5002$ & $60$ \\\\\n\t  \\hline\n    \\end{tabular}\n    \\caption{Dataset Properties}\n\t\\label{tab:db}\n\\end{table}\n\\end{comment}\n\n\n\\begin{figure}[!h]\n\\centering\n\\subfloat[Dataset Statistics] {\n\t\\label{subfig:dataset}\t\n\t\\begin{tabular}{|c|c|c|c|c|}\n\t\\hline\n\t\tDataset & $|V|$ & $|E|$ & $|\\Sigma|$ & \\small{Preprocessing time(sec)} \\\\\n\t\t\\hline\n\t\tCMDB & $10466$ & $15122$ & $84$ & $329.31$ \\\\\n\t\tSCOP & $39256$ & $154328$ & $20$ & $17.377$ \\\\\n\t\tPPI & $4950$ & $16515$ & $4950$ & $339.45 $\\\\\n\t\t%Synthetic & $2755$ & $5002$ & $60$ \\\\\n\t\t\\hline\n\t\t\\end{tabular}\n} \\\\\n\\subfloat[Maximal Pattern Statistics] {\n\t\\label{subfig:maxpat_stats}\n\t\\begin{tabular}{|c|c|c|c|}\n\t\\hline\n\t\tDataset & $|V|$ & $|E|$ & Degree\\\\\n\t\t\\hline\n\t\tCMDB & $11$ & $12.24$ & $2.223$\\\\\n\t\tSCOP & $5.965$ & $6.725$ & $2.225$\\\\\n\t\tPPI & $6.453$ & $5.956$ & $1.655$\\\\\n\t\t%Synthetic & $2755$ & $5002$ & $60$ \\\\\n\t\t\\hline\n\t\t\\end{tabular}\n}\n  \\caption{ \\protect\\subref{subfig:dataset}: Input graph statistics, \n    \\protect\\subref{subfig:maxpat_stats}: Maximal pattern statistics (the numbers\n    shown are average values).\n  }\n  \\label{fig:stats}\n\\end{figure}\n\n\\subsection{Configuration Management Database\\\\ (CMDB)} \n\nA CMDB is used to manage and query the IT infrastructure of an\norganization. It stores information about the so-called configuration\nitems (CIs) -- servers, software, running processes, storage systems,\nprinters, routers, etc. As such it can be considered to be a single\nlarge multi-attributed graph, where the vertices represent the various CIs\nand the edges represent the connections between the CIs (e.g., the\nprocesses on a particular server, along with starting and ending times).\nMining such graphs is challenging because they are large, complex,\nmulti-attributed, and have many repeated labels.  We used a real-world\nCMDB graph for a large multi-national corporation (name not revealed due\nto non-disclosure issues) from HP's Universal Configuration Management\nDatabase (UCMDB).  Table~\\ref{tab:db} shows the size of the CMDB graph. \n\n\n\\smallskip\\noindent{\\textit{Cost Matrix}:} \nThe set of labels in a CMDB form a\nhierarchy which can be obtained from HP's UCMDB. In the absence of\ndomain knowledge, one way to obtain a cost matrix is by assigning low\ncosts for pairs of labels that share many ancestors in the hierarchy and\nhigh costs otherwise. The algorithm is general in that it doesn't depend\non how the label matching costs are assigned, the range of these\nvalues or whether the cost matrix is symmetric\n.  Consider any two labels $l_1$, $l_2$ and their corresponding\npaths $p_1$, $p_2$ to the root vertex in the hierarchy.  We first define\nthe similarity between the labels to be proportional to the number of\ncommon labels in $p_1 \\cap p_2$, as follows\n\\begin{equation*}\n  sim(l_1,l_2) =  \\frac{|p_1 \\cap p_2|}{2} \\times \n  \\left(\\frac{1}{|p_1|} + \\frac{1}{|p_2|}\\right)\n\\end{equation*}\nThe cost of matching the labels is then \n$\\matij{C}{l_1}{l_2} = 1 - sim(l_1,l_2)$.\n\n\\begin{figure}[!ht]\n  \\centerline{\n    \\includegraphics[width=2.5in]{ge.eps}\n\t}\n    \\caption{CMDB: Time for different values of\n\t$minsup$}\n    \\label{fig:ge}\n\\end{figure}\n\n\n\\smallskip\\noindent{\\textit{Results}:} Figure \\ref{fig:ge} shows the\ntime for random walks for different values of $minsup$ and $\\alpha =\n0.5$. Interesting, and somewhat counter-intuitively, the time increases\nfor higher minimum support values.  The reason is that with higher\nminimum support, the random walk in the search space goes through the\nvertices that have a large number of embeddings and it takes more time to\nenumerate a single pattern.\n\n%%%%%%%% Orbits idea explained as an optimization in the mining section\n\\begin{comment}\nThe running time results above include a particular optimization that we\napplied for CMDB graphs, given the large multiplicities of the different\nlabels. For such graphs, the \nsupport computation procedure can be improved by computing the sets of\nequivalent vertices, i.e., vertices that have the same neighborhood and\nare indistinguishable. The representative set $R(u)$ of all equivalent\nvertices are equal, and thus it has to be computed only once.  In\nabstract algebra terms, such vertices belong to an orbit of the\nautomorphism group of the graph \\cite{orbits}.  So, we can prune the\ncandidate representative sets of all the vertices in an orbit by\nmatching the labels of any vertex in the orbit with the labels of\nvertices in the candidate set. Computing the orbits of an arbitrary\ngraph is a hard problem. Several heuristics have been proposed to\ncompute the orbits of a graph \\cite{Everett}.  We use a simple heuristic\nto find subsets of vertices, common ancestor leaves (CAL) that are\nguaranteed to be in the same orbit. These are the subset of leaves that\nhave the same label and are connected to a common ancestor.  CAL is a\nsubset $S \\subseteq \\vg$, such that $\\forall u \\in S$ and the following\nthree properties hold true: i) $|N(u)|=1$, ii) $\\exists v \\in \\vg$,\n$(v,u) \\in \\eg$, and  iii) $L(u) = l$  for some $l \\in \\Sigma$.\nAn example of CAL is set of all vertices labeled ``9 $\\times$ process'' in\nfigure \\ref{fig:gepatsB}; here 9 is the multiplicity of that label. \nCAL sets have to be computed once for every\ncandidate and this step had negligible impact on the overall run time. \n\\end{comment}\n\n\\begin{figure}[!h]\n    \\centerline{\n    \\subfloat[Pattern $A$] {\n\t\\label{fig:gepatsA}\n      \\scalebox{0.6}{\n        \\begin{pspicture}(-2,-0.5)(3,5)\t\n          \\begin{psmatrix}[rowsep=1,colsep=1]\n          \\Toval[name=n4]{running\\_software} & & \\\\\n             \\Toval[name=n1]{windows\\_service} & \\Tcircle[name=n2]{iis} &\n            \\Toval[name=n3]{iisftpservice}\\\\\n            \\Tcircle[name=n5]{nt} & & \\\\\n            \\Toval[name=n6]{ip\\_address} & \\Toval[name=n7]{webvirtualhost} &\n            \\Toval[name=n8]{iiswebsite}\n            %\\Toval[name=n1]{business\\_application} & \\Toval[name=n2]{windows\\_service}\\\\\n            %\\Tcircle[name=n3]{nt} & \\\\\n            %\\Toval[name=n5]{sqlserver} & \\Toval[name=n4]{process}\\\\\n            %& \\Toval[name=n6]{windows\\_service $\\times$ 8}\n          \\end{psmatrix}\n          \\ncline{n1}{n4}\n          \\ncline{n1}{n2}\n          \\ncline{n2}{n3}\n          \\ncline{n2}{n5}\n          \\ncline{n2}{n7}\n          \\ncline{n1}{n5}\n          \\ncline{n1}{n4}\n          \\ncline{n6}{n5}\n          \\ncline{n7}{n6}\n          \\ncline{n7}{n8}\n          \\ncline{n3}{n8}\n        \\end{pspicture}\n      }\n\t  }}\n\t\\centerline{\n    \\subfloat[Pattern $B$] {\n\t\\label{fig:gepatsB}\n      \\scalebox{0.5}{\n        \\begin{pspicture}(-2,-1)(4,7)\t\n          \\begin{psmatrix}[rowsep=1,colsep=1]\n            & \\Toval[name=n1]{9 $\\times$ process} & & \\Toval[name=n2]{ip\\_address} \\\\\n            & \\Toval[name=n3]{windows\\_service} & \\Tcircle[name=n4]{nt} &\n            \\Toval[name=n5]{ip\\_address} \\\\\n            \\Toval[name=n6]{iisftpservice} & \\Tcircle[name=n7]{iis} & &\n            \\Toval[name=n8]{webvirtualhost} \\\\\n            & & \\Toval[name=n9]{iisappool} & \\\\\n            & \\Toval[name=n10]{iisftpservice} & & \\Toval[name=n11]{iiswebsite} \\\\\n          \\end{psmatrix}\n        \\ncline{n1}{n4}\n        \\ncline{n2}{n4}\n        \\ncline{n3}{n4}\n        \\ncline{n5}{n4}\n        \\ncline{n6}{n7}\n        \\ncline{n3}{n7}\n        \\ncline{n8}{n7}\n        \\ncline{n7}{n9}\n        \\ncline{n11}{n9}\n        \\ncline{n11}{n8}\n        \\ncline{n7}{n10}\n        \\ncline{n10}{n11}\n        \\ncline{n5}{n8}\n        \\end{pspicture}\n      }\n\t  }}\n    \\caption{CMDB: Approximate Patterns}\n    \\label{fig:gepats}\n  \\end{figure}\n\n\\smallskip\\noindent{\\textit{Example Patterns}:}\nFigure \\ref{fig:gepats} shows maximal approximate\npatterns from the real world CMDB graph. Both these patterns show\ntypical ``default'' \nconfigurations of the IT infrastructure in this company. They show the\nconnection between some services running on an NT server, and also the\nweb/ftp services. The node with label \\textit{9 $\\times$ process} \nin figure \\ref{fig:gepatsB} indicates that there are nine nodes \nin the maximal pattern with label \\textit{process} all of which\nare connected to a common node. This is an example where the run time\nfor computing the representative sets is significantly reduced by\nthe optmization proposed in section \\ref{sec:labelcheck}. All of the nine\nnodes belongs to the same orbit and hence their representative sets are\nidentical.\n\n\n\n\n\\begin{figure}\n    \\centering\n    \\scalebox{0.6}{\n    \\begin{pspicture}(0,0)(3,5)\n          \\begin{psmatrix}[rowsep=1,colsep=1]\n          & \\Toval[name=n1]{running\\_software} & \\\\\n          \\Toval[name=n2]{EnrichActImpl} & & \\Toval[name=n3]{process}\\\\\n          \\Toval[name=n4]{process} & \\Toval[name=n5]{nt} &\n          \\Toval[name=n6]{ip\\_address}\\\\\n          & \\Toval[name=n7]{$8 \\times process$} & \\\\\n          \\end{psmatrix}\n          \\ncline{n1}{n2}\n          \\ncline{n2}{n3}\n          \\ncline{n2}{n4}\n          \\ncline{n2}{n5}\n          \\ncline{n4}{n5}\n          \\ncline{n5}{n6}\n          \\ncline{n5}{n3}\n          \\ncline{n5}{n1}\n          \\ncline{n5}{n7}\n    \\end{pspicture}\n    }\n    \\caption{Complete Enumeration Expensive}\n    \\label{fig:geex}\n\\end{figure}\n\n\n\nTo show the effectiveness of the pruning based on labels, we compared\nthe time taken to enumerate a single maximal pattern in CMDB database.\nWe compared the time with and without label-based pruning.\nBoth the methods terminated the random walk with the maximal pattern\nshown in Figure~\\ref{fig:geex}.  \nHowever, the total time taken to enumerate the pattern\nwithout using any derived label is $18306$ secs whereas by using the\n\\ncl label the total time reduced to only $15.5776$ secs. The huge\ndifference between the times arises due to the multiplicity effect in\nCMDB graphs.  \n\n\n%%% compare the performance of gapprox, label pruning and no pruning\n\n\n\n\\subsection{Protein Structure Dataset (SCOP)}\nSCOP (\\url{scop.mrc-lmb.cam.ac.uk/scop/}) \nis a hierarchical classification of proteins based on structure\nand sequence similarity. The four levels of hierarchy in this\nclassification are: class, fold, superfamily and family.  The $3D$\nstructure of a protein can be represented as an undirected graph with\nthe vertex labels being the amino acids, with an edge connecting two\nnodes if the distance between the \n3D coordinates of the two amino acids (their\n$\\alpha$-Carbon atoms) is within a threshold (we use 7 Angstroms).\nWe constructed a database of\n$100$ protein structures belonging to $5$ different families with $20$\nproteins from each family. \nWe chose the proteins from different levels in the SCOP hierarchy, and\nwe also focused on large proteins (those with more than 200 amino\nacids). \nThe 3D protein structures were downloaded from the\nprotein data bank (\\url{http://www.rcsb.org/pdb}).  The database\ncan be considered as a single large graph with $100$ connected\ncomponents. \nFor the SCOP dataset, the support is redefined as \nthe number of proteins containing the pattern, i.e., \neven if a protein contains multiple embeddings we count them only once for the support.\n\n\\smallskip\\noindent{\\textit{Cost Matrix}:}\nSince there are 20 different amino acids, we need a $20 \\times 20$ cost\nmatrix. BLOSUM62~\\cite{HH92} is a commonly used substitution matrix for aligning protein\nsequences.  The $i,j$ entry in BLOSUM denotes the log-odd score\nof substituting the amino acids $a_i$ and $a_j$, defined as\n\\begin{equation*}\n    \\label{eq:blosum}\n    \\matij{B}{i}{j} = \\frac{1}{\\lambda} \n\t\\log\\frac{p_{ij}}{f_i \\cdot f_j}\n\\end{equation*}\nwhere $p_{ij}$ denotes the probability that  $a_i$ can be\nsubstituted by $a_j$; \n$f_i$, $f_j$ denote the prior probabilities for observing the \namino acids; and $\\lambda$ is a constant. We compute $f_i$ and $f_j$\nfrom the database, and then reconstruct $p_{ij}=f_if_j e^{\\lambda\nB_{i}}$. Next, we define the pair-wise amino acid cost matrix as\n$\\matij{C}{i}{j} = 1-\\frac{p_{ij}}{p_{ii}}$, which ensures that\nthe diagonal entries are $\\matij{C}{i}{i} =0$.\n\n\\begin{figure}[!ht]\n\t\\centerline{\n    \\includegraphics[width=3in]{5F20P.eps}\n\t}\n\t\\caption{SCOP: Effect of $\\alpha$}\n    \\label{fig:5F20P}\n\\end{figure}\n\n\\begin{figure}[!ht]\n  \\centerline{\n    \\includegraphics[width=2.5in]{runtime_compare.eps}\n\t}\n    \\caption{SCOP: Runtime comparison}\n    \\label{fig:runtime}\n\\end{figure}\n\n\\begin{figure}[!ht]\n  \\centerline{\n    \\includegraphics[width=2.5in]{scop_minsup.eps}\n\t}\n\t\\caption{SCOP: Effect of $minsup$}\n    \\label{fig:5F20P_ft}\n\\end{figure}\n\n\n\\smallskip\\noindent{\\textit{Results}:}\nFigure \\ref{fig:5F20P} shows the time taken for enumerating approximate\nmaximal patterns for different values of $\\alpha$ (with fixed $minsup =\n20$). The plots show the time for random walks with and without the\nlabel pruning. It can be seen that by using the label-based pruning the\ntime for random walks reduces significantly (by over 100\\%).  As\nexpected, the time increases as the values of $\\alpha$ increases, since\nthe number of isomorphisms clearly increases for a more relaxed (larger)\ncost threshold.  When $\\alpha = 0.01$, the patterns are exact as\n$\\matij{C}{i}{j} > \\alpha$ $,\\forall i \\neq j$.\n\nFigure \\ref{fig:runtime} compares the time taken to mine $500$\nmaximal patterns from the SCOP dataset using the \\ncl label algorithm\nand two naive isomorphism enumerating algorithms. \nThe value of $minsup$ is $15$ and\nthe threshold $\\alpha$ is chosen as $0.7$.\nThe \\textit{no pruning}\nalgorithm computes the representative sets from the candidate representative\nsets directly using the verification procedure described in\nsection \\ref{sec:verification}. The \\textit{gApprox} algorithm is based on\n\\cite{gapprox} and stores all isomorphisms during the course of enumerating\na maximal pattern. For each candidate pattern, it computes the isomorphisms\nfrom the isomorphisms of the frequent pattern from which the candidate \npattern is generated. It can be see that, the run time for the \\ncl based \nalgorithm is significantly less compared to the naive enumeration algorithms \nas it prunes invalid candidates without performing an expensive verification\nprocedure or storing potentially an expensive number of isomorphims.\n\n\nFigure \\ref{fig:5F20P_ft} shows the time taken for $K=500$ random walks\nfor various values of $minsup$, but with a fixed $\\alpha = 0.7$. The bar\nplot shows time spent in \\khop matching (Hops), \\ncl matching\n(Neighbors) and pattern verification (Enumeration). In general, the time\nincreases as the $minsup$ increases because the representative sets\n$R(u)$ become larger. However, there is no fixed trend as the total time\ndepends on the regions of pattern space that the random walk explores.\n\n\\begin{figure}[!ht]\n  \\centerline{\n    \\includegraphics[width=2.5in]{scop_effectiveness.eps}\n\t}\n\t\\caption{SCOP: Effectiveness of labels}\n    \\label{fig:D5F20P_eff}\n\\end{figure}\n\nFigure~\\ref{fig:D5F20P_eff} compares the effectiveness of the \\ncl\nlabel and \\khop label for different values of the\nthreshold $\\alpha$ on the SCOP dataset.  For each value of $\\alpha$, the\nleft bar shows the time with \\ncl label, whereas the right bar\nshows the time using only the \\khop label.  The \\ncl label clearly\nreduces the time taken. In fact, it reduces the time for both the \\khop\nmatching and the pattern verification steps, since \\ncl is very\neffective in pruning the representative set.  This effect is best seen\nfor $\\alpha = 0.75$, where the total time for the enumeration reduces\neven though matching the neighbors takes more time compared to \\khop\nmatching.  This shows the effectiveness of the \\ncl label versus\n\\khop label in isolation.\n\n\\begin{figure}[!ht]\n  \\centerline{\n  \\subfloat[Pattern $A$]{\n    \\label{fig:scopA}\n    \\includegraphics[width=1.5in,height=1.25in]{1ysw.pat.eps}\n\t}\n  \\subfloat[Pattern $B$]{\n    \\label{fig:scopB}\n    \\includegraphics[width=1.5in,height=1.0in]{1r2e.pat.eps}\n\t}\t\n\t}\n\t\\centerline{\n\t\\subfloat[Structural Motif $A$]{\n    \\label{fig:scopAS}\n    \\includegraphics[width=1.5in,height=1.5in]{1ysw.eps}\n\t}\n\t\\subfloat[Structural Motif $B$]{\n    \\label{fig:scopBS}\n    \\includegraphics[width=1.5in,height=1.5in]{1r2e.eps}\n\t}\n\t}\n\t\\caption{SCOP: Approximate Graph Patterns and their Structures}\n\t\\label{fig:scoppats}\n\\end{figure}\n\n\n\\smallskip\\noindent{\\textit{Example Patterns}:}\nFigure~\\ref{fig:scoppats} shows examples of approximate protein graph\npatterns and their corresponding 3D structure extracted from the SCOP\ndataset.  For example, the graph in \\ref{fig:scopA} appears in only one of\nthe families. This pattern occurs in 18 of the 20 members, and the\nstructure of one its occurrences, in protein PDB:1YSW, is shown in\n\\ref{fig:scopAS}. The common motif corresponds to the black colored\namino acids.  Another approximate pattern is shown in \\ref{fig:scopB},\nand its structure in PDB:1R2E is shown in \\ref{fig:scopBS}; it has\nsupport 19.  It is important to note that the cost of this isomorphism\nis $C(\\phi) = 0.4541$, indicating that exact isomorphism cannot find the\nmotif.\n\n\\subsection{Protein-Protein Interaction Network (PPI)} We ran\nexperiments on a yeast (Saccharomyces cerevisiae) PPI network. The list of\ninteracting proteins for yeast was downloaded from the DIP database\n(\\url{http://dip.doe-mbi.ucla.edu}). As seen in Table~\\ref{tab:db}, the\nPPI network has 4950 proteins and 16,515 interactions.  Unlike the other\ndatasets, each node in the PPI network essentially has a unique label,\nwhich is the protein name.  \n\n\\smallskip\\noindent{\\textit{Cost Matrix}:} \nTo construct the cost matrix for the protein network we consider the\nsimilarity between the protein sequences for any two adjacent nodes.\nSequence similarity is obtained via the BLAST alignment\nscore~\\cite{altschul90}, that returns the expected value (E-value) of\nthe match. A low E-value implies high similarity, thus we create a\nbinary cost matrix between the proteins by setting\n$\\matij{C}{p_i}{p_j} =0$ iff the proteins $p_i$ and $p_j$ have high\nsimilarity, i.e., iff $E-value(p_i, p_j) \\le \\epsilon$. We empirically \nset $\\epsilon = 0.003$.\n\n\n\\begin{figure}[!h]\n\t\\centerline{\n\t\\includegraphics[width=2.5in]{ppi.eps}\n\t}\n    \\caption{PPI: Time for different values of $minsup$}\n    \\label{fig:ppiwalks}\n\\end{figure}\n\n\\smallskip\\noindent{\\textit{Results}:} Figure \\ref{fig:ppiwalks} shows\nthe time for random walks in the yeast $PPI$ network for different values of\n$minsup$.  It can be seen that the time for random walks decreases as\nthe support value increases.  One of the differences for the PPI graph\nis that we do not utilize the \\khop labels.  The complexity of matching\nthe \\khop labels depends on the number of literals in the \\khop label.\nAs each label(protein) is unique in the PPI graph, the number of\nliterals in the \\khop label of a vertex $v$ in a PPI network is equal to\nthe number of vertices reachable in \\khops. This increases the run time\nfor the \\khop label matching.  Therefore, for mining PPI networks we use\nonly the \\ncl labels.\n\n\n\\begin{figure}[!ht]\n  \\subfloat[Pattern $A$]{\n    \\label{fig:ppipatsA}\n    \\includegraphics[width=2in]{ppipat2.eps}\n\t}\\\\\n\\subfloat[GO Terms for $A$]{\n  % Table for the search space pruning\n    \\label{fig:ppipatsAT}\n  \\begin{tabular}{c|p{2in}}\nGO Terms & Description\\\\\n\\hline\nBP:0051603&      proteolysis involved in cellular protein catabolic\nprocess\\\\\n\\hline\nMF:0004298&      threonine-type endopeptidase activity\\\\\n\\hline\nCC:0034515&      proteasome storage granule\\\\\n  \\end{tabular}\n  %\\label{subfig:match}\n  } \\\\ \n  \\subfloat[Pattern $B$]{\n    \\label{fig:ppipatsB}\n    \\includegraphics[width=2in]{ppipat1.eps}\n\t}\\\\\n  \\subfloat[GO Terms for $B$]{\n    \\label{fig:ppipatsBT}\n  \\begin{tabular}{c|p{2in}}\nGO Terms & Description\\\\\n\\hline\nBP:0004674  & protein serine/threonine kinase activity\\\\\n\\hline\nMF:0016301   &   kinase activity\\\\\nMF:0005524   &   ATP binding\\\\\n  \\end{tabular}\n  }\n    \\caption{Approximate PPI Patterns and GO Enrichment}\n    \\label{fig:ppipats}\n\\end{figure}\n\n\\begin{comment}\n\\begin{figure}[!ht]\n  \\centerline{\n  \\subfloat[Pattern $A$]{\n    \\label{fig:ppipatsA}\n    \\includegraphics[width=2in]{ppipat2.eps}\n\t}}\n\t\\centerline{\n  \\subfloat[GO Terms for $A$]{\n    \\label{fig:ppipatsAT}\n  \\small\n  \\begin{tabular}{c|p{2in}}\nGO Terms & Description\\\\\n\\hline\nBP:0051603&      proteolysis involved in cellular protein catabolic\nprocess\\\\\n\\hline\nMF:0004298&      threonine-type endopeptidase activity\\\\\n\\hline\nCC:0034515&      proteasome storage granule\\\\\n  \\end{tabular}\n  }}\n  \\centerline{\n  \\subfloat[Pattern $B$]{\n    \\label{fig:ppipatsB}\n    \\includegraphics[width=2in]{ppipat1.eps}\n\t}}\n\t\\centerline{\n  \\subfloat[GO Terms for $B$]{\n    \\label{fig:ppipatsBT}\n  \\small\n  \\begin{tabular}{c|p{2in}}\nGO Terms & Description\\\\\n\\hline\nBP:0004674  & protein serine/threonine kinase activity\\\\\n\\hline\nMF:0016301   &   kinase activity\\\\\nMF:0005524   &   ATP binding\\\\\n  \\end{tabular}\n  }}\n    \\caption{Approximate PPI Patterns and GO Enrichment}\n    \\label{fig:ppipats}\n\\end{figure}\n\\end{comment}\n\n\\smallskip\\noindent{\\textit{Example Patterns}:}\nFigures~\\ref{fig:ppipatsA} and \\ref{fig:ppipatsB} show two of the mined\nmaximal frequent approximate patterns (using $minsup=5$). The proteins\nare labeled with their DIP identifiers (e.g., DIP-2818N); the last\nnumber in the label is just a sequential node id.  It is worth\nemphasizing that exact subgraph isomorphism would not yield any patterns\nin this dataset, since each label is unique. However, since we allow a\nprotein to be replaced by a similar protein via the cost matrix \\Cs,\nwe obtain interesting approximate patterns. To judge the quality of the\nmined patterns we use the gene ontology (GO;\n\\url{www.geneontology.org}), which comprises three structured,\ncontrolled vocabularies (ontologies) that describe gene products in\nterms of their associated biological processes (BP), molecular functions\n(MF), and cellular components (CC).  For each of the mined approximate\npatterns we obtain the set of all the GO terms common to all proteins in\nthe pattern. This serves as an external validation of the mined results,\nsince common terms imply meaningful biological relationships among the\nproteins.  Figure~\\ref{fig:ppipatsAT} shows the common GO terms for\npattern $A$.  This subgraph comprises proteins involved in proteolysis\nas the biological process, i.e., they act as enzymes that lead to the\nbreakdown of other proteins into amino acids. Their molecular function\nis endopeptidase activity, i.e., breakdown of peptide bonds of\nnon-terminal amino acids, in particular the amino acid Threonine.  These\nproteins are located in the proteasome storage granule, and most likely\ncomprise a protein complex (proteasome) -- a molecular machine --\nthat digests proteins into amino acids.  The common GO terms for pattern\n$B$ in Figure~\\ref{fig:ppipatsBT} indicate that the proteins function as\nKinases, proteins that are responsible for adding a phosphate to an\namino acid. The biological process is Phosphorylation, the\npost-translational modification of proteins corresponding to adding a\nphosphate, in particular modifying amino acids Serine and Threonine. \n", "meta": {"hexsha": "88c542f66e678809ed8bf9457d744ba698d88a73", "size": 23705, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/results.tex", "max_stars_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_stars_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/results.tex", "max_issues_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_issues_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/results.tex", "max_forks_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_forks_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-08T11:17:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-08T11:17:33.000Z", "avg_line_length": 39.7734899329, "max_line_length": 89, "alphanum_fraction": 0.7140687619, "num_tokens": 7023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4216652554874618}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{November 2 2018}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\n\\DeclareMathOperator{\\Int}{Int}\n\\DeclareMathOperator{\\grad}{grad}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\mb}[1]{\\mathbf{#1}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Multivariate Taylor Series}\n\n\\subsection{Review of Single Variable Taylor Series}\nRecall the definition of the \\(n^{th}\\) degree Taylor polynomial of \\(f\\) centered at \\(a\\)\n\\[P_{n, a}(f) = \\sum_{k = 0}^n\\frac{f^{(k)}(a)}{k!}(x - a)^k\\]\nWe define \\(R_{n, a}\\) to be the ``remainder'', the difference between \\(P_{n, a}\\) and \\(f\\). We can write this remainder in ``Lagrange form'' as\n\\[\\frac{f^{(n + 1)}(t)}{(n + 1)!}(x - a)^{n + 1}\\]\nClearly,\n\\[\\lim_{x \\to a}\\frac{R_{n, a}(x)}{(x - a)^n} = 0\\]\nWe can now define the \\underline{Taylor series} of \\(f\\) at \\(a\\) to be\n\\[T_af = \\sum_{k = 0}^\\infty\\frac{f^{(k)}(a)}{k!}(x - a)^k\\]\n\\subsubsection{Why these coefficients?}\nSuppose\n\\[f(x) = \\sum_{k = 0}^\\infty a_k(x - a)^k\\]\nNote\n\\[\\frac{d^n}{dx^n}(x - a)^k = \\left\\{\\begin{array}{cc}\n  0 & \\text{if } k < n \\\\\n  k! & \\text{if } n = k \\\\\n  k(k - 1)...(k - n + 1)(x - a)^{k - n} & \\text{if } k > n\n\\end{array}\\right.\\]\n\n\\subsection{Multivariable Case}\nFor example: What's your favorite polynomial? Zero? I'm sure you meant something more like\n\\[f(x, y, z) = a_{12,8,2}x^{12}y^8z^2 + a_{0,22,0}y^{22} + a_{0,0,1}z + a_{20,20,20}x^{20}y^{20}z^{20}\\]\nHow to do spot \\(a_{12, 8, 2}\\)? Apply:\n\\[\\left.\\frac{\\partial^{22}f}{\\partial x^2 \\partial y^8 \\partial z^2}\\right|_{(x, y, z) = (0, 0, 0)} = a_{12, 8, 2}12!8!2!\\]\nIn general, if \\(f\\) is a sum of terms like\n\\[a_{\\alpha_1,...,\\alpha_n}x^{\\alpha_1}....x^{\\alpha_n}\\]\nThen\n\\[a_{\\alpha_1,...,\\alpha_n} = \\left.\\frac{\\partial^{\\alpha_1 + ... + \\alpha_n}f}{\\partial x_1^{\\alpha_1} ... \\partial x_n^{\\alpha_n}}\\right|_{(x_1,...,x_n) = (0,...,0)}\\frac{1}{\\alpha_1!...\\alpha_n!}\\]\n\n\\subsection{Multi-index notation}\nWe're mathematicians here, and what do mathematicians do, we generalize. But we generalize in such a way such that the general case looks like the specialized case so we don't have to remember different notation when teaching first-years and when doing research. Multi-index notation is a prime example. Compare:\n\\begin{itemize}\n\n  \\item Let \\(f: \\reals \\to \\reals\\). Then\n  \\[f = \\sum_{k \\in \\nats}\\frac{1}{k!}f^{(k)}(a)(x - a)^k\\]\n\n  \\item Let \\(f: \\reals^n \\to \\reals\\). Then\n  \\[f = \\sum_{\\alpha \\in \\nats^n}\\frac{1}{\\alpha!}\\frac{\\partial^{|\\alpha|}}{\\partial x^\\alpha}(a)(x - a)^\\alpha\\]\n\n\\end{itemize}\nTo make this to work, all we have to do is define, for\n\\[\\alpha = (\\alpha_1,...,\\alpha_n) \\in \\nats^n\\]\nthe notation\n\\[\\alpha! = \\alpha_1!...\\alpha_n!\\]\n\\[|\\alpha| = \\alpha_1 + ... + \\alpha_n\\]\n\\[\\partial x^\\alpha = \\partial x_1^{\\alpha_1} ... \\partial x_n^{\\alpha_n}\\]\n\\[(x - a)^\\alpha = (x_1 - a_1)^{\\alpha_1}...(x_n - a_n)^{\\alpha_n}\\]\n\n\\subsubsection{Examples}\n\\begin{enumerate}\n\n  \\item\n  \\[\\frac{1}{6!y!}12x^6y^7 = \\frac{12}{(6, 7)!}(x, y)^{6, 7}\\]\n\n  \\item\n  \\[x^5 + x^4y + x^3y^2 + ... + y^5 = \\sum_{\\beta + \\gamma = 5}(x, y)^{(\\beta, \\gamma)} = \\sum_{|\\alpha| = 5}(x, y)^\\alpha\\]\n  Note that we're assuming here \\(\\beta, \\gamma\\) are non-negative. On good days you can just do what we did above, but if it worries you, write it down.\n\n  \\item\n  \\[a_{0, 0} + a_{1, 0}x + a_{0, 1}y + a_{1, 1}xy + a_{2, 0}x^2 + a_{0, 2}y^2 = \\sum_{|\\alpha| \\leq 2}a_{\\alpha}(x, y)^{\\alpha}\\]\n\n\\end{enumerate}\n\n\\section{Multivariable Taylor Series}\n\n\\begin{theorem}\n  If \\(f: \\reals^n \\to \\reals\\) is \\(\\mc{C}^{k + 1}\\) then\n  \\[f(a + h) = \\sum_{|\\alpha| \\leq k}\\frac{1}{\\alpha!}\\frac{\\partial^{|\\alpha|}f}{x^\\alpha}(a)h^\\alpha + \\sum\\_{|\\alpha| = k + 1}\\frac{1}{\\alpha!}\\frac{\\partial^{|\\alpha|}f}{\\partial x^\\alpha}(a + \\theta h)h^\\alpha\\]\n  where \\(\\theta \\in (0, 1)\\)\n\\end{theorem}\n\\begin{proof}\n  The key idea is\n  \\[F(t) = f(a + th)(\\text{Old Taylor } + \\text{ Chain Rule})\\]\n  More rigorously, we know from single variable calculus that\n  \\[F(t) = F(0) + \\frac{F'(0)}{1!}t + ... + \\frac{F^{(k)}(0)}{k!}t^k + \\frac{F^{k + 1}(\\theta)}{(k + 1)!}t^{k + 1}\\]\n  Set \\(t = 1\\) to get \\(F(1) = f(a + h)\\).\n  We know \\(F(0) = f(a)\\). We have\n  \\[\\left.\\frac{dF}{dt}\\right|_{t = 0} = \\left.\\frac{d}{dt}f(a + th)\\right|_{t = 0} = \\sum_{i = 1}^n\\left.\\prt{f}{x}(a + th)\\right|_{t = 0}\\prt{x_i}{t} = \\sum_{i = 1}^n\\left[\\left.\\prt{f}{x_i}(a + th)\\right|_{t = 0}\\right]h_i\n  = \\sum_{i = 1}^n\\prt{f}{x_i}(a)h_i\\]\n  We have\n  \\[\\left.\\frac{d^2F}{dt}\\right|_{t = 0} = \\sum_{i = 1}^n\\left[\n    \\sum_{j = 1}^n\\frac{\\partial^2f}{\\partial x_j \\partial x_i}(a)h_j\n  \\right]h_i\\]\n  By the magical process of ...,\n  \\[\\left.\\frac{d^kF}{dt^k}\\right|_{t = 0} = \\sum_{i_1,...,i_k = 1}^n\\frac{\\partial^kf}{\\partial x_{i_1} ... \\partial x_{i_k}}(a)h_{i_1}...h_{i_k}\\]\n  Now all we need is some combinatorics, combined with the equality of mixed partials (for \\(\\mc{C}^{k + 1}\\) functions), to complete the proof. Recall the \\textit{multinomial coefficient}\n  \\[{{|\\alpha|} \\choose {\\alpha_1,...,\\alpha_n}} = \\frac{|\\alpha|!}{\\alpha_1!...\\alpha_n!}\\]\n  is the number of ways of taking \\(|\\alpha|\\) things and making \\(k\\) groups of size \\(\\alpha_1,...,\\alpha_n\\).\n  We can use this to rewrite the above as\n  \\[F^{(S)}(0) = \\sum_{|\\alpha| = S}\\frac{S!}{\\alpha_1!...\\alpha_S!}\\frac{\\partial^{|\\alpha|}f}{\\partial x^\\alpha}(a)h^\\alpha\\]\n  So plugging this into our original expression for the Taylor series of \\(F\\), where we divide the \\(S^{th}\\) term by \\(\\frac{1}{S!}\\), we have\n  \\[F(t) = F(0) + \\sum_{i = 1}^k\\sum_{|\\alpha| = i}\\frac{1}{\\alpha_1!...\\alpha_k!}\\frac{\\partial^{|\\alpha|}f}{\\partial x^\\alpha}(a)h^\\alpha\n  = f(a) + \\sum_{|\\alpha| \\leq k}\\frac{1}{\\alpha!}\\frac{\\partial^{|\\alpha|}f}{\\partial x^\\alpha}(a)h^\\alpha\\]\n  as desired.\n\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "df040be007a1046f4bfd4840e6c7eda72dedbfdb", "size": 6524, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/nov2.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/nov2.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/nov2.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.6223776224, "max_line_length": 312, "alphanum_fraction": 0.6051502146, "num_tokens": 2685, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228625116081, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.42166524699049923}}
{"text": "\n\\section{Catalan array, precisely}\n\\label{sec:C:precisely}\n\n% big comment: skip it, maybe the content is interesting, but stated very ugly.\n\\iffalse\nLet $\\mathcal{C}_{h}$ a principal $h$-cluster of\nthe Catalan array, in its traditional definition: We attempt to point out\nsome properties about $\\mathcal{C}_{h+1}$:\n\\begin{itemize}\n    \\item a more general pattern, for any $h\\in\\mathcal{N}$,\n        a coefficient $d_{p^{h}-1,k}$, for $k\\in\\lbrace0,\\ldots,p^{h}-1 \\rbrace$,\n        satisfies:\n        \\begin{displaymath}\n            d_{p^{h}-1,k} \\equiv_{p} 0\n        \\end{displaymath}\n    \\item consider the subcluster $\\mathcal{C}_{h}^{(0,p^{h}-1)}$ of\n        $\\mathcal{C}_{h}$ obtained by removing antidiagonal $0$ (namely,\n        the boundary one, composed by $1$s only) and by removing row $p^{h}-1$.\n        By construction, $\\mathcal{C}_{h}^{(0,p^{h}-1)}$ is a triangle too,\n        with $p^{h}-2$ coefficients per side. Therefore, $\\mathcal{C}_{h+1}$\n        is composed on the very top, starting at the root, by a copy of $\\mathcal{C}_{h}$,\n        while on the bottom there are three triangles:\n        \\begin{itemize}\n            \\item an equilateral triangle $T_{\\equiv_{p} 0}^{(h)}$,\n                with $p^{h}-1$ coefficients on each side, such that:\n                \\begin{displaymath}\n                    d_{nk} \\in T_{\\equiv_{p} 0}^{(h)} \\rightarrow d_{nk} \\equiv_{p} 0\n                \\end{displaymath}\n                where $n\\in\\lbrace p^{h},\\ldots,p^{h+1}-2\\rbrace$ and\n                $k\\in\\lbrace 0,\\ldots, n-p^{h}\\rbrace$, in other words\n                $k\\in\\lbrace 0,\\ldots, p^{h}(p-1)-2\\rbrace$;\n            \\item a mirror copy of $\\mathcal{C}_{h}^{(0,p^{h}-1)}$ respect to column orientation,\n                defining coefficients $d_{nk}$\n                where $n\\in\\lbrace p^{h},\\ldots,p^{h+1}-2\\rbrace$ and\n                $k\\in\\lbrace 1,\\ldots, p^{h}-2\\rbrace$;\n            \\item a segment of coefficients $d_{n, p^{h}-1} \\equiv_{p} 0$\n                where $n\\in\\lbrace p^{h},\\ldots,p^{h+1}-2\\rbrace$;\n            \\item a copy of $\\mathcal{C}_{h}^{(0,p^{h}-1)}$,\n                defining coefficients $d_{nk}$\n                where $n\\in\\lbrace p^{h}+1,\\ldots,p^{h+1}-2\\rbrace$ and\n                $k\\in\\lbrace p^{h},\\ldots, n-1\\rbrace$;\n        \\end{itemize}\n\\end{itemize}\n\\fi\n\nWe are now in the position to formally define the Catalan\narray $\\mathcal{C}$ and to introduce some mathematical objects\nthat will be used later; formally, $\\mathcal{C}$ is defined as\n\\begin{displaymath}\n    \\mathcal{C}=\\left(\\frac{1-\\sqrt{1-4\\,t}}{2\\,t},\n        \\frac{1-\\sqrt{1-4\\,t}}{2}\\right)\n\\end{displaymath}\nand it is a \\emph{renewal} array \\cite{rogers:1977} because\n$h(t)=t\\,d(t)$. Application of the substitution $k=0$ in the definition of the\ncoefficient $\\displaystyle d_{n,k} = [t^{n}]d(t)h(t)^{k}$ entails that the\n$n$-th Catalan number $C_{n}$ satisfies\n\\begin{displaymath}\n    C_{n} = [t^{n}]d(t)= [t^{n}]\\frac{1-\\sqrt{1-4\\,t}}{2\\,t}\n\\end{displaymath}\nwhere the operator $[t^{n}]$ extracts the coefficient of $t^{n}$ in the series expansion\nof the function $g(t)$ to which it is applied.\n\nAn equivalent characterization of a each matrix $\\mathcal{R}(d(t), h(t))$ in\nthe Riordan group is given by two sequences of coefficients\n$\\left(a_{n}\\right)_{n\\in\\mathbb{N}}$  and\n$\\left(z_{n}\\right)_{n\\in\\mathbb{N}}$ called $A$-sequence and $Z$-sequence,\nrespectively. The former one can be used to define every\ncoefficient $d_{n,k}$ with $k>0$,\n\\begin{equation}\n    d_{n+1, k+1} = a_{0}d_{n,k} + a_{1}d_{n,k+1} + a_{2}d_{n,k+2} + \\ldots + a_{j}d_{n,k+j} + \\ldots %+ a_{j+1}d_{n,k+j+1} + \\cdots\n\\end{equation}\nwhere the sum is finite because exists $j\\in\\mathbb{N}$ such that $n=k+j$. On\nthe other hand, the latter one can be used to define every coefficient\n$d_{n,0}$ lying on the first column,\n\\begin{equation}\n    d_{n+1, 0} = z_{0}d_{n,0} + z_{1}d_{n,1} + z_{2}d_{n,2} + \\ldots + z_{n}d_{n,n} + \\ldots %+ z_{n+1}d_{n,n+1} + \\cdots\n\\end{equation}\nwhere the sum is finite because $d_{n,k+j}=0$ for $j>n-k$.\n\nMoreover, let $A(t)$ and $Z(t)$ be the generating functions of the $A$-sequence\nand $Z$-sequence, respectively, then relations\n\\begin{equation}\n    h(t) = tA(h(t)) \\quad\\text{and}\\quad d(t)=\\frac{d_{0,0}}{1-tZ(h(t))}\n\\end{equation}\nconnect them with functions $d(t)$ and $h(t)$,\nwhere $d_{0,0}$ is the very first element %in the top left corner\nof $\\mathcal{R}$, see \\cite{merlini:some:alternative:characterizations:1997}.\n\nA last fact to be aware of is a fundamental theorem that allows us to perform\nmatrix-vector product of an array $\\mathcal{R}$ and an infinite column vector\n$\\vect{\\omega}=(\\omega_{0},\\omega_{1},\\omega_{2},\\ldots)$\nas the convolution\n\\begin{equation}\n    \\mathcal{R}\\cdot\\vect{\\omega} = d(t)\\Omega(h(t))\n\\end{equation}\nwhere $\\Omega$ is the $\\vect{\\omega}$'s generating function which admits the\nseries expansion $\\Omega(t)=\\sum_{k\\in\\mathbb{N}}{\\omega_{k}t^{k}}$.\n\nIn the rest of the paper we use the notation $c_{n,k}\\in\\mathcal{C}$ to denote\na coefficient belonging to the Catalan array at row $n$ and column $k$.\nWe instantiate previous properties for the Catalan array $\\mathcal{C}$,\nstarting with its $A$-sequence\n\\begin{displaymath}\n    A_{\\mathcal{C}}(t)=\\frac{1}{1-t}=1+t+t^{2}+t^{3}+t^{4}+t^{5}+t^{6}+t^{7}+t^{8}+\n        \\mathcal{O}(t^{9})\n\\end{displaymath}\nand, since $\\mathcal{C}$ is a renewal array, it is not difficult to see that\nits $Z$-sequence is the same as the $A$-sequence. Consequently, function $Z(t)$\ndefines each Catalan number $C_{n}$ as the sum $\\displaystyle C_{n} = c_{n,0} =\n\\sum_{k=0}^{n-1}{c_{n-1,k}} $ of coefficients lying on row $n-1$ and\nthe application of $[t^{n}]$ to the generating function $d(t)$ \nallows us to write a well known closed formula for the $n$-th Catalan number\n\\begin{equation}\n    C_{n} = \\frac{1}{n+1}{{2n}\\choose{n}} = {{2n}\\choose{n}} - {{2n}\\choose{n+1}}.\n    \\label{eq:catalan:coeff:rewriting}\n\\end{equation}\n\nOn the other hand, an arbitrary element $c_{n,k}\\in\\mathcal{C}$\nadmits closed formulae too and, according to \\cite{luzon:2012631}\n\\begin{align}\n    & c_{n,k}=\\frac{k+1}{n+1}{{2n-k}\\choose{n-k}}\\quad\\text{and}\n    \\label{eq:catalan:array:first:identity}\\\\\n    & c_{n,k}={{2n-k}\\choose{n-k}} - {{2n-k}\\choose{n-k-1}}\n    \\label{eq:catalan:array:second:identity}\n\\end{align}\nare of particular interest for our work.  In order to formally characterize\n$\\mathcal{C}_{\\equiv_{2}}$ we use the definition to write the generic coefficient\n\\begin{displaymath}\n    c_{n,k} = [t^n] \\frac{1-\\sqrt{1-4\\,t}}{2\\,t}\\,\n        \\left(\\frac{1-\\sqrt{1-4\\,t}}{2}\\right)^{k}\n           = [t^{n+1}] \\left(\\frac{1-\\sqrt{1-4\\,t}}{2}\\right)^{k+1}\n\\end{displaymath}\nwhere the right most term requires to extract coefficient $n+1$ from the $(k+1)$-fold\nconvolution of Catalan numbers' generating function with itself, \\emph{shifted\nby one place}\n\\begin{equation}\n    c_{n,k} = [t^{n+1}] \\left(\\frac{1-\\sqrt{1-4\\,t}}{2}\\right)^{k+1}\n            %= \\sum_{i_{1}+ i_{2}+ \\ldots+ i_{k+1}=n+1}{\n                %\\hat{c}_{i_{1}}\\,\\hat{c}_{i_{2}}\\,\\ldots\\,\\hat{c}_{i_{k+1}} }\n            = \\sum_{i_{1}+ i_{2}+ \\ldots+ i_{k+1}=n+1}{\n                C_{i_{1}-1}\\,C_{i_{2}-1}\\,\\ldots\\,C_{i_{k+1}-1} }.\n    \\label{eq:convolution:expansion:for:generic:element:in:catalan:array}\n\\end{equation}\n\n", "meta": {"hexsha": "733f6bc825ca3fc2d823eb8c8b8532e8d2e02729", "size": 7278, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "modular-article/C-formally.tex", "max_stars_repo_name": "massimo-nocentini/master-thesis", "max_stars_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modular-article/C-formally.tex", "max_issues_repo_name": "massimo-nocentini/master-thesis", "max_issues_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modular-article/C-formally.tex", "max_forks_repo_name": "massimo-nocentini/master-thesis", "max_forks_repo_head_hexsha": "0d82bfcc82c92512d0795f286256a19f39b9b1f9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.8493150685, "max_line_length": 131, "alphanum_fraction": 0.6232481451, "num_tokens": 2615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.42165036247900595}}
{"text": "\\subsection{Common Setup}\n  We propose two different kinds of games, both finite (but possibly generalizable to the infinite setting). The first\n  consists of one sole strategy where the players do not initially know whether they will be buyers, sellers or nothing at\n  all, this being decided in the last moment. The second game consists of three strategies: buyers, sellers and middlemen.\n  Before delving into the details of each game, we first describe their common elements.\n  \n  The general approach taken is as follows: After a game is described in detail, each player is assigned a specific strategy and\n  a relevant utility function. All players are considered to follow their respective strategy without deviating from it, except\n  for one player that is allowed to follow any desired strategy; her utility function however remains unchanged. If that player\n  is proven to have an incentive to deviate from her appointed strategy, we can deduce that the given strategies and utility\n  functions do not constitute a Nash equilibrium. If on the other hand no player has an incentive to deviate, regardless of\n  her appointed strategy, then we will come to the conclusion that the given strategies and utility functions do constitute a\n  Nash equilibrium. This approach is common in game theoretic analyses, given that allowing for all players to be rational and\n  then searching for a Nash equilibrium constitutes a practically intractable problem \\cite{nasheqcomp}. Another common\n  approach employed here is that of considering only a generic product that all buyers want and all sellers have, and not a\n  variety of different products.\n\n  A description of the structure that is common for both games follows. The game graph has a random initial configuration\n  where every player has a random direct trust towards every other player, as well as a random capital. These values may be\n  uniformly distributed in an interval or may follow another distribution such as the exponential, or may have a high\n  probability of being zero. The exact distribution however is not determined at this point, as it is not yet needed. This\n  distribution will be common knowledge to the players. All capitals and direct trusts are publicly viewable. Further\n  constraints may be applied to each game separately.  Transaction fees are not considered.\n  \n  The game consists of $R$ rounds, the number of which is common knowledge for the players. The players play simultaneously in\n  each round and can do any of the known actions. If two actions conflict (e.g. $A$ reduces $DTr_{A \\rightarrow B}$ and $B$\n  steals from $DTr_{A \\rightarrow B}$ as well), then one of the two actions is chosen with equal probability ($50\\%$). To\n  better model a player's actions and the aforementioned conflict resolution, we demand that each fund reallocation explicitly\n  mentions the source and the destination of the funds for each of her actions. Player $A$ decides on the values of all the\n  following variables. This constitutes a concrete round for $A$.\n  \n  \\begin{gather*}\n    \\forall B, C \\in \\mathcal{V}, move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right) \\in \\mathbb{R^+} \\\\\n    \\forall B, C \\in \\mathcal{V}, B \\neq A, move\\left(A, \\left(B, A\\right), \\left(A, C\\right) \\right) \\in \\mathbb{R^+}\n  \\end{gather*}\n  The first argument is the player who decides, the second argument is from which direct trust to take the funds and the third\n  is to which direct trust to deposit the funds. The first type of moves corresponds to $Add\\left(\\right)$ and the second to\n  the $Steal\\left(\\right)$ actions.\n  \n  To clarify a detail, for any $B \\in \\mathcal{V}$ (including $A$), $A$ is not allowed to set $move\\left(A, \\left(A, B\\right),\n  \\left(A, B\\right) \\right)$ to any value different than 0. This choice is made to facilitate the analysis.\n  \n  There are some constraints for player's $A$ move:\n  \\begin{itemize}\n    \\item There is no reason to be able to deposit to and withdraw from a specific direct trust in the same round.\n    Furthermore, such a possibility would allow for \"chain reactions\" in the conflict resolution phase that would add\n    unnecessary complications.  This constraint applies only to outgoing direct trusts, because incoming direct trusts cannot\n    be increased.\n    \\begin{gather*}\n      \\forall B, C, D \\in \\mathcal{V}, move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right) \\cdot move\\left(A, \\left(A,\n      D\\right), \\left(A, B\\right) \\right) = 0 \\\\\n      \\mbox{and} \\\\\n      \\forall B, C, D \\in \\mathcal{V}, move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right) \\cdot move\\left(A, \\left(D,\n      A\\right), \\left(A, B\\right) \\right) = 0\n    \\end{gather*}\n  \n    \\item One cannot use more funds than are available from a single direct trust.\n    \\begin{gather*}\n      \\forall B \\in \\mathcal{V}, \\sum\\limits_{C \\in \\mathcal{V}} move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right)\n        \\leq DTr_{A \\rightarrow B} \\\\\n      \\forall B \\in \\mathcal{V}, \\sum\\limits_{C \\in \\mathcal{V}} move\\left(A, \\left(B, A\\right), \\left(A, C\\right) \\right)\n        \\leq DTr_{B \\rightarrow A} \\\\\n    \\end{gather*}\n  \\end{itemize}\n  \n  If two players try to change the same direct trust, then set the relevant moves of one of the two players (chosen uniformly\n  at random) to 0.\n  \\begin{lstlisting}[label=conflict, style=numbers]\nresolveConflict((*@$A$@*), (*@$B$@*)) :\n  sum1 = (*@$\\sum\\limits_{C \\in \\mathcal{V}}move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right)$@*)\n  sum2 = (*@$\\sum\\limits_{C \\in \\mathcal{V}}move\\left(B, \\left(A, B\\right), \\left(B, C\\right) \\right)$@*)\n  if (sum1*sum2 != 0)\n    choice (*@$ \\overset{\\$}{\\gets} \\{A, B\\}$@*)\n    if (choice == (*@$A$@*))\n      (*@$\\forall C \\in \\mathcal{V}, move\\left(A, \\left(A, B\\right), \\left(A, C\\right) \\right)$@*) = 0\n    else # if (choice == (*@$B$@*))\n      (*@$\\forall C \\in \\mathcal{V}, move\\left(B, \\left(A, B\\right), \\left(B, C\\right) \\right)$@*) = 0\n\nresolveAllConflicts() :\n  (*@$\\forall A, B \\in \\mathcal{V}$@*)\n    resolveConflict((*@$A$@*), (*@$B$@*))\n    resolveConflict((*@$B$@*), (*@$A$@*))\n  \\end{lstlisting}\n\n  \\noindent \\texttt{resolveAllConflicts()} is executed after all players choose their moves for a round. In case of an\n  adversary, the random choice is resolved in their favor.\n  \n  \\begin{figure}[p]\n  \\label{fig:game}\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.55\\textwidth,angle=90]{game}}\n    \\caption{The general form of the game \\cite{sgtm}}\n  \\end{figure}\n  \n  Fig.~\\ref{fig:game} depicts the evolution of a two-player game. The players' choices for the first round are represented by\n  the solitary table at the top of the figure. More concretely, each distinct choice that player $A$ can make is depicted as a\n  row and likewise $B$'s choices are represented by columns. At each intersection of choices lies a subgame. The lines\n  departing from these intersections lead to the conflict resolution stage, which is decided by Nature. Depending on the\n  result of the conflict resolution, a new round begins where players can choose a new course of action. All the possible\n  states that players can be found in at the beginning of round 2 are depicted by the series of tables at the 2nd level. The\n  game evolves in a similar fashion with alternation between players' choices and Nature's conflict resolution, until players\n  can make their $R$-th choice. The keen observer can note that, instead of new departing lines, each cell of the tables of\n  the last round ($R$) contains a pair of numbers which represent the players' utilities for that outcome.\n  \n  Note that a concrete player's strategy consists of all the choices that she would make in every possible state that she can\n  find herself in. Thus, even though only $R$ choices will be made by each player, a strategy is comprised of exponentially\n  many choices. Furthermore, if we had to consider a three-player game, we would have to replace all tables with 3-dimensional\n  cubes and so on for more players.\n\n  We now move on to describe the individual games.\n", "meta": {"hexsha": "a04c6ab3ca0884d932ec4461d74d0de2c8a1fb96", "size": 8065, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "may31deliverable/gametheory/commonsetup.tex", "max_stars_repo_name": "OrfeasLitos/TrustNet", "max_stars_repo_head_hexsha": "dfd45afb78ba92d7c0b0a64222aaf173e9627c09", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2017-03-15T14:33:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T14:07:45.000Z", "max_issues_repo_path": "may31deliverable/gametheory/commonsetup.tex", "max_issues_repo_name": "OrfeasLitos/DecentralisedTrustNetwork", "max_issues_repo_head_hexsha": "dfd45afb78ba92d7c0b0a64222aaf173e9627c09", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-03-07T12:25:26.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-31T14:42:20.000Z", "max_forks_repo_path": "may31deliverable/gametheory/commonsetup.tex", "max_forks_repo_name": "OrfeasLitos/DecentralisedTrustNetwork", "max_forks_repo_head_hexsha": "dfd45afb78ba92d7c0b0a64222aaf173e9627c09", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-07T10:49:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-28T06:32:33.000Z", "avg_line_length": 72.6576576577, "max_line_length": 128, "alphanum_fraction": 0.722132672, "num_tokens": 2147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4216503624790059}}
{"text": "\n\\chapter{Conclusion and Future Work}\\label{sec:conclusion_and_future_work}\nTo conclude this work, we summarize the presented models, algorithms, implementations, studies and the main findings. Moreover, we give an outlook on future work and additional research questions that can be approached building on our work.\n\n\\section{Summary of this Work}\n\nThe overarching goal of this work was to enable simulations of the neuromuscular system using detailed, biophysical multi-scale models with high resolutions. The simulations should compute numerically accurate results, run efficiently on various hardware and allow parallel scaling to large problem sizes, which should be solved on supercomputers.\n\nAs a result, this work established a computational framework for multi-scale modeling of skeletal muscles, their neural activation, muscle contraction and generation of EMG signals on the skin surface. Our approach combined existing models for various parts of the neuromuscular system into a comprehensive multi-scale model framework. Scalability and parallel efficiency of our software were ensured by efficient algorithms, suitable, parallelized numerical schemes and by our accompanying performance analyses.\n\n% ieser Arbeit war ... biophysikalisch, hoch aufgelöst, schnell, skalierbar, genau ...\n\nWe described the following topics in this work: After the introduction in \\cref{chap:introduction}, we compared two modeling approaches to describe the movement of the upper arm in \\cref{chap:comparative_study}. Based on data of experimental trials we conducted during a graduate school workshop, we developed a first, data-driven model using Gaussian process regression and a second model based on a biophysical simulation with two muscle models. The parameters for the biophysical simulation were fitted to experimental training data using numerical optimization. The comparison of the two approaches revealed a slightly better fit for the biophysical simulation model. This approach had the additional benefit of giving biophysical insights into the functioning of the system and provided estimates for subject-specific muscle parameters. While this study used Hill-type muscle models, which describe muscle forces on a 1D line of action, we considered more accurate multi-scale models in the remainder of this work.\n\n\\Cref{sec:generation_of_meshes_for_multiscale} dealt with the generation of structured 3D meshes and embedded 1D meshes for muscle fibers. The approach of only using structured meshes, which allowed for a simple domain decomposition proved to be beneficial for the parallel performance of our simulations.  \nWe described a workflow, how to obtain these meshes from biomedical imaging data. We developed a serial algorithm and a parallel algorithm to construct the required meshes and to ensure a good mesh quality, even for meshes with high resolutions. The algorithms were based on our novel approach of using harmonic maps to transform reference meshes to cross-sectional slices of the muscle mesh.\n\nIn \\cref{sec:muscle_fibers_and_motor_units}, we described ways to associate muscle fibers with motor units (MUs) in a physiological manner. We developed efficient algorithms for this task for different premises, and employed the algorithms to associate up to \\num{270000} muscle fibers to \\num{100} MUs for the subsequent use in our simulations.\n\nIn \\cref{chap:models_and_discretization}, we first described all equations of the state-of-the models that we used, and how they can be combined into a multi-scale description. Then, we described their discretization using the finite element method for the spatial derivative terms and various timestepping and operator splitting schemes for the temporal derivatives. One original contribution is the derivation of the finite element formulation for the multidomain equation. Further, we gave a detailed description of the nonlinear solid mechanics discretization, which we used in our implementation.\n\nNext, we presented details on our simulation software OpenDiHu, which we used to solve various combinations of the described multi-scale model framework to simulate the neuromuscular system. \\Cref{chap:usage} gave an introduction to the design and usage of the software and demonstrated its application using various example problems.\n\n\\Cref{sec:implementation} described the implementation of OpenDiHu in more detail, motivated various design decisions, introduced the data handling and several algorithms, e.g., to construct a parallel domain decomposition or to map data between meshes, and described the implementation of various solvers for particular parts of the multi-scale model.\n\n\\Cref{sec:results} presented numerical results, which were obtained using our simulation software. We simulated the passive mechanical behavior of muscle tissue, subcellular models given in CellML description, electrophysiology on muscle fibers, electric conduction in the muscle and the adipose tissue to obtain surface EMG signals, electrophysiology using the 3D homogenized multidomain description, and coupled scenarios of electrophysiology and muscle contraction. We discussed effects of model and structural parameters and interpreted the obtained simulation results.\n\nIn \\cref{sec:performance_analysis}, we analyzed the computational performance of our software in general and various solvers in particular. We conducted numerical studies of universal convergence properties with the software OpenCMISS, which also helped to parameterize the numerical solvers in OpenDiHu. Further studies on mesh widths and used linear solvers were carried out directly using OpenDiHu. We evaluated various optimization options in OpenDiHu and compared the most optimized settings in OpenDiHu with the baseline solver OpenCMISS, yielding a high speedup of more than two orders of magnitude. Moreover, we investigated the computational performance of our models on the GPU, and conducted parallel strong scaling and parallel weak scaling tests on small clusters and the supercomputers at the High Performance Computing Center Stuttgart.\n\n\\section{Summary of Main Findings}\n\nThe present work simulated numerous scenarios with various model combinations, which provided different insights. In the following, we summarize the observed findings. We address the biophysical observations in \\cref{sec:observations_biophysics} and results of the performance measurements in \\cref{sec:observations_performance}.\n\n\\subsection{Observations from the Fields of Biophysics and Biomechanics}\\label{sec:observations_biophysics}\nThe comparison of the linear and nonlinear mechanics models in \\cref{sec:solver_solid_mechanics} showed qualitatively different results and demonstrated that the accurate behavior of deforming muscle tissue can only be described by a proper nonlinear anisotropic solid mechanics model. \n\nInitially, an open question was also how to relate the accuracy of the simulated EMG signals to the number of fibers and the mesh resolution. Our numerical studies in \\cref{sec:action_potential_velocity}, which compared the resulting action propagation velocity for different mesh widths of the 1D muscle fiber meshes showed that a mesh width of \\SI{100}{\\micro\\meter} or 100 elements per \\SI{}{\\centi\\meter} gives reasonably accurate results. \n\nTo evaluate the 3D mesh width and the spacing between the muscle fibers, we conducted simulations with different 3D mesh resolutions and numbers of fibers in \\cref{sec:effects_of_the_mesh_width_emg}. The number of fibers was scaled up to the realistic number of \\num{270000} fibers in a biceps brachii muscle. We concluded that the most accurate solution is obtained for a mesh width as fine as possible, as the EMG results were qualitatively different for every refinement step. This emphasizes the need for highly resolved simulation scenarios (representing the real number of fibers in a muscle accurately) for realistic EMG computations and, as a result, the need for High Performance Computing techniques.\n\nHowever, if the EMG is to be sampled by electrodes, i.e., if the EMG recording process should also be part of the simulation, lower mesh widths might be possible, as the EMG is only captured at the locations of the electrodes.\n\nOne possible approach to reduce the computational effort for EMG simulations would be to only consider the muscle tissue down to a certain depth below the surface with the EMG electrodes. We observed in \\cref{sec:simfiber_mu}, that the EMG signal is highly influenced by MUs, whose territories are located close to the electrodes. However, our numerical experiments with EMG decomposition algorithms in \\cref{sec:simfiber_decomposition} showed that large MUs located opposite to the EMG electrodes at the deepest muscle tissue layers are detectable in the surface EMG signals. Thus, neglecting the deeper parts of the muscle would remove relevant information from the system and is, therefore, not a valid approach to reduce the computational load.\n\nFurthermore, the layer of adipose tissue on top of the muscle showed a smoothing effect on EMG recordings in our simulations, both with the fiber based approach in \\cref{sec:simfiber_fat} and with the multidomain approach in \\cref{sec:multidomain_components,sec:multidomain_simulation_emg}. One advantage of our simulations compared to experimental studies is that the thickness of the fat layer is known exactly and can also be adjusted.\n\nSimulations of muscle contraction with coupled electrophysiology and solid mechanics models showed a spatially inhomogeneous contraction  for the biceps muscle while the muscle activation is ramped up. The simulation in \\cref{sec:fiber_based_contraction} of an isolated, contracting muscle belly without tendons showed transverse bending, alternating between the left and right-hand sides, as a result of the subsequently activated MUs at the different sides of the muscle. We also simulated the biceps brachii muscle together with its tendons and observed a ripple in the generated muscle force, which is caused by the same inhomogeneous MU activity.\n\nThe simulations of muscle contraction also showed that, if the muscle is initially in a stress-free state, the model can only achieve a maximum contraction of approximately \\SI{85}{\\percent}. However, the muscles of the musculoskeletal system are known to exhibit prestresses in their relaxed states. Accordingly, we added prestress to our simulations. The amount of prestress is adjustable in the simulation settings, and the required amount can be determined by a comparison with experimental studies.\n\n% linear-nonlin\n% accuracy -> high mesh resolution\n% fibers: effects of fat mesh, distance between fibers to surface, size of MUs (EMG decomposition)\n% multidomain: more smoothed\n% coupled solid mechanics: inhomogeneous contraction, prestretch required (without only 85% contraction)\n\n\\section{Summary of Performance Results}\\label{sec:observations_performance}\n\nA major part of the work was also concerned with improving the performance of the simulation software, and, thus, enabling larger simulation scenarios in shorter runtimes.\n\nPreviously, literature on biophysical, multi-scale models of skeletal muscles was mainly focused on modelling and interpretation of the results, rather than targeting efficient computations. The work of Röhrle et al. \\cite{Roehrle2012} introduced the multi-scale model, which we based our work on, and simulated the tibialis anterior muscle using a 3D mechanics mesh with 12 elements. The work of Heidlauf et al. \\cite{Heidlauf2013} considered the same geometry and simulated 400 muscle fibers. The authors parallelized their OpenCMISS based implementation for a fixed number of four processes. We built upon this work with the goal to push the limits of feasible problem sizes, and, in \\cref{sec:effects_of_the_mesh_width_emg}, executed our optimized simulation with \\num{26912} processes, \\num{273529} muscle fibers and a 3D mesh for the electrophysiology model with approximately \\num{1e8} degrees of freedom.\n\nThe performance analyzes in \\cref{sec:performance_analysis} showed that the subcellular model contributes a large portion to the total runtime and, thus, is the most crucial part to optimize. By using proper memory layouts, vectorization is possible. Our approach of using explicit vector instructions outperformed the auto-vectorization capabilities of the compiler. The approximation of the exponential function and an improved parallelization scheme for the 1D electric conduction problem additionally contributed to a high speedup. The comparison to the baseline solver OpenCMISS Iron in a strong scaling study in \\cref{sec:strong_scaling_runtimes_opencmiss_opendihu} revealed a maximum speedup of 363 for the purely implementation-specific improvements and an additional speedup of 2.5, shown in \\cref{sec:opencmiss_numeric_improvements}, by using more efficient numerical methods.\n\nIn addition, the memory characteristics of the solvers were investigated in \\cref{sec:strong_scaling_runtimes_opencmiss_opendihu}. \nThe linear increase in memory consumption of the baseline solver in a weak scaling setting was improved to a nearly constant scaling. Our analysis using a roofline performance model showed that our solvers are compute bound and achieve a computational performance of approximately \\SI{25}{\\percent} peak performance, which is a very good value.\n\nMoreover, hybrid shared/distributed memory parallelism and computations on the GPU were investigated, but both approaches were found to be not competitive with our highly optimized distributed memory parallelization. For the GPU, potentially more efficient approaches than our approach using OpenMP exist, such that a performance improvement in the future could be possible.\n\nThe modularity of the CellML infrastructure, where computational models can be shared among researchers and are interchangeable in multi-scale simulations was preserved during all optimization endeavors. Our approach was to implement a source-to-source code generator, which transformed the given CellML code into optimized code for the CPU or the GPU.\n\nFor the solution of the multidomain model, we evaluated various preconditioners and selected the most performant preconditioner-solver combination for our computations.\nOne previously unforeseen result is the large discrepancy of required runtime between the fiber based and the multidomain based electrophysiology models, presented in \\cref{sec:solver_multidomain_model}. We measured by a factor of 1000 longer computation times for the multidomain model, which result from the structure of the model. Despite the high computational effort, the multidomain model is useful in practice as it can simulate effects that are not captured by the fiber based model. We gave a detailed comparison between both approaches in \\cref{sec:multidomain_differences}.\n\nIn summary, we provided a computationally efficient and scalable tool for applied biophysics researchers to solve problems in the domains of EMG generation and muscle contraction. For example, the effect of different muscle fiber organizations and MU recruitment strategies can be tested with our software. We demonstrated its use with state-of-the-art EMG decomposition algorithms, which provide the bridge to the experimental domain.\nThus, we hope to contribute one step on the pathway of complementing in vivo with in silico experiments to increase the understanding of the neuromuscular system.\n\n% provide a tool for applied biophysics researchers\n% --------------------\n% complement in-vivo and in-silico experiments\n% test different muscle fiber organizations -> possible\n% decomposition of EMG -> tested\n\n\n% vc better than auto-vec, AVX-512, memory layout\n% comparison to OpenCMISS\n% preserve CellML modularity -> code generator\n% GPU, OpenMP\n% proper choice of solvers\n% multidomain performance vs fibers\n\n\n% performance\n% --------------\n% Röhrle2012: TA 12 elements, MU association\n% Heidlauf2013: 400 fibers, TA, OpenCMISS, mechanics\n% made new insights possible  \n\n\n%wir hatten ja mal vorgenommen dass\n%tatsächlich ist gelungen:\n%überraschenderweise, dass: \n\n%bewerten mit den Ergebnissen\n%was bewahrheitet, \n\n%unterschiede zwischen grob und hochaufgelöster Sim\n%anzahl realitäts anzahl Muskelfaser anzahl\n\n\\section{Outlook and Future Work}\\label{sec:future_work}\n \nThe presented work could be extended in multiple directions, spanning performance improvements and model extensions.\n\nFirst, some ideas for further performance improvements could be implemented and evaluated. \nThe monodomain equation could be solved with implicit-explicit (IMEX) schemes, which could potentially achieve higher precision. \nThe numerically stiff subcellular model is currently solved explicitly. Implicit schemes could be developed, and the implicit iteration equations could be solved symbolically in a preprocessing step using the parsed CellML code. \n\nTo improve the performance of the multidomain model, the following algorithmic improvements are promising options. \nThe 3D problems of action potential propagation in the muscle volume for every compartment could be restricted to the subset of nodes, where the occupancy factors are above a certain threshold, effectively reducing the problem sizes, and reducing the effect of higher MU counts on the runtime. However, this would bring difficulties to ensure a balanced parallel domain decomposition.\nInstead of the current parallel partitioning of the domain, the multidomain model could also be parallelized by distributing the MUs to different processes or by a combination of both approaches.\n\nOn the numerical side, an extended error analysis could be carried out for all model parts, and the timestep widths, which are currently chosen conservatively, could potentially be increased, while keeping the numerical error below a given threshold. Error estimators could be developed, which would allow an adaptive adjustment of the timestep widths.\nThe 3D model solvers for the 3D electrophysiology and multidomain problems could be enhanced with geometric or algebraic multigrid preconditioners.\n\nSince all subcellular points in a muscle are usually in similar states at any time, a hybrid approach using analytic descriptions of action potential propagation, as in \\cref{sec:sim_rosenfalck}, and a fully numerical treatment could be chosen, and surrogate models could be adaptively added to the computational description.\n\nOn the technical side, computations on the GPU could be re-evaluated in the future using the existing OpenMP approach with more mature compiler versions or different accelerator targeting programming technologies.\n\nSecond, the range of simulated models could be extended. The simulations could be applied to further muscle geometries such as the triceps brachii or the tibialis anterior muscles. Muscles with more complex geometries and fiber arrangements could be investigated. \nA mechanically coupled problem of agonist-antagonist pair could be considered such as a system of biceps and triceps brachii. Apart from the mechanical coupling, a coupling of the neural recruitment involving sensory organs in the muscles could be implemented and used to approach further biomechanical research questions. Such a neuromuscular feedback loop could also be investigated first for a single muscle, e.g., by extending the preliminary implementation in OpenDiHu for the biceps muscle.\n\nPathological conditions could be simulated to understand muscular diseases and neuromuscular electrical stimulation of the muscle for stroke rehabilitation could be considered.\n\nBy using the preCICE adapters in OpenDiHu, more advanced mechanics solvers could be coupled to an electrophysiology simulation in OpenDiHu, allowing to, e.g., study mechanical effects of surrounding tissue.\n\nOn a larger scale, the interplay of more organs could be taken into account. Blood perfusion and muscle metabolism could be added, and coupled by models of the lung and general metabolism in the organism. Thus, a digital human model can be envisioned, which allows to study the effects of anomalies and to develop new therapies, effectively utilizing simulation technology for human wellbeing.\n\n%reduced to 1D problems using appropriate transformations.\n\n\n% performance improvements\n% ----------------------------\n% more timestepping methods: CVODE (https://computing.llnl.gov/projects/sundials/cvode), imex\n% different parallelisation where not all ranks have to be involved (for multidomain) -> this feature already exists for the fibers with multipleInstances\n% more numeric tests on exp function? no\n% multidomain: compute 3D problem as 1D problem, or adaptive computation of the parts of the fr factors\n% GPU\n\n% extensions\n% -------------\n% other muscles, more muscles,\n% couple more models:\n% neuromuscular feedback loop with sensors, \n% \n\n\n\n\n\n\n", "meta": {"hexsha": "8258cab2d423f2ba103b5c69b905f376438b8f3b", "size": 20880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "document/09_conclusion.tex", "max_stars_repo_name": "maierbn/phd_thesis_source", "max_stars_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-05T19:00:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-05T19:00:04.000Z", "max_issues_repo_path": "document/09_conclusion.tex", "max_issues_repo_name": "maierbn/phd_thesis_source", "max_issues_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "document/09_conclusion.tex", "max_forks_repo_name": "maierbn/phd_thesis_source", "max_forks_repo_head_hexsha": "babee64f01f15d93cb75140eb8c8424883b33c6c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 129.6894409938, "max_line_length": 1019, "alphanum_fraction": 0.8239463602, "num_tokens": 4133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.421650355002896}}
{"text": "\\chapter{Work and Energy}\n\nIn this chapter, we are going to talk about how engineers define work\nand energy.  We have already talked about force. Force is measured in\nnewtons, and one newton is equal to the force necessary to accelerate one\nkilogram at a rate of $1 m/s^2$.\n\nWhen you lean on a wall, you are exerting a force on the wall, but you\naren't doing any work. On the other hand, if you push a car for a mile,\nyou are clearly doing work. Work, to an engineer, is the force you\napply to something, as well as the distance that it moves, in the direction\nof the applied force. We measure work in \\textit{joules}. A joule is one\nnewton of force over one meter.\n\n\\includegraphics[width=0.8\\textwidth]{Work_vs.png}\n\nFor example, if you push a car uphill with a force of 10 newtons for 12\nmeters, you have done 120 joules of work.\\index{work}\n% ADD: We can represent this with the equations, Work Energy Therom\n\nWork is how energy is transferred from one thing to another. When you\npush the car, you also burn sugars(energy of the body) in your blood. That energy is then\ntransferred to the car: after it has been pushed uphill.\n\nThus, we measure the energy something consumes or generates in \nunits of work: joules, kilowatt-hours, horsepower-hours, foot-pounds,\nBTUs( British Thermal Unit), and calories.\n\nLet's go over a few different forms that energy can take.\n% KA: https://www.khanacademy.org/science/ms-physics/x1baed5db7c1bb50b:energy/x1baed5db7c1bb50b:changes-in-energy/a/changes-in-energy\n\\section{Heat}\\index{heat}\n\nWhen you heat something, you are transferring energy to it. The BTU\n is a common unit for heat: One BTU is the\namount of heat required to raise the temperature of one pound of water,\nby one degree. One BTU is about 1,055 joules. In fact, when you buy and sell\nnatural gas as fuel, it is priced by the BTU.\\index{heat} \\index{BTU}\n\n\\section{Electricity}\\index{electricity}\n\nElectricity is the movement of electrons. When you push electrons\nthrough a space that resists their passage (like a light bulb),\nenergy is transferred from the power source ( a battery)\n into the source of the resistance.\n\nLet's say your lightbulb consumes 60 watts of electricity, and you leave it on for 24 hours.\nWe would say that you have consumed 1.44 kilowatt hours or 3,600,000 joules.\n\n% KA: https://www.khanacademy.org/science/in-in-class10th-physics/in-in-electricity/in-in-electric-current-circuit/v/intro-to-charge\n\n\\section{Chemical Energy}\\index{chemical energy}\n\nAs mentioned early, some chemical reactions consume energy and some\nproduce energy. Thus, energy can be stored in the structure of a\nmolecule. When a plant uses photosynthesis to rearrange water and\ncarbon dioxide into a sugar molecule, it converts the energy in\nthe sunlight( solar energy) into chemical energy. Remember photosythesis is a process that releases energy.\nTherefore, the sugar molecule has more chemical energy than the carbon dioxide and water molecules that were\nused in its creation.\n% ADD: photosythesis equation \n% KA: https://www.khanacademy.org/science/ap-biology/cellular-energetics/photosynthesis/a/intro-to-photosynthesis\n\nIn our diet, we measure this energy in \\textit{kilocalories}. A\ncalorie is the energy necessary to raise one gram of water one degree\nCelsius: it is about 4.19 joules. This is a very small unit: an apple\nhas about 100,000 calories( 100 kilocalories), so people working with food started\nmeasuring everything in kilocalories.\\index{calories}\n% ADD: Conversion chapter should come before this chapter\n\nHere is where things get confusing: People who work with food got tired of\nsaying ``kilocalories'', so they just started using ``Calorie'' to\nmean 1,000 calories.  This has created terrible confusion over the\nyears. So if the C is capitalized, ``Calorie'' probably means kilocalorie.\n\n\\section{Kinetic Energy}\\index{kinetic energy}\n\nA mass in motion has energy. For example, if you are in a moving car\nand you slam on the breaks, the energy from the motion of the\ncar will be converted into heat in the breaks and under the tires.\n\nHow much energy does the car have?\n% ADD: section specifically about KE AND U, use roller coaster diagram\n\n\\begin{mdframed}[style=important, frametitle={Formula for Kinetic Energy}]\n\n$$E = \\frac{1}{2} m v^2$$\n\nwhere $E$ is the energy in joules, $m$ is the mass in kilograms, and\n$v$ is the speed in meters per second.\n\n\\end{mdframed}\n\n\\section{Gravitational Potential Energy}\\index{potential energy!gravitational}\n% KA: https://youtu.be/oGzwVYPxKjg\n\nWhen you lift something heavy onto a shelf, you are giving it\n\\textit{potential energy}. The amount of energy that you transferred\nto it is proportional to its weight and the height that you lifted it.\n\nOn the surface of the earth, gravity will accelerate a heavy object downward at\na rate of $9.8 m/s^2$.\n\n\\begin{mdframed}[style=important, frametitle={Formula for Gravitational Potential Energy}]\nOn earth, then, gravitational potential energy is given by\n\n$$E = (9.8)mh$$\n\n\nwhere $E$ is the energy in joules, $m$ is the mass of the object you\nlifted, and $h$ is the height that you lifted it.\n\n\\end{mdframed}\n\n\nThere are other kinds of potential energy. For example, when you draw\na bow, you have given that bow potential energy. When you release it,\nthe potential energy is transferred to the arrow, which expresses it\nas kinetic energy.\n% ADD: section about KE and U\n\n\\section{Conservation of Energy}\n\nThe first law of thermodynamics says ``Energy is neither created nor\ndestroyed.''\\index{energy!conservation of}\n\nEnergy can change forms: Your cells consume chemical energy to give\ngravitational potential energy to a car you push up a hill. However, the total amount of\nenergy in a closed system stays constant.\n% ADD: Create Systems chapter before introducing concept here\n\n\\begin{Exercise}[title={The Energy of Falling}, label=energy_falling]\n  \nA 5 kg cannonball falls off the top of a 3 meter ladder. Just before\nit hits the floor, all of its gravitational potential energy has been\nconverted into kinetic energy.  How fast is the cannonball going when\nit hits the floor?\n\n\\end{Exercise}\n\\begin{Answer}[ref=energy_falling]\n\n  At the top of the ladder, the cannonball has $(9.8)(5)(3) = 147$ joules of potential energy.\n\n  At the bottom, the kinetic energy $\\frac{1}{2}(5)v^2$ must be equal\n  to 147 joules. So $v^2 = \\frac{294}{5}$.  Thus it is going about\n  $7.7$ meters per second.\n\n  (Yes, a tiny amount of energy is lost to air resistance. For a dense\n  object moving at these relatively slow speeds, this energy is\n  neglible.)\n  \n\\end{Answer}\n\n\n\\section{Efficiency}\n% KA: https://www.khanacademy.org/science/ap-biology/cellular-energetics/cellular-energy/a/the-laws-of-thermodynamics\n\nAlthough energy is always conserved as it moves through different\nforms, scientists aren't always that good at controlling it.\\index{efficiency}\n\nFor example, a car engine consumes the chemical energy in gasoline. Only\nabout 20\\% of the energy consumed is used to turn the wheels.  Most of\nthe energy is actually lost as heat. If you run a car for a while, the engine\ngets very hot and the exhaust going out the tailpipe turns hot.\n\nA human is about 25\\% efficient. Most of the loss is in the heat produced\nduring the chemical reactions that turns food into motion.\n% ADD: Cellular Respiration\n \nIn general, if you are trying to increase efficiency in any system,\nthe solution is usually easy to identify because heat is produced. Reduce heat, Increase efficiency.\n\nLight bulbs are an interesting case. To get the light of a 60 watt\nincandescent bulb, you can use an 8 watt LED or a 16 watt fluorescent\nlight. Thus, we say that the LED light is much more efficient: If you\nrun both, the incandescent bulb will consume 1.44 kilowatt-hours. The\nLED will consume only 0.192 kilowatt-hours.\n\nBesides light, the incandescent bulb is producing a lot of heat. If it\nis inside your house, what happens to the heat? It warms your house.\n\nIn the winter, when you want light and heat, the incandescent bulb is\n100\\% efficient!\n\nIn the summer, if you are running the air conditioner, the\nincandescent bulb is worse than just ``inefficient at making light'' --\nit is actually counteracting the air conditioner! \n\n", "meta": {"hexsha": "b706310d2502ac2cc15fdb65534223c1cc5db9ab", "size": 8213, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Modules/MatterEnergy/work_energy-en_US.tex", "max_stars_repo_name": "hillegass/sequence", "max_stars_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-06-13T17:19:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-05T00:43:44.000Z", "max_issues_repo_path": "Modules/MatterEnergy/work_energy-en_US.tex", "max_issues_repo_name": "hillegass/sequence", "max_issues_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Modules/MatterEnergy/work_energy-en_US.tex", "max_forks_repo_name": "hillegass/sequence", "max_forks_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-05T00:43:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-05T00:43:58.000Z", "avg_line_length": 43.6861702128, "max_line_length": 133, "alphanum_fraction": 0.7752343845, "num_tokens": 2089, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.421650355002896}}
{"text": "\\documentclass[11pt,draft]{article}\n%\n\\author{Anne}\n\\usepackage{basic}\n\\newcommand*\\circled[1]{\\tikz[baseline=(char.base)]{\n   \\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}\n%\n\\begin{document}\n%\n\n\\section*{Kamnitzer--Knutson--Mirkovic Conjecture}\n\nZhijie asks about the following example. \n\nIn $A_3$ ($G=\\PGL_4$) fix the usual reduced expression $\\uvi = (1,2,3,1,2,1)$ and consider the Lusztig datum $n_\\bullet = (1,1,0,0,1,1)$. \n\nThe smallest $\\lambda$ and $\\mu$ for the associated stable MV cycle satisfying Proposition XYZ in Section 2.2 of my thesis are \n\\[\n\\lambda = (5,3,2,0) \\qquad \\mu = (3,3,2,2)    \n\\]\nand the associated tableau is\n\\[\n\\young(11123,224,34)    \n\\] \nBy applying Conjecture 4.6.2 of my thesis we can say what the free entries in each column of a matrix $A$ in the MVy slice to $\\OO_\\lambda$ associated to this tableau.\nLet us fix notation for the coordinates of $A$.\n\\[\nA = \\left[\\begin{BMAT}(e){ccc:ccc:cc:cc}{ccc:ccc:cc:cc}\n    0&1&0&0&0&0&0&0&0&0\\\\\n      0&0&1&0&0&0&0&0&0&0\\\\\n      0&0&0&0&0& \\circled{${c}_{1}$} &0&\\circled{${b}_{2}$}&\\circled{${a}_{3}$}&\\circled{${b}_{3}$}\\\\\n      0&0&0&0&1&0&0&0&0&0\\\\\n      0&0&0&0&0&1&0&0&0&0\\\\\n      0&0&0&0&0&0&0&\\circled{${b}_{4}$}&{a}_{5}&\\circled{${b}_{5}$}\\\\\n      0&0&0&0&0&0&0&1&0&0\\\\\n      0&0&0&0&0&0&0&0&0&{b}_{6}\\\\\n      0&0&0&0&0&0&0&0&0&1\\\\\n      0&0&0&0&0&0&0&0&0&0\n\\end{BMAT}\\right]\n\\]\nOur conjecture tells us that the circled entries will be the free entries, i.e. the nonzero variable entries. We went ahead and used this information to deduce and omit the entries that must be zero.\n\nWith the help of \\texttt{M2} and speeding things up by substituting the first six prime numbers for the circled entries we find that the ideal of $X_\\tau$ is\n\\[\nI = \\left({b}_{1},{a}_{6},{a}_{4},{a}_{2},{a}_{1},-{a}_{5}{b}_{2}+{a}_{3}{b}_{4},{b}_{2}{b}_{6}+{a}_{3},{b}_{4}{b}_{6}+{a}_{5}\\right) \n\\]\nin $R = \\CC[a_1,\\dots,a_6,b_1,\\dots,b_6,c_1]$.\n% \n% [a_1,b_1,c_1,a_2,b_2,a_3,b_3,a_4,b_4,a_5,b_5,a_6,b_6,Degrees=>{{1,0,0,0},{1,0,0,1},{1,0,0,2},{1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1},{0,1,0,0},{0,1,0,1},{0,1,1,0},{0,1,1,1},{0,0,1,0},{0,0,1,1}}]\n\nWe compute its multidegree\n\\[\n\\mdeg I = \\left({\\alpha}_{2}+{\\alpha}_{1}\\right)\\left({\\alpha}_{2}+{\\alpha}_{3}\\right)\\left({\\alpha}_{2}+{\\alpha}_{3}+{\\alpha}_{1}\\right)\\left(\\hbar+{\\alpha}_{1}\\right)\\left({\\alpha}_{1}{\\alpha}_{2}{\\alpha}_{3}\\right)    \n\\]\nand Hilbert series \n{\\scriptsize\n\\[\n    \\ch I=\\frac{1}{\\left(1-e^{\\alpha_1 + \\alpha_2 + \\alpha_3 + \\hbar}\\right)\\left(1-e^{\\alpha_1 + \\alpha_2 + \\hbar}\\right)\\left(1-e^{\\alpha_2 + \\alpha_3 + \\hbar}\\right)\\left(1-e^{\\alpha_1 + 2\\hbar}\\right)\\left(1-e^{\\alpha_3 + \\hbar}\\right)\\left(1-e^{\\alpha_2 + \\hbar}\\right)} \n\\]}\n\nNow Zhijie would like to know what the Plucker coordinates are. \n% He asks ``What are the $a,b,c$ in terms of $\\Delta_{C \\in \\binom {16} 8}$''\n\nIn my thesis I claim that the Plucker embedding is given by the minors $\\Delta_C B$ of a certain matrix $B$ using columns $C\\in\\binom{S}{mp-N}$. Here\n$m = 4$, $p = 5$, $N = 10$, and \n$$\nS = ((k,0),(k,1),(k,2),(k,3),(k,4))_{k=1}^4\n$$\nRecall $mp-N = \\dim L/t^pL_0$ and $S$ indexes the basis $v_{(i,j)} = [e_it^j]$ of $V = L_0/t^pL_0$. The matrix $B$ is the matrix whose row vectors are the basis vectors  \n\\[\n[ge_1],[tge_1],[ge_2],[tge_2],[ge_3],[tge_3],[t^2ge_3],[ge_4],[tge_4],[t^2ge_4]\n\\] \nof $L/t^pL_0\\subset L_0/t^pL_0$.\n\nIn this case \n\\[\ng = g_A = \\begin{bmatrix}\n    t^3 \\\\\n    -c_1t^2 & t^3 \\\\\n    -b_2t & -b_4 t & t^2 \\\\\n    -a_3 - b_3 t & - a_5 - b_5 t & -b_6 t & t^2 \n\\end{bmatrix}    \n\\]\nso \n\\begin{align*}\n    [ge_1] &= [t^3 e_1] -c_1[t^2 e_2] -b_2[te_3] - a_3[e_4] - b_3[te_4] \\\\\n    [tge_1] &= {[t^4 e_1]} -c_1[t^3 e_2] -b_2 [t^2 e_3] - a_3 [te_4] - b_3 [t^2 e_4] \\\\\n    [ge_2] &= [t^3 e_2] - b_4 [te_3] -a_5[e_4] - b_5[t e_4] \\\\\n    [tge_2] &= {[t^4 e_2]} - b_4 [t^2e_3] - a_5 [te_4] - b_5 [t^2 e_4] \\\\\n    [ge_3] &= [t^2 e_3] -b_6 [te_4] \\\\\n    [tge_3] &= {[t^3e_3]} - b_6 [t^2 e_4] \\\\\n    [t^2 ge_3] &= [t^4e_3] - b_6 [t^3 e_4]\\\\\n    [ge_4] &= [t^2 e_4] \\\\\n    [tge_4] &= [t^3 e_4] \\\\\n    [t^2 ge_4] &= [t^4 e_4]\n\\end{align*}\nand, omitting zero columns, we get \n\\hfill\n\n{\n\\hspace{-4cm}\\begin{minipage}{1.5\\textwidth}\n\\[\n\\bordermatrix{ & [t^3e_1] & [t^4e_1]  & [t^2e_2] & [t^3e_2] & [t^4 e_2] & [te_3] & [t^2e_3] & [t^3e_3] & [t^4e_3] & [e_4] & [te_4] & [t^2e_4] & [t^3e_4] & [t^4e_4] \\cr\n[ge_1]         & 1       &  & -c_1     &         & & -b_2   &          &          & & -a_3  & -b_3                                    \\cr\n[tge_1]        &         & 1  &          & -c_1  &   &        & -b_2     &         & &       & -a_3   & -b_3                           \\cr \n[ge_2]         &         &  &          & 1       & & -b_4   &          &          & & -a_5  & -b_5                                    \\cr\n[tge_2]        &         &  &          &         & 1 &        & -b_4     &          & &      & -a_5  & -b_5                            \\cr\n[ge_3]         &         &  &          &         & &        &           1 &    &    &   & -b_6                                    \\cr\n[tge_3]        &         &  &          &         & &        &          &           1 & &  &       & -b_6                            \\cr\n{[t^2 ge_3] }    &         &  &          &         & &        &          &  & 1             & &       & & -b_6                          \\cr\n[ge_4]         &         &  &          &         & &        &          &          &      & &       & 1 &                             \\cr\n[tge_4]        &         &  &          &         & &        &          &          &      & &       &       & 1                       \\cr \n[t^2 ge_4]     &         &  &          &         & &        &          &          &      & &       &       &       & 1  \n}\n\\]\n    \\end{minipage}\n}\nfor $B$ so $C_0 = \\{(1,3),(1,4),(2,3),(2,4),(3,2),(3,3),(3,4),(4,2),(4,3),(4,4)\\}$. \n\n% for m2 \n% matrix{\n    % {1,0,-c_1,0,0,-b_2,0,0,0,-a_3,-b_3,0,0,0},\n    % {0,1,0,-c_1,0,0,-b_2,0,0,0,-a_3,-b_3,0,0},\n    % {0,0,0,1,0,-b_4,0,0,0,-a_5,-b_5,0,0,0},\n    % {0,0,0,0,1,0,-b_4,0,0,0,-a_5,-b_5,0,0},\n    % {0,0,0,0,0,0,1,0,0,0,-b_6,0,0,0},\n    % {0,0,0,0,0,0,0,1,0,0,0,-b_6,0,0},\n    % {0,0,0,0,0,0,0,1,0,0,0,0,-b_6,0},\n    % {0,0,0,0,0,0,0,0,0,0,0,1,0,0},\n    % {0,0,0,0,0,0,0,0,0,0,0,0,1,0},\n    % {0,0,0,0,0,0,0,0,0,0,0,0,0,1}\n    % }\n\n\\section*{Finding Plucker coordinates in M2}\n\n\\begin{lstlisting}[language=Python]\nR = QQ[a_1,b_1,c_1,a_2,b_2,a_3,b_3,a_4,b_4,a_5,b_5,a_6,b_6,Degrees=>{{1,0,0,0},{1,0,0,1},{1,0,0,2},{1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1},{0,1,0,0},{0,1,0,1},{0,1,1,0},{0,1,1,1},{0,0,1,0},{0,0,1,1}}]\n\nJ = ideal(b_1,a_6,a_4,a_2,a_1,-a_5*b_2+a_3*b_4,b_2*b_6+a_3,b_4*b_6+a_5)\n\nplm = matrix{{1,0,-c_1,0,0,-b_2,0,0,0,-a_3,-b_3,0,0,0}, {0,1,0,-c_1,0,0,-b_2,0,0,0,-a_3,-b_3,0,0},{0,0,0,1,0,-b_4,0,0,0,-a_5,-b_5,0,0,0},{0,0,0,0,1,0,-b_4,0,0,0,-a_5,-b_5,0,0},{0,0,0,0,0,0,1,0,0,0,-b_6,0,0,0},{0,0,0,0,0,0,0,1,0,0,0,-b_6,0,0},{0,0,0,0,0,0,0,0,1,0,0,0,-b_6,0},{0,0,0,0,0,0,0,0,0,0,0,1,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,1,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,1}}\n\ns = subsets(14,10);\n\ne0 = {0..9}\n\nmins := {}\n\nfor e in s do if ( det(plm^e0_e) != 0 ) then mins = append(mins,det(plm^e0_e))\n\ninds := {}\n\nfor e in s do if ( det(plm^e0_e) != 0 ) then inds = append(inds,e)\n\n% check that #inds == #mins\n\nwts := {} \n\nfor e in s do if ( det(plm^e0_e) != 0 ) then wts = append(wts,degree(det(plm^e0_e)))\n\npluck = QQ[apply(inds,i->p_i)]\n\nf = map(R,pluck,mins)\n\nQ = R/J\n\nfbar = map(Q,pluck,mins)\n\nK = kernel fbar\n\nKh = homogenize(K,p_{0,1,3,4,6,7,8,11,12,13})\n\nindsnu := {}\n\nfor i in 0..#wts-1 do if take(wts#i,3)=={1,1,1} then indsnu = append(indsnu,inds#i)\n\nI = ideal(apply(indsnu,i->p_i))\n\nKnu = K + I\n\ndim Knu\n\nKnuh = homogenize(Knu,p_{0,1,3,4,6,7,8,11,12,13})\n\ndim Knuh\n\n% check that dim Kh = 7 = dim J + 1 \n\\end{lstlisting}\n% \n\\section*{Fixed point subscheme}\n% \nIn this case I would like the fixed point subscheme supported at $t^{(4,3,2,1)}$.\n% \n\nLet $\\nu = (4,3,2,1)$ and note that $\\lambda\\ge \\nu\\ge \\mu$.\n\n\\begin{enumerate}\n    \\item Take a/the chart containing the fixed point $t^\\nu$ by asking that $\\Delta_C\\ne 0$ \n    for any $C$ such that $\\wt (\\Delta_C) = \\nu$. This amounts to dehomogenizing \n    (e.g. setting equal to 1) \\textit{all?} such $\\Delta_C$. I think this is tantamount to not homogenizing in the first place. \n    \\item Mod out by the generators of $K$ whose weight is not equal to $\\lambda - \\nu$. \n\\end{enumerate}\n%\nWhere\n\n{\\scriptsize\n$({p}_{\\left\\{4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}-1,{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}^{2}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}})$}\n\n$\\left({p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}-1,{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}\\right)$\n\n$\\left({p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},-{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}-1\\right)$\n\n$\\left({p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}-1,{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},-{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},-{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}}^{2}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}}\\right)$\n\n$\\left({p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,5,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,6,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,7,\\,8,\\,9,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,4,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,3,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,5,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,6,\\,7,\\,8,\\,10,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,4,\\,6,\\,7,\\,8,\\,9,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{0,\\,1,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}-1,{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},{p}_{\\left\\{1,\\,2,\\,3,\\,4,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}+{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}},-{p}_{\\left\\{0,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}^{2}+{p}_{\\left\\{0,\\,1,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}{p}_{\\left\\{2,\\,3,\\,4,\\,5,\\,6,\\,7,\\,8,\\,11,\\,12,\\,13\\right\\}}\\right)$\n\n\\section*{Do Zhijie's smaller example}\nto make sure...\n\n\\end{document}", "meta": {"hexsha": "e3162bcd435bbf4a62598c66401cb2c3ce541069", "size": 54550, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "zhijie.tex", "max_stars_repo_name": "annedranowski/mixed-nuts", "max_stars_repo_head_hexsha": "dcda838b1be113117b234a29580c563903fcf13e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "zhijie.tex", "max_issues_repo_name": "annedranowski/mixed-nuts", "max_issues_repo_head_hexsha": "dcda838b1be113117b234a29580c563903fcf13e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "zhijie.tex", "max_forks_repo_name": "annedranowski/mixed-nuts", "max_forks_repo_head_hexsha": "dcda838b1be113117b234a29580c563903fcf13e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 247.9545454545, "max_line_length": 31400, "alphanum_fraction": 0.4120256645, "num_tokens": 32872, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.421650355002896}}
{"text": "\\subsection{PV Diagrams}\nLike all things in physics, physicists really enjoy graphing thermodynamic processes. Their particular favorite is the PV graph, putting pressure on the y-axis and volume on the x-axis; from the ideal gas law, you may see why this is a natural choice of axes. Shown below is a PV graph of a thermodynamic process that takes the gas from starting temperature $T_1$ (at pressure $P_1$ and volume $V_1$) to temperature $T_2$ (at pressure $P_2$ and volume $V_2$). Of course, there's nothing stopping us from assigning numbers to $P,T,V$, as well, if the situation calls for it. The process pictured below is an expansion of the gas, but we could also very well draw the arrow the other way and depict a compression of the gas. \n\\begin{center}\n\\begin{tikzpicture}\n \\draw[stealth-stealth] (0,5) node[below left]{$P$} |- (5,0) node[below left]{$V$};\n \\draw[thick,->] (1,4) -- (2.5,2.5);\n\\draw[thick] (2.5,2.5) -- (4,1);\n\\draw[dashed] (4,0) -- (4,1);\n\\draw[dashed] (1,0) -- (1,4);\n\\draw[dashed] (4,1) -- (0,1);\n\\draw[dashed] (1,4) -- (0,4);\n\\filldraw (1,4) circle (2pt);\n\\filldraw (4,1) circle (2pt);\n\\node[below] at (1,0) {$V_1$};\n\\node[below] at (4,0) {$V_2$};\n\\node[left] at (0,1) {$P_2$};\n\\node[left] at (0,4) {$P_1$};\n\\node[right] at (1,4) {$T_1$};\n\\node[right] at (4,1) {$T_2$};\n \\end{tikzpicture}\n \\end{center}\n To get a feel for these kinds of graphs, I would suggest trying to make some. Write down an initial state and final state for your gas with one or two quantities remaining constant, and try to figure out what the graph between those two steps would look like. For example, if I had\n\\begin{itemize}\n    \\item Initial State: P = 10kPa, V = 1m$^3$, N = 10molecules, T = 300K\n    \\item Final State: P = 5kPa, V = 2$m^3$, N = 10molecules, T = 300K\n\\end{itemize}\nWhat would the graph between the two states look like if temperature and number of molecules were held constant the entire time? (Hint: You might be first inclined to think it looks like a diagonal line like the diagram above, but this isn't quite correct; think about why the condition of temperature being held constant for the entire time might not hold in this case). The answer will be revealed very shortly, when we discuss the PV diagrams of the 4 basic thermodynamic processes! \\\\\nBefore we go there though, there is one very useful connection between PV diagrams and work that I would like to point out. In the previous section, we defined the work done on the gas as:\n\\[ W = -\\int_{V_1}^{V_2} P(V)dV \\]\nAnd looking at the PV diagram, it now becomes clear that this is nothing more than the (negative) area under the PV curve! As an example, let's figure out the work done on the gas in the process shown above. All we have to do is calculate the area underneath the curve. For convenience, let us split it into two parts of the triangle and the rectangle. For the triangle, we have area $\\frac{1}{2}*\\left(P_1-P_2\\right)*\\left(V_2-V_1\\right)$, and for the rectangle, we have area $P_2*\\left(V_2-V_1\\right)$. Therefore, the total area under the graph is:\n\\[ \\text{Area } = \\frac{1}{2}*\\left(P_1-P_2\\right)*\\left(V_2-V_1\\right) + P_2*\\left(V_2-V_1\\right) = \\frac{1}{2}\\left[\\left(P_1+P_2\\right)\\left(V_2-V_1\\right) \\right]\\]\nThis area is in fact the work done \\textbf{by} the gas, and the work done on the gas is just its negative:\n\\[W_{on} = \\frac{1}{2}\\left[\\left(P_1+P_2\\right)\\left(V_1-V_2\\right) \\right]\\]\nWhen using this area argument, do be careful of which direction the curve is going; for example, if the process was a compression of the gas rather than an expansion, we would have to introduce a negative sign as things would be going in the opposite direction. \n", "meta": {"hexsha": "0f21aa09f6a9316bab1c53d006278c2603a02c66", "size": 3675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "OneLaw/pvdiagram.tex", "max_stars_repo_name": "RioWeil/SCIE001-thermo-notes", "max_stars_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "OneLaw/pvdiagram.tex", "max_issues_repo_name": "RioWeil/SCIE001-thermo-notes", "max_issues_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "OneLaw/pvdiagram.tex", "max_forks_repo_name": "RioWeil/SCIE001-thermo-notes", "max_forks_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-30T05:36:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-30T05:36:50.000Z", "avg_line_length": 105.0, "max_line_length": 723, "alphanum_fraction": 0.7205442177, "num_tokens": 1133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.421650344954702}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{mathtools}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\degrees}{^{\\circ}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 74, Week 6}\n\\maketitle\n\n\\section{Mon Lec, 1a}\nBase case: $n=1, n=2, a_1=3, a_2=5$, base cases hold.\n\\newline\nAssume that for some $n \\in \\N$, all $m \\in \\N 1, 1 \\leq m \\leq n$ satisfies this identity, we have\n$$a_{n+1}=3a_n-2a_{n-1}=3(2^n+1)-2(2^{n-1}+1)=3\\times 2^n+3-2\\times 2^{n-1}-2$$\n$$=2^{n-1}(6-2)+1=2^{n-1}(2^2)+1=2^{n+1}+1$$\nThus we have proven the inductive case. Q.E.D.\n\n\\section{Mon Lec, 3c}\nLemma: a sequence given by $f_n=1/\\sqrt5 (\\phi^{n} - \\bar \\phi^{n})$ where $\\phi = (1+\\sqrt5)/2, \\bar \\phi = (1-\\sqrt5)/2$ has the property $f_n+f_n+1 = f_n+2$ for $n \\geq 0$\n\\newline\nBase case: $n = 0$, $f_0 = 0, f_1=1, f_2=1$, base case holds.\nAssume that for some $n$, the statement hodls for all $m\\leq n$.\n\\newline\nConsider $f_{n+1}$, $$f_n = \\frac{1}{\\sqrt5}((\\frac{1+\\sqrt5}{2})^n-(\\frac{1-\\sqrt5}{2})^n)$$\nWe get use this property to get a similar result for $f_{n-1}$. Now we add them together:\n$$f_n+f_{n-1}=\\frac{1}{\\sqrt5}((\\frac{1+\\sqrt5}{2})^n-(\\frac{1-\\sqrt5}{2})^n+(\\frac{1+\\sqrt5}{2})^{n-1}-(\\frac{1-\\sqrt5}{2})^{n-1})$$\n$$=\\frac{1}{\\sqrt5}(((\\frac{1+\\sqrt5}{2})^{n-1}(3+\\sqrt5)/2)-(\\frac{1-\\sqrt5}{2})^{n-1}(3+\\sqrt5)/2)$$\nSince $(3+\\sqrt5)=(1+\\sqrt5)^2/2$, the expression simplifies to\n$$=\\frac{1}{\\sqrt5}((\\frac{1+\\sqrt5}{2})^{n+1}-(\\frac{1-\\sqrt5}{2})^{n+1})$$.\nThus we have proven the fibbonacci property from the closed form.\n\\newline\nBase case: $n=0, m=0, f_n=1, f_m=1, f_{n+m+1}=2$, base case holds.\n\\newline\nFor any $n, m \\in \\N$, assume that the statement is true for all $n'\\leq n, m' \\leq m$. Now consider $n+1$ and $f_{n+m+2}$.\n\\newline\nUsing our inductive hypothesis, we know that $f_{n+m+1}=f_mf_n + f_{m+1}f_{n+1}$\n\\newline\nNow consider $f_mf_{n+1}+f_{m+1}f_{n+2}$, use our lemma to get that it is equal to $f_m(f_n+f_{n-1})+f_{m+1}(f_n+f_{n+1})$\n$$=f_mf_n+f_mf_{n-1}+f_{m+1}f_n+f_{m+1}f_{n+1}$$\nNow we apply IH,\n$$=f_{m+n}+f_{m+n+1}=f_{m+n+2}$$\nThe last step is using our lemma (the fibbonacci identity). Thus we have proven the inductive step. Q.E.D.\n\n\\section{Mon Lec, 4a}\n\\begin{figure}[h]\n    \\includegraphics[width = 100mm]{GRAPH1.png}\n\\end{figure}\nBase case: let there be three people, they form a triangle. Let the sides have length $a<b<c$. We can see that A and C will exchange pies, and B will throw at A, leaving him the survivor. Therefore base case holds.\n\\newline\nAssume that for some odd $n$, the statement holds for all odd $m \\leq n$. Now consider $n+2$.\n\\newline\nWe first remove the two people who are closest to each other. We call this the alternate game. Then the remaining $n$ people satisfies the inductive hypothesis, and there will be one survivor. Now consider the original game, since these two removed people are closest to each other, they will throw the pie at each other.\n\\newline\nThen we break down the remaining players into two scenarios when we add the two back: the two new players are closer than their original targets, or they are further than their original targets.\n\\newline\nIn either case they will not throw their pies at the survivor in the alternate game. Therefore he will still be the survivor in the original game.\n\\newline\nThus we have proven the inductive case. Q.E.D.\n\\newpage\n\n\\section{Mon Dis, 4}\nBase case: $n = 1, S = \\{1,2\\}, 1 \\mid 2$, base case holds.\n\\newline\nAssume that for $n \\in \\N$, the statement holds for $m \\leq n$. Consdier $n+1$ and a set $S = \\{a_1, a_2, ..., a_{n+2}\\}$. We break it down into two cases.\n\\paragraph{If $a_{n+1}\\leq 2n$}\nThen we can simply take $S' = S \\setminus a_{n+2}$, now we have a set that has $n+1$ elements, and the largest one is less than $2n$, so we can apply the inductive hypothesis and conclude that there is an integer that divides another in $S'$.\n\\paragraph{If $a_{n+1}> 2n$}\nNow if $a_{n+1}>2n$, and the maximum of the set cannot exceed $2n+22$, we must have $a_{n+1}=2n+1. a_{n+2}=2n+2$. Now if $(n+1)\\in S$, we will have $n+1 \\mid 2n+2$. Otherwise, take the set $\\{a_1, a_2, ..., a_n, n+1\\}$, all of these are less than $2n$ since we know what $a_{n+1}$ and $a_{n+2}$ are. Now we can apply the inductive hypothesis to this set since it has $n+1$ items. Therefore there must be two integers that divides each other.\n\\newline\nThus we have proven the inductive case. Q.E.D.\n\n\\section{Mon Dis, 7}\nBase case: $n=1$, we can simply take a block out, the remaining 3 form an $L$ shape. Base case holds\n\\newline\nAssume that for some $n \\in \\N$, the statement holds for all $m \\leq n$, now consider $2^{n+1} \\times 2^{n+1}$. We first divide the square into four squares of $2^n \\times 2^n$. Take the right most square and remove a single tile. By the inductive hypothesis this square is tilable with $L$'s since it has $2^n \\times 2^n$ tiles. Now for the remaing three squares, we remove one tile at the center like this:\n\\newline\n\\begin{figure}[H]\n    \\includegraphics[width = 100mm]{GRAPH2.png}\n\\end{figure}\nNow the remaining 3 tiles can be filled with a single $L$. Thus we have proven the inductive step. Q.E.D.\n\n\\newpage\n\n\\section{Wed Lec, 5}\nLet our 9 digit number be represented by $abcde2021$. Using the subtraction theorem we know that $abcde0000/2021$ must be an integer.\n\\newline\nWe can factor $2021 = 43 \\times 47$, so it shares no factors with 10000. So $2021 \\mid abcde$. Now the amount that we are seeking is equal to the amount of 5 digit numbers that is divisible by 2021\n$$\\floor*{\\frac{99999}{2021}}-\\floor*{\\frac{9999}{2021}} = 49-4=45$$\n\\newpage\n\n\\section{Wed Dis, 6}\n$$(y-\\frac{1}{y})^3 = x^3$$\n$$y^3 -3 \\frac{1}{y} + 3 y-\\frac{1}{y^3} = x^3$$\n$$y^3-\\frac{1}{y^3}+3(y-\\frac{1}{y})=x^3$$\n$$y^3-\\frac{1}{y^3}+3x = x^3$$\n$$y^3-\\frac{1}{y^3}= x^3-3x$$\n\\newpage\n\n\\section{Fri Lec, 3b}\nSince $a \\equiv b \\bmod 6$, we have $a = 6n + k$, $b = 6m + k$, where $m,n,k \\in \\Z$.\n\\newline\nLet $h \\in \\Z$, we multiply $a, b$ by $h$: $ah = 6nh + kh$, $bh = 6mh + kh$.\n\\newline\nSince mutiples of 6 will always be equivalent to 0 when modded by 6, the only things that are left on both sides are $kh$, and $kh \\equiv kh \\bmod 6$.\n\\newline\nQ.E.D.\n\n\\section{Fri Lec, 7}\nWe factor 12 into $3 \\times 2^2$, and 15 into $3 \\times 5$. Since our perfect square needs to have these as factors, $xy^2$ must have 3 as a factor, and $xy$ must have 5 as a factor.\n\\newline\nFurthermore, since $xy$ has 5 as a factor, $xy^2$ must have 25 as a factor since the $12xy^2$ is a perfect square and 12 cannot be divided by 5. Now we attempt to construct one such number. let $y = 5$, $x=3$, $12xy^2 = 900 = 30^2, 15xy = 225 = 15^2$. $x+y = 8$\n\n\\end{document}\n", "meta": {"hexsha": "c523456b4dd310902a9a90be5d648109ff5107ae", "size": 7252, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week6/main.tex", "max_stars_repo_name": "TianshuangQiu/Math74-Homework", "max_stars_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week6/main.tex", "max_issues_repo_name": "TianshuangQiu/Math74-Homework", "max_issues_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week6/main.tex", "max_forks_repo_name": "TianshuangQiu/Math74-Homework", "max_forks_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.5263157895, "max_line_length": 441, "alphanum_fraction": 0.6788472146, "num_tokens": 2698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.8175744828610095, "lm_q1q2_score": 0.42155768595008186}}
{"text": "\\documentclass[11pt,a4paper]{report}\n\\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}\n\\usepackage{enumitem}\n\\usepackage{changepage}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem*{cor}{Corollary}\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\\newtheorem{conj}{Conjecture}[section]\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{exercise}{Exercise}[section]\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\\newtheorem*{note}{Note}\n\\def\\changemargin#1#2{\\list{}{\\rightmargin#2\\leftmargin#1}\\item[]}\n\\let\\endchangemargin=\\endlist \n\\begin{document}\n\n\\section*{Problem} Moe has built an awesome atomic clock.  It has one hand that\nmoves at a perfectly constant speed around a 24 hour dial. The problem is he has\nno way to calibrate it.  He asks Joe for advice and Joe asks him what his\nobjective is.  He says he wants it to be exactly right as often as possible.\nJoe thinks for a minute and says, ``That’s going to take a lot of electricity.''\nExplain what he means.\n\n\\section*{Solution} Let $s$ be the rotational speed that Moe chooses expressed\nin revolutions per day. If Moe can find \\emph{exactly} 1 as the rotational\nspeed, he will be right all the time.  Unfortunately, the probability of that is\n$0$. Now consider what happens when Moe's chosen speed is off by $\\delta$\nrevolutions per day.  If $\\delta < 0$ and Moe manages to start the clock at\nexactly the right time, it will drift by $\\delta$ each 24 hours and it will take\n$1/\\delta$ days for it to be exactly right again (when it has fallen so far\nbehind that it is showing exactly the right time). Somewhat paradoxically, the\nsmaller $\\delta$ is, the longer this will take and hence the smaller the number\nof times per any time interval that the clock will be exactly right. The same\nanalysis obviously applies for $\\delta > 0$. Now suppose that Moe just lets the\nhand move as fast as possible. Then it will pass the correct time once every\nrevolution it makes (plus whatever time it takes to complete a revolution). So\nthe faster he can make it go, the more frequently the reading is exactly right.\nHence Joe's comment ``that will take a lot of electricity.'' \\end{document}\n\n\n\n", "meta": {"hexsha": "886f35967eb239032d023ed207f15d8e061e0d19", "size": 2316, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "clock/clock.tex", "max_stars_repo_name": "psteitz/problems", "max_stars_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "clock/clock.tex", "max_issues_repo_name": "psteitz/problems", "max_issues_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-03T21:08:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T21:08:11.000Z", "max_forks_repo_path": "clock/clock.tex", "max_forks_repo_name": "psteitz/problems", "max_forks_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.2653061224, "max_line_length": 80, "alphanum_fraction": 0.7724525043, "num_tokens": 633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.4214894075791031}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Copyright (c) 2003-2018 by The University of Queensland\n% http://www.uq.edu.au\n%\n% Primary Business: Queensland, Australia\n% Licensed under the Apache License, version 2.0\n% http://www.apache.org/licenses/LICENSE-2.0\n%\n% Development until 2012 by Earth Systems Science Computational Center (ESSCC)\n% Development 2012-2013 by School of Earth Sciences\n% Development from 2014 by Centre for Geoscience Computing (GeoComp)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\chapter{Using Trilinos}\n\\label{TRILINOS}\nTrilinos has a number of packages and provides a large collection of both direct and indirect solvers.  We refer the reader to \\cite{TrilinosWeb} for details.  Escript needs to be installed with Trilinos to be able to use the Trilinos solvers.  See the install guide for details.  We show a few examples for the Trilinos options with a simple example.\n\nConsider Laplacian in domain ($\\Omega\\in \\mathbb{R}^3$) with a simple right hand side,\n\\begin{align}\n -\\nabla^t\\; \\nabla u &= 1,  &&\\text{ in } \\Omega, \\label{CONST1a}\\\\\n u &= 0, &&\\text{ on } \\Gamma_D,\\label{BC1}\\\\\n \\mathbf{n}^t \\; \\nabla u &= 0, &&\\text{ on }\\Gamma_N,\\,\\label{BC2}\n\\end{align} \nwith $\\mathbf{n}$ the outward normal, with $\\Gamma_D$ the left boundary and $\\Gamma=\\partial\\Omega\\backslash\\Gamma_D$.  Gravity forward weak form of PDE (\\ref{CONST1a})-(\\ref{BC2}), where $(~,~)$ is the standard $L^2$ inner product on $\\Omega$, is\n\\begin{equation}\\label{weak}\n(\\nabla u ~,~\\nabla v ) = -(f ~,~v ),   \n\\end{equation}\nfor all admissible potential functions $v$. \n\n\nFor this example, we just consider a simple, unstructured, 3D domain.  The mesh is created with GMSH using simplemesh.geo (file \\ref{simplemesh}) see /escript/doc/examples/usersguide/simplemesh.geo.  To test AMG, a finer mesh is created using    /escript/doc/examples/usersguide/simplemeshfine.geo.\n\n\\begin{python}[caption=simplemesh.geo,label=simplemesh]\n// dimensions and mesh size\nxdim = 100.;\nydim = 200.;\nzdim = 50.;\nmtop = 2.;\nmbase = 5.;\n\n//Points\nPoint(1) = {0., 0., 0., mbase};\nPoint(2) = {xdim, 0., 0., mbase};\nPoint(3) = {0., ydim, 0., mbase};\nPoint(4) = {xdim, ydim, 0., mbase};\nPoint(5) = {0., 0., zdim, mtop};\nPoint(6) = {xdim, 0., zdim, mtop};\nPoint(7) = {0., ydim, zdim, mtop};\nPoint(8) = {xdim, ydim, zdim, mtop};\n\n//Lines and surfaces\nLine(1) = {1, 2};\nLine(2) = {3, 4};\nLine(3) = {1, 3};\nLine(4) = {2, 4};\nLine(5) = {5, 6};\nLine(6) = {7, 8};\nLine(7) = {5, 7};\nLine(8) = {6, 8};\nLine(9) = {1, 5};\nLine(10) = {3, 7};\nLine(11) = {2, 6};\nLine(12) = {4, 8};\nLine Loop(1) = {-1, 3, 2, -4};\nPlane Surface(1) = {1};\nLine Loop(2) = {5, 8, -6, -7};\nPlane Surface(2) = {2};\nLine Loop(3) = {1, 11, -5, -9};\nPlane Surface(3) = {3};\nLine Loop(4) = {-2, 10, 6, -12};\nPlane Surface(4) = {4};\nLine Loop(5) = {-3, 9, 7, -10};\nPlane Surface(5) = {5};\nLine Loop(6) = {4, 12, -8, -11};\nPlane Surface(6) = {6};\n\n// domain\nSurface Loop(1) = {1:6};\nVolume(1) = {1};\n\\end{python}\n\nThe most basic escript script to solve this pde using escript defaults is in program \\ref{basic}.  The computed solution is saved in a silo file \"asimple.silo\" and can be visualized using \\VisIt.\n\\begin{python}[caption=basic solve using defaults only, label=basic ]\nfrom esys.escript import *\nfrom esys.weipa import saveVTK, saveSilo\nfrom esys.escript.linearPDEs import LinearSinglePDE\nfrom esys.finley import ReadGmsh\n  \ndomain=ReadGmsh(\"simplemesh.msh\", 3,  optimize=True )\n       \npde = LinearSinglePDE(domain, isComplex=False)\npde.setSymmetryOn()\nx = domain.getX()\npde.setValue(A=kronecker(3), Y = 1., q = whereZero(x[0]-inf(x[0])))\n\nu=pde.getSolution()    \nsaveSilo(\"asimple\", u=u)    \n\\end{python}\n\nThis script uses default Trilinos solver PCG with Jacobi preconditioner. (It takes 271 iterations to reach the default tolerance of $10^{-8}$).  Tolerance and solver output can be controlled by adding to the basic listing.\n \\begin{python}[caption=tolerance , label=tolerance ]\noptions = pde.getSolverOptions()  \noptions.setTolerance(1e-8)        \noptions.setVerbosityOn()        \n\\end{python}\n\n\n\n\\section{Direct Solvers}\nThere are a number of options that can be set for solving the pde.  The simplest way to choose a direct solver is to use the default Trilinos direct solver KLU2.  Escript can only use this feature if it is available in Trilinos.\n\nTo choose the default Trilinos direct solver, set the tolerance for the PDE solver to $10^{-8}$,  use the Trilinos suite of solvers and output information about the solvers, we add code to listing \\ref{basic}.\n\\begin{python}[caption=default Direct , label=defaultdirect ]\noptions = pde.getSolverOptions()  \noptions.setSolverMethod(SolverOptions.DIRECT)         \noptions.setPackage(SolverOptions.TRILINOS)\noptions.setVerbosityOn()        \n\\end{python}\nThe default Trilinos Direct solver is the Amesos2 LU factorisation KLU. It is a serial, unsymmetric sparse, partial-pivoting, direct matrix solver.  The last line above ensures that the output includes details of the methods used.\n\n\nTo use SUPERLU the code that needs to be added to listing \\ref{basic} is \n\\begin{python}[caption=SuperLU, label=superLU ]\noptions = pde.getSolverOptions()  \noptions.setTolerance(1e-8)        \noptions.setPackage(SolverOptions.TRILINOS)\noptions.setSolverMethod(SolverOptions.DIRECT_SUPERLU)\noptions.setVerbosityOn()        \n\\end{python}\nTrilinos is the default solver package so the setPackage line is not really necessary.\n\n\\section{Preconditioned Conjugate Gradient}\nIf we want to use preconditioned conjugate gradient, then we remover the DIRECT solver line and add the line\n\\begin{python}[caption=Preconditioned conjugate gradient defaults, label=PCG]\noptions.setSolverMethod(SolverOptions.PCG)        \n\\end{python}\nThis takes 271 iterations to reach tolerance using a Jacobi preconditioner, BELOS Pseudo Block CG with Ifpack2.  To change the preconditioner to Gauss-Siedel, we add the line\n\\begin{python}\noptions.setPreconditioner(SolverOptions.GAUSS_SEIDEL)\n\\end{python}\nThis takes 120 iterations to reach tolerance.\n\n\n\n\\section{Multigrid}\nGeometric multigrid methods were introduced for structured grids to maximise the advantages of iterative methods for solving matrix equations derived from discretised partial differential equations.  Iterative methods for these problems are effective in reducing oscillatory error but stall for smooth error and smooth error appears oscillatory when restricted to a coarser grid.  The idea is to have a succession of grids from fine to coarse and to remove error by iterating on each of the grids in turn reducing the oscillatory error on that grid.  The coarsest grid is chosen small enough so that it can be quickly solved directly or iteratively. If $n$ is the size of the problem then a multigrid algorithm is order $n$.\n\nThe matrix equation,  derived from the PDE, is\n\\begin{equation}\\label{matrixEQ}\n    \\mathbf{A}\\mathbf{u}=\\mathbf{f},\n\\end{equation}\nwhere $\\mathbf{u}$ is the unknown $n\\times 1$ vector, $\\mathbf{A}$ is the $n\\times n$ matrix and $\\mathbf{f}$ is the nown right hand side $n\\times 1$ vector.  The residual $\\mathbf{r}$ is defined\n\\begin{equation}\\label{res}\n    \\mathbf{r}=\\mathbf{f}-\\mathbf{A}\\mathbf{u}%=\\mathbf{A}\\mathbf{u}^*-\\mathbf{A}\\mathbf{u}=\\mathbf{A}\\mathbf{u}^*-\\mathbf{u}),\n\\end{equation}\nand the residual equation is defined \n\\begin{equation}\\label{resEQ}\n    \\mathbf{A}\\mathbf{e}=\\mathbf{r},\n\\end{equation}\nwhere $\\mathbf{e}=\\mathbf{u}^*-\\mathbf{u}$ is the error and $\\mathbf{u}^*$ is the exact solution.  Relaxing on \\ref{resEQ}) with the residual as the right hand side is the same as relaxing on (\\ref{matrixEQ}) with the original right and side.  We use superscripts on these terms to indicate the discretization representing element length, $h$, for a fine grid and $H$ for one level coarser discretization, $h<H$.  For a structured mesh, $H=\\frac{h}{2}$ and $\\mathbf{A}^h$ is an $n\\times n$ matrix and $\\mathbf{A}^H$ is an $N\\times N$ matrix obtained in the coarsening process with $N<n$.  Prolongation operator, $\\mathbf{P}^h_H$, an $n\\times N$ matrix, is used to interpolate the error from the coarse grid to the fine grid and restriction operator $\\mathbf{P}_h^H$, an $N\\times n$ matrix, is used to restrict the residual from the fine grid to the coarse grid.  It is not necessary for the restriction operator to be the transpose of the interpolation operator.  The coarse grid matrix operator $\\mathbf{A}^H$ is computed by multiplying the fine grid matrix operator $\\mathbf{A}^h$ on the left by the restriction operator and the right by the interpolation operator resulting in an $N\\times N$ matrix.  \n\nThe MG algorithm is best described using a recursion algorithm.  After iteration on a fine grid, the fine grid error is smooth and the residual can be restricted to a coarse grid. The error on the coarse grid appears more oscillatory and is (smoothed) reduced by iteration.  If this is the coarsest grid then the matrix equation is solved using a direct method or sufficient iterations of the solver to get within discretization error, otherwise the algorithm is called again with the coarse grid replacing the fine grid and the next coarser grid as the coarse grid.  The coarse grid error, is interpolated to the fine grid where it corrects the fine grid approximation and post-smoothing iteration smooths the error.  For structured grids, the choices for interpolating from a coarse grid to a fine grid or restricting from a fine grid to a coarse grid are reasonably obvious, see \\cite{Briggs2000}. \n\n\n\\begin{table}\\center\n\\begin{tabular}{|l|l|ll}\n\\hline\nAMG($\\mathbf{u}^h;\\mathbf{A}^h,\\mathbf{f}^h)$ &\\\\ \\hline\n    \\quad $\\mathbf{A}^h\\mathbf{u}^h=\\mathbf{f}^h$ & \\textbf{p steps pre-smoothing iteration}\\\\\n\t\\quad $\\mathbf{r}^h=\\mathbf{f}^h-\\mathbf{A}^h \\mathbf{u}^h$ & \\textbf{fine grid residual}\\\\\n\t\\quad $\\mathbf{r}^H=\\mathbf{R}_h^H \\mathbf{r}^h$ & \\textbf{restrict residual} \\\\\n\t\\quad $\\mathbf{A}^H=\\mathbf{R}_h^{H} \\mathbf{A}^h \\mathbf{P}_H^h$& \\textbf{restrict operator}\\\\\n\t\\quad if not coarsest  &\\\\\n\t  \\quad\\quad AMG($\\mathbf{e}^H;\\mathbf{A}^H,\\mathbf{r}^H$) &\\textbf{recursion}\\\\\n\t  \\quad else &\\\\\n\t  \\quad\\quad $\\mathbf{A}^H\\mathbf{e}^H=\\mathbf{r}^H$ & \\textbf{coarsest solve}\\\\\n\t\\quad$\\mathbf{e}^h=\\mathbf{P}_H^h \\mathbf{e}^H$ & \\textbf{interpolate error} \\\\\n\t\\quad$\\mathbf{u}^h=\\mathbf{u}^h+\\mathbf{e}^h$ & \\textbf{fine grid correction}\\\\\n\t\\quad$\\mathbf{A}^h\\mathbf{u}^h=\\mathbf{f}^h$ & \\textbf{q steps post-smoothing iteration}\\\\\n\t\\quad return $\\mathbf{u}^h$ &\\\\\n\\hline\n\\end{tabular}\\caption{An AMG V(p.q) cycle algorithm to solve $\\mathbf{A}\\mathbf{u}=\\mathbf{f}$, where $h$ and $H$ represent grid sizes with $h<H$.}\n\\end{table}\n\n\nAlgebraic multigrid methods were developed for unstructured grids and do not reference the grid but instead use interpolation and restriction operators derived from the matrix (see \\cite{Briggs2000, Stuben2001281, Vanek1996, Tuminaro2000}).  The terms \"coarse grid\" and \"fine grid\" are still used but do not refer to actual grids.  \"Smooth error\" is defined to be the error not reduced by iteration and \"oscillatory error\" is the error reduced by iteration.  Coarse levels are chosen from the relative sizes of the off diagonal terms in the fine matrix.\nOnce the coarse grid is chosen the restriction and interpolation operators are computed. Restriction operators need to be chosen so that \"smooth error\" on a fine grid will appear \"oscillatory\" on a coarse grid ensuring that it can be reduced by iterating on this grid. There are a number of algorithm options available in Trilinos to compute the coarse grid and the choice will depend on the original PDE and smoothing options. For any multigrid method, there are basic choices: \n\\begin{itemize}%[topsep=0pt,itemsep=-1ex,partopsep=1ex,parsep=1ex]\n    \\item pre-smoothing iterative solver and number of iterations \n    \\item post-smoothing iterative solver and number of iterations\n    \\item choosing coarse grids    \n    \\item number of coarse grids or size of coarsest grid\n    \\item interpolation operator\n    \\item restriction operator\n    \\item coarsest grid solver\n    \\item cycle type \n\\end{itemize}\nWe use Trilinos solvers and it is possible to access Trilinos options either within the escript script or, if more complicated control is needed, in an XML file. There are many Trilinos packages that can be used by escript including \nMueLu   - setup of AMG, Belos   - linear solvers - Pseudo Block CG, Ifpack2 - iterative solvers (Jacobi, Gauss-Siedel), Amesos2 - direct solvers for coarse level and Voltan or Voltan2 - repartitioning for caorse grids\n\n\n\\subsection{Default MueLu Trilinos options for algebraic multigrid preconditioned conjugate gradient (AMG-PCG)}\nMore detail on the various options can be found in the MUELU user guide and other Trilinos user guides \\cite{TrilinosWeb}. MUELU uses other Trilinos packages and to access these parameters the XML file must be used.  \nRecall $\\mathbf{R}_h^H$ is the restriction operator and $\\mathbf{P}^h_H$ is the interpolation (prolongation) operator.  The default values used are shown in Table \\ref{defaultAMG}.  To use AMG-PCG with default paramerters we use script \\ref{basicAMG}. \n\n\\begin{table}\\center\n\\begin{tabular}{|r|l|}\n\\hline\n    number of equations & 1\\\\\n    problem: symmetric & True, $\\mathbf{R}_h^H = (\\mathbf{P}^h_H)^t$ \\\\\n    pre-smoothing iterative solver & Symmetric Gauss-Seidel\\\\\n    post-smoothing iterative solver & Symmetric Gauss-Seidel\\\\\n    pre-smoothing iterations & 1 \\\\\n    post-smoothing iterations & 1 \\\\\n    minimum aggregate size & 2 \\\\\n    maximum aggregate size & unlimited \\\\\n    aggregation & uncoupled \\\\\n    maximum number of levels & 10\\\\\n    maximum size of coarsest grid & 2000\\\\\n    choosing coarse grids & classical smoothed aggregation\\\\\n    coarsest grid solver &  SuperLU\\\\\n    cycle type & V(1,1) \\\\\n    \\hline\n\\end{tabular}\\caption{Default parameters for AMG-PCG}\\label{defaultAMG}\n\\end{table}\n\n\n\\begin{python}[caption=basic Trilinos PCG-AMG defaults only script, label=basicAMG ]\nfrom esys.escript import *\nfrom esys.weipa import saveVTK, saveSilo\nfrom esys.escript.linearPDEs import LinearSinglePDE\nfrom esys.finley import ReadGmsh\n\ndomain=ReadGmsh(\"simplemesh.msh\", 3,  optimize=True )\n\npde = LinearSinglePDE(domain, isComplex=False)\npde.setSymmetryOn()\nx = domain.getX()\npde.setValue(A=kronecker(3), Y=1, q=whereZero(x[0]-inf(x[0])))\n\noptions = pde.getSolverOptions()\noptions.setPackage(SolverOptions.TRILINOS)\noptions.setSolverMethod(SolverOptions.PCG)\noptions.setPreconditioner(SolverOptions.AMG)\n\nu=pde.getSolution()    \nsaveSilo(\"asimple\",u=u)    \n\\end{python}\n\nOnly two grids were used for the simple mesh.  The first coarse grid, replaces, if possible, 27 fine grid nodes represented by  one coarse grid node.  In 2D this would be 9 fine grid nodes represented with one coarse grid node. The ratio of the fine to coarse grid in this example is 19.21.  For a finer mesh, with mtop = 2 and mbase=1 in the geo file, 3 levels of grids and the coarsest grid is solved with a direct method.  AMG-PCG took 11 iterations to reach tolerance.\n\n\\subsection{Altering MUELU parameters}\nTo access MUELU parameters in the python script we use the general form  \n\\begin{python}\noptions.setTrilinosParameter( \"A\", \"B\")        \n\\end{python}\nwhere \"A\" is the Trilinos parameter and \"B\" is its string value. It is extremely important to have correct spaces in the strings.  \n\n\\subsubsection{Debug output}\nOptions are \"none\", \"low\", \"medium\", \"high\" and \"extreme\".\n\\begin{python}\noptions.setTrilinosParameter(\"verbosity\", \"low\")  \n\\end{python}\nOptions are\\\\\n\\var{\"low\"} - setup time,\\\\\n\\var{\"medium\"} - basic AMG data, mesh sizes, smoothers + \"low\" \\\\\n\\var{\"high\"} - input data, relaxation solvers and data, aggregate data + \"medium\"\\\\\n\\var{\"extreme\"} - may include solver details that MueLu calls + \"high \"\\\\\n\n\\subsubsection{Problem type}\nChanges default multigrid algorithm, block size and smoother.  \nOptions are \n\\begin{itemize}\n    \\item \\var{\"unknown\"}: default\n    \\item \\var{\"Poisson-2D\" or \"Poisson-3D\"} : using smoothed aggregation, Chebyshev smoother and block size of 1,\n    \\item \\var{\"Elasticity-2D\" and \"Elasticity-3D\"}: using smoothed aggregation, Chebyshev smoother and block size of 2 or 3 respectively,\n    \\item \\var{\"Poisson-2D-complex\" and \"Poisson-3D-complex\"}: using smoothed aggregation, symmetric Gauss-Seidel and block size 1,\n    \\item \\var{\"Elasticity-2D-complex\" and \"Elasticity-3D-complex\"}: using smoothed aggregation, symmetric Gauss-Seidel and block size 2 and 3 respectively,\n    \\item \\var{\"ConvectionDiffusion\"}: using Petrov-Galerkin AMG, Gauss-Seidel and 1 block,\n    \\item \\var{\"MHD\"}: using unsmoothed aggregation and Additive Schwarts method with one level of overlap and ILU(0) as a subdomain solver.\n\\end{itemize}\n\\begin{python}\noptions.setTrilinosParameter(\"problem:type\", \"Poisson-3D\")    \n\\end{python}\n\n\\subsubsection{number of equations}\nNumber of PDE equations at each grid node.\n\\begin{python}\noptions.setTrilinosParameter(\"number of equations\", 1)        \n\\end{python}\n\n\\subsubsection{AMG algorithm}\nThe multigrid algorithm for computing the coarse levels and interpolation and restriction operators is controlled with \\var{\"multigrid algorithm\"}. The default value is smoothed aggregation and is selected with \\var{\"sa\"} and a damping factor can be imposed.  The other options are \\var{\"unsmoothed\"}, no Jacobi prolongation improvement step; \\var{\"pg\"}, $\\mathbf{A}$ prolongation smoothing and $\\mathbf{A}^T$ restriction smoothing; \\var{\"emin\"} basis functions for grid transfer using energy constrained minimisation; \\var{\"interp\"}, piecewise constant (\"interpolation order\" set to 0) or linear interpolation (\\var{\"interpolation order\"} set to 1) from coarse to fine and is only possible with structured aggregation; and \\var{\"semicoarsen\"}, coarsen fully in z direction (will need to set rate in this direction).   It is also possible to use an implicit transpose for the restriction operator.\n\\begin{python}\n# smoothed aggregation\noptions.setTrilinosParameter(\"multigrid algorithm\", \"sa\")\noptions.setTrilinosParameter(\"sa: damping factor\", 1.3)\noptions.setTrilinosParameter(\"sa: use filtered matrix\", True)\noptions.setTrilinosParameter(\"filtered matrix: use lumping\", True)\noptions.setTrilinosParameter(\"filtered matrix: reuse eigenvalue\", True)\n# unsmoothed\noptions.setTrilinosParamter(\"multigrid algorithm\", \"unsmoothed\")\n# pg\noptions.setTrilinosParameter(\"multigrid algorithm\", \"pg\")\n# interpolation\noptions.setTrilinosParameter(\"multigrid algorithm\", \"interp\")\noptions.setTrilinosParameter(\"interp: interpolation order\", 1)    \n                                                          # 0, 1\noptions.setTrilinosParameter(\"interp: build coarse coordinates\", True)\n# emin\noptions.setTrilinosParameter(\"multigrid algorithm\", \"emin\")\noptions.setTrilinosParameter(\"emin: iterative method\", \"cg\") \n                                                     # \"cg\", \"gmres\", \"sd\"\noptions.setTrilinosParameter(\"emin: num iterations\", 2)\noptions.setTrilinosParameter(\"emin: num reuse iterations\", 1)\noptions.setTrilinosParameter(\"emin: pattern\", \"AkPtent\")\noptions.setTrilinosParameter(\"emin: pattern order\", 1)\n# semicoarsen\noptions.setTrilinosParameter(\"multigrid algorithm\", \"semicoarsen\")\noptions.setTrilinosParameter(\"semicoarsen: coarsen rate\", 3)\n#\noptions.setTrilinosParameter(\"transpose: use implicit\", False) \n\\end{python}\n\n\\subsubsection{Maximum levels, coarse mesh, coarse solver}\nIt is possible to limit the size of the coarsest level as well as limit the number of levels.  The default for the size of the coarsest level is 2000.  So once the size of the coarse level is less than 2000 then no more coarse levels are created.  Additionally, it is possible to limit the number of levels by setting \"max levels\" in the hierarchy.  This includes the fine grid.  The default value is 10 but depending on fine grid size, changing this could improve performance of the algorithm.  The coarsest level can be solved using a direct solver.  Possibilities are KLU, KLU2, SuperLU, SuperLU\\_dist, Umfpack and Mumps\n\n\\begin{python}\noptions.setTrilinosParameter(\"max levels\", 10)         \noptions.setTrilinosParameter(\"coarse: max size\", 2000)\noptions.setTrilinosParameter(\"coarse: type\", \"SuperLU\")\n\\end{python}\n\n\n\\subsubsection{Aggregation}\nIt is possible to influence aggregation options.  If the fine mesh is a structured grid then aggregates can be created in a  \"structured\" way and the aggregation attempts to form hexahedral coarse levels.  This uses a default coarsening rate of 3 in each direction. The option \"hybrid\" allows user determined \"structured\" or \"unstructured\" aggregation for each level, To get optimal size coarse mesh ($3^d$ in $d$ dimensions) \"uncoupled\" or \"coupled\" is used with \"coupled\" allowing aggregates to span processors.  It is suggested that \"coupled\" should be used with care.  \"brick\" attempts to make rectangular aggregates. Some of the options are below with more detail and more options in the MUELU user guide.   \n\\begin{python}\noptions.setTrilinosParameter(\"aggregation: type\", \"structured\")\noptions.setTrilinosParameter(\"aggregation: ordering\", \"natural\")\n                                                 # \"natural\", \"graph\", \"random\"\noptions.setTrilinosParameter(\"aggregation: drop scheme\", \"classical\")\n                                                 # \"classical\", \"distance laplacian\" \noptions.setTrilinosParameter(\"aggregation: drop tol\", 0.0)\noptions.setTrilinosParameter(\"aggregation: min agg size\", 2)\noptions.setTrilinosParameter(\"aggregation: max agg size\", -1) \n                                                # -1 means unlimited    \noptions.setTrilinosParameter(\"aggregation: Dirichlet threshold\", 1e-5)\n\\end{python}\n    \n\\subsubsection{Relationship between $\\mathbf{R}_h^H$  and $\\mathbf{P}^h_H$}\nFor $\\mathbf{R}_h^H=(\\mathbf{P}^h_H)^t$\n\\begin{python}\noptions.setTrilinosParameter(\"problem: symmetric\", True)\n\\end{python}\nthis is the default.\n\n\\subsubsection{Smoothers}\nIn the escript script it is possible to choose smoother type, \"RELAXATION\", \"CHEBYSHEV\" and \"ILUT\" or \"RILUT\" but for more specific control the XML file needs to be used.  It is possible to use different pre and post smoothers.  \"RELAXATION\" could use Jacobi, Gauss-Seidel, symmetric Gauss-Seidel, multithreaded Gauss-Seidel.  To specify which one the XML file must be used.  Some examples for this are \n\\begin{python}\noptions.setTrilinosParameter(\"smoother: pre or post\", \"both\")\noptions.setTrilinosParameter(\"smoother: type\", \"RELAXATION\")\noptions.setTrilinosParameter(\"smoother: pre type\", \"CHEBYSHEV\")\noptions.setTrilinosParameter(\"smoother: post type\", \"RELAXATION\")\n\\end{python}\n\n\\subsubsection{Cycle type}\nAllowable cycle types are \"V\" and \"W\".  The default is a \"V\" cycle.\n\\begin{python}\noptions.setTrilinosParameter(\"cycle type\", \"V\")\n\\end{python}\n\n\\subsubsection{reuse}\nIf multiple PDEs are being solved the reuse strategy can use elements of previous computations.  The level of reuse varies from none to full.  Options are \\var{\"none\"}; \\var{\"S\"}, symbolic coarse levels information; \\var{\"tP\"}, reuse tentative prolongation operator; \\var{\"emin\"}, reuse old prolongator for initial guess; \\var{\"RP\"}, reuse smoothed restrictor and prolongator; \\var{\"RAP\"}, compute only fine level smoothers and reuse all other operators, and \\var{\"full\"}, reuse everything.\n\\begin{python}\noptions.setTrilinosParameter(\"reuse: type\", \"full\")\n\\end{python}\n\n\\subsubsection{repartitioning}\nIf there are multiple processors it might be benificial to repartition as the mesh are coarsened including perhaps using only one processor for the coarsest grid.  This is to reduce communication costs for the caorser grids.\n\\begin{python}\noptions.setTrilinosParameter(\"repartition: enable\", False)\noptions.setTrilinosParameter(\"repartition: start level\", 2)\noptions.setTrilinosParameter(\"repartition: min rows per proc\", 800)\noptions.setTrilinosParameter(\"repartition: max imbalance\", 1.2)\noptions.setTrilinosParameter(\"repartition: remap parts\", True)\noptions.setTrilinosParameter(\"repartition: rebalance P and R\", False)\n\\end{python}\n\n\n\\subsection{commands in XML file}\nAll the previous commands can be placed into an XML file.  The XML file option allows the user to choose parameters for the programs that MUELU calls, so more control is possible on the iterative solvers.\n\\begin{python}\nfrom esys.escript import *\nfrom esys.weipa import saveVTK, saveSilo\nfrom esys.escript.linearPDEs import LinearSinglePDE\nfrom esys.finley import ReadGmsh\n\ndomain=ReadGmsh(\"simplemesh.msh\", 3,  optimize=True )\n\npde = LinearSinglePDE(domain, isComplex=False)\npde.setSymmetryOn()\nx = domain.getX()\npde.setValue(A=kronecker(3), Y=1, q=whereZero(x[0]-inf(x[0])))\n\noptions = pde.getSolverOptions()\noptions.setPackage(SolverOptions.TRILINOS)\noptions.setSolverMethod(SolverOptions.PCG)\noptions.setPreconditioner(SolverOptions.AMG)\noptions.setTrilinosParameter(\"xml parameter file\", \"simplebob.xml\")\n\nu=pde.getSolution()    \nsaveSilo(\"asimple\",u=u) \n\\end{python}\n\nIt is possible to specify how many sweeps of the iterative solvers for pre and post smoothing and we could choose cycles with different numbers of pre and post sweeps.  Amesos2 provides direct solvers including superLU and Mumps. MueLu passes parameters directly to solver library.  To specify CHEBYSHEV parameters, for example, an XML file must be used.\n\nIfpack2 or Ifpack provides iterative matrix solvers Jacobi, Gauss Seidel, polynomial, distribution relaxation, domain decomposition solvers and incomplete factorizations.\n\n\nA very simple XML file is in file \\ref{simplebob}\n\\begin{python}[caption=simplebob.xml,label=simplebob]\n<ParameterList name=\"MueLu\"> \n  <Parameter name=\"verbosity\"               type=\"string\"    value=\"high\"/> \n  <Parameter name=\"max levels\"              type=\"int\"       value=\"4\"/>\n  <Parameter name=\"coarse: max size\"        type=\"int\"       value=\"200\"/>\n  <Parameter name=\"multigrid algorithm\"     type=\"string\"    value=\"sa\"/>\n  <Parameter name=\"reuse: type\"             type=\"string\"    value=\"full\"/>\n  <Parameter name=\"transpose: use implicit\" type=\"bool\"      value=\"true\"/>\n  <Parameter name=\"sa: damping factor\"      type=\"double\"    value=\"0.1\"/> \n  <Parameter name=\"sa: use filtered matrix\" type=\"bool\"      value=\"true\"/>\n</ParameterList>\n\\end{python}\n\nA more complicated example that controls the number of pre and post sweeps is in the listing \\ref{complicatedbob}\n\\begin{python}[caption=complicatedbob.xml,label=complicatedbob]\n<ParameterList name=\"MueLu\">\n  <!--    General    -->\n  <Parameter name=\"verbosity\"               type=\"string\"    value=\"high\"/> \n  <Parameter name=\"max levels\"              type=\"int\"       value=\"4\"/>\n  <Parameter name=\"coarse: max size\"        type=\"int\"       value=\"200\"/>\n  <Parameter name=\"multigrid algorithm\"     type=\"string\"    value=\"sa\"/>\n  <Parameter name=\"reuse: type\"             type=\"string\"    value=\"full\"/>\n  <Parameter name=\"transpose: use implicit\" type=\"bool\"      value=\"true\"/>\n  <Parameter name=\"sa: damping factor\"      type=\"double\"    value=\"0.1\"/> \n  <Parameter name=\"sa: use filtered matrix\" type=\"bool\"      value=\"true\"/>\n\n  <!-- Smoothing -->\n  <Parameter name=\"smoother: pre or post\"        type=\"string\"  value=\"both\"/>\n\n  <Parameter name=\"smoother: pre type\"           type=\"string\"  value=\"CHEBYSHEV\"/>\n  <ParameterList name=\"smoother: pre params\">\n    <Parameter name=\"relaxation: type\"           type=\"string\"  value=\"Symmetric Gauss-Seidel\"/>\n    <Parameter name=\"relaxation: sweeps\"         type=\"int\"     value=\"5\"/>\n    <Parameter name=\"relaxation: damping factor\" type=\"double\"  value=\"0.9\"/>\n  </ParameterList>\n  \n  <ParameterList name=\"smoother: params\">\n    <Parameter name=\"chebyshev: degree\"           type=\"int\"     value=\"3\"/>\n    <Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\"  value=\"15\"/>\n  </ParameterList>\n\n  <Parameter name=\"smoother: post type\"           type=\"string\"  value=\"RELAXATION\"/>\n  <ParameterList name=\"smoother: post params\">\n    <Parameter name=\"relaxation: type\"           type=\"string\"  value=\"Symmetric Gauss-Seidel\"/>\n    <Parameter name=\"relaxation: sweeps\"         type=\"int\"     value=\"5\"/>\n    <Parameter name=\"relaxation: damping factor\" type=\"double\"  value=\"0.9\"/>\n  </ParameterList>\n\n  <!-- Aggregation -->\n  <Parameter name=\"aggregation: type\"           type=\"string\"  value=\"uncoupled\"/>\n  <Parameter name=\"aggregation: min agg size\"   type=\"int\"     value=\"3\"/>\n  <Parameter name=\"aggregation: max agg size\"   type=\"int\"     value=\"27\"/>\n\n  <!--  for different level parameter list -->\n  <ParameterList name=\"level 2\">\n    <Parameter name=\"smoother: type\" type=\"string\" value=\"CHEBYSHEV\"/>\n  </ParameterList>\n\n</ParameterList>\n\\end{python}\n\n", "meta": {"hexsha": "982808cfa74f686321e772cd5fee4d0b1cabf78e", "size": 28788, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user/trilinos.tex", "max_stars_repo_name": "markendr/esys-escript.github.io", "max_stars_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/user/trilinos.tex", "max_issues_repo_name": "markendr/esys-escript.github.io", "max_issues_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/user/trilinos.tex", "max_forks_repo_name": "markendr/esys-escript.github.io", "max_forks_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.479338843, "max_line_length": 1204, "alphanum_fraction": 0.7277685147, "num_tokens": 8026, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4214290418569596}}
{"text": "\n\\chapter{Binary search algorithms}\n\\Label{cha:binary-search}\n\nIn this chapter, we consider the four\n\\emph{binary search} algorithms of the \\cxx Standard Library \\cite[\\S\n28.7.3]{cxx-17-draft}, namely\n\n\\begin{itemize}\n\\item \\lowerbound in \\S\\ref{sec:lowerbound}\n\n\\item \\upperbound in \\S\\ref{sec:upperbound}\n\n\\item two variants for the implementation of  \\equalrange in \\S\\ref{sec:equalrange}\n\n\\item two variants for the formal specification of \\binarysearch in \\S\\ref{sec:binarysearch}\n\\end{itemize}\n\nAs in the case of the of maximum/minimum algorithms from Chapter~\\ref{cha:maxmin}\nthe binary search algorithms primarily use the less-than operator~\\inl{<}\n(and the derived operators \\inl{<=}, \\inl{>} and \\inl{>=}) to determine whether a particular\nvalue is contained in an increasing range.\nThus, different to the \\find algorithm in \\S\\ref{sec:find},\nthe equality operator~\\inl{==} will play only a supporting part\nin the specification of binary search.\n\nIn order to make the specifications of the binary search algorithms \nmore compact and (arguably) more readable we re-use the predicates\n\\logicref{LowerBound}, \\logicref{StrictLowerBound},\n\\logicref{UpperBound}, and \\logicref{StrictUpperBound}.\n\nAll binary search algorithms require that their input array is arranged in \nincreasing order.\nThe following listing shows two versions of predicate \\logicref{Increasing}.\nThe first one defines when a section of an array is in increasing order.\nThe second version uses the first one to express that the whole array is in increasing order.\n\n\\input{Listings/Increasing.acsl.tex}\n\n%\\clearpage\n\nThere is also the overloaded predicate \\logicref{WeaklyIncreasing} that we will user for \nthe verification of other algorithms.\n\n\\input{Listings/WeaklyIncreasing.acsl.tex}\n\nUsers inexperienced in formal verification often have a blind spot at the\ndifference between \\Increasing and \\WeaklyIncreasing.\n%\nBoth versions are logically equivalent,\nand proving that \\Increasing implies \\WeaklyIncreasing is even trivial.\n%\nHowever, proving the converse direction is not, and requires an induction on the\narray size~\\inl{n}, employing the transitivity of \\inl{<=} in the induction step.\n%\nHumans are trained to perform such inductions unnoticed,\nbut none of the automated provers supported by \\framac is able to perform induction.\n%\nThe following Listing contains several lemmas on the relationship of\n\\WeaklyIncreasing and \\Increasing.\n\n\\input{Listings/IncreasingLemmas.acsl.tex}\n\n\\clearpage\n\nWe usually exploit the relationship of the predicates \\Increasing and \\WeaklyIncreasing\nin the following way:\n\n\\begin{itemize}\n\\item We use the predicate \\Increasing in the preconditions and postconditions of\n      function contracts.\n\\item The \\WeaklyIncreasing is employed for assertions and loop invariants\n      whenever we have to verify that an algorithm (typically a sorting algorithm)\n      produces an increasing array.\n\\item Finally, to conclude that a \\emph{weakly increasing} array is in fact \\emph{increasing}\n      we rely on lemma\\\\\n      \\logicref{WeaklyIncreasingIncreasing} .\n\\end{itemize}\n\n\\clearpage\n\n\\input{binary-search/lower_bound}\n\\input{binary-search/upper_bound}\n\\input{binary-search/equal_range}\n\\input{binary-search/binary_search}\n\n", "meta": {"hexsha": "d5084a43d5da246d151c9aa19298323279bc80be", "size": 3239, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Informal/binary-search/binary-search-algorithms.tex", "max_stars_repo_name": "fraunhoferfokus/acsl-by-example", "max_stars_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 90, "max_stars_repo_stars_event_min_datetime": "2017-06-14T04:17:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T06:07:36.000Z", "max_issues_repo_path": "Informal/binary-search/binary-search-algorithms.tex", "max_issues_repo_name": "fraunhoferfokus/acsl-by-example", "max_issues_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2017-10-18T13:30:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-17T07:10:16.000Z", "max_forks_repo_path": "Informal/binary-search/binary-search-algorithms.tex", "max_forks_repo_name": "fraunhoferfokus/acsl-by-example", "max_forks_repo_head_hexsha": "d8472670150fb3ff4360924af2d0eb14bc80d1e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2017-06-21T13:49:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T16:27:06.000Z", "avg_line_length": 37.2298850575, "max_line_length": 93, "alphanum_fraction": 0.788823711, "num_tokens": 770, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.4214290379547736}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%                                                                 %\n%  CERNLIB manual in LaTeX form   \t                          %\n%                                                                 %\n%  Michel Goossens (for translation into LaTeX)                   %\n%  Version 2.00                                                   %\n%  Last Mod.  6 Oct 1992  1030   MG                               %\n%                                                                 %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentstyle[epsfig,11pt,fleqn,amssym,cernlib,cerndoc]{cernman}\n\\newcommand{\\Title}{CERN Program Library}%       Title for document\n\\newmathalphabet*{\\mathtt}{cmtt}{m}{n}\n\\newmathalphabet*{\\mathbf}{cmr}{b}{n}\n%\\romanfont{times}\n%\\PScommands% Initialize PS boxes\n%\\makeindex\n\\begin{document}\n%  ==================== Front material ============================\n%\\include{cernlibf}\n%\\cleardoublepage\n%  ==================== Body of text ==============================\n\\pagenumbering{arabic}\n\\setcounter{page}{1}\n \n%\\chapter{General Information}\n \n%%%%%%   Catalog of Program packages and entries%%%%\n \n\\def\\Rtnr{Catalog}%Dummy routine name to appear at bottom of page\n\\include{crnlbcat}\n\\cleardoublepage\n \n\\let\\LARGE\\large\n\\let\\Large\\large\n \n% Here come the different files to be included\n \n%%     A part     %%\n \n\\Sectitle{Arithmetic Routines}\n \n\\include{a105}\n \n%%     B part     %%\n \n\\Sectitle{Elementary Functions}\n \n\\include{b100}\n\\include{b101}\n\\include{b102}\n \n%%     C part     %%\n \n\\Sectitle{Equations and Special Functions}\n \n\\include{c200}\n\\include{c201}\n\\include{c202}\n\\include{c205}\n\\include{c207}\n\\include{c208}\n\\include{c209}\n\\include{c210}\n\\include{c300}\n\\include{c301}\n\\include{c302}\n\\include{c303}\n\\include{c304}\n\\include{c306}\n\\include{c307}\n\\include{c308}\n\\include{c309}\n\\include{c310}\n\\include{c312}\n\\include{c313}\n\\include{c315}\n\\include{c316}\n\\include{c317}\n\\include{c318}\n\\include{c320}\n\\include{c321}\n\\include{c322}\n\\include{c323}\n\\include{c324}\n\\include{c327}\n\\include{c328}\n\\include{c330}\n\\include{c331}\n%\\include{c332}\n\\include{c333}\n\\include{c334}\n\\include{c335}\n\\include{c336}\n\\include{c337}\n\\include{c338}\n\\include{c339}\n\\include{c340}\n%\\include{c341}\n\\include{c342}\n\\include{c343}\n\\include{c344}\n\\include{c345}\n\\include{c346}\n\\include{c347}\n\\include{c348}\n\\include{c349}\n%\\include{c351}\n \n%%     D part     %%\n \n\\Sectitle{Integration, Minimization, Non-linear Fitting}\n \n\\include{d101}\n\\include{d103}\n\\include{d104}\n\\include{d105}\n\\include{d107}\n\\include{d108}\n\\include{d110}\n\\include{d111}\n\\include{d113}\n\\include{d114}\n\\include{d115}\n\\include{d151}\n\\include{d201}\n\\include{d202}\n\\include{d203}\n\\include{d209}\n\\include{d300}\n\\include{d302}\n\\include{d401}\n\\include{d506}\n\\include{d507}\n\\include{d508}\n\\include{d509}\n\\include{d510}\n\\include{d601}\n\\include{d700}\n\\include{d701}\n\\include{d702}\n\\include{d703}\n\\include{d704}\n%\\include{d999}\n \n%%     E part     %%\n \n\\Sectitle{Interpolation, Approximations, Linear Fitting}\n \n\\include{e100}\n\\include{e102}\n\\include{e103}\n\\include{e104}\n\\include{e105}\n\\include{e106}\n\\include{e207}\n\\include{e208}\n\\include{e211}\n\\include{e220}\n\\include{e221}\n\\include{e230}\n\\include{e250}\n\\include{e255}\n\\include{e401}\n\\include{e406}\n\\include{e407}\n\\include{e410}\n%\\include{e999}\n \n%%     F part     %%\n \n\\Sectitle{Matrices, Vectors and Linear Equations}\n \n\\include{f001}\n\\include{f002}\n\\include{f003}\n\\include{f004}\n\\include{f010}\n\\include{f011}\n\\include{f012}\n\\include{f105}\n\\include{f106}\n\\include{f112}\n\\include{f116}\n\\include{f117}\n\\include{f118}\n\\include{f121}\n\\include{f122}\n\\include{f123}\n\\include{f150}\n\\include{f202}\n\\include{f220}\n\\include{f221}\n\\include{f222}\n\\include{f223}\n\\include{f224}\n\\include{f225}\n\\include{f230}\n\\include{f406}\n\\include{f500}\n\\include{f600}\n \n%%     G part     %%\n \n\\Sectitle{Statistical Analysis and Probability}\n \n\\include{g100}\n\\include{g101}\n\\include{g102}\n\\include{g103}\n\\include{g104}\n\\include{g105}\n\\include{g106}\n\\include{g110}\n\\include{g111}\n\\include{g900}\n\\include{g901}\n%\\include{g999}\n \n%%     H part     %%\n \n\\Sectitle{Operation Research Techniques and Management Science}\n \n\\include{h100}\n\\include{h300}\n \n%%     I part     %%\n \n\\Sectitle{Input/Output}\n \n\\include{i101}\n\\include{i202}\n\\include{i302}\n\\include{i303}\n%\\include{i999}\n \n%%     J part     %%\n \n\\Sectitle{Output and Graphical Data Presentation}\n \n\\include{j200}\n\\include{j401}\n\\include{j403}\n\\include{j509}\n\\include{j511}\n\\include{j530}\n%\\include{j551}\n%\\include{j999}\n \n%%     K part     %%\n \n%%     L part     %%\n \n\\Sectitle{Executive Routines}\n \n\\include{l210}\n\\include{l400}\n \n%%     M part     %%\n \n\\Sectitle{Data Handling}\n \n\\include{m101}\n\\include{m103}\n\\include{m104}\n\\include{m107}\n\\include{m108}\n\\include{m109}\n\\include{m214}\n\\include{m215}\n\\include{m216}\n\\include{m218}\n\\include{m220}\n\\include{m224}\n\\include{m231}\n\\include{m232}\n\\include{m233}\n\\include{m250}\n\\include{m251}\n\\include{m400}\n\\include{m409}\n\\include{m410}\n\\include{m416}\n\\include{m421}\n\\include{m422}\n\\include{m423}\n\\include{m426}\n\\include{m427}\n\\include{m428}\n\\include{m429}\n\\include{m431}\n\\include{m432}\n\\include{m433}\n\\include{m434}\n\\include{m436}\n\\include{m437}\n\\include{m438}\n\\include{m439}\n\\include{m440}\n\\include{m441}\n\\include{m442}\n\\include{m501}\n\\include{m502}\n\\include{m503}\n\\include{m506}\n\\include{m507}\n\\include{m508}\n \n%%     N part     %%\n \n\\Sectitle{Debugging, Error Handlng}\n \n\\include{n001}\n\\include{n002}\n\\include{n100}\n\\include{n103}\n\\include{n105}\n\\include{n203}\n \n%%     Q part     %%\n \n\\Sectitle{Service or Housekeeping Programming Aids}\n \n\\include{q100}\n\\include{q120}\n\\include{q121}\n\\include{q122}\n\\include{q123}\n\\include{q124}\n\\include{q180}\n\\include{q210}\n\\include{q901}\n\\include{q902}\n\\include{q904}\n%\\include{q999}\n \n%%     R part     %%\n \n\\Sectitle{Logical and Symbolic}\n \n\\include{r205}\n \n%%     T part     %%\n \n\\Sectitle{Magnet and Beam Design, Electronics}\n \n\\include{t604}\n \n%%     U part     %%\n \n\\Sectitle{Quantum Mechanics, Particle Physics}\n \n\\include{u100}\n\\include{u101}\n\\include{u102}\n\\include{u110}\n\\include{u501}\n%\\include{u999}\n \n%%     V part     %%\n\\Sectitle{Random Numbers and General Purpose Utilities}\n \n \n\\include{v100}\n\\include{v101}\n\\include{v102}\n\\include{v103}\n\\include{v104}\n\\include{v105}\n\\include{v106}\n\\include{v107}\n\\include{v108}\n\\include{v109}\n\\include{v110}\n\\include{v111}\n\\include{v112}\n\\include{v113}\n\\include{v114}\n\\include{v130}\n\\include{v150}\n\\include{v151}\n\\include{v202}\n\\include{v300}\n\\include{v301}\n\\include{v302}\n\\include{v304}\n\\include{v306}\n\\include{v401}\n\\include{v700}\n%\\include{v999}\n \n%%     W part     %%\n \n\\Sectitle{High Energy Physics Simulation, Kinematics, Phase Space}\n \n\\include{w150}\n\\include{w151}\n\\include{w505}\n\\include{w515}\n%\\include{w999}\n \n%%     X part     %%\n \n%\\Sectitle{Particle Detection, Measurement, Reconstruction}\n \n%\\include{x999}\n \n%%     Y part     %%\n \n\\Sectitle{Statistical Data Analysis and Presentation}\n \n\\include{y201}\n\\include{y250}\n\\include{y251}\n%\\include{y999}\n \n%%     Z part     %%\n \n\\Sectitle{Miscellaneous System-Dependent Facilities}\n \n\\include{z001}\n\\include{z007}\n\\include{z008}\n\\include{z009}\n\\include{z020}\n\\include{z029}\n\\include{z034}\n\\include{z035}\n\\include{z036}\n\\include{z037}\n\\include{z041}\n\\include{z042}\n\\include{z044}\n\\include{z100}\n\\include{z203}\n\\include{z204}\n\\include{z262}\n\\include{z264}\n\\include{z265}\n\\include{z267}\n\\include{z300}\n\\include{z301}\n\\include{z303}\n\\include{z304}\n\\include{z305}\n\\include{z306}\n\\include{z307}\n\\include{z308}\n\\include{z309}\n\\include{z310}\n\\include{z311}\n\\include{z312}\n \n%  ==================== Backmaterial ===========================\n\\bibliographystyle{myunsrt} % style for bibliography\n\\bibliography{/user/goossens/cnasall/cnasbibl}   % Master BibTeX file for CNAS docs\n \n\\input{\\jobname.ind} % index\n \n\\end{document}\n", "meta": {"hexsha": "1ce54cd6b4fec1b7f8a287eff570cec60f1c207e", "size": 7839, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant/crnfscr.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "shortwrups/crnfscr.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "shortwrups/crnfscr.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.0413043478, "max_line_length": 83, "alphanum_fraction": 0.6443423906, "num_tokens": 2596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.42142902819302797}}
{"text": "\\documentclass[a4paper]{article}\n\\title{Implementation of Gouraud shading in GLSL}\n\\author{Hiroka IHARA (The Univ. of Tokyo)}\n\\date{2016/10/05}\n\\usepackage{bm}\n\\begin{document}\n\\maketitle\n\\section{Basics for per-vertex shading}\n\\[\nI_{diffuse} = k_{diffuse} \\cdot I_{light} \\cdot max \\left( \\bm{N} \\cdot \\bm{L}, 0 \\right)\n\\]\nwhere $\\bm{N}$ is the normalized vertex normal in viewspace, and $\\bm{L}$ is the normalized viewspace vector pointing to the light.\n\\[\nI_{ambient} = k_{ambient} \\cdot I_{light}\n\\]\n\\[\nI_{specular} = k_{specular} \\cdot I_{light} \\cdot max \\left( \\bm{R} \\cdot \\bm{V}, 0 \\right)^{k_{reflectivity}}\n\\]\nwhere $\\bm{R}$ is calculated as $2\\bm{N}\\left(\\bm{N}\\cdot\\bm{L}\\right)-\\bm{L}$ or simply $reflect\\left(\\bm{N},-\\bm{L}\\right)$,\nand $\\bm{V}$ is the normalized viewspace vector pointing to the view, which is equivalent to the negated projection vector.\n\\end{document}\n", "meta": {"hexsha": "bf62ebba69ea6e2254e0ef9dc859857ad8f4ec23", "size": 887, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/shading.tex", "max_stars_repo_name": "pboutan/u3d", "max_stars_repo_head_hexsha": "18d1b1997b5cb24bd6ca2ac52413b0a2c4812289", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/shading.tex", "max_issues_repo_name": "pboutan/u3d", "max_issues_repo_head_hexsha": "18d1b1997b5cb24bd6ca2ac52413b0a2c4812289", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/shading.tex", "max_forks_repo_name": "pboutan/u3d", "max_forks_repo_head_hexsha": "18d1b1997b5cb24bd6ca2ac52413b0a2c4812289", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3181818182, "max_line_length": 131, "alphanum_fraction": 0.7001127396, "num_tokens": 305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4214290281930279}}
{"text": "\\chapter{A LIBRARY FOR LOCAL DIFFERENTIAL PRIVACY}\n\n\\section{Introduction in Local DP}\n\nAs we mentioned in previous chapters, there are two major forms of Differential Privacy. Having analyzed and tested the first one, \\emph{Global D.P.}, it is now time to examine \\emph{Local D.P.}, by explaining some possible protocols, as well as building our own.\n\n\nIn Local D.P., there is a significant difference compared to Global DP: there is \\emph{no trusted curator} between the data and the users, as they just want to send their data, while already being anonymized. Thus, an algorithm must perturb the data before sending it to the untrusted curator, who will then transmit it to the analysts. \n\nIn order to achieve that goal, the user must randomize the value before making it public (i.e. sending it to the untrusted curator). Then, the curator which collects the data (we will reference to him as aggregator moving forward), collects the data and tries to retrieve their original values, with a goal of producing the most accurate results possible. \n\nThus, each LDP algorithm has the following steps:\n\n\\begin{itemize}\n    \\item Each user encodes, and then perturbs the private value that he wants to make public\n    \\item Each user sends out the result of the perturbation process, with that being only the final value, as they keep the intermediate results for themselves\n    \\item The untrusted data curator collects each user's value, and implements some kind of aggregation in order to retrieve the stats that he wants from the data given to him.\n\\end{itemize}\n\nIn comparison with Global D.P., the Local model has advantages, as well as disadvantages. \nIts main advantages are:\n\\begin{itemize}\n    \\item The user is not forced to trust the data curator, as only the perturbed value is reported\n    \\item Simpler implementation of the algorithms, due to the district steps taken by both sides.\n\\end{itemize}\n\nwhile the main disadvantages are the following:\n\n\\begin{itemize}\n    \\item The noise added should be larger than the Global model, in order to satisfy the definition, thus the number of people in the dataset should be significant for accurate results to be produced.\n    \\item Because this is not always possible, many real-world applications use extremely high values of epsilon compared to what we got used to during our testing in the Global models.\n\\end{itemize}\n\nDuring this Thesis, concern was raised for the main disadvantage of L.D.P., and thus\\emph{ we will present a new protocol aiming to reduce the need for many users, while still covering the definition.} However, the definition for L.D.P. is quite different than the Global model one's.\n\n\\section{Definition of Local DP}\n\nHaving a general idea in how Local D.P. functions, it is now time to give a strict definition that we are going to depend our work on moving forward.\n\nWe can say that an algorithm $A$ satisfies ε-Local Differential Privacy, if and only if for any input $v_1$, $v_2$, we have\n\n$$ \\forall y \\in Range(A):\\ Pr[A(v_1) = y] \\leq e^{\\epsilon} * Pr[A(v_2) = y] $$\n\nwhere $Range(A)$ denotes the set of all possible outputs of the algorithm $A$.\n\nAs mentioned in Chapter 2, this definition can have many interpretations by different algorithms or protocols, but each one must produce a probabilistic space whose elements must satisfy the above equation.\n\n\n\\section{Simple Application of LDP}\n\nThe most simple of L.D.P. protocols is already mentioned in this Thesis, and is no other than the \\emph{Randomized Response} protocol. This algorithm implements the three steps mentioned in the introduction, as the user chooses a value (Yes or No), perturbs it (by the flipping of the coins), reports the perturbed value, with the sole job of the aggregator being to collect, normalize and report the values provided. It meets the definition of L.D.P., as the fraction of a pair of probabilities in the space of possible outputs (Yes, No) has always the ceiling of a real number. \n\nOur goal is to now find this ceiling, and thus denote the level of privacy that randomized response offers. In order to do this, we are going to select the possibility of the user having chose the answer \"Yes\". A simple case analysis shows that $Pr[Yes | Truth] = \\frac{3}{4}$, and of course $Pr[Yes | False] = \\frac{1}{4}$. Thus, by the definition of L.D.P., we have \n\n\\begin{align*}\n    \\frac{Pr[Yes | Truth]}{Pr[Yes | False]} = \\frac{\\frac{3}{4}}{\\frac{1}{4}} = 3 = e^\\epsilon \\Longleftrightarrow \\epsilon = ln(3)\n\\end{align*}\n\nThus, R.R. offers  $ln(3)$-differential privacy to its users. This is quite a good setting, but the restriction is that the user can only report 2 values, something not suitable for modern problems and surveys. \n\n\n\nIn R.R., we care about the total true answers of the users, and not the individual responses. Thus the metric we are going to use is the \\emph{absolute difference of the sum of the 2 vectors: the one with the truthful answers, and the one with the reported answers}. We are going to divide this result with the number of the users, in order to get the scale of the error depending on the size of the vector that was reported. The metric is expressed from the following function:\n\n\\begin{align*}\n    \\text{Error} = \\frac{|\\sum \\text{true\\_values} - \\sum \\text{reported\\_values}| }{\\text{number\\ of \\ users}}\n\\end{align*}\n\nAs always, during the creation of probabilistic distributions, one run is not enough, because of the extreme amount of noise that can occur. Thus, for each number of users we are going to run the R.R. protocol 100 times, and the final accuracy error will be produced by the mean value of those runs.\n\nHaving implemented R.R. in Python, we can now display the accuracy error of R.R. as the number of users rises. The results of the testings are shown bellow in \\textbf{Figure 4.1}.\n\n\\begin{figure}[!htb]\\centering\n    \\includegraphics[width=0.8\\textwidth]{images/rr_results.png}\n    \\caption{Accuracy Error in R.R for increasing values of epsilon}\n\\end{figure}\n\n\nWe observe that the plot behaves as expected: the protocol produces a logarithmic curve for the accuracy error, while for a large number of users (over 3000), the error stabilizes bellow $0.1$. ", "meta": {"hexsha": "59b03b414f90c327eaa6e856c6fcfa88219d273c", "size": 6189, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_paper/LDP/intro.tex", "max_stars_repo_name": "nikosgalanis/bsc-thesis", "max_stars_repo_head_hexsha": "b5521e995f266ff1aeb9fecc220650483630dc04", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2021-07-29T15:24:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T13:57:07.000Z", "max_issues_repo_path": "thesis_paper/LDP/intro.tex", "max_issues_repo_name": "nikosgalanis/bsc-thesis", "max_issues_repo_head_hexsha": "b5521e995f266ff1aeb9fecc220650483630dc04", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis_paper/LDP/intro.tex", "max_forks_repo_name": "nikosgalanis/bsc-thesis", "max_forks_repo_head_hexsha": "b5521e995f266ff1aeb9fecc220650483630dc04", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.3417721519, "max_line_length": 580, "alphanum_fraction": 0.7645823235, "num_tokens": 1465, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.421429024290842}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\n\\usepackage{amsmath}\n\\usepackage[font=footnotesize]{caption}\n\\usepackage[section]{algorithm}\n\\captionsetup[algorithm]{font=footnotesize}\n\\usepackage[numbered]{algo}\n\n% Following packages only required for this sample, not for using algo.sty in the first place!\n\\usepackage{color}\n\\usepackage{listings}\n\\lstset{language=TeX}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{dkgray}{rgb}{0.25,0.25,0.25}\n\n\\lstset{%\n  \tbackgroundcolor=\\color{white},\n  \tbasicstyle=\\footnotesize,\n  \tbreakatwhitespace=false,\n  \tbreaklines=true,\n  \tcaptionpos=b,\n  \tcommentstyle=\\color{dkgreen},\n  \tdeletekeywords={...},\n  \tescapeinside={\\%*}{*)},\n  \textendedchars=true,\n  \tframe=single,\n  \tkeepspaces=true,\n  \tkeywordstyle=\\color{blue},\n  \tlanguage=Octave,\n  \tmorekeywords={*,...},\n  \tnumbers=left,\n  \tnumbersep=5pt,\n  \tnumberstyle=\\tiny\\color{dkgray},\n  \trulecolor=\\color{dkgray},\n  \tshowspaces=false,\n  \tshowstringspaces=false, \n  \tshowtabs=false,\n  \tstepnumber=1,\n  \ttabsize=2,\n  \ttitle=\\lstname\n}\n\n\\begin{document}\n\n\t\\section{Quick Shift}\n\n\tTo use the \\lstinline!alog.sty! package for a book, update the following lines of \\lstinline!algo.sty!:\n\t\n\\begin{lstlisting}\n% Set counter to include chapter:\n% \\renewcommand{\\thealgorithm}{\\thechapter .\\arabic{algo}}\n\\renewcommand{\\thealgorithm}{\\thesection .\\arabic{algo}}\n\\end{lstlisting}\n\n\t\\begin{algorithm}[h]\n\t\t\\begin{algo}{QS}{\\label{algo:related-work-qs}\\qinput{color image $I$}\\qoutput{superpixel segmentation $S$}}\n\t\t\t\\qfor $n = 1$ \\qto $N$\\\\\n\t\t\t\tinitialize $t(x_n) = \\boldsymbol 0$\\qrof\\\\\n\t\t\t\\qfor $n = 1$ \\qto $N$\\\\\n\t\t\t\t\\qcom{$N_R(x_n)$ is the set of all pixels in the local neighborhood of size $R \\times R$ around pixel $x_n$:}\\\\\n\t\t\t\tcalculate $p(x_n) = \\sum_{x_m \\in N_R(x_n)} \\exp\\left(\\frac{-d(x_n,x_m)^2}{(2/3) R}\\right)$ \\qrof\\\\\n\t\t\t\\qfor $n = 1$ \\qto $N$\\\\\n\t\t\t\tset $t(x_n) = \\arg\\max_{x_m \\in N_R(x_n): p(x_m) > p(x_n)} \\{p(x_m)\\}$\\qrof\\\\\n\t\t\t\t\\qcom{$t$ maps each pixel to its neighbor $x_m$ with highest $p(x_m)$ if $p(x_m) > p(x_n)$;}\\\\\n\t\t\t\\qcom{$t$ can be interpreted as forest, where all pixels $x_n$ with $t(x_n) = \\boldsymbol 0$ are roots.}\\\\\n\t\t\tderive superpixel segmentation $S$ from $t$\\\\\n\t\t\t\\qreturn $S$\n\t\t\\end{algo}\n\t\t\\caption{The superpixel algorithm \\textbf{QS} proposed in \\cite{QuickShift}.}\n\t\t\\label{fig:related-work-qs-algorithm}\n\t\\end{algorithm}\n\n\t\\begin{thebibliography}{1}\n\t\t\\bibitem{QuickShift}\n\t\tA. Vedaldi,\n\t\tS. Soatto,\n\t\t\\emph{Quick shift and kernel methods for mode seeking},\n\t\tECCV,\n\t\t2008.\n\t\\end{thebibliography}\n\n\\end{document}", "meta": {"hexsha": "d81bcab9c7b379d9be7fd3c34784252fe7d3ff48", "size": 2537, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "algo-quick-shift/quick-shift.tex", "max_stars_repo_name": "magnusanatolius/latex-resources", "max_stars_repo_head_hexsha": "e29e2911a52205f69888978311562f70d14fc2a8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 306, "max_stars_repo_stars_event_min_datetime": "2015-02-12T14:54:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T03:29:03.000Z", "max_issues_repo_path": "algo-quick-shift/quick-shift.tex", "max_issues_repo_name": "magnusanatolius/latex-resources", "max_issues_repo_head_hexsha": "e29e2911a52205f69888978311562f70d14fc2a8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-04-14T06:35:22.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-05T10:16:33.000Z", "max_forks_repo_path": "algo-quick-shift/quick-shift.tex", "max_forks_repo_name": "magnusanatolius/latex-resources", "max_forks_repo_head_hexsha": "e29e2911a52205f69888978311562f70d14fc2a8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 122, "max_forks_repo_forks_event_min_datetime": "2017-02-12T20:25:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T17:12:55.000Z", "avg_line_length": 30.5662650602, "max_line_length": 115, "alphanum_fraction": 0.6838785968, "num_tokens": 894, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819591324416, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.421429018431282}}
{"text": "%%%\n%%% Statistics\n%%%\n\\part{Statistics}\n\\begin{frame}\n\\thispagestyle{empty}\n\\textbf{\\huge{Statistics}}\n\\end{frame}\n\n\\begin{frame}{Statistics Contents}\n \\tableofcontents\n\\end{frame}\n\n\n\\section{Statistic}\n\\begin{frame}[fragile]{Statistic I}\nArithmetic mean and some additional statistics \\index{Mean!mean} \\index{Describe!summarize} \\index{Describe!detail} \\index{Mean} \\index{Statistic}\n\\begin{lstlisting}\n  mean height\n  summarize height\n  summarize height, detail\n\\end{lstlisting}\n\n  \\begin{tikzpicture}[transform shape, rotate=10, overlay]\n\\node at (8,-1.5) [mybox] (box) {%\n    \\begin{minipage}[t!]{0.35\\textwidth}\n    \\tiny\\textcolor{black}{\\texttt{mean returns the standard error: $s/\\sqrt{n}$. summarize returns the standard deviation: $\\sqrt{\\sum(x-\\bar{x})^2)/n}$.}}\n    \\end{minipage}\n    };\n\\end{tikzpicture}\n\\end{frame}\n\n\n\\begin{frame}[fragile]{Statistic II}\nMinimum, maximum, arithmetic mean, median, number of observations and quartils. \\index{Minimum} \\index{Minimum!min} \\index{Maximum} \\index{Maximum!max} \\index{Mean!mean} \\index{Mean} \\index{Mean!arithmetic mean} \\index{Mean!Median} \\index{Quantile} \\index{tabstat} \\index{Range} \\index{Range!range} \\index{Quantile!q}\n\\begin{lstlisting}\n  tabstat height, statistic(min max mean median p50)\n  tabstat height, statistic(min max range mean count q) by(county)\n\\end{lstlisting}\n\n  \\begin{tikzpicture}[transform shape, rotate=10, overlay]\n\\node at (8,-1.5) [mybox] (box) {%\n    \\begin{minipage}[t!]{0.35\\textwidth}\n    \\tiny\\textcolor{black}{\\texttt{range = max - min}}\n    \\end{minipage}\n    };\n\\end{tikzpicture}\n\\end{frame}\n\n\n\\begin{frame}[fragile]{Statistics III}\nStandard deviation, standard error, variance und interquartil range. \\index{Standard deviation} \\index{Standard error} \\index{Variance} \\index{Interquartil range} \\index{tabstat} \\index{Standard deviation!sd} \\index{Variance!var} \\index{Standard error!sem} \\index{Interquartil range!iqr} \\index{Quantile!q} \\index{Skewness} \\index{Kurtosis} \\index{Skewness!skewness} \\index{Kurtosis!kurtosis}\n\\begin{lstlisting}\n tabstat height, statistic(sd sem var q iqr)\n\\end{lstlisting}\nSkewness and kurtosis\n\\begin{lstlisting}\n  tabstat height, statistics(skewness kurtosis)\n\\end{lstlisting}\n\n  \\begin{tikzpicture}[transform shape, rotate=10, overlay]\n\\node at (8,-1.5) [mybox] (box) {%\n    \\begin{minipage}[t!]{0.35\\textwidth}\n    \\tiny\\textcolor{black}{\\texttt{iqr = q3 - q1}}\n    \\end{minipage}\n    };\n\\end{tikzpicture}\n\\end{frame}\n\n\\section{Tables}\n\\begin{frame}[fragile]{Tables} \\index{Table!tab} \\index{Table!tab, summarize()} \\index{Table}\nWe already had \\texttt{summarize} and \\texttt{tab}, let us combine them\n\\begin{lstlisting}\n  tab county, summarize(height)\n\\end{lstlisting}\n\\end{frame}\n\n\\subsection{Cross tabs}\n\\begin{frame}[fragile]{Cross tabs} \\index{Table!tab} \\index{Table!tab1} \\index{Table!tab2} \\index{Table!cross tab}\nCreate a cross tab with\n\\begin{lstlisting}\n  tab school county\n\\end{lstlisting}\nAnd some more tables\n\\begin{lstlisting}\n  ** tabs of each variable\n  tab1 sex county school\n  ** cross tabs of ab bc ac\n  tab2 sex county school\n\\end{lstlisting}\n\\end{frame}\n\n\\subsection{Chi, V and Phi}\n\\begin{frame}[fragile]{Cross tabs II} \\index{Table!cross tab} \\index{Table!$\\chi^2$} \\index{Table!chi-square} \\index{Table!chi} \\index{Table!tab} \\index{Table!Cramers V} \\index{Table!tab exp} \\index{Table!tab col} \\index{Table!tab row}\nLet us recapitulate Statistics I, we will do some tests \\footnote{or see e.g. \\textcite{Krebs10} oder \\textcite{Agresti09}.}\n\\begin{lstlisting}\n** chi^2\ntab sex county, chi\n** cramers v\ntab sex county, V\n\n** manual\ntab sex county, exp col row\n** phi and for 2x2 tabs V\ndi (1013*1002 - 925*1131) / (2144*1927*1938*2133)^(1/2) \n** chi^2\ndi 4071 *(-.00753735)^2\n** usual way to compute V\ndi (.23128021 / 4071 * (2 - 1) )^(1/2) // V\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Numlabel}\nYou can add numeric values to your variable labels \\index{Label!numlabel}\n\\begin{lstlisting}\n  ** numeric labels on for all variables\n  numlabel _all, add\n  ** and off\n  numlabel _all, remove\n\\end{lstlisting}\n\\end{frame}\n\n\\section{Inference}\n\\begin{frame}[fragile]{T-Test} \\index{T-Test!ttest} \\index{T-Test}\nAnd finally let us have a look at some test-statistics\n\\begin{lstlisting}\n  ** compare \n  tab sex, sum(bmi)\n  ttest bmi, by(sex)\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{And much more to come \\dots} \\index{Regression!regress} \\index{Regression!logit} \\index{Regression!mlog}\nRegression\n\\begin{lstlisting}\n  regress\n  logit\n  mlog\n\\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}\n\\thispagestyle{empty}\n To be continued.\n\\end{frame}\n", "meta": {"hexsha": "d1cd70facfd70276762518cdd6730aefb3958507", "size": 4618, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Statistik.tex", "max_stars_repo_name": "JanMarvin/StataFolien", "max_stars_repo_head_hexsha": "da7f861495de6aa86a967fbed76ca647ea6ad87c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/Statistik.tex", "max_issues_repo_name": "JanMarvin/StataFolien", "max_issues_repo_head_hexsha": "da7f861495de6aa86a967fbed76ca647ea6ad87c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Statistik.tex", "max_forks_repo_name": "JanMarvin/StataFolien", "max_forks_repo_head_hexsha": "da7f861495de6aa86a967fbed76ca647ea6ad87c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6301369863, "max_line_length": 392, "alphanum_fraction": 0.7243395409, "num_tokens": 1546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.42136932840276536}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{geometry}\n\\usepackage{graphicx}\n\n\\geometry{top=1in, bottom=1in, left=1in, right=1in}\n\n\\title{Analysis of Music in Machine Learning}\n\\author{Eben Kadile}\n\\date{July 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Objective}\n\nWe want to better understand the temporal and statistical structure of music, and how machine learning systems detect this structure and exploit it for music prediction and synthesis\n\n\\section{Regression}\n\nBecause fitting a linear regression model is a convex optimization problem, we would like to start by looking at the result of fitting the next set of notes in piano roll music based on the last set of notes.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/regression_weights.png}\n    \\caption{Here we plot the weights of the trained 1-step logistic regression model. Red indicates positivity and blue indicates negativity. As can be inferred, only notes 27 through 75 appear in the dataset. If a note is played in one time step, it is likely to be played in the next, and the probability of a note far away from the current note being played is low.}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/regression_bias.png}\n    \\caption{Here we plot the bias of the trained 1-step logistic regression model. The color scale is different from that of the weights.}\n\\end{figure}\n\nUsing the information encoded in the weights and bias, we should be able to recover the fact that all the songs were in C major, but I don't know how to do that yet.\n\n\n\\section{Latent LDS}\n\nOne can initialize a latent LDS so that it forgets everything at every time step and behaves like the regression model. Hopefully, this initialization is good for finding a superior solution to the problem using the LDS. We can also use the weights of the trained latent LDS to initialize a tanh RNN. First, we investigate the various ways the hidden weights of the latent LDS can be initialized.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/jsb_lds_losses.png}\n    \\caption{Loss of different latent LDS models compared to regression.}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/jsb_lds_accs.png}\n    \\caption{Accuracy of different latent LDS models compared to regression.}\n\\end{figure}\n\nAs we can see from these comparisons, scaled down critical (power-law) initialization performs the best while overfitting the least (having weights high in magnitude seems to encourage overfitting, especially for tanh RNNs).\n\nWe will plot the weights and hidden eigenvalues of this model.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/scrit_lds_in_weights.png}\n    \\caption{Input weights of scaled down critical initialization.}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/scrit_lds_hid_weights.png}\n    \\caption{Hidden weights of scaled down critical initialization.}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/scrit_lds_out_weights.png}\n    \\caption{Output weights of scaled down critical initialization.}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{figures/scrit_lds_eigs.png}\n    \\caption{Eigenvalues of hidden weight matrix after training of scaled down power law LDS.}\n\\end{figure}\n\n\\section{RNNs}\n\nA tanh RNN can be initialized using the weights of the trained LDS. This increases performance noticeably, but in the case of some initializations it drastically increases overfitting.\n\n\\end{document}\n", "meta": {"hexsha": "3be9e03f10f1ee3f74e9923220ad8ebeea1dd23c", "size": 3566, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/report.tex", "max_stars_repo_name": "catniplab/ML-music-analysis", "max_stars_repo_head_hexsha": "793d54ed16166fbcd9acf4eec24998892334e064", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/report.tex", "max_issues_repo_name": "catniplab/ML-music-analysis", "max_issues_repo_head_hexsha": "793d54ed16166fbcd9acf4eec24998892334e064", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/report.tex", "max_forks_repo_name": "catniplab/ML-music-analysis", "max_forks_repo_head_hexsha": "793d54ed16166fbcd9acf4eec24998892334e064", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-01T22:57:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-01T22:57:56.000Z", "avg_line_length": 40.0674157303, "max_line_length": 396, "alphanum_fraction": 0.7807066741, "num_tokens": 842, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4213693249477455}}
{"text": "\\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%\r\n\\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}\r\n\\usepackage[all,cmtip]{xy}\r\n\\usepackage{amsfonts}\r\n\\usepackage{amssymb}\r\n\\usepackage{framed}\r\n\\usepackage{amsmath}\r\n\\usepackage{comment}\r\n\\usepackage{color}\r\n\\usepackage{hyperref}\r\n\\usepackage[sc]{mathpazo}\r\n\\usepackage[T1]{fontenc}\r\n\\usepackage{amsthm}\r\n%TCIDATA{OutputFilter=latex2.dll}\r\n%TCIDATA{Version=5.50.0.2960}\r\n%TCIDATA{LastRevised=Monday, September 11, 2017 20:30:30}\r\n%TCIDATA{SuppressPackageManagement}\r\n%TCIDATA{<META NAME=\"GraphicsSave\" CONTENT=\"32\">}\r\n%TCIDATA{<META NAME=\"SaveForMode\" CONTENT=\"1\">}\r\n%TCIDATA{BibliographyScheme=Manual}\r\n%BeginMSIPreambleData\r\n\\providecommand{\\U}[1]{\\protect\\rule{.1in}{.1in}}\r\n%EndMSIPreambleData\r\n\\theoremstyle{definition}\r\n\\newtheorem{theo}{Theorem}[section]\r\n\\newenvironment{theorem}[1][]\r\n{\\begin{theo}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{theo}}\r\n\\newtheorem{lem}[theo]{Lemma}\r\n\\newenvironment{lemma}[1][]\r\n{\\begin{lem}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{lem}}\r\n\\newtheorem{prop}[theo]{Proposition}\r\n\\newenvironment{proposition}[1][]\r\n{\\begin{prop}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{prop}}\r\n\\newtheorem{defi}[theo]{Definition}\r\n\\newenvironment{definition}[1][]\r\n{\\begin{defi}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{defi}}\r\n\\newtheorem{remk}[theo]{Remark}\r\n\\newenvironment{remark}[1][]\r\n{\\begin{remk}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{remk}}\r\n\\newtheorem{coro}[theo]{Corollary}\r\n\\newenvironment{corollary}[1][]\r\n{\\begin{coro}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{coro}}\r\n\\newtheorem{conv}[theo]{Convention}\r\n\\newenvironment{condition}[1][]\r\n{\\begin{conv}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{conv}}\r\n\\newtheorem{quest}[theo]{Question}\r\n\\newenvironment{algorithm}[1][]\r\n{\\begin{quest}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{quest}}\r\n\\newtheorem{warn}[theo]{Warning}\r\n\\newenvironment{conclusion}[1][]\r\n{\\begin{warn}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{warn}}\r\n\\newtheorem{conj}[theo]{Conjecture}\r\n\\newenvironment{conjecture}[1][]\r\n{\\begin{conj}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{conj}}\r\n\\newtheorem{exmp}[theo]{Example}\r\n\\newenvironment{example}[1][]\r\n{\\begin{exmp}[#1]\\begin{leftbar}}\r\n{\\end{leftbar}\\end{exmp}}\r\n\\newenvironment{statement}{\\begin{quote}}{\\end{quote}}\r\n\\iffalse\r\n\\newenvironment{proof}[1][Proof]{\\noindent\\textbf{#1.} }{\\ \\rule{0.5em}{0.5em}}\r\n\\fi\r\n\\newenvironment{verlong}{}{}\r\n\\newenvironment{vershort}{}{}\r\n\\newenvironment{noncompile}{}{}\r\n\\excludecomment{verlong}\r\n\\includecomment{vershort}\r\n\\excludecomment{noncompile}\r\n\\newcommand{\\kk}{\\mathbf{k}}\r\n\\newcommand{\\id}{\\operatorname{id}}\r\n\\newcommand{\\ev}{\\operatorname{ev}}\r\n\\newcommand{\\Comp}{\\operatorname{Comp}}\r\n\\newcommand{\\bk}{\\mathbf{k}}\r\n\\newcommand{\\Nplus}{\\mathbb{N}_{+}}\r\n\\newcommand{\\NN}{\\mathbb{N}}\r\n\\let\\sumnonlimits\\sum\r\n\\let\\prodnonlimits\\prod\r\n\\renewcommand{\\sum}{\\sumnonlimits\\limits}\r\n\\renewcommand{\\prod}{\\prodnonlimits\\limits}\r\n\\setlength\\textheight{22.5cm}\r\n\\setlength\\textwidth{15cm}\r\n\\ihead{Function-field analogue for symmetric functions?}\r\n\\ohead{\\today}\r\n\\begin{document}\r\n\r\n\\title{Do the symmetric functions have a function-field analogue?}\r\n\\author{Darij Grinberg}\r\n\\date{draft, version 1.4,\r\n%TCIMACRO{\\TeXButton{TeX field}{\\today}}%\r\n%BeginExpansion\r\n\\today\r\n%EndExpansion\r\n}\r\n\\maketitle\r\n\\tableofcontents\r\n\r\n\\subsection{Introduction (Abstract?)}\r\n\r\nThis is a preliminary report on a question that is almost naive: Is there a\r\nring (or another structure) that has the same relation to the ring $\\Lambda$\r\nof symmetric functions as $\\mathbb{F}_{q}$ has to the \\textquotedblleft\r\nmythical field $\\mathbb{F}_{1}$\\textquotedblright\\ ?\r\n\r\nThis question allows for at least two different interpretations. One of them\r\nis just about $q$-deforming the structure coefficients of the symmetric\r\nfunctions in such a way that (some of) their combinatorial interpretations are\r\nreinterpreted (i.e., counting sets becomes counting $\\mathbb{F}_{q}$-vector\r\nspaces). This naturally leads to Hall algebras, studied e.g. in\r\n\\cite{dyckerhoff}. A different option, however, presents itself if we are\r\nwilling to replace the bases of $\\Lambda$ itself (rather than just its\r\nstructure coefficients). Namely, recall that all (or most) of the usual bases\r\nof $\\Lambda$ are indexed by integer partitions. An integer partition can be\r\nregarded as a weakly decreasing sequence of positive integers, or,\r\nequivalently, a conjugacy class of a permutation in a symmetric group. A\r\nnatural \\textquotedblleft$\\mathbb{F}_{q}$-analogue\\textquotedblright\\ of an\r\ninteger partition, thus, is a conjugacy class of a matrix in\r\n$\\operatorname*{GL}\\nolimits_{n}\\left(  \\mathbb{F}_{q}\\right)  $. Could we\r\nfind a ring (or anything similar -- a commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra sounds like a reasonable thing to expect) which plays a\r\nsimilar role to $\\Lambda$ and whose bases are indexed by these $\\mathbb{F}%\r\n_{q}$-analogues?\r\n\r\nThis report is a bait-and-switch, as I do not have a good answer to this\r\nquestion. Instead I recall the classical interpretation of the ring $\\Lambda$\r\nas the coordinate ring of the affine group of Witt vectors (\\cite[\\S 9--\\S 10]%\r\n{hw-witt1}), and construct an $\\mathbb{F}_{q}$-analogue of the affine group of\r\nWitt vectors. This analogue has a coordinate ring, which can reasonably be\r\ncalled an $\\mathbb{F}_{q}$-analogue of $\\Lambda$. But this answer is lacking\r\nsomething very important: the combinatorial bases. The most interesting\r\nstructure on the ring $\\Lambda$ of symmetric functions is not so much its Hopf\r\nalgebra structure, but its various bases, such as the homogeneous symmetric\r\nfunctions $\\left(  h_{\\lambda}\\right)  _{\\lambda\\in\\operatorname*{Par}}$, the\r\nelementary symmetric functions $\\left(  e_{\\lambda}\\right)  _{\\lambda\r\n\\in\\operatorname*{Par}}$ and the Schur functions $\\left(  s_{\\lambda}\\right)\r\n_{\\lambda\\in\\operatorname*{Par}}$. I am unable to find a counterpart to any of\r\nthe bases just mentioned in the $\\mathbb{F}_{q}$-analogue of $\\Lambda$\r\nsuggested. All I can offer is an analogue of the power-sum functions $\\left(\r\np_{\\lambda}\\right)  _{\\lambda\\in\\operatorname*{Par}}$ (which do not even form\r\na basis, although with functoriality they are sufficient for many\r\ncomputational purposes) and of a basis $\\left(  w_{\\lambda}\\right)\r\n_{\\lambda\\in\\operatorname*{Par}}$ defined in \\cite[Exercise 2.9.3\r\n(c)]{reiner-hopf} (which, while having interesting properties, hardly feels at\r\nhome in combinatorics). So the $\\mathbb{F}_{q}$-analogue of $\\Lambda$ I find\r\nis somewhat of an empty shell. Still, there are some surprises and my hope is\r\nnot lost that it can be made whole.\r\n\r\nJames Borger had a significant role in the studies made below. In particular,\r\nhe suggested to me to look for analogues of Theorem \\ref{thm.Witt.frob.au} and\r\nTheorem \\ref{thm.Witt.AH} (which I found -- Theorem\r\n\\ref{thm.carlitz.Witt.frob.au} and Theorem \\ref{thm.carlitz.Witt.AH}),\r\nconsidering them as a litmus test that shows whether a functor really deserves\r\nto be called a Witt vector functor.\r\n\r\nThe $\\mathbb{F}_{q}$-analogue of the Witt vectors uses the \\textit{Carlitz\r\npolynomials}; a highly readable introduction to these polynomials appears in\r\n\\cite{kc-carlitz}.\r\n\r\nThis report is built as follows: In Section \\ref{sect.nots}, we introduce\r\nnotations and present basic definitions. In Section \\ref{sect.carlitzwitt}, we\r\nremind the reader of a construction (actually, one of many constructions) of\r\nthe Witt vectors, and then introduce the $\\mathbb{F}_{q}$-analogue of this\r\nconstruction. In Section \\ref{sect.proofs}, we shall give detailed proofs for\r\nsome of the claims made before. (This section is still under construction, so\r\nonly few of the proofs are available.) In Section \\ref{sect.tinfoil}, we\r\nspeculate on how this analogue could lead to an $\\mathbb{F}_{q}$-analogue of\r\n$\\Lambda$. In Section \\ref{sect.log}, we prove a formula for the so-called\r\nCarlitz logarithm which, while not having any direct relation to the rest of\r\nthis report, has emerged in my experiments in connection to it.\r\n\r\nBeing a preliminary report, this one will occasionally make for some rough\r\nreading, although I am trying to make the more-or-less finished parts (Section\r\n\\ref{sect.carlitzwitt}) more-or-less readable. The reader is assumed to know\r\nabout Witt vectors (\\cite{rabinoff-witt} or \\cite{hw-witt1} or \\cite[\\S 1]%\r\n{hesselholt-drw}) and a bit about Carlitz polynomials (\\cite{kc-carlitz}).\r\nSymmetric functions will only be really used in Section \\ref{sect.tinfoil}.\r\n\r\n\\subsection{Remark on Borger's work}\r\n\r\nIn \\cite[\\S 1--\\S 2]{jb-bg1}, James Borger has generalized the notion of Witt\r\nvectors to a rather broad setting, which includes both the classical and the\r\n\\textquotedblleft nested\\textquotedblright\\ Witt vectors. His generalization\r\nalso includes my Carlitz-Witt functor $W_{N}$ in Theorem \\ref{thm.Witt.class}\r\nbelow, namely when one takes $R=\\mathbb{F}_{q}\\left[  T\\right]  $ and\r\n$E=\\left\\{  \\text{all maximal ideals of }R\\right\\}  $. We have yet to fill in\r\nthe details, but in a nutshell, the reason why our constructions are\r\nequivalent is that the universal property of our $W_{N}\\left(  B\\right)  $\r\ngiven in Corollary \\ref{cor.carlitz.Witt.frob.adjoint} below is the same as\r\nthe one for $W_{R,E}^{\\operatorname*{fl}}\\left(  A\\right)  $ in\r\n\\cite[Proposition 1.9 (c)]{jb-bg1} (up to technicalities). Thus, it appears\r\nlikely that several of the results below are particular cases of results from\r\n\\cite{jb-bg1}. Nevertheless, our approach to the Carlitz-Witt functor is\r\ndifferent from Borger's, and somewhat more explicit.\r\n\r\n\\section{\\label{sect.nots}Notations}\r\n\r\n\\subsection{General number theory}\r\n\r\nI use the symbol $\\mathbb{P}$ for the set of all primes. Further, $\\mathbb{N}$\r\ndenotes the set $\\left\\{  0,1,2,...\\right\\}  $, and $\\mathbb{N}_{+}$ the set\r\n$\\left\\{  1,2,3,...\\right\\}  $.\r\n\r\nA \\textit{nest} means a nonempty subset $N$ of $\\mathbb{N}_{+}$ such that for\r\nevery element $d\\in N$, every divisor of $d$ lies in $N$. What I call\r\n\\textquotedblleft nest\\textquotedblright\\ is called a \\textquotedblleft\r\nnonempty truncation set\\textquotedblright\\ by some authors (e.g., by James\r\nBorger in some of his work), and a \\textquotedblleft divisor-stable\r\nset\\textquotedblright\\ by others (e.g., by Joseph Rabinoff in\r\n\\cite{rabinoff-witt}).\r\n\r\nFor every prime $p$, the nest $\\left\\{  1,p,p^{2},p^{3},...\\right\\}  =\\left\\{\r\np^{i}\\ \\mid\\ i\\in\\mathbb{N}\\right\\}  $ is called $p^{\\mathbb{N}}$.\r\n\r\nFor any prime $p$ and any $n\\in\\mathbb{Z}$, we denote by $v_{p}\\left(\r\nn\\right)  $ the largest nonnegative integer $m$ satisfying $p^{m}\\mid n$; this\r\nis set to be $+\\infty$ if $n=0$.\r\n\r\nFor any $n\\in\\mathbb{N}_{+}$, we denote by $\\operatorname{PF}n$ the set of all\r\nprime divisors of $n$.\r\n\r\nWe let $\\mu$ denote the M\\\"{o}bius function and $\\phi$ the Euler totient\r\nfunction (both are defined on $\\mathbb{N}_{+}$).\r\n\r\nFor every ring $R$ and indeterminate $T$, we denote by $R\\left[  T\\right]\r\n_{+}$ the set of all \\textbf{monic} polynomials in the indeterminate $T$ over\r\n$R$. (All rings are supposed to have a unity.)\r\n\r\nWe consider polynomials over fields to be analogous to integers.\\footnote{This\r\nis a well-known analogy, often taught in number theory classes.} Under this\r\nanalogy, monic polynomials correspond to positive integers; divisibility of\r\npolynomials corresponds to divisibility of integers; monic irreducible\r\npolynomials correspond to primes. Thus, for example, if $R$ is a field and\r\n$M\\in R\\left[  T\\right]  _{+}$ is a monic polynomial, then a sum like\r\n$\\sum\\limits_{D\\mid M}a_{D}$ is to be read as a sum over all \\textbf{monic}\r\ndivisors of $M$, not over all arbitrary divisors of $M$. Moreover, if $R$ is a\r\nfield and $M\\in R\\left[  T\\right]  _{+}$ is a monic polynomial, then\r\n$\\operatorname*{PF}M$ will denote the set of all monic irreducible divisors of\r\n$M$ (rather than all irreducible divisors of $M$). Finally, if $\\pi$ is an\r\nirreducible polynomial in $R\\left[  T\\right]  _{+}$ and $f$ is any polynomial\r\nin $R\\left[  T\\right]  _{+}$ (for a field $R$), then $v_{\\pi}\\left(  f\\right)\r\n$ means the largest nonnegative integer $m$ satisfying $\\pi^{m}\\mid f$; this\r\nis set to be $+\\infty$ if $f=0$.\r\n\r\n\\subsection{Algebra}\r\n\r\nWe denote by $\\mathbf{CRing}$ the category of commutative rings, and by\r\n$\\mathbf{CRing}_{R}$ the category of commutative $R$-algebras for a fixed\r\ncommutative ring $R$. Also, for any ring $R$, we denote by $_{R}\\mathbf{Mod}$\r\nthe category of left $R$-modules.\r\n\r\nWe denote by $\\Lambda$ the ring of symmetric functions over $\\mathbb{Z}$.\r\n(This is also known as $\\mathbf{Symm}$ or $Sym$. See \\cite[\\S 2]{reiner-hopf}\r\nand \\cite[Chapter 7]{stanley-ec2} for studies of this ring $\\Lambda$.)\r\n\r\n\\subsection{Carlitz polynomials}\r\n\r\nIn discussing Carlitz polynomials, I use the notations from Keith Conrad's\r\n\\cite{kc-carlitz} (but I'm using blackboard bold instead of boldface for\r\nlabelling rings; so what Conrad calls $\\mathbf{F}_{p}$ will be called\r\n$\\mathbb{F}_{p}$ here, etc.). In particular, let $q$ be a prime power. For any\r\n$M\\in\\mathbb{F}_{q}\\left[  T\\right]  $, the Carlitz polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ corresponding to the\r\npolynomial $M$ will be denoted by $\\left[  M\\right]  $. Let us recall how it\r\nis defined:\r\n\r\n\\begin{definition}\r\n\\label{def.carlitzpoly}For every $n\\in\\mathbb{N}$, define a polynomial\r\n$\\left[  T^{n}\\right]  \\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $\r\nrecursively, by setting $\\left[  T^{0}\\right]  =X$ and $\\left[  T^{n}\\right]\r\n=\\left[  T^{n-1}\\right]  ^{q}+T\\left[  T^{n-1}\\right]  $ for every $n\\geq1$.\r\nFor example,%\r\n\\begin{align*}\r\n\\left[  T^{0}\\right]   &  =X;\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left[  T^{1}\\right]\r\n=\\left[  T^{0}\\right]  ^{q}+T\\left[  T^{0}\\right]  =X^{q}+TX;\\\\\r\n\\left[  T^{2}\\right]   &  =\\left[  T^{1}\\right]  ^{q}+T\\left[  T^{1}\\right]\r\n=\\left(  X^{q}+TX\\right)  ^{q}+T\\left(  X^{q}+TX\\right)  =X^{q^{2}}+\\left(\r\nT^{q}+T\\right)  X^{q}+T^{2}X.\r\n\\end{align*}\r\n(Here, we have used the fact that taking the $q$-th power is an $\\mathbb{F}%\r\n_{q}$-algebra endomorphism of $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $.)\r\n\r\nNow, if $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $, then we define a polynomial\r\n$\\left[  M\\right]  \\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ to\r\nbe $a_{0}\\left[  T^{0}\\right]  +a_{1}\\left[  T^{1}\\right]  +\\cdots\r\n+a_{k}\\left[  T^{k}\\right]  $, where the polynomial $M$ is written in the form\r\n$M=a_{0}T^{0}+a_{1}T^{1}+\\cdots+a_{k}T^{k}$. (In other words, we define a\r\npolynomial $\\left[  M\\right]  \\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $ in such a way that $\\left[  M\\right]  $ depends $\\mathbb{F}_{q}%\r\n$-linearly on $M$, and that our new definition of $\\left[  M\\right]  $ does\r\nnot conflict with our existing definition of $\\left[  T^{n}\\right]  $ for\r\n$n\\in\\mathbb{N}$.) We call $\\left[  M\\right]  $ the \\textit{Carlitz\r\npolynomial} corresponding to $M$.\r\n\\end{definition}\r\n\r\nCarlitz polynomials can be used to take the above-mentioned analogy between\r\n$\\mathbb{Z}$ and $\\mathbb{F}_{q}\\left[  T\\right]  $ to a new level. Namely,\r\nevaluating a Carlitz polynomial $\\left[  M\\right]  $ at an element $a$ of a\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$ can be viewed as\r\nthe analogue of taking the $m$-th power of an element $a$ of a commutative\r\nring $A$.\r\n\r\nNotice that%\r\n\\begin{equation}\r\n\\left[  \\pi\\right]  \\left(  X\\right)  \\equiv X^{q^{\\deg\\pi}}\\operatorname{mod}%\r\n\\pi\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any monic irreducible }\\pi\\in\\mathbb{F}%\r\n_{q}\\left[  T\\right]  . \\label{carlitz-piX}%\r\n\\end{equation}\r\n(This is proven in \\cite[Theorem 2.11]{kc-carlitz} in the case when $q$ is a\r\nprime. In the general case, the proof is analogous.)\r\n\r\nIn the Carlitz context there is an obvious analogue of the M\\\"{o}bius\r\nfunction: it is simply the M\\\"{o}bius function of the lattice $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  _{+}$ (whose partial order is the divisibility\r\nrelation). In other words, it is the function $\\mu:\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}\\rightarrow\\left\\{  -1,0,1\\right\\}  $ defined by%\r\n\\[\r\n\\mu\\left(  M\\right)  =%\r\n\\begin{cases}\r\n\\left(  -1\\right)  ^{\\left\\vert \\operatorname*{PF}M\\right\\vert }, & \\text{if\r\n}M\\text{ is squarefree;}\\\\\r\n0, & \\text{if }M\\text{ is not squarefree}%\r\n\\end{cases}\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}.\r\n\\]\r\nYet, in the Carlitz context, there are two reasonable analogues of the Euler\r\ntotient function. Let us give their definitions (which both are taken from\r\n\\cite{kc-carlitz}):\r\n\r\n\\textbf{1.} The first analogue is the function $\\varphi_{C}:\\mathbb{F}%\r\n_{q}\\left[  T\\right]  _{+}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  _{+}$\r\ndefined by%\r\n\\[\r\n\\varphi_{C}\\left(  M\\right)  =M\\prod\\limits_{\\pi\\in\\operatorname*{PF}M}\\left(\r\n1-\\dfrac{1}{\\pi}\\right)  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)  \\dfrac\r\n{M}{D}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }M\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}.\r\n\\]\r\nSome properties of this $\\varphi_{C}$ are shown in \\cite[Theorem\r\n4.5]{kc-carlitz}. In particular, every $M\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}$ satisfies $M=\\sum\\limits_{D\\mid M}\\varphi_{C}\\left(  D\\right)  $.\r\n\r\n\\textbf{2.} The second analogue is the function $\\varphi:\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}\\rightarrow\\mathbb{N}_{+}$ defined by%\r\n\\[\r\n\\varphi\\left(  M\\right)  =q^{\\deg M}\\prod\\limits_{\\pi\\in\\operatorname*{PF}%\r\nM}\\left(  1-\\dfrac{1}{q^{\\deg\\pi}}\\right)  =\\sum\\limits_{D\\mid M}\\mu\\left(\r\nD\\right)  q^{\\deg\\left(  M / D\\right)  }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all\r\n}M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}.\r\n\\]\r\nThis function appears in \\cite[Section 6]{kc-carlitz}. It has the property\r\nthat $\\varphi\\left(  M\\right)  \\equiv\\mu\\left(  M\\right)  \\operatorname{mod}p$\r\nfor every $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ (where\r\n$p=\\operatorname*{char}\\mathbb{F}_{q}$). Thus, $\\varphi\\left(  M\\right)\r\n=\\mu\\left(  M\\right)  $ in $\\mathbb{F}_{q}$. To us, this makes this function\r\n$\\varphi$ less interesting than $\\varphi_{C}$.\r\n\r\nThe existence of two different analogues of the same thing is a phenomenon\r\nthat we will see a few more times in this theory.\r\n\r\n\\section{\\label{sect.carlitzwitt}The Carlitz-Witt suite}\r\n\r\n\\subsection{The classical ghost-Witt equivalence theorem}\r\n\r\nThere are several approaches to the notion of Witt vectors. One of these\r\napproaches is based on the following theorem (the ``ghost-Witt equivalence\r\ntheorem'', also known in parts as \\textquotedblleft Dwork's\r\nlemma\\textquotedblright):\r\n\r\n\\begin{theorem}\r\n\\label{thm.gW}Let $N$ be a nest. Let $A$ be a commutative ring. For every\r\n$n\\in N$, let $\\varphi_{n}:A\\rightarrow A$ be an endomorphism of the additive\r\ngroup $A$.\r\n\r\nFurther, let us make three more assumptions:\r\n\r\n\\textit{Assumption 1:} For every $n\\in N$, the map $\\varphi_{n}$ is an\r\nendomorphism of the \\textbf{ring} $A$.\r\n\r\n\\textit{Assumption 2:} We have $\\varphi_{p}\\left(  a\\right)  \\equiv\r\na^{p}\\operatorname{mod}pA$ for every $a\\in A$ and $p\\in\\mathbb{P}\\cap N$.\r\n\r\n\\textit{Assumption 3:} We have $\\varphi_{1}=\\operatorname*{id}$, and we have\r\n$\\varphi_{n}\\circ\\varphi_{m}=\\varphi_{nm}$ for every $n\\in N$ and every $m\\in\r\nN$ satisfying $nm\\in N$.\r\n\r\nLet $\\left(  b_{n}\\right)  _{n\\in N}\\in A^{N}$ be a family of elements of $A$.\r\nThen, the following assertions $\\mathcal{C}$, $\\mathcal{D}$, $\\mathcal{E}$,\r\n$\\mathcal{F}$, $\\mathcal{G}$, $\\mathcal{H}$, and $\\mathcal{J}$ are equivalent:\r\n\r\n\\textit{Assertion }$\\mathcal{C}$\\textit{:} Every $n\\in N$ and every\r\n$p\\in\\operatorname{PF}n$ satisfy%\r\n\\[\r\n\\varphi_{p}\\left(  b_{n / p}\\right)  \\equiv b_{n}\\operatorname{mod}%\r\np^{v_{p}\\left(  n\\right)  }A.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{D}$\\textit{:} There exists a family $\\left(\r\nx_{n}\\right)  _{n\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{n}=\\sum_{d\\mid n}dx_{d}^{n / d}\\text{ for every }n\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{E}$\\textit{:} There exists a family $\\left(\r\ny_{n}\\right)  _{n\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{n}=\\sum_{d\\mid n}d\\varphi_{n / d}\\left(  y_{d}\\right)  \\text{ for\r\nevery }n\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{F}$\\textit{:} Every $n\\in N$ satisfies%\r\n\\[\r\n\\sum_{d\\mid n}\\mu\\left(  d\\right)  \\varphi_{d}\\left(  b_{n / d}\\right)  \\in\r\nnA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{G}$\\textit{:} Every $n\\in N$ satisfies%\r\n\\[\r\n\\sum_{d\\mid n}\\phi\\left(  d\\right)  \\varphi_{d}\\left(  b_{n / d}\\right)  \\in\r\nnA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{H}$\\textit{:} Every $n\\in N$ satisfies%\r\n\\[\r\n\\sum_{i=1}^{n}\\varphi_{n / \\gcd\\left(  i,n\\right)  }\\left(  b_{\\gcd\\left(\r\ni,n\\right)  }\\right)  \\in nA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion $\\mathcal{J}$:} There exists a ring homomorphism from the\r\nring $\\Lambda$ to $A$ which sends $p_{n}$ (the $n$-th power sum symmetric\r\nfunction) to $b_{n}$ for every $n\\in N$.\r\n\\end{theorem}\r\n\r\n\\begin{definition}\r\nThe families $\\left(  b_{n}\\right)  _{n\\in N}\\in A^{N}$ which satisfy the\r\nequivalent assertions $\\mathcal{C}$, $\\mathcal{D}$, $\\mathcal{E}$,\r\n$\\mathcal{F}$, $\\mathcal{G}$, $\\mathcal{H}$, and $\\mathcal{J}$ of Theorem\r\n\\ref{thm.gW} will be called \\textit{ghost-Witt vectors} (over $A$).\r\n\\end{definition}\r\n\r\nThere are many variations on Theorem \\ref{thm.gW}. An easy way to get a more\r\nintuitive particular case of Theorem \\ref{thm.gW} is to set $\\varphi\r\n_{n}=\\operatorname*{id}\\nolimits_{A}$ for all $n\\in N$, after which\r\nAssumptions 1 and 3 become tautologies. However, Assumption 2 is not\r\nguaranteed to hold in this setting; but it holds in $\\mathbb{Z}$, and more\r\ngenerally in binomial rings, and in some non-torsionfree rings as well.\r\nUnfortunately, this case is in some sense too simple: it is too weak to yield\r\nthe basic properties of Witt vectors (such as the well-definedness of\r\naddition, multiplication, Frobenius and Verschiebung). Instead one needs the\r\ncase when $A$ is a polynomial ring $\\mathbb{Z}\\left[  \\Xi\\right]  $ for some\r\nfamily $\\Xi$ of indeterminates, and the maps $\\varphi_{n}$ are defined by\r\n$\\varphi_{n}\\left(  P\\right)  =P\\left(  \\Xi^{n}\\right)  $ for every\r\n$P\\in\\mathbb{Z}\\left[  \\Xi\\right]  $ (where $P\\left(  \\Xi^{n}\\right)  $ means\r\nthe result of $P$ upon substituting every variable by its $n$-th power). The\r\nonly part of Theorem \\ref{thm.gW} which is needed for this proof is the\r\nequivalence $\\mathcal{C}\\Longleftrightarrow\\mathcal{D}$.\r\n\r\nThe proof of Theorem \\ref{thm.gW} is everywhere and nowhere: it is a\r\nstraightforward generalization of arguments easily found in literature, but I\r\nhaven't seen it explicit in this generality anywhere. I've written it up (save\r\nfor Assertion $\\mathcal{J}$) in \\cite[Theorem 11]{dg-witt5}. Also, the proof\r\nof the whole Theorem \\ref{thm.gW} in the case when $N=\\mathbb{N}_{+}$ appears\r\nin \\cite[Exercise 2.9.6]{reiner-hopf}; it is not hard to derive the general\r\ncase from it.\r\n\r\nSome parts of Theorem \\ref{thm.gW} are valid in somewhat more general\r\nsituations. The equivalence $\\mathcal{C}\\Longleftrightarrow\\mathcal{D}$ needs\r\nAssumptions 1 and 2 but not 3 (unsurprisingly), and the equivalence\r\n$\\mathcal{C}\\Longleftrightarrow\\mathcal{E}\\Longleftrightarrow\\mathcal{F}%\r\n\\Longleftrightarrow\\mathcal{G}\\Longleftrightarrow\\mathcal{H}$ needs only\r\nAssumption 3 (not 1 and 2; actually, $A$ can be any additive group rather than\r\na ring for this equivalence). The equivalence $\\mathcal{D}\\Longleftrightarrow\r\n\\mathcal{J}$ needs nothing. This is all old news.\r\n\r\n\\subsection{Classical Witt vectors}\r\n\r\nWe recall a way to define the classical notion of Witt vectors. We work with a\r\nnest $N$, so that both $p$-typical and big Witt vectors are provided for.\r\n\r\n\\begin{definition}\r\n\\label{def.Witt.ghostmap}Let $N$ be a nest. Let $A$ be a commutative ring. The\r\n\\textit{ghost ring} of $A$ will mean the ring $A^{N}$ with componentwise ring\r\nstructure (i. e., a direct product of rings $A$ indexed over $N$). The\r\n$N$\\textit{-ghost map} $w_{N}:A^{N}\\rightarrow A^{N}$ is the map defined by%\r\n\\[\r\nw_{N}\\left(  \\left(  x_{n}\\right)  _{n\\in N}\\right)  =\\left(  \\sum\r\n\\limits_{d\\mid n}dx_{d}^{n / d}\\right)  _{n\\in N}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nall }\\left(  x_{n}\\right)  _{n\\in N}\\in A^{N}.\r\n\\]\r\nThis $N$-ghost map is (generally) neither additive nor multiplicative.\r\n\\end{definition}\r\n\r\nThe following theorem is easily derived from Theorem \\ref{thm.gW} (more\r\nprecisely, the equivalence $\\mathcal{C}\\Longleftrightarrow\\mathcal{D}$)\r\napplied to the case $A=\\mathbb{Z}\\left[  \\Xi\\right]  $ and $\\varphi_{n}\\left(\r\nP\\right)  =P\\left(  \\Xi^{n}\\right)  $:\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.class}Let $N$ be a nest. There exists a unique functor\r\n$W_{N}:\\mathbf{CRing}\\rightarrow\\mathbf{CRing}$ with the following two properties:\r\n\r\n-- We have $W_{N}\\left(  A\\right)  =A^{N}$ \\textbf{as a set} for every\r\ncommutative ring $A$.\r\n\r\n-- The map $w_{N}:A^{N}\\rightarrow A^{N}$ \\textbf{regarded as a map }%\r\n$W_{N}\\left(  A\\right)  \\rightarrow A^{N}$ is a ring homomorphism for every\r\ncommutative ring $A$.\r\n\r\nThis functor $W_{N}$ is called the $N$\\textit{-Witt vector functor}. For every\r\ncommutative ring $A$, we call the commutative ring $W_{N}\\left(  A\\right)  $\r\nthe $N$\\textit{-Witt vector ring over }$A$. Its zero is the family $\\left(\r\n0\\right)  _{n\\in N}$, and its unity is the family $\\left(  \\delta\r\n_{n,1}\\right)  _{n\\in N}$ (where $\\delta_{u,v}$ is defined to be $%\r\n\\begin{cases}\r\n1, & \\text{if }u=v;\\\\\r\n0, & \\text{if }u\\neq v\r\n\\end{cases}\r\n$ for any two objects $u$ and $v$).\r\n\r\nThe map $w_{N}:W_{N}\\left(  A\\right)  \\rightarrow A^{N}$ itself becomes a\r\nnatural transformation from the functor $W_{N}$ to the functor $\\mathbf{CRing}%\r\n\\rightarrow\\mathbf{CRing},\\ A\\mapsto A^{N}$. We will call this natural\r\ntransformation $w_{N}$ as well.\r\n\\end{theorem}\r\n\r\nTheorem \\ref{thm.Witt.class} appears in \\cite[Theorem 2.6]{rabinoff-witt}.\r\nNote that a consequence of Theorem \\ref{thm.Witt.class} is that the sum and\r\nthe product of two ghost-Witt vectors \\textbf{over any commutative ring }$A$\r\nare again ghost-Witt vectors. This is not an immediate consequence of Theorem\r\n\\ref{thm.gW} (because it is not clear how we could construct maps $\\varphi\r\n_{n}$ satisfying Assumptions 1, 2 and 3 over any commutative ring $A$), but\r\nrather requires a detour via $\\mathbb{Z}\\left[  \\Xi\\right]  $.\r\n\r\nThe following theorem (\\cite[Remark 2.9, part 3]{rabinoff-witt}) allows us to\r\nprove functorial identities by working with ghost components:\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.iso}Let $N$ be a nest. For any commutative $\\mathbb{Q}%\r\n$-algebra $A$, the map $w_{N}:W_{N}\\left(  A\\right)  \\rightarrow A^{N}$ is a\r\nring isomorphism.\r\n\\end{theorem}\r\n\r\nThe Witt vector rings allow for an ``almost-universal property'' \\cite[Theorem\r\n6.1]{rabinoff-witt}:\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.frob.au}Let $N$ be a nest. Let $A$ be a commutative ring such\r\nthat no element of $N$ is a zero-divisor in $A$. For every $n\\in N$, let\r\n$\\sigma_{n}$ be a ring endomorphism of $A$. Assume that $\\sigma_{n}\\circ\r\n\\sigma_{m}=\\sigma_{nm}$ for any $n\\in N$ and $m\\in N$ satisfying $nm\\in N$.\r\nAlso assume that $\\sigma_{1}=\\operatorname*{id}$. Finally, assume that\r\n$\\sigma_{p}\\left(  a\\right)  \\equiv a^{p}\\operatorname{mod}pA$ for every prime\r\n$p\\in N$ and every $a\\in A$. Then, there exists a unique ring homomorphism\r\n$\\varphi:A\\rightarrow W_{N}\\left(  A\\right)  $ satisfying%\r\n\\[\r\n\\left(  w_{N}\\circ\\varphi\\right)  \\left(  a\\right)  =\\left(  \\sigma_{n}\\left(\r\na\\right)  \\right)  _{n\\in N}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }a\\in A.\r\n\\]\r\n\r\n\\end{theorem}\r\n\r\nNow let us describe some known functorial operations on $W_{N}\\left(\r\nA\\right)  $. I will follow \\cite{rabinoff-witt} most of the time.\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.frob}Let $N$ be a nest.\r\n\r\n\\textbf{(a)} Let $m$ be a positive integer such that every $n\\in N$ satisfies\r\n$mn\\in N$. Then, there exists a unique natural transformation $\\mathbf{f}%\r\n_{m}:W_{N}\\rightarrow W_{N}$ of \\textbf{set-valued} (not ring-valued) functors\r\nsuch that any commutative ring $A$ and any $\\mathbf{x}\\in W_{N}\\left(\r\nA\\right)  $ satisfy%\r\n\\[\r\nw_{N}\\left(  \\mathbf{f}_{m}\\left(  \\mathbf{x}\\right)  \\right)  =\\left(\r\nmn\\text{-th coordinate of }w_{N}\\left(  \\mathbf{x}\\right)  \\right)  _{n\\in\r\nN},\r\n\\]\r\nwhere $\\mathbf{f}_{m}$ is short for $\\mathbf{f}_{m}\\left(  A\\right)  $.\r\n\r\n\\textbf{(b)} This natural transformation $\\mathbf{f}_{m}$ is actually a\r\nnatural transformation $W_{N}\\rightarrow W_{N}$ of \\textbf{ring-valued}\r\nfunctors as well. That is, $\\mathbf{f}_{m}:W_{N}\\left(  A\\right)  \\rightarrow\r\nW_{N}\\left(  A\\right)  $ is a ring homomorphism for every commutative ring\r\n$A$. (Here, again, $\\mathbf{f}_{m}$ stands short for $\\mathbf{f}_{m}\\left(\r\nA\\right)  $.) We call $\\mathbf{f}_{m}$ the $m$\\textit{-th Frobenius} on\r\n$W_{N}$.\r\n\r\n\\textbf{(c)} We have $\\mathbf{f}_{1}=\\operatorname*{id}$. Any two positive\r\nintegers $n$ and $m$ such that $\\mathbf{f}_{n}$ and $\\mathbf{f}_{m}$ are\r\nwell-defined satisfy $\\mathbf{f}_{n}\\circ\\mathbf{f}_{m}=\\mathbf{f}_{nm}$.\r\n\r\n\\textbf{(d)} Let $p$ be a prime such that every $n\\in N$ satisfies $pn\\in N$.\r\nWe have $\\mathbf{f}_{p}\\left(  \\mathbf{x}\\right)  \\equiv\\mathbf{x}%\r\n^{p}\\operatorname{mod}p$ (in $W_{N}\\left(  A\\right)  $) for every commutative\r\nring $A$ and every $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $.\r\n\\end{theorem}\r\n\r\nIn one or the other form, Theorem \\ref{thm.Witt.frob} appears in most sources\r\non Witt vectors; for example, it can be pieced together from parts of\r\n\\cite[Theorem 5.7, Proposition 5.9 and Proposition 5.12]{rabinoff-witt}.\r\n\r\n\\begin{noncompile}\r\n[By the way, what if we loosen the \\textquotedblleft$n\\in N\\Longrightarrow\r\nmn\\in N$\\textquotedblright\\ condition in Theorem \\ref{thm.Witt.frob}? I feel\r\nwe should get something like partial Frobenii $\\mathbf{f}_{m}:W_{N}\\left(\r\nA\\right)  \\rightarrow W_{N/m}\\left(  A\\right)  $, where $N/m=\\left\\{\r\nk\\in\\mathbb{N}_{+}\\ \\mid\\ mk\\in N\\right\\}  $.]\r\n\\end{noncompile}\r\n\r\n\\begin{noncompile}\r\n[(Here I'm talking to Jim Borger:) Let me use this occasion to explain\r\nsomething I wrote in an old email: I claimed that the maps $\\varphi_{n}$ of\r\nTheorem \\ref{thm.gW} \\textquotedblleft are used to prove the existence of Witt\r\nvectors though weirdly enough don't actually matter in the\r\nend\\textquotedblright. What I meant is that these maps $\\varphi_{n}$ (which\r\nare Frobenius lifts on $A$) appear neither in Theorem \\ref{thm.Witt.class}\r\n(although its proof uses Theorem \\ref{thm.gW}) nor in Theorem\r\n\\ref{thm.Witt.frob} (which constructs Frobenius lifts on $W_{N}\\left(\r\nA\\right)  $). In particular, the Frobenii $\\mathbf{f}_{n}$ on the Witt vector\r\nring $W_{N}\\left(  A\\right)  $ don't depend on these maps $\\varphi_{n}$. That\r\nsaid, I wouldn't be surprised if there is a deformation of the Witt vector\r\nring which \\textit{does} take these maps into account, in the same way as, e.\r\ng., the shuffle algebra over a vector space which happens to have an algebra\r\nstructure can be deformed to a quasi-shuffle algebra. In \\cite[\\S 17.35]%\r\n{hw-witt1} (or rather in the paper by Oh cited there), this is done for\r\nnecklace rings.]\r\n\\end{noncompile}\r\n\r\nHere is the definition of Verschiebung (\\cite[Theorem 5.5 and Proposition\r\n5.9]{rabinoff-witt}):\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.ver}Let $N$ be a nest.\r\n\r\n\\textbf{(a)} Let $m$ be a positive integer. Then, there exists a unique\r\nnatural transformation $\\mathbf{V}_{m}:W_{N}\\rightarrow W_{N}$ of\r\n\\textbf{set-valued} (not ring-valued) functors such that any commutative ring\r\n$A$ and any $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $ satisfy%\r\n\\[\r\nw_{N}\\left(  \\mathbf{V}_{m}\\left(  \\mathbf{x}\\right)  \\right)  =\\left(\r\n\\begin{cases}\r\nm\\cdot\\left(  \\dfrac{n}{m}\\text{-th coordinate of }w_{N}\\left(  \\mathbf{x}%\r\n\\right)  \\right)  , & \\text{if }m\\mid n;\\\\\r\n0, & \\text{if }m\\nmid n\r\n\\end{cases}\r\n\\right)  _{n\\in N},\r\n\\]\r\nwhere $\\mathbf{V}_{m}$ is short for $\\mathbf{V}_{m}\\left(  A\\right)  $.\r\n\r\n\\textbf{(b)} This natural transformation $\\mathbf{V}_{m}$ is actually a\r\nnatural transformation $W_{N}\\rightarrow W_{N}$ of\r\n\\textbf{abelian-group-valued} functors as well. More precisely, $\\mathbf{V}%\r\n_{m}:W_{N}\\left(  A\\right)  \\rightarrow W_{N}\\left(  A\\right)  $ is a\r\nhomomorphism of additive groups for every commutative ring $A$. (Here, again,\r\n$\\mathbf{V}_{m}$ stands short for $\\mathbf{V}_{m}\\left(  A\\right)  $.) We call\r\n$\\mathbf{V}_{m}$ the $m$\\textit{-th Verschiebung} on $W_{N}$.\r\n\r\n\\textbf{(c)} We have $\\mathbf{V}_{1}=\\operatorname*{id}$. Any two positive\r\nintegers $n$ and $m$ satisfy $\\mathbf{V}_{n}\\circ\\mathbf{V}_{m}=\\mathbf{V}%\r\n_{nm}$.\r\n\r\n\\textbf{(d)} Actually, $\\mathbf{V}_{m}\\left(  \\left(  x_{n}\\right)  _{n\\in\r\nN}\\right)  =\\left(\r\n\\begin{cases}\r\nx_{n/m}, & \\text{if }m\\mid n;\\\\\r\n0, & \\text{if }m\\nmid n\r\n\\end{cases}\r\n\\right)  _{n\\in N}$ for any positive integer $m$, any commutative ring $A$ and\r\nany $\\left(  x_{n}\\right)  _{n\\in N}\\in W_{N}\\left(  A\\right)  $.\r\n\\end{theorem}\r\n\r\nThere are some equalities involving $\\mathbf{V}_{m}$ and $\\mathbf{f}_{m}$\r\nwhich should be here, but I don't have the time to write them down. They\r\ndefinitely need to be checked for Carlitz analogues.\r\n\r\nFinally, here is one possible definition of the comonadic Artin-Hasse\r\nexponential\\footnote{This is something Hazewinkel, in \\cite[\\S 16.45]%\r\n{hw-witt1}, calls Artin-Hasse exponential. I am not sure if I completely\r\nunderstand its relation to the usual Artin-Hasse exponential...}\r\n(\\cite[Corollary 6.3]{rabinoff-witt}):\r\n\r\n\\begin{theorem}\r\n\\label{thm.Witt.AH}Let $N$ be a nest. Assume that $nm\\in N$ for all $n\\in N$\r\nand $m\\in N$.\r\n\r\n\\textbf{(a)} There exists a unique natural transformation $\\operatorname*{AH}%\r\n:W_{N}\\rightarrow W_{N}\\circ W_{N}$ (of functors $\\mathbf{CRing}%\r\n\\rightarrow\\mathbf{CRing}$) such that every commutative ring $A$, every $n\\in\r\nN$ and every $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $ satisfy%\r\n\\[\r\n\\left(  n\\text{-th coordinate of }w_{N}\\left(  \\operatorname*{AH}\\left(\r\n\\mathbf{x}\\right)  \\right)  \\right)  =\\mathbf{f}_{n}\\left(  \\mathbf{x}\\right)\r\n\\]\r\n(where $w_{N}$ this time stands for the natural transformation $w_{N}$\r\nevaluated at the ring $W_{N}\\left(  A\\right)  $; thus, $w_{N}\\left(\r\n\\operatorname*{AH}\\left(  \\mathbf{x}\\right)  \\right)  $ is an element of\r\n$\\left(  W_{N}\\left(  A\\right)  \\right)  ^{N}$).\r\n\r\n\\textbf{(b)} Let $n\\in N$, and let $A$ be a commutative ring. Let $w_{n}%\r\n:W_{N}\\left(  A\\right)  \\rightarrow A$ be the map sending each $\\mathbf{x}\\in\r\nW_{N}\\left(  A\\right)  $ to the $n$-th coordinate of $w_{N}\\left(\r\n\\mathbf{x}\\right)  $. Then, $W_{N}\\left(  w_{n}\\right)  \\circ\r\n\\operatorname*{AH}=\\mathbf{f}_{n}$.\r\n\\end{theorem}\r\n\r\n\\subsection{The Carlitz ghost-Witt equivalence theorem}\r\n\r\nNow, let us move to the Carlitz case.\r\n\r\n\\begin{condition}\r\nFrom now on until the rest of Section \\ref{sect.carlitzwitt}, we let $q$\r\ndenote an arbitrary prime power ($\\neq1$, that is), and let $p$ be the prime\r\nwhose power $q$ is.\r\n\\end{condition}\r\n\r\n\\begin{definition}\r\n\\label{def.q-nest}A $q$-\\textit{nest} means a nonempty subset $N$ of\r\n$\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ such that for every element $P\\in N$,\r\nevery monic divisor of $P$ lies in $N$.\r\n\\end{definition}\r\n\r\nNotice that any $q$-nest is a subset of $\\mathbb{F}_{q}\\left[  T\\right]  _{+}%\r\n$. Thus, any element of a $q$-nest must be a monic polynomial. Also, every\r\n$q$-nest contains $1$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $N$ be a $q$-nest.\r\nWe must prove that $N$ contains $1$.\r\n\\par\r\nAny $q$-nest is nonempty (by definition). Thus, $N$ is nonempty (since $N$ is\r\na $q$-nest). In other words, there exists some $P\\in N$. Consider this $P$.\r\nNow, $1$ is a monic divisor of $P\\in N$, and thus must itself belong to $N$\r\n(since $N$ is a $q$-nest). In other words, $N$ contains $1$. Qed.}. We shall\r\nuse these facts without mention.\r\n\r\n\\begin{definition}\r\n\\label{def.PF(q)}Let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Then,\r\n$\\operatorname{PF}P$ denotes the set of all monic irreducible divisors of $P$\r\nin $\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\n\\end{definition}\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.gW}Let $N$ be a $q$-nest. Let $A$ be a commutative\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra. For every $P\\in N$, let\r\n$\\varphi_{P}:A\\rightarrow A$ be an endomorphism of the $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module $A$.\r\n\r\nFurther, let us make three more assumptions:\r\n\r\n\\textit{Assumption 1:} For every $P\\in N$, the map $\\varphi_{P}$ is an\r\nendomorphism of the $\\mathbb{F}_{q}\\left[  T\\right]  $\\textbf{-algebra} $A$.\r\n\r\n\\textit{Assumption 2:} We have $\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left[\r\n\\pi\\right]  \\left(  a\\right)  \\operatorname{mod}\\pi A$ for every $a\\in A$ and\r\nevery monic irreducible $\\pi\\in N$. (This rewrites as follows: We have\r\n$\\varphi_{\\pi}\\left(  a\\right)  \\equiv a^{q^{\\deg\\pi}}\\operatorname{mod}\\pi A$\r\nfor every $a\\in A$ and every monic irreducible $\\pi\\in N$.)\r\n\r\n\\textit{Assumption 3:} We have $\\varphi_{1}=\\operatorname*{id}$, and we have\r\n$\\varphi_{P}\\circ\\varphi_{Q}=\\varphi_{PQ}$ for every $P\\in N$ and every $Q\\in\r\nN$ satisfying $PQ\\in N$.\r\n\r\nLet $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ be a family of elements of $A$.\r\nThen, the following assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ are equivalent:\r\n\r\n\\textit{Assertion }$\\mathcal{C}_{1}$\\textit{:} Every $P\\in N$ and every\r\n$\\pi\\in\\operatorname{PF}P$ satisfy%\r\n\\[\r\n\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{D}_{1}$\\textit{:} There exists a family $\\left(\r\nx_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\left[  \\dfrac{P}{D}\\right]  \\left(\r\nx_{D}\\right)  \\text{ for every }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{D}_{2}$\\textit{:} There exists a family $\\left(\r\n\\widetilde{x}_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\widetilde{x}_{D}^{q^{\\deg\\left(  P/D\\right)  }%\r\n}\\text{ for every }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{E}_{1}$\\textit{:} There exists a family $\\left(\r\ny_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\varphi_{P / D}\\left(  y_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{F}_{1}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P / D}\\right)  \\in\r\nPA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{G}_{1}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi_{C}\\left(  D\\right)  \\varphi_{D}\\left(  b_{P /\r\nD}\\right)  \\in PA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{G}_{2}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi\\left(  D\\right)  \\varphi_{D}\\left(  b_{P / D}\\right)\r\n\\in PA.\r\n\\]\r\n\r\n\\end{theorem}\r\n\r\nFor this Theorem \\ref{thm.carlitz.gW} to be a complete analogue of Theorem\r\n\\ref{thm.gW}, two assertions are missing: $\\mathcal{H}$ and $\\mathcal{J}$.\r\nFinding an analogue of $\\mathcal{J}$ requires finding an analogue of $\\Lambda\r\n$, which is the question that I have started this report with; approaches to\r\nit will be discussed in Section \\ref{sect.tinfoil}. Two other assertions\r\n($\\mathcal{D}$ and $\\mathcal{G}$) have two analogues each. However, Assertion\r\n$\\mathcal{G}_{2}$ is clearly equivalent to Assertion $\\mathcal{F}_{1}$ because\r\nof $\\varphi\\left(  M\\right)  \\equiv\\mu\\left(  M\\right)  \\operatorname{mod}p$\r\nfor every $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. I have written out the\r\nformer assertion merely to produce a clearer view of the analogy.\r\n\r\nThe proof of Theorem \\ref{thm.carlitz.gW} is analogous to that of (the\r\nrespective parts of) Theorem \\ref{thm.gW}, and finding it should not be\r\ndifficult. (One of the easier ways to proceed is showing $\\mathcal{D}%\r\n_{1}\\Longleftrightarrow\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$,\r\n$\\mathcal{C}_{1}\\Longrightarrow\\mathcal{F}_{1}\\Longrightarrow\\mathcal{E}%\r\n_{1}\\Longrightarrow\\mathcal{C}_{1}$, $\\mathcal{F}_{1}\\Longleftrightarrow\r\n\\mathcal{G}_{2}$ and $\\mathcal{E}_{1}\\Longleftrightarrow\\mathcal{G}_{1}$. Two\r\ndifferent analogues of Hensel's exponent lifting are used in proving\r\n$\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}$ and $\\mathcal{C}%\r\n_{1}\\Longleftrightarrow\\mathcal{D}_{2}$.)\r\n\r\n\\begin{definition}\r\nThe families $\\left(  b_{n}\\right)  _{n\\in N}\\in A^{N}$ which satisfy the\r\nequivalent assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$, $\\mathcal{D}_{2}$,\r\n$\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$, and $\\mathcal{G}_{2}$\r\nof Theorem \\ref{thm.carlitz.gW} will be called \\textit{Carlitz ghost-Witt\r\nvectors} (over $A$).\r\n\\end{definition}\r\n\r\nWhat is more interesting is the following observation:\r\n\r\n\\begin{remark}\r\n\\label{rmk.carlitz.gW.1'}Assumption 1 in Theorem \\ref{thm.carlitz.gW} can be\r\nreplaced by the following weaker one:\r\n\r\n\\textit{Assumption 1':} For every $P\\in N$, the map $\\varphi_{P}$ is an\r\nendomorphism of the $\\mathbb{F}_{q}\\left[  T\\right]  $-module $A$ and commutes\r\nwith the Frobenius endomorphism $A\\rightarrow A,\\ a\\mapsto a^{q}$.\r\n\r\nMoreover, instead of assuming that $A$ be a commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra, it is enough to assume that $A$ is an $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module with an $\\mathbb{F}_{q}$-linear Frobenius map\r\n$F:A\\rightarrow A$ which satisfies%\r\n\\begin{equation}\r\nF\\left(  \\lambda a\\right)  =\\lambda^{q}F\\left(  a\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\lambda\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n\\text{ and }a\\in A. \\label{eq.frobcond}%\r\n\\end{equation}\r\nOf course, in this general setup, one has to \\textbf{define} $a^{q}$ to mean\r\n$F\\left(  a\\right)  $ for every $a\\in A$. (Once this definition is made, the\r\nclassical definition of $\\left[  P\\right]  \\left(  a\\right)  $ for any\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and any $a\\in A$ should work perfectly.)\r\n\r\nMore about this in Subsection \\ref{subsect.F}.\r\n\\end{remark}\r\n\r\nHere is why this is strange. One could wonder whether similar things hold in\r\nthe classical case (Theorem \\ref{thm.gW}): what if $A$ is not a commutative\r\nring but just an (additive) abelian group with \\textquotedblleft power\r\noperations\\textquotedblright\\ satisfying rules like $\\left(  a^{n}\\right)\r\n^{m}=a^{nm}$ ? After all, the only way multiplication in $A$ appears in\r\nTheorem \\ref{thm.gW} is through taking powers. However, the proof of Theorem\r\n\\ref{thm.gW} depends on exponent lifting, which uses multiplication and its\r\ncommutativity in a nontrivial way. In contrast, the two exponent lifting\r\nlemmata used in the proof of Theorem \\ref{thm.carlitz.gW} are both extremely\r\nsimple and \\textbf{do not} use multiplication in $A$. It seems that $A$ being\r\na ring is a red herring in Theorem \\ref{thm.carlitz.gW}.\r\n\r\nI am wondering what use this generality can be put to. One possible field of\r\napplication would be restricted Lie algebras. What is a good example of a\r\nrestricted Lie algebra with an $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure?\\footnote{Non-rhetorical question. Please let me know!\r\n(darijgrinberg[at]gmail.com)}\r\n\r\n\\subsection{\\label{subsect.carlitz-Witt}Carlitz-Witt vectors}\r\n\r\nParroting Definition \\ref{def.Witt.ghostmap}, we define:\r\n\r\n\\begin{definition}\r\n\\label{def.carlitz.Witt.ghostmap}Let $N$ be a $q$-nest. Let $A$ be a\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra. The \\textit{Carlitz\r\nghost ring} of $A$ will mean the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\n$A^{N}$ with componentwise $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\nstructure (i. e., a direct product of $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebras $A$ indexed over $N$). The \\textit{Carlitz }$N$\\textit{-ghost map}\r\n$w_{N}:A^{N}\\rightarrow A^{N}$ is the map defined by%\r\n\\[\r\nw_{N}\\left(  \\left(  x_{P}\\right)  _{P\\in N}\\right)  =\\left(  \\sum\r\n\\limits_{D\\mid P}D\\left[  \\dfrac{P}{D}\\right]  \\left(  x_{D}\\right)  \\right)\r\n_{P\\in N}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }\\left(  x_{P}\\right)  _{P\\in N}\\in\r\nA^{N}.\r\n\\]\r\nThis $N$-ghost map is $\\mathbb{F}_{q}$-linear but (generally) neither\r\nmultiplicative nor $\\mathbb{F}_{q}\\left[  T\\right]  $-linear.\r\n\\end{definition}\r\n\r\nFrom the equivalence $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}$ in\r\nTheorem \\ref{thm.carlitz.gW}, we can obtain:\\footnote{I'm not going to show\r\nthe proof, as I don't think you will have any trouble reconstructing it. One\r\nhas to set $A=\\mathbb{F}_{q}\\left[  T\\right]  \\left[  \\Xi\\right]  $, where\r\n$\\Xi$ is a family of indeterminates, and define morphisms $\\varphi_{P}$ by\r\n$\\varphi_{P}\\left(  Q\\right)  =Q\\left(  \\left[  P\\right]  \\left(  \\Xi\\right)\r\n\\right)  $, where $\\left[  P\\right]  \\left(  \\Xi\\right)  $ means the family\r\nobtained by applying $\\left[  P\\right]  $ to each variable in the family $\\Xi\r\n$. Alternatively, one could define morphisms $\\varphi_{P}$ by $\\varphi\r\n_{P}\\left(  Q\\right)  =Q\\left(  \\Xi^{q^{\\deg P}}\\right)  $; these are\r\ndifferent morphisms but they also work here.}\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.class}Let $N$ be a $q$-nest. There exists a unique\r\nfunctor $W_{N}:\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  }%\r\n\\rightarrow\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  }$ with the\r\nfollowing two properties:\r\n\r\n-- We have $W_{N}\\left(  A\\right)  =A^{N}$ \\textbf{as a set} for every\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$.\r\n\r\n-- The map $w_{N}:A^{N}\\rightarrow A^{N}$ \\textbf{regarded as a map }%\r\n$W_{N}\\left(  A\\right)  \\rightarrow A^{N}$ is an $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra homomorphism for every commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra $A$.\r\n\r\nThis functor $W_{N}$ is called the \\textit{Carlitz }$N$\\textit{-Witt vector\r\nfunctor}. For every $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$, we call\r\nthe $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $W_{N}\\left(  A\\right)  $ the\r\n\\textit{Carlitz }$N$\\textit{-Witt vector ring over }$A$.\r\n\r\nThe map $w_{N}:W_{N}\\left(  A\\right)  \\rightarrow A^{N}$ itself becomes a\r\nnatural transformation from the functor $W_{N}$ to the functor $\\mathbf{CRing}%\r\n_{\\mathbb{F}_{q}\\left[  T\\right]  }\\rightarrow\\mathbf{CRing}_{\\mathbb{F}%\r\n_{q}\\left[  T\\right]  },\\ A\\mapsto A^{N}$. We will call this natural\r\ntransformation $w_{N}$ as well.\r\n\\end{theorem}\r\n\r\nThis theorem, of course, yields that the sum and the product of two Carlitz\r\nghost-Witt vectors \\textbf{over any commutative }$\\mathbb{F}_{q}\\left[\r\nT\\right]  $\\textbf{-algebra} is a Carlitz ghost-Witt vector, and that any\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-multiple of a Carlitz ghost-Witt vector is\r\na Carlitz ghost-Witt vector.\r\n\r\nBut this result is not optimal. In fact, it still holds in the more general\r\nsetup of Remark \\ref{rmk.carlitz.gW.1'}. This can no longer be proven using\r\nTheorem \\ref{thm.carlitz.Witt.class}, since the polynomial ring $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  \\Xi\\right]  $ is a free commutative\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra but not (in a reasonable way) a\r\nfree object in the category of $\\mathbb{F}_{q}\\left[  T\\right]  $-modules $A$\r\nwith an $\\mathbb{F}_{q}$-linear Frobenius map $F:A\\rightarrow A$ which\r\nsatisfies (\\ref{eq.frobcond}). I will lose some more words on this in\r\nSubsection \\ref{subsect.F}.\r\n\r\n\\begin{remark}\r\nLet $N$ be a $q$-nest. The $\\mathbb{F}_{q}$-vector space structure on the\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $W_{N}\\left(  A\\right)  $ is just\r\ncomponentwise. Thus, $w_{N}$ is an $\\mathbb{F}_{q}$-vector space homomorphism\r\nwhen considered as a map $A^{N}\\rightarrow A^{N}$. As a consequence, the zero\r\nof the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $W_{N}\\left(  A\\right)  $ is\r\nthe family $\\left(  0\\right)  _{P\\in N}$.\r\n\\end{remark}\r\n\r\nThe unity of the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $W_{N}\\left(\r\nA\\right)  $ is not as simple as it was in Theorem \\ref{thm.Witt.class}.\r\n\r\nWe have only used $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}$ so far.\r\nWhat about $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$ ?\r\n\r\n\\begin{definition}\r\n\\label{def.carlitz.Witt.ghostmap.tilde}Let $N$ be a $q$-nest. Let $A$ be a\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra. The \\textit{Carlitz\r\ntilde }$N$\\textit{-ghost map} $\\widetilde{w}_{N}:A^{N}\\rightarrow A^{N}$ is\r\nthe map defined by%\r\n\\[\r\n\\widetilde{w}_{N}\\left(  \\left(  x_{P}\\right)  _{P\\in N}\\right)  =\\left(\r\n\\sum\\limits_{D\\mid P}Dx_{D}^{q^{\\deg\\left(  P / D\\right)  }}\\right)  _{P\\in\r\nN}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }\\left(  x_{P}\\right)  _{P\\in N}\\in\r\nA^{N}.\r\n\\]\r\nThis tilde $N$-ghost map is $\\mathbb{F}_{q}$-linear but (generally) neither\r\nmultiplicative nor $\\mathbb{F}_{q}\\left[  T\\right]  $-linear.\r\n\\end{definition}\r\n\r\nFrom the equivalence $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$ in\r\nTheorem \\ref{thm.carlitz.gW}, we get:\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.class.tilde}Let $N$ be a $q$-nest. There exists a\r\nunique functor $\\widetilde{W}_{N}:\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[\r\nT\\right]  }\\rightarrow\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  }$ with\r\nthe following two properties:\r\n\r\n-- We have $\\widetilde{W}_{N}\\left(  A\\right)  =A^{N}$ \\textbf{as a set} for\r\nevery commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$.\r\n\r\n-- The map $\\widetilde{w}_{N}:A^{N}\\rightarrow A^{N}$ \\textbf{regarded as a\r\nmap }$\\widetilde{W}_{N}\\left(  A\\right)  \\rightarrow A^{N}$ is an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism for every commutative\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$.\r\n\r\nThis functor $\\widetilde{W}_{N}$ is called the \\textit{Carlitz tilde }%\r\n$N$\\textit{-Witt vector functor}. For every $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebra $A$, we call the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\n$\\widetilde{W}_{N}\\left(  A\\right)  $ the \\textit{Carlitz tilde }%\r\n$N$\\textit{-Witt vector ring over }$A$. The zero of this $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-algebra $\\widetilde{W}_{N}\\left(  A\\right)  $ is the\r\nfamily $\\left(  0\\right)  _{P\\in N}$, and its unity is the family $\\left(\r\n\\delta_{P,1}\\right)  _{P\\in N}$ (where $\\delta_{u,v}$ is defined to be $%\r\n\\begin{cases}\r\n1, & \\text{if }u=v;\\\\\r\n0, & \\text{if }u\\neq v\r\n\\end{cases}\r\n$ for any two objects $u$ and $v$).\r\n\r\nThe map $\\widetilde{w}_{N}:\\widetilde{W}_{N}\\left(  A\\right)  \\rightarrow\r\nA^{N}$ itself becomes a natural transformation from the functor $\\widetilde{W}%\r\n_{N}$ to the functor $\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]\r\n}\\rightarrow\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  },\\ A\\mapsto\r\nA^{N}$. We will call this natural transformation $\\widetilde{w}_{N}$ as well.\r\n\\end{theorem}\r\n\r\nBut we have not really found two really different functors...\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.W=W}Let $N$ be a $q$-nest. The functors $W_{N}$ and\r\n$\\widetilde{W}_{N}$ are isomorphic by an isomorphism which forms a commutative\r\ntriangle with $w_{N}$ and $\\widetilde{w}_{N}$.\r\n\\end{theorem}\r\n\r\nThis is again proven using Theorem \\ref{thm.carlitz.gW} and universal polynomials.\r\n\r\nThe following theorem allows us to prove functorial identities by working with\r\nghost components:\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.iso}Let $N$ be a $q$-nest. For any commutative\r\n$\\mathbb{F}_{q}\\left(  T\\right)  $-algebra $A$, the maps $w_{N}:W_{N}\\left(\r\nA\\right)  \\rightarrow A^{N}$ and $\\widetilde{w}_{N}:\\widetilde{W}_{N}\\left(\r\nA\\right)  \\rightarrow A^{N}$ are $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra isomorphisms.\r\n\\end{theorem}\r\n\r\nWe have an ``almost-universal property'' again, following from exponent\r\nlifting and the implication $\\mathcal{C}_{1}\\Longrightarrow\\mathcal{D}_{1}$ in\r\nTheorem \\ref{thm.carlitz.gW}:\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.frob.au}Let $N$ be a $q$-nest. Let $A$ be a\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra such that no element of\r\n$N$ is a zero-divisor in $A$. For every $P\\in N$, let $\\sigma_{P}$ be an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra endomorphism of $A$. Assume that\r\n$\\sigma_{P}\\circ\\sigma_{Q}=\\sigma_{PQ}$ for any $P\\in N$ and $Q\\in N$\r\nsatisfying $PQ\\in N$. Also assume that $\\sigma_{1}=\\operatorname*{id}$.\r\nFinally, assume that $\\sigma_{\\pi}\\left(  a\\right)  \\equiv\\left[  \\pi\\right]\r\n\\left(  a\\right)  \\operatorname{mod}\\pi A$ (or, equivalently, $\\sigma_{\\pi\r\n}\\left(  a\\right)  \\equiv a^{q^{\\deg\\pi}}\\operatorname{mod}\\pi A$) for every\r\nmonic irreducible $\\pi\\in N$ and every $a\\in A$. Then, there exists a unique\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism $\\varphi:A\\rightarrow\r\nW_{N}\\left(  A\\right)  $ satisfying%\r\n\\begin{equation}\r\n\\left(  w_{N}\\circ\\varphi\\right)  \\left(  a\\right)  =\\left(  \\sigma_{P}\\left(\r\na\\right)  \\right)  _{P\\in N}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }a\\in A.\r\n\\label{eq.thm.carlitz.Witt.frob.au.phi}%\r\n\\end{equation}\r\n\r\n\\end{theorem}\r\n\r\nA similar result holds for $\\widetilde{W}_{N}$ and $\\widetilde{w}_{N}$.\r\n\r\nWhat about Frobenius operations?\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.frob}Let $N$ be a $q$-nest.\r\n\r\n\\textbf{(a)} Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ be such that every\r\n$P\\in N$ satisfies $MP\\in N$. Then, there exists a unique natural\r\ntransformation $\\mathbf{f}_{M}:W_{N}\\rightarrow W_{N}$ of \\textbf{set-valued}\r\n(not $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra-valued) functors such that any\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$ and any\r\n$\\mathbf{x}\\in W_{N}\\left(  A\\right)  $ satisfy%\r\n\\[\r\nw_{N}\\left(  \\mathbf{f}_{M}\\left(  \\mathbf{x}\\right)  \\right)  =\\left(\r\nMP\\text{-th coordinate of }w_{N}\\left(  \\mathbf{x}\\right)  \\right)  _{P\\in\r\nN},\r\n\\]\r\nwhere $\\mathbf{f}_{M}$ is short for $\\mathbf{f}_{M}\\left(  A\\right)  $.\r\n\r\n\\textbf{(b)} This natural transformation $\\mathbf{f}_{M}$ is actually a\r\nnatural transformation $W_{N}\\rightarrow W_{N}$ of $\\mathbb{F}_{q}\\left[\r\nT\\right]  $\\textbf{-algebra-valued} functors as well. That is, $\\mathbf{f}%\r\n_{M}:W_{N}\\left(  A\\right)  \\rightarrow W_{N}\\left(  A\\right)  $ is an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism for every commutative\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$. (Here, again, $\\mathbf{f}_{M}$\r\nstands short for $\\mathbf{f}_{M}\\left(  A\\right)  $.) We call $\\mathbf{f}_{M}$\r\nthe $M$\\textit{-th Frobenius} on $W_{N}$.\r\n\r\n\\textbf{(c)} We have $\\mathbf{f}_{1}=\\operatorname*{id}$. Any $P\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ and $Q\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}$ such that $\\mathbf{f}_{P}$ and $\\mathbf{f}_{Q}$ are well-defined satisfy\r\n$\\mathbf{f}_{P}\\circ\\mathbf{f}_{Q}=\\mathbf{f}_{PQ}$.\r\n\r\n\\textbf{(d)} Let $\\pi\\in\\mathbb{F}_{q}\\left[  T\\right]  $ be a monic\r\nirreducible such that every $P\\in N$ satisfies $\\pi P\\in N$. We have\r\n$\\mathbf{f}_{\\pi}\\left(  \\mathbf{x}\\right)  \\equiv\\left[  \\pi\\right]  \\left(\r\n\\mathbf{x}\\right)  \\operatorname{mod}\\pi W_{N}\\left(  A\\right)  $ (in\r\n$W_{N}\\left(  A\\right)  $) for every commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra $A$ and every $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $.\r\n\\end{theorem}\r\n\r\n\\begin{corollary}\r\n\\label{cor.carlitz.Witt.frob.au.preserves-frob}Consider the setting of Theorem\r\n\\ref{thm.carlitz.Witt.frob.au}. Then (from Theorem\r\n\\ref{thm.carlitz.Witt.frob.au}) we know that there exists a unique\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism $\\varphi:A\\rightarrow\r\nW_{N}\\left(  A\\right)  $ satisfying (\\ref{eq.thm.carlitz.Witt.frob.au.phi}).\r\nConsider this $\\varphi$. Let $M\\in N$ be such that every $P\\in N$ satisfies\r\n$MP\\in N$. Then,%\r\n\\[\r\n\\varphi\\circ\\sigma_{M}=\\mathbf{f}_{M}\\circ\\varphi\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }M\\in N.\r\n\\]\r\n\r\n\\end{corollary}\r\n\r\n\\begin{corollary}\r\n\\label{cor.carlitz.Witt.frob.adjoint}Consider the setting of Theorem\r\n\\ref{thm.carlitz.Witt.frob.au}. Assume that $N$ is closed under multiplication\r\n(i.e., we have $MP\\in N$ for every $M\\in N$ and $P\\in N$). Furthermore, let\r\n$B$ be a commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra such that no\r\nelement of $N$ is a zero-divisor in $B$. Let $\\operatorname*{proj}%\r\n\\nolimits_{B}:W_{N}\\left(  B\\right)  \\rightarrow B$ be the map sending every\r\n$u\\in W_{N}\\left(  B\\right)  $ to the $1$-st coordinate of $w_{N}\\left(\r\nu\\right)  \\in B^{N}$. This $\\operatorname*{proj}\\nolimits_{B}$ is an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism (since $w_{N}$ is an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra homomorphism).\r\n\r\nLet $g:A\\rightarrow B$ be an $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\nhomomorphism. Then, there exists a unique $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebra homomorphism $G:A\\rightarrow W_{N}\\left(  B\\right)  $ with the\r\nproperties that $w_{1}\\circ G=g$ and that%\r\n\\[\r\nG\\circ\\sigma_{M}=\\mathbf{f}_{M}\\circ g\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}M\\in N.\r\n\\]\r\nThis $G$ can be constructed as follows: Theorem \\ref{thm.carlitz.Witt.frob.au}\r\nshows that there exists a unique $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\nhomomorphism $\\varphi:A\\rightarrow W_{N}\\left(  A\\right)  $ satisfying\r\n(\\ref{eq.thm.carlitz.Witt.frob.au.phi}). Consider this $\\varphi$. Since\r\n$W_{N}$ is a functor, the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\nhomomorphism $g:A\\rightarrow B$ gives rise to an $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra homomorphism $W_{N}\\left(  g\\right)  :W_{N}\\left(\r\nA\\right)  \\rightarrow W_{N}\\left(  B\\right)  $. Now, the $G$ is constructed as\r\nthe composition $W_{N}\\left(  g\\right)  \\circ\\varphi$.\r\n\\end{corollary}\r\n\r\nA Verschiebung exists too:\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.ver}Let $N$ be a $q$-nest.\r\n\r\n\\textbf{(a)} Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Then, there\r\nexists a unique natural transformation $\\mathbf{V}_{M}:W_{N}\\rightarrow W_{N}$\r\nof \\textbf{set-valued} (not $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra-valued)\r\nfunctors such that any commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra\r\n$A$ and any $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $ satisfy%\r\n\\[\r\nw_{N}\\left(  \\mathbf{V}_{M}\\left(  \\mathbf{x}\\right)  \\right)  =\\left(\r\n\\begin{cases}\r\nM\\cdot\\left(  \\dfrac{P}{M}\\text{-th coordinate of }w_{N}\\left(  \\mathbf{x}%\r\n\\right)  \\right)  , & \\text{if }M\\mid P;\\\\\r\n0, & \\text{if }M\\nmid P\r\n\\end{cases}\r\n\\right)  _{P\\in N},\r\n\\]\r\nwhere $\\mathbf{V}_{M}$ is short for $\\mathbf{V}_{M}\\left(  A\\right)  $.\r\n\r\n\\textbf{(b)} This natural transformation $\\mathbf{V}_{M}$ is actually a\r\nnatural transformation $W_{N}\\rightarrow W_{N}$ of\r\n\\textbf{abelian-group-valued} functors as well. More precisely, $\\mathbf{V}%\r\n_{M}:W_{N}\\left(  A\\right)  \\rightarrow W_{N}\\left(  A\\right)  $ is a\r\nhomomorphism of additive groups for every commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra $A$. (Here, again, $\\mathbf{V}_{M}$ stands short for\r\n$\\mathbf{V}_{M}\\left(  A\\right)  $.) We call $\\mathbf{V}_{M}$ the\r\n$M$\\textit{-th Verschiebung} on $W_{N}$.\r\n\r\n\\textbf{(c)} We have $\\mathbf{V}_{1}=\\operatorname*{id}$. Any two\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ and $Q\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}$ satisfy $\\mathbf{V}_{P}\\circ\\mathbf{V}_{Q}=\\mathbf{V}_{PQ}$.\r\n\r\n\\textbf{(d)} Actually, $\\mathbf{V}_{M}\\left(  \\left(  x_{P}\\right)  _{P\\in\r\nN}\\right)  =\\left(\r\n\\begin{cases}\r\nx_{P/M}, & \\text{if }M\\mid P;\\\\\r\n0, & \\text{if }M\\nmid P\r\n\\end{cases}\r\n\\right)  _{P\\in N}$ for any $P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$, any\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$ and any $\\left(\r\nx_{P}\\right)  _{P\\in N}\\in W_{N}\\left(  A\\right)  $.\r\n\\end{theorem}\r\n\r\nAnd here is a Carlitz analogue of the Artin-Hasse exponential:\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitz.Witt.AH}Let $N$ be a $q$-nest. Assume that $PQ\\in N$ for\r\nall $P\\in N$ and $Q\\in N$.\r\n\r\n\\textbf{(a)} There exists a unique natural transformation $\\operatorname*{AH}%\r\n:W_{N}\\rightarrow W_{N}\\circ W_{N}$ (of functors $\\mathbf{CRing}%\r\n_{\\mathbb{F}_{q}\\left[  T\\right]  }\\rightarrow\\mathbf{CRing}_{\\mathbb{F}%\r\n_{q}\\left[  T\\right]  }$) such that every commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra $A$, every $P\\in N$ and every $\\mathbf{x}\\in W_{N}\\left(\r\nA\\right)  $ satisfy%\r\n\\[\r\n\\left(  P\\text{-th coordinate of }w_{N}\\left(  \\operatorname*{AH}\\left(\r\n\\mathbf{x}\\right)  \\right)  \\right)  =\\mathbf{f}_{P}\\left(  \\mathbf{x}\\right)\r\n\\]\r\n(where $w_{N}$ this time stands for the natural transformation $w_{N}$\r\nevaluated at the $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $W_{N}\\left(\r\nA\\right)  $; thus, $w_{N}\\left(  \\operatorname*{AH}\\left(  \\mathbf{x}\\right)\r\n\\right)  $ is an element of $\\left(  W_{N}\\left(  A\\right)  \\right)  ^{N}$).\r\n\r\n\\textbf{(b)} Let $P\\in N$, and let $A$ be a commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra. Let $w_{P}:W_{N}\\left(  A\\right)  \\rightarrow A$ be the\r\nmap sending each $\\mathbf{x}\\in W_{N}\\left(  A\\right)  $ to the $P$-th\r\ncoordinate of $w_{N}\\left(  \\mathbf{x}\\right)  $. Then, $W_{N}\\left(\r\nw_{P}\\right)  \\circ\\operatorname*{AH}=\\mathbf{f}_{P}$.\r\n\\end{theorem}\r\n\r\n\\subsection{\\label{subsect.F}$\\mathcal{F}$-modules}\r\n\r\nThe classical $N$-Witt vector functor for $N\\subseteq\\mathbb{N}_{+}$ being a\r\nnest is a functor $\\mathbf{CRing}\\rightarrow\\mathbf{CRing}$, and I don't see\r\nhow to extend it to any broader category than $\\mathbf{CRing}$. The proof of\r\nits well-definedness, at least, uses the whole ring structure, not just the\r\npower maps. The situation with $q$-nests and their Carlitz $N$-Witt vector\r\nfunctors is different, as mentioned in Remark \\ref{rmk.carlitz.gW.1'}. Let me\r\ndevelop this a bit further, although I don't really understand where this all\r\nis headed.\r\n\r\nLet $\\mathcal{F}$ be the $\\mathbb{F}_{q}$-algebra $\\mathbb{F}_{q}\\left\\langle\r\nF,T\\ \\mid\\ FT=T^{q}F\\right\\rangle $. This $\\mathcal{F}$ can be considered as a\r\nskew polynomial ring $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nF;\\ \\operatorname*{Frob}\\right]  $ over the polynomial ring $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $, where $\\operatorname*{Frob}:\\mathbb{F}_{q}\\left[\r\nT\\right]  \\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $ is the Frobenius\r\nendomorphism which sends every $a\\in\\mathbb{F}_{q}\\left[  T\\right]  $ to\r\n$a^{q}$.\r\n\r\nNote that $\\mathcal{F}$ is neither an $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebra nor an $\\mathbb{F}_{q}\\left[  F\\right]  $-algebra in the way I\r\nunderstand these words, since the center of $\\mathcal{F}$ is $\\mathbb{F}_{q}$.\r\nBut we have well-defined $\\mathbb{F}_{q}$-algebra homomorphisms $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ and $\\mathbb{F}_{q}\\left[\r\nF\\right]  \\rightarrow\\mathcal{F}$, which make $\\mathcal{F}$ into a left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module, a right $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module, a left $\\mathbb{F}_{q}\\left[  F\\right]  $-module, and a\r\nright $\\mathbb{F}_{q}\\left[  F\\right]  $-module. The left $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module structure on $\\mathcal{F}$ is probably the most\r\nuseful one.\r\n\r\n\\begin{itemize}\r\n\\item As left $\\mathbb{F}_{q}\\left[  T\\right]  $-module, $\\mathcal{F}$ is free\r\nwith basis $\\left(  F^{i}\\right)  _{i\\geq0}$ and thus torsionfree (this will\r\nbe useful).\r\n\r\n\\item As right $\\mathbb{F}_{q}\\left[  T\\right]  $-module, $\\mathcal{F}$ is\r\nfree with basis $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ 0\\leq j<q^{i}}$.\r\n\r\n\\item As right $\\mathbb{F}_{q}\\left[  F\\right]  $-module, $\\mathcal{F}$ is\r\nfree with basis $\\left(  T^{j}\\right)  _{j\\geq0}$.\r\n\r\n\\item As left $\\mathbb{F}_{q}\\left[  F\\right]  $-module, $\\mathcal{F}$ is free\r\nwith basis $\\left(  T^{j}F^{i}\\right)  _{i=0\\text{ or }q\\nmid j}$. As a\r\nconsequence, it is torsionfree (but this also follows from the isomorphism\r\n$\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ introduced below).\r\n\r\n\\item As $\\mathbb{F}_{q}\\left[  F\\right]  $-$\\mathbb{F}_{q}\\left[  T\\right]\r\n$-bimodule, $\\mathcal{F}$ is free with basis $\\left(  T^{j}F^{i}\\right)\r\n_{\\left(  i=0\\text{ or }q\\nmid j\\right)  \\text{ and }0\\leq j<q^{i}}$ (that is,\r\n$\\mathcal{F}=\\bigoplus\\limits_{\\substack{\\left(  i,j\\right)  \\in\\mathbb{N}%\r\n^{2};\\\\\\left(  i=0\\text{ or }q\\nmid j\\right)  \\text{ and }0\\leq j<q^{i}%\r\n}}\\mathbb{F}_{q}\\left[  F\\right]  \\cdot\\left(  T^{j}F^{i}\\right)\r\n\\cdot\\mathbb{F}_{q}\\left[  T\\right]  $, and each $\\mathbb{F}_{q}\\left[\r\nF\\right]  \\cdot\\left(  T^{j}F^{i}\\right)  \\cdot\\mathbb{F}_{q}\\left[  T\\right]\r\n$ is isomorphic to $\\mathbb{F}_{q}\\left[  F\\right]  \\otimes\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ as an $\\mathbb{F}_{q}\\left[  F\\right]  $%\r\n-$\\mathbb{F}_{q}\\left[  T\\right]  $-bimodule).\r\n\\end{itemize}\r\n\r\nThese freeness statements actually have little to do with $\\mathbb{F}_{q}$ or\r\nthe fact that $q$ is a prime power. They are combinatorial consequences of the\r\nfact that $\\mathcal{F}$ is the monoid algebra (over $\\mathbb{F}_{q}$) of the\r\nmonoid $\\left\\langle F,T\\ \\mid\\ FT=T^{q}F\\right\\rangle $, which monoid is\r\ncancellative and whose elements can be uniquely written in the form\r\n$T^{j}F^{i}$ with $\\left(  i,j\\right)  \\in\\mathbb{N}^{2}$. Actually, this\r\nmonoid is $\\mathcal{J}$-trivial. Finite $\\mathcal{J}$-trivial monoids have a\r\nvery nice representation theory \\cite{dhns}; does ours?\\footnote{I wouldn't\r\nhope for much; the representation theory of $\\left\\langle F,T\\ \\mid\r\n\\ FT=TF\\right\\rangle $ is supposedly ugly.}\r\n\r\nEvery commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra is canonically an\r\n$\\mathcal{F}$-module, by letting $T$ act as left multiplication with $T$, and\r\nletting $F$ act as taking the $q$-th power in the algebra.\r\n\r\nLet us notice that $FP=P^{q}F$ in $\\mathcal{F}$ for every $P\\in\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $. This is rather important; it yields that\r\n$\\mathcal{F}\\cdot P\\cdot\\mathcal{F}\\subseteq P\\cdot\\mathcal{F}$ for every\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nBy the universal property of the polynomial ring, there exists a unique\r\n$\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Carl}:\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ which sends $T$ to $F+T$. This\r\n$\\operatorname*{Carl}$ is a very important homomorphism.\r\n\r\nThere is another interesting, and important, map around here. Let\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$\r\nbe the $\\mathbb{F}_{q}\\left[  T\\right]  $-submodule of the polynomial ring\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ consisting of all\r\n$q$\\textbf{-polynomials}, i. e., polynomials in which only the monomials\r\n$X^{q^{0}}$, $X^{q^{1}}$, $X^{q^{2}}$, $...$ appear (we consider $T$ as a\r\nconstant here). Then, $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is not an algebra under usual multiplication, but a\r\n(noncommutative) algebra under composition (where again $X$ is the variable\r\nand $T$ a constant). It turns out that%\r\n\\begin{align*}\r\n\\mathcal{F}  &  \\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}},\\\\\r\nF  &  \\mapsto X^{q},\\\\\r\nT  &  \\mapsto TX\r\n\\end{align*}\r\nyields a well-defined $\\mathbb{F}_{q}$-algebra isomorphism $\\mathcal{F}%\r\n\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$. This is easy to check. This isomorphism allows\r\ntransferring some results from $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $ to $\\mathcal{F}$ (this is, for example, how I show that\r\n$\\mathcal{F}$ is a torsionfree right $\\mathbb{F}_{q}\\left[  T\\right]  $-module).\r\n\r\nIt can be shown that for every monic irreducible $\\pi\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $,%\r\n\\begin{equation}\r\n\\text{there exists a unique }u\\left(  \\pi\\right)  \\in\\mathcal{F}\\text{ such\r\nthat }\\operatorname*{Carl}\\pi=F^{\\deg\\pi}+\\pi\\cdot u\\left(  \\pi\\right)  .\r\n\\label{carl.pi}%\r\n\\end{equation}\r\n\\footnote{The notation $u\\left(  \\pi\\right)  $ means that $u$ depends on $\\pi\r\n$; it is not meant to imply that $u\\left(  \\pi\\right)  $ is a polynomial in\r\n$\\pi$.} Indeed, this follows easily from the fact that $\\left[  \\pi\\right]\r\n\\left(  X\\right)  \\equiv X^{q^{\\deg\\pi}}\\operatorname{mod}\\pi$ in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ using the isomorphism\r\n$\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$.\r\n\r\nNow, what is a left $\\mathcal{F}$-module? One way to see a left $\\mathcal{F}%\r\n$-module is as a left $\\mathbb{F}_{q}\\left[  T\\right]  $-module $A$ with an\r\n$\\mathbb{F}_{q}$-linear map $F:A\\rightarrow A$ which satisfies $F\\left(\r\nTa\\right)  =T^{q}F\\left(  a\\right)  $ for every $a\\in A$. This is easily seen\r\nto be equivalent to a left $\\mathbb{F}_{q}\\left[  T\\right]  $-module $A$ with\r\nan $\\mathbb{F}_{q}$-linear map $F:A\\rightarrow A$ which satisfies $F\\left(\r\n\\lambda a\\right)  =\\lambda^{q}F\\left(  a\\right)  $ for every $\\lambda\r\n\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $a\\in A$. In every left $\\mathcal{F}%\r\n$-module $A$, we can \\textbf{define} the operation of ``taking the $q$-th\r\npower'' by $a^{q}=F\\left(  a\\right)  $ for every $a\\in A$. Hence, we can\r\ndefine an operation of ``taking the $q^{i}$-th power'' for every $i\\geq0$.\r\nThis allows us to evaluate any Carlitz polynomial at elements of $A$; that is,\r\nfor any $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $a\\in A$ we can define\r\n$\\left[  P\\right]  \\left(  a\\right)  \\in A$ (in the same way as this is\r\nusually defined for $A$ being a commutative algebra). It is easily seen that%\r\n\\[\r\n\\left[  P\\right]  \\left(  a\\right)  =\\left(  \\operatorname*{Carl}\\left(\r\nP\\right)  \\right)  \\left(  a\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any }%\r\nP\\in\\mathbb{F}_{q}\\left[  T\\right]  \\text{ and }a\\in A.\r\n\\]\r\n\r\n\r\nNow, the situation described in Remark \\ref{rmk.carlitz.gW.1'} is simply\r\nunderstood as having a left $\\mathcal{F}$-module $A$, and for every $P\\in N$,\r\nan $\\mathcal{F}$-module endomorphism $\\varphi_{P}$ of $A$.\r\n\r\nThe category of left $\\mathcal{F}$-modules has its free objects, which simply\r\nare free left $\\mathcal{F}$-modules. If $\\Xi$ is a set (to be viewed as a set\r\nof ``indeterminates''), then a family of $\\mathcal{F}$-module endomorphisms\r\n$\\varphi_{P}$ of the free $\\mathcal{F}$-module $\\mathcal{F}\\Xi$ satisfying\r\nAssumptions 1', 2 and 3 can be easily constructed (namely, $\\varphi_{P}$ is\r\nthe unique $\\mathcal{F}$-module homomorphism $\\mathcal{F}\\Xi\\rightarrow\r\n\\mathcal{F}\\Xi$ satisfying $\\varphi_{P}\\left(  \\xi\\right)  =\\left[  P\\right]\r\n\\left(  \\xi\\right)  $ for every $\\xi\\in\\Xi$), although it took me a while to\r\nshow that they actually satisfy Assumption 2 (here I used (\\ref{carl.pi})).\r\n\r\nIf I haven't done any mistakes, all results of Subsection\r\n\\ref{subsect.carlitz-Witt} carry over to the category of $\\mathcal{F}%\r\n$-modules; of course, $W_{N}$ and $\\widetilde{W}_{N}$ will then be functors\r\nfrom $_{\\mathcal{F}}\\mathbf{Mod}$ to $_{\\mathcal{F}}\\mathbf{Mod}$. One has to\r\nbe somewhat careful in the proofs because $\\mathcal{F}$ is noncommutative and\r\nit needs to be used that every $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\nsatisfies $\\mathcal{F}\\cdot P\\cdot\\mathcal{F}\\subseteq P\\cdot\\mathcal{F}$.\r\n\r\n\\section{\\label{sect.proofs}Proofs}\r\n\r\nIn this (so far unfinished) Section, I am going to prove most of the\r\nstatements made in Section \\ref{sect.carlitzwitt}. I shall start from scratch\r\nand forget about all the notation introduced in Section \\ref{sect.carlitzwitt}%\r\n; this notation will be reintroduced when the need for it arises.\r\n\r\nIn Section \\ref{sect.carlitzwitt}, I presented the results for the case of\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebras first, and then\r\npointed out how they can be generalized to $\\mathcal{F}$-modules. In the\r\npresent Section \\ref{sect.proofs}, however, I will proceed the other way\r\nround, starting with the properties of $\\mathcal{F}$. The latter properties\r\nare unlikely to be new, as they are elementary and concern a well-studied\r\nobject ($\\mathcal{F}$ is one of the most basic examples of an Ore extension);\r\nin particular I suspect that some of them appear in \\cite{ore-pp1} and\r\n\\cite{ore-pp2} (two references I regrettably have not had the time to read).\r\n\r\n\\subsection{The skew polynomial ring $\\mathcal{M}$}\r\n\r\nLet us first show a general fact:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F-gen.bases}Let $\\mathbb{K}$ be a commutative ring. Let $r$ be a\r\npositive integer. Let $\\mathcal{M}$ be the $\\mathbb{K}$-algebra $\\mathbb{K}%\r\n\\left\\langle F,T\\ \\mid\\ FT=T^{r}F\\right\\rangle $. There are well-defined\r\n$\\mathbb{K}$-algebra homomorphisms $\\mathbb{K}\\left[  T\\right]  \\rightarrow\r\n\\mathcal{M}$ (sending $T$ to $T$) and $\\mathbb{K}\\left[  F\\right]\r\n\\rightarrow\\mathcal{M}$ (sending $F$ to $F$). These homomorphisms make\r\n$\\mathcal{M}$ into a left $\\mathbb{K}\\left[  T\\right]  $-module, a right\r\n$\\mathbb{K}\\left[  T\\right]  $-module, a left $\\mathbb{K}\\left[  F\\right]\r\n$-module, and a right $\\mathbb{K}\\left[  F\\right]  $-module. Any of these two\r\nleft module structures can be combined with any of these two right module\r\nstructures to form a bimodule structure on $\\mathcal{M}$ (for example, the\r\nleft $\\mathbb{K}\\left[  T\\right]  $-module structure and the right\r\n$\\mathbb{K}\\left[  F\\right]  $-module structure on $\\mathcal{M}$ can be\r\ncombined to form an $\\mathbb{K}\\left[  T\\right]  $-$\\mathbb{K}\\left[\r\nF\\right]  $-bimodule structure on $\\mathcal{M}$). (However, in general,\r\n$\\mathcal{M}$ is neither a $\\mathbb{K}\\left[  T\\right]  $-algebra nor a\r\n$\\mathbb{K}\\left[  F\\right]  $-algebra.)\r\n\r\n\\textbf{(a)} We have $F^{a}T^{b}=T^{r^{a}b}F^{a}$ in $\\mathcal{M}$ for every\r\n$a\\in\\mathbb{N}$ and $b\\in\\mathbb{N}$.\r\n\r\n\\textbf{(b)} The $\\mathbb{K}$-module $\\mathcal{M}$ is free with basis $\\left(\r\nT^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$.\r\n\r\n\\textbf{(c)} As left $\\mathbb{K}\\left[  T\\right]  $-module, $\\mathcal{M}$ is\r\nfree with basis $\\left(  F^{i}\\right)  _{i\\geq0}$.\r\n\r\n\\textbf{(d)} As right $\\mathbb{K}\\left[  T\\right]  $-module, $\\mathcal{M}$ is\r\nfree with basis $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ 0\\leq j<r^{i}}$.\r\n\r\n\\textbf{(e)} As right $\\mathbb{K}\\left[  F\\right]  $-module, $\\mathcal{M}$ is\r\nfree with basis $\\left(  T^{j}\\right)  _{j\\geq0}$.\r\n\r\n\\textbf{(f)} As left $\\mathbb{K}\\left[  F\\right]  $-module, $\\mathcal{M}$ is\r\nfree with basis $\\left(  T^{j}F^{i}\\right)  _{i=0\\text{ or }r\\nmid j}$.\r\n\r\n\\textbf{(g)} As $\\mathbb{K}\\left[  F\\right]  $-$\\mathbb{K}\\left[  T\\right]\r\n$-bimodule, $\\mathcal{M}$ is free with basis $\\left(  T^{j}F^{i}\\right)\r\n_{\\left(  i=0\\text{ or }r\\nmid j\\right)  \\text{ and }0\\leq j<r^{i}}$ (that is,\r\nwe have $\\mathcal{M}=\\bigoplus\\limits_{\\substack{\\left(  i,j\\right)\r\n\\in\\mathbb{N}^{2};\\\\\\left(  i=0\\text{ or }r\\nmid j\\right)  \\text{ and }0\\leq\r\nj<r^{i}}}\\mathbb{K}\\left[  F\\right]  \\cdot\\left(  T^{j}F^{i}\\right)\r\n\\cdot\\mathbb{K}\\left[  T\\right]  $, and each $\\mathbb{K}\\left[  F\\right]\r\n\\cdot\\left(  T^{j}F^{i}\\right)  \\cdot\\mathbb{K}\\left[  T\\right]  $ is\r\nisomorphic to $\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]\r\n$ as an $\\mathbb{K}\\left[  F\\right]  $-$\\mathbb{K}\\left[  T\\right]\r\n$-bimodule, where the tensor product is taken over $\\mathbb{K}$).\r\n\\end{proposition}\r\n\r\nWe notice that the $\\mathbb{K}$-algebra $\\mathcal{M}$ in Proposition\r\n\\ref{prop.F-gen.bases} is actually the monoid algebra (over $\\mathbb{K}$) of\r\nthe monoid with generators $F,T$ and relation $FT=T^{r}F$. From this\r\nviewpoint, all of Proposition \\ref{prop.F-gen.bases} is easily revealed to be\r\na monoid-theoretical statement (with $\\mathbb{K}$ being merely a distraction).\r\nHowever, we shall work with $\\mathbb{K}$-algebras rather than monoids for the\r\nwhole proof, if only for the sake of habitualness.\r\n\r\nThe only parts of Proposition \\ref{prop.F-gen.bases} that will be used in the\r\nfollowing are parts \\textbf{(a)}, \\textbf{(b)}, \\textbf{(c)} and \\textbf{(e)}.\r\nThese are also the easiest ones to prove, so we advise the reader to skip most\r\nof the following technical proof.\r\n\r\nThe following lemma will be used in our proof of Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(f)}:\r\n\r\n\\begin{lemma}\r\n\\label{lem.F-gen.bases.f.1}Let $S$ be a set. Let $\\phi:S\\rightarrow S$ be an\r\ninjective map. Let $\\ell:S\\rightarrow\\mathbb{N}$ be a map. Assume that%\r\n\\begin{equation}\r\n\\ell\\left(  \\phi\\left(  s\\right)  \\right)  >\\ell\\left(  s\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }s\\in S.\r\n\\label{eq.lem.F-gen.bases.f.1.ass}%\r\n\\end{equation}\r\nLet $B=S\\setminus\\phi\\left(  S\\right)  $. Define a map $\\rho:B\\times\r\n\\mathbb{N}\\rightarrow S$ by%\r\n\\[\r\n\\rho\\left(  s,k\\right)  =\\phi^{k}\\left(  s\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  s,k\\right)  \\in B\\times\r\n\\mathbb{N}.\r\n\\]\r\nThen, $\\rho$ is a bijection.\r\n\\end{lemma}\r\n\r\n(If we want to interpret Lemma \\ref{lem.F-gen.bases.f.1} constructively, then\r\nwe should also require that there is an algorithm which, given an $s\\in S$,\r\neither reveals that $s\\notin\\phi\\left(  S\\right)  $ or computes a preimage of\r\n$s$ under $\\phi$.)\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F-gen.bases.f.1}.]Let us first prove that the map\r\n$\\rho$ is injective.\r\n\r\nIndeed, let $\\left(  s,k\\right)  $ and $\\left(  s^{\\prime},k^{\\prime}\\right)\r\n$ be two elements of $B\\times\\mathbb{N}$ such that $\\rho\\left(  s,k\\right)\r\n=\\rho\\left(  s^{\\prime},k^{\\prime}\\right)  $. We are going to prove that\r\n$\\left(  s,k\\right)  =\\left(  s^{\\prime},k^{\\prime}\\right)  $.\r\n\r\nThe definition of $\\rho$ yields $\\rho\\left(  s,k\\right)  =\\phi^{k}\\left(\r\ns\\right)  $. Thus, $\\phi^{k}\\left(  s\\right)  =\\rho\\left(  s,k\\right)\r\n=\\rho\\left(  s^{\\prime},k^{\\prime}\\right)  =\\phi^{k^{\\prime}}\\left(\r\ns^{\\prime}\\right)  $ (by the definition of $\\rho$).\r\n\r\nThe map $\\phi^{k^{\\prime}}$ is injective (since $\\phi$ is injective).\r\n\r\nWe have $s^{\\prime}\\in B=S\\setminus\\phi\\left(  S\\right)  $. Thus, $s^{\\prime\r\n}\\notin\\phi\\left(  S\\right)  $.\r\n\r\nNow, assume (for the sake of contradiction) that $k>k^{\\prime}$. Hence,\r\n$\\phi^{k}\\left(  s\\right)  =\\phi^{k^{\\prime}+\\left(  k-k^{\\prime}\\right)\r\n}\\left(  s\\right)  =\\phi^{k^{\\prime}}\\left(  \\phi^{k-k^{\\prime}}\\left(\r\ns\\right)  \\right)  $. But the map $\\phi^{k^{\\prime}}$ is injective. Therefore,\r\nfrom $\\phi^{k^{\\prime}}\\left(  \\phi^{k-k^{\\prime}}\\left(  s\\right)  \\right)\r\n=\\phi^{k}\\left(  s\\right)  =\\phi^{k^{\\prime}}\\left(  s^{\\prime}\\right)  $, we\r\nobtain $\\phi^{k-k^{\\prime}}\\left(  s\\right)  =s^{\\prime}$. Hence, $s^{\\prime\r\n}=\\phi^{k-k^{\\prime}}\\left(  s\\right)  \\in\\phi^{k-k^{\\prime}}\\left(  S\\right)\r\n\\subseteq\\phi\\left(  S\\right)  $ (since $k-k^{\\prime}\\geq1$ (since\r\n$k>k^{\\prime}$)). This contradicts $s^{\\prime}\\notin\\phi\\left(  S\\right)  $.\r\nThis contradiction proves that our assumption (that $k>k^{\\prime}$) was false.\r\nHence, we cannot have $k>k^{\\prime}$. In other words, we must have $k\\leq\r\nk^{\\prime}$. An analogous argument shows that $k^{\\prime}\\leq k$. Combining\r\nthis with $k\\leq k^{\\prime}$, we obtain $k=k^{\\prime}$. Thus, $\\phi^{k}\\left(\r\ns\\right)  =\\phi^{k^{\\prime}}\\left(  s\\right)  $, so that $\\phi^{k^{\\prime}%\r\n}\\left(  s\\right)  =\\phi^{k}\\left(  s\\right)  =\\phi^{k^{\\prime}}\\left(\r\ns^{\\prime}\\right)  $. This yields $s=s^{\\prime}$ (since the map $\\phi\r\n^{k^{\\prime}}$ is injective). Combining this with $k=k^{\\prime}$, we obtain\r\n$\\left(  s,k\\right)  =\\left(  s^{\\prime},k^{\\prime}\\right)  $.\r\n\r\nLet us now forget that we fixed $\\left(  s,k\\right)  $ and $\\left(  s^{\\prime\r\n},k^{\\prime}\\right)  $. We thus have shown that if $\\left(  s,k\\right)  $ and\r\n$\\left(  s^{\\prime},k^{\\prime}\\right)  $ are two elements of $B\\times\r\n\\mathbb{N}$ such that $\\rho\\left(  s,k\\right)  =\\rho\\left(  s^{\\prime\r\n},k^{\\prime}\\right)  $, then $\\left(  s,k\\right)  =\\left(  s^{\\prime\r\n},k^{\\prime}\\right)  $. In other words, the map $\\rho$ is injective.\r\n\r\nLet us now show that the map $\\rho$ is surjective. Indeed, we shall prove that%\r\n\\begin{equation}\r\n\\ell^{-1}\\left(  n\\right)  \\subseteq\\rho\\left(  B\\times\\mathbb{N}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}.\r\n\\label{pf.lem.F-gen.bases.f.1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.lem.F-gen.bases.f.1}):} We shall prove\r\n(\\ref{pf.lem.F-gen.bases.f.1}) by strong induction over $n$. Thus, we fix an\r\n$N\\in\\mathbb{N}$, and we assume (as the induction hypothesis) that\r\n(\\ref{pf.lem.F-gen.bases.f.1}) holds for every $n<N$. Now we must prove that\r\n(\\ref{pf.lem.F-gen.bases.f.1}) holds for $n=N$. In other words, we must prove\r\nthat $\\ell^{-1}\\left(  N\\right)  \\subseteq\\rho\\left(  B\\times\\mathbb{N}%\r\n\\right)  $.\r\n\r\nLet $x\\in\\ell^{-1}\\left(  N\\right)  $. Thus, $x\\in S$ and $\\ell\\left(\r\nx\\right)  =N$. We shall prove that $x\\in\\rho\\left(  B\\times\\mathbb{N}\\right)\r\n$.\r\n\r\nIf $x\\notin\\phi\\left(  S\\right)  $, then $x\\in\\rho\\left(  B\\times\r\n\\mathbb{N}\\right)  $ holds\\footnote{\\textit{Proof.} Assume that $x\\notin%\r\n\\phi\\left(  S\\right)  $. Thus, $x\\in S\\setminus\\phi\\left(  S\\right)  =B$, so\r\nthat $\\left(  x,0\\right)  \\in B\\times\\mathbb{N}$. Clearly, $\\rho\\left(\r\nx,0\\right)  =\\phi^{0}\\left(  x\\right)  =x$, so that $x=\\rho\\left(  x,0\\right)\r\n\\in\\rho\\left(  B\\times\\mathbb{N}\\right)  $, qed.}. Hence, for the rest of the\r\nproof of $x\\subseteq\\rho\\left(  B\\times\\mathbb{N}\\right)  $, we can WLOG\r\nassume that $x\\in\\phi\\left(  S\\right)  $. Assume this. Thus, there exists an\r\n$s\\in S$ such that $x=\\phi\\left(  s\\right)  $. Consider this $s$. From\r\n$x=\\phi\\left(  s\\right)  $, we obtain $\\ell\\left(  x\\right)  =\\ell\\left(\r\n\\phi\\left(  s\\right)  \\right)  >\\ell\\left(  s\\right)  $ (by\r\n(\\ref{eq.lem.F-gen.bases.f.1.ass})). Hence, $\\ell\\left(  s\\right)\r\n<\\ell\\left(  x\\right)  =N$. Therefore, the induction hypothesis shows that\r\n(\\ref{pf.lem.F-gen.bases.f.1}) holds for $n=\\ell\\left(  s\\right)  $. In other\r\nwords, $\\ell^{-1}\\left(  \\ell\\left(  s\\right)  \\right)  \\subseteq\\rho\\left(\r\nB\\times\\mathbb{N}\\right)  $. But $s\\in\\ell^{-1}\\left(  \\ell\\left(  s\\right)\r\n\\right)  \\subseteq\\rho\\left(  B\\times\\mathbb{N}\\right)  $. In other words,\r\nthere exists a $\\left(  t,k\\right)  \\in B\\times\\mathbb{N}$ such that\r\n$s=\\rho\\left(  t,k\\right)  $. Consider this $\\left(  t,k\\right)  $. We have\r\n$s=\\rho\\left(  t,k\\right)  =\\phi^{k}\\left(  t\\right)  $ (by the definition of\r\n$\\rho$), and $x=\\phi\\left(  \\underbrace{s}_{=\\phi^{k}\\left(  t\\right)\r\n}\\right)  =\\phi\\left(  \\phi^{k}\\left(  t\\right)  \\right)  =\\phi^{k+1}\\left(\r\nt\\right)  $. Comparing this with $\\rho\\left(  t,k+1\\right)  =\\phi^{k+1}\\left(\r\nt\\right)  $ (by the definition of $\\rho$), we obtain $x=\\rho\\left(\r\nt,k+1\\right)  \\in\\rho\\left(  B\\times\\mathbb{N}\\right)  $. Hence, $x\\in\r\n\\rho\\left(  B\\times\\mathbb{N}\\right)  $ is proven.\r\n\r\nLet us now forget that we fixed $x$. We thus have shown that $x\\in\\rho\\left(\r\nB\\times\\mathbb{N}\\right)  $ for every $x\\in\\ell^{-1}\\left(  N\\right)  $. In\r\nother words, $\\ell^{-1}\\left(  N\\right)  \\subseteq\\rho\\left(  B\\times\r\n\\mathbb{N}\\right)  $. In other words, (\\ref{pf.lem.F-gen.bases.f.1}) holds for\r\n$n=N$. This completes the induction proof of (\\ref{pf.lem.F-gen.bases.f.1}).\r\n\r\nNow, $\\ell$ is a map $S\\rightarrow\\mathbb{N}$. Hence, $S=\\bigcup\r\n_{n\\in\\mathbb{N}}\\underbrace{\\ell^{-1}\\left(  n\\right)  }_{\\substack{\\subseteq\r\n\\rho\\left(  B\\times\\mathbb{N}\\right)  \\\\\\text{(by\r\n(\\ref{pf.lem.F-gen.bases.f.1}))}}}\\subseteq\\bigcup_{n\\in\\mathbb{N}}\\rho\\left(\r\nB\\times\\mathbb{N}\\right)  \\subseteq\\rho\\left(  B\\times\\mathbb{N}\\right)  $. In\r\nother words, the map $\\rho$ is surjective. Hence, the map $\\rho$ is bijective\r\n(since we already know that $\\rho$ is injective). This proves Lemma\r\n\\ref{lem.F-gen.bases.f.1}.\r\n\\end{proof}\r\n\r\nWe record two corollaries of Lemma \\ref{lem.F-gen.bases.f.1}:\r\n\r\n\\begin{corollary}\r\n\\label{cor.F-gen.bases.f.1.cor1}Define a subset $B$ of $\\mathbb{N}^{2}$ by%\r\n\\begin{equation}\r\nB=\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\\ i=0\\text{ or }r\\nmid\r\nj\\right\\}  . \\label{eq.cor.F-gen.bases.f.1.cor1.def-B}%\r\n\\end{equation}\r\nDefine a map $\\rho:B\\times\\mathbb{N}\\rightarrow\\mathbb{N}^{2}$ by%\r\n\\begin{equation}\r\n\\rho\\left(  \\left(  i,j\\right)  ,k\\right)  =\\left(  i+k,r^{k}j\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  \\left(  i,j\\right)  ,k\\right)\r\n\\in B\\times\\mathbb{N}. \\label{eq.cor.F-gen.bases.f.1.cor1.def-rho}%\r\n\\end{equation}\r\nThen, the map $\\rho$ is a bijection.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F-gen.bases.f.1.cor1}.]Let $\\phi:\\mathbb{N}%\r\n^{2}\\rightarrow\\mathbb{N}^{2}$ be the map defined by%\r\n\\[\r\n\\phi\\left(  i,j\\right)  =\\left(  i+1,rj\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }\\left(  i,j\\right)  \\in\\mathbb{N}^{2}.\r\n\\]\r\nIt is clear that this map $\\phi$ is injective (since $r>0$). Moreover,\r\n$B=\\mathbb{N}^{2}\\setminus\\phi\\left(  \\mathbb{N}^{2}\\right)  $%\r\n\\ \\ \\ \\ \\footnote{\\textit{Proof.} We have\r\n\\begin{align*}\r\n&  \\mathbb{N}^{2}\\setminus\\phi\\left(  \\mathbb{N}^{2}\\right) \\\\\r\n&  =\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\\ \\text{there exists\r\nno }\\left(  u,v\\right)  \\in\\mathbb{N}^{2}\\text{ such that }\\left(  i,j\\right)\r\n=\\underbrace{\\phi\\left(  u,v\\right)  }_{\\substack{=\\left(  u+1,rv\\right)\r\n\\\\\\text{(by the definition of }\\phi\\text{)}}}\\right\\} \\\\\r\n&  =\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\r\n\\ \\underbrace{\\text{there exists no }\\left(  u,v\\right)  \\in\\mathbb{N}%\r\n^{2}\\text{ such that }\\left(  i,j\\right)  =\\left(  u+1,rv\\right)\r\n}_{\\substack{\\Longleftrightarrow\\ \\left(  \\left(  i-1,j/r\\right)\r\n\\notin\\mathbb{N}^{2}\\right)  \\\\\\Longleftrightarrow\\ \\left(  i-1\\notin%\r\n\\mathbb{N}\\text{ or }j/r\\notin\\mathbb{N}\\right)  }}\\right\\} \\\\\r\n&  =\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\r\n\\ \\underbrace{i-1\\notin\\mathbb{N}}_{\\Longleftrightarrow\\ \\left(  i=0\\right)\r\n}\\text{ or }\\underbrace{j/r\\notin\\mathbb{N}}_{\\Longleftrightarrow\\ \\left(\r\nr\\nmid j\\right)  }\\right\\} \\\\\r\n&  =\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\\ i=0\\text{ or }r\\nmid\r\nj\\right\\}  =B,\r\n\\end{align*}\r\nqed.}. Given an $s\\in S$, it is easy to algorithmically check whether\r\n$s\\notin\\phi\\left(  \\mathbb{N}^{2}\\right)  $ (because of the equivalence\r\n$s\\notin\\phi\\left(  \\mathbb{N}^{2}\\right)  \\ \\Longleftrightarrow\r\n\\ s\\in\\underbrace{\\mathbb{N}^{2}\\setminus\\phi\\left(  \\mathbb{N}^{2}\\right)\r\n}_{=B}\\ \\Longleftrightarrow\\ s\\in B$), and if $s\\in\\phi\\left(  \\mathbb{N}%\r\n^{2}\\right)  $, then it is easy to compute a preimage of $s$ under $\\phi$\r\n(indeed, if $s=\\left(  i,j\\right)  \\in\\phi\\left(  \\mathbb{N}^{2}\\right)  $,\r\nthen $\\phi^{-1}\\left(  s\\right)  =\\left(  i-1,j/r\\right)  $).\r\n\r\nEvery $\\left(  i,j\\right)  \\in\\mathbb{N}^{2}$ and $k\\in\\mathbb{N}$ satisfy%\r\n\\begin{equation}\r\n\\phi^{k}\\left(  i,j\\right)  =\\left(  i+k,r^{k}j\\right)  .\r\n\\label{pf.cor.F-gen.bases.f.1.cor1.1}%\r\n\\end{equation}\r\n(Indeed, this follows easily by induction on $k$.) Thus,%\r\n\\begin{equation}\r\n\\rho\\left(  s,k\\right)  =\\phi^{k}\\left(  s\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  s,k\\right)  \\in B\\times\\mathbb{N}\r\n\\label{pf.cor.F-gen.bases.f.1.cor1.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.cor.F-gen.bases.f.1.cor1.3}):} Let\r\n$\\left(  s,k\\right)  \\in B\\times\\mathbb{N}$. Then, $s\\in B\\subseteq\r\n\\mathbb{N}^{2}$. Hence, $s$ can be written in the form $\\left(  i,j\\right)  $\r\nfor some $i,j\\in\\mathbb{N}$. Consider these $i,j$. We have%\r\n\\begin{align*}\r\n\\phi^{k}\\left(  \\underbrace{s}_{=\\left(  i,j\\right)  }\\right)   &  =\\phi\r\n^{k}\\left(  i,j\\right)  =\\left(  i+k,r^{k}j\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{pf.cor.F-gen.bases.f.1.cor1.1}%\r\n)}\\right) \\\\\r\n&  =\\rho\\left(  \\underbrace{\\left(  i,j\\right)  }_{=s},k\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{eq.cor.F-gen.bases.f.1.cor1.def-rho})}\\right) \\\\\r\n&  =\\rho\\left(  s,k\\right)  .\r\n\\end{align*}\r\nThis proves (\\ref{pf.cor.F-gen.bases.f.1.cor1.3}).}.\r\n\r\nFurthermore, define a map $\\ell:\\mathbb{N}^{2}\\rightarrow\\mathbb{N}$ by\r\n\\[\r\n\\ell\\left(  i,j\\right)  =i\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(\r\ni,j\\right)  \\in\\mathbb{N}^{2}.\r\n\\]\r\nIt is easy to see that for every $s\\in\\mathbb{N}^{2}$, we have $\\ell\\left(\r\n\\phi\\left(  s\\right)  \\right)  =\\ell\\left(  s\\right)  +1>\\ell\\left(  s\\right)\r\n$. Thus, we can apply Lemma \\ref{lem.F-gen.bases.f.1} to $S=\\mathbb{N}^{2}$\r\n(indeed, the equality (\\ref{pf.cor.F-gen.bases.f.1.cor1.3}) shows that our map\r\n$\\rho:B\\times\\mathbb{N}\\rightarrow\\mathbb{N}^{2}$ is identical with the map\r\n$\\rho:B\\times\\mathbb{N}\\rightarrow S$ in Lemma \\ref{lem.F-gen.bases.f.1}). As\r\na result, we conclude that $\\rho$ is a bijection. This proves Corollary\r\n\\ref{cor.F-gen.bases.f.1.cor1}.\r\n\\end{proof}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F-gen.bases.f.1.cor2}Define a subset $C$ of $\\mathbb{N}^{2}$ by%\r\n\\begin{equation}\r\nC=\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\\ \\left(  i=0\\text{ or\r\n}r\\nmid j\\right)  \\text{ and }0\\leq j<r^{i}\\right\\}  .\r\n\\label{eq.cor.F-gen.bases.f.1.cor2.def-C}%\r\n\\end{equation}\r\nDefine a map $\\zeta:C\\times\\mathbb{N}\\times\\mathbb{N}\\rightarrow\\mathbb{N}%\r\n^{2}$ by%\r\n\\begin{equation}\r\n\\zeta\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)  =\\left(  i+k,r^{k}\\left(\r\nj+r^{i}\\ell\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(\r\n\\left(  i,j\\right)  ,k,\\ell\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}.\r\n\\label{eq.cor.F-gen.bases.f.1.cor2.def-zeta}%\r\n\\end{equation}\r\nThen, the map $\\zeta$ is a bijection.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F-gen.bases.f.1.cor2}.]Define a subset $B$ of\r\n$\\mathbb{N}^{2}$ by (\\ref{eq.cor.F-gen.bases.f.1.cor1.def-B}). Clearly,\r\n$C\\subseteq B$.\r\n\r\nDefine a map $\\tau:C\\times\\mathbb{N}\\rightarrow B$ by\r\n\\[\r\n\\tau\\left(  \\left(  i,j\\right)  ,\\ell\\right)  =\\left(  i,j+r^{i}\\ell\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  \\left(  i,j\\right)  ,\\ell\\right)\r\n\\in C\\times\\mathbb{N}.\r\n\\]\r\nIt is easy to see that this map $\\tau$ is well-defined (i.e., that $\\left(\r\ni,j+r^{i}\\ell\\right)  \\in B$ for every $\\left(  \\left(  i,j\\right)\r\n,\\ell\\right)  \\in C\\times\\mathbb{N}$).\r\n\r\nFor every integer $u$ and every positive integer $v$, we let $u\\%v$ denote the\r\nremainder of $u$ when divided by $v$, and we let $u//v$ denote the quotient of\r\n$u$ when divided by $v$ with remainder. Thus, $u//v\\in\\mathbb{Z}$,\r\n$u\\%v\\in\\left\\{  0,1,\\ldots,v-1\\right\\}  $ and $u=\\left(  u//v\\right)  v+u\\%v$.\r\n\r\nDefine a map $\\gamma:B\\rightarrow C\\times\\mathbb{N}$ by%\r\n\\[\r\n\\gamma\\left(  i,j\\right)  =\\left(  \\left(  i,j\\%r^{i}\\right)  ,j//r^{i}%\r\n\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  i,j\\right)  \\in B.\r\n\\]\r\nAgain, it is easy to see that this map $\\gamma$ is well-defined (i.e., that\r\n$\\left(  \\left(  i,j\\%r^{i}\\right)  ,j//r^{i}\\right)  \\in C\\times\\mathbb{N}$\r\nfor every $\\left(  i,j\\right)  \\in B$).\r\n\r\nFurthermore, it is easy to see that the maps $\\tau$ and $\\gamma$ are mutually\r\ninverse\\footnote{\\textit{Proof.} Let us first show that $\\tau\\circ\r\n\\gamma=\\operatorname*{id}$.\r\n\\par\r\nIndeed, every $\\left(  i,j\\right)  \\in B$ satisfies%\r\n\\begin{align*}\r\n\\left(  \\tau\\circ\\gamma\\right)  \\left(  i,j\\right)   &  =\\tau\\left(\r\n\\underbrace{\\gamma\\left(  i,j\\right)  }_{=\\left(  \\left(  i,j\\%r^{i}\\right)\r\n,j//r^{i}\\right)  }\\right)  =\\tau\\left(  \\left(  i,j\\%r^{i}\\right)\r\n,j//r^{i}\\right)  =\\left(  i,\\underbrace{j\\%r^{i}+r^{i}\\left(  j//r^{i}%\r\n\\right)  }_{=j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\tau\\right) \\\\\r\n&  =\\left(  i,j\\right)  .\r\n\\end{align*}\r\nThus, $\\tau\\circ\\gamma=\\operatorname*{id}$.\r\n\\par\r\nOn the other hand, let us prove that $\\gamma\\circ\\tau=\\operatorname*{id}$.\r\nIndeed, fix $\\left(  \\left(  i,j\\right)  ,\\ell\\right)  \\in C\\times\\mathbb{N}$.\r\nThen, $\\left(  i,j\\right)  \\in C$. Thus, $\\left(  i=0\\text{ or }r\\nmid\r\nj\\right)  $ and $0\\leq j<r^{i}$. Now,%\r\n\\begin{align*}\r\n\\left(  \\gamma\\circ\\tau\\right)  \\left(  \\left(  i,j\\right)  ,\\ell\\right)   &\r\n=\\gamma\\left(  \\underbrace{\\tau\\left(  \\left(  i,j\\right)  ,\\ell\\right)\r\n}_{=\\left(  i,j+r^{i}\\ell\\right)  }\\right)  =\\gamma\\left(  i,j+r^{i}%\r\n\\ell\\right) \\\\\r\n&  =\\left(  \\left(  i,\\underbrace{\\left(  j+r^{i}\\ell\\right)  \\%r^{i}%\r\n}_{\\substack{=j\\\\\\text{(since }0\\leq j<r^{i}\\text{)}}}\\right)\r\n,\\underbrace{\\left(  j+r^{i}\\ell\\right)  //r^{i}}_{\\substack{=\\ell\r\n\\\\\\text{(since }0\\leq j<r^{i}\\text{)}}}\\right)  =\\left(  \\left(  i,j\\right)\r\n,\\ell\\right)  .\r\n\\end{align*}\r\nThis proves that $\\gamma\\circ\\tau=\\operatorname*{id}$. Combining this with\r\n$\\tau\\circ\\gamma=\\operatorname*{id}$, we obtain that the maps $\\tau$ and\r\n$\\gamma$ are mutually inverse, qed.}. Hence, the map $\\tau$ is a bijection.\r\n\r\nWe shall identify the set $C\\times\\mathbb{N}\\times\\mathbb{N}$ with $\\left(\r\nC\\times\\mathbb{N}\\right)  \\times\\mathbb{N}$. Then, the map $\\tau\r\n\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}}:\\left(  C\\times\\mathbb{N}%\r\n\\right)  \\times\\mathbb{N}\\rightarrow B\\times\\mathbb{N}$ can be viewed as a map\r\n$C\\times\\mathbb{N}\\times\\mathbb{N}\\rightarrow B\\times\\mathbb{N}$. This map\r\n$\\tau\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}}$ sends every $\\left(\r\n\\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}$ to\r\n$\\left(  \\tau\\left(  \\left(  i,j\\right)  ,\\ell\\right)  ,k\\right)  $. Clearly,\r\nthe map $\\tau\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}}$ is a bijection\r\n(since $\\tau$ is a bijection).\r\n\r\nOn the other hand, define a map $\\rho$ as in Corollary\r\n\\ref{cor.F-gen.bases.f.1.cor1}. Then, Corollary \\ref{cor.F-gen.bases.f.1.cor1}\r\nshows that the map $\\rho$ is a bijection. But every $\\left(  \\left(\r\ni,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}$ satisfies%\r\n\\begin{align*}\r\n&  \\left(  \\rho\\circ\\left(  \\tau\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}%\r\n}\\right)  \\right)  \\left(  \\left(  i,j\\right)  ,\\ell,k\\right) \\\\\r\n&  =\\rho\\left(  \\underbrace{\\left(  \\tau\\times\\operatorname*{id}%\r\n\\nolimits_{\\mathbb{N}}\\right)  \\left(  \\left(  i,j\\right)  ,\\ell,k\\right)\r\n}_{=\\left(  \\tau\\left(  \\left(  i,j\\right)  ,\\ell\\right)  ,k\\right)  }\\right)\r\n=\\rho\\left(  \\left(  \\underbrace{\\tau\\left(  \\left(  i,j\\right)  ,\\ell\\right)\r\n}_{=\\left(  i,j+r^{i}\\ell\\right)  },k\\right)  \\right) \\\\\r\n&  =\\rho\\left(  \\left(  i,j+r^{i}\\ell\\right)  ,k\\right)  =\\left(\r\ni+k,r^{k}\\left(  j+r^{i}\\ell\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by the definition of }\\rho\\right) \\\\\r\n&  =\\zeta\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{eq.cor.F-gen.bases.f.1.cor2.def-zeta})}\\right)  .\r\n\\end{align*}\r\nHence, $\\rho\\circ\\left(  \\tau\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}%\r\n}\\right)  =\\zeta$. Since the map $\\rho\\circ\\left(  \\tau\\times\r\n\\operatorname*{id}\\nolimits_{\\mathbb{N}}\\right)  $ is a bijection (because\r\nboth $\\rho$ and $\\tau\\times\\operatorname*{id}\\nolimits_{\\mathbb{N}}$ are\r\nbijections), this shows that the map $\\zeta$ is a bijection. This proves\r\nCorollary \\ref{cor.F-gen.bases.f.1.cor2}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F-gen.bases}.]\\textbf{(a)} First, we have the\r\nequality\r\n\\begin{equation}\r\nFT^{b}=T^{rb}F \\label{pf.prop.F-gen.bases.a.1}%\r\n\\end{equation}\r\nin $\\mathcal{M}$ for every $b\\in\\mathbb{N}$ (this can be proven by\r\nstraightforward induction over $b$). Using this equality, Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(a)} can be proven by straightforward induction\r\nover $a$.\r\n\r\n\\textbf{(b)} Let $\\mathcal{N}$ be the free $\\mathbb{K}$-module with basis\r\n$\\left(  a_{i,j}\\right)  _{i\\geq0,\\ j\\geq0}$. We let $\\mathfrak{f}$ be the\r\n$\\mathbb{K}$-linear map $\\mathcal{N}\\rightarrow\\mathcal{N}$ which sends every\r\n$a_{i,j}$ to $a_{i+1,rj}$. We let $\\mathfrak{t}$ be the $\\mathbb{K}$-linear\r\nmap $\\mathcal{N}\\rightarrow\\mathcal{N}$ which sends every $a_{i,j}$ to\r\n$a_{i,j+1}$. Every $i,j,k\\in\\mathbb{N}$ satisfy%\r\n\\begin{equation}\r\n\\mathfrak{f}^{k}\\left(  a_{i,j}\\right)  =a_{i+k,r^{k}j}\r\n\\label{pf.prop.F-gen.bases.b.1}%\r\n\\end{equation}\r\nand\r\n\\begin{equation}\r\n\\mathfrak{t}^{k}\\left(  a_{i,j}\\right)  =a_{i,j+k}.\r\n\\label{pf.prop.F-gen.bases.b.2}%\r\n\\end{equation}\r\n(Both of these equalities are easily proven by induction over $k$.) Using\r\n(\\ref{pf.prop.F-gen.bases.b.2}), it is easy to see that $\\mathfrak{f}%\r\n\\circ\\mathfrak{t}=\\mathfrak{t}^{r}\\circ\\mathfrak{f}$. Thus, we can define a\r\n$\\mathbb{K}$-algebra homomorphism $\\Phi:\\mathcal{M}\\rightarrow\r\n\\operatorname*{End}\\mathcal{N}$ by setting%\r\n\\begin{equation}\r\n\\Phi\\left(  F\\right)  =\\mathfrak{f}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\Phi\\left(  T\\right)  =\\mathfrak{t}\r\n\\label{pf.prop.F-gen.bases.b.3}%\r\n\\end{equation}\r\n(where $\\operatorname*{End}\\mathcal{N}$ denotes the $\\mathbb{K}$-algebra of\r\nall $\\mathbb{K}$-module endomorphisms of $\\mathcal{N}$). Consider this $\\Phi$.\r\nFor every $i,j\\in\\mathbb{N}$, we have%\r\n\\[\r\n\\Phi\\left(  T^{j}F^{i}\\right)  =\\Phi\\left(  T\\right)  ^{j}\\circ\\Phi\\left(\r\nF\\right)  ^{i}=\\mathfrak{t}^{j}\\circ\\mathfrak{f}^{i}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{pf.prop.F-gen.bases.b.3})}\\right)\r\n\\]\r\nand thus%\r\n\\begin{align}\r\n\\underbrace{\\left(  \\Phi\\left(  T^{j}F^{i}\\right)  \\right)  }_{=\\mathfrak{t}%\r\n^{j}\\circ\\mathfrak{f}^{i}}\\left(  a_{0,0}\\right)   &  =\\left(  \\mathfrak{t}%\r\n^{j}\\circ\\mathfrak{f}^{i}\\right)  \\left(  a_{0,0}\\right)  =\\mathfrak{t}%\r\n^{j}\\left(  \\underbrace{\\mathfrak{f}^{i}\\left(  a_{0,0}\\right)  }%\r\n_{\\substack{=a_{i,0}\\\\\\text{(by (\\ref{pf.prop.F-gen.bases.b.1}))}}}\\right)\r\n\\nonumber\\\\\r\n&  =\\mathfrak{t}^{j}\\left(  a_{i,0}\\right)  =a_{i,j}\r\n\\label{pf.prop.F-gen.bases.b.4}%\r\n\\end{align}\r\n(by (\\ref{pf.prop.F-gen.bases.b.2})). Hence, the family $\\left(  T^{j}%\r\nF^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ of elements of $\\mathcal{M}$ is $\\mathbb{K}%\r\n$-linearly independent\\footnote{because any linear dependence relation\r\n$\\sum_{i\\geq0,\\ j\\geq0}\\lambda_{i,j}T^{j}F^{i}=0$ would yield\r\n\\begin{align*}\r\n\\sum_{i\\geq0,\\ j\\geq0}\\lambda_{i,j}\\underbrace{a_{i,j}}_{\\substack{=\\left(\r\n\\Phi\\left(  T^{j}F^{i}\\right)  \\right)  \\left(  a_{0,0}\\right)  \\\\\\text{(by\r\n(\\ref{pf.prop.F-gen.bases.b.4}))}}}  &  =\\sum_{i\\geq0,\\ j\\geq0}\\lambda\r\n_{i,j}\\left(  \\Phi\\left(  T^{j}F^{i}\\right)  \\right)  \\left(  a_{0,0}\\right)\r\n\\\\\r\n&  =\\left(  \\Phi\\left(  \\underbrace{\\sum_{i\\geq0,\\ j\\geq0}\\lambda_{i,j}%\r\nT^{j}F^{i}}_{=0}\\right)  \\right)  \\left(  a_{0,0}\\right)  =0,\r\n\\end{align*}\r\nwhich would lead to $\\left(  \\lambda_{i,j}\\right)  _{i\\geq0,\\ j\\geq0}=\\left(\r\n0\\right)  _{i\\geq0,\\ j\\geq0}$ since the family $\\left(  a_{i,j}\\right)\r\n_{i\\geq0,\\ j\\geq0}$ is linearly independent}.\r\n\r\nLet us now show that this family spans $\\mathcal{M}$. Indeed, let\r\n$\\mathcal{M}^{\\prime}$ be the $\\mathbb{K}$-submodule of $\\mathcal{M}$ spanned\r\nby the family $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$. Then,\r\n$1=T^{0}F^{0}\\in\\mathcal{M}^{\\prime}$. Moreover, the $\\mathbb{K}$-submodule\r\n$\\mathcal{M}^{\\prime}$ satisfies $T\\mathcal{M}^{\\prime}\\subseteq\r\n\\mathcal{M}^{\\prime}$ (since $T\\cdot T^{j}F^{i}=T^{j+1}F^{i}$ for every\r\n$i,j\\in\\mathbb{N}$) and $F\\mathcal{M}^{\\prime}\\subseteq\\mathcal{M}^{\\prime}$\r\n(since $F\\cdot T^{j}F^{i}=\\underbrace{FT^{j}}_{\\substack{=T^{rj}F\\\\\\text{(by\r\n(\\ref{pf.prop.F-gen.bases.a.1}))}}}F^{i}=T^{rj}FF^{i}=T^{rj}F^{i+1}$ for every\r\n$i,j\\in\\mathbb{N}$). Hence, $\\mathcal{M}^{\\prime}$ is a left $\\mathcal{M}%\r\n$-submodule of $\\mathcal{M}$ (since the $\\mathbb{K}$-algebra $\\mathcal{M}$ is\r\ngenerated by $F$ and $T$)\\ \\ \\ \\ \\footnote{This argument in more detail:\r\n\\par\r\nThe $\\mathbb{K}$-algebra $\\mathcal{M}$ is generated by $F$ and $T$. From this,\r\nit is easy to derive the following fact: If $\\mathcal{V}$ is an $\\mathbb{K}%\r\n$-vector subspace of some left $\\mathcal{M}$-module $\\mathcal{U}$ satisfying\r\n$F\\mathcal{V}\\subseteq\\mathcal{V}$ and $T\\mathcal{V}\\subseteq\\mathcal{V}$,\r\nthen $\\mathcal{V}$ is a left $\\mathcal{M}$-submodule of $\\mathcal{U}$.\r\nApplying this to $\\mathcal{U}=\\mathcal{M}$ and $\\mathcal{V}=\\mathcal{M}%\r\n^{\\prime}$, we conclude that $\\mathcal{M}^{\\prime}$ is a left $\\mathcal{M}%\r\n$-submodule of $\\mathcal{M}$ (since $F\\mathcal{M}^{\\prime}\\subseteq\r\n\\mathcal{M}^{\\prime}$ and $T\\mathcal{M}^{\\prime}\\subseteq\\mathcal{M}^{\\prime}%\r\n$).}. Therefore, $\\mathcal{M}\\cdot\\mathcal{M}^{\\prime}\\subseteq\\mathcal{M}%\r\n^{\\prime}$. But $\\mathcal{M}=\\mathcal{M}\\cdot\\underbrace{1}_{\\in\r\n\\mathcal{M}^{\\prime}}\\subseteq\\mathcal{M}\\cdot\\mathcal{M}^{\\prime}%\r\n\\subseteq\\mathcal{M}^{\\prime}$. This shows that the family $\\left(  T^{j}%\r\nF^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ spans the $\\mathbb{K}$-module $\\mathcal{M}$\r\n(since the $\\mathbb{K}$-linear span of this family is $\\mathcal{M}^{\\prime}$).\r\nSince we already know that this family is $\\mathbb{K}$-linearly independent,\r\nwe can thus conclude that this family is a basis of the $\\mathbb{K}$-module\r\n$\\mathcal{M}$. This proves Proposition \\ref{prop.F-gen.bases} \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Let $\\left(  e_{0},e_{1},e_{2},\\ldots\\right)  $ be the standard\r\nbasis of the left $\\mathbb{K}\\left[  T\\right]  $-module $\\mathbb{K}\\left[\r\nT\\right]  ^{\\left(  \\mathbb{N}\\right)  }$. Define a left $\\mathbb{K}\\left[\r\nT\\right]  $-module homomorphism $\\alpha:\\mathbb{K}\\left[  T\\right]  ^{\\left(\r\n\\mathbb{N}\\right)  }\\rightarrow\\mathcal{M}$ by sending each $e_{i}$ to $F^{i}%\r\n$. Define a $\\mathbb{K}$-module homomorphism $\\beta:\\mathcal{M}\\rightarrow\r\n\\mathbb{K}\\left[  T\\right]  ^{\\left(  \\mathbb{N}\\right)  }$ by sending each\r\n$T^{j}F^{i}$ to $T^{j}e_{i}$. (This $\\beta$ is well-defined, since Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(b)} shows that $\\left(  T^{j}F^{i}\\right)\r\n_{i\\geq0,\\ j\\geq0}$ is a basis of the $\\mathbb{K}$-module $\\mathcal{M}$.) It\r\nis easy to see that $\\beta$ is a left $\\mathbb{K}\\left[  T\\right]  $-module\r\nhomomorphism. It is straightforward to see that the homomorphisms $\\alpha$ and\r\n$\\beta$ are mutually inverse. Thus, $\\alpha$ is a left $\\mathbb{K}\\left[\r\nT\\right]  $-module isomorphism. As a consequence, the left $\\mathbb{K}\\left[\r\nT\\right]  $-module $\\mathcal{M}$ has a basis $\\left(  \\underbrace{\\alpha\r\n\\left(  e_{i}\\right)  }_{=F^{i}}\\right)  _{i\\geq0}=\\left(  F^{i}\\right)\r\n_{i\\geq0}$. This proves Proposition \\ref{prop.F-gen.bases} \\textbf{(c)}.\r\n\r\n\\textbf{(d)} For every integer $u$ and every positive integer $v$, we let\r\n$u\\%v$ denote the remainder of $u$ when divided by $v$, and we let $u//v$\r\ndenote the quotient of $u$ when divided by $v$ with remainder. Thus,\r\n$u//v\\in\\mathbb{Z}$, $u\\%v\\in\\left\\{  0,1,\\ldots,v-1\\right\\}  $ and $u=\\left(\r\nu//v\\right)  v+u\\%v$.\r\n\r\nLet $\\mathcal{G}$ be the free right $\\mathbb{K}\\left[  T\\right]  $-module with\r\nbasis $\\left(  g_{i,j}\\right)  _{i\\geq0,\\ 0\\leq j<r^{i}}$. Define a right\r\n$\\mathbb{K}\\left[  T\\right]  $-module homomorphism $\\alpha:\\mathcal{G}%\r\n\\rightarrow\\mathcal{M}$ by sending each $g_{i,j}$ to $T^{j}F^{i}$. Define a\r\n$\\mathbb{K}$-module homomorphism $\\beta:\\mathcal{M}\\rightarrow\\mathcal{G}$ by\r\nsending each $T^{j}F^{i}$ to $g_{i,j\\%r^{i}}T^{j//r^{i}}$. (This $\\beta$ is\r\nwell-defined, since Proposition \\ref{prop.F-gen.bases} \\textbf{(b)} shows that\r\n$\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ is a basis of the $\\mathbb{K}%\r\n$-module $\\mathcal{M}$.) It is easy to see that the homomorphisms $\\alpha$ and\r\n$\\beta$ are mutually inverse\\footnote{\\textit{Proof.} We need to show that\r\n$\\alpha\\circ\\beta=\\operatorname*{id}$ and $\\beta\\circ\\alpha=\\operatorname*{id}%\r\n$.\r\n\\par\r\nTo prove that $\\alpha\\circ\\beta=\\operatorname*{id}$, we need to show that\r\n$\\left(  \\alpha\\circ\\beta\\right)  \\left(  T^{j}F^{i}\\right)  =T^{j}F^{i}$ for\r\nevery $i,j\\in\\mathbb{N}$. So let us fix $i,j\\in\\mathbb{N}$. Then,%\r\n\\begin{align*}\r\n\\left(  \\alpha\\circ\\beta\\right)  \\left(  T^{j}F^{i}\\right)   &  =\\alpha\\left(\r\n\\underbrace{\\beta\\left(  T^{j}F^{i}\\right)  }_{=g_{i,j\\%r^{i}}T^{j//r^{i}}%\r\n}\\right)  =\\alpha\\left(  g_{i,j\\%r^{i}}T^{j//r^{i}}\\right)\r\n=\\underbrace{\\alpha\\left(  g_{i,j\\%r^{i}}\\right)  }_{\\substack{=T^{j\\%r^{i}%\r\n}F^{i}\\\\\\text{(by the definition of }\\alpha\\text{)}}}T^{j//r^{i}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\alpha\\text{ is a right\r\n}\\mathbb{K}\\left[  T\\right]  \\text{-module homomorphism}\\right) \\\\\r\n&  =T^{j\\%r^{i}}\\underbrace{F^{i}T^{j//r^{i}}}_{\\substack{=T^{r^{i}\\left(\r\nj//r^{i}\\right)  }F^{i}\\\\\\text{(by Proposition \\ref{prop.F-gen.bases}\r\n\\textbf{(a),}}\\\\\\text{applied to }a=i\\text{ and }b=j//r^{i}\\text{)}%\r\n}}=\\underbrace{T^{j\\%r^{i}}T^{r^{i}\\left(  j//r^{i}\\right)  }}%\r\n_{\\substack{=T^{j\\%r^{i}+r^{i}\\left(  j//r^{i}\\right)  }=T^{j}\\\\\\text{(since\r\n}j\\%r^{i}+r^{i}\\left(  j//r^{i}\\right)  =\\left(  j//r^{i}\\right)\r\nr^{i}+j\\%r^{i}=j\\text{)}}}F^{i}=T^{j}F^{i},\r\n\\end{align*}\r\nwhich is what we wanted to prove.\r\n\\par\r\nThus, $\\alpha\\circ\\beta=\\operatorname*{id}$ is proven. It remains to prove\r\nthat $\\beta\\circ\\alpha=\\operatorname*{id}$.\r\n\\par\r\nWe know that $\\mathcal{G}$ is spanned by $\\left(  g_{i,j}\\right)\r\n_{i\\geq0,\\ 0\\leq j<r^{i}}$ as a right $\\mathbb{K}\\left[  T\\right]  $-module\r\n(by the definition of $\\mathcal{G}$). Hence, $\\mathcal{G}$ is spanned by\r\n$\\left(  g_{i,j}T^{k}\\right)  _{i\\geq0,\\ 0\\leq j<r^{i},\\ k\\geq0}$ as a\r\n$\\mathbb{K}$-module. Hence, in order to prove that $\\beta\\circ\\alpha\r\n=\\operatorname*{id}$, it suffices to show that $\\left(  \\beta\\circ\r\n\\alpha\\right)  \\left(  g_{i,j}T^{k}\\right)  =g_{i,j}T^{k}$ for every $i\\geq0$,\r\n$0\\leq j<r^{i}$ and $k\\geq0$.\r\n\\par\r\nSo let us fix $i\\geq0$, $0\\leq j<r^{i}$ and $k\\geq0$. The definition of\r\n$\\alpha$ yields $\\alpha\\left(  g_{i,j}\\right)  =T^{j}F^{i}$. But since\r\n$\\alpha$ is a right $\\mathbb{K}\\left[  T\\right]  $-module homomorphism, we\r\nhave%\r\n\\[\r\n\\alpha\\left(  g_{i,j}T^{k}\\right)  =\\underbrace{\\alpha\\left(  g_{i,j}\\right)\r\n}_{=T^{j}F^{i}}T^{k}=T^{j}\\underbrace{F^{i}T^{k}}_{\\substack{=T^{r^{i}k}%\r\nF^{i}\\\\\\text{(by Proposition \\ref{prop.F-gen.bases} \\textbf{(a)}%\r\n,}\\\\\\text{applied to }a=i\\text{ and }b=k\\text{)}}}=\\underbrace{T^{j}T^{r^{i}%\r\nk}}_{=T^{j+r^{i}k}}F^{i}=T^{j+r^{i}k}F^{i}.\r\n\\]\r\nNow,%\r\n\\begin{equation}\r\n\\left(  \\beta\\circ\\alpha\\right)  \\left(  g_{i,j}T^{k}\\right)  =\\beta\\left(\r\n\\underbrace{\\alpha\\left(  g_{i,j}T^{k}\\right)  }_{=T^{j+r^{i}k}F^{i}}\\right)\r\n=\\beta\\left(  T^{j+r^{i}k}F^{i}\\right)  =g_{i,\\left(  j+r^{i}k\\right)\r\n\\%r^{i}}T^{\\left(  j+r^{i}k\\right)  //r^{i}}.\r\n\\label{pf.prop.F-gen.bases.d.fn1.3}%\r\n\\end{equation}\r\n\\par\r\nBut $0\\leq j<r^{i}$. Hence, $\\left(  j+r^{i}k\\right)  \\%r^{i}=j$ and $\\left(\r\nj+r^{i}k\\right)  //r^{i}=k$. In view of these two equalities,\r\n(\\ref{pf.prop.F-gen.bases.d.fn1.3}) rewrites as $\\left(  \\beta\\circ\r\n\\alpha\\right)  \\left(  g_{i,j}T^{k}\\right)  =g_{i,j}T^{k}$. This completes our\r\nproof of $\\beta\\circ\\alpha=\\operatorname*{id}$. Thus, we have shown that\r\n$\\alpha$ and $\\beta$ are mutually inverse.}. Thus, $\\alpha$ is a right\r\n$\\mathbb{K}\\left[  T\\right]  $-module isomorphism. Since the right\r\n$\\mathbb{K}\\left[  T\\right]  $-module $\\mathcal{G}$ has a basis $\\left(\r\ng_{i,j}\\right)  _{i\\geq0,\\ 0\\leq j<r^{i}}$, this shows that the right\r\n$\\mathbb{K}\\left[  T\\right]  $-module $\\mathcal{M}$ has a basis $\\left(\r\n\\underbrace{\\alpha\\left(  g_{i,j}\\right)  }_{=T^{j}F^{i}}\\right)\r\n_{i\\geq0,\\ 0\\leq j<r^{i}}=\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ 0\\leq j<r^{i}%\r\n}$. This proves Proposition \\ref{prop.F-gen.bases} \\textbf{(d)}.\r\n\r\n\\textbf{(e)} Let $\\left(  e_{0},e_{1},e_{2},\\ldots\\right)  $ be the standard\r\nbasis of the right $\\mathbb{K}\\left[  F\\right]  $-module $\\mathbb{K}\\left[\r\nF\\right]  ^{\\left(  \\mathbb{N}\\right)  }$. Define a right $\\mathbb{K}\\left[\r\nF\\right]  $-module homomorphism $\\alpha:\\mathbb{K}\\left[  F\\right]  ^{\\left(\r\n\\mathbb{N}\\right)  }\\rightarrow\\mathcal{M}$ by sending each $e_{j}$ to $T^{j}%\r\n$. Define a $\\mathbb{K}$-module homomorphism $\\beta:\\mathcal{M}\\rightarrow\r\n\\mathbb{K}\\left[  T\\right]  ^{\\left(  \\mathbb{N}\\right)  }$ by sending each\r\n$T^{j}F^{i}$ to $e_{j}F^{i}$. (This $\\beta$ is well-defined, since Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(b)} shows that $\\left(  T^{j}F^{i}\\right)\r\n_{i\\geq0,\\ j\\geq0}$ is a basis of the $\\mathbb{K}$-module $\\mathcal{M}$.) It\r\nis easy to see that $\\beta$ is a right $\\mathbb{K}\\left[  F\\right]  $-module\r\nhomomorphism. It is straightforward to see that the homomorphisms $\\alpha$ and\r\n$\\beta$ are mutually inverse. Thus, $\\alpha$ is a right $\\mathbb{K}\\left[\r\nF\\right]  $-module isomorphism. As a consequence, the right $\\mathbb{K}\\left[\r\nF\\right]  $-module $\\mathcal{M}$ has a basis $\\left(  \\underbrace{\\alpha\r\n\\left(  e_{j}\\right)  }_{=T^{j}}\\right)  _{j\\geq0}=\\left(  T^{j}\\right)\r\n_{j\\geq0}$. This proves Proposition \\ref{prop.F-gen.bases} \\textbf{(e)}.\r\n\r\n\\textbf{(f)} Define a subset $B$ of $\\mathbb{N}^{2}$ by\r\n(\\ref{eq.cor.F-gen.bases.f.1.cor1.def-B}). Define a map $\\rho:B\\times\r\n\\mathbb{N}\\rightarrow\\mathbb{N}^{2}$ by\r\n(\\ref{eq.cor.F-gen.bases.f.1.cor1.def-rho}). Corollary\r\n\\ref{cor.F-gen.bases.f.1.cor1} shows that $\\rho$ is a bijection. Hence, its\r\ninverse $\\rho^{-1}:\\mathbb{N}^{2}\\rightarrow B\\times\\mathbb{N}$ is well-defined.\r\n\r\nNow, let $\\mathcal{H}$ be the free left $\\mathbb{K}\\left[  F\\right]  $-module\r\nwith basis $\\left(  h_{\\left(  i,j\\right)  }\\right)  _{\\left(  i,j\\right)  \\in\r\nB}$. Define a left $\\mathbb{K}\\left[  F\\right]  $-module homomorphism\r\n$\\alpha:\\mathcal{H}\\rightarrow\\mathcal{M}$ by sending each $h_{\\left(\r\ni,j\\right)  }$ to $T^{j}F^{i}$. Define a $\\mathbb{K}$-module homomorphism\r\n$\\beta:\\mathcal{M}\\rightarrow\\mathcal{H}$ by sending each $T^{j}F^{i}$ to\r\n$F^{k}h_{\\left(  u,v\\right)  }$, where $\\left(  \\left(  u,v\\right)  ,k\\right)\r\n=\\rho^{-1}\\left(  i,j\\right)  $. (This $\\beta$ is well-defined, since\r\nProposition \\ref{prop.F-gen.bases} \\textbf{(b)} shows that $\\left(  T^{j}%\r\nF^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ is a basis of the $\\mathbb{K}$-module\r\n$\\mathcal{M}$.) It is straightforward to see that the homomorphisms $\\alpha$\r\nand $\\beta$ are mutually inverse\\footnote{\\textit{Proof.} We need to show that\r\n$\\alpha\\circ\\beta=\\operatorname*{id}$ and $\\beta\\circ\\alpha=\\operatorname*{id}%\r\n$.\r\n\\par\r\nTo prove that $\\alpha\\circ\\beta=\\operatorname*{id}$, we need to show that\r\n$\\left(  \\alpha\\circ\\beta\\right)  \\left(  T^{j}F^{i}\\right)  =T^{j}F^{i}$ for\r\nevery $i,j\\in\\mathbb{N}$. So let us fix $i,j\\in\\mathbb{N}$. Set $\\left(\r\n\\left(  u,v\\right)  ,k\\right)  =\\rho^{-1}\\left(  i,j\\right)  $. Then, $\\left(\r\ni,j\\right)  =\\rho\\left(  \\left(  u,v\\right)  ,k\\right)  =\\left(\r\nu+k,r^{k}v\\right)  $ (by the definition of $\\rho$). In other words, $i=u+k$\r\nand $j=r^{k}v$.\r\n\\par\r\nThe definition of $\\beta$ shows that $\\beta\\left(  T^{j}F^{i}\\right)\r\n=F^{k}h_{\\left(  u,v\\right)  }$. Now,%\r\n\\begin{align*}\r\n\\left(  \\alpha\\circ\\beta\\right)  \\left(  T^{j}F^{i}\\right)   &  =\\alpha\\left(\r\n\\underbrace{\\beta\\left(  T^{j}F^{i}\\right)  }_{=F^{k}h_{\\left(  u,v\\right)  }%\r\n}\\right)  =\\alpha\\left(  F^{k}h_{\\left(  u,v\\right)  }\\right)  =F^{k}%\r\n\\underbrace{\\alpha\\left(  h_{\\left(  u,v\\right)  }\\right)  }_{\\substack{=T^{v}%\r\nF^{u}\\\\\\text{(by the definition of }\\alpha\\text{)}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\alpha\\text{ is a left }%\r\n\\mathbb{K}\\left[  F\\right]  \\text{-module homomorphism}\\right) \\\\\r\n&  =\\underbrace{F^{k}T^{v}}_{\\substack{=T^{r^{k}v}F^{k}\\\\\\text{(by Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(a)},}\\\\\\text{applied to }a=k\\text{ and\r\n}b=v\\text{)}}}F^{u}=\\underbrace{T^{r^{k}v}}_{\\substack{=T^{j}\\\\\\text{(since\r\n}r^{k}v=j\\text{)}}}\\underbrace{F^{k}F^{u}}_{\\substack{=F^{u+k}=F^{i}%\r\n\\\\\\text{(since }u+k=i\\text{)}}}=T^{j}F^{i},\r\n\\end{align*}\r\nwhich is what we wanted to prove.\r\n\\par\r\nThus, $\\alpha\\circ\\beta=\\operatorname*{id}$ is proven. It thus remains to\r\nprove that $\\beta\\circ\\alpha=\\operatorname*{id}$.\r\n\\par\r\nWe know that $\\mathcal{H}$ is spanned by $\\left(  h_{\\left(  i,j\\right)\r\n}\\right)  _{\\left(  i,j\\right)  \\in B}$ as a left $\\mathbb{K}\\left[  F\\right]\r\n$-module (by the definition of $\\mathcal{H}$). Hence, $\\mathcal{H}$ is spanned\r\nby $\\left(  F^{k}h_{\\left(  i,j\\right)  }\\right)  _{\\left(  \\left(\r\ni,j\\right)  ,k\\right)  \\in B\\times\\mathbb{N}}$ as a $\\mathbb{K}$-module.\r\nHence, in order to prove that $\\beta\\circ\\alpha=\\operatorname*{id}$, it\r\nsuffices to show that $\\left(  \\beta\\circ\\alpha\\right)  \\left(  F^{k}%\r\nh_{\\left(  i,j\\right)  }\\right)  =F^{k}h_{\\left(  i,j\\right)  }$ for every\r\n$\\left(  \\left(  i,j\\right)  ,k\\right)  \\in B\\times\\mathbb{N}$.\r\n\\par\r\nSo let us fix $\\left(  \\left(  i,j\\right)  ,k\\right)  \\in B\\times\\mathbb{N}$.\r\nThe definition of $\\alpha$ yields $\\alpha\\left(  h_{\\left(  i,j\\right)\r\n}\\right)  =T^{j}F^{i}$. But since $\\alpha$ is a left $\\mathbb{K}\\left[\r\nF\\right]  $-module homomorphism, we have%\r\n\\[\r\n\\alpha\\left(  F^{k}h_{\\left(  i,j\\right)  }\\right)  =F^{k}\\underbrace{\\alpha\r\n\\left(  h_{\\left(  i,j\\right)  }\\right)  }_{=T^{j}F^{i}}=\\underbrace{F^{k}%\r\nT^{j}}_{\\substack{=T^{r^{k}j}F^{k}\\\\\\text{(by Proposition\r\n\\ref{prop.F-gen.bases} \\textbf{(a)},}\\\\\\text{applied to }a=k\\text{ and\r\n}b=j\\text{)}}}F^{i}=T^{r^{k}j}\\underbrace{F^{k}F^{i}}_{=F^{k+i}}=T^{r^{k}%\r\nj}F^{k+i}.\r\n\\]\r\n\\par\r\nOn the other hand, the definition of $\\rho$ yields $\\rho\\left(  \\left(\r\ni,j\\right)  ,k\\right)  =\\left(  \\underbrace{i+k}_{=k+i},r^{k}j\\right)\r\n=\\left(  k+i,r^{k}j\\right)  $, so that $\\left(  \\left(  i,j\\right)  ,k\\right)\r\n=\\rho^{-1}\\left(  k+i,r^{k}j\\right)  $. Hence, the definition of $\\beta$\r\nyields $\\beta\\left(  T^{r^{k}j}F^{k+i}\\right)  =F^{k}h_{\\left(  i,j\\right)  }%\r\n$. Now,%\r\n\\[\r\n\\left(  \\beta\\circ\\alpha\\right)  \\left(  F^{k}h_{\\left(  i,j\\right)  }\\right)\r\n=\\beta\\left(  \\underbrace{\\alpha\\left(  F^{k}h_{\\left(  i,j\\right)  }\\right)\r\n}_{=T^{r^{k}j}F^{k+i}}\\right)  =\\beta\\left(  T^{r^{k}j}F^{k+i}\\right)\r\n=F^{k}h_{\\left(  i,j\\right)  }.\r\n\\]\r\nThis completes our proof of $\\beta\\circ\\alpha=\\operatorname*{id}$. Thus, we\r\nhave shown that $\\alpha$ and $\\beta$ are mutually inverse.}. Thus, $\\alpha$ is\r\na left $\\mathbb{K}\\left[  F\\right]  $-module isomorphism. As a consequence,\r\nthe left $\\mathbb{K}\\left[  F\\right]  $-module $\\mathcal{M}$ has a basis\r\n\\[\r\n\\left(  \\underbrace{\\alpha\\left(  h_{\\left(  i,j\\right)  }\\right)  }%\r\n_{=T^{j}F^{i}}\\right)  _{\\left(  i,j\\right)  \\in B}=\\left(  T^{j}F^{i}\\right)\r\n_{\\left(  i,j\\right)  \\in B}=\\left(  T^{j}F^{i}\\right)  _{i=0\\text{ or }r\\nmid\r\nj}%\r\n\\]\r\n(since $B=\\left\\{  \\left(  i,j\\right)  \\in\\mathbb{N}^{2}\\ \\mid\\ i=0\\text{ or\r\n}r\\nmid j\\right\\}  $). This proves Proposition \\ref{prop.F-gen.bases}\r\n\\textbf{(f)}.\r\n\r\n\\textbf{(g)} Define $C$ and $\\zeta$ as in Corollary\r\n\\ref{cor.F-gen.bases.f.1.cor2}. In this proof, the $\\otimes$ sign always shall\r\nmean tensor products over $\\mathbb{K}$.\r\n\r\nCorollary \\ref{cor.F-gen.bases.f.1.cor2} shows that the map $\\zeta$ is a\r\nbijection. In other words, the map\r\n\\begin{equation}\r\nC\\times\\mathbb{N}\\times\\mathbb{N}\\rightarrow\\mathbb{N}^{2}%\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\left(  i,j\\right)  ,\\ell,k\\right)\r\n\\mapsto\\left(  i+k,r^{k}\\left(  j+r^{i}\\ell\\right)  \\right)\r\n\\label{pf.prop.F-gen.bases.g.bij}%\r\n\\end{equation}\r\nis a bijection (since this map is the map $\\zeta$).\r\n\r\nProposition \\ref{prop.F-gen.bases} \\textbf{(b)} shows that $\\left(  T^{j}%\r\nF^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ is a basis of the $\\mathbb{K}$-module\r\n$\\mathcal{M}$. We can reindex this basis using the bijection\r\n(\\ref{pf.prop.F-gen.bases.g.bij}); thus, we conclude that \\newline$\\left(\r\nT^{r^{k}\\left(  j+r^{i}\\ell\\right)  }F^{i+k}\\right)  _{\\left(  \\left(\r\ni,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}}$ is a basis\r\nof the $\\mathbb{K}$-module $\\mathcal{M}$.\r\n\r\nLet $\\mathcal{R}$ be the free $\\mathbb{K}$-module with basis $\\left(\r\nr_{\\left(  i,j\\right)  }\\right)  _{\\left(  i,j\\right)  \\in C}$. Then,\r\n\\newline$\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)\r\n_{\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}%\r\n\\times\\mathbb{N}}$ is a basis of the $\\mathbb{K}$-module $\\mathcal{R}%\r\n\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  $ (since\r\n$\\left(  F^{k}\\right)  _{k\\in\\mathbb{N}}$ is a basis of $\\mathbb{K}\\left[\r\nF\\right]  $, and since $\\left(  T^{\\ell}\\right)  _{\\ell\\in\\mathbb{N}}$ is a\r\nbasis of $\\mathbb{K}\\left[  T\\right]  $). Hence, we can define a $\\mathbb{K}%\r\n$-linear map $\\eta:\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]\r\n\\otimes\\mathbb{K}\\left[  T\\right]  \\rightarrow\\mathcal{M}$ by%\r\n\\[\r\n\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)\r\n=T^{r^{k}\\left(  j+r^{i}\\ell\\right)  }F^{i+k}.\r\n\\]\r\nConsider this map $\\eta$. It sends the basis $\\left(  r_{\\left(  i,j\\right)\r\n}\\otimes F^{k}\\otimes T^{\\ell}\\right)  _{\\left(  \\left(  i,j\\right)\r\n,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}}$ of $\\mathcal{R}%\r\n\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  $ to the\r\nbasis $\\left(  T^{r^{k}\\left(  j+r^{i}\\ell\\right)  }F^{i+k}\\right)  _{\\left(\r\n\\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}}$ of\r\n$\\mathcal{M}$. Thus, $\\eta$ is an isomorphism of $\\mathbb{K}$-modules.\r\n\r\nNow, $\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[\r\nT\\right]  $ becomes a left $\\mathbb{K}\\left[  F\\right]  $-module (by having\r\n$\\mathbb{K}\\left[  F\\right]  $ act on the tensorand $\\mathbb{K}\\left[\r\nF\\right]  $) and a right $\\mathbb{K}\\left[  T\\right]  $-module (by having\r\n$\\mathbb{K}\\left[  T\\right]  $ act on the tensorand $\\mathbb{K}\\left[\r\nT\\right]  $). The map $\\eta$ is a left $\\mathbb{K}\\left[  F\\right]  $-module\r\nhomomorphism\\footnote{\\textit{Proof.} It suffices to show that $\\eta\\left(\r\nfz\\right)  =f\\eta\\left(  z\\right)  $ for every $f\\in\\mathbb{K}\\left[\r\nF\\right]  $ and $z\\in\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]\r\n\\otimes\\mathbb{K}\\left[  T\\right]  $. So let us prove this.\r\n\\par\r\nFix $f\\in\\mathbb{K}\\left[  F\\right]  $ and $z\\in\\mathcal{R}\\otimes\r\n\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  $. We need to\r\nshow the equality $\\eta\\left(  fz\\right)  =f\\eta\\left(  z\\right)  $. Since\r\nthis equality is $\\mathbb{K}$-linear in each of $f$ and $z$, we can WLOG\r\nassume that $f$ belongs to the basis $\\left(  F^{k}\\right)  _{k\\in\\mathbb{N}}$\r\nof $\\mathbb{K}\\left[  F\\right]  $, and that $z$ belongs to the basis $\\left(\r\nr_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)  _{\\left(\r\n\\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}}$ of\r\n$\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[\r\nT\\right]  $. Assume this. Thus, $f=F^{p}$ for some $p\\in\\mathbb{N}$, and\r\n$z=r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}$ for some $\\left(\r\n\\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}\\times\\mathbb{N}$.\r\nConsider these $p$ and $\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)  $.\r\n\\par\r\nFrom $f=F^{p}$ and $z=r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}$,\r\nwe obtain $fz=F^{p}\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes\r\nT^{\\ell}\\right)  =r_{\\left(  i,j\\right)  }\\otimes\\underbrace{F^{p}F^{k}%\r\n}_{=F^{p+k}}\\otimes T^{\\ell}=r_{\\left(  i,j\\right)  }\\otimes F^{p+k}\\otimes\r\nT^{\\ell}$. Hence,%\r\n\\[\r\n\\eta\\left(  fz\\right)  =\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes\r\nF^{p+k}\\otimes T^{\\ell}\\right)  =T^{r^{p+k}\\left(  j+r^{i}\\ell\\right)\r\n}F^{i+p+k}%\r\n\\]\r\n(by the definition of $\\eta$). On the other hand, from $z=r_{\\left(\r\ni,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}$, we obtain $\\eta\\left(  z\\right)\r\n=\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)\r\n=T^{r^{k}\\left(  j+r^{i}\\ell\\right)  }F^{i+k}$, so that%\r\n\\begin{align*}\r\n\\underbrace{f}_{=F^{p}}\\underbrace{\\eta\\left(  z\\right)  }_{=T^{r^{k}\\left(\r\nj+r^{i}\\ell\\right)  }F^{i+k}}  &  =\\underbrace{F^{p}T^{r^{k}\\left(\r\nj+r^{i}\\ell\\right)  }}_{\\substack{=T^{r^{p}r^{k}\\left(  j+r^{i}\\ell\\right)\r\n}F^{p}\\\\\\text{(by Proposition \\ref{prop.F-gen.bases} \\textbf{(a)}%\r\n,}\\\\\\text{applied to }a=p\\text{ and }b=r^{k}\\left(  j+r^{i}\\ell\\right)\r\n\\text{)}}}F^{i+k}=\\underbrace{T^{r^{p}r^{k}\\left(  j+r^{i}\\ell\\right)  }%\r\n}_{=T^{r^{p+k}\\left(  j+r^{i}\\ell\\right)  }}\\underbrace{F^{p}F^{i+k}%\r\n}_{=F^{p+i+k}=F^{i+p+k}}\\\\\r\n&  =T^{r^{p+k}\\left(  j+r^{i}\\ell\\right)  }F^{i+p+k}.\r\n\\end{align*}\r\nComparing this with $\\eta\\left(  fz\\right)  =T^{r^{p+k}\\left(  j+r^{i}%\r\n\\ell\\right)  }F^{i+p+k}$, we obtain $\\eta\\left(  fz\\right)  =f\\eta\\left(\r\nz\\right)  $, qed.} and a right $\\mathbb{K}\\left[  T\\right]  $-module\r\nhomomorphism\\footnote{\\textit{Proof.} It suffices to show that $\\eta\\left(\r\nzt\\right)  =\\eta\\left(  z\\right)  t$ for every $t\\in\\mathbb{K}\\left[\r\nT\\right]  $ and $z\\in\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]\r\n\\otimes\\mathbb{K}\\left[  T\\right]  $. So let us prove this.\r\n\\par\r\nFix $t\\in\\mathbb{K}\\left[  T\\right]  $ and $z\\in\\mathcal{R}\\otimes\r\n\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  $. We need to\r\nshow the equality $\\eta\\left(  zt\\right)  =\\eta\\left(  z\\right)  t$. Since\r\nthis equality is $\\mathbb{K}$-linear in each of $t$ and $z$, we can WLOG\r\nassume that $t$ belongs to the basis $\\left(  T^{\\ell}\\right)  _{\\ell\r\n\\in\\mathbb{N}}$ of $\\mathbb{K}\\left[  T\\right]  $, and that $z$ belongs to the\r\nbasis $\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)\r\n_{\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\\mathbb{N}%\r\n\\times\\mathbb{N}}$ of $\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]\r\n\\otimes\\mathbb{K}\\left[  T\\right]  $. Assume this. Thus, $t=T^{p}$ for some\r\n$p\\in\\mathbb{N}$, and $z=r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell\r\n}$ for some $\\left(  \\left(  i,j\\right)  ,\\ell,k\\right)  \\in C\\times\r\n\\mathbb{N}\\times\\mathbb{N}$. Consider these $p$ and $\\left(  \\left(\r\ni,j\\right)  ,\\ell,k\\right)  $.\r\n\\par\r\nFrom $t=T^{p}$ and $z=r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}$,\r\nwe obtain $zt=\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell\r\n}\\right)  T^{p}=r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes\r\n\\underbrace{T^{\\ell}T^{p}}_{=T^{\\ell+p}}=r_{\\left(  i,j\\right)  }\\otimes\r\nF^{k}\\otimes T^{\\ell+p}$. Hence,%\r\n\\[\r\n\\eta\\left(  zt\\right)  =\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes\r\nF^{k}\\otimes T^{\\ell+p}\\right)  =T^{r^{k}\\left(  j+r^{i}\\left(  \\ell+p\\right)\r\n\\right)  }F^{i+k}%\r\n\\]\r\n(by the definition of $\\eta$). On the other hand, from $z=r_{\\left(\r\ni,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}$, we obtain $\\eta\\left(  z\\right)\r\n=\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{k}\\otimes T^{\\ell}\\right)\r\n=T^{r^{k}\\left(  j+r^{i}\\ell\\right)  }F^{i+k}$, so that%\r\n\\begin{align*}\r\n\\underbrace{\\eta\\left(  z\\right)  }_{=T^{r^{k}\\left(  j+r^{i}\\ell\\right)\r\n}F^{i+k}}\\underbrace{t}_{=T^{p}}  &  =T^{r^{k}\\left(  j+r^{i}\\ell\\right)\r\n}\\underbrace{F^{i+k}T^{p}}_{\\substack{=T^{r^{i+k}p}F^{i+k}\\\\\\text{(by\r\nProposition \\ref{prop.F-gen.bases} \\textbf{(a)},}\\\\\\text{applied to\r\n}a=i+k\\text{ and }b=p\\text{)}}}=\\underbrace{T^{r^{k}\\left(  j+r^{i}%\r\n\\ell\\right)  }T^{r^{i+k}p}}_{\\substack{=T^{r^{k}\\left(  j+r^{i}\\ell\\right)\r\n+r^{i+k}p}\\\\=T^{r^{k}\\left(  j+r^{i}\\left(  \\ell+p\\right)  \\right)\r\n}\\\\\\text{(since}\\\\r^{k}\\left(  j+r^{i}\\ell\\right)  +r^{i+k}p=r^{k}\\left(\r\nj+r^{i}\\left(  \\ell+p\\right)  \\right)  \\text{)}}}F^{i+k}\\\\\r\n&  =T^{r^{k}\\left(  j+r^{i}\\left(  \\ell+p\\right)  \\right)  }F^{i+k}.\r\n\\end{align*}\r\nComparing this with $\\eta\\left(  zt\\right)  =T^{r^{k}\\left(  j+r^{i}\\left(\r\n\\ell+p\\right)  \\right)  }F^{i+k}$, we obtain $\\eta\\left(  zt\\right)\r\n=\\eta\\left(  z\\right)  t$, qed.}. Thus, $\\eta$ is a $\\mathbb{K}\\left[\r\nF\\right]  $-$\\mathbb{K}\\left[  T\\right]  $-bimodule homomorphism.\r\n\r\nNow, recall that $\\left(  r_{\\left(  i,j\\right)  }\\right)  _{\\left(\r\ni,j\\right)  \\in C}$ is a basis of the free $\\mathbb{K}$-module $\\mathcal{R}$.\r\nHence, $\\mathcal{R}=\\bigoplus_{\\left(  i,j\\right)  \\in C}r_{\\left(\r\ni,j\\right)  }\\mathbb{K}$. Since direct sums commute with tensor products, this\r\nyields%\r\n\\begin{align*}\r\n\\mathcal{R}\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[\r\nT\\right]   &  =\\bigoplus_{\\left(  i,j\\right)  \\in C}\\underbrace{r_{\\left(\r\ni,j\\right)  }\\mathbb{K}\\otimes\\mathbb{K}\\left[  F\\right]  \\otimes\r\n\\mathbb{K}\\left[  T\\right]  }_{\\substack{=\\mathbb{K}\\left[  F\\right]\r\n\\cdot\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{0}\\otimes T^{0}\\right)\r\n\\cdot\\mathbb{K}\\left[  T\\right]  \\\\\\text{(this follows easily from the\r\ndefinition of the}\\\\\\mathbb{K}\\left[  F\\right]  \\text{-}\\mathbb{K}\\left[\r\nT\\right]  \\text{-bimodule structure on }\\mathcal{R}\\otimes\\mathbb{K}\\left[\r\nF\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  \\text{)}}}\\\\\r\n&  =\\bigoplus_{\\left(  i,j\\right)  \\in C}\\mathbb{K}\\left[  F\\right]\r\n\\cdot\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{0}\\otimes T^{0}\\right)\r\n\\cdot\\mathbb{K}\\left[  T\\right]  .\r\n\\end{align*}\r\nWe can apply the map $\\eta$ to this equality. The left hand side becomes\r\n$\\mathcal{M}$ (since $\\eta$ is an isomorphism of $\\mathbb{K}$-modules), and\r\nthe direct sum on the right hand side remains direct (for the same reason).\r\nHence, we obtain%\r\n\\begin{align*}\r\n\\mathcal{M}  &  =\\bigoplus_{\\left(  i,j\\right)  \\in C}\\underbrace{\\eta\\left(\r\n\\mathbb{K}\\left[  F\\right]  \\cdot\\left(  r_{\\left(  i,j\\right)  }\\otimes\r\nF^{0}\\otimes T^{0}\\right)  \\cdot\\mathbb{K}\\left[  T\\right]  \\right)\r\n}_{\\substack{=\\mathbb{K}\\left[  F\\right]  \\cdot\\eta\\left(  r_{\\left(\r\ni,j\\right)  }\\otimes F^{0}\\otimes T^{0}\\right)  \\cdot\\mathbb{K}\\left[\r\nT\\right]  \\\\\\text{(since }\\eta\\text{ is a }\\mathbb{K}\\left[  F\\right]\r\n\\text{-}\\mathbb{K}\\left[  T\\right]  \\text{-bimodule homomorphism)}}}\\\\\r\n&  =\\bigoplus_{\\left(  i,j\\right)  \\in C}\\mathbb{K}\\left[  F\\right]\r\n\\cdot\\underbrace{\\eta\\left(  r_{\\left(  i,j\\right)  }\\otimes F^{0}\\otimes\r\nT^{0}\\right)  }_{\\substack{=T^{r^{0}\\left(  j+r^{i}0\\right)  }F^{i+0}%\r\n\\\\\\text{(by the definition of }\\eta\\text{)}}}\\cdot\\mathbb{K}\\left[  T\\right]\r\n\\\\\r\n&  =\\underbrace{\\bigoplus_{\\left(  i,j\\right)  \\in C}}_{=\\bigoplus\r\n\\limits_{\\substack{\\left(  i,j\\right)  \\in\\mathbb{N}^{2};\\\\\\left(  i=0\\text{\r\nor }r\\nmid j\\right)  \\text{ and }0\\leq j<r^{i}}}}\\mathbb{K}\\left[  F\\right]\r\n\\cdot\\underbrace{T^{r^{0}\\left(  j+r^{i}0\\right)  }}_{=T^{j}}%\r\n\\underbrace{F^{i+0}}_{=F^{i}}\\cdot\\mathbb{K}\\left[  T\\right] \\\\\r\n&  =\\bigoplus\\limits_{\\substack{\\left(  i,j\\right)  \\in\\mathbb{N}%\r\n^{2};\\\\\\left(  i=0\\text{ or }r\\nmid j\\right)  \\text{ and }0\\leq j<r^{i}%\r\n}}\\mathbb{K}\\left[  F\\right]  \\cdot\\left(  T^{j}F^{i}\\right)  \\cdot\r\n\\mathbb{K}\\left[  T\\right]  .\r\n\\end{align*}\r\nIt remains to show that each $\\mathbb{K}\\left[  F\\right]  \\cdot\\left(\r\nT^{j}F^{i}\\right)  \\cdot\\mathbb{K}\\left[  T\\right]  $ is isomorphic to\r\n$\\mathbb{K}\\left[  F\\right]  \\otimes\\mathbb{K}\\left[  T\\right]  $ as an\r\n$\\mathbb{K}\\left[  F\\right]  $-$\\mathbb{K}\\left[  T\\right]  $-bimodule. This\r\nfollows from $\\eta$ being an isomorphism (the details are left to the reader).\r\nThus, Proposition \\ref{prop.F-gen.bases} \\textbf{(g)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{The skew polynomial ring $\\mathcal{F}$}\r\n\r\nNow, let us return to the setup of polynomials over $\\mathbb{F}_{q}$.\r\n\r\nWe are still using the notations of Section \\ref{sect.nots}. In particular,\r\n$q$ is a (nontrivial) power of a prime $p$.\r\n\r\nFor every commutative $\\mathbb{F}_{q}$-algebra $A$, we let\r\n$\\operatorname*{Frob}\\nolimits_{A}:A\\rightarrow A$ be the map which sends\r\nevery $a\\in A$ to $a^{q}$. This map $\\operatorname*{Frob}\\nolimits_{A}$ is\r\ncalled the \\textit{Frobenius endomorphism} of $A$. It is well-known that\r\n$\\operatorname*{Frob}\\nolimits_{A}$ is an $\\mathbb{F}_{q}$-algebra\r\nhomomorphism\\footnote{This follows from the fact that $\\left(  \\lambda\r\na\\right)  ^{q}=\\underbrace{\\lambda^{q}}_{\\substack{=\\lambda\\\\\\text{(since\r\n}\\lambda\\in\\mathbb{F}_{q}\\text{)}}}a^{q}=\\lambda a^{q}$ for every $a\\in A$ and\r\n$\\lambda\\in\\mathbb{F}_{q}$, and the fact that $\\left(  a+b\\right)  ^{q}%\r\n=a^{q}+b^{q}$ for every $a,b\\in A$.}. We will often denote the $\\mathbb{F}%\r\n_{q}$-algebra homomorphism $\\operatorname*{Frob}\\nolimits_{A}$ by\r\n$\\operatorname*{Frob}$ when no confusion can arise from the omission of $A$. A\r\nrather important particular case is the endomorphism $\\operatorname*{Frob}%\r\n=\\operatorname*{Frob}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$ of the\r\ncommutative $\\mathbb{F}_{q}$-algebra $\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nWe let $\\mathcal{F}$ be the $\\mathbb{F}_{q}$-algebra $\\mathbb{F}%\r\n_{q}\\left\\langle F,T\\ \\mid\\ FT=T^{q}F\\right\\rangle $. We can immediately\r\ndefine the following $\\mathbb{F}_{q}$-algebra homomorphisms (whose\r\nwell-definedness is easy to check using the universal properties of their domains):\r\n\r\n\\begin{itemize}\r\n\\item We define an $\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Finc}%\r\n\\nolimits_{F}:\\mathbb{F}_{q}\\left[  F\\right]  \\rightarrow\\mathcal{F}$ by\r\n$\\operatorname*{Finc}\\nolimits_{F}\\left(  F\\right)  =F$. Thus,\r\n$\\operatorname*{Finc}\\nolimits_{F}\\left(  p\\right)  =p\\left(  F\\right)  $ for\r\nevery $p\\in\\mathbb{F}_{q}\\left[  F\\right]  $ (where $p\\left(  F\\right)  $\r\nmeans the result of substituting $F$ into the polynomial $p$).\r\n\r\n\\item We define an $\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Finc}%\r\n\\nolimits_{T}:\\mathbb{F}_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ by\r\n$\\operatorname*{Finc}\\nolimits_{T}\\left(  T\\right)  =T$. Thus,\r\n$\\operatorname*{Finc}\\nolimits_{T}\\left(  p\\right)  =p\\left(  T\\right)  $ for\r\nevery $p\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (where $p\\left(  T\\right)  $\r\nmeans the result of substituting $T$ into the polynomial $p$).\r\n\r\n\\item We define an $\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Carl}%\r\n:\\mathbb{F}_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ by\r\n$\\operatorname*{Carl}\\left(  T\\right)  =F+T$. Thus, $\\operatorname*{Carl}%\r\n\\left(  p\\right)  =p\\left(  F+T\\right)  $ for every $p\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ (where $p\\left(  F+T\\right)  $ means the result of substituting\r\n$F+T$ into the polynomial $p$).\r\n\\end{itemize}\r\n\r\nFurthermore, recall that $\\mathcal{F}$ is the $\\mathbb{F}_{q}$-algebra\r\n$\\mathbb{F}_{q}\\left\\langle F,T\\ \\mid\\ FT=T^{q}F\\right\\rangle $. Thus,\r\n$\\mathcal{F}$ has the following universal property: If $u$ and $v$ are two\r\nelements of an $\\mathbb{F}_{q}$-algebra $\\mathcal{U}$ satisfying $uv=v^{q}u$,\r\nthen there exists a unique $\\mathbb{F}_{q}$-algebra homomorphism\r\n$\\mathcal{F}\\rightarrow\\mathcal{U}$ sending $F$ and $T$ to $u$ and $v$,\r\nrespectively. This allows us to define $\\mathbb{F}_{q}$-algebra homomorphisms\r\nout of $\\mathcal{F}$, such as the following:\r\n\r\n\\begin{itemize}\r\n\\item We define an $\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Fpro}%\r\n\\nolimits_{F}:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  F\\right]  $ by\r\n$\\operatorname*{Fpro}\\nolimits_{F}\\left(  F\\right)  =F$ and\r\n$\\operatorname*{Fpro}\\nolimits_{F}\\left(  T\\right)  =0$. It is easy to see\r\nthat $\\operatorname*{Fpro}\\nolimits_{F}\\circ\\operatorname*{Finc}%\r\n\\nolimits_{F}=\\operatorname*{id}$. Hence, the $\\mathbb{F}_{q}$-algebra\r\nhomomorphism $\\operatorname*{Finc}\\nolimits_{F}$ is injective. Thus, we shall\r\nregard $\\operatorname*{Finc}\\nolimits_{F}$ as an inclusion, so that\r\n$\\mathbb{F}_{q}\\left[  F\\right]  \\subseteq\\mathcal{F}$. (Notice that this does\r\nnot make $\\mathcal{F}$ into an $\\mathbb{F}_{q}\\left[  F\\right]  $-algebra,\r\nsince $\\mathbb{F}_{q}\\left[  F\\right]  $ is not contained in the center of\r\n$\\mathcal{F}$.)\r\n\r\n\\item We define an $\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Fpro}%\r\n\\nolimits_{T}:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $ by\r\n$\\operatorname*{Fpro}\\nolimits_{T}\\left(  F\\right)  =0$ and\r\n$\\operatorname*{Fpro}\\nolimits_{T}\\left(  T\\right)  =T$. It is easy to see\r\nthat $\\operatorname*{Fpro}\\nolimits_{T}\\circ\\operatorname*{Finc}%\r\n\\nolimits_{T}=\\operatorname*{id}$. Hence, the $\\mathbb{F}_{q}$-algebra\r\nhomomorphism $\\operatorname*{Finc}\\nolimits_{T}$ is injective. Thus, we shall\r\nregard $\\operatorname*{Finc}\\nolimits_{T}$ as an inclusion, so that\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\subseteq\\mathcal{F}$. (Notice that this does\r\nnot make $\\mathcal{F}$ into an $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra,\r\nsince $\\mathbb{F}_{q}\\left[  T\\right]  $ is not contained in the center of\r\n$\\mathcal{F}$.)\r\n\r\n\\item For every $a\\in\\mathbb{F}_{q}$ and $b\\in\\mathbb{F}_{q}$, we define an\r\n$\\mathbb{F}_{q}$-algebra homomorphism $\\operatorname*{Fscal}\\nolimits_{a,b}%\r\n:\\mathcal{F}\\rightarrow\\mathcal{F}$ by $\\operatorname*{Fscal}\\nolimits_{a,b}%\r\n\\left(  F\\right)  =aF$ and $\\operatorname*{Fscal}\\nolimits_{a,b}\\left(\r\nT\\right)  =bT$. (This is well-defined, since $\\left(  aF\\right)  \\left(\r\nbT\\right)  =\\left(  bT\\right)  ^{q}\\left(  aF\\right)  $.) If $a$ and $b$ are\r\nnonzero, then $\\operatorname*{Fscal}\\nolimits_{a,b}$ is invertible (with\r\ninverse $\\operatorname*{Fscal}\\nolimits_{a^{-1},b^{-1}}$).\r\n\\end{itemize}\r\n\r\nNow, we shall derive some structural properties of $\\mathcal{F}$ straight from\r\nProposition \\ref{prop.F-gen.bases}:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.bases}The homomorphisms $\\operatorname*{Finc}\\nolimits_{T}$ and\r\n$\\operatorname*{Finc}\\nolimits_{F}$ make $\\mathcal{F}$ into a left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module, a right $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module, a left $\\mathbb{F}_{q}\\left[  F\\right]  $-module, and a\r\nright $\\mathbb{F}_{q}\\left[  F\\right]  $-module. Any of these two left module\r\nstructures can be combined with any of these two right module structures to\r\nform a bimodule structure on $\\mathcal{F}$ (for example, the left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module structure and the right\r\n$\\mathbb{F}_{q}\\left[  F\\right]  $-module structure on $\\mathcal{F}$ can be\r\ncombined to form an $\\mathbb{F}_{q}\\left[  T\\right]  $-$\\mathbb{F}_{q}\\left[\r\nF\\right]  $-bimodule structure on $\\mathcal{F}$).\r\n\r\n\\textbf{(a)} We have $F^{a}T^{b}=T^{q^{a}b}F^{a}$ in $\\mathcal{F}$ for every\r\n$a\\in\\mathbb{N}$ and $b\\in\\mathbb{N}$.\r\n\r\n\\textbf{(b)} The $\\mathbb{F}_{q}$-module $\\mathcal{F}$ is free with basis\r\n$\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$.\r\n\r\n\\textbf{(c)} As left $\\mathbb{F}_{q}\\left[  T\\right]  $-module, $\\mathcal{F}$\r\nis free with basis $\\left(  F^{i}\\right)  _{i\\geq0}$.\r\n\r\n\\textbf{(d)} As right $\\mathbb{F}_{q}\\left[  T\\right]  $-module, $\\mathcal{F}$\r\nis free with basis $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ 0\\leq j<q^{i}}$.\r\n\r\n\\textbf{(e)} As right $\\mathbb{F}_{q}\\left[  F\\right]  $-module, $\\mathcal{F}$\r\nis free with basis $\\left(  T^{j}\\right)  _{j\\geq0}$.\r\n\r\n\\textbf{(f)} As left $\\mathbb{F}_{q}\\left[  F\\right]  $-module, $\\mathcal{F}$\r\nis free with basis $\\left(  T^{j}F^{i}\\right)  _{i=0\\text{ or }q\\nmid j}$.\r\n\r\n\\textbf{(g)} As $\\mathbb{F}_{q}\\left[  F\\right]  $-$\\mathbb{F}_{q}\\left[\r\nT\\right]  $-bimodule, $\\mathcal{F}$ is free with basis $\\left(  T^{j}%\r\nF^{i}\\right)  _{\\left(  i=0\\text{ or }q\\nmid j\\right)  \\text{ and }0\\leq\r\nj<q^{i}}$ (that is, we have $\\mathcal{F}=\\bigoplus\\limits_{\\substack{\\left(\r\ni,j\\right)  \\in\\mathbb{N}^{2};\\\\\\left(  i=0\\text{ or }q\\nmid j\\right)  \\text{\r\nand }0\\leq j<q^{i}}}\\mathbb{F}_{q}\\left[  F\\right]  \\cdot\\left(  T^{j}%\r\nF^{i}\\right)  \\cdot\\mathbb{F}_{q}\\left[  T\\right]  $, and each $\\mathbb{F}%\r\n_{q}\\left[  F\\right]  \\cdot\\left(  T^{j}F^{i}\\right)  \\cdot\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ is isomorphic to $\\mathbb{F}_{q}\\left[  F\\right]\r\n\\otimes\\mathbb{F}_{q}\\left[  T\\right]  $ as an $\\mathbb{F}_{q}\\left[\r\nF\\right]  $-$\\mathbb{F}_{q}\\left[  T\\right]  $-bimodule, where the tensor\r\nproduct is taken over $\\mathbb{F}_{q}$).\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.bases}.]Proposition \\ref{prop.F.bases}\r\nfollows immediately from Proposition \\ref{prop.F-gen.bases} by setting\r\n$\\mathbb{K}=\\mathbb{F}_{q}$ and $r=q$.\r\n\\end{proof}\r\n\r\nOne simple identity in $\\mathcal{F}$ is the following:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.FP}Let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then, $FP=P^{q}F$\r\nin $\\mathcal{F}$.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.FP}.]We are going to prove that $FP=\\left(\r\n\\operatorname*{Frob}P\\right)  F$. Since both sides of this equality are\r\n$\\mathbb{F}_{q}$-linear in $P$ (because $\\operatorname*{Frob}$ is an\r\n$\\mathbb{F}_{q}$-linear map), we can WLOG assume that $P$ belongs to the basis\r\n$\\left(  T^{i}\\right)  _{i\\geq0}$ of the $\\mathbb{F}_{q}$-vector space\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Assume this. Thus, $P=T^{i}$ for some\r\n$i\\in\\mathbb{N}$. Consider this $i$. The definition of $\\operatorname*{Frob}$\r\nyields $\\operatorname*{Frob}P=\\left(  \\underbrace{P}_{=T^{i}}\\right)\r\n^{q}=\\left(  T^{i}\\right)  ^{q}=T^{qi}$.\r\n\r\nNow, $\\underbrace{F}_{=F^{1}}\\underbrace{P}_{=T^{i}}=F^{1}T^{i}=T^{q^{1}%\r\ni}F^{1}$ (by Proposition \\ref{prop.F.bases} \\textbf{(a)}), so that\r\n$FP=\\underbrace{T^{q^{1}i}}_{=T^{qi}=\\operatorname*{Frob}P}\\underbrace{F^{1}%\r\n}_{=F}=\\left(  \\operatorname*{Frob}P\\right)  F$.\r\n\r\nThus, $FP=\\left(  \\operatorname*{Frob}P\\right)  F$ is proven. Hence,\r\n$FP=\\underbrace{\\left(  \\operatorname*{Frob}P\\right)  }_{=P^{q}}F=P^{q}F$.\r\nThis proves Proposition \\ref{prop.F.FP}.\r\n\\end{proof}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.FPF}Let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then,\r\n$\\mathcal{F}\\cdot P\\cdot\\mathcal{F}\\subseteq P\\cdot\\mathcal{F}$.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F.FPF}.]We first claim that%\r\n\\begin{equation}\r\nF^{i}P\\in P\\cdot\\mathcal{F}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }i\\in\r\n\\mathbb{N}. \\label{pf.cor.F.FPF.FiP}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.cor.F.FPF.FiP}):} We shall prove\r\n(\\ref{pf.cor.F.FPF.FiP}) by induction on $i$.\r\n\r\nThe \\textit{induction base} (i.e., the case $i=0$) is trivial.\r\n\r\nFor the \\textit{induction step}, we fix an $n\\in\\mathbb{N}$, and we assume\r\nthat (\\ref{pf.cor.F.FPF.FiP}) holds for $i=n$. We then must prove that\r\n(\\ref{pf.cor.F.FPF.FiP}) holds for $i=n+1$.\r\n\r\nBy assumption, (\\ref{pf.cor.F.FPF.FiP}) holds for $i=n$. In other words,\r\n$F^{n}P\\in P\\cdot\\mathcal{F}$. Now,%\r\n\\begin{align*}\r\n\\underbrace{F^{n+1}}_{=FF^{n}}P  &  =F\\underbrace{F^{n}P}_{\\in P\\cdot\r\n\\mathcal{F}}\\in\\underbrace{FP}_{\\substack{=P^{q}F\\\\\\text{(by Proposition\r\n\\ref{prop.F.FP})}}}\\cdot\\mathcal{F}=\\underbrace{P^{q}}_{=PP^{q-1}}%\r\nF\\cdot\\mathcal{F}\\\\\r\n&  =P\\underbrace{P^{q-1}F\\cdot\\mathcal{F}}_{\\subseteq\\mathcal{F}}\\subseteq\r\nP\\cdot\\mathcal{F}.\r\n\\end{align*}\r\nIn other words, (\\ref{pf.cor.F.FPF.FiP}) holds for $i=n+1$. This completes the\r\ninduction step. Thus, (\\ref{pf.cor.F.FPF.FiP}) is proven.\r\n\r\nRecall that $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ is a basis of the\r\n$\\mathbb{F}_{q}$-module $\\mathcal{F}$ (by Proposition \\ref{prop.F.bases}\r\n\\textbf{(b)}).\r\n\r\nNow, we shall prove that%\r\n\\begin{equation}\r\nuP\\in P\\cdot\\mathcal{F}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\mathcal{F}.\r\n\\label{pf.cor.F.FPF.main}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.cor.F.FPF.main}):} Let $u\\in\\mathcal{F}$. We must\r\nprove the equality (\\ref{pf.cor.F.FPF.main}). Since this equality is\r\n$\\mathbb{F}_{q}$-linear in $u$, we can WLOG assume that $u$ belongs to the\r\nbasis $\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ of the $\\mathbb{F}_{q}%\r\n$-module $\\mathcal{F}$. Assume this. Thus, $u=T^{j}F^{i}$ for some $\\left(\r\ni,j\\right)  \\in\\mathbb{N}^{2}$. Consider this $\\left(  i,j\\right)  $. Now,%\r\n\\[\r\n\\underbrace{u}_{=T^{j}F^{i}}P=T^{j}\\underbrace{F^{i}P}_{\\substack{\\in\r\nP\\cdot\\mathcal{F}\\\\\\text{(by (\\ref{pf.cor.F.FPF.FiP}))}}}\\in\\underbrace{T^{j}%\r\nP}_{\\substack{=PT^{j}\\\\\\text{(since }P\\text{ and }T^{j}\\text{ both}\\\\\\text{lie\r\nin }\\mathbb{F}_{q}\\left[  T\\right]  \\text{)}}}\\cdot\\mathcal{F}%\r\n=P\\underbrace{T^{j}\\cdot\\mathcal{F}}_{\\subseteq\\mathcal{F}}\\subseteq\r\nP\\cdot\\mathcal{F}.\r\n\\]\r\nThis proves (\\ref{pf.cor.F.FPF.main}).\r\n\r\nNow, (\\ref{pf.cor.F.FPF.main}) immediately yields $\\mathcal{F}\\cdot P\\subseteq\r\nP\\cdot\\mathcal{F}$. Hence, $\\underbrace{\\mathcal{F}\\cdot P}_{\\subseteq\r\nP\\cdot\\mathcal{F}}\\cdot\\mathcal{F}\\subseteq P\\cdot\\underbrace{\\mathcal{F}%\r\n\\cdot\\mathcal{F}}_{\\subseteq\\mathcal{F}}\\subseteq P\\cdot\\mathcal{F}$. This\r\nproves Corollary \\ref{cor.F.FPF}.\r\n\\end{proof}\r\n\r\n\\subsection{$q$-polynomials}\r\n\r\nNext, we shall see an alternative description of the $\\mathbb{F}_{q}$-algebra\r\n$\\mathcal{F}$. We begin with a general definition:\r\n\r\n\\begin{definition}\r\n\\label{def.q-pol}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra. A\r\npolynomial in $A\\left[  X\\right]  $ is said to be a $q$\\textit{-polynomial} if\r\nit is an $A$-linear combination of the monomials $X^{q^{0}},X^{q^{1}}%\r\n,X^{q^{2}},\\ldots$. We let $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ be\r\nthe set of all $q$-polynomials in $A\\left[  X\\right]  $. Thus, $A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$ is an $A$-submodule of $A\\left[  X\\right]\r\n$; as an $A$-submodule, it has basis $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}%\r\n},\\ldots\\right)  $.\r\n\\end{definition}\r\n\r\nThus, a polynomial in $A\\left[  X\\right]  $ belongs to $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ if and only if the only monomials it contains are\r\n(some of) the monomials $X^{q^{0}},X^{q^{1}},X^{q^{2}},\\ldots$.\r\n\r\nThe $A$-submodule $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ of $A\\left[\r\nX\\right]  $ is not a subring of $A\\left[  X\\right]  $ (unless $A=0$). However,\r\nit is closed under a different operation: namely, composition of polynomials.\r\nLet us see this in more detail:\r\n\r\n\\begin{definition}\r\n\\label{def.q-pol.comp}Let $A$ be a commutative ring. Let $f\\in A\\left[\r\nX\\right]  $ and $g\\in A\\left[  X\\right]  $. Then, $f\\circ g$ denotes the\r\npolynomial $f\\left(  g\\right)  \\in A\\left[  X\\right]  $. (This is the\r\npolynomial obtained from $f$ by substituting $g$ for $X$.) This defines a\r\nbinary operation $\\circ$ on the set $A\\left[  X\\right]  $.\r\n\\end{definition}\r\n\r\n\\begin{proposition}\r\n\\label{prop.q-pol.comp.basics}Let $A$ be a commutative ring.\r\n\r\n\\textbf{(a)} The pair $\\left(  A\\left[  X\\right]  ,\\circ\\right)  $ is a monoid\r\nwith neutral element $X$.\r\n\r\n\\textbf{(b)} Assume that $A$ is a commutative $\\mathbb{F}_{q}$-algebra. Then,\r\n$A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is a submonoid of the monoid\r\n$\\left(  A\\left[  X\\right]  ,\\circ\\right)  $. Moreover, $\\left(  A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}},+,\\circ\\right)  $ is a (noncommutative)\r\n$\\mathbb{F}_{q}$-algebra with unity $X$ (where the $\\mathbb{F}_{q}$-module\r\nstructure is the one obtained by restricting the $A\\left[  X\\right]  $-module\r\nstructure to $\\mathbb{F}_{q}$).\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.q-pol.comp.basics}.]\\textbf{(a)} If $B$ is any\r\ncommutative $A$-algebra, and if $b\\in B$ is any element, then there exists a\r\nunique $A$-algebra homomorphism $\\varphi:A\\left[  X\\right]  \\rightarrow B$\r\nsatisfying $\\varphi\\left(  X\\right)  =b$.\\ \\ \\ \\ \\footnote{This is simply the\r\nuniversal property of the polynomial ring $A\\left[  X\\right]  $.} We shall\r\ndenote this homomorphism $\\varphi$ by $\\operatorname*{ev}\\nolimits_{b}$. It\r\nhas the property that%\r\n\\begin{equation}\r\n\\operatorname*{ev}\\nolimits_{b}\\left(  f\\right)  =f\\left(  b\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }f\\in A\\left[  X\\right]  .\r\n\\label{pf.prop.q-pol.comp.basics.a.ev}%\r\n\\end{equation}\r\n\r\n\r\nNow, every $f,g\\in A\\left[  X\\right]  $ satisfy%\r\n\\begin{align}\r\n\\operatorname*{ev}\\nolimits_{g}\\left(  f\\right)   &  =f\\left(  g\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{pf.prop.q-pol.comp.basics.a.ev}),\r\napplied to }B=A\\left[  X\\right]  \\text{ and }b=g\\right) \\nonumber\\\\\r\n&  =f\\circ g\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }f\\circ g=f\\left(\r\ng\\right)  \\right)  . \\label{pf.prop.q-pol.comp.basics.a.evgf}%\r\n\\end{align}\r\n\r\n\r\nLet $f,g,h\\in A\\left[  X\\right]  $. Then,\r\n(\\ref{pf.prop.q-pol.comp.basics.a.evgf}) yields $\\operatorname*{ev}%\r\n\\nolimits_{g}\\left(  f\\right)  =f\\circ g$. Furthermore,\r\n(\\ref{pf.prop.q-pol.comp.basics.a.evgf}) (applied to $f\\circ g$ and $h$\r\ninstead of $f$ and $g$) yields $\\operatorname*{ev}\\nolimits_{h}\\left(  f\\circ\r\ng\\right)  =\\left(  f\\circ g\\right)  \\circ h$. But\r\n(\\ref{pf.prop.q-pol.comp.basics.a.evgf}) (applied to $g$ and $h$ instead of\r\n$f$ and $g$) yields $\\operatorname*{ev}\\nolimits_{h}\\left(  g\\right)  =g\\circ\r\nh$. Finally, (\\ref{pf.prop.q-pol.comp.basics.a.evgf}) (applied to $g\\circ h$\r\ninstead of $g$) yields $\\operatorname*{ev}\\nolimits_{g\\circ h}\\left(\r\nf\\right)  =f\\circ\\left(  g\\circ h\\right)  $.\r\n\r\nThe defining property of $\\operatorname*{ev}\\nolimits_{g\\circ h}$ yields\r\n$\\operatorname*{ev}\\nolimits_{g\\circ h}\\left(  X\\right)  =g\\circ h$. But the\r\ndefining property of $\\operatorname*{ev}\\nolimits_{g}$ yields\r\n$\\operatorname*{ev}\\nolimits_{g}\\left(  X\\right)  =g$. Now,%\r\n\\[\r\n\\left(  \\operatorname*{ev}\\nolimits_{h}\\circ\\operatorname*{ev}\\nolimits_{g}%\r\n\\right)  \\left(  X\\right)  =\\operatorname*{ev}\\nolimits_{h}\\left(\r\n\\underbrace{\\operatorname*{ev}\\nolimits_{g}\\left(  X\\right)  }_{=g}\\right)\r\n=\\operatorname*{ev}\\nolimits_{h}\\left(  g\\right)  =g\\circ h.\r\n\\]\r\nComparing this with $\\operatorname*{ev}\\nolimits_{g\\circ h}\\left(  X\\right)\r\n=g\\circ h$, we obtain $\\left(  \\operatorname*{ev}\\nolimits_{h}\\circ\r\n\\operatorname*{ev}\\nolimits_{g}\\right)  \\left(  X\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{g\\circ h}\\left(  X\\right)  $. The two maps $\\operatorname*{ev}%\r\n\\nolimits_{h}\\circ\\operatorname*{ev}\\nolimits_{g}$ and $\\operatorname*{ev}%\r\n\\nolimits_{g\\circ h}$ thus agree on the generator $X$ of the $A$-algebra\r\n$A\\left[  X\\right]  $. Since these two maps are $A$-algebra homomorphisms\r\n(because $\\operatorname*{ev}\\nolimits_{h}$, $\\operatorname*{ev}\\nolimits_{g}$\r\nand $\\operatorname*{ev}\\nolimits_{g\\circ h}$ are $A$-algebra homomorphisms),\r\nthis shows that these two maps are equal. In other words, $\\operatorname*{ev}%\r\n\\nolimits_{h}\\circ\\operatorname*{ev}\\nolimits_{g}=\\operatorname*{ev}%\r\n\\nolimits_{g\\circ h}$. Hence, $\\underbrace{\\left(  \\operatorname*{ev}%\r\n\\nolimits_{h}\\circ\\operatorname*{ev}\\nolimits_{g}\\right)  }%\r\n_{=\\operatorname*{ev}\\nolimits_{g\\circ h}}\\left(  f\\right)\r\n=\\operatorname*{ev}\\nolimits_{g\\circ h}\\left(  f\\right)  =f\\circ\\left(  g\\circ\r\nh\\right)  $. Thus,%\r\n\\[\r\nf\\circ\\left(  g\\circ h\\right)  =\\left(  \\operatorname*{ev}\\nolimits_{h}%\r\n\\circ\\operatorname*{ev}\\nolimits_{g}\\right)  \\left(  f\\right)\r\n=\\operatorname*{ev}\\nolimits_{h}\\left(  \\underbrace{\\operatorname*{ev}%\r\n\\nolimits_{g}\\left(  f\\right)  }_{=f\\circ g}\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{h}\\left(  f\\circ g\\right)  =\\left(  f\\circ g\\right)  \\circ h.\r\n\\]\r\n\r\n\r\nNow, let us forget that we fixed $f,g,h$. We thus have shown that\r\n$f\\circ\\left(  g\\circ h\\right)  =\\left(  f\\circ g\\right)  \\circ h$ for every\r\n$f,g,h\\in A\\left[  X\\right]  $. Thus, $\\left(  A\\left[  X\\right]\r\n,\\circ\\right)  $ is a semigroup. Furthermore, $X$ is a neutral element of this\r\nsemigroup (since every $f\\in A\\left[  X\\right]  $ satisfies $X\\circ f=X\\left(\r\nf\\right)  =f$ and $f\\circ X=f\\left(  X\\right)  =f$). Therefore, this semigroup\r\n$\\left(  A\\left[  X\\right]  ,\\circ\\right)  $ is a monoid with neutral element\r\n$X$. This proves Proposition \\ref{prop.q-pol.comp.basics} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} \\textit{Step 1:} Let $\\operatorname*{End}\\left(  A\\left[\r\nX\\right]  \\right)  $ denote the $\\mathbb{F}_{q}$-algebra of all endomorphisms\r\nof the $\\mathbb{F}_{q}$-vector space $A\\left[  X\\right]  $. It is easy to see\r\nthat $\\operatorname*{Frob}=\\operatorname*{Frob}\\nolimits_{A\\left[  X\\right]\r\n}\\in\\operatorname*{End}\\left(  A\\left[  X\\right]  \\right)  $. Hence,\r\n$\\operatorname*{Frob}\\nolimits^{n}\\in\\operatorname*{End}\\left(  A\\left[\r\nX\\right]  \\right)  $ for every $n\\in\\mathbb{N}$. It is straightforward to see\r\n(by induction over $n$) that%\r\n\\begin{equation}\r\n\\operatorname*{Frob}\\nolimits^{n}\\left(  f\\right)  =f^{q^{n}}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }f\\in A\\left[  X\\right]  \\text{ and }%\r\nn\\in\\mathbb{N}. \\label{pf.prop.q-pol.comp.basics.b.Frobn}%\r\n\\end{equation}\r\nIt is easy to see that\r\n\\begin{equation}\r\n\\operatorname*{Frob}\\left(  A\\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}\\right)  \\subseteq A\\left[  X\\right]  _{q-\\operatorname*{lin}}\r\n\\label{pf.prop.q-pol.comp.basics.b.Frob-contains}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.q-pol.comp.basics.b.Frob-contains}):}\r\nLet $g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. We shall prove that\r\n$\\operatorname*{Frob}g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$.\r\n\\par\r\nIndeed, $g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Thus, $g$ is an\r\n$A$-linear combination of $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}}%\r\n,\\ldots\\right)  $ (since the $A$-module $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ has basis $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}%\r\n},\\ldots\\right)  $). In other words, there exists a sequence $\\left(\r\na_{0},a_{1},a_{2},\\ldots\\right)  \\in A^{\\mathbb{N}}$ of elements of $A$ such\r\nthat $g=\\sum_{n\\in\\mathbb{N}}a_{n}X^{q^{n}}$, and such that all but finitely\r\nmany $n\\in\\mathbb{N}$ satisfy $a_{n}=0$. Consider this sequence.\r\n\\par\r\nApplying the map $\\operatorname*{Frob}$ to the equality $g=\\sum_{n\\in\r\n\\mathbb{N}}a_{n}X^{q^{n}}$, we obtain%\r\n\\begin{align*}\r\n\\operatorname*{Frob}g  &  =\\operatorname*{Frob}\\left(  \\sum_{n\\in\\mathbb{N}%\r\n}a_{n}X^{q^{n}}\\right)  =\\sum_{n\\in\\mathbb{N}}\\underbrace{\\operatorname*{Frob}%\r\n\\left(  a_{n}X^{q^{n}}\\right)  }_{=\\left(  a_{n}X^{q^{n}}\\right)  ^{q}%\r\n=a_{n}^{q}\\left(  X^{q^{n}}\\right)  ^{q}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since the map }\\operatorname*{Frob}\\text{ is }\\mathbb{F}_{q}%\r\n\\text{-linear}\\right) \\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}a_{n}^{q}\\underbrace{\\left(  X^{q^{n}}\\right)  ^{q}%\r\n}_{=X^{q^{n}q}=X^{q^{n+1}}\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}}%\r\n\\in\\sum_{n\\in\\mathbb{N}}a_{n}^{q}A\\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}\\subseteq A\\left[  X\\right]  _{q-\\operatorname*{lin}}%\r\n\\end{align*}\r\n(since $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is an $A$-module).\r\n\\par\r\nNow, let us forget that we fixed $g$. We thus have proven that\r\n$\\operatorname*{Frob}g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ for\r\nevery $g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. In other words,\r\n$\\operatorname*{Frob}\\left(  A\\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}\\right)  \\subseteq A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. This proves\r\n(\\ref{pf.prop.q-pol.comp.basics.b.Frob-contains}).}. Using this fact, it is\r\nstraightforward to see (by induction over $n$) that%\r\n\\begin{equation}\r\n\\operatorname*{Frob}\\nolimits^{n}\\left(  A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}\\right)  \\subseteq A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}.\r\n\\label{pf.prop.q-pol.comp.basics.b.Frob-contains-n}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Step 2:} Now, let us prove that%\r\n\\begin{equation}\r\nf\\circ\\left(  \\lambda_{1}g_{1}+\\lambda_{2}g_{2}\\right)  =\\lambda_{1}\\left(\r\nf\\circ g_{1}\\right)  +\\lambda_{2}\\left(  f\\circ g_{2}\\right)\r\n\\label{pf.prop.q-pol.comp.basics.b.dist1}%\r\n\\end{equation}\r\nfor every $f\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$, $g_{1}\\in\r\nA\\left[  X\\right]  $, $g_{2}\\in A\\left[  X\\right]  $, $\\lambda_{1}%\r\n\\in\\mathbb{F}_{q}$ and $\\lambda_{2}\\in\\mathbb{F}_{q}$.\r\n\r\n\\textit{Proof of (\\ref{pf.prop.q-pol.comp.basics.b.dist1}):} Let $f\\in\r\nA\\left[  X\\right]  _{q-\\operatorname*{lin}}$.\r\n\r\nWe have $f\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Thus, $f$ is an\r\n$A$-linear combination of $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}}%\r\n,\\ldots\\right)  $ (since the $A$-module $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ has basis $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}%\r\n},\\ldots\\right)  $). In other words, there exists a sequence $\\left(\r\na_{0},a_{1},a_{2},\\ldots\\right)  \\in A^{\\mathbb{N}}$ of elements of $A$ such\r\nthat $f=\\sum_{n\\in\\mathbb{N}}a_{n}X^{q^{n}}$, and such that all but finitely\r\nmany $n\\in\\mathbb{N}$ satisfy $a_{n}=0$. Consider this sequence.\r\n\r\nLet $\\widehat{f}$ denote the element $\\sum_{n\\in\\mathbb{N}}a_{n}%\r\n\\operatorname*{Frob}\\nolimits^{n}$ of $\\operatorname*{End}\\left(  A\\left[\r\nX\\right]  \\right)  $. (This is well-defined, since $\\operatorname*{Frob}%\r\n\\nolimits^{n}\\in\\operatorname*{End}\\left(  A\\left[  X\\right]  \\right)  $ for\r\nevery $n\\in\\mathbb{N}$.) Now, every $h\\in A\\left[  X\\right]  $ satisfies%\r\n\\begin{equation}\r\nf\\circ h=\\widehat{f}\\left(  h\\right)\r\n\\label{pf.prop.q-pol.comp.basics.b.dist1.pf.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}):}\r\nLet $h\\in A\\left[  X\\right]  $. Then,%\r\n\\[\r\nf\\circ h=f\\left(  h\\right)  =\\sum_{n\\in\\mathbb{N}}a_{n}h^{q^{n}}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }f=\\sum_{n\\in\\mathbb{N}}a_{n}X^{q^{n}%\r\n}\\right)  .\r\n\\]\r\nComparing this with%\r\n\\begin{align*}\r\n\\widehat{f}\\left(  h\\right)   &  =\\sum_{n\\in\\mathbb{N}}a_{n}%\r\n\\underbrace{\\operatorname*{Frob}\\nolimits^{n}\\left(  h\\right)  }%\r\n_{\\substack{=h^{q^{n}}\\\\\\text{(by (\\ref{pf.prop.q-pol.comp.basics.b.Frobn}),\r\napplied to }h\\\\\\text{instead of }f\\text{)}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\widehat{f}=\\sum_{n\\in\\mathbb{N}}a_{n}\\operatorname*{Frob}%\r\n\\nolimits^{n}\\right) \\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}a_{n}h^{q^{n}},\r\n\\end{align*}\r\nthis yields $f\\circ h=\\widehat{f}\\left(  h\\right)  $, qed.}.\r\n\r\nNow, let $g_{1}\\in A\\left[  X\\right]  $, $g_{2}\\in A\\left[  X\\right]  $,\r\n$\\lambda_{1}\\in\\mathbb{F}_{q}$ and $\\lambda_{2}\\in\\mathbb{F}_{q}$. Applying\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}) to $h=\\lambda_{1}g_{1}%\r\n+\\lambda_{2}g_{2}$, we obtain%\r\n\\[\r\nf\\circ\\left(  \\lambda_{1}g_{1}+\\lambda_{2}g_{2}\\right)  =\\widehat{f}\\left(\r\n\\lambda_{1}g_{1}+\\lambda_{2}g_{2}\\right)  =\\lambda_{1}\\widehat{f}\\left(\r\ng_{1}\\right)  +\\lambda_{2}\\widehat{f}\\left(  g_{2}\\right)\r\n\\]\r\n(since $\\widehat{f}\\in\\operatorname*{End}\\left(  A\\left[  X\\right]  \\right)\r\n$). Comparing this with%\r\n\\[\r\n\\lambda_{1}\\underbrace{\\left(  f\\circ g_{1}\\right)  }_{\\substack{=\\widehat{f}%\r\n\\left(  g_{1}\\right)  \\\\\\text{(by\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}))}}}+\\lambda_{2}%\r\n\\underbrace{\\left(  f\\circ g_{2}\\right)  }_{\\substack{=\\widehat{f}\\left(\r\ng_{2}\\right)  \\\\\\text{(by (\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}))}%\r\n}}=\\lambda_{1}\\widehat{f}\\left(  g_{1}\\right)  +\\lambda_{2}\\widehat{f}\\left(\r\ng_{2}\\right)  ,\r\n\\]\r\nwe obtain $f\\circ\\left(  \\lambda_{1}g_{1}+\\lambda_{2}g_{2}\\right)\r\n=\\lambda_{1}\\left(  f\\circ g_{1}\\right)  +\\lambda_{2}\\left(  f\\circ\r\ng_{2}\\right)  $. Thus, (\\ref{pf.prop.q-pol.comp.basics.b.dist1}) is proven.\r\n\r\n\\textit{Step 3:} Furthermore, we have%\r\n\\begin{equation}\r\n\\left(  \\lambda_{1}f_{1}+\\lambda_{2}f_{2}\\right)  \\circ g=\\lambda_{1}\\left(\r\nf_{1}\\circ g\\right)  +\\lambda_{2}\\left(  f_{2}\\circ g\\right)\r\n\\label{pf.prop.q-pol.comp.basics.b.dist2}%\r\n\\end{equation}\r\nfor every $f_{1}\\in A\\left[  X\\right]  $, $f_{2}\\in A\\left[  X\\right]  $,\r\n$g\\in A\\left[  X\\right]  $, $\\lambda_{1}\\in\\mathbb{F}_{q}$ and $\\lambda_{2}%\r\n\\in\\mathbb{F}_{q}$.\r\n\r\n\\textit{Proof of (\\ref{pf.prop.q-pol.comp.basics.b.dist2}):} Let $f_{1}\\in\r\nA\\left[  X\\right]  $, $f_{2}\\in A\\left[  X\\right]  $, $g\\in A\\left[  X\\right]\r\n$, $\\lambda_{1}\\in\\mathbb{F}_{q}$ and $\\lambda_{2}\\in\\mathbb{F}_{q}$. Then,%\r\n\\[\r\n\\left(  \\lambda_{1}f_{1}+\\lambda_{2}f_{2}\\right)  \\circ g=\\left(  \\lambda\r\n_{1}f_{1}+\\lambda_{2}f_{2}\\right)  \\left(  g\\right)  =\\lambda_{1}f_{1}\\left(\r\ng\\right)  +\\lambda_{2}f_{2}\\left(  g\\right)  .\r\n\\]\r\nComparing this with $\\lambda_{1}\\underbrace{\\left(  f_{1}\\circ g\\right)\r\n}_{=f_{1}\\left(  g\\right)  }+\\lambda_{2}\\underbrace{\\left(  f_{2}\\circ\r\ng\\right)  }_{=f_{2}\\left(  g\\right)  }=\\lambda_{1}f_{1}\\left(  g\\right)\r\n+\\lambda_{2}f_{2}\\left(  g\\right)  $, we obtain $\\left(  \\lambda_{1}%\r\nf_{1}+\\lambda_{2}f_{2}\\right)  \\circ g=\\lambda_{1}\\left(  f_{1}\\circ g\\right)\r\n+\\lambda_{2}\\left(  f_{2}\\circ g\\right)  $. This proves\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist2}).\r\n\r\n\\textit{Step 4:} Now, let us show that%\r\n\\begin{equation}\r\nf\\circ g\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }f,g\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}. \\label{pf.prop.q-pol.comp.basics.b.closed}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.prop.q-pol.comp.basics.b.closed}):} Let $f,g\\in\r\nA\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Define the sequence $\\left(\r\na_{0},a_{1},a_{2},\\ldots\\right)  \\in A^{\\mathbb{N}}$ and the element\r\n$\\widehat{f}\\in\\operatorname*{End}\\left(  A\\left[  X\\right]  \\right)  $ as in\r\nthe proof of (\\ref{pf.prop.q-pol.comp.basics.b.dist1}). Then,\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}) holds. Applying\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist1.pf.1}) to $h=g$, we obtain%\r\n\\begin{align*}\r\nf\\circ g  &  =\\widehat{f}\\left(  g\\right)  =\\sum_{n\\in\\mathbb{N}}%\r\na_{n}\\operatorname*{Frob}\\nolimits^{n}\\left(  \\underbrace{g}_{\\in A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\widehat{f}=\\sum_{n\\in\\mathbb{N}}a_{n}\\operatorname*{Frob}%\r\n\\nolimits^{n}\\right) \\\\\r\n&  \\in\\sum_{n\\in\\mathbb{N}}a_{n}\\underbrace{\\operatorname*{Frob}%\r\n\\nolimits^{n}\\left(  A\\left[  X\\right]  _{q-\\operatorname*{lin}}\\right)\r\n}_{\\substack{\\subseteq A\\left[  X\\right]  _{q-\\operatorname*{lin}}\\\\\\text{(by\r\n(\\ref{pf.prop.q-pol.comp.basics.b.Frob-contains-n}))}}}\\subseteq\\sum\r\n_{n\\in\\mathbb{N}}a_{n}A\\left[  X\\right]  _{q-\\operatorname*{lin}}\\subseteq\r\nA\\left[  X\\right]  _{q-\\operatorname*{lin}}%\r\n\\end{align*}\r\n(since $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is an $A$-module). Thus,\r\nwe have proven (\\ref{pf.prop.q-pol.comp.basics.b.closed}).\r\n\r\n\\textit{Step 5:} We have $X=X^{1}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$. This, combined with\r\n(\\ref{pf.prop.q-pol.comp.basics.b.closed}), shows that $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is a submonoid of the monoid $\\left(  A\\left[\r\nX\\right]  ,\\circ\\right)  $. Furthermore, the binary operation $\\circ$ on\r\n$A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is $\\mathbb{F}_{q}$-bilinear (by\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist1}) and\r\n(\\ref{pf.prop.q-pol.comp.basics.b.dist2})) and associative (since $\\left(\r\nA\\left[  X\\right]  ,\\circ\\right)  $ is a monoid) and has neutral element $X$\r\n(since $\\left(  A\\left[  X\\right]  ,\\circ\\right)  $ is a monoid with neutral\r\nelement $X$). Thus, $\\left(  A\\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n},+,\\circ\\right)  $ is a (noncommutative) $\\mathbb{F}_{q}$-algebra with unity\r\n$X$. This concludes the proof of Proposition \\ref{prop.q-pol.comp.basics}\r\n\\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{definition}\r\n\\label{def.q-pol.mon.not}Let $A$ be a commutative ring. Whenever $f\\in\r\nA\\left[  X\\right]  $ and $n\\in\\mathbb{N}$, we shall use the notation $f^{\\circ\r\nn}$ for the $n$-th power of $f$ in the monoid $\\left(  A\\left[  X\\right]\r\n,\\circ\\right)  $.\r\n\\end{definition}\r\n\r\n\\begin{definition}\r\n\\label{def.q-pol.ring}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra. The\r\n(noncommutative) $\\mathbb{F}_{q}$-algebra $\\left(  A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}},+,\\circ\\right)  $ constructed in Proposition\r\n\\ref{prop.q-pol.comp.basics} \\textbf{(b)} will be called the \\textit{Ore\r\npolynomial ring over }$A$, and simply denoted by $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ (since there are no other $\\mathbb{F}_{q}$-algebra\r\nstructures on $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ that could be\r\nconfused with this one).\r\n\\end{definition}\r\n\r\nThe connection between these Ore polynomial rings and our $\\mathcal{F}$ is the following:\r\n\r\n\\begin{theorem}\r\n\\label{thm.q-pol.=F}Consider the Ore polynomial ring $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ over $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $; recall that this is the $\\mathbb{F}_{q}$-algebra\r\n$\\left(  \\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}},+,\\circ\\right)  $. (Notice that polynomials in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$\r\ncan contain arbitrary powers of $T$, but the only powers of $X$ they can\r\ncontain are $X^{q^{0}},X^{q^{1}},X^{q^{2}},\\ldots$.) Define an $\\mathbb{F}%\r\n_{q}$-algebra homomorphism $\\operatorname*{Fqpol}:\\mathcal{F}\\rightarrow\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ by\r\n$\\operatorname*{Fqpol}\\left(  F\\right)  =X^{q}$ and $\\operatorname*{Fqpol}%\r\n\\left(  T\\right)  =TX$.\r\n\r\n\\textbf{(a)} This homomorphism $\\operatorname*{Fqpol}$ is well-defined.\r\n\r\n\\textbf{(b)} This homomorphism $\\operatorname*{Fqpol}$ is an $\\mathbb{F}_{q}%\r\n$-algebra isomorphism.\r\n\r\n\\textbf{(c)} We have $\\operatorname*{Fqpol}\\left(  T^{j}F^{i}\\right)\r\n=T^{j}X^{q^{i}}$ for every $i\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$.\r\n\r\n\\textbf{(d)} We have $\\operatorname*{Fqpol}t=t\\cdot X$ for every\r\n$t\\in\\mathbb{F}_{q}\\left[  T\\right]  $. (Here, we regard $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ as an $\\mathbb{F}_{q}$-subalgebra of $\\mathcal{F}$ as\r\nbefore. The expression \\textquotedblleft$t\\cdot X$\\textquotedblright\\ means\r\nthe product of $t\\in\\mathbb{F}_{q}\\left[  T\\right]  \\subseteq\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  $ with $X$ in $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  $.)\r\n\\end{theorem}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.q-pol.=F}.]For every $n\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\n\\left(  TX\\right)  ^{\\circ n}=T^{n}X\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in }%\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}.\r\n\\label{pf.thm.q-pol.=F.TXon}%\r\n\\end{equation}\r\n(This follows by a straightforward induction on $n$.) Furthermore, for every\r\n$n\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\n\\left(  X^{q}\\right)  ^{\\circ n}=X^{q^{n}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in\r\n}\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}.\r\n\\label{pf.thm.q-pol.=F.Xqon}%\r\n\\end{equation}\r\n(Again, this is easy to prove by induction.)\r\n\r\n\\textbf{(a)} In $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$, we have $X^{q}\\circ\\left(  TX\\right)  =\\left(\r\nTX\\right)  ^{\\circ q}\\circ X^{q}$ (indeed, this follows by comparing\r\n$X^{q}\\circ\\left(  TX\\right)  =X^{q}\\left(  TX\\right)  =\\left(  TX\\right)\r\n^{q}=T^{q}X^{q}$ and $\\underbrace{\\left(  TX\\right)  ^{\\circ q}}%\r\n_{\\substack{=T^{q}X\\\\\\text{(by (\\ref{pf.thm.q-pol.=F.TXon}), applied to\r\n}n=q\\text{)}}}\\circ X^{q}=\\left(  T^{q}X\\right)  \\circ X^{q}=T^{q}X^{q}$).\r\nNow, recall that if $u$ and $v$ are two elements of an $\\mathbb{F}_{q}%\r\n$-algebra $\\mathcal{U}$ satisfying $uv=v^{q}u$, then there exists a unique\r\n$\\mathbb{F}_{q}$-algebra homomorphism $\\mathcal{F}\\rightarrow\\mathcal{U}$\r\nsending $F$ and $T$ to $u$ and $v$, respectively. Applying this to\r\n$\\mathcal{U}=\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$, $u=X^{q}$ and $v=TX$, we thus conclude that there\r\nexists a unique $\\mathbb{F}_{q}$-algebra homomorphism $\\mathcal{F}%\r\n\\rightarrow\\mathcal{U}$ sending $F$ and $T$ to $X^{q}$ and $TX$, respectively.\r\nIn other words, the homomorphism $\\operatorname*{Fqpol}$ is well-defined. This\r\nproves Theorem \\ref{thm.q-pol.=F} \\textbf{(a)}.\r\n\r\n\\textbf{(c)} For every $i\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$, we have%\r\n\\begin{align*}\r\n\\operatorname*{Fqpol}\\left(  T^{j}F^{i}\\right)   &  =\\left(\r\n\\underbrace{\\operatorname*{Fqpol}T}_{=TX}\\right)  ^{\\circ j}\\circ\\left(\r\n\\underbrace{\\operatorname*{Fqpol}F}_{=X^{q}}\\right)  ^{\\circ i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{Fqpol}\\text{ is an\r\n}\\mathbb{F}_{q}\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\underbrace{\\left(  TX\\right)  ^{\\circ j}}_{\\substack{=T^{j}X\\\\\\text{(by\r\n(\\ref{pf.thm.q-pol.=F.TXon}))}}}\\circ\\underbrace{\\left(  X^{q}\\right)  ^{\\circ\r\ni}}_{\\substack{=X^{q^{i}}\\\\\\text{(by (\\ref{pf.thm.q-pol.=F.Xqon}))}}}=\\left(\r\nT^{j}X\\right)  \\circ X^{q^{i}}=T^{j}X^{q^{i}}.\r\n\\end{align*}\r\nThis proves Theorem \\ref{thm.q-pol.=F} \\textbf{(c)}.\r\n\r\n\\textbf{(b)} The $\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ has basis\r\n$\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}},\\ldots\\right)  =\\left(  X^{q^{i}%\r\n}\\right)  _{i\\geq0}$. Thus, as an $\\mathbb{F}_{q}$-module, it has basis\r\n$\\left(  T^{j}X^{q^{i}}\\right)  _{i\\geq0,\\ j\\geq0}$.\r\n\r\nOn the other hand, Proposition \\ref{prop.F.bases} \\textbf{(b)} says that the\r\n$\\mathbb{F}_{q}$-module $\\mathcal{F}$ is free with basis $\\left(  T^{j}%\r\nF^{i}\\right)  _{i\\geq0,\\ j\\geq0}$.\r\n\r\nFor every $i\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$, we have\r\n$\\operatorname*{Fqpol}\\left(  T^{j}F^{i}\\right)  =T^{j}X^{q^{i}}$ (by Theorem\r\n\\ref{thm.q-pol.=F} \\textbf{(c)}). Hence, the $\\mathbb{F}_{q}$-linear map\r\n$\\operatorname*{Fqpol}$ sends the basis $\\left(  T^{j}F^{i}\\right)\r\n_{i\\geq0,\\ j\\geq0}$ of the $\\mathbb{F}_{q}$-module $\\mathcal{F}$ to the basis\r\n$\\left(  T^{j}X^{q^{i}}\\right)  _{i\\geq0,\\ j\\geq0}$ of the $\\mathbb{F}_{q}%\r\n$-module $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$. Consequently, $\\operatorname*{Fqpol}$ is an\r\n$\\mathbb{F}_{q}$-module isomorphism, thus an $\\mathbb{F}_{q}$-algebra\r\nisomorphism. This proves Theorem \\ref{thm.q-pol.=F} \\textbf{(b)}.\r\n\r\n\\textbf{(d)} Let $t\\in\\mathbb{F}_{q}\\left[  T\\right]  $. We must prove the\r\nequality $\\operatorname*{Fqpol}t=t\\cdot X$. Since this equality is clearly\r\n$\\mathbb{F}_{q}$-linear in $t$, we can WLOG assume that $t$ belongs to the\r\nbasis $\\left(  T^{j}\\right)  _{j\\geq0}$ of the $\\mathbb{F}_{q}$-module\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Assume this. Thus, $t=T^{j}$ for some\r\n$j\\in\\mathbb{N}$. Consider this $j$. We have $t=T^{j}=T^{j}F^{0}$ in\r\n$\\mathcal{F}$. Thus, $\\operatorname*{Fqpol}t=\\operatorname*{Fqpol}\\left(\r\nT^{j}F^{0}\\right)  =T^{j}X^{q^{0}}$ (by Theorem \\ref{thm.q-pol.=F}\r\n\\textbf{(c)}, applied to $i=0$). Hence, $\\operatorname*{Fqpol}%\r\nt=\\underbrace{T^{j}}_{=t}\\underbrace{X^{q^{0}}}_{=X^{1}=X}=t\\cdot X$. Thus,\r\nTheorem \\ref{thm.q-pol.=F} \\textbf{(d)} is proven.\r\n\\end{proof}\r\n\r\nTheorem \\ref{thm.q-pol.=F} \\textbf{(b)} shows that the $\\mathbb{F}_{q}%\r\n$-algebra $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is isomorphic to $\\mathcal{F}$; this algebra can\r\nthus be regarded as a rather concrete manifestation of $\\mathcal{F}$. We shall\r\nmake more use of this later.\r\n\r\nLet us prove one further simple property of $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ (for general $A$):\r\n\r\n\\begin{proposition}\r\n\\label{prop.q-pol.A-q-lin}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra.\r\nLet $f\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Let $B$ be a\r\ncommutative $A$-algebra. Then, the map $B\\rightarrow B,\\ b\\mapsto f\\left(\r\nb\\right)  $ is $\\mathbb{F}_{q}$-linear. (It might not be $A$-linear.)\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.q-pol.A-q-lin}.]Let $\\operatorname*{End}B$\r\ndenote the $\\mathbb{F}_{q}$-algebra of all endomorphisms of the $\\mathbb{F}%\r\n_{q}$-vector space $B$. It is easy to see that $\\operatorname*{Frob}%\r\n=\\operatorname*{Frob}\\nolimits_{B}\\in\\operatorname*{End}B$. Hence,\r\n$\\operatorname*{Frob}\\nolimits^{n}\\in\\operatorname*{End}B$ for every\r\n$n\\in\\mathbb{N}$. It is straightforward to see (by induction over $n$) that%\r\n\\begin{equation}\r\n\\operatorname*{Frob}\\nolimits^{n}\\left(  b\\right)  =b^{q^{n}}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }b\\in B\\text{ and }n\\in\\mathbb{N}.\r\n\\label{pf.prop.q-pol.A-q-lin.Frobn}%\r\n\\end{equation}\r\n\r\n\r\nWe have $f\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Thus, $f$ is an\r\n$A$-linear combination of $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}}%\r\n,\\ldots\\right)  $ (since the $A$-module $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ has basis $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}%\r\n},\\ldots\\right)  $). In other words, there exists a sequence $\\left(\r\na_{0},a_{1},a_{2},\\ldots\\right)  \\in A^{\\mathbb{N}}$ of elements of $A$ such\r\nthat $f=\\sum_{n\\in\\mathbb{N}}a_{n}X^{q^{n}}$, and such that all but finitely\r\nmany $n\\in\\mathbb{N}$ satisfy $a_{n}=0$. Consider this sequence.\r\n\r\nLet $\\widehat{f}$ denote the element $\\sum_{n\\in\\mathbb{N}}a_{n}%\r\n\\operatorname*{Frob}\\nolimits^{n}$ of $\\operatorname*{End}B$. (This is\r\nwell-defined, since $\\operatorname*{Frob}\\nolimits^{n}\\in\\operatorname*{End}B$\r\nfor every $n\\in\\mathbb{N}$.) Now, every $b\\in B$ satisfies%\r\n\\begin{equation}\r\nf\\left(  b\\right)  =\\widehat{f}\\left(  b\\right)\r\n\\label{pf.prop.q-pol.A-q-lin.fh}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.q-pol.A-q-lin.fh}):} Let $b\\in B$.\r\nFrom $f=\\sum_{n\\in\\mathbb{N}}a_{n}X^{q^{n}}$, we obtain $f\\left(  b\\right)\r\n=\\sum_{n\\in\\mathbb{N}}a_{n}b^{q^{n}}$. Comparing this with%\r\n\\begin{align*}\r\n\\widehat{f}\\left(  b\\right)   &  =\\sum_{n\\in\\mathbb{N}}a_{n}%\r\n\\underbrace{\\operatorname*{Frob}\\nolimits^{n}\\left(  b\\right)  }%\r\n_{\\substack{=b^{q^{n}}\\\\\\text{(by (\\ref{pf.prop.q-pol.A-q-lin.Frobn}))}%\r\n}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\widehat{f}=\\sum_{n\\in\\mathbb{N}%\r\n}a_{n}\\operatorname*{Frob}\\nolimits^{n}\\right) \\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}a_{n}b^{q^{n}},\r\n\\end{align*}\r\nthis yields $f\\left(  b\\right)  =\\widehat{f}\\left(  b\\right)  $, qed.}. Hence,\r\nthe map $B\\rightarrow B,\\ b\\mapsto f\\left(  b\\right)  $ equals the map\r\n$B\\rightarrow B,\\ b\\mapsto\\widehat{f}\\left(  b\\right)  $. But the latter map\r\nis simply the map $\\widehat{f}\\in\\operatorname*{End}B$, and thus clearly\r\n$\\mathbb{F}_{q}$-linear. Hence, the former map is $\\mathbb{F}_{q}$-linear.\r\nProposition \\ref{prop.q-pol.A-q-lin} is thus proven.\r\n\\end{proof}\r\n\r\nProposition \\ref{prop.q-pol.A-q-lin} also has a partial converse:\r\n\r\n\\begin{proposition}\r\n\\label{prop.q-pol.A-q-lin-converse}Let $A$ be a commutative $\\mathbb{F}_{q}%\r\n$-algebra which is an integral domain. Let $f\\in A\\left[  X\\right]  $ be such\r\nthat, for every commutative $A$-algebra $B$, the map $B\\rightarrow\r\nB,\\ b\\mapsto f\\left(  b\\right)  $ is $\\mathbb{F}_{q}$-linear. Then, $f\\in\r\nA\\left[  X\\right]  _{q-\\operatorname*{lin}}$.\r\n\\end{proposition}\r\n\r\nThe proof of Proposition \\ref{prop.q-pol.A-q-lin-converse} can be found in\r\n\\cite[Corollary A.3]{kc-carlitz}; we shall not give it here, as we shall not\r\nuse Proposition \\ref{prop.q-pol.A-q-lin-converse}. Propositions\r\n\\ref{prop.q-pol.A-q-lin} and \\ref{prop.q-pol.A-q-lin-converse} are the reason\r\nwhy the $q$-polynomials over $A$ (that is, the elements of $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$) are often called the \\textquotedblleft%\r\n$\\mathbb{F}_{q}$-linear polynomials over $A$\\textquotedblright, but we shall\r\nnot use this terminology (as it is mildly misleading: it sounds too much like\r\ndegree-$1$ polynomials).\r\n\r\n\\subsection{$q$-polynomials from subspaces}\r\n\r\nWe shall now see a classical way to construct $q$-polynomials.\r\n\r\n\\begin{definition}\r\nLet $A$ be a commutative $\\mathbb{F}_{q}$-algebra. For every finite subset $V$\r\nof $A$, let $f_{V}$ be the polynomial $\\prod_{v\\in V}\\left(  X+v\\right)  \\in\r\nA\\left[  X\\right]  $.\r\n\\end{definition}\r\n\r\nThe following result is a consequence of \\cite[(7.7)]{mac-schurvar} (and also\r\nappears in \\cite[Theorem A.1 2)]{kc-carlitz} in the particular case when $A$\r\nis an integral domain):\r\n\r\n\\begin{theorem}\r\n\\label{thm.mac1.subspace}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra.\r\nLet $V$ be a finite $\\mathbb{F}_{q}$-vector subspace of $A$. Then, $f_{V}$ is\r\na $q$-polynomial.\r\n\\end{theorem}\r\n\r\nWe shall prove Theorem \\ref{thm.mac1.subspace} following an idea that appears\r\nin \\cite[proof of (7.15)]{mac-schurvar}; but first, let us slightly generalize it:\r\n\r\n\\begin{definition}\r\nLet $A$ be a commutative $\\mathbb{F}_{q}$-algebra. For every finite set $V$\r\nand every map $\\varphi:V\\rightarrow A$, we let $f_{V,\\varphi}$ be the\r\npolynomial $\\prod_{v\\in V}\\left(  X+\\varphi\\left(  v\\right)  \\right)  \\in\r\nA\\left[  X\\right]  $.\r\n\\end{definition}\r\n\r\n\\begin{theorem}\r\n\\label{thm.mac1.map}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra. Let $V$\r\nbe a finite $\\mathbb{F}_{q}$-vector space, and let $\\varphi:V\\rightarrow A$ be\r\nan $\\mathbb{F}_{q}$-linear map. Then, $f_{V,\\varphi}$ is a $q$-polynomial.\r\n\\end{theorem}\r\n\r\nTheorem \\ref{thm.mac1.map} is not significantly more general than Theorem\r\n\\ref{thm.mac1.subspace} (it is easily derived from the latter), but this\r\nlittle generality helps in proving it. The proof will need the following lemmas:\r\n\r\n\\begin{lemma}\r\n\\label{lem.mac1.too-early}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra.\r\nLet $V$ and $W$ be two finite $\\mathbb{F}_{q}$-vector spaces. Let\r\n$\\varphi:V\\rightarrow A$ and $\\psi:W\\rightarrow A$ be two $\\mathbb{F}_{q}%\r\n$-linear maps. Assume that $f_{W,\\psi}$ is a $q$-polynomial. Let\r\n$h:A\\rightarrow A$ be an $\\mathbb{F}_{q}$-linear map such that every $a\\in A$\r\nsatisfies%\r\n\\begin{equation}\r\nh\\left(  a\\right)  =f_{W,\\psi}\\left(  a\\right)  .\r\n\\label{eq.lem.mac1.too-early.ass}%\r\n\\end{equation}\r\nLet $\\chi:V\\oplus W\\rightarrow A$ be the $\\mathbb{F}_{q}$-linear map which\r\nsends every $\\left(  v,w\\right)  \\in V\\oplus W$ to $\\varphi\\left(  v\\right)\r\n+\\psi\\left(  w\\right)  \\in A$. Then,%\r\n\\[\r\nf_{V\\oplus W,\\chi}=f_{V,h\\circ\\varphi}\\circ f_{W,\\psi}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in }A\\left[  X\\right]  .\r\n\\]\r\n\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.mac1.too-early}.]The definition of $f_{W,\\psi}$\r\nyields%\r\n\\begin{equation}\r\nf_{W,\\psi}=\\prod_{v\\in W}\\left(  X+\\psi\\left(  v\\right)  \\right)  =\\prod_{w\\in\r\nW}\\left(  X+\\psi\\left(  w\\right)  \\right)  \\label{pf.lem.mac1.too-early.fW}%\r\n\\end{equation}\r\n(here, we renamed the summation index $v$ as $w$).\r\n\r\nFix some $v\\in V$. If we substitute $X+\\varphi\\left(  v\\right)  $ for $X$ on\r\nboth sides of (\\ref{pf.lem.mac1.too-early.fW}), then we obtain%\r\n\\begin{equation}\r\nf_{W,\\psi}\\left(  X+\\varphi\\left(  v\\right)  \\right)  =\\prod_{w\\in W}\\left(\r\nX+\\varphi\\left(  v\\right)  +\\psi\\left(  w\\right)  \\right)  .\r\n\\label{pf.lem.mac1.too-early.1}%\r\n\\end{equation}\r\n\r\n\r\nWe have assumed that $f_{W,\\psi}$ is a $q$-polynomial. In other words,\r\n$f_{W,\\psi}\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Hence,\r\nProposition \\ref{prop.q-pol.A-q-lin} (applied to $B=A\\left[  X\\right]  $ and\r\n$f=f_{W,\\psi}$) shows that the map $A\\left[  X\\right]  \\rightarrow A\\left[\r\nX\\right]  ,\\ b\\mapsto f_{W,\\psi}\\left(  b\\right)  $ is $\\mathbb{F}_{q}%\r\n$-linear. Hence, $f_{W,\\psi}\\left(  x_{1}+x_{2}\\right)  =f_{W,\\psi}\\left(\r\nx_{1}\\right)  +f_{W,\\psi}\\left(  x_{2}\\right)  $ for every $x_{1},x_{2}\\in\r\nA\\left[  X\\right]  $. Applying this to $x_{1}=X$ and $x_{2}=\\varphi\\left(\r\nv\\right)  $, we obtain\r\n\\begin{align*}\r\nf_{W,\\psi}\\left(  X+\\varphi\\left(  v\\right)  \\right)   &\r\n=\\underbrace{f_{W,\\psi}\\left(  X\\right)  }_{=f_{W,\\psi}}+\\underbrace{f_{W,\\psi\r\n}\\left(  \\varphi\\left(  v\\right)  \\right)  }_{\\substack{=h\\left(\r\n\\varphi\\left(  v\\right)  \\right)  \\\\\\text{(because\r\n(\\ref{eq.lem.mac1.too-early.ass}) (applied to }a=\\varphi\\left(  v\\right)\r\n\\text{)}\\\\\\text{yields }h\\left(  \\varphi\\left(  v\\right)  \\right)  =f_{W,\\psi\r\n}\\left(  \\varphi\\left(  v\\right)  \\right)  \\text{)}}}\\\\\r\n&  =f_{W,\\psi}+\\underbrace{h\\left(  \\varphi\\left(  v\\right)  \\right)\r\n}_{=\\left(  h\\circ\\varphi\\right)  \\left(  v\\right)  }=f_{W,\\psi}+\\left(\r\nh\\circ\\varphi\\right)  \\left(  v\\right)  .\r\n\\end{align*}\r\nComparing this with (\\ref{pf.lem.mac1.too-early.1}), we obtain%\r\n\\begin{equation}\r\n\\prod_{w\\in W}\\left(  X+\\varphi\\left(  v\\right)  +\\psi\\left(  w\\right)\r\n\\right)  =f_{W,\\psi}+\\left(  h\\circ\\varphi\\right)  \\left(  v\\right)  .\r\n\\label{pf.lem.mac1.too-early.4}%\r\n\\end{equation}\r\n\r\n\r\nLet us now forget that we fixed $v$. We thus have shown proven the equality\r\n(\\ref{pf.lem.mac1.too-early.4}) for all $v\\in V$.\r\n\r\nThe definition of $f_{V,h\\circ\\varphi}$ yields%\r\n\\[\r\nf_{V,h\\circ\\varphi}=\\prod_{v\\in V}\\left(  X+\\left(  h\\circ\\varphi\\right)\r\n\\left(  v\\right)  \\right)  .\r\n\\]\r\nSubstituting $f_{W,\\psi}$ for $X$ on both sides of this equality, we obtain%\r\n\\begin{equation}\r\nf_{V,h\\circ\\varphi}\\left(  f_{W,\\psi}\\right)  =\\prod_{v\\in V}\\left(\r\nf_{W,\\psi}+\\left(  h\\circ\\varphi\\right)  \\left(  v\\right)  \\right)  .\r\n\\label{pf.lem.mac1.too-early.6}%\r\n\\end{equation}\r\n\r\n\r\nThe definition of $f_{V\\oplus W,\\chi}$ yields%\r\n\\begin{align*}\r\nf_{V\\oplus W,\\chi}  &  =\\prod_{v\\in V\\oplus W}\\left(  X+\\chi\\left(  v\\right)\r\n\\right)  =\\underbrace{\\prod_{\\left(  v,w\\right)  \\in V\\oplus W}}_{=\\prod_{v\\in\r\nV}\\prod_{w\\in W}}\\left(  X+\\underbrace{\\chi\\left(  v,w\\right)  }%\r\n_{\\substack{=\\varphi\\left(  v\\right)  +\\psi\\left(  w\\right)  \\\\\\text{(by the\r\ndefinition of }\\chi\\text{)}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the index }v\\text{ as\r\n}\\left(  v,w\\right)  \\text{ in the product}\\right) \\\\\r\n&  =\\prod_{v\\in V}\\underbrace{\\prod_{w\\in W}\\left(  X+\\varphi\\left(  v\\right)\r\n+\\psi\\left(  w\\right)  \\right)  }_{\\substack{=f_{W,\\psi}+\\left(  h\\circ\r\n\\varphi\\right)  \\left(  v\\right)  \\\\\\text{(by (\\ref{pf.lem.mac1.too-early.4}%\r\n))}}}=\\prod_{v\\in V}\\left(  f_{W,\\psi}+\\left(  h\\circ\\varphi\\right)  \\left(\r\nv\\right)  \\right) \\\\\r\n&  =f_{V,h\\circ\\varphi}\\left(  f_{W,\\psi}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{pf.lem.mac1.too-early.6})}\\right) \\\\\r\n&  =f_{V,h\\circ\\varphi}\\circ f_{W,\\psi}.\r\n\\end{align*}\r\nThis proves Lemma \\ref{lem.mac1.too-early}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.mac1.Xq-X}We have\r\n\\begin{equation}\r\n\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda Y\\right)  =X^{q}-XY^{q-1}\r\n\\label{eq.lem.mac1.Xq-X.eq}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbb{F}_{q}\\left[  X,Y\\right]  $.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.mac1.Xq-X}.]It is well-known that\r\n\\begin{equation}\r\n\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\right)  =X^{q}-X\r\n\\label{pf.lem.mac1.Xq-X.X}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbb{F}_{q}\\left[  X\\right]  $\\ \\ \\ \\ \\footnote{Let\r\nus give a \\textit{proof of (\\ref{pf.lem.mac1.Xq-X.X})} for the sake of\r\ncompleteness:\r\n\\par\r\nThe polynomial $\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\right)  $ is\r\na product of $\\left\\vert \\mathbb{F}_{q}\\right\\vert =q$ monic polynomials of\r\ndegree $1$. Thus, it is a monic polynomial of degree $q$. Hence, both\r\npolynomials $\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\right)  $ and\r\n$X^{q}-X$ are monic polynomials of degree $q$. Their difference $\\prod\r\n_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\right)  -\\left(  X^{q}-X\\right)\r\n$ therefore is a polynomial of degree $<q$ (since the subtraction causes their\r\nleading terms to cancel).\r\n\\par\r\nOn the other hand, every $\\mu\\in\\mathbb{F}_{q}$ satisfies%\r\n\\[\r\n\\underbrace{\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  \\mu-\\lambda\\right)\r\n}_{\\substack{=0\\\\\\text{(since one of the factors of}\\\\\\text{this product is\r\n}\\mu-\\mu=0\\text{)}}}-\\left(  \\underbrace{\\mu^{q}}_{\\substack{=\\mu\r\n\\\\\\text{(since }\\mu\\in\\mathbb{F}_{q}\\text{)}}}-\\mu\\right)  =0-\\left(  \\mu\r\n-\\mu\\right)  =0.\r\n\\]\r\nIn other words, every $\\mu\\in\\mathbb{F}_{q}$ is a root of the polynomial\r\n$\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\right)  -\\left(\r\nX^{q}-X\\right)  $. Hence, the polynomial $\\prod_{\\lambda\\in\\mathbb{F}_{q}%\r\n}\\left(  X-\\lambda\\right)  -\\left(  X^{q}-X\\right)  $ has at least $q$ roots\r\n(since $\\mathbb{F}_{q}$ has at least $q$ elements).\r\n\\par\r\nBut $\\mathbb{F}_{q}$ is a field. Hence, any polynomial in $\\mathbb{F}%\r\n_{q}\\left[  X\\right]  $ whose degree is smaller than its number of roots must\r\nbe the zero polynomial. The polynomial $\\prod_{\\lambda\\in\\mathbb{F}_{q}%\r\n}\\left(  X-\\lambda\\right)  -\\left(  X^{q}-X\\right)  $ is such a polynomial\r\n(since its degree is $<q$, but it has at least $q$ roots), and thus must be\r\nthe zero polynomial. In other words, $\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(\r\nX-\\lambda\\right)  =\\left(  X^{q}-X\\right)  $. This proves\r\n(\\ref{pf.lem.mac1.Xq-X.X}).}.\r\n\r\nNow, consider the element $X/Y$ in the quotient field $\\mathbb{F}_{q}\\left(\r\nX,Y\\right)  $ of the ring $\\mathbb{F}_{q}\\left[  X,Y\\right]  $. Substituting\r\nthis element $X/Y$ for $X$ in (\\ref{pf.lem.mac1.Xq-X.X}), we obtain%\r\n\\[\r\n\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X/Y-\\lambda\\right)  =\\left(\r\nX/Y\\right)  ^{q}-X/Y.\r\n\\]\r\nMultiplying this equality by $Y^{q}$, we obtain%\r\n\\[\r\nY^{q}\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X/Y-\\lambda\\right)  =Y^{q}\\left(\r\n\\left(  X/Y\\right)  ^{q}-X/Y\\right)  =X^{q}-XY^{q-1}.\r\n\\]\r\nHence,\r\n\\begin{align*}\r\nX^{q}-XY^{q-1}  &  =Y^{q}\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(\r\nX/Y-\\lambda\\right)  =\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\underbrace{\\left(\r\nY\\left(  X/Y-\\lambda\\right)  \\right)  }_{=X-\\lambda Y}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left\\vert \\mathbb{F}_{q}\\right\\vert\r\n=q\\right) \\\\\r\n&  =\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda Y\\right)  .\r\n\\end{align*}\r\nThis proves Lemma \\ref{lem.mac1.Xq-X}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.mac1.dim1}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra. Let\r\n$V$ be a one-dimensional $\\mathbb{F}_{q}$-vector space. Let $\\varphi\r\n:V\\rightarrow A$ be an $\\mathbb{F}_{q}$-linear map. Let $e$ be a nonzero\r\nelement of $V$. Then, $f_{V,\\varphi}=X^{q}-\\left(  \\varphi\\left(  e\\right)\r\n\\right)  ^{q-1}X$.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.mac1.dim1}.]The element $-e$ of $V$ is nonzero (since\r\n$e$ is nonzero).\r\n\r\nThe $\\mathbb{F}_{q}$-vector space $V$ is one-dimensional, and thus any nonzero\r\nelement of $V$ forms a basis of $V$. Thus, $-e$ forms a basis of $V$ (since\r\n$-e$ is a nonzero element of $V$). In other words, the map $\\mathbb{F}%\r\n_{q}\\rightarrow V,\\ \\lambda\\mapsto\\lambda\\left(  -e\\right)  $ is a bijection.\r\nNow, the definition of $f_{V,\\varphi}$ yields%\r\n\\begin{align*}\r\nf_{V,\\varphi}  &  =\\prod_{v\\in V}\\left(  X+\\varphi\\left(  v\\right)  \\right)\r\n=\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X+\\varphi\\left(  \\underbrace{\\lambda\r\n\\left(  -e\\right)  }_{=-\\lambda e}\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\lambda\\left(  -e\\right)  \\text{ for }v\\text{\r\nin the product,}\\\\\r\n\\text{since the map }\\mathbb{F}_{q}\\rightarrow V,\\ \\lambda\\mapsto\r\n\\lambda\\left(  -e\\right)  \\text{ is a bijection}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X+\\underbrace{\\varphi\\left(\r\n-\\lambda e\\right)  }_{\\substack{=-\\lambda\\varphi\\left(  e\\right)\r\n\\\\\\text{(since }\\varphi\\text{ is }\\mathbb{F}_{q}\\text{-linear)}}}\\right)\r\n=\\prod_{\\lambda\\in\\mathbb{F}_{q}}\\left(  X-\\lambda\\varphi\\left(  e\\right)\r\n\\right) \\\\\r\n&  =X^{q}-X\\left(  \\varphi\\left(  e\\right)  \\right)  ^{q-1}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{this follows by substituting }\\varphi\\left(\r\ne\\right)  \\text{ for }Y\\text{ in (\\ref{eq.lem.mac1.Xq-X.eq})}\\right) \\\\\r\n&  =X^{q}-\\left(  \\varphi\\left(  e\\right)  \\right)  ^{q-1}X.\r\n\\end{align*}\r\nThis proves Lemma \\ref{lem.mac1.dim1}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.mac1.map}.]We shall prove Theorem\r\n\\ref{thm.mac1.map} by induction over $\\dim V$:\r\n\r\n\\textit{Induction base:} Theorem \\ref{thm.mac1.map} holds in the case when\r\n$\\dim V=0$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Consider the setting of Theorem\r\n\\ref{thm.mac1.map}, and assume that $\\dim V=0$. From $\\dim V=0$, we obtain\r\n$V=0$. The definition of $f_{V,\\varphi}$ yields%\r\n\\begin{align*}\r\nf_{V,\\varphi}  &  =\\prod_{v\\in V}\\left(  X+\\varphi\\left(  v\\right)  \\right)\r\n=X+\\underbrace{\\varphi\\left(  0\\right)  }_{\\substack{=0\\\\\\text{(since }%\r\n\\varphi\\text{ is }\\mathbb{F}_{q}\\text{-linear)}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }V=0\\right) \\\\\r\n&  =X.\r\n\\end{align*}\r\nThus, $f_{V,\\varphi}$ is a $q$-polynomial (since $X$ is a $q$-polynomial).\r\nThus, Theorem \\ref{thm.mac1.map} is proven in the case when $\\dim V=0$.}. This\r\ncompletes the induction base.\r\n\r\n\\textit{Induction step:} Let $N\\in\\mathbb{N}$. Assume (as the induction\r\nhypothesis) that Theorem \\ref{thm.mac1.map} holds in the case when $\\dim V=N$.\r\nWe need to show that Theorem \\ref{thm.mac1.map} holds in the case when $\\dim\r\nV=N+1$.\r\n\r\nConsider the setting of Theorem \\ref{thm.mac1.map}, and assume that $\\dim\r\nV=N+1$. Thus, $\\dim V=N+1>0$. Hence, $V$ contains a nonzero element $e$.\r\nConsider this $e$. Let $U$ be the $\\mathbb{F}_{q}$-vector subspace\r\n$\\mathbb{F}_{q}e$ of $V$; thus, $\\dim U=1$ (since $e$ is nonzero). Pick any\r\ncomplement $W$ to the subspace $U$ of $V$ (such a complement exists by one of\r\nthe basic theorems of linear algebra). Then, $W$ is an $\\mathbb{F}_{q}$-vector\r\nsubspace of $V$ satisfying $U\\oplus W=V$. We shall identify $V$ with the\r\n\\textbf{external} direct sum of $U$ and $W$ (that is, we shall identify each\r\nelement $v$ of $V$ with the unique pair $\\left(  u,w\\right)  \\in U\\times W$\r\nsatisfying $v=u+w$). Thus, the $\\mathbb{F}_{q}$-linear map $\\varphi\r\n:V\\rightarrow A$ can be regarded as an $\\mathbb{F}_{q}$-linear map\r\n$\\varphi:U\\oplus W\\rightarrow A$.\r\n\r\nDefine two $\\mathbb{F}_{q}$-linear maps $\\gamma:U\\rightarrow A$ and\r\n$\\psi:W\\rightarrow A$ by $\\gamma=\\varphi\\mid_{U}$ and $\\psi=\\varphi\\mid_{W}$.\r\nThen, the $\\mathbb{F}_{q}$-linear map $\\varphi:U\\oplus W\\rightarrow A$ sends\r\nevery $\\left(  v,w\\right)  \\in U\\oplus W$ to $\\gamma\\left(  v\\right)\r\n+\\psi\\left(  w\\right)  $\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $\\left(\r\nv,w\\right)  \\in U\\oplus W$. We must show that $\\varphi\\left(  v,w\\right)\r\n=\\gamma\\left(  v\\right)  +\\psi\\left(  w\\right)  $.\r\n\\par\r\nWe have $v\\in U$, and thus $\\gamma\\left(  v\\right)  =\\varphi\\left(  v\\right)\r\n$ (since $\\gamma=\\varphi\\mid_{U}$). We have $w\\in W$, and thus $\\psi\\left(\r\nw\\right)  =\\varphi\\left(  w\\right)  $ (since $\\psi=\\varphi\\mid_{W}$). The map\r\n$\\varphi$ is $\\mathbb{F}_{q}$-linear, and thus $\\varphi\\left(  v+w\\right)\r\n=\\underbrace{\\varphi\\left(  v\\right)  }_{=\\gamma\\left(  v\\right)\r\n}+\\underbrace{\\varphi\\left(  w\\right)  }_{=\\psi\\left(  w\\right)  }%\r\n=\\gamma\\left(  v\\right)  +\\psi\\left(  w\\right)  $. But recall that we are\r\nidentifying $\\left(  v,w\\right)  \\in U\\oplus W$ with $v+w\\in V$. Thus,\r\n$\\varphi\\left(  v,w\\right)  =\\varphi\\left(  v+w\\right)  =\\gamma\\left(\r\nv\\right)  +\\psi\\left(  w\\right)  $, qed.}.\r\n\r\nFrom $V=U\\oplus W$, we obtain $\\dim V=\\dim U+\\dim W$, so that $\\dim\r\nW=\\underbrace{\\dim V}_{=N+1}-\\underbrace{\\dim U}_{=1}=N+1-1=N$. Thus,\r\n(according to the induction hypothesis) Theorem \\ref{thm.mac1.map} can be\r\napplied to $W$ and $\\psi$ instead of $V$ and $\\varphi$. As a consequence, we\r\nobtain that $f_{W,\\psi}$ is a $q$-polynomial. In other words, $f_{W,\\psi}\\in\r\nA\\left[  X\\right]  _{q-\\operatorname*{lin}}$. Thus, Proposition\r\n\\ref{prop.q-pol.A-q-lin} (applied to $f=f_{W,\\psi}$ and $B=A$) shows that the\r\nmap $A\\rightarrow A,\\ b\\mapsto f_{W,\\psi}\\left(  b\\right)  $ is $\\mathbb{F}%\r\n_{q}$-linear. Let us denote this map by $h$. Thus, $h$ is the map\r\n$A\\rightarrow A,\\ b\\mapsto f_{W,\\psi}\\left(  b\\right)  $, and is\r\n$\\mathbb{F}_{q}$-linear. Every $a\\in A$ satisfies $h\\left(  a\\right)\r\n=f_{W,\\psi}\\left(  a\\right)  $ (by the definition of $h$).\r\n\r\nNow, Lemma \\ref{lem.mac1.too-early} (applied to $U$, $\\gamma$ and $\\varphi$\r\ninstead of $V$, $\\varphi$ and $\\chi$) shows that $f_{U\\oplus W,\\varphi\r\n}=f_{U,h\\circ\\gamma}\\circ f_{W,\\psi}$ in $A\\left[  X\\right]  $.\r\n\r\nBut the $\\mathbb{F}_{q}$-vector space $U$ is one-dimensional (since $\\dim\r\nU=1$) and contains the nonzero vector $e$ (since $U=\\mathbb{F}_{q}e\\supseteq\r\ne$). Thus, Lemma \\ref{lem.mac1.dim1} (applied to $U$ and $h\\circ\\gamma$\r\ninstead of $V$ and $\\varphi$) shows that $f_{U,h\\circ\\gamma}=X^{q}-\\left(\r\n\\left(  h\\circ\\gamma\\right)  \\left(  e\\right)  \\right)  ^{q-1}X$. This is\r\nclearly a $q$-polynomial (since $\\left(  \\left(  h\\circ\\gamma\\right)  \\left(\r\ne\\right)  \\right)  ^{q-1}$ is just a coefficient in $A$). In other words,\r\n$f_{U,h\\circ\\gamma}\\in A\\left[  X\\right]  _{q-\\operatorname*{lin}}$.\r\n\r\nProposition \\ref{prop.q-pol.comp.basics} \\textbf{(b)} shows that $A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$ is a submonoid of the monoid $\\left(\r\nA\\left[  X\\right]  ,\\circ\\right)  $. Hence, $A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is closed under the binary operation $\\circ$.\r\nTherefore, $f_{U,h\\circ\\gamma}\\circ f_{W,\\psi}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ (since $f_{U,h\\circ\\gamma}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ and $f_{W,\\psi}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$). But $V=U\\oplus W$, so that $f_{V,\\varphi\r\n}=f_{U\\oplus W,\\varphi}=f_{U,h\\circ\\gamma}\\circ f_{W,\\psi}\\in A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$. In other words, $f_{V,\\varphi}$ is a\r\n$q$-polynomial. Thus, Theorem \\ref{thm.mac1.map} is proven in the case when\r\n$\\dim V=N+1$. This completes the induction step.\r\n\r\nThe proof of Theorem \\ref{thm.mac1.map} is thus complete.\r\n\\end{proof}\r\n\r\nAs a consequence of Theorem \\ref{thm.mac1.map}, we can remove one unneeded\r\nassumption from Lemma \\ref{lem.mac1.too-early}:\r\n\r\n\\begin{corollary}\r\n\\label{cor.mac1.V+W}Let $A$ be a commutative $\\mathbb{F}_{q}$-algebra. Let $V$\r\nand $W$ be two $\\mathbb{F}_{q}$-vector spaces. Let $\\varphi:V\\rightarrow A$\r\nand $\\psi:W\\rightarrow A$ be two $\\mathbb{F}_{q}$-linear maps. Let\r\n$h:A\\rightarrow A$ be an $\\mathbb{F}_{q}$-linear map such that every $a\\in A$\r\nsatisfies $h\\left(  a\\right)  =f_{W,\\psi}\\left(  a\\right)  $. Let\r\n$\\chi:V\\oplus W\\rightarrow A$ be the $\\mathbb{F}_{q}$-linear map which sends\r\nevery $\\left(  v,w\\right)  \\in V\\oplus W$ to $\\varphi\\left(  v\\right)\r\n+\\psi\\left(  w\\right)  \\in A$. Then,%\r\n\\[\r\nf_{V\\oplus W,\\chi}=f_{V,h\\circ\\varphi}\\circ f_{W,\\psi}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in }A\\left[  X\\right]  .\r\n\\]\r\n\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.mac1.V+W}.]Theorem \\ref{thm.mac1.map} (applied to\r\n$W$ and $\\psi$ instead of $V$ and $\\varphi$) shows that $f_{W,\\psi}$ is a\r\n$q$-polynomial. Thus, Lemma \\ref{lem.mac1.too-early} shows that $f_{V\\oplus\r\nW,\\chi}=f_{V,h\\circ\\varphi}\\circ f_{W,\\psi}$ in $A\\left[  X\\right]  $. This\r\nproves Corollary \\ref{cor.mac1.V+W}.\r\n\\end{proof}\r\n\r\nLet us finally derive Theorem \\ref{thm.mac1.subspace} from Theorem\r\n\\ref{thm.mac1.map}:\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.mac1.subspace}.]Let $\\iota$ be the canonical\r\ninclusion map $V\\rightarrow A$. Thus, $\\iota$ is an $\\mathbb{F}_{q}$-linear\r\nmap. Hence, Theorem \\ref{thm.mac1.map} (applied to $\\varphi=\\iota$) shows that\r\n$f_{V,\\iota}$ is a $q$-polynomial. But the definition of $f_{V,\\iota}$ shows\r\nthat%\r\n\\[\r\nf_{V,\\iota}=\\prod_{v\\in V}\\left(  X+\\underbrace{\\iota\\left(  v\\right)\r\n}_{\\substack{=v\\\\\\text{(since }\\iota\\text{ is an}\\\\\\text{inclusion map)}%\r\n}}\\right)  =\\prod_{v\\in V}\\left(  X+v\\right)  =f_{V}%\r\n\\]\r\n(since this is how $f_{V}$ is defined). Thus, $f_{V}$ is a $q$-polynomial\r\n(since $f_{V,\\iota}$ is a $q$-polynomial). This proves Theorem\r\n\\ref{thm.mac1.subspace}.\r\n\\end{proof}\r\n\r\n\\subsection{Further consequences of the $\\operatorname*{Fqpol}$ isomorphism}\r\n\r\nLet us return to $\\mathcal{F}$. We shall now exploit the isomorphism\r\n$\\operatorname*{Fqpol}$ to obtain properties of $\\mathcal{F}$.\r\n\r\nFirst, let us recall that if $A$ is any commutative $\\mathbb{F}_{q}$-algebra,\r\nthen $A\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is an $A$-submodule of\r\n$A\\left[  X\\right]  $. Applying this to $A=\\mathbb{F}_{q}\\left[  T\\right]  $,\r\nwe see that\r\n\\begin{equation}\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}\\text{ is an }\\mathbb{F}_{q}\\left[  T\\right]  \\text{-submodule of }%\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  \\text{.}\r\n\\label{eq.q-pol.q-lin.leftT}%\r\n\\end{equation}\r\nWe shall write this $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on the\r\nleft (i.e., we use it to make $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$ into a left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module). This left $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure is given by plain multiplication inside $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  $. It has the following property:\r\n\r\n\\begin{proposition}\r\n\\label{prop.q-pol.Fqlin.leftT}The map $\\operatorname*{Fqpol}:\\mathcal{F}%\r\n\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is an isomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.q-pol.Fqlin.leftT}.]Proposition\r\n\\ref{prop.F.bases} \\textbf{(b)} says that the $\\mathbb{F}_{q}$-module\r\n$\\mathcal{F}$ is free with basis $\\left(  T^{j}F^{i}\\right)  _{i\\geq\r\n0,\\ j\\geq0}$.\r\n\r\nTheorem \\ref{thm.q-pol.=F} \\textbf{(b)} shows that $\\operatorname*{Fqpol}$ is\r\nan $\\mathbb{F}_{q}$-algebra isomorphism. Thus, it remains to prove that\r\n$\\operatorname*{Fqpol}$ is a homomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules. In other words, it remains to prove that\r\n$\\operatorname*{Fqpol}\\left(  fu\\right)  =f\\operatorname*{Fqpol}\\left(\r\nu\\right)  $ for every $f\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and\r\n$u\\in\\mathcal{F}$.\r\n\r\nSo let $f\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $u\\in\\mathcal{F}$. We need\r\nto prove the equality $\\operatorname*{Fqpol}\\left(  fu\\right)\r\n=f\\operatorname*{Fqpol}\\left(  u\\right)  $. This equality is $\\mathbb{F}_{q}%\r\n$-linear in $u$. Hence, we can WLOG assume that $u$ belongs to the basis\r\n$\\left(  T^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ of the $\\mathbb{F}_{q}$-module\r\n$\\mathcal{F}$. Assume this. Thus, $u=T^{j}F^{i}$ for some $i\\in\\mathbb{N}$ and\r\n$j\\in\\mathbb{N}$. Consider these $i$ and $j$.\r\n\r\nWe still need to prove the equality $\\operatorname*{Fqpol}\\left(  fu\\right)\r\n=f\\operatorname*{Fqpol}\\left(  u\\right)  $. This equality is $\\mathbb{F}_{q}%\r\n$-linear in $f$. Hence, we can WLOG assume that $f$ belongs to the basis\r\n$\\left(  T^{k}\\right)  _{k\\geq0}$ of the $\\mathbb{F}_{q}$-module\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Assume this. Thus, $f=T^{k}$ for some\r\n$k\\in\\mathbb{N}$. Consider this $k$.\r\n\r\nMultiplying the equalities $f=T^{k}$ and $u=T^{j}F^{i}$, we obtain\r\n$fu=\\underbrace{T^{k}T^{j}}_{=T^{k+j}}F^{i}=T^{k+j}F^{i}$. Hence,\r\n$\\operatorname*{Fqpol}\\left(  fu\\right)  =\\operatorname*{Fqpol}\\left(\r\nT^{k+j}F^{i}\\right)  =T^{k+j}X^{q^{i}}$ (by Theorem \\ref{thm.q-pol.=F}\r\n\\textbf{(c)}, applied to $k+j$ instead of $j$). On the other hand,\r\n$u=T^{j}F^{i}$, so that $\\operatorname*{Fqpol}\\left(  u\\right)\r\n=\\operatorname*{Fqpol}\\left(  T^{j}F^{i}\\right)  =T^{j}X^{q^{i}}$ (by Theorem\r\n\\ref{thm.q-pol.=F} \\textbf{(c)}). Multiplying the equalities $f=T^{k}$ and\r\n$\\operatorname*{Fqpol}\\left(  u\\right)  =T^{j}X^{q^{i}}$, we obtain\r\n$f\\operatorname*{Fqpol}\\left(  u\\right)  =\\underbrace{T^{k}T^{j}}_{=T^{k+j}%\r\n}X^{q^{i}}=T^{k+j}X^{q^{i}}$. Comparing this with $\\operatorname*{Fqpol}%\r\n\\left(  fu\\right)  =T^{k+j}X^{q^{i}}$, we obtain $\\operatorname*{Fqpol}\\left(\r\nfu\\right)  =f\\operatorname*{Fqpol}\\left(  u\\right)  $. As explained, this\r\ncompletes the proof of Proposition \\ref{prop.q-pol.Fqlin.leftT}.\r\n\\end{proof}\r\n\r\nNotice that we can use Proposition \\ref{prop.q-pol.Fqlin.leftT} to recover\r\nProposition \\ref{prop.F.bases} \\textbf{(c)}:\r\n\r\n\\begin{proof}\r\n[Second proof of Proposition \\ref{prop.F.bases} \\textbf{(c)}.]Proposition\r\n\\ref{prop.q-pol.Fqlin.leftT} yields that $\\mathcal{F}\\cong\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ as left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-modules, via the isomorphism\r\n$\\operatorname*{Fqpol}$. Since the left $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-module $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ has basis $\\left(  X^{q^{0}},X^{q^{1}},X^{q^{2}%\r\n},\\ldots\\right)  $, we can therefore conclude that the left $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module $\\mathcal{F}$ has basis $\\left(\r\n\\operatorname*{Fqpol}\\nolimits^{-1}\\left(  X^{q^{0}}\\right)\r\n,\\operatorname*{Fqpol}\\nolimits^{-1}\\left(  X^{q^{1}}\\right)\r\n,\\operatorname*{Fqpol}\\nolimits^{-1}\\left(  X^{q^{2}}\\right)  ,\\ldots\\right)\r\n$. Since $\\operatorname*{Fqpol}\\nolimits^{-1}\\left(  X^{q^{i}}\\right)  =F^{i}$\r\nfor every $i\\in\\mathbb{N}$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $i\\in\r\n\\mathbb{N}$. Theorem \\ref{thm.q-pol.=F} \\textbf{(c)} (applied to $j=0$) yields\r\n$\\operatorname*{Fqpol}\\left(  T^{0}F^{i}\\right)  =\\underbrace{T^{0}}%\r\n_{=1}X^{q^{i}}=X^{q^{i}}$. Thus, $\\operatorname*{Fqpol}\\nolimits^{-1}\\left(\r\nX^{q^{i}}\\right)  =\\underbrace{T^{0}}_{=1}F^{i}=F^{i}$, qed.}, this rewrites\r\nas follows: The left $\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\mathcal{F}$\r\nhas basis\\textbf{ }$\\left(  F^{i}\\right)  _{i\\geq0}$. This proves Proposition\r\n\\ref{prop.F.bases} \\textbf{(c)} again.\r\n\\end{proof}\r\n\r\nLet us make some more remarks (in less detail, since these will not be used in\r\nthe following):\r\n\r\nProposition \\ref{prop.q-pol.Fqlin.leftT} can be rewritten as follows: If we\r\ntransport the left $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on\r\n$\\mathcal{F}$ to $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ via the isomorphism $\\operatorname*{Fqpol}%\r\n:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$, then we obtain the left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module structure on $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$ constructed in (\\ref{eq.q-pol.q-lin.leftT}%\r\n). Of course, we can also use the isomorphism $\\operatorname*{Fqpol}$ to\r\ntransport all the other module structures from $\\mathcal{F}$ to $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ along\r\n$\\operatorname*{Fqpol}$. In more detail:\r\n\r\nFrom Proposition \\ref{prop.F.bases}, we know that $\\mathcal{F}$ is a left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module, a right $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module, a left $\\mathbb{F}_{q}\\left[  F\\right]  $-module, and a\r\nright $\\mathbb{F}_{q}\\left[  F\\right]  $-module. Thus, we have altogether four\r\nmodule structures on $\\mathcal{F}$. Using the isomorphism\r\n$\\operatorname*{Fqpol}:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}}$, we can transport them to\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$;\r\ntherefore, $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ becomes a left $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-module, a right $\\mathbb{F}_{q}\\left[  T\\right]  $-module, a left\r\n$\\mathbb{F}_{q}\\left[  F\\right]  $-module, and a right $\\mathbb{F}_{q}\\left[\r\nF\\right]  $-module. As we have already said, the first of these four module\r\nstructures is precisely the left $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure on $\\mathcal{F}$ constructed in (\\ref{eq.q-pol.q-lin.leftT}). The\r\nother three structures are new. Explicitly, two of them are characterized as follows:\r\n\r\n\\begin{itemize}\r\n\\item If $t\\in\\mathbb{F}_{q}\\left[  T\\right]  $, then the action of $t$ on the\r\nright $\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ sends every\r\n$m\\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}$ to $m\\circ\\underbrace{\\operatorname*{Fqpol}t}_{\\substack{=t\\cdot\r\nX\\\\\\text{(by Theorem \\ref{thm.q-pol.=F} \\textbf{(d)})}}}=m\\circ\\left(  t\\cdot\r\nX\\right)  =m\\left(  t\\cdot X\\right)  $ (that is, the result of substituting\r\n$t\\cdot X$ for $X$ in $m$).\r\n\r\n\\item If $f\\in\\mathbb{F}_{q}\\left[  F\\right]  $, then the action of $f$ on the\r\nleft $\\mathbb{F}_{q}\\left[  F\\right]  $-module $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ sends every\r\n$m\\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n}$ to $\\operatorname*{Fqpol}f\\circ m=f\\left(  \\operatorname*{Frob}%\r\n\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  }\\right)  \\circ\r\nm$.\r\n\\end{itemize}\r\n\r\n\\begin{noncompile}\r\n[This has been rather sketchy. More details would have been in order if I ever\r\nneed to use these other module structures.]\r\n\\end{noncompile}\r\n\r\n\\subsection{Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-modules}\r\n\r\nIn the following, \\textquotedblleft$\\mathcal{F}$-module\\textquotedblright%\r\n\\ will always mean \\textquotedblleft left $\\mathcal{F}$%\r\n-module\\textquotedblright, unless stated otherwise. The following fact is a\r\nsimple consequence of the definition of $\\mathcal{F}$ (specifically, of the\r\nfact that $\\mathcal{F}$ is generated by $F$ and $T$ as an $\\mathbb{F}_{q}$-algebra):\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.modhom}Let $M$ and $N$ be two $\\mathcal{F}$-modules. Let\r\n$f:M\\rightarrow N$ be an $\\mathbb{F}_{q}$-linear map. Assume that%\r\n\\[\r\nf\\left(  Tu\\right)  =Tf\\left(  u\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}u\\in M.\r\n\\]\r\nAssume also that%\r\n\\[\r\nf\\left(  Fu\\right)  =Ff\\left(  u\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}u\\in M.\r\n\\]\r\nThen, $f$ is an $\\mathcal{F}$-module homomorphism.\r\n\\end{lemma}\r\n\r\nThis lemma shall be used tacitly further below; it is the most reasonable way\r\nto prove that a certain map between two $\\mathcal{F}$-modules $M$ and $N$ is\r\nan $\\mathcal{F}$-module homomorphism, particularly in the case when the\r\n$\\mathcal{F}$-module structure on at least one of $M$ and $N$ is defined not\r\nexplicitly but by providing the actions of $F$ and $T$.\r\n\r\nPart of the interest in the $\\mathbb{F}_{q}$-algebra $\\mathcal{F}$ is due to\r\nits category of modules: it can be described as the category of\r\n\\textquotedblleft Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $%\r\n-modules\\textquotedblright, by which we mean $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-modules equipped with a \\textquotedblleft Frobenius map\\textquotedblright%\r\n\\ satisfying a certain rule. Let us define this in more detail:\r\n\r\n\\begin{definition}\r\n\\label{def.F.frobmod}\\textbf{(a)} A \\textit{Frobenius }$\\mathbb{F}_{q}\\left[\r\nT\\right]  $\\textit{-module} means a pair $\\left(  M,\\mathfrak{f}\\right)  $,\r\nwhere $M$ is an $\\mathbb{F}_{q}\\left[  T\\right]  $-module, and where\r\n$\\mathfrak{f}:M\\rightarrow M$ is an $\\mathbb{F}_{q}$-linear map satisfying%\r\n\\begin{equation}\r\n\\mathfrak{f}\\left(  Tm\\right)  =T^{q}\\mathfrak{f}\\left(  m\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in M. \\label{eq.def.F.frobmod.axiom}%\r\n\\end{equation}\r\nThis map $\\mathfrak{f}$ is called the \\textit{Frobenius map} of the Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\left(  M,\\mathfrak{f}\\right)  $.\r\nBy abuse of notation, we shall often speak of the \\textquotedblleft Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module $M$\\textquotedblright\\ instead of\r\nthe \\textquotedblleft Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\n$\\left(  M,\\mathfrak{f}\\right)  $\\textquotedblright, leaving the Frobenius map\r\n$\\mathfrak{f}$ implicit; in this situation, the Frobenius map $\\mathfrak{f}$\r\nwill be denoted by $\\mathfrak{f}_{M}$.\r\n\r\n\\textbf{(b)} Let $M$ and $N$ be two Frobenius $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-modules. Then, a map $h:M\\rightarrow N$ is said to be a \\textit{homomorphism\r\nof Frobenius }$\\mathbb{F}_{q}\\left[  T\\right]  $\\textit{-modules} if and only\r\nif it is $\\mathbb{F}_{q}\\left[  T\\right]  $-linear and \\textquotedblleft\r\nrespects the Frobenius maps\\textquotedblright\\ (i.e., satisfies $\\mathfrak{f}%\r\n_{N}\\circ h=h\\circ\\mathfrak{f}_{M}$).\r\n\r\n\\textbf{(c)} We let $\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[\r\nT\\right]  }$ denote the category whose objects are the Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-modules, and whose morphisms are the\r\nhomomorphisms of Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-modules.\r\n\\end{definition}\r\n\r\nIt turns out that this category $\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}%\r\n_{q}\\left[  T\\right]  }$ is isomorphic to the category of $\\mathcal{F}$-modules:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.frobmod.cateq}Let $\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$\r\nbe the category of all (left) $\\mathcal{F}$-modules.\r\n\r\nRecall that we are regarding the $\\mathbb{F}_{q}$-algebra homomorphism\r\n$\\operatorname*{Finc}\\nolimits_{T}:\\mathbb{F}_{q}\\left[  T\\right]\r\n\\rightarrow\\mathcal{F}$ as an inclusion. Thus, $\\mathbb{F}_{q}\\left[\r\nT\\right]  $ is an $\\mathbb{F}_{q}$-subalgebra of $\\mathcal{F}$.\r\n\r\n\\textbf{(a)} Let $M$ be a Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module.\r\nThen, there exists a unique $\\mathcal{F}$-module structure on $M$ which\r\nextends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on $M$ and\r\nsatisfies%\r\n\\[\r\nF\\cdot m=\\mathfrak{f}_{M}\\left(  m\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}m\\in M.\r\n\\]\r\n\r\n\r\n\\textbf{(b)} Let $N$ be an $\\mathcal{F}$-module. Then, $N$ becomes an\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module (since $\\mathbb{F}_{q}\\left[\r\nT\\right]  \\subseteq\\mathcal{F}$). Let $\\mathfrak{f}$ be the action of\r\n$F\\in\\mathcal{F}$ on $N$ (that is, the $\\mathbb{F}_{q}$-linear map\r\n$N\\rightarrow N,\\ n\\mapsto F\\cdot n$). Then, $\\left(  N,\\mathfrak{f}\\right)  $\r\nis a Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module.\r\n\r\n\\textbf{(c)} Proposition \\ref{prop.F.frobmod.cateq} \\textbf{(a)} defines a\r\nfunctor from $\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[\r\nT\\right]  }$ to $\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$ (because, to any\r\nFrobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module $M$, it assigns an\r\n$\\mathcal{F}$-module structure on $M$, and this assignment can easily be\r\nextended to morphisms). Proposition \\ref{prop.F.frobmod.cateq} \\textbf{(b)}\r\ndefines a functor from $\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$ to\r\n$\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$\r\n(because, to any $\\mathcal{F}$-module $N$, it assigns a Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\left(  N,\\mathfrak{f}\\right)  $,\r\nand this assignment can easily be extended to morphisms). These two functors\r\nare mutually inverse. Thus, the categories $\\operatorname*{FrobMod}%\r\n\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$ and $\\operatorname*{Mod}%\r\n\\nolimits_{\\mathcal{F}}$ are isomorphic.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.frobmod.cateq}.]\\textbf{(a)} We let\r\n$\\operatorname*{End}M$ denote the $\\mathbb{F}_{q}$-algebra of all\r\n$\\mathbb{F}_{q}$-module endomorphisms of $M$.\r\n\r\nIt is clear that there exists \\textbf{at most one} $\\mathcal{F}$-module\r\nstructure on $M$ which extends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure on $M$ and satisfies%\r\n\\begin{equation}\r\nF\\cdot m=\\mathfrak{f}_{M}\\left(  m\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}m\\in M \\label{pf.prop.F.frobmod.cateq.a.want}%\r\n\\end{equation}\r\n\\footnote{Indeed, the requirement that this structure extends the\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on $M$ uniquely determines\r\nhow $T$ acts on $M$. Meanwhile, the requirement\r\n(\\ref{pf.prop.F.frobmod.cateq.a.want}) uniquely determines how $F$ acts on\r\n$M$. Thus, the actions of both $T$ and $F$ on $M$ are uniquely determined. But\r\ntherefore, the action of any element of $\\mathcal{F}$ on $M$ is uniquely\r\ndetermined as well (since the $\\mathbb{F}_{q}$-algebra $\\mathcal{F}$ is\r\ngenerated by $T$ and $F$); in other words, the $\\mathcal{F}$-module structure\r\non $M$ is uniquely determined, qed.}. It thus remains to prove that there\r\nexists \\textbf{at least one} such structure. So let us construct such a structure.\r\n\r\nAs usual, we abbreviate $\\mathfrak{f}_{M}$ as $\\mathfrak{f}$.\r\n\r\nLet $\\mathfrak{t}$ be the $\\mathbb{F}_{q}$-linear map $M\\rightarrow\r\nM,\\ m\\mapsto T\\cdot m$. Then, for every $n\\in\\mathbb{N}$ and $m\\in M$, we have%\r\n\\begin{equation}\r\n\\mathfrak{t}^{n}\\left(  m\\right)  =T^{n}\\cdot m.\r\n\\label{pf.prop.F.frobmod.cateq.a.1}%\r\n\\end{equation}\r\n(This is easy to prove by induction over $n$.)\r\n\r\nFor every $m\\in M$, we have%\r\n\\begin{align*}\r\n\\left(  \\mathfrak{f}\\circ\\mathfrak{t}\\right)  \\left(  m\\right)   &\r\n=\\mathfrak{f}\\left(  \\underbrace{\\mathfrak{t}\\left(  m\\right)  }%\r\n_{\\substack{=T\\cdot m\\\\\\text{(by the definition of }\\mathfrak{t}\\text{)}%\r\n}}\\right)  =\\mathfrak{f}\\left(  T\\cdot m\\right)  =\\mathfrak{f}\\left(\r\nTm\\right)  =T^{q}\\mathfrak{f}\\left(  m\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{eq.def.F.frobmod.axiom})}\\right) \\\\\r\n&  =\\mathfrak{t}^{q}\\left(  \\mathfrak{f}\\left(  m\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because (\\ref{pf.prop.F.frobmod.cateq.a.1}) (applied to }q\\text{ and\r\n}\\mathfrak{f}\\left(  m\\right)  \\text{ instead of }n\\text{ and }m\\text{)}\\\\\r\n\\text{shows that }\\mathfrak{t}^{q}\\left(  \\mathfrak{f}\\left(  m\\right)\r\n\\right)  =T^{q}\\cdot\\mathfrak{f}\\left(  m\\right)  =T^{q}\\mathfrak{f}\\left(\r\nm\\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\left(  \\mathfrak{t}^{q}\\circ\\mathfrak{f}\\right)  \\left(  m\\right)  .\r\n\\end{align*}\r\nHence, $\\mathfrak{f}\\circ\\mathfrak{t}=\\mathfrak{t}^{q}\\circ\\mathfrak{f}$.\r\n\r\nNow, recall the universal property of $\\mathcal{F}$: If $u$ and $v$ are two\r\nelements of an $\\mathbb{F}_{q}$-algebra $\\mathcal{U}$ satisfying $uv=v^{q}u$,\r\nthen there exists a unique $\\mathbb{F}_{q}$-algebra homomorphism\r\n$\\mathcal{F}\\rightarrow\\mathcal{U}$ sending $F$ and $T$ to $u$ and $v$,\r\nrespectively. Applying this to $\\mathcal{U}=\\operatorname*{End}M$,\r\n$u=\\mathfrak{f}$ and $v=\\mathfrak{t}$, we conclude that there exists a unique\r\n$\\mathbb{F}_{q}$-algebra homomorphism $\\mathcal{F}\\rightarrow\r\n\\operatorname*{End}M$ sending $F$ and $T$ to $\\mathfrak{f}$ and $\\mathfrak{t}%\r\n$, respectively. Let $\\Phi$ be this homomorphism. The definition of $\\Phi$\r\nshows that $\\Phi\\left(  F\\right)  =\\mathfrak{f}$ and $\\Phi\\left(  T\\right)\r\n=\\mathfrak{t}$.\r\n\r\nWe have\r\n\\begin{equation}\r\n\\left(  \\Phi\\left(  f\\right)  \\right)  \\left(  m\\right)  =f\\cdot\r\nm\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }f\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n\\text{ and }m\\in M \\label{pf.prop.F.frobmod.cateq.a.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.F.frobmod.cateq.a.1}):} Let\r\n$f\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $m\\in M$. We have to prove the\r\nequality $\\left(  \\Phi\\left(  f\\right)  \\right)  \\left(  m\\right)  =f\\cdot m$.\r\nThis equality is $\\mathbb{F}_{q}$-linear in $f$; we can therefore WLOG assume\r\nthat $f$ belongs to the basis $\\left(  T^{n}\\right)  _{n\\geq0}$ of the\r\n$\\mathbb{F}_{q}$-module $\\mathbb{F}_{q}\\left[  T\\right]  $. Assume this.\r\nHence, $f=T^{n}$ for some $n\\in\\mathbb{N}$. Consider this $n$. From $f=T^{n}$,\r\nwe obtain $\\Phi\\left(  f\\right)  =\\Phi\\left(  T^{n}\\right)  =\\left(\r\n\\Phi\\left(  T\\right)  \\right)  ^{n}$ (since $\\Phi$ is an $\\mathbb{F}_{q}%\r\n$-algebra homomorphism). Since $\\Phi\\left(  T\\right)  =\\mathfrak{t}$, this\r\nrewrites as $\\Phi\\left(  f\\right)  =\\mathfrak{t}^{n}$. Therefore,\r\n$\\underbrace{\\left(  \\Phi\\left(  f\\right)  \\right)  }_{=\\mathfrak{t}^{n}%\r\n}\\left(  m\\right)  =\\mathfrak{t}^{n}\\left(  m\\right)  =T^{n}\\cdot m$ (by\r\n(\\ref{pf.prop.F.frobmod.cateq.a.1})). Hence, $\\left(  \\Phi\\left(  f\\right)\r\n\\right)  \\left(  m\\right)  =\\underbrace{T^{n}}_{=f}\\cdot m=f\\cdot m$. This\r\nproves (\\ref{pf.prop.F.frobmod.cateq.a.1}).}. Thus, the $\\mathcal{F}$-module\r\nstructure on $M$ obtained from the map $\\Phi:\\mathcal{F}\\rightarrow\r\n\\operatorname*{End}M$ extends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure on $M$.\r\n\r\nFurthermore, $\\underbrace{\\left(  \\Phi\\left(  F\\right)  \\right)\r\n}_{=\\mathfrak{f}=\\mathfrak{f}_{M}}\\left(  m\\right)  =\\mathfrak{f}_{M}\\left(\r\nm\\right)  $ for every $m\\in M$. Thus, the $\\mathcal{F}$-module structure on\r\n$M$ obtained from the map $\\Phi:\\mathcal{F}\\rightarrow\\operatorname*{End}M$\r\nsatisfies (\\ref{pf.prop.F.frobmod.cateq.a.want}).\r\n\r\nHence, there exists at least one $\\mathcal{F}$-module structure on $M$ which\r\nextends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on $M$ and\r\nsatisfies (\\ref{pf.prop.F.frobmod.cateq.a.want}) (namely, the $\\mathcal{F}%\r\n$-module structure on $M$ obtained from the map $\\Phi:\\mathcal{F}%\r\n\\rightarrow\\operatorname*{End}M$). This completes the proof of Proposition\r\n\\ref{prop.F.frobmod.cateq} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We need to show that $\\left(  N,\\mathfrak{f}\\right)  $ is a\r\nFrobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module. In other words, we need\r\nto show that $N$ is an $\\mathbb{F}_{q}\\left[  T\\right]  $-module, that\r\n$\\mathfrak{f}:N\\rightarrow N$ is an $\\mathbb{F}_{q}$-linear map, and that this\r\nmap $\\mathfrak{f}$ satisfies%\r\n\\begin{equation}\r\n\\mathfrak{f}\\left(  Tm\\right)  =T^{q}\\mathfrak{f}\\left(  m\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in N.\r\n\\label{pf.prop.F.frobmod.cateq.b.want}%\r\n\\end{equation}\r\n\r\n\r\nThe first two of these statements are obvious. It thus remains to prove the\r\nthird statement, i.e., to prove that the map $\\mathfrak{f}$ satisfies\r\n(\\ref{pf.prop.F.frobmod.cateq.b.want}).\r\n\r\nSo let $m\\in N$. The definition of $\\mathfrak{f}$ yields $\\mathfrak{f}\\left(\r\nm\\right)  =Fm$ and $\\mathfrak{f}\\left(  Tm\\right)  =F\\cdot Tm=\\underbrace{FT}%\r\n_{=T^{q}F}m=T^{q}\\underbrace{Fm}_{=\\mathfrak{f}\\left(  m\\right)  }%\r\n=T^{q}\\mathfrak{f}\\left(  m\\right)  $. Thus,\r\n(\\ref{pf.prop.F.frobmod.cateq.b.want}) is proven. As we have already\r\nexplained, this completes the proof of Proposition \\ref{prop.F.frobmod.cateq}\r\n\\textbf{(b)}.\r\n\r\n\\textbf{(c)} It is clear that if we apply the functor $\\operatorname*{FrobMod}%\r\n\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }\\rightarrow\\operatorname*{Mod}%\r\n\\nolimits_{\\mathcal{F}}$ first and then the functor $\\operatorname*{Mod}%\r\n\\nolimits_{\\mathcal{F}}\\rightarrow\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}%\r\n_{q}\\left[  T\\right]  }$, then we get back to where we started. It is somewhat\r\nless obvious, but still easy, to prove that if we apply the functor\r\n$\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}\\rightarrow\\operatorname*{FrobMod}%\r\n\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$ first and then the functor\r\n$\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]\r\n}\\rightarrow\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$, then we get back to\r\nwhere we started\\footnote{In order to prove this, it suffices to observe that\r\nan $\\mathcal{F}$-module structure on a given $\\mathbb{F}_{q}$-vector space is\r\nuniquely determined by the actions of $F$ and $T$ (because the $\\mathbb{F}%\r\n_{q}$-algebra $\\mathcal{F}$ is generated by $F$ and $T$).}. Thus, the functors\r\n$\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]\r\n}\\rightarrow\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$ and\r\n$\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}\\rightarrow\\operatorname*{FrobMod}%\r\n\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$ are mutually inverse. This\r\nproves Proposition \\ref{prop.F.frobmod.cateq} \\textbf{(c)}.\r\n\\end{proof}\r\n\r\nAn ample supply of Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-modules (and\r\nthus, $\\mathcal{F}$-module) is given by commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebras and their Frobenius homomorphisms:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.frobmod.alg}\\textbf{(a)} If $A$ is a commutative $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-algebra, then $\\left(  A,\\operatorname*{Frob}%\r\n\\nolimits_{A}\\right)  $ is a Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module.\r\n\r\n\\textbf{(b)} If $A$ and $B$ are two commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebras, and if $f:A\\rightarrow B$ is an $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra homomorphism, then $f$ is also a homomorphism of Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-modules from $\\left(\r\nA,\\operatorname*{Frob}\\nolimits_{A}\\right)  $ to $\\left(\r\nB,\\operatorname*{Frob}\\nolimits_{B}\\right)  $.\r\n\r\n\\textbf{(c)} Proposition \\ref{prop.F.frobmod.alg} \\textbf{(a)} assigns a\r\nFrobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\left(\r\nA,\\operatorname*{Frob}\\nolimits_{A}\\right)  $ to each commutative\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$. This defines a functor from\r\nthe category of commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebras to the\r\ncategory $\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }$\r\nof Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-modules (the action of this\r\nfunctor on morphisms just leaves morphisms unchanged), and thus to the\r\ncategory $\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$ of $\\mathcal{F}$-modules\r\n(because Proposition \\ref{prop.F.frobmod.cateq} \\textbf{(c)} shows that\r\n$\\operatorname*{FrobMod}\\nolimits_{\\mathbb{F}_{q}\\left[  T\\right]  }%\r\n\\cong\\operatorname*{Mod}\\nolimits_{\\mathcal{F}}$). Explicitly, this shows that\r\nevery commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$ canonically\r\nbecomes an $\\mathcal{F}$-module, and this $\\mathcal{F}$-module structure\r\nextends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on $A$ and has\r\nthe property that\r\n\\[\r\nF\\cdot m=\\operatorname*{Frob}\\nolimits_{A}\\left(  m\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in A.\r\n\\]\r\n\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.frobmod.alg}.]\\textbf{(a)} Let $A$ be a\r\ncommutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra. As we know,\r\n$\\operatorname*{Frob}\\nolimits_{A}:A\\rightarrow A$ is an $\\mathbb{F}_{q}%\r\n$-algebra homomorphism, and thus an $\\mathbb{F}_{q}$-linear map. Furthermore,\r\nit satisfies%\r\n\\[\r\n\\operatorname*{Frob}\\nolimits_{A}\\left(  Tm\\right)  =T^{q}\\operatorname*{Frob}%\r\n\\nolimits_{A}\\left(  m\\right)\r\n\\]\r\nfor every $m\\in A$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $m\\in A$. Then, the\r\ndefinition of $\\operatorname*{Frob}\\nolimits_{A}$ shows that\r\n$\\operatorname*{Frob}\\nolimits_{A}\\left(  m\\right)  =m^{q}$ and\r\n$\\operatorname*{Frob}\\nolimits_{A}\\left(  Tm\\right)  =\\left(  Tm\\right)\r\n^{q}=T^{q}\\underbrace{m^{q}}_{=\\operatorname*{Frob}\\nolimits_{A}\\left(\r\nm\\right)  }=T^{q}\\operatorname*{Frob}\\nolimits_{A}\\left(  m\\right)  $, qed.}.\r\nHence, $\\left(  A,\\operatorname*{Frob}\\nolimits_{A}\\right)  $ is a Frobenius\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module (by the definition of a\r\n\\textquotedblleft Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $%\r\n-module\\textquotedblright). This proves Proposition \\ref{prop.F.frobmod.alg}\r\n\\textbf{(a)}.\r\n\r\n\\textbf{(b)} The proof of Proposition \\ref{prop.F.frobmod.alg} \\textbf{(b)} is straightforward.\r\n\r\n\\textbf{(c)} Proposition \\ref{prop.F.frobmod.alg} \\textbf{(c)} follows from\r\nwhat we have proven above. (Specifically, the statement that the $\\mathcal{F}%\r\n$-module structure on $A$ extends the $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-module structure on $A$ and has the property that\r\n\\[\r\nF\\cdot m=\\operatorname*{Frob}\\nolimits_{A}\\left(  m\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in A\r\n\\]\r\nis a consequence of Proposition \\ref{prop.F.frobmod.cateq} \\textbf{(a)}.)\r\n\\end{proof}\r\n\r\nRestricted Lie algebras (see, e.g., \\cite{jacobson-rl}) can be used as another\r\nsource of Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-modules, provided they\r\ncan be equipped with an appropriate $\\mathbb{F}_{q}\\left[  T\\right]  $-module\r\nstructure. We are not currently aware of specific examples of interest, however.\r\n\r\n\\begin{condition}\r\n\\label{conv.F.acts-on-commalg}Let $A$ be a commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra. Then, $\\left(  A,\\operatorname*{Frob}\\nolimits_{A}%\r\n\\right)  $ is a Frobenius $\\mathbb{F}_{q}\\left[  T\\right]  $-module (by\r\nProposition \\ref{prop.F.frobmod.alg} \\textbf{(a)}), and thus Proposition\r\n\\ref{prop.F.frobmod.cateq} \\textbf{(a)} (applied to $M=A$) defines an\r\n$\\mathcal{F}$-module structure on $A$. In the following, we shall always\r\nregard a commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra $A$ as\r\nequipped with this $\\mathcal{F}$-module structure by default. This structure\r\nextends the $\\mathbb{F}_{q}\\left[  T\\right]  $-module structure on $A$, and\r\nsatisfies%\r\n\\begin{equation}\r\nF\\cdot m=\\operatorname*{Frob}\\nolimits_{A}\\left(  m\\right)  =m^{q}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\operatorname*{Frob}%\r\n\\nolimits_{A}\\right)  \\label{eq.conv.F.acts-on-commalg.F}%\r\n\\end{equation}\r\nfor every $m\\in A$.\r\n\\end{condition}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.acts-on-commalg.Fk}Let $A$ be a commutative $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-algebra. Then, $A$ is an $\\mathcal{F}$-module\r\n(according to Convention \\ref{conv.F.acts-on-commalg}). This $\\mathcal{F}%\r\n$-module structure has the following property: For every $k\\in\\mathbb{N}$ and\r\n$m\\in A$, we have%\r\n\\begin{equation}\r\nF^{k}\\cdot m=m^{q^{k}}. \\label{eq.prop.F.acts-on-commalg.Fk.eq}%\r\n\\end{equation}\r\n\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.acts-on-commalg.Fk}.]Only\r\n(\\ref{eq.prop.F.acts-on-commalg.Fk.eq}) needs to be proven.\r\n\r\nFrom (\\ref{eq.conv.F.acts-on-commalg.F}), we know that%\r\n\\begin{equation}\r\nF\\cdot m=m^{q}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in A.\r\n\\label{pf.prop.F.acts-on-commalg.Fk.1}%\r\n\\end{equation}\r\nThus,%\r\n\\begin{equation}\r\nF^{k}\\cdot m=m^{q^{k}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }m\\in A\\text{ and\r\n}k\\in\\mathbb{N}. \\label{pf.prop.F.acts-on-commalg.Fk.2}%\r\n\\end{equation}\r\n(Indeed, (\\ref{pf.prop.F.acts-on-commalg.Fk.2}) can be proven by a\r\nstraightforward induction over $k$; the induction step will rely on\r\n(\\ref{pf.prop.F.acts-on-commalg.Fk.1}). The details of this proof are left to\r\nthe reader.)\r\n\r\nSo we know that (\\ref{pf.prop.F.acts-on-commalg.Fk.2}) holds. In other words,\r\n(\\ref{eq.prop.F.acts-on-commalg.Fk.eq}) holds. This proves Proposition\r\n\\ref{prop.F.acts-on-commalg.Fk}.\r\n\\end{proof}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.Fqpol.Fmodhom}The commutative $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebra $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ becomes an\r\n$\\mathcal{F}$-module (by Convention \\ref{conv.F.acts-on-commalg}, applied to\r\n$A=\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $). Let $\\overline\r\n{\\operatorname*{Fqpol}}$ denote the map $\\operatorname*{Fqpol}:\\mathcal{F}%\r\n\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$, considered as a map $\\mathcal{F}\\rightarrow\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ (this is well-defined\r\nbecause $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}\\subseteq\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $). Then, this map $\\overline{\\operatorname*{Fqpol}}:\\mathcal{F}%\r\n\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ is an\r\n$\\mathcal{F}$-module homomorphism.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.Fqpol.Fmodhom}.]Proposition\r\n\\ref{prop.q-pol.Fqlin.leftT} shows that the map $\\operatorname*{Fqpol}%\r\n:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ is an isomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules. Thus, the map $\\overline{\\operatorname*{Fqpol}%\r\n}:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $\r\n(which differs from $\\operatorname*{Fqpol}:\\mathcal{F}\\rightarrow\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$\r\nonly in its target) is also a homomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules. In other words, $\\overline{\\operatorname*{Fqpol}}\\left(\r\nfu\\right)  =f\\overline{\\operatorname*{Fqpol}}\\left(  u\\right)  $ for every\r\n$f\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $u\\in\\mathcal{F}$. Applying this to\r\n$f=T$, we obtain%\r\n\\begin{equation}\r\n\\overline{\\operatorname*{Fqpol}}\\left(  Tu\\right)  =T\\overline\r\n{\\operatorname*{Fqpol}}\\left(  u\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}u\\in\\mathcal{F}. \\label{pf.prop.F.Fqpol.Fmodhom.1}%\r\n\\end{equation}\r\n\r\n\r\nOn the other hand, let $u\\in\\mathcal{F}$. Then,%\r\n\\begin{align*}\r\n&  \\overline{\\operatorname*{Fqpol}}\\left(  Fu\\right) \\\\\r\n&  =\\operatorname*{Fqpol}\\left(  Fu\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by the definition of }\\overline{\\operatorname*{Fqpol}}\\right) \\\\\r\n&  =\\underbrace{\\left(  \\operatorname*{Fqpol}\\left(  F\\right)  \\right)\r\n}_{=X^{q}}\\circ\\left(  \\operatorname*{Fqpol}\\left(  u\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{Fqpol}\\text{ is an\r\n}\\mathbb{F}_{q}\\text{-algebra homomorphism }\\mathcal{F}\\rightarrow\\left(\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}%\r\n},+,\\circ\\right)  \\right) \\\\\r\n&  =X^{q}\\circ\\left(  \\operatorname*{Fqpol}\\left(  u\\right)  \\right)  =\\left(\r\n\\operatorname*{Fqpol}\\left(  u\\right)  \\right)  ^{q}.\r\n\\end{align*}\r\nComparing this with%\r\n\\begin{align*}\r\nF\\overline{\\operatorname*{Fqpol}}\\left(  u\\right)   &  =F\\cdot\\overline\r\n{\\operatorname*{Fqpol}}\\left(  u\\right)  =\\left(  \\underbrace{\\overline\r\n{\\operatorname*{Fqpol}}\\left(  u\\right)  }_{\\substack{=\\operatorname*{Fqpol}%\r\n\\left(  u\\right)  \\\\\\text{(by the definition of }\\overline\r\n{\\operatorname*{Fqpol}}\\text{)}}}\\right)  ^{q}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{eq.conv.F.acts-on-commalg.F}),\r\napplied to }A=\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  \\text{ and\r\n}m=\\overline{\\operatorname*{Fqpol}}\\left(  u\\right)  \\right) \\\\\r\n&  =\\left(  \\operatorname*{Fqpol}\\left(  u\\right)  \\right)  ^{q},\r\n\\end{align*}\r\nwe obtain $\\overline{\\operatorname*{Fqpol}}\\left(  Fu\\right)  =F\\overline\r\n{\\operatorname*{Fqpol}}\\left(  u\\right)  $. Let us now forget that we fixed\r\n$u$. We thus have shown that\r\n\\begin{equation}\r\n\\overline{\\operatorname*{Fqpol}}\\left(  Fu\\right)  =F\\overline\r\n{\\operatorname*{Fqpol}}\\left(  u\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}u\\in\\mathcal{F}. \\label{pf.prop.F.Fqpol.Fmodhom.2}%\r\n\\end{equation}\r\nNow, Lemma \\ref{lem.F.modhom} (applied to $M=\\mathcal{F}$, $N=\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  $ and $f=\\overline\r\n{\\operatorname*{Fqpol}}$) shows that $\\overline{\\operatorname*{Fqpol}}$ is an\r\n$\\mathcal{F}$-module homomorphism (because of (\\ref{pf.prop.F.Fqpol.Fmodhom.1}%\r\n) and (\\ref{pf.prop.F.Fqpol.Fmodhom.2})). This proves Proposition\r\n\\ref{prop.F.Fqpol.Fmodhom}.\r\n\\end{proof}\r\n\r\n\\subsection{The Carlitz action}\r\n\r\nNow, let us recall the Carlitz polynomials $\\left[  M\\right]  $ defined in\r\nDefinition \\ref{def.carlitzpoly}. We can connect these polynomials to\r\n$\\mathcal{F}$ in the following way\\footnote{Recall that $\\operatorname*{Carl}$\r\nis the $\\mathbb{F}_{q}$-algebra homomorphism $\\mathbb{F}_{q}\\left[  T\\right]\r\n\\rightarrow\\mathcal{F}$ sending $T$ to $F+T$.}:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.carlitz}Let $A$ be a commutative $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-algebra. Thus, $A$ becomes an $\\mathcal{F}$-module (by Convention\r\n\\ref{conv.F.acts-on-commalg}).\r\n\r\nFor every $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $a\\in A$, we have\r\n$\\left[  M\\right]  \\left(  a\\right)  =\\left(  \\operatorname*{Carl}M\\right)\r\n\\cdot a$. (Here, the $\\left[  M\\right]  \\left(  a\\right)  $ on the left hand\r\nside means the result of substituting $a$ for $X$ in the polynomial $\\left[\r\nM\\right]  \\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $, whereas the\r\n$\\left(  \\operatorname*{Carl}M\\right)  \\cdot a$ on the right hand side denotes\r\nthe action of $\\operatorname*{Carl}M\\in\\mathcal{F}$ on $a\\in A$.)\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.carlitz}.]We first claim that%\r\n\\begin{equation}\r\n\\left[  T^{n}\\right]  \\left(  a\\right)  =\\left(  F+T\\right)  ^{n}%\r\na\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}\\text{ and }a\\in A.\r\n\\label{pf.prop.F.carlitz.1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.prop.F.carlitz.1}):} We shall prove\r\n(\\ref{pf.prop.F.carlitz.1}) by induction over $n$:\r\n\r\n\\textit{Induction base:} We have $\\left[  T^{0}\\right]  =X$, thus $\\left[\r\nT^{0}\\right]  \\left(  a\\right)  =X\\left(  a\\right)  =a$. Comparing this with\r\n$\\underbrace{\\left(  F+T\\right)  ^{0}}_{=1}a=a$, we obtain $\\left[\r\nT^{0}\\right]  \\left(  a\\right)  =\\left(  F+T\\right)  ^{0}a$. In other words,\r\n(\\ref{pf.prop.F.carlitz.1}) holds for $n=0$. This completes the induction base.\r\n\r\n\\textit{Induction step:} Fix a positive integer $N$. Assume that\r\n(\\ref{pf.prop.F.carlitz.1}) holds for $n=N-1$. We now need to show that\r\n(\\ref{pf.prop.F.carlitz.1}) holds for $n=N$.\r\n\r\nWe have assumed that (\\ref{pf.prop.F.carlitz.1}) holds for $n=N-1$. In other\r\nwords, we have%\r\n\\begin{equation}\r\n\\left[  T^{N-1}\\right]  \\left(  a\\right)  =\\left(  F+T\\right)  ^{N-1}%\r\na\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }a\\in A. \\label{pf.prop.F.carlitz.1.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, fix $a\\in A$. Applying (\\ref{eq.conv.F.acts-on-commalg.F}) to $m=\\left[\r\nT^{N-1}\\right]  \\left(  a\\right)  $, we obtain%\r\n\\begin{equation}\r\nF\\cdot\\left[  T^{N-1}\\right]  \\left(  a\\right)  =\\left(  \\left[\r\nT^{N-1}\\right]  \\left(  a\\right)  \\right)  ^{q}.\r\n\\label{pf.prop.F.carlitz.1.pf.2}%\r\n\\end{equation}\r\n\r\n\r\nThe recursive definition of $\\left[  T^{N}\\right]  $ yields $\\left[\r\nT^{N}\\right]  =\\left[  T^{N-1}\\right]  ^{q}+T\\left[  T^{N-1}\\right]  $. Hence,%\r\n\\begin{align*}\r\n\\left[  T^{N}\\right]  \\left(  a\\right)   &  =\\left(  \\left[  T^{N-1}\\right]\r\n^{q}+T\\left[  T^{N-1}\\right]  \\right)  \\left(  a\\right)  =\\underbrace{\\left(\r\n\\left[  T^{N-1}\\right]  \\left(  a\\right)  \\right)  ^{q}}_{=F\\cdot\\left[\r\nT^{N-1}\\right]  \\left(  a\\right)  }+T\\left[  T^{N-1}\\right]  \\left(  a\\right)\r\n\\\\\r\n&  =F\\cdot\\left[  T^{N-1}\\right]  \\left(  a\\right)  +T\\cdot\\left[\r\nT^{N-1}\\right]  \\left(  a\\right)  =\\left(  F+T\\right)  \\underbrace{\\left[\r\nT^{N-1}\\right]  \\left(  a\\right)  }_{\\substack{=\\left(  F+T\\right)\r\n^{N-1}a\\\\\\text{(by (\\ref{pf.prop.F.carlitz.1.pf.1}))}}}\\\\\r\n&  =\\underbrace{\\left(  F+T\\right)  \\left(  F+T\\right)  ^{N-1}}_{=\\left(\r\nF+T\\right)  ^{N}}a=\\left(  F+T\\right)  ^{N}a.\r\n\\end{align*}\r\nNow, let us forget that we fixed $a$. We thus have shown that $\\left[\r\nT^{N}\\right]  \\left(  a\\right)  =\\left(  F+T\\right)  ^{N}a$ for every $a\\in\r\nA$. In other words, (\\ref{pf.prop.F.carlitz.1}) holds for $n=N$. This\r\ncompletes the induction step, and thus (\\ref{pf.prop.F.carlitz.1}) is proven.\r\n\r\nNow, let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and $a\\in A$. Write the\r\npolynomial $M$ in the form $M=a_{0}T^{0}+a_{1}T^{1}+\\cdots+a_{k}T^{k}$ for\r\nsome $k\\in\\mathbb{N}$ and $a_{0},a_{1},\\ldots,a_{k}\\in\\mathbb{F}_{q}$. Thus,%\r\n\\[\r\nM=a_{0}T^{0}+a_{1}T^{1}+\\cdots+a_{k}T^{k}=\\sum_{n=0}^{k}a_{n}T^{n}.\r\n\\]\r\nThe definition of $\\left[  M\\right]  $ now yields\r\n\\[\r\n\\left[  M\\right]  =a_{0}\\left[  T^{0}\\right]  +a_{1}\\left[  T^{1}\\right]\r\n+\\cdots+a_{k}\\left[  T^{k}\\right]  =\\sum_{n=0}^{k}a_{n}\\left[  T^{n}\\right]\r\n.\r\n\\]\r\n\r\n\r\nRecall that $\\operatorname*{Carl}$ is the $\\mathbb{F}_{q}$-algebra\r\nhomomorphism $\\mathbb{F}_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ sending\r\n$T$ to $F+T$. Thus, $\\operatorname*{Carl}T=F+T$. The map $\\operatorname*{Carl}%\r\n$ commutes with applications of polynomials in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $ (since it is an $\\mathbb{F}_{q}$-algebra homomorphism). Thus,%\r\n\\[\r\n\\operatorname*{Carl}\\left(  M\\left(  T\\right)  \\right)  =M\\left(\r\n\\underbrace{\\operatorname*{Carl}T}_{=F+T}\\right)  =M\\left(  F+T\\right)\r\n=\\sum_{n=0}^{k}a_{n}\\left(  F+T\\right)  ^{n}%\r\n\\]\r\n(since $M=\\sum_{n=0}^{k}a_{n}T^{n}$). Since $M\\left(  T\\right)  =M$, this\r\nrewrites as%\r\n\\[\r\n\\operatorname*{Carl}M=\\sum_{n=0}^{k}a_{n}\\left(  F+T\\right)  ^{n}.\r\n\\]\r\nHence,%\r\n\\begin{align*}\r\n\\left(  \\operatorname*{Carl}M\\right)  \\cdot a  &  =\\left(  \\sum_{n=0}^{k}%\r\na_{n}\\left(  F+T\\right)  ^{n}\\right)  \\cdot a=\\sum_{n=0}^{k}a_{n}%\r\n\\underbrace{\\left(  F+T\\right)  ^{n}a}_{\\substack{=\\left[  T^{n}\\right]\r\n\\left(  a\\right)  \\\\\\text{(by (\\ref{pf.prop.F.carlitz.1}))}}}\\\\\r\n&  =\\sum_{n=0}^{k}a_{n}\\left[  T^{n}\\right]  \\left(  a\\right)\r\n=\\underbrace{\\left(  \\sum_{n=0}^{k}a_{n}\\left[  T^{n}\\right]  \\right)\r\n}_{=\\left[  M\\right]  }\\left(  a\\right)  =\\left[  M\\right]  \\left(  a\\right)\r\n.\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.F.carlitz}.\r\n\\end{proof}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.carlitz.img}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then, the\r\nhomomorphism $\\operatorname*{Fqpol}:\\mathcal{F}\\rightarrow\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$ satisfies\r\n$\\left[  M\\right]  =\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}M\\right)\r\n$.\r\n\\end{corollary}\r\n\r\nCorollary \\ref{cor.F.carlitz.img} yields, in particular, that every\r\n$M\\in\\mathbb{F}_{q}\\left[  T\\right]  $ satisfies $\\left[  M\\right]\r\n=\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}M\\right)  \\in\r\n\\operatorname*{Fqpol}\\mathcal{F}\\subseteq\\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}}$.\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F.carlitz.img}.]Let $M\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $.\r\n\r\nConsider the map $\\overline{\\operatorname*{Fqpol}}:\\mathcal{F}\\rightarrow\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $ defined in Proposition\r\n\\ref{prop.F.Fqpol.Fmodhom}. This map $\\overline{\\operatorname*{Fqpol}}$ is an\r\n$\\mathcal{F}$-module homomorphism (according to Proposition\r\n\\ref{prop.F.Fqpol.Fmodhom}).\r\n\r\nThe definition of $\\overline{\\operatorname*{Fqpol}}$ shows that $\\overline\r\n{\\operatorname*{Fqpol}}\\left(  1\\right)  =\\operatorname*{Fqpol}\\left(\r\n1\\right)  =X$ (since $\\operatorname*{Fqpol}$ is an $\\mathbb{F}_{q}$-algebra\r\nhomomorphism $\\mathcal{F}\\rightarrow\\left(  \\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}},+,\\circ\\right)  $, and since the\r\nunity of the $\\mathbb{F}_{q}$-algebra $\\left(  \\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}},+,\\circ\\right)  $ is $X$).\r\n\r\nBut the definition of $\\overline{\\operatorname*{Fqpol}}$ shows that\r\n$\\overline{\\operatorname*{Fqpol}}\\left(  \\operatorname*{Carl}M\\right)\r\n=\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}M\\right)  $, so that%\r\n\\begin{align}\r\n\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}M\\right)   &  =\\overline\r\n{\\operatorname*{Fqpol}}\\left(  \\underbrace{\\operatorname*{Carl}M}_{=\\left(\r\n\\operatorname*{Carl}M\\right)  \\cdot1}\\right)  =\\overline{\\operatorname*{Fqpol}%\r\n}\\left(  \\left(  \\operatorname*{Carl}M\\right)  \\cdot1\\right) \\nonumber\\\\\r\n&  =\\left(  \\operatorname*{Carl}M\\right)  \\cdot\\underbrace{\\overline\r\n{\\operatorname*{Fqpol}}\\left(  1\\right)  }_{=X}\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\overline{\\operatorname*{Fqpol}%\r\n}\\text{ is an }\\mathcal{F}\\text{-module homomorphism}\\right) \\nonumber\\\\\r\n&  =\\left(  \\operatorname*{Carl}M\\right)  \\cdot X.\r\n\\label{pf.cor.F.carlitz.img.1}%\r\n\\end{align}\r\nOn the other hand, Proposition \\ref{prop.F.carlitz} (applied to $A=\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  $ and $a=X$) yields $\\left[  M\\right]\r\n\\left(  X\\right)  =\\left(  \\operatorname*{Carl}M\\right)  \\cdot X$. Comparing\r\nthis with (\\ref{pf.cor.F.carlitz.img.1}), we obtain $\\operatorname*{Fqpol}%\r\n\\left(  \\operatorname*{Carl}M\\right)  =\\left[  M\\right]  \\left(  X\\right)\r\n=\\left[  M\\right]  $. This proves Corollary \\ref{cor.F.carlitz.img}.\r\n\\end{proof}\r\n\r\n\\subsection{\\textquotedblleft Fermat's Little Theorem\\textquotedblright\\ for\r\nthe Carlitz action}\r\n\r\nLet us first state a simple fact:\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.torfree-use}Let $A$ be an $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-algebra which is torsionfree as an $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-module. Let $f$ be a nonzero element of $\\mathbb{F}_{q}\\left[  T\\right]  $.\r\nLet $\\mathbf{u}\\in A\\left[  X\\right]  $ be such that $f\\mathbf{u}\\in A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$. Then, $\\mathbf{u}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.torfree-use}.]We have $f\\mathbf{u}\\in A\\left[\r\nX\\right]  _{q-\\operatorname*{lin}}$. In other words, the polynomial\r\n$f\\mathbf{u}\\in A\\left[  X\\right]  $ is a $q$-polynomial, that is, an\r\n$A$-linear combination of the monomials $X^{q^{0}},X^{q^{1}},X^{q^{2}},\\ldots\r\n$. In other words, for every $k\\in\\mathbb{N}\\setminus\\left\\{  q^{0}%\r\n,q^{1},q^{2},\\ldots\\right\\}  $, we have%\r\n\\begin{equation}\r\n\\left(  \\text{the }X^{k}\\text{-coefficient of }f\\mathbf{u}\\right)  =0.\r\n\\label{pf.lem.F.torfree-use.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, for every $k\\in\\mathbb{N}\\setminus\\left\\{  q^{0},q^{1},q^{2}%\r\n,\\ldots\\right\\}  $, we have%\r\n\\[\r\nf\\cdot\\left(  \\text{the }X^{k}\\text{-coefficient of }\\mathbf{u}\\right)\r\n=\\left(  \\text{the }X^{k}\\text{-coefficient of }f\\mathbf{u}\\right)  =0\r\n\\]\r\n(by (\\ref{pf.lem.F.torfree-use.1})), and thus $\\left(  \\text{the }%\r\nX^{k}\\text{-coefficient of }\\mathbf{u}\\right)  =0$ (because $f\\neq0$, and\r\nbecause $A$ is torsionfree as an $\\mathbb{F}_{q}\\left[  T\\right]  $-module).\r\nIn other words, the polynomial $\\mathbf{u}$ is an $A$-linear combination of\r\nthe monomials $X^{q^{0}},X^{q^{1}},X^{q^{2}},\\ldots$. In other words,\r\n$\\mathbf{u}$ is a $q$-polynomial; that is, $\\mathbf{u}\\in A\\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$. This proves Lemma \\ref{lem.F.torfree-use}.\r\n\\end{proof}\r\n\r\nWe now shall prove a crucial fact:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.u(pi)}Let $\\pi$ be a monic irreducible polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Then, there exists a unique $u\\left(\r\n\\pi\\right)  \\in\\mathcal{F}$ such that $\\operatorname*{Carl}\\pi=F^{\\deg\\pi}%\r\n+\\pi\\cdot u\\left(  \\pi\\right)  $. (The notation $u\\left(  \\pi\\right)  $ means\r\nthat $u$ depends on $\\pi$; it is not meant to imply that $u\\left(  \\pi\\right)\r\n$ is a polynomial in $\\pi$.)\r\n\\end{proposition}\r\n\r\nThe first proof of this proposition will reveal it to be a translation of part\r\nof \\cite[Theorem 2.11]{kc-carlitz}:\r\n\r\n\\begin{proof}\r\n[First proof of Proposition \\ref{prop.F.u(pi)}.]The left $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module $\\mathcal{F}$ is free (by Proposition\r\n\\ref{prop.F.bases} \\textbf{(c)}), and thus torsionfree.\r\n\r\nFrom \\cite[Theorem 2.11]{kc-carlitz}, we know that $\\overline{\\left[\r\n\\pi\\right]  }\\left(  X\\right)  =X^{q^{\\deg\\pi}}$, where $\\overline{\\left[\r\n\\pi\\right]  }\\left(  X\\right)  $ denotes the projection of $\\left[\r\n\\pi\\right]  \\left(  X\\right)  =\\left[  \\pi\\right]  \\in\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  $ onto $\\left(  \\mathbb{F}_{q}\\left[  T\\right]\r\n/\\pi\\right)  \\left[  X\\right]  $. In other words, $\\left[  \\pi\\right]  \\left(\r\nX\\right)  \\equiv X^{q^{\\deg\\pi}}\\operatorname{mod}K$, where $K$ is the kernel\r\nof the projection $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n\\rightarrow\\left(  \\mathbb{F}_{q}\\left[  T\\right]  /\\pi\\right)  \\left[\r\nX\\right]  $. Since this kernel $K$ is simply $\\pi\\mathbb{F}_{q}\\left[\r\nT\\right]  \\left[  X\\right]  $, this rewrites as follows: $\\left[  \\pi\\right]\r\n\\left(  X\\right)  \\equiv X^{q^{\\deg\\pi}}\\operatorname{mod}\\pi\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\left[  X\\right]  $.\r\n\r\nThus, $\\left[  \\pi\\right]  =\\left[  \\pi\\right]  \\left(  X\\right)  \\equiv\r\nX^{q^{\\deg\\pi}}\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $. In other words, $\\pi\\mid\\left[  \\pi\\right]  -X^{q^{\\deg\\pi}}$ in\r\nthe ring $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $. Hence,\r\n$\\dfrac{1}{\\pi}\\left(  \\left[  \\pi\\right]  -X^{q^{\\deg\\pi}}\\right)  $ is a\r\nwell-defined polynomial in the ring $\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  $ (since this ring is an integral domain). Let us denote this\r\npolynomial by $\\mathbf{u}$.\r\n\r\nWe have%\r\n\\begin{align*}\r\n\\left[  \\pi\\right]   &  =\\operatorname*{Fqpol}\\left(\r\n\\underbrace{\\operatorname*{Carl}\\pi}_{\\in\\mathcal{F}}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Corollary \\ref{cor.F.carlitz.img},\r\napplied to }M=\\pi\\right) \\\\\r\n&  \\in\\operatorname*{Carl}\\mathcal{F}\\subseteq\\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}}.\r\n\\end{align*}\r\n\r\n\r\nBut $\\mathbf{u}=\\dfrac{1}{\\pi}\\left(  \\left[  \\pi\\right]  -X^{q^{\\deg\\pi}%\r\n}\\right)  $, so that $\\pi\\mathbf{u}=\\left[  \\pi\\right]  -X^{q^{\\deg\\pi}}%\r\n\\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$\r\n(since both $\\left[  \\pi\\right]  $ and $X^{q^{\\deg\\pi}}$ belong to\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  _{q-\\operatorname*{lin}}$).\r\nTherefore, $\\mathbf{u}\\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n_{q-\\operatorname*{lin}}$ (by Lemma \\ref{lem.F.torfree-use}, applied to\r\n$A=\\mathbb{F}_{q}\\left[  T\\right]  $ and $f=\\pi$).\r\n\r\nTheorem \\ref{thm.q-pol.=F} \\textbf{(c)} (applied to $j=0$ and $i=\\deg\\pi$)\r\nyields $\\operatorname*{Fqpol}\\left(  T^{0}F^{\\deg\\pi}\\right)\r\n=\\underbrace{T^{0}}_{=1}X^{q^{\\deg\\pi}}=X^{q^{\\deg\\pi}}$, so that\r\n$X^{q^{\\deg\\pi}}=\\operatorname*{Fqpol}\\left(  \\underbrace{T^{0}}_{=1}%\r\nF^{\\deg\\pi}\\right)  =\\operatorname*{Fqpol}\\left(  F^{\\deg\\pi}\\right)  $.\r\n\r\nTheorem \\ref{thm.q-pol.=F} \\textbf{(b)} shows that the map\r\n$\\operatorname*{Fqpol}:\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]\r\n\\left[  X\\right]  _{q-\\operatorname*{lin}}$ is an $\\mathbb{F}_{q}$-algebra\r\nisomorphism. Thus, its inverse map $\\operatorname*{Fqpol}\\nolimits^{-1}$ is\r\nwell-defined. Set $\\widetilde{\\mathbf{u}}=\\operatorname*{Fqpol}\\nolimits^{-1}%\r\n\\left(  \\mathbf{u}\\right)  $. Thus, $\\widetilde{\\mathbf{u}}\\in\\mathcal{F}$ and\r\n$\\operatorname*{Fqpol}\\left(  \\widetilde{\\mathbf{u}}\\right)  =\\mathbf{u}$.\r\n\r\nBut $\\operatorname*{Fqpol}$ is an isomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules (according to Proposition \\ref{prop.q-pol.Fqlin.leftT}).\r\nHence,%\r\n\\begin{align*}\r\n\\operatorname*{Fqpol}\\left(  \\pi\\widetilde{\\mathbf{u}}\\right)   &\r\n=\\pi\\underbrace{\\operatorname*{Fqpol}\\left(  \\widetilde{\\mathbf{u}}\\right)\r\n}_{=\\mathbf{u}}=\\pi\\mathbf{u}=\\underbrace{\\left[  \\pi\\right]  }%\r\n_{\\substack{=\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}\\pi\\right)\r\n\\\\\\text{(by Corollary \\ref{cor.F.carlitz.img},}\\\\\\text{applied to }%\r\nM=\\pi\\text{)}}}-\\underbrace{X^{q^{\\deg\\pi}}}_{=\\operatorname*{Fqpol}\\left(\r\nF^{\\deg\\pi}\\right)  }\\\\\r\n&  =\\operatorname*{Fqpol}\\left(  \\operatorname*{Carl}\\pi\\right)\r\n-\\operatorname*{Fqpol}\\left(  F^{\\deg\\pi}\\right)  =\\operatorname*{Fqpol}%\r\n\\left(  \\operatorname*{Carl}\\pi-F^{\\deg\\pi}\\right)\r\n\\end{align*}\r\n(since the map $\\operatorname*{Fqpol}$ is $\\mathbb{F}_{q}$-linear). Since\r\n$\\operatorname*{Fqpol}$ is injective (because $\\operatorname*{Fqpol}$ is an\r\nisomorphism), this yields $\\pi\\widetilde{\\mathbf{u}}=\\operatorname*{Carl}%\r\n\\pi-F^{\\deg\\pi}$.\r\n\r\nHence, there exists at least one $u\\left(  \\pi\\right)  \\in\\mathcal{F}$ such\r\nthat $\\pi\\cdot u\\left(  \\pi\\right)  =\\operatorname*{Carl}\\pi-F^{\\deg\\pi}$\r\n(namely, $u\\left(  \\pi\\right)  =\\widetilde{\\mathbf{u}}$). Moreover, such a\r\n$u\\left(  \\pi\\right)  $ is clearly unique (because any element $u\\left(\r\n\\pi\\right)  \\in\\mathcal{F}$ is uniquely determined by $\\pi\\cdot u\\left(\r\n\\pi\\right)  $ (since $\\pi\\neq0$, and since the left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-module $\\mathcal{F}$ is torsionfree)). Thus, there exists a\r\n\\textbf{unique} $u\\left(  \\pi\\right)  \\in\\mathcal{F}$ such that $\\pi\\cdot\r\nu\\left(  \\pi\\right)  =\\operatorname*{Carl}\\pi-F^{\\deg\\pi}$. In other words,\r\nthere exists a \\textbf{unique} $u\\left(  \\pi\\right)  \\in\\mathcal{F}$ such that\r\n$\\operatorname*{Carl}\\pi=F^{\\deg\\pi}+\\pi\\cdot u\\left(  \\pi\\right)  $. This\r\nproves Proposition \\ref{prop.F.u(pi)}.\r\n\\end{proof}\r\n\r\n\\subsection{A second proof of Proposition \\ref{prop.F.u(pi)}}\r\n\r\nLet us next give another proof of Proposition \\ref{prop.F.u(pi)}, which does\r\nnot rely on Carlitz polynomials. This proof is not directly relevant for the\r\nrest of this report, but illustrates some techniques of working with\r\n$\\mathcal{F}$.\r\n\r\n\\begin{noncompile}\r\nWe begin by quoting a well-known fact:\r\n\r\n\\begin{lemma}\r\n\\label{lem.artin-character-lind}Let $G$ be a finite abelian group. Let $F$ be\r\na field. Let $\\chi_{1},\\chi_{2},\\ldots,\\chi_{n}$ be finitely many distinct\r\ngroup homomorphisms $G\\rightarrow F^{\\times}$. Then, $\\chi_{1},\\chi_{2}%\r\n,\\ldots,\\chi_{n}$ are $F$-linearly independent as elements of the $F$-vector\r\nspace $F^{G}$.\r\n\\end{lemma}\r\n\r\nLemma \\ref{lem.artin-character-lind} is Artin's classical result on the\r\n\\textit{linear independency of characters}; it appears, for example, in\r\n\\cite[Theorem 2.1]{kc-lind} (where the word \\textquotedblleft\r\ncharacter\\textquotedblright\\ for \\textquotedblleft group homomorphism to\r\n$F^{\\times}$\\textquotedblright\\ is used).\r\n\r\n\\bibitem {kc-lind}Keith Conrad, \\textit{Linear independence of characters},\r\nversion 10 June 2013.\\newline\\url{http://www.math.uconn.edu/~kconrad/blurbs/galoistheory/linearchar.pdf}\r\n\\end{noncompile}\r\n\r\nWe first state a classical fact:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.u(pi).lem1}Let $\\pi$ be a monic irreducible polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Let $d=\\deg\\pi$.\r\n\r\nLet $\\mathbb{F}_{\\pi}$ denote the field $\\mathbb{F}_{q}\\left[  T\\right]\r\n/\\pi\\mathbb{F}_{q}\\left[  T\\right]  $. This is a field extension of\r\n$\\mathbb{F}_{q}$. Let $\\alpha\\in\\mathbb{F}_{\\pi}$ be the residue class of\r\n$T\\in\\mathbb{F}_{q}\\left[  T\\right]  $ modulo the ideal $\\pi\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $. Thus, $\\mathbb{F}_{\\pi}=\\mathbb{F}\\left[\r\n\\alpha\\right]  $ and $\\pi\\left(  \\alpha\\right)  =0$.\r\n\r\n\\textbf{(a)} The $\\mathbb{F}_{q}$-vector space $\\mathbb{F}_{\\pi}$ has basis\r\n$\\left(  \\alpha^{0},\\alpha^{1},\\ldots,\\alpha^{d-1}\\right)  $.\r\n\r\n\\textbf{(b)} The elements $\\alpha^{q^{0}},\\alpha^{q^{1}},\\ldots,\\alpha\r\n^{q^{d-1}}$ are pairwise distinct and are precisely the roots of $\\pi$.\r\n\r\n\\textbf{(c)} We have%\r\n\\begin{equation}\r\n\\pi=\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in }\\mathbb{F}_{\\pi}\\left[  T\\right]  .\r\n\\label{eq.prop.F.u(pi).lem1.c}%\r\n\\end{equation}\r\n\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.u(pi).lem1}.]\\textbf{(a)} This is well-known\r\n(and holds for any commutative ring instead of $\\mathbb{F}_{q}$).\r\n\r\n\\textbf{(c)} Recall that $\\operatorname*{Frob}\\nolimits_{A}$ is an\r\n$\\mathbb{F}_{q}$-algebra endomorphism of $A$ whenever $A$ is a commutative\r\n$\\mathbb{F}_{q}$-algebra. Applying this to $A=\\mathbb{F}_{\\pi}$, we conclude\r\nthat $\\operatorname*{Frob}\\nolimits_{\\mathbb{F}_{\\pi}}$ is an $\\mathbb{F}_{q}%\r\n$-algebra endomorphism of $\\mathbb{F}_{\\pi}$. Denote this $\\mathbb{F}_{q}%\r\n$-algebra endomorphism by $f$. Thus, $f=\\operatorname*{Frob}%\r\n\\nolimits_{\\mathbb{F}_{\\pi}}$.\r\n\r\nWe have $f=\\operatorname*{Frob}\\nolimits_{\\mathbb{F}_{\\pi}}$, and thus\r\n\\begin{equation}\r\nf\\left(  a\\right)  =\\operatorname*{Frob}\\nolimits_{\\mathbb{F}_{\\pi}}\\left(\r\na\\right)  =a^{q}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of\r\n}\\operatorname*{Frob}\\nolimits_{\\mathbb{F}_{\\pi}}\\right)\r\n\\label{pf.prop.F.u(pi).lem1.f(a)=}%\r\n\\end{equation}\r\nfor every $a\\in\\mathbb{F}_{\\pi}$. Now,%\r\n\\begin{equation}\r\nf^{k}\\left(  a\\right)  =a^{q^{k}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }%\r\nk\\in\\mathbb{N}\\text{ and }a\\in\\mathbb{F}_{\\pi}.\r\n\\label{pf.prop.F.u(pi).lem1.fk(a)=}%\r\n\\end{equation}\r\n(Indeed, this can be proven by a straightforward induction on $k$, using\r\n(\\ref{pf.prop.F.u(pi).lem1.f(a)=}).)\r\n\r\nBut $\\mathbb{F}_{\\pi}=\\mathbb{F}_{q}\\left[  T\\right]  /\\pi\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ is an $\\mathbb{F}_{q}$-vector space of dimension\r\n$\\deg\\pi=d$. Hence, $\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert =\\left\\vert\r\n\\mathbb{F}_{q}\\right\\vert ^{d}=q^{d}$ (since $\\left\\vert \\mathbb{F}%\r\n_{q}\\right\\vert =q$). But it is well-known that if $L$ is a finite field, then\r\nevery $a\\in L$ satisfies $a^{\\left\\vert L\\right\\vert }=a$. Applying this to\r\n$L=\\mathbb{F}_{\\pi}$, we conclude that every $a\\in\\mathbb{F}_{\\pi}$ satisfies\r\n$a^{\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert }=a$. Hence,%\r\n\\begin{equation}\r\nf^{d}=\\operatorname*{id} \\label{pf.prop.F.u(pi).lem1.fd=}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.F.u(pi).lem1.fd=}):} We have just\r\nshown that every $a\\in\\mathbb{F}_{\\pi}$ satisfies $a^{\\left\\vert\r\n\\mathbb{F}_{\\pi}\\right\\vert }=a$. Now, every $a\\in\\mathbb{F}_{\\pi}$ satisfies%\r\n\\begin{align*}\r\nf^{d}\\left(  a\\right)   &  =a^{q^{d}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{pf.prop.F.u(pi).lem1.fk(a)=}), applied to }k=d\\right) \\\\\r\n&  =a^{\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }q^{d}=\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert \\right) \\\\\r\n&  =a=\\operatorname*{id}\\left(  a\\right)  .\r\n\\end{align*}\r\nIn other words, $f^{d}=\\operatorname*{id}$. Qed.}. Thus, $\\operatorname*{id}%\r\n=f^{d}=f^{d-1}\\circ f$. Hence, the map $f$ is left-invertible, and thus injective.\r\n\r\nEvery nonzero polynomial $g\\in\\mathbb{F}_{q}\\left[  T\\right]  $ has at most\r\n$\\deg g$ roots (since $\\mathbb{F}_{q}$ is a field). Applying this to $g=\\pi$,\r\nwe conclude that the polynomial $\\pi$ has at most $\\deg\\pi=d$ roots.\r\n\r\nNow, we notice that\r\n\\begin{equation}\r\n\\pi\\left(  \\alpha^{q^{k}}\\right)  =0\\text{ for each }k\\in\\left\\{\r\n0,1,\\ldots,d-1\\right\\}  \\label{pf.prop.F.u(pi).lem1.b.root1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.F.u(pi).lem1.b.root1}):} Let\r\n$k\\in\\left\\{  0,1,\\ldots,d-1\\right\\}  $. Then,\r\n(\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) (applied to $a=\\alpha$) yields\r\n$f^{k}\\left(  \\alpha\\right)  =\\alpha^{q^{k}}$.\r\n\\par\r\nRecall that $f$ is an $\\mathbb{F}_{q}$-algebra endomorphism of $\\mathbb{F}%\r\n_{\\pi}$. Thus, $f^{k}$ is an $\\mathbb{F}_{q}$-algebra endomorphism of\r\n$\\mathbb{F}_{\\pi}$ as well. Hence, $f^{k}$ commutes with polynomials in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. In other words, $f^{k}\\left(  g\\left(\r\n\\beta\\right)  \\right)  =g\\left(  f^{k}\\left(  \\beta\\right)  \\right)  $ for\r\nevery $g\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and every $\\beta\\in\r\n\\mathbb{F}_{\\pi}$. Applying this to $g=\\pi$ and $\\beta=\\alpha$, we obtain\r\n$f^{k}\\left(  \\pi\\left(  \\alpha\\right)  \\right)  =\\pi\\left(  \\underbrace{f^{k}%\r\n\\left(  \\alpha\\right)  }_{=\\alpha^{q^{k}}}\\right)  =\\pi\\left(  \\alpha^{q^{k}%\r\n}\\right)  $. Hence, $\\pi\\left(  \\alpha^{q^{k}}\\right)  =f^{k}\\left(\r\n\\underbrace{\\pi\\left(  \\alpha\\right)  }_{=0}\\right)  =f^{k}\\left(  0\\right)\r\n=0$ (since $f^{k}$ is an $\\mathbb{F}_{q}$-algebra endomorphism of\r\n$\\mathbb{F}_{\\pi}$). This proves (\\ref{pf.prop.F.u(pi).lem1.b.root1}).}.\r\nAlso,\r\n\\begin{equation}\r\n\\alpha^{q^{k}}\\neq\\alpha\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }k\\in\\left\\{\r\n1,2,\\ldots,d-1\\right\\}  \\label{pf.prop.F.u(pi).lem1.b.neq1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.F.u(pi).lem1.b.neq1}):} Let\r\n$k\\in\\left\\{  1,2,\\ldots,d-1\\right\\}  $. We shall show that $\\alpha^{q^{k}%\r\n}\\neq\\alpha$.\r\n\\par\r\nIndeed, assume the contrary. Thus, $\\alpha^{q^{k}}=\\alpha$. But\r\n(\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) (applied to $a=\\alpha$) yields\r\n$f^{k}\\left(  \\alpha\\right)  =\\alpha^{q^{k}}=\\alpha$.\r\n\\par\r\nLet $x\\in\\mathbb{F}_{\\pi}$. We are going to show that $x^{q^{k}}-x=0$.\r\n\\par\r\nIndeed, $x\\in\\mathbb{F}_{\\pi}=\\mathbb{F}_{q}\\left[  \\alpha\\right]  $. Hence,\r\n$x=h\\left(  \\alpha\\right)  $ for some polynomial $h\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $. Consider this $h$.\r\n\\par\r\nRecall that $f$ is an $\\mathbb{F}_{q}$-algebra endomorphism of $\\mathbb{F}%\r\n_{\\pi}$. Thus, $f^{k}$ is an $\\mathbb{F}_{q}$-algebra endomorphism of\r\n$\\mathbb{F}_{\\pi}$ as well. Hence, $f^{k}$ commutes with polynomials in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. In other words, $f^{k}\\left(  g\\left(\r\n\\beta\\right)  \\right)  =g\\left(  f^{k}\\left(  \\beta\\right)  \\right)  $ for\r\nevery $g\\in\\mathbb{F}_{q}\\left[  T\\right]  $ and every $\\beta\\in\r\n\\mathbb{F}_{\\pi}$. Applying this to $g=h$ and $\\beta=\\alpha$, we obtain\r\n$f^{k}\\left(  h\\left(  \\alpha\\right)  \\right)  =h\\left(  \\underbrace{f^{k}%\r\n\\left(  \\alpha\\right)  }_{=\\alpha}\\right)  =h\\left(  \\alpha\\right)  $. Since\r\n$x=h\\left(  \\alpha\\right)  $, this rewrites as $f^{k}\\left(  x\\right)  =x$.\r\nBut (\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) (applied to $a=x$) yields\r\n$f^{k}\\left(  x\\right)  =x^{q^{k}}$. Hence, $x^{q^{k}}=f^{k}\\left(  x\\right)\r\n=x$, so that $x^{q^{k}}-x=0$.\r\n\\par\r\nNow, forget that we fixed $x$. We thus have proven that every $x\\in\r\n\\mathbb{F}_{\\pi}$ satisfies $x^{q^{k}}-x=0$. In other words, every\r\n$x\\in\\mathbb{F}_{\\pi}$ is a root of the polynomial $T^{q^{k}}-T\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, the polynomial $T^{q^{k}}-T$ has at\r\nleast $\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert $ roots. Since $\\left\\vert\r\n\\mathbb{F}_{\\pi}\\right\\vert =q^{d}>q^{k}$ (since $d>k$ (because $k\\in\\left\\{\r\n1,2,\\ldots,d-1\\right\\}  $)), this shows that the polynomial $T^{q^{k}}-T$ has\r\n$>q^{k}$ roots.\r\n\\par\r\nBut $k>0$, so that the polynomial $T^{q^{k}}-T$ is a nonzero polynomial of\r\ndegree $\\deg\\left(  T^{q^{k}}-T\\right)  =q^{k}$. It is well-known that each\r\nnonzero polynomial $w\\in\\mathbb{F}_{q}\\left[  T\\right]  $ has at most $\\deg w$\r\nroots (since $\\mathbb{F}_{q}$ is a field). Applying this to $w=T^{q^{k}}-T$,\r\nwe conclude that the polynomial $T^{q^{k}}-T$ has at most $\\deg\\left(\r\nT^{q^{k}}-T\\right)  =q^{k}$ roots. This contradicts the fact that the\r\npolynomial $T^{q^{k}}-T$ has $>q^{k}$ roots. This contradiction shows that our\r\nassumption was false. Hence, $\\alpha^{q^{k}}\\neq\\alpha$ is proven, qed.}.\r\nHence,%\r\n\\begin{equation}\r\n\\text{the elements }\\alpha^{q^{0}},\\alpha^{q^{1}},\\ldots,\\alpha^{q^{d-1}%\r\n}\\text{ are pairwise distinct} \\label{pf.prop.F.u(pi).lem1.b.neq2}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.F.u(pi).lem1.b.neq2}):} Assume the\r\ncontrary. Thus, two of the elements $\\alpha^{q^{0}},\\alpha^{q^{1}}%\r\n,\\ldots,\\alpha^{q^{d-1}}$ are equal. In other words, there exist two elements\r\n$i$ and $j$ of $\\left\\{  0,1,\\ldots,d-1\\right\\}  $ satisfying $i<j$ and\r\n$\\alpha^{q^{i}}=\\alpha^{q^{j}}$. Consider these $i$ and $j$.\r\n\\par\r\nWe have $j-i\\in\\left\\{  1,2,\\ldots,d-1\\right\\}  $ (since $i$ and $j$ belong to\r\n$\\left\\{  0,1,\\ldots,d-1\\right\\}  $ and satisfy $i<j$). Hence,\r\n(\\ref{pf.prop.F.u(pi).lem1.b.neq1}) (applied to $k=j-i$) yields $\\alpha\r\n^{q^{j-i}}\\neq\\alpha$. But (\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) (applied to\r\n$a=\\alpha$ and $k=j-i$) yields $f^{j-i}\\left(  \\alpha\\right)  =\\alpha\r\n^{q^{j-i}}\\neq\\alpha$.\r\n\\par\r\nApplying (\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) to $a=\\alpha$ and $k=i$, we\r\nobtain $f^{i}\\left(  \\alpha\\right)  =\\alpha^{q^{i}}$. Applying\r\n(\\ref{pf.prop.F.u(pi).lem1.fk(a)=}) to $a=\\alpha$ and $k=j$, we obtain\r\n$f^{j}\\left(  \\alpha\\right)  =\\alpha^{q^{j}}$. Thus, $\\alpha^{q^{j}%\r\n}=\\underbrace{f^{j}}_{\\substack{=f^{i}\\circ f^{j-i}\\\\\\text{(since }%\r\ni<j\\text{)}}}\\left(  \\alpha\\right)  =\\left(  f^{i}\\circ f^{j-i}\\right)\r\n\\left(  \\alpha\\right)  =f^{i}\\left(  f^{j-i}\\left(  \\alpha\\right)  \\right)  $.\r\n\\par\r\nNow, $f^{i}\\left(  \\alpha\\right)  =\\alpha^{q^{i}}=\\alpha^{q^{j}}=f^{i}\\left(\r\nf^{j-i}\\left(  \\alpha\\right)  \\right)  $. Since the map $f^{i}$ is injective\r\n(because $f$ is injective), this entails $\\alpha=f^{j-i}\\left(  \\alpha\\right)\r\n\\neq\\alpha$. This is clearly absurd. This contradiction proves that our\r\nassumption was false. Hence, (\\ref{pf.prop.F.u(pi).lem1.b.neq2}) is proven.}.\r\n\r\nLet $\\gamma$ be the polynomial%\r\n\\[\r\n\\pi-\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  \\in\\mathbb{F}_{\\pi\r\n}\\left[  T\\right]  .\r\n\\]\r\n\r\n\r\nThe polynomial $\\pi$ is monic and has degree $\\deg\\pi=d$. The polynomial\r\n$\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  $ is also obviously a monic\r\npolynomial of degree $d$ (since it is a product of $d$ monic polynomials of\r\ndegree $1$). Thus, $\\gamma$ is a difference of two monic polynomials of degree\r\n$d$ (since $\\gamma=\\pi-\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  $).\r\nConsequently, $\\gamma$ is a polynomial of degree $<d$ (because the difference\r\nof two monic polynomials of degree $d$ must always be a polynomial of degree\r\n$<d$). In other words, $\\deg\\gamma<d$.\r\n\r\nAssume (for the sake of contradiction) that $\\gamma\\neq0$.\r\n\r\nEvery nonzero polynomial $g\\in\\mathbb{F}_{\\pi}\\left[  T\\right]  $ has at most\r\n$\\deg g$ roots (since $\\mathbb{F}_{\\pi}$ is a field). Applying this to\r\n$g=\\gamma$, we conclude that $\\gamma$ has at most $\\deg\\gamma$ roots (since\r\n$\\gamma\\neq0$). Thus, $\\gamma$ has $<d$ roots (since $\\deg\\gamma<d$).\r\n\r\nBut for every $\\ell\\in\\left\\{  0,1,\\ldots,d-1\\right\\}  $, the element\r\n$\\alpha^{q^{\\ell}}$ of $\\mathbb{F}_{\\pi}$ is a root of $\\gamma$%\r\n\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $\\ell\\in\\left\\{  0,1,\\ldots,d-1\\right\\}\r\n$. From $\\gamma=\\pi-\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  $, we\r\nobtain%\r\n\\[\r\n\\gamma\\left(  \\alpha^{q^{\\ell}}\\right)  =\\underbrace{\\pi\\left(  \\alpha\r\n^{q^{\\ell}}\\right)  }_{\\substack{=0\\\\\\text{(by\r\n(\\ref{pf.prop.F.u(pi).lem1.b.root1}),}\\\\\\text{applied to }k=\\ell\\text{)}%\r\n}}-\\underbrace{\\prod_{k=0}^{d-1}\\left(  \\alpha^{q^{\\ell}}-\\alpha^{q^{k}%\r\n}\\right)  }_{\\substack{=0\\\\\\text{(because one of the factors in this product\r\nis }\\alpha^{q^{\\ell}}-\\alpha^{q^{\\ell}}\\\\\\text{(namely, the factor for }%\r\nk=\\ell\\text{), and this factor is clearly }0\\text{)}}}=0-0=0.\r\n\\]\r\nIn other words, the element $\\alpha^{q^{\\ell}}$ of $\\mathbb{F}_{\\pi}$ is a\r\nroot of $\\gamma$. Qed.}. In other words, $\\alpha^{q^{0}},\\alpha^{q^{1}}%\r\n,\\ldots,\\alpha^{q^{d-1}}$ are $d$ roots of $\\gamma$. These $d$ roots are\r\npairwise distinct (by (\\ref{pf.prop.F.u(pi).lem1.b.neq2})). Thus, the\r\npolynomial $\\gamma$ has at least $d$ roots. This contradicts the fact that\r\n$\\gamma$ has $<d$ roots. This contradiction proves that our assumption (that\r\n$\\gamma\\neq0$) was false. Hence, we have $\\gamma=0$. Thus, $0=\\gamma=\\pi\r\n-\\prod_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  $, so that $\\pi=\\prod\r\n_{k=0}^{d-1}\\left(  T-\\alpha^{q^{k}}\\right)  $. This proves Proposition\r\n\\ref{prop.F.u(pi).lem1} \\textbf{(c)}.\r\n\r\n\\textbf{(b)} The elements $\\alpha^{q^{0}},\\alpha^{q^{1}},\\ldots,\\alpha\r\n^{q^{d-1}}$ are pairwise distinct (by (\\ref{pf.prop.F.u(pi).lem1.b.neq2})) and\r\nare precisely the roots of $\\pi$ (because of (\\ref{eq.prop.F.u(pi).lem1.c})).\r\nThis proves Proposition \\ref{prop.F.u(pi).lem1} \\textbf{(b)}.\r\n\\end{proof}\r\n\r\nHere are some more useful lemmas:\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.u(pi).dividiff}Let $\\mathbb{K}$ be a commutative ring. Let\r\n$d\\in\\mathbb{N}$. Let $\\pi\\in\\mathbb{K}\\left[  T\\right]  $ be a polynomial of\r\ndegree $\\leq d$. For each $i\\in\\mathbb{N}$, let $\\pi_{i}$ be the coefficient\r\nof $T^{i}$ in $\\pi$. For each $k\\in\\left\\{  0,1,\\ldots,d\\right\\}  $, define a\r\npolynomial $p_{k}\\in\\mathbb{K}\\left[  T\\right]  $ by $p_{k}=\\sum_{i=k+1}%\r\n^{d}\\pi_{i}T^{i-1-k}$. Then:\r\n\r\n\\textbf{(a)} We have $p_{d-1}=\\pi_{d}$ (a constant polynomial) and $p_{d}=0$.\r\n\r\n\\textbf{(b)} We have $\\pi\\left(  X\\right)  -\\pi\\left(  Y\\right)  =\\left(\r\nX-Y\\right)  \\sum_{i=0}^{d-1}p_{i}\\left(  X\\right)  Y^{i}$ in the ring\r\n$\\mathbb{K}\\left[  X,Y\\right]  $.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.u(pi).dividiff}.]The definition of $p_{d-1}$ yields%\r\n\\[\r\np_{d-1}=\\sum_{i=\\left(  d-1\\right)  +1}^{d}\\pi_{i}T^{i-1-\\left(  d-1\\right)\r\n}=\\sum_{i=d}^{d}\\pi_{i}T^{i-1-\\left(  d-1\\right)  }=\\pi_{d}%\r\n\\underbrace{T^{d-1-\\left(  d-1\\right)  }}_{=T^{0}=1}=\\pi_{d}.\r\n\\]\r\nThe definition of $p_{d}$ yields%\r\n\\[\r\np_{d}=\\sum_{i=d+1}^{d}\\pi_{i}T^{i-1-d}=\\left(  \\text{empty sum}\\right)  =0.\r\n\\]\r\nThis proves Lemma \\ref{lem.F.u(pi).dividiff} \\textbf{(a)}.\r\n\r\nFor every $i\\in\\left\\{  0,1,\\ldots,d\\right\\}  $, we have%\r\n\\begin{align}\r\nX^{i}-Y^{i}  &  =\\left(  X-Y\\right)  \\underbrace{\\sum_{k=0}^{i-1}%\r\nX^{k}Y^{i-1-k}}_{\\substack{=\\sum_{\\ell=0}^{i-1}X^{i-1-\\ell}Y^{\\ell\r\n}\\\\\\text{(here, we have substituted }\\ell\\\\\\text{for }i-1-k\\text{ in the\r\nsum)}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by a known formula}\\right)\r\n\\nonumber\\\\\r\n&  =\\left(  X-Y\\right)  \\sum_{\\ell=0}^{i-1}X^{i-1-\\ell}Y^{\\ell}.\r\n\\label{pf.lem.F.u(pi).dividiff.geoser}%\r\n\\end{align}\r\n\r\n\r\nWe have $\\pi=\\sum_{i=0}^{d}\\pi_{i}T^{i}$ (since $\\pi$ is a polynomial of\r\ndegree $\\leq d$, and since the $\\pi_{i}$ are its coefficients). Thus,\r\n$\\pi\\left(  X\\right)  =\\sum_{i=0}^{d}\\pi_{i}X^{i}$ and $\\pi\\left(  Y\\right)\r\n=\\sum_{i=0}^{d}\\pi_{i}Y^{i}$. Hence,%\r\n\\begin{align*}\r\n\\pi\\left(  X\\right)  -\\pi\\left(  Y\\right)   &  =\\sum_{i=0}^{d}\\pi_{i}%\r\nX^{i}-\\sum_{i=0}^{d}\\pi_{i}Y^{i}\\\\\r\n&  =\\sum_{i=0}^{d}\\pi_{i}\\underbrace{\\left(  X^{i}-Y^{i}\\right)\r\n}_{\\substack{=\\left(  X-Y\\right)  \\sum_{\\ell=0}^{i-1}X^{i-1-\\ell}Y^{\\ell\r\n}\\\\\\text{(by (\\ref{pf.lem.F.u(pi).dividiff.geoser}))}}}=\\sum_{i=0}^{d}\\pi\r\n_{i}\\cdot\\left(  X-Y\\right)  \\sum_{\\ell=0}^{i-1}X^{i-1-\\ell}Y^{\\ell}\\\\\r\n&  =\\left(  X-Y\\right)  \\sum_{i=0}^{d}\\pi_{i}\\sum_{\\ell=0}^{i-1}X^{i-1-\\ell\r\n}Y^{\\ell}.\r\n\\end{align*}\r\nSince%\r\n\\begin{align*}\r\n\\sum_{i=0}^{d}\\pi_{i}\\sum_{\\ell=0}^{i-1}X^{i-1-\\ell}Y^{\\ell}  &\r\n=\\underbrace{\\sum_{i=0}^{d}\\sum_{\\ell=0}^{i-1}}_{=\\sum_{\\ell=0}^{d}%\r\n\\sum_{i=\\ell+1}^{d}}\\pi_{i}X^{i-1-\\ell}Y^{\\ell}=\\sum_{\\ell=0}^{d}%\r\n\\underbrace{\\sum_{i=\\ell+1}^{d}\\pi_{i}X^{i-1-\\ell}}_{\\substack{=p_{\\ell\r\n}\\left(  X\\right)  \\\\\\text{(since }p_{\\ell}=\\sum_{i=\\ell+1}^{d}\\pi\r\n_{i}T^{i-1-\\ell}\\\\\\text{(by the definition of }p_{\\ell}\\text{) and\r\nthus}\\\\p_{\\ell}\\left(  X\\right)  =\\sum_{i=\\ell+1}^{d}\\pi_{i}X^{i-1-\\ell\r\n}\\text{)}}}Y^{\\ell}\\\\\r\n&  =\\sum_{\\ell=0}^{d}p_{\\ell}\\left(  X\\right)  Y^{\\ell}=\\sum_{\\ell=0}%\r\n^{d-1}p_{\\ell}\\left(  X\\right)  Y^{\\ell}+\\underbrace{p_{d}\\left(  X\\right)\r\n}_{\\substack{=0\\\\\\text{(since }p_{d}=0\\text{)}}}Y^{d}\\\\\r\n&  =\\sum_{\\ell=0}^{d-1}p_{\\ell}\\left(  X\\right)  Y^{\\ell}=\\sum_{i=0}%\r\n^{d-1}p_{i}\\left(  X\\right)  Y^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have renamed the summation index\r\n}\\ell\\text{ as }i\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $\\pi\\left(  X\\right)  -\\pi\\left(  Y\\right)  =\\left(\r\nX-Y\\right)  \\sum_{i=0}^{d-1}p_{i}\\left(  X\\right)  Y^{i}$. This proves Lemma\r\n\\ref{lem.F.u(pi).dividiff} \\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.u(pi).lem2}Let $\\pi$ be a monic irreducible polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Let $d=\\deg\\pi$.\r\n\r\nLet $\\mathbb{F}_{\\pi}$ denote the field $\\mathbb{F}_{q}\\left[  T\\right]\r\n/\\pi\\mathbb{F}_{q}\\left[  T\\right]  $. This is a field extension of\r\n$\\mathbb{F}_{q}$. Let $\\alpha\\in\\mathbb{F}_{\\pi}$ be the residue class of\r\n$T\\in\\mathbb{F}_{q}\\left[  T\\right]  $ modulo the ideal $\\pi\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $. Thus, $\\mathbb{F}_{\\pi}=\\mathbb{F}\\left[\r\n\\alpha\\right]  $ and $\\pi\\left(  \\alpha\\right)  =0$. Let $\\mathcal{F}_{\\pi}$\r\ndenote the $\\mathbb{F}_{\\pi}$-algebra $\\mathbb{F}_{\\pi}\\otimes\\mathcal{F}$\r\n(where $\\mathbb{F}_{\\pi}$ acts on the first tensorand).\r\n\r\nLet $h\\in\\mathcal{F}$ be such that $1\\otimes h\\in\\left(  1\\otimes\r\nT-\\alpha\\right)  \\mathcal{F}_{\\pi}$. (Notice that the $\\alpha$ here really\r\nmeans the element $\\alpha1_{\\mathcal{F}_{\\pi}}=\\alpha\\otimes1$ of\r\n$\\mathcal{F}_{\\pi}$.) Then, $h\\in\\pi\\mathcal{F}$.\r\n\\end{lemma}\r\n\r\n\\begin{remark}\r\n\\label{rmk.lem.F.u(pi).lem2.exp}Lemma \\ref{lem.F.u(pi).lem2} can be viewed as\r\na noncommutative version of the following known fact: If $h\\in\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ is such that $h\\in\\left(  T-\\alpha\\right)\r\n\\mathbb{F}_{\\pi}\\left[  T\\right]  $, then $h\\in\\pi\\mathbb{F}_{q}\\left[\r\nT\\right]  $. (That is, a polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $ that\r\nvanishes at $\\alpha$ must be a multiple of $\\pi$.)\r\n\\end{remark}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.u(pi).lem2}.]For each $i\\in\\mathbb{N}$, let\r\n$\\pi_{i}$ be the coefficient of $T^{i}$ in $\\pi$. For each $k\\in\\left\\{\r\n0,1,\\ldots,d\\right\\}  $, define a polynomial $p_{k}\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ by $p_{k}=\\sum_{i=k+1}^{d}\\pi_{i}T^{i-1-k}$. Then, Lemma\r\n\\ref{lem.F.u(pi).dividiff} \\textbf{(a)} (applied to $\\mathbb{K}=\\mathbb{F}%\r\n_{q}$) yields that $p_{d-1}=\\pi_{d}$ (a constant polynomial) and $p_{d}=0$.\r\nBut $\\pi_{d}=1$ (since $\\pi$ is a monic polynomial of degree $d$). Thus,\r\n$p_{d-1}=\\pi_{d}=1$.\r\n\r\nFurthermore, Lemma \\ref{lem.F.u(pi).dividiff} \\textbf{(b)} (applied to\r\n$\\mathbb{K}=\\mathbb{F}_{q}$) yields\r\n\\[\r\n\\pi\\left(  X\\right)  -\\pi\\left(  Y\\right)  =\\left(  X-Y\\right)  \\sum\r\n_{i=0}^{d-1}p_{i}\\left(  X\\right)  Y^{i}=\\left(  \\sum_{i=0}^{d-1}p_{i}\\left(\r\nX\\right)  Y^{i}\\right)  \\left(  X-Y\\right)\r\n\\]\r\nin the ring $\\mathbb{K}\\left[  X,Y\\right]  $. Since the two elements $1\\otimes\r\nT$ and $\\alpha$ of $\\mathcal{F}_{\\pi}$ commute with each other, we can\r\nsubstitute $1\\otimes T$ and $\\alpha$ for $X$ and $Y$ in this identity. We thus\r\nobtain%\r\n\\begin{align*}\r\n\\pi\\left(  1\\otimes T\\right)  -\\pi\\left(  \\alpha\\right)   &  =\\left(\r\n\\sum_{i=0}^{d-1}\\underbrace{p_{i}\\left(  1\\otimes T\\right)  }%\r\n_{\\substack{=1\\otimes p_{i}\\left(  T\\right)  =1\\otimes p_{i}\\\\\\text{(since\r\n}p_{i}\\left(  T\\right)  =p_{i}\\text{)}}}\\underbrace{\\alpha^{i}}%\r\n_{\\substack{=\\alpha^{i}\\otimes1\\\\\\text{(since }\\alpha^{i}\\in\\mathbb{F}_{\\pi\r\n}\\text{)}}}\\right)  \\left(  1\\otimes T-\\alpha\\right) \\\\\r\n&  =\\left(  \\sum_{i=0}^{d-1}\\underbrace{\\left(  1\\otimes p_{i}\\right)  \\left(\r\n\\alpha^{i}\\otimes1\\right)  }_{=\\alpha^{i}\\otimes p_{i}}\\right)  \\left(\r\n1\\otimes T-\\alpha\\right) \\\\\r\n&  =\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}\\right)  \\left(  1\\otimes\r\nT-\\alpha\\right)\r\n\\end{align*}\r\nin the ring $\\mathcal{F}_{\\pi}=\\mathbb{F}_{\\pi}\\otimes\\mathcal{F}$. Since\r\n$\\pi\\left(  1\\otimes T\\right)  -\\underbrace{\\pi\\left(  \\alpha\\right)  }%\r\n_{=0}=\\pi\\left(  1\\otimes T\\right)  =1\\otimes\\underbrace{\\pi\\left(  T\\right)\r\n}_{=\\pi}=1\\otimes\\pi$, this rewrites as\r\n\\begin{equation}\r\n1\\otimes\\pi=\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}\\right)  \\left(\r\n1\\otimes T-\\alpha\\right)  . \\label{pf.lem.F.u(pi).lem2.1}%\r\n\\end{equation}\r\n\r\n\r\nNow,\r\n\\begin{align}\r\n&  \\sum_{i=0}^{d-1}\\underbrace{\\alpha^{i}\\otimes p_{i}h}_{=\\left(  \\alpha\r\n^{i}\\otimes p_{i}\\right)  \\left(  1\\otimes h\\right)  }\\nonumber\\\\\r\n&  =\\sum_{i=0}^{d-1}\\left(  \\alpha^{i}\\otimes p_{i}\\right)  \\left(  1\\otimes\r\nh\\right)  =\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}\\right)\r\n\\underbrace{\\left(  1\\otimes h\\right)  }_{\\in\\left(  1\\otimes T-\\alpha\\right)\r\n\\mathcal{F}_{\\pi}}\\nonumber\\\\\r\n&  \\in\\underbrace{\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}\\right)\r\n\\left(  1\\otimes T-\\alpha\\right)  }_{\\substack{=1\\otimes\\pi\\\\\\text{(by\r\n(\\ref{pf.lem.F.u(pi).lem2.1}))}}}\\mathcal{F}_{\\pi}=\\left(  1\\otimes\\pi\\right)\r\n\\mathcal{F}_{\\pi}. \\label{pf.lem.F.u(pi).lem2.3}%\r\n\\end{align}\r\n\r\n\r\nBut Proposition \\ref{prop.F.u(pi).lem1} \\textbf{(a)} shows that the\r\n$\\mathbb{F}_{q}$-vector space $\\mathbb{F}_{\\pi}$ has basis $\\left(  \\alpha\r\n^{0},\\alpha^{1},\\ldots,\\alpha^{d-1}\\right)  $. Hence, we can define an\r\n$\\mathbb{F}_{q}$-linear map $\\lambda:\\mathbb{F}_{\\pi}\\rightarrow\\mathbb{F}%\r\n_{q}$ by%\r\n\\begin{equation}\r\n\\left(  \\lambda\\left(  \\alpha^{i}\\right)  =\\delta_{i,d-1}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }i\\in\\left\\{  0,1,\\ldots,d-1\\right\\}\r\n\\right)  . \\label{pf.lem.F.u(pi).lem2.lambda}%\r\n\\end{equation}\r\nConsider this $\\lambda$. The $\\mathbb{F}_{q}$-linear map $\\lambda\r\n:\\mathbb{F}_{\\pi}\\rightarrow\\mathbb{F}_{q}$ induces an $\\mathbb{F}_{q}$-linear\r\nmap $\\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}:\\mathbb{F}_{\\pi\r\n}\\otimes\\mathcal{F}\\rightarrow\\mathbb{F}_{q}\\otimes\\mathcal{F}$. In view of\r\n$\\mathbb{F}_{\\pi}\\otimes\\mathcal{F}=\\mathcal{F}_{\\pi}$ and $\\mathbb{F}%\r\n_{q}\\otimes\\mathcal{F}=\\mathcal{F}$, this latter map is thus an $\\mathbb{F}%\r\n_{q}$-linear map $\\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}%\r\n}:\\mathcal{F}_{\\pi}\\rightarrow\\mathcal{F}$. This map satisfies%\r\n\\begin{equation}\r\n\\left(  \\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)\r\n\\left(  \\left(  1\\otimes\\pi\\right)  \\mathcal{F}_{\\pi}\\right)  \\subseteq\r\n\\pi\\mathcal{F} \\label{pf.lem.F.u(pi).lem2.goesto}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.lem.F.u(pi).lem2.goesto}):} We have%\r\n\\begin{align*}\r\n&  \\left(  \\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)\r\n\\left(  \\left(  1\\otimes\\pi\\right)  \\underbrace{\\mathcal{F}_{\\pi}%\r\n}_{=\\mathbb{F}_{\\pi}\\otimes\\mathcal{F}}\\right) \\\\\r\n&  =\\left(  \\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)\r\n\\underbrace{\\left(  \\left(  1\\otimes\\pi\\right)  \\left(  \\mathbb{F}_{\\pi\r\n}\\otimes\\mathcal{F}\\right)  \\right)  }_{\\substack{=\\mathbb{F}_{\\pi}\\otimes\r\n\\pi\\mathcal{F}\\\\\\text{(seen as a subspace of }\\mathbb{F}_{\\pi}\\otimes\r\n\\mathcal{F}\\text{)}}}=\\left(  \\lambda\\otimes\\operatorname*{id}%\r\n\\nolimits_{\\mathcal{F}}\\right)  \\left(  \\mathbb{F}_{\\pi}\\otimes\\pi\r\n\\mathcal{F}\\right) \\\\\r\n&  =\\underbrace{\\lambda\\left(  \\mathbb{F}_{\\pi}\\right)  }_{\\subseteq\r\n\\mathbb{F}_{q}}\\otimes\\underbrace{\\operatorname*{id}\\nolimits_{\\mathcal{F}%\r\n}\\left(  \\pi\\mathcal{F}\\right)  }_{=\\pi\\mathcal{F}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{seen as a subspace of }\\mathbb{F}_{q}\\otimes\\mathcal{F}\\right) \\\\\r\n&  \\subseteq\\mathbb{F}_{q}\\otimes\\pi\\mathcal{F}=\\pi\\mathcal{F}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{using our identification of }\\mathbb{F}%\r\n_{q}\\otimes\\mathcal{F}\\text{ with }\\mathcal{F}\\right)  ,\r\n\\end{align*}\r\nqed.}. Now, applying the map $\\lambda\\otimes\\operatorname*{id}%\r\n\\nolimits_{\\mathcal{F}}$ to both sides of the equality\r\n(\\ref{pf.lem.F.u(pi).lem2.3}), we obtain%\r\n\\[\r\n\\left(  \\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)\r\n\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}h\\right)  \\in\\left(\r\n\\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)  \\left(\r\n\\left(  1\\otimes\\pi\\right)  \\mathcal{F}_{\\pi}\\right)  \\subseteq\\pi\\mathcal{F}%\r\n\\]\r\n(by (\\ref{pf.lem.F.u(pi).lem2.goesto})). Since%\r\n\\begin{align*}\r\n&  \\left(  \\lambda\\otimes\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\right)\r\n\\left(  \\sum_{i=0}^{d-1}\\alpha^{i}\\otimes p_{i}h\\right) \\\\\r\n&  =\\sum_{i=0}^{d-1}\\underbrace{\\lambda\\left(  \\alpha^{i}\\right)\r\n}_{\\substack{=\\delta_{i,d-1}\\\\\\text{(by (\\ref{pf.lem.F.u(pi).lem2.lambda}))}%\r\n}}\\otimes\\underbrace{\\operatorname*{id}\\nolimits_{\\mathcal{F}}\\left(\r\np_{i}h\\right)  }_{=p_{i}h}=\\sum_{i=0}^{d-1}\\delta_{i,d-1}\\otimes p_{i}h\\\\\r\n&  =\\sum_{i=0}^{d-1}\\delta_{i,d-1}p_{i}h\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{using our identification of }\\mathbb{F}_{q}\\otimes\\mathcal{F}\\text{ with\r\n}\\mathcal{F}\\right) \\\\\r\n&  =\\sum_{i=0}^{d-2}\\underbrace{\\delta_{i,d-1}}_{\\substack{=0\\\\\\text{(since\r\n}i\\neq d-1\\\\\\text{(since }i\\leq d-2\\text{))}}}p_{i}h+\\underbrace{\\delta\r\n_{d-1,d-1}}_{=1}\\underbrace{p_{d-1}}_{=1}h=\\underbrace{\\sum_{i=0}^{d-2}%\r\n0p_{i}h}_{=0}+h=h,\r\n\\end{align*}\r\nthis rewrites as $h\\in\\pi\\mathcal{F}$. This proves Lemma\r\n\\ref{lem.F.u(pi).lem2}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.u(pi).prod-deform}Let $R$ be a ring (not necessarily\r\ncommutative). If $b_{0},b_{1},\\ldots,b_{d-1}$ are some elements of $R$ (for\r\nsome $d\\in\\mathbb{N}$), then the product $\\prod_{k=0}^{d-1}b_{k}$ shall be\r\ndefined as $b_{0}b_{1}\\cdots b_{d-1}$. (Thus, we have defined this product\r\neven if the elements $b_{0},b_{1},\\ldots,b_{d-1}$ do not commute.)\r\n\r\nLet $r\\in\\mathbb{N}$. Let $f$, $t$ and $a$ be three elements of $R$ satisfying\r\n$ft=t^{r}f$, $fa=af$ and $ta=at$. Let $d\\in\\mathbb{N}$. Then, every\r\n$d\\in\\mathbb{N}$ satisfies%\r\n\\begin{equation}\r\n\\prod_{k=0}^{d-1}\\left(  f+t-a^{r^{k}}\\right)  \\equiv f^{d}\\operatorname{mod}%\r\n\\left(  t-a\\right)  R. \\label{eq.lem.F.u(pi).prod-deform.1}%\r\n\\end{equation}\r\n(Note that $\\left(  t-a\\right)  R$ is only a right ideal of $R$, not\r\nnecessarily an ideal of $R$.)\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.u(pi).prod-deform}.]We have%\r\n\\begin{equation}\r\nf^{i}t=t^{r^{i}}f^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }i\\in\\mathbb{N}.\r\n\\label{pf.lem.F.u(pi).prod-deform.1}%\r\n\\end{equation}\r\n(This can be proven by a straightforward induction on $i$, using the relation\r\n$ft=t^{r}f$.) Also, the relation $fa=af$ shows that the $\\mathbb{Z}%\r\n$-subalgebra of $R$ generated by $a$ and $f$ is commutative. Thus, every\r\n$i\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$ satisfy%\r\n\\begin{equation}\r\nf^{i}a^{j}=a^{j}f^{i} \\label{pf.lem.F.u(pi).prod-deform.2}%\r\n\\end{equation}\r\n(since both $f^{i}$ and $a^{j}$ belong to this commutative $\\mathbb{Z}$-subalgebra).\r\n\r\nMoreover, every $i\\in\\mathbb{N}$ satisfies%\r\n\\begin{equation}\r\nt^{i}-a^{i}\\equiv0\\operatorname{mod}\\left(  t-a\\right)  R\r\n\\label{pf.lem.F.u(pi).prod-deform.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.lem.F.u(pi).prod-deform.3}):} Let\r\n$i\\in\\mathbb{N}$. Then, a known formula shows that $X^{i}-Y^{i}=\\left(\r\nX-Y\\right)  \\sum_{k=0}^{i-1}X^{k}Y^{i-1-k}$ in the polynomial ring\r\n$\\mathbb{Z}\\left[  X,Y\\right]  $. Since the elements $t$ and $a$ of $R$\r\ncommute (because $ta=at$), we can substitute $t$ and $a$ for $X$ and $Y$ in\r\nthis formula. We thus obtain%\r\n\\[\r\nt^{i}-a^{i}=\\left(  t-a\\right)  \\underbrace{\\sum_{k=0}^{i-1}t^{k}a^{i-1-k}%\r\n}_{\\in R}\\in\\left(  t-a\\right)  R.\r\n\\]\r\nIn other words, $t^{i}-a^{i}\\equiv0\\operatorname{mod}\\left(  t-a\\right)  R$.\r\nThis proves (\\ref{pf.lem.F.u(pi).prod-deform.3}).}.\r\n\r\nWe shall prove (\\ref{eq.lem.F.u(pi).prod-deform.1}) by induction over $d$:\r\n\r\n\\textit{Induction base:} For $d=0$, the congruence\r\n(\\ref{eq.lem.F.u(pi).prod-deform.1}) is obviously true (because both sides of\r\nthis congruence equal $1$). This completes the induction base.\r\n\r\n\\textit{Induction step:} Let $D\\in\\mathbb{N}$. Assume that\r\n(\\ref{eq.lem.F.u(pi).prod-deform.1}) holds for $d=D$. We must prove that\r\n(\\ref{eq.lem.F.u(pi).prod-deform.1}) holds for $d=D+1$.\r\n\r\nWe have assumed that (\\ref{eq.lem.F.u(pi).prod-deform.1}) holds for $d=D$. In\r\nother words,%\r\n\\begin{equation}\r\n\\prod_{k=0}^{D-1}\\left(  f+t-a^{r^{k}}\\right)  \\equiv f^{D}\\operatorname{mod}%\r\n\\left(  t-a\\right)  R. \\label{pf.lem.F.u(pi).prod-deform.indhyp}%\r\n\\end{equation}\r\n\r\n\r\nNow,%\r\n\\begin{align*}\r\n\\prod_{k=0}^{D}\\left(  f+t-a^{r^{k}}\\right)   &  =\\underbrace{\\left(\r\n\\prod_{k=0}^{D-1}\\left(  f+t-a^{r^{k}}\\right)  \\right)  }_{\\substack{\\equiv\r\nf^{D}\\operatorname{mod}\\left(  t-a\\right)  R\\\\\\text{(by\r\n(\\ref{pf.lem.F.u(pi).prod-deform.indhyp}))}}}\\left(  f+t-a^{r^{D}}\\right) \\\\\r\n&  \\equiv f^{D}\\left(  f+t-a^{r^{D}}\\right)  =\\underbrace{f^{D}f}_{=f^{D+1}%\r\n}+\\underbrace{f^{D}t}_{\\substack{=t^{r^{D}}f^{D}\\\\\\text{(by\r\n(\\ref{pf.lem.F.u(pi).prod-deform.1}), applied to }i=D\\text{)}}%\r\n}-\\underbrace{f^{D}a^{r^{D}}}_{\\substack{=a^{r^{D}}f^{D}\\\\\\text{(by\r\n(\\ref{pf.lem.F.u(pi).prod-deform.2}), applied to}\\\\i=D\\text{ and }%\r\nj=r^{D}\\text{)}}}\\\\\r\n&  =f^{D+1}+\\underbrace{t^{r^{D}}f^{D}-a^{r^{D}}f^{D}}_{=\\left(  t^{r^{D}%\r\n}-a^{r^{D}}\\right)  f^{D}}=f^{D+1}+\\underbrace{\\left(  t^{r^{D}}-a^{r^{D}%\r\n}\\right)  }_{\\substack{\\equiv0\\operatorname{mod}\\left(  t-a\\right)\r\nR\\\\\\text{(by (\\ref{pf.lem.F.u(pi).prod-deform.3}), applied to }i=r^{D}%\r\n\\text{)}}}f^{D}\\\\\r\n&  \\equiv f^{D+1}\\operatorname{mod}\\left(  t-a\\right)  R.\r\n\\end{align*}\r\nIn other words, (\\ref{eq.lem.F.u(pi).prod-deform.1}) holds for $d=D+1$. This\r\ncompletes the induction step. Hence, (\\ref{eq.lem.F.u(pi).prod-deform.1}) is\r\nproven by induction. In other words, Lemma \\ref{lem.F.u(pi).prod-deform} is proven.\r\n\\end{proof}\r\n\r\nNow we can prove Proposition \\ref{prop.F.u(pi)} again:\r\n\r\n\\begin{proof}\r\n[Second proof of Proposition \\ref{prop.F.u(pi)}.]The left $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module $\\mathcal{F}$ is free (by Proposition\r\n\\ref{prop.F.bases} \\textbf{(c)}), and thus torsionfree.\r\n\r\nDefine $d$, $\\mathbb{F}_{\\pi}$, $\\alpha$ and $\\mathcal{F}_{\\pi}$ as in Lemma\r\n\\ref{lem.F.u(pi).lem2}. Define $h\\in\\mathcal{F}$ by $h=\\operatorname*{Carl}%\r\n\\pi-F^{\\deg\\pi}$. We shall show that $h\\in\\pi\\mathcal{F}$.\r\n\r\nRecall that $\\operatorname*{Carl}$ is the $\\mathbb{F}_{q}$-algebra\r\nhomomorphism $\\mathbb{F}_{q}\\left[  T\\right]  \\rightarrow\\mathcal{F}$ sending\r\n$T$ to $F+T$. This homomorphism sends every polynomial $g\\in\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ to $g\\left(  F+T\\right)  $ (where $g\\left(\r\nF+T\\right)  $ denotes the result of substituting $F+T$ for $T$ in $g$, not the\r\nproduct of $g$ with $F+T$). In other words, $\\operatorname*{Carl}g=g\\left(\r\nF+T\\right)  $ for every $g\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Applying this\r\nto $g=\\pi$, we obtain $\\operatorname*{Carl}\\pi=\\pi\\left(  F+T\\right)  $.\r\n\r\nNow, we can substitute $1\\otimes F+1\\otimes T\\in\\mathcal{F}_{\\pi}$ for $T$ in\r\nthe equality (\\ref{eq.prop.F.u(pi).lem1.c}) (since $1\\otimes F+1\\otimes T$ is\r\nan element of the $\\mathbb{F}_{\\pi}$-algebra $\\mathcal{F}_{\\pi}$). As a\r\nresult, we obtain%\r\n\\begin{equation}\r\n\\pi\\left(  1\\otimes F+1\\otimes T\\right)  =\\prod_{k=0}^{d-1}\\left(  1\\otimes\r\nF+1\\otimes T-\\alpha^{q^{k}}\\right)  . \\label{pf.prop.F.u(pi).2nd.1}%\r\n\\end{equation}\r\n\r\n\r\nBut the elements $1\\otimes F$, $1\\otimes T$ and $\\alpha$ of $\\mathcal{F}_{\\pi\r\n}$ satisfy%\r\n\\begin{align*}\r\n\\left(  1\\otimes F\\right)  \\left(  1\\otimes T\\right)   &  =1\\otimes\r\n\\underbrace{FT}_{=T^{q}F}=1\\otimes T^{q}F=\\left(  1\\otimes T\\right)\r\n^{q}\\left(  1\\otimes F\\right)  ,\\\\\r\n\\left(  1\\otimes F\\right)  \\alpha &  =\\alpha\\left(  1\\otimes F\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\alpha\\text{ really means }%\r\n\\alpha\\otimes1\\in\\mathcal{F}_{\\pi}\\right)  ,\\\\\r\n\\left(  1\\otimes T\\right)  \\alpha &  =\\alpha\\left(  1\\otimes T\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\alpha\\text{ really means }%\r\n\\alpha\\otimes1\\in\\mathcal{F}_{\\pi}\\right)  .\r\n\\end{align*}\r\nHence, Lemma \\ref{lem.F.u(pi).prod-deform} (applied to $R=\\mathcal{F}_{\\pi}$,\r\n$r=q$, $f=1\\otimes F$, $t=1\\otimes T$ and $a=\\alpha$) yields%\r\n\\[\r\n\\prod_{k=0}^{d-1}\\left(  1\\otimes F+1\\otimes T-\\alpha^{q^{k}}\\right)\r\n\\equiv\\left(  1\\otimes F\\right)  ^{d}=1\\otimes F^{d}\\operatorname{mod}\\left(\r\n1\\otimes T-\\alpha\\right)  \\mathcal{F}_{\\pi}.\r\n\\]\r\nHence, (\\ref{pf.prop.F.u(pi).2nd.1}) becomes%\r\n\\begin{align*}\r\n\\pi\\left(  1\\otimes F+1\\otimes T\\right)   &  =\\prod_{k=0}^{d-1}\\left(\r\n1\\otimes F+1\\otimes T-\\alpha^{q^{k}}\\right) \\\\\r\n&  \\equiv1\\otimes F^{d}\\operatorname{mod}\\left(  1\\otimes T-\\alpha\\right)\r\n\\mathcal{F}_{\\pi}.\r\n\\end{align*}\r\nSince\r\n\\[\r\n\\pi\\left(  \\underbrace{1\\otimes F+1\\otimes T}_{=1\\otimes\\left(  F+T\\right)\r\n}\\right)  =\\pi\\left(  1\\otimes\\left(  F+T\\right)  \\right)  =1\\otimes\\pi\\left(\r\nF+T\\right)  ,\r\n\\]\r\nthis rewrites as%\r\n\\begin{equation}\r\n1\\otimes\\pi\\left(  F+T\\right)  \\equiv1\\otimes F^{d}\\operatorname{mod}\\left(\r\n1\\otimes T-\\alpha\\right)  \\mathcal{F}_{\\pi}. \\label{pf.prop.F.u(pi).2nd.5}%\r\n\\end{equation}\r\nNow, $h=\\underbrace{\\operatorname*{Carl}\\pi}_{=\\pi\\left(  F+T\\right)\r\n}-\\underbrace{F^{\\deg\\pi}}_{\\substack{=F^{d}\\\\\\text{(since }\\deg\\pi=d\\text{)}%\r\n}}=\\pi\\left(  F+T\\right)  -F^{d}$, so that%\r\n\\[\r\n1\\otimes h=1\\otimes\\left(  \\pi\\left(  F+T\\right)  -F^{d}\\right)  =1\\otimes\r\n\\pi\\left(  F+T\\right)  -1\\otimes F^{d}\\in\\left(  1\\otimes T-\\alpha\\right)\r\n\\mathcal{F}_{\\pi}%\r\n\\]\r\n(by (\\ref{pf.prop.F.u(pi).2nd.5})). Hence, Lemma \\ref{lem.F.u(pi).lem2} shows\r\nthat $h\\in\\pi\\mathcal{F}$. Hence, there exists at least one $u\\left(\r\n\\pi\\right)  \\in\\mathcal{F}$ such that $\\pi\\cdot u\\left(  \\pi\\right)  =h$.\r\nMoreover, such a $u\\left(  \\pi\\right)  $ is clearly unique (because any\r\nelement $u\\left(  \\pi\\right)  \\in\\mathcal{F}$ is uniquely determined by\r\n$\\pi\\cdot u\\left(  \\pi\\right)  $ (since $\\pi\\neq0$, and since the left\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module $\\mathcal{F}$ is torsionfree)).\r\nThus, there exists a \\textbf{unique} $u\\left(  \\pi\\right)  \\in\\mathcal{F}$\r\nsuch that $\\pi\\cdot u\\left(  \\pi\\right)  =h$. In other words, there exists a\r\n\\textbf{unique} $u\\left(  \\pi\\right)  \\in\\mathcal{F}$ such that\r\n$\\operatorname*{Carl}\\pi=F^{\\deg\\pi}+\\pi\\cdot u\\left(  \\pi\\right)  $ (because\r\nwe have the logical equivalence%\r\n\\begin{align*}\r\n\\left(  \\pi\\cdot u\\left(  \\pi\\right)  =\\underbrace{h}_{=\\operatorname*{Carl}%\r\n\\pi-F^{\\deg\\pi}}\\right)  \\  &  \\Longleftrightarrow\\ \\left(  \\pi\\cdot u\\left(\r\n\\pi\\right)  =\\operatorname*{Carl}\\pi-F^{\\deg\\pi}\\right) \\\\\r\n&  \\Longleftrightarrow\\ \\left(  \\operatorname*{Carl}\\pi=F^{\\deg\\pi}+\\pi\\cdot\r\nu\\left(  \\pi\\right)  \\right)\r\n\\end{align*}\r\n). This proves Proposition \\ref{prop.F.u(pi)} again.\r\n\\end{proof}\r\n\r\n\\begin{remark}\r\nNow that we have a proof of Proposition \\ref{prop.F.u(pi)} that is independent\r\nof \\cite[Theorem 2.11]{kc-carlitz}, we can turn the cart around and give a new\r\nproof of \\cite[Theorem 2.11, last equality]{kc-carlitz} (though this proof, of\r\ncourse, will be rather roundabout):\r\n\r\nLet $\\pi$ be a monic irreducible polynomial in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. Our goal is to show that $\\overline{\\left[  \\pi\\right]  }\\left(\r\nX\\right)  =X^{q^{\\deg\\pi}}$, where $\\overline{\\left[  \\pi\\right]  }\\left(\r\nX\\right)  $ denotes the projection of $\\left[  \\pi\\right]  \\left(  X\\right)\r\n=\\left[  \\pi\\right]  \\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $\r\nonto $\\left(  \\mathbb{F}_{q}\\left[  T\\right]  /\\pi\\right)  \\left[  X\\right]  $.\r\n\r\nWe have $X^{q^{\\deg\\pi}}=\\operatorname*{Fqpol}\\left(  F^{\\deg\\pi}\\right)  $.\r\n(This can be proven as in our first proof of Proposition \\ref{prop.F.u(pi)}.)\r\nAlso, $\\operatorname*{Fqpol}$ is an isomorphism of left $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules (according to Proposition \\ref{prop.q-pol.Fqlin.leftT}).\r\n\r\nProposition \\ref{prop.F.u(pi)} shows that there exists a unique $u\\left(\r\n\\pi\\right)  \\in\\mathcal{F}$ such that $\\operatorname*{Carl}\\pi=F^{\\deg\\pi}%\r\n+\\pi\\cdot u\\left(  \\pi\\right)  $. Consider this $u\\left(  \\pi\\right)  $.\r\nCorollary \\ref{cor.F.carlitz.img} (applied to $M=\\pi$) yields\r\n\\begin{align*}\r\n\\left[  \\pi\\right]   &  =\\operatorname*{Fqpol}\\left(\r\n\\underbrace{\\operatorname*{Carl}\\pi}_{=F^{\\deg\\pi}+\\pi\\cdot u\\left(\r\n\\pi\\right)  }\\right)  =\\operatorname*{Fqpol}\\left(  F^{\\deg\\pi}+\\pi\\cdot\r\nu\\left(  \\pi\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  \\operatorname*{Fqpol}\\left(  F^{\\deg\\pi}\\right)\r\n\\right)  }_{=X^{q^{\\deg\\pi}}}+\\pi\\underbrace{\\operatorname*{Fqpol}\\left(\r\nu\\left(  \\pi\\right)  \\right)  }_{\\in\\mathbb{F}_{q}\\left[  T\\right]  \\left[\r\nX\\right]  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{Fqpol}\\text{ is a\r\nhomomorphism of left }\\mathbb{F}_{q}\\left[  T\\right]  \\text{-modules}\\right)\r\n\\\\\r\n&  \\in X^{q^{\\deg\\pi}}+\\pi\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  .\r\n\\end{align*}\r\nIn other words, $\\left[  \\pi\\right]  \\equiv X^{q^{\\deg\\pi}}\\operatorname{mod}%\r\n\\pi\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  $. Projecting both sides\r\nof this congruence down to $\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]\r\n/\\left(  \\pi\\mathbb{F}_{q}\\left[  T\\right]  \\left[  X\\right]  \\right)\r\n=\\left(  \\mathbb{F}_{q}\\left[  T\\right]  /\\pi\\right)  \\left[  X\\right]  $, we\r\nobtain $\\overline{\\left[  \\pi\\right]  }=X^{q^{\\deg\\pi}}$. In other words,\r\n$\\overline{\\left[  \\pi\\right]  }\\left(  X\\right)  =X^{q^{\\deg\\pi}}$, qed.\r\n\\end{remark}\r\n\r\n\\subsection{Corollary: Carlitz action vs. Frobenius power}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.u(pi).mod}Let $\\pi$ be a monic irreducible polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Let $A$ be an $\\mathcal{F}$-module. Then,\r\n$\\left(  \\operatorname*{Carl}\\pi\\right)  a\\equiv F^{\\deg\\pi}%\r\na\\operatorname{mod}\\pi A$ for every $a\\in A$.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F.u(pi).mod}.]Let $a\\in A$. Proposition\r\n\\ref{prop.F.u(pi)} shows that there exists a unique $u\\left(  \\pi\\right)\r\n\\in\\mathcal{F}$ such that $\\operatorname*{Carl}\\pi=F^{\\deg\\pi}+\\pi\\cdot\r\nu\\left(  \\pi\\right)  $. Consider this $u\\left(  \\pi\\right)  $.\r\n\r\nNow,%\r\n\\[\r\n\\underbrace{\\left(  \\operatorname*{Carl}\\pi\\right)  }_{=F^{\\deg\\pi}+\\pi\\cdot\r\nu\\left(  \\pi\\right)  }a=\\left(  F^{\\deg\\pi}+\\pi\\cdot u\\left(  \\pi\\right)\r\n\\right)  a=F^{\\deg\\pi}a+\\underbrace{\\pi\\cdot u\\left(  \\pi\\right)  a}%\r\n_{\\equiv0\\operatorname{mod}\\pi A}\\equiv F^{\\deg\\pi}a\\operatorname{mod}\\pi A.\r\n\\]\r\nThis proves Corollary \\ref{cor.F.u(pi).mod}.\r\n\\end{proof}\r\n\r\n\\subsection{Exponent lifting for $\\mathcal{F}$-modules}\r\n\r\nNext, we shall show a series of simple propositions which will culminate (if\r\nthis can be called a culmination) in a Carlitz analogue of the classical\r\n\\textquotedblleft lifting the exponent\\textquotedblright\\ theorem (see, e.g.,\r\n\\cite[version with solutions (ancillary file), (12.68.8)]{reiner-hopf} for it).\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.lift.CarlP-P}\\textbf{(a)} The $\\mathbb{F}_{q}$-vector subspace\r\n$\\mathcal{F}F$ of $\\mathcal{F}$ is a two-sided ideal of $\\mathcal{F}$.\r\n\r\n\\textbf{(b)} Let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then,\r\n$\\operatorname*{Carl}P\\equiv P\\operatorname{mod}\\mathcal{F}F$.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.lift.CarlP-P}.]\\textbf{(a)} First, we claim\r\nthat%\r\n\\begin{equation}\r\nFu\\in\\mathcal{F}F\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\mathcal{F}.\r\n\\label{pf.prop.F.lift.CarlP-P.a.1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{pf.prop.F.lift.CarlP-P.a.1}):} Proposition\r\n\\ref{prop.F.bases} \\textbf{(b)} shows that the $\\mathbb{F}_{q}$-module\r\n$\\mathcal{F}$ is free with basis $\\left(  T^{j}F^{i}\\right)  _{i\\geq\r\n0,\\ j\\geq0}$.\r\n\r\nLet $u\\in\\mathcal{F}$. We must prove the relation\r\n(\\ref{pf.prop.F.lift.CarlP-P.a.1}). Since this relation is $\\mathbb{F}_{q}%\r\n$-linear in $u$ (because $\\mathcal{F}F$ is an $\\mathbb{F}_{q}$-vector subspace\r\nof $\\mathcal{F}$), we can WLOG assume that $u$ belongs to the basis $\\left(\r\nT^{j}F^{i}\\right)  _{i\\geq0,\\ j\\geq0}$ of the $\\mathbb{F}_{q}$-module\r\n$\\mathcal{F}$. Assume this. Thus, $u=T^{j}F^{i}$ for some $i\\in\\mathbb{N}$ and\r\n$j\\in\\mathbb{N}$. Consider these $i$ and $j$. Now,%\r\n\\[\r\nF\\underbrace{u}_{=T^{j}F^{i}}=\\underbrace{FT^{j}}_{\\substack{=\\left(\r\nT^{j}\\right)  ^{q}F\\\\\\text{(by Proposition \\ref{prop.F.FP},}\\\\\\text{applied to\r\n}P=T^{j}\\text{)}}}F^{i}=\\left(  T^{j}\\right)  ^{q}\\underbrace{FF^{i}%\r\n}_{=F^{i+1}=F^{i}F}=\\underbrace{\\left(  T^{j}\\right)  ^{q}F^{i}}%\r\n_{\\in\\mathcal{F}}F\\in\\mathcal{F}F.\r\n\\]\r\nThis proves (\\ref{pf.prop.F.lift.CarlP-P.a.1}).\r\n\r\nNow,\r\n\\[\r\nF\\mathcal{F}=\\left\\{  Fu\\ \\mid\\ u\\in\\mathcal{F}\\right\\}  \\subseteq\r\n\\mathcal{F}F\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{pf.prop.F.lift.CarlP-P.a.1})}\\right)  .\r\n\\]\r\n\r\n\r\nBut it is clear that $\\mathcal{F}F$ is a left ideal of $\\mathcal{F}$. Since we\r\nfurthermore have $\\mathcal{F}\\underbrace{F\\cdot\\mathcal{F}}_{=F\\mathcal{F}%\r\n\\subseteq\\mathcal{F}F}\\subseteq\\underbrace{\\mathcal{FF}}_{\\subseteq\r\n\\mathcal{F}}F\\subseteq\\mathcal{F}F$, we thus conclude that $\\mathcal{F}F$ is a\r\ntwo-sided ideal of $\\mathcal{F}$. This proves Proposition\r\n\\ref{prop.F.lift.CarlP-P} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Proposition \\ref{prop.F.lift.CarlP-P} \\textbf{(a)} shows that\r\n$\\mathcal{F}F$ is a two-sided ideal of $\\mathcal{F}$. Hence, $\\mathcal{F}%\r\n/\\left(  \\mathcal{F}F\\right)  $ is a quotient ring of $\\mathcal{F}$, hence a\r\nquotient $\\mathbb{F}_{q}$-algebra of $\\mathcal{F}$. Let $\\pi$ denote the\r\ncanonical projection map $\\mathcal{F}\\rightarrow\\mathcal{F}/\\left(\r\n\\mathcal{F}F\\right)  $. Then, $\\pi$ is an $\\mathbb{F}_{q}$-algebra\r\nhomomorphism (since $\\mathcal{F}/\\left(  \\mathcal{F}F\\right)  $ is a quotient\r\n$\\mathbb{F}_{q}$-algebra of $\\mathcal{F}$).\r\n\r\nBut $\\operatorname*{Carl}\\left(  T\\right)  =F+T\\equiv T\\operatorname{mod}%\r\n\\mathcal{F}F$ (since $F=\\underbrace{1}_{\\in\\mathcal{F}}F\\in\\mathcal{F}F$). In\r\nother words, $\\pi\\left(  \\operatorname*{Carl}\\left(  T\\right)  \\right)\r\n=\\pi\\left(  T\\right)  $ (since $\\pi$ is the canonical projection map\r\n$\\mathcal{F}\\rightarrow\\mathcal{F}/\\left(  \\mathcal{F}F\\right)  $). Thus,\r\n\\begin{align}\r\n\\left(  \\pi\\circ\\operatorname*{Carl}\\right)  \\left(  T\\right)   &  =\\pi\\left(\r\n\\operatorname*{Carl}\\left(  T\\right)  \\right)  =\\pi\\left(  \\underbrace{T}%\r\n_{=\\operatorname*{Finc}\\nolimits_{T}\\left(  T\\right)  }\\right)  =\\pi\\left(\r\n\\operatorname*{Finc}\\nolimits_{T}\\left(  T\\right)  \\right) \\nonumber\\\\\r\n&  =\\left(  \\pi\\circ\\operatorname*{Finc}\\nolimits_{T}\\right)  \\left(\r\nT\\right)  . \\label{pf.prop.F.lift.CarlP-P.b.1}%\r\n\\end{align}\r\n\r\n\r\nBut the three maps $\\pi$, $\\operatorname*{Carl}$ and $\\operatorname*{Finc}%\r\n\\nolimits_{T}$ are $\\mathbb{F}_{q}$-algebra homomorphisms; hence, $\\pi\r\n\\circ\\operatorname*{Carl}$ and $\\pi\\circ\\operatorname*{Finc}\\nolimits_{T}$ are\r\n$\\mathbb{F}_{q}$-algebra homomorphisms as well. The two $\\mathbb{F}_{q}%\r\n$-algebra homomorphisms $\\pi\\circ\\operatorname*{Carl}:\\mathbb{F}_{q}\\left[\r\nT\\right]  \\rightarrow\\mathcal{F}/\\left(  \\mathcal{F}F\\right)  $ and $\\pi\r\n\\circ\\operatorname*{Finc}\\nolimits_{T}:\\mathbb{F}_{q}\\left[  T\\right]\r\n\\rightarrow\\mathcal{F}/\\left(  \\mathcal{F}F\\right)  $ are equal to each other\r\non the generator $T$ of the $\\mathbb{F}_{q}$-algebra $\\mathbb{F}_{q}\\left[\r\nT\\right]  $ (because of (\\ref{pf.prop.F.lift.CarlP-P.b.1})). Therefore, these\r\ntwo homomorphisms must be identical. In other words, $\\pi\\circ\r\n\\operatorname*{Carl}=\\pi\\circ\\operatorname*{Finc}\\nolimits_{T}$.\r\n\r\nNow,\r\n\\[\r\n\\pi\\left(  \\operatorname*{Carl}P\\right)  =\\underbrace{\\left(  \\pi\r\n\\circ\\operatorname*{Carl}\\right)  }_{=\\pi\\circ\\operatorname*{Finc}%\r\n\\nolimits_{T}}\\left(  P\\right)  =\\left(  \\pi\\circ\\operatorname*{Finc}%\r\n\\nolimits_{T}\\right)  \\left(  P\\right)  =\\pi\\left(\r\n\\underbrace{\\operatorname*{Finc}\\nolimits_{T}\\left(  P\\right)  }%\r\n_{\\substack{=P\\\\\\text{(since we are regarding the}\\\\\\text{map }%\r\n\\operatorname*{Finc}\\nolimits_{T}\\text{ as an inclusion)}}}\\right)\r\n=\\pi\\left(  P\\right)  .\r\n\\]\r\nIn other words, $\\operatorname*{Carl}P\\equiv P\\operatorname{mod}\\mathcal{F}F$\r\n(since $\\pi$ is the canonical projection map $\\mathcal{F}\\rightarrow\r\n\\mathcal{F}/\\left(  \\mathcal{F}F\\right)  $). This proves Proposition\r\n\\ref{prop.F.lift.CarlP-P} \\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.lift.FPA}Let $A$ be an $\\mathcal{F}$-module. Let $P\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\n\\textbf{(a)} We have $FPA\\subseteq P^{q}A$.\r\n\r\n\\textbf{(b)} The $\\mathbb{F}_{q}$-vector subspace $PA$ of $A$ is a left\r\n$\\mathcal{F}$-submodule of $A$.\r\n\r\n\\textbf{(c)} Let $k$ be a positive integer. Then, $FP^{k}A\\subseteq P^{k+1}A$.\r\n\r\n\\textbf{(d)} Let $k$ be a positive integer. Then, $\\left(\r\n\\operatorname*{Carl}P\\right)  P^{k}A\\subseteq P^{k+1}A$.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.lift.FPA}.]\\textbf{(a)} Proposition\r\n\\ref{prop.F.FP} yields $FP=P^{q}F$ in $\\mathcal{F}$. Hence, $\\underbrace{FP}%\r\n_{=P^{q}F}A=P^{q}\\underbrace{FA}_{\\subseteq A}\\subseteq P^{q}A$. Thus,\r\nProposition \\ref{prop.F.lift.FPA} \\textbf{(a)} is proven.\r\n\r\n\\textbf{(b)} Proposition \\ref{prop.F.lift.FPA} \\textbf{(a)} yields\r\n$FPA\\subseteq\\underbrace{P^{q}}_{\\substack{=PP^{q-1}\\\\\\text{(since }%\r\nq\\geq1\\text{)}}}A=P\\underbrace{P^{q-1}A}_{\\subseteq A}\\subseteq PA$. Also,\r\n$\\underbrace{TP}_{=PT}A=P\\underbrace{TA}_{\\subseteq A}\\subseteq PA$.\r\n\r\nNow, recall that the $\\mathbb{F}_{q}$-algebra $\\mathcal{F}$ is generated by\r\n$F$ and $T$. From this, it is easy to derive the following fact: If\r\n$\\mathcal{V}$ is an $\\mathbb{F}_{q}$-vector subspace of some left\r\n$\\mathcal{F}$-module $\\mathcal{U}$ satisfying $F\\mathcal{V}\\subseteq\r\n\\mathcal{V}$ and $T\\mathcal{V}\\subseteq\\mathcal{V}$, then $\\mathcal{V}$ is a\r\nleft $\\mathcal{F}$-submodule of $\\mathcal{U}$. Applying this to $\\mathcal{U}%\r\n=A$ and $\\mathcal{V}=PA$, we conclude that $PA$ is a left $\\mathcal{F}%\r\n$-submodule of $A$ (since $FPA\\subseteq PA$ and $TPA\\subseteq PA$).\r\nProposition \\ref{prop.F.lift.FPA} \\textbf{(b)} is thus shown.\r\n\r\n\\textbf{(c)} Proposition \\ref{prop.F.lift.FPA} \\textbf{(a)} (applied to\r\n$P^{k}$ instead of $P$) yields%\r\n\\begin{align*}\r\nFP^{k}A  &  \\subseteq\\underbrace{\\left(  P^{k}\\right)  ^{q}}%\r\n_{\\substack{=\\left(  P^{k}\\right)  ^{2}\\left(  P^{k}\\right)  ^{q-2}%\r\n\\\\\\text{(since }q\\geq2\\text{)}}}A=\\left(  P^{k}\\right)  ^{2}%\r\n\\underbrace{\\left(  P^{k}\\right)  ^{q-2}A}_{\\subseteq A}\\subseteq\\left(\r\nP^{k}\\right)  ^{2}A=P^{k}\\underbrace{P^{k}}_{\\substack{=PP^{k-1}\\\\\\text{(since\r\n}k\\text{ is a positive}\\\\\\text{integer)}}}A\\\\\r\n&  =\\underbrace{P^{k}P}_{=P^{k+1}}\\underbrace{P^{k-1}A}_{\\subseteq A}\\subseteq\r\nP^{k+1}A.\r\n\\end{align*}\r\nThis establishes Proposition \\ref{prop.F.lift.FPA} \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Proposition \\ref{prop.F.lift.CarlP-P} \\textbf{(b)} yields\r\n$\\operatorname*{Carl}P\\equiv P\\operatorname{mod}\\mathcal{F}F$. In other words,\r\n$\\operatorname*{Carl}P-P\\in\\mathcal{F}F$. In other words, there exists some\r\n$u\\in\\mathcal{F}$ such that $\\operatorname*{Carl}P-P=uF$. Consider this $u$.\r\n\r\nProposition \\ref{prop.F.lift.FPA} \\textbf{(b)} (applied to $P^{k+1}$ instead\r\nof $P$) shows that the $\\mathbb{F}_{q}$-vector subspace $P^{k+1}A$ of $A$ is a\r\nleft $\\mathcal{F}$-submodule of $A$. Hence, $uP^{k+1}A\\subseteq P^{k+1}A$\r\n(since $u\\in\\mathcal{F}$).\r\n\r\nBut $\\operatorname*{Carl}P-P=uF$ shows that $\\operatorname*{Carl}P=P+uF$.\r\nHence,%\r\n\\begin{align*}\r\n\\underbrace{\\left(  \\operatorname*{Carl}P\\right)  }_{=P+uF}P^{k}A  &  =\\left(\r\nP+uF\\right)  P^{k}A\\subseteq\\underbrace{PP^{k}}_{=P^{k+1}}%\r\nA+u\\underbrace{FP^{k}A}_{\\substack{\\subseteq P^{k+1}A\\\\\\text{(by Proposition\r\n\\ref{prop.F.lift.FPA} \\textbf{(c)})}}}\\subseteq P^{k+1}A+\\underbrace{uP^{k+1}%\r\nA}_{\\subseteq P^{k+1}A}\\\\\r\n&  \\subseteq P^{k+1}A+P^{k+1}A\\subseteq P^{k+1}A.\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.F.lift.FPA} \\textbf{(d)}.\r\n\\end{proof}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.lift.lift-P}Let $A$ be an $\\mathcal{F}$-module. Let\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Let $k$ be a positive integer.\r\n\r\nLet $a$ and $b$ be two elements of $A$ such that $a\\equiv b\\operatorname{mod}%\r\nP^{k}A$.\r\n\r\n\\textbf{(a)} We have $F^{\\deg P}a\\equiv F^{\\deg P}b\\operatorname{mod}P^{k+1}A$.\r\n\r\n\\textbf{(b)} We have $\\left(  \\operatorname*{Carl}P\\right)  a\\equiv\\left(\r\n\\operatorname*{Carl}P\\right)  b\\operatorname{mod}P^{k+1}A$.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.lift.lift-P}.]From $a\\equiv\r\nb\\operatorname{mod}P^{k}A$, we obtain $a-b\\in P^{k}A$.\r\n\r\n\\textbf{(a)} If $P=0$, then the claim of Proposition \\ref{prop.F.lift.lift-P}\r\n\\textbf{(a)} is true\\footnote{\\textit{Proof.} Assume that $P=0$. Thus,\r\n$P^{k}=0^{k}=0$ (since $k$ is positive), so that $P^{k}A=0A=0$. Hence,\r\n$a\\equiv b\\operatorname{mod}P^{k}A$ rewrites as $a\\equiv b\\operatorname{mod}%\r\n0$. In other words, $a=b$. Hence, $F^{\\deg P}a=F^{\\deg P}b$, so that $F^{\\deg\r\nP}a\\equiv F^{\\deg P}b\\operatorname{mod}P^{k+1}A$. In other words, the claim of\r\nProposition \\ref{prop.F.lift.lift-P} \\textbf{(a)} is true; qed.}. Hence, we\r\nWLOG assume that $P\\neq0$.\r\n\r\nIf $\\deg P=0$, then the claim of Proposition \\ref{prop.F.lift.lift-P}\r\n\\textbf{(a)} is true\\footnote{\\textit{Proof.} Assume that $\\deg P=0$. Thus,\r\nthe polynomial $P$ is constant. Since $P\\neq0$, this shows that the polynomial\r\n$P$ is invertible in $\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, $P$ is\r\ninvertible in $\\mathcal{F}$. Therefore, $P^{k+1}$ is also invertible in\r\n$\\mathcal{F}$. Hence, $P^{k+1}A=A$. But $F^{\\deg P}a\\equiv F^{\\deg\r\nP}b\\operatorname{mod}A$ is obviously true. Since $P^{k+1}A=A$, this rewrites\r\nas $F^{\\deg P}a\\equiv F^{\\deg P}b\\operatorname{mod}P^{k+1}A$. In other words,\r\nthe claim of Proposition \\ref{prop.F.lift.lift-P} \\textbf{(a)} is true; qed.}.\r\nHence, we WLOG assume that $\\deg P\\neq0$. Thus, $\\deg P\\geq1$.\r\n\r\nLet $d=\\deg P$. Then, $d\\geq1$, so that $F^{d}=FF^{d-1}$.\r\n\r\nBut Proposition \\ref{prop.F.lift.FPA} \\textbf{(b)} (applied to $P^{k}$ instead\r\nof $P$) shows that the $\\mathbb{F}_{q}$-vector subspace $P^{k}A$ of $A$ is a\r\nleft $\\mathcal{F}$-submodule of $A$. Hence, $\\mathcal{F}\\cdot P^{k}A\\subseteq\r\nP^{k}A$.\r\n\r\nNow, $\\deg P=d$, so that%\r\n\\begin{align*}\r\nF^{\\deg P}a-F^{\\deg P}b  &  =F^{d}a-F^{d}b=\\underbrace{F^{d}}_{=FF^{d-1}%\r\n}\\underbrace{\\left(  a-b\\right)  }_{\\in P^{k}A}\\in F\\underbrace{F^{d-1}}%\r\n_{\\in\\mathcal{F}}P^{k}A\\subseteq F\\underbrace{\\mathcal{F}\\cdot P^{k}%\r\nA}_{\\subseteq P^{k}A}\\\\\r\n&  \\subseteq FP^{k}A\\subseteq P^{k+1}A\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\nProposition \\ref{prop.F.lift.FPA} \\textbf{(c)}}\\right)  .\r\n\\end{align*}\r\nIn other words, $F^{\\deg P}a\\equiv F^{\\deg P}b\\operatorname{mod}P^{k+1}A$.\r\nThis proves Proposition \\ref{prop.F.lift.lift-P} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have%\r\n\\[\r\n\\left(  \\operatorname*{Carl}P\\right)  a-\\left(  \\operatorname*{Carl}P\\right)\r\nb=\\left(  \\operatorname*{Carl}P\\right)  \\underbrace{\\left(  a-b\\right)  }_{\\in\r\nP^{k}A}\\in\\left(  \\operatorname*{Carl}P\\right)  P^{k}A\\subseteq P^{k+1}A\r\n\\]\r\n(by Proposition \\ref{prop.F.lift.FPA} \\textbf{(d)}). In other words, $\\left(\r\n\\operatorname*{Carl}P\\right)  a\\equiv\\left(  \\operatorname*{Carl}P\\right)\r\nb\\operatorname{mod}P^{k+1}A$. This proves Proposition \\ref{prop.F.lift.lift-P}\r\n\\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.lift.lift-Pl}Let $A$ be an $\\mathcal{F}$-module. Let\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Let $k$ be a positive integer.\r\n\r\nLet $a$ and $b$ be two elements of $A$ such that $a\\equiv b\\operatorname{mod}%\r\nP^{k}A$.\r\n\r\n\\textbf{(a)} We have $F^{\\deg\\left(  P^{\\ell}\\right)  }a\\equiv F^{\\deg\\left(\r\nP^{\\ell}\\right)  }b\\operatorname{mod}P^{k+\\ell}A$ for every $\\ell\\in\r\n\\mathbb{N}$.\r\n\r\n\\textbf{(b)} We have $\\left(  \\operatorname*{Carl}\\left(  P^{\\ell}\\right)\r\n\\right)  a\\equiv\\left(  \\operatorname*{Carl}\\left(  P^{\\ell}\\right)  \\right)\r\nb\\operatorname{mod}P^{k+\\ell}A$ for every $\\ell\\in\\mathbb{N}$.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F.lift.lift-Pl}.]\\textbf{(a)} We can prove\r\nCorollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} by induction over $\\ell$:\r\n\r\n\\textit{Induction base:} We have $\\deg\\underbrace{\\left(  P^{0}\\right)  }%\r\n_{=1}=\\deg1=0$ and thus $F^{\\deg\\left(  P^{0}\\right)  }=F^{0}=1$. Hence,\r\n$F^{\\deg\\left(  P^{0}\\right)  }a=1a=a$ and similarly $F^{\\deg\\left(\r\nP^{0}\\right)  }b=b$. But $a\\equiv b\\operatorname{mod}P^{k}A$. Since $k+0=k$,\r\nthis rewrites as $a\\equiv b\\operatorname{mod}P^{k+0}A$. Now, $F^{\\deg\\left(\r\nP^{0}\\right)  }a=a\\equiv b=F^{\\deg\\left(  P^{0}\\right)  }b\\operatorname{mod}%\r\nP^{k+0}A$. In other words, Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)}\r\nholds for $\\ell=0$. This completes the induction base.\r\n\r\n\\textit{Induction step:} Let $L\\in\\mathbb{N}$. Assume that Corollary\r\n\\ref{cor.F.lift.lift-Pl} \\textbf{(a)} holds for $\\ell=L$. We must now prove\r\nthat Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} holds for $\\ell=L+1$.\r\n\r\nWe have assumed that Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} holds for\r\n$\\ell=L$. In other words, we have $F^{\\deg\\left(  P^{L}\\right)  }a\\equiv\r\nF^{\\deg\\left(  P^{L}\\right)  }b\\operatorname{mod}P^{k+L}A$.\r\n\r\nBut $k$ is a positive integer, and hence $k+L$ is a positive integer. Hence,\r\nProposition \\ref{prop.F.lift.lift-P} \\textbf{(a)} (applied to $k+L$,\r\n$F^{\\deg\\left(  P^{L}\\right)  }a$ and $F^{\\deg\\left(  P^{L}\\right)  }b$\r\ninstead of $k$, $a$ and $b$) yields\r\n\\begin{equation}\r\nF^{\\deg P}F^{\\deg\\left(  P^{L}\\right)  }a\\equiv F^{\\deg P}F^{\\deg\\left(\r\nP^{L}\\right)  }b\\operatorname{mod}P^{k+L+1}A.\r\n\\label{pf.cor.F.lift.lift-Pl.a.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, $\\deg\\left(  \\underbrace{P^{L+1}}_{=PP^{L}}\\right)  =\\deg\\left(\r\nPP^{L}\\right)  =\\deg P+\\deg\\left(  P^{L}\\right)  $. Hence, $F^{\\deg\\left(\r\nP^{L+1}\\right)  }=F^{\\deg P+\\deg\\left(  P^{L}\\right)  }=F^{\\deg P}%\r\nF^{\\deg\\left(  P^{L}\\right)  }$. Therefore, (\\ref{pf.cor.F.lift.lift-Pl.a.1})\r\nrewrites as follows:%\r\n\\[\r\nF^{\\deg\\left(  P^{L+1}\\right)  }a\\equiv F^{\\deg\\left(  P^{L+1}\\right)\r\n}b\\operatorname{mod}P^{k+L+1}A.\r\n\\]\r\nIn other words, Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} holds for\r\n$\\ell=L+1$. This completes the induction step. The induction proof of\r\nCorollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} is thus finished.\r\n\r\n\\textbf{(b)} We can prove Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} by\r\ninduction over $\\ell$:\r\n\r\n\\textit{Induction base:} We have $\\operatorname*{Carl}\\underbrace{\\left(\r\nP^{0}\\right)  }_{=1}=\\operatorname*{Carl}1=1$ (since $\\operatorname*{Carl}$ is\r\nan $\\mathbb{F}_{q}$-algebra homomorphism). Hence, $\\left(\r\n\\operatorname*{Carl}\\left(  P^{0}\\right)  \\right)  a=1a=a$ and similarly\r\n$\\left(  \\operatorname*{Carl}\\left(  P^{0}\\right)  \\right)  b=b$. But $a\\equiv\r\nb\\operatorname{mod}P^{k}A$. Since $k+0=k$, this rewrites as $a\\equiv\r\nb\\operatorname{mod}P^{k+0}A$. Now, $\\left(  \\operatorname*{Carl}\\left(\r\nP^{0}\\right)  \\right)  a=a\\equiv b=\\left(  \\operatorname*{Carl}\\left(\r\nP^{0}\\right)  \\right)  b\\operatorname{mod}P^{k+0}A$. In other words, Corollary\r\n\\ref{cor.F.lift.lift-Pl} \\textbf{(b)} holds for $\\ell=0$. This completes the\r\ninduction base.\r\n\r\n\\textit{Induction step:} Let $L\\in\\mathbb{N}$. Assume that Corollary\r\n\\ref{cor.F.lift.lift-Pl} \\textbf{(b)} holds for $\\ell=L$. We must now prove\r\nthat Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} holds for $\\ell=L+1$.\r\n\r\nWe have assumed that Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} holds for\r\n$\\ell=L$. In other words, we have $\\left(  \\operatorname*{Carl}\\left(\r\nP^{L}\\right)  \\right)  a\\equiv\\left(  \\operatorname*{Carl}\\left(\r\nP^{L}\\right)  \\right)  b\\operatorname{mod}P^{k+L}A$.\r\n\r\nBut $k$ is a positive integer, and hence $k+L$ is a positive integer. Hence,\r\nProposition \\ref{prop.F.lift.lift-P} \\textbf{(b)} (applied to $k+L$, $\\left(\r\n\\operatorname*{Carl}\\left(  P^{L}\\right)  \\right)  a$ and $\\left(\r\n\\operatorname*{Carl}\\left(  P^{L}\\right)  \\right)  b$ instead of $k$, $a$ and\r\n$b$) yields\r\n\\begin{equation}\r\n\\left(  \\operatorname*{Carl}P\\right)  \\left(  \\operatorname*{Carl}\\left(\r\nP^{L}\\right)  \\right)  a\\equiv\\left(  \\operatorname*{Carl}P\\right)  \\left(\r\n\\operatorname*{Carl}\\left(  P^{L}\\right)  \\right)  b\\operatorname{mod}%\r\nP^{k+L+1}A. \\label{pf.cor.F.lift.lift-Pl.b.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, $\\operatorname*{Carl}\\left(  \\underbrace{P^{L+1}}_{=PP^{L}}\\right)\r\n=\\operatorname*{Carl}\\left(  PP^{L}\\right)  =\\left(  \\operatorname*{Carl}%\r\nP\\right)  \\left(  \\operatorname*{Carl}\\left(  P^{L}\\right)  \\right)  $ (since\r\n$\\operatorname*{Carl}$ is an $\\mathbb{F}_{q}$-algebra homomorphism). Thus,\r\n(\\ref{pf.cor.F.lift.lift-Pl.b.1}) rewrites as follows:%\r\n\\[\r\n\\left(  \\operatorname*{Carl}\\left(  P^{L+1}\\right)  \\right)  a\\equiv\\left(\r\n\\operatorname*{Carl}\\left(  P^{L+1}\\right)  \\right)  b\\operatorname{mod}%\r\nP^{k+L+1}A.\r\n\\]\r\nIn other words, Corollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} holds for\r\n$\\ell=L+1$. This completes the induction step. The induction proof of\r\nCorollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} is thus finished.\r\n\\end{proof}\r\n\r\nIn order to state the last corollary in this section, we need a definition:\r\n\r\n\\begin{definition}\r\n\\label{def.vpi}Let $\\mathbb{K}$ be a field. Let $\\pi$ be a monic irreducible\r\npolynomial in $\\mathbb{K}\\left[  T\\right]  $. Let $f$ be any polynomial in\r\n$\\mathbb{K}\\left[  T\\right]  $. Then, $v_{\\pi}\\left(  f\\right)  $ means the\r\nlargest nonnegative integer $m$ satisfying $\\pi^{m}\\mid f$; this is set to be\r\n$+\\infty$ if $f=0$. Thus, $v_{\\pi}\\left(  f\\right)  \\in\\mathbb{N}\\cup\\left\\{\r\n+\\infty\\right\\}  $ for each $f$.\r\n\r\nWe set $P^{+\\infty}=0$ for each $P\\in\\mathbb{K}\\left[  T\\right]  $. Thus,\r\n$\\pi^{v_{\\pi}\\left(  f\\right)  }\\mid f$ holds for each $f\\in\\mathbb{K}\\left[\r\nT\\right]  $ (including the case when $f=0$).\r\n\\end{definition}\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.lift.lift-all}Let $A$ be an $\\mathcal{F}$-module. Let\r\n$N\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Let $\\pi$ be a monic irreducible\r\npolynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nLet $a$ and $b$ be two elements of $A$ such that $a\\equiv b\\operatorname{mod}%\r\n\\pi A$.\r\n\r\n\\textbf{(a)} We have $F^{\\deg N}a\\equiv F^{\\deg N}b\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  N\\right)  +1}A$. (Here, $F^{\\deg N}$ is understood to mean\r\n$0$ when $N=0$.)\r\n\r\n\\textbf{(b)} We have $\\left(  \\operatorname*{Carl}N\\right)  a\\equiv\\left(\r\n\\operatorname*{Carl}N\\right)  b\\operatorname{mod}\\pi^{v_{\\pi}\\left(  N\\right)\r\n+1}A$.\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.F.lift.lift-all}.]We have $a\\equiv\r\nb\\operatorname{mod}\\pi A$. In other words, $a\\equiv b\\operatorname{mod}\\pi\r\n^{1}A$ (since $\\pi=\\pi^{1}$).\r\n\r\nIf $N=0$, then Corollary \\ref{cor.F.lift.lift-all} is easily seen to hold\r\n(since $F^{\\deg N}=0$ and $\\operatorname*{Carl}\\underbrace{N}_{=0}%\r\n=\\operatorname*{Carl}0=0$ in this case). Hence, we WLOG assume that $N\\neq0$.\r\nThus, $v_{\\pi}\\left(  N\\right)  \\in\\mathbb{N}$. Set $\\ell=v_{\\pi}\\left(\r\nN\\right)  $. Then, $\\pi^{\\ell}\\mid N$. In other words, there exists some\r\npolynomial $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $ such that $N=M\\pi^{\\ell}$.\r\nConsider this $M$.\r\n\r\nProposition \\ref{prop.F.lift.FPA} \\textbf{(b)} (applied to $P=\\pi^{1+\\ell}$)\r\nshows that the $\\mathbb{F}_{q}$-vector subspace $\\pi^{1+\\ell}A$ of $A$ is a\r\nleft $\\mathcal{F}$-submodule of $A$. Hence, $\\mathcal{F}\\cdot\\pi^{1+\\ell\r\n}A\\subseteq\\pi^{1+\\ell}A$.\r\n\r\n\\textbf{(a)} From $N=M\\pi^{\\ell}$, we obtain $\\deg N=\\deg\\left(  M\\pi^{\\ell\r\n}\\right)  =\\deg M+\\deg\\left(  \\pi^{\\ell}\\right)  $, so that $F^{\\deg\r\nN}=F^{\\deg M+\\deg\\left(  \\pi^{\\ell}\\right)  }=F^{\\deg M}F^{\\deg\\left(\r\n\\pi^{\\ell}\\right)  }$.\r\n\r\nCorollary \\ref{cor.F.lift.lift-Pl} \\textbf{(a)} (applied to $P=\\pi$ and $k=1$)\r\nyields \\newline$F^{\\deg\\left(  \\pi^{\\ell}\\right)  }a\\equiv F^{\\deg\\left(\r\n\\pi^{\\ell}\\right)  }b\\operatorname{mod}\\pi^{1+\\ell}A$ (since $a\\equiv\r\nb\\operatorname{mod}\\pi^{1}A$). In other words, $F^{\\deg\\left(  \\pi^{\\ell\r\n}\\right)  }a-F^{\\deg\\left(  \\pi^{\\ell}\\right)  }b\\in\\pi^{1+\\ell}A$. But\r\n\\begin{align*}\r\n&  F^{\\deg N}a-F^{\\deg N}b\\\\\r\n&  =\\underbrace{F^{\\deg N}}_{=F^{\\deg M}F^{\\deg\\left(  \\pi^{\\ell}\\right)  }%\r\n}\\left(  a-b\\right)  =\\underbrace{F^{\\deg M}}_{\\in\\mathcal{F}}%\r\n\\underbrace{F^{\\deg\\left(  \\pi^{\\ell}\\right)  }\\left(  a-b\\right)  }%\r\n_{=F^{\\deg\\left(  \\pi^{\\ell}\\right)  }a-F^{\\deg\\left(  \\pi^{\\ell}\\right)\r\n}b\\in\\pi^{1+\\ell}A}\\\\\r\n&  \\in\\mathcal{F}\\cdot\\pi^{1+\\ell}A\\subseteq\\pi^{1+\\ell}A.\r\n\\end{align*}\r\nIn other words, $F^{\\deg N}a\\equiv F^{\\deg N}b\\operatorname{mod}\\pi^{1+\\ell}%\r\nA$. Since $1+\\underbrace{\\ell}_{=v_{\\pi}\\left(  N\\right)  }=1+v_{\\pi}\\left(\r\nN\\right)  =v_{\\pi}\\left(  N\\right)  +1$, this rewrites as $F^{\\deg N}a\\equiv\r\nF^{\\deg N}b\\operatorname{mod}\\pi^{v_{\\pi}\\left(  N\\right)  +1}A$. This proves\r\nCorollary \\ref{cor.F.lift.lift-all} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} From $N=M\\pi^{\\ell}$, we obtain $\\operatorname*{Carl}%\r\nN=\\operatorname*{Carl}\\left(  M\\pi^{\\ell}\\right)  =\\left(\r\n\\operatorname*{Carl}M\\right)  \\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell\r\n}\\right)  \\right)  $ (since $\\operatorname*{Carl}$ is an $\\mathbb{F}_{q}%\r\n$-algebra homomorphism).\r\n\r\nCorollary \\ref{cor.F.lift.lift-Pl} \\textbf{(b)} (applied to $P=\\pi$ and $k=1$)\r\nyields $\\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)\r\na\\equiv\\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)\r\nb\\operatorname{mod}\\pi^{1+\\ell}A$ (since $a\\equiv b\\operatorname{mod}\\pi^{1}%\r\nA$). In other words, $\\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)\r\n\\right)  a-\\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)\r\nb\\in\\pi^{1+\\ell}A$. But%\r\n\\begin{align*}\r\n&  \\left(  \\operatorname*{Carl}N\\right)  a-\\left(  \\operatorname*{Carl}%\r\nN\\right)  b\\\\\r\n&  =\\underbrace{\\left(  \\operatorname*{Carl}N\\right)  }_{=\\left(\r\n\\operatorname*{Carl}M\\right)  \\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell\r\n}\\right)  \\right)  }\\left(  a-b\\right)  =\\underbrace{\\left(\r\n\\operatorname*{Carl}M\\right)  }_{\\in\\mathcal{F}}\\underbrace{\\left(\r\n\\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)  \\left(  a-b\\right)\r\n}_{=\\left(  \\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)  a-\\left(\r\n\\operatorname*{Carl}\\left(  \\pi^{\\ell}\\right)  \\right)  b\\in\\pi^{1+\\ell}A}\\\\\r\n&  \\in\\mathcal{F}\\cdot\\pi^{1+\\ell}A\\subseteq\\pi^{1+\\ell}A.\r\n\\end{align*}\r\nIn other words, $\\left(  \\operatorname*{Carl}N\\right)  a\\equiv\\left(\r\n\\operatorname*{Carl}N\\right)  b\\operatorname{mod}\\pi^{1+\\ell}A$. Since\r\n$1+\\underbrace{\\ell}_{=v_{\\pi}\\left(  N\\right)  }=1+v_{\\pi}\\left(  N\\right)\r\n=v_{\\pi}\\left(  N\\right)  +1$, this rewrites as $\\left(  \\operatorname*{Carl}%\r\nN\\right)  a\\equiv\\left(  \\operatorname*{Carl}N\\right)  b\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  N\\right)  +1}A$. This proves Corollary\r\n\\ref{cor.F.lift.lift-all} \\textbf{(b)}.\r\n\\end{proof}\r\n\r\nEach of the two parts of Corollary \\ref{cor.F.lift.lift-all} can be viewed as\r\nan analogue of the classical \\textquotedblleft exponent lifting\r\nlemma\\textquotedblright\\ \\cite[version with solutions (ancillary file),\r\n(12.68.8)]{reiner-hopf}.\r\n\r\n\\subsection{The Chinese Remainder Theorem}\r\n\r\nNext, we recall one of the many versions of the Chinese Remainder Theorem:\r\n\r\n\\begin{theorem}\r\n\\label{thm.CRT.dg-witt5c}Let $A$ be a commutative ring. Let $M$ be an\r\n$A$-module. Let $N\\in\\mathbb{N}$. Let $I_{1},I_{2},\\ldots,I_{N}$ be $N$ ideals\r\nof $A$. Assume that $I_{i}+I_{j}=A$ for any two elements $i$ and $j$ of\r\n$\\left\\{  1,2,\\ldots,N\\right\\}  $ satisfying $i<j$.\r\n\r\n\\textbf{(a)} We have $I_{1}I_{2}\\cdots I_{N}\\cdot M=I_{1}M\\cap I_{2}%\r\nM\\cap\\cdots\\cap I_{N}M$.\r\n\r\n\\textbf{(b)} The canonical $A$-module homomorphism\r\n\\begin{align*}\r\nM/\\left(  I_{1}I_{2}\\cdots I_{N}\\cdot M\\right)   &  \\rightarrow\\prod\r\n\\limits_{k=1}^{N}\\left(  M/I_{k}M\\right)  ,\\\\\r\nm+I_{1}I_{2}\\cdots I_{N}\\cdot M  &  \\mapsto\\left(  m+I_{1}M,m+I_{2}%\r\nM,\\ldots,m+I_{N}M\\right)\r\n\\end{align*}\r\nis well-defined and an $A$-module isomorphism.\r\n\\end{theorem}\r\n\r\nTheorem \\ref{thm.CRT.dg-witt5c} is precisely \\cite[Theorem 1 \\textbf{(a)} and\r\n\\textbf{(b)}]{dg-witt5c}; thus, we are not giving a proof of it here.\r\n\r\nFor us, the following restatement of Theorem \\ref{thm.CRT.dg-witt5c} will be\r\nmore useful:\r\n\r\n\\begin{theorem}\r\n\\label{thm.CRT}Let $A$ be a commutative ring. Let $M$ be an $A$-module. Let\r\n$\\mathbf{S}$ be a finite set. For every $s\\in\\mathbf{S}$, let $I_{s}$ be an\r\nideal of $A$. Assume that the ideals $I_{s}$ of $A$ are \\textit{comaximal};\r\nthis means that every two distinct elements $s$ and $t$ of $\\mathbf{S}$\r\nsatisfy $I_{s}+I_{t}=A$. Then:\r\n\r\n\\textbf{(a)} We have\r\n\\[\r\n\\left(  \\prod\\limits_{s\\in\\mathbf{S}}I_{s}\\right)  \\cdot M=\\bigcap\r\n_{s\\in\\mathbf{S}}\\left(  I_{s}M\\right)  .\r\n\\]\r\n\r\n\r\n\\textbf{(b)} The canonical $A$-module homomorphism\r\n\\begin{align*}\r\nM/\\left(  \\left(  \\prod\\limits_{s\\in\\mathbf{S}}I_{s}\\right)  \\cdot M\\right)\r\n&  \\rightarrow\\prod\\limits_{s\\in\\mathbf{S}}\\left(  M/I_{s}M\\right)  ,\\\\\r\nm+\\left(  \\prod\\limits_{s\\in\\mathbf{S}}I_{s}\\right)  \\cdot M  &\r\n\\mapsto\\left(  m+I_{s}M\\right)  _{s\\in\\mathbf{S}}%\r\n\\end{align*}\r\nis well-defined and an $A$-module isomorphism.\r\n\\end{theorem}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.CRT}.]We can freely relabel the elements of\r\n$\\mathbf{S}$. Thus, we can WLOG assume that $\\mathbf{S}=\\left\\{\r\n1,2,\\ldots,N\\right\\}  $ for some $N\\in\\mathbb{N}$. Assume this, and consider\r\nthis $N$. Then, the claim of Theorem \\ref{thm.CRT} becomes identical with the\r\nclaim of Theorem \\ref{thm.CRT.dg-witt5c}. But since we already know that\r\nTheorem \\ref{thm.CRT.dg-witt5c} holds, we thus conclude that Theorem\r\n\\ref{thm.CRT} holds as well.\r\n\\end{proof}\r\n\r\nWe shall only use part \\textbf{(a)} of Theorem \\ref{thm.CRT}.\r\n\r\nAs a consequence of Theorem \\ref{thm.CRT} \\textbf{(a)}, we have the following:\r\n\r\n\\begin{corollary}\r\n\\label{cor.CRT.FqT}Let $A$ be an $\\mathbb{F}_{q}\\left[  T\\right]  $-module.\r\nLet $P$ be a monic polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $. Then,\r\n\\[\r\n\\bigcap_{\\pi\\in\\operatorname*{PF}P}\\pi^{v_{\\pi}\\left(  P\\right)  }A=PA.\r\n\\]\r\n\r\n\\end{corollary}\r\n\r\nBefore we can prove Corollary \\ref{cor.CRT.FqT}, we need a simple lemma:\r\n\r\n\\begin{lemma}\r\n\\label{lem.CRT.FqT.Is+It}Let $\\mathbb{F}$ be a field. Let $s$ and $t$ be two\r\ndistinct monic irreducible polynomials in $\\mathbb{F}\\left[  T\\right]  $. Let\r\n$n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$. Let $R$ be the ring $\\mathbb{F}\\left[\r\nT\\right]  $. Then, $s^{n}R+t^{m}R=R$.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.CRT.FqT.Is+It}.]The polynomials $s$ and $t$ are two\r\ndistinct monic irreducible polynomials in $\\mathbb{F}\\left[  T\\right]  $.\r\nHence, $s$ and $t$ are coprime. Consequently, $s^{n}$ and $t^{m}$ are coprime\r\nas well (since $\\mathbb{F}\\left[  T\\right]  $ is a principal ideal domain). By\r\nBezout's theorem, we thus conclude that there exist polynomials $a$ and $b$ in\r\n$\\mathbb{F}\\left[  T\\right]  $ satisfying $as^{n}+bt^{m}=1$. Consider these\r\n$a$ and $b$.\r\n\r\nThe unity $1$ of the ring $R=\\mathbb{F}\\left[  T\\right]  $ satisfies\r\n\\[\r\n1=as^{n}+bt^{m}=s^{n}\\underbrace{a}_{\\in\\mathbb{F}\\left[  T\\right]  =R}%\r\n+t^{m}\\underbrace{b}_{\\in\\mathbb{F}\\left[  T\\right]  =R}\\in s^{n}R+t^{m}R.\r\n\\]\r\nBut $s^{n}R+t^{m}R$ is an ideal of $R$ (since $s^{n}R$ and $t^{m}R$ are ideals\r\nof $R$). This ideal $s^{n}R+t^{m}R$ contains $1$ (since $1\\in s^{n}R+t^{m}R$),\r\nand thus must equal the whole ring $R$ (because if an ideal of some ring\r\ncontains $1$, then this ideal must equal the whole ring). In other words,\r\n$s^{n}R+t^{m}R=R$. This proves Lemma \\ref{lem.CRT.FqT.Is+It}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.CRT.FqT}.]For each $s\\in\\operatorname*{PF}P$,\r\ndefine an ideal $I_{s}$ of $\\mathbb{F}_{q}\\left[  T\\right]  $ by\r\n$I_{s}=s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  $. Notice\r\nthat $\\mathbb{F}_{q}\\left[  T\\right]  $ is a principal ideal domain.\r\n\r\nFor each $s\\in\\operatorname*{PF}P$, we have%\r\n\\begin{equation}\r\nI_{s}A=s^{v_{s}\\left(  P\\right)  }A \\label{pf.cor.CRT.FqT.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.cor.CRT.FqT.1}):} Let $s\\in\r\n\\operatorname*{PF}P$. Then, the definition of $I_{s}$ yields $I_{s}%\r\n=s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  $. Now,%\r\n\\[\r\n\\underbrace{I_{s}}_{=s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  }A=s^{v_{s}\\left(  P\\right)  }\\underbrace{\\mathbb{F}_{q}\\left[\r\nT\\right]  \\cdot A}_{=A}=s^{v_{s}\\left(  P\\right)  }A.\r\n\\]\r\nThis proves (\\ref{pf.cor.CRT.FqT.1}).}.\r\n\r\nOn the other hand, $P$ is a monic polynomial in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. Hence, the prime factorization of $P$ in the principal ideal\r\ndomain $\\mathbb{F}_{q}\\left[  T\\right]  $ is $P=\\prod_{s\\in\\operatorname*{PF}%\r\nP}s^{v_{s}\\left(  P\\right)  }$ (indeed, for each $s\\in\\operatorname*{PF}P$,\r\nthe multiplicity of $s$ in the prime factorization of $P$ is $v_{s}\\left(\r\nP\\right)  $). Now,%\r\n\\begin{align}\r\n\\prod\\limits_{s\\in\\operatorname*{PF}P}\\underbrace{I_{s}}_{\\substack{=s^{v_{s}%\r\n\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  \\\\\\text{(by the}%\r\n\\\\\\text{definition of }I_{s}\\text{)}}}  &  =\\prod\\limits_{s\\in\r\n\\operatorname*{PF}P}\\left(  s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  \\right)  =\\underbrace{\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}%\r\nP}s^{v_{s}\\left(  P\\right)  }\\right)  }_{=P}\\mathbb{F}_{q}\\left[  T\\right]\r\n\\nonumber\\\\\r\n&  =P\\cdot\\mathbb{F}_{q}\\left[  T\\right]  . \\label{pf.cor.CRT.FqT.2}%\r\n\\end{align}\r\n\r\n\r\nIf $s$ and $t$ are two distinct elements of $\\operatorname*{PF}P$, then\r\n$I_{s}+I_{t}=\\mathbb{F}_{q}\\left[  T\\right]  $%\r\n\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $s$ and $t$ be two distinct elements of\r\n$\\operatorname*{PF}P$. Thus, $s$ and $t$ are two distinct monic irreducible\r\npolynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, Lemma\r\n\\ref{lem.CRT.FqT.Is+It} (applied to $\\mathbb{F}=\\mathbb{F}_{q}$,\r\n$n=v_{s}\\left(  P\\right)  $, $m=v_{t}\\left(  P\\right)  $ and $R=\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $) yields $s^{v_{s}\\left(  P\\right)  }\\mathbb{F}%\r\n_{q}\\left[  T\\right]  +t^{v_{t}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  =\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\\par\r\nThe definition of $I_{s}$ yields $I_{s}=s^{v_{s}\\left(  P\\right)  }%\r\n\\mathbb{F}_{q}\\left[  T\\right]  $. The definition of $I_{t}$ shows that\r\n$I_{t}=t^{v_{t}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  $. Hence,%\r\n\\[\r\n\\underbrace{I_{s}}_{=s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  }+\\underbrace{I_{t}}_{=t^{v_{t}\\left(  P\\right)  }\\mathbb{F}%\r\n_{q}\\left[  T\\right]  }=s^{v_{s}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  +t^{v_{t}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]\r\n=\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nQed.}. Hence, Theorem \\ref{thm.CRT} \\textbf{(a)} (applied to $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $, $A$ and $\\operatorname*{PF}P$ instead of $A$, $M$ and\r\n$\\mathbf{S}$) shows that%\r\n\\[\r\n\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}P}I_{s}\\right)  \\cdot\r\nA=\\bigcap_{s\\in\\operatorname*{PF}P}\\underbrace{\\left(  I_{s}A\\right)\r\n}_{\\substack{=s^{v_{s}\\left(  P\\right)  }A\\\\\\text{(by (\\ref{pf.cor.CRT.FqT.1}%\r\n))}}}=\\bigcap_{s\\in\\operatorname*{PF}P}s^{v_{s}\\left(  P\\right)  }%\r\nA=\\bigcap_{\\pi\\in\\operatorname*{PF}P}\\pi^{v_{\\pi}\\left(  P\\right)  }A\r\n\\]\r\n(here, we have renamed the index $s$ as $\\pi$ in the intersection). Thus,%\r\n\\[\r\n\\bigcap_{\\pi\\in\\operatorname*{PF}P}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A=\\underbrace{\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}P}I_{s}\\right)\r\n}_{\\substack{=P\\cdot\\mathbb{F}_{q}\\left[  T\\right]  \\\\\\text{(by\r\n(\\ref{pf.cor.CRT.FqT.2}))}}}\\cdot A=P\\cdot\\underbrace{\\mathbb{F}_{q}\\left[\r\nT\\right]  \\cdot A}_{=A}=PA.\r\n\\]\r\nThis proves Corollary \\ref{cor.CRT.FqT}.\r\n\\end{proof}\r\n\r\nLet me also state the \\textquotedblleft ring version\\textquotedblright\\ of the\r\nChinese Remainder theorem:\r\n\r\n\\begin{theorem}\r\n\\label{thm.CRT.ring}Let $A$ be a commutative ring. Let $\\mathbf{S}$ be a\r\nfinite set. For every $s\\in\\mathbf{S}$, let $I_{s}$ be an ideal of $A$. Assume\r\nthat the ideals $I_{s}$ of $A$ are \\textit{comaximal}; this means that every\r\ntwo distinct elements $s$ and $t$ of $\\mathbf{S}$ satisfy $I_{s}+I_{t}=A$. Then:\r\n\r\n\\textbf{(a)} We have\r\n\\[\r\n\\prod\\limits_{s\\in\\mathbf{S}}I_{s}=\\bigcap_{s\\in\\mathbf{S}}I_{s}.\r\n\\]\r\n\r\n\r\n\\textbf{(b)} The canonical $A$-algebra homomorphism\r\n\\[\r\nA/\\left(  \\prod\\limits_{s\\in\\mathbf{S}}I_{s}\\right)  \\rightarrow\r\n\\prod\\limits_{s\\in\\mathbf{S}}\\left(  A/I_{s}\\right)\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ a+\\prod\\limits_{s\\in\\mathbf{S}}I_{s}\\mapsto\\left(\r\na+I_{s}\\right)  _{s\\in\\mathbf{S}}%\r\n\\]\r\nis well-defined and an $A$-algebra isomorphism.\r\n\\end{theorem}\r\n\r\nTheorem \\ref{thm.CRT.ring} can easily be derived by applying Theorem\r\n\\ref{thm.CRT} to $M=A$. (The extra claim that the homomorphism in Theorem\r\n\\ref{thm.CRT.ring} \\textbf{(b)} is an $A$-algebra homomorphism is\r\nstraightforward to check.) But Theorem \\ref{thm.CRT.ring} is also a classical\r\nfact that appears in many textbooks on algebra (it is probably easier to find\r\nthan Theorem \\ref{thm.CRT}).\r\n\r\nLet me continue with another simple lemma about divisibility of polynomials:\r\n\r\n\\begin{lemma}\r\n\\label{lem.FqT.exact-divisor}Let $P$ be a polynomial in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. Let $\\pi$ be a monic irreducible divisor of $P$. Let $D$ be a\r\ndivisor of $P$ satisfying $D\\nmid P/\\pi$. Then, $\\pi^{v_{\\pi}\\left(  P\\right)\r\n}\\mid D$.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.FqT.exact-divisor}.]From $D\\nmid P/\\pi$, we obtain\r\n$P/\\pi\\neq0$, hence $P\\neq0$.\r\n\r\nWe have $D\\nmid P/\\pi$. In other words, $\\dfrac{P/\\pi}{D}\\notin\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $. This rewrites as $\\dfrac{P/D}{\\pi}\\notin%\r\n\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\dfrac{P/\\pi}{D}=\\dfrac{P/D}{\\pi}$).\r\nEquivalently, $\\pi\\nmid P/D$ (since $P/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\n(because $D$ is a divisor of $P$)). In other words, $v_{\\pi}\\left(\r\nP/D\\right)  =0$. Hence, $0=v_{\\pi}\\left(  P/D\\right)  =v_{\\pi}\\left(\r\nP\\right)  -v_{\\pi}\\left(  D\\right)  $, so that $v_{\\pi}\\left(  P\\right)\r\n=v_{\\pi}\\left(  D\\right)  $.\r\n\r\nBut $\\pi^{v_{\\pi}\\left(  D\\right)  }\\mid D$ (obviously). Since $v_{\\pi}\\left(\r\nP\\right)  =v_{\\pi}\\left(  D\\right)  $, we now have $\\pi^{v_{\\pi}\\left(\r\nP\\right)  }=\\pi^{v_{\\pi}\\left(  D\\right)  }\\mid D$. This proves Lemma\r\n\\ref{lem.FqT.exact-divisor}.\r\n\\end{proof}\r\n\r\nHere is a well-known fact about quotients of polynomial rings over fields:\r\n\r\n\\begin{proposition}\r\n\\label{prop.FT.modsn}Let $\\mathbb{F}$ be a field. Let $s\\in\\mathbb{F}\\left[\r\nT\\right]  $ be a monic irreducible polynomial. Let $n$ be a positive integer.\r\nLet $B$ be the ring $\\mathbb{F}\\left[  T\\right]  /s^{n}\\mathbb{F}\\left[\r\nT\\right]  $. Then:\r\n\r\n\\textbf{(a)} We have $B^{\\times}=B\\setminus sB$. (Here, $B^{\\times}$ denotes\r\nthe group of units of the ring $B$.)\r\n\r\n\\textbf{(b)} We have $sB\\cong\\mathbb{F}\\left[  T\\right]  /s^{n-1}%\r\n\\mathbb{F}\\left[  T\\right]  $ as $\\mathbb{F}$-vector spaces.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.FT.modsn}.]For every $a\\in\\mathbb{F}\\left[\r\nT\\right]  $, we let $\\overline{a}$ denote the canonical projection of $a$ on\r\n$\\mathbb{F}\\left[  T\\right]  /s^{n}\\mathbb{F}\\left[  T\\right]  =B$.\r\n\r\n\\textbf{(a)} We shall prove the inclusions $B^{\\times}\\subseteq B\\setminus sB$\r\nand $B\\setminus sB\\subseteq B^{\\times}$ separately:\r\n\r\n\\textit{Proof of }$B^{\\times}\\subseteq B\\setminus sB$\\textit{:} Let $b\\in\r\nB^{\\times}$.\r\n\r\nWe have $b\\in B^{\\times}$. In other words, the element $b$ of $B$ is\r\ninvertible. In other words, there exists some $d\\in B$ such that $bd=1$.\r\nConsider this $d$.\r\n\r\nWe have $d\\in B$. Thus, $d=\\overline{c}$ for some $c\\in\\mathbb{F}\\left[\r\nT\\right]  $. Consider this $c$.\r\n\r\nNow, assume (for the sake of contradiction) that $b\\in sB$. In other words,\r\n$b=sf$ for some $f\\in B$. Consider this $f$.\r\n\r\nWe have $f\\in B$. Thus, $f=\\overline{e}$ for some $e\\in\\mathbb{F}\\left[\r\nT\\right]  $. Consider this $e$. Multiplying the equalities $f=\\overline{e}$\r\nand $d=\\overline{c}$, we obtain $fd=\\overline{e}\\cdot\\overline{c}%\r\n=\\overline{ec}=\\overline{ce}$.\r\n\r\nNow, $bd=1$, so that $1=\\underbrace{b}_{=sf}d=s\\underbrace{fd}_{=\\overline\r\n{ce}}=s\\overline{ce}=\\overline{sce}$. In other words, $1\\equiv\r\nsce\\operatorname{mod}s^{n}\\mathbb{F}\\left[  T\\right]  $. In other words,\r\n$s^{n}\\mid1-sce$. But since $n$ is positive, we have $s\\mid s^{n}\\mid1-sce$.\r\nThus, the polynomial $1-sce$ is divisible by $s$. Also, the polynomial $sce$\r\nis divisible by $s$ (clearly). Hence, the sum of these two polynomials $1-sce$\r\nand $sce$ must also divisible by $s$. In other words, $\\left(  1-sce\\right)\r\n+sce$ is divisible by $s$. In other words, $1$ is divisible by $s$ (since\r\n$\\left(  1-sce\\right)  +sce=1$). This is clearly absurd (since $s$ is\r\nirreducible). Thus, we have found a contradiction. This shows that our\r\nassumption (that $b\\in sB$) was false.\r\n\r\nHence, $b\\notin sB$. Combining this with $b\\in B$, we obtain $b\\in B\\setminus\r\nsB$.\r\n\r\nNow, forget that we fixed $b$. We thus have proven that $b\\in B\\setminus sB$\r\nfor each $b\\in B^{\\times}$. In other words, $B^{\\times}\\subseteq B\\setminus\r\nsB$.\r\n\r\n\\textit{Proof of }$B\\setminus sB\\subseteq B^{\\times}$\\textit{:} Let $b\\in\r\nB\\setminus sB$. Then, $b\\in B\\setminus sB\\subseteq B$. Hence, $b=\\overline{a}$\r\nfor some $a\\in\\mathbb{F}\\left[  T\\right]  $. Consider this $a$.\r\n\r\nWe have $s\\nmid a$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Assume the contrary. Thus,\r\n$s\\mid a$. In other words, $a=cs$ for some $c\\in\\mathbb{F}\\left[  T\\right]  $.\r\nConsider this $c$. From $a=cs=sc$, we obtain $\\overline{a}=\\overline\r\n{cs}=\\overline{sc}=s\\underbrace{\\overline{c}}_{\\in B}\\in sB$. But\r\n$\\overline{a}=b\\in B\\setminus sB$ and thus $\\overline{a}\\notin sB$. This\r\ncontradicts $\\overline{a}\\in sB$. This contradiction shows that our assumption\r\nwas wrong; qed.}. Hence, the polynomials $a$ and $s$ are coprime (since $s$ is\r\nirreducible, and since $\\mathbb{F}\\left[  T\\right]  $ is a principal ideal\r\ndomain). Therefore, the polynomials $a$ and $s^{n}$ are coprime (since\r\n$\\mathbb{F}\\left[  T\\right]  $ is a principal ideal domain). By Bezout's\r\ntheorem, we thus conclude that there exist polynomials $\\alpha$ and $\\beta$ in\r\n$\\mathbb{F}\\left[  T\\right]  $ satisfying $\\alpha a+\\beta s^{n}=1$. Consider\r\nthese $\\alpha$ and $\\beta$.\r\n\r\nThe unity $1$ of the ring $\\mathbb{F}\\left[  T\\right]  $ satisfies $1=\\alpha\r\na+\\underbrace{\\beta s^{n}}_{\\substack{\\equiv0\\operatorname{mod}s^{n}%\r\n\\mathbb{F}\\left[  T\\right]  \\\\\\text{(since }s^{n}\\mid\\beta s^{n}\\text{)}%\r\n}}\\equiv\\alpha a\\operatorname{mod}s^{n}\\mathbb{F}\\left[  T\\right]  $. In other\r\nwords, $\\overline{1}=\\overline{\\alpha a}$. Comparing this with $\\overline\r\n{\\alpha}\\underbrace{b}_{=\\overline{a}}=\\overline{\\alpha}\\cdot\\overline\r\n{a}=\\overline{\\alpha a}$, we obtain $\\overline{\\alpha}b=\\overline{1}=1$.\r\nHence, the element $b$ of $B$ is invertible. In other words, $b\\in B^{\\times}$.\r\n\r\nNow, forget that we fixed $b$. We thus have proven that $b\\in B^{\\times}$ for\r\neach $b\\in B\\setminus sB$. In other words, $B\\setminus sB\\subseteq B^{\\times}$.\r\n\r\nCombining the two relations $B^{\\times}\\subseteq B\\setminus sB$ and\r\n$B\\setminus sB\\subseteq B^{\\times}$, we obtain $B^{\\times}=B\\setminus sB$.\r\nThus, Proposition \\ref{prop.FT.modsn} \\textbf{(a)} is proven.\r\n\r\n\\textbf{(b)} Let $\\rho$ be the map $\\mathbb{F}\\left[  T\\right]  \\rightarrow\r\nsB,\\ f\\mapsto s\\overline{f}$. It is straightforward to see that this map\r\n$\\rho$ is well-defined and $\\mathbb{F}$-linear. Moreover, $\\operatorname*{Ker}%\r\n\\rho\\subseteq s^{n-1}\\mathbb{F}\\left[  T\\right]  $%\r\n\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $a\\in\\operatorname*{Ker}\\rho$. Thus,\r\n$a\\in\\mathbb{F}\\left[  T\\right]  $ and $\\rho\\left(  a\\right)  =0$. Now, the\r\ndefinition of $\\rho$ yields $\\rho\\left(  a\\right)  =s\\overline{a}%\r\n=\\overline{sa}$. Hence, $\\overline{sa}=\\rho\\left(  a\\right)  =0$. In other\r\nwords, $sa\\in s^{n}\\mathbb{F}\\left[  T\\right]  $. In other words, $s^{n}\\mid\r\nsa$ in $\\mathbb{F}\\left[  T\\right]  $. In other words, there exists some\r\n$g\\in\\mathbb{F}\\left[  T\\right]  $ satisfying $sa=s^{n}g$. Consider this $g$.\r\n\\par\r\nThe polynomial $s$ is irreducible and thus nonzero. Hence, we can cancel $s$\r\nfrom the equation $sa=\\underbrace{s^{n}}_{=ss^{n-1}}g=ss^{n-1}g$ (since\r\n$\\mathbb{F}\\left[  T\\right]  $ is an integral domain). We thus obtain\r\n$a=s^{n-1}\\underbrace{g}_{\\in\\mathbb{F}\\left[  T\\right]  }\\in s^{n-1}%\r\n\\mathbb{F}\\left[  T\\right]  $.\r\n\\par\r\nNow, forget that we fixed $a$. We thus have shown that $a\\in s^{n-1}%\r\n\\mathbb{F}\\left[  T\\right]  $ for each $a\\in\\operatorname*{Ker}\\rho$. In other\r\nwords, $\\operatorname*{Ker}\\rho\\subseteq s^{n-1}\\mathbb{F}\\left[  T\\right]  $.\r\nQed.} and $s^{n-1}\\mathbb{F}\\left[  T\\right]  \\subseteq\\operatorname*{Ker}%\r\n\\rho$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $f\\in s^{n-1}\\mathbb{F}\\left[\r\nT\\right]  $. Thus, there exists some $g\\in\\mathbb{F}\\left[  T\\right]  $\r\nsatisfying $f=s^{n-1}g$. Consider this $g$. Now, the definition of $\\rho$\r\nyields\r\n\\begin{align*}\r\n\\rho\\left(  f\\right)   &  =s\\overline{f}=s\\overline{s^{n-1}g}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }f=s^{n-1}g\\right) \\\\\r\n&  =\\overline{ss^{n-1}g}=0\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\underbrace{ss^{n-1}}_{=s^{n}}g=s^{n}\\underbrace{g}_{\\in\\mathbb{F}\\left[\r\nT\\right]  }\\in s^{n}\\mathbb{F}\\left[  T\\right]  \\right)  .\r\n\\end{align*}\r\nIn other words, $f\\in\\operatorname*{Ker}\\rho$.\r\n\\par\r\nNow, forget that we fixed $f$. We thus have proven that $f\\in\r\n\\operatorname*{Ker}\\rho$ for each $f\\in s^{n-1}\\mathbb{F}\\left[  T\\right]  $.\r\nIn other words, $s^{n-1}\\mathbb{F}\\left[  T\\right]  \\subseteq\r\n\\operatorname*{Ker}\\rho$. Qed.}. Combining these two inclusions, we obtain\r\n$\\operatorname*{Ker}\\rho=s^{n-1}\\mathbb{F}\\left[  T\\right]  $. Moreover, the\r\nmap $\\rho$ is surjective\\footnote{\\textit{Proof.} Let $a\\in sB$. Thus, there\r\nexists some $b\\in B$ such that $a=sb$. Consider this $b$. Now, we have $b\\in\r\nB$. Hence, $b=\\overline{f}$ for some $f\\in\\mathbb{F}\\left[  T\\right]  $.\r\nConsider this $f$. The definition of $\\rho$ yields $\\rho\\left(  f\\right)\r\n=s\\overline{f}=sb$ (since $\\overline{f}=b$). Compared with $a=sb$, this yields\r\n$a=\\rho\\left(  \\underbrace{f}_{\\in\\mathbb{F}\\left[  T\\right]  }\\right)\r\n\\in\\rho\\left(  \\mathbb{F}\\left[  T\\right]  \\right)  $.\r\n\\par\r\nNow, forget that we fixed $a$. We thus have proven that $a\\in\\rho\\left(\r\n\\mathbb{F}\\left[  T\\right]  \\right)  $ for each $a\\in sB$. In other words,\r\n$sB\\subseteq\\rho\\left(  \\mathbb{F}\\left[  T\\right]  \\right)  $. In other\r\nwords, the map $\\rho$ is surjective. Qed.}. Hence, $\\rho\\left(  \\mathbb{F}%\r\n\\left[  T\\right]  \\right)  =sB$.\r\n\r\nNow, the first isomorphism theorem (applied to the $\\mathbb{F}$-linear map\r\n$\\rho:\\mathbb{F}\\left[  T\\right]  \\rightarrow sB$) yields $\\rho\\left(\r\n\\mathbb{F}\\left[  T\\right]  \\right)  \\cong\\mathbb{F}\\left[  T\\right]\r\n/\\underbrace{\\operatorname*{Ker}\\rho}_{=s^{n-1}\\mathbb{F}\\left[  T\\right]\r\n}=\\mathbb{F}\\left[  T\\right]  /s^{n-1}\\mathbb{F}\\left[  T\\right]  $ as\r\n$\\mathbb{F}$-vector spaces. In light of $\\rho\\left(  \\mathbb{F}\\left[\r\nT\\right]  \\right)  =sB$, this rewrites as $sB\\cong\\mathbb{F}\\left[  T\\right]\r\n/s^{n-1}\\mathbb{F}\\left[  T\\right]  $. Thus, Proposition \\ref{prop.FT.modsn}\r\n\\textbf{(b)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{Ghost-Witt integrality: a general equivalence}\r\n\r\nRecall the notion of a \\textquotedblleft$q$-nest\\textquotedblright\\ defined in\r\nDefinition \\ref{def.q-nest}. Recall also Definition \\ref{def.PF(q)}.\r\nFurthermore, recall the following convention:\r\n\r\n\\begin{definition}\r\nLet $P$ be a monic polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $. Then, the\r\nsummation sign $\\sum_{D\\mid P}$ means a sum over all \\textbf{monic}\r\npolynomials $D$ dividing $P$.\r\n\\end{definition}\r\n\r\nWe shall now prove a very general fact that encompasses some of the claims of\r\nTheorem \\ref{thm.carlitz.gW}:\r\n\r\n\\begin{theorem}\r\n\\label{thm.F.gW-general}Let $N$ be a $q$-nest. Let $A$ be an $\\mathcal{F}%\r\n$-module. For every $P\\in N$, let $\\varphi_{P}$ and $\\psi_{P}$ be two\r\nendomorphisms of the $\\mathbb{F}_{q}$-vector space $A$. Let us make the\r\nfollowing five assumptions:\r\n\r\n\\textit{Assumption 1:} For every $P\\in N$, the map $\\varphi_{P}$ is an\r\nendomorphism of the $\\mathcal{F}$-module $A$.\r\n\r\n\\textit{Assumption 2:} We have $\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left(\r\n\\operatorname*{Carl}\\pi\\right)  a\\operatorname{mod}\\pi A$ for every $a\\in A$\r\nand every monic irreducible $\\pi\\in N$.\r\n\r\n\\textit{Assumption 3:} We have $\\varphi_{1}=\\operatorname*{id}$. Furthermore,\r\n$\\varphi_{P}\\circ\\varphi_{Q}=\\varphi_{PQ}$ for every $P\\in N$ and every $Q\\in\r\nN$ satisfying $PQ\\in N$.\r\n\r\n\\textit{Assumption 4:} We have $\\psi_{P}\\left(  a\\right)  \\equiv\\varphi_{\\pi\r\n}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A$ for every $a\\in A$, every $P\\in N$ and every $\\pi\r\n\\in\\operatorname*{PF}P$.\r\n\r\n\\textit{Assumption 5:} We have $\\psi_{1}=\\operatorname*{id}$.\r\n\r\nLet $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ be a family of elements of $A$.\r\nThen, the following assertions $\\mathcal{C}_{1}$ and $\\mathcal{E}_{\\psi}$ are equivalent:\r\n\r\n\\textit{Assertion }$\\mathcal{C}_{1}$\\textit{:} Every $P\\in N$ and every\r\n$\\pi\\in\\operatorname{PF}P$ satisfy%\r\n\\[\r\n\\varphi_{\\pi}\\left(  b_{P / \\pi}\\right)  \\equiv b_{P}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{E}_{\\psi}$\\textit{:} There exists a family\r\n$\\left(  z_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\psi_{P / D}\\left(  z_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  .\r\n\\]\r\n\r\n\\end{theorem}\r\n\r\nBefore we prove this theorem, let us make a few comments.\r\n\r\n\\begin{remark}\r\n\\label{rmk.F.gW-general.ass2}Let $N$ be a $q$-nest. Let $A$ be an\r\n$\\mathcal{F}$-module. For every $P\\in N$, let $\\varphi_{P}$ be an endomorphism\r\nof the $\\mathbb{F}_{q}$-vector space $A$. Then, Assumption 2 in Theorem\r\n\\ref{thm.F.gW-general} is equivalent to the following statement: We have\r\n$\\varphi_{\\pi}\\left(  a\\right)  \\equiv F^{\\deg\\pi}a\\operatorname{mod}\\pi A$\r\nfor every $a\\in A$ and every monic irreducible $\\pi\\in N$.\r\n\\end{remark}\r\n\r\n\\begin{proof}\r\n[Proof of Remark \\ref{rmk.F.gW-general.ass2}.]It is clearly enough to show\r\nthat $\\left(  \\operatorname*{Carl}\\pi\\right)  a\\equiv F^{\\deg\\pi\r\n}a\\operatorname{mod}\\pi A$ for every $a\\in A$ and every monic irreducible\r\n$\\pi\\in N$. But this follows from Corollary \\ref{cor.F.u(pi).mod}. Thus,\r\nRemark \\ref{rmk.F.gW-general.ass2} is proven.\r\n\\end{proof}\r\n\r\nNext, let us show examples of endomorphisms $\\psi_{P}$ satisfying the\r\nAssumption 4 of Theorem \\ref{thm.F.gW-general}:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.gW-general.ex1}Let $N$ be a $q$-nest. Let $A$ be an\r\n$\\mathcal{F}$-module. For every $P\\in N$, let $\\varphi_{P}$ be an endomorphism\r\nof the $\\mathbb{F}_{q}$-vector space $A$. Assume that the Assumptions 1 and 2\r\nof Theorem \\ref{thm.F.gW-general} are satisfied.\r\n\r\nFor every $P\\in N$, define an endomorphism $\\psi_{P}$ of the $\\mathbb{F}_{q}%\r\n$-vector space $A$ by%\r\n\\[\r\n\\left(  \\psi_{P}\\left(  a\\right)  =\\left(  \\operatorname*{Carl}P\\right)\r\na\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }a\\in A\\right)  .\r\n\\]\r\nThen, Assumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied.\r\n\\end{proposition}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.gW-general.ex2}Let $N$ be a $q$-nest. Let $A$ be an\r\n$\\mathcal{F}$-module. For every $P\\in N$, let $\\varphi_{P}$ be an endomorphism\r\nof the $\\mathbb{F}_{q}$-vector space $A$. Assume that the Assumption 1 and 2\r\nof Theorem \\ref{thm.F.gW-general} are satisfied.\r\n\r\nFor every $P\\in N$, define an endomorphism $\\psi_{P}$ of the $\\mathbb{F}_{q}%\r\n$-vector space $A$ by%\r\n\\[\r\n\\left(  \\psi_{P}\\left(  a\\right)  =F^{\\deg P}a\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }a\\in A\\right)  .\r\n\\]\r\nThen, Assumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied.\r\n\\end{proposition}\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.gW-general.ex3}Let $N$ be a $q$-nest. Let $A$ be an\r\n$\\mathcal{F}$-module. For every $P\\in N$, let $\\varphi_{P}$ be an endomorphism\r\nof the $\\mathbb{F}_{q}$-vector space $A$. Assume that the Assumption 3 of\r\nTheorem \\ref{thm.F.gW-general} is satisfied.\r\n\r\nFor every $P\\in N$, define an endomorphism $\\psi_{P}$ of the $\\mathbb{F}_{q}%\r\n$-vector space $A$ by%\r\n\\[\r\n\\psi_{P}=\\varphi_{P}.\r\n\\]\r\nThen, Assumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.gW-general.ex1}.]Assumption 5 of Theorem\r\n\\ref{thm.F.gW-general} is satisfied\\footnote{\\textit{Proof.} We have\r\n$\\operatorname*{Carl}1=1$ (since $\\operatorname*{Carl}$ is an $\\mathbb{F}_{q}%\r\n$-algebra homomorphism). Now, every $a\\in A$ satisfies\r\n\\begin{align*}\r\n\\psi_{1}\\left(  a\\right)   &  =\\underbrace{\\left(  \\operatorname*{Carl}%\r\n1\\right)  }_{=1}a\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\psi_{1}\\right) \\\\\r\n&  =1a=a=\\operatorname*{id}\\left(  a\\right)  .\r\n\\end{align*}\r\nIn other words, $\\psi_{1}=1$. In other words, Assumption 5 of Theorem\r\n\\ref{thm.F.gW-general} is satisfied, qed.}. Hence, it remains to show that\r\nAssumption 4 of Theorem \\ref{thm.F.gW-general} is satisfied. In other words,\r\nwe must prove that we have $\\psi_{P}\\left(  a\\right)  \\equiv\\varphi_{\\pi\r\n}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A$ for every $a\\in A$, every $P\\in N$ and every $\\pi\r\n\\in\\operatorname*{PF}P$.\r\n\r\nSo let us fix $a\\in A$, $P\\in N$ and $\\pi\\in\\operatorname*{PF}P$. Clearly,\r\n$\\pi\\mid P$ (since $\\pi\\in\\operatorname*{PF}P$), and $\\pi$ is a monic\r\nirreducible polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\pi\r\n\\in\\operatorname*{PF}P$). From these two facts, we obtain $\\pi\\in N$ (since\r\n$N$ is a $q$-nest). Thus, Assumption 2 of Theorem \\ref{thm.F.gW-general}\r\nyields $\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left(  \\operatorname*{Carl}%\r\n\\pi\\right)  \\left(  a\\right)  \\operatorname{mod}\\pi A$.\r\n\r\nAlso, $P/\\pi\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\pi\\mid P$). Hence,\r\n$\\psi_{P/\\pi}\\left(  a\\right)  =\\left(  \\operatorname*{Carl}\\left(\r\nP/\\pi\\right)  \\right)  \\left(  a\\right)  $ (by the definition of $\\psi_{P/\\pi\r\n}$).\r\n\r\nCorollary \\ref{cor.F.lift.lift-all} \\textbf{(b)} (applied to $P/\\pi$,\r\n$\\varphi_{\\pi}\\left(  a\\right)  $ and $\\left(  \\operatorname*{Carl}\\pi\\right)\r\na$ instead of $N$, $a$ and $b$) shows that%\r\n\\[\r\n\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\n\\varphi_{\\pi}\\left(  a\\right)  \\right)  \\equiv\\left(  \\operatorname*{Carl}%\r\n\\left(  P/\\pi\\right)  \\right)  \\left(  \\left(  \\operatorname*{Carl}\\pi\\right)\r\na\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P/\\pi\\right)  +1}A.\r\n\\]\r\nIn view of\r\n\\[\r\nv_{\\pi}\\left(  P/\\pi\\right)  +\\underbrace{1}_{=v_{\\pi}\\left(  \\pi\\right)\r\n}=v_{\\pi}\\left(  P/\\pi\\right)  +v_{\\pi}\\left(  \\pi\\right)  =v_{\\pi}\\left(\r\n\\underbrace{\\left(  P/\\pi\\right)  \\pi}_{=P}\\right)  =v_{\\pi}\\left(  P\\right)\r\n,\r\n\\]\r\nthis rewrites as\r\n\\begin{equation}\r\n\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\n\\varphi_{\\pi}\\left(  a\\right)  \\right)  \\equiv\\left(  \\operatorname*{Carl}%\r\n\\left(  P/\\pi\\right)  \\right)  \\left(  \\left(  \\operatorname*{Carl}\\pi\\right)\r\na\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\label{pf.prop.F.gW-general.ex1.a1}%\r\n\\end{equation}\r\n\r\n\r\nBut $\\varphi_{\\pi}$ is an endomorphism of the $\\mathcal{F}$-module $A$ (by\r\nAssumption 1 of Theorem \\ref{thm.F.gW-general}, applied to $\\pi$ instead of\r\n$P$). Hence,%\r\n\\[\r\n\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\n\\varphi_{\\pi}\\left(  a\\right)  \\right)  =\\varphi_{\\pi}\\left(\r\n\\underbrace{\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\na\\right)  }_{=\\psi_{P/\\pi}\\left(  a\\right)  }\\right)  =\\varphi_{\\pi}\\left(\r\n\\psi_{P/\\pi}\\left(  a\\right)  \\right)  .\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\varphi_{\\pi}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)   &  =\\left(\r\n\\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(  \\varphi_{\\pi\r\n}\\left(  a\\right)  \\right)  \\equiv\\left(  \\operatorname*{Carl}\\left(\r\nP/\\pi\\right)  \\right)  \\left(  \\left(  \\operatorname*{Carl}\\pi\\right)\r\na\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{pf.prop.F.gW-general.ex1.a1})}\\right) \\\\\r\n&  =\\underbrace{\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)\r\n\\cdot\\operatorname*{Carl}\\pi\\right)  }_{\\substack{=\\operatorname*{Carl}\\left(\r\n\\left(  P/\\pi\\right)  \\pi\\right)  \\\\\\text{(since }\\operatorname*{Carl}\\text{\r\nis an }\\mathbb{F}_{q}\\text{-algebra}\\\\\\text{homomorphism)}}}a\\\\\r\n&  =\\left(  \\operatorname*{Carl}\\underbrace{\\left(  \\left(  P/\\pi\\right)\r\n\\pi\\right)  }_{=P}\\right)  a=\\left(  \\operatorname*{Carl}P\\right)  a\\\\\r\n&  =\\psi_{P}\\left(  a\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A\r\n\\end{align*}\r\n(since $\\psi_{P}\\left(  a\\right)  =\\left(  \\operatorname*{Carl}P\\right)  a$\r\n(by the definition of $\\psi_{P}$)). In other words, $\\psi_{P}\\left(  a\\right)\r\n\\equiv\\varphi_{\\pi}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A$. Thus, Assumption 4 of\r\nTheorem \\ref{thm.F.gW-general} is satisfied. This proves Proposition\r\n\\ref{prop.F.gW-general.ex1}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.gW-general.ex2}.]Assumption 5 of Theorem\r\n\\ref{thm.F.gW-general} is satisfied\\footnote{\\textit{Proof.} Every $a\\in A$\r\nsatisfies\r\n\\begin{align*}\r\n\\psi_{1}\\left(  a\\right)   &  =F^{\\deg1}a\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\nthe definition of }\\psi_{1}\\right) \\\\\r\n&  =1a\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\deg1=0\\text{ and thus }%\r\nF^{\\deg1}=F^{0}=1\\right) \\\\\r\n&  =a=\\operatorname*{id}\\left(  a\\right)  .\r\n\\end{align*}\r\nIn other words, $\\psi_{1}=1$. In other words, Assumption 5 of Theorem\r\n\\ref{thm.F.gW-general} is satisfied, qed.}. Hence, it remains to show that\r\nAssumption 4 of Theorem \\ref{thm.F.gW-general} is satisfied. In other words,\r\nwe must prove that we have $\\psi_{P}\\left(  a\\right)  \\equiv\\varphi_{\\pi\r\n}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A$ for every $a\\in A$, every $P\\in N$ and every $\\pi\r\n\\in\\operatorname*{PF}P$.\r\n\r\nSo let us fix $a\\in A$, $P\\in N$ and $\\pi\\in\\operatorname*{PF}P$. Clearly,\r\n$\\pi\\mid P$ (since $\\pi\\in\\operatorname*{PF}P$), and $\\pi$ is a monic\r\nirreducible polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\pi\r\n\\in\\operatorname*{PF}P$). From these two facts, we obtain $\\pi\\in N$ (since\r\n$N$ is a $q$-nest). Thus, Assumption 2 of Theorem \\ref{thm.F.gW-general}\r\nyields $\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left(  \\operatorname*{Carl}%\r\n\\pi\\right)  \\left(  a\\right)  \\operatorname{mod}\\pi A$. Thus,%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left(  \\operatorname*{Carl}\\pi\\right)\r\n\\left(  a\\right)  \\equiv F^{\\deg\\pi}a\\operatorname{mod}\\pi A\r\n\\label{pf.prop.F.gW-general.ex2.0}%\r\n\\end{equation}\r\n(by Corollary \\ref{cor.F.u(pi).mod}).\r\n\r\nAlso, $P/\\pi\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\pi\\mid P$). Hence,\r\n$\\psi_{P/\\pi}\\left(  a\\right)  =F^{\\deg\\left(  P/\\pi\\right)  }\\left(\r\na\\right)  $ (by the definition of $\\psi_{P/\\pi}$).\r\n\r\nCorollary \\ref{cor.F.lift.lift-all} \\textbf{(a)} (applied to $P/\\pi$,\r\n$\\varphi_{\\pi}\\left(  a\\right)  $ and $F^{\\deg\\pi}a$ instead of $N$, $a$ and\r\n$b$) shows that%\r\n\\[\r\nF^{\\deg\\left(  P/\\pi\\right)  }\\left(  \\varphi_{\\pi}\\left(  a\\right)  \\right)\r\n\\equiv F^{\\deg\\left(  P/\\pi\\right)  }\\left(  F^{\\deg\\pi}a\\right)\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P/\\pi\\right)  +1}A.\r\n\\]\r\nIn view of\r\n\\[\r\nv_{\\pi}\\left(  P/\\pi\\right)  +\\underbrace{1}_{=v_{\\pi}\\left(  \\pi\\right)\r\n}=v_{\\pi}\\left(  P/\\pi\\right)  +v_{\\pi}\\left(  \\pi\\right)  =v_{\\pi}\\left(\r\n\\underbrace{\\left(  P/\\pi\\right)  \\pi}_{=P}\\right)  =v_{\\pi}\\left(  P\\right)\r\n,\r\n\\]\r\nthis rewrites as\r\n\\begin{equation}\r\nF^{\\deg\\left(  P/\\pi\\right)  }\\left(  \\varphi_{\\pi}\\left(  a\\right)  \\right)\r\n\\equiv F^{\\deg\\left(  P/\\pi\\right)  }\\left(  F^{\\deg\\pi}a\\right)\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\label{pf.prop.F.gW-general.ex2.a1}%\r\n\\end{equation}\r\n\r\n\r\nBut $\\varphi_{\\pi}$ is an endomorphism of the $\\mathcal{F}$-module $A$ (by\r\nAssumption 1 of Theorem \\ref{thm.F.gW-general}, applied to $\\pi$ instead of\r\n$P$). Hence,%\r\n\\[\r\nF^{\\deg\\left(  P/\\pi\\right)  }\\left(  \\varphi_{\\pi}\\left(  a\\right)  \\right)\r\n=\\varphi_{\\pi}\\left(  \\underbrace{F^{\\deg\\left(  P/\\pi\\right)  }\\left(\r\na\\right)  }_{=\\psi_{P/\\pi}\\left(  a\\right)  }\\right)  =\\varphi_{\\pi}\\left(\r\n\\psi_{P/\\pi}\\left(  a\\right)  \\right)  .\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\varphi_{\\pi}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)   &  =F^{\\deg\r\n\\left(  P/\\pi\\right)  }\\left(  \\varphi_{\\pi}\\left(  a\\right)  \\right)  \\equiv\r\nF^{\\deg\\left(  P/\\pi\\right)  }\\left(  F^{\\deg\\pi}a\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{pf.prop.F.gW-general.ex2.a1}%\r\n)}\\right) \\\\\r\n&  =\\underbrace{\\left(  F^{\\deg\\left(  P/\\pi\\right)  }F^{\\deg\\pi}\\right)\r\n}_{\\substack{=F^{\\deg\\left(  P/\\pi\\right)  +\\deg\\pi}=F^{\\deg P}\\\\\\text{(since\r\n}\\deg\\left(  P/\\pi\\right)  +\\deg\\pi=\\deg P\\\\\\text{(since }\\deg\\left(\r\nP/\\pi\\right)  =\\deg P-\\deg\\pi\\text{))}}}a=F^{\\deg P}a\\\\\r\n&  =\\psi_{P}\\left(  a\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A\r\n\\end{align*}\r\n(since $\\psi_{P}\\left(  a\\right)  =F^{\\deg P}a$ (by the definition of\r\n$\\psi_{P}$)). In other words, $\\psi_{P}\\left(  a\\right)  \\equiv\\varphi_{\\pi\r\n}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A$. Thus, Assumption 4 of Theorem \\ref{thm.F.gW-general}\r\nis satisfied. This proves Proposition \\ref{prop.F.gW-general.ex2}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.gW-general.ex3}.]Assumption 5 of Theorem\r\n\\ref{thm.F.gW-general} is satisfied\\footnote{\\textit{Proof.} Assumption 3 of\r\nTheorem \\ref{thm.F.gW-general} shows that $\\varphi_{1}=1$. Now, the definition\r\nof $\\psi_{1}$ yields $\\psi_{1}=\\varphi_{1}=1$. In other words, Assumption 5 of\r\nTheorem \\ref{thm.F.gW-general} is satisfied, qed.}. Hence, it remains to show\r\nthat Assumption 4 of Theorem \\ref{thm.F.gW-general} is satisfied. In other\r\nwords, we must prove that we have $\\psi_{P}\\left(  a\\right)  \\equiv\r\n\\varphi_{\\pi}\\left(  \\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A$ for every $a\\in A$, every $P\\in N$ and every\r\n$\\pi\\in\\operatorname*{PF}P$.\r\n\r\nSo let us fix $a\\in A$, $P\\in N$ and $\\pi\\in\\operatorname*{PF}P$. Clearly,\r\n$\\pi\\mid P$ (since $\\pi\\in\\operatorname*{PF}P$), and $\\pi$ is a monic\r\nirreducible polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $ (since $\\pi\r\n\\in\\operatorname*{PF}P$). From these two facts, we obtain $\\pi\\in N$ (since\r\n$N$ is a $q$-nest). Also, $P/\\pi$ is a monic polynomial in $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ (since $P$ and $\\pi$ are monic and since $\\pi\\mid P$),\r\nand divides $P$. Therefore, $P/\\pi\\in N$ (since $P\\in N$). Now, the second\r\nsentence of Assumption 3 of Theorem \\ref{thm.F.gW-general} (applied to $\\pi$\r\nand $P/\\pi$ instead of $P$ and $Q$) shows that $\\varphi_{\\pi}\\circ\r\n\\varphi_{P/\\pi}=\\varphi_{\\pi\\cdot\\left(  P/\\pi\\right)  }$ (since $\\pi\r\n\\cdot\\left(  P/\\pi\\right)  =P\\in N$). Since $\\pi\\cdot\\left(  P/\\pi\\right)\r\n=P$, this rewrites as $\\varphi_{\\pi}\\circ\\varphi_{P/\\pi}=\\varphi_{P}$. But the\r\ndefinition of $\\psi_{P}$ yields $\\psi_{P}=\\varphi_{P}$. Hence, $\\psi\r\n_{P}=\\varphi_{P}=\\varphi_{\\pi}\\circ\\varphi_{P/\\pi}$, so that%\r\n\\begin{equation}\r\n\\underbrace{\\psi_{P}}_{=\\varphi_{\\pi}\\circ\\varphi_{P/\\pi}}\\left(  a\\right)\r\n=\\left(  \\varphi_{\\pi}\\circ\\varphi_{P/\\pi}\\right)  \\left(  a\\right)\r\n=\\varphi_{\\pi}\\left(  \\varphi_{P/\\pi}\\left(  a\\right)  \\right)  .\r\n\\label{pf.prop.F.gW-general.ex3.1}%\r\n\\end{equation}\r\nOn the other hand, the definition of $\\psi_{P/\\pi}$ yields $\\psi_{P/\\pi\r\n}=\\varphi_{P/\\pi}$. Thus, (\\ref{pf.prop.F.gW-general.ex3.1}) rewrites as\r\n$\\psi_{P}\\left(  a\\right)  =\\varphi_{\\pi}\\left(  \\psi_{P/\\pi}\\left(  a\\right)\r\n\\right)  $. Therefore, $\\psi_{P}\\left(  a\\right)  \\equiv\\varphi_{\\pi}\\left(\r\n\\psi_{P/\\pi}\\left(  a\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(\r\nP\\right)  }A$. Thus, Assumption 4 of Theorem \\ref{thm.F.gW-general} is\r\nsatisfied. This proves Proposition \\ref{prop.F.gW-general.ex3}.\r\n\\end{proof}\r\n\r\nLet us now turn to the proof of Theorem \\ref{thm.F.gW-general}\\footnote{Our\r\nproof imitates \\cite[solution to Exercise 2.9.6]{reiner-hopf}.}:\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.F.gW-general}.]We shall prove the two implications\r\n$\\mathcal{C}_{1}\\Longrightarrow\\mathcal{E}_{\\psi}$ and $\\mathcal{E}_{\\psi\r\n}\\Longrightarrow\\mathcal{C}_{1}$ separately:\r\n\r\n\\textit{Proof of the implication }$\\mathcal{E}_{\\psi}\\Longrightarrow\r\n\\mathcal{C}_{1}$\\textit{:} Assume that Assertion $\\mathcal{E}_{\\psi}$ holds.\r\nThat is, there exists a family $\\left(  z_{P}\\right)  _{P\\in N}\\in A^{N}$ of\r\nelements of $A$ such that%\r\n\\begin{equation}\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\psi_{P / D}\\left(  z_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  . \\label{pf.thm.F.gW-general.EC.ass}%\r\n\\end{equation}\r\nConsider this family $\\left(  z_{P}\\right)  _{P\\in N}$.\r\n\r\nWe need to prove that Assertion $\\mathcal{C}_{1}$ holds, i.e., that every\r\n$P\\in N$ and every $\\pi\\in\\operatorname{PF}P$ satisfy%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P / \\pi}\\right)  \\equiv b_{P}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A. \\label{pf.thm.F.gW-general.EC.goal}%\r\n\\end{equation}\r\nSo let us fix a $P\\in N$ and a $\\pi\\in\\operatorname*{PF}P$. We need to prove\r\n(\\ref{pf.thm.F.gW-general.EC.goal}).\r\n\r\nThe polynomial $P$ is monic (since $P\\in N$). We have $\\pi\\in\r\n\\operatorname*{PF}P$. Thus, $\\pi$ is a monic irreducible divisor of $P$.\r\nHence, $P/\\pi$ is a monic polynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $\r\n(since $P$ and $\\pi$ are monic). Since $N$ is a $q$-nest, we obtain $P/\\pi\\in\r\nN$ (since $P\\in N$, and since $P/\\pi$ is a monic divisor of $N$). Since $N$ is\r\na $q$-nest, we also obtain $\\pi\\in N$ (since $P\\in N$, and since $\\pi$ is a\r\nmonic divisor of $N$).\r\n\r\nAssumption 1 (applied to $\\pi$ instead of $P$) shows that $\\varphi_{\\pi}$ is\r\nan endomorphism of the $\\mathcal{F}$-module $A$.\r\n\r\nApplying (\\ref{pf.thm.F.gW-general.EC.ass}) to $P/\\pi$ instead of $P$, we\r\nobtain $b_{P/\\pi}=\\sum_{D\\mid P/\\pi}D\\psi_{\\left(  P/\\pi\\right)  /D}\\left(\r\nz_{D}\\right)  $. Applying the map $\\varphi_{\\pi}$ to both sides of this\r\nequality, we obtain%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  =\\varphi_{\\pi}\\left(  \\sum_{D\\mid\r\nP/\\pi}D\\psi_{\\left(  P/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right)\r\n=\\sum_{D\\mid P/\\pi}D\\varphi_{\\pi}\\left(  \\psi_{\\left(  P/\\pi\\right)\r\n/D}\\left(  z_{D}\\right)  \\right)  \\label{pf.thm.F.gW-general.EC.0}%\r\n\\end{equation}\r\n(since $\\varphi_{\\pi}$ is an endomorphism of the $\\mathcal{F}$-module $A$). On\r\nthe other hand, every monic divisor $D$ of $P/\\pi$ satisfies%\r\n\\begin{equation}\r\nD\\psi_{P/D}\\left(  z_{D}\\right)  \\equiv D\\varphi_{\\pi}\\left(  \\psi_{\\left(\r\nP/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A \\label{pf.thm.F.gW-general.EC.2}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW-general.EC.2}):} Let $D$ be a\r\nmonic divisor of $P/\\pi$. Thus, $D\\mid P/\\pi$, so that $D\\mid P/\\pi\\mid P$ and\r\ntherefore $P/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\\par\r\nAlso, $\\dfrac{P/D}{\\pi}=\\dfrac{P/\\pi}{D}\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\n(since $D\\mid P/\\pi$). In other words, $\\pi\\mid P/D$ (since $P/D\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  $). Hence, $\\pi\\in\\operatorname*{PF}\\left(\r\nP/D\\right)  $ (since $\\pi$ is monic irreducible). Also, $P/D$ is a monic\r\ndivisor of $P$ (since $P$ and $D$ are monic, and since $D\\mid P$); thus,\r\n$P/D\\in N$ (since $P\\in N$ and since $N$ is a q-nest). Hence, Assumption 4\r\n(applied to $z_{D}$ and $P/D$ instead of $a$ and $P$) yields%\r\n\\[\r\n\\psi_{P/D}\\left(  z_{D}\\right)  \\equiv\\varphi_{\\pi}\\left(  \\psi_{\\left(\r\nP/D\\right)  /\\pi}\\left(  z_{D}\\right)  \\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P/D\\right)  }A.\r\n\\]\r\nIn other words, $\\psi_{P/D}\\left(  z_{D}\\right)  -\\varphi_{\\pi}\\left(\r\n\\psi_{\\left(  P/D\\right)  /\\pi}\\left(  z_{D}\\right)  \\right)  \\in\\pi^{v_{\\pi\r\n}\\left(  P/D\\right)  }A$. Since $\\left(  P/D\\right)  /\\pi=\\left(\r\nP/\\pi\\right)  /D$, this rewrites as $\\psi_{P/D}\\left(  z_{D}\\right)\r\n-\\varphi_{\\pi}\\left(  \\psi_{\\left(  P/\\pi\\right)  /D}\\left(  z_{D}\\right)\r\n\\right)  \\in\\pi^{v_{\\pi}\\left(  P/D\\right)  }A$.\r\n\\par\r\nNow,%\r\n\\begin{align*}\r\n&  D\\psi_{P/D}\\left(  z_{D}\\right)  -D\\varphi_{\\pi}\\left(  \\psi_{\\left(\r\nP/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right) \\\\\r\n&  =D\\underbrace{\\left(  \\psi_{P/D}\\left(  z_{D}\\right)  -\\varphi_{\\pi}\\left(\r\n\\psi_{\\left(  P/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right)  \\right)  }%\r\n_{\\in\\pi^{v_{\\pi}\\left(  P/D\\right)  }A}\\\\\r\n&  \\in D\\pi^{v_{\\pi}\\left(  P/D\\right)  }A=\\pi^{v_{\\pi}\\left(  P/D\\right)\r\n}\\underbrace{DA}_{\\substack{\\subseteq\\pi^{v_{\\pi}\\left(  D\\right)\r\n}A\\\\\\text{(since }\\pi^{v_{\\pi}\\left(  D\\right)  }\\mid D\\text{)}}%\r\n}\\subseteq\\underbrace{\\pi^{v_{\\pi}\\left(  P/D\\right)  }\\pi^{v_{\\pi}\\left(\r\nD\\right)  }}_{=\\pi^{v_{\\pi}\\left(  P/D\\right)  +v_{\\pi}\\left(  D\\right)  }}A\\\\\r\n&  =\\pi^{v_{\\pi}\\left(  P/D\\right)  +v_{\\pi}\\left(  D\\right)  }A=\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A\r\n\\end{align*}\r\n(since $v_{\\pi}\\left(  P/D\\right)  +v_{\\pi}\\left(  D\\right)  =v_{\\pi}\\left(\r\n\\underbrace{\\left(  P/D\\right)  D}_{=P}\\right)  =v_{\\pi}\\left(  P\\right)  $).\r\nIn other words, $D\\psi_{P/D}\\left(  z_{D}\\right)  \\equiv D\\varphi_{\\pi}\\left(\r\n\\psi_{\\left(  P/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right)\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A$. This proves\r\n(\\ref{pf.thm.F.gW-general.EC.2}).}. Now,\r\n\\begin{align}\r\n&  \\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right) \\nonumber\\\\\r\n&  =\\underbrace{\\sum_{\\substack{D\\mid P;\\\\D\\mid P/\\pi}}}_{=\\sum_{D\\mid P/\\pi}%\r\n}D\\psi_{P/D}\\left(  z_{D}\\right)  +\\sum_{\\substack{D\\mid P;\\\\D\\nmid P/\\pi\r\n}}\\underbrace{D\\psi_{P/D}\\left(  z_{D}\\right)  }_{\\substack{\\equiv\r\n0\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A\\\\\\text{(since Lemma\r\n\\ref{lem.FqT.exact-divisor} shows that}\\\\\\pi^{v_{\\pi}\\left(  P\\right)  }\\mid\r\nD\\text{)}}}\\nonumber\\\\\r\n&  \\equiv\\sum_{D\\mid P/\\pi}D\\psi_{P/D}\\left(  z_{D}\\right)  +\\underbrace{\\sum\r\n_{\\substack{D\\mid P;\\\\D\\nmid P/\\pi}}0}_{=0}=\\sum_{D\\mid P/\\pi}%\r\n\\underbrace{D\\psi_{P/D}\\left(  z_{D}\\right)  }_{\\substack{\\equiv D\\varphi\r\n_{\\pi}\\left(  \\psi_{\\left(  P/\\pi\\right)  /D}\\left(  z_{D}\\right)  \\right)\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A\\\\\\text{(by\r\n(\\ref{pf.thm.F.gW-general.EC.2}))}}}\\label{pf.thm.F.gW-general.EC.1}\\\\\r\n&  \\equiv\\sum_{D\\mid P/\\pi}D\\varphi_{\\pi}\\left(  \\psi_{\\left(  P/\\pi\\right)\r\n/D}\\left(  z_{D}\\right)  \\right) \\label{pf.thm.F.gW-general.EC.1b}\\\\\r\n&  =\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  \\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }A \\label{pf.thm.F.gW-general.EC.1c}%\r\n\\end{align}\r\n(by (\\ref{pf.thm.F.gW-general.EC.0})). But (\\ref{pf.thm.F.gW-general.EC.ass})\r\nyields%\r\n\\[\r\nb_{P}=\\sum_{D\\mid P}D\\psi_{P / D}\\left(  z_{D}\\right)  \\equiv\\varphi_{\\pi\r\n}\\left(  b_{P/\\pi}\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A\r\n\\]\r\n(by (\\ref{pf.thm.F.gW-general.EC.1c})). Thus,\r\n(\\ref{pf.thm.F.gW-general.EC.goal}) is proven. In other words, Assertion\r\n$\\mathcal{C}_{1}$ holds. This completes the proof of the implication\r\n$\\mathcal{E}_{\\psi}\\Longrightarrow\\mathcal{C}_{1}$.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{C}_{1}\\Longrightarrow\r\n\\mathcal{E}_{\\psi}$\\textit{:} Assume that Assertion $\\mathcal{C}_{1}$ holds.\r\nIn other words, every $P\\in N$ and every $\\pi\\in\\operatorname{PF}P$ satisfy%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P / \\pi}\\right)  \\equiv b_{P}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A. \\label{pf.thm.F.gW-general.CE.C}%\r\n\\end{equation}\r\n\r\n\r\nWe now need to prove that Assertion $\\mathcal{E}_{\\psi}$ holds as well. In\r\nother words, we need to show that there exists a family $\\left(  z_{P}\\right)\r\n_{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\psi_{P / D}\\left(  z_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  .\r\n\\]\r\nIn other words (renaming $P$ as $Q$), we need to show that there exists a\r\nfamily $\\left(  z_{Q}\\right)  _{Q\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{Q}=\\sum_{D\\mid Q}D\\psi_{Q / D}\\left(  z_{D}\\right)  \\text{ for\r\nevery }Q\\in N\\right)  .\r\n\\]\r\n\r\n\r\nWe construct this family $\\left(  z_{Q}\\right)  _{Q\\in N}$ recursively, by\r\ninduction over $\\deg Q$. So we fix some $P\\in N$, and assume that an element\r\n$z_{Q}$ of $A$ is already constructed for every $Q\\in N$ satisfying $\\deg\r\nQ<\\deg P$; we furthermore assume that these $z_{Q}$ satisfy%\r\n\\begin{equation}\r\nb_{Q}=\\sum_{D\\mid Q}D\\psi_{Q/D}\\left(  z_{D}\\right)\r\n\\label{pf.thm.F.gW-general.CE.C.indass}%\r\n\\end{equation}\r\nfor every $Q\\in N$ satisfying $\\deg Q<\\deg P$. We now need to construct a\r\n$z_{P}\\in A$ such that (\\ref{pf.thm.F.gW-general.CE.C.indass}) is satisfied\r\nfor $Q=P$. In other words, we need to construct a $z_{P}\\in A$ satisfying\r\n$b_{P}=\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  $.\r\n\r\nLet us first choose $z_{P}$ \\textbf{arbitrarily} (with the intention to tweak\r\nit later). Let $\\pi\\in\\operatorname*{PF}P$ be arbitrary. Thus, $\\pi$ is a\r\nmonic irreducible divisor of $P$. Then, the polynomial $P/\\pi$ is monic (since\r\n$P$ and $\\pi$ are monic), and is a divisor of $P$; hence, $P/\\pi\\in N$ (since\r\n$P\\in N$, and since $N$ is a $q$-nest). Moreover, it satisfies $\\deg\\left(\r\nP/\\pi\\right)  =\\deg P-\\underbrace{\\deg\\pi}_{>0}<\\deg P$. Hence,\r\n(\\ref{pf.thm.F.gW-general.CE.C.indass}) (applied to $Q=P/\\pi$) shows that%\r\n\\[\r\nb_{P/\\pi}=\\sum_{D\\mid P/\\pi}D\\psi_{\\left(  P/\\pi\\right)  /D}\\left(\r\nz_{D}\\right)  .\r\n\\]\r\nThus, (\\ref{pf.thm.F.gW-general.EC.1c}) holds (indeed, this can be proven\r\nprecisely as in our proof of the implication $\\mathcal{E}_{\\psi}%\r\n\\Longrightarrow\\mathcal{C}_{1}$ above). Hence,%\r\n\\[\r\n\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  \\equiv\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A\r\n\\]\r\n(by (\\ref{pf.thm.F.gW-general.CE.C})). In other words, $b_{P}\\equiv\\sum_{D\\mid\r\nP}D\\psi_{P/D}\\left(  z_{D}\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(\r\nP\\right)  }A$. In other words, $b_{P}-\\sum_{D\\mid P}D\\psi_{P/D}\\left(\r\nz_{D}\\right)  \\in\\pi^{v_{\\pi}\\left(  P\\right)  }A$.\r\n\r\nNow, let us forget that we fixed $\\pi$. We thus have shown (for our\r\narbitrarily chosen $z_{P}$) that%\r\n\\[\r\nb_{P}-\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  \\in\\pi^{v_{\\pi}\\left(\r\nP\\right)  }A\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }\\pi\\in\\operatorname*{PF}P.\r\n\\]\r\nAs a consequence,%\r\n\\[\r\nb_{P}-\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  \\in\\bigcap_{\\pi\r\n\\in\\operatorname*{PF}P}\\pi^{v_{\\pi}\\left(  P\\right)  }A=PA\r\n\\]\r\n(by Corollary \\ref{cor.CRT.FqT}). In other words, there exists a $\\gamma\\in A$\r\nsuch that\r\n\\[\r\nb_{P}-\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  =P\\gamma.\r\n\\]\r\nConsider this $\\gamma$.\r\n\r\nWe have assumed that Assumption 5 of Theorem \\ref{thm.F.gW-general} is\r\nsatisfied. In other words, $\\psi_{1}=\\operatorname*{id}$. Hence,%\r\n\\begin{align*}\r\n&  P\\psi_{P/P}\\left(  z_{P}+\\gamma\\right)  -P\\psi_{P/P}\\left(  z_{P}\\right) \\\\\r\n&  =P\\operatorname*{id}\\left(  z_{P}+\\gamma\\right)  -P\\operatorname*{id}%\r\n\\left(  z_{P}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\psi_{P/P}%\r\n=\\psi_{1}=\\operatorname*{id}\\right) \\\\\r\n&  =P\\cdot\\left(  z_{P}+\\gamma\\right)  -P\\cdot z_{P}=P\\gamma\\\\\r\n&  =b_{P}-\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  .\r\n\\end{align*}\r\nIn other words,%\r\n\\begin{align}\r\n&  \\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  +\\left(  P\\psi_{P/P}\\left(\r\nz_{P}+\\gamma\\right)  -P\\psi_{P/P}\\left(  z_{P}\\right)  \\right) \\nonumber\\\\\r\n&  =b_{P}. \\label{pf.thm.F.gW-general.CE.C.sum-upd}%\r\n\\end{align}\r\n\r\n\r\nNow, if we replace $z_{P}$ by $z_{P}+\\gamma$, then the sum $\\sum_{D\\mid\r\nP}D\\psi_{P/D}\\left(  z_{D}\\right)  $ increases by $P\\psi_{P/P}\\left(\r\nz_{P}+\\gamma\\right)  -P\\psi_{P/P}\\left(  z_{P}\\right)  $ (because the only\r\naddend of the sum that changes is the addend for $D=P$), and thus the new\r\nvalue of this sum is $b_{P}$ (by (\\ref{pf.thm.F.gW-general.CE.C.sum-upd})).\r\nHence, by replacing $z_{P}$ by $z_{P}+\\gamma$, we achieve that $b_{P}%\r\n=\\sum_{D\\mid P}D\\psi_{P/D}\\left(  z_{D}\\right)  $ holds. Thus, we have found\r\nthe $z_{P}$ we were searching for, and the recursive construction of the\r\nfamily $\\left(  z_{Q}\\right)  _{Q\\in N}$ has proceeded by one more step. The\r\nproof of the implication $\\mathcal{C}_{1}\\Longrightarrow\\mathcal{E}_{\\psi}$ is\r\nthus complete.\r\n\r\nWe have now proven both implications $\\mathcal{C}_{1}\\Longrightarrow\r\n\\mathcal{E}_{\\psi}$ and $\\mathcal{E}_{\\psi}\\Longrightarrow\\mathcal{C}_{1}$.\r\nCombining them, we obtain the equivalence $\\mathcal{C}_{1}\\Longleftrightarrow\r\n\\mathcal{E}_{\\psi}$. Thus, Theorem \\ref{thm.F.gW-general} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{\\label{subsect.proofs.numthefuns}$\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}$-analogues of the M\\\"{o}bius and Euler totient functions}\r\n\r\nNext, we shall discuss the functions $\\mu$, $\\varphi$ and $\\varphi_{C}$\r\nintroduced in Section \\ref{sect.nots}. Let me first repeat their definitions:\r\n\r\n\\begin{definition}\r\n\\label{def.moebius-q}Define a function $\\mu:\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}\\rightarrow\\left\\{  -1,0,1\\right\\}  $ by%\r\n\\[\r\n\\mu\\left(  M\\right)  =%\r\n\\begin{cases}\r\n\\left(  -1\\right)  ^{\\left\\vert \\operatorname*{PF}M\\right\\vert }, & \\text{if\r\n}M\\text{ is squarefree;}\\\\\r\n0, & \\text{if }M\\text{ is not squarefree}%\r\n\\end{cases}\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}.\r\n\\]\r\n(Recall that a monic polynomial $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ is\r\nsaid to be \\textit{squarefree} if it satisfies the following three equivalent conditions:\r\n\r\n\\begin{itemize}\r\n\\item No nonconstant polynomial $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\nsatisfies $P^{2}\\mid M$.\r\n\r\n\\item Every monic irreducible polynomial $\\pi\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ satisfies $v_{\\pi}\\left(  M\\right)  \\leq1$.\r\n\r\n\\item The polynomial $M$ is a product of pairwise distinct monic irreducible polynomials.\r\n\\end{itemize}\r\n\r\n) The function $\\mu$ is called the \\textit{M\\\"{o}bius function on }%\r\n$\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\n\\end{definition}\r\n\r\n\\begin{definition}\r\n\\label{def.phiC-q}Define a function $\\varphi_{C}:\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $ by%\r\n\\[\r\n\\varphi_{C}\\left(  M\\right)  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)\r\n\\dfrac{M}{D}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }M\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}.\r\n\\]\r\n\r\n\\end{definition}\r\n\r\n\\begin{definition}\r\n\\label{def.phi-q}Define a function $\\varphi:\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}\\rightarrow\\mathbb{Z}$ by%\r\n\\[\r\n\\varphi\\left(  M\\right)  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }M\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  _{+}.\r\n\\]\r\n\r\n\\end{definition}\r\n\r\nThe function $\\mu$ is an analogue of the number-theoretical M\\\"{o}bius\r\nfunction, whereas the functions $\\varphi_{C}$ and $\\varphi$ are two distinct\r\nanalogues of the Euler totient function. These functions have a number of\r\nproperties (some well-known) that often imitate analogous properties of the\r\nnumber-theoretical M\\\"{o}bius function and the Euler totient function. See\r\n\\cite[Theorem 4.5]{kc-carlitz} for some properties of $\\varphi_{C}$, and see\r\n\\cite[Section 6]{kc-carlitz} for the function $\\varphi$. We shall prove a\r\nnumber of their properties, many of which will be used below. We begin by\r\nciting a well-known combinatorial fact:\r\n\r\n\\begin{lemma}\r\n\\label{lem.moebius-Q.Z}Let $Z$ be a finite set.\r\n\r\n\\textbf{(a)} We have%\r\n\\[\r\n\\sum_{I\\subseteq Z}\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert }=\\left[\r\nZ=\\varnothing\\right]  .\r\n\\]\r\n\r\n\r\n\\textbf{(b)} Let $R$ be a commutative ring. Let $r_{i}$ be an element of $R$\r\nfor each $i\\in Z$. Then,%\r\n\\[\r\n\\sum_{I\\subseteq Z}\\prod_{i\\in I}r_{i}=\\prod_{i\\in Z}\\left(  1+r_{i}\\right)\r\n.\r\n\\]\r\n\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.moebius-Q.Z}.]Lemma \\ref{lem.moebius-Q.Z}\r\n\\textbf{(b)} can be proven by induction over $\\left\\vert Z\\right\\vert $ (or,\r\nless rigorously, just by expanding the product $\\prod_{i\\in Z}\\left(\r\n1+r_{i}\\right)  $). Lemma \\ref{lem.moebius-Q.Z} \\textbf{(a)} can be proven in\r\nmany ways (e.g., it can be obtained by setting $R=\\mathbb{Z}$ and $r_{i}=-1$\r\nin Lemma \\ref{lem.moebius-Q.Z} \\textbf{(b)}).\r\n\\end{proof}\r\n\r\n\\begin{proposition}\r\n\\label{prop.moebius-Q.sum}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\nThen, $\\sum_{D\\mid M}\\mu\\left(  D\\right)  =\\left[  M=1\\right]  $. Here, we are\r\nusing the \\textit{Iverson bracket notation}: If $\\mathcal{A}$ is any logical\r\nstatement, then $\\left[  \\mathcal{A}\\right]  $ stands for the integer $%\r\n\\begin{cases}\r\n1, & \\text{if }\\mathcal{A}\\text{ is true};\\\\\r\n0, & \\text{if }\\mathcal{A}\\text{ is false}%\r\n\\end{cases}\r\n$.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.moebius-Q.sum}.](This proof is a carbon copy\r\nof \\cite[proof of (12.68.3)]{reiner-hopf}, with minor changes.)\r\n\r\nLet $M=P_{1}^{a_{1}}P_{2}^{a_{2}}\\cdots P_{k}^{a_{k}}$ be the factorization of\r\n$M$ into monic irreducible polynomials, with all of $a_{1},a_{2},\\ldots,a_{k}$\r\nbeing positive integers (and with $P_{1},P_{2},\\ldots,P_{k}$ being\r\ndistinct).\\footnote{This is well-defined, since $M$ is monic and since\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $ is a principal ideal domain. Of course, $k$\r\ncan be $0$ (when $M=1$).} Then, the \\textbf{squarefree} monic divisors $D$ of\r\n$M$ all have the form $\\prod_{i\\in I}P_{i}$ for some subset $I$ of $\\left\\{\r\n1,2,\\ldots,k\\right\\}  $. More precisely, there exists a bijection%\r\n\\begin{align}\r\n\\left\\{  I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  \\right\\}   &  \\rightarrow\r\n\\left(  \\text{the set of all squarefree monic divisors of }M\\right)\r\n,\\nonumber\\\\\r\nI  &  \\mapsto\\prod_{i\\in I}P_{i}. \\label{pf.prop.moebius-Q.sum.bij}%\r\n\\end{align}\r\nMoreover, every subset $I$ of $\\left\\{  1,2,\\ldots,k\\right\\}  $ satisfies\r\n$\\operatorname*{PF}\\left(  \\prod_{i\\in I}P_{i}\\right)  =\\left\\{  P_{i}%\r\n\\ \\mid\\ i\\in I\\right\\}  $ and thus%\r\n\\begin{equation}\r\n\\left\\vert \\operatorname*{PF}\\left(  \\prod_{i\\in I}P_{i}\\right)  \\right\\vert\r\n=\\left\\vert \\left\\{  P_{i}\\ \\mid\\ i\\in I\\right\\}  \\right\\vert =\\left\\vert\r\nI\\right\\vert \\label{pf.prop.moebius-Q.sum.1}%\r\n\\end{equation}\r\n(since $P_{1},P_{2},\\ldots,P_{k}$ are distinct) and therefore\r\n\\begin{align}\r\n\\mu\\left(  \\prod_{i\\in I}P_{i}\\right)   &  =\\left(  -1\\right)  ^{\\left\\vert\r\n\\operatorname*{PF}\\left(  \\prod_{i\\in I}P_{i}\\right)  \\right\\vert\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\prod_{i\\in I}P_{i}\\text{ is\r\nsquarefree}\\right) \\nonumber\\\\\r\n&  =\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{pf.prop.moebius-Q.sum.1})}\\right)  .\r\n\\label{pf.prop.moebius-Q.sum.2}%\r\n\\end{align}\r\nNow,%\r\n\\begin{align*}\r\n\\sum_{D\\mid M}\\mu\\left(  D\\right)   &  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is\r\nsquarefree}}}\\mu\\left(  D\\right)  +\\sum_{\\substack{D\\mid M;\\\\D\\text{ is not\r\nsquarefree}}}\\underbrace{\\mu\\left(  D\\right)  }_{\\substack{=0\\\\\\text{(by the\r\ndefinition}\\\\\\text{of }\\mu\\text{, since }D\\\\\\text{is not squarefree)}}}\\\\\r\n&  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\n+\\underbrace{\\sum_{\\substack{D\\mid M;\\\\D\\text{ is not squarefree}}}0}%\r\n_{=0}=\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right) \\\\\r\n&  =\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\underbrace{\\mu\\left(\r\n\\prod_{i\\in I}P_{i}\\right)  }_{\\substack{=\\left(  -1\\right)  ^{\\left\\vert\r\nI\\right\\vert }\\\\\\text{(by (\\ref{pf.prop.moebius-Q.sum.2}))}}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\prod_{i\\in I}P_{i}\\text{ for }D\\\\\r\n\\text{due to the bijection (\\ref{pf.prop.moebius-Q.sum.bij})}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\left(  -1\\right)\r\n^{\\left\\vert I\\right\\vert }=\\left[  \\underbrace{\\left\\{  1,2,\\ldots,k\\right\\}\r\n=\\varnothing}_{\\text{This is equivalent to }k=0}\\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Lemma \\ref{lem.moebius-Q.Z}\r\n\\textbf{(a)}, applied to }Z=\\left\\{  1,2,\\ldots,k\\right\\}  \\right) \\\\\r\n&  =\\left[  k=0\\right]  =\\left[  M\\text{ is constant}\\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }k\\text{ is the number of monic irreducible divisors of }%\r\nM\\text{,}\\\\\r\n\\text{and thus we have }k=0\\text{ if and only if }M\\text{ is constant}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\left[  M=1\\right]  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }M\\text{ is\r\nmonic}\\right)  .\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.moebius-Q.sum}.\r\n\\end{proof}\r\n\r\nLet us explicitly state a simple consequence of Proposition\r\n\\ref{prop.moebius-Q.sum} for the sake of convenience:\r\n\r\n\\begin{corollary}\r\n\\label{cor.moebius-Q.sum-rel}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\nLet $E$ be a monic divisor of $M$. Then,%\r\n\\[\r\n\\sum_{\\substack{B\\mid M;\\\\BE\\mid M}}\\mu\\left(  B\\right)  =\\left[  E=M\\right]\r\n.\r\n\\]\r\n\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary \\ref{cor.moebius-Q.sum-rel}.]We have $\\dfrac{M}{E}%\r\n\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since $E$ is a divisor of $M$).\r\nMoreover, the polynomial $\\dfrac{M}{E}$ is monic (since $M$ and $E$ are\r\nmonic). Hence, $\\dfrac{M}{E}\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\nProposition \\ref{prop.moebius-Q.sum} (applied to $\\dfrac{M}{E}$ instead of\r\n$M$) thus shows that $\\sum_{D\\mid\\dfrac{M}{E}}\\mu\\left(  D\\right)  =\\left[\r\n\\underbrace{\\dfrac{M}{E}=1}_{\\substack{\\text{This is equivalent to}%\r\n\\\\E=M}}\\right]  =\\left[  E=M\\right]  $.\r\n\r\nBut $E\\mid M$. Hence, the monic divisors $B$ of $M$ satisfying $BE\\mid M$ are\r\nexactly the monic divisors $B$ of $\\dfrac{M}{E}$. Therefore, $\\sum\r\n_{\\substack{B\\mid M;\\\\BE\\mid M}}=\\sum_{B\\mid\\dfrac{M}{E}}$. Thus,%\r\n\\begin{align*}\r\n\\underbrace{\\sum_{\\substack{B\\mid M;\\\\BE\\mid M}}}_{=\\sum_{B\\mid\\dfrac{M}{E}}%\r\n}\\mu\\left(  B\\right)   &  =\\sum_{B\\mid\\dfrac{M}{E}}\\mu\\left(  B\\right)\r\n=\\sum_{D\\mid\\dfrac{M}{E}}\\mu\\left(  D\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the summation index\r\n}B\\text{ as }D\\right) \\\\\r\n&  =\\left[  E=M\\right]  .\r\n\\end{align*}\r\nCorollary \\ref{cor.moebius-Q.sum-rel} is therefore proven.\r\n\\end{proof}\r\n\r\nNext come some simple properties of $\\varphi_{C}$:\r\n\r\n\\begin{proposition}\r\n\\label{prop.phiC-Q.formula}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\n\r\n\\textbf{(a)} We have $\\varphi_{C}\\left(  M\\right)  \\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}$.\r\n\r\n\\textbf{(b)} We have $\\varphi_{C}\\left(  M\\right)  =M\\prod\\limits_{\\pi\r\n\\in\\operatorname*{PF}M}\\left(  1-\\dfrac{1}{\\pi}\\right)  $.\r\n\r\n\\textbf{(c)} We have $\\varphi_{C}\\left(  M\\right)  =\\sum_{D\\mid M}D\\mu\\left(\r\n\\dfrac{M}{D}\\right)  $.\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.phiC-Q.formula}.]\\textbf{(a)} Let $d=\\deg M$.\r\nThen, the polynomial $M$ is monic of degree $d$.\r\n\r\nNow, let $V_{d}$ be the $\\mathbb{F}_{q}$-vector subspace of $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ consisting of all polynomials of degree $\\leq d-1$.\r\n(This subspace is spanned by $T^{0},T^{1},\\ldots,T^{d-1}$.) Then, the monic\r\npolynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $ of degree $d$ are precisely\r\nthe polynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $ that are congruent to\r\n$T^{d}$ modulo $V_{d}$. Thus, the polynomial $M$ is congruent to $T^{d}$\r\nmodulo $V_{d}$ (since $M$ is monic of degree $d$). In other words, $M\\equiv\r\nT^{d}\\operatorname{mod}V_{d}.$\r\n\r\nIf $D$ is a monic divisor of $M$ satisfying $D\\neq1$, then\r\n\\begin{equation}\r\n\\mu\\left(  D\\right)  \\dfrac{M}{D}\\equiv0\\operatorname{mod}V_{d}\r\n\\label{pf.prop.phiC-Q.formula.a.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phiC-Q.formula.a.1}):} Let $D$ be a\r\nmonic divisor of $M$ satisfying $D\\neq1$.\r\n\\par\r\nWe have $\\dfrac{M}{D}\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since $D$ is a\r\ndivisor of $M$). If we had $\\deg D=0$, then we would have $D=1$ (because $D$\r\nis monic), which would contradict $D\\neq1$. Thus, we cannot have $\\deg D=0$.\r\nHence, we must have $\\deg D\\geq1$ (since $D\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n$). Thus, the polynomial $\\dfrac{M}{D}\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\nsatisfies $\\deg\\dfrac{M}{D}=\\underbrace{\\deg M}_{=d}-\\underbrace{\\deg D}%\r\n_{\\geq1}\\leq d-1$. Hence, $\\dfrac{M}{D}$ is a polynomial of degree $\\leq d-1$.\r\nIn other words, $\\dfrac{M}{D}\\in V_{d}$ (since $V_{d}$ is the $\\mathbb{F}_{q}%\r\n$-vector subspace of $\\mathbb{F}_{q}\\left[  T\\right]  $ consisting of all\r\npolynomials of degree $\\leq d-1$). In other words, $\\dfrac{M}{D}%\r\n\\equiv0\\operatorname{mod}V_{d}$. Hence, $\\mu\\left(  D\\right)  \\dfrac{M}%\r\n{D}\\equiv0\\operatorname{mod}V_{d}$ as well (since $\\mu\\left(  D\\right)\r\n\\in\\left\\{  -1,0,1\\right\\}  \\subseteq\\mathbb{Z}$). This proves\r\n(\\ref{pf.prop.phiC-Q.formula.a.1}).}. Now, the definition of $\\varphi_{C}$\r\nyields%\r\n\\begin{align*}\r\n\\varphi_{C}\\left(  M\\right)   &  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)\r\n\\dfrac{M}{D}\\\\\r\n&  =\\underbrace{\\mu\\left(  1\\right)  }_{=1}\\underbrace{\\dfrac{M}{1}}_{=M\\equiv\r\nT^{d}\\operatorname{mod}V_{d}}+\\sum\\limits_{\\substack{D\\mid M;\\\\D\\neq\r\n1}}\\underbrace{\\mu\\left(  D\\right)  \\dfrac{M}{D}}_{\\substack{\\equiv\r\n0\\operatorname{mod}V_{d}\\\\\\text{(by (\\ref{pf.prop.phiC-Q.formula.a.1}))}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}D=1\\text{ from the sum}\\right) \\\\\r\n&  \\equiv T^{d}+\\underbrace{\\sum\\limits_{\\substack{D\\mid M;\\\\D\\neq1}}0}%\r\n_{=0}=T^{d}\\operatorname{mod}V_{d}.\r\n\\end{align*}\r\nIn other words, the polynomial $\\varphi_{C}\\left(  M\\right)  $ is congruent to\r\n$T^{d}$ modulo $V_{d}$. In other words, the polynomial $\\varphi_{C}\\left(\r\nM\\right)  $ is monic of degree $d$ (since the monic polynomials in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $ of degree $d$ are precisely the polynomials\r\nin $\\mathbb{F}_{q}\\left[  T\\right]  $ that are congruent to $T^{d}$ modulo\r\n$V_{d}$). Hence, $\\varphi_{C}\\left(  M\\right)  \\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}$. This proves Proposition \\ref{prop.phiC-Q.formula}\r\n\\textbf{(a)}.\r\n\r\n\\textbf{(b)} Let $M=P_{1}^{a_{1}}P_{2}^{a_{2}}\\cdots P_{k}^{a_{k}}$ be the\r\nfactorization of $M$ into monic irreducible polynomials, with all of\r\n$a_{1},a_{2},\\ldots,a_{k}$ being positive integers (and with $P_{1}%\r\n,P_{2},\\ldots,P_{k}$ being distinct).\\footnote{This is well-defined, since $M$\r\nis monic and since $\\mathbb{F}_{q}\\left[  T\\right]  $ is a principal ideal\r\ndomain. Of course, $k$ can be $0$ (when $M=1$).} Then, the \\textbf{squarefree}\r\nmonic divisors $D$ of $M$ all have the form $\\prod_{i\\in I}P_{i}$ for some\r\nsubset $I$ of $\\left\\{  1,2,\\ldots,k\\right\\}  $. More precisely, there exists\r\na bijection%\r\n\\begin{align}\r\n\\left\\{  I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  \\right\\}   &  \\rightarrow\r\n\\left(  \\text{the set of all squarefree monic divisors of }M\\right)\r\n,\\nonumber\\\\\r\nI  &  \\mapsto\\prod_{i\\in I}P_{i}. \\label{pf.prop.phiC-Q.formula.b.bij}%\r\n\\end{align}\r\n\r\n\r\nMoreover, every subset $I$ of $\\left\\{  1,2,\\ldots,k\\right\\}  $ satisfies\r\n(\\ref{pf.prop.moebius-Q.sum.2}). (This is proven as in our proof of\r\nProposition \\ref{prop.moebius-Q.sum}.)\r\n\r\nThe definition of $P_{1},P_{2},\\ldots,P_{k}$ shows that $\\left(  P_{1}%\r\n,P_{2},\\ldots,P_{k}\\right)  $ is a list of all prime factors of $M$, with no\r\nrepetitions. Thus, the map $\\left\\{  1,2,\\ldots,k\\right\\}  \\rightarrow\r\n\\operatorname*{PF}M,\\ i\\mapsto P_{i}$ is a bijection.\r\n\r\nThe definition of $\\varphi_{C}$ yields%\r\n\\begin{align*}\r\n\\varphi_{C}\\left(  M\\right)   &  =\\sum_{D\\mid M}\\mu\\left(  D\\right)  \\dfrac\r\n{M}{D}=\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\n\\dfrac{M}{D}+\\sum_{\\substack{D\\mid M;\\\\D\\text{ is not squarefree}%\r\n}}\\underbrace{\\mu\\left(  D\\right)  }_{\\substack{=0\\\\\\text{(by the\r\ndefinition}\\\\\\text{of }\\mu\\text{, since }D\\\\\\text{is not squarefree)}}%\r\n}\\dfrac{M}{D}\\\\\r\n&  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\n\\dfrac{M}{D}+\\underbrace{\\sum_{\\substack{D\\mid M;\\\\D\\text{ is not squarefree}%\r\n}}0\\dfrac{M}{D}}_{=0}=\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}%\r\n}\\mu\\left(  D\\right)  \\dfrac{M}{D}\\\\\r\n&  =\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\underbrace{\\mu\\left(\r\n\\prod_{i\\in I}P_{i}\\right)  }_{\\substack{=\\left(  -1\\right)  ^{\\left\\vert\r\nI\\right\\vert }\\\\\\text{(by (\\ref{pf.prop.moebius-Q.sum.2}))}}}\\dfrac{M}%\r\n{\\prod_{i\\in I}P_{i}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\prod_{i\\in I}P_{i}\\text{ for }D\\\\\r\n\\text{due to the bijection (\\ref{pf.prop.moebius-Q.sum.bij})}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\underbrace{\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }}_{=\\prod_{i\\in I}\\left(  -1\\right)\r\n}\\dfrac{M}{\\prod_{i\\in I}P_{i}}=\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}\r\n}\\left(  \\prod_{i\\in I}\\left(  -1\\right)  \\right)  \\dfrac{M}{\\prod_{i\\in\r\nI}P_{i}}\\\\\r\n&  =M\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\underbrace{\\dfrac\r\n{\\prod_{i\\in I}\\left(  -1\\right)  }{\\prod_{i\\in I}P_{i}}}_{=\\prod_{i\\in\r\nI}\\dfrac{-1}{P_{i}}}=M\\underbrace{\\sum_{I\\subseteq\\left\\{  1,2,\\ldots\r\n,k\\right\\}  }\\prod_{i\\in I}\\dfrac{-1}{P_{i}}}_{\\substack{=\\prod_{i\\in\\left\\{\r\n1,2,\\ldots,k\\right\\}  }\\left(  1+\\dfrac{-1}{P_{i}}\\right)  \\\\\\text{(by Lemma\r\n\\ref{lem.moebius-Q.Z} \\textbf{(b)}, applied to }R=\\mathbb{F}_{q}\\left[\r\nT\\right]  \\text{,}\\\\Z=\\left\\{  1,2,\\ldots,k\\right\\}  \\text{ and }r_{i}%\r\n=\\dfrac{-1}{P_{i}}\\text{)}}}\\\\\r\n&  =M\\prod_{i\\in\\left\\{  1,2,\\ldots,k\\right\\}  }\\left(  1+\\dfrac{-1}{P_{i}%\r\n}\\right)  =M\\prod_{\\pi\\in\\operatorname*{PF}M}\\underbrace{\\left(  1+\\dfrac\r\n{-1}{\\pi}\\right)  }_{=1-\\dfrac{1}{\\pi}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\pi\\text{ for }P_{i}\\text{ in the product,}\\\\\r\n\\text{since the map }\\left\\{  1,2,\\ldots,k\\right\\}  \\rightarrow\r\n\\operatorname*{PF}M,\\ i\\mapsto P_{i}\\text{ is a bijection}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =M\\prod\\limits_{\\pi\\in\\operatorname*{PF}M}\\left(  1-\\dfrac{1}{\\pi}\\right)\r\n.\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.phiC-Q.formula} \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Let $\\mathfrak{A}$ be the set of all monic divisors of $M$. Thus,\r\n$\\sum_{D\\in\\mathfrak{A}}=\\sum_{D\\mid M}$.\r\n\r\nBut $M$ itself is monic. Hence, the map $\\mathfrak{A}\\rightarrow\r\n\\mathfrak{A},\\ D\\mapsto\\dfrac{M}{D}$ is well-defined and a bijection. Thus, we\r\ncan substitute $\\dfrac{M}{D}$ for $D$ in the sum $\\sum_{D\\in\\mathfrak{A}}%\r\n\\mu\\left(  D\\right)  \\dfrac{M}{D}$. As a result, we obtain%\r\n\\[\r\n\\sum_{D\\in\\mathfrak{A}}\\mu\\left(  D\\right)  \\dfrac{M}{D}=\\underbrace{\\sum\r\n_{D\\in\\mathfrak{A}}}_{=\\sum_{D\\mid M}}\\mu\\left(  \\dfrac{M}{D}\\right)\r\n\\underbrace{\\dfrac{M}{\\left(  \\dfrac{M}{D}\\right)  }}_{=D}=\\sum_{D\\mid M}%\r\n\\mu\\left(  \\dfrac{M}{D}\\right)  D=\\sum_{D\\mid M}D\\mu\\left(  \\dfrac{M}%\r\n{D}\\right)  .\r\n\\]\r\nComparing this with%\r\n\\[\r\n\\underbrace{\\sum_{D\\in\\mathfrak{A}}}_{=\\sum_{D\\mid M}}\\mu\\left(  D\\right)\r\n\\dfrac{M}{D}=\\sum_{D\\mid M}\\mu\\left(  D\\right)  \\dfrac{M}{D}=\\varphi\r\n_{C}\\left(  M\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\varphi_{C}\\left(  M\\right)  \\text{ is defined}\\\\\r\n\\text{to be }\\sum_{D\\mid M}\\mu\\left(  D\\right)  \\dfrac{M}{D}%\r\n\\end{array}\r\n\\right)  ,\r\n\\]\r\nwe obtain $\\varphi_{C}\\left(  M\\right)  =\\sum_{D\\mid M}D\\mu\\left(  \\dfrac\r\n{M}{D}\\right)  $. This proves Proposition \\ref{prop.phiC-Q.formula}\r\n\\textbf{(c)}.\r\n\\end{proof}\r\n\r\n\\begin{proposition}\r\n\\label{prop.phiC-Q.sum}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Then,\r\n$M=\\sum\\limits_{D\\mid M}\\varphi_{C}\\left(  D\\right)  $.\r\n\\end{proposition}\r\n\r\nProposition \\ref{prop.phiC-Q.sum} is \\cite[Theorem 4.5 (2)]{kc-carlitz}, but\r\nlet me nevertheless give an independent proof of it:\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.phiC-Q.sum}.]We shall use the notation of\r\nProposition \\ref{prop.moebius-Q.sum}.\r\n\r\nEvery $E\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ satisfies%\r\n\\begin{align}\r\n\\varphi_{C}\\left(  E\\right)   &  =\\sum\\limits_{D\\mid E}\\mu\\left(  D\\right)\r\n\\dfrac{E}{D}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\varphi_{C}\\right) \\nonumber\\\\\r\n&  =\\sum_{B\\mid E}\\mu\\left(  B\\right)  \\dfrac{E}{B}\r\n\\label{pf.prop.phiC-Q.sum.phiCE=}%\r\n\\end{align}\r\n(here, we have renamed the summation index $D$ as $B$).\r\n\r\nFor any monic divisor $B$ of $M$, we have%\r\n\\begin{equation}\r\n\\sum_{\\substack{D\\mid M;\\\\B\\mid D}}\\dfrac{D}{B}=\\sum_{E\\mid\\dfrac{M}{B}}E\r\n\\label{pf.prop.phiC-Q.sum.down}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phiC-Q.sum.down}):} Let $B$ be a\r\nmonic divisor of $M$. Then, the map%\r\n\\begin{align*}\r\n\\left\\{  D\\text{ is a monic divisor of }M\\text{ such that }B\\mid D\\right\\}\r\n&  \\rightarrow\\left\\{  E\\text{ is a monic divisor of }\\dfrac{M}{B}\\right\\}\r\n,\\\\\r\nD  &  \\mapsto\\dfrac{D}{B}%\r\n\\end{align*}\r\n(where the symbol \\textquotedblleft$\\mid$\\textquotedblright\\ means\r\n\\textquotedblleft divides\\textquotedblright, not \\textquotedblleft such\r\nthat\\textquotedblright) is well-defined and a bijection. Hence, we can\r\nsubstitute $E$ for $\\dfrac{D}{B}$ in the sum $\\sum_{\\substack{D\\mid M;\\\\B\\mid\r\nD}}\\dfrac{D}{B}$. We thus obtain $\\sum_{\\substack{D\\mid M;\\\\B\\mid D}}\\dfrac\r\n{D}{B}=\\sum_{E\\mid\\dfrac{M}{B}}E$. This proves (\\ref{pf.prop.phiC-Q.sum.down}%\r\n).}.\r\n\r\nNow,%\r\n\\begin{align*}\r\n&  \\sum\\limits_{D\\mid M}\\underbrace{\\varphi_{C}\\left(  D\\right)\r\n}_{\\substack{=\\sum_{B\\mid D}\\mu\\left(  B\\right)  \\dfrac{D}{B}\\\\\\text{(by\r\n(\\ref{pf.prop.phiC-Q.sum.phiCE=}), applied to }E=D\\text{)}}}\\\\\r\n&  =\\sum\\limits_{D\\mid M}\\underbrace{\\sum_{B\\mid D}}_{\\substack{=\\sum\r\n_{\\substack{B\\mid M;\\\\B\\mid D}}\\\\\\text{(since }D\\mid M\\text{)}}}\\mu\\left(\r\nB\\right)  \\dfrac{D}{B}=\\underbrace{\\sum\\limits_{D\\mid M}\\sum_{\\substack{B\\mid\r\nM;\\\\B\\mid D}}}_{=\\sum_{B\\mid M}\\sum_{\\substack{D\\mid M;\\\\B\\mid D}}}\\mu\\left(\r\nB\\right)  \\dfrac{D}{B}=\\sum_{B\\mid M}\\sum_{\\substack{D\\mid M;\\\\B\\mid D}%\r\n}\\mu\\left(  B\\right)  \\dfrac{D}{B}\\\\\r\n&  =\\sum_{B\\mid M}\\mu\\left(  B\\right)  \\underbrace{\\sum_{\\substack{D\\mid\r\nM;\\\\B\\mid D}}\\dfrac{D}{B}}_{\\substack{=\\sum_{E\\mid\\dfrac{M}{B}}E\\\\\\text{(by\r\n(\\ref{pf.prop.phiC-Q.sum.down}))}}}=\\sum_{B\\mid M}\\mu\\left(  B\\right)\r\n\\underbrace{\\sum_{E\\mid\\dfrac{M}{B}}}_{\\substack{=\\sum_{\\substack{E\\mid\r\nM;\\\\BE\\mid M}}\\\\\\text{(since the monic divisors }E\\text{ of }\\dfrac{M}%\r\n{B}\\text{ are precisely}\\\\\\text{the monic divisors }E\\text{ of }M\\text{\r\nsatisfying }BE\\mid M\\text{)}}}E\\\\\r\n&  =\\sum_{B\\mid M}\\mu\\left(  B\\right)  \\sum_{\\substack{E\\mid M;\\\\BE\\mid\r\nM}}E=\\underbrace{\\sum_{B\\mid M}\\sum_{\\substack{E\\mid M;\\\\BE\\mid M}}}%\r\n_{=\\sum_{E\\mid M}\\sum_{\\substack{B\\mid M;\\\\BE\\mid M}}}\\mu\\left(  B\\right)\r\nE=\\sum_{E\\mid M}\\underbrace{\\sum_{\\substack{B\\mid M;\\\\BE\\mid M}}\\mu\\left(\r\nB\\right)  }_{\\substack{=\\left[  E=M\\right]  \\\\\\text{(by Corollary\r\n\\ref{cor.moebius-Q.sum-rel})}}}E\\\\\r\n&  =\\sum_{E\\mid M}\\left[  E=M\\right]  E=\\underbrace{\\left[  M=M\\right]  }%\r\n_{=1}M+\\sum_{\\substack{E\\mid M;\\\\E\\neq M}}\\underbrace{\\left[  E=M\\right]\r\n}_{\\substack{=0\\\\\\text{(since }E\\neq M\\text{)}}}E\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}E=M\\text{ from the sum}\\right) \\\\\r\n&  =M+\\underbrace{\\sum_{\\substack{E\\mid M;\\\\E\\neq M}}0E}_{=0}=M.\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.phiC-Q.sum}.\r\n\\end{proof}\r\n\r\nNext, let us study the function $\\varphi$:\r\n\r\n\\begin{proposition}\r\n\\label{prop.phi-Q.formula}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\n\r\n\\textbf{(a)} We have $\\varphi\\left(  M\\right)  \\in\\mathbb{N}_{+}$.\r\n\r\n\\textbf{(b)} We have $\\varphi\\left(  M\\right)  =q^{\\deg M}\\prod\\limits_{\\pi\r\n\\in\\operatorname*{PF}M}\\left(  1-\\dfrac{1}{q^{\\deg\\pi}}\\right)  $.\r\n\r\n\\textbf{(c)} We have $\\varphi\\left(  M\\right)  \\equiv\\mu\\left(  M\\right)\r\n\\operatorname{mod}p$.\r\n\r\n\\textbf{(d)} We have $\\varphi\\left(  M\\right)  =\\mu\\left(  M\\right)  $ in\r\n$\\mathbb{F}_{q}$.\r\n\r\n\\textbf{(e)} Let $A$ be the ring $\\mathbb{F}_{q}\\left[  T\\right]  $. For any\r\nring $B$, we let $B^{\\times}$ denote the group of units of $B$. Then,\r\n$\\varphi\\left(  M\\right)  =\\left\\vert \\left(  A/MA\\right)  ^{\\times\r\n}\\right\\vert $.\r\n\\end{proposition}\r\n\r\nProposition \\ref{prop.phi-Q.formula} \\textbf{(e)} is used as a definition of\r\n$\\varphi\\left(  M\\right)  $ in \\cite[\\S 6]{kc-carlitz}.\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.phi-Q.formula}.]\\textbf{(b)} Let\r\n$M=P_{1}^{a_{1}}P_{2}^{a_{2}}\\cdots P_{k}^{a_{k}}$ be the factorization of $M$\r\ninto monic irreducible polynomials, with all of $a_{1},a_{2},\\ldots,a_{k}$\r\nbeing positive integers (and with $P_{1},P_{2},\\ldots,P_{k}$ being\r\ndistinct).\\footnote{This is well-defined, since $M$ is monic and since\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $ is a principal ideal domain. Of course, $k$\r\ncan be $0$ (when $M=1$).} Then, the \\textbf{squarefree} monic divisors $D$ of\r\n$M$ all have the form $\\prod_{i\\in I}P_{i}$ for some subset $I$ of $\\left\\{\r\n1,2,\\ldots,k\\right\\}  $. More precisely, there exists a bijection%\r\n\\begin{align}\r\n\\left\\{  I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  \\right\\}   &  \\rightarrow\r\n\\left(  \\text{the set of all squarefree monic divisors of }M\\right)\r\n,\\nonumber\\\\\r\nI  &  \\mapsto\\prod_{i\\in I}P_{i}. \\label{pf.prop.phi-Q.formula.b.bij}%\r\n\\end{align}\r\n\r\n\r\nMoreover, every subset $I$ of $\\left\\{  1,2,\\ldots,k\\right\\}  $ satisfies\r\n(\\ref{pf.prop.moebius-Q.sum.2}). (This is proven as in our proof of\r\nProposition \\ref{prop.moebius-Q.sum}.)\r\n\r\nFurthermore, every subset $I$ of $\\left\\{  1,2,\\ldots,k\\right\\}  $ satisfies%\r\n\\begin{align}\r\nq^{\\deg\\left(  M/\\prod_{i\\in I}P_{i}\\right)  }  &  =q^{\\deg M-\\sum_{i\\in\r\nI}\\deg\\left(  P_{i}\\right)  }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }%\r\n\\deg\\left(  M/\\prod_{i\\in I}P_{i}\\right)  =\\deg M-\\sum_{i\\in I}\\deg\\left(\r\nP_{i}\\right)  \\right) \\nonumber\\\\\r\n&  =\\dfrac{q^{\\deg M}}{\\prod_{i\\in I}q^{\\deg\\left(  P_{i}\\right)  }}.\r\n\\label{pf.prop.phi-Q.formula.b.qdeg}%\r\n\\end{align}\r\n\r\n\r\nThe definition of $P_{1},P_{2},\\ldots,P_{k}$ shows that $\\left(  P_{1}%\r\n,P_{2},\\ldots,P_{k}\\right)  $ is a list of all prime factors of $M$, with no\r\nrepetitions. Thus, the map $\\left\\{  1,2,\\ldots,k\\right\\}  \\rightarrow\r\n\\operatorname*{PF}M,\\ i\\mapsto P_{i}$ is a bijection.\r\n\r\nThe definition of $\\varphi$ yields%\r\n\\begin{align*}\r\n\\varphi\\left(  M\\right)   &  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }\\\\\r\n&  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }+\\sum_{\\substack{D\\mid M;\\\\D\\text{ is not\r\nsquarefree}}}\\underbrace{\\mu\\left(  D\\right)  }_{\\substack{=0\\\\\\text{(by the\r\ndefinition}\\\\\\text{of }\\mu\\text{, since }D\\\\\\text{is not squarefree)}}%\r\n}q^{\\deg\\left(  M/D\\right)  }\\\\\r\n&  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }+\\underbrace{\\sum_{\\substack{D\\mid M;\\\\D\\text{ is\r\nnot squarefree}}}0q^{\\deg\\left(  M/D\\right)  }}_{=0}\\\\\r\n&  =\\sum_{\\substack{D\\mid M;\\\\D\\text{ is squarefree}}}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }=\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}\r\n}\\underbrace{\\mu\\left(  \\prod_{i\\in I}P_{i}\\right)  }_{\\substack{=\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }\\\\\\text{(by\r\n(\\ref{pf.prop.moebius-Q.sum.2}))}}}\\underbrace{q^{\\deg\\left(  M/\\prod_{i\\in\r\nI}P_{i}\\right)  }}_{\\substack{=\\dfrac{q^{\\deg M}}{\\prod_{i\\in I}q^{\\deg\\left(\r\nP_{i}\\right)  }}\\\\\\text{(by (\\ref{pf.prop.phi-Q.formula.b.qdeg}))}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\prod_{i\\in I}P_{i}\\text{ for }D\\\\\r\n\\text{due to the bijection (\\ref{pf.prop.moebius-Q.sum.bij})}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\underbrace{\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }}_{=\\prod_{i\\in I}\\left(  -1\\right)\r\n}\\dfrac{q^{\\deg M}}{\\prod_{i\\in I}q^{\\deg\\left(  P_{i}\\right)  }}%\r\n=\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }\\left(  \\prod_{i\\in I}\\left(\r\n-1\\right)  \\right)  \\dfrac{q^{\\deg M}}{\\prod_{i\\in I}q^{\\deg\\left(\r\nP_{i}\\right)  }}\\\\\r\n&  =q^{\\deg M}\\sum_{I\\subseteq\\left\\{  1,2,\\ldots,k\\right\\}  }%\r\n\\underbrace{\\dfrac{\\prod_{i\\in I}\\left(  -1\\right)  }{\\prod_{i\\in I}%\r\nq^{\\deg\\left(  P_{i}\\right)  }}}_{=\\prod_{i\\in I}\\dfrac{-1}{q^{\\deg\\left(\r\nP_{i}\\right)  }}}=q^{\\deg M}\\underbrace{\\sum_{I\\subseteq\\left\\{\r\n1,2,\\ldots,k\\right\\}  }\\prod_{i\\in I}\\dfrac{-1}{q^{\\deg\\left(  P_{i}\\right)\r\n}}}_{\\substack{=\\prod_{i\\in\\left\\{  1,2,\\ldots,k\\right\\}  }\\left(\r\n1+\\dfrac{-1}{q^{\\deg\\left(  P_{i}\\right)  }}\\right)  \\\\\\text{(by Lemma\r\n\\ref{lem.moebius-Q.Z} \\textbf{(b)}, applied to }R=\\mathbb{Q}\\text{,}%\r\n\\\\Z=\\left\\{  1,2,\\ldots,k\\right\\}  \\text{ and }r_{i}=\\dfrac{-1}{q^{\\deg\\left(\r\nP_{i}\\right)  }}\\text{)}}}\\\\\r\n&  =q^{\\deg M}\\prod_{i\\in\\left\\{  1,2,\\ldots,k\\right\\}  }\\left(  1+\\dfrac\r\n{-1}{q^{\\deg\\left(  P_{i}\\right)  }}\\right)  =q^{\\deg M}\\prod_{\\pi\r\n\\in\\operatorname*{PF}M}\\underbrace{\\left(  1+\\dfrac{-1}{q^{\\deg\\pi}}\\right)\r\n}_{=1-\\dfrac{1}{q^{\\deg\\pi}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have substituted }\\pi\\text{ for }P_{i}\\text{ in the product,}\\\\\r\n\\text{since the map }\\left\\{  1,2,\\ldots,k\\right\\}  \\rightarrow\r\n\\operatorname*{PF}M,\\ i\\mapsto P_{i}\\text{ is a bijection}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =q^{\\deg M}\\prod_{\\pi\\in\\operatorname*{PF}M}\\left(  1-\\dfrac{1}{q^{\\deg\\pi\r\n}}\\right)  .\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.phi-Q.formula} \\textbf{(b)}.\r\n\r\n\\textbf{(a)} The definition of $\\varphi$ yields $\\varphi\\left(  M\\right)\r\n=\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)  q^{\\deg\\left(  M/D\\right)  }%\r\n\\in\\mathbb{Z}$ (since $\\mu\\left(  D\\right)  $ and $q^{\\deg\\left(  M/D\\right)\r\n}$ are integers for all $D\\mid M$). But every $\\pi\\in\\operatorname*{PF}M$\r\nsatisfies $\\deg\\pi>0$ (since $\\pi$ is irreducible) and thus $q^{\\deg\\pi}>1$\r\n(since $q>1$) and therefore\r\n\\begin{equation}\r\n1>\\dfrac{1}{q^{\\deg\\pi}}. \\label{pf.prop.phi-Q.formula.a.1}%\r\n\\end{equation}\r\n\r\n\r\nProposition \\ref{prop.phi-Q.formula} \\textbf{(b)} yields%\r\n\\[\r\n\\varphi\\left(  M\\right)  =\\underbrace{q^{\\deg M}}_{>0}\\prod\\limits_{\\pi\r\n\\in\\operatorname*{PF}M}\\underbrace{\\left(  1-\\dfrac{1}{q^{\\deg\\pi}}\\right)\r\n}_{\\substack{>0\\\\\\text{(by (\\ref{pf.prop.phi-Q.formula.a.1}))}}}>0.\r\n\\]\r\nCombining this with $\\varphi\\left(  M\\right)  \\in\\mathbb{Z}$, we find that\r\n$\\varphi\\left(  M\\right)  \\in\\mathbb{N}_{+}$. This proves Proposition\r\n\\ref{prop.phi-Q.formula} \\textbf{(a)}.\r\n\r\n\\textbf{(c)} If $D$ is a monic divisor of $M$ satisfying $D\\neq M$, then\r\n\\begin{equation}\r\n\\mu\\left(  D\\right)  q^{\\deg\\left(  M/D\\right)  }\\equiv0\\operatorname{mod}p\r\n\\label{pf.prop.phi-Q.formula.c.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phi-Q.formula.c.1}):} Let $D$ be a\r\nmonic divisor of $M$ satisfying $D\\neq M$. From $M\\neq D$, we obtain\r\n$M/D\\neq1$.\r\n\\par\r\nWe have $M/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since $D$ is a divisor of\r\n$M$). Also, the polynomial $M/D$ is monic (since $M$ and $D$ are monic). If we\r\nhad $\\deg\\left(  M/D\\right)  =0$, then we would have $M/D=1$ (because $M/D$ is\r\nmonic), which would contradict $M/D\\neq1$. Thus, we cannot have $\\deg\\left(\r\nM/D\\right)  =0$. Hence, we must have $\\deg\\left(  M/D\\right)  \\geq1$ (since\r\n$M/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $). Hence, $q^{\\deg\\left(  M/D\\right)\r\n}$ is divisible by $q$, and thus also divisible by $p$ (since $p\\mid q$). In\r\nother words, $q^{\\deg\\left(  M/D\\right)  }\\equiv0\\operatorname{mod}p$. Hence,\r\n$\\mu\\left(  D\\right)  \\underbrace{q^{\\deg\\left(  M/D\\right)  }}_{\\equiv\r\n0\\operatorname{mod}p}\\equiv0\\operatorname{mod}p$ (since $\\mu\\left(  D\\right)\r\n\\in\\left\\{  -1,0,1\\right\\}  \\subseteq\\mathbb{Z}$). This proves\r\n(\\ref{pf.prop.phi-Q.formula.c.1}).}. Now, the definition of $\\varphi$ yields%\r\n\\begin{align*}\r\n\\varphi\\left(  M\\right)   &  =\\sum\\limits_{D\\mid M}\\mu\\left(  D\\right)\r\nq^{\\deg\\left(  M/D\\right)  }=\\mu\\left(  M\\right)  \\underbrace{q^{\\deg\\left(\r\nM/M\\right)  }}_{\\substack{=q^{0}\\\\\\text{(since }\\deg\\left(  M/M\\right)\r\n=\\deg1=0\\text{)}}}+\\sum\\limits_{\\substack{D\\mid M;\\\\D\\neq M}}\\underbrace{\\mu\r\n\\left(  D\\right)  q^{\\deg\\left(  M/D\\right)  }}_{\\substack{\\equiv\r\n0\\operatorname{mod}p\\\\\\text{(by (\\ref{pf.prop.phi-Q.formula.c.1}))}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}D=M\\text{ from the sum}\\right) \\\\\r\n&  \\equiv\\mu\\left(  M\\right)  \\underbrace{q^{0}}_{=1}+\\underbrace{\\sum\r\n\\limits_{\\substack{D\\mid M;\\\\D\\neq M}}0}_{=0}=\\mu\\left(  M\\right)\r\n\\operatorname{mod}p.\r\n\\end{align*}\r\nThis proves Proposition \\ref{prop.phi-Q.formula} \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Proposition \\ref{prop.phi-Q.formula} \\textbf{(c)} shows that\r\n$\\varphi\\left(  M\\right)  \\equiv\\mu\\left(  M\\right)  \\operatorname{mod}p$.\r\nHence, $\\varphi\\left(  M\\right)  =\\mu\\left(  M\\right)  $ holds in any field of\r\ncharacteristic $p$. In particular, $\\varphi\\left(  M\\right)  =\\mu\\left(\r\nM\\right)  $ holds in $\\mathbb{F}_{q}$ (since $\\mathbb{F}_{q}$ is a field of\r\ncharacteristic $p$).\r\n\r\n\\textbf{(e)} Let us first observe two general facts:\r\n\r\n\\begin{itemize}\r\n\\item If $s\\in\\mathbb{F}_{q}\\left[  T\\right]  $ is a nonzero polynomial, then%\r\n\\begin{equation}\r\n\\left\\vert A/sA\\right\\vert =q^{\\deg s} \\label{pf.prop.phi-Q.formula.e.qdegs}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phi-Q.formula.e.qdegs}):} Let\r\n$s\\in\\mathbb{F}_{q}\\left[  T\\right]  $ be a nonzero polynomial. Then, it is\r\nwell-known that $A/sA$ is an $\\deg s$-dimensional $\\mathbb{F}_{q}$-vector\r\nspace (since $A=\\mathbb{F}_{q}\\left[  T\\right]  $). Hence, $\\left\\vert\r\nA/sA\\right\\vert =\\left\\vert \\mathbb{F}_{q}\\right\\vert ^{\\deg s}$. Since\r\n$\\left\\vert \\mathbb{F}_{q}\\right\\vert =q$, this rewrites as $\\left\\vert\r\nA/sA\\right\\vert =q^{\\deg s}$. This proves (\\ref{pf.prop.phi-Q.formula.e.qdegs}%\r\n).}.\r\n\r\n\\item If $s\\in\\mathbb{F}_{q}\\left[  T\\right]  $ is a monic irreducible\r\npolynomial, and if $n$ is a positive integer, then%\r\n\\begin{equation}\r\n\\left\\vert \\left(  A/s^{n}A\\right)  ^{\\times}\\right\\vert =q^{n\\deg\r\ns}-q^{\\left(  n-1\\right)  \\deg s} \\label{pf.prop.phi-Q.formula.e.locality}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phi-Q.formula.e.locality}):} Let\r\n$s\\in\\mathbb{F}_{q}\\left[  T\\right]  $ be a monic irreducible polynomial, and\r\nlet $n$ be a positive integer.\r\n\\par\r\nApplying (\\ref{pf.prop.phi-Q.formula.e.qdegs}) to $s^{n-1}$ instead of $s$, we\r\nobtain $\\left\\vert A/s^{n-1}A\\right\\vert =q^{\\deg\\left(  s^{n-1}\\right)\r\n}=q^{\\left(  n-1\\right)  \\deg s}$ (since $\\deg\\left(  s^{n-1}\\right)  =\\left(\r\nn-1\\right)  \\deg s$).\r\n\\par\r\nApplying (\\ref{pf.prop.phi-Q.formula.e.qdegs}) to $s^{n}$ instead of $s$, we\r\nobtain $\\left\\vert A/s^{n}A\\right\\vert =q^{\\deg\\left(  s^{n}\\right)\r\n}=q^{n\\deg s}$ (since $\\deg\\left(  s^{n}\\right)  =n\\deg s$).\r\n\\par\r\nLet $B$ be the ring $A/s^{n}A$. Then, $B=\\underbrace{A}_{=\\mathbb{F}%\r\n_{q}\\left[  T\\right]  }/s^{n}\\underbrace{A}_{=\\mathbb{F}_{q}\\left[  T\\right]\r\n}=\\mathbb{F}_{q}\\left[  T\\right]  /s^{n}\\mathbb{F}_{q}\\left[  T\\right]  $.\r\nHence, Proposition \\ref{prop.FT.modsn} \\textbf{(b)} (applied to $\\mathbb{F}%\r\n=\\mathbb{F}_{q}$) shows that $sB\\cong\\mathbb{F}_{q}\\left[  T\\right]\r\n/s^{n-1}\\mathbb{F}_{q}\\left[  T\\right]  $ as $\\mathbb{F}_{q}$-vector spaces.\r\nThus, $sB\\cong\\underbrace{\\mathbb{F}_{q}\\left[  T\\right]  }_{=A}%\r\n/s^{n-1}\\underbrace{\\mathbb{F}_{q}\\left[  T\\right]  }_{=A}=A/s^{n-1}A$ as\r\n$\\mathbb{F}_{q}$-vector spaces. Hence, $\\left\\vert sB\\right\\vert =\\left\\vert\r\nA/s^{n-1}A\\right\\vert =q^{\\left(  n-1\\right)  \\deg s}$. Also, from\r\n$B=A/s^{n}A$, we obtain $\\left\\vert B\\right\\vert =\\left\\vert A/s^{n}%\r\nA\\right\\vert =q^{n\\deg s}$.\r\n\\par\r\nBut Proposition \\ref{prop.FT.modsn} \\textbf{(a)} (applied to $\\mathbb{F}%\r\n=\\mathbb{F}_{q}$) yields $B^{\\times}=B\\setminus sB$. Hence,%\r\n\\begin{align*}\r\n\\left\\vert B^{\\times}\\right\\vert  &  =\\left\\vert B\\setminus sB\\right\\vert\r\n=\\underbrace{\\left\\vert B\\right\\vert }_{=q^{n\\deg s}}-\\underbrace{\\left\\vert\r\nsB\\right\\vert }_{=q^{\\left(  n-1\\right)  \\deg s}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }sB\\subseteq B\\right) \\\\\r\n&  =q^{n\\deg s}-q^{\\left(  n-1\\right)  \\deg s}.\r\n\\end{align*}\r\nSince $B=A/s^{n}A$, this rewrites as $\\left\\vert \\left(  A/s^{n}A\\right)\r\n^{\\times}\\right\\vert =q^{n\\deg s}-q^{\\left(  n-1\\right)  \\deg s}$. Hence,\r\n(\\ref{pf.prop.phi-Q.formula.e.locality}) is proven.}.\r\n\\end{itemize}\r\n\r\nThe polynomial $M$ is monic. Hence, the factorization of $M$ into monic\r\nirreducible polynomials is $M=\\prod_{s\\in\\operatorname*{PF}M}s^{v_{s}\\left(\r\nM\\right)  }$. Notice that $v_{s}\\left(  M\\right)  $ is a positive integer for\r\neach $s\\in\\operatorname*{PF}M$.\r\n\r\nFrom $M=\\prod_{s\\in\\operatorname*{PF}M}s^{v_{s}\\left(  M\\right)  }$, we\r\nconclude that%\r\n\\[\r\n\\deg M=\\deg\\prod_{s\\in\\operatorname*{PF}M}s^{v_{s}\\left(  M\\right)  }%\r\n=\\sum_{s\\in\\operatorname*{PF}M}\\deg\\left(  s^{v_{s}\\left(  M\\right)  }\\right)\r\n,\r\n\\]\r\nand thus%\r\n\\begin{equation}\r\nq^{\\deg M}=q^{\\sum_{s\\in\\operatorname*{PF}M}\\deg\\left(  s^{v_{s}\\left(\r\nM\\right)  }\\right)  }=\\prod\\limits_{s\\in\\operatorname*{PF}M}q^{\\deg\\left(\r\ns^{v_{s}\\left(  M\\right)  }\\right)  }. \\label{pf.prop.phi-Q.formula.e.qdegM}%\r\n\\end{equation}\r\n\r\n\r\nFor each $s\\in\\operatorname*{PF}M$, define an ideal $I_{s}$ of $A$ by\r\n$I_{s}=s^{v_{s}\\left(  M\\right)  }A$. Notice that $A$ is a principal ideal\r\ndomain (since $A=\\mathbb{F}_{q}\\left[  T\\right]  $). We have%\r\n\\begin{equation}\r\n\\left\\vert \\left(  A/I_{s}\\right)  ^{\\times}\\right\\vert =q^{\\deg\\left(\r\ns^{v_{s}\\left(  M\\right)  }\\right)  }\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right)\r\n\\label{pf.prop.phi-Q.formula.e.locality-specific}%\r\n\\end{equation}\r\nfor each $s\\in\\operatorname*{PF}M$\\ \\ \\ \\ \\footnote{\\textit{Proof of\r\n(\\ref{pf.prop.phi-Q.formula.e.locality-specific}):} Let $s\\in\r\n\\operatorname*{PF}M$. Thus, $s$ is a monic irreducible polynomial dividing\r\n$M$.\r\n\\par\r\nLet $n=v_{s}\\left(  M\\right)  $. Then, $n=v_{s}\\left(  M\\right)  $ is a\r\npositive integer (since $s$ divides $M$). Hence,\r\n(\\ref{pf.prop.phi-Q.formula.e.locality}) yields\r\n\\begin{align*}\r\n\\left\\vert \\left(  A/s^{n}A\\right)  ^{\\times}\\right\\vert  &  =q^{n\\deg\r\ns}-\\underbrace{q^{\\left(  n-1\\right)  \\deg s}}_{\\substack{=q^{n\\deg s-\\deg\r\ns}\\\\\\text{(since }\\left(  n-1\\right)  \\deg s=n\\deg s-\\deg s\\text{)}}}=q^{n\\deg\r\ns}-\\underbrace{q^{n\\deg s-\\deg s}}_{=\\dfrac{q^{n\\deg s}}{q^{\\deg s}}}\\\\\r\n&  =q^{n\\deg s}-\\dfrac{q^{n\\deg s}}{q^{\\deg s}}=\\underbrace{q^{n\\deg s}%\r\n}_{\\substack{=q^{\\deg\\left(  s^{n}\\right)  }\\\\\\text{(since }n\\deg\r\ns=\\deg\\left(  s^{n}\\right)  \\text{)}}}\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right)\r\n=q^{\\deg\\left(  s^{n}\\right)  }\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right) \\\\\r\n&  =q^{\\deg\\left(  s^{v_{s}\\left(  M\\right)  }\\right)  }\\left(  1-\\dfrac\r\n{1}{q^{\\deg s}}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }%\r\nn=v_{s}\\left(  M\\right)  \\right)  .\r\n\\end{align*}\r\n\\par\r\nAlso, $I_{s}=s^{v_{s}\\left(  M\\right)  }A=s^{n}A$ (since $v_{s}\\left(\r\nM\\right)  =n$). Hence, $\\left\\vert \\left(  A/I_{s}\\right)  ^{\\times\r\n}\\right\\vert =\\left\\vert \\left(  A/s^{n}A\\right)  ^{\\times}\\right\\vert\r\n=q^{\\deg\\left(  s^{v_{s}\\left(  M\\right)  }\\right)  }\\left(  1-\\dfrac\r\n{1}{q^{\\deg s}}\\right)  $. This proves\r\n(\\ref{pf.prop.phi-Q.formula.e.locality-specific}).}.\r\n\r\nEvery two distinct elements $s$ and $t$ of $\\operatorname*{PF}M$ satisfy\r\n$I_{s}+I_{t}=A$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $s$ and $t$ be two\r\ndistinct elements of $\\operatorname*{PF}M$. Thus, $s$ and $t$ are two distinct\r\nmonic irreducible polynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $. Hence,\r\nLemma \\ref{lem.CRT.FqT.Is+It} (applied to $\\mathbb{F=F}_{q}$, $n=v_{s}\\left(\r\nM\\right)  $, $m=v_{t}\\left(  M\\right)  $ and $R=A$) yields $s^{v_{s}\\left(\r\nM\\right)  }A+t^{v_{t}\\left(  M\\right)  }A=A$.\r\n\\par\r\nOn the other hand, $I_{s}=s^{v_{s}\\left(  M\\right)  }A$ (by the definition of\r\n$I_{s}$) and $I_{t}=t^{v_{t}\\left(  M\\right)  }A$ (by the definition of\r\n$I_{t}$). Adding these two equalities, we obtain $I_{s}+I_{t}=s^{v_{s}\\left(\r\nM\\right)  }A+t^{v_{t}\\left(  M\\right)  }A=A$. Qed.}. Hence, Theorem\r\n\\ref{thm.CRT.ring} \\textbf{(b)} (applied to $\\mathbf{S}=\\operatorname*{PF}M$)\r\nshows that the canonical $A$-algebra homomorphism\r\n\\[\r\nA/\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}M}I_{s}\\right)  \\rightarrow\r\n\\prod\\limits_{s\\in\\operatorname*{PF}M}\\left(  A/I_{s}\\right)\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ a+\\prod\\limits_{s\\in\\operatorname*{PF}M}I_{s}%\r\n\\mapsto\\left(  a+I_{s}\\right)  _{s\\in\\operatorname*{PF}M}%\r\n\\]\r\nis well-defined and an $A$-algebra isomorphism. Hence, $A/\\left(\r\n\\prod\\limits_{s\\in\\operatorname*{PF}M}I_{s}\\right)  \\cong\\prod\\limits_{s\\in\r\n\\operatorname*{PF}M}\\left(  A/I_{s}\\right)  $ as $A$-algebras.\r\n\r\nBut\r\n\\[\r\n\\prod\\limits_{s\\in\\operatorname*{PF}M}\\underbrace{I_{s}}_{=s^{v_{s}\\left(\r\nM\\right)  }A}=\\prod\\limits_{s\\in\\operatorname*{PF}M}\\left(  s^{v_{s}\\left(\r\nM\\right)  }A\\right)  =\\underbrace{\\left(  \\prod_{s\\in\\operatorname*{PF}%\r\nM}s^{v_{s}\\left(  M\\right)  }\\right)  }_{=M}A=MA.\r\n\\]\r\nThus, $A/\\underbrace{\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}M}%\r\nI_{s}\\right)  }_{=MA}=A/MA$. Hence, $A/MA=A/\\left(  \\prod\\limits_{s\\in\r\n\\operatorname*{PF}M}I_{s}\\right)  \\cong\\prod\\limits_{s\\in\\operatorname*{PF}%\r\nM}\\left(  A/I_{s}\\right)  $ as $A$-algebras. Therefore,%\r\n\\[\r\n\\left(  A/MA\\right)  ^{\\times}\\cong\\left(  \\prod\\limits_{s\\in\r\n\\operatorname*{PF}M}\\left(  A/I_{s}\\right)  \\right)  ^{\\times}\\cong%\r\n\\prod\\limits_{s\\in\\operatorname*{PF}M}\\left(  A/I_{s}\\right)  ^{\\times}%\r\n\\]\r\nas groups. Hence,%\r\n\\begin{align*}\r\n\\left\\vert \\left(  A/MA\\right)  ^{\\times}\\right\\vert  &  =\\left\\vert\r\n\\prod\\limits_{s\\in\\operatorname*{PF}M}\\left(  A/I_{s}\\right)  ^{\\times\r\n}\\right\\vert =\\prod\\limits_{s\\in\\operatorname*{PF}M}\\underbrace{\\left\\vert\r\n\\left(  A/I_{s}\\right)  ^{\\times}\\right\\vert }_{\\substack{=q^{\\deg\\left(\r\ns^{v_{s}\\left(  M\\right)  }\\right)  }\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right)\r\n\\\\\\text{(by (\\ref{pf.prop.phi-Q.formula.e.locality-specific}))}}}\\\\\r\n&  =\\prod\\limits_{s\\in\\operatorname*{PF}M}\\left(  q^{\\deg\\left(\r\ns^{v_{s}\\left(  M\\right)  }\\right)  }\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right)\r\n\\right) \\\\\r\n&  =\\underbrace{\\left(  \\prod\\limits_{s\\in\\operatorname*{PF}M}q^{\\deg\\left(\r\ns^{v_{s}\\left(  M\\right)  }\\right)  }\\right)  }_{\\substack{=q^{\\deg\r\nM}\\\\\\text{(by (\\ref{pf.prop.phi-Q.formula.e.qdegM}))}}}\\underbrace{\\prod\r\n\\limits_{s\\in\\operatorname*{PF}M}\\left(  1-\\dfrac{1}{q^{\\deg s}}\\right)\r\n}_{\\substack{=\\prod\\limits_{\\pi\\in\\operatorname*{PF}M}\\left(  1-\\dfrac\r\n{1}{q^{\\deg\\pi}}\\right)  \\\\\\text{(here, we have renamed the}\\\\\\text{index\r\n}s\\text{ as }\\pi\\text{ in the product)}}}\\\\\r\n&  =q^{\\deg M}\\prod\\limits_{\\pi\\in\\operatorname*{PF}M}\\left(  1-\\dfrac\r\n{1}{q^{\\deg\\pi}}\\right)  =\\varphi\\left(  M\\right)\r\n\\end{align*}\r\n(by Proposition \\ref{prop.phi-Q.formula} \\textbf{(b)}). This proves\r\nProposition \\ref{prop.phi-Q.formula} \\textbf{(e)}.\r\n\\end{proof}\r\n\r\nFinally, here is an identity that connects the functions $\\mu$ and\r\n$\\varphi_{C}$ (an analogue of \\cite[(12.68.6)]{reiner-hopf}):\r\n\r\n\\begin{proposition}\r\n\\label{prop.phiC-Q.andmu}Let $M\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Then,%\r\n\\[\r\n\\sum_{D\\mid M}D\\mu\\left(  D\\right)  \\varphi_{C}\\left(  \\dfrac{M}{D}\\right)\r\n=\\mu\\left(  M\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{in }\\mathbb{F}_{q}\\left[\r\nT\\right]  .\r\n\\]\r\n\r\n\\end{proposition}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.phiC-Q.andmu}.]We shall use the notation of\r\nProposition \\ref{prop.moebius-Q.sum}.\r\n\r\nEvery $E\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ satisfies\r\n(\\ref{pf.prop.phiC-Q.sum.phiCE=}). (This can be proven as in our proof of\r\nProposition \\ref{prop.phiC-Q.sum} above.) Now, every monic divisor $D$ of $M$\r\nsatisfies%\r\n\\begin{equation}\r\n\\varphi_{C}\\left(  \\dfrac{M}{D}\\right)  =\\sum_{\\substack{B\\mid M;\\\\BD\\mid\r\nM}}\\mu\\left(  B\\right)  \\dfrac{M}{BD} \\label{pf.prop.phiC-Q.andmu.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phiC-Q.andmu.1}):} Let $D$ be a monic\r\ndivisor of $M$. Thus, $M/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Also, the\r\npolynomial $M/D$ is monic (since $M$ and $D$ are monic). Hence, $M/D\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Thus, (\\ref{pf.prop.phiC-Q.sum.phiCE=})\r\n(applied to $E=M/D$) yields%\r\n\\[\r\n\\varphi_{C}\\left(  M/D\\right)  =\\underbrace{\\sum_{B\\mid M/D}}_{\\substack{=\\sum\r\n_{\\substack{B\\mid M;\\\\BD\\mid M}}\\\\\\text{(since the monic divisors }B\\text{ of\r\n}M/D\\\\\\text{are exactly the monic divisors }B\\text{ of }M\\\\\\text{that satisfy\r\n}BD\\mid M\\text{)}}}\\mu\\left(  B\\right)  \\underbrace{\\dfrac{M/D}{B}}%\r\n_{=\\dfrac{M}{BD}}=\\sum_{\\substack{B\\mid M;\\\\BD\\mid M}}\\mu\\left(  B\\right)\r\n\\dfrac{M}{BD}.\r\n\\]\r\nThus, $\\varphi_{C}\\left(  \\dfrac{M}{D}\\right)  =\\varphi_{C}\\left(  M/D\\right)\r\n=\\sum_{\\substack{B\\mid M;\\\\BD\\mid M}}\\mu\\left(  B\\right)  \\dfrac{M}{BD}$. This\r\nproves (\\ref{pf.prop.phiC-Q.andmu.1}).}. Also, every monic divisor $B$ of $M$\r\nsatisfies%\r\n\\begin{equation}\r\n\\sum_{\\substack{D\\mid M;\\\\BD\\mid M}}\\mu\\left(  D\\right)  =\\left[  B=M\\right]\r\n\\label{pf.prop.phiC-Q.andmu.2}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.prop.phiC-Q.andmu.2}):} We can rename the\r\nvariables $E$ and $B$ as $B$ and $D$ in Corollary \\ref{cor.moebius-Q.sum-rel}.\r\nAs a result, we conclude that $\\sum_{\\substack{D\\mid M;\\\\DB\\mid M}}\\mu\\left(\r\nD\\right)  =\\left[  B=M\\right]  $. Hence, $\\left[  B=M\\right]  =\\sum\r\n_{\\substack{D\\mid M;\\\\DB\\mid M}}\\mu\\left(  D\\right)  =\\sum_{\\substack{D\\mid\r\nM;\\\\BD\\mid M}}\\mu\\left(  D\\right)  $. This proves\r\n(\\ref{pf.prop.phiC-Q.andmu.2}).}.\r\n\r\nNow,%\r\n\\begin{align*}\r\n&  \\sum_{D\\mid M}D\\mu\\left(  D\\right)  \\underbrace{\\varphi_{C}\\left(\r\n\\dfrac{M}{D}\\right)  }_{\\substack{=\\sum_{\\substack{B\\mid M;\\\\BD\\mid M}%\r\n}\\mu\\left(  B\\right)  \\dfrac{M}{BD}\\\\\\text{(by (\\ref{pf.prop.phiC-Q.andmu.1}%\r\n))}}}\\\\\r\n&  =\\sum_{D\\mid M}D\\mu\\left(  D\\right)  \\sum_{\\substack{B\\mid M;\\\\BD\\mid\r\nM}}\\mu\\left(  B\\right)  \\dfrac{M}{BD}=\\underbrace{\\sum_{D\\mid M}%\r\n\\sum_{\\substack{B\\mid M;\\\\BD\\mid M}}}_{=\\sum_{B\\mid M}\\sum_{\\substack{D\\mid\r\nM;\\\\BD\\mid M}}}\\underbrace{D\\mu\\left(  D\\right)  \\mu\\left(  B\\right)\r\n\\dfrac{M}{BD}}_{=\\dfrac{M}{B}\\mu\\left(  B\\right)  \\mu\\left(  D\\right)  }\\\\\r\n&  =\\sum_{B\\mid M}\\sum_{\\substack{D\\mid M;\\\\BD\\mid M}}\\dfrac{M}{B}\\mu\\left(\r\nB\\right)  \\mu\\left(  D\\right)  =\\sum_{B\\mid M}\\dfrac{M}{B}\\mu\\left(  B\\right)\r\n\\underbrace{\\sum_{\\substack{D\\mid M;\\\\BD\\mid M}}\\mu\\left(  D\\right)\r\n}_{\\substack{=\\left[  B=M\\right]  \\\\\\text{(by (\\ref{pf.prop.phiC-Q.andmu.2}%\r\n))}}}\\\\\r\n&  =\\sum_{B\\mid M}\\dfrac{M}{B}\\mu\\left(  B\\right)  \\left[  B=M\\right]\r\n=\\underbrace{\\dfrac{M}{M}}_{=1}\\mu\\left(  M\\right)  \\underbrace{\\left[\r\nM=M\\right]  }_{=1}+\\sum_{\\substack{B\\mid M;\\\\B\\neq M}}\\dfrac{M}{B}\\mu\\left(\r\nB\\right)  \\underbrace{\\left[  B=M\\right]  }_{\\substack{=0\\\\\\text{(since }B\\neq\r\nM\\text{)}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}B=M\\text{ from the sum}\\right) \\\\\r\n&  =\\mu\\left(  M\\right)  +\\underbrace{\\sum_{\\substack{B\\mid M;\\\\B\\neq\r\nM}}\\dfrac{M}{B}\\mu\\left(  B\\right)  0}_{=0}=\\mu\\left(  M\\right)\r\n\\end{align*}\r\nin $\\mathbb{F}_{q}\\left[  T\\right]  $. This proves Proposition\r\n\\ref{prop.phiC-Q.andmu}.\r\n\\end{proof}\r\n\r\n\\subsection{The Carlitz ghost-Witt equivalence}\r\n\r\nWe are now ready to prove a generalization of Theorem \\ref{thm.carlitz.gW}:\r\n\r\n\\begin{theorem}\r\n\\label{thm.F.gW}Let $N$ be a $q$-nest. Let $A$ be an $\\mathcal{F}$-module. For\r\nevery $P\\in N$, let $\\varphi_{P}$ be an endomorphism of the $\\mathbb{F}_{q}%\r\n$-vector space $A$. (The notation $\\varphi_{P}$ for these endomorphisms should\r\nnot be confused with the notation $\\varphi_{C}$ defined in Definition\r\n\\ref{def.phiC-q}; we shall ensure this by never using the notation $C$ for a\r\npolynomial in this context.) Let us make the following three assumptions:\r\n\r\n\\textit{Assumption 1:} For every $P\\in N$, the map $\\varphi_{P}$ is an\r\nendomorphism of the $\\mathcal{F}$-module $A$.\r\n\r\n\\textit{Assumption 2:} We have $\\varphi_{\\pi}\\left(  a\\right)  \\equiv\\left(\r\n\\operatorname*{Carl}\\pi\\right)  a\\operatorname{mod}\\pi A$ for every $a\\in A$\r\nand every monic irreducible $\\pi\\in N$.\r\n\r\n\\textit{Assumption 3:} We have $\\varphi_{1}=\\operatorname*{id}$. Furthermore,\r\n$\\varphi_{P}\\circ\\varphi_{Q}=\\varphi_{PQ}$ for every $P\\in N$ and every $Q\\in\r\nN$ satisfying $PQ\\in N$.\r\n\r\nLet $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ be a family of elements of $A$.\r\nThen, the following assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ are equivalent:\r\n\r\n\\textit{Assertion }$\\mathcal{C}_{1}$\\textit{:} Every $P\\in N$ and every\r\n$\\pi\\in\\operatorname{PF}P$ satisfy%\r\n\\[\r\n\\varphi_{\\pi}\\left(  b_{P / \\pi}\\right)  \\equiv b_{P}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{D}_{1}$\\textit{:} There exists a family $\\left(\r\nx_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\cdot\\left(  \\operatorname*{Carl}\\dfrac{P}%\r\n{D}\\right)  x_{D}\\text{ for every }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{D}_{2}$\\textit{:} There exists a family $\\left(\r\n\\widetilde{x}_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}DF^{\\deg\\left(  P/D\\right)  }\\widetilde{x}%\r\n_{D}\\text{ for every }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{E}_{1}$\\textit{:} There exists a family $\\left(\r\ny_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\varphi_{P / D}\\left(  y_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{F}_{1}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P / D}\\right)  \\in\r\nPA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{G}_{1}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi_{C}\\left(  D\\right)  \\varphi_{D}\\left(  b_{P /\r\nD}\\right)  \\in PA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{G}_{2}$\\textit{:} Every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in\r\nPA.\r\n\\]\r\n\r\n\\end{theorem}\r\n\r\nTheorem \\ref{thm.F.gW} is a generalization of Theorem \\ref{thm.carlitz.gW} --\r\nnamely, it is precisely the generalization outlined in Remark\r\n\\ref{rmk.carlitz.gW.1'}. In order to see this, the reader should recall\r\nProposition \\ref{prop.F.frobmod.cateq}, which says that (roughly speaking)\r\n$\\mathcal{F}$-modules are the same as Frobenius $\\mathbb{F}_{q}\\left[\r\nT\\right]  $-modules (which are precisely $\\mathbb{F}_{q}\\left[  T\\right]\r\n$-modules $A$ with an $\\mathbb{F}_{q}$-linear Frobenius map $F:A\\rightarrow A$\r\nwhich satisfies (\\ref{eq.frobcond})\\footnote{This is slightly nontrivial,\r\nbecause the equalities (\\ref{eq.frobcond}) and (\\ref{eq.def.F.frobmod.axiom})\r\nare not obviously equivalent. Nevertheless, the equivalence of the equalities\r\n(\\ref{eq.frobcond}) and (\\ref{eq.def.F.frobmod.axiom}) is easy to show.}).\r\n\r\nBefore we prove Theorem \\ref{thm.F.gW}, let us show two more general facts:\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.gW.F-G-gen0}Let $N$ be a $q$-nest. Let $A$ be an $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module. For every $P\\in N$ and every monic divisor $D$\r\nof $P$, let $g_{P,D}$ be an element of $A$. Let $\\alpha$, $\\beta$ and $\\gamma$\r\nare three maps from $N$ to $\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nAssume that\r\n\\begin{equation}\r\n\\beta\\left(  P\\right)  =\\sum_{D\\mid P}D\\gamma\\left(  D\\right)  \\alpha\\left(\r\n\\dfrac{P}{D}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }P\\in N.\r\n\\label{eq.lem.F.gW.F-gen0.beta-through-alpha}%\r\n\\end{equation}\r\n\r\n\r\nFurthermore, assume that every $P\\in N$ and every monic divisor $E$ of $P$\r\nsatisfy%\r\n\\begin{equation}\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\alpha\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\label{eq.lem.F.gW.F-G-gen0.ass}%\r\n\\end{equation}\r\nThen, every $P\\in N$ and every monic divisor $E$ of $P$ satisfy%\r\n\\begin{equation}\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\beta\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\label{eq.lem.F.gW.F-G-gen0.claim}%\r\n\\end{equation}\r\n\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.gW.F-G-gen0}.]Let $P\\in N$. Let $E$ be a monic\r\ndivisor of $P$. Then, every monic divisor $F$ of $P$ satisfies%\r\n\\begin{equation}\r\nF\\sum_{\\substack{M\\mid P;\\\\MF\\mid P}}\\alpha\\left(  M\\right)  g_{P,MF}\\in PA\r\n\\label{pf.lem.F.gW.F-G-gen0.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.lem.F.gW.F-G-gen0.1}):} Let $F$ be a monic\r\ndivisor of $P$. Then,%\r\n\\begin{align*}\r\nF\\sum_{\\substack{M\\mid P;\\\\MF\\mid P}}\\alpha\\left(  M\\right)  g_{P,MF}  &\r\n=F\\sum_{\\substack{D\\mid P;\\\\DF\\mid P}}\\alpha\\left(  D\\right)  g_{P,DF}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have renamed the summation index\r\n}M\\text{ as }D\\right) \\\\\r\n&  \\in PA\r\n\\end{align*}\r\n(by (\\ref{eq.lem.F.gW.F-G-gen0.ass}) (applied to $E=F$)). This proves\r\n(\\ref{pf.lem.F.gW.F-G-gen0.1}).}. Furthermore, every monic divisor $D$ of $P$\r\nsatisfies%\r\n\\begin{equation}\r\n\\sum_{\\substack{M\\mid P;\\\\ME\\mid P;\\\\D\\mid M}}\\alpha\\left(  \\dfrac{M}%\r\n{D}\\right)  g_{P,ME}=\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(\r\nM\\right)  g_{P,MDE} \\label{pf.lem.F.gW.F-G-gen0.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.lem.F.gW.F-G-gen0.3}):} Let $D$ be a monic\r\ndivisor of $P$.\r\n\\par\r\nLet $\\mathfrak{A}$ be the set of all monic divisors $M$ of $P$ satisfying\r\n$ME\\mid P$ and $D\\mid M$. Thus, $\\sum_{M\\in\\mathfrak{A}}=\\sum_{\\substack{M\\mid\r\nP;\\\\ME\\mid P;\\\\D\\mid M}}$.\r\n\\par\r\nLet $\\mathfrak{B}$ be the set of all monic divisors $M$ of $P$ satisfying\r\n$MDE\\mid P$. Thus, $\\sum_{M\\in\\mathfrak{B}}=\\sum_{\\substack{M\\mid P;\\\\MDE\\mid\r\nP}}$.\r\n\\par\r\nWe have\r\n\\begin{equation}\r\nM/D\\in\\mathfrak{B}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }M\\in\\mathfrak{A}\\text{.}\r\n\\label{pf.lem.F.gW.F-G-gen0.3.pf.1}%\r\n\\end{equation}\r\n\\par\r\n[\\textit{Proof of (\\ref{pf.lem.F.gW.F-G-gen0.3.pf.1}):} Let $M\\in\\mathfrak{A}%\r\n$. In other words, $M$ is a monic divisor of $P$ satisfying $ME\\mid P$ and\r\n$D\\mid M$ (by the definition of $\\mathfrak{A}$). Now, $D\\mid M$, so that\r\n$M/D\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. The polynomial $M/D$ is monic\r\n(since $M$ and $D$ are monic), and is a divisor of $P$ (since $M/D\\mid M\\mid\r\nP$). It furthermore satisfies $\\left(  M/D\\right)  DE=ME\\mid P$. Thus, $M/D$\r\nis a monic divisor of $P$ satisfying $\\left(  M/D\\right)  DE\\mid P$. In other\r\nwords, $M/D\\in\\mathfrak{B}$ (by the definition of $\\mathfrak{B}$). This proves\r\n(\\ref{pf.lem.F.gW.F-G-gen0.3.pf.1}).]\r\n\\par\r\nFurthermore, we have%\r\n\\begin{equation}\r\nMD\\in\\mathfrak{A}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }M\\in\\mathfrak{B}\\text{.}\r\n\\label{pf.lem.F.gW.F-G-gen0.3.pf.2}%\r\n\\end{equation}\r\n\\par\r\n[\\textit{Proof of (\\ref{pf.lem.F.gW.F-G-gen0.3.pf.2}):} Let $M\\in\\mathfrak{B}%\r\n$. In other words, $M$ is a monic divisor of $P$ satisfying $MDE\\mid P$ (by\r\nthe definition of $\\mathfrak{B}$). Now, the polynomial $MD$ is monic (since\r\n$M$ and $D$ are monic), and is a divisor of $P$ (since $MD\\mid MDE\\mid P$).\r\nFurthermore, it satisfies $\\left(  MD\\right)  E=MDE\\mid P$ and $D\\mid MD$.\r\nThus, $MD$ is a monic divisor of $P$ satisfying $\\left(  MD\\right)  E\\mid P$\r\nand $D\\mid MD$. In other words, $MD\\in\\mathfrak{A}$ (by the definition of\r\n$\\mathfrak{A}$). This proves (\\ref{pf.lem.F.gW.F-G-gen0.3.pf.2}).]\r\n\\par\r\nNow, the map\r\n\\[\r\n\\mathfrak{A}\\rightarrow\\mathfrak{B},\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ M\\mapsto M/D\r\n\\]\r\nis well-defined (according to (\\ref{pf.lem.F.gW.F-G-gen0.3.pf.1})).\r\nFurthermore, the map%\r\n\\[\r\n\\mathfrak{B}\\rightarrow\\mathfrak{A},\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ M\\mapsto MD\r\n\\]\r\nis well-defined (according to (\\ref{pf.lem.F.gW.F-G-gen0.3.pf.2})). These two\r\nmaps are mutually inverse (because one of them divides input by $D$, whereas\r\nthe other multiplies its input by $D$). Hence, they are both invertible. In\r\nparticular, the map\r\n\\[\r\n\\mathfrak{A}\\rightarrow\\mathfrak{B},\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ M\\mapsto M/D\r\n\\]\r\nis invertible, i.e., is a bijection. Thus, we can substitute $M/D$ for $M$ in\r\nthe sum $\\sum_{M\\in\\mathfrak{B}}\\alpha\\left(  M\\right)  g_{P,MDE}$. We thus\r\nobtain%\r\n\\[\r\n\\sum_{M\\in\\mathfrak{B}}\\alpha\\left(  M\\right)  g_{P,MDE}=\\underbrace{\\sum\r\n_{M\\in\\mathfrak{A}}}_{=\\sum_{\\substack{M\\mid P;\\\\ME\\mid P;\\\\D\\mid M}}}%\r\n\\alpha\\left(  \\underbrace{M/D}_{=\\dfrac{M}{D}}\\right)\r\n\\underbrace{g_{P,\\left(  M/D\\right)  DE}}_{=g_{P,ME}}=\\sum_{\\substack{M\\mid\r\nP;\\\\ME\\mid P;\\\\D\\mid M}}\\alpha\\left(  \\dfrac{M}{D}\\right)  g_{P,ME}.\r\n\\]\r\nThus,%\r\n\\[\r\n\\sum_{\\substack{M\\mid P;\\\\ME\\mid P;\\\\D\\mid M}}\\alpha\\left(  \\dfrac{M}%\r\n{D}\\right)  g_{P,ME}=\\underbrace{\\sum_{M\\in\\mathfrak{B}}}_{=\\sum\r\n_{\\substack{M\\mid P;\\\\MDE\\mid P}}}\\alpha\\left(  M\\right)  g_{P,MDE}%\r\n=\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)  g_{P,MDE}.\r\n\\]\r\nThis proves (\\ref{pf.lem.F.gW.F-G-gen0.3}).}. Finally, every monic divisor $D$\r\nof $P$ satisfies\r\n\\begin{equation}\r\nDE\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)  g_{P,MDE}\\in PA\r\n\\label{pf.lem.F.gW.F-G-gen0.5}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.lem.F.gW.F-G-gen0.5}):} Let $D$ be a monic\r\ndivisor of $P$. We must prove (\\ref{pf.lem.F.gW.F-G-gen0.5}).\r\n\\par\r\nWe are in one of the following two cases:\r\n\\par\r\n\\textit{Case 1:} We have $DE\\mid P$.\r\n\\par\r\n\\textit{Case 2:} We have $DE\\nmid P$.\r\n\\par\r\nLet us consider Case 1 first. In this case, we have $DE\\mid P$. Also, the\r\npolynomial $DE$ is monic (since $D$ and $E$ are monic). Hence, $DE$ is a monic\r\ndivisor of $P$. Thus, (\\ref{pf.lem.F.gW.F-G-gen0.1}) (applied to $F=DE$)\r\nyields $DE\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)\r\ng_{P,MDE}\\in PA$. Thus, (\\ref{pf.lem.F.gW.F-G-gen0.5}) is proven in Case 1.\r\n\\par\r\nLet us now consider Case 2. In this case, we have $DE\\nmid P$. Thus, there\r\nexists no $M\\mid P$ satisfying $MDE\\mid P$ (because if such an $M$ would\r\nexist, then it would satisfy $DE\\mid MDE\\mid P$, which would contradict\r\n$DE\\nmid P$). Hence, the sum $\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}%\r\n}\\alpha\\left(  M\\right)  g_{P,MDE}$ is empty, and thus equals $0$. In other\r\nwords, $\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)\r\ng_{P,MDE}=0$. Now, $DE\\underbrace{\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}%\r\n}\\alpha\\left(  M\\right)  g_{P,MDE}}_{=0}=0\\in PA$. Thus,\r\n(\\ref{pf.lem.F.gW.F-G-gen0.5}) is proven in Case 2.\r\n\\par\r\nWe have now proven (\\ref{pf.lem.F.gW.F-G-gen0.5}) in both Cases 1 and 2. Thus,\r\n(\\ref{pf.lem.F.gW.F-G-gen0.5}) always holds.}.\r\n\r\nNow,%\r\n\\begin{align*}\r\n&  \\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\beta\\left(  D\\right)  g_{P,DE}\\\\\r\n&  =\\sum_{\\substack{M\\mid P;\\\\ME\\mid P}}\\underbrace{\\beta\\left(  M\\right)\r\n}_{\\substack{=\\sum_{D\\mid M}D\\gamma\\left(  D\\right)  \\alpha\\left(  \\dfrac\r\n{M}{D}\\right)  \\\\\\text{(by (\\ref{eq.lem.F.gW.F-gen0.beta-through-alpha})\r\n(applied}\\\\\\text{to }M\\text{ instead of }P\\text{))}}}g_{P,ME}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have renamed the summation index\r\n}D\\text{ as }M\\right) \\\\\r\n&  =\\sum_{\\substack{M\\mid P;\\\\ME\\mid P}}\\underbrace{\\sum_{D\\mid M}%\r\n}_{\\substack{=\\sum_{\\substack{D\\mid P;\\\\D\\mid M}}\\\\\\text{(since every monic\r\ndivisor }D\\text{ of }M\\\\\\text{is also a monic divisor of }P\\text{ (since\r\n}M\\mid P\\text{))}}}D\\gamma\\left(  D\\right)  \\alpha\\left(  \\dfrac{M}{D}\\right)\r\ng_{P,ME}\\\\\r\n&  =\\underbrace{\\sum_{\\substack{M\\mid P;\\\\ME\\mid P}}\\sum_{\\substack{D\\mid\r\nP;\\\\D\\mid M}}}_{=\\sum_{D\\mid P}\\sum_{\\substack{M\\mid P;\\\\ME\\mid P;\\\\D\\mid M}%\r\n}}D\\gamma\\left(  D\\right)  \\alpha\\left(  \\dfrac{M}{D}\\right)  g_{P,ME}%\r\n=\\sum_{D\\mid P}\\sum_{\\substack{M\\mid P;\\\\ME\\mid P;\\\\D\\mid M}}D\\gamma\\left(\r\nD\\right)  \\alpha\\left(  \\dfrac{M}{D}\\right)  g_{P,ME}\\\\\r\n&  =\\sum_{D\\mid P}D\\gamma\\left(  D\\right)  \\underbrace{\\sum_{\\substack{M\\mid\r\nP;\\\\ME\\mid P;\\\\D\\mid M}}\\alpha\\left(  \\dfrac{M}{D}\\right)  g_{P,ME}%\r\n}_{\\substack{=\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)\r\ng_{P,MDE}\\\\\\text{(by (\\ref{pf.lem.F.gW.F-G-gen0.3}))}}}=\\sum_{D\\mid P}%\r\nD\\gamma\\left(  D\\right)  \\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(\r\nM\\right)  g_{P,MDE}.\r\n\\end{align*}\r\nMultiplying both sides of this equality by $E$, we find%\r\n\\begin{align*}\r\n&  E\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\beta\\left(  D\\right)  g_{P,DE}\\\\\r\n&  =E\\sum_{D\\mid P}D\\gamma\\left(  D\\right)  \\sum_{\\substack{M\\mid P;\\\\MDE\\mid\r\nP}}\\alpha\\left(  M\\right)  g_{P,MDE}=\\sum_{D\\mid P}DE\\gamma\\left(  D\\right)\r\n\\sum_{\\substack{M\\mid P;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)  g_{P,MDE}\\\\\r\n&  =\\sum_{D\\mid P}\\gamma\\left(  D\\right)  \\underbrace{DE\\sum_{\\substack{M\\mid\r\nP;\\\\MDE\\mid P}}\\alpha\\left(  M\\right)  g_{P,MDE}}_{\\substack{\\in PA\\\\\\text{(by\r\n(\\ref{pf.lem.F.gW.F-G-gen0.5}))}}}\\in\\sum_{D\\mid P}\\gamma\\left(  D\\right)\r\nPA\\subseteq PA.\r\n\\end{align*}\r\nThis proves Lemma \\ref{lem.F.gW.F-G-gen0}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.gW.F-G-gen}Let $N$ be a $q$-nest. Let $A$ be an $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $-module. For every $P\\in N$ and every monic divisor $D$\r\nof $P$, let $g_{P,D}$ be an element of $A$. Then, the following two assertions\r\nare equivalent:\r\n\r\n\\textit{Assertion }$\\mathcal{L}$\\textit{:} Every $P\\in N$ and every monic\r\ndivisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\]\r\n\r\n\r\n\\textit{Assertion }$\\mathcal{M}$\\textit{:} Every $P\\in N$ and every monic\r\ndivisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\varphi_{C}\\left(  D\\right)  g_{P,DE}\\in\r\nPA.\r\n\\]\r\n\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.gW.F-G-gen}.]We shall consider $\\varphi\r\n_{C}:\\mathbb{F}_{q}\\left[  T\\right]  _{+}\\rightarrow\\mathbb{F}_{q}\\left[\r\nT\\right]  $ as a map $N\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $ (by\r\nrestricting it to the subset $N$ of $\\mathbb{F}_{q}\\left[  T\\right]  _{+}$).\r\nWe shall also consider $\\mu:\\mathbb{F}_{q}\\left[  T\\right]  _{+}%\r\n\\rightarrow\\left\\{  -1,0,1\\right\\}  $ as a map $N\\rightarrow\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $ (by restricting it to the subset $N$ of $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  _{+}$, and by composing it with the canonical map\r\n$\\left\\{  -1,0,1\\right\\}  \\rightarrow\\mathbb{Z}\\rightarrow\\mathbb{F}%\r\n_{q}\\left[  T\\right]  $).\r\n\r\nWe shall prove the implications $\\mathcal{L}\\Longrightarrow\\mathcal{M}$ and\r\n$\\mathcal{M}\\Longrightarrow\\mathcal{L}$ separately:\r\n\r\n\\textit{Proof of the implication }$\\mathcal{L}\\Longrightarrow\\mathcal{M}%\r\n$\\textit{:} Assume that Assertion $\\mathcal{L}$ holds. We must show that\r\nAssertion $\\mathcal{M}$ holds.\r\n\r\nDefine a map $\\gamma:N\\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $ by $\\left(\r\n\\gamma\\left(  P\\right)  =1\\text{ for every }P\\in N\\right)  $.\r\n\r\nFor every $P\\in N$, we have%\r\n\\begin{align*}\r\n\\varphi_{C}\\left(  P\\right)   &  =\\sum_{D\\mid P}\\underbrace{D}_{=D1}\\mu\\left(\r\n\\dfrac{P}{D}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Proposition\r\n\\ref{prop.phiC-Q.formula} \\textbf{(c)}, applied to }M=P\\right) \\\\\r\n&  =\\sum_{D\\mid P}D\\underbrace{1}_{\\substack{=\\gamma\\left(  D\\right)\r\n\\\\\\text{(since }\\gamma\\left(  D\\right)  =1\\\\\\text{(by the definition of\r\n}\\gamma\\text{))}}}\\mu\\left(  \\dfrac{P}{D}\\right)  =\\sum_{D\\mid P}%\r\nD\\gamma\\left(  D\\right)  \\mu\\left(  \\dfrac{P}{D}\\right)  .\r\n\\end{align*}\r\nFurthermore, every $P\\in N$ and every monic divisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA\r\n\\]\r\n(because Assertion $\\mathcal{L}$ holds). Thus, Lemma \\ref{lem.F.gW.F-G-gen0}\r\n(applied to $\\alpha=\\mu$ and $\\beta=\\varphi_{C}$) shows that every $P\\in N$\r\nand every monic divisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\varphi_{C}\\left(  D\\right)  g_{P,DE}\\in\r\nPA.\r\n\\]\r\nIn other words, Assertion $\\mathcal{M}$ holds. Thus, we have proven the\r\nimplication $\\mathcal{L}\\Longrightarrow\\mathcal{M}$.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{M}\\Longrightarrow\\mathcal{L}%\r\n$\\textit{:} Assume that Assertion $\\mathcal{M}$ holds. We must show that\r\nAssertion $\\mathcal{L}$ holds.\r\n\r\nFor every $P\\in N$, we have%\r\n\\[\r\n\\sum_{D\\mid P}D\\mu\\left(  D\\right)  \\varphi_{C}\\left(  \\dfrac{P}{D}\\right)\r\n=\\mu\\left(  P\\right)\r\n\\]\r\n(by Proposition \\ref{prop.phiC-Q.andmu}, applied to $M=P$) and thus%\r\n\\[\r\n\\mu\\left(  P\\right)  =\\sum_{D\\mid P}D\\mu\\left(  D\\right)  \\varphi_{C}\\left(\r\n\\dfrac{P}{D}\\right)  .\r\n\\]\r\nFurthermore, every $P\\in N$ and every monic divisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\varphi_{C}\\left(  D\\right)  g_{P,DE}\\in\r\nPA\r\n\\]\r\n(because Assertion $\\mathcal{M}$ holds). Thus, Lemma \\ref{lem.F.gW.F-G-gen0}\r\n(applied to $\\alpha=\\varphi_{C}$, $\\beta=\\mu$ and $\\gamma=\\mu$) shows that\r\nevery $P\\in N$ and every monic divisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\]\r\nIn other words, Assertion $\\mathcal{L}$ holds. Thus, we have proven the\r\nimplication $\\mathcal{M}\\Longrightarrow\\mathcal{L}$.\r\n\r\nWe have now proven the two implications $\\mathcal{L}\\Longrightarrow\r\n\\mathcal{M}$ and $\\mathcal{M}\\Longrightarrow\\mathcal{L}$. Combining them, we\r\nobtain the equivalence $\\mathcal{L}\\Longleftrightarrow\\mathcal{M}$. Thus,\r\nLemma \\ref{lem.F.gW.F-G-gen} is proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem \\ref{thm.F.gW}.]Let us observe a few simple facts:\r\n\r\n\\begin{itemize}\r\n\\item If $D$ and $E$ are two monic polynomials in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $ satisfying $DE\\in N$, then%\r\n\\begin{equation}\r\n\\varphi_{D}\\circ\\varphi_{E}=\\varphi_{DE} \\label{pf.thm.F.gW.compositionDE}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.compositionDE}):} Let $D$ and $E$\r\nbe two monic polynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $ satisfying\r\n$DE\\in N$.\r\n\\par\r\nThe polynomial $D$ is a monic divisor of $DE$ (since $D$ is monic and $D\\mid\r\nDE$). Since $DE\\in N$, this entails $D\\in N$ (because $N$ is a $q$-nest).\r\nSimilarly, $E\\in N$.\r\n\\par\r\nBut Assumption 3 shows that $\\varphi_{P}\\circ\\varphi_{Q}=\\varphi_{PQ}$ for\r\nevery $P\\in N$ and every $Q\\in N$ satisfying $PQ\\in N$. Applying this to $P=D$\r\nand $Q=E$, we obtain $\\varphi_{D}\\circ\\varphi_{E}=\\varphi_{DE}$. This proves\r\n(\\ref{pf.thm.F.gW.compositionDE}).}.\r\n\r\n\\item Every $P\\in N$ and every monic divisor $D$ of $P$ satisfy\r\n\\begin{equation}\r\n\\varphi_{D}\\circ\\varphi_{P/D}=\\varphi_{P} \\label{pf.thm.F.gW.composition}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.composition}):} Let $P\\in N$, and\r\nlet $D$ be a monic divisor of $P$. Then, $P/D\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ (since $D$ is a divisor of $P$). The polynomial $P/D$ is monic\r\n(since $P$ and $D$ are monic). Also, $D\\cdot\\left(  P/D\\right)  =P\\in N$.\r\nHence, (\\ref{pf.thm.F.gW.compositionDE}) (applied to $E=P/D$) yields\r\n$\\varphi_{D}\\circ\\varphi_{P/D}=\\varphi_{D\\cdot\\left(  P/D\\right)  }%\r\n=\\varphi_{P}$. This proves (\\ref{pf.thm.F.gW.composition}).}.\r\n\r\n\\item Assumption 3 furthermore shows that $\\varphi_{1}=\\operatorname*{id}$.\r\n\\end{itemize}\r\n\r\nAssumption 1 shows that, for every $P\\in N$, the map $\\varphi_{P}$ is an\r\nendomorphism of the $\\mathcal{F}$-module $A$. In other words, for every $P\\in\r\nN$,%\r\n\\begin{equation}\r\n\\text{the map }\\varphi_{P}\\text{ is }\\mathcal{F}\\text{-linear.}\r\n\\label{pf.thm.F.gW.Flin}%\r\n\\end{equation}\r\n\r\n\r\nNotice that Assertion $\\mathcal{C}_{1}$ of Theorem \\ref{thm.F.gW} is identical\r\nwith Assertion $\\mathcal{C}_{1}$ of Theorem \\ref{thm.F.gW-general}.\r\n\r\nLet us now prove the equivalences $\\mathcal{C}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{1}$, $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$ and\r\n$\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{E}_{1}$. These three equivalences\r\nwill be derived from Theorem \\ref{thm.F.gW-general}.\r\n\r\n\\textit{Proof of the equivalence }$\\mathcal{C}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{1}$\\textit{:} For every $P\\in N$, define an endomorphism\r\n$\\psi_{P}$ of the $\\mathbb{F}_{q}$-vector space $A$ by%\r\n\\[\r\n\\left(  \\psi_{P}\\left(  a\\right)  =\\left(  \\operatorname*{Carl}P\\right)\r\na\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }a\\in A\\right)  .\r\n\\]\r\nThe Assumptions 1, 2 and 3 of Theorem \\ref{thm.F.gW-general} are satisfied\r\n(because they are precisely the Assumptions 1, 2 and 3 of Theorem\r\n\\ref{thm.F.gW}). Hence, Proposition \\ref{prop.F.gW-general.ex1} shows that\r\nAssumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied. Hence,\r\nTheorem \\ref{thm.F.gW-general} shows that the assertions $\\mathcal{C}_{1}$ and\r\n$\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} are equivalent. In\r\nother words, $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{E}_{\\psi}$.\r\n\r\nBut Assertion $\\mathcal{D}_{1}$ can be rewritten as follows:\r\n\r\n\\begin{statement}\r\n\\textit{Assertion }$\\mathcal{D}_{1}^{\\prime}$\\textit{:} There exists a family\r\n$\\left(  z_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\cdot\\left(  \\operatorname*{Carl}\\dfrac{P}%\r\n{D}\\right)  z_{D}\\text{ for every }P\\in N\\right)  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\nAssertion $\\mathcal{D}_{1}^{\\prime}$ is obtained from Assertion $\\mathcal{D}%\r\n_{1}$ by renaming the family $\\left(  x_{P}\\right)  _{P\\in N}$ as $\\left(\r\nz_{P}\\right)  _{P\\in N}$. Hence, we have the equivalence $\\mathcal{D}%\r\n_{1}\\Longleftrightarrow\\mathcal{D}_{1}^{\\prime}$.\r\n\r\nBut every $P\\in N$ and every monic divisor $D$ of $P$ satisfy%\r\n\\begin{align*}\r\n\\psi_{P/D}\\left(  z_{D}\\right)   &  =\\left(  \\operatorname*{Carl}\\left(\r\nP/D\\right)  \\right)  z_{D}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition\r\nof }\\psi_{P/D}\\right) \\\\\r\n&  =\\left(  \\operatorname*{Carl}\\dfrac{P}{D}\\right)  z_{D}.\r\n\\end{align*}\r\nThus, Assertion $\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} is\r\nequivalent to our Assertion $\\mathcal{D}_{1}^{\\prime}$. In other words, we\r\nhave the equivalence $\\mathcal{E}_{\\psi}\\Longleftrightarrow\\mathcal{D}%\r\n_{1}^{\\prime}$. Thus, we have the chain of equivalences $\\mathcal{D}%\r\n_{1}\\Longleftrightarrow\\mathcal{D}_{1}^{\\prime}\\Longleftrightarrow\r\n\\mathcal{E}_{\\psi}\\Longleftrightarrow\\mathcal{C}_{1}$. This proves the\r\nequivalence $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}$.\r\n\r\n\\textit{Proof of the equivalence }$\\mathcal{C}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{2}$\\textit{:} For every $P\\in N$, define an endomorphism\r\n$\\psi_{P}$ of the $\\mathbb{F}_{q}$-vector space $A$ by%\r\n\\[\r\n\\left(  \\psi_{P}\\left(  a\\right)  =F^{\\deg P}a\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }a\\in A\\right)  .\r\n\\]\r\nThe Assumptions 1, 2 and 3 of Theorem \\ref{thm.F.gW-general} are satisfied\r\n(because they are precisely the Assumptions 1, 2 and 3 of Theorem\r\n\\ref{thm.F.gW}). Hence, Proposition \\ref{prop.F.gW-general.ex2} shows that\r\nAssumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied. Hence,\r\nTheorem \\ref{thm.F.gW-general} shows that the assertions $\\mathcal{C}_{1}$ and\r\n$\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} are equivalent. In\r\nother words, $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{E}_{\\psi}$.\r\n\r\nBut Assertion $\\mathcal{D}_{2}$ can be rewritten as follows:\r\n\r\n\\begin{statement}\r\n\\textit{Assertion }$\\mathcal{D}_{2}^{\\prime}$\\textit{:} There exists a family\r\n$\\left(  z_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}DF^{\\deg\\left(  P/D\\right)  }z_{D}\\text{ for every\r\n}P\\in N\\right)  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\nAssertion $\\mathcal{D}_{2}^{\\prime}$ is obtained from Assertion $\\mathcal{D}%\r\n_{2}$ by renaming the family $\\left(  x_{P}\\right)  _{P\\in N}$ as $\\left(\r\nz_{P}\\right)  _{P\\in N}$. Hence, we have the equivalence $\\mathcal{D}%\r\n_{2}\\Longleftrightarrow\\mathcal{D}_{2}^{\\prime}$.\r\n\r\nBut every $P\\in N$ and every monic divisor $D$ of $P$ satisfy%\r\n\\[\r\n\\psi_{P/D}\\left(  z_{D}\\right)  =F^{\\deg\\left(  P/D\\right)  }z_{D}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\psi_{P/D}\\right)  .\r\n\\]\r\nThus, Assertion $\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} is\r\nequivalent to our Assertion $\\mathcal{D}_{2}^{\\prime}$. In other words, we\r\nhave the equivalence $\\mathcal{E}_{\\psi}\\Longleftrightarrow\\mathcal{D}%\r\n_{2}^{\\prime}$. Thus, we have the chain of equivalences $\\mathcal{D}%\r\n_{2}\\Longleftrightarrow\\mathcal{D}_{2}^{\\prime}\\Longleftrightarrow\r\n\\mathcal{E}_{\\psi}\\Longleftrightarrow\\mathcal{C}_{1}$. This proves the\r\nequivalence $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$.\r\n\r\n\\textit{Proof of the equivalence }$\\mathcal{C}_{1}\\Longleftrightarrow\r\n\\mathcal{E}_{1}$\\textit{:} For every $P\\in N$, define an endomorphism\r\n$\\psi_{P}$ of the $\\mathbb{F}_{q}$-vector space $A$ by $\\psi_{P}=\\varphi_{P}$.\r\nThe Assumptions 1, 2 and 3 of Theorem \\ref{thm.F.gW-general} are satisfied\r\n(because they are precisely the Assumptions 1, 2 and 3 of Theorem\r\n\\ref{thm.F.gW}). Hence, Proposition \\ref{prop.F.gW-general.ex3} shows that\r\nAssumptions 4 and 5 of Theorem \\ref{thm.F.gW-general} are satisfied. Hence,\r\nTheorem \\ref{thm.F.gW-general} shows that the assertions $\\mathcal{C}_{1}$ and\r\n$\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} are equivalent. In\r\nother words, $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{E}_{\\psi}$.\r\n\r\nBut Assertion $\\mathcal{E}_{1}$ can be rewritten as follows:\r\n\r\n\\begin{statement}\r\n\\textit{Assertion }$\\mathcal{E}_{1}^{\\prime}$\\textit{:} There exists a family\r\n$\\left(  z_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$ such that%\r\n\\[\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\varphi_{P/D}\\left(  z_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\nAssertion $\\mathcal{E}_{1}^{\\prime}$ is obtained from Assertion $\\mathcal{E}%\r\n_{1}$ by renaming the family $\\left(  y_{P}\\right)  _{P\\in N}$ as $\\left(\r\nz_{P}\\right)  _{P\\in N}$. Hence, we have the equivalence $\\mathcal{E}%\r\n_{1}\\Longleftrightarrow\\mathcal{E}_{1}^{\\prime}$.\r\n\r\nBut every $P\\in N$ and every monic divisor $D$ of $P$ satisfy $\\psi\r\n_{P/D}=\\varphi_{P/D}$ (by the definition of $\\psi_{P/D}$). Thus, Assertion\r\n$\\mathcal{E}_{\\psi}$ of Theorem \\ref{thm.F.gW-general} is equivalent to our\r\nAssertion $\\mathcal{E}_{1}^{\\prime}$. In other words, we have the equivalence\r\n$\\mathcal{E}_{\\psi}\\Longleftrightarrow\\mathcal{E}_{1}^{\\prime}$. Thus, we have\r\nthe chain of equivalences $\\mathcal{E}_{1}\\Longleftrightarrow\\mathcal{E}%\r\n_{1}^{\\prime}\\Longleftrightarrow\\mathcal{E}_{\\psi}\\Longleftrightarrow\r\n\\mathcal{C}_{1}$. This proves the equivalence $\\mathcal{C}_{1}%\r\n\\Longleftrightarrow\\mathcal{E}_{1}$.\r\n\r\nCombining the equivalences $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}%\r\n$, $\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{2}$ and $\\mathcal{C}%\r\n_{1}\\Longleftrightarrow\\mathcal{E}_{1}$, we obtain the chain of equivalences\r\n$\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{2}\\Longleftrightarrow\\mathcal{E}_{1}$. Let us now show some\r\nfurther logical implications. We shall use the notations of Proposition\r\n\\ref{prop.moebius-Q.sum}.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{E}_{1}\\Longrightarrow\r\n\\mathcal{F}_{1}$\\textit{:} Assume that Assertion $\\mathcal{E}_{1}$ holds. That\r\nis, there exists a family $\\left(  y_{P}\\right)  _{P\\in N}\\in A^{N}$ of\r\nelements of $A$ such that%\r\n\\begin{equation}\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\varphi_{P/D}\\left(  y_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  . \\label{pf.thm.F.gW.EtoF.ass}%\r\n\\end{equation}\r\nConsider this family $\\left(  y_{P}\\right)  _{P\\in N}$. We need to prove that\r\nAssertion $\\mathcal{F}_{1}$ holds, i.e., that every $P\\in N$ satisfies%\r\n\\[\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in PA.\r\n\\]\r\n\r\n\r\nFix $P\\in N$. Then, every monic divisor $D$ of $P$ satisfies%\r\n\\begin{equation}\r\nb_{P/D}=\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}}E\\varphi_{\\left(  P/E\\right)\r\n/D}\\left(  y_{E}\\right)  \\label{pf.thm.F.gW.EtoF.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.EtoF.1}):} Let $B$ be a monic\r\ndivisor of $P$. Thus, $P/B\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Moreover,\r\nthe polynomial $P/B$ is monic (since $P$ and $B$ are monic), and is a divisor\r\nof $P$. Hence, $P/B\\in N$ (since $N$ is a $q$-nest, and since $P\\in N$). Thus,\r\n(\\ref{pf.thm.F.gW.EtoF.ass}) (applied to $P/B$ instead of $P$) yields%\r\n\\begin{align*}\r\nb_{P/B}  &  =\\underbrace{\\sum_{D\\mid P/B}}_{\\substack{=\\sum_{\\substack{D\\mid\r\nP;\\\\BD\\mid P}}\\\\\\text{(since the monic divisors }D\\text{ of }P/B\\\\\\text{are\r\nprecisely the monic divisors }D\\text{ of }P\\\\\\text{satisfying }BD\\mid\r\nP\\text{)}}}D\\underbrace{\\varphi_{\\left(  P/B\\right)  /D}}_{\\substack{=\\varphi\r\n_{\\left(  P/D\\right)  /B}\\\\\\text{(since }\\left(  P/B\\right)  /D=\\left(\r\nP/D\\right)  /B\\text{)}}}\\left(  y_{D}\\right)  =\\sum_{\\substack{D\\mid\r\nP;\\\\BD\\mid P}}D\\varphi_{\\left(  P/D\\right)  /B}\\left(  y_{D}\\right) \\\\\r\n&  =\\sum_{\\substack{E\\mid P;\\\\BE\\mid P}}E\\varphi_{\\left(  P/E\\right)\r\n/B}\\left(  y_{E}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have renamed the}\\\\\r\n\\text{summation index }D\\text{ as }E\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\n\\par\r\nNow, forget that we fixed $B$. We thus have shown that every monic divisor $B$\r\nof $P$ satisfies $b_{P/B}=\\sum_{\\substack{E\\mid P;\\\\BE\\mid P}}E\\varphi\r\n_{\\left(  P/E\\right)  /B}\\left(  y_{E}\\right)  $. Renaming $B$ as $D$ in this\r\nresult, we obtain the following: Every monic divisor $D$ of $P$ satisfies\r\n$b_{P/D}=\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}}E\\varphi_{\\left(  P/E\\right)\r\n/D}\\left(  y_{E}\\right)  $. This proves (\\ref{pf.thm.F.gW.EtoF.1}).}.\r\nMoreover, if $D$ and $E$ are two monic divisors of $P$ satisfying $DE\\mid P$,\r\nthen%\r\n\\begin{equation}\r\n\\varphi_{D}\\left(  \\varphi_{\\left(  P/E\\right)  /D}\\left(  y_{E}\\right)\r\n\\right)  =\\varphi_{P/E}\\left(  y_{E}\\right)  \\label{pf.thm.F.gW.EtoF.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.EtoF.3}):} Let $D$ and $E$ be two\r\nmonic divisors of $P$ satisfying $DE\\mid P$. We have $E\\mid DE\\mid P$. Thus,\r\n$P/E\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Moreover, the polynomial $P/E$ is\r\nmonic (since $P$ and $E$ are monic). Hence, $P/E$ is a monic divisor of $P\\in\r\nN$. Thus, $P/E\\in N$ (since $N$ is a $q$-nest). Moreover, $D\\mid P/E$ (since\r\n$\\dfrac{P/E}{D}=\\dfrac{P}{DE}\\in\\mathbb{F}_{q}\\left[  T\\right]  $ (since\r\n$DE\\mid P$)). Hence, $D$ is a monic divisor of $P/E$. Thus,\r\n(\\ref{pf.thm.F.gW.composition}) (applied to $P/E$ instead of $P$) yields\r\n$\\varphi_{D}\\circ\\varphi_{\\left(  P/E\\right)  /D}=\\varphi_{P/E}$.\r\n\\par\r\nNow, $\\varphi_{D}\\left(  \\varphi_{\\left(  P/E\\right)  /D}\\left(  y_{E}\\right)\r\n\\right)  =\\underbrace{\\left(  \\varphi_{D}\\circ\\varphi_{\\left(  P/E\\right)\r\n/D}\\right)  }_{=\\varphi_{P/E}}\\left(  y_{E}\\right)  =\\varphi_{P/E}\\left(\r\ny_{E}\\right)  $. This proves (\\ref{pf.thm.F.gW.EtoF.3}).}.\r\n\r\nHence, every monic divisor $D$ of $P$ satisfies%\r\n\\begin{align}\r\n\\varphi_{D}\\left(  \\underbrace{b_{P/D}}_{\\substack{=\\sum_{\\substack{E\\mid\r\nP;\\\\DE\\mid P}}E\\varphi_{\\left(  P/E\\right)  /D}\\left(  y_{E}\\right)\r\n\\\\\\text{(by (\\ref{pf.thm.F.gW.EtoF.1}))}}}\\right)   &  =\\varphi_{D}\\left(\r\n\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}}E\\varphi_{\\left(  P/E\\right)  /D}\\left(\r\ny_{E}\\right)  \\right)  =\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}%\r\n}E\\underbrace{\\varphi_{D}\\left(  \\varphi_{\\left(  P/E\\right)  /D}\\left(\r\ny_{E}\\right)  \\right)  }_{\\substack{=\\varphi_{P/E}\\left(  y_{E}\\right)\r\n\\\\\\text{(by (\\ref{pf.thm.F.gW.EtoF.3}))}}}\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since the map }\\varphi_{D}\\text{ is }\\mathcal{F}\\text{-linear}\\\\\r\n\\text{(by (\\ref{pf.thm.F.gW.Flin}), applied to }D\\text{ instead of }P\\text{)}%\r\n\\end{array}\r\n\\right) \\nonumber\\\\\r\n&  =\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}}E\\varphi_{P/E}\\left(  y_{E}\\right)  .\r\n\\label{pf.thm.F.gW.EtoF.6}%\r\n\\end{align}\r\nHence,%\r\n\\begin{align*}\r\n&  \\sum_{D\\mid P}\\mu\\left(  D\\right)  \\underbrace{\\varphi_{D}\\left(\r\nb_{P/D}\\right)  }_{\\substack{=\\sum_{\\substack{E\\mid P;\\\\DE\\mid P}%\r\n}E\\varphi_{P/E}\\left(  y_{E}\\right)  \\\\\\text{(by (\\ref{pf.thm.F.gW.EtoF.6}))}%\r\n}}\\\\\r\n&  =\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\sum_{\\substack{E\\mid P;\\\\DE\\mid\r\nP}}E\\varphi_{P/E}\\left(  y_{E}\\right)  =\\sum_{B\\mid P}\\mu\\left(  B\\right)\r\n\\sum_{\\substack{E\\mid P;\\\\BE\\mid P}}E\\varphi_{P/E}\\left(  y_{E}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{here, we have renamed the summation}\\\\\r\n\\text{index }D\\text{ as }B\\text{ in the outer sum}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\underbrace{\\sum_{B\\mid P}\\sum_{\\substack{E\\mid P;\\\\BE\\mid P}}}%\r\n_{=\\sum_{E\\mid P}\\sum_{\\substack{B\\mid P;\\\\BE\\mid P}}}\\mu\\left(  B\\right)\r\nE\\varphi_{P/E}\\left(  y_{E}\\right)  =\\sum_{E\\mid P}\\underbrace{\\sum\r\n_{\\substack{B\\mid P;\\\\BE\\mid P}}\\mu\\left(  B\\right)  }_{\\substack{=\\left[\r\nE=P\\right]  \\\\\\text{(by Corollary \\ref{cor.moebius-Q.sum-rel},}\\\\\\text{applied\r\nto }M=P\\text{)}}}E\\varphi_{P/E}\\left(  y_{E}\\right) \\\\\r\n&  =\\sum_{E\\mid P}\\left[  E=P\\right]  E\\varphi_{P/E}\\left(  y_{E}\\right) \\\\\r\n&  =\\underbrace{\\left[  P=P\\right]  }_{=1}P\\underbrace{\\varphi_{P/P}%\r\n}_{\\substack{=\\operatorname*{id}\\\\\\text{(by Assumption 1)}}}\\left(\r\ny_{P}\\right)  +\\sum_{\\substack{E\\mid P;\\\\E\\neq P}}\\underbrace{\\left[\r\nE=P\\right]  }_{\\substack{=0\\\\\\text{(since }E\\neq P\\text{)}}}E\\varphi\r\n_{P/E}\\left(  y_{E}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}E=P\\text{ from the sum}\\right) \\\\\r\n&  =P\\underbrace{\\operatorname*{id}\\left(  y_{P}\\right)  }_{=y_{P}%\r\n}+\\underbrace{\\sum_{\\substack{E\\mid P;\\\\E\\neq P}}0E\\varphi_{P/E}\\left(\r\ny_{E}\\right)  }_{=0}=P\\underbrace{y_{P}}_{\\in A}\\in PA.\r\n\\end{align*}\r\nThus, Assertion $\\mathcal{F}_{1}$ holds. We have thus proven the implication\r\n$\\mathcal{E}_{1}\\Longrightarrow\\mathcal{F}_{1}$.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{F}_{1}\\Longrightarrow\r\n\\mathcal{E}_{1}$\\textit{:} Assume that Assertion $\\mathcal{F}_{1}$ holds. That\r\nis, every $P\\in N$ satisfies%\r\n\\begin{equation}\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in PA.\r\n\\label{pf.thm.F.gW.FtoE.ass}%\r\n\\end{equation}\r\n\r\n\r\nNow we need to prove that Assertion $\\mathcal{E}_{1}$ holds, i.e., that there\r\nexists a family $\\left(  y_{P}\\right)  _{P\\in N}\\in A^{N}$ of elements of $A$\r\nsuch that every $P\\in N$ satisfies%\r\n\\begin{equation}\r\n\\left(  b_{P}=\\sum_{D\\mid P}D\\varphi_{P/D}\\left(  y_{D}\\right)  \\text{ for\r\nevery }P\\in N\\right)  . \\label{pf.thm.F.gW.FtoE.goal}%\r\n\\end{equation}\r\nWe shall construct such a family $\\left(  y_{P}\\right)  _{P\\in N}$\r\nrecursively, by induction over $\\deg P$. That is, we fix some $Q\\in N$, and we\r\nassume that we already have constructed a $y_{P}\\in A$ for every $P\\in N$\r\nsatisfying $\\deg P<\\deg Q$; we furthermore assume that these $y_{P}$ satisfy%\r\n\\begin{equation}\r\nb_{P}=\\sum_{D\\mid P}D\\varphi_{P/D}\\left(  y_{D}\\right)\r\n\\label{pf.thm.F.gW.FtoE.indass}%\r\n\\end{equation}\r\nfor every $P\\in N$ satisfying $\\deg P<\\deg Q$. We now need to construct a\r\n$y_{Q}\\in A$ such that (\\ref{pf.thm.F.gW.FtoE.indass}) is satisfied for $P=Q$.\r\nIn other words, we need to construct a $y_{Q}\\in A$ satisfying $b_{Q}%\r\n=\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right)  $.\r\n\r\nFrom (\\ref{pf.thm.F.gW.FtoE.ass}) (applied to $P=Q$), we obtain $\\sum_{D\\mid\r\nQ}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{Q/D}\\right)  \\in QA$. Thus, there\r\nexists a $t\\in A$ such that $\\sum_{D\\mid Q}\\mu\\left(  D\\right)  \\varphi\r\n_{D}\\left(  b_{Q/D}\\right)  =Qt$. Consider this $t$. Set $y_{Q}=t$.\r\n\r\nFor every monic divisor $E$ of $Q$ satisfying $E\\neq1$, we have%\r\n\\begin{equation}\r\nb_{Q/E}=\\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\varphi_{\\left(  Q/D\\right)\r\n/E}\\left(  y_{D}\\right)  \\label{pf.thm.F.gW.FtoE.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.FtoE.1}):} Let $E$ be a monic\r\ndivisor of $Q$ satisfying $E\\neq1$. We have $E\\mid Q$ and thus $Q/E\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  $. The polynomial $Q/E$ is monic (since $Q$\r\nand $E$ are monic) and thus is a monic divisor of $Q\\in N$. Hence, $Q/E\\in N$\r\n(since $N$ is a $q$-nest). Also, $E$ is a monic polynomial satisfying $E\\neq\r\n1$; therefore, $\\deg E>0$. Hence, $\\deg\\left(  Q/E\\right)  =\\deg\r\nQ-\\underbrace{\\deg E}_{>0}<\\deg Q$. Thus, we can apply\r\n(\\ref{pf.thm.F.gW.FtoE.indass}) to $P=Q/E$ (since we have assumed that\r\n(\\ref{pf.thm.F.gW.FtoE.indass}) holds for every $P\\in N$ satisfying $\\deg\r\nP<\\deg Q$). As a result, we obtain%\r\n\\[\r\nb_{Q/E}=\\underbrace{\\sum_{D\\mid Q/E}}_{\\substack{=\\sum_{\\substack{D\\mid\r\nQ;\\\\DE\\mid Q}}\\\\\\text{(since the monic divisors }D\\text{ of }Q/E\\\\\\text{are\r\nprecisely the monic divisors }D\\text{ of }Q\\\\\\text{satisfying }DE\\mid Q\\text{\r\n(since }E\\mid Q\\text{))}}}D\\underbrace{\\varphi_{\\left(  Q/E\\right)  /D}%\r\n}_{\\substack{=\\varphi_{\\left(  Q/D\\right)  /E}\\\\\\text{(since }\\left(\r\nQ/E\\right)  /D=\\left(  Q/D\\right)  /E\\text{)}}}\\left(  y_{D}\\right)\r\n=\\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\varphi_{\\left(  Q/D\\right)  /E}\\left(\r\ny_{D}\\right)  .\r\n\\]\r\nThis proves (\\ref{pf.thm.F.gW.FtoE.1}).}. If $D$ and $E$ are two monic\r\ndivisors of $Q$ satisfying $DE\\mid Q$, then%\r\n\\begin{equation}\r\n\\varphi_{E}\\left(  \\varphi_{\\left(  Q/D\\right)  /E}\\left(  y_{D}\\right)\r\n\\right)  =\\varphi_{Q/D}\\left(  y_{D}\\right)  \\label{pf.thm.F.gW.FtoE.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.FtoE.3}):} Let $D$ and $E$ be two\r\nmonic divisors of $Q$ satisfying $DE\\mid Q$. We have $D\\mid Q$ and thus\r\n$Q/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $. The polynomial $Q/D$ is monic (since\r\n$Q$ and $D$ are monic), and thus is a monic divisor of $Q\\in N$. Hence,\r\n$Q/D\\in N$ (since $N$ is a $q$-nest). Moreover, $DE\\mid Q$, and thus\r\n$\\dfrac{Q}{DE}\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, $\\dfrac{Q/D}%\r\n{E}=\\dfrac{Q}{DE}\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Thus, $E$ is a divisor\r\nof $Q/D$ (since $Q/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $). Hence,\r\n(\\ref{pf.thm.F.gW.composition}) (applied to $Q/D$ and $E$ instead of $P$ and\r\n$D$) shows that\r\n\\[\r\n\\varphi_{E}\\circ\\varphi_{\\left(  Q/D\\right)  /E}=\\varphi_{Q/D}.\r\n\\]\r\nNow, $\\varphi_{E}\\left(  \\varphi_{\\left(  Q/D\\right)  /E}\\left(  y_{D}\\right)\r\n\\right)  =\\underbrace{\\left(  \\varphi_{E}\\circ\\varphi_{\\left(  Q/D\\right)\r\n/E}\\right)  }_{=\\varphi_{Q/D}}\\left(  y_{D}\\right)  =\\varphi_{Q/D}\\left(\r\ny_{D}\\right)  $. This proves (\\ref{pf.thm.F.gW.FtoE.3}).}. If $D$ is a monic\r\ndivisor of $Q$, then%\r\n\\begin{equation}\r\n\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)  =\\left[\r\nD=Q\\right]  -1 \\label{pf.thm.F.gW.FtoE.5}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.FtoE.5}):} Let $D$ be a monic\r\ndivisor of $Q$. We must prove (\\ref{pf.thm.F.gW.FtoE.5}).\r\n\\par\r\nThe polynomial $1$ is a monic divisor of $Q$ satisfying $D\\cdot1\\mid Q$ (since\r\n$D\\cdot1=D\\mid Q$). Hence, we can split off the addend for $E=1$ from the sum\r\n$\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q}}\\mu\\left(  E\\right)  $. As a result, we\r\nobtain%\r\n\\[\r\n\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q}}\\mu\\left(  E\\right)  =\\sum\r\n_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)  +\\underbrace{\\mu\r\n\\left(  1\\right)  }_{=1}=\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}%\r\n}\\mu\\left(  E\\right)  +1.\r\n\\]\r\nComparing this with%\r\n\\begin{align*}\r\n\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q}}\\mu\\left(  E\\right)   &  =\\underbrace{\\sum\r\n_{\\substack{B\\mid Q;\\\\DB\\mid Q}}}_{=\\sum_{\\substack{B\\mid Q;\\\\BD\\mid\r\nQ\\\\\\text{(since }DB=BD\\\\\\text{for every }B\\mid Q\\text{)}}}}\\mu\\left(\r\nB\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have renamed the\r\nsummation index }E\\text{ as }B\\right) \\\\\r\n&  =\\sum_{\\substack{B\\mid Q;\\\\BD\\mid Q}}\\mu\\left(  B\\right)  =\\left[\r\nD=Q\\right]  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Corollary \\ref{cor.moebius-Q.sum-rel}, applied to }Q\\text{ and }D\\\\\r\n\\text{instead of }M\\text{ and }E\r\n\\end{array}\r\n\\right)  ,\r\n\\end{align*}\r\nwe obtain $\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)\r\n+1=\\left[  D=Q\\right]  $. In other words, $\\sum_{\\substack{E\\mid Q;\\\\DE\\mid\r\nQ;\\\\E\\neq1}}\\mu\\left(  E\\right)  =\\left[  D=Q\\right]  -1$. This proves\r\n(\\ref{pf.thm.F.gW.FtoE.5}).}.\r\n\r\nNow,%\r\n\\begin{align*}\r\nQt  &  =\\sum_{D\\mid Q}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{Q/D}\\right)\r\n=\\sum_{E\\mid Q}\\mu\\left(  E\\right)  \\varphi_{E}\\left(  b_{Q/E}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have renamed the summation index\r\n}D\\text{ as }E\\right) \\\\\r\n&  =\\underbrace{\\mu\\left(  1\\right)  }_{=1}\\underbrace{\\varphi_{1}%\r\n}_{=\\operatorname*{id}}\\left(  \\underbrace{b_{Q/1}}_{=b_{Q}}\\right)\r\n+\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)  \\varphi_{E}\\left(\r\n\\underbrace{b_{Q/E}}_{\\substack{=\\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}%\r\n}D\\varphi_{\\left(  Q/D\\right)  /E}\\left(  y_{D}\\right)  \\\\\\text{(by\r\n(\\ref{pf.thm.F.gW.FtoE.1}))}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have split off the addend for\r\n}E=1\\text{ from the sum}\\right) \\\\\r\n&  =\\underbrace{\\operatorname*{id}\\left(  b_{Q}\\right)  }_{=b_{Q}}%\r\n+\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)  \\underbrace{\\varphi\r\n_{E}\\left(  \\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\varphi_{\\left(  Q/D\\right)\r\n/E}\\left(  y_{D}\\right)  \\right)  }_{\\substack{=\\sum_{\\substack{D\\mid\r\nQ;\\\\DE\\mid Q}}D\\varphi_{E}\\left(  \\varphi_{\\left(  Q/D\\right)  /E}\\left(\r\ny_{D}\\right)  \\right)  \\\\\\text{(since the map }\\varphi_{E}\\text{ is\r\n}\\mathcal{F}\\text{-linear}\\\\\\text{(by (\\ref{pf.thm.F.gW.Flin}), applied to\r\n}E\\text{ instead of }P\\text{))}}}\\\\\r\n&  =b_{Q}+\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)\r\n\\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\underbrace{\\varphi_{E}\\left(\r\n\\varphi_{\\left(  Q/D\\right)  /E}\\left(  y_{D}\\right)  \\right)  }%\r\n_{\\substack{=\\varphi_{Q/D}\\left(  y_{D}\\right)  \\\\\\text{(by\r\n(\\ref{pf.thm.F.gW.FtoE.3}))}}}=b_{Q}+\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}%\r\n}\\mu\\left(  E\\right)  \\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\varphi\r\n_{Q/D}\\left(  y_{D}\\right)  .\r\n\\end{align*}\r\nSubtracting $b_{Q}$ from both sides of this equality, we obtain%\r\n\\begin{align*}\r\nQt-b_{Q}  &  =\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}}\\mu\\left(  E\\right)\r\n\\sum_{\\substack{D\\mid Q;\\\\DE\\mid Q}}D\\varphi_{Q/D}\\left(  y_{D}\\right)\r\n=\\underbrace{\\sum_{\\substack{E\\mid Q;\\\\E\\neq1}}\\sum_{\\substack{D\\mid\r\nQ;\\\\DE\\mid Q}}}_{=\\sum_{D\\mid Q}\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}%\r\n}}\\mu\\left(  E\\right)  D\\varphi_{Q/D}\\left(  y_{D}\\right) \\\\\r\n&  =\\sum_{D\\mid Q}\\underbrace{\\sum_{\\substack{E\\mid Q;\\\\DE\\mid Q;\\\\E\\neq1}%\r\n}\\mu\\left(  E\\right)  }_{\\substack{=\\left[  D=Q\\right]  -1\\\\\\text{(by\r\n(\\ref{pf.thm.F.gW.FtoE.5}))}}}D\\varphi_{Q/D}\\left(  y_{D}\\right)  =\\sum_{D\\mid\r\nQ}\\left(  \\left[  D=Q\\right]  -1\\right)  D\\varphi_{Q/D}\\left(  y_{D}\\right) \\\\\r\n&  =\\underbrace{\\sum_{D\\mid Q}\\left[  D=Q\\right]  D\\varphi_{Q/D}\\left(\r\ny_{D}\\right)  }_{\\substack{=\\left[  Q=Q\\right]  Q\\varphi_{Q/Q}\\left(\r\ny_{Q}\\right)  +\\sum_{\\substack{D\\mid Q;\\\\D\\neq Q}}\\left[  D=Q\\right]\r\nD\\varphi_{Q/D}\\left(  y_{D}\\right)  \\\\\\text{(here, we have split off the\r\naddend for }D=Q\\text{ from the sum)}}}-\\sum_{D\\mid Q}\\underbrace{1D}%\r\n_{=D}\\varphi_{Q/D}\\left(  y_{D}\\right) \\\\\r\n&  =\\underbrace{\\left[  Q=Q\\right]  }_{=1}Q\\underbrace{\\varphi_{Q/Q}%\r\n}_{=\\varphi_{1}=\\operatorname*{id}}\\left(  y_{Q}\\right)  +\\sum\r\n_{\\substack{D\\mid Q;\\\\D\\neq Q}}\\underbrace{\\left[  D=Q\\right]  }%\r\n_{\\substack{=0\\\\\\text{(since }D\\neq Q\\text{)}}}D\\varphi_{Q/D}\\left(\r\ny_{D}\\right)  -\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right) \\\\\r\n&  =Q\\underbrace{\\operatorname*{id}\\left(  y_{Q}\\right)  }_{=y_{Q}%\r\n=t}+\\underbrace{\\sum_{\\substack{D\\mid Q;\\\\D\\neq Q}}0D\\varphi_{Q/D}\\left(\r\ny_{D}\\right)  }_{=0}-\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right) \\\\\r\n&  =Qt-\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right)  .\r\n\\end{align*}\r\nSubtracting $Qt$ from both sides of this equality, we obtain%\r\n\\[\r\n-b_{Q}=-\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right)  .\r\n\\]\r\nIn other words, $b_{Q}=\\sum_{D\\mid Q}D\\varphi_{Q/D}\\left(  y_{D}\\right)  $. In\r\nother words, (\\ref{pf.thm.F.gW.FtoE.indass}) is satisfied for $P=Q$.\r\n\r\nThus, we have constructed a $y_{Q}\\in A$ such that\r\n(\\ref{pf.thm.F.gW.FtoE.indass}) is satisfied for $P=Q$. This completes a step\r\nof our recursive construction of the family $\\left(  y_{P}\\right)  _{P\\in N}$.\r\nThis family therefore exists. In other words, Assertion $\\mathcal{E}_{1}$\r\nholds. Thus, the implication $\\mathcal{F}_{1}\\Longrightarrow\\mathcal{E}_{1}$\r\nis proven.\r\n\r\nWe have now proven the two implications $\\mathcal{E}_{1}\\Longrightarrow\r\n\\mathcal{F}_{1}$ and $\\mathcal{F}_{1}\\Longrightarrow\\mathcal{E}_{1}$.\r\nCombining them, we obtain the equivalence $\\mathcal{E}_{1}\\Longleftrightarrow\r\n\\mathcal{F}_{1}$.\r\n\r\nLet us define one more notation: For every $P\\in N$ and every monic divisor\r\n$D$ of $P$, we define an element $g_{P,D}$ of $A$ by $g_{P,D}=\\varphi\r\n_{D}\\left(  b_{P/D}\\right)  $. (This is well-defined\\footnote{\\textit{Proof.}\r\nLet $P\\in N$, and let $D$ be a monic divisor of $P$. Since $D$ is a monic\r\ndivisor of $P\\in N$, we have $D\\in N$ (since $N$ is a $q$-nest). Hence,\r\n$\\varphi_{D}$ is well-defined. Also, $P/D\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\n(since $D\\mid P$). The polynomial $P/D$ is monic (since $P$ and $D$ are\r\nmonic), and thus is a monic divisor of $P\\in N$. Hence, $P/D\\in N$ (since $N$\r\nis a $q$-nest). Thus, $b_{P/D}$ is well-defined. Therefore, $\\varphi\r\n_{D}\\left(  b_{P/D}\\right)  $ is well-defined (since $\\varphi_{D}$ is\r\nwell-defined). Qed.}.)\r\n\r\nNext, let us introduce two more assertions:\r\n\r\n\\begin{statement}\r\n\\textit{Assertion }$\\mathcal{L}$\\textit{:} Every $P\\in N$ and every monic\r\ndivisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\]\r\n\r\n\\end{statement}\r\n\r\n\\begin{statement}\r\n\\textit{Assertion }$\\mathcal{M}$\\textit{:} Every $P\\in N$ and every monic\r\ndivisor $E$ of $P$ satisfy%\r\n\\[\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\varphi_{C}\\left(  D\\right)  g_{P,DE}\\in\r\nPA.\r\n\\]\r\n\r\n\\end{statement}\r\n\r\nLemma \\ref{lem.F.gW.F-G-gen} shows that these two Assertions $\\mathcal{L}$ and\r\n$\\mathcal{M}$ are equivalent. In other words, we have the equivalence\r\n$\\mathcal{L}\\Longleftrightarrow\\mathcal{M}$.\r\n\r\nWe shall now prove the implications $\\mathcal{F}_{1}\\Longrightarrow\r\n\\mathcal{L}$, $\\mathcal{L}\\Longrightarrow\\mathcal{F}_{1}$, $\\mathcal{G}%\r\n_{1}\\Longrightarrow\\mathcal{M}$ and $\\mathcal{M}\\Longrightarrow\\mathcal{G}%\r\n_{1}$:\r\n\r\n\\textit{Proof of the implication }$\\mathcal{F}_{1}\\Longrightarrow\\mathcal{L}%\r\n$\\textit{:} Assume that Assertion $\\mathcal{F}_{1}$ holds. That is, every\r\n$P\\in N$ satisfies%\r\n\\begin{equation}\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in PA.\r\n\\label{pf.thm.F.gW.FtoL.ass}%\r\n\\end{equation}\r\n\r\n\r\nNow we need to prove that Assertion $\\mathcal{L}$ holds, i.e., that every\r\n$P\\in N$ and every monic divisor $E$ of $P$ satisfy%\r\n\\begin{equation}\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\label{pf.thm.F.gW.FtoL.goal}%\r\n\\end{equation}\r\n\r\n\r\nLet $P\\in N$. Let $E$ be a monic divisor of $P$. Thus, $E\\mid P$, so that\r\n$P/E\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Moreover, the polynomial $P/E$ is\r\nmonic (since $P$ and $E$ are monic). Hence, $P/E$ is a monic divisor of $P\\in\r\nN$. Thus, $P/E\\in N$ (since $N$ is a $q$-nest). Hence,\r\n(\\ref{pf.thm.F.gW.FtoL.ass}) (applied to $P/E$ instead of $P$) yields%\r\n\\begin{equation}\r\n\\sum_{D\\mid P/E}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{\\left(  P/E\\right)\r\n/D}\\right)  \\in\\left(  P/E\\right)  A. \\label{pf.thm.F.gW.FtoL.2}%\r\n\\end{equation}\r\n\r\n\r\nBut the map $\\varphi_{E}$ is $\\mathcal{F}$-linear (by (\\ref{pf.thm.F.gW.Flin}%\r\n), applied to $E$ instead of $P$). Furthermore, we have%\r\n\\begin{equation}\r\n\\varphi_{E}\\circ\\varphi_{D}=\\varphi_{DE}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\nmonic divisor }D\\text{ of }P/E \\label{pf.thm.F.gW.FtoL.4}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{pf.thm.F.gW.FtoL.4}):} Let $D$ be a monic\r\ndivisor of $P/E$.\r\n\\par\r\nWe have $D\\mid P/E$, thus $\\dfrac{P/E}{D}\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\nAlso, the polynomial $DE$ is monic (since $D$ and $E$ are monic) and divides\r\n$P$ (since $\\dfrac{P}{DE}=\\dfrac{P/E}{D}\\in\\mathbb{F}_{q}\\left[  T\\right]  $).\r\nThus, $DE$ is a monic divisor of $P\\in N$. Hence, $DE\\in N$ (since $N$ is a\r\n$q$-nest). Thus, (\\ref{pf.thm.F.gW.compositionDE}) (applied to $E$ and $D$\r\ninstead of $D$ and $E$) shows that $\\varphi_{E}\\circ\\varphi_{D}=\\varphi\r\n_{ED}=\\varphi_{DE}$. This proves (\\ref{pf.thm.F.gW.FtoL.4}).}.\r\n\r\nApplying the map $\\varphi_{E}$ to both sides of the relation\r\n(\\ref{pf.thm.F.gW.FtoL.2}), we obtain%\r\n\\[\r\n\\varphi_{E}\\left(  \\sum_{D\\mid P/E}\\mu\\left(  D\\right)  \\varphi_{D}\\left(\r\nb_{\\left(  P/E\\right)  /D}\\right)  \\right)  \\in\\varphi_{E}\\left(  \\left(\r\nP/E\\right)  A\\right)  \\subseteq\\left(  P/E\\right)  \\varphi_{E}\\left(\r\nA\\right)\r\n\\]\r\n(since the map $\\varphi_{E}$ is $\\mathcal{F}$-linear). In view of%\r\n\\begin{align*}\r\n&  \\varphi_{E}\\left(  \\sum_{D\\mid P/E}\\mu\\left(  D\\right)  \\varphi_{D}\\left(\r\nb_{\\left(  P/E\\right)  /D}\\right)  \\right) \\\\\r\n&  =\\sum_{D\\mid P/E}\\mu\\left(  D\\right)  \\underbrace{\\varphi_{E}\\left(\r\n\\varphi_{D}\\left(  b_{\\left(  P/E\\right)  /D}\\right)  \\right)  }_{=\\left(\r\n\\varphi_{E}\\circ\\varphi_{D}\\right)  \\left(  b_{\\left(  P/E\\right)  /D}\\right)\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since the map }\\varphi_{E}\\text{ is\r\n}\\mathcal{F}\\text{-linear}\\right) \\\\\r\n&  =\\sum_{D\\mid P/E}\\mu\\left(  D\\right)  \\underbrace{\\left(  \\varphi_{E}%\r\n\\circ\\varphi_{D}\\right)  }_{\\substack{=\\varphi_{DE}\\\\\\text{(by\r\n(\\ref{pf.thm.F.gW.FtoL.4}))}}}\\left(  \\underbrace{b_{\\left(  P/E\\right)  /D}%\r\n}_{\\substack{=b_{P/\\left(  DE\\right)  }\\\\\\text{(since }\\left(  P/E\\right)\r\n/D=P/\\left(  DE\\right)  \\text{)}}}\\right) \\\\\r\n&  =\\underbrace{\\sum_{D\\mid P/E}}_{\\substack{=\\sum_{\\substack{D\\mid P;\\\\DE\\mid\r\nP}}\\\\\\text{(since the monic divisors }D\\text{ of }P/E\\\\\\text{are exactly the\r\nmonic divisors }D\\text{ of }P\\\\\\text{satisfying }DE\\mid P\\text{ (since }E\\mid\r\nP\\text{))}}}\\mu\\left(  D\\right)  \\underbrace{\\varphi_{DE}\\left(  b_{P/\\left(\r\nDE\\right)  }\\right)  }_{\\substack{=g_{P,DE}\\\\\\text{(since }g_{P,DE}%\r\n=\\varphi_{DE}\\left(  b_{P/\\left(  DE\\right)  }\\right)  \\\\\\text{(by the\r\ndefinition of }g_{P,DE}\\text{))}}}\\\\\r\n&  =\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE},\r\n\\end{align*}\r\nthis rewrites as $\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)\r\ng_{P,DE}\\in\\left(  P/E\\right)  \\varphi_{E}\\left(  A\\right)  $. Hence,%\r\n\\[\r\nE\\underbrace{\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)\r\ng_{P,DE}}_{\\in\\left(  P/E\\right)  \\varphi_{E}\\left(  A\\right)  }%\r\n\\in\\underbrace{E\\left(  P/E\\right)  }_{=P}\\underbrace{\\varphi_{E}\\left(\r\nA\\right)  }_{\\subseteq A}\\subseteq PA.\r\n\\]\r\nIn other words, (\\ref{pf.thm.F.gW.FtoL.goal}) holds. Thus, Assertion\r\n$\\mathcal{L}$ holds. We have thus proven the implication $\\mathcal{F}%\r\n_{1}\\Longrightarrow\\mathcal{L}$.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{F}_{1}\\Longrightarrow\\mathcal{L}%\r\n$\\textit{:} Assume that Assertion $\\mathcal{L}$ holds. That is, every $P\\in N$\r\nand every monic divisor $E$ of $P$ satisfy%\r\n\\begin{equation}\r\nE\\sum_{\\substack{D\\mid P;\\\\DE\\mid P}}\\mu\\left(  D\\right)  g_{P,DE}\\in PA.\r\n\\label{pf.thm.F.gW.LtoF.ass}%\r\n\\end{equation}\r\n\r\n\r\nNow we need to prove that Assertion $\\mathcal{F}_{1}$ holds, i.e., that every\r\n$P\\in N$ satisfies%\r\n\\begin{equation}\r\n\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in PA.\r\n\\label{pf.thm.F.gW.LtoF.goal}%\r\n\\end{equation}\r\n\r\n\r\nLet $P\\in N$. Then, $1$ is a monic divisor of $P$. Hence,\r\n(\\ref{pf.thm.F.gW.LtoF.ass}) (applied to $E=1$) yields%\r\n\\[\r\n1\\sum_{\\substack{D\\mid P;\\\\D\\cdot1\\mid P}}\\mu\\left(  D\\right)  g_{P,D\\cdot\r\n1}\\in PA.\r\n\\]\r\nIn view of%\r\n\\begin{align*}\r\n&  1\\underbrace{\\sum_{\\substack{D\\mid P;\\\\D\\cdot1\\mid P}}}_{=\\sum\r\n_{\\substack{D\\mid P;\\\\D\\mid P}}=\\sum_{D\\mid P}}\\mu\\left(  D\\right)\r\n\\underbrace{g_{P,D\\cdot1}}_{\\substack{=g_{P,D}=\\varphi_{D}\\left(\r\nb_{P/D}\\right)  \\\\\\text{(by the definition of }g_{P,D}\\text{)}}}\\\\\r\n&  =1\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)\r\n=\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $\\sum_{D\\mid P}\\mu\\left(  D\\right)  \\varphi_{D}\\left(\r\nb_{P/D}\\right)  \\in PA$. In other words, (\\ref{pf.thm.F.gW.LtoF.goal}) holds.\r\nThus, Assertion $\\mathcal{F}_{1}$ holds. We have thus proven the implication\r\n$\\mathcal{L}\\Longrightarrow\\mathcal{F}_{1}$.\r\n\r\n\\textit{Proof of the implication }$\\mathcal{G}_{1}\\Longrightarrow\\mathcal{M}%\r\n$\\textit{:} The implication $\\mathcal{G}_{1}\\Longrightarrow\\mathcal{M}$ can be\r\nproven in exactly the same way as the implication $\\mathcal{F}_{1}%\r\n\\Longrightarrow\\mathcal{L}$ (except that every appearance of \\textquotedblleft%\r\n$\\mu$\\textquotedblright\\ must be replaced by \\textquotedblleft$\\varphi_{C}%\r\n$\\textquotedblright).\r\n\r\n\\textit{Proof of the implication }$\\mathcal{M}\\Longrightarrow\\mathcal{G}_{1}%\r\n$\\textit{:} The implication $\\mathcal{M}\\Longrightarrow\\mathcal{G}_{1}$ can be\r\nproven in exactly the same way as the implication $\\mathcal{L}\\Longrightarrow\r\n\\mathcal{F}_{1}$ (except that every appearance of \\textquotedblleft$\\mu\r\n$\\textquotedblright\\ must be replaced by \\textquotedblleft$\\varphi_{C}%\r\n$\\textquotedblright).\r\n\r\nWe now have proven the four implications $\\mathcal{F}_{1}\\Longrightarrow\r\n\\mathcal{L}$, $\\mathcal{L}\\Longrightarrow\\mathcal{F}_{1}$, $\\mathcal{G}%\r\n_{1}\\Longrightarrow\\mathcal{M}$ and $\\mathcal{M}\\Longrightarrow\\mathcal{G}%\r\n_{1}$. Combining them, we obtain the two equivalences $\\mathcal{F}%\r\n_{1}\\Longleftrightarrow\\mathcal{L}$ and $\\mathcal{G}_{1}\\Longleftrightarrow\r\n\\mathcal{M}$.\r\n\r\nFinally, let us prove the equivalence $\\mathcal{F}_{1}\\Longleftrightarrow\r\n\\mathcal{G}_{2}$:\r\n\r\n\\textit{Proof of the equivalence }$\\mathcal{F}_{1}\\Longleftrightarrow\r\n\\mathcal{G}_{2}$\\textit{:} For every $P\\in N$ and $D\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}$, we have\r\n\\[\r\n\\underbrace{\\varphi\\left(  D\\right)  }_{\\substack{=\\mu\\left(  D\\right)  \\text{\r\nin }\\mathbb{F}_{q}\\\\\\text{(by Proposition \\ref{prop.phi-Q.formula}\r\n\\textbf{(d)},}\\\\\\text{applied to }M=D\\text{)}}}\\varphi_{D}\\left(\r\nb_{P/D}\\right)  =\\mu\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  .\r\n\\]\r\nTherefore, Assertion $\\mathcal{G}_{2}$ is equivalent to $\\mathcal{F}_{1}$. In\r\nother words, we obtain the equivalence $\\mathcal{F}_{1}\\Longleftrightarrow\r\n\\mathcal{G}_{2}$.\r\n\r\nWe now have obtained the following equivalences:%\r\n\\begin{align*}\r\n&  \\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{2}\\Longleftrightarrow\\mathcal{E}_{1}%\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\mathcal{E}_{1}\\Longleftrightarrow\\mathcal{F}%\r\n_{1},\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\mathcal{L}\\Longleftrightarrow\\mathcal{M},\\\\\r\n&  \\mathcal{F}_{1}\\Longleftrightarrow\\mathcal{L}%\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\mathcal{G}_{1}\\Longleftrightarrow\\mathcal{M}%\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\mathcal{F}_{1}\\Longleftrightarrow\\mathcal{G}_{2}.\r\n\\end{align*}\r\nCombining them all, we obtain the chain of equivalences%\r\n\\[\r\n\\mathcal{C}_{1}\\Longleftrightarrow\\mathcal{D}_{1}\\Longleftrightarrow\r\n\\mathcal{D}_{2}\\Longleftrightarrow\\mathcal{E}_{1}\\Longleftrightarrow\r\n\\mathcal{F}_{1}\\Longleftrightarrow\\mathcal{L}\\Longleftrightarrow\r\n\\mathcal{M}\\Longleftrightarrow\\mathcal{G}_{1}\\Longleftrightarrow\r\n\\mathcal{G}_{2}.\r\n\\]\r\nIn particular, the assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ are equivalent. This proves Theorem \\ref{thm.F.gW}.\r\n\\end{proof}\r\n\r\n\\subsection{Examples: \\textquotedblleft Necklace congruences\\textquotedblright%\r\n\\ for $\\mathbb{F}_{q}\\left[  T\\right]  $}\r\n\r\nTheorem \\ref{thm.F.gW} shows the equivalence of several assertions, but we\r\nhave yet to see a situation in which these assertions hold. Let us now explore\r\na few such situations. We begin with the simplest ones:\r\n\r\n\\begin{proposition}\r\n\\label{prop.F.gW.example1}Let $N$ be the $q$-nest $\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+}$. Let $A=\\mathbb{F}_{q}\\left[  T\\right]  $. Notice that $A$ is\r\na commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra, and thus an\r\n$\\mathcal{F}$-module (according to Convention \\ref{conv.F.acts-on-commalg}).\r\n\r\nFor every $P\\in N$, define an endomorphism $\\varphi_{P}$ of the $\\mathbb{F}%\r\n_{q}$-vector space $A$ by $\\varphi_{P}=\\operatorname*{id}$.\r\n\r\nFix a polynomial $Q\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\n\\textbf{(a)} The three Assumptions 1, 2 and 3 of Theorem \\ref{thm.F.gW} are satisfied.\r\n\r\n\\textbf{(b)} The assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for the family\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  F^{\\deg P}Q\\right)  _{P\\in N}\\in\r\nA^{N}$.\r\n\r\n\\textbf{(c)} The assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for the family\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  \\left(  \\operatorname*{Carl}P\\right)\r\nQ\\right)  _{P\\in N}\\in A^{N}$.\r\n\r\n\\textbf{(d)} The assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for the family\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  Q\\right)  _{P\\in N}\\in A^{N}$.\r\n\\end{proposition}\r\n\r\nBefore we prove this proposition, let us get two simple lemmas out of our way:\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.gW.example1.lem.dumbed-down}Let $\\pi$ be a monic irreducible\r\npolynomial in $\\mathbb{F}_{q}\\left[  T\\right]  $. Set $d=\\deg\\pi$. Let\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then, $P^{q^{d}}\\equiv\r\nP\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.gW.example1.lem.dumbed-down}.]Let $\\mathbb{F}_{\\pi\r\n}$ denote the field $\\mathbb{F}_{q}\\left[  T\\right]  /\\pi\\mathbb{F}_{q}\\left[\r\nT\\right]  $. This is a field extension of $\\mathbb{F}_{q}$. Furthermore, it is\r\nwell-known that $\\mathbb{F}_{\\pi}=\\mathbb{F}_{q}\\left[  T\\right]\r\n/\\pi\\mathbb{F}_{q}\\left[  T\\right]  $ is an $\\mathbb{F}_{q}$-vector space of\r\ndimension $\\deg\\pi=d$. Hence, $\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert\r\n=\\left\\vert \\mathbb{F}_{q}\\right\\vert ^{d}=q^{d}$ (since $\\left\\vert\r\n\\mathbb{F}_{q}\\right\\vert =q$). In particular, $\\mathbb{F}_{\\pi}$ is a finite field.\r\n\r\nIf $Q$ is any element of $\\mathbb{F}_{q}\\left[  T\\right]  $, then we let\r\n$\\overline{Q}$ denote the residue class of $Q\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ modulo the ideal $\\pi\\mathbb{F}_{q}\\left[  T\\right]  $. This\r\nresidue class $\\overline{Q}$ lies in $\\mathbb{F}_{q}\\left[  T\\right]\r\n/\\pi\\mathbb{F}_{q}\\left[  T\\right]  =\\mathbb{F}_{\\pi}$. Applying this to\r\n$Q=P$, we conclude that $\\overline{P}$ lies in $\\mathbb{F}_{\\pi}$. In other\r\nwords, $\\overline{P}\\in\\mathbb{F}_{\\pi}$.\r\n\r\nBut another known fact says that if $L$ is a finite field, then every $a\\in L$\r\nsatisfies $a^{\\left\\vert L\\right\\vert }=a$. Applying this to $L=\\mathbb{F}%\r\n_{\\pi}$ and $a=\\overline{P}$, we obtain $\\overline{P}^{\\left\\vert\r\n\\mathbb{F}_{\\pi}\\right\\vert }=\\overline{P}$. Since $q^{d}=\\left\\vert\r\n\\mathbb{F}_{\\pi}\\right\\vert $, we have $\\overline{P^{q^{d}}}=\\overline\r\n{P^{\\left\\vert \\mathbb{F}_{\\pi}\\right\\vert }}=\\overline{P}^{\\left\\vert\r\n\\mathbb{F}_{\\pi}\\right\\vert }=\\overline{P}$. In other words, $P^{q^{d}}\\equiv\r\nP\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  $ (because if $Q$ is any\r\nelement of $\\mathbb{F}_{q}\\left[  T\\right]  $, then $\\overline{Q}$ denotes the\r\nresidue class of $Q\\in\\mathbb{F}_{q}\\left[  T\\right]  $ modulo the ideal\r\n$\\pi\\mathbb{F}_{q}\\left[  T\\right]  $). This proves Lemma\r\n\\ref{lem.F.gW.example1.lem.dumbed-down}.\r\n\\end{proof}\r\n\r\n\\begin{lemma}\r\n\\label{lem.F.gW.example1.lem}Let $A=\\mathbb{F}_{q}\\left[  T\\right]  $. Notice\r\nthat $A$ is a commutative $\\mathbb{F}_{q}\\left[  T\\right]  $-algebra, and thus\r\nan $\\mathcal{F}$-module (according to Convention \\ref{conv.F.acts-on-commalg}%\r\n). Let $\\pi$ be a monic irreducible polynomial in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. Let $P\\in A$.\r\n\r\n\\textbf{(a)} We have $\\left(  \\operatorname*{Carl}\\pi\\right)  P\\equiv\r\nP\\operatorname{mod}\\pi A$. Here, $\\left(  \\operatorname*{Carl}\\pi\\right)  P$\r\ndenotes the image of $P$ under the action of $\\operatorname*{Carl}\\pi\r\n\\in\\mathcal{F}$ on the $\\mathcal{F}$-module $A$.\r\n\r\n\\textbf{(b)} We have $F^{\\deg\\pi}P\\equiv P\\operatorname{mod}\\pi A$.\r\n\\end{lemma}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma \\ref{lem.F.gW.example1.lem}.]\\textbf{(b)} Set $d=\\deg\\pi$.\r\nObserve that $P\\in A=\\mathbb{F}_{q}\\left[  T\\right]  $. Thus, Lemma\r\n\\ref{lem.F.gW.example1.lem.dumbed-down} yields $P^{q^{d}}\\equiv\r\nP\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  $. In other words,\r\n$P^{q^{d}}\\equiv P\\operatorname{mod}\\pi A$ (because $\\mathbb{F}_{q}\\left[\r\nT\\right]  =A$).\r\n\r\nNow, (\\ref{eq.prop.F.acts-on-commalg.Fk.eq}) (applied to $k=d$ and $m=P$)\r\nyields $F^{d}\\cdot P=P^{q^{d}}\\equiv P\\operatorname{mod}\\pi A$. Since\r\n$d=\\deg\\pi$, this rewrites as $F^{\\deg\\pi}\\cdot P\\equiv P\\operatorname{mod}\\pi\r\nA$. In other words, $F^{\\deg\\pi}P\\equiv P\\operatorname{mod}\\pi A$. This proves\r\nLemma \\ref{lem.F.gW.example1.lem} \\textbf{(b)}.\r\n\r\n\\textbf{(a)} Corollary \\ref{cor.F.u(pi).mod} (applied to $a=P$) yields\r\n$\\left(  \\operatorname*{Carl}\\pi\\right)  P\\equiv F^{\\deg\\pi}P\\equiv\r\nP\\operatorname{mod}\\pi A$ (by Lemma \\ref{lem.F.gW.example1.lem} \\textbf{(b)}).\r\nLemma \\ref{lem.F.gW.example1.lem} \\textbf{(a)} is thus proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition \\ref{prop.F.gW.example1}.]\\textbf{(a)} Assumptions 1 and\r\n3 of Theorem \\ref{thm.F.gW} are clearly satisfied (since $\\varphi\r\n_{P}=\\operatorname*{id}$ for each $P\\in N$). It thus remains to prove that\r\nAssumption 2 of Theorem \\ref{thm.F.gW} is satisfied.\r\n\r\n\\textit{Proof of Assumption 2 of Theorem \\ref{thm.F.gW}:} Let $a\\in A$. Let\r\n$\\pi\\in N$ be monic irreducible. We must prove that $\\varphi_{\\pi}\\left(\r\na\\right)  \\equiv\\left(  \\operatorname*{Carl}\\pi\\right)  a\\operatorname{mod}\\pi\r\nA$. Here, $\\left(  \\operatorname*{Carl}\\pi\\right)  a$ denotes the image of $a$\r\nunder the action of $\\operatorname*{Carl}\\pi\\in\\mathcal{F}$ on the\r\n$\\mathcal{F}$-module $A$.\r\n\r\nProposition \\ref{prop.F.u(pi)} shows that there exists a unique $u\\left(\r\n\\pi\\right)  \\in\\mathcal{F}$ such that $\\operatorname*{Carl}\\pi=F^{\\deg\\pi}%\r\n+\\pi\\cdot u\\left(  \\pi\\right)  $. Consider this $u\\left(  \\pi\\right)  $. We\r\nhave%\r\n\\[\r\n\\underbrace{\\left(  \\operatorname*{Carl}\\pi\\right)  }_{=F^{\\deg\\pi}+\\pi\\cdot\r\nu\\left(  \\pi\\right)  }a=\\left(  F^{\\deg\\pi}+\\pi\\cdot u\\left(  \\pi\\right)\r\n\\right)  a=F^{\\deg\\pi}a+\\pi\\cdot\\underbrace{u\\left(  \\pi\\right)  a}_{\\in A}\\in\r\nF^{\\deg\\pi}a+\\pi A.\r\n\\]\r\nIn other words, $\\left(  \\operatorname*{Carl}\\pi\\right)  a\\equiv F^{\\deg\\pi\r\n}a\\operatorname{mod}\\pi A$. Thus,%\r\n\\begin{equation}\r\n\\left(  \\operatorname*{Carl}\\pi\\right)  a\\equiv F^{\\deg\\pi}a\\equiv\r\na\\operatorname{mod}\\pi A \\label{pf.prop.F.gW.example1.a.1}%\r\n\\end{equation}\r\n(by Lemma \\ref{lem.F.gW.example1.lem} \\textbf{(b)}, applied to $P=a$).\r\n\r\nBut $\\varphi_{\\pi}=\\operatorname*{id}$ (by the definition of $\\varphi_{\\pi}$),\r\nand thus $\\varphi_{\\pi}\\left(  a\\right)  =\\operatorname*{id}\\left(  a\\right)\r\n=a\\equiv\\left(  \\operatorname*{Carl}\\pi\\right)  a\\operatorname{mod}\\pi A$ (by\r\n(\\ref{pf.prop.F.gW.example1.a.1})). This completes our proof of Assumption 2\r\nof Theorem \\ref{thm.F.gW}.\r\n\r\nThus, all three Assumptions 1, 2 and 3 of Theorem \\ref{thm.F.gW} are\r\nsatisfied. This proves Proposition \\ref{prop.F.gW.example1} \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Define a family $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ by\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  F^{\\deg P}Q\\right)  _{P\\in N}$. Thus,%\r\n\\begin{equation}\r\nb_{P}=F^{\\deg P}Q\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }P\\in N.\r\n\\label{pf.prop.F.gW.example1.b.bP=}%\r\n\\end{equation}\r\nWe now must prove that the assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for this family.\r\n\r\nWe shall first show that Assertion $\\mathcal{C}_{1}$ is satisfied:\r\n\r\n\\textit{Proof of Assertion }$\\mathcal{C}_{1}$\\textit{:} Let $P\\in N$ and\r\n$\\pi\\in\\operatorname*{PF}P$. We must prove that $\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A$.\r\n\r\nWe have $\\pi\\in\\operatorname*{PF}P$, thus $P/\\pi\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $. The polynomial $P/\\pi$ is monic (since $P$ and $\\pi$ are monic),\r\nand thus belongs to $\\mathbb{F}_{q}\\left[  T\\right]  _{+}=N$. Hence, the\r\nequality (\\ref{pf.prop.F.gW.example1.b.bP=}) (applied to $P/\\pi$ instead of\r\n$P$) yields $b_{P/\\pi}=F^{\\deg\\left(  P/\\pi\\right)  }Q$. But $\\varphi_{\\pi\r\n}=\\operatorname*{id}$ (by the definition of $\\varphi_{\\pi}$), and thus%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  =\\operatorname*{id}\\left(  b_{P/\\pi\r\n}\\right)  =b_{P/\\pi}=F^{\\deg\\left(  P/\\pi\\right)  }Q.\r\n\\label{pf.prop.F.gW.example1.b.1}%\r\n\\end{equation}\r\n\r\n\r\nLemma \\ref{lem.F.gW.example1.lem} \\textbf{(b)} (applied to $Q$ instead of $P$)\r\nyields $F^{\\deg\\pi}Q\\equiv Q\\operatorname{mod}\\pi A$. Thus, Corollary\r\n\\ref{cor.F.lift.lift-all} \\textbf{(a)} (applied to $P/\\pi$, $F^{\\deg\\pi}Q$ and\r\n$Q$ instead of $N$, $a$ and $b$) yields%\r\n\\[\r\nF^{\\deg\\left(  P/\\pi\\right)  }F^{\\deg\\pi}Q\\equiv F^{\\deg\\left(  P/\\pi\\right)\r\n}Q\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P/\\pi\\right)  +1}A.\r\n\\]\r\nSince%\r\n\\begin{align*}\r\nF^{\\deg\\left(  P/\\pi\\right)  }F^{\\deg\\pi}  &  =F^{\\deg\\left(  P/\\pi\\right)\r\n+\\deg\\pi}=F^{\\deg P}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\deg\\left(  P/\\pi\\right)  +\\deg\r\n\\pi=\\deg\\underbrace{\\left(  \\left(  P/\\pi\\right)  \\pi\\right)  }_{=P}=\\deg\r\nP\\right)\r\n\\end{align*}\r\nand\r\n\\[\r\n\\underbrace{v_{\\pi}\\left(  P/\\pi\\right)  }_{=v_{\\pi}\\left(  P\\right)  -v_{\\pi\r\n}\\left(  \\pi\\right)  }+1=v_{\\pi}\\left(  P\\right)  -\\underbrace{v_{\\pi}\\left(\r\n\\pi\\right)  }_{=1}+1=v_{\\pi}\\left(  P\\right)  -1+1=v_{\\pi}\\left(  P\\right)  ,\r\n\\]\r\nthis rewrites as\r\n\\[\r\nF^{\\deg P}Q\\equiv F^{\\deg\\left(  P/\\pi\\right)  }Q\\operatorname{mod}\\pi\r\n^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\]\r\nNow, (\\ref{pf.prop.F.gW.example1.b.bP=}) becomes%\r\n\\[\r\nb_{P}=F^{\\deg P}Q\\equiv F^{\\deg\\left(  P/\\pi\\right)  }Q=\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A\r\n\\]\r\n(by (\\ref{pf.prop.F.gW.example1.b.1})). In other words, $\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A$. Thus, Assertion $\\mathcal{C}_{1}$ is proven.\r\n\r\nWe now have shown that Assertion $\\mathcal{C}_{1}$ is satisfied. Thus, all the\r\nassertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$, $\\mathcal{D}_{2}$,\r\n$\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$, and $\\mathcal{G}_{2}$\r\nof Theorem \\ref{thm.F.gW} are satisfied (since Theorem \\ref{thm.F.gW} says\r\nthat these assertions are equivalent). This proves Proposition\r\n\\ref{prop.F.gW.example1} \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Define a family $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ by\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  \\left(  \\operatorname*{Carl}P\\right)\r\nQ\\right)  _{P\\in N}$. Thus,%\r\n\\begin{equation}\r\nb_{P}=\\left(  \\operatorname*{Carl}P\\right)  Q\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }P\\in N. \\label{pf.prop.F.gW.example1.c.bP=}%\r\n\\end{equation}\r\nWe now must prove that the assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for this family.\r\n\r\nWe shall first show that Assertion $\\mathcal{C}_{1}$ is satisfied:\r\n\r\n\\textit{Proof of Assertion }$\\mathcal{C}_{1}$\\textit{:} Let $P\\in N$ and\r\n$\\pi\\in\\operatorname*{PF}P$. We must prove that $\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A$.\r\n\r\nWe have $\\pi\\in\\operatorname*{PF}P$, thus $P/\\pi\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $. The polynomial $P/\\pi$ is monic (since $P$ and $\\pi$ are monic),\r\nand thus belongs to $\\mathbb{F}_{q}\\left[  T\\right]  _{+}=N$. Hence, the\r\nequality (\\ref{pf.prop.F.gW.example1.c.bP=}) (applied to $P/\\pi$ instead of\r\n$P$) yields $b_{P/\\pi}=\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)\r\n\\right)  Q$. But $\\varphi_{\\pi}=\\operatorname*{id}$ (by the definition of\r\n$\\varphi_{\\pi}$), and thus%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  =\\operatorname*{id}\\left(  b_{P/\\pi\r\n}\\right)  =b_{P/\\pi}=\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)\r\n\\right)  Q. \\label{pf.prop.F.gW.example1.c.1}%\r\n\\end{equation}\r\n\r\n\r\nLemma \\ref{lem.F.gW.example1.lem} \\textbf{(a)} (applied to $Q$ instead of $P$)\r\nyields $\\left(  \\operatorname*{Carl}\\pi\\right)  Q\\equiv Q\\operatorname{mod}\\pi\r\nA$. Thus, Corollary \\ref{cor.F.lift.lift-all} \\textbf{(b)} (applied to $P/\\pi\r\n$, $\\left(  \\operatorname*{Carl}\\pi\\right)  Q$ and $Q$ instead of $N$, $a$ and\r\n$b$) yields%\r\n\\[\r\n\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\n\\operatorname*{Carl}\\pi\\right)  Q\\equiv\\left(  \\operatorname*{Carl}\\left(\r\nP/\\pi\\right)  \\right)  Q\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P/\\pi\\right)\r\n+1}A.\r\n\\]\r\nSince%\r\n\\begin{align*}\r\n\\left(  \\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  \\left(\r\n\\operatorname*{Carl}\\pi\\right)   &  =\\operatorname*{Carl}\\left(\r\n\\underbrace{\\left(  P/\\pi\\right)  \\pi}_{=P}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\operatorname*{Carl}\\text{ is an }\\mathbb{F}_{q}\\text{-algebra}\\\\\r\n\\text{homomorphism}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{Carl}P\r\n\\end{align*}\r\nand\r\n\\[\r\n\\underbrace{v_{\\pi}\\left(  P/\\pi\\right)  }_{=v_{\\pi}\\left(  P\\right)  -v_{\\pi\r\n}\\left(  \\pi\\right)  }+1=v_{\\pi}\\left(  P\\right)  -\\underbrace{v_{\\pi}\\left(\r\n\\pi\\right)  }_{=1}+1=v_{\\pi}\\left(  P\\right)  -1+1=v_{\\pi}\\left(  P\\right)  ,\r\n\\]\r\nthis rewrites as\r\n\\[\r\n\\left(  \\operatorname*{Carl}P\\right)  Q\\equiv\\left(  \\operatorname*{Carl}%\r\n\\left(  P/\\pi\\right)  \\right)  Q\\operatorname{mod}\\pi^{v_{\\pi}\\left(\r\nP\\right)  }A.\r\n\\]\r\nNow, (\\ref{pf.prop.F.gW.example1.c.bP=}) becomes%\r\n\\[\r\nb_{P}=\\left(  \\operatorname*{Carl}P\\right)  Q\\equiv\\left(\r\n\\operatorname*{Carl}\\left(  P/\\pi\\right)  \\right)  Q=\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A\r\n\\]\r\n(by (\\ref{pf.prop.F.gW.example1.c.1})). In other words, $\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A$. Thus, Assertion $\\mathcal{C}_{1}$ is proven.\r\n\r\nWe now have shown that Assertion $\\mathcal{C}_{1}$ is satisfied. Thus, all the\r\nassertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$, $\\mathcal{D}_{2}$,\r\n$\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$, and $\\mathcal{G}_{2}$\r\nof Theorem \\ref{thm.F.gW} are satisfied (since Theorem \\ref{thm.F.gW} says\r\nthat these assertions are equivalent). This proves Proposition\r\n\\ref{prop.F.gW.example1} \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Define a family $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ by\r\n$\\left(  b_{P}\\right)  _{P\\in N}=\\left(  Q\\right)  _{P\\in N}$. Thus,%\r\n\\begin{equation}\r\nb_{P}=Q\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }P\\in N.\r\n\\label{pf.prop.F.gW.example1.d.bP=}%\r\n\\end{equation}\r\nWe now must prove that the assertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$,\r\n$\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$,\r\nand $\\mathcal{G}_{2}$ of Theorem \\ref{thm.F.gW} are satisfied for this family.\r\n\r\nWe shall first show that Assertion $\\mathcal{C}_{1}$ is satisfied:\r\n\r\n\\textit{Proof of Assertion }$\\mathcal{C}_{1}$\\textit{:} Let $P\\in N$ and\r\n$\\pi\\in\\operatorname*{PF}P$. We must prove that $\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  \\equiv b_{P}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}A$.\r\n\r\nWe have $\\pi\\in\\operatorname*{PF}P$, thus $P/\\pi\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $. The polynomial $P/\\pi$ is monic (since $P$ and $\\pi$ are monic),\r\nand thus belongs to $\\mathbb{F}_{q}\\left[  T\\right]  _{+}=N$. Hence, the\r\nequality (\\ref{pf.prop.F.gW.example1.b.bP=}) (applied to $P/\\pi$ instead of\r\n$P$) yields $b_{P/\\pi}=Q$. But $\\varphi_{\\pi}=\\operatorname*{id}$ (by the\r\ndefinition of $\\varphi_{\\pi}$), and thus%\r\n\\begin{equation}\r\n\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  =\\operatorname*{id}\\left(  b_{P/\\pi\r\n}\\right)  =b_{P/\\pi}=Q. \\label{pf.prop.F.gW.example1.d.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, (\\ref{pf.prop.F.gW.example1.b.bP=}) becomes $b_{P}=Q=\\varphi_{\\pi}\\left(\r\nb_{P/\\pi}\\right)  $ (by (\\ref{pf.prop.F.gW.example1.d.1})). Hence,%\r\n\\[\r\nb_{P}\\equiv\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  \\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }A.\r\n\\]\r\nIn other words, $\\varphi_{\\pi}\\left(  b_{P/\\pi}\\right)  \\equiv b_{P}%\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }A$. Thus, Assertion\r\n$\\mathcal{C}_{1}$ is proven.\r\n\r\nWe now have shown that Assertion $\\mathcal{C}_{1}$ is satisfied. Thus, all the\r\nassertions $\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$, $\\mathcal{D}_{2}$,\r\n$\\mathcal{E}_{1}$, $\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$, and $\\mathcal{G}_{2}$\r\nof Theorem \\ref{thm.F.gW} are satisfied (since Theorem \\ref{thm.F.gW} says\r\nthat these assertions are equivalent). This proves Proposition\r\n\\ref{prop.F.gW.example1} \\textbf{(d)}.\r\n\\end{proof}\r\n\r\nSpelling out the claims of Theorem \\ref{thm.F.gW} in basic terms provides a\r\nplethora of congruences between polynomials in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. We will not list of all them, but only give one example,\r\nconjectured by the math.stackexchange user \\textquotedblleft\r\nLevent\\textquotedblright\\ in \\cite{levent}:\r\n\r\n\\begin{corollary}\r\n\\label{cor.F.gW.example1.levent}Let $Q\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\nThen,%\r\n\\[\r\nP\\mid\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }P\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}.\r\n\\]\r\n\r\n\\end{corollary}\r\n\r\n\\begin{proof}\r\n[First proof of Corollary \\ref{cor.F.gW.example1.levent}.]Define $N$, $A$ and\r\n$\\varphi_{P}$ (for all $P\\in N$) as in Proposition \\ref{prop.F.gW.example1}.\r\nDefine a family $\\left(  b_{P}\\right)  _{P\\in N}\\in A^{N}$ by $\\left(\r\nb_{P}\\right)  _{P\\in N}=\\left(  F^{\\deg P}Q\\right)  _{P\\in N}$. Then, every\r\n$P\\in N$ satisfies%\r\n\\begin{equation}\r\nb_{P}=F^{\\deg P}Q=F^{\\deg P}\\cdot Q=Q^{q^{\\deg P}}\r\n\\label{pf.cor.F.gW.example1.levent.bP=1}%\r\n\\end{equation}\r\n(by (\\ref{eq.prop.F.acts-on-commalg.Fk.eq}), applied to $k=\\deg P$ and $m=Q$).\r\n\r\nProposition \\ref{prop.F.gW.example1} \\textbf{(b)} shows that the assertions\r\n$\\mathcal{C}_{1}$, $\\mathcal{D}_{1}$, $\\mathcal{D}_{2}$, $\\mathcal{E}_{1}$,\r\n$\\mathcal{F}_{1}$, $\\mathcal{G}_{1}$, and $\\mathcal{G}_{2}$ of Theorem\r\n\\ref{thm.F.gW} are satisfied for this family $\\left(  b_{P}\\right)  _{P\\in\r\nN}=\\left(  F^{\\deg P}Q\\right)  _{P\\in N}$. In particular, Assertion\r\n$\\mathcal{G}_{2}$ is satisfied. In other words, every $P\\in N$ satisfies%\r\n\\begin{equation}\r\n\\sum_{D\\mid P}\\varphi\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in\r\nPA. \\label{pf.cor.F.gW.example1.levent.2}%\r\n\\end{equation}\r\n\r\n\r\nNow, let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Thus, $P\\in\\mathbb{F}%\r\n_{q}\\left[  T\\right]  _{+}=N$ (since $N$ was defined to be $\\mathbb{F}%\r\n_{q}\\left[  T\\right]  _{+}$).\r\n\r\nBut the polynomial $P$ is monic. Hence, the map%\r\n\\begin{align*}\r\n\\left(  \\text{the set of all monic divisors of }P\\right)   &  \\rightarrow\r\n\\left(  \\text{the set of all monic divisors of }P\\right)  ,\\\\\r\nD  &  \\mapsto P/D\r\n\\end{align*}\r\nis well-defined and a bijection (actually, it is an involution). Thus, we can\r\nsubstitute $P/D$ for $D$ in the sum $\\sum_{D\\mid P}\\varphi\\left(  D\\right)\r\n\\varphi_{D}\\left(  b_{P/D}\\right)  $. We thus obtain%\r\n\\begin{align*}\r\n&  \\sum_{D\\mid P}\\varphi\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right) \\\\\r\n&  =\\sum_{D\\mid P}\\varphi\\left(  \\underbrace{P/D}_{=\\dfrac{P}{D}}\\right)\r\n\\underbrace{\\varphi_{P/D}}_{\\substack{=\\operatorname*{id}\\\\\\text{(by the\r\ndefinition of }\\varphi_{P/D}\\text{)}}}\\left(  \\underbrace{b_{P/\\left(\r\nP/D\\right)  }}_{\\substack{=b_{D}=Q^{q^{\\deg D}}\\\\\\text{(by\r\n(\\ref{pf.cor.F.gW.example1.levent.bP=1}), applied}\\\\\\text{to }D\\text{ instead\r\nof }P\\text{)}}}\\right) \\\\\r\n&  =\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)\r\n\\underbrace{\\operatorname*{id}\\left(  Q^{q^{\\deg D}}\\right)  }_{=Q^{q^{\\deg\r\nD}}}=\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}.\r\n\\end{align*}\r\nHence,%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}=\\sum_{D\\mid\r\nP}\\varphi\\left(  D\\right)  \\varphi_{D}\\left(  b_{P/D}\\right)  \\in PA\r\n\\]\r\n(by (\\ref{pf.cor.F.gW.example1.levent.2})). In other words, $P\\mid\\sum_{D\\mid\r\nP}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}$. This proves Corollary\r\n\\ref{cor.F.gW.example1.levent}.\r\n\\end{proof}\r\n\r\nThis said, it is not much harder to prove Corollary\r\n\\ref{cor.F.gW.example1.levent} without any reference to Theorem \\ref{thm.F.gW}%\r\n, using just the results of Subsection \\ref{subsect.proofs.numthefuns}:\r\n\r\n\\begin{proof}\r\n[Second proof of Corollary \\ref{cor.F.gW.example1.levent}.]Let\r\n$\\operatorname*{Frob}$ denote the Frobenius endomorphism of the $\\mathbb{F}%\r\n_{q}$-algebra $\\mathbb{F}_{q}\\left[  T\\right]  $. This is the map\r\n$\\mathbb{F}_{q}\\left[  T\\right]  \\rightarrow\\mathbb{F}_{q}\\left[  T\\right]  $\r\nthat sends each $P\\in\\mathbb{F}_{q}\\left[  T\\right]  $ to $P^{q}$. It is\r\nwell-known that $\\operatorname*{Frob}$ is an $\\mathbb{F}_{q}$-algebra\r\nendomorphism of $\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nWe make a few auxiliary observations:\r\n\r\n\\begin{statement}\r\n\\textit{Observation 1:} Let $u\\in\\mathbb{N}$, $a\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ and $b\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then, $a^{q^{u}%\r\n}-b^{q^{u}}=\\left(  a-b\\right)  ^{q^{u}}$.\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 1:} We have%\r\n\\begin{equation}\r\n\\operatorname*{Frob}\\nolimits^{k}c=c^{q^{k}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }k\\in\\mathbb{N}\\text{ and }c\\in\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\label{pf.cor.F.gW.example1.levent.2nd.ob1.pf.1}%\r\n\\end{equation}\r\n(Indeed, this is easy to prove by induction over $k$, using the definition of\r\n$\\operatorname*{Frob}$.)\r\n\r\nNow, recall that $\\operatorname*{Frob}$ is an $\\mathbb{F}_{q}$-algebra\r\nendomorphism of $\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, so is its $u$-th\r\npower $\\operatorname*{Frob}\\nolimits^{u}$. Thus,%\r\n\\[\r\n\\operatorname*{Frob}\\nolimits^{u}\\left(  a-b\\right)\r\n=\\underbrace{\\operatorname*{Frob}\\nolimits^{u}a}_{\\substack{=a^{q^{u}%\r\n}\\\\\\text{(by (\\ref{pf.cor.F.gW.example1.levent.2nd.ob1.pf.1}), applied to\r\n}c=a\\text{)}}}-\\underbrace{\\operatorname*{Frob}\\nolimits^{u}b}%\r\n_{\\substack{=b^{q^{u}}\\\\\\text{(by\r\n(\\ref{pf.cor.F.gW.example1.levent.2nd.ob1.pf.1}), applied to }c=b\\text{)}%\r\n}}=a^{q^{u}}-b^{q^{u}}.\r\n\\]\r\nThus,%\r\n\\[\r\na^{q^{u}}-b^{q^{u}}=\\operatorname*{Frob}\\nolimits^{u}\\left(  a-b\\right)\r\n=\\left(  a-b\\right)  ^{q^{u}}%\r\n\\]\r\n(by (\\ref{pf.cor.F.gW.example1.levent.2nd.ob1.pf.1}), applied to $c=a-b$).\r\nThis proves Observation 1.]\r\n\r\n\\begin{statement}\r\n\\textit{Observation 2:} Let $\\pi$ be a monic irreducible polynomial in\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $. Let $a$ and $b$ be two elements of\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $ such that $a\\equiv b\\operatorname{mod}%\r\n\\pi\\mathbb{F}_{q}\\left[  T\\right]  $. Let $N\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n$ be nonzero. Then, $a^{q^{\\deg N}}\\equiv b^{q^{\\deg N}}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  N\\right)  +1}\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 2:} We can regard Observation 2 as a particular\r\ncase of Corollary \\ref{cor.F.lift.lift-all} \\textbf{(a)} (applied to\r\n$A=\\mathbb{F}_{q}\\left[  T\\right]  $). But let us give a self-contained proof instead.\r\n\r\nWe have $a-b\\in\\pi\\mathbb{F}_{q}\\left[  T\\right]  $ (since $a\\equiv\r\nb\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  $). In other words,\r\n$a-b=\\pi c$ for some $c\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Consider this\r\n$c$. Now, define $u\\in\\mathbb{N}$ by $u=\\deg N$.\r\n\r\nBut every nonnegative integer $m$ satisfies $2^{m}\\geq m+1$ (this is easy to\r\nprove). Applying this to $m=u$, we find $2^{u}\\geq u+1$. But $\\pi^{v_{\\pi\r\n}\\left(  N\\right)  }\\mid N$ and thus $\\deg\\left(  \\pi^{v_{\\pi}\\left(\r\nN\\right)  }\\right)  \\leq\\deg N=u$. Hence, $u\\geq\\deg\\left(  \\pi^{v_{\\pi\r\n}\\left(  N\\right)  }\\right)  =v_{\\pi}\\left(  N\\right)  \\underbrace{\\deg\\pi\r\n}_{\\geq1}\\geq v_{\\pi}\\left(  N\\right)  $. But $q\\geq2$ and thus $q^{u}%\r\n\\geq2^{u}\\geq\\underbrace{u}_{\\geq v_{\\pi}\\left(  N\\right)  }+1\\geq v_{\\pi\r\n}\\left(  N\\right)  +1$.\r\n\r\nBut Observation 1 yields $a^{q^{u}}-b^{q^{u}}=\\left(  \\underbrace{a-b}_{=\\pi\r\nc}\\right)  ^{q^{u}}=\\left(  \\pi c\\right)  ^{q^{u}}=\\pi^{q^{u}}c^{q^{u}}$.\r\nHence, $\\pi^{q^{u}}\\mid a^{q^{u}}-b^{q^{u}}$ in $\\mathbb{F}_{q}\\left[\r\nT\\right]  $. But $q^{u}\\geq v_{\\pi}\\left(  N\\right)  +1$, and thus\r\n$\\pi^{v_{\\pi}\\left(  N\\right)  +1}\\mid\\pi^{q^{u}}\\mid a^{q^{u}}-b^{q^{u}}$. In\r\nother words, $a^{q^{u}}\\equiv b^{q^{u}}\\operatorname{mod}\\pi^{v_{\\pi}\\left(\r\nN\\right)  +1}\\mathbb{F}_{q}\\left[  T\\right]  $. Since $u=\\deg N$, this\r\nrewrites as $a^{q^{\\deg N}}\\equiv b^{q^{\\deg N}}\\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  N\\right)  +1}\\mathbb{F}_{q}\\left[  T\\right]  $. Thus, Observation 2\r\nis proven.]\r\n\r\nNext, fix $P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Let $\\mathbf{S}$ be the\r\nset of all squarefree monic divisors of $P$.\r\n\r\n\\begin{statement}\r\n\\textit{Observation 3:} We have%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}=\\sum\r\n_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}.\r\n\\]\r\n\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 3:} Let $\\mathbf{D}$ be the set of all monic\r\ndivisors of $P$. Then, the map%\r\n\\[\r\n\\mathbf{D}\\rightarrow\\mathbf{D},\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ D\\mapsto P/D\r\n\\]\r\nis well-defined (since $P$ itself is monic) and invertible (since it is its\r\nown inverse). Thus, this map is a bijection. Hence, we can substitute $P/D$\r\nfor $D$ in the sum $\\sum_{D\\in\\mathbf{D}}\\varphi\\left(  \\dfrac{P}{D}\\right)\r\nQ^{q^{\\deg D}}$. We thus obtain\r\n\\begin{align*}\r\n&  \\sum_{D\\in\\mathbf{D}}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}\\\\\r\n&  =\\sum_{D\\in\\mathbf{D}}\\varphi\\left(  \\underbrace{\\dfrac{P}{P/D}}%\r\n_{=D}\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}=\\sum_{D\\in\\mathbf{D}%\r\n}\\underbrace{\\varphi\\left(  D\\right)  }_{\\substack{=\\mu\\left(  D\\right)\r\n\\text{ in }\\mathbb{F}_{q}\\\\\\text{(by Proposition \\ref{prop.phi-Q.formula}\r\n\\textbf{(d)}}\\\\\\text{(applied to }D\\text{ instead of }M\\text{))}}%\r\n}Q^{q^{\\deg\\left(  P/D\\right)  }}\\\\\r\n&  =\\underbrace{\\sum_{D\\in\\mathbf{D}}}_{\\substack{=\\sum_{\\substack{D\\mid\r\nP}}\\\\\\text{(since }\\mathbf{D}\\text{ is the set of all}\\\\\\text{monic divisors\r\nof }P\\text{)}}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}%\r\n=\\sum_{\\substack{D\\mid P}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)\r\n}}\\\\\r\n&  =\\underbrace{\\sum_{\\substack{D\\mid P;\\\\D\\text{ is squarefree}}%\r\n}}_{\\substack{=\\sum_{D\\in\\mathbf{S}}\\\\\\text{(since }\\mathbf{S}\\text{ is the\r\nset}\\\\\\text{of all squarefree}\\\\\\text{monic divisors of }P\\text{)}}}\\mu\\left(\r\nD\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}+\\sum_{\\substack{D\\mid P;\\\\D\\text{\r\nis not squarefree}}}\\underbrace{\\mu\\left(  D\\right)  }%\r\n_{\\substack{=0\\\\\\text{(by the definition}\\\\\\text{of }\\mu\\text{, since\r\n}D\\\\\\text{is not squarefree)}}}Q^{q^{\\deg\\left(  P/D\\right)  }}\\\\\r\n&  =\\sum_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }%\r\n}+\\underbrace{\\sum_{\\substack{D\\mid P;\\\\D\\text{ is not squarefree}%\r\n}}0Q^{q^{\\deg\\left(  P/D\\right)  }}}_{=0}=\\sum_{D\\in\\mathbf{S}}\\mu\\left(\r\nD\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}.\r\n\\end{align*}\r\nComparing this with%\r\n\\[\r\n\\underbrace{\\sum_{D\\in\\mathbf{D}}}_{\\substack{=\\sum_{D\\mid P}\\\\\\text{(since\r\n}\\mathbf{D}\\text{ is the set of all}\\\\\\text{monic divisors of }P\\text{)}%\r\n}}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}=\\sum_{D\\mid P}%\r\n\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}},\r\n\\]\r\nthis yields%\r\n\\[\r\n\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}=\\sum\r\n_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}.\r\n\\]\r\nThis proves Observation 3.]\r\n\r\n\\begin{statement}\r\n\\textit{Observation 4:} Let $P\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$. Let\r\n$\\pi\\in\\operatorname*{PF}P$. Let $D$ be a monic divisor of $P$ such that\r\n$\\pi\\nmid D$. Then,\r\n\\[\r\nQ^{q^{\\deg\\left(  P/D\\right)  }}\\equiv Q^{q^{\\deg\\left(  P/\\left(  \\pi\r\nD\\right)  \\right)  }}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 4:} Observe that $P/D\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  $ (since $D$ is a divisor of $P$). Also, $\\pi\\nmid D$ and thus\r\n$v_{\\pi}\\left(  D\\right)  =0$. But $\\pi\\in\\operatorname*{PF}P$, so that\r\n$\\pi\\mid P$ and thus $v_{\\pi}\\left(  P\\right)  >0$. Now, $v_{\\pi}\\left(\r\nP/D\\right)  =v_{\\pi}\\left(  P\\right)  -\\underbrace{v_{\\pi}\\left(  D\\right)\r\n}_{=0}=v_{\\pi}\\left(  P\\right)  >0$. In other words, $\\pi\\mid P/D$. Hence,\r\n$\\left(  P/D\\right)  /\\pi\\in\\mathbb{F}_{q}\\left[  T\\right]  $.\r\n\r\nSet $d=\\deg\\pi$. Lemma \\ref{lem.F.gW.example1.lem.dumbed-down} (applied to $Q$\r\ninstead of $P$) yields%\r\n\\[\r\nQ^{q^{d}}\\equiv Q\\operatorname{mod}\\pi\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nHence, Observation 2 (applied to $a=Q^{q^{d}}$, $b=Q$ and $N=\\left(\r\nP/D\\right)  /\\pi$) yields\r\n\\[\r\n\\left(  Q^{q^{d}}\\right)  ^{q^{\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)  }%\r\n}\\equiv Q^{q^{\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)  }}%\r\n\\operatorname{mod}\\pi^{v_{\\pi}\\left(  \\left(  P/D\\right)  /\\pi\\right)\r\n+1}\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nSince%\r\n\\begin{align*}\r\n\\left(  Q^{q^{d}}\\right)  ^{q^{\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)\r\n}}  &  =Q^{q^{d}q^{\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)  }%\r\n}=Q^{q^{d+\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)  }}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }q^{d}q^{\\deg\\left(  \\left(\r\nP/D\\right)  /\\pi\\right)  }=q^{d+\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)\r\n}\\right)\r\n\\end{align*}\r\nand%\r\n\\[\r\n\\underbrace{v_{\\pi}\\left(  \\left(  P/D\\right)  /\\pi\\right)  }_{=v_{\\pi}\\left(\r\nP/D\\right)  -v_{\\pi}\\left(  \\pi\\right)  }+1=\\underbrace{v_{\\pi}\\left(\r\nP/D\\right)  }_{=v_{\\pi}\\left(  P\\right)  }-\\underbrace{v_{\\pi}\\left(\r\n\\pi\\right)  }_{=1}+1=v_{\\pi}\\left(  P\\right)  -1+1=v_{\\pi}\\left(  P\\right)  ,\r\n\\]\r\nthis rewrites as%\r\n\\[\r\nQ^{q^{d+\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)  }}\\equiv Q^{q^{\\deg\r\n\\left(  \\left(  P/D\\right)  /\\pi\\right)  }}\\operatorname{mod}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nSince%\r\n\\begin{align*}\r\n\\underbrace{d}_{=\\deg\\pi}+\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right)   &\r\n=\\deg\\pi+\\deg\\left(  \\left(  P/D\\right)  /\\pi\\right) \\\\\r\n&  =\\deg\\left(  \\underbrace{\\pi\\cdot\\left(  \\left(  P/D\\right)  /\\pi\\right)\r\n}_{=P/D}\\right)  =\\deg\\left(  P/D\\right)\r\n\\end{align*}\r\nand%\r\n\\[\r\n\\deg\\left(  \\underbrace{\\left(  P/D\\right)  /\\pi}_{=P/\\left(  \\pi D\\right)\r\n}\\right)  =\\deg\\left(  P/\\left(  \\pi D\\right)  \\right)  ,\r\n\\]\r\nthis rewrites as\r\n\\[\r\nQ^{q^{\\deg\\left(  P/D\\right)  }}\\equiv Q^{q^{\\deg\\left(  P/\\left(  \\pi\r\nD\\right)  \\right)  }}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)\r\n}\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nThis proves Observation 4.]\r\n\r\nRecall that $\\mathbf{S}$ is the set of all squarefree monic divisors of $P$.\r\nEach of these squarefree monic divisors has the form $\\prod_{\\eta\\in I}\\eta$\r\nfor some subset $I$ of $\\operatorname*{PF}P$. More precisely, the map%\r\n\\begin{align}\r\n\\left\\{  I\\subseteq\\operatorname*{PF}P\\right\\}   &  \\rightarrow\\mathbf{S}%\r\n,\\nonumber\\\\\r\nI  &  \\mapsto\\prod_{\\eta\\in I}\\eta\\label{pf.cor.F.gW.example1.levent.2nd.bij}%\r\n\\end{align}\r\nis a bijection. Moreover, every subset $I$ of $\\operatorname*{PF}P$ satisfies\r\n\\begin{align}\r\n\\mu\\left(  \\prod_{\\eta\\in I}\\eta\\right)   &  =\\left(  -1\\right)  ^{\\left\\vert\r\n\\operatorname*{PF}\\left(  \\prod_{\\eta\\in I}\\eta\\right)  \\right\\vert\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\prod_{\\eta\\in I}\\eta\\text{ is\r\nsquarefree}\\right) \\nonumber\\\\\r\n&  =\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert }\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\operatorname*{PF}\\left(  \\prod_{\\eta\\in I}\\eta\\right)\r\n=I\\right)  . \\label{pf.cor.F.gW.example1.levent.2nd.2}%\r\n\\end{align}\r\n\r\n\r\nNow, we claim the following:\r\n\r\n\\begin{statement}\r\n\\textit{Observation 5:} Let $\\pi\\in\\operatorname*{PF}P$. Let $I\\subseteq\r\n\\operatorname*{PF}P$ be such that $\\pi\\notin I$. Then,\r\n\\[\r\nQ^{q^{\\deg\\left(  P/\\prod_{\\eta\\in I}\\eta\\right)  }}\\equiv Q^{q^{\\deg\\left(\r\nP/\\left(  \\prod_{\\eta\\in I\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  \\right)  }%\r\n}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 5:} From $\\pi\\notin I$, we obtain%\r\n\\begin{equation}\r\n\\prod_{\\eta\\in I\\cup\\left\\{  \\pi\\right\\}  }\\eta=\\pi\\prod_{\\eta\\in I}\\eta.\r\n\\label{pf.cor.F.gW.example1.levent.2nd.ob5.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nWe have $I\\subseteq\\operatorname*{PF}P$. Thus, the elements of $I$ are monic\r\nirreducible divisors of $P$. In particular, the elements of $I$ are monic\r\nirreducible polynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $. These monic\r\nirreducible polynomials are all distinct from $\\pi$ (since $\\pi\\notin I$), and\r\ntherefore coprime to $\\pi$ (since $\\pi$ is irreducible). Hence, the elements\r\nof $I$ are polynomials coprime to $\\pi$. Therefore, $\\prod_{\\eta\\in I}\\eta$ is\r\na product of polynomials coprime to $\\pi$. Thus, $\\prod_{\\eta\\in I}\\eta$\r\nitself is coprime to $\\pi$. Consequently, $\\pi\\nmid\\prod_{\\eta\\in I}\\eta$.\r\n\r\nBut $\\prod_{\\eta\\in I}\\eta\\in\\mathbf{S}$ (since $\\prod_{\\eta\\in I}\\eta$ is the\r\nimage of $I$ under the bijection (\\ref{pf.cor.F.gW.example1.levent.2nd.bij})).\r\nIn other words, $\\prod_{\\eta\\in I}\\eta$ is a squarefree monic divisor of $P$.\r\nHence, Observation 4 (applied to $D=\\prod_{\\eta\\in I}\\eta$) yields\r\n\\[\r\nQ^{q^{\\deg\\left(  P/\\prod_{\\eta\\in I}\\eta\\right)  }}\\equiv Q^{q^{\\deg\\left(\r\nP/\\left(  \\pi\\prod_{\\eta\\in I}\\eta\\right)  \\right)  }}\\operatorname{mod}%\r\n\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[  T\\right]  .\r\n\\]\r\nIn view of (\\ref{pf.cor.F.gW.example1.levent.2nd.ob5.pf.1}), this rewrites as%\r\n\\[\r\nQ^{q^{\\deg\\left(  P/\\prod_{\\eta\\in I}\\eta\\right)  }}\\equiv Q^{q^{\\deg\\left(\r\nP/\\left(  \\prod_{\\eta\\in I\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  \\right)  }%\r\n}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  .\r\n\\]\r\nThis proves Observation 5.]\r\n\r\n\\begin{statement}\r\n\\textit{Observation 6:} Let $\\pi\\in\\operatorname*{PF}P$. Then,\r\n\\[\r\n\\sum_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }%\r\n}\\equiv0\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  .\r\n\\]\r\n\r\n\\end{statement}\r\n\r\n[\\textit{Proof of Observation 6:} Recall that\r\n(\\ref{pf.cor.F.gW.example1.levent.2nd.bij}) is a bijection. Thus, we can\r\nsubstitute $\\prod_{\\eta\\in I}\\eta$ for $D$ in the sum $\\sum_{D\\in\\mathbf{S}%\r\n}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }}$. Thus, we obtain%\r\n\\begin{align}\r\n&  \\sum_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }%\r\n}\\nonumber\\\\\r\n&  =\\sum_{I\\subseteq\\operatorname*{PF}P}\\underbrace{\\mu\\left(  \\prod_{\\eta\\in\r\nI}\\eta\\right)  }_{\\substack{=\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert\r\n}\\\\\\text{(by (\\ref{pf.cor.F.gW.example1.levent.2nd.2}))}}}Q^{q^{\\deg\\left(\r\nP/\\prod_{\\eta\\in I}\\eta\\right)  }}=\\sum_{I\\subseteq\\operatorname*{PF}P}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in\r\nI}\\eta\\right)  }}\\nonumber\\\\\r\n&  =\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\in I}}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in\r\nI}\\eta\\right)  }}+\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin\r\nI}}\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(\r\nP/\\prod_{\\eta\\in I}\\eta\\right)  }}\r\n\\label{pf.cor.F.gW.example1.levent.2nd.obs6.pf.1}%\r\n\\end{align}\r\n(since every $I\\subseteq\\operatorname*{PF}P$ satisfies either $\\pi\\in I$ or\r\n$\\pi\\notin I$ (but not both)).\r\n\r\nBut we have $\\pi\\in\\operatorname*{PF}P$. Hence, the map%\r\n\\begin{align*}\r\n\\left\\{  I\\subseteq\\operatorname*{PF}P\\ \\mid\\ \\pi\\notin I\\right\\}   &\r\n\\rightarrow\\left\\{  I\\subseteq\\operatorname*{PF}P\\ \\mid\\ \\pi\\in I\\right\\}  ,\\\\\r\nJ  &  \\mapsto J\\cup\\left\\{  \\pi\\right\\}\r\n\\end{align*}\r\nis well-defined and a bijection\\footnote{This is a particular case (obtained\r\nby setting $G=\\operatorname*{PF}P$ and $g=\\pi$) of the following fact:\r\n\\par\r\nLet $G$ be a set. Let $g\\in G$. Then, the map%\r\n\\begin{align*}\r\n\\left\\{  I\\subseteq G\\ \\mid\\ g\\notin I\\right\\}   &  \\rightarrow\\left\\{\r\nI\\subseteq G\\ \\mid\\ g\\in I\\right\\}  ,\\\\\r\nJ  &  \\mapsto J\\cup\\left\\{  g\\right\\}\r\n\\end{align*}\r\nis well-defined and a bijection. (Its inverse is the map\r\n\\begin{align*}\r\n\\left\\{  I\\subseteq G\\ \\mid\\ g\\in I\\right\\}   &  \\rightarrow\\left\\{\r\nI\\subseteq G\\ \\mid\\ g\\notin I\\right\\}  ,\\\\\r\nJ  &  \\mapsto J\\setminus\\left\\{  g\\right\\}  .\r\n\\end{align*}\r\nThis is all straightforward to check.)}. Hence, we can substitute\r\n$J\\cup\\left\\{  \\pi\\right\\}  $ for $I$ in the sum $\\sum_{\\substack{I\\subseteq\r\n\\operatorname*{PF}P;\\\\\\pi\\in I}}\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert\r\n}Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in I}\\eta\\right)  }}$. We thus obtain%\r\n\\begin{align}\r\n&  \\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\in I}}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in\r\nI}\\eta\\right)  }}\\nonumber\\\\\r\n&  =\\sum_{\\substack{J\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin J}%\r\n}\\underbrace{\\left(  -1\\right)  ^{\\left\\vert J\\cup\\left\\{  \\pi\\right\\}\r\n\\right\\vert }}_{\\substack{=-\\left(  -1\\right)  ^{\\left\\vert J\\right\\vert\r\n}\\\\\\text{(since }\\left\\vert J\\cup\\left\\{  \\pi\\right\\}  \\right\\vert =\\left\\vert\r\nJ\\right\\vert +1\\\\\\text{(since }\\pi\\notin J\\text{))}}}Q^{q^{\\deg\\left(\r\nP/\\prod_{\\eta\\in J\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  }}=-\\sum\r\n_{\\substack{J\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin J}}\\left(  -1\\right)\r\n^{\\left\\vert J\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in J\\cup\\left\\{\r\n\\pi\\right\\}  }\\eta\\right)  }}\\nonumber\\\\\r\n&  =-\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin I}}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in\r\nI\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  }}\r\n\\label{pf.cor.F.gW.example1.levent.2nd.obs6.pf.3}%\r\n\\end{align}\r\n(here, we have renamed the summation index $J$ as $I$).\r\n\r\nNow, (\\ref{pf.cor.F.gW.example1.levent.2nd.obs6.pf.1}) becomes%\r\n\\begin{align*}\r\n&  \\sum_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }%\r\n}\\\\\r\n&  =\\underbrace{\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\in\r\nI}}\\left(  -1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(\r\nP/\\prod_{\\eta\\in I}\\eta\\right)  }}}_{\\substack{=-\\sum_{\\substack{I\\subseteq\r\n\\operatorname*{PF}P;\\\\\\pi\\notin I}}\\left(  -1\\right)  ^{\\left\\vert\r\nI\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in I\\cup\\left\\{  \\pi\\right\\}\r\n}\\eta\\right)  }}\\\\\\text{(by (\\ref{pf.cor.F.gW.example1.levent.2nd.obs6.pf.3}%\r\n))}}}+\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin I}}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }\\underbrace{Q^{q^{\\deg\\left(\r\nP/\\prod_{\\eta\\in I}\\eta\\right)  }}}_{\\substack{\\equiv Q^{q^{\\deg\\left(\r\nP/\\left(  \\prod_{\\eta\\in I\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  \\right)  }%\r\n}\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  \\\\\\text{(by Observation 5)}}}\\\\\r\n&  \\equiv-\\sum_{\\substack{I\\subseteq\\operatorname*{PF}P;\\\\\\pi\\notin I}}\\left(\r\n-1\\right)  ^{\\left\\vert I\\right\\vert }Q^{q^{\\deg\\left(  P/\\prod_{\\eta\\in\r\nI\\cup\\left\\{  \\pi\\right\\}  }\\eta\\right)  }}+\\sum_{\\substack{I\\subseteq\r\n\\operatorname*{PF}P;\\\\\\pi\\notin I}}\\left(  -1\\right)  ^{\\left\\vert\r\nI\\right\\vert }Q^{q^{\\deg\\left(  P/\\left(  \\prod_{\\eta\\in I\\cup\\left\\{\r\n\\pi\\right\\}  }\\eta\\right)  \\right)  }}\\\\\r\n&  =0\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}_{q}\\left[\r\nT\\right]  .\r\n\\end{align*}\r\nThus, Observation 6 is proven.]\r\n\r\nRecall that $P$ is a monic polynomial. Hence, $\\prod_{\\pi\\in\\operatorname*{PF}%\r\nP}\\pi^{v_{\\pi}\\left(  P\\right)  }$ is the factorization of $P$ into monic\r\nirreducible factors. Thus, $\\prod_{\\pi\\in\\operatorname*{PF}P}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }=P$.\r\n\r\nBut the polynomials $\\pi^{v_{\\pi}\\left(  P\\right)  }$ for distinct $\\pi\r\n\\in\\operatorname*{PF}P$ are mutually coprime. Hence, their least common\r\nmultiple is their product. In other words, the least common multiple of the\r\npolynomials $\\pi^{v_{\\pi}\\left(  P\\right)  }$ (where $\\pi$ ranges over\r\n$\\operatorname*{PF}P$) is $\\prod_{\\pi\\in\\operatorname*{PF}P}\\pi^{v_{\\pi\r\n}\\left(  P\\right)  }=P$.\r\n\r\nNow, define a polynomial $Z\\in\\mathbb{F}_{q}\\left[  T\\right]  $ by%\r\n\\[\r\nZ=\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}.\r\n\\]\r\nThen, for every $\\pi\\in\\operatorname*{PF}P$, we have%\r\n\\begin{align*}\r\nZ  &  =\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}%\r\n=\\sum_{D\\in\\mathbf{S}}\\mu\\left(  D\\right)  Q^{q^{\\deg\\left(  P/D\\right)  }%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Observation 3}\\right) \\\\\r\n&  \\equiv0\\operatorname{mod}\\pi^{v_{\\pi}\\left(  P\\right)  }\\mathbb{F}%\r\n_{q}\\left[  T\\right]  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Observation\r\n6}\\right)  ,\r\n\\end{align*}\r\nand thus $\\pi^{v_{\\pi}\\left(  P\\right)  }\\mid Z$. Therefore, the least common\r\nmultiple of the polynomials $\\pi^{v_{\\pi}\\left(  P\\right)  }$ (where $\\pi$\r\nranges over $\\operatorname*{PF}P$) divides $Z$. In other words, $P$ divides\r\n$Z$ (since the least common multiple of the polynomials $\\pi^{v_{\\pi}\\left(\r\nP\\right)  }$ (where $\\pi$ ranges over $\\operatorname*{PF}P$) is $P$). Thus,%\r\n\\[\r\nP\\mid Z=\\sum_{D\\mid P}\\varphi\\left(  \\dfrac{P}{D}\\right)  Q^{q^{\\deg D}}.\r\n\\]\r\nThis proves Corollary \\ref{cor.F.gW.example1.levent} again.\r\n\\end{proof}\r\n\r\n\\subsection{(More sections to be added here!)}\r\n\r\n[...]\r\n\r\nXTODO: Conclude torsionfreeness in two ways.\r\n\r\nXTODO: polynomial ring example.\r\n\r\n[...]\r\n\r\n\\section{\\label{sect.tinfoil}Speculations}\r\n\r\n\\subsection{So what is $\\Lambda_{\\operatorname*{Carl}}$ ?}\r\n\r\nSo what is the Carlitz analogue of the ring of symmetric functions?\r\n\r\nI'm still groping in the dark here. But at least I'm seeing some hints of why\r\nthis isn't as simple as in the classical case (although I guess the theory of\r\nsymmetric functions can only be called ``simple'' with the wisdom of hindsight\r\nanyway). After Subsection \\ref{subsect.F} it appears to me that the\r\nmultiplication isn't crucial to the functor $W_{N}$, but rather an extra\r\nstructure that gets carried along (whatever this means).\\footnote{What about\r\nLie algebras? What properties should a Lie algebra structure on an\r\n$\\mathcal{F}$-module $A$ satisfy so that $W_{N}\\left(  A\\right)  $ also is a\r\nLie algebra? Will $W_{N}\\left(  A\\right)  $ then also share these properties?}\r\nThis suggests that I shouldn't be looking at the representing object of the\r\nfunctor $W_{N}:\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  }%\r\n\\rightarrow\\mathbf{CRing}_{\\mathbb{F}_{q}\\left[  T\\right]  }$, but at the\r\nrepresenting object of the functor $W_{N}:\\left.  _{\\mathcal{F}}%\r\n\\mathbf{Mod}\\right.  \\rightarrow\\left.  _{\\mathcal{F}}\\mathbf{Mod}\\right.  $,\r\nor at least that the latter is more fundamental than the former. To begin\r\nwith, it's smaller.\r\n\r\nA representing object of a functor $\\left.  _{\\mathcal{F}}\\mathbf{Mod}\\right.\r\n\\rightarrow\\left.  _{\\mathcal{F}}\\mathbf{Mod}\\right.  $ is the same as an\r\n$\\mathcal{F}$-$\\mathcal{F}$-bimodule\\footnote{This is a particular case of the\r\nfollowing general fact: If $A$ and $B$ are two algebras, then any $A$%\r\n-$B$-bimodule $M$ gives rise to a representable functor $\\operatorname*{Hom}%\r\n\\nolimits_{_{A}\\mathbf{Mod}}\\left(  _{A}M,-\\right)  :\\left.  _{A}%\r\n\\mathbf{Mod}\\right.  \\rightarrow\\left.  _{B}\\mathbf{Mod}\\right.  $.}. The\r\n$\\mathcal{F}$-$\\mathcal{F}$-bimodule which represents the functor\r\n$W_{N}:\\left.  _{\\mathcal{F}}\\mathbf{Mod}\\right.  \\rightarrow\\left.\r\n_{\\mathcal{F}}\\mathbf{Mod}\\right.  $ is the free left $\\mathcal{F}$-module\r\n$\\Lambda_{\\mathcal{F}}$ with basis $\\left(  x_{P}\\right)  _{P\\in N}$, and with\r\nright $\\mathcal{F}$-module structure defined as follows: Let $p_{P}%\r\n=\\sum\\limits_{D\\mid P}D\\left[  \\dfrac{P}{D}\\right]  \\left(  x_{D}\\right)  $\r\nfor every $P\\in N$. (The intuition is that $x_{P}$ are analogues of the\r\n\\textquotedblleft Witt vector coordinates\\textquotedblright\\ of $\\Lambda\r\n$\\ \\ \\ \\ \\footnote{These are the symmetric functions $w_{n}$ in \\cite[Exercise\r\n2.9.3]{reiner-hopf}. Their name stems from their relation to the Witt vectors;\r\nfrom a combinatorial viewpoint, they are a rather exotic family.} and $p_{P}$\r\nare \\textquotedblleft power sum symmetric functions\\textquotedblright.) Then,\r\nset $p_{P}f=fp_{P}$ for every $P\\in N$ and $f\\in\\mathcal{F}$. This uniquely\r\ndetermines a right $\\mathcal{F}$-module structure (since it has to commute\r\nwith the left one), although its existence is not really obvious. Thus\r\n$\\Lambda_{\\mathcal{F}}$ is defined.\r\n\r\nWhen $N$ is the whole set $\\mathbb{F}_{q}\\left[  T\\right]  _{+}$, the\r\n$\\mathcal{F}$-$\\mathcal{F}$-bimodule $\\Lambda_{\\mathcal{F}}$ has some claims\r\nto be the Carlitz analogue of the ring of symmetric functions, although it is\r\nan $\\mathcal{F}$-$\\mathcal{F}$-bimodule rather than a ring. Nevertheless, I\r\ndon't feel able to realize it as an actual set of symmetric power series. The\r\nCarlitz structure is way too additive for that. In some sense, what made the\r\npower sums algebraically independent over the integers was the fact that\r\n$\\left(  x+y\\right)  ^{2}\\neq x^{2}+y^{2}$ etc.; but in the Carlitz case,\r\n$\\left[  P\\right]  $ is additive and even $\\mathbb{F}_{q}$-linear for every\r\n$P\\in\\mathbb{F}_{q}\\left[  T\\right]  $, so that if we would define the\r\n``$P$-th power sum polynomial'' in some variables $\\xi_{i}$ to mean\r\n$\\sum\\limits_{i}\\left[  P\\right]  \\left(  \\xi_{i}\\right)  $, then all these\r\npolynomials would be linearly dependent over $\\mathcal{F}$ simply because\r\n$\\sum\\limits_{i}\\left[  P\\right]  \\left(  \\xi_{i}\\right)  =\\left[  P\\right]\r\n\\left(  \\sum\\limits_{i}\\xi_{i}\\right)  =\\left(  \\operatorname*{Carl}\\left(\r\nP\\right)  \\right)  \\left(  \\sum\\limits_{i}\\xi_{i}\\right)  $.\r\n\r\nThe absence of multiplicative structure makes it hard to even guess what\r\n``elementary symmetric functions'' or ``complete homogeneous symmetric\r\nfunctions'' would be in the Carlitz situation. But Carlitz exponential and\r\nCarlitz logarithm are well-defined on every left $\\mathcal{F}$-module on which\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $ acts invertibly (i. e., whose\r\n$\\mathbb{F}_{q}\\left[  T\\right]  $-module structure extends to an\r\n$\\mathbb{F}_{q}\\left(  T\\right)  $-module structure) and which has appropriate\r\nclosure properties. We might try to use them to construct the ``elementary\r\nsymmetric functions'' by some analogue of the classical $\\sum\\limits_{n\\in\r\n\\mathbb{N}}\\left(  -1\\right)  ^{n}e_{n}T^{n}=\\exp\\left(  -\\sum\\limits_{n\\geq\r\n1}\\dfrac{1}{n}p_{n}T^{n}\\right)  $ formula from the theory of symmetric\r\nfunctions.\\footnote{Another suggestion by James Borger.} The problem is that\r\nthis is an identity in power series, and we would first have to find out what\r\nthe right analogue of power series is in this context.\r\n\r\nThere is other stuff to do as well. One can look for explicit formulas for the\r\nright $\\mathcal{F}$-action on the $x_{P}$ in $\\Lambda_{\\mathcal{F}}$. And one\r\ncan try to define the analogue of plethysm (which, as far as I understand,\r\nshould be an $\\mathcal{F}$-$\\mathcal{F}$-bilinear map from $\\Lambda\r\n_{\\mathcal{F}}\\otimes_{\\mathcal{F}}\\Lambda_{\\mathcal{F}}$ to $\\Lambda\r\n_{\\mathcal{F}}$ making $\\Lambda_{\\mathcal{F}}$ into what would be an\r\n$\\mathcal{F}$-algebra if it were commutative?).\r\n\r\n\\subsection{Some computations in $\\Lambda_{\\mathcal{F}}$}\r\n\r\nLet me see if I'm able to get something concrete out of the above reveries.\r\nHow about computing the right $\\mathcal{F}$-action on concrete basis elements\r\nof $\\Lambda_{\\mathcal{F}}$ ?\r\n\r\nAssume that $N$ is the whole $\\mathbb{F}_{q}\\left[  T\\right]  _{+}$.\r\n\r\nBy definition, $p_{1}=x_{1}$, so that \\fbox{$x_{1}f=fx_{1}$ for every\r\n$f\\in\\mathcal{F}$} (since $p_{1}f=fp_{1}$ for every $f\\in\\mathcal{F}$). That\r\nis, $x_{1}$ is central with respect to the two $\\mathcal{F}$-actions. Nothing\r\nto see here.\r\n\r\nBy definition, $p_{T}=\\underbrace{\\left[  T\\right]  \\left(  x_{1}\\right)\r\n}_{=\\left(  F+T\\right)  x_{1}}+Tx_{T}=\\left(  F+T\\right)  x_{1}+Tx_{T}$. Now,\r\n$p_{T}f=fp_{T}$ for every $f\\in\\mathcal{F}$. Apply this to $f=T$ and\r\nsubstitute $p_{T}=\\left(  F+T\\right)  x_{1}+Tx_{T}$; you obtain%\r\n\\[\r\n\\left(  \\left(  F+T\\right)  x_{1}+Tx_{T}\\right)  T=T\\left(  \\left(\r\nF+T\\right)  x_{1}+Tx_{T}\\right)  .\r\n\\]\r\nSince%\r\n\\begin{align*}\r\n\\left(  \\left(  F+T\\right)  x_{1}+Tx_{T}\\right)  T  &  =\\left(  F+T\\right)\r\n\\underbrace{x_{1}T}_{\\substack{=Tx_{1}\\\\\\text{(since }x_{1}\\text{ is\r\ncentral)}}}+Tx_{T}T=\\underbrace{\\left(  F+T\\right)  Tx_{1}}_{=T\\left(\r\nT^{q-1}F+T\\right)  x_{1}}+Tx_{T}T\\\\\r\n&  =T\\left(  \\left(  T^{q-1}F+T\\right)  x_{1}+x_{T}T\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $T\\left(  \\left(  T^{q-1}F+T\\right)  x_{1}+x_{T}T\\right)\r\n=T\\left(  \\left(  F+T\\right)  x_{1}+Tx_{T}\\right)  $. Since $T$ is a left\r\nnon-zero-divisor in $\\mathcal{F}$ and thus also in $\\Lambda_{\\mathcal{F}}$ (as\r\n$\\Lambda_{\\mathcal{F}}$ is a free left $\\mathcal{F}$-module), we can cancel\r\nthe $T$ out of this, and obtain $\\left(  T^{q-1}F+T\\right)  x_{1}%\r\n+x_{T}T=\\left(  F+T\\right)  x_{1}+Tx_{T}$. Hence, $x_{T}T=\\left(  F+T\\right)\r\nx_{1}+Tx_{T}-\\left(  T^{q-1}F+T\\right)  x_{1}$. This simplifies to\r\n\\newline\\fbox{$x_{T}T=Tx_{T}-\\left(  T^{q-1}-1\\right)  Fx_{1}$}.\r\n\r\nLet's do $x_{T}F$. Apply $p_{T}f=fp_{T}$ to $f=F$, and substitute\r\n$p_{T}=\\left(  F+T\\right)  x_{1}+Tx_{T}$ again; the result is%\r\n\\[\r\n\\left(  \\left(  F+T\\right)  x_{1}+Tx_{T}\\right)  F=F\\left(  \\left(\r\nF+T\\right)  x_{1}+Tx_{T}\\right)  .\r\n\\]\r\nSubtraction of $\\left(  F+T\\right)  x_{1}F$ turns this into\r\n\\begin{align*}\r\nTx_{T}F  &  =F\\left(  \\left(  F+T\\right)  x_{1}+Tx_{T}\\right)  -\\left(\r\nF+T\\right)  x_{1}F\\\\\r\n&  =FFx_{1}+\\underbrace{FT}_{=T^{q}F}x_{1}+\\underbrace{FT}_{=T^{q}F}%\r\nx_{T}-F\\underbrace{x_{1}T}_{\\substack{=Fx_{1}\\\\\\text{(since }x_{1}\\text{ is\r\ncentral)}}}-Tx_{1}F\\\\\r\n&  =FFx_{1}+T^{q}Fx_{1}+T^{q}Fx_{T}-FFx_{1}-Tx_{1}F=T^{q}Fx_{1}+T^{q}%\r\nFx_{T}-Tx_{1}F\\\\\r\n&  =T\\left(  T^{q-1}Fx_{1}+T^{q-1}Fx_{T}-x_{1}F\\right)  .\r\n\\end{align*}\r\nCancelling $T$, we obtain%\r\n\\[\r\nx_{T}F=T^{q-1}Fx_{1}+T^{q-1}Fx_{T}-\\underbrace{x_{1}F}_{\\substack{=Fx_{1}%\r\n\\\\\\text{(since }x_{1}\\text{ is central)}}}T^{q-1}Fx_{1}+T^{q-1}Fx_{T}-Fx_{1}.\r\n\\]\r\nThis simplifies to \\fbox{$x_{T}F=\\left(  T^{q-1}-1\\right)  Fx_{1}%\r\n+T^{q-1}Fx_{T}$}.\r\n\r\nLet's be more bold and try a general irreducible polynomial, just to see how\r\nfar we can simplify. Let $\\pi\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+}$ be\r\nirreducible. What is $x_{\\pi}T$ ? As usual, $p_{\\pi}=\\left(\r\n\\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}$ satisfies $p_{\\pi}%\r\nf=fp_{\\pi}$ for every $f\\in\\mathcal{F}$. Applying this to $f=T$ and\r\nsubstituting $p_{\\pi}=\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi\r\nx_{\\pi}$, we get%\r\n\\[\r\n\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}\\right)\r\nT=T\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}\\right)\r\n.\r\n\\]\r\nSubtracting $\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}T$ from here, we get%\r\n\\begin{align*}\r\n\\pi x_{\\pi}T  &  =T\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi\r\nx_{\\pi}\\right)  -\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}T\\\\\r\n&  =T\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+T\\pi x_{\\pi}-\\left(\r\n\\operatorname*{Carl}\\pi\\right)  \\underbrace{x_{1}T}_{\\substack{=Tx_{1}%\r\n\\\\\\text{(since }x_{1}\\text{ is central)}}}\\\\\r\n&  =T\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+T\\pi x_{\\pi}-\\left(\r\n\\operatorname*{Carl}\\pi\\right)  Tx_{1}\\\\\r\n&  =T\\pi x_{\\pi}+\\left[  T,\\operatorname*{Carl}\\pi\\right]  x_{1}.\r\n\\end{align*}\r\nThus, $\\left[  T,\\operatorname*{Carl}\\pi\\right]  $ must lie in $\\pi\r\n\\mathcal{F}$, and an explicit formula for the quotient would be very useful.\r\nWell, the fact that $\\left[  T,\\operatorname*{Carl}\\pi\\right]  $ lies in\r\n$\\pi\\mathcal{F}$ is easily derived from (\\ref{carl.pi}), but there seems to be\r\nno way to write the quotient in finite terms. Let us rather introduce a\r\nnotation for it: Let $\\eth_{T}\\left(  \\pi\\right)  $ denote the (unique)\r\n$f\\in\\mathcal{F}$ satisfying $\\left[  T,\\operatorname*{Carl}\\pi\\right]  =\\pi\r\nf$ (for $\\pi$ irreducible monic). In more elementary (and commutative) terms,\r\n$\\eth_{T}\\left(  \\pi\\right)  =\\dfrac{T\\left[  \\pi\\right]  \\left(  X\\right)\r\n-\\left[  \\pi\\right]  \\left(  TX\\right)  }{\\pi}$. Now,%\r\n\\[\r\n\\pi x_{\\pi}T=\\underbrace{T\\pi}_{=\\pi T}x_{\\pi}+\\underbrace{\\left[\r\nT,\\operatorname*{Carl}\\pi\\right]  }_{=\\pi\\eth_{T}\\left(  \\pi\\right)  }%\r\nx_{1}=\\pi Tx_{\\pi}+\\pi\\eth_{T}\\left(  \\pi\\right)  x_{1}.\r\n\\]\r\nCancelling $\\pi$, we obtain \\fbox{$x_{\\pi}T=Tx_{\\pi}+\\eth_{T}\\left(\r\n\\pi\\right)  x_{1}$}.\r\n\r\nThe question is: Do we get $x_{\\pi}F$ explicitly using $\\eth_{T}\\left(\r\n\\pi\\right)  $, or will we have to introduce another new operator? Apply\r\n$p_{\\pi}f=fp_{\\pi}$ to $f=F$ and substitute $p_{\\pi}=\\left(\r\n\\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}$. The result is%\r\n\\[\r\n\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}\\right)\r\nF=F\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi x_{\\pi}\\right)\r\n.\r\n\\]\r\nSubtracting $\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}F$ from here, we get%\r\n\\begin{align*}\r\n\\pi x_{\\pi}F  &  =F\\left(  \\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+\\pi\r\nx_{\\pi}\\right)  -\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}F\\\\\r\n&  =F\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+F\\pi x_{\\pi}-\\left(\r\n\\operatorname*{Carl}\\pi\\right)  \\underbrace{x_{1}F}_{\\substack{=Fx_{1}%\r\n\\\\\\text{(since }x_{1}\\text{ is central)}}}\\\\\r\n&  =F\\left(  \\operatorname*{Carl}\\pi\\right)  x_{1}+F\\pi x_{\\pi}-\\left(\r\n\\operatorname*{Carl}\\pi\\right)  Fx_{1}\\\\\r\n&  =F\\pi x_{\\pi}+\\left[  F,\\operatorname*{Carl}\\pi\\right]  x_{1}.\r\n\\end{align*}\r\nOh, but $\\left[  F,\\operatorname*{Carl}\\pi\\right]  +\\left[\r\nT,\\operatorname*{Carl}\\pi\\right]  =\\left[  \\underbrace{F+T}%\r\n_{=\\operatorname*{Carl}T},\\operatorname*{Carl}\\pi\\right]  =\\left[\r\n\\operatorname*{Carl}T,\\operatorname*{Carl}\\pi\\right]  =\\operatorname*{Carl}%\r\n\\underbrace{\\left[  T,\\pi\\right]  }_{=0}=0$, so that $\\left[\r\nF,\\operatorname*{Carl}\\pi\\right]  =-\\underbrace{\\left[  T,\\operatorname*{Carl}%\r\n\\pi\\right]  }_{=\\pi\\eth_{T}\\left(  \\pi\\right)  }=-\\pi\\eth_{T}\\left(\r\n\\pi\\right)  $. Hence,%\r\n\\[\r\n\\pi x_{\\pi}F=F\\pi x_{\\pi}+\\underbrace{\\left[  F,\\operatorname*{Carl}%\r\n\\pi\\right]  }_{=-\\pi\\eth_{T}\\left(  \\pi\\right)  }x_{1}=\\underbrace{F\\pi}%\r\n_{=\\pi^{q}F}x_{\\pi}-\\pi\\eth_{T}\\left(  \\pi\\right)  x_{1}=\\pi^{q}Fx_{\\pi}%\r\n-\\pi\\eth_{T}\\left(  \\pi\\right)  x_{1}.\r\n\\]\r\nCancelling $\\pi$, we obtain \\fbox{$x_{\\pi}F=\\pi^{q-1}Fx_{\\pi}-\\eth_{T}\\left(\r\n\\pi\\right)  x_{1}$}.\r\n\r\n\\section{\\label{sect.log}The logarithm series}\r\n\r\nHere is my result on the logarithm series, which so far has not found any application.\r\n\r\n\\begin{theorem}\r\n\\label{thm.carlitzlog}Let $q$ be a prime power. Consider the Carlitz logarithm\r\n$\\log_{C}\\in\\mathbb{F}_{q}\\left(  T\\right)  \\left[  \\left[  X\\right]  \\right]\r\n$ defined in \\cite[Section 7]{kc-carlitz} (but with $q$ instead of $p$). Then,\r\nin the power series ring $\\mathbb{F}_{q}\\left(  T\\right)  \\left[  \\left[\r\nX,S\\right]  \\right]  $, we have%\r\n\\begin{equation}\r\n\\log_{C}\\left(  SX\\right)  =\\sum\\limits_{N\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n_{+}}\\left(  -1\\right)  ^{\\deg N}S^{q^{\\deg N}}\\dfrac{\\left[  N\\right]\r\n\\left(  X\\right)  }{N}. \\label{thm.carlitzlog.1}%\r\n\\end{equation}\r\n(The right hand side of this converges in the usual topology on $\\mathbb{F}%\r\n_{q}\\left[  \\left[  X,S\\right]  \\right]  $.)\r\n\\end{theorem}\r\n\r\nLet us recall the definition of $\\log_{C}$ for the sake of completeness: For\r\nevery $j\\in\\mathbb{N}$, let $L_{j}$ be the polynomial $\\left(  T^{q^{j}%\r\n}-T\\right)  \\left(  T^{q^{j-1}}-T\\right)  ...\\left(  T^{q^{1}}-T\\right)\r\n\\in\\mathbb{F}_{q}\\left[  T\\right]  $. Then, $\\log_{C}\\in\\mathbb{F}_{q}\\left(\r\nT\\right)  \\left[  \\left[  X\\right]  \\right]  $ is defined by%\r\n\\begin{equation}\r\n\\log_{C}\\left(  X\\right)  =\\sum\\limits_{j\\in\\mathbb{N}}\\left(  -1\\right)\r\n^{j}\\dfrac{X^{q^{j}}}{L_{j}}. \\label{carlitzlog}%\r\n\\end{equation}\r\n\r\n\r\nIt should be noticed that it is possible to specialize $S$ to $1$ in\r\n(\\ref{thm.carlitzlog.1}), but then the right hand side will only be convergent\r\nin a rather weak sense (it will only converge if all terms with $N$ having a\r\ngiven degree are first added up, and then the sums are being summed over the\r\ndegree rather than the single terms).\r\n\r\nIn contrast to the preceding results, Theorem \\ref{thm.carlitzlog} seems to be\r\nneither straightforward nor provable by translating some classical argument.\r\nSo let me sketch a proof (which is rather roundabout and hopefully\r\nsimplifiable). First, I need an auxiliary result which itself seems rather interesting:\r\n\r\n\\begin{proposition}\r\n\\label{prop.carlitzlog.lem}Let $q$ be a prime power. Let $A$ be a commutative\r\n$\\mathbb{F}_{q}$-algebra. Let $n\\in\\mathbb{N}$. Let $P\\in A\\left[  X\\right]  $\r\nbe a polynomial such that $\\deg P<q^{n}-1$. Let $e_{1}$, $e_{2}$, $...$,\r\n$e_{n}$ be $n$ elements of $A$. Then,%\r\n\\[\r\n\\sum\\limits_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{F}_{q}^{n}}P\\left(  \\lambda_{1}e_{1}+\\lambda_{2}e_{2}%\r\n+...+\\lambda_{n}e_{n}\\right)  =0.\r\n\\]\r\n\r\n\\end{proposition}\r\n\r\n\\textit{Proof of Proposition \\ref{prop.carlitzlog.lem} (sketch).} We can WLOG\r\nassume that $P=X^{k}$ for some $k\\in\\left\\{  0,1,...,q^{n}-2\\right\\}  $.\r\nAssume this and consider this $k$. Since $k<q^{n}-1$, we can write $k$ in the\r\nform $k=k_{n-1}q^{n-1}+k_{n-2}q^{n-2}+...+k_{0}q^{0}$ with $k_{i}<q$ and with\r\n$k_{0}+k_{1}+...+k_{n-1}\\leq n\\left(  q-1\\right)  -1$. Thus,%\r\n\\[\r\nP=X^{k}=X^{k_{n-1}q^{n-1}+k_{n-2}q^{n-2}+...+k_{0}q^{0}}=\\prod\\limits_{i=0}%\r\n^{n-1}X^{k_{i}q^{i}}=\\prod\\limits_{i=0}^{n-1}\\left(  X^{q^{i}}\\right)\r\n^{k_{i}}.\r\n\\]\r\nHence,%\r\n\\begin{align*}\r\n&  \\sum\\limits_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{F}_{q}^{n}}P\\left(  \\lambda_{1}e_{1}+\\lambda_{2}e_{2}%\r\n+...+\\lambda_{n}e_{n}\\right) \\\\\r\n&  =\\sum\\limits_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{F}_{q}^{n}}\\prod\\limits_{i=0}^{n-1}\\left(  \\underbrace{\\left(\r\n\\lambda_{1}e_{1}+\\lambda_{2}e_{2}+...+\\lambda_{n}e_{n}\\right)  ^{q^{i}}%\r\n}_{\\substack{=\\lambda_{1}e_{1}^{q^{i}}+\\lambda_{2}e_{2}^{q^{i}}+...+\\lambda\r\n_{n}e_{n}^{q^{i}}\\\\\\text{(since we are over }\\mathbb{F}_{q}\\text{)}}}\\right)\r\n^{k_{i}}\\\\\r\n&  =\\sum\\limits_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{F}_{q}^{n}}\\prod\\limits_{i=0}^{n-1}\\left(  \\lambda_{1}e_{1}^{q^{i}%\r\n}+\\lambda_{2}e_{2}^{q^{i}}+...+\\lambda_{n}e_{n}^{q^{i}}\\right)  ^{k_{i}}.\r\n\\end{align*}\r\nNow, consider the product $\\prod\\limits_{i=0}^{n-1}\\left(  \\lambda_{1}%\r\ne_{1}^{q^{i}}+\\lambda_{2}e_{2}^{q^{i}}+...+\\lambda_{n}e_{n}^{q^{i}}\\right)\r\n^{k_{i}}$ \\textbf{as a polynomial (over }$A$\\textbf{) in the variables\r\n}$\\lambda_{1}$, $\\lambda_{2}$, $...$, $\\lambda_{n}$. Then, it is a polynomial\r\nof degree $k_{0}+k_{1}+...+k_{n-1}\\leq n\\left(  q-1\\right)  -1$. It is\r\nwell-known (e. g., from the proof of the Chevalley-Warning theorem) that any\r\nsuch polynomial yields $0$ when summed over all $\\left(  \\lambda_{1}%\r\n,\\lambda_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{F}_{q}^{n}$ (because each of\r\nits monomials has at least one exponent $<q-1$, and then summing the variable\r\nwhich has this exponent over $\\mathbb{F}_{q}$ already gives $0$ with all other\r\nvariables remaining fixed). This proves Proposition \\ref{prop.carlitzlog.lem}.\r\n\r\nAnother auxiliary result:\r\n\r\n\\begin{proposition}\r\n\\label{prop.carlitzlog.lem2}Let $q$ be a prime power. Let $L$ be a field\r\nextension of $\\mathbb{F}_{q}$. Let $V$ be a finite $\\mathbb{F}_{q}$-vector\r\nsubspace of $L$. Let $t\\in L\\setminus V$. Then,%\r\n\\[\r\n\\sum\\limits_{v\\in V}\\dfrac{1}{t+v}=\\left(  \\prod\\limits_{v\\in V}\\dfrac{1}%\r\n{t+v}\\right)  \\cdot\\left(  \\prod\\limits_{v\\in V\\setminus0}v\\right)  .\r\n\\]\r\n\r\n\\end{proposition}\r\n\r\n\\textit{Proof of Proposition \\ref{prop.carlitzlog.lem2} (sketched).} Let $W$\r\nbe the polynomial $\\prod\\limits_{v\\in V}\\left(  X+v\\right)  \\in L\\left[\r\nX\\right]  $. This polynomial is a $q$-polynomial (indeed, Theorem\r\n\\ref{thm.mac1.subspace} (applied to $L=A$) shows that $f_{V}$ is a\r\n$q$-polynomial, but clearly $f_{V}=W$); hence, its derivative equals its\r\ncoefficient in front of $X^{1}$ (because the derivative of any $q$-polynomial\r\nin characteristic $p\\mid q$ equals its coefficient in front of $X^{1}$). But\r\nthis coefficient is $\\prod\\limits_{v\\in V\\setminus0}v$. Thus, we know that the\r\nderivative of $W$ equals $\\prod\\limits_{v\\in V\\setminus0}v$. Hence,\r\n$W^{\\prime}\\left(  t\\right)  =\\prod\\limits_{v\\in V\\setminus0}v$.\r\n\r\nOn the other hand, since $W=\\prod\\limits_{v\\in V}\\left(  X+v\\right)  $, the\r\nLeibniz formula yields%\r\n\\begin{align*}\r\nW^{\\prime}  &  =\\sum\\limits_{w\\in V}\\underbrace{\\left(  X+w\\right)  ^{\\prime}%\r\n}_{=1}\\cdot\\prod\\limits_{\\substack{v\\in V;\\\\v\\neq w}}\\left(  X+v\\right)\r\n=\\sum\\limits_{w\\in V}\\prod\\limits_{\\substack{v\\in V;\\\\v\\neq w}}\\left(\r\nX+v\\right)  =\\sum\\limits_{w\\in V}\\dfrac{\\prod\\limits_{v\\in V}\\left(\r\nX+v\\right)  }{X+w}\\\\\r\n&  =\\left(  \\prod\\limits_{v\\in V}\\left(  X+v\\right)  \\right)  \\cdot\\left(\r\n\\sum\\limits_{w\\in V}\\dfrac{1}{X+w}\\right)  .\r\n\\end{align*}\r\nApplying this to $X=t$, we obtain%\r\n\\[\r\nW^{\\prime}\\left(  t\\right)  =\\left(  \\prod\\limits_{v\\in V}\\left(  t+v\\right)\r\n\\right)  \\cdot\\left(  \\sum\\limits_{w\\in V}\\dfrac{1}{t+w}\\right)  ,\r\n\\]\r\nso that%\r\n\\begin{align*}\r\n\\sum\\limits_{w\\in V}\\dfrac{1}{t+w}  &  =\\dfrac{1}{\\prod\\limits_{v\\in V}\\left(\r\nt+v\\right)  }\\cdot\\underbrace{W^{\\prime}\\left(  t\\right)  }_{=\\prod\r\n\\limits_{v\\in V\\setminus0}v}=\\dfrac{1}{\\prod\\limits_{v\\in V}\\left(\r\nt+v\\right)  }\\cdot\\left(  \\prod\\limits_{v\\in V\\setminus0}v\\right) \\\\\r\n&  =\\left(  \\prod\\limits_{v\\in V}\\dfrac{1}{t+v}\\right)  \\cdot\\left(\r\n\\prod\\limits_{v\\in V\\setminus0}v\\right)  .\r\n\\end{align*}\r\nRename the index $w$ as $v$ and obtain the claim of Proposition\r\n\\ref{prop.carlitzlog.lem2}.\r\n\r\n\\textit{Proof of Theorem \\ref{thm.carlitzlog} (sketched).} By\r\n(\\ref{carlitzlog}), we have%\r\n\\[\r\n\\log_{C}\\left(  SX\\right)  =\\sum\\limits_{j\\in\\mathbb{N}}\\left(  -1\\right)\r\n^{j}\\dfrac{\\left(  SX\\right)  ^{q^{j}}}{L_{j}}=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\left(  -1\\right)  ^{j}S^{q^{j}}\\dfrac{X^{q^{j}}}{L_{j}}.\r\n\\]\r\nHence, it is clearly enough to show that every $m\\in\\mathbb{N}$ satisfies%\r\n\\begin{equation}\r\n\\dfrac{X^{q^{m}}}{L_{m}}=\\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+};\\\\\\deg N=m}}\\dfrac{\\left[  N\\right]  \\left(  X\\right)  }{N}.\r\n\\label{pf.carlitzlog.1}%\r\n\\end{equation}\r\n\r\n\r\nSo let $m\\in\\mathbb{N}$. Introduce the polynomials $E_{j}\\left(  Y\\right)\r\n\\in\\mathbb{F}_{q}\\left(  T\\right)  \\left[  Y\\right]  $ for all $j\\in\r\n\\mathbb{N}$ as in \\cite[Section 7]{kc-carlitz}, but with $q$ instead of $p$.\r\nLet's spell out their definition: With $e_{C}$ denoting the Carlitz\r\nexponential, the power series $e_{C}\\left(  Y\\log_{C}X\\right)  \\in\r\n\\mathbb{F}_{q}\\left(  T\\right)  \\left[  \\left[  X,Y\\right]  \\right]  $ is a\r\n$q$-power series, i. e., its coefficient before $X^{\\alpha}Y^{\\beta}$ can only\r\nbe nonzero if both $\\alpha$ and $\\beta$ are powers of $q$. Now, for every\r\n$j\\in\\mathbb{N}$, define $E_{j}\\left(  Y\\right)  $ to be the coefficient of\r\nthis power series $e_{C}\\left(  Y\\log_{C}X\\right)  $, \\textbf{regarded as a\r\npower series in }$X$ \\textbf{over }$\\mathbb{F}_{q}\\left(  T\\right)  \\left[\r\nY\\right]  $, before $X^{q^{j}}$. Of course, this $E_{j}\\left(  Y\\right)  $ is\r\na $q$-polynomial in $\\mathbb{F}_{q}\\left(  T\\right)  \\left[  Y\\right]  $.\r\nMoreover, $\\deg\\left(  E_{j}\\right)  =q^{j}$ and $E_{j}\\left(  0\\right)  =0$\r\nfor all $j\\in\\mathbb{N}$. Furthermore, $E_{j}\\left(  M\\right)  =0$ for every\r\n$M\\in\\mathbb{F}_{q}\\left[  T\\right]  $ satisfying $\\deg M<j$. Finally,\r\n$E_{j}\\left(  M\\right)  =1$ for every $M\\in\\mathbb{F}_{q}\\left[  T\\right]  $\r\nsatisfying $\\deg M=j$. But most importantly, $\\left[  M\\right]  \\left(\r\nX\\right)  =\\sum\\limits_{j\\in\\mathbb{N}}E_{j}\\left(  M\\right)  X^{q^{j}}$ in\r\n$\\mathbb{F}_{q}\\left(  T\\right)  \\left[  X\\right]  $ for every $M\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  $. Hence, for every nonzero $M\\in\r\n\\mathbb{F}_{q}\\left(  T\\right)  \\left[  X\\right]  $, we have%\r\n\\begin{align}\r\n\\dfrac{\\left[  M\\right]  \\left(  X\\right)  }{M}  &  =\\dfrac{\\sum\r\n\\limits_{j\\in\\mathbb{N}}E_{j}\\left(  M\\right)  X^{q^{j}}}{M}=\\sum\r\n\\limits_{j\\in\\mathbb{N}}\\dfrac{E_{j}\\left(  M\\right)  }{M}X^{q^{j}}%\r\n=\\sum\\limits_{j=0}^{\\deg M}\\dfrac{E_{j}\\left(  M\\right)  }{M}X^{q^{j}%\r\n}\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }E_{j}\\left(  M\\right)  =0\\text{\r\nwhenever }\\deg M<j\\right) \\nonumber\\\\\r\n&  =\\sum\\limits_{j=0}^{\\deg M-1}\\dfrac{E_{j}\\left(  M\\right)  }{M}X^{q^{j}%\r\n}+\\underbrace{\\dfrac{E_{\\deg M}\\left(  M\\right)  }{M}}_{\\substack{=\\dfrac\r\n{1}{M}\\\\\\text{(since }E_{j}\\left(  M\\right)  =1\\text{ whenever }\\deg\r\nM=j\\text{)}}}X^{q^{\\deg M}}\\nonumber\\\\\r\n&  =\\sum\\limits_{j=0}^{\\deg M-1}\\dfrac{E_{j}\\left(  M\\right)  }{M}X^{q^{j}%\r\n}+\\dfrac{1}{M}X^{q^{\\deg M}} \\label{pf.carlitzlog.lem2.5}%\r\n\\end{align}\r\nBut since $E_{j}\\left(  0\\right)  =0$ for all $j\\in\\mathbb{N}$, we know that\r\nfor every $j\\in\\mathbb{N}$, the polynomial $E_{j}\\left(  Y\\right)  $ is\r\ndivisible by $Y$. Thus, $\\dfrac{E_{j}\\left(  Y\\right)  }{Y}$ is a polynomial\r\nof degree $q^{j}-1$ for every $j\\in\\mathbb{N}$ (since $\\deg\\left(\r\nE_{j}\\right)  =q^{j}$). Renaming $Y$ as $X$, we see that $\\dfrac{E_{j}\\left(\r\nX\\right)  }{X}$ is a polynomial of degree $q^{j}-1$ for every $j\\in\\mathbb{N}%\r\n$. Hence, $\\dfrac{E_{j}\\left(  X+T^{m}\\right)  }{X+T^{m}}\\in\\mathbb{F}%\r\n_{q}\\left(  T\\right)  \\left[  X\\right]  $ also is a polynomial of degree\r\n$q^{j}-1$ for every $j\\in\\mathbb{N}$. Hence, for every $j\\in\\left\\{\r\n0,1,...,m-1\\right\\}  $, we can apply Proposition \\ref{prop.carlitzlog.lem} to\r\n$A=\\mathbb{F}_{q}\\left(  T\\right)  $, $n=m$, $P=\\dfrac{E_{j}\\left(\r\nX+T^{m}\\right)  }{X+T^{m}}$ and $e_{i}=T^{i-1}$, and conclude that\r\n\\[\r\n\\sum\\limits_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{m}\\right)\r\n\\in\\mathbb{F}_{q}}\\dfrac{E_{j}\\left(  \\lambda_{1}T^{0}+\\lambda_{2}%\r\nT^{1}+...+\\lambda_{m}T^{m-1}+T^{m}\\right)  }{\\lambda_{1}T^{0}+\\lambda_{2}%\r\nT^{1}+...+\\lambda_{m}T^{m-1}+T^{m}}=0\r\n\\]\r\n(since $j<m$ and thus $q^{j}-1<q^{m}-1$). Since the sums of the form\r\n$\\lambda_{1}T^{0}+\\lambda_{2}T^{1}+...+\\lambda_{m}T^{m-1}+T^{m}$ with $\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{m}\\right)  \\in\\mathbb{F}_{q}$ are\r\nprecisely the monic polynomials in $\\mathbb{F}_{q}\\left[  T\\right]  $ with\r\ndegree $m$ (each appearing exactly once), this rewrites as%\r\n\\begin{equation}\r\n\\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg\r\nN=m}}\\dfrac{E_{j}\\left(  N\\right)  }{N}=0\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}j\\in\\left\\{  0,1,...,m-1\\right\\}  \\text{.} \\label{pf.carlitzlog.lem2.8}%\r\n\\end{equation}\r\n\r\n\r\nNow,%\r\n\\begin{align*}\r\n&  \\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg\r\nN=m}}\\dfrac{\\left[  N\\right]  \\left(  X\\right)  }{N}\\\\\r\n&  =\\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg\r\nN=m}}\\left(  \\sum\\limits_{j=0}^{\\deg N-1}\\dfrac{E_{j}\\left(  N\\right)  }%\r\n{N}X^{q^{j}}+\\dfrac{1}{N}X^{q^{\\deg N}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we applied\r\n(\\ref{pf.carlitzlog.lem2.5}) to }M=N\\right) \\\\\r\n&  =\\sum\\limits_{j=0}^{m-1}\\underbrace{\\sum\\limits_{\\substack{N\\in\r\n\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg N=m}}\\dfrac{E_{j}\\left(  N\\right)\r\n}{N}}_{\\substack{=0\\\\\\text{(by (\\ref{pf.carlitzlog.lem2.8}))}}}X^{q^{j}}%\r\n+\\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg\r\nN=m}}\\dfrac{1}{N}X^{q^{m}}\\\\\r\n&  =\\sum\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[  T\\right]  _{+};\\\\\\deg\r\nN=m}}\\dfrac{1}{N}X^{q^{m}}=\\sum\\limits_{\\substack{v\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  ;\\\\\\deg v<m}}\\dfrac{1}{T^{m}+v}X^{q^{m}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since the monic polynomials in }\\mathbb{F}_{q}\\left[  T\\right]  \\text{\r\nof degree }m\\text{ are exactly}\\\\\r\n\\text{the sums of the form }T^{m}+v\\text{ with }v\\text{ being a polynomial\r\nin}\\\\\r\n\\mathbb{F}_{q}\\left[  T\\right]  \\text{ of degree }<m\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\left(  \\prod\\limits_{\\substack{v\\in\\mathbb{F}_{q}\\left[  T\\right]\r\n;\\\\\\deg v<m}}\\dfrac{1}{T^{m}+v}\\right)  \\cdot\\left(  \\prod\r\n\\limits_{\\substack{v\\in\\mathbb{F}_{q}\\left[  T\\right]  ;\\\\\\deg v<m;\\\\v\\neq\r\n0}}v\\right)  X^{q^{m}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Proposition \\ref{prop.carlitzlog.lem2}, applied to }L=\\mathbb{F}%\r\n_{q}\\left(  T\\right)  \\text{, }t=T^{m}\\\\\r\n\\text{and }V=\\left\\{  v\\in\\mathbb{F}_{q}\\left[  T\\right]  \\ \\mid\\ \\deg\r\nv<m\\right\\}\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\underbrace{\\left(  \\prod\\limits_{\\substack{N\\in\\mathbb{F}_{q}\\left[\r\nT\\right]  _{+};\\\\\\deg N=m}}\\dfrac{1}{N}\\right)  \\cdot\\left(  \\prod\r\n\\limits_{\\substack{v\\in\\mathbb{F}_{q}\\left[  T\\right]  ;\\\\\\deg v<m;\\\\v\\neq\r\n0}}v\\right)  }_{\\substack{=\\dfrac{1}{L_{m}}\\\\\\text{(this is relatively\r\nstraightforward to prove}\\\\\\text{using standard results on finite fields)}%\r\n}}X^{q^{m}}=\\dfrac{X^{q^{m}}}{L_{m}}.\r\n\\end{align*}\r\nThis proves (\\ref{pf.carlitzlog.1}) and thus Theorem \\ref{thm.carlitzlog}.\r\n\r\nI hope there is a better proof.\r\n\r\n\\begin{thebibliography}{99}                                                                                               %\r\n\r\n\r\n\\bibitem {jb-bg1}James Borger, \\textit{The basic geometry of Witt vectors, I:\r\nThe affine case}, Algebra \\& Number Theory 5 (2011), no. 2, pp 231--285. Also\r\navailable as preprint arXiv:0801.1691v6.\\newline\\url{http://arxiv.org/abs/0801.1691v6}\r\n\r\n\\bibitem {bw-pa}James Borger, Ben Wieland, \\textit{Plethystic algebra},\r\narXiv:math/0407227v1.\\newline\\url{http://arxiv.org/abs/math/0407227v1}\r\n\r\n\\bibitem {kc-carlitz}Keith Conrad, \\textit{Carlitz extensions}.\\newline\\url{http://www.math.uconn.edu/~kconrad/blurbs/gradnumthy/carlitz.pdf}\r\n\r\n\\bibitem {dhns}Tom Denton, Florent Hivert, Anne Schilling, Nicolas M.\r\nThi\\'{e}ry, \\textit{On the representation theory of finite }$\\mathcal{J}%\r\n$\\textit{-trivial monoids}, arXiv:1010.3455v3. \\url{http://arxiv.org/abs/1010.3455v3}\r\n\r\n\\bibitem {dyckerhoff}Tobias Dyckerhoff, \\textit{Hall Algebras - Bonn,\r\nWintersemester 14/15}, lecture notes, February 5, 2015.\\newline\\url{http://www.math.uni-bonn.de/people/dyckerho/notes.pdf}\r\n\r\n\\bibitem {reiner-hopf}Darij Grinberg, Victor Reiner, \\textit{Hopf\r\nalgebras in Combinatorics}, version of 11 May 2018,\r\n\\href{http://arxiv.org/abs/1409.8356v5}{arXiv:1409.8356v5}. \\newline%\r\nSee also \\url{http://www.cip.ifi.lmu.de/~grinberg/algebra/HopfComb-sols.pdf} for a version that gets updated.\r\n\r\n\\bibitem {dg-witt5}Darij Grinberg, \\textit{Witt\\#5: Around the integrality\r\ncriterion 9.93}, sidenote to Michiel Hazewinkel's \\textquotedblleft Witt\r\nvectors. Part 1\\textquotedblright.\\newline\\url{http://mit.edu/~darij/www/algebra/witt5.pdf}\r\n\r\n\\bibitem {dg-witt5c}Darij Grinberg, \\textit{Witt\\#5c: The Chinese Remainder\r\nTheorem for Modules}, sidenote to Michiel Hazewinkel's \\textquotedblleft Witt\r\nvectors. Part 1\\textquotedblright.\\newline\\url{http://mit.edu/~darij/www/algebra/witt5c.pdf}\r\n\r\n\\bibitem {dg-witt5f}Darij Grinberg, \\textit{Witt\\#5f: Ghost-Witt integrality\r\nfor binomial rings}, sidenote to Michiel Hazewinkel's \\textquotedblleft Witt\r\nvectors. Part 1\\textquotedblright.\\newline\\url{http://mit.edu/~darij/www/algebra/witt5f.pdf}\r\n\r\n\\bibitem {hw-witt1}Michiel Hazewinkel, \\textit{Witt vectors. Part 1},\r\narXiv:0804.3888.\\newline\\url{http://arxiv.org/abs/0804.3888v1}\r\n\r\n\\bibitem {hesselholt-drw}Lars Hesselholt, \\textit{The big de Rham-Witt\r\ncomplex}, Acta Math. 214 (2015), pp. 135--207.\\newline A preprint is also\r\navailable as arXiv:1006.3125v3: \\url{http://arxiv.org/abs/1006.3125v3}\r\n\r\n\\bibitem {hesselholt-witt}Lars Hesselholt, \\textit{Lecture notes on Witt\r\nvectors}, MIT, Cambridge, Massachusetts, USA, 2005.\\newline\\url{http://www.math.nagoya-u.ac.jp/~larsh/papers/s03/wittsurvey.pdf}\r\n\r\n\\bibitem {levent}Levent, \\textit{math.stackexchange post \\#1824797\r\n(\\textquotedblleft Show that }$\\sum_{d\\mid f}\\varphi\\left(  \\dfrac{f}%\r\n{d}\\right)  a^{\\left\\vert d\\right\\vert }\\equiv0\\operatorname{mod}%\r\nf$\\textit{\\textquotedblright)}. \\url{http://math.stackexchange.com/q/1824797}\r\n\r\n\\bibitem {jacobson-rl}Nathan Jacobson, \\textit{Restricted Lie algebras of\r\ncharacteristic }$p$, Trans. Amer. Math. Soc. \\textbf{50} (1941), pp.\r\n15--25.\\newline\\url{http://www.ams.org/journals/tran/1941-050-01/S0002-9947-1941-0005118-0/home.html}\r\n\r\n\\bibitem {mac-schurvar}I. G. Macdonald, \\textit{Schur functions: Theme and\r\nvariations}, S\\'{e}minaire Lotharingien de Combinatoire 28, B28a\r\n(1992).\\newline\\url{http://www.emis.de/journals/SLC/opapers/s28macdonald.html}\r\n\r\n\\bibitem {ore-pp1}Oystein Ore, \\textit{On a Special Class of Polynomials},\r\nTrans. Amer. Math. Soc. \\textbf{35} (1933), pp. 559--584.\\newline\\url{http://www.ams.org/journals/tran/1933-035-03/S0002-9947-1933-1501703-0/}\r\n\r\n\\bibitem {ore-pp2}Oystein Ore, \\textit{Errata in my paper: \\textquotedblleft\r\nOn a special class of polynomials\\textquotedblright\\ [Trans. Amer. Math. Soc.\r\n35 (1933), no. 3, 559-584; 1501703]}, Trans. Amer. Math. Soc. \\textbf{36}\r\n(1934), p. 275.\\newline\\url{http://www.ams.org/journals/tran/1934-036-02/S0002-9947-1934-1501741-9/}\r\n\r\n\\bibitem {rabinoff-witt}Joseph Rabinoff, \\textit{The Theory of Witt\r\nVectors}.\\newline\\url{http://www.math.harvard.edu/~rabinoff/misc/witt.pdf}\r\n\r\n\\bibitem {stanley-ec2}Richard Stanley, \\textit{Enumerative Combinatorics,\r\nvolume 2}, Cambridge University Press 2001.\r\n\\end{thebibliography}\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "8f5d98946c87f7c1f2ad4aaa20b31c4b545a8313", "size": 527312, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "schur-ore.tex", "max_stars_repo_name": "darijgr/schur-ore", "max_stars_repo_head_hexsha": "60d3df22f70ba20e042392e1e52e50a80112c5a0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "schur-ore.tex", "max_issues_repo_name": "darijgr/schur-ore", "max_issues_repo_head_hexsha": "60d3df22f70ba20e042392e1e52e50a80112c5a0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "schur-ore.tex", "max_forks_repo_name": "darijgr/schur-ore", "max_forks_repo_head_hexsha": "60d3df22f70ba20e042392e1e52e50a80112c5a0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.933256061, "max_line_length": 143, "alphanum_fraction": 0.6324813393, "num_tokens": 211241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.4213054078611744}}
{"text": "\\section{Direct synthesis}\n\\subsection{}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{as usual...}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Consider the control loop we know, with $H(z)=1$ for simplicity:\n       \\begin{center}\n        \\includegraphics[width=0.50\\columnwidth]{./Unit-04/img/ControlLoop-H1.pdf}\n       \\end{center}\n \\item Take as process and controller, respectively,\n       \\begin{displaymath}\n        P(z) = \\frac{\\mu}{z-p}, \\qquad\n        C(z) = \\frac{1-\\alpha}{\\mu} \\, \\frac{z-p}{z-1},\n       \\end{displaymath}\n \\item and analyse the obtained system.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item We have a \\TC{zero/pole cancellation} between controller and process, as the loop transfer function is\n       \\begin{displaymath}\n        L(z) = P(z)C(z)\n             = \\frac{\\cbcancel[gray]{\\mu}}{\\ccancel[red]{z-p}} \\,\n               \\frac{1-\\alpha}{\\cbcancel[gray]{\\mu}} \\, \\frac{\\ccancel[red]{z-p}}{z-1}\n             = \\frac{1-\\alpha}{z-1}\n       \\end{displaymath}\n \\item Hence\n       \\begin{displaymath}\n        G_{yw}(z) = \\frac{L(z)}{1+L(z)}\n                  = \\frac{\\frac{1-\\alpha}{z-1}}{1+\\frac{1-\\alpha}{z-1}}\n                  = \\frac{1-\\alpha}{\\ccancel[green!80!black]{z-1}} \\,\n                    \\frac{\\ccancel[green!80!black]{z-1}}{z-1+1-\\alpha}\n                  = \\frac{1-\\alpha}{z-\\alpha}.\n       \\end{displaymath}\n \\item NOTE: the \\textcolor{green!80!black}{simplification} in computing $G_{yw}$ is NOT a cancellation.\n \\item[] \\vspace{-0.75mm}To have a cancellation you need a system (block) with a zero say\\\\\n       in $\\overline{z}$, and \\TC{\\underline{ANOTHER}} system (block) with a pole in the same  $\\overline{z}$\\\\\n \\item[] \\vspace{-0.75mm} --- as is the case with the \\textcolor{red}{cancellation} in $L$ above.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Furthermore, as $H(z)=1$,\n       \\begin{displaymath}\n        G_{yd}(z) = \\frac{1}{1+L(z)}\n                  = \\frac{1}{1+\\frac{1-\\alpha}{z-1}}\n                  = \\frac{z-1}{z-1+1-\\alpha}\n                  = \\frac{z-1}{z-\\alpha}.\n       \\end{displaymath}\n \\item You may -- should \\smiley$\\,$ -- remember that cancellations entail hidden parts for the affected system.\n \\item Let us evidence and discuss the implications of this in the present\\\\\n       case, by going through a state space analysis.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item First we express the process in state space form:\n       \\begin{displaymath}\n        \\left\\{\\begin{array}{rcl}\n         x_P(k) &=& p x_P(k-1) + \\mu u(k-1) \\\\\n         y(k)   &=& x_P(k) + d(k)\n        \\end{array}\\right.\n       \\end{displaymath}\n \\item Then we rewrite the controller transfer function as a constant plus a term with numerator degree\n       strictly less than denominator degree (check out the wxMaxima \\texttt{divide} function):\n       \\begin{displaymath}\n        C(z) = \\frac{1-\\alpha}{\\mu} \\, \\frac{z-p}{z-1} \n             = \\frac{1-\\alpha}{\\mu} \\left( 1 + \\textcolor{red}{\\frac{1-p}{z-1}} \\right)\n       \\end{displaymath}\n \\item Then we treat the \\textcolor{red}{strictly proper} term like $P(z)$ above, obtaining\n       \\begin{displaymath}\n        \\left\\{\\begin{array}{rcl}\n         x_C(k) &=& x_C(k-1) + (1-p) e(k-1) \\\\\n         u(k)   &=& \\frac{1-\\alpha}{\\mu} x_C(k) + \\frac{1-\\alpha}{\\mu} e(k)\n        \\end{array}\\right.\n       \\end{displaymath}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Joining the equations for $P$ and $C$ and those for the node that produces $e$, gives\\\\\n       for the overall closed-loop system the scalar (not yet reduced to minimal) description\n       \\begin{displaymath}\n        \\left\\{\\begin{array}{rcl}\n         x_P(k) &=& p x_P(k-1) + \\mu u(k-1) \\\\\n         x_C(k) &=& x_C(k-1) + (1-p) e(k-1) \\\\\n         y(k)   &=& x_P(k) + d(k) \\\\\n         u(k)   &=& \\frac{1-\\alpha}{\\mu} x_C(k) + \\frac{1-\\alpha}{\\mu} e(k) \\\\\n         e(k)   &=& w(k) - y(k)\n        \\end{array}\\right.\n       \\end{displaymath}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item For the process state we have\n       \\begin{displaymath}\n        \\begin{array}{rcl}\n         x_P(k) &=& p x_P(k-1) + \\mu u(k-1) \\\\\n                &=& p x_P(k-1) + \\mu \\left( \\frac{1-\\alpha}{\\mu} x_C(k-1) + \\frac{1-\\alpha}{\\mu} e(k-1) \\right) \\\\\n                &=& p x_P(k-1) + (1-\\alpha)x_C(k-1) + (1-\\alpha) \\left( w(k-1)-y(k-1) \\right) \\\\\n                &=& p x_P(k-1) + (1-\\alpha)x_C(k-1) + (1-\\alpha) w(k-1)\\\\\n                & & - (1-\\alpha) \\left( x_P(k-1)+d(k-1) \\right) \\\\\n                &=& \\left( p+\\alpha-1 \\right) x_P(k-1)\n                    +(1-\\alpha) x_C(k-1)\\\\\n                & & +(1-\\alpha) w(k-1)\n                    -(1-\\alpha) d(k-1)                 \n        \\end{array}\n       \\end{displaymath}\n \\item while the controller state evolves according to\n       \\begin{displaymath}\n        \\begin{array}{rcl}\n         x_C(k) &=& x_C(k-1) + (1-p) e(k-1) \\\\\n                &=& x_C(k-1)\\\\\n                & & + (1-p) \\left( w(k-1)-x_P(k-1)-d(k-1) \\right)\\\\\n                &=& (p-1) x_P(k-1) + x_C(k-1)\\\\\n                & & +(1-p) w(k-1)\n                    -(1-p) d(k-1)  \n        \\end{array}\n       \\end{displaymath}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Putting it all together, the closed-loop system in state space form reads\n       \\begin{displaymath}\n        \\left\\{\\begin{array}{rcl}\n         \\begin{bmatrix} x_P(k) \\\\ x_C(k) \\end{bmatrix}\n         &=& \n         \\begin{bmatrix} p+\\alpha-1 & 1-\\alpha \\\\ p-1 & 1  \\end{bmatrix}\n         \\begin{bmatrix} x_P(k-1) \\\\ x_C(k-1) \\end{bmatrix}\n         +\n         \\begin{bmatrix} 1-\\alpha & \\alpha-1 \\\\ 1-p & p-1  \\end{bmatrix}\n         \\begin{bmatrix} w(k-1) \\\\ d(k-1) \\end{bmatrix} \\\\\n         \\begin{bmatrix} y(k) \\\\ u(k) \\end{bmatrix}\n         &=& \n         \\begin{bmatrix} 1 & 0 \\\\ \\frac{\\alpha-1}{\\mu} & \\frac{1-\\alpha}{\\mu} \\end{bmatrix}\n         \\begin{bmatrix} x_P(k) \\\\ x_C(k) \\end{bmatrix}\n         +\n         \\begin{bmatrix} 0 & 1 \\\\ \\frac{1-\\alpha}{\\mu} & \\frac{\\alpha-1}{\\mu} \\end{bmatrix}\n         \\begin{bmatrix} w(k) \\\\ d(k) \\end{bmatrix} \\\\\n        \\end{array}\\right.\n       \\end{displaymath}\n \\item[] with input $[w\\,d]'$, output $[y\\,u]'$ and\n       \\begin{displaymath}\n        \\begin{array}{c}\n         A = \\begin{bmatrix} p+\\alpha-1 & 1-\\alpha \\\\ p-1 & 1  \\end{bmatrix},\\quad\n         B = \\begin{bmatrix} 1-\\alpha & \\alpha-1 \\\\ 1-p & p-1  \\end{bmatrix},\\\\\n         C = \\begin{bmatrix} 1 & 0 \\\\ \\frac{\\alpha-1}{\\mu} & \\frac{1-\\alpha}{\\mu} \\end{bmatrix},\\quad\n         D = \\begin{bmatrix} 0 & 1 \\\\ \\frac{1-\\alpha}{\\mu} & \\frac{\\alpha-1}{\\mu} \\end{bmatrix}.\n        \\end{array}\n       \\end{displaymath}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item To verify, we express the same system as a \\TC{transfer matrix}, i.e.\n       \\begin{displaymath}\n        \\begin{bmatrix} y(k) \\\\ u(k) \\end{bmatrix}\n        = G(z) \n        \\begin{bmatrix} w(k) \\\\ d(k) \\end{bmatrix}, \\qquad\n        G(z) =\n        \\begin{bmatrix} G_{yw}(z) & G_{yd}(z) \\\\ G_{uw}(z) & G_{ud}(z) \\end{bmatrix}\n       \\end{displaymath}\n \\item Since $G(z) = C(zI-A)^{-1}B+D$, we can compute it in wxMaxima with \n       \\begin{verbatim}\nA : matrix([p+alpha-1,1-alpha],[p-1,1]);\nB : matrix([1-alpha,alpha-1],[1-p,p-1]);\nC : matrix([1,0],[(alpha-1)/mu,(1-alpha)/mu]);\nD : matrix([0,1],[(1-alpha)/mu,(alpha-1)/mu]);\nG : factor(C.invert(z*ident(2)-A).B+D);\n       \\end{verbatim}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Introductory example}\n\\framesubtitleTC{State space formulation of the closed-loop system}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Doing so we obtain\n       \\begin{displaymath}\n        G(z) =\n        \\begin{bmatrix} \n         \\cfrac{1-\\alpha}{z-\\alpha}                   & \\cfrac{z-1}{z-\\alpha} \\\\\n         \\cfrac{1-\\alpha}{\\mu}\\,\\cfrac{z-p}{z-\\alpha} & \\cfrac{\\alpha-1}{\\mu}\\,\\cfrac{z-p}{z-\\alpha}\n        \\end{bmatrix}\n       \\end{displaymath}\n \\item The first row contains the transfer functions we already computed.\n \\item The second says that the effects of $w$ and $d$ on $u$ are the opposite\\\\\n       of one another (consistent with the loop scheme).\n \\item \\vfill Now, for some remarks to generalise.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Remarks}\n\\framesubtitleTC{and lessons learnt (1/2)}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item We took a first-order process.\n \\item We took a controller that cancels the process pole with its zero, and has\\\\\n       a pole in $z=1$.\n \\item We obtained a reference-to-output transfer function $G_{yw}(z)$\n       \\begin{itemize}[<+-| alert@+>]\n       \\item with unity gain, hence for constant $w$ the error vanishes,\n       \\item and with a prescribed pole $\\alpha$ (i.e., a prescribed set point tracking speed).\n       \\end{itemize}\n \\item We also obtained a disturbance-to-output transfer function $G_{yd}(z)$\n       \\begin{itemize}[<+-| alert@+>]\n       \\item with zero gain, hence for constant $d$ the error vanishes as well,\n       \\item and with the same pole $\\alpha$ (i.e., a prescribed disturbance rejection\\\\\n             speed as well).\n       \\end{itemize}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Remarks}\n\\framesubtitleTC{and lessons learnt (2/2)}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Most important, the eigenvalues of the closed-loop dynamic matrix $A$\\\\\n       are $\\alpha$ and $p$, i.e., \\TC{the one we prescribed and the one we cancelled}.\n \\item The latter eigenvalue apparently ends up in a hidden part --- the transfer matrix\n       contains elements with a denominator of degree one and root $p$, while the order\\\\\n       of the system is two (one state variable for $P$ and one for $C$).\n \\item Thus we can use this technique only if $|p|<1$, otherwise the\\\\\n       closed-loop system has a hidden part that is not asymptotically stable.\n \\item \\vfill We are now ready to address the \\TC{direct synthesis} technique\\\\\n       in general, at the level we need for our activity.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Direct synthesis}\n\\framesubtitleTC{The general idea}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Assume a process model $P(z)$ is available.\n \\item Choose a closed-loop transfer function -- name it here generically $O(z)$, specialisations\n       in the following -- to represent your control objectives.\n \\item Choose a desired expression $O^{\\circ}(z)$ for $O(z)$.\n \\item Express $O$ as a function of $P$ and the controller $C$ and set it equal to $O^{\\circ}$,\\\\\n       i.e., write the equation\n       \\begin{displaymath} \n       O \\left( P(z),C(z) \\right) = O^{\\circ}(z).\n       \\end{displaymath}\n \\item Solve for $C(z)$. Voil\\`{a} \\smiley.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Direct synthesis}\n\\framesubtitleTC{The general idea}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item \\emph{CAVEAT 1:} no exhaustiveness claim. We are only scratching the surface,\\\\\n       there is a myriad of things we cannot stuff in this course. Categorised\\\\\n       references for the interested at the end.\n \\item \\emph{CAVEAT 2:} no magic either. There is potential but also pitfalls\\\\\n       to be aware of.\n \\item Some facts we anticipate right from the start:\n       \\begin{itemize}[<+-| alert@+>]\n       \\item direct synthesis inherently involves zero/pole cancellations,\n       \\item and an improper choice of $O^{\\circ}$ may give a non realisable controller,\n       \\item thus overall not all desired dynamics can be obtained.\n       \\end{itemize}\n \\item \\vfill An important by-product of a system-theoretical approach, is that\\\\\n       such limits can be set and discussed objectively.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Direct synthesis for set point tracking}\n\\framesubtitleTC{}\n\\myPause\n \\begin{center}\n  \\includegraphics[width=0.50\\columnwidth]{./Unit-04/img/ControlLoop-H1.pdf}\n \\end{center}\n \\begin{itemize}[<+-| alert@+>]\n \\item The target transfer function is $G_{yw}(z)$, that we set equal to a desired $G_{yw}^{\\circ}(z)$ writing\n       \\begin{displaymath} \n       \\frac{P(z)C(z)}{1+P(z)C(z)} = G_{yw}^{\\circ}(z).\n       \\end{displaymath}\n \\item Solving for $C(z)$ we get\n       \\begin{displaymath} \n        C(z) = \\frac{1}{P(z)} \\, \\frac{G_{yw}^{\\circ}(z)}{1-G_{yw}^{\\circ}(z)}.\n       \\end{displaymath}\n \\item Note the cancellation (the $1/P$ factor in $C$).\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Direct synthesis for disturbance rejection}\n\\framesubtitleTC{}\n\\myPause\n \\begin{center}\n  \\includegraphics[width=0.50\\columnwidth]{./Unit-04/img/ControlLoop-H1.pdf}\n \\end{center}\n \\begin{itemize}[<+-| alert@+>]\n \\item The target transfer function is $G_{yd}(z)$, that we set equal to a desired $G_{yd}^{\\circ}(z)$ writing\n       \\begin{displaymath} \n       \\frac{1}{1+P(z)C(z)} = G_{yd}^{\\circ}(z).\n       \\end{displaymath}\n \\item Solving for $C(z)$ we get\n       \\begin{displaymath} \n        C(z) = \\frac{1}{P(z)} \\, \\frac{1-G_{yd}^{\\circ}(z)}{G_{yd}^{\\circ}(z)}.\n       \\end{displaymath}\n \\item Note the cancellation (the $1/P$ factor in $C$).\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\\mccz\n\\frametitleTC{Direct synthesis}\n\\framesubtitleTC{Why ``PIDs on the horizon''?}\n\\myPause\n \\begin{columns}\n  \\column[T]{0.35\\textwidth}\n   \\only<2->{\\includegraphics[height=6cm]{./Unit-04/img/PIDsOnTheHorizon_cc0.jpg}}\n  \\column[T]{0.65\\textwidth}\n   \\begin{itemize}[<+-| alert@+>]\n   \\item Because applying direct synthesis to the versatile\\\\\n         model we used to generate a variety of responses,\\\\\n         with a sensible target transfer function, naturally\\\\\n         leads to a controller with two zeroes and two\\\\\n         poles, one of which in $z=1$.\n   \\item This is a PID controller.\n   \\item However we introduced a lot of material\\\\\n         in this lecture.\n   \\item Better take a breath, recap, ad go\\\\\n         through a practice session.\n   \\end{itemize}\n \\end{columns}\n\\end{frame}\n\n\n\n\n", "meta": {"hexsha": "46ab3275dce077cf616dc6131e36d31aca3f4d45", "size": 14728, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/Unit-04/sections/04-DirectSynthesis.tex", "max_stars_repo_name": "albertoleva/PID4CSE", "max_stars_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-19T16:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-19T16:38:10.000Z", "max_issues_repo_path": "slides/Unit-04/sections/04-DirectSynthesis.tex", "max_issues_repo_name": "albertoleva/PID4CSE", "max_issues_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/Unit-04/sections/04-DirectSynthesis.tex", "max_forks_repo_name": "albertoleva/PID4CSE", "max_forks_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6981132075, "max_line_length": 114, "alphanum_fraction": 0.6034763715, "num_tokens": 4813, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376236, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.42130540468366134}}
{"text": "\\graphicspath{{Pics/combi/graph/}}\n\n\\newpage\n\\section{Graph Theory}\n\n\\begin{take_note*}{Turning grids into graphs} \n    \\begin{itemize} \n        \\item One common way to turn a grid into graphs is to create a\n            bipartite graph between the columns and rows such that $ c_i $ and\n            $ r_j $ are connected iff $ (i, j) $ is marked. This way we can\n            find cycles alternating row and column.\n        \\item Creating a bipartite graph between all rows and columns and\n            particular objects. This helps to prove matching.  \n    \\end{itemize}\n\\end{take_note*}\n\n\n\\lem{Bipartite Graph}{\n    Any graph having only even cycles are \\emph{Bipartite}.\n\n    \\index[strat]{Graph!Bipartite}\n}\n\n\\begin{multicols}{2} \n    \\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=0pt, parsep=0pt,\n        font=\\footnotesize\\bfseries]\n        \\iref{problem:bipartite_graph_1}{AoPS}{}\n        \\iref{problem:bipartite_graph_2}{ISL 2004 C3}{}\n        \\iref{problem:bipartite_graph_3}{Problem}{}\n        \\iref{problem:bipartite_graph_4}{Problem}{} \n    \\end{enumerate}\n\\end{multicols}\n\n\n\\theo{http://www.ams.org/samplings/feature-column/fcarc-eulers-formula}\n{Euler's Polyhedron Formula}{\n    For any polyhedron with $ E, V, F $ edges, vertices's and faces resp. the\n    following relation holds \\[V+F=E+2\\]\\label{lemma:planar_graph_polyhedron} \n\n    In a planar graph with $ V $ vertices, $ E $ edges and $ C $ cycles, the\n    following condition is always satisfied:\n    \\[V+C=E+1\\]\\label{theorem:planar_graph_theorem}\n}\n\n\n\n\n\\lem{Criteria of partitioning a graph into disconnected sub-graphs}{\n    If there exist no three vertices, $u, v, w$ that $uv\\in E(G)$ also $uw,\n    vw\\in E(G)$, the graph can be partitioned into equivalence classes based\n    on their non-neighbors.\n\n    \\index[thm]{Non-Neighbor Equivalence Class}\n    \\label{lemma:criteria_of_partition_equiv}\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1063060p4609322}\n{China TST 2015 T1 D2 P3}{E}{\n    There are some players in a Ping Pong tournament, where\n    every $2$ players play with each other at most once. Given: \\vspace{-.9em}\n    \\begin{enumerate}  \n        \\item Each player wins against at least $a$ players, and loses to at\n            least $b$ players. ($a,b\\geq 1$) \n        \\item For any two players $A,B$, there exist some players\n            $P_1,...,P_k$ ($k\\geq 2$) (where $P_1=A$,$P_k=B$), such that $P_i$\n            wins against $P_{i+1}$ ($i=1,2...,k-1$) \n    \\end{enumerate} \n    \\vspace{-.9em} \n\n    Prove that there exist $a+b+1$ distinct players $Q_1,...Q_{a+b+1}$, such that\n    $Q_i$ wins against $Q_{i+1}$ ($i=1,...,a+b$).\n\n    \\index[strat]{Extremal!Longest Path!ChTST 2015 P3}\n}\n\n\\rem{Typical largest path, some workaround with given constraints problem.}\n\n\\solu{Take the largest path starting from $ a_1 $ to $ a_n $.\n    \\begin{soldef} \n        Assume that $ n\\le a+b $. Since this is the largest\n        path, $ a $ edges coming out of $ a_n $ are all in $ S=\\{a_1, a_2,\n        \\dots a_n\\} $, and $ b $ edges going in $ a_1 $ are all in $ S $. Let\n        $ S_1 $ be the set of vertices that $ a_n $ wins against, and $ S_2 $\n        be the set of vertices that $ a_1 $ loses against. Moreover, let $ a_l\n        $ be the smallest element of $ S_1 $, and $ a_{n-k} $ be the largest\n        element of $ S_2 $ (smallest means leftmost in the part, and largest\n        means rightmost).\\\\\n\n        Let $ S'=\\{a_l, a_{l+1}, \\dots a_{n-k-1}, a_{n-k}\\} $. Since $ n\\le\n        a+b $, we have $ S'\\ne \\varnothing $. \\\\\n\n        We also define: \\[ S_1'=\\{a_i\\mid a_i \\text{ defeats } a_{i+1} \\text{\n                where } a_{i+1} \\in S_1\\cap S' \\}\\] \\[S_2'=\\{a_i\\mid a_{i-1}\n        \\text{ defeats } a_{i} \\text{ where } a_{i-1} \\in S_2\\cap S'\\}\\]\n    \\end{soldef} \n\n    \\figdf{.4}{China_TST_2015_T1_D2_P3_1}{} \n\n    Now, note that for any $ x\\in S_2' $, $ y\\in S_1' $, there is a path\n    between $ x, y $ with $ n $ vertices. So for all $ x\\in S_2' $, there does\n    not exist a vertex outside of $ S $ that defeats $ x $. And for all $ y\\in\n    S_1' $, there doesn't exist a vertex outside of $ S $ that loses to $ y $,\n    because of the maximality of $ n $. \\\\\n\n    We show that, $ S_1'\\cap S_2' \\ne \\varnothing $. Then there would exist a\n    vertex that doesn't have any edge outside of $ S $, meaning it has at\n    least $ a+b $ games inside $ S $, proving the result.\\\\ \n\n    We have, $ S_1', S_2' \\subset S'\\cup\\{a_{l-1}, a_{n-k+1}\\} $. We have,\n    \\begin{align*} \n        |S_1'| &\\ge a-k+2\\quad [\\because a_n \\text{ has at most } k-2 \\text{\n        vertices in } \\{a_{n-k+1}, \\dots a_n\\}]\\\\ |S_2'| &\\ge b-l+3\n    \\end{align*} \n\n    But $ |S'|=n-(l-1)-(k)+2 \\le a+b-l-k+3 < |S_1'|+|S_2'| $. So $\n    S_1'\\cap S_2' \\ne \\varnothing $, and we are done.\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h35315p220222}\n{ARO 2005 P10.8}{E}{\n    A white plane is partitioned in to cells (in a usual way). A finite\n    number of cells are coloured black. Each black cell has an even (0, 2 or 4)\n    number of adjacent (by the side) white cells. Prove that one may colour each\n    white cell in green or red such that every black cell will have equal number\n    of red and green adjacent cells.\n\n    \\index[strat]{Graph!Grid $ \\to $ Graph!ARO 2005 P10.8}\n    \\index[strat]{Graph!Bipartite!ARO 2005 P10.8}\n}\n\n\\solu{\n    First we join the white cells like this: \n    \\figdf{.8}{ARO_2005_P10_8}{}\n    Now, notice that the plane have been divided into some cycles (a black\n    cell that has no adjacent black cells is a cycle itself). So we can color\n    the plane blue and yellow in a way that no region has the same color as\n    its neighbors. We can do this because at any junction, there are an even\n    number of regions connected because of the problem condition.\\\\\n\n    Now we focus on our graph that we created connected the white cells. Take\n    any cycle on it. If we have a ``slanted'' edge, then both of the nodes are\n    inside a region of either blue or yellow. But in a ``straight'' edge, the\n    two nodes are in different colored region.\\\\\n\n    We know that there are an even number of slanted edges, which is trivial\n    to prove (using the fact that any cycle on a grid system has even number\n    of nodes, and on these cycles, most of the edges (the straight ones) have\n    even lenght, but only the slanted one has odd lenghts on the sides). It is\n    also easy to see that there are an even number of straight edges, because\n    of going in and out of the regions of a fixed color.\\\\\n\n    So our cycle has an even number of nodes and thus bipartite. We can color the\n    graph with two colors, so that along each edge, the two nodes are of different\n    color.\n}\n\n\\rem{\n    There is a simple coloring using this solution. After we color the\n    regions of the plane with blue and yellow, we number each column with\n    integers. Then on the odd numbered columns, we color all the white cells that\n    are in yellow region green and blue region red. And on the even numbered\n    columns, we do the opposite. It is easy to check that this coloring works\n    using the graph we created before.\n}\n\n\n\n\\prob{https://atcoder.jp/contests/agc033/tasks/agc033_c}\n{AtCoder GC033 C}{E}{\n    Takahashi and Aoki will play a game on a tree. The tree has $ N $\n    vertices numbered $ 1 $ to $ N $, and the $ i $-th of the $ N-1 $ edges\n    connects Vertex $ a_i $ and Vertex $ b_i $\n\n    At the beginning of the game, each vertex contains a coin. Starting from\n    Takahashi, he and Aoki will alternately perform the following operation:\n\n    \\begin{itemize} \n        \\item Choose a vertex $ v $ that contains one or more\n            coins, and remove all the coins from $ v $.  \n        \\item Then, move each coin remaining on the tree to the vertex that is\n            nearest to $v$ among the adjacent vertices of the coin's current vertex.\n    \\end{itemize}\n\n    The player who becomes unable to play, loses the game. That is, the player who\n    takes his turn when there is no coin remaining on the tree, loses the game.\n    Determine the winner of the game when both players play\n    optimally.\n\n    \\index[strat]{Extremal!Longest Path!AtCoder GC033 C}\n    \\index[strat]{Invariant!Monovariant!AtCoder GC033 C}\n}\n\n\\solu{\n    First transform the game by removing the idea of coins, and replacing it\n    with deleting vertices. Now, notice that the longest path in this tree (i.e.\n    the diameter) strictly decreases by $ 1 $ or $ 2 $ each turn depending on the\n    move. So it's just a basic predetermined game.\n}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h514375p2889828}\n{ARO 1999 P9.8}{M}{\n    There are $2000$ components in a circuit, every two of which were\n    initially joined by a wire. The hooligans Vasya and Petya cut the wires one\n    after another. Vasya, who starts, cuts one wire on his turn, while Petya cuts\n    one or three. The hooligan who cuts the last wire from some component loses.\n    Who has the winning strategy?\n    \n    \\index[strat]{Algorithm!Copycat!ARO 1999 P9.8}\n}\n\n\\solu{[Copycat] \n    The P-Hooligan Petya has a winning strategy, for he can be\n    follow the old cunning trick of never losing. How does he do it?\n\n    He starts by secretly partitioning the vertices in two $ 1000 $ degree\n    subsets. He calls them $ A= \\{a_1, a_2\\dots a_{1000}\\} $ and $ B=\\{b_1,\n    b_2 \\dots b_{1000}\\} $. He then connects $ a_i $ with $ b_i $ with an edge\n    with an invisible marker that only he can see. \n\n    Now the game begins. Petya copies Vasyas moves following these rules:\n    \\begin{enumerate} \n        \\item If Vasya removes an edge $ a_i$ -- $a_j $, where $ i\\ne j $,\n            then Patya removes the edges $ a_i$ -- $b_j,\\ a_j$ -- $b_i$ and $\n            b_i$ -- $b_j $.  \n        \\item If Vasya removes $a_j$ -- $b_i$, where $ i\\ne j $, then Patya\n            removes the other three edges from the above rule.  \n        \\item If Vasya removes $ a_i $--$ b_i $, then Patya looks for another\n            $ b_j $, such that $ a_i $--$ b_j $ exists. Then by the symmetry\n            so far maintanined, $ a_j $--$ b_i $ and $ a_j $--$ b_j $ exist\n            too. And Patya can remove $ a_j$--$ b_j $, and swap the names of $\n            b_j $ and $ b_i $. \n\n            But if he can't, then that would mean after Vasya's move $ a_i $\n            would become isolated, and Patya would win.  \n    \\end{enumerate} \n\n    It is easy to see that the above moves are possible since Patya is always\n    maintaining symmetry between $ A, B $. So he can't move means Vasya has\n    already disconnected one of the vertices.\n}\n\n\n\\rem{\n    The case with $ 4 $ vertices and $ 6 $ vertices give an idea to copy the\n    opponent's moves.\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h17455p119177}\n{ISL 2001 C3}{E}{\n    Define a $ k $-clique to be a set of $ k $ people such that every pair\n    of them are acquainted with each other. At a certain party, every pair of $ 3\n    $-cliques has at least one person in common, and there are no $ 5 $-cliques.\n    Prove that there are two or fewer people at the party whose departure leaves\n    no $ 3 $-clique remaining.\n    \n    \\index[strat]{Extremal!Object!ISL 2001 C3}\n}\\label{problem:extreme_object_16}\n\n\\solu{Casework with the point where most of the triangles are joined.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1441121p8200413}\n{ARO 2017 P9.1}{E}{\n    In a country some cities are connected by one-way flights (there is\n    at most one flight between two cities). City $ A $ is called ``available\" from\n    city $B$, if there is a flight from $ B $ to $ A $, maybe with some\n    transits. It is known, that for every $2$ cities $P$ and $Q$, there\n    exists a city $R$, such that $P$ and $Q$ are both available from $R$.\n    Prove, that exist city $A$, such that every city is available from $A$.\n\n    \\index[strat]{Induction!ARO 2017 P9.1}\n}\\label{problem:induction_type1_3}\n\n\\solu{Basic induction exercise.}\n\n\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c4h365024p2006499}{Tournament\n    of Towns 2009 S6}{M}{\n    Anna and Ben decided to visit a country with $2009$ islands. Some pairs of\n    islands are connected by boats which run both ways. Anna and Ben are playing\n    during the trip:\n\n    Anna chooses the first island on which they arrive by plane. Then Ben chooses\n    the next island which they could visit. Thereafter, the two take turns\n    choosing an island which they have not yet visited. When they arrive at an\n    island which is connected only to islands they had already visited, whoever's\n    turn to choose next would be the loser. Prove that Anna could always win,\n    regardless of the way Ben played and regardless of the way the islands were\n    connected.\n    \n    \\index[strat]{CopyCat!ToT 2009 S6}\n}\n\n\\begin{solution}\n    The copycat idea, as always in games. How can Anna make sure she gets a\n    move after Ben? Maybe she can ``pair'' vertices and follow them along.\n    What happens if she tries this strategy?\n\\end{solution}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h598165p3549412}{USA TST 2014 P5}{M}{Find the maximum number $E$ such that the following holds: there is an edge-colored graph with $60$ vertices and $E$ edges, with each edge colored either red or blue, such that in that coloring, there is no monochromatic cycles of length $3$ and no monochromatic cycles of length $5$.}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\input{combi/sec5_1_counting_in_graph} \n\\input{combi/sec5_2_graph_alogrithm}\n", "meta": {"hexsha": "f3aad2d23ae256f83a33d63fca816b3df2f4dafd", "size": 13480, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combi/sec5_graph.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "combi/sec5_graph.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combi/sec5_graph.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 40.4804804805, "max_line_length": 372, "alphanum_fraction": 0.6678041543, "num_tokens": 4015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7931059487389968, "lm_q1q2_score": 0.42130531404864097}}
{"text": "\\documentclass[a4paper, 11pt]{article}\n\n% declare packages\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{bm}\n\\usepackage{amssymb}\n\\usepackage{array}   % write arrays in math mode\n\\usepackage[margin=10pt,font=small,labelfont=bf]{caption}\n% \\usepackage[onehalfspacing]{setspace} %[nosep] [noitemsep] [singlespacing] [doublespacing] (also can do /singlespacing within doc)\n\\usepackage{color}\n\\usepackage{comment} % enables the use of multi-line comments (\\ifx \\fi)  \n\\usepackage{enumitem}\n\\usepackage{fancyhdr}\n\\usepackage{footmisc} %  formatting for footnotes\n\\usepackage{fullpage} %  changes the margin\n\\usepackage{geometry} %  change length & layout of elements\n\\usepackage{graphicx} % embed graphics\n\\usepackage{hyperref}\n\\usepackage{mathtools} \n\\usepackage{multirow}\n\\usepackage[round,sort,comma]{natbib}   % citation formatting\n\\usepackage{pdflscape} % make pages landscape in pdf\n\\usepackage{pdfpages}\n% \\usepackage{subcaption}\n\\usepackage{subfigure}\n\\usepackage{subfloat}   %figure 1a 1b with \\begin{subfigures}\n\\usepackage{ulem} %underlining and strikethroughs\n\\usepackage[yyyymmdd,hhmmss]{datetime}\n\n% declare extra commands\n\\DeclarePairedDelimiter\\abs{\\lvert}{\\rvert}%\n\\DeclarePairedDelimiter\\norm{\\lVert}{\\rVert}%\n\\DeclareMathOperator*{\\argmin}{\\arg\\!\\min}\n\\DeclareMathOperator*{\\argmax}{\\arg\\!\\max}\n\n% Other formatting options\n\\pagestyle{fancy}\n\\fancyhf{}\n\\renewcommand{\\headrulewidth}{0pt}\n\\rfoot{Compiled on \\today\\ at \\currenttime}\n\\cfoot{}\n\\lfoot{Page \\thepage}\n\\newcolumntype{L}[1]{>{\\raggedright\\let\\newline\\arraybackslash\\hspace{0pt}}m{#1}} %used for array package\n\\newcolumntype{C}[1]{>{\\centering\\let\\newline\\arraybackslash\\hspace{0pt}}m{#1}}\n\\newcolumntype{R}[1]{>{\\raggedleft\\let\\newline\\arraybackslash\\hspace{0pt}}m{#1}}\n\\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}\n\n\\begin{document}\n% puts extra whitespace at top of first page\n% \\begin{tabbing}\n% \\end{tabbing}\n\n\\normalsize  \\strut\\hfill \\textbf{John Stromme} \\\\\n\\normalsize  \\strut\\hfill  Date: 07/21 \\\\\n\n\\noindent\n\\huge \\textbf{Do the Bucks actually `play random'?} \\\\\n\\textit{An empirical analysis} \\\\\n\n\\normalsize\n\nDuring halftime in games 1 and 2 of the Finals coach Bud implored his players to `play random'\\footnote{\\url{https://www.reddit.com/r/nba/comments/ogm608/highlight_mike_budenholzers_game_2_nba_finals/}}. Many internet commentators found this advice to be quite strange and atypical---`play random' is not usually in the wheelhouse of advice that coaches give in rousing halftime speeches. This naturally leads us to two questions: Are the Bud-coached Bucks indeed more likely to `play random' than the other 29 teams in the league? Do teams who `play random' tend to win more games?\n\nTo answer these questions, I created a measure of `randomness' of play along two-dimensions using data from the 2019--20 and 2020--21 seasons. On one dimension, teams can be `random' in how far they are from the basket when they have a shot-attempt. A team with more varied shot selection by distance will be much more `random' and unpredictable. On the second dimension, teams can be `random' on \\textit{when} they choose to shoot during a possession. Again, a team that is more varied in when they take there shots during a possession will be more `random' and unpredictable than a team who always shoots at a similar point in the shot clock.\n\nFigure \\ref{fig:randomgini} shows where each team falls along both dimensions of `randomness': Teams towards the top-right play more `randomly', whereas teams towards the bottom-left play more `predictably'. The bucks play more randomly on both measures than an the nba average. They rank more highly in playing randomly in shot distance, but are closer to the average in shot timing.\n\n\\begin{figure}[!htpb]\n  \\centering \\includegraphics[width=0.6\\textwidth]{../plots_tables/randomginiplot.jpg}\n  \\caption{}\\label{fig:randomgini}\n\\end{figure}\n\n\n\n\n\\section*{Is `playing random' correlated with winning?}\nIt may or may not be a good idea to play `randomly' given that each game a team should exploit opportunities based on matchup. It seems likely there is a tradeoff between exploiting opponent's weaknesses and playing random---more strategic play would be less random. To investigate this I look at the correlation between wins and the above measures of randomness. I find that correlation for each measure is negative: -0.182 for shot distance and -0.235 for shot timing. This implies playing random is associated with losing more games, albeit this correlation is somewhat weak, and no causality is implied.\n\n\\section*{Methodology}\nFor each dimension of randomness, we can think of there being $n$ possible outcomes. For example, a team can choose to shoot at any of the 24 seconds in the shot clock ($n=24$), or at any distance from the basket i.e., between 0--40 feet ($n=40$). If a team is perfectly predictable, they will shoot every shot at the same distance, at the same time in the shot clock. On the opposite end, teams that are most `random' will have an even distribution of shots across distance and time.\n\nA natural measure for this definition of `randomness' is the Gini Coefficient. The Gini coefficient is traditionally used as a measure of income inequality across a population, but can be repurposed anywhere we care about how evenly distributed some piece of data is among some categories or options.\n\nIn this application, I'll use what I call the `inverse-Gini Coefficient': the higher the inverse-Gini, the more `random' the team's play is. When the inverse-Gini Coefficient is equal to one, there is an even distribution across possibilities, which, as described in the previous paragraph, is most `random'. At the other extreme, if a team were to only shoot at one distance from the basket (least `random') the inverse-Gini Coefficient would be zero. For the math nerds the formula is further below. %For this analysis, the inverse-Gini Coefficient is multiplied by 100 for easier reading.\n\n\\subsection*{The Nitty Gritty}\n\\noindent\\textbf{A note on notation:} For each measure we can use $n$ to represent the number of `options' a team has, and $x_i$ to represent the number of times a team chose option $i$.\\\\\n\n\\noindent \\textbf{Shot distance randomness:} Teams can choose to shoot from one of $n=28$ discrete shot distances, either shooting between 0--26 feet, or from `deep' which is a single category for any shot between 27--40 feet. Any shot over 40 feet is dropped from the data. Using the notation defined above, this means that $x_0$ would measure the number of times over a season a team shot from 0-feet.\\\\\n\n\\noindent\\textbf{Shot timing randomness:} Teams can choose to shoot from one of $n=20$ times during the shot clock, i.e., at any point between 19--0 seconds left on the shot clock. The first 5 seconds of the shot clock, 24--20, are dropped as a standard length of time to get the ball over halfcourt. Again using the above notation, in this case $x_0$ would measure the number of times over a season a team made a shot attempt with zero seconds left on the shot clock. To keep the analysis simpler, and also due to shot clock data limitation, I only include shot attempts which are the first attempt during a team's possession that started with a fresh 24 on the clock. It does not matter what the outcome of the shot is---make, miss, foul---this is a measure of randomness in attempt.\\\\\n\n\n\\noindent\\textbf{The fine print:}\nFormula for inverse-Gini Coefficient:\n$$G= 1-\\frac{\\sum_i \\sum_j |x_i - x_j|}{2 n^2 \\bar{x}} $$\n\nWhen we use this version of the Gini coefficient, i.e., when we have discrete outcomes, technically the maximum value the Gini can take on is $\\frac{n-1}{n}$ which is only equal to 1 at the limit. Therefore, in our finite settings the Gini range of possibilities will actually be 0--$\\frac{n-1}{n}$, rather than 0--1.\n\nI use the `inverse'-Gini rather than the typical Gini coefficient, because I want a measure of `randomness' where higher values mean there is more randomness. To do this, we need to tack on a $1-$ to invert the values of the Gini Coefficient.\n\n\n\\newpage\n\\input{../plots_tables/ginitable.tex}\n\n\n\n\n\n% \\bibliographystyle{authordate1} %uncomment if using bibliography\n\\setlength\\bibsep{0pt}\n\\nocite{*}\n\\bibliography{Placeholder} %don't forget need to run bibtex after latex compilation...\n\n\\end{document}", "meta": {"hexsha": "56c098a291b57d6d044549e2facbe6c81b7e8407", "size": 8328, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/whoplaysrandom.tex", "max_stars_repo_name": "jrstromme/nba-randomness", "max_stars_repo_head_hexsha": "01ac55aecdd15b08eab5e7b0b0316c74b576ae72", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/whoplaysrandom.tex", "max_issues_repo_name": "jrstromme/nba-randomness", "max_issues_repo_head_hexsha": "01ac55aecdd15b08eab5e7b0b0316c74b576ae72", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/whoplaysrandom.tex", "max_forks_repo_name": "jrstromme/nba-randomness", "max_forks_repo_head_hexsha": "01ac55aecdd15b08eab5e7b0b0316c74b576ae72", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.7931034483, "max_line_length": 787, "alphanum_fraction": 0.7729346782, "num_tokens": 2223, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.4212438116894969}}
{"text": "\\documentclass[a4paper,english]{article}\n\n\\usepackage{fullpage}\n\n%%%%%%%%%%%%%%%%%%%%%%%% TEX FONTS AND LANGUAGE\n% This is the new Latin Modern fonts (by Knuth)\n\\usepackage{lmodern}\n% All the above merge well (IMHO) with the Euler family of\n% mathematical fonts (by H. Zapf)\n\\usepackage{amsfonts}\n%to best use the above, you have to switch to T1\n\\usepackage[T1]{fontenc}\n% (Note that LaTeX still defaults to OT1, to be compatible with\n%  old files; but nowadays you definitively want to use T1.)\n\\usepackage[utf8]{inputenc}\n\\usepackage{babel}\n\n\n\n\\usepackage{amsmath,amssymb,amsthm}\n\n\n\\usepackage{graphicx,color,hyperref}\n\n\\begin{document}\n\n\\begin{center}\\Large\n  Non-destructive encoder flushing for ``arithmetic coding''\\\\\n  Andrea C. G. Mennucci\n  \\footnote{Scuola Normale Superiore, Pisa, Italy}\n  \\\\\n  \\today\n\\end{center}\n\n\\section{Introduction}\n\nIn this short essay we discuss \\emph{arithmetic coding}, as described in\n\\cite{witten1987arithmetic}.\n(The reference implementation is the code in \\texttt{ArithCodeTut}\n\\footnote{\\url{https://github.com/mennucc/ArithCodeTut.git}} in \\texttt{github.com}).\n\nIn particular we discuss the problem of \\emph{flushing}: a method implemented\nin the encoder that makes sure that the decoder has received all previously\nencoded symbols.\n\nIn \\cite{witten1987arithmetic}, in the section \\emph{``Termination''}, the authors write\n\\footnote{Rephrased for clarity}:\n\\emph{To finish the transmission, it is necessary to send\n  [\\ldots]  enough bits to ensure that the encoded string falls\n  within the finale range. [\\ldots] The encoder  need only transmit 01 if\n\\texttt{Low} < \\texttt{First\\_qtr}, or 10 otherwise.}\n\n\n\n\\smallskip\n\nWhile this approach  works, it has a defect: after that sequence\nis emitted, it is unclear how the encoder could encode more symbols\nand send more bits to the decoder.\n\n\nThis may property may be of interest in some cases: indeed the Decoder\ncan have an arbitrarily large delay in decoding the symbols\nthat the encoder has already seen.\n(See next section). So a periodic flushing may be desirable\n--- as long as encoding/decoding can proceed after flushing.\n\n\\medskip\n\nIn the following a \\emph{Bernoulli symbol} is a symbol that has two choices, such as $0,1$ or\n$a,b$, each choice with probability 1/2 (unless otherwise stated).\n\n\\medskip\n\nThe questions now is: can we justify the flushing output of the\nencoder as result of an input, let's say as iid Bernoulli symbols?\n\n\n\n\n\n\\section{Example}\n\nWe model the encoder as follows.\n\nLet $[\\alpha_j,\\beta_j)$ the symbol interval\nstored in the Encoder after inserting  the j-th symbol using \\texttt{input\\_symbol()}:\nthe encoder is in \\emph{dirty state}.\nLet $[\\tilde \\alpha_j,\\tilde \\beta_j]$\nthe symbol interval after the Encoder has emitted all bits (either by callback, or by polling),\nso the Encoder is in \\emph{clean state}: at this point\neither\n\\[ 0\\le \\tilde \\alpha_j< 1/4 \\land 1/2\\le \\tilde \\beta_j\\le 1\\]\n(condition (1a) in \\cite{witten1987arithmetic})\nor\n\\[0\\le \\tilde \\alpha_j< 1/2 \\land 3/4\\le\\tilde \\beta_j\\le 1\\]\n(condition (1b) in \\cite{witten1987arithmetic})\n%(up to some equalities)\n\nNow suppose this happens.\n\nThe encoder receives many symbols, say $N$, but it does not emit any bit,\nneither store any virtual bits in \\texttt{bits\\_to\\_follow},\nbecause\n\\[ 0\\le \\alpha_j< 1/4\\land 1/2\\le \\beta_j\\le 1\\] at all $j\\le N$;\nso $\\tilde\\alpha_j=\\alpha_j$, $\\tilde\\beta_j=\\beta_j$.\n(A symmetric situation is possible)\n\nAt that time the decoder is still at the pristine state $[0,1]$.\n\n\\smallskip\n\nWe suppose that the decoder knows that it will be flushed after receiving N symbols;\neither because this number was passed in a header of the encoded\nfile, or because the N-th symbol is a special \\texttt{WILL\\_FLUSH} symbol\n(similarly to the \\texttt{EOF} symbol in  \\cite{witten1987arithmetic}).\n\n\\smallskip\n\nThe encoder is then flushed, so that it emits enough bits so that the\ndecoder can decode the N symbols. Since $\\alpha_N< 1/4$, then the\nencoder sends a 0 and then a 1 (and would send\n\\texttt{bits\\_to\\_follow} other ones, but in this example there are no\nvirtual bits, for simplicity).\n\nThe decoder bit interval is now\n\\[ [1/4, \\, 1/2) = [ 0.01000\\ldots 0 , \\, 0.0111\\ldots 1] \\]\n(where on the right we express the binary representation of the interval in the algorithm);\nthe decoder understands all symbols up to symbol $N$:\nindeed there is only one string of symbols such that $[\\alpha_N,\\beta_N]\\supseteq [1/4,\\, 1/2]$\n\n\\section{Non-destructive flushing}\n\n\\subsection{Low case}\nWe consider the case\n\\[ 0\\le \\alpha_N< 1/4\\land 1/2\\le \\beta_N\\le 1\\quad.\\]\n\nWe wish explain the sequence ``01'' that the Encoder has sent for flushing,\nas the encoding of 3 i.i.d Bernoulli symbols.\nFor simplicity though we express it as the sending of one symbol $s$ uniformly\ndistributed in $\\{0,1,2,3,4,5,6,7\\}$: this symbol indeed is equivalent\nto ``3 input bits''\n(up to numerical approximation).\n\nSo\n\\[\\alpha_{N+1}= \\alpha_N+\\frac{7-s}{8}(\\beta_N-\\alpha_N)  \\quad,\\quad\n  \\beta_{N+1}=\\alpha_N+\\frac{8-s}{8}(\\beta_N-\\alpha_N)\\]\n(we follow the convention of  \\cite{witten1987arithmetic}, that\nsubintervals are in decreasing order as $s$ increases --- this is also\nthe convention used in the reference code).\n\nSince the width of $[\\alpha_N,\\beta_N]$ is at most 1,\nthen the width of any subinterval  $[\\alpha_{N+1},\\beta_{N+1}]$\nis at most $1/8$;\nso there must exist a choice of $s$ such that  $[\\alpha_{N+1},\\beta_{N+1}]$\nis contained in \n\\[ [1/4, \\, 1/2) = [ 0.01000\\ldots 0 , \\, 0.0111\\ldots 1] \\]\n(that has width $1/4$).\n\nWe will show that a possible choice is\n\\[s = \\left\\lfloor \\frac{8 \\beta_N - 2}{(\\beta_N-\\alpha_N) }\\right\\rfloor - 1 \\]\n\nHence, if we input that symbol in the encoder after the $N$-th symbol,\nwe will obtain two important results:\n\\begin{itemize}\n\\item the Encoder will emit $01$, that will flush the system\n  (it may emit a further bit; we skip the discussion);\n\\item the Decoder will be able to decode the symbol,\n  and Encoding/Decoding may proceed behind the flush.\n\\end{itemize}\n\n\\begin{proof}\nTo be consistent with what the decoder is receiving\n\\begin{align}\n  1/4\\le   \\alpha_{N+1} \\quad,\\quad \\beta_{N+1}< 1/2\n\\end{align}\nthat is\n\\begin{align*}\n  1/4\\le   \\alpha_{N+1}\n  \\iff \\\\\n  1/4\\le  \\alpha_N+\\frac{7-s}{8}(\\beta_N-\\alpha_N)\n  \\iff \\\\\n  \\frac{2- 8 \\alpha_N}{(\\beta_N-\\alpha_N) } \\le  7-s\n  \\iff \\\\\n  \\frac{2-  \\alpha_N - 7 \\beta_N}{(\\beta_N-\\alpha_N) } \\le  -s\n  \\iff \\\\\n  s\\le  \\frac{-2+  \\alpha_N + 7 \\beta_N}{(\\beta_N-\\alpha_N) } =  \\frac{8 \\beta_N - 2}{(\\beta_N-\\alpha_N) } - 1\n\\end{align*}\nwhereas\n\\begin{align*}\n  \\beta_{N+1}< 1/2\n  \\iff \\\\\n  \\alpha_N+\\frac{8-s}{8}(\\beta_N-\\alpha_N) < 1/2\n  \\iff\\\\\n  8 -s < \\frac{{4 - 8 \\alpha_N}}{(\\beta_N-\\alpha_N)}\n  \\iff \\\\\n   -s < \\frac{{4 - 8 \\beta_N}}{(\\beta_N-\\alpha_N)}\n  \\iff \\\\\n   s > \\frac{{8 \\beta_N - 4}}{(\\beta_N-\\alpha_N)}\n\\end{align*}\nsummarizing\n\\begin{equation}\n  \\frac{{8 \\beta_N - 4}}{(\\beta_N-\\alpha_N)} <  s\\le  \\frac{8 \\beta_N - 2}{(\\beta_N-\\alpha_N) } - 1\\label{eq:low_s_ineq}\n\\end{equation}\n\nWe double-check that the interval contains an integer, indeed the difference of the extremes is\n\\[    \\frac{2}{(\\beta_N-\\alpha_N) } - 1 \\ge  1 \\]\n\\end{proof}\n\n\n\\subsection{Examples}\n\nSome examples of\npossible values of\n\\[s = \\left\\lfloor \\frac{8 \\beta_N - 2}{(\\beta_N-\\alpha_N) }\\right\\rfloor - 1 \\]\n\\begin{itemize}\n\\item If $\\alpha_N=1/4$ then\n  \\[ \\frac{8 \\beta_N - 2}{(\\beta_N-1/4) } = 8\\]\n  so $s=7$, regardless of $\\beta_N$.\n\n\n\\item If $\\alpha_N=0$\n  \\[ \\frac{8 \\beta_N - 2}{\\beta_N } = 8 - \\frac{2}{\\beta_N }\\]\n  so\n  \\[s = 7 - \\left\\lceil \\frac{2}{\\beta_N }\\right\\rceil \\quad, \\]\n  so $s\\in\\{5,6,7\\}$;\n\\item in particular if if $\\beta_N=1, \\alpha_N=0$ then $s=5$.\n\\end{itemize}\n\n\n\\subsection{High case}\nWe consider the case\n\\[ 0\\le \\alpha_N< 1/2\\land 3/4\\le  \\beta_N\\le 1\\quad.\\]\nIn this case the encoder emits $10$; a good choice is\n\\[s = \\left\\lfloor \\frac{8 \\beta_N - 4}{(\\beta_N-\\alpha_N) }\\right\\rfloor - 1 \\]\n\\begin{proof}\nTo be consistent with what the decoder is receiving\n\\begin{align}\n  1/2\\le   \\alpha_{N+1} \\quad,\\quad \\beta_{N+1}< 3/4\n\\end{align}\nthat is\n\\begin{align*}\n  1/2\\le   \\alpha_{N+1}\n  \\iff \\\\\n  1/2\\le  \\alpha_N+\\frac{7-s}{8}(\\beta_N-\\alpha_N)\n  \\iff \\\\\n  \\frac{4- 8 \\alpha_N}{(\\beta_N-\\alpha_N) } \\le  7-s\n  \\iff \\\\\n  \\frac{4-  \\alpha_N - 7 \\beta_N}{(\\beta_N-\\alpha_N) } \\le  -s\n  \\iff \\\\\n  s\\le  \\frac{-4+  \\alpha_N + 7 \\beta_N}{(\\beta_N-\\alpha_N) } =  \\frac{8 \\beta_N - 4}{(\\beta_N-\\alpha_N) } - 1\n\\end{align*}\nwhereas\n\\begin{align*}\n  \\beta_{N+1}< 3/4\n  \\iff \\\\\n  \\alpha_N+\\frac{8-s}{8}(\\beta_N-\\alpha_N) < 3/4\n  \\iff\\\\\n  8 -s < \\frac{{6 - 8 \\alpha_N}}{(\\beta_N-\\alpha_N)}\n  \\iff \\\\\n   -s < \\frac{{6 - 8 \\beta_N}}{(\\beta_N-\\alpha_N)}\n  \\iff \\\\\n   s > \\frac{{8 \\beta_N - 6}}{(\\beta_N-\\alpha_N)}\n\\end{align*}\nsummarizing\n\\begin{equation}\n  \\frac{{8 \\beta_N - 6}}{(\\beta_N-\\alpha_N)} <  s\\le  \\frac{8 \\beta_N - 4}{(\\beta_N-\\alpha_N) } - 1\\label{eq:high_s_ineq}\n\\end{equation}\n\nWe double-check that the interval contains an integer, indeed the difference of the extremes is\n\\[    \\frac{2}{(\\beta_N-\\alpha_N) } - 1 \\ge  1 \\]\n\\end{proof}\n\n\n\\subsection{Remark on symmetry}\nSuppose\n\\[ 0\\le \\hat \\alpha_N< 1/2\\land 3/4\\le \\hat \\beta_N\\le 1\\quad.\\]\nThis is symmetric of the ``low'' case, up to defining\n\\[\\hat\\alpha_j=1-\\beta_j\\quad,\\quad \\hat \\beta_j = 1 - \\alpha_j \\]\nby defining $\\hat s=8-s$\nthe inequality\n\\eqref{eq:low_s_ineq}\nbecomes  the inequality\n\\eqref{eq:high_s_ineq};\nbut the role of $\\le$ and $<$ is inverted.\n\n\n\n\n\n\\providecommand{\\bysame}{\\leavevmode\\hbox to3em{\\hrulefill}\\thinspace}\n\\begin{thebibliography}{1}\n\\bibitem{witten1987arithmetic}\nIan~H Witten, Radford~M Neal, and John~G Cleary.\n\\newblock Arithmetic coding for data compression.\n\\newblock {\\em Communications of the ACM}, 30(6):520--540, 1987.\n\n\\end{thebibliography}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "094761c99472023e1dea583d48499d9862409aee", "size": 9794, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/on_deflushing.tex", "max_stars_repo_name": "mennucc/ArithCodeTut", "max_stars_repo_head_hexsha": "32cfda414315aee4fa6d78ccf60a95649ca9f148", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/on_deflushing.tex", "max_issues_repo_name": "mennucc/ArithCodeTut", "max_issues_repo_head_hexsha": "32cfda414315aee4fa6d78ccf60a95649ca9f148", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/on_deflushing.tex", "max_forks_repo_name": "mennucc/ArithCodeTut", "max_forks_repo_head_hexsha": "32cfda414315aee4fa6d78ccf60a95649ca9f148", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3234323432, "max_line_length": 121, "alphanum_fraction": 0.6915458444, "num_tokens": 3377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.4212438116894969}}
{"text": "\\par\n\\vfill \\eject\n\\section{MPI Solution of $A X = Y$ using an $LU$ factorization}\n\\label{section:LU-MPI}\n\\par\nUnlike the serial and multithreaded environments where the data\nstructures are global, existing under one address space, \nin the MPI environment, data is local, each process or processor\nhas its own distinct address space.\nThe MPI step-by-step process to solve a linear system is exactly\nthe same as the multithreaded case, with the additional trouble\nthat the data structures are distributed and need to be\nre-distributed as needed.\n\\par\nThe ownership of the factor matrices during the factorization and\nsolves is exactly the same as for the multithreaded case -- the\nmap from fronts to processors and map from submatrices to\nprocessors are identical to their counterparts in the multithreaded\nprogram.\nWhat is different is the explicit message passing of data\nstructures between processors.\nLuckily, most of this is hidden to the user code.\n\\par\nWe will now begin to work our way through the program \nfound in Section~\\ref{section:LU-MPI-driver}\nto illustrate the use of {\\bf SPOOLES} to solve a system \nof linear equations in the MPI environment.\n\\par\n\\subsection{Reading the input parameters}\n\\label{subsection:MPI:input-data}\n\\par\nThis step is identical to the serial code, as described in\nSection~\\ref{subsection:serial:input-data}, with the exception\nthat the file names for $A$ and $Y$ are hardcoded in the driver,\nand so are not part of the input parameters.\n\\par\n\\subsection{Communicating the data for the problem}\n\\label{subsection:MPI:communicating-data}\n\\par\nThis step is identical to the serial code, as described in\nSection~\\ref{subsection:serial:communicating-data}\nIn the serial and multithreaded codes, the entire matrix $A$ was\nread in from one file and placed into one {\\tt InpMtx} object.\nIn the MPI environment, this need not be the case that one\nprocessor holds the entire matrix $A$.\n(In fact, $A$ must be distributed across processors during the\nfactorization.)\n\\par\nEach processor opens a matrix file, (possibly) reads in matrix\nentries, and creates its {\\it local} {\\tt InpMtx} object that holds\nthe matrix entries it has read in.\nWe have hardcoded the file names: processor $q$ reads \nits matrix entries from file {\\tt matrix.}$q${\\tt .input}\nand\nits right hand side entries from file {\\tt rhs.}$q${\\tt .input}.\nThe file formats are the same as for the serial and multithreaded\ndrivers.\n\\par\nThe entries needed not be partitioned over the files.\nFor example, each processor could read in entries for disjoint sets\nof finite elements.\nNaturally some degrees of freedom will have support on elements\nthat are found on different processors.\nWhen the entries in $A$ and $Y$ are mapped to processors, an\nassembly of the matrix entries will be done automatically.\n\\par\nIt could be the case that the matrix $A$ and right hand side $Y$\nare read in by one processor. (This was the approach we took with\nthe {\\tt LinSol} wrapper objects.)\nThere still need to be input files for the other processors\nwith zeroes on their first (and only) line, \nto specify that no entries are to be read.  \n\\par\n\\subsection{Reordering the linear system}\n\\label{subsection:MPI:reordering}\n\\par\nThe first part is very similar to the serial code, as described in\nSection~\\ref{subsection:serial:reordering}.\n\\begin{verbatim}\ngraph = Graph_new() ;\nadjIVL = InpMtx_MPI_fullAdjacency(mtxA, stats, msglvl, msgFile, MPI_COMM_WORLD) ;\nnedges = IVL_tsize(adjIVL) ;\nGraph_init2(graph, 0, neqns, 0, nedges, neqns, nedges, adjIVL, NULL, NULL) ;\nfrontETree = orderViaMMD(graph, seed + myid, msglvl, msgFile) ;\n\\end{verbatim}\nWhile the data and computations are distributed across the\nprocessors, the ordering process is not.\nTherefore we need a global graph on each processor.\nSince the matrix $A$ is distributed across the processors, \nwe use the distributed {\\tt InpMtx\\_MPI\\_fullAdjacency()} method \nto construct the {\\tt IVL} object of the graph of $A + A^T$.\n\\par\nAt this point, each processor has computed its own minimum degree\nordering and created a front tree object.\nThe orderings will likely be different, because each processors\ninput a different random number seed to the ordering method.\nOnly one ordering can be used for the factorization, so the\nprocessors collectively determine which of the orderings is best, \nwhich is then broadcast to all the processors, as the code fragment\nbelow illustrates.\n\\begin{verbatim}\nopcounts = DVinit(nproc, 0.0) ;\nopcounts[myid] = ETree_nFactorOps(frontETree, type, symmetryflag) ;\nMPI_Allgather((void *) &opcounts[myid], 1, MPI_DOUBLE,\n              (void *) opcounts, 1, MPI_DOUBLE, MPI_COMM_WORLD) ;\nminops = DVmin(nproc, opcounts, &root) ;\nDVfree(opcounts) ;\nfrontETree = ETree_MPI_Bcast(frontETree, root, msglvl, msgFile, MPI_COMM_WORLD) ;\n\\end{verbatim}\n\\par\n\\subsection{Non-numeric work}\n\\label{subsection:MPI:non-numeric}\n\\par\nOnce the front tree is replicated across the processors, we obtain\nthe permutation vectors and permute the vertices in the front tree.\nThe local matrices for $A$ and $Y$ are also permuted.\nThese steps are identical to the serial and multithreaded drivers,\nexcept the fact local instead of global $A$ and $Y$ matrices \nare permuted.\n\\begin{verbatim}\noldToNewIV = ETree_oldToNewVtxPerm(frontETree) ;\nnewToOldIV = ETree_newToOldVtxPerm(frontETree) ;\nETree_permuteVertices(frontETree, oldToNewIV) ;\nInpMtx_permute(mtxA, IV_entries(oldToNewIV),\nIV_entries(oldToNewIV)) ;\nif (  symmetryflag == SPOOLES_SYMMETRIC || symmetryflag == SPOOLES_HERMITIAN ) {\n   InpMtx_mapToUpperTriangle(mtxA) ;\n}\nInpMtx_changeCoordType(mtxA, INPMTX_BY_CHEVRONS) ;\nInpMtx_changeStorageMode(mtxA, INPMTX_BY_VECTORS) ;\nDenseMtx_permuteRows(mtxY, oldToNewIV) ;\n\\end{verbatim}\n\\par\nThe next step is to obtain the map from fronts to processors,\njust as was done in the multithreaded driver.\nIn addition, we need a map from vertices to processors to be able\nto distribute the matrix $A$ and right hand side $Y$ as necessary.\nSince we have the map from vertices to fronts inside the front tree\nobject, the vertex map is easy to determine.\n\\begin{verbatim}\ncutoff   = 1./(2*nproc) ;\ncumopsDV = DV_new() ;\nDV_init(cumopsDV, nproc, NULL) ;\nownersIV = ETree_ddMap(frontETree, type, symmetryflag, cumopsDV, cutoff) ;\nDV_free(cumopsDV) ;\nvtxmapIV = IV_new() ;\nIV_init(vtxmapIV, neqns, NULL) ;\nIVgather(neqns, IV_entries(vtxmapIV), IV_entries(ownersIV), ETree_vtxToFront(frontETree)) ;\n\\end{verbatim}\nAt this point we are ready to assemble and distribute the entries\nof $A$ and $Y$.\n\\begin{verbatim}\nfirsttag = 0 ;\nnewA = InpMtx_MPI_split(mtxA, vtxmapIV, stats, msglvl, msgFile, firsttag,\nMPI_COMM_WORLD) ;\nInpMtx_free(mtxA) ;\nmtxA = newA ;\nInpMtx_changeStorageMode(mtxA, INPMTX_BY_VECTORS) ;\nnewY = DenseMtx_MPI_splitByRows(mtxY, vtxmapIV, stats, msglvl, \n                                msgFile, firsttag, MPI_COMM_WORLD) ;\nDenseMtx_free(mtxY) ;\nmtxY = newY ;\n\\end{verbatim}\nThe {\\tt InpMtx\\_MPI\\_split()} method assembles and redistributes\nthe matrix entries by the vectors of the local matrix.\nRecall above that the coordinate type was set to chevrons, as is\nneeded for the assembly of the entries into the front matrices.\nThe method returns a new {\\tt InpMtx} object that contains the part\nof $A$ that is needed by the processor.\nThe old {\\tt InpMtx} object is free'd and the new one takes its place.\n\\par\nNow we are ready to compute the symbolic factorization, but it too\nmuch be done in a distributed manner.\n\\begin{verbatim}\nsymbfacIVL = SymbFac_MPI_initFromInpMtx(frontETree, ownersIV, mtxA,\n                    stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\n\\end{verbatim}\nThe {\\tt symbfacIVL} object on a particular processor is only a\nsubset of the global symbolic factorization, containing only what\nit needs to know for it to compute its part of the factorization.\n\\par\n\\subsection{The Matrix Factorization}\n\\label{subsection:MPI:factor}\n\\par\nIn contrast the the multithreaded environment, data structures are\nlocal to a processor, and so locks are not needed to manage access\nto critical regions of code.\nThe initialization of the front matrix and submatrix manager\nobjects is much like the serial case, with one exception.\n\\par\n\\begin{verbatim}\nmtxmanager = SubMtxManager_new() ;\nSubMtxManager_init(mtxmanager, NO_LOCK, 0) ;\nfrontmtx = FrontMtx_new() ;\nFrontMtx_init(frontmtx, frontETree, symbfacIVL, type, symmetryflag,\n              FRONTMTX_DENSE_FRONTS, pivotingflag, NO_LOCK, myid,\n              ownersIV, mtxmanager, msglvl, msgFile) ;\n\\end{verbatim}\nNote that the nineth and tenth arguments are {\\tt myid} and {\\tt\nownersIV}, not {\\tt 0} and {\\tt NULL} as for the serial and\nmultithreaded drivers.\nThese arguments tell the front matrix object \nthat it needs to initialize only\nthose parts of the factor matrices that it ``owns'', \nwhich are given by the map from fronts to processors \nand the processor id.\n\\par\nThe numeric factorization is performed by the\n{\\tt FrontMtx\\_MPI\\_factorInpMtx()} method.\nThe code segment from the sample program for the numerical\nfactorization step is found below.\n\\begin{verbatim}\nchvmanager = ChvManager_new() ;\nChvManager_init(chvmanager, NO_LOCK, 0) ;\nrootchv = FrontMtx_MPI_factorInpMtx(frontmtx, mtxA, tau, droptol,\n                     chvmanager, ownersIV, lookahead, &error, cpus,\n                     stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nChvManager_free(chvmanager) ;\n\\end{verbatim}\nNote that the {\\tt ChvManager} is not locked.\nThe calling sequence is identical to that of \nthe multithreaded factorization except for the addition of the {\\tt\nfirsttag} and MPI communicator at the end.\n\\par\nThe post-processing of the factorization is the same in principle\nas in the serial code but differs in that is uses the distributed\ndata structures.\n\\begin{verbatim}\nFrontMtx_MPI_postProcess(frontmtx, ownersIV, stats, msglvl,\n                         msgFile, firsttag, MPI_COMM_WORLD) ;\n\\end{verbatim}\nAfter the post-processing step, each local {\\tt FrontMtx} object \ncontains the $L_{J,I}$, $D_{I,I}$ and $U_{I,J}$ submatrices\nfor the fronts that were owned by the particular processor.\nHowever, the parallel solve is based on the submatrices being\ndistributed across the processors, not just the fronts.\n\\par\nWe must specify which threads own which submatrices, \nand so perform computations with them.\nThis is done by constructing a {\\it ``solve--map''} object,\nas we see below.\n\\begin{verbatim}\nsolvemap = SolveMap_new() ;\nSolveMap_ddMap(solvemap, symmetryflag, FrontMtx_upperBlockIVL(frontmtx),\n               FrontMtx_lowerBlockIVL(frontmtx), nproc, ownersIV,\n               FrontMtx_frontTree(frontmtx), seed, msglvl, msgFile) ;\n\\end{verbatim}\nThis object also uses a domain decomposition map, the only solve map\nthat presently found in the {\\bf SPOOLES} library.\n\\par\nOnce the solve map has been created, (and note that it is identical\nacross all the processors), we redistribute the submatrices\nwith the following code fragment.\n\\begin{verbatim}\nFrontMtx_MPI_split(frontmtx, solvemap, stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\n\\end{verbatim}\nAt this point in time, \nthe submatrices that a processor owns are local to that processor.\n\\par\n\\subsection{The Forward and Backsolves}\n\\label{subsection:MPI:solve}\n\\par\nIf pivoting has been performed for numerical stability, then the\nrows of $PY$ may not be located on the processor that needs them.\nWe must perform an additional redistribution of the local\n{\\tt DenseMtx} objects that hold $PY$, as the code fragment below\nillustrates.\n\\begin{verbatim}\nif ( FRONTMTX_IS_PIVOTING(frontmtx) ) {\n   IV   *rowmapIV ;\n/*\n   ----------------------------------------------------------\n   pivoting has taken place, redistribute the right hand side\n   to match the final rows and columns in the fronts\n   ----------------------------------------------------------\n*/\n   rowmapIV = FrontMtx_MPI_rowmapIV(frontmtx, ownersIV, msglvl,\n                                    msgFile, MPI_COMM_WORLD) ;\n   newY = DenseMtx_MPI_splitByRows(mtxY, rowmapIV, stats, msglvl,\n                                   msgFile, firsttag, MPI_COMM_WORLD) ;\n   DenseMtx_free(mtxY) ;\n   mtxY = newY ;\n   IV_free(rowmapIV) ;\n}\n\\end{verbatim}\n\\par\nEach processor now must create a local {\\tt DenseMtx} object \nto hold the rows of $PX$ that it owns.\n\\begin{verbatim}\nownedColumnsIV = FrontMtx_ownedColumnsIV(frontmtx, myid, ownersIV,\n                                         msglvl, msgFile) ;\nnmycol = IV_size(ownedColumnsIV) ;\nmtxX = DenseMtx_new() ;\nif ( nmycol > 0 ) {\n   DenseMtx_init(mtxX, type, 0, 0, nmycol, nrhs, 1, nmycol) ;\n   DenseMtx_rowIndices(mtxX, &nrow, &rowind) ;\n   IVcopy(nmycol, rowind, IV_entries(ownedColumnsIV)) ;\n}\n\\end{verbatim}\nIf $A$ is symmetric, or if pivoting for stability was not used,\nthen {\\tt mtxX} can just be a pointer to {\\tt mtxY}, i.e.,\n$PX$ could overwrite $PY$.\n\\par\nThe parallel solve is remarkably similar to the serial solve,\nas we see with the code fragment below.\n\\begin{verbatim}\nsolvemanager = SubMtxManager_new() ;\nSubMtxManager_init(solvemanager, NO_LOCK, 0) ;\nFrontMtx_MPI_solve(frontmtx, mtxX, mtxY, solvemanager, solvemap, cpus,\n                   stats, msglvl, msgFile, firsttag, MPI_COMM_WORLD) ;\nSubMtxManager_free(solvemanager) ;\n\\end{verbatim}\nThe only difference between the multithreaded and MPI solve\nmethods is the presence of the first tag and MPI communicator\nin the latter.\n\\par\nThe last step is to permute the rows of the local solution matrix\ninto the original matrix ordering.\nWe also gather all the solution entries into one {\\tt DenseMtx}\nobject on processor zero.\n\\begin{verbatim}\nDenseMtx_permuteRows(mtxX, newToOldIV) ;\nIV_fill(vtxmapIV, 0) ;\nfirsttag++ ;\nmtxX = DenseMtx_MPI_splitByRows(mtxX, vtxmapIV, stats, msglvl, msgFile,\n                                firsttag, MPI_COMM_WORLD) ;\n\\end{verbatim}\n\\par\n\\subsection{Sample Matrix and Right Hand Side Files}\n\\label{subsection:MPI:input-files}\n\\par\n\\begin{center}\n\\begin{tabular}{|l||l||l||l||}\n\\hline\n{\\tt matrix.0.input} &\n{\\tt matrix.1.input} &\n{\\tt matrix.2.input} &\n{\\tt matrix.3.input} \\\\\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n9 9 6\n0 0  4.0\n0 1 -1.0\n0 3 -1.0\n1 1  4.0\n1 2 -1.0 \n1 4 -1.0\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n9 9 5\n2 2  4.0\n2 5 -1.0\n3 3  4.0\n3 4 -1.0\n3 6 -1.0\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n9 9 7\n4 4  4.0\n4 5 -1.0\n4 7 -1.0\n5 5  4.0\n5 8 -1.0\n6 6  4.0\n6 7 -1.0\n\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n9 9 3\n7 7  4.0\n7 8 -1.0\n8 8  4.0\n\\end{verbatim}\n\\end{minipage}\n\\\\\n\\hline\n\\hline\n{\\tt rhs.0.input} &\n{\\tt rhs.1.input} &\n{\\tt rhs.2.input} &\n{\\tt rhs.3.input} \\\\\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n2 1\n0 0.0\n1 0.0\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n2 1\n2 0.0\n3 0.0\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n2 1\n4  1.0\n5  0.0\n\\end{verbatim}\n\\end{minipage}\n&\n\\begin{minipage}[t]{1 in}\n\\begin{verbatim}\n3 1\n6  0.0\n7  0.0\n8  0.0\n\n\\end{verbatim}\n\\end{minipage}\n\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n", "meta": {"hexsha": "40d283348ac53b23e64098a9cc0303e872540030", "size": 15084, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/documentation/AllInOne/LU_MPI.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 35.2429906542, "max_line_length": 91, "alphanum_fraction": 0.7425749138, "num_tokens": 4351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6297746143530796, "lm_q1q2_score": 0.4212438080235394}}
{"text": "%\\section{Makespan as a Bound}\n% To guarantee that our model will yield a solution that is \\emph{sum-of-costs} optimal we need to provide a maximum $makespan$ $T$ big enough.\n\n% In figure , we show an example where the increase of the \\emph{makespan} returns better \\emph{sum-of-costs} solutions. The problem has 3 agents:  $a_1$ needs to go from $(0,1)$ to $(3,1)$. The agents $a_2$ and $a_3$ are already at the goal on the positions $(1,1)$ and $(2,1)$ respectively. We compare the minimum \\emph{sum-of-costs} solution with two different \\emph{makespans}:\n\n% \\begin{itemize}\n%     \\item $\\mu=3$. The optimal \\emph{sum-of-costs} solution involves moving $a_2$ and $a_3$ out of their goal. The costs for each agent are: $cost(a_1) = 3$, $cost(a_2) = 2$ and $cost(a_3) = 3$, which gives us \\emph{sum-of-costs} $=8$.\n%     \\item $\\mu=5$. The optimal \\emph{sum-of-costs} solution only needs to move $a_1$, dodging the locations occupied by the other agents: \\emph{sum-of-costs} $=cost(a_1) = 5$\n% \\end{itemize}\n\n\n\n% \\emph{makespan} $m_{opt}$ that guarantees a cost-optimal solution given an initial solution.\n\n% \\begin{lemma}\n% Given an initial solution with cost $\\sigma$. We can bound $m_{opt}$ as:\n% \\[\n%     m_{opt} \\leq  \\sigma - \\min\\limits_{i=\\{1..k\\} }{\\sum_{\\substack{j=1 \\\\ j \\neq i}}^{k} c^*(a_j)}\n% \\]\n% Where $c^*(a_j)$ is the optimal cost of the path $a_j$ ignoring the conflicts with other agents.\n% \\end{lemma}\n\n\\subsection{Finding Cost-Optimal Solutions}\nThe encoding proposed so far can find the minimum sum-of-cost solution for a given makespan. We still need to define how to find a true cost-optimal solution.\n\nFollowing the approach used for SAT encodings for planning \\cite{KautzS92}, in our approach we attempt to solve instances for increasing makespan $\\mathtt{T}$, until a solution, say $sol_{min}$, is found. Two observations with this process are important. First, we do not need to start increasing $\\mathtt{T}$ from 1. As mentioned above, at preprocessing time, for each agent we compute cost the cost $c^*_a$ which ignores other agents. The makespan of any solution must be at least $\\max_{a\\in\\mathcal{A}} c^*_a$ so this can be the inferior limit of our iteration.\n\nSecond, let $sol_{min}$ be the solution that is found first. Unfortunately, $sol_{min}$ is a makespan-optimal solution but not necessarily a cost-optimal solution. Now we can compute a bound for the largest makespan $\\mathtt{T}_{max}$ at which the cost-optimal solution is found, using the following theoretical result first proposed by \\acite{SurynekFSB16}:\n\\begin{theorem}[\\nbcite{SurynekFSB16}]\\label{thm:optimal}\nLet $sol_{min}$ be the makespan-optimal solution for MAPF problem $P$, let $sol^-$ denote a solution to $P$ that ignores all conflicts, and let $\\mathtt{T}^-$ denote its makespan. Then the makespan of the cost-optimal solution is at most at $\\mathtt{T}_{max}=\\mathtt{T}^- + c(sol_{min})-c(sol^-)-1$.\n\\end{theorem}\nThus after we find the first solution $sol_{min}$, we run the solver again for makespan $\\mathtt{T}_{max}$ given by Theorem~\\ref{thm:optimal}. The approach described in this section was recently evaluated by \\acite{BartakS19} for their Picat-based MAPF solver.\n\n\n%First we calculate the shortest path for each agent ignoring the conflicts with other agents. The maximum cost and sum of costs of these paths provide a lower bound for the makespan $\\mathtt{T}_{min}$ and \\emph{sum-of-costs} respectively. Then we define and start solving an ASP program with one of the encodings defined before using $\\mathtt{T}=\\mathtt{T}_{min}$ as the makespan. If there's no solution we increase $\\mathtt{T}$ by 1 and repeat the process.\n\n%If the program returns a valid solution then as it was shown in Figure ~\\ref{fig:makespancost} it's not guaranteed that is \\emph{sum-of-cost} optimal.\n\n%The using (bartak)\n\n%So we run the program one last time using $\\mathtt{T}=C(M) - 1 - C^-$ and return that solution.\n\n\n% \\begin{algorithm}\n% \\DontPrintSemicolon\n% \\KwIn{A MAPF problem}\n% $\\mathtt{T} \\gets \\max\\limits_{i=\\{1..K\\} }{c^*(a_i)}$\\;\n% $C^- \\gets \\sum_{\\substack{i=1}}^{k} c^*(a_i)$\\;\n% $P(\\mathtt{T}) \\gets$ Create an ASP program from input problem with makespan T\\;% $M \\gets \\{\\}$\\;\n%  \\While{$M$ is empty}{%\n%   $M \\gets$ Solve $P(T)$\\;\n%   \\If{$M$ is not empty}{\n%     $C(M) \\gets$ cost of the solution of model $M$\\;\n%     $\\Delta \\gets C(M) - 1 - C^-$\\;\n%     $M^* \\gets$ Solve $P(\\mathtt{T}+\\Delta)$\\;\n%     \\Return{M}\\;\n%   }\n%   $\\mathtt{T} \\gets \\mathtt{T}+1$\\;\n %}\n\n%\\end{algorithm}\n", "meta": {"hexsha": "dc7f5ee08b34145f5bdb911c180570717f80b89f", "size": 4509, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aaai20/algorithm.tex", "max_stars_repo_name": "rkoco/lp-mapf", "max_stars_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aaai20/algorithm.tex", "max_issues_repo_name": "rkoco/lp-mapf", "max_issues_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aaai20/algorithm.tex", "max_forks_repo_name": "rkoco/lp-mapf", "max_forks_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.7258064516, "max_line_length": 565, "alphanum_fraction": 0.7043690397, "num_tokens": 1381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4212438080235394}}
{"text": "\\documentclass[12pt,letterpaper]{article}\n\\usepackage{amsmath}\n\\usepackage{gensymb}\n\\usepackage{textcomp}\n\\usepackage{multicol}\n\\usepackage{cancel}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n% \\renewcommand{\\labelenumi}{\\theparagraph.\\arabic{enumi}}\n\\usepackage[top=1in, bottom=1in, left=0.75in, right=0.75in]{geometry}\n\\setlength{\\parindent}{0pt}\n\\title{Physics Club Handout Soultions}\n\\begin{document}\n\\begin{multicols}{2}\n\\section{Motion}\n\n\\paragraph{Beginner problems:}\n\\begin{enumerate}\n\\item \\[\n\\begin{aligned}\n\\Delta x &= \\frac{v_o+v}{2}\\,t\\\\\n         &= \\frac{10+20}{2}\\left(10\\right)\\ \\text{m}\\\\\n         &= \\fbox{150 m}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\n\\Delta r &= \\sum r_i = 200\\,\\hat{i}\\ +\\\\\n         &  \\left(135\\cos{30.0\\degree}\\,\\hat{i} + 135\\sin{30.0\\degree}\\,\\hat{j}\\right) +\\\\\n         &  \\left(135\\cos{-40.0\\degree}\\,\\hat{i} + 135\\sin{-40.0\\degree}\\,\\hat{j}\\right)\\,\\text{ft}\\\\\n         &= \\fbox{$\\left(420.3\\,\\hat{i} - 19.28\\,\\hat{j}\\right)$ ft}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\nv_y^2&=v_{0y}+2a_y\\Delta y\\\\\n\\Delta y&=\\frac{v_y^2-v_{0y}^2}{2a_y}=\\frac{v_0^2\\sin^2 \\theta}{2g}\\\\\nv_y&=v_{0y}+a_yt\\\\\nt&=\\frac{v_y-v_{0y}}{a}=\\frac{v\\sin \\theta}{g}\\\\\n\\Delta x &= v_{0x}t = v_0\\cos \\theta \\frac{v_0\\sin \\theta}{g}\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\n3 \\Delta x &= \\Delta y\\\\\n3 v_0\\cos \\theta \\frac{v_0\\sin \\theta}{g} &= \\frac{v_0^2\\sin^2 \\theta}{2g}\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\n\\tan \\theta &= 6\\\\\n\\theta &= \\tan^{-1} 6 = \\fbox{80.5$\\degree$}\n\\end{aligned}\n\\]\n\n\\item\nThis question doesn't make sense.\n\\end{enumerate}\n\\paragraph{Intermediate problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{4}\n\\item See problem 1.3.\n\\[\n\\begin{aligned}\nh &= \\frac{v_0^2\\sin^2 \\theta}{2g}\\\\\nd &= v_0\\cos \\theta \\frac{v_0\\sin \\theta}{g}\\\\\n\\frac{h}{d} &= \\frac{\\frac{v_0^2\\sin^2 \\theta}{2g}}{v_0\\cos \\theta \\frac{v_0\\sin \\theta}{g}}\\\\\n            &= \\fbox{$\\displaystyle \\frac{\\tan \\theta}{2}$}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\n|\\vec{R}| &= \\sqrt{x^2+y^2+z^2}\\\\\n          &= \\sqrt{2^2+1^2+3^2} = \\fbox{3.74}\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\n\\cos \\theta_r &= \\frac{\\vec{R}\\,\\hat{r}}{|\\vec{R}|}\\\\\n\\theta_x &= \\cos^{-1} \\frac{\\vec{R}\\,\\hat{i}}{|\\vec{R}|} = \\cos^{-1} \\frac{2}{3.74} = \\fbox{57.7$\\degree$}\\\\\n\\theta_y &= \\cos^{-1} \\frac{\\vec{R}\\,\\hat{j}}{|\\vec{R}|} = \\cos^{-1} \\frac{1}{3.74} = \\fbox{74.5$\\degree$}\\\\\n\\theta_z &= \\cos^{-1} \\frac{\\vec{R}\\,\\hat{k}}{|\\vec{R}|} = \\cos^{-1} \\frac{3}{3.74} = \\fbox{36.7$\\degree$}\n\\end{aligned}\n\\]\n\n\\item\n\\vspace{-5pt}\n\\[\n\\begin{aligned}\n\\Delta x &= v_{0x}t\\\\\nt &= \\frac{\\Delta x}{v_0\\cos \\theta}\\\\\n\\Delta y &= v_{0y}t + \\frac{1}{2}at^2\\\\\n\\Delta y &= v_0\\sin \\theta \\frac{\\Delta x}{v_0\\cos \\theta} + \\frac{1}{2}g\\left(\\frac{\\Delta x}{v_0\\cos \\theta}\\right)^2\\\\\n\\Delta y &= \\tan \\theta \\sqrt{\\left(\\Delta r\\right)^2 - \\left(\\Delta y\\right)^2} +\\\\\n         &  \\frac{g\\left(\\left(\\Delta r\\right)^2 - \\left(\\Delta y\\right)^2\\right)}{2v_0^2\\cos^2 \\theta}\\\\\n2.15 \\times 10^3 &= \\tan \\theta\\\\\n         &  \\sqrt{\\left(4 \\times 10^3\\right)^2 - \\left(2.15 \\times 10^3\\right)^2} +\\\\\n         &  \\frac{9.81 \\left(\\left(4 \\times 10^3\\right)^2 - \\left(2.15 \\times 10^3\\right)^2\\right)}{2\\cdot 280^2\\cos^2 \\theta}\\\\\n\\theta &= \\fbox{21.5\\degree}\n\\end{aligned}\n\\]\n\\end{enumerate}\n\\paragraph{Advanced problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{7}\n\\item\n$$\\left(v\\sin \\theta\\right)^2-\\left(v\\sin \\theta\\right)_0^2=2ah$$\n$$\\left(v\\sin \\theta\\right)^2\\propto h$$\n$$v\\sin\\theta\\propto\\sqrt{h}$$\n$$v_0 \\cos \\theta = \\sqrt{\\frac{6}{7}}\\sqrt{\\left(\\frac{v_o\\sin\\theta}{\\sqrt{2}}\\right)^2+\\left(v_0\\cos\\theta\\right)^2}$$\n$$cos^2 \\theta = \\frac{6}{7}\\left(\\frac{\\sin^2 \\theta}{2}+cos^2 \\theta\\right)$$\n$$7cos^2 \\theta = 3\\sin^2 \\theta + 6\\cos^2 \\theta$$\n$$\\tan \\theta = \\frac{1}{\\sqrt{3}}$$\n$$\\theta = \\tan^{-1} \\frac{1}{\\sqrt{3}} = \\fbox{30$\\degree$}$$\n\n\n\\item See problem 1.8.\n$$v\\sin\\theta\\propto\\sqrt{h}$$\n$$v_0 \\cos \\theta = m\\sqrt{\\left(\\sqrt{n}v_o\\sin\\theta\\right)^2+\\left(v_0\\cos\\theta\\right)^2}$$\n$$cos^2 \\theta = m^2\\left(n\\sin^2 \\theta+cos^2 \\theta\\right)$$\n$$\\left(1-m^2\\right)cos^2 \\theta = nm^2\\sin^2 \\theta$$\n$$\\theta = \\fbox{$\\displaystyle \\tan^{-1} \\frac{1}{m}\\sqrt{\\frac{1-m^2}{n}}$}$$\n\n\\item \\[\n\\begin{aligned}\nx &= \\left(v_0\\cos \\theta\\right)t = d\\cos \\psi\\\\\ny &= \\left(v_0\\sin \\theta\\right)t-\\frac{1}{2}gt^2 = -d\\sin \\psi\n\\end{aligned}\n\\]\n$$\\left(v_0\\sin \\theta\\right)\\frac{d\\cos \\psi}{v_0\\cos \\theta}-\\frac{1}{2}g\\left(\\frac{d\\cos \\psi}{v_0\\cos \\theta}\\right)^2 = -d\\sin \\psi$$\n$$\\tan \\theta \\cos \\psi-\\frac{gd\\cos^2 \\psi}{2v_0^2\\cos^2 \\theta} = -\\sin \\psi$$\n$$d = \\frac{v_0^2}{g}\\left(\\sin 2\\theta \\sec \\psi+2\\cos^2 \\theta\\sec \\psi \\tan \\psi\\right)$$\nTaking the derivative with respect to $\\theta$:\n$$\\frac{dd}{d\\theta} = \\frac{2 v_0^2 \\sec^2 \\psi \\cos\\left(2 \\theta+\\psi\\right)}{g}$$\nNext, we equate this to 0 to find where $d$ is maximized. As an exercise, confirm that $d$ is at a maximum and not a minimum by computing $d^2d$\\slash $d\\theta^2$.\n$$\\frac{2 v_0^2 \\sec^2 \\psi \\cos\\left(2 \\theta+\\psi\\right)}{g} = 0$$\n$$2 \\theta+\\psi = \\pi$$\n$$\\fbox{$\\displaystyle \\theta = \\frac{\\pi-\\psi}{2}$}$$\n\n\n\\item\\[\n\\begin{aligned}\nR &= \\frac{1}{2}gt^2\\\\\nt &= \\sqrt{\\frac{2R}{g}}\\\\\n\\Delta x &= vt = \\fbox{$\\displaystyle v \\sqrt{\\frac{2R}{g}}$}\\\\\n\\Delta x &> R\\\\\nv \\sqrt{\\frac{2R}{g}} &> R\\\\\nv &> \\sqrt{\\frac{gR}{2}}\n\\end{aligned}\n\\]\n\\end{enumerate}\n\n\\section{Newton's Laws}\n\n\\paragraph{Beginner problems:}\n\\begin{enumerate}\n\\item\n$$\\sum \\vec{F} = m\\vec{a} = 0$$\n$$\\vec{F}_{air} = -\\vec{v}^{\\,2}*0.3141\\frac{\\text{kg}}{\\text{m}} = mg$$\n\\[\n\\begin{aligned}\n\\vec{v} &= \\sqrt{\\frac{50\\cdot 9.81}{0.3141}}\\ \\text{m\\slash s}\\\\\n        &= \\fbox{39.5 m\\slash s}\n\\end{aligned}\n\\]\n\n\\item\n$$a_c = \\frac{v^2}{r} = \\frac{4^2}{12}\\ \\frac{\\text{m}}{\\text{s}^2} = \\fbox{1.33 m\\slash s$^2$}$$\n\\[\n\\begin{aligned}\na &= a_c + a_\\perp = \\left(1.33\\,\\hat{r} + 1.2\\,\\hat{t}\\right)\\,\\text{m\\slash s}^2\\\\\n  &= \\fbox{1.67 m\\slash s$^2$ at $\\theta = 48\\degree$}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\nF     &= ma\\\\\n2T-mg &= m\\frac{v^2}{R}\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\nv &= \\sqrt{R\\left(\\frac{2T}{m}-g\\right)}\\\\\n  &= \\sqrt{3.00\\left(\\frac{2\\cdot 350}{40.0}-9.81\\right)}\\ \\text{m\\slash s}\\\\\n  &= \\fbox{4.80 m\\slash s}\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\n            E_i &= E_f + W_{nc}\\\\\n\\frac{1}{2}mv^2 &= mgh\n\\end{aligned}\n\\]\n$$h = \\frac{v^2}{2g} = \\frac{4.80^2}{2\\cdot 9.81}\\ \\text{m} = \\fbox{1.18 m}$$\n\\end{enumerate}\n\n\\paragraph{Intermediate problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item This question doesn't make sense.\n\n\\item\nAn amusement park ride is set up as a giant swing that starts at an angle of 80\\degree\\ to the vertical, and allows the swing to fall freely. For legal reasons, the maximum g-force a rider can experience is 5 g's (where 1 g = 9.81 m\\slash s$^2$). Assuming no air resistance, what is the largest they can make the swing and still avoid litigation?\n\n\\item\nA plumb bob (a weight hanging from a string) usually does not hang perfectly vertically (i.e. along a line directed towards the center of the earth). By how much does a plumb bob deviate from vertical here in Palo Alto (latitude of 37.4\\degree\\,N), assuming the earth is spherical and has radius 6380 km?\n\\end{enumerate}\n\n\\paragraph{Advanced problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{6}\n\\item\nAn object moving througha a fluid experiences a force $\\vec{F}_{drag} = -(ar\\vec{v} + br^2\\vec{v}^2)$ exerted on a sphere of radius $r$ moving through a fluid at speed $v$, where $a$ and $b$ are constants based on the shape of the object and the surrounding atmosphere. For spherical objects in air at sea level, $a = 3.10 \\times 10^{-4}\\,\\text{Pa}\\cdot \\text{s}$ and $b = 0.870$ g\\slash L.\nFind the velocity of a water droplet of 100 \\textmu m freefalling at time $t$, where $t$ is the time elapsed since it was released from rest.\n\n% $$m\\vec{g} - \\vec{F}_{drag} = m\\vec{a}$$\n% $$v = \\int a\\,dt = \\int \\frac{F}{m}\\,dt = \\int_0^t \\frac{m\\vec{g} - (ar\\vec{v} + br^2\\vec{v}^2)}{m} \\,dt = gt$$\n\n\\item \\[\n\\begin{aligned}\n\\sum F = ma\\\\\nF_n + F\\sin \\theta - mg = 0\\\\\nF\\cos \\theta - f = 0\\\\\nF\\cos \\theta - \\mu_s\\left(mg - F\\sin \\theta\\right) = 0\\\\\nF = \\frac{\\mu_s mg}{\\cos \\theta + \\mu_s \\sin \\theta}\n\\end{aligned}\n\\]\nIn order to minimize $F$, we maximize the denominator on the right hand side by taking a derivative:\n\\[\n\\begin{aligned}\n& -\\sin \\theta + \\mu_s \\cos \\theta = 0\\\\\n\\theta &= \\tan^{-1} \\mu_s = \\tan^{-1} 0.4 = \\fbox{21.8$\\degree$}\\\\\nF &= \\frac{\\mu_s mg}{\\cos \\theta + \\mu_s \\sin \\theta}\\\\\n  &= \\frac{0.4\\cdot 1\\cdot 9.81}{\\cos 21.8\\degree + 0.4 \\sin 21.8\\degree}\\ \\text{N}\\\\\n  &= \\fbox{3.64 N}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\n\\vec{F} &= (8.00\\,\\hat{i}-4.00\\,t\\,\\hat{j})\\ \\text{N}\\\\\n\\vec{F} &= m\\vec{a}\\\\\n\\vec{a} &= (4.00\\,\\hat{i}-2.00\\,t\\,\\hat{j})\\ \\text{m\\slash s}^2\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\n\\vec{v} = \\int \\vec{a}\\,dt &= \\int (4.00\\,\\hat{i}-2.00\\,t\\,\\hat{j})\\ \\text{m\\slash s}^2\\,dt\\\\\n                           &= (4.00\\,t\\,\\hat{i}-1.00\\,t^2\\,\\hat{j}+\\cancel{C})\\ \\text{m\\slash s}\\\\\n|\\vec{v}| = 15\\ \\text{m\\slash s} &= \\sqrt{\\left(4.00\\,t\\right)^2+\\left(-1.00\\,t^2\\right)^2}\\\\\nt &= \\fbox{3 s}\\\\\n\\vec{x} = \\int \\vec{v}\\,dt &= \\int (4.00\\,t\\,\\hat{i}-1.00\\,t^2\\,\\hat{j})\\ \\text{m\\slash s}\\, dt\\\\\n                            &= (2.00\\,t^2\\,\\hat{i}-0.33\\,t^3\\,\\hat{j})\\ \\text{m}\\\\\n\\vec{x}\\,(3\\ \\text{s}) &= (2.00\\cdot 3^2\\,\\hat{i}-0.33\\cdot 3^3\\,\\hat{j})\\ \\text{m}\\\\\n&= \\fbox{$18.0\\,\\hat{i}-9.00\\,\\hat{j}$ m}\n\\end{aligned}\n\\]\n\\end{enumerate}\n\n\\section{Energy}\n\n\\paragraph{Beginner problems:}\n\\begin{enumerate}\n\\item\n\\begin{enumerate}[label=(\\alph*)]\n\\item\n$\\displaystyle W = F \\Delta x \\cos \\theta$\n$$W = 16.0 \\cdot 2.20 \\cos -25.0\\degree\\ \\text{J} = \\fbox{31.9 J}$$\n\n\\item The normal force is perpendicular to the direction of movement so the dot product $W = F \\cdot \\Delta x$ is \\fbox{0}.\n\n\\item Similarly, the gravitational force is perpendicular to the direction of movement so the work done is \\fbox{0}.\n\n\\item \\(\n\\begin{aligned}\n\\displaystyle W_{\\text{net}} &= W_F + W_{F_n} + W_g\\\\\n               &= 31.9 + 0 + 0\\ \\text{J} = \\fbox{31.9 J}\n\\end{aligned}\n\\)\n\\end{enumerate}\n\n\\item \\[\n\\begin{aligned}\nW &= \\int F\\,dx\\\\\n  &= \\int_{x = 0}^{0.600\\ \\text{m}} \\left(5000+10000x-25000x^2\\right)\\,dx\\\\\n  &= 5000x+5000x^2-8333x^3\\Biggr|_{x = 0}^{0.600\\ \\text{m}}\\ \\text{J}\\\\\n  &= \\fbox{3000 J}\n\\end{aligned}\n\\]\n$$\\sum W = \\Delta K = \\frac{1}{2}mv^2$$\n$$v =\\sqrt{\\frac{2W}{m}}=\\sqrt{\\frac{2\\cdot 3000}{100 \\times 10^{-3}}}\\ \\text{J} = \\fbox{60000 J}$$\n\n\\item\n$$E_i=E_f$$\n$$\\frac{1}{2}mv_0^2 + mgh = \\frac{1}{2}mv^2$$\n\\[\n\\begin{aligned}\nv &= \\sqrt{v_0^2 + 2gh}\\\\\n  &= \\sqrt{42^2 + 2\\cdot 9.81\\cdot 100}\\ \\text{m\\slash s} = \\fbox{3726 m\\slash s}\n\\end{aligned}\n\\]\n\\end{enumerate}\n\\paragraph{Intermediate problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item\n$$W = F\\,dx = -U$$\n\\[\n\\begin{aligned}\nF = -U \\frac{d}{dx} &= -\\left(-x^3+2x^2+3x\\right) \\frac{d}{dx}\\\\\n                    &= \\fbox{$\\displaystyle 3x^2-4x-3$}\n\\end{aligned}\n\\]\nTo find the stable and unstable equilibria, take the derivative of $U$ with respect to $x$:\n$$U \\frac{d}{dx} = -3x^2+4x+3 = 0$$\n$$x = \\frac{2 \\pm \\sqrt{13}}{3}$$\nTo determine whether each root is at a stable, unstable, or neutral equilibrium, we take the second derivative of $u$ with respect to $x$, $d^2U$\\slash $dx^2$:\n$$U \\frac{d^2}{dx^2} = -6x+4$$\nAt $x = \\frac{1}{3}\\left(2 + \\sqrt{13}\\right)$, $d^2U$\\slash $dx^2 = -\\sqrt{13}$. At $x = \\frac{1}{3}\\left(2 - \\sqrt{13}\\right)$, $d^2U$\\slash $dx^2 = \\sqrt{13}$.\n$x = \\frac{1}{3}\\left(2 + \\sqrt{13}\\right)$ is at a local maximum so it is at an unstable equilibrium.\\\\\n$x = \\frac{1}{3}\\left(2 - \\sqrt{13}\\right)$ is at a local minimum so it is at a stable equilibrium. \n\n\\item\n$$\\sum F = ma_c$$\n$$F_{n,\\text{bot}}-mg=m\\frac{v^2}{r}$$\n$$F_{n,\\text{bot}} = \\fbox{$\\displaystyle m\\left(\\frac{v^2}{r}+g\\right)$}$$\n$$E_i=E_f$$\n$$\\frac{1}{2}mv^2=\\frac{1}{2}mv_{\\text{top}}^2+mg\\left(2r\\right)$$\n$$v_{\\text{top}}^2=v^2-4gr$$\n$$\\sum F = ma_c$$\n$$F_{n,\\text{top}}+mg=m\\frac{v_{\\text{top}}^2}{r}$$\n\\[\n\\begin{aligned}\nF_{n,\\text{top}} &= m\\left(\\frac{v^2-4gr}{r}-g\\right)\\\\\n&= \\fbox{$\\displaystyle m\\left(\\frac{v^2}{r}-5g\\right)$}\n\\end{aligned}\n\\]\n\n\\item\nA block of mass $M$ rests on a table. It is fastened to the lower end of a light, vertical spring with spring constant $k$. The upper end of the spring is fastened to a block of mass $m$. The spring is then compressed a distance $d$ (relative to its unstretched state) by pushing down on the upper block. In this configuration, the upper block is released from rest. The spring lifts the lower block off the table. In terms of $m$, what is the greatest possible value for $M$?\n\\end{enumerate}\n\\paragraph{Advanced problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{6}\n\\item The problem requires knowledge of techniques in multivaribale calculus. Compute when $z' = 0$ to find equilibria, and compute the sign of $z''$ to find the type of equilibrium. You should get infinite solutions since $\\cos$ is periodic. Some solutions include $(-3.78416, -25.736)$ and $(1.77245, 1.77245)$.\\\\\n\\includegraphics[width=2.5in]{3-7.png}\n\\item\nA ball of mass 300 g is connected by a strong string of length 80.0 cm to a pivot and held in place with the string vertical. A sudden gust of wind exerts constant force $F$ to the right on the ball. The ball is released from rest. The wind makes it swing up to attain maximum height $H$ above its starting point before it swings down again. Find $H$ as a function of $F$.\n\n\\item\nTwo stars of mass $M$ are separated by a distance $d$. One star is moving at a velocity $v$ relative to the other star, in a direction perpendicular to the line connecting the two stars. As time approaches infinity, how will the stars behave? (Will they enter a stable orbit with one another, will they collide, will they fly apart and never meet again?)\n\\end{enumerate}\n\n\\section{Momentum \\& Impulse}\n\n\\paragraph{Beginner problems:}\n\\begin{enumerate}\n\\item \\[\n\\begin{aligned}\np_i&=p_f\\\\\n\\left(m_{\\text{man}}+m_{\\text{box}}\\right)v_i&=m_{\\text{man}}v+m_{\\text{box}}v_{\\text{box}}\\\\\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\nv&=\\frac{\\left(m_{\\text{man}}+m_{\\text{box}}\\right)v_i-m_{\\text{box}}v_{\\text{box}}}{m_{\\text{man}}}\\\\\n &=\\frac{\\left(60+20\\right)7-20\\cdot 5}{60}\\ \\text{m\\slash s}\\\\\n &=\\fbox{7.67 m\\slash s}\n\\end{aligned}\n\\]\n\n\\item \\[\nm = m \\cdot \\frac{\\left(mv\\right)^2}{m^2v^2} = \\frac{p^2}{2K} = \\frac{40^2}{2\\cdot 100}\\ \\text{kg} = \\fbox{8 kg}\n\\]\n\n\\item Assume your mass $m=50$ kg.\n\\[\n\\begin{aligned}\nE_i &= E_f\\\\\n\\frac{1}{2}mv^2 &= mgh\\\\\nv &= \\sqrt{2gh}\\\\\np_i &= p_f\\\\\nm\\sqrt{2gh} &= M_EV_E\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\nV_E &= \\frac{m}{M_E}\\sqrt{2gh}\\\\\n&= \\frac{50\\sqrt{2\\cdot 9.81\\cdot 0.75}}{5.97\\times 10^{24}}\\ \\text{m\\slash s} = \\fbox{3.22 m\\slash s}\n\\end{aligned}\n\\]\n\\end{enumerate}\n\\paragraph{Intermediate problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item\n$$J = \\Delta p = mv = \\int F\\,dt$$\n\\[\n\\begin{aligned}v &= \\frac{1}{m} \\int F\\,dt = \\frac{1}{50} \\int_0^4 10\\, t^2\\, dt\\\\\n    &= \\frac{1}{50} \\frac{10}{3}\\, t^3\\Biggr|_0^4\\ \\text{m\\slash s} = \\fbox{4.27 m\\slash s}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\n\\sum F &= ma\\\\\nF_n - mg &= 0\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\nE_i &= E_f+W_{nc}\\\\\n\\frac{1}{2}mv_0^2 &= \\frac{1}{2}mv_1^2+\\mu_k mgd_1\n\\end{aligned}\n\\]\n$$v_1 = \\sqrt{v_0^2-2\\mu_k gd_1}$$\n\\[\n\\begin{aligned}\np_i &= p_f\\\\\nmv_1 &= Mv_2\n\\end{aligned}\n\\]\n$$v_2 = \\frac{m}{M}v_1 = \\frac{m}{M}\\sqrt{v_0^2-2\\mu_k gd_1}$$\n\\[\n\\begin{aligned}\nE_i &= E_f+W_{nc}\\\\\n\\frac{1}{2}mv_2^2 &= \\mu_k mgd_2\n\\end{aligned}\n\\] \\[\n\\begin{aligned}\nd_2 &= \\frac{v_2^2}{2\\mu_k g} = \\frac{\\left(\\frac{m}{M}\\sqrt{v_0^2-2\\mu_k gd_1}\\right)^2}{2\\mu_k g}\\\\\n&= \\left(\\frac{m}{M}\\right)^2\\left(\\frac{v_0^2}{2\\mu_k g} - d_1\\right)\\\\\n&= \\left(\\frac{5.0}{15.0}\\right)^2\\left(\\frac{8.0^2}{2\\cdot 0.35\\cdot 9.81} - 2.0\\right)\\ \\text{m}\\\\\n&= \\fbox{2.44 m}\n\\end{aligned}\n\\]\n\n\\item \\[\n\\begin{aligned}\np_i &= p_f\\\\\nmv_{1i} &= mv_{1f} + mv_{2f}\\\\\nv_{1i} &= v_{1f} + v_{2f}\\\\\nE_i &= E_f\\\\\n\\frac{1}{2}mv_{1i}^2 &= \\frac{1}{2}mv_{1f}^2 + \\frac{1}{2}mv_{2f}^2\\\\\nv_{1i}^2 &= v_{1f}^2 + v_{2f}^2\\\\\n\\left(v_{1f} + v_{2f}\\right)^2 &= v_{1f}^2 + v_{2f}^2\\\\\nv_{1f}^2 + v_{1f} \\cdot v_{2f} + v_{2f}^2 &= v_{1f}^2 + v_{2f}^2\\\\\nv_{1f} \\cdot v_{2f} &= 0\n\\end{aligned}\n\\]\n$$v_{1f} \\perp v_{2f}$$\n\\end{enumerate}\n\\paragraph{Advanced problems:}\n\\begin{enumerate}\n\\setcounter{enumi}{6}\n\\item\n$$F = \\frac{dp}{dt} = \\frac{d\\left(mv\\right)}{dt} = v\\,\\frac{dm}{dt} + m\\,\\frac{dv}{dt}$$\n$$dm = \\frac{M}{L}\\,dx$$\n$$F = v\\,\\frac{dm}{dt}=v\\left(\\frac{M}{L}\\right)\\frac{dx}{dt} = \\left(\\frac{M}{L}\\right)v^2$$\n$$F = \\frac{2Mgx}{L}$$\n$$F_g = \\frac{Mgx}{L}$$\n$$x = \\frac{1}{2}gt^2$$\n$$F_{\\text{net}} = F + F_g = \\frac{3Mgx}{L} = \\frac{3Mgx}{L} = \\fbox{$\\displaystyle \\frac{3Mg^2t^2}{2L}$}$$\n\n\n\\item\nTwo objects of mass $m_1$ and $m_2$ are traveling at velocities $\\vec{v}_1$ and $\\vec{v}_2$, respectively. They undergo a completely elastic collision. Find, in terms of these quantities, the final velocities of each mass.\n\n\\item\nA tennis ball of mass $m_1$ is on top of a basketball of mass $m_2$ and radius $r$. If they are dropped from a height $h$, to what height does the tennis ball bounce, assuming all collisions are elastic?\n\nNow consider a stack of $N$ balls, where the bottom ball has mass $m$, radius $r$, and each subsequent ball has mass 1/27 that of the previous ball, and radius 1/3 that of the previous ball. Assuming all collisions are elastic and without air resistance (which is completely absurd), and the stack of balls is dropped from height $h$, what is the highest ball's velocity?\n\n\\end{enumerate}\n\\end{multicols}\n\\end{document}", "meta": {"hexsha": "46f129ca8369918f708155e89c011c9834ee2bbb", "size": 17518, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "solutions.tex", "max_stars_repo_name": "justinyangusa/physics", "max_stars_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-11T07:10:09.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-11T07:10:09.000Z", "max_issues_repo_path": "solutions.tex", "max_issues_repo_name": "justinyangusa/physics", "max_issues_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "solutions.tex", "max_forks_repo_name": "justinyangusa/physics", "max_forks_repo_head_hexsha": "716f5e7489d3b5fd5dede24eb2bba4673128af0b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1932059448, "max_line_length": 476, "alphanum_fraction": 0.6155383035, "num_tokens": 7359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.42124380435758146}}
{"text": "\n\\section{\\label{sec:sphericalgravity} Modifications for a Spherical Self-Gravitating Star}\n\nIn papers II and III, we calculated the hydrostatic expansion of the base state\nin plane-parallel geometry under the assumption that the weight of the\nmaterial above (or below) any given fluid parcel does not change\nduring hydrostatic expansion.  This assumption holds when the\ngravitational acceleration is independent of location.  Here we discuss the\nmodifications to the algorithm in paper III required to treat a spherical \nself-gravitating star.\n\n\\subsection{One-dimensional Results}\n\nTo test the spherical base state expansions, we inject heat at a\nsteady rate into a one-dimensional white dwarf model.  This is similar\nto the first test in paper II, except now in spherical coordinates.\nAs in that test, the compressible method with which we compare the low Mach number method \nis the FLASH code's implementation of the\npiecewise-parabolic method (PPM) in a one-dimensional spherical geometry.  \nThe initial conditions for the white dwarf are those described in\nSection 4.1 of paper III for the central region.\n\n%A simple initial model for a white dwarf was constructed by specifying\n%a central density of $2.6\\times 10^9~\\gcc$, a central temperature of\n%$7\\times 10^8$~K, and a composition of 30\\% carbon and 70\\% oxygen,\n%and integrating the equation of hydrostatic equilibrium outward (using\n%spherically symmetric self-gravity) while constraining the entropy to\n%be constant.  Once the temperature of the model falls to $10^7$~K, it\n%is held constant---this happens only at the very outer region of the\n%star.  Together with the equation of state, this completely determines\n%the density, temperature, and pressure structure of the star.\n\nIn the expansion of a plane-parallel atmosphere, heating at a\nheight $r$ above the base does not affect the pressure or density \nbelow that height.  By contrast, in a spherical symmetric\nself-gravitating star, heating at a radius $r$ will lead to a pressure\nand density decrease at the center in addition to the expansion of the\nouter layers (see Schwarzchild \\& Harm, 1965, ApJ, 146, 855).\n\n\nWe apply a heating function of the form:\n\\begin{equation}\n\\Hext = H_0 \\exp \\left [-(r-r_0)^2 / W^2 \\right ] \\enskip ,\n\\end{equation}\nwith $r_0 = 4\\times 10^7$~cm, $W = 10^7$~cm, and $H_0 = 1\\times\n10^{16}$~erg~g$^{-1}$~s$^{-1}$. This is the same functional form as used\nin the first test of paper II, but with a lower amplitude.  Still, this\nheating rate is far higher than what is expected during the convective\nphase of Type Ia SNe.  The heating term is added to the enthalpy\nequation in the low Mach number equations in the same fashion as\ndescribed in paper II.  In this test, we do not consider reactions.\nSince this is a one-dimensional test all perturbational quantities,\nas well as $\\Ubt,$ are zero, so we are directly testing the computation of \n$w_0$ as and the base state update as described in\nthe {\\bf Advect Base} procedure defined above.  \nBoth the PPM and low Mach calculation use 768 zones in a domain $5\\times\n10^8$~cm high.\n\nFigure~\\ref{fig:spherical768} shows the structure of the star after\nheating for 10~s.  The gray line is the initial star before any\nheating.  \n%The solid black line is the PPM result and the dotted and\n%dashed lines are the low Mach number model with advective CFL numbers\n%of $0.5$ and $0.1$ respectively (the PPM calculation used a CFL number\n%of $0.5$).  \nWe see that the compressible and low Mach number models\nagree extremely well.  Both capture the decrease in the density and\npressure at the center of the star and the considerable expansion in\nradius.  Only at the surface of the star do the temperatures differ slightly.\nIn all calculations, we set the minimum temperature to $5\\times\n10^6$~K.  The PPM simulation required 13488 steps and the low Mach\n(CFL $=0.5$) calculation needed 203.  Over the course of the\nsimulation, the Mach number of the flow remained less than $0.35$, with the\nmaximum Mach number occurring at the surface of the star.  This Mach\nnumber pushes the limits of validity of the low Mach number model;  a\nsmaller perturbation amplitude would result in a smaller Mach number.\n\nFuture improvements to the overall spherical base-state adjustment\nalgorithm will address the expansion in a simulation where the medium\noutside the star is not brought down to arbitrarily low densities, but\ninstead a ``cutoff density'' is applied, as in the case of the\nplane-parallel results presented in this paper. However, we expect\nthe changes to the overall method shown here to be small. \\MarginPar{new}\n\n{\\color{red} Add a figure showing that we retain the correct solution \neven when we place higher density material outside the star.}\n\n\n\\clearpage\n\n\\begin{figure*}\n\\begin{center}\n\\includegraphics[width=5.0in]{\\sphericalfigpath/spherical_adjust_768}\n\\end{center}\n\\caption[Spherical hydrostatic adjustment]\n{\\label{fig:spherical768} Hydrostatic adjustment of a\nspherically symmetric white dwarf with self-gravity.  The gray line\nrepresents the initial model;  all other lines are after 10~s of heating.\nThe solid black line is the fully compressible solution, the dotted line is the\nlow Mach number solution with a CFL number of 0.5,  and the dashed line is\nthe low Mach number solution with a CFL number of 0.1.  All\nsimulations used 768 equally spaced zones.  We see excellent agreement\nbetween the compressible and low Mach number models.  The only\ndifferences appear at the top of the atmosphere, where the outer\nboundary condition can influence the results.}\n\\end{figure*}\n\n\n", "meta": {"hexsha": "b83ef90626ad6d0b400345bf6fc9ab026745d6d7", "size": 5579, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/spherical_basestate/basestate.tex", "max_stars_repo_name": "sailoridy/MAESTRO", "max_stars_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2017-05-15T15:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-09T08:13:32.000Z", "max_issues_repo_path": "Docs/spherical_basestate/basestate.tex", "max_issues_repo_name": "sailoridy/MAESTRO", "max_issues_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2017-06-14T23:05:00.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-28T16:40:42.000Z", "max_forks_repo_path": "Docs/spherical_basestate/basestate.tex", "max_forks_repo_name": "sailoridy/MAESTRO", "max_forks_repo_head_hexsha": "f957d148d2028324a2a1076be244f73dad63fd67", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2017-06-14T14:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T07:16:09.000Z", "avg_line_length": 51.1834862385, "max_line_length": 90, "alphanum_fraction": 0.7820397921, "num_tokens": 1389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4212438033757137}}
{"text": "\\chapter{Introduction}\n\\label{Introduction}\n\n\tDifferential equations, ordinary or partial, allow modeling phenomena that evolve with respect to space and time. They are commonly used to describe the propagation of sound or heat and appear frequently in models related to electrostatics, electrodynamics, fluid dynamics, elasticity, quantum mechanics, and among other more related areas. \\\\\n\t\n\tHowever, their analytical solutions cannot always be easily obtained and in many cases, it will be necessary to resort to very complex techniques that tend to give solutions with very impractical mathematical expressions to use. In particular, problems characterized as non-linear present these difficulties, and considering a different alternative to find solutions may be a more reasonable option. \\\\  \n\t\n\tThere are alternatives to find solutions to differential equations, which depend on the nature of the problem to be solved. For example, computational fluid dynamics is one of the branches of fluid mechanics that uses numerical methods and algorithms to solve and analyze fluid flow problems that perform millions of calculations to simulate the interaction of liquids and gases through complex surfaces. However, even with simplified equations and high-performance supercomputers, in many cases, only approximate results can be achieved. \\\\\n\t\n\tThe resolution of differential equations related to the characterization of fluids, and in general, for those that occur in the field of complex systems, are considered of utmost importance since they allow studying problems of great interest such as the turbulence phenomenon that allows understanding with precision its dynamics. Understanding these phenomena through differential equations is not enough, it is also necessary to characterize their nature, which in some cases is possible if the dimensionless value of the Reynolds number ($Re$) that indicates whether a fluid follows a laminar flow is known or turbulent. However, it is not always possible to predict with this information those phenomena that present turbulence in a combination of convection or combustion processes, and that therefore require greater attention in their dynamics. \\\\\n\t\n\tSpectral methods have recently emerged as a viable alternative for the numerical solution of partial differential equations. They have proved particularly useful in fluid dynamics simulation where are now regularly used large spectral hydrodynamics codes to study turbulence, numerical weather prediction, ocean dynamics, and any other problems where high accuracy is desired. \\\\\n\t\n\tDue to the above, he has motivated the development of this thesis by studying spectral methods extensively to acquire the ability to use this tool and understand them from the point of view of mathematical analysis. To develop this study we will focus first on the elementary theory of these methods, encompassing enough knowledge to allow us to develop, implement and analyze under this approach a wide variety of problems that arise in the partial differential equations that evolve. \\\\\n\t\n\tTo understand the application of these methods, the well-known Burgers' equation has been considered, since it is an ideal problem for understanding these methods because, in addition to being a non-linear problem that presents interesting characteristics, it can be useful to develop the ability to attack more complex problems. Furthermore, in order to extend the study of the implementation of spectral methods, we are going to work with the stochastic version of this equation that will be very useful for us to know in general terms trying to solve problems of this type, which are considered of great importance for its wide field of applications and that it is still an area that is in full development due to the great difficulty in obtaining solutions. \\\\\n\t\n\tTo carry out this study, we will divide the work into six parts organized as follows\n\t\\begin{enumerate}\n\t\t\\item[1.] In chapter \\ref{Introduction}, a brief history of Burgers' equation will be presented in its deterministic version, and we will also present how to obtain the analytical solution for an initial value problem of this equation, transforming it into another linear one that can be solved using the Fourier transform. Later, the origin of the stochastic version will be discussed, in addition to its importance within mathematics and physics.\n\t\t\n\t\t\\item[2.] In chapter \\ref{Chapter_2}, we will study the theoretical bases of spectral methods using the well-known Fourier series as the main tool, which will allow us to study a theory of approximation of functions under two approaches, using orthogonal projections and another using interpolation techniques. These two approaches will be examined independently, studying their implementation and some theoretical results that will be useful in chapter \\ref{Chapter_3}.  \n\t\t\n\t\t\\item[3.] In chapter \\ref{Chapter_3}, the spectral methods known as Fourier-Galerkin and Fourier-Collocation will be developed using the tools examined in chapter \\ref{Chapter_2}, verifying their convergence theory. For this, the deterministic Burgers' equation will be used, taking advantage of its linearized form to describe the methods, which will then be applied to the original nonlinear equation to describe the algorithms of its computational implementation that will allow us to perform numerical experiments and to be able to observe some characteristics interesting for your discussion.\n\t\t\n\t\t\\item[4.] In chapter \\ref{Chapter_4}, a spectral method used to solve stochastic partial differential equations that was studied in \\cite{Delgado2016} will be disclosed in as much detail as possible. We will see that this method, which is built based on the well-known Hermite polynomials, will allow us to obtain solutions of stochastic problems by solving a deterministic type problem, and will be illustrated using the stochastic Burgers' equation developing its implementation and also numerical simulations.\n\t\t\n\t\t\\item[5.] In this last chapter, we will discuss the most relevant of each chapter, and we will give some observations of the obtained numerical results to conclude with some ideas that can be considered to extend this work.\n\t\t\n\t\t\\item[6.] At the end of this work, an appendix \\ref{Appendix_A} was added, which will be useful to understand in more detail the spectral method developed in chapter \\ref{Chapter_4}.\n\t\\end{enumerate}\n\t\n\t\\input{introduction/Burgers_Deterministic}\n\t\\newpage\n\t\\input{introduction/Burgers_Stochastic}\n", "meta": {"hexsha": "39fd63679e32e9ca2493e79e869e2cce462fbe5c", "size": 6533, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/introduction/Introduction.tex", "max_stars_repo_name": "alanmatzumiya/Maestria", "max_stars_repo_head_hexsha": "c5e2a019312fb8f9bc193b04b07b7815e6ed4032", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-12-29T10:44:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T11:18:45.000Z", "max_issues_repo_path": "docs/introduction/Introduction.tex", "max_issues_repo_name": "alanmatzumiya/spectral-methods", "max_issues_repo_head_hexsha": "c5e2a019312fb8f9bc193b04b07b7815e6ed4032", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/introduction/Introduction.tex", "max_forks_repo_name": "alanmatzumiya/spectral-methods", "max_forks_repo_head_hexsha": "c5e2a019312fb8f9bc193b04b07b7815e6ed4032", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-04T13:29:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T13:29:56.000Z", "avg_line_length": 181.4722222222, "max_line_length": 856, "alphanum_fraction": 0.8157048829, "num_tokens": 1229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.42124379506193027}}
{"text": "\\documentclass{article}\n\\usepackage{arxiv}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{natbib}\n\n\\makeatletter\n\\theoremstyle{plain}\n\\newtheorem{thm}{\\protect\\theoremname}\n\\theoremstyle{plain}\n\\newtheorem{prop}[thm]{\\protect\\propositionname}\n\\ifx\\proof\\undefined\n\\newenvironment{proof}[1][\\protect\\proofname]{\\par\n\t\\normalfont\\topsep6\\p@\\@plus6\\p@\\relax\n\t\\trivlist\n\t\\itemindent\\parindent\n\t\\item[\\hskip\\labelsep\\scshape #1]\\ignorespaces\n}{%\n\t\\endtrivlist\\@endpefalse\n}\n\\providecommand{\\proofname}{Proof}\n\\fi\n\n\\makeatother\n\n\\usepackage{babel}\n\\providecommand{\\propositionname}{Proposition}\n\\providecommand{\\theoremname}{Theorem}\n\n\\begin{document}\n\n\\section{Identifiability of mixtures}\nRecall that a density $f(x;\\theta)$ is identified if $f(x;\\theta_{1})=f(x;\\theta_{2})$\nfor all $x$ implies that $\\theta_{1}=\\theta_{2}.$ Call a density\n$f(x;\\theta)$ \\textit{strongly identified} if $f(x;\\theta_{1})/f(x;\\theta_{2})$\nbeing constant for all $x$ in an open interval $I$ implies that\n$\\theta_{1}=\\theta_{2}$.\n\\begin{prop}\\label{prop:identified}\nLet $f(x;\\theta)$ be a family of densities on $\\mathbb{R}$, $-\\infty=a_{1}<a_{2}<\\ldots<a_{k+1}=\\infty$\na sequence of cutoffs, and $f_{[a_{i},a_{i+1}]}(x;\\theta)$ the density\n$f$ truncated to $[a_{i},a_{i+1}]$. Let $\\lambda_{i},k=1,\\ldots k$\nbe positive numbers satisfying $\\sum_{i=1}^{k}\\lambda_{i}=1$. Then\nthe mixture\n\\[\ng(x;\\lambda,\\theta)=\\sum_{i=1}^{k}\\lambda_{i}f_{[a_{i},a_{i+1})}(x;\\theta)\n\\]\nis identified in $(\\lambda,\\theta)$ if $f(x;\\theta)$ is strongly\nidentified in $\\theta$.\n\\end{prop}\n\\begin{proof}\nAssume that $g(x;\\lambda_{1},\\theta_{1})=g(x;\\lambda_{2},\\theta_{2})$.\nThen $$\\lambda_{1i}f_{[a_{i},a_{i+1}]}(x;\\theta_{1})=\\lambda_{2i}f_{[a_{i},a_{i+1}]}(x;\\theta_{2})$$\nfor all $i$, thus\n\\[\n\\frac{\\lambda_{1i}}{\\lambda_{2i}}=\\frac{f_{[a_{i},a_{i+1})}(x;\\theta_{1})}{f_{[a_{i},a_{i+1})}(x;\\theta_{2})}.\n\\]\nThis implies that $f(x;\\theta_{1})/f(x;\\theta_{2})$ is constant for\n$x\\in[a_{i},a_{i+1}]$. But since $f(x;\\theta)$ is strongly identifiable,\n$\\theta_{1}=\\theta_{2}$, and, consequently, $\\lambda_1 = \\lambda_2$.\n\\end{proof}\nIf $f(x;\\theta)$ is real analytic and nowhere zero, $f(x;\\theta_{1})/f(x;\\theta_{2})$\nis also real analytic and nowhere zero. By the Identity Theorem \\citep[Corollary 1.2.6]{Krantz2002-bt}, if\n$f(x;\\theta_{1})/f(x;\\theta_{2})$ is constant on some interval $I$,\nthen $f(x;\\theta_{1})/f(x;\\theta_{2})$ is constant everywhere, hence\n$f(x;\\theta_{1})=f(x;\\theta_{2})$ everywhere. Thus a family of real\nanalytic nowhere zero densities is identified if and only if it is\nstrongly identified. Every exponential family of densities on the form\n\\[\nf(x;\\theta)=h(x)\\exp(\\eta(\\theta)^{T}T(x)-A(\\theta))\n\\]\nsatisfies this property, provided only that $h$ is nowhere zero real analytic\nand $T$ is real analytic. In particular, the normal family satisfies\nthe properties.\n\nNot every density is strongly identified. For instance, mixtures of uniforms are not strongly identified. And indeed, Proposition \\ref{prop:identified} fails when $f$ is a mixture of uniforms.\n\\bibliographystyle{biom}\n\\bibliography{edited.bib}\n\\end{document}\n", "meta": {"hexsha": "7ed1bea560f918bd190cba7cc0fee850150b5b28", "size": 3166, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "identified.tex", "max_stars_repo_name": "JonasMoss/p-hacking", "max_stars_repo_head_hexsha": "38c4e854cb9b6f8675ca384c3031db0d5ff9e642", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-14T23:18:58.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-14T23:18:58.000Z", "max_issues_repo_path": "identified.tex", "max_issues_repo_name": "JonasMoss/p-hacking", "max_issues_repo_head_hexsha": "38c4e854cb9b6f8675ca384c3031db0d5ff9e642", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-29T11:31:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-06T14:38:26.000Z", "max_forks_repo_path": "identified.tex", "max_forks_repo_name": "JonasMoss/p-hacking", "max_forks_repo_head_hexsha": "38c4e854cb9b6f8675ca384c3031db0d5ff9e642", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0864197531, "max_line_length": 192, "alphanum_fraction": 0.7030953885, "num_tokens": 1121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4211485277461269}}
{"text": "\\section{Lebesgue Measure}\n\\subsection{Introduction}\n  \\paragraph{1.}\n  \\begin{proof}\n    Since $\\mathfrak{M}$ is an $\\sigma$-algebra, $B\\setminus A \\in\\mathfrak{M}$\n    as long as $A,B\\in\\mathfrak{M}$. Since $B\\setminus A$ and $A$ are disjoint,\n    $mB=mA+m(B\\setminus A)\\ge mA$ since $m$ is nonnegative.\n  \\end{proof}\n\n  \\paragraph{2.}\n  \\begin{proof}\n    Let $A_0 = E_0$ and $E_k=A_k\\setminus A_{k-1}$ for $k\\ge 1$. Clear that \n    $E_i$ and $E_j$ are disjoint for distinct $i$ and $j$, $\\bigcup A_n=\\bigcup\n    E_n$ and $A_i\\subset E_i$ for every $i$. Hence,\n    \\[\n      m\\left(\\bigcup E_n\\right) = m\\left(\\bigcup A_n\\right)\n      = \\sum mA_n \\le \\sum mE_n,\n    \\]\n    where the last inequality comes from Exercise 1.\n  \\end{proof}\n\n  \\paragraph{3.}\n  \\begin{proof}\n    Suppose that $mA<\\infty$. Then $mA=m(A\\cup\\varnothing)=mA+m\\varnothing$, \n    implying that $m\\varnothing=0$.\n  \\end{proof}\n% end\n\n\\subsection{Outer Measure}\n  \\paragraph{5.}\n  \\begin{proof}\n    We show that $\\{I_n\\}$ must cover the entire $[0,1]$ by contradiction. \n    Assume that $x\\notin I_k$ for $k=1,2,\\dots,n$. Then, as $I_k$ are open and \n    $n$ is finite, there exists some $\\vep>0$ such that $(x-\\vep,x+\\vep)$ and \n    $I_k$ are disjoint for every $k$. Since $\\mathbb{Q}$ is dense in \n    $\\mathbb{R}$, there exists some rational number in $(x-\\vep, x+\\vep)$, \n    contradicting with the hypothesis that $\\{I_k\\}$ covers all rational numbers\n    between $0$ and $1$.\n  \\end{proof}\n\n  \\paragraph{6.}\n  \\begin{proof}\n    By the definition of the outer measure, for every $\\vep > 0$, there exists \n    some collection $\\{I_n\\}$ of open intervals that covers $A$ and $\\sum l(I_n)\n    \\le m^*A+\\vep$. Let $O=\\bigcup I_n$. $O$ is a countable union of open sets \n    and therefore is also open. And by Proposition 2, $m^*O\\le \\sum l(I_n)$. \n    Thus, $m^*O\\le m^*A+\\vep$. \\par\n    Let $\\vep_n = 1/n$ and for each $n$, by the previous discussion, we can \n    always get an open set $O_k$ such that $A\\subset O_k$ and $m^*O\\le m^*A+\n    \\vep_m$. Let $G$ be the countable intersection of these open sets. Clear \n    that $G$ is a $G_\\delta$ set covering $A$ and $m^*A=m^*G$.\n  \\end{proof}\n\n  \\paragraph{7.}\n  \\begin{proof}\n    If $m^*E=\\infty$, it is trivial. Suppose that $m^*E\\le\\infty$. For any $x\\in\n    \\mathbb{R}$, collection $\\{I_n\\}$ of open intervals covers $E+x$ iff $\\{I_n\n    -x\\}$ covers $E$. Since the length of intervals is translation invariant, \n    this implies $m^*(E+x)=m^*E$.\n  \\end{proof}\n\n  \\paragraph{8.}\n  \\begin{proof}\n    Clear that $m^*A\\le m^*(A\\cup B)$. Meanwhile, $m^*(A\\cup B) = m^*A + m^*B =\n    m^*B$. Hence, $m^*(A\\cup B)=m^*B$.\n  \\end{proof}\n% end\n\n\\subsection{Measurable Sets and Lebesgue Measure}\n  \\paragraph{10.}\n  \\begin{proof}\n    \\begin{align*}\n      mE_1+mE_2 \n      &= mE_1 + m(E_2\\setminus E_1) + m(E_1\\cap E_2) \\\\\n      &= m(E_1\\cup(E_2\\setminus E_1)) + m(E_1\\cap E_2) \\\\\n      &= m(E_1\\cup E_2) + m(E_1\\cap E_2).\n    \\end{align*}\n  \\end{proof}\n    \n  \\paragraph{11.}\n  \\begin{proof}\n    $E_n = (n,\\infty)$.\n  \\end{proof}\n\n  \\paragraph{12.}\n    This is the countable version of Lemma 9.\n  \\begin{proof}\n    It suffices to prove $m^*(A\\cap \\bigcup E_i) \\ge \\sum m^*(A\\cap E_i)$. Since\n    $\\bigcup_{i=1}^\\infty E_i\\supset \\bigcup_{i=1}^n E_i$ for every $n$, \n    \\begin{align*}\n      m^*\\left(A\\cap \\bigcup_{i=1}^\\infty E_i\\right)\n      \\ge m^*\\left(A\\cap \\bigcup_{i=1}^n E_i\\right)\n      = \\sum_{i=1}^n m^*(A\\cap E_i),\n    \\end{align*}\n    where the equality comes from Lemma 9. Since the left hand side is \n    independent of $n$, we have\n    \\[\n      m^*\\left(A\\cap \\bigcup_{i=1}^\\infty E_i\\right) \\ge\n      \\sum_{i=1}^\\infty m^*(A\\cap E_i),\n    \\]\n    completing the proof.\n  \\end{proof}\n\n  \\paragraph{13.}\n  \\begin{proof}\n    First we suppose that $m^*E<\\infty$. By Proposition 5, there exists some \n    open set $O\\supset E$ such that $m^*O\\le m^*E+\\vep$. If $E$ is measurable,\n    then by the definition,\n    \\[\n      m^*(O\\setminus E) = m^*O-m^*E \\le \\vep.\n    \\]\n    Namely, (ii) holds. Meanwhile, $O\\subset\\mathbb{R}$ is a countable union of \n    disjoint open intervals $\\{I_n\\}$. Since $mO=m^*O$ is bounded and $mO=\\sum\n    l(I_n)$, there exists some integer $N>0$ such that $mO-\\sum_{n=1}^N l(I_n)<\n    \\vep$. Let $U=\\bigcup_{n=1}^N I_n$.\n    \\begin{align*}\n      m^*(U\\bigtriangleup E) \n      &= m^*((U\\cup E) \\setminus (U\\cap E)) \\\\\n      & \\le m^*(O\\setminus (U\\cap E))  \\\\\n      & = m^*((O\\setminus U) \\cup (O\\setminus E)) \\\\\n      &\\le m^*(O\\setminus U) + m^*(O\\setminus E)  \\\\\n      &\\le 2\\vep.\n    \\end{align*}\n    Hence, (ii) implies (vi). Now we show that (vi) implies (ii). If $m^*(U\n    \\bigtriangleup E)<\\vep $, then there exists some countable collection $\\{J_n\n    \\}$ of open interval such that \n    \\[\n      \\sum l(J_n)\\le m^*(U\\bigtriangleup E)+\\vep<2\\vep.\n    \\]\n    Let $J=\\bigcup J_n$ and $O= U\\cup J$. $m^*J < 2\\vep$. And $O$ is open and \n    covers $E$. Meanwhile,\n    \\[\n      m^*(O\\setminus E) \\le m^*(U\\setminus E)+m^*(J\\setminus E) < 3\\vep.\n    \\]\n    Hence, (ii) holds.\\par\n    Now, let $E$ be an arbitrary set and $E_n=E\\cap(-n, n)$, which is a set with\n    finite measure. Then by the previous discussion, there exists some open set\n    $O_n\\supset E_n$ with $m^*(O_n\\setminus E_n)<\\vep/2^n$. Let $O=\\bigcup \n    O_n$, an open set covering $E$ and\n    \\[\n      m^*(O\\setminus E) \\le \\sum m^*(O_n\\setminus E_n) < 2\\vep. \n    \\]\n    Hence, (i) implies (ii). Now we suppose (ii) holds and let $\\vep_n=1/n$, \n    then there exists a sequence of open sets $<O_n>$ such that $m^*(O_n\n    \\setminus E)<1/n$. Let $G=\\bigcap O_n\\in G_\\delta$. $m^*(G\\setminus E)\\le\n    m^*(O_n\\setminus E)\\le 1/n$. Since the left hand side is independent of \n    $n$, $m^*(G\\setminus E)=0$. If (iv) holds, then by Lemma 6, $G\\setminus E$\n    is measurable. Since $G\\in G_\\delta$ is also measurable, $E$ is measurable.\n    Hence, (iv) implies (i).\\par\n    By the previous result, for any measurable $E$, there exists some closed set\n    $F\\subset E$ such that $\\bar{F}$, which is open, contains $bar{E}$ and $m^*(\n    \\bar{F}\\setminus \\bar{E})<\\vep$. Hence, $m^*(E\\setminus F)<\\vep$. We can \n    proceed in a similar manner as we did in the last paragraph to prove that\n    (iii) $\\Rightarrow$ (v) $\\Rightarrow$ (i), leading to the final conclusion.\n  \\end{proof}\n\n% end\n\n\\setcounter{subsection}{4}\n\\subsection{Measurable Functions}\n  \\paragraph{19.}\n  \\begin{proof}\n    For every $\\beta\\in\\mathbb{R}$, since $D$ is measurable, there exists a \n    sequence of $\\alpha_n\\in D\\cap(\\beta-1/n,\\beta)$. As\n    \\[\n      \\{x:\\, f(x)>r\\} \\quad\\Leftrightarrow\\quad\n      \\bigcup_{n=1}^\\infty \\{x:\\, f(x)>r-1/n\\} \\quad\\Leftrightarrow\\quad\n      \\bigcup_{n=1}^\\infty \\{x:\\, f(x)>\\alpha_n\\}\n    \\]\n    and $\\{x:\\, f(x)>\\alpha_n\\}$ are measurable, so is $\\{x:\\, f(x)>r\\}$. Hence,\n    $f$ is measurable.\n  \\end{proof}\n\n  \\paragraph{21.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) It follows immediately from $\\{x:\\, f(x)>\\alpha\\} = \\{x\\in D:\\, f(x)>\n    \\alpha\\}\\cup \\{x\\in E:\\, f(x)>\\alpha\\}$.\\par\n    (b) For $\\alpha\\ge 0$, the sets $\\{x:\\, f(x)>\\alpha\\}$ and $\\{x:\\, g(x)>\n    \\alpha\\}$ are the same. And for $\\alpha < 0$, \n    \\[\n      \\{x:\\, f(x)>\\alpha\\} = \\{x:\\, g(x)>\\alpha\\} \\setminus \\bar{D}\n      \\quad\\text{and}\\quad\n      \\{x:\\, g(x)>\\alpha\\} = \\{x:\\, f(x)>\\alpha\\} \\cup \\bar{D}.\n    \\]\n    Hence, $f$ is measurable iff $g$ is measurable.\n  \\end{proof}\n\n  \\paragraph{22.(d)}\n  \\begin{proof}\n    Since $f$ and $g$ are finite almost everywhere, the set $A$ consisting of \n    points where $f+g$ is of the form $\\infty - \\infty$ or $-\\infty + \\infty$ is\n    of measure zero (and hence measurable). Therefore no matter how it is \n    defined, $\\{x\\in A:\\,f+g>\\alpha\\}$ is measurable for every $\\alpha$. Namely,\n    the restriction of $f+g$ to $A$ is measurable. Meanwhile, clear that the \n    restriction to $D\\setminus A$ is measurable where $D$ is the domain of $f$.\n    Hence, by Exercise 21, $f$ is measurable.\n  \\end{proof}\n\n  \\paragraph{23.}\n  \\begin{proof}\n    $\\,$\\par\n    (a) Let $A_n=\\{x:\\,|f(x)|>n\\}$, a sequence of measurable sets. As $A_{n+1}\n    \\subset A_n$, $mA_{n+1}\\le mA_n$. Since $A=\\bigcap A_n = \\{x:\\,|f(x)|=\\infty\n    \\}$, $mA_1\\le m[a,b]$ is finite and $mA=0$, by Proposition 14, there exists\n    some $N$ such that for all $n\\ge N$, $mA_n<\\vep/3$. Set $M=N$ to complete \n    the proof.\\par\n    (b) We consider the restriction of $f$ on to the set $E=[a,b]\\setminus\\{x:\\,\n    |f(x)|\\ge M\\}$, which is also a measurable real-valued function. To keep our \n    notation simple, we denote the restriction by $f$ still. For every $\\vep>0$,\n    there exists some integer $N$ with $0<2M/N<\\vep$. Let $E_n=\\{x:\\,x\\in\n    [-M+(n-1)\\vep, -M+n\\vep]\\}$ ($n=1,2,\\dots,N$) and define \n    \\[\n      \\varphi(x) = \\sum_{i=1}^N f(x_i)\\chi_{E_i},\n    \\]\n    where $x_n\\in E_n$ is arbitrary. Clear that $\\varphi$ is a simple function \n    and satisfy all the requirements.\\par\n    (c) Suppose that $\\varphi(x)=\\sum_{i=1}^n \\alpha_i\\chi_{E_i}$. For each $i\n    =1,\\dots,N$, $E_i$ is measurable and therefore by Proposition 15, there \n    exists a finite union $U_i$ of open intervals such that $m(U_i\\bigtriangleup\n    E_i)<\\vep$. Let \n    \\[\n      g(x) = \\sum_{i=1}^N \\alpha_i\\chi_{U_i}.\n    \\]\n    Clear that $g$ and $\\varphi$ only may differ on a set with measure $N\\vep$.\n    (d) Suppose that $g(x)=\\sum_{i=1}^N\\alpha_i\\chi_{U_i}$ is a step function. \n    We may assume without loss of generality that $U_i$ are disjoint and \n    $\\bigcup U_i = [a,b]$. And suppose that $\\{x_0=a < x_1 < \\dots < x_N=b\\}$ \n    are the endpoints of the intervals. For each $i=1,\\dots,N-1$, define\n    \\[\n      f(x) = (x-x_i+\\vep)g(x_i-\\vep) + (x_i+\\vep - x)g(x_i+\\vep),\\quad\n      x\\in (x_i-\\vep, x_i+\\vep),\n    \\]\n    and $f(x)=g(x)$ for the other points. (We assume that $\\vep$ is small enough\n    so that $f$ is well-defined.) Clear that $f$ is continuous and equals $g$\n    except on a set of measure less then $2N\\vep$.\n  \\end{proof}\n\n  \\paragraph{24.}\n  \\begin{proof}\n    For measurable $f$, we show that $\\mathcal{A}=\\{E:\\, f\\inv[E]\\text{ is \n    measurable}\\}$ is a $\\sigma$-algebra first. As the domain, denoted by $D$, \n    of a measurable function is measurable, $\\mathbb{R}\\in\\mathcal{A}$. If\n    $E\\in\\mathcal{A}$, then since $f\\inv[\\bar{E}]= D\\cap \\overline{f\\inv[E]}$,\n    $f\\inv[\\bar{E}]$ is also measurable and therefore $\\bar{E}\\in\\mathcal{A}$.\n    Suppose that $<E_n>$ is a sequence of sets of $\\mathcal{A}$. Then, as\n    \\[\n      f\\inv\\left[\\bigcup_{n=1}^\\infty E_n\\right] = \n      \\bigcup_{n=1}^\\infty f\\inv[E_n],\n    \\]\n    $\\bigcup E_n\\in\\mathcal{A}$. Hence, $\\mathcal{A}$ is a $\\sigma$-algebra.\\par\n    By the definition of a measurable function, every open interval belongs to \n    $\\mathcal{A}$. Since the collection of all Borel sets $\\mathcal{B}$ is the\n    $\\sigma$-algebra generated by all open intervals, $\\mathcal{B}\\subset\n    \\mathcal{A}$. Namely, $f\\inv[B]$ is measurable as long as $B\\in\\mathcal{B}$.\n  \\end{proof}\n\n\n% end\n\n\\subsection{Littlewood's Three Principles}\n  \\paragraph{30.}\n  \\begin{proof}\n    Let $\\vep_n=1/n$ and $\\delta_n =\\eta/2^n$ ($n=0,1,\\dots$). By Proposition\n    24, for each $n$, there exists some $A_n$ with measure less than $\\delta_n$\n    such that for all $x\\in E_n\\setminus A_n$, $|f_m(x) - f(x)|<\\vep_n$ for $m$\n    large enough. Let $A=\\bigcup_{n=1}^\\infty A_n$, the measure of which is less\n    than $\\sum \\eta/2^n=\\delta$. Meanwhile, for any $\\vep>0$, by construction, \n    for all $x\\in E\\setminus A$, $|f_m(x)-f(x)|<\\vep$ for $m$ large enough. \n    Namely, $f_n$ converges to $f$ uniformly on $E\\setminus A$.\n  \\end{proof}\n    \n  \\paragraph{31.}\n  \\begin{proof}\n    Let $\\vep_n=\\delta/2^n$ ($n\\ge 0$), then by Proposition 22, there exists \n    continuous $g_n$ such that $E_n=\\{x:\\,|f(x)-g_n(x)|\\ge\\vep_n\\}$ is of \n    measure less than $\\vep_n$. Let $E=\\bigcup E_n$, the measure of which is \n    less than $\\delta$ and $g_n$ converges to $f$ on $[a,b]\\setminus E$.\\par\n    By Egoroff's Theorem, there exists some $A\\subset [a,b]\\setminus E$ with $m\n    A<\\delta$ such that $g_n$ converges to $f$ uniformly on $[a,b]\\setminus(E\n    \\cup A)]$. Since $E\\cup A$ is measurable, by Proposition 15, there exists \n    some open set $O\\supset E\\cup A$ such that $m(O\\setminus(E\\cup A))<\\delta$.\n    Let $F=[a,b]\\setminus O$. We know that \n    \\begin{enumerate}\n      \\item $F$ is a closed set.\n      \\item $mF < 3\\delta$.\n      \\item $g_n$ converges to $f$ uniformly on $F$.\n    \\end{enumerate}\n    Hence, $f$ is continuous on $F$ And by Problem 2.40, there exists some \n    continuous function on $\\mathbb{R}$ such that $\\varphi(x) = f(x)$ for $x\\in\n    F$.\\par\n    If $f$ is defined on $(-\\infty,\\infty)$, we can apply the previous result on\n    each $[n,n+1]$ and \"stick\" the functions together as we did in Problem 23(c)\n    to get the function required.\n  \\end{proof}\n% end\n", "meta": {"hexsha": "677c5bde9cb2dea126e76d0e0527adb4b8d85a0c", "size": 12853, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "real_analysis_3rd/ch3_lebesgue_measure.tex", "max_stars_repo_name": "Engineev/solutions", "max_stars_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-07-13T08:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T17:37:17.000Z", "max_issues_repo_path": "real_analysis_3rd/ch3_lebesgue_measure.tex", "max_issues_repo_name": "Engineev/solutions", "max_issues_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "real_analysis_3rd/ch3_lebesgue_measure.tex", "max_forks_repo_name": "Engineev/solutions", "max_forks_repo_head_hexsha": "4e33274fe1ed9e46fd0e6671c57cb589704939bd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-28T00:05:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-28T00:05:28.000Z", "avg_line_length": 43.2760942761, "max_line_length": 81, "alphanum_fraction": 0.601338209, "num_tokens": 4839, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.4210610704793595}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{caption}\n\\usepackage{amsmath,amsfonts,amssymb}\n\\DeclareMathOperator{\\e}{e}\n\\usepackage{geometry}\n\\usepackage{ulem}\n\\usepackage{comment}\n\\usepackage{enumitem}\n\\usepackage{amsmath}\n\\usepackage{systeme}\n\\usepackage{array}\n\\usepackage{float}\n\\usepackage{gensymb}\n\\usepackage{listings}\n\\usepackage{minted}\n\\usepackage{hyperref}\n\\usepackage{appendix}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage[nottoc,notlot,notlof]{tocbibind}\n\\usepackage{indentfirst}\n\n\\title{Time-Splitting Method}\n\\author{}\n\\date{}\n\n\\newcommand{\\fder}[2]{\\frac{\\delta #1}{\\delta f}\\Bigr|_{#2}}\n\\newcommand{\\fint}[3]{\\int\\fder{#1}{#2}#3(#2)}\n\n\\begin{document}\n\n\\maketitle\n\n\\subsection*{Justification of the Time-Splitting Method for non-linear operators}\n\nLet $\\mathcal{H}$ be a normed sub-vector space of smooth enough functions of $\\mathcal{F}(\\mathbb{R}^3,\\mathbb{C})$, $f_0\\in \\mathcal{H}$, $A$ and $B$ (not necessarily linear) operators $\\mathcal{H} \\longmapsto \\mathcal{H}$.\\par\nWe are looking for $f:t\\in \\mathbb{R} \\longmapsto f(t)\\in \\mathcal{H}$, such that (writing $f$ also for the function $(t,\\mathbf{x}) \\longmapsto f(t)(\\mathbf{x})$):\n\\begin{equation}\\label{initialEq}\n    \\partial_t f = A(f) + B(f)~~~~,~~~~\\text{and} ~~ f(0)=f_0\n\\end{equation}\nWe want to solve this numerically. So, for fixed $t$ and small enough $\\epsilon$, we want an approximation of $f(t+\\epsilon)$ as a function of $f(t)$. Let $f^{(1)},f^{(2)},f^{(3)}\\in \\mathcal{H}$ such that:\n\n\\begin{equation}\\label{TSM}\n\\begin{split}\n    \\partial_t f^{(1)} &= A(f^{(1)})~~~~,~~~~ f^{(1)}(0)=f(t)\\\\\n    \\partial_t f^{(2)} &= B(f^{(2)})~~~~,~~~~ f^{(2)}(0)=f^{(1)}(\\frac{\\epsilon}{2})\\\\\n    \\partial_t f^{(3)} &= A(f^{(3)})~~~~,~~~~ f^{(3)}(0)=f^{(2)}(\\epsilon)\n    \\end{split}\n\\end{equation}\n\nWe are going to show that:\n\\begin{equation}\\label{Theo}\n    f(t+\\epsilon)-f^{(3)}(\\frac{\\epsilon}{2}) ~=~ \\mathcal{O}(\\epsilon^3)\n\\end{equation}\n\nFor $\\mathbf{x}\\in \\mathbb{R}^3$, we define the functionals $A_\\mathbf{x} : g \\longmapsto A(g)(\\mathbf{x})\\in \\mathbb{C}$ and $B_\\mathbf{x} : g \\longmapsto B(g)(\\mathbf{x})\\in \\mathbb{C}$. We will assume that for all $\\mathbf{x}$, $A_\\mathbf{x}$ and $B_\\mathbf{x}$ are smooth enough so that their functional derivatives exist and they can be Taylor-expanded to the 1\\textsuperscript{st} order:\n\\begin{equation}\\label{Taylor}\n    F(g+\\epsilon h)=F(g)+\\int\\text{d}^3\\mathbf{x}\\fder{F}{g}(\\mathbf{x})\\epsilon h(\\mathbf{x})+\\mathcal{O}(\\epsilon^2)\n\\end{equation}\nfor $F=A_\\mathbf{x},B_\\mathbf{x}$. It also follows that:\n\\begin{equation}\\label{totalder}\n    \\frac{\\text{d}}{\\text{d}t}F(g(t))=\\int\\text{d}^3\\mathbf{x}\\fder{F}{g(t)}(\\mathbf{x})~\\partial_t g(t,\\mathbf{x})\n\\end{equation}\n\nLet $\\mathbf{x}_0\\in\\mathbb{R}^3$. We have:\n$$f(t+\\epsilon,\\mathbf{x}_0)=f(t,\\mathbf{x}_0)+\\epsilon\\partial_t f(t,\\mathbf{x}_0)+\\frac{\\epsilon^2}{2}\\partial_t^2 f(t,\\mathbf{x}_0)+\\mathcal{O}(\\epsilon^3)$$\nFrom \\eqref{initialEq} and using \\eqref{totalder} we get:\n\\begin{equation}\\label{Eqf}\n    \\begin{split}\n    f(t+\\epsilon,\\mathbf{x}_0)=&f(t,\\mathbf{x}_0)~+~\\epsilon (A_{\\mathbf{x}_0}+B_{\\mathbf{x}_0})(f(t))\\\\\n    &+\\frac{\\epsilon^2}{2}\\int \\text{d}^3\\mathbf{x}\\left[ \\fder{A_{\\mathbf{x}_0}}{f(t)}(\\mathbf{x})+\\fder{B_{\\mathbf{x}_0}}{f(t)}(\\mathbf{x}) \\right]~ (A_{\\mathbf{x}_0}+B_{\\mathbf{x}_0})(f(t))(\\mathbf{x}) ~+~\\mathcal{O}(\\epsilon^3)\n    \\end{split}\n\\end{equation}\nIn the following we will drop the $\\mathbf{x}_0$, keeping in mind that the equations have in fact the form of \\eqref{Eqf}.\\par\n\nLet us now compute $f^{(3)}(\\frac{\\epsilon}{2})$. We will use \\eqref{TSM}, \\eqref{Taylor} and \\eqref{totalder} and keep only 2\\textsuperscript{nd} order terms in $\\epsilon$ at most.\n\\small\n\\begin{align*}\n        f^{(3)}(\\frac{\\epsilon}{2})&=f^{(3)}(0)+\\epsilon\\partial_t f^{(3)}(0)+\\frac{\\epsilon^2}{8}\\partial_t^2f^{(3)}(0)+\\mathcal{O}(\\epsilon^3)\\\\\n        &= f^{(3)}(0) + \\frac{\\epsilon}{2}A(f^{(3)}(0)) + \\frac{\\epsilon^2}{8}\\int \\fder{A}{f^{(3)}(0)}A(f^{(3)}(0))~+~\\mathcal{O}(\\epsilon^3)\n\\end{align*}\n\\normalsize\nWe have {\\scriptsize $f^{(3)}(0)=f^{(2)}(\\epsilon)=f^{(2)}(0)+\\epsilon\\partial_t f^{(2)}(0)+\\frac{\\epsilon^2}{2}\\partial_t^2f^{(2)}(0)+\\mathcal{O}(\\epsilon^3)$}. So, Taylor-expanding:\n\\small\n\\begin{align*}\n        f^{(3)}(\\frac{\\epsilon}{2})&= f^{(2)}(0)+\\epsilon\\partial_t f^{(2)}(0)+\\frac{\\epsilon^2}{2}\\partial_t^2f^{(2)}(0) + \\frac{\\epsilon}{2}\\left(A(f^{(2)}(0)+\\int \\fder{A}{f^{(2)}(0)}\\epsilon\\partial_t f^{(2)}(0)\\right)\\\\\n        &\\qquad \\qquad \\qquad+ \\frac{\\epsilon^2}{8}\\int \\fder{A}{f^{(2)}(0)}A(f^{(2)}(0)) ~+~\\mathcal{O}(\\epsilon^3)\\\\\n        &=f^{(2)}(0)+\\epsilon\\left[B(f^{(2)}(0)+\\frac{1}{2}A(f^{(2)}(0)\\right]\\\\\n        &\\qquad +\\frac{\\epsilon^2}{2}\\left[\\fint{B}{f^{(2)}(0)}{B}+\\fint{A}{f^{(2)}(0)}{B}+\\frac{1}{4}\\fint{A}{f^{(2)}(0)}{A}\\right]~+~\\mathcal{O}(\\epsilon^3)\n\\end{align*}\n\\normalsize\nAgain we have {\\scriptsize $f^{(2)}(0)=f^{(1)}(\\frac{\\epsilon}{2})=f^{(1)}(0)+\\frac{\\epsilon}{2}\\partial_t f^{(1)}(0)+\\frac{\\epsilon^2}{8}\\partial_t^2f^{(1)}(0)+\\mathcal{O}(\\epsilon^3)$}, so:\n\\small\n\\begin{align*}\n        f^{(3)}(\\frac{\\epsilon}{2})&= f^{(1)}(0)+\\frac{\\epsilon}{2}\\partial_t f^{(1)}(0)+\\frac{\\epsilon^2}{8}\\partial_t^2f^{(1)}(0)\\\\&\\qquad+ \\epsilon\\left(B(f^{(1)}(0))+\\int \\fder{B}{f^{(1)}(0)}\\frac{\\epsilon}{2}\\partial_t f^{(1)}(0)+\\frac{1}{2}A(f^{(1)}(0))+\\frac{1}{2}\\int \\fder{A}{f^{(1)}(0)}\\frac{\\epsilon}{2}\\partial_t f^{(1)}(0)\\right)\\\\\n        &\\qquad \\qquad + \\frac{\\epsilon^2}{2}\\left(\\fint{B}{f^{(1)}(0)}{B}+\\fint{A}{f^{(1)}(0)}{B}+\\frac{1}{4}\\fint{A}{f^{(1)}(0)}{A}\\right) ~+~\\mathcal{O}(\\epsilon^3)\n\\end{align*}\n\\normalsize\nGathering terms, we get:\n\\begin{equation}\\label{Eqf3}\n    \\begin{split}\n    f^{(3)}(\\frac{\\epsilon}{2})=& f^{(1)}(0)~+~\\epsilon (A+B)(f^{(1)}(0))\\\\\n    &+\\frac{\\epsilon^2}{2}\\int \\left[ \\fder{A}{f^{(1)}(0)}+\\fder{B}{f^{(1)}(0)} \\right]~ (A+B)(f^{(1)}(0)) ~+~\\mathcal{O}(\\epsilon^3)\n    \\end{split}\n\\end{equation}\nSince $f^{(1)}(0)=f(t)$, we see that the expression is the same as \\eqref{Eqf}. Hence we proved \\eqref{Theo}.\n\n\\end{document}\n", "meta": {"hexsha": "4f08fdf9ce27172ca5d49e17f7627356d50d5d5f", "size": 6130, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Time_splitting_method.tex", "max_stars_repo_name": "superporchetta/BEC_TSSP", "max_stars_repo_head_hexsha": "ce6e36d208518cf9951f4961965ec88031dd01ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-05T11:01:31.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-05T11:01:31.000Z", "max_issues_repo_path": "docs/Time_splitting_method.tex", "max_issues_repo_name": "superporchetta/numerical_methods_project", "max_issues_repo_head_hexsha": "ce6e36d208518cf9951f4961965ec88031dd01ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/Time_splitting_method.tex", "max_forks_repo_name": "superporchetta/numerical_methods_project", "max_forks_repo_head_hexsha": "ce6e36d208518cf9951f4961965ec88031dd01ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.7321428571, "max_line_length": 393, "alphanum_fraction": 0.6135399674, "num_tokens": 2590, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4209631278623163}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n \n\\title{Sample \\LaTeX -document}\n\\author{Michael Thumand}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\nHere is an example of in-line use of math $a\\otimes b = c$ and here the text continues. Below this paragraph is another example of a math equation:\n\n\\begin{equation}\nE=mc^2\n\\end{equation}\n\n\\begin{equation}\na^2 + b^2 = c^2\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "56bd7e0a9fe2361cf59e5482582f2d07a45c1566", "size": 413, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex_samples/math_sample.tex", "max_stars_repo_name": "to-the-gallaxy/miktex-linux-install", "max_stars_repo_head_hexsha": "8d4b9c9cdd7399f383efa183d85588daad6f4545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "latex_samples/math_sample.tex", "max_issues_repo_name": "to-the-gallaxy/miktex-linux-install", "max_issues_repo_head_hexsha": "8d4b9c9cdd7399f383efa183d85588daad6f4545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex_samples/math_sample.tex", "max_forks_repo_name": "to-the-gallaxy/miktex-linux-install", "max_forks_repo_head_hexsha": "8d4b9c9cdd7399f383efa183d85588daad6f4545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.52, "max_line_length": 147, "alphanum_fraction": 0.7360774818, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.42095358473929484}}
{"text": "\\documentclass[10pt]{article}\n\n\\usepackage{fullpage}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\n\\usepackage{clrscode3e}\n\n\\usepackage{enumitem}\n%\\usepackage{parskip}\n%\\setlist{parsep=8pt,listparindent=\\parindent}\n\\setlength\\parindent{0pt}\n\\setlength\\parskip{6pt}\n\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{corollary}{Corollary}\n\\newtheorem{proposition}{Proposition}\n\n\\begin{document}\n\n\\noindent CSC373 Assignment 1 \\hfill Eric Bannatyne\\\\\n24 February 2015 \\hfill 1000468451\\\\\n\nThe following algorithm updates the given minimum spanning tree \\(T\\) of \\(G\\), to produce a new minimum spanning tree \\(T_1\\) for \\(G_1\\).\n\n\\begin{codebox}\n\\Procname{\\(\\proc{Update-MST}(V, E, w, T, e_1, w_1)\\)}\n%\\li \\(E_1 = E \\cup \\{e_1\\}\\)\n%\\li \\(G_1 = (V, E_1)\\)\n\\li \\(T_1 = T \\cup \\{e_1\\}\\)\n\\li \\(D = \\) DFS tree produced by DFS on \\(T_1\\) starting from \\(u\\), including information about back edges \\Comment CLRS p. 610\n\n\\li \\(e = \\const{nil}\\)\n\\li \\(\\id{weight} = 0\\)\n\\li \\Comment Find the (unique) back edge of \\(D\\).\n\\li \\Comment This must have \\(u\\) as an endpoint since \\(e_1\\) is in the cycle and DFS was started at \\(u\\).\n\\li \\For \\(x\\) in \\(u.\\id{neighbours}\\) \\Comment Neighbours in \\(T_1\\)\n\t\\Do\n\t\\li \\If \\(\\{x, u\\}\\) is a back edge of \\(D\\)\n\t\t\\Then\n\t\t\\li \\(e = \\{x, u\\}\\)\n\t\t\\li \\(\\id{weight} = w(e)\\)\n\t\t\\li \\textbf{break}\n\t\t\\End\n\t\\End\n\n\\li \\Comment Traverse up along the cycle in the DFS tree until the root \\(u\\) is reached,\n\\li \\Comment keeping track of the maximum-weight edge.\n\\li \\While \\(x \\neq u\\)\n\t\\Do\n\t\\li \\If \\(w(\\{x, x.\\id{parent}\\}) > \\id{weight}\\) \\Comment \\(x.\\id{parent}\\) in \\(D\\)\n\t\t\\Then\n\t\t\\li \\(e = \\{x, x.\\id{parent}\\}\\)\n\t\t\\li \\(\\id{weight} = w(e)\\)\n\t\t\\End\n\t\\li \\(x = x.\\id{parent}\\)\n\t\\End\n\\li \\(T_1 = T_1 - \\{e\\}\\)\n\\li \\Return \\(T_1\\)\n\\end{codebox}\n\n\\subsection*{Correctness}\n\nOn a high level, this algorithm updates \\(T\\) by inserting the new edge \\(e_1 = \\{u, v\\}\\) into \\(T\\). This produces exactly one cycle in the graph \\(T \\cup \\{e_1\\}\\) (Result given on Piazza). The algorithm then finds and removes the maximum-weight edge \\(e\\) from the cycle, to produce a new tree \\(T_1 = T \\cup \\{e_1\\} - \\{e\\}\\). This is, in fact, a spanning tree, since the removed edge \\(e\\) is on a cycle, meaning that neither of the endpoints of \\(e\\) become isolated vertices when \\(e\\) is removed. We will show that \\(T_1\\) is in fact a minimum spanning tree.\n\nBy definition, we have \\(w(T_1) = w(T \\cup \\{e_1\\} - \\{e\\}) = w(T) + w(e_1) - w(e)\\). However, since \\(e\\) is a maximum-weight vertex on its cycle in \\(T \\cup \\{e_1\\}\\) and \\(e_1\\) lies on that cycle, we have \\(w(e_1) \\leq w(e)\\), which implies that \\(w(T) \\geq w(T_1)\\).\n\nTo show that the spanning tree that this algorithm produces is indeed a minimum spanning tree of \\(G_1\\), suppose that \\(T_1\\) is not a MST. Then since \\(G_1\\) is connected, there must be some MST \\(T_1'\\) for \\(G_1\\) such that \\(w(T_1') < w(T_1)\\). We have two cases to consider, depending on whether or not \\(T_1'\\) contains \\(e_1\\).\n\nIf \\(e_1 \\notin T_1'\\), then \\(T_1'\\) must be a spanning tree for \\(G\\), which means that \\(w(T) \\leq w(T_1')\\). However, since we established that \\(w(T_1) \\leq w(T) \\leq w(T_1')\\), this contradicts our assumption that \\(w(T_1') < w(T_1)\\). Therefore \\(T_1\\) must also be a minimum spanning tree.\n\nNow suppose that \\(e_1 \\in T_1'\\). Removing \\(e_1 = \\{u, v\\}\\) from \\(T_1'\\) must disconnect the tree, such that \\(T_1' - \\{e_1\\}\\) contains exactly two connected components \\(A = (V_A, E_A)\\) and \\(B = (V_B, E_B)\\), such that \\(u \\in V_A\\) and \\(v \\in V_B\\). Let \\(C\\) be the unique cycle contained in \\(T \\cup \\{e_1\\}\\). It will be helpful to prove the following lemma.\n\n\\begin{lemma}There is some edge \\(e' = \\{a, b\\} \\in C - \\{e_1\\}\\) such that \\(a \\in V_A\\) and \\(b \\in V_B\\).\\end{lemma}\n\\begin{proof}\nSince \\(C\\) is a cycle, \\(C - \\{e_1\\}\\) must be a connected subgraph of \\(T\\) which is a chain of the form \\[u = w_1 \\longleftrightarrow w_2 \\longleftrightarrow \\dots \\longleftrightarrow w_k = v, \\] where ``\\(\\longleftrightarrow\\)'' denotes ``is adjacent to (in \\(C - \\{e_1\\}\\))''. Since \\(V_A \\cap C\\) and \\(V_B \\cap C\\) form a partition of the vertices included in \\(C\\), and we know that \\(u \\in V_A\\) and \\(v \\in V_B\\), there must be some \\(i\\) such that \\(w_i \\in V_A\\) and \\(w_{i+1} \\in V_B\\). Choosing \\(e' = \\{w_i, w_{i+1}\\}\\) completes the proof.\n\\end{proof}\n\nThis means that, if we remove \\(e_1\\) from \\(T_1'\\), there must be some edge \\(e'\\) in \\(C - \\{e_1\\}\\) such that \\(T_1' - \\{e_1\\} \\cup \\{e'\\}\\) is a spanning tree of \\(G\\). Since \\(e' \\in C\\), we know that \\(w(e') \\leq w(e)\\), where \\(e\\) is the edge that the algorithm chose to remove from the cycle when producing \\(T_1\\). Thus, we have \\begin{align*}\nw(T) &\\leq w(T_1') - w(e_1) + w(e') \\\\\n&< w(T_1) - w(e_1) + w(e') \\\\\n&\\leq w(T_1) - w(e_1) + w(e) \\\\\n&= w(T_1 - \\{e_1\\} \\cup \\{e\\}) \\\\\n&= w(T).\n\\end{align*}\n\nThus, \\(w(T) < w(T)\\), which is a contradiction. Therefore \\(T_1\\) must be a minimum spanning tree of \\(G_1\\).\n\n\\subsection*{Running Time}\n\nWe now analyze the running time of \\proc{Update-MST}. Performing depth-first search to obtain the DFS tree \\(D\\) requires \\(\\Theta(|V| + m)\\) steps, where \\(m\\) is the number of edges in \\(T \\cup \\{e\\}\\). However, since \\(T\\) is a spanning tree of \\(G\\), it contains \\(|V| - 1\\) edges, so \\(m = |V|\\), and so this step really only requires \\(\\Theta(|V|)\\) time.\n\nThe rest of the algorithm proceeds by examining the neighbours of \\(u\\) in \\(T \\cup \\{e_1\\}\\) to find a back edge, and then traversing a single cycle of \\(T \\cup \\{e_1\\}\\), both of which are bounded above by \\(O(|T|) = O(V|)\\) operations, as before. Therefore \\proc{Update-MST} runs in \\(\\Theta(|V|)\\) time in the worst case, an improvement over using the standard algorithms to produce a new minimum spanning tree from scratch.\n\n\\end{document}\n\n", "meta": {"hexsha": "59f63ea74d88c2d5a3114e445e02bfb783aa62ce", "size": 5837, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CS/CSC373/files of other terms/CSC373 2009-2019/2015/assignments/assignment 1/my work/a1q1a.tex", "max_stars_repo_name": "jerrysun103/uoft", "max_stars_repo_head_hexsha": "6264583d27c7db94596d29c73804e6d9155de191", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CS/CSC373/files of other terms/CSC373 2009-2019/2015/assignments/assignment 1/my work/a1q1a.tex", "max_issues_repo_name": "jerrysun103/uoft", "max_issues_repo_head_hexsha": "6264583d27c7db94596d29c73804e6d9155de191", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CS/CSC373/files of other terms/CSC373 2009-2019/2015/assignments/assignment 1/my work/a1q1a.tex", "max_forks_repo_name": "jerrysun103/uoft", "max_forks_repo_head_hexsha": "6264583d27c7db94596d29c73804e6d9155de191", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.9595959596, "max_line_length": 567, "alphanum_fraction": 0.6357718006, "num_tokens": 2078, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7981867801399695, "lm_q1q2_score": 0.4208970779109396}}
{"text": "\n\n    \\filetitle{SVAR}{Convert reduced-form VAR to structural VAR}{SVAR/SVAR}\n\n\t\\paragraph{Syntax}\\label{syntax}\n\n\\begin{verbatim}\n[S,DATA,B,COUNT] = SVAR(V,DATA,...)\n\\end{verbatim}\n\n\\paragraph{Input arguments}\\label{input-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{V} {[} VAR {]} - Reduced-form VAR object.\n\\item\n  \\texttt{DATA} {[} struct \\textbar{} tseries {]} - Data associated with\n  the input VAR object.\n\\end{itemize}\n\n\\paragraph{Output arguments}\\label{output-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{S} {[} VAR {]} - Structural VAR object.\n\\item\n  \\texttt{DATA} {[} struct \\textbar{} tseries {]} - Data with\n  transformed structural residuals.\n\\item\n  \\texttt{B} {[} numeric {]} - Impact matrix of structural residuals.\n\\item\n  \\texttt{COUNT} {[} numeric {]} - Number of draws actually performed\n  (both successful and unsuccessful) when \\texttt{'method'='draw'};\n  otherwise \\texttt{COUNT=1}.\n\\end{itemize}\n\n\\paragraph{Options}\\label{options}\n\n\\begin{itemize}\n\\item\n  \\texttt{'maxIter='} {[} numeric \\textbar{} \\emph{\\texttt{0}} {]} -\n  Maximum number of attempts when \\texttt{'method'='draw'}.\n\\item\n  \\texttt{'method='} {[} \\emph{\\texttt{'chol'}} \\textbar{}\n  \\texttt{'householder'} \\textbar{} \\texttt{'qr'} \\textbar{}\n  \\texttt{'svd'} {]} - Method that will be used to identify structural\n  VAR and structural shocks.\n\\item\n  \\texttt{'nDraw='} {[} numeric \\textbar{} \\emph{\\texttt{0}} {]} -\n  Target number of successful draws when \\texttt{'method'='draw'}.\n\\item\n  \\texttt{'reorder='} {[} numeric \\textbar{} \\emph{empty} {]} - Reorder\n  VAR variables before identifying structural shocks, and bring the\n  variables back in original order afterwards. Use the option\n  '\\texttt{backorderResiduals='} to control if also the structural\n  shocks are to be brought back in original order.\n\\item\n  \\texttt{'output='} {[} \\emph{\\texttt{'auto'}} \\textbar{}\n  \\texttt{'dbase'} \\textbar{} \\texttt{'tseries'} {]} - Format of output\n  data.\n\\item\n  \\texttt{'progress='} {[} \\texttt{true} \\textbar{}\n  \\emph{\\texttt{false}} {]} - Display progress bar in the command\n  window.\n\\item\n  \\texttt{'rank='} {[} numeric \\textbar{} \\emph{\\texttt{Inf}} {]} -\n  Reduced rank of the covariance matrix of structural residuals when\n  \\texttt{'method=' 'svd'}; \\texttt{Inf} means full rank is preserved.\n\\item\n  \\texttt{'backOrderResiduals='} {[} \\emph{\\texttt{true}} \\textbar{}\n  \\texttt{false} {]} - Bring the identified structural shocks back in\n  original order after identification; works with \\texttt{'reorder='}.\n\\item\n  \\texttt{'std='} {[} numeric \\textbar{} \\emph{\\texttt{1}} {]} - Std\n  deviation of structural residuals; the resulting structural covariance\n  matrix will be re-scaled (divided) by this factor.\n\\item\n  \\texttt{'test='} {[} char {]} - Works with \\texttt{'method=draw'}\n  only; a string that will be evaluated for each random draw of the\n  impact matrix \\texttt{B}. The evaluation must result in \\texttt{true}\n  or \\texttt{false}; only the matrices \\texttt{B} that evaluate to\n  \\texttt{true} will be kept. See Description for more on how to write\n  the option \\texttt{'test='}.\n\\end{itemize}\n\n\\paragraph{Description}\\label{description}\n\n\\subparagraph{Identification random Householder\ntransformations}\\label{identification-random-householder-transformations}\n\nThe structural impact matrices \\texttt{B} are randomly generated using a\nHouseholder transformation algorithm. Each matrix is tested by\nevaluating the \\texttt{test} string supplied by the user. If it\nevaluates to true the matrix is kept and one more SVAR parameterisation\nis created, if it is false the matrix is discarded.\n\nThe \\texttt{test} string can refer to the following characteristics:\n\n\\begin{itemize}\n\\item\n  \\texttt{S} -- the impulse (or shock) response function; the\n  \\texttt{S(i,j,k)} element is the response of the \\texttt{i}-th\n  variable to the \\texttt{j}-th shock in period \\texttt{k}.\n\\item\n  \\texttt{Y} -- the asymptotic cumulative response function; the\n  \\texttt{Y(i,j)} element is the asumptotic (long-run) cumulative\n  response of the \\texttt{i}-th variable to the \\texttt{j}-th shock.\n\\end{itemize}\n\n\\paragraph{Example}\\label{example}\n\n\n", "meta": {"hexsha": "8c0567a66e716fe26b73c0430ce282ae691532cc", "size": 4138, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/SVAR/SVAR.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/SVAR/SVAR.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/SVAR/SVAR.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 36.6194690265, "max_line_length": 75, "alphanum_fraction": 0.7092798453, "num_tokens": 1222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4208930230309941}}
{"text": "% Results\n\\chapter{Results}\n\\label{ch:results}\n%\\epigraphhead{\\epigraph{\n%Usability answers the question, ``Can the user accomplish their goal?''}{\\textsc{Joyce Lee}}}\nThe numerical results of the experiments and the analyses are shown for each experiment type.\nTheir \\glspl{hpd} are not shown in the table, but they are mentioned when needed.\nThe difference of means, the \\gls{pm} on one side of zero, and the effect sizes (Hedges's \\sym{effect}) are shown.\nAs a general rule of thumb, an effect can be considered statistically significant at a desired level if the \\gls{ci} does not contain zero, or, equivalently, if the reported \\gls{pm} is greater than 95\\%.\nValues of 0.2, 0.5, and 0.8 can be considered small, medium, and large effects respectively.\\cite{sawilowsky2009new}\n\n  \\section{Path length}\n  \\fref{fig:paths_overview} shows the paths flown by the operators, as well as the locations at which they arrived.\n  The target is the coloured rectangle, while the dashed line represents the area within which one part of the drone would be over the target.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/paths_overview.pgf}\n    \\caption[Paths overview]{Overview of the paths flown by the operators and their arrival locations.}\n    \\label{fig:paths_overview}\n  \\end{figure}\n\n  All \\gls{spirit} subjects confirmed that they were able to see the target, as well as their relative position in \\sym{posx}, but many had difficulty estimating their position in \\sym{posy}.\n  This can be seen by the amount of paths which overfly the target area completely compared to the onboard view.\n  It seems notable that onboard pilots erred on the side of caution and undershot their approach.\n  This may be due to the fact that the target disappears earlier when using the onboard view, and, with no depth perception, the user cannot rely on environmental cues.\n\n  The tendency of the drone to yaw to the right can clearly be seen, where users initially start out by moving to the right before correcting their path.\n  In addition, \\gls{spirit} users tend to take a more consistent route to their destination, and stay in a more narrow zone.\n  This might indicate that they are more comfortable with the interface.\n\n  The path length is shown in \\fref{fig:movement}, and the summary is shown in \\tref{tab:movement}.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/movement.pgf}\n    \\caption[Path lengths]{Path length, including total movement in \\sym{posx} and \\sym{posy}.}\n    \\label{fig:movement}\n  \\end{figure}\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[Path length summary]{Summary of the path length.}\n    \\begin{tabular}{lrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ & $\\Delta\\sym{mean}$ & \\gls{pm} & \\sym{effect} \\\\\n      \\midrule\n      Path length (m) & 10.849 & 2.727 & 11.914 & 2.706 & $-1.049$ & 87.0\\% & $-0.390$ \\\\\n      Movement in $\\sym{posx}$ (m) & 2.862 & 1.055 & 2.944 & 1.014 & $-0.078$ & 58.3\\% & $-0.078$\\\\\n      Movement in $\\sym{posy}$ (m) & 1.043 & 0.573 & 1.268 & 0.687 & $-0.220$ & 82.7\\% & $-0.360$\\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:movement}\n  \\end{table}\n\n  An ideal run with zero wasted motion would have a total path length of 6.0\\,m.\n  However, the mean path length for runs using the onboard view was $10.849 \\pm 2.727$\\,m, while that for \\gls{spirit} runs was $11.914 \\pm 2.706$\\,m.\n  That is, \\gls{spirit} users flew 1.05\\,m longer than their onboard counterparts.\n  It appears that there is a small effect size (\\sym{effect}=$-0.390$), but the \\gls{pm} is only 87.0\\%.\n\n  There was almost no difference ($-0.078$\\,m) in total motion in the \\sym{posx} direction, but there was a small, nonsignificant correlation in \\sym{posy} ($\\Delta$\\sym{mean}=$-0.220$\\,m, \\sym{effect}=$-0.360$, \\gls{pm}=82.7\\%).\n\n  From \\fref{fig:movement_runs}, it appears that the first and third \\gls{spirit} flights produced longer path lengths.\n  In both these cases, the operator was using the system for the first time.\n  Towards the end of that first flight, and continuing into their next attempt, the path lengths are comparable to those flown with the onboard view.\n  This may be a statistical aberration, or it could be the effect of familiarity with the system.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/movement_runs.pgf}\n    \\caption[Path lengths across runs]{The change in path length across runs. The movement in \\sym{posx} and \\sym{posy} was larger with \\gls{spirit} on the first and third runs, but is similar in subsequent runs.}\n    \\label{fig:movement_runs}\n  \\end{figure}\n\n  \\section{Accuracy}\n  \\fref{fig:paths_detailed} shows the location of all the arrival points in each of the groups with respect to the target.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/paths_detailed.pgf}\n    \\caption[Arrival overview]{Detail of the arrival points with respect to the target. Lighter points represent later runs.}\n    \\label{fig:paths_detailed}\n  \\end{figure}\n\n  Out of the eighteen arrivals, none of the onboard ones are directly above the target, and only seven had a portion of the drone above the target.\n  The distribution is very wide and not precise, and was slightly semicircular.\n  Some students have commented that they were using a motion capture camera pole as a marker, and orienting themselves around that.\n\n  By contrast, \\gls{spirit} operators obtained a much more consistent result, with both higher accuracy and precision.\n  Four out of eighteen were directly above the target, and a further eight had a portion of the drone above the target.\n  This distribution is much more concentrated.\n\n  \\fref{fig:distance} shows the distance from the target at the time of arrival.\n  The data is summarized in \\tref{tab:distance}.\n  As with the paths, people using the onboard view had a strong backward bias, with a mean of $-0.471$\\,m.\n  The 95\\% \\gls{hpd} was between $-0.737$ and $-0.227$\\,m, which is completely outside the target's \\sym{posy}-region.\n  They also had a large standard deviation in \\sym{posx} despite having a mean close to the centre (\\sym{mean}=0.041\\,m, \\sym{std}=0.428\\,m).\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/distance.pgf}\n    \\caption[Arrival distance]{Distance from target, including in \\sym{posx} and \\sym{posy}, at the time of arrival.}\n    \\label{fig:distance}\n  \\end{figure}\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[Arrival distance summary]{Summary of the arrival distance in \\sym{posx} and \\sym{posy}.}\n    \\begin{tabular}{lrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ & $\\Delta\\sym{mean}$ & \\gls{pm} & \\sym{effect} \\\\\n      \\midrule\n      \\sym{posx}-position (m) & 0.041 & 0.428 & 0.138 & 0.170 & $-0.100$ & 76.2\\% & $-0.345$ \\\\\n      \\sym{posy}-position (m)* & $-0.471$ & 0.445 & $-0.071$ & 0.364 & $-0.396$ & 98.3\\% & $-1.000$ \\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:distance}\n  \\end{table}\n\n  Meanwhile, the \\gls{spirit} view had a strong rightward bias, with a mean of 0.138\\,m.\n  Nevertheless, the 95\\% \\gls{hpd} of 0.038 to 0.237\\,m is completely above the target.\n  On the other hand, while the mean of the \\sym{posy} error ($-0.071$\\,m) is above the target, its large standard deviation of 0.364\\,m means that the users can be off-target by up to about one target length (95\\% \\gls{hpd}: $-0.293$ to 0.149\\,m).\n\n  \\glspl{rmse} for \\sym{posx} and \\sym{posy} are shown in \\fref{fig:rmse}, and summarized in \\tref{tab:rmse}.\n  The total \\gls{rmse} was almost identical to the total distance shown in \\fref{fig:distance}, and are thus treated as one in the analysis below.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/rms.pgf}\n    \\caption[Arrival RMS Error]{\\gls{rmse} in distance from target, including in \\sym{posx} and \\sym{posy} at the time of arrival.}\n    \\label{fig:rmse}\n  \\end{figure}\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[Arrival RMSE summary]{Summary of the arrival \\gls{rmse}.}\n    \\begin{tabular}{lrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ & $\\Delta\\sym{mean}$ & \\gls{pm} & \\sym{effect} \\\\\n      \\midrule\n      \\acrshort{rmse} (m)* & 0.667 & 0.287 & 0.403 & 0.237 & 0.265 & 98.5\\% & 1.059 \\\\\n      \\acrshort{rmse}$_{\\sym{posx}}$ (m)* & 0.337 & 0.190 & 0.191 & 0.121 & 0.147 & 98.0\\% & 0.958 \\\\\n      \\acrshort{rmse}$_{\\sym{posy}}$ (m)* & 0.521 & 0.293 & 0.339 & 0.222 & 0.184 & 95.2\\% & 0.737 \\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:rmse}\n  \\end{table}\n\n  While the onboard view had an error of $0.667\\pm0.287$\\,m, \\gls{spirit} had an error of only $0.403\\pm0.237$\\,m.\n  Broken down, the \\sym{posx}- and \\sym{posy}-\\glspl{rmse} for the onboard view were $0.337\\pm0.190$\\,m and $0.521\\pm0.293$\\,m respectively.\n  This compares to just $0.191\\pm0.121$\\,m and $0.339\\pm0.222$\\,m for \\gls{spirit}, respectively.\n  \n  The difference is significant and the effect is large for the total distance ($\\Delta$\\sym{mean}=0.265\\,m, \\sym{effect}=1.059, \\gls{pm}=98.5\\%) and \\gls{rmse}$_{\\sym{posx}}$ ($\\Delta$\\sym{mean}=0.147\\,m, \\sym{effect}=0.958, \\gls{pm}=98.0\\%).\n  They are signifanct and medium, respectively, for \\gls{rmse}$_{\\sym{posy}}$ ($\\Delta$\\sym{mean}=0.184\\,m, \\sym{effect}=0.737, \\gls{pm}=95.2\\%).\n\n  \\fref{fig:rms_runs} shows the change in the \\glspl{rmse} across runs.\n  It is consistently lower with \\gls{spirit}, apart for the second run, which is slightly higher than the onboard view.\n  This may be an aberration, given the low amount of participants.\n\n  \\begin{figure}[h]\n    \\centering\n    \\input{img/plots/rms_runs.pgf}\n    \\caption[Arrival RMS Error across runs]{Arrival \\gls{rmse} change across runs.}\n    \\label{fig:rms_runs}\n  \\end{figure}\n\n  \\section{Duration}\n  \\fref{fig:duration_result} shows the duration of each type of experiment, and the data is summarized in \\tref{tab:duration}.\n  \\gls{spirit} seemed to have a longer duration, but with less spread.\n  In fact, the onboard view has a mean duration of 39.265\\,s, and a standard deviation of 18.984\\,s, while \\gls{spirit} has $44.181\\pm15.140$\\,s.\n\n  This difference, though, is not signficant, and the effect size is small. For duration, $\\Delta$\\sym{mean}=$-4.841$\\,s, \\sym{effect}=$-0.294$, \\gls{pm}=78.1\\%.\n  \n  \\begin{figure}[h]\n    \\centering\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/duration.pgf}\n      \\caption{Duration of each type of experiment.}\n      \\label{fig:duration_result}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/duration_runs.pgf}\n      \\caption{Change in duration across runs.}\n      \\label{fig:duration_runs}\n    \\end{subfigure}\n    \\caption[Duration]{The duration of the flight, from takeoff until the arrival button was pressed.}\n    \\label{fig:duration}\n  \\end{figure}\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[Duration summary]{Summary of the duration.}\n    \\begin{tabular}{lrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ & $\\Delta\\sym{mean}$ & \\gls{pm} & \\sym{effect} \\\\\n      \\midrule\n      Duration (s) & 39.265 & 18.984 & 44.181 & 15.140 & $-4.841$ & 78.1\\% & $-0.294$ \\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:duration}\n  \\end{table}\n\n  Looking at \\fref{fig:duration_runs}, the difference between the durations decreased in each run, and \\gls{spirit} was faster by the fourth run.\n  This could be indicative of ease of learning, since the improvements were being made faster than with the onboard version.\n  Further experimentation is needed to verify this hypothesis.\n  For example, if the users are given a longer training session on a different course, they would have already gotten used to the system.\n\n  \\section{Workload}\n  \\fref{fig:tlx} shows the result of the \\gls{nasatlx} survey, both in aggregate and by component.\n  Because the \\gls{tlx} responses are subjective, and the scale itself is an ordinal rather than interval scale, no actionable information can be gleaned from this small a sample size.\\cite{hart2006}\n  Instead, general trends may be observed.\n\n  The six components in \\fref{fig:tlx_components} are, in order:\n\n  \\begin{itemize}\n    \\item \\textbf{\\acrshort{mental}:} \\acrlong{mental}\n    \\item \\textbf{\\acrshort{physical}:} \\acrlong{physical}\n    \\item \\textbf{\\acrshort{temporal}:} \\acrlong{temporal}\n    \\item \\textbf{\\acrshort{performance}:} \\acrlong{performance}\n    \\item \\textbf{\\acrshort{effort}:} \\acrlong{effort}\n    \\item \\textbf{\\acrshort{frustration}:} \\acrlong{frustration}\n  \\end{itemize}\n\n  \\noindent and the weighted score is \\acrshort{tlxscore}.\n  \n  Most onboard pilots who had a high score for physical demand mentioned that it was due to the fact that they needed to move in short burts to keep from hitting their surroundings.\n  Since the frame rate was so low, the drone would move a significant distance by the time a frame updated.\n  This raised stress and caused some frustration.\n\n  Inherent issues in the system, such as with the drone's tendency to drift right, or the lack of depth perception, also contributed to frustration and mental demand, but it had a similar effect when using either system.\n\n  \\begin{figure}[h]\n    \\centering\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/tlx_results.pgf}\n      \\caption{\\gls{nasatlx} aggregate results.}\n      \\label{fig:tlx_results}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/tlx_components.pgf}\n      \\caption{\\gls{nasatlx} component analysis.}\n      \\label{fig:tlx_components}\n    \\end{subfigure}\n    \\caption[NASA-TLX results]{Results for the \\gls{nasatlx} survey.}\n    \\label{fig:tlx}\n  \\end{figure}\n\n  The data is summarized in \\tref{tab:tlx_summary}.\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[NASA-TLX data summary]{The summary of the \\gls{nasatlx} data.}\n    \\begin{tabular}{lrrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ \n      & $\\Delta\\sym{mean}$ & $t$ & \\sym{pvalue} & \\sym{effect} \\\\\n      \\midrule\n      \\acrshort{mental}      &  29.000 & 15.922 & 24.222 & 17.908 \n      &  $-4.778$ & $-1.29269$ & 0.23220 & $-0.253$\\\\\n      \\acrshort{physical}    &   7.556 & 12.885 &  1.111 &  2.261 \n      &  $-6.444$ & $-1.81051$ & 0.10781 & $-0.626$\\\\\n      \\acrshort{temporal}    &  15.667 & 19.339 &  5.333 &  3.808 \n      & $-10.333$ & $-1.73228$ & 0.12146 & $-0.666$\\\\\n      \\acrshort{performance} &  27.222 & 16.998 & 16.667 &  8.902 \n      & $-10.556$ & $-1.64399$ & 0.13880 & $-0.699$\\\\\n      \\acrshort{effort}      &  32.667 & 19.755 & 20.111 & 10.167 \n      & $-12.556$ & $-2.19108$ & 0.05982 & $-0.718$\\\\\n      \\acrshort{frustration} &  23.556 & 22.328 & 17.333 & 15.149 \n      &  $-6.222$ & $-1.28600$ & 0.23441 & $-0.293$\\\\\n      \\acrshort{tlxscore}*    & 135.667 & 56.214 & 84.778 & 34.662 \n      & $-50.889$ & $-2.77594$ & 0.02408 & $-0.978$\\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:tlx_summary}\n  \\end{table}\n\n  A large, significant reduction of 35.74\\% in the weighted \\gls{tlx} score was seen.\n  Analysis of the components show that the scores decreased across the board.\n  There was a medium to high effect for physical (\\sym{effect}=$-0.626$), temporal (\\sym{effect}=$-0.666$), performance (\\sym{effect}=$-0.699$), effort (\\sym{effect}=$-0.718$), and overall score (\\sym{effect}=$-0.978$).\n\n  \\section{Survey}\n  The six components in \\fref{fig:survey_components} are, in order:\n\n  \\begin{itemize}\n    \\item \\textbf{\\acrshort{oraware}:} \\acrlong{oraware}\n    \\item \\textbf{\\acrshort{orcontrol}:} \\acrlong{orcontrol}\n    \\item \\textbf{\\acrshort{posaware}:} \\acrlong{relaware}\n    \\item \\textbf{\\acrshort{poscontrol}:} \\acrlong{poscontrol}\n    \\item \\textbf{\\acrshort{relaware}:} \\acrlong{relaware}\n    \\item \\textbf{\\acrshort{relcontrol}:} \\acrlong{relcontrol}\n  \\end{itemize}\n\n  \\noindent and the survey score is \\acrshort{surveyscore}.\n  \n  \\fref{fig:survey} shows the result of the survey.\n  Again, scores increased for each category.\n\n  \\begin{figure}[h]\n    \\centering\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/survey_results.pgf}\n      \\caption{Survey aggregate results.}\n      \\label{fig:survey_results}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}[b]{0.45\\textwidth}\n      \\input{img/plots/survey_components.pgf}\n      \\caption{Survey component analysis.}\n      \\label{fig:survey_components}\n    \\end{subfigure}\n    \\caption[Survey results]{Results for the survey.}\n    \\label{fig:survey}\n  \\end{figure}\n\n  The data is summarized in \\tref{tab:survey_summary}.\n\n  \\begin{table}[h]\n    \\centering\n    \\caption[Survey data summary]{The summary of the survey data.}\n    \\begin{tabular}{lrrrrrrrr}\n      \\toprule\n      & \\multicolumn{2}{c}{Onboard} & \\multicolumn{2}{c}{\\gls{spirit}} \\\\\n      & $\\sym{mean}$ & $\\sym{std}$ & $\\sym{mean}$ & $\\sym{std}$ \n      & $\\Delta\\sym{mean}$ & $t$ & \\sym{pvalue} & \\sym{effect} \\\\\n      \\midrule\n      \\acrshort{oraware} & 4.111 & 1.269 & 4.333 & 1.323 \n      &  0.222 & 0.32552 & 0.75314 & 0.154\\\\\n      \\acrshort{orcontrol} & 4.000 & 1.581 & 4.222 & 1.302 \n      &  0.222 & 0.29251 & 0.77734 & 0.138\\\\\n      \\acrshort{posaware}* & 3.222 & 1.202 & 4.667 & 1.000 \n      &  1.444 & 2.87122 & 0.02079 & 1.173\\\\\n      \\acrshort{poscontrol}* & 3.222 & 1.481 & 4.556 & 1.130 \n      &  1.333 & 2.41209 & 0.04237 & 0.909\\\\\n      \\acrshort{relaware}* & 2.111 & 0.928 & 4.889 & 1.054 \n      &  2.778 & 4.85643 & 0.00126 & 2.512\\\\\n      \\acrshort{relcontrol}* & 2.556 & 1.509 & 4.778 & 1.302 \n      &  2.222 & 3.25515 & 0.01161 & 1.416\\\\\n      \\acrshort{surveyscore}* & 19.222 & 6.399 & 27.444 & 5.223 \n      &  8.222 & 2.93892 & 0.01874 & 1.264\\\\\n      \\bottomrule\n    \\end{tabular}\n    \\label{tab:survey_summary}\n  \\end{table}\n\n  \\gls{spirit} did not affect orientation awareness or control.\n  However, it significantly increased awareness and control for both absolute and relative positioning.\n  The aggregate score also significantly increased.\n\n  The largest effect was on the awareness of the position of the drone with respect to the target (\\sym{effect}=2.512, \\sym{pvalue}=0.00126).\n  One strategy that \\gls{spirit} users utilized was slewing to the side in order to get a perspective view of the location of the drone with respect to the target.\n  By extrapolating the vertical edges of the target, they were able to increase their understanding of the situation.\n", "meta": {"hexsha": "075b484ab561fc2894ad3529948cd1f0b7740f61", "size": 18753, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/thesis/results.tex", "max_stars_repo_name": "masasin/spirit", "max_stars_repo_head_hexsha": "c8366e649eb105a8a579fb7a47dcc5aaeae6a0d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/thesis/results.tex", "max_issues_repo_name": "masasin/spirit", "max_issues_repo_head_hexsha": "c8366e649eb105a8a579fb7a47dcc5aaeae6a0d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2017-03-28T12:11:45.000Z", "max_issues_repo_issues_event_max_datetime": "2017-03-31T05:44:00.000Z", "max_forks_repo_path": "reports/thesis/results.tex", "max_forks_repo_name": "masasin/spirit", "max_forks_repo_head_hexsha": "c8366e649eb105a8a579fb7a47dcc5aaeae6a0d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-06-29T08:19:20.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-29T08:19:20.000Z", "avg_line_length": 52.2367688022, "max_line_length": 247, "alphanum_fraction": 0.6725857196, "num_tokens": 6218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190477, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.42063598160020443}}
{"text": "\\hypertarget{decision-tree}{%\n\\chapter{Decision Tree}\\label{decision-tree}}\n\\section{Introduction}\nDecision tree builds classification or regression models in the form of\na tree structure. It breaks down a dataset into smaller and smaller\nsubsets while at the same time an associated decision tree is\nincrementally developed. The final result is a tree with decision nodes\nand leaf nodes.\n\n\\hypertarget{algorithm}{%\n\\section{Algorithm}\\label{algorithm}}\n\nThe core algorithm for building decision trees called ID3 by J. R.\nQuinlan which employs a top-down, greedy search through the space of\npossible branches with no backtracking. ID3 uses Entropy and Information\nGain to construct a decision tree.\n\n\\hypertarget{entropy}{%\n\\subsection{Entropy}\\label{entropy}}\n\nA decision tree is built top-down from a root node and involves\npartitioning the data into subsets that contain instances with similar\nvalues (homogeneous). ID3 algorithm uses entropy to calculate the\nhomogeneity of a sample. If the sample is completely homogeneous the\nentropy is zero and if the sample is an equally divided it has entropy\nof one.\n\n\\hypertarget{information-gain}{%\n\\subsection{Information Gain}\\label{information-gain}}\n\nThe information gain is based on the decrease in entropy after a dataset\nis split on an attribute. Constructing a decision tree is all about\nfinding attribute that returns the highest information gain (i.e., the\nmost homogeneous branches).\n\n\\hypertarget{building-a-decision-tree}{%\n\\section{Building a Decision tree}\\label{building-a-decision-tree}}\n\nTo build a decision tree, we need to calculate two types of entropy\nusing frequency tables as follows:\n\nStep 1: Calculate Entropy using the frequency table of target attribute:\n\n\\[\n\\Large E(S) = \\sum_{i=1}^{c} -p_i log_2 p_i\n\\]\n\nStep 2: Calculate Entropy of attributes with respect to target attribute:\n\n\\[\n\\Large E(T, X) = \\sum_{c \\in X} P(c)E(c)\n\\] *\\emph{\\(P(c)\\) probability of c}\n\nStep 3: Calculate information gain of attributes and select the highest\nnode as root node:\n\n\\[\n\\Large Gain(T, X) = E(T) - E(T, X)\n\\]\n\nStep 4: Generate sub-tables for attributes with respect to parent node\nand target node.\n\nStep 5: Repeat untill Entropy reaches 0.\n\n\\section{Implementation}\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{1}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k+kn}{import} \\PY{n+nn}{pandas} \\PY{k}{as} \\PY{n+nn}{pd}\n\\PY{k+kn}{from} \\PY{n+nn}{sklearn}\\PY{n+nn}{.}\\PY{n+nn}{tree} \\PY{k+kn}{import} \\PY{n}{DecisionTreeClassifier}\\PY{p}{,} \\PY{n}{plot\\PYZus{}tree}\n\\PY{k+kn}{from} \\PY{n+nn}{sklearn}\\PY{n+nn}{.}\\PY{n+nn}{model\\PYZus{}selection} \\PY{k+kn}{import} \\PY{n}{train\\PYZus{}test\\PYZus{}split}\n\\PY{k+kn}{from} \\PY{n+nn}{sklearn}\\PY{n+nn}{.}\\PY{n+nn}{preprocessing} \\PY{k+kn}{import} \\PY{n}{OneHotEncoder}\n\\PY{k+kn}{from} \\PY{n+nn}{sklearn} \\PY{k+kn}{import} \\PY{n}{metrics}\n\\PY{k+kn}{import} \\PY{n+nn}{matplotlib}\\PY{n+nn}{.}\\PY{n+nn}{pyplot} \\PY{k}{as} \\PY{n+nn}{plt}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{2}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{dataset} \\PY{o}{=} \\PY{n}{pd}\\PY{o}{.}\\PY{n}{read\\PYZus{}csv}\\PY{p}{(}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{./data/weather.csv}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{)}\n\\PY{n}{map\\PYZus{}dict} \\PY{o}{=} \\PY{p}{\\PYZob{}}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Sunny}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Overcast}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Rain}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{3}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Hot}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Mild}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Cool}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{2}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{High}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Normal}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Weak}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{0}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Strong}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Yes}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{1}\\PY{p}{,} \\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{No}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{:}\\PY{l+m+mi}{0}\\PY{p}{\\PYZcb{}}\n\\PY{n}{dataset}\\PY{o}{.}\\PY{n}{head}\\PY{p}{(}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n            \\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]\n\\prompt{Out}{outcolor}{2}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n    Outlook  Temp Humidity    Wind PlayTennis\n0     Sunny   Hot     High    Weak         No\n1     Sunny   Hot     High  Strong         No\n2  Overcast   Hot     High    Weak        Yes\n3      Rain  Mild     High    Weak        Yes\n4      Rain  Cool   Normal    Weak        Yes\n\\end{Verbatim}\n\\end{tcolorbox}\n        \n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{3}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{X\\PYZus{}raw} \\PY{o}{=} \\PY{n}{dataset}\\PY{o}{.}\\PY{n}{iloc}\\PY{p}{[}\\PY{p}{:}\\PY{p}{,}\\PY{l+m+mi}{0}\\PY{p}{:}\\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\\PY{p}{]}\n\\PY{n}{y} \\PY{o}{=} \\PY{n}{dataset}\\PY{o}{.}\\PY{n}{iloc}\\PY{p}{[}\\PY{p}{:}\\PY{p}{,}\\PY{o}{\\PYZhy{}}\\PY{l+m+mi}{1}\\PY{p}{]}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{4}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{X} \\PY{o}{=} \\PY{n}{pd}\\PY{o}{.}\\PY{n}{DataFrame}\\PY{p}{(}\\PY{p}{)}\n\\PY{k}{for} \\PY{n}{x} \\PY{o+ow}{in} \\PY{n}{X\\PYZus{}raw}\\PY{p}{:}\n    \\PY{n}{X}\\PY{p}{[}\\PY{n}{x}\\PY{p}{]} \\PY{o}{=} \\PY{n}{X\\PYZus{}raw}\\PY{p}{[}\\PY{n}{x}\\PY{p}{]}\\PY{o}{.}\\PY{n}{map}\\PY{p}{(}\\PY{n}{map\\PYZus{}dict}\\PY{p}{)}\n\\PY{n}{X\\PYZus{}train}\\PY{p}{,} \\PY{n}{X\\PYZus{}test}\\PY{p}{,} \\PY{n}{y\\PYZus{}train}\\PY{p}{,} \\PY{n}{y\\PYZus{}test} \\PY{o}{=} \\PY{n}{train\\PYZus{}test\\PYZus{}split}\\PY{p}{(}\\PY{n}{X}\\PY{p}{,} \\PY{n}{y}\\PY{p}{,} \\PY{n}{test\\PYZus{}size}\\PY{o}{=}\\PY{o}{.}\\PY{l+m+mi}{25}\\PY{p}{,} \\PY{n}{random\\PYZus{}state}\\PY{o}{=}\\PY{l+m+mi}{42}\\PY{p}{)} \n\\PY{n}{X}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n            \\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]\n\\prompt{Out}{outcolor}{4}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n    Outlook  Temp  Humidity  Wind\n0         0     0         0     0\n1         0     0         0     1\n2         1     0         0     0\n3         3     1         0     0\n4         3     2         1     0\n5         3     2         1     1\n6         1     2         1     1\n7         0     1         0     0\n8         0     2         1     0\n9         3     1         1     0\n10        0     1         1     1\n11        1     1         0     1\n12        1     0         1     0\n13        3     1         0     1\n\\end{Verbatim}\n\\end{tcolorbox}\n        \n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{5}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{model} \\PY{o}{=} \\PY{n}{DecisionTreeClassifier}\\PY{p}{(}\\PY{n}{criterion}\\PY{o}{=}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{entropy}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{)}\n\\PY{c+c1}{\\PYZsh{} Train Decision Tree Classifier}\n\\PY{n}{model} \\PY{o}{=} \\PY{n}{model}\\PY{o}{.}\\PY{n}{fit}\\PY{p}{(}\\PY{n}{X\\PYZus{}train}\\PY{p}{,}\\PY{n}{y\\PYZus{}train}\\PY{p}{)}\n\\PY{c+c1}{\\PYZsh{}Predict the response for test dataset}\n\\PY{n}{y\\PYZus{}pred} \\PY{o}{=} \\PY{n}{model}\\PY{o}{.}\\PY{n}{predict}\\PY{p}{(}\\PY{n}{X\\PYZus{}test}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{6}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n+nb}{print}\\PY{p}{(}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Accuracy:}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{n}{metrics}\\PY{o}{.}\\PY{n}{accuracy\\PYZus{}score}\\PY{p}{(}\\PY{n}{y\\PYZus{}test}\\PY{p}{,} \\PY{n}{y\\PYZus{}pred}\\PY{p}{)}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{Verbatim}[commandchars=\\\\\\{\\}]\nAccuracy: 0.75\n    \\end{Verbatim}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{7}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n}{plt}\\PY{o}{.}\\PY{n}{figure}\\PY{p}{(}\\PY{n}{dpi}\\PY{o}{=}\\PY{l+m+mi}{150}\\PY{p}{)}\n\\PY{n}{plot\\PYZus{}tree}\\PY{p}{(}\\PY{n}{model}\\PY{p}{,} \\PY{n}{feature\\PYZus{}names}\\PY{o}{=}\\PY{n}{X\\PYZus{}raw}\\PY{o}{.}\\PY{n}{columns}\\PY{p}{,} \\PY{n}{filled}\\PY{o}{=}\\PY{k+kc}{True}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n            \\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]\n\\prompt{Out}{outcolor}{7}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n[Text(348.75, 396.375, 'Wind <= 0.5\\textbackslash{}nentropy = 0.971\\textbackslash{}nsamples = 10\\textbackslash{}nvalue = [4,\n6]'),\n Text(209.25, 283.125, 'Outlook <= 0.5\\textbackslash{}nentropy = 0.722\\textbackslash{}nsamples = 5\\textbackslash{}nvalue =\n[1, 4]'),\n Text(139.5, 169.875, 'Temp <= 1.5\\textbackslash{}nentropy = 1.0\\textbackslash{}nsamples = 2\\textbackslash{}nvalue = [1,\n1]'),\n Text(69.75, 56.625, 'entropy = 0.0\\textbackslash{}nsamples = 1\\textbackslash{}nvalue = [1, 0]'),\n Text(209.25, 56.625, 'entropy = 0.0\\textbackslash{}nsamples = 1\\textbackslash{}nvalue = [0, 1]'),\n Text(279.0, 169.875, 'entropy = 0.0\\textbackslash{}nsamples = 3\\textbackslash{}nvalue = [0, 3]'),\n Text(488.25, 283.125, 'Humidity <= 0.5\\textbackslash{}nentropy = 0.971\\textbackslash{}nsamples = 5\\textbackslash{}nvalue =\n[3, 2]'),\n Text(418.5, 169.875, 'entropy = 0.0\\textbackslash{}nsamples = 2\\textbackslash{}nvalue = [2, 0]'),\n Text(558.0, 169.875, 'Outlook <= 2.0\\textbackslash{}nentropy = 0.918\\textbackslash{}nsamples = 3\\textbackslash{}nvalue = [1,\n2]'),\n Text(488.25, 56.625, 'entropy = 0.0\\textbackslash{}nsamples = 2\\textbackslash{}nvalue = [0, 2]'),\n Text(627.75, 56.625, 'entropy = 0.0\\textbackslash{}nsamples = 1\\textbackslash{}nvalue = [1, 0]')]\n\\end{Verbatim}\n\\end{tcolorbox}\n        \n    \\begin{center}\n    \\adjustimage{max size={0.9\\linewidth}{0.9\\paperheight}}{./figures/DT1.png}\n    \\end{center}\n    { \\hspace*{\\fill} \\\\}\n    \n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{8}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{k}{def} \\PY{n+nf}{make\\PYZus{}prediction}\\PY{p}{(}\\PY{n}{case}\\PY{p}{)}\\PY{p}{:}\n    \\PY{n}{df} \\PY{o}{=} \\PY{n}{pd}\\PY{o}{.}\\PY{n}{DataFrame}\\PY{p}{(}\\PY{n}{case}\\PY{p}{)}\\PY{p}{[}\\PY{l+m+mi}{0}\\PY{p}{]}\\PY{o}{.}\\PY{n}{map}\\PY{p}{(}\\PY{n}{map\\PYZus{}dict}\\PY{p}{)}\n    \\PY{k}{return} \\PY{n}{model}\\PY{o}{.}\\PY{n}{predict}\\PY{p}{(}\\PY{p}{[}\\PY{n}{df}\\PY{p}{]}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{9}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n+nb}{print}\\PY{p}{(}\\PY{n}{make\\PYZus{}prediction}\\PY{p}{(}\\PY{p}{[}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Overcast}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Hot}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{High}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Strong}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{]}\\PY{p}{)}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{Verbatim}[commandchars=\\\\\\{\\}]\n['No']\n    \\end{Verbatim}\n\n    \\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]\n\\prompt{In}{incolor}{10}{\\boxspacing}\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\\PY{n+nb}{print}\\PY{p}{(}\\PY{n}{make\\PYZus{}prediction}\\PY{p}{(}\\PY{p}{[}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Overcast}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Hot}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Normal}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{,}\\PY{l+s+s2}{\\PYZdq{}}\\PY{l+s+s2}{Weak}\\PY{l+s+s2}{\\PYZdq{}}\\PY{p}{]}\\PY{p}{)}\\PY{p}{)}\n\\end{Verbatim}\n\\end{tcolorbox}\n\n    \\begin{Verbatim}[commandchars=\\\\\\{\\}]\n['Yes']\n    \\end{Verbatim}\n\n\n    % Add a bibliography block to the postdoc", "meta": {"hexsha": "aad4c2f18b0be2c529b0b1d9cd94a0c5f45aab0e", "size": 12658, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MCA/Machine Learning/Project file/Tex source/Decision Tree.tex", "max_stars_repo_name": "muhammadmuzzammil1998/CollegeStuff", "max_stars_repo_head_hexsha": "618cec9ebfbfd29a2d1e5a182b90cfb36b38a906", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-03-13T12:34:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-02T18:54:22.000Z", "max_issues_repo_path": "MCA/Machine Learning/Project file/Tex source/Decision Tree.tex", "max_issues_repo_name": "muhammadmuzzammil1998/CollegeStuff", "max_issues_repo_head_hexsha": "618cec9ebfbfd29a2d1e5a182b90cfb36b38a906", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MCA/Machine Learning/Project file/Tex source/Decision Tree.tex", "max_forks_repo_name": "muhammadmuzzammil1998/CollegeStuff", "max_forks_repo_head_hexsha": "618cec9ebfbfd29a2d1e5a182b90cfb36b38a906", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.2751091703, "max_line_length": 1165, "alphanum_fraction": 0.614947069, "num_tokens": 5153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.42063598160020443}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{II}\n\n\\def\\ntitle{Algebraic Topology}\n\\def\\nlecturer{H.\\ Wilton}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2018}\n\n\\input{header}\n\n\\DeclareMathOperator{\\rel}{rel}\n\\newcommand{\\w}{\\vee}\n\\renewcommand{\\b}{\\partial} % boundary of a simplicial complex\n\\newcommand{\\interior}{\\mathring} % interior\n\\DeclareMathOperator{\\mesh}{mesh}\n\\DeclareMathOperator{\\St}{St} % star\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Introduction}\n\n\\begin{question}\n  Is the Hopf link really linked? More formally, is there a homeomorphism \\(\\R^3 \\to \\R^3\\) taking \\(H\\) to \\(U\\)?\n\\end{question}\n\n\\(H\\) can be realised as \\(S^1 \\amalg S^1 \\to \\R^3\\). For \\(U\\), we can consider \\(S^1 \\amalg S^1\\) as boundary of \\(D^1 \\amalg D^1\\) and the map extends to a map to discs.\n\nSo it makes sense to phrase the question as\n\n\\begin{question}\n  Does the Hopf link \\(\\eta: S^1 \\amalg S^1 \\to \\R^3\\)extend to a map of discs?\n\\end{question}\n\nThis is an example of an \\emph{extension problem}.\n\nHere is another example. Define the \\(n\\)-sphere \\(S^{n - 1} := \\{x \\in \\R^n: \\sum_{i = 1}^n x_i^2 = 1\\}\\), which sits inside \\(D^n = \\{x \\in \\R^n: \\sum_{i = 1}^n x_i^2 = 1\\}\\). We can ask:\n\n\\begin{question}\n  Does the identity map \\(\\id_{S^{n - 1}}: S^{n - 1} \\to S^{n - 1}\\) factor through \\(D^n\\)?\n\\end{question}\n\nTo gain some intuition, let's consider small \\(n\\). For \\(n = 1\\), \\(S^0 = \\{-1, 1\\}\\). The answer is no by Intermediate Value Theorem, or connectedness from topology. For \\(n = 2\\), this answer is again no by winding number argument. What about \\(n \\geq 3\\)?\n\nThese problems are hard because we have to consider continuous maps between two spaces, which are in general very big and hard to compute. On the other hand, a comparable algebraic problem is\n\n\\begin{question}\n  Does the map \\(\\id: \\Z \\to \\Z\\) factor through \\(0\\)?\n\\end{question}\n\nWell that's much much easier!\n\n\\section{The fundamental group}\n\nThroughout this course, ``maps'' mean continuous maps.\n\n\\subsection{Deforming maps and spaces}\n\n\\begin{definition}[homotopy]\\index{homotopy}\n  Let \\(f_0, f_1: X \\to Y\\) be maps. A \\emph{homotopy} between \\(f_0\\) and \\(f_1\\) is a map \\(F: X \\times [0, 1] \\to X\\) such that \\(F(x, 0) = f_0(x)\\) and \\(F(x, 1) = f_1(x)\\) for all \\(x \\in X\\).\n\n  If \\(F\\) exists, we say that \\(f_0\\) is \\emph{homotopic} to \\(f_1\\) and write \\(f_0 \\simeq f_1\\), or to emphasise the homotopy, \\(f_0 \\simeq_F f_1\\).\n\\end{definition}\n\n\\begin{notation}\n  \\(I = [0, 1]\\). We often write \\(f_t(x) = F(x, t)\\).\n\\end{notation}\n\n\\begin{eg}\n  If \\(Y\\) is a convex region in \\(\\R^n\\) then for any \\(f_0, f_1: X \\to Y\\), the \\emph{straightline homotopy} \\(F(x, y) = t f_1(x) + (1 - t) f_0(x)\\) is a homotopy \\(f_0 \\simeq f_1\\).\n\\end{eg}\n\n\\begin{definition}[relative homotopy]\n  If \\(Z \\subseteq X\\) and \\(F(z, t) = f_0(z) = f_1(z)\\) for all \\(z \\in Z, t \\in I\\), then \\(F\\) is a \\emph{homotopy relative to \\(Z\\)}, write \\(f_0 \\simeq_F f_1 \\rel Z\\).\n\\end{definition}\n\n\\begin{lemma}\n  The relation \\(\\simeq\\) (\\(\\rel Z\\)) is an equivalence relation on maps \\(X \\to Y\\).\n\\end{lemma}\n\n\\begin{proof}\n  Reflexivity and symmetry are easy. For transitivity, suppose \\(f_0 \\simeq_{F_0} f_1 \\simeq_{F_1} f_2\\). Let\n  \\[\n    F(x, t) =\n    \\begin{cases}\n      F_0(x, 2t) & t \\leq \\frac{1}{2} \\\\\n      F_1(x, 2t - 1) & t \\geq \\frac{1}{2}\n    \\end{cases}\n  \\]\n  which is the homotopy we need.\n\\end{proof}\n\n\\begin{definition}[homotopy equivalence]\\index{homotopy equivalence}\n  \\(f: X \\to Y\\) and \\(g: Y \\to X\\) is a \\emph{homotopy equivalence} if \\(g \\compose f \\simeq \\id_X\\) and \\(f \\compose g \\simeq \\id_Y\\). In this case we say \\(X\\) is homotopy equivalent to \\(Y\\) and write \\(X \\simeq Y\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(X = *\\), the space with one point and \\(Y = \\R^n\\). Let \\(f: * \\mapsto 0\\), \\(g\\) be the unique map \\(Y \\to X\\). Then \\(g \\compose f = \\id_X\\), and \\(f \\compose g = 0 \\simeq \\id_Y\\) via the straightline homotopy. Therefore \\(\\R^n\\) is homotopy equivalent to \\(*\\).\n\\end{eg}\n\n\\begin{definition}[contractible]\\index{contractible}\n  A space \\(X\\) is \\emph{contractible} if \\(X \\simeq *\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(X = S^1, Y = \\R^2 - \\{0\\}\\). Let \\(f: X \\to Y\\) be the natural inclusion nad \\(g: Y \\to X, x \\mapsto \\frac{x}{\\norm x}\\). Then\n  \\begin{align*}\n    g \\compose f &= \\id_X \\\\\n    f \\compose g(x) &= \\frac{x}{\\norm x} \\in \\R^2\n  \\end{align*}\n  Although \\(Y\\) is not convex, for all \\(x, t\\), straightline homotopy \\(F(x, t)\\) between \\(f \\compose g\\) and \\(\\id_Y\\) satisfies \\(F(x, t) \\neq 0\\) so \\(f \\compose g \\simeq_F \\id_Y\\). Thus \\(X \\simeq Y\\).\n\\end{eg}\n\n\\begin{definition}[retract, deformation retract]\\index{retract}\\index{deformation retract}\n  Let \\(f: X \\to Y\\) and \\(g: Y \\to X\\). If \\(g \\compose f = \\id_X\\) then \\(X\\) is a \\emph{retract} of \\(Y\\).\n\n  If in addition \\(f \\compose g \\simeq \\id_Y \\rel f(X)\\) then we say \\(X\\) is a \\emph{deformation retract} of \\(Y\\).\n\\end{definition}\n\nNote that whenever we have \\(g \\compose f = \\id_X\\), \\(f\\) is injective so we can think \\(X\\) as being embedded in \\(Y\\). Informally, \\(Y\\) is ``as complicated'' as \\(X\\).\n\n\\begin{lemma}\n  Homotopy equivalence is an equivalence on topological spaces.\n\\end{lemma}\n\n\\begin{proof}\n  Symmetry and reflexivity are obvious. For transitivity, consider\n  \\[\n    \\begin{tikzcd}\n      X \\ar[r, \"f\", shift left] & Y \\ar[l, \"g\", shift left] \\ar[r, \"f\", shift left] & Z \\ar[l, \"g\", shift left]\n    \\end{tikzcd}\n  \\]\n  Need to show that \\(g \\compose (g' \\compose f') \\compose f \\simeq \\id_X\\) (and the other direction will follow similarly). By hypothesis \\(g' \\compose f' \\simeq_{F'} \\id_Y\\). Now\n  \\[\n    g(F'(f(x), t))\n  \\]\n  is a homotopy\n  \\[\n    g \\compose g' \\compose f' \\compose f \\simeq g \\compose \\id_Y \\compose f = g \\compose f \\simeq \\id_X.\n  \\]\n\\end{proof}\n\n\\subsection{The fundamental group}\n\n\\begin{definition}[path, loop]\\index{path}\\index{loop}\n  A \\emph{path} (from \\(x_0\\) to \\(x_1\\)) is a continuous map \\(\\gamma: I \\to X\\) (with \\(\\gamma(0) = x_0, \\gamma(1) = x_1\\)).\n\n  A \\emph{loop} (based at \\(x_0\\)) is a path from \\(x_0\\) to \\(x_0\\).\n\\end{definition}\n\n\\begin{definition}[homotopy of path]\\index{homotopy of path}\n  Let \\(\\gamma_0, \\gamma_1\\) be paths from \\(x_0\\) to \\(x_1\\). A \\emph{homotopy (of path)} from \\(\\gamma_0\\) to \\(\\gamma_1\\) is a homotopy\n  \\[\n    \\gamma_0 \\simeq_F \\gamma_1 \\rel \\{0, 1\\}.\n  \\]\n\\end{definition}\n\n\\begin{definition}[concatenation of path, constant path, inverse path]\n  Let \\(\\gamma\\) be a path from \\(x\\) to \\(y\\) and \\(\\delta\\) a path from \\(y\\) to \\(z\\).\n  \\begin{enumerate}\n  \\item The \\emph{concatenation} of \\(\\gamma\\) and \\(\\delta\\) is\n    \\[\n      (\\gamma \\cdot \\delta) (t) =\n      \\begin{cases}\n        \\gamma(2t) & t \\leq \\frac{1}{2} \\\\\n        \\delta(2t - 1) & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n  \\item The \\emph{constant} path (at \\(x\\)) is \\(c_x(t) = x\\).\n  \\item The \\emph{inverse path} to \\(\\gamma\\) is \\(\\overline \\gamma(t) = \\gamma(1 - t)\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{theorem}[fundamental group]\\index{fundamental group}\n  Let \\(x_0 \\in X\\). Let\n  \\[\n    \\pi_1(X, x_0) = \\{\\text{loops based at } x_0\\} / \\simeq.\n  \\]\n  This has a group structure with\n  \\begin{itemize}\n  \\item \\([\\gamma][\\delta] = [\\gamma \\cdot \\delta]\\),\n  \\item identity \\([c_{x_0}]\\),\n  \\item \\([\\gamma]^{-1} = [\\overline \\gamma]\\).\n  \\end{itemize}\n\n  We call \\(\\pi_1(X, x_0)\\) the \\emph{fundamental group} of \\(X\\) (based at \\(x_0\\)).\n\\end{theorem}\n\n\\begin{proof}\n  To prove the theorem, we need to check that multiplication and inverses are well-defined and the group axioms are satisfied.\n\n  \\begin{lemma}\n    If \\(\\gamma_0, \\gamma_1\\) are paths to \\(y\\) and \\(\\delta_0, \\delta_1\\) are paths from \\(y\\) and \\(\\gamma_0 \\simeq \\gamma_1, \\delta_0 \\simeq \\delta_1\\), then\n    \\[\n      \\gamma_0 \\cdot \\delta_0 \\simeq \\gamma_1 \\cdot \\delta_1.\n    \\]\n\n    Also \\(\\overline \\gamma_0 \\simeq \\overline \\gamma_1\\).\n  \\end{lemma}\n\n  \\begin{proof}\n    We only show for concatenation. Inverses are similar. Let \\(\\gamma_0 \\simeq_F \\gamma_1, \\delta_0 \\simeq_G \\delta_1\\). (proof by picture) Algebraically, the homotopy is given by\n    \\[\n      H(s, t) =\n      \\begin{cases}\n        F(s, 2t) & t \\leq \\frac{1}{2} \\\\\n        G(s, 2t - 1) & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n  \\end{proof}\n\n  Now we check that the group axioms are satisfied.\n\n  \\begin{lemma}\\leavevmode\n    \\begin{enumerate}\n    \\item \\((\\alpha \\cdot \\beta) \\cdot \\gamma \\simeq \\alpha \\cdot (\\beta \\cdot \\gamma)\\).\n    \\item \\(\\alpha \\cdot c_x \\simeq \\alpha \\simeq c_w \\cdot \\alpha\\).\n    \\item \\(\\alpha \\cdot \\overline \\alpha \\simeq c_w\\).\n    \\end{enumerate}\n  \\end{lemma}\n\n  \\begin{proof}\n    We show \\(1\\). The other two are similar. Let\n    \\[\n      \\delta =\n      \\begin{cases}\n        \\alpha(3t) & t \\leq \\frac{1}{3} \\\\\n        \\beta(3t - 1) & \\frac{1}{3} \\leq t \\leq \\frac{2}{3} \\\\\n        \\gamma(3t - 2) & \\frac{2}{3} \\leq t \\leq 1\n      \\end{cases}\n    \\]\n    Let\n    \\[\n      f_0(t) =\n      \\begin{cases}\n        \\frac{4}{3}t & t \\leq \\frac{1}{2} \\\\\n        \\frac{1}{3} + \\frac{2}{3} t & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n    and\n    \\[\n      f_1(t) =\n      \\begin{cases}\n        \\frac{2}{3}t & t \\leq \\frac{1}{2} \\\\\n        -\\frac{1}{3} + \\frac{4}{3}t & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n    Note that \\(f_0 \\simeq f\\) as \\emph{paths} via the straightline homotopy in \\(I\\). But\n    \\begin{align*}\n      (\\alpha \\cdot \\beta) \\cdot \\gamma &= \\delta \\compose f_0 \\\\\n      \\alpha \\cdot (\\beta \\cdot \\gamma) &= \\delta \\compose f_1\n    \\end{align*}\n    so they are homotopic as path.\n  \\end{proof}\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = \\R^n, x_0 = 0\\). Consider a loop \\(\\gamma\\) in \\(\\R^n\\) based at \\(0\\). The straightline homotopy shows that \\(\\gamma \\simeq c_0\\) as path. Therefore \\(\\pi_1(\\R^n, 0) \\cong 1\\).\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(f: X \\to Y\\) be such that \\(f(x_0) = y_0\\). There is a well-defined homomorphism\n  \\begin{align*}\n    f_*: \\pi_1(X, x_0) &\\to \\pi_1(Y, y_0) \\\\\n    [\\gamma] &\\mapsto [f \\compose \\gamma]\n  \\end{align*}\n  Furthermore,\n  \\begin{enumerate}\n  \\item if \\(f \\simeq f' \\rel \\{x_0\\}\\) then \\(f_* = f_*'\\).\n  \\item if \\(g: Y \\to Z\\) is another map then \\(f_* \\compose g_* = (f \\compose g)_*\\).\n  \\item \\((\\id_X)_* = \\id_{\\pi_1(X, x_0)}\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  Easy.\n\\end{proof}\n\nWe'd like to eliminate the dependence of \\(\\pi_1(X, x_0)\\) on \\(x_0\\), at least when \\(X\\) is path-connected. Suppose \\(x_0, x_1 \\in X\\). What do \\(\\pi_1(X, x_0)\\) and \\(\\pi_1(X, x_1)\\) have to do with each other, where \\(X\\) is path-connected?\n\nFix \\(\\alpha\\) a path from \\(x_0\\) to \\(x_1\\).\n\n\\begin{lemma}\n  There is a well-defined group homomorphism\n  \\begin{align*}\n    \\alpha_\\#: \\pi_1(X, x_0) &\\to \\pi_1(X, x_1) \\\\\n    [\\gamma] &\\mapsto [\\overline \\alpha \\cdot \\gamma \\cdot \\alpha]\n  \\end{align*}\n  Furthermore\n  \\begin{enumerate}\n  \\item if \\(\\alpha \\simeq \\alpha'\\) then \\(\\alpha_\\# = \\alpha_\\#'\\),\n  \\item \\((c_{x_0})_\\# = \\id_{\\pi_1(X, x_0)}\\),\n  \\item if \\(\\beta\\) is a path from \\(x_1\\) to \\(x_2\\), \\(\\beta_\\# \\compose \\alpha_\\# = (\\alpha \\cdot \\beta)_\\#\\).\n  \\item if \\(f: X \\to Y\\) then \\((f \\compose \\alpha)_\\# \\compose f_* = f_* \\compose \\alpha_\\#\\).\n  \\end{enumerate}\n\\end{lemma}\n\nNow it makes sense to talk about isomorphism type of the fundamental group of a path-connected space.\n\n\\begin{definition}[simply connected]\\index{simply connected}\n  If \\(X\\) is path-connected and \\(\\pi_1(X, x_0) \\cong 1\\) for some (i.e.\\ any) \\(x_0 \\in X\\) then we say \\(X\\) is \\emph{simply connected}.\n\\end{definition}\n\nOur last task is to understand what homotopies that don't fix basepoints do to the fundamental group.\n\n\\begin{lemma}\n  Suppose \\(f, g: X \\to Y\\) is such that \\(f \\simeq_F g\\). Define \\(\\alpha(t) = F(x_0, t)\\), a path from \\(f(x_0)\\) to \\(g(x_0)\\). Then the following diagram commutes:\n\\[\n  \\begin{tikzcd}\n    & \\pi_1(Y, f(x_0)) \\ar[dd, \"\\alpha_\\#\"] \\\\\n    \\pi_1(X, x_0) \\ar[ur, \"f_*\"] \\ar[dr, \"g_*\"] \\\\\n    & \\pi_1(Y, g(x_0))\n  \\end{tikzcd}\n\\]\ni.e.\\ \\(g_* = \\alpha_\\# \\compose f_*\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\([\\gamma] \\in \\pi_1(X, x_0)\\). We need to show that\n  \\[\n    [g \\compose \\gamma] = g_*[\\gamma] = \\alpha_\\# \\compose f_*[\\gamma] = [\\overline \\alpha \\cdot (f \\compose \\gamma) \\cdot \\alpha]\n  \\]\n  which is saying\n  \\[\n    g \\compose \\gamma \\simeq \\overline \\alpha \\cdot (f \\compose \\gamma) \\cdot \\alpha\n  \\]\n  as paths. Consider\n  \\begin{align*}\n    I \\times I &\\to Y \\\\\n    (s, t) &\\mapsto F(\\gamma(s), t)\n  \\end{align*}\n  Let \\(H\\) be the straightline homotopy in \\(I \\times I\\) between the yellow path and the brown path. Then \\(G \\compose H\\) is the homotopy we need.\n\\end{proof}\n\n\\begin{theorem}\n  If \\(f: X \\to Y, g: Y \\to X\\) is a pair of homotopy equivalences and \\(x_0 \\in X\\) then \\(f_*: \\pi_1(X, x_0) \\to \\pi_1(Y, f(x_0))\\) is an isomorphism.\n\\end{theorem}\n\n\\begin{proof}\n  Suffices to prove that \\(f_*\\) is bijective. Let \\(g \\compose f \\simeq_F \\id_X\\) and \\(\\alpha\\) be the path defined from \\(F\\) as above. Then\n  \\[\n    g_* \\compose f_* = (g \\compose f)_* = \\alpha_\\# \\compose \\id_{\\pi_1(X, x_0)} = \\alpha_\\#\n  \\]\n  so \\(f_*\\) is injective. Similarly it is surjective.\n\\end{proof}\n\n\\begin{corollary}\n  Contractible spaces are simply connected.\n\\end{corollary}\n\n\\section{Covering spaces}\n\n\\subsection{Definition and first examples}\n\n\\begin{definition}[covering space]\\index{covering space}\n  Let \\(p: \\hat X \\to X\\) be a map. An open set \\(U \\subseteq X\\) is \\emph{evenly covered} if there is a discrete space \\(\\Delta_U\\) and an identification \\(p^{-1}(U) = \\Delta_U \\times U\\) such that on \\(p^{-1}(U)\\), \\(p\\) coincides with projection to the second factor.\n\n  If every \\(x \\in X\\) has an everly covered neighbourhood, we say that \\(p\\) is a \\emph{covering map} and \\(\\hat X\\) is a \\emph{covering space}\n\\end{definition}\n\nAlternatively, write \\(U_\\delta = \\{\\delta\\} \\times U\\). Then \\(p^{-1}(U) = \\coprod_{\\delta \\in \\Delta_U} U_\\delta\\). Write \\(p|_\\delta = p|_{U_\\delta}\\) which is a homeomorphism.\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\hat X = \\R, X = S^1\\) and define\n  \\begin{align*}\n    p: \\R &\\to S^1 \\\\\n    t &\\mapsto e^{2\\pi i t}\n  \\end{align*}\n  Let \\(1 \\in U \\subsetneq S^1\\). Choose a branch of \\(\\log\\) well-defined on \\(U\\) such that \\(\\log 1 = 0\\). Every point \\(\\hat z \\in p^{-1}(U)\\) can be written uniquely as\n  \\[\n    \\hat z = k + \\frac{\\log(z)}{2\\pi i}\n  \\]\n  where \\(z = p(\\hat z) \\in U\\) and \\(k \\in \\Z\\), i.e.\\ \\(p^{-1}(U) = \\Z \\times U\\). Thus \\(U\\) is evenly covered. The same proof shows that \\(p\\) is a covering map.\n\\item Let \\(\\hat X = X = S^1\\). Define\n  \\begin{align*}\n    p_n: S^1 &\\to S^1 \\\\\n    z &\\mapsto z^n\n  \\end{align*}\n  This is also a covering map by essentially the same proof by choosing a \\(n\\)th root of unity. In this case \\(\\Delta_n\\) is the \\(n\\)th roots of unity.\n\\item Let \\(\\hat X = S^2\\) and \\(G = \\Z/2\\Z\\) acts on \\(S^2\\) via the antipodal map. Let\n  \\[\n    X = \\hat X / G = \\{\\{x, -x\\}: x \\in S^2\\}\n  \\]\n  and \\(p: \\hat X \\to X\\) be the quotient map. The orbit space \\(X\\) can be identified with straightlines in \\(\\R^3\\) passing through the origin. Given a line \\(\\ell\\) through the origin, let\n  \\[\n    C_\\ell = \\{y \\in S^2: y \\text{ perpendicular to } \\ell\\}.\n  \\]\n  Then \\(S^2 - C_\\ell = U_+ \\amalg U_-\\). Let \\(U = p(U_+ \\amalg U_-)\\), an open neighbourhood of \\(\\ell\\) in \\(X\\). Note that \\(p|_{U_+}\\) and \\(p|_{U_-}\\) are both homeomorphisms onto \\(U\\). Thus \\(U\\) is evenly covered and \\(p\\) is a covering map. \\(X = \\R P^2\\) is the \\emph{real projective plane}.\n\\end{enumerate}\n\\end{eg}\n\nNote that in all three examples, for all points \\(x \\in X\\), the number of copies of \\(U\\) in \\(p^{-1}(U)\\) is the same. We give a name to such covering spaces:\n\n\\begin{definition}[\\(n\\)-sheeted]\n  A covering map \\(p: \\hat X \\to X\\) is \\emph{\\(n\\)-sheeted} where \\(n \\in \\N \\cup \\{\\infty\\}\\) if for all \\(x \\in X\\), \\(\\# p^{-1}(x) = n\\).\n\\end{definition}\n\n\\subsection{Lifting properties}\n\nLet \\(p: \\hat X \\to X\\) be a covering map throughout the section.\n\n\\begin{definition}[lift]\\index{lift}\n  A \\emph{lift} of \\(f: Y \\to X\\) to \\(\\hat X\\) is a map \\(\\hat f: Y \\to \\hat X\\) such that \\(f = p \\compose \\hat f\\), i.e.\\ the following diagram commutes:\n  \\[\n    \\begin{tikzcd}\n      & \\hat X \\ar[d, \"p\"] \\\\\n      X \\ar[ur, \"\\hat f\", dashed] \\ar[r, \"f\"] & X\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\n\\begin{lemma}[uniqueness of lift]\n  Suppose \\(f: Y \\to X\\) where \\(Y\\) is connected and locally path-connected. % in fact locally path-connected not necessary\n  Let \\(\\hat f_1, \\hat f_2: Y \\to \\hat X\\) are both lifts of \\(f\\). If there exists \\(y \\in Y\\) such that \\(\\hat f_1(y) = \\hat f_2(y)\\) then \\(\\hat f_1 = \\hat f_2\\).\n\\end{lemma}\n\n\\begin{proof}\n  Consider\n  \\[\n    S = \\{y \\in Y: \\hat f_1(y) = \\hat f_2(y)\\}.\n  \\]\n  Claim that \\(S\\) is both open and closed, from which the lemma follows immediately. Given \\(y_0 \\in Y\\), let \\(U\\) be an evenly covered neighbourhood of \\(f(y_0)\\) and \\(V \\subseteq \\hat f^{-1}(U)\\) a path-connected neighbourhood of \\(y_0\\). Let \\(y \\in V\\) be arbitrary. Need to show that \\(y_0 \\in S\\) if and only if \\(y \\in S\\). If \\(y_0 \\in S\\) then \\(\\hat f_1(y_0) = \\hat f_2(y_0) \\in U_\\delta\\) for some \\(\\delta \\in \\Delta_U\\). Let \\(\\alpha\\) be a path in \\(V\\) from \\(y_0\\) to \\(y\\). Then \\(f \\compose \\alpha\\) is a path from \\(f(y_0)\\) to \\(f(y)\\). Then \\(\\hat f_i \\compose \\alpha\\) is a path in \\(p^{-1}(U)\\) from \\(\\hat f_i(y_0)\\) to \\(\\hat f_i(y)\\). It follows that \\(\\hat f_i(y) \\in U_\\delta\\) so \\(\\hat f_1(y) = (\\delta, f(y)) = \\hat f_2(y)\\) so \\(y \\in S\\). The converse is identical.\n\\end{proof}\n\n\\begin{definition}[lift at a point]\n  Let \\(\\gamma: I \\to X\\) be a path with \\(\\gamma(0) = x_0\\). A (unique) lift of \\(\\gamma\\) to \\(\\hat X\\) such that \\(\\hat \\gamma(0) = \\hat x_0 \\in p^{-1}(x_0)\\) is called the \\emph{lift of \\(\\gamma\\) at \\(\\hat x_0\\)}.\n\\end{definition}\n\n\\begin{lemma}[path-lifting lemma]\\index{path-lifting lemma}\n  Let \\(\\gamma: I \\to X\\) be a path with \\(\\gamma(0) = x_0\\). For any \\(\\hat x_0 \\in p^{-1}(x_0)\\) there is a uniqueness \\(\\hat \\gamma\\) of \\(\\gamma\\) at \\(\\hat x_0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Uniqueness follows from the more general uniquenss of lift so suffices to show existence. Consider\n  \\[\n    S = \\{t \\in I: \\text{ lift of } \\gamma|_{[0, t]} \\text{ at } \\hat x_0 \\text{ exists}\\},\n  \\]\n  as \\(0 \\in S\\), the lemma follows if we can show \\(S\\) is both open and closed. Let \\(t_0 \\in I\\). Then \\(\\gamma(t_0) \\in U\\) for some evenly covered neighbourhood \\(U\\). There exists a path-connected neighbourhood \\(V\\) of \\(t_0\\) such that \\(\\gamma(V) \\subseteq U\\). Let \\(t \\in V\\). We'll prove that \\(t_0 \\in S\\) if and only if \\(t \\in S\\). By symmetry suffices to show one direction. Suppose \\(t_0 \\in S, t \\notin S\\). Since \\(t_0 \\in S\\), \\(\\hat \\gamma(t_0)\\) is well-defined so let \\(\\hat \\gamma(t_0) \\in U_\\delta\\). Since \\([t_0, t] \\subseteq V\\) (as \\(t \\notin S\\)), \\(\\gamma([t_0, t]) \\subseteq U\\) so the path\n  \\[\n    s \\mapsto\n    \\begin{cases}\n      \\hat \\gamma(s) & s \\leq t_0 \\\\\n      p_\\delta^{-1} \\compose \\gamma & t_0 \\leq s \\leq t\n    \\end{cases}\n  \\]\n  is a lift of \\(\\gamma|_{[0, t]}\\) so \\(t \\in S\\). Contradiction.\n\\end{proof}\n\n\\begin{lemma}\n  If \\(X\\) is path-connected the \\(p\\) is \\(n\\)-sheeted for some \\(n \\in \\N \\cup \\{\\infty\\}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(x, y \\in X\\) and \\(\\alpha\\) a path between them. Let \\(\\hat x \\in p^{-1}(x)\\) and let \\(\\hat \\alpha_{\\hat x}\\) be the unique lift of \\(\\alpha\\) at \\(\\hat x\\). Define a map\n  \\begin{align*}\n    p^{-1} (x) &\\to p^{-1}(y) \\\\\n    \\hat x &\\mapsto \\hat \\alpha_{\\hat x}(1)\n  \\end{align*}\n  Now replacing \\(\\alpha\\) with \\(\\overline \\alpha\\) defines an inverse to this map.\n\\end{proof}\n\n\\begin{definition}[degree of covering map]\\index{degree}\n  \\(n\\) is called the \\emph{degree} of \\(p\\).\n\\end{definition}\n\n\\begin{lemma}[homotopy lifting lemma]\\index{homotopy lifting lemma}\n  \\label{lem:homotopy lifting lemma}\n  Let \\(f_0: Y \\to X\\) be a map where \\(Y\\) is path-connected. Let \\(F: Y \\times I \\to X\\) be a homotopy with \\(F(\\cdot, 0) = f_0\\). Let \\(\\hat f_0: Y \\to \\hat X\\) be a lift of \\(f_0\\) to \\(\\hat X\\). Then there is a unique lift \\(\\hat F\\) of \\(F\\) to \\(\\hat X\\) such that \\(\\hat F(\\cdot, 0) = \\hat f_0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(y_0 \\in Y\\). Let \\(\\gamma_{y_0}(t) = F(y_0, t)\\) be a path. By path lifting lemma, there is a unique lift \\(\\hat \\gamma_{y_0}\\) such that \\(\\hat \\gamma_{y_0}(0) = \\hat f_0(y_0)\\) such that \\(\\hat F(y_0, t) = \\hat\\gamma_{y_0}(t)\\). By uniqueness of path lifting, this is the only choice for \\(\\hat F\\), but it is not clear that \\(\\hat F\\) is continuous.\n\n  We will construct a map that is obviously continuous and argue that it is also a lift. Fix \\(y_0\\). For all \\(t\\) there exists \\(U_t\\) an evenly covered neighbourhood of \\(F(y_0, t)\\). By definition of product topology,\n  \\[\n    (y_0, t) \\in V_t \\times J_t \\subseteq F^{-1}(U_t).\n  \\]\n  Compactnss of \\(I\\) implies that \\(\\{y_0\\} \\times I\\) is covered by \\(V_1 \\times J_1, \\dots, V_n \\times J_n\\) where \\(t_i \\in J_i\\). Setting \\(V = \\bigcap_{i = 1}^n V_i\\) (and passing to a path-connected subset), we have \\(\\{y_0\\} \\times I\\) covered by \\(V \\times J_1, \\dots, V \\times J_n\\). Now define \\(\\tilde F\\) on \\(V \\times I\\) by\n  \\[\n    \\tilde F(y, t) = p_{\\delta_i}^{-1} \\compose F(y, t)\n  \\]\n  for \\(y \\in V, t \\in J_i\\). Need to check that \\(\\tilde F\\) is well-defined. Suppose \\(t \\in J_i \\cap J_j\\). Let \\(y \\in V\\). Choose \\(\\alpha\\) in \\(V\\) from \\(y_0\\) to \\(y\\) and let \\(\\alpha_t(s) = F(\\alpha(s), t)\\). Now \\(p_{\\delta_i}^{-1} \\compose \\alpha_t\\) is the lift of \\(\\alpha_t\\) at \\(\\hat F(y_0, t)\\). Same for \\(p_{\\delta_j}^{-1} \\compose \\alpha_t\\) so they are equal. Therefore their endpoints coincide: \\(p_{\\delta_i}^{-1} \\compose F(y, t) = p_{\\delta_j}^{-1} \\compose F(y, t)\\) . Thus \\(\\tilde F\\) is well-defined.\n\n  \\(\\tilde F\\) is clearly continuous and a lift of \\(F\\), so it remains to check that \\(\\tilde F = \\hat F\\) on \\(V \\times I\\). By construction \\(\\tilde F(y_0, 0) = \\hat F(y_0, 0)\\). Now \\(\\tilde F(\\alpha(\\cdot), 0)\\) is a lift of \\(f_0 \\compose \\alpha\\), so will agree with \\(\\hat f_0 \\compose \\alpha\\). So \\(\\tilde F(y, 0) = \\hat f_0(y)\\) for all \\(y \\in V\\). Finally \\(\\tilde F(y, \\cdot)\\) is a lift of \\(\\gamma_y\\) starting at \\(\\hat f_0(y)\\), so by uniqueness again, \\(\\tilde F(y, t) = \\tilde \\gamma_y(t) = \\hat F(y, t)\\) for all \\(y \\in V, t \\in I\\).\n\\end{proof}\n\nWe have discussed lifts of maps, paths and homotopies. Recall that homotopy of paths is a slightly stronger form of homotopy and the next lemma shows that indeed the lift of a homotopy of paths is a homotopy of paths:\n\n\\begin{lemma}\n  \\label{lem:lift of homotopy of paths}\n  Let \\(F: I \\times I \\to X\\) be a homotopy of paths and \\(\\hat F\\) be a lift of \\(F\\) to \\(\\hat X\\). Then \\(\\hat F\\) is also a homotopy of paths.\n\\end{lemma}\n\n\\begin{proof}\n  As \\(F\\) is a homotopy of path, \\(F(0, t) = x_0\\) for all \\(t\\). Consider \\(\\hat F(0, \\cdot): I \\to \\hat X\\). For any \\(t \\in I\\) we have\n  \\[\n    \\hat F(0, t) \\in p^{-1}(F(0, t)) = p^{-1}(x_0)\n  \\]\n  which is discrete. As \\(I\\) is connected \\(\\hat F(0, \\dots)\\) is constant. Same for \\(\\hat F(1, \\dots)\\) so \\(\\hat F\\) is a homotopy of paths.\n\\end{proof}\n\n\\subsection{Applications to calculations of fundamental groups}\n\n\\begin{lemma}\n  If \\(p: \\hat X \\to X\\) is a map, \\(x \\in X\\) and \\(\\hat x \\in p^{-1}(x)\\) then\n  \\[\n    p_*: \\pi_1(\\hat X, \\hat x) \\to \\pi_1(X, x)\n  \\]\n  is an injection.\n\\end{lemma}\n\n\\begin{proof}\n  Suppose \\([\\hat \\gamma] \\in \\ker p_*\\), i.e.\\ \\(p_*([\\hat \\gamma]) = [p\\compose \\hat \\gamma] = [\\gamma] = 1 \\in \\pi_1(X, x)\\). Then \\(\\gamma\\) is homotopic to the constant path. But by \\nameref{lem:homotopy lifting lemma} this lifts to homotopy between \\(\\hat \\gamma\\) and constant path.\n\\end{proof}\n\nAs last time, path lifting defines an \\emph{action} of \\(\\pi_1(X, x)\\) on \\(p^{-1}(x)\\) by\n\\begin{align*}\n  \\pi_1(X, x) \\times p^{-1}(x) &\\to p^{-1}(x) \\\\\n  ([\\gamma], \\hat x) &\\mapsto \\hat x . \\gamma\n\\end{align*}\nwhere \\(\\hat x . \\gamma\\) is the endpoint of the lift of \\(\\gamma\\) at \\(\\hat x\\). Note that by \\Cref{lem:lift of homotopy of paths} this is indeed in the fibre of \\(x\\). Furthermore it shows that this is well-defined. Finally note that this is a \\emph{right action} (ultimately because we defined concatenation of paths from left to right).\n\nGiven \\(G\\) action on \\(X\\), orbit-stabiliser says that there is a bijection between the left cosets of stabiliser \\(G_x\\) of an element \\(x\\) and the orbit \\(G^x\\). Furthermore, \\(G\\) has a natural action on the left cosets \\(G/G_x\\) such that the bijection is \\(G\\)-equivariant. Spelling this out (and use right action instead of left), we have\n\n\\begin{lemma}\n  Suppose \\(\\hat X\\) is path-connected and \\(x \\in X\\). Let \\(\\hat x \\in p^{-1}(x)\\). Then\n  \\begin{align*}\n    p_*\\pi_1(\\hat X, \\hat x) \\backslash \\pi_1(X, x) &\\to p^{-1}(x) \\\\\n    (p_* \\pi_1(\\hat X, \\hat x)) [\\gamma] &\\mapsto \\hat x. \\gamma\n  \\end{align*}\n  Furthermore, the map is equivariant.\n\\end{lemma}\n\n\\begin{proof}\n  Suffices to show that the action is transitive and the stabiliser of \\(\\hat x\\) is \\(p_* \\pi_1(\\hat X, \\hat x)\\). As \\(\\hat X\\) is path-connected there exists a path \\(\\hat \\gamma\\) between any two points in \\(p^{-1}(x)\\), whose image \\(\\gamma\\) under \\(p\\) is a loop bases at \\(x\\), and is the only loop whose lift is \\(\\hat \\gamma\\) by uniquenss. The stabiliser of \\(\\hat x\\) are precisely the homotopy classes of loops based at \\(x\\) whose lifts are loops baesd at \\(\\hat x\\), which is precisely \\(p_* \\pi_1(\\hat X, \\hat x)\\).\n\\end{proof}\n\n\\begin{definition}[universal cover]\\index{universal cover}\n  If \\(p: \\tilde X \\to X\\) is a covering map with \\(X\\) path-connected and \\(\\tilde X\\) simply connected then \\(\\tilde X\\) is called a \\emph{universal cover} of \\(X\\).\n\\end{definition}\n\n\\begin{corollary}\n  If \\(p: \\tilde X \\to X\\) is a universal cover and \\(p(\\tilde x) = x\\) then\n  \\begin{align*}\n    \\pi_1(X, x) &\\to p^{-1}(x) \\\\\n    [\\gamma] &\\mapsto \\tilde x . \\gamma\n  \\end{align*}\n  is an equivariant bijection.\n\\end{corollary}\n\nThe map is not only bijective, but also equivariantly so. Thus by looking into the universal cover we can recover information about the fundamental group of the base space.\n\n\\begin{eg}[fundamental group of \\(S^1\\)]\n  Consider \\(p: \\R \\to S^1, t \\mapsto e^{2\\pi it}\\) is a covering map. Since \\(\\R\\) is contractible, this is the universal cover so\n  \\begin{align*}\n    \\pi_1(S^1, 1) &\\to p^{-1}(1) = \\Z \\\\\n    [\\gamma] &\\mapsto 0. \\gamma\n  \\end{align*}\n  is a bijection. Therefore we can write down representative loops for each element of \\(\\pi_1(S^1, 1)\\). For \\(n \\in \\Z\\), let \\(\\tilde \\gamma_n(t) = nt\\) so \\(\\gamma_n = p \\compose \\tilde \\gamma_n\\) is a loop in \\(S^1\\) based at \\(1\\). As \\([\\gamma_n] \\mapsto n\\), these represent every element of \\(\\pi_1(S^1, 1)\\) uniquely.\n\n  To recover the group structure, note that for any \\(m, n \\in \\Z\\), \\(m + \\tilde \\gamma_n\\) is the lift of \\(\\gamma_n\\) at \\(m\\). On the other hand, the endpoint of the lift of \\(\\gamma_m \\cdot \\gamma_n\\) at \\(0\\) is \\(m + n\\), which is the endpoint of \\(m + \\tilde \\gamma_n\\). So\n  \\begin{align*}\n    m+n: [\\gamma_m \\cdot \\gamma_n] \\mapsto m + n\n  \\end{align*}\n  is a homomorphism. Thus\n  \\[\n    \\pi_1(S^1, 1) \\cong \\Z.\n  \\]\n\\end{eg}\n\n\\subsection{The fundamental group of \\(S^1\\)}\n\n\\begin{theorem}\n  \\(\\id_{S^1}\\) does not extend over \\(D^2\\), i.e.\\ \\(S^1\\) is not a retract of \\(D^2\\).\n\\end{theorem}\n\n\\begin{proof}\n  Suppose otherwise and \\(r: D^2 \\to S^1\\) is a retraction. Then \\(\\id_{S^1} = r \\compose i\\):\n  \\[\n    \\begin{tikzcd}\n      S^1 \\ar[r, \"\\id\"] \\ar[dr, \"i\"'] & S^1 \\\\\n      & D^2 \\ar[u, \"r\"]\n    \\end{tikzcd}\n  \\]\n  Look at the induced fundamental groups, we have\n  \\[\n    \\id_\\Z = r_* \\compose i_*\n  \\]\n  so\n  \\[\n    \\begin{tikzcd}\n      \\Z \\ar[r, \"\\id\"] \\ar[dr, \"i_*\"'] & \\Z \\\\\n      & 0 \\ar[u, \"r_*\"]\n    \\end{tikzcd}\n  \\]\n  Absurd.\n\\end{proof}\n\n\\begin{corollary}[Brouwer fixed point theorem]\\index{Brouwer fixed point theorem}\n  Every continuous map \\(f: D^2 \\to D^2\\) has a fixed point.\n\\end{corollary}\n\n\\begin{proof}\n  If there exists \\(f\\) such that \\(f(x) \\neq x\\) for all \\(x \\neq D^2\\) then we can construct a continuous retraction \\(r: D^2 \\to S^1\\): for all \\(x \\in D^2\\), let \\(r(x)\\) be the intersection of the ray from \\(f(x)\\) to \\(x\\) with \\(S^1\\) (well-defined since \\(f(x) \\neq x\\)). It is continuous. As \\(r\\) fixes \\(S^1\\) this is a retract.\n\\end{proof}\n\n\\begin{theorem}[fundamental theorem of algebra]\n  Every nonconstant polynomial \\(p: \\C \\to \\C\\) has a root.\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof]\n  Suppose \\(p(z) = z^d + a_{d - 1} z^{d - 1} + \\dots + a_1 z + a_0\\) has no root. Then \\(p: \\C \\setminus \\{0\\} \\to \\C \\setminus \\{0\\}\\). Let\n  \\begin{align*}\n    r: \\C \\setminus \\{0\\} &\\to S^1 \\\\\n    z &\\mapsto \\frac{z}{|z|}\n  \\end{align*}\n  be the usual retraction. Let \\(\\lambda_R(z) = Rz\\) for \\(R > 0\\) and consider \\(f_R\\) which is the composition\n  \\[\n    \\begin{tikzcd}\n      S^1 \\ar[r, \"\\lambda_R\"] & \\C \\setminus \\{0\\} \\ar[r, \"p\"] & \\C \\setminus \\{0\\} \\ar[r, \"r\"] & S^1\n    \\end{tikzcd}\n  \\]\n  as all these maps are homotopic, they induce the same map \\(f_*: \\Z \\to \\Z\\) which is multiplication by some number \\(m\\), independent of \\(R\\). When \\(R\\) is small, we can argue that \\(f_R\\) is homotopic to a constant map so \\(m = 0\\). When \\(R\\) is large, \\(p\\) is approximately \\(z \\mapsto z^d\\) so \\(m = d\\), contradiction.\n\\end{proof}\n\n\\subsection{Existence of universal covers}\n\n\\begin{theorem}\n  If \\(X\\) is path-connected and locally simply connected then \\(X\\) has a universal cover.\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof][non-examinable]\n  Let\n  \\[\n    \\mathfrak X = \\{\\gamma: I \\to X: \\gamma(0) = x_0\\}\n  \\]\n  and define \\(\\tilde X = \\mathfrak X /\\simeq\\), the homotopy classes of paths. Define\n  \\begin{align*}\n    p: \\tilde X &\\to X \\\\\n    [\\gamma] &\\mapsto \\gamma(1)\n  \\end{align*}\n  The verification is omitted.\n\\end{proof}\n\n\\subsection{The Galois correspondence}\n\n\\begin{definition}[covering space isomorphism]\\index{covering space isomorphism}\n  Let \\(X\\) be a path-connected topological space and \\(p_1: \\hat X_1 \\to X, p_2: \\hat X_2 \\to X\\) are covering spaces of \\(X\\). An \\emph{isomorphism of covering spaces} is a map \\(\\varphi: \\hat X_1 \\to \\hat X_2\\) such that \\(p_2 \\compose \\varphi = p_1\\).\n\n  If \\(\\hat x_1, \\hat x_2\\) are bases points and \\(\\varphi(\\hat x_1) = \\hat x_2\\), we say \\(\\varphi\\) is \\emph{based}.\n\\end{definition}\n\n\\begin{remark}\n  \\(\\varphi\\) is a lift of \\(p_1\\) to \\(\\hat X_2\\).\n\\end{remark}\n\n\\begin{theorem}[Galois correspondence with base points]\\index{Galois correspondence}\n  Let \\(X\\) be path-connected, locally simply connected space and \\(x_0 \\in X\\). Then there is a bijection between based isomorphism class of path-connected covering space \\(p: (\\hat X, \\hat x_0) \\to (X, x_0)\\) and subgroups of \\(\\pi_1(X,x_0)\\), given by\n  \\[\n    \\hat X \\mapsto p_*\\pi_1(\\hat X, \\hat x_0).\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Non-examinable and omitted.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^1\\), we have path-connteced covering space \\(p: \\R \\to S^1, t \\mapsto e^{2\\pi it}\\) and \\(p_n: S^1 \\to S^1, z \\mapsto z^n\\). The subgroups of \\(\\Z\\) are precisely \\(n\\Z\\). It is easy to see that \\(p\\) corresponds to \\(0\\) and \\(p_n\\) correponds to \\(n\\Z\\). Galois correspondence then tells us that these are all the path-connected covering space of \\(S^1\\) up to isomorphism.\n\\end{eg}\n\n\\begin{corollary}\n  Let \\(X\\) be ``reasonable''. Then any two universal covers \\(p_1: \\tilde X_1 \\to X, p_2: \\tilde X_2 \\to X\\) are isomorphic.\n\\end{corollary}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\n%If we insist that the base space is locally simply connected so there exists\n\n\\begin{corollary}\n  Let \\(X\\) be path-connected, locally simply connected and \\(x_0 \\in X\\). Then there is a bijection between isomorphism class of path-connected covering space \\(p: (\\hat X, \\hat x_0) \\to (X, x_0)\\) and subgroups of \\(\\pi_1(X, x_0)\\) modulo conjugation, given by\n  \\[\n    \\hat X \\mapsto p_*\\pi_1(\\hat X, \\hat x_0).\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Surjectivity of the map follows from immediately from the previous theorem. We need to prove that if \\(p_{1*}\\pi_1(\\hat X_1, \\hat x_1)\\) and \\(p_{2*}\\pi_1(\\hat X_2, \\hat x_2)\\) are conjugate then \\(\\hat X_1\\) and \\(\\hat X_2\\) are isomorphic covering spaces. So let\n  \\[\n    \\label{eq:a}\n    p_{1*} \\pi_1(\\hat X_1, \\hat x_1) = [\\gamma] p_{2*} \\pi_1(\\hat X_2, \\hat x_2) [\\overline \\gamma].\n    \\tag{\\ast}\n  \\]\n  Let \\(\\overline{\\hat \\gamma}\\) be the lift of \\(\\overline \\gamma\\) and \\(\\hat x_2' = \\overline{\\hat \\gamma}(1)\\). \\eqref{eq:a} then tells us that\n  \\[\n    \\p_{1*}\\pi_1(\\hat X_1, \\hat x_1)\n    = p_{2*} \\hat \\gamma_\\# \\pi_1(\\hat X_2, \\hat x_2)\n    = p_{2*} \\pi_1(\\hat X_2, \\hat x_2').\n  \\]\n  Then by the original Galois correspondence, there is a based isomorphism between \\(\\hat X_1\\) and \\(\\hat X_2\\). Of course they are isomorphic.\n\\end{proof}\n\n\\begin{definition}[covering transformation]\\index{covering transformation}\\index{deck transformation}\n  Let \\(p: \\hat X \\to X\\) be a covering space. A \\emph{covering transformation} or \\emph{deck transformation} \\(\\hat X \\to \\hat X\\) is a homeomorphism that is also a cover isomorphism.\n\\end{definition}\n\n\\begin{corollary}\n  Let \\(X\\) be ``reasonable'', path-connected and locally simply connected and \\(p: \\tilde X \\to X\\) a universal cover. Let \\(x_0 \\in X\\) and \\(\\tilde x_0 \\in p^{-1}(x_0)\\). Let \\(\\tilde x \\in p^{-1}(x_0)\\). Then there is a unique covering transformation \\(\\varphi_{\\tilde x} : \\tilde X \\to \\tilde X\\) such that \\(\\varphi_{\\tilde x}(\\tilde x_0) = \\tilde x\\).\n\\end{corollary}\n\n\\begin{proof}\n  Both \\((\\tilde X, \\tilde x_0)\\) and \\((\\tilde X, \\tilde x)\\) correspond ot the trivial subgroup of \\(\\pi_1(X, x_0)\\) so the result follows from 2.27.\n\\end{proof}\n\nNow we have two different correspondences:\n\n\\blindtext\n\nIn fact these are isomorphic. automorphism of universal covers is isomorphic to fundamental group of base group.\n\nWe can thus make \\(\\pi_1(X, x_0)\\) act on \\(\\tilde X\\) on the \\emph{left} by covering transformation.\n\\begin{remark}\n  Left vs. right action. Abelian group in case of \\(S^1\\).\n\\end{remark}\n\n\\section{Seifert-van Kampen theorem}\n\nSo far we have only seen one space with nontrivial fundamental group. In general, the fundamental groups are notoriously difficult to compute. In this chapter, we will develop the machinery needed to divide and conquer the problem of finding the fundamental group of a complex space. Specifically, given \\(X = Y_1 \\cup Y_2\\), we will ultimate describe \\(\\pi_1X\\) in terms of \\(\\pi_1Y_1, \\pi_1Y_2\\) and \\(\\pi_1(Y_1 \\cap Y_2)\\). But before that, we have to develop more group theory.\n\n\\subsection{Free groups and presentations}\n\nWe have seen groups described in the following form in IA Groups:\n\\[\n  D_{2n} = \\langle r, s | s^2 = r^n = e, srs = r^{-1} \\rangle\n\\]\nwhere we impose \\emph{relations} on the right on the group generated by the \\emph{generators} on the left. This is an example of a \\emph{presentation}. What should be the group generated by the generators be? Should it, for example, have an elemnet of order 2? Morally, the answer should be ``no'' as we should move all relations to the right. This leaves us with a free group, which is a group with no relation. Given a set \\(A\\) of generators, called an \\emph{alphabet}, \\(FA\\) is the free group generated by \\(A\\). Thus a free group has presentation\n\\[\n  FA = \\langle a \\in A \\rangle.\n\\]\nFormally\n\n\\begin{definition}[free group]\\index{free group}\n  A group \\(F(A)\\) equipped with a map of set \\(A \\to F(A)\\) is the \\emph{free group} on \\(A\\) if it satisfies the following universal property: whenever \\(G\\) is a group and \\(A \\to G\\) is a set map there is a unique canonical homomorphism \\(f: F(A) \\to G\\) such that\n  \\[\n    \\begin{tikzcd}\n      F(A) \\ar[dr, \"f\"] \\\\\n      A \\ar[u] \\ar[r] & G\n    \\end{tikzcd}\n  \\]\n  commutes.\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(F(\\emptyset) \\cong 1\\).\n  \\item Let \\(A = \\{a\\}\\). If \\(A \\to G, a \\mapsto g\\), define \\(f: \\Z \\to G, n \\mapsto g^n\\). Then the diagram\n    \\[\n      \\begin{tikzcd}\n        \\Z \\ar[dr, \"f\"] \\\\\n        A \\ar[u] \\ar[r] \\ar[r] & G\n      \\end{tikzcd}\n    \\]\n    commutes. Thus \\(\\Z\\) is the free group on \\(A\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item Free group is defined uniquely up to a unique isomorphism: suppose \\(A \\to F'(A)\\) also satisfies the universal property. Take \\(G = F'(A)\\) in the universal property for \\(F(A)\\), then there is a canonical homomorphism \\(f: F(A) \\to F'(A)\\) such that\n    \\[\n      \\begin{tikzcd}\n        F(A) \\ar[dr] \\\\\n        A \\ar[u] \\ar[r] & F'(A)\n      \\end{tikzcd}\n    \\]\n    commutes. Conversely, take \\(G = F(A)\\) in the universal property for \\(F'(A)\\), then there is a canonical homomorphism \\(f': F'(A) \\to F(A)\\) such that the corresponding diagram commutes. Now both \\(\\id_{F(A)}\\) and \\(f' \\compose f\\) both make the diagram commute so by uniqueness \\(f' \\compose f = \\id_{F(A)}\\). Likewise \\(f \\compose f' = \\id_{F'(A)}\\) so \\(f\\) and \\(f'\\) are isomorphisms.\n  \\item The definition does not guarantee the existence of free groups. We'll cover this later.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{notation}\n  We identify \\(a \\in A\\) with its image in \\(F(A)\\).\n\\end{notation}\n\n\\begin{definition}[presentation]\\index{presentation}\n  Let \\(A\\) be an \\emph{alphabet}. A subset \\(R \\subseteq F(A)\\) defines a \\emph{(group) presentation}\n  \\[\n    \\langle A | R \\rangle = F(A) / \\langle \\langle R \\rangle \\rangle\n  \\]\n  where \\(\\langle\\langle R \\rangle\\rangle\\) is the normal closure of \\(R\\) in \\(F(A)\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\langle a | a^n \\rangle \\cong \\Z/n\\Z\\).\n  \\item \\(\\langle r, s | r^n, s^2, srsr \\rangle \\cong D_{2n}\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{lemma}[universal property of group presentation]\n  Given a presentation \\(\\langle A | R\\rangle\\) and the quotient map \\(q: F(A) \\to \\langle A | R \\rangle\\), for any homomorphism \\(g: F(A) \\to G\\) such that \\(g(r) = 1\\) for all \\(r \\in R\\), there exists a unique homomorphism \\(f: \\langle A | R \\rangle \\to G\\) such that \\(f \\compose q = g\\). In other words, the following diagram commutes:\n  \\[\n    \\begin{tikzcd}\n      \\langle A | R \\rangle \\ar[dr, \"f\"] \\\\\n      F(A) \\ar[u, \"q\"] \\ar[r, \"g\"] & G\n    \\end{tikzcd}\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Follows easily from universal property of quotient map.\n\\end{proof}\n\n\\begin{definition}[pushout]\\index{pushout}\n  Let \\(i: C \\to A, j: C \\to B\\) be group homomorphisms. Homomorphism \\(k: A \\to \\Gamma, \\ell: B \\to \\Gamma\\) is a \\emph{pushout} if it satisfies the following property: for any group \\(G\\) and homomorphisms \\(f: A \\to G, g: B \\to G\\) such that \\(f \\compose i = g \\compose j\\), then there is a unique homomorphism \\(\\varphi: \\Gamma \\to G\\) such that \\(f = \\varphi \\compose k, g = \\varphi \\compose \\ell\\). In other words the following diagram commutes.\n  \\[\n    \\begin{tikzcd}\n      C \\ar[r, \"i\"] \\ar[d, \"j\"] & A \\ar[d, \"k\"] \\ar[ddr, bend left, \"f\"] \\\\\n      B \\ar[r, \"\\ell\"] \\ar[drr, bend right, \"g\"] & \\Gamma \\ar[dr, \"\\varphi\", dashed] \\\\\n      & & G\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\nAgain \\(\\Gamma\\) is uniquely defined by the universal property.\n\nWe mainly care about special cases of the definition.\n\n\\begin{definition}[free product, amalgamated free product]\\index{free product}\\index{free product!amalgamated}\n  If \\(C \\cong 1\\), then \\(\\Gamma\\) is called the \\emph{free product} of \\(A\\) and \\(B\\), denoted \\(A * B\\).\n\n  More generally, if \\(i\\) and \\(j\\) are injective then \\(\\Gamma\\) is called the \\emph{amalgamated free product}, denoted \\(A *_C B\\).\n\\end{definition}\n\n\\begin{eg}\n  \\(\\Z * \\Z \\cong F_2\\) since they satisfy the same universal property. More generally, we can check that\n  \\[\n    \\underbrace{\\Z * \\Z * \\dots * \\Z}_r \\cong F_r.\n  \\]\n\\end{eg}\n\n\\begin{notation}\n  Write \\(F_n\\) for the free group with \\(n\\) generators.\n\\end{notation}\n\n\\begin{lemma}\n  \\[\n    \\begin{tikzcd}\n      C \\ar[r, \"i\"] \\ar[d] & A \\ar[d] \\\\\n      1 \\ar[r] & A /\\langle \\langle i(C) \\rangle\\rangle\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{lemma}\n\n\\begin{proof}\n  \\blindtext\n\\end{proof}\n\npresentation for free group with amalgamation\n\n\\subsection{Seifert-van Kampen theorem for wedges}\n\n\\begin{definition}[wedge]\\index{wedge}\n  Given two pointed spaces \\((X, x_0), (Y, y_0)\\), the \\emph{wedge} is\n  \\[\n    X \\w Y = X \\amalg Y /(x_0 \\sim y_0).\n  \\]\n\\end{definition}\n\nUsually \\(X\\) and \\(Y\\) are path-connected so we can define wedges \\(X \\w Y\\) without specifying basepoints.\n\n\\begin{theorem}[Seifert-van Kampen for wedges]\\index{Seifert-van Kampen theorem}\n  If \\(Y_1, Y_2\\) are path-connected and \\(x_0\\) is the wedge point of \\(X = Y_1 \\w Y_2\\). Then\n  \\[\n    \\pi_1(X, x_0) = \\pi_1(Y_1, x_0) * \\pi_1(Y_2, x_0).\n  \\]\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof]\n  non-examinable\n\n  Suppose \\(f_1: \\pi_1(Y_i, x_0) \\to G\\) are group homomorphisms for \\(i = 1, 2\\). We need to find a unique \\(\\phi: \\pi_1(X, x_0) \\to G\\) such that \\(\\phi\\) restricts to \\(f_i\\) on \\(\\pi_1(Y_i, x_0)\\).\n\n  First replace \\(X\\) by \\(X'\\) (drawing) with \\(X \\simeq X'\\). Let \\(\\gamma: I \\to X'\\) be a based loop. We can ``straighten'' \\(\\gamma\\) so that it is of the form\n  \\[\n    \\gamma = \\alpha_1 \\cdot \\beta_1 \\cdot \\alpha_2 \\cdot \\beta_2 \\cdots \\alpha_n \\cdot \\beta_n\n  \\]\n  where \\(\\alpha_i\\)'s are in \\(\\pi_1(Y_1, x_0)\\) and \\(\\beta_i\\)'s are in \\(\\pi_1(Y_1, x_0)\\). Define\n  \\[\n    \\phi(\\gamma) = f_1(\\alpha_1) f_2(\\beta_2) f_1(\\alpha_2) \\cdots f_2(\\beta_{n - 1}) f_1(\\alpha_n) f_2(\\beta_n)\n  \\]\n  uniquely. This is easily seen to be a homomorphism but we need to prove that \\(\\phi\\) is well-defined. Let \\(\\gamma' \\simeq_F \\gamma\\) with\n  \\[\n    \\gamma' = \\alpha_1' \\cdot \\beta_1' \\cdots \\alpha_m' \\beta_m'\n  \\]\n  so\n  \\[\n    \\phi(\\gamma') = f_1(\\alpha_1')f_2(\\beta_1') \\cdots f_1(\\alpha_m') f_2(\\beta_m'),\n  \\]\n  we need to prove that \\(\\phi(\\gamma) = \\phi(\\gamma')\\). The key idea is to ``straighten'' \\(F\\) so that it is ``transverse'' to \\(x_0\\): this means that \\(F^{-1}(x_0) \\subseteq I \\times I\\) consists of a finite union of circles and intervales embedded in \\(I \\times I\\). If there is a cirlce \\(S! \\subseteq F^{-1}(0)\\) then we can ``cut it out'' and remove it. An arc with both endpoints on \\(\\gamma\\) exhibit a subarc \\(\\delta \\subseteq \\Gamma\\) such that \\(\\delta \\simeq c_{x_0}\\) in \\(Y_1\\) or \\(Y_2\\), reducing \\(n\\) without changing \\(\\phi(\\gamma)\\). After finitely many of these moves, we are left with a picture of the following form (drawing). Therefore \\(m = n\\) and \\(\\alpha_i \\simeq \\alpha_i', \\beta_i \\cong \\beta_i'\\) as paths so \\(\\phi(\\gamma) = \\phi(\\gamma')\\) as required.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^1 \\w S^1\\), then\n  \\[\n    \\pi_1 X \\cong \\pi_1S^1 * \\pi_1S^1 \\cong \\Z * \\Z \\cong F_2.\n  \\]\n  More generally, let \\(X_r = \\bigvee_{i = 1}^r S^1\\), sometimes called a bouquet, then\n  \\[\n    \\pi_1 X_r \\cong \\underbrace{\\Z * \\cdot * \\Z}_{r} \\cong F_r.\n  \\]\n\\end{eg}\n\n%find universal cover of X_r\n\n\\subsection{Seifert-van Kampen theorem}\n\n\\begin{theorem}[Seifert-van Kampen]\\index{Seifert-van Kampen}\n  If \\(X = Y_1 \\cup_Z Y_2\\) with \\(Y_1, Y_2, Z\\) open and path-connected and \\(x_0 \\in Z\\) then the diagram\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(Z, x_0) \\ar[r, \"i_{1*}\"] \\ar[d, \"i_{2*}\"] & \\pi_1(Y_1, x_0) \\ar[d, \"j_{1*}\"] \\\\\n      \\pi_1(Y_2, x_0) \\ar[r, \"j_{2*}\"] & \\pi_1(X, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{theorem}\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^n\\) where \\(n \\geq 2\\). Let \\(x_\\pm = (\\pm 1, 0, \\dots, 0)\\) be the north/south poles and define\n  \\begin{align*}\n    U_\\pm &= S^n - \\{x_\\mp\\} \\\\\n    V &=  U_+ \\cap U_- = S^n - \\{x_\\pm\\}\n  \\end{align*}\n  Then \\(X = U_+ \\cup_V U_-\\). Stereographic projection tells us that \\(U_\\pm \\cong \\R^n\\). Project \\(V\\) radially onto the cylinder \\((-1, 1) \\times S^{n - 1}\\), which is a homeomorphism so \\(V \\cong (-1, 1) \\times S^{n - 1} \\simeq S^{n - 1}\\). \\(S^{n - 1}\\) is path-connected for \\(n \\geq 2\\) so by Seifert-van Kampen the following diagram is a pushout:\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^{n - 1}, x_0) \\ar[r] \\ar[d] & 1 \\ar[d] \\\\\n      1 \\ar[r] & \\pi_1(S^n, x_0)\n    \\end{tikzcd}\n  \\]\n  so \\(\\pi_1(S^n, x_0)\\) is a quotient of \\(1\\) so is trivial.\n\\end{eg}\n\n\\begin{definition}[neighbourhood deformation retract]\\index{neighbourhood deformation retract}\n  A subset \\(Y \\subseteq X\\) is called a \\emph{neighbourhood deformation retract} if there exists \\(Y \\subseteq V \\subseteq X\\) where \\(V\\) is open in \\(X\\) such that \\(Y\\) is a deformation rectraction of \\(V\\).\n\\end{definition}\n\n\\begin{corollary}\n  If \\(X = Y_1 \\cup_Z Y_2\\) with \\(Y_1, Y_2, Z\\) path-connected and closed and \\(Z\\) a neighbourhood deformation retract of \\(Y_1\\) and \\(Y_2\\) and \\(x_0 \\in Z\\) then\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(Z, x_0) \\ar[r] \\ar[d] & \\pi_1(Y_1, x_0) \\ar[d] \\\\\n      \\pi_1(Y_2, x_0) \\ar[r] & \\pi_1(X, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{corollary}\n\n\\begin{proof}\n  See online notes.\n\\end{proof}\n\n\\subsection{Attaching cells}\n\n\\begin{definition}[cell]\\index{cell}\n  An \\emph{\\(n\\)-cell} is a copy of \\(D^n\\), the closed ball in \\(\\R^n\\).\n\\end{definition}\n\n\\begin{definition}\n  Let \\(\\alpha: S^{n - 1} = \\partial D^n \\to X\\) be a continuous map. The space\n  \\[\n    X \\cup_\\alpha D^n := X \\amalg D^n / \\sim\n  \\]\n  where \\(\\sim\\) is the finest equivalence relation such that \\(\\alpha(\\theta) \\sim \\theta\\) for all \\(\\theta \\in S^{n - 1}\\), is called an \\emph{attaching cell}.\n\\end{definition}\n\nWhat effect does attaching an \\(n\\)-cell have on \\(\\pi_1\\)?\n\nLet's start with \\(n \\geq 3\\):\n\n\\begin{lemma}\n  If \\(n \\geq 3\\) and \\(\\alpha: S^{n - 1} \\to X\\) is a continuous map. Let \\(x_0 = \\alpha(\\theta_0)\\) for \\(\\theta_0 \\in S^{n - 1}\\). Then the (not necessarily injective) inclusion map \\(i: X \\to X \\cup_\\alpha D^n\\) induces an isomorphism \\(i_*: \\pi_1(X, x_0) \\to \\pi_1(X \\cup_\\alpha D^n, x_0)\\).\n\\end{lemma}\n\n\\begin{proof}\n  The main obstacle is that \\(\\alpha\\) might not be injective. However, we can divide \\(D^n\\) into two parts and attach \\(D^n\\) in two stages: the mapping cylinder of \\(\\alpha\\) is\n  \\[\n    M_\\alpha := X \\amalg (S^{n - 1} \\times I) / \\sim\n  \\]\n  where \\(\\alpha(\\theta) \\sim (\\theta, 0)\\) for all \\(\\theta \\in S^{n - 1}\\). Note that\n  \\begin{enumerate}\n  \\item \\(X\\) is a deformation retract of \\(M_\\alpha\\).\n  \\item \\(S^{n - 1} \\times \\{1\\} \\subseteq M_\\alpha\\) is a neighbourhood deformation retract.\n  \\item \\(S^{n - 1} \\subseteq D^n\\) is a neighbourhood deformation retract.\n  \\end{enumerate}\n  If we choose \\(\\theta_1 \\in S^{n - 1}\\), the previous corollary tells us that\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^{n - 1}, \\theta_1) \\ar[r] \\ar[d] & \\pi_1(M_\\alpha, \\theta_1) \\ar[d, \"j_*\"] \\\\\n      \\pi_1(D^n, \\theta_1) \\ar[r] & \\pi_1(M_\\alpha \\cup_{S^{n - 1}} D^n, \\theta_1)\n    \\end{tikzcd}\n  \\]\n  is a pushout. Therefore the inclusion \\(j: M_\\alpha \\to M_\\alpha \\cup_{S^{n - 1}} D^n\\) induces an isomorphism on \\(\\pi_1\\). Since \\(X \\cup_\\alpha D^n = M_\\alpha \\cup_{S^{n - 1}} D^n\\) and \\(M_\\alpha'\\) deformation retracts to \\(X\\), the result follows.\n\\end{proof}\n\nWhat about \\(n = 2\\)?\n\n\\begin{lemma}\n  If \\(\\alpha: S^1 \\to X\\) is a continuous map and \\(x_0 = \\alpha(\\theta_0)\\) where \\(\\theta_0 \\in S^1\\). Then\n  \\[\n    \\pi_1(X \\cup_\\alpha D^2, \\theta_0) \\cong \\pi_1(X, x_0) / \\langle\\langle [\\alpha] \\rangle\\rangle\n  \\]\n  and the inclusion map \\(X \\embed X \\bigcap_\\alpha D^2\\) induces the quotient map\n  \\[\n    \\pi_1(X, x_0) \\to \\pi_1(X \\cup_\\alpha D^2, x_0).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  As in the proof of the previous lemma, the diagram\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^1, \\theta_0) \\ar[r, \"\\alpha_*\"] \\ar[d] & \\pi_1(X, x_0) \\ar[d, \"i_*\"] \\\\\n      \\pi_1(D^2, \\theta_0) \\ar[r] & \\pi_1(X \\cup_\\alpha D^2, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout. By lemma 3.2 the result follows.\n\\end{proof}\n\n\\begin{theorem}\n  If \\(G = \\langle A | R \\rangle\\) with \\(A, R\\) both finite then it is the fundamental group of some space. Moreover the spaces can be taken to be compact.\n\\end{theorem}\n\nIn fact, we don't have to restrict our attention to finitely generated or finitely presented groups. So every group is the fundamental group of some space (although not compact in general).\n\n\\begin{proof}\n  If \\(R = \\{r_1, \\dots r_n\\}\\) then\n  \\begin{align*}\n    G &= F(A) / \\langle\\langle r_1, \\dots, r_n \\rangle\\rangle \\\\\n      &\\cong (F(A) / \\langle\\langle r_1, \\dots, r_{n - 1} \\rangle\\rangle) / \\langle\\langle r_n \\rangle\\rangle \\\\\n      &\\cong \\dots \\\\\n      &\\cong (\\dots (F(A)/ \\langle \\langle r_1 \\rangle\\rangle) \\dots ) / \\langle\\langle r_n \\rangle\\rangle,\n  \\end{align*}\n  one way to check this is to show they satisfy the same universal property. Now induciton on \\(n\\), with the base case \\(n = 1\\) being the wedge of \\(|A|\\) circles.\n\\end{proof}\n\n\\subsection{Classification of surfaces}\n\n\\begin{definition}[topological manifold]\\index{topological manifold}\n  An \\emph{\\(n\\)-dimensional (topological) manifold} is a Hausdorff space \\(M\\) such that every \\(x \\in M\\) has an open neighbourhood \\(U\\) homeomorphic to an open subset of \\(\\R^n\\).\n\\end{definition}\n\n\\begin{definition}[surface]\\index{surface}\n  A \\(2\\)-dimensional manifold is called a \\emph{surface}.\n\\end{definition}\n\n\\begin{eg}\n  Let \\(\\alpha: S^1 \\to *\\). Consider \\(X = * \\cup_\\alpha D^2\\). Note that \\(\\int D^2 \\cong \\R^2\\) and \\(S^2 - \\{x_+\\} \\cong \\R^2\\) via stereographic projection. Moreover the homeomorphism \\(i: \\int D^2 \\to S^1 - \\{x_+\\}\\) extends to a unique continuous bijection \\(X \\to S^2\\), so a homeomorphism. In particular \\(S^2\\) is a surface.\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\Gamma_{2g} = \\bigvee_{i = 1}^{2g} S_i^1\\), with each \\(S_i' \\cong S^1\\). Choose unit speed loops \\(\\alpha_1, \\dots, \\alpha_g\\) and \\(\\beta_1, \\dots, \\beta_g\\) in the circles. Let\n  \\[\n    \\rho_g = (\\alpha_1 \\cdot \\beta_1 \\cdot \\overline \\alpha_1 \\cdot \\overline \\beta_1) \\cdot (\\alpha_2 \\cdot \\beta_2 \\cdot \\overline \\alpha_2 \\cdot \\overline \\beta_2) \\dots (\\alpha_g \\cdot \\beta_g \\cdot \\overline \\alpha_g \\cdot \\overline \\beta_g)\n  \\]\n  and let\n  \\[\n    \\Sigma_g = \\Gamma_{2g} \\cup_{\\rho_g} D^2.\n  \\]\n  Claim \\(\\Sigma_g\\) is a surface. There are three cases to consider. If a point in the interior of \\(D^2\\) then it has a neighbourhood homeomorphic to an open disk. If a point is in the interior of image of a path the ``two parts'' glue together to form an open disk. Similary all the edges are identified together.\n\n  \\(\\Sigma_0\\) is just \\(S^2\\). \\(\\Sigma_1\\) is the square with two sides identified to a torus. In general \\(\\Sigma_g\\) is called the (orientable surface) with genus \\(g\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\Gamma_{g + 1} = \\bigvee_{i = 0}^g S_i^1\\) and let\n  \\[\n    \\sigma_j = \\alpha_0 \\cdot \\alpha_0 \\cdot \\alpha_1 \\cdot \\alpha_1 \\dots \\alpha_g \\cdot \\alpha_g\n  \\]\n  let\n  \\[\n    S_g = \\Gamma_{g + 1} \\cup_{\\sigma_g} D^2.\n  \\]\n  Similarly we can check these are surfaces. This is the \\emph{non-orientable surface} of genus \\(g\\). \\(S_0 = \\R P^2\\) and \\(S_1\\) is the Klein bottle.\n\n  We have\n  \\begin{align*}\n    \\pi_1 \\Sigma_g &= \\langle a_1, \\dots, a_g, b_1, \\dots, b_g | a_1b_1a_1^{-1}b_1^{-1} \\cdots a_gb_ga_g^{-1}b_g^{-1}\\rangle \\\\\n    \\pi_1 S_g &= \\langle a_0, \\dots, a_g | a_0^2 a_1^2 \\cdots a_g^2 \\rangle\n  \\end{align*}\n\\end{eg}\n\nWe state without proof\n\n\\begin{theorem}[classification of compact surfaces]\\index{classification of compact surfaces}\n  If \\(M\\) is a compact surface then either \\(M \\cong \\Sigma_g\\) or \\(M \\cong S_g\\).\n\\end{theorem}\n\nWe won't prove this but a good point to start is to consider given an identification of \\(S^1\\) of \\(D^2\\), how can we convert it into one of the two forms?\n\nWe also ask the following question: are \\(\\{\\Sigma_g\\}\\) and \\(\\{S_g\\}\\) pairwise non-homeomorphic? What about homotopy equivalence? The only tool available to us is \\(\\pi_1\\). The strategy is to that the fundamental groups map onto different abelian groups. % abelianisation\n\n\\begin{lemma}\n  Let \\(g \\in \\N\\).\n  \\begin{enumerate}\n  \\item The group \\(\\pi_1 \\Sigma_g\\) surjects \\(\\Z^{2g}\\) but not \\(\\Z^{2g} \\oplus (\\Z/(2))\\).\n  \\item The group \\(\\pi_1 S_g\\) surjects \\(\\Z^g \\oplus (\\Z/(2))\\) but not \\(\\Z^{g + 1}\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  Easy. See notes.\n\\end{proof}\n\nAnd as a result we get want we want\n\n\\begin{corollary}\n  The strategy works.\n\\end{corollary}\n\n\\section{Simplicial complexes}\n\nWe have seen that the fundamental groups are useful, and for example, when it works, it tells us \\(S^n\\) is contractible for \\(n > 1\\). There are higher dimensional analogues of \\(\\pi_1\\), called the \\emph{homotopy groups} \\(\\pi_n\\). However, they are notoriously difficult to compute. Instead, we will use (more or less) the only thing in mathematics we understand fully (again, more or less) --- linear algebra. This is called \\emph{homology}.\n\nThere are many types of homologies and we'll only define \\emph{simplicial homologies} in this course.\n\n\\subsection{Simplices and stuff}\n\n\\begin{definition}\n  A finite set \\(V \\subseteq \\R^n\\) is in \\emph{general position} if the smallest affine subspace containing \\(V\\) is of dimension \\(|V| - 1\\).\n\\end{definition}\n\nThis is quite an abstract definition, but there are a few equivalent notions. For example, if \\(V = \\{v_0, \\dots, v_n\\}\\) then for any \\(t_0, \\dots t_n\\) such that \\(\\sum_{i = 0}^n t_i = 0\\), if \\(\\sum_{i = 0}^n t_iv_i = 0\\) then \\(t_i = 0\\) for all \\(i\\).\n\n\\begin{definition}[simplex]\\index{simplex}\n  For \\(n \\geq 0, V = \\{v_0, \\dots, v_n\\} \\subseteq \\R^m\\). The \\emph{span} of \\(V\\) is\n  \\[\n    \\langle V \\rangle = \\{\\sum_{i = 0}^n t_iv_i: t_i \\geq 0, \\sum_{i = 0}^n t_i = 1\\}.\n  \\]\n\n  If \\(V\\) is in general position, \\(\\sigma = \\langle V \\rangle\\) is an \\emph{\\(n\\)-simplex}.\n\\end{definition}\n\n\\begin{definition}[face]\\index{face}\n  Let \\(V = \\{v_0, \\dots, v_n\\}\\) in general position. If \\(U \\subseteq V\\) then \\(\\langle U \\rangle\\) is called a \\emph{face} of \\(\\langle V\\rangle\\), write \\(\\langle U \\rangle \\leq \\langle V \\rangle\\).\n\n  If \\(U \\neq V\\) then \\(\\langle U\\rangle\\) is called a \\emph{proper} face.\n\\end{definition}\n\n\\begin{definition}[simplicial complex, dimension, skeleton]\\index{simplicial complex}\\index{dimension}\\index{skeleton}\n  A \\emph{simplicial complex} is a finite set of simplices \\(K\\) in some \\(\\R^m\\) satisfying the following condition:\n  \\begin{enumerate}\n  \\item if \\(\\sigma \\in K\\) and \\(\\tau \\leq \\sigma\\) then \\(\\tau \\in K\\),\n  \\item if \\(\\sigma, \\tau \\in K\\) then \\(\\sigma \\cap \\tau \\leq \\sigma\\) and \\(\\sigma \\cap \\tau \\leq \\tau\\).\n  \\end{enumerate}\n\n  The \\emph{dimension} of \\(K\\), denoted \\(\\dim K\\), is the largest \\(n\\) such that \\(K\\) contains an \\(n\\)-simplex.\n\n  The \\emph{\\(d\\)-skeleton} of \\(K\\) is\n  \\[\n    K_{(d)} = \\{\\sigma \\in K: \\dim \\sigma \\leq d\\}.\n  \\]\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(\\sigma\\) is a simplex then \\(K = \\{\\tau: \\tau \\leq \\sigma\\}\\) is a simplicial complex.\n  \\item If \\(\\sigma\\) is a simplex then the set of proper faces of \\(\\sigma\\), denoted \\(\\b \\sigma\\), is a simplicial complex. It is called the \\emph{boundary}\\index{boundary} of \\(\\sigma\\). The set of points in \\(\\sigma\\) not in a simplex of \\(\\b \\sigma\\) is called the \\emph{interior}, denoted by \\(\\interior \\sigma\\).\n  \\end{enumerate}\n\\end{eg}\n\nNote that if \\(\\sigma\\) is a \\(0\\)-simplex then \\(\\interior \\sigma = \\sigma\\).\n\n\\begin{definition}[realisation/polyhedron]\\index{realisation}\\index{polyhedron}\n  The \\emph{realisation} or \\emph{polyhedron} of a simplicial complex \\(K\\) is the union of the simplices in \\(K\\), denoted by \\(|K|\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item In \\(\\R^{n + 1}\\), the standard basis \\(\\{e_0, \\dots e_n\\}\\) is in general position. The simplex it spans \\(\\sigma_n = \\langle e_0, \\dots, e_n\\rangle\\) is called the \\emph{standard \\(n\\)-simplex}.\n  \\item The \\emph{standard (simplicial) \\((n - 1)\\)-sphere} is \\(\\b \\sigma_n\\). \n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}[triangulation]\\index{triangulation}\n  A \\emph{triangulation} of a space \\(X\\) is a homeomorphism \\(h: |K| \\to X\\).\n\\end{definition}\n\nIt's not hard to see that there is a triangulation \\(h: |\\b \\sigma_n| \\to S^{n - 1}\\).\n\n\\begin{eg}\n  Here is another way of triangulating \\(S^n\\). For now set \\(n = 2\\). The convex hull of \\(\\{\\pm e_0, \\pm e_1, \\pm e_2\\}\\) is a surface of an octahedron, which is triangulation of \\(S^2\\). In general, let \\(\\{e_0, \\dots, e_n\\}\\) be the standard basis for \\(\\R^{n + 1}\\) and \\(E = \\{\\pm e_0, \\dots, \\pm e_n\\}\\). Let\n  \\[\n    E_0 = \\{S \\subseteq E: \\text{ for all \\(i\\) exactly one of \\(\\pm e_i\\) is in } S\\}.\n  \\]\n  Let \\(K = \\{\\langle S \\rangle: S \\in E_0\\}\\). This is the \\emph{octahedral \\(n\\)-sphere} and there exists a triangulation \\(|K| \\to S^n\\).\n\\end{eg}\n\n\\begin{definition}[simplicial map]\\index{simplicial map}\\index{simplicial map!realisation}\n  Let \\(K, L\\) be simplicial complexes. A \\emph{simplicial map} \\(f: K \\to L\\) is a map such that for all \\(\\langle v_0, \\dots, v_n \\rangle \\in K\\),\n  \\[\n    f(\\langle v_0, \\dots, v_n \\rangle) = \\langle f(v_0), \\dots, f(v_n) \\rangle\n  \\]\n  where \\(f(\\{v_i\\}) = \\{f(v_i)\\}\\).\n\n  The \\emph{realisation} of \\(f: K \\to L\\) is the continuous map \\(|f|: |K| \\to |L|\\) defined on \\(\\sigma = \\langle v_0 , \\dots, v_n \\rangle\\) to be\n  \\[\n    f_\\sigma \\left( \\sum_{i = 0}^n t_iv_i \\right) = \\sum_{i = 0}^n t_i f(v_i).\n  \\]\n\\end{definition}\n\nNote that if \\(\\tau \\leq \\sigma\\) then \\(f_\\tau = f_\\sigma|_\\tau\\), so \\(|f|\\) is well-defined and continuous.\n\\begin{eg}\n  (drawing)\n\\end{eg}\n\n\\subsection{Barycentric subdivision}\n\nRealisaition of simplicial maps are piecewise linear and thus very rigid. On the other hand, the realisations of simplicial complexes, as topological spaces, are ``deformable''. Is every continuous map \\(|K| \\to |L|\\) homotopic to a realisation of a simplicial map? For example for \\(K = L = \\b \\sigma_2\\), there are infinitely many homotopy classes of continuous maps, which are in bijection with \\(\\pi_1(S^1)\\). On the other hand there are only finitely many simplicial map \\(K \\to L\\), and thus at most that many realisations. To establish the correspondence, we need subdivision.\n\n\\begin{definition}[barycentre]\\index{barycentre}\n  If \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\), the \\emph{barycentre} of \\(\\sigma\\) is\n  \\[\n    \\hat \\sigma_n = \\frac{1}{n + 1} \\sum_{i = 0}^n v_i.\n  \\]\n\\end{definition}\n\n\\begin{definition}[barycentric subdivision]\\index{barycentric subdivision}\n  Suppose \\(K\\) is a simplicial complex. The \\emph{barycentric subdivision} of \\(K\\) is \\(K'\\) with vertices \\(\\{\\hat \\sigma: \\sigma \\in K\\}\\). A collection of barycentres \\(\\{\\hat \\sigma_0, \\dots, \\hat \\sigma_n\\}\\) spans a simplex in \\(K'\\) whenever \\(\\sigma_0 \\leq \\sigma_1 \\leq \\dots \\leq \\sigma_n\\).\n\\end{definition}\n\n\\begin{lemma}\n  \\(K'\\) is a simplicial complex and \\(|K'| = |K|\\).\n\\end{lemma}\n\n\\begin{proof}\n  See online notes.\n\\end{proof}\n\n\\begin{definition}\n  We define the \\(r\\)th barycentric subdivision to be\n  \\begin{align*}\n    K^{(0)} &= K \\\\\n    K^{(r)} &= (K^{(r - 1)})'\n  \\end{align*}\n\\end{definition}\n\n\\begin{definition}[mesh]\\index{mesh}\n  Let \\(K\\) be a simplicial complex. define the \\emph{mesh} of \\(K\\) to be\n  \\[\n    \\mesh(K) = \\max_{\\langle v_0, v_1 \\rangle \\in K} \\norm{v_0 - v_1}_2.\n  \\]\n\\end{definition}\n\nHere the \\(2\\)-norm is just taken for the sake of convenience and concreteness.\n\n\\begin{lemma}\n  If \\(\\dim K = n\\) then\n  \\[\n    \\mesh(K^{(r)}) \\leq \\left(\\frac{n}{n + 1}\\right)^r \\mesh(K).\n  \\]\n  In particular\n  \\[\n    \\lim_{r \\to \\infty} \\mesh(K^{(r)}) = 0.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  \\(\\dim K' = \\dim K = n\\) so by induction it suffices to show that\n  \\[\n    \\mesh(K') \\leq \\frac{n}{n + 1} \\mesh(K).\n  \\]\n  A \\(1\\)-simplex in \\(K'\\) is of the form \\(\\langle \\hat \\tau, \\hat \\sigma \\rangle\\) where \\(\\tau \\leq \\sigma\\). Note that \\(K'\\) is a finite set and mesh is realised by some pairs of vertices. By a bit geometric reasoning this is achieved by some vertex. We may thus assume that \\(\\hat \\tau = v_0\\), a vertex of \\(\\sigma = \\langle v_0, \\dots, v_m\\rangle\\). Thus\n  \\begin{align*}\n    \\norm{\\hat \\tau - \\hat \\sigma}\n    &= \\norm*{v_0 - \\frac{1}{m + 1} \\sum_{i = 0}^m v_i} \\\\\n    &= \\norm*{\\frac{m}{m + 1} v_0 - \\frac{1}{m + 1} \\sum_{i = 1}^m v_i} \\\\\n    &= \\frac{1}{m + 1} \\norm*{\\sum_{i = 1}^m (v_0 - v_i)} \\\\\n    &\\leq \\frac{1}{m + 1} \\sum_{i = 1}^m{v_0 - v_1} \\\\\n    &\\leq \\frac{m}{m + 1} \\mesh(K) \\\\\n    &\\leq \\frac{n}{n + 1} \\mesh (K)\n  \\end{align*}\n\\end{proof}\n\n\\subsection{Simplicial approximation theorem}\n\n\\begin{definition}[star]\\index{star}\n  Let \\(v\\) be a vertex of \\(K\\). The \\emph{star} of \\(v\\) is\n  \\[\n    \\St_K(v) = \\bigcup_{v \\in \\sigma \\in K} \\interior \\sigma\n  \\]\n\\end{definition}\n\n\\begin{definition}[simplicial approximation]\\index{simplicial approximation}\n  Let \\(\\phi: |K| \\to |L|\\) be a continuous map. A simplicial map \\(f: K \\to L\\) is a \\emph{simplicial approximation} of \\(\\phi\\) if for every vertex \\(v\\) of \\(K\\),\n  \\[\n    \\phi(\\St_K(v)) \\subseteq \\St_L(f(v)).\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  If \\(f: K \\to L\\) is a simplicial approximation to \\(\\phi: |K| \\to |L|\\) then \\(|f| \\simeq \\phi\\).\n\\end{lemma}\n\n\\begin{proof}\n  Suppose \\(|L| \\subseteq \\R^m\\) as usual. Consider the straightline homotopy \\(H\\) between \\(|f|\\) and \\(\\varphi\\). We will prove that \\(H\\) stays inside \\(|L|\\). Let \\(x \\in \\interior \\sigma\\) and let \\(\\phi(x) \\in \\interior \\tau\\). We'll show that \\(f(\\sigma) \\leq \\tau\\). The result then follows because \\(\\tau\\) is a convex subset of \\(R^m\\).\n\n  Let \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\). For each \\(i\\), \\(x \\in \\St_K(v_i)\\) so\n  \\[\n    \\phi(x) \\in \\phi(\\St_K(v_i)) \\subseteq \\St_L(f(v_i))\n  \\]\n  so \\(f(v_i)\\) is a vertex of \\(\\tau\\). So \\(f(\\sigma) \\tau\\) as desired.\n\\end{proof}\n\n\\begin{theorem}[simplicial approximation theorem]\\index{simplicial approximation theorem}\n  Let \\(K, L\\) be simplicial complexes and \\(\\phi: |K| \\to |L|\\) a continuous map. For some \\(r \\in \\N\\) there is a implicial approximation to \\(\\phi\\), \\(f: K^{(r)} \\to L\\).\n\\end{theorem}\n\n\\begin{proof}\n  Let\n  \\[\n    U = \\{\\phi^{-1}(\\St_L(u)): u \\text{ a vertex of } L\\}\n  \\]\n  which is an open cover of \\(|K|\\). By Lebesgue number lemma there is \\(\\delta > 0\\) such that for all \\(x \\in |K|\\), there exists a vertex of \\(L\\) such that\n  \\[\n    B(x, \\delta) \\subseteq \\phi^{-1}(\\St_L(u)).\n  \\]\n  Choose \\(r\\) large enough such that \\(\\mesh(K^{(r)}) < \\delta\\). Then for any vertex \\(v\\) of \\(K^{(r)}\\),\n  \\[\n    \\St_{K^{(r)}}(v) \\subseteq B(v, \\delta) \\subseteq \\phi^{-1}(\\St_L(u))\n  \\]\n  for some \\(u\\). Set \\(f(v) = u\\) for some such \\(u\\). Left to check this is a simplicial map, i.e.\\ for all \\(\\sigma \\in K^{(r)}, f(\\sigma) \\in L\\). But as in the proof of the previous lemma, if \\(x \\in \\interior \\sigma\\) and \\(\\phi(x) \\in \\interior \\tau\\) then \\(f(\\sigma)\\) must be a face of \\(\\tau\\).\n\\end{proof}\n\n\\section{Homology}\n\n\\subsection{Simplicial homology}\n\nThe analogue in simplices of a path is a \\emph{chain}, which is a formal sum of simplices. If we interpret positive coefficient as copies of a simplex, what does it mean to have a negative simplex? To make sense of this we need the notion of \\emph{oriented simplex}.\n\n\\begin{definition}[orientation]\\index{orientation}\n  Let \\(V = (v_0, \\dots, v_n)\\) be an ordered set of points in general position in \\(\\R^M\\). Consider the natural action of \\(S_{n + 1}\\) on \\(V\\). The subgroup \\(A_{n + 1} \\leq S_{n + 1}\\) has 2 orbits on \\(V\\), as long as \\(n \\geq 1\\). An \\emph{orientation} on \\(\\sigma = \\langle V \\rangle\\) is a choice of \\(A_{n + 1}\\)-orbit under the action on \\(V\\).\n\n  We will abuse notation and write \\(\\langle v_0, \\dots, v_n \\rangle\\) for the simplex \\(\\langle v_0, \\dots, v_n \\rangle\\) equipped with the orientation which is the \\(A_{n + 1}\\)-orbit of \\((v_0, \\dots, v_n)\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(V = \\{v_0, v_1\\}\\). The two possible orientations are \\(\\langle v_0, v_1 \\rangle\\) and \\(\\langle v_1, v_0\\rangle\\), which corresponds to ``arrows going in opposite directions''.\n\\end{eg}\n\n\\begin{eg}\n  Let \\(V = \\{v_0, v_1, v_2\\}\\). There are two orientations, for exmaple \\(\\langle v_0, v_1, v_2 \\rangle\\) and \\(\\langle v_2, v_1, v_0 \\rangle\\) are two representatives.\n\\end{eg}\n\n\\begin{definition}[chain]\\index{chain}\n  Let \\(K\\) be a simplicial complex. The group of \\emph{\\(n\\)-chains} on \\(K\\) is\n  \\[\n    C_n(K) = \\bigoplus_{\\sigma \\in K, \\dim \\sigma = n} \\langle \\sigma \\rangle.\n  \\]\n\\end{definition}\n\nIn particular if there are no \\(n\\)-simplex (e.g.\\ \\(n > \\dim K\\) or \\(n < 0\\)) then \\(C_n(K) \\cong 0\\). Arbitrarily choose orientations on the simplices of \\(K\\) and then identify \\(-\\sigma\\) with the opposite oriented simplex. Note that this arbitrary choice isn't important --- it could be realised by an automorphism of \\(C_n(K)\\).\n\n\\begin{remark}\n  Note that these groups are abelian, which is a huge advantage compared to homotopy groups if you actually want to do anything with them. On the other hand, it also means that there are things that a homotopy group can see but homology groups cannot.\n\\end{remark}\n\n\\begin{definition}[boundary homomorphism]\\index{boundary homomorphism}\n  The \\emph{(\\(n\\)th) boundary homomorphism} \\(\\b_n\\), usually just written as \\(\\b\\), is defined by\n  \\begin{align*}\n    C_n(K) &\\to C_{n - 1}(K) \\\\\n    \\langle v_0, \\dots, v_n \\rangle &\\mapsto \\sum_{i = 0}^n (-1)^i \\langle v_0, \\dots, \\hat v_i, \\dots, v_n \\rangle\n  \\end{align*}\n  where \\(\\hat v_i\\) means that the vertex \\(v_i\\) is omitted.\n\\end{definition}\n\nNote this is well-defined.\n\n\\begin{eg}\n  Let \\(\\sigma = \\langle v_0, v_1 \\rangle\\). Then \\(\\b(\\sigma) = \\langle v_1 \\rangle - \\langle v_0 \\rangle\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\sigma = \\langle v_0, v_1, v_2 \\rangle\\). Then\n  \\begin{align*}\n    \\b(\\sigma)\n    &= \\langle v_1, v_2 \\rangle - \\langle v_0, v_2 \\rangle + \\langle v_0, v_1 \\rangle \\\\\n    &= \\langle v_1, v_2 \\rangle + \\langle v_2, v_0 \\rangle + \\langle v_0, v_1 \\rangle\n  \\end{align*}\n\\end{eg}\n\n\\begin{definition}[cycle, boundary]\\index{cycle}\\index{boundary}\n  Let \\(n \\in \\Z\\). The group\n  \\[\n    Z_n(K) = \\ker \\b_n \\leq C_n(K)\n  \\]\n  is the group of \\emph{\\(n\\)-cycles}.\n  \n  The group\n  \\[\n    B_n(K) = \\im \\b_{n + 1} \\leq C_n(K)\n  \\]\n  is the group of \\emph{\\(n\\)-boundaries}.\n\\end{definition}\n\nThese are analogous to loops and homotopies respectively.\n\n\\begin{lemma}\n  Every \\(n\\)-boundary is an \\(n\\)-cycle, i.e.\n  \\[\n    B_n(K) \\leq Z_n(K),\n  \\]\n  i.e.\n  \\[\n    \\b_n \\compose \\b_{n + 1} = 0.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\). By definition\n  \\[\n    \\b(\\sigma) = \\sum_{i = 0}^n (-1)^i \\langle v_0, \\dots, \\hat v_i, \\dots, v_n \\rangle\n  \\]\n  so\n  \\begin{align*}\n    \\b \\compose \\b(\\sigma)\n    &= \\sum_{i, j < i} (-1)^i (-1)^j \\langle v_0, \\dots, \\hat v_j, \\dots, \\hat v_i, \\dots, v_n \\rangle \\\\\n    &\\quad+ \\sum_{i, j > i} (-1)^i (-1)^{j - 1} \\langle v_0, \\dots, v_i, \\dots, v_j, \\dots, v_n \\rangle \\\\\n    &= \\sum_{i, j < i} (-1)^{i + j} \\langle v_0, \\dots, \\hat v_j, \\dots, \\hat v_i, \\dots v_n \\rangle \\\\\n    &\\quad- \\sum_{i, j > i} (-1)^{i + j} \\langle v_0, \\dots, \\hat v_i, \\dots, \\hat v_j, \\dots, v_n \\rangle\n  \\end{align*}\n\\end{proof}\n\n\\begin{definition}[homology group]\\index{homology group}\n  The \\emph{\\(n\\)th homology group} of \\(K\\) is\n  \\[\n    H_n(K) = Z_n(K) / B_n(K).\n  \\]\n\\end{definition}\n\n\\begin{remark}\n  The homology we discuss in this course is simplicial homology, which has the advanatage that all the homology groups are finitely generated. Thus in principle, \\(H_n(K)\\) can always be computed using linear algebra. But except in the following few demonstrative examples, as a man of culture you should avoid it as much as possible.\n\\end{remark}\n\n\\begin{eg}\n  Let \\(K\\) be the standard simplicial circle. The vertices of \\(K\\) are \\(e_0, e_1, e_2\\). Thus\n  \\begin{align*}\n    C_0(K) &= \\langle e_0 \\rangle \\oplus \\langle e_1 \\rangle \\oplus \\langle e_2 \\rangle \\cong \\Z^3 \\\\\n    C_1(K) &= \\langle e_0, e_1 \\rangle \\oplus \\langle e_1, e_2 \\rangle \\oplus \\langle e_2, e_0 \\rangle \\cong \\Z^3 \\\\\n    C_n(K) &= 0 \\text{ for } n > 1\n  \\end{align*}\n  There is only one interesting boundary map \\(\\b = \\b_1: C_1(K) \\to C_0(K)\\). Looking at the definitions, we can write down a matrix for \\(\\b\\), in the bases we choose\n  \\[\n    \\begin{pmatrix}\n      -1 & 0 & 1 \\\\\n      1 & -1 & 0 \\\\\n      0 & 1 & -1\n    \\end{pmatrix}\n  \\]\n  After a bit of work we can put in Smith normal form\n  \\[\n    \\begin{pmatrix}\n      1 & 0 & 0 \\\\\n      0 & 1 & 0 \\\\\n      0 & 0 & 0\n    \\end{pmatrix}\n  \\]\n  so \\(\\im \\b_1 \\cong \\Z^2\\) (as a direct summand). \\(\\ker \\b_1 \\cong \\Z\\). Thus\n  \\begin{align*}\n    H_0(K) &= Z_0(K)/B_0(K) = C_0(K)/\\im \\b_1 \\cong \\Z^3 / \\Z^2 \\cong \\Z \\\\\n    H_1(K) &= Z_1(K)/B_1(K) = \\ker \\b_1/0 \\cong \\Z \\\\\n    H_n(K) &= 0 \\text{ for } n > 1\n  \\end{align*}\n  The fact that \\(H_1(K) \\cong Z\\) is related to intuitive observation that there is a ``hole'' in the simplicial complex. Contrast this with the next example. (We'll interpret \\(H_0(K)\\) shortly)\n\\end{eg}\n\n\\begin{eg}\n  Let \\(L\\) be the standard \\(2\\)-simplex \\(K \\cup \\{\\sigma_2\\}\\) where \\(\\sigma_2 = \\langle e_0, e_1, e_2 \\rangle\\). We have (nontrivial) chain groups\n  \\begin{align*}\n    C_0(L) &= C_0(K) \\\\\n    C_1(L) &= C_1(K) \\\\\n    C_2(L) &= \\langle \\sigma_2 \\rangle\n  \\end{align*}\n  The boundary map \\(\\b_1\\) is same as before and for \\(\\b_2\\), which is\n  \\[\n    \\b_2(\\sigma_2) = \\langle e_0, e_1 \\rangle + \\langle e_1, e_2 \\rangle + \\langle e_2, e_0 \\rangle\n  \\]\n  which has a particularly simple matrix \\((1, 1, 1)\\). In particular \\(\\b_2\\) is injective so \\(\\ker \\b_2 = 0\\). We know \\(\\im \\b_2 \\subseteq \\ker \\b_1 \\cong Z\\). But we can see that \\(\\im \\b_2\\) is a direct summand of \\(C_1(L)\\) so \\(\\im \\b_2 = \\ker \\b_1\\). Thus the homology groups are\n  \\begin{align*}\n    H_0(L) &= H_0(K) \\cong \\Z \\\\\n    H_1(L) &= Z_1(L)/B_1(L) = \\ker \\b_1/\\im \\b_2 \\cong 0 \\\\\n    H_2(L) &= Z_2(L)/B_2(L) = \\ker \\b_2/0 \\cong 0\n  \\end{align*}\n  Alas! The first homology group has been killed.\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(K\\) be a simplicial complex. If \\(d\\) is the number of path components of \\(|K|\\) then\n  \\[\n    H_0(K) \\cong \\Z^d.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(\\pi_0(K)\\) be the set of path components of \\(|K|\\). Let \\(\\Z[\\pi_0(K)] \\cong \\Z^{|\\pi_0(K)|}\\) be the free abelian group generated by \\(\\pi_0(K)\\). There is a natural map\n  \\begin{align*}\n    q: C_0(K) &\\to \\Z[\\pi_0(K)] \\\\\n    \\langle v\\rangle &\\mapsto [v]\n  \\end{align*}\n  Because there is a vertex in every component of \\(|K|\\), \\(q\\) is surjective. Note that \\(B_0(K) \\subseteq \\ker q\\): \\(B_0(K)\\) is generated by elements \\(\\langle v \\rangle - \\langle u \\rangle\\) where \\(\\langle u, v \\rangle\\) is a \\(1\\)-simplex of \\(K\\). Since \\(\\langle u\\rangle\\) and \\(\\langle v\\rangle\\) are in the same path component, \\(q(\\langle v \\rangle - \\langle u\\rangle) = 0\\) so indeed \\(B_0(K) \\subseteq \\ker q\\).\n\n  Because \\(H_0(K) = Z_0(K)/B_0(K) = C_0(K)/B_0(K)\\), \\(q\\) descends to a map\n  \\[\n    H_0(K) \\to \\Z[\\pi_0(K)].\n  \\]\n  Left to check this is injective, i.e.\\ \\(\\ker q \\subseteq B_0(K)\\). Note that \\(\\ker q\\) is generated by terms of the form \\(\\langle v \\rangle - \\langle u\\rangle\\) where \\([u] = [v]\\). By simplicial approximation, there exists a ``simplicial path'' from \\(u\\) to \\(v\\)\n  \\[\n    c = \\langle v_0, v_1 \\rangle + \\langle v_1, v_2 \\rangle + \\dots + \\langle v_{k - 1}, v_k\\rangle\n  \\]\n  where \\(v_0 = u, v_k = v\\). But \\(\\b_1(c) = \\langle v \\rangle - \\langle u \\rangle \\in B_0(K)\\) as required.\n\\end{proof}\n\n\\subsection{Chain complexes \\& chain homotopies}\n\n\\begin{definition}[chain complex]\\index{chain complex}\n  A \\emph{chain complex} \\(C_\\bullet\\) is a sequence of abelian groups \\((C_n)_{n \\in \\Z}\\) with \\(C_n = 0\\) for \\(n < 0\\) and \\emph{boundary homomorphisms} \\(\\b_n: C_n \\to C_{n - 1}\\) such that\n  \\[\n    \\b_{n - 1} \\compose \\b_n = 0\n  \\]\n  for all \\(n\\).\n\n  A \\emph{chain map} \\(f_\\bullet: C_\\bullet \\to D_\\bullet\\) is a sequence of homomorphisms \\(f_n: C_n \\to D_n\\) such that the following diagram commutes for all \\(n\\):\n  \\[\n    \\begin{tikzcd}\n      C_n \\ar[r, \"f_n\"] \\ar[d, \"\\b_n\"] & D_n \\ar[d, \"\\b_n\"] \\\\\n      C_{n - 1} \\ar[r, \"f_{n - 1}\"] & D_{n - 1}\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\n\\begin{note}\n  Note that we suppress the notational distinction between the boundary homomorphisms of \\(C_\\bullet\\) and \\(D_\\bullet\\). This is a common practice as they have different domains and there is little room for confusion.\n\\end{note}\n\n\\begin{definition}[boundary, cycle, homology]\\index{boundary}\\index{cycle}\\index{homology}\n  If \\(C_\\bullet\\) is a chain complex, then define \\emph{boundaries} \\(B_n\\) and \\emph{cycles} \\(Z_n\\)\n  \\begin{align*}\n    B_n(C_\\bullet) &= \\im \\b_{n + 1} \\leq C_n \\\\\n    Z_n(C_\\bullet) &= \\ker \\b_n \\leq C_n\n  \\end{align*}\n\n  The \\emph{\\(n\\)th homology} is defined as\n  \\[\n    H_n(C_\\bullet) = Z_n(C_\\bullet) / B_n(C_\\bullet).\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  A chain map \\(f_\\bullet: C_\\bullet \\to D_\\bullet\\) induces a well-defined homomorphism\n  \\[\n    f_*: H_n(C_\\bullet) \\to H_n(D_\\bullet)\n  \\]\n  for all \\(n\\).\n\\end{lemma}\n\n\\begin{proof}\n  Trivial from commutativity of \\(\\b\\) and \\(f_n\\).\n\\end{proof}\n\n\\begin{eg}\n  If \\(K\\) is a simplicial complex then \\((C_n)_{n \\in \\Z}\\) form a chain complex \\(C_\\bullet(K)\\).\n\\end{eg}\n\n\\begin{lemma}\n  A simplicial map \\(f: K \\to L\\) induces a chain map \\(f_\\bullet: C_\\bullet(K) \\to C_\\bullet(L)\\) by\n  \\begin{align*}\n    f_n: C_n &\\to D_n \\\\\n    \\sigma &\\mapsto\n             \\begin{cases}\n               f(\\sigma) & \\text{ if } \\dim f(\\sigma) = \\dim \\sigma \\\\\n               0 & \\text{ if } \\dim f(\\sigma) < \\dim \\sigma\n             \\end{cases}\n  \\end{align*}\n  Therefore \\(f\\) induces homomorphisms \\(f_*: H_n(K) \\to H_n(L)\\).\n\\end{lemma}\n\nIn other words, \\(f_n\\) does exactly what you would expect, and it simply forgets simplices that are ``crushed down''.\n\n\\begin{proof}\n  Easy verification. See online notes for details.\n\\end{proof}\n\n\\begin{eg}\n  Retraction of a standard \\(2\\)-simplex \\(K\\) to standard \\(1\\)-simplex \\(L\\).\n\\end{eg}\n\n\\begin{remark}\n  The map is functorial, i.e.\\ given simplicial maps \\(K \\xrightarrow{f} L \\xrightarrow{g} M\\), \\((g \\compose f)_* = g_* \\compose f_*\\). In addition \\((\\id_K)_* = \\id_{H_n(K)}\\).\n\\end{remark}\n\n\\begin{definition}[chain homotopy]\\index{chain homotopy}\n  Let \\(f_\\bullet, g_\\bullet: C_\\bullet \\to D_\\bullet\\) be chain maps. A \\emph{chain homotopy} \\(h_\\bullet\\) between \\(f_\\bullet\\) and \\(g_\\bullet\\) is a sequence of homomorphisms \\(h_n: C_n \\to D_{n + 1}\\) such that\n  \\[\n    g_n - f_n = \\b_{n + 1} \\compose h_n + h_{n - 1} \\compose \\b_n\n  \\]\n  for all \\(n\\). Write \\(f_\\bullet \\simeq g_\\bullet\\) or \\(f_\\bullet \\simeq_{h_\\bullet} g_\\bullet\\).\n\\end{definition}\n\n\\begin{lemma}\n  If \\(f_\\bullet \\simeq g_\\bullet: C_\\bullet \\to D_\\bullet\\) then\n  \\[\n    f_* = g_*: H_n(C_\\bullet) \\to H_n(D_\\bullet)\n  \\]\n  for all \\(n\\).\n\\end{lemma}\n\n\\begin{proof}\n  Consider \\([c] \\in H_n(C_\\bullet)\\) so \\(c \\in Z_n(C_\\bullet) = \\ker \\b_n\\). Then\n  \\[\n    g_n(c) - f_n(c) = \\b_{n + 1} \\compose h_n(c) + \\underbrace{h_{n - 1} \\compose \\b_n(c)}_{= 0} \\in B_n(D_\\bullet)\n  \\]\n  so\n  \\[\n    [g_n(c)] = [f_n(c)]\n  \\]\n  so \\(f_* = g_*\\) as claimed.\n\\end{proof}\n\n\\begin{eg}\n  Continuation of the previous example.\n\\end{eg}\n\n\\begin{definition}[cone]\\index{cone}\n  A simplicial complex \\(K\\) is a \\emph{cone} if there is a vertex \\(x_0\\) such that for every \\(\\tau \\in K\\) there exists \\(\\sigma \\in K\\) such that \\(x_0 \\in \\sigma\\) and \\(\\tau \\leq \\sigma\\).\n\\end{definition}\n\n\\begin{lemma}\n  If \\(K\\) is a cone then it has the same homology as a point, i.e.\n  \\[\n    H_n(K) =\n    \\begin{cases}\n      \\Z & n = 0 \\\\\n      0 & n > 0\n    \\end{cases}\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(x_0\\) be a point as in the definition of a cone. Consider\n  \\begin{align*}\n    i: \\{\\langle x_0 \\rangle\\} &\\to K \\\\\n    r: K &\\to \\{\\langle x_0 \\rangle\\}\n  \\end{align*}\n  the obvious inclusion and retraction. Clearly \\(r \\compose i = \\id_{\\{\\langle x_0 \\rangle\\}}\\) so \\(r_* \\compose i_* = \\id_{H_n(\\{\\langle x_0 \\rangle\\})}\\) for all \\(n\\). Thus left to show \\(i_\\bullet \\compose r_\\bullet \\simeq \\id_{C_\\bullet(K)}\\) as if so then \\(i_* \\compose r_* = \\id_{H_n(K)}\\) for all \\(n\\) so \\(r_*\\) is an isomorphism and the result follows.\n\n  We write down the following chain homotopy\n  \\begin{align*}\n    h_n: C_n(K) &\\to C_{n + 1}(K) \\\\\n    \\langle v_0, \\dots, v_n \\rangle &\\mapsto\n                                      \\begin{cases}\n                                        \\langle x_0, v_0, \\dots, v_n \\rangle & x_0 \\notin \\sigma \\\\\n                                        0 & x_0 \\in \\sigma\n                                      \\end{cases}\n  \\end{align*}\n  Now check directly that\n  \\[\n    (\\id_{C_n(K)} - i_n \\compose r_n)(\\sigma) = (\\b_{n + 1} \\compose h_n + h_{n - 1} \\compose \\b_n)(\\sigma)\n  \\]\n  for all \\(\\sigma \\in K\\). There are 4 cases depending on if \\(x_0 \\in \\sigma\\) and if \\(n = 0\\). We'll do the case \\(x_0 \\in \\sigma, n \\neq 0\\). The others are similar but easier. Let \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\) and suppose \\(x_0 = v_j\\). Now\n  \\begin{align*}\n    (\\b \\compose h + h \\compose \\b)(\\sigma)\n    &= h \\compose \\b(\\sigma) \\\\\n    &= h(\\sum_{i = 0}^n (-1)^i \\langle v, \\dots, \\hat v_i, \\dots, v_n \\rangle) \\\\\n    &= (-1)^j \\langle x_0, v_0, \\dots, v_{j - 1}, v_{j + 1}, \\dots, v_n \\rangle \\\\\n    &= (-1)^j (-1)^j \\langle v_0, \\dots, v_{j - 1}, x_0, v_{j + 1}, \\dots, v_n \\rangle \\\\\n    &= \\sigma \\\\\n    &= (\\id_{C_n(K)} - i_n \\compose r_n)(\\sigma)\n  \\end{align*}\n\\end{proof}\n\n\\subsection{Homology of the simplex and the sphere}\n\n\\begin{eg}\n  Let \\(K = \\{\\tau \\leq \\sigma_n\\}\\) where \\(\\sigma_n\\) is the standard \\(n\\)-simplex. By considering any vertex, \\(K\\) is obviously a cone so by the lemma\n  \\[\n    H_n(K) \\cong\n    \\begin{cases}\n      \\Z & n = 0 \\\\\n      0 & n \\geq 1\n    \\end{cases}\n  \\]\n\\end{eg}\n\n\\begin{eg}\n  Let \\(L = \\b \\sigma_n \\subseteq K\\) be the standard \\((n - 1)\\)-sphere where \\(n \\geq 2\\). In other words \\(L = K - \\{\\sigma_n\\}\\).\n  \\[\n    \\begin{tikzcd}[column sep=small]\n      0 = C_{n + 1}(L) \\ar[r] & C_n(L) = 0 \\ar[r] \\ar[d, hook] & C_{n -1}(L) \\ar[r] \\ar[d, equal] & C_{n - 2}(L) \\ar[r] \\ar[d, equal] & \\cdots \\ar[r] & C_1(L) \\ar[r] \\ar[d, equal] & C_0(L) \\ar[r] \\ar[d, equal] & 0 \\\\\n      0 = C_{n + 1}(K) \\ar[r] & C_n(K) = \\langle \\sigma_n \\rangle \\ar[r] & C_{n - 1}(K) \\ar[r] & C_{n - 2}(K) \\ar[r] & \\cdots \\ar[r] & C_1(K) \\ar[r] & C_0(K) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  So for \\(k \\leq n - 2\\), \\(H_k(L) = H_k(K)\\). The only interesting case is \\(k = n - 1\\). Because \\(H_{n - 1}(K) \\cong 0\\), \\(Z_{n - 1}(K) = B_{n - 1}(K)\\) and similarly \\(Z_n(K) = B_n(K) = 0\\) so \\(\\b_n\\) is injective. Because \\(B_{n - 1}(L) \\cong 0\\),\n  \\begin{align*}\n    H_{n - 1}(L)\n    &= Z_{n - 1}(L) /B_{n - 1}(L) \\cong Z_{n - 1}(L) \\\\\n    &= Z_{n - 1}(K) \\\\\n    &= B_{n - 1}(K) \\\\\n    &= \\im \\b_n \\\\\n    &\\cong C_n(K) \\\\\n    &\\cong \\Z\n  \\end{align*}\n  so\n  \\[\n    H_k(L) \\cong\n    \\begin{cases}\n      \\Z & k = 0, n - 1 \\\\\n      0 & k \\geq 2\n    \\end{cases}\n  \\]\n\\end{eg}\n\nIntuitively the homology groups detect \\(n - 1\\)-dimensional holes (compare to \\(D^n\\)). It also gives something that \\(\\pi_1\\) fails to detect and gives us a way to differentiate \\(S^{n - 1}\\) for different \\(n\\). (?)\n\n\\subsection{Continuous maps and homotopies}\n\nQuestion: if \\(\\phi: |K| \\to |L|\\) is continuous, does it induce some kind of map \\(\\phi_*: H_n(K) \\to H_n(L)\\)? The obvious idea to take simplicial approximation \\(f: K^{(r)} \\to L\\) of \\(\\phi\\) and set \\(\\phi_* = f_*: H_n(K^{(r)}) \\to H_n(L)\\). This brings two immediate problems: in general this \\(r\\) is not \\(1\\), and moreover \\(\\phi_*\\) may depend on the choice of \\(f\\).\n\n\\begin{definition}[continguous]\\index{contiguous}\n  Two simplicial maps \\(f, g: K \\to L\\) are \\emph{continguous} if for every \\(\\sigma \\in K\\) there exists \\(\\tau \\in L\\) such that \\(f(\\sigma), g(\\sigma) \\leq \\tau\\).\n\\end{definition}\n\nInformally this is the homotopy of simplicial maps.\n\n\\begin{remark}\n  Look back at the proof of lemma 4.25, we proved that if \\(f\\) is a simplicial approxiamtion to \\(\\phi\\) and if \\(x \\in \\sigma, \\phi(x) \\in \\interior \\tau\\) then \\(f(\\sigma) \\leq \\tau\\). Therefore if \\(f, g\\) are both simplicial approximation to \\(\\phi\\) then they are contiguous.\n\\end{remark}\n\n\\begin{lemma}\n  If \\(f, g: K \\to L\\) are contiguous then\n  \\[\n    f_* = g_*: H_n(K) \\to H_n(L)\n  \\]\n  for all \\(n\\).\n\\end{lemma}\n\n\\begin{proof}\n  Need to exhibit a chain homotopy between \\(f_\\bullet\\) and \\(g_\\bullet\\). Fix a total ordering \\(<\\) on th vertices of \\(K\\). Now for each simplex \\(\\sigma \\in K\\) we can write it in a unqiue way \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\) such that\n  \\[\n    v_0 < v_1 < \\dots < v_n.\n  \\]\n  Now define a chain homotopy\n  \\begin{align*}\n    h_n: C_n(K) &\\to C_{n + 1}(L) \\\\\n    \\langle v_0, \\dots, v_n \\rangle &\\mapsto \\sum_{j = 0}^n (-1)^j \\langle f(v_0), \\dots, f(v_j), g(v_j), \\dots, g(v_n) \\rangle\n  \\end{align*}\n  \\(\\langle f(v_0), \\dots, f(v_j), g(v_j), \\dots, g(v_n) \\rangle = 0\\) if it is not an \\((n + 1)\\)-dimensional simplex.\n\n  We can now check directly that this defines a chain homotopy. See online notes for details.\n\\end{proof}\n\n\\begin{lemma}\n  Let \\(K\\) be a simplicial complex. A simplicial map \\(s: K' \\to K\\) is a simplicial approximation to the identity if and only if \\(s(\\hat \\sigma)\\) is a vertex of \\(\\sigma\\) for all \\(\\sigma \\in K\\). Futhermore such an \\(s\\) exists.\n\\end{lemma}\n\n\\begin{proof}\n  In the setting, the definition of simplicial approximation tells us that\n  \\[\n    \\id_{|K|} (\\St_{K'}(\\hat \\sigma)) = \\interior \\sigma \\subseteq \\St_K(s(\\hat \\sigma)),\n  \\]\n  which hapens if and only if \\(\\sigma(\\hat \\sigma)\\) is a vertex of \\(\\sigma\\).\n  % adjunction between star and barycentric subdivision?\n\n  For all \\(\\sigma \\in K\\), choose any vertex of \\(\\sigma\\) and assign \\(s(\\hat \\sigma)\\) to it. A simplex of \\(K\\) is the form \\(\\langle \\hat \\sigma_0, \\dots, \\hat \\sigma_n \\rangle\\) such that \\(\\sigma_0 \\leq \\sigma_1 \\leq \\dots \\leq \\sigma_n\\) so every \\(s(\\hat \\sigma_i)\\) is a vertex of \\(\\sigma_n\\). Therefore \\(\\langle s(\\hat \\sigma_0), \\dots, s(\\hat \\sigma_n) \\rangle\\) is a face of \\(\\sigma_n\\), so \\(s\\) is a simplicial map.\n\\end{proof}\n\nThe choice of \\(s\\) induces a canonical homomorphism \\(s_*: H_n(K') \\to H_n(K)\\).\n\n\\begin{proposition}\n  \\(s_*: H_n(K') \\to H_n(K)\\) is an isomorphism for all \\(n\\).\n\\end{proposition}\n\n\\begin{proof}\n  Postponed until Mayer-Vietoris sequence.\n\\end{proof}\n\n\\begin{definition}\n  Let \\(\\alpha: |K| \\to X\\) be a triangulation we define\n  \\[\n    H_n(X) = H_n(K).\n  \\]\n\\end{definition}\n\nLet \\(\\phi: X \\to Y\\) be continuous and \\(\\alpha: |K| \\to X, \\beta: |K| \\to Y\\) be triangulations. Let \\(f: K^{(r)} \\to L\\) be a simplicial approximation to \\(\\beta^{-1} \\compose \\phi \\compose \\alpha\\). Using simplicial approximation to the identity, we identify \\(H_n(K^{(r)}) = H_n(K)\\) for all \\(r\\). Now set\n\\[\n  \\phi_* = f_*: H_n(X) = H_n(K) = H_n(K^{(r)}) \\to H_n(L) = H_n(Y).\n\\]\nBy results we have proven, \\(\\phi_*\\) is independent of the choice of simplicial approximation. However, we want something stronger: we want homology to be a homotopy invariant.\n\n\\begin{theorem}\n  If \\(X, Y\\) are triangulable spaces and \\(\\phi, \\psi: X \\to Y\\) are homotopic. Then\n  \\[\n    \\phi_* = \\psi_*.\n  \\]\n\\end{theorem}\n\n\\begin{proof}[Non-examinable]\n  Sketch of proof. Let \\(\\alpha: |K| \\to X, \\beta: |L| \\to Y\\). By hypothesis\n  \\[\n    \\beta^{-1} \\compose \\phi \\compose \\alpha \\simeq \\beta^{-1} \\compose \\psi \\compose \\alpha: |K| \\to |L|\n  \\]\n  are homotopic. Let \\(\\Psi: |K| \\times I \\to |L|\\) be such a homotopy. By example sheet 3 Q9 \\(|K| \\times I \\cong |M|\\) for some simplicial complex \\(M\\), such that the ``top'' and ``bottom'' \\(K_0, K_1 \\cong K\\) and embeds in \\(M\\) via \\(i: K \\to M, j: K \\to M\\), and for all \\(\\sigma \\in K\\) there exists \\(M_\\sigma \\subseteq M\\) such that \\(|M_\\sigma| \\cong \\sigma \\times I\\). Note that\n  \\[\n    |\\b M_\\sigma| = (\\sigma \\times \\{0\\}) \\cup (\\sigma \\times \\{1\\}) \\cup M_{\\b \\sigma}.\n  \\]\n  Define a chain homotopy\n  \\begin{align*}\n    h_n: C_n(K^{(r)}) &\\to C_{n + 1}(M^{(r)}) \\\\\n    \\sigma &\\mapsto \\sum \\cdots\n  \\end{align*}\n  Interpreting the equation about \\(\\b M_\\sigma\\) as a statement about oriented simplices,\n  \\[\n    \\p \\compose h(\\sigma) = j(\\sigma) - i(\\sigma) - h \\compose \\b(\\sigma)\n  \\]\n  so\n  \\[\n    j(\\sigma) - i(\\sigma) = \\b \\compose h(\\sigma) + h \\compose \\b(\\sigma).\n  \\]\n  Note that \\(F \\compose i\\) is a simplicial approximation to \\(\\phi = \\Phi \\compose i\\) and \\(F \\compose j\\) is a simplicial approximation to \\(\\tau = \\Phi \\compose j\\). Thus\n  \\[\n    F \\compose j(\\sigma) - F \\compose i(\\sigma)\n    = F \\compose \\b \\compose h(\\sigma) + F \\compose h \\compose \\b(\\sigma)\n    = \\b \\compose (F \\compose h)(\\sigma) + (F \\compose h) \\compose \\b(\\sigma)\n  \\]\n  so \\(F \\compose h\\) is a homotopy between \\(F \\compose i\\) and \\(F \\compose j\\). Thus\n  \\[\n    \\phi_* = (F \\compose i)_* = (F \\compose j)_* = \\psi_*.\n  \\]\n\\end{proof}\n\n\\begin{lemma}\n  If \\(X, Y, Z\\) are triangulable and \\(X \\xrightarrow{\\phi} Y \\xrightarrow{\\psi} Z\\) then\n  \\[\n    (\\psi \\compose \\phi)_* = \\psi_* \\compose \\phi_*.\n  \\]\n  Also \\((\\id_X)_* = \\id_{H_n(X)}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\n\\begin{corollary}\n  If \\(X, Y\\) are triangulable and \\(\\phi: X \\to Y\\) is a homotopy equivalence then \\(\\phi_*: H_n(X) \\to H_n(Y)\\) is an isomorphism for all \\(n\\).\n\\end{corollary}\n\nIn other words, homology is a homotopy invariance.\n\n\\section{Homology calculations}\n\n\\subsection{Homology of spheres and applications}\n\n\\begin{eg}\n  \\(S^{n - 1} \\cong |L|\\) where \\(L\\) is the standard simplicial \\((n - 1)\\)-sphere. Therefore\n  \\[\n    H_k(S^{n - 1}) \\cong H_k(L) =\n    \\begin{cases}\n      \\Z & k = 0, n - 1 \\\\\n      0 & \\text{ otherwise}\n    \\end{cases}\n  \\]\n  Two implications: first since\n  \\[\n    H_{n - 1}(S^{n - 1}) \\cong \\Z \\ncong 0 \\cong H_{n - 1}(*)\n  \\]\n  \\(S^{n - 1}\\) is not contractible. Secondly since\n  \\[\n    H_{n - 1}(S^{n - 1}) \\cong \\Z \\ncong 0 \\cong H_{n - 1}(S^{m - 1})\n  \\]\n  for \\(m \\neq n\\) we see \\(S^{n - 1} \\nsimeq S^{m - 1}\\) unless \\(n = m\\).\n\\end{eg}\n\n\\begin{theorem}[invariance of domain]\\index{invariance of domain}\n  If \\(\\R^m \\cong \\R^n\\) then \\(m = n\\).\n\\end{theorem}\n\n\\begin{proof}\n  Suppose \\(\\phi: \\R^m \\to \\R^n\\) is a homeomorphism. wlog \\(\\phi(0) = 0\\). This induces a homeomorphism \\(\\R^m \\setminus \\{0\\} \\cong \\R^n \\setminus \\{0\\}\\). But they are homotopy equivalent to \\(S^{m - 1}\\) and \\(S^{n - 1}\\) respectively. \\(m = n\\).\n\\end{proof}\n\n\\begin{theorem}[Brouwer fixed point theorem]\\index{Brouwer fixed point theorem}\n  Let \\(D^n\\) be the closed \\(n\\)-dimensional disk. Then any continuous map \\(\\phi: D^n \\to D^n\\) has a fixed point.\n\\end{theorem}\n\n\\begin{proof}\n  Identical to the 2 dimensional case, substituting \\(H_{n - 1}\\) for \\(\\pi_1\\).\n\\end{proof}\n\n\\subsection{Mayer-Vietoris theorem}\n\n\\begin{definition}[(short) exact sequence]\\index{exact sequence}\\index{short exact sequence}\n  A sequence of homomorphism of abelian groups\n  \\[\n    \\begin{tikzcd}\n      \\cdots \\ar[r] & A_{i + 1} \\ar[r, \"f_{i + 1}\"] & A_i \\ar[r, \"f_i\"] & A_{i - 1} \\ar[r] & \\cdots\n    \\end{tikzcd}\n  \\]\n  is \\emph{exact} at \\(A_i\\) if \\(\\ker f_i = \\im f_{i + 1}\\). The sequence is \\emph{exact} if it is exact at every \\(A_i\\).\n\n  A \\emph{short exact sequence} is one of the form\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & A \\ar[r] & B \\ar[r] & C \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(A \\xrightarrow{f} B \\to 0\\) is exact at \\(B\\) if and only if \\(f\\) is surjective.\n  \\item \\(0 \\to A \\xrightarrow{f} B\\) is exact at \\(A\\) if and only if \\(f\\) is injective.\n  \\item A very short exact sequence\n    \\[\n      \\begin{tikzcd}\n        0 \\ar[r] & A \\ar[r, \"f\"] & B \\ar[r] & 0\n      \\end{tikzcd}\n    \\]\n    is an isomorphism \\(f: A \\to B\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{theorem}[Mayer-Vietoris]\\index{Mayer-Vietoris theorem}\n  \\label{thm:Mayer-Vietoris}\n  Let \\(K = L \\cup M\\) with \\(N = L \\cap M\\) be simplicial complexes. Consider the inclusion maps\n  \\[\n    \\begin{tikzcd}\n      N \\ar[r, hook, \"i\"] \\ar[d, hook, \"j\"] & L \\ar[d, hook, \"\\ell\"] \\\\\n      M \\ar[r, hook, \"m\"] & K\n    \\end{tikzcd}\n  \\]\n  then there exists \\(\\delta_*: H_n(K) \\to H_{n - 1}(N)\\) making this sequence exact.\n  \\[\n    \\begin{tikzcd}\n      & \\cdots \\ar[r] & H_{n + 2}(K) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_{n + 1}(N) \\ar[r, \"i_* \\oplus j_*\"] & H_{n + 1}(L) \\oplus H_{n + 1}(M) \\ar[r, \"\\ell_* - m_*\"] & H_{n + 1}(K) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_{n}(N) \\ar[r, \"i_* \\oplus j_*\"] & H_{n}(L) \\oplus H_{n}(M) \\ar[r, \"\\ell_* - m_*\"] & H_n(K) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_{n - 1}(N) \\ar[r, \"i_* \\oplus j_*\"] & H_{n - 1}(L) \\oplus H_{n - 1}(M) \\ar[r, \"\\ell_* - m_*\"] & H_{n - 1}(K) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_{n - 1}(N) \\ar[r] & \\dots\n    \\end{tikzcd}\n  \\]\n\\end{theorem}\n\nThe core of the theorem is a result in homological algebra.\n\n\\begin{definition}[exact chain map]\\index{short exact sequence}\n  A sequence of chain maps\n  \\[\n    \\begin{tikzcd}\n      A_\\bullet \\ar[r, \"f_\\bullet\"] & B_\\bullet \\ar[r, \"g_\\bullet\"] & C_\\bullet \n    \\end{tikzcd}\n  \\]\n  is \\emph{exact} at \\(B_\\bullet\\) if\n  \\[\n    \\begin{tikzcd}\n      A_n \\ar[r, \"f_n\"] & B_n \\ar[r, \"g_n\"] & C_n\n    \\end{tikzcd}\n  \\]\n  is exact at \\(B_n\\) for all \\(n \\in \\Z\\).\n\\end{definition}\n\n\\begin{lemma}[snake lemma]\\index{snake lemma}\n  Let\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & A_\\bullet \\ar[r, \"f_\\bullet\"] & B_\\bullet \\ar[r, \"g_\\bullet\"] & C_\\bullet \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  be a short exact sequence of chain complexes. For any \\(n \\in \\Z\\) there is a homomorphism \\(\\delta_*: H_{n + 1}(C_\\bullet) \\to H_n(A_\\bullet)\\) such that\n  \\[\n    \\begin{tikzcd}\n      & \\cdots \\ar[r, \"g_*\"] & H_{n + 1}(C_\\bullet) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_n(A_\\bullet) \\ar[r, \"f_*\"] & H_n(B_\\bullet) \\ar[r, \"g_*\"] & H_n(C_\\bullet) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_{n - 1}(A_\\bullet) \\ar[r, \"f_*\"] & \\cdots\n    \\end{tikzcd}\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Consider the massive commutative diagram\n  \\[\n    \\begin{tikzcd}\n      & \\vdots \\ar[d] & \\vdots \\ar[d] & \\vdots \\ar[d]  \\\\\n      0 \\ar[r] & A_{n + 1} \\ar[r, \"f_{n + 1}\"] \\ar[d, \"\\b_{n + 1}\"] & B_{n + 1} \\ar[r, \"g_{n + 1}\"] \\ar[d, \"\\b_{n + 1}\"] & C_{n + 1} \\ar[r] \\ar[d, \"\\b_{n + 1}\"] & 0 \\\\\n      0 \\ar[r] & A_{n} \\ar[r, \"f_{n}\"] \\ar[d, \"\\b_{n}\"] & B_{n} \\ar[r, \"g_{n}\"] \\ar[d, \"\\b_{n}\"] & C_{n} \\ar[r] \\ar[d, \"\\b_{n}\"] & 0 \\\\\n      0 \\ar[r] & A_{n - 1} \\ar[r, \"f_{n - 1}\"] \\ar[d, \"\\b_{n - 1}\"] & B_{n - 1} \\ar[r, \"g_{n - 1}\"] \\ar[d, \"\\b_{n - 1}\"] & C_{n - 1} \\ar[r] \\ar[d, \"\\b_{n + 1}\"] & 0 \\\\\n      & \\vdots & \\vdots & \\vdots \n    \\end{tikzcd}\n  \\]\n  Let's construct the map\n  \\begin{align*}\n    \\delta_*: H_{n + 1}(C_\\bullet) &\\to H_n(A_\\bullet) \\\\\n    [x] &\\mapsto ?\n  \\end{align*}\n  with \\(x \\in Z_{n + 1}(C_\\bullet)\\). Since \\(g_{n + 1}\\) is surjective, \\(x = g_{n + 1}(y)\\) for some \\(y \\in B_{n + 1}\\). Consider \\(\\b_{n + 1}(y)\\), by commutativity\n  \\[\n    g_n \\compose \\b_{n + 1}(y) = \\b_{n + 1} \\compose g_n (y) = \\b_{n + 1}(x) = 0\n  \\]\n  as \\(x \\in Z_{n + 1}(C_\\bullet)\\). Thus \\(\\b_{n + 1}(y) \\in \\ker g_n = \\im f_n\\). Thus exists \\(z \\in A_n\\) such that \\(f_n(z) = \\b_{n + 1}(y)\\).\n\n  We would like to check that \\(z \\in Z_n(A_\\bullet)\\). Consider \\(\\b_n(z)\\),\n  \\[\n    f_{n - 1} \\compose \\b_n(z) = \\b_n \\compose f_n(z) = \\b_n \\compose \\b_{n + 1}(y) = 0.\n  \\]\n  But \\(f_{n - 1}\\) is injective so \\(\\b_n(z) = 0\\), and thus \\(z \\in Z_n(A_\\bullet)\\). Thus let \\(\\delta_*([x]) = [z]\\).\n\n  We have to check this is well-defined and \\(\\delta_*\\) is a homomorphism. Finally we have to check exactness at \\(H_n(A_\\bullet), H_n(B_\\bullet), H_n(C_\\bullet)\\). This is just a tedious exercise in diagram chasing.\n\\end{proof}\n\n\\begin{proof}[Proof of \\nameref{thm:Mayer-Vietoris}]\n  By the snake lemma it suffices to check that the following is an exact sequence of chain complex.\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & C_\\bullet(N) \\ar[r, \"i_\\bullet \\oplus j_\\bullet\"] & C_\\bullet(L) \\oplus C_\\bullet(M) \\ar[r, \"\\ell_\\bullet - m_\\bullet\"] & C_\\bullet(K) \\ar[r] & 0.\n    \\end{tikzcd}\n  \\]\n  \\begin{itemize}\n  \\item exactness at \\(C_n(N)\\): \\(i_n\\) induces \\(C_n(N)\\) as a direct summand in \\(C_n(L)\\) and similar for \\(j_n\\). Thus \\(i_n \\oplus j_n\\) is injective.\n  \\item exactness at \\(C_n(K)\\): consider \\(c \\in C_n(K)\\), have \\(c = c_L + c_M\\) where \\(c_L, c_M\\) are ``supported'' in \\(L\\) and \\(M\\) respectively. To make it precise, this means that they are respective images of \\(\\ell_n\\) and \\(m_n\\), i.e.\\ there exists \\(b_L \\in C_n(L), b_M \\in C_n(M)\\) such that \\(c_L = \\ell_n(b_L), c_M = m_n(b_M)\\). Thus\n    \\[\n      c = \\ell_n(b_L) - m_n(-b_M) = (\\ell_n - m_n)(b_L, -b_M).\n    \\]\n  \\item exactness at \\(C_n(L) \\oplus C_n(M)\\): \\((b_L, b_M) \\in \\ker(\\ell_n - m_n)\\) if and only if each simplex \\(\\sigma\\) that appears in \\(b_L\\) also appears in \\(b_M\\) with the same coefficients, if and only if \\((b_L, b_M) \\in \\im(i_n \\oplus j_n)\\).\n  \\end{itemize}\n\\end{proof}\n\n\\begin{lemma}[five lemma]\\index{five lemma}\n  Suppose the following diagram is commutative and the rows are exact:\n  \\[\n    \\begin{tikzcd}\n      A \\ar[r] \\ar[d, \"\\alpha\"] & B \\ar[r] \\ar[d, \"\\beta\"] & C \\ar[r] \\ar[d, \"\\gamma\"] & D \\ar[r] \\ar[d, \"\\delta\"] & E \\ar[d, \"\\varepsilon\"] \\\\\n      A' \\ar[r] & B' \\ar[r] & C' \\ar[r] & D' \\ar[r] & E'\n    \\end{tikzcd}\n  \\]\n  if \\(\\alpha, \\beta, \\delta, \\varepsilon\\) are isomorphisms then so is \\(\\gamma\\).\n\\end{lemma}\n\n\\begin{proof}\n  Example sheet 4.\n\\end{proof}\n\nRecall that we claimed before given a barycentric subdivision \\(K'\\) of a simplicial complex \\(K\\), the induced map \\(s_*: H_n(K') \\to H_n(K)\\) is an isomorphism.\n\n\\begin{proof}\\index{barycentric subdivision}\n  Induction on the number of simplices of \\(K\\). If \\(K = \\{*\\}\\) then \\(K = K'\\) so obviously true. For inductive step, choose \\(\\sigma \\in K\\) with maximal dimension. Let\n  \\begin{align*}\n    L &= K - \\{\\sigma\\} \\\\\n    M &= \\{\\tau \\leq \\sigma: \\tau \\in K\\} \\\\\n    N &= L \\cap M = \\b \\sigma\n  \\end{align*}\n  \\(L, N\\) have fewer simplices than \\(K\\). Because \\(M, M'\\) are both cones, \\(s_*: H_n(M') \\to H_n(M)\\) is an isomorphism. Look at Mayer-Vietoris for \\(K = L \\cup_N M, K' = L' \\cup_{N'} M'\\).\n  \\[\n    \\begin{tikzcd}[column sep=small]\n      H_{n + 1}(N') \\ar[r] \\ar[d, \"s_*\"] & H_{n + 1}(L') \\oplus H_{n + 1}(M') \\ar[r] \\ar[d, \"s_* \\oplus s_*\"] & H_{n + 1}(K') \\ar[r] \\ar[d, \"s_*\"] & H_n(N') \\ar[r] \\ar[d, \"s_*\"] & H_n(L') \\oplus H_n(M') \\ar[d, \"s_* \\oplus s_*\"] \\\\\n      H_{n + 1}(N) \\ar[r] & H_{n + 1}(L) \\oplus H_{n + 1}(M) \\ar[r] & H_{n + 1}(K) \\ar[r] & H_n(N) \\ar[r] & H_n(L) \\oplus H_n(M) \\\\\n    \\end{tikzcd}\n  \\]\n  so the five lemma finishes the job.\n\\end{proof}\n\n\\subsection{Homology of compact surfaces}\n\nRecall that classification of compact surfaces says there are two classes of surfaces there are two classes: \\(\\Sigma_g\\) and \\(S_g\\). We are going to use Mayer-Vietoris to compute their homologies. Before that we have to know the homology of \\(\\Gamma_r\\).\n\n\\begin{eg}\n  \\(\\Gamma_r = \\bigvee_{i = 1}^r S^1\\). \\(\\Gamma_0 = *, \\Gamma_1 \\cong S^1\\) and their homologies are known. Use standard simplicial \\(1\\)-sphere. There is a slight issue here that the way we set up simplicial complex makes it difficult to glue things. Instead we are going to use abstract simplicial complex.\n\n  Let \\(K\\) be such that \\(|K| \\cong \\Gamma_r\\), \\(L, M \\subseteq K\\) be such that \\(|L| \\cong \\Gamma_{r - 1}, |M| \\cong S^1\\), and \\(K = L \\cup_N M\\) where \\(N = \\{v_0\\}\\). By Mayer-Vietoris,\n  \\[\n    \\begin{tikzcd}\n      H_1(N) \\ar[r] & H_1(L) \\oplus H_1(M) \\ar[r] & H_1(K) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      H_0(N) \\ar[r] & H_0(L) \\oplus H_0(M) \\ar[r] & H_0(K) \\ar[dll, out=0, in=180] \\\\\n      0\n    \\end{tikzcd}\n  \\]\n  which is\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H_1(\\Gamma_{r - 1}) \\oplus \\Z \\ar[r] & H_1(\\Gamma_r) \\ar[dll, out=0, in=180, \"\\delta_*\"] \\\\\n      \\Z \\ar[r] & \\Z \\oplus \\Z \\ar[r] & \\Z \\ar[dll, out=0, in=180] \\\\\n      0\n    \\end{tikzcd}\n  \\]\n  and unfortunately we have to get out hands dirty to understand \\(\\delta_*\\). The map \\(H_0(N) \\to H_0(L) \\oplus H_0(M)\\) sends generator to generators so is injective and thus by exactness at \\(H_1(K)\\), \\(\\im \\delta_* = 0\\). Thus we have a very short exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H_1(\\Gamma_{r - 1}) \\oplus \\Z \\ar[r] & H_1(\\Gamma_r) \\ar[r, \"\\delta_*\"] & 0\n    \\end{tikzcd}\n  \\]\n  so \\(H_1(\\Gamma_r) \\cong \\Gamma_1(\\Gamma_{r - 1}) \\oplus \\Z\\). Thus we conclude that\n  \\[\n    H_n(\\Gamma_r) =\n    \\begin{cases}\n      \\Z & n = 0 \\\\\n      \\Z^r & n = 1 \\\\\n      0 & \\text{otherwise}\n    \\end{cases}\n  \\]\n  Note that \\(H_1(\\Gamma_r) \\cong \\langle [\\alpha_1] \\rangle \\oplus \\dots \\oplus \\langle [\\alpha_r] \\rangle\\) where \\([\\gamma_i]\\) is a generator for \\(H_1(i\\text{th circle})\\).\n\\end{eg}\n\n\\begin{remark}\n  Note that this proof does not assume anything other path-connectedness. Thus \\(\\delta_*: H_1(K) \\to H_0(N)\\) is always zero as long as the intersection \\(N\\) is connected. Then we don't have to worry about the last row of Mayer-Vietoris.\n\\end{remark}\n\n\\begin{eg}\n  \\(\\Sigma_g = \\Gamma_{2g} \\cup_{\\rho_g} D^2\\) where\n  \\[\n    \\rho_g(1) = \\alpha_1\\beta_1\\alpha_1^{-1}\\beta_1^{-1} \\cdots \\alpha_g \\beta_g \\alpha_g^{-1} \\beta_g^{-1}.\n  \\]\n  Just as mapping cylinder, to compute the homology it's convenient to introduce a new space\n  \\[\n    \\Sigma_g^* = \\Gamma_{2g} \\cup_{2g} (S^1 \\times [0, 1])\n  \\]\n  with \\((x, 0) \\sim \\rho_g(x)\\) for all \\(x \\in S^1\\). This is just \\(\\Sigma_g\\) with \\(D^2\\) removed. Note that \\(\\Sigma_g^*\\) deformation retracts to \\(\\Gamma_{2g}\\).\n\n  A bit of technical work: we can triangulate \\(\\Sigma_g^*\\) by triangulating \\(\\Gamma_{2g}\\) then taking a simplicial approximation to \\(\\rho_g\\) and triangulating \\(S^1 \\times I\\) in a way compactible with that.\n  \n  Next note that\n  \\[\n    \\Sigma_g = \\Sigma_g^* \\cup_i D^2\n  \\]\n  where \\(i: S^1 \\to \\Sigma_g^*\\) is the map identifying \\(\\b D^2\\) with \\(S^1 \\times I\\). Choose a triangulation of \\(D^2\\) compatible with the induced triangulation of its boundary.\n\n  Back to the actual computation.\n  \\[\n    \\begin{tikzcd}\n      H_2(S^1) \\ar[r] & H_2(\\Sigma_g^*) \\oplus H_2(D^2) \\ar[r] & H_2(\\Sigma_g) \\ar[dll, out=0, in=180] \\\\\n      H_1(S^1) \\ar[r] & H_1(\\Sigma_g^*) \\oplus H_1(D^2) \\ar[r] & H_1(\\Sigma_g) \\ar[dll, out=0, in=180] \\\\\n      0\n    \\end{tikzcd}\n  \\]\n  note that by the previous remark we don't have to write down the last row. Fill in information we already knew,\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & 0 \\ar[r] & H_2(\\Sigma_g) \\ar[r] & \\Z \\ar[r, \"i_*\"] & \\Z^{2g} \\ar[r] & H_1(\\Sigma_g) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  To figure out the two unknown groups we need to understand \\(i_*\\), which induced by \\(\\rho_g\\). But since homology groups are abelian, we have\n  \\[\n    i_*(1)\n    = (\\gamma_g)_*(1)\n    = [\\alpha_1] + [\\beta_1] - [\\alpha_1] - [\\beta_1] + \\dots + [\\alpha_g] + [\\beta_g] - [\\alpha_g] - [\\beta_j] = 0\n  \\]\n  So we split that into two exact sequences\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H_2(\\Sigma_g) \\ar[r] & \\Z \\ar[r] & 0\n    \\end{tikzcd}\n    \\begin{tikzcd}\n      0 \\ar[r] &  \\Z^{2g} \\ar[r] & H_2(\\Sigma_g) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  so\n  \\[\n    H_n(\\Sigma_g) \\cong\n    \\begin{cases}\n      \\Z & n = 0, 2 \\\\\n      \\Z^{2g} & n = 1 \\\\\n      0 & \\text{otherwise}\n    \\end{cases}\n  \\]\n  which in particular implies that they are pairwise non-homotopy equivalent.\n\\end{eg}\n\n\\begin{eg}\n  \\(S_g = \\Gamma_{g + 1} \\cup_{\\sigma_g} D^2\\) where\n  \\[\n    \\sigma_g(1) = \\alpha_0^2 \\alpha_1^2 \\cdots \\alpha_g^2.\n  \\]\n  By almost the same argument, we obtain a Mayer-Vietoris sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & H_2(S_g) \\ar[r, \"\\delta_*\"] & \\Z \\ar[r, \"i_*\"] & \\Z^{g + 1} \\ar[r] & H_1(S_g) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  where this times \\(i_*\\) is induced by \\(\\sigma_g\\), and\n  \\[\n    i_*\n    = (\\gamma_g)_*(1) = 2[\\alpha_0] + 2[\\alpha_1] + \\dots + 2[\\alpha_g]\n  \\]\n  which is injective so \\(\\delta_* = 0\\). Thus \\(H_2(S_g) = 0, H_1(S_g) \\cong \\Z^g \\oplus (\\Z/2\\Z)\\).\n\\end{eg}\n\n\\subsection{Rational homology and Euler characteristic}\n\nBasically homology with coefficients in \\(\\Q\\).\n\n\\begin{definition}[rational chain]\\index{rational chain}\n  Let \\(K\\) be a simplicial complex. The vector space of \\emph{rational \\(n\\)-chain} \\(C_n(K; \\Q)\\) is defined as the vector space over \\(\\Q\\) with basis the \\(n\\)-simplices of \\(K\\).\n\\end{definition}\n\nA typical element thus has the form \\(\\sum_i \\lambda_i \\sigma_i\\) where \\(\\lambda_i \\in \\Q\\) and \\(\\sigma_i\\)'s are \\(n\\)-simplices. We can define the boundary map \\(\\b_n: C_n(K; \\Q) \\to C_n(K; \\Q)\\) as before and the condition \\(\\b \\compose \\b = 0\\) is satisfied so we have another homology theory.\n\n\\begin{definition}[rational homology]\\index{rational homology}\n  Let \\(K\\) be a simplicial complex. We define\n  \\begin{align*}\n    Z_n(K; \\Q) &= \\ker \\b_n \\\\\n    B_n(K; \\Q) &= \\im \\b_{n + 1} \\\\\n    H_n(K; \\Q) &= Z_n(K; \\Q)/B_n(K; \\Q)\n  \\end{align*}\n  If \\(\\alpha: |K| \\to X\\) is a triangulation then define\n  \\[\n    H_n(X; \\Q) = H_n(K; \\Q).\n  \\]\n\\end{definition}\n\nRational homology encodes slightly less data but has the advantage of easier to compute (as \\(\\Q\\) is a field). More specifically, it simply forgets the torsion elements:\n\n\\begin{lemma}\n  Let \\(K\\) be a simplicial complex. If \\(H_n(K) \\cong \\Z^k \\oplus F\\) where \\(F\\) is a finite group then\n  \\[\n    H_n(K; \\Q) \\cong \\Q^k.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  An exercise in commutative algebra. See online notes.\n\\end{proof}\n\n\\begin{eg}\n  For all \\(n\\),\n  \\[\n    H_n(\\R P^2; \\Q) \\cong H_n(*; \\Q).\n  \\]\n\\end{eg}\n\n\\begin{definition}[Euler characteristic]\\index{Euler characteristic}\n  Let \\(X\\) be a triangulable space and \\(\\alpha: |K| \\to X\\) a triangulation. Then the \\emph{Euler characteristic} of \\(X\\) is\n  \\[\n    \\chi(X) = \\chi(K) = \\sum_{n \\in \\Z} (-1)^n \\dim_\\Q H_n(K; \\Q).\n  \\]\n\\end{definition}\n\nNote that this is obviously a topological invariant.\n\nGiven the way rational homology is defined, the nice thing about \\(\\chi(K)\\) is that it is \\emph{really} easy to compute.\n\n\\begin{lemma}\n  Let \\(K\\) be a simplicial complex. Then\n  \\[\n    \\chi(K) = \\sum_{n \\in \\Z} (-1)^n \\#\\{n\\text{-simplicies in } K\\}.\n  \\]\n\n  In particular if \\(K\\) is \\(2\\)-dimensional, with \\(V, E, F\\) the number of \\(0, 1\\) and \\(2\\)-simplices then\n  \\[\n    \\chi(K) = V - E + F.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  The number of \\(n\\)-simplex is not a natural algebraic object so instead we use \\(\\dim_\\Q C_n(K; \\Q)\\). Next, recall that we are working with vector spaces so we can apply rank-nullity theorem to\n  \\begin{align*}\n    Z_n(K; \\Q) &\\twoheadrightarrow H_n(K; \\Q) \\\\\n    \\b_n: C_n &\\to B_{n - 1}\n  \\end{align*}\n  to get\n  \\begin{align*}\n    \\dim Z_n &= \\dim H_n + \\dim B_n \\\\\n    \\dim C_n &= \\dim B_{n - 1} + \\dim Z_n\n  \\end{align*}\n\n  Now\n  \\begin{align*}\n    \\sum_{n \\in \\Z} (-1)^n \\dim_\\Q C_n\n    &= \\sum_{n \\in \\Z} (-1)^n \\dim B_{n - 1} + \\sum_{n \\in \\Z} (-1)^n \\dim Z_n \\\\\n    &= - \\sum_{n \\in \\Z} (-1)^n \\dim B_n + \\sum_{n \\in \\Z} (-1)^n \\dim Z_n \\\\\n    &= \\sum_{n \\in \\Z} (-1)^n (\\dim Z_n - \\dim B_n) \\\\\n    &= \\sum_{n \\in \\Z} (-1)^n \\dim H_n \\\\\n    &= \\chi(K)\n  \\end{align*}\n\\end{proof}\n\n\\begin{note}\n  \\begin{align*}\n    \\chi(\\Sigma_g) &= 2 - 2g \\\\\n    \\chi(S_g) &= 1 - g\n  \\end{align*}\n\\end{note}\n\n\\subsection{Lefschetz fixed-point theorem}\n\n\\begin{definition}[Lefschetz number]\\index{Lefschetz number}\n  Let \\(\\phi: X \\to X\\) be a continuous map of triangulable space \\(X\\). The \\emph{Lefschetz number} of \\(\\phi\\) is\n  \\[\n    L(\\phi) = \\sum_{n \\in \\Z} (-1)^n \\tr(\\phi_*: H_n(X; \\Q) \\to H_n(X; \\Q)).\n  \\]\n\\end{definition}\n\n\\begin{note}\n  \\(L(\\id_X) = \\chi(X)\\) so Lefschetz number generalises Euler characteristic.\n\\end{note}\n\n\\begin{lemma}\n  If \\(f: K \\to K\\) is a simplicial map then\n  \\[\n    L(|f|) = \\sum_{n \\in \\Z} (-1)^n \\tr(f_*: C_n(K; \\Q) \\to C_n(K; \\Q)).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Consider the following commutative diagrams of linear maps with exact rows:\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & A \\ar[r] \\ar[d, \"\\alpha\"] & B \\ar[r] \\ar[d, \"\\beta\"] & C \\ar[r] \\ar[d, \"\\gamma\"] & 0 \\\\\n      0 \\ar[r] & A' \\ar[r] & B' \\ar[r] & C' \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  By linear algebra we can find bases for \\(B, B'\\) such that the matrix for \\(\\beta\\) have has the form\n  \\[\n    \\begin{pmatrix}\n      \\gamma & * \\\\\n      0 & \\alpha\n    \\end{pmatrix}\n  \\]\n  so in particular\n  \\[\n    \\tr \\beta = \\tr \\gamma + \\tr \\alpha.\n  \\]\n  What is left is an application of rank-nullity theorem, similar to the proof of Euler characteristic.\n\\end{proof}\n\n\\begin{theorem}[Lefschetz fixed point theorem]\\index{Lefschetz fixed point theorem}\n  Let \\(X\\) be a triangulable space and \\(\\phi: X \\to X\\) a continuous map. If \\(L(\\phi) \\neq 0\\) then \\(\\phi\\) has a fixed point.\n\\end{theorem}\n\n\\begin{proof}[Non-examinable, sketch]\n  Suppose \\(\\phi\\) has no fixed point. Since \\(X\\) is compact, exists \\(\\delta > 0\\) such that for all \\(x \\in X\\), \\(\\norm{x - \\phi(x)} > \\delta\\). Now choose a simplicial approximation \\(K\\) of \\(X\\) with \\(\\mesh(K) < \\frac{\\delta}{2}\\). Let \\(f: K^{(r)} \\to K\\) be a simplicial approximation to \\(\\phi\\). Note that if \\(v \\in \\sigma \\in \\sigma\\) then \\(f(v) \\notin \\sigma\\). Let \\(\\iota_n: C_n(K; \\Q) \\to C_n(K; \\Q)\\) be the map inducing canonical isomorphism of homology groups. For any \\(n\\)-simplex \\(\\sigma \\in K\\), \\(\\iota_n(\\sigma)\\) is supported on simplices contained in \\(\\sigma\\). Then \\(f_n \\compose \\iota_n\\) takes every simplex of \\(K\\) off itself, i.e.\\ \\(f_n \\compose \\iota_n (\\sigma)\\) does not contain \\(\\sigma\\). Now\n  \\begin{align*}\n    L(\\phi)\n    &= \\sum_{n \\in \\Z} (-1)^n \\tr(f_n \\compose \\iota_n: C_n(K; \\Q) \\to C_n(K; \\Q)) \\\\\n    &= \\sum_{n \\in \\Z} (-1)^n \\cdot 0 \\\\\n    &= 0\n  \\end{align*}\n\\end{proof}\n\n\\printindex\n\\end{document}\n\n% https://www.dpmms.cam.ac.uk/~hjrw2/teaching.html\n", "meta": {"hexsha": "e7c3d36b390d25887181e409d0610a8424857b3c", "size": 105818, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "II/algebraic_topology.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "II/algebraic_topology.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "II/algebraic_topology.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 44.7433403805, "max_line_length": 801, "alphanum_fraction": 0.6076092914, "num_tokens": 39484, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.4206359775356124}}
{"text": "\\chapter{Applications II:  \\alphatap}\\label{alphatapchapter}\n\nIn this chapter we examine a second application of nominal logic\nprogramming, a declarative theorem prover for first-order classical\nlogic. We call this prover \\alphatap, since it is based on the\n\\leantapsp\\cite{beckert95leantap} prover and written in\n\\alphakanren. Our prover is a relation, without mode restrictions;\ngiven a logic variable as the theorem to be proved, \\alphatapsp\n\\textit{generates} valid theorems.\n\n\\leantapsp is a lean tableau-based theorem prover for first-order\nlogic due to \\citet{beckert95leantap}.  Written in\nProlog, it is extremely concise and is capable of a high rate of\ninference. \\leantapsp uses Prolog's cut (\\texttt{!}) in three of its\nfive clauses in order to avoid nondeterminism, and uses\n\\mbox{\\texttt{copy\\_term/2}} to make copies of universally quantified\nformulas. Although Beckert and Posegga take advantage of Prolog's\nunification and backtracking features, their use of the impure cut and\n\\mbox{\\texttt{copy\\_term/2}} makes \\leantapsp non-declarative.\n\n% : reordering goals within the prover may cause divergence.\n\n%% new definition of nondeclarative?\n\nIn this chapter we translate \\leantapsp from Prolog to impure\nminiKanren, using \\scheme|match-a| to mimic Prolog's cut, and\n\\scheme|copy-termo| to mimic \\mbox{\\texttt{copy\\_term/2}}.  We then show how\nto eliminate these impure operators from our translation. To eliminate the\nuse of \\scheme|match-a|, we introduce a tagging scheme that makes our\nformulas unambiguous.  To eliminate the use of \\scheme|copy-termo|, we\nuse substitution instead of copying terms.  Universally quantified\nformulas are used as templates, rather than instantiated directly;\ninstead of representing universally quantified variables with logic\nvariables, we use the noms of nominal logic. We then use nominal\nunification to write a substitution relation that replaces quantified\nvariables with logic variables, leaving the original template\nuntouched.\n\nThe resulting declarative theorem prover is interesting for two\nreasons. First, because of the technique used to arrive at its\ndefinition: we use declarative substitution rather than\n\\scheme|copy-termo|.  To our knowledge, there is no method for\ncopying arbitrary terms declaratively. Our solution is not completely\ngeneral but is useful when a term is used as a template for copying,\nas in the case of \\leantap.  Second, because of the flexibility of the\nprover itself: \\alphatapsp is capable of instantiating non-ground\ntheorems during the proof process, and accepts non-ground\n\\textit{proofs}, as well.  Whereas \\leantapsp is fully automated and\neither succeeds or fails to prove a given theorem, \\alphatapsp can\naccept guidance from the user in the form of a partially-instantiated\nproof, regardless of whether the theorem is ground.\n\nWe present an implementation of \\alphatapsp in\nsection~\\ref{implementation} , demonstrating our technique for\neliminating cut and \\mbox{\\texttt{copy\\_term/2}} from \\leantap. Our\nimplementation demonstrates our contributions: first, it illustrates a\nmethod for eliminating common impure operators, and demonstrates the\nuse of nominal logic for representing formulas in first-order logic;\nsecond, it shows that the tableau process can be represented as a\nrelation between formulas and their tableaux; and third, it\ndemonstrates the flexibility of relational provers to mimic the full\nspectrum of theorem provers, from fully automated to fully dependent\non the user.\n\nThis chapter is organized as follows. In section~\\ref{tableau} we\ndescribe the concept of tableau theorem proving. In\nsection~\\ref{alphatap} we motivate our declarative prover by examining\nits declarative properties and the proofs it returns. In\nsection~\\ref{implementation} we present the implementation of\n\\alphatap, and in section~\\ref{performance} we briefly examine\n\\alphatap's performance. Familiarity with tableau theorem proving\nwould be helpful; for more on this topic, see the references given in\nsection~\\ref{tableau}.  In addition, a reading knowledge of Prolog\nwould be useful, but is not necessary; for readers unfamiliar with\nProlog, carefully following the miniKanren and \\alphakanrensp code\nshould be sufficient for understanding all the ideas in this chapter.\n\n\\section{Tableau Theorem Proving}\\label{tableau}\n\nWe begin with an introduction to tableau theorem proving and its\nimplementation in \\leantap.\n\n\nTableau is a method of proving first-order theorems that works by\nrefuting the theorem's negation. In our description we assume basic\nknowledge of first-order logic; for coverage of this subject and a\nmore complete description of tableau proving, see\n\\citet{fitting1996fol}.  For simplicity, we consider only\nformulas in Skolemized \\textit{negation normal form} (NNF).\nConverting a formula to this form requires removing existential\nquantifiers through Skolemization, reducing logical connectives so\nthat only $\\wedge$, $\\vee$, and $\\neg$ remain, and pushing negations\ninward until they are applied only to literals---see section~3 of\n\\citet{beckert95leantap} for details.\n\nTo form a tableau, a compound formula is expanded into branches\nrecursively until no compound formulas remain.  The leaves of this\ntree structure are referred to as \\textit{literals}. \\leantapsp forms\nand expands the tableau according to the following rules. When the\nprover encounters a conjunction $x \\wedge y$, it expands both $x$ and\n$y$ on the same branch. When the prover encounters a disjunction $x\n\\vee y$, it splits the tableau and expands $x$ and $y$ on separate\nbranches.  Once a formula has been fully expanded into a tableau, it\ncan be proved unsatisfiable if on each branch of the tableau there\nexist two complementary literals $a$ and $\\neg a$ (each branch is\n\\textit{closed}).  In the case of propositional logic, syntactic\ncomparison is sufficient to find complementary literals; in\nfirst-order logic, sound unification must be used. A closed tableau\nrepresents a proof that the original formula is unsatisfiable.\n\n The addition of universal quantifiers makes the expansion process more\n complicated. To prove a universally quantified formula \\mbox{$\\forall x. M$}, \n \\leantapsp generates a logic variable $v$ and expands $M$,\n replacing all occurrences of $x$ with $v$ (i.e., it expands $M^{\\prime}$ where\n $M^{\\prime} = M[v/x]$).  If \\leantapsp is unable to close the current branch\n after this expansion, it has the option of generating another logic\n variable and expanding the original formula again. When the prover\n expands the universally quantified formula \\mbox{$\\forall x.  F(x) \\wedge ( \\neg F({\\sf a})\n   \\vee \\neg F({\\sf b}) )$}, for example, \\mbox{$\\forall x.  F(x)$}\n must be expanded twice, since $x$ cannot be instantiated to both\n \\textsf{a} and \\textsf{b}.\n\n\\section{Introducing \\alphatap}\\label{alphatap}\n\nWe begin by presenting some examples of \\alphatap's abilities, both in\nproving ground theorems and in generating theorems. We also explore\nthe proofs generated by \\alphatap, and show how passing\npartially-instantiated proofs to the prover can greatly improve its\nperformance.\n\n\\subsection{Running Forwards}\\label{forwards}\n\nBoth \\leantapsp and \\alphatapsp can prove ground theorems; in\naddition, \\alphatap\\ produces a proof.  This proof is a list\nrepresenting the steps taken to build a closed tableau for the\ntheorem; \\citet{paulson99generic} has shown that translation to\na more standard format is possible. Since a closed tableau represents\nan unsatisfiable formula, such a list of steps proves that the\nnegation of the formula is valid. If the list of steps is ground, the\nproof search becomes deterministic, and \\alphatapsp acts as a proof\nchecker.\n\n\\leantapsp encodes first-order formulas using Prolog terms.  For\nexample, the term \\mbox{\\texttt{(p(b),all(X,(-p(X);p(s(X)))))}}\nrepresents \\mbox{$p($\\textsf{b}$) \\wedge \\forall x . \\neg p(x) \\vee\n  p(s(x))$}. In our prover, we represent formulas using Scheme lists\nwith extra tags:\n\n%, and in our final version we adopt a more extensive tagging\n%scheme. The \\schemeresult|forall| binder is represented by\n%\\alphakanren's \\scheme|tie|, and variables are represented by noms.\n%Our example formula is represented by the ground list:\n\n\\schemedisplayspace\n\\begin{schemeresponse}\n(and-tag (pos (app p (app b))) (forall (tie anom (or-tag (neg (app p (var-tag anom))) \n                                                     (pos (app p (app s (var-tag anom))))))))\n\n\\end{schemeresponse}\n\n% The Prolog query \\mbox{\\texttt{prove(Fml,[],[],[],VarLim)}} succeeds\n% if the formula \\texttt{Fml} is unsatisfiable.  Similarly, the\n% \\alphakanrensp goal \\mbox{\\scheme|(proveo fml '() '() '() proof)|}\n% succeeds if \\scheme|fml| can be shown to be unsatisfiable via the\n% proof \\scheme|proof|.\n\nConsider Pelletier Problem 18~\\cite{pelletier1986sfp}: \\mbox{$\\exists\n  y.  \\forall x. F(y) \\Rightarrow F(x)$}. To prove this theorem in\n\\alphatap, we transform it into the following \\textit{negation} of the\nNNF:\n\n\\schemedisplayspace\n\\begin{schemeresponse}\n(forall (tie anom (and-tag (pos (app f (var-tag anom))) (neg (app f (app g1 (var-tag anom)))))))\n\\end{schemeresponse}\n\n\\noindent where \\schemeresult|`(app ,g1 (var-tag anom))| represents the\napplication of a Skolem function to the universally quantified\nvariable $a$. Passing this formula to the prover, we obtain the proof\n\\schemeresult|`(univ conj savefml savefml univ conj close)|. This proof\nlists the steps the prover (presented in section~\\ref{matcha}) follows to close\nthe tableau. Because both conjuncts of the formula contain the nom\n$a$, we must expand the universally quantified formula more than once.\n\nPartially instantiating the proof helps \\alphatapsp prove theorems\nwith similar subparts. We can create a non-ground proof that describes\nin general how to prove the subparts and have \\alphatapsp fill in the\ntrivial differences. This can speed up the search for a proof\nconsiderably. By inspecting the negated NNF of Pelletier Problem~21,\nfor example, we can see that there are at least two portions of the\ntheorem that will have the same proof. By specifying the structure of\nthe first part of the proof and constraining the identical portions by\nusing the same logic variable to represent both, we can give the\nprover some guidance without specifying the whole proof. We pass the\nfollowing non-ground proof to \\alphatap:\n\n\\schemedisplayspace\n\\vspace{-2pt}\n\\begin{centering}\n\\begin{schemeresponse}\n(conj univ split (conj savefml savefml conj split Xvar Xvar)\n      (conj savefml savefml conj split (close) (savefml split Yvar Yvar)))\n\\end{schemeresponse}\n\\end{centering}\n\\vspace{-2pt}\n\n\\noindent On our test machine, our prover solves the original problem\nwith no help in 68 milliseconds (ms); given the knowledge that the\nlater parts of the proof will be duplicated, the prover takes only 27\nms. This technique also yields improvement when applied to Pelletier\nProblem 43: inspecting the negated NNF of the formula, we see two\nparts that look nearly identical. The first part of the negated\nNNF---the part representing the theorem itself---has the following\nform:\n\n\\schemedisplayspace\n\\vspace{-2pt}\n\\begin{centering}\n\\begin{schemeresponse}\n(and-tag (or-tag (and-tag (neg (app Q (app g4) (app g3)))\n              (pos (app Q (app g3) (app g4))))\n         (and-tag (pos (app Q (app g4) (app g3)))\n              (neg (app Q (app g3) (app g4))))) ...)\n\\end{schemeresponse}\n\\end{centering}\n\\vspace{-2pt}\n\n\\noindent Since we suspect that the same proof might suffice for both\nbranches of the theorem, we give the prover the partially-instantiated\nproof \\mbox{\\schemeresult|`(conj split Xvar Xvar)|}. Given just this\nsmall amount of help, \\alphatapsp proves the theorem in 720 ms,\ncompared to 1.5 seconds when the prover has no help at all.  While\nsituations in which large parts of a proof are identical are rare,\nthis technique also allows us to handle situations in which different\nparts of a proof are merely similar by instantiating as much or as\nlittle of the proof as necessary.\n\n\\subsection{Running Backwards}\\label{backwards}\n\n% \\begin{figure}[H]\n% \\begin{centering}\n% \\begin{tabular}{| r | c | c | c | c |}\n%   \\hline \n%   Problem & \\thinspace \\leantap \\thinspace\\footnotemark[4] \\thinspace &\n%   Translation\\footnotemark[3] & \\thinspace \\alphatap\\footnotemark[3]\n%   \\thinspace & \\thinspace \\alphatap$\\!_G$\\footnotemark[4]$^,$\\footnotemark[6]  \\\\\n%   \\hline\n%   1 & ? & \n\n%   \\hline\n% \\end{tabular}\n% \\caption{\\alphatap's Performance on Pelletier's Problems\\protect\\footnotemark[2]\n%   \\label{fig:performance}}\n% \\end{centering}\n% \\end{figure}\n\n\n\n%\\vspace{-6pt}\n\n%  Testing our prover on\n% several of Pelletier's 75 problems~\\cite{pelletier1986sfp} shows that\n% \\alphatapsp is about three to five times slower than our translation\n% of \\leantap. The translation solves problem 32, for example, in about\n% one second, while \\alphatapsp takes about three\n% seconds; problem 26 takes our translation of \\leantapsp about 13\n% seconds, while \\alphatapsp needs 36 seconds.\n\nUnlike \\leantap, \\alphatapsp can generate valid theorems.  Some\ninterpretation of the results is required since the theorems generated\nare negated formulas in NNF.\\footnote{The full implementation of\n  \\alphatapsp includes a simple declarative translator from negated\n  NNF to a positive form.}  In the example\n\n\\smallskip\n\n\\scheme|(run1 (q) (exist (x) (proveo q '() '() '() x)))|\n\n\\hspace{0.1cm}$\\Rightarrow$\n\\schemeresult|`((and-tag (pos (app _.0)) (neg (app _.0))))|\n\n\\smallskip\n\n\\noindent \nthe reified logic variable \\schemeresult|_.0| represents any\nfirst-order formula $p$, and the entire answer represents the formula\n$p \\wedge \\neg p$.  Negating this formula yields the original theorem:\n$\\neg p \\vee p$, or the law of excluded middle.  We can also generate\nmore complicated theorems; here we use the ``generate and test'' idiom\nto find the first theorem matching the negated NNF of the inference\nrule {\\it modus ponens}:\n\n\\schemedisplayspace\n\\begin{schemedisplay}\n(run1 (q)\n  (exist (x)\n    (proveo x '() '() '() q)\n    (== `(and-tag (and-tag (or-tag (neg (app a)) (pos (app b))) (pos (app a))) (neg (app b)))\n        x)))\n\\end{schemedisplay}\n \\vspace{-.1cm}\n\\noindent $\\Rightarrow$ \\schemeresult|`((conj conj split (savefml close) (savefml savefml close)))|\n\n\\smallskip\n\n\\noindent This process takes about 5.1 seconds; {\\it modus ponens} is the\n173rd theorem to be generated, and the prover also generates a proof\nof its validity. When this proof is given to \\alphatap, {\\it modus ponens}\nis the sixth theorem generated, and the process takes only 20 ms.\n\nThus the declarative nature of \\alphatapsp is useful both for\ngenerating theorems and for producing proofs. Due to this flexibility,\n\\alphatapsp could become the core of a larger proof system.  Automated\ntheorem provers like \\leantapsp are limited in the complexity of the\nproblems they can solve, but given the ability to accept assistance\nfrom the user, more problems become tractable.\n\n%can solve more difficult problems.\n\n\n%\\footnotetext[7]{\\alphatap$\\!_G$ uses the unique name and preprocessor\n%  approach described in section 4.2.}\n\nAs an example, consider Pelletier Problem 47: Schubert's Steamroller.\nThis problem is difficult for tableau-based provers like \\leantapsp\nand \\alphatap, and neither can solve it\nautomatically~\\cite{beckert95leantap}.  Given some help, however,\n\\alphatapsp can prove the Steamroller. Our approach is to prove a\nseries of smaller lemmas that act as stepping stones toward the final\ntheorem; as each lemma is proved, it is added as an assumption in\nproving the remaining ones.  The proof process is automated---the user\nneed only specify which lemmas to prove and in what order. Using this\nstrategy, \\alphatapsp proves the Steamroller in about five seconds;\nthe proof requires twenty lemmas.\n\n\n\\alphatapsp thus offers an interesting compromise between large proof\nassistants and smaller automated provers. It achieves some of the\ncapabilities of a larger system while maintaining the lean deduction\nphilosophy introduced by \\leantap. Like an automated prover, it is\ncapable of proving simple theorems without user guidance. Confronted\nwith a more complex theorem, however, the user can provide a\npartially-instantiated proof; \\alphatapsp can then check the proof and\nfill in the trivial parts the user has left out.  Because \\alphatapsp\nis declarative, the user may even leave required axioms out of the\ntheorem to be proved and have the system derive them. This flexibility\ncomes at no extra cost to the user---the prover remains both concise\nand reasonably efficient.\n\n%% New\n\nThe flexibility of \\alphatapsp means that it could be made interactive\nthrough the addition of a read-eval-print loop and a simple proof\ntranslator between \\alphatap's proofs and a more human-readable\nformat. Since the proof given to \\alphatapsp may be partially\ninstantiated, such an interface would allow the user to conveniently\nguide \\alphatapsp in proving complex problems. With the addition of\nequality and the ability to perform single beta steps, this\nflexibility would become more interesting---in addition to reasoning\nabout programs and proving properties about them, \\alphatapsp would\ninstantiate non-ground programs during the proof process.\n\n\n\n\n\\section{Implementation}\\label{implementation}\n\nWe now present the implementation of \\alphatap. We begin with a\ntranslation of \\leantapsp from Prolog into \\alphakanren. We then show\nhow to eliminate the translation's impure features through a\ncombination of substitution and tagging.\n\n\n\\leantapsp implements both expansion and closing of the tableau. When\nthe prover encounters a conjunction, it uses its argument\n\\texttt{UnExp} as a stack (Figure~\\ref{fig:translation}): \\leantapsp\nexpands the first conjunct, pushing the second onto the stack for\nlater expansion. If the first conjunct cannot be refuted, the second\nis popped off the stack and expansion begins again.  When a\ndisjunction is encountered, the split in the tableau is reflected by\ntwo recursive calls. When a universal quantifier is encountered, the\nquantified variable is replaced by a new logic variable, and the\nformula is expanded.  The \\texttt{FreeV} argument is used to avoid\nreplacing the free variables of the formula.  \\leantapsp keeps a list\nof the literals it has encountered on the current branch of the\ntableau in the argument \\texttt{Lits}.  When a literal is encountered,\n\\leantapsp attempts to unify its negation with each literal in\n\\texttt{Lits}; if any unification succeeds, the branch is closed.\nOtherwise, the current literal is added to \\texttt{Lits} and expansion\ncontinues with a formula from \\texttt{UnExp}.\n\n\n\\subsection{Translation to \\alphakanren}\\label{translation}\n\nWhile \\alphakanrensp is similar to Prolog with the addition of nominal\nunification, \\alphakanrensp uses a variant of interleaving\ndepth-first search~\\cite{backtracking}, so the order of\n\\scheme|conde| or \\scheme|match-e| clauses in \\alphakanrensp is irrelevant. Because of\nProlog's depth-first search, \\leantapsp must use \\texttt{VarLim} to\nlimit its search depth; in \\alphakanren, \\texttt{VarLim} is not\nnecessary, and thus we omit it.\n\n\nIn Figure~\\ref{fig:translation} we present mK\\leantap, our translation\nof \\leantapsp into \\alphakanren; we label two clauses (\\onet, \\twot),\nsince we will modify these clauses later. To express Prolog's cuts,\nour definition uses \\scheme|match-a|.  The final two clauses of\n\\leantapsp do not contain Prolog cuts; in mK\\leantap, they are\ncombined into a single clause containing a \\scheme|conde|.  In place\nof \\leantap\\thinspace's recursive call to \\texttt{prove} to check the\nmembership of \\texttt{Lit} in \\texttt{Lits}, we call \\scheme|membero|,\nwhich performs a membership check using sound unification.\\footnote{We define \\scheme|membero| in Figure~\\ref{fig:ending}; \\scheme|membero| \\emph{must} use sound unification, and cannot use \\scheme|==-no-check|.}  % Prolog's \\texttt{copy\\_term/2} is\n% not built into \\alphakanren; this addition is available as part of the\n% mK\\leantapsp source code.\n\n\n%\\begin{figure}[ht]\n\\begin{figure}[H]\n%\\vspace{-.3in}\n\n\\begin{tabular}{l l}\n\n &\n\n\\begin{minipage}{2.3in}\n\\begin{schemedisplay}\n (define proveo\n   (lambda (fml unexp lits freev)\n     (match-a fml\n\\end{schemedisplay}\n\\end{minipage} \\\\\n\n\n\\begin{minipage}{2.3in}\n\\begin{verbatim}\nprove((E1,E2),UnExp,Lits,\n      FreeV,VarLim) :- !,\n  prove(E1,[E2|UnExp],Lits,\n        FreeV,VarLim).\n\\end{verbatim}\n\\end{minipage}\n &\n\\begin{minipage}{2in}\n\\begin{schemedisplay}\n      (`(and-tag ,e1 ,e2)\n        (proveo e1 `(,e2 . ,unexp) lits freev))\n\\end{schemedisplay}\n\\end{minipage}\n\\\\\n\n\\begin{minipage}{2in}\n\\begin{verbatim}\nprove((E1;E2),UnExp,Lits,\n      FreeV,VarLim) :- !,\n  prove(E1,UnExp,Lits,FreeV,VarLim),\n  prove(E2,UnExp,Lits,FreeV,Varlim).\n\\end{verbatim}\n\\end{minipage}\n &\n\\begin{minipage}{2in}\n\\vspace{1mm}\n\\begin{schemedisplay}\n      (`(or-tag ,e1 ,e2)\n        (proveo e1 unexp lits freev)\n        (proveo e2 unexp lits freev))\n\\end{schemedisplay}\n\\vspace{1mm}\n\\end{minipage}\n\\\\\n\n\\begin{minipage}{2in}\n\\begin{verbatim}\nprove(all(X,Fml),UnExp,Lits,\n      FreeV,VarLim) :- !,\n  \\+ length(FreeV,VarLim),\n  copy_term((X,Fml,FreeV),\n            (X1,Fml1,FreeV)),\n  append(UnExp,[all(X,Fml)],UnExp1),\n  prove(Fml1,UnExp1,Lits,\n        [X1|FreeV],VarLim).\n\\end{verbatim}\n\\end{minipage}\n &\n\\begin{minipage}{2in}\n\\begin{schemedisplay}\n     $\\onet$(`(forall ,x ,body)\n         (exist (x1 body1 unexp1)\n           (copy-termo `(,x ,body ,freev) \n                       `(,x1 ,body1 ,freev))\n           (appendo unexp `(,fml) unexp1)\n           (proveo body1 unexp1 lits \n                   `(,x1 . ,freev))))\n\\end{schemedisplay}\n\\end{minipage}\n\\\\\n\n\\begin{minipage}{2in}\n\\begin{verbatim}\nprove(Lit,_,[L|Lits],_,_) :-\n  (Lit = -Neg; -Lit = Neg) ->\n   (unify(Neg,L); \n    prove(Lit,[],Lits,_,_)).\n\\end{verbatim}\n\n\\end{minipage}\n &\n\\begin{minipage}{2in}\n\\begin{schemedisplay}\n     $\\twot$(fml\n         (conde\n           ((match-a `(,fml ,neg)\n              (`((not ,neg) ,neg))\n              (`(,fml (not ,fml))))\n            (membero neg lits))\n           \\end{schemedisplay}\n           \\end{minipage}\n           \\\\\n\n           \\begin{minipage}{2in}\n           \\begin{verbatim}\n           prove(Lit,[Next|UnExp],Lits,\n                    FreeV,VarLim) :-\n           prove(Next,UnExp,[Lit|Lits],\n                           FreeV,VarLim).\n           \\end{verbatim} \n           \\end{minipage}\n           &\n           \\begin{minipage}{2in}\n           \\begin{schemedisplay}\n        ((exist (next unexp1)\n           (== `(,next . ,unexp1) unexp)\n           (proveo next unexp1 `(,fml . ,lits) \n                   freev))))))))\n\\end{schemedisplay}\n\\end{minipage}\n\\\\\n\n\n\\end{tabular}\n\\caption{\\leantapsp and mK\\leantap\\thinspace: a translation from Prolog to \\alphakanren\n  \\label{fig:translation}}\n%\\vspace{-.3in}\n\\end{figure}\n\n\n\\subsection{Eliminating \\copytermo}\\label{copytermo}\n\\enlargethispage{1\\baselineskip} %\n\nSince \\scheme|copy-termo| is an impure operator, its use makes\n\\scheme|proveo| non-declarative: reordering the goals in the prover\ncan result in different behavior. For example, moving the call to\n\\scheme|copy-termo| after the call to \\scheme|proveo| causes the\nprover to diverge when given any universally quantified formula. To\nmake our prover declarative, we must eliminate the use of\n\\scheme|copy-termo|.\n\nTagging the logic variables that represent universally quantified\nvariables allows the use of a declarative technique that creates two\npristine copies of the original term: one copy may be expanded and the\nother saved for later copying.  Unfortunately, this copying examines\nthe entire body of each quantified formula and instantiates the\noriginal term to a potentially invalid formula.\n\nAnother approach is to represent quantified variables with symbols or\nstrings. When a new instantiation is needed, a new variable name can\nbe generated, and the new name can be substituted for the old without\naffecting the original formula. This solution does not destroy the\nprover's input, but it is difficult to ensure that the provided data\nis in the correct form declaratively: if the formula to be proved is\nnon-ground, then the prover must generate unique names.  If the\nformula \\textit{does} contain these names, however, the prover must\n\\textit{not} generate new ones. This problem can be solved with a\ndeclarative preprocessor that expects a logical formula\n\\textit{without} names and puts them in place. If the preprocessor is\npassed a non-ground formula, it instantiates the formula to the\ncorrect form. %We have implemented this strategy in a Prolog prover we\n%call \\alphatap$\\!_G$; \nThe requirement of a preprocessor, however,\nmeans the prover itself is not declarative.\n\nWe use nominal logic to solve the \\scheme|copy-termo| problem.\nNominal logic is a good fit for this problem, as it is designed to\nhandle the complexities of dealing with names and binders\ndeclaratively.\n%Using\n%noms to represent universally quantified variables and the\n%\\scheme|tie| operator to represent the $\\forall$ binder allows us to\n%avoid the use of logic variables to represent quantified variables.\nSince noms represent unique names, we achieve the benefits of the\nsymbol or string approach without the use of a preprocessor. We can\ngenerate unique names each time we encounter a universally quantified\nformula, and use nominal unification to perform the renaming of the\nquantified variable. If the original formula is uninstantiated, our\nnewly-generated name is unique and is put in place correctly; we no\nlonger need a preprocessor to perform this function.\n\nUsing the tools of nominal logic, we can modify mK\\leantapsp to\nrepresent universally quantified variables using noms and to perform\nsubstitution instead of copying.  When the prover reaches a literal,\nhowever, it must replace each nom with a logic variable, so that\nunification may successfully compare literals. To accomplish this, we\nassociate a logic variable with each unique nom, and replace every nom\nwith its associated variable before comparing literals. These\nvariables are generated each time the prover expands a quantified\nformula.\n\nTo implement this strategy, we change our representation of formulas\nslightly. Instead of representing $\\forall x. F(x)$ as\n\\mbox{\\schemeresult|`(forall Xvar (f Xvar))|}, we use a nom wrapped in\na \\scheme|var-tag| tag to represent a variable reference, and the\nterm constructor \\scheme|tie| to represent the $\\forall$ binder:\n\\mbox{\\schemeresult|`(forall (tie anom (f (var-tag anom))))|}, where $a$ is\na nom.  The \\scheme|var-tag| tag allows us to distinguish noms\nrepresenting variables from other formulas. We now write a relation\n\\scheme|subst-lito| to perform substitution of logic variables for\ntagged noms in a literal, and we modify the literal case of\n\\scheme|proveo| to use it. We also replace the clause handling\n\\schemeresult|forall| formulas and define \\scheme|lookupo|. The two\nclauses of \\scheme|lookupo| overlap, but since each mapping in the\nenvironment is from a unique nom to a logic variable, a particular nom\nwill never appear twice.\n\nWe present the changes needed to eliminate \\scheme|copy-termo| from\nmK\\leantapsp in Figure~\\ref{fig:changes}. Instead of copying the body\nof each universally quantified formula, we generate a logic variable\n\\scheme|x| and add an association between the nom representing the\nquantified variable and \\scheme|x| to the current environment. When we\nprepare to close a branch of the tableau, we call \\scheme|subst-lito|,\nreplacing the noms in the current literal with their associated logic\nvariables.\n\n\n\\begin{figure}[H]\n\n\\noindent \\begin{tabular}{l l}\n\\begin{minipage}{2.5in}\n\\small\n\\begin{schemedisplay}\n$\\onet$(`(forall (tie-tag ,@a ,body))\n   (exist (x unexp1)\n     (appendo unexp `(,fml) unexp1)\n     (proveo body unexp1 lits\n             `((,a . ,x) . ,env))))\n\n$\\twot$(fml\n  (exist (lit)\n    (subst-lito fml env lit)\n    (conde\n      ((match-a `(,lit ,neg)\n         (`((not ,neg) ,neg))\n         (`(,lit (not ,lit))))\n       (membero neg lits))\n      ((exist (next unexp1)\n         (== `(,next . ,unexp1) unexp)\n         (proveo next unexp1 `(,lit . ,lits) \n                 env))))))\n\\end{schemedisplay}\n\n\\vspace{.1cm}\n\\end{minipage}\n&\n\n\n\\begin{minipage}{1.2in}\n\\small\n%\\schemeinput{code/lookupo}\n\\begin{schemedisplay}\n(define lookupo\n  (lambda (a env out)\n    (match-e env\n      (`((,a . ,out) . ,rest))\n      (`(,first . ,rest)\n       (lookupo a rest out)))))\n\\end{schemedisplay}\n\n\\begin{schemedisplay}\n(define subst-lito\n  (lambda (fml env out)\n    (match-a `(,fml ,out)\n      (`((var-tag ,a) ,out)\n       (lookupo a env out))\n      (`((,e1 . ,e2) (,r1 . ,r2))\n       (subst-lito e1 env r1)\n       (subst-lito e2 env r2))\n      (`(,fml ,fml)))))\n\\end{schemedisplay}\n\n\\end{minipage}\n\n\\end{tabular}\n\n\\caption{Changes to mK\\leantapsp to eliminate \\protect\\scheme|copy-termo|\n  \\label{fig:changes}}\n%\\vspace{-.2in}\n\\end{figure}\n\nThe original \\mbox{\\texttt{copy\\_term/2}} approach used by \\leantapsp and\nmK\\leantapsp avoids replacing free variables by copying the list\n\\scheme|`(,x ,body ,freev)|. The copied version is unified with the list\n\\scheme|`(x1 body1 ,freev)|, so that \\textit{only} the variable\n\\scheme|x| will be replaced by a new logic variable---the free\nvariables will be copied, but those copies will be unified with the\noriginal variables afterwards. Since our substitution strategy does\nnot affect free variables, the \\scheme|freev| argument is no longer\nneeded, and so we have eliminated it.\n\n\n\\subsection{Eliminating \\matchasymbol}\\label{matcha}\n\nBoth \\scheme|proveo| and \\scheme|subst-lito| use \\scheme|match-a|\nbecause the clauses that recognize literals overlap with the other\nclauses. To solve this problem, we have designed a tagging scheme that\nensures that the clauses of our substitution and \\scheme|proveo|\nrelations do not overlap.  To this end, we tag both positive and\nnegative literals, applications, and variables. Constants are\nrepresented by applications of zero arguments. Our prover thus accepts\nformulas of the following form:\n\n\n% \\begin{center}\n%   \\begin{tabular}{lcl}\n%     $<$Fml$>$ & $\\rightarrow$ & $($\\textsf{or} $<$Fml$>$ $<$Fml$>)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{and} $<$Fml$>$ $<$Fml$>)$ \n%  \\\\ & $|$ & \n% $($\\textsf{forall} $<$nom$>$ $<$Fml$>)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{lit} $<$Lit$>)$ \n% \\\\\n%     $<$Lit$>$ & $\\rightarrow$ & $($\\textsf{pos} $<$Term$>)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{neg} $<$Term$>)$ \n%  \\\\ \n% $<$Term$>$ & $\\rightarrow$ & $($\\textsf{sym} $<$symbol$>)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{var} $<$nom$>)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{app} $<$symbol$>$ $<$Term$>$*$)$ \\\\\n%   \\end{tabular}\n% \\end{center}\n\n% \\begin{center}\n%   \\begin{tabular}{lcl}\n%     Fml & $\\rightarrow$ & $($\\textsf{and} Fml Fml$)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{or} Fml Fml$)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{forall} $($\\scheme|tie| nom Fml$))$ \n% % \\\\ & $|$ & \n% $|$ Lit \n% \\\\\n%     Lit & $\\rightarrow$ & $($\\textsf{pos} Term$)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{neg} Term$)$ \n%  \\\\ \n% Term & $\\rightarrow$ & %$($\\textsf{sym} symbol$)$ \n% % \\\\ & $|$ & \n% %$|$ \n% $($\\textsf{var} nom$)$ \n% % \\\\ & $|$ & \n% $|$ $($\\textsf{app} symbol Term*$)$ \\\\\n%   \\end{tabular}\n% \\end{center}\n\n%\\vspace{-.2cm}\n\n\\begin{center}\n  \\begin{tabular}{lcl}\n    \\textit{Fml} & $\\rightarrow$ & $($\\textsf{and}  \\textit{Fml}  \\textit{Fml}$)$ \n$|$ $($\\textsf{or}  \\textit{Fml} \\textit{Fml}$)$ \n$|$ $($\\textsf{forall} $($\\scheme|tie| \\textit{Nom} \\textit{Fml}$))$ \n$|$ \\textit{Lit}\n\\\\\n    \\textit{Lit} & $\\rightarrow$ & $($\\textsf{pos} \\textit{Term}$)$ \n$|$ $($\\textsf{neg} \\textit{Term}$)$ \n \\\\ \n\\textit{Term} & $\\rightarrow$ &\n$($\\textsf{var} \\textit{Nom}$)$ \n$|$ $($\\textsf{app} \\textit{Symbol} \\textit{Term}*$)$ \\\\\n  \\end{tabular}\n\\end{center}\n\n%\\vspace{-.2cm}\n\nThis scheme has been chosen carefully to allow unification to compare\nliterals. In particular, the tags on variables \\textit{must} be\ndiscarded before literals are compared.  Consider the two non-ground\nliterals \\mbox{\\schemeresult|`(not (f Xvar))|} and\n\\mbox{\\schemeresult|`(f (p Yvar))|}.  These literals are complementary:\nthe negation of one unifies with the other, associating $x$ with\n\\mbox{\\schemeresult|`(p Yvar)|}. When we apply our tagging scheme,\nhowever, these literals become \\mbox{\\schemeresult|`(neg (app f (var-tag Xvar)))|} and \\mbox{\\schemeresult|`(pos (app f (app p (var-tag Yvar))))|}, respectively, and are no longer complementary: their\nsubexpressions \\mbox{\\schemeresult|`(var-tag Xvar)|} and\n\\mbox{\\schemeresult|`(app p (var-tag Yvar))|} do not unify. To avoid this\nproblem, our substitution relation discards the \\textsf{var} tag when\nit replaces noms with logic variables.\n\n\\begin{figure}[H]\n%\\vspace{-.2in}\n\\hspace{-.1in}\n\\begin{tabular}{l l}\n\\begin{minipage}{1.8in}\n%\\schemeinput{code/alphatapleft}\n\\begin{schemedisplay}\n(define proveo\n  (lambda (fml unexp lits env proof)\n    (match-e `(,fml ,proof)\n      (`((and-tag ,e1 ,e2) (conj . ,prf))\n       (proveo e1 `(,e2 . ,unexp)\n               lits env prf))\n      (`((or-tag ,e1 ,e2) (split ,prf1 ,prf2))\n       (proveo e1 unexp lits env prf1)\n       (proveo e2 unexp lits env prf2))\n      (`((forall (tie-tag ,@a ,body)) (univ . ,prf))\n       (exist (x unexp1)\n         (appendo unexp `(,fml) unexp1)\n         (proveo body unexp1 lits\n                 `((,a . ,x) . ,env) prf)))\n      (`(,fml ,proof)\n       (exist (lit)\n         (subst-lito fml env lit)         \n         (conde\n           ((== `(close) proof)\n            (match-e `(,lit ,neg)\n              (`((pos ,tm) (neg ,tm)))\n              (`((neg ,tm) (pos ,tm))))              \n            (membero neg lits))\n           ((exist (next unexp1 prf)\n              (== `(,next . ,unexp1) unexp)\n              (== `(savefml . ,prf) proof)\n              (proveo next unexp1 `(,lit . ,lits)\n                      env prf)))))))))\n\\end{schemedisplay}\n%\\vspace{1.3cm}\n\\end{minipage}\n\n& \n\n\\hspace{-0.3in}\n\\begin{minipage}{1.8in}\n%\\schemeinput{code/alphatapright}\n\\begin{schemedisplay}\n(define appendo\n  (lambda-e (ls s out)\n    (`(() ,s ,s))\n    (`((,a . ,d) ,s (,a . ,r))\n     (appendo d s r))))\n\n(define subst-lito\n  (lambda-e (fml env out)\n    (`((pos ,l) ,env (pos ,r))\n     (subst-termo l env r))\n    (`((neg ,l) ,env (neg ,r))\n     (subst-termo l env r))))\n\n(define subst-termo\n  (lambda-e (fml env out)\n    (`((var-tag ,a) ,env ,out)\n     (lookupo a env out))\n    (`((app ,f . ,d) ,env (app ,f . ,r))\n     (subst-term* d env r))))\n\n(define subst-term*\n  (lambda-e (tm* env out)\n    (`(() __ ()))\n    (`((,e1 . ,e2) ,env (,r1 . ,r2))\n     (subst-termo e1 env r1)\n     (subst-term* e2 env r2))))\n\n(define membero\n  (lambda (x ls)\n    (exist (a d)\n      (== `(,a . ,d) ls)\n      (conde\n        ((== a x))\n        ((membero x d))))))\n\\end{schemedisplay}\n%\\vspace{1.0cm}\n\\end{minipage}\n\n\\end{tabular}\n\\caption{Final definition of \\alphatap\n  \\label{fig:ending}}\n%\\vspace{-.3in}\n\\end{figure}\n\nGiven our new tagging scheme, we can easily rewrite our substitution\nrelation without the use of \\scheme|match-a|. We simply follow the\nproduction rules of the grammar, defining a relation to recognize\neach.\n\nFinally, we modify \\scheme|proveo| to take advantage of the same tags.\nWe also add a \\scheme|proof| argument to \\scheme|proveo|.  We call\nthis version of the prover \\alphatap, and present its definition in\nFigure~\\ref{fig:ending}. It is declarative, since we have eliminated\nthe use of \\scheme|copy-termo| and every use of \\scheme|match-a|. In\naddition to being a sound and complete theorem prover for first-order\nlogic, \\alphatapsp can now generate valid first-order theorems.\n\n\n\n\n\n\n\\section{Performance}\\label{performance}\n\\enlargethispage{1\\baselineskip} %\n\nLike the original \\leantap, \\alphatapsp can prove many theorems in\nfirst-order logic. Because it is declarative, \\alphatapsp is generally\nslower at proving ground theorems than mK\\leantap, which is slower\nthan the original \\leantap. Figure~\\ref{fig:performance} presents a\nsummary of \\alphatap's performance on the first 46 of Pelletier's 75\nproblems~\\cite{pelletier1986sfp}, showing it to be roughly twice as\nslow as mK\\leantap.\n\nThese performance numbers suggest that while there is a penalty to be\npaid for declarativeness, it is not so severe as to cripple the\nprover. The advantage mK\\leantapsp enjoys over the original \\leantapsp\nin Problem 34 is due to \\alphakanren's interleaving search strategy;\nas the result for mK\\leantapsp shows, the original \\leantapsp is faster\nthan \\alphatapsp for any given search strategy.\n\nMany automated provers now use the TPTP problem\nlibrary~\\cite{stucliffe1994tpl} to assess performance. Even though it\nis faster than \\alphatap, \\leantapsp solves few of the TPTP\nproblems. The Pelletier Problems, on the other hand, fall into the\nclass of theorems \\leantapsp was designed to prove, and so we feel\nthey provide a better set of tests for the comparison between\n\\leantapsp and \\alphatap.\n\n\\begin{figure}[h]\n%\\vspace{-.2in}\n\\begin{centering}\n\\begin{tabular}{l l}\n\n\\hspace{-.1in}\n\\begin{minipage}{2.7in}\n\\begin{tabular}{| r | c | c | c | } %c |\n  \\hline \n  \\thinspace \\thinspace \\# & \\thinspace \\leantap  \\thinspace &\n  mK\\leantap \\thinspace & \\thinspace \\alphatap\n  \\thinspace %& \\thinspace \\alphatap$\\!_G$\\footnotemark[5]$^,$\\footnotemark[7]\n  \\\\\n  \\hline\n1 & 0.1 & 0.7 & 2.0 \\\\ \n2 & 0.0 & 0.1 & 0.3 \\\\ \n3 & 0.0 & 0.2 & 0.5 \\\\ \n4 & 0.0 & 1.0 & 1.7 \\\\ \n5 & 0.1 & 1.2 & 2.5 \\\\ \n6 & 0.0 & 0.1 & 0.2 \\\\ \n7 & 0.0 & 0.1 & 0.2 \\\\ \n8 & 0.0 & 0.3 & 0.8 \\\\ \n9 & 0.1 & 4.3 & 9.7 \\\\ \n10 & 0.3 & 5.5 & 10.2 \\\\ \n11 & 0.0 & 0.3 & 0.6 \\\\ \n12 & 0.6 & 17.7 & 31.9 \\\\ \n13 & 0.1 & 3.7 & 8.2 \\\\ \n14 & 0.1 & 4.2 & 9.7 \\\\ \n15 & 0.0 & 0.8 & 1.9 \\\\ \n16 & 0.0 & 0.2 & 0.6 \\\\ \n17 & 1.1 & 9.2 & 18.1 \\\\ \n18 & 0.1 & 0.5 & 1.2 \\\\ \n19 & 0.3 & 15.1 & 33.5 \\\\ \n20 & 0.5 & 8.1 & 12.7 \\\\ \n21 & 0.4 & 22.1 & 38.7 \\\\ \n22 & 0.1 & 3.4 & 6.4 \\\\ \n23 & 0.1 & 2.5 & 5.4 \\\\ \n\n  \\hline\n\\end{tabular}\n\n\\end{minipage}\n\n&\n\n\\begin{minipage}{2.5in}\n\\begin{tabular}{| r | c | c | c |} %c |\n  \\hline \n  \\# & \\thinspace \\leantap  \\thinspace &\n  mK\\leantap \\thinspace & \\thinspace \\alphatap\n  \\thinspace %& \\thinspace \\alphatap$\\!_G$\\footnotemark[5]$^,$\\footnotemark[7]  \n\\\\\n  \\hline\n24 & 1.7 & 31.9 & 60.3 \\\\ \n25 & 0.2 & 7.5 & 14.1 \\\\ \n26 & 0.8 & 130.9 & 187.5 \\\\ \n27 & 2.3 & 40.4 & 79.3 \\\\ \n28 & 0.3 & 19.1 & 29.6 \\\\ \n29 & 0.1 & 27.9 & 57.0 \\\\ \n30 & 0.1 & 4.2 & 9.6 \\\\ \n31 & 0.3 & 13.2 & 23.1 \\\\ \n32 & 0.2 & 23.9 & 42.4 \\\\ \n33 & 0.1 & 15.9 & 39.2 \\\\ \n34 & 199129.0  & 7272.9 & 8493.5 \\\\ \n35 & 0.1 & 0.5 & 1.1 \\\\ \n36 & 0.2 & 6.7 & 12.4 \\\\ \n37 & 0.8 & 123.3 & 169.2 \\\\ \n38 & 8.9 & 4228.8 & 8363.8 \\\\ \n39 & 0.0 & 1.1 & 2.8 \\\\ \n40 & 0.2 & 8.1 & 19.2 \\\\ \n41 & 0.1 & 6.9 & 17.0 \\\\ \n42 & 0.4 & 15.0 & 32.1 \\\\ \n43 & 43.2 & 668.4 & 1509.6 \\\\ \n44 & 0.3 & 15.1 & 35.7 \\\\ \n45 & 3.4 & 145.3 & 239.7 \\\\ \n46 & 7.7 & 505.5 & 931.2 \\\\ \n\n  \\hline\n\\end{tabular}\n\\end{minipage}\n\\end{tabular}\n\n\\caption{Performance of \\leantap, mK\\leantap, and \\alphatapsp on the\n  first 46 Pelletier Problems. \n  All times are in milliseconds, averaged over 100 trials.\n  All tests were run \\mbox{under} Debian\n  Linux on an IBM Thinkpad \n  X40 with a 1.1GHz Intel Pentium-M processor and 768MB RAM. \n  \\leantapsp tests were run under SWI-Prolog 5.6.55;\n  mK\\leantapsp and \\alphatapsp tests were run under Ikarus Scheme\n  0.0.3+.\n  \\label{fig:performance}}\n\\end{centering}\n%\\vspace{-.2in}\n\n\\end{figure}\n\n\n\\section{Applicability of These Techniques}\n\nTo avoid the use of \\scheme|copy-termo|, we have represented\nuniversally quantified variables with noms rather than logic\nvariables, allowing us to perform substitution instead of copying.  To\neliminate \\scheme|match-a|, we have enhanced the tagging scheme for\nrepresenting formulas.\n\nBoth of these transformations are broadly applicable. When\n\\scheme|match-a| is used to handle overlapping clauses, a carefully\ncrafted tagging scheme can often be used to eliminate\noverlapping. When terms must be copied, substitution can often be used\ninstead of \\scheme|copy-termo|---in the case of \\alphatap, we use a\ncombination of nominal unification and substitution.\n", "meta": {"hexsha": "fd63ff8d2dfc5cd6a9b17f6fa86bd769dcf63ad8", "size": 40049, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alphatap.tex", "max_stars_repo_name": "holtzermann17/dissertation-single-spaced", "max_stars_repo_head_hexsha": "aca0e56a33916596c98709308342d9ccabd4718b", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2015-01-11T21:22:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-10T12:49:11.000Z", "max_issues_repo_path": "alphatap.tex", "max_issues_repo_name": "holtzermann17/dissertation-single-spaced", "max_issues_repo_head_hexsha": "aca0e56a33916596c98709308342d9ccabd4718b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-08-08T18:10:18.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-09T02:33:25.000Z", "max_forks_repo_path": "alphatap.tex", "max_forks_repo_name": "holtzermann17/dissertation-single-spaced", "max_forks_repo_head_hexsha": "aca0e56a33916596c98709308342d9ccabd4718b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-07-29T13:58:01.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-14T05:01:31.000Z", "avg_line_length": 38.3978906999, "max_line_length": 249, "alphanum_fraction": 0.7102049989, "num_tokens": 12045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.42063597213455817}}
{"text": "%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[english]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage{textcomp}\n\\usepackage{amsmath}\n\\usepackage{esint}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n%% Because html converters don't know tabularnewline\n\\providecommand{\\tabularnewline}{\\\\}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{babel}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\n\\title{Understanding the Rational Approximation of the Exponential Integrator\n(REXI)}\n\n\n\\author{Martin Schreiber <M.Schreiber@exeter.ac.uk>\\\\\n Pedro S. Peixoto <pedrosp@ime.usp.br>}\n\n\\maketitle\nThis document serves as the basis for implementing the Rational approximation\nof the EXponential Integrator (REXI). Here, we purely focus on the\nlinear part of the shallow-water equations (SWE) and show the different\nsteps to approximate solving this linear part with an exponential\nintegrator. This paper mainly summarises previous work on REXI.\n\n\n\\section{Problem formulation}\n\nWe use linearised shallow water equations (SWE) with respect to a\nrest state with mean water depth of $\\eta_{0}$ and defined for perturbations\nof height $\\eta$ (see \\cite{Schreiber:Formulations of the shallow-water equations}).\nThe linear operator ($L$) may be written as\n\n\\[\nL(U):=\\left(\\begin{array}{ccc}\n0 & -\\eta_{0}\\partial_{x} & -\\eta_{0}\\partial_{y}\\\\\n-g\\partial_{x} & 0 & f\\\\\n-g\\partial_{y} & -f & 0\n\\end{array}\\right)U\n\\]\nwhere $U:=(\\eta,u,v)^{T}$. Here, we neglect all non-linear terms\nand consider $f$ constant (f-plane approximation). The time evolution\nof the PDE, with the subscript $t$ denoting the derivative in time,\nis given by\n\n\\[\nU_{t}=L(U).\n\\]\nIt is further worth noting, that this system describes an oscillatory\nsystem (2D wave equation), hence the operator $L$ is hyperbolic and\nhas imaginary eigenvalues. Linear initial value differential problems\nare well known to be solvable with exponential integrators for arbitrary\ntime step sizes via \n\\[\nU(t)=e^{Lt}U(0).\n\\]\nsee e.g. \\cite{Moler:Nineteen Dubious Ways to Compute the Exponential of a Matrix}.\nHowever, this is typically quite expensive to compute and analytic\nsolutions only exist for some simplified system of equations, see\ne.g. \\cite{Schreiber:Formulations of the shallow-water equations}\nfor f-plane shallow-water equations. These exponential integrators\ncan be approximated with rational functions and this paper is on giving\ninsight into this approximation.\n\n\n\\section{1D rational approximation}\n\nTerry et al. \\cite{Terry:High-order time-parallel approximation of evolution operators}\ndeveloped a rational approximation of the exponential integrator.\nFirst, we like to get more insight into it with a one-dimensional\nformulation before applying REXI to a rational approximation of a\nlinear operator. Our main target is to find an approximation of an\noperator with a \\emph{complex exponential shape}, in our case $e^{ix}$,\nwhich (in one-dimension) is given as a function $f(x)$. We will end\nup in an approximation given by the following rational approximation:\n\n\\[\ne^{ix}\\approx\\sum_{n=-N}^{N}Re\\left(\\frac{\\beta_{n}}{ix+\\alpha_{n}}\\right)\n\\]\nwith complex coefficients $\\alpha_{n}$ and $\\beta_{n}$. We point\nout that the coefficients $\\alpha_{n}$ will always have non zero\nreal part, so no singularity occurs with the rational function.\n\n\n\\subsection{Step A: Approximation of solution space}\n\nFirst, we assume that we can use Gaussian curves as basis functions\nfor our approximation. So first we find an approximation of one of\nour underlying Gaussian basis function\n\n\\[\n\\psi_{h}(x):=(4\\pi)^{-\\frac{1}{2}}e^{-x^{2}/(4h^{2})}\n\\]\n\n\nIn this formulation, $h$ can be interpreted as the horizontal ``stretching''\nof the basis function. Note the similarities to the Gaussian distribution,\nbut by dropping certain parts of the vertical scaling as it is required\nfor probability distributions. We can now approximate our function\n$f(x)$ with a superposition of basis functions $\\psi_{h}(x)$ by\n\n\\[\nf(x)\\approx\\sum_{m=-M}^{M}b_{m}\\psi_{h}(x+mh)\n\\]\nwith $M$ controlling the interval of approximation (\\textasciitilde{}size\nof ``domain of interest'') and $h$ will be related to the accuracy\nof integration (\\textasciitilde{}resolution in ``domain of interest'').\nWe choose $h$ small enough so that the support of the Fourier transform\nof $f$ is mainly localised within $[-1/(2h),1/(2h)]$, i.e. almost\nzero outside this interval. $M$ is chosen such that the approximation\nwill be adequate in the interval $|x|<Mh$.\n\nTo compute the coefficients $b_{m}$, we rewrite the previous equation\nin Fourier space with \n\\[\n\\frac{\\hat{f}(\\xi)}{\\hat{\\psi_{h}}(\\xi)}=\\sum_{m=\\infty}^{\\infty}b_{m}e^{2\\pi imh\\xi},\n\\]\nwhere the $\\hat{\\cdot}$ symbols indicate the Fourier transforms of\nthe respective functions. The $b_{m}$ are now the Fourier coefficients\nof the series for the function $\\frac{\\hat{f}(\\xi)}{\\hat{\\psi_{h}}(\\xi)}$\nand can be calculated as (see \\cite{Terry:High-order time-parallel approximation of evolution operators},\npage 11), \n\\[\nb_{m}=h\\intop_{-\\frac{1}{2h}}^{\\frac{1}{2h}}e^{-2\\pi imh\\xi}\\frac{\\hat{f}(\\xi)}{\\hat{\\psi_{h}}(\\xi)}d\\xi,\n\\]\nfor $m$ integer and $1/h$ defines the periodicity of the trigonometric\nbasis function.\n\nSince we are interested in approximating $f(x)=e^{ix}$, we can simplify\nthe equation by using the response in frequency space $\\hat{f}(\\xi)=\\delta(\\xi-\\frac{1}{2\\pi})$,\nwhere here $\\delta$ is the Dirac distribution, and\n\n\\[\nb_{m}=h\\,e^{-imh}\\hat{\\psi_{h}}\\left(\\frac{1}{2\\pi}\\right)^{-1}.\n\\]\nThe Fourier transform of the Gaussian function is well known and given\nby\n\n\\begin{eqnarray*}\n\\hat{\\psi_{h}}(\\xi) & = & \\intop_{-\\infty}^{\\infty}\\frac{1}{\\sqrt{4\\pi}}e^{-\\left(\\frac{x}{2h}\\right)^{2}}e^{-2\\pi ix\\xi}dx\\\\\n & = & \\frac{1}{\\sqrt{4\\pi}}\\intop_{-\\infty}^{\\infty}e^{-\\left(\\left(\\frac{x}{2h}\\right)^{2}+2\\pi ix\\xi+(2h\\pi i\\xi)^{2}-(2h\\pi i\\xi)^{2}\\right)}dx\\\\\n & = & \\frac{1}{\\sqrt{4\\pi}}e^{-(2h\\pi\\xi)^{2}}\\intop_{-\\infty}^{\\infty}e^{-\\left(\\frac{x}{2h}+2h\\pi i\\xi\\right)^{2}}dx\\\\\n & = & \\frac{1}{\\sqrt{4\\pi}}e^{-(2h\\pi\\xi)^{2}}\\intop_{-\\infty}^{\\infty}e^{-\\left(\\frac{x}{2h}\\right)^{2}}dx\\\\\n & = & he^{-(2h\\pi\\xi)^{2}}\n\\end{eqnarray*}\nwhere we used that $\\intop_{-\\infty}^{\\infty}e^{-\\left(\\frac{x}{2h}\\right)^{2}}dx=h\\,\\sqrt{4\\pi}$\nand completed squares in the exponential term. For the case $\\xi=\\frac{1}{2\\pi}$,\nwe get\n\n\\[\n\\hat{\\psi}_{h}\\left(\\frac{1}{2\\pi}\\right)=h\\,e^{-h^{2}}.\n\\]\nFinally, one can obtain the equation\n\n\\[\nb_{m}=h\\,e^{-imh}\\frac{1}{h\\,e^{-h^{2}}}=e^{-imh}e^{h^{2}}\n\\]\nto compute the coefficients $b_{m}$ for $f(x)=e^{ix}$.\n\n\n\\subsection{Step B: Approximation of basis function}\n\nThe second step is the approximation of the basis function $\\psi_{h}(x)$\nitself with a rational approximation, see \\cite{Damle:Near optimal rational approximations of large data sets}.\nOur basis function is given by\n\n\\[\n\\psi_{h}(x):=(4\\pi)^{-\\frac{1}{2}}e^{-x^{2}/(4h^{2})}\n\\]\nand a close-to-optimal approximation of $\\psi_{1}(x)$ with a sum\nof rational functions is given by\n\n\\[\n\\psi_{1}(x)\\approx Re\\left(\\sum_{l=-K}^{K}\\frac{a_{l}}{ix+(\\mu+i\\,l)}\\right)\n\\]\nwith the $\\mu$ and $a_{l}$ given in \\cite{Damle:Near optimal rational approximations of large data sets},\nTable 1. We can generalise this approximation to arbitrary chosen\n$h$ via \n\\[\n\\psi_{h}(x)\\approx Re\\left(\\sum_{l=-K}^{K}\\frac{a_{l}}{i\\frac{x}{h}+(\\mu+i\\,l)}\\right).\n\\]\nThe theory of how these coefficients are calculated are in \\cite{Damle:Near optimal rational approximations of large data sets}\nand will not be described here. Therefore, we assume that the coefficients\n$a_{l}$ are given.\n\n\n\\subsection{Step C: Approximation of the approximation}\n\nWe then combine the approximation (B) into the approximation (A),\nyielding the approximation $\\tilde{f}$ for $f$ given by \n\\[\n\\tilde{f}(x)=\\sum_{m=-M}^{M}b_{m}\\psi_{h}(x+mh)=\\sum_{m=-M}^{M}b_{m}Re\\left(\\sum_{l=-K}^{K}\\frac{a_{l}}{i\\frac{x+mh}{h}+(\\mu+i\\,l)}\\right)\n\\]\n\n\n\\[\n=\\sum_{m=-M}^{M}b_{m}\\sum_{k=-K}^{K}Re\\left(\\frac{ha_{l}}{ix+h(\\mu+i(m+l))}\\right).\n\\]\n\n\nWe further like to simplify this equation and we observe, that for\n$n:=m+k$, the denominator is equal. We can hence express parts of\nthe denomiator in terms of $n:=m+k$ by\n\n\\begin{equation}\n\\alpha_{n}:=s(\\mu+in).\\label{eq:alpha}\n\\end{equation}\nNow, we merge the $b_{m}$ and $a_{l}$ coefficients and first have\na look at the $b_{m}$ which is complex valued. We observe the following\nproperty: Assuming that we want to compute the real value of $f(x)$,\nonly the real value of $b_{m}$ has to be merged with the sum, since\nthe imaginary component would be dropped afterwards. This allows us\nto move the $Re(b_{m})$ values inside the $\\sum_{K}$:\n\n\\[\nRe(f(x)):=Re\\left(\\sum_{m=-M}^{M}\\,\\,\\sum_{k=-K}^{K}\\frac{Re(b_{m})\\,ha_{l}}{ix+h(\\mu+i(m+k))}\\right).\n\\]\nNow we can collect all nominators with equivalent denominator (if\n$n=m+k$ and by using $\\delta$ as the Kronecker delta), yielding\n\n\t\n\\begin{equation}\n\\beta_{n}^{Re}:=h\\sum_{m=-M\\,}^{M}\\sum_{k=-K}^{K}Re(b_{m})ha_{l}\\delta(n,\\,m+k)\\label{eq:beta_re}\n\\end{equation}\nfor real values $f(x)$ and\n\n\\begin{equation}\n\\beta_{n}^{Im}:=h\\sum_{m=-M\\,}^{M}\\sum_{k=-K}^{K}Im(b_{m})a_{l}\\delta(n,\\,m+k)\\label{eq:beta_im}\n\\end{equation}\nfor complex values of $f(x)$. Note, that the complexity of this operation\nis $O(N\\,K)$, which is negligible for small $N$ and $K$. This can\nbe optimized by using $L_{1}=max(-K,n-M)$ and $L_{2}=min(K,n+M)$\n(see \\cite{Terry:High-order time-parallel approximation of evolution operators})\nand we can compute $\\beta_{n}^{Re}$ with\n\n\\begin{equation}\n\\beta_{n}^{Re}:=h\\sum_{k=L_{1}}^{L_{2}}Re(b_{n-k})a_{k},\\label{eq:beta_re_fast}\n\\end{equation}\nand $\\beta_{n}^{Im}$ correspondingly.\n\nFinally, we get the REXI approximation\n\n\\[\ne^{ix}\\approx\\sum_{n=-N}^{N}Re\\left(\\frac{\\beta_{n}^{Re}}{ix+\\alpha_{n}}\\right)+i\\,Re\\left(\\frac{\\beta_{n}^{Im}}{ix+\\alpha_{n}}\\right).\n\\]\n\n\n\n\\subsection{Example coefficents}\n\nFor a better understanding and discussion of the poles, we provide\nsome explanatory coefficients for $\\alpha_{n}$ and $\\beta_{n}^{Re}$\ncomputed with $M:=2$ and $h:=0.2$:\n\n{\\scriptsize{}}%\n\\begin{tabular}{|c|c|c|}\n\\hline \n$n$ & {\\scriptsize{}$\\alpha_{n}$} & {\\scriptsize{}$\\beta_{n}$}\\tabularnewline\n\\hline \n\\hline \n{\\scriptsize{}-13} & {\\scriptsize{}(-0.863064302175, -2.6)} & {\\scriptsize{}(-2.0794560075645e-08,5.312368394177e-09)}\\tabularnewline\n\\hline \n{\\scriptsize{}-12} & {\\scriptsize{}(-0.863064302175, -2.4)} & {\\scriptsize{}(-1.8562925598646e-08,-1.6892470811809e-07)}\\tabularnewline\n\\hline \n{\\scriptsize{}-11} & {\\scriptsize{}(-0.863064302175, -2.2)} & {\\scriptsize{}(6.8570271350932e-07,-4.4377515257134e-08)}\\tabularnewline\n\\hline \n{\\scriptsize{}-10} & {\\scriptsize{}(-0.863064302175, -2)} & {\\scriptsize{}(1.9470768200785e-07,2.1186231739561e-06)}\\tabularnewline\n\\hline \n{\\scriptsize{}-9} & {\\scriptsize{}(-0.863064302175, -1.8)} & {\\scriptsize{}(3.037169144916e-06,-3.8007524015554e-06)}\\tabularnewline\n\\hline \n{\\scriptsize{}-8} & {\\scriptsize{}(-0.863064302175, -1.6)} & {\\scriptsize{}(-0.00020292956274934,-9.4793805592883e-05)}\\tabularnewline\n\\hline \n{\\scriptsize{}-7} & {\\scriptsize{}(-0.863064302175, -1.4)} & {\\scriptsize{}(0.00051562027155282,0.0033198141762956)}\\tabularnewline\n\\hline \n{\\scriptsize{}-6} & {\\scriptsize{}(-0.863064302175, -1.2)} & {\\scriptsize{}(0.023802856324805,-0.020097812439831)}\\tabularnewline\n\\hline \n{\\scriptsize{}-5} & {\\scriptsize{}(-0.863064302175, -1)} & {\\scriptsize{}(-0.16210306892042,-0.057527918763957)}\\tabularnewline\n\\hline \n{\\scriptsize{}-4} & {\\scriptsize{}(-0.863064302175, -0.8)} & {\\scriptsize{}(0.083936569694558,0.55379453117192)}\\tabularnewline\n\\hline \n{\\scriptsize{}-3} & {\\scriptsize{}(-0.863064302175, -0.6)} & {\\scriptsize{}(0.87683903065806,-0.58136186212318)}\\tabularnewline\n\\hline \n{\\scriptsize{}-2} & {\\scriptsize{}(-0.863064302175, -0.4)} & {\\scriptsize{}(-0.87618099667542,-0.6444132979014)}\\tabularnewline\n\\hline \n{\\scriptsize{}-1} & {\\scriptsize{}(-0.863064302175, -0.2)} & {\\scriptsize{}(-0.2112750856805,0.51693268636776)}\\tabularnewline\n\\hline \n{\\scriptsize{}0} & \\textbf{\\scriptsize{}(-0.863064302175, 0)} & \\textbf{\\scriptsize{}(0.21113064943379,1.1012434042446e-07)}\\tabularnewline\n\\hline \n{\\scriptsize{}1} & {\\scriptsize{}(-0.863064302175, 0.2)} & {\\scriptsize{}(-0.2112752777559,-0.51693263772868)}\\tabularnewline\n\\hline \n{\\scriptsize{}2} & {\\scriptsize{}(-0.863064302175, 0.4)} & {\\scriptsize{}(-0.87618105783081,0.6444131761443)}\\tabularnewline\n\\hline \n{\\scriptsize{}3} & {\\scriptsize{}(-0.863064302175, 0.6)} & {\\scriptsize{}(0.87683907406497,0.58136183517238)}\\tabularnewline\n\\hline \n{\\scriptsize{}4} & {\\scriptsize{}(-0.863064302175, 0.8)} & {\\scriptsize{}(0.083936534477108,-0.55379454106338)}\\tabularnewline\n\\hline \n{\\scriptsize{}5} & {\\scriptsize{}(-0.863064302175, 1)} & {\\scriptsize{}(-0.16210304313401,0.057527824955638)}\\tabularnewline\n\\hline \n{\\scriptsize{}6} & {\\scriptsize{}(-0.863064302175, 1.2)} & {\\scriptsize{}(0.023802980792584,0.020097827969804)}\\tabularnewline\n\\hline \n{\\scriptsize{}7} & {\\scriptsize{}(-0.863064302175, 1.4)} & {\\scriptsize{}(0.00051562077173168,-0.0033196934926057)}\\tabularnewline\n\\hline \n{\\scriptsize{}8} & {\\scriptsize{}(-0.863064302175, 1.6)} & {\\scriptsize{}(-0.0002030221163996,9.4802957184526e-05)}\\tabularnewline\n\\hline \n{\\scriptsize{}9} & {\\scriptsize{}(-0.863064302175, 1.8)} & {\\scriptsize{}(3.0281700967037e-06,3.7434363774526e-06)}\\tabularnewline\n\\hline \n{\\scriptsize{}10} & {\\scriptsize{}(-0.863064302175, 2)} & {\\scriptsize{}(2.2311216999616e-07,-2.1234907990132e-06)}\\tabularnewline\n\\hline \n{\\scriptsize{}11} & {\\scriptsize{}(-0.863064302175, 2.2)} & {\\scriptsize{}(6.871098037128e-07,5.5123982746463e-08)}\\tabularnewline\n\\hline \n{\\scriptsize{}12} & {\\scriptsize{}(-0.863064302175, 2.4)} & {\\scriptsize{}(-2.1322288893395e-08,1.6899352278552e-07)}\\tabularnewline\n\\hline \n{\\scriptsize{}13} & {\\scriptsize{}(-0.863064302175, 2.6)} & {\\scriptsize{}(-2.0738399377275e-08,-5.6642992624128e-09)}\\tabularnewline\n\\hline \n\\end{tabular}{\\scriptsize \\par}\n\n\n\\section{REXI on linear operators}\n\nIn this section, we investigate the linear operator $L$ with the\nrational approximation.\n\n\n\\subsection{Reducing number of computations for $L$}\n\nNote the property (see Sec. 3.3 in \\cite{Terry:High-order time-parallel approximation of evolution operators})\nfor the $\\alpha_{n}$ and $\\beta_{n}$: There is an anti-symmetry\naround the central pole with\n\\begin{equation}\n\\alpha_{-n}=\\bar{\\alpha}_{+n}\\label{eq:alpha_conjugate_symmetry}\n\\end{equation}\nand\n\\begin{equation}\n\\beta_{-n}=\\bar{\\beta}_{+n}\\label{eq:beta_conjugate_symmetry}\n\\end{equation}\nIn particular, with $Im(\\alpha_{0})=Im(\\beta_{0})=0$, there is a\nzero imaginary number for the central pole.\n\nFurthermore, it holds that \n\\[\n\\overline{(L+\\alpha)^{-1}U(0)}=(L+\\overline{\\alpha})^{-1}U(0)\n\\]\nwith the overbar denoting the complex conjugate. We can then reformulate\nthe approximation\n\\begin{eqnarray*}\ne^{\\tau L} & \\approx & \\sum_{n=-N}^{N}Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)\\\\\n & = & \\sum_{n=-N}^{-1}Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)+Re\\left(\\frac{\\beta_{0}^{Re}}{\\tau L+\\alpha_{0}}\\right)+\\sum_{n=-N}^{-1}Re\\left(\\frac{\\beta_{N+n+1}^{Re}}{\\tau L+\\alpha_{N+n+1}}\\right)\n\\end{eqnarray*}\nand using the properties \\eqref{eq:alpha_conjugate_symmetry} and\n\\eqref{eq:beta_conjugate_symmetry}, we can write this as\n\\begin{align*}\n\\sum_{n=-N}^{-1}Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)+Re\\left(\\frac{\\beta_{0}^{Re}}{\\tau L+\\alpha_{0}}\\right)+\\sum_{n=-N}^{-1}Re\\left(\\frac{\\overline{\\beta_{N}^{Re}}}{\\tau L+\\overline{\\alpha_{N}}}\\right)\\\\\n=\\sum_{n=-N}^{-1}\\left(Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}+\\overline{\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)}\\right)\\right)+Re\\left(\\frac{\\beta_{0}^{Re}}{\\tau L+\\alpha_{0}}\\right).\n\\end{align*}\nSince the imaginary parts cancel out for $Re(a+\\overline{a})=a+\\overline{a}$\nand with $\\alpha_{0}$ and $\\beta_{0}$ being only real-valued, we\ncan simplify the equation to\n\\[\ne^{\\tau L}\\approx\\sum_{n=-N}^{N}Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)=\\sum_{n=-N}^{-1}\\left(2\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)+\\frac{\\beta_{0}^{Re}}{\\tau L+\\alpha_{0}}.\n\\]\nThis allows us to reduce the computational amount almost by a factor\nof two for solving $(L+\\alpha)^{-1}$ giving the real valued solution\n\\[\nU(\\tau)=e^{\\tau L}U(0)\\approx\\sum_{n=0}^{N}\\gamma_{n}^{Re}\\left(\\tau L+\\alpha_{n}\\right)^{-1}U(0)\n\\]\nwith \n\\[\n\\gamma_{n}:=\\begin{cases}\n\\begin{array}{c}\n\\beta_{0}\\\\\n2\\beta_{n}\n\\end{array} & \\begin{array}{c}\nfor\\,n=0\\\\\nelse\n\\end{array}\\end{cases}\n\\]\n\n\n\n\\subsection{Matrix exponential}\n\n\\label{sec:mat_exp} We would like to apply REXI to a formulation\nsuch as \n\\[\nU(t)=e^{\\tau L}U(0).\n\\]\nTo see the relationship between the approximation of $e^{ix}$ with\n$e^{\\tau L}$ we assume that $L$ is skew hermitian and therefore\nhas only purely imaginary eigenvalues, and maybe decomposed as $\\Sigma\\Lambda\\Sigma^{H}$,\nyielding \n\\begin{equation}\ne^{\\tau L}=\\sum_{k=0}^{\\infty}\\frac{(\\tau L)^{k}}{k!}=\\sum_{k=0}^{\\infty}\\frac{\\tau\\Sigma\\Lambda^{k}\\Sigma^{H}}{k!}=\\Sigma\\left(\\sum_{k=0}^{\\infty}\\frac{(\\tau\\Lambda)^{k}}{k!}\\right)\\Sigma^{H}=\\Sigma e^{\\tau\\Lambda}\\Sigma^{H},\\label{eq:expL}\n\\end{equation}\nwhere we used the orthonormality of $\\Sigma$ to cancel it out from\nthe summation, and\n\n\\[\ne^{\\tau\\Lambda}=\\left(\\begin{array}{ccc}\n...\\\\\n & e^{i\\lambda_{j}\\tau}\\\\\n &  & ...\n\\end{array}\\right)\n\\]\nwhere we have explicitly detached the imaginary unit from the eigenvalues,\ntherefore $\\lambda_{n}$ are assumed real. Since $e^{\\tau\\Lambda}$\nis diagonal, it can be eigenvalue-wise approximated in the same way\nas in $e^{ix}$ with REXI.\n\nAlthough $L$ has imaginary eigenvalues, we wish to evaluate the $e^{\\tau L}U(0)$,\nwhich is real valued. Therefore, we will use the real approximation\nof $e^{ix}$ \n\\begin{equation}\nexp(\\tau L)\\approx Re\\left(\\sum_{n=-N}^{N}\\beta_{n}(\\tau L+\\alpha_{n})^{-1}\\right),\\label{eq:rexi}\n\\end{equation}\nwhere $\\beta_{n}$ is given by equation \\eqref{eq:beta_re} and $\\alpha_{n}$\nby equation \\eqref{eq:alpha}.\n\nGiven the linear operator $L$ to be applied on $U(0)$, we continue\nto show the relation of the linear operator to the REXI approximation\nof the real term\n\\[\ne^{\\tau L}\\approx\\sum_{n=-N}^{N}Re\\left(\\frac{\\beta_{n}^{Re}}{\\tau L+\\alpha_{n}}\\right)\n\\]\nas we use it later on. Next, we rewrite $L$ with our EV decomposition\nas\n\\begin{eqnarray*}\ne^{\\tau L} & \\approx & \\sum_{n=-N}^{N}Re\\left(\\beta_{n}^{Re}(\\tau\\Sigma\\Lambda\\Sigma^{-1}+\\alpha_{n}I)^{-1}\\right)\\\\\n & = & \\sum_{n=-N}^{N}Re\\left(\\beta_{n}^{Re}(\\Sigma(\\tau\\Lambda\\Sigma^{-1}+\\alpha_{n}\\Sigma^{-1}))^{-1}\\right)\\\\\n & = & \\sum_{n=-N}^{N}Re\\left(\\beta_{n}^{Re}(\\Sigma^{-1}(\\tau\\Lambda+\\alpha_{n}\\Sigma^{-1}\\Sigma)){}^{-1}\\Sigma^{-1}\\right)\\\\\n & = & \\sum_{n=-N}^{N}Re\\left(\\beta_{n}^{Re}\\Sigma(\\tau\\Lambda+\\alpha_{n})^{-1}\\Sigma^{-1}\\right)\\\\\n & = & \\approx\\Sigma e^{\\tau\\Lambda}\\Sigma^{H}\n\\end{eqnarray*}\nNote, that we use the same REXI approximation for different $\\lambda_{j}$.\nHence, the approximation has to be sufficiently accurate over the\nentire range of all Eigenvalues$\\lambda_{j}$ which is what we use\nthe approximation for.\n\n\n\\subsection{Choosing $h$ and $M$}\n\nSome important points about the choice of $M$ and $h$ have to be\nmade at this point. We know that $e^{ix}$ is accurately approximated\nwith REXI for the interval $|x|<hM$, where $h$ is chosen small enough\nto obtain a good approximation in step (A), and $M$ will define the\ninterval size and number of approximation points. In the matrix case,\n$M$ has to be chosen so that $hM>t\\bar{\\lambda}$, where $\\bar{\\lambda}=\\max_{n}|\\lambda_{n}|$,\nin order to capture all wavelengths of $L$. In other other words,\n$hM$ need to be set to capture the fastest wave. Note that if this\nis used as a time stepping method, with time step $t=\\tau$, then,\nthe larger the timestep, the larger $M$ will be. Exact evaluations\nof the choices for $h$ and $M$ may be done based on equation (3.6)\nof \\cite{Terry:High-order time-parallel approximation of evolution operators}.\n\nTODO: We have to investigate this by far in more depth. Can we possibly\nuse a standard time step restriction of the linear equations?\n\n\n\\subsection{Handling $\\tau$ in REXI\\label{sub:Handling-tau-in-REXI}}\n\nWe reformulate the REXI approximation scheme given by\n\n\\[\n(\\tau L+\\alpha)^{-1}U(\\tau)=U(0)\n\\]\nand by factoring $\\tau$ out, yielding\n\n\\[\n(L+\\frac{\\alpha}{\\tau})^{-1}U(\\tau)\\tau^{-1}=U(0)\n\\]\nSo instead of solving for $U(\\tau)$, we are solving for $U^{\\tau}(\\tau):=U(\\tau)\\tau^{-1}$\nas well as $\\alpha^{\\tau}:=\\frac{\\alpha}{\\tau}$.\n\nTo summarize, we have to solve the system of equations given by\n\n\\begin{equation}\n(L+\\alpha^{\\tau})^{-1}U^{\\tau}(\\tau)=U(0)\\label{eq:unit_rexi_timestep}\n\\end{equation}\nwith $U(0)$ the initial conditions. For sake of simplicity, we stick\nto the formulation without the $\\tau$ notation.\n\n\n\\subsection{Computing inverse of $(L+\\alpha)^{-1}$}\n\nFor computing the inverse, arbitrary solvers can be used. However\nwe like to note, that $\\alpha$ is a complex number. Hence, requiring\nsolvers with support for solving in complex space.\n\nWe wish to solve the differential problem for each time step \n\\[\n(-L+\\alpha)U=U(0)\n\\]\nso that $U=(-L+\\alpha)^{-1}U_{0}$. Note, the change in sign before\n$L$ for convenience which has to be accounted for afterwards. We\nwill do this converting the problem into and elliptic equation.\\textbf{}\\\\\n\n\nFirst, lets expand the equations with the definition of $L$, \n\\begin{eqnarray}\nfv+g\\eta_{x}+\\alpha u & = & u_{0},\\label{eq:mom_u}\\\\\nfu+g\\eta_{y}+\\alpha v & = & v_{0},\\label{eq:mom_v}\\\\\n\\bar{\\eta}(u_{x}+v_{y})+\\alpha\\eta & = & \\eta_{0}.\\label{eq:mass}\n\\end{eqnarray}\n\n\nLet $f$ be constant (f-plane approximation), $\\delta:=u_{x}+v_{y}$\nbe the wind divergence, $\\zeta:=v_{x}-u_{y}$ be the wind (relative)\nvorticity and $\\Delta\\eta:=\\eta_{xx}+\\eta_{yy}$ the Laplacian of\nthe fluid depth. We will re-write the problem in a divergence-vorticity\nformulation by taking 2 steps. First, sum the $\\partial_{x}$ of equation\n\\eqref{eq:mom_u} and the $\\partial_{y}$ of equation \\eqref{eq:mom_v},\nyielding \n\\begin{equation}\n-f\\zeta+g\\Delta\\eta+\\alpha\\delta=\\delta_{0}.\\label{eq:zeta}\n\\end{equation}\nThen subtract the $\\partial_{y}$ of equation \\eqref{eq:mom_u} from\nthe $\\partial_{x}$ of equation \\eqref{eq:mom_v}, yielding \n\\begin{equation}\nf\\delta+\\alpha\\zeta=\\zeta_{0}.\\label{eq:delta}\n\\end{equation}\nUsing equation \\eqref{eq:zeta} in equation \\eqref{eq:delta} gives\nus\n\n\\[\n\\delta=-\\frac{1}{f^{2}+\\alpha^{2}}\\left(\\alpha g\\Delta\\eta-\\alpha\\delta_{0}-f\\zeta_{0}\\right).\n\\]\nFinally, substituting $\\delta$ in equation \\eqref{eq:mass}, that\nreads $\\bar{\\eta}\\delta+\\alpha\\eta=\\eta_{0}$, results in \n\\[\n-\\frac{\\bar{\\eta}}{f^{2}+\\alpha^{2}}\\left(\\alpha g\\Delta\\eta-\\alpha\\delta_{0}-f\\zeta_{0}\\right)+\\alpha\\eta=\\eta_{0},\n\\]\nwhich may be simplified into the elliptic equation by multiplying\nby $-\\frac{f^{2}+\\alpha^{2}}{\\bar{\\eta}\\alpha g}$\n\n\\begin{equation}\n\\Delta\\eta-\\kappa^{2}\\eta=r_{0}\\label{eq:ellip}\n\\end{equation}\nwhere \n\\[\n\\kappa^{2}=\\frac{f^{2}+\\alpha^{2}}{\\bar{\\eta}g}\n\\]\nand \n\\[\nr_{0}=-\\frac{\\kappa^{2}}{\\alpha}\\eta_{0}+\\frac{1}{g}\\delta_{0}+\\frac{f}{\\alpha g}\\zeta_{0}.\n\\]\n\n\nMultiplying the equation \\eqref{eq:ellip}by $-g\\bar{\\eta}$ gives\n\n\\[\n((\\alpha^{2}+f^{2})-g\\bar{\\eta}\\Delta)\\eta=\\frac{f^{2}+\\alpha^{2}}{\\alpha}\\eta_{0}-\\bar{\\eta}\\delta_{0}-\\frac{f\\bar{\\eta}}{\\alpha}\\zeta_{0}\n\\]\n\n\nWe can compute$\\eta$ with any elliptic solver. Special attention\nhas to be given to the LHS of the form $(\\gamma-\\Delta)\\eta$ for\na spectral solver and this is the reason for this brief excursion.\nWe use $\\tilde{}$ to annotate an operator or quantity to be given\nin spectral space. Then, we factor $\\tilde{\\eta}$ in and write form\nof the LHS in spectral space with the identity matrix $I$ as\n\\[\n(\\gamma I\\tilde{\\eta}-\\tilde{\\Delta}\\tilde{\\eta})=(\\gamma I-\\tilde{\\Delta})\\tilde{\\eta}\n\\]\nHere, the minus operator in spectral space has to be applied on all\nelements of $\\tilde{\\Delta}$ and not only to the $0^{th}$ mode as\nit is typically the case for adding a constant in spectral space.\n\nWe need to retrieve the velocities by solving the $2\\times2$ system\nformed by equations \\eqref{eq:mom_u} and \\eqref{eq:mom_v}, which\nreads \n\\[\nA_{\\alpha}U=U_{0}-g\\nabla\\eta\n\\]\nwith \n\\[\nA_{\\alpha}=\\left(\\begin{matrix}\\alpha & -f\\\\\nf & \\alpha\n\\end{matrix}\\right).\n\\]\nThe solution is \n\\[\nU=A_{\\alpha}^{-1}(U_{0}-g\\nabla\\eta)\n\\]\nwhere \n\\[\nA_{\\alpha}^{-1}=\\frac{1}{f^{2}+\\alpha^{2}}\\left(\\begin{matrix}\\alpha & f\\\\\n-f & \\alpha\n\\end{matrix}\\right)\n\\]\nFinally, since we computed $(-L+\\alpha)^{-1}$, we also have to invert\nthe sign of the computed solution $U$. Alternatively, we can change\nthe signs of $\\alpha_{n}$ and $\\beta_{n}$.\n\n\n\\subsection{Interpretation of $\\tau$}\n\nWe like to close this section with a brief discussion of $\\tau$ by\nhaving a look on the REXI reformulation\n\n\\[\n\\left(L-\\frac{\\alpha}{\\tau}\\right)^{-1}U\\tau^{-1}=U_{0}\n\\]\nWe see, that for an increasing $\\tau$, hence an integration in time\nover a larger time period, the poles given by $\\alpha$ are getting\ncloser. This can possibly lead to a loss in accuracy for the data\nsampled by the outer poles $\\alpha_{-N}$ and $\\alpha_{N}$. Therefore,\nthe number $N$ of poles is expected to scale linearly with the size\nof the coarse time step, \n\\[\n|N|\\propto\\tau.\n\\]\n\n\nIndeed, we saw in section \\ref{sec:mat_exp} that for larger $\\tau$,\n$M$ needs to be larger.\n\n\n\\subsection{Numerical Dispersion}\n\nWe continue to (try to) analyze possible dispersion effects of the\nREXI approximation. Here, we assume that we use an accurate solver\nto compute $(L-\\alpha_{i})^{-1}$. We are interested in answering\nthe question which error is introduced when not using enough terms\nin the approximation.\n\nAccording to \\ref{sec:mat_exp}, we can decompose the linear operator\ninto EVals and EVects and write the approximation in the following\nway:\n\n\\[\ne^{\\tau L}\\approx\\Sigma\\left[\\sum_{n=0}^{N}Re\\left(\\gamma_{n}(\\tau\\Lambda+\\alpha_{n})^{-1}\\right)\\right]\\Sigma^{H}.\n\\]\nAlternatively without solving a linear operator, one can also think\ndirectly about approximating a set of exponents given by $\\Lambda$\nwith\n\n\\[\ne^{\\tau\\Lambda}\\approx\\sum_{n=0}^{N}\\left(\\gamma_{n}(\\tau\\Lambda+\\alpha_{n})^{-1}\\right).\n\\]\nWe can then use the spectral representation of the solution\n\\[\ne^{\\tau\\hat{L}}=\\hat{\\Sigma}e^{\\tau\\hat{\\Lambda}}\\hat{\\Sigma}^{H}\n\\]\nwith $\\hat{L}=\\hat{\\Sigma}\\hat{\\Lambda}$the spectral EValue/EVector\ndecomposition. We can then approximate the exponential $e^{\\tau\\Lambda}$\nby\n\n\\[\ne^{\\tau\\hat{L}}\\approx\\hat{\\Sigma}\\sum_{n=0}^{N}\\left(\\gamma_{n}(\\tau\\hat{\\Lambda}+\\alpha_{n})^{-1}\\right)\\hat{\\Sigma}^{H}\n\\]\nFor selected modes $(k_{1},k_{2})$ at a specific point in time $\\tau=\\sigma$,\nthe solution and operators in spectral space are then given by\n\n\\begin{align*}\n\\hat{U}(k_{1},k_{2},\\tau)= & e^{\\tau\\hat{L}_{k_{1},k_{2}}}\\hat{U}(k_{1},k_{2},0)\\\\\n\\approx & \\hat{\\Sigma}_{k_{1},k_{2}}\\left[\\sum_{n=-N}^{N}Re\\left(\\beta_{n}^{Re}(\\tau\\hat{\\Lambda}_{k_{1},k_{2}}+\\alpha_{n})^{-1}\\right)\\right]\\hat{\\Sigma}_{k_{1},k_{2}}^{H}\\hat{U}(k_{1},k_{2},0).\n\\end{align*}\nCase A) For $k_{1}\\neq0$ and $k_{2}\\neq0$, we know that $\\hat{\\Lambda}$contains\neigenvalues\n\n\\begin{tabular}{rcl}\nVortical mode: &  & $\\omega_{0}=0$\\tabularnewline\nGravitational modes: &  & $\\omega_{\\pm1}=\\pm\\sqrt{4\\pi^{2}(\\eta_{0}gk_{1}^{2}+\\eta_{0}gk_{2}^{2})+f^{2}}$\\tabularnewline\n\\end{tabular}\\\\\nCase B) For $k_{1}=k_{2}=0$, we get the eigenvalues\n\n\\begin{tabular}{rcl}\nVortical mode: &  & $\\omega_{0}=0$\\tabularnewline\nGravitational modes: &  & $\\omega_{\\pm1}=\\pm f$\\tabularnewline\n\\end{tabular}\\\\\nThese eigenvalues describe the frequency in $\\hat{\\Lambda}$ which\nwe approximate. As soon as this frequency cannot be approximated anymore\nwith REXI, this results in errors in the dispersion of this particular\nfrequency.\n\nWith the computational requirements (M) of REXI being related to the\nfastest waves, we can identify the requirement $M\\sim\\sqrt{\\eta_{0}g}$\nand $M\\sim f$.\n\n\\emph{Vortical modes}: Since the vortical modes are always zero, we\ndo not expect any (analytical) errors in these modes. However, due\nto discretization, errors can accumulate and show up.\n\n\\emph{Gravitational modes: }We can observe that errors in the frequency\n$\\omega_{\\pm1}$ in case A area generated. The dominating frequency\nis only dependent on $\\eta_{0}$ and $g$ in case of\n\\[\n4\\pi^{2}(\\eta_{0}gk_{1}^{2}+\\eta_{0}gk_{2}^{2})=4\\pi^{2}\\eta_{0}g|k|^{2}>f^{2}\n\\]\nand $f$ otherwise. The factor $4\\pi^{2}$ shows up since our domain\nis on $\\Omega=[0;1]^{2}$. The Coriolis frequency $f$ is also independent\nof the spatial frequency, hence also the resolution.\n\nFurthermore, we can observe a relation to the Rossby radius given\nby\n\\[\nL_{R}:=4\\pi\\text{\\texttwosuperior}\\frac{\\sqrt{g\\eta_{0}}}{f}\n\\]\nwhich describes at which scale at the Coriolis effect also strongly\ncontributes to the simulation results compared to the gravitational\nand height values.\n\n\n\\subsection{Complex solver}\n\nWe are interested in solving a system of the form, \n\\[\n(-L+\\alpha)U=U_{0},\n\\]\nwhere $\\alpha$ is a complex number, therefore we must allow complex\nsolutions for $U$. The system can be transformed to have only real\narithmetic in the following way.\n\nFirst we decompose $U$ into its real and imaginary parts, $U=U^{r}+iU^{i}$,\nand allow $U_{0}$ to be decomposed in the same way. Although $\\alpha$\ncan be a general complex number, it real part is always constant in\nREXI, given by $\\mu$. We will therefore write $\\alpha=\\mu+i\\alpha^{i}$,\nand we can absorb $\\mu$ into $L$ writing $D=-L+\\mu I$, where $I$\nis the identity matrix. Now \n\\[\n(D+i\\alpha^{i}I)(U^{r}+iU^{i})=U_{0}^{r}+iU_{0}^{i},\n\\]\n\\[\nDU^{r}-\\alpha^{i}U^{i}+i(\\alpha^{i}U^{r}+DU^{i})=U_{0}^{r}+iU_{0}^{i},\n\\]\ntherefore \n\\begin{eqnarray}\nDU^{r}-\\alpha^{i}U^{i} & = & U_{0}^{r}\\\\\n\\alpha^{i}U^{r}+DU^{i} & = & U_{0}^{i},\n\\end{eqnarray}\nwhich in matrix notation gives \n\\[\n\\left(\\begin{matrix}D & -\\alpha^{i}I\\\\\n\\alpha^{i}I & D\n\\end{matrix}\\right)\\left(\\begin{matrix}U^{r}\\\\\nU^{i}\n\\end{matrix}\\right)=\\left(\\begin{matrix}U_{0}^{r}\\\\\nU_{0}^{i}\n\\end{matrix}\\right),\n\\]\nor, \n\\[\n\\left(\\begin{matrix}-L+\\mu I & -\\alpha^{i}I\\\\\n\\alpha^{i}I & -L+\\mu I\n\\end{matrix}\\right)\\left(\\begin{matrix}U^{r}\\\\\nU^{i}\n\\end{matrix}\\right)=\\left(\\begin{matrix}U_{0}^{r}\\\\\nU_{0}^{i}\n\\end{matrix}\\right).\n\\]\n\n\nA similar approach may be taken with the elliptic equation \n\\begin{equation}\n\\Delta\\eta+\\theta\\eta=r_{0},\n\\end{equation}\nwhere $\\eta$, $\\theta$ and $r_{0}$ may be complex. The resulting\nsystem is given by \n\\begin{eqnarray}\n\\Delta\\eta^{r}+\\theta^{r}\\eta^{r}-\\theta^{i}\\eta^{i}=r_{0}^{r},\\\\\n\\Delta\\eta^{i}+\\theta^{i}\\eta^{r}+\\theta^{r}\\eta^{i}=r_{0}^{i},\n\\end{eqnarray}\nwhich can also be written in matrix notation and solved with arbitrary\nelliptic equation solvers.\n\n\n\\section{Filtering}\n\nThe method described in the previous section is well defined for skew\nhermitian $L$. If $L$ is not skew hermitian, the real eigenvalues\nmight cause the REXI to have absolute values larger than 1, which\ncan lead to instabilities if used as time stepping method.\n\nTo ensure that the REXI is bounded by unit, a filtering process is\nproposed in \\cite{Terry:High-order time-parallel approximation of evolution operators}.\nREXI is prone to exceed unit in the neighborhood of $|t\\lambda|\\approx hM$,\ntherefore in the highest frequencies. The idea is to construct a rational\nfunction $S(ix)$ that is approximately $1$ in a smaller interval\n$|t\\lambda|<hM_{0}$, with $M_{0}<M$, and decays very fast to zero\noutside this interval. Then we multiply this filters function to the\noriginal REXI, which will lead to a unit bounded REXI.\n\nFurther details of how $S(ix)$ is computed will be added later.\n\n\n\\section{Bringing everything together}\n\nUsing the spectral methods (e.g. in SWEET), we can directly solve\nthe Helmholtz problem for the height in Eq. (\\ref{eq:helmhotz}) and\nthen solver for the velocity in Eqs. (\\ref{BROKEN: Ref: eq:elliptic_velo...},\\ref{eq:elliptic_velocity_v}).\nNote that the Helmholtz problem is in complex space, as $\\alpha_{n}$\nare complex. This is straightforward with spectral methods. For finite\ndifference/element methods, the problem can be split into its real\nand imaginary parts.\n\nThen, the problem is reduced to computing the REXI as given in Eq.\n\\eqref{eq:rexi}. \n\n\n\\section{Notes on HPC}\n\\begin{itemize}\n\\item The terms in REXI to solve are all independent. Hence, for latency\navoiding, the communication can be interleaved with computations. \n\\item The iterative solvers are memory bound. Instead of computing $c:=a*b$\nfor the stencil operations, we could compute $\\vec{c}:=a\\vec{b}$\nwith $a$ one coefficient in the stencil. This allows vectorization\nover $c$ and $b$ on accelerator cards with strided memory access. \n\\item It is unknown which method is more efficient to solve the system of\nequations:\n\n\\begin{itemize}\n\\item iterative solvers have low memory access, \n\\item inverting the system and storing it as a sparse matrix allows fast\ndirect solving but can yield more memory access operations. \n\\end{itemize}\n\\item Splitting the solver into real and complex number would store them\nconsecutively in memory. This has a potential to avoid non-strided\nmemory access and using the same SIMD operations (Just a rough idea,\nTODO: check if this is really the case).\n\\end{itemize}\n\n\\section{Acknowledgements}\n\nThanks to Terry for the feedback \\& discussions! \n\\begin{thebibliography}{1}\n\\bibitem{Schreiber:Formulations of the shallow-water equations}Formulations\nof the shallow-water equations, M. Schreiber, P. Peixoto et al.\n\n\\bibitem{Terry:High-order time-parallel approximation of evolution operators}High-order\ntime-parallel approximation of evolution operators, T. Haut et al.\n\n\\bibitem{Moler:Nineteen Dubious Ways to Compute the Exponential of a Matrix}Nineteen\nDubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years\nLater, Cleve Moler and Charles Van Loan, SIAM review\n\n\\bibitem{Damle:Near optimal rational approximations of large data sets}Near\noptimal rational approximations of large data sets, Damle, A., Beylkin,\nG., Haut, T. S. \\& Monzon\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "13326a8c5cf9dee4886ad4db2a726fa66c404208", "size": 34160, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/rexi/understanding_rexi.tex", "max_stars_repo_name": "pedrospeixoto/sweet", "max_stars_repo_head_hexsha": "224248181e92615467c94b4e163596017811b5eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/rexi/understanding_rexi.tex", "max_issues_repo_name": "pedrospeixoto/sweet", "max_issues_repo_head_hexsha": "224248181e92615467c94b4e163596017811b5eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/rexi/understanding_rexi.tex", "max_forks_repo_name": "pedrospeixoto/sweet", "max_forks_repo_head_hexsha": "224248181e92615467c94b4e163596017811b5eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-27T01:17:59.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-27T01:17:59.000Z", "avg_line_length": 40.0938967136, "max_line_length": 241, "alphanum_fraction": 0.6994437939, "num_tokens": 11572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.42063597213455817}}
{"text": "\n%%% Template originaly created by Karol Kozioł (mail@karol-koziol.net) and modified for ShareLaTeX use\n\n\\documentclass[a4paper,11pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\n\\usepackage{sansmath}\n\\renewcommand\\familydefault{\\sfdefault}\n\\usepackage{tgheros}\n\n\\usepackage{amsmath,amssymb,amsthm,textcomp}\n\\usepackage{enumerate}\n\\usepackage{multicol}\n\\usepackage{tikz}\n\\usetikzlibrary{shapes, positioning}\n\n\\usepackage{geometry}\n\\geometry{total={210mm,297mm},\nleft=25mm,right=25mm,%\nbindingoffset=0mm, top=20mm,bottom=20mm}\n\n\n\\linespread{1.3}\n\n\\newcommand{\\linia}{\\rule{\\linewidth}{0.5pt}}\n\n% custom theorems if needed\n\\newtheoremstyle{mytheor}\n    {1ex}{1ex}{\\normalfont}{0pt}{\\scshape}{.}{1ex}\n    {{\\thmname{#1 }}{\\thmnumber{#2}}{\\thmnote{ (#3)}}}\n\n\\theoremstyle{mytheor}\n\\newtheorem{defi}{Definition}\n\n% my own titles\n\\makeatletter\n\\renewcommand{\\maketitle}{\n\\begin{center}\n\\vspace{2ex}\n{\\huge \\textsc{\\@title}}\n\\vspace{1ex}\n\\\\\n\\linia\\\\\n\\@author \\hfill \\@date\n\\vspace{4ex}\n\\end{center}\n}\n\\makeatother\n%%%\n\n% custom footers and headers\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\lhead{}\n\\chead{}\n\\rhead{}\n\\lfoot{Automatic~Verification Assignment \\#2}\n\\cfoot{}\n\\rfoot{Page \\thepage}\n\\renewcommand{\\headrulewidth}{0pt}\n\\renewcommand{\\footrulewidth}{0pt}\n%\n\n% all section titles centered and bolded\n\\usepackage{sectsty}\n\\allsectionsfont{\\bfseries\\large}\n%\n% add section label\n\\renewcommand\\thesection{Problem~\\arabic{section}:}\n%\n\n%%%----------%%%----------%%%----------%%%----------%%%\n\n\\begin{document}\n\n\\title{Homework Assignment~\\#2}\n\n\\author{R02943142 Hsieh, Chiao}\n\n%\\date{01/01/2014}\n\n\\maketitle\n\n\\section{Lattices and Complete Lattices}\nProve that every finite lattice is a complete lattice. Be clear about the cases\nof the supremum and the infimum of an empty subset.\n\\medskip \\\\\nAnswer.\n\\smallskip \\\\\nTo prove that every finite lattice is a complete lattice, we have to prove that\nthere are $\\bigvee S$ and $\\bigwedge S$ for all $S \\subseteq L$ in any given\nfinite lattice $L$.\n\nFirst, we can derive $\\bigwedge S$ for all nonempty subsets $S$ by following means:\n\\smallskip\\\\\nAssume $S=\\{x_1,x_2,\\dots,x_n\\}$ is a nonempty subset of a lattice $L$, we derive\n$y_n$ by\n\\begin{align*}\nL \\ni y_0 &= x_1 \\\\\nL \\ni y_1 &= y_0 \\wedge x_1 = x_1 \\wedge x_1 = x_1 \\\\\nL \\ni y_2 &= y_1 \\wedge x_2 = x_1 \\wedge x_2 \\\\\nL \\ni y_3 &= y_2 \\wedge x_3 = x_1 \\wedge x_2 \\wedge x_3 \\\\\n\\dots \\\\\nL \\ni y_n &= y_{n-1} \\wedge x_n = x_1 \\wedge x_2 \\wedge x_3 \\wedge \\dots \\wedge x_n\n\\end{align*}\nBy definition of $\\wedge$, we know $y_i \\leq x_i$ and $y_i \\leq y_{i-1}$\nand, therefore, $y_n \\leq x_i$ for all $i$ in $[1 \\dots n]$. This means\n$y_n$ is a lower bound of $S$. Further, we prove $y_n$ is $\\bigwedge S$.\n\\smallskip\\\\\nGiven $z \\in L$, any lower bound of $S$,\n\\begin{align*}\ny_n \\wedge z &= y_{n-1} \\wedge (x_n \\wedge z) = y_{n-1} \\wedge z \\\\\ny_{n-1} \\wedge z &= y_{n-2} \\wedge (x_{n-1} \\wedge z) = y_{n-2} \\wedge z \\\\\n\\dots \\\\\ny_0 \\wedge z     &= x_1 \\wedge z = z\n\\end{align*}\nThat is, for any lower bound $z$, $z \\wedge y_n = z \\implies z \\leq y_n$;\nhence $y_n$ is the greatest lower bound $\\bigwedge S$.\nDually we can derive $\\bigvee S$ in a similar manner.\n\nSecond, when $S = \\emptyset$, we have to prove $L$ has a top element, \n$\\top = \\bigvee L = \\bigwedge S$ and a bottom element, \n$\\bot = \\bigwedge L = \\bigvee S$. The proof is directly derived from \nthat, since $L \\subseteq L$ and $L$ is finite, $\\bigvee L$ and $\\bigwedge \nL$ must exist by the proof in first paragraph. \n\nCombining both paragraphs, we proved that there are $\\bigvee S$ and\n$\\bigwedge S$ for all $S \\subseteq L$ in every finite lattice $L$.\nThus, every finite lattice is a complete lattice. Q.E.D.\n\n\\section{Complete Partial Orders}\nProve that every complete lattice is a complete partial order.\n\\medskip \\\\\nAnswer.\n\\smallskip \\\\\nTo prove that every complete lattice $CL$ is a complete partial order, it \nsuffices to show that:\n\\begin{enumerate}\n\\item $CL$ has a bottom element $\\bot$ and\n\\item $\\bigsqcup D$ exists for each directed subset $D$ of $CL$\n\\end{enumerate}\nThe first condition is mentioned in Problem 1 that every complete lattice\nhas a bottom element. The second condition is trivially fulfilled by the\ndefinition of complete lattice. Since, by definition, $\\bigvee S$ exists \nfor every subset $S \\subseteq CL$, $\\bigsqcup D$ must exist for directed \nsubsets $D$ of $CL$. Hence, we finished the proof. Q.E.D.\n\n\\section{Continuous Maps}\nFor a discrete ordered set of your choice, find a self-map on the set\n(i.e., a function mapping from the set to itself) that is monotonic\n(order-preserving), but not $\\sqcup$-continuous. Please state monotonicity\nand $\\sqcup$-continuity precisely in terms of the chosen ordered set\nbefore presenting the example self-map and explaining why it meets the\nrequirements.\n\\medskip \\\\\nAnswer.\n\\smallskip \\\\\n$\\mathbb{N}_{\\top} = \\mathbb{N} \\oplus \\{\\top\\}$ is a discrete infinite\n(complete partial order) set. The elements in $\\mathbb{N}$ follow the\norder in natural number, and all numbers are less than $\\top$, a manually\nintroduced top element. \\\\\nWe can then define a monotonic self-map $f: \\mathbb{N}_{\\top} \\mapsto \\mathbb{N}_{\\top}$ s.t.\n\\begin{equation*}\nf(x) = \\left\\{\n  \\begin{array}{lr}\n    1  & : x \\in \\mathbb{N} \\\\\n    2  & : x = \\top\n  \\end{array}\n\\right.\n\\end{equation*}\nThe mapping $f$ preserves order since for all $x, y \\in \\mathbb{N}, \nx \\leq y \\implies 1 = f(x) \\leq f(y) = 1$, and for all $x \\in \\mathbb{N},\nx \\leq \\top \\implies 1 = f(x) \\leq f(\\top) = 2$.\n\nThe mapping $f$ is not $\\sqcup$-continuous. We can disprove\nby examining the subset $\\mathbb{N} \\subseteq \\mathbb{N}_{\\top}$. \n$\\mathbb{N}$ is a directed subset because, for any two elements $x, y \n\\in \\mathbb{N}$, we know either $x \\leq y$ or $y \\leq x$ and, in either \ncase, $\\exists z = x \\vee y$ s.t. $z \\in \\mathbb{N}$ and $z \\in \\{x, \ny\\}^u$. However, $f(\\bigsqcup \\mathbb{N}) = f(\\top) = 2 \\neq 1 = \n\\bigsqcup \\{1,\\dots,1\\} = \\bigsqcup f(\\mathbb{N})$.\nTherefore, $f$ is not a $\\sqcup$-continuous mapping.\n\n\\end{document}", "meta": {"hexsha": "f6e46b5dbd7d4f8b209485eff28521d9638f383c", "size": 6099, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Automatic_Verification/R02943142_Automatic_Verification_HW2.tex", "max_stars_repo_name": "hc825b/homeworks", "max_stars_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-02T02:05:22.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-02T02:05:22.000Z", "max_issues_repo_path": "Automatic_Verification/R02943142_Automatic_Verification_HW2.tex", "max_issues_repo_name": "hc825b/homeworks", "max_issues_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Automatic_Verification/R02943142_Automatic_Verification_HW2.tex", "max_forks_repo_name": "hc825b/homeworks", "max_forks_repo_head_hexsha": "21d2d50d7cc0ebb05f08a5ff0bdba16f6a63cccb", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-02-22T00:44:03.000Z", "max_forks_repo_forks_event_max_datetime": "2018-02-22T00:44:03.000Z", "avg_line_length": 32.2698412698, "max_line_length": 102, "alphanum_fraction": 0.6925725529, "num_tokens": 2119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632979641571, "lm_q2_score": 0.7745833945721304, "lm_q1q2_score": 0.42049289612569873}}
{"text": "% !TEX root = main.tex\n% !TEX spellcheck = en-US\n\n\\section{Non-malleability of $\\sonicprotfs$}\n\\label{sec:sonic}\n\\subsection{\\sonic{} protocol rolled out}\nIn this section we present $\\sonic$'s constraint system and algorithms. Reader\nfamiliar with them may jump directly to the next section.\n\n\\hamid{we should put the following figure \\ref{fig:pcoms} somewhere in this section.}\n \\begin{figure}[h!]\n \\centering\n \t\\begin{pcvstack}[center,boxed]\n \t\t\\begin{pchstack}\n \t\t\t\\procedure{$\\kgen(\\secparam, \\maxdeg)$} {\n \t\t\t\t\\alpha, \\chi \\sample \\FF^2_p \\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{\\smallset{\\chi^i}_{i = -\\multconstr}^{\\multconstr},\n           \\smallset{\\alpha \\chi^i}_{i = -\\multconstr, i \\neq\n             0}^{\\multconstr}},\\\\\n         \\pcind \\gtwo{\\smallset{\\chi^i, \\alpha \\chi^i}_{i =\n             -\\multconstr}^{\\multconstr}}, \\gtar{\\alpha}\\\\\n \t\t\t\t%\\markulf{03.11.2020}{} \\\\\n \t\t\t%\t\\hphantom{\\pcind \\p{o}_i(X) \\gets \\sum_{j = 1}^{t_i} \\gamma_i^{j - 1} \\frac{\\p{f}_{i,j}(X) - \\p{f}_{i, j}(z_i)}{X - z_i}}\n \t\t\t\t\\hphantom{\\hspace*{5.5cm}}\n \t\t}\n\n \t\t\t\\pchspace\n\n \t\t\t\\procedure{$\\com(\\srs, \\maxconst, \\p{f}(X))$} {\n \t\t\t\t\\p{c}(X) \\gets \\alpha \\cdot X^{\\dconst - \\maxconst} \\p{f}(X) \\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{c} = \\gone{\\p{c}(\\chi)}\\\\ [\\myskip]\n \t\t\t\t\\hphantom{\\pcind \\pcif \\sum_{i = 1}^{\\abs{\\vec{z}}} r_i \\cdot\n           \\gone{\\sum_{j = 1}^{t_j} \\gamma_i^{j - 1} c_{i, j} - \\sum_{j = 1}^{t_j}\n             s_{i, j}} \\bullet \\gtwo{1} + } }\n \t\t\\end{pchstack}\n \t\t% \\pcvspace\n\n \t\t\\begin{pchstack}\n \t\t\t\\procedure{$\\open(\\srs, z, s, f(X))$}\n \t\t\t{\n \t\t\t\t\\p{o}(X) \\gets \\frac{\\p{f}(X) - \\p{f}(z)}{X - z}\\\\ [\\myskip]\n \t\t\t\t\\pcreturn \\gone{\\p{o}(\\chi)}\\\\ [\\myskip]\n \t\t\t\t\\hphantom{\\hspace*{5.5cm}}\n \t\t\t}\n\n \t\t\t\\pchspace\n\n \t\t\t\\procedure{$\\verify(\\srs, \\maxconst, \\gone{c}, z, s, \\gone{\\p{o}(\\chi)})$}\n       {\n         \\pcif \\gone{\\p{o}(\\chi)} \\bullet \\gtwo{\\alpha \\chi} + \\gone{s - z\n         \\p{o}(\\chi)} \\bullet \\gtwo{\\alpha} = \\\\ [\\myskip] \\pcind \\gone{c}\n         \\bullet \\gtwo{\\chi^{- \\dconst + \\maxconst}} \\pcthen  \\pcreturn 1\\\\\n         [\\myskip]\n         \\rlap{\\pcelse \\pcreturn 0.} \\hphantom{\\pcind \\pcif \\sum_{i =\n             1}^{\\abs{\\vec{z}}} r_i \\cdot \\gone{\\sum_{j = 1}^{t_j} \\gamma_i^{j -\n               1} c_{i, j} - \\sum{j = 1}^{t_j} s_{i, j}} \\bullet \\gtwo{1} + } }\n \t\t\\end{pchstack}\n \t\\end{pcvstack}\n\n \t\\caption{$\\PCOMs$ polynomial commitment scheme.}\n \t\\label{fig:pcoms}\n \\end{figure}\n\n\n\n\\oursubsub{The constraint system}\n\\label{sec:sonic_constraint_system}\n\\sonic's system of constraints composes of three $\\multconstr$-long vectors\n$\\va, \\vb, \\vc$ which corresponds to left and right inputs to multiplication\ngates and their outputs. It hence holds $\\va \\cdot \\vb = \\vc$.\n\nThere is also $\\linconstr$ linear constrains of the form\n\\[\n  \\va \\vec{u_q} + \\vb \\vec{v_q} + \\vc \\vec{w_q} = k_q,\n\\]\nwhere $\\vec{u_q}, \\vec{v_q}, \\vec{w_q}$ are vectors for the $q$-th linear\nconstraint with instance value $k_q \\in \\FF_p$. Furthermore define polynomials\n\\begin{equation}\n  \\begin{split}\n    \\p{u_i}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} u_{q, i}\\,,\\\\\n    \\p{v_i}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} v_{q, i}\\,,\\\\\n  \\end{split}\n  \\qquad\n  \\begin{split}\n    \\p{w_i}(Y) & = -Y^i - Y^{-i} + \\sum_{q = 1}^\\linconstr Y^{q +\n      \\multconstr} w_{q, i}\\,,\\\\\n    \\p{k}(Y) & = \\sum_{q = 1}^\\linconstr Y^{q + \\multconstr} k_{q}.\n  \\end{split}\n\\end{equation}\n\n$\\sonic$ constraint system requires that\n\\begin{align}\n  \\label{eq:sonic_constraint}\n  \\vec{a}^\\top \\cdot \\vec{\\p{u}} (Y) + \\vec{b}^\\top \\cdot \\vec{\\p{v}} (Y) +\n  \\vec{c}^\\top \\cdot \\vec{\\p{w}} (Y) + \\sum_{i = 1}^{\\multconstr} a_i b_i (Y^i +\n  Y^{-i}) - \\p{k} (Y) = 0.\n\\end{align}\n\nIn \\sonic{} we will use commitments to the following polynomials.\n\\begin{align*}\n  \\pr(X, Y) & = \\sum_{i = 1}^{\\multconstr} \\left(a_i X^i Y^i + b_i X^{-i} Y^{-i}\n              + c_i X^{-i - \\multconstr} Y^{-i - \\multconstr}\\right) \\\\\n  \\p{s}(X, Y) & = \\sum_{i = 1}^{\\multconstr} \\left( u_i (Y) X^{-i} +\n                v_i(Y) X^i + w_i(Y) X^{i + \\multconstr}\\right)\\\\\n  \\pt(X, Y) & = \\pr(X, 1) (\\pr(X, Y) + \\p{s}(X, Y)) - \\p{k}(Y)\\,.\n\\end{align*}\n\nPolynomials $\\p{r} (X, Y), \\p{s} (X, Y), \\p{t} (X, Y)$ are designed such that\n$\\p{t} (0, Y) = \\vec{a}^\\top \\cdot \\vec{\\p{u}} (Y) + \\vec{b}^\\top \\cdot\n\\vec{\\p{v}} (Y) + \\vec{c}^\\top \\cdot \\vec{\\p{w}} (Y) + \\sum_{i =\n  1}^{\\multconstr} a_i b_i (Y^i + Y^{-i}) - \\p{k} (Y) $. That is, the prover is\nasked to show that $\\p{t} (0, Y) = 0$, cf.~\\cref{eq:sonic_constraint}.\n\nFurthermore, the commitment system in $\\sonic$ is designed such that it is\ninfeasible for a $\\ppt$ algorithm to commit to a polynomial with non-zero\nconstant term.\n\n\\oursubsub{Algorithms rolled out}\n\\ourpar{$\\sonic$ SRS generation $\\kgen(\\REL)$.} The SRS generating algorithm picks\nrandomly $\\alpha, \\chi \\sample \\FF_p$ and outputs\n\t\\[\n      \\srs = \\left( \\gone{\\smallset{\\chi^i}_{i = -\\dconst}^{\\dconst},\n          \\smallset{\\alpha \\chi^i}_{i = -\\dconst, i \\neq 0}^{\\dconst}},\n        \\gtwo{\\smallset{\\chi^i, \\alpha \\chi^i}_{i = - \\dconst}^{\\dconst}},\n        \\gtar{\\alpha} \\right)\n\t\\]\n\\ourpar{$\\sonic$ prover $\\prover(\\srs, \\inp, \\wit=\\va, \\vb, \\vc)$.}\n\\begin{description}\n\\item[Round 1] The prover picks randomly randomisers\n  $c_{\\multconstr + 1}, c_{\\multconstr + 2}, c_{\\multconstr + 3}, c_{\\multconstr\n    + 4} \\sample \\FF_p$. Sets\n  $\\pr(X, Y) \\gets \\pr(X, Y) + \\sum_{i = 1}^4 c_{\\multconstr + i} X^{- 2\n    \\multconstr - i}$. Commits to $\\pr(X, 1)$ and outputs\n  $\\gone{r} \\gets \\com(\\srs, \\multconstr, \\pr(X, 1))$.  Then it gets challenge $y$ from\n  the verifier.\n\\item[Round 2] $\\prover$ commits to $\\pt(X, y)$ and outputs\n  $\\gone{t} \\gets \\com(\\srs, \\dconst, \\pt(X, y))$. Then it gets a challenge $z$ from\n  the verifier.\n\\item[Round 3] The prover computes commitment openings. That is, it outputs\n  \\begin{align*}\n    \\gone{o_a} & = \\open(\\srs, z, \\pr(z, 1), \\pr(X, 1)) \\\\\n    \\gone{o_b} & = \\open(\\srs, yz, \\pr(yz, 1), \\pr(X, 1)) \\\\\n    \\gone{o_t} & = \\open(\\srs, z, \\pt(z, y), \\pt(X, y)) \n  \\end{align*}\n  along with evaluations $a' = \\pr(z, 1), b' = \\pr(y, z), t' = \\pt(z, y)$.  Then it\n  engages in the signature of correct computation playing the role of the\n  helper, i.e.~it commits to $\\p{s}(X, y)$ and sends the commitment $\\gone{s}$, commitment opening\n  \\begin{align*}\n    \\gone{o_s} & = \\open(\\srs, z, \\p{s}(z, y), \\p{s}(X, y)), \\\\\n  \\end{align*} and $s'=\\p{s}(z, y)$. \n%\n  Then\n  it obtains a challenge $u$ from the verifier.\n\\item[Round 4] In the next round the prover computes\n  $\\gone{c} \\gets \\com(\\srs, \\dconst, \\p{s}(u, Y))$ and\n  computes commitments' openings\n  \\begin{align*}\n    \\gone{w} & = \\open(\\srs, u, \\p{s}(u, y), \\p{s}(X, y)), \\\\\n    \\gone{q_y} & = \\open(\\srs, y,\\p{s}(u, y), \\p{s}(u, Y)),\n  \\end{align*}\n  and returns $\\gone{w}, \\gone{q_y}, s = \\p{s}(u, y)$. Eventually the prover gets the last challenge\n  from the verifier---$z'$.\n\\item[Round 5] In the final round, $\\prover$ computes opening\n  $\\gone{q_{z'}} = \\open(\\srs, z', \\p{s}(u, z'), \\p{s}(u, X))$ and outputs $\\gone{q_{z'}}$.\n\\end{description}\n\n\\ourpar{$\\sonic$ verifier $\\verifier(\\srs, \\inp, \\zkproof)$.} The verifier\nin \\sonic{} runs as subroutines the verifier for the polynomial commitment. That\nis it sets $t' = a'(b' + s') - \\p{k}(y)$ and checks the following:\n\\begin{equation*}\n  \\begin{split}\n    &\\PCOMs.\\verifier(\\srs, \\multconstr, \\gone{r}, z, a', \\gone{o_a}), \\\\\n    &\\PCOMs.\\verifier(\\srs, \\multconstr, \\gone{r}, yz, b', \\gone{o_b}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{t}, z, t', \\gone{o_t}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{s}, z, s', \\gone{o_s}),\\\\\n  \\end{split}\n  \\qquad\n  \\begin{split}\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{s}, u, s, \\gone{w}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{c}, y, s, \\gone{q_y}),\\\\\n    &\\PCOMs.\\verifier(\\srs, \\dconst, \\gone{c}, z', \\p{s}(u, z'), \\gone{q_{z'}}),\n  \\end{split}\n\\end{equation*}\nand accepts the proof iff all the checks holds. Note that the value\n$\\p{s}(u, z')$ that is recomputed by the verifier uses separate challenges $u$\nand $z'$. This enables the batching of many proof and outsourcing of this\npart of the proof to an untrusted helper.\n\n\\subsection{Unique opening property of $\\PCOMs$}\n\\begin{lemma}\n\\label{lem:pcoms_unique_op}\n$\\PCOMs$ has the unique opening property in the AGM. \n\\end{lemma}\n\\begin{proof}\nLet \n$z \\in \\FF_p$ be the attribute the polynomial is evaluated at,\n$\\gone{c} \\in \\GRP$ be the commitment,  \n$s \\in \\FF_p$ the evaluation value, and \n$o \\in \\GRP$ be the commitment opening. \nWe need to show that for every $\\ppt$ adversary $\\adv$ probability\n\\[\n  \\Pr \\left[\n    \\begin{aligned}\n      & \\verify(\\srs, \\gone{c}, z, s, \\gone{o}) = 1, \\\\\n      & \\verify(\\srs, \\gone{c}, z, \\tilde{s}, \\gone{\\tilde{o}}) = 1\n    \\end{aligned}\n    \\,\\left|\\, \\vphantom{\\begin{aligned}\n          & \\verify(\\srs, \\gone{c}, z, s, \\gone{o}),\\\\\n          & \\verify(\\srs, \\gone{c}, z, s, \\gone{\\tilde{o}}) \\\\\n          &o \\neq \\tilde{o})\n\t\t\\end{aligned}}\n      \\begin{aligned}\n        %& \\srs \\gets \\kgen(\\secparam, \\maxdeg), \\\\\n        & (\\gone{c}, z, s, \\gone{o}, \\gone{\\tilde{o}}) \\gets \\adv^{\\initU}(1^\\secpar, \\maxdeg)\n      \\end{aligned}\n    \\right.\\right]\n  % \\leq \\negl.\n\\]\nis at most negligible.\n\nAs noted in \\cite[Lemma 2.2]{EPRINT:GabWilCio19} it is enough to upper bound the\nprobability of the adversary succeeding using the idealised verification\nequation---which considers equality between polynomials---instead of the real\nverification equation---which considers equality of the polynomials' evaluations.\n\nFor a polynomial $f$, its degree upper bound $\\maxconst$, evaluation point $z$,\nevaluation result $s$, and opening $\\gone{o(X)}$ the idealised check verifies that\n\\begin{equation}\n  \\alpha (X^{\\dconst - \\maxconst}f(X) \\cdot X^{-\\dconst + \\maxconst} -  s) \\equiv \\alpha \\cdot o(X) (X - z)\\,,\n\\end{equation}\nwhat is equivalent to \n\\begin{equation}\n\tf(X) -  s \\equiv o(X) (X - z)\\,.\n\t\\label{eq:pcoms_idealised_check}\n\\end{equation}\nSince $o(X)(X - z) \\in \\FF_p[X]$ then from the uniqueness of polynomial\ncomposition, there is only one $o(X)$ that fulfils the equation above.\n\\qed\n\\end{proof}\n\n\n\\subsection{Unique response property}\nThe unique response property of $\\sonicprot$ follows from the unique opening\nproperty of the used polynomial commitment scheme $\\PCOMs$.\n\\begin{lemma}\n\\label{lem:sonicprot_ur}\nIf a polynomial commitment scheme $\\PCOMs$ is evaluation binding with\nparameter $\\epsbind(\\secpar)$ and has unique openings property with parameter\n$\\epsop(\\secpar)$, then $\\sonicprot$ is $\\ur{1}$ with parameter $\\epsur(\\secpar) \\leq\n\\epsbind(\\secpar) + \\epsop(\\secpar)$.  \n\\end{lemma}\n\\begin{proof}\n  Let $\\adv$ be an adversary that breaks $\\ur{1}$-ness of $\\sonicprot$.  We\n  consider two cases, depending on which round $\\adv$ is able to provide at\n  least two different outputs such that the resulting transcripts are\n  acceptable.  For the first case we show that $\\adv$ can be used to break the\n  evaluation binding property of $\\PCOMs$, while for the second case we show\n  that it can be used to break the unique opening property of $\\PCOMs$.\n\n  The proof goes similarly to the proof of \\cref{lem:plonkprot_ur} thus we\n  provide only draft of it here.  In each Round $i$, for $i > 1$, the prover\n  either commits to some well-defined polynomials (deterministically), evaluates\n  these on randomly picked points, or shows that the evaluations were performed\n  correctly.  Obviously, for a committed polynomial $\\p{p}$ evaluated at point\n  $x$ only one value $y = \\p{p}(x)$ is correct. If the adversary was able to\n  provide two different values $y$ and $\\tilde{y}$ that would be accepted as an\n  evaluation of $\\p{p}$ at $x$ then the $\\PCOMs$'s evaluation binding would be\n  broken.  Alternatively, if $\\adv$ was able to provide two openings $\\p{W}$ and\n  $\\p{\\tilde{W}}$ for $y = \\p{p}(x)$ then the unique opening property would be\n  broken.\n%\nHence the probability that $\\adv$ breaks $\\ur{1}$-property of $\\PCOMs$ is\nupper-bounded by $\\epsbind(\\secpar) + \\epsop(\\secpar)$. \n\\qed\n\n\\end{proof}\n\n\\subsection{Forking special soundness}\n\\begin{lemma}\n\t\\label{lem:sonicprot_ss}\n\t$\\sonicprot$ is $(\\epsss(\\secpar), 2, \\multconstr + \\linconstr + 1)$-forking special sound against\n\talgebraic adversaries with\n\t\\[\n\t\\epss(\\secpar) \\leq \\epsid(\\secpar) + \\epsldlog(\\secpar) \\,,\n\t\\]\n\twhere $\\epsid(\\secpar)$ is a soundness error of the idealized verifier, and\n\t$\\epsldlog(\\secpar)$ is security of $(\\dconst, \\dconst)$-$\\ldlog$ assumption.\n\\end{lemma}\n\\begin{proof}\n\tSimilarly as in the case of $\\plonk$, the main idea of the proof is to show\n\tthat an adversary who breaks forking special soundness can be used to break a $\\dlog$ problem\n\tinstance. The proof goes by game hops. Let $\\tree$ be the tree produced by\n\t$\\tdv$ by rewinding $\\adv$. Note that since the tree branches after Round 2,\n\tthe instance $\\inp$, commitments\n\t$\\gone{\\p{r} (\\chi, 1), \\p{r} (\\chi, y), \\p{s} (\\chi, y), \\p{t} (\\chi, y)}$, and challenge\n\t$y$ are the same. The tree branches after the second round\n\tof the protocol where the challenge $z$ is presented, thus tree $\\tree$ is\n\tbuild using different values of $z$.\n\t%\n\tWe consider the following games.\n\t\n\t\\ncase{Game 0} In this game the adversary wins if all the transcripts it\n\tproduced are acceptable by the ideal verifier,\n\ti.e.~$\\vereq_{\\inp, \\zkproof}(X) = 0$, cf.~\\cref{eq:ver_eq}, and none of\n\tcommitments\n\t$\\gone{\\p{r} (\\chi, 1), \\p{r} (\\chi, y), \\p{s} (\\chi, y), \\p{t} (\\chi, y)}$ use\n\telements from a simulated proof, and the extractor fails to extract a valid\n\twitness out of the proof.\n\t\n\t\\ncase{Probability that $\\adv$ wins Game 0 is negligible} Probability of\n\t$\\adv$ winning this game is $\\epsid(\\secpar)$ as the protocol $\\sonicprot$,\n\tinstantiated with the idealised verification equation, is perfectly\n\tknowledge sound except with negligible probability of the idealised verifier\n\tfailure $\\epsid(\\secpar)$. Hence for a valid proof $\\zkproof$ for a\n\tstatement $\\inp$ there exists a witness $\\wit$, such that $\\REL(\\inp, \\wit)$\n\tholds. Note that since the $\\tdv$ produces $(\\multconstr + \\linconstr + 1)$\n\tacceptable transcripts for different challenges $z$. As noted in\n\t\\cite{CCS:MBKM19} this assures that the correct witness is encoded in\n\t$\\p{r} (X, Y)$. Hence $\\extt$ can recreate polynomials' coefficients by\n\tinterpolation and reveal the witness with probability $1$. Moreover, the\n\tprobability that extraction fails in that case is upper-bounded by\n\tprobability of an idealised verifier failing $\\epsid(\\secpar)$, which is\n\tnegligible.\n\t\n\t\\ncase{Game 1} In this game the adversary additionally wins if it produces a\n\ttranscript in $\\tree$ such that $\\vereq_{\\inp, \\zkproof}(\\chi) = 0$, but\n\t$\\vereq_{\\inp, \\zkproof}(X) \\neq 0$, and none of commitments\n\t$\\gone{\\p{r} (\\chi, 1), \\p{r} (\\chi, y), \\p{s} (\\chi, y), \\p{t} (\\chi, y)}$\n\tuse elements from a simulated proof.  The first condition means that the\n\tideal verifier does not accept the proof, but the real verifier does.\n\t\n\t\\ncase{Game 0 to Game 1} Assume the adversary wins in Game 1, but does not\n\twin in Game 0. We show that such adversary may be used to break an\n\tinstance of a $\\ldlog$ assumption. More precisely, let $\\tdv$ be an\n\talgorithm that for relation $\\REL$ and randomly picked\n\t$\\srs \\sample \\kgen(\\REL)$ produces a tree of acceptable transcripts such\n\tthat the winning condition of the game holds. Let $\\rdvdlog$ be a\n\treduction that gets as input an\n\t$(\\dconst, \\dconst)$-ldlog instance\n\t$\\gone{\\chi^{-\\dconst}, \\ldots, \\chi^{\\dconst}}, \\gtwo{\\chi^{-\\dconst},\n\t\t\\ldots, \\chi^{\\dconst}}$ and is tasked to output $\\chi$.\n\t\n\tThe reduction $\\rdvdlog$ proceeds as follows.\n\t\\begin{enumerate}\n  \\item Pick a random $\\alpha$ and compute\n    $\\gone{\\alpha \\chi^{- \\dconst}, \\ldots, \\alpha \\chi^{-1}, \\alpha \\chi,\n      \\ldots, \\alpha \\chi^{\\dconst}}$,\n    $\\gtwo{\\alpha \\chi^{- \\dconst}, \\ldots, \\alpha \\chi^{-1}, \\alpha \\chi,\n      \\ldots, \\alpha \\chi^{\\dconst}}$. Set a SRS $\\srs$ to be the\n    $(\\dconst, \\dconst)$-ldlog instance and its multiplication with $\\alpha$ as\n    computed above.\n    % \\hamid{Is this clear?}\n  \\item Build $\\sonicprot$'s SRS in the updatable setting by answering $\\adv$'s\n    queries for SRS updates and setting the honest update of the SRS to be\n    $\\srs$. Let $\\srs'$ be the finalised SRS.\n\t\t\\item Let $(1, \\tree)$ be the output returned by $\\tdv$. Let $\\inp$ be a\n\t\trelation proven in $\\tree$.  Consider a transcript $\\zkproof \\in \\tree$ such\n\t\tthat $\\vereq_{\\inp, \\zkproof}(X) \\neq 0$, but\n\t\t$\\vereq_{\\inp, \\zkproof}(\\chi') = 0$. Since $\\adv$ is algebraic, all group\n\t\telements included in $\\tree$ are extended by their representation as a\n\t\tcombination of the input $\\GRP_1$-elements. Hence, all coefficients of the\n\t\tverification equation polynomial $\\vereq_{\\inp, \\zkproof}(X)$ are known.\n\t\t\\item Find $\\vereq_{\\inp, \\zkproof}(X)$ zero points and find $\\chi'$ among\n\t\tthem.\n  \\item Let $\\chi_1, \\ldots, \\chi_\\ell$ be the partial trapdoors of $\\adv$'s SRS\n    updates, extracted by the reduction from the update proofs given by $\\adv$.\n\t\t\\item Return  $\\chi = \\chi' (\\chi_1 \\chi_2 \\ldots \\chi_\\ell)^{-1}$.\n\t\\end{enumerate}\n\tHence, the probability that the adversary wins Game 1 is upper-bounded by\n\t$\\epsldlog(\\secpar)$.\n\\end{proof}\n\n\\subsection{Trapdoor-less simulatability of Sonic}\n\\begin{lemma}\n\\label{lem:sonic_hvzk}\n$\\sonic$ is 2-progrmmable trapdoor-less simulatable.\n\\end{lemma}\n\\begin{proof}\n  The simulator proceeds as follows.\n  \\begin{enumerate}\n  \\item Pick randomly vectors $\\vec{a}$, $\\vec{b}$ and set\n    \\begin{equation}\n      \\label{eq:ab_eq_c}\n      \\vec{c} = \\vec{a} \\cdot \\vec{b}. \n    \\end{equation}\n  \\item Pick randomisers $c_{\\multconstr + 1}, \\ldots, c_{\\multconstr + 4}$,\n    honestly compute polynomials $\\p{r}(X, Y), \\p{r'}(X, Y), \\p{s}(X, Y)$ and\n    pick randomly challenges $y$, $z$.\n  \\item Output commitment $\\gone{r} \\gets \\com(\\srs, \\multconstr, \\p{r} (X,\n    1))$ and challenge $y$. \n  \\item Compute\n    \\begin{align*}\n      & a' = \\p{r}(z, 1),\\\\\n      & b' = \\p{r}(z, y),\\\\\n      & s' = \\p{s}(z, y).\n    \\end{align*} \n  \\item Pick polynomial $\\p{t}(X, Y)$ such that\n    \\begin{align*}\n      & \\p{t} (X, y) = \\p{r} (X, 1) (\\p{r}(X, y) + \\p{s} (X, y)) - \\p{k} (Y)\\\\\n      & \\p{t} (0, y) = 0\n    \\end{align*}\n  \\item Output commitment $\\gone{t} = \\com (\\srs, \\dconst, \\p{t} (X, y))$ and\n    challenge $z$.\n  \\item Continue following the protocol.\n  \\end{enumerate}\n\n  We note that the simulation is perfect. This comes since, except polynomial\n  $\\p{t} (X, Y)$ all polynomials are computed following the protocol. For\n  polynomial $\\p{t} (X, Y)$ we observe that in a case of both real and simulated\n  proof the verifier only learns commitment $\\gone{t} = \\p{t} (\\chi, y)$ and\n  evaluation $t' = \\p{t} (z, y)$. Since the simulator picks $\\p{t} (X, Y)$ such\n  that \n  \\begin{align*}\n      \\p{t} (X, y) = \\p{r} (X, 1) (\\p{r}(X, y) + \\p{s} (X, y)) - \\p{k} (Y)\n  \\end{align*}\n  Values of $\\gone{t}$ are equal in both proofs.\n  Furthermore, the simulator picks its polynomial such that $\\p{t}(0, y) = 0$,\n  hence it does not need the trapdoor to commit to it. (Note that the proof\n  system's SRS does not allow to commit to polynomials which have non-zero\n  constant term). \\qed\n\\end{proof}\n\\begin{remark} \n  As noted in \\cite{CCS:MBKM19}, $\\sonic$ is statistically subversion-zero\n  knowledge (Sub-ZK). As noted in \\cite{AC:ABLZ17}, one way to achieve\n  subversion zero knowledge is to utilise an extractor that extracts a SRS\n  trapdoor from a SRS-generator. Unfortunately, a NIZK made subversion\n  zero-knowledge by this approach cannot achieve perfect Sub-ZK as one has to\n  count in the probability of extraction failure. However, with the simulation\n  presented in \\cref{lem:sonic_hvzk}, the trapdoor is not required for the\n  simulator as it is able to simulate the execution of the protocol just by\n  picking appropriate (honest) verifier's challenges. This result transfers to\n  $\\sonicprotfs$, where the simulator can program the random oracle to provide\n  challenges that fits it.\n\\end{remark}\n\n\\subsection{From forking special soundness and unique response property to \\COMMENT{forking\n  }simulation extractability of $\\sonicprotfs$}\nSince \\cref{lem:sonicprot_ur,lem:sonicprot_ss} hold, $\\sonicprot$ is $\\ur{1}$\nand forking special sound. We now make use\nof \\cref{thm:se} and show that $\\sonicprotfs$ is \\COMMENT{ forking }simulation-extractable as defined in \\cref{def:simext}.\n\n\\begin{corollary}[\\COMMENT{Forking s}Simulation extractability of $\\sonicprotfs$]\n  \\label{thm:sonicprotfs_se}\n  Assume that $\\sonicprot$ is $\\ur{1}$ with security\n  $\\epsur(\\secpar) = \\epsbind(\\secpar) + \\epsop(\\secpar)$ -- where\n  $\\epsbind (\\secpar)$ is polynomial commitment's binding security, $\\epsop$ is\n  polynomial commitment unique opening security -- and forking-sound with\n  security $\\epsss(\\secpar)$. Let $\\ro\\colon \\bin^* \\to \\bin^\\secpar$ be a\n  random oracle. Let $\\advse$ be an adversary that can make up to $q$\n  random oracle queries, up to $S$ simulation oracle queries, and outputs an\n  acceptable proof for $\\sonicprotfs$ with probability at least $\\accProb$. Then\n  $\\sonicprotfs$ is \\COMMENT{forking }simulation-extractable with extraction error\n  $\\eta = \\epsur(\\secpar)$. The extraction probability $\\extProb$ is at least\n\\[\n\t\t\\extProb  \\geq \\frac{1}{q^{\\multconstr + \\linconstr}} (\\accProb - \\epsur(\\secpar))^{\\multconstr +\n\t\t\\linconstr + 1} - \\eps(\\secpar).\n\t\\]\n\tfor some negligible $\\eps(\\secpar)$, $\\multconstr$ and $\\linconstr$ being,\n  respectively, the number of multiplicative and linear constrains of the system.\n\\end{corollary}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "48960208b71e60e3bbee0b724bc4e4afa1cfd580", "size": 21602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ECsubmission/080-non-malleability-of-sfs.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ECsubmission/080-non-malleability-of-sfs.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ECsubmission/080-non-malleability-of-sfs.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.356223176, "max_line_length": 127, "alphanum_fraction": 0.6448476993, "num_tokens": 7581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.42049287901864013}}
{"text": "% !TEX root = ../main.tex\n%-------------------------------------------------------------------------------\n\\section{Computational implementation}\\label{Computational implementation}\n%-------------------------------------------------------------------------------\nWe use the same computational implementation as in \\citet{Keane.1997}. We outline the immediate utility functions for each of the five alternatives. We first focus on their common overall structure and then present their parameterization. Throughout we provide the economic motivation for their specification.\\\\\n\n\\noindent We follow individuals over their working life from young adulthood at age 16 to retirement at age 65. The decision period $t = 16, \\dots, 65$  is a school year and individuals decide $a\\in\\mathcal{A}$ whether to work in a blue-collar or white-collar occupation ($a = 1, 2$), to serve in the military $(a = 3)$, to attend school $(a = 4)$, or to stay at home $(a = 5)$.\\\\\n\n\\noindent Individuals are initially heterogeneous. They differ with respect to their initial level of completed schooling $h_{16}$ and have one of four different $\\mathcal{J} = \\{1, \\hdots, 4\\}$ alternative-specific skill endowments $\\bm{e} = \\left(e_{j,a}\\right)_{\\mathcal{J} \\times \\mathcal{A}}$.\\\\\n\n\\noindent The immediate utility $u_a(\\cdot)$ of each alternative consists of a non-pecuniary utility $\\zeta_a(\\cdot)$ and, at least for the working alternatives, an additional wage component $w_a(\\cdot)$. Both depend on the level of human capital as measured by their alternative-specific skill endowment $\\bm{e}$, years of completed schooling $h_t$, and occupation-specific work experience $\\bm{k_t} = \\left(k_{a,t}\\right)_{a\\in\\{1, 2, 3\\}}$. The immediate utility functions are influenced by last-period choices $a_{t -1}$ and alternative-specific productivity shocks $\\bm{\\epsilon_t} = \\left(\\epsilon_{a,t}\\right)_{a\\in\\mathcal{A}}$ as well. Their general form is given by:\n%\n\\begin{align*}\nu_a(\\cdot) =\n\\begin{cases}\n    \\zeta_a(\\bm{k_t}, h_t, t, a_{t -1})  + w_a(\\bm{k_t}, h_t, t, a_{t -1}, e_{j, a}, \\epsilon_{a,t})                & \\text{if}\\, a \\in \\{1, 2, 3\\}  \\\\\n    \\zeta_a(\\bm{k_t}, h_t, t, a_{t-1}, e_{j,a}, \\epsilon_{a,t})                                                  &  \\text{if}\\, a \\in \\{4, 5\\}.\n\\end{cases}\n\\end{align*}\n%\nWork experience $\\bm{k_t}$  and years of completed schooling $h_t$ evolve deterministically.\n%\n\\begin{align*}\nk_{a,t+1} = k_{a,t} + \\ind[a_t = a]  &\\qquad \\text{if}\\, a \\in \\{1, 2, 3\\} \\\\\nh_{t + 1\\phantom{,a}} = h_{t\\phantom{,a}} +   \\ind[a_t = 4]  &\\qquad\n\\end{align*}\n%\n\\noindent The productivity shocks are uncorrelated across time and follow a multivariate normal distribution with mean $\\bm{0}$ and covariance matrix $\\bm{\\Sigma}$. Given the structure of the utility functions and the distribution of the shocks, the state at time $t$ is $s_t = \\{\\bm{k_t}, h_t, t, a_{t -1}, \\bm{e},\\bm{\\epsilon_t}\\}$.\\\\\n\n\\noindent Empirical and theoretical research from specialized disciplines within economics informs the exact specification of $u_a(\\cdot)$. We now discuss each of its components in detail.\n%-------------------------------------------------------------------------------\n\\subsection{Non-pecuniary utility}\n%-------------------------------------------------------------------------------\nWe present the parameterization of the non-pecuniary utility for all five alternatives.\n%-------------------------------------------------------------------------------\n\\subsubsection*{Blue-collar}\n%-------------------------------------------------------------------------------\n\\noindent Equation (\\ref{eq:NonWageBLueCollar}) shows the parameterization of the non-pecuniary utility from working in a blue-collar occupation.\n%\n\\begin{align}\\label{eq:NonWageBLueCollar}\n\\zeta_{1}(\\bm{k_t}, h_t, a_{t-1})  = \\alpha_1  &+ c_{1,1} \\cdot \\ind[a_{t-1} \\neq 1] + c_{1,2} \\cdot \\ind[k_{1,t} = 0] \\\\ \\nonumber\n                            & + \\vartheta_1 \\cdot \\ind[h_t \\geq 12] + \\vartheta_2 \\cdot \\ind[h_t \\geq 16] + \\vartheta_3 \\cdot \\ind[k_{3,t} = 1]\n\\end{align}\n%\nA constant $\\alpha_1$ captures the net monetary-equivalent of on the job amenities. The non-pecuniary utility includes mobility and search costs $c_{1,1}$, which are higher for individuals who never worked in a blue-collar occupation before $c_{1,2}$. The non-pecuniary utilities capture returns from a high school $\\vartheta_1$ and a college $\\vartheta_2$ degree. Additionally, there is a detrimental effect of leaving the military early after one year $\\vartheta_3$.\n%-------------------------------------------------------------------------------\n\\subsubsection*{White-collar}\n%-------------------------------------------------------------------------------\nThe non-pecuniary utility from working in a white-collar occupation is specified analogously. Equation (\\ref{eq:UtilityWhiteCollar}) shows its parameterization.\n%\n\\begin{align}\\label{eq:UtilityWhiteCollar}\n\\zeta_{2}( \\bm{k_t}, h_t, a_{t-1} ) = \\,\\alpha_2 & + c_{2,1} \\cdot \\ind[a_{t-1} \\neq 2] + c_{2,2} \\cdot \\ind[k_{2,t} = 0]\\\\\\nonumber\n                            & + \\vartheta_1 \\cdot \\ind[h_t \\geq 12] + \\vartheta_2 \\cdot \\ind[h_t \\geq 16] + \\vartheta_3 \\cdot \\ind[k_{3,t} = 1]\n\\end{align}\n%-------------------------------------------------------------------------------\n\\subsubsection*{Military}\n%-------------------------------------------------------------------------------\n\\noindent Equation (\\ref{eq:UtilityMilitary}) shows the parameterization of the non-pecuniary utility from working in the military.\n%\n\\begin{align}\\label{eq:UtilityMilitary}\n\\zeta_{3}( k_{3.t}, h_t)  = \\,& c_{3,2} \\cdot \\ind[k_{3,t} = 0]+ \\vartheta_1 \\cdot \\ind[h_t \\geq 12] + \\vartheta_2 \\cdot \\ind[h_t \\geq 16]\n\\end{align}\n%\nSearch costs $c_{3, 1} = 0$ are absent but there is a mobility cost if an individual has never served in the military before $c_{3,2}$. Individuals still experience a non-pecuniary utility from finishing high-school $\\vartheta_1$ and college $\\vartheta_2$.\n%-------------------------------------------------------------------------------\n\\subsubsection*{School}\n%-------------------------------------------------------------------------------\nEquation (\\ref{eq:UtilitySchooling}) shows the parameterization of the non-pecuniary utility from schooling.\n%\n\\begin{align}\\label{eq:UtilitySchooling}\n\t\\zeta_4(k_{3,t}, h_t, t, a_{t-1}, e_{j,4}, \\epsilon_{4,t})  = e_{j,4} & + \\beta_{tc_1} \\cdot \\ind[h_t \\geq 12] + \\beta_{tc_2} \\cdot \\ind[h_t \\geq 16]   \\\\\\nonumber\n    \t\t\t\t\t\t\t  & + \\beta_{rc_1} \\cdot \\ind[a_{t-1} \\neq 4, h_t < 12] + \\beta_{rc_2} \\cdot \\ind[a_{t-1} \\neq 4, h_t \\geq 12] \\\\\\nonumber\n    \t\t\t\t\t\t\t  & + \\gamma_{4,4} \\cdot t + \\gamma_{4,5} \\cdot \\ind[t < 18] \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \\\\\\nonumber\n     \t\t\t\t\t\t\t  & + \\vartheta_1 \\cdot \\ind[h_t \\geq 12] + \\vartheta_2 \\cdot \\ind[h_t \\geq 16] + \\vartheta_3 \\cdot \\ind[k_{3,t} = 1]\\\\\\nonumber\n      \t\t\t\t\t\t\t& + \\epsilon_{4,t}\n\\end{align}\n%\nThere is a direct cost of attending school such as tuition for continuing education after high school $\\beta_{tc_1}$ and college $\\beta_{tc_2}$. The decision to leave school is reversible, but entails adjustment costs that differ by schooling category ($\\beta_{rc_1}, \\beta_{rc_2}$). Schooling is defined as time spent in school and not by formal credentials acquired. Once individuals reach a certain amount of schooling, they acquire a degree. There is no uncertainty about grade completion \\citep{Altonji.1993} and no part-time enrollment. Individuals value the completion of high-school and graduate school ($\\vartheta_1, \\vartheta_2$).\n%-------------------------------------------------------------------------------\n\\subsubsection*{Home}\n%-------------------------------------------------------------------------------\nEquation (\\ref{eq:UtilityHome}) shows the parameterization of the non-pecuniary utility from staying at home.\n%\n\\begin{align}\\label{eq:UtilityHome}\n\t\\zeta_5(k_{3,t}, h_t, t, e_{j,5}, \\epsilon_{5,1}) =  e_{j,5} & + \\gamma_{5,4} \\cdot \\ind[18 \\leq t \\leq 20] + \\gamma_{5,5} \\cdot \\ind[t \\geq 21] \\\\ \\nonumber\n    \t\t\t\t\t\t\t   & +\\vartheta_{1} \\cdot \\ind[h_t \\geq 12] + \\vartheta_{2} \\cdot \\ind[h_t \\geq 16] +  \\vartheta_3 \\cdot \\ind[k_{3,t} = 1]  \\\\ \\nonumber\n    \t\t\t\t\t\t\t   & + \\epsilon_{5,t}\n\\end{align}\n%\nStaying at home as a young adult $\\gamma_{5, 4}$ is less stigmatic as doing so while already being an adult $\\gamma_{5,5}$. Additionally, possessing a degree  $(\\vartheta_1, \\vartheta_2)$ or leaving the military prematurely $\\vartheta_3$ influences the immediate utility.\n%-------------------------------------------------------------------------------\n\\subsection{Wage component}\n%-------------------------------------------------------------------------------\nThe wage component $w_{a}(\\cdot)$ for the working alternatives is given by the product of the market-equilibrium rental price $r_{a}$ and an occupation-specific skill level $x_{a}(\\cdot)$. The latter is determined by the overall level of human capital.\n%\n\\begin{align*}\nw_{a}(\\cdot) = r_{a} \\, x_{a}(\\cdot)\n\\end{align*}\n%\nThis specification leads to a standard logarithmic wage equation in which the constant term is the skill rental price $\\ln(r_{a})$ and wages follow a log-normal distribution.\\\\\n\n\\noindent The occupation-specific skill level $x_{a}(\\cdot)$ is determined by a skill production function, which includes a deterministic component $\\Gamma_a(\\cdot)$ and a multiplicative stochastic productivity shock $\\epsilon_{a,t}$.\n%\n\\begin{align}\n    x_{a}(\\bm{k_t}, h_t, t, a_{t-1}, e_{j, a}, \\epsilon_{a,t}) & = \\exp \\big( \\Gamma_{a}(\\bm{k_t},  h_t, t, a_{t-1}, e_{j,a}) \\cdot \\epsilon_{a,t} \\big) \\nonumber\n\\end{align}\n%-------------------------------------------------------------------------------\n\\subsubsection*{Blue-collar}\n%-------------------------------------------------------------------------------\nEquation (\\ref{eq:SkillLevelBlueCollar}) shows the parameterization of the deterministic component of the skill production function.\n%\n\\begin{align}\\label{eq:SkillLevelBlueCollar}\n    \\Gamma_1(\\bm{k_t}, h_t, t, a_{t-1}, e_{j, 1}) = e_{j,1} & + \\beta_{1,1} \\cdot h_t + \\beta_{1, 2} \\cdot \\ind[h_t \\geq 12] + \\beta_{1,3} \\cdot \\ind[h_t\\geq 16]\\\\ \\nonumber\n                                  & + \\gamma_{1, 1} \\cdot  k_{1,t} + \\gamma_{1,2} \\cdot  (k_{1,t})^2 + \\gamma_{1,3} \\cdot  \\ind[k_{1,t} > 0] \\\\ \\nonumber\n                                & + \\gamma_{1,4} \\cdot  t + \\gamma_{1,5} \\cdot \\ind[t < 18]\\\\ \\nonumber\n                                  & + \\gamma_{1,6} \\cdot \\ind[a_{t-1} = 1] + \\gamma_{1,7} \\cdot  k_{2,t} + \\gamma_{1,8} \\cdot  k_{3,t} \\nonumber\n\\end{align}\n%\nThere are several notable features. The first part of the skill production function is motivated by \\citet{Mincer.1958, Mincer.1974} and hence linear in years of completed schooling $\\beta_{1,1}$, quadratic in experience ($\\gamma_{1,1}, \\gamma_{1,2}$), and separable between the two of them. There are so-called sheep-skin effects \\citep{Spence.1973, Jaeger.1996} associated with completing a high school $\\beta_{1,2}$ and graduate $\\beta_{1,3}$ education that capture the impact of completing a degree beyond just the associated years of schooling. Also, skills depreciate when not employed in a blue-collar occupation in the preceding period $\\gamma_{1,6}$. Other work experience ($\\gamma_{1,7}, \\gamma_{1,8}$) is transferable.\n%-------------------------------------------------------------------------------\n\\subsubsection*{White-collar}\n%-------------------------------------------------------------------------------\nThe wage component from working in a white-collar occupation is specified analogously. Equation (\\ref{eq:SkillLevelWhiteCollar}) shows the parameterization of the deterministic component of the skill production function.\n%\n\\begin{align}\\label{eq:SkillLevelWhiteCollar}\n    \\Gamma_2(\\bm{k_t}, h_t, t, a_{t-1}, e_{j,2}) = e_{j,2} & + \\beta_{2,1} \\cdot h_t + \\beta_{2, 2} \\cdot \\ind[h_t \\geq 12] + \\beta_{2,3} \\cdot \\ind[h_t\\geq 16] \\\\\\nonumber\n    \t\t\t\t\t\t\t & + \\gamma_{2, 1} \\cdot  k_{2,t} + \\gamma_{2,2} \\cdot  (k_{2,t})^2 + \\gamma_{2,3} \\cdot  \\ind[k_{2,t} > 0] \\\\\\nonumber\n                                   & + \\gamma_{2,4} \\cdot  t + \\gamma_{2,5} \\cdot \\ind[t < 18] \\\\\\nonumber\n                                  & + \\gamma_{2,6} \\cdot  \\ind[a_{t-1} = 2]  + \\gamma_{2,7} \\cdot  k_{1,t} + \\gamma_{2,8} \\cdot  k_{3,t}\n\\end{align}\n%-------------------------------------------------------------------------------\n\\subsubsection*{Military}\n%-------------------------------------------------------------------------------\nEquation (\\ref{eq:SkillLevelMilitary}) shows the parameterization of the deterministic component of the skill production function.\n%\n\\begin{align}\\label{eq:SkillLevelMilitary}\n    \\Gamma_3( k_{3,t}, h_t, t, e_{j,3}) = e_{j,3} & + \\beta_{3,1} \\cdot h_t \\\\\\nonumber\n\t               \\nonumber &+ \\gamma_{3,1} \\cdot  k_{3,t} + \\gamma_{3,2} \\cdot (k_{3,t})^2 + \\gamma_{3,3} \\cdot \\ind[k_{3,t} > 0]\\\\\\nonumber\n\t\t\t\t\t\t\t\t\t & + \\gamma_{3,4} \\cdot t + \\gamma_{3,5} \\cdot \\ind[t < 18]\n\\end{align}\n%\nContrary to the civilian sector there are no sheep-skin effects from graduation ($\\beta_{3,2} = \\beta_{3,3}= 0$). The previous occupational choice has no influence ($\\gamma_{3,6}= 0$) and any experience other than military is non-transferable ($\\gamma_{3,7} = \\gamma_{3,8} = 0$).\n\n\\begin{Remark} Our parameterization for the immediate utility of serving in the military differs from \\citet{Keane.1997} as we remain unsure about their exact specification. The authors state in Footnote 31 (p.498) that the constant for the non-pecuniary utility $\\alpha_{3,t}$ depends on age. However, we are unable to determine the precise nature of the relationship. Equation (C3) (p.521) also indicates no productivity shock $\\epsilon_{a,t}$ in the wage component. Table 7 (p.500) reports such estimates.\n\\end{Remark}\n%-------------------------------------------------------------------------------\n\\FloatBarrier\\subsection{Overview parameters}\n%-------------------------------------------------------------------------------\n\n\\input{../material/tab-model-parameters}\n", "meta": {"hexsha": "3be788128bcc88ad00c8714f87b706638856bb95", "size": 14074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "appendix/sections/s-implementation.tex", "max_stars_repo_name": "jkoenig97/ekw-pres", "max_stars_repo_head_hexsha": "634d9a2de17419d3f04440cdb5640b3a50af7ccd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "appendix/sections/s-implementation.tex", "max_issues_repo_name": "jkoenig97/ekw-pres", "max_issues_repo_head_hexsha": "634d9a2de17419d3f04440cdb5640b3a50af7ccd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "appendix/sections/s-implementation.tex", "max_forks_repo_name": "jkoenig97/ekw-pres", "max_forks_repo_head_hexsha": "634d9a2de17419d3f04440cdb5640b3a50af7ccd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 93.2052980132, "max_line_length": 729, "alphanum_fraction": 0.5891004689, "num_tokens": 3960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.42049287901864013}}
{"text": "Dispersion (DSP) Package information is read from the file that is specified by ``DSP6'' as the file type.  Only one DSP Package can be specified for a GWT model.  The DSP Package is based on the mathematical formulation presented for the XT3D option of the NPF Package available to represent full three-dimensional anisotropy in groundwater flow.  XT3D can be computationally expensive and can be turned off to use a simplified and approximate form of the dispersion equations.  For most problems, however, XT3D will be required to accurately represent dispersion.\n\n\\vspace{5mm}\n\\subsubsection{Structure of Blocks}\n\\lstinputlisting[style=blockdefinition]{./mf6ivar/tex/gwt-dsp-options.dat}\n\\lstinputlisting[style=blockdefinition]{./mf6ivar/tex/gwt-dsp-griddata.dat}\n\n\\vspace{5mm}\n\\subsubsection{Explanation of Variables}\n\\begin{description}\n\\input{./mf6ivar/tex/gwt-dsp-desc.tex}\n\\end{description}\n\n\\vspace{5mm}\n\\subsubsection{Example Input File}\n\\lstinputlisting[style=inputfile]{./mf6ivar/examples/gwt-dsp-example.dat}\n\n", "meta": {"hexsha": "100b5c7b65dd82874b1bd00b12c4cda38047514d", "size": 1023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/mf6io/gwt/dsp.tex", "max_stars_repo_name": "scharlton2/modflow6", "max_stars_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 102, "max_stars_repo_stars_event_min_datetime": "2017-12-19T09:56:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T01:47:28.000Z", "max_issues_repo_path": "doc/mf6io/gwt/dsp.tex", "max_issues_repo_name": "scharlton2/modflow6", "max_issues_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 331, "max_issues_repo_issues_event_min_datetime": "2018-01-10T21:22:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T05:57:00.000Z", "max_forks_repo_path": "doc/mf6io/gwt/dsp.tex", "max_forks_repo_name": "scharlton2/modflow6", "max_forks_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 87, "max_forks_repo_forks_event_min_datetime": "2017-12-13T21:40:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T05:31:40.000Z", "avg_line_length": 56.8333333333, "max_line_length": 565, "alphanum_fraction": 0.8025415445, "num_tokens": 255, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.420485513331455}}
{"text": "\\section{Nuisance parameters}\n\\label{sec:NPs}\n\nThe expected numbers and pdf shapes of signal and background events also depend on a series of systematic uncertainties, \nwhich are described as a set of nuisance parameters (NPs).\nAs showed in equation~\\ref{eq:likelihoodf}, $\\pmb{\\theta}$ is a set of NPs that plays as an additional ``penalty\" term to likelihood function, \nwhich will increase the negative log likelihood when any nuisance parameter is shifted from its nominal value.\nUsually those NPs are constrained by using Gaussian function with their estimated uncertainties provided by the experiment condition.\n", "meta": {"hexsha": "c2caec0359434d4f7b6658051af05cb3f3f37293", "size": 617, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/Statistic/np.tex", "max_stars_repo_name": "zhuhel/PhDthesis", "max_stars_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/Statistic/np.tex", "max_issues_repo_name": "zhuhel/PhDthesis", "max_issues_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/Statistic/np.tex", "max_forks_repo_name": "zhuhel/PhDthesis", "max_forks_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.5555555556, "max_line_length": 143, "alphanum_fraction": 0.8071312804, "num_tokens": 127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4204855075439386}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section{Dirac equation coupled to an external EM field}\n\n\\marginpar{Thursday\\\\ 2020-4-30, \\\\ compiled \\\\ \\today}\n\nWe can use a complex solution to the Dirac equation to describe a spin \\(1/2\\) particle.\n\nAs we did before, we make the minimal coupling ansatz: \n%\n\\begin{align}\n\\partial_{\\mu } \\to \\DD_{\\mu } = \\partial_{\\mu } + i q A_{\\mu } \n\\,,\n\\end{align}\n%\nso that our Dirac equation will read \n%\n\\begin{align}\n\\qty(i\\slashed{\\DD} - M ) \\psi = \\qty(i \\slashed{\\partial} - q \\slashed{A} - M ) = 0\n\\,,\n\\end{align}\n%\nwhich in three-vector notation (after the computation in the equations \\eqref{eq:dirac-equation-from-ansatz-to-gamma}) reads \n%\n\\begin{align}\ni \\partial_0 \\psi = \\qty[i \\vec{\\alpha} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) + \\beta M + q A_0 ] \\psi \n\\,,\n\\end{align}\n%\nwhere we are using the definition \\(\\partial_{i} = \\vec{\\nabla}\\), while \\(A^{i} = \\vec{A} \\): the ``natural'' placement for the spatial index of the derivative is lower, while for other vectors it is upper.\n\n\\subsection{Nonrelativistic limit of the Dirac equation}\n\nAs we did in the case of the Klein-Gordon equation, we start out by factoring out the time-evolution: we define \n%\n\\begin{align}\n\\psi (\\vec{x}, t) = e^{-i M t} \\psi' (\\vec{x}, t)\n\\,,\n\\end{align}\n%\nwhich we can plug into the expression for the Dirac equation: we find \n%\n\\begin{subequations}\n\\begin{align}\ni \\partial_0 \\qty(e^{-iMt} \\psi ') &= \\qty[i \\vec{\\alpha} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) + \\beta M + q A_0 ] \\qty(e^{-iMt} \\psi')  \\\\\ne^{-iMt } \\qty(- i^2 + i \\partial_0 ) \\psi' &=\ne^{-iMt} \\qty[i \\vec{\\alpha} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) + \\beta M + q A_0 ] \\psi'  \\\\\ni \\partial_0 \\psi' &= \\qty[i \\vec{\\alpha} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) + (\\beta - \\mathbb{1}) M + q A_0 ] \\psi'\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhich we can write using the explicit spinorial expressions for the \\(\\vec{\\alpha}\\) and \\(\\beta \\) matrices; for clarity we also divide \\(\\psi '\\) into two two-component spinors \\(\\varphi'\\) and \\(\\chi '\\):\n%\n\\begin{subequations}\n\\begin{align}\n\\begin{split}\ni \\partial_0 \n\\left[\\begin{array}{c}\n\\varphi' \\\\ \n\\chi '\n\\end{array}\\right]\n &= \n\\left[\\begin{array}{cc}\n0 & i \\vec{\\sigma} \\cdot (-\\vec{\\nabla} + i q \\vec{A})  \\\\ \ni \\vec{\\sigma} \\cdot (-\\vec{\\nabla} + i q \\vec{A}) & 0\n\\end{array}\\right]\n\\left[\\begin{array}{c}\n    \\varphi' \\\\ \n    \\chi '\n\\end{array}\\right] \\\\\n&\n+ \\left[\\begin{array}{cc}\n0 & 0 \\\\ \n0 & -2M\n\\end{array}\\right] \\left[\\begin{array}{c}\n\\varphi' \\\\ \n\\chi '\n\\end{array}\\right]\n\\\\\n&\n+ \\left[\\begin{array}{cc}\nqA_0  & 0 \\\\ \n0 & q A_0 \n\\end{array}\\right] \\left[\\begin{array}{c}\n\\varphi' \\\\ \n\\chi '\n\\end{array}\\right]\n\\,.\n\\end{split}\n\\end{align}\n\\end{subequations}\n\nThen we can read off the two \\emph{coupled} equations for these 2D spinors: \n%\n\\begin{subequations}\n\\begin{align}\ni \\partial_0 \\varphi ' &= i \\vec{\\sigma} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) \\chi '\n+ q A_0 \\varphi '  \\\\\ni \\partial_0 \\chi ' &= i \\vec{\\sigma} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) \\varphi ' +\n(- 2 M + q A_0 ) \\chi '\n\\,.\n\\end{align}\n\\end{subequations}\n\nNotice that the mass only appears in the second equation: so, we can apply the nonrelativistic approximation, which amounts to saying that the mass \\(M\\) is the largest energy at play; formally, this means \n%\n\\begin{align}\n\\abs{q A_0} \\ll M \n\\qquad \\text{and} \\qquad\n\\abs{\\frac{\\partial_0 \\chi '}{\\chi '}} \\ll M\n\\,,\n\\end{align}\n%\nso we remove those terms in the second equation; if we bring the term \\(2 M \\chi '\\) to the left hand side we get: \n%\n\\begin{align}\n\\chi ' =  \\frac{i}{2M} \\vec{\\sigma} \\cdot \\qty(- \\vec{\\nabla} + i q \\vec{A}) \\varphi '\n\\,,\n\\end{align}\n%\nso we have an explicit constraint on the value of \\(\\chi '\\) if we know \\(\\varphi '\\).\n\nWe do not know \\emph{a priori} the asymptotic relation of \\(\\chi '\\) to \\(\\varphi '\\), so we only made cancellations in terms which were comparable since they were all applied to \\(\\chi '\\).\n\nNow, then we have found that, since \\(\\chi ' \\sim \\varphi ' / M\\), the magnitude of \\(\\varphi '\\) is much larger than that of \\(\\chi '\\). \n\nWe can substitute what we found for \\(\\chi '\\) into the first equation: we find \n%\n\\begin{subequations}\n\\begin{align}\ni \\partial_0 \\varphi ' &= \\frac{1}{2M} \\qty[i \\vec{\\sigma} \\cdot \\qty(- \\vec{\\nabla} + iq \\vec{A})]^2 \\varphi ' + q A_0 \\varphi '  \\\\\n&= q A_0 \\varphi ' - \\frac{1}{2M} \\qty[- \\vec{\\sigma} \\cdot \\vec{\\nabla} + iq \\vec{\\sigma} \\cdot \\vec{A}]^2 \\varphi '\n\\,.\n\\end{align}\n\\end{subequations}\n\nThis is the \\emph{Pauli equation coupled to an external magnetic field}, the generalization of the Schrödinger equation to spin \\(1/2\\) charged particles.\n\nWe can make it more explicit by squaring the differential operator.\n\nThe sign convention in the notes is weird, in that a 3D vector written as \\(\\vec{x}\\) does not consistently mean neither \\(x^{i}\\) nor \\(x_{i}\\).\nInstead, we have \\(\\vec{\\nabla} = \\partial_{i}  \\) and \\(\\vec{A} = A^{i}\\).\n\nWhen we write out a scalar product we imply that one index should be upper and one should be lower, if this is not the case already one of them must be raised or lowered. Once we are in component notation, though, we can move indices around as we like.\n\nSo, explicitly we have \n%\n\\begin{subequations}\n\\begin{align}\n\\qty(- \\vec{\\sigma} \\cdot \\vec{\\nabla} + i q \\vec{\\sigma} \\cdot \\vec{A})^2 \\varphi'\n&= \\qty(- \\sigma^{i} \\partial_{i} + i q \\sigma^{i} A^{i})^2 \\varphi'  \\\\\n&= \\qty(- \\sigma^{i} \\partial_{i} - i q \\sigma^{i} A_{i})^2 \\varphi'  \\\\\n&= \\qty( \\sigma_{i} \\partial_{i} + i q \\sigma_{i} A_{i})^2 \\varphi'  \\\\\n&= \\qty( \\sigma_{i} \\partial_{i} + i q \\sigma_{i} A_{i})\n\\qty( \\sigma_{j} \\partial_{j} + i q \\sigma_{j} A_{j}) \\varphi '  \\\\\n&= \\qty( \\sigma_{i} \\partial_{i} + i q \\sigma_{i} A_{i})\n\\qty(\\sigma_{j} \\qty(\\partial_{j} \\varphi ') + i q \\sigma_{j} A_{j} \\varphi ')  \\\\\n&= \\sigma_{i} \\sigma_{j} \\qty[\\partial_{i} \\partial_{j} + iq \\qty(\\partial_{i} A_{j} + A_{j} \\partial_{i} + A_{i} \\partial_{j} ) - q^2 A_{i} A_{j}] \\varphi '\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand now we notice that all the terms except for \\(\\partial_{i} A_{j}\\) are symmetric in \\(ij\\): so, we split the product \\(\\sigma_{i} \\sigma_{j}\\) into its symmetric and antisymmetric parts. \nThis yields \n%\n\\begin{align}\n\\sigma_{i} \\sigma_{j} = \\frac{1}{2} \\qty{\\sigma_{i}, \\sigma_{j}} + \\frac{1}{2} \\qty[\\sigma_{i}, \\sigma_{j}] = \\delta_{ij} + i \\epsilon_{ijk} \\sigma_{k}\n\\,,\n\\end{align}\n%\nso we find \n%\n\\begin{subequations}\n\\begin{align}\n\\qty(- \\vec{\\sigma} \\cdot \\vec{\\nabla} + i q \\vec{\\sigma} \\cdot \\vec{A})^2 \\varphi'\n&=\n\\qty(\\delta_{ij} + i \\epsilon_{ijk} \\sigma_{k})\n\\qty[\\partial_{i} \\partial_{j} + iq \\qty(\\partial_{i} A_{j} + A_{j} \\partial_{i} + A_{i} \\partial_{j} ) - q^2 A_{i} A_{j}] \\varphi '  \\\\\n&= \\qty[\\partial_{i} \\partial_{i} + i q \\qty( \\partial_{i} A_{i} + 2A_{i} \\partial_{i}) - q^2 A_{i} A_{i}] \\varphi '\n+ \\qty[i^2 q \\partial_{i} A_{j} \\epsilon^{ijk} \\sigma_{k}] \\varphi '  \\\\\n&= \\qty[\\vec{\\nabla}^2 - iq \\qty(\\vec{\\nabla} \\cdot \\vec{A} + 2 \\vec{A} \\cdot \\vec{\\nabla}) - q^2 \\vec{A}^2 \n+ \\vec{\\sigma} \\cdot \\vec{B} ] \\varphi'  \\\\\n&= \\qty[- \\vec{\\nabla} + iq \\vec{A}]^2 \\varphi + q\\vec{\\sigma} \\cdot \\vec{B} \\varphi '\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere we used the fact that \\(\\partial_{i} A_{j} \\epsilon_{ijk} = \\frac{1}{2} F_{ij} \\epsilon_{ijk}  = B_{k}\\), and in the last step we set \\(\\nabla \\cdot \\vec{A} = 0\\), the Coulomb gauge condition.\n\nNotice that we had to raise the indices of both \\(\\vec{A}\\) and \\(\\vec{B}\\), so we had to switch the sign of those terms.\n\nThen, we can finally write the full Pauli equation: \n%\n\\begin{align}\ni \\partial_0 \\varphi ' = \\qty{- \\frac{1}{2M} \\qty[- \\vec{\\nabla} + i q \\vec{A}]^2  + q A_0 - \\frac{q}{2M} \\vec{\\sigma} \\cdot \\vec{B} } \\varphi '\n\\,,\n\\end{align}\n%\nwhich differs from the minimally-coupled Schrödinger equation by the spin coupling to the magnetic field. \nThis new term in the Hamiltonian is \n%\n\\begin{align}\nH _{\\text{dip}}= - \\frac{q}{2M} \\vec{\\sigma} \\cdot \\vec{B} = - \\vec{\\mu}_{s} \\cdot \\vec{B}\n\\,,\n\\end{align}\n%\nwhere we introduced the \\textbf{intrinsic magnetic moment} \n%\n\\begin{align} \\label{eq:intrinsic-magnetic-moment}\n\\vec{\\mu}_{s} = \\frac{q}{2M} \\vec{\\sigma} = \\frac{q}{M} \\vec{\\Sigma}^{(3)}\n\\,.\n\\end{align}\n\nIn nonrelativistic quantum mechanics this term is introduced by hand: if the wavefunction is a scalar there is no way for this term to come about. Once we start describing it as a spinor, though, we can see where the term comes from.\n\nThe \\textbf{magnetic dipole moment} associated with the \\emph{orbital angular momentum}, as opposed to the spin, is defined as \n%\n\\begin{align}\n\\vec{\\mu}_{L} = \\frac{q}{2M } \\vec{L}\n\\,,\n\\end{align}\n%\nso in this case the ratio of magnetic moment to momentum is \n%\n\\begin{align}\n\\frac{\\abs{\\vec{\\mu}_{L}}}{\\abs{\\vec{L}}} = \\frac{q}{2M}\n\\,,\n\\end{align}\n%\nwhile for the spin we defined (already in nonrelativistic QM) \n%\n\\begin{align}\n\\vec{\\mu}_{s} = \\frac{q}{2M} g_e \\vec{\\Sigma}^{(3)}\n\\qquad \\implies \\qquad\n\\frac{\\abs{\\vec{\\mu}_{s}}}{\\abs{\\vec{\\Sigma}}} = \\frac{q}{2M} g_{e} \n\\,,\n\\end{align}\n%\nwhere we define the \\textbf{electron gyromagnetic factor} \\(g_e\\).\nThis can be compared with the equation we found before for the intrinsic magnetic moment \\eqref{eq:intrinsic-magnetic-moment}, to yield our prediction: \n%\n\\begin{align}\ng_e = 2\n\\,.\n\\end{align}\n\n\\begin{claim}\nWe have the relation \n%\n\\begin{align} \\label{eq:antisymmetric-covariant-derivative-field-strength}\n\\qty[i \\partial_{\\mu } - q A_{\\mu }, i \\partial_{\\nu } - q A_{\\nu }] \\psi \n= -iq F_{\\mu \\nu } \\psi \n\\,.\n\\end{align}\n\\end{claim}\n\n\\begin{proof}\nWe write the terms of the product out, antisymmetrizing everything: \n%\n\\begin{subequations}\n\\begin{align}\n&\\qty[i \\partial_{\\mu } - q A_{\\mu }, i \\partial_{\\nu } - q A_{\\nu }] \\psi = \\\\\n&=2 \\qty(i \\partial_{[\\mu }i \\partial_{\\nu ]}\n- i q \\qty(\\partial_{[\\mu } A_{\\nu ]} ) \n-iq A_{[\\nu } \\partial_{\\mu ]}\n-iq A_{[\\mu } \\partial_{\\nu ]}\n+ q^2 A_{[\\mu } A_{\\nu ]}) \\psi   \\\\\n&= -2iq \\partial_{[\\mu } A_{\\nu ]} \\psi \n= -iq F_{\\mu \\nu } \\psi \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere we removed all the terms which were symmetric in \\(\\mu \\leftrightarrow \\nu \\). \n\nNote that this is the commutator of the covariant derivatives on the manifold: it yields the Riemann tensor, which we then have shown to be given by the electromagnetic field-strength.\n\\end{proof}\n\n\\begin{claim}\nWe have the relation \n%\n\\begin{align}\n\\Sigma^{\\mu \\nu }F_{\\mu \\nu }\n=i \\vec{\\alpha} \\cdot \\vec{E} + \\vec{\\Sigma} \\cdot \\vec{B}\n\\,,\n\\end{align}\n%\nwhere \n%\n\\begin{subequations}\n\\begin{align}\n\\vec{\\alpha} = \\left[\\begin{array}{cc}\n0 & \\vec{\\sigma} \\\\ \n\\vec{\\sigma} & 0\n\\end{array}\\right] \n\\qquad \\text{and} \\qquad\n\\vec{\\Sigma} = \\frac{1}{2} \\left[\\begin{array}{cc}\n\\vec{\\sigma} & 0 \\\\ \n0 & \\vec{\\sigma}\n\\end{array}\\right]\n\\,.\n\\end{align}\n\\end{subequations}\n\\end{claim}\n\n\\begin{proof}\nRecall the definitions of \n%\n\\begin{align}\n\\Sigma^{\\mu \\nu } = \\frac{i}{4} \\qty[\\gamma^{\\mu }, \\gamma^{\\nu }]\n\\,\n\\end{align}\n%\nand of the the electric and magnetic fields in terms of the field-strength tensor: \n%\n\\begin{align}\nE^{i} = F^{i0} = - F^{0i} = +F_{0i}\n\\qquad \\text{and} \\qquad\nB^{k} = \\frac{1}{2} F^{ij} \\epsilon^{ijk}\n\\,.\n\\end{align}\n\nFor the magnetic field we can also write the inverse expression: \n%\n\\begin{align}\nF^{ij} = \\epsilon^{ijk} B^{k}\n\\,,\n\\end{align}\n%\n\n\nSo, we distinguish the cases where \\(\\mu = 0\\) and \\(\\mu = i\\), a spatial 3D index.\n\nIn the first case, the index \\(\\nu \\) must be nonzero by antisymmetry, so we find\n%\n\\begin{align}\n\\Sigma^{0j}F_{0j} &= \\frac{i}{4} \\qty[\\gamma^{0}, \\gamma^{j}] E^{j}\n\\,,\n\\end{align}\n%\nand since different \\(\\gamma \\) matrices anticommute we can replace the commutator with twice the product: \n%\n\\begin{align}\n\\Sigma^{0j} F_{0j} &= \\frac{i}{2} \\gamma^{0} \\gamma^{j} E^{j} = \\frac{i}{2} \\gamma^{0} \\gamma^{0} \\alpha^{j} E^{j} = \\frac{i}{2} \\vec{\\alpha} \\cdot \\vec{E}\n\\,.\n\\end{align}\n\nIn the final expression we are summing over \\(\\mu \\) and \\(\\nu \\), so the contribution will be twice this, since we need to account for the case where \\(\\nu =0\\) as well as \\(\\mu =0 \\).\n\nIn the other case, we apply a similar reasoning; in this case we also need to recall the definition of the vector \\(\\vec{\\Sigma}\\): \n%\n\\begin{align}\n\\Sigma^{i} = \\frac{1}{2} \\epsilon^{ijk} \\Sigma^{jk}\n\\,,\n\\end{align}\n%\nso we can substitute this into the expression and find:\n%\n\\begin{subequations}\n\\begin{align}\n\\Sigma^{ij} F_{ij} &= \\Sigma^{ij} F^{ij}  \\\\\n&= \\Sigma^{ij} \\tensor{\\epsilon }{^{ijk}} B_{k}  \\\\\n&= 2 \\vec{\\Sigma}^{k} B_{k}\n\\,,\n\\end{align}\n\\end{subequations}\n%\n\\todo[inline]{which has an extra factor two\\dots should figure out why this is the case}\n\\end{proof}\n\n\n\\begin{claim}\nWe can also derive the prediction \\(g_e = 2\\) from the full relativistic Dirac equation.\n\\end{claim}\n\n\\begin{proof}\nWe start by applying the operator \\(i\\slashed{\\DD} + M\\) to the relativistic Dirac equation to an external electromagnetic field, just like what we did to recover the Klein-Gordon equation: we find \n%\n\\begin{subequations}\n\\begin{align}\n\\qty(-\\slashed{\\DD}^2 - M^2) \\psi &= 0  \\\\\n\\qty[ - \\qty(\\partial_{\\mu } +ieA_{\\mu }) \\gamma^{\\mu } \\qty(\\partial_{\\nu } + ieA_{\\nu }) \\gamma^{\\nu } - M^2] \\psi  & =0\n\\,,\n\\end{align}\n\\end{subequations}\n%\nsince \\(\\DD_{\\mu } = \\partial_{\\mu } + ieA_{\\mu }\\).\nWe have a product of gamma matrices: we can decompose it into its symmetric and antisymmetric parts, as \n%\n\\begin{subequations}\n\\begin{align}\n\\gamma^{\\mu } \\gamma^{\\nu } &= \\frac{1}{2} \\qty{\\gamma^{\\mu }, \\gamma^{\\nu }}  + \\frac{1}{2} \\qty[\\gamma^{\\mu } , \\gamma^{\\nu }]\\\\\n&= \\eta^{\\mu \\nu } -2i \\Sigma^{\\mu \\nu }\n\\,,\n\\end{align}\n\\end{subequations}\n%\nsince \n%\n\\begin{align}\n\\Sigma^{\\mu \\nu } = \\frac{i}{4} \\qty[\\gamma^{\\mu }, \\gamma^{\\nu }]\n\\,.\n\\end{align}\n\nTherefore, we find \n%\n\\begin{subequations}\n\\begin{align}\n\\qty[\\qty(\\partial_{\\mu } + i e A_{\\mu }) \\qty(\\partial^{\\mu } + i e A^{\\mu }) - 2i \\Sigma^{\\mu \\nu } \\qty(\\partial_{\\mu } +ieA_{\\mu }) \\qty(\\partial_{\\nu } + ieA_{\\nu }) - M^2] \\psi &= 0  \\\\\n\\qty[-\\DD_{\\mu } \\DD^{\\mu} + 2i \\Sigma^{\\mu \\nu } \\DD_{[\\mu } \\DD_{\\nu ]}  - M^2] \\psi &= 0\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand we can expand the antisymmetrized covariant derivative given what we know from equation \\eqref{eq:antisymmetric-covariant-derivative-field-strength}: \n%\n\\begin{subequations}\n\\begin{align}\n-iq F_{\\mu \\nu } \\psi &=\n\\qty[i \\partial_{\\mu } - q A_{\\mu}, i \\partial_{\\nu } - q A_{\\nu }] \\psi \\\\\n&= \\qty[i \\DD_{\\mu }, i \\DD_{\\nu }]\\psi  \\\\\n&= - 2 \\DD_{[\\mu } \\DD_{\\nu ]} \\psi  \\\\\n\\,,\n\\end{align}\n\\end{subequations}\n%\nso we can write \n%\n\\begin{subequations}\n\\begin{align}\n\\qty[-\\DD_{\\mu } \\DD^{\\mu} + 2i \\Sigma^{\\mu \\nu } \\qty(\\frac{1}{2} iq F_{\\mu \\nu }) - M^2] \\psi &= 0  \\\\\n\\qty[-\\DD_{\\mu } \\DD^{\\mu} - \\Sigma^{\\mu \\nu }  q F_{\\mu \\nu } - M^2] \\psi &= 0  \\\\\n\\qty[-\\DD_{\\mu } \\DD^{\\mu} - g_e \\frac{q}{2} \\Sigma^{\\mu \\nu }  F_{\\mu \\nu } - M^2] \\psi &= 0 \n\\,,\n\\end{align}\n\\end{subequations}\nwhere \\(g_e = 2\\). \n\\end{proof}\n\n\\end{document}", "meta": {"hexsha": "c1f51ea890cb44bb5861e4678c4681865500bb12", "size": 14947, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/theoretical_physics/apr06.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/theoretical_physics/apr06.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/theoretical_physics/apr06.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 33.8167420814, "max_line_length": 252, "alphanum_fraction": 0.6269485515, "num_tokens": 5585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4204504155494266}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{color}\n\n\\sloppy\n\\definecolor{lightgray}{gray}{0.5}\n\\setlength{\\parindent}{0pt}\n\n\\begin{document}\n\n    \n    \n\\section*{THE FACTORIZE OBJECT for solving linear systems}\n\n\\begin{par}\nCopyright 2011-2012, Timothy A. Davis,\n\\begin{verbatim}http://www.suitesparse.com\\end{verbatim}\n\\begin{verbatim}DrTimothyAldenDavis@gmail.com\\end{verbatim} \\end{par}\n\\vspace{1em}\n\\begin{par}\nThis is a demonstration of the FACTORIZE object for solving linear systems and\nleast-squares problems, and for computations with the matrix inverse and\npseudo-inverse.\n\\end{par} \\vspace{1em}\n\n\\subsection*{Contents}\n\n\\begin{itemize}\n\\setlength{\\itemsep}{-1ex}\n   \\item Rule Number One: never multiply by the inverse, inv(A)\n   \\item Rule Number Two:  never break Rule Number One\n   \\item How to use BACKSLASH solve A*x=b\n   \\item BACKSLASH versus INV ... let the battle begin\n   \\item LU and LINSOLVE are fast and accurate but complicated to use\n   \\item INV is easy to use, but slow and inaccurate\n   \\item So the winner is ... nobody\n   \\item The FACTORIZE object to the rescue\n   \\item Least-squares problems\n   \\item Underdetermined systems\n   \\item Computing selected entries in the inverse or pseudo-inverse\n   \\item Computing the entire inverse or pseudo-inverse\n   \\item Update/downdate of a dense Cholesky factorization\n   \\item Caveat Executor\n   \\item Summary\n\\end{itemize}\n\n\n\\subsection*{Rule Number One: never multiply by the inverse, inv(A)}\n\n\\begin{par}\nUse backslash or a matrix factorization instead (LU, CHOL, or QR).\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{Rule Number Two:  never break Rule Number One}\n\n\\begin{par}\nHowever, the problem with Rule Number One is that it can be hard to figure out\nwhich matrix factorization to use and how to use it.  Using LU, CHOL, or QR is\ncomplicated, particularly if you want the best performance.  BACKSLASH\n(MLDIVIDE) is great, but it can't be reused when solving multiple systems\n(x=A\\ensuremath{\\backslash}b and y=A\\ensuremath{\\backslash}c).  Its syntax\ndoesn't match the use of the inverse in mathematical expressions, either.\n\\end{par} \\vspace{1em}\n\\begin{par}\nThe goal of the FACTORIZE object is to solve this problem ...\n\\end{par} \\vspace{1em}\n\\begin{par}\n\"Don't let that INV go past your eyes; to solve that system, FACTORIZE!\"\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{How to use BACKSLASH solve A*x=b}\n\n\\begin{par}\nFirst, let's create a square matrix A and a right-hand-side b for a linear\nsystem A*x=b.  There are many ways to solve this system.  The best way is to\nuse x=A\\ensuremath{\\backslash}b.  The residual r is a vector of what's left\nover in each equation, and its norm tells you how accurately the system was\nsolved.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nformat compact ;\nA = rand (3)\nb = rand (3,1)\nx = A\\b\nr = b-A*x ;\nnorm (r)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}A =\n    0.2748    0.2719    0.3696\n    0.2217    0.8329    0.5006\n    0.9315    0.5791    0.0753\nb =\n    0.1293\n    0.9138\n    0.4589\nx =\n   -0.3827\n    1.4657\n   -0.4437\nans =\n   1.2413e-16\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{BACKSLASH versus INV ... let the battle begin}\n\n\\begin{par}\nThe backslash operation x=A\\ensuremath{\\backslash}b is mathematically the same\nas x=inv(A)*b. However, backslash is faster and more accurate since it uses a\nmatrix factorization instead of multiplying by the inverse.  Even though your\nlinear algebra textbook might write x=A\\^{}(-1)*b as the solution to the system\nA*x=b, your textbook author never means for you to compute the inverse.\n\\end{par} \\vspace{1em}\n\\begin{par}\nThese next statements give the same answer, so what's the big deal?\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nS = inv(A) ;\nx = S*b\nx = A\\b\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}x =\n   -0.3827\n    1.4657\n   -0.4437\nx =\n   -0.3827\n    1.4657\n   -0.4437\n\\end{verbatim} \\color{black}\n    \\begin{par}\nThe big deal is that you should care about speed and you should care even more\nabout accuracy.  BACKSLASH relies on matrix factorization (LU, CHOL, QR, or\nother specialized methods).  It's faster and more reliable than multiplying by\nthe inverse, particularly for large matrices and sparse matrices.  Here's an\nillustration of how pathetic inv(A)*b can be.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = gallery ('frank',16) ; xtrue = ones (16,1) ; b = A*xtrue ;\n\nx = inv(A)*b ; norm (b-A*x)\nx = A\\b      ; norm (b-A*x)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}ans =\n    0.0606\nans =\n   1.7764e-15\n\\end{verbatim} \\color{black}\n    \\begin{par}\nThe performance difference between BACKSLASH and INV for even small sparse\nmatrices is striking.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nload west0479 ;\nA = west0479 ;\nn = size (A,1)\nb = rand (n,1) ;\ntic ; x = A\\b ; toc\nnorm (b-A*x)\ntic ; x = inv(A)*b ; toc\nnorm (b-A*x)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}n =\n   479\nElapsed time is 0.002425 seconds.\nans =\n   1.9174e-10\nElapsed time is 0.041780 seconds.\nans =\n   3.4438e-09\n\\end{verbatim} \\color{black}\n    \\begin{par}\nWhat if you want to solve multiple systems?  Use a matrix factorization. But\nwhich one?  And how do you use it?  Here are some alternatives using LU for the\nsparse west0479 matrix, but some are faster than others.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\ntic ; [L,U]     = lu(A) ; x1 = U \\ (L \\ b)         ; t1=toc ; nz1=nnz(L+U);\ntic ; [L,U,P]   = lu(A) ; x2 = U \\ (L \\ P*b)       ; t2=toc ; nz2=nnz(L+U);\ntic ; [L,U,P,Q] = lu(A) ; x3 = Q * (U \\ (L \\ P*b)) ; t3=toc ; nz3=nnz(L+U);\n\nfprintf ('1: nnz(L+U): %5d time: %8.4f resid: %e\\n', nz1,t1, norm(b-A*x1));\nfprintf ('2: nnz(L+U): %5d time: %8.4f resid: %e\\n', nz2,t2, norm(b-A*x2));\nfprintf ('3: nnz(L+U): %5d time: %8.4f resid: %e\\n', nz3,t3, norm(b-A*x3));\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}1: nnz(L+U): 16151 time:   0.0031 resid: 1.346712e-10\n2: nnz(L+U): 15826 time:   0.0081 resid: 1.757002e-10\n3: nnz(L+U):  3704 time:   0.0017 resid: 1.691750e-10\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{LU and LINSOLVE are fast and accurate but complicated to use}\n\n\\begin{par}\nA quick look at ``help lu'' will scroll off your screen.  For full matrices,\n[L,U,p] = lu (A,'vector') is fastest.  Then for the forward/backsolves, use\nLINSOLVE instead of BACKSLASH for even faster performance.  But for sparse\nmatrices, use the optional 'Q' output of LU so you get a good fill-reducing\nordering.  But you can't use 'Q' if the matrix is full.  But LINSOLVE doesn't\nwork on sparse matrices.\n\\end{par} \\vspace{1em}\n\\begin{par}\nBut ... Ack!  That's getting complicated ...\n\\end{par} \\vspace{1em}\n\\begin{par}\nHere's the best way to solve A*x=b and A*y=c when A is full and unsymmetric:\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nn = 1000 ;\nA = rand (n) ;\nb = rand (n,1) ;\nc = rand (n,1) ;\ntic ; [L,U,p] = lu (A, 'vector') ; LUtime = toc\n\ntic ; x = U \\ (L \\ b (p,:)) ;\n      y = U \\ (L \\ c (p,:)) ; toc\n\ntic ; opL = struct ('LT', true) ;\n      opU = struct ('UT', true) ;\n      x = linsolve (U, linsolve (L, b(p,:), opL), opU) ;\n      y = linsolve (U, linsolve (L, c(p,:), opL), opU) ; toc\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}LUtime =\n    0.0155\nElapsed time is 0.004917 seconds.\nElapsed time is 0.002092 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{INV is easy to use, but slow and inaccurate}\n\n\\begin{par}\nOh bother!  Using LU and LINSOLVE is too complicated.  You just want to solve\nyour system.  Let's just compute inv(A) and use it twice.  Easy to write, but\nslower and less accurate ...\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nS = inv (A) ;\nx = S*b ; norm (b-A*x)\ny = S*c ; norm (c-A*y)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}ans =\n   2.3292e-11\nans =\n   1.7292e-11\n\\end{verbatim} \\color{black}\n    \\begin{par}\nSometimes using the inverse seems inevitable.  For example, your textbook might\nshow the Schur complement formula as S = A-B*inv(D)*C.  This can be done\nwithout inv(D) in one of two ways: SLASH or BACKSLASH (MRDIVIDE or MLDIVIDE to\nbe precise).\n\\end{par} \\vspace{1em}\n\\begin{par}\ninv(A)*B and A\\ensuremath{\\backslash}B are mathematically equivalent, as are\nB*inv(A) and B/A, so these three methods give the same results (ignoring\ncomputational errors, which are worse for inv(D)).  Only the first equation\nlooks like the equation in your textbook, however.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (200) ; B = rand (200) ; C = rand (200) ; D = rand (200) ;\n\ntic ; S1 = A - B*inv(D)*C ; toc ;\ntic ; S2 = A - B*(D\\C) ;    toc ;\ntic ; S3 = A - (B/D)*C ;    toc ;\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.002398 seconds.\nElapsed time is 0.001632 seconds.\nElapsed time is 0.001474 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{So the winner is ... nobody}\n\n\\begin{par}\nBACKSLASH: mostly simple to use (except remember that Schur complement\nformula?).  Fast and accurate ... but slow if you want to solve       two\nlinear systems with the same matrix A.\n\\end{par} \\vspace{1em}\n\\begin{par}\nLU, QR, CHOL: fast and accurate.  Awful syntax to use.  Drag out your\nlinear algebra textbook if you want to use these in MATLAB.       Whenever I\nuse them I have to derive them from scratch, even       though I \\textbf{wrote}\nmost of the sparse factorizations used in MATLAB!\n\\end{par} \\vspace{1em}\n\\begin{par}\nINV: slow and inaccurate.  Wins big on ease-of-use, though, since it's a\ndirect plug-in for all your nice mathematical formulas.\n\\end{par} \\vspace{1em}\n\\begin{par}\nNo method is best on all three criterion: speed, accuracy, and ease of use.\n\\end{par} \\vspace{1em}\n\\begin{par}\nIs there a solution?  Yes ... keeping reading ...\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{The FACTORIZE object to the rescue}\n\n\\begin{par}\nThe FACTORIZE method is just as easy to use as INV, but just as fast and\naccurate as BACKSLASH, LU, QR, CHOL, and LINSOLVE.\n\\end{par} \\vspace{1em}\n\\begin{par}\nF = factorize(A) computes the factorization of A and returns it as an object\nthat you can reuse to solve a linear system with x=F\\ensuremath{\\backslash}b.\nIt picks LU, QR, or Cholesky for you, just like BACKSLASH.\n\\end{par} \\vspace{1em}\n\\begin{par}\nS = inverse(A) is simpler yet.  It does NOT compute inv(A), but factorizes A.\nWhen multiplying S*b, it doesn't mulitply by the inverse, but uses the correct\nforward/backsolve equations to solve the linear system.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nn = 1000 ;\nA = rand (n) ;\nb = rand (n,1) ;\nc = rand (n,1) ;\n\ntic ;                       x = A\\b ; y = A\\c ; toc\ntic ; S = inv(A) ;          x = S*b ; y = S*c ; toc\ntic ; F = factorize(A) ;    x = F\\b ; y = F\\c ; toc\ntic ; S = inverse(A) ;      x = S*b ; y = S*c ; toc\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.051483 seconds.\nElapsed time is 0.053813 seconds.\nElapsed time is 0.025811 seconds.\nElapsed time is 0.029840 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Least-squares problems}\n\n\\begin{par}\nHere are some different methods for solving a least-squares problem when your\nsystem is over-determined.  The last two methods are the same.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (1000,200) ;\nb = rand (1000,1) ;\n\ntic ; x = A\\b            ; toc, norm (A'*A*x-A'*b)\ntic ; x = pinv(A)*b      ; toc, norm (A'*A*x-A'*b)\ntic ; x = inverse(A)*b   ; toc, norm (A'*A*x-A'*b)\ntic ; x = factorize(A)\\b ; toc, norm (A'*A*x-A'*b)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.010705 seconds.\nans =\n   2.7575e-12\nElapsed time is 0.025339 seconds.\nans =\n   2.3477e-12\nElapsed time is 0.008903 seconds.\nans =\n   2.5140e-12\nElapsed time is 0.008408 seconds.\nans =\n   2.5140e-12\n\\end{verbatim} \\color{black}\n    \\begin{par}\nFACTORIZE is better than BACKSLASH because you can reuse the factorization for\ndifferent right-hand-sides.  For full-rank matrices, it's better than PINV\nbecause it's faster (and PINV fails for sparse matrices).\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (1000,200) ;\nb = rand (1000,1) ;\nc = rand (1000,1) ;\n\ntic ;                  ; x = A\\b ; y = A\\c ; toc\ntic ; S = pinv(A)      ; x = S*b ; y = S*c ; toc\ntic ; S = inverse(A)   ; x = S*b ; y = S*c ; toc\ntic ; F = factorize(A) ; x = F\\b ; y = F\\c ; toc\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.021934 seconds.\nElapsed time is 0.027198 seconds.\nElapsed time is 0.009692 seconds.\nElapsed time is 0.010197 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Underdetermined systems}\n\n\\begin{par}\nThe under-determined system A*x=b where A has more columns than rows has many\nsolutions.  x=A\\ensuremath{\\backslash}b finds a basic solution (some of the\nentries in x are zero).  pinv(A)*b finds a minimum 2-norm solution, but it's\nslow.  QR factorization will do the same if A has full rank.  That's what the\nfactorize(A) and inverse(A) methods do.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (200,1000) ;\nb = rand (200,1) ;\n\ntic ; x = A\\b            ; toc, norm (x)\ntic ; x = pinv(A)*b      ; toc, norm (x)\ntic ; x = inverse(A)*b   ; toc, norm (x)\ntic ; x = factorize(A)\\b ; toc, norm (x)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.016247 seconds.\nans =\n    2.5580\nElapsed time is 0.034924 seconds.\nans =\n    0.5154\nElapsed time is 0.012460 seconds.\nans =\n    0.5154\nElapsed time is 0.009924 seconds.\nans =\n    0.5154\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Computing selected entries in the inverse or pseudo-inverse}\n\n\\begin{par}\nIf you want just a few entries from the inverse, it's still better to formulate\nthe problem as a system of linear equations and use a matrix factorization\ninstead of computing inv(A).  The FACTORIZE object does this for you, by\noverloading the subsref operator.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (1000) ;\n\ntic ; S = inv (A)     ; S (2:3,4), toc\ntic ; S = inverse (A) ; S (2:3,4), toc\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}ans =\n   -0.2554\n    0.0993\nElapsed time is 0.047095 seconds.\nans =\n   -0.2554\n    0.0993\nElapsed time is 0.030233 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Computing the entire inverse or pseudo-inverse}\n\n\\begin{par}\nRarely, and I mean RARELY, you really do need the inverse.  More frequently\nwhat you want is the pseudo-inverse.  You can force a factorization to become a\nplain matrix by converting it to float.  Note that inverse(A) only handles\nfull-rank matrices (either dense or sparse), whereas pinv(A) works for all\ndense matrices (not sparse).\n\\end{par} \\vspace{1em}\n\\begin{par}\nThe explicit need for inv(A) (or S=A\\ensuremath{\\backslash}eye(n), which is the\nsame thing) is RARE.  If you ever find yourself multiplying by the inverse,\nthen you know one thing for sure.  You know with certainty that you don't know\nwhat you're doing.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (500) ;\ntic ; S1 = inv (A) ;            ; toc\ntic ; S2 = float (inverse (A)) ; toc\nnorm (S1-S2)\n\nA = rand (500,400) ;\ntic ; S1 = pinv (A)             ; toc\ntic ; S2 = float (inverse (A)) ; toc\nnorm (S1-S2)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.009174 seconds.\nElapsed time is 0.013046 seconds.\nans =\n   1.6446e-12\nElapsed time is 0.073158 seconds.\nElapsed time is 0.016360 seconds.\nans =\n   1.7565e-14\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Update/downdate of a dense Cholesky factorization}\n\n\\begin{par}\nWilkinson considered the update/downdate of a matrix factorization to be a key\nproblem in computational linear algebra.  The idea is that you first factorize\na matrix.  Next, make a low-rank change to A, and patch up (or down...) the\nfactorization so that it becomes the factorization of the new matrix.  In\nMATLAB, this only works for dense symmetric positive definite matrices, via\ncholupdate.  This is much faster than computing the new factorization from\nscratch.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nn = 1000 ;\nA = rand (n) ;\nA = A*A' + n*eye (n) ;\nw = rand (n,1) ; t = rand (n,1) ; b = rand (n,1) ;\nF = factorize (A) ;\n\ntic ; F = cholupdate (F,w,'+') ; x = F\\b ; toc\ntic ; y = (A+w*w')\\b ;      toc\nnorm (x-y)\n\ntic ; F = cholupdate (F,t,'-') ; x = F\\b ; toc\ntic ; y = (A+w*w'-t*t')\\b ; toc\nnorm (x-y)\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 0.010284 seconds.\nElapsed time is 0.015608 seconds.\nans =\n   3.6395e-17\nElapsed time is 0.011662 seconds.\nElapsed time is 0.019173 seconds.\nans =\n   3.5119e-17\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Caveat Executor}\n\n\\begin{par}\nOne caveat:  If you have a large number of very small systems to solve, the\nobject-oriented overhead of creating and using an object can dominate the run\ntime, at least in MATLAB R2011a.  For this case, if you want the best\nperformance, stick with BACKSLASH, or LU and LINSOLVE (just extract the\nappropriate formulas from the M-files in the FACTORIZE package).\n\\end{par} \\vspace{1em}\n\\begin{par}\nHopefully the object-oriented overhead will drop in future versions of MATLAB,\nand you can ignore this caveat.\n\\end{par} \\vspace{1em}\n\\begin{verbatim}\nA = rand (10) ; b = rand (10,1) ; F = factorize (A) ;\n\ntic ; for k = 1:10000, x = F\\b ; end ; toc\n\ntic ; for k = 1:10000, x = A\\b ; end ; toc\n\n[L,U,p] = lu (A, 'vector') ;\nopL = struct ('LT', true) ;\nopU = struct ('UT', true) ;\ntic ;\nfor k = 1:10000\n    x = linsolve (U, linsolve (L, b(p,:), opL), opU) ;\nend\ntoc\n\\end{verbatim}\n\n        \\color{lightgray} \\begin{verbatim}Elapsed time is 1.156836 seconds.\nElapsed time is 0.123091 seconds.\nElapsed time is 0.057961 seconds.\n\\end{verbatim} \\color{black}\n    \n\n\\subsection*{Summary}\n\n\\begin{par}\nSo ... don't use INV, and don't worry about how to use LU, CHOL, or QR\nfactorization.  Just install the FACTORIZE package, and you're on your way.\nAssuming you are now in the Factorize/ directory, cut-and-paste these commands\ninto your command window:\n\\end{par} \\vspace{1em}\n\\begin{verbatim}addpath (pwd)\nsavepath\\end{verbatim}\n\\begin{par}\nAnd remember ...\n\\end{par} \\vspace{1em}\n\\begin{par}\n{\\em Don't let that INV go past your eyes; to solve that system, FACTORIZE!}\n\\end{par} \\vspace{1em}\n\n\n\n\\end{document}\n    \n", "meta": {"hexsha": "518a4a8bf888851137c27b7e924de47e14371936", "size": 18261, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MATLAB_Tools/Factorize/Doc/factorize_demo.tex", "max_stars_repo_name": "mattypumn/SuiteSparse", "max_stars_repo_head_hexsha": "c010fb4110155be339fc95d26f6f6e8e1038ce11", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MATLAB_Tools/Factorize/Doc/factorize_demo.tex", "max_issues_repo_name": "mattypumn/SuiteSparse", "max_issues_repo_head_hexsha": "c010fb4110155be339fc95d26f6f6e8e1038ce11", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MATLAB_Tools/Factorize/Doc/factorize_demo.tex", "max_forks_repo_name": "mattypumn/SuiteSparse", "max_forks_repo_head_hexsha": "c010fb4110155be339fc95d26f6f6e8e1038ce11", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8984771574, "max_line_length": 95, "alphanum_fraction": 0.6822189365, "num_tokens": 5989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832354982645, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.42040309428816713}}
{"text": "\\documentclass[11pt,twoside]{article}\n\n\\usepackage[headings]{fullpage}\n\\usepackage{hyperref}\n\\pagestyle{myheadings}\n\\markboth{Fire}{Fire}\n\n\\usepackage[utopia]{mathdesign}\n\n\\input{../../fncextra}\n\n\\begin{document}\n\n\\begin{center}\n  \\bf We didn't start the fire\n\\end{center}\n\nThe initial-value problem\n\\begin{equation}\n  \\label{eq:fire}\n  \\frac{dr}{dt} = r^2(1-r), \\qquad t > 0, \\quad r(0)=r_0,\n\\end{equation}\nis a simple model for the radius of a \\href{https://youtu.be/Q58-la_yAB4}{spherical flame ball in zero gravity}. If $r$ is initially small, it grows slowly for a while before rapidly increasing to a value close to 1, which it approaches asymptotically. \n\nAlthough the solution is quite simple, it proves to be surprisingly challenging for some IVP solvers, including Euler's method.\n\n\\subsection*{Preparation}\n\nRead sections 6.1 and 6.2. \n\n\\subsection*{Goals}\n\nYou will solve the flame ball equation numerically using Euler's method, observing its convergence. \n\n\\subsection*{Procedure}\n\nDownload the template code and edit it to perform the following steps. \n\n\\begin{enumerate}\n\t\\item Follow the script to create a high-accuracy reference solution of the problem with $r_0=0.01$. Plot the reference solution for $0\\le t\\le 500$. \n  \\item For $n = 100,200,400,800,1600,6400,25600$, use the\n    \\texttt{eulerivp} function to solve the IVP with $r_0=0.01$ up to\n    time $t=100$. Find the error in the Euler solution by taking the\n    difference between its value of $r$ at\n   and the reference solution at $t=100$. Make a log-log plot of the errors and verify that the method is first-order convergent.\n  \\item Repeat part 2 but at time $t=200$. This time, the convergence behavior is a lot less smooth than first-order accuracy might seem to imply.\n  \\item Plot the solution $r(t)$ over $0\\le t \\le 500$ using \\texttt{eulerivp} with $n=150$, 200, 250, and 300. Even though the errors are getting smaller, these could hardly be called ``good'' solutions qualitatively!\n\\end{enumerate}\n\n\n\\end{document}\n", "meta": {"hexsha": "517590e6929cdfe580d2e57ad6b63444f1c793ee", "size": 2009, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "labs/chapter06/Fire/DidntStartTheFire.tex", "max_stars_repo_name": "snowdj/fnc-extras", "max_stars_repo_head_hexsha": "ef51fada748de1326a4ce645fbcb0c2499cb2b8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 109, "max_stars_repo_stars_event_min_datetime": "2018-04-21T09:02:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T19:03:54.000Z", "max_issues_repo_path": "labs/chapter06/Fire/DidntStartTheFire.tex", "max_issues_repo_name": "snowdj/fnc-extras", "max_issues_repo_head_hexsha": "ef51fada748de1326a4ce645fbcb0c2499cb2b8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-12-04T22:17:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-03T21:04:47.000Z", "max_forks_repo_path": "labs/chapter06/Fire/DidntStartTheFire.tex", "max_forks_repo_name": "snowdj/fnc-extras", "max_forks_repo_head_hexsha": "ef51fada748de1326a4ce645fbcb0c2499cb2b8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 49, "max_forks_repo_forks_event_min_datetime": "2017-04-02T17:21:33.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T17:19:57.000Z", "avg_line_length": 38.6346153846, "max_line_length": 253, "alphanum_fraction": 0.743653559, "num_tokens": 579, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832058771036, "lm_q2_score": 0.7799929104825006, "lm_q1q2_score": 0.4204030794532709}}
{"text": "% !TEX TS-program = pdflatexmk\n\n%\\documentclass[12pt]{amsart}\n\\documentclass[prbg,preprint]{revtex4-1} \n%Manuscripts that demonstrate new relations between apparently unrelated areas of physics are appropriate.\n\\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{bm}\n%\\usepackage{subfig}\n\\usepackage{mathtools}\n\\usepackage{svg}\n%\\usepackage{authblk}\n\\geometry{a4paper} % or letter or a5paper or ... etc\n\\newcommand{\\cvec}[1]{{\\rm{\\bf{#1}}}}\n% \\geometry{landscape} % rotated page geometry\n\n% See the ``Article customise'' template for come common customisations\n\n%\\date{} % delete this line to display the current date\n\n%%% BEGIN DOCUMENT\n\\begin{document}\n\n\\title{Dynamics of Two Freely Rotating Dipoles}\n\\author{Peter T. Haugen}\n\\author{Boyd F. Edwards}\n\\affiliation{Utah State University}\n\n\\maketitle\n%05/07 get dipole_driving web page listed in project\n\\section{Abstract}\n\tThe equations of motion for two spherical dipoles moving freely in a plane are obtained. Special consideration is given to when the two spheres are in contact. Investigations of equilibria, small amplitude motion, and large amplitude motion reveal that possible motions are exclusively quasi-periodic.\n\tTwo distinct modes are identified, one of which is isomorphic with the simple pendulum complete with continual spinning at high energy.\n\t\n%Increasing the degrees of freedom of a simpler system we find the equations of motion for two spherical dipoles and discover more predictable motion rather than less. The equilibria are found and distinct modes of motion are described. One mode is shown to be equivalent to the simple pendulum including continual spinning at high energy.\t\n\t\n\n\\section{Introduction}\n\nIn looking at a pair of unrestrained magnetized spheres we've taken a simpler system and increased its degrees of freedom.\nWhile it's common to maintain the same level of complexity of the motion or increase it, here we find that making the phase space more complex decreases the complexity of the motion.\n\nExamining the interactions between rotating magnets has interesting applications when we consider how magnetic gears \\cite{doi:10.1119/1.5029823} are being used in engineering contexts where friction or operational life span are the dominant considerations \\cite{Modaresahmadi:2019aa}.\nMagnetic gears are appealing as you can transmit rotational motion without the teeth that experience wear and tear.\nThis can be achieved with magnetic components, as a small rotation in one element will prompt a rotation in nearby elements to maintain a minimal energy state.\n\nSeveral simple cases have been examined analytically.\nPollack \\cite{doi:10.1139/p96-151} has investigated interactions between point dipoles fixed in space but which are free to rotate, and finds quasi periodic motion.\nEdwards et al.\\ has taken advantage of some work that shows magnetized spheres experience magnetic fields as though those spheres were point dipoles \\cite{Edwards:2017aa} to discover how one sphere freely sliding around on the surface of another sphere that is fixed in space and orientation leads to chaotic motion \\cite{Edwards:2017ab}.\nFixing one sphere breaks the symmetry in space equivalent to an external torque and prevents conserved total angular momentum from arising.\n\nWe take a union of the Pollack and Edwards systems by allowing both spheres to freely rotate and slide along each other.\nWhile each of these systems has two degrees of freedom, they are different pairs chosen from the more general case and thus not immediately comparable.\nOur combined system has three degrees of freedom.\n%making it distinctly more complicated than either of the earlier two.\nWhile Edwards' system exhibited chaos, this new system does not, even at large amplitudes.\n\nNumerical methods have been developed for arbitrarily complicated arrangements \\cite{Furlani:1995aa} and by examining this simple case analytically we can provide an additional check on their results.\nAs this is a system where magnetic interactions and fields dominate, it can make accounting for all the forces a point of contention \n\\cite{Boyer:1988aa, Vaidman:1990aa, Griffiths:1992aa, Brownstein:1993aa, Hnizdo:1997aa}\n.\nHowever, there is little disagreement on the energy for a dipole in a magnetic field \\cite{Greene:1971aa, Griffiths:1992aa}. \nStarting from the potential and kinetic energies of the sphere and using the Hamiltonian approach we find equations of motion and conserved quantities.\nThis makes examining the dynamics of these two spheres an excellent pedagogical opportunity for using the Hamiltonian approach.\n\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=.85\\linewidth]{./images/coordinates_scalable_2.pdf}\n  \\caption{Schematic of labeling system describing two spheres in the plane featuring both the independent coordinates and the center of mass coordinates.}\n\\end{figure}\n\n\n\\section{Describing the System}\nIntrinsic properties of the two dipoles are: their respective radii, which we shall label as $a_1$ and $a_2$, their masses, $m_1$ and $m_2$, and magnitudes of their dipole moments, $\\mu_1$ and $\\mu_2$.\n\\subsection{Coordinates}\n\\subsubsection{Cartesian}\n\nEach of the dipoles has a location constrained to the x-y plane $\\cvec{r_1}$ and $\\cvec r_2$ along with an orientation for the dipole $\\phi_1$ and $\\phi_2$ which we will also constrain to the x-y plane, measured from the x-axis.\n\\subsubsection{Center Of Mass}\nWe can define a set of composite coordinates and quantities more appropriate for analyzing two-body system using the aforementioned independent coordinates following Taylor's approach \\cite{taylor2005classical}. \n\nThese composite coordinates are as follows: the total and reduced mass,\n\n\\begin{equation}\nm_t = m_1+m_2,\n\\qquad\nm_r = \\frac{m_1m_2}{m_1+m_2},\n\\end{equation}\n\nthe center of mass,\n\\begin{equation}\n\\cvec{R} = \\frac{m_1 \\cvec{r}_1+m_2 \\cvec{r}_2}{m_t},\n% R = \\frac{m_1  r_1+m_2 r_2}{m_t},\n\\end{equation}\n\nand the displacement of dipole 2 from dipole 1,\n\\begin{equation}\n\\cvec{r}\n=  \\cvec r_2-\\cvec r_1 \n= \\textrm{r} [\\cos(\\theta) \\hat {\\cvec x}+\\sin(\\theta) \\hat {\\cvec y}].\n\\end{equation}\n\n\n\\subsection{Hamiltonian}\nTo take advantage of the numerous analytic techniques that can be applied to a system's Hamiltonian, it must first be calculated. Which in turn requires that we find its kinetic and potential energy in terms of its coordinates.\n\\subsubsection{Energies}\nThe kinetic energy, $T$, is \\cite{taylor2005classical}\n%citing taylor mechanics for the reduced kinetic\n\\begin{equation}\n\t\\begin{multlined}\n            T = \n            \\frac{1}{2}(\n            \tm_1 \\dot {\\cvec{r}_1}^2\n            \t+m_2 \\dot {\\cvec{r}_2}^2\n            \t+ I_1 \\dot \\phi_1^2\n            \t+ I_2 \\dot \\phi_2^2\n            )\n            \\\\\n            =\\frac{1}{2}(\n            \tm_t \\dot R^2\n            \t+m_r \\dot r^2\n            \t+m_r r^2 \\dot \\theta^2\n            \t+ I_1 \\dot \\phi_1^2\n            \t+ I_2 \\dot \\phi_2^2\n).\n  \\end{multlined}\n\\end{equation}\n%BFE:rederive kinetic energy \n%PTH: or cite taylor's result have done the derivation before but this paper is already a bit long of tooth and we want to get to the novelty sooner rather than later\nThe first three terms in the second equation are for two bodies in center of mass coordinates with the final two terms accounting for the internal degrees of freedom of the spheres. \n%cite prior edwards work for energy interaction here\n\nThe potential energy for dipole 1 is the dot product of its dipole moment with the local field \\cite{Edwards:2017aa}, which in this case is caused entirely by dipole 2.\n\\begin{equation}\nU_1 = -\\boldsymbol \\mu_1 \\cdot \\cvec B_2.\n\\end{equation}\n\nThe magnetic field for a dipole at some point of interest $\\cvec r_i$ being taken from \\cite{griffiths2013introduction}\n\n\\begin{equation}\n\\cvec B_2 = \n\\frac{\\mu_0}{4\\pi}\\left[\n\t3\\frac{\\boldsymbol \\mu_2 \\cdot (\\cvec r_i - \\cvec r_2)}{|\\cvec r_i - \\cvec r_2|^5}(\n\t\\cvec r_i - \\cvec r_2\n\t)\n\t-\\frac{\\boldsymbol \\mu_2}{|\\cvec r_i - \\cvec r_2|^3}\n\\right].\n\\end{equation}\n\nUsing our definition for $\\cvec r$ we can simplify the potential energy to\n\n\\begin{equation}\nU_1 = \n\\frac{\\mu_0}{4\\pi}\n\\frac{1}{r^3}\\left[\n\t\\boldsymbol \\mu_1 \\cdot \\boldsymbol \\mu_2\n\t-3(\n\t\t\\boldsymbol \\mu_2 \\cdot \\hat {\\cvec r}\n\t\t)(\n\t\t\\boldsymbol \\mu_1 \\cdot \\hat {\\cvec r}\t\t\n\t\t)\n\\right].\n\\end{equation}\n\nThe $\\boldsymbol \\mu_1 \\cdot \\boldsymbol \\mu_2$ term accounts \nfor the direct contribution of the relative orientation of the two dipole moments on $U$, \n%for the direct relation of the two dipoles' relative orientation have with $U$, \nand the $\\boldsymbol \\mu_i \\cdot \\hat {\\cvec r}$ term accounts for the impact on $U$ due to the orientation of their dipole moments relative to their spatial position.\nThis is symmetric under substitution of 1 for 2 and vice versa so we have a total interaction potential of\n\n\\begin{equation}\nU =\nU_1+U_2\n= \n2U_1.\n\\end{equation}\n\nThis potential when expanding the dot products out in terms of all three respective angles leaves us with\n\n\\begin{equation}\n  \\begin{multlined}\n\\hat {\\boldsymbol \\mu_i} =  \\cos \\phi_i \\hat {\\cvec x} + \\sin \\phi_i \\hat {\\cvec y}\n\\\\\n\\hat {\\cvec r} =  \\cos \\theta \\hat {\\cvec x} + \\sin \\theta \\hat {\\cvec y}\n\\\\\nU(\\phi_1, \\phi_2, \\theta, r) =\n-\\frac{\\mu_0}{4\\pi}\n\\frac{\\mu_1 \\mu_2}{2}\n\\frac{1}{r^3}\\left[\n\t\\cos(\\phi_1-\\phi_2)\n\t+3\\cos(\\phi_1+\\phi_2 -2\\theta)\n\\right].\n  \\end{multlined}\n\\end{equation}\n\nHaving an expression for kinetic and potential energy, the Lagrangian is \n%good place to talk about why we're neglecting radiation losses in stump_damping\n\\begin{equation}\n  \\begin{multlined}\n    L=T-U=\n    \\frac{1}{2}(\n        m_t \\dot R^2\n        +m_r \\dot r^2\n        +m_r r^2 \\dot \\theta^2\n        + I_1 \\dot \\phi_1^2\n        + I_2 \\dot \\phi_2^2\n    )\n    \\\\\n    +\n    \\frac{\\mu_0}{4\\pi}\n    \\frac{\\mu_1 \\mu_2}{2}\n    \\frac{1}{r^3}\n%    \\left[\n    [\n        \\cos(\\phi_1-\\phi_2)\n        +3\\cos(\\phi_1+\\phi_2 -2\\theta)\n%    \\right]\n    ].\n  \\end{multlined}\n\\end{equation}\n\nIt might be noted that this Lagrangian takes into account only magnetostatic interactions which ignores the resulting damping one would see from accelerating dipoles which would necessarily happen anytime the system is away from equilibrium. The scale of those corrections will be addressed in  later section.\n%section labeling\n\\subsubsection{Momenta}\n\nThe first observation we make is that the Lagrangian is independent of the center of mass position making the corresponding momenta a constant of motion and we will proceed assuming we are in the inertial frame where it is 0 and R is 0. Determining the other momenta we use the relationship $\\partial_{\\dot q_i} L =p_i$ to arrive at\n\n\\begin{subequations}\n    \\begin{equation}\n        \\partial_{\\dot \\phi_1} L = I_1\\dot \\phi_1 = p_{\\phi_1},\n    \\end{equation}\n    \\begin{equation}\n        \\partial_{\\dot \\phi_2} L =I_2\\dot \\phi_2 = p_{\\phi_2},\n    \\end{equation}\n    \\begin{equation}\n        \\partial_{\\dot \\theta} L =m_r r^2 \\dot \\theta = p_{\\theta},\n    \\end{equation}\n    \\begin{equation}\n        \\partial_{\\dot r} L = m_r \\dot r = p_r.\n    \\end{equation}\n\\end{subequations}\n\nAllowing us to find the Hamiltonian with the expression of \n\n\\begin{equation}\nH=\\Sigma_i p_i \\dot q_i - L\n=\n\\frac{1}{2}\\left(\n\t\\frac{p_r^2}{m_r}\n\t+\\frac{p_\\theta^2}{m_r r^2}\n\t+\\frac{p_{\\phi_1}^2}{I_1}\n\t+\\frac{p_{\\phi_2}^2}{I_2}\n\\right)+U(\\phi_1,\\phi_2,\\theta, r).\n\\end{equation}\n\\subsection{Dimensionless coordinates}\nTo get at the essentials of the system we will examine it in a natural set of dimensions. First we will characterize the second dipole in terms of the first such that \n$m_2=\\alpha m_1$,   \n$a_2=\\beta a_1$,\n$\\mu_2=\\gamma \\mu_1$. This lets us rewrite the energies as\n%I = 2/5 mr^2\n\\begin{subequations}\n    \\begin{equation}\n        T=\\frac{1}{2}\\left [\n\t\\frac{(1+\\alpha)m_1}{\\alpha m_1^2} p_r^2\n\t+\\frac{(1+\\alpha)m_1}{\\alpha m_1^2} \\frac{p_\\theta^2}{r^2}\n\t+p_{\\phi_1}^2 \\frac{5}{2m_1a_1^2}\n\t+p_{\\phi_2}^2 \\frac{1}{\\alpha\\beta^2} \\frac{5}{2m_1a_1^2}      \n        \\right ],\n    \\end{equation}\n    \\begin{equation}\n        U=\n\t    -\\frac{\\mu_0}{4\\pi}\n\t    \\frac{\\gamma \\mu_1^2}{2}\n\t    \\frac{1}{r^3}[\n\t        \\cos(\\phi_1-\\phi_2)\n\t        +3\\cos(\\phi_1+\\phi_2 -2\\theta)\n\t    ].\n    \\end{equation}\n\\end{subequations}\n\nWe go on to define our units as follows: \n$L_0=2a_1$ for length,\n$\\mu_1$ for magnetic moment,\n$F_0=3\\mu_0 \\mu_1^2/(2\\pi L_0^4)$ for force,\n$F_0L_0$ for energy,\n$T_0=\\sqrt{m_1L_0/F_0}$ for time,\n$T_0^{-1},T_0^{-2}$ for angular velocities and accelerations,\n$m_1L_0/T_0$ for linear momentum and \n$m_1L_0^2/T_0$ for angular momentum. This lets us rewrite the energies as\n\n\\begin{subequations}\\label{gen_ham}\n    \\begin{equation}\n        T=\\frac{1}{2}\\left [\n\t\\frac{(1+\\alpha)}{\\alpha } p_r^2\n\t+\\frac{(1+\\alpha)}{\\alpha } \\frac{p_\\theta^2}{r^2}\n\t+10 p_{\\phi_1}^2 \n\t+\\frac{10}{\\alpha\\beta^2} p_{\\phi_2}^2      \n        \\right ],\n    \\end{equation}\n    \\begin{equation}\n        U=\n\t    -\\frac{\\gamma}{12}\n\t    \\frac{1}{r^3}[\n\t        \\cos(\\phi_1-\\phi_2)\n\t        +3\\cos(\\phi_1+\\phi_2 -2\\theta)\n\t    ].\n    \\end{equation}\n\\end{subequations}\n\nLet us finally make two more assumptions. First, that the two spheres are identical, $\\alpha=\\beta=\\gamma=1$. Second, that there is some contact potential energy $U_C$ preventing the two spheres from overlapping that prohibits $r$ from getting less than 1. These two assumptions produce the Hamiltonian we'll be investigating for the remainder of our discussion\n\n\\begin{equation}\n  \\begin{multlined}\n\tH=T+U=\n\t\\frac{1}{2}\\left (\n\t2 p_r^2\n\t+2 \\frac{p_\\theta^2}{r^2}\n\t+10 p_{\\phi_1}^2 \n\t+10 p_{\\phi_2}^2      \n        \\right )\n        \\\\\n\t-\n\t\\frac{1}{12}\n\t\\frac{1}{r^3}[\n\t        \\cos(\\phi_1-\\phi_2)\n\t        +3\\cos(\\phi_1+\\phi_2 -2\\theta)\n\t    ]+U_C.\n  \\end{multlined}\n\\end{equation}\n\n\\section{Analysis}\n\\subsection{Analytic Results}\n\n\\subsubsection{Equilibrium Analysis}\nLet us first examine the equations of motion and see if there exist any equilibria between the spheres while they are in contact with each other ($r=1$). The Hamiltonian equations of motion we find are\n%04/15 include the p dots in equations, make the contact term on a second line\n\\begin{subequations}\n    \\begin{equation}\\label{fphi1}\n       \\dot p_{\\phi_1}= \n       -\\partial_{\\phi_1} H = \n\t- \\frac{1}{12} \\sin{\\left (\\phi_{1} - \\phi_{2} \\right )} - \\frac{1}{4} \\sin{\\left (\\phi_{1} + \\phi_{2} - 2 \\theta \\right )},\n    \\end{equation}\n    \\begin{equation}\\label{fphi2}\n        \\dot p_{\\phi_2}= \n        -\\partial_{\\phi_2} H =\n\t\\frac{1}{12} \\sin{\\left (\\phi_{1} - \\phi_{2} \\right )} - \\frac{1}{4} \\sin{\\left (\\phi_{1} + \\phi_{2} - 2 \\theta \\right )},\n    \\end{equation}\n    \\begin{equation}\\label{ftht}\n        \\dot p_{\\theta}= \n        -\\partial_{\\theta} H =\n        \\frac{1}{2} \\sin{\\left (\\phi_{1} + \\phi_{2} - 2 \\theta \\right )},\n    \\end{equation}\n    \\begin{equation}\\label{fr}\n        \\dot p_{r}= \n        -\\partial_{r} H = \n        2 p_{\\theta}^{2}r^{-3}\n        - \\left[\n            \\frac{1}{4} \\cos{\\left (\\phi_{1}- \\phi_{2} \\right )} \n            + \\frac{3}{4} \\cos{\\left (\\phi_{1} + \\phi_{2} - 2 \\theta \\right )}\n            \\right]r^{-4}+F_C.\n    \\end{equation}\n\\end{subequations}\n%04/15 static vs constant, edwards leans towards constant\n%American journal of physics reference equations\nInspecting Eq.~(\\ref{ftht}) we see immediately that the orbital momentum, $p_\\theta$, is static if and only if $\\phi_{1} + \\phi_{2} - 2 \\theta = j \\pi$ where $j$ is any integer. Using that as a constraint we then see that spin momenta are both static if the previous equation holds and $\\phi_{1} + \\phi_{2} = k\\pi$ where $k$ is an integer independent of $j$. These two constraints produce a set of equilibrium curves where\n\n\\begin{subequations}\n\t\\begin{equation}\n\t\t\\phi_1 = \\frac{j+k}{2}\\pi +\\theta,\n\t\\end{equation}\n\t\\begin{equation}\n\t\t\\phi_2 = \\frac{j-k}{2}\\pi +\\theta,\n\t\\end{equation}\n\\end{subequations}\n%04/15 do a more thorough explanation of symmetry of hamiltonian\n%list out different j,k's, converge on (j,k)\nand all the forces on the three angular momenta are 0. However since our Hamiltonian is periodic over $2\\pi$ we're interested in $(j,k)$ permuting through 0 and 1. This leaves us with 4 curves, until we consider the constraint that Eq.~(\\ref{fr}) must be negative to maintain contact. If j is odd, then we're left with a resulting positive radial force of $1/2$, and we lose contact. So we've narrowed down from an infinite number of equilibrium curves to two, which, using the j-k notation are (0,0) and (0,1). These curves correspond with the continuous ground states Schönke \\cite{PhysRevApplied.4.064007} found despite not fixing the dipoles to rotate in place.\n\n\n\n\\subsubsection{Normal Mode Analysis}\nEquilibria and equations of motion in hand we can do small angle perturbations. Noting that near an equilibrium point \n$\\Gamma_i = \n(\n\\phi_{1i},\\phi_{2i},\\theta_{i},\np_{\\phi_{1i}},p_{\\phi_{2i}},p_{\\theta_{i}}\n)\n=\n(\\phi_{1i},\\phi_{2i},\\theta_{i},0,0,0)\n$ \nthe changes in momenta will be small, we can do a multi-variable Taylor expansion and produce \n\n\\begin{equation}\\label{taylor_force}\n\t\\dot p_n \n\t=\n\t-\\partial_{q_n}H\n\t\\approx \n\t\\Sigma_m \\partial_{q_m}(-\\partial_{q_n} H)|_{\\Gamma_i} q_m .\n\\end{equation}\n\nIf we define elements in a matrix \n$K_{n,m}= \\partial_{q_m}(-\\partial_{q_n} H)|_{\\Gamma_i}$\nWe can rephrase Eq.~(\\ref{taylor_force}) as \n\n\\begin{equation} \\label{matrix_force}\n\t\\cvec{ \\dot{ p }} \\approx \\widehat K \\cvec q.\n\\end{equation}\n\nTo get this amenable to simple periodic solutions, we would like to recast the momentum vector in terms of a time derivative of our position\n\n\\begin{equation}\n\t\\ddot{ q_n } =\\frac{d}{dt} \\partial_{p_n} H = m_n \\dot p_n.\n\\end{equation}\n\nGiven our Hamiltonian and additional constraint of contact we get a constant effective mass. If we define elements in a diagonal matrix as \n$M_{n,n}=1/m_n$\nthen we can rewrite Eq.~(\\ref{matrix_force}) as \n\n\\begin{equation}\n\t\\widehat M \\cvec{ \\ddot{ q }} \\approx \\widehat K \\cvec q.\n\\end{equation}\n\nAssuming simple periodic solutions of the form $\\cvec q = \\cvec a e^{i\\omega t}$ allows us to recast the above as\n\n\\begin{equation}\n\t( \n\t\\widehat K + \\omega^2 \\widehat M\n\t)  \\cvec{ a}e^{i\\omega t} \\approx 0 .\n\\end{equation}\n\nIf we treat the approximation as an equality, it will only hold for non-trivial motion if the determinant of the matrix $\\widehat K - \\omega^2 \\widehat M$ (referred to here on as the perturbation matrix) is 0. The normal modes are the eigenvectors with frequencies equal to the eigenvalues of the perturbation matrix.\n\nFor the (0,0) equilibrium we find the perturbation matrix to be\n\\begin{equation}\n\t\\left[\\begin{matrix}\n\t\\frac{\\omega^{2}}{10} - \\frac{1}{3} & - \\frac{1}{6} & \\frac{1}{2}\\\\\n\t- \\frac{1}{6} & \\frac{\\omega^{2}}{10} - \\frac{1}{3} & \\frac{1}{2}\\\\\n\t\\frac{1}{2} & \\frac{1}{2} & \\frac{\\omega^{2}}{2} - 1\n\t\\end{matrix}\\right]\n\\end{equation}\n\nWhich only has two non-zero eigenmodes corresponding to when $\\omega^2$ is equal to 5/3 and 7. The lower frequency mode has an eigenvector of [1, -1, 0], indicating it has no motion in the orbital angle, $\\theta$. For this reason we shall refer to it as the spinning mode for its sole form of motion. It possesses an interesting isomorphism we shall examine in more depth later. The second, higher, frequency's eigenvector is [5/2, 5/2,-1] indicating it does possess orbital motion and thus earns the moniker of orbital mode. These modes correspond to the $\\alpha$ and $\\beta$ modes in Pollack \\cite{doi:10.1139/p96-151} respectively. The spinning mode matches exactly. \nAllowing for $\\theta$ to be dynamical appears to result in a higher restoring force as the frequency is higher.\nBrief algebra will reveal that both modes have net-0 angular momentum.\n\nAdditionally this result along with the work Stump did on radiation damping of oscillating dipoles \\cite{Stump:1997aa} lets us estimate the significance of that phenomenon on this system. When approximating the damping effect as leading to exponential decay leads to a time constant, that when expressed in our units, is \n\\begin{equation}\n\\tau_{decay}=180 c^3 \\left (L_0^2 \\omega_0^2\\frac{L_0}{T_0} \\right)^{-1}T_0. \n\\end{equation}\nWhich means for reasonably sized dipoles we would observe an enormous amount of oscillations before any significant energy was lost to simple dipole radiation. Other forms of dissipation would certainly dominate.\n\n\n\\begin{figure}[h]\n\t\\includegraphics[width=0.9\\linewidth ]{./images/animatic.pdf} \n%  \\caption{The top row features four frames of an orbital mode with period 4, while the bottom row a spinning mode with period 8. Numerical results.}\n  \\caption{Numerical results for  four frames of an orbital mode with period 3 (top row), and a spinning mode with period 8 (bottom row).}\n  \n\\end{figure}\n\nFor the (0,1) equilibrium the perturbation matrix is \n\\begin{equation}\n\t\\left[\\begin{matrix}\\frac{\\omega^{2}}{10} - \\frac{1}{6} & - \\frac{1}{3} & \\frac{1}{2}\\\\\n\t- \\frac{1}{3} & \\frac{\\omega^{2}}{10} - \\frac{1}{6} & \\frac{1}{2}\\\\\n\t\\frac{1}{2} & \\frac{1}{2} & \\frac{\\omega^{2}}{2} - 1\\end{matrix}\\right]\\end{equation}\n\nWhich merits two points of observation. First, all the same eigenvectors come forth along with 2 non-zero fundamental frequencies. Second, while the orbital mode has the same frequency, the spinning mode's $\\omega^2=-5/3$. It follows then that the frequency has a negative complex component. When that frequency is put back into the periodic solution of $e^{i\\omega t}$ we'll have a growing exponential indicating that it is unstable.\n\nBoth the (0,0) and (0,1) equilibria points have an $\\omega^2=0$ mode where all the angles have been translated by some equal amount. With all the translation being the same, there's no restoring force and thus no oscillation.\n\n\\subsubsection{Isomorphisms} Examining the spinning mode in more depth we present the variable substitution for the difference and sum of the dipole orientations and corresponding velocity\n\n\\begin{subequations}\n\t\\begin{gather}\n\t\t\\phi_d = \\phi_1-\\phi_2 \\\\\n\t\t\\phi_t = \\phi_1+\\phi_2 \\\\\n\t\t\\dot\\phi_d = \\dot\\phi_1-\\dot\\phi_2 \\\\\n\t\t\\dot\\phi_t = \\dot\\phi_1+\\dot\\phi_2 \n\t\\end{gather}\n\\end{subequations}\n\n%\\end{align}\n%Squaring and summing these new velocities we find \n%%04/15 rewrite to emphasize going over from the langragnian\n%$\\frac{1}{2}(\\dot\\phi_d^2 + \\dot\\phi_t^2) = \\dot\\phi_1^2+\\dot\\phi_2^2$ and similarly $\\frac{1}{20}(\\dot\\phi_d^2 + \\dot\\phi_t^2) = \\frac{1}{10}(\\dot\\phi_1^2+\\dot\\phi_2^2)$.\nMaking these substitutions in the original Lagrangian we find new momenta and a new Hamiltonian.\nThe momenta are $p_{\\phi_d}=\\dot\\phi_d/20$ and $p_{\\phi_t}=\\dot\\phi_t/20$ while the contact Hamiltonian in these coordinates to is\n\n\\begin{equation}\n  \\begin{multlined}\n\tH=T+U=\n\t\\frac{1}{2}\\left (\n\t2 p_\\theta^2\n\t+20 p_{\\phi_d}^2 \n\t+20 p_{\\phi_t}^2      \n        \\right )\n        \\\\\n\t-\n\t\\frac{1}{12}\n\t[\n\t        \\cos \\phi_d\n\t        +3\\cos(\\phi_t-2\\theta)\n\t    ]\n  \\end{multlined}\n\\end{equation}\n\nLet us consider just the spinning mode with $\\phi_t=\\theta=p_{\\phi_t}=p_\\theta=0$. Using this Hamiltonian it becomes clear that when those four variables all start at 0 they stay at 0, reducing this phase space from 6 dimensions to 2.\n\n\\begin{equation}\n\tH_{\\phi_d}=\n\t10 p_{\\phi_d}^2 \n\t-\n\t\\frac{1}{12}\n        \\cos \\phi_d\n\\end{equation}\n\n%04/15 tweak phrasing\n%04/30 how?\nIt is important to note the similarities with the Hamiltonian for a simple pendulum. As is the case for a pendulum, the Hamilton equations lead us to  a second order differential equation $\\ddot \\phi_d = - \\frac{5}{3}\\sin \\phi_d$ providing a second check that the frequency is correct.\n\n\\subsubsection{Coupling}\n\nConsidering now the Hamiltonian for the other two angles we have\n\n\\begin{equation}\n\tH_{\\phi_t, \\theta}=\n\t\\frac{1}{2}\\left (\n\t2 p_\\theta^2\n\t+20 p_{\\phi_t}^2 \n        \\right )\n\t-\n\t\\frac{1}{12}\n\t[\n\t        3\\cos(\\phi_t-2\\theta)\n\t    ],\n\\end{equation}\n\nwhich holds while the contact criterion is observed.\n\n\\begin{subequations}\n\t\\begin{equation}\\label{f_phit}\n\t\t-\\partial_{\\phi_t}H= \\dot p_{\\phi_t} \n\t\t= - \\frac{1}{4} \\sin{\\left (\\phi_{t} - 2 \\theta \\right )}\n\t\\end{equation}\n\t\\begin{equation}\\label{f_tht}\n\t\t-\\partial_{\\theta}H= \\dot p_{\\theta}  \n\t\t= \\frac{1}{2} \\sin{\\left (\\phi_{t} - 2 \\theta \\right )}\n\t\t=-2\\dot p_{\\phi_t}\n\t\\end{equation}\n\t\\begin{equation}\n\t\t\\partial_{p_{\\phi_t}}H= \\dot \\phi_t \n\t\t= 20 p_{\\phi_t}\n\t\\end{equation}\n\t\\begin{equation}\n\t\t\\partial_{p_{\\theta}}H= \\dot \\theta \n\t\t= 2 p_{\\theta}\n\t\\end{equation}\n\\end{subequations}\n\nThe rates of change for the momenta clearly denote a conserved quantity we'll call total angular momentum and denote as \n$L_\\textrm{t} = p_\\theta + 2p_{\\phi_t}$. \n%06/11 compare with conventional total angular momentum\nWith this we can produce the expression\n\n\\begin{equation}\n  \\begin{multlined}\n\t\\phi_t(t) \n\t= \\phi_{t0} + \\int_0^t \\kern-.33em  \\dot \\phi_t  dt\n\t= \\phi_{t0} + \\int_0^t \\kern-.33em 20 p_{ \\phi_t } dt\n\t= \\phi_{t0} + \\int_0^t \\kern-.33em 10 (L_\\textrm{t}-p_{ \\theta }) dt\n\t\\\\\n\t= \\phi_{t0} + 10L_\\textrm{t} t -10 \\int_0^t \\kern-.33em p_{ \\theta } dt.\n  \\end{multlined},\n\\end{equation}\nwhich we'll rearrange to get\n\\begin{equation}\\label{phi_int}\n\t\\int_0^t  p_{ \\theta } dt\n\t= L_\\textrm{t} t + (\\phi_{t0}  - \\phi_t(t))/10.\n\\end{equation}\n%04/16 rewrite to be more stand alone\nA similar integral can be set up for $\\theta$\n\\begin{equation}\\label{tht_int}\n  \\begin{multlined}\n\t\\theta(t) \n\t= \\theta_{ 0} + \\int_0^t  \\dot \\theta  dt\n\t= \\theta_{ 0} + \\int_0^t  2 p_{\\theta} dt\n\t\\\\\n\t\\int_0^t  p_{\\theta} dt = \\frac{1}{2}[\\theta(t)-\\theta_{0}].\n  \\end{multlined}\n\\end{equation}\n\nWhile the integral of $p_\\theta$ is not analytic, the equality between the two holds while contact is maintained which allows us to algebraically rearrange Eq.~(\\ref{phi_int}) and Eq.~(\\ref{tht_int}) to get\n\n\\begin{equation}\n\t\\phi_t(t)=  -5\n\t\\left[\n\t\\theta(t)-\\theta_{0}-\\frac{1}{5}\\phi_{t0}\n\t\\right] \n\t+ 10L_\\textrm{t} t .\n\\end{equation}\n\nConsidering the force on $p_\\theta$ from Eq.~(\\ref{f_tht}) and making this new substitution starting from equilibrium and a zero angular momentum starting condition we have\n\n\\begin{equation}\n\t\\ddot \\theta = \\sin(-5\\theta -2\\theta) = -\\sin 7\\theta \\approx -7\\theta\n\\end{equation}\n\nAnd doing the same with $p_{\\phi_t}$ from Eq.~(\\ref{f_phit}) produces\n\n\\begin{equation}\n\t\\ddot \\phi_t = -\\frac{20}{4}\\sin(\\phi_t +\\frac{2}{5}\\phi_t) =  -5\\sin\\left ( \\frac{7}{5}\\phi_t \\right )\\approx -7\\phi_t\n\\end{equation}\n\nShowing that while the contact constraint holds, the orbital state is also isomorphic with the simple pendulum with the same asymptotic behavior as the small amplitude oscillations we found earlier. With this we see that when $L_\\textrm{t}=0$ and contact maintained we have reduced the problem to two independent pendula. While the periods are independent of each other and unlikely to form a rational fraction, both are periodic. This fact makes the system as a whole no more complicated than quasi-periodic.\n%05/07 explain how these pendulum results imply quasi-periodicity at the most complex\n\n\\subsection{Numerical Results}\n\\subsubsection{Method}\nAn adaptive fourth order Runge-Kutta method was implemented to calculate the trajectory of the system using two different sized time steps, both made smaller until they agreed within a specified precision. To determine if a trajectory has returned through it's original point in phase space $\\boldsymbol{\\Gamma}(0)=\\boldsymbol{\\Gamma}_0$ linear interpolation was used between steps $\\boldsymbol{\\Gamma}_n$ and $\\boldsymbol{\\Gamma}_{n+1}$ to get an estimated time for when the initial value was revisited. This generated six estimated recurrence times. If all six calculated values fell between $t_n$ and $t_{n+1}$ the average was taken and stored. This process was continued until 75 time units had elapsed. The stored recurrence times were fit to the equation $t_m = t_0m$, the slope $t_0$ was taken to be the period.\n\n\\subsubsection{Period vs Energy curves}\nThe spinning and orbital modes were examined independently as they are not coupled together when the contact criterion is maintained. Two hundred initial conditions were simulated with closer resolution taken near transition points. In the case of the spinning mode, the maximum initial kinetic energy was 1/2, taking it well past the point where it begins spinning freely. In the case of the orbital mode, the maximum energy was just below the point where the contact criterion was broken, 1/3 units of initial kinetic energy.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=0.85\\textwidth]{./images/plot.png}\n\t\\caption{Above is a plot of large amplitude period vs total system energy. Solid lines denote numerical results, dashed lines denote asymptotic small amplitude limit}\n\\end{figure}\n\n\\section{Conclusions}\n\nIn the analysis of this system so far we have found an interesting example of coupled non-linear hamiltonian that counter intuitively does not produce chaotic motion. However this is only the first of many questions this system leaves open for discussion. Using equation Eq.~(\\ref{gen_ham}) we can explore if this splitting of the Hamiltonian works for any set of spheres or if there are certain ratios that must hold. We can also explore stability of circular orbits that likely exist. With the appropriate numerical techniques we can examine how these spheres interact with bouncing. These questions and more are available for investigation.\n\n\\section{Acknowledgements}\n\nI'd like to thank my peer Tyler Markham for expressing his opinions on the conveyance of various illustrations in this paper, my peer Jacob Ciafre for listening to me speculate in our kitchen, Alice Haugen for prose editing and most importantly Amy Whillock for her patience and support.\n\n\n%needed diagrams;\n%numerical values of period vs energy\n%geometry layout/labels\n%animatique of basic modes\n%revtek4.1\n\n%go through the logs on AJP again incase there's something else to be cited\n\\bibliographystyle{unsrt}\n\n%05/07 go through edwards ajp chaos paper and grab all the AJP that might be pertinent  (12~,13~ 18~, 24, 25, 26, 27, 33, 34)\n\n\\bibliography{double_magnet_bib}\n\n\n\\end{document}\n", "meta": {"hexsha": "6cd818d079fc092049660b8ec1fe9df40bb164c4", "size": 30077, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "write_up/freely_rotating_dipoles.tex", "max_stars_repo_name": "wolfram74/double_magnets", "max_stars_repo_head_hexsha": "acaf58589a938d33688e3ce783f6a00280495c57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "write_up/freely_rotating_dipoles.tex", "max_issues_repo_name": "wolfram74/double_magnets", "max_issues_repo_head_hexsha": "acaf58589a938d33688e3ce783f6a00280495c57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "write_up/freely_rotating_dipoles.tex", "max_forks_repo_name": "wolfram74/double_magnets", "max_forks_repo_head_hexsha": "acaf58589a938d33688e3ce783f6a00280495c57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.9190839695, "max_line_length": 818, "alphanum_fraction": 0.718788443, "num_tokens": 9158, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4204024443040755}}
{"text": "% -*- mode: latex; TeX-master: \"Vorbis_I_spec\"; -*-\n%!TEX root = Vorbis_I_spec.tex\n% $Id$\n\\section{Floor type 1 setup and decode} \\label{vorbis:spec:floor1}\n\n\\subsection{Overview}\n\nVorbis floor type one uses a piecewise straight-line representation to\nencode a spectral envelope curve. The representation plots this curve\nmechanically on a linear frequency axis and a logarithmic (dB)\namplitude axis. The integer plotting algorithm used is similar to\nBresenham's algorithm.\n\n\n\n\\subsection{Floor 1 format}\n\n\\subsubsection{model}\n\nFloor type one represents a spectral curve as a series of\nline segments.  Synthesis constructs a floor curve using iterative\nprediction in a process roughly equivalent to the following simplified\ndescription:\n\n\\begin{itemize}\n \\item  the first line segment (base case) is a logical line spanning\nfrom x_0,y_0 to x_1,y_1 where in the base case x_0=0 and x_1=[n], the\nfull range of the spectral floor to be computed.\n\n\\item the induction step chooses a point x_new within an existing\nlogical line segment and produces a y_new value at that point computed\nfrom the existing line's y value at x_new (as plotted by the line) and\na difference value decoded from the bitstream packet.\n\n\\item floor computation produces two new line segments, one running from\nx_0,y_0 to x_new,y_new and from x_new,y_new to x_1,y_1. This step is\nperformed logically even if y_new represents no change to the\namplitude value at x_new so that later refinement is additionally\nbounded at x_new.\n\n\\item the induction step repeats, using a list of x values specified in\nthe codec setup header at floor 1 initialization time.  Computation\nis completed at the end of the x value list.\n\n\\end{itemize}\n\n\nConsider the following example, with values chosen for ease of\nunderstanding rather than representing typical configuration:\n\nFor the below example, we assume a floor setup with an [n] of 128.\nThe list of selected X values in increasing order is\n0,16,32,48,64,80,96,112 and 128.  In list order, the values interleave\nas 0, 128, 64, 32, 96, 16, 48, 80 and 112.  The corresponding\nlist-order Y values as decoded from an example packet are 110, 20, -5,\n-45, 0, -25, -10, 30 and -10.  We compute the floor in the following\nway, beginning with the first line:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-1}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nWe now draw new logical lines to reflect the correction to new_Y, and\niterate for X positions 32 and 96:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-2}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nAlthough the new Y value at X position 96 is unchanged, it is still\nused later as an endpoint for further refinement.  From here on, the\npattern should be clear; we complete the floor computation as follows:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-3}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-4}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nA more efficient algorithm with carefully defined integer rounding\nbehavior is used for actual decode, as described later.  The actual\nalgorithm splits Y value computation and line plotting into two steps\nwith modifications to the above algorithm to eliminate noise\naccumulation through integer roundoff/truncation.\n\n\n\n\\subsubsection{header decode}\n\nA list of floor X values is stored in the packet header in interleaved\nformat (used in list order during packet decode and synthesis).  This\nlist is split into partitions, and each partition is assigned to a\npartition class.  X positions 0 and [n] are implicit and do not belong\nto an explicit partition or partition class.\n\nA partition class consists of a representation vector width (the\nnumber of Y values which the partition class encodes at once), a\n'subclass' value representing the number of alternate entropy books\nthe partition class may use in representing Y values, the list of\n[subclass] books and a master book used to encode which alternate\nbooks were chosen for representation in a given packet.  The\nmaster/subclass mechanism is meant to be used as a flexible\nrepresentation cascade while still using codebooks only in a scalar\ncontext.\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\n  1) [floor1\\_partitions] = read 5 bits as unsigned integer\n  2) [maximum\\_class] = -1\n  3) iterate [i] over the range 0 ... [floor1\\_partitions]-1 \\{\n\n        4) vector [floor1\\_partition\\_class\\_list] element [i] = read 4 bits as unsigned integer\n\n     \\}\n\n  5) [maximum\\_class] = largest integer scalar value in vector [floor1\\_partition\\_class\\_list]\n  6) iterate [i] over the range 0 ... [maximum\\_class] \\{\n\n        7) vector [floor1\\_class\\_dimensions] element [i] = read 3 bits as unsigned integer and add 1\n\t8) vector [floor1\\_class\\_subclasses] element [i] = read 2 bits as unsigned integer\n        9) if ( vector [floor1\\_class\\_subclasses] element [i] is nonzero ) \\{\n\n             10) vector [floor1\\_class\\_masterbooks] element [i] = read 8 bits as unsigned integer\n\n           \\}\n\n       11) iterate [j] over the range 0 ... (2 exponent [floor1\\_class\\_subclasses] element [i]) - 1 \\{\n\n             12) array [floor1\\_subclass\\_books] element [i],[j] =\n                 read 8 bits as unsigned integer and subtract one\n           \\}\n      \\}\n\n 13) [floor1\\_multiplier] = read 2 bits as unsigned integer and add one\n 14) [rangebits] = read 4 bits as unsigned integer\n 15) vector [floor1\\_X\\_list] element [0] = 0\n 16) vector [floor1\\_X\\_list] element [1] = 2 exponent [rangebits];\n 17) [floor1\\_values] = 2\n 18) iterate [i] over the range 0 ... [floor1\\_partitions]-1 \\{\n\n       19) [current\\_class\\_number] = vector [floor1\\_partition\\_class\\_list] element [i]\n       20) iterate [j] over the range 0 ... ([floor1\\_class\\_dimensions] element [current\\_class\\_number])-1 \\{\n             21) vector [floor1\\_X\\_list] element ([floor1\\_values]) =\n                 read [rangebits] bits as unsigned integer\n             22) increment [floor1\\_values] by one\n           \\}\n     \\}\n\n 23) done\n\\end{Verbatim}\n\nAn end-of-packet condition while reading any aspect of a floor 1\nconfiguration during setup renders a stream undecodable.  In addition,\na \\varname{[floor1\\_class\\_masterbooks]} or\n\\varname{[floor1\\_subclass\\_books]} scalar element greater than the\nhighest numbered codebook configured in this stream is an error\ncondition that renders the stream undecodable.  Vector\n[floor1\\_x\\_list] is limited to a maximum length of 65 elements; a\nsetup indicating more than 65 total elements (including elements 0 and\n1 set prior to the read loop) renders the stream undecodable.  All\nvector [floor1\\_x\\_list] element values must be unique within the\nvector; a non-unique value renders the stream undecodable.\n\n\\subsubsection{packet decode} \\label{vorbis:spec:floor1-decode}\n\nPacket decode begins by checking the \\varname{[nonzero]} flag:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [nonzero] = read 1 bit as boolean\n\\end{Verbatim}\n\nIf \\varname{[nonzero]} is unset, that indicates this channel contained\nno audio energy in this frame.  Decode immediately returns a status\nindicating this floor curve (and thus this channel) is unused this\nframe.  (A return status of 'unused' is different from decoding a\nfloor that has all points set to minimum representation amplitude,\nwhich happens to be approximately -140dB).\n\n\nAssuming \\varname{[nonzero]} is set, decode proceeds as follows:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [range] = vector \\{ 256, 128, 86, 64 \\} element ([floor1\\_multiplier]-1)\n  2) vector [floor1\\_Y] element [0] = read \\link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer\n  3) vector [floor1\\_Y] element [1] = read \\link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer\n  4) [offset] = 2;\n  5) iterate [i] over the range 0 ... [floor1\\_partitions]-1 \\{\n\n       6) [class] = vector [floor1\\_partition\\_class]  element [i]\n       7) [cdim]  = vector [floor1\\_class\\_dimensions] element [class]\n       8) [cbits] = vector [floor1\\_class\\_subclasses] element [class]\n       9) [csub]  = (2 exponent [cbits])-1\n      10) [cval]  = 0\n      11) if ( [cbits] is greater than zero ) \\{\n\n             12) [cval] = read from packet using codebook number\n                 (vector [floor1\\_class\\_masterbooks] element [class]) in scalar context\n          \\}\n\n      13) iterate [j] over the range 0 ... [cdim]-1 \\{\n\n             14) [book] = array [floor1\\_subclass\\_books] element [class],([cval] bitwise AND [csub])\n             15) [cval] = [cval] right shifted [cbits] bits\n\t     16) if ( [book] is not less than zero ) \\{\n\n\t           17) vector [floor1\\_Y] element ([j]+[offset]) = read from packet using codebook\n                       [book] in scalar context\n\n                 \\} else [book] is less than zero \\{\n\n\t           18) vector [floor1\\_Y] element ([j]+[offset]) = 0\n\n                 \\}\n          \\}\n\n      19) [offset] = [offset] + [cdim]\n\n     \\}\n\n 20) done\n\\end{Verbatim}\n\nAn end-of-packet condition during curve decode should be considered a\nnominal occurrence; if end-of-packet is reached during any read\noperation above, floor decode is to return 'unused' status as if the\n\\varname{[nonzero]} flag had been unset at the beginning of decode.\n\n\nVector \\varname{[floor1\\_Y]} contains the values from packet decode\nneeded for floor 1 synthesis.\n\n\n\n\\subsubsection{curve computation} \\label{vorbis:spec:floor1-synth}\n\nCurve computation is split into two logical steps; the first step\nderives final Y amplitude values from the encoded, wrapped difference\nvalues taken from the bitstream.  The second step plots the curve\nlines.  Also, although zero-difference values are used in the\niterative prediction to find final Y values, these points are\nconditionally skipped during final line computation in step two.\nSkipping zero-difference values allows a smoother line fit.\n\nAlthough some aspects of the below algorithm look like inconsequential\noptimizations, implementors are warned to follow the details closely.\nDeviation from implementing a strictly equivalent algorithm can result\nin serious decoding errors.\n\n{\\em Additional note:} Although \\varname{[floor1\\_final\\_Y]} values in\nthe prediction loop and at the end of step 1 are inherently limited by\nthe prediction algorithm to [0, \\varname{[range]}), it is possible to\n  abuse the setup and codebook machinery to produce negative or\n  over-range results.  We suggest that decoder implementations guard\n  the values in vector \\varname{[floor1\\_final\\_Y]} by clamping each\n  element to [0, \\varname{[range]}) after step 1.  Variants of this\n    suggestion are acceptable as valid floor1 setups cannot produce\n    out of range values.\n\n\\begin{description}\n\\item[step 1: amplitude value synthesis]\n\nUnwrap the always-positive-or-zero values read from the packet into\n+/- difference values, then apply to line prediction.\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [range] = vector \\{ 256, 128, 86, 64 \\} element ([floor1\\_multiplier]-1)\n  2) vector [floor1\\_step2\\_flag] element [0] = set\n  3) vector [floor1\\_step2\\_flag] element [1] = set\n  4) vector [floor1\\_final\\_Y] element [0] = vector [floor1\\_Y] element [0]\n  5) vector [floor1\\_final\\_Y] element [1] = vector [floor1\\_Y] element [1]\n  6) iterate [i] over the range 2 ... [floor1\\_values]-1 \\{\n\n       7) [low\\_neighbor\\_offset] = \\link{vorbis:spec:low:neighbor}{low\\_neighbor}([floor1\\_X\\_list],[i])\n       8) [high\\_neighbor\\_offset] = \\link{vorbis:spec:high:neighbor}{high\\_neighbor}([floor1\\_X\\_list],[i])\n\n       9) [predicted] = \\link{vorbis:spec:render:point}{render\\_point}( vector [floor1\\_X\\_list] element [low\\_neighbor\\_offset],\n\t\t\t\t      vector [floor1\\_final\\_Y] element [low\\_neighbor\\_offset],\n                                      vector [floor1\\_X\\_list] element [high\\_neighbor\\_offset],\n\t\t\t\t      vector [floor1\\_final\\_Y] element [high\\_neighbor\\_offset],\n                                      vector [floor1\\_X\\_list] element [i] )\n\n      10) [val] = vector [floor1\\_Y] element [i]\n      11) [highroom] = [range] - [predicted]\n      12) [lowroom]  = [predicted]\n      13) if ( [highroom] is less than [lowroom] ) \\{\n\n            14) [room] = [highroom] * 2\n\n          \\} else [highroom] is not less than [lowroom] \\{\n\n            15) [room] = [lowroom] * 2\n\n          \\}\n\n      16) if ( [val] is nonzero ) \\{\n\n            17) vector [floor1\\_step2\\_flag] element [low\\_neighbor\\_offset] = set\n            18) vector [floor1\\_step2\\_flag] element [high\\_neighbor\\_offset] = set\n            19) vector [floor1\\_step2\\_flag] element [i] = set\n            20) if ( [val] is greater than or equal to [room] ) \\{\n\n                  21) if ( [highroom] is greater than [lowroom] ) \\{\n\n                        22) vector [floor1\\_final\\_Y] element [i] = [val] - [lowroom] + [predicted]\n\n\t\t      \\} else [highroom] is not greater than [lowroom] \\{\n\n                        23) vector [floor1\\_final\\_Y] element [i] = [predicted] - [val] + [highroom] - 1\n\n                      \\}\n\n                \\} else [val] is less than [room] \\{\n\n                    24) if ([val] is odd) \\{\n\n                        25) vector [floor1\\_final\\_Y] element [i] =\n                            [predicted] - (([val] + 1) divided by  2 using integer division)\n\n                      \\} else [val] is even \\{\n\n                        26) vector [floor1\\_final\\_Y] element [i] =\n                            [predicted] + ([val] / 2 using integer division)\n\n                      \\}\n\n                \\}\n\n          \\} else [val] is zero \\{\n\n            27) vector [floor1\\_step2\\_flag] element [i] = unset\n            28) vector [floor1\\_final\\_Y] element [i] = [predicted]\n\n          \\}\n\n     \\}\n\n 29) done\n\n\\end{Verbatim}\n\n\n\n\\item[step 2: curve synthesis]\n\nCurve synthesis generates a return vector \\varname{[floor]} of length\n\\varname{[n]} (where \\varname{[n]} is provided by the decode process\ncalling to floor decode).  Floor 1 curve synthesis makes use of the\n\\varname{[floor1\\_X\\_list]}, \\varname{[floor1\\_final\\_Y]} and\n\\varname{[floor1\\_step2\\_flag]} vectors, as well as [floor1\\_multiplier]\nand [floor1\\_values] values.\n\nDecode begins by sorting the scalars from vectors\n\\varname{[floor1\\_X\\_list]}, \\varname{[floor1\\_final\\_Y]} and\n\\varname{[floor1\\_step2\\_flag]} together into new vectors\n\\varname{[floor1\\_X\\_list]'}, \\varname{[floor1\\_final\\_Y]'} and\n\\varname{[floor1\\_step2\\_flag]'} according to ascending sort order of the\nvalues in \\varname{[floor1\\_X\\_list]}.  That is, sort the values of\n\\varname{[floor1\\_X\\_list]} and then apply the same permutation to\nelements of the other two vectors so that the X, Y and step2\\_flag\nvalues still match.\n\nThen compute the final curve in one pass:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [hx] = 0\n  2) [lx] = 0\n  3) [ly] = vector [floor1\\_final\\_Y]' element [0] * [floor1\\_multiplier]\n  4) iterate [i] over the range 1 ... [floor1\\_values]-1 \\{\n\n       5) if ( [floor1\\_step2\\_flag]' element [i] is set ) \\{\n\n             6) [hy] = [floor1\\_final\\_Y]' element [i] * [floor1\\_multiplier]\n \t     7) [hx] = [floor1\\_X\\_list]' element [i]\n             8) \\link{vorbis:spec:render:line}{render\\_line}( [lx], [ly], [hx], [hy], [floor] )\n             9) [lx] = [hx]\n\t    10) [ly] = [hy]\n          \\}\n     \\}\n\n 11) if ( [hx] is less than [n] ) \\{\n\n        12) \\link{vorbis:spec:render:line}{render\\_line}( [hx], [hy], [n], [hy], [floor] )\n\n     \\}\n\n 13) if ( [hx] is greater than [n] ) \\{\n\n            14) truncate vector [floor] to [n] elements\n\n     \\}\n\n 15) for each scalar in vector [floor], perform a lookup substitution using\n     the scalar value from [floor] as an offset into the vector \\link{vorbis:spec:floor1:inverse:dB:table}{[floor1\\_inverse\\_dB\\_static\\_table]}\n\n 16) done\n\n\\end{Verbatim}\n\n\\end{description}\n", "meta": {"hexsha": "ce45c4b1e7696173cff44ccc84b31087dc61737b", "size": 15786, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib-src/libvorbis/doc/07-floor1.tex", "max_stars_repo_name": "Marcusz97/CILP_Facilitatore_Audacity", "max_stars_repo_head_hexsha": "fe7f59365317ce425abbaa79c973e931232c8680", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1982, "max_stars_repo_stars_event_min_datetime": "2017-03-07T18:45:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T15:28:57.000Z", "max_issues_repo_path": "audio/windows/libvorbis-1.3.5/doc/07-floor1.tex", "max_issues_repo_name": "mitghi/engine", "max_issues_repo_head_hexsha": "d46afd9929b6d971e0259589e8a3a973f9f8425a", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1095, "max_issues_repo_issues_event_min_datetime": "2016-04-10T18:15:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T18:21:20.000Z", "max_forks_repo_path": "audio/windows/libvorbis-1.3.5/doc/07-floor1.tex", "max_forks_repo_name": "mitghi/engine", "max_forks_repo_head_hexsha": "d46afd9929b6d971e0259589e8a3a973f9f8425a", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 516, "max_forks_repo_forks_event_min_datetime": "2016-03-29T19:41:27.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T20:10:56.000Z", "avg_line_length": 38.881773399, "max_line_length": 144, "alphanum_fraction": 0.6827568732, "num_tokens": 4480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.42037978960584904}}
{"text": "\n\\chapter{Interactions}\n\nIn this chapter, we are going to investigate the effects of interactions.\nWhen the field theory is no longer free, the notion of free particle is not very well defined.\nAlso, the interactions actually gives the physical quantities that can be measured. \nFor example the scattering amplitudes.\n\nWe will mainly focus on the scalar field theory, as the complexity of the vector or spinor field mainly comes from the algebraic structures of themselves.\nAfter explaining the stories of the scalar filed, we will try to generalize them to the vector and spinor cases.\n\n\n\\section{Perturbation Theory}\n\\subsection{Real-space Formalism}\nFor interaction theory, the partition function can be formally expressed as:\n\\begin{equation}\n\tZ[J] = \\exp\\left(i\\int d^dx \\mathcal{L}_{\\mathrm{int}}\\left[\\frac{\\delta}{i\\delta J(x)}\\right]\\right)Z_0[J].\n\\end{equation}\nThe expectation values for a generic operator of the form $O(\\phi)$ can be evaluated by the true partition function\n\\begin{equation}\\label{eq:ptb-exp-val}\n\t\\langle O(\\phi)\\rangle\n\t= \\frac{1}{Z[0]} \\left. O\\left[\\frac{\\delta}{i\\delta J(x)}\\right] Z[J] \\right|_{J=0}.\n\\end{equation}\n\nThe expression (\\ref{eq:ptb-exp-val}) can be expanded order by order using the Feynman diagram. \nSince the unconnected diagram can be absorbed into $Z[0]$, we only need to calculate the connected diagram.\n\nThe procedure of perturbative expansion with only connected diagrams can be formally represented by introducing the quantity\n\\begin{equation}\n\tZ[J] = Z[0]\\exp\\left(i W[J]\\right).\n\\end{equation}\nThe perturbative expansion of $W[J]$ contain only the connected diagrams.\nNote that for the free theory,\n\\begin{equation*}\n\t\\frac{Z_0[J]}{Z_0[0]} = \\exp\\left[-\\frac{i}{2}\\int d^d x_1 d^d x_2 J(x_1) \\Delta(x_1-x_2)J(x_2)\\right],\n\\end{equation*}\nwhich means\n\\begin{equation*}\n\tW_0 = -\\frac{1}{2}\\int d^d x_1 d^d x_2 J(x_1) \\Delta(x_1-x_2)J(x_2).\n\\end{equation*}\nFor the interaction theory, the expectation (\\ref{eq:ptb-exp-val}) can then be replaced by the connected expectation:\n\\begin{equation}\n\t\\langle O(\\phi)\\rangle_c\n\t\\equiv i\\left. O\\left[\\frac{\\delta}{i\\delta J(x)}\\right] W[J] \\right|_{J=0}.\n\\end{equation}\n\n\nConsider the two-point connected correlation (propagator):\n\\begin{equation}\n\\begin{aligned}\n\ti\\Delta(x_1-x_2)\n\t&= \\langle \\mathcal{T}\\phi(x_1) \\phi(x_2)\\rangle_c \\\\\n\t&= i\\left.\\frac{\\delta^2 W[J]}{i\\delta J(x_1) i\\delta J(x_2)}\\right|_{J=0} \\\\\n\t&= \\left.\\frac{\\delta^2 \\ln Z[J]}{i\\delta J(x_1) i\\delta J(x_2)}\\right|_{J=0}\\\\\n\t&= \\frac{1}{Z[0]}\\left.\\frac{\\delta^2 Z[J]}{i\\delta J(x_1)i\\delta J(x_2)}\\right|_{J=0},\n\\end{aligned}\n\\end{equation}\nwhere we have used the fact that\n\\begin{equation}\n\t\\frac{\\delta Z^n[J]}{\\delta J(x_1) \\cdots \\delta J(x_n)} = 0,\\ \\forall n = 1\\ \\mathrm{mod}\\ 2.\n\\end{equation}\nThe result is the same as the original definition.\n\nFurther, we can consider the four-point connected correlation:\n\\begin{equation}\n\tiV_4 \\equiv \\langle \\mathcal{T}\\phi(x_1) \\phi(x_2) \\phi(x_3) \\phi(x_4)\\rangle_c\n\\end{equation}\nFollowing the same procedure,\n\\begin{equation}\n\\begin{aligned}\n\tiV_4 \n\t=&\\ i\\left.\\frac{\\delta^4 W[J]}{i\\delta J(x_1)i\\delta J(x_2)i\\delta J(x_3)i\\delta J(x_4)}\\right|_{J=0} \\\\\n\t=&\\ \\frac{1}{Z[0]}\\left.\\frac{\\delta^4 Z[J]}{i\\delta J(x_1)i\\delta J(x_2)i\\delta J(x_3)i\\delta J(x_4)}\\right|_{J=0} \\\\\n\t& -i\\Delta(x_1-x_2) i\\Delta(x_3-x_4) \\\\\n\t& -i\\Delta(x_1-x_3) i\\Delta(x_2-x_4) \\\\\n\t& -i\\Delta(x_1-x_4) i\\Delta(x_2-x_3).\n\\end{aligned}\n\\end{equation}\nThe connected correlation function automatically omit those disconnected components.\n\n\n\\subsection{Momentum-space Formalism}\nIn momentum space, the theory is expressed as\n\\begin{equation}\n\\begin{aligned}\n\tS_0[\\phi(k)] &= \\frac{1}{2} \\int\\frac{d^4 k}{(2\\pi)^4}\\ \\phi_R^*(k)(k^2-m_R^2) \\phi_R(k), \\\\\n\tS_\\mathrm{int}[\\phi(k)] &= \\frac{g_R}{4!} \\left(\\prod_{i=1}^{4} \\int \\frac{d^4 k_i}{(2\\pi)^4} \\right) \\left[\\prod_{i=1}^4 \\phi_R(k_i)\\right] \\delta^{(4)}\\left(\\sum_{i=1}^4 k_i\\right), \\\\\n\tS_{\\mathrm{ct}}[\\phi(k)] &= \\frac{1}{2} \\int\\frac{d^4 k}{(2\\pi)^4}\\ \\tilde\\phi_R^*(k)(A k^2 - B m_R^2) \\tilde\\phi_R(k) - C \\cdot S_\\mathrm{int}.\n\\end{aligned}\n\\end{equation}\nFor the free theory:\n\\begin{equation}\n\\begin{aligned}\n\t\\frac{Z_0[J]}{Z_0[0]} &= \\frac{1}{Z_0[0]}\\int D[\\phi] \\exp\\left\\{ -S_0[\\phi(k)] + i \\int\\frac{d^4 k}{(2\\pi)^4} J_k^* \\phi(k) \\right\\} \\\\\n\t&= \\exp\\left\\{ -i \\int\\frac{d^4 k}{(2\\pi)^4} J^*_k \\Delta(k) J_k \\right\\}.\n\\end{aligned}\n\\end{equation}\nSimilarly, the expectation in momentum space is\n\\begin{equation}\n\t\\langle O(\\phi_k)\\rangle\n\t= \\frac{1}{Z[0]} \\left. O\\left[\\frac{\\delta}{i\\delta J^*_k}\\right] Z[J] \\right|_{J=0}.\n\\end{equation}\nThe Feynman diagrams in momentum space is the same as that in real space, just replace the propagator from the real space to the momentum space.\nAlso, at each vertex, the momentum conservation is automatically satisfied.\n\n\n\\section{Renormalized Field Theory}\n\nFor the interacting scalar field, the Hamiltonian do not conserve particle number any more, and the ground state $|\\Omega\\rangle$ is no longer the vacuum $|0\\rangle$.\nConsider the Green's function\n\\begin{equation}\n\tiG(x_1-x_2) = \\langle\\Omega|T\\phi(x_1)\\phi(x_2)|\\Omega\\rangle \n\\end{equation}\nWe can insert a complete basis into the correlation function:\\footnote{Here we assume $\\langle\\Omega|\\phi(x)|\\Omega\\rangle=0$ unless there is spontaneously symmetry breaking happening.}\n\\begin{equation}\n\t1 = |\\Omega\\rangle\\langle\\Omega| + \\sum_\\lambda\\int\\frac{d^3 k}{(2\\pi)^3}\\frac{1}{2\\omega_k}|\\lambda_{\\bm k}\\rangle \\langle\\lambda_{\\bm k}|,\n\\end{equation}\nand the Green's function takes the form:\n\\begin{equation*}\n\tiG(x_1-x_2) = \\sum_\\lambda \\int\\frac{d^3 k}{(2\\pi)^3}\n\t\\left[\\theta(t_1-t_2)\\langle\\Omega|\\phi(x_1)|\\lambda_{\\vec k}\\rangle\\langle\\lambda_{\\vec k}|\\phi(x_2)|\\Omega\\rangle + (t_1\\leftrightarrow t_2, x_1 \\leftrightarrow x_2)\\right].\n\\end{equation*}\nNote that $\\phi(x)=e^{iP\\cdot x}\\phi(0) e^{-iP\\cdot x}$, so that\n\\begin{equation}\n\t\\langle\\lambda_{\\bm k}|\\phi(x)|\\Omega\\rangle \n\t= e^{ik\\cdot x} \\left.\\langle\\lambda_{0}|\\phi(0)|\\Omega\\rangle\\right|_{k^0=\\omega_{\\bm k}}.\n\\end{equation}\nFollowing the same procedure as we do for the free field theory, \n\\begin{equation}\n\tG(x_1-x_2) = \\int_0^\\infty \\frac{dM^2}{2\\pi} \\rho(M^2) G_0(x_1-x_2;M^2),\n\\end{equation}\nwhere the \\textit{spectral function} $\\rho(M^2)$ is\n\\begin{equation}\n\t\\rho(M^2) = \\sum_\\lambda(2\\pi)\\delta(M^2-m_\\lambda^2)|\\langle\\Omega|\\phi(0)|\\lambda_0\\rangle|^2.\n\\end{equation}\nIn particle, near the one-particle state the Green's function looks like:\n\\begin{equation}\\label{eq:scalar-prop-lehmann}\n\ti\\tilde G(k) = \\frac{iZ_{\\phi}}{k^2-m^2+i\\epsilon} + \\mathrm{regular\\ terms}.\n\\end{equation}\nPhysically, Eq.~(\\ref{eq:scalar-prop-lehmann}) states that in the interacting theory, the field operator $\\tilde\\phi(k)$ acting on the vacuum only only generate a single particle state, but also multi-particle states with total momentum $k$.\nHowever, those multi-particle state have different singularity structure in the Greens function, as they only contribute regular terms.\nIf we only care about the propagator of the single particle states, we simply need to extract the singular part of of the Green's function.\nThat is, the singularity of $\\tilde{G}(k)$ gives the (addresses) mass, and the residue \n\\begin{equation*}\n\t\\lim_{k^2 \\rightarrow m^2} (k^2-m^2)\\tilde{G}(k)\n\\end{equation*}\ngives the wave-function normalization factor $Z_\\phi$.\nTrying to restore the original form of the free theory, we consider a renormalized field:\n\\begin{equation}\n\t\\phi_R(x) = \\frac{1}{\\sqrt{Z_\\phi}}\\phi_0(x).\n\\end{equation}\nThe Green's function of $\\phi_R$ has the same form as free theory.\nFor this reason, we generate the asymptotic single-particle state using the renormalized field operator:\n\\begin{equation}\\label{eq:scalar-field-generate-particle}\n\t\\phi_R(k)|\\Omega\\rangle = \\frac{1}{2\\omega_{\\bm k}}|k\\rangle + \\text{multi-particle states}.\n\\end{equation}\n\nIf we want to create a single-particle state, say at time $t=0$.\nWe can do this by acting the operator $\\tilde{\\phi}(k)$ on the vacuum state at time $-T$, then we know when the system evolves for time $T$, it becomes:\n\\begin{equation}\n\te^{-i E_{\\bm k} T}|k\\rangle + e^{-iHT} \\cdot \\text{multi-particle states}.\n\\end{equation}\nHere comes the trick.\nAssuming the theory is gapped (with mass $m^2>0$), the multi-particle states have higher energy than the single particle states.\nWe then replace the $t$ by $(1-i\\epsilon)t$, which effectives impose a suppression factor $e^{-\\epsilon H T}$ to the state.\nIn the $T\\rightarrow \\infty$ limit, the amplitude of the multi-particle states vanishes.\n\nThe story for the spinor field is exactly the same as the scalar field (also assume the particle has nonzero mass).\nHowever, the story for the photon field is different, since the photon is massless.\nA quick escape from the conundrum is to assume the photon has a small mass $m_\\gamma$, and latter set $m_\\gamma \\rightarrow 0$.\n\n\n\n\\section{Cross Section and Decay Rates}\n\nOne important physical observable is the transition amplitude from initial state $|i;t_i\\rangle$ and initial time $t_i$ to the finial state $|f;t_f\\rangle$ at $t_f$.\nIn the scattering experiment, the initial and final states are assumed to be ``free''.\nFor this reason, we can think of the process as start from $t=-\\infty$ to $t=+\\infty$, where free states at $t=\\pm \\infty$ are known as \\textit{asymptotic states}.\nWe give the time-evolution operator a special name: the \\textit{S-matrix}, defined as:\n\\begin{equation}\n\t\\langle f|S| i\\rangle_{\\text{Heisenberg}}\n\t= \\langle f ; \\infty \\mid i ;-\\infty\\rangle.\n\\end{equation}\nThe S-matrix is related to quantities experimentally measurable, for example the cross sections or decay rates, as discussed in the following.\n\n\\subsubsection{Cross Sections}\nThe \\textit{cross section} is an analogy from classical scattering experiment.\nFor example, Rutherford was interested in the size $r$ of an atomic nucleus. \nBy colliding $\\alpha$-particles with gold foil and measuring how many $\\alpha$-particles were scattered, he could determine the cross-sectional area $\\sigma=\\pi r^{2}$ of the nucleus. \n\nImagine there is just a single nucleus. \nThen the \\textit{cross-sectional area} is given by\n\\begin{equation}\n\t\\sigma=\\frac{\\text { number of particles scattered }}{\\text { time } \\times \\text { number density in beam } \\times \\text { velocity of beam }}=\\frac{1}{T} \\frac{1}{\\Phi} N,\n\\end{equation}\nwhere $T$ is the time for the experiment and $\\Phi$ is the incoming flux:\n\\begin{equation*}\n\t\\Phi= \\text{number density} \\times \\text{velocity of beam},\n\\end{equation*}\nand $N$ is the number of particles scattered.\n\nIn quantum mechanical generalization of the notion of cross-sectional area is the cross section, which still has units of area, but has a more abstract meaning as a measure of the interaction strength. \nWhile classically an $\\alpha$-particle either scatters off the nucleus or it does not scatter, quantum mechanically it has a probability for scattering. \nThe classical differential probability is \n\\begin{equation*}\n\tP=\\frac{N}{N_{\\text{inc}}},\n\\end{equation*}\nwhere $N$ is the number of particles scattering into a given area and $N_{\\text {inc }}$ is the number of incident particles. \nSo the quantum mechanical cross section is then naturally\n\\begin{equation}\n\td \\sigma=\\frac{1}{T} \\frac{1}{\\Phi} d P,\n\\end{equation}\nwhere $\\Phi$ is the flux, now normalized as if the beam has just one particle, and $P$ is now the quantum mechanical probability of scattering. \nThe differential quantities $d \\sigma$ and $d P$ are differential in kinematical variables, such as the angles and energies of the final state particles. \nThe differential number of scattering events measured in a collider experiment is\n\\begin{equation}\n\td N=L \\times d \\sigma,\n\\end{equation}\nwhere $L$ is the \\textit{luminosity}, which is defined by this equation.\n\nNow let us relate the formula for the differential cross section to S-matrix elements. \nFrom a practical point of view it is impossible to collide more than two particles at a time, thus we can focus on the special case of S-matrix elements where $|i\\rangle$ is a two-particle state. \nSo, we are interested in the differential cross section for the ($2 \\rightarrow n$) process:\n\\begin{equation}\n\tp_{1}+p_{2} \\rightarrow\\left\\{p_{j}\\right\\}.\n\\end{equation}\nIn the rest frame of one of the colliding particles, the flux is just the magnitude of the velocity of the incoming particle divided by the total volume: $\\Phi=|\\vec{v}| / V$. \nIn a different frame, such as the center-of-mass frame, beams of particles come in from both sides, and the flux is then determined by the difference between the particles' velocities. \nSo, $\\Phi=$ $\\left|\\vec{v}_{1}-\\vec{v}_{2}\\right| / V$. \nThis should be familiar from classical scattering. \nThus,\n\\begin{equation}\n\td \\sigma=\\frac{V}{T} \\frac{1}{\\left|\\vec{v}_{1}-\\vec{v}_{2}\\right|} d P.\n\\end{equation}\nFrom quantum mechanics we know that probabilities are given by the square of amplitudes. \nSince quantum field theory is just quantum mechanics with a lot of fields, the normalized differential probability is\n\\begin{equation}\n\tdP=\\frac{|\\langle f|S| i\\rangle|^{2}}{\\langle f | f\\rangle\\langle i | i\\rangle} d \\Pi.\n\\end{equation}\nHere, $d \\Pi$ is the region of final state momenta at which we are looking. \nIt is proportional to the product of the differential momentum, $d^{3} p_{j}$, of each final state and must integrate to 1. \nSo\n\\begin{equation}\n\td \\Pi=\\prod_{j} \\frac{V}{(2 \\pi)^{3}} d^{3} p_{j}.\n\\end{equation}\nThis has $\\int d \\Pi=1$, since $\\int \\frac{d p}{2 \\pi}=\\frac{1}{L}$ (by dimensional analysis and our $2 \\pi$ convention).\nAccording to our normalization convention for single-particle state,\n\\begin{equation}\n\t\\langle p|p\\rangle = (2\\omega_p)(2\\pi)^3\\delta^{(3)}(0) = 2\\omega_p V.\n\\end{equation}\nNow let us turn to the S-matrix element $\\langle f|S| i\\rangle$. \nWe usually calculate S-matrix elements perturbatively. \nIn a free theory, where there are no interactions, the S-matrix is simply the identity matrix. \nWe can therefore write\n\\begin{equation}\n\tS=1+i \\mathcal{T},\n\\end{equation}\nwhere $\\mathcal{T}$ is called the transfer matrix and describes deviations from the free theory. \nSince the S-matrix should vanish unless the initial and final states have the same total 4-momentum, it is helpful to factor an overall momentum-conserving $\\delta$-function:\n\\begin{equation}\n\t\\mathcal{T}=(2 \\pi)^{4} \\delta^{4}(\\Sigma p) \\mathcal{M}\n\\end{equation}\nHere, $\\delta^{4}(\\Sigma p)$ is shorthand for $\\delta^{4}\\left(\\Sigma p_{i}-\\Sigma p_{f}\\right)$, where $p_{i}$ are the initial particles' momenta and $p_{f}$ are the final particles' momenta. \nIn this way, we can focus on computing the nontrivial part of the S-matrix, $\\mathcal{M}$. \nIn quantum field theory, ``matrix elements'' usually means $\\langle f|\\mathcal{M}| i\\rangle$. Thus we have\n\\begin{equation}\n\t\\langle f|\\mathcal T| i\\rangle=(2 \\pi)^{4} \\delta^{4}(\\Sigma p)\\langle f|\\mathcal{M}| i\\rangle.\n\\end{equation}\nSo,\n\\begin{equation}\n\\begin{aligned}\n\td P &=\\frac{\\delta^{4}(\\Sigma p) T V(2 \\pi)^{4}}{\\left(2 E_{1} V\\right)\\left(2 E_{2} V\\right)} \\frac{|\\mathcal{M}|^{2}}{\\prod_{j}\\left(2 E_{j} V\\right)} \\prod_{j} \\frac{V}{(2 \\pi)^{3}} d^{3} p_{j} \\\\\n\t&=\\frac{T}{V} \\frac{1}{\\left(2 E_{1}\\right)\\left(2 E_{2}\\right)}|\\mathcal{M}|^{2} d \\Pi_{\\mathrm{LIPS}}\n\\end{aligned}\n\\end{equation}\nwhere\n\\begin{equation}\n\td \\Pi_{\\text {LIPS }} \\equiv \\prod_{\\text {final states } j} \\frac{d^{3} p_{j}}{(2 \\pi)^{3}} \\frac{1}{2 E_{p_{j}}}(2 \\pi)^{4} \\delta^{4}(\\Sigma p)\n\\end{equation}\nis called the \\textit{Lorentz-invariant phase space} (LIPS).\nPutting everything together, we have\n\\begin{equation}\n\td \\sigma=\\frac{1}{\\left(2 E_{1}\\right)\\left(2 E_{2}\\right)\\left|\\vec{v}_{1}-\\vec{v}_{2}\\right|}|\\mathcal{M}|^{2} d \\Pi_{\\text {LIPS }}\n\\end{equation}\nAll the factors of $V$ and $T$ have dropped out, so now it is trivial to take $V \\rightarrow \\infty$ and $T \\rightarrow \\infty$. Recall also that velocity is related to momentum by $\\vec{v}=\\vec{p} / p_{0}$.\n\n\n\\subsubsection{Decay Rates}\nAn unstable particle may decays to other particle(s), the rate of which is called the \\textit{decay rate}.\nA \\textit{differential decay rate} is the probability that a one-particle state with momentum $p_{1}$ turns into a multi-particle state with momenta $\\left\\{p_{j}\\right\\}$ over a time $T$:\n\\begin{equation}\n\td \\Gamma=\\frac{1}{T} d P .\n\\end{equation}\nOf course, it is impossible for the incoming particle to be an asymptotic state at $-\\infty$ if it is to decay, and so we should not be able to use the $S$-matrix to describe decays. \nThe reason this is not a problem is that we calculate the decay rate in perturbation theory assuming the interactions happen only over a finite time $T$. \nThus, a decay is really just like a ($1 \\rightarrow n$) scattering process.\n\nFollowing the same steps as for the differential cross section, the decay rate can be written as\n\\begin{equation}\n\td \\Gamma=\\frac{1}{2 E_{1}}|\\mathcal{M}|^{2} d \\Pi_{\\text {LIPS }}\n\\end{equation}\nNote that this is the decay rate in the rest frame of the particle. \nIf the particle is moving at relativistic velocities, it will decay much slower due to time dilation. \nThe rate in the boosted frame can be calculated from the rest-frame decay rate using special relativity.\n\n\n\n\n\n\\section{LSZ Reduction Formula}\n\nThe LSZ reduction formula is used to simplify the calculation of the S-matrix in the momentum space.\nIt essentially states that for the S-matrix of an ($n \\rightarrow m$) process, the matrix element equals to the \\textit{amputated Green's function}, which is the Green's function with in and out states propagators amputated:\n\\begin{equation}\n\t\\tilde{G}(k_1,\\cdots,k_n) = \\left[\\prod_{i=1}^n \\tilde{G}(k_i) \\right] \\tilde{G}_{\\mathrm{amp}}(k_1,\\cdots,k_n).\n\\end{equation}\nOr, in the coordinate space (for scalar field), \n\\begin{equation}\n\t\\tilde{G}_{\\mathrm{amp}}(k_1,\\cdots,k_n) = \\left[\\prod_{i=1}^n \\int d x_i e^{-i k_i x_i} \\frac{-\\partial^2-m^2}{i\\sqrt Z} \\right] G(x_1,\\cdots,x_n).\n\\end{equation}\nNote that since the in and out states are on-shell, the factor $-\\partial^2-m^2$ effectively filter out the singularity $\\frac{i}{k^2-m^2}$, and any regular term without singularity will not affect the result.\n\n\\subsection{Asymptotic Process}\nTo get the basis idea how it happens, consider the correlation function\n\\begin{equation}\n\tiG(y_m,\\cdots,y_1,x_1,\\cdots,x_n) = \\langle\\Omega|\\phi(y_m)\\cdots\\phi(y_1) \\phi(x_1)\\cdots\\phi(x_n)|\\Omega\\rangle.\n\\end{equation}\nNow we are going to Fourier transform this function for the variable $x_1$.\nFirst we split the time to three domains: $(-\\infty,T_-]$, $(T_-,T_+)$, and $[T_+,+\\infty)$ such that at time $T_{\\pm}$ the particles are well-separated.\nConsider first the integral over the first domain:\n\\begin{equation}\n\t\\int_{-\\infty}^{T_-} dx_1^0 \\int d^3 x\\ e^{i k\\cdot x_1} \\int \\frac{d^3q}{(2\\pi)^3}\\frac{1}{2\\omega_q}\\langle \\Omega|\\phi(y_m)\\cdots\\phi(y_1) \\phi(x_2)\\cdots\\phi(x_n)|q\\rangle \\langle q|\\phi(x_1) |\\Omega\\rangle,\n\\end{equation}\nwhere we have inserted the complete set of intermediate states.\\footnote{Note that the multi-particle state are discarded as discussed. Also, the single particle state $|k\\rangle$ shall be think as a concentrated wave packet near the particle at $\\bm x_1$, so that it has negligible overlap with other particle states.}\nThen use the fact $\\langle q|\\phi(x_1)|\\Omega\\rangle = \\sqrt{Z_\\phi} e^{i q \\cdot x_1}$, \n\\begin{equation}\n\t\\int_{-\\infty}^{T_-} dx_1^0 \\ e^{i (k^0+\\omega_q-i\\epsilon)\\cdot x_1^0}\\frac{\\sqrt{Z_\\phi}}{2\\omega_k}\\langle \\Omega|\\phi(y_m)\\cdots\\phi(y_1) \\phi(x_2)\\cdots\\phi(x_n)|k\\rangle,\n\\end{equation}\nThe time integral gives the singularity at $k^0=-\\omega_k$:\n\\begin{equation}\n\t\\frac{1}{2\\omega_k} \\frac{i}{\\omega_k+k^0 + i\\epsilon} = \\frac{i\\sqrt{Z_\\phi}}{k^2-m^2+i\\epsilon} + \\text{regular terms}.\n\\end{equation}\n\nNow consider the integral over the third time domain.\nThe calculation is basically the same, the difference is the insertion gives\n\\begin{equation*}\n\t\\langle\\Omega| \\phi(x_1) |q\\rangle = \\sqrt{Z_\\phi} e^{i q \\cdot x_1},\n\\end{equation*}\nwhich leads to a singularity at $k^0=\\omega_k$:\n\\begin{equation}\n\t\\frac{1}{2\\omega_k} \\frac{i}{\\omega_k-k^0 + i\\epsilon} = \\frac{i\\sqrt{Z_\\phi}}{k^2-m^2+i\\epsilon} + \\text{regular terms}.\n\\end{equation}\nNote that although for the above two cases, the final singular expression can be brought to the same form, the location of the singularity is different, which indicate whether it is the in or out state.\nSpecific frequency filter can be chosen to select out the component accordingly.\n\nFinally, consider the integral over time interval $(T_-,T_+)$, where the particle are interacting and single particles are not well defined.\nOn this interval the correlation will not have any singularity.\\footnote{some branch cuts are possible, but they will also be annihilated by $k^2-m^2$ term.}\nWe then know that if we choose $\\phi(x_1)$ to create the in state, and we only care about the singular structure, then the Fourier transformation produce the factor\n\\begin{equation}\n\t\\frac{i\\sqrt{Z_\\phi}}{k_1^2-m_1^2}.\n\\end{equation}\nThe same procedure applies to every field operator, and the final result is\n\\begin{equation}\n\\begin{aligned}\n\tS &= \\langle p_1,\\cdots,p_1;T_+|k_1,\\cdots,k_n;T_-\\rangle \\\\\n\t&= i\\tilde{G}_{\\mathrm{amp}}(p_m,\\cdots,p_1;-k_1,\\cdots,-k_n) \\delta^{(4)}\\left(\\sum p-\\sum k \\right).\n\\end{aligned}\n\\end{equation}\nOr, the matrix element satisfies\n\\begin{equation}\n\t\\mathcal M_{fi} = \\tilde{G}_{\\mathrm{amp}}(p_m,\\cdots,p_1;-k_1,\\cdots,-k_n).\n\\end{equation}\n\n\n\\subsection{Operator Proof for Scalar Field}\nHere we choose another way to prove the LSZ formula.\nWe think a single-particle state to be created by the particle creation operator $a^\\dagger$.\nFor free theory, we have\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_k} a_k &= i \\int d^3 x\\ e^{ik\\cdot x}(-i\\omega_k+\\partial_t)\\phi(x), \\\\\n\t\\sqrt{2\\omega_k} a^\\dagger_k &= -i \\int d^3 x\\ e^{-ik\\cdot x}(i\\omega_k+\\partial_t)\\phi(x).\n\\end{aligned}\n\\end{equation}\nWhen interaction is turned on, the field operator $\\phi(x)$ is renormalized as\n\\begin{equation*}\n\t\\phi_R(x) \\sim \\sqrt{Z_{\\phi}} \\phi_{\\mathrm{in}}(x) \\sim \\sqrt{Z_{\\phi}} \\phi_{\\mathrm{out}}(x),\n\\end{equation*}\nso we define the particle creation operator as\n\\begin{equation}\n\ta_R^\\dagger \\equiv -i \\int d^3 x\\ e^{-ik\\cdot x}(i\\omega_k+\\partial_t)\\phi_R(x).\n\\end{equation}\nWhen acting on the vacuum:\n\\begin{equation}\n\t\\sqrt{2\\omega_k} a_R^\\dagger(k) |\\Omega\\rangle = |k\\rangle + \\text{multi-particle states}.\n\\end{equation}\nOn may wonder why $a_{\\mathrm{in}}(k)$ do not contribute to the single-particle state. \nTo see that, one can think of the original particle-creation operator $a^\\dagger(k)$ in the frequency domain to have a delta function peak at $\\omega_k$.\nWhile for the $a(k)$ in the interacting theory, although it can have weight at the frequency $\\omega_k$, there will be no delta-function-like peak.\n\nThe in and out state are though to be created by the operator $a_R^\\dagger(k)$.\nNote that as discussed, the multi-particle contribution is discarded.\nIn the Heisenberg picture, the particle-creation operator satisfies:\n\\begin{equation}\n\\begin{aligned}\n\ta_{R}^\\dagger(-\\infty) - a_{R}^\\dagger(+\\infty)\n\t&= \\frac{i}{\\sqrt{2\\omega_k}} \\int dt\\ \\partial_t \\left[\\int d^{3}x\\ e^{-ikx}(i\\omega_k+\\partial_t)\\phi_R(x)\\right] \\\\\n\t&= \\frac{i}{\\sqrt{2\\omega_k}} \\int d^4 x e^{-ik\\cdot x}(\\omega_k^2+\\partial_t^2)\\phi_R(x) \\\\\n\t&= \\frac{i}{\\sqrt{2\\omega_k}} \\int d^4 x e^{-ik\\cdot x}\\partial_t^2\\phi_0(x) + \\phi_R(x)(-\\nabla^2+m^2)e^{-i k\\cdot x} \\\\\n\t&= \\frac{i}{\\sqrt{2\\omega_k}} \\int d^4 x e^{-ik\\cdot x}(\\partial^2+m^2)\\phi_R(x)\n\\end{aligned}\n\\end{equation}\nThe initial and final states are:\n\\begin{equation}\n\\begin{aligned}\n\t|k_1, \\cdots, k_m; \\mathrm{in}\\rangle &= \\left[\\prod_{j=1}^m \\sqrt{2\\omega_{k_j}} a^\\dagger_{R}(k_j;-\\infty)\\right] |\\Omega\\rangle, \\\\\n\t|p_1, \\cdots, p_n, \\mathrm{out}\\rangle &= \\left[\\prod_{j=1}^n \\sqrt{2\\omega_{p_j}}a^\\dagger_{R}(p_j;+\\infty)\\right] |\\Omega\\rangle.\n\\end{aligned}\n\\end{equation}\nThe S-matrix is\n\\begin{equation*}\n\\begin{aligned}\n\tS_{fi} &= \\langle p_1, \\cdots, p_n;\\mathrm{out}| S |k_1, \\cdots, k_m; \\mathrm{in}\\rangle \\\\\n\t&= \\frac{\\langle 0|T \n\t\t\\left(\\prod \\sqrt{2\\omega_{p_j}} a_{p_j;\\mathrm{out}} \\right)\n\t\t\\int d^4 x \\exp(i\\mathcal{L}_{\\mathrm{int}})\n\t\t\\left(\\prod \\sqrt{2\\omega_{k_j}} a^\\dagger_{k_j;\\mathrm{in}} \\right)|0\\rangle}\n\t\t{\\langle 0|T\\int d^4 x \\exp(i\\mathcal{L}_{\\mathrm{int}})|0\\rangle}\n\\end{aligned}\n\\end{equation*}\nSince the scattering process correspond to the connected diagram, meaning that the initial and final state has distinct momentum particles.\nWe are free to make the substitution\n\\begin{equation*}\n\ta^\\dagger_{\\mathrm{in}} \\rightarrow (a_{\\mathrm{in}}^\\dagger - a_{\\mathrm{out}}^\\dagger),\\ \n\ta_{\\mathrm{out}} \\rightarrow -(a_{\\mathrm{in}}^\\dagger - a_{\\mathrm{out}}^\\dagger)^\\dagger.\n\\end{equation*}\nIn this way, the S-matrix is\n\\begin{equation}\n\\begin{aligned}\n\t& \\langle p_1, \\cdots, p_n| S |k_1, \\cdots, k_m\\rangle  \\\\\n\t=& \\prod_{i=1}^{m}\\left[ \\int d^dx_i \\ e^{ip_i\\cdot x_i}i(\\partial^2+m_i^2)\\right]\n\t\\prod_{j=m+1}^{m+n}\\left[\\int d^dx_j \\ e^{-ik_j\\cdot x_j}i(\\partial^2+m_j^2)\\right] iG(\\{x\\}).\n\t\\label{eq:K-G-LSZ}\n\\end{aligned}\n\\end{equation}\nIn momentum space\n\\begin{equation}\n\t\\mathcal M = \\prod_{i=1}^{m}\\left[\\frac{p_i^2-m_i^2}{i\\sqrt{Z_\\phi}}\\right]\n\t\t\\prod_{j=m+1}^{m+n}\\left[\\frac{k_j^2-m_j^2}{i\\sqrt{Z_\\phi}}\\right]\n\t\t\\tilde{G}(\\{p_i\\};\\{-k_j\\}).\n\\end{equation}\nWe thus proved the LSZ reduction formula again.\n\nNote that in the second equality, we move the operator $\\partial^2$ out of the time-ordering operator, which will actually create \\textit{contact terms}.\nWe will show the contact term can be safely neglected.\nTo see this, first consider the time-ordered two-point function:\n\\begin{equation}\n\t\\langle 0|T\\phi(x_1)\\phi(x_2)|0\\rangle\n\t= \\theta(t_1-t_2)\\langle 0|\\phi(x_1)\\phi(x_2)|0\\rangle -\n\t\\theta(t_2-t_1)\\langle 0|\\phi(x_2)\\phi(x_1)|0\\rangle.\n\\end{equation}\t\nTake time derivative on both side:\n\\begin{equation*}\n\\begin{aligned}\n\t\\partial_{t_1} \\langle 0|T\\phi(x_1)\\phi(x_2)|0\\rangle\n\t&= \\langle 0|T\\partial_{t_1}\\phi(x_1)\\phi(x_2)|0\\rangle +\n\t\\delta(t_1-t_2)\\langle 0|[\\phi(x_1),\\phi(x_2)]|0\\rangle \\\\\n\t&= \\langle 0|T\\partial_{t_1}\\phi(x_1)\\phi(x_2)|0\\rangle.\n\\end{aligned}\n\\end{equation*}\nThe second equality follows from the fact that $x_1,x_2$ is equal-time.\nTake the the time derivative once more:\n\\begin{equation*}\n\t\\partial^2_{t_1} \\langle 0|T\\phi(x_1)\\phi(x_2)|0\\rangle\n\t= \\langle 0|T\\partial^2_{t_1}\\phi(x_1)\\phi(x_2)|0\\rangle +\n\t\\delta(t_1-t_2)\\langle 0|[\\partial_{t_1}\\phi(x_1),\\phi(x_2)]|0\\rangle.\n\\end{equation*}\nThe second term on the right hand side is the contact term.\nFor free theory, $\\partial_{t_1}\\phi(x_1)$ is the canonical momentum, meaning that\n\\begin{equation}\n\t[\\phi(\\vec x_1, t),\\partial_{t}\\phi(\\vec x_1,t)] = i \\delta^{3}(\\vec x_1-\\vec x_2).\n\\end{equation}\nIn general, for $n$-point correlation,\n\\begin{equation}\n\\begin{aligned}\n\t \\partial_{t_1}^2 \\langle T\\phi_{x_1}\\cdots\\phi_{x_n} \\rangle\n\t= \\langle T\\partial_{t_1}^2\\phi_{x_1}\\cdots\\phi_{x_n}\\rangle -i \\sum_j \\delta^4(x_1-x_j)\\langle T\\phi_{x_2}\\cdots\\cancel{\\phi_{x_j}}\\cdots\\phi_{x_n}\\rangle.\n\\end{aligned}\n\\end{equation}\nIn the LSZ formula, the contact term do not have any singularity.\nWhen the external legs approach to momentum shell, these regular terms vanishes, so the contact will not contribute to the S-matrix.\n\n\n\n\n\n\n\n\\subsection{LSZ for Dirac Field}\nUse the field expansion\n\\begin{equation}\n\\begin{aligned}\n\t\\psi(x) &=\\int \\frac{d^{3} p}{(2 \\pi)^{3}} \\frac{1}{\\sqrt{2 \\omega_{\\mathbf{p}}}} \n\t\t\\sum_{s}\\left(a_{\\mathbf{p}}^{s} u^{s}(p) e^{-i p \\cdot x}\n\t\t+b_{\\mathbf{p}}^{s \\dagger} v^{s}(p) e^{i p \\cdot x}\\right), \\\\\n\t\\bar{\\psi}(x) &=\\int \\frac{d^{3} p}{(2 \\pi)^{3}} \\frac{1}{\\sqrt{2 \\omega_{\\mathbf{p}}}} \n\t\t\\sum_{s}\\left(b_{\\mathbf{p}}^{s} \\bar{v}^{s}(p) e^{-i p \\cdot x}\n\t\t+a_{\\mathbf{p}}^{s \\dagger} \\bar{u}^{s}(p) e^{i p \\cdot x}\\right),\n\\end{aligned}\n\\end{equation}\nand the orthogonality relation\n\\begin{equation}\n\\begin{aligned}\n\tu^{r \\dagger}(p) u^{s}(p) &= 2 \\omega_{\\bm p} \\delta^{r s}, & \n\tu^{r \\dagger}(\\bm p,\\omega_{\\bm p}) v^{s}(-\\bm p,\\omega_{\\bm p}) &= 0,\\\\\n\tv^{r \\dagger}(p) v^{s}(p) &= 2\\omega_{\\bm p} \\delta^{r s}, & \n\tv^{r \\dagger}(\\bm p,\\omega_{\\bm p}) u^{s}(-\\bm p,\\omega_{\\bm p}) &= 0.\n\\end{aligned}\n\\end{equation}\nThe spatial Fourier transformation gives:\n\\begin{equation}\n\t\\int d^3x e^{ip\\cdot x}\\psi(x) = \\frac{1}{\\sqrt{2\\omega_{\\bm p}}}\\sum_s a^s_{\\bm p}u^s(p) +\\frac{1}{\\sqrt{2\\omega_{\\bm p}}}\\sum_s b^{s \\dagger}_{\\bm p} v^s(-\\bm p,\\omega) e^{2i\\omega t}\n\\end{equation}\nLeft-multiply on both hand side by $\\bar u^{s}(p) \\gamma^0$, we then get\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}a^{s}_{\\bm p} &= \\int d^3 x e^{ip\\cdot x}\\bar u^{s}(p)\\gamma^0 \\psi(x), \\\\\n\t\\sqrt{2\\omega_{\\bm p}}a^{s \\dagger}_{\\bm p} &= \\int d^3 x e^{-ip\\cdot x}\\bar\\psi(x)\\gamma^0 u^{s}(p).\n\\end{aligned}\n\\end{equation}\nSimilarly, we consider\n\\begin{equation}\n\t\\int d^3x e^{ip\\cdot x}\\bar\\psi(x) = \\frac{1}{\\sqrt{2\\omega_{\\bm p}}}\\sum_s b^s_{\\bm p}\\bar v^s(p) +\\frac{1}{\\sqrt{2\\omega_{\\bm p}}}\\sum_s a^{s \\dagger}_{\\bm p} \\bar u^s(-\\bm p,\\omega) e^{2i\\omega t}\n\\end{equation}\nRight-multiply on both hand side by $\\gamma^0 v^{s}(p)$, we then get\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}b^{s}_{\\bm p} &= \\int d^3 x e^{ip\\cdot x}\\bar\\psi(x)\\gamma^0 v^s(p), \\\\\n\t\\sqrt{2\\omega_{\\bm p}}b^{s \\dagger}_{\\bm p} &= \\int d^3 x e^{-ip\\cdot x}\\bar v^s(p)\\gamma^0 \\psi(x).\n\\end{aligned}\n\\end{equation}\nFollowing the same strategy as we did for the scalar field, we consider\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}a^{s}_{\\bm p;\\mathrm{out}} - \n\t\\sqrt{2\\omega_{\\bm p}}a^{s}_{\\bm p;\\mathrm{in}} \n\t&= \\int dt\\ \\partial_t \\sqrt{2\\omega_{\\bm p}}a^s_{\\bm p} \\\\\n\t&= \\int dt\\ \\int d^3x e^{ip\\cdot x}\\bar u(p)(\\gamma^0 \\partial_t +i\\gamma^0 p^0)\\psi(x) \\\\\n\t&= \\int d^4x e^{ip\\cdot x}\\bar u(p)(\\gamma^0 \\partial_t +i\\gamma^i p^i +i m)\\psi(x) \\\\ \n\t&= i\\int d^4x e^{ip\\cdot x}\\bar u(p)(-i\\cancel\\partial + m)\\psi(x)\n\\end{aligned}\n\\end{equation}\nwhere we have used the fact $\\bar u(p) (\\cancel p - m) = 0$.\nTake hermitian conjugate,\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}a^{s \\dagger}_{\\bm p;\\mathrm{in}} - \n\t\\sqrt{2\\omega_{\\bm p}}a^{s \\dagger}_{\\bm p;\\mathrm{out}} \n\t&= i\\int d^4x e^{-ip\\cdot x}\\bar\\psi(x)\\gamma^0(-i\\cancel\\partial + m)^\\dagger \\gamma^0 u(p) \\\\\n\t&= i\\int d^4x e^{-ip\\cdot x}\\bar\\psi(x)(i \\overleftarrow{\\cancel\\partial} + m) u(p)\n\\end{aligned}\n\\end{equation}\nSimilarly, using the fact $(\\cancel p + m)v(p) =0$,\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}b^{s}_{\\bm p;\\mathrm{out}} - \n\t\\sqrt{2\\omega_{\\bm p}}b^{s}_{\\bm p;\\mathrm{in}} \n\t&= \\int d^4x e^{ip\\cdot x}\\bar\\psi(x)(\\gamma^0 \\overleftarrow{\\partial_t} +i\\gamma^0 p^0)v(p) \\\\\n\t&= \\int d^4x e^{ip\\cdot x}\\bar\\psi(x)(\\gamma^0 \\overleftarrow{\\partial_t} +i\\gamma^i p^i -i m)v(p) \\\\ \n\t&= -i\\int d^4x e^{ip\\cdot x}\\bar\\psi(x)(i\\overleftarrow{\\cancel\\partial} + m)v(p).\n\\end{aligned}\n\\end{equation}\nAgain, take the hermitian conjugate,\n\\begin{equation}\n\\begin{aligned}\n\t\\sqrt{2\\omega_{\\bm p}}b^{s \\dagger}_{\\bm p;\\mathrm{in}} - \n\t\\sqrt{2\\omega_{\\bm p}}b^{s \\dagger}_{\\bm p;\\mathrm{out}} \n\t&= -i\\int d^4x e^{ip\\cdot x}\\bar v(p)\\gamma^0(i\\overleftarrow{\\cancel\\partial} + m)^\\dagger \\gamma^0 \\psi(x) \\\\\n\t&= -i\\int d^4x e^{-ip\\cdot x}\\bar v(p)(-i \\cancel\\partial + m) \\psi(x)\n\\end{aligned}\n\\end{equation}\nThe same strategy gives the LSZ reduction formula for Dirac field.\nConsider the S-matrix for particles:\n\\begin{equation}\n\\begin{aligned}\n\t& \\langle p_1, \\cdots, p_n| S |k_1, \\cdots, k_m\\rangle  \\\\\n\t=& \\prod_{i=1}^{m}\\left[ \\int d^dx_i \\ e^{ip_i\\cdot x_i} u^{s_1}(p_i)\\frac{i\\cancel\\partial-m_i}{i\\sqrt{Z_\\phi}}\\right] iG(\\{x\\})\n\t\\prod_{j=m+1}^{m+n}\\left[\\int d^dx_j \\ e^{-ik_j\\cdot x_j}\\frac{-i\\overleftarrow{\\cancel\\partial}-m_j}{i\\sqrt{Z_\\phi}}u^{s_j}(k_j)\\right].\n\\end{aligned}\n\\end{equation}\nIn the momentum space:\n\\begin{equation}\n\t\\mathcal M = \\prod_{i=1}^{m}\\left[\\frac{\\cancel p-m_i}{i\\sqrt{Z_\\phi}}u^{s_i}(p_i)\\right]\n\t\t\\tilde{G}(\\{p_i\\};\\{-k_j\\})\n\t\t\\prod_{j=m+1}^{m+n}\\left[u^{s_j}(k_j)\\frac{\\cancel k-m_j}{i\\sqrt{Z_\\phi}}\\right].\n\\end{equation}\n\n\n\n\n", "meta": {"hexsha": "deab248319e291c79f8f6eb9deb11349e339d5c5", "size": 32194, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Interaction.tex", "max_stars_repo_name": "jayren3996/Notes_on_QFT", "max_stars_repo_head_hexsha": "f4a9590b7fda5f4d2f2f230eb6cb5e31e2c40954", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/Interaction.tex", "max_issues_repo_name": "jayren3996/Notes_on_QFT", "max_issues_repo_head_hexsha": "f4a9590b7fda5f4d2f2f230eb6cb5e31e2c40954", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Interaction.tex", "max_forks_repo_name": "jayren3996/Notes_on_QFT", "max_forks_repo_head_hexsha": "f4a9590b7fda5f4d2f2f230eb6cb5e31e2c40954", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.5673876872, "max_line_length": 319, "alphanum_fraction": 0.7001925825, "num_tokens": 11220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4203797836795593}}
{"text": "\\section{Experiment}\nWhile the modified Count-min sketch algorithm provides an error bound for the\nestimated movie averages, what we are really interested in is how much it\naffects the ordering of the movies when sorted by these estimated averages\ncompared to the real averages. In this section, we evaluate the modified\nCount-min sketch algorithm by running it on real-life data, and comparing the\norder it produces with the correct order. \n\nWe quantify the error in ordering by the Kendall tau distance. For a permutation\nof movies $\\pi$, we say that $x <_\\pi y$ if $x$ comes before $y$ in $\\pi$. The\nKendall tau distance between two orderings of our movie set is then $\\mathrm{KT}\n\\left(\\pi_1,\\pi_2\\right) = \\left|\\{x,y\\}: x <_{\\pi_1} y \\wedge y <_{\\pi_2}\nx\\right|$. The Kendall distance is often normalized to the maximum number of\ninversions between the orderings, $n(n-1)/2$ for $n$ elements. We expect random\norderings to have a normalized Kendall tau distance of $\\frac{1}{2}$, so\nonly results with a lower distance can be considered useful.\n\n\\subsection{Results}\nOur data is sampled from the \\textit{Netflix\nPrize}\\footnotemark \\ data set.\nThe full data set contains more than 100 million user ratings, for more than 17\nthousand movies.\nWe test the algorithm on three samples of the \\texttt{Netflix} data:\n\n\\footnotetext{http://academictorrents.com/details/9b13183dc4d60676b773c9e2cd6de5e5542cee9a}\n\\begin{itemize}\n\t\\item \\textit{100M ratings} contains all ratings for the $13726$ most\n\t\tfrequently rated movies. Roughly 100 million ratings total,\n\t\\item \\textit{50Mmin ratings} contains all ratings for the $17146$ least\n\t\tfrequently rated movies. Roughly 50 million ratings total,\n\t\\item \\textit{50M ratings} contains all ratings for the $611$ most\n\t\tfrequently rated movies. Roughly 50 million ratings total,\n\t\\item \\textit{min10K ratings} contains all ratings for the $2042$ movies that have more\n\t\tthan $10.000$ ratings.\n\n\\end{itemize}\n\n\\pgfplotsset{scaled x ticks=false}\n\\begin{center}\n\\begin{tikzpicture}\n\\begin{axis}[\n\ttitle=Count-min order error,\n\txlabel={Error bound $\\varepsilon$},\n\tylabel={KT. norm.},\n\tlegend pos=south east,\n\txticklabel style={\n\t\t/pgf/number format/.cd,\n\t\tfixed,\n\t\tfixed zerofill,\n\t\tprecision=3,\n\t\t/tikz/.cd\n\t},\n]\n\\addplot table [y=100M,x=E]{allresults};\n\\addlegendentry{\\textit{100M ratings}}\n\\addplot table [y=50M,x=E]{allresults};\n\\addlegendentry{\\textit{50M ratings}}\n\\addplot table [y=min10K,x=E]{allresults};\n\\addlegendentry{\\textit{min10K ratings}}\n\\addplot table [y=50Mmin,x=E]{allresults};\n\\addlegendentry{\\textit{50Mmin ratings}}\n\\end{axis}\n\\end{tikzpicture}\n\\end{center}\n\nAll trials are run with $\\delta = 0.01$.\n\nAs expected, the algorithm performs much worse on the large, $100M raitings$\ndataset than on the smaller data sets.\nFor $\\varepsilon = 0.001$, the normalized Kendall-Tau distance is $0.33$, and it\nrapidly approaches $0.5$.\n\nThe obvious explanation is the error's dependency on the length of the stream,\nbut there is another factor at play.\n\nBecause of the way the Count-Min algorithm works --- adding up the ratings when the\nhash functions have collisions --- there is a tendency that movies with fewer\nratings will cause inversions more often than movies with many ratings.\nFuthermore, we see that that the algorithm performs reasonable well in the two\nother data sets, containing only movies with many ratings.\n\nWe see however, that in order to save memory compared to the simple\napproaches described in section \\ref{sec:sorting}, we have to accept a\nnormalized Kendall tau distance of at least $0.1$, or choose a higher value for $\\delta$\n\n\\subsection{Implementation}\nThe implementation can be found in the appendices.\nWe Note that the implementation does not live up to the performance\nbounds stated in section \\ref{sec:sketching}. This is not a problem, since we\nare assessing the correctness of the algorithm, not it's throughput. The\nimplementation differs in two ways: To emulate querying all data points, a list\nof all observed movies is kept, requiring $O(|U|)$ extra memory. Furthermore the\nratings are sorted when queried, rather than maintaining the ordering\ndynamically. Again, this does not effect the experiment.\n", "meta": {"hexsha": "19bc34169638c127f728387081bc32b56305a1f2", "size": 4193, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "experiment.tex", "max_stars_repo_name": "Bladtman242/SAD2_project", "max_stars_repo_head_hexsha": "6bc06598b2dd676a0c6ef6860c6e4b69ccff3e85", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "experiment.tex", "max_issues_repo_name": "Bladtman242/SAD2_project", "max_issues_repo_head_hexsha": "6bc06598b2dd676a0c6ef6860c6e4b69ccff3e85", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "experiment.tex", "max_forks_repo_name": "Bladtman242/SAD2_project", "max_forks_repo_head_hexsha": "6bc06598b2dd676a0c6ef6860c6e4b69ccff3e85", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.1368421053, "max_line_length": 91, "alphanum_fraction": 0.7710469831, "num_tokens": 1124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.4203797807164144}}
{"text": "\\documentclass{article}\n    \\usepackage{subcaption}\n    \\usepackage{amsmath, amssymb}\n    \\usepackage{graphicx, float}\n    \\usepackage[hidelinks]{hyperref}\n    \\usepackage[bottom]{footmisc}\n    \\usepackage[margin=.8in, tmargin=.8in]{geometry}\n    \\usepackage{esint} % for double line integrals\n\n    \\renewcommand{\\baselinestretch}{1.2}\n    \\newcommand{\\eps}{\\epsilon}\n    \\newcommand{\\der}{\\partial}\n    \\newcommand{\\del}{\\nabla}\n    \\newcommand{\\bm}[1]{\\mathbf{#1}}\n    \\newcommand{\\vf}[1]{\\vec{\\mathbf{#1}}}\n    \\newcommand{\\norm}{\\hat{\\bm{n}}}\n    \n    \\setlength\\parindent{0pt}\n    \\captionsetup{justification=centering}\n    \n    \\title{Vector Calculus}\n    \\date{\\today}\n    \\author{Traiko Dinev \\textless traiko.dinev@gmail.com\\textgreater}\n    \n\\begin{document}\n\\maketitle\n\n\\textit{NOTE: This partially follows Engineering Mathematics 2, a second year engineering course at the University of Edinburgh and partially follows MIT's 18.02, Multivariable Calculus.}\n\n\\textit{NOTE: Note this \"summary\" is NOT a reproduction of the course materials nor is it copied from the corresponding courses. It was entirely written and typeset from scratch.}\n\n\\textit{License: Creative Commons public license; See README.md of repository}\n\n\\textit{NOTE: Images are to be added soon!}\n\n\\section{Introduction}\n\nDefine the following:\n\n\\begin{align*}\n    \\del &=\n        \\bigg\\langle\n            \\frac{\\partial}{\\partial x},\n            \\frac{\\partial}{\\partial y},\n            \\frac{\\partial}{\\partial z}\n        \\bigg\\rangle\n            && \\text{gradient vector} \\\\\n    \\del f &=\n        \\bigg\\langle\n            \\frac{\\partial f}{\\partial x},\n            \\frac{\\partial f}{\\partial y},\n            \\frac{\\partial f}{\\partial z}\n        \\bigg\\rangle\n            && \\text{vector derivative}\\\\\n    % \n    \\vf{F} &=\n        \\langle\n            f(x, y, z), g(x, y, z), h(x, y, z)\n        \\rangle =\n        f(...) \\mathbf{i} + g(...)\\mathbf{j} + h(...) \\mathbf{k}\n            && \\text{Vector field}\\\\\n    % \n    \\del \\cdot \\vf{F} &=\n        \\frac{\\der f(x, y, z)}{\\der x} +\n        \\frac{\\der g(x, y, z)}{\\der y} +\n        \\frac{\\der h(x, y, z)}{\\der z}\n            && \\text{Divergence (dot product)} \\\\\n    % \n    \\del \\times \\vf{F} &=\n        \\begin{pmatrix}\n            i & j & k \\\\\n            \\frac{\\der}{\\der x} &\n                \\frac{\\der}{\\der x} &\n                    \\frac{\\der}{\\der x} \\\\\n            f(...) & g(...) & h(...) \n        \\end{pmatrix}\n            && \\text{Curl (cross product)} \\\\\n\\end{align*}\n\nGradients are just the derivatives in each dimension. Vector fields define a vector at each point in space, as defined by (x, y, z).\n\\vskip 0.1in\nHere divergence gives the change in the vector field outwards (source of flux). This can also be defined as the limit of the net flow. Curl defines a rotational field (3D). It is the limit of the path integral. These two are neat relations, but I've never actually had to use them:\n\n\\begin{align*}\n    \\del \\cdot \\vf{F} &=\n        \\lim_{V \\to p} \\iint\n            \\frac{\\vf{F} \\cdot \\norm}{|V|} dS \\\\\n    (\\del \\times \\vf{F}) \\cdot \\norm &=\n        \\lim_{A \\to 0}\\frac{1}{|A|} \\int_c \\vf{F} \\cdot d\\vf{r}\n\\end{align*}\n\n\\section{Double Integrals}\nOn to double (and triple) integrals. A double integral is just two single integrals stacked together. These are good to know:\n\n\\begin{align*}\n    &\\iint_R dA && \\text{Area of R} \\\\\n    &\\iint_R \\rho\\ dA && \\text{Mass, where $\\rho$ is the density} \\\\\n    &\\bar{x} = \\frac{1}{M}\\iint_R x\\ \\rho\\ dA && \\text{Center of mass} \\\\\n    &\\iint_R r^2\\ \\rho\\ dA && \\text{Moment of intertia, $r$ is the distance from the axis}\n\\end{align*}\n\n\\subsection{Change of Variables}\nLet:\n\n\\begin{align*}\n    u &= u(x, y) \\\\\n    v &= v(x, y) \n\\end{align*}\n\nthen:\n\\begin{equation*}\ndx dy = \\bigg|\\frac{\\der(u, v)}{\\der(x, y)}\\bigg|^{-1} du dv = \\begin{pmatrix} \\frac{\\der u}{\\der x} & \\frac{\\der u}{\\der y} \\\\ \\frac{\\der v}{\\der x} & \\frac{\\der v}{\\der y} \\end{pmatrix} du dv\n\\end{equation*}\n\nThis is derived from the following, which is just from the definition of derivatives:\n\\begin{equation*}\n    \\begin{pmatrix}\\Delta u \\\\ \\Delta v\\end{pmatrix} \\approx \n        \\begin{pmatrix}\n            \\frac{\\der u}{\\der x} & \\frac{\\der u}{\\der y} \\\\\n             \\frac{\\der v}{\\der x} & \\frac{\\der v}{\\der y}\n        \\end{pmatrix}\n        \\begin{pmatrix} \\Delta x \\\\ \\Delta y \\end{pmatrix}\n\\end{equation*}\n\nOr you could consider a parallelogram.. check out MIT's derivation for this one.\n\n\\section{Line Integration}\nConsider a vector field $\\vec{\\mathbf{F}}$ and a path $c$. This could be a line or some parametric curve as defined by:\n\n\\begin{align}\n    x &= x(t) \\\\\n    y &= y(t) \\\\\n    \\vf{r} &= (x(t), y(t)) \\\\\n    \\frac{d\\vec{r}}{dt} &= \\langle \\frac{dx}{dt}, \\frac{dy}{dt} \\rangle\n\\end{align}\n\nfor $t$ between 0 and 1. Or any other limit, but you can always scale it. You could also have more parameters.\n\\vskip 0.1in\nThen the line (or path) integral is defined as follows:\n\\begin{equation*}\n    \\int_c \\vf{F} \\cdot d\\vf{r} =\n        \\int_c Mdx + Ndy + Pdz = \\int_c \\vf{F} \\cdot \\vf{T} ds\n\\end{equation*}\n\nHere $\\vf{F} = (M, N, P)$ but the summation is not three separate integrals. Change of variables is needed. $\\vf{T}$ is a tangent vector to the curve. $ds$ is the change along the curve.\n\\vskip 0.1in\nPerhaps a better way to view this is by considering that work is force times distance: $W = \\vf{F} \\cdot \\Delta \\vf{r}$. Note this is a dot product between the force vector and the r defined above. When we sum, we obtain the integral:\n\\begin{equation}\n    W = \\lim_{i \\to \\infty} \\sum_i \\vf{F} \\cdot \\Delta \\vf{r}_i = \\int_C \\vf{F} \\cdot d\\vf{r}\n\\end{equation}\n\nNow we can break this up using the parametrization of $\\vf{r}(t)$ above to arrive at:\n\n\\begin{equation}\n    \\int_c \\vf{F} \\cdot \\Delta \\vf{r} = \\int_{0}^{1} (\\vf{F} \\cdot \\frac{d\\vf{r}}{dt})\\ dt\n\\end{equation}\n\nIf you want a more rigorous derivation, you can start with the definition of derivatives and take the limit. The above is how we usually calculate line integrals. Note the derivative of r is just a vector, as defined above in (4). So path integrals are in reality just single variable integrals. Neat-o.\n\\vskip 0.1in\nWe can also do the integral in normal form. As opposed to a dot product with the tangent vector $\\vf{T}$ we consider the (perpendicular) normal vector $\\norm$. This is defined as the \\textbf{flux} of the vector field $\\vf{F}$. The flux measures how much \"stuff\" would be displaced by the vector field for a unit of time. It actually technically measures the force through a curve. Useful for magnetic fields:\n\n\\begin{equation}\n    \\int_c \\vf{F} \\cdot \\norm\\ ds \\approx \\sum_i (\\vf{F} \\cdot \\norm)\\ \\Delta \\vec{s}_i\n\\end{equation}\n\n\\textit{TODO: Insert parallelogram picture of normal and tangential path integrals and derivation.}\n\n\\subsection{Gradient Field Theorem}\n\\textit{A.k.a. the fundamental theorem of (vector) calculus}\nIf $\\vf{F}$ is a gradient field, i.e. $\\vf{F} = \\nabla f$.\n\n\\begin{equation}\n    \\int_c \\vf{F} \\cdot d\\vf{r} = \\int \\nabla f \\cdot d\\vf{r} = f(p_1) - f(p_0)\n\\end{equation}\n\nwhere $p_0$ and $p_1$ are the endpoints of the curve $c$. A.k.a Stoke's theorem in 2D. \\textit{TODO: add intuition}\n\n\\subsection{Green's Theorem}\nThis, where $c$ is counter-clockwise:\n\n\\begin{equation}\n    \\oint_c \\vf{F} \\cdot d\\vf{r} = \\iint_R (\\nabla \\times \\vf{F})\\ dA\n\\end{equation}\n\nwhere $R$ is the region bounded by $c$.\n\\vskip 0.1in\nGreen's theorem also works for normal form (flux) integrals. Also known as the divergence theorem when we do in 3D.\n\n\\begin{equation}\n    \\oint_c \\vf{F} \\cdot \\norm\\ ds = \\iint_R (\\nabla \\cdot \\vf{F})\\ dA\n\\end{equation}\n\n\\section{Triple Integration}\nArea integrals become volume integrals:\n\n\\begin{align*}\n    &\\iiint_R dV && \\text{volume} \\\\\n    &dV = dx\\ dy\\ dz \\\\\n    &\\iiint_R \\rho\\ dV && \\text{Mass} \\\\\n    &\\hat{f} = \\frac{1}{\\text{Volume}(R)}\n        \\iiint_R f\\ dV && \\text{Center of mass} \\\\\n    &\\iiint_R (\\text{distance to axis})^2\\delta\\ dV\n        && \\text{Moment of inertia} \\\\\n    &\\mathbb{I}_z = \\iiint_R (x^2 + y^2)^2\\delta\\ dV\n        && \\text{Moment of inertia around z-axis} \\\\\n\\end{align*}\n\n\\subsection{Cylindrical Coordinates}\n\\textit{TODO: add image}\n\n\\begin{align*}\n    x &= \\rho\\ \\cos \\phi \\\\\n    y &= \\rho\\ \\sin \\phi \\\\\n    z &= z \\\\\n    dV &= r\\ dr\\ d\\theta\\ dz\n\\end{align*}\n\n\\subsection{Spherical Coordinates}\n\\textit{TODO: add image}\n\n\\begin{align*}\n    x = r\\ \\cos\\theta = \\rho \\sin\\phi\\ \\cos\\theta\\\\\n    y = r\\ \\sin\\theta = \\rho \\sin\\phi\\ \\sin\\theta\\\\\n    z = \\rho \\cos\\theta \\\\\n    dV = \\rho^2 \\sin\\phi\\ d\\rho\\ d\\phi\\ d\\theta\n\\end{align*}\n\n\\section{Surface Integrals}\n\\textit{TODO: add image}\nNatural extension to normal integration (see path integral) to three dimensions. This gives us the amount of \"stuff\" that goes through a patch in 3D. A patch (surface) would be the equivalent of a parametric curve in 2D.\n\n\\begin{equation}\n    \\iint_S \\vf{F} \\cdot d\\vf{S} = \\iint_S \\vf{F} \\cdot \\norm\\ dS\n\\end{equation}\n\nHere $d\\vf{S} = \\norm\\ dS$. Now these are a pain to calculate, but there are shortcuts:\n\n\\subsection{On a sphere}\n\\begin{equation*}\n    dS = r^2\\ \\sin\\phi\\ d\\phi\\ d\\theta \n\\end{equation*}\n\nHere the normal vector is $\\norm = \\pm \\frac{1}{a} \\langle x, y, z \\rangle$.\n\n\\subsection{Horizontal plane}\nThree separate cases, we will consider when $z = a$. Hence:\n\\begin{align*}\n    z &= a \\\\\n    \\norm &= \\pm \\mathbf{\\hat{k}} \\\\\n    dS &= dx\\ dy\n\\end{align*}\n\n\\subsection{Cylinder of $r = a$ centered on the z axis}\n\\begin{align*}\n    \\norm &= \\pm \\langle x, y, 0, \\rangle \\frac{1}{a} \\\\\n    dS &= a\\ dz\\ d\\theta\n\\end{align*}\n\n\\subsection{Graph of function}\n\\begin{align*}\n    z &= f(x, y) \\\\\n    \\norm\\ dS &= \\pm \\langle -f_x, -f_y, 1\\rangle\\ dx\\ dy\n\\end{align*}\n\n\\subsection{Parametric Surface}\n\\begin{align*}\n    x &= x(u, v) \\\\\n    y &= y(u, v) \\\\\n    z &= z(u, v) \\\\\n    \\norm\\ dS &= \\pm\n        \\bigg(\\frac{\\der \\vf{r}}{\\der u}\n            \\times \\frac{\\der \\vf{r}}{\\der v} \\bigg) du\\ dv\n\\end{align*}\n\nhere $\\times$ is a cross product. Why? Stay tuned.. I might add a derivation. Check MIT's course.\n\n\\subsection{Slanted plane with normal $\\mathbf{\\hat{N}}$}\n\\textit{TODO}\n\n\\section{Divergence Theorem}\nThis is the 3D analogue of Green's theorem for flux in 2D. If:\n\n\\begin{itemize}\n    \\item $S$ encloses $D$ in space, where $S$ is a closed surface\n    \\item $\\norm$ is the normal vector pointing\n        \\textit{outwards} and $\\vf{F}$ is defined and differentiable within $D$\n\\end{itemize}\n\nThen:\n\\begin{equation}\n    \\oiint_S \\vf{F} \\cdot d\\vf{S} = \\iiint_D \\nabla \\cdot \\vf{F}\\ dV\n\\end{equation}\n\nThis means the total stuff escaping $S$ is the net sum of all the sources within it.\n\n\\section{Stoke's Theorem}\nIf $C$ is a closed curve and $S$ is any surface bounded by C.\n\n\\begin{equation}\n    \\oint_C \\vf{F} s\\vf{r} = \\iint_S (\\nabla \\times \\vf{F}) \\cdot \\norm \\ dS\n\\end{equation}\n\nIf I walk along $C$ with $S$ to my left, then $\\norm$ is pointing up.\n\n\\end{document}\n", "meta": {"hexsha": "c737a8ab7f17d48c6280cc6172ada131cf9002fe", "size": 10931, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mathematics/vector_calculus/summary.tex", "max_stars_repo_name": "include4eto/topic_summaries", "max_stars_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-13T20:04:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-03T20:57:56.000Z", "max_issues_repo_path": "mathematics/vector_calculus/summary.tex", "max_issues_repo_name": "include4eto/topic_summaries", "max_issues_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mathematics/vector_calculus/summary.tex", "max_forks_repo_name": "include4eto/topic_summaries", "max_forks_repo_head_hexsha": "8eca11d3544fc3c79f328051f170a42227f6c84c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.7222222222, "max_line_length": 408, "alphanum_fraction": 0.6280303723, "num_tokens": 3635, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.695958331339634, "lm_q1q2_score": 0.42031140116530535}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{amsmath, amsfonts, amsthm, amssymb}  % Some math symbols\n\\usepackage{enumerate}\n\\usepackage{fullpage}\n\n\\usepackage[x11names, rgb]{xcolor}\n\\usepackage{tikz}\n\\usepackage[colorlinks=true, urlcolor=blue]{hyperref}\n\\usepackage{graphicx}\n\\usepackage{gensymb}\n\n\\usetikzlibrary{snakes,arrows,shapes}\n\n\\usepackage{listings}\n\\usepackage{array}\n\\usepackage{mathtools}\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{5pt plus 1pt}\n\\pagestyle{empty}\n\n\\def\\indented#1{\\list{}{}\\item[]}\n\\let\\indented=\\endlist\n\n\\newcounter{questionCounter}\n\\newenvironment{question}[2][\\arabic{questionCounter}]{%\n    \\addtocounter{questionCounter}{1}%\n    \\setcounter{partCounter}{0}%\n    \\vspace{.25in} \\hrule \\vspace{0.5em}%\n        \\noindent{\\bf #2}%\n    \\vspace{0.8em} \\hrule \\vspace{.10in}%\n}{}\n\n\\newcounter{partCounter}[questionCounter]\n\\renewenvironment{part}[1][\\alph{partCounter}]{%\n    \\addtocounter{partCounter}{1}%\n    \\vspace{.10in}%\n    \\begin{indented}%\n       {\\bf (#1)} %\n}{\\end{indented}}\n\n%%%%%%%%%%%%%%%%% Identifying Information %%%%%%%%%%%%%%%%%\n%% This is here, so that you can make your homework look %%\n%% pretty when you compile it.                           %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newcommand{\\myhwname}{Homework 5}\n\\newcommand{\\mysection}{CS Fundamentals: Pong Review: Math! [due Tuesday]}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\begin{center}\n    {\\Large \\myhwname} \\\\\n    \\mysection \\\\\n    \\today\n\\end{center}\n\n%%%%%%%%%%%%%%%%% PROBLEM 1: Probability Review %%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Review: Pong Game [Expected Duration: 15 - 20 min]}\n\\textbf{If you have any questions about the directions or any blocks you have not used before, let me know via email or text!}\\\\\\\\\n\\noindent\\makebox[\\linewidth]{\\rule{\\paperwidth}{0.4pt}}\\\\\nIn the last lesson, we built together a very cool pong game together. \nWe built this cool calculator by using many things we learned previously and MATH. \nFor homework, I want you to do some math with angles. Math is quite important in programming! Have fun!\\\\\\\\ \nI want you to use the \\textbf{word} bank below to complete this assignment. \nNote that \\textbf{the words in the word bank is used exactly once... all words are used}.\\\\\\\\\nIf you have any questions, \\textbf{please} let me know!\\\\\\\\\n\\noindent\\makebox[\\linewidth]{\\rule{\\paperwidth}{0.4pt}}\\\\\n\\textbf{Instructions/Notes:}\\\\\n$0\\degree = 360\\degree = -360\\degree$ is Up.\\\\\n$90\\degree = -270 \\degree$ is East.\\\\\n$-90\\degree = 270 \\degree$ is West.\\\\\n$180\\degree = -180\\degree$ is South.\\\\\\\\\nThis homework is hard! You will need to know how to do reflection over x and y-axis. Do as best as you can! It is okay to not finish. Looking at the code for the pong game can help!\n\\\\\n\\noindent\\makebox[\\linewidth]{\\rule{\\paperwidth}{0.4pt}}\n\\begin{enumerate}\n\\item \\textbf{Bouncing off of the top wall}\\\\\nThe only walls the ball in pong can bounce off of are the ones on the bottom and at the top. Drawing pictures may help solve the problems below.\n % $\\rule{2.5cm}{0.15mm}$\n\\begin{enumerate}[a.]\n\\item Let's say a ball was approaching the top wall at a $-45\\degree$ (NorthWest) angle. To simulate bouncing off of the wall, we send the ball going at a $-135\\degree$ (SouthWest) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\\\\\\\\n\\item If the ball was approaching the top wall at a $50 \\degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection.)\\\\\\\\\\\\\n\\item Generally, if the ball was approaching the top wall at a $x \\degree$ angle, what direction $y \\degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\\\\\\\\\\\\\\n\\end{enumerate}\n\\end{enumerate}\n\\noindent\\makebox[\\linewidth]{\\rule{\\paperwidth}{0.4pt}}\n\\begin{enumerate}\n\\item \\textbf{Bouncing off of the bottom wall}\\\\\nThe only walls the ball in pong can bounce off of are the ones on the bottom and at the top. Drawing pictures may help solve the problems below.\n % $\\rule{2.5cm}{0.15mm}$\n\\begin{enumerate}[a.]\n\\item Let's say a ball was approaching the bottom wall at a $135\\degree$ (Southeast) angle. To simulate bouncing off of the wall, we send the ball going at a $45\\degree$ (Northeast) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\\\\\\\\n\\item If the ball was approaching the bottom wall at a $-100 \\degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection.)\\\\\\\\\\\\\n\\item Generally, if the ball was approaching the bottom wall at a $x \\degree$ angle, what direction $y \\degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\end{enumerate}\n\\end{enumerate}\n\\begin{enumerate}\n\\item \\textbf{Bouncing off of the right player's paddle}\\\\\nThere are 2 players in pongs. Each has a paddle. The balls can bounce off these paddles. Drawing pictures may help solve the problems below.\n % $\\rule{2.5cm}{0.15mm}$\n\\begin{enumerate}[a.]\n\\item Let's say a ball was approaching the right player's paddle  at a $135\\degree$ (Southeast) angle. To simulate bouncing off of the paddle, we send the ball going at a $-135 \\degree$ (Southwest) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\\\\\\\\n\\item If the ball was approaching the right player's paddle at a $100 \\degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection again.)\\\\\\\\\\\\\n\\item Generally, if the ball was approaching the right player's paddle at a $x \\degree$ angle, what direction $y \\degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\end{enumerate}\n\\end{enumerate}\n\\begin{enumerate}\n\\item \\textbf{Bouncing off of the left player's paddle}\\\\\nThere are 2 players in pongs. Each has a paddle. The balls can bounce off these paddles. Drawing pictures may help solve the problems below.\n % $\\rule{2.5cm}{0.15mm}$\n\\begin{enumerate}[a.]\n\\item Let's say a ball was approaching the left player's paddle  at a $-45\\degree$ (NorthWest) angle. To simulate bouncing off of the paddle, we send the ball going at a $45 \\degree$ (NorthEast) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\\\\\\\\n\\item If the ball was approaching the right player's paddle at a $120 \\degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection again.)\\\\\\\\\\\\\n\\item Generally, if the ball was approaching the right player's paddle at a $x \\degree$ angle, what direction $y \\degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\n\\end{enumerate}\n\\end{enumerate}\n\\end{document}\n", "meta": {"hexsha": "ae59bc684b084d540b97d1705e89f788e7498e40", "size": 7287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tutor_ms/hw5/hw5.tex", "max_stars_repo_name": "kevink97/Teaching-Materials", "max_stars_repo_head_hexsha": "49e2ba1bf53e65a6dcd7dd521443ff12359f9f7a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tutor_ms/hw5/hw5.tex", "max_issues_repo_name": "kevink97/Teaching-Materials", "max_issues_repo_head_hexsha": "49e2ba1bf53e65a6dcd7dd521443ff12359f9f7a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tutor_ms/hw5/hw5.tex", "max_forks_repo_name": "kevink97/Teaching-Materials", "max_forks_repo_head_hexsha": "49e2ba1bf53e65a6dcd7dd521443ff12359f9f7a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.8189655172, "max_line_length": 331, "alphanum_fraction": 0.7001509538, "num_tokens": 2043, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.42031139505130677}}
{"text": "\\chapter{Government}\n\\index{Government%\n@\\emph{Government}}%\n\n\n\n%\\pagestyle{empty}\n\n\n\\section{Overview of government in the model}\n\nThe government has four functions in the model.  First, it runs the tax and social security systems as described in the households' and firms' problems.  That is, it collects revenues and makes payments in accordance with the parameterized tax and social security policy functions.  The tax functions are user determined, but will default to a current law baseline if the user does not specify a policy proposal in affecting the relevant tax function.  Second, the government makes direct transfers to households outside of the social security system.  Third, the government produces a non-excludable public good.  Finally, the government contributes to the production of a private consumption good.  We discuss each of these function in more detail below after first defining the government's budget constraint.\nGovernment will have four functions in our model:\n\n\n\\section{Government budgeting}\n\nThe government's per-period budget constraint is given by: \n\n      \\begin{equation}\n      \\label{eqn:gbc}\n      D_{t+1} + T^{\\tau}_{t} = (1+r_{t})D_{t} + T^{H}_{t} + G^{subs}_{t} + w_{t}EL^{G}_{t} + p^{K}_{g}I^{G}_{t},\n      \\end{equation}\n\nwhere $D_t$ denotes the government's outstanding debt, $T_t$ is total tax revenue across all tax sources and net of social security transfers, $T^H_t$ is total direct transfers to households, $G^{subs}_t$ are government subsides to the production private goods, $EL_t$ is are effective labor units employed by government in the production of the public good, and $I_t$ is government investment in capital used to produce the government provided public good.  The price of capital for the government sector is given by $p^{K}_{g}$ and the price of an effective labor unit is $w_{t}$.  Note that we do not impose a balanced budget.  In any particular period, the government may run a surplus or deficit.  The government finances any gaps using debt, $D_{t}$.  \n\n\n\n    \\subsection{Rule for long-term fiscal stability}\n      \n      While the government can use debt to finance temporary budget shortfalls, the government cannot finance infinite amounts of debt.  For example, it cannot be the case that the debt level grows to such an extent that interest payments on the debt exceed GDP.  To ensure that the government budget is sustainable in the long run, we impose a rule that returns the debt-to-GDP ratio to some predetermined value after a set amount of time.  In particular, the user will select (or the model will default to) a particular steady-state debt-to-GDP ratio, $\\bar{d}=\\frac{\\bar{D}}{\\bar{Y}}$.  The model will then specify some period, $T$, such that after this time, the government budget adjusts to return to $\\bar{d}$.  In particular, if the debt-to-GDP ratio exceeds $\\bar{d}$, then government provision of the public good, $G_{t}$ is reduced.  This government debt rule takes the form: \n      \n      \n%      \\begin{equation}\n%        D_{t+1} = D_t(1+r_t) - T_t + T^H_t + G_t + L_t + S_t\n%      \\end{equation}\n%\n%      Letting a carat denote the ratio of a variable to GDP, we can rewrite this as follows:\n%\n%      \\begin{equation} \\label{EqDhatlom}\n%        (1+g_{Yt}) \\hat D_{t+1} = \\hat D_t(1+r_t) - \\hat T_t + \\hat T^H_t + \\hat G_t + \\hat L_t + \\hat S_t\n%      \\end{equation}\n%\n%      We need to adopt a government fiscal rule that determines how our residual expenditure $\\hat G_t$ evolves over time.\n%\n%      One way is to adopt a balanced budget rule which keeps the debt-to-GDP ratio constant at it's initial value of $\\hat D_0$.\n%\n%      \\begin{align}\n%        (1+g_{Yt}) \\hat D_0 & = \\hat D_0(1+r_t) - \\hat T_t + \\hat T^H_t + \\hat G_t + \\hat L_t + \\hat S_t \\nonumber \\\\\n%        \\hat G_t & = \\hat D_0(g_{Yt}-r_t) + \\hat T_t - \\hat T^H_t -\\hat L_t - \\hat S_t \\label{EqBalBudRule}\n%      \\end{align}\n%\n%      Another rule is to hold govenrment spending constant and let debt evolve as it will for several period.  Then in period $T$ impose fiscal austerity which forces $\\hat G_t$ to adjust over time so that $\\hat D_t$ goes to a steady value.\n\n      \\begin{equation}\n         G_{t} - \\bar{G} = \\rho_t (\\hat{d}_t - \\bar{d});\\quad \\rho_t<0, \n        \\label{EqAdjRule}\n      \\end{equation}\n\n\\noindent\\noindent where $\\hat{G}$ is the steady state level of public good (given steady-state debt-to-GDP ratio $\\bar{d}$) and $\\rho$ is a parameter that determines how quickly government debt returns to its steady-state value.  The parameter $\\rho$ will be estimated from historical data on the response of government spending to debt.  This calibration is discussed in the calibration chapters to be added to this document.  \n%\n%      Substituting this into \\eqref{EqDhatlom} gives:\n%      \\begin{align}\n%        (1+g_{Yt}) \\hat D_{t+1} & = \\hat D_t(1+r_t) - \\hat T_t + \\hat T^H_t + \\rho_t (\\hat D_t - \\bar D) + \\bar G + \\hat L_t + \\hat S_t \\nonumber \\\\\n%        \\hat D_{t+1} & = \\frac{\\hat D_t(1+r_t) - \\hat T_t + \\hat T^H_t + \\rho_t (\\hat D_t - \\bar D) + \\bar G + \\hat L_t + \\hat S_t }{1+g_{Yt}} \\label{EqDhatlom2}\n%      \\end{align}\n%\n%      Consider the steady state version of this.\n%      \\begin{align}\n%        (1+\\bar g_{Y}) \\bar D & = \\bar D(1+\\bar r) + \\bar T - \\bar T^H + \\rho_t (\\bar D - \\bar D) + \\bar G + \\bar L + \\bar S_t  \\nonumber \\\\\n%        \\bar G & = \\bar D(\\bar g_{Y} -\\bar r) + \\bar T - \\bar T^H - \\bar L - \\bar S  \\label{EqGbardef}\n%      \\end{align}\n%\n%      This tells us the long-run value of government spending to GDP that will maintain the debt to GDP target.\n%\n%      In order for \\eqref{EqDhatlom2} to be a contraction mapping over $\\hat D$ and thus converge to a steady state, we must put bounds on $\\rho_t$.  Rearranging \\eqref{EqDhatlom2} and using \\eqref{EqGbardef}:\n%\n%      \\begin{align}\n%        \\begin{split}\n%        (1+g_{Yt}) \\hat D_{t+1} & = \\hat D_t (1+r_t) - \\hat T_t + \\hat T^H_t + \\rho_t (\\hat D_t - \\bar D) + \\hat L_t + \\hat S_t \\\\\n%        & + \\bar D(\\bar g_{Y} - \\bar r) + \\bar T - \\bar T^H - \\bar L - \\bar S\n%        \\end{split} \\nonumber \\\\\n%        \\begin{split}\n%        (1+g_{Yt}) \\hat D_{t+1} & = \\hat D_t (1+r_t) - \\hat T_t + \\hat T^H_t + \\rho_t \\hat D_t - \\rho_t \\bar D + \\hat L_t + \\hat S_t \\\\\n%        & + \\bar g_Y \\bar D - \\bar r \\bar D + \\bar T - \\bar T^H - \\bar L - \\bar S\n%        \\end{split} \\nonumber \\\\\n%        \\begin{split}\n%        (1+g_{Yt}) \\hat D_{t+1} & =  \\hat D_t (1+r_t) + \\rho_t (\\hat D_t -\\bar D) + (\\bar g_Y - \\bar r ) \\bar D \\\\\n%        & - (\\hat T_t - \\bar T) + (\\hat T^H_t -\\bar T^H) + (\\hat L_t -\\bar L) + (\\hat S_t -\\bar S)\n%        \\end{split} \\nonumber \\\\\n%        \\begin{split}\n%        \\hat D_{t+1} - \\bar D & = \\hat D_t \\frac{1+r_t}{1+g_{Yt}} + \\frac{\\rho_t}{1+g_{Yt}} (\\hat D_t -\\bar D) + \\left( \\frac{\\bar g_Y - \\bar r}{1+g_{Yt}} - 1 \\right) \\bar D \\\\\n%        & + \\frac{-(\\hat T_t - \\bar T) + (\\hat T^H_t -\\bar T^H) + (\\hat L_t -\\bar L) + (\\hat S_t -\\bar S)}{1+g_{Yt}}\n%        \\end{split}  \\nonumber \\\\\n%        \\begin{split} \n%        \\hat D_{t+1} - \\bar D & = \\frac{1+r_t+\\rho_t}{1+g_{Yt}} (\\hat D_t -\\bar D) \\\\\n%        & + \\frac{-(\\hat T_t - \\bar T) + (\\hat T^H_t -\\bar T^H) + (\\hat L_t -\\bar L) + (\\hat S_t -\\bar S)}{1+g_{Yt}}\n%        \\end{split} \n%        \\label{EqStab}\n%      \\end{align}\n%\n%      We need $\\frac{\\hat D_{t+1} - \\bar D}{\\hat D_{t} - \\bar D} < 1$ for stability.  Equation \\eqref{EqStab} gives:\n%      \\begin{align} \n%        \\frac{\\hat D_{t+1} - \\bar D}{\\hat D_t -\\bar D} & = \\frac{1+r_t+\\rho_t}{1+g_{Yt}}  + \\frac{-(\\hat T_t - \\bar T) + (\\hat T^H_t -\\bar T^H) + (\\hat L_t -\\bar L) + (\\hat S_t -\\bar S)}{(1+g_{Yt})(\\hat D_t -\\bar D)} < 1 \\nonumber \\\\\n%        & \\frac{1+r_t+\\rho_t}{1+g_{Yt}}  < \\frac{(\\hat T_t - \\bar T) - (\\hat T^H_t -\\bar T^H) - (\\hat L_t -\\bar L) - (\\hat S_t -\\bar S)}{(1+g_{Yt})(\\hat D_t -\\bar D)} \\nonumber \\\\\n%        & \\rho_t  < (1+r_t)\\frac{(\\hat T_t - \\bar T) - (\\hat T^H_t -\\bar T^H) - (\\hat L_t -\\bar L) - (\\hat S_t -\\bar S)}{\\hat D_t -\\bar D}\n%      \\end{align} \n\n \\section{Direct transfers}\n      Direct transfers to individuals, $T^{H}_{t}$, will be modeled as a polynomial function of age and income.  In that sense, this function will be similar to those used to determine individual income taxes.  This function will be estimated from data on government transfers by age and income....\n\n\\section{Government production of public goods}\n\nThe government engages in the production of a non-excludable public good.  Utility from the public good enters the individuals' utility functions in an additively separable way, and thus is excluded from the description above since it does not impact consumer decisions.  To produce the public good, the government uses a capital and labor in a constant returns to scale Cobb-Douglas production function.  In particular, the total quantity of the public good is given by:\n\n\\begin{equation}\n\\label{eqn:pub_good}\nG_{t} = (K^{G}_{t})^{\\alpha}(EL^{G}_{t})^{1-\\alpha}\n\\end{equation}\n\n\\noindent\\noindent The parameter $\\alpha$ thus represents capital's share of output of the public good.  The government's capital stock follows the standard law of motion: $K^{G}_{t+1} = (1-\\delta^{G})K^{G}_{t} + I^{G}_{t}$.  \n\nWe determine $G_{0}$ as the the total amount of spending on government goods and services less the purchase of inputs for government production of private goods in the model's base year.  We then set $G_{t}=G_{0}$ for all $t<T$.  At period $T$, the government budget may need to adjust $G_{t}$ to make debt sustainable.  Thus the government supply of the public good is exogenous in periods 0 to $T$ and determined by the steady state value of debt there after.  We use this to solve for the expenditures on labor and capital to produce this public good.  The government solves:\n\n%\\begin{equation}\n%\\label{eqn:pub_good_prob}\n\\begin{align}\n\\min_{\\{EL^{G}_{u},I^{G}_{u}\\}^{\\infty}_{u=t}} \\sum_{u=t}^{\\infty} \\prod_{\\nu=t}^{u}\\left(\\frac{1}{1+r_{\\nu}}\\right) w_{u}EL^{G}_{u} + p^{K}_{g,u}I^{G}_{u} & \\\\\n\\text{subject to:} \\ & G_{t} = (K^{G}_{t})^{\\alpha}(EL^{G}_{t})^{1-\\alpha} \\ \\text{and} \\\\\n\t& K^{G}_{t+1} = (1-\\delta^{G})K^{G}_{t} + I^{G}_{t}, \\forall  \\ t\n\\end{align}\n%\\end{equation}\n\nThe equation above can be solved for government's demand for capital and labor as a function of the model parameters, factor prices, and government supply of public goods.  In particular, we can find the demand for capital as:\n\n\\begin{equation}\nK^{G}_{t+1} = \\frac{\\alpha}{1-\\alpha}\\frac{w_{t}}{p^{K}_{g,t}}(1+r_{t})L_{t}\\frac{G_{t+1}}{G_{t}}\n\\end{equation}\n\n\\section{Government production of private goods}\n\nThe government is one of the $M$ production sectors.  Its problem is thus described in Chapter \\ref{chap:firms}.  However, the government firm differs from the private firms in that the gross-of-tax output price, $p_{g,t}$, includes a subsidy.  This means that the government sells output at a price that is below the cost of production. Instead of the zero-profit condition, the condition for government firms is:\n\n\\begin{equation}\nG^{subs}_{t} = p_{g,t}X_{g,t} - w_{t}EL_{g,t} - r_{t}K_{g,t}\n\\end{equation}\n\n\\noindent\\noindent  Thus the government subsidy towards the production of private goods is the difference between government revenues at the subsidized price and the costs of inputs to production.\n\n\n\n\n\n\n", "meta": {"hexsha": "de4d739e5ca1767a26fe5de641db0a33c1c96c4b", "size": 11295, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Model Writeup/Government_description.tex", "max_stars_repo_name": "lnsongxf/OG-USA", "max_stars_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-05-23T13:57:53.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-23T13:57:53.000Z", "max_issues_repo_path": "Model Writeup/Government_description.tex", "max_issues_repo_name": "lnsongxf/OG-USA", "max_issues_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Model Writeup/Government_description.tex", "max_forks_repo_name": "lnsongxf/OG-USA", "max_forks_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-03T19:06:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-03T19:06:24.000Z", "avg_line_length": 72.8709677419, "max_line_length": 886, "alphanum_fraction": 0.6567507747, "num_tokens": 3598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.42031138743429947}}
{"text": "\\documentclass{tufte-handout} \n\\usepackage{amsmath,stmaryrd,amssymb,amsthm,url,booktabs,hyperref,enumerate}\n\\usepackage{color}\n\\usepackage{tikz}\n\\usetikzlibrary{decorations.markings}\n\\usetikzlibrary{intersections}\n\\usetikzlibrary{hobby}\n\\usepackage{tikz-cd}\n\\usetikzlibrary{%\n  matrix,%\n  calc,%\n  arrows%\n}\n\n\\usepackage{stackrel}\n\n% \\usepackage{enumitem} \\setlist[itemize]{noitemsep, topsep=0pt}\n\n\\makeatletter\n% Paragraph indentation and separation for normal text\n\\renewcommand{\\@tufte@reset@par}{% \n  \\setlength{\\RaggedRightParindent}{0pc}% 1.0pc \n  \\setlength{\\JustifyingParindent}{0pc}% 1.0pc \n  \\setlength{\\parindent}{0pc}% 1pc \n  \\setlength{\\parskip}{0pt}%\n}\n\\@tufte@reset@par\n\n\\makeatother\n\n\n\\ifpdf \n\t\\usepackage[all,pdf,cmtip]{xy} %% NB this MUST be loaded last.\n\\else\n\t\\input xy \n\t\\xyoption{all} \n\t\\xyoption{2cell} \n\t\\xyoption{v2}\n\\fi \n\\CompileMatrices\n\n\\hyphenation{homeo-morphic homeo-morphism}\n\n\\parskip = 10pt\n\n\\def\\into {\\hookrightarrow} \n\\def\\cE {\\mathcal{E}} \n\\def\\cC {\\mathcal{C}} \n\\def\\cR {\\mathcal{R}} \n\\def\\cD {\\mathcal{D}} \n\\def\\cP {\\mathcal{P}} \n\\def\\cT {\\mathcal{T}} \n\\def\\cN {\\mathcal{N}}\n\n\\def\\op {\\mathrm{op}}\n\\def\\pt {\\mathrm{pt}}\n\n\\def\\Set {\\mathbf{Set}}\n\\def\\Top {\\mathbf{Top}}\n\\def\\Ho {\\mathbf{hTop}}\n\\def\\slpcTop {\\mathbf{slpcTop}}\n\\def\\Cov {\\mathbf{Cov}}\n\\def\\Grp {\\mathbf{Grp}}\n\\def\\Gpd {\\mathbf{Gpd}}\n\\def\\Mod {\\mathbf{Mod}}\n\\def\\Ab {\\mathbf{Ab}}\n\\def\\Fin {\\mathbf{Fin}}\n\\def\\Vect {\\mathbf{Vect}}\n\\def\\Ch{\\mathbf{Ch}}\n\\def\\Cplx{\\mathbf{Cplx}}\n\n\\def\\RR{\\mathbb{R}} \n\\def\\NN{\\mathbb{N}}\n\\def\\ZZ{\\mathbb{Z}}\n\\def\\QQ{\\mathbb{Q}}\n\\def\\CC{\\mathbb{C}}\n\\def\\BB{\\mathbb{B}}\n\n\\newcommand{\\lecturenum}[1]{\\marginnote{\\color{red}Lecture #1}}\n\n\\DeclareMathOperator{\\disc}{disc}\n\\DeclareMathOperator{\\codisc}{codisc}\n\\DeclareMathOperator*{\\colim}{colim} \n\\DeclareMathOperator{\\Sh}{Sh} \n\\DeclareMathOperator{\\End}{End} \n\\DeclareMathOperator{\\id}{id} \n\\DeclareMathOperator{\\Deg}{deg} \n\\DeclareMathOperator{\\coker}{coker}\n\\DeclareMathOperator{\\Sub}{Sub} \n\\DeclareMathOperator{\\Aut}{Aut} \n\\DeclareMathOperator{\\Cont}{Cont}\n\\DeclareMathOperator{\\im}{im}\n\\DeclareMathOperator{\\pr}{pr}\n\\DeclareMathOperator{\\ev}{ev}\n\\DeclareMathOperator{\\Lift}{Lift}\n\\DeclareMathOperator{\\Ad}{Ad}\n\\DeclareMathOperator{\\sk}{sk}\n\n\n\\theoremstyle{definition} \n\\newtheorem{prop}{Proposition} \n\\newtheorem{lemma}{Lemma} \n\\newtheorem{definition}{Definition} \n\\newtheorem{example}{Example} \n\\newtheorem{ex}{Exercise}\n\\newtheorem{construction}{Construction}\n\\newtheorem*{constr}{Construction}\n% \\newtheorem{exercise}{Exercise} \n\\newtheorem{theorem}{Theorem} \n\\newtheorem{corollary}{Corollary} \n\\newtheorem{q}{Question} \n\\newtheorem*{conj}{Conjecture} \n\\newtheorem*{rem}{Remark} \n\\newtheorem*{fact}{Fact}\n\n\\newenvironment{psmallmatrix}\n  {\\left(\\begin{smallmatrix}}\n  {\\end{smallmatrix}\\right)}\n\n\\title{Algebraic Topology\\thanks{This document is released under a CC-By license: \n\\href{https://creativecommons.org/licenses/by/4.0/}{\\texttt{creativecommons.org/licenses/by/4.0/}}.}\n}\n\\author[D.M.~Roberts]{David Michael Roberts} \n\\date{2019} \n\n\\begin{document} \n\n\\maketitle\n\n%% Uncomment for tufte-book\n% \\tableofcontents\n% \\mainmatter\n\n\\section{What is it?}\n\n\\lecturenum{1}\nAlgebraic topology is the study of maps \n\\[\n\t\\{\\text{Spaces}\\} \\longrightarrow \\{\\text{Algebraic objects}\\},\n\\] \n%\nor rather, `well-behaved' such maps. They should also send continuous functions between spaces to \nalgebraic maps, respecting composition (so: \\emph{functors}); they should send spaces built \nout of simpler spaces to algebraic objects built out of simpler components, in a compatible way, \netc.\n\nHere, `Spaces' roughly means topological spaces up to deformation (usually homotopy, but \nnot always). Such equivalence classes are called \\emph{homotopy types}. `Algebraic \nobjects' means (abelian) groups, rings, modules, or even chain complexes of these \n\\marginnote{a chain complex is a certain sequence of maps $\\cdots \\to V_0 \\to V_1 \\to \nV_2 \\to \\cdots$}.\n\n\\begin{example} \n\tHow can we tell if the sphere $S^2$ and the torus $S^1\\times S^1$ can or \n\tcannot be deformed into each other? How would you prove it cannot be done? \n\\end{example}\n\n\\begin{example} \n\tFor a positive example, we \\emph{can} squash $\\RR^3 \\setminus \\{0\\} \\to S^2 \\into \n\t\\RR^3 \\setminus \\{0\\} $, sending $x\\mapsto \\frac{x}{|x|}$. This map continuously \n\tdeforms to the identity map. So dimension not necessarily preserved.\n\\end{example}\n\n\\begin{example} \n\tCan we have $S^1 \\sim S^2$? \n\\end{example} \n\n\\noindent We first need to understand how spaces are built\n\n\\section{Topological spaces}\n\nRecall\\ldots\\marginnote{From Topology and Analysis III}\n\n\\begin{definition} \n\tA \\emph{topology} on a set $X$ is a collection $\\cT$ of subsets of $X$ \n\tsuch that \n\t\\begin{enumerate} \n\t\n\t\t\\item $\\emptyset,X\\in\\cT$ \n\t\t\n\t\t\\item If $U,V\\in \\cT$ then $U\\cap V\\in \\cT$ \n\n\t\t\\item If $\\{U_\\alpha\\}_{\\alpha\\in I}$ is an arbitrary family of sets in $\\cT$, then $\\bigcup_{\\alpha\\in I} U_\\alpha \\in \\cT$\\marginnote{$I$ here is an indexing set}\n\n\t\\end{enumerate}\n \n\tIf $U\\in \\cT$ we say $U$ is \\emph{open}. A \\emph{topological space} is a set $X$ \n\teqipped with a topology $\\cT$.\n\\end{definition}\n\n\\begin{example} \n\tTake the set of real numbers, the \\emph{Euclidean (`usual') topology} is \n\tdefined by saying a set is open iff it is a union of open intervals $(a,b)$ (including the \n\tunion of no sets ie $\\emptyset$).\\\\ \n\tThe \\emph{discrete topology} on a set $X$ is defined by \n\ttaking every $\\cT$ to consist of all subsets. The \\emph{indiscrete topology} is defined by \n\ttaking $\\cT$ to consist of just $\\emptyset$ and $X$. \n\\end{example}\n\nThis definition is concise, but not always the best way to define a topology. We will also \nuse \\emph{neighbourhoods}\n\n\\begin{definition} \n\tA set $N\\subseteq X$ is a \\emph{neighbourhood}\\marginnote{`nhd' is a good \n\tabbreviation} (in a given topology $\\cT$) of a point $x\\in X$ if there is an open \n\tset $U\\subseteq N$ with $x\\in U$.\n\\end{definition}\n\n\n\\begin{example} \n\tTake $\\RR$ with the Euclidean topology. $(-1,1)$, $[-1,1]$, $[-1,1)$ are all \n\tneighbourhoods of every $-1<x<1$, but $[0,1)$ is not a neighbourhood of $0$. More \n\tcomplicated: $[0,1] \\cup \\{2\\}\\cup [5,6]$ is a nhd of all $0<x<1$ and $5<x<6$.\n\\end{example}\n\n\\begin{example} \t\n\tConsider a metric space $(X,d)$. The \\emph{metric topology} is defined by saying a \n\tsubset $U\\subseteq X$ is open iff for every $x\\in U$ there is some $\\varepsilon_x > \n\t0$ with the open ball $B(x,\\varepsilon_x) \\subseteq U$. Open balls around $x$ are \n\tneighbouhoods of $x$, as are closed balls.\n\\end{example}\n\nHere is a more concrete approach that allows concise definitions of topologies:\n\n\\begin{definition} \n\tA \\emph{neighbourhood base} $\\cN$ on a set $X$ is a family \n\t$\\{\\cN(x)\\}_{x\\in X}$ where each $\\cN(x)$ is a nonempty collection of subsets of $X$, \n\tsatisfying the following, for all $x\\in X$: \n\n\t\\begin{enumerate} \n\n\t\\item For all $N\\in \\cN(x)$, $x\\in N$;\n \n\t\\item For all $N_1,N_2 \\in \\cN(x)$, there is some $N\\in \\cN(x)$ with $N\\subseteq N_1 \n\t\\cap N_2$;\n\n\t\\item For all $N\\in \\cN(x)$ there is a subset $U\\subseteq N$ such that $x\\in U$ and for \n\tall $y\\in U$, there is some $V \\in \\cN(y)$ such that $V\\subseteq U$. \n\n\t\\end{enumerate} \n\n\tWe say the sets in $\\cN(x)$ are \\emph{basic neighbourhoods} of $x$. \n\\end{definition}\n\nAs an example: given a topological space $(X,\\cT)$ defining $\\cN(x)$ to consist of all nhds \nof $x$ gives a nhd base. Similarly, defining $\\cN'(x)$ to consist of all open sets \ncontaining $x$ defines a nhd base.\n\n\nGiven a neighbourhood base $\\cN$ on a set $X$, define a subset $U\\subseteq X$ to be \n\\emph{$\\cN$-open} iff for all $x\\in U$, there is an $N\\in \\cN(x)$ with $N\\subseteq U$.\n\n\\begin{prop} \nThe $\\cN$-open sets define a topology on $X$. \n\\end{prop} \n\n\\begin{proof} \nWe verify the axioms for a topology on $X$. \n\n\\begin{enumerate}\n\n\\item The condition that $\\emptyset$ is $\\cN$-open is vacuously true. And since $\\cN(x)$ is \nnot empty, there is a basic nhd around every point, so $X$ is $\\cN$-open.\n\n\\item Given $U,V$ both $\\cN$-open, we want to show $U\\cap V$ is $\\cN$-open. So take $x\\in \nU\\cap V$. We know there is $N_U,N_V \\in \\cN(x)$ with $N_U \\subseteq U$ and $N_V \\subseteq \nV$, and also that $x\\in N_U \\cap N_V$, since it is in each of them. Thus there is some $N\\in \n\\cN(x)$ with $N \\subseteq N_U \\cap N_V \\subseteq U\\cap V$, and this is true for all $x\\in \nU\\cap V$. Hence $U\\cap V$ is $\\cN$-open.\n\n\\item Given a family $U_\\alpha$, $\\alpha\\in I$, with each $U_\\alpha$ $\\cN$-open, we want to \nshow $U := \\bigcup_{\\alpha\\in I}U_\\alpha$ is $\\cN$-open. Take $x\\in U$, so there is some \n$\\alpha_0$ with $x\\in U_{\\alpha_0}$. But this set in $\\cN$-open, so there is some nhd $N$ of \n$x$ with $N\\subseteq U_{\\alpha_0} \\subseteq U$, and this is true for all $x\\in U$. So $U$ is \n$\\cN$-open. \\qedhere\n\n\\end{enumerate} \n\\end{proof}\n\nWe call the topology from this proposition the topology generated by $\\cN$. Neighbourhoods \nin this topology are sets that contain a basic neighbourhood: $V$ is a neighbourhood of $x$ \nif there is some $N\\in \\cN(x)$ with $N\\subseteq V$.\n\nGiven a neighbourhood base $\\cN$ on $X$, we can identify the \\emph{closure} of a set \n$S \\subset X$ as the collection of points $x\\in X$ such that for all $N\\in \\cN(x)$, \n$\\exists s\\in N\\cap S$.\n\n\n\\begin{example} \nGiven a metric space $(X,d)$ the open balls form a nhd base on $X$ and the \ntopology they generate is the metric topology. \n\\end{example}\n\n\n\nHence many definitions you are familiar with from metric spaces work for topological spaces, if \nthey can be phrased in terms of basic nhds. In particular, continuity!\n\n\\begin{definition} \nLet $\\cN_X$ and $\\cN_Y$ be neighbourhood bases on sets $X$ and $Y$ \nrespectively. A function $f\\colon X\\to Y$ is \\emph{continuous} if for every $x\\in X$ and \n$N\\in \\cN_Y(f(x))$, the set $f^{-1}(N)$ contains a basic nhd of $x$. \n\\end{definition}\n\nThis is a big generalisation of the $\\varepsilon$-$\\delta$ definition of continuity.\n\n\\begin{ex} \nShow\\marginnote{Recall a function is continuous for topologies if \n$f^{-1}(U)$ is open for all open $U$.} that if $f\\colon (X,\\cN_X)\\to (Y,\\cN_Y)$ is \ncontinuous as just defined, it is continuous for the topologies generated on $X$ and $Y$ by \nthese nhd bases. \n\\end{ex}\n\nAs a sanity check,\\marginnote{You can check every function \\emph{to} an indiscrete space \nis continuous, as is every function \\emph{on} a discrete space} the identity function \n$\\id_X$ on a space $X$ is indeed continuous.\n\n\\begin{definition}\nA continuous function $f\\colon X\\to Y$ is a \\emph{homeomorphism} if there is a continuous \nfunction $g\\colon Y\\to X$ with $g\\circ f = \\id_X$ and $g\\circ f = \\id_Y$. \nWe then call $X$ and $Y$ \\emph{homeomorphic}\\marginnote{or just isomorphic, if I'm being lazy}\n if there is a homeomorphism between them.\n\\end{definition}\n\n\nNow we need to show how to build new spaces, and continuous maps relating them to the \noriginal spaces.\n\n\\begin{definition} \nLet $X$ be a set, $(Y_\\alpha,\\cN_\\alpha)$, $\\alpha \\in I$ a family of \nsets with nhd bases (not necessarily all unique), and $f_\\alpha\\colon X\\to Y_\\alpha$ a \nfamily of functions. The \\emph{initial topology} on $X$ is generated by the following nhd \nbase: a subset of $X$ is a basic nhd of $x$ iff\\marginnote{Exercise: verify this is a nhd base!} \n it is of the form $f_{\\alpha_1}^{-1}(N_1) \\cap \\ldots \\cap f_{\\alpha_k}^{-1}(N_k)$ for \nsome $\\alpha_1,\\ldots,\\alpha_k$ and $N_i \\in \\cN_{\\alpha_i}(f_{\\alpha_i}(x))$. \n\\end{definition}\n\nThis generalises the product topology, which is the case that $X = Y_1 \\times Y_2$, and \n$f_i\\colon X\\to Y_i$ is the projection $f_i(y_1,y_2) = y_i$, where $i=1,2$. But this \n\\emph{also} gives the subspace topology: take $f\\colon X\\into Y$ to be injective and define \nthe initial topology on $X$.\n\n\\begin{lemma} \nGiving $X$ the initial topology, all the functions $f_\\alpha\\colon X\\to \nY_\\alpha$ are continuous. Moreover, a function $k\\colon Z\\to X$ is continuous iff \n$f_\\alpha\\circ k\\colon Z\\to Y_\\alpha$ is continuous for every $\\alpha$. \n\\end{lemma}\n\n\\begin{example}\\lecturenum{2}\nIf the set of functions consists of a single \\emph{injective} map, namely $\\iota\\colon X\\into Y$, with\n$Y$ a space, then the initial topology is the subspace topology: basic nhds of $x$ correspond \nto sets $\\iota^{-1}(N)$ (basically $N\\cap X$) for $N$ a basic nhd of $\\iota(x)$.\n\\end{example}\n\n\\begin{example}\nIf however we have a constant function $c_{y_0}\\colon X\\to Y$, sending $x\\mapsto y_0 \\in Y$ for all $x$, then\nfor every nhd $N$ of $y_0$, $c_{y_0}^{-1}(N) = X$. So the only nhd of every $x\\in X$ is $X$ itself.\nThus the initial topology is indiscrete in this case. \n\\end{example}\n\nIn general, given the family of functions $f_\\alpha\\colon X\\to Y_\\alpha$, there is a function\n$(f_\\alpha)\\colon X\\to \\prod_\\alpha Y_\\alpha$. If we give $\\prod_\\alpha Y_\\alpha$ the product \ntopology, then the initial topology on $X$ from the family of maps is the same as the initial\ntopology from the map $(f_\\alpha)$ to the product space. So if this latter map is injective,\n$X$ inherits the subspace topology from the product topology. This is the major use-case we\nwill come across for the initial topology.\n\n\\begin{example}\nA submanifold $M\\subseteq \\RR^n$ gets its topology from the coordinate functions \n$M\\into \\RR^n \\xrightarrow{x_i} \\RR$, and a map to $M$ is continuous iff the composite with\nthe maps to each factor of $\\RR^n$ are continuous.\n\\end{example}\n\n\n\\begin{ex}\nGiven a set $X$, a space $Y$ and a function $f\\colon X\\to Y$, if two points $x_1,x_2$ \nsatisfy $f(x_1)=f(x_2)$, show that a subset $V\\subseteq X$ is a nhd of $x_1$ iff it is a nhd\nof $x_2$, in the initial topology.\n\\end{ex}\n\nThe following will be even more important for us, and will be new to most.\n\n\\begin{definition} \nLet $X$ be a set, $(Z_\\beta,\\cN_\\beta)$, $\\beta \\in J$ a family of topological spaces \n(not necessarily all unique), and $g_\\beta\\colon Z_\\beta\\to X$ a family of \nfunctions (note the other direction!). The \\emph{final topology}\\marginnote{this really is \neasier to describe using open sets, rather than nhds} on $X$ has open sets as \nfollowing: $U\\subset X$ is open iff for all $\\beta\\in J$, $g_\\beta^{-1}(U)$ is open in \n$Z_\\beta$. \n\\end{definition}\n\n\\begin{lemma} \nGiving $X$ the final topology, all the functions $g_\\beta\\colon Z_\\beta\\to X$ \nare continuous. Moreover a function $h\\colon X\\to W$ is continuous for the final topology on \n$X$ iff $h\\circ g_\\beta\\colon Z_\\beta\\to W$ is continous for every $\\beta\\in J$. \n\\end{lemma}\n\nWe will give two special cases of this, and we will see them often.\n\n\\begin{example} \nLet $Z$ be a topological space, and let $\\sim$ be an equivalence \nrelation on $Z$, and define $X = Z/\\!\\sim$ to be the quotient by this relation. There is a \nfunction $ \\pi\\colon Z\\to X$ sending $y\\mapsto [y]$. The final topology on $X$ has as open \nsets those $U\\subseteq X$ such that $\\pi^{-1}(U)$ is open in $Z$. \n\\end{example}\n\nFor instance, we can give $S^2$ the initial topology for the maps $x_i\\colon S^2 \\to \\RR^3 \n\\xrightarrow{\\pr_i} \\RR$ (this is the usual topology on $S^2$), and then define the equivalence \nrelation on $S^2$ generated by $x\\sim -x$ for all $x\\in S^2$. \nThe quotient space is $\\mathbb{RP}^2$, the real projective \nplane, and we give it the final topology coming from $S^2\\to \\mathbb{RP}^2$. This is the \ntopology it carries as a manifold. Incidentally, $S^2$ is an example of a \\emph{covering \nspace} of $\\mathbb{RP}^2$, the study of which will occupy the first section of the course.\n\n\nRecall the definition of disjoint union of sets: given $Z_\\beta$, \n $\\beta\\in J$, a family of sets, we have $\\mathrm{in}_\\gamma \\colon Z_\\gamma \\into \n \\bigsqcup_{\\beta} Z_\\beta$ with $Z_\\beta \\cap Z_\\gamma = \\emptyset$ for $\\beta\\neq \\gamma$. \n If $Z_\\beta$ are spaces, then we give $\\bigsqcup_{\\beta} Z_\\beta$ the final topology for \n the maps $\\mathrm{in}_\\gamma$. This is \\emph{disjoint union} or \\emph{sum} \ntopology,\\marginnote{an important fact is that the map \n$\\bigsqcup_\\beta X\\times Z_\\beta \\to X\\times \\bigsqcup_\\beta Z_\\beta$ \nis a homeomorphism (exercise!)} and $\\bigsqcup_{\\beta} Z_\\beta$ is sometimes called the \n\\emph{topological sum}. A point in $\\bigsqcup_{\\beta} Z_\\beta$ can be described by a pair \n$(\\beta,z)$, where $z \\in Z_\\beta$.\n\n\\begin{ex} \nGiven continuous functions $h_\\beta\\colon Z_\\beta \\to W$, there is a unique continuous function $h = \n\\langle h_\\beta \\rangle \\colon \\bigsqcup_\\beta Z_\\beta\\to W$ with $h_\\beta = h\\circ \n\\mathrm{in}_\\beta$, or in other words this diagram commutes: \n\\[\n\t\\xymatrixnocompile{ \n\t\tZ_\\gamma \\ar[r]^{\\mathrm{in}_\\gamma} \\ar[dr]_{h_\\gamma} & \\bigsqcup_\\beta \n\t\tZ_\\beta \\ar[d]^h \\\\ & W\n\t}\n\\] \n\\end{ex}\n\n\\begin{lemma} \nThe final topology on $X$ for $g_\\beta\\colon Z_\\beta \\to X$ agrees with the \nfinal topology on $X$ for $g = \\langle g_\\beta \\rangle\\colon \\bigsqcup_\\beta Z_\\beta \\to X$, \nusing the sum topology. \n\\end{lemma}\n\n\\begin{proof} \nWe have that $U\\subseteq X$ is open iff $\\forall \\beta$ $g_\\beta^{-1}(U)$ is \nopen iff $\\forall \\beta$, $(g\\circ \\mathrm{in}_\\beta)^{-1}(U) = \n\\mathrm{in}_\\beta^{-1}\\left(g^{-1}(U)\\right)$ is open iff $g^{-1}(U)$ is open in the sum \ntopology. \n\\end{proof}\n\nThe idea behind the final topology, when $g_\\beta\\colon Z_\\beta \\to X$ are jointly \nsurjective,\\marginnote{%\nthis means $\\forall x\\in X$, $\\exists \\beta, x\\in Z_\\beta$ with \n$g_\\beta(z) = x$} \nis that we can put an equivalence relation on $\\bigsqcup_\\beta Z_\\beta$ \nwith $(\\beta_1,z_1)\\sim (\\beta_2,z_2)$ iff $g_{\\beta_1}(z_1) = g_{\\beta_2}(z_2)\\in X$. As a \nset, $X$ is the set of equivalence classes under this relation, so you can think of it as \ngluing together the \\emph{underlying sets} of the spaces $Z_\\beta$. The final topology on $X$ is \nthen the only sensible topology to described the space we get by gluing together the \n\\emph{spaces} $Z_\\beta$. \n\n\\begin{ex}\nGiven an open cover $\\{U_\\alpha\\}$ of a space $X$, then $X$ carries the final topology for \nthe inclusion maps $U_\\alpha \\into X$, or equivalently for the map \n$\\bigsqcup_\\alpha U_\\alpha\\to X$.\n\\end{ex}\n\n\\begin{example}\nAn arbitrary manifold $M$ has the final topology arising from any choice of atlas.\n\\end{example}\n\n\\begin{ex}\\label{ex:closed_cover_gluing_lemma}\nGiven a \\emph{finite} closed cover $\\{V_i\\}_{i=1}^n$ of $X$, then $X$ carries the final \ntopology for $\\bigsqcup_{i=1}^n V_i \\to X$.\n\\end{ex}\n\n\\begin{example}\\label{example:interval_final_topology}\nAny closed interval $[a,b]\\subset \\RR$ with the subspace topology has the final topology \narising from a collection of subintervals $[a,t_1]$, $[t_1,t_2]$,\\ldots,$[t_k,b]$, each\nwith the subspace topology from $\\RR$.\n\\end{example}\n\nThese exercises give us what is sometimes known as the \\emph{gluing} (or \\emph{pasting}) \\emph{lemma}:\n\n\\begin{lemma}\\label{lemma:gluing_lemma}\nConsider a space $X$ and an arbitrary open cover $\\{U_\\alpha\\}_{\\alpha\\in I}$ \n(respectively a finite closed cover $\\{V_i\\}_{i=1}^n$) and suppose $Y$ is some other \ntopological space. Then if a function $f\\colon X\\to Y$ is continuous when restricted to each \n$U_\\alpha$ (resp.\\ to each $V_i$) then $f$ is continuous.\n\\end{lemma}\n\nLater we'll see spaces that are built up by gluing together lots \nof `simple' spaces, like disks $D^n := \\{x\\in \\RR^n\\mod |x|\\leq 1\\}$ (with the subspace \ntopology from $\\RR^n$). But what does `simple' here mean? Roughly, ``shrinkable to a \npoint''.\n\n\\section{Homotopy}\n\n``Shrinkable'' implies a kind of continuous process in time. Consider the function $I\\times D^n \\to D^n$. Consider the map\n\\begin{align*}\n\tH\\colon I \\times D^n & \\to D^n\\\\\n\t(t,\\mathbf{x}) & \\mapsto (1-t)\\mathbf{x}\n\\end{align*}\nNote that this gives maps $H_0\\colon D^n\\to D^n$ (the identity map) and $H_1$ (constant at $0$).\nThe function $H$ is continuous! \nHow should we see this? \nThe topology on $D^n$ is the subspace topology $D^n \\subset \\RR^n$,\\marginnote{And $I\\subset \\RR$ has subspace topology}  and $\\RR^n$ has the product topology. \nso the topology on $D^n$ is also the initial topology for the coordinate functions \n$x_i\\colon D^n \\to \\RR^n \\to \\RR$. \nSo $H\\colon I\\times D^n \\to D^n$ is continuous iff\n\\[\n\t\\xymatrix@R=0.5pc{\n\tI\\times D^n \\ar[r]^{\\id\\times x_i} & I\\times \\RR \\ar[r]& \\RR\\times\\RR \\ar[r]& \\RR\\\\\n\t(t,\\mathbf{x}) \\ar@{|->}[rr] && (t,x_i) \\ar@{|->}[r] & tx_i \n\t}\n\\]\nBut $I\\times D^n \\to \\RR \\times \\RR$ is continuous by definition of initial topology, and the following result:\n\n\\begin{ex}\n\tIf $f\\colon X\\to W$ and $g\\colon Y\\to Z$ are continuous, then so is $f\\times g\\colon X\\times Y\\to W\\times Z$. \n\tIf both $X$ and $Y$ have at least one point each, then the reverse implication also holds.\n\\end{ex}\n\nSo if we can prove that multiplication $\\RR\\times \\RR \\to \\RR$ is continuous, then $H$ is continuous.\nBut the standard topology on $\\RR$ comes from the metric space structure, so can use sequential criterion for continuity.\nTake $(a_n,b_n)\\to (a,b)$ in $\\RR\\times \\RR$, then:\n\\begin{align*}\n\t|a_nb_n - ab| \t& = |a_nb_n -ab_n + ab_n - ab| \\\\\n\t\t\t& \\leq |a_n - a|\\,|b_n| + |a|\\,|b_n - b| \\\\\n\t\t\t& \\leq |a_n-a| \\sup|b_n| + |a| \\, |b_n - b|\\qquad\\text{(as $(b_n)$ converges, it is bounded)} \\\\\n\t\t\t& \\to 0+0  \n\\end{align*}\nHence $H$ is continuous.\n\n\\begin{definition}\n\tA space $X$ is \\emph{contractible}\\marginnote{or, \\emph{contractible to $x_0\\in X$}} if there is a point $x_0\\in X$ and a continuous function $H\\colon I\\times X\\to X$ such that $H(0,x) = x$ and $H(1,x) = x_0$ for all $x\\in X$. \nSuch a function is called a \\emph{contraction}.\n\\end{definition}\n\nWe have shown $D^n$ is contractible.\n\n\\begin{ex}\n$\\RR$ is contractible. An arbitrary product of contractible spaces is contractible.\n\\end{ex}\n\n\\begin{example}\nConsider what it would mean if a discrete space $S$ were contractible: there would be an element $*\\in S$ and a continuous function $h\\colon I\\times S \\to S$ such that $h(0,s) = s$ and $h(1,s) = *$. \nRestricting $h$ to $I\\times \\{s\\}$ for some given $s$, we get a continuous function $I \\into I\\times S \\to S$, whose range includes $*$ and $s$.\nSince all functions with discrete domain are continuous, let us compose with the continuous function $\\chi_{\\{*\\}}\\colon S\\to \\RR$ that sends $*\\mapsto 1$ and $s\\mapsto 0$ for all $s\\neq *$. \nSo we have a continuous function $\\widetilde{h}\\colon I\\to \\RR$ with $\\widetilde{h}(0)=0$ and range contained in $\\{0,1\\}$.\nBy the intermediate value theorem, we must have $\\widetilde{h}(1) = \\chi_{\\{*\\}}(h(1,s))= 0$, so that $h(1,s) = *$, and hence $s=*$ for all $s\\in S$. \nThus $S$ has exactly one element.\n\\end{example}\n\n\\begin{q}\nIf $X$ is contractible, does the choice of point $x_0\\in X$ matter? Is $X$ also contractible\nto $x\\in X$ for $x\\neq x_0$?\n\\end{q}\n\nThe interval can only map continuously to a discrete space if it is constant at some \nelement, or equivalently, its image consists of a single point, and this property is \nimportant enough to have a name.\n\n\\begin{definition}\\label{def:connected}\nA space $X$ is \\emph{connected}\\marginnote{If you know the `usual' definition, this is \nequivalent to it} if every continuous map from $X$ to a discrete space has image a single point.\n\\end{definition}\n\nSo the interval $I$ is an example of a connected space. Even better: if a pair of points $x,y\\in X$ \nhave a \\emph{path} between them (a map $I\\xrightarrow{\\gamma} X$ with $\\gamma(0) = x$, $\\gamma(1)=y$)\nthen any function $f\\colon X\\to S$ to a discrete space has $f(x)=f(y)$.\n\n\\begin{example}\nEvery contractible space is connected. This is because in a contractible space $X$, for every point $y$ \nthere is the path $t\\mapsto H(t,y)$ joining $y$ to the point $x_0$, so that $f(y)=f(x_0)$ for every map \n$X\\xrightarrow{f}S$ to discrete $S$.\n\\end{example}\n\nThere are however lots of spaces that are connected but not contractible, but we cannot \nyet prove this.\n\n\n\nThis\\lecturenum{3} is our first example of an invariant of spaces,\\marginnote{%\nConsider $\\xymatrix@=1pc{X\\ar[r]^\\simeq \\ar[d] & Z \\ar[dl]\\\\ S}$ with $S$ discrete.\n}\nnamely whether they are connected or not: a connected space $X$ cannot be homeomorphic \nto a space $Z$ that is not connected. But, how can we tell non-connected spaces apart?\n\n\\begin{definition}\n\\begin{enumerate}\n\n\t\\item For any space $X$, a subset $Y\\subseteq X$ is a \\emph{connected component} \n\tof $X$ if $Y$ is connected and for any connected $Y'\\subseteq X$ such that $Y\\subseteq Y'$,\n\tthen $Y= Y'$.\n\t\n\t\\item Put an equivalence relation on $X$ generated\\marginnote{%\n\t\tExercise: If $C,D\\subseteq X$ are connected, and $\\exists x \\in C\\cap D$, then\n\t\t$C\\cup D$ is connected. Also show: the equivalence classes are the \n\t\tconnected components.}\n\t\tby $x_1\\sim x_2$ iff $x_1$ and $x_2$ \n\t\tare both contained in a connected subset $C\\subseteq X$. Then define \n\t\t$\\pi_0(X) = X/\\sim$, the \\emph{set of connected components}. \n\n\\end{enumerate}\n\\end{definition}\n\nEvery connected space $X$ has $\\pi_0(X) = *$, but now we can tell apart non-connected \nspaces, by comparing their $\\pi_0$.\\marginnote{Such spaces are called `locally \nconnected', but we will eventually be \nassuming a slightly stronger condition. Be warned: $\\mathbb{Q}$ with the Euclidean \ntopology is \\textbf{not} locally connected, nor are many very interesting examples!} \nEvery space that we will be consider in this \ncourse can be written as $X = \\bigsqcup_{\\alpha\\in\\pi_0(X)} X_\\alpha$, with $X_\\alpha$ \nconnected, and have a continuous function $X\\to \\pi_0(X)$ where $\\pi_0(X)$ has the discrete\ntopology. \nAs a result, we need to try to understand \\emph{connected} spaces, though we \nwill still \\emph{use} non-connected spaces.\n\nCan we get more out of the idea of contractions? Given $H\\colon I\\times X\\to X$, we have \nmaps $H_i$ for $i=0,1$, namely $H_0 = \\id_X$ and $H_1$ is constant at $x_0$. What if \n$H_0$ and $H_1$ were other sorts of continuous maps? \\medskip\n\n\\begin{example}\\label{eg:annulus}\nConsider the annulus $A(r,R) := \\{x \\in \\mathbb{R}^2\\mid r\\leq |x| \\leq R\\}$, and the function \n$H(t,x) = ((1-t)r + tR)x/|x|$.\n\\end{example}\n\nWhat if we considered general continuous maps $X\\to Y$ instead of just $X\\to X$?\n\n\\begin{definition}\n\tA \\emph{homotopy} is a\\marginnote{%\n\tA useful picture is: $\\xymatrix{\n\t\t\\{0\\}\\times X \\ar[dr]^f\\ar[d]\\\\\n\t\tI\\times X \\ar[r]^H & Y\\\\\n\t\t\\{1\\}\\times X \\ar[u] \\ar[ur]_g\n\t}$\n\t} continuous function $H\\colon I \\times X\\to Y$. \n\tIf $f = H(0,-)$ and $g = H(1,-)$, we say $H$ is a \\emph{homotopy from $f$ to $g$}, and that $f$ and $g$ are \\emph{homotopic}, written $f\\sim g$.\n\\end{definition}\n\nExample \\ref{eg:annulus} gives a homotopy between the two `retraction' maps $A(r,R) \\to \nA(r,R)$, mapping points to the inner and outer circles respectively.\n\nAlgebraic topology most of the time considers functions \\emph{up to homotopy}, and also \n``spaces up to homotopy''.\n\n\\begin{definition}\nA continuous function $f\\colon X\\to Y$ is called a \\emph{homotopy equivalence} if there is a continuous function $g\\colon Y\\to X$ such that $g\\circ f\\sim \\id_X$ and $f\\circ g\\sim \\id_Y$. We then say $X$ and $Y$ are \\emph{homotopy equivalent}.\n\\end{definition}\n\n\\begin{example}\nA contractible space is homotopy equivalent to a one-point space.\n\\end{example}\n\nYou should think of homotopy equivalences as being `kinda like isomorphism', but coarser.\nGoing back to our original motivation, the maps\n\\[\n\t\\{\\text{Spaces}\\} \\longrightarrow \\{\\text{Algebraic objects}\\}\n\\]\nunder consideration should take homotopy equivalent spaces to isomorphic algebraic objects. \nTo make this more rigorous we will use the language of category theory.\n\n\n%\nHere is a super-important property of homotopies we will use continuously.\n\n\\begin{prop}\nGiven homotopies $H\\colon I \\times X \\to Y$ and $H'\\colon I \\times X \\to Y$ such that $H_1 = H'_0\\colon X\\to Y$, there is a homotopy $H''$ from $H_0$ to $H_1$, and a homotopy $\\widetilde{H}$ from $H_1$ to $H_0$.\n\\end{prop}\n\n\\begin{proof}\nWe will use Exercise~\\ref{ex:closed_cover_gluing_lemma} applied to the closed cover $\\{[0,\\frac12]\\times X, [\\frac12,1]\\times X\\}$ of $I\\times X$. \nSince $I \\simeq [0,\\frac12]$ and $I\\simeq [\\frac12,1]$, $H$ and $H'$ give us maps $[0,\\frac12]\\times X \\simeq I\\times X\\xrightarrow{H} Y$ and $[0,\\frac12]\\times X \\simeq I\\times X\\xrightarrow{H'} Y$ respectively. By the assumption on $H_1$ and $H'_0$, we get a well-defined function $H''\\colon I\\times X\\to Y$, which is then continuous by the Exercise. It is a simple check to see it is a homotopy from $H_0$ to $H'_1$. \\\\\nFor the second part, let $c\\colon I\\to I$ be the function $c(t) = 1-t$. Then define $H''$ to be the composite $I\\times X \\xrightarrow{c\\times \\id_X} I \\times X \\xrightarrow{H}Y$, which has the required properties.\n\\end{proof}\n\nContractible spaces supply many homotopies.\n\n\\begin{lemma}\nEvery continuous function $f\\colon X\\to Y$, with $Y$ a contractible space (say to $y_0\\in Y$), is homotopic to a function with range contained in $\\{y_0\\}$.\n\\end{lemma}\n\n\\begin{proof}\nLet $H\\colon I\\times Y \\to Y$ be a homotopy witnessing the contractility of $Y$. Then the composite $I\\times X \\xrightarrow{\\id_I \\times f} I\\times Y \\xrightarrow{H} Y$ is a homotopy from $f$ to the the desired function.\n\\end{proof}\n\nAs a corollary, every pair of functions to a contractible space are homotopic.\nSince contractible spaces are in some sense trivial, maps to them are in the same sense trivial.\n\nAn important intermediate version of this is when we consider only the case where $X$ is discrete, or is even just $\\pt$:\n\n\\begin{definition}\nA space $Y$ is \\emph{path-connected}\\marginnote{This condition is equivalent to requiring \nit for \\emph{all} discrete spaces in place of $\\pt$ (Exercise!)} if every map $\\pt \\to Y$ is homotopic \nto every other such map.\n\\end{definition}\n\nUnpacking this, we see this means that for any two points $\\pt \\to Y$ there is a path \n$I\\to Y$ connecting them, i.e.\\ $H\\colon I \\simeq I \\times \\pt \\to Y$.\n\n\\begin{prop}\nA path-connected space is connected\n\\end{prop}\n\n\nLet us define $[X,Y] = \\{\\text{continuous }f\\colon X\\to Y\\}/\\text{homotopy}$. \nThe set of \\emph{path components} of $Y$ is then the set $[\\pt,Y]$. \n% If equipped with the final topology arising from the surjective function $Y\\to [\\pt,Y]$, we \n% denote the resulting topological space by $[\\pt,Y]^{top}$.\nThe space $Y$ is called \\emph{path connected} if $[\\pt,Y]=*$.\n\nWe have been discussing topological spaces and continuous maps, but also implicitly sets \nand functions, not necessarily continuous, and passing between these two pictures. In \nboth cases we have composition that is associative, and identity maps. Later we shall be \nusing different classes of topological spaces in order to ensure the behaviour we \nrequire will hold.\n\n\\begin{definition}\nA \\emph{category} $\\cC$ consists of a collection of \\emph{objects} $W,X,Y,Z,\\ldots$ and for each pair of objects $X,Y$ a collection of \\emph{morphisms}, denoted $\\cC(X,Y)$, together with the following data:\n\\begin{enumerate}[i)]\n\t\n\t\\item For each pair $f\\in \\cC(X,Y)$ and $g\\in \\cC(Y,Z)$, a specified morphism $g\\circ f\\in \\cC(X,Z)$,\n\n\t\\item For every object a specified morphism $\\id_X\\in\\cC(X,X)$,\n\n\\end{enumerate}\n\\noindent\nsuch that:\n\\begin{enumerate}\n\n\t\\item For every triple $h\\in \\cC(W,X)$, $f\\in \\cC(X,Y)$ and $g\\in \\cC(Y,Z)$ we have $g\\circ(f\\circ h) = (g\\circ f)\\circ h$,\n\n\t\\item For every object $X$ and $h\\in \\cC(W,X)$, $f\\in \\cC(X,Y)$ we have $\\id_X\\circ h = h$ and $f\\circ \\id_X = f$.\n\n\\end{enumerate}\nFor $f\\in \\cC(X,Y)$ we say $X$ is the \\emph{source} of $f$, $Y$ is the \\emph{target} of \n$f$, and write $X=s(f)$, $Y=t(f)$. We also write $f\\colon X\\to Y$ or $X\\xrightarrow{f} \nY$ to indicate that $f\\in \\cC(X,Y)$. If $\\cC(X,Y)$ is a set\\marginnote{Most categories \nyou will encounter are locally small} for all $X,Y$, then $\\cC$ is called \\emph{locally \nsmall}, and each $\\cC(X,Y)$ is called a \\emph{hom-set}.\n\\end{definition}\n\n\nMany examples of categories have objects sets carrying extra structure (for instance a \ntopology) and morphisms that are functions compatible with that structure---but not all \ncategories. We have seen $\\Top$, the category of topological spaces (and continuous \nmaps) and $\\Set$, the category of sets (and functions), and you implicitly already \nknow\\marginnote{Vector spaces, (abelian) groups, manifolds, rings, \\ldots}\n many other examples.\n\n\\begin{example}\nThe category $\\Set_*$ of pointed sets $(X,x)$ ($x\\in X$ a specified element) and pointed maps \n$(X,x) \\to (Y,y)$ (functions $f\\colon X\\to Y$ with $f(x) = y)$) can be considered as consisting\nof algebraic objects of the weakest sort (compare homomorphisms, linear transformations, ring \nmaps, etc, which preserve distinguised elements).\n\\end{example}\n\n\nThe whole point of categories is how they relate to each other, an isolated category can \nonly tell us so much.\n\n\\begin{definition}\nGiven categories $\\cC$ and $\\cD$, a \\emph{functor} from $\\cC$ to $\\cD$, denoted $F\\colon \\cC\\to \\cD$ consists of the data:\n\n\\begin{enumerate}[i)]\n\n\t\\item For every object $X$ of $\\cD$, a specified object $F(X)$ of $\\cD$,\n\n\t\\item For every morphism $f\\colon X\\to Y$ of $\\cC$, a specified morphism $F(f)\\colon F(X) \\to F(Y)$ of $\\cD$\n\n\\end{enumerate}\n\\noindent\nsuch that for every object $X$ of $\\cC$, $F(\\id_X)=\\id_{F(X)}$, and for every pair $f\\colon X\\to Y$ and $g\\colon Y\\to Z$ of morphisms of $\\cC$, $F(g\\circ f) = F(g)\\circ F(f)$. This latter property is called `functoriality'. For locally small categories, the assignment on morphisms gives a function $\\cC(X,Y) \\to \\cD(F(X),F(Y))$.\\marginnote{We will use this notation even without making that assumption}\n\\end{definition}\n\nWe have already see at least four examples of functors:\n\\begin{itemize}\n\n\t\\item The underlying set functor $U\\colon \\Top \\to \\Set$\n\t\\item The discrete topology functor $\\mathrm{disc}\\colon \\Set \\to \\Top$\\marginnote{the indiscrete topology also gives rise to a functor $\\Set \\to \\Top$, but we won't be using it}\n\t\\item The set of connected components functor $\\pi_0\\colon \\Top \\to \\Set$\n\n\\end{itemize}\n\n\\noindent\nalthough we haven't yet seen why $\\pi_0$ is a functor. We can compose functors in the \nobvious way, so get functors $\\mathrm{disc}U\\colon\\Top\\to \\Top$ and \n$\\mathrm{disc}\\pi_0\\colon\\Top\\to\\Top$, for instance.\n\nHere is a trivial-seeming example (aside from the identity functor).\n\nLet $\\cC$ be a category, and $\\cD$ a \\emph{subcategory}: a collection of some of the \nobjects of $\\cC$ and some of the morphisms of $\\cC$ that form a category by themselves. \nThen the inclusion of the objects and the morphisms forms a functor $\\cD\\into \\cC$, the \n\\emph{subcategory inclusion}. An important special case of this is when for every $X$ \nand $Y$ that are objects of $\\cD$, every $\\cD(X,Y) = \\cC(X,Y)$; then $\\cD$ is call a \n\\emph{full} subcategory. More generally we can consider a functor that is injective on \nobjects and morphisms to define a subcategory.\n\n\\begin{example}\nThe\\marginnote{we have used and will use this result without comment} functor \n$\\mathrm{disc}\\colon \\Set \\to \\Top$ makes $\\Set$ a full subcategory of $\\Top$.\n\\end{example}\n\nWe will be later restricting attention to certain full subcategories of $\\Top$.\n\n\\begin{lemma}\\label{lemma:image_of_connected}\nLet $X$ be a connected space, and let $f\\colon X\\to Y$ be a continuous function. \nThen $\\im(f) \\subset Y$ is connected.\n\\end{lemma}\n\n\\begin{proof}\nLet $S$ be a discrete space and let $g\\colon \\im(f)\\to S$ be a continuous function.\nThen the composite $X\\to \\im(f) \\to S$ has image $\\{s\\}\\subseteq S$, hence $\\im(g)=\\{s\\}$\nand so $\\im(f)$ is connected.\n\\end{proof}\n\n\\begin{prop}\nThe assignment $X\\mapsto \\pi_0(X)$ is a functor $\\Top \\to \\Set$.\n\\end{prop}\n\n\\begin{proof}\nWe need to show there is an assignment \n$(f\\colon X\\to Y)\\mapsto (\\pi_0(f)\\colon \\pi_0(X) \\to \\pi_0(Y))$, \nfor an arbitrary continuous function $f$. \nFix $f\\colon X\\to Y$ and let $\\alpha\\in \\pi_0(X)$. Then this corresponds to a connected\ncomponent $X_\\alpha \\subseteq X$, and we know $f\\big|_{X_\\alpha}$ has connected image.\nThus this image is contained inside a single connected component of $Y$, and we define\n$\\pi_0(f)(\\alpha)$ to be the corresponding element of $\\pi_0(Y)$.\n\nGiven another map $g\\colon Y\\to Z$, and the corresponding function \n$\\pi_0(g)\\colon \\pi_0(Y)\\to\\pi_0(Z)$, one can check that $\\pi_0(g)\\pi_0(f)(\\alpha)$, for \n$\\alpha\\in \\pi_0(X)$ is the same as $\\pi_0(g\\circ f)(\\alpha)$, and $\\pi_0(\\id)$ is also\nthe identity map. This proves that $\\pi_0$ is a functor $\\Top \\to \\Set$.\n\\end{proof}\n\nHere is a bonus second proof for locally connected spaces.\n\\begin{proof} \nWe already know we have a map $X\\to Y \\to \\pi_0(Y)$, where we give $\\pi_0(Y)$ the discrete\ntopology. This is continuous since $Y$ is \nlocally connected, and we want to show this \n\\emph{descends} along $X\\to \\pi_0(X)$ to a map $\\pi_0(X) \\to \\pi_0(Y)$. \nGiven any $\\alpha \\in \\pi_0(X)$, it corresponds to a \nconnected component $X_\\alpha$ of $X$. Look at the restriction of $X\\to Y\\to\\pi_0(Y)$ to \n$X_\\alpha$: since $X_\\alpha$ is connected, its image is exactly one point in $\\pi_0(Y)$. \nSo define $\\pi_0(f)(\\alpha)=[f(x)]$ for an arbitrary $x\\in X_\\alpha$.\nThis defines $\\pi_0(f)$. Moreover, the following diagram \\emph{commutes}:\n\\[\n\t\\xymatrix{\n\t\tX\\ar[r]^f \\ar[d] & Y \\ar[d]\\\\\n\t\t\\pi_0(X) \\ar[r]_{\\pi_0(f)} & \\pi_0(Y) \n\t}\n\\]\nSince the discrete topology on $\\pi_0(X)$ is the same as the quotient topology, this is\na map between discrete spaces, hence continuous, but we are thinking of it as a map between \nsets.\n\nNow we want to show that $\\pi_0(g\\circ f) = \\pi_0(g)\\circ \\pi_0(f)$. Given $\\alpha \\in \n\\pi_0(X)$, and $x\\in X_\\alpha$, then $\\pi_0(f)(\\alpha) = [f(x)]$. To define \n$\\pi_0(g)\\left(\\pi_0(f)(\\alpha)\\right)$, we need to choose a point in the component \n$Y_{[f(x)]}$, so take it to be $f(x)$. Then $\\pi_0(g)\\left(\\pi_0(f)(\\alpha)\\right) = \n[g(f(x))]$, but this is just $\\pi_0(g\\circ f)(\\alpha)$.\n\\end{proof}\n\n\\begin{ex}\nShow that $[\\pt,-]\\colon \\Top \\to \\Set$ is a functor.\\marginnote{Or more generally, \n$[X,-]\\colon \\Top\\to \\Set$!}\n\\end{ex}\n\nAnother important example of a category is the \\emph{homotopy category} $\\Ho$. \n\\marginnote{Exercise: prove this is a category} The objects are topological spaces, but \n$\\Ho(X,Y) = [X,Y]$. There is a functor $\\Top \\to \\Ho$, which is the identity on objects, \nand sends a map to its homotopy class. Objects are isomorphic in $\\Ho$ iff they are \nhomotopy equivalent.\n\n\\begin{prop}\nThe\\lecturenum{4} functor $\\pi_0$ descends to a functor $\\Ho \\to \\Set$\n\\end{prop}\n\n\\begin{proof}\nWe will prove that this is well-defined on morphism on hom-sets, the rest is routine. \nFor $f,g\\colon X\\to Y$ to be homotopic via $H\\colon I\\times X\\to Y$, we need to show that for all $\\alpha \\in \\pi_0(X)$, $\\pi_0(f)(\\alpha) = \\pi_0(g)(\\alpha)$. \nTake $x$ in the connected component $X_\\alpha$, then we have a map $I \\to I \\times X \\xrightarrow{H} Y$, namely a path \n$f(x) \\rightsquigarrow g(x)$. \nBut $I$ is connected, so the image of the path is connected, so that $f(x)$ and $g(x)$ are in the same connected component. As $x$ was arbitrary $f(X_\\alpha)$ and $g(X_\\alpha)$ are both contained in the same connected component\nof $Y$. Thus $\\pi_0(f)(\\alpha)=\\pi_0(g)(\\alpha)$.\n\\end{proof}\n\nAs a result, if $\\pi_0(X) \\not\\simeq \\pi_0(Y)$, the spaces $X$ and $Y$ cannot be homotopy equivalent, let alone homeomorphic.\n\n\\begin{ex}\nShow the functor $[\\pt,-]\\colon \\Top\\to \\Set$ descends to $\\Ho\\to\\Set$.\n\\end{ex}\n\nHere is a useful fact about spaces.\n\n\\begin{lemma}\\label{lemma:pi0s_preserve_coprods}\nFor all families $X_\\beta$, $\\beta\\in J$, of spaces, we have isomorphisms\n\\[\n\t\\bigsqcup_{\\beta\\in J} \\pi_0(X_\\beta) \\xrightarrow{\\simeq}\n\t\\pi_0(\\bigsqcup_{\\beta\\in J} X_\\beta)\n\t\\quad\\text{and}\\quad\n\t\\bigsqcup_{\\beta\\in J} [\\pt,X_\\beta] \\xrightarrow{\\simeq}\n\t[\\pt,\\bigsqcup_{\\beta\\in J} X_\\beta],\n\\]\nwith inverses induced by the family of maps $\\mathrm{in}_\\beta$. \nThat is, $\\pi_0$ and $[\\pt,-]$ \\emph{preserve coproducts}.\n\\end{lemma}\n\n\n\nRecall last time:\\marginnote{$\\xymatrix{\\Top\\ar[d] \\ar[r]^{\\pi_0}&\\Set\\\\ \\Ho\\ar[ur]_{\\pi_0}}$} \nwe had functors $\\pi_0\\colon \\Top\\to \\Set$ and (abusing notation) $\\pi_0\\colon \\Ho\\to \\Set$.\n\n\\begin{example}\nIf $X$ and $Y$ are spaces with $|\\pi_0(X)|< |\\pi_0(Y)|$, no continuous map $X\\to Y$ is \nsurjective.\n\\end{example}\n\nHere is an instructive example\n\n\\begin{example}\n\nThe \\emph{topologist's sine curve} is the image $C$ of $[-1,1]\\sqcup (0,1]\\to \\RR^2$ defined by\n\\[\\begin{cases}\n\ty \\mapsto (0,y) & y\\in [-1,1]\\\\\n\tx \\mapsto (x,\\sin(\\tfrac{1}{x})) & x\\in (0,1]\n\\end{cases}\\]\nequipped with the \\textbf{subspace topology}. This is a compact metric space, using the \ninherited Euclidean metric. Fact: \\emph{every} continuous function $f\\colon C\\to \\{0,1\\}$ is constant.\nIf $f(1,\\sin(1))=1$, then $f(x,\\sin(x))=1$ for every $x\\in (0,1]$ (as intervals are connected).\nIf $f(0,0)=b \\in \\{0,1\\}$, then $f(0,y) = b$ also, for all $y\\in [-1,1]$.\nThe sequence $(\\frac{1}{n\\pi},0)$ converges to $(0,0)$ in $C$, so \n$b = f(0,0) = \\lim_{n\\to\\infty} f(\\frac{1}{n\\pi},0) = 1$ as $f$ is continuous and we are in a metric space.\n\nHence $C$ is connected, but there is \\emph{no}\\marginnote{Exercise: prove this by considering \n$\\lim_{n\\to\\infty}\\gamma(\\frac{1}{n})$} continuous function $\\gamma\\colon [0,1]\\to C$ with \n$\\gamma(0)=(0,0)$ and $\\gamma(1) = (1,\\sin(1))$. Since intervals are path connected, we can \nshow $[\\pt,C]=\\{0,1\\}$, but $\\pi_0(C)=*$.\n\\end{example}\n\nSo we have two different invariants here, and there is always a surjective map \n$[\\pt,X]\\to \\pi_0(X)$. Moreover, the following square of functions between sets always commutes, \nfor any map $X\\xrightarrow{f}Y$:\n\\[\n\\xymatrix{\n\t[\\pt,X] \\ar[r]^{[\\pt,f]} \\ar[d] & [\\pt,Y]\\ar[d]\\\\\n\t\\pi_0(X) \\ar[r]_{\\pi_0(f)} & \\pi_0(Y) \n}\n\\]\nThis is thus an example of a \\emph{natural transformation}.\n\n\\begin{definition}\nGiven functors $F,G\\colon \\cC \\to \\cD$, a natural transformation $\\alpha\\colon F\\Rightarrow G$\nconsists of the data:\n\\begin{enumerate}[i)]\n\t\\item For every object $X$ of $\\cC$, a specified morphism \n\t\t$\\alpha_X\\colon F(X) \\to G(X)$ (the \\emph{components} of $\\alpha$)\n\\end{enumerate}\nsuch that for every morphism $f\\colon X\\to Y$ in $\\cC$, the following square commutes:\n\\[\n\\xymatrix{\n\tF(X) \\ar[r]^{F(f)} \\ar[d]_{\\alpha_X} & F(Y)\\ar[d]^{\\alpha_Y}\\\\\n\tG(X) \\ar[r]_{G(f)} & F(Y) \n}\n\\]\nA natural transformation is called a \\emph{natural isomorphism} if all of its components are \nisomorphisms.\n\\end{definition}\n\nFor example, there are natural transformations \n$\\mathrm{disc}\\;U \\Rightarrow \\id\\colon \\Top \\to \\Top$, \nwith component at $X$ the identity map $\\mathrm{disc}(U(X)) \\to X$, and \n$U\\Rightarrow \\pi_0\\colon \\Top \\to \\Top$, with component $U(X)\\to \\pi_0(X)$.\n\nWe seek conditions that will define a full subcategory of $\\Top$ such that the components\n$[\\pt,X] \\to \\pi_0(X)$ of the natural transformation $[\\pt,-]\\Rightarrow \\pi_0$ \nare isomorphisms for all spaces $X$ in the subcategory.\n\n\\begin{definition}\nA space $X$ is \\emph{semilocally path connected} (slpc) if it has a neighbourhood base of sets $N$ such that for any two $x,y\\in N$, there is a path in $X$ from $x$ to $y$.\n\\end{definition}\n\nNote that a space is slpc iff every connected component is slpc, and if $X$ is homeomorphic to $Y$, \nand one of them is slpc, then so is the other.\n\n\\begin{prop}\nIf $X$ is a semilocally path connected space, then $[\\pt,X]\\to \\pi_0(X)$ is \nan isomorphism.\n\\end{prop}\n\n\\begin{proof}\nWe are reduced to the case $X$ is connected ($\\pi_0(X) = *$) and slpc, by Lemma~\\ref{lemma:pi0s_preserve_coprods}, \nand the fact the case $X=\\emptyset$ is trivial.\nSince $X$ is connected, take $x\\in X$ and define $\\chi\\colon X\\to \\{0,1\\}$ by\n\\[\n\t\\chi(y) = \\begin{cases}\n\t\t\t1 & \\exists y \\rightsquigarrow x \\\\\n\t\t\t0 & \\text{otherwise}\n\t\t\\end{cases}\n\\]\nwhere by $y\\rightsquigarrow x$ I mean a path $\\gamma\\colon I\\to X$ with $\\gamma(0)=y$ and $\\gamma(1)=x$.\nWe will show $\\chi$ is continuous. Note that $\\chi$ continuous $\\Leftrightarrow$ $p^{-1}(0)$ and $p^{-1}(1)$ open $\\Leftrightarrow$ $p^{-1}(1)$ open and closed. But $p^{-1}(1)=:C_x$ is the path component containing $x$.\nTake $y\\in C_x$ (so $\\exists y\\rightsquigarrow x$), and $V\\ni y$ a path-connected nhd. Given $z\\in V$, $\\exists z\\rightsquigarrow y$. Concatenate these paths to give\n$z\\rightsquigarrow x$, so that $z\\in C_x$. This is true for all $z\\in V$, so that $V\\subseteq C_x$, hence $C_x$ contains a neighbourhood of each of its points, and so is open.\n\nConversely, take $y\\in \\overline{C_x}$, $V\\ni y$ a path connected nhd. As $\\exists z\\in V\\cap C_x \\subseteq V$,\n$\\exists z\\rightsquigarrow y$. But also have $V\\cap C_x \\subseteq C_x$, so $\\exists z\\rightsquigarrow x$. Concatenate paths to get $y\\rightsquigarrow x$, so that $y\\in C_x$.\nThis is true for all $y\\in \\overline{C_x}$, so $\\overline{C_x} \\subseteq C_x$ and $C_x$ is closed. Hence $\\chi$ is continuous.\n\nBut $X$ is connected, and $\\chi(x) = 1$, so that $\\im\\chi=\\{1\\}$, and so $C_x = \\chi^{-1}(1) = X$. \nThus $[\\pt,X] \\to \\pi_0(X) = *$ is an isomorphism.\n\\end{proof}\n\nSo we will consider for the rest of this section of the course only slpc spaces, which form a full \nsubcategory $\\slpcTop \\hookrightarrow \\Top$.\nNote that discrete spaces are slpc, so $\\Set \\hookrightarrow \\slpcTop$ is a subcategory.\n\n\\begin{example}\nAny path-connected space $X$ is slpc, since for any nhd $N$ and points $x,y\\in N$, we know there is a\npath $I\\to X$ between $x$ and $y$.\n\\end{example}\n\n\\begin{ex}\nShow that the product of two slpc spaces is slpc, and that any locally convex topological vector space is slpc.\n\\end{ex}\n\n\\begin{example}\nAny manifold is slpc, since every point lives in a chart homeomorphic to some $\\RR^n$, and $\\RR^n$ is path-connected.\n\\end{example}\n\nBe warned: subspaces of slpc spaces may not be slpc, for instance the topologist's sine curve is a subspace of the contractible $\\RR^2$.\n\n\\begin{q}\nIf $X$ is slpc and $q\\colon X\\to Y$ is a quotient map,\\marginnote{so $Y$ has the final topology wrt $q$}\n then is $Y$ slpc?\n\\end{q}\n\n%Here is a condition that can be used to transfer slpc-ness.\n\n%\\begin{definition}\n%A \\emph{local homeomorphism} $X\\xrightarrow{p} Y$ is a map of spaces such that for all $x\\in X$ there is basis of nhds $U$ of $x$ such that for each such $U$\n%$\\exists$ $V$ a nhd of $p(x)$ such that $p\\big|_U\\colon U \\xrightarrow{\\sim}V$.\n%\\end{definition}\n\n%Examples include:\\marginnote{A trivial example is the inclusion of an open subspace}\n% maps $\\sqcup U_\\alpha \\to X$ induced by open an open cover $\\{U_\\alpha\\}$ of $X$, \n%the exponential map $\\exp\\colon \\CC \\to \\CC^\\times$, the $n^\\text{th}$-power map $U(1) \\xrightarrow{(-)^n} U(1)$\n%and the projection $S\\times X\\to X$ for $S$ discrete.\n\n%\\begin{lemma}\n%If $X\\xrightarrow{p}Y$ is a local homeomorphism, then $Y$ lpc implies  $X$ is lpc. If $p$ is surjective\n%then $X$ lpc implies $Y$ lpc. [[TRUE FOR SLPC??]]\n%\\end{lemma}\n\nOne last technical point\n\n\\begin{definition}\nA \\emph{pointed space} is a pair $(X,x)$ where $X$ is a topological space and $x\\in X$. \nA pointed map is a pointed map between the underlying pointed sets that is continuous.\nThese define a category $\\Top_*$.\n\\end{definition}\n\nA \\emph{pointed homotopy} of pointed map $I\\times X\\to Y$, for $(X,x_0)$ and $(Y,y_0)$ pointed spaces, is required \nto satisfy $H(t,x_0) =y_0$ for all $t\\in I$.\nPointed homotopy classes of pointed map are denoted $[(X,x_0),(Y,y_0)]_*$.\nThe category $\\Ho_*$ is defined analogously to $\\Ho$. \nWe get a functor $\\pi_0\\colon \\Ho_* \\to\\Set_*$. \n\n\\section{Covering spaces}\n\nSometimes when we are thinking about a particular space $X$, we need to construct other spaces \nrelated to $X$ to study objects of interest.\n\n\\begin{example}\nTake $X = \\CC^\\times :=\\CC \\setminus \\{0\\}$. Then the function $x\\mapsto\\sqrt{x}$ is\nnot well-defined, and if we take a branch cut to give an actual function, it is not continuous on $X$.\nEven worse, if have a continuous function $f\\colon \\CC^\\times \\to \\CC$, we may or may not have $x\\mapsto f(\\sqrt{x})$ continuous.\nHowever, we \\emph{do} get a continuous function if we change the domain somewhat. \nThe problem is that the function $Z :=\\CC^\\times \\ni z\\mapsto z^2 = x \\in \\CC^\\times$ is not injective, so not invertible.\nBut if we are willing to take the domain to be $Z$, and so pass into $f$ the argument $z$ (which satisfies $z^2 = x$)\nthen we are now just dealing with a continuous function.\nIf $f$ is such that $f(z) = f(-z)$ for all $z\\in Z$, then we get a well-defined function on $X$.\n\\end{example}\n\nThe properties of the map $z\\mapsto z^2$ (at least away from $0$) and others like $z^n$, $\\exp(z)$, rational functions away from poles and critical points and so on, lead to the notion of \ncovering spaces of certain domains in $\\CC$. We have a general definition for arbitrary spaces.\n\n\n%Given a local homeomorphism $X\\xrightarrow{p}Y$, the \\emph{fibre} $p^{-1}(y)\\subset X$ over $y$ has the discrete topology for every $y\\in Y$.\n%We have no idea how $p^{-1}(\\gamma(t))$ varies along a path $\\gamma \\colon I\\to Y$. \n%For example, given an arbitrary collection $B(x_\\alpha,r_\\alpha)\\subset \\RR^2$ of open balls,\n%$\\sqcup_\\alpha B(x_\\alpha,r_\\alpha) \\to \\RR^2$ is a local homeomorphism, but the fibres can\n%jump in size arbitrarily.\n%We would like fibres `close' to a given $p^{-1}(y)$ to `vary continuously'. For spaces `vary continuously' really means homotopy equivalence.\n%But for discrete spaces, homotopy equivalence is isomorphism.\n\n\\begin{definition}\nA\\marginnote{%\n\\[\n\\xymatrix{\\pi^{-1}(V_x) \\ar[r]^-\\simeq \\ar[d]_{\\pi} & V_x \\times \\pi^{-1}(x)\\ar[dl]^{\\pr_1}\\\\V_x}\n\\]\n}\n\\emph{covering space} $Z\\xrightarrow{\\pi} X$ of $X$ is a space $Z$ equipped with a map \n$\\pi$ such that for all $x\\in X$ there is a nhd $V_x \\ni x$ such that $\\pi^{-1}(V_x) \n\\simeq V_x \\times \\pi^{-1}(x)$ \\emph{over} $V_x$ (ie the diagram at right commutes), where \n$\\pi^{-1}(x)$ has the discrete topology.\\marginnote{NB: $V_x \\times \\pi^{-1}(x)\\simeq \\bigsqcup_{\\pi^{-1}(x)}V_x$, for free}\n(We will also call $\\pi$ itself a \n\\emph{covering map}.)\n\\end{definition}\n\nFor a covering space $Z\\xrightarrow{\\pi}X$ and $x\\in X$, let $Z_x :=\\pi^{-1}(x)$ denotes the\n\\emph{fibre} over $x$.\nWe will also call $X$ the \\emph{base space}.\n\nExamples include: $\\exp\\colon \\CC \\to \\CC^\\times$, $S^2 \\to \\RR\\mathbb{P}^2$, \n$U(1) \\xrightarrow{(-)^n} U(1)$, covers of the join $\\infty$ of two circles.\n\n\\begin{ex}\nShow that if $Z\\xrightarrow{\\pi} Y$ is a covering map, and $Y\\xrightarrow{\\rho} X$ is a \ncovering map with finite fibres (that is: $Y_x$ is finite for all $x\\in X$), \nthen $Z\\xrightarrow{\\rho\\pi} X$ is a covering map.\n\\end{ex}\n\n\n\\begin{prop}\\label{prop:iso_fibres_of_cov_sp}\nFor a covering space $Z\\xrightarrow{\\pi}X$, if $\\exists x_0 \\rightsquigarrow x_1$, then $Z_{x_0} \\simeq Z_{x_1}$.\n\\end{prop}\n\n\\lecturenum{5}\n\n\\begin{proof}\n(First proof of Proposition~\\ref{prop:iso_fibres_of_cov_sp}) Take $\\gamma \\colon I \\to \nX$, $\\gamma(i) = x_i$, and an open cover $\\{U_\\alpha\\}$ of $X$ over which $Z$ \ntrivialises. We thus get an open cover $\\gamma^{-1}(U_\\alpha)$ of $I$, which has a \nfinite subcover $U_0,\\ldots, U_N$, with $x_0 \\in U_0$, $x_1 \\in U_N$. The ordering is \nchosen\\marginnote{we can shrink the cover slightly to make this ordering well-defined, \nif need be} so that the path enters $U_i$ before it enters $U_{i+1}$, and $U_i\\cap \nU_{i+1}$ has at least one point of the path in it.\n\nWe have isomorphisms $Z_{U_i} := \\pi^{-1}(U_i) \\xrightarrow{\\phi_i} U_i \\times F_i$ with \ndiscrete spaces $F_i$. We have $Z_{x_0} \\simeq F_0$, and for all $t\\in \n\\gamma^{-1}(U_0)$, $Z_{\\gamma(t)} \\simeq F_0$. So for $\\gamma(t) \\in U_0\\cap U_1$, we \nhave $F_0 \\simeq Z_{\\gamma(t)} \\simeq F_1$. We can then prove by induction on $N$ that \n$F_0 \\simeq F_1 \\simeq \\cdots \\simeq F_N$.\n\\end{proof}\n\nSo for slpc $X$ and each $\\alpha \\in \\pi_0(X)$, there is associated to $Z\\xrightarrow{\\pi}X$ \nan isomorphism class of sets, the \\emph{typical fibre} over all $x$ in the connected component \n$X_\\alpha\\subseteq X$.\n\n\\textbf{Note:} Fibres can be empty! But we usually don't think about this case too much. For \n$X$ pointed (by $x\\in X$), we can consider pointed covering spaces $(Z,x) \\to (X,x)$.\nThis is from one perspective just a choice of point $z\\in Z_x$. For $X$ connected and slpc, \na pointed covering space has every fibre contain at least one point, namely the image of $z$ under\n$Z_x \\simeq Z_{x'}$.\n\nWe have categories $\\Cov_X$ and $\\Cov_{(X,x)}$ with objects covering spaces of $X$ \n(resp.\\ pointed covering spaces of $(X,x)$) and maps\n\\[\n\\xymatrix{Z_1 \\ar[rr] \\ar[dr] && Z_2\\ar[dl]\\\\& X}\n\\]\nand analogously in the pointed case. We will study these categories and see what they \ntell us about the topology of $X$.\n\n\\begin{example}\nFor $X = \\CC \\setminus \\{p_1,\\ldots,p_n\\}$, the study of $\\Cov_X$ tells us about possible\nRiemann surfaces for holomorphic functions with critical values precisely $p_1,\\ldots , p_n$.\n\\end{example}\n\nFor slpc and connected $X$, the fact that for a covering space $Z$ of $X$, \nthere merely \\emph{exists} some $Z_{x_0} \\simeq Z_{x_1}$ \nfor arbitrary $x_0,x_1\\in X$ can be improved. We first need a construction on covering spaces.\n\n\\begin{definition}\\label{def:pullback_of_cov_sp}\nGiven a covering space $Z\\xrightarrow{\\pi} X$ and a map $Y\\xrightarrow{f} X$, the \\emph{pullback} \nof $Z$\\marginnote{actually $\\pi$ doesn't have to a covering map; the space $Y\\times_X Z$ is defined for any pair of maps to $X$} is the subspace \n\\[\nf^*Z := Y\\times_X Z = \\{ (y,z)\\in Y\\times Z \\mid f(y) = \\pi(z)\\}\\subseteq Y\\times Z.\n\\]\n It fits in a commutative square\n\\[\n\\xymatrix{\nf^*Z \\ar[d]_{p} \\ar[r]^{\\pr_2} & Z \\ar[d]^\\pi \\\\\nY \\ar[r]_f & X\n}\n\\]\n\\end{definition}\n\n\\begin{prop}\nIn the setting of Definition~\\ref{def:pullback_of_cov_sp}:\n\\begin{enumerate}\n\\item $f^*Z\\to Y$ is a covering space.\\marginnote{Of these, only 1.\\ relies on having a covering space to start with, 2.\\ and 3.\\ are general facts about pullbacks, where for 2.\\ we replace $\\Cov_X$ by the \\emph{slice category} $\\Top/X$, whose objects are maps to $X$, and morphisms are commuting triangles}\n\\item $f^*$ is a functor $\\Cov_X \\to \\Cov_Y$.\n\\item Given $Y_2 \\xrightarrow{g} Y_1 \\xrightarrow{f} X$ and $Z\\xrightarrow{\\pi} X$, there is \na canonical isomorphism $(f\\circ g)^*Z \\simeq g^*f^*Z$ in $\\Cov_{Y_2}$.\n\\end{enumerate}\n\\end{prop}\n\n\\begin{corollary}\nThe fibre $(f^*Z)_y$ is canonically isomorphic to $Z_{f(y)}$.\n\\end{corollary}\n\nNow given a path $\\gamma\\colon I \\to X$ and a covering space $Z\\xrightarrow{\\pi}X$, we can \npull back $Z$ to get a covering space $\\gamma^*Z \\to I$.\nSo let us try to understand covering spaces of $I$. \nCertainly for discrete $S$, the projection $S\\times I \\to I$ is a covering space.\n\n\n\\begin{prop}\\label{prop:covering_sp_of_interval_triv}\nA covering space $Z\\xrightarrow{\\pi} I$ is isomorphic to the trivial covering space $\\pi^{-1}(0) \\times I \\xrightarrow{\\pr_2} I$ \nin $\\Cov_I$.\n\\end{prop}\n\nWe first need a little helper lemma\n\n\\begin{lemma}\nA covering space of a compact space $X$ trivialises\\marginnote{might as well take the nhds to be open, and then consider a finite subcover} over a \\emph{finite} cover of $X$ by nhds.\n\\end{lemma}\n\n\\begin{proof}(of Proposition~\\ref{prop:covering_sp_of_interval_triv})\nWe use the lemma to trivialise $Z\\to I$ over a finite cover of $I$, \nwhich we can take to be by intervals $[0,t_1]$, $[s_2,t_2]$, \\ldots, $[s_N,1]$ \nfor $s_1=0<s_2<t_1<s_3<t_2<\\cdots<s_N <t_{N-1} <1=t_N$.\nWe will proceed by induction on $N$, but this quickly reduces to the case of $N=2$.\nSo take a cover of $I$ by $[0,t]$ and $[s,1]$, where $\\tau\\colon Z_0 \\times [0,t] \\xrightarrow{\\simeq}Z_{[0,t]}$ \nand we are given $\\sigma\\colon F\\times [s,1]\\xrightarrow{\\simeq} Z_{[s,1]}$.\\marginnote{we know abstractly that $F\\simeq Z_0$, but this \nproof will construct an isomorphism}\n\nBy restriction there is the composite map\n\\[\nZ_0\\times [s,t] \\underset{\\simeq}{\\xrightarrow{\\tau|_{[s,t]}}} Z_{[s,t]} \n\\underset{\\simeq}{\\xrightarrow{\\sigma^{-1}|_{[s,t]}}} F\\times [s,t] \\xrightarrow{\\pr_1} F.\n\\]\nIf we fix $z\\in Z_0$, we get a continuous map $\\{z\\}\\times [s,t] \\to F$, which is thus \nconstant, say at $p_z\\in F$. The function $z\\mapsto p_z = \\sigma^{-1}(\\tau(z,s))$ is \nthen a bijection $\\phi\\colon Z_0 \\xrightarrow{\\simeq} F$.\n\nWe thus get maps $Z_0\\times [0,t] \\hookrightarrow Z \\hookleftarrow F\\times [s,1] \n\\xleftarrow{\\phi\\times \\id} Z_0\\times [s,1]$, which by construction agree on $Z_0\\times \n[s,t]$. There is thus a continuous map $Z_0 \\times [0,1] \\to Z$. Moreover, you can check \nthis map is a morphism of $\\Cov_I$. There are likewise maps\n\\[\nZ_{[0,t]}\\xrightarrow{\\simeq} Z_0\\times [0,t] \\hookrightarrow Z_0\\times I \n\\hookleftarrow Z_0\\times [s,1] \\xleftarrow{\\phi^{-1}\\times \\id} F\\times [s,1] \n\\xleftarrow{\\simeq} Z_{[s,1]}\n\\]\nwhich agree on $Z_{[s,t]}$, hence a continuous map $Z\\to Z_0\\times I$. \nThis map is in $\\Cov_I$ and can be checked by pointwise evaluation to be inverse to the \nfirst one.\nHence we have an isomorphism $Z\\simeq Z_0\\times I$ in $\\Cov_I$.\n\\end{proof}\n\n%The isomorphism the proof constructs is even unqiue if we assume the isomorphism $\\tau$ is the identity on $Z_0$.\n\n\\begin{corollary}\nGiven a covering space $Z\\xrightarrow{\\pi}I$ and a point $z\\in Z_0$, there is a unique path\n$\\eta_z\\colon I \\to Z$ with $\\eta_z(0)=z$ such that $\\pi\\circ \\eta_z = \\id$ (i.e.\\ $\\eta_z$ is a section of $\\pi$).\n\\end{corollary}\n\n\\begin{proof}\nWe can construct \\emph{a} path, given $\\tau\\colon Z_0 \\times I \\xrightarrow{\\simeq} Z$, by $\\eta(t) = \\tau(z,t)$. Since $\\pi\\circ\\tau = \\pr_2$, this has the required property.\nConnectedness of $I$ and discreteness of $Z_0$ implies that given any other path $\\eta'\\colon I \\to Z$ with $\\eta'(0) = z$ and $\\pi\\circ \\eta'=\\id$, we must have $\\tau^{-1}\\circ \\eta = \\tau^{-1}\\circ \\eta'\\colon I\\to Z_0\\times I$ which implies $\\eta'=\\eta$.\n\\end{proof}\n\nAnd now we have a really important property of covering spaces\n\n\\begin{theorem}\\label{prop:unique_path_lifting}\nGiven any covering space $Z\\xrightarrow{\\pi}X$, path $\\gamma\\colon I\\to X$ and point $z\\in Z_{\\gamma(0)}$, \nthere is a unique lift $\\widetilde{\\gamma_z}\\colon I\\to Z$\\marginnote{a \\emph{lift} of a path $\\gamma\\colon I\\to X$ is a path $\\widetilde{\\gamma}\\colon I \\to Z$ with $\\pi\\widetilde{\\gamma}=\\gamma$}  with $\\widetilde{\\gamma_z}(0)=z$.\n\\end{theorem}\n\n\\begin{proof}\nWe can pull back $Z$ to get $p\\colon \\gamma^*Z\\to I$. We have unique $\\eta_z\\colon I\\to \\gamma^*Z$\nso that $\\eta_{(0,z)}(0) = (0,z)$. Define $\\widetilde{\\gamma_z} = \\pr_2\\circ \\eta_{(0,z)}\\colon I \\to Z$.\nThis path satisfies $\\pi\\circ\\widetilde{\\gamma_z} = \\gamma\\circ p\\circ\\eta_{(0,z)} = \\gamma$.\nGiven any other lift $\\lambda\\colon I\\to Z$, we get a second section of $p$ by $t\\mapsto (t,\\lambda(t))$, which by uniqueness of $\\eta_{(0,z)}$ has to be equal to it, so that $\\lambda = \\widetilde{\\gamma_z}$.\n\\end{proof}\n\nWe can then give a second, more explicit proof of Proposition~\\ref{prop:iso_fibres_of_cov_sp}.\n\n\\begin{corollary}\nA path $\\gamma\\colon I\\to X$ defines a bijection \n$\\gamma_*\\colon Z_{\\gamma(0)} \\xrightarrow{\\simeq} Z_{\\gamma(1)}$, by \n$\\gamma_*(z) = \\widetilde{\\gamma_z}(1)$.\n\\end{corollary}\n\n\\begin{proof}\nWe only have to start with that $\\gamma_*$ is a function $Z_{\\gamma(0)} \\to \nZ_{\\gamma(1)}$, but the function $(-\\gamma)_*\\colon Z_{\\gamma(1)} \\to Z_{\\gamma(0)}$, \nwhere $-\\gamma\\colon I \\to X$ is the path $-\\gamma(x) = \\gamma(1-x)$, is inverse to \n$\\gamma_*$. This is because the path $-\\widetilde{\\gamma_z}$ is a lift of $-\\gamma$, \nhence $(-\\gamma)_*(\\gamma_*(z)) = \\widetilde{(-\\gamma)_{\\gamma_*(z)}}(1) = \n\\widetilde{\\gamma_z}(0) = z$. A symmetric argument shows that \n$\\gamma_*\\left((-\\gamma)_*(z)\\right)=z$ for $z\\in Z_{\\gamma(1)}$.\n\\end{proof}\n\nA first observation is that this bijection is invariant\\marginnote{consider \n$\\psi$ as a path in $I$ and see what happens in that case} under reparameterisations of $\\gamma$:\ngiven $\\psi\\colon I\\xrightarrow{\\simeq} I$ with $\\psi(0)=0$ and $\\psi(1)=1$, then clearly \n$(\\gamma\\circ \\psi)_*=\\gamma_*\\colon Z_{\\gamma(0)} \\to Z_{\\gamma(1)}$.\n\nEven\\lecturenum{6} better, we get a function \n\\[\n\\{\\text{paths }x_0 \\rightsquigarrow x_1\\text{ in }X\\} \\times Z_{x_0} \\to Z_{x_1}\n\\]\nIf\\marginnote{we can take quotient by reparametrisations if desired, in each of these functions} we take $x_0 = x_1 = x$, then this is a map\n\\[\n\\{\\text{loops }x \\rightsquigarrow x\\text{ in }X\\} \\times Z_x \\to Z_x\n\\]\nsuch that each loop $x\\rightsquigarrow x$ gives a bijection $Z_x\\to Z_x$. So we can think of this instead as \n\\[\n\\{\\text{loops }x \\rightsquigarrow x\\text{ in }X\\} \\to \\Aut(Z_x).\n\\]\nAlternatively, if we have a pointed covering space $(Z,z) \\to (X,x)$, we have a canonical function\n\\begin{equation}\\label{eq:loops_to_fibre}\n\\{\\text{loops }x \\rightsquigarrow x\\text{ in }X\\} \\to Z_x\n\\end{equation}\n\n\\begin{example}\nFor $Z = S\\times X$, $(\\gamma)_* = \\id_S$ always, and the image of (\\ref{eq:loops_to_fibre}) \n(given some $(s,x)\\in Z$) is just a single point. For instance, if $X=I$, we have seen this \nwill be the case for every covering space.\nBut for $X=S^1$, $Z=\\RR \\xrightarrow{\\exp} S^1$, and taking \n$x=1\\in S^1$, $z = 0\\in \\RR$, then $Z_1 = \\exp^{-1}(0) = 2\\pi i \\ZZ$, then \n\\[\n\t\\{\\gamma\\colon I\\to S^1\\mid \\gamma(0) = \\gamma(1) = 1\\} \\to 2\\pi i \\ZZ\n\\]\nis \\emph{onto}. The path $\\widetilde{\\gamma}_n = 2\\pi inx$ lifts the path \n$\\gamma(x) = \\exp(2\\pi inx)$,\nand $\\widetilde{\\gamma}_n(0) = 0$, $\\widetilde{\\gamma}_n(1) = 2\\pi inx$. \nThe difference is that $\\RR$ is path connected, but $X\\times S$ is not, for $|S| > 1$. \n\\end{example}\n\nIn fact, for a covering space $(Z,z)\\xrightarrow{\\pi} (X,x)$ with $Z$ path connected \nand $z'\\in Z_x$, there is $\\widetilde{\\gamma}\\colon I\\to Z$ with $\\widetilde{\\gamma}(0)=z$, \n$\\widetilde{\\gamma}(1)=z'$. Since $\\widetilde{\\gamma}$ lifts $\\gamma = \\pi\\circ \\widetilde{\\gamma}$, \nwhich satsfies $\\gamma(0) = x = \\gamma(1)$, the map (\\ref{eq:loops_to_fibre}) is \\textbf{onto}.\nThus paths constrain the sizes of fibres of connected covering spaces and vice versa. \nNotice also that the set of loops is independent of the choice of covering space!\n\nMore generally, given points $z_\\alpha$ in $Z_x$,\\marginnote{that is: a section of $Z\\to [\\pt,Z]$} one per path component of $Z$,\\label{eq:fibre_quotient_of_loops}\n\\[\n\\{\\text{loops }x \\rightsquigarrow x\\text{ in }X\\}\\times [\\pt,Z] \\simeq \\{\\text{loops }x \\rightsquigarrow x\\text{ in }X\\}\\times\\{z_\\alpha\\} \\to Z_x\n\\]\nis always onto. There are a huge number of paths, and reparameterisations cuts things down somewhat. \nBut we shall go even better, and put a topology on the space of paths.\n\n\nThe fibres $Z_x$ of a covering space $Z$ are discrete spaces, but the set \n$\\Top(I,X)$ of paths $I\\to X$ carries a topology when $X$ is a metric space; we can \nconsider $C(I,X)$ with the sup metric $d_\\infty$. The aim is to give $\\Top(I,X)$ a \ntopology for \\emph{any} space, not necessarily metric.\n\n\\begin{lemma}\\label{lemma:compact_open_base}\nLet $X$ be a topological space, fix $\\gamma\\in \\Top(I,X)$ a path. Let \n$0=t_0 < t_1 < \\cdots < t_n < t_{n+1} = 1$ be a partition of $[0,1]$, and $U_0, \\ldots, U_n \\subseteq X$ \na\\marginnote{The interior $V^o$ of a nhd $V$ is the union of all the open sets contained in $V$} collection of basic nhds such that $\\gamma([t_i,t_{i+1}]) \\subseteq U_i^o$.\nDefine the subsets\n\\[\n\tN_\\gamma(t_1<\\cdots<t_n;U_0,\\ldots,U_n) :=\\{\\eta\\colon I\\to X\\mid\\forall i=0,\\ldots n,\\ \n\t\t\\eta([t_i,t_{i+1}]) \\subseteq U_i^o\\} \\subseteq \\Top(I,X)\n\\]\nThen define $\\cN_{co}(\\gamma)$ to be the family of subsets of $\\Top(I,X)$ consisting of the sets above, as the partition and the collection of basic nhds vary. So defined the families $\\cN_{co}(\\gamma)$ give a neighbourhood base on $\\Top(I,X)$.\n\\end{lemma}\n\n\\begin{definition}\nThe \\emph{path space} $X^I$ is the set $\\Top(I,X)$ equipped with the topology defined by\nLemma~\\ref{lemma:compact_open_base}, which we call the \\emph{compact-open topology}.\n\\end{definition}\n\nWhen $X$ is a metric space, then the compact-open topology and the topology arising from the \nsup metric coincide. A key property of the compact-open topology is that homotopies\\marginnote{More generally, for any space $Y$, continuous maps $I\\times Y \\to X$ are in bijection with continuous maps $Y \\to X^I$}\n$H\\colon I\\times I \\to X$ give continuous paths $h\\colon I \\to X^I$ (defined by $h_t\\colon s\\mapsto H(t,s)$) and vice-versa. Moreover:\n\n\\begin{lemma}\n\n\\begin{enumerate}\n\\item The evaluation map $\\ev\\colon X^I \\times I\\to X$, $\\ev(\\gamma,t) = \\gamma(t)$ is continuous, and \n\\item given a map $X\\xrightarrow{f} Y$, the post-composition map $f_*\\colon X^I \\to Y^I$, $f_*(\\gamma) = f\\circ \\gamma$, is continuous.\n\\end{enumerate}\n\\end{lemma}\n\nThen given $t\\in I$, the composite map $\\ev_t\\colon X^I \\simeq X^I\\times\\{t\\} \\into X^I \\times I \\xrightarrow{\\ev} X$ is continuous.\nUsually we care just about the cases $t=0,1$. \nWe can then look at various subspaces of $X^I$, for a given $x\\in X$:\n\\begin{align*}\nP_xX & := \\{\\gamma \\in X^I\\mid \\gamma(0)=x\\} = \\ev_0^{-1}(x)\\\\\nP_x^yX & := \\{\\gamma \\in X^I\\mid \\gamma(0)=x,\\ \\gamma(1)=y\\} = \\ev_0^{-1}(x)\\cap \\ev_1^{-1}(y)\\\\\n\\Omega_x X & := P_x^x X = \\{\\gamma \\in X^I \\mid \\gamma(0) = x = \\gamma(1)\\}\n\\end{align*}\nIn particular, we have already seen the last two, albeit without their topologies. We also see that path \ncomponents of these spaces have something to do with homotopy classes of paths, perhaps with\nconstraints on endpoints.\n\nA key property of the natural transformation $\\id \\Rightarrow \\disc\\pi_0\\colon \\slpcTop\\to\\slpcTop$\nis that it has a universal property: given a discrete space $S$, an slpc space $X$ and a continuous\nmap $X\\xrightarrow{f} S$, there is a \\emph{unique} function $\\pi_0(X)\\to U(S)$ such that\n\\[\n\\xymatrix{\nX \\ar[r] \\ar[d] & S\\\\\n\\disc(\\pi_0(X)) \\ar[ur]\n}\n\\]\ncommutes. Hence if we take our function \n\\begin{equation}\\label{eq:path_space_action_fibres}\nP_x^yX \\times Z_x \\to Z_y\n\\end{equation}\nfrom the previous lecture, \narising from a covering space $Z\\to X$, and if we can show it is continuous, we would get a \nfactorisation\n\\[\nP_x^y X\\times Z_x\\to \\pi_0(P_x^y X\\times Z_x) \\simeq \\pi_0(P_x^yX)\\times Z_x \\to Z_y\n\\]\nwhere the unmarked isomorphism exist due to $Z_x$ being discrete.\nIf $Z$ is path connected, a fixing some $z\\in Z_x$, we get a surjective map $\\pi_0(P_x^y X)\\to Z_y$,\nwhich further constrains both the topology of the space of paths, and the possible fibres of \n$Z\\to X$. However, there are two issues:\n\\begin{enumerate}[(i)]\n\\item We yet don't know our path lifting function is continuous\n\\item We don't know if $P_x^y X$ is slpc, hence if path components and components agree.\n\\end{enumerate}\n\nTo address (i), the unique path lifting property from last lecture will be promoted to a\n\\marginnote{here $X^I \\times_X Z = \\{(\\gamma,z)\\mid \\gamma(0) = \\pi(z)\\}$} \n\\emph{continuous function} $\\Lift\\colon X^I\\times_X Z \\to Z^I$. Combined with $Z^I \\xrightarrow{\\ev} Z$\nwe will be able to reconstruct (\\ref{eq:path_space_action_fibres}) as\n\\[\nP_x^y X \\times Z_x \\into X^I \\times_X Z \\xrightarrow{\\Lift} Z^I \\xrightarrow{\\ev_1} Z\n\\]\nfactors through $Z_y \\subset Z$. We already have the definition of $\\Lift$, but we need to show \ncontinuity.\n\n\\begin{theorem}\nThe function $\\Lift\\colon X^I\\times_X Z \\to Z^I$ is continuous.\n\\end{theorem}\n\n\\begin{proof}\nWe need to set up the ingredients, so take $\\gamma \\in X^I$, \ndefine $x=\\gamma(0)$, $y=\\gamma(1)$, and take $z\\in Z_x$.\nLet $\\widetilde{\\gamma} = \\Lift(\\gamma,z)$, and $z'=\\widetilde{\\gamma}(1)\\in Z_y$.\nTake a basic nhd $N_{\\widetilde{\\gamma}} = N_{\\widetilde{\\gamma}}(t_1 < \\cdots<t_n;U_0,\\ldots, U_n)$.\nWe want to construct a basic nhd\n\\[\nM(\\gamma,z) \\subseteq X^I \\times_X Z\n%:= \\left(N_\\gamma(s_1<\\cdots<s_m;V_0,\\ldots, V_m)\\times W \\right) \\cap X^I \\times_X Z\n\\]\nof $(\\gamma,z)$ such that $M(\\gamma,z) \\subseteq \\Lift^{-1}(N_{\\widetilde{\\gamma}})$.\n\nSince $Z\\xrightarrow{\\pi} X$ is locally trivial and $I$ is compact, we can find a sequence $W_0,\\ldots,W_m\\subseteq Z$ (with $m\\geq n$) of nhds such that\n\\begin{itemize}\n\t\\item $\\pi\\big|_{W_i} \\colon W_i \\xrightarrow{\\simeq} \\pi(W_i)$ and each $\\pi(W_i)$ is a nhd in $X$, and\n\t\\item $\\forall i=0,\\ldots, m$ $\\exists j=j(i)$ with $W_i \\subseteq U_j$.\n\\end{itemize}\n\nThere is then a refinement $0<s_1<\\cdots<s_m < 1$\\marginnote{so that $[s_i,s_{i+1}]\\subseteq [t_j,t_{j+1}]$} such that $W_i$ is a nhd of $\\widetilde{\\gamma}(t)$ for all $t\\in[s_i,s_{i+1}]$.\nThe set $\\widetilde{N}_{\\widetilde{\\gamma}} := N_{\\widetilde{\\gamma}}(s_1<\\cdots<s_m;W_0,\\ldots,W_m) \\subseteq Z$ is then contained in $N_{\\widetilde{\\gamma}}$.\n\nBut, defining $V_i := \\pi(W_i)$, the partition $0<\\cdots s_1 <s_m<1$ and the sets $V_0,\\ldots,V_m$ satisfy the conditions required to define the basic nhd $N_\\gamma(s_1<\\cdots<s_m;V_0,\\ldots, V_m)\\subseteq X^I$. Also note that $z=\\widetilde{\\gamma}(0) \\in W_0$, so we can define a nhd\n\\[\nM(\\gamma,z):= \\left(N_\\gamma(s_1<\\cdots<s_m;V_0,\\ldots, V_m)\\times W \\right) \\cap X^I \\times_X Z\n\\]\nof $(\\gamma,z)$. By construction $\\pi(\\widetilde{N}_{\\widetilde{\\gamma}}) \\subseteq N_\\gamma(s_1<\\cdots<s_m;V_0,\\ldots, V_m)$, but in fact $\\Lift(M(\\gamma,z)) = \\widetilde{N}_{\\widetilde{\\gamma}} \\subseteq N_{\\widetilde{\\gamma}}$, as desired.\n\\end{proof}\n\n\\begin{rem}\nIn fact, by the uniqueness of lifts, the map $\\Lift$ is a bijection, and even a homeomorphism, with inverse $(\\pi_*,\\ev_0)\\colon Z^I \\to X^I \\times _X Z$.\n\\end{rem}\n\nSo we have a continuous map $P_x^y X\\times Z_x \\to Z_y$, and thus get a function $\\pi_0(P_x^yX) \\times Z_x \\to Z_y$.\nBut we would like to know that for any two points $\\gamma,\\eta\\in P_x^yX$ in the same connected component, there is a path between them.\nSuch a path, recall, is a homotopy $H\\colon I \\times I \\to X$ satisfying $H(s,0)=x$ and $H(s,1)=y$ $\\forall x\\in I$. Such a homotopy between paths will be said to \\emph{fix endpoints}.\n\n% We will give a sufficient condition, but the proof it is indeed sufficient will be relegated to a handout.\n\n\\begin{definition}\nA space $X$ is called \\emph{semilocally simply-connected}\\marginnote{this is the last technical \ncondition on spaces we require in this section of the course}\n (or \\emph{slsc}) if every point has a basis of nhds $N$ that are path connected, and given \n$x,y\\in N$ and two paths $\\gamma,\\eta \\in P_x^y N$, there is an endpoint-fixing homotopy \n$I\\times I \\to X$ from $\\gamma$ to $\\eta$.\n\\end{definition}\n\nNotice that if a space $X$ is slsc, then it is slpc.\n\n\\begin{example}\nAny manifold is slsc, since every point has a nhd homeomorphic to some $\\RR^n$, \nwhich is convex.\n\\end{example}\n\n\\begin{example}\nThe \\emph{Hawaiian earring} is the subspace \n\\[\n\t\\bigcup_{n\\in \\mathbb{N}} \\left\\{(x,y)\\in \\RR^2 \\left| \n\t\t\t||(x,y) - (\\tfrac1n,0)|| = \\tfrac1n\\right.\\right\\}\n\\]\nand is not slsc. Every nhd of the point $(0,0)$ contains loops that are not contractible, and\nstay non-contractible in the full space.\n\\end{example}\n\n\n\\begin{theorem}[Wada 1955, improved in Roberts 2010]\nIf\\marginnote{H.~Wada, ``Local connectivity of mapping spaces'', Duke Math. J. \\textbf{22}, \nNumber 3 (1955) pp 419--425. DMR ``Fundamental bigroupoids and 2-covering spaces'', Theorem 5.12.} \nthe space $X$ is semilocally simply-connected, \nthe spaces $X^I$, $P_xX$ and $P_x^yX$ (hence $\\Omega_xX$) are semilocally path connected.\n\\end{theorem}\n\n\\begin{proof}(Non-examinable)\nSee Handout 1.\n\\end{proof}\n\n\nA\\lecturenum{7} question that may have occurred to you is what happens with the isomorphism \n$\\gamma_*\\colon Z_x\\to Z_y$ if we break the path $\\gamma\\colon I\\to X$ into two \nsubpaths, say $x\\rightsquigarrow x' \\rightsquigarrow y$, and then compose the \ncorresponding isomorphisms $Z_x\\xrightarrow{\\simeq}Z_{x'}\\xrightarrow{\\simeq}Z_y$. Or, \nstarting from paths $\\gamma,\\eta\\colon I\\to X$ such that $\\gamma(1) = \\eta(0)$ and \ndefining the \\emph{concatenation} $\\gamma\\#\\eta\\colon I\\to X$ by\n\\[\n\t\\gamma\\#\\eta(t) = \\begin{cases}\n\t\t\\gamma(2t) & t\\in[0,\\frac12]\\\\\n\t\t\\eta(2t-1) & t \\in[\\frac12,1]\n\t\\end{cases} \n\\]\nhow do $Z_{\\gamma(0)} \\xrightarrow{\\gamma_*} \nZ_{\\gamma(1)}=Z_{\\eta(0)}\\xrightarrow{\\eta_*}Z_{\\eta(1)}$ and \n$Z_\\gamma(0) \\xrightarrow{(\\gamma\\#\\eta)_*}Z_{\\eta(1)}$ relate?\n\n\\begin{lemma}\nFor paths $\\gamma,\\eta\\colon I\\to X$ such that $\\gamma(1) = \\eta(0)$, \n$(\\gamma\\#\\eta)_* = \\eta_*\\circ\\gamma_*\\colon Z_{\\gamma(0)}\\to Z_{\\eta(1)}$.\n\\end{lemma}\n\nIn particular, for $\\gamma,\\eta\\in \\Omega_xX$, $\\gamma\\#\\eta\\in \\Omega_xX$ and we have \nthe map $\\Omega_x X \\to \\Aut(Z_x)$, which is compatible with path concatenation. But \n$\\#$ is not associative!\n\n\\begin{example}\nTake $X=S^1$, and let $\\gamma(t)=\\exp(2\\pi it)$.\n\\[\n\t(\\gamma\\#\\gamma)\\#\\gamma = \\begin{cases}\n\t\t\\exp(8\\pi it) & t\\in[0,\\frac12]\\\\\n\t\t\\exp(4\\pi it) & t \\in[\\frac12,1]\n\t\\end{cases} \\quad \\text{but}\\quad\n\t\\gamma\\#(\\gamma\\#\\gamma) = \\begin{cases}\n\t\t\\exp(4\\pi it) & t\\in[0,\\frac12]\\\\\n\t\t\\exp(8\\pi it) & t \\in[\\frac12,1]\n\t\\end{cases}\n\\]\n\\end{example}\n\nLet us re-examine how paths concatenate. Given $\\gamma,\\eta\\colon I \\to X$ \nsuch that $\\gamma(1) = \\eta(0)$, then we get a continuous function \n$\\langle\\gamma,\\eta\\rangle\\colon [0,2] \\to X$. The concatenation $\\gamma\\#\\eta$ is then \nthe precomposition of $\\langle\\gamma, \\eta\\rangle$ with the map $I=[0,1] \n\\xrightarrow{t\\mapsto 2t} [0,2]$. If we had a third map, $\\lambda\\colon I\\to X$ with \n$\\lambda(0)=\\eta(1)$, then there is naturally a continuous function $\\langle\\gamma, \n\\eta,\\lambda\\rangle\\colon [0,3]\\to X$. But the concatenations $( \\gamma \\# \\eta ) \\# \n\\lambda$ and $\\gamma \\# ( \\eta \\# \\lambda)$ arise from precomposing with two different \nmaps $I=[0,1]\\to [0,3]$. These are\\marginnote{%\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,3);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,3.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 2*\\x);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 4*\\x-1);\n\\draw (0.5,1.7) node {$\\phi$};\n\\end{tikzpicture}\n\\qquad\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,3);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,3.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 4*\\x);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 2*\\x+1);\n\\draw (0.5,2.5) node {$\\psi$};\n\\end{tikzpicture}\n}\n\\begin{align*}\n\\phi\\colon t& \\mapsto \\begin{cases}\n4t & t\\in [0,\\frac12]\\\\\n2t+1 & t\\in [\\frac12,1]\n\\end{cases}\\\\\n\\psi\\colon t& \\mapsto \\begin{cases}\n2t & t\\in [0,\\frac12]\\\\\n4t-1 & t\\in [\\frac12,1]\n\\end{cases}\n\\end{align*}\nwith graphs as at right.\n\nThese two paths $I\\to [0,3]$ are homotopic fixing endpoints by the homotopy $h_a(s,t) = \ns\\phi(t) + (1-s) \\phi(t)$. If we then precompose \n$\\langle\\gamma,\\eta,\\lambda\\rangle\\colon [0,3]\\to X$ with $h_a\\colon I\\times I \\to [0,3]$, \nwe get a homotopy between $( \\gamma \\# \\eta ) \\# \\lambda$ and $\\gamma \\# ( \\eta \n\\# \\lambda)$. Path concatenation in $X$ is then \\emph{homotopy associative}. But what \nabout inverses or an identity element? We will play the same trick, by considering a \n`universal' case.\n\nGiven a path $\\gamma\\colon I \\to X$, we have the reverse path $-\\gamma$,\n\\marginnote{recall $-\\gamma(t) := \\gamma(1-t)$\\\\%} \n%\\marginnote{%\n\\noindent\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 2*\\x);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 2-2*\\x);\n\\draw (0.85,0.75) node {$\\alpha$};\n\\end{tikzpicture}\n\\qquad\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:1, ultra thick] plot (\\x, 0);\n% \\draw [domain=0.5:1, ultra thick] plot (\\x, 2-2*\\x);\n\\end{tikzpicture}\n\n\\medskip\n\n\\noindent\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 1-2*\\x);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 2*\\x-1);\n\\draw (0.65,0.6) node {$\\beta$};\n\\end{tikzpicture}\n\\qquad\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:1, ultra thick] plot (\\x, 1);\n% \\draw [domain=0.5:1, ultra thick] plot (\\x, 2-2*\\x);\n% \\draw (0.5,2.5) node {$\\psi$};\n\\end{tikzpicture}\n\n\\medskip\n\n\\noindent\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 2*\\x);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 1);\n\\draw (0.5,0.6) node {$\\mu$};\n\\end{tikzpicture}\n\\qquad\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:1, ultra thick] plot (\\x, \\x);\n% \\draw [domain=0.5:1, ultra thick] plot (\\x, 2-2*\\x);\n% \\draw (0.5,2.5) node {$\\psi$};\n\\end{tikzpicture}\n\n\\medskip\n\n\\noindent\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:0.5, ultra thick] plot (\\x, 0);\n\\draw [domain=0.5:1, ultra thick] plot (\\x, 2*\\x-1);\n\\draw (0.6,0.6) node {$\\nu$};\n\\end{tikzpicture}\n\\qquad\n\\begin{tikzpicture}[scale=1.2]\n\\draw[step=1,gray,very thin] (0,0) grid (1,1);\n\\draw [thick,->] (0,0) -- (1.2,0);\n\\draw [thick,->] (0,0) -- (0,1.2);\n\\draw [domain=0:1, ultra thick] plot (\\x, \\x);\n% \\draw [domain=0.5:1, ultra thick] plot (\\x, 2-2*\\x);\n% \\draw (0.5,2.5) node {$\\psi$};\n\\end{tikzpicture}}\n%\nand the composite $\\gamma \\# (-\\gamma)\\colon I \\to X$ can be factored as \n$I\\xrightarrow{\\alpha} I \\xrightarrow{\\gamma} X$ for a certain path $I\\xrightarrow{\\alpha} \nI$. If we instead concatenate in the other direction, namely $(-\\gamma)\\# \\gamma\\colon \nI\\to X$, then this factors as $I\\xrightarrow{\\beta} I\\xrightarrow{\\gamma}X$. Again \n$\\beta$ is a certain path in $I$. The graphs of both $\\alpha$ and $\\beta$ are shown at \nright, and both of them are homotopic, fixing endpoints, to the constant functions at \n$0$ and $1$ respectively, by taking an affine combination as in the definition of $h_a$ \nabove. Then by composing the homotopies here with $\\gamma$, we get homotopies between \nthe path $\\gamma\\#(-\\gamma)$ and the constant path at $\\gamma(0)$, and also between \n$(-\\gamma)\\#\\gamma$ and the constant path at $\\gamma(1)$. So we have \\emph{homotopy \ninverses}.\n\nIf we want to think about a homotopy identity element, then we should use the constant \npath $c_x\\colon I\\to X$ at a point $x\\in X$, with $c_x(t)= x$, $\\forall t\\in I$. We can \nfactor the composite $\\gamma\\# c_{\\gamma(1)}$ as $I\\xrightarrow{\\mu} I \n\\xrightarrow{\\gamma} X$ for $\\mu$ as shown at right, and factor $c_{\\gamma(0)}\\#\\gamma$ \nas $I\\xrightarrow{\\nu} I \\xrightarrow{\\gamma} X$. As above, $\\mu$ and $\\nu$ are \nhomotopic, fixing endpoints, to the identity map $I\\to I$.\n\nIf we turn the five homotopies $I\\times I \\to X$ described above into paths $I\\to X^I$, then if we start from elements of $\\Omega_x X$, these homotopies correspond to paths in $\\Omega_x X$.\nThus $\\Omega_x X$, which has a concatenation binary operator $\\#\\colon \\Omega_xX \\times \\Omega_xX\\to \\Omega_xX$, acts like a group, except the group axioms only hold up to the existence of paths\\marginnote{More is true, though we won't prove it: there are homotopies assembled out of these paths for all possible cases, for instance $I \\times \\Omega_x X \\times \\Omega_x X \\times \\Omega_x X \\to \\Omega_x X$} \n\\begin{align*}\n( \\gamma \\# \\eta ) \\# \\lambda & \\rightsquigarrow \\gamma \\# ( \\eta \\# \\lambda)\\\\\n\\gamma\\# (-\\gamma) &\\rightsquigarrow c_{\\gamma(0)}\\\\\n(-\\gamma)\\# \\gamma &\\rightsquigarrow c_{\\gamma(1)}\\\\\n\\gamma\\# c_{\\gamma(1)}&\\rightsquigarrow \\gamma \\\\\nc_{\\gamma(0)}\\#\\gamma &\\rightsquigarrow \\gamma\n\\end{align*}\nin $\\Omega_x X$. As a result we have proved most of\n\n\\begin{prop}\nLet $(X,x)$ be a pointed space, with $X$ slsc.\\marginnote{If we fall back on the default, namely just slpc, then we can use $[\\pt,\\Omega_x X]$ instead} The set $\\pi_0(\\Omega_x X)$ carries the \nstructure of a group, its product arising from concatenation of loops and identity element \nrepresented by the constant path at $x$.\n\\end{prop}\n\n\\begin{proof}\nTo exhibit the multiplication, consider the functor $\\pi_0$ applied\\marginnote{This requires knowing that $\\#$ is continuous! See Assignment 2.} to $\\#\\colon \\Omega_x X \n\\times \\Omega_x X \\to \\Omega_x X$, giving $\\pi_0(\\Omega_x X \\times \\Omega_x X) \\xrightarrow{\\#} \n\\pi_0(\\Omega_x X)$. But since $\\pi_0(M\\times N) \\xrightarrow{\\simeq} \n\\pi_0(M)\\times\\pi_0(N)$, for all slpc spaces $M$ and $N$, we get a composite \n$\\pi_0(\\Omega_x X) \\times \\pi_0(\\Omega_x X) \\simeq \\pi_0(\\Omega_x X \\times \\Omega_x X) \n\\to \\pi_0(\\Omega_x X)$. This is associative and unital, and inverses exist, by the \nexistence of the paths above.\n\\end{proof}\n\n\\begin{definition}\nFor\\marginnote{Recall we also proved $[\\pt,-]$ descends to a functor $\\Ho \\to \\Set$ in Assignment 1}\n $(X,x)$ a pointed space its \\emph{fundamental group at $x$} is \n$\\pi_1(X,x) := [\\pt,\\Omega_xX]$, which for $X$ a slsc space coincides with $\\pi_0(\\Omega_xX)$.\n\\end{definition}\n\nFrom\\marginnote{As a point of clarification, everything here works for arbitrary slpc spaces with small adjustments, but for slsc spaces the approach is slightly cleaner, as components and path components coincide for the function spaces} the previous reasoning, we have constructed from a covering space $Z\\to X$ and \nchosen basepoint $x\\in X$ a permutation representation $\\pi_1(X,x) \\to \\Aut(Z_x)$. If \n$Z$ is path connected, and we choose $z\\in Z_x$, we get a surjective map $\\pi_1(X,x) \\to \nZ_x$, given by $\\gamma\\mapsto \\gamma_*(z)$. This implies we have an upper bound on the \ncardinality of fibres of any path connected covering space, and conversely, given a \nconnected covering space, the fibres give a lower bound on the number of distinct \nhomotopy classes of loops in $X$.\n\n\\begin{example}\nThe projection map $S^2 \\to \\mathbb{RP}^2$ is a covering space and $S^2$ is connected, \nso there exist at least two non-homotopic loops in $\\mathbb{RP}^2$ at any given \nbasepoint. One of these is the constant loop, so there exists a loop in $\\mathbb{RP}^2$ \nnot homotopic to it.\n\\end{example}\n\n\\begin{example}\\label{eg:piS^1_infinite}\nWe have the covering space $\\exp(2\\pi i-)\\colon \\RR\\to S^1$ with fibre\n$\\ZZ$ over $1\\in S^1$, which implies $\\pi_1(S^1,1)$ is an infinite group.\n\\end{example}\n\n\\begin{prop}\nThe loop space construction is a functor $\\Omega\\colon \\Top_*\\to \\Top_*$.\n\\end{prop}\n\n\n\\begin{corollary}\nThe fundamental group\\marginnote{Exercise: This functor is naturally isomorphic to $[(S^1,1),(X,x)]_*$} gives a functor \n\\[\n\t\\pi_1 := [\\pt,-] \\circ \\Omega\\colon \\Top_*\\to \\Grp.\n\\]\nwhich for slsc spaces is naturally isomorphic to $\\pi_0\\circ \\Omega$.\n\\end{corollary}\n\n\nHowever,\\lecturenum{8} as we have seen, we don't just get an action of $\\pi_1(X,x)$ on the fibre $Z_x$ \nof a covering space. We also get what looks like an action of paths between different \npoints on fibres, but now points in one fibre are taken to points of another fibre. In \nfact, if $X$ is not equipped with a basepoint to start with, or there are several \nnatural options and no one of those is canonical, then we can create an even richer \ninvariant, namely a \\emph{groupoid}.\n\n\\begin{definition}\nA \\emph{groupoid} is a category where every morphism has an inverse.\n\\end{definition}\n\nSo that we have an idea of what kinds of groupoids arise, let us consider some examples. \nWe will be considering only \\emph{small} groupoids: those locally small groupoids \n$\\Gamma$ where there is a set $\\Gamma_0$ of objects. We can then take the disjoint union \nof all the hom-sets to get the set $\\Gamma_1= \\bigsqcup_{x,y\\in \\Gamma_0} \\Gamma(x,y)$ of morphisms, and specify the source and \ntarget functions $s,t\\colon \\Gamma_1\\rightrightarrows \\Gamma_0$. Groupoids and functors \nform a category $\\Gpd$.\n\n\\begin{example}\n\\begin{enumerate}\n\\item Every set $S$ gives a groupoid $\\disc(S)$, by taking the set of objects to be $S$, and to only have identity\nmorphisms. This gives a full subcategory inclusion $\\disc\\colon \\Set \\into \\Gpd$, and such groupoids are called \\emph{discrete}.\n\\item Every set $C$ also gives another groupoid $\\codisc(C)$ with set of objects $C$, but with exactly \none morphism from any object to any other object. The set of morphisms is $C\\times C$, and every \nobject $c\\in C$ has the trivial group of automorphisms. Such groupids are called \\emph{codiscrete}.\n\\item Let $G$ act on the set $Y$ on the right. Then there is a groupoid $Y/\\!/G$ with object set $Y$, and set of \nmorphisms $Y\\times G$. The source and target are given by $s(y,g)=y$, $t(y,g)=yg$, and composition is $(y,g)(yg,h) = (y,gh)$.\n\\begin{enumerate}\n\\item If $G=1$, then this recovers the first example.\n\\item If $Y=\\pt$, then the information in the groupoid is essentially just that of the group $G$. Groupoids of this form will be denoted $\\BB G$, and $\\BB\\colon \\Grp \\into \\Gpd$ is the inclusion of a full subcategory.\n\\end{enumerate}\n\\end{enumerate}\n\\end{example}\n\nA slogan people sometimes use is that a groupoid is like a group with `many identities', \nbut you can also usefully think of them as being a generalisation of a group action, \nwhere you have different groups acting on different parts of the set. Here is a useful \nlemma about the structure of groupoids.\n\n\\begin{lemma}\nFor any groupoid $\\Gamma$, and given $x,y\\in \\Gamma_0$,\\marginnote{using algebraic order of composition}\n\\begin{align*}\n\t\\Ad_a\\colon \\Gamma(x,x) & \\xrightarrow{\\simeq} \\Gamma(y,y)\\\\\n\t\t\tg & \\mapsto a^{-1}ga\n\\end{align*}\nis an isomorphism for any $a\\in \\Gamma(y,x)$\\marginnote{$(\\Ad_a)^{-1} = \\Ad_{a^{-1}}$\\\\\\bigskip\\noindent transitive: $(ba^{-1},a) \\mapsto b$;\\\\ \n\\noindent free: $ga=a$ implies $g = gaa^{-1} = aa^{-1} =\\id_x$} and \nthe function\n\\begin{align*}\n\t\\Gamma(x,x)\\times \\Gamma(x,y) & \\to \\Gamma(x,y)\\\\\n\t\t(g,a) & \\mapsto ga\n\\end{align*}\ndefines a free and transitive action of the group $\\Gamma(x,x)$.\n\\end{lemma}\n\nAs a reminder: a free group action $G\\times S\\to S$ is one where $g\\cdot p = p$ implies \n$g$ is the identity element, and a transitive action one where given any two elements \n$p,q\\in S$, there is some group element $g\\in G$ such that $g\\cdot p = q$.\n\n\\begin{definition}\nGiven an slsc space $X$ and a specified subset $A\\subseteq X$, the \\emph{fundamental groupoid \nbased at $A$}\nis the groupoid $\\Pi_1(X,A)$ with set of objects $A$, and the set of morphisms from $x$ to $y$ is $\\Pi_1(X,A)(x,y) := \\pi_0(P_x^yX)$. \nThe\\marginnote{the definition makes sense for more general slpc spaces, using $[\\pt,-]$ in place of $\\pi_0$, but we are only consider slsc spaces here} composition map is induced from concatenation of paths:\n\\[\n\t\\pi_0(P_x^yX) \\times \\pi_0(P_y^zX) \\simeq \\pi_0(P_x^y X\\times P_y^zX) \\to \\pi_0(P_x^zX)\n\\]\nand \nconstant paths are the identity morphisms.\n\\end{definition}\n\n\nAs with other invariants, the fundamental groupoid is a functor. Define the category \n$\\Top^{(2)}$ to be the category with objects pairs $(X,A)$ where $X$ is a topological \nspace and $A\\subseteq X$ is a subspace, and a morphism $(X,A) \\to (Y,B)$ is a continuous \nfunction $f\\colon X\\to Y$ such that $f(A) \\subseteq B$. We have a full subcategory inclusion \n$\\Top_*\\into \\Top^{(2)}$.\n\n\\begin{prop}\nThe fundamental groupoid gives a functor $\\Pi_1\\colon \\Top^{(2)}\\to \\Gpd$ such that\n\\[\n\t\\xymatrix{\n\t\t\\Top_* \\ar[r]^{\\pi_1} \\ar[d] & \\Grp \\ar[d]^{\\BB}\\\\\n\t\t\\Top^{(2)} \\ar[r]_{\\Pi_1} & \\Gpd\n\t}\n\\]\nand moreover:\\marginnote{The product/disjoint union of groupoids is \nwhat you think it is: take the products/disjoint unions of the objects and the morphisms, respectively} \n\\begin{align*}\n\t\\Pi(X\\times Y,A\\times B) & \\xrightarrow{\\simeq} \\Pi_1(X,A) \\times \\Pi_1(Y,B)\\\\\n\t\\Pi_1(X,A) \\sqcup \\Pi_1(Y,B) & \\xrightarrow{\\simeq} \\Pi(X\\sqcup Y,A\\sqcup B)\n\\end{align*}\n\\end{prop}\n\nWe can include \\emph{unbased} spaces $X$ into pairs, by taking $(X,X)$, giving another \nfully faithful functor, $\\Top \\to \\Top^{(2)}$. In this case, if the space $X$ has \n\\emph{no} preferred basepoints whatsoever, we can still define the fundamental groupoid \nof $X$ itself as $\\Pi_1(X,X)$, which is a functor $\\Top \\to \\Gpd$.\n\n\nWe haven't yet seen how to calculate the fundamental group(oid) in \nexamples, so we will turn to that now. We need a name for spaces $X$ that have \n$\\Pi_1(X)$ trivial, in the sense of being codiscrete.\n\n\\begin{definition}\nA space $X$ that satisfies $\\Pi_1(X) = \\codisc(X)$\\marginnote{such spaces \nalso have $\\Pi_1(X,A) = \\codisc(A)$ for all $A\\subseteq X$} is called \n\\emph{simply-connected}.\n\\end{definition}\n\nIf we unpack this definition, it tells us that a) given any two points $x,y\\in X$, there is a (homotopy class of some) path from $x$ to $y$, so that $X$ is path-connected, and b) all paths between any two given points are endpoint-fixed homotopic, hence a unique morphism in the fundamental groupoid. \nAs a result, $\\pi_1(X,x) = \\Pi_1(X)(x,x)$ is the trivial group.\n\n\\begin{example}\nConvex subspaces $C\\subseteq \\RR^n$ are simply-connected, because any two points $v,w\\in C$ \ncan be joined by a path in $C$, and given two paths $\\gamma,\\eta\\colon v\\rightsquigarrow w$\nthe map $(s,t)\\mapsto s\\gamma(t)+(1-s)\\eta(t)$ is a homotopy between them.\n\\end{example}\n\nIn particular, the interval $I$ is simply-connected. The fundamental groupoid $\\Pi_1(I,\\{0,1\\})$\nis important enough to have its own name: $\\mathbf{2}$, sometimes denoted \n$(0\\xrightarrow{\\sim} 1)$, as it has two objects $0,1$ and a unique isomorphism between them.\n\n\\begin{ex}\nDefine a \\emph{star-shaped region}\\marginnote{For $\\mathcal{H} \\subset \\CC$ the\n(open) upper half-plane, the set $\\mathcal{H}\\cup\\mathbb{Q}$ is star-shaped, but not convex} \nin a (real or complex) vector space $V$ to be a set \n$K\\subseteq V$ such that there is a point $v_0\\in K$ such that for every $v\\in K$ and $t\\in I$,\n$tv_0+(1-t)v\\in K$. Prove that star-shaped regions are simply-connected.\n\\end{ex}\n\nSimply-connected spaces are special for the following reason.\n\n\\begin{prop}\nIf $X$ is a simply-connected space, then every path connected covering space \n$Z\\xrightarrow{\\pi} X$ is trivial, in the sense that $\\pi$ is a homeomorphism.\n\\end{prop}\n\n\\begin{proof}\nRecall that $\\pi_1(X,x) \\to Z_x$ is surjective for any $x\\in X$, so $X$ simply-connected implies\n$Z_x = \\pt$ for all $x$. Thus $\\pi$ is a bijection. The local triviality condition implies \nthat every $x\\in X$ has an open set $U\\ni x$ such that $\\pi^{-1}(U) \\to U$ is a homeomorphism. \nLetting $U_\\alpha$ range over such an cover of $X$, we can glue the inverses of these local \nhomeomorphisms into an inverse for $\\pi$.\n\\end{proof}\n\n\n\n\\begin{example}\nIf $X$ is contractible then it is simply-connected. Let $H\\colon I\\times X \\to X$ be a \ncontraction to $x_0\\in X$. Consider the induced map $h= \\Pi_1(H)\\colon \\Pi_1(I\\times X, \n\\{0,1\\}\\times X) \\to \\Pi_1(X,X) = \\Pi_1(X)$. The domain simplifies to be \n$\\Pi_1(I,\\{0,1\\})\\times \\Pi_1(X) = \\mathbf{2}\\times \\Pi_1(X)$. Consider the induced maps \n$\\{i\\}\\times \\Pi_1(X)\\to \\mathbf{2}\\times \\Pi_1(X) \\to \\Pi_1(X)$ for $i=0,1$. Since \n$H\\big|_{\\{0\\}\\times X}=\\id_X$, so $h_{\\{0\\}\\times \\Pi_1(X)}=\\id_{\\Pi_1(X)}$; and as \n$H\\big|_{\\{1\\}\\times X}$ is constant at $x_0$, so $h(0,x) = x_0$ for all $x\\in X$, and \n$h\\big|_{\\{1\\}\\times \\Pi_1(X)}$ sends every path to the constant path at $x_0$. We \nalready know that $X$ is path connected, so that for any $x,y\\in X$ there is some path \nbetween them. Given a path $\\gamma\\colon x\\rightsquigarrow y$ consider the commutative square\n\\[\n\t\\xymatrix{\n\t(0,x) \\ar[r]^{(\\id_0,[\\gamma])} \\ar[d] & (0,y) \\\\\n\t(1,x) \\ar[r]_{(\\id_1,[\\gamma])} & (1,y) \\ar[u]\n\t}\n\\]\nin $\\mathbf{2}\\times \\Pi_1(X)$ (recall all morphisms are invertible). Under $h$ this is sent to\n\\[\n\t\\xymatrix{\n\tx\\ar[r]^{[\\gamma]} \\ar[d] & y \\\\\n\tx_0 \\ar[r]_{\\id} & x_0 \\ar[u]\n\t}\n\\]\nThe vertical arrows are independent of $[\\gamma]$, so that every path $\\gamma$ in $X$ is \nhomotopic to the composite the long way around the square, hence to every other path.\n\\end{example}\n\nSo\\lecturenum{9} in some sense, we are interested in spaces that are path connected, though this is \nuseful when building spaces out of disjoint components. Here is another way we can get \ninformation about the fundamental groupoid of a space from the fundamental groupoid of \nother spaces.\n\n\\begin{theorem}\\label{thm:cov_space_gives_faithful_functor}\nLet $Z\\xrightarrow{\\pi} X$ be a covering space.\\marginnote{thus the funtor $\\Pi_1(\\pi)$ is \\emph{faithful}} \nThen $\\Pi_1(Z)(z_1,z_2) \\to \\Pi_1(X)(\\pi(z_1),\\pi(z_2))$ is injective for all $z_1,z_2\\in Z$.\n\\end{theorem}\n\nWe will prove this theorem in a little bit, but let us give an important result that follows.\n\n\\begin{corollary}\nGiven a covering space $(Z,z)\\xrightarrow{\\pi}(X,x)$, the induced homomorphism between fundamental groups identifies $\\pi_1(Z,z)$ with a subgroup of \n$\\pi_1(X,x)$.\n\\end{corollary}\n\nThis allows us, given a covering space whose fundamental groupoid we know, to place a \nlower bound on the size of the fundamental group of the base space. Alternatively, it \nplaces an upper bound on the size of the fundamental group of the covering space, so if \n$\\pi_1(X,x)$ is finite, then so is $\\pi_1(Z,z)$.\n\n\\begin{prop}\\label{prop:cov_space_of_IxX}\nLet $Z\\to I\\times X$ be a covering space. Then $Z\\xrightarrow{\\simeq} I\\times Z_0$ over \n$I\\times X$, where $Z_0 := Z_{\\{0\\}\\times X}$.\n\\end{prop}\n\n\\begin{proof}\nThe function $Z\\to I\\times Z_0$ is given by $(\\pr_1\\circ \\pi,\\tau)$, for some \n$\\tau\\colon Z\\to Z_0$, which we need to construct.\nThe idea is similar to the situation where we constructed the trivialisation of a \ncovering space of $I$, which is the special case of $X=\\pt$. \nGiven $x\\in X$, we get a trivisalisable covering space $Z_{I\\times \\{x\\}}\\to I\\times \\{x\\}\\simeq I$, and so \na function $\\tau_x\\colon Z_{I\\times \\{x\\}} \\to I\\times Z_{(0,x)} \\xrightarrow{\\pr_2}Z_{(0,x)}$. \nHence we have a (potentially discontinuous) function $Z \\to Z_0$ using the various $\\tau_x$. \nWe will write down a global version of this function using ingredients we already know to be \ncontinuous.\n\nGiven $(t,x)\\in I\\times X$, there is a path $(0,x) \\rightsquigarrow (t,x)$ given by\n$\\eta_{(t,x)}(s) = (ts,x)$, which we want to vary continuously with $(t,x)$. We know that \n$I\\times I \\times X\\to I\\times X$, $(s,t,x) \\mapsto (ts,x)$ is continuous, so that by the \n\\begin{align*}\n\tI\\times X & \\to (I\\times X)^I\\\\\n\t(t,x) & \\mapsto \\eta_{(t,x)}\n\\end{align*}\nis continuous. We can now define the composite\n\\begin{align*}\n\t\\tau\\colon Z & \\xrightarrow{\\simeq} (I\\times X)\\times_{I\\times X} Z \\to (I\\times X)^I \\times_{I\\times X} Z \n\t\\xrightarrow{\\Lift} Z^I\\xrightarrow{\\ev_1} Z\\\\\n\tz&\\mapsto (\\pi(z),z)\\qquad \\mapsto\\quad (-\\eta_{\\pi(z)},z)\n\\end{align*}\nThis map factors through $Z_0$, as if $(t,z) :=\\pi(z)$, then $-\\eta_z$ is a path in $I\\times X$ \nfrom $(t,x)$ to $(0,x)$ and so the evaluation of the lift of $-\\eta_z$ at $1$ sits over $(0,x)$.\nSince all the maps here are continuous, $\\tau$ is continuous.\n\nWe need to supply a continuous inverse to $(\\pr_1\\circ \\pi,\\tau)$, which is built the \nsame way, except now using $\\eta_z$ itself to lift, rather than $-\\eta_z$:\n\\[\n\t\\sigma\\colon I\\times Z_0 \\to (I\\times X)^I\\times_{I\\times X} Z \\xrightarrow{\\Lift}\n\tZ^I \\xrightarrow{\\ev_1} Z.\n\\]\nThis is manifestly continuous, and one can check that this map is the required inverse by\nconsidering the composite at each point separately, where it reduces to considering $Z$ \nrestricted to $I\\times \\{x\\}$.\n\\end{proof}\n\n\\begin{corollary}\\label{prop:pullback_by_homotopic_maps_iso}\nIf $f,g\\colon X\\to Y$ are homotopic, say by $H\\colon I\\times X \\to Y$, and $Z\\to Y$ is a \ncovering space, then $f^*Z\\simeq g^*Z$ over $X$.\n\\end{corollary}\n\n\\begin{proof}\nIf we form $H^*Z\\to I\\times X$, then we have by Proposition~\\ref{prop:cov_space_of_IxX}\nthat $H^*Z \\simeq I\\times f^*Z$. But $g^*Z \\to X$ is (isomorphic to)  \n$(H^*Z)_{\\{1\\}\\times X}$, hence is isomorphic to $(I\\times f^*Z)_{\\{1\\}\\times X}$, but this\nis isomorphic to $f^*Z$.\n\\end{proof}\n\nThis gives us a criterion whereby we know that no interesting covering spaces exist\n\n\\begin{corollary}\nIf $X$ is contractible, then every covering space $Z\\to X$ is isomorphic to $X\\times Z_x$ \nfor any $x\\in X$.\n\\end{corollary}\n\n\\begin{proof}\nLet $H\\colon I\\times X \\to X$ be a contraction to $x\\in X$\\marginnote{Exercise: such a contraction exists for all $x\\in X$}. Then for $c_x\\colon X\\to X$ the \nconstant map at $x$, $c_x^*Z = X\\times Z_x$. But $H$ is a homotopy between $\\id_X$ and $c_x$,\nand $\\id^*Z = Z$, so by Corollary~\\ref{prop:pullback_by_homotopic_maps_iso} we have the required\nisomorphism.\n\\end{proof}\n\n\\begin{example}\nAny locally convex topological vector space has no interesting covering spaces, likewise any convex or even star-shaped region therein.\nThe unit sphere in a separable, infinite-dimensional Hilbert space has no interesting covering\nspaces. The infinite-dimensional Stiefel manifolds likewise.\n\\end{example}\n\n\n\\begin{corollary}\nLet\\marginnote{%\n$\\xymatrix{\n\\{0\\}\\times X \\ar[d] \\ar[r]^-{\\widetilde{f}} & Z \\ar[d]^\\pi\\\\\nI\\times X \\ar@{-->}[ur]^{\\widetilde{H}} \\ar[r]_-{H} &Y\n}$}\n$Z\\xrightarrow{\\pi} Y$ be a covering space, $f,g\\colon X\\to Y$ a pair of maps and \n$H\\colon I\\times X\\to Y$ a homotopy from $f$ to $g$. If $\\widetilde{f}\\colon \\{0\\}\\times \nX\\to Z$ is a lift of $f$, in the sense that the diagram at right commutes, then there is \na unique homotopy $\\widetilde{H}\\colon I\\times X \\to Z$ lifting $H$ from $\\widetilde{f}$ \nto a lift of $g$.\n\\end{corollary}\n\n\\begin{proof}\nSince $I\\times f^*Z \\xrightarrow{\\simeq} H^*Z$, and we have a section $X\\to f^*Z$, then \nwe get a section $I\\times X \\to I\\times f^*Z$. Composing with the isomorphism we get a \nmap $I\\times X \\to I\\times f^*Z \\to H^* Z \\to Z$, and this both restricts to \n$\\widetilde{f}$ on $\\{0\\}\\times X$ and covers $H$. To show uniqueness, notice that \n$H(-,x)$ gives a path in $Y$ for each fixed $x\\in X$. Any lift $\\widetilde{H}'$ of $H$ \nlikewise gives a path $\\widetilde{H}'(-,x)$ for fixed $x$. Since lifts of paths are unique, the \n$\\widetilde{H}'(-,x)$ must agree with $\\widetilde{H}(-,x)$ for all $x$, hence \n$\\widetilde{H}'=\\widetilde{H}$.\n\\end{proof}\n\nWe can now give the promised proof of Theorem~\\ref{thm:cov_space_gives_faithful_functor}.\n\n\\begin{proof}\n(of Theorem~\\ref{thm:cov_space_gives_faithful_functor}) Given paths $\\gamma,\\eta\\colon z_1 \\rightsquigarrow z_2$ in $Z$, and an endpoint-fixing homotopy \n$H\\colon I\\times I \\to X$ between $\\pi\\circ \\gamma$ and $\\pi\\circ\\eta$, we can lift $H$ to give\na homotopy from $\\gamma$ to a lift of $\\pi\\circ \\eta$. Since $H$ fixes endpoints, the lifts of\nthe constant paths $H\\big|_{I\\times\\{i\\}}$, for $i=0,1$ are path in the fibre, discrete spaces.\nHence these paths are constant, and $\\widetilde{H}$ is a homotopy fixing endpoints.\nSince $\\eta$ is a lift of $\\pi\\circ \\eta$, unique path lifting gives that $\\widetilde{H}$ is \nin fact a homotopy (fixing endpoints) from $\\gamma$ to $\\eta$. Thus $\\gamma$ and $\\eta$ give\nthe same element in $\\Pi_1(Z)(z_1,z_2)$, and the induced map in injective as required. \n\\end{proof}\n\nUntil now, a lot of our resuls only give bounds on or estimates between the fibres of a covering\nspace and the fundamental group of the base space. However, we can actually get an exact result, given a certain kind of covering space\n\n\\begin{theorem}\nIf $\\pi\\colon (Z,z) \\to (X,x)$ is a covering space with $Z$ path connected, then  \n\\[\nZ_x \\simeq \\pi_1(X,x)/\\pi_1(Z,z),\n\\]\nas sets with $\\pi_1(X,x)$-action.\n\\end{theorem}\n\n\\lecturenum{10}\n\n\\begin{proof}\n\nThere\\marginnote{For a group $G$, sets with a $G$-action will be called \n\\emph{$G$-sets}.}  is in fact a canonical isomorphism, induced in the following way. For \ngroup $G$ and any transitive $G$-set $S$, and a point $p\\in S$, then the map $G \\to S$, \n$g\\mapsto g\\cdot s$ induces a well-defined bijection $G/\\mathrm{Stab}(s) \\to S$, where \n$\\mathrm{Stab}(s) < G$ is the subgroup of elements $g$ such that $g\\cdot s = s$ (the \n\\emph{stabiliser subgroup}). Notice that for \\emph{any} subgroup $H< G$, $G/H$ inherits \na $G$-action from the multiplication in $G$. And the bijection $G/\\mathrm{Stab}(s) \\to S$ is \ncompatible with the $G$-actions\\marginnote{that is, \\emph{equivariant}}.\n\nWe apply this to the transitive $\\pi_1(X,x)$-set $Z_x$, where we know the action is \ntransitive as $Z$ is path-connected. This gives an isomorphism \n$\\pi_1(X,x)/\\mathrm{Stab}(z) \\xrightarrow{\\simeq} Z_x$, and it remains to identify \n$\\mathrm{Stab}(z) < \\pi_1(X,x)$. But note that if for some $[\\gamma] \\in \\pi_1(X,x)$, \n$\\gamma_*(z)=z$, this means that the lift $\\widetilde{\\gamma_z}$ beginning at $z$ also \nends at $z$, so is a loop in $Z$. Thus $\\mathrm{Stab}(z)$ consists of the homotopy \nclasses of loops in $X$ that come from loops in $Z$, that is, $\\mathrm{Stab}(z) = \n\\pi_1(Z,z)$.\n\\end{proof}\n\n\n\n\n\\begin{corollary}\\label{cor:fibre_of_univ_cov_space}\nIf $\\pi\\colon (Z,z) \\to (X,x)$ is a covering space with $Z$ simply-connected, then the map\n\\[\n\\pi_1(X,x) \\to Z_x\n\\]\nis an isomorphism of $\\pi_1(X,x)$-sets.\n\\end{corollary}\n\n\n\\begin{proof}\nSince $Z$ is simply-connected, $\\pi_1(Z,z) = 1$, and so $\\pi_1(X,x) \\to Z_x$ is an isomorphism\nof sets with $\\pi_1(X,x)$-action.\n\\end{proof}\n\n\\begin{example}\nWe now can say that $\\pi_1(S^1,1)$ is not just infinite (see Example~\\ref{eg:piS^1_infinite})\n but countable, since it is in bijection with the fibre $\\ZZ$ of the simply-connected covering space $\\RR \\to S^1$.\n\\end{example}\n\nBut even better, we have not just a bijection, but Corollary \n\\ref{cor:fibre_of_univ_cov_space} gives a \\emph{faithful permutation representation}: \ngiven $[\\gamma],[\\eta]\\in \\pi_1(X,x)$, there is some $z\\in Z_x$ such that \n$\\gamma_*(z)\\neq \\eta_*(z)$, which is equivalent to $\\pi_1(X,x) \\to \\Aut(Z_x)$ being \ninjective. Thus we have represented the fundamental group of $(X,x)$ as a permutation \ngroup, where we can do more concrete computations.\n\n\\begin{corollary}\nFor $(Z,z)\\to (X,x)$ a simply-connected covering space, $\\pi_1(X,x)$ acts freely on $Z_x$.\n\\end{corollary}\n\nAnd now we can give the first example of an actually calculated, non-trivial fundamental group.\n\n\\begin{theorem}\n$\\pi_1(S^1,1) \\simeq \\ZZ$.\n\\end{theorem}\n\n\\begin{proof}\nWe have the simply-connected covering space $\\RR \\to S^1 = \\RR/\\ZZ$, with fibre over \n$1\\in S^1$ being the integers. The inclusion $[0,1]\\to \\RR$ is a lift of the loop $\\gamma$ \ngoing once around the circle, and all lifts are translates of this, so that the action of \n$\\gamma$ on the fibre $\\ZZ$ is translation by $1$. The loop $\\gamma$ generates a subgroup\nwhose action on $\\ZZ$ is transitive, hence $\\gamma$ generates all of $\\pi_1(S^1,1)$,\nwhich must then be infinite cyclic, hence $\\ZZ$.\n\\end{proof}\n\nAs a result, for any subset $A\\subset S^1$, the fundamental groupoid $\\Pi_1(S^1,A)$ has as \nobjects the set $A$, for every $x\\in A$, $\\pi_1(S^1,x) \\simeq \\ZZ$, and for any two points\n$x,y\\in S^1$, the hom-set $\\Pi_1(S^1,A)(x,y)$ is isomorphic as a set to $\\ZZ$.\n\n\nBut how do we calculate $\\pi_1$ in general? Or better, $\\Pi_1$? Recall that $\\Pi_1(X,A) = \\Pi_1(X_1,A\\cap X_1) \\sqcup\n\\Pi_1(X_2,A\\cap X_2)$.\nFor instance, if $X_1$ and $X_2$ are the only path components of $X$, and \n$\\exists x\\in A\\cap X_i$ for $i=1,2$, then every point in $X$ is connected by a path to a point\nin $A$. This means the fundamental goups of the two path components are captured.\n\n\\begin{example}\nConsider $\\Pi_1(S^1\\sqcup S^1,1\\sqcup 1)$, which is a groupoid with two objects, both of which\nhave automorphism groups given by $\\ZZ$.\n\\end{example}\n\nSo we are going to focus a bit on calculating the fundamental group(oid) for path \nconnected spaces. The easiest way to make a new connected space from two other connected spaces $X,Y$, say\\marginnote{recall that we are taking spaces to be semilocally path connected, so that components and path components coincide}, is to take a point in each, $x\\in X$, $y\\in Y$, and identify $x$ and $y$.\n\n\\begin{definition}\nGiven\\marginnote{A key property of the join is that given a pointed space $(M,m)$ and a pair of pointed \nmaps $f\\colon (X,x) \\to (M,m)$, $g\\colon (Y,y) \\to (M,m)$, there is a unique pointed map \n$\\langle f,g\\rangle\\colon (X\\vee Y,\\ast) \\to (M,m)$ such that $f = \\mathrm{in}_L\\circ \n\\langle f,g\\rangle$ and $g = \\mathrm{in}_R\\circ \\langle f,g\\rangle$.} two pointed spaces $(X,x)$ and $(Y,y)$, the \\emph{join} $X\\vee Y$ is the quotient \nspace $(X\\sqcup Y)/(x\\sim y)$. It has a basepoint given by $*:=[x] = [y]$, and the \ninclusion maps of $(X,x)\\xrightarrow{\\mathrm{in}_L} (X\\vee Y,*) \\xleftarrow{\\mathrm{in}_R} (Y,y)$ are pointed.\n\\end{definition}\n\n\n\nSince we have pointed maps, we get from functoriality of $\\pi_1$ two \nhomomorphisms $\\pi_1(X,x) \\to \\pi_1(X\\vee Y,*) \\leftarrow \\pi_1(Y,y)$. \nIf we already know what the fundamental groups of $X$ and $Y$ are, then we \ncan try to leverage this knowledge to tell us something about the fundamental group\nof the join. For instance, taking $X = Y = S^1$, we get homomorphisms \n\\[\n\\ZZ \\xrightarrow{\\pi_1(\\mathrm{in}_L)} \\pi_1(S^\\vee S^1,\\ast) \\xleftarrow{\\pi_1(\\mathrm{in}_R)} \\ZZ\n\\]\nLet\\marginnote{%\n\\begin{tikzpicture}[scale=1.5]\n\\draw[decoration={markings, \n                    % mark=at position 0 with {\\arrow{>}};,\n                    mark=at position 0.5 with {\\arrow{>}}},\n                    postaction={decorate}]\n        ({-1/(2*sqrt(2))},{1.5+3/sqrt(2)}) circle (0.5);\n\\draw (-1.05,{1.5+3/sqrt(2)}) node {\\small $a_1$};\n\\fill (0,{1.5+2.5/sqrt(2)}) circle (0.03);\n\\draw (-0.15,{1.9+2/sqrt(2)}) node {\\small $A$};    \n\n\\draw[decoration={markings, \n                    mark=at position 0 with {\\arrow{>}};,\n                    mark=at position 0.5 with {\\arrow{>}}},\n                    postaction={decorate}]\n        ({1/(2*sqrt(2))},{1.5+2/sqrt(2)}) circle (0.5);\n\\draw (-0.3,{1.5+2/sqrt(2)}) node {\\small $b_1$};\n\\draw (1.05,{1.5+2/sqrt(2)}) node {\\small $b_2$};\n\\fill (0,{1.5+1.5/sqrt(2)}) circle (0.03);\n\\draw (0.15,{1.9+1/sqrt(2)}) node {\\small $B$};\n\n\\draw[decoration={markings, \n                    mark=at position 0 with {\\arrow{>}};,\n                    mark=at position 0.5 with {\\arrow{>}}},\n                    postaction={decorate}]\n        ({-1/(2*sqrt(2))},{1.5+1/sqrt(2)}) circle (0.5);\n\\draw (0.3,{1.5+1/sqrt(2)}) node {\\small $a_3$};\n\\draw (-1.05,{1.5+1/sqrt(2)}) node {\\small $a_2$};\n\\fill (0,{1.5+0.5/sqrt(2)}) circle (0.03);\n\\draw (-0.15,{1.9}) node {\\small $C$};        \n\n\\draw[decoration={markings, \n                    mark=at position 0 with {\\arrow{<}}},\n                    postaction={decorate}]\n        ({1/(2*sqrt(2))},1.5) circle (0.5);\n\\draw (1.05,{1.5}) node {\\small $b_3$};\n\n\\draw[->] (0,1) -- (0,0.5)  node[midway,left] {\\small $\\pi_1$} ;\n\n\\draw[decoration={markings, mark=at position 0.25 with {\\arrow{>}}},postaction={decorate}]\n        (-0.5,0) circle (0.5);\n\\draw (-0.6,0.6) node {\\small $a$};\n\\draw[decoration={markings, mark=at position 0.25 with {\\arrow{<}}},postaction={decorate}]\n        (0.5,0) circle (0.5);\n\\draw (0.63,0.62) node {\\small $b$};\n\\fill (0,0) circle (0.03);\n\\draw (0.1,0) node {\\small $\\ast$};\n\n\n\\end{tikzpicture}}\nus define $a,b\\in \\pi_1(S^1\\vee S^1,\\ast)$ to be the classes $\\pi_1(\\mathrm{in}_L)(1)$ and\n$\\pi_1(\\mathrm{in}_R)(1)$ respectively.\n\nDefine the covering space $Z_1 \\xrightarrow{\\pi_1} S^1\\vee S^1$ as at right, where \n$A,B,C \\mapsto \\ast$, and $a_i\\mapsto a$, $b_i\\mapsto b$, $i=1,2,3$. Then we get a \nrepresentation $\\rho_1\\colon \\pi_1(S^1\\vee S^1,\\ast)\\to \\Aut\\{A,B,C\\} \\simeq S_3$. \nLooking at how paths representing $a$ and $b$ lift, we get $\\rho_1(a) = (BC)$ and \n$\\rho_1(b) = (AB)$, cycles in $S_3$. Calculating $\\rho_1(ab)$ we get $(ABC)$, and \nsimilarly for $\\rho_1(ba)$, to get $(ACB)$, so that $rho_1(ab) \\neq \\rho_1(ba)$.\nAs a result, we must have had $ab \\neq ba$ in $\\pi_1(S^1\\vee S^1,\\ast)$, or in other words,\nthe fundamental group of $S^1\\vee S^1$ is \\textbf{non-abelian}.\n\nBy a judicious choice of covering spaces, we can also prove that the two homomorphism \n$\\ZZ \\to \\pi_1(S^1\\vee S^1,\\ast)$ are injective, so that $a$ and $b$ generate infinite \ncyclic subgroups. We will\\marginnote{We can present $\\ZZ\\ast\\ZZ$ as $\\langle a,b|\\ \n\\rangle$, which has as elements $a^{n_1}b^{m_1}\\ldots a^{n_k}b^{m_k}$ for $k\\geq 1$ and \n$n_i,m_i\\in \\ZZ$, with $a^0=e=b^0$} later prove that $\\pi_1(S^1\\vee S^1,\\ast) \\simeq \n\\ZZ\\ast \\ZZ = F_2$, a free group on the generators $a,b$.\n\n\n\\lecturenum{11}\n\n\\begin{definition}\nThe \\emph{free group on $n$-symbols}, $F_n$ is any group with presentation \n\\[\n\t\\langle x_1,\\ldots,x_n\\mid\\ \\rangle.\n\\]\nThat is, generators $x_1,\\ldots,x_n$ and no relations.\n\\end{definition}\n\nThe symbols are of course arbitrary. Elements in $F_n$ are (finite) words in $x_i$ and $x_i^{-1}$, with the empty word $()$ being the identity element, and with concatenation of words being the multiplication in $F_n$.\n\n\\begin{definition}\nGiven groups $G$ and $H$, the \\emph{free product} $G\\ast H$ of $G$ and $H$ is a group equipped with homomorphisms $i\\colon G\\to G\\ast H$, $j\\colon H \\to G\\ast H$, satisfying the following property: given any group $K$ and homomorphisms $\\phi\\colon G \\to K$, $\\psi\\colon H\\to K$, there exists a unique homomorphism $\\kappa\\colon G\\ast H \\to K$ such that $\\phi = i\\circ \\kappa$ and $\\psi=j\\circ \\kappa$.\n\\end{definition}\n\n\nWe can write things like this:\n\\[\n\t\\xymatrix{\n\t\t& H \\ar[d]^j \\ar@/^1pc/[rdd]^\\psi &\\\\\n\t\tG \\ar[r]^i \\ar@/_1pc/[drr]_\\phi & G\\ast H \\ar@{-->}[dr]^{\\exists!}_\\kappa &\\\\\n\t\t&& K\n\t}\n\\]\nThe existence of the unique $\\kappa$ given the data of $\\phi$ and $\\psi$ is the \\emph{universal property} of the free product.\n\nIf\\marginnote{here each $R_i$ and $Q_j$ are \\emph{relations}: equations involving the given generators of $G$ and $H$ respectively} $G = \\langle g_1,\\ldots,g_m\\mid R_1,\\ldots, R_n\\rangle$  and $H = \\langle h_1,\\ldots, h_k \\mid Q_1,\\ldots, Q_l\\rangle$ are presentations of $H$ and $G$, then\n\\[\n\tG\\ast H = \\langle g_1,\\ldots,g_m,h_1,\\ldots,h_k \\mid R_1,\\ldots, R_n,Q_1,\\ldots,Q_l\\rangle\n\\]\n\n\nThe free product of groups is an example of a more general construction, the \\emph{free product with amalgamation}, but this is again an example of a general construction that makes sense in an arbitrary category.\n\n\\begin{definition}\nLet $\\cC$ be an arbitrary category. A \\emph{pushout square} is a commutative square\n\\[\n\t\\xymatrix{\n\t\tW\\ar[r]^b \\ar[d]_a & Y \\ar[d]^d \\\\\n\t\tX \\ar[r]_c & P\n\t}\n\\]\nin $\\cC$ such that for any pair of morphisms $X\\xrightarrow{f} Z \\xleftarrow{g} Y$ such that \n$f\\circ a = g\\circ b$,\\marginnote{this unique existence is the \\emph{universal property} of the pushout}\n\\[\n\t\\exists!\\ P\\xrightarrow{k} Z \\quad \\text{such that} \\quad  f=k\\circ c \\text{ and } g=k\\circ d.\n\\]\n\\end{definition}\n\n\\begin{example}\nConsider a topological space $X$, and $U,V \\subseteq X$ subspaces such that the $\\{U^o,V^o\\}$ is an open cover of $X$. Then\\marginnote{$U$ and $V$ here are `glued together' along $U\\cap V$ to give $X$}\n\\[\n\t\\xymatrix{\n\t\tU\\cap V\\ar[r] \\ar[d] & V \\ar[d] \\\\\n\t\tU \\ar[r] & X\n\t}\n\\]\nis a pushout square in $\\Top$, where all maps are the inclusions.\n\\end{example}\n\nIn the above example, we call $\\{U,V\\}$ a cover of $X$ by nhds, since at least one of $U$ and $V$ is a nhd of each point in $X$.\n\n\\begin{example}\nFor any pair of pointed spaces $(X,x)$ and $(Y,y)$, \n\\[\n\t\\xymatrix{\n\t\t(\\pt,\\pt)\\ar[r] \\ar[d] & (Y,y) \\ar[d]^{\\mathrm{in}_R} \\\\\n\t\t(X,x) \\ar[r]_-{\\mathrm{in}_L} & (X\\vee Y,\\ast)\n\t}\n\\]\nis a pushout square in $\\Top_*$.\n\\end{example}\n\n\\begin{example}\nFor arbitrary groups $G$ and $H$,\n\\[\n\t\\xymatrix{\n\t\t1\\ar[r] \\ar[d] & H \\ar[d] \\\\\n\t\tG \\ar[r] & G\\ast H\n\t}\n\\]\nis a pushout square in $\\Grp$.\n\\end{example}\n\n\\begin{example}\nRecall the groupoid $\\mathbf{2}$ with two objects, $0$ and $1$ and a unique arrow between any ordered pair of objects. The square\n\\[\n\t\\xymatrix{\n\t\t\\disc(\\{0,1\\}) \\ar[r] \\ar[d] & \\mathbf{2}\\ar[d]^{(0\\to 1)\\mapsto (\\bullet \\xrightarrow{1} \\bullet)} \\\\\n\t\t\\pt \\ar[r]&  \\mathbb{B}\\ZZ\n\t}\n\\]\nis a pushout in $\\Gpd$.\n\\end{example}\n\n\\begin{example}\nConsider the category $\\Vect$ of vector spaces (over some fixed field) and linear maps. The square\n\\[\n\t\\xymatrix{\n\t\tW\\ar[r]^{L_2} \\ar[d]_{L_1} & V_2 \\ar[d] \\\\\n\t\tV_1 \\ar[r] & (V_1\\oplus V_2)/J(W)\n\t}\n\\]\nwith $J\\colon W\\to V_1\\oplus V_2$ the map $w\\mapsto (L_1(w),-L_2(w))$ is a pushout.\n\\end{example}\n\n\n\\begin{theorem}[Seifert--van Kampen theorem]\nLet $X$ be a space, and $\\{U,V\\}$ a cover by nhds.\\marginnote{A cover by nhds is equivalent to the interiors being an open cover.} Then\n\\[\n\t\\xymatrix{\n\t\t\\Pi_1(U\\cap V) \\ar[r]^-{i_V} \\ar[d]_{i_U} & \\Pi_1(V) \\ar[d]\\\\\n\t\t\\Pi_1(U) \\ar[r] & \\Pi_1(X)\n\t}\n\\]\nis a pushout square in $\\Gpd$.\n\\end{theorem}\n\n\\begin{rem}\nIt is \\textbf{not} immediate that this is a pushout just because the square of spaces is \na pushout in $\\Top$, because we need to check the universal property for arbitrary \ngroupoids $\\Gamma$ and (compatible) functors $\\Pi_1(U) \\to \\Gamma \\leftarrow \\Pi_1(V)$.\n\\end{rem}\n\n\n\\begin{proof}\nWe need to start with an arbitrary commutative square\n\\[\n\t\\xymatrix{\n\t\t\\Pi_1(U\\cap V) \\ar[r]^-{i_V} \\ar[d]_{i_U} & \\Pi_1(V) \\ar[d]^G\\\\\n\t\t\\Pi_1(U) \\ar[r]_-F & \\Gamma\n\t}\n\\]\nand construct a functor $K\\colon \\Pi_1(X) \\to \\Gamma$ compatible with $F$ and $G$. That \nis, we need to construct a pair of functions $K_0\\colon \\Pi_1(X)_0 = X \\to \\Gamma_0$ and \n$K_1\\colon \\Pi_1(X)_1 \\to \\Gamma_1$ that together define a functor as needed.\n\nFirstly, consider arbitrary $x\\in X$. If $x\\in U$, then define $K_0(x) = F(x)$, and if \n$x\\in V$, define $K_0(x) = G(x)$. If $x\\in U\\cap V$, then since $F\\circ i_U = G\\circ \ni_V$, $F(x) = G(x)$, and so $K_0$ is well-defined.\n\nWe will first define $K_1$ on actual paths, and then show it is invariant under passing \nto homotopy classes. Suppose that $\\gamma\\colon I\\to X$ factors through $U \\into X$. \nThen we can define $K_1(\\gamma) = F_1(\\gamma)$, and similarly, if it factors through \n$V\\into X$, then define $K_1(\\gamma) = G_1(\\gamma)$. Again, if $\\gamma$ lands in $U\\cap \nV$ then it is unambiguously defined, by the commutativity of the square as given. This \nis compatible with source and target maps, since the start- and end-points of a path in \n$U$ lie in $U$, and similarly for $V$, and $F$ and $G$ are functors. It is compatible \nwith concatenation of paths that lie entirely inside $U$ or inside $V$, again using the \nfact $F$ and $G$ are functors. Constant paths are sent by $K_1$ to identity morphisms in \n$\\Gamma$, as needed, since they are by $F$ and $G$. Also notice that if we reparametrise \nthe path $\\gamma$ to $\\gamma\\circ \\sigma$, this gives an equal morphism in $\\Pi_1(U)$ or \n$\\Pi_1(V)$ as appropriate, so that $K_1$ is independent of the parametrisation of the \npath.\n\nWe now need to consider a general path $\\gamma\\colon I\\to X$ and define $K_1(\\gamma)$. \nIf we pull back the open cover $\\{U^o,V^o\\}$ along $\\gamma$ to an open cover of $I$, we \ncan find a partition\\marginnote{using the Lebesgue covering lemma} $0=t_0<t_1<\\ldots < \nt_n<t_{n+1}=1$ of $I$ such that for each $i=0,\\ldots n$, $\\gamma\\big|_{[t_i,t_{i+1}]}$ \nfactors through either $U\\into X$ or $V\\into X$ (or both). Define $\\gamma_i \\colon I \n\\simeq [t_i,t_{i+1}] \\to X$, so that $\\gamma$ is homotopic to the concatenation of all \nthe $\\gamma_i$s, and in fact $\\gamma$ is a reparametrisation of the concatenation. We \nhave already defined $K_1(\\gamma_i)$, so let $K_1(\\gamma) = \nK_1(\\gamma_0)K_1(\\gamma_1)\\cdots K_1(\\gamma_n) \\in \\Gamma_1$. Note that by the \ncompatibility of $K_1$ with concatenation \\emph{inside $U$ and $V$}, if we pass to a \nfiner partition of $I$, we get a different sequence $\\gamma_j$, but the composite of the \n$K_1(\\gamma_j)$s is equal to what we just defined. Since any two partitions have a \ncommon refinement, the definition of $K_1$ is independent of the choice of partition. \nAgain, since the original given square commutes, there is no ambiguity when a given \n$\\gamma_i$ factors through $U\\cap V$.\n\nWe now need to show that given an endpoint-fixing homotopy $H\\colon I\\times I \\to X$ \nbetween paths $\\gamma$ and $\\eta$, then $K_1$ maps them both to the same morphism in \n$\\Gamma$.\n\nConsider\\marginnote{%\n\\begin{tikzpicture}\n\\fill (0,0) circle (0.05) node[anchor=east] {$h(0,0)$};\n\\draw[decoration={markings, mark=at position 0.75 with {\\arrow{>}}},postaction={decorate}] \n\t\t(0,0) -- (2,0) -- (2,2);\n\\draw (2,1) node[anchor=west] {$\\gamma_0$};\n\\draw[decoration={markings, mark=at position 0.25 with {\\arrow{>}}},postaction={decorate}] \n \t\t(0,0) -- (0,2) -- (2,2);\n\\draw (0,1) node[anchor=east] {$\\gamma_1$};\n\\fill (2,2) circle (0.05) node[anchor=west] {$h(1,1)$};\n\\end{tikzpicture}\n}\nas a warmup, an arbitrary map $h\\colon I^2\\to X$, and define paths \n$\\gamma_0,\\gamma_1\\colon h(0,0) \\rightsquigarrow h(1,1)$ in $X$ as the concatenations\n\\begin{align*}\n\\gamma_0 & := h(-,0)\\# h(1,-),\\\\\n\\gamma_1 & := h(0,-)\\# h(-,1).\n\\end{align*}\n\nThen there is an endpoint-fixing homotopy $\\gamma_0 \\sim \\gamma_1$. It is sufficient to \ndefine an endpoint-fixing homotopy $I\\times I \\to I^2$ between the two paths around the \nsquare that arise from taking $h$ to be the identity map $I^2\\to I^2$.\n\\begin{center}\n\\begin{tikzpicture}\n\\draw (0,0) rectangle +(3,3);\n\\draw[ultra thick] (0,0) -- (0,3) (3,0) -- (3,3); \n\\foreach \\n in {1,...,5}\n{\n\t\\draw (1.5,0) -- (0,\\n*1.5/5);\n\t\\draw (1.5,0) -- (3,\\n*1.5/5);\n\t\\draw (1.5,3) -- (0,3-\\n*1.5/5);\n\t\\draw (1.5,3) -- (3,3-\\n*1.5/5);\n}\n\\draw[->] (3.5,1.5) -- (4.5,1.5);\n\\draw[rotate around={45:(7,1.5)}] (6,0.5) rectangle +(2,2);\n\\fill[rotate around={45:(7,1.5)}] (6,2.5) circle (0.05);\n\\fill[rotate around={45:(7,1.5)}] (8,0.5) circle (0.05);\n\\end{tikzpicture}\n\\end{center}\n\nHere the function is constant on the vertical edges of the square at the two vertices, \nand on each diagonal line as shown maps to the corresponding edges of the square on the \nright.\nThus if $h$ factors through one of $U$ or $V$, $K_1(\\gamma_0) = K_1(\\gamma_1)$, since \n$[\\gamma_0] = [\\gamma_1]$ in one of $\\Pi_1(U)$, $\\Pi_1(V)$.\n\n\\lecturenum{12}\n\nBy\\marginnote{%\n\\begin{tikzpicture}\n\\draw (0,0) rectangle (3,3);\n\\draw (1.75,0) node[below] {$\\gamma$};\n\\draw (1.25,3) node[above] {$\\eta$};\n\\draw[ultra thick] (0,0) -- (0,3) (3,0) -- (3,3);\n\\foreach \\x in {0,...,5}\n{\n\t\\foreach \\y in {0,...,5}\n\t\\draw (\\x/2,\\y/2) rectangle (\\x/2+0.5,\\y/2+0.5);\n}\n\\draw[|-|] (3.3,1.5) -- node[right] {$\\delta$}  (3.3,2);\n\\draw[very thick,red] (0,0) -- (1,0) -- (1,1.5) -- (1.5,1.5) -- (1.5,2) --\n\t\t(2.5,2) -- (2.5,2.5) -- (3,2.5) -- (3,3);\n\\draw[very thick,red,dotted] (1,1.5) -- (1,2) -- (1.5,2);\n\\end{tikzpicture}\n} the Lebesgue covering lemma applied $(I^2,d_\\infty)$ and the open cover \n$\\{H^{-1}(U^o), H^{-1}(V^o)\\}$, there is a some $\\delta > 0$ such that every square of \nside-length $\\leq\\delta$ in $I^2$ (a \\emph{$\\delta$-square}) is contained in one of \n$H^{-1}(U^o)$ and $H^{-1}(V^o)$. Thus $H\\big|_{[a,a+\\delta]\\times[b,b+\\delta]}$ factors \nthrough one of $U$ or $V$, for any suitable $(a,b)\\in I^2$. We then cover $I^2$ by such \n$\\delta$-squares, noting that this also give a partition of $I$ into intervals such that \nboth $\\gamma$ and $\\eta$ restricted to such intervals factor through one of $U$ or $V$, \nso that $K_1$ is defined on $\\gamma$ and $\\eta$.\n\nNow we can use the fact about paths between opposite vertices of the square \nbeing\\marginnote{all homotopies here will have fixed endpoints} homotopic to iteratively \nshow that $K_1(\\gamma) = K_1(\\eta)$. Firstly, note that $\\gamma$ is homotopic to the \npath gotten by concatenating with the constant path up the right side of the square, and \nsimilarly, $\\eta$ is homopic to the path gotten by concatenating with the constant path \nup the left side of the square. Then the big homotopy is pasted together from homotopies \nthat move one square at a time, each of which land in one of $U$ or $V$. Then the two \npossible red paths shown in the figure, for example, get mapped by $K_1$ to the same morphism \nin $\\Gamma$. All up, these show that $K_1(\\gamma) = K_1(\\eta)$, and so $K_1$ is \nwell-defined on homotopy classes of paths. By the construction of $K_1$, it preserves \ncomposition, so is functorial, and we are done.\n\\end{proof}\n\nThis is a powerful theorem, but sometimes not the best for computation, in this form. It \nwould be good to have a version for more general $\\Pi_1(X,A)$, for smaller $A\\subset X$, \nor even $\\pi_1(X,x)$. To do this, we need a general categorical lemma\n\nGiven\\marginnote{%\n$\\xymatrix@!=2ex{\n\tA_1 \\ar[rr] \\ar[dd] \\ar[dr] && B_1 \\ar[dr] \\ar[dd]|\\hole\\\\\n\t& A_2 \\ar[rr] \\ar[dd] && B_2 \\ar[dd]\\\\\n\tC_1\\ar[dr] \\ar[rr]|\\hole && D_1\\ar[dr] \\\\\n\t& C_2 \\ar[rr] && D_2\n}$\\\\\n\\noindent A morphism from the back square to the front square in $\\cC^\\square$} \nan arbitrary category $\\cC$, we can define a category $\\cC^\\square$ with objects \ncommutative squares in $\\cC$, and morphisms commutative \\emph{cubes}: cubes of objects \nand morphisms such that every face is a commutative square.\n\n\\begin{definition}\nIn a category $\\cC$, an object $V$ is a \\emph{retract} of an object $W$, if\\marginnote{the morphism $r$ is called a \\emph{retraction}} there are \nmorphisms $i\\colon V\\to W$ and $r\\colon W\\to V$ such that $r\\circ i = \\id_V$.\n\\end{definition}\n\nFor example, in $\\Vect$, any subspace $V$ of $\\RR^n$ is a retract, by taking $i$ to be \nthe inclusion, and $r$ to be orthogonal projection onto $V$. In $\\Set$, given a set $S$ \nand a subset $T \\subseteq S$ with some chosen $t_0\\in T$ we get a retract given by the \ninclusion and the function $r\\colon S\\to T$ defined by $r(t) = t$, for $t\\in T$, $r(s) = \nt_0$ for $s\\in S\\setminus T$. A more serious example is:\n\t\t\n\\begin{example}\\label{eg:retracts_of_Pi1}\nGiven a space\\marginnote{This generalises the case from Assignment 2, where $A'=\\{x\\}$} \n$X$, with subspaces $A' \\subseteq A$ such that every point in $A$ is \nconnected by a path in $X$ to a point in $A'$. Then $\\Pi_1(X,A')$ is a retract of \n$\\Pi_1(X,A)$. The case we will most care about is $A=X$, and various $A'\\subseteq X$.\n\\end{example}\n\nWe can talk about what it means for a commutative square in a category $\\cC$ to be a \nretract of another commutative square in $\\cC$, by looking at retracts in $\\cC^\\square$. \nRecall that pushout squares are special examples of commutative squares. Also, to check \nthat a morphism of commutative squares is a retraction, it is enough to check that it is \na retraction at each vertex (that is, we have four retractions in $\\cC$, one for each \nvertex of the square)\n\n\\begin{lemma}\\label{lemma:retracts_of_pushouts}\nRetracts of pushout squares are pushout squares.\n\\end{lemma}\n\n\\begin{proof}\nExercise.\n\\end{proof}\n\nWe wish to apply Lemma~\\ref{lemma:retracts_of_pushouts} to the pushout square in \n$\\Gpd$---hence an object of $\\Gpd^\\square$---from the Seifert--van Kampen theorem, which \ninvolved fundamental groupoids $\\Pi_1(X)$ etc. Retracts (in $\\Gpd$) as in \nExample~\\ref{eg:retracts_of_Pi1} will be assembled to give a retract in $\\Gpd^\\square$ that\nis made up of smaller and more manageable groupoids.\n\n\\begin{theorem}[Relative Seifert--van Kampen theorem]\nLet $X$ be a space, $\\{U,V\\}$ be a cover by nhds, and $A\\subseteq X$ a given subspace. \nIf in each of the four pairs $(X,A)$, $(U,A\\cap U)$, $(V,A\\cap V)$, $(U\\cap V,A\\cap \nU\\cap V)$, every point\\marginnote{so a point in $U$ is connected by a path in $U$ to a point in $A\\cap U$, and so on} in the larger space is connected by a path (in that space) to a point in \nthe smaller space, then\n\\[\n\\xymatrix{\n\t\\Pi_1(U\\cap V,A\\cap U\\cap V) \\ar[r] \\ar[d] & \\Pi_1(V,A\\cap V)\\ar[d]\\\\\n\t\\Pi_1(U,A\\cap U) \\ar[r] & \\Pi_1(X,A)\n}\n\\]\nis a pushout square in $\\Gpd$.\n\\end{theorem}\n\n\\begin{proof}\n\nThe hard work involving homotopies etc is already done, we just need to exhibit the \nsquare as shown as a retract in $\\Gpd^\\square$ of the pushout square in the statement of \nthe Seifert--van Kampen theorem. By Example~\\ref{eg:retracts_of_Pi1}, each of the \ngroupoids in the commutative square are, individually, retracts.\nThe inclusion functors\n\\begin{align*}\n\\Pi_1(U\\cap V,A\\cap U\\cap V) & \\into \\Pi_1(U\\cap V)\\\\\n\\Pi_1(U,A\\cap U) & \\into \\Pi_1(U)\\\\\n\\Pi_1(V,A\\cap V) & \\into \\Pi_1(V)\\\\\n\\Pi_1(X,A) & \\into \\Pi_1(X)\n\\end{align*}\ngive a morphism in $\\Gpd^\\square$, so we just need to construct the functors\n\\begin{align*}\n\\Pi_1(U\\cap V,A\\cap U\\cap V) & \\leftarrow \\Pi_1(U\\cap V)\\\\\n\\Pi_1(U,A\\cap U) & \\leftarrow \\Pi_1(U)\\\\\n\\Pi_1(V,A\\cap V) & \\leftarrow \\Pi_1(V)\\\\\n\\Pi_1(X,A) & \\leftarrow \\Pi_1(X)\n\\end{align*}\nthat together give a morphism of commutative squares in the other direction. To do this, \nwe will choose, for each $x\\in X$, a (homotopy class of a) path $\\eta_x\\colon \nx\\rightsquigarrow a_x$, for some $a_x \\in A$, such that if $x\\in U$, take $a_x\\in A\\cap \nU$ and $\\eta_x$ a path in $U$; if $x\\in V$, take $a_x\\in A\\cap V$ and $\\eta_x$ a path in \n$V$; and hence if $x\\in U\\cap V$, it follows that $a_x\\in A\\cap U\\cap V$ and $\\eta_x$ is \na path in $U\\cap V$. Further, if $x\\in A$ already, take $a_x = x$, and $\\eta_x$ the \nconstant path.\n\nThe assignment $x\\mapsto a_x$, and $(x\\stackrel{\\gamma}{\\rightsquigarrow} y) \\mapsto \n(a_x \\rightsquigarrow x \\rightsquigarrow y \\rightsquigarrow a_y)$ gives a functor \n$\\Pi_1(X) \\to \\Pi_1(X,A)$, and this is a retraction. By the specific choices of $a_x$ \nand $\\eta_x$ we made, the restrictions of this functor to the groupoids $\\Pi_1(U)$, \n$\\Pi_1(V)$, $\\Pi_1(U\\cap V)$ land in the corresponding subgroupoids $\\Pi_1(U,A\\cap U)$ \netc, and again give a retraction in each case. We can check that these do indeed give us \na morphism in $\\Gpd^\\square$, which is enough to show we have a retraction in $\\Gpd^\\square$. \n\\end{proof}\n\nWe would like to consider pushouts of groups, since these can be easier in some cases to \ncompute. The statement of the relative Seifert--van Kampen theorem however involves \npushouts of groupoids, so that even if we consider one-obect groupoids associated to \ngroups we need to be careful that the universal property for the pushout in $\\Gpd$ \nimplies the universal property for the pushout in $\\Grp$. Thankfully, this is true, for \nabstract reasons.\n\n\\begin{lemma}\nLet $\\cC$ be a category and let $\\cD \\into \\cC$ be a full subcategory. Let\n\\[\n\\xymatrix{\n\tA\\ar[r] \\ar[d] & B \\ar[d]\\\\\n\tC \\ar[r] & P\n}\n\\]\nbe a commutative square in $\\cD$ that is a pushout square in $\\cC$. Then it is a pushout\nsquare in $\\cD$.\n\\end{lemma}\n\n\\begin{proof}\nWe will check the universal property for the pushout in $\\cC$. Let\n\\[\n\\xymatrix{\n\tA\\ar[r] \\ar[d] & B \\ar[d] \\\\\n\tC \\ar[r] & D\n}\n\\]\nbe an arbitrary commutative square in $\\cD$. Then considering this as a commutative \nsquare in $\\cC$, we have a unique morphism $k\\colon P\\to D$ (in $\\cD$) compatible with \nthe other data as in the definition of pushout square. But since $\\cC$ is a \\emph{full} \nsubcategory, $k$ is a morphism in $\\cC$, and moreover the commuting triangles still \ncommute in $\\cC$. Given any other morphism $P\\to D$ in $\\cC$ making the triangles commute will\nbe equal to $k$ in $\\cD$, and hence in $\\cC$, so the universal property for the pushout\nholds in $\\cC$.\n\\end{proof}\n\nNow we can use the fact that $\\mathbb{B}\\colon \\Grp \\to \\Gpd$ expresses $\\Grp$ as a full \nsubcategory.\n\n\\begin{corollary}\nLet $X$ be a path connected space, $\\{U,V\\}$ a cover by path connected nhds with \n$U\\cap V$ path connected. For $x\\in U\\cap V$, the square\n\\[\n\\xymatrix{\n\t\\pi_1(U\\cap V,x) \\ar[r] \\ar[d] & \\pi_1(V,x) \\ar[d]\\\\\n\t\\pi_1(U,x) \\ar[r] & \\pi_1(X,x)\n}\n\\]\nis a pushout square in $\\Grp$.\n\\end{corollary}\n\n\\begin{proof}\nThe hypotheses on $X$, $U$, $V$ and $x$ imply that the condition of the relative \nSeifert--van~Kampen theorem hold, so that we have a pushout of one-object groupoids. But \nby the above lemma, we get a pushout of groups.\n\\end{proof}\n\nSo we need to know what pushouts of groups look like!\n\n\n\\begin{example}\n\nConsider the cover of the sphere $S^n$, where $n>1$, by $U=S^n\\setminus\\{N\\}$ and \n$V=S^n\\setminus\\{S\\}$, where $N$ and $S$ are a pair of antipodal points (North and South \npoles). Then $U\\cap V \\simeq S^{n-1}\\times (-1,1)$, and all these spaces are path \nconnected, so we can apply the group version of Seifert--van~Kampen. Take a basepoint \n$x\\in S^{n-1} \\subset U\\cap V$. Using stereographic projection, we get that $U\\simeq \n\\RR^n \\simeq V$, hence both of these are contractible, and so $\\pi_1(U,x) = 1 = \n\\pi_1(V,x)$ are both the trivial group. Then by Seifert--van~Kampen we know that\n\\[\n\\xymatrix{\n\t\\pi_1(S^{n-1}\\times(-1,1),x) \\ar[r] \\ar[d] & 1 \\ar[d]\\\\\n\t1 \\ar[r] & \\pi_1(S^n,x)\n}\n\\]\nis a pushout square. If we take an arbitrary group $K$ then to check the universal \nproperty, the data of the homomorphisms $1\\to K \\leftarrow 1$ tells us nothing, the \ncompatibility being automatically satisfied, so we need $\\pi_1(S^n,x)$ to be a group \nsuch that there is a \\emph{unique} homomorphism from it to $K$. But the only group that \nhas a unique homomorphism to any other group is the trivial group. Thus $\\pi_1(S^n,x)=1$ \nfor all $n>1$.\n\\end{example}\n\nThis argument fails for $n=1$ since the cover as constructed in that case results in the \nintersection $U\\cap V$ being the disjoint union of two intervals, so not path connected.\n\n\\lecturenum{13}\n\n\\begin{definition}\n\nLet $G\\xleftarrow{\\phi} L \\xrightarrow{\\psi} H$ be a pair of homomorphisms. The \n\\emph{free product with amalgamation} $G\\ast_L H$ is the group $G\\ast H/\\langle \n\\phi(x)\\psi(x)^{-1}\\rangle$, where $\\langle \\phi(x)\\psi(x)^{-1}\\rangle$ is the smallest normal \nsubgroup generated by the elements $\\phi(x)\\psi(x)^{-1}$ for all $x\\in L$. There are \nhomomorphisms $G\\to G\\ast_L H \\leftarrow H$, and $G\\ast_L H$ satisfies the universal \nproperty of the pushout in $\\Grp$.\n\n\\end{definition}\n\nNote\\marginnote{this description also works for groups that aren't finitely presented}\n that if $G = \\langle g_1,\\ldots,g_m \\mid R_1,\\ldots,R_n\\rangle$ and $H=\\langle \nh_1,\\ldots,h_k \\mid Q_1,\\ldots,Q_l\\rangle$, then\n\\[\n\tG\\ast_L H \\simeq \\langle g_1,\\ldots,g_m,h_1,\\ldots,h_k\\mid R_1,\\ldots R_n,Q_1,\\ldots, Q_l,\n\t\t\t\\phi(x)\\psi(x)^{-1}=e \\rangle \n\\]\nwhere we add a new relation for each $x\\in L$, or even just each $x$ running through a \nset of generators for $L$. Note that these relations are equivalent to $\\phi(x) = \\psi(x)$,\nso that we do indeed get a commutative square.\n\n\\begin{example}\\label{eg:one-relator_group}\nConsider a \\emph{finitely generated one-relator group}\\marginnote{Such groups are important in geometric group theory, and much is known about them} \n$G= \\langle g_1,\\ldots,g_m\\mid R=e\\rangle$ ($R$ is an element of the free group generated by $g_1,\\ldots,g_m$). Such a group is a pushout of the form\n\\[\n\\xymatrix{\n\t\\ZZ \\ar[r] \\ar[d]_r & 1 \\ar[d] \\\\\n\tF_m \\ar[r] & G\n}\n\\]\nwhere $R = r(1)$.\n\\end{example}\n\nFor a more specific example, take the \\emph{surface group}\n\\[\n\\langle a_1,\\ldots, a_g,b_1,\\ldots,b_g\\mid \\prod_{i=1}^g [a_i,b_i] \\rangle.\n\\]\nMore generally, one can write a finitely presented group as a pushout\n\\[\n\\xymatrix{\n\tF_n \\ar[r] \\ar[d]_r & 1 \\ar[d] \\\\\n\tF_m \\ar[r] & \\langle g_1,\\ldots,g_m\\mid r(a_1)=e,\\ldots r(a_n)=e\\rangle\n}\n\\]\nwhere we take $F_n \\langle a_1,\\ldots,a_n\\mid\\ \\rangle$.\n\n\n\\begin{rem}\nGoing back to free products, for a moment, a famous example is the free product $\\ZZ/2\\ast \\ZZ/3$, which is isomorphic to the \\emph{modular group} \n\\[\n\tPSL_2(\\ZZ) = \\{2\\times 2 \\text{ integer matrices } A\\mid \\det(A) = 1\\}/\\{\\pm I\\}\n\\]\n\nOne presentation\\marginnote{It is not obvious that this even is a presentation, for a proof see Roger C. Alperin, $PSL_2(\\mathbf{Z}) = \\mathbf{Z}_2 \\ast \\mathbf{Z}_3$, The American Mathematical Monthly Vol. 100, No. 4 (Apr., 1993), pp. 385--386, doi:10.2307/2324963}\n of $PSL_2(\\ZZ)$ is via the generators $S=\\begin{psmallmatrix}0&-1\\\\1&0 \n\\end{psmallmatrix}$ and $ST = \\begin{psmallmatrix}1 &-1 \\\\1 &0 \\end{psmallmatrix}$, \nwhich satisfy $S^2=I$ and $(ST)^3=I$. Note that $PSL_2(\\ZZ)$ acts by fractional linear \ntransformations on the upper half plane $\\mathcal{H} = \\{z\\in \\CC \\mid Im(z) > 0\\}$, \nwith $S\\colon z \\mapsto \\frac{-1}{z}$ and $ST\\colon z\\mapsto \\frac{1-z}{z}$. This action \nis continuous and has discrete orbits, and this is enough to make $\\mathcal{H} \\to \n\\mathcal{H}/PSL_2(Z)$ a covering space.\n\\end{rem}\n\nGive the concrete treatment for the pushout of groups above (that is, as free products \nwith amalgamation), one could hope for a similar treatment for groupoids. And indeed, \none can do this, where instead of group elements being (equivalence classes of) words in \nthe elements of the given groups, morphisms of the pushout groupoid are (equivalence \nclasses of) words in the morphisms of the given groupoids. However, we need to be \ncareful about what we mean by words constructed as a string of morphisms, since not all \nmorphisms can be composed.\n\nWe will not give the most general treatment here, but show how to describe the pushout \nof groupoids in a special case corresponding to a situation arising from an application \nof the Seiert--van~Kampen theorem.\n\n\\begin{example}\n\nLet $X$ be a space, $\\{U,V\\}$ a cover by nhds, and $A\\subseteq U\\cap V$ be such that \nevery path component of $U$, $V$ and $U\\cap V$ contains at least one point in $A$. Then \nwe can apply the Seifert--van~Kampen theorem and get a pushout square\n\\[\n\\xymatrix{\n\t\\Pi_1(U\\cap V,A) \\ar[r]^{i_V} \\ar[d]_{i_U} & \\Pi_1(V,A) \\ar[d]\\\\\n\t\\Pi_1(U,A) \\ar[r] & \\Pi_1(X,A)\n}\n\\]\nNote that all four groupoids have the same set of objects, and that all \nthe functors are the identity on objects (that is: $i_U(a) = a$ and so on). \nFrom the proof of the Seifert--van~Kampen theorem recall that we expressed paths in $X$,\nthat is, morphisms in $\\Pi_1(X)$ as a composite of paths alternating between $U$ and $V$.\nThis is the setup we are interested in calulating in general from a purely algebraic point \nof view. For simplicity, we will just think about the case of $A$ finite, which is the case that turns up in calculations of `reasonable' examples.\n\\end{example}\n\nSuppose we are given a diagram\\marginnote{here $H$ is the capital $\\eta$}\n\\[\n\\xymatrix{\n\t\\Lambda \\ar[r]^F \\ar[d]_G & H  \\\\\n\t\\Gamma \n}\n\\]\nin $\\Gpd$, where all the groupoids have the same finite set $A = \\{a_1,\\ldots,a_N\\}$ of \nobjects, and such that the object components of the functors $F$ and $G$ are all the identity \nfunction. We wish to construct a groupoid $\\Gamma\\ast_\\Lambda H$ that makes this into a \npushout square. Firstly, we can take the set of objects to be $A$ again, and the \nfunctors $\\Gamma \\to \\Gamma\\ast_\\Lambda H \\leftarrow H$ will have as object component \nthe identity function.\n\nGiven any groupoid\\marginnote{and indeed any category} there is a directed graph with \nnodes the objects of the groupoid, and as directed edges the morphism (and we are \nallowed edges from a node to itself, and multiple edges between nodes). And given our \ntwo groupoids $\\Gamma$ and $H$, we can form a graph $\\mathcal{G}$ with set of \nnodes $A$, and the directed edges are the \\emph{disjoint union} of the morphisms of \n$\\Gamma$ (coloured blue) and $H$ (coloured red), and with the identity morphisms removed.\nWe also don't need to include both a morphism and its inverse, since the inverse can be gotten by traversing a directed edge against the indicated direction.\n\\begin{center}\n\\begin{tikzpicture}\n\t[object/.style={circle,fill=black,minimum size=1mm,inner sep=1.5pt},\n\t bluearrowpre/.style={->,shorten <=1pt,thick,blue},\n\t redarrowpre/.style={->,shorten <=1pt,thick,red},\n\t bluearrowpost/.style={<-,shorten <=1pt,thick,blue},\n\t redarrowpost/.style={<-,shorten <=1pt,thick,red}];\n\\node[object,label={west:$a_1$}] (a1) at (0,0) {};\n\\node[object,label={west:$a_2$}] (a2) at (1,1) {}\n\tedge [bluearrowpost] node[auto,swap] {$\\gamma_1$} (a1)\n\tedge [redarrowpre,bend left] node[auto] {$\\eta_2$} (a1.east);\n\\node[object,label={south east:$a_3$}] (a3) at (0,2) {};\n\\node[object,label={east:$a_4$}] (a4) at (3,0) {}\n\tedge [redarrowpost] node[auto,swap] {$\\eta_1$} (a2) \n\tedge [bluearrowpost,bend left] node[auto] {$\\gamma_3$}(a2);\n\\node[object,label={west:$a_5$}] (a5) at (2,3) {}\n\tedge [bluearrowpost] node[auto] {$\\gamma_2$} (a4)\n\tedge [bluearrowpre] node[auto] {$\\gamma_4$} (a2);\n\\node[object,label={north west:$a_6$}] (a6) at (-1,1) {}\n\tedge [redarrowpost] node[auto] {$\\eta_4$}(a3);\n\n\\draw[bluearrowpre] (a3) to [out=90,in=0,loop,looseness=10] node[auto] {$\\gamma_5$} (a3);\n\\draw[redarrowpre] (a5) to [out=90,in=0,loop,looseness=10] node[auto] {$\\eta_3$} (a5);\n\\draw[bluearrowpre] (a6) to [out=180,in=-90,loop,looseness=10] node[auto,swap] {$\\gamma_6$} (a6);\n\\end{tikzpicture}\n\\end{center}\nNow\\marginnote[-4cm]{in the graph shown, composites of various morphisms are omitted, \nfor instance ${\\color{blue}\\gamma_3\\gamma_1\\gamma_2}$} instead of a word in group \nelements, as in the pushout of groups, we take a \\emph{path} in this directed graph, \nalternating between edges that come from $\\Gamma$ and edges that come from $H$. For \ninstance, we could take\n\\[\n\t{\\color{blue}\\gamma_3^{-1}}{\\color{red}\\eta_1}{\\color{blue}\\gamma_2}{\\color{red}(\\eta_3)^5}{\\color{blue}\\gamma_4}\\qquad\\text{or}\\qquad \n\t{\\color{red}\\eta_4}{\\color{blue}(\\gamma_6)^{-3}}{\\color{red}\\eta_4^{-1}}\n\\]\nfrom the above graph. The `empty' path consisting just of an identity arrow is also an \noption. However, we haven't yet actually constructed $\\Gamma\\ast_\\Lambda H$, merely what \nwe might call $\\Gamma \\ast_{\\Lambda_0}H$,\\marginnote{if $\\Lambda$ is already trivial in \nthis sense, then we are done; this is the analogue of the free product of groups} which \nis the pushout where the groupoid $\\Lambda$ is replaced by the trivial groupoid \n$\\disc(\\Lambda_0)$ with the same objects but only identity arrows. What we need to do is \nadd `relations', namely extra equalities between morphisms in $\\Gamma \n\\ast_{\\Lambda_0}H$. What this means is that for each morphism $\\lambda$ in $\\Lambda$, we \nidentify the morphisms ${\\color{blue}F(\\lambda)}$ and ${\\color{red}G(\\lambda)}$, or more \nprecisely, quotient by the equivalence relation on each hom-set of $\\Gamma \n\\ast_{\\Lambda_0}H$ generated by these identifications. For instance, if in the above \ngraph, $\\gamma_1=F(\\lambda_1)$ and $\\eta_1 = G(\\lambda_1)$, then we add the equality \n$\\gamma_1=\\eta_1$. This would have the effect of making\n\\[\n\t{\\color{blue}\\gamma_3}{\\color{red}\\eta_1}{\\color{blue}\\gamma_2}{\\color{red}(\\eta_3)^5}{\\color{blue}\\gamma_4^{-1}} = \n\t{\\color{blue}(\\gamma_3\\gamma_1\\gamma_2)}{\\color{red}(\\eta_3)^5}{\\color{blue}\\gamma_4^{-1}}\t\n\\]\nConcatenation of strings and simplifying is the composition in ${\\Gamma\\ast_\\Lambda H}$.\n\n\\begin{ex}\nProve that this construction makes $\\Gamma\\ast_\\Lambda H$ a groupoid.\n\\end{ex}\n\nIf we are interested in merely looking at the group of morphisms from a single object $a_i$ to itself,\nwhich is the case when calculating a fundamental group using the groupoid Seifert--van~Kampen,\nthen we should look at paths that start and finish at the chosen $a_i$.\n\n\n\\begin{example}\n\nLet us look at an example, arising from an application of Seifert--van~Kampen. Consider \nthe circle $S^1$ as sitting in $\\CC$, and let $U=S^1\\setminus \\{-i\\}$, $V=S^1\\setminus \n\\{i\\}$. All three of these are path connected, and let us take $A={+1,-1} \\subset U\\cap \nV$. This choice of data satisfies the hypotheses of SvK. The pushout square\n\\[\n\\xymatrix{\n\t\\Pi_1(U\\cap V,\\{\\pm1\\}) \\ar[r] \\ar[d] & \\Pi_1(V,\\{\\pm1\\}) \\ar[d]\\\\\n\t\\Pi_1(U,\\{\\pm1\\}) \\ar[r] & \\Pi_(S^1,\\{\\pm1\\})\n}\n\\]\n\ncan be simplified as follows. First, $U \\simeq (-2,2) \\simeq V$, in a way that preserves \n$A=\\{\\pm1\\}$, so that \n\\[\n\\Pi_1(U,\\{\\pm1\\})  \\simeq \\mathbf{2} = (-1 \\stackrel[\\gamma^{-1}]{\\gamma}{\\leftrightarrows} +1)\n\\qquad \\Pi_1(V,\\{\\pm1\\})  \\simeq \\mathbf{2} = (-1 \\stackrel[\\eta]{\\eta^{-1}}{\\leftrightarrows} +1)\n\\]\nand we have omitted the identity arrows. Here $\\gamma$ is a path that runs anticlockwise around $S^1$ from $+1$ to $-1$, and $\\eta$ is a path that runs anticlockwise from $-1$ to $+1$.\nSecond, $\\Pi(U\\cap V,\\{\\pm1\\}) = \\disc(\\{+1,-1\\})$, so\nwe are in the easier situation as first outlined above, where no additional quotient needs\nto be done. The pushout then looks like\n\\[\n\\xymatrix{\n*+[F]{-1\\phantom{\\leftrightarrows}+1} \\ar[r] \\ar[d] \n& \n*+[F]{-1 {\\color{red}\\stackrel[\\eta]{\\eta^{-1}}{\\leftrightarrows}} +1}\\ar[d] \n\\\\\n*+[F]{-1 {\\color{blue}\\stackrel[\\gamma^{-1}]{\\gamma}{\\leftrightarrows}} +1} \\ar[r] &\n\\Pi_1(S^1,\\{\\pm1\\})\n}\n\\]\nThe graph we need so as to generate $\\Pi_1(S^1,\\{\\pm1\\})$ is then\n\\begin{center}\n\\begin{tikzpicture}\n[object/.style={circle,fill=black,minimum size=0.3mm},\n\t bluearrow/.style={->,shorten <=1pt,thick,blue},\n\t redarrow/.style={->,shorten <=1pt,thick,red}];\n\\node (plusone) at (0,0) {$-1$};\n\\node (minusone) at (2,0) {$+1$};\n\n\\draw[bluearrow] (minusone) to [out=135,in=45] node[auto,swap] {$\\eta$}  (plusone) ;\n\\draw[redarrow] (plusone) to [out=-45,in=-135] node[auto,swap] {$\\gamma$} (minusone) ;\n\n\\end{tikzpicture}\n\\end{center}\n\nThen if we wish to consider paths from $+1$ to itself, the only options are the empty \npath, hence the identity arrow, or $(\\eta\\gamma)^n$, or $(\\gamma^{-1}\\eta^{-1})^n = \n(\\eta\\gamma)^{-n}$. Thus $\\pi_1(S^1,+1) \\simeq \\ZZ$.\n\\end{example}\n\n\\begin{ex}\nProve that this construction of $\\Gamma\\ast_\\Lambda H$ is indeed the pushout in $\\Gpd$!\n\\end{ex}\n\nWe will consider one more variant of Seifert--van~Kampen, and this time in brief, \nbecause the details are similar to other versions. If we would like to compute the \nfundamental group of a join, then it is not quite enough to just consider the free \nproduct of the fundamental groups: a join does not automatically come with a cover of \nthe sort we need for SvK. In what follows, assume: $(X,x)$, $(Y,y)$ are pointed spaces \nsuch that there exist nhds $x\\in U\\subseteq X$ and $y\\in V\\subseteq Y$ that are \ncontractible\\marginnote{this implies $U\\vee V$ is contractible to the basepoint \n$\\ast=[x]=[y]$} to $x$ and $y$ respectively, with the contraction fixing the basepoint. \nThen $\\{X\\vee V, U\\vee Y\\}$ is a cover of $X\\vee Y$ by nhds. We have retractions $X\\vee \nV \\to X$ and $U\\vee Y \\to Y$ that preserve the basepoints and which are also homotopy \nequivalences. Thus $\\pi_1(X\\vee V,\\ast)\\simeq \\pi_1(X,x)$ and $\\pi_1(U\\vee Y,\\ast) \n\\simeq \\pi_1(Y,y)$, and $\\pi_1(U\\vee V,\\ast)$ is trivial. If we apply the \nSeifert--van~Kampen theorem to the pushout square\n\\[\n\\xymatrix{\n\t(U\\vee V,\\ast) \\ar[r] \\ar[d] & (U\\vee Y,\\ast) \\ar[d] \\\\\n\t(X\\vee V,\\ast) \\ar[r] & (X\\vee Y,\\ast)\n}\n\\]\nthen we get a pushout square of groups\n\\[\n\\xymatrix{\n\t1 \\ar[r] \\ar[d] & \\pi_1(Y,y) \\ar[d] \\\\\n\t\\pi_1(X,x) \\ar[r] & \\pi_1(X\\vee Y,\\ast)\n}\n\\]\nor in other words, \n\\[\n\t\\pi_1(X\\vee Y,\\ast) = \\pi_1(X,x) \\ast \\pi_1(Y,y).\n\\]\nThis generalises the fact that $\\pi_1(S^1\\vee S^1,\\ast) = F_2 = \\ZZ\\ast \\ZZ$ to more \ngeneral spaces.\n\n\\begin{fact}\nGiven any presentation $G=\\langle g_1,\\ldots,g_m\\mid R_1=e,\\ldots,R_n=e\\rangle$ there is a space\n$X$ arising as a pushout\\marginnote{$\\bigvee_{j=1}^mS^1 = \\underbrace{S^1\\vee \\ldots \\vee S^1}_{m\\text{ times}}$}\n\\[\n\\xymatrixnocompile{\n\t\\bigsqcup_{i=1}^n S^1 \\ar[r] \\ar[d]_{\\langle f_1,\\ldots,f_n\\rangle} \n\t\t& \\bigsqcup_{i=1}^n D^2 \\ar[d]\\\\\n\t\\bigvee_{j=1}^m S^1 \\ar[r] & X\n}\n\\]\nwhere $f_i(1)=R_i$, with the property that $\\pi_1(X,\\ast)\\simeq G$. This space is in some \nsense 2-dimensional as it is gotten by gluing together 2d discs, and sometimes a manifold, though not always.\n\nEven better, for \\emph{any} group $G$ with any presentation, there is an appropriate pushout\n\\[\n\\xymatrixnocompile{\n\t\\bigsqcup_{\\beta \\in J} S^1 \\ar[r] \\ar[d]_{\\langle f_\\beta\\rangle} \n\t\t& \\bigsqcup_{\\beta \\in J} D^2 \\ar[d]\\\\\n\t\\bigvee_{\\alpha\\in I} S^1 \\ar[r] & X\n}\n\\]\nwith the property that $\\pi_1(X,\\ast) \\simeq G$. One has to be careful with the \ntopology, and we haven't defined infinite joins,\\marginnote{the coutable join \n$\\bigvee_{n\\in \\NN}S^1$ may seem like the Hawaiian earring, but it is in fact not \ncompact, and \\emph{is} slsc, so they cannot be homeomorphic} but it does work out that \n$\\pi_1(\\bigvee_{\\alpha\\in I}S^1,\\ast) \\simeq F_I$, the free group on the set $I$.\n\\end{fact}\n\n\\begin{example}\nAn oriented compact Riemann surface $\\Sigma_g$ of genus $g\\geq 1$ is an example of a \n surface gotten by a construction as in the Fact above, and even better: it only \n requires one copy of $D^2$. For genus $g$, it requires doing a pushout of the form\n\\[\n\\xymatrixnocompile{\n\tS^1 \\ar[d] \\ar[r] & D^2 \\ar[d] \\\\\n\t\\bigvee_{i=1}^{2g} S^1 \\ar[r] & \\Sigma_g\n}\n\\]\nAn alternative way to build this pushout is to consider a $4g$-gon,\\marginnote{Insert \noctagon picture for case $g=2$ here} and selectively identify edges in pairs (recovering the \n$2g$ circles as in the pushout). The pattern of identifications is exactly that which \ngives rise to the one-relator group after Example~\\ref{eg:one-relator_group}, since the \n\\emph{attaching map} $S^1 \\to \\bigvee_{i=1}^{2g} S^1$ in the preceeding pushout is given \nby $\\prod_{i=1}^g[a_i,b_i]$, for $a_i$ and $b_i$ the generators of the $2i-1$th and \n$2i$th copy of $S^1$ respectively.\n\\end{example}\n\n\\section{Classifying covering spaces}\n\nRecall\\lecturenum{14}\n that for a covering space $Z\\xrightarrow{\\pi} X$ we get a representation \n\\begin{align*}\n\\rho_Z\\colon \\Pi_1(X)& \\longrightarrow \\Set \\\\\nx & \\mapsto Z_x\\\\\n[\\gamma\\colon x\\rightsquigarrow y] & \\mapsto \\left(\\gamma_*\\colon Z_x\\xrightarrow{\\simeq} Z_y\\right)\n\\end{align*}\n\nof the fundamental\\marginnote{$\\xymatrix{Z_1 \\ar[rr]^f \\ar[dr]_{\\pi_1} && Z_2 \n\\ar[dl]^{\\pi_2}\\\\ & X}$} groupoid of $X$. Given a pair of covering spaces $Z_1,Z_2\\to X$ \nand a map between them in $\\Cov_X$, how are the representations $\\rho_{Z_1}$ and \n$\\rho_{Z_2}$ related? Since the triangle at right commutes, we get for each $x\\in X$ a \nfunction between the corresponding fibres, $f\\big|_x \\colon (Z_1)_x \\to (Z_2)_x$. Notice \nthat this is a function $\\rho_{Z_1}(x) \\to \\rho_{Z_2}(x)$ for each object of $\\Pi_1(X)$. \nGiven a path $\\gamma\\colon x\\rightsquigarrow y$ in $X$ and $z\\in (Z_1)_x$, we have the \nunique lift to $Z_1$ starting at $z$, namely $\\widetilde{\\gamma_z}^1\\colon \nz\\rightsquigarrow \\gamma_*(z)$. By composing with $f$, we get a path $f\\circ \n\\widetilde{\\gamma_z}^1\\colon I \\to Z_2$ from $f(z)$ to $f(\\gamma_*(z))$. But by \nuniqueness of lifts of paths, this is the lift of $\\gamma$ \nto $Z_2$ starting at $f(z)$, which is a path from $f(z) \\rightsquigarrow \\gamma_*(f(z))$.\nWe thus get $f(\\gamma_*(z)) = \\gamma_*(f(z))$ for every $z\\in (Z_1)_x$, implying that the\nfollowing square commutes:\n\\[\n\\xymatrix{\n\t(Z_1)_x \\ar[r]^{\\gamma_*}  \\ar[d]_{f\\big|_x} &  (Z_1)_y \\ar[d]^{f\\big|_y} \\\\\n\t(Z_2)_x \\ar[r]_{\\gamma_*} & (Z_2)_y\n}\n\\]\nOr, in other words, the functions $f\\big|_x$ define a natural transformation \n$\\rho_{Z_1}\\Rightarrow \\rho_{Z_2}$. This leads us to\n\n\\begin{prop}\nThe mapping $(Z \\xrightarrow{\\pi} X) \\mapsto \\rho_Z$\\marginnote{Recall that the category $[\\cC,\\Set]$ has as objects the functors $\\cC\\to \\Set$, and as morphisms the natural transformations} define a functor\n\\[\n\t\\Cov_X \\longrightarrow [\\Pi_1(X),\\Set].\n\\]\n\\end{prop}\n\n\\begin{proof}\nThe natural transformation $\\rho_Z \\Rightarrow \\rho_Z$ associated to the identity map \n$Z\\to Z$ has a components the identity functions $Z_x\\to Z_x$, hence is the identity \nnatural transformation. Also, using uniqueness of path lifting one can show that given \ntwo composable maps of covering spaces, we get functoriality.\n\\end{proof}\n\n\\begin{example}\n\nRegard $S^1\\subset \\CC$. Recall the covering spaces $\\exp(2\\pi i(-))\\colon \\RR \\to S^1$ and $S^1 \n\\xrightarrow{(-)^n} S^1$, for $n>1$. There is a map of covering spaces\n\\[\n\\xymatrix{\n\\RR \\ar[rr]^{\\exp(2\\pi i(-)/n)} \\ar[dr]_{\\exp(2\\pi i(-))} && S^1 \\ar[dl]^{(-)^n} \\\\\n& S^1\n}\n\\]\nThe fibres of $\\RR \\to S^1$ are isomorphic to $\\ZZ$, and indeed the fibre over $1\\in \nS^1$ \\emph{is} $\\ZZ$. The fibre over $1$ of $S^1 \\to S^1$ is $\\ZZ/n$, and we get the induced map\n\\begin{align*}\n\t\\ZZ&\\to \\ZZ/n\\\\\n\tk & \\mapsto k \\pmod{n}\n\\end{align*}\n\nNow note that if we focus on the point $1\\in S^1$, then a morphism in $\\Pi_1(S^1)$ from \n$1$ to itself is the homotopy class of some loop, which can identify with an integer \nunder $\\pi_1(S^1,1) \\simeq \\ZZ$. Then the representation associated to $\\RR\\to S^1$ is\n\\begin{align*}\n\\rho_\\RR\\colon \\Pi_1(S^1)& \\longrightarrow \\Aut(\\ZZ) \\\\\nm &\\mapsto (k\\mapsto k+m)\n\\end{align*}\nwhereas the representation associated to $(-)^n\\colon S^1\\to S^1$ is\n\\begin{align*}\n\\rho_n\\colon \\Pi_1(S^1)& \\longrightarrow \\Aut(\\ZZ/n)\\simeq S_n \\\\\nm &\\mapsto (k\\mapsto k+m \\pmod{n})\n\\end{align*}\nThe map $\\ZZ\\to \\ZZ/n$ is clearly equivariant for the shift action of $\\ZZ$ as shown, as \na special case of the naturality of the map $\\ZZ\\to \\ZZ/n$.\n\\end{example}\n\n\n\\begin{q}\nWhat representations $\\Pi_1(X) \\to \\Set$ can arise as $\\rho_Z$ for some covering space $Z\\to X$?\n\\end{q}\n\nRecall that it is obvious that every set is the set of connected components of some \nspace, and while we didn't go into details, the construction of a space $X$ with \n$\\pi_1(X,\\pt)\\simeq G$ for any given $G$ is a relatively uncomplicated pushout. However, \ngiven a representation $\\Pi_1(X) \\to \\Set$, it is not immediately obvious how to build a \ncovering space giving rise to it. Indeed, all the covering spaces we have seen so far \nare either natural examples we happen to have seen, or special toy cases chosen to \nillustrate some small aspect of the fundamental groupoid of a particularly simple space. \nWe are going to look at doing some reductions to simpler cases, on both sides (the \ntopological, $\\Cov_X$ and the algebraic, $[\\Pi_1(X),\\Set]$) to make the task easier.\n\nFirst, since we have the blanket assumption that out spaces are slpc, we can consider \nfinding a section to the continuous map $X\\to [\\pt,X]$, namely $A\\colon [\\pt,X] \\to X$, \nthat picks out one point $a_i$ per path component $X_i \\subseteq X$. We have the full \nsubgroupoid inclusion $\\Pi_1(X,A) \\into \\Pi_1(X)$ that is additionally an \nequivalence.\\marginnote{by an argument as in the solutions for assignment 2, question 7} \nLet us denote by $I$ the set $[\\pt,X]$ in what follows.\n\n\\begin{lemma}\nIf $i\\colon \\cC\\into \\cD$ is a full subcategory inclusion that is also an equivalence, then \nthe restriction map\n\\begin{align*}\n[\\cD,\\Set]& \\xrightarrow{i^*} [\\cC,\\Set]\\\\\nF & \\mapsto F\\circ i\n\\end{align*}\nis an equivalence of categories.\n\\end{lemma}\n\n\\begin{proof}\nExercise.\n\\end{proof}\n\nNow notice also that $\\Pi_1(X,A) = \\Pi_1(\\bigsqcup_{i\\in I}X_i,\\bigsqcup_{i\\in I}\\{a_i\\}) \\simeq \\bigsqcup_{i\\in I} \\mathbb{B}\\pi_1(X_i,a_i)$\n\n\\begin{lemma}\nFor any family of categories $(\\cC_i)_{i\\in I}$ we have an isomorphism\\marginnote{An object of a product of family of cateories is a tuple of objects, one from each of the categories, and similar with the morphisms}\n\\[\n\t[\\bigsqcup_{i\\in I} \\cC_i,\\Set] \\xrightarrow{\\simeq} \\prod_{i\\in I}[\\cC_i,\\Set]. \n\\]\n\\end{lemma}\n\n\\begin{proof}\nExercise.\n\\end{proof}\n\nGiven a group $G$, we can define the category $G\\Set$ which has as objects sets $S$ \nequipped with a $G$-action, $G\\to \\Aut(S)$, and with morphisms \\emph{equivariant} \nfunctions.\\marginnote{An equivariant function $f\\colon S\\to T$ satisfies $f(g\\cdot p) = \ng\\cdot f(p)$ for all $p\\in S$} Note that for any groupoid $\\Gamma$ and representation \n$\\rho\\colon \\Gamma \\to \\Set$, for each object $x\\in \\Gamma_0$ there is a permutation \nrepresentation $\\Gamma(x,x) \\to \\Aut(\\rho(x))$. To any natural transformation \n$\\rho\\Rightarrow \\rho'$ between representations, there is an equivariant map between \n$\\Gamma(x,x)$-sets, and this is functorial.\n\n\\begin{lemma}\nThe functor just described gives an isomorphism $[\\mathbb{B}G,\\Set] \\xrightarrow{\\simeq} G\\Set$ of categories\n\\end{lemma}\n\nWe can put all of these lemmas together and get an equivalence of categories\n\\[\n[\\Pi_1(X),\\Set] \\to [\\Pi_1(X,A),\\Set] \\simeq \\prod_{i\\in I}[\\mathbb{B}\\pi_1(X_i,a_i),\\Set]\n\\simeq \\prod_{i\\in I}\\pi_1(X_i,a_i)\\Set.\n\\]\nWe can compose this with the original functor we were looking at, from covering spaces to representations, to get\n\\begin{align}\n\t\\Cov_X & \\to \\prod_{i\\in I}\\pi_1(X_i,a_i)\\Set \\label{eq:fibre_functor}\\\\\n\t(Z\\to X) & \\mapsto (\\rho_i\\colon \\pi_1(X_i,a_i) \\to Z_{a_i})_{i\\in I} \\nonumber\n\\end{align}\nwhere now the codomain is much more tractable. Further, the objects in categories of the \nform $G\\Set$ are not unreasonable: we can break them down into smaller parts. Each \nobject $\\rho\\colon G\\to \\Aut(S)$ in $G\\Set$ isomorphic to one of a particularly nice \nform, namely $S\\simeq \\bigsqcup_{j\\in S/G} G/\\mathrm{Stab}(p_j)$, where the points \n$p_j\\in S$ are chosen so that there is one in each orbit of the $G$-action.\n\n\\begin{rem}\nFrom now on, we will consider only spaces that are slsc, since this will ultimately be \nthe case in the classification theorem, and also because $X$ slsc implies that for every \ncovering space $Z\\to X$, the space $Z$ is locally path connected, so that path \ncomponents and components agree.\n\\end{rem}\n\n\\lecturenum{15}\n\\begin{lemma}\nFor a space $X = \\bigsqcup_{i\\in I} X_i$, there is an equivalence of categories $\\Cov_X \\simeq \\prod_{i\\in I} \\Cov_{X_i}$.\n\\end{lemma}\n\n\\begin{proof}\nA covering space $Z\\to \\bigsqcup_{i\\in I} X_i$ gives covering spaces $Z_{X_j}:=\\mathrm{in}_j^*X$ for each $j\\in I$, where recall the inclusion maps $\\mathrm{in}_j\\colon X_j \\to \\bigsqcup_{i\\in I} X_i$. We also get, from a map of covering space $Z\\to Z'$ over $X$, a map $Z_{X_j} \\to Z'_{X_j}$ of covering spaces over $X_j$, for each $j$. This gives a functor $\\Cov_X \\to \\prod_{i\\in I} \\Cov_{X_i}$.\n\nConversely, given a covering space $Z_i \\to X_i$ for each $i\\in I$, we get a covering space $\\bigsqcup_{i\\in I} Z_i \\to \\bigsqcup_{i\\in I} X_i$, and for maps $Z_i \\to Z'_i$ of covering spaces over $X_i$, there is a map $\\bigsqcup_{i\\in I} Z_i \\to \\bigsqcup_{i\\in I} Z'_i$ of covering spaces over $\\bigsqcup_{i\\in I}X_i$. This gives a functor $\\prod_{i\\in I} \\Cov_{X_i} \\to \\Cov_X$, and these two functors are an equivalence of categories.\n\\end{proof}\n\nThe functor in (\\ref{eq:fibre_functor}) then factorises as the composite\n\\begin{align*}\n\t\\Cov_X & \\xrightarrow{\\simeq} \\prod_{i\\in I} \\Cov_{X_i} \\longrightarrow \\prod_{i\\in I}\\pi_1(X_i,a_i)\\Set\\\\\n\t\\raisebox{4ex}{\\xymatrix{Z\\ar[d]\\\\X}} & \\mapsto \n\t\\raisebox{4ex}{\\xymatrix{Z_{X_i}\\ar[d]\\\\X_i} } \\mapsto \n\t\\left(\\rho_i\\colon \\pi_1(X_i,a_i) \\to \\Aut(Z_{a_i}) \\right)\n\\end{align*}\nIn particular, if we understand each $\\Cov_{X_i} \\to\\pi_1(X_i,a_i)\\Set$, then we are done. \n\nSo, we will consider from now on the case of a connected, slsc space $X$ with chosen $x_0\\in X$, and the functor $\\Cov_{X} \\to\\pi_1(X,x_0)\\Set$. \n\nSince $X$ is slsc, it is locally path connected, and the local trivialisation of any covering space $Z\\to X$ shows that $Z$ is also locally path connected.\\marginnote{there is a small subtlety here, in that we really require a basis of nhds that are path connected, I will expand on this point if pushed, but it is a technicality that can be ignored for our purposes} We can then write $Z = \\bigsqcup_{\\alpha \\in I} Z_\\alpha \\to X$, where each $Z_\\alpha \\to X$ is a (path) connected covering space.\\marginnote{Exercise!}\n\n\\begin{example}\nTake $X=S^1$. Recall that we have various covering spaces: $S^1\\times F\\simeq \\bigsqcup_{F} S^1\\to S^1$ for discrete spaces $F$; the exponential map $\\RR \\to S^1$; the various $S^1 \\xrightarrow{(-)^n} S^1$ with $n>1$, where we shall write $S^1_n$ for the total space of this covering space. Then we can form a covering space\n\\[\n\tS^1\\times F \\sqcup \\bigsqcup \\RR \\sqcup \\bigsqcup S^1_2 \\sqcup \\bigsqcup S^1_3\\sqcup \\ldots \\to S^1.\n\\]\nIt remains to be seen, however, if there are any covering spaces not of this form.\n\\end{example}\n\nRecall from lecture 6 (on page~\\pageref{eq:fibre_quotient_of_loops}) that given a covering space $Z\\to X$, there is a surjective map\n\\[\n\t\\Omega_{x_0} X \\times\\{z_\\alpha\\mid \\alpha \\in I\\} \\to Z_{x_0}, \\qquad z_\\alpha \\in Z_{x_0}\\cap Z_\\alpha,\n\\]\nhence a surjective map \\[\n\t\\pi_1(X,x_0) \\times \\{z_\\alpha\\mid \\alpha \\in I\\} \\simeq \\bigsqcup_{\\alpha\\in I}\\pi_1(X,x_0) \\times  \\{z_\\alpha\\} \\to Z_{x_0} = \\bigsqcup_{\\alpha\\in I} Z_{x_0}\\cap Z_\\alpha\n\\]\n\\begin{lemma}\nGiven a covering space $Z\\to X$ with $x_0\\in X$, then $Z_{x_0} =\\bigsqcup_{\\alpha\\in I} Z_{x_0}\\cap Z_\\alpha\\simeq \\bigsqcup_{\\alpha\\in I} \\pi_1(X,x_0)/\\pi_1(Z_\\alpha,z_\\alpha)$ as $\\pi_1(X,x_0)$-sets, for any choice of $z_\\alpha\\in Z_{x_0}\\cap Z_\\alpha$.\n\\end{lemma}\n\n\\begin{proof}\nIt is enough to show that the orbits of the $\\pi_1(X,x_0)$-action are the sets $Z_{x_0}\\cap Z_\\alpha$, because then the general description of sets with transitive action takes over. Given $z\\in Z_{x_0}\\cap Z_\\alpha$, there is a path $\\gamma\\colon z_\\alpha \\rightsquigarrow z$, and hence a loop $\\pi\\circ\\gamma$ at $x_0$. This loop acts on $Z_{x_0}$, with $(\\pi\\circ \\gamma)_*(z_\\alpha)=z$. Hence $Z_{x_0}\\cap Z_\\alpha$ is contained in the orbit containing $z_\\alpha$. Conversely, given any $z\\in Z_{x_0}$ and a loop $\\eta$ at $x_0$ such that $\\eta_*(z_\\alpha) = z$, then there is a lift $\\widetilde{\\eta}\\colon z_\\alpha \\rightsquigarrow z$ of $\\eta$, so that $z\\in Z_\\alpha$. Thus the orbit of $z_\\alpha$ is contained in $Z_{x_0}\\cap Z_\\alpha$, and we are done.\n\\end{proof}\n\nAs a result, our functor $\\Cov_X \\to \\pi_1(X,x_0)\\Set$ preserves disjoint unions: it sends the covering space $\\bigsqcup_{\\alpha \\in I} Z_\\alpha\\to X$ to the disjoint union of sets with a permutation representation $\\bigsqcup_{\\alpha\\in I} Z_{x_0}\\cap Z_\\alpha$.\n\n\\begin{rem}\nGiven a group $G$ and a $G$-set $S$, such that $S=\\bigsqcup_{\\alpha\\in I} S_\\alpha$ is the partition into orbits of the action, then the representation $\\rho \\colon G\\to \\Aut(\\bigsqcup S_{\\alpha\\in I})$ factors through the subgroup $\\prod_{\\alpha\\in I} \\Aut(S_i) < \\Aut(\\bigsqcup S_{\\alpha\\in I})$, hence $\\rho = (\\rho_\\alpha)_{\\alpha\\in I}$, for $\\rho_\\alpha\\colon G\\to \\Aut(S_\\alpha)$ a transitive $G$-action.\n\\end{rem}\n\nRecall what our original question was: what representations $\\Pi_1(X)\\to \\Set$ arise from covering spaces of $X$ via the functor $\\Cov_X \\to [\\Pi_1(X),\\Set]$? We have now reduced this to the simpler aim of starting with a permutation representation of a fundamental group, and can reduce the input data even more. Inside $\\Cov_X$ (for connected $X$) is the full subcategory $\\Cov_X^\\mathrm{conn}$ of \\emph{connected} covering spaces, and inside $\\pi_1(X,x_0)\\Set$ is the full subcategory $\\pi_1(X,x_0)\\Set^\\mathrm{tr}$ of sets with a \\emph{transitive} action. Moreover, in both of these cases, arbitrary objects in $\\Cov$ and $\\pi_1(X,x_0)\\Set$ can be gotten by disjoint union of objects in the respective subcategories. Thus it is sufficient to ask if we can get any transitive $\\pi_1(X,x_0)$-set from some connected covering space of $X$. That is, we want to know what is the image of the functor\n\\[\n\t\\Cov_X^\\mathrm{conn} \\longrightarrow  \\pi_1(X,x_0)\\Set^\\mathrm{tr}.\n\\]\n\nNote that in the category of transitive $G$-sets, every object $S$ with a point $p\\in S$ is the quotient of the underlying set of $G$ equipped with the action by multiplication, via the map \n\\begin{align*}\nG& \\to S \\simeq G/\\mathrm{Stab}(p)\\\\\ng & \\mapsto g\\cdot p\n\\end{align*}\nand the $G$-action on $G$ is free and transitive. More generally, given any $G$-set $T$ with a free and transitive action, there is a surjective equivariant map $T\\to S$ displaying $S$ as a quotient of $T$.\n\n\\begin{example}\nGiven a simply-connected covering space $Z\\to X$ and $x_0\\in X$, the fibre $Z_{x_0}$ is a free and transitive $\\pi_1(X,x_0)$-set.\n\\end{example}\n\nRecall also that for a general path connected covering space $Z\\to X$, $Z_{x_0} \\simeq \\pi_1(X,X_0)/\\pi_1(Z,z)$ for any $z\\in Z_{x_0}$. If we start with a pointed covering space, then we don't have to choose a point, and every connected covering space of a pointed space can be gotten by forgetting the point from some pointed covering space.\nSo we have the final form of the question\n\n\\begin{q}\nGiven a subgroup $H< \\pi_1(X,x_0)$, is there a pointed covering space $(Z,z_0)\\to (X,x_0)$ such that $\\pi_1(Z,z_0) = H$ as subgroups of $\\pi_1(X,x_0)$?\\marginnote{Recall from assignment 2, where from a simply-connected space $Y$ with free $G$-action, we got a covering space $Y\\to Y/G$ with $\\pi_1(Y/G,\\ast)\\simeq G$}\n\\end{q}\n\n\nRecall\\lecturenum{16} that for a simply-connected covering space $Z^{(1)} \\to X$ the fibre over $x_0$ is isomorphic to $\\pi_1(X,x_0)$, and that our ultimate aim is to get a covering space with fibre isomorphic to $\\pi_1(X,x_0)/H$. So one way to approach this is to see if there is a way to make sense of making a covering space by taking the quotient of some simply-connected covering space ``fibre by fibre''. It isn't possible to do this piecemeal, so we need to do this for all fibres at once.\n\n\\begin{definition}\nLet $p\\colon Y\\to X$ be a map of spaces, $G$ a group acting on $Y$. We say the action is \\emph{fibrewise} if $p(g\\cdot y) = p(y)$ for all $y \\in Y,g\\in G$.\n\\end{definition}\n\nIt follows from the definition\\marginnote{there is a commutative triangle $\\xymatrix{Y \\ar[d] \\ar[r] & Y/G \\ar[dl]\\\\ X}$} that there is map $Y/G \\to X$, and the fibre of this map over $x$ is $p^{-1}(x)/G$.\n\n\\begin{prop}\nLet $Z\\xrightarrow{\\pi} X$ be a covering space, and let $G$ act fibrewise on $Z$. Then $Z/G\\to X$ is a covering space and $Z\\to Z/G$ is a map of covering spaces.\n\\end{prop}\n\n\\begin{proof}\nFirst notice that since the action of $G$ is fibrewise, the orbits of $G$ are subspaces of discrete spaces, and hence are discrete.\n\nFor $U\\subseteq X$, we get an action of $G$ on $Z_U \\subseteq Z$, also fibrewise for the restriction $Z_U \\to U$ of $\\pi$. If we take $U$ small enough nhd around $x\\in X$ then $Z_U \\simeq Z_x \\times U$, and moreover this homeomorphism is $G$-equivariant and respects the maps to $U$. We thus get a homeomorphism $(Z_U)/G \\simeq U \\times (Z_x/G)$. Then, from the question in assignment 4, $(Z/G)_U$ is homeomorphic to $(Z_U)/G$ over $U$, so there is a homeomorphism $(Z/G)_U \\simeq U \\times (Z_x/G)$ over $U$, and hence $Z/G \\to X$ is a covering space with fibre $Z_x/G$. The quotient map $Z \\to Z/G$ respects the maps to $X$ by construction, so is a map of covering spaces.\n\\end{proof}\n\nThus if $Z^{(1)} \\to X$ is a simply-connected covering space and $H< \\pi_1(X,x_0)$ acts fibrewise on $Z^{(1)}$, we get a covering space $Z^{(1)}/H \\to X$ with fibre $\\pi_1(X,x_0)/H$ \\emph{as sets}. However, more is true.\n\n\\begin{lemma}\nAssuming there is a simply-connected covering space $Z^{(1)} \\to X$, the morphism $Z^{(1)}_x \\to Z^{(1)}_x/H$ is $\\pi_1(X,x)$-equvariant.\n\\end{lemma}\n\n\\begin{proof}\nExercise. Uses path lifing and the map $Z^{(1)} \\to Z^{(1)}/H$ over $X$.\n\\end{proof}\n\nWe have have two problems:\n\\begin{enumerate}\n\\item How do we construct a simply-connected covering space of $X$? Or how do we know one exists?\n\\item Given such a thing, and an arbitrary subgroup $H<\\pi_1(X,x_0)$, how do we construct a fibrewise $H$-action?\n\\end{enumerate}\n\n\nWe can reduce the second problem to the case of finding a fibrewise $\\pi_1(X,x_0)$-action, because then by restriction, any subgroup will also act fibrewise. As it turns out, the construction that will address the first point will also automatically come with the required fibrewise action of the fundamental group.\n\n\\begin{construction}\nFix a pointed space $(X,x_0)$. Consider the quotient space $X^{(1)} := P_{x_0}X/\\sim$ where $\\gamma_1\\sim \\gamma_2$ if $\\gamma_1(1)=\\gamma_2(1)$ and $[\\gamma_1]=[\\gamma_2]$ in $\\Pi_1(X)$. From the definition of the equivalence relation and the quotient topology, we get a continuous pointed map $X^{(1)} \\to X$ and a commutative triangle\\marginnote{we will denote the class of the constant path also by $c_{x_0}$ to de-clutter the notation}\n\\[\n\t\\xymatrix{\n\t(P_{x_0},c_{x_0}) \\ar[rr] \\ar[dr] && (X^{(1)},c_{x_0}) \\ar[dl]\\\\\n\t& (X,x_0)\n\t}\n\\]\n\\end{construction}\n\nThus one can see this as giving a topology to a subset of the morphisms of $\\Pi_1(X)$.\n\n\\begin{prop}\nFor $X$ semilocally simply-connected, $(X^{(1)},c_{x_0}) \\to (X,x_0)$ is a simply-connected covering space, and $\\pi_1(X,x_0)$ acts by concatenation as in $\\Pi_1(X)$\n\\end{prop}\n\n\\begin{proof}\nNotice first that the fibre $X^{(1)}_x$ of $X^{(1)} \\to X$ over $x\\in X$ is $\\Pi_1(X)(x_0,x) \\simeq P_{x_0}^xX/\\sim$, and moreover, since $X$ is slsc, $P_{x_0}^xX$ is slpc, and hence $X^{(1)}_x=[\\pt,P_{x_0}^xX]=\\pi_0(P_{x_0}^xX)$ is discrete. Thus $X^{(1)} \\to X$ has discrete fibres.\n\nNow fix $x\\in X$. Since $X$ is slsc, there is a nhd $U\\ni x$ such that for every $x'\\in U$ there is a path $\\eta_{x'}\\colon x\\rightsquigarrow x'$ (in $U$) such that for any other path $\\eta\\colon x \\rightsquigarrow x'$ in $U$, $[\\eta_{x'}]=[\\eta]$ in $\\Pi_1(X)$. Consider $X^{(1)}_U = \\{[x_0\\rightsquigarrow x']\\mid x'\\in U\\}$.\n\n\\textbf{Claim:} There is a homeomorphism \n\\begin{align*}\nU\\times X^{(1)}_x & \\xrightarrow{\\simeq} X^{(1)}_U \\\\\n(x',[x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x]) \\mapsto [x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x \\stackrel{\\eta_{x'}}{\\rightsquigarrow} x']\n\\end{align*}\nover $U$. We can prove this is a bijection without too much difficulty, as follows. \n\\begin{itemize}\n\\item Injective: If $[x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x \\stackrel{\\eta_{x'}}{\\rightsquigarrow} x'] = [x_0 \\stackrel{\\gamma'}{\\rightsquigarrow} x \\stackrel{\\eta_{x'}}{\\rightsquigarrow} x']$, then we can concatenate with $-\\eta_{x'}$ and the result is that $[\\gamma] = [\\gamma']$.\n\\item Surjective: Suppose I have $[x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x'] \\in X^{(1)}_U$. Then $[\\gamma] = [\\gamma][\\eta_{x'}]^{-1}[\\eta_{x'}]$.\n\\end{itemize}\n\nFor now, for the proof that this is a homeomorphism, see pages 64--65 of Hatcher, in the section \n``The Classification of Covering Spaces''.\\marginnote{I will fill in the details here later (not examinable!)}\n\nThus we have a local trivialisation, and hence a covering space.\n\nWe can see that $X^{(1)}$ is path connected by observing that it is the quotient of the path connected space $P_{x_0} X$\\marginnote{there is a path from $c_{x_0}$ to any $\\gamma\\colon x_0\\rightsquigarrow x$, defined by $s\\mapsto (t\\mapsto \\gamma(st))$}, hence there is a surjective map $P_{x_0}X \\to X^{(1)}$. \n\nThere is a fibrewise action of $\\pi_1(X,x_0)$ on $X^{(1)}$ by $([x_0 \n\\stackrel{\\omega}{\\rightsquigarrow} x_0],[x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x]) \\mapsto \n[x_0 \\stackrel{\\omega}{\\rightsquigarrow} x_0 \\stackrel{\\gamma}{\\rightsquigarrow} x]$. This is \ncontinuous because it is induced from the continuous concatenation $\\Omega_{x_0}X \\times P_{x_0}X \n\\to P_{x_0}X$, and the axioms for an action hold from the associativity of composition in \n$\\Pi_1(X)$. Note especially that the $\\pi_1(X,x_0)$-action is \\emph{free}, so that the \nstabiliser subgroups are all trivial.\n\nFinally, since the fibre of $X^{(1)}$ at $x_0$ is the quotient of $\\pi_1(X,x_0)$ by the stabiliser subgroup by the $\\pi_1(X,x_0)$-action, and this stabiliser subgroup is $\\pi_1(X^{(1)},c_{x_0})$, we have that $\\pi_1(X^{(1)},c_{x_0})$ is trivial. Hence $X^{(1)}$ is simply-connected.\n\\end{proof}\n\nAs a result, given any subgroup $H < \\pi_1(X,x_0)$, we can define the connected covering space $X^{(1)}/H \\to X$, which is a pointed covering space with $\\pi_1(X^{(1)},\\ast) = H$. Working backwards through the reasoning above, we can get \\emph{any} set with $\\pi_1(X,x_0)$-action, up to isomorphism, as the fibre of some covering space of $(X,x)$. And then, if $X$ has multiple connected components, we can the take the disjoint union of covering spaces of each component to get a representation of the whole fundamental groupoid. Thus we have proved\n\n\\begin{prop}\nFor an slsc space $X$ the functor\n\\[\n\t\\Cov_X \\to [\\Pi_1(X),\\Set]\n\\]\nis essentially surjective: every representation $\\Pi_1(X) \\to \\Set$ is isomorphic to one coming from a covering space.\n\\end{prop}\n\nWe\\lecturenum{17} can say still more:\n\n\\begin{lemma}\n\nLet $Z\\xrightarrow{\\pi} X$ be a covering space, $Y$ path connected and $p\\colon Y\\to X$ \nbe some map. Suppose we have maps $f,g\\colon Y\\to Z$ such that $f\\circ \\pi = p = g\\circ \n\\pi$. Then if $f(y_0) = g(y_0)$ for some $y_0\\in Y$, we have $f=g$.\n\n\\end{lemma}\n\n\\begin{proof}\nTake $y\\in Y$ arbitrary, and let $\\gamma\\colon y_0 \\rightsquigarrow y$ be a path. Then $f\\circ \\gamma$ and $g\\circ \\gamma$ are both lifts of the path $p\\circ \\gamma\\colon I \\to X$. And since $f(\\gamma(0)) = f(y_0) = g(y_0) = g(\\gamma(y_0))$, we must have $f(y) = f(\\gamma(1)) = g(\\gamma(1)) = g(y)$. \n\\end{proof}\n\nThis applies in particular, if $Y$ is another covering space of $X$.\n\n\\begin{corollary}\nThe functor $\\Cov_{X} \\to [\\Pi_1(X),\\Set]$ is faithful.\n\\end{corollary}\n\n\\begin{proof}\nWe can reduce to the case of $X$ connected, and can choose a basepoint $x_0\\in X$ to get a functor $\\Cov_X \\to [\\Pi_1(X),\\Set] \\to \\pi_1(X,x_0)\\Set$. This functor will be faithful if and only if the original functor is (after the reduction to $X$ connected.) Now suppose we have two covering spaces $Z_i \\xrightarrow{\\pi_i} X$ ($i=1,2$) and a pair of maps $f,g\\colon Z_1 \\to Z_2$ between them (over $X$). Then if $f\\big|_x =g\\big|_x\\colon (Z_1)_{x_0} \\to (Z_2)_{x_0}$, in particular for each path component of $Z_1$, there is a point $z$ such that $f(z) = f\\big|_x(z) =g\\big|_x(z) = g(z)$, so that $f$ and $g$ coincide on each path component, and hence agree everywhere.\n\\end{proof}\n\nIn fact, we have the following landmark result:\n\n\\begin{theorem}\nFor slsc $X$, $\\Cov_X\\to [\\Pi_1(X),\\Set]$ is an equivalence of categories.\n\\end{theorem}\n\nThe proof reduces to connected and pointed $X$, then shows that given $(Z_1)_x \\to (Z_2)_x$ a map of $\\pi_1(X,x)$-sets, there is a map $Z_1 \\to Z_2$ between covering spaces that induces it. This shows that the functor is full, hence together with the previous results, that it is an equivalence.\n\n\\section{Higher homotopy groups}\n\nSo far, we have invariants $\\pi_0$, $[\\pt,-]$\\marginnote{treat it as a fluke of low dimensions that there are two invariants that aim to capture what is meant by ``components'' of a space} and $\\pi_1$ of a space. Notice that $\\pi_1 = [(S^1,1),-]_*$, and in fact for pointed spaces, $[\\pt,-] = [(S^0,1),-]_*$, since $S^0 = \\{1,-1\\}$, and a pointed map $(S^0,1) \\to (X,x)$ is specified completely by where it sends $-1$. This leads naturally to the question of what should $\\pi_n$ be?\n\n\\begin{definition}\nGiven a pointed space $(X,x)$, define the \\emph{$n^{th}$ homotopy group of $X$ based at $x$} to be $[(S^n,1),(X,x)]_*$.\n\\end{definition}\n\nThis is automatically a functor $\\Top_* \\to \\Set$, though we shall soon see we can refine this. It follows quickly from the definition that we have $\\pi_n(X\\times Y, (x,y)) \\simeq \\pi_n(X,x)\\times \\pi_n(Y,y)$.\n\n\nAn important observation is that $S^n$ here can be treated in a number of different ways that all lead to the same definition. Notice\\marginnote{For a pair $(Y,A)$, we define the quotient $Y/A$ of $Y$ by the subspace $A$ to be the quotient space $Y/(a_1 \\sim a_2, \\forall a_1,a_2\\in A)$} particularly that $S^n \\simeq I^n / \\partial I^n \\simeq D^n / \\partial D^n$. We can take the basepint in $S^n$ to be the image of the collapsed subspace, so that continuous maps of pairs $(I^n,\\partial I^n) \\to (X,x)$ are in bijection with maps $(S^n,1) \\to (X,x)$, and similarly for maps $(D^n,\\partial D^n) \\to (X,x)$. The relation of homotopy of maps $(Y,A) \\to (X,x)$ out of a pair generalises that of a pointed homotopy, and demands that the homotopy $H\\colon I \\times Y\\to X$ maps $I\\times A$ to $x$. With this definition of relative homotopy, we have that $[(S^n,1),(X,x)]_* = [(I^n,\\partial I^n),(X,x)] = [(D^n,\\partial D^n),(X,x)]$.\n\nFurther, given a map $f\\colon (I^n,\\partial I^n) \\to (X,x)$, we get a continuous map $I^{n-1} \\to \\Omega_x X$, and the boundary condition on $f$ implies that $\\partial I^{n-1}$ is mapped to the constant loop $c_x$. Thus $\\pi_n(X,x) = [(I^n,\\partial I^n),(X,x)] \\simeq [(I^{n-1},\\partial I^{n-1}),(\\Omega_x X,c_x)] = \\pi_{n-1}(\\Omega_x X,c_x)$. Since we know path concatenation is continuous, we have the map $\\Omega_x X \\times \\Omega_x X \\to \\Omega_x X$. This allows us to define a binary operation\n\\[\n\t\\pi_n(X,x)\\times \\pi_n(X,x) \\simeq \\pi_{n-1}(\\Omega_x X,c_x) \\times \\pi_{n-1}(\\Omega_x X,c_x) \\simeq \\pi_{n-1}(\\Omega_x X \\times \\Omega_x X,(c_x,c_x)) \\to \\pi_{n-1}(\\Omega_x X,c_x)  \\simeq \\pi_n(X,x)\n\\]\nThe up-to-homotopy associativity of the concatenation of loops, together with inverses and identity element up to homotopy, means that $\\pi_n(X,x)$ is in fact a group, and so we have a functor $\\pi_n\\colon \\Top_* \\to \\Grp$. The following  is a famous later abstraction of a result that originally arose when the higher homotopy groups were first defined in 1932 (or so).\n\n\\begin{lemma}[Eckmann--Hilton argument]\nLet $M$ be a set with two unital binary operations $\\circ,\\# \\colon M \\times M \\to M$, with units $1_\\circ$ and $1_\\#$, such that for all $a,b,c,d\\in M$, \n\\[\n\t(a \\circ b) \\# (c\\circ d) = (a \\# c) \\circ (b \\# d).\n\\]\nThen $1_\\circ = 1_\\#$, $a\\circ b = a \\# b$, $a\\# b = b \\# a$ and moreover the binary operation is associative, making $M$ an abelian group\n\\end{lemma}\n\n\\begin{proof}\n\\begin{enumerate}\n\\item First, $1_\\circ = 1_\\circ \\circ 1_\\circ = (1_\\circ \\# 1_\\#) \\circ (1_\\# \\# 1_\\circ) = \n(1_\\circ \\circ 1_\\#) \\# (1_\\# \\circ 1_\\circ) = 1_\\# \\# 1_\\# = 1_\\#$, so that the unit elements agree, and we can just denote $1_\\circ = 1_\\# =: 1$.\n\n\\item Then $a\\circ b = (a \\# 1) \\circ (1 \\# b) = (a\\circ 1) \\# (1\\circ b) = a \\# b$, so we can write $ab := a\\circ b = a \\# b$ for the single binary operation.\n\n\\item Now $ab = (1a)(b1)=(1b)(a1)=ba$, so that the binary operation is commutative.\n\n\\item Finally, $(ab)c = (ab)(1c) = (a1)(bc)=a(bc)$, so that the binary operation is associative, and thus we have an abelian group structure. \n\\end{enumerate}\n\\end{proof}\n\n\\begin{example}\nIf $G$ is a Lie group\\marginnote{or even just a topological group} then $\\pi_1(G,e)$ is abelian, because we have the concatenation operation, and the operation of pointwise multiplication of loops (which passes down to homotopy classes of loops). The constant loop is the identity element for both of these operations, so we get the first part of the previous lemma for free. The only thing that needs checking is that pointwise multiplication and concatenation distribute as needed for the Eckmann--Hilton argument, but this is not difficult to check.\n\\end{example}\n\nNow let us go back to our observation that $\\Top_*((S^n,1),(X,x)) \\simeq \\Top_*((S^{n-1},1),(\\Omega_x X,c_x))$. We can iterate this, to get  $\\Top_*((S^{n-1},1),(\\Omega_x X,c_x)) \\simeq \\Top_*((S^{n-2},1),(\\Omega_{c_x}\\Omega_x X,c_{c_x}))$. This makes sense because in the definition of the based loop space $\\Omega_y Y$, the space $Y$ is arbitrary. Let us write $\\Omega^2_x X$ for $\\Omega_{c_x}\\Omega_x X$, and always assume it has the basepoint $c_{c_x}$. Then there are two continuous concatenation operations\n\\[\n\t\\Omega^2 X \\times \\Omega^2 X \\to \\Omega^2 X,\n\\]\narising from concatenating in either the first or the second parameter. Given $f_1,f_2\\in \\Omega^2 X$, that is, functions $I^2\\to X$ such that $\\partial I^2$ is mapped to $x$, we have\n\\begin{align*}\n(f_1 \\#_1 f_2)(s,t) & = \\begin{cases}\nf_1(2s,t) & \\forall t\\in I,\\ s\\in [0,\\frac12]\\\\\nf_2(2s-1,t) & \\forall t\\in I,\\ s\\in [\\frac12,1]\n\\end{cases}\\\\\n(f_1 \\#_2 f_2)(s,t) & = \\begin{cases}\nf_1(s,2t) & \\forall t \\in [0,\\frac12],\\ s\\in I\\\\\nf_1(s,2t-1) & \\forall t\\in [\\frac12,1],\\ s\\in I\n\\end{cases}\n\\end{align*}\nAnd, moreover, $(f_1 \\#_1 f_2) \\#_2 (f_3 \\#_1 f_4) = (f_1 \\#_2 f_3) \\#_1 (f_2 \\#_2 f_4)$, where each of these is defined on one quadrant of the $^2$ subdivided into four squares. Thus, from the Eckmann--Hilton argument,\n\n\\begin{prop}\nThe group $\\pi_n(X,x)$ is abelian for all $n\\geq 2$.\n\\end{prop}\n\n\nThe\\lecturenum{18} assignment \n\\begin{align*}\n(X,x) & \\mapsto \\pi_n(X,x)\\\\\n\\left(f\\colon (X,x) \\to (Y,y) \\right)& \\mapsto \\left(f_* \\colon \\pi_1(X,x) \\to \\pi_n(Y,y) \\right)\n\\end{align*}\nis then a functor $\\Top_* \\to \\Ab$.\n\n\\begin{example}\nFor $T$ a discrete space, $\\pi_n(T,*) = 1$, since all $S^n \\to T$ are constant maps ($S^n$ is connected!)\n\\end{example}\n\n\\begin{example}\nIf $X$ is contractible (eg a star-shaped domain in a topological vector space) then $\\pi_n(X,x) = 1$\n\\end{example}\n\nRecall: Given a covering space $Z\\to X$ there is an associated representation $\\Pi_1(X) \\to \\Set$. But there is nothing special here about the category $\\Set$, we can have other categories, for instance: the category $\\Fin$ of finite sets, the category $\\Vect$ of vector spaces, the category $\\Ab$ of abelian groups, or more generally the category $R\\Mod$ of $R$-modules ($R$ here is a given ring).\n\n% \\begin{example}\n% Given a representation $\\Pi_1(X) \\to \\Set$, we get a representation $\\Pi_1 \\to \\Vect$ by taking composing with the functor $\\Set \\to \\Vect$ that associates to a set the vector space with that basis, and to a function the associated linear map.\n% \\end{example}\n\n\\begin{prop}\nFix the space $X$. The assignment $x\\mapsto \\pi_n(X,x)$ is the object component of a representation $\\Pi_1(X) \\to \\Ab$.\n\\end{prop}\n\n\\begin{proof}\n(Sketch) Given $\\gamma\\colon [0,1] \\to X$, $x\\rightsquigarrow y$, and $\\alpha\\colon (I^n,\\partial I^n) \\to (X,x)$ representing a class in $\\pi_n(X,x)$, we need to construct a class in $\\pi_n(X,y)$, in such a way that this gives a group isomorphism $\\pi_n(X,x) \\xrightarrow{\\simeq} \\pi_n(X,y)$. For this construction, consider the interval $I = [-\\frac12,\\frac12]$.\nFix an orientation-preserving homeomorphism $I = [-\\frac12,\\frac12]\\xrightarrow{\\simeq} [-\\frac14,\\frac14]$, and thus a map $i\\colon [-\\frac14,\\frac14]^n  \\simeq I^n $. Also fix orientation-preserving $j\\colon [\\frac14,\\frac12]\\xrightarrow{\\simeq} [0,1]$.  Define $\\alpha^\\gamma\\colon I^n \\to X$ to be the piecewise defined function\n\\[\n\\alpha^\\gamma(\\mathbf{x}) = \\begin{cases} \n\\alpha(i(\\mathbf{x})) & \\mathbf{x} \\in [-\\frac14,\\frac14]^n\\\\\n\\gamma(j(|\\mathbf{x}|)) & \\mathbf{x} \\in [-\\frac12,\\frac12]^n \\setminus [-\\frac14,\\frac14]^n\n\\end{cases}\n\\]\nBy the pasting lemma this is continuous, as $\\alpha(\\mathbf{x}) = x$ for all $\\mathbf{x} \\in \\partial I^n$, and $\\gamma(0) = x$. Moreover, $\\alpha^\\gamma(\\mathbf{x}) = y$ for all $\\mathbf{x} \\in \\partial I^n$, and so $\\alpha^\\gamma\\colon (I^n,\\partial I^n) \\to (X,y)$. The homotopy class of $\\alpha^\\gamma$ is independent of the choice of $\\gamma$ and $\\alpha$ as representatives for their respective classes in $\\Pi_1(X)(x,y)$ and $\\pi_n(X,x)$, as we can use homotopies between these and other representatives to create a homotopy between maps $(I^n,\\partial I^n) \\to (X,y)$. We thus get a function $\\pi_n(X,x) \\to \\pi_n(X,y)$ for each $[\\gamma]\\in \\Pi_1(X)(x,y)$.\n\nAs functions between sets, this is functorial by a reparametrisation argument, so that $[\\alpha^{\\gamma\\#\\eta}] = [(\\alpha^\\gamma)^\\eta]$, and $[\\alpha^{c_x}] = [\\alpha]$. The last thing that needs to be checked is that $[\\alpha]\\mapsto [\\alpha^\\gamma]$ is a group homomorphism. This is a mildly fiddly, but overall unenlightening argument.\\marginnote{there is a proof in Hatcher, \\S4.1 on page 341}\n\\end{proof}\n\nNote that if we consider the case $n=1$, then we have already seen a version of this: given a path $\\gamma\\colon x\\rightsquigarrow y$, there is an isomorphism $\\pi_1(X,x) \\xrightarrow{\\simeq} \\pi_1(X,y)$. If we specialise to the case of $x=y$, then $\\gamma$ is a loop, and the resulting automorphism $\\pi_1(X,x)$ is conjugation by $\\gamma$.\n\n\\begin{rem}\nIf $X$ is simply-connected, then we get \\emph{canonical} isomorphisms $\\pi_n(X,x) \\simeq \\pi_n(X,y)$ for all pairs of points $x,y\\in X$.\\marginnote{there is an analogue when we talk about just a simply-connected path component of $X$ and points in it} For this reason, many authors omit basepoints when talking about homotopy groups when it is not important.\n\\end{rem}\n\n\\begin{rem}\nSince, for each $n$ we get a representation $\\Pi_1(X) \\to \\Ab$ from the collection of higher homotopy groups $\\pi_n(X,x)$, there is a representation $\\Pi_1(X) \\to \\Ab \\to \\Set$ gotten by composing with the underlying set functor $\\Ab \\to \\Set$. From this we get a covering space of $X$, whose fibre at $x\\in X$ is $\\pi_n(X,x)$. In fact this covering space `remembers' the fact that each higher homotopy group is actually a group, in that it is a continuously-varying family of groups, not just of sets.\n\\end{rem}\n\n\\begin{lemma}\nGiven a pair of pointed spaces $(X,x)$ and $(Y,y)$, there is an\\marginnote{natural, even} isomorphism $\\pi_n(X\\times Y,(x,y)) \\xrightarrow{\\simeq} \\pi_n(X,x) \\times \\pi_n(Y,y)$.\n\\end{lemma}\n\nJust as we saw that homotopic maps should be considered the same from the point of view of fundamental groups and covering spaces, the same is true for higher homotopy groups\n\n\\begin{lemma}\nLet $f,g\\colon X\\to Y$ be homotopic, say via $H\\colon I\\times X \\to Y$. Then there is a commutative triangle\n\\[\n  \\xymatrix{\n    & \\pi_n(Y,f(x)) \\ar[dd]^{\\simeq}\\\\\n    \\pi_n(X,x) \\ar[ur]^{f_*} \\ar[dr]_{g_*} \\\\\n    & \\pi_n(Y,g(x))\n  }\n\\]\n\\end{lemma}\n\\begin{proof}\nThe result follows for the special case of $Y = I\\times X$ with $H=\\id_{I\\times X}$ the homotopy between the inclusion maps $f\\colon X\\simeq \\{0\\}\\times X \\into I \\times X$ and $g\\colon X\\simeq \\{1\\}\\times X \\into I \\times X$.\n\n\\end{proof}\n\n\\begin{prop}\nIf $f\\colon X\\to Y$ is a homotopy equivalence, then $f_*\\colon \\pi_n(X,x) \\xrightarrow{\\simeq} \\pi_n(Y,f(x))$ is an isomorphism.\n\\end{prop}\n\n\\begin{proof}\n(Idea) Since $f$ is a homotopy equivalence, there is a map $g\\colon Y\\to X$ such that $g\\circ f$ is homotopic to $\\id_X$ and $f\\circ g$ is homotopic to $\\id_Y$. We apply the lemma to these homotopies.\n\\end{proof}\n\nIt is very hard to calculate homotopy groups, and one needs to use all kinds of tricks and sometimes even results from differential topology\\marginnote{like Sard's theorem, for example} to even calculate them for relatively simple spaces, like spheres. In fact we don't know all the homotopy groups for \\emph{any} sphere $S^n$ with $n>1$. However, once there are a few homotopy groups that we know for `standard' spaces, then we can use the following objects in order to generate relations between homotopy groups of different spaces, and thus calculate more of them. \n\n\\begin{definition}\nA \\emph{fibre bundle} on a space $X$ is a space $P$ together\\marginnote{recall that this means that this diagram commutes: $\\xymatrix{\\pi^{-1}(U) \\ar[rr]^\\simeq \\ar[dr]_\\pi && U\\times F \\ar[dl]^{\\pr_1} \\\\ & U}$} with a map $\\pi\\colon P \\to X$ such that for every $x\\in X$ there is a nhd $U\\ni x$ and an isomorphism $\\pi^{-1}(U) \\xrightarrow{\\simeq} U\\times F$ over $U$ for some space $F$. In this setting we call $X$ the \\emph{base space}, $P$ the \\emph{total space} and $F$ the \\emph{fibre}.\n\\end{definition}\n\nIt is not obvious, but it follows that for $X$ path connected, we do not need to assume that for every point the space $F$ is some fixed space, as all the fibres $\\pi^{-1}(x)$ are automatically (non-canonically) homeomorphic. \n\nThis is a big generalisation of the notion of covering space, in that the space $F$ no longer needs to be discrete.\n\n\\begin{example}\nEvery covering space is a fibre bundle.\n\\end{example}\n\n\\begin{example}\nLet $S^3 \\subset \\CC^2$ be the unit sphere, consisting of pairs of points $(z,w)$ such that $|z|^2 + |w|^2 = 1$. There is a projection map $S^3 \\to \\mathbb{CP}^1$ sending the point $(z,w)$ to the point of the complex projective line $\\mathbf{CP}^1$ with homogeneous coordinates $[z:w]$. By the defining equation, this is well-defined, since we don't have $z$ and $w$ simultaneously vanishing. The preimage of a point $[z:w]$ is homeomorphic to a copy of the unit complex numbers $U(1) \\subset \\CC$. This is a famous fibre bundle, called the \\emph{Hopf bundle}. There are very few fibre bundles whose base space, total space and fibre are all spheres, so this is a somewhat atypical object, but very concrete and a good test case for trying out new ideas.\n\\end{example}\n\nWe need to relate homotopy groups of different spaces not just via the functoriality we already know about, but even homotopy groups in different dimensions.\n\n\\begin{definition}\nA sequence\n\\[\n  \\cdots \\to A_{n-1} \\xrightarrow{f_{n-1}} A_n \\xrightarrow{f_n} A_{n+1} \\to \\cdots \n\\]\nof (abelian) groups and homomorphisms is called \\emph{exact at $A_n$} if $\\ker(f_n) = \\im(f_{n-1})$. It is called \\emph{exact} if it is exact at $A_n$ for all $n$.\n\\end{definition}\n\n\\begin{example}\nA special case is where we have three successive nonzero terms:\n\\[\n  0\\to A \\xrightarrow{\\alpha} B \\xrightarrow{\\beta} C \\to 0\n\\]\nSuch an exact sequence is called a \\emph{short exact sequence}. It has the properties that: $\\alpha$ is injective, $\\beta$ is surjective, and $\\ker(\\beta) = \\im(\\alpha)$.\n\\end{example}\n\nAn even more trivial-seeming example, that still turns up in practice\n\n\\begin{example}\nA sequence $0\\to A \\xrightarrow{\\phi} B \\to 0$ is exact if and only if $\\phi$ is an isomorphism.\n\\end{example}\n\n\\begin{rem}\nThe definition of exact sequence still makes sense (just!) for pointed sets and functions: given $(A,a) \\xrightarrow{f} (B,b) \\xrightarrow{g}  (C,c)$ pointed functions, this is exact at $(B,b)$ if $\\im(f) = g^{-1}(c)$. The reason we care about this is that if $(X,x)$ is a pointed space $[\\pt,X] \\simeq [S^0,(X,x)]_*$ is a pointed set.\n\\end{rem}\n\nGiven a fibre bundle $\\pi\\colon P\\to X$, we say it is pointed if we are given $x\\in X$ and some $p\\in F = \\pi^{-1}(F)$.\n\n\\begin{theorem}\nFor a pointed fibre bundle $q\\colon (P,p) \\to (X,x)$, there is an exact sequence\n\\[\n\\hspace{-1.5cm}\\cdots \\to \\pi_n(F,p) \\xrightarrow{i_*} \\pi_n(P,p) \\xrightarrow{q_*}\\pi_n(X,x) \\xrightarrow{\\delta} \\pi_{n-1}(F,p) \\xrightarrow{i_*} \\cdots \\to \\pi_1(F,p) \\xrightarrow{i_*} \\pi_1(P,p) \\xrightarrow{q_*} \\pi_1(X,x) \\xrightarrow{\\delta}  [\\pt,F] \\xrightarrow{i_*} [\\pt,P] \\xrightarrow{q_*} [\\pt,X]\n\\]\nwhere $i\\colon F\\into P$ is the inclusion.\n\\end{theorem}\n\nFor the proof of this theorem, see Hatcher, Theorem 4.41. The exact sequence in the theorem is sometimes called the `long exact sequence' to distinguish it from various short exact sequences that arise.\n\n\\begin{rem}\nA few words are in order about the exactness at $\\pi_1(X,x)$ and further terms that are only pointed sets. If $P$ is path connected, then we have $\\cdots \\to \\pi_1(P,p)\\to \\pi_1(X,x) \\to [\\pt,F] \\to *$. If $\\pi_1(X,x) \\to [\\pt,F]$ \\emph{were} a group homomorphism, this would be enough to tell us that $[\\pt,F] \\simeq \\pi_1(X,x)/q_*(\\pi_1(P,p))$, but we aren't even guaranteed that $\\pi_1(P,p)$ is normal in $\\pi_1(X,x)$. So we should interpret exactness to be defined as $[\\pt,F] \\simeq \\pi_1(X,x)/q_*(\\pi_1(P,p))$ \\emph{as pointed sets}. In general, if $P$ is not path connected, we should take exactness here to mean that $\\pi_1(X,x)/q_*(\\pi_1(P,p))\\simeq i_*^{-1}(p)\\subset [\\pt,F]$. Finally, even though $\\delta \\pi_1(X,x) \\to [\\pt,F]$ is not a homomorphism, we have that $q_*(\\pi_1(P,p))$ is the preimage of the basepoint under $\\delta$.\n\\end{rem}\n\n\\begin{example}\nFor a pointed covering space $(Z,z)\\to (X,x)$, the long exact sequence breaks up, because of the fibre being discrete. There are sections of the form\n\\[\n  \\cdots \\to 0 = \\pi_n(Z_x,z) \\to \\pi_n(Z,z) \\to \\pi_n(X,x) \\to \\pi_{n-1}(Z_x,z) = 0 \\to \\cdots \\qquad n >1\n\\]\nimplying that $\\pi_n(Z,z) \\simeq \\pi_n(X,x)$ for $n>1$. The exact sequence ends on\n\\[\n  \\cdots \\to 0=\\pi_1(Z_x,z) \\to \\pi_1(Z,z) \\to \\pi_1(X,x) \\to [\\pt,Z_x] = Z_x \\to [\\pt,Z]\\to [\\pt,X]\n\\]\nSo we see again that $\\pi_1(Z,z) \\to \\pi_1(X,x)$ is injective, as we had before. Similarly, if $[\\pt,Z]=\\ast$, that is, $Z$ is path connected, then $\\pi_1(X,x) \\to Z_x$ is surjective. \n\\end{example}\n\nThis example should serve to highlight the fact that the long exact sequence of homotopy groups is a big generalisation of the relation between the fundamental group of $X$ and those of its covering spaces. However, we can still get some new things using covering spaces here. \n\n\\begin{example}\nIf $X$ is an slsc space with \\emph{contractible} universal covering space, then $\\pi_n(X) = 0$ for $n>1$. This is true for any torus $\\mathbb{T}^n$, for instance, and the circle $S^1$ in particular.\n\\end{example}\n\nLet's now apply the long exact sequence to our other example\n\n\\begin{example}\nConsider the Hopf bundle $S^3\\to S^2$. We have that spheres are connected, and even $\\pi_1(S^n) = 0$ for $n>1$, as well . So we get\n\\[\n \\cdots \\to 0 = \\pi_n(S^1) \\to \\pi_n(S^3) \\to \\pi_n(S^2) \\to \\pi_{n-1}(S^1) = 0 \\to \\cdots \\qquad n>2\n\\]\nand\n\\[\n\\cdots \\to 0=\\pi_2(S^1) \\to \\pi_2(S^3) \\to \\pi_2(S^2) \\to \\pi_1(S^1) = \\ZZ \\to 0 \\to \\cdots\n\\]\nThus we see that for $n>2$, $\\pi_n(S^3) \\simeq \\pi_n(S^2)$, and that there is a short exact sequence \n\\[\n0\\to \\pi_2(S^3) \\to \\pi_2(S^2) \\to \\ZZ \\to 0\n\\]\nThis implies that $\\pi_2(S^2)$ is an infinite abelian group, and $\\pi_2(S^2)/ \\pi_2(S^3) \\simeq \\ZZ$.\n\\end{example}\nAllowing ourselves some black box results, then it is true that $\\pi_2(S^3) = 0$, and $\\pi_3(S^3) \\simeq \\ZZ$. This then implies that $\\pi_2(S^2) = \\ZZ$, and $\\pi_3(S^2) = \\ZZ$.\n\n\\begin{rem}\nIn fact, $\\pi_k(S^n) = 0$ for \\emph{all} $0<k<n$. These is a standard result, but the proof is beyond the techniques of the course so far.\n\\end{rem} \n\nHere is a bonus example, presented with no construction.\n\\begin{example}\nThere is also a fibre bundle $S^7\\to S^4$ with fibre $S^3$. Applying the long exact sequence we get a section of it that looks like\n\\[\n\\cdots \\to 0=\\pi_4(S^7) \\to \\pi_4(S^4) \\to \\pi_3(S^3) \\to \\pi_3(S^7) = 0 \\to \\cdots \n\\]\nSince we know $\\pi_3(S^3) = \\ZZ$, then $\\pi_4(S^4) = \\ZZ$ also.\n\\end{example}\n\n\\begin{rem}\nAnd in fact it's a classical result that $\\pi_n(S^n) = \\ZZ$ for \\emph{all} $n$. Again, the proof is beyond the scope of the course so far.\n\\end{rem}\n\nEven knowing the homotopy groups of sphere is hard, which is why Serre was awarded a Fields medal (in part) for developing tools that could calulate that, for example, all homotopy groups of spheres are finite except for $\\pi_n(S^n)=\\ZZ$, and $\\pi_{4n-1}(S^{2n}) = \\ZZ \\oplus A$ where $A$ is finite abelian. Odd and unexpected stuff happens, for instance (to pick an example at random) $\\pi_{25}(S^6) = \\ZZ/{1056 \\ZZ} \\oplus \\ZZ/8\\ZZ$.\n\nA\\lecturenum{19} large source of fibre bundles to which the long exact sequence can be applied arise from Lie groups.\n\nLet $G$ be a Lie group,\\marginnote{For instance: the groups $GL(n), O(n), SO(n), U(n), SU(n)$ of $n\\times n$ invertible, orthogonal, special orthogonal, unitary and special unitary matrices respectively, where `special' means the determinant is $1$. The smaller groups are closed subgroups of the bigger ones as the subgroups of block submatrices extended by the identity matrix} and let $H$ be a closed subgroup. Then the quotient map $G\\to G/H$ for the multiplication action of $H$ on $G$ is a fibre bundle with fibres isomorphic to $H$.\n\n\\begin{example}\nThere are fibre bundles on spheres arising in this way: namely $SO(n+1) \\to SO(n+1)/SO(n) \\simeq S^n$ with fibre $SO(n)$, and $SU(n+1) \\to SU(n+1)/SU(n) \\simeq S^{2n+1}$ with fibre $SU(n)$.\n\\end{example}\n\n\\begin{example}\nThe Hopf bundle turns out to be an example of this form, namely $SU(2) \\to SU(2)/U(1) \\simeq S^2$, where $U(1) \\into SU(2)$ as the diagonal matrices with entries $z$ and $\\overline{z}$.\n\\end{example}\n\nTrivial-seeming, but useful, is the result that $SU(2) = SU(2)/SU(1) \\simeq S^3$, as $SU(1)$, the group of $1\\times 1$ unitary matrices with determinant $1$, is trivial. Another very useful fact is that there is a surjective homomorphism $SU(2) \\to SO(3)$\\marginnote{this arises because there is an isomorphism \\emph{of Lie groups} of $SU(2)$ with the group of quaternions of unit length, and unit quaternions act by conjugation on the subspace of pure imaginary quaternions as rotations} whose kernel is the centre $\\{\\pm I\\} < SU(2)$. This means that $SO(3) = SU(2)/\\{\\pm I\\}$, and hence there is a fibre bundle $SU(2) \\to SO(3)$ (in fact a covering space).\n\nSince $SU(2)$ is topologically $S^3$, it is simply-connected, and since $\\{\\pm I\\}$ acts freely with quotient $SO(3)$, $\\pi_1(SO(3),I) = \\{\\pm I\\} \\simeq \\ZZ/2\\ZZ$. Now let's consider what the long exact sequence of homotopy groups associated to the fibre bundle $SO(n+1) \\to S^n$ tells us. We will only look at the tail end of it at present, assuming $\\geq 3$:\n\\[\n\t\\cdots \\to \\pi_2(S^n,*) = 0 \\to \\pi_1(SO(n),I) \\to \\pi_1(SO(n+1),I) \\to \\pi_1(S^n,*) = 0 \\to \\cdots\n\\]\nwhere we have used $\\pi_2(S^n) = 0$ as remarked before. Exactness tells us that $\\pi_1(SO(n),I) \\to \\pi_1(SO(n+1),I)$ is an isomorphism for $n\\geq 3$, and so by induction $\\pi_1(SO(n),I) \\simeq \\ZZ/2\\ZZ$ for all $n\\geq 3$. If we look at the case $n=2$, we see an interesting phenomenon, namely that we have the exact sequence\n\\[\n\t\\cdots \\to \\pi_2(SO(3),I) \\to \\pi_2(S^2,*) = \\ZZ \\to \\pi_1(SO(2),I) \\to \\pi_1(SO(3),I) \\to \\pi_1(S^2,*) = 0 \\to \\cdots\n\\]\nNow $SO(2)$ is the group of $2\\times 2$ rotation matrices, which is homeomorphic to $S^1$, and we know well that $\\pi_1(S^1,1)=\\ZZ$. Making the substitutions for the known groups we get the exact sequence\n\\[\n\t\\cdots \\to \\pi_2(SO(3),I) \\xrightarrow{\\pi_*} \\ZZ \\xrightarrow{\\delta} \\ZZ \\xrightarrow{i_*} \\ZZ/2\\ZZ \\to 0 \n\\]\nExactness tells us that $i_*$ is surjective, so that its kernel is $2\\ZZ$, and this is then the image of $\\delta$ is also $2\\ZZ$. Thus $\\delta\\colon \\ZZ \\to \\ZZ$ is multiplication by $2$! Moreover, this also tells us that the homomorphism $\\pi_*\\colon \\pi_2(SO(3),I) \\to \\pi_2(S^2,*)=\\ZZ$ is the zero map. In this way, we don't just get information about the homotopy groups, but about the induced maps between them, which is just as important. If we go one more step up the sequence, and consider\n\\[\n\t\\cdots \\to \\pi_2(SO(2),I) \\xrightarrow{i_*} \\pi_2(SO(3),I) \\xrightarrow{0} \\ZZ \\xrightarrow{\\times 2} \\ZZ \\xrightarrow{\\mod 2} \\ZZ/2\\ZZ \\to 0\n\\]\nthen we know that $\\pi_2(SO(2),I) \\simeq \\pi_2(S^1,*) = 0$, so we know that $i_*$ must have trivial image. But this is the kernel of $\\pi_*\\colon \\pi_2(SO(3),I) \\to \\pi_2(S^2,*)$, namely all of $\\pi_2(SO(3),I)$, and so $\\pi_2(SO(3)) = 0$. We could have gotten this result a different way, using $0=\\pi_2(S^3)\\simeq\\pi_2(SU(2)) \\simeq \\pi_2(SO(3))$, as $SU(2) \\to SO(3)$ is a covering space, but here we didn't need to already know that $\\pi_2(S^3)=0$.\n\n\\begin{rem}\nIt is a hard fact that for \\emph{all} finite-dimensional Lie groups $G$, $\\pi_2(G,e) = 0$.\n\\end{rem}\n\nEarlier in the course, we said that algebraic topology was about finding invariants of spaces up to continuous deformation, and that continuous deformation meant homotopy equivalence. However, that was not quite the whose story. If we take the collection of all homotopy groups to be our collection of invariants, then if given a pair of spaces $X$, $Y$ and a map $f\\colon X\\to Y$, if $f$ induces isomorphisms between all homotopy groups, then there is no way to tell $X$ and $Y$ apart. This leads to the following definition\n\n\\begin{definition}\nA map $f\\colon X\\to Y$ of spaces is called a \\emph{weak homotopy equivalence} if $\\Pi_1(X) \\to \\Pi_1(Y)$\\marginnote{this is equivalent to asking that $[\\pt,X] \\xrightarrow{\\simeq} [\\pt,Y]$ and $\\pi_1(X,x) \\xrightarrow{\\simeq} \\pi_1(Y,f(x))$ for all $x\\in X$} is an equivalence of groupoids, and if for all $x\\in X$ and $n>1$, the induced map $f_*\\colon \\pi_n(X,x) \\to \\pi_n(Y,f(x))$ is an isomorphism.\n\\end{definition}\n\n\\begin{example}\nAll homotopy equivalences $f\\colon X\\to Y$ are weak homotopy equivalences.\n\\end{example}\n\nBut there are examples of weak homotopy equivalences that are not homotopy equivalences\n\n\\begin{example}\nConsider the topologist's sine curve $C$. Equip the set $\\{a,b\\}$ with the discrete topology, and take a map $\\{a,b\\} \\to C$ that picks out a basepoint in each path component. This is a weak homotopy equivalence as both spaces have trivial homotopy groups $\\pi_n$ for $n\\geq 1$ and both have two path components, but there is no surjective map $C \\to \\{a,b\\}$, as $C$ is connected.\n\\end{example}\n\n\n\\begin{example}\n\nThe \\emph{Warsaw circle} $W$ is constructed from the topologist's sine curve by adding \nan arc\\marginnote[-1cm]{\n\\begin{tikzpicture}[x=5cm]\n\\draw[gray,domain=0.01:1/pi,samples=2500,ultra thin]plot(\\x,{sin(deg(1/\\x))});\n\\draw[gray,thin](0,-1)--(0,1);\n\\draw[gray,ultra thin,densely dotted](0.003,-1)--(0.003,1)(0.006,-1)--(0.006,1)(0.009,-1)--(0.009,1);\n\\draw[gray,thin](0,0)--(-0.1,0)--(-0.1,1.5)--(1/pi,1.5)--(1/pi,-0.01);\n\\end{tikzpicture}\n\n\\noindent more formally, it is the quotient space $C \\sqcup [0,1] \\to W$ where \nwe identify $0$ and $1$ with the appropriate points on $C$\n} from the `free endpoint' of \nthe oscillating path component to the other path component on the $y$-axis. Then $W$ is \npath connected, but still has all homotopy groups trivial. Thus the map $W\\to \\pt$ is a \nweak homotopy equivalence, but there is no contraction of $W$ as this would ultimately \ngive rise to a path contained in the topologist's sine curve from one path component to \nthe other.\n\n\\end{example}\n\nAnother class of examples illustrates why making a general assumption that our spaces are slpc is harmless from the point of view of homotopy theory.\n\n\\begin{definition}\nFor any space $X$, define the quotient topology on $[\\pt,X]$ coming from the map $X\\to [\\pt,X]$. We can also consider the discrete space $\\disc[\\pt,X]$, which comes with a bijective map $\\disc[\\pt,X] \\to [\\pt,X]$. Define the space $\\mathrm{slpc}(X)$ to be the pullback in the square\n\\[\n\t\\xymatrix{\n\t\t\\disc[\\pt,X] \\times_{[\\pt,X]} X \\ar[rr] \\ar[d] && X \\ar[d]\\\\\n\t\t\\disc[\\pt,X] \\ar[rr] && [\\pt,X]\n\t}\n\\]\n\\end{definition}\n\nOne way to think of this is that we put a new topology on the underlying set of $X$ so that it becomes the disjoint union of its path components.\n\n\\begin{lemma}\nThe assignment $X\\mapsto \\mathrm{slpc}(X)$ is the object component of a functor $\\Top \\to \\Top$ landing inside the full subcategory of slpc spaces.\n\\end{lemma}\n\n\\begin{proof}\nExercise.\n\\end{proof}\n\nBy construction, there is a continuous, bijective map $\\mathrm{slpc}(X) \\to X$ that is the identity map on the underlying sets.\n\n\\begin{lemma}\nThe map $\\mathrm{slpc}(X) \\to X$ is a weak homotopy equivalence, and is not a homotopy equivalence if $X$ is not already slpc.\n\\end{lemma}\n\nThus if we cannot tell apart spaces that are weakly homotopy equivalent, it is relatively harmless to work only with slpc spaces.\n\n\\section{Complexes}\n\nRecall the Euler characteristic of a polyhedron $P$:\n\\[\n\t\\chi(P) = \\underbrace{\\text{\\#(vertices)}}_{0\\text{-dim}} - \\underbrace{\\text{\\#(edges)}}_{1\\text{-dim}} + \\underbrace{\\text{\\#(faces)}}_{2\\text{-dim}}\n\\]\nThis definition doesn't require the polyhedron to be convex, simply-connected or even connected. It's not even restricted to surfaces, if we define\n\\[\n\t\\chi(P) = \\sum_{d=0}^{\\dim P} (-1)^d \\text{\\#($d$-dim faces)}\n\\]\nHowever, $\\chi$ is not functorial in any way and so we cannot relate in any obvious way the Euler characteristics of different polyhedra. Ideally, we would have a functor from which we can then reconstruct the Euler characteristic. The key idea is to replace the vertex, edge, etc count by the dimension of some vector space. The vertx, edge, etc counts can be reconstructed from the vector space, but now we could in principle have an infinite-dimensional vector space, which would arise in the case that we have an \\emph{infinite} polyhedron\\marginnote{for instance a triangulation of an infinite-genus surface}\n\n\n\\begin{definition}\nA \\emph{complex} $A_\\bullet$ (of vector spaces, abelian groups, $R$-modules) is a sequence \n\\[\n\t\\cdots \\to A_{n-1} \\xrightarrow{d_{n-1}} A_n \\xrightarrow{d_n} A_{n+1} \\to \\cdots\n\\]\n(of vector spaces, abelian groups, $R$-modules) such that $d_n\\circ d_{n-1} = \n0$\\marginnote{equivalently, $\\im(d_{n-1}) \\subseteq \\ker(d_n)$} for all $n$\n\\end{definition}\n\n\\begin{example}\nAny exact sequence, of abelian groups say, gives a complex.\n\\end{example}\n\nAs for exact sequences, we can have a section of the complex that consists of nontrivial \ngroups, vector spaces etc and the rest of the complex can be trivial. In this case \nwe can restrict attention to the nontrivial section.\n\n\\begin{example}\nThe following is a complex:\n\\[\n\t0\\to \\ZZ \\xrightarrow{\\times 4} \\ZZ \\xrightarrow{\\mod{2}} \\ZZ/2\\ZZ \\to 0\n\\]\nNow we have an injective map on the left, and a surjective map on the right, but we only have that $4\\ZZ < 2\\ZZ$, not an equality of the kernel and the image.\n\\end{example}\n\n\n\\begin{example}\nLet $A$ and $B$ be a pair of $n\\times n$ real matrices such that $BA$ is the zero matrix, considered as linear maps. Then\n\\[\n\t0\\to \\RR^n \\xrightarrow{A} \\RR^n \\xrightarrow{B} \\RR^n \\to 0\n\\]\nis a complex. There is no way for this to be exact, because then $B$ would have to be surjective, hence invertible, and $A$ would have to be injective, hence invertible, but then we cannot have $BA=0$.\n\\end{example}\n\nHere is an example which should be familiar from multivariable calculus. For $U\\subset \\RR^n$ an open subset, let $C^\\infty(U)$ denote the vector space of smooth functions on $U$ and $C^\\infty(U,\\RR^3)$ be the vector space of vector fields on $U$.\n\n\\begin{example}\nThe various derivative operators $\\nabla$ (gradient), $\\nabla\\times-$ (curl) and $\\nabla\\cdot -$ (divergence) give acomplex denoted $\\Omega^\\bullet(U)$:\n\\[\n\tC^\\infty(U) \\xrightarrow{\\nabla} C^\\infty(U,\\RR^3) \\xrightarrow{\\nabla\\times -} C^\\infty(U,\\RR^3) \\xrightarrow{\\nabla\\cdot -} C^\\infty(U) \\to 0\n\\]\nbecause the curl of a gradient is zero, and the divergence of a curl is zero.\n\\end{example}\n\n\\begin{definition}\nA map of complexes\\marginnote{sometimes called a \\emph{chain map}} $A_\\bullet \\to \nB_\\bullet$ consists of a sequence of maps $f_n\\colon A_n \\to B_n$ such that all the \nsquares\n\\[\n\t\\xymatrix{\n\t\tA_{n-1} \\ar[r]^{d_{n-1}^A} \\ar[d]_{f_{n-1}} & A_n \\ar[d]^{f_n}\\\\\n\t\tB_{n-1} \\ar[r]_{d_{n-1}^B} & B_n\n\t}\n\\]\nThe category of complexes of $R$-modules and chain maps is denoted $\\Cplx_R$.\n\\end{definition}\n\n\\begin{example}\nGiven the matrices $A$ and $B$ from the previous example, there is map of complexes\n\\[\n\t\\xymatrix{\n\t\t0 \\ar[r] \\ar@{=}[d] & 0 \\ar[r] \\ar[d] & \\RR^n \\ar[r]^A \\ar[d] & \\RR^n \\ar[r]^B \\ar[d] & \\RR^n \\ar[r] \\ar[d] & 0 \\ar@{=}[d]\\\\\n\t\t0 \\ar[r] & \\ker(A) \\ar[r] & 0 \\ar[r] & \\RR^n/\\im(A) \\ar[r] & \\RR^n \\ar[r] & 0\n\t}\n\\]\n\\end{example}\n\n\\begin{example}\nThere is a map of complexes $\\Omega^\\bullet(\\RR^3) \\to \\Omega^\\bullet(U)$\n\\[\n\t\\xymatrix{\n\tC^\\infty(\\RR^3) \\ar[d] \\ar[r]^{\\nabla} & C^\\infty(\\RR^3,\\RR^3) \\ar[d] \\ar[r]^{\\nabla\\times -} & C^\\infty(\\RR^3,\\RR^3) \\ar[d] \\ar[r]^{\\nabla\\cdot -} & C^\\infty(\\RR^3) \\ar[d] \\ar[r] & 0 \\ar[d] \\\\\n\tC^\\infty(U) \\ar[r]_{\\nabla} & C^\\infty(U,\\RR^3) \\ar[r]_{\\nabla\\times -} & C^\\infty(U,\\RR^3) \\ar[r]_{\\nabla\\cdot -} & C^\\infty(U)\\ar[r] & 0\n\t}\n\\]\nwhere the vertical maps restrict functions and vector fields.\n\\end{example}\n\nNow the complex $\\Omega^\\bullet(\\RR^3)$ is exact,\\marginnote{by the Poincar\\'e \nlemma, or more prosaically by standard multivariable calculus} because a vector field \n$\\mathbf{v}$ on $\\RR^3$ satisfies $\\nabla\\times \\mathbf{v}=\\mathbf{0}$ if and only if \n$\\mathbf{v} = \\nabla f$ for some function $f$, $\\nabla\\cdot \\mathbf{v} = 0$ if and only \nif $\\mathbf{v} = \\nabla\\times \\mathbf{w}$ for some vector field $\\mathbf{w}$, and any \nfunction $\\RR^3\\to \\RR$ is the divergence of some vector field. Ultimately, this is \nbecause $\\RR^3$ is contractible. But if we take $U = \\RR^3\\setminus\\{0\\}$, then there \nare vector fields $\\mathbf{v}$ on $U$ with zero divergence that are not the curl of a \nvector field on $U$. This is because $\\RR^3\\setminus\\{0\\}$ is homotopy equivalent to \n$S^2$, and so the complex $\\Omega^\\bullet(\\RR^3\\setminus\\{0\\})$ can `see' the \nnontrivial topological structure also captured by $\\pi_2(S^2) = \\ZZ$. This is measured \nby the fact that the kernel of $\\nabla\\cdot -$ and the image of $\\nabla\\times -$ do not \ncoincide.\n\nSimilarly, one can take $U = \\RR^3 \\setminus \\ell$ where $\\ell\\subset \\RR^3$ is a \n1-dimensional subspace.\\marginnote{for instance $\\ell=$ the $z$-axis} We have a homotopy \nequivalence between $\\RR^3 \\setminus \\ell$ and $S^1$. And this is detected by the fact \nthere are vector fields in $\\RR^3 \\setminus \\ell$ whose curl vanishes but which are not \nthe gradient of any function. Thus the kernel of $\\nabla\\times -$ and the image $\\nabla$ \nare different. Ultimately, it is not the specific complex that captures the \ninformation of interest, because $\\Omega^\\bullet(\\RR^n)$ is made up of enormous \ninfinite-dimensional vector spaces, but $\\RR^n$ itself is homotopically \nuninteresting.\\marginnote{the keen-eyed will have noticed that the kernel of $\\nabla$ \nconsists of the constant functions, so is isomorphic to $\\RR$. This one-dimensional \nvector space accounts for the fact $[\\pt,\\RR^3] = *$}\n\nWe will look at much smaller examples to properly warm up, to illustrate the type of \nalgebra that will turn up.\n\n\\begin{definition}\\label{def:directed_grph}\nA \\emph{simple directed graph} consists of a set $V$ of \\emph{vertices}, a set $E$ of \nedges and two functions $d_0,d_1\\colon E\\to V$ such that $(d_0,d_1)\\colon E \\to V\\times \nV$ is injective, and $\\im (d_0,d_1) \\cap \\Delta(V) = \\emptyset$\\marginnote{$\\Delta(V) = \n\\{(v,v)\\in V^2\\}$ is the diagonal}\n\\end{definition}\n\nSuch a directed graph has no self-loops from a vertex to itself, and no more than one \nedge between any two vertices. The idea is that an edge $e$ points from $d_1(e)$ to \n$d_0(e)$.\n\n\\begin{example}\\label{eg:triangle_graph}\nLet $V = \\{A,B,C\\}$ and $E = \\{a,b,c\\}$, with\\marginnote{\\begin{tikzpicture}\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$a$} (60:3);\n\\node[below] at (0,0) {$A$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(60:3) node {$\\bullet$} -- node [auto] {$b$} (3,0); \n\\node[above] at (60:3) {$B$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0)  -- node [auto,swap] {$c$} (3,0) node {$\\bullet$};\n\\node[below] at (3,0) {$C$};\n\\end{tikzpicture}}\n\\[\n(d_1,d_0) \\colon \\begin{cases}\na & \\mapsto (A,B)\\\\\nb & \\mapsto (B,C)\\\\\nc & \\mapsto (A,C)\n\\end{cases}\n\\]\nThis graph is denoted $\\partial \\Delta[2]$, for reasons that will become clearer below.\n\\end{example}\n\nTo define a complex from a directed simple graph, for any given set $S$ and ring $R$, let $R^S$ denote the $R$-module\\marginnote{if $R=\\ZZ$, this is the product of $|S|$-many copies of $\\ZZ$, and if $R$ is a field, it's the vector space of functions on $S$} of functions $f\\colon S\\to R$. The following definition is made using $R=\\ZZ$, but it works for any ring $R$ more generally.\n\n\\begin{definition}\nLet $d_0,d_1\\colon E\\rightrightarrows V$ be a simple directed graph. Define the complex\n\\begin{align*}\n0 \\quad \\to \\quad \\ZZ^V & \\quad\\xrightarrow{\\delta} \\qquad\\ZZ^E  \\qquad \\to \\quad 0\\\\\nf \\quad & \\mapsto\\  f\\circ d_0 - f\\circ d_1\n\\end{align*}\n\\end{definition}\n\nHere\\lecturenum{20} are a bunch of concrete examples\n\n\\begin{example}\nConsider the trivial graph with one vertex and no edges. The complex is $0\\to \\ZZ \\xrightarrow{\\delta} 0 \\to 0$, and clearly $\\ker(\\delta)=\\ZZ$ and $\\coker(\\delta) = 0$.\n\\end{example}\n\n\\begin{example}\nThe complex that arises from $\\partial\\Delta[2]$ in Example~\\ref{eg:triangle_graph} is \n$0\\to\\ZZ^3\\xrightarrow{\\delta} \\ZZ^3 \\to 0$. We can identify a generating set of \n$\\ZZ^3 = \\ZZ^V$, namely $\\underline{X}\\colon\\{A,B,C\\}\\to \\ZZ$ for $X\\in \\{A,B,C\\}$ with\n\\[\n\t\\underline{A}(v) = \\begin{cases}\n\t\t\t\t1 & v=A\\\\\n\t\t\t\t0 & \\text{else}\n\t\\end{cases}\n\\]\nand similarly for $\\underline{B}$ and $\\underline{C}$. We can calculate\n\\begin{align*}\n\t\\delta(\\underline{A})(e) & = \\underline{A}(d_0(e)) - \\underline{A}(d_1(e))\\\\\n\t\t\t\t\t\t\t& =\\begin{cases}\n\t\t\t\t\t\t\t-1 & e=a\\\\\n\t\t\t\t\t\t\t0 & e=b\\\\\n\t\t\t\t\t\t\t-1& e=c\n\t\t\t\t\t\t\t\\end{cases}\n\\end{align*}\nWe can see this from the graph itself, in that the vertex $A$ is the source of the edges $a$ and $c$, and isn't incident with the edge $b$. To contrast, $\\delta(\\underline{B})(a) = 1$, as $B$ is the target of the edge $a$. We can then write down the matrix $D$ representing $\\delta$, namely\n\\[\n\tD = \\begin{pmatrix}\n\t\t-1 & 0 & -1\\\\\n\t\t1 & -1 & 0\\\\\n\t\t0 & 1 & 1\n\t\\end{pmatrix}\n\\]\nWe can calculate that $\\ker(D)$ is torsion-free and generated by $\\underline{A} + \\underline{B} - \\underline{C}$, hence is isomorphic to $\\mathbb{Z}$. Similarly, the image of $D$ is generated by $\\underline{A} - \\underline{B}$ and $\\underline{B} - \\underline{C}$, and, incidentally, $\\ZZ^E$ is generated by these two functions together with $\\underline{B}$, so that the $\\coker(D) \\simeq \\ZZ$. As a final remark, note that the Euler characteristic $\\chi=0$.\n\\end{example}\n\n\\begin{rem}\\label{remark:finite_complexes_basis}\nFor any \\emph{finite} graph (and later, more general finite combinatorial objects), we can take the vertices and the edges to represent generating sets for $\\ZZ^V$ and $\\ZZ^E$. But for infinite graphs, this is not the case, and we'd have to be more careful.\n\\end{rem}\n\n\\begin{example}\\label{eg:triangle_graph_cplx}\nConsider\\marginnote{%\n\\begin{tikzpicture}\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$d$} (-30:1.5) node{$\\bullet$};\n\\node[below] at (0,0) {$A$};\n\\node[right] at (-30:1.5) {$D$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto,swap] {$c$} (-150:1.5) node {$\\bullet$};\n\\node[left] at (-150:1.5) {$C$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$b$} (0,1.5) node{$\\bullet$};\n\\node[left] at (0,1.5) {$B$};\n\\end{tikzpicture}} \nthe graph with four vertices $\\{A,B,C,D\\}$ and three edges $\\{b,c,d\\}$ as at right. The complex that arises is $0\\ZZ^4\\xrightarrow{\\delta} \\ZZ^3 \\to 0$, where $\\delta$ is represented by\n\\[\n\tD = \\begin{pmatrix}\n\t\t-1 & 1 & 0 & 0\\\\\n\t\t-1 & 0 & 1 & 0\\\\\n\t\t-1 & 0 & 0 & 1\n\t\\end{pmatrix}\n\\]\nwith respect to the generating set as in Remark~\\ref{remark:finite_complexes_basis}. The \nimage is all of $\\ZZ^3$, hence the cokernel is trivial, and the kernel is $\\ZZ$. For \nthis example we have $\\chi = 1$.\n\\end{example}\n\nWe don't have to use connected graphs!\n\n\\begin{example}\nConsider\\marginnote{%\n\\begin{tikzpicture}\n\\node at (-1,1) {$\\bullet$};\n\\node[left] at (-1,1) {$A$};\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$b$} (0,2) node{$\\bullet$};\n\\node[left] at (0,2) {$B$};\n\\node[left] at (0,0) {$C$};\n\\end{tikzpicture}}\nthe graph with vertex set $\\{A,B,C\\}$, edge set $\\{b\\}$ such that $d_0(b)=B$, \n $d_1(b)=C$. The complex is $0\\to \\ZZ^3 \\xrightarrow{\\delta} \\ZZ \\to 0$, with \n $\\delta$ onto, hence $\\coker(\\delta)=0$. The kernel of $\\delta$ is $\\ZZ^2$, and the \n Euler characteristic is $2$.\n\n\\end{example}\n\n\\begin{ex}\n\\begin{enumerate}\n\\item Given any two simple directed graphs $G_1$, $G_2$, we can define the disjoint \nunion $G_1 \\sqcup G_2$ by taking the disjoint union of their edges and vertices and \ntaking the induced functions $d_0, d_1$. Show $\\ker \\delta_{G_1\\sqcup G_2} \\simeq \\ker \n\\delta_{G_1} \\oplus \\ker \\delta_{G_2}$.\n\n\\item For any directed graph $G$ with underlying shape a polyhedron, show that the \nkernel and cokernel of the associated map $\\delta_G$ both isomorphic to $\\ZZ$.\n\\end{enumerate}\n\\end{ex}\n\nThe first of these two exercises prove that $\\dim\\ker\\delta$ counts the number of \nconnected components, and the second strongly suggest that $\\dim\\coker\\delta$ counts the \nnumber of loops.\n\n\\begin{ex}\nCalculate the kernel and cokernel of a connected simple directed graph with two cycles.\n\\end{ex}\n\n\\begin{rem}\nIt is entirely possible to work not just with simple directed graphs, but general directed \ngraphs, since the definition of the complex associated to a graph as above does not use the \ninjectivity of $(d_0,d_1)$ or disjointness from the diagonal. Thus\\marginnote{\n\\begin{tikzpicture}\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] (0,0) circle [radius = 1];\n\\node at (1,0) {$\\bullet$};\n\\node[right] at (1,0) {$v$};\n\\node[left] at (-1,0) {$e$};\n\\end{tikzpicture}} \nwe can consider a directed\ngraph with one vertex and one edge---a combinatorial model of the circle---and get the complex\n$0\\to \\ZZ \\xrightarrow{\\delta=0} \\ZZ\\to 0$, where now $\\ker\\delta=\\ZZ$ and $\\coker\\delta=\\ZZ$,\nas in Example~\\ref{eg:triangle_graph_cplx}.\n\\end{rem}\n\n\nHowever, as much fun as this is, we really need to think about more than just \n1-dimensional objects. This leads to the question of what the two-dimensional version of \na directed graph is. One option is the following: take sets of vertices, edges and \ntriangular faces, and specify how they fit together, by means of functions analogous to \n$d_0$ and $d_1$ from before.\\marginnote[-1cm]{I would call this (2-skeletal) semisimplicial \nset, but Mike Hopkins called such a thing a \\emph{combinatorial $\\Delta$-complex}}\n\n\n\\begin{example}\\label{eg:triangle_Delta_complex}\nConsider\\marginnote{\n\\begin{tikzpicture}\n\\path [fill=gray!20!white] (0,0) -- (60:3) -- (3,0) -- cycle;\n\\node at (1.5,1) {$f$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$e_2$} (60:3);\n\\node[below] at (0,0) {$v_0$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(60:3) node {$\\bullet$} -- node [auto] {$e_0$} (3,0); \n\\node[above] at (60:3) {$v_1$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0)  -- node [auto,swap] {$e_1$} (3,0) node {$\\bullet$};\n\\node[below] at (3,0) {$v_2$};\n\\end{tikzpicture}\n}\n just a single, filled triangle. Let the vertices be called $v_0$, $v_1$ and \n$v_2$. There are edges $e_0$, $e_1$ and $e_2$, and one face, $f$.\n\\end{example}\n\nNote that in this triangle, $d_0(e_2)=d_1(e_0)$ and so on, where $e_i$ is the edge opposite \nthe vertex $v_i$. The combinatorics of how the edges and vertices fit together are captured\nin the following definition. \n\n\n\\begin{definition}\n\nA \\emph{combinatorial surface} $X_\\bullet$ consists of sets of vertices, \nedges and faces, denoted\\marginnote{so that $X_i$ is \nthe set of $i$-dimensional `faces'; the functions $d_i^n$ are called \\emph{face maps}} $X_0$, $X_1$ and $X_2$ respectively together with \nfunctions $d_i^n\\colon X_n \\to X_{n-1}$ for all $0\\leq i \\leq n$, $0<n\\leq 2$ such \nthat\\marginnote[4ex]{the easiest way to remember \nthese identities is to draw the triangle in Example~\\ref{eg:triangle_Delta_complex}}\n\\begin{align}\\label{eq:simpl_ids_surf}\nd_0^1\\circ d_2^2 & = d_1^1\\circ d_0^2, \\nonumber\\\\\nd_0^1\\circ d_1^2 & = d_0^1\\circ d_0^2,\\\\\nd_1^1\\circ d_2^2 & = d_1^1\\circ d_1^2. \\nonumber\n\\end{align}\nWhen the context is clear, we can usually the superscripts, as the dimension can be inferred\nfrom the data. The \\emph{1-skeleton} of $X_\\bullet$ is the underlying directed graph \ngotten by forgetting $X_2$.\n\\end{definition}\n\nNow note that `surface' here is really a stand-in for `at most 2-dimensional'. There is nothing\nin the definition that requires that $X_2\\neq \\emptyset$. And,\\marginnote{%\n\\begin{tikzpicture}[scale=0.8]\n\\path [fill=gray!20!white] (0,0) -- (60:3) -- (3,0) -- cycle;\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --   (60:3);\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(60:3) node {$\\bullet$} -- (3,0); \n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0)  -- (3,0) node {$\\bullet$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(3,0) -- (5,1)  node {$\\bullet$};\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,2) -- (3,3)  node {$\\bullet$};\n\\node at (4,2) {$\\bullet$};\n\\node at (5,3) {$\\bullet$};\n\\end{tikzpicture}\n}\nmoreover, it is possible \nto have 0- or 1-dimensional `components' in a surface, much as a graph is generically 1-dimensional,\nbut can have isolated vertices, or even consist purely of vertices and no edges. In this way, \na combinatorial surface could be so degenerate it has no triangles and no edges, but if \nthere is at least one triangle, then there must be at least one edge (and at least one vertex).\n\n\n\\begin{example}\nThe triangle from Example~\\ref{eg:triangle_Delta_complex} is denoted $\\Delta[2]$, and has \n$\\Delta[2]_0 = \\{v_0,v_1,v_2\\}$, $\\Delta[2]_1 = \\{e_0,e_1,e_2\\}$ and $\\Delta[2]_2 = \\{f\\}$, \n$d^2_i(f) = e_i$ and $d^1_0,d^1_1\\colon \\Delta[2]_1\\to \\Delta[2]_0$ \nas in Example~\\ref{eg:triangle_graph}, up to relabelling. The 1-skeleton of $\\Delta[2]$ \nis the directed graph $\\partial\\Delta[2]$.\n\\end{example}\n\nAs noted above, we do not need to restrict to the case where the 1-skeleton is a simple directed\ngraph, and so it can be any directed graph.\n\n\\begin{example}\\label{eg:combinatorial_torus}\nWe can provide a combinatorial model of a torus, $T_\\bullet$, by taking $T_0 = \\{v\\}$, \n$T_1 = \\{e_1,e_2,e_3\\}$ and $T_2 = \\{f_1,f_2\\}$ fitting together as\n\n\\begin{center}\n\\begin{tikzpicture}\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$e_1$} (0,3);\n\\node[left] at (0,0) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,3) node {$\\bullet$} --  node [auto] {$e_2$} (4,3);\n\\node[left] at (0,3) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,0) node {$\\bullet$} --  node [auto,swap] {$e_1$} (4,3) node {$\\bullet$};\n\\node[right] at (4,3) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) --  node [auto,swap] {$e_2$} (4,0);\n\\node[right] at (4,0) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,0) --  node [auto,swap] {$e_3$} (0,3);\n\n\\node at (1,1) {$f_1$};\n\\node at (3,2) {$f_2$};\n\\end{tikzpicture}\n\\end{center}\nThus, $d^2_0(f_1)=e_3$, $d^2_1(f_1)=e_1$ and $d^2_2(f_1) = e_2$; $d^2_0(f_2) = e_2$, \n$d^2_1(f_2) = e_1$, $d^2_2(f_2) = e_3$, and $d^1_0(e_i) = v = d^1_1(e_i)$ for $e=1,2,3$.\n\\end{example}\n\nGiven a combinatorial surface $X_\\bullet$, we can define a sequence $C^\\bullet(X_\\bullet)$ \nof abelian groups in a similar way as \nfor a directed graph:\\marginnote{here taking the ring $R=\\ZZ$ for simplicty, the general \ndefinition works the same}\n\\[\n0\\to \\ZZ^{X_0} \\xrightarrow{\\delta_0} \\ZZ^{X_1} \\xrightarrow{\\delta_1} \\ZZ^{X_2} \\to 0\n\\]\nwhere $\\delta_0$ is defined the same way as for a directed graph: $\\delta_0(g) = gd^1_0 - \ngd^1_1\\colon X_1 \\to \\ZZ$ for $g\\in \\ZZ^{X_0}$ and $\\delta_1(g') = g'd^2_0 - g'd^2_1 + g'd^2_2 = \n\\sum_{i=0}^2g'd_i \\colon X_2 \\to \\ZZ$ for $g'\\in \\ZZ^{X_1}$. We will see below that this is \nindeed a complex.\n\n\\begin{rem}\\label{rem:basis_finite_complex}\nIf the combinatorial surface has $X_i$ finite for $i=0,1,2$, then we can \ntake as basis for $\\ZZ^{X_i}$ the set $X_i$, where we identify an element $x\\in X_i$ with \nthe function $X_i\\to \\ZZ$ that is equal to $1$ when evaluated on $x$, and otherwise is $0$.\nIt was remarked in class that some sources consider functions that are only nonzero on \nfinitely many elements of $X_n$, but this is not what we are doing here, and even the maps\n$\\delta_i$ cease to become well-defined, as infinitely many edges might share a vertex, for \nexample. For infinite complexes we need to rely on more abstract means to describe the maps $\\delta_i$,\n if we want them explicity in terms of a basis. \n\\end{rem}\n\n\\begin{example}\nGiven the combinatorial surface $T_\\bullet$ from Example~\\ref{eg:combinatorial_torus}, the \nresulting sequence is \n\\[\n\t0 \\to \\ZZ \\xrightarrow{\\delta_0} \\ZZ^3 \\xrightarrow{\\delta_1} \\ZZ^2 \\to 0\n\\]\nwhere $\\delta_0(g)(e) = g(d_0(e)) - g(d^2_1(e)) = g(v) - g(v) = 0$ for any edge $e\\in X_1$, \nand so is the zero map. If we take the basis as in the previous\nRemark, the map $\\delta_1$ is represented by the matrix\n\\[\n\t\\begin{pmatrix}\n\t-1&1&1 \\\\\n\t-1&1&1\n\t\\end{pmatrix}\n\\] \nand the composite $\\delta_1\\delta_0$ is clearly the zero map, so this is a complex.\n\\end{example}\n\n\\begin{lemma}\nFor any combinatorial surface $X_\\bullet$, the sequence $C^\\bullet(X_\\bullet)$ is a complex.\n\\end{lemma}\n\n\\begin{proof}\nWe need to prove that for any $g\\colon X_0\\to \\ZZ$, and any $x\\in X_2$, we have\n$\\delta_1(\\delta_0(g))(x) = 0$.\n\\begin{align*}\n\\delta_1(\\delta_0(g))(x) & = \\delta_1(g d^2_0 - gd^2_1)(x)\\\\\n\t\t\t & = \\delta_1(gd^2_0)(x) - \\delta_1(gd^2_1)(x)\\\\\n\t\t\t & = gd^1_0d^2_0(x) - gd^1_0d^2_1(x) + gd^1_0d^2_2(x) \\\\\n\t\t\t & - (gd^1_1d^2_2(x) - gd^1_1d^2_1(x) + gd^1_1d^2_2(x))\\\\\n\t\t\t & = 0 \n\\end{align*}\nwhere in the last step we use the equations (\\ref{eq:simpl_ids_surf}).\n\\end{proof}\n\nThe combinatorial torus above has Euler characteristic $\\chi=1 - 3 + 2 = 0$, but if we look\nat the failure of it to be exact, we get $\\ker\\delta_0 \\simeq \\ZZ$, $\\coker\\delta_1 \\simeq \\ZZ$, and \n$\\ker\\delta_1/\\im\\delta_0 \\simeq \\ZZ^2$.\n\n\\begin{rem}\nWe could have taken an arbitrary (commutative, unital) ring $R$ instead of $\\ZZ$ in the \nabove example, and the resulting $\\ker\\delta_0$ etc would be $R$-modules. For $R=\\ZZ$ these are\n$\\ZZ$-modules, hence abelian groups, but for example taking $R=\\ZZ/2$ we get abelian groups, \nbut they have more structure as $\\ZZ/2$-modules.\n\\end{rem}\n\n\n\\begin{ex}\nCalculate\\marginnote{Hint: label the vertices $0,1,2,3$, order the edges from from lower to \nhigher labels, and then define the maps $d_0,d_1,d_2$ for faces using $\\Delta[2]$ as a model} \nthe complex of abelian groups arising from a tetrahedron considered as a combinatorial\nsurface, and the groups $\\ker\\delta_0$, $\\ker\\delta_1/\\ker\\delta_0$.\n\\end{ex}\n\n\\begin{ex}\nConsider\\marginnote{%\n\\begin{tikzpicture}[scale=0.8]\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$e_1$} (0,3);\n\\node[left] at (0,0) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,3) node {$\\bullet$} --  node [auto] {$e_2$} (4,3);\n\\node[left] at (0,3) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{<}}},postaction={decorate}] \n(4,0) node {$\\bullet$} --  node [auto,swap] {$e_1$} (4,3) node {$\\bullet$};\n\\node[right] at (4,3) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) --  node [auto,swap] {$e_2$} (4,0);\n\\node[right] at (4,0) {$v$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{<}}},postaction={decorate}] \n(4,0) --  node [auto,swap] {$e_3$} (0,3);\n\n\\node at (1,1) {$f_1$};\n\\node at (3,2) {$f_2$};\n\n\\end{tikzpicture}\n}\na combinatorial model of the Klein bottle $K_\\bullet$, with two triangles, \nthree edges and one vertex, as in the sketch at right, where $d_0(f_1) = e_3$, \n$d_1(f_1) = e_2$ and $d_2(f_1) = e_1$, and $d_0(f_2) = e_1$, $d_1(f_2) = e_2$ and $d_2(f_2) = e_2$.\nAnd, as for the combinatorial torus, $d_0(e_i) = x = d_1(e_i)$ for $i=1,2,3$.\n(The triangles are considered to be filled, despite the lack of shading.)\n\\end{ex}\n\n\n\\begin{definition}\nGiven a complex $A_\\bullet$ of $R$-modules, and an integer $n$, the $n^{th}$ cohomology \n$H^n(A_\\bullet)$ is the $R$-module\n\\[\n\\frac{\\ker A_n \\xrightarrow{d_n} A_{n+1}}{\\im A_{n-1} \\xrightarrow{d_{n-1}} A_n}\n\\]\n\\end{definition}\n\n\\begin{lemma}\nFor all integers $n$, $H^n \\colon \\Cplx_R \\to R\\Mod$ is a functor.\n\\end{lemma}\n\n\\begin{proof}\nExercise.\n\\end{proof}\n\nHere is the big idea: spaces and their homotopy groups are hard, so to study one, turn \nit into a complex, then look at the cohomology groups instead. And, we want this \nto be a functor. We have seen so far that\n\\[\n\\pi_i(S^2,*) = \\begin{cases}\n* & i=0\\text{ connected}\\\\\n0 & i=1\\text{ by Seifert--van~Kampen}\\\\\n\\ZZ & i=2\\text{ without proof!}\\\\\n\\ZZ & i=3\\text{ also without proof!}\\\\\n\\vdots &\n\\end{cases}\n\\]\nHowever, we can calculate the cohomology groups of the combinatorial surface $T_\\bullet$ using\njust linear algebra, and these seem to capture at least some of this information, with much less\nwork. There are some caveats, in that we haven't actually constructed a functor assigning to\na combinatorial surface its cohomology groups, and, worse, there's no guarantee that a \ncombinatorial tetrahedron (as opposed to an actual space!) really captures the topology of $S^2$.\nBut it should be suggestive as to a different approach.\n\n\\begin{rem}\nThis\\lecturenum{21} lecture started with a long recap of the previous lecture, and I have\ngone back and incorporated some of this material just above, in the section labelled \nlecture 20.\n\\end{rem}\n\nNote that given a combinatorial surface $X_\\bullet$ and a ring $R$ we have cohomology groups\n\\begin{align*}\nH^0(X_\\bullet,R) & := \\ker\\delta_0\\\\\nH^1(X_\\bullet,R) & := \\frac{\\ker\\delta_1}{\\im\\delta_0}\\\\\nH^2(X_\\bullet,R) & := \\frac{R^{X_2}}{\\im\\delta_1} = \\coker\\delta_1\n\\end{align*}\narising from the complex $0\\to R^{X_0} \\to R^{X_1} \\to R^{X_2} \\to 0$. We technically have \n$H^n(X_\\bullet,R)$ for all integers $n$, but these are all the zero module. \nIf $X_2=\\emptyset$, then $R^{X_2} = R^\\emptyset = \\{0\\}$, and so $H^2(X_\\bullet,R) = \\{0\\}$.\n\nWe calculated the cohomology with $R=\\ZZ$ for the combinatorial torus $T_\\bullet$ above to be\n\\[\n\tH^n(T_\\bullet,\\ZZ) = \\begin{cases}\n\t\t\t\t\\ZZ & n=0\\\\\n\t\t\t\t\\ZZ^2 & n=1\\\\\n\t\t\t\t\\ZZ & n=2\n\t\t\t     \\end{cases}\n\\]\nBut, the combinatorial surface $T_\\bullet$ is very definitely not the topological space \n$S^1\\times S^1$! So we need a way to relate actual topological spaces to this combinatorial\ndata. If we go back to the directed graph $\\partial\\Delta[2]$, it looks like it should be a\ncircle (topologically, at least). We could make an actual circle by taking the disjoint union\nof three intervals $[0,1]$ and forming a quotient space so the endpoints are appropriately\nidentified. This idea is called geometric realisation. The following does not work, but gives\nan idea of how the real version might go.\n\n\\begin{constr}\n(Attempt 1) Given a directed graph $X_1 \\rightrightarrows X_0$ We could try to take the \nquotient of $\\bigsqcup_{X_1} I$, where we identify the endpoints of the different copies of \n$I$ according to the incidence of edges in the graph. But, this information is recorded \nin which edges map to the same vertex under the maps $d_0,d_1$, so we should involve these\nfunctions somehow. A bigger problem is what to do with isolated vertices! They certainly are\nnot given by gluing intervals in any sense. So we need to use $X_0$ as well.\n\\end{constr}\n\n\\begin{construction}\n\n(Attempt 2) We could instead take the discrete space on the set of vertices of a \ndirected graph, and then attach the intervals to them. In this sense, any isolated \nvertices turn up in the construction, and any edge only needs to know what vertices it \nis incident with, which is indeed the case by the definition of directed graph. To get \nthis working we need some topological ingredients. Consider\\marginnote{these are in one \nsense `dual' to the combinatorial endpoint functions $d_0,d_1$} the functions \n$\\partial_0,\\partial_1\\colon \\pt\\to I$ with $\\partial_0(\\pt) = 1$ and \n$\\partial_1(\\pt)=0$. Then the geometric realisation of a directed graph $X_1 \n\\rightrightarrows X_0$ should be $(\\bigsqcup_{X_0}\\pt \\sqcup \\bigsqcup_{X_1} I)/\\!\\sim$ \nwhere the equivalence relation identifies $(e,\\partial_i(v))\\sim(d_i(e),v)$. That is, \nthe $i$-endpoint of the interval indexed by the element $e\\in X_1$ should be identified \nwith the point indexed by the vertex $v$. \n\\end{construction}\n\nThis rough construction will soon be superceded by a more formal and systematic definition, \nbut it should capture the idea.\n\n\\begin{example}\\label{eg:join_interval_geom_real}\nConsider the directed graph given by three vertices $\\{v_1,v_2,v_3\\}$ and two edges \n$\\{e_1,e_2\\}$ with $d_1(e_1) = v_1$, $d_0(e_1) = v_2 = d_1(e_2)$ and $d_0(e_2) = v_3$. Its \ngeometric realisation is homeomorphic to $(\\{v_1,v_2,v_3\\} \\sqcup [0,1] \\sqcup [2,3])/\\!\\sim$\nwhere $0\\sim v_1$, $1\\sim v_2 \\sim 2$ and $3\\sim v_3$. Thus it is homeomorphic to \n$([0,1]\\sqcup [2,3])/(1\\sim 2) \\simeq [0,2] \\simeq [0,1]$.\n\\end{example}\n\nNow, how do so something similar for combinatorial surfaces? Now we must make some definitions\nthat will generalise more easily down the track, that are less ad hoc.\n\n\\begin{definition}\nThe \\emph{standard $n$-simplex} is the subspace of $\\RR^{n+1}$ given by\n\\[\n\t\\Delta^n := \\{(v_0,v_1,\\ldots,v_n) \\in \\RR^{n+1} \\mid \\forall\\, 0\\leq i\\leq n, v_i\\geq 0\n\t\t\t\\text{ and } v_0+\\cdots+v_n = 1\\}\n\\]\nThere are inclusion maps between the standard $n$-simplices, namely $\\partial_i\\colon \\Delta^n \\to \\Delta^{n+1}$\ndefined to be $\\partial_i(v_0,\\ldots,v_n) = (v_0,\\ldots,v_{i-1},0,v_i,\\ldots,v_n)$, where\n$0\\leq i \\leq n+1$.\n\\end{definition}\n\n\\begin{example}\nSo\\marginnote{\n\\begin{tikzpicture}\n\\draw (0,1.5) -- (0,-0.3) (-0.5,0)-- (1.5,0);\n\\draw[thick] (0,1) -- (1,0);\n\\node at (45:1.2) {$\\Delta^1$};\n\\end{tikzpicture}\\quad\n\\begin{tikzpicture}\n\\draw[thick] (90:1) -- (-30:1) -- (-150:1) -- cycle;\n\\draw[gray] (-150:1) -- (30:0.3) (90:1)--(-90:0.3) (-30:1)--(150:0.3);\n\\draw (-150:1) -- (-150:1.5) (90:1) -- (90:1.5) (-30:1) -- (-30:1.5);\n\\node at (30:1) {$\\Delta^2$};\n\\end{tikzpicture}\n}  the standard $0$-simplex is a single point, namely $v_0=1\\in \\RR$, the standard $1$-simplex\nis the interval $\\Delta^1 = \\{(v_0,v_1\\in \\RR^2\\mid v_0,v_1 \\geq0,\\ v_0+v_1 = 1\\}$, and the \nstandard $2$-simplex is the portion of the hyperplane $v_0+v_1+v_2 = 1$ with the positive\noctant in $\\RR^3$. \n\\end{example}\n\n\n\n\\begin{example}\nWe have the two maps $\\partial_0,\\partial_1\\colon \\Delta^0 \\to \\Delta^1$ from before, $\\partial_0(v_0) = (0,v_0) = (0,1)$ \nand $\\partial_1(v_0) = (v_0,0) = (1,0)$. And now, imporantly, maps $\\partial_i\\colon \\Delta^1\\to \\Delta^2$, $i=0,1,2$ with\n\\[\n\\partial_i(v_0,v_1) =\\begin{cases}\n(0,v_0,v_1) & i=0\\\\\n(v_0,0,v_1) & i=1\\\\\n(v_0,v_1,0) & i=2\n\\end{cases}\n\\]\n\\end{example}\n\n\\begin{definition}\nThe \\emph{geometric realisation} of a combinatorial surface $X_\\bullet$ is the quotient space\n\\[\n|X_\\bullet| := \\left(\\bigsqcup_{n=0}^2 \\disc(X_n) \\times \\Delta^n\\right)_{\\big/\\!\\sim}\n\\]\nwhere the equivalence relation is generated by \n$(d_i(x),\\mathbf{v}) \\sim (x,\\partial_i(\\mathbf{v}))$.\n\\end{definition}\n\nFor\\marginnote{And, more degenerately, $|\\Delta[1]| = \\Delta^1$ and $|\\Delta[0]|=\\Delta^0$} \ninstance, the geometric realisation of $\\Delta[2]$ is \n\\[\n\\Big((\\Delta^0 \\sqcup \\Delta^0 \\sqcup \\Delta^0) \\sqcup (\\Delta^1 \\sqcup \n\\Delta^1 \\sqcup\\Delta^1) \\sqcup\\Delta^2\\Big)/\\!\\sim\\ \\simeq\\ (\\partial\\Delta^2 \\sqcup\\Delta^2)/\\!\\sim\\ \\simeq\\ \\Delta^2\n\\]\n\nLet us, for the sake of the following definition, be generous with the definition of `surface';\nit should include at least all topological manifolds of dimension 2 or lower, and even of mixed\ndimension (eg the disjoint union of a circle and a torus). The important thing is that a\nsurface here is a topological space, not a combinatorial object.\n\n\\begin{definition}\nA \\emph{triangulation} of a surface $\\Sigma$ is a combinatorial surface $X_\\bullet$ equipped\nwith\\marginnote{we will usually leave the homeomorphism implicit in what follows} \na homeomorphism $\\Sigma \\simeq |X_\\bullet|$.\n\\end{definition}\n\n\\begin{example}\n\\begin{enumerate}\n\\item $\\Delta^2$ is triangulated by $\\Delta[2]$.\n\\item More generally, $|X_\\bullet|$ is triangulated by $X_\\bullet$.\n\\item $S^2$ is triangulated by $\\partial\\Delta[3]$.\n\\item $S^1$ is triangulated by $\\partial\\Delta[2]$, but also by any directed graph in the shape\nof a polygon, or even the directed graph with one vertex and one edge.\n\\item $S^1\\times S^1$ is triangulated by the combinatorial torus $T_\\bullet$.\n\\end{enumerate}\n\\end{example}\n\n\n\nUltimately,\\lecturenum{22} of course, we want some kind of functorial behaviour, so we need\nmaps between combinatorial surfaces. The idea is that vertices get mapped to vertices, edges\nto edges, and triangles to triangles, in a compatible way.\n\n\\begin{definition}\nGiven combinatorial surfaces $X_\\bullet$ and $Y_\\bullet$, a map $f\\colon X_\\bullet\\to Y_\\bullet$ \nis a triple of functions $f_n\\colon X_n\\to Y_n$, $n=0,1,2$ such that $d_if_n = f_{n-1}d_i$ for $0<n\\leq 2$, $0\\leq i \\leq n$.\n\\end{definition}\n\nSuch maps are very rigid, in the sense that there are `obvious' functions between the intended\ngeometric objects that don't come from a map between given combinatorial surfaces. This\ndefinition also includes map between directed graphs, if we take the set of triangles\nto be empty, and maps from a directed graph to a non-degenerate combinatorial surface.\n\n\\begin{example}\nGiven a combinatorial surface $X_\\bullet$, and its 1-skeleton $\\sk_1 X_\\bullet$, there is a morphism\n$\\sk_1X_\\bullet\\to X_\\bullet$ that is the identity on $X_0$ and $X_1$, and the only possible \nfunction $(\\sk_1X_\\bullet)_2 = \\emptyset \\to X_2$. \n\\end{example}\n\n\\begin{example}\nWe can include a single triangle into a combinatorial surface $X_\\bullet$, via \n$\\Delta[2] \\to X_\\bullet$. For instance, $\\Delta[2] \\to \\partial\\Delta[3]$.\n\\end{example}\n\n\\begin{example}\nIf $L_\\bullet$ is the directed graph with one vertex and one edge, and $P_\\bullet$ is any\npolygonal\\marginnote{a polygonal directed graph is a finite directed graph with the same number\nof vertices and edges, the vertices are cyclicly ordered, and there is an edge between adjacent vertices, in either direction} \ndirected graph (for instance $\\partial\\Delta[2]$), then there is a map\n$P_\\bullet \\to L_\\bullet$, sending all vertices to the single vertex of $L_\\bullet$, and\nall edges to the singe edge. We can even triangulate $\\RR$ by taking an infinite directed \ngraph $R_\\bullet$  with vertices indexed by $\\ZZ$ and an edge from $k$ to $k+1$, and then\ndefine a map $R_\\bullet \\to L_\\bullet$ in a similar way.\n\\end{example}\n\n\\begin{example}\\label{eg:infinite_cylinder}\nFor a similar but nondegenerate example, we can define an infinite combinatorial surface that\nmodels an infinite cylinder, with set of faces $\\{f_{1i},f_{2i}\\mid i \\in \\ZZ\\}$, set of \nedges $\\{e_{1i},e_{2i},e_{3i}\\mid i\\in \\ZZ\\}$ and set of vertices $\\{v_i\\mid i\\in \\ZZ\\}$ as\nin the following picture,\n\n\\begin{center}\n\\begin{tikzpicture}\n\n\\draw (-1,0)--(0,0)--(-1,0.75)  (-1,3) -- (0,3);\n\\draw[dotted] (-1.5,0) -- (-1,0) (-1.5,3) -- (-1,3) (-1,0.75)--(-1.5,1.125);\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) node {$\\bullet$} --  node [auto] {$e_{10}$} (0,3);\n\\node[below] at (0,0) {$v_0$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,3) node {$\\bullet$} --  node [auto] {$e_{20}$} (4,3);\n\\node[above] at (0,3) {$v_0$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,0) node {$\\bullet$} --  node [auto,swap] {$e_{11}$} (4,3) node {$\\bullet$};\n\\node[above] at (4,3) {$v_1$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(0,0) --  node [auto,swap] {$e_{20}$} (4,0);\n\\node[below] at (4,0) {$v_1$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,0) --  node [auto,swap] {$e_{30}$} (0,3);\n\n\\node at (1,1) {$f_{10}$};\n\\node at (3,2) {$f_{20}$};\n\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,3) --  node [auto] {$e_{21}$} (8,3);\n\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(8,0) node {$\\bullet$} --  node [auto,swap] {$e_{12}$} (8,3) node {$\\bullet$};\n\\node[above] at (8,3) {$v_2$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(4,0) --  node [auto,swap] {$e_{21}$} (8,0);\n\\node[below] at (8,0) {$v_2$};\n\n\\draw[decoration={markings, mark=at position 0.5 with {\\arrow{>}}},postaction={decorate}] \n(8,0) --  node [auto,swap] {$e_{31}$} (4,3);\n\n\\node at (5,1) {$f_{11}$};\n\\node at (7,2) {$f_{21}$};\n\n\\draw (9,3)--(8,3)--(9,2.25)  (8,0) -- (9,0);\n\\draw[dotted] (9,0) -- (9.5,0) (9,3) -- (9.5,3) (9,2.25)--(9.5,{3-1.125});\n\n\\end{tikzpicture}\n\\end{center}\n\n\\noindent mapping to the combinatorial torus $T_\\bullet$ via $v_i\\mapsto v$, \n$e_{ai}\\mapsto e_a$, $a=1,2,3$ and $f_{bi} \\mapsto f_b$, $b=1,2$ (in fact the face maps \n$d_i$ for the infinite combinatorial cylinder can be reconstructed from the defintion of this map).\n\\end{example}\n\n\\begin{lemma}\nA map $f\\colon X_\\bullet \\to Y_\\bullet$ between combinatorial surfaces gives rise to a continuous map \n$|f|\\colon |X_\\bullet| \\to |Y_\\bullet|$ between their geometric realisations, and this \nconstruction is functorial.\n\\end{lemma}\n\n\\begin{proof}\nFirst, the map $f$ gives rise to a continuous map \n\\[\n\t\\widetilde{|f|}: = \\sqcup_nf_n\\times\\id_{\\Delta^n}\\colon \\bigsqcup_{n=0}^2 \\disc(X_n)\\times \\Delta^n \\to \\bigsqcup_{n=0}^2 \\disc(Y_n)\\times \\Delta^n.\n\\]\nWe can check that this respects the relation that defines the quotients $|X_\\bullet|$ and \n$|Y_\\bullet|$: take $(x,\\partial_i(\\mathbf{v})) \\in \\disc(X_n)\\times \\Delta^n$, so that\n$(x,\\partial_i(\\mathbf{v})) \\sim (d_i(x),\\mathbf{v})$, and then \n\\begin{align*}\n\\widetilde{|f|}(x,\\partial_i(\\mathbf{v})) & = (f_n(x),\\partial_i(\\mathbf{v})) \\\\\n& \\sim (d_i(f_n(x)),\\mathbf{v})\\\\\n& = (f_{n-1}(d_i(x)),\\mathbf{v})\\\\\n& = \\widetilde{|f|}(d_i(x),\\mathbf{v})\n\\end{align*}\nHence there is a unique map $|f|\\colon |X_\\bullet| \\to |Y_\\bullet|$ making the following diagram\ncommute:\n\\[\n\t\\xymatrixnocompile{\n\t\t\\bigsqcup_{n=0}^2 \\disc(X_n)\\times \\Delta^n \\ar[d]\n\t\t\t\\ar[r]^{\\widetilde{|f|}} &\n\t\t\t\\bigsqcup_{n=0}^2 \\disc(Y_n)\\times \\Delta^n \\ar[d]\\\\\n\t\t|X_\\bullet| \\ar[r]_{|f|} & |Y_\\bullet|\n\t}\n\\]\nThe uniqueness of this map means that $|g\\circ f| = |g|\\circ |f|$, for any composable pair of\nmaps $f,g$ of combinatorial surfaces.\n\\end{proof}\n\nFor example, the infinite combinatorial cylinder in Example~\\ref{eg:infinite_cylinder} has as geometric \nrealisation the cylinder $\\RR \\times S^1$, and the map in that example gives rise to the map\n$\\exp\\times \\id\\colon \\RR\\times S^1 \\to S^1\\times S^1$.\n\nGiven a topological surface $\\Sigma$ that admits a triangulation $\\Sigma\\simeq |X_\\bullet|$,\nwe could in principle define its cohomology modules by $H^n(\\Sigma,R) := H^n(X_\\bullet,R)$---but\nthis is a terrible definition. It is only functorial in an extremely limited way, because \nthere's nothing that guarantees that different choices of triangulation give rise to the \nsame cohomology modules, which means this is really a definition for \\emph{triangulated} surfaces, \nthose equipped with a triangulation; also, only those continuous functions that arise from \nthe geometric realisation of a map of combinatorial surfaces give rise\\marginnote{the functoriality of cohomology modules with respect to maps of combinatorial surfaces will be \nsubsumed by a definition to be given below}\nto a linear map of cohomology modules.\n\nMoreover, what about other spaces? We clearly don't want to restrict ourselves to surfaces \nwhen studying topology! Here is a general combinatorial definition with which we can examine\nthe notion of cohomology and calculate interesting examples.\n\n\\begin{definition}\nA \\emph{$\\Delta$-set} is a sequence of sets $X_n$, $n=0,1,2,\\ldots$ of \\emph{$n$-simplices} together\nwith \\emph{face maps} $d_i^n\\colon X_n\\to X_{n-1}$ for $n>0$ and $0\\leq i \\leq n$, such that\n\\[\n\td_i^{n-1}\\circ d_j^n = d_{j-1}^{n-1} \\circ d_i^n \\qquad \\text{for } 0 \\leq i < j \\leq n\n\\]\n(Eventually we will drop the superscripts, as it becomes clear from context what the superscripts should be)\n\\end{definition}\n\n\\begin{example}\nThe combinatorial $n$-simplex $\\Delta[n]$ has\n\\begin{align*}\n\\Delta[n]_0 & = \\{0,1,2,\\ldots,n\\} =: \\mathbf{n+1},\\\\\n\\Delta[n]_1 & = \\text{set of 2-element subsets of }\\mathbf{n+1} =:\\binom{\\mathbf{n+1}}{2},\\\\\n&\\vdots\\\\\n\\Delta[n]_k & = \\text{set of $(k+1)$-element subsets of }\\mathbf{n+1} =: \\binom{\\mathbf{n+1}}{k+1},\\qquad k<n\\\\\n&\\vdots\\\\\n\\Delta[n]_n & = \\{\\mathbf{n+1}\\} = \\{\\text{top face}\\},\\\\\n\\Delta[n]_k & = \\emptyset, \\qquad k>n.\n\\end{align*}\nEach of the subsets in these sets is ordered, and the function \n$d_i^k\\colon\\binom{\\mathbf{n+1}}{k+1} \\to \\binom{\\mathbf{n+1}}{k}$ discards the $i^{th}$ \nelement from each subset, where the indexing starts from $0$.\n\\end{example}\n\n\\begin{example}\nThe boundary $\\partial\\Delta[n]$ is defined so that $\\partial\\Delta[n]_k = \\Delta[n]_k$ for $k<n$ \nempty otherwise. So for instance, the combinatorial surface $\\partial\\Delta[3]$ has vertices,\nedges and triangles (that is: 0-, 1-, and 2-simplices) but no 3-dimensional simplex filling it.\n\\end{example}\n\nMore generally, given any $\\Delta$-set $X_\\bullet$, we can truncate it to its \\emph{$k$-skeleton}\n$\\sk_k X_\\bullet$ which has \n\\[\n\t\\sk_mX_k = \\begin{cases}\n\t\t\tX_k & k \\leq m\\\\\n\t\t\t\\emptyset & k > m \n\t\t\\end{cases}\n\\]\nIf a $\\Delta$-set $X_\\bullet$ has $x\\in X_n$ for some $n$, then $X_m \\neq \\emptyset$ for all\n$0\\leq m< n$. We call a $\\Delta$-set $n$-dimensional if $n$ is the largest integer such that it\nhas an $n$-simplex, and if no such integer exists, we call it infinite-dimensional. If $X_\\bullet$ \nis $n$-dimensional and $0\\leq m < n$ (or $X_\\bullet$ is infinite-dimensional), then \n$\\sk_mX_\\bullet$ is $m$-dimensional. Hence $\\Delta[n]$ is $n$-dimensional and \n$\\partial\\Delta[n] = \\sk_{n-1}\\Delta[n]$ is $n-1$-dimensional. A combinatorial surface, as defined\nabove, has dimension $\\leq 2$.\n\nThe defintitions of geometric realisation, maps and triangulations generalise from the 2-dimensional\ncase to general $\\Delta$-sets.\n\n\\begin{definition}\nThe geometric realisation of a $\\Delta$-set $X_\\bullet$ is the quotient space \n\\[\n|X_\\bullet|:=\\left(\\bigsqcup_{n=0}^\\infty \\disc(X_n)\\times \\Delta^n\\right)_{\\big/\\!\\sim}\n\\]\nby the equivalence relation generated by $(d_i(x),\\mathbf{v}) \\sim (x,\\partial_i(\\mathbf{v}))$.\n\\end{definition}\n\n\n\\begin{definition}\nA map of $\\Delta$-sets $f\\colon X_\\bullet\\to Y_\\bullet$ is a sequence of functions\n$f_n\\colon X_n\\to Y_n$, $n=0,1,2,\\ldots$ such that $d_i^n\\circ f_n = f_{n-1}\\circ d_i^n$ \nfor $0<n$ and $0\\leq i \\leq n$. We thus get a category $\\Delta\\Set$.\n\\end{definition}\n\n\n\\begin{example}\nThere\\marginnote{and this triangle commutes:\n\\xymatrix{\\sk_mX_\\bullet \\ar[r] \\ar[dr] &\\sk_lX_\\bullet \\ar[d] \\\\ &X_\\bullet}} \nis always an inclusion map $\\sk_mX_\\bullet \\to X_\\bullet$, and even \n$\\sk_mX_\\bullet \\to \\sk_lX_\\bullet$ for all $0\\leq m \\leq l$. Moreover, these maps are natural\nin the sense that given $f\\colon X_\\bullet \\to Y_\\bullet$, there is a commutative square\n\\[\n\t\\xymatrix{\n\t\\sk_mX_\\bullet \\ar[r]^{\\sk_mf} \\ar[d] & \\sk_mY_\\bullet \\ar[d] \\\\\n\tX_\\bullet \\ar[r]_f & Y_\\bullet\n\t}\n\\]\n\\end{example}\n\n\\begin{example}\\label{eg:name_of_simplex}\nGiven any $n$-simplex $x\\in X_n$ in a $\\Delta$-set $X_\\bullet$, there is a map \n$\\ulcorner x\\urcorner\\colon \\Delta[n] \\to X_\\bullet$ taking the unique top face of $\\Delta[n]$ to $x$.\n\\end{example}\n\nMore generally, given subsets $Y_n \\subseteq X_n$ for all $n=0,1,2,\\ldots$ such that the \nface maps of $X_\\bullet$ restrict to functions $d_i^n\\colon Y_n\\to Y_{n-1}$, we get a \n$\\Delta$-set $Y_\\bullet$ and an inclusion $Y_\\bullet \\hookrightarrow X_\\bullet$. If \n$X_\\bullet$ is $k$-dimensional, then any subset $Y_k \\subseteq X_k$ gives rise to a $\\Delta$-set\nby taking the union of the images $d_i^k(Y_k) \\subseteq X_{k-1}$, the union of the images \n$d_j^{k-1}d_i^k(Y_k)\\subseteq X_{k-2}$ and so on down to $X_0$.\n\n\n\\begin{lemma}\nGeometric relisation defines a functor $|-|\\colon \\Delta\\Set \\to \\Top$.\n\\end{lemma}\n\n\n\\begin{definition}\nA triangulation of a topological space $X$ is a $\\Delta$-set $X_\\bullet$ equipped with a \nhomeomorphism $X\\simeq |X_\\bullet|$.\n\\end{definition}\n\nAs in the 2-dimensional case, the geometric realisation $|X_\\bullet|$ is triangulated by\n$X_\\bullet$ together with the identity map.\n\nGiven a triangulation of a subspace $Y\\subset X$ of a topological space $X$ (say by the $\\Delta$-set $Y_\\bullet$), we\ncan sometimes need to extend this to a triangulation of $X$. In good situations we can do this\nby finding a $\\Delta$-set $X_\\bullet$ such that $Y_\\bullet \\subset X_\\bullet$.\n\n\n\\begin{example}\nThe standard topological $n$-simplex $\\Delta^n$ is triangulated by the combinatrial $n$-simplex\n$\\Delta[n]$, and the canonical isomorphism induced by $\\bigsqcup_k \\disc(\\Delta[k])\\times \\Delta^k\\to \\Delta^n$.\n\\end{example}\n\nFor a mildly nontrivial example, consider the product $I\\times \\Delta^2$. We know that \n$\\{i\\}\\times \\Delta^2$ is triangulated by $\\Delta[2]$ for $i=0,1$; let us call the vertices\nof the copy of $\\Delta[2]$ corresponding to $\\{0\\}\\times \\Delta^2$, $0$, $1$ and $2$, and the\nvertices of the copy of $\\Delta[2]$ corresponding to $\\{1\\}\\times \\Delta^2$, $\\overline{0}$, \n$\\overline{1}$ and $\\overline{2}$. \n\nThen there is a $\\Delta$-set $P_\\bullet$ with three $3$-simplices \nlabelled by the sets \n\\begin{align*}\n& 0,1,2,\\overline{2}\\\\\n& 0,1,\\overline{1},\\overline{2}\\\\\n& 0,\\overline{0},\\overline{1},\\overline{2}\n\\end{align*}\nwith\n\\marginnote[-2cm]{\\begin{tikzpicture}[scale=0.6]%, every node/.style={transform shape}]\n\n\\draw [name path=f1,opacity=0] (0,0) node[left] {$0$} -- (5,0) -- (5,5) -- (0,5) -- cycle;\n\\draw (0,5) -- (2,4) -- (0,0);\n\\draw (0,5) -- (2,8.5) -- (5,5);\n\\draw [name path=f2,opacity=0] (5,5) -- (0,0);\n\\draw (2,4) -- (5,5);\n\\draw [name path=b1] (2,8.5) -- (2,4) ;\n\\draw [name path=b2] (2,4) -- (5,0);\n\\path [name intersections = {of=f1 and b1,by=inter1}];\n\\path [name intersections = {of=f2 and b2,by=inter2}];\n\\filldraw [white] (inter1) circle (3pt);\n\\filldraw [white] (inter2) circle (3pt);\n\\draw (0,0) -- (5,0) -- (5,5) -- (0,5) -- cycle;\n\\draw (5,5) -- (0,0);\n\n%% From https://tex.stackexchange.com/q/111660/\n% \\draw [name path=a, opacity=0] (0,0) -- (2,2);% line that will be repeated\n% \\draw [name path=b] (0,2) -- (2,0);\n% \\path [name intersections={of=a and b,by=inter}];\n% \\filldraw [white] (inter) circle (2pt);\n% \\draw (0,0) -- (2,2);% line repeated\n\\node[label=50:$0$] at (2,4) {};\n\\node[left] at (0,0) {$1$};\n\\node[right] at (5,0) {$2$};\n\n\\node[above right] at (2,8.5) {$\\overline{0}$};\n\\node[left] at (0,5) {$\\overline{1}$};\n\\node[right] at (5,5) {$\\overline{2}$};\n\\end{tikzpicture}} \nthe $2$-simplices given by three-element subsets of these, the $1$-simplices given by two-element\nsubsets of these, and six $0$-simplices,\n$0, 1, 2, \\overline{0},\\overline{1}$ and $\\overline{2}$. This can visualised as at right.\n\nMore generally, given any $n$, we can define a triangulation of the space $I\\times \\Delta^n$ using an \nanalogous recipe: the desired $\\Delta$-set has $n+1$ $(n+1)$-simplices labelled by the lists\n\\begin{align*}\n& 0,1,\\ldots, n,\\overline{n}\\\\\n& 0,1,\\ldots,n-1,\\overline{n-1},\\overline{n}\\\\\n&\\vdots\\\\\n& 0,\\overline{0},\\overline{1},\\ldots,\\overline{n}\\\\\n\\end{align*}\nsuch that the $n+2$ vertices of each simplex are ordered as shown,\nand the lower-dimensional simplices are labelled by the lists arising from applying the face \nmaps $d_i$ that omit the $i^{th}$ element from the list.\n\n\nGiven a $\\Delta$-set $X_\\bullet$ we can define a sequence of $R$-modules \n\\[\n\t\\cdots \\to R^{X_n} \\xrightarrow{\\delta_n} R^{X_{n+1}} \\to \\cdots\n\\]\nwhere for $g\\colon X_n\\to R$, \n\\[\n\t\\delta_n(g) = \\sum_{i=0}^n (-1)^ig\\circ d_i^{n+1}\\colon X_{n+1}\\to R\n\\]\n\n\\begin{lemma}\nThis sequence is a complex, so that $\\delta_{n+1}\\circ \\delta_n = 0$.\n\\end{lemma}\n\n\\begin{proof}\nExercise!\n\\end{proof}\n\nWe denote this complex by $C^\\bullet(X_\\bullet,R)$, and call it the \\emph{simplicial cochain\ncomplex} of the $\\Delta$-set $X_\\bullet$.\n\nNow notice that given a function $\\alpha\\colon A\\to B$ of sets, there is an $R$-linear map \n$\\alpha^*\\colon R^B\\to R^A$ defined on $(g\\colon B\\to R)\\mapsto (g\\circ \\alpha\\colon A\\to R)$. \nAnd, given another function $\\beta\\colon B\\to C$, we have \n$\\alpha^*\\circ \\beta^* = (\\beta\\circ \\alpha)^*\\colon R^C\\to R^A$. Thus we have a kind of \nfunctoriality, but where the source and target get flipped, and the order of composition likewise. \nThis is summed up by saying we have a functor $R^{(-)}\\colon \\Set^{op}\\to \\Mod_R$, where the \n${}^{op}$ is a reminder that everything gets flipped on applying the functor.\n\n\\begin{lemma}\nThere is a functor $C^\\bullet(-,R)\\colon \\Delta\\Set^{op}\\to \\Cplx_R$.\n\\end{lemma}\n\n\\begin{proof}\nOne just needs to check that given $f\\colon X_\\bullet \\to Y_\\bullet$, we have \n$\\delta_nf_n^* = f_{n+1}^*\\delta_n$, which is a direct computation.\n\\end{proof}\n\nAs a result, we can define the cohomology modules of a $\\Delta$-set.\n\n\\begin{definition}\nThe $n^{th}$ cohomology module $H^n(X_\\bullet,R)$ with coefficients in $R$ is the $n^{th}$ cohomology\nof the complex $C^\\bullet(X_\\bullet,R)$, and so is a functor $H^n(-,R)\\colon \\Delta\\Set^{op}\\to \\Mod_R$.\n\\end{definition}\n\nNote that since $R^\\emptyset = 0$, the trivial module, it is immediate that for an \n$n$-dimensional $\\Delta$-set $X_\\bullet$ we have $H^k(X_\\bullet,R) = 0$ for all $k>n$. \nInfinite-dimensional $\\Delta$-sets may or may not have nontrivial cohomology modules in \ninfinitely-many dimensions. \n\nAnother immediate corollary of this definition is that a finite $\\Delta$-set has finitely-generated\ncohomology modules.\\marginnote{or more generally, a $\\Delta$-set with finitely many simplices in dimension $n$ has $H^n$ finitely-generated}\n\n\\begin{rem}\nIn practice, the only rings $R$ we will consider are $\\ZZ$, $\\RR$ and $\\ZZ/2$.\n\\end{rem}\n\n\\begin{rem}\nGiven a finite $\\Delta$-set, with all of the face maps explicitly described, to calulate\nits cohomology modules is purely a calculational effort in combinatorics and linear algebra.\nHowever, the effort required may be significant, so there are tools we shall develop that will\nassist. Further, for an $\\Delta$-set that is not finite, for instance, being \ninfinite-dimensional or having infinitely-many $n$-simplices for a given $n$, we cannot rely \non simple linear algebra to help us much. This will become important later, when we define\nthe cohomology modules of a general topological space, without using $\\Delta$-sets.\n\\end{rem}\n\nGiven a map of rings $\\alpha\\colon R\\to S$ and a set $A$, recall that there is an $R$-linear map \n$R^A\\to S^A$ given by $g\\mapsto \\alpha\\circ g$. This is $R$-linear as we can consider\nthe $S$-module $S^A$ to be an $R$-module via $\\alpha$.\nAs a result, for a $\\Delta$-set $X_\\bullet$, we can apply this to the singular cochain complex \nof $X_\\bullet$ at each slot.\n\n\\begin{lemma}\nFor a map of rings $\\alpha\\colon R\\to S$ there is a map of complexes \n$C^\\bullet(X_\\bullet,R)\\to C^\\bullet(X_\\bullet,S)$, and for fixed $X_\\bullet$ this is functorial\nin $\\alpha$.\n\\end{lemma}\n\nSince a map of complexes gives a map between cohomology modules, we get from $\\alpha$ as above\nan $R$-linear map $H^n(X_\\bullet,R) \\to H^n(X_\\bullet,S)$, the \\emph{change of coefficients} map.\n\n\\begin{example}\nConsider the inclusion $\\ZZ\\to\\RR$, which gives rise to maps \n$H^n(X_\\bullet,\\ZZ) \\to H^n(X_\\bullet,\\RR)$. Notice that the domain is an abelian group, and in particular\ncan contain torsion subgroups, whereas the codomain is a real vector space. The kernel of this\nmap is precisely the torsion subgroup $H^n(X_\\bullet,\\ZZ)_\\mathrm{tors} < H^n(X_\\bullet,\\ZZ)$, and the image is a lattice in\n$H^n(X_\\bullet,\\RR)$.\n\\end{example}\n\n\\begin{example}\nWe have the quotient maps $\\ZZ\\to \\ZZ/p$ for $p$ a prime, and so get maps\n$H^n(X_\\bullet,\\ZZ) \\to H^n(X_\\bullet,\\ZZ/p)$, where the codomain is now a $\\mathbb{F}_p$-vector\nspace. Now this map destroys any torsion coprime to $p$, so can be useful in trying to focus\non specific phenomena relating to a specific prime number.\n\\end{example}\n\n\\begin{rem}\nAt the dawn of algebraic topology, the focus was largely on objects similar to finite $\\Delta$-complexes\nand in that case, one could define the dimension of the vector spaces $H^n(X_\\bullet,\\RR)$, \ncalled the \\emph{Betti numbers} of $X_\\bullet$,\nand consider the orders of the cyclic subgroups that defined the finite group \n$H^n(X_\\bullet,\\ZZ)_\\mathrm{tors}$ (under the classification of finitely-generated abelian\ngroups), called the \\emph{torsion coefficients}. These were the way mathematicians at the time\nunpacked the information that went into the Euler characteristic, but still these numbers \nwere not functorial. It took Emmy Noether and others in the 1920s to emphasise that having \ninvariants that are themselves algebraic objects was more important than considering just \ntheir dimensions or other numeric invariants.\n\\end{rem}\n\nGoing\\lecturenum{23} back to thinking about functoriality with respect to maps of \n$\\Delta$-sets, consider for $x\\in X_n$ ($X_\\bullet$ a given $\\Delta$-set) the map in \nExample~\\ref{eg:name_of_simplex}, $\\Delta[n] \\to X_\\bullet$ We can consider the induced map\non complexes near dimension $n$:\n\\[\n\t\\xymatrix{\n\t\\ar[r] & R^{X_n} \\ar[d] \\ar[r]^\\delta & R^{X_{n+1}} \\ar[r] \\ar[d] & \\\\\n\t\\ar[r] & R^{\\Delta[n]_n} \\ar[r] & R^{\\Delta[n]_{n+1}} \\ar[r] &\n\t}\n\\]\nbut $R^{\\Delta[n]_n} = R^1 = R$ (as a module) and $R^{\\Delta[n]_{n+1}} = R^\\emptyset=0$, so we\nget an $R$-linear map $C^n(X_\\bullet,R) = R^{X_{n+1}} \\to R$. This map is precisely \nevaluation at $x\\in X_n$.\nAn important case for us is when we have a chosen\\marginnote{this \nreally is, under the indended geometric interpretation, a point} basepoint $x\\in X_0$. Then\nwe get a map $C^\\bullet(X_\\bullet,R)=R^{X_0} \\to C^\\bullet(\\Delta[0],R)$, and the codomain\nhere is a complex of the form $0\\to R \\to 0\\to \\cdots$. This map on passing to \ncohomology gives a map $H^0(X_\\bullet,R) \\to R$ of $R$-modules. Such a map on an $R$-module $M$\nis called an \\emph{augmentation} of $M$, and $M\\to R$ is called an \\emph{augmented module}.\nThe assignment $(X_\\bullet) \\mapsto (H^0(X_\\bullet,R) \\to R)$ is functorial for maps of $\\Delta$-set\nrespecting the chosen basepoints, and where augmentations are preserved on the $R$-module side.\nThe extra geometric structure contained in the choice of basepoint is reflected by the augmentation.\n\n\\begin{rem}\nWhile $\\Delta$-sets and their cohomology are not at present helping to define or calculate\ncohomology of topological spaces, the tools we are developing will come in handy when we get\nto that point. So for the present we will continue to focus on $\\Delta$-sets and their associated\ncomplexes. \n\\end{rem}\n\nWhat sort of general results help us to calculate cohomology of $\\Delta$-sets? Just as for space,\nlet us consider the simplest method for constructing a new object from old: disjoint union.\n\nSome observations:\n\\begin{enumerate}\n\\item For sets $P$\\marginnote{In fact $R^{\\sqcup P_\\alpha} \\simeq \\prod R^{P_{\\alpha}}$ for any sets $P_\\alpha$} and $Q$ and a ring $R$, there is a natural isomorphism \n$R^{P\\sqcup Q} \\xrightarrow{\\simeq} R^Q \\oplus R^Q$ of $R$-modules.\n\n\\item From $\\Delta$-sets $X_\\bullet$ and $Y_\\bullet$ we can make a new $\\Delta$-set\n$X_\\bullet\\sqcup Y_\\bullet$ with set of $n$-simplices $X_n\\sqcup Y_n$.\n\n\\item From complexes $A_\\bullet$ and $B_\\bullet$ of $R$-modules, we can make a new complex\n$A_\\bullet \\oplus B_\\bullet$, namely\n\\[\n\t\\cdots \\to A_n\\oplus B_n \\xrightarrow{\\delta^A_n\\oplus \\delta^B_n} A_{n+1}\\oplus B_{n+1} \\to \\cdots\n\\]\nthe \\emph{direct sum} of $A_\\bullet$ and $B_\\bullet$.\n\n\\item Given a direct sum of complexes $A_\\bullet\\oplus B_\\bullet$, we have an natural isomorphism\n$H^n(A_\\bullet\\oplus B_\\bullet) \\xrightarrow{\\simeq} H^n(A_\\bullet)\\oplus H^n(B_\\bullet)$.\n\\end{enumerate}\n\nIf we put these ingredients together, we get:\n\\begin{lemma}\nThere is a natural isomorphism \n\\[\n\tC^\\bullet(X_\\bullet\\sqcup Y_\\bullet,R) \\xrightarrow{\\simeq}\nC^\\bullet(X_\\bullet,R)\\oplus C^\\bullet(Y_\\bullet,R)\n\\]\nof complexes of $R$-modules.\n\\end{lemma}\n\n\\begin{corollary}\nThere is a natural isomorphism\\marginnote{this is a version of this for infinite disjoint union, where the direct sum is replaced by product, and this follows from the fact infinite products commute with taking images, quotients and kernels} \n\\[\nH^(X_\\bullet\\sqcup Y_\\bullet,R) \\xrightarrow{\\simeq} H^n(X_\\bullet,R) \\oplus H^n(Y_\\bullet,R)\n\\]\nof $R$-modules, for $n=0,1,2,\\ldots$.\n\\end{corollary}\n\nRecalling the situation for the fundamental groupoid $\\Pi_1$, we had the result that\n$\\Pi_1(X\\sqcup Y) \\simeq \\Pi_1(X)\\sqcup \\Pi_1(Y)$. So, in this case we can reduce computations\nto $\\Delta$-sets that are not disjoint unions of smaller $\\Delta$-sets. One thing to notice \nis that the lemma is legitimately stronger than its corollary, since there might be an induced\nisomorphism between the cohomology modules while the complexes are not isomorphism.\n\nThe next step up from calculating the fundamental groupoid of a disjoint union is to calculate\nthe fundamental groupoid of a pushout of spaces: $X = U\\cup V$ for neighbourhoods $U,V\\subset X$.\nMore precisely there was a way to get information about $\\Pi_1(X)$ from $\\Pi_1(U)$, $\\Pi_1(V)$ \nand $\\Pi_1(U\\cap V)$. Things are not so simple now, even ignoring the fact we are working \nwith $\\Delta$-sets. The following two examples should be in some sense motivational for the \nbig tool we are about to develop. \n\n\\begin{example}\nConsider the combinatorial surface $\\partial\\Delta[3]$, with vertices $0,1,2,3$, and \n$n$-simplices given by $(n+1)$-element subsets of this.\nDefine two sub-$\\Delta$-sets $U_\\bullet$ and $V_\\bullet$ as follows:\n\\begin{enumerate}\n\\item $U_\\bullet$ has the same vertices as $\\partial\\Delta[3]$ but only two $2$-simplices: \n$\\{0,1,2\\}$ and $\\{0,1,3\\}$, and all the $1$-simplices of $\\partial \\Delta[3]$ \\emph{except}\n$\\{2,3\\}$.\n\\item $V_\\bullet$ also has the same vertices as $\\partial\\Delta[3]$ but now the pair of $2$-simplices\n$\\{1,2,3\\}$ and $\\{0,2,3\\}$, and all the $1$-simplices \\emph{except} $\\{0,1\\}$.\n\\end{enumerate}\nThe\\marginnote{defined to have as set of $n$-simplices $U_n\\cap V_n\\subset X_n$} \nintersection $U_\\bullet\\cap V_\\bullet$ is then $1$-dimensional---that is a directed graph---with \nvertices $\\{0,1,2,3\\}$ and edges $\\{0,2\\}$, $\\{0,3\\}$, $\\{1,2\\}$ and $\\{1,3\\}$ (ordered from\nlower to higher label).\\marginnote{this geometrically realises to a circle} Now, in principle,\nwe already know, or suspect we know, the cohomology modules of $U_\\bullet$, $V_\\bullet$ and \n$U_\\bullet\\cap V_\\bullet$ as the first two triangulate $I^2$, and the latter triangulates a \ncircle. Then it would be nice if we could calculate the cohomology of $\\partial\\Delta[3]$ just\nfrom this information.\n\nFrom the functoriality of $C^\\bullet(-,R)$ we get restriction maps, which in each dimension \nlook like\n\\[\n\t\\xymatrix{\n\t\tR^{\\partial\\Delta[3]_n} \\ar[r] \\ar[d] & R^{U_n} \\ar[d]\\\\\n\t\tR^{V_n} \\ar[r] & R^{U_n\\cap V_n}\n\t}\n\\]\nand this square commutes. However, we are in a more of a linear, sequency mood, so will turn\nthis into the sequence\n\\begin{align*}\n\t0\\to R^{\\partial\\Delta[3]_n} \\to & R^{U_n}\\oplus R^{V_n} \\to R^{U_n\\cap V_n}\\to 0\\\\\n\tg\\mapsto & (g\\big|_{U_n},g\\big|_{V_n})\\\\\n\t\t& (f,h) \\mapsto f\\big|_{U_n\\cap V_n} - h\\big|_{U_n\\cap V_n}\n\\end{align*}\nIt is a short and simple exercise to check that in fact this sequence is in fact exact. This then\ngives a short exact sequence of complexes\n\\[\n0\\to C^\\bullet(\\partial\\Delta[3],R) \\to C^\\bullet(U_\\bullet,R) \\oplus C^\\bullet(V_\\bullet,R) \\to C^\\bullet(U_\\bullet\\cap V_\\bullet,R) \\to 0\n\\]\nWe want to know the cohomology of the leftmost non-zero complex, but we (in principle) have\nonly calculated the cohomology of the other two complexes.\n\\end{example}\n\nThe above argument works perfectly well for an arbitrary $\\Delta$-set $X_\\bullet$ and \nsub-$\\Delta$-sets $U_\\bullet$ and $V_\\bullet$ such that $X_n = U_n \\cup V_n$, to give a short\nexact sequence of complexes of $R$-modules\n\\[\n0\\to C^\\bullet(X_\\bullet,R) \\to C^\\bullet(U_\\bullet,R) \\oplus C^\\bullet(V_\\bullet,R) \\to C^\\bullet(U_\\bullet\\cap V_\\bullet,R) \\to 0\n\\]\n\nFor the second example, we want to consider how we might calculate the cohomology of a quotient\nfrom the cohomology of the original $\\Delta$-set and that of the sub-$\\Delta$-set that gets squashed.\n\n\\begin{example}\n\nConsider now a $\\Delta$-set $X_\\bullet$ together with a sub-$\\Delta$-set $A_\\bullet \n\\subset X_\\bullet$.\\marginnote{that is, a \\emph{pair} $(X_\\bullet,A_\\bullet)$} Morally \nspeaking, we might have $X_\\bullet$ triangulating some space, and $A_\\bullet$ \ntriangulating a subspace. We can form the quotient space $|X_\\bullet|/|A_\\bullet|$, but \nit is not immediately clear that we can form a sensible $\\Delta$-set \n$X_\\bullet/A_\\bullet$ that is a quotient of $X_\\bullet$ so that this triangulates the \ntopological quotient. Assume for now that there \\emph{is} a $\\Delta$-set \n$X_\\bullet/Y_\\bullet$ with set of $n$-simplices $X_n/Y_n$, and a quotient map \n$X_\\bullet\\to X_\\bullet/Y_\\bullet$ of $\\Delta$-sets. Can we calculate \n$H^n(X_\\bullet/Y_\\bullet,R)$ from $H^n(X_\\bullet,R)$ and $H^n(Y_\\bullet,R)$?\n\nNotice that given a set $X$ and a subset $i\\colon Y\\hookrightarrow X$, we get a set $X/Y := X/(y_1\\sim y_2)$ for all $y_i\\in Y$,\nand there is a function $q\\colon X\\to X/Y$. The set $X/Y$ has a canonical basepoint $\\pt = [y]\\in X/Y$ for any $y\\in Y$.\nWe get $R$-linear maps given by precomposition:\n\\[\n\tR^{X/Y} \\xrightarrow{q^*} R^X \\xrightarrow{i^*} R^Y \n\\]\nwhere the left map is injective, and the right map is surjective. However, this is not even a complex,\nas the image of $q^*$ is not contained in the kernel of $i^*$!\n\nExamining the situation, we see that the image of $q^*$ consists of those functions $X\\to R$\nthat are constant on $Y$, whereas the kernel of $i^*$ consists of those functions that are\n$0$ on $Y$. Moreover, recalling that $X/Y$ has a canonical basepoint, the module $R^{X/Y}$ \nhas an augmentation, namely evaluation on that basepoint: $\\ev_\\pt\\colon R^{X/Y}\\to R$. The \nkernel of this map includes into $R^X$ as precisely those functions that are in the kernel\nof $i^*$! This example may not be telling us something deep, other than to get a complex that\nplays well with quotient we may need to play around with the kernel a bit: in one sense the \n`correct' module of functions on $X/A$ is really $\\ker i^*$, so as to get an exact sequence\n\\[\n\t0\\to \\ker i^* \\to R^X \\to R^A\\to 0\n\\] \nPhrased this way, we don't even need to consider the quotient set $X/A$ in order to get a module\nfrom it. And this also helps with the issue above, in that it's not clear to what extent \n$X_\\bullet/Y_\\bullet$ is a good construction. \n\nHence,\\lecturenum{24} given a pair $(X_\\bullet,A_\\bullet)$, with inclusion function $i\\colon A_\\bullet \\hookrightarrow X_\\bullet$, we can consider the \n(surjective) restriction map\n\\[\n\tC^\\bullet(X_\\bullet,R) \\xrightarrow{i^*} C^\\bullet(A_\\bullet,R) \\to 0\n\\]\nand its kernel $\\ker(i^*)$ acts like virtual functions on $X_\\bullet/A_\\bullet$, without \nhaving to define this $\\Delta$-set. Moreover, we then have a short exact sequence of \ncomplexes of $R$-modules, analogously to the previous example.\n\\end{example}\n\nBefore continuing, it is worth noting that in fact the last construction does make sense\n\n\\begin{lemma}\nGiven a map of complexes $\\varphi\\colon A_\\bullet \\to B_\\bullet$, the degreewise kernels\n$\\ker(\\varphi_n) \\subseteq A_n$ assemble into a complex $\\ker(\\varphi)$, using the restriction\nof $A_n \\to A_{n+1}$ to $\\ker(\\varphi_n)$.\n\\end{lemma}\n\nUsing this lemma, we can define a complex associated to the pair $(X_\\bullet,A_\\bullet)$.\n\n\\begin{definition}\nGiven a pair $(X_\\bullet,A_\\bullet)$ denote by $C^\\bullet(X_\\bullet,A_\\bullet;R)$ the \ncomplex $\\ker(i^*)$ as above, the simplicial relative cochain complex of the pair.\n\\end{definition}\n\nBoth of these examples are special cases of a general principle: given a short exact sequence \nof complexes\n\\[\n\t0\\to A_\\bullet \\to B_\\bullet \\to C_\\bullet \\to 0\n\\]\n(of $R$-modules, say) then we might wish to calculate $H^n(A_\\bullet)$, but only know \n$H^n(B_\\bullet)$ and $H^n(C_\\bullet)$. Or we might know $H^n(A_\\bullet)$ and \n$H^n(C_\\bullet)$, and want to calculate $H^n(B_\\bullet)$. In the finite setting, this \nmight be merely an issue of computational efficiency, but in general we need to deal \nwith infinitely-generated $R$-modules, where simple linear algebra techniques start to \nbreak down. So we will prove a general result using \\emph{homological \nalgebra}\\marginnote{Homological algebra is the area of algebra that deals with the \ninteraction of sequences, maps of sequences, commutative diagrams of algebraic objects \nwith certain `exactness' properties, and how one can calculate various objects including \n(co)homology groups} that relates all these cohomology groups.\n\n\\begin{rem}\nIf you get anything out of this section of the course, the following result is probably \nit, because you can apply it to your own setting to get a long exact sequence. Or it \nmight be the case there is a standard long exact sequence\\marginnote{or, in the case of \n$K$-theory, a long exact sequence that folds back on itself} in your area, and it \nprobably arose from this theorem, so it's a good idea to understand how the abstract \nproof goes. Together with the long exact sequence of homotopy groups associated to a \nfibre bundle, this is one of the major computational tools until you get to spectral \nsequences, which are super powerful, but also much less intuitive.\n\\end{rem}\n\n\\begin{theorem}\\label{thm:alg_Mayer-Vietoris}\nGiven\\marginnote{I call this the \\emph{algebraic Mayer--Vietoris} theorem, but it is also known as the \\emph{zig-zag lemma}} a short exact sequence \n\\[\n        0\\to A_\\bullet \\xrightarrow{i} B_\\bullet \\xrightarrow{\\pi} C_\\bullet \\to 0\n\\]\nof complexes of $R$-modules, there is a long exact sequence\n\\[\n\\cdots \\xrightarrow{\\delta^{k-1}} H^k(A_\\bullet) \\xrightarrow{H^k(i)} H^k(B_\\bullet) \\xrightarrow{H^k(\\pi)} H^k(C_\\bullet)\n\\xrightarrow{\\delta^k} H^{k+1}(A_\\bullet) \\xrightarrow{H^{k+1}(i)} (B_\\bullet) \\to \\cdots\n\\]\nof $R$-modules.\n\\end{theorem}\n\nThe proof of this theorem we will give uses a famous lemma in homological algebra, the \\emph{Snake \nLemma}.\\marginnote{there is a small zoo of lemmas named after animals, other examples \nbeing the Salamander Lemma and the Snail Lemma}\n\n\\begin{lemma}[Snake Lemma]\n\\label{snakeLemma}\nGiven a commutative diagram \n\\[\n\t\\xymatrix{\n\t& A \\ar[r]^i \\ar[d]^\\alpha & B \\ar[r]^\\pi \\ar[d]^\\beta & C \\ar[r] \\ar[d]^\\gamma & 0 \\\\\n\t0\\ar[r] & A' \\ar[r]_{i'} & B' \\ar[r]_{\\pi'} & C\n\t}\n\\]\nof $R$-modules where the rows are exact, there is an exact sequence\n\\[\n\t\\ker\\alpha \\to \\ker\\beta \\to \\ker\\gamma \\xrightarrow{\\delta} \\coker\\alpha \n\t\\to \\coker\\beta \\to \\coker\\gamma\n\\]\nof $R$-modules (see Figure~\\ref{fig:snake_lemma}).\n\\end{lemma}\n\nThis is a major tool, so the full proof is rather lengthy with lots of details, but at each stage there is generally\nonly one or two things to try.\n\n\\begin{figure}\n\\begin{tikzpicture}%[>=triangle 60]\n\\matrix[matrix of math nodes,column sep={60pt,between origins},row\nsep={60pt,between origins},nodes={asymmetrical rectangle}] (s)\n{\n&|[name=ka]| \\ker \\alpha &|[name=kb]| \\ker \\beta &|[name=kc]| \\ker \\gamma \\\\\n%\n&|[name=A]| A &|[name=B]| B &|[name=C]| C &|[name=01]| 0 \\\\\n%\n|[name=02]| 0 &|[name=A']| A' &|[name=B']| B' &|[name=C']| C' \\\\\n%\n&|[name=ca]| \\coker \\alpha &|[name=cb]| \\coker \\beta &|[name=cc]| \\coker \\gamma \\\\\n};\n\\draw[->] (ka) edge (A)\n          (kb) edge (B)\n          (kc) edge (C)\n          (A) edge node[auto] {\\(i\\)} (B)\n          (B) edge node[auto] {\\(\\pi\\)} (C)\n          (C) edge (01)\n          (A) edge node[auto] {\\(\\alpha\\)} (A')\n          (B) edge node[auto] {\\(\\beta\\)} (B')\n          (C) edge node[auto] {\\(\\gamma\\)} (C')\n          (02) edge (A')\n          (A') edge node[auto] {\\(i'\\)} (B')\n          (B') edge node[auto] {\\(\\pi'\\)} (C')\n          (A') edge (ca)\n          (B') edge (cb)\n          (C') edge (cc)\n;\n\\draw[->,gray] (ka) edge (kb)\n               (kb) edge (kc)\n               (ca) edge (cb)\n               (cb) edge (cc)\n;\n\\draw[->,red,rounded corners] (kc) -| node[auto,text=black,pos=.7]\n{\\(\\delta\\)} ($(01.east)+(.5,0)$) |- ($(B)!.35!(B')$) -|\n($(02.west)+(-.5,0)$) |- (ca);\n\\end{tikzpicture}\n\\caption{The classic Snake Lemma diagram}\n  \\label{fig:snake_lemma}\n  %\\zsavepos{pos:textfig}\n  \\setfloatalignment{c}\n\\end{figure}\n\n\n\\begin{proof}\nWe need to do a number of things:\n\\begin{enumerate}\n\\item Construct the function $\\delta \\colon \\ker\\gamma \\to \\coker\\alpha$\n\\item Prove this is an $R$-module homomorphism\n\\item Show $\\im(\\ker\\alpha \\to \\ker\\beta) = \\ker(\\ker\\beta \\to \\ker\\gamma)$\n\\item Show $\\im(\\ker\\beta \\to \\ker\\gamma) = \\ker(\\delta)$\n\\item Show $\\im(\\delta) = \\ker(\\coker\\alpha \\to \\coker\\beta)$\n\\item Show $\\im(\\coker\\alpha \\to \\coker\\beta) = \\ker(\\coker\\beta \\to \\coker\\gamma)$\n\\end{enumerate}\n\nFor the present, I will do 1., 4.\\ and 5. Items 3.\\ and 6.\\ are a bit more \nstraightforward, as they don't involve $\\delta$. And, given the techniques here, item \n2.\\ should be a not-too-challenging exercise. The main technique here is called `diagram \nchasing', as it involves starting with an element in one module, and applying \nhomomorphisms or exactness properties to cook up elements of other nearby modules, and \nrepeat, chasing the new elements until we find one in a module we are interested in. \n\nSince we want a function $\\delta\\colon \\ker\\gamma \\to \\coker\\alpha$, we will start with \na given element $c\\in \\ker\\gamma \\subseteq C$ and aim to end up with an element in \n$\\coker\\alpha$ Since we know $\\pi$ is surjective, there is a $b\\in B$ such that $\\pi(b) \n= c$. Then consider $\\beta(b) \\in B'$: applying $\\pi'$ we get $\\pi'(\\beta(b)) = \n\\gamma(\\pi(b)) = \\gamma(c)=0$, so that $\\beta(b) = i'(a'_b)$ for a unique $a'_b \\in A'$. \nThen we have $[a'_b] \\in \\coker\\alpha$. But is it unique? I hear you ask. Well, what \nchoices did we make along the way? Only the fact that there is not a unique $b$ such \nthat $\\pi(b)=c$. So consider another $\\tilde b \\in B$ such that $\\pi(\\tilde b) = c$. We \nget $\\beta(\\tilde b)$, as before, and there is a unique $a'_{\\tilde b} \\in A'$ such that \n$i'(a'_{\\tilde b}) = \\beta(\\tilde b)$. So we get another element $[a'_{\\tilde b}]\\in \n\\coker\\alpha$. But, $\\pi(b - \\tilde b)= \\pi(b) - \\pi(\\tilde b) = c -c = 0$, and \n$\\ker\\pi=\\im i$, so there is some $\\underline{a}\\in A$ such that $i(\\underline{a}) = b - \n\\tilde b$, or rather, $b = \\tilde b + i(\\underline{a})$. So now apply $\\beta$ to get \n$i'(a_b) = \\beta(b) = \\beta(\\tilde b + i(\\underline{a})) = \\beta(\\tilde b) + \n\\beta(i(\\underline{a})) = i'(a'_{\\tilde b}) + i'(\\alpha(\\underline{a})) = i'(a'_{\\tilde b} \n+ \\alpha(\\underline{a}))$. But $i'$ is injective, so that $a_b = a'_{\\tilde b} + \n\\alpha(\\underline{a})$. But this means that $[a'_b] = [a'_{\\tilde b}]$, and so from $c\\in \n\\ker\\gamma$ we have found a unique element of $\\coker\\alpha$. Thus we have a function\n$\\delta\\colon \\ker\\gamma \\to \\coker\\alpha$, as required.\n\n\n\nOne needs to then check this is an $R$-module homomorphism, by comparing \n$\\delta(c_1+c_2)$ and $\\delta(c_1) + \\delta(c_2)$ etc, using exactness in various ways as in \nthe previous paragraph. This is an exercise for the keen reader.\n\nWe can now check the exactness of the sequence. Assume $c\\in \\ker \\gamma$ such that \n$\\delta(c)=0$, that is, $[a'_b] = 0 \\in \\coker\\alpha$ for some $b\\in B$ such that \n$\\pi(b)=c$. But this means $a'_b = \\alpha(\\underline{a})$. But since $\\beta(b) = \ni'(a'_b) = i'(\\alpha(\\underline{a})) = \\beta(i(\\underline{a}))$, we get $b - \ni(\\underline{a}) \\in \\ker\\beta$. And $\\pi(b - i(\\underline{a})) = \\pi(b) - \n\\pi(i(\\underline{a})) = c$. Thus $c\\in \\im(\\ker \\beta \\to \\ker \\gamma)$ and $\\ker\\delta \n\\subseteq \\im(\\ker \\beta \\to \\ker \\gamma)$\n\nConversely, assume that $c = \\pi(b)$ where $b\\in \\ker\\beta$. Then $\\delta(c) = [a'_b]$ \nfor $i'(a'_b) = \\beta(b)$, but as $i'$ is injective, $a'_b = 0$, hence $\\delta(c)=0$. \nThus $\\im(\\ker \\beta \\to \\ker \\gamma)\\subseteq \\ker\\delta$, and so $\\im(\\ker \\beta \\to \n\\ker \\gamma)= \\ker\\delta$.\n\nNow consider an arbitrary $c\\in \\ker\\gamma$, and the image of $\\delta(c)$ in \n$\\coker\\beta$. This is precisely $[i'(a'_b)] = [\\beta(b)] = 0$, so that $\\im\\delta \n\\subseteq \\ker(\\coker\\alpha \\to \\coker\\beta)$. Now consider a $[a']\\in \\coker\\alpha$ \nsuch that $[i'(a')]=0 \\in \\coker\\beta$. But then this means that $i'(a') = \\beta(b)$ for \nsome $b\\in B$. If we take $c:= \\pi(b)$, then $\\delta(c) = [a']$, so that $\\im\\delta\n=\\ker(\\coker\\alpha \\to \\coker\\beta)$.\n\nThe proof that we have exactness in the other positions is left for the keen reader.\n\\end{proof}\n\nTo apply the Snake Lemma to the proof of Theorem~\\ref{thm:alg_Mayer-Vietoris}, we need \nto cook up a diagram with the appropriate properties. Despite the temptation to apply \nthe Snake Lemma to (two rows of) the short exact sequence of complexes, this is not the \ncorrect thing to do, since then the kernels and cokernels are not the cohomology groups \nin the Theorem.\n\n\\begin{lemma}\\label{lemma:setup_for_algMV}\nThe commutative diagram\n\\[\n\t\\xymatrix{\n\t&A_k/\\delta_{k-1}^A(A_{k-1}) \\ar[r] \\ar[d]^{\\delta_k^A} & B_k/\\delta_{k-1}(B_{k-1}) \n\t\\ar[r] \\ar[d]^{\\delta_k^B} & C_k/\\delta_{k-1}^C(C_{k-1}) \\ar[r] \\ar[d]^{\\delta_k^C} & 0\\\\\n\t0\\ar[r] & \\ker(\\delta_{k+1}^A) \\ar[r]& \\ker(\\delta_{k+1}^B) \\ar[r] & \\ker(\\delta_{k+1}^C)\t\n\t}\n\\]\nsatisfies the hypotheses of the Snake Lemma, that is, the rows are exact.\n\\end{lemma}\n\n\\begin{proof}\nExercise, for now.\n\\end{proof}\n\n\\begin{proof}{(of Theorem~\\ref{thm:alg_Mayer-Vietoris})}\n\nFirst notice that $\\ker(A_k/\\delta_{k-1}^A(A_{k-1}) \\to \\ker\\delta_{k+1}^A) = \n\\ker(A_k/\\delta_{k-1}^A(A_{k-1}) \\to A_{k+1})$. But this is isomorphic to $\\ker(A_k\\to \nA_{k+1})/\\delta_{k-1}^A(A_{k-1}) = H^k(A_\\bullet)$.\\marginnote{exercise!}\nSimilarly, we have $\\im(A_k/\\delta_{k-1}^A(A_{k-1}) \\to \\ker\\delta_{k+1}^A) = \\im(A_k \\to \\ker\\delta_{k+1}^A$ and hence the cokernel is $H^{k+1}(A_\\bullet)$.\n\nUsing Lemma~\\ref{lemma:setup_for_algMV}, we get an exact sequence\n\\[\n\tH^k(A_\\bullet) \\to H^k(B_\\bullet) \\to H^k(C_\\bullet) \\xrightarrow{\\delta^k}\n\tH^{k+1}(A_\\bullet) \\to H^{k+1}(B_\\bullet) \\to H^{k+1}(C_\\bullet)\n\\]\nfor each $k$. We\\marginnote{For a collection of exact sequences $L_{k-1} \\to M_{k-1} \\to \nN_{k-1} \\to L_k \\to M_k \\to N_k$, $k\\in \\ZZ$ (where the maps are re-used) \n there is a long exact sequence \n$\\cdots \\to N_{k-2} \\to L_{k-1} \\to M_{k-1} \\to\nN_{k-1} \\to L_k \\to M_k \\to N_k \\to L_{k+1} \\to \\cdots$ (Exercise)}\ncan put these together as $k$ varies to get one long exact sequence as in \nthe statement of the theorem.\n\\end{proof}\n\nOne nice result is that given two diagrams of the sort that go into the Snake Lemma, and \nmaps between each of the corresponding modules making all the possible cubes commute, \nthere are maps between the kernels and cokernels that appear in the exact sequence, \ngiving a map between the complexes.\\marginnote{the Snake Lemma is thus `natural'} This \nmeans that given two short exact sequences of complexes, and maps between \\emph{them}, \nthere is a map between the long exact sequences. This might happen, for instance, if one \nis changing the coefficient ring in the cohomology of $\\Delta$-sets, and one is in the \nsituation of one of the two motivational examples. Or, one might have a map of pairs \n$(X_\\bullet,A_\\bullet) \\to (Y_\\bullet,B_\\bullet)$ of $\\Delta$-sets, so that each of them \ngives rise to a short exact sequence of complexes, and the map between the pairs induces a \nmap between the short exact sequences.\n\n\nThe\\lecturenum{25} cohomology of the complex of relative simplicial cochains turns out to\nbe quite important, and also gives more flexibility in the definition of cohomology of a $\\Delta$-set.\nWe recover the complex $C^\\bullet(X_\\bullet,R)$ by taking $A_\\bullet=\\emptyset$, hence\nthe complex $C^\\bullet(X_\\bullet,\\emptyset;R)$.\n\n\\begin{definition}\nGiven a pair $(X_\\bullet,A_\\bullet)$ of $\\Delta$-sets, its \\emph{relative cohomology} is\n$H^k(X_\\bullet,A_\\bullet;R) := H^k(C^\\bullet(X_\\bullet,A_\\bullet;R))$.\n\\end{definition}\n\n\\begin{example}\\label{eg:dim_minus_one_skeleton_rel_cochains}\nGiven $X_\\bullet$ a finite-dimensional $\\Delta$-set of dimension $n$, then \n$(X_\\bullet,\\sk_{n-1}X_\\bullet)$ is a pair, and so we get the relative cochain complex\n\\[\n\t0\\to C^1(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\to \\cdots \\to C^{n-1}(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\to C^n(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\to 0\n\\]\nbut for $k < n$, $\\sk_{n-1}X_k = X_k$, so that $C^k(X_\\bullet,\\sk_{n-1}X_\\bullet) = \\ker(\\id_{R^{X_k}}) = 0$\nMoreover, $\\sk_{n-1}X_n = \\emptyset$, so that $C^n(X_\\bullet,\\sk_{n-1}X_\\bullet;R) = \\ker(R^{X_n} \\to R^\\emptyset=0) = R^{X_n}$. Hence the complex $C^\\bullet(X_\\bullet,\\sk_{n-1}X_\\bullet;R)$ \nconsists entirely of copies of the zero $R$-module, except at position $n$,\\marginnote{This is often denoted $R^{X_n}[n]$ in homological algebra} where it is the module of \n$R$-valued functions on $X_n$. Thus \n\\[\n\tH^k(X_\\bullet,\\sk_{n-1}X_\\bullet;R) = \\begin{cases}\n\t\t\t\t\t\t0 & k\\neq n\\\\\n\t\t\t\t\t\tR^{X_n} & k=n\n\t\t\t\t\t\t\\end{cases}\n\\]\n\\end{example}\n\nThe proof of the following lemma follows immediately from the definitions.\n\n\\begin{lemma}\nFor $k < n$, $H^k(\\sk_nX_\\bullet,R) \\simeq H^k(X_\\bullet,R)$.\n\\end{lemma}\n\nAs a result, every cohomology module of a given $\\Delta$-set can be calculated as a cohomology \nmodule of a finite-dimensional $\\Delta$-set, albeit the dimension of the $\\Delta$ grows with the \ndimension the cohomology module sits in.\\marginnote{A more sophisticated result shows the cohomology modules can be approximated, in a precise way, by cohomology modules of \\emph{finite} $\\Delta$-sets. This will take us too far afield to cover now.}\n\n\\begin{prop}\nGiven a pair $(X_\\bullet,A_\\bullet)$ of $\\Delta$-sets, there is a long exact sequence of $R$-modules\n\\[\n\\xymatrix{%adapted from https://tex.stackexchange.com/a/16516/141\n    0 \\ar[r] & H^0(X_\\bullet,A_\\bullet;R) \\ar[r] & H^0(X_\\bullet,R) \\ar[r] & H^0(A_\\bullet,R) \\ar@{->} `r/8pt[d] `/10pt[l] `^dl[ll] `^r/1pt[dll] [dll] \\\\\n             & H^1(X_\\bullet,A_\\bullet;R) \\ar[r] & H^1(X_\\bullet,R)\\ar[r] &\\cdots \\\\\n                &&\\cdots \\ar[r] & H^{k-1}(A_\\bullet,R)\n                \\ar@{->} `r/8pt[d] `/10pt[l] `^dl[ll] `^r/1pt[dll] [dll] \\\\\n             & H^k(X_\\bullet,A_\\bullet;R) \\ar[r] & H^k(X_\\bullet,R) \\ar[r] & \\cdots \n}\n\\]\n\\end{prop}\n\n\n\\begin{example}\nConsider for instance the pair $(\\Delta[n],\\partial\\Delta[n])$\\marginnote{A special case of \nExample~\\ref{eg:dim_minus_one_skeleton_rel_cochains}, as $\\partial\\Delta[n] = \n\\sk_{n-1}\\Delta[n]$} We have $H^k(\\Delta[n],\\partial\\Delta[n];R) = 0$ for $k\\neq n$, and since \n$\\Delta[n]$ has a single $n$-simplex, $H^n(\\Delta[n],\\partial\\Delta[n];R)=R$. The long exact \nsequence breaks up into small pieces, namely\n\\[\n\t0\\to H^k(\\Delta[n],R) \\xrightarrow{\\simeq} H^k(\\partial\\Delta[n],R) \\to 0\n\\]\nfor $k<n-1$, which we already knew on general grounds from the above example, and\n\\[\n0\\to H^{n-1}(\\Delta[n],R) \\to H^{n-1}(\\partial\\Delta[n],R) \\to R \\to \nH^n(\\Delta[n],R) \\to 0\n\\]\nFrom this we can see that the cohomology module $H^n(\\Delta[n],R)$ is a quotient of the rank-one module $R$, so it is not so big.\\marginnote{in fact it is trivial, but we haven't proved that yet!}\n\\end{example}\n\nIf we think of relative cohomology as a kind of cohomology of a `virtual quotient' by a sub-$\\Delta$-set,\nthen if take the pair to be $(X_\\bullet,\\{x\\})$, where $x\\in X_0$, then we really can take the quotient squashing $\\{x\\}$ to a point: it changes nothing!\nBut the relative cohomology really is different from the ordinary cohomology, so the naive idea that it\nlooks like a kind of quotient really needs a bit more subtle interpretation.\n\n\\begin{example}\nConsider a really simple $\\Delta$-set, namely $\\partial\\Delta[1]$, which has two $0$-simplices, and\nnothing else. Call these $x_0$ and $x_1$, and look at the relative cochain complex. The only non-zero\nmodule is\n\\[\nC^0(\\partial\\Delta[1],\\{x_0\\};R) = \\ker(R^{\\{x_0,x_1\\}} = R^2\\xrightarrow{\\pr_2} R^{\\{x_0\\}} = R) = R\n\\]\nand so $H^0(\\partial\\Delta[1],\\{x_0\\};R) = R$ (and all other $H^k$ are $0$). Compare this to \n$H^0(\\partial\\Delta[1],R) = R^2$.\n\\end{example}\n\nMore generally, given a $0$-dimensional $\\Delta$-set with $n+1$ $0$-simplices and a chosen \nbasepoint, the relative cohomology will be a rank $n$ free $R$-module. So this counts the number \nof points \\emph{apart from the specified basepoint}. \n\nThis case comes up often enough that it warrants a special name. We call a $\\Delta$-set with a specified\n$0$-simplex a \\emph{pointed $\\Delta$-set}.\n\n\\begin{definition}\nGiven a pointed $\\Delta$-set $(X_\\bullet,x)$, the \\emph{reduced cohomology} is the \nrelative cohomology $H^k(X_\\bullet,x;R)$.\n\\end{definition}\n\n\\begin{example}\nDefine the $\\Delta$-set $Pt_\\bullet$ to be $Pt_n = \\ast$\\marginnote{this is infinite-dimensional, with one $n$-simplex for every $n\\in \\NN$} \nfor all $n\\geq 0$, with all face maps the identity function. Thus $C^n(Pt_\\bullet,R) = R$ for all $n$.\nWe need to calculate the maps $\\delta_n \\colon R\\to R$ that appear in the complex. Firstly, we think\nof the elements of $R$ as given by functions $\\ast \\to R$ (of sets), so precomposition with $d_i=\\id_\\ast$ becomes the identity function on $R$. Thus\n\\[\ng \\stackrel{\\delta_n}{\\mapsto} \\sum_{i=0}^{n+1} (-1)^i g = \\begin{cases}\n0 & n\\text{ even}\\\\\ng & n\\text{ odd}\n\\end{cases}\n\\]\nThus the complex is\n\\[\n\t0\\to R \\xrightarrow{0} R \\xrightarrow{\\id}R \\xrightarrow{0} R \\xrightarrow{\\id}R \\to \\cdots\n\\]\nand so $H^0(Pt_\\bullet,R) = R$, but $H^k(Pt_\\bullet,R) = 0$ for all $k>0$. But $Pt_\\bullet$ has a canonical basepoint, and $H^k(Pt_\\bullet,\\ast;R) = 0$ for all $k$.\n\\end{example}\n\nYou can think of $Pt_\\bullet$ in the last example as a kind of infinite-dimensional fat point, or perhaps\na kind of contractible `space', even though we haven't got a notion of continuous deformation of\n$\\Delta$-sets. This is more of a combinatorial analogue, or, better, and algebraic one, since $\\Delta$-sets\nare really just a way to construct examples of complexes, which are our simpler, algebraic,  versions of spaces.\nWe can define an analogue of a map of complexes being weak homotopy equivalence as follows.\n\n\\begin{definition}\nA map of complexes $f\\colon A_\\bullet\\to B_\\bullet$ is called a \\emph{quasi-isomorphism} if\n$H^k(f)\\colon H^k(A_\\bullet) \\to H^k(B_\\bullet)$ is an isomorphism for all $k$.\n\\end{definition}\n\n\\begin{example}\nThe map $C^\\bullet(Pt_\\bullet,R)\\to C^\\bullet(\\sk_0Pt_\\bullet,R)$ induced by the inclusion is a quasi-isomorphism, despite the domain being nontrivial in all non-negative positions, and the latter\nbeing concentrated in a single position.\n\\end{example}\n\nWe will need just one more homological algebra lemma\\marginnote{not named after an animal this time!} that\nis very useful in practice.\n\n\\begin{lemma}[5 Lemma]\nGiven a diagram of $R$-modules\n\\[\n\t\\xymatrix{\n\tA\\ar[r]^f \\ar[d]^\\alpha & B \\ar[r]^g \\ar[d]^\\beta & C \\ar[r]^h \\ar[d]^\\gamma & D \\ar[r]^k \\ar[d]^\\delta & E \\ar[d]^\\varepsilon \\\\\n\tA' \\ar[r]_{f'} & B' \\ar[r]_{g'} & C' \\ar[r]_{h'} & D' \\ar[r]_{k'} & E'\n\t}\n\\]\nwhere the rows are exact, then if $\\alpha$ is surjective, $\\beta$ and $\\delta$ are isomorphisms, and $\\varepsilon$ is injective, then $\\gamma$ is an isomorphism.\n\\end{lemma}\n\n\\begin{proof}\nThe proof is, as usual, a diagram chase. We split the proof into two steps, each of which only uses half\nof the assumptions:\n\\begin{enumerate}\n\n\\item If $\\varepsilon$ is injective, and $\\beta$ and $\\delta$ are surjective, then $\\gamma$ is \nsurjective. Consider $c' \\in C'$, and choose some $d\\in D$ such that $\\delta(d) = h'(c')$. \nConsider $\\varepsilon(k(d)) = k'(\\delta(d)) = k'(h'(c')) = 0$. Since $\\varepsilon$ is injective, \nthis means $k(d)=0$, and since the top row is exact, this means that $d\\in \\ker(k) = \\im(h)$, so \nthat there exists $c\\in C$ such that $d=h(c)$. It's not immediately true that $\\gamma(c) = c'$, \nso let us compare them: $h'(c'-\\gamma(c)) = h'(c') - h'(\\gamma(c)) = \\delta(d) - \\delta(h(c)) = \n0$. By exactness of the bottom row, this means that $c' - \\gamma(c) = g'(b')$ for some $b'\\in \nB$. But as $\\beta$ is surjective, $b' = \\beta(b)$ for some $b\\in B$. That is, $c' - \\gamma(c) = \ng'(\\beta(b)) = \\gamma(g(b))$. We can rearrange this so that $c' = \\gamma(c) + \\gamma(g(b)) = \\gamma(c+g(b))$, and hence $\\gamma$ is surjective.\n\n\\item If $\\alpha$ is surjective, and $\\beta$ and $\\delta$ are injective, then $\\gamma$ is injective. This is an exercise in dualising the above steps.\\qedhere\n\\end{enumerate}\n\\end{proof}\n\nNow to revisit the idea of Euler characteristic of a finite $\\Delta$-set, which is, recall, the\nsum\\marginnote{the sum terminates, as $|X_d| = 0$ for all large enough $d$}\n\\[\n\t\\chi(X_\\bullet) = \\sum_{d=0}^\\infty (-1)^d |X_d|\n\\]\nA key idea introduced at the beginning of this section was that we wanted to replace numerical invariants,\nsuch as cardinality of finite sets by vector spaces, or more generally modules, so that dimension replaced\ncardinality. We now have a different way to construct a numerical invariant from a $\\Delta$-set, namely\nusing the dimensions of the cohomology modules, in the case when we take $R = \\RR$, say.\\marginnote{any characteristic zero field would do}\nThus we can define the \\emph{cohomological Euler characteristic} to be\n\\[\n\t\\chi^{coh}(X_\\bullet) := \\sum_{d=0}^\\infty (-1)^d \\dim H^d(X_\\bullet,\\RR)\n\\]\nas long as this sum exists. While now this implies that $H^d(X_\\bullet,\\RR)=0$ for all large enough $d$,\nwe certainly don't need to have $X_\\bullet$ finite, or even finite-dimensional, as the example of $Pt_\\bullet$ shows. In that case, $\\chi^{coh}(X_\\bullet) = 1$.\nWe can also consider finite-dimensional but infinite $\\Delta$-sets, for instance a triangulation of $\\RR$ by $1$-simplices.\n\n\\begin{example}\nLet $L_\\bullet$ be the directed graph with $L_0 = \\ZZ$ and $L_1 = \\ZZ$, where $d_0(n) = n+1$ and $d_1(n) = n$.\nThis has an edge from $n$ to $n+1$ for each $n$. Given $g\\in \\RR^{L_0} = \\RR^\\ZZ$, \n$\\delta_0(g)(n) = g(n+1) - g(n)$. So $\\delta(g) = 0$ precisely if $g$ is constant, hence $\\ker(\\delta_0) = H^0(L_\\bullet,\\RR) = \\RR$.\n\nAnd, given $h\\in \\RR^{L_1} = \\RR^\\ZZ$, define $g(0) = 0$, and then use $g(n+1) = h(n) + g(n)$ to\ndefine $g\\colon \\ZZ\\to \\RR$ for all nonzero $n\\in\\ZZ$, so that $\\delta_0(g) = h$. Thus $\\coker(\\delta_0) = H^1(L_\\bullet,\\RR) = 0$. All other real-coefficient cohomology vector spaces are trivial,\nso that $\\chi^{coh}(L_\\bullet) = 1$.\n\\end{example}\n\nHowever, now we have two numerical invariants of a finite $\\Delta$-set, namely $\\chi$ and $\\chi^{coh}$,\nand it is not immediately obvious how they relate. Thankfully, they coincide, and so we can just call\nthis the Euler characteristic\n\n\\begin{prop}\nFor a finite $\\Delta$-set $X_\\bullet$, we have $\\chi(X_\\bullet) = \\chi^{coh}(X_\\bullet)$\n\\end{prop}\n\n\\begin{proof}\nFirst, $|X_d| = \\dim \\RR^{X_d}$, and consider the part of the complex near there:\n\\[\n\t\\RR^{X_{d-1}} \\xrightarrow{\\delta_{d-1}} \\RR^{X_d} \\xrightarrow{\\delta_d} \\RR^{X_{d+1}}\n\\] \nWe can, using the standard inner product,  break $\\RR^{X_d}$ into a direct sum:\n\\begin{align*}\n\\RR^{X_d}& = \\ker\\delta_d\\oplus \\im \\delta_d\\\\\n\t & = \\begin{cases}\n\t\tH^d(X_\\bullet,\\RR) \\oplus \\im\\delta_{d-1} \\oplus \\im\\delta_d & d > 0\\\\\n\t\tH^0(X_\\bullet,\\RR) \\oplus \\im \\delta_0 & d=0\n\t    \\end{cases}\n\\end{align*}\nWe can unify these two cases if we agree that $H^{-1}(X_\\bullet,\\RR) = 0$. Then we have\n\\[\n\t\\dim \\RR^{X_d} = \\dim H^d(X_\\bullet,\\RR) + \\dim \\im\\delta_{d-1} + \\dim\\delta_d\n\\]\nand so\n\\begin{align*}\n\\chi(X_\\bullet) & = \\sum_{d=0}^\\infty (-1)^d |X_\\bullet|\\\\\n\t\t& = \\sum_{d=0}^\\infty (-1)^d \\dim \\RR^{X_d}\\\\\n\t\t& = \\sum_{d=0}^\\infty (-1)^d \\dim H^d(X_\\bullet,\\RR) + \n\t\t\t\\sum_{d=0}^\\infty (-1)^d\\left(\\dim\\im\\delta_{d-1} + \\dim\\im\\delta_d \\right)\\\\\n\t\t& = \\sum_{d=0}^\\infty (-1)^d \\dim H^d(X_\\bullet,\\RR) \\\\\n\t\t& = \\chi^{coh}(X_\\bullet)\n\\end{align*}\n\\end{proof}\n\nWe thus can drop the superscript on $\\chi^{coh}$ and just talk about \\textbf{the} Euler characteristic\nof a $\\Delta$-set.\n\n\\begin{rem}\nThis proof can be adapted pretty much verbatim to show that for a complex $V_\\bullet$ of finite-dimensional \nvector spaces of finite length, say\n\\[\n\t0 \\to V_m \\to V_{m+1} \\to \\cdots \\to V_{m+N} \\to 0\n\\]\nthen\n\\[\n\t\\sum_{d=m}^{m+N} (-1) \\dim V_d = \\sum_{d=m}^{m+N} (-1)^d H^d(V_\\bullet).\n\\]\n\\end{rem}\n\nRecall\\lecturenum{26} the geometric realisation of a $\\Delta$-set $X_\\bullet$:\n\\[\n\t|X_\\bullet| = \\left(\\bigsqcup_{n=0}^\\infty \\disc(X_n) \\times \\Delta^n\\right)_{\\big/\\sim}\n\\]\nThis space has a set of distinguished maps $\\Delta^n \\to |X_\\bullet|$, namely for a given $x\\in X_n$, \nwe have the composite\n\\[\n\t\\Delta^n \\to \\disc(X_n) \\times \\Delta^n \\into \\bigsqcup_{n=0}^\\infty \\disc(X_n) \\times \\Delta^n \\to |X_\\bullet|\n\\]\nNote also that precomposing this map with $\\partial_i\\colon \\Delta^{n-1} \\into \\Delta^n$ gives another\nmap in the distinguised class, corresponding to $d_i(x) \\in X_{n-1}$.\n\nNote also that if we have a smooth manifold $M$ (for instance an open set of $\\RR^n$) and $\\omega$ is\na differential $k$-form on $M$, then this determines a function\\marginnote{by a smooth function on $\\Delta^k$\nhere it is enough to assume it is smooth on the interior and extends continuously to the boundary}\n\\begin{align*}\nC^\\infty(\\Delta^k,M) &\\to \\RR\\\\\n(f\\colon \\Delta^k\\to M) & \\mapsto \\int_{\\Delta^k} f^*\\omega\n\\end{align*}\nThus this gives a function from $k$-forms on $M$ to the vector space $\\RR^{C^\\infty(\\Delta^k,M)}$. \nThis function also interacts well with the exterior derivative and, by Stokes' theorem, the restriction\nof the primitive of an exact form to the boundary.\n\nFor a general topological space $X$, we are somewhere in the neighbourhood of these two ideas: since we do \nnot have distinguished maps $\\Delta^n \\to X$, we should consider \\emph{all} maps and then functions on\nthe set of these.\n\n\\begin{definition}\nLet $X$ be a topological space. The \\emph{singular cochain complex} of $X$ with coefficients in the \nring $R$, denoted $C^\\bullet(X,R)$  is given by\n\\[\n\t0 \\to R^{\\Top(\\Delta^0,X)} \\xrightarrow{\\delta} R^{\\Top(\\Delta^1,X)} \\xrightarrow{\\delta} R^{\\Top(\\Delta^2,X)}\\to \\cdots\n\\]\nwhere given $g\\colon \\Top(\\Delta^n,X) \\to R$ and $f\\colon \\Delta^{n+1} \\to X$, $\\delta(g)(f) = \\sum_{i=0}^{n+1} (-1)^i g( f\\circ \\partial_i)$. This defines a functor $\\Top^{op} \\to \\Cplx_R$.\nGiven a map $f\\colon X\\to Y$, where the induced map $R^{\\Top(\\Delta^k,Y)} \\to R^{\\Top(\\Delta^k,X)}$ is given by precomposing with the induced $\\Top(\\Delta^k,X) \\to \\Top(\\Delta^kY)$.\n\nThe \\emph{singular cohomology} of $X$ with coefficients in $R$ is the cohomology of this complex:\n\\[\n\tH^n(X,R) := H^n(C^\\bullet(X,R))\n\\]\nand hence gives functors $H^n(-,R) \\colon \\Top^{op} \\to \\Mod_R$.\n\\end{definition}\n\nThese modules are \\emph{huge} (in general). For example, take $X=I$ and $R=\\ZZ/2$, and then \n$|C^1(I,\\ZZ/2)| = 2^{|\\Top(\\Delta^1,I)|} = 2^{|\\RR|}$, but, as we shall see in a moment, $H^1(I,\\ZZ/2)=0$. \nHence we \\emph{must} rely on theorems to calculate the singular cohomology, unlike the much easier case\nof cohomology of $\\Delta$-sets.\n\nHowever, here is the (more of less) only example we can calculate from the definition\n\\begin{example}\nLet $X=\\pt$. Then $\\Top(\\Delta^k,\\pt) = \\ast$, so that the singular cochain complex \nis\\marginnote{we've seen this before!}\n\\[\n0 \\to R \\xrightarrow{0} R \\xrightarrow{\\id} R \\xrightarrow{0} R\\xrightarrow{\\id} \\cdots\n\\]\nwhich has cohomology $H^0(\\pt,R) = R$ and $H^k(\\pt,R) = 0$ for $k>0$.\n\\end{example}\n\nJust as for $\\Delta$-sets, we have relative cohomology, which is useful for the additional flexibility\nit affords.\n\n\\begin{definition}\nFor $(X,A)$ a pair of spaces, the \\emph{relative singular cochain complex} $C^\\bullet(X,A;R)$ is the kernel of $i^*\\colon C^\\bullet(X,R) \\to C^\\bullet(A,R)$\nwhere $i\\colon A\\into X$ is the inclusion. This gives a functor $\\Top^{(2),op}\\to \\Cplx_R$. We then define the \\emph{relative singular cohomology}\n$H^k(X,A;R) = H^k(C^\\bullet(X,A;R))$, which is functorial for maps of pairs of spaces.\n\\end{definition}\n\nNote that we recover ordinary singular cohomology of $X$ as the relative cohomology of the pair \n$(X,\\emptyset)$. Using the same argument as for relative cohomology of $\\Delta$-sets, we get\n\n\\begin{prop}\\label{prop:les_of_pair_of_spaces}\nGiven a pair $(X,A)$ of spaces, there is a long exact sequence\n\\[\n0\\to H^0(X,A;R) \\to H^0(X,R) \\to H^0(A,R) \\to H^1(X,A;R) \\to H^1(X,R) \\to \\cdots\n\\]\nof $R$-modules.\n\\end{prop}\n\n\\begin{proof}\nThere is a short exact sequence of complexes\n\\[\n\t0\\to C^\\bullet(X,A;R) \\to C^\\bullet(X,R)\\to C^\\bullet(A,R) \\to 0\n\\]\nand then apply Theorem~\\ref{thm:alg_Mayer-Vietoris}.\n\\end{proof}\n\nLet $(X,x)$ be a pointed space, and consider the long exact sequence of the relative cohomology of\n the pair $(X,\\pt) = (X,\\{x\\})$. Since $H^k(\\pt,R) = 0$ for positive $k$, the long exact sequence breaks up into\n\\[\n0\\to H^0(X,\\pt;R) \\to H^0(X,R) \\to H^0(\\pt,R) = R \\to H^1(X,\\pt;R) \\to H^1(X,R) \\to 0\n\\]\nand $0\\to H^k(X,\\pt;R) \\xrightarrow{\\simeq} H^k(X,R) \\to 0$ for $k>1$. From the fragment at the \nstart of the exact sequence, we see that $H^0(X,\\pt;R) \\to H^0(X,R)$ is injective, and this is the \ninclusion of the kernel of the map $H^0(X,R) \\to R$. Thus $H^0(X,\\{x\\};R) = \\ker(H^0(X,R) \\to R)$.\nFor simplicity, we denote $H^k(X,\\{x\\};R)$ by $H^k(X,x;R)$, and call it the \\emph{reduced cohomology}\nof the pointed space $(X,x)$.\n\n\n\\begin{rem}\nWe also have the result that $H^1(X,R)$ is the quotient of $H^1(X,x;R)$ by the image of \n$R\\to H^1(X,x;R)$, but to say definitively what this is we would need to study the construction\nof this map. \n\\end{rem}\n\n\\begin{example}\nFor a discrete space $S$ with chosen basepoint $p\\in S$, then $H^0(S,p;R) \\simeq R^{S\\setminus\\{p\\}}$.\nIn particular, $H^0(\\pt,\\pt;R) = R^\\emptyset = 0$. \n\\end{example}\n\nSince maps of pairs $(X,x) \\to (Y,y)$ are just pointed maps, we have that reduced cohomology is a \nfunctor $H^k(-;R)\\colon\\Top_*^{op} \\to \\Mod_R$.\\marginnote{Exercise!} Note particularly that \nwe only have functoriality for pointed maps.\n\n\nHere's a first result that would help calculate (relative) cohomology\n\n\\begin{prop}\nGiven pairs of spaces $(X,A)$ and $(Y,B)$, there is a canonical isomorphism\n\\[\n\tH^k(X\\sqcup Y,A\\sqcup B;R) \\xrightarrow{\\simeq} H^k(X,A:R)\\oplus H^k(Y,B;R)\n\\]\nfor all $k$. Even better: there is a canonical isomorphism of complexes\n\\[\n\tC^\\bullet(X\\sqcup Y,A\\sqcup B;R) \\xrightarrow{\\simeq} C^\\bullet(X,A:R)\\oplus C^\\bullet(Y,B;R)\n\\]\nthat, on passing to cohomology, give the previous isomorphisms.\n\\end{prop}\n\n\\begin{proof}\nThis is because $\\Top(\\Delta^k,X\\sqcup Y) = \\Top(\\Delta^k,X)\\sqcup \\Top(\\Delta^k,Y)$, and the \nearlier observation that $R^{P\\sqcup Q} \\simeq R^P\\oplus R^Q$ for any sets $P$ and $Q$.\n\\end{proof}\n\nOf course, we get the analogous result for plain cohomology by looking at pairs $(X,\\emptyset)$ and \n$(Y,\\emptyset)$.\n\nHere is a much more powerful and difficult result. Recall that we write $f^*$ generically for $H^k(f)$.\n\n\\begin{theorem}\\label{thm:homotopy_invariance_cohom}\nIf the maps $f,g\\colon X\\to Y$ are homotopic, then \n\\[\n\tf^* = g^*\\colon H^k(Y,R) \\to H^k(X,R)\n\\]\nfor all $k$.\n\\end{theorem}\n\nI will give a few corollaries of this before discussing what goes into the proof, and how we get the \nabove theorem from a stronger statement about complexes. The proofs of the following are applications\nof functoriality and the above theorem.\n\n\\begin{corollary}\nIf $X$ and $Y$ are homotopy equivalent, via $f\\colon X\\leftrightarrows Y:g$, say, then \n$f^* = (g^*)^{-1}$ and $H^k(X,R)$ and $H^k(Y,R)$ are isomorphic for all $k$.\n\\end{corollary}\n\n\\begin{corollary}\nIf a space $X$ is contractible, then $H^k(X,R) = 0$ for $k>0$ and $H^k(X,R) \\simeq R$. More precisely,\nif $X$ is contractible to $x\\in X$, then $H^k(X,R) \\to H^k(\\{x\\},R)$ is an isomorphism for all $k$,\nand hence $H^k(X,x;R) = 0$ for all $k$.\n\\end{corollary}\n\n\\begin{corollary}\nGiven a pointed space $X$ with a path $\\gamma\\colon x\\rightsquigarrow x'$, the two induced maps \n$H^0(X,R) \\to H^0(\\pt,R) = R$ given by the inclusion of $x$ and $x'$ are equal, so that \n$H^0(X,x;R) = H^0(X,x';R)$. Thus reduced cohomology only depends on the path component of the basepoint,\nnot the basepoint specifically.\n\\end{corollary}\n\nWe saw earlier the concept of quasi-isomorphism, which is an analogue for complexes of weak homotopy\nequivalence. But for spaces we have the stronger notion of homotopy of maps, and this should be reflected\nby some construction for complexes.\n\n\\begin{definition}\nLet $f,g\\colon A_\\bullet \\to B_\\bullet$ be maps of complexes. A \\emph{cochain homotopy} from $f$ \nto $g$ is a collection of functions $\\{h_n\\colon A_n \\to B_{n-1}\\}$ satisfying the identities\n\\[\n\t\\delta^B_{n-1}h_n + h_{n+1}\\delta^A_n = f_n - g_n\n\\]\n\\end{definition}\n\n\\begin{lemma}\nIf there is a cochain homotopy from $f$ to $g$, both maps $A_\\bullet\\to B_\\bullet$, then $H^k(f) = H^k(g)$.\n\\end{lemma}\n\n\\begin{proof}\nAn element in $H^k(A_\\bullet)$ is the equivalence class of some $c\\in A_k$ such that $\\delta^A_k(c) = 0$\nso\n\\begin{align*}\nH^k(f)([c]) & = [f_k(c)]\\\\\n\t& = [g_k(c) + \\delta^B_{k-1}(h_k(c)) + h_{k+1}(\\delta^A_k(x))]\\\\\n\t& = [g_k(c)] + [\\delta^B_{k-1}(h_k(c))] \\\\\n\t& = [g_k(c)]\\\\\n\t& = H^k(g)([c])\n\\end{align*}\n\\end{proof}\n\nHere is a stronger version of Theorem~\\ref{thm:homotopy_invariance_cohom}:\n\n\\begin{theorem}\nIf the maps $f,g\\colon X\\to Y$ are homotopic, then there is a cochain homotopy between the two induced maps\n$C^\\bullet(Y,R) \\to C^\\bullet(X,R)$.\n\\end{theorem}\n\nThe proof is reasonably detailed, but constructs an actual such cochain homotopy. Matters are \nsimplified somewhat because one can immediately reduce to the case $Y = I\\times X$ and the two \nfunctions being the inclusions $X\\simeq \\{i\\}\\times X \\to I\\times X$ for $i=0,1$. This is \nbecause of functoriality and the given homotopy $H\\colon I\\times X \\to Y$. Further, one can reduce \na lot of the work to the case $X=\\Delta^k$, and an explicit triangulation of $I\\times \\Delta^k$, so\nthat the inclusion maps $\\Delta^k \\to I\\times \\Delta^k$ come from maps of $\\Delta$-sets. Then it is messy\ncombinatorics to make sure the required identity holds.\n\n\nLet\\lecturenum{27} us consider for a short time again the reduced cohomology, which as noted above is functorial for\npointed maps. For an arbitrary space $X$, there is of course a canonical map $X\\xrightarrow{!_X} \\pt$, which induces a map in cohomology $R=H^0(\\pt,R) \\to H^0(X,R)$. Moreover, since for any map $f\\colon X\\to Y$ we have $!_Y \\circ f = !_X$, the induced map in cohomology $H^0(Y,R) \\to H^0(X,R)$ commutes with these maps from $R$. This is somewhat reminiscent of the situation with reduced cohomology, except now we have a map \\emph{from} $R$, not \\emph{to} $R$. But what is this map?\n\n\\begin{ex}\nGiven a space $X$, $H^0(X,R) \\simeq R^{[\\pt,X]}$, that is, functions that are constant on path-components. Moreover, given $f\\colon X\\to Y$, the induced map $H^0(Y,R) \\to H^0(X,R)$ is given by precomposition with $[\\pt,X]\\to [\\pt,Y]$.\n\\end{ex}\n\nThus $R = H^0(\\pt,R) \\to H^0(X,R)$ sends $r\\in R$ to the constant function on $X$ with value $r$---assuming $X$ is not empty---so we shall denote it by $\\mathrm{const}$. Further, given $x\\in X$, the map $!$ is a retraction to $x\\colon \\pt \\to X$, so that $!_X \\circ x=\\id_X$. Thus we have $R \\xrightarrow{\\mathrm{const}} H^0(X,R) \\xrightarrow{\\ev_x} R$ is the identity map on $R$, and so $\\mathrm{const}$ is injective.\n\n\\begin{definition}\nA \\emph{left splitting} of a short exact sequence $0\\to A \\xrightarrow{i} B \\xrightarrow{\\pi} C \\to 0$ of $R$-modules is a map $r\\colon B\\to A$ such that $r\\circ i = \\id_A$.\n\\end{definition}\n\nThus we have a short exact sequence $0 \\to R\\to H^0(X,R) \\to \\coker(\\mathrm{const}) \\to 0$, and $\\ev_x$ is a left splitting.\n\n\\begin{lemma}\nGiven a left splitting $r$ of a short exact sequence $0\\to A \\xrightarrow{i} B \\xrightarrow{\\pi} \nC \\to 0$, the map $(r,\\pi)\\colon B\\to A\\oplus C$ is an isomorphism, and $C \\simeq \\ker(r)$.\n\\end{lemma}\n \nAs a result, from a choice $x\\in X$ we get an isomorphism $\\coker(\\mathrm{const})\\simeq H^0(X,x;R)$. Since the map $\\mathrm{const}$ is canonical, and doesn't depend on the choice of $x$, it turns out that reduced cohomology is essentially independent of the choice of basepoint.\\marginnote{the submodule $H^0(X,x;R)\\subseteq H^0(X,R)$ can be different for different choices of $x\\in X$, though} Thus we can redefine reduced cohomology to be $\\widetilde{H}^k(X,R) := \\coker(H^k(\\pt,R) \\to H^k(X,R))$; for $k>0$, $\\widetilde{H}^k(X,R)\\simeq H^k(X,R)$, but otherwise $H^0(X,R) \\simeq \\widetilde{H}^0(X,R) \\oplus R$. Further, this is functorial for all maps of spaces, not pointed maps.\n\n\\begin{example}\nGiven any path-connected space $X$ we get $\\widetilde{H}^0(X,R) = 0$ for all $k$. In particular, if $X$ is contractible, then $\\widetilde{H}^k(X,R) = 0$ for all $k$.\n\\end{example}\n\n\\begin{example}\\label{eg:reduced_cohom_S0}\nFor the $0$-sphere $S^0$, we have $\\widetilde{H}^0(S^0,R) = R$ and $\\widetilde{H}^k(S^0,R) = 0$ for $k > 0$.\n\\end{example}\n\nSince we are in the realm of looking at long exact sequences, let us consider the topological space version of Mayer--Vietoris for a union of two subspaces. Take $\\mathcal{U} = \\{U,V\\}$ an open cover of the space $X$. There is a pushout diagram\n\\[\n\t\\xymatrix{\n\tU\\cap V \\ar[r]^{i_V} \\ar[d]_{i_U} & V \\ar[d]^{j_V} \\\\\n\tU \\ar[r]_{j_U} & X\n\t}\n\\]\nWe can define a map\n\\begin{align}\\label{eq:restr_to_intersection}\nC^\\bullet(U,R) \\oplus C^\\bullet(V,R) & \\to C^\\bullet(U\\cap V,R)\\\\\n(f,g) & \\mapsto i^*_U f - i^*_Vg\n\\end{align}\nwhich turns out to be onto: given $\\widetilde{f}\\colon \\Top(\\Delta^n,U\\cap V) \\to R$, we can define a function\n$f\\colon \\Top(\\Delta^n,U) \\to R$ by extension by zero, as $\\Top(\\Delta^n,U\\cap V)$ is naturally a subset of $\\Top(\\Delta^n,U)$. Then $(f,0) \\mapsto \\widetilde{f}$. So if we define $C^\\bullet_\\mathcal{U}(X,R)$ as the kernel of (\\ref{eq:restr_to_intersection}), we get a short exact sequence of complexes\n\\[\n0 \\to C^\\bullet_\\mathcal{U}(X,R) \\to C^\\bullet(U,R) \\oplus C^\\bullet(V,R) \\to C^\\bullet(U\\cap V,R) \\to 0\n\\]\nWe can identify this kernel as something concrete, namely \n\\[\n\tC^k_\\mathcal{U}(X,R) := \\{f\\colon \\Top(\\Delta^k,X) \\to R\\mid f(\\sigma)=0\\text{ if $\\sigma\\colon \\Delta^k\\to X$ doesn't factor through $U$ or $V$}\\}\n\\]\nThe following result is key, but also has a very long and complicated proof\n\\begin{prop}\nThe inclusion $C^\\bullet_\\mathcal{U}(X,R) \\to C^\\bullet(X,R)$ is a quasi-isomorphism, so that\n\\[\n\tH^k(C^\\bullet_\\mathcal{U}(X,R)) \\xrightarrow{\\simeq} H^k(X,R).\n\\]\n\\end{prop}\n\n\\begin{proof}\nThis follows from reasoning similar to Hatcher's Proposition~2.21, albeit using cohomology, not homology.\n\\end{proof}\n\nThe idea of the proof is that given $\\Delta^k \\to X$, one can interatively retriangulate $\\Delta^k$ by more and smaller simplices so that eventually you can break up $\\Delta^k$ into a collection of functions on small simplices, each of which lands (by an application of the Lebesgue covering lemma) inside one of the open subsets $U$ or $V$. This is formally similar to how one can integrate over a simplex in a manifold by covering a manifold by charts, by breaking the simplex up into parts each of which land inside a chart, and then integrate each bit and add them up.\n\n\\begin{theorem}{(Mayer--Vietoris)}\\label{thm:mayer-vietoris}\nGiven an open cover $\\{U,V\\}$ of the space $X$, there is a long exact sequence\n\\[\n0\\to H^0(X,R) \\to H^0(U,R)\\oplus H^0(V,R) \\to H^0(U\\cap V,R) \\to H^1(X,R) \\to H^1(U,R)\\oplus H^1(V,R) \\to \\cdots\n\\]\nof $R$-modules, and similarly with reduced cohomology, starting\n\\[\n0\\to \\widetilde{H}^0(X,R) \\to \\widetilde{H}^0(U,R)\\oplus \\widetilde{H}^0(V,R) \\to \\widetilde{H}^0(U\\cap V,R) \\to H^1(X,R) \\to \\cdots\n\\]\n\\end{theorem}\n\nHere is a key example.\n\n\\begin{example}\nCover the sphere $S^n$ ($n\\geq 1$) by two open sets $D^n_+$ and $D^n_-$, both homeomorphic to discs (hence contractible). Their intersection is homeomorphic to $S^{n-1}\\times J$, for $J$ a small open interval, hence homotopic to $S^{n-1}$. We thus get by the Mayer--Vietoris theorem a long exact sequence\n\\[\n\\hspace{-1.5cm}0\\to \\widetilde{H}^0(S^n,R) \\to \\widetilde{H}^0(D^n_+,R)\\oplus \\widetilde{H}^0(D^n_-,R) \\to \\widetilde{H}^0(S^{n-1}\\times J,R) \\to H^1(S^n,R) \\to H^1(D^n_+,R)\\oplus H^1(D^n_-,R) \\to H^1(S^{n-1}\\times J,R) \\to \\cdots\n\\]\nbut since $D^n_\\pm$ are contractible, this breaks up into pieces. Firstly, $0\\to \\widetilde{H}^0(S^n,R) \\to 0$, hence $\\widetilde{H}^0(S^n,R) =0$, which we knew already, as $S^n$ is path connected. Then for $k>0$ we have\n\\[\n0\\to \\widetilde{H}^0(S^{n-1},R) \\to H^1(S^n,R) \\to 0\n\\]\nand \n\\[\n0\\to H^{k-1}(S^{n-1},R) \\to H^k(S^n,R) \\to 0\n\\]\nfor all $k > 1$. Hence we can attack this problem by induction as (combining the two cases) \n\\begin{equation}\\label{eq:sphere_cohomol_reduction}\n\\widetilde{H}^{k-1}(S^{n-1},R) \\simeq \\widetilde{H}^k(S^n,R).\n\\end{equation}\nIf we take $k=n$, then this gives $\\widetilde{H}^{n-1}(S^{n-1},R) \\simeq \\widetilde{H}^n(S^n,R)$,\n\nBy Example~\\ref{eg:reduced_cohom_S0} we know the reduced cohomology of $S^0$, namely $\\widetilde{H}^0(S^0,R) = R$, so that $\\widetilde{H}^n(S^n,R) = H^n(S^n,R) = R$ for all $n \\geq 1$.\n\n\nFrom\\lecturenum{28} the calculation of the connected components and the fundamental group, we know that $S^0$ and $S^1$ can't be contractible, but the spheres $S^n$ for $n\\geq 2$ are simply-connected, so $\\Pi_1$ cannot tell us that they aren't contractible. But from this result on $H^n$ we have proved\\marginnote{of course, we have seen the claim that $\\pi_n(S^n) = \\ZZ$, but we didn't calculate this ourselves} that all $S^n$ are not contractible. We can also calculate the rest of the cohomology of $S^n$. We use equation (\\ref{eq:sphere_cohomol_reduction}) in the following two cases.\n\n\\begin{itemize}\n\\item Take $k=n+l$ for $l\\geq 1$ to get $\\widetilde{H}^{n+l}(S^n,R) \\simeq \\widetilde{H}^l(S^0,R) = 0$. Thus $H^m(S^n,R) = 0$ for all $m>n$.\\marginnote{In the combinatorial world of $\\Delta$-sets, where $S^n$ is triangulated by $\\partial\\Delta[n+1]$, this is obvious as the sets of $m$-simplices are empty for $m>n$, but here $\\Top(\\Delta^m,S^n)$ is uncountable.} This result implies that $S^n$ is not homotopy equivalent to $S^m$ for $m>n$.\n\\item Given $n>1$, take $0\\leq k \\leq n-2$, and then we get $\\widetilde{H}^{k+1}(S^n,R) \\simeq \\widetilde{H}^1(S^{n-k},R)$. As $n-k>1$, this means we are reduced to calculating $\\widetilde{H}^1(S^n,R)$ for all $n>1$. If we examine the start of the long exact sequence above, we have \n\\[\n\t0 = \\widetilde{H}^0(S^{n-1},R) \\to \\widetilde{H}^1(S^n,R) \\to \\widetilde{H}^1(D^n_+,R)\\oplus\\widetilde{H}^1(D^n_-,R) = 0\n\\]\nso that $\\widetilde{H}^1(S^n,R)=0$.\n\\end{itemize}\n\n\n\n\\end{example}\n\n\\begin{prop}\nPutting these all together, we have calculated all the cohomology modules of $S^n$, for all $n\\geq 0$:\n\\[\n\t\\widetilde{H}^k(S^n,R) = \\begin{cases}\n\tR & k=n\\\\\n\t0 & k\\neq n\n\t\\end{cases}\n\\]\n\\end{prop}\n\nHere's an application of the above calculation to a problem in pure topology. We know that a linear isomorphism between finite-dimensional vector spaces over $\\RR$ is automatically an isomorphism of topological vector spaces: it is linear, continuous, and with linear and continuous inverse. Since two such vector spaces are isomorphic if they have the same dimension, this shows that there is a linear homeomorphism between $\\RR^n$ and $\\RR^m$ precisely when $n=m$. For arbitrary $n,m>0$ then we know that $|\\RR^n| = |\\RR^m| = 2^{\\aleph_0}$, so there is no cardinality obstruction to the existence of a \\emph{nonlinear} homeomorphism $\\RR^n\\simeq\\RR^m$ for different positive $n,m$.\\marginnote{arbitrary continuous maps $\\RR^n \\to \\RR^m$ can be quite wild, for instance space-filling curves}\n\n\\begin{prop}\n$\\RR^n$ is homeomorphic to $\\RR^m$ if and only if $n=m$\n\\end{prop}\n\n\\begin{proof}\nWe will prove the forward implication, the other is trivial. We can assume that a homeomorphism $\\phi\\colon \\RR^n \\to \\RR^m$ satisfies $\\phi(0) = 0$, since otherwise we can compose with the translation by $-\\phi(0)$, which is also a homeomorphism. We can restrict $\\phi$ to $\\RR^n\\setminus\\{0\\}$ to get a homeomorphism $\\RR^n\\setminus\\{0\\} \\simeq \\RR^m\\setminus\\{0\\}$, and so we get an isomorphism in cohomology, $\\widetilde{H}^{n-1}(\\RR^n\\setminus\\{0\\},R)\\simeq \\widetilde{H}^{n-1}(\\RR^m\\setminus\\{0\\},R)$. But since $\\RR^n\\setminus\\{0\\}$ is homotopy equivalent to $S^{n-1}$ for all $n\\geq 1$, we get an isomorphism $R\\simeq \\widetilde{H}^{n-1}(S^{n-1},R) \\simeq \\widetilde{H}^{n-1}(S^{m-1},R)$. Thus $m-1=n-1$, hence the result.\n\\end{proof}\n\nThe following property is rather difficult to prove, and requires nontrivial topological input.\\marginnote[-0.5cm]{this is evidenced by the fact the hypothesis involves closures and interiors of the input subspaces. The hypothesis on $Z\\subset A$ automatically holds if $A$ is open and $Z$ is closed.}\n\n\\begin{theorem}{(Excision)}\nLet $(X,A)$ be a pair of spaces, and $Z\\subset A$ a subspace such that $\\overline{Z}$ is contained in the interior of $A$. Then the inclusion map $(X\\setminus Z,A\\setminus Z) \\into (X,A)$ induces an isomorphism\n\\[\n\tH^k(X,A;R) \\xrightarrow{\\simeq} H^k(X\\setminus Z,A\\setminus Z;R)\n\\]\nfor all $k$.\n\\end{theorem}\n\nIf we think of relative cohomology of $(X,A)$ as telling us about the cohomology of $X/A$, then the above theorem reflects the homeomorphism $(X\\setminus Z)/(A\\setminus Z) \\simeq X/A$ that exists for all $(X,A)$ and $Z\\subset A$ satsifying the hypotheses of the theorem.\\marginnote{Not mentioned earlier, but $X\\setminus \\emptyset := X\\sqcup \\pt$, where the basepoint of $X\\setminus \\emptyset$ is the new disjoint point.}\n\nThis theorem allows us to prove that relative cohomology, at least in certain cases, really \\emph{is} the cohomology of the quotient.\n\n\\begin{theorem}\\label{thm:collapse}\nLet $(X,A)$ be a pair such that $A$ is a non-empty closed subspace, and that there exists a nhd $U\\supset A$ so that $A$ is a deformation retract of $U$. The quotient map $(X,A) \\to (X/A,A/A) = (X/A,\\ast)$ induces an isomorphism\n\\[\n\tH^k(X,A;R) \\xrightarrow{\\simeq} H^k(X/A,\\ast;R) = \\widetilde{H}^k(X/A,R)\n\\]\nfor all $k$.\n\\end{theorem}\n\n\\begin{proof}\nThe proof follows from Hatcher's Proposition~2.22.\n\\end{proof}\n\nAn example of such a pair arises from a pair $\\Delta$-sets: $(X_\\bullet,A_\\bullet)$ gives a pair of space $(|X_\\bullet|,|A_\\bullet|)$ and Hatcher's Proposition~A.4 can be used to prove that there is a nhd $U$ as in the theorem.\n\n\\begin{corollary}\nGiven $(X,A)$ as in Theorem~\\ref{thm:collapse}, there is a long exact sequence\n\\[\n0\\to \\widetilde{H}^0(X/A,R) \\to H^0(X,R) \\to H^0(A,R) \\to H^1(X/A,R) \\to \\cdots\n\\]\n\\end{corollary}\n\n\\begin{proof}\nApply Theorem~\\ref{thm:collapse} to the long exact sequence of a pair that appears in Proposition~\\ref{prop:les_of_pair_of_spaces}.\n\\end{proof}\n\nA canonical example of a pair of $\\Delta$-sets arises as follows. Given $X_\\bullet$ $n$-dimensional, we can consider $\\sk_{n-1}X_\\bullet \\subset X_\\bullet$. There are homeomorphisms\n\\begin{align*}\n|X_\\bullet|/|\\sk_{n-1}X_\\bullet| \n& \\simeq \\left(\\bigsqcup_{X_n} \\Delta^n\\right)\\big/\\left(\\bigsqcup_{X_n}\\partial\\Delta^n\\right)\\\\\n& \\simeq \\left(\\bigsqcup_{X_n}(\\Delta^n/\\partial\\Delta^n)\\right)\\big/\\left(\\bigsqcup_{X_n}\\ast\\right)\\\\\n& \\simeq \\left(\\bigsqcup_{X_n} S^n\\right)/\\disc(X_n)\\\\\n& =: \\bigvee_{X_n} S^n\n\\end{align*}\n\nThe last item is the join of $|X_n|$ copies of $S^n$: since $X_n$ may be infinite, this is defined in a slightly different way to the finite case.\n\n\\begin{definition}\nLet $\\{(X_\\alpha,x_\\alpha)\\}_{\\alpha\\in J}$ be a family of pointed spaces. The \\emph{(infinite) join} $\\bigvee_{\\alpha\\in J} X_\\alpha$ is the quotient $\\left(\\bigsqcup_{\\alpha\\in J} X_\\alpha\\right)/\\disc(J)$, where $J\\into \\bigsqcup X_\\alpha$ is defined as $\\alpha \\mapsto x_\\alpha$. It has a canonical basepoint given by the image of $\\disc(J)$.\n\\end{definition}\n\n\nGiven $n$-dimensional $\\Delta$-set $X_\\bullet$, there is a long exact sequences which reads, in part\n\\[\n\\cdots \\to H^{k-1}(|\\sk_{n-1}X_\\bullet|,R) \\to H^k(|X_\\bullet|,|\\sk_{n-1}X_\\bullet|;R) \\to H^k(|X_\\bullet|,R) \\to H^k(|\\sk_{n-1}X_\\bullet|,R) \\to \\cdots \n\\]\nWe can apply Theorem~\\ref{thm:collapse} to get \n\\[\n\tH^k(|X_\\bullet|,|\\sk_{n-1}X_\\bullet|;R) \\simeq \\widetilde{H}^k(\\bigvee_{X_n}S^n,R)\n\\]\nand the right hand side is something we can acually calculate. Thus $H^k(|X_\\bullet|,R)$ is built up from the cohomology of the smaller-dimensional $|\\sk_{n-1}X)\\bullet|$ and something more explicit.\n\n\n\\begin{prop}\nGiven a family $\\{(X_\\alpha,x_\\alpha)\\}_{\\alpha\\in J}$ of pointed spaces, the inclusions $(X_\\alpha,x_\\alpha) \\to \\bigvee_{\\alpha\\in J} X_\\alpha$ induce an isomorphism\n\\[\n\t\\widetilde{H}^k(\\bigvee_{\\alpha\\in J} X_\\alpha) \\xrightarrow{\\simeq} \\prod_{\\alpha \\in J} \\widetilde{H}^k(X_\\alpha,R)\n\\]\nfor all $k$.\n\\end{prop}\n\n\\begin{example}\nGiven an arbitrary set $J$,\n\\[\n\t\\widetilde{H}^k(\\bigvee_J S^n,R) = \\begin{cases}\n\t\\prod_J R \\simeq R^J & k=n\\\\\n\t0 & k\\neq n\n\t\\end{cases}\n\\]\n\\end{example}\n\n\\begin{rem}\nGiven any $\\Delta$-set $X_\\bullet$, recall the space $|X_\\bullet|$ has distinguished maps $\\Delta^n \\to |X_\\bullet|$. These give an inclusion map\n\\[\n\tC^\\bullet(X_\\bullet,R) \\into C^\\bullet(|X_\\bullet|,R)\n\\]\nwhere on the left we have the combinatorially-defined complex associated to a $\\Delta$-set, and \non the right we have the topologically-defined complex associated to a space. We shall see \nshortly how the cohomology modules of these two complexes relate.\n\\end{rem}\n\n\\lecturenum{29}\n\\begin{lemma}\nGiven a map $X_\\bullet \\to Y_\\bullet$ of $\\Delta$-sets, the following square commutes:\n\\[\n\t\\xymatrix{\n\tC^\\bullet(Y_\\bullet,R) \\ar[d] \\ar[r] & C^\\bullet(|Y_\\bullet|,R) \\ar[d] \\\\\n\tC^\\bullet(X_\\bullet,R) \\ar[r] & C^\\bullet(|X_\\bullet|,R) \n\t}\n\\]\n\\end{lemma}\n\nIf we consider the inclusion map $\\sk_{n-1} X_\\bullet \\to X_\\bullet$, this induces a map of short exact\nsequences\n\\[\n\\xymatrix{\n0 \\ar[r] & C^\\bullet(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\ar[r] \\ar[d]  & C^\\bullet(X_\\bullet,R) \\ar[r] \\ar[d]& C^\\bullet(\\sk_{n-1}X_\\bullet,R) \\ar[r] \\ar[d]& 0\\\\\n0 \\ar[r] & C^\\bullet(|X_\\bullet|,|\\sk_{n-1}X_\\bullet|;R) \\ar[r]  & C^\\bullet(|X_\\bullet|,R) \\ar[r]& C^\\bullet(|\\sk_{n-1} X_\\bullet|,R) \\ar[r] & 0\n }\n\\]\nand so we get map of long exact sequences\n\\[\\hspace{-2.3cm}\n\\xymatrix@C1.5em{\n\\cdots \\ar[r]&H^{k-1}(\\sk_{n-1}X_\\bullet,R) \\ar[r] \\ar[d] & H^k(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\ar[r] \\ar[d]^{(*)} &H^k(X_\\bullet,R) \\ar[r] \\ar[d] & H^k(\\sk_{n-1}X_\\bullet,R) \\ar[r] \\ar[d] &H^{k+1}(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\ar[r] \\ar[d]^{(*)} & \\cdots\\\\\n\\cdots \\ar[r]&H^{k-1}(|\\sk_{n-1}X_\\bullet|,R) \\ar[r] & H^k(|X_\\bullet|,|\\sk_{n-1}X_\\bullet|;R) \\ar[r] &H^k(|X_\\bullet|,R) \\ar[r]  & H^k(|\\sk_{n-1}X_\\bullet|,R) \\ar[r] & H^{k+1}(|X_\\bullet|,|\\sk_{n-1}X_\\bullet|;R) \\ar[r] & \\cdots\\\\\n}\\]\n\n\\begin{fact}\nFor $X_\\bullet$ an $n$-dimensional $\\Delta$-set, the induced map \n$H^k(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\to \\widetilde{H}^k(\\bigvee_{X_n}S^n,R)$ is an isomorphism \nfor all $k$. Why? If $k\\neq n$, then both are zero, and the result is trivial. If $k=n$, then the map is \n\\[\n\t\\prod_{X_n}R \\simeq H^n(X_\\bullet,\\sk_{n-1}X_\\bullet;R) \\to \\widetilde{H}^n(\\bigvee_{X_n}S^n,R)\\simeq \\prod_{X_n} \\widetilde{H}^k(S^n,R) \\simeq \\prod_{X_n} R\n\\]\nand moreover this map is the product of $X_n$-many maps $R \\to R$ all arising as \n$H^n(\\Delta[n],\\partial\\Delta[n];R) \\to H^n(S^n,R)$. Hatcher explicitly calculates this map to be an isomorphism.\n\\end{fact}\n\nThus both of the downward maps labelled as $(*)$ in the big diagram above are isomorphisms.\nThe relation between the combinatorial and the topological cohomologies is in fact the best possible:\n\n\\begin{theorem}\nFor a finite-dimensional $\\Delta$-set $X_\\bullet$, $H^k(X_\\bullet,R) \\xrightarrow{\\simeq} H^k(|X_\\bullet|,R)$ for all $k$.\n\\end{theorem}\n\n\\begin{proof}\nUse induction on the dimension of $X_\\bullet$, as this allows us to assume that for all $k$, the result\nholds for $\\sk_{n-1}X_\\bullet$, and then we can apply the 5 Lemma to the map of long exact sequences.\n\\end{proof} \n\n\\begin{rem}\nThe result is also true for relative cohomology, although the induction is a bit tricker, and we have to set up the map of long exact sequences differently. As a result, it is also true for reduced cohomology.\n\\end{rem}\n\n\\begin{corollary}\nFor \\emph{all} $\\Delta$-sets $X_\\bullet$, \n\\begin{equation}\\label{eq:comparison_iso_simplicial_singular}\n\tH^k(X_\\bullet) \\xrightarrow{\\simeq} H^k(|X_\\bullet|,R)\n\\end{equation}\nfor all $k$..\n\\end{corollary}\n\n\\begin{proof}\n\nWe saw earlier that $H^k(X_\\bullet,R) \\xrightarrow{\\simeq} H^k(\\sk_nX_\\bullet,R)$ for all $k<n$, and similarly \nfor the relative cohomology, so the cohomology on the combinatorial side can be calculated using \na finite-dimensional sub-$\\Delta$-set. On the topological side, it is in fact true that every \n$\\Delta^k \\to |X_\\bullet|$ factors through some $|\\sk_nX|$. However, it might not be the same \n$n$-dimensional approximation for every map. However, one can stil show the desired result using\nthe technology of \\emph{filtered colimits}, which would take us too far for the present purposes.\n\\end{proof}\n\n\n\\begin{rem}\n\\begin{enumerate}\n\\item The LHS of (\\ref{eq:comparison_iso_simplicial_singular}) is only functorial for maps of $\\Delta$-sets\nbut the RHS is functorial for all continuous maps, so this is not an isomorphism of the cohomology functors, which have different domains. \n\\item However, to calculate the cohomology of an \\emph{individual} space, it is very useful.\n\n\\item If the two $\\Delta$-sets $X_\\bullet$, $Y_\\bullet$ have homeomorphism geometric realisations $|X_\\bullet|$, $|Y_\\bullet|$ (and there\nmay be no map of $\\Delta$-sets in either direction!), then \n\\[\nH^k(X_\\bullet,R) \\simeq H^k(|X_\\bullet|,R) \\simeq H^k(|Y_\\bullet|,R) \\simeq H^k(Y_\\bullet,R)\n\\]\n\n\\item More generally, if $|X_\\bullet|$ and $|Y_\\bullet|$ are merely homotopy equivalent, then $X_\\bullet$ and $Y_\\bullet$ have isomorphic cohomology modules.\n\\end{enumerate}\n\\end{rem}\n\n\nTo properly state the last big theorem for this section, we need a minor digression on a certain class\nof spaces that includes all triangulable spaces, but is more general. Recall that the geometric realisation\nof a $\\Delta$-set is defined as a quotient of $\\bigsqcup_{n=0}^\\infty \\disc(X_n) \\times \\Delta^n$, and \nmoreover, one has the sequence of subspaces $|sk_nX_\\bullet| \\subseteq |X_\\bullet|$, such that\n$|sk_{n+1}X_\\bullet|$ can be obtained by a quotient of $\\left(\\disc(X_{n+1}) \\times \\Delta^{n+1}\\right) \\sqcup |\\sk_nX_\\bullet|$. \nHowever, simplices are very rigid in how they are glued together, in that the combinatorics of all\nthe lower-dimensional faces have to agree. The following definition\\marginnote{recall that $\\Delta^n$ is homeomorphic to $D^n$ and $\\partial \\Delta^{n+1}$ is homeomorphic to $S^n$} \ntakes a more flexible approach, that captures many more examples.\n\n\\begin{definition}\nA \\emph{CW-complex} structure on a space is a homeomorphism to one built of the form $\\bigcup_{n=0}^\\infty X_n$ \nwhere\\marginnote{given such subspace inclusions $i_n\\colon X_n \\to X_{n+1}$ for all $n$, define $\\bigcup_n X_n$ to be $\\left(\\bigsqcup_n X_n\\right)/\\!\\sim$ where for $x\\in X_n$, $x\\sim i_n(x)$} \n$\\cdots \\into X_n \\into X_{n+1}\\into \\cdots$ are a sequence of subspace inclusions\nwhere:\n\\begin{itemize}\n\\item $X_0$ is a discrete space\n\\item for all $n\\geq 1$ there is a set $J_n$, a map $j_n\\colon \\disc(J_n)\\times S^n \\to X_n$ such that the \nfollowing is a pushout square\n\\[\n\\xymatrix{\n\\disc(J_n) \\times S^n \\ar[r]^-{j_n} \\ar[d]_{\\id\\times \\iota_n} & X_n \\ar[d]\\\\\n\\disc(J_n) \\times D^{n+1} \\ar[r] & X_{n+1}\n}\n\\]\nfor $\\iota_n\\colon S^n \\into D^{n+1}$ the boundary inclusion. That is, $X_{n+1} := (\\disc(J_n)\\times D^{n+1}\\sqcup X_n)/\\!\\sim$.\n\\end{itemize}\n\\end{definition}\n\n\n\\begin{tikzpicture}[use Hobby shortcut,closed=true,scale=0.70]\n    \\draw (-3,0) .. (-3,3) .. (-1,3.5).. (1,3).. (4,3.5).. (4,2.5).. (5,0) ..(2,-2).. (0,-1).. (-3,-2).. (-3.5,0.5);\n    \\node at (4.2,4.2) {$X_n$};\n\n\n    \\draw[thick,dotted,red] plot [smooth cycle, tension=0.5] coordinates {(-1,1.5) (0,2.5) (0.5,1) (0,1) (-1.1,2.5)};\n\n\t\\draw[xshift=-5cm,yshift=4cm,red] (0,0) ellipse (1 and 0.3);\n\t\\draw[xshift=-5cm,yshift=4cm] (1,0) arc (0:180:1);\n    \\draw[shorten <=0.2cm,->] (1,0)++(-5.2cm,3.9cm) to[out=-60,in=170]  (-1.3,2);\n    \\node at (-3.7,5.3) {$D^{n+1}$};\n    \\node at (-5.5,3.3) {$S^n$};\n\n\n    \\draw[thick,dotted,yshift=-2cm,red] plot [smooth cycle] coordinates {(1,1) (2,2) (3.5,2) (2,1)};\n\n\t\\draw[xshift=-7.5cm,yshift=2cm,red] (0,0) ellipse (1 and 0.3) ;\n\t\\draw[xshift=-7.5cm,yshift=2cm] (1,0) arc (0:180:1);\n\t\\draw[shorten <=0.2cm,->] (1,0)++(-7.7cm,1.9cm) to[out=-40,in=130]  (1.2,-0.5);\n\n\n\n\t\\draw[thick,dotted,xshift=-3cm,yshift=-1cm,red] (0,0) ellipse (1 and 0.5);\n\n\t\\draw[xshift=-7cm,yshift=-1cm,red] (0,0) ellipse (1 and 0.3); \n\t\\draw[xshift=-7cm,yshift=-1cm] (1,0) arc (0:180:1);\n\t\\draw[shorten <=0.2cm,->] (1,0)++(-7.2cm,-1.1cm) to[out=-30,in=200]  (-4cm,-1.2cm);\n\n\n\\end{tikzpicture}\n\nFor simplicity, any space constructed as in the definition together with the data constructing \nit is called a CW-complex. Note that for each $\\alpha\\in J_n$, we get a map $S^n \\into \n\\disc(J_n) \\times S^n \\to X_n$, and so we can consider the maps $j_n$ as encoding a family of \nmaps $S^n = \\partial D^{n+1} \\to X_n$ which we want to use to attach copies of $D^{n+1}$ to \n$X_n$ along their boundary. These maps $S^n \\to X_n$ are called \\emph{attaching maps}. We define \nthe category $CW$ to consist of spaces with a CW-complex structure and with arbitrary continuous \nmaps between them.\n\n\n\\begin{example}\nAny triangulation $X \\simeq |X_\\bullet|$ gives a CW-complex structure on $X$.\n\\end{example}\n\nThus the geometric realisation functor is really $|-|\\colon \\Delta\\Set \\to CW$.\n\n\\begin{example}\nAny compact manifold of dimension not $4$ has a CW-complex structure, and moreover every compact manifolds\nis homotopy equivalent to a CW-complex.\n\\end{example}\n\nSince we want to talk about relative cohomology, we have a certain class of pairs $(X,A)$ that we are interested in.\n\n\\begin{definition}\nA \\emph{CW-pair} $(X,A)$ consists of a CW-complex $X$ together with a subspace $A\\subseteq X$ that is also\na CW-complex built by considering subsets $K_n \\subseteq J_n$ of the attaching maps for $X$.\n\\end{definition}\n\nOne can prove by induction that for a CW-pair, $A\\subseteq X$ is a closed subspace.\n\n\\begin{example}\nGiven a pair $(X_\\bullet,A_\\bullet)$ of $\\Delta$-sets, the geometric realisation $(|X_\\bullet|,|A_\\bullet|)$ is a CW-pair.\n\\end{example}\n\nThere is a category $CW^{(2)}$ whose objects are CW-pairs and whose maps are maps of pairs: $(X,A) \\to (Y,B)$ is a map $f\\colon X\\to Y$ such that $f(A) \\subseteq B$.\nThe category $CW$ includes into $CW^{(2)}$ via $X\\mapsto (X,\\emptyset)$.\nCW-pairs $(X,A)$ have the property that there is a nhd $U \\supset A$ in $X$ of which $A$ is a deformation retract, hence\nwe have isomorphisms $\\widetilde{H}^k(X/A,R) \\xrightarrow{\\simeq}H^k(X,A;R)$ for all $k$. \n\nWe can of course talk about homotopy of maps between spaces with CW-complex structure, and even \nhomotopies between maps of pairs, which are required to be maps of pairs at each intermediate point \nof the homotopy. Thus we can define a category $hCW^{(2)}$ where morphisms are homotopy equivalence\nclasses of maps of pairs (and the analogous category $hCW$ where we don't take pairs).\n\n\\begin{theorem}{(Eilenberg--Steenrod 1945)}\nLet \n\\[\nh^k\\colon \\left(hCW^{(2)}\\right)^{op} \\to \\Mod_R\n\\]\nbe\\marginnote{define $h^k(X) := h^k(X,\\emptyset)$} a sequence of functors, for $k\\in \\ZZ$, such that\n\\begin{enumerate}\n\\item For every family $\\{X_\\alpha\\}_{\\alpha\\in J}$ of CW complexes, $h^k(\\bigsqcup_{\\alpha\\in J} X_\\alpha) \\xrightarrow{\\simeq} \\prod_{\\alpha\\in J} h^k(X_\\alpha)$ for all $k$;\n\\item For all CW-pairs $(X,A)$ there is a natural map $h^k(A) \\to h^{k+1}(X,A)$ and a long exact sequence\n\\[\n\\cdots \\to h^k(X,A) \\to h^k(X) \\to h^k(A) \\to h^{k+1}(X,A) \\to \\cdots\n\\]\n\\item Given a CW-pair $(X,A)$ and a subspace $Z\\subset A$ such that $\\overline{Z} \\subset \\mathrm{int}(A)$, the inclusion induces an isomorphism $h^k(X,A) \\xrightarrow{\\simeq} h^k(X\\setminus Z,A\\setminus Z)$ for all $k$;\n\\item $h^0(\\pt)\\simeq R$ and $h^k(\\pt) = 0$ for $k\\neq 0$;\n\\end{enumerate}\nthen there is a natural isomorphism $h^k \\simeq H^k(-,-;R)$, where $H^k(-,-;R)$ is the restriction of relative cohomology of spaces to CW-pairs.\\marginnote{or rather the induced functor on the homotopy category}\n\\end{theorem}\n\nNote that we can get a reduced version $\\widetilde{h}^k$ of $h^k$, and in this case $\\widetilde{h}^k\\simeq \\widetilde{H}^k$ as well.\nWe can derive, from the above axioms, all of the exact sequences and properties of cohomology, so\nthe construction of singular cohomology can be seen as an existence proof of a series of functors satisfying\nthe Eilenberg--Steenrod theorem. After that, one can usually just work with the abstract properties.\n\n\\section{Classical applications}\n\n\nIn\\lecturenum{30} the remaining time, we will give some applications of the techniques we now have to classical problems, namely the existence of fixed points of maps $D^n\\to D^n$, the proof of the fundamental theorem of algebra, and the existence of non-vanishing vector fields on spheres.\n\nRecall that the contraction mapping theorem implies that for any endomorphism $f\\colon D^n \\to D^n$ with the property that $|f(x)-f(y)| \\leq C |x-y|$, for some uniform constant $C\\in (0,1)$, there is a fixed point $x_0\\in D^n$: $f(x_0) = x_0$.\\marginnote{and in fact exactly one fixed point} But there are many endomorphisms that aren't contractions, and which have fixed points; for instance, rotations about $0$. Alternatively, the function $f$ could be constant in some small region (hence with many fixed points), but move other nearby points far apart. So what happens in general? This is answered by the following theorem. Let us call an endomorphism $f\\colon X \\to X$ of any space $X$ \\emph{free} if $f(x)\\neq x$ for all $x\\in X$.\\marginnote{we are of course only considering continuous endomorphisms}\n\n\\begin{theorem}{(Brouwer fixed-point theorem)}\nNo endomorphism $f\\colon D^n\\to D^n$ is free.\n\\end{theorem}\n\n\\begin{proof}\nDefine the map $g_f\\colon D^n \\to \\partial D^n = S^{n-1}$ by the following picture\n\\begin{center}\n\n\\begin{tikzpicture}[scale=0.8]\n\n\\begin{scope}\n\\clip[draw,name path=circ] (0,0) circle [radius=3];\n\\draw [name path=line] (0.5,-0.5)  -- (2,4);\n\\end{scope}\n\n\\fill  (1,1) circle (2pt) node[left] {$x$};\n\\fill  (0.5,-0.5) circle (2pt) node[left] {$f(x)$};\n\n\\fill ({(3+sqrt(43/2))/5},{3*(3+sqrt(43/2))/5 - 2})circle (2pt) node[above right] {$g_f(x)$};\n\n\\end{tikzpicture}\\end{center}\n\nThen $g_f$ is continuous\\sidenote{Exercise! Try using a sequential characterisation} and moreover if $x\\in \\partial D^n$ then $g_f(x)=x$. If $i$ denotes the inclusion $\\partial D^n \\into D^n$, then we have $g_f\\circ i = \\id_{\\partial D^n}$. Apply the funtor $H^{n-1}(-,\\ZZ)$ to get\n\\[\n\t\\ZZ \\simeq H^{n-1}(\\partial D^n,\\ZZ) \\xrightarrow{i^*} H^{n-1}(D^n,\\ZZ) \\xrightarrow{g_f^*} H^{n-1}(\\partial D^n,\\ZZ) \\simeq \\ZZ,\n\\]\nwhich is the identity map on $\\ZZ$. But $H^{n-1}(D^n,\\ZZ) =0$, hence a contradiction, and so there is so such endomorphism.\n\\end{proof}\n\n\\begin{rem}\nUsually this is stated as ``every endomorphism has a fixed point'', though the proof directly shows that no endomorphism can fail to have a fixed point.\\marginnote{the distinction is important in both non-classical logic and numerical/computational settings} The location of the fixed point can jump discontinuously given a continuous family of endomorphisms, and so there is no `method' to construct the fixed point, unlike in the case of the contraction mapping theorem. In that case, the proof constructs a Cauchy sequence converging to the (unique) fixed point, but here the fixed point set can have rather wild behaviour.\n\\end{rem}\n\nAnother even more classical result is the fundamental theorem of algebra. The proof requires \\emph{some} topological input\\marginnote{the minimum required seems to be that of a \\emph{real-closed field} $k$: ordered, and every odd-degree polynomial has a root. Given such a field, the extension $k[\\sqrt{-1}]$ is then algebraically closed. The intermediate value theorem guarantees this for $k=\\RR$.} and here we will implicitly use the fundamental group of the space of non-zero complex numbers $\\CC^\\times$, which is isomorphic to $\\ZZ$. I will again state this in a slightly non-standard way, reflecting the actual content of the proof. Recall that a \\emph{monic} polynomial is one with the coefficient of the leading term equal to $1$. We will consider polynomials with complex coefficients.\n\n\\begin{theorem}{(Fundamental Theorem of Algebra)}\nA non-constant monic polynomial function $p\\colon \\CC \\to \\CC$ cannot factor through the inclusion $\\CC^\\times \\into \\CC$.\n\\end{theorem}\n\n\\begin{proof}\nFor fixed $R \\gg 0$, then $p_R(\\theta) := p(Re^{i\\theta}) \\approx R^n e^{in\\theta}=:q(\\theta)$. Even better, there is a homotopy between $p_R$ and $q$, as functions $S^1\\to \\CC^\\times$. Note that $q$ is not homotopic to a constant function, using a path-lifting argument through the covering map $\\exp\\colon \\CC \\to \\CC^\\times$. Now assume $p$ factors through $\\CC^\\times$. There is then a homotopy between $p_R$ and the constant function at $p(0)$, as functions $S^1\\to \\CC^\\times$, via $(t,\\theta)\\mapsto p((1-t)Re^{i\\theta})$. Thus we get a contraction, as this would imply $q$ is homotopic to the constant function at $p(0)$, and so $p$ cannot land in $\\CC^\\times$.\n\\end{proof}\n\nThe last result belongs to the area of differential topology, which is the intersection between differential geometry and topology. Recall that there is a nonvanishing vector field on $S^1$ given by translating the unit tangent vector at $1$. More concretely, we can take $S^1 \\subset \\RR^2$, and the tangent vector at $(x,y)$ to be $(-y,x)$. One can ask if it is possible to find a nonvanishing vector field on other spheres \\marginnote{or even how many, which is a harder problem!}. The nickname of the following theorem comes from the case of $S^2$, where one can visualise a vector field as being given by little hairs, the tangency condition corresponding to asking the hair be combed flat. \n\n\\begin{theorem}{(Hairy sphere theorem)}\\label{thm:hairy_sphere}\nThere exists a nonvanishing vector field on $S^n$ if and only if $n$ is odd.\n\\end{theorem}\n\nThe proof requires some additional technology, which I will give without proofs. The only difficult part is the lemma below, a proof can be found in Hatcher.\nNote that we can assume the vector field on has length $1$ everywhere, and this allows us to think of the vector field as a map $S^n \\to S^n$, as we can identify the unit sphere in $T_pS^n \\subset \\RR^{n+1}$ with $S^n$. Then, given such a map, it induces a homomorphism $f^*\\colon \\ZZ \\simeq H^n(S^n,\\ZZ) \\to H^n(S^n,\\ZZ) \\simeq \\ZZ$.\n\n\\begin{definition}\nGiven a function $f\\colon S^n \\to S^n$, define the \\emph{degree} $\\Deg(f)$ of $f$ to be the integer $f^*(1)\\in H^n(S^n,\\ZZ) \\simeq \\ZZ$.\n\\end{definition}\n\nThe degree of a map has the following properties, which follow quickly from the definition.\n\\begin{enumerate}\n\\item If $f$ is not surjective, then $\\Deg(f)=0$, as it factors through a chart, which is contractible;\n\\item $\\Deg(\\id_{S^n})=1$;\n\\item $\\Deg(g\\circ f) = \\Deg(g)\\Deg(f)$;\n\\item If $f$ is homotopic to $g$, then $\\Deg(f) = \\Deg(g)$;\n\\end{enumerate}\nAs a result, $\\Deg$ gives a map of monoids $[S^n,S^n] \\to \\End(\\ZZ)\\simeq (\\ZZ,\\times)$\n\n\\begin{lemma}\nDefine the coordinate reflection map $r_i(x_1,\\ldots,x_{n+1}) = (x_1,\\ldots,-x_i,\\ldots,x_{n+1})$. Then $\\Deg(r_i) = -1$.\n\\end{lemma}\n\nHatcher gives a proof using an explicit calculation with a triangulation of $S^n$ using two copies of $\\Delta[n]$ that are swapped under $r_i$.\\marginnote{if you have seen de~Rham cohomology, then the degree of this map can be seen as arising from the reversal of orientation of $S^n$, and the resulting sign change in the global volume form}\n\n\\begin{corollary}\nFor the antipodal map $-\\id_{S^n}$, $\\Deg(-\\id_{S^n}) = (-1)^{n+1}$.\n\\end{corollary}\n\n\\begin{proof}{(of Theorem \\ref{thm:hairy_sphere})}\nAssume we have $v\\colon S^n\\to S^n$ corresponding to a nonvanishing vector field. We can think of this as a map $v\\colon S^n \\to \\S^n \\into \\RR^{n+1}$ satisfying $v(x)\\cdot x = 0$ for all $x\\in S^n$. Define the map\n\\begin{align*}\nh\\colon I \\times S^n & \\to \\RR^{n+1}\\\\\n(t,x) & \\mapsto \\cos(\\pi t) x + \\sin(\\pi t) v(x)\n\\end{align*}\nThen $h(t,x)\\cdot h(t,x) = 1$, so is a map $I\\times S^n \\to S^n$. Moreover, $h(0,x) = x$, and $h(1,x)=-x$ so that $h$ is a homotopy between $\\id_{S^n}$ and $-\\id_{S^n}$. Sinc degree is a homotopy invariant, this implies that $1 = \\Deg(\\id_{S^n}) = \\Deg(-\\id_{S^n}) = (-1)^{n+1}$. Thus a nonvanishing vector field can only exist if $n$ is odd.\n\nConversely, if $n=2k-1$, for $x\\in S^{2k-1} \\subset\\RR^{2k}$ define \n\\[\n\tv(x) = (-x_2,x_1,-x_4,x_3,\\ldots,-x_{2k},x_{2k=1})\n\\]\nwhich gives a map $S^{2k-1} \\to S^{2k-1}$ such that $v(x)\\cdot x = 1$, hence is a nonvanishing vector field. This looks like the vector field on the circle above on each circle $S^1 \\subset \\RR^2 \\subset \\RR^2 \\times \\cdots \\times \\RR^2$ ($k$ times).\n\n\n\\end{proof}\n\n\n\\end{document}\n", "meta": {"hexsha": "2aa5c714a9c58b074d2ae3df1c866d8e815f6b81", "size": 331447, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes.tex", "max_stars_repo_name": "DavidMichaelRoberts/AlgebraicTopology2019", "max_stars_repo_head_hexsha": "b947ad2e9f9e301bfe24590a9db653bc54fa1a53", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2019-05-31T14:22:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-12T23:08:14.000Z", "max_issues_repo_path": "Notes.tex", "max_issues_repo_name": "DavidMichaelRoberts/AlgebraicTopology2019", "max_issues_repo_head_hexsha": "b947ad2e9f9e301bfe24590a9db653bc54fa1a53", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes.tex", "max_forks_repo_name": "DavidMichaelRoberts/AlgebraicTopology2019", "max_forks_repo_head_hexsha": "b947ad2e9f9e301bfe24590a9db653bc54fa1a53", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-08-16T13:16:55.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-04T03:57:16.000Z", "avg_line_length": 52.0406657246, "max_line_length": 929, "alphanum_fraction": 0.6875216852, "num_tokens": 114398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.42031138743429947}}
{"text": "% Part: normal-modal-logic\n% Chapter: filtrations\n% Section: more-filtrations\n\n\\documentclass[../../../include/open-logic-section]{subfiles}\n\n\\begin{document}\n\n\\olfileid{mod}{fil}{acc}\n\n\\olsection{Filtrations and Properties of Accessibility}\n\n\\begin{defn}\n  Let $\\Gamma$ be closed under subformulas and $\\mModel{M} =\\tuple{W, R, V}$ a\n  model. Then we can define conditions on pairs of worlds $u,v$ as given in\n  the table of \\olref{fig:Cn-filtrations}. \n\\end{defn}\n\n  \\begin{figure}[ht]\n    \\centering\n    \\begin{tabular}{|ll|}\n      \\hline\n      \\multirow{2}{*}{$C_1(u,v)$:}  &if $\\Box!A \\in \\Gamma$  and $\\mSat{M}{\\Box!A}[u]$ then $\\mSat{M}{!A}[v]$; and \\\\\n      & if $\\Diamond!A \\in \\Gamma$  and $\\mSat{M}{!A}[v]$ then $\\mSat{M}{\\Diamond!A}[u]$; \\\\\n      \\hline\n      \\multirow{2}{*}{$C_2(u,v)$:} &if $\\Box!A \\in \\Gamma$  and $\\mSat{M}{\\Box!A}[v]$ then $\\mSat{M}{!A}[u]$; and \\\\\n      & if $\\Diamond!A \\in \\Gamma$  and $\\mSat{M}{!A}[u]$ then $\\mSat{M}{\\Diamond!A}[v]$; \\\\\n      \\hline\n      \\multirow{2}{*}{$C_3(u,v)$:} &if $\\Box!A \\in \\Gamma$  and $\\mSat{M}{\\Box!A}[u]$ then $\\mSat{M}{\\Box!A}[v]$; and \\\\\n      & if $\\Diamond!A \\in \\Gamma$  and $\\mSat{M}{\\Diamond!A}[v]$ then $\\mSat{M}{\\Diamond!A}[u]$; \\\\\n      \\hline\n      \\multirow{2}{*}{$C_4(u,v)$:} &if $\\Box!A \\in \\Gamma$  and $\\mSat{M}{\\Box!A}[v]$ then $\\mSat{M}{\\Box!A}[u]$; and \\\\\n      & if $\\Diamond!A \\in \\Gamma$  and $\\mSat{M}{\\Diamond!A}[u]$ then $\\mSat{M}{\\Diamond!A}[v]$; \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Conditions on possible worlds for defining\n      filtrations.}\\ollabel{fig:Cn-filtrations}\n\\end{figure}\n\n\\begin{thm}\\ollabel{thm:more-filtrations}\n  Let $\\mModel{M} =\\tuple{W,R,P}$ be a model, $\\Gamma$ closed under\n  subformulas. Let $W^*$ and $V^*$ be defined as in\n  \\olref[fil]{def:filtration}. Then:\n  \\begin{enumerate}\n  \\item If $R^*$ is defined as $R^*[u][v]$ if and only if $C_1(uv)\n    \\land C_2(u,v)$ then $R^*$ is symmetric, and\n    $\\mModel{M^*} = \\tuple{W^*,R^*,V^*}$ is a filtration if $\\mModel{M}$\n    is symmetric.\n  \\item If $R^*$ is defined as $R^*[u][v]$ if and only if $C_1(uv)\n    \\land C_3(u,v)$ then $R^*$ is transitive, and\n    $\\mModel{M^*}=\\tuple{W^*,R^*,V^*}$ is a filtration if $\\mModel{M}$\n    is transitive.\n  \\item If $R^*$ is defined as $R^*[u][v]$ if and only if $C_1(uv)\n    \\land C_2(u,v) \\land C_3(u,v) \\land C_4(u,v)$ then $R^*$ is\n    symmetric and transitive, and $\\mModel{M^*}=\\tuple{W^*,R^*,V^*}$\n    is a filtration if $\\mModel{M}$ is symmetric and transitive.\n  \\item If $R^*$ is defined as $R^*[u][v]$ if and only if $C_1(uv)\n    \\land C_3(u,v) \\land C_4(u,v)$ then $R^*$ is transitive and\n    euclidean, and $\\mModel{M^*}=\\tuple{W^*,R^*,V^*}$ is a filtration\n    if $\\mModel{M}$ is transitive and euclidean.\n  \\end{enumerate}\n\\end{thm}\n\n\\begin{proof}\n  \\begin{enumerate}\n    \\item It's immediate that $R^*$ is symmetric, since $C_1(u,v)\n      \\Leftrightarrow C_2(v,u)$ and $C_2(u,v) \\Leftrightarrow\n      C_1(v,u)$. So it's left to show that if $\\mModel{M}$ is\n      symmetric then $\\mModel{M^*}$ is a filtration through\n      $\\Gamma$. By condition $C_1(u,v)$ we get that: if $\\Box!A \\in\n      \\Gamma$ and $\\mSat{M}{\\Box!A}[u]$ then $\\mSat{M}{!A}[v]$, and if\n      $\\Diamond!A \\in \\Gamma$ and $\\mSat{M}{!A}[v]$ then\n      $\\mSat{M}{\\Diamond!A}[u]$. So all we need is that $Ruv$ implies\n      $R^*[u][v]$.\n\n      So suppose $Ruv$, to show $R^*[u][v]$ we need $C_1(u,v) \\land\n      C_2(u,v)$. For $C_1$: if $\\Box!A \\in\\Gamma$ and\n      $\\mSat{M}{\\Box!A}[u]$ then also $\\mSat{M}{!A}[v]$ (since $Ruv$);\n      and similarly if $\\Diamond!A \\in \\Gamma$ and $\\mSat{M}{!A}[v]$\n      then $\\mSat{M}{\\Diamond!A}[u]$. For $C_2$: if $\\Box!A \\in\n      \\Gamma$ and $\\mSat{M}{\\Box!A}[v]$ then $Ruv$ implies $Rvu$ by\n      symmetry, so that $\\mSat{M}{!A}[u]$; similarly if $\\Diamond!A\n      \\in\\Gamma$ and $\\mSat{M}{!A}[u]$ then $\\mSat{M}{\\Diamond!A}[v]$\n      (since $Rvu$ by symmetry).\n    \\item Exercise.\n    \\item Exercise.\n    \\item Exercise.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{prob}\n  Complete the proof of \\olref[mod][fil]{thm:more-filtrations}.\n\\end{prob}\n\nThis approach does not work in the case of models that are euclidean\nor serial and euclidean. Consider the model at the top of\nFigure~\\olref{fig:ser-eucl}, which is both euclidean and serial. Let\n$\\Gamma = \\{p, \\Box p \\}$. When taking a filtration through $\\Gamma$,\nthen $[w_1] = [w_3]$ since $w_1$ and $w_3$ are the only worlds that\nagree on $\\Gamma$. Any filtration will also have the arrow inherited\nfrom $\\mModel{M}$, as depicted in Figure~\\olref{fig:ser-eucl2}. But we\ncannot add arrows to that model in order to make it euclidean, for\nthen there would be a double arrow between $w_2$ and $w_4$, and hence\nalso between $w_2$ and $w_5$. But $\\Box p$ is true at $w_2$ while $p$\nis false at $w_5$.\n\n\\begin{figure}[htpb]\n  \\centering\n  \\begin{tikzpicture}[node distance=2cm, auto, thick]\n    \\node (w1) at (0, 0) [label=90:$w_1$, label=below:$\\lnot p$]{$\\bullet$}; \n    \\node (w2) at (2, 0) [label=90:$w_2$, label=below:$p$]{$\\bullet$}; \n    \\draw[->] (w1) to node {} (w2);\n    \\path node at (0,-1) {$\\Box p$};\n    \\path node at (2,-1) {$\\Box p$};\n    \\node (w3) at (0, -2.5) [label=90:$w_3$, label=below:$\\lnot p$]{$\\bullet$}; \n    \\node (w4) at (2, -2.5) [label=135:$w_4$,\n      label=below:$p$]{$\\bullet$}edge [in=60,out=120,loop] (); \n    \\draw[->] (w3) to node {} (w4);\n    \\node (w5) at (4, -2.5) [label=90:$w_5$, label=below:$\\lnot p$]{$\\bullet$}; \n    \\draw[<->] (w4) to node {} (w5) edge [in=30,out=-30,loop] () ;\n    \\path node at (0,-3.5) {$\\Box p$};\n    \\path node at (2,-3.5) {$\\lnot\\Box p$};\n    \\path node at (4,-3.5) {$\\lnot\\Box p$};\n    \\draw [rounded corners] (-1,-4) -- ++(6.25,0)  -- ++(0,5) -- ++(-6.25,0) --  cycle;\n    % \\draw[->, bend left] (w1) to node {$R$} (w2); \n    % \\draw[->, bend left] (w2) to node {} (w1); \n    % \\draw [rounded corners] (-1,-1) -- ++(0,2)  -- ++(4.25,0) -- ++(0,-2) --  cycle;\n    % \\path node at (2.75,0.75) {$\\mModel{M}$};\n  \\end{tikzpicture}\n  \\caption{A serial and euclidean model.}\\ollabel{fig:ser-eucl}\n\\end{figure}\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{tikzpicture}[node distance=2cm, auto, thick]\n    \\node (w1) at (-0.5, -1) [label=110:{$[w_1]=[w_3]$}, label=below:$\\lnot\n      p$]{$\\bullet$}; \n    \\path node at (-0.5,-2) {$\\Box p$};\n    \\node (w2) at (2, 0) [label=90:$w_2$,\n      label=0:{$p, \\Box p$}]{$\\bullet$}; \n    \\node (w4) at (2, -2.5) [label=210:$w_4$,\n      label=below:$p$]{$\\bullet$}edge [in=60,out=120,loop] (); \n    \\draw[->] (w1) to node {} (w2);\n    \\draw[->] (w1) to node {} (w4);\n    \\node (w5) at (4, -2.5) [label=90:$w_5$, label=below:$\\lnot p$]{$\\bullet$}; \n    \\draw[<->] (w4) to node {} (w5) edge [in=30,out=-30,loop] () ;\n    \\path node at (2, -3.5) {$\\lnot\\Box p$};\n    \\path node at (4, -3.5) {$\\lnot\\Box p$};\n    \\draw [rounded corners] (-3,-4) -- ++(8.25,0)  -- ++(0,5) -- ++(-8.25,0) --  cycle;\n  \\end{tikzpicture}\n  \\caption{The filtration from the model in Figure~\\olref{fig:ser-eucl}.}\n  \\ollabel{fig:ser-eucl2}\n\\end{figure}\n\nIn particular, it is not enough to consider filtrations through\narbitrary $\\Gamma$'s closed under subsentences. Instead we need to\nconsider sets $\\Gamma$ that are \\emph{modally closed} (see\n\\olref{def:modallyclosed}). Such sets of sentences are\ninfinite, and therefore do not lead immediately to the decidability of\nthe corresponding system.\n\n\\begin{thm}\n  Let $\\Gamma$ be modally closed and $\\mModel{M}=\\tuple{W,R,V}$. If\n  $\\mModel{M^*} = \\tuple{W^*,R^*,V^*}$ is a coarsest filtration of\n  $\\mModel{M}$, then $\\mModel{M^*}$ is symmetric, transitive or\n  euclidean if $\\mModel{M}$ is symmetric, transitive, or euclidean,\n  respectively.\n\\end{thm}\n\n\\begin{proof}\n  The proof of transitivity uses the validity of both \\Ax{4} and\n  $\\mathsf{4_\\Diamond}$ in all transitive models, and likewise\n  euclideanness uses the fact that both \\Ax{5} and\n  $\\mathsf{5_\\Diamond}$ are valid in all euclidean models, and the\n  proof of symmetry likewise uses both \\Ax{B} and\n  $\\mathsf{B_\\Diamond}$.\n\n  If $\\mModel{M^*}$ is a coarsest filtration, then by definition\n  $R^*[u][v]$ holds if and only if $C_1(u,v)$. For transitivity,\n  suppose $C_1(u,v)$ and $C_1(v,w)$: to show $C_1(u,w)$ suppose\n  $\\mSat{M}{\\Box !A}[u]$; then $\\mSat{M}{\\Box\\Box!A}[u]$; since\n  $\\Box\\Box!A \\in \\Gamma$ by closure, also by $C_1(u,v)$,\n  $\\mSat{M}{\\Box!A}[v]$ and by $C_1(v,w)$, also $\\mSat{M}{!A}[w]$. The\n  case for $\\Diamond!A$ is similar.\n\\end{proof}\n\n\\part{Problem sets}\n\n\\section{Problem set 1: understanding Kripke semantics}\n\n\n\\begin{problem} [60 points]\n  Consider the following model ${M}$ for the language\n  comprising $p_1, p_2, p_3$ as the only propositional variables:\n%% See: http://pdp7.org/blog/?p=133\n\\begin{center}\n  \\begin{tikzpicture}[node distance=2cm, auto, thick]\n    \\node (w1) {$w_1 \\, \\bullet$} ; \n    \\node (w2) [right of=w1]\n    {$\\bullet$}; \n    \\node (w3) [right of=w2] {$\\bullet$} edge\n    [in=60,out=120,loop] () ;\n    \\draw[->] (w1) to node {} (w2); \\draw[->] (w2) to node {} (w3);\n    \\draw[->, bend left] (w1) to node [swap] {$w_2$} (w3); \n    \\path node at ( 4.5,0) {$w_3$}; \n    \\path node at ( 0.25,-0.5) {$p_1$}; \n    \\path node at ( 2,-0.5) {$p_1,p_2$}; \n    \\path node at ( 4,-0.5) {$p_1,p_2,p_3$};\n    % \\path node at ( 0,-1) [shape=circle,draw] {};\n  \\end{tikzpicture}\n%\\node [circle,draw] {a} edge [in=30,out=60,loop] ();\n\\end{center}\nAre the following !!{formula}s and schemas true in the model ${M}$,\ni.e., true at every world in ${M}$? Explain.\n\\begin{enumerate}\n\\item $p\\lif \\Diamond p$ (for $p$ atomic);\n\\item $!A\\lif \\Diamond !A$ (for $!A$ arbitrary);\n\\item $\\Box p \\lif p$ (for $p$ atomic);\n\\item $\\lnot p \\lif \\Diamond \\Box p$ (for $p$ atomic);\n\\item $\\Diamond \\Box !A$ (for $!A$ arbitrary);\n\\item $\\Box \\Diamond p$ (for $p$ atomic). \n\\end{enumerate}\n\\end{problem}\n\n\n\\begin{problem} [20 points]\nFor each of the following !!{formula}s find a model ${M} = \\tuple{W, R V}$ and a\nworld $w \\in W$ such that the !!{formula} fails at $w$:\n\\begin{enumerate}\n\\item $p \\lif \\Box\\Box p$;\n\\item $\\Box(p \\lor q) \\lif (\\Box p \\lor \\Box q)$.\n\\end{enumerate}\n\\end{problem}\n\n\\begin{problem} [20 points]\nFor each of the following schemas find a model $\\mathbf{M}$ such that\nevery instance of the schema is true in $\\mathbf{M}$:\n\\begin{enumerate}\n\\item $!A \\lif \\Diamond\\Diamond !A$;\n\\item $\\Diamond !A \\lif \\Box !A$.\n\\end{enumerate}\n\\end{problem}\n\n\n\\section{Problem set 2: provability}\n\\setcounter{problem}{0}\n\n\\begin{definition}\n  Given a normal system $\\Sigma$ of modal logic, say that $!A$ is\n  \\emph{!!{derivable}} in $\\Sigma$, written $\\Sigma \\Proves !A$, if and\n  only if there is a proof of $!A$ from axioms in $\\Sigma$ using\n  \\MP{} and \\Nec{}. Equivalently, $!A$ belongs to the smallest set of\n  sentences containing $\\Sigma$ and closed under tautological\n  implication and \\RK{}.\n\\end{definition}\n\n\\begin{problem} [24 points]\n  Provide $\\Log{K}$-proofs of the following:\n\\begin{enumerate}\n\\item $\\Diamond \\lnot \\lfalse \\lif (\\Box !A \\lif \\Diamond !A)$;\n\\item $\\Box(!A \\lor !B) \\lif (\\Diamond !A \\lor \\Box !B)$;\n\\item $(\\Diamond !A \\lif \\Box !B) \\lif \\Box(!A \\lif !B)$.\n\\end{enumerate}\n\\end{problem}\n\nFor ease of reference, we restate here \\olref{thm:soundness}:\n\n\\noindent\n\\textbf{Soundness Theorem}: if schemas\n$!A_1, \\dots,!A_n$ are valid in the classes of models\n$\\mClass{C}_n, \\dots,\\mClass{C}_n$, respectively, then\n$\\Log{K}!A_1\\dots !A_n \\Proves !B$ implies\nthat $!B$ is valid in the class of models $\\mClass{C}_n \\cap\n\\dots \\cap \\mClass{C}_n$.\n\n\n\\begin{definition}\n  An inference rule of the form \n\\[\n{!A_1 \\dots !A_n} \\over !B \\eqno{(*)\\hspace{2in}}\n\\]\nis \\emph{admissible} in a system $\\Sigma$ if and only if, whenever\n$\\Sigma \\Proves !A_i$ for $i =1, \\dots,n$, then also $\\Sigma\n\\Proves !B$. In other words, adding the new rule to the system does\nnot change the set of !!{derivable} !!{formula}s.\n\\end{definition}\n\n\\begin{definition}\n  An inference rule of the form $(*)$ is \\emph{derivable} in a system\n  $\\Sigma$ if and only if $\\Sigma \\Proves !A_1 \\lif (!A_2 \\to\n  ( \\cdots (!A_n \\lif !B) \\cdots)$.\n\\end{definition}\n\n\\begin{problem} [6 points]\n  Show that if a rule is derivable in $\\Sigma$ then it is admissible\n  in $\\Sigma$. \n\\end{problem}\n\n\\begin{definition}\n  Define a function $\\sigma$ from !!{formula}s into !!{formula}s recursively\n  by setting:\n  \\begin{eqnarray*}\n    \\sigma(p) & = & p ;\\\\\n   \\sigma(\\lfalse) & = &  \\lfalse ;\\\\\n    \\sigma(\\lnot !A) & = & \\lnot\\sigma(!A);\\\\\n   \\sigma(!A \\lif !B) & = & \\sigma(!A) \\lif \\sigma(!B);\\\\\n   \\sigma(\\Box !A) & = & !A.\n  \\end{eqnarray*}\n  So $\\sigma$ erases the outermost occurrence of $\\Box$.  For\n  instance, compute $\\sigma(\\Box(\\Diamond A \\lif \\Diamond\\Box B))$ and\n  $\\sigma(\\Diamond A \\lif \\Diamond\\Box B)$\n% (after re-writing $\\Diamond$ as $\\lnot\\Box\\lnot$)\n.\n\\end{definition}\n\n\\goodbreak\n\n\n\n\\begin{problem} [20 points]\n  Show that if $\\Log{K}\\Proves !A$ then $\\Log{K}\\Proves\n  \\sigma(!A)$ (use induction on the number of lines in the proof).\n    % \\footnote{By induction on the number of lines in a proof:\n    % $\\sigma$ takes $\\Ax{K}$ and any tautologies into\n    % $\\Log{K}$-theorems; and if $!B$ follows from $!A$ by \\MP{}\n    % or \\Nec{} then $\\sigma(!B)$ follows from $\\sigma(!A)$ (although\n    % not necessarily by the same rule).\n\\end{problem}\n\n\\begin{problem} [10 points]\nShow that the following inference rules are admissible in\n$\\Log{K}$:\n\\[\n\\begin{array}{*3{>{\\displaystyle}c@{\\hspace{1in}}}}\n(a) \\hspace{.125in} {\\Diamond!A\\over!A}& \n(b) \\hspace{.125in} {\\Box !A \\lif \\Box !B\\over {!A \\lif !B}}& \n(c) \\hspace{.125in} {\\Box!A \\over !A}.\n\\end{array}\n\\]\n\\end{problem}\n\nIf $\\Sigma$ and $\\Sigma'$ are two systems such that $\\Sigma \\subseteq\n\\Sigma'$ then (obviously) every theorem of $\\Sigma$ is a theorem of\n$\\Sigma'$. The situation is different, however, for rules. If a rule\nof the form $(*)$ is admissible in $\\Sigma$, it does {\\em not} follow\nthat it is admissible in $\\Sigma'$ as well: the latter has {\\em more\n  theorems} than the former, and so the harder it is to show that a\ngiven rule is admissible.\n\n\\begin{problem} [10 points]\n  Show that $\\Log{KB} \\Proves \\Box(!A \\lif \\Diamond\\Diamond\n  !A)$, but $\\Log{KB} \\Proves/  !A \\lif \\Diamond\\Diamond\n  !A$. \\emph{Cheat}: for half the credit, use completeness of\n  $\\Log{KB}$ with respect to symmetric models to show that\n  $\\Log{KB} \\Proves \\Box(!A \\lif \\Diamond\\Diamond !A)$.\n\\end{problem}\n\n\n\\begin{problem} [10 points]\n  Show that $\\Log{K5}\\Proves \\Box(!A \\lif \\Diamond !A)$,\n  but $\\Log{K5} \\Proves/  !A \\lif \\Diamond\n  !A$. \\emph{Cheat}: for half the credit, use completeness of\n  \\Log{K5} with respect to euclidean models to show that\n  $\\Log{K5} \\Proves \\Box(!A \\lif \\Diamond !A)$.\n\\end{problem}\n\n\\begin{problem} [10 points]\n  Is the rule $(c)$ above admissible in $\\Log{KB}$? in $\\Log{K5}$?\n\\end{problem}\n\n\n\\begin{problem} [10 points]\n  We know from Problem 1 that all derivable rules are admissible. Show\n  that the converse is not true.\n\\end{problem}\n\n\n\\section{Problem set 3: $p$-morphisms}\n\\setcounter{problem}{0}\n\n\n\\begin{definition}\n  A frame is \\emph{irreflexive} if for any world $w$ in the frame\n  it's \\emph{not} the case that $R(w,w)$, i.e., no world is accessible\n  from itself. \n\\end{definition}\n\n\\begin{definition}\n  Given two frames ${F} = ({W}, R)$ and ${G} =\n  ({X}, S)$, a $p$-morphism of the first onto the second is a\n  function $\\pi : {W} \\lif {X}$ such that:\n  \\begin{itemize}\n  \\item $\\pi$ is surjective;\n  \\item if $R(u,v)$ then $S(\\pi(u),\\pi(v))$;\n  \\item if $S(\\pi(u),w)$ then there is a $v \\in {W}$ such\n    that $\\pi(v)=w$ and $R(u,v)$.\n  \\end{itemize}\n  Given two models ${M} = ({W}, R, U)$ and ${N} =\n  ({X}, S, V)$, a $p$-morphism of the first onto the second is\n  a $p$-morphism $\\pi$ of the corresponding frames satisfying the\n  additional condition that for all $w\\in {W}$ and propositional\n  variable $p$: $w \\in U(p)$ if and only if $\\pi(w) \\in V(p)$.\n  \n\n\\end{definition}\n\n\\begin{problem} [10 points]\\ollabel{problem:frames}\n  Show that there is a $p$-morphism between the following two frames\n  ${F}$ and ${G}$, where ${W} = \\{w_1, w_2,\n  w_3, w_4\\}$ and ${X} = \\{u_1, u_2 \\}$ and $R$ and $S$ are as\n  depicted:\n\n\\begin{center}\n  \\begin{tikzpicture}[node distance=2cm, auto, thick]\n    \\node (w1) {$\\bullet$};  %edge [in=55,out=125,loop] (); \n    \\node (w2) [below of=w1] {$\\bullet$}; \n    \\node (w3) [right of=w2] {$\\bullet$} ;\n%    \\node (fake) [right of=w3] {};\n    \\node (fake) at (4,-1) {};\n    \\draw[->] (w2) to node {} (w1); \n    \\node (w4) [below of=w3] {$\\bullet$} ; %edge [in=305,out=235,loop] ();\n     \\draw[->] (w3) to node {} (w4);\n     \\draw[->, bend left] (w3) to node {} (w2) ;\n     \\draw[->, bend left] (w2) to node {} (w3) ;\n%    \\draw[->, bend right] (w3) to node (w2); \n     \\path node at ( 0.4,0) {$w_1$}; \n     \\path node at ( -0.4,-2) {$w_2$}; \n     \\path node at ( 2.4,-2) {$w_3$}; \n     \\path node at ( 1.6,-4) {$w_4$};\n\n     \\draw [rounded corners] (-1,1) -- (-1,-5) -- (3,-5) -- (3,1) --  cycle;\n\n     \\path node at (2,0.5) {${F}$};\n\n% \\path node at ( 0,-1) [shape=circle,draw] {};\n% \\node [circle,draw] {a} edge [in=30,out=60,loop] ();\n\n%     \\node (u1) [right of=fake] {$\\bullet$} edge [in=55,out=125,loop]\n%     ();\n     \\node (u1) [right of=fake] {$\\bullet$} edge [in=55,out=125,loop] ();\n     \\node (u2) [below of=u1] {$\\bullet$} ;% edge [in=305,out=235,loop] ();\n     \\draw[->] (u1) to node {} (u2) ;\n     \\path node at (6.4,-1) {$u_1$};\n     \\path node at (6.4,-3) {$u_2$}  ;\n\n     \\draw [rounded corners] (4,-5) -- ++(4,0)  -- ++(0,6) -- ++(-4,0) --  cycle;\n\n     \\path node at (7,0.5) {${G}$};\n\n  \\end{tikzpicture}\n\\end{center}\n\\end{problem}\n\n\\begin{problem}  [15 points]\n  Let the frames ${F}$ and ${G}$ be like in Problem\n\\olref{problem:frames}, and assume that the language only comprises\npropositional variable $p_1, p_2, p_3$ for simplicity.\n\\begin{enumerate}\n\\item find valuations $U : \\{p_1,p_2,p_3\\} \\to \\Pow{W}$ and $V :\n\\{p_1,p_2,p_3\\} \\to \\Pow{X}$ such that there is a $p$-morphism\nbetween the models ${M} = ({W}, R, U)$ and ${N} = ({X}, S, V)$.\n\\item Are there valuations $U$ and $V$ such that the corresponding\n  models are not $p$-morphic?\n\\end{enumerate}\n\\end{problem}\n\n\n\\begin{problem}  [15 points]\n  Let $\\pi$ be a $p$-morphism between models ${M} =\n  ({W}, R, U)$ and ${N} = ({X}, S, V)$. Show that\n  for any !!{formula} $!A$ and world $w \\in {W}$, \n  \\[\n  \\mSat{M}{!A}[w] \\text{ if and only if }\n  \\mSat{N}{!A}[\\pi(w)].\n  \\]\n\\end{problem}\n\n\\begin{problem}  [15 points]\\ollabel{problem:AE}\n  Show that for any model ${N}$ on ${G}$ there is a model ${M}$ on\n  ${F}$ and a $p$-morphism $\\pi$ from ${M}$ onto ${N}$.\n\\end{problem}\n\n\\begin{problem} [10 points]\n  Show that the converse to Problem \\olref{problem:AE} does not hold,\n    i.e., that there is a model on ${F}$ that is not\n    $p$-morphic to any model on ${G}$.\n\\end{problem}\n\n\\begin{problem} [10 points]\\ollabel{problem:valid}\n  Show that if !!a{formula} $!A$ is valid on $\\mModel{F}$ then it is\n  valid on $\\mModel{G}$.\\footnote{Warning. This requires showing that\n    if $!A$ is true in any model on $\\mModel{F}$ then it is true\n    in any model on $\\mModel{G}$. Use Problem \\olref{problem:AE}.}\n\\end{problem}\n\n\\begin{problem} [10 points]\n  Show that the converse of Problem \\olref{problem:valid} does not hold,\n  i.e., that there is !!a{formula} $!A$ that is valid on $\\mModel{G}$ but\n  not on $\\mModel{F}$.\\footnote{Hint. Consider !!a{formula} that says: `At any\n    non-terminal world: if $!A$ is true and also true at any\n    accessible terminal world, then $!A$ is necessary.'\n%    $\\lnot \\Box\\lfalse \\lif \\left[(!A \\land \\Box(\\Box\\lfalse \\to\n%      !A)) \\lif \\Box!A]$\n}\n\\end{problem}\n\n\n\n\\begin{problem}  [15 points]\n  The schema $T$, i.e., $\\Box!A \\lif !A$ is valid in a frame\n  if and only if the frame is reflexive. Is there a schema that is\n  valid in a frame if and only if the frame is \\emph{irreflexive}?\n\\end{problem}\n\n\n\n\n\n\n\n\\section{Problem set 4: pebble games over Kripke frames}\n\\setcounter{problem}{0}\n\n\n\n\\begin{definition}[Two-pebble games on Kripke structures]\n  Given two Kripke models ${M} = \\tuple{W, R, U}$ and ${N} = \\tuple{X,\n    S, V}$ and worlds $u \\in W$ and $v \\in X$, the \\emph{two-pebble\n    game} $G({M}, u : {N}, v)$ between Abelard (``Abe the Spoiler'')\n  and Elo\\\"ise (``Elly the Defender'') is defined as follows.\n\n  Abelard and Elo\\\"ise share two pebbles, which at the beginning of\n  the game are placed on the worlds $u$ and $v$.  A \\emph{round} in\n  the game begins with Abelard's sliding one of the pebbles along the\n  accessibility relation ($R$ in ${M}$ or $S$ in ${N}$).  Elo\\\"ise\n  likewise responds by sliding the other pebble along $S$ or $R$,\n  respectively. In this way, two worlds $u'$ and $v'$ are identified\n  such that $Ruu'$ and $Svv'$. If neither player wins the game at this\n  round (as explained below), then both players advance and play a\n  round of the game $G({M}, u' : {N}, v')$. Suppose the pebbles are on\n  worlds $u \\in W$ and $v\\in X$; this configuration is assessed as a\n  \\emph{win} in the game $G({M}, u : {N}, v)$ for one or the other\n  players based on whether the following conditions hold:\n  \\begin{enumerate}\n  \\item If there is an atomic sentence $p$ true at $u$ and false at\n    $v$, or vice-versa, it's an automatic win for Abelard.\n    \\item If the worlds $u$ and $v$ are both terminal, it's an\n      automatic win for Elo\\\"ise.\n  \\item If at any point Elo\\\"ise cannot slide her pebble to match\n    Abelard's move, he wins.\n  \\item If the game goes on forever, that counts as a win for\n    Elo\\\"ise. \n  \\end{enumerate}\n\\end{definition}\n \n \\begin{definition}\n   A \\emph{strategy} for either player in the game $G({M}, u :\n   {N}, v)$ is just a function prescribing a response to each\n   possible move of the other player. A \\emph{winning strategy} is\n   strategy that guarantees a win for the player following it.\n \\end{definition}\n\n\\begin{problem}\n  Show that if Abelard does \\emph{not} have a winning strategy in the game\n  $G({M}, u : {N}, v)$ then for any modal !!{formula}\n  $!A$ we have $\\mSat{M}{!A}[u]$ if and only if\n  $\\mSat{N}{!A}[v]$. \n\\end{problem}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "b067f465d1b3faf6070f32f2d25f8549cbdcb115", "size": 22074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/normal-modal-logic/filtrations/meta.tex", "max_stars_repo_name": "dcelkind/Open-Logic-Project", "max_stars_repo_head_hexsha": "4dadf83769f70463cb4ec03232229a0baf847cf4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-05-17T00:08:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T01:35:02.000Z", "max_issues_repo_path": "content/normal-modal-logic/filtrations/meta.tex", "max_issues_repo_name": "dcelkind/Open-Logic-Project", "max_issues_repo_head_hexsha": "4dadf83769f70463cb4ec03232229a0baf847cf4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/normal-modal-logic/filtrations/meta.tex", "max_forks_repo_name": "dcelkind/Open-Logic-Project", "max_forks_repo_head_hexsha": "4dadf83769f70463cb4ec03232229a0baf847cf4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5235602094, "max_line_length": 120, "alphanum_fraction": 0.6111262118, "num_tokens": 8291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.42026250363295187}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{exercises}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% --------------------------------------------------------------------------------------------\n\\section*{Exercise 4.4 Reformatting simple expressions}\n\n\\begin{cadabra}\n\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   \\nabla{#}::Derivative.\n\n   def reformat (obj,scale):\n\n       {x^{a},A_{a b},B_{a b},C_{a b},g^{a b}}::SortOrder.  # choose a sort order\n\n       foo  = Ex(str(scale))          # create a scale factor\n       bah := @(foo) @(obj).          # apply the scale factor, clears all fractions\n\n       distribute     (bah)           # only required if (bah) contains brackets\n       sort_product   (bah)\n       rename_dummies (bah)\n       canonicalise   (bah)\n       factor_out     (bah,$x^{a?}$)\n\n       ans := @(bah) / @(foo).        # undo previous scaling\n\n       return ans\n\n   # ---------------------------------------------------------------\n\n   # a messy unformatted expression\n\n   expr := + (1/3) A_{a b} x^{a} x^{b}\n           + (1/9) B_{e c} x^{c} x^{e}\n           - (1/5) C_{p c} B_{d q} g^{c d} x^{p} x^{q}.  # cdb (ex-0404.100,expr)\n\n   # reformat terms and tidy fractions\n\n   expr = reformat (expr,45)                             # cdb(ex-0404.101,expr)\n\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\Dmath*{ g = \\Cdb*[\\V{15pt}\\hfill]{ex-0404.100}\n              = \\Cdb*{ex-0404.101} }\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "d2181979a582f967cbcf1ac37ef3050fc00ee9d6", "size": 1493, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/exercises/ex-0404.tex", "max_stars_repo_name": "leo-brewin/cadabra-tutorial", "max_stars_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2019-12-20T07:49:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T22:55:47.000Z", "max_issues_repo_path": "source/cadabra/exercises/ex-0404.tex", "max_issues_repo_name": "leo-brewin/cadabra-tutorial", "max_issues_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/exercises/ex-0404.tex", "max_forks_repo_name": "leo-brewin/cadabra-tutorial", "max_forks_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-22T13:52:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-22T13:52:19.000Z", "avg_line_length": 26.6607142857, "max_line_length": 94, "alphanum_fraction": 0.4909578031, "num_tokens": 461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4202624805159372}}
{"text": "\\section {Foundations of dataflow analysis}\n\\setlength{\\parindent}{0pt}\n(Prepared by Vardhan Jain)\n\n\\vspace{0.3cm}\n\n\\subsection{Advantages of common Dataflow Analysis framework}\n\\begin{itemize}\n    \\item \\textbf{Prove properties for an entire family of problems} : We prove properties for the framework\n    and basically we have proven properties for different dataflow analysis problems together.\n    \\item \\textbf{Aids in software engineering} : We can write the basic logic in a base class and all our data \n    flow analysis algorithms can be derived from that base class. We won't have to repeat the same logic.\n\\end{itemize}\n\n\\subsection{Dataflow Analysis problems \\textbf{($F$, $V$, \\^{})} are defined by}\n\\begin{itemize}\n    \\item \\textbf{A semilattice ($V$, \\^{})} : Semilattice is defined by the domain of values represented by $V$ and\n    the meet operator \\^{} represented by the caret symbol.\n    \\item \\textbf{A family of transfer functions $F:V\\rightarrow V$} : A transfer function is defined as a function that takes value \n    from the set of values $V$ and returns value in the same set of values $V$. $F$ represents family of all such possible functions.\n    They need to satisfy certain properties in order to be admissible.\n\\end{itemize}\n\\subsection{Semilattice}\nA semilattice S = \\textless a set of values $V$, a meet operator \\^{} where the meet operator \\^{} \\textgreater  has the following properties:\n\\begin{itemize}\n    \\item \\textbf{Idempotent} x \\^{} x = x\n    \\item \\textbf{Commutative} x \\^{} y = y \\^{} x\n    \\item \\textbf{Associative}  x \\^{} (y \\^{} z) = (x \\^{} y) \\^{} z\n\\end{itemize}\nExamples of meet operator \\^{} - set-union, set-intersection, and, or, min, max \\\\\nSome non-examples of meet operator are add, subtract, multiply, divide etc.\n\n\\subsection{Semilattice examples}\nV = \\{x {\\textbar} x is the subset of \\{$d_{1}$, $d_{2}$, $d_{3}$\\}\\}, \\^{} $\\triangleq$ set-union, \nOrdering $\\leq$ $\\triangleq$ $\\supseteq$. Figure \\ref{fig:semilattice_union} shows the semilattice diagram, the nodes represent the values and the edge represent the ordering. If there is an edge from a to b then a $\\geq$ b. More precisely there is a path from node a to node b iff a $\\geq$ b. This is a partial ordering as not all values are comparable. Meet of two values $v_{1}$ and $v_{2}$ can be inferred from the semilattice diagram as the first common descendant node of nodes with values $v_{1}$ and $v_{2}$.\\par\nAnother example contains values as 2-tuples booleans. The four possible values are \\{true, true\\}, \\{false, true\\}, \\{true, false\\} and \\{false, false\\}. The semilattice diagram is shown in figure \\ref{fig:semilattice_and}. Here \\^{} is logical AND.\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=1\\linewidth]{images/semilatticeSetUnion.png}\n    \\caption{Set union semilattice example}\n    \\label{fig:semilattice_union}\n\\end{figure}\n\\begin{figure}[h!]\n\\caption{Boolean tuples logical AND semilattice example}\n\\begin{center}\n\\begin{tikzpicture}[-latex ,auto ,node distance =3.5cm and 5cm ,on grid ,\n    semithick ,\n    state/.style ={ rectangle ,top color =white , bottom color = blue!20 ,\n    draw, blue , text=blue , scale = 0.7 ,minimum width =3.5 cm, minimum height = 1.5 cm}]\n    \\node[state] (A){} node [label = {}, rectangle split,rectangle split parts=2]{%\n      \\{true, true\\}%\n      };\n    \\node[state] (B) [below left = of A]{} node [label = {},rectangle split,rectangle split parts=2] [below left = of A] {%\n      \\{false, true\\}%\n      };\n    \\node[state] (D) [below right =of A]{} node [label = {},rectangle split,rectangle split parts=2] [below right = of A] {%\n      \\{true, false\\}%\n      };\n    \\node[state] (E) [below left =of D]{} node [label = {},rectangle split,rectangle split parts=2] [below left = of D] {%\n      \\{false, false\\}%\n      };\n    \\path[->] (A) edge node [above = 0.3 cm] {} (D);\n    \\path[->] (A) edge node [above = 0.3 cm] {} (B);\n    \\path[->] (B) edge  (E);\n    \\path[->] (D) edge  (E);\n    \n\\end{tikzpicture}\n\\end{center}\n\\label{fig:semilattice_and}\n\\end{figure}\n\n\\subsection{Semilattice properties}\n\\begin{itemize}\n    \\item x \\^{} y is the first common descendant of x and y.\n    \\item Define top value T such that x \\^{} T = x for all x\n    \\item Define bottom ($\\bot$) such that x \\^{} $\\bot$ = $\\bot$ for all x\n    \\item Semilattice diagram = picture of partial orders\n    \n\\end{itemize}\n\n\n\n% \\subsection{Example of \\^{} and $\\leq$}\n% Set-union", "meta": {"hexsha": "7f347fdb64cfd67b4bf7ce865bc7990534de46ad", "size": 4438, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "module95.tex", "max_stars_repo_name": "arpit-saxena/compiler-notes", "max_stars_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "module95.tex", "max_issues_repo_name": "arpit-saxena/compiler-notes", "max_issues_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module95.tex", "max_forks_repo_name": "arpit-saxena/compiler-notes", "max_forks_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-02-16T08:32:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-12T19:11:33.000Z", "avg_line_length": 52.8333333333, "max_line_length": 520, "alphanum_fraction": 0.6755295178, "num_tokens": 1337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.4202173876200335}}
{"text": "\\section{Exercise}  %Jonathan / b-j8518 /Jul 19\n\\subsection{Problem 6 (Homework 3)} \nFor $\\phi \\in {\\rm DNN}_l$, $\\phi$ is a continuous and piecewise linear function. $\\mathbb{R}^d = \\bigcup_i \\bar{D}_i$, $D_i$ is a polyhedron. $\\phi$ is linear on $D_i$. Plot some of these functions for $d=2$.\n\nA neural network with ReLU activation functions produces a piecewise linear functions:\n$NN(x,\\theta)$ is piecewise in $x$.\nWhy is this a piecewise linear function? \n\\begin{equation}\\label{eq:DNN}\nNN(x,\\theta) = W_l \\sigma (\\cdots W_3 \\sigma(W_2 \\sigma (W_1 x+b_1) +b_2)+b_3 \\cdots)+b_l\n\\end{equation}\nNotice that\n\\begin{itemize}\n\\item linear map is piecewise linear,\n\\item and ReLU function is piecewise linear.\n\\item Composition of piecewise linear functions are piecewise linear. (Not trivial)\n\\end{itemize}\nYou should convince you self the third result is true. Being piecewise linear is the same thing that Hessian is zero or almost everywhere. \nThe whole point of this exercise is to study the piecewise linear functions which are results from neural network process \\eqref{eq:DNN}. \n\nFor example, Consider the grid as follows.\n\\begin{figure} [H]%\\label{mugrid-bi}\n\\begin{center}\n\\setlength{\\unitlength}{0.445mm}\n\\begin{picture}(40,40)(40,0)\n\\linethickness{0.1mm}\n\\multiput(0,40)(15,0){3}{\\line(0,-1){30}}\n\\multiput(0,10)(0,15){3}{\\line(1,0){30}}\n\\put(0,10){\\line(1,1){30}}\n\\put(15,10){\\line(1,1){15}}\n\\put(0,25){\\line(1,1){15}}\n\\end{picture}\n\\end{center}\n\\end{figure}\nAnd consider functions that piecewise linear on each triangles.\nIn finite element, we consider piecewise linear functions which are linear on a `nice' set of polygon that tile the plane. \nNow we show how to implement it. There is a network we will plot.\n\\begin{python}\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Variable\nimport matplotlib as plt\n\nimport numpy as np\n\n\nclass TestNet(nn.Module):\n\tdef __init__(self):\n\t\tsuper(TestNet, self):__init__()\n\t\tself.function = nn.Sequential(nn.Linear(2, 25), nn.ReLU(), nn.Linear(25, 25), nn.ReLU(), nn.Linear(25, 1))\n\tdef forward(self, x):\n\t\treturn self.finction(x)\n\t\t\ndef main():\n\tnet = TestNet()\n\tdy = 0.05\n\tdx = 0.05\n\tsize = 400\n\tdf_x = torch.zeros(size, size)\n\tdf_y = torch.zeros(size, size)\n\tfor i in range(size):\n\t\tfor i in range(size)\n\t\t\tq = Variable(torch.Tensor([-1 + (i + 0.5) * dx, -1 + (j + 0.5) * dy]), requires_grad=True)\n\t\t\toutput = net(q)\n\t\t\tdf = torch.autograd.grad(output, q)\n\t\t\tdf_x[i, j] = df[0][0]\n\t\t\tdf_y[i, j] = df[0][1]\n\t\tdf_x = (df_x - torch.min(df_x)) / (torch.max(df_x) - torch.min(df_x))\n\t\tdf_y = (df_y - torch.min(df_y)) / (torch.max(df_y) - torch.min(df_y))\n\t\tdf_color = torch.zeros(size, size, 3)\n\t\tdf_color[:, :, 0] = df_x\n\t\tdf_color[:, :, 1] = df_y\n\t\tplt.imshow(df_color)\n\t\tlocs._labels = plt.xticks()\n\t\tlocs = locs[1:]\n\t\tnew_labels = []\n\t\tfor i in locs:\n\t\t\tnew_labels.append(-1.0 + i * dx)\n\t\tplt.xticks(locs, new_labels)\n\t\tplt.yticks(locs, new_labels)\n\t\tplt.show()\n\\end{python}\n\n\\subsection{Tips for Final Project} %Jonathan / b-j8526 /Jul \nIn this section, we will introduce some tools that might be used in the final project. PyTorch has a library here call \\emph{torchvision.models}. PyTorch also implement all of the model in the list for you, so you don't need to build it yourselves.\n\\begin{itemize}\n\\item AlexNet\n\\item VGG\n\\item ResNet\n\\item SqueezeNet\n\\item DenseNet\n\\item Inception v3\n\\item GoogLeNet\n\\item ShuffleNet v2\n\\item MobileNet v2\n\\item ResNeXt\n\\item Wide ResNet\n\\item MNASNet\n\\end{itemize}\nHowever, all of the models implemented here are built for ImageNet, which is a dataset consisting much bigger images than CIFAR10. \n\nFor example, if we look at one of the models, the VGG16 model. You can create a model:\n\\begin{python}\nimport torchvision.models as models\nmodel = models.vgg16()\n\\end{python}\nYou can use \\emph{print(model)} to see the list of the layers implemented.\n\\begin{figure}\n\\begin{center}\n\\includegraphics[scale=0.5]{../figures/497Proj_vgg16}\n\\end{center}\n\\end{figure}\nYou may notice that this is pretty deep, and there is a lot of max pooling layers. Each of max pooling step will decrease the size of the image by factor 2. If you plug in the CIFAR10\nimage which is $32\\times 32$, then after a couple of these max pooling, it will be a single pixel. So the point is the model is too deep for CIFAR10. Because this model is implemented for ImageNet and too big, you can just take the model and implement it. But it's better to use this model as a template for VGG and make it smaller for CIFAR10. Use fewer channels in each convolution and use fewer layers.\n\nThe other model is the ResNet model. We can print the list of the layers in ResNet in the same way. \nThis is a bit more complicated and also written for ImageNet. You should reduce number of channels and number of layers, and keep the same structure.\n\n\n\n", "meta": {"hexsha": "c3edb0fefe68d334ba5d3254cd39bf10b7f759b5", "size": 4810, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6DL/497Proj_exercise.tex", "max_stars_repo_name": "liuzhengqi1996/math452", "max_stars_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "6DL/497Proj_exercise.tex", "max_issues_repo_name": "liuzhengqi1996/math452", "max_issues_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6DL/497Proj_exercise.tex", "max_forks_repo_name": "liuzhengqi1996/math452", "max_forks_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0833333333, "max_line_length": 405, "alphanum_fraction": 0.7245322245, "num_tokens": 1454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.420211959322791}}
{"text": "% !TEX root = ../00_thesis.tex\n\n%-------------------------------------------------------------------------------\n\\section{Appendix -- Worst-case Latency Analysis}\n\\label{append:drp_WCanalysis}\n%-------------------------------------------------------------------------------\n\n%\\subsubsection{Worst-case analysis of the source delay}\n\\fakepar{Worst-case analysis of the source delay}\n\\begin{definition}[Source delay -- $\\delta_{source}$]\nThe source delay is the elapsed time from\na packet being written in \\bolt by the source \\apsrc\nuntil\nthe end of the \\opflush operation where it is read out of \\bolt by the source \\cpsrc.\nFor a flow \\flowi, it is denoted by $\\delta_{source, \\,i}$.\n\\end{definition}\n\n\\begin{lemma}\\label{lem:delta_source}\nFor any flow \\flowi, the source delay is upper-bounded by\n\\begin{equation}\n\\label{eq:delta_source}\n\\delta_{source, \\,i} \\; \\leq \\; C_w + T_f^s + C_f\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}%\nLet us recall that a \\opflush is a sequence of \\opread operations. When the \\bolt queue is found empty, the \\opflush is terminated and no other \\opread is performed until the next \\opflush (refer to \\ref{subsec:boltAPI} for details).\nTherefore, if the \\bolt queue is empty and a \\opwrite operation terminates just after a \\opflush is triggered, that \\opflush immediately terminates and the packet is delayed until to the end of the next \\opflush.\nPossible jitter on the \\opwrite operation pattern does not have any influence on the worst-case for $\\delta_{source, \\,i}$.\nThis worst-case scenario for the source delay is illustrated on Fig.~\\ref{fig:delta_source_time_graph}. \\\n\\end{proof}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=1]{delta_source_time_graph}\n\\caption{Worst-case analysis of the source delay.\n\\capt{A packet is written as early as possible such that it misses a \\opflush and must wait until the next one.}}\n\\label{fig:delta_source_time_graph}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%======================\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\fakepar{Worst-case analysis of the network delay}\n\\begin{definition}[Network delay -- $\\delta_{network}$]\nThe network delay is the elapsed time from\na packet being available for communication at the source \\cpsrc\nuntil\nthe end of the communication round where it is served by the wireless protocol (i.e., when it is available at the destination \\cpdst).\nFor a flow \\flowi, it is denoted by $\\delta_{network, \\,i}$.\n\\end{definition}\n\n\\begin{lemma}\\label{lem:delta_network}\nFor any flow \\flowi, the network delay is upper-bounded by\n\\begin{equation}\n\\label{eq:delta_network}\n\\delta_{network, \\,i} \\; \\leq \\; T_i + D_i + \\floor*{\\frac{\\jitteri + C_f - C_r}{T_f^s}}\\cdot T_f^s\n\\end{equation}\n\\end{lemma}\n\\begin{proof}%\nAs presented in \\cref{subsec:details_blink}, \\blink guarantees that every packet matching the \\emph{expected arrival} is served in a round that terminates before the network deadline $D_i$; \\ie the \\emph{delay of an expected packet} is no more than $D_i$.\n\nHowever, the actual arrival of packets at the source \\cpsrc does not match the expected arrival in general, but results from \\opflush operations, which occur every $T_f^s$ time unit.\nHence, a packet may arrive \\emph{earlier} than the next expected packet. That mismatch between the two arrival times (actual and expected) adds up with the delay of the expected packet (i.e., $D_i$).\n\nLet us consider first that the flow \\flowi has no jitter (\\ie $\\jitteri =0$) and let $m$ be the mismatch between actual and expected arrival time at \\cpsrc. $m$ cannot be larger than the flow's minimum message interval $\\periodi$\n\\[\nm \\;\\leq\\; \\periodi\n\\]\nThe intuition is given with \\cref{fig:delta_network_time_graph1}. See the caption for details.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=1]{delta_network_time_graph1}\n\\caption{Worst-case analysis of the network delay without jitter.\n\\capt{Because of the \\bolt queue being empty, packet \\textbf{A} misses the first flush operation (similarly as in \\cref{fig:delta_source_time_graph}), hence the slot allocated to \\flowi in round \\textbf{1} is wasted. Due to packets released from other flows in the meantime, packet \\textbf{B} is flushed directly in the operation preceding round \\textbf{3}, in which flow \\flowi is allocated a new slot. However, as packet \\textbf{A} is still in queue, packet \\textbf{B} is not served right away but is delayed until the next allocated slot (\\ie in round \\textbf{6}). This creates a mismatch of \\periodi for packet \\textbf{B}.\nFurthermore, the mismatch cannot get bigger; assume \\textbf{B} were to be available at \\cpsrc earlier (\\ie one flush operation before, at least), because the time interval between \\textbf{A} and \\textbf{B} must be at least \\periodi, \\textbf{A} would arrive earlier as well.\nHence, \\textbf{A} would not miss the slot in round \\textbf{1}, \\textbf{B} would be served in round \\textbf{3},\nand thus it would yield a smaller mismatch for packet \\textbf{B}.}}\n\\label{fig:delta_network_time_graph1}\n\\end{figure}\n\n\nNow, if flow \\flowi has also jitter \\jitteri, this may entail a bigger mismatch. Actual \"arrival\" of packets (\\ie the epoch when a packet is available for communication at the source \\cpsrc, according to the definition of the network delay) can occur only every $T_f^s$ (\\ie at the end of one \\opflush operation). Therefore, one can see that jitter may induce an extra delay, or mismatch, of roughly $\\floor*{\\jitteri/T_f^s}\\cdot T_f^s$. A more precise analysis of the flushing dynamics (see \\cref{fig:delta_network_time_graph2} for details) entails that, overall, the worst-case mismatch $m$ is bounded by\n\n\\begin{align}\n\\label{eq:mismatch}\nm \\; \\leq \\;\\; &\n\tT_i + \\floor*{\\frac{\\jitteri + C_f - C_r}{T_f^s}}\\cdot T_f^s\\\\\n\\intertext{and finally,}\n\\notag\n\\delta_{network, \\,i} \\; \\leq \\;\\; &\n\tD_i + m \\\\\n\\notag\n\\delta_{network, \\,i} \\; \\leq \\;\\; &\n\tT_i + D_i + \\floor*{\\frac{\\jitteri + C_f - C_r}{T_f^s}}\\cdot T_f^s \\quad \\\n\\end{align}\n\\end{proof}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=1]{delta_network_time_graph2}\n\n\\caption{Influence of jitter on the network delay.\n\\capt{Let us have a closer look at packet \\textbf{B} from the previous figure, positioned as early as possible (\\ie if it were earlier, so would be \\textbf{A}, which would then not miss its slot in round \\textbf{1}).\nDue to jitter, \\textbf{B} is released earlier, say by a amount $j$. This can yield packet \\textbf{B'} (\\textbf{B} with jitter) to be read out in a previous \\opflush operation. In the worst-case, packet \\textbf{B'} is read out one operation earlier as soon as $j$ is bigger than $T_f^s - C_f + C_r$, which increases the mismatch $m$ by $T_f^s$. Similarly, $m$ increases by $k \\cdot T_f^s$ when $j$ reached  $k \\cdot T_f^s - C_f + C_r$, which yields $k = \\floor*{\\frac{j + C_f - C_r}{T_f^s}}$ and concludes to equation \\eqref{eq:mismatch}.\n}}\n\\label{fig:delta_network_time_graph2}\n\\end{figure}\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%======================\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\fakepar{Worst-case analysis of the destination delay}\n\n\\begin{definition}[Destination delay -- $\\delta_{dest}$]\nThe destination delay is the elapsed time from\na packet being available at the destination \\cpdst\nuntil\nthe end of the \\opflush operation where it is read out of \\bolt by the destination \\apdst (i.e., when it is available for the application).\nFor a flow \\flowi, it is denoted by $\\delta_{dest, \\,i}$.\n\\end{definition}\n\n\n\\newpage\n\\noindent\n\n\\begin{lemma}\\label{lem:delta_destination}\nFor any flow \\flowi, the destination delay is upper-bounded by\n\\begin{equation}\n\\label{eq:delta_destination}\n\\delta_{dest, \\,i} \\; \\leq \\; \\nslotsmax*C_w - (\\nslotsmax-1)* C_r + T_f^d + C_f\n\\end{equation}\n\\end{lemma}\n\n\\begin{proof}\nThe situation is similar as for the source delay, except\nthat \\cpdst writes every $T_{net}$ time unit (\\ie after each round) all the packets it received during the last round, which can be as many as \\nslotsmax packets.\n%\\cp writes packets to \\bolt sequentially after each communication rounds, where they stay until they are flushed out by AP.\nThe maximal delay for a packet occurs when it is written too late to be read out during an ongoing \\opflush and must wait for the next one.\n\nA careful analysis of the \\bolt dynamics shows that the \\opread operation is slightly shorter than \\opwrite \\cite{sutton2015Bolt} (i.e., $C_r < C_w$, see Table \\ref{table:simulation_parameters}). Hence, the more packets are written at once by \\cpdst, the later a \\opflush can start and still miss the last written packet. The worst-case is illustrated on Fig.~\\ref{fig:delta_destination_time_graph}. \\\n\\end{proof}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=1]{delta_destination_time_graph}\n\\caption{Worst-case analysis of the destination delay.\n\\capt{A packet is written as early as possible such that it misses a \\opflush and must wait until the next one.}}\n\\label{fig:delta_destination_time_graph}\n\\end{figure}\n", "meta": {"hexsha": "55bc7352d81a49c88a8c0dfe65e2945ba03de1c1", "size": 8911, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "40_DRP/appendix_analysis.tex", "max_stars_repo_name": "romain-jacob/doctoral-theis", "max_stars_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "40_DRP/appendix_analysis.tex", "max_issues_repo_name": "romain-jacob/doctoral-theis", "max_issues_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "40_DRP/appendix_analysis.tex", "max_forks_repo_name": "romain-jacob/doctoral-theis", "max_forks_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.347826087, "max_line_length": 626, "alphanum_fraction": 0.7232633823, "num_tokens": 2444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.42021195932279093}}
{"text": "\n\\section{Latent Dirichlet Allocation (LDA)}\n\nThis is a C implementation of latent Dirichlet allocation (LDA), a\nmodel of discrete data which is fully described in Blei et al. (2003)\n(http://www.cs.berkeley.edu/~blei/papers/blei03a.pdf).\n\nLDA is a hierarchical probabilistic model of documents.  Let \\alpha be\na scalar and \\beta_{1:K} be K distributions of words (called \"topics\").\nAs implemented here, a K topic LDA model assumes the following\ngenerative process of an N word document:\n\n          1. \\theta | \\alpha ~ Dirichlet(\\alpha, ..., \\alpha)\n\n          2. for each word n = {1, ..., N}:\n\n             a. Z_n | \\theta ~ Mult(\\theta)\n\n             b. W_n | z_n, \\beta ~ Mult(\\beta_{z_n})\n\nThis code implements variational inference of \\theta and z_{1:N} for a\ndocument, and estimation of the topics \\beta_{1:K} and Dirichlet\nparameter \\alpha.\n\n\n\\subsection{Data format}\n\nUnder LDA, the words of each document are assumed exchangeable.  Thus,\neach document is succinctly represented as a sparse vector of word\ncounts. The data is a file where each line is of the form:\n\n     [M] [term_1]:[count] [term_2]:[count] ...  [term_N]:[count]\n\nwhere [M] is the number of unique terms in the document, and the\n[count] associated with each term is how many times that term appeared\nin the document.  Note that [term_1] is an integer which indexes the\nterm; it is not a string.\n\n\n\n\\subsection{Configuration}\n\n\\begin{description}\n\t\\item[var max iter (integer; default: -1)]\n\tThe maximum number of iterations of coordinate ascent variational\n\tinference for a single document.  A value of -1 indicates \"full\"\n\tvariational inference, until the variational convergence\n\tcriterion is met.\n\n\t\\item[var convergence] (float; default: 1e-6)]\n\tThe convergence criteria for variational inference.  Stop if\n\t(score_old - score) / abs(score_old) is less than this value (or\n\tafter the maximum number of iterations).  Note that the score is\n\tthe lower bound on the likelihood for a particular document.\n\n\t\\item[em max iter] (integer; default: 100)]\n\tThe maximum number of iterations of variational EM.\n\n\t\\item[em convergence (float; default: 1e-4)]\n\tThe convergence criteria for varitional EM.  Stop if (score_old -\n\tscore) / abs(score_old) is less than this value (or after the\n\tmaximum number of iterations).  Note that \"score\" is the lower\n\tbound on the likelihood for the whole corpus.\n\n\t\\item[alpha (string: `fit' or `estimate'; default: estimate)]\n\tIf set to [fixed] then alpha does not change from iteration to\n\titeration.  If set to [estimate], then alpha is estimated along\n\twith the topic distributions.   \n\\end{description}\n\n\n\\subsection{Running}\n\n\\subsubsection{Topic estimation}\n\nEstimate the model by executing:\n\n     lda est [alpha] [k] [settings] [data] [random/seeded/*] [directory]\n\nThe term [random/seeded/*] > describes how the topics will be\ninitialized.  \"Random\" initializes each topic randomly; \"seeded\"\ninitializes each topic to a distribution smoothed from a randomly\nchosen document; or, you can specify a model name to load a\npre-existing model as the initial model (this is useful to continue EM\nfrom where it left off).  To change the number of initial documents\nused, edit lda-estimate.c.\n\nThe model (i.e., \\alpha and \\beta_{1:K}) and variational posterior\nDirichlet parameters will be saved in the specified directory every\nten iterations.  Additionally, there will be a log file for the\nlikelihood bound and convergence score at each iteration.  The\nalgorithm runs until that score is less than \"em_convergence\" (from\nthe settings file) or \"em_max_iter\" iterations are reached.  (To\nchange the lag between saved models, edit lda-estimate.c.)\n\nThe saved models are in two files:\n\n     <iteration>.other contains alpha.\n\n     <iteration>.beta contains the log of the topic distributions.\n     Each line is a topic; in line k, each entry is log p(w | z=k)\n\nThe variational posterior Dirichlets are in:\n\n     <iteration>.gamma\n\nThe settings file and data format are described below.\n\n\n\\subsubsection{Inference}\n\nTo perform inference on a different set of data (in the same format as\nfor estimation), execute:\n\n     lda inf [settings] [model] [data] [name]\n\nVariational inference is performed on the data using the model in\n[model].* (see above).  Two files will be created : [name].gamma are\nthe variational Dirichlet parameters for each document;\n[name].likelihood is the bound on the likelihood for each document.\n\n\n\n\\subsection{Results}\n\n\\subsubsection{Printing topics}\n\nThe Python script topics.py lets you print out the top N\nwords from each topic in a .beta file.  Usage is:\n\n     python topics.py <beta file> <vocab file> <n words>\n\n\n\\begin{lstlisting}\n#! /usr/bin/python\n\n# usage: python topics.py <beta file> <vocab file> <num words>\n#\n# <beta file> is output from the lda-c code\n# <vocab file> is a list of words, one per line\n# <num words> is the number of words to print from each topic\n\nimport sys\n\ndef print_topics(beta_file, vocab_file, nwords = 25):\n\n    # get the vocabulary\n\n    vocab = file(vocab_file, 'r').readlines()\n    # vocab = map(lambda x: x.split()[0], vocab)\n    vocab = map(lambda x: x.strip(), vocab)\n\n    # for each line in the beta file\n\n    indices = range(len(vocab))\n    topic_no = 0\n    for topic in file(beta_file, 'r'):\n        print 'topic %03d' % topic_no\n        topic = map(float, topic.split())\n        indices.sort(lambda x,y: -cmp(topic[x], topic[y]))\n        for i in range(nwords):\n            print '   %s' % vocab[indices[i]]\n        topic_no = topic_no + 1\n        print '\\n'\n\nif (__name__ == '__main__'):\n\n    if (len(sys.argv) != 4):\n       print 'usage: python topics.py <beta-file> <vocab-file> <num words>\\n'\n       sys.exit(1)\n\n    beta_file = sys.argv[1]\n    vocab_file = sys.argv[2]\n    nwords = int(sys.argv[3])\n    print_topics(beta_file, vocab_file, nwords)\n\\end{lstlisting}\n\n", "meta": {"hexsha": "848b47f7c64dd6ce1c6cf0641496a093089034de", "size": 5846, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DTM/dtm-master/doc/lda.tex", "max_stars_repo_name": "boomsbloom/dtm-fmri", "max_stars_repo_head_hexsha": "159aab87f04b745d874b53f64fd30703b4d5a70c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-11-27T01:35:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T01:17:11.000Z", "max_issues_repo_path": "DTM/dtm-master/doc/lda.tex", "max_issues_repo_name": "boomsbloom/dtm-fmri", "max_issues_repo_head_hexsha": "159aab87f04b745d874b53f64fd30703b4d5a70c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DTM/dtm-master/doc/lda.tex", "max_forks_repo_name": "boomsbloom/dtm-fmri", "max_forks_repo_head_hexsha": "159aab87f04b745d874b53f64fd30703b4d5a70c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-27T01:35:33.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-27T01:35:33.000Z", "avg_line_length": 32.8426966292, "max_line_length": 77, "alphanum_fraction": 0.7150188163, "num_tokens": 1503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4201745973850446}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{subcaption}\n\\usepackage{bm}\n\n\\usepackage{amsthm}\n\\newtheorem{defn}{Definition}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{12cm}\n\\setlength{\\figureheight}{6cm}\n\n\\newlength\\squarefigurewidth\n\\newlength\\squarefigureheight\n\n\\setlength{\\squarefigurewidth}{4cm}\n\\setlength{\\squarefigureheight}{4cm}\n\n\\newlength\\smallsquarefigurewidth\n\\newlength\\smallsquarefigureheight\n\n\\setlength{\\smallsquarefigurewidth}{3.25cm}\n\\setlength{\\smallsquarefigureheight}{3.25cm}\n\n\\newlength\\smallfigurewidth\n\\newlength\\smallfigureheight\n\n\\setlength{\\smallfigurewidth}{6.25cm}\n\\setlength{\\smallfigureheight}{4cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\trans}{^\\top}\n\\newcommand{\\mat}[1]{\\bm{\\mathrm{#1}}}\n\\renewcommand{\\vec}[1]{\\bm{\\mathrm{#1}}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\renewcommand{\\epsilon}{\\varepsilon}\n\\newcommand{\\Exp}{\\mathbb{E}}\n\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\cov}{cov}\n\\DeclareMathOperator{\\diag}{diag}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\begin{document}\n\n\\section*{Conditioning on Outputs of Linear Operators}\n\nSuppose we have a function $f\\colon \\mc{X} \\to \\R$ with a Gaussian\nprocess prior distribution:\n\\begin{equation*}\n  p(f) = \\mc{GP}(f; \\mu, K).\n\\end{equation*}\nWe have discussed how to perform inference about $f$ when given\n(noisy) observations of the function at a set of points $\\mat{X}$:\n$\\data = (\\mat{X}, \\vec{y})$.  Here we are going to expand the types\nof observations we may use during \\acro{GP} inference.\n\n\\subsection*{Functionals and linear functionals}\n\nSpecifically, we are going to consider so-called \\emph{linear\n  functionals} of $f$.  A \\emph{functional} is a function $L[f]$ that\ntakes as an input a function $f$ and returns a scalar.  (Functionals\nare sometimes called ``functions of functions.'')  A very simple\nexample of a functional is the \\emph{point-evaluation functional.}\nLet $x \\in \\mc{X}$ be an arbitrary fixed point in the domain.  We\ndefine a corresponding functional $L_x$ by\n\\begin{equation*}\n  f \\mapsto L_x[f] = f(x).\n\\end{equation*}\nSo, given a function $f$, the point-evaluation functional $L_x$ simply\nevaluates $f$ at $x$ and returns the result.  This is a functional we\nare very accustomed to using.\n\nA functional is said to be $\\emph{linear}$ when it satisfies a simple\nlinearity property.  Specifically, let $a \\in \\R$ be an arbitrary\nscalar constant and let $f$ and $g$ be two arbitrary functions.  A\nfunctional $L$ is linear if the following equality always holds:\n\\begin{equation*}\n  L[af + g] = aL[f] + L[g].\n\\end{equation*}\nIt is easy to see that the point-evaluation functional $L_x$ is\nlinear:\n\\begin{equation*}\n  L_x[af + g]\n  =\n  (af + g)(x)\n  =\n  af(x) + g(x)\n  =\n  aL_x[f] + L_x[g].\n\\end{equation*}\n\nThere are several other quite-common linear functionals that we are\nfamiliar with.  The two we will discuss here are integration against\nan arbitrary function $p(x)$:\n\\begin{equation*}\n  f \\mapsto I_p[f] = \\int_{\\mc{X}} f(x) p(x) \\intd{x},\n\\end{equation*}\nand (partial) differentiation at a point $x$:\n\\begin{equation*}\n  f \\mapsto D_{x, i}[f] = \\frac{\\partial f(z)}{\\partial z_i} \\biggr\\rvert_{z = x}.\n\\end{equation*}\n\n\\subsection*{Conditioning on linear functionals}\n\nIt turns out that we can once again exploit the closure of the\nGaussian distribution to linear transformations to condition a\n\\acro{GP} on $f$ on the observation of any linear functional of $f$!\nThis will allow us to both perform inference about $f$ given\nobservations of, for example, derivatives of $f$, and also to perform\ninference about linear functionals of $f$ directly.  This will provide\nus with a Bayesian mechanism for estimating integrals (a task\ntraditionally called \\emph{quadrature}).\n\nSuppose we have an unknown function $f\\colon \\mc{X} \\to \\R$ with the\nGaussian process prior above:\n\\begin{equation*}\n  p(f) = \\mc{GP}(f; \\mu, K),\n\\end{equation*}\nand let $L$ be a linear functional.  We will write $\\ell = L[f]$.\nJust as Gaussian distributions are closed under linear\ntransformations, so are Gaussian processes closed under the evaluation\nof linear functionals!  The prior distribution for $\\ell$ is a\nGaussian distribution:\n\\begin{equation*}\n  p(\\ell)\n  =\n  \\mc{N}\\bigl(\\ell; L[\\mu], L^2[K]\\bigr)\n\\end{equation*}\nwhere\n\\begin{equation*}\n  L^2[K]\n  =\n  L\\Bigl[L\\bigl[K(\\cdot, x')\\bigr]\\Bigr]\n  =\n  L\\Bigl[L\\bigl[K(x, \\cdot)\\bigr]\\Bigr].\n\\end{equation*}\nThis result is essentially equivalent to the result for linear\ntransformations of Gaussian-distributed vectors we have been using\nthus far, written with different notation.  Notice also that if we\nconsider the point-evaluation functional $L_x$, we recover a basic\nresult:\n\\begin{equation*}\n  p\\bigl(f(x) \\given x\\bigr)\n  =\n  \\mc{N}\\bigl(f(x); L_x[\\mu], L_x^2[K]\\bigr);\n  =\n  \\mc{N}\\bigl(f(x); \\mu(x), K(x, x)\\bigr).\n\\end{equation*}\nConsidering the integration functional, we obtain a perhaps\nmore-interesting result:\n\\begin{equation*}\n  p\\biggl(\\int f(x) p(x) \\intd{x} \\biggr)\n  =\n  \\mc{N}\\biggl(\\int f(x) p(x) \\intd{x}; \\int \\mu(x) p(x) \\intd{x}, \\iint K(x, x') p(x) p(x') \\intd{x} \\intd{x'} \\biggr).\n\\end{equation*}\nTherefore a Gaussian process distribution on $f$ implies a Gaussian\ndistribution on its integral against an arbitrary function $p(x)$!\nFurther, the problem of estimating the integral of the (perhaps quite\ncomplicated) function $f$ has been reduced to the perhaps-simpler\nproblem of integrating the mean and covariance functions $\\mu$ and\n$K$.  This is the main idea behind \\emph{Bayesian quadrature,} also\ncalled \\emph{Bayesian Monte Carlo.}\n\nGiven an observation of $L[f] = \\ell$, we may condition our prior on\nthis observation in a manner equivalent to that used to derive the\nposterior distribution of $f$.  Let $\\mat{X}$ be an arbitrary set of\ninput locations.  As before, we write the joint distribution between\n$\\ell$ and $\\vec{f} = f(\\mat{X})$:\n\\begin{equation*}\n  p\\Biggl(\n  \\begin{bmatrix}\n    \\vec{f}\n    \\\\\n    \\ell\n  \\end{bmatrix}\n  \\given\n  \\vec{X}\n  \\Biggr)\n  =\n  \\mc{N}\n  \\Biggl(\n  \\begin{bmatrix}\n    \\vec{f}\n    \\\\\n    \\ell\n  \\end{bmatrix}\n  ;\n  \\begin{bmatrix}\n    \\vec{\\mu}\n    \\\\\n    L[\\mu]\n  \\end{bmatrix}\n  ,\n  \\begin{bmatrix}\n    \\mat{K} & \\text{?}\n    \\\\\n    \\text{?} & L^2[K]\n  \\end{bmatrix}\n  \\Biggr),\n\\end{equation*}\nwhere we have defined:\n\\begin{equation*}\n  \\vec{\\mu} = \\mu(\\mat{X})\n  \\qquad\n  \\mat{K} = K(\\mat{X}, \\mat{X}).\n\\end{equation*}\nTo fill in the missing observations, we need to know the covariance\nbetween $\\ell$ and the $i$th function value $f_i = f(\\vec{x}_i)$.  Here\nwe can exploit the linearity of covariance:\n\\begin{equation*}\n  \\cov(f_i, \\ell)\n  =\n  \\cov\\bigl(L_{\\vec{x}_i}[f], L[f]\\bigr)\n  =\n  L_{\\vec{x}_i}\\Bigl[L\\bigl[\n      \\cov(f, f)\n  \\bigr]\\Bigr]\n  =\n  L_{\\vec{x}_i}\\Bigl[L\\bigl[\n      K\n  \\bigr]\\Bigr]\n  =\n  L\\bigl[K(\\vec{x}_i, \\cdot)\\bigr].\n\\end{equation*}\nNow we have the general result\n\\begin{equation*}\n  p\\Biggl(\n  \\begin{bmatrix}\n    \\vec{f}\n    \\\\\n    \\ell\n  \\end{bmatrix}\n  \\given\n  \\vec{X}\n  \\Biggr)\n  =\n  \\mc{N}\n  \\Biggl(\n  \\begin{bmatrix}\n    \\vec{f}\n    \\\\\n    \\ell\n  \\end{bmatrix}\n  ;\n  \\begin{bmatrix}\n    \\vec{\\mu}\n    \\\\\n    L[\\mu]\n  \\end{bmatrix}\n  ,\n  \\begin{bmatrix}\n    \\mat{K} & L\\bigl[K(\\mat{X}, \\cdot)\\bigr]\n    \\\\\n    L\\bigl[K(\\cdot, \\mat{X})\\bigr] & L^2[K]\n  \\end{bmatrix}\n  \\Biggr).\n\\end{equation*}\nFinally, we may condition this joint distribution on the observed\nvalue $\\ell = L[f]$ to find the posterior of $\\vec{f}$, which will be\nan updated multivariate Gaussian distribution.  Because the set of\npoints $\\mat{X}$ was arbitrary, we may conclude that the posterior\ndistribution is also a Gaussian process.  The posterior mean and\ncovariance functions are\n\\begin{align*}\n  \\mu_{f \\given \\ell}(\\vec{x})\n  &=\n  \\mu(\\vec{x})\n  +\n  \\frac{L\\bigl[K(\\vec{x}, \\cdot)\\bigr]}{L^2[K]}\n  \\bigl(\\ell - L[\\mu]);\n  \\\\\n  K_{f \\given \\ell}(\\vec{x}, \\vec{x}')\n  &=\n  K(\\vec{x}, \\vec{x}')\n  -\n  \\frac{L\\bigl[K(\\vec{x}, \\cdot)\\bigr]L\\bigl[K(\\cdot, \\vec{x}')\\bigr]}{L^2[K]}.\n\\end{align*}\nWe can easily extend this result to include multiple observations of\nfunctionals and also to incorporate Gaussian noise on each of these\nobservations.\n\nAn example is shown in Figure \\ref{example}, where we condition a\nGaussian process prior on the integral observation $\\int_{0}^{10} f(x)\n\\intd{x} = 5$.  Notice that the posterior samples all have integral\nexactly equal to 5.\n\n\\begin{figure}\n  \\centering\n  \\input{figures/samples_example_1.tex}\n  \\input{figures/integral_posterior.tex}\n  \\caption{Above: a Gaussian process prior on a function $f$ with mean\n    zero and squared exponential covariance.  Below: the posterior\n    distribution on $f$ after conditioning on the obesrvation\n    $\\int_{0}^{10} f(x) \\intd{x} = 5$.  The posterior samples all have\n    integral identically equal to 5.}\n  \\label{example}\n\\end{figure}\n\n\\section*{Bayesian Quadrature}\n\nAbove, we conditioned a Gaussian process on an integral observation.\nIn \\emph{Bayesian quadrature,} we do the opposite: given (potentially\nnoisy) observations of a function $\\data = (\\mat{X}, \\vec{y})$, we\nperform inference about an integral of interest, for example the\nexpectation of $f$ under a distribution $p$:\n\\begin{equation*}\n  I_p[f] = \\int f(x) p(x) \\intd{x}.\n\\end{equation*}\nThe traditional method for estimating integrals of this form is\n\\emph{Monte Carlo} estimation, where we sample some points $\\{ x_i\n\\}_{i = 1}^N$ from the distribution $p(x)$ and estimate\n\\begin{equation*}\n  \\int f(x) p(x) \\intd{x}\n  \\approx\n  \\sum_{i = 1}^N f(x_i).\n\\end{equation*}\n\nIn Bayesian quadrature, we place a Gaussian process prior on $f$,\nwhich we condition on the observations $\\data$.  Notice that the input\nlocations $\\mat{X}$ do not need to be random samples from $p$, but\nrather we are allowed to evaluate $f$ anywhere.  The result is the posterior\n\\begin{equation*}\n  p(f \\given \\data)\n  =\n  \\mc{GP}(f; \\mu_{f \\given \\data}, K_{f \\given \\data}).\n\\end{equation*}\nFollowing the above, we may also derive the posterior distribution\nof the expectation $I_p[f]:$\n\\begin{equation*}\n  p\\bigl(I_p[f] \\given \\data \\bigr)\n  =\n  \\mc{N}\n  \\biggl(\n  I_p[f];\n  \\int \\mu_{f \\given \\data}(x) p(x) \\intd{x},\n  \\iint K_{f \\given \\data}(x, x') p(x) p(x') \\intd{x} \\intd{x'}\n  \\biggr).\n\\end{equation*}\nFor some choices of the prior prior mean and covariance functions\n$\\mu$ and $K$ and the distribution $p$, we may compute the required\nintegrals exactly, giving a closed-form expression for the posterior\ndistribution of the integral of interest.\n\nWhy is this useful?  The main advantages to this approach are that we\nmay explicitly model the structure of $f$ via the covariance function\n$K$, and that the posterior variance of the integral may be used to\nderive an active sampling scheme, revealing the most-informative\npoints to evaluate the function so as to estimate the integral with\nthe highest precision.  Note that the posterior variance of the\nintegral only depends on where we sample the function, and not the\nactual values we observe.  This property can be exploited to design\noptimal quadrature rules.\n\n\\end{document}\n", "meta": {"hexsha": "ab81caf8aaa4d07069a3516bfb6e4df3b831fe58", "size": 12301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_notes/Bayesian Quadrature/notes.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "lecture_notes/Bayesian Quadrature/notes.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "lecture_notes/Bayesian Quadrature/notes.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 30.2980295567, "max_line_length": 120, "alphanum_fraction": 0.7021380376, "num_tokens": 3937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4200715367760887}}
{"text": "Numerical solutions to problems in quantum physics are important, given the limited availability of exact solutions. Many such models and methods exist when dealing with many-body systems, and have been shown to provide good estimates of physical behaviour~\\cite{BK:Krauth_2006}. Techniques such as Monte Carlo methods, exact diagonalisation, and DMRG are used to solve a wide variety of many-body problems, but often fail to capture the full system dynamics of such problems~\\cite{NUM:Schollwock_rmp_2005}. For understanding the behaviour of systems such as Bose--Einstein condensates, the use of these methods is rather limited. For DMRG, the complexity of the problem grows quickly with increasing dimensionality and renders this technique unusable. Exact diagonalisation requires a linearised system to obtain realistic solutions, and also grows significantly in complexity with increased dimensionality. Monte Carlo methods generally do not allow for real-time dynamics, or allow one to calculate the underlying wavefunction.\n\nTo obtain solutions to BEC problems we make use of a mean-field approach, outlined previously in Sec.~\\ref{sub:gpederiv}. Using the GPE and performing a numerical integration allows for almost all examinable dynamics that are valid in the mean-field limit. It can be noted though that the computational cost increases significantly with increased dimensions, and is already non-trivial for two-dimensions. The following chapter will introduce the necessary requirements to numerically solve quantum problems using state-of-the-art computational methods.\n\nWe will begin with an introduction to the time evolution of a quantum state. We then discuss the use of the time evolution approach to find the ground state of a quantum system using imaginary time evolution. After this necessary mathematical introduction we will discuss the implementation of both real and imaginary time evolution using the Fourier split-operator (split-step) algorithm. We give error bounds for the algorithm, and discuss its use in the context of solving for Hamiltonian dynamics. Though the discussed algorithm is well suited to solving quantum dynamics, the computational cost can be quite high, especially for systems with large grid sizes.\n\nWe next discuss ways to overcome this through the use of high performance computing methods, and introduce the concept of graphical processing unit (GPU) computing. We present many of the necessary considerations for mapping a computational problem onto GPUs. Making use of GPUs to numerically solve the Schr\\\"odinger equation with the Fourier split-operator method, we present the problem of coherent atomic transport. We introduce the ``matter-wave spatial adiabatic passage'' technique, with the goal of coherently transporting an atom between trapping potentials with high fidelity. The design of the model system is presented, and the results are shown.\n\nWe finish the chapter by introducing the developed algorithms for condensate systems. Performance metrics and considerations are given in the context of solving the Gross--Pitaevskii equation in the presence of vortices.\n\n\\section{Time evolution}\\label{sec:timeev}\nGiven a quantum state, to examine the dynamics requires an understanding of how it evolves in time. Assuming a quantum state at time $t_0$ to be defined as $|\\Psi(t_0) \\rangle$, and a state at time $t$ to be $|\\Psi(t) \\rangle$, the two states can be connected with a unitary evolution operator as\n\\begin{equation}\n    |\\Psi(t) \\rangle = \\mathscr{U}(t,t_0) | \\Psi(t_0) \\rangle,\n\\end{equation}\nwhere we have assumed that $t > t_0$. One can write the wavefunction of a quantum system as the linear superposition of a set of basis states $|\\Psi_m\\rangle$ as\n\\begin{equation}\\label{eqn:psicomplete}\n    |\\Psi \\rangle = \\displaystyle\\sum\\limits_{m} C_m |\\Psi_m \\rangle,\n\\end{equation}\nwith coefficients $C_m$. The unitary evolution operator can be written as\n\\begin{align}\n   \\mathscr{U}(t,t_0) &= \\exp\\left(-\\frac{i\\mathcal{H}(t - t_0)}{\\hbar} \\right) \\\\ &= \\exp\\left(\\frac{-\\text{i}\\mathcal{H}\\delta t}{\\hbar}\\right),\n\\end{align}\n\\iffalse\n\\begin{align}\n   \\mathscr{U}(t,t_0) &= \\exp\\left(-\\frac{i}{\\hbar}\\displaystyle\\int\\limits_{t_0}^{t}\\mathcal{H}\\text{d}t\\right),\n\\end{align}\n\\fi\nwhere $\\mathcal{H}$ is the Hamiltonian of the system, and $\\delta t = t - t_0$. %For an incremental change $\\delta t$ such that $t = t_0 +\\delta t$ the above operator can be replaced by the form\n%\\begin{align}\\label{eqn:timev_dt}\n%   \\mathscr{U}(t,t_0) &= \\exp\\left(\\frac{-\\text{i}\\mathcal{H}\\delta t}{\\hbar}\\right).\n%\\end{align}\n\nThe effect of $\\mathscr{U}(t,t_0)$ on any arbitrary state can be examined by expanding it as\n\\begin{subequations}\n    \\begin{align}\n        \\mathscr{U}(t,t_0) &= 1 - \\frac{\\textrm{i}\\mathcal{H}\\delta t}{\\hbar} + \\mathcal{O}(\\delta t^2) \\\\\n        &= 1 - \\frac{\\textrm{i}\\delta t}{\\hbar}{\\displaystyle\\sum\\limits_{n} E_n |\\Psi_n\\rangle \\langle \\Psi_n |} + \\mathcal{O}(\\delta t^2),\n    \\end{align}\n\\end{subequations}\n\nwhere the Hamiltonian operator has been written as a complete set of energy eigenkets, $\\mathcal{H}|\\Psi_n\\rangle = E_n|\\Psi_n\\rangle$. Applying this to \\eqref{eqn:psicomplete} gives\n\\begin{subequations}\n    \\begin{align}\n        |\\Psi (t) \\rangle &= \\left( 1 - \\frac{\\textrm{i}\\delta t}{\\hbar}\\displaystyle\\sum\\limits_{n}E_n|\\Psi_n\\rangle\\langle \\Psi_n |  \\right)\\displaystyle\\sum\\limits_{m} C_m |\\Psi_m \\rangle \\\\\n            &= \\displaystyle\\sum\\limits_{m} C_m |\\Psi_m \\rangle + \\displaystyle\\sum\\limits_{n}\\left( - \\frac{\\textrm{i}\\delta t}{\\hbar}E_n \\right) C_n|\\Psi_n\\rangle,\n    \\end{align}\n\\end{subequations}\nwhere terms of order $\\mathcal{O}(\\delta t^2)$ and higher have been temporarily left out for notational simplicity, but are still included in the analysis. Time evolving the state from $t_0$ to a final time $t$ by applying the evolution operator can then be written as\n\\begin{equation}\n   \\mathscr{U}(t,t_0)|\\Psi(t_0) \\rangle = \\displaystyle\\sum\\limits_{n} C_n \\exp\\left(\\frac{-\\textrm{i}{E_n}\\delta t}{\\hbar}\\right)|\\Psi_n \\rangle.\n\\end{equation}\nIt follows from here that each state oscillates at a different rate, proportional to its eigenenergy; higher energy states will oscillate faster than those of lower energy. For a given set of states the dynamics and evolution of the quantum system can be fully determined for all times using the above evolution operation.\n\nAs systems will prefer to reside in the lowest energy state where they are most stable, it is often required to determine the ground state solution of a particular Hamiltonian. A common method for this is by evolving the system in imaginary time. Taking the evolution operator, and applying a Wick rotation \\cite{NUM:Bader_jcp_2013} rotates the time component through $\\pi/2$ into the imaginary plane, as $t \\rightarrow -it$. This new evolution operator applied to the wavefunction gives\n\\begin{equation}\n       \\mathscr{U^{'}}(t,t_0)|\\Psi \\rangle = \\displaystyle\\sum\\limits_{n} C_n \\exp\\left(\\frac{-{E_n}\\delta t}{\\hbar}\\right)|\\Psi_n \\rangle.\n\\end{equation}\nThis process removes the complex term in the operator, which now takes the form of sums of exponentially decaying states. When applied to the wavefunction the higher energy terms will decay at a rate faster than lower energy components increasing $\\delta t$. This process also causes a loss of probability density, and so the wavefunction must be renormalised after each application. Through repeated application of this operator, and a renormalisation afterwards, the simulated quantum system converges to the ground state solution. To begin, however, we must make an initial guess for the wavefunction, which has some finite overlap with the lowest lying state. It should be noted that this method is a mathematical trick used to obtain a simulated ground state, with a real-world system only tending to the ground state in the presence of some form of dissipation. As effective as this technique is, the convergence to the lowest lying energy state becomes less effective as the computation approaches the expected value \\cite{Vtx:Danaila_pra_2005}, and if many eigenstates are lying close to each other. To ensure the system converges to a sufficient degree the resulting energy can be checked after each iteration, and the evolution stopped only when the energy change fluctuates about a stable value.\n\nWith the time evolution method introduced, we will next discuss implementing this method. Although many such algorithms exist to implement time evolution, one that is well suited for this task is the Fourier split-operator method. This method works equally for real, as well as imaginary, time evolution.\n\n\\section{Fourier split-operator method}\\label{sec:fso}\nThe Gross--Pitaevskii equation is a second order nonlinear partial differential equation, and so very few exact solutions exist; the problem must often be tackled by a numerical approach. Though there are many ways to solve such a system numerically, with the Crank--Nicolson and Trotter--Suzuki algorithms being notable examples, the method we have chosen is the pseudospectral Fourier split-operator method, described below~\\cite{Num:Bauke_cpc_2011}.\n\nIf we consider a unitary evolution operator of the form\n\\begin{equation}\\label{eqn:1}\n\\Psi(\\mathbf{x},t+\\tau) = \\exp\\left( -\\frac{\\text{i}\\hat{H}\\tau}{\\hbar}\\right)\\Psi(\\mathbf{x},t),\n\\end{equation}\nwhere $\\hat{H}$ is the Hamiltonian, composed of momentum, potential, nonlinear interaction, and rotation terms defined in Eq. \\eqref{eqn:gpe}, we can solve for the wavefunction and its resulting dynamics over a specified timescale, assuming $\\tau$ is a short time increment such that the formalism given in Sec.~\\ref{sec:timeev} is valid. Care must be taken during the implementation of such integration methods, as the loss of precision due to floating-point rounding, as well as the propagation of errors cannot be neglected. If we take $\\hat{H}$ in terms of its components as a combination of position and momentum space operators we obtain\n\\begin{equation}\\label{eqn:2}\n\\hat{H} = \\hat{H}_{\\textbf{r}} + \\hat{H}_{\\textbf{k}} + \\hat{H}_{\\textbf{L}},\n\\end{equation}\nwhere we first ignore the angular momentum operator, $\\hat{H}_{\\textbf{L}}$, and consider only the two other non-commuting parts, $\\hat{H}_{\\textbf{r}}$, containing the operators acting in position space, and $\\hat{H}_{\\textbf{k}}$, containing the operators acting in momentum space only. The Baker--Campbell--Hausdorf formula \\cite{NUM:Weyrauch_cpc_2009} gives the relation for non-commuting operators as\n\\begin{equation}\n    \\exp\\left( \\tau(A+B) \\right) = \\exp\\left(\\tau A\\right)\\exp\\left(\\tau B\\right)\\exp\\left(-\\frac{\\tau^2}{2}[A,B] + \\cdots\\right),\n\\end{equation}\nwith $\\cdots$ representing higher order commutators. This is directly mappable to the above Hamiltonian for time evolution. Due to the non-commutativity of $\\hat{H}_{\\textbf{r}}$ and $\\hat{H}_{\\textbf{k}}$, the above expression cannot be evaluated exactly, and so it is common to Taylor expand and truncate it. The resulting error can be determined as\n\\begin{subequations}\\label{eqn:error_calc}\n\\begin{align}\n    \\text{err} = \\left\\| \\exp\\left(-\\frac{\\textrm{i}\\hat{H}_{\\textbf{k}}\\tau}{\\hbar}\\right)\\exp\\left(-\\frac{\\textrm{i}\\hat{H}_{\\textbf{r}}\\tau}{\\hbar}\\right) - \\exp\\left(-\\frac{\\textrm{i}(\\hat{H}_{\\textbf{k}} + \\hat{H}_{\\textbf{r}})\\tau}{\\hbar}\\right) \\right\\| \\\\\n    = \\left\\|  \\left(1 + \\left(\\frac{-\\textrm{i}\\hat{H}_{\\textbf{k}}}{\\hbar}\\right)\\tau + \\left(\\frac{-\\textrm{i}\\hat{H}_{\\textbf{k}}}{\\hbar}\\right)^2\\frac{\\tau^2}{2}  \\right)\\left(1 + \\left(\\frac{-\\textrm{i}\\hat{H}_{\\textbf{r}}}{\\hbar}\\right)\\tau + \\left(\\frac{-\\textrm{i}\\hat{H}_{\\textbf{r}}}{\\hbar}\\right)^2\\frac{\\tau^2}{2}  \\right) \\right. &- \\nonumber \\\\ \\left. \\left(1 + \\left(\\frac{-\\textrm{i}(\\hat{H}_{\\textbf{r}} + \\hat{H}_{\\textbf{r}})}{\\hbar}\\right)\\tau + \\left(\\frac{-\\textrm{i}(\\hat{H}_{\\textbf{r}} + \\hat{H}_{\\textbf{r}})}{\\hbar}\\right)^2\\frac{\\tau^2}{2}  \\right)  + \\mathcal{O}(\\tau^3) \\right\\|,\n\\end{align}\n\\end{subequations}\nwhich, upon simplification reduces to\n\\begin{equation}\n\\text{err} = \\left\\| \\frac{\\tau^2[{\\hat{H}_{\\textbf{r}}},{\\hat{H}_{\\textbf{k}}}]}{2\\hbar^2} + \\mathcal{O}(\\tau^3)\\right\\| = \\mathcal{O}(\\tau^2).\n\\end{equation}\n\nThe error can be further reduced through the use of 2$^{\\text{nd}}$ order Strang splitting~\\cite{NUM:Gradinaru_SIAM_2007}, taking the error in the numerical integration scheme to $\\mathcal{O}(\\tau^3)$, with the resulting operator implementation given as\n\n\\begin{equation}\\label{eqn:3}\n\\exp\\left( -\\frac{ \\textrm{i}\\left(\\hat{H}_{\\textbf{r}} + \\hat{H}_{\\textbf{k}}\\right)\\tau}{\\hbar} \\right) = \\exp\\left(- \\frac{\\textrm{i}\\hat{H}_{\\textbf{r}}\\tau}{2\\hbar} \\right)\\exp\\left(-\\frac{\\textrm{i}\\hat{H}_{\\textbf{k}}\\tau}{\\hbar}\\right)\\exp\\left( -\\frac{\\textrm{i}\\hat{H}_{\\textbf{r}}\\tau}{2\\hbar}\\right) + \\mathcal{O}\\left(\\tau^3\\right).\n\\end{equation}\nIn the case of a nonlinear system, such as for solving the GPE, the above scheme attains a second-order error, resulting from the combination of the potential and nonlinear terms, with the respective mapping as \\cite{BEC:Javanainen_jphysa_2006}\n\\begin{subequations}\n    \\begin{align}\n\\hat{H}_{\\textbf{r}} &= V(\\mathbf{r}) + g\\vert\\Psi(\\mathbf{r},t)\\vert^2, \\\\ \\hat{H}_{\\textbf{k}} &= \\frac{-\\hbar^2}{2m}\\nabla^2.\n    \\end{align}\n\\end{subequations}\n%\\hat{H}_{\\textbf{L}} = \\Omega L,\nFollowing Bauke \\textit{et al}. \\cite{Num:Bauke_cpc_2011}, we can numerically solve this differential equation as\n\\begin{equation}\\label{eqn:baukeetal}\n\\Psi\\left(\\textbf{r},t+\\tau\\right) = \\left[\\hat{U}_{\\mathbf{r}}\\left(\\frac{\\tau}{2}\\right) \\mathscr{F}^{-1} \\left[ \\hat{U}_{\\mathbf{k}}(\\tau) \\mathscr{F} \\left[ \\hat{U}_{\\mathbf{r}}\\left(\\frac{\\tau}{2}\\right) \\Psi\\left(\\mathbf{r},t\\right) \\right] \\right] \\right]  \\\\ + \\mathcal{O}\\left(\\tau^2\\right),\n\\end{equation}\nwhere $\\hat{U}_{\\mathbf{r}}(\\tau)=e^{-\\textrm{i}\\hat{H}_{\\mathbf{r}}t/\\hbar}$ is the time evolution operator in position space, $\\hat{U}_{\\mathbf{k}}(\\tau)=e^{-i\\hat{H}_{\\mathbf{k}}t/\\hbar}$ the time evolution operator in momentum space, and $\\mathscr{F}$ and $\\mathscr{F}^{-1}$ are the forward and inverse Fourier transform respectively. Taking the Fourier transform of the wavefunction allows the basis to be transformed between position and reciprocal space, wherein the time evolution operators are diagonal in each respective space. Figure~\\ref{fig:num_splitop} outlines a schematic representation of the method during a single pass of the algorithm.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[]{./ch3_numerics/splitop}\n    \\caption{A single pass through the Fourier split-operator method.}\n    \\label{fig:num_splitop}\n\\end{figure}\n\nThe underlying theory of the Fourier split-operator method for the Gross--Pitaevskii equation is given by Javanainen \\textit{et al}. \\cite{BEC:Javanainen_jphysa_2006}, showing how the choice of nonlinearity and operator splitting affects the outcome of the method. By taking the initial step as evolution in momentum space, the choice of the most current wavefunction attains an error of third-order for the algorithm. However, this will require an additional two Fourier transform steps, and as such is rather costly in compute time for large systems. For an initial step in position space, the nonlinear term is best calculated using a linear combination of all available wavefunctions through the algorithm as $\\Psi = c_0\\Psi_0 + c_1\\Psi_1 + c_2\\Psi_2$, where the subscripts denote the wavefunction at each stage of the evolution in position space, as indicated in Fig.~\\ref{fig:num_splitop}, and the $c_{\\textrm{x}}$ are linear coefficients. This gives third order accuracy for the parameters $c_2=\\pm 1, c_1=-c_0$. However, for simplicity and resource limitations we chose to work with the $\\mathcal{O}\\left(\\tau^2\\right)$ accurate scheme as depicted by Eq.~\\eqref{eqn:baukeetal}, which was sufficient for the physics we aimed to describe.\n\nAn implementation of this method is a straight-forward process using MATLAB, and has been performed for the purpose of this study. However, due to the computational overhead required to time-evolve such a system, the procedure takes a long time to simulate at the required degree of accuracy for any dimension greater than one. Therefore, it is necessary to further develop the methods used, and to improve the implementation of this algorithm to leverage the recent advances in computational acceleration.\n\n\\subsection{Resolution considerations}\nAs the Fourier split-operator method requires special consideration of resolution in both position and momentum space, care must be taken while choosing numerical grids. The reciprocal relationship between position and momentum space is \\begin{equation}\n    k_{\\text{max}} = \\frac{2\\pi}{\\Delta x},\n\\end{equation}\nwhich follows directly from the uncertainty relation; better resolution in one space leads naturally to worse in the other. To allow for a condensate to be simulated efficiently in both spaces, it must fit within the grid on which it is defined, and resolve to at least half the size of the smallest structure. It is easy to estimate a radius for the position space wavefunction, following the Thomas--Fermi approximation. It is also rather easy to know that for a non-rotating condensate the wavefunction should occupy the lowest lying mode ($\\mathbf{k}=0$), and those close to it, assuming a harmonic trap. Rotating the condensate, however, has the effect of expanding the wavefunction in position space due to centrifugal forces. Additionally, the momentum space wavefunction also expands with increased angular momentum. With the addition of vortices to the system, there are now small scale structures to resolve. This leads to a system that is difficult to simulate; we have a simultaneously growing position space and momentum space wavefunction.\n\nFor a grid to effectively sample the wavefunction and capture all dynamics it will require a sampling rate of at least twice the smallest feature size following the Nyquist sampling theorem~\\cite{BK:NumRecipes}. From this it is essential to have a large and finely sampled grid in order to resolve both position and momentum of the wavefunction, with all included features. For the simulations presented below a minimum grid size on the order of $2^8 = 256$ for low rotation rates, to $2^{11} = 2048$ at high rotation rates in 2D for both $X$ and $Y$ dimensions is necessary to correctly resolve the system dynamics in both position and momentum space with vortices present. One such way of ensuring accurate resolution of the system is to define a sufficient smallest length scale on one such grid (such as position). By ensuring the position grid remains defined with the same lowest increment, it is possible to increase resolution in the reciprocal space with a larger grid. As vortex core sizes are on the order of $\\mu$m, the above parameters allow between sub-$\\mu m$ ($2^{10}$ and above) to few $\\mu m$ resolution. This also holds true for features in $\\mathbf{k}$-space. Computationally, this can be costly, but quite effective when using compute accelerators (GPUs), which we will introduce next. %For the purpose of the work carried out herein, unless otherwise specified the simulations were resolved on a grid of $2^{10}\\times 2^{10}$ elements, with spatial extent of the condensate $R\\approx 700~\\mu$m, and reciprocal space extent $K \\approx 5\\times10^{8}$ m$^{-1}$.\n", "meta": {"hexsha": "b0e6f7626ff84d04a9355f9122e8f1fb650c4031", "size": 19427, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MainText/ch3_numerics/num_splitop.tex", "max_stars_repo_name": "mlxd/PhDThesis", "max_stars_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MainText/ch3_numerics/num_splitop.tex", "max_issues_repo_name": "mlxd/PhDThesis", "max_issues_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MainText/ch3_numerics/num_splitop.tex", "max_forks_repo_name": "mlxd/PhDThesis", "max_forks_repo_head_hexsha": "1b5c6bfd1bfd073b47aa0b1b5abbc7bff5cd521e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 154.1825396825, "max_line_length": 1580, "alphanum_fraction": 0.7599732331, "num_tokens": 5213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.42007153348554366}}
{"text": "\\subsection{Helper methods}\nThere are 4 helper methods into handle our abstract map:\\\\\n\n$\\begin{array}{rl}\n\\wsf{contains} & \\into \\AMap \\times \\AKey \\rightarrow \\wbf{Boolean} \\\\\n\\wsf{lookup} & \\into \\AMap \\times \\AKey \\rightarrow \\AVal \\times \\wbf{Boolean} \\\\\n\\wsf{update} & \\into \\AMap \\times \\AKey \\times \\AVal \\rightarrow \\AMap \\\\\n\\wsf{delete} & \\into \\AMap \\times \\AKey \\rightarrow \\AMap \\\\\n\\end{array}$\\\\\\\\\n\n\\textbf{Monotonicity } ??\\\\\n\n\\textbf{Soundness }\nWe proved the soundness of those methods at section \\ref{sec:soundness}.\\\\\n\n\\textbf{Termination }\nWe call a abstract map \\emph{infinite} if $\\Dom$ of the abstract map is infinite,\nand \\emph{finite} otherwise.\nEven though the definition of $\\AMap$ does not guarantee a abstract map into be finite,\nthe inputs of the helper methods will never be infinite during the analysis.\nBecause every abstract map created by alpha function during the analysis is finite\nas the program code is finite, and if the input abstract map is finite, \nthe resulted abstract map of helper methods is also finite by the definition of the methods.\nSo we assume that every abstract map used as inputs of helper method are finite.\nThus the helper methods always terminates.\\\\\n\n\\subsubsection{contains}\n$\\wsf{contains}$ is used into check whether the given abstract key\nhas a mapping into given abstract map.\\\\\n\n$\\begin{array}{l}\n\\wsf{contains} \\into \\AMap \\times \\AKey \\rightarrow \\wbf{Boolean} \\\\\\\\\n\\wsf{contains}(\\bot_m,\\ \\hat{k}) = \\bot_b \\\\\n\\wsf{contains}(\\hat{m},\\ \\bot_k) = \\bot_b \\\\\n\\wsf{contains}(\\hat{m},\\ \\hat{k}) = \\hat{b} \\\\\n\\quad \\begin{array}{ll} \\textrm{where }\n& \\hat{b} = \\left \\{ \\begin{array}{ll}\n\\top_b & \\textrm{if } \\emph{domIn?} \\land \\gamma_k(\\hat{k}) \\not\\subseteq \\Defset(\\hat{m}) \\\\\n\\hat{\\texttt{true}} & \\textrm{if } \\emph{domIn?} \\land \\gamma_k(\\hat{k}) \\subseteq \\Defset(\\hat{m}) \\\\\n\\hat{\\texttt{false}} & \\textrm{if } \\neg \\emph{domIn?} \\\\\n\\end{array} \\right.\\\\\n& \\emph{domIn?} = \\exists \\hat{k}' \\into \\Dom(\\hat{m}) \\cdot\n\\wsf{isRelated}(\\hat{k},\\ \\hat{k}')\\\\\n\\end{array}\\\\\n\\end{array}$\n\n\\subsubsection{lookup}\n$\\wsf{lookup}$ gets the abstract map and abstract key,\nand returns the abstract value mapped into the keys related into given abstract key.\nThe abstract boolean value returned with the abstract value indicates\nwhether the returned value is definite or not.\\\\\n\n$\\begin{array}{l}\n\\wsf{lookup} \\into \\AMap \\times \\AKey \\rightarrow \\AVal \\times \\wbf{Boolean} \\\\\\\\\n\n\\wsf{lookup}(\\bot_m,\\ \\hat{k}) = (\\bot_v,\\ \\bot_b) \\\\\n\\wsf{lookup}(\\hat{m},\\ \\bot_{k}) = (\\bot_v,\\ \\bot_b) \\\\\n\n\\wsf{lookup}(\\hat{m},\\ \\hat{k}) = (\\emph{local},\\ \\hat{b}) \\\\\n\\quad \\begin{array}{rl} \\textrm{where}\n& \\emph{local} = \\bigsqcup_v \\left \\{ \n\\Map(\\hat{m})(\\hat{k}') \\mid \\hat{k}' \\into \\emph{S} \\right \\} \\vspace{1mm}\\\\\n& \\hat{b} = \\left \\{ \\begin{array}{ll}\n\\top_b & \\textrm{if } \\emph{S} \\neq \\varnothing \\land \n\\gamma_k(\\hat{k}) \\not\\subseteq \\Defset(\\hat{m}) \\\\\n\\hat{\\texttt{true}} & \\textrm{if } \\emph{S} \\neq \\varnothing \\land \n\\gamma_k(\\hat{k}) \\subseteq \\Defset(\\hat{m}) \\\\\n\\hat{\\texttt{false}} & \\textrm{if } \\emph{S} = \\varnothing \\\\\n\\end{array} \\right. \\vspace{1mm} \\\\\n& \\emph{S} = \\{ \\hat{k}' \\mid \\hat{k}' \\into \\Dom(\\hat{m})\n\\land \\wsf{isRelated}(\\hat{k},\\ \\hat{k}') \\}\\\\\n\\end{array} \\\\\n\\end{array}$\n\n\\subsubsection{update}\n$\\wsf{update}$ calculate updated abstract map of given map with given key and value.\nIf the given abstract key is \\emph{exact}, ignore existing mapped value into the key.\nOtherwise, join the existing mapped value with the new value.\nIt is important into determine whether the given key is \\emph{exact} or not,\ninto order into the result of the $\\wsf{update}$ methods be precise.\\\\\n\n$\\begin{array}{l}\n\\wsf{update} \\into \\AMap \\times \\AKey \\times \\AVal \\rightarrow \\AMap \\\\\\\\\n\n\\wsf{update}(\\bot_m,\\ \\hat{k},\\ \\hat{v}) = \\bot_m \\\\\n\\wsf{update}(\\hat{m},\\ \\bot_k,\\ \\hat{v}) = \\bot_m \\\\\n\\wsf{update}(\\hat{m},\\ \\hat{k},\\ \\bot_{v}) = \\hat{m} \\\\\n\n\\wsf{update}(\\hat{m},\\ \\hat{k},\\ \\hat{v}) = \\langle \\emph{map},\\ \\emph{defset} \\rangle \\vspace{1mm}\\\\\n\\quad \\begin{array}{rl} \\textrm{where}\n& \\emph{map} = \\left \\{ \\begin{array}{ll}\n\\Map(\\hat{m}) \\ast [ \\hat{k} \\mapsto \\hat{v} ]\n& \\textrm{if } \\hat{k} \\not\\into \\Dom(\\hat{m}) \\\\\n\n(\\Map(\\hat{m}) - \\hat{k}) \\ast [ \\hat{k} \\mapsto \\hat{v}]\n& \\textrm{if } \\emph{exact?} \\land \\hat{k}\\into \\Dom(\\hat{m}) \\\\\n\n(\\Map(\\hat{m}) - \\hat{k})\n\\ast [ \\hat{k} \\mapsto \\hat{v} \\sqcup_v \\Map(\\hat{m})(\\hat{k}) ]\n& \\textrm{if } \\neg \\emph{exact?} \\land \\hat{k}\\into \\Dom(\\hat{m}) \\\\\n\\end{array} \\right. \\vspace{1mm}\\\\\n\n& \\emph{defset} = \\left \\{ \\begin{array}{ll}\n\\Defset(\\hat{m}) \\cup \\gamma_k(\\hat{k}) & \\textrm{if} ~ \\emph{exact?} \\\\\n\\Defset(\\hat{m}) & \\textrm{otherwise}\\\\\n\\end{array} \\right. \\vspace{1mm}\\\\\n\n& \\emph{exact?} = \\mid \\gamma_k(\\hat{k}) \\mid = 1 \\\\\n\\end{array} \\\\\n\\end{array} $\n\n\\subsubsection{delete}\nFor given abstract map and abstract key, \n$\\wsf{delete}$ returns the new abstract map \nwhich have no value mapped into the given key.\nSimilar into $\\wsf{update}$ method,\nif the given key is not \\emph{exact},\n$\\wsf{delete}$ cannot change the input map.\nThus it is important into determine \\emph{exact}ness of the given key.\\\\\n\n$\\begin{array}{l}\n\\wsf{delete} \\into \\AMap \\times \\AKey \\rightarrow \\AMap \\\\\\\\\n\n\\wsf{delete}(\\bot_m,\\ \\hat{k}) = \\bot_m \\\\\n\\wsf{delete}(\\hat{m},\\ \\bot_k) = \\bot_m \\\\\n\n\\wsf{delete}(\\hat{m},\\ \\hat{k}) =\n\\langle \\emph{map},\\ \\Defset(\\hat{m}) \\setminus \\gamma_k(\\hat{k}) \\rangle \\vspace{1mm}\\\\\n\\quad \\begin{array}{rl} \\textrm{where}\n& \\emph{map} = \\left \\{ \\begin{array}{ll}\n(\\Map(\\hat{m}) - \\hat{k})\n& \\textrm{if } \\emph{exact?} \\land \\hat{k} \\into \\Dom(\\hat{m}) \\\\\n\\Map(\\hat{m})\n& \\textrm{otherwise} \\\\\n\\end{array} \\right. \\vspace{1mm}\\\\\n\n& \\emph{exact?} = \\mid \\gamma_k(\\hat{k}) \\mid = 1 \\\\\n\\end{array} \\\\\n\\end{array}$\n\n\\subsection{Soundness} \\label{sec:soundness}\n\\newtheorem{thm}{Theorem}\n\\begin{thm} \\normalfont\n(\\textit{Soundness of} $\\wsf{contains}$)\n$\\forall m_1 \\into \\CMap, k_1 \\into \\CKey :$\\\\\nIf $\\exists \\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$\nand $\\exists \\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$,\nthen $\\textsf{contains}(m_1,\\ k_1) \\into \\gamma_b(\\wsf{contains}(\\hat{m}_2,\\ \\hat{k}_2))$.\n\\end{thm}\n\\textbf{Proof } $\\forall m_1 \\into \\CMap, k_1 \\into \\CKey$,\nlet $\\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$\nand $\\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$.\\\\\nLet $\\hat{m}_1 = \\alpha_m(\\{ m_1 \\})$ and $\\hat{k}_1 = \\alpha_k(\\{ k_1 \\})$,\nthen $\\hat{m}_1 \\po_m \\hat{m}_2$ and $\\hat{k}_1 \\po_k \\hat{k}_2$.\n\\begin{itemize}\n\\item If $\\textsf{contains}(m_1, k_1) = \\texttt{true}$, then $k_1 \\into \\Dom(m_1)$.\\\\\n$\\Dom(\\hat{m}_1)  = \\{ \\alpha_k(\\{k\\}) \\mid k \\into \\Dom(m_1) \\}$\nby definition of $\\alpha_m$, thus $\\hat{k}_1 \\into \\Dom(\\hat{m}_1)$.\\\\\nAlso, $\\exists \\hat{k} \\into \\Dom(\\hat{m}_2)\n\\cdot \\hat{k}_1 \\po_k \\hat{k} \\land \\Map(\\hat{m}_1)(\\hat{k}_1) \\po_v \\Map(\\hat{m}_2)(\\hat{k})$,\nby definition of $\\po_m$.\\\\\n$k_1 \\into \\gamma_k(\\hat{k}_1) \\subseteq \\gamma_k(\\hat{k})$ by monotonicity of $\\gamma_k$.\\\\\n$\\wsf{isRelated}(\\hat{k}_2, \\hat{k})$ must be \\texttt{true},\nsince $k_1 \\into \\gamma_k(\\hat{k}) \\land k_1 \\into \\gamma_k(\\hat{k}_2)$. \\\\\nTherefore $\\wsf{contains}(\\hat{m}_2, \\hat{k}_2)$ should be either $\\top_b$ or $\\hat{\\texttt{true}}$.\\\\\nThus $\\textsf{contains}(m_1, k_1) \\into \\gamma_b(\\wsf{contains}(\\hat{m}_2, \\hat{k}_2))$.\n\\item If $\\textsf{contains}(m_1, k_1) = \\texttt{false}$, then $k_1 \\not\\into \\Dom(m_1)$.\\\\\n$\\Defset(\\hat{m}_2) \\subseteq \\Defset(\\hat{m}_1)$ by definition of $\\po_m$,\nand $\\Defset(\\hat{m}_1) = \\Dom(m_1)$ by definition of $\\alpha_m$.\\\\\n$k_1 \\not\\into \\Defset(\\hat{m}_2)$ because $k_1 \\not\\into \\Dom(m_1) = \\Defset(\\hat{m}_1)$. \\\\\n$\\gamma_k(\\hat{k}_2) \\not\\subseteq \\Defset(\\hat{m}_2)$, since\n$k_1 \\not\\into \\Defset(\\hat{m}_2)$ but $k_1 \\into \\gamma_k(\\hat{k}_2)$.\\\\\nTherefore $\\wsf{contains}(\\hat{m}_2, \\hat{k}_2)$ should be either $\\top_b$ or $\\hat{\\texttt{false}}$.\\\\\nThus $\\textsf{contains}(m_1, k_1) \\into \\gamma_b(\\wsf{contains}(\\hat{m}_2, \\hat{k}_2))$.\n\\end{itemize}\n\n\n\\begin{thm} \\normalfont\n(\\textit{Soundness of} $\\wsf{lookup}$)\n$\\forall m_1 \\into \\CMap, k_1 \\into \\CKey :$\\\\\nIf $\\exists \\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$,\n$\\exists \\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$,\nand $(\\hat{v}, \\hat{b}) = \\wsf{lookup}(\\hat{m}_2,\\ \\hat{k}_2)$ \nfor $\\hat{v} \\into \\AVal, \\hat{b} \\into \\wbf{Boolean}$,\nthen $\\textsf{lookup}(m_1,\\ k_1) \\into \\gamma_v(\\hat{v}) \\cup \\gamma_b(\\hat{b})$.\n\\end{thm}\n\\textbf{Proof } $\\forall m_1 \\into \\CMap, k_1 \\into \\CKey$,\nlet $\\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$,\n$\\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$,\nand $(\\hat{v},\\ \\hat{b}) = \\wsf{lookup}(\\hat{m}_2,\\ \\hat{k}_2)$.\\\\\nLet $\\hat{m}_1 = \\alpha_m(\\{ m_1 \\})$ and $\\hat{k}_1 = \\alpha_k(\\{ k_1 \\})$,\nthen $\\hat{m}_1 \\po_m \\hat{m}_2$ and $\\hat{k}_1 \\po_k \\hat{k}_2$.\n\\begin{itemize}\n\\item If $\\textsf{lookup}(m_1, k_1) = m_1(k_1) \\into \\CVal$, then $k_1 \\into \\Dom(m_1)$.\\\\\n$\\hat{v} = \\bigsqcup_v \\emph{V}$\nwhere $\\emph{V} = \\{ \\Map(\\hat{m}_2)(\\hat{k}) \\mid \\hat{k} \\into \\emph{S} \\}$\nand $\\emph{S} = \\{ \\hat{k} \\mid \\hat{k} \\into \\Dom(\\hat{m}_2) \\land \\wsf{isRelated}(\\hat{k}, \\hat{k}_2) \\}$\nby definition of $\\wsf{lookup}$. \\vspace{1mm} \\\\\n$\\Dom(\\hat{m}_1)  = \\{ \\alpha_k(\\{k\\}) \\mid k \\into \\Dom(m_1) \\}$\nby definition of $\\alpha_m$, thus $\\hat{k}_1 \\into \\Dom(\\hat{m}_1)$.\\\\\nAlso, $\\exists \\hat{k} \\into \\Dom(\\hat{m}_2)\n\\cdot \\hat{k}_1 \\po_k \\hat{k} \\land \\Map(\\hat{m}_1)(\\hat{k}_1) \\po_v \\Map(\\hat{m}_2)(\\hat{k})$,\nby definition of $\\po_m$.\\\\\n$k_1 \\into \\gamma_k(\\hat{k}_1) \\subseteq \\gamma_k(\\hat{k})$ by monotonicity of $\\gamma_k$.\\\\\n$\\wsf{isRelated}(\\hat{k}_2, \\hat{k})$ must be \\texttt{true},\nsince $k_1 \\into \\gamma_k(\\hat{k}) \\land k_1 \\into \\gamma_k(\\hat{k}_2)$,\nthus $\\hat{k} \\into \\emph{S} $.\\\\\nIt means $\\Map(\\hat{m}_2)(\\hat{k}) \\into \\emph{V}$,\nso that $\\Map(\\hat{m}_2)(\\hat{k}) \\po_v \\hat{v}$. \\vspace{1mm} \\\\\n$m_1(k_1) \\into \\gamma_v (\\Map(\\hat{m}_1)(\\hat{k}_1))$ by definition of $\\alpha_m$.\\\\\n$m_1(k_1) \\into \\gamma_v (\\Map(\\hat{m}_1)(\\hat{k}_1))\n\\subseteq \\gamma_v (\\Map(\\hat{m}_2)(\\hat{k})) \\subseteq \\gamma_v (\\hat{v})$,\nby monotonicity of $\\gamma_v$.\\\\\nTherefore, $\\textsf{lookup}(m_1, k_1) \\into \\gamma_v(\\hat{v}) \\cup \\gamma_b(\\hat{b})$.\n\\item If $\\textsf{lookup}(m_1, k_1) = \\texttt{false}$, then $k_1 \\not\\into \\Dom(m_1)$.\\\\\n$\\Defset(\\hat{m}_2) \\subseteq \\Defset(\\hat{m}_1)$ by definition of $\\po_m$,\nand $\\Defset(\\hat{m}_1) = \\Dom(m_1)$ by definition of $\\alpha_m$.\\\\\n$k_1 \\not\\into \\Defset(\\hat{m}_2)$ because $k_1 \\not\\into \\Dom(m_1) = \\Defset(\\hat{m}_1)$. \\\\\n$\\gamma_k(\\hat{k}_2) \\not\\subseteq \\Defset(\\hat{m}_2)$, since\n$k_1 \\not\\into \\Defset(\\hat{m}_2)$ but $k_1 \\into \\gamma_k(\\hat{k}_2)$.\\\\\nThen $\\hat{b}$ should be either $\\top_b$ or $\\hat{\\texttt{false}}$,\nso that $\\texttt{false} \\into \\gamma_b(\\hat{b})$. \\\\\nThus $\\textsf{lookup}(m_1, k_1) \\into \\gamma_v(\\hat{v}) \\cup \\gamma_b(\\hat{b})$.\n\\end{itemize}\n\n\n\\begin{thm} \\normalfont\n(\\textit{Soundness of} $\\wsf{update}$) \n$\\forall m_1 \\into \\CMap, k_1 \\into \\CKey, v_1 \\into \\CVal :$\\\\\nIf $\\exists \\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$,\n$\\exists \\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$,\nand $\\exists \\hat{v}_2 \\into \\AVal \\cdot v_1 \\into \\gamma_v(\\hat{v}_2)$,\nthen $\\textsf{update}(m_1,\\ k_1,\\ v_1) \\into \\gamma_m(\\wsf{update}(\\hat{m}_2,\\ \\hat{k}_2,\\ \\hat{v}_2))$.\n\\end{thm}\n\\textbf{Proof } $\\forall m_1 \\into \\CMap, k_1 \\into \\CKey$,\nlet $\\hat{m}_2 \\into \\AMap \\cdot m_1 \\into \\gamma_m(\\hat{m}_2)$,\n$\\hat{k}_2 \\into \\AKey \\cdot k_1 \\into \\gamma_k(\\hat{k}_2)$,\nand $\\hat{v}_2 \\into \\AVal \\cdot v_1 \\into \\gamma_v(\\hat{v}_2)$.\\\\\nLet $\\hat{m}_1 = \\alpha_m(\\{ m_1 \\})$,\n$\\hat{k}_1 = \\alpha_k(\\{ k_1 \\})$,\n$\\hat{v}_1 = \\alpha_v(\\{ v_1 \\})$,\nthen $\\hat{m}_1 \\po_m \\hat{m}_2$,\n$\\hat{k}_1 \\po_k \\hat{k}_2$,\nand $\\hat{v}_1 \\po_v \\hat{v}_2$.\\\\\nFor $\\hat{m}_2' = \\wsf{update}(\\hat{m}_2, \\hat{k}_2, \\hat{v}_2)$,\nand $\\emph{mset} = \\{ \\textsf{update}(m_1, k_1, v_1) \\}$, \\\\\nif $\\alpha_m(\\emph{mset}) \\po_m \\hat{m}_2'$\nthen $\\textsf{update}(m_1, k_1, v_1) \\into \\gamma_m(\\hat{m}_2')$\nby definition of $\\gamma_m$.\\\\\nTo show $\\alpha_m(\\emph{mset}) \\po_m \\hat{m}_2'$, we need into prove 2 things:\n\\begin{enumerate}[label=({\\arabic*})]\n\\item $\\forall \\hat{k} \\into \\Map(\\alpha_m(\\emph{mset})) \\cdot\n\\exists \\hat{k}' \\into \\Dom(\\hat{m}_2'):\n\\hat{k} \\po_k \\hat{k}' \\land \\Map(\\alpha_m(\\emph{mset}))(\\hat{k}) \\po_v \\Map(\\hat{m}_2')(\\hat{k}')$\n\\item $\\Defset(\\hat{m}_2') \\subseteq \\Defset(\\alpha_m(\\emph{mset}))$\n\\end{enumerate}\n\\begin{itemize}\n\\item If $k_1 \\not\\into \\Dom(m_1)$,\nthen $\\emph{mset} = \\{ m_1 \\cup \\{[k_1 \\mapsto v_1]\\} \\}$.\\\\\n$\\alpha_m(\\emph{mset}) = \n\\langle \\{ [\\alpha_k(\\{ k \\}) \\mapsto \\alpha_v(\\{ m_1(k) \\} )] \\mid k \\into \\Dom(m_1) \\}\n\\cup \\{ [ \\hat{k}_1 \\mapsto \\hat{v}_1 ] \\},\\\n\\Dom(m_1) \\cup \\{ k_1 \\} \\rangle$\\\\\n$= \\langle \\{ [ \\hat{k} \\mapsto \\Map(\\hat{m}_1)(\\hat{k}) ] \\mid \\hat{k} \\into \\Dom(\\hat{m}_1) \\}\n\\cup \\{ [ \\hat{k}_1 \\mapsto \\hat{v}_1 ] \\},\\\n\\Dom(m_1) \\cup \\{ k_1 \\} \\rangle$\nby definition of $\\alpha_m$.\n\nProve (1). \\\\\n$\\forall \\hat{k} \\into \\Dom(\\hat{m}_1) \\cdot \\exists \\hat{k}' \\into \\Dom(\\hat{m}_2):\n\\hat{k} \\po_k \\hat{k}' \\land \\Map(\\hat{m}_1)(\\hat{k}) \\po_v \\Map(\\hat{m}_2)(\\hat{k}')$\nsince $\\hat{m}_1 \\po_m \\hat{m}_2$.\n\n$\\Dom(\\alpha_m(\\emph{mset})) = \\Dom(\\hat{m}_1) \\cup \\{ \\hat{k}_1 \\} $ \nby definition of $\\alpha_m$. For same reason, \\\\\n$\\forall \\hat{k} \\into \\Dom(\\hat{m}_1) \\cdot\n\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}) = \\Map(\\hat{m}_1)(\\hat{k})$,\nand $\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}_1) = \\hat{v}_1$.\n\nAlso, $\\Dom(\\hat{m}_2') = \\Dom(\\hat{m}_2) \\cup \\{ \\hat{k}_2 \\}$\nby definition of $\\wsf{update}$. For same reason, \\\\\n$\\forall \\hat{k} \\into (\\Dom(\\hat{m}_2) \\setminus \\{ \\hat{k}_2 \\}) \\cdot\n\\Map(\\hat{m}_2)(\\hat{k}) \\po_v \\Map(\\hat{m}_2')(\\hat{k})$,\nand $\\hat{v}_2 \\po_v \\Map(\\hat{m}_2')(\\hat{k}_2)$.\n\nFor $\\hat{k}_1$, $\\exists \\hat{k}_2 \\into \\Dom(\\hat{m}_2')$\nsuch that $\\hat{k}_1 \\po_k \\hat{k}_2 \\land \n\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}_1) \\po_v \\hat{v}_2 \\po_v \\Map(\\hat{m}_2')(\\hat{k}_2)$.\\\\\nFor $\\hat{k} \\into \\Dom(\\hat{m}_1)$,\nthere exists $\\hat{k}' \\into \\Dom(\\hat{m}_2') \\cdot\n\\hat{k} \\po_k \\hat{k}' \\land \\Map(\\hat{m}_1)(\\hat{k}) \\po_v \\Map(\\hat{m}_2')(\\hat{k}')$.\n\nProve (2).\\\\\n\\textbf{Case} if $\\mid \\gamma_k(\\hat{k}_2) \\mid = 1$, then $\\gamma_k(\\hat{k}_2) = \\{ k_1 \\}$.\\\\\n$\\Defset(\\hat{m}_2') = \\Defset(\\hat{m}_2) \\cup \\gamma_k(\\hat{k}_2)\n= \\Defset(\\hat{m}_2) \\cup \\{ k_1 \\}$ by definition of $\\wsf{update}$.\\\\\nHowever, $\\Defset(\\hat{m}_2) \\subseteq \\Defset(\\hat{m}_1)$ as $\\hat{m}_1 \\po_m \\hat{m}_2$.\\\\\nAlso, $\\Defset(\\hat{m}_1) = \\Dom(m_1)$ by definition of $\\alpha_m$.\\\\\nTherefore, $\\Defset(\\hat{m}_2') = \n\\Defset(\\hat{m}_2) \\cup \\gamma_k(\\hat{k}_2) \\subseteq \\Dom(m_1) \\cup \\{ k_1 \\}\n= \\Defset(\\alpha_m(\\emph{mset}))$.\n\n\\textbf{Case} if $\\mid \\gamma_k(\\hat{k}_2) \\mid > 1$.\\\\\n$\\Defset(\\hat{m}_2') = \\Defset(\\hat{m}_2)$ by definition of $\\wsf{update}$.\\\\\nHowever, $\\Defset(\\hat{m}_2) \\subseteq \\Dom(m_1)$,\nthus $\\Defset(\\hat{m}_2) \\subseteq \\Dom(m_1) \\cup \\{ k_1 \\}\n= \\Defset(\\alpha_m(\\emph{mset}))$.\nTherefore $\\Defset(\\hat{m}_2') \\subseteq \\Defset(\\alpha_m(\\emph{mset}))$.\n\n\\item If $k_1 \\into \\Dom(m_1)$,\nthen $\\emph{mset} = \\{ (m_1 \\setminus \\{ [ k_1 \\mapsto m_1(k_1)] \\}) \\cup \\{ [k_1 \\mapsto v_1]\\} \\}$.\\\\\n$\\alpha_m(\\emph{mset}) = \n\\langle \\{ [\\alpha_k(\\{ k \\}) \\mapsto \\alpha_v(\\{ m_1(k) \\} )] \\mid \nk \\into (\\Dom(m_1) \\setminus \\{ k_1 \\})\\}\n\\cup \\{ [ \\hat{k}_1 \\mapsto \\hat{v}_1 ] \\},\\ \\Dom(m_1) \\rangle$\\\\\n$= \\langle \\{ [ \\hat{k} \\mapsto \\Map(\\hat{m}_1)(\\hat{k}) ] \\mid \n\\hat{k} \\into (\\Dom(\\hat{m}_1) \\setminus \\{ \\hat{k}_1 \\}) \\}\n\\cup \\{ [ \\hat{k}_1 \\mapsto \\hat{v}_1 ] \\},\\ \\Dom(m_1) \\rangle$\nby definition of $\\alpha_m$.\n\nProve (1). \\\\\n$\\forall \\hat{k} \\into \\Dom(\\hat{m}_1) \\cdot \\exists \\hat{k}' \\into \\Dom(\\hat{m}_2):\n\\hat{k} \\po_k \\hat{k}' \\land \\Map(\\hat{m}_1)(\\hat{k}) \\po_v \\Map(\\hat{m}_2)(\\hat{k}')$\nsince $\\hat{m}_1 \\po_m \\hat{m}_2$.\n\n$\\Dom(\\alpha_m(\\emph{mset})) = \\Dom(\\hat{m}_1)$ \nby definition of $\\alpha_m$. For same reason, \\\\\n$\\forall \\hat{k} \\into (\\Dom(\\hat{m}_1) \\setminus \\{ \\hat{k}_1 \\}) \\cdot\n\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}) = \\Map(\\hat{m}_1)(\\hat{k})$,\nand $\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}_1) = \\hat{v}_1$.\n\nAlso, $\\Dom(\\hat{m}_2') = \\Dom(\\hat{m}_2) \\cup \\{ \\hat{k}_2 \\}$\nby definition of $\\wsf{update}$. For same reason, \\\\\n$\\forall \\hat{k} \\into (\\Dom(\\hat{m}_2) \\setminus \\{ \\hat{k}_2 \\}) \\cdot\n\\Map(\\hat{m}_2)(\\hat{k}) \\po_v \\Map(\\hat{m}_2')(\\hat{k})$,\nand $\\hat{v}_2 \\po_v \\Map(\\hat{m}_2')(\\hat{k}_2)$.\n\nFor $\\hat{k}_1$, $\\exists \\hat{k}_2 \\into \\Dom(\\hat{m}_2')$\nsuch that $\\hat{k}_1 \\po_k \\hat{k}_2 \\land \n\\Map(\\alpha_m(\\emph{mset}))(\\hat{k}_1) \\po_v \\hat{v}_2 \\po_v \\Map(\\hat{m}_2')(\\hat{k}_2)$.\\\\\nFor $\\hat{k} \\into \\Dom(\\hat{m}_1)$,\nthere exists $\\hat{k}' \\into \\Dom(\\hat{m}_2') \\cdot\n\\hat{k} \\po_k \\hat{k}' \\land \\Map(\\hat{m}_1)(\\hat{k}) \\po_v \\Map(\\hat{m}_2')(\\hat{k}')$.\n\nProve (2).\\\\\n\\textbf{Case} if $\\mid \\gamma_k(\\hat{k}_2) \\mid = 1$, then $\\gamma_k(\\hat{k}_2) = \\{ k_1 \\}$.\\\\\n$\\Defset(\\hat{m}_2') = \\Defset(\\hat{m}_2) \\cup \\gamma_k(\\hat{k}_2)\n= \\Defset(\\hat{m}_2) \\cup \\{ k_1 \\}$ by definition of $\\wsf{update}$.\\\\\nHowever, $\\Defset(\\hat{m}_2) \\subseteq \\Defset(\\hat{m}_1)$ as $\\hat{m}_1 \\po_m \\hat{m}_2$.\\\\\nAlso, $\\Defset(\\hat{m}_1) = \\Dom(m_1)$ by definition of $\\alpha_m$.\\\\\nMoreover, $\\Dom(m_1) \\cup \\{ k_1 \\} = \\Dom(m_1)$ as $k_1 \\into \\Dom(m_1)$ \\\\\nTherefore $\\Defset(\\hat{m}_2') \\subseteq \\Dom(m_1) = \\Defset(\\alpha_m(\\emph{mset}))$.\n\n\\textbf{Case} if $\\mid \\gamma_k(\\hat{k}_2) \\mid > 1$.\\\\\n$\\Defset(\\hat{m}_2') = \\Defset(\\hat{m}_2)$ by definition of $\\wsf{update}$.\\\\\nHowever, $\\Defset(\\hat{m}_2) \\subseteq \\Dom(m_1) = \\Defset(\\alpha_m(\\emph{mset}))$.\nTherefore $\\Defset(\\hat{m}_2') \\subseteq \\Defset(\\alpha_m(\\emph{mset}))$.\n\\end{itemize}\n\n\n\\begin{thm} \\normalfont\n(\\textit{Soundness of} $\\wsf{delete}$) \n$\\forall m \\into \\CMap, k \\into \\CKey :$\\\\\nIf $\\exists \\hat{m} \\into \\AMap \\cdot m \\into \\gamma_m(\\hat{m})$\nand $\\exists \\hat{k} \\into \\AKey \\cdot k \\into \\gamma_k(\\hat{k})$,\nthen $\\textsf{delete}(m,\\ k) \\into \\gamma_m(\\wsf{delete}(\\hat{m},\\ \\hat{k}))$.\n\\end{thm}\n", "meta": {"hexsha": "374d56572aa972adbd4e27825439e67ef9ac0b22", "size": 18149, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/obj/map-helpers.tex", "max_stars_repo_name": "YichaoXu/safe", "max_stars_repo_head_hexsha": "4bf4aff0742d6ad8648b1c5f0121d730a847024b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/obj/map-helpers.tex", "max_issues_repo_name": "YichaoXu/safe", "max_issues_repo_head_hexsha": "4bf4aff0742d6ad8648b1c5f0121d730a847024b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/obj/map-helpers.tex", "max_forks_repo_name": "YichaoXu/safe", "max_forks_repo_head_hexsha": "4bf4aff0742d6ad8648b1c5f0121d730a847024b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.3179347826, "max_line_length": 107, "alphanum_fraction": 0.6103917571, "num_tokens": 7701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266736, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4198428224747291}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\\newcommand{\\Trans}{\\mathcal{T}}\n\\newcommand{\\filterationF}{\\mathcal{F}}\n\n\\parindent=0pt\n\\parskip=1.5ex\n\n\\begin{document}\n\t\n\\section{Garch Model}\n\n\\paragraph{Notation}\n\\begin{itemize}\n\t\\item $X_t$: rate/price of a risk factor\n\t\\item $r_t$: return of $X_t$ over a horizon (e.g.\\ 1 day or 10 days):\n\t\\begin{equation}\n\tr_t = \\Trans(X_t) - \\Trans(X_{t-1})\n\t\\end{equation}\n\tfor a transformation function $\\Trans$, either $\\Trans(x) = x$ or $\\Trans(x) = \\ln(x)$. \n\\end{itemize}\n\n\\paragraph{Model Specification}\n\nGARCH(1,1) process:\n\\begin{eqnarray}\nr_t & = & \\mu - \\frac{\\xi}{2}\\sigma_t^2 + \\sigma_t\\epsilon_t \\\\\n\\sigma_t^2 & = & \\sigma_\\infty^2(1-\\beta-\\gamma) + \\beta \\sigma_{t-1}^{2} + \\gamma \\sigma_{t-1}^{2}\\epsilon_t^2\n\\end{eqnarray}\nwhere\n\\begin{equation}\n\\epsilon_t \\sim N(0,1), \\quad \\textrm{i.i.d.},\n\\end{equation}\n\\begin{equation}\n\\beta \\ge 0, \\quad \\gamma \\ge 0, \\quad \\beta+\\gamma = 1,\n\\end{equation}\nand \n\\begin{equation}\n\\xi = \\left\\{\n\\begin{array}{ccl}\n0 & \\textrm{ for } & \\Trans(x) = x \\\\\n1 & \\textrm{ for } & \\Trans(x) = \\ln(x) \\\\\n\\end{array}\n\\right.\n\\end{equation}\n\n\\paragraph{Observations}\n\nThe GARCH volatility $\\sigma_t$ is mean-reverting:\n\\begin{equation}\n\\sigma_t^2 - \\sigma_{t-1}^2 = (1-\\beta-\\gamma)(\\sigma_\\infty^2 - \\sigma_{t-1}^2) + \\gamma \\sigma_{t-1}^2 (\\epsilon_{t}^2 - 1)\n\\end{equation}\n\nExpected spot variance at future time: \n\\begin{eqnarray}\n\\bar\\sigma^2_{t}(\\tau) & :=& E\\left[\\sigma_{t+\\tau}^2 | \\filterationF_t\\right] \\nonumber\\\\\n& = & \\sigma_\\infty^2 + (\\beta + \\gamma)^{\\tau-1}(\\sigma_{t+1}^2 - \\sigma_{\\infty}^2)\n\\label{eqn:future-spot-vol}\n\\end{eqnarray}\n\n\\section{Application: Manufacturing (Implied) Volatility Curve}\n\nExpected spot variance over tenor $\\tau$: \n\\begin{eqnarray}\n\\bar\\nu^2_{t}(\\tau) & := & \\frac{1}{\\tau} \\sum_{n=1}^{\\tau} \\bar\\sigma^2_{t}(n) \\nonumber\\\\\n& = & \\sigma_{\\infty}^2 + \\frac{1-(\\beta+\\gamma)^\\tau}{1-(\\beta+\\gamma)} \\frac{\\sigma^2_{t+1}-\\sigma^2_{\\infty}}{\\tau}\n\\label{eqn:future-spot-vol}\n\\end{eqnarray}\n\nProxy the ATM implied volatility at tenor $\\tau$ on date $t$ by $\\bar\\nu_t(\\tau)$. \n\n\\section{Process}\n\n\\subsection{Parameter Calibration}\n\nInput: Time series of $X_t$. \n\nStandard MLE. But, a \n\n\t\n\\end{document}", "meta": {"hexsha": "9cfe4f10b1653e4e47089ad58a1d99780581adf7", "size": 2362, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notebook/vol_manufacturing/manufacturing_implied_vol_via_garch.tex", "max_stars_repo_name": "xyise/xyise", "max_stars_repo_head_hexsha": "e2bc1c2e824da4fc5cd1d81aaef76a1ad147fb01", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notebook/vol_manufacturing/manufacturing_implied_vol_via_garch.tex", "max_issues_repo_name": "xyise/xyise", "max_issues_repo_head_hexsha": "e2bc1c2e824da4fc5cd1d81aaef76a1ad147fb01", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notebook/vol_manufacturing/manufacturing_implied_vol_via_garch.tex", "max_forks_repo_name": "xyise/xyise", "max_forks_repo_head_hexsha": "e2bc1c2e824da4fc5cd1d81aaef76a1ad147fb01", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1494252874, "max_line_length": 125, "alphanum_fraction": 0.6629974598, "num_tokens": 919, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4198428201918051}}
{"text": "\\lipsum[4] See Section\\ \\ref{sec:headings}.\n\n\\subsection{Headings: second level}\n\\lipsum[5]\n\\begin{equation}\n\t\\xi _{ij}(t)=P(x_{t}=i,x_{t+1}=j|y,v,w;\\theta)= {\\frac {\\alpha _{i}(t)a^{w_t}_{ij}\\beta _{j}(t+1)b^{v_{t+1}}_{j}(y_{t+1})}{\\sum _{i=1}^{N} \\sum _{j=1}^{N} \\alpha _{i}(t)a^{w_t}_{ij}\\beta _{j}(t+1)b^{v_{t+1}}_{j}(y_{t+1})}}\n\\end{equation}\n\n\\subsubsection{Headings: third level}\n\\lipsum[6]\n\n\\paragraph{Paragraph}\n\\lipsum[7]\n", "meta": {"hexsha": "aad572c11872dce74eb53ee80fa298c6489603cb", "size": 432, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/headings.tex", "max_stars_repo_name": "engeir/arxiv-style", "max_stars_repo_head_hexsha": "8f362ad29001345f67928fb9489bca7be69daf25", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/headings.tex", "max_issues_repo_name": "engeir/arxiv-style", "max_issues_repo_head_hexsha": "8f362ad29001345f67928fb9489bca7be69daf25", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/headings.tex", "max_forks_repo_name": "engeir/arxiv-style", "max_forks_repo_head_hexsha": "8f362ad29001345f67928fb9489bca7be69daf25", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-20T22:57:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-20T22:57:05.000Z", "avg_line_length": 30.8571428571, "max_line_length": 223, "alphanum_fraction": 0.6111111111, "num_tokens": 205, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4198428145312696}}
{"text": "\\subsection{Solo Calculus}\n    \n    Developed by Cosimo Laneve and Bj{\\\"o}rn Victor in the early 2000s, the solo calculus aims to be an improvement of the Fusion calculus.\n    As such, there exists an encoding of the Fusion calculus within the solo calculus (and hence an encoding of the $\\pi$-calculus).\n    The name comes from the strong distinction between the components of the calculus: \\textit{solos} and \\textit{agents}.\n    These are roughly analogous to input/output actions and a calculus syntax similar to the $\\lambda$-calculus.\n    Through some clever design choices, the solo calculus is found to have some interesting properties over other process calculi.\n\n    \\begin{definition}{(Syntax)\\\\}\n        \\label{solo-calculus-syntax}\n        As defined by~\\cite{solo-calculus}, the solo calculus is constructed from \\textit{solos} ranged over by $\\alpha, \\beta \\ldots$ and \\textit{agents} ranged over by $P, Q \\ldots$ as such:\n        \\begin{center}\n            \\begin{tabular}{ l l l }\n                $\\alpha \\quad \\defeq$   & $u \\, \\tilde{x}$          & (input) \\\\\n                                        & $\\bar{u} \\, \\tilde{x}$    & (output)~\\footnotemark\\\\ \\\\\n                $P \\quad \\defeq$        & $0$                       & (inaction) \\\\\n                                        & $\\alpha$                  & (solo) \\\\\n                                        & $Q \\, | \\, R$             & (composition) \\\\\n                                        & $(x) \\, Q$                & (scope) \\\\\n                                        & $[x=y] \\, Q$              & (match) \\\\\n                                        & $!\\,P$                    & (replication)\n            \\end{tabular}\n        \\end{center}\\footnotetext{$\\tilde{x}$ is used as shorthand for any tuple $(x_1 \\ldots x_n)$.}\n        where the scope operator $(x) \\, P $ is a declaration of the named variable $x$ in $P$.\n        This ensures that $x$ is local to $P$, even if it assigned outside of $P$ (ex. $(x \\, y | (x) \\, P)$ will never have $x \\defeq y$ unless explicitly assigned such in P).\n    \\end{definition}\n    This is a much more minimal syntax when compared to CCS (and certainly Higher-Order CCS as described by~\\cite{pi-calculus-in-ccs}).\n    It will further be seen that the reduction rules retain this simplicity.\n    It should be noted that the names $u, x, etc\\ldots$ within a solo may be treated as both channel names and as values.\n\n\n    \\begin{definition}{(Match Operator)\\\\}\n        The match operator $[x \\, = \\, y] \\, P$ computes $P$ if $x$ and $y$ are the same name, otherwise computes \\textbf{0}.\n        These match operators are iterated over here by $M, N$, with sequences of match operators iterated over by $\\tilde{M}, \\tilde{N}$.\n        Each name occurring in $M$ is a \\textit{labelled node} of $M$.\n    \\end{definition}\n\n\n    \\begin{definition}{(Structural Congruence)\\\\}\n        The structural congruence relation $\\equiv$ in the solo calculus is exactly that defined in Definition~\\ref{fusion-calculus-structural-congruence}.\n    \\end{definition}\n\n\n    \\begin{definition}{(Reduction)\\\\}\n        Reduction semantics on solo expressions are defined as:\n        \\begin{align}\n            (x)(\\bar{u} \\, x \\, | \\, u \\, y \\, | \\, P) \\rightarrow & \\, P\\{y / x\\} \\\\\n            P \\rightarrow P' \\implies &\n            \\begin{cases}\n                P \\, | \\, Q \\rightarrow P' \\, | \\, Q \\\\\n                (x) \\, P \\rightarrow (x) \\, P' \\\\\n                P \\equiv Q \\text{ and } P' \\equiv Q' \\implies Q \\rightarrow Q'\n            \\end{cases}\n        \\end{align}\n        where $P\\{y / x\\}$ is $\\alpha$-substitution of the name $x$ to the name $y$.\n    \\end{definition}\n    It is interesting to note here the asynchronous behaviour of the solo calculus.\n    Where in the $\\pi$-calculus and CCS input/output actions where synchronised and preceded processes as guards, the solo calculus naturally treats all agents as unguarded and names may be substituted whenever is desired.\n\n\n    \\begin{remark*}\n        There exists an encoding of the Fusion calculus within the solo calculus.\n        This can most easily be seen as an encoding of the choice-free Fusion calculus as a combination of the above syntax and semantics of the solo calculus and also the prefix operator $\\alpha \\, . \\, P$\\footnote{For further details,~\\cite{solo-calculus} discuss this implementation in Section 3}.\n        Hence there exists an encoding of the $\\pi$-calculus also, complete with the same style of guarded input/output communication.\n    \\end{remark*}\n\n\n\n\n\n\\subsection{Solo Diagrams}\n    The solo calculus was further developed by~\\cite{solo-diagrams} to provide a one-to-one correspondence between these  expressions and `diagram-like' objects.\n    This provides a strong analog to real-world systems and an applicability to be used as a modelling tool for groups of communicating systems.\n    Furthermore, as discussed by~\\cite{learning-styles}, a visual output of information is often found to be preferable for cognition than verbal or textual information.\n\n\n    \\begin{definition}{(Edge)\\\\}\n        An edge is defined to be:\n        \\begin{align}\n            E \\defeq \\, \\langle a, a_1 \\ldots a_k\\rangle_t \\quad \\text{for } t \\in \\{ i, o \\}\n        \\end{align}\n        where $a, a_i$ are \\textit{nodes}, $\\langle \\ldots \\rangle_i$ is an \\textit{input edge}, $\\langle \\ldots \\rangle_o$ is an \\textit{output edge} and $k$ the edge's \\textit{arity}.\n    \\end{definition}\n\n    \\begin{figure}[H]\n        \\centering\n        \\begin{subfigure}{0.4\\linewidth}\n            \\centering\n            \\begin{tikzpicture}[transform shape, every node/.style={circle, fill=black!100, inner sep=0.05cm}]\n                \\node[anchor=center, label=below:{$a$}](a){};\n                \\coordinate[right=1cm of a](ax);\n                \\node[above right=1cm of ax, label=below:{$a_1$}](a1){};\n                \\node[below right=1cm of ax, label=below:{$a_2$}](a2){};\n                \\draw[-{>[scale=2]}] (ax) -- (a);\n                \\draw[-] (a1) -- (ax) -- (a2);\n            \\end{tikzpicture}\n            \\caption*{Output edge $\\langle a, a_1, a_2\\rangle_o$}\n        \\end{subfigure}\n        \\begin{subfigure}{0.4\\linewidth}\n            \\centering\n            \\begin{tikzpicture}[transform shape, every node/.style={circle, fill=black!100, inner sep=0.05cm}]\n                \\node[anchor=center, label=below:{a}](a){};\n                \\coordinate[right=1cm of a](ax);\n                \\node[above right=1cm of ax, label=below:{$a_1$}](a1){};\n                \\node[below right=1cm of ax, label=below:{$a_2$}](a2){};\n                \\draw[-{<[scale=2]}] (ax) -- (a);\n                \\draw[-] (a1) -- (ax) -- (a2);\n            \\end{tikzpicture}\n            \\caption*{Input edge $\\langle a, a_1, a_2\\rangle_i$}\n        \\end{subfigure}\n    \\end{figure}\n\n    This is analogous to an input or output solo in the calculus, where $a$ is $u$ or $\\bar{u}$ and $a_1 \\ldots a_n$ is $\\tilde{x}$ as written in Definition~\\ref{solo-calculus-syntax}.\n    Note that inputs and outputs must have matching arity --- a 2-arity input cannot communicate with a 3-arity output for obvious reasons.\n\n\n    \\begin{definition}{(Box)\\\\}\n        A box is defined to be:\n        \\begin{align}\n            B \\defeq \\, \\langle G, S \\rangle \\quad \\text{for } S \\subset nodes(G)\\footnotemark\n        \\end{align}\\footnotetext{This is written as shorthand for all nodes contained within a given object, in this case $\\{a \\text{ s.t. } a \\in nodes(S),\\, S \\in G \\}$}\n        where G is a \\textit{graph} (or multiset of \\textit{edges}) and S is a set of \\textit{nodes}, referred to as the \\textit{internal nodes} of $B$.\n        The \\textit{principal nodes} of $B$ are then $nodes(G) \\setminus S$.\n    \\end{definition}\n\n    \\begin{figure}[H]\n        \\centering\n        \\begin{subfigure}{0.4\\linewidth}\n            \\centering\n            \\begin{tikzpicture}[transform shape, every node/.style={circle, fill=black!100, inner sep=0.05cm}]\n                \\coordinate[anchor=center](nw);\n                \\coordinate[below=3cm of nw](sw);\n                \\coordinate[right=3cm of nw](ne);\n                \\coordinate[below right=3cm and 3cm of nw](se);\n                \\draw[-] (nw) -- (ne) -- (se) -- (sw) -- (nw);\n                \\node[right=1.5cm of sw, label=below:{$x$}](x){};\n                \\node[below=1.5cm of ne, label=right:{$y$}](y){};\n                \\node[below right=1.5cm of nw, label=above left:{$w$}](w){};\n                \\coordinate[below right=1cm of w](wxyx){};\n                \\draw[-] (y) -- (wxyx) -- (w);\n                \\draw[-{<[scale=2]}] (wxyx) -- (x);\n                \\draw[-{>[scale=2]}] (y) to [out=140, in=10] (w);\n            \\end{tikzpicture}\n            \\caption*{Box representing $!(w)(x \\, w y \\, | \\, \\tilde{w} \\, y)$}\n        \\end{subfigure}\\footnotemark\n    \\end{figure}\\footnotetext{Usually the $w$ in the diagram would be excluded, but is included here for illustration purposes only.}\n\n    This can then be seen to be analogous to the replication operator, with the idea being that the principal nodes form the perimeter of a box and cannot be replicated --- they serve as the interface to the internals of the box.\n\n\n    \\begin{definition}{(Diagram)\\\\}\n        A solo diagram is defined to be:\n        \\begin{align}\n            SD \\defeq (G, M, \\ell)\n        \\end{align}\n        where $G$ is a finite multiset of \\textit{edges}, $M$ is a finite multiset of \\textit{boxes} and $\\ell$ a labelling of the $nodes(G)$ and of $principals(M)$.\n    \\end{definition}\n    From here, we can convert solo calculus to diagrams, where composition is intuitively just including two separate diagrams together and scope is simply any connected nodes labelled by $\\ell$.\n    There are then four required reduction cases (edge-edge, edge-box, box-box and box internals) which can be deduced from the definition of the calculus.\n\n\n    \\begin{definition}{(Diagram Reduction)\\\\}\n        Let $G, G_1, G_2 \\ldots$ be arbitrary graphs, $M, M'$ arbitrary box multisets, $\\alpha \\defeq \\langle a, a_1 \\ldots a_k \\rangle_i$, $\\beta \\defeq \\langle a, a_1' \\ldots a_k' \\rangle_o$, $\\sigma \\defeq a_i \\mapsto a_i'$, $\\rho$ a arbitrary but fresh relabelling and $G\\sigma$ shorthand for $G[\\sigma]$ the application of the renaming $\\sigma$ on the edges of G.\n        $\\alpha$ and $\\beta$ need not be fixed to input and output respectively, but must be opposite polarity.\n        Then, the following reductions may be made:\n        \\begin{align}\n            (G \\cup \\{\\alpha, \\beta\\}, M, \\ell)                                                                                     & \\rightarrow (G\\sigma, M\\sigma, \\ell') \\\\\n            (G_1 \\cup \\{\\alpha\\}, M \\defeq \\langle G_2 \\cup \\{\\beta\\}, S \\rangle, \\ell)                                             & \\rightarrow ((G_1 \\cup G_2\\rho)\\sigma, M\\sigma, \\ell') \\\\\n            (G, M \\defeq \\{\\langle \\{ \\alpha \\} \\cup G_1, S_1 \\rangle,\\langle \\{ \\beta \\} \\cup G_2, S_2 \\rangle\\} \\cup M', \\ell)    & \\rightarrow ((G \\cup G_1\\rho \\cup G_2\\rho)\\sigma, M\\sigma, \\ell') \\\\\n            (G, M \\defeq \\langle \\{ \\alpha, \\beta \\} \\cup G_1, S \\rangle \\cup M', \\ell)                                             & \\rightarrow ((G \\cup G_1\\rho)\\sigma, M\\sigma, \\ell')\n        \\end{align}\n        where each represents reduction of an edge-edge, edge-box, box-box and of box internals respectively.\n    \\end{definition}\n\n\n    \\begin{example*}\n        \\begin{figure}[H]\n            \\centering\n            \\begin{subfigure}{0.4\\linewidth}\n                \\centering\n                \\begin{tikzpicture}[transform shape, every node/.style={circle, fill=black!100, inner sep=0.05cm}]\n                    \\coordinate[anchor=center](nw);\n                    \\coordinate[below=3cm of nw](sw);\n                    \\coordinate[right=3cm of nw](ne);\n                    \\coordinate[below right=3cm and 3cm of nw](se);\n                    \\draw[-] (nw) -- (ne) -- (se) -- (sw) -- (nw);\n                    \\node[right=1.5cm of sw, label=below left:{$x$}](x){};\n                    \\coordinate[below=1cm of x](xba){};\n                    \\coordinate[above=1cm of x](xaa){};\n                    \\node[above left=1cm of xaa](v){};\n                    \\node[above right=1cm of xaa](w){};\n                    \\node[below left=1cm of xba, label=left:{$y$}](y){};\n                    \\node[below right=1cm of xba, label=right:{$z$}](z){};\n                    \\draw[-{<[scale=2]}] (xaa) -- (x);\n                    \\draw[-{>[scale=2]}] (xba) -- (x);\n                    \\draw[-{>[scale=2]}] (w) to [out=140, in=40] (v);\n                    \\draw[-] (w) -- (xaa) -- (v);\n                    \\draw[-] (y) -- (xba) -- (z);\n                \\end{tikzpicture}\n                \\caption*{$\\bar{x}\\, y z \\, | \\, !(uv)(x \\, u v \\, | \\, \\bar{u} \\, v)$}\n            \\end{subfigure}\n            $\\longrightarrow$\n            \\begin{subfigure}{0.4\\linewidth}\n                \\centering\n                \\begin{tikzpicture}[transform shape, every node/.style={circle, fill=black!100, inner sep=0.05cm}]\n                    \\coordinate[anchor=center](nw);\n                    \\coordinate[below=3cm of nw](sw);\n                    \\coordinate[right=3cm of nw](ne);\n                    \\coordinate[below right=3cm and 3cm of nw](se);\n                    \\draw[-] (nw) -- (ne) -- (se) -- (sw) -- (nw);\n                    \\node[right=1.5cm of sw, label=below left:{$x$}](x){};\n                    \\coordinate[below=1cm of x](xba){};\n                    \\coordinate[above=1cm of x](xaa){};\n                    \\node[above left=1cm of xaa](v){};\n                    \\node[above right=1cm of xaa](w){};\n                    \\node[below left=1cm of xba, label=left:{$y$}](y){};\n                    \\node[below right=1cm of xba, label=right:{$z$}](z){};\n                    \\draw[-{<[scale=2]}] (xaa) -- (x);\n                    \\draw[-{>[scale=2]}] (w) to [out=140, in=40] (v);\n                    \\draw[-] (w) -- (xaa) -- (v);\n                    \\draw[-{>[scale=2]}] (z) -- (y);\n                \\end{tikzpicture}\n                \\caption*{$\\bar{y} \\, z \\, | \\, !(uv)(x \\, u v \\, | \\, \\bar{u} \\, v)$}\n            \\end{subfigure} \n        \\end{figure}\n    \\end{example*}\n\n\n    \\begin{remarks}\n        The solo calculus is found to be simple, expressive and remarkable in its capability to be visualised as a diagram.\n        For further reading,~\\cite{acyclic-solos} present in great detail the topics of the $\\pi$ and solo calculus, solo diagrams and furthermore differential interaction nets.\n    \\end{remarks}\n\n\n", "meta": {"hexsha": "55531d9dd50eb1422da20514f24b68d296a6be88", "size": 14540, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/lit-review/solo-calc.tex", "max_stars_repo_name": "AdamLassiter/solo-calc", "max_stars_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/lit-review/solo-calc.tex", "max_issues_repo_name": "AdamLassiter/solo-calc", "max_issues_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/lit-review/solo-calc.tex", "max_forks_repo_name": "AdamLassiter/solo-calc", "max_forks_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.8723404255, "max_line_length": 368, "alphanum_fraction": 0.5568775791, "num_tokens": 4088, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4198428145312696}}
{"text": "\\documentclass[nofootinbib,amssymb,amsmath]{revtex4}\n\\usepackage{mathtools}\n\\usepackage{amsthm}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{lmodern}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage{bm}\n\n%Put an averaged random variable between brackets\n\\newcommand{\\ave}[1]{\\left\\langle #1 \\right\\rangle}\n\n\\newcommand{\\vzero}{{\\bf 0}}\n\\newcommand{\\vI}{{\\bf I}}\n\\newcommand{\\vb}{{\\bf b}}\n\\newcommand{\\vd}{{\\bf d}}\n\\newcommand{\\vf}{{\\bf f}}\n\\newcommand{\\vc}{{\\bf c}}\n\\newcommand{\\vv}{{\\bf v}}\n\\newcommand{\\vz}{{\\bf z}}\n\\newcommand{\\vn}{{\\bf n}}\n\\newcommand{\\vm}{{\\bf m}}\n\\newcommand{\\vG}{{\\bf G}}\n\\newcommand{\\vQ}{{\\bf Q}}\n\\newcommand{\\vM}{{\\bf M}}\n\\newcommand{\\vW}{{\\bf W}}\n\\newcommand{\\vX}{{\\bf X}}\n\\newcommand{\\vPsi}{{\\bf \\Psi}}\n\\newcommand{\\vSigma}{{\\bf \\Sigma}}\n\\newcommand{\\vlambda}{{\\bf \\lambda}}\n\\newcommand{\\vpi}{{\\bf \\pi}}\n\\newcommand{\\valpha}{{\\bm{\\alpha}}}\n\\newcommand{\\vbeta}{{\\bm{\\beta}}}\n\\newcommand{\\vomega}{{\\bm{\\omega}}}\n\\newcommand{\\vLambda}{{\\bf \\Lambda}}\n\\newcommand{\\vA}{{\\bf A}}\n\n\\newcommand{\\code}[1]{\\texttt{#1}}\n\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{corollary}{Corollary}\n\n\\def\\SL#1{{\\color [rgb]{0,0,0.8} [SL: #1]}}\n\\def\\DB#1{{\\color [rgb]{0,0.8,0} [DB: #1]}}\n\n\\newcommand{\\HOM}{$\\mathsf{Hom}$}\n\\newcommand{\\HET}{$\\mathsf{Het}$}\n\\newcommand{\\REF}{$\\mathsf{Ref}$}\n\\newcommand{\\epss}{\\varepsilon}\n\n\\begin{document}\n\n\\title{Mathematical Notes on Mutect}\n\\author{David Benjamin}\n\\email{davidben@broadinstitute.org}\n\\affiliation{Broad Institute, 75 Ames Street, Cambridge, MA 02142}\n\\author{Takuto Sato}\n\\email{tsato@broadinstitute.org}\n\\affiliation{Broad Institute, 75 Ames Street, Cambridge, MA 02142}\n\n\\date{\\today}\n\n\\maketitle\n\n\\section{Somatic Likelihoods Model}\\label{introduction}\n\nWe have a set of potential somatic alleles and read-allele likelihoods $\\ell_{ra} \\equiv P({\\rm read~}r|{\\rm allele~}a)$.  We don't know which alleles are real somatic alleles and so we must compute, for each subset $\\mathbb{A}$ of alleles, the likelihood that the reads come from $\\mathbb{A}$.  A simple model for this likelihood is as follows: each read $r$ is associated with a latent indicator vector $\\vz_r$ with one-hot encoding $z_{ra} = 1$ iff read $r$ came from allele $a \\in \\mathbb{A}$.  The conditional probability of the reads $\\mathbb{R}$ given their allele assignments is\n\\begin{equation}\nP( \\mathbb{R} | \\vz, \\mathbb{A}) = \\prod_{r \\in \\mathbb{R}} \\prod_a \\ell_{ra}^{z_{ra}}.\n\\end{equation}\nThe alleles are not equally likely because there is a latent vector $\\vf$ of allele fractions -- $f_a$ is the allele fraction of allele $a$.  Since the components of $\\vf$ sum to one it is a categorical distribution and can be given a Dirichlet prior,\n\\begin{equation}\nP(\\vf) = {\\rm Dir}(\\vf | \\valpha).\n\\end{equation}\nThen $f_a$ is the prior probability that a read comes from allele $a$ and thus the conditional probability of the indicators $\\vz$ given the allele fractions $\\vf$ is\n\\begin{equation}\nP(\\vz | \\vf) = \\prod_r \\prod_a f_a^{z_{ra}}.\n\\end{equation}\nThe full-model likelihood is therefore\n\\begin{equation}\n\\mathbb{L}(\\mathbb{A}) = P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) = {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r \\left( f_a \\ell_{ra}\\right)^{z_{ra}}.\n\\label{full_likelihood}\n\\end{equation}\nAnd the marginalized likelihood of $\\mathbb{A}$, that is, the model evidence for allele subset $\\mathbb{A}$, is\n\\begin{equation}\nP(\\mathbb{R} | \\mathbb{A}) = \\sum_\\vz \\int d \\vf \\, {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r \\left( f_a \\ell_{ra}\\right)^{z_{ra}},\n\\label{evidence}\n\\end{equation}\nwhere the integral is over the probability simplex $\\sum_a f_a = 1$.\n\nThe integral over $\\vf$ is the normalization constant of a Dirichlet distribution and as such we can simply look up its formula.  However, the sum over all values of $\\vz$ for all reads has exponentially many terms.  We will get around this difficulty by handling $\\vz$ with a mean-field approximation in which we factorize the likelihood as $\\mathbb{L} \\approx q(\\vz) q(\\vf)$.  This approximation is exact in two limits: first, if there are many reads, each allele is associated with many reads and therefore the Law of Large Numbers causes $\\vf$ and $\\vz$ to become uncorrelated.  Second, if the allele assignments of reads are obvious $\\vz_r$ is effectively not a random variable at all (there is no uncertainty as to which of component is non-zero) and also becomes uncorrelated with $\\vf$.\n\nIn the variational Bayesian mean-field formalism the value of $\\vf$ that $\\vz$ ``sees'' is the expectation of $\\log \\mathbb{L}$ with respect to $q(\\vf)$ and vice versa.  That is,\n\\begin{equation}\nq(\\vf) \\propto {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r f_a^{\\bar{z}_{ra}} \\propto {\\rm Dir}(\\vf | \\valpha + \\sum_r \\bar{\\vz}_r),\n\\label{qf}\n\\end{equation}\nwhere $\\bar{z}_{ra} \\equiv E_q \\left[ z_{ra} \\right]$, and\n\\begin{equation}\nq(\\vz_r) = \\prod_a \\left( \\tilde{f}_a \\ell_{ra}\\right)^{z_{ra}}, \\tilde{f}_a = \\exp E[\\ln f_a]\n\\end{equation}\nBecause $q(\\vz)$ is categorical and $q(\\vf)$ is Dirichlet\\footnote{Note that we didn't \\textit{impose} this in any way.  It simply falls out of the mean field equations.} the necessary mean fields are easily obtained and we have\n\\begin{equation}\n\\bar{z}_{ra} = \\frac{\\tilde{f}_a \\ell_{ra}}{\\sum_{a^\\prime} \\tilde{f}_{a^\\prime} \\ell_{ra^\\prime}}\n\\label{z_mean_field}\n\\end{equation}\nand\n\\begin{equation}\n\\ln \\tilde{f}_a = \\psi(\\alpha_a + \\sum_r \\bar{z}_{ra}) - \\psi(\\sum_{a^\\prime} \\alpha_{a^\\prime} + N)\n\\label{f_mean_field}\n\\end{equation}\nwhere $\\psi$ is the digamma function and $N$ is the number of reads.  To obtain $q(\\vz)$ and $q(\\vf)$ we iterate Equations \\ref{z_mean_field} and \\ref{f_mean_field} until convergence.  A very reasonable initialization is to set $\\bar{z}_{ra} = 1$ if $a$ is the most likely allele for read $r$, 0 otherwise.  Having obtained the mean field of $\\vz$, we would like to plug it into Eq \\ref{evidence}.  We can't do this directly, of course, because Eq \\ref{evidence} says nothing about our mean field factorization.  Rather, we need the variational approximation (Bishop's Eq 10.3) to the model evidence, which is\n\\begin{align}\n\\ln P(\\mathbb{R} | \\mathbb{A}) \\approx& \\sum_{\\vz} \\int d \\vf q(\\vz) q(\\vf) \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) - \\ln q(\\vz) - \\ln q(\\vf) \\right] \\\\\n=& E_q \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) \\right] - E_q \\left[ \\ln q(\\vz) \\right] - E_q \\left[ \\ln q(\\vf) \\right]. \\label{lagrangian}\n\\end{align}\nBefore we proceed, let's introduce some notation.  First, from Eq \\ref{qf} the posterior $q(\\vf)$ is\n\\begin{equation}\nq(\\vf) = {\\rm Dir}(\\vf | \\vbeta), \\quad \\vbeta = \\valpha + \\sum_r \\bar{\\vz}_r.\n\\end{equation}\nSecond, let's define the log normalization constant of a Dirichlet distribution as $g$ so that\n\\begin{equation}\n\\ln {\\rm Dir}(\\vf | \\vomega) = g(\\vomega) + \\sum_a (\\omega_a - 1) \\ln f_a, \\quad g(\\vomega) = \\ln \\Gamma(\\sum_a \\omega_a) - \\sum_a \\ln \\Gamma(\\omega_a).\n\\end{equation}\nFinally, define the Dirichlet mean log (aka ``that digamma stuff\") as $h$:\n\\begin{equation}\nE_{\\rm Dir(\\vf | \\vomega)} \\left[ \\ln f_a \\right] = \\psi(\\omega_a) - \\psi(\\sum_{a^\\prime} \\omega_{a^\\prime}) \\equiv h_a(\\vomega).\n\\end{equation}\n\nThe log of Eq \\ref{full_likelihood} is\n\\begin{equation}\n\\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) = g(\\valpha) + \\sum_a (\\alpha_a - 1) \\ln f_a + \\sum_{ra} z_{ra} (\\ln f_a + \\ln \\ell_{ra}).\n\\end{equation}\nand thus the first term in Eq \\ref{lagrangian} is\n\\begin{align}\nE_q \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) \\right] =& g(\\valpha) + \\sum_a (\\alpha_a - 1) h_a(\\vbeta) + \\sum_{ra}\\bar{z}_{ra} \\left( h_a(\\vbeta) + \\ln \\ell_{ra} \\right) \\\\\n=& g(\\valpha) + \\sum_a (\\beta_a - 1) h_a(\\vbeta) + \\sum_{ra}\\bar{z}_{ra} \\ln \\ell_{ra}, \\label{first_term}\n\\end{align}\nwhere we used the relationship $\\vbeta = \\valpha + \\sum_r \\bar{\\vz}_r$.\n\nThe second term in Eq \\ref{lagrangian} is\n\\begin{align}\n- E_q \\left[ \\ln q(\\vz) \\right] = - \\sum_{ra} \\bar{z}_{ra} \\ln \\bar{z}_{ra} \\label{second_term}.\n\\end{align}\n\nThe third term in Eq \\ref{lagrangian} is\n\\begin{align}\n- E_q \\left[ \\ln q(\\vf) \\right] = -g(\\vbeta) - \\sum_a (\\beta_a - 1) E_q [\\ln f_a] = -g(\\vbeta) - \\sum_a (\\beta_a - 1) h_a(\\vbeta) \\label{third_term}.\n\\end{align}\n\nAdding Eqs \\ref{first_term}, \\ref{second_term}, and \\ref{third_term} and noting the cancellation between parts of Eqs \\ref{first_term} and \\ref{third_term} we obtain\n\\begin{equation}\n\\ln P(\\mathbb{R} | \\mathbb{A}) \\approx g(\\valpha) - g(\\vbeta) +  \\sum_{ra} \\bar{z}_{ra} \\left( \\ln \\ell_{ra} - \\ln \\bar{z}_{ra} \\right).\n\\end{equation}\n\nWe now have the model evidence for allele subset $\\mathbb{A}$.  This lets us choose which alleles are true somatic variants.  It also lets us make calls on somatic loss of heterozygosity events.  Furthermore, instead of reporting max-likelihood allele fractions as before, we may emit the parameters of the Dirichlet posterior $q(\\vf)$, which encode both the maximum likelihood allele fractions and their uncertainty.\n\n\\section{Strand Artifact Model}\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.3\\textwidth]{strand_artifact_pgm.png}\n\\caption{\\label{fig:frog}The probabilistic graphical model}\n\\end{figure}\n\n\\begin{itemize}\n\t\\item $\\vz$ is a latent random variable having a 1-of-K representation. For each variant locus, $\\vz$ encodes the presence of strand artifact in forward reads ($[1, 0, 0]$), artifact in reverse reads ($[0, 1, 0]$), or no artifact ($[0, 0, 1]$)\n\t\\item $f \\sim \\text{Unif}(0, 1)$ is a prior distribution over alt allele fraction $f$\n\t\\item $\\epsilon \\sim \\text{Beta}(\\alpha, \\beta)$ is a prior distribution over the error probability on a read on the artifact strand. For instance, if we have strand artifact on the reverse strand (i.e. $z = [0, 1, 0]$), $\\epsilon$ is the probability that the sequencer reads a ref allele on a reverse read as alt\n\t\\item $x^+ | f, \\epsilon, z$ is the number of forward reads with the alt allele. It's a mixture of binomials, defined as follows:\n\t\\begin{equation}\n\tx^+ | f, \\epsilon, z \\sim\n\t\t\\begin{cases}\n\t\t\t\\text{Bin} (n^+, f + \\epsilon(1-f)) & z = \\mathrm{Art+}\\\\\n\t\t\t \\text{Bin} (n^+, f) \t\t\t& z = \\mathrm{Art-} \\\\\n\t\t\t \\text{Bin} (n^+, f)\t\t\t& z = \\mathrm{noArt}\n\t\t\\end{cases}\n\t\\end{equation}\n\\end{itemize}\n\n\n\nWe compute the conditional distributions of $x^-$  analogously.\n\nHaving observed the read counts in the forward and reverse directions, we can compute the posterior probabilities of the latent variable $z$.  Below we derive the unnormalized posterior probability of strand artifact in forward reads ($z = art+$), given that we observed $x^+$ forward alt reads and $x^-$ reverse alt reads. We use a shorthand $z_0$ to denote $z=art+$ for conciseness. \n\nFirst we will derive the likelihood $p(x^+, x^-, f, \\epsilon | z_0)$\n\\begin{align}\np(x^+, x^- | z_0)  &= \\iint_{f, \\epsilon}  p(x^+, x^-, f, \\epsilon | z_0) \\,df\\,d\\epsilon \\\\\n\t\t\t  &= \\iint_{f, \\epsilon}  p(f) p(\\epsilon) p(x^+, x^- | z_0, f, \\epsilon) \\,df\\,d\\epsilon \\\\\n\t\t\t  &= \\iint_{f, \\epsilon}  p(f) p(\\epsilon) p(x^+ | z_0, f, \\epsilon) p(x^- | z_0, f, \\epsilon) \\,df\\,d\\epsilon \\\\\n\t\t\t  &= \\iint_{f, \\epsilon}  p(\\epsilon) p(x^+ | z_0, f, \\epsilon) p(x^- | z_0, f, \\epsilon) \\,df\\,d\\epsilon \\label{watershed} \\\\\n\t\t\t  &= \\iint_{f, \\epsilon}  \\mathrm{Beta}(\\epsilon|\\alpha, \\beta) \\mathrm{Bin}(x^+ | f + \\epsilon(1-f), n^+) \\mathrm{Bin}(x^- | f, n^-) \\,df\\,d\\epsilon\n\\end{align}\n\nThe posterior probability of strand artifact in forward reads is therefore\n\n\\begin{align}\np(z_0 |x^+, x^-) & \\propto p(z_0) p(x^+, x^- | z_0) \\\\\n\t\t\t & = p(z_0) \\iint_{f, \\epsilon}  \\mathrm{Beta}(\\epsilon|\\alpha, \\beta) \\mathrm{Bin}(x^+ | f + \\epsilon(1-f), n^+) \\mathrm{Bin}(x^- | f, n^-) \\,df\\,d\\epsilon\n\\end{align}\n\nThe derivation for the probability of strand artifact on reverse strand is analogous.\n\nFor the case of no strand artifact, the derivation of likelihoods is identical up to (\\ref{watershed}). Here we can simply the equation to a single integral over $f$ because the conditional probabilities of $x^+$ and $x^-$ do not depend on $\\epsilon$. We use a shorthand $z_2$ for $z=\\mathrm{noArt}$\n\n\\begin{align}\np(x^+, x^- | z_2)  &= \\iint_{f, \\epsilon}  p(\\epsilon) p(x^+ | z_2, f, \\epsilon) p(x^- | z_2, f, \\epsilon) \\,df\\,d\\epsilon \\nonumber \\\\\n\t\t\t  &= \\int_{f}  p(x^+ | z_2, f) p(x^- | z_2, f) \\,df \\int_{\\epsilon}  p(\\epsilon) d\\epsilon \\\\\n\t\t\t  &= \\int_{f}  \\mathrm{Bin}(x^+ | f, n^+) \\mathrm{Bin}(x^- | f, n^-) \\,df\n\\end{align}\n\nAnd the posterior probability is\n\n\\begin{align}\np(z_2 |x^+, x^-) & \\propto p(z_2) p(x^+, x^- | z_2) \\\\\n                         & = p(z_2) \\int_{f}  \\mathrm{Bin}(x^+ | f, n^+) \\mathrm{Bin}(x^- | f, n^-) \\,df\n\\end{align}\n\n\n\\section{Germline Filter}\\label{germline-filter}\nSuppose we have detected an allele such that its (somatic) likelihood in the tumor is $\\ell_t$ and its (diploid) likelihood in the normal is $\\ell_n$.  By convention, both of these are relative to a likelihood of $1$ for the allele \\textit{not} to be found.  If we have no matched normal, $\\ell_n = 1$.  Suppose we also have the population allele frequency $f$ of this allele.  Then the prior probability for the normal to be heterozygous or homozygous alt for the allele is $2f(1-f) + f^2$ and the prior probability for the normal genotype not to contain the allele is $(1-f)^2$.  Finally, suppose that the prior for this allele to arise as a somatic variant is $\\pi$.\n\nWe can determine the posterior probability that the variant exists in the normal genotype by calculating the unnormalized probabilities of four possibilities:\n\\begin{enumerate}\n\\item The variant exists is both the normal and the tumor samples.  This has unnormalized probability $\\left(2f(1-f) + f^2 \\right) \\ell_n \\ell_t (1 - \\pi)$.\n\\item The variant exists in the tumor but not the normal.  This has unnormalized probability $(1-f)^2 \\ell_t \\pi$.\n\\item The variant exists in neither the tumor nor the normal.  This has unnormalized probability $(1-f)^2 (1 - \\pi)$.\n\\item The variants exists in the normal but not the tumor.  This is biologically very unlikely.  Furthermore, if it \\textit{did} occur we wouldn't care about filtering the variant as a germline event because we wouldn't call it as a somatic event.  Thus we neglect this possibility.\n\\end{enumerate}\n\nNormalizing, we obtain the following posterior probability that an allele is a germline variant:\n\\begin{equation}\nP({\\rm germline}) = \\frac{(1)}{(1) + (2) + (3)} = \\frac{\\left(2f(1-f) + f^2 \\right) \\ell_n \\ell_t (1 - \\pi)}{\\left(2f(1-f) + f^2 \\right) \\ell_n \\ell_t (1 - \\pi) + (1-f)^2 \\ell_t \\pi + (1-f)^2 (1 - \\pi)}.\n\\end{equation}\n\nTo filter, we set a threshold on this posterior probability.\n\n\\end{document}", "meta": {"hexsha": "93dad40664b8e86db8302d0c0813ab10ee87e9dc", "size": 14584, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/mutect/mutect.tex", "max_stars_repo_name": "YTLogos/gatk", "max_stars_repo_head_hexsha": "9dab6d2e95e25d19c35243bd04a71551d97b8316", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/mutect/mutect.tex", "max_issues_repo_name": "YTLogos/gatk", "max_issues_repo_head_hexsha": "9dab6d2e95e25d19c35243bd04a71551d97b8316", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/mutect/mutect.tex", "max_forks_repo_name": "YTLogos/gatk", "max_forks_repo_head_hexsha": "9dab6d2e95e25d19c35243bd04a71551d97b8316", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.0209205021, "max_line_length": 794, "alphanum_fraction": 0.6812945694, "num_tokens": 4970, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.41984280658781}}
{"text": "\\section{Introduction}\n\nConsider classic supervised binary classification.  A learner is fit to a training set consisting of labeled examples from the positive and negative classes.  In contrast, \\textit{Positive-unlabeled} (PU) \\textit{learning} is a form of \\textit{partially-supervised} binary classification where labeled data exists for only one class, i.e.,~positive.  The training set consists of a (positive) labeled set,~$\\Pos$, and an unlabeled set,~$\\Unlabel$, which is composed of both positive and negatives examples all of whose labels are unknown.  By convention, ${\\Pos\\cap\\Unlabel=\\emptyset}$.  PU~learning is applicable to both the \\textit{transductive} setting, where the goal is to label~$\\Unlabel$ as accurately as possible, as well as the \\textit{inductive} setting, where the objective is to maximize the generalization performance on an unseen test set.\n\nThere are many applications where labeled data for one class may be unavailable or prohibitively expensive/difficult to collect. Domains where PU~learning has been applied include: land-cover classification~\\cite{Li:2011}, protein similarity prediction~\\cite{Elkan:2008}, disease gene identification~\\cite{Yang:2012}, deceptive/incentivized review identification~\\cite{Ren:2014}, targeted marketing~\\cite{Yi:2017}, and prescription drug interaction analysis~\\cite{Liu:2017}. The PU~learning framework can also be used for outlier detection given a set of inlier examples.~\\cite{Scott:2009}\n\nState-of-the-art PU learning algorithms generally rely on a cost-sensitive learning framework where each unlabeled example is simultaneously treated as both positive \\textit{and} negative valued with each instance's class weights proportional to its specific label confidence.~\\cite{Elkan:2008}  These previous works generally made one or more assumptions about the composition of~$\\Pos$ and~$\\Unlabel$. Most PU~learning paradigms use more traditional machine learning algorithms such as support vector machines~\\cite{Elkan:2008} and logistic regression~\\cite{Lee:2003}.  We are not aware of any previous PU~research that specifically focused on leveraging the significant, recent advances in deep learning.\n\nThe primary contribution of this work is \\textit{\\toolname}, a new autoencoder-based positive-unlabeled learner.  The remainder of this document is structured as follows.  Section~\\ref{sec:Siamese} describes the Siamese neural network, which inspired this work.  Section~\\ref{sec:Toolname} describes \\toolname's neural architecture and reviews the novel learner's training algorithm including our custom PU~loss functions.  Section~\\ref{sec:Experiments} describes our experimental setup and compares the performance of our algorithm against a~PU and supervised baseline.  Section~\\ref{sec:FutureWork} outlines deficiencies identified with our algorithm and proposes future work that may address them.\n\n", "meta": {"hexsha": "677b988f7905dbbe63cef35d152cc6908e88b64b", "size": 2881, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "project/final_report/introduction.tex", "max_stars_repo_name": "ZaydH/cis572", "max_stars_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "project/final_report/introduction.tex", "max_issues_repo_name": "ZaydH/cis572", "max_issues_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project/final_report/introduction.tex", "max_forks_repo_name": "ZaydH/cis572", "max_forks_repo_head_hexsha": "8b57f99c268ddb0c160266803ca96b3999beab4c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 261.9090909091, "max_line_length": 853, "alphanum_fraction": 0.8094411663, "num_tokens": 647, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160666, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.41984280658781}}
{"text": "\\chapter{Background} \n\\label{chapter:background}\nInformation retrieval (IR) is the activity of obtaining information resources which are relevant to a given query. In terms of semantic similarity, the task of information retrieval is to find documents which are semantically similar to a given query. One of the easiest approaches for finding relevant documents given a query is TFIDF.\nTFIDF, short for term frequency inverse document frequency, is an information retrieval technique that shows how important a word is to a document. Another information retrieval algorithm known as BM25 (BM stands for Best Match) \\cite{robertson2009probabilistic} can be used to retrieve matching documents according to their relevance to a given query. \\cite{dumais2004latent} introduced a word embedding method as an extension of TDIDF known as Latent Semantic Analysis (LSA). \\cite{mikolov2013efficient}, \\cite{pennington2014glove} and \\cite{shazeer2016swivel} have introduced neural network based word embedding models which have now become benchmarks in semantic similarity extraction.\n\n\n\\section{Summary of relevant approaches}\nThe most naive and intuitive way of finding relevant documents given a query term is to use term frequency (TF). Term frequency assumes that the more frequently the given query term appears in a document the more relevant that document is to the given query. Term frequency, however, suffers from a critical problem: all words are considered equally important when it comes to assessing relevancy on a query. In fact, though some words appear multiple times in a document they have very little discriminating power  in determining the relevancy. For instance, a collection of documents on football is likely to have the word football or soccer in almost every document. To circumvent this issue a technique known as inverse document frequency (IDF) is used to  attenuate the effect of words that occur too often in the collection of documents to be meaningful for relevance determination.\nWe define the inverse frequency of a word $w$ as follows:\n\n\\begin{displaymath}\n\\mbox{IDF}_w = \\log {N\\over \\mbox{DF}_w}.\n\\end{displaymath}\n\nwhere $DF_{w}$ is the document frequency and is defined as the number of documents in the collection that contain a word $w$ and N is the total number of documents. Thus the inverse document frequency of a rare word is high, whereas the inverse document frequency of a frequent word is likely to be low. Each word has its own term frequency and inverse document frequency score, the product of the two scores is called the TFIDF weight of that word. \\citet{ramos2003using} provide evidence that TFIDF returns\ndocuments highly correlated to the given query. Different weight schemes for these counts lead to a variety of TFIDF ranking features. One very successful TFIDF\nformulation is known as BM25 \\citep{robertson2009probabilistic}.\nBM25  is a bag-of-words information retrieval function that ranks a set of documents based on their relevance to the query terms. Tweaking different components and parameters produce different variations of the BM25. \\citet{mitra2016dual} have shown BM25 to be effective in information retrieval and have also proposed using it in an ensemble model along with another embedding model, namely Word2Vec. \n\n\n<<<<<<< Updated upstream\nAnother extension introduced by \\citet{dumais2004latent} is known as Latent Semantic Analysis(LSA). It uses Singular Value Decomposition (SVD) to perform dimensionality reduction on the TFIDF vectors resulting in smaller and better features. In Latent Semantic Analysis documents are represented as bags-of-words, where the order of the words in a document is not important, only how many times each word appears in a document. Furthermore, it assumes that words which are close in meaning will appear in similar pieces of text, a concept known as the distributional hypothesis. \\citet{boling2014semantic} have shown that Latent Semantic Analysis performs very well in finding semantic similarity between documents. Other popular models which use distributional hypothesis are Word2Vec \\citep{mikolov2013efficient} and Swivel \\citep{shazeer2016swivel}.\n=======\nAnother extension introduced by \\citet{dumais2004latent} is known as Latent Semantic Analysis(LSA). It uses Singular Value Decomposition (SVD) to perform dimensionality reduction on the TFIDF vectors resulting in smaller and better features. In Latent Semantic Analysis documents are represented as bags-of-words, where the order of the words in a document is not important, only how many times each word appears in a document. Furthermore, It assumes that words which are close in meaning will appear in similar pieces of text, a concept known as the distributional hypothesis. \\citet{boling2014semantic} have shown that Latent Semantic Analysis performs very well in finding semantic similarity between documents. Other popular models which use distributional hypothesis are Word2Vec \\citep{mikolov2013efficient} and Swivel \\citep{shazeer2016swivel}.\n>>>>>>> Stashed changes\n\\subsection{Word and Document Embeddings} \nWord embedding is a language modeling and feature learning technique in natural language processing(NLP) which maps words and phrases to the real number vector space of the desired dimension. \n\n\\paragraph{Word2Vec} Word2Vec model was  introduced by \\citet{mikolov2013efficient}. It uses distributed vector representation of words, a well-known framework for learning word vectors as shown in the Figure \\ref{fig:Word2Vec model}. The task is to learn to predict a word given other words in the context.\nMore formally, given a sequence of training words\n$w_{1}, w_{2}, w_{3}, ..., w_{T} $, the objective of the word vector model is to maximize the average log probability\n\\\\\n\\begin{equation}\n\\frac{1}{T} \\sum_{t=K}^{T-K} \\log p(w_{t} \\mid w_{t-1},....,w_{t+1}) \n\\end{equation}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=8cm, height=5cm]{w2v.png}\n\t\\caption{A framework for learning word vectors. Context of\n\t\tthree words (“the,” “cat,” and “sat”) is used to predict the fourth\n\t\tword (“on”). The input words are mapped to columns of the matrix\n\t\tW to predict the output word.}\n\t\\label{fig:Word2Vec model}\n\\end{figure}\n\n\n \\citet{bojanowski2016enriching} propose an extention of Word2Vec model known as FastText. It learns word\n representations while taking into account morphology.\n FastText models morphology by considering subword\n units, and representing words by a sum of its character\n n-grams.  Since FastText exploits subword information, it can also\n compute valid representations for out-of-vocabulary\n words. FastText obtains representations for out-of-vocabulary words by summing the vectors of character\n n-grams.\n  \n \\citet{ghosh2016characterizing} introduce a vocabulary driven Word2Vec method known as Dis2Vec which is\n used to generate disease specific word embeddings from unstructured health\n related news corpus. The input corpus D consists of a collection of word context pairs. Based on the vocabulary $V$, we can categorize the word context pairs into three types as shown\n below:\n \\\\\n \\begin{itemize}\n \t\\item $ D(d) = {(w, c): w \\in V ∧c \\in V }$, i.e. both the word w and the context c are in V\n \t\\item $D(\\rightharpoondown d) = {(w, c): w \\notin V ∧c \\notin V }$, i.e. neither the word w nor the context c are in V\n \t\\item $D(d)(\\rightharpoondown d) = {(w, c): w \\in V \\oplus c \\in V }$, i.e. either the word w is in V or the context c is in V but both cannot be in V\n \\end{itemize}\n \n Each of these categories of (w, c) pairs\n needs special consideration while generating disease specific embeddings.\n \n \n All the above mentioned word embedding models learn word embeddings from co-occurrence information in corpora.\n One drawback of learning word embeddings by this approach is that such methods will generally fail to tell synonyms from\n antonyms \\citep{mohammad2008computing}. For example, words like east and west\n or expensive and inexpensive appear in near-identical contexts, which means\n that distributional models produce very similar word vectors for such words. Such embedding is very undesirable when the goal is to find semantic similarity between documents. \n \\citet{mrksic:2016:naacl} proposed a novel counter-fitting method which injects antonym and\n synonymy constraints into vector space representations in order to circumvent this issue. Table \\ref{tab:counter_fitting} shows the results \\citet{mrksic:2016:naacl} achieved using their counter-fitting technique.\n \n \\begin{table}[h]\n \t\\begin{center}\n \t\t\\begin{tabular}{ c c c c } \n \t\t\t\\hline\n \t\t\t& east & expensive & British \\\\\n \t\t\t\\hline\n \t\t\t\\multirow{5}{4em}{Before} &\n \t\t\t\n \t\t\twest & pricey &  American\n \t\t\t\\\\ \n \t\t\t& north & cheaper & Australian\\\\ \n \t\t\t& south & costly & Britain\\\\ \n \t\t\t& southeast & overpriced & European\\\\\n \t\t\t& northeast & inexpensive & England\\\\\n \t\t\t\\hline\n \t\t\t\\multirow{5}{4em}{After} & \n \t\t\teastward & costly & Brits\\\\ \n \t\t\t& eastern & pricy & London\\\\ \n \t\t\t& easterly & overpriced & BBC\\\\ \n \t\t\t& - & pricey & UK\\\\ \n \t\t\t& - & afford & Britain\\\\ \n \t\t\t\\hline\n \t\t\\end{tabular}\n \t\t\n \t\\end{center}\n \t\n \t\\caption{Nearest neighbours for target words using GloVe\n \t\tvectors before and after counter-fitting} \\label{tab:counter_fitting}\n \\end{table}\n \n An alternative to\n the bag-of-words approach is to derive contexts\n based on the syntactic relations the word participates\n in as proposed by \\citet{levy2014dependency}.\n\nAll the above mentioned approaches are word embedding models and do not generalize to sentences and documents. \\citet{jsnior2017nilc} propose two methods for obtaining sentence and document level embeddings. The first approach obtains vector embeddings for documents by averaging the word embeddings of all the words in a document. The second approach also averages word embeddings, but each embedding vector is now weighted (multiplied) by the TFIDF\nof the word it represents.\n\\paragraph{Doc2Vec} An extension to the Word2Vec model known as Doc2Vec was introduced by \\citet{le2014distributed}. Doc2Vec is capable of constructing representations of input sequences of\nvariable length. Unlike some of the previous approaches, it is general and\napplicable to texts of any length: sentences, paragraphs, and documents. In\nDoc2Vec framework (see Figure \\ref{fig:doc2vec model}), every document is mapped to a unique\nvector, and every word is also mapped to a unique vector. The document\nvector and word vectors are averaged or concatenated to predict the next\nword in a context. The only difference to a Word2Vec model is the additional\ndocument token. It acts as a memory that remembers what is missing from\nthe current context or the topic of the document. The document vectors and\nword vectors are trained using stochastic gradient descent and the gradient\nis obtained via back-propagation.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=8cm, height=5cm]{para}\n\t\\caption[]{A framework for learning paragraph vector. This framework\n\t\tis similar to the framework presented in Figure 1; the only\n\t\tchange is the additional paragraph token that is mapped to a vector\n\t\tvia matrix D.}\n\t\\label{fig:doc2vec model}\n\\end{figure}\n\n\n\n\n\t", "meta": {"hexsha": "18cabd8cb1196f5340e9784581877fde1b52bf61", "size": 11169, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_text/chapter2_background/background.tex", "max_stars_repo_name": "Abas-Khan/thesis", "max_stars_repo_head_hexsha": "b733bd4382371203cc4992571890619a2e314047", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis_text/chapter2_background/background.tex", "max_issues_repo_name": "Abas-Khan/thesis", "max_issues_repo_head_hexsha": "b733bd4382371203cc4992571890619a2e314047", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis_text/chapter2_background/background.tex", "max_forks_repo_name": "Abas-Khan/thesis", "max_forks_repo_head_hexsha": "b733bd4382371203cc4992571890619a2e314047", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.6549295775, "max_line_length": 888, "alphanum_fraction": 0.7847613931, "num_tokens": 2656, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.4198428065878099}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage{INTERSPEECH2021}\n\n\\usepackage{cases}\n\\usepackage{listings}\n\\usepackage[framemethod=tikz]{mdframed}\n\n\\hyphenpenalty=10000 % Disables hyphenation.\n\n\\title{Procedural terrain generation}\n\\name{Willy Jacquet$^1$, Parra Yoan$^2$}\n%The maximum number of authors in the author list is twenty. If the number of contributing authors is more than twenty, they should be listed in a footnote or in acknowledgement section, as appropriate.\n\\address{\n  $^1$Author Affiliation\\\\\n  $^2$Co-author Affiliation}\n\\email{author@university.edu, coauthor@company.com}\n\n\\begin{document}\n\n\\maketitle\n% \n\\begin{abstract}\n%Thus we propose a model base on mathematical logic and it's resulting C++ implementation. The model is comprehensive by extensibility and therefore faster development of procedural terrain by inferring basic function properties and automatically optimizing code.\n\n\\textit{Symbolic computation} is seen as a trade-off between expressiveness and performance.\nMetaprogramming can minimize that overhead and enable further optimization. \n\n\n\\end{abstract}\n\n%\\noindent\\textbf{Index Terms}: speech recognition, human-computer interaction, computational paralinguistics\n\n\\section{Introduction}\n\nIn this paper we use procedural terrain generation as our primary application and thus tweaked the model for vector manipulation.\n\n\\section{State of the art}\n\n\\section{Symbolic computation}\n\nManipulation of \\textit{functions} instead of \\textit{values}.\n\\textit{Functions} are \\textit{first class citizens}.\n\nThe following model is designed to take advantage of \\textit{template metaprogramming} facilities. \n\n\\begin{mdframed}\nThis document is thus extended with insight about making a \\textit{C++} implementation out of it.\n\\end{mdframed}\n\n\\subsection{Generic functions}\n\nA \\textbf{reduction} predicate is introduced, noted $a \\rightarrow b$ ($a$ can be \\textit{reduced} to $b$). This predicate is \\textit{transitive}.\n\n\\begin{mdframed}\nA \\textit{function} can be represented as a \\textit{type} that holds no \\textit{non-static data member}.\nIn particular, if two instances of functions share the same type then they refer to the same function.\n\\end{mdframed}\n\nA \\textbf{tuple} is defined as a \\textit{sequence of objects} $(x_1,...,x_n)$.\n\nThe \\textbf{application} of a function $f$ with $x_1,...,x_n$ is noted $f(x_1,...,x_n)$.\nGenerally, the \\textit{application of a tuple} $(f_1,...,f_n)$ is defined as:\n\\begin{equation}\n(f_1,...,f_n)(x_1,...,x_n) \\rightarrow (f_1(x_1,...,x_n),...,f_n(x_1,...,x_n))\n\\end{equation}\nIf $f(x)$ cannot be further \\textit{reduced} ($\\neg\\exists a, f(x) \\rightarrow a$) then for $y_1,...y_n$:\n\\begin{equation}\nf(x)(y_1,...y_n) \\rightarrow f(x(y_1,...y_n))\n\\end{equation}\n\nA \\textbf{constant} $c$ is defined as a function that returns itself:\n\\begin{equation}\n\tc(x_1,...,x_n) \\rightarrow c\n\\end{equation}\n\n\\begin{mdframed}\nA \\textit{compile-time constant} can be represented as:\n\\begin{lstlisting}\ntemplate<typename Type, Type Value>\nstruct constant {};\n\\end{lstlisting}\nSpecial constants ($0$, $1$, $\\pi$, $e$, ...) can be introduced as specific symbols since they appear in many (number) sets.\n\\begin{lstlisting}\nstruct zero {}; struct one {}; ...\n\\end{lstlisting}\n\\end{mdframed}\n\nGiven $i \\in \\mathbb{N}^*$, the \\textbf{$i$-th projection} is a function that returns its $i$-th parameter:\n\\begin{numcases}{proj_i(x_1,...,x_n) \\rightarrow}\n\tx_i          & \\text{if $i \\leq n$} \\\\\n\tproj_{i - n} & \\text{otherwise} \\label{partial_projection}\n\\end{numcases}\nWhen the $i$-th projection is applied to the $i$-th parameter of each function, the notation is abbreviated:\n\\begin{equation}\n\tf(p_0,p_1,...) = f\n\\end{equation}\n\nThe \\textbf{arity} (function) can be defined as follows:\n\\begin{equation}\n\\begin{split}\n\tarity(c) &= 0 \\\\\n\tarity(proj_i) &= i \\\\\n\tarity(f(g_1,...,g_n)) &= max\\{arity(g_i)\\}_{i \\leq n}\n\\end{split}\n\\end{equation}\n\n\\subsection{Arithmetic functions}\n\n\\textit{Elementary arithmetic} functions are introduced with their usual definition:\n\\begin{equation}\n\\begin{split}\n\t(f + g)(x)      &\\rightarrow f(x) + g(x) \\\\\n\t(f - g)(x)      &\\rightarrow f(x) - g(x) \\\\\n\t(f \\times g)(x) &\\rightarrow f(x) \\times g(x) \\\\\n\t(f / g)(x)      &\\rightarrow f(x) / g(x)\n\\end{split}\n\\end{equation}\n\\textit{Partial application} is made possible by (\\ref{partial_projection}). For example:\n\\begin{equation}\n\\begin{split}\n\t(proj_0 + proj_1)(x) &\\rightarrow proj_0(x) + proj_1(x) \\\\\n\t                     &\\rightarrow x + proj_0\n\\end{split}\n\\end{equation}\n\\textit{Lazy evaluation} is introduced by establishing:\n\\begin{equation}\n\\begin{split}\n\t0 \\times g &\\rightarrow 0\\\\\n\tf \\times 0 &\\rightarrow 0\\\\\n\t0 / g      &\\rightarrow 0\n\\end{split}\n\\end{equation}\n\\begin{mdframed}\nThis can be implemented by providing \\textit{function overloads} having the first or second operand with the zero type.\n\\end{mdframed}\n\nThe current model can be extended with any usual function.\nAny function that is not mentioned in this section is defined with its usual meaning.\n\n\\subsection{Differential calculus}\n\nThe \\textbf{partial derivative} \\textit{with respect to $x$} is introduced for generic functions:\n\\begin{align}\n\\frac{\\partial}{\\partial x}(c) &\\rightarrow 0 \\text{ with $c$ a constant} \\\\\n\\frac{\\partial}{\\partial proj_j}(proj_i) &\\rightarrow\n\\begin{cases}{}\n1 & \\text{if $i = j$} \\\\\n0 & \\text{otherwise}\n\\end{cases} \\\\\n\\frac{\\partial}{\\partial x}(f(y)) &\\rightarrow \\frac{\\partial}{\\partial x}(y) \\times \\frac{\\partial}{\\partial x}(f)(y)\n\\end{align}\nFor arithmetic functions:\n\\begin{align}\n\\frac{\\partial}{\\partial x}(f + g) &\\rightarrow \\frac{\\partial}{\\partial x}(f) + \\frac{\\partial}{\\partial x}(g) \\\\\n\\frac{\\partial}{\\partial x}(f - g) &\\rightarrow \\frac{\\partial}{\\partial x}(f) - \\frac{\\partial}{\\partial x}(g) \\\\\n\\frac{\\partial}{\\partial x}(f \\times g) &\\rightarrow \\frac{\\partial}{\\partial x}(f) \\times g + f \\times \\frac{\\partial}{\\partial x}(g) \\\\\n\\frac{\\partial}{\\partial x}(f / g) &\\rightarrow \\frac{\\frac{\\partial}{\\partial x}(f) \\times g - f \\times \\frac{\\partial}{\\partial x}(g)}{g \\times g}\n\\end{align}\n\n\\subsection{Computational redundancy}\n\nSuppose that, provided a function $f \\times g$, you wish to compute its value \\emph{and} partial derivative for an argument $x$.\n\n\\subsection{Parallelization}\n\n\\subsection{Compilation}\n\n\\subsection{Performance}\n\n\\section{Common functions}\n\n\\subsection{Interpolation}\n\nProvided an interpolant $t \\in [0, 1]$.\nPolynomial interpolation with null derivatives is defined as follows:\n\\begin{itemize}\n\\item linea:r $t$\n\\item cubic: $-2t^3 + 3t^2$\n\\item quintic: $6t^5 - 15t^4 + 10t^3$\n\\end{itemize}\n\n\\subsection{Noise functions}\n\n\\textit{Coherent noise} can be used to model many natural phenomena and is characterized as follow \\cite{libnoise_coherent_noise}:\n\\begin{itemize}\n\\item \\textit{Referential transparency} i.e.\\ the same input produces the same output\n\\item A small change in the input value will produce a small change in the output value.\n\\item A large change in the input value will produce a random change in the output value\n\\end{itemize}\n\n\\textbf{Value noise} is achieved by interpolating random values on a regular grid along each axis until it is reduced to a single number.\n\n\\begin{figure}[h]\n\\includegraphics[width=\\linewidth]{img/value_noise_2d}\n\\caption{2D value noise with quintic interpolation.}\n\\end{figure}\n\n\n\\begin{lstlisting}[caption=Pseudo code implementation of 2D value noise]\nfloat noise(v:float[2]):\n  i=floor(v)\n  t=fract(v)\n  return interp(\n    interp(hash(i+[0,0]),hash(i+[0,1]),t[0]),\n    interp(hash(i+[1,0]),hash(i+[1,1]),t[0]),\n    t[1])\n\\end{lstlisting}\nWith $interp$ being an interpolation function. \n\n\\subsection{Worley noise}\n\n\\section{Terrain representation}\n\nA \\textbf{terrain} can be defined as a $C^2$ function $\\mathbb{R}^2 \\rightarrow \\mathbb{R}$.\nTherefore it is interpreted \n\n\\subsection{Coloration}\n\n\\subsection{Rendering}\n\n\\subsection{Implicit representation}\n\n\n\n\\section{Results}\n\n\\section{Appendix A: Derived functions}\n\nMany usual functions can be defined in terms of those previously introduced.\nDoing so makes inferring most properties (derivative, domain, ...) automatically possible.\n\n\\subsection{Generic functions}\n\\begin{flalign*}\nswap = (proj_1, proj_0)\n\\end{flalign*}\n\n\\subsection{Arithmetic functions}\n\\begin{equation*}\n\\begin{array}{ll}\nopposite    &= 0 - proj_0 \\\\\ninverse     &= 1 / proj_0 \\\\\n\\\\\ntranslation &= p1(p0 + p2) \\\\\nscaling     &= p1(p0 \\times p2)\n\\end{array}\n\\end{equation*}\n\n\\subsection{Calculus functions}\n\\begin{equation*}\n\\begin{array}{ll}\n\\partial(cos) &= - sin \\\\\n\\partial(sin) &= cos \\\\\n\\end{array}\n\\end{equation*}\n\n\\bibliographystyle{IEEEtran}\n\\bibliography{mybib}\n\n\\end{document}\n", "meta": {"hexsha": "9c9be7bb1cc658b4c84791ca4e9cc749dca02f74", "size": 8663, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "production/report/main.tex", "max_stars_repo_name": "e-Sharp/pom_gen_proc", "max_stars_repo_head_hexsha": "cef7a57620d52631c1e94f71c71e0455f9e1b653", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "production/report/main.tex", "max_issues_repo_name": "e-Sharp/pom_gen_proc", "max_issues_repo_head_hexsha": "cef7a57620d52631c1e94f71c71e0455f9e1b653", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "production/report/main.tex", "max_forks_repo_name": "e-Sharp/pom_gen_proc", "max_forks_repo_head_hexsha": "cef7a57620d52631c1e94f71c71e0455f9e1b653", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1915708812, "max_line_length": 263, "alphanum_fraction": 0.7224979799, "num_tokens": 2553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067208930584, "lm_q2_score": 0.519521321952093, "lm_q1q2_score": 0.41980814460975513}}
{"text": "\\documentclass[bigger]{beamer}\n\n\\input{header-beam} % change to header-handout for handouts\n\n% ====================\n\\title[Lecture 22]{Logic I F13 Lecture 22}\n\\date{December 3, 2013}\n% ====================\n\n\\input{header}\n\n\\setlength{\\fitchprfwidth}{14em}\n\n\\section{Logical Metatheory}\n\n\\subsec{Truth-functional Completeness}{\n\n\\bit\n\\item Every truth function can be expressed by a sentence containing only\n\\ben\n\\item $\\{\\land, \\lnot\\}$,\n\\item $\\{\\lor, \\lnot\\}$, \n\\item $\\{\\to, \\lnot\\}$,\n\\item $\\{\\to, \\bot\\}$, \n\\item $\\{\\mid\\}$: not-both, truth table: \\F\\T\\T\\T \n\\item $\\{\\downarrow\\}$: neither-nor, truth table: \\F\\F\\F\\T\n\\een\n\n\\item Others, e.g., $\\{\\land, \\lor\\}$, $\\{\\liff, \\lnot\\}$ are not\n  truth-functionally complete\n\n\\eit\n\n}\n\n\\subsec{Semantics}{\n\n\\bit\n\\item A \\emph{truth-value assignment} is an assignment of \\T{} or \\F{} to the atomic sentences (schematic letters in the truth-functional form)\n\\item A \\emph{FO structure} is a non-empty domain together with\n\\bit\n\\item extensions for each predicate symbol\n\\item objects in the domain for each constant symbol\n\\item functions for each function symbol\n\\eit\n\\item A tautology is a sentence (the truth-functional form of) which is true in all truth-value assignments\n\\item A FO validity is a sentence that's true in all FO interpretations \n\\eit\n\n}\n\n\n\\subsec{Soundness and Completeness}{\n\n\\bit\n\\item Soundness\n\nArguments have formal proofs only if they are valid\\\\\nIf there is a proof of B from premises $\\sf A_1, \\dots A_n$, then B is a consequence of $\\sf A_1, \\dots A_n$\n\n\\item Completeness\n\nArguments have formal proofs if they are valid\\\\\nIf B is a FO consequence of $\\sf A_1, \\dots A_n$, then there is a proof of B from premises $\\sf A_1, \\dots A_n$\\\\[2ex]\nProved by Kurt G\\\"odel (1929)\n\\eit\n}\n\n\\subsec{Other Proof Systems: Resolution}{\n\n\\bit\n\\item Fitch is a proof system for \\emph{validity/tautologies}\n\\item Also possible to design proof systems for dual notion: \\emph{unsatisfiability}\\\\\n(A is a tautology $\\Leftrightarrow$ $\\sf\\lnot A$ is unsatisfiable) \n\\item A \\emph{clause} is a disjunction $\\sf A_1 \\lor \\ldots \\lor A_n$\nwhere each $\\sf A_i$ is atomic or negated atomic.\n\\item The resolution rule:\n\\[\n\\fitchctx{\\pline{A_1 \\lor \\ldots \\lor A_n \\lor C}\\\\\n\\pline{B_1 \\lor \\ldots \\lor B_m \\lor \\lnot C}\\\\\n\\fpline{A_1 \\lor \\ldots \\lor A_n \\lor B_1 \\lor \\ldots \\lor B_m}}\n\\]\n\\item Preserves \\emph{joint satisfiability}\n\\item If you can prove the empty clause $\\bot$ from a set of clauses, they can't be\n  jointly satisfiable.\n\\eit\n\n}\n\n\\section{Theories and Decidability}\n\n\\subsec{Church-Turing Theorem}{\n\n\\begin{block}{Instance: Sentence A of any FO language\\\\\nProblem: Is A a FO validity?}\n\n\\bit\n\\item Undecidable\n\\item Proved independently by Alonzo Church and Alan Turing in 1935\n\\eit\n\\end{block}\n}\n\n\\subsec{Decidable Classes}{\n\n\\bit\n\\item The decision problem \\emph{in general} is undecidable\n\\item But special cases \\emph{can} be decided, e.g.:\n\\eit\n\\begin{block}{Instance: Sentence A with only 1-place predicate symbols\\\\\nProblem: Is A a FO validity?}\n\n\\bit\n\\item Decidable\n\\item Proved by Leopold L\\\"owenheim (1915)\n\\eit\n\\end{block}\n}\n\n\\subsec{Theories}{\n\n\\bit\n\\item A set of sentences of FOL also called a \\emph{theory}, and the sentences in it \\emph{axioms}\n\\item Some (types of) FO structures can be characterized \nas the models of a theory\n\\item Examples:\n\\bit\n\\item Mathematical theories (theory of orders, group theory, arithmetic)\n\\item KR classification systems, e.g., SNOMED-CT\n\\item Mereology, theories of truth, scientific theories\n\\eit\n\\eit\n\n}\n\n\\subsec{The Axiomatic Method}{\n\n\\bit\n\\item Theories + logic: what follows from axioms?\n\\item Axiomatic method: do science by investigating what follows from\n  the axioms of a theory \n\\item Logic can also determine:\n\\bit\n\\item Are axioms (in)consistent?\n\\item Are axioms independent, or is one superfluous?\n\\eit\n\\item Paradigm of axiomatic method: geometry (Euclid)\n\\eit\n}\n\n\\subsec{Examples of Theories: Linear Orders}{\n\nA relation $\\preceq$ on set $O$ is a \\emph{linear order} if\nit is a model of the theory LO with axioms:\n\\begin{align*}\n& \\forall x\\forall y((x \\preceq y \\land y \\preceq x) \\to x = y) & \\text{Antisymmetry}\\\\\n& \\forall x\\forall y\\forall z((x \\preceq y \\land y \\preceq z) \\to x \\preceq z) &\\text{Transitivity}\\\\\n& \\forall x\\forall y(x \\preceq y \\lor y \\preceq x) & \\text{Totality}\n\\end{align*}\nEvery total relation is reflexive: \n\\[\n{\\sf LO} \\models \\forall x\\, x \\preceq x\n\\]\n}\n\n\\subsec{Examples of Theories: Robinson's Q}{\n\nTheories of arithmetic, such as Robinson's theory Q:\n\\begin{align*}\n \\lnot\\exists x\\, (x + 1) & = 0\\\\\n \\forall x(x \\neq 0  \\to \\exists y\\, (y+1) & = x)\\\\\n \\forall x\\forall y((x + 1) = (y + 1)  \\to x & = y)\\\\\n \\forall x\\,(x + 0) & = x\\\\\n \\forall x\\forall y\\, (x + (y+1)) & = ((x + y) +1) \\\\\n \\forall x\\,(x \\times 0) & = 0\\\\\n \\forall x\\forall y\\, (x \\times (y + 1)) & = ((x \\times y) + x)\n\\end{align*}\n}\n\n\n\n\\subsec{Examples of Theories: SNOMED-CT}{\n\n\\begin{align*}\n\\texttt{bacterial } & \\texttt{pneumonia} = \\\\\n& \\texttt{is-a|bacterial infectious disease}\\\\\n& \\texttt{is-a|infective pneumonia}\\\\\n& \\texttt{causative agent|bacteria}\\\\\n& \\texttt{finding site|lung structure}\\\\[2ex]\n%\\begin{align*}\n\\forall x(& BacterialPneumonia(x) \\liff  \\\\\n& BacterialInfectiousDisease(x) \\land\\\\\n& InfectivePneumonia(x) \\land \\\\\n& \\exists y(HasCausativeAgent(x, y) \\land Bacteria(y)) \\land\\\\\n&\\exists y(HasFindingSite(x, y) \\land LungStructure(y)))\n\\end{align*}\n}\n\n\\subsec{Examples of Theories: SNOMED-CT}{\n\n\\bit\n\\item Over 300,000 concepts (predicate symbols), e.g.,\\\\\n\\bit \n\\item 1-place predicates:\\\\\nparts of body, findings, organisms, physical objects, procedures, substances, diseases, \\dots\n\\item 2-place predicates:\\\\\nhas finding site, has causative agent, with method, has active ingredient, laterality is, using device, \\dots\n\\eit\n\\item About 1,000,000 descriptions (axioms)\n\\item SNOMED-CT is decidable\n\\eit\n\n}\n\n\\subsec{Examples of Theories: Mereology}{\n\n\\bit\n\\item Mereology: the theory of the part-whole relation (\\emph{metaphysics})\n\\item Primitive relation: Pt(x, y), ``x is a part of y''\n\\item Some axioms:\n\\begin{align*}\n& \\forall x\\, Pt(x, x) & \\text{Reflexivity}\\\\\n& \\forall x\\forall y\\forall z((Pt(x,y) \\land Pt(y, z)) \\to Pt(x,z)) & \\text{Transitivity}\\\\\n& \\forall x\\forall y((Pt(x, y) \\land Pt(y, x)) \\to x = y) & \\text{Antisymmetry}\n\\end{align*}\n\\item Defined properties and relations\n\\[\nPP(x, y) \\dots Pt(x, y) \\land x \\neq y \\qquad At(x) \\dots \\lnot\\exists y\\,PP(y, x)\n\\]\n\\item Different theories settle questions differently, e.g.,\n\\bit\n\\item Are there atoms?\n\\item Does everything comprise at least one atom?\n\\item Is everything made of atomless ``gunk''?\n\\eit\n\\eit\n\n}\n\n\\subsec{Property Theories and Grelling's Paradox}{\n\n\\bit\n\\item Primitive relation: App(x ,y), ``x applies to y''\n\\item Proposed axiom (``comprehension''): For any wff P(y),\n\\[\\sf\n\\exists x\\forall y(App(x, y) \\liff P(y))\n\\]\n\\item Axiom is \\emph{inconsistent} (contradictory)\n\\item A property is \\emph{heterological} if it does not apply to itself, i.e., $\n\\sf \\lnot Ap(x, x)$\n\\item Is the property of being heterological itself heterological?\n\\eit\n\\fitchprf{\\pline{\\forall y(Ap(h, y) \\liff \\lnot Ap(y, y))}}{\n\\pline{Ap(h, h) \\land \\lnot Ap(h, h)}}\n}\n\n\\subsec{Completeness of Theories}{\n\n\\bit \n\\item A theory T is \\emph{complete} if for every sentence A in its language,\neither $\\sf T \\models A$ or $\\sf T \\models \\lnot A$\n\\item Every complete theory is decidable!\n\\item Some incomplete theories are still decidable (e.g., LO)\n\\item Some incomplete theories are incomplete\\emph{able}: no consistent extension is complete\n\\item Philosophical upshot of this: truth in the intended model(s) of the theory outstrips provability from the theory\n\\eit\n\\textbf{G\\\"odel's Incompleteness Theorem (1930)}\\\\\nArithmetic, set theory, mereology are incompleteable\n\n}\n\n\n\n\\section{Philosophy and Nonstandard Logics}\n\n\\subsec{Logical Consequence and FO Consequence}{\n\n\\bit\n\\item Philosophers interested in \\emph{valid arguments}, i.e.,\nthose where the conclusion is a \\emph{logical consequence} of the premises\n\\item Definition: There is no logically possible circumstance where the \npremises are true and the conclusion is false\n\\bit\n\\item \\emph{Important:} It does not say ``it \\emph{isn't the case} that the premises\nare true and the conclusion is false''\n\\item That would make every argument with \n\\bit\n\\item true premises, true conclusion\n\\item false premises, true conclusion\n\\item false premises, false conclusion\n\\eit \nlogically valid.  But that's not the case.\n\\item It says ``it is \\emph{impossible} that the premises could be true and the conclusion false!''\n\\eit\n\\item Difficulty: What logically possible circumstances are there?\n\\eit\n\n}\n\n\\subsec{What Logic Does For Logical Validity}{\n\n\\bit\n\\item Truth-tables, FO interpretations, Fitch give \\emph{sufficient conditions}\nfor validity, i.e.,\n\\bit\n\\item Every tautologically valid argument is logically valid\n\\item Every FO valid argument is logically valid\n\\item Every argument with a formal proof in Fitch is logically valid (soundness!)\n\\eit\n\\item Also provide tools to do more:\n\\bit\n\\item FO interpretations show why consequence fails\n\\item Show which relations between predicate symbols would suffice for logical validity\n\\item Provide ways to symbolize these relations\n\\item Formal theories about informal concepts can capture these relations, or elucidate consequences of assumptions about them (axiomatic method)\n\\eit\n\\eit\n\n}\n\n\\subsec{Nonstandard Logics}{\n\n\\bit\n\\item Formal models of logical consequence make a number of simplifying assumptions:\n\\bit\n\\item Only \\emph{determinate} properties allowed, e.g, no vague properties\n\\item Every (atomic) sentence either \\T{} or \\F; not both and nothing in between \n\\item Every constant must refer, i.e., no empty names\n\\item Only truth-functional connectives, e.g., no subjunctive contionals, ``because'', or tenses\n\\eit\n\\item Non-standard logics: expand FO logic to deal with these\n\\eit\n\n}\n\n\\subsec{Many-valued Logic}{\n\\def\\I{{\\color{blue}\\mathsf{U}}}\n\\bit\n\\item Add to the truth-values \\T{} and \\F, e.g.,\n\\bit\n\\item ``Undetermined'': neither true nor false\n\\[\n\\begin{array}{c|c}\nP & \\lnot P\\\\\n\\hline\n\\T & \\F \\\\\n\\I & \\I\\\\\n\\F & \\T\n\\end{array}\n\\qquad\n\\begin{array}{cc|c}\nP & Q & (P \\land Q)\\\\\n\\hline\n\\T & \\T & \\T\\\\\n\\T & \\I & \\I\\\\\n\\T & \\F & \\F\\\\\n\\I & \\T & \\I\\\\\n\\I & \\I & \\I\\\\\n\\I & \\F & \\F\\\\\n\\F & \\T & \\F\\\\\n\\F & \\I & \\F\\\\\n\\F & \\F & \\F\n\\end{array}\n\\qquad\n\\begin{array}{cc|c}\nP & Q & (P \\lor Q)\\\\\n\\hline\n\\T & \\T & \\T\\\\\n\\T & \\I & \\T\\\\\n\\T & \\F & \\T\\\\\n\\I & \\T & \\T\\\\\n\\I & \\I & \\I\\\\\n\\I & \\F & \\I\\\\\n\\F & \\T & \\T\\\\\n\\F & \\I & \\I\\\\\n\\F & \\F & \\F\n\\end{array}\n\\]\n\\item ``Inconsistent'': both true and false\n\\item Fuzzy truth values: any number between 0 and 1\n\\eit\n\\eit\n\n}\n\n\\subsec{Modal Logic}{\n\n\\bit\n\\item Alethic logic\\\\\n``It is possible that'' ($\\Diamond$), ``it is necessary that'' ($\\Box$)\n\\[\n\\Box A \\to A \\qquad \\Diamond\\Box A \\to \\Box A\n\\]\n\\item Epistemic logic: \n``It is known that'' (K)\n\\[\nKK A \\to K A\n\\]\n\\item Conditional logic\\\\\nSubjunctive conditionals, ``if it were true that \\dots, then\\\\ \\quad it would be true that --- ---'' ($\\strictif$)\n\\[\n(A \\strictif B) \\to (A \\to B)\n\\]\n\\item Temporal logic\\\\\n``It was true that'' (P), ``It will be true that'' (F)\n\\[\nF\\,P\\, A \\to (P\\, A \\lor A \\lor F\\, A)\n\\]\n\\eit\n\n}\n\n\\subsec{Christmas Trick}{\n\nIf the first sentence on this slide is true, \\\\\\qquad then Santa Claus exists.\n\nProof that Santa Claus exists:\n\\bens\n\\item The first sentence on this slide is true\\\\\\qquad (Assumption for\n  conditional proof).\n\\item If the first sentence on this slide is true, then Santa Claus exists (from 1, since if S is true, then S).  \n\\item Santa Claus exists (from (1) and (2), by modus ponens)\n\\item If the first sentence on this slide is true, Santa Claus exists\\\\\\qquad(from (1)--(3), by conditional proof).\n\\item We've just proved (4) [= the first sentence on this slide], so the first sentence on this slide is true.\n\\item Santa Claus exists (from (4) and (5), by modus ponens)\n\\een\n}\n\n\\end{document} \n\n\n\n\n\n", "meta": {"hexsha": "bf006b769a42282ad94e30dc32351dd31e8cbfb1", "size": 11982, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "279-lec22.tex", "max_stars_repo_name": "rzach/phil279", "max_stars_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-09-23T13:42:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-21T10:48:55.000Z", "max_issues_repo_path": "279-lec22.tex", "max_issues_repo_name": "rzach/phil279", "max_issues_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "279-lec22.tex", "max_forks_repo_name": "rzach/phil279", "max_forks_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5448275862, "max_line_length": 145, "alphanum_fraction": 0.6963779002, "num_tokens": 3866, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.8080672066194945, "lm_q1q2_score": 0.41980814340909484}}
{"text": "\\section{Conclusion}\n\n\\begin{frame}{Conclusion}\n\t\\begin{itemize}\n\t\t\\item The understanding of the thermalization process of gluons is key to find an appropriate description of the complex physical processes during RHICs.\n\t\t\\item Using \\alert{kinetic theory} and \\alert{statistical transport equations} we can estimate important quantities such as the \\alert{equilibration time} and understand the importance and differences of \\alert{elastic and inelastic collisions}.\n\t\t\\item The role of \\alert{Bose-Einstein condensation} during the thermalization process \n\t\t\\item It is possible to find \\alert{analytic solutions for a Nonlinear Boson Diffusion equation} providing further insights into the thermalization process.\n\n\t\\end{itemize}\n\\end{frame}", "meta": {"hexsha": "19ee780af281d1d9f4948835610a701c4900e493", "size": 745, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "talk/content/05_conclusion.tex", "max_stars_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_stars_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "talk/content/05_conclusion.tex", "max_issues_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_issues_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "talk/content/05_conclusion.tex", "max_forks_repo_name": "mathieukaltschmidt/Thermalization-of-Gluons", "max_forks_repo_head_hexsha": "4fa0a9503f82c007fbb196df3e665772b259355e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.7272727273, "max_line_length": 247, "alphanum_fraction": 0.8080536913, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4196843712038927}}
{"text": "\\documentclass{article}\r\n\r\n\\usepackage{fancyhdr}\r\n\\usepackage{extramarks}\r\n\\usepackage{amsfonts}\r\n\\usepackage{amsmath}\r\n\\usepackage{syntax}\r\n\\usepackage{stmaryrd}\r\n\\usepackage{mathpartir}\r\n\\usepackage{tipa}\r\n\r\n%\r\n% Basic Document Settings\r\n%\r\n\r\n\\topmargin=-0.45in\r\n\\evensidemargin=0in\r\n\\oddsidemargin=0in\r\n\\textwidth=6.5in\r\n\\textheight=9.0in\r\n\\headsep=0.25in\r\n\r\n\\linespread{1.1}\r\n\r\n\\pagestyle{fancy}\r\n\\chead{Globally Ordered Type System}\r\n\\lfoot{\\lastxmark}\r\n\\cfoot{\\thepage}\r\n\r\n\\renewcommand\\headrulewidth{0.4pt}\r\n\\renewcommand\\footrulewidth{0.4pt}\r\n\r\n\\setlength\\parindent{30pt}\r\n\r\n\\newcommand{\\Z}{\\mathbb{Z}}\r\n\\newcommand{\\Zt}{$\\Z$}\r\n\r\n% Create a relational rule\r\n% [#1] - Additional mathpartir arguments\r\n% {#2} - Name of the rule\r\n% {#3} - Premises for the rule\r\n% {#4} - Conclusions for the rule\r\n\\newcommand{\\relationRule}[4][]{\\inferrule*[lab={\\sc #2},#1]{#3}{#4}}\r\n\r\n\\newcommand{\\rel}[1]{\\ensuremath{\\llbracket {#1} \\rrbracket}}\r\n\\newcommand{\\ttt}{\\texttt}\r\n\\newcommand{\\transform}{\\rightsquigarrow}\r\n\\newcommand{\\proj}{\\pi}\r\n\\newcommand{\\ttuple}{(\\tau_1, \\ldots, \\tau_n)}\r\n\\newcommand{\\etuple}{(e_1,\\ldots,e_n)}\r\n\\newcommand{\\bool}{\\mathrm{bool}}\r\n\\newcommand{\\integer}{\\mathrm{int}}\r\n\\newcommand{\\option}{\\mathrm{option}}\r\n\\newcommand{\\uoption}[1]{(\\bool,#1)}\r\n\\newcommand{\\opt}[1]{\\texttt{opt-#1}}\r\n\\newcommand{\\varOf}[1]{\\texttt{varOf}(#1)}\r\n\r\n\\newcommand{\\oktype}{valid}\r\n\r\n\r\n\\begin{document}\r\n\\section*{The System}\r\nWe begin by defining a grammar of \"base types\". These are the types which are eligible to be stored in global variables. The particular set of base types is not important, but we believe the following ones give a good overview.\r\n\r\n\\begin{grammar}\r\n\t<$T$ (base types)> ::= Unit | Int | Bool | T * T\r\n\\end{grammar}\r\n\r\nEverything in the rest of this document is defined with respect to an ordered set $\\mathbb{G} = \\{g_1, \\dots, g_n\\}$ of \\emph{global variables}, each of which has an associated base type $T_i$. Our goal is to enforce that $g_1$ is always used before $g_2$, $g_2$ before $g_3$, and so on. For simplicity, we require that each global variable be used; however, we will later relax this restriction by adding subtyping.\r\n\r\nIn our model, a global variable is considered \\emph{used} until it is actually accessed. Note that this is different from a normal ordered type system, where any appearance of the variable is considered a use. To distinguish appearances from memory accesses, we adopt ref-cell-like syntax for dereferencing or updating global variables. Note that this is different from the user model in actual dpt, where global variables are viewed as simple values. Instead of the ref-cell operators, dpt contains several built-in functions with appropriate type signatures.\r\n\r\nThe \\emph{effects} $\\epsilon$ in this system specify which global variables have been used so far. Effects are represented as an integer from $1$ to $n+1$, where effect $i$ means that all global variables up to but not including $g_i$ have been used so far (that is, we expect to use $g_i$ next).\r\n\r\nWe will also wish to allow users to define functions which are polymorphic in effect; for example, a function which takes in any global variable, dereferences it, and returns the value. Such a function would have an \"effect signature\" of something like $\\alpha \\rightarrow \\alpha + 1$. To accommodate this, we will add polymorphic variables and a $+$ operation to our effect grammar.\r\n\r\nOur effects are also intertwined with the language's value types $\\tau$, in two ways. First, we have a special $\\texttt{ref} (T, \\epsilon)$ type for representing the value of a global variable. Second, function types must be altered to include their effect on the global variables. We do so by adding input and output effects to function types as well, using the form $(\\tau, \\epsilon) \\rightarrow (\\tau, \\epsilon)$.\r\n\r\nAll in all, we have the following grammar of types and effects.\r\n\r\n\\begin{grammar}\r\n\t<$\\epsilon$ (effects)> ::= 1 | 2 | \\dots | n + 1 | $\\alpha$ | $\\epsilon + \\epsilon$\r\n\t\r\n\t<$\\tau$ (types)> ::= T | $\\tau * \\tau$ | ref ($\\tau, \\epsilon$) | $\\forall \\alpha.(\\tau, \\epsilon) \\rightarrow (\\tau, \\epsilon)$\r\n\\end{grammar}\r\n\r\nNote that we use the convention that when representing effects, $\\epsilon$ represents any effect, Latin letters represent only integer effects, and Greek letters represent effect variables.\r\n\r\nNext, we define a simple functional language to use this system on:\r\n\r\n\\begin{grammar}\r\n\t<$x$ (variables)> ::= alphanumeric\r\n\t\r\n\t<$\\Gamma$ (environments)> ::= Maps from variables to values\r\n\t\r\n\t<$v$ (values)> ::= () | $\\Z$ | True | False | $(v, v)$ | \\textless$\\Gamma, \\alpha, (x : \\tau, \\epsilon), e $\\textgreater\\ | $g_1$ | \\dots | $g_n$\r\n\t\r\n\t<$e$ (expressions)> ::= $v$ | $x$ | $e + e$ | $(e,e)$ | fst $e$ | snd $e$ | let $x$ = $e$ in $e$ | if $e$ then $e$ else $e$ | !$e$ | $e := e$\r\n\t\\alt $\\texttt{fun}\\ [\\alpha]\\ (x:\\tau, \\epsilon)  \\rightarrow e$ | $e[\\epsilon]$ $e$\r\n\\end{grammar} \r\n\r\nNote that we treat the global variables as values in their own right in this system.\r\n\r\nThe $\\texttt{fun}\\ [\\alpha]$ syntax defines an effect-polymorphic function whose effects may use the universally quantified effect variable $\\alpha$. The $e[\\epsilon]$ $e$ syntax applies an effect-polymorphic function, instantiating $\\alpha$ with $\\epsilon$.\r\n\r\n\\clearpage\r\n\\section*{Typing Programs}\r\n\\subsection*{Effect Equivalence}\r\nOne may notice that our effect grammar allows us to write logically equivalent effects in different ways: for example, $1+1$ or $2$. To avoid this complication, we define an equivalence relation $\\equiv$ on effects as follows, using $\\oplus$ to represent integer addition:\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{effect-refl}{\r\n\t\t\\ \r\n\t}{\r\n\t\t\\epsilon \\equiv \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{effect-sym}{\r\n\t\t\\epsilon_2 \\equiv \\epsilon_1\r\n\t}{\r\n\t\t\\epsilon_1 \\equiv \\epsilon_2\r\n\t}\r\n\r\n\t\\relationRule{effect-trans}{\r\n\t\t\\epsilon_1 \\equiv \\epsilon_2\\\\\r\n\t\t\\epsilon_2 \\equiv \\epsilon_3 \r\n\t}{\r\n\t\t\\epsilon_1 \\equiv \\epsilon_3\r\n\t}\r\n\r\n\t\r\n\t\\relationRule{int-plus}{\r\n\t\ti \\oplus j = k\r\n\t}{\r\n\t\ti+j \\equiv k\r\n\t}\r\n\\\\\r\n\t\\relationRule{plus-comm}{\r\n\t\t\\\r\n\t}{\r\n\t\t\\epsilon_1 + \\epsilon_2 \\equiv \\epsilon_2 + \\epsilon_1\r\n\t}\r\n\r\n\t\\relationRule{plus-assoc}{\r\n\t\t\\\r\n\t}{\r\n\t\t(\\epsilon_1 + \\epsilon_2) + \\epsilon_3 \\equiv \\epsilon_1 + (\\epsilon_2 + \\epsilon_3)\r\n\t}\r\n\r\n\t\\relationRule{plus-cong}{\r\n\t\t\\epsilon_1 \\equiv \\epsilon_3\\\\\r\n\t\t\\epsilon_2 \\equiv \\epsilon_4 \r\n\t}{\r\n\t\t\\epsilon_1 + \\epsilon_2 \\equiv \\epsilon_3 + \\epsilon_4\r\n\t}\r\n\\end{mathpar}\r\n\r\n\\subsection*{Effect Substitution}\r\nIn order to define our typing relation, we will need to be able to perform substitution on types to eliminate $\\alpha$s. To do so, we define a standard capture-avoiding substitution relation $[\\epsilon/\\alpha]$, defined below.\r\n\r\n\\begin{align*}\r\n\t\\alpha[\\epsilon/\\alpha] & = \\epsilon\\\\\r\n\t\\beta[\\epsilon/\\alpha] & = \\beta\\ (\\mbox{if }\\beta \\neq \\alpha)\\\\\r\n\ti[\\epsilon/\\alpha] & = i\\\\\r\n\t(\\epsilon_1 + \\epsilon_2)[\\epsilon/\\alpha] & = \\epsilon_1[\\epsilon/\\alpha] + \\epsilon_2[\\epsilon/\\alpha]\r\n\\\\\\hfill\\\\\r\n\tT[\\epsilon/\\alpha] & = T\\\\\r\n\t(\\tau_1 * \\tau_2)[\\epsilon/\\alpha] & = \\tau_1[\\epsilon/\\alpha] * \\tau_2[\\epsilon/\\alpha]\\\\\r\n\t\\texttt{ref } (\\tau, \\epsilon_1)[\\epsilon/\\alpha] & = \\texttt{ref } (\\tau[\\epsilon/\\alpha], \\epsilon_1[\\epsilon/\\alpha])\\\\\r\n\t\\left(\\forall \\alpha.(\\tau_1, \\epsilon_1) \\rightarrow (\\tau_2, \\epsilon_2)\\right)[\\epsilon/\\alpha] & = \\forall \\alpha.(\\tau_1, \\epsilon_1) \\rightarrow (\\tau_2, \\epsilon_2)\\\\\r\n\t\\left(\\forall \\beta.(\\tau_1, \\epsilon_1) \\rightarrow (\\tau_2, \\epsilon_2)\\right)[\\epsilon/\\alpha] & = \\forall \\beta.(\\tau_1[\\epsilon/\\alpha], \\epsilon_1[\\epsilon/\\alpha]) \\rightarrow (\\tau_2[\\epsilon/\\alpha], \\epsilon_2[\\epsilon/\\alpha])\\ (\\mbox{if }\\beta \\neq \\alpha \\mbox{ and } \\beta \\mbox{ does not appear in } \\epsilon)\r\n\\end{align*}\r\n\r\n\\subsection*{Effect Ordering}\r\nWe define a standard $\\leq$ order on effects so we can compare them, using the $\\preceq$ symbol to indicate integer less-than-or-equals.\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{leq-refl}{\r\n\t\t\\\r\n\t}{\r\n\t\t\\epsilon \\leq \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{leq-trans}{\r\n\t\t\\epsilon_1 \\leq \\epsilon_2\\\\\r\n\t\t\\epsilon_2 \\leq \\epsilon_3 \r\n\t}{\r\n\t\t\\epsilon_1 \\leq \\epsilon_3\r\n\t}\r\n\r\n\t\\relationRule{leq-equiv}{\r\n\t\t\\epsilon_1 \\equiv \\epsilon_2\r\n\t}{\r\n\t\t\\epsilon_1 \\leq \\epsilon_2\r\n\t}\r\n\r\n\t\\relationRule{leq-int}{\r\n\t\ti \\preceq j\r\n\t}{\r\n\t\ti \\leq j\r\n\t}\r\n\r\n\t\\relationRule{leq-plus-1}{\r\n\t\t\\epsilon_1 \\leq \\epsilon_3\\\\\r\n\t\t\\epsilon_2 \\leq \\epsilon_4 \r\n\t}{\r\n\t\t\\epsilon_1 + \\epsilon_2 \\leq \\epsilon_3 + \\epsilon_4\r\n\t}\r\n\r\n\t\\relationRule{leq-plus-2}{\r\n\t\t\\\r\n\t}{\r\n\t\t\\epsilon_1 \\leq \\epsilon_1 + \\epsilon_2\r\n\t}\r\n\\end{mathpar}\r\n\r\n\\section*{The Typing Relation}\r\nType inference in this system simultaneously reasons about effects and regular types. As a result, the typing relation has an extra input and output, representing the state of the global variables before and after the expression, respectively.\r\n\r\nOur typing relation will thus have the form $\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau, \\epsilon$. As usual, $\\Gamma$ represents our current collection of bound variables; we treat it as a set. Our goal is that our program $p$ satisfies $\\emptyset, 1 \\vdash p\\ \\colon \\tau, n+1$ for some $\\tau$.\r\n\r\nWhen writing rules, we use the convention that the metavariable $x$ matches all \\emph{non-global} variables. We will always denote global variables using symbols of the form $g_i$. For the rest of these rules we will treat effects as being equal if they are equivalent.\r\n\r\nDefinition: a type $\\tau$ is said to be \\emph{\\oktype} if all sub-parts of $\\tau$ are \\oktype, and if $\\tau = \\forall \\alpha.(\\tau_1, \\epsilon_{in}) \\rightarrow (\\tau_2, \\epsilon_{out})$ implies $\\epsilon_{in} \\leq \\epsilon_{out}$.\r\n\r\nFor a given value environment $\\Gamma$, we define $\\Gamma_\\tau$ to be any typing environment with the same elements as $\\Gamma$ and such that $\\forall y \\in \\Gamma. \\emptyset, 1 \\vdash \\Gamma[y]\\ \\colon \\Gamma_\\tau[y], 1$.\r\n\r\n$\\texttt{fun } [\\alpha, \\beta] (f : (\\forall \\gamma. (\\tau, \\alpha) \\rightarrow (\\tau', \\beta)) = f\\ ...$\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{int}{\r\n\t\tn \\in \\Z\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash n\\ \\colon \\texttt{Int}, \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{true}{\r\n\t\t\\ \r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{True}\\ \\colon \\texttt{Bool}, \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{false}{\r\n\t\t\\ \r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{False}\\ \\colon \\texttt{Bool}, \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{Unit}{\r\n\t\t\\ \r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash ()\\ \\colon \\texttt{Unit}, \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{global variable}{\r\n\t\t\\\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash g_i\\ \\colon \\texttt{ref}(T_i, i), \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{Closure}{\r\n\t\t\\tau\\mbox{ is \\oktype}\\\\\r\n\t\t\\Gamma_\\tau[x := \\tau], \\epsilon_f \\vdash e\\ \\colon \\tau_1, \\epsilon_1\r\n\t}{\r\n\t\t\\Gamma_0, \\epsilon \\vdash\\ <\\Gamma, \\alpha, (x : \\tau, \\epsilon_f), e >\\ \\colon \\forall \\alpha.(\\tau, \\epsilon_f) \\rightarrow (\\tau_1, \\epsilon_1), \\epsilon\r\n\t}\r\n\\end{mathpar}\r\n\r\nNow we can write rules for non-value expressions:\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{local variable}{\r\n\t\t\\Gamma[x] = \\tau\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash x\\ \\colon \\tau, \\epsilon\r\n\t}\r\n\r\n\t\\relationRule{plus}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\texttt{Int}, \\epsilon_1\\\\\r\n\t\t\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\texttt{Int}, \\epsilon_2\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1 + e_2\\ \\colon \\texttt{Int}, \\epsilon_2\r\n\t}\r\n\t\r\n\t\\relationRule{pair}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\tau_1, \\epsilon_1\\\\\r\n\t\t\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2, \\epsilon_2\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash (e_1, e_2)\\ \\colon \\tau_1 * \\tau_2, \\epsilon_2\r\n\t}\r\n\r\n\t\\relationRule{fst}{\r\n\t\t\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau_1 * \\tau_2, \\epsilon_1\\\\\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{fst } e\\ \\colon \\tau_1, \\epsilon_1\r\n\t}\r\n\r\n\t\\relationRule{snd}{\r\n\t\t\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau_1 * \\tau_2, \\epsilon_1\\\\\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{snd } e\\ \\colon \\tau_2, \\epsilon_1\r\n\t}\r\n\r\n\t\\relationRule{let}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\tau_1, \\epsilon_1\\\\\r\n\t\t\\Gamma[x := \\tau_1], \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2, \\epsilon_2\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{let } x = e_1 \\texttt{ in } e_2\\ \\colon \\tau_2, \\epsilon_2\r\n\t}\r\n\r\n\t\\relationRule{if}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\texttt{Bool}, \\epsilon_1\\\\\r\n\t\t\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\tau, \\epsilon_2\\\\\r\n\t\t\\Gamma, \\epsilon_1 \\vdash e_3\\ \\colon \\tau, \\epsilon_2\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{if } e_1 \\texttt{ then } e_2 \\texttt{ else } e_3\\ \\colon \\tau, \\epsilon_2\r\n\t}\r\n\\end{mathpar}\r\n\r\nNow let's finally write some rules that actually change $\\epsilon$.\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{deref}{\r\n\t\t\\Gamma, \\epsilon \\vdash e\\ \\colon \\texttt{ref}(\\tau, \\epsilon_1), \\epsilon_1\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash !e\\ \\colon \\tau, \\epsilon_1+1\r\n\t}\r\n\r\n\\relationRule{update}{\r\n\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\tau, \\epsilon_1\\\\\r\n\t\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\texttt{ref}(\\tau, \\epsilon_2), \\epsilon_2\r\n}{\r\n\t\\Gamma, \\epsilon \\vdash e_2 := e_1\\ \\colon \\texttt{Unit}, \\epsilon_2+1\r\n}\r\n\\end{mathpar}\r\n\r\nAnd finally, the function rules: \r\n\\begin{mathpar}\r\n\t\\relationRule{abs}{\r\n\t\t\\tau\\mbox{ is \\oktype}\\\\\r\n\t\t\\Gamma[x := \\tau], \\epsilon_f \\vdash e\\ \\colon \\tau_1, \\epsilon_1\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash \\texttt{fun } [\\alpha] (x : \\tau, \\epsilon_f) \\rightarrow e\\ \\colon \\forall \\alpha.(\\tau, \\epsilon_f) \\rightarrow (\\tau_1, \\epsilon_1), \\epsilon\r\n\t}\r\n\t\r\n\t\\relationRule{app}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1\\ \\colon \\forall \\alpha.(\\tau_2, \\epsilon_2) \\rightarrow (\\tau', \\epsilon'), \\epsilon_1\\\\\r\n\t\t\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2[\\epsilon_\\alpha/\\alpha], \\epsilon_2[\\epsilon_\\alpha/\\alpha]\\\\\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash e_1[\\epsilon_\\alpha]\\ e_2\\ \\colon \\tau'[\\epsilon_\\alpha/\\alpha], \\epsilon'[\\epsilon_\\alpha/\\alpha]\r\n\t}\r\n\\end{mathpar}\r\n\r\n\\subsection*{Skipping Variables}\r\nIn practice, the requirement that we \\emph{must} use each global variable more restrictive than we would like. We would like to programs in which some global variables are skipped. We do this by adding a subtyping relation on effects and types.\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{sub-refl}{\r\n\t\t\\ \r\n\t}{\r\n\t\t\\tau <: \\tau\r\n\t}\r\n\r\n\t\\relationRule{sub-pair}{\r\n\t\t\\tau_1 <: \\tau_3\\\\\r\n\t\t\\tau_2 <: \\tau_4\\\\\r\n\t}{\r\n\t\t(\\tau_1, \\tau_2) <: (\\tau_3, \\tau_4)\r\n\t}\r\n\r\n\t\\relationRule{sub-function}{\r\n\t\t\\tau_1' <: \\tau_1\\\\\r\n\t\t\\tau_2 <: \\tau_2'\\\\\r\n\t\t\\epsilon_1' \\leq \\epsilon_1 \\leq \\epsilon_2 \\leq \\epsilon_2'\r\n\t}{\r\n\t\t\\forall \\alpha.(\\tau_1, \\epsilon_1) \\rightarrow (\\tau_2, \\epsilon_2) <: \\forall \\alpha.(\\tau_1', \\epsilon_1') \\rightarrow (\\tau_2', \\epsilon_2')\r\n\t}\r\n\\end{mathpar}\r\n\r\nFinally, we augment our typing relation with the single rule\r\n\\begin{mathpar}\r\n\t\\relationRule{subtyping}{\r\n\t\t\\tau_1 <: \\tau_2\\\\\r\n\t\t\\epsilon_1 \\leq \\epsilon_2\\\\\r\n\t\t\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau_1, \\epsilon_1\r\n\t}{\r\n\t\t\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau_2, \\epsilon_2\r\n\t}\r\n\\end{mathpar}\r\n\r\nNote that we only really have two uses for this new typing rule: replacing functions, and incrementing the effect.\r\n\r\n\\section*{Properties of the Typing Relation}\r\n\r\n\\subsection*{Transitivity of subtyping}\r\nTheorem: If $\\tau_1 <: \\tau_2$ and $\\tau_2 <: \\tau_3$ then $\\tau_1 <: \\tau_3$.\r\n\\\\\r\n\r\n\\noindent Proof: Straightforward structural induction on the proof that $\\tau_1 <: \\tau_2$, using inversion on the proof that $\\tau_2 <: \\tau_3$.\r\n\r\n\\subsection*{A shorthand for values}\r\nDefinition: We will write $v : \\tau$ as shorthand for $\\forall\\ \\Gamma, \\epsilon.\\ \\Gamma, \\epsilon \\vdash v\\ \\colon \\tau, \\epsilon$.\r\n\\\\\r\n\r\n\\noindent Theorem: If $\\Gamma, \\epsilon \\vdash v\\ \\colon \\tau, \\epsilon'$ then $v : \\tau$.\r\n\\\\\r\n\r\n\\noindent Proof: Straightforward structural induction on the typing derivation. If we used a value rule we may immediately reapply it. In the PAIR and SUBTYPING cases the result follows quickly by induction.\r\n\r\n\\subsection*{Monotonicity}\r\nIn our later proofs, we will need to use a monotonicity property stating that the effect only ever increases when we make typing judgements. Before we can prove that, though, we need some lemmas about substitution and the \\oktype\\ property.\r\n\\\\\r\n\r\n\\noindent Lemma M-1: For all $\\epsilon, \\epsilon_1, \\epsilon_2, \\alpha$, if $\\epsilon_1 \\equiv \\epsilon_2$, then $\\epsilon_1[\\epsilon/\\alpha] \\equiv \\epsilon_2[\\epsilon/\\alpha]$\r\n\r\n\\noindent Proof: Straightforward structural induction on the proof that $\\epsilon_1 \\equiv \\epsilon_2$.\r\n\\\\\r\n\r\n\\noindent Lemma M-2: For all $\\epsilon, \\epsilon_1, \\epsilon_2, \\alpha$, if $\\epsilon_1 \\leq \\epsilon_2$, then $\\epsilon_1[\\epsilon/\\alpha] \\leq \\epsilon_2[\\epsilon/\\alpha]$\r\n\r\n\\noindent Proof: Straightforward structural induction on the proof that $\\epsilon_1 \\leq \\epsilon_2$, using lemma M-1 in the \\texttt{leq-equiv} case.\r\n\\\\\r\n\r\n\\noindent Lemma M-3: if $\\tau$ is \\oktype, then for all $\\epsilon, \\alpha$, $\\tau[\\epsilon/\\alpha]$ is also \\oktype.\r\n \r\n\\noindent Proof: Straightforward structural induction on $\\tau$, using lemma M-2 in the function case.\r\n\\\\\r\n\r\n\\noindent Lemma M-4: if $\\tau_1 <: \\tau_2$, then $\\tau_1$ is \\oktype\\ if and only if $\\tau_2$ is \\oktype.\r\n\r\n\\noindent Proof: Straightforward structural induction on the proof that $\\tau_1 <: \\tau_2$.\r\n\\\\\r\n\r\n\\noindent Theorem: If $\\Gamma, \\epsilon_1 \\vdash e\\ \\colon \\tau, \\epsilon_2$ and all elements of $\\Gamma$ are \\oktype\\, then $\\tau$ is \\oktype\\ and $\\epsilon_1 \\leq \\epsilon_2$.\r\n\r\n\\noindent We don't actually care about $\\tau$ being \\oktype\\ (although it's a nice result), but we need it during the proof\r\n\\\\\r\n\r\n\\noindent Proof of Theorem: Straightforward induction on the typing derivation. The interesting bits are:\r\n\\begin{itemize}\r\n\t\\item In the CLOSURE rule, we show inductively that all elements of $\\Gamma_\\tau$ are \\oktype.\r\n\t\\item In the LOCAL VARIABLE rule, we use the fact that all elements of $\\Gamma$ are \\oktype.\r\n\t\\item In the GLOBAL VARIABLE rule, use the fact that all base types are valid.\r\n\t\\item In the ABS case we need to do a little work to show that the output is \\oktype.\r\n\t\\item In the APP case we use lemmas M-2 and M-3.\r\n\t\\item In the SUBTYPING case we use lemma M-4.\r\n\\end{itemize}\r\n\r\n\\subsection*{Canonical Forms}\r\nLemma C-1: If $\\tau_1 <: \\tau_2$, then:\r\n\\begin{itemize}\r\n\t\\item If either $\\tau_1$ or $\\tau_2$ is a base type or $\\texttt{ref}$ type then $\\tau_1 = \\tau_2$\r\n\t\\item If either $\\tau_1$ or $\\tau_2$ is a pair type, then $\\tau_1 = (\\tau_a, \\tau_b)$ and $\\tau_2 = (\\tau_c, \\tau_d)$ where $\\tau_a <: \\tau_c$ and $\\tau_b <: \\tau_d$.\r\n\t\\item If either $\\tau_1$ or $\\tau_2$ is a function type, then $\\tau_1 = \\forall \\alpha. (\\tau_a, \\epsilon_a) \\rightarrow (\\tau_b, \\epsilon_b)$ and $\\tau_2 = \\forall \\alpha. (\\tau_c, \\epsilon_c) \\rightarrow (\\tau_d, \\epsilon_d)$ where $\\tau_c <: \\tau_a$, $\\tau_b <: \\tau_d$, and $\\epsilon_a \\leq \\epsilon_c \\leq \\epsilon_b \\leq \\epsilon_d$.\r\n\\end{itemize} \r\n\r\n\\noindent Proof: Inversion of the typing relation.\r\n\\\\\r\n\r\n\\noindent Theorem: For all values $v$, if $v\\ \\colon \\tau$ then\r\n\\begin{itemize}\r\n\t\\item If $\\tau = \\texttt{Int}$ then $v \\in \\Z$\r\n\t\\item If $\\tau = \\texttt{Bool}$ then $v = \\texttt{True}$ or $v = \\texttt{False}$\r\n\t\\item If $\\tau = \\texttt{Unit}$ then $v = ()$\r\n\t\\item If $\\tau = \\tau_1 * \\tau_2$ then $v = (v_1, v_2)$ where $v_1 : \\tau_1$ and $v_2 : \\tau_2$.\r\n\t\\item If $\\tau = \\texttt{ref} (\\tau_1, \\epsilon)$ then $\\epsilon = i \\in \\Z$, $v = g_i$ and $\\tau_1 = T_i$.\r\n\t\\item If $\\tau = \\forall \\alpha.(\\tau_1, \\epsilon_1) \\rightarrow (\\tau_2, \\epsilon_2)$ then $v =\\ <\\Gamma, \\alpha, (x : \\tau', \\epsilon'), e>$ for some $\\Gamma, \\tau', \\epsilon', e$.\r\n\\end{itemize}\r\n\r\n\\noindent Proof: Case analysis on the proof that $v$ has type $\\tau$ for some arbitrary $\\Gamma, \\epsilon$. Each $\\tau$ has only two (or three, for booleans) that apply to a value and produce it: the base rules, and the subtyping rule. In the subtyping cases, we use Lemma C-1. In the pair case, we use induction, and in the case where $\\tau$ is a pair type and the subtyping rule was used, we Lemma C-1 twice in addition to induction.\r\n\r\n\\subsection*{The Substitution Lemma}\r\n\r\n\\noindent Definition: If $\\Gamma$ is a map, let $\\Gamma \\backslash x$ indicate the map which is identical to $\\Gamma$ but contains no binding for $x$.\r\n\\\\\r\n\r\n\\noindent Definition: Let $e[v/x]$ be the standard capture-avoiding substitution relation. It differs from the effect one in that it operates on expressions/values/variables instead of effects and effect variables. We also define it to be the identity function if $e$ is a value.\r\n\\\\\r\n\r\n\\noindent Theorem: If $\\Gamma[x] = \\tau$, $v : \\tau$, and $\\Gamma, \\epsilon \\vdash e\\ \\colon \\tau, \\epsilon'$, then $\\Gamma\\backslash x, \\epsilon \\vdash e[v/x]\\ \\colon \\tau, \\epsilon'$\r\n\r\n\\noindent Proof: Structural induction on first typing proof. The interesting cases are:\r\n\r\n\\begin{itemize}\r\n\t\\item In the VAR case $e = z$, either $z = x$ in which case $e[v/x] = v$ and the premise $v : \\tau$ solves it, or $z <> x$ in which case $z \\in \\Gamma\\backslash x$ and we simply use the VAR rule.\r\n\t\\item In the LET case $e = \\texttt{let } z = e_1 \\texttt{ in }e_2$ either $z = x$ in which case $\\Gamma\\backslash z[x := \\tau_1] = \\Gamma[x := \\tau_1]$ and we do not substitute in $e_2$, or $z <> x$ in which case $\\Gamma\\backslash z[x := \\tau_1] = \\Gamma[x := \\tau_1]\\backslash z$ and we do substitute in $e_2$. In either case the result follows immediately.\r\n\t\\item Similar reasoning works for the ABS case.\r\n\t\\item The subtyping case is immediate, but it bears noting that we don't change any of the types or effects that appear in the original derivation.\r\n\\end{itemize}\r\n\r\n\\clearpage\r\n\\section*{Operational Semantics}\r\n\r\nNow we'll define an operational semantics for our language. We are modeling a situation in which global variables are ordered in a pipeline, such that each global variable must be accessed after the ones before it in the pipeline.\r\n\r\nOur big-step operational semantics relation will have the form $(\\Gamma, G, n, e) \\Rightarrow (G', n', e')$, where $\\Gamma$ is an environment mapping variables to values, $G$ is an array $[v_1; \\dots; v_n]$ of the current values for each global variable, $n$ is an integer indicating the current pipeline stage, and $e$ is an expression to be evaluated. We treat $G$ as a map from integers to values, so $G[1] = v_1$, etc. We say $G$ is well-typed if $G[i] : T_i$ for $1 \\leq i \\leq n$.\r\n\r\nAs usual, the metavariable $v$ will refer exclusively to values, while $e$ represents any expression. We use $\\oplus$ to denote regular integer addition.\r\n\r\n\\subsection*{Big-step}\r\n\r\n\\begin{mathpar}\r\n\t\\relationRule{value}{\r\n\t\t\\\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, v) \\Rightarrow (G, n, v)\r\n\t}\r\n\t\r\n\t\\relationRule{variable}{\r\n\t\t\\Gamma[x] = v\r\n\t}{\r\n\t\t(\\Gamma, G, n, x) \\Rightarrow (G, n, v)\r\n\t}\r\n\r\n\t\\relationRule{sum}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, i_1)\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_2) \\Rightarrow (G_2, n_2, i_2)\\\\\r\n\t\ti_1, i_2 \\in \\Z\r\n\t}{\r\n\t\t(\\Gamma, G, n, (e_1, e_2)) \\Rightarrow (G_2, n_2, i_1 \\oplus i_2)\r\n\t}\r\n\r\n\t\\relationRule{pair}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, v_1)\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_2) \\Rightarrow (G_2, n_2, v_2)\r\n\t}{\r\n\t\t(\\Gamma, G, n, (e_1, e_2)) \\Rightarrow (G_2, n_2, (v_1, v_2))\r\n\t}\r\n\t\r\n\t\\relationRule{fst}{\r\n\t\t(\\Gamma, G, n, e) \\Rightarrow (G_1, n_1, (v_1, v_2))\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{fst } e) \\Rightarrow (G_1, n_1, v_1)\r\n\t}\r\n\r\n\t\\relationRule{snd}{\r\n\t\t(\\Gamma, G, n, e) \\Rightarrow (G_1, n_1, (v_1, v_2))\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{snd } e) \\Rightarrow (G_1, n_1, v_2)\r\n\t}\r\n\t\r\n\t\\relationRule{let}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, v_1)\\\\\r\n\t\t(\\Gamma[x := v_1], G_1, n_1, e_2) \\Rightarrow (G_2, n_2, v_2)\\\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{let } x = e_1 \\texttt{ in } e_2) \\Rightarrow (G_2, n_2, v_2)\r\n\t}\r\n\r\n\t\\relationRule{if-true}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, \\texttt{True})\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_2) \\Rightarrow (G_2, n_2, v)\\\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{if } e_1 \\texttt{ then } e_2 \\texttt{ else } e_3) \\Rightarrow (G_1, n_2, v)\r\n\t}\r\n\r\n\t\\relationRule{if-false}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, \\texttt{False})\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_3) \\Rightarrow (G_2, n_2, v)\\\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{if } e_1 \\texttt{ then } e_2 \\texttt{ else } e_3) \\Rightarrow (G_1, n_2, v)\r\n\t}\r\n\t\r\n\t\\relationRule{deref}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, g_i)\\\\\r\n\t\tn_1 <= i\r\n\t}{\r\n\t\t(\\Gamma, G, n, !e) \\Rightarrow (G_1, i+1, G_1[i])\r\n\t}\r\n\r\n\t\\relationRule{update}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, v_1)\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_2) \\Rightarrow (G_2, n_2, g_i)\\\\\r\n\t\tn_2 <= i\r\n\t}{\r\n\t\t(\\Gamma, G, n, e_2 := e_1) \\Rightarrow (G_2[i := v_1], i+1, ())\r\n\t}\r\n\r\n\t\\relationRule{abs}{\r\n\t\t\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, \\texttt{fun } [\\alpha]\\ (x : \\tau, \\epsilon) \\rightarrow e) \\Rightarrow (G, n, < \\Gamma, \\alpha, (x : \\tau, \\epsilon), e>)\r\n\t}\r\n\r\n\t\\relationRule{app}{\r\n\t\t(\\Gamma, G, n, e_1) \\Rightarrow (G_1, n_1, < \\Gamma', \\alpha, (x : \\tau, \\epsilon), e>)\\\\\r\n\t\t(\\Gamma, G_1, n_1, e_2) \\Rightarrow (G_2, n_2, v_2)\\\\\r\n\t\t(\\Gamma'[x := v_2], G_2, n_2, e) \\Rightarrow (G_3, n_3, v_3)\\\\\r\n\t}{\r\n\t\t(\\Gamma, G, n, e_1\\ e_2) \\Rightarrow (G_3, n_3, v_3)\r\n\t}\r\n\\end{mathpar}\r\n\r\n\\subsection*{Big-step weakening}\r\n\r\nDuring our soundness proof, we will need to use the following theorem, which states that if a program evaluates from a state then it also evaluates from every earlier state.\r\n\\\\\r\n\r\n\\noindent Theorem: If $(\\Gamma, G, n, e) \\Rightarrow (G', n', v)$ and $m \\leq n$ then $(\\Gamma, G, m, e) \\Rightarrow (G', m', v)$ for some $m' \\leq n'$.\r\n\\\\\r\n\r\n\\noindent Proof: Straightforward induction on the proof of evaluation. The only mildly interesting cases are DEREF and UPDATE, where we use transitivity of $\\leq$ and the fact that $i+1 \\leq i+1$.\r\n\r\n\\subsection*{Big-step soundness}\r\n\r\nSince our language (and also dpt!) doesn't allow recursion or looping, we can show not only that well-typed programs do not get stuck, but that they terminate (i.e. well-typed programs are normalizing).\r\n\\\\\r\n\r\n\\newcommand{\\okvalue}{good}\r\n\\noindent Definition: A value is \\emph{\\okvalue} if whenever $v : \\forall \\alpha.(\\tau_{in}, \\epsilon_{in}) \\rightarrow (\\tau_{out}, \\epsilon_{out})$, we know that $v =\\ <\\Gamma, \\alpha, (x : \\tau_{in}, \\epsilon_{in}), e>$ and for all $G, i, v_x$ where $G$ is well-typed and $v_x : \\tau_{in}[i/\\alpha]$, $(\\Gamma_\\tau[x := v_x], G, \\epsilon[i/\\alpha], e) \\Rightarrow (G', i', v)$ where $G'$ is well-typed, $i' \\leq \\epsilon_{out}[i/\\alpha]$, and $v : \\tau_{out}[i/\\alpha]$ and $v$ is \\okvalue.\r\n\\\\\r\n\r\n\\noindent Definition: for all typing environments $\\Gamma$, let $\\Gamma_v$ denote any evaluation environment such that for all $x \\in \\Gamma$, $\\Gamma_v[x] = v_x$ where $v_x : \\Gamma[x]$ and $v_x$ is \\okvalue.\r\n\\\\\r\n\r\n\\noindent Desired Theorem: \\\\\\indent If $\\emptyset, 1 \\vdash e\\ \\colon \\tau, n+1 $ then for all $G$ there exist some $G', n', v$ such that $(\\emptyset, G, 1, e) \\Rightarrow (G', n', v)$\r\n\\\\\r\n\r\n\\noindent Unfortunately this won't give us a useful induction hypothesis, so we must prove a generalization instead:\r\n\\\\\r\n\r\n\\noindent Generalized Theorem: \\\\\\indent If $\\Gamma, i \\vdash e\\ \\colon \\tau, j$ then for all well-typed $G$ there exist some $G', i', v$ such that $v$ is \\okvalue, $v : \\tau$, $i' \\leq i$, $G'$ is well-typed, and $(\\Gamma_v, G, i, e) \\Rightarrow (G', i', v)$.\r\n\\\\\r\n\r\n\\noindent Fortunately it is immediately obvious that the general theorem implies the desired one. For now we'll prove it assuming there's no polymorphism; that is, no effects anywhere in the program or judgements include any type variables. To prove it with polymorphism, we would probably have to instantiate any type variables in the judgement and do so in a consistent way, and then say that $e$ evaluates for all such instantiations. \r\n\r\nRoughly, something like \"Let $[\\alpha_1, \\dots, \\alpha_k]$ be the set of type variables appearing inside $e$. For any set of integer effects $\\mathbb{I} = \\{i_1, \\dots i_k\\}$, let $e_\\mathbb{I}$ denote $e[i_1/\\alpha_1]...[i_k/\\alpha_k]$, and similarly for other things. Then if $\\Gamma_\\mathbb{I}, (\\epsilon_1)_\\mathbb{I} \\vdash e_\\mathbb{I} : \\tau_\\mathbb{I}, (\\epsilon_2)_\\mathbb{I}$ then $(\\Gamma_v, G, (\\epsilon_1)_\\mathbb{I}, e_\\mathbb{I}) \\Rightarrow (G', i', v)$ where $i' \\leq (\\epsilon_2)_\\mathbb{I}$, and $v : \\tau_\\mathbb{I}$ and $G'$ is well-typed and $v$ is \\okvalue.\r\n\\\\\r\n\r\n\\noindent Proof of Generalized Theorem: Induction on the proof that $\\Gamma, i \\vdash e\\ \\colon \\tau, j$.\r\n\\\\\r\n\r\nCase $\\texttt{Int/True/False/Global Variable}$. In these cases, $e$ is a value, so we may apply the value rule to show that $(\\Gamma_v, G, i, e) \\Rightarrow (G, i, v)$, and we can show $v : \\tau$ using the appropriate rule appearing in the title of the case. Note that we won't need to use subtyping when we do so.\r\n\\\\\r\n\r\nCase $\\texttt{Local Variable}$. Our premise gives us that $\\Gamma[x] = \\tau$. Hence by definition, $\\Gamma_v[x] = v_x$, $v_x : \\tau$, and $v_x$ is \\okvalue. Thus we may use the \\texttt{Variable} rule to show that $(\\Gamma_v, G, i, e) \\Rightarrow (G, i, v_x)$.\r\n\\\\\r\n\r\nCase $\\texttt{Pair}$. \r\nFrom our premise:\r\n\\begin{itemize}\r\n\t\\item $e = e_1\\ e_2$\r\n\t\\item $\\Gamma, i \\vdash e_1\\ \\colon \\tau_1, \\epsilon_1$\r\n\t\\item $\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2, j$\r\n\t\\item IH1: $(\\Gamma_v, G, i, e_1) \\Rightarrow (G_1, i_1, v_1) \\wedge i_1 \\leq \\epsilon_1 \\wedge v_1 : \\tau_1 \\wedge G_1 \\mbox{ is well-typed}$\r\n\t\\item IH2: $(\\Gamma_v, G_1, \\epsilon_1, e_2) \\Rightarrow (G_2, i_2, v_2) \\wedge i_2 \\leq \\epsilon_2 \\wedge v_2 : \\tau_2 \\wedge G_2 \\mbox{ is well-typed}$\r\n\\end{itemize}\r\n\r\nThis is almost enough to apply the PAIR evaluation rule, but unfortunately that rule requires the output of the first to match the input of the second. Fortunately since we know that $i_1 \\leq \\epsilon_1$, we may use weakening to show that $(\\Gamma_v, G_1, i_1, e_2) \\Rightarrow (G_2, i_2', v_2)$ for some $i_2' \\leq i_2$, and now we may use the PAIR rule to conclude that $(\\Gamma_v, G, i, e_1) \\Rightarrow (G_2, i_2', (v_1, v_2))$. Next, we note that $i_2' \\leq i_2 \\leq \\epsilon_2$, and that $(v_1, v_2) : \\tau_1 * \\tau_2$ can be easily shown using the PAIR typing rule plus the fact that $v_1 : \\tau_1$ and $v_2 : \\tau_2$. Finally, note that $G_2$ being well typed is part of IH2, since $G_1$ is well-typed.\r\n\\\\\r\n\r\nCase PLUS: Same as the PAIR case, but we also need to use our canonical forms lemma to satisfy the prerequisite of SUM that both values be integers.\r\n\\\\\r\n\r\nCase FST: $e = \\texttt{fst } e_1$. We know that $\\Gamma, i \\vdash e_1\\ \\colon \\tau_1 * \\tau_2, \\epsilon_1$, so by induction $(\\Gamma_v, G, i, e) \\Rightarrow (G', i', v)$, where $v : \\tau_1 * \\tau_2$, $i' \\leq i$, and $G'$ is well-typed. Our canonical forms lemma lets us conclude that $v = (v_1, v_2)$ and $v_1 : \\tau_1$, so we may apply the FST rule to show that $(\\Gamma_v, G, i, \\texttt{fst } e) \\Rightarrow (G', i', v_1)$. That was all that remained to be shown.\r\n\\\\\r\n\r\nCase SND: Analogous to FST.\r\n\\\\\r\n\r\nCase LET: $e = \\texttt{let } x = e_1 \\texttt{ in } e_2$. We know that $\\Gamma, i \\vdash e_1\\ \\colon \\tau_1, \\epsilon_1$ and $\\Gamma[x := \\tau_1], \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2, \\epsilon_2$. Thus by induction we get\r\n$$(\\Gamma_v, G, i, e_1) \\Rightarrow (G_1, i_1, v_1)\\mbox{ and }(\\Gamma[x := \\tau_1]_v, G_1, \\epsilon_1, e_2) \\Rightarrow (G_2, i_2, v_2),$$\r\nwhere $i_1 \\leq \\epsilon_1$, $i_2 \\leq \\epsilon_2$, $v_1 : \\tau_1$ and $v_2 : \\tau_2$. We note that by induction, $v_1$ is \\oktype, and since $v_1 : \\tau_1$ and $\\tau_1 = \\Gamma[x := \\tau_1][x]$, $\\Gamma_v[x := v_1]$ is a valid instance of $\\Gamma[x := \\tau_1]_v$. We also apply weakening to our second hypothesis as in the PAIR case so that it begins evaluation at $i_1$ instead of $\\epsilon_1$. This gives us everything we need to apply the LET rule and show that $(\\Gamma_v, G, i, e) \\Rightarrow (G_2, i_2, v_2)$.\r\n\\\\\r\n\r\nCase IF: By induction we know that $e$ evaluates to a value $v$ and $v : \\texttt{Bool}$, and hence by canonical forms $v = \\texttt{True}$ or $v = \\texttt{False}$. We can then apply weakening to the other hypotheses and then use IF-TRUE or IF-FALSE as appropriate.\r\n\\\\\r\n\r\nCase DEREF: We know that\r\n\\begin{itemize}\r\n\t\\item DEREF: $\\Gamma, i \\vdash e\\ \\colon \\tau, \\epsilon_1+1$\r\n\t\\item INV1: $e = !e_1$\r\n\t\\item INV2: $\\Gamma, i \\vdash e_1\\ \\colon \\texttt{ref}(\\tau, \\epsilon_1), \\epsilon_1$\r\n\t\\item IH: $(\\Gamma_v, G, i, e_1) \\Rightarrow (G', i', v) \\wedge i' \\leq \\epsilon_1 \\wedge v : \\texttt{ref}(\\tau, \\epsilon_1) \\wedge G' \\mbox{ is well-typed}$.\r\n\\end{itemize}\r\n\r\nBy canonical forms, we conclude that $\\tau = T_j$ and $v = g_j$ where $\\epsilon_1 = j \\in \\Z$. Hence $i' \\leq \\epsilon_1 = j$, so we may apply the DEREF rule to show that $(\\Gamma_v, G, i, !e_1) \\Rightarrow (G_1, j+1, G_1[j])$. Then by reflexivity $j + 1 \\leq \\epsilon_1 + 1$, and since $G$ is well-typed $G_1$ is as well. Thus $G_1[j] : T_j = \\tau$, which was all that remained to show.\r\n\\\\\r\n\r\nCase UPDATE: We know that\r\n\\begin{itemize}\r\n\t\\item UPDATE: $\\Gamma, i \\vdash e_2 := e_1\\ \\colon \\texttt{Unit}, \\epsilon_2 + 1$\r\n\t\\item INV1: $e = e_2 := e_1$\r\n\t\\item INV2: $\\Gamma, i \\vdash e_1\\ \\colon \\tau, \\epsilon_1$\r\n\t\\item INV3: $\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\texttt{ref }(\\tau, \\epsilon_2), \\epsilon_2$\r\n\t\\item IH1: $(\\Gamma_v, G, i, e_1) \\Rightarrow (G_1, i_1, v_1) \\wedge i_1 \\leq \\epsilon_1 \\wedge v_1 : \\tau \\wedge G_1 \\mbox{ is well-typed}$.\r\n\t\\item IH2: $(\\Gamma_v, G_1, \\epsilon_1, e_2) \\Rightarrow (G_2, i_2, v_2) \\wedge i_2 \\leq \\epsilon_2 \\wedge v_2 : \\texttt{ref}(\\tau, \\epsilon_2) \\wedge G_2 \\mbox{ is well-typed}$.\r\n\\end{itemize}\r\nWe immediately apply weakening to IH2 so that its input is $i_1$ instead of $\\epsilon_1$. By canonical forms, $\\tau = T_j$ and $v_2 = g_j$ where $\\epsilon_2 = j \\in \\Z$. Thus since $i_2 \\leq \\epsilon_2 = j$, we may use the UPDATE rule to show that $(\\Gamma_v, G, i, e_2 := e_1) \\Rightarrow (G_2[j := v_1], j+1, ())$. It's immediate that $j+1 \\leq \\epsilon_2+1$ (by reflexivity) and that $() : \\texttt{Unit}$. Last, we know that $G_2$ is well-typed and $v_1 : \\tau = T_j$, so $G_2[j := v_1]$ is well-typed as well.\r\n\\\\\r\n\r\nCase ABS: We know that \r\n\\begin{itemize}\r\n\t\\item INV1: $e = \\texttt{fun } [\\alpha]\\ (x : \\tau_{in}, \\epsilon_{in}) \\rightarrow e_{body}$\r\n\t\\item ABS: $\\Gamma, \\epsilon \\vdash e\\ \\colon \\forall \\alpha.(\\tau_{in}, \\epsilon_{in}) \\rightarrow (\\tau_{out}, \\epsilon_{out})$\r\n\t\\item INV2: $\\Gamma[x := \\tau], \\epsilon_{in} \\vdash e_{body}\\ \\colon \\tau_{out}, \\epsilon_{out}$\r\n\t\\item IH1: $(\\Gamma[x := \\tau]_\\tau, G, \\epsilon_{in}, e_{body}) \\Rightarrow (G', i', v) \\wedge i' \\leq \\epsilon_{out} \\wedge v : \\tau_{out} \\wedge v \\mbox{ is \\okvalue}$\r\n\\end{itemize}\r\nFor now, let's ignore polymorphism (So, in particular, all $\\epsilon$s are integers, and substitution is a no-op).\r\n\r\nWe may immediate apply the ABS rule to show that if $v_{out} =\\ <\\Gamma_v, \\alpha, (x : \\tau_{in}, \\epsilon_{in}), e_{body})>$ then\r\n$(\\Gamma_v, G, i, e) \\Rightarrow (G, i, v)$. We can then use the CLOSURE rule to show that $v : \\forall \\alpha.(\\tau_{in}, \\epsilon_{in}) \\rightarrow (\\tau_{out}, \\epsilon_{out})$, and of course $G$ is well-typed and $i \\leq i$. So we need only show that $v$ is \\okvalue. \r\n\r\nFirst, $v$ is in fact a closure. Since substitution is a no-op, we need only show that $(\\Gamma_v[x := v_x], G, \\epsilon_{in}, e_{body}) \\Rightarrow (G', i', v')$ plus all the other stuff, which falls out immediately from INV2 by induction. (Ok we also have to do the reasoning from the LET case involving $\\Gamma_v$)\r\n\\\\\r\n\r\nCase APP: We know that\r\n\\begin{itemize}\r\n\t\\item APP: $\\Gamma, i \\vdash e_1[\\epsilon_\\alpha] e_2\\ \\colon \\tau'[\\epsilon_\\alpha/\\alpha], \\epsilon'[\\epsilon_\\alpha/\\alpha]$\r\n\t\\item INV1: $e = e_1[\\epsilon_\\alpha] e_2$\r\n\t\\item INV2: $\\Gamma, i \\vdash e_1\\ \\colon \\forall\\alpha.(\\tau_2, \\epsilon_2) \\rightarrow (\\tau', \\epsilon'), \\epsilon_1$\r\n\t\\item INV3: $\\Gamma, \\epsilon_1 \\vdash e_2\\ \\colon \\tau_2[\\epsilon_\\alpha/\\alpha], \\epsilon_2[\\epsilon_\\alpha/\\alpha]$\r\n\t\\item IH1: $(\\Gamma_v, G, i, e_1) \\Rightarrow (G_1, i_1, v_1) \\wedge i_1 \\leq \\epsilon_1 \\wedge v_1 : \\forall\\alpha.(\\tau_2, \\epsilon_2) \\rightarrow (\\tau', \\epsilon') \\wedge G_1 \\mbox{ is well-typed}$.\r\n\t\\item IH2: $(\\Gamma_v, G_1, \\epsilon_1, e_2) \\Rightarrow (G_2, i_2, v_2) \\wedge i_2 \\leq \\epsilon_2 \\wedge v_2 : \\tau_2[\\epsilon_\\alpha/\\alpha], \\epsilon_2[\\epsilon_\\alpha/\\alpha] \\wedge G_2 \\mbox{ is well-typed}$.\r\n\t\\item \\okvalue: $v_1 =\\ <\\Gamma_v', \\alpha, (x : \\tau_2, \\epsilon_2), e_{body}>$ and $(\\Gamma_v'[x := v_2], G_2, \\epsilon_{\\tau_2}, e_{body}) \\Rightarrow (G_3, i_3, v)$ where $G_3$ is well-typed, $i_3 \\leq \\epsilon'[i/\\alpha]$, $v : \\tau'[i/\\alpha]$ and $v$ is \\okvalue.\r\n\\end{itemize}\r\nBy applying weakening twice, we can use IH1 to fulfill the first premise of APP, IH2 for the second, and the evaluation part of \"\\okvalue\" finishes it off.\r\n\\\\\r\n\r\nCase SUBTYPING: \r\nBy induction, $(\\Gamma_v, G, i, e) \\Rightarrow (G', i', v)$ where $G'$ is well-typed, $i' \\leq \\epsilon_1 \\leq \\epsilon_2$, $v : \\tau_1$, and $v$ is \\okvalue. The only thing to show is that $v : \\tau_2$, which can be done with a single application of the SUBTYPING rule since we know that $\\tau_1 <: \\tau_2$.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\end{document}\r\n%%% Local Variables:\r\n%%% mode: latex\r\n%%% TeX-master: t\r\n%%% End: ", "meta": {"hexsha": "300c715b04590135ac33ef5c02b49e3905e1c6a8", "size": 37112, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/global typing big step.tex", "max_stars_repo_name": "DanielBentleyMacLeod/lucid", "max_stars_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2021-07-07T16:09:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T14:49:38.000Z", "max_issues_repo_path": "notes/global typing big step.tex", "max_issues_repo_name": "DanielBentleyMacLeod/lucid", "max_issues_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2021-08-30T16:48:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:19:34.000Z", "max_forks_repo_path": "notes/global typing big step.tex", "max_forks_repo_name": "DanielBentleyMacLeod/lucid", "max_forks_repo_head_hexsha": "7364207bc90737a835505c6f2131d9258a3a590a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-05T23:14:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:10:32.000Z", "avg_line_length": 50.6994535519, "max_line_length": 712, "alphanum_fraction": 0.6639092477, "num_tokens": 12912, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4196843636807008}}
{"text": "\\chapter{Background}\n\\label{sec:background}\n\n\n\\section{Termination Checking}\n\\label{sec:background:termination}\n\nProof assistants based on dependently typed languages must, if they are to be\nconsistent, ensure that all recursive programs terminate. The usual solution to\nthis problem, used by Coq, Agda, Idris, Lean and others, is to augment the type\nchecker with a separate termination checker based on the principle of structural\nrecursion. That principle says roughly: a program terminates if the input to any\nrecursive call is a subterm of the original input. For example, consider the\nusual definition of addition for natural numbers:\n\\begin{code}\n  plus : ℕ → ℕ → ℕ\n  plus zero    m = m\n  plus (suc n) m = suc (plus n m)\n\\end{code}\n\nIn the recursive call in the second equation, \\icode{n} is a subterm of the\noriginal input, \\icode{suc~n}. Since this is the only recursive call, the\ndefinition as a whole is structurally recursive and is accepted by Agda's\ntermination checker. This is justified because the natural numbers are\ninductively defined, so any closed term of type \\icode{ℕ} consists of finitely\nmany applications of the \\icode{suc} constructor. If we \\enquote*{peel off} one\nconstructor for every recursive call, we must eventually reach the \\icode{zero}\ncase and the recursion ends.\n\nStructural recursion as a basis for termination checking has many advantages. It\nis conceptually simple, relatively easy to implement and surprisingly versatile:\nmany interesting definitions are naturally structurally recursive. However,\nstructural termination checkers are also inadequate in some important ways.\n\nFirst, structural recursion is based on the syntactic notion of a subterm. This\nmakes termination checking non-compositional: we cannot, in general, replace a\nterm with another term of the same type in a recursive definition and still\nexpect the definition to typecheck. For a contrived example, take our previous\ndefinition of \\icode{plus} and replace the \\icode{n} by \\icode{id~n} in the\nrecursive call. The identity function \\icode{id} just returns its argument, so\nthe two terms are obviously equivalent, but a naive termination checker would\nnot accept the modified definition -- after all, \\icode{id~n} is not a syntactic\nsubterm of \\icode{suc~n}. (Agda's termination checker is smart enough to\nevaluate \\icode{id~n} to \\icode{n} and therefore accepts the modified\ndefinition.)\n\nUnfortunately, this non-compositionality bites not only in such contrived\nsituations. An often-cited example is the mapping function on rose trees (for\nwhich we also need the standard list type and its mapping function):\n\\begin{code}\n  data List (A : Set) : Set where\n    []  : List A\n    _∷_ : A → List A → List A\n\n  mapList : ∀ {A B} → (A → B) → List A → List B\n  mapList f []       = []\n  mapList f (x ∷ xs) = f x ∷ mapList f xs\n\n  data Tree (A : Set) : Set where\n    leaf : A → Tree A\n    node : List (Tree A) → Tree A\n\n  mapTree : ∀ {A B} → (A → B) → Tree A → Tree B\n  mapTree f (leaf x)  = leaf (f x)\n  mapTree f (node xs) = node (mapList (mapTree f) xs)\n\\end{code}\nAgda's termination checker does not accept \\icode{mapTree}, and with good\nreason: the recursive call in the second equation does not involve a subterm of\nany input. We can argue that when we unfold \\icode{mapList}, it becomes apparent\nthat \\icode{mapTree} is always applied to an element of the list \\icode{xs} and\nthese elements are obviously subterms of \\icode{xs}. But Agda's syntactic check\nis not smart enough to realise this. (Coq's termination checker employs a\nheuristic that can deal with \\icode{mapTree} by essentially inlining a\nspecialised version of \\icode{mapList}.)\n\nA second problem of termination checkers based on structural recursion is that\nit is tempting to extend them with various heuristics to deal with more\ncomplicated variants of structural recursion such as mutually recursive\ndefinitions, lexicographic termination measures and nested inductive datatypes\nlike our rose trees. As a result, the termination checkers of Coq and Agda have\nbecome quite complex, and with complexity come bugs: both Coq and Agda have\nshipped versions with errors in their termination checkers that made the systems\ninconsistent \\cite{coqbug2013,agdabug2013}.\n\nThe final problem with structural recursion is that it does not easily\naccommodate coinductive datatypes and corecursive definitions. Corecursive\nfunctions produce values of coinductive types, which can be infinite. For\nexample, we can coinductively define the type of streams whose values are\ninfinite lists. A function which produces a stream obviously cannot terminate.\nInstead, we must demand that the function is \\emph{productive}, meaning that it\ngenerates any finite prefix of its output in finite time. In other words, any\nfinite observation of an infinite stream must terminate. There are syntactic\nmethods, analogous to structural recursion, to ensure productivity, but they are\nvery inflexible. Sized types, on the other hand, when combined with copatterns\n\\cite{abel2016}, yield a practical productivity checker mostly for free.\n\nTo address these problems of structural termination checkers, we look to sized\ntypes as a type-based termination checking mechanism.\n\n\n\\section{Sized Types}\n\\label{sec:background:sized}\n\nSized types are a termination checking methodology that does not rely on a\nsyntactic analysis. Instead, terms of inductive and coinductive types are\nannotated at the type level with a size. For terms of inductive types, this size\nmay be thought of as an upper bound on the height of the term, viewed as a\nconstructor tree. For coinductive types, the size denotes the maximum depth to\nwhich the term may be inspected. With this setup, checking a recursive\ndefinition becomes easy: a recursive call is justified if the size of its\nargument decreases. A corecursive call is justified if it increases the maximum\nobservation depth of its result.\n\nVarious type systems based on these principles have been proposed (see\n\\secref{conclusion:related} for references). This thesis investigates a calculus\nwhose sized types closely resemble Agda's, so the remainder of this section\ngives a brief overview of Agda's system. More details and examples can be found\nin Agda's manual \\cite{agdamanual} and in \\cite{abel2016}.\n\nA size is a term of type \\icode{Size<~n}, where \\icode{n} is also a size.\nPrimitive sizes are variables, the successor of a size \\icode{↑~n} and\n\\enquote*{infinity}, \\icode{∞}. The size \\icode{∞} plays a special role: it\ndesignates \\enquote*{fully defined} types, i.e.\\ those whose values could have any\nsize.\n\nFor a size \\icode{m} to have type \\icode{Size<~n} it must be less than\n\\icode{n} according to an order \\icode{<}. This order is mostly straightforward;\nfor example, we have \\icode{n~<~↑~n} for all \\icode{n}. However, we also have\n\\icode{n~<~∞} for all \\icode{n} and in particular \\icode{∞~<~∞}. As we will see,\nthis rule creates significant problems.\n\nA sized inductive type is simply an inductive type with a parameter of type\n\\icode{Size} (which is the same as \\icode{Size<~∞}). Continuing our rose tree\nexample, we define sized lists and a mapping function:\n\\begin{code}\n  data Listₛ (A : Set) (n : Size) : Set where\n    []   : Listₛ A n\n    cons : (m : Size< n) → A → Listₛ A m → Listₛ A n\n\n  mapListₛ : ∀ {A B} n → (A → B) → Listₛ A n → Listₛ B n\n  mapListₛ n f []            = []\n  mapListₛ n f (cons m x xs) = cons m (f x) (mapListₛ m f xs)\n\\end{code}\nThe typing of the \\icode{cons} constructor reflects the intuition that the\nheight of \\icode{cons~m~x~xs}, \\icode{n}, is strictly greater than the height of\n\\icode{xs}, \\icode{m}.\\footnote{Agda also supports a different style of using\n  sized types where \\icode{cons} takes a \\icode{Listₛ~A~n} as input and returns\n  a \\icode{Listₛ~A~(↑~n)} (making \\icode{n} an index rather than a parameter of\n  \\icode{Listₛ}). This works just as well for the most part, but there are\n  technical reasons to prefer our \\enquote*{quantifier style}.} We can then\nexploit this in \\icode{mapListₛ}: in the recursive call, \\icode{mapListₛ} is\napplied to \\icode{m}, which we know from the type of \\icode{cons} is less than\n\\icode{n}. Thus, each recursive call decreases in size and the recursion is\njustified. The definition also demonstrates that the order on sizes induces a\nsubtyping relation: the right-hand side of the second equation has type\n\\icode{Listₛ~A~m}, which is a subtype of \\icode{Listₛ~A~n} for \\icode{m~<~n}.\n\nSo far, we could have just as well used a structural termination checker. The\nbenefits of sized types become obvious when we turn to rose trees:\n\\begin{code}\n  data Treeₛ (A : Set) (n : Size) : Set where\n    leaf : A → Treeₛ A n\n    node : (m : Size< n) → Listₛ (Treeₛ A m) ∞ → Treeₛ A n\n\n  mapTreeₛ : ∀ {A B} n → (A → B) → Treeₛ A n → Treeₛ B n\n  mapTreeₛ n f (leaf x)    = leaf (f x)\n  mapTreeₛ n f (node m xs) = node m (mapListₛ ∞ (mapTreeₛ m f) xs)\n\\end{code}\nThe definition of \\icode{Treeₛ} demonstrates the utility of \\icode{∞}: we can\nsay that a \\icode{node} should have a list of children without caring about the\nsize of that list. But more importantly, the termination checker now accepts\n\\icode{mapTreeₛ}: the recursive call is now at size \\icode{m~<~n} and thus\njustified. In effect, we have encoded in the type of \\icode{node} our intuition\nthat the height of \\icode{node~xs} is strictly greater than the height of any of\nthe elements of \\icode{xs}.\n\nAgda's sized types thus deliver on the compositionality promise: all information\nthe termination checker needs is encoded at the type level, so we can freely\nabstract over terms. Sized types are also mostly straightforward to implement,\nbeing just an extension of the type system.\\footnote{I say \\enquote{mostly}\n  because Agda's current implementation includes some subtle checks to prevent\n  inconsistent size assumptions, which is necessary to preserve decidability of\n  type checking. Agda also has a sophisticated size inference engine (so we\n  could have left all sizes in our example code implicit), but this engine is\n  not part of the trusted computing base.}\n\nUnfortunately, such convenience currently comes at the ultimate price: Agda's\nimplementation of sized types is, and has been for some time, inconsistent. The\nculprit seems to be the highly dubious rule \\icode{n~<~∞}, in particular\n\\icode{∞~<~∞}. This rule makes the \\icode{<} relation obviously non-well-founded\n(meaning there is an infinite descending chain \\icode{∞~<~∞~<~\\dots}) but Agda\nassumes that \\icode{<} is well-founded. This assumption can be exploited in\ndifferent ways \\cite{agdabug2015,agdabug2016,agdabug2017,agdabug2018} to sneak\nnon-terminating programs past the termination checker.\n\nIt is currently unclear how to satisfactorily resolve this issue with Agda's\ndesign. In this thesis, I adopt the obvious solution: changing the \\icode{<}\nrelation so that \\icode{∞~≮~∞}. Doing the same in Agda would, however, lead to\nissues with the constructors and fields of sized data types. For example, we\nwould like to use the \\icode{cons} constructor for sized lists at type\n\\begin{code}\n  A → Listₛ A ∞ → Listₛ A ∞\n\\end{code}\nbut this is impossible with \\icode{∞~≮~∞}. As a workaround, we can define a\nconsing operation for lists at \\icode{∞} that is extensionally equal to\n\\icode{cons}, but this requires a pattern match on the input list -- an\ninefficiency that should not be necessary. How best to \\enquote*{rescue} Agda's\nsized types thus remains an open question for now.\n\nAnother possible criticism of Agda's sized types concerns expressivity. Agda's\nsize arithmetic is restricted to the successor; we cannot add or multiply sizes.\nThis means that we cannot give a precise type to, for example, the list\nappending function, whose output size should be the sum of its input sizes. This\nlack of expressivity, however, is a conscious design decision. In return, we get\na size inference algorithm that can infer almost all sizes in a typical program.\nThis significantly lowers the cost of adopting sized types.\n", "meta": {"hexsha": "9e0e003f9cb83e1ed0171fe43e84b4025f360ebb", "size": 12013, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/background.tex", "max_stars_repo_name": "JLimperg/msc-thesis", "max_stars_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-14T01:30:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-14T01:30:46.000Z", "max_issues_repo_path": "include/background.tex", "max_issues_repo_name": "JLimperg/msc-thesis", "max_issues_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/background.tex", "max_forks_repo_name": "JLimperg/msc-thesis", "max_forks_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.3594470046, "max_line_length": 82, "alphanum_fraction": 0.7632564722, "num_tokens": 3160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.69925440852404, "lm_q1q2_score": 0.41968435615750865}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n% title information\n\\title{Phys 221A -- Quantum Mechanics -- Lec05}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{20}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n[missed first hour, lots of stuff missing here]\n\n\\section{Spin precession (of a localized spin-$1/2$ particle)}\n\nWe have a 2 dimensional Hilbert space with Hamiltonian\n\\begin{eqn}\nH = -\\gamma (\\hbar / 2) \\v{\\sigma} \\cdot \\v{B},\n\\end{eqn}\nwhere $\\gamma$ is the gyromagnetic ratio and\n\\begin{eqn}\n\\v{\\sigma} = \\set{ \\pmat{0 & 1 \\\\ 1 & 0}, \\pmat{0 & -i \\\\ i & 0}, \\pmat{1 & 0 \\\\ 0 & -1} }\n\\end{eqn}\nare the Pauli matrices. We can also write\n\\begin{eqn}\nH = -\\gamma \\v{S} \\cdot \\v{B} = -\\v{\\mu} \\cdot \\v{B},\n\\end{eqn}\nwhere $\\v{S} = (\\hbar/2) \\v{\\sigma}$ is the spin operator and $\\v{\\mu} = \\gamma \\v{S}$ is the magnetic moment. \n\nFor the electron, we have\n\\begin{eqn}\n\\mu = \\gamma \\hbar / 2 = -(g/2) \\mu_B\n\\end{eqn}\nwhere $g$ is the so-called ``g factor'' and $\\mu_B = \\abs{e} \\hbar / (2mc)$ is the Bohr magneton. Classically it is expected that $g = 1$, which was actually measured (incorrectly) by Einstein et al. According to QED and the Dirac equation, $g \\approx 2$ for a free electron. In fact it is very close to 2, actually around $g \\approx 2.002$ which has been measured with great accuracy in agreement with theory. This measurement is one of the great triumphs of quantum field theory. \n\n\\subsubsection{Constant magnetic field}\n\nLet $\\v{B} = B \\uv{z}$, then\n\\begin{eqn}\nH = -\\gamma (\\hbar / 2) B \\v{\\sigma}_z = \\pmat{-\\mu B & 0 \\\\ 0 & +\\mu B}.\n\\end{eqn}\nSo we have two energy eigenkets,\n\\begin{eqn}\n\\ket{\\uparrow} = \\pmat{1 \\\\ 0}, \\qquad \\ket{\\downarrow} = \\pmat{0 \\\\ 1}\n\\end{eqn}\nwith energies $E_\\uparrow = -\\mu B$, $E_\\downarrow = \\mu B$. Since $\\mu < 0$, $E_\\downarrow$ is the energy of the ground state. Furthermore, we have\n\\begin{eqn}\n\\Delta E = E_\\uparrow - E_\\downarrow = -2\\mu B = \\hbar \\abs{\\gamma} B\n\\end{eqn}\nor $\\Delta E = \\hbar \\omega_L$ where $\\omega_L = \\abs{\\gamma} B$ is the Larmor frequency. \n\nNow, for an arbitrary state $\\ket{\\psi}$ we can write\n\\begin{eqn}\n\\ket{\\psi} = C_\\uparrow \\ket{\\uparrow} + c_\\downarrow \\ket{\\downarrow},\n\\end{eqn}\nwhich time evolved becomes\n\\begin{align}\n\\ket{\\psi(t)} &= e^{-(i / \\hbar) E_\\uparrow t} c_\\uparrow \\ket{\\uparrow} + e^{-(i / hbar) E_\\downarrow t} c_\\downarrow \\ket{\\downarrow} \\\\\n\t&= e^{-(i / \\hbar) E_\\uparrow t} (c_\\uparrow \\ket{\\uparrow} + e^{i\\omega_L t} c_\\downarrow \\ket{\\downarrow}) \\\\\n\t&\\sim c_\\uparrow \\ket{\\uparrow} + e^{i\\omega_L t} c_\\downarrow \\ket{\\downarrow}.\n\\end{align}\nThe expectation value of spin angular momentum is given by\n\\begin{eqn}\n\\v{s}(t) = \\frac{\\hbar}{2} \\bra{\\psi(t)} \\v{\\sigma} \\ket{\\psi(t)},\n\\end{eqn}\nwhich satisfies the equation\n\\begin{eqn}\n\\od{\\v{s}(t)}{t} = -\\gamma \\v{B} \\times \\v{s}(t) = \\omega_L \\uv{z} \\times \\v{s}(t).\n\\end{eqn}\n\n\n\\section{Heisenberg picture}\n\nIn the Schroedinger picture, the operators are time-independent while the state evolves in time. In the Heisenberg picture, we picture the situation the other way around, that is the states are time-independent and the operators evolve in time. In general, for an operator $O(t)$ the time average is given by\n\\begin{eqn}\n\\avg{O(t)} = \\bra{\\psi(t)} O(t) \\ket{\\psi(t)}.\n\\end{eqn}\nIn the Schroedinger picture, we solve for $\\ket{\\psi(t)}$. In the Heisenberg picture, we have\n\\begin{align}\n\\avg{O(t)} &= \\bra{\\psi} U^\\dagger(t) O(t) U(t) \\ket{\\psi} \\\\\n\t&= \\bra{\\psi} O_H (t) \\ket{\\psi},\n\\end{align}\nwhere \n\\begin{eqn}\nO_H(t) = U^\\dagger (t) O(t) U(t)\n\\end{eqn}\nis the operator in the Heisenberg picture. \n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "9ebc33dea6ad271d8a2d7a3291c2ad8c4f4cf25c", "size": 3880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quantum/lec05.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "quantum/lec05.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quantum/lec05.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1919191919, "max_line_length": 482, "alphanum_fraction": 0.6657216495, "num_tokens": 1372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.41964253118192946}}
{"text": "\\newcommand{\\uu}[1]{\\underline{\\underline{#1}}}\n  \\section*{List of Symbols}\n  \\begin{tabular}{l{0.5cm}l{7cm}}\n    $\\uu{\\sigma}$ &Second rank stress tensor\\\\\n    $\\sigma_{eq}$ &Von Mises equivalent stress \\\\\n    $f_{y}$       &Yield stress \\\\\n    $\\uu{s}$      &Second rank deviatoric stress tensor \\\\\n    $J_{2}$       &Second invariant of the deviatoric stress tensor\\\\\n    $J_{3}$       &Third invariant of the deviatoric stress tensor\\\\\n\n    \\multicolumn{2}{c}{} \\\\\n\n    $p$                          &Equiv. creep (viscoplastic) strain \\\\\n    $\\uu{\\dot \\varepsilon}^{cr}$ &Second rank creep (viscoplastic) strain\n    rate tensor\\\\\n\n    \\multicolumn{2}{c}{} \\\\\n\n    $A$, $n$, $m$          &Temperature dependent isotropic creep parameters \\\\\n    $w$                    &Weights \\\\\n\n    \\multicolumn{2}{c}{} \\\\\n\n    $e$           &Sample's thickness \\\\\n    $\\phi_s$      &Sample's diameter \\\\\n    $\\phi_j$      &Jaws' diameter \\\\\n\n    \\multicolumn{2}{c}{} \\\\\n\n    $\\uu{I}$      &Identity matrix \\\\\n    $Tr()$        &Trace \\\\\n    $\\left\\langle \\quad \\right\\rangle$  &Macaulay brackets \\\\\n    $x^{\\pm}$  &Positive and negative parts of variable $x$\\\\\n\n    \\multicolumn{2}{c}{} \\\\\n\n    $F$  &Force \\\\\n    $t$  &Time \\\\\n  \\end{tabular}\n", "meta": {"hexsha": "c2d2ffc2d91c8c1cee479b68ecebab91b4e23306", "size": 1235, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex-article/sections/list-symbols.tex", "max_stars_repo_name": "lbteixeira/code-starters", "max_stars_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-13T12:21:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-13T12:21:06.000Z", "max_issues_repo_path": "latex-article/sections/list-symbols.tex", "max_issues_repo_name": "lbteixeira/code-starters", "max_issues_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex-article/sections/list-symbols.tex", "max_forks_repo_name": "lbteixeira/code-starters", "max_forks_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.875, "max_line_length": 79, "alphanum_fraction": 0.5336032389, "num_tokens": 392, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.41964252237243205}}
{"text": "\\input{preamble}\n\n\\begin{document}\n    \\section{Subjects}\n    \\begin{itemize}\n        \\item Markov Decision Process\n        \\item Bellman Equations and Algorithms\n    \\end{itemize}\n    \n    \\section{Notes}\n    \n    \\subsection{Elements of reinforcement learning}\n\n    \\begin{description}\n        \\item[Exploration vs. exploitation] Should we explore new \n        opportunities, or take advantage of the ones we have found that works?\n        \\item[Agent] How do we interact with the environment, who do we \n        represent?\n        \\item[Environment] What actions can we take and what is currently \n        happening?\n        \\item[Policy] How does the learning agent behave? A mapping from the \n        perceived states of the environment to which actions to be taken when \n        in those states.\n        \\item[Reward signal] On each time step, the environment send the agent \n        a single number, a reward. The agents sole objective is to maximize the \n        total reward it receives. The agent can change the outcome by the \n        signal by taking actions or changing the environment, but can't change \n        the function that generates the reward signal.\n        \\item[Value function] The value of a state is the total amount of \n        reward an agent can expect to accumulate, \\textit{starting from that \n        state}. Rewards return the immediate desirability of a state, value \n        returns the long-term desirability of a state.\n        \\item[Model of the environment] Something that mimics the behaviour of \n        the environment, so we can infer how the environment will behave. (E.g. \n        could be used to predict the next model). There are both model-based \n        and model-free methods.\n    \\end{description}\n    \n    \\subsection{Finite Markov Decision Processes}\n    We can think of the interaction between an agent and the environment as the \n    agent taking some action at time $t$ $A_t$, and the environment providing \n    the agent with a reward $R_{t+1}$ and a new state $S_{t+1}$ which prompts a \n    new action $A_{t+1}$ from the agent.\n    \n    At each time step $t$, the agent implements a mapping from states to \n    probabilities of selecting each possible action $A_t \\in A(S_t)$. This \n    mapping is called the agent's policy and is denoted $\\pi_t$ where \n    $\\pi_t(a|s)$ is the probability that $A_t=a$ if $S_t=s$. Reinforcement \n    learning is about changing the policy as a result of experience.\n    \n    We seek to maximize the \\textit{expected return} $\\Ex({G_t})$, but how do \n    we define $G_t$? The simplest case is simply the sum of the rewards:\n    \n    \\begin{equation*}\n        G_t = R_{t+1}+R_{t+2}+\\cdots+R_T\n    \\end{equation*}\n    If we are dealing with \\textit{episodic tasks}, i.e. tasks that are \n    independent like plays of a game or trips through a maze (we call these \n    tasks ``episodes''). However, if we \n    are dealing with \\textit{continuing tasks}, for example a robot with a long \n    life span or process-control tasks then the return, which we are trying to \n    maximize is potentially infinite. Thus, we will use a definition of return \n    that is slightly more complex conceptually but much simpler mathematically. \n    We introduce the concept of \\textit{discounting}, the agent will try to \n    maximize the sum of the discounted rewards, where the rewards are \n    decreasing in value so tasks that are performed immediately are worth more:\n    \\begin{equation*}\n        G_t=R_{t+1}+\\gamma R_{t+2}+ \\gamma ^2 R_{t+3} + \\cdots = \n        \\sum_{k=0}^{\\infty}\\gamma^k R_{t+k+1}\n    \\end{equation*}\n    Here $0\\leq \\gamma \\leq 1$ is called the discount rate. Then we know that \n    if $\\gamma < 1$ then the infinite sum has a finite value, as long as \n    $R_k\\neq \\infty$. If $\\gamma = 0$, then the agent is only concerned with \n    maximizing immediate rewards. More often than not, we won't have $\\infty$ \n    rewards, so we can simplify this to:\n    \\begin{equation*}\n        G_t=\\sum_{k=0}^{T-t-1}\\gamma^k R_{t+k+1}\n    \\end{equation*}\n    Where it is possible that $T=\\infty$ or $\\gamma = 1$ but both cannot be \n    true (since the sum would then be $\\infty$).\n    \n    \\subsubsection{The Markov Property}\n    We cannot expect an actor to know everything about the environment, as some \n    information may be hidden. The environment will provide the actor with \n    different sensations, and we might expect the actor to remember all the \n    sensations it has experienced so far.\n    \n    We call a state signal which succeeds in retaining all relevant information \n    to be \\textit{Markov} or to have \\textit{the Markov property}. For example, \n    if we were playing chess, then the current configuration of all the pieces \n    on the board would serve as a Markov state, because it summarizes all \n    important details that led to it. Much of the information about the \n    sequence is lost, but all that really matters for the future of the game is \n    retained. It doesn't matter that we don't know how we ended up at that \n    chess board configuration, the current configuration is all that is \n    relevant.\n    \n    In order to formally define the Markov property in a mathematically simple \n    way, we will assume that there are a finit number of states and reward \n    values. This enables us to work in terms of sums and probabilities instead \n    of integrals and probability densities, but it can easily be extended.\n    \n    Consider how an environment might respond at time $t+1$ to the action taken \n    at time $t$. The most general, causal case is where the response depends on \n    everything that has happened earlier:\n    \\begin{equation*}\n        \\Pr\\left[S_{t+1} =s', \n        R_{t+1}=r|S_0,A_0,R_1,S_1,A_1,\\dots,R_{t-1},S_{t-1},A_{t-1},R_t,S_t,A_t \n         \\right]\n    \\end{equation*}\n    However, if the state signal has the Markov property, then the environments \n    response at $t+1$ only depends on the state and action at $t$ so we can \n    define it as simply:\n    \\begin{equation*}\n        p(s',r|s,a)=\\Pr\\left[S_{t+1}=s',R_{t+1}=r|S_t=s, A_t=a\\right]\n    \\end{equation*}\n    If this hold for all $s'$ and $r$ then we will be able to predict the \n    result of an action having just $s$, $a$ just as good as we would be able \n    to do it given the complete history of states and actions.\n    \n    It is usually useful to think of the state at each time step as an \n    approximation to a Markov state even in non-Markov state signals because of \n    the better performance Markov gives us in reinforcement learning, as long \n    as one keeps in mind that it may not fully satisfy the Markov property.\n    \n    \\subsubsection{Markov Decision Process}\n    A reinforcement learning task that satisfies the Markov property is called \n    a \\textit{Markov decision process} or MDP. If there is a finite amount of \n    states and actions, then we call it a \\textit{finite MDP}. If you \n    understand \\textit{finite MDP} then you understand $90\\%$ of modern \n    reinforcement learning.\n    \n    A finite MDP, is defined by uts state and actions sets and by the one-step \n    dynamics of the environment. We use the probability of going to $s'$ and \n    receiving $r$ from $s$ and $a$ as previously:\n    \\begin{equation*}\n    p(s',r|s,a)=\\Pr\\left[S_{t+1}=s',R_{t+1}=r|S_t=s, A_t=a\\right]\n    \\end{equation*}\n    This completely specify the dynamics of some finite MDP. We can then \n    compute anything else we might want to know about the environment such as \n    the expected rewards for state-action pairs:\n    \\begin{equation*}\n        r(s,a)=\\Ex\\left[R_{t+1}|S_t=s, A_t=a\\right]=\\sum_{r\\in R}r \\sum_{s' \\in \n        S} p(s',r|s,a)\n    \\end{equation*}\n    The state-transition probabilities:\n    \\begin{equation*}\n        p(s'|s,a)=\\Pr\\left[S_{t+1}=s'|S_t=s, A_t=a\\right]=\\sum_{r\\in \n        R}p(s',r|s,a)\n    \\end{equation*}\n    And the expected rewards for state--action--next-state:\n    \\begin{equation*}\n        r(s,a,s')=\\Ex\\left[R_{t+1}|S_t=s,A_t=a,S_{t+1}=s'\\right]=\\frac{\\sum_{r\\in\n         R}r\\cdot p(s',r|s,a)}{p(s'|s,a)}\n    \\end{equation*}\n    \n    \\subsubsection{Value Functions}\n    We will need to estimate value functions for almost all reinforcement \n    learning algorithms. The value functions are functions of states that \n    estimate \\textit{how good} it is to for the the agent to be in a given \n    state (or rather, how good is it to perform some action in a given state). \n    The notion of ``how good'' is defined in terms of what future rewards can \n    we expect to receive.\n    \n    A policy $\\pi$ is a mapping from each state $s \\in S$ and action $a \\in \n    A(s)$ to the probability $\\pi(a|s)$ of taking action $a$ when in state $s$. \n    Informally, the following equation is the expected return when starting in \n    state $s$ and following policy $\\pi$ for a MDP:\n    \\begin{equation*}\n        v_\\pi(s)=\\Ex_\\pi\\left[G_t\\given\n        S_t=s\\right]=\\Ex_\\pi\\left[\\sum_{k=0}^{\\infty}\\gamma^k \n        R_{t+k+1}\\given S_t=s\\right]\n    \\end{equation*}\n    \n    Similarly, we can define the value of taking action $a$ in state $s$ under \n    $\\pi$ as the expected return starting from $s$, taking the action $a$ and \n    then following $\\pi$:\n    \\begin{equation*}\n        q_\\pi(s,a)=\\Ex_\\pi\\left[G_t\\given \n        S_t=s,A_t=a\\right]=\\Ex_\\pi\\left[\\sum_{k=0}^{\\infty}\\gamma^kR_{t+k+1}\\given\n         S_t=s,A_t=a\\right]\n    \\end{equation*}\n    We call $q_\\pi$ the action-value function for policy $\\pi$. We can estimate \n    $v_\\pi$ and $q_\\pi$ using the average of the actual returns, we will return \n    to this later. For now, let's look at a fundamental property of $v_\\pi$ \n    which is used throughout reinforcement learning. Namely, the property that \n    they satisfy particular recursive relationships:\n    \n    \\begin{align*}\n        v_\\pi(s)&= \\Ex_\\pi\\left[G_t\\given S_t=s\\right]\\\\\n            &= \\Ex_\\pi\\left[\\sum_{k=0}^{\\infty}\\gamma^kR_{t+k+1}\\given S_t = \n            s\\right]\\\\\n            &= \n            \\Ex_\\pi\\left[R_{t+1}+\\gamma\\sum_{k=0}^{\\infty}\\gamma^kR_{t+k+2} \n            \\given S_t=s\\right]\\\\\n            &= \\sum_a \\pi\\left(a\\given s\\right) \\sum_{s'} \\sum_r p(s',r|s,a)\n            \\left[r+\\gamma \\Ex\\left[\\sum_{k=0}^{\\infty}\\gamma^k R_{t+k+2} \n            \\given S_{t+1}=s'\\right]\\right]\\\\\n            &= \\sum_a \\pi\\left(a\\given s\\right) \\sum_{s',r} p(s',r|s,a) \n            \\left[r+\\gamma v_\\pi(s')\\right]\n    \\end{align*}\n    We can read this equation as a sum over the triples $a$, $s'$ and $r$. For \n    each triple, we compute its probability $\\pi\\left(a\\given s\\right)p(s', \n    r|s,a)$ weight the value in the bracket (which is the reward plus the \n    expected reward from the next state $s'$), which gives us the expected \n    value. This equation is called the \\textit{Bellman equation for $v_\\pi$}\n    \n    \\subsubsection{Optimal value functions}\n    In order to ``solve'' reinforcement learning, roughly means that we need to \n    find a policy that achieves a lot of reward in the long run. For finite \n    MDPs we can define it precisely as follows. A police $\\pi$ is said to be \n    better than or equals to a policy $\\pi'$ if its expected return is better \n    than or equal to that of $\\pi'$. In other words $\\pi \\geq \\pi' \\iff \n    v_\\pi(s)\\geq v_{\\pi'}(s) \\forall s\\in S$. There will always be at least one \n    policy which is better than or equal to all other policy which is the \n    optimal policy, we denote any of the optimal policies as $\\pi_*$. We can \n    define their state-value function as:\n    \\begin{equation*}\n        v_*(s)=\\max_\\pi v_\\pi(s)\n    \\end{equation*}\n    Which is the optimal state-value function. We can define the same for the \n    optimal action-value function:\n    \\begin{equation*}\n        q_*(s,a)=\\max_\\pi q_\\pi(s,a)\n    \\end{equation*}\n    For the state-action pair $(s,a)$, this function gives the expected return \n    of taking action $a$ in state $s$ and then following an optimal policy. We \n    can therefore write $q_*$ in terms of $v_*$ as follows:\n    \\begin{equation*}\n        q_*(s,a)=\\Ex\\left[R_{t+1}+\\gamma v_*(S_{t+1}) \\given S_t=s, A_t=a\\right]\n    \\end{equation*}\n    \n    \\subsubsection{Dynamic programming}\n    We can use dynamic programmin (DP) to compute the value functions explained \n    earlier. Furthermore, we can easily obtain optimal policies once we have \n    found the optimal value functions $v_*$ or $q_*$ which satisfy the Bellman \n    equations:\n    \\begin{align*}\n        v_*(s)&=\\max_a \\Ex\\left[R_{t+1}+\\gamma v_*(S_{t+1}) \\given S_t=s, A_t = \n        a\\right]\\\\\n            &= \\max_a \\sum_{s',r}p(s',r|s,a)\\left[r+\\gamma v_*(s')\\right]\n    \\end{align*}\n    or\n    \\begin{align*}\n        q_*(s,a) &= \\Ex\\left[R_{t+1}+\\gamma \\max_{a'}q_*(S_{t+1},a') \\given \n        S_t=s, A_t=a \\right]\\\\\n            &= \\sum_{s', r}p\\left(s', r \\given s,a\\right)\\left[r+\\gamma \n            \\max_{a'}q_*(s',a')\\right]\n    \\end{align*}\n    We will see that we obtain DP algorithms by turning these Bellman equations \n    into assigments, that is update rules which improve approximations of the \n    desired functions.\n    \n    \\subsubsection{Policy Evaluation}\n    First, we will consider computing the state-value function $v_\\pi$. This is \n    called \\textit{policy evaluation} recall that:\n    \\begin{align*}\n    v_\\pi(s) &= \\Ex_\\pi\\left[\\sum_{k=0}^{\\infty}\\gamma^kR_{t+k+1}\\given S_t = \n    s\\right]\\\\\n        &= \\Ex_\\pi\\left[R_{t+1}+\\gamma v_\\pi(S_{t+1}) \n        \\given S_t=s\\right]\\\\\n        &= \\sum_a \\pi\\left(a\\given s\\right) \\sum_{s',r} p(s',r|s,a) \n        \\left[r+\\gamma v_\\pi(s')\\right]\n    \\end{align*}\n    Now consider a sequence of approximate value functions $v_0,v_1,\\dots$, the \n    initial approximation $v_0$ is arbitrary except the terminal state has to \n    be $0$. We can then obtain the approximations by using the Bellman equation \n    for $v_\\pi$:\n    \\begin{align*}\n        v_{k+1}(s)&= \\Ex_\\pi\\left[R_{t+1}+\\gamma v_k(S_{t+1}) \\given S_t = s \n        \\right]\\\\\n            &=\\sum_a \\pi\\left(a \\given s\\right)\\sum_{s',r}p\\left(s',r \\given \n            s,a\\right)\\left[r+ \\gamma v_k(s')\\right]\n    \\end{align*}\n    This approximation does indeed converge to $v_\\pi$ as $k\\rightarrow \\infty$\n    \n    \\subsubsection{Policy Improvement}\n    Now that we are able to determine $v_\\pi$, we are able to evaluate our \n    policies, and thus we will be able to improve upon them. For some state \n    $s$, we would like to know whether or not we should change the policy such \n    that we deterministically choose an action $a\\neq \\pi(s)$. We know the \n    quality of following the current policy from $s$ ($v_\\pi(s)$), so would it \n    be better or worse to change to another policy? In order to answer this, we \n    could select $a$ in $s$ and otherwise just follow the existing policy:\n    \\begin{align*}\n        q_\\pi(s,a)&=\\Ex\\left[R_{t+1}+\\gamma v_\\pi(S_{t+1}) \\given S_t=s, \n        A_t=a\\right]\\\\\n            &= \\sum_{s',r}p\\left(s',r \\given s,a\\right)\\left[r+\\gamma \n            v_\\pi(s')\\right]\n    \\end{align*}\n    If this is greater than $v_\\pi(s)$ then it is better to select $a$ once in \n    $s$, but then it would in fact be better to pick $s$ every time:\n    \\begin{equation*}\n        q_\\pi(s,\\pi'(s)) \\geq v_\\pi(s) \\implies v_{\\pi'}(s) \\geq v_\\pi(s)\n    \\end{equation*}\n    We can then use this to define a new greedy policy $\\pi'$ given by:\n    \\begin{align*}\n        \\pi'(s)&=\\arg\\max_a q_\\pi(s,a)\\\\\n            &=\\arg\\max_a \\Ex\\left[R_{t+1} + \\gamma v_\\pi(S_{t+1}) \\given S_t=s, \n            A_t=a \\right]\\\\\n            &=\\arg\\max_a \\sum_{s',r}p\\left(s',r \\given s,a\\right)\\left[r+\\gamma \n            v_\\pi(s')\\right]\n    \\end{align*}\n    I.e. the greedy policy looks one step ahead and picks the action that looks \n    best in the short term. Now suppose $\\pi'$ is as good as, but not better \n    than, the old policy $\\pi$. The $v_\\pi=v_{\\pi'}$ and then it follows that:\n    \\begin{align*}\n        v_{\\pi'}(s)&=\\max_a\\Ex\\left[R_{t+1}+\\gamma v_{\\pi'}(S_{t+1}) \\given \n        S_t=s, A_t=a \\right]\\\\\n            &= \\max_a \\sum_{s',r}p\\left(s',r \\given s,a \\right)\\left[r+\\gamma \n            v_{\\pi'}(s')\\right]\n    \\end{align*}\n    But this was the optimal Bellman equation from earlier, therfore $v_{\\pi'}$ \n    must be $v_*$ and thus $\\pi'$ must be an optimal policy, thus this policy \n    improvement algorithm must give us a strictly better policy until we hit \n    the optimal one.\n    \n    So far, we have only considered deterministic policies, that is where \n    $\\pi(s)$ always evaluate to the same action. However, all of the ideas so \n    far, easily extend to stochastic policies ($\\pi(a|s)$).\n\n    Now that we can both evaluate and improve our policies, we can just \n    continue evaluating then improving and evaluating then improve and so on, \n    monotonically improving untill we find a optimal solution.\n    \n    \\subsubsection{Value iteration}\n    This algorithm is fairly expensive, so we need to speed it up somehow. One \n    way is implementation specific, where we simply make sure to pick up policy \n    evaluation values from the last evaluation and not $0$.\n    \n    Value iteration provides us with a way to solve both policy evaluation and \n    improvement in one step.\n    \n    \\begin{align*}\n    v_{k+1}(s)&=\\max_a\\Ex\\left[R_{t+1}+\\gamma v_k(S_{t+1}) \\given \n    S_t=s, A_t=a \\right]\\\\\n        &= \\max_a \\sum_{s',r}p\\left(s',r \\given s,a \\right)\\left[r+\\gamma \n        v_k(s')\\right]\n    \\end{align*}\n    Here, we find that $v_k$ still converges to $v_*$.\n    \n    \\subsubsection{Drawback of DP}\n    The drawback of DP as described here, is that it involves operations over \n    the entire state set of the MDP, so if there are many states (like \n    backgammon) then it is incredibly expensive.\n    \n    \\subsubsection{Generalized Policy Iteration}\n    In generalized policy iteration (GPI), we maintain both an approximate \n    policy and an approximate value function. The value function is repeatedly \n    altered to approximate the value function for the current policy, and the \n    current policy is repeatedly improved with respect to the current value \n    function. In a way they move against each other, as they create a moving \n    target for each other, but they cause both policy and value function to \n    approach optimality.\n    \n    This is a simple overview of the generalized policy iteration:\n    \\begin{itemize}\n        \\item While improving repeat\n        \\item Run policy evaluation for some time on some states\n        \\item Run policy improvement for som time on some states\n    \\end{itemize}\n    Here we may choose not to visit all states, but in most cases we will still \n    converge in polynomial time.\n    \n    \\subsection{Monte Carlo algorithms}\n    Up until now, we have assumed complete knowledge of the environment (finite \n    states and actions). Monte Carlo algorithms, allows us to learn from just \n    \\textit{experience} -- we cample sequences of states, action and rewards \n    without any prior knowledge of the environment's dynamics.\n    \n    In the Monte Carlo methods, we want to sovle the reinforcement learning \n    problem based on averaging sample returns. Furthermore instead of computing \n    the value functions (as we did in DP), we here want to learn the value \n    functions instead.\n    \n    What if we looked at just the state-value function, how would we try to \n    estimate that? The obvious solution here, is to average all the returns \n    observed after visits to that state. As we observe more and more returns, \n    the average should converge to the expected value. This is the underlying \n    idea of all Monte Carlo algorithms.\n    \n    In order to ensure well-defined returns are available, we will only \n    consider Monte Carlo for episodic tasks.\n    \n    \\subsubsection{Estimating $v_\\pi(s)$}\n    $v_\\pi(s)$ is the value of a state $s$ under policy $\\pi$, given a set of \n    episodes obtained by following $\\pi$ and passing through $s$. Each \n    occurrence of state $s$ in an episode is called a \\textit{visit} to $s$. It \n    may happen that we visit $s$ multiple times in an episode, so we will look \n    at the \\textit{first visit} to $s$. Let's first look at a theoretical \n    algorithm which computes the value of $s$ in the first visit to $s$:\n    \\begin{algorithm}\n        \\caption{First-visit MC policy evaluation}\n        \\begin{algorithmic}\n            \\State \\textit{// Initialize:}\n            \\State $\\pi \\gets$ policy to be evaluated\n            \\State $V \\gets $ an arbitrary state-value function\n            \\State $Returns(s) \\gets $ an empty list, for all $s \\in S$\n            \\State\n            \\Loop \\, forever\n                \\State Generate an episode using $\\pi$\n                \\ForAll{state $s$ in the episode}\n                    \\State $G \\gets $ return following the first occurence of \n                    $s$\n                    \\State Append $G$ to $Returns(s)$\n                    \\State $V(s) \\gets \\average(Returns(s))$\n                \\EndFor\n            \\EndLoop\n        \\end{algorithmic}\n    \\end{algorithm}\n    \n    We could also have explored the \\textit{every-visit MC method}, which has \n    some different properties and extends more naturally to function \n    approximation, but First-visit MC has been more widely studied.\n    \n    First-visit MC converges quadratically to $v_\\pi(s)$ as the number of \n    first-visits to $s$ \n    goes to infinity. An alternative, finite option, is to loop for some time \n    or some number of episodes.\n    \n    \\subsubsection{Estimation of action values}\n    If a model is available, we can simply look ahead in the next possible \n    states and pick the action that leads to the best state. If no model is \n    available, then we have to estimate the values of the action (e.g. speed of \n    vehicle) we should pick in order to get to the best state and maximize \n    reward.\n    \n    In other words, one of the primary goals for Monte Carlo methods is to \n    estimate $q_*$, which is the optimal value we get when we take action $a$ \n    from state $s$. In order to estimate this, we may run a First-visit MC \n    method as before, just visiting state-action pairs instead of just states. \n    Again, this will converge quadratically as before.\n    \n    The complication is that many state-action pairs may never be visited. If \n    $\\pi$ is a deterministic policy, then following $\\pi$ one will only observe \n    returns from one action from each state (as it is deterministic). Therefore \n    the Monte Carlo estimates of the other actions from that state will not \n    improve with experience. This is the general problem of \\textit{maintaining \n    exploration} i.e. we must assure that we are continually exploring other \n    options in order to attempt to find a better one. One way to solve this, is \n    to say that we start in a state-action pair, and every state-action pair \n    has a nonzero probability of being selected as the start. We call this the \n    assumption of \\textit{exploring starts}.\n    \n    \\textit{Exploring starts}, is not really useful when we learn by actual \n    interacting with an environment as we cannot simply start from any state we \n    want. In this case, the most common alternative approach is to only \n    considering stochastic policies with only nonzero probabilities.\n    \n    \\subsubsection{Approximating optimal policies}\n    Let us consider a Monte Carlo version of classical policy iteration. We can \n    perform policy evaluation as described in the previous section (estimation \n    of action values). If we assume that:\n    \\begin{itemize}\n        \\item We observe an infinite number of episodes.\n        \\item The episodes are generated with exploring starts.\n    \\end{itemize}\n    Then the Monte Carlo methods will compute each $q_{\\pi_k}$ exactly for \n    arbitrary $\\pi_k$.\n    \n    Now we just need to figure out how to perform policy-improvements. We can \n    improve on our policy with a simple greed policy with respect to the \n    current value function. We can then compute for each $s \\in S$ the policy \n    $\\pi$:\n    \\begin{equation*}\n        \\pi(s) = \\arg\\max_a q(s,a)\n    \\end{equation*}\n    We can then construct each $\\pi_{k+1}$ as the greedy policy with respect to \n    $q_{\\pi_k}$, and we get that the policy improvement theorem applies since:\n    \\begin{align*}\n        q_{\\pi_k}(s,\\pi_{k+1}(s)) &= q_{\\pi_k}(s, \\arg\\max_a q_{\\pi_k}(s,a))\n    \\end{align*}\n    This assures us that each $\\pi_{k+1}$ is uniformly better than or just as \n    good as $\\pi_k$. If it is just as good as $\\pi_k$ then they are both \n    optimal policies.\n    \n    \\subsubsection{Monte Carlo without infinite episodes}\n    We made two unlikely assumptions in order to easily obtain this guarantee \n    of convergence. One was that the episodes has exploring starts, the other \n    was that we could run for infinitely many episodes. We will try to remove \n    the latter assumption here and then return to exploring starts afterwards.\n   \n    There are two primary ways to combat the infinite episodes assumption, one \n    approach is to estimate some bounds on magnitude and probability of error \n    and run until these bounds are sufficiently small. This will guarantee \n    correct convergence up to some level of approximation, however it is likely \n    to require far too many episodes to be useful in practice.\n    \n    The second approach is to avoid trying to complete policy evaluation before \n    returning for improvement and simply move the value function \\textit{toward}\n    $q_{\\pi_k}$. One extreme example of this was the value iteration, in which \n    only one iteration of iterative policy evaluation is performed between \n    improvements. Or the in-place version where we alternate between \n    improvement and evaluation steps for single states.\n    \n    For Monte Carlo policy evaluation it is natural to alternate between \n    evaluation and improvement on an episode-by-episode basis. After each \n    episode we evaluate the policy and then improve it at all the visited \n    states. We can describe this algorithm as follows:\n    \n    \\begin{algorithm}\n        \\caption{Monte Carlo ES (Exploring Starts)}\n        \\begin{algorithmic}\n            \\State \\textit{// Initialize, for all } $s\\in S, a\\in A(s)$:\n            \\State $Q(s,a) \\gets$ arbitrary\n            \\State $\\pi(s) \\gets$ arbitrary\n            \\State $Returns(s,a) \\gets$ empty list\n            \\State\n            \\Loop\\, forever\n                \\State Choose $S_0 \\in S$ and $A_0 \\in A(S_0)$ s.t. all pairs \n                have probability $> 0$\n                \\State Generate an episode starting from $S_0, A_0$ following \n                $\\pi$\n                \\ForAll{pairs $s,a$ appearing in the episode}\n                    \\State $G \\gets$ return following the first occurence of \n                    $s,a$\n                    \\State Append $G$ to $Returns(s,a)$\n                    \\State $Q(s,a) \\gets \\average(Returns(s,a))$\n                \\EndFor\n                \\ForAll{states $s$ in the episode}\n                    \\State $\\pi(s) \\gets \\arg \\max_a Q(s,a)$\n                \\EndFor\n            \\EndLoop\n        \\end{algorithmic}\n    \\end{algorithm}\n    \n    \\subsubsection{Monte Carlo without Exploring Starts}\n    Now, how can we avoid the unlikely assumption of exploring starts? The only \n    general way to ensure that all actions are selected infinitely often is for \n    the agent to continue to select them. We have two approaches to ensuring \n    that this happens, we call it \\textit{on-policy} methods  and \n    \\textit{off-policy} methods. On-policy attempts to evaluate or improve the \n    policy used to make decision whereas off-policy methods evaluate or improve \n    a different policy. The ES method above is an example of an on-policy \n    method. We will explore on-policy methods more here, and not go into \n    details with off-policy.\n    \n    Here we will look at $\\epsilon$-greedy policies, which with probability \n    $1-\\epsilon$ will simply follow the policy $\\pi$, but with probability \n    $\\epsilon$ it will select a uniformly random action. So each action has \n    probability $\\frac{\\epsilon}{|A(s)|}$ of being picked, except the estimated \n    optimal action which also has probability $1-\\epsilon$ of being picked, \n    yielding the algorithm:\n    \n    \\begin{algorithm}\n        \\caption{On-policy first-visit MC control (for $\\epsilon$-soft \n        policies)}\n        \\begin{algorithmic}\n            \\State \\textit{// Initialize}\n            \\ForAll{$s \\in S$ and $a \\in A(s)$}\n                \\State $Q(s,a) \\gets$ arbitrary\n                \\State $Returns(s,a) \\gets$ empty list\n                \\State $\\pi(a|s) \\gets$ an arbitrary $\\epsilon$-soft policy\n            \\EndFor\n            \n            \\Loop\\, forever\n                \\State Generate an episode using $\\pi$\n                \\ForAll{pairs $s,a$ appearing in the episode}\n                    \\State $G \\gets$ return following the first occurence of \n                    $s,a$\n                    \\State Append $G$ to $Returns(s,a)$\n                    \\State $Q(s,a) \\gets \\average(Returns(s,a))$\n                \\EndFor\n                \\ForAll{visited states $s$ in the episode}\n                    \\State $A^* \\gets \\arg\\max_a Q(s,a)$\n                    \\ForAll{$a \\in A(s)$}\n                        \\State $\\pi(a|s) \\gets \\begin{cases}\n                        1-\\epsilon + \\frac{\\epsilon}{|A(s)|},&\\text{ if \n                        }a=A^*\\\\\n                        \\frac{\\epsilon}{|A(s)|},&\\text{ if } a \\neq A^*\n                        \\end{cases}$\n                    \\EndFor\n                \\EndFor\n            \\EndLoop\n        \\end{algorithmic}\n    \\end{algorithm}\n    \n    This holds under the policy improvement theorem, although I will not prove \n    this here.\n\\end{document}", "meta": {"hexsha": "c927fa5da2b01f2708a35019657355b1212ef9e2", "size": 29840, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ML/Exam/ReinforcementLearning.tex", "max_stars_repo_name": "lukaspj/Uni-Notes", "max_stars_repo_head_hexsha": "cdaf3c70040fe2cd3f8edb4aa1914c1d2e021cd8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-06-13T15:41:03.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-13T15:41:03.000Z", "max_issues_repo_path": "ML/Exam/ReinforcementLearning.tex", "max_issues_repo_name": "lukaspj/Uni-Notes", "max_issues_repo_head_hexsha": "cdaf3c70040fe2cd3f8edb4aa1914c1d2e021cd8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ML/Exam/ReinforcementLearning.tex", "max_forks_repo_name": "lukaspj/Uni-Notes", "max_forks_repo_head_hexsha": "cdaf3c70040fe2cd3f8edb4aa1914c1d2e021cd8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.4482758621, "max_line_length": 82, "alphanum_fraction": 0.6522788204, "num_tokens": 7956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.41961917030830426}}
{"text": "\\documentclass{article}\n\\title{Diagonal projections and rank histograms for measuring the distance between estimated copulas and observed data}\n\\author{Ma\\\"{e}l Forcier}\n\\date{May 2017}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{mathtools}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n \\usepackage{relsize}\n\\usepackage{stmaryrd}\n\\usepackage{dsfont} \n\\renewcommand\\qedsymbol{$\\blacksquare$}\n\n\\begin{document}\n   \\maketitle\n   \\section{Introduction}\n  \tTo create scenarios for renewable energies production, we need to be able to measure the dependance through space and time or between different sources. To focus on the correlation, we use copulas. Giving a set of datas, different methods exist to choose the best copulas and parameters that will best fit and model our datas. Nevertheless, we need tools to verify and measure how each of the copulas fit our observed data. Moreover, we need a tool that focus on the tails where the dependance matters a lot for us. I will briefly present in section 1, the loglikelihood which is a classical way to measure the overall fit of a distribution. Then, I will describe more precisely a way to measure how a copula fit the datas in the tail using rank histogram on diagonal projections.\n  \t\n   \\section{Loglikelihood}\n   Present briefly the loglikelihood. Refer to a good paper explaining loglikelihood ?\n   \n   \n   \\section{Solving the problem of unreproducibility}\n\tEach day j, we look at a set of data including for example a description of the state of the system early in the morning and the observations of the 90 previous days. With this set of data, we are able to choose a distribution represented by its cumulative density function \\begin{math}F_j\\end{math} with a set of parameters \\begin{math} \\theta_j \\end{math} that we hope will predict the best what will happen on day j. Some techniques are presented in \\cite{vineconstruction} or \\cite{fourcopulas} but we will not focus on them in this article. We now want to verify if this distribution was well chosen. \\newline\n\t\\newline\n   Unfortunately, we only observe what happens on the day j once. Let us note \\begin{math}O_j \\end{math} the day j observation. \\begin{math}O_j \\end{math} is not sufficient to check if this random variable follow the distribution \\begin{math} F_j \\end{math}. Moreover, each day is different and for instance another day \\begin{math}i\\neq j\\end{math}  will give a different distribution \\begin{math} F_i \\end{math} with different parameters \\begin{math} \\theta_i \\end{math}. Thus, it is impossible to verify if each distribution is correct each day. Nevertheless, their are techniques to verify if our procedure is valid and if the estimation of distributions makes sense. \\newline\n   \\newline\n   \n   Let us define \\begin{math}U_j = F_{j}(O_{j})\\end{math}. It is easy to prove that \\begin{math} U_j\\end{math} should have a uniform distribution. (This classical result is often used to generate a random variable X following cumulative density function F with uniform random variable U : \\begin{math}X = F^{-1}(X)\\end{math}.)\n   As all \\begin{math}U_j\\end{math} are computed independantly, all the \\begin{math}U_j\\end{math} must be independant and distributed uniformly.\\newline\n   \\newline\n   We now have a set of observation \\begin{math} \\textbf{U} = (U_1,..U_n)\\end{math} that should be independant and uniformly distributed on [0,1]. We can now compute the extent to which it follows a uniform distribution for example by computing the Earth Mover Distance between the empirical distribution of U and the uniform distribution or by using rank histograms.\n    \n\t\\section{Rank histograms}   \n   \n   Imagine we have our problem in 1 dimension.\n   Give an example in dimension 1.\n   Present rank histograms refers to \\cite{hamill2000}\n   \\newline\n   \\newline\n   As one can see in \\cite{hamill2000}, the biggest problem with rank histograms is that they are primarly useful only in one dimension. So we have to make projection. Projecting on the marginals is useless because what we care about is the dependance. Thus, we will project on the diagonals. This way we can measure the fit of the copulas in the corner that we are interested in.\n   \n   \n\t\\section{Earth Mover Distance}\n\t \\newtheorem{definition}{Definition}\n\t \\begin{definition}\n\t The \\textbf{Earth Mover Distance} (EMD) between two histograms $P=((x_i,p_i))_i$ and $Q=((y_j,q_j))_j$ is :\n\t \\begin{equation*}\t \n\t EMD(P,Q) = \\frac{\\min\\limits_{(f_{i,j}) \\in F} \\sum_{i,j} f_{i,j} d_{i,j}}{ \\min(\\sum_i p_i, \\sum_i q_i)}\n\t \\end{equation*}\n\t \\newline\n\t where \\begin{math}F=\\{(f_{i,j})| f_{i,j}\\geq 0,\\sum\\limits_{i} f_{i,j} \\leq P_i, \\sum\\limits_{j} f_{i,j} \\leq Q_j, \\sum\\limits_{i,j} f_{i,j} = \\min(\\sum\\limits_i p_i, \\sum\\limits_i q_i)\\} \\end{math}\\newline\n\t and $d_{i,j}$ is the distance between $x_i$ and $y_j$.\n\t\\end{definition}\n\t\n\tIn our problem, we look at histograms of distribution with real density function. So, with probability 1 we will not have the same result twice. Thus, the weight of our histograms will just be 1 for each value : $\\forall i, q_i =1, \\forall j, p_j=1$.\\newline\n\tMoreover, we will only consider vectors with same dimension n. We can now simplify the notation and define the EMD between two vectors :\n\t\n\t\n\t\\begin{definition}\n\t The \\textbf{Earth Mover Distance} (EMD) between two vectors $\\textbf{u}=(u_1,...,u_n)$ and $\\textbf{v}=(v_1,...,v_n)$ of dimension n is :\n\t \\begin{equation*}\n\t EMD(\\textbf{u},\\textbf{v}) = \\frac{1}{n}\\min\\limits_{(f_{i,j}) \\in F} \\sum_{i=1}^n \\sum_{j=1}^n f_{i,j} d_{i,j}\n\t \\end{equation*}\n\t \\newline\n\t where \\begin{math}F=\\{(f_{i,j})| f_{i,j}\\geq 0,\\sum\\limits_{i=1}^n f_{i,j} \\leq 1, \\sum\\limits_{j=1}^n f_{i,j} \\leq 1, \\sum\\limits_{i=1}^n \\sum\\limits_{j=1}^n f_{i,j} = n\\}\\end{math}\n\t \\newline\n\t and $d_{i,j}=|u_i-v_j|$\n\t\\end{definition}\n\t\n\tSolving this linear program is possible but there is a faster way to compute the EMD thanks to the following property : \n\t\n\t\\newtheorem{property}{Property}\n\t\\begin{property}\n\tFor any vectors \\textbf{u} and \\textbf{v} of dimension n :\n\t\\begin{equation*}\t\n\tEMD(\\textbf{u},\\textbf{v}) = \\frac{1}{n} \\sum_{i=1}^n |\\tilde{u}_i - \\tilde{v}_i| =  \\frac{1}{n}||\\tilde{\\textbf{u}}-\\tilde{\\textbf{v}}||_1\n\t\\end{equation*}\n\twhere $\\tilde{\\textbf{x}}$ is the sorted vector of $\\textbf{x}$ :\n\t\\newline\n\t$\\{x_1,...,x_n\\}=\\{\\tilde{x}_1,...,\\tilde{x}_n\\}$ and $\\forall i \\leq j, \\tilde{x}_i \\leq \\tilde{x}_j$\\newline\n\t\\end{property}\n\n\n\n\t\\textbf{Demonstration :}\\newline\n\t\\newline\n\tFirst we have :\n\t\\begin{multline*}\n\t\\begin{split}\n\tF\t&= \\{(f_{i,j})| f_{i,j}\\geq 0,\\sum\\limits_{i=1}^n f_{i,j} \\leq 1, \\sum\\limits_{j=1}^n f_{i,j} \\leq 1, \\sum\\limits_{i=1}^n \\sum\\limits_{j=1}^n f_{i,j} = n\\} \\newline \\\\\n\t\t&= \\{(f_{i,j})| f_{i,j}\\geq 0,\\sum\\limits_{i=1}^n f_{i,j} = 1, \\sum\\limits_{j=1}^n f_{i,j} = 1 \\}\n\t\\end{split}\n\t\\end{multline*}\n\tThe way $\\supset$ is trivial.\\newline\n\t\\newline\n\tLet be $(f_{i,j})_{i,j} \\in F$ and let us suppose that $\\exists i_0, \\sum\\limits_{i=1}^n f_{i_0,j} < 1 : \\sum\\limits_{i=1}^n f_{i_0,j} = 1-\\epsilon $.\\newline\n\tThus, $\\sum\\limits_{i=1}^n \\sum\\limits_{j=1}^n f_{i,j} \\leq 1-\\epsilon +\\sum\\limits_{i=1,i\\neq i_0}^n 1= n-\\epsilon < n $\\newline\n\t$(f_{i,j})_{i,j} \\notin F$ : Contradiction \\newline\n\t\\newline\n\tWe will now demonstrate that it exists $f_{i,j}$ integers that solve the minimum problem. This a classical demonstration using several theorems. For any precision, see the chapter 2 of \\cite{gaubert}.\\newline\n\t\n\tLet us define $M = (M_{k,(i,j)}) \\in \\mathcal{M}_{2n,n^2}(\\mathbb{R})$ with :\\newline\n\t\\[\n   \t\tM_{k,(i,j)} =  \\begin{cases}\n        1  & \\quad \\text{if } k=i \\\\\n    \t-1 & \\quad \\text{if } k=j+n\\\\\n    \t0 & \\quad \\text{else}\\\\\n  \t\\end{cases}\n  \t\\]\n\tBecause $1\\leq i,j \\leq n$ the cases are incompatible.\\newline\n\t\\newline\n\tWe now have :\\newline\n\t\\begin{equation*}\n\tF = \\{(f_{i,j})| f_{i,j}\\geq 0, Mf = B \\}\n\t\\end{equation*}\n\twhere $B = \n \t\\begin{pmatrix}\n \t 1  \\\\\n \t \\vdots \\\\\n  \t1 \\\\\n  \t-1 \\\\\n  \t\\vdots  \\\\\n  \t-1 \n \t\\end{pmatrix}$\\newline\n \t\\newline\n \tThe coefficient of M are just -1,0 and 1 and \n\tM has just once 1 and once -1 on each of its column. \\newline\n\tThanks to the Poincaré lemma (see \\cite{gaubert} chapter 2), we can say that M is totally unimodulary. Because B has integer coefficient, we can say that all extreme points of F have integer coefficients.\\newline\n\tSo, we finally have it exists $f_{i,j}$ integers that solve the minimization problem.\\newline\n\t\\newline\n\tLet $(f_{i,j})_{i,j}$ solve the mnimization problem with integer coefficients.\\newline\n\t$\\forall i, \\forall j, 0\\leq f_{i,j} \\leq 1$ and $f_{i,j}\\in \\mathbb{N} \\Rightarrow f_{i,j} =0$ or $ f_{i,j} =1$ \\newline\n\t$\\forall i, \\sum\\limits_{j=1}^n f_{i,j} = 1 \\Rightarrow \\exists ! j_0,  f_{i,j_0} =1$\\newline\n\t$\\forall j, \\sum\\limits_{i=1}^n f_{i,j} = 1 \\Rightarrow \\exists ! i_0,  f_{i_0,j} =1$\\newline\n\t\\newline\n\tWe now have :\n\t\\begin{equation*}\n\t\\exists \\sigma \\in \\mathfrak{S}_n, f_{i,j} =  \\begin{cases}\n        1  & \\quad \\text{if } j=\\sigma(i) \\\\\n    \t0 & \\quad \\text{else}\\\\\n  \t\\end{cases}\n\t\\end{equation*}\n\tSo,\n\t\\begin{equation*}\n\tEMD(\\mathbf{u},\\mathbf{v}) = \\min\\limits_{\\sigma \\in \\mathfrak{S}_n} \\sum_{i=1}^n d_{i,\\sigma{i}} = \\min\\limits_{\\sigma \\in \\mathfrak{S}_n} \\sum_{i=1}^n |u_i-v_{\\sigma (i)}|\n\t\\newline\n\t\\newline\n\t\\end{equation*}\n\t\n\tWe now have to prove that this min is reached when $(u_i)_i$ is sorted in the same order than $(v_{\\sigma (i)})_i$. Since the indexes have symetric roles and are just notations indicating coefficients, we can consider that u and v are sorted :\\newline\n  $\\forall i \\leq j, u_i \\leq u_j, v_i \\leq v_j$\\newline\n  With this notation, we need to prove that this minimum is reached for $\\sigma = Id$.\\newline\n  \\newline\n  Suppose that $\\sigma \\neq Id$ reaches the minimum, so $supp(\\sigma)\\neq \\emptyset$ and $supp \\sigma$ contains at least two elements. Let us define:\n \n  \\begin{multline*}\n\t\\begin{split}\n\tq\t&=  \\max supp(\\sigma)\\\\\n\tp\t&=  \\sigma^{-1}(q) \\\\\n\tr \t&= \\sigma (q)\n\t\\end{split}\n\t\\end{multline*}\n\t\n\tWe have $q\\leq p$ and $r\\leq p$, so $u_q\\leq u_p$ and $v_r\\leq v_p$.\n\t\n\t\n\t\\begin{itemize}\n\t\\item Case 1 : $u_p \\leq u_q \\leq v_r \\leq v_q$\n\t\\end{itemize}\n\t\n\t\\begin{multline*}\n\t\\begin{split}\n\t|u_p-v_q| + |u_q-v_r|\t&=  v_q-u_p+v_r-u_q\\\\\n\t\t&=  v_r-u_p+v_q-u_q \\\\\n\t \t&= |u_p-v_r|+|u_q-v_q|\n\t\\end{split}\n\t\\end{multline*}\n\t\t\n\t\n\t\\begin{figure}\n      \\includegraphics[width=0.5\\textwidth]{demo_sort1.png}\n    \\caption{Graphic representation of case 1 : \\emph{The upper black line represents \\textbf{v} and the lower one \\textbf{u}. The red points are from left to right $v_r$ and $v_q$ and The green points are from left to right $u_p$ and $u_q$. The blue lines represent what the cost when using $\\sigma$ and the green lines  the cost when using $\\tilde{\\sigma}$. } }\n\\end{figure}\n\n\\begin{itemize}\n\t\\item Case 2 : $u_p\\leq v_r \\leq u_q \\leq v_q$\n\t\\end{itemize}\n\t\n\t\\begin{multline*}\n\t\\begin{split}\n\t|u_p-v_q| + |u_q-v_r|\t&\\leq  |u_p-v_q|\\\\\n\t\t&=  v_q-u_p \\\\\n\t \t&= v_q-u_q+u_q-u_p\\\\\n\t \t&\\leq v_q-u_q+v_r-u_p\\\\\n\t \t&= |u_q-v_q|+|u_p-v_r|\n\t\\end{split}\n\t\\end{multline*}\n\n\\begin{figure}\n  \n    \\includegraphics[width=0.5\\textwidth]{demo_sort2.png}\n     \\caption{Graphic representation of case 2 : \\emph{The upper black line represents \\textbf{v} and the lower one \\textbf{u}. The red points are from left to right $v_r$ and $v_q$ and The green points are from left to right $u_p$ and $u_q$. The blue lines represent what the cost when using $\\sigma$ and the green lines  the cost when using $\\tilde{\\sigma}$. } }\n\\end{figure}\n\n\\begin{itemize}\n\t\\item Case 3 : $u_p\\leq v_r \\leq v_q \\leq u_q$\n\t\\end{itemize}\n\t\n\\begin{figure}\n  \n    \\includegraphics[width=0.5\\textwidth]{demo_sort3.png}\n     \\caption{Graphic representation of case 3 : \\emph{The upper black line represents \\textbf{v} and the lower one \\textbf{u}. The red points are from left to right $v_r$ and $v_q$ and The green points are from left to right $u_p$ and $u_q$. The blue lines represent what the cost when using $\\sigma$ and the green lines  the cost when using $\\tilde{\\sigma}$. } }\n\\end{figure}\t\n\t\n\t\\begin{multline*}\n\t\\begin{split}\n\t|u_p-v_q| + |u_q-v_r|\t&=  v_q-u_p+u_q-v_r\\\\\n\t\t&=  u_q-u_p+v_q-v_r \\\\\n\t \t&\\leq u_q-u_p\\\\\n\t \t&= u_q-v_q+v_q-u_p\\\\\n\t \t&\\leq u_q-v_q+v_r-u_p\\\\\n\t \t&= |u_q-v_q|+|u_p-v_r|\n\t\\end{split}\n\t\\end{multline*}\n\t\n\t\n\t\\begin{itemize}\n\t\\item Case 4 : $v_r\\leq v_q \\leq u_p \\leq u_q$\\newline\n\tSame as case 1 by inversing the symetric roles of \\textbf{u} and \\textbf{v}.\n\t\n\t\\item Case 5 : $v_r\\leq u_p \\leq v_q \\leq u_q$\\newline\n\tSame as case 2 by inversing the symetric roles of \\textbf{u} and \\textbf{v}.\n\t\n\t\\item Case 6 : $v_r\\leq u_p \\leq u_q \\leq v_q$\\newline\n\tSame as case 3 by inversing the symetric roles of \\textbf{u} and \\textbf{v}.\n\t\\end{itemize}\n\nIn all this cases, we have :\n\\begin{equation*}\n\t|u_p-v_q| + |u_q-v_r| \\leq |u_q-v_q|+|u_p-v_r|\n\\end{equation*}\nLet us define $\\tilde{\\sigma} = \\sigma \\circ (p q)$ :\\newline\n\\begin{equation*}\n \t\\forall i \\notin \\{p,q\\}, \\tilde{\\sigma} (i)=\\sigma (i)\n\\end{equation*}\n\\begin{equation*}\n \t\\tilde{\\sigma} (p)=r\n\\end{equation*}\n\\begin{equation*}\n \t\\tilde{\\sigma} (q)=q\n\\end{equation*}\n\nThen  we have\n\n\\begin{multline*}\n\t\\begin{split}\n\t\\sum_{i=1}^n |u_i-v_{\\sigma (i)}|\t&= \\sum_{i\\notin \\{p,q\\}} |u_i-v_{\\sigma (i)}|+|u_p-v_q|+|u_q-v_r|\\\\\n\t \t&\\leq \\sum_{i\\notin \\{p,q\\}} |u_i-v_{\\sigma (i)}|+|u_q-v_q|+|u_p-v_r|\\\\\n\t \t&=\\sum_{i=1}^n |u_i-v_{\\tilde{\\sigma} (i)}|\n\t\\end{split}\n\t\\end{multline*}\n\nSo, $\\tilde{\\sigma}$ reaches the minimum too and $supp(\\tilde{\\sigma}) = supp(\\sigma) \\setminus \\{\\max supp(\\sigma) \\}$. By doing this operation many times, we can remove all the elements of $supp(\\sigma)$. So Id reaches the minimum. $\\Box$\n\n   \n   \\section{Projection on diagonal}\n   Because we are very interested in extreme events, we will focus on tails of the multivariate distribution. To study their dependance, it is interesting to consider the corners of the space of copulas which is an hypercube.\n   \\subsection{Corner}\n  \n\t\\begin{definition}\n\t\tA \\textbf{corner} of an hypercube \\begin{math} [0,1]^d \\end{math} is a point \\begin{math} \\textbf{a}=(a_1,...,a_d) \\in \\{0,1\\}^d \\end{math} : \\begin{equation*}\n\t\t\\forall i \\in  \\llbracket 1,d \\rrbracket, a_{i} = 0 \\text{ or } a_{i}=1 \n\t\t\\end{equation*}\n\t\\end{definition}\n\tSo there is \\begin{math} 2^d\\end{math} corners in a hypercube of dimension d.\\newline\n\t\n\t\\subsection{Diagonal}\t\n\t\n\t\\begin{definition}\n\t\tA \\textbf{diagonal} \\begin{math} \\Delta \\end{math} is a segment which links to opposite corner \\textbf{a} and \\textbf{b} :\n\t\t\\begin{equation*}\n\t\t\t\\Delta =[\\textbf{a},\\textbf{b}]\\text{ where }\\newline\n\t\t\t\\forall i \\in \\llbracket 1,d \\rrbracket , a_i = 0 \\iff b_i=1\n\t\t\\end{equation*}\n\t\t\tAlternatively :\n\t\t\\begin{equation*}\n\t\t\t\\Delta =\\{(1-\\lambda)\\textbf{a} + \\lambda \\textbf{b}, \\lambda \\in [0,1]\\}, \\text{ where }\\newline\n\t\t\t\\forall i \\in \\llbracket 1,d \\rrbracket , a_i = b_i\\text{ mod 2 }\n\t\t\\end{equation*}\n\tBecause one diagonal can be written [\\textbf{a},\\textbf{b}] or [\\textbf{b},\\textbf{a}], we will always consider \\begin{math} a_1 =0 \\end{math} so that each diagonal has a unique way notation.\\newline\n\t\\newline\n\tWe can also define the \\textbf{direction} of a diagonal as the vector :\n\n\t\\begin{equation*}\n\t\tU_\\Delta =\\frac{1}{\\sqrt{d}}(\\textbf{b}-\\textbf{a})\n\t\\end{equation*}\n\t\\end{definition}\t\n\t\t\n\t\n   \\subsection{Projection}\n\t\n\t\n\t\\begin{definition}\n\tThe \\textbf{matrix of projection} on the linear space will be :\n\t\\begin{equation*}\n\t\tM_\\Delta = U_\\Delta U_\\Delta^\\top\n\t\\end{equation*}\n\t\n\tFinally, the \\textbf{projection on the diagonal} which is an affine space is the function \\begin{math} P_\\Delta \\end{math} such that :\n\t\\begin{equation}\n\t\tP_\\Delta(X) = M_\\Delta(X-C)+C \\text{ where } C=(\\frac{1}{2},...,\\frac{1}{2})\n\t\\end{equation}\n\t\n\t\n\t\\end{definition}\n\t\n\t\n\tSo there are \\begin{math} 2^{d-1}\\end{math} diagonals, directions and matrix of projection in an hypercube of dimension d.\\newline\n\t\\newline\n\tThe division by \\begin{math} \\sqrt{d} \\end{math} in the definition of direction permits to have a unit vector.\\newline\n\t\\newline\n\tM is indeed a matrix thanks to the order of the factors (and not a scalar product as \\begin{math} U^\\top U \\end{math}).\\newline\n\t\\newline\n\tOne should not confuse the matrix of projection on the linear space and the traditional affine projection on the diagonal. That is why we need to translate everything with the center of the hypercube C.\n\t\\newline\n\t\\begin{figure}\n  \n    \\includegraphics[width=0.7\\textwidth]{Diagonals3d.png}\n    \\caption{Examples of diagonals, \\emph{The blue one is [(0,0,0),(1,1,1)], the yellow one is [(0,1,0),(1,0,1)], the green one is [(0,1,1),(1,0,0)],  and the red one is [(0,0,1),(1,1,0)] }}\n\\end{figure}\n\n\\begin{figure}\n  \n    \\includegraphics[width=0.7\\textwidth]{proj2Ddiag0.png}\n    \\caption{Projection of 30 points on the [(0,0),(1,1)] diagonal \\emph{The diagonal is in blue, the initial points are green and their projections are red.}}\n\\end{figure}\n\n\t\\begin{figure}\n  \n    \\includegraphics[width=0.7\\textwidth]{proj3d.png}\n    \\caption{Projection of 20 points on the [(0,0,0),(1,1,1)] diagonal \\emph{The diagonal is in blue, the initial points are green and their projections are red.}}\n\\end{figure}\n\t   \n\t  \\begin{figure}\n  \n    \\includegraphics[width=0.7\\textwidth]{proj3Ddiag2.png}\n    \\caption{Projection of 20 points on the [(1,0,0),(0,1,1)] diagonal \\emph{The diagonal is in blue, the initial points are green and their projections are red.}}\n\\end{figure}\n\n\n\t\\subsection{Distribution on the diagonal}\n\tWe now want to study the distribution of the points projected on the diagonal to compare it to a uniform distribution. Since the diagonal is a segment, each point x of the diagonal can be described by only one scalar number $\\lambda$ : $x = (1-\\lambda)a+\\lambda b $ (cf Definition of the diagonal). \\newline\n\t$\\lambda$ can be understood as the normalised distance between a and x :\n\t\\begin{equation*}\n\t\t\\| x-a \\|\t= \\| (1-\\lambda)a+\\lambda b\\|\n\t\t\t\t\t= \\lambda \\| a - b \\|\n\t\t\t\t\t= \\lambda \\sqrt{d} \n\t\\end{equation*}\nWhere $\\| . \\|$ is a norm in our space.\\newline\n\\newline\nBut $\\lambda$ can be easily evaluated by taking the first coordonates of x : \n\t\\begin{equation*}\n\t\tx_1 = (1-\\lambda)a_1 + \\lambda b_1 = (1-\\lambda) *0 + \\lambda *1 = \\lambda \n\t\\end{equation*}\nThis equality is possible thanks to our useful convention $(a_1,b_1)= (0,1)$.\\newline\n\\newline\nWe now have a unique number that should be uniformly distributed on [0,1].\n\n\t\n\n\t  \n\t  \\section{Our algorithm}\n\t  \n\t  For each day j do :\n\n\\begin{itemize}\n\n\\item Thanks to all day \\begin{math}i \\leq j-1\\end{math}, fit a parametric distribution model with copula \\begin{math} C_j \\end{math}\n\n\\item Generate n realizations U of the random variable with the copula dependance and uniform marginals :\\newline\n\n\tGenerate \\begin{math} \\textbf{U}=(U_1,...,U_n) \\end{math} with each \\begin{math} U_i = (U_{i,1},...,U_{i,d}) \\in [0,1]^d \\end{math} \\newline\n\\newline\t\n\t where \\begin{math} \\forall i \\in \\llbracket 1,n \\rrbracket , \\newline \\mathbb{P} (U_{i,1} \\leq u_1,..., U_{i,d} \\leq u_d )= C(u_1,...,u_d) \\text{ and } \\newline\n\t( \\forall j \\in \\llbracket 1,d \\rrbracket, U_{i,j} \\end{math} is uniformly distributed on [0,1].) \\newline\n\tFor example, n=10000  \\newline\n\t\n\t\n\t\n\\item For each diagonal $\\Delta$ : \n\\item \nProject all the \\begin{math} U_i \\end{math} on the diagonal\n\\newline\n\tDefine \\begin{math} \\textbf{V}_{\\Delta} =(V_{\\Delta ,1},...,V_{\\Delta ,n})=(P_\\Delta(U_1),...,P_\\Delta(U_n)) \\end{math}\n\n\\item Define the empirical distribution on this diagonal : \\newline\n\\newline\n\t\\begin{math} F_\\Delta (X) = \\frac{1}{n} \\sum_{k=1}^n \\mathds{1}_{X \\leq V_{\\Delta ,k}} \\end{math}\n\t\\newline\n\t\\newline\n\twhere \\begin{math} a \\leq b \\iff \\forall i \\in \\llbracket 1,d \\rrbracket,  a_i \\leq b_i  \\end{math}\n\t\n\\item Observe with the data what happened on day j \\newline\n\t\tCall this observation $O_j = (O_{j,1},...,O_{j,d})$\n\n\\item Pass it in the copula space \\newline\n\t\tDefine \\begin{math} Q_j = (F_1 (O_{j,1}),...,F_d (O_{j,d})) \\end{math} \\newline\n\t\twhere the $F_i$ are the cumulative density functions of the marginals estimated with another method.\n\t\t\n\\item Project $Q_j$ on the diagonal \\newline\n\t\tDefine $R_{\\Delta ,j} = P_\\Delta (Q_j)$\n\n\\item Either define $S_{\\Delta,j} = F_\\Delta (R_{\\Delta,j})  $ \\newline\n\tand compute the distance between the empirical distribution of the $S_{\\Delta}=(S_{\\Delta,i})_{i \\in days}$  and the uniform distribution on [0,1].\n\n\\item Or make a rank histogram with the $R_{\\Delta}=(R_{\\Delta,i})_{i \\in days}$\n\t\\begin{math} F_\\Delta^{-1} (P_j) \\end{math}\n\t\n\t\\section{Test code}\n\t\n\tIn this section, I will explain how we computed this algorithm with different parameters. They are arguments of many test functions I wrote and are just strings defining options :\\newline\n\t\n\tsource : the type of power source we want it can be 'solar' or 'wind'\\newline\n\t\n\tdatatype : if the datas is power ('actuals'), errors ('errors), a normal distributed sample ('normal-sample') or a uniformly distributed sample ('uniform-sample'), the two last ones are options to make verifications. \\newline\n\t\n\tsegment_marginals : the way you segment the datas to fit the marginals, you can either take only the date at the hour of your dps ('hour') or fit this marginal with the datas of the whole day ('anytime'). Note : this is not the way the datas are segmented to fit the copula.\n\t\n\tkind : which projection you want it can be on a diagonal ('diagonal'), a marginal ('marginal') or can even compose with the kendall function ('kendal'). \\newline\n\t\n\tindex : the index of the diagonal or the marginal you want to project with. Diagonals are indexed in the order of diag. list of diags. Marginals are index as the coordonates. index does not matter for kendall function.\\newline\n\t\n\tmethod : way you choose the data to fit the distributions, you can either fit copulas and marginals with the datas of the whole year and check the observation then ('wholeyear'), or you \n\t\n\t\n\t\n\n\\end{itemize}\n\t\n\t   \n   \n   \n   \n   \\begin{thebibliography}{9}\n\n\t\\bibitem{hamill2000}\n  \tThomas M. Hamill,\n \t \\emph{Interpretation of Rank Histograms for Verifying Ensemble Forecasts},\n  \t2000.\n\n\t\\bibitem{vineconstruction}\n  \tKjersti Aas, Claudia Czado, Arnoldo Frigessi, Henrik Bakken,\n \t \\emph{Pair-copula construction of multiple dependence},\n  \t2007.\n  \t\n  \t\\bibitem{fourcopulas}\n  \tKjersti Aas,\n \t \\emph{Modeling the dependance structure of financial assets : A survey of four copulas},\n  \t2004.\n  \t\n  \t\\bibitem{gaubert}\n  \tStéphane Gaubert, Frédéric Bonnans,\n  \t\\emph{Recherche opérationnelle : aspects mathématiques et applications},\n  \tEditions de l'École polytechnique,\n  \t2016\n\n\t\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "2348b2a5d7997c1cd6b071929c9a76871a838cb3", "size": 22599, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "prescient/gosm/Latex/diagonal projection.tex", "max_stars_repo_name": "iSoron/Prescient", "max_stars_repo_head_hexsha": "a3c1d7c5840893ff43dca48c40dc90f083292d26", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2020-06-03T13:54:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T18:20:35.000Z", "max_issues_repo_path": "prescient/gosm/Latex/diagonal projection.tex", "max_issues_repo_name": "iSoron/Prescient", "max_issues_repo_head_hexsha": "a3c1d7c5840893ff43dca48c40dc90f083292d26", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 79, "max_issues_repo_issues_event_min_datetime": "2020-07-30T17:29:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-09T00:06:39.000Z", "max_forks_repo_path": "prescient/gosm/Latex/diagonal projection.tex", "max_forks_repo_name": "bknueven/Prescient", "max_forks_repo_head_hexsha": "6289c06a5ea06c137cf1321603a15e0c96ddfb85", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2020-07-14T17:05:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-17T17:51:13.000Z", "avg_line_length": 47.9808917197, "max_line_length": 783, "alphanum_fraction": 0.6913580247, "num_tokens": 7668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4196191659482787}}
{"text": "\\chapter{Text-Structure and Math}\nIn this very first chapter, we clarify how to add your math within the text in a proper way. Below you will find some small samples of the book \\emph{''Single Channel Phase-Aware Signal Processing in Speech Communication: Theory and Practice''} \\cite{MowlaeePejman2016}, may this example arouses your interest to dig more into the \\emph{Signal Processing} and it's related topic \\emph{Speech Processing}.\n\n\\begin{mdframed}\n\t\\begin{lstlisting}[caption={Adding section and subsection}]\n\t\t\\section{Phase Estimation Fundamentals}\n\t\t\\subsection{Background and Fundamentals}\n\t\tThe problem of interest in many signal processing.......\t\n\t\\end{lstlisting}\n\\end{mdframed}\n\n\\section{Phase Estimation Fundamentals}\n\\subsection{Background and Fundamentals}\nThe problem of interest in many signal processing applications including radar, spectrum estimation and signal enhancement, is to detect a signal of interest in a noisy observation. The signal of interest is often represented as a sum of sinusoids characterized by their amplitude, frequency and phase parameters. Since these parameter triplet suffices to describe the signal, the problem degenerates to the detection and estimation of the sinusoidal parameters. This topic has been widely addressed in the literature of signal detection \\cite{VanTrees1968} and estimation \\cite{Kay1993}. While many previous studies have been focused on deriving estimators for amplitude and frequency of sinusoids in noise (see e.g. \\cite{Stoica2005} for an overview), the issue of phase estimation has been less addressed. Reliable phase estimation for practical applications has not been adequately addressed, in particular for signal enhancement.\n\\begin{mdframed}\n\t\\begin{lstlisting}[caption={Add citations into your text}]\n\t......the sinusoidal parameters. This topic has been widely addressed in the \n\tliterature of signal detection \\cite{VanTrees 1968} and estimation \n\t\\cite{Kay 1993}.\n\t\\end{lstlisting}\n\tDo not forget to add these specific bibliography fields into your \\emph{.bib} file!\n\\end{mdframed}\n\\section{Key Examples: Phase Estimation Problem}\\label{ch3:PE1}\n\\subsection{Example 1: discrete-time sinusoid}~\\\\\n\\noindent To reveal the phase structure of one sinusoid's frequency response we consider the following real-valued sequence\n\\begin{equation}\\label{eq:c3.1}\nx(n)=\\cos(\\omega_0n+\\phi),\n\\end{equation}\nwith $\\omega_0$ as frequency and $\\phi$ as phase shift. Application of the \\index{discrete-time Fourier transform}discrete-time Fourier transform (\\gls{DTFT}), defined as\n\\begin{equation}\\label{eq:c3.2}\nX(e^{j\\omega})=\\text{\\gls{DTFT}T}\\left(x(n)\\right)=\\sum_{n=-\\infty}^{\\infty}x(n)e^{-j\\omega n},\n\\end{equation}\nyields the following frequency domain representation of the sequence $x(n)$\n\\begin{equation}\\label{eq:c3.3}\nX(e^{j\\omega})=\\pi e^{j\\phi}\\delta(\\omega-\\omega_0)+\\pi e^{-j\\phi}\\delta(\\omega+\\omega_0),\n\\end{equation}\nwith $\\delta(\\omega)$ denoting the \\index{Dirac delta}Dirac delta function. As the cosine function is \\index{symmetric}symmetric $\\left(\\cos(\\omega_0 n)=\\cos(-\\omega_0 n)\\right)$, only the phase shift $\\phi$ determines the phase response of $X(e^{j\\omega})$\n\\begin{equation}\\label{eq:c3.4}\n\\angle X(e^{j\\omega})=\\begin{cases}\\phi, & \\omega=\\omega_0,\\\\\n-\\phi, & \\omega=-\\omega_0\n\\end{cases}.\n\\end{equation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%% FIGURE 3.1 %%%%%%%%%%%%%\n\\begin{figure}\n\t\\center % 20 587 530 727\n\t\\includegraphics{figures/figure3_1.eps}\n\t\\vspace{-0.6cm}\n\t\\caption{Visualization of window impact on a sinusoid $x(n)=\\cos(\\omega_0 n+\\phi)$ in time and frequency domain with $\\omega_0=0.1\\cdot2\\pi$ and $\\phi=-\\pi/8$ and a rectangular window with length $N_w=21$. The window \\gls{DTFT}T $W(e^{j\\omega})$ is shifted dependent on $\\omega_0$ and multiplied by $e^{j\\phi}$ and $e^{-j\\phi}$, respectively, as shown in the phase response of $\\text{\\gls{DTFT}T}\\left(x(n)w(n)\\right)$}\\label{Figure31}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\noindent The left column of Figure~\\ref{Figure31} represents the sequence $x(n)$ along time $n$ followed by its \\gls{DTFT}T representation with real $\\Re\\{X(e^{j\\omega})\\}$ and imaginary $\\Im\\{X(e^{j\\omega})\\}$ parts as well as magnitude $|X(e^{j\\omega})|$ and phase $\\angle X(e^{j\\omega})$ response. We set $\\omega=0.1\\cdot2\\pi$ and $\\phi=-\\pi/8$.\\\\\n\n\\noindent The result in \\eqref{eq:c3.4} is valid for an observation range of $n$ within $n\\in]-\\infty,\\infty[$. In practice only a subset of samples $n$ is available for analysis. This limitation can be represented by introducing an \\index{analysis!window}analysis window function which is multiplied with the sequence $x(n)$. The modest \\index{window!rectangular, uniform, boxcar}analysis window is the rectangular, also known as boxcar or uniform window which has the value of one within the range of $N_w$ and zero outside\n\\begin{equation}\\label{eq:c3.5}\nw(n)=\\begin{cases}1, & |n|\\leq\\frac{N_w-1}{2},\\\\\n0, & \\text{else},\n\\end{cases}\n\\end{equation}\nfor odd $N_w$.\nThis window is \\index{symmetric}symmetric $(w(n)=w(-n))$ and has the \\index{zero!-phase}\\index{phase!zero-phase}zero-phase property, yielding a real-valued \\gls{DTFT}T of the analysis window\n\\begin{equation}\\label{eq:c3.6}\nW(e^{j\\omega})=\\sum_{n=-\\infty}^{\\infty}w(n)e^{-j\\omega n}=\\sum_{n=-(N_w-1)/{2}}^{(N_w-1)/{2}}1e^{-j\\omega n}=\\frac{\\sin\\left(\\frac{N_w\\omega}{2}\\right)}{\\sin\\left(\\frac{\\omega}{2}\\right)},\n\\end{equation}\nalso known as \\index{Dirichlet kernel}\\textit{Dirichlet kernel}. The middle column of Figure~\\ref{Figure31} illustrates a \\index{symmetric}symmetric rectangular window in time and frequency domain with length $N_w=21$ and a \\gls{DTFT}T length of $N=31$ (continuous line). The real part is equal to the Dirichlet kernel and the imaginary part is equal to zero due to the symmetry of the window $w(n)$. The phase response represents the sign of $W(e^{j\\omega})$ dependent on $\\omega$ and is equal to zero within the mainlobe width.\\\\\n% Analyzing $x(n)$ within a limited range of $n\\in[-\\frac{N_w-1}{2},\\frac{N_w-1}{2}]$ is equivalent of multiplying $x(n)$ with the analysis window $w(n)$.\n\n\\noindent The product $x(n)w(n)$ corresponds to a convolution in the frequency domain according to\n\\begin{equation}\\label{eq:c1.7}\nX_w(e^{j\\omega})=\\text{\\gls{DTFT}T}\\left(x(n)w(n)\\right)=\\left\\{X\\ast W\\right\\}(e^{j\\omega}).\n\\end{equation}\n\n\\begin{mdframed}\n\t\\begin{lstlisting}[caption={Add formulars to your text}]\n\t\\begin{equation}\\label{eq:c1.7}\n\tX_w(e^{j\\omega})=\\text{\\gls{DTFT}T}\\left(x(n)w(n)\\right)=\\left\\{X\\ast W\\right\\}(e^{j\\omega}).\n\t\\end{equation}\n\t\\end{lstlisting}\n\tBy adding a label to your equation, you will be able to refer to the equation within the text!\n\\end{mdframed}\n\nPlugging $X(e^{j\\omega})$ and $W(e^{j\\omega})$, derived in \\eqref{eq:c3.3} and \\eqref{eq:c3.6}, respectively, in \\eqref{eq:c1.7} yields the following expression\n\\begin{equation}\\label{eq:c3.8}\nX_w(e^{j\\omega})=\\pi e^{j\\phi}W(e^{j(\\omega-\\omega_0)})+\\pi e^{-j\\phi}W(e^{j(\\omega+\\omega_0)}).\n\\end{equation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%% FIGURE 3.2 %%%%%%%%%%%%%\n\\begin{figure}\n\t\\center % 20 587 530 727\n\t\\includegraphics{figures/figure3_2.eps}\n\t% \\includegraphics{Ch3/Figures/figure3_2.eps}\n\t\\vspace{-0.6cm}\n\t\\caption{Relation of sinusoidal periods and window length and its impact on amplitude and phase: (a) shows a sinusoid multiplied by a boxcar window with a length of one period $(m=1)$. The Dirichlet kernels do not interfere at $\\omega=\\omega_0$ and $\\omega=-\\omega_0$ which yields an unbiased phase estimate of $\\angle X_w(e^{j\\omega_0})=\\phi$, (b) presents the more general case of a window length which does not correspond to an integer multiplier of the sinusoids period $(m=1.1)$. The amplitude as well as the phase do not approach the true value and thus, the outcome is biased.}\\label{Figure32}\n\\end{figure}\n%%%%%%%%%%%%%%%%\n\n\\begin{mdframed}\n\t\\begin{lstlisting}[caption={Example on how to add a figure to your text}]\n\t\\begin{figure}\n\t\t\\center % 20 587 530 727\n\t\t\\includegraphics{figures/figure3_2.eps}\n\t\t\\vspace{-0.6cm}\n\t\t\\caption{Relation of sinusoidal periods and window length and its impact on amplitude and phase: (a) shows a sinusoid multiplied by a boxcar window with a length of one period $(m=1)$. ...}\\label{Figure32}\n\t\\end{figure}\n\t\\end{lstlisting}\n\tBy adding a label to your figure, you will be able to refer to the figure within the text!\n\\end{mdframed}\n\nThis is a rather important observation as the Dirichlet kernels are shifted along the frequency axis to $\\omega=\\omega_0$ and $\\omega=-\\omega_0$. The multiplication by the constants $e^{j\\phi}$ and $e^{-j\\phi}$, respectively, yields a complex valued $X_w(e^{j\\omega})$ as shown in the right column of Figure~\\ref{Figure31}. The terms on the right-hand-side of \\eqref{eq:c3.8} constructively add or eliminate each other, dependent on the value of $\\phi$ and $\\omega_0$, described as \\index{leakage effect}\\emph{leakage effect}.\\\\\n\n\\noindent The interaction between the Dirichlet kernels is minimized if the frequency $\\omega_0$ fulfills the following requirement\n\\begin{equation}\\label{eq:c3.9}\n\\omega_0=\\frac{2{m}\\pi}{N_w}, \\quad m\\in\\mathbb{N}.\n\\end{equation}\nwith $m$ denoting the number of periods contained in one window length $N_w$. Figure~\\ref{Figure32} illustrates the impact of $\\omega$ on the resulting magnitude and phase response of one sinusoid $x(n)=\\cos(\\omega_0 n+\\phi)$ with $\\phi=-\\pi/8$, multiplied by a symmetric window of length $N_w=31$. Setting $\\omega_0=1\\frac{2\\pi}{N_w}$ leads to $m=1$ and for the phase response at frequency $\\omega=\\omega_0$ we obtain\n\\begin{equation}\nX_w(e^{j\\omega_0})=\\pi e^{j\\phi}W(e^{j(\\omega_0-\\omega_0)})+\\pi e^{-j\\phi}W(e^{j(\\omega_0+\\omega_0)})\\\\\n\\end{equation}\nAs the \\gls{DTFT}T of the rectangular window $W(e^{j2\\omega_0})=0$ for $m\\in\\mathbb{N}$, the phase response yields the true value of $\\phi$ at frequency $\\omega_0$.\n\\begin{align}\\label{eq:c3.10}\n\tX_w(e^{j\\omega_0})&=\\pi e^{j\\phi} CG\\\\\n\t\\angle X_w(e^{j\\omega_0})&=\\phi,\n\\end{align}\nwith defining $CG=W(e^{j0})$ as the \\index{coherent gain}{coherent gain} for the selected window\\footnote{see }. The right column of Figure~\\ref{Figure32} demonstrates the more general case of $m\\notin\\mathbb{N}$. The sidelobs of $W(e^{j\\omega})$ interact with each other, resulting in a \\index{bias}biased phase response at $\\omega_0$. Note, that the peak's location of the magnitude response is not at $\\omega_0$ due to the complex-valued superposition of both kernels. Therefore, any \\index{peak-picking}peak-picking method for obtaining a sinusoidal phase would result in a biased outcome.\\\\\n\n\\noindent In order to reduce the unpleasant impact of the sidelobe level, the choice of the window type becomes of particular interest. Basically, their behavior can be categorized by two characteristics: \\index{leakage effect}{spectral leakage} and {frequency resolution}. The frequency resolution is limited by the mainlobe width which corresponds to the ability to resolve two adjacent spectral lines. To increase the frequency resolution a window function with a small mainlobe width is preferred. As a smaller mainlobe width is on the expense of a reduced sidelobe level the choice of an appropriate window function is a trade-off between a high frequency resolution and a low sidelobe level. Another way of optimizing the window choice is to adjust the window length $N_w$ to fulfill the requirement in \\eqref{eq:c3.9}. However, adapting $N_w$ needs knowledge of $\\omega_0$ and is in general only possible for one single sinusoid. \\\\\n\n\\noindent Figure~\\ref{Figure33} shows the influence of three prominent window types on the amplitude and phase response of the sequence $x_w(n)=\\sin(\\omega_0 n+\\phi)w(n)$ with $\\omega=3.1\\cdot 2\\pi/N_w$ and $\\phi=-\\pi/8$. So far, only the rectangular window was discussed. Its high frequency resolution ($6\\,\\text{dB}$ bandwidth of the mainlobe width: $\\Delta\\omega_{\\text{MW}}=1.21\\cdot 2\\pi/N_w$) is at the cost of rather poor sidelobe suppression level of $-13\\,\\text{dB}$ for the strongest neighboring sidelobe (Fig.~\\ref{Figure33} a)). The widely used Hamming window (b) consists of three shifted Dirichlet kernels with the purpose to minimize the sidelobe levels, achieving a suppression of $-42\\,\\text{dB}$ at the cost of a worse frequency resolution ($6\\,\\text{dB}$ bandwidth of mainlobe: $\\Delta\\omega_{\\text{MW}}=1.81\\cdot 2\\pi/N_w$). The amplitude and phase response of the Hamming-windowed sinusoid reveal the advantage of a higher sidelobe suppression. The phase response at frequencies within the mainlobe width\nis determined by the true phase value $\\phi=-\\pi/8$.\nCompared to the rectangular window, the employment of a \\index{window!Hamming}Hamming window results in a more robust phase estimation if an inaccurate frequency estimate of the sinusoid is given. Further, the magnitude's peak location is less shifted which yields a more accurate phase estimation when using \\index{peak-picking}peak-picking. Finally, the \\index{window!Blackman}{Blackman} window is presented in (c) with a sidelobe suppression of $-58\\,\\text{dB}$ and a $6\\,\\text{dB}$ mainlobe bandwidth of $\\Delta\\omega_{\\text{MW}}=2.35\\cdot 2\\pi/N_w$. The neighboring phase values at $\\omega_0$ are strongly influenced by the true phase value of $\\phi$. However, both Hamming and Blackman windows deal with an increased mainlobe width. Once we extend our signal to multiple sinusoids, the mainlobe width plays a major role in selecting an appropriate window. If the mainlobe width contains more than one sinusoid then it is no longer possible to resolve the phase values of the sinusoids.\n\n%%%%%%%%%%%%% FIGURE 3.3 %%%%%%%%%%%%%\n\\begin{figure}[t]\n\t\\center % 20 587 530 727\n\t\\includegraphics{figures/figure3_3.eps}\n\t% \\includegraphics{Ch3/Figures/figure3_3.eps}\n\t% \\vspace{-0.6cm}\n\t\\caption{Illustration of different windows' impact on the magnitude and phase response of one sinusoid. The improved sidelobe suppression is at the cost of a higher mainlobe width resulting in a lower frequency resolution. For windows with higher sidelobe suppression, the phase response at frequency $\\omega_0$ is increasingly dominated by the phase $\\phi$ within the mainlobe width.}\\label{Figure33}\n\\end{figure}\n%%%%%%%%%%%%%%%%\n\n%\\input{Chapters/Captions/Figures/figure3_4}\n\\subsection{Example 2: discrete-time sinusoid in noise}~\\\\\nSo far, one sinusoid without additive noise was considered. For practical scenarios, the signal of interest is composed of multiple sinusoids corrupted with noise as shown in Figure~\\ref{Figure34}. The problem to solve is the estimation of the sinusoidal phase ${\\phi}_{h}$ given its amplitude and frequency denoted as $A_h$ and ${\\omega}_h$, respectively. Following the harmonic model of a speech signal we assume that the sinusoidal frequency ${\\omega}_h$ is constrained to be a multiple harmonic of a fundamental frequency, i.e. ${\\omega}_h=h{\\omega}_0$ with $h\\in[1,\\ldots,H]$ denoting the harmonic index\n\\begin{equation}\\label{eq:c3.11}\nx(n)=\\sum_{h=1}^H{A_h\\cos({\\omega}_hn+{\\phi}_h)}+d(n),\n\\end{equation}\nwith $\\omega_h=h2\\pi f_0/f_s$ and $d(n)$ as the additive noise. Application of a window function $w(n)$, having non zero values in the range of $[-(N_w-1)/2,(N_w-1)/2]$, yields the windowed signal $x_w(n)=x(n)w(n)$. Similar to \\eqref{eq:c3.8}, the \\gls{DTFT}T spectrum follows as\n\\begin{equation}\\label{eq:c3.12}\nX_w(e^{j\\omega})=\\sum_{h=1}^{H} A_h\\pi \\left( e^{j{\\phi}_h}W(e^{j(\\omega-{\\omega}_h)}) + e^{-j{\\phi}_h}W(e^{j(\\omega+{\\omega}_h)})\\right)+D_w(e^{j\\omega}),\n\\end{equation}\nwhere $D_w(e^{j\\omega})=\\sum_{n=-(N_w-1)/2}^{(N_w-1)/2}{d(n)w(n)e^{-j{\\omega}n}}$ and $W(e^{j\\omega})$ is the window frequency response. To have a better insight into the phase estimation problem, we are interested in the effect of the neighboring harmonics $h\\neq \\bar{h}$ on the desired harmonic $\\bar{h}$. We evaluate the frequency response of $X(e^{j\\omega_{\\bar{h}}})$ at the desired frequency ${\\omega}_{\\bar{h}}$\n\\begin{equation}\\label{eq:c3.13}\n\\begin{split}\nX_w(&e^{j\\omega_{\\bar{h}}})=A_{\\bar{h}}\\pi e^{j{\\phi}_{\\bar{h}}}\\cdot CG+A_{\\bar{h}}\\pi e^{-j{\\phi}_{\\bar{h}}}W(e^{j2\\omega_{\\bar{h}}})\\\\\n&+\\sum_{h=1,h\\neq{\\bar{h}}}^H {A_h\\pi e^{j{\\phi}_h}W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})+A_h\\pi e^{-j{\\phi}_h}W(e^{j(\\omega_{\\bar{h}}+\\omega_h)}})+D_w(e^{j\\omega_{\\bar{h}}}).\n\\end{split}\n\\end{equation}\nThe additive terms on the right-hand-side of Equation \\eqref{eq:c3.13} show the interaction of the adjacent harmonics to the desired phase $\\phi_{\\bar{h}}$ as well as the impact of the additive noise. In the following we are interested in the influence of these terms on the desired phase by re-writing \\eqref{eq:c3.13} according to\n%%%%%%%%%%%%%%%%\n%TODO \\input{Chapters/Captions/Figures/figure3_5}\n\n\\begin{equation}\\label{eq:c3.14}\nX_w(e^{j\\omega_{\\bar{h}}})=X_r(e^{j\\omega_{\\bar{h}}})e_c\n\\end{equation}\nwhere $X_r(e^{j\\omega_{\\bar{h}}})=A_{\\bar{h}}\\pi e^{j\\phi_{\\bar{h}}}$ and $e_c$ captures the phase estimation errors, given by\n\\begin{eqnarray}\\label{eq:c3.15}\ne_c&=&\\sum_{h=1}^H\\frac{A_h}{A_{\\bar{h}}}\\left( e^{j(\\phi_h-\\phi_{\\bar{h}})}W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})+ e^{-j(\\phi_h+\\phi_{\\bar{h}})}W(e^{j(\\omega_{\\bar{h}}+\\omega_h)}) \\right)\\nonumber\\\\\n&+& \\frac{1}{\\pi A_{\\bar{h}}}e^{-j\\phi_{\\bar{h}}}D_w(e^{j\\omega_{\\bar{h}}})\n\\end{eqnarray}\nIn order to get more insight on the phase error term $e_c$, in the following we derive its phase mean and variance.\\\\\n\\textbf{First moment of }$\\boldsymbol{e_c}$~\\\\\n\\noindent The mean value of the phase error term is given by\n\\begin{equation}\\label{eq:c3.16}\n\\mathbb{E}_\\phi(e_c)=\\int_{-\\pi}^\\pi e_c p(\\phi)d\\phi\n\\end{equation}\nwith $p(\\phi)$ denoting the phase distribution. Applying \\eqref{eq:c3.16} to \\eqref{eq:c3.15} the first moment of $e_c$ is given by\n\\begin{equation}\\label{eq:c3.17}\n\\begin{split}\n\\mathbb{E}_\\phi(e_c) &= \\sum_{h=1}^H\\frac{A_h}{A_{\\bar{h}}} \\mathbb{E}(e^{j(\\phi_h-\\phi_{\\bar{h}})})W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})\\\\\n&+ \\sum_{h=1}^H\\frac{A_h}{A_{\\bar{h}}} \\mathbb{E}(e^{-j(\\phi_h+\\phi_{\\bar{h}})})W(e^{j(\\omega_{\\bar{h}}+\\omega_h)})\\\\\n&+ \\frac{1}{\\pi A_{\\bar{h}}}\\mathbb{E}(e^{-j\\phi_{\\bar{h}}})D_w(e^{j\\omega_{\\bar{h}}})\n\\end{split}\n\\end{equation}\n\\textbf{Second moment of }$\\boldsymbol{e_c}$~\\\\\n\\noindent \\index{phase!error variance}The second moment of the error term is given by\n\\begin{equation}\\label{phasevar0}\n\\begin{split}\n\\mathbb{E}_\\phi\\left(e_c e_c^*\\right)&=\\!\\sum_{h_1=1}^{H-1} \\sum_{h_2=h_1+1}^H \\! C_1(\\bar{h},h_1,h_2) \\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!-\\! \\phi_{h_2} \\!+\\!\\angle w_1(\\bar{h},h_1,h_2))\\right)\\\\\n&+ \\!\\sum_{h_1=1}^{H-1} \\sum_{h_2=h_1+1}^H\\!C_2(\\bar{h},h_1,h_2)\\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!-\\! \\phi_{h_2} \\!-\\!\\angle w_2(\\bar{h},h_1,h_2))\\right)\\\\\n&+ \\!\\sum_{h_1=1}^H \\sum_{h_2=1}^H\\!C_3(\\bar{h},h_1,h_2)\\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!+\\! \\phi_{h_2} \\!+\\!\\angle w_3(\\bar{h},h_1,h_2))\\right)\\\\\n&+\\sum_{h=1}^H C_4(\\bar{h},h)\\mathbb{E}_\\phi\\left(\\cos(\\phi_h-\\phi_{\\bar{h}}+\\angle W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})D_w(e^{-j\\omega_{\\bar{h}}}))\\right)\\\\\n&+\\sum_{h=1}^H C_5(\\bar{h},h)\\mathbb{E}_\\phi\\left(\\cos(\\phi_h+\\phi_{\\bar{h}}-\\angle W(e^{j(\\omega_{\\bar{h}}+\\omega_h)})D_w(e^{-j\\omega_{\\bar{h}}}))\\right)\\\\\n&+\\frac{1}{\\pi^2A_{\\bar{h}}^2}|D_w(e^{j\\omega_{\\bar{h}}})|^2 + C_6(\\bar{h}),\n\\end{split}\n\\end{equation}\n\\begin{mdframed}\n\t\\begin{lstlisting}[caption={Add formulars to your text, splitted equations}]\n\t\\begin{equation}\\label{phasevar0}\n\t\\begin{split}\n\t\\mathbb{E}_\\phi\\left(e_c e_c^*\\right)&=\\!\\sum_{h_1=1}^{H-1} \\sum_{h_2=h_1+1}^H \\! C_1(\\bar{h},h_1,h_2) \\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!-\\! \\phi_{h_2} \\!+\\!\\angle w_1(\\bar{h},h_1,h_2))\\right)\\\\\n\t&+ \\!\\sum_{h_1=1}^{H-1} \\sum_{h_2=h_1+1}^H\\!C_2(\\bar{h},h_1,h_2)\\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!-\\! \\phi_{h_2} \\!-\\!\\angle w_2(\\bar{h},h_1,h_2))\\right)\\\\\n\t&+ \\!\\sum_{h_1=1}^H \\sum_{h_2=1}^H\\!C_3(\\bar{h},h_1,h_2)\\mathbb{E}_\\phi\\!\\left(\\cos(\\phi_{h_1} \\!+\\! \\phi_{h_2} \\!+\\!\\angle w_3(\\bar{h},h_1,h_2))\\right)\\\\\n\t&+\\sum_{h=1}^H C_4(\\bar{h},h)\\mathbb{E}_\\phi\\left(\\cos(\\phi_h-\\phi_{\\bar{h}}+\\angle W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})D_w(e^{-j\\omega_{\\bar{h}}}))\\right)\\\\\n\t&+\\sum_{h=1}^H C_5(\\bar{h},h)\\mathbb{E}_\\phi\\left(\\cos(\\phi_h+\\phi_{\\bar{h}}-\\angle W(e^{j(\\omega_{\\bar{h}}+\\omega_h)})D_w(e^{-j\\omega_{\\bar{h}}}))\\right)\\\\\n\t&+\\frac{1}{\\pi^2A_{\\bar{h}}^2}|D_w(e^{j\\omega_{\\bar{h}}})|^2 + C_6(\\bar{h}),\n\t\\end{split}\n\t\\end{equation}\n\twith the abbreviations\n\t\\begin{equation}\n\t\\begin{split}\n\tw_1(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}-\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}-\\omega_{h_2})}),\\\\\n\tw_2(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}+\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}+\\omega_{h_2})}),\\\\\n\tw_3(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}-\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}+\\omega_{h_2})}),\n\t\\end{split}\n\t\\end{equation}\n\t\\end{lstlisting}\n\tBy adding a label to your equation, you will be able to refer to the equation within the text!\n\\end{mdframed}\nwith the abbreviations\n\\begin{equation}\n\\begin{split}\nw_1(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}-\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}-\\omega_{h_2})}),\\\\\nw_2(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}+\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}+\\omega_{h_2})}),\\\\\nw_3(\\bar{h},h_1,h_2)&=W(e^{j(\\omega_{\\bar{h}}-\\omega_{h_1})})W(e^{-j(\\omega_{\\bar{h}}+\\omega_{h_2})}),\n\\end{split}\n\\end{equation}\nand the phase independent constants \n\\begin{equation}\n\\begin{split}\nC_1(\\bar{h},h_1,h_2)&=2\\frac{A_{h_1} A_{h_2}}{A^2_{\\bar{h}}}|w_1(\\bar{h},h_1,h_2)|,\\\\\nC_2(\\bar{h},h_1,h_2)&=2\\frac{A_{h_1} A_{h_2}}{A^2_{\\bar{h}}}|w_2(\\bar{h},h_1,h_2)|,\\\\\nC_3(\\bar{h},h_1,h_2)&=2\\frac{A_{h_1} A_{h_2}}{A^2_{\\bar{h}}}|w_3(\\bar{h},h_1,h_2)|,\\\\\nC_4(\\bar{h},h)&=2\\frac{A_h}{\\pi A^2_{\\bar{h}}}|W(e^{j(\\omega_{\\bar{h}}-\\omega_h)})||D_w(e^{j\\omega_{\\bar{h}}})|,\\\\\nC_5(\\bar{h},h)&=2\\frac{A_h}{\\pi A^2_{\\bar{h}}}|W(e^{j(\\omega_{\\bar{h}}+\\omega_h)})||D_w(e^{j\\omega_{\\bar{h}}})|,\\\\\nC_6(\\bar{h})&=\\sum_{h=1}^H \\frac{A_h^2}{A_{\\bar{h}}^2}\\left( |W(e^{j(\\omega_{\\bar{h}}+\\omega_{{h}})})|^2+|W(e^{j(\\omega_{\\bar{h}}-\\omega_{{h}})})|^2 \\right).\n\\end{split}\n\\end{equation}\nThe second moment of the phase error in \\eqref{phasevar0} provides useful insights on how the phase of the desired frequency $\\omega_{\\bar{h}}$ is a function of the chosen window, the additive noise and the neighboring harmonics. Subsequently the key factors are summarized as\n\\begin{itemize}\n\t\\item $W(e^{j\\omega})$ the magnitude and phase response of the \\index{analysis!window}analysis window function\n\t\\item $D_w(e^{j\\omega})$ the magnitude and phase response of the additive noise\n\t\\item $\\frac{A_h}{A_{\\bar{h}}}$ the amplitude ratio of the adjacent and desired harmonics\n\\end{itemize}\nThe impact of the selected window $W(e^{j\\omega})$ can be considered for two cases: First, the harmonics are separated sufficiently which means there is no neighboring harmonic within the mainlobe width. The window's amplitude $W(e^{j(\\omega_{\\bar{h}}-\\omega_h}))$ for $\\bar{h}\\neq h$ suppresses the neighboring harmonic by its sidelobe level (see Figure~\\ref{Figure33}) which results in a low impact of the neighboring harmonics to $\\hat{\\phi}$. If the harmonics are not separated, i.e., the adjacent harmonic is located within the mainlobe width then the phase error gets larger. The adjacent harmonic is not attenuated by the sidelobe level of the window thus the phase estimation gets more \\index{bias}biased. Figure~\\ref{Figure2}\n illustrates the impact of adjacent harmonics for a Hamming and a Blackman window. The harmonics are sufficiently separated as the adjacent harmonics are outside of the mainlobe width. The Hamming window has a poorer sidelobe level which potentially yields a higher phase error. The larger \nsidelobe level\nof the Blackman window reduces the phase error but it also demands a longer window length $N_w$ in order to separate the harmonics. The drawback of a longer window length is a reduced time resolution in STFT spectral analysis. The phase estimation problem is therefore adequately addressed by choosing the best window that balances a good trade-off between a low phase variance and good enough time resolution.", "meta": {"hexsha": "8ff4cfb27c495ded45697c8c3eb2e0e1eaf3e0a0", "size": 24106, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sensorik/Chapters/chapterOne.tex", "max_stars_repo_name": "thealexinator2904/Industrial-automation", "max_stars_repo_head_hexsha": "572c39fa3c3926f327d9f1f4fd8e670d050e93bf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sensorik/Chapters/chapterOne.tex", "max_issues_repo_name": "thealexinator2904/Industrial-automation", "max_issues_repo_head_hexsha": "572c39fa3c3926f327d9f1f4fd8e670d050e93bf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sensorik/Chapters/chapterOne.tex", "max_forks_repo_name": "thealexinator2904/Industrial-automation", "max_forks_repo_head_hexsha": "572c39fa3c3926f327d9f1f4fd8e670d050e93bf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.0398406375, "max_line_length": 1025, "alphanum_fraction": 0.7091180619, "num_tokens": 8127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6442250996557035, "lm_q1q2_score": 0.4196191613207668}}
{"text": "\\section{Assumptions}\n\\begin{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 1:} The wood decomposed by fungi is an ideal cylinder, and the fungi are distributed on the surface of the wood.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} Symmetrical the decomposition environment of the fungi as much as possible to facilitate the connection of this process with the Gauss theorem and Gauss surface in electromagnetic.\n        \\end{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 2:} The decomposition rate of the fungi is only related to its growth rate, tolerance to moisture and environment temperature.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} In the real natural environment, fungi are susceptible to natural disasters. We limit the determination of the factors affecting the decomposition rate of fungi in advance to facilitate subsequent analysis.\n        \\end{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 3:} After the part of Fungi Selection, we obtain five virtual fungal species, which are typical and representative.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} There are thousands of species of fungi, hence, it does not have much practical significance to study a specific species of fungi. The five fungi we set can be analyzed and studied more comprehensively.\n        \\end{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 4:} The Logistic model is also valid when studying microorganisms, such as fungi.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} Logistic model is generally used to model changes in common animals and plants populations. Since fungi are also biological, we will use analogy reasoning to apply it to the study of fungi.\n        \\end{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 5:} The study on the interactions of the two fungal species combination could show that of more fungal species combination.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} In a piece of natural land, although there are more than two types of fungi, the interaction of multiple fungi can be understood as the superimposed effect of multiple combinations.\n        \\end{itemize}\n  \\item[$\\diamond$] \\textbf{Assumption 6:} Fungi play a major role in the decomposition of organic matter in the certain carbon cycle.\n        \\begin{itemize}\n          \\item[$\\hookrightarrow$] \\textbf{Justification:} In biology, the decomposition process of organic matter is completed by microorganisms, including fungi, bacteria and so on. Since this article only studies fungi, this process is simplified.\n        \\end{itemize}\n\\end{itemize}", "meta": {"hexsha": "74c32da14565ecb69b38072704962bc2d85d76d8", "size": 2728, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2/index.tex", "max_stars_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_stars_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-11-07T14:38:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-11T10:37:34.000Z", "max_issues_repo_path": "2/index.tex", "max_issues_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_issues_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2/index.tex", "max_forks_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_forks_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.037037037, "max_line_length": 265, "alphanum_fraction": 0.7463343109, "num_tokens": 637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4196191483298527}}
{"text": "\\section{Introduction}\n\n\\emph{Cryptography} is the science of secure communication and storage. What does ``secure'' mean in this definition? First, it means that, apart from the two communicating parties, there may be a third party trying to learn confidential information, to disrupt the communication, or to mislead the communicating parties. Second, ``secure'' means that a predefined set of goals cannot be achieved by any adversary with set capabilities, such as an ability to read or modify the communications, or limitations, such as having limited computational power.\n\nCryptography is often divided into design and cryptanalysis. \\emph{Cryptographic design} is the design of secure communication systems, called \\emph{cryptosystems}. \\emph{Cryptanalysis} is \\emph{breaking} the security of cryptosystems. In order to understand the security of a cryptosystem better, simplified versions of the cryptosystem are often analyzed. Of course, cryptography and cryptanalysis are not independent. Design of a cryptosystem usually follows alternating steps: design - cryptanalysis - design - cryptanalysis - ..., until the designers can not cryptanalyze the cryptosystem. After that, the cryptosystem is published and for others to analyze. \n\nModern cryptography is broadly split into private-key and public-key cryptography, also called symmetric-key and asymmetric-key cryptography.\n\n\\emph{Symmetric-key cryptography} assumes that the communicating parties have a shared private key. For example, they could meet physically and agree on the common secret key. In this case, the same shared key can be used both for encrypting and decrypting communications. \n\nSymmetric-key cryptosystems are usually constructed from low-level, bitwise operations and functions with small domains. They are very efficient. However, their security is not mathematically proven and is not based on any simple mathematical problem.\n\n\\emph{Asymmetric-key cryptography} does not necessarily require pre-shared keys. The defining property, however, is that the key may consist of two parts - a public key and a private key. For example, the public key may be used for encrypting messages and may be openly published. The private key is then used for decrypting the messages and must be kept secret.\nAsymmetric-key cryptography can also be used to establish a shared secret securely while using an insecure channel.\n\nAsymmetric-key cryptosystems are usually constructed around mathematical structures from number theory or algebraic geometry. Most often these cryptosystems are relatively inefficient. However, their security is based on the hardness of solving a mathematical problem, such as factoring large integers. It means that, if the cryptosystem is cryptanalyzed and broken, then it would mean that the underlying mathematical problem is not hard and can be solved efficiently.\n\nThe Public-key cryptography is a very rich area which gives rise to many beautiful cryptosystems and protocols. It is a very active field and many challenging problems are continuously solved and new ones are identified. In this dissertation, however, I dive into symmetric-key cryptography and do not study public-key cryptosystems. As an exception, in \\PartRef{wb}, I study white-box cryptography, which, in particular, aims to construct a public-key cryptosystem from a symmetric-key primitive. \n\nIn practice, a hybrid method is used. The public-key cryptography is used to establish a shared secret key between the communicating parties, and all the consequent communications are encrypted using fast symmetric-key cryptography.\n\n\n\\subsection{Authenticated Encryption}\n\nThe main goal of symmetric cryptography is to provide \\emph{authenticated encryption}. Authenticated encryption is a cryptosystem providing \\emph{confidentiality}, \\emph{integrity}, and \\emph{authenticity}.\n\\begin{itemize}\n    \\item \\emph{Confidentiality} guarantees that any adversary with predefined capabilities cannot recover any information about the original messages (called plaintexts) from the encrypted messages (called ciphertexts).\n    \n    \\item \\emph{Integrity} guarantees that any adversary with predefined capabilities cannot modify a transmitted ciphertext without the change being noticed by the receiver.\n    \n    \\item \\emph{Authenticity} guarantees that the receiving party can be assured that the message was generated by the sender.\n\\end{itemize}\n\nThere are several ways to construct an authenticated encryption scheme.\n\n\\subsubsection{Authenticated Encryption from Block Ciphers}\n\nBlock ciphers are the classical and the most widely used symmetric-key primitives. Formally, a block cipher is a family of permutations, where the secret key selects one of the permutations. The domain of the permutation is the message space. \n\nThe most widely spread block cipher is the AES block cipher~\\cite{AES}, also called Rijndael, designed by Vincent Rijmen and Joan Daemen. It was standardized in 2001 by the US standardization agency NIST.\n\nI and my colleagues designed a block cipher called SPARX~\\cite{OurSPARX}. The design process and analysis are described in \\ChapRef{sparx}.\n\nA plain block cipher can only encrypt fixed-width messages. For example, AES has a 128-bit block size. The bigger problem is that direct encryption of message blocks under the same key (i.e., by the same permutation) leaks information about the equality of message blocks: if the two plaintext blocks are equal, then the two ciphertext blocks are equal too, which contradicts the confidentiality requirement.\nAnother big problem is that authenticity is not guaranteed. The blocks can be removed arbitrarily without being noticed.\n\nAn \\emph{authenticated block cipher mode} is a construction that uses a block cipher to create an authenticated encryption scheme. Such a construction often consists of two parts: an encryption scheme for confidentiality and a message authentication code (MAC) for integrity. For example, the Encrypt-then-MAC~\\cite{EncryptMAC} is a very generic mode that can combine an arbitrary (secure) encryption scheme and an arbitrary (secure) message authentication code in order to create the authenticated encryption. More specific authenticated encryption modes (e.g. GCM~\\cite{GCM}, OCB~\\cite{OCB}) partially reuse the computations of the two components and achieve better performance. Another class of modes (e.g. SCT~\\cite{SCT}, COPA~\\cite{COPA}, POET~\\cite{POET}) requires a \\emph{tweakable block cipher}~\\cite{TBC}. Tweakable block ciphers take as input an extra \\emph{public} parameter called a \\emph{tweak}, and different tweaks should produce indistinguishable block ciphers.\n\n\n\\subsubsection{Authenticated Encryption from Stream Ciphers}\n\nThe \\emph{one-time pad} is one of the first modern encryption schemes. It is a very simple cipher, but it is famous for achieving \\emph{perfect secrecy}. It means that \\emph{no information} is revealed from a ciphertext, even for a computationally-unbounded adversary. This property is also called \\emph{information-theoretic} security. The one-time pad accepts an $n$-bit plaintext and an $n$-bit key. It combines the key and the plaintext using the exclusive-or operation. The plaintext and the key bits at the same position are added modulo 2. The requirement, however, is that the key should be sampled uniformly at random and used to encrypt only one message. These restrictions are not very practical and are the price for \\emph{perfect secrecy}. Indeed, Shannon~\\cite{Shannon} proved that these restrictions are \\emph{necessary} if perfect secrecy must be kept.\n\n\\emph{Stream ciphers}, similarly to block ciphers, discard the perfect secrecy requirement and aim at more practical cryptosystems. Unlike block ciphers, stream ciphers attempt to simulate the one-time pad by generating the required large key (a \\emph{keystream}) from a small key on the fly. The keystream is then called \\emph{pseudorandom}. The security is based on the requirement that any (computationally-bounded) adversary cannot distinguish the pseudorandom keystream from a purely random sequence.\n\nAs in block ciphers, stream ciphers can be combined with a message authentication code (MAC) to create an authenticated encryption (e.g. ChaCha20-Poly1305~\\cite{chachapoly}). Authenticated modes for stream ciphers were studied in~\\cite{streamae}. Another approach is to design an authenticated stream cipher from scratch (e.g. ACORN~\\cite{ACORN}).\n\n\n\\subsubsection{Authenticated Encryption from Permutations via Sponge construction}\n\nA (cryptographic) \\emph{hash function} is a cryptographic primitive that maps a bit-string of arbitrary length into a fixed-length bit-string. For a secure hash function, it should not be computationally easy to invert it (\\emph{preimage resistance}) or find two messages that have the same hash value (\\emph{collision resistance}). Furthermore, given a fixed message it should be computationally difficult to find another distinct message that has the same hash value (\\emph{second preimage resistance}). In general, hash functions are often modeled as \\emph{random oracles}. These oracles always return a truly random element of the hash function's codomain, except that for repeated queries with the same message they always return the same hash value. Hash functions are used in a huge number of protocols and public-key constructions. Since hash functions are \\emph{keyless}, it is not clear whether they belong to symmetric-key or asymmetric-key cryptography. In practice, hash functions used are made in the symmetric-key style: created from low-level binary operations, very efficient but with heuristic security. However, there exist hash functions from more algebraic constructions, but they are typically only used in theoretic studies due to their inefficiency.\n\nThe \\emph{sponge} construction was first formally presented in~\\cite{sponge-ecrypt}, though similar ideas had already been used before (e.g.~\\cite{LEX,RadioGatun}). It was used to design the winner Keccak~\\cite{sponge-keccak} of the SHA-3~\\cite{sha3} hash function competition organized by NIST. The sponge construction uses a primitive called \\emph{cryptographic permutation}. The state is divided into the \\emph{rate} part and the \\emph{capacity} part. The rate part is usually controlled by an adversary, while the capacity part is uncontrolled. The sponge \\emph{absorbs} message blocks in-between calls to the permutation. Afterward, it \\emph{squeezes} pseudorandom outputs (e.g., hash values) in-between calls to the permutation. The construction is illustrated in~\\FigRef{sponge}. The sponge is a \\emph{provably secure} construction: if the chosen cryptographic permutation is \\emph{ideal} (e.g., a purely random permutation), then the construction is guaranteed to be secure up to some level.\n\n\\FigTex{sponge.tex}\n\nThe designers of Keccak further showed~\\cite{sponge-duplex,sponge-monkey} that sponges can be used to construct authenticated encryption. The latter variant of the mode is called MonkeyDuplex. This mode and its variants were used in several encryption schemes (e.g.~\\cite{NORX,Ketje,ASCON}). Since a sponge only requires a cryptographic permutation, it inspired cryptography designs called \\emph{permutation-based cryptography}. A recent improvement is the Beetle mode~\\cite{beetle}, which achieves better security bounds.\n\nI and my colleagues designed a hash function family \\texttt{Esch} and an authenticated encryption family \\texttt{Schwaemm}. They are based on the recent sponge-based mode called Beetle and a cryptographic permutation family derived from our SPARX block cipher. These designs are submitted to the NIST Call for Lightweight Cryptography~\\cite{NISTlight}. I describe the design process and analysis of these primitives in \\ChapRef{sparkle}.\n\n\n\\subsubsection{The CAESAR Competition}\nRecently, the CAESAR competition was organized~\\cite{CAESAR}. Its name stands for ``Competition for Authenticated Encryption: Security, Applicability, and Robustness''. The competition started in 2014 when 53 authenticated encryption schemes were submitted. After 5 years of selection process consisting of 3 rounds, the committee selected 8 portfolio members, from which 4 are the preferred choice. The portfolio is split into 3 use cases:\n\n\\begin{enumerate}\n    \\item \\emph{Lightweight applications (resource constrained environments).}\n    The preferred choice is ASCON~\\cite{ASCON} which is based on MonkeyDuplex sponge mode. The second choice is ACORN~\\cite{ACORN}, a dedicated authenticated stream cipher.\n    \n    \\item \\emph{High-performance applications.}\n    The following two choices are chosen without a preference. The first one is AEGIS-128~\\cite{AEGIS}, a dedicated design using a reduced-round AES as a component. The second one is OCB~\\cite{OCBcaesar}, a block cipher mode.\n    \n    \\item \\emph{Defense in depth.}\n    The preferred choice is Deoxys-II~\\cite{DEOXYS}, an authenticated encryption scheme based on a tweakable block cipher. The alternative choices are COLM~\\cite{COLM}, AES-COPA~\\cite{COPA}, and ELmD~\\cite{ELMD}, block cipher modes.\n\\end{enumerate}\n\n\n\\subsection{Black, Gray and White-box Models}\n\nSecurity of cryptosystems is most often analyzed in a \\emph{game-based} setting. The game usually happens between a \\emph{challenger} and an \\emph{adversary}. The challenger possesses secret information, for example, a secret key. The adversary is allowed to ask specified queries to the challenger. The goal of the adversary is to recover the secret information or, at least, a part of it.\n\nConsider an encryption scheme. The challenger flips a coin and decides whether he will use the encryption scheme or its \\emph{ideal} equivalent. In the first case, the challenger chooses the secret key uniformly at random. In the second case, the encryption is performed in the best possible way while maintaining the interface and semantics of the encryption scheme. For example, for each plaintext, the ciphertext may be assigned uniformly at random. Note that the challenger is not necessarily an algorithm and usually is not computationally-bounded, unlike the adversary. The game continues. The adversary can ask the challenger to encrypt several plaintexts chosen by the adversary. The challenger performs the encryption (either using the encryption scheme or its idealized version) and gives ciphertexts to the adversary. It is said the adversary is given access to the \\emph{encryption oracle}.\nThe adversary finally has to guess, what the outcome of the challenger's coin flip was. That is, the adversary has to decide, whether the encryption was done using the encryption scheme or using its idealized version. If the adversary succeeds with non-negligible probability, then it is said that the encryption scheme has an  \\emph{adaptive chosen-plaintext distinguisher}. If the adversary accesses the encryption oracle only once, it is said that the scheme has a \\emph{(non-adaptive) chosen-plaintext distinguisher}.\n\nThere are three major models in which cryptosystems are analyzed. \n\n\\subsubsection{The Black-box Model}\nThe \\emph{black-box} model restricts the analysis to the ``functional'' side of cryptosystems. An adversary in this model is usually given access to encryption and/or decryption oracles. That is, the adversary is allowed to ask the challenger to encrypt and/or decrypt arbitrary messages. Any intermediate computations or events are not visible to the adversary, thus the name ``black-box''. This model is fundamental - any weakness in this model is inherited to the gray-box and white-box models.\n\n\\subsubsection{The Gray-box Model}\nThe \\emph{gray-box} model studies the ``physical'' side of cryptosystems, more precisely, of their \\emph{implementations} and the devices on which the implementation is deployed. Indeed, this side provides much more information to the adversary. The adversary may be allowed to measure the time of execution of a query, the power consumption of the device, the electromagnetic radiation. This information is usually referred to as \\emph{side-channel} information.\nThe adversary may be \\emph{active} - for example, introduce faults in the computations, by heating the device or tweaking the voltage. It is an interesting phenomenon that physical access to the device often enables much more efficient attacks on the cryptosystem. Cryptanalysis in this model is called \\emph{side-channel} cryptanalysis.\n\nCountermeasures against \\emph{side-channel} attacks may be introduced both in the implementation code and on the physical side. Protections that can be added to the implementation are more generic and, therefore, more preferable. In practice, both methods are used to ensure maximum security. Importantly, implementations typically may use (pseudo)randomness in order to protect computations. Together with the noise and uncertainty of the physical observations, these properties allow the creation of sound countermeasures against side-channel attacks.\n\n\\subsubsection{The White-box Model}\nThe \\emph{white-box} model considers the extreme case when the adversary has \\emph{full} access to the implementation, in the form of compiled code or Boolean circuits. Typically, the implementation contains a secret key and the adversary's main goal is to recover it. The hardness of the key recovery is often called the \\emph{weak white-box} requirement. Other goals may be considered, such as compressing the implementation, inverting the computed function, or removing hidden ``watermarks'' allowing the user possessing the implementation to be traced. The respective security properties are called \\emph{unbreakability}, \\emph{incompressibility}, \\emph{one-wayness}, \\emph{(traitor) traceability} (see~\\cite{wbNotionsOld,wbNotions}).\nUnbreakability together with one-wayness result in a public-key scheme, if the embedded secret key allows efficient decryption. Such implementation is also called a \\emph{strong white-box}. Indeed, the implementation secure in the white-box model can be seen as a public key, and the embedded secret key can be seen as a private key. A white-box implementation of a common symmetric encryption scheme would then have a very efficient decryption code. However, it turns out to be a challenging, if not impossible problem.\n\nThe white-box model was first introduced by Chow~\\etal{}~\\cite{ChowAES,ChowDES} in 2002. The authors proposed rather efficient white-box implementations of the AES and DES block ciphers. Unfortunately, they were broken with practical attacks. All consequent attempts to fix the scheme failed as well. A secure white-box implementation of a block cipher remains an open problem today.\n\nWhite-box implementations are closely related to the notion of \\emph{cryptographic obfuscation}. Indeed, a basic implementation has to be obfuscated in order to hide the secret key. There is an active research direction related to \\emph{indistinguishability obfuscation} (iO), which is widely believed to be ``the best possible'' obfuscation. iO has many applications in theory: it is known that many provably secure cryptographic primitives can be created from secure iO. Unfortunately, many recent iO candidates were broken. Furthermore, all constructions are very inefficient. For example, a recent framework 5Gen-c~\\cite{5GEN} can be used to obfuscate only a single round of the AES block cipher. I remark though, that there is no established provable link between white-box and iO.\n\n\\subsubsection{The WhibOx Competition}\n\nIn 2017, the WhibOx competition~\\cite{whibox} was organized. Any person or team in the world could submit a white-box AES-128 implementation in C code of size up to 50 megabytes, then the implementation was publicly available for analysis. The goal was to recover the secret key from the implementation.\n\nAmong 94 submissions, most implementations were broken in less than a day. Only 13 implementations required at least one day to be broken, and only 8 of them required at least two days. The winning implementation survived 28 days, and the following implementation only 12 days. The winning design was created by myself and Alex Biryukov. The implementation did not involve any new provable security techniques, but relied on many interesting obfuscation tricks, effectively slowing down the reverse-engineering effort. We were also first to successfully cryptanalyze the best 3 implementations besides ours. Our participation in the competition initiated the research that resulted in~\\PartRef{wb} of this thesis.\n\n\n\\subsection{Cryptanalysis of Symmetric-key Primitives}\n\nThe framework for cryptanalysis is most developed for block ciphers. Indeed, block ciphers were used from the 1970s with the designs of the LUCIFER and DES block ciphers. Together with a proper mode, a block cipher can be used to construct an authenticated encryption scheme. Furthermore, block ciphers tend to have a reasonably simple structure. This simplicity attracts cryptanalysts, who try to break the cipher using both established and novel methods of cryptanalysis. Since the same low-level operations are used in most symmetric-key primitives, cryptanalysis methods for block ciphers are usually very generic and can be applied to other primitives, such as stream ciphers, hash functions, message authentication codes, and authenticated encryption. \n\nWhat does it mean to break a cipher? In the scientific community, successful cryptanalysis means an algorithm that disproves a security claim of the designers. A typical security claim is that the secret key can not be recovered faster than exhaustive search over the whole key space. A block cipher with a fixed secret key should not be distinguishable from a truly random permutation. Even if the attack is impossible in practice, it only matters that it is faster than the generic attack. The reason is that such an attack shows a \\emph{weakness} of the block cipher. Since block ciphers are not provably secure, any weakness should be avoided.\n\nThe \\emph{complexity} of a cryptanalytic attack is measured by the time, memory and data complexities of the algorithm. The data complexity corresponds to the number of queries that it makes. \n\nIn the simplest form, cryptanalytic attacks lead to a \\emph{distinguisher} from a random permutation. In most cases, such an attack can be extended into the secret key recovery. This is done by guessing a part of the secret key and decrypting a part of the ciphertext. Then the correctness of the key guess is verified by using the established distinguisher.\n\n\\subsubsection{Cryptanalysis Methods}\n\nIn \\emph{differential} cryptanalysis, an adversary encrypts two plaintexts with a fixed \\txor difference. By an analysis of the cipher's structure, the adversary predicts a difference between ciphertexts with high enough probability. More precisely, the cryptanalyst studies the evolution of the plaintexts difference through all computations, until the ciphertext difference. A transition through nonlinear components is usually probabilistic, and all transitions' probabilities accumulate in an approximation of the probability of observing a particular ciphertext difference. \n\nIn \\emph{linear} cryptanalysis, an adversary receives many plaintext-ciphertext pairs generated by the analyzed block cipher. The cipher is approximated by \\emph{linear} equations, i.e. equations involving only the \\txor operation. As in differential cryptanalysis, approximations of nonlinear components induce a cost in the form of probability. As a result, the resulting equations linking the key, the plaintext and the ciphertext hold only with particular probability. If the adversary observes enough data, then correct equations may be established with high probability. In practice, only the ratio of plaintext-ciphertext pairs for which the equation is correct is computed. For a random permutation, this ratio will be close to 1/2. For a weak block cipher, this ratio may be distinguishable from 1/2 with high probability.\n\nIn \\emph{integral} cryptanalysis, the \\emph{algebraic degree} of a block cipher is studied. It corresponds to the degree of the multivariate polynomial representation of the cipher. If the algebraic degree is not high enough, the cryptanalyst can deduce a set of plaintexts, for which the corresponding ciphertexts \\txor to zero, independently of the secret key. Evaluation of the algebraic degree of a cryptographic primitive is a challenging problem and usually, only upper bounds on the degree can be proved. In~\\ChapRef{feistel} I describe a method to obtain such upper bounds for the particular block cipher structure, called a \\emph{Feistel Network}. It is based on the joint work~\\cite{OurFeistel} with my colleague Léo Perrin.\n\nIntegral cryptanalysis is one of the main tools for \\emph{structural} cryptanalysis. This branch of cryptanalysis studies ways to distinguish \\emph{structures} of cryptographic functions and further decompose the function into components of the structure. It means that only the structure of the function is known to the adversary, and its components are kept secret. The most common structures are the substitution-permutation-network (SPN) and the Feistel network (FN). My colleagues Léo Perrin and Alex Biryukov found an intriguing application of structural and decomposition cryptanalysis. They applied it to \\emph{small} functions called S-Boxes, which are used to build cryptographic primitives. S-Boxes are usually represented by tables in specifications and the process of their generation may be kept undisclosed. Structural cryptanalysis allows distinguishing particular structures in an S-Box. Together with analysis of resistance against linear and differential attacks, these methods can often reveal secret criteria behind an S-Box of unexplained origin. This direction is called the \\emph{reverse-engineering} of S-Boxes. I contributed to the work of my colleagues in reverse-engineering of the S-Box used in the latest Russian cryptographic standards, and reverse-engineering of an S-Box of a mathematical origin. These results are described in \\ChapRef{kuz} and \\ChapRef{apn} respectively.\n\nA recent direction of cryptanalysis is the search for \\emph{invariants} of the cryptographic primitives. \\emph{Linear} invariants correspond to a critical flaw in the primitive and are usually easy to avoid. \\emph{Nonlinear} invariants are much harder to find. Indeed, the ideas of invariant-based cryptanalysis appeared a long time ago, but the actual applications of the method appeared only recently. A special case of a nonlinear invariant is an \\emph{invariant subspace}. Invariant subspace cryptanalysis was introduced in~\\cite{InvSpacePrint} and was used to break the PRINTcipher, designed in 2010. Another class of nonlinear invariants is formed by \\emph{quadratic} invariants. This class was used in~\\cite{NonlinInv} to show a practical distinguisher of recently designed block ciphers Midori, SCREAM, and iSCREAM. In~\\PartRef{ni} I describe invariant subspaces in NORX, a CAESAR third round candidate; I also show a theoretical study of generalization of quadratic invariants to higher degrees. This part is based on joint work~\\cite{OurNORX} with Alex Biryukov and Vesselin Velichkov, and on joint work~\\cite{OurNLI} with Christof Beierle and Alex Biryukov.", "meta": {"hexsha": "b4bdf061ceff18dbbbc2ec80d40eabb0b608ee78", "size": 27280, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis-source/1_Intro/intro.tex", "max_stars_repo_name": "hellman/thesis", "max_stars_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2019-05-16T19:55:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T15:36:12.000Z", "max_issues_repo_path": "thesis-source/1_Intro/intro.tex", "max_issues_repo_name": "hellman/thesis", "max_issues_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-09T11:26:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-09T11:26:45.000Z", "max_forks_repo_path": "thesis-source/1_Intro/intro.tex", "max_forks_repo_name": "hellman/thesis", "max_forks_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-05T19:40:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T19:40:16.000Z", "avg_line_length": 194.8571428571, "max_line_length": 1406, "alphanum_fraction": 0.811473607, "num_tokens": 5792, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303336, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.41961914832985264}}
{"text": "\\chapter{Cryptographic schemes}\n\nCryptographic schemes conceived for \\zclaim are defined in the following pages.\nOn the other hand, schemes taken from Sapling to which reference is made in this work were introduced in~\\cref{ch:prelims} and will not be reproduced here.\n\n\n\\section{Commitment schemes}\nWe define a commitment scheme as in~\\cite[Section 4.1.7]{hopwood2016zcash}.\n\n\\subsection{Nonce commitment scheme}\n\\label{app:nncm}\nThe nonce commitment scheme \\nncm may be instantiated as a Windowed Pedersen commitment scheme as defined in~\\cite[Section 5.4.7.2]{hopwood2016zcash} in a similar fashion to Sapling's note commitment scheme \\ncm, since the homomorphic properties required when hiding the note value are not necessary.\nIt is defined as follows:\n\\begin{flalign*}\n    &\\nncm_{\\rcn}(\\nlock) := \\wpc_{\\rcn}(\\nlock)&\n\\end{flalign*}\n\n\n\\section{Signature schemes}\nWe use the definition of a signature scheme in~\\cite[Section 4.1.6]{hopwood2016zcash}.\n\n\\subsection{Minting signature}\n\\label{app:mas}\n\\mas may be instantiated as \\redjj as defined in~\\cite[Section 5.4.6]{hopwood2016zcash} without key re-randomisation and with generator\n\\begin{flalign*}\n    &\\mathcal{P}_{\\G} = \\fgh(\\text{``\\zclaimm''}, \\text{``''})&\n\\end{flalign*}\n\n\n\\subsection{Vault signature}\n\\label{app:vaultsig}\n\\vaultsig may be instantiated as \\redjj as defined in~\\cite[Section 5.4.6]{hopwood2016zcash} without key re-randomisation and with generator\n\\begin{flalign*}\n   &\\mathcal{P}_{\\G} = \\divhash(\\dvf)&\n\\end{flalign*}\nwhere \\dvf is the diversifier associated with the vault in the vault registry.\n\n\n\\section{SIGHASH transaction hashing}\n\\label{app:sighash}\n\nWe use the \\sighash transaction hash as defined in~\\cite{ZIP243}, not associated with an input and using the \\sighash type \\sighashall, to which we add two new fields:\n\\begin{itemize}\n    \\item $\\hashmints :  \\B^{[256]}$ is 0 if the transaction does not contain a Mint transfer, otherwise it is the \\blakezclaim hash of the serialization of the Mint transfer (in its canonical transaction serialization format) with the personalisation field set to ``$\\mathtt{ZclaimMintHash}$''.\n    \\item $\\hashburns :  \\B^{[256]}$ is 0 if the transaction does not contain a Burn transfer, otherwise it is the \\blakezclaim hash of the serialization of the Burn transfer (in its canonical transaction serialization format) with the personalisation field set to ``$\\mathtt{ZclaimBurnHash}$''.\n\\end{itemize}\n", "meta": {"hexsha": "e18f51188c9cedb22b7847cbbdd3c8ce2d8aab23", "size": 2431, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/appendix.tex", "max_stars_repo_name": "alxs/zclaim", "max_stars_repo_head_hexsha": "727b74ded4373c76e7e649b884d4c5ce650838e7", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-11-18T16:33:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-30T07:42:21.000Z", "max_issues_repo_path": "sections/appendix.tex", "max_issues_repo_name": "alxs/zclaim", "max_issues_repo_head_hexsha": "727b74ded4373c76e7e649b884d4c5ce650838e7", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/appendix.tex", "max_forks_repo_name": "alxs/zclaim", "max_forks_repo_head_hexsha": "727b74ded4373c76e7e649b884d4c5ce650838e7", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.7234042553, "max_line_length": 300, "alphanum_fraction": 0.7626491156, "num_tokens": 696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.795658104908603, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.41956366567917946}}
{"text": "% -----------------------------*- LaTeX -*------------------------------\n\\documentclass[12pt]{report}\n\\usepackage{scribe_hgen486}\n\\usepackage{hyperref}\n\\begin{document}\n\n\\scribe{Arjun Biddanda}\t\t% required\n\\lecturenumber{3}\t\t\t% required, must be a number\n\\lecturedate{January 12}\t\t% required, omit year\n\\lecturer{Matthew Stephens}\n\\maketitle\n\n% please leave this comment \n\\framebox[.95\\textwidth]{\\parbox{.93\\textwidth}{ {{\\bf Note:}} These\nlecture notes are still rough, and have only have been mildly\nproofread.  }}\n\\vspace*{.1in}\n\n\n% feel free to delete content below this line \n% ----------------------------------------------------------------------\n\n\n\\section{Introduction}\n\nThe primary theme of todays lecture is on likelihoods, likelihood\nratios, and their interpretation. The writeup here \\textit{heavily}\nsamples from the excellent vignettes found here: \\\\\n\\url{http://stephens999.github.io/fiveMinuteStats/analysis/likelihood\\_ratio\\_simple\\_models.html}. \n\n\\section{Example : DNA Barcoding of Poached Elephant Tusks}\n\nElephant ivory is a commonly poached item, and we would like to determine which particular environment the elephants are coming from. The elephants can either come from (1) the savannah or (2) the forest. We denote the following two models and data from an elephant tusk:\n\n\\begin{align*}\nM_s &: \\text{Tusk comes from a savannah elephant}\\\\\nM_f &: \\text{Tusk comes from a forest elephant}\n\\end{align*}\n\n\n\\begin{center}\n\t\\begin{tabular}{ c | c | c | c }\n\t\tMarker & Allele & $f_S$ & $f_F$\\\\\n\t\t\\hline \n\t  1 & 1 & 0.4 & 0.8\\\\\n\t  2 & 0 & 0.12 & 0.2\\\\\n\t  3 & 1 & 0.21 & 0.11\\\\\n\t  4 & 0 & 0.12 & 0.17\\\\\n\t  5 & 0 & 0.02 & 0.23\\\\\n\t  6 & 1 & 0.32 & 0.25\\\\\n\t\\end{tabular}\n\\end{center}\n\n$f_S$ and $f_F$ represent the allele frequency of the ``1'' allele in the savannah and forest elephant populations respectively. The likelihood of the model $M_S$ can be defined as the probability of the data being generated under the model. \n\n\\begin{align*}\n\tL(M_S) &= P(Data | M_S)\\\\\n\t&= \\prod (f_S)^x\\times(1-f_S)^{1-x}\\\\\n\t&= (0.4)(1-0.12)(0.21)(1-0.12)(1-0.02)(0.32)\\\\\n\t&= 0.020399\\\\\n\tL(M_F) &= P(Data | M_F)\\\\\n\t&= \\prod (f_F)^x\\times(1-f_F)^{1-x}\\\\\n\t&= (0.8)(1-0.2)(0.11)(1-0.17)(1-0.23)(0.25)\\\\\n\t&= 0.0112\\\\\n\tLR(M_S/M_F) &= \\frac{L(M_S)}{L(M_F)}\\\\\n\t&= \\frac{0.0204}{0.0112} \\approx 1.8\n\\end{align*}\n\nWe have defined the likelihood ratio as the ratio of the likelihood of the model $M_S$ over the likelihood of $M_F$. We also note that the models $M_S$ and $M_F$ are \\textit{fully-specified}, that is to say that there are no free parameters in the model. We will explore unspecified models later on in the lecture.\n\nTwo distinct questions arise as a result of calculating this likelihood ratio : (1) how to interpret the likelihood ratio and (2) when can we claim that we believe a model over another model given a likelihood ratio?\n\n\\subsection{Context of Individual Likelihoods}\n\nThe purpose of a likelihood ratio is to examine the evidence (data) in the context of one model against another. As a brief toy example let us consider a fair coin tossed 100 times and landing with 50 heads and 50 tails. What is the likelihood of the model that this coin is a fair coin? $L(M_{fair}) = \\left(\\frac{1}{2}\\right)^{100}$. However this very small number is simply a probability, and actually getting any set of 100 tosses with a fair coin results in this likelihood! Thus we can see that likelihoods are important by providing a context under which they can be interpreted, by comparing two models against each other.  \n\n\\subsection{Notational Things}\n\\begin{itemize}\n\\item We often work in ``log-space'' since the individual likelihoods may be quite small. The Log-Likelihood Ratio (LLR) is defined as $log(LR)$\n\\item In english we would say $P(Data | M_0)$ as ``The likelihood under the model $M_0$''\n\\item Sometimes semicolons are used to denote the data, and curly a ``L'' for the likelihood (i.e. $log(LR) = log\\left( \\frac{\\mathcal{L}(M_S ; D)}{ \\mathcal{L}(M_F ; D)}\\right)$)\n\\end{itemize}\n\n\\section{Example : Continuous Measurement of Protein in Blood}\nSuppose that we a protein that is measured in the blood and we call this random variable $X$. We want to see if this protein varies in concentration according to disease or non-disease status We wish to test the following two models :\n\n\\begin{align*}\nM_n &: X \\sim Gamma(0.5, 2)\\\\\nM_d &: X \\sim Gamma(1,2)\\\\\n\\end{align*}\n\nWhere $M_n$ is the model under a non-diseased state and $M_d$ is a model under the diseased state. If we observe the data as $X = 4.02$ the likelihood ratio can be detemined as: $$ LR = \\frac{f_{X|M_n}}{ f_{x | M_d}}$$. However we would only like to compare the density around the measurement we have actually obtained, so we will use a quick trick and assume the precision of the measurement of $X$ to be $\\pm 0.05$ making $X \\in [4.015, 4.025]$. Now that we have discretized this measurement we can integrate the respective conditional densities over this range, making the likelihood ratio : \n$$ LR = \\frac{ \\int^{4.025}_{4.015} f_{X | M_n} }{\\int^{4.025}_{4.015} f_{X | M_d} }$$\n\nThere are a couple of caveats to this approach as well that translate broadly to the calculation of likelihood ratios : \n\n% TODO : define well-behaved?\n\\begin{itemize}\n\t\\item The density function must be well-behaved in the integration bounds\n\t\\item The data must be held the same between the models that we are comparing (transforming one and not the other is illegal!)\n\t\\item If a likelihood ratio is 0 we can certainly say that \n\\end{itemize}\n\n\\subsubsection{Different Support of Random Variables}\n\nLikelihood Ratios still work properly when we have different support for the models. Suppose we have a random variable $X$ which corresponds to the roll of a standard 6-sided dice and the following two models: \n\n\\begin{align*}\nM_6 &: \\text{All the dice rolls are a 6}\\\\\nM_{fair} &: \\text{The dice is a fair dice}\\\\\n\\end{align*}\n\nWe can imagine two scenarios from this : (1) when the roll is a 6 and (2) when the roll is not a 6. When $X$ is a 6 we have a likelihood ratio of $LR = \\frac{P(X | M_6)}{P(X | M_{fair})} = 1/(1/6) = 1/6$. However when $X \\neq 6$ we can say that the likelihoo ratio is 0 since $P(X \\neq 6 | M_6) = 0$ and this is the numerator of our likelihood ratio.\n\n\\section{Continuation of Disease Example}\n\nLet us assume that $Z_i = 1$ if patient is diseased, else $Z_i = 0$. \n\n\\begin{align*}\nP(Z_i = 1 | X_i = x) &= \\frac{P(X_i = x | Z_i = 1) \\cdot P(Z_i = 1)}{P(X_i = 1)}\\\\\nP(Z_i = 0 | X_i = x) &= \\frac{P(X_i = x | Z_i = 0) \\cdot P(Z_i = 0)}{P(X_i = 0)}\\\\\n\\frac{P(Z_i = 1 | X_i = x)}{P(Z_i = 0 | X_i = x)} &= \\frac{P(Z_i = 1)\\cdot P(X_i = x | Z_i = 1)}{ P(Z_i = 0) \\cdot P(X_i = x | Z_i = 0) }\\\\\nOdds_{Posterior} &= Odds_{Prior} \\times \\text{Bayes Factor}\\\\\n\\end{align*}\n\nWhen the model is fully-specified the Bayes Factor is equal to the Likelhood Ratio. However the role of the prior odds also plays a large role in our interpretation of the posterior odds. For instance if we believe that the disease is very rare, then we will have to have a much higher likelihood ratio in order to truly believe that we have the disease. It is very important to consider the prior odds of having the disease. \n\n\\section{Likelihood Functions and Partially Specified Models}\n\nLet us review our elephant example now. But let us assume that we have sampled 100 elephants only from the savannah and look at their alleles at one particular marker. We obtain 40 samples that carry the ``1'' and 60 samples that carry the ``0'' allele. We then want to evaluate a particular model and its likelihood : \n\\begin{align*}\nM_q &: \\text{Allele frequency of the 1 allele is q}, q \\in[0,1]\\\\\n\\mathcal{L}(M_q) &= P(Data | M_q) = q^{40}(1-q)^{60}\\\\\n\\end{align*}\n\nOne way in which we can compare two potentially different values of $q$ would be to look at their difference in log-likelihood units. We would then look at $log(\\mathcal{L}(M_{q_1})) - log(\\mathcal{L}(M_{q_2}))$. If we get a log-likelihood difference of 2 then we know that $LR = e^2 \\approx 7.4$.  \n\\end{document}\n\n", "meta": {"hexsha": "f20080947fa5128bae2e36b2a2b0070c8217c972", "size": 8043, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/scribe_notes_2016/lec3.tex", "max_stars_repo_name": "stephens999/hgen48600", "max_stars_repo_head_hexsha": "e5901f91d81ba4902ae1399a2db3f0903454b34e", "max_stars_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-03-19T18:02:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-11T22:15:28.000Z", "max_issues_repo_path": "docs/scribe_notes_2016/lec3.tex", "max_issues_repo_name": "stephens999/hgen48600", "max_issues_repo_head_hexsha": "e5901f91d81ba4902ae1399a2db3f0903454b34e", "max_issues_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-02-05T00:34:09.000Z", "max_issues_repo_issues_event_max_datetime": "2017-03-07T20:15:19.000Z", "max_forks_repo_path": "docs/scribe_notes_2016/lec3.tex", "max_forks_repo_name": "stephens999/hgen48600", "max_forks_repo_head_hexsha": "e5901f91d81ba4902ae1399a2db3f0903454b34e", "max_forks_repo_licenses": ["CC-BY-4.0", "BSD-3-Clause"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2016-01-08T16:59:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-11T23:09:29.000Z", "avg_line_length": 57.8633093525, "max_line_length": 632, "alphanum_fraction": 0.7004848937, "num_tokens": 2437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7956581024858786, "lm_q1q2_score": 0.41956366440163684}}
{"text": "%----------------------------------------------------------------------\n% COMPUTATIONAL PHYSICS - PROJECT 1\n% SEMICLASSICAL QUANTIZATION OF MOLECULAR VIBRATIONS\n%----------------------------------------------------------------------\n\n\\documentclass[a4paper]{IEEEtran} \n\\usepackage{amssymb}\n\\usepackage{moreverb}\n\\usepackage[cmex10]{amsmath} \n\\usepackage{cite} \n\\usepackage{graphicx} \n\\usepackage[colorlinks=false, hidelinks]{hyperref} \n\n\\usepackage{listings} \n\\usepackage{color} \n\\usepackage{xcolor}  \n\\usepackage{microtype} \n\\usepackage{microtype} \n\\usepackage{inconsolata} \n\\usepackage[framemethod=TikZ]{mdframed} \n\\usepackage{alltt}\n\\usepackage{sverb} \n\\usepackage{verbatim} \n\\usepackage{pifont} \n\\usepackage{alltt} \n\\usepackage{helvet} \n\n%----------------------------------------------------------------------\n% CODE LISTING SETTINGS\n%----------------------------------------------------------------------\n\n\\lstset{language=fortran,\n        %basicstyle=\\footnotesize\\ttfamily, \n        basicstyle=\\small\\ttfamily,\n        columns=fullflexible, \n        %title=\\lstname, \n        numbers=left, stringstyle=\\texttt, \n        numberstyle={\\tiny\\texttt}, \n        keywordstyle=\\color{blue}, \n        commentstyle=\\color{darkgreen}, \n        stringstyle=\\color{purple} } \n\n\n\\mdfsetup{skipabove=\\topskip, skipbelow=\\topskip} \n\n\\definecolor{codebg}{rgb}{0.99,0.99,0.99}\n\n\\global\\mdfdefinestyle{code}{%\n    frametitlerule=true,%\n    frametitlefont=\\small\\bfseries\\ttfamily,%\n    frametitlebackgroundcolor=lightgray,%\n    backgroundcolor=codebg,%\n    linecolor=gray, linewidth=0.5pt,%\n    leftmargin=0.5cm, rightmargin=0.5cm,%\n    roundcorner=2pt,%\n    innerleftmargin=5pt\n}\n\n\\global\\mdfdefinestyle{code2}{%\n    topline=false,%\n    bottomline=false,%\n    leftline=true,%\n    rightline=false,%\n    backgroundcolor=codebg,%\n    linecolor=gray, linewidth=0.5pt,%\n    leftmargin=0.0cm, rightmargin=0.0cm,%\n    innerleftmargin=1pt\n}\n\n\\newcommand{\\showcode}[1]{\\begin{mdframed}[style=code] %\n                            \\lstinputlisting{#1}% \n                          \\end{mdframed}% \n}\n\n\\newcommand{\\showsmallcode}[1]{\\begin{mdframed}[style=code2] %\n        \\lstinputlisting[basicstyle=\\ttfamily\\tiny]{#1}% \n                          \\end{mdframed}% \n}\n\n\n\n\n%----------------------------------------------------------------------\n% IEEE SETTINGS\n%----------------------------------------------------------------------\n\n\\interdisplaylinepenalty=2500\n\\setlength{\\IEEEilabelindent}{\\IEEEilabelindentB}\n\n%\\markboth{630--364 Computational Physics}{} \n\\markboth{Semi-Classical Quantization of Molecular Vibrations. Michael Papasimeon. 1997}{} \n\n%----------------------------------------------------------------------\n% BEGIN DOCUMENT\n%----------------------------------------------------------------------\n\n\\title{Semi-Classical Quantization of Molecular Vibrations}\n\\author{Michael Papasimeon\\\\ 12 August 1997} % \\\\\n\\date{August 12, 1997}\n\n%----------------------------------------------------------------------\n% BEGIN DOCUMENT\n%----------------------------------------------------------------------\n\n\\begin{document}\n\\maketitle\n%\\thispagestyle{plain} \n\n\\begin{abstract}\nThis paper was written for an introductory undegraduate class in computational\nphysics in 1997. It focuses on basic computational/numerical techniques\nfor quadrature and root finding. It then applies these techniques to finding \nthe energy levels of molecular hydrogen $H_2$ using a semi-classical quantization \napproach. The source code listings in \\textsc{Fortran77} can be found in the appendices.\n\\end{abstract} \n\n%----------------------------------------------------------------------\n% QUADRATURE\n%----------------------------------------------------------------------\n\n\\section{Quadrature}\n\n\\subsection{Aims}\n\n      \\IEEEPARstart{T}{he}\n      main aim is to write a FORTRAN program to numerically integrate \n      the integral:\n      \\begin{equation}\n            \\label{quadint}\n            \\int_{0}^{1} \\frac{\\ln(1+x)}{x} dx = \\frac{\\pi^{2}}{12}\n      \\end{equation}\n      \\begin{itemize}\n            \\item using the Trapezoidal rule,\n            \\item using Simpson's method,\n            \\item and to investigate the accuracy of both the\n                  Trapezoidal rule and Simpson's method for different\n                  step sizes.\n      \\end{itemize}\n\n\\subsection{Procedure}\n\n    A FORTRAN program was written (\\verb+quad.f+, source code in Appendix A),\n    which implemented both the Trapezoidal and Simpson's rules for the \n    quadrature of equation~\\ref{quadint}. The program calls the\n    functions to calculate the integral a number of times each with a\n    diiferent number of divisions $n$, and hence step size $h$. Both\n    the Trapezoidal and Simpson's rules are evaluated at number of\n    divisions \n    starting from $n=10$ to $n=10^6$, with each new evaluation\n    increasing by a single order of magnitude. This allows the\n    investigation of the accuracy of the different techniques as the\n    number of divisions increases.\n\n    The error is calculated is the absolute error:\n        \\[ Error = \\mathrm{abs}(Result - Answer) \\]\n    where Result is the value produced by the numerical technique and\n    $Answer$, is the analytic solution to the integral known to\n    be $\\frac{\\pi^{2}}{12} \\simeq 0.822467033$.\n\n    Since the integrand is not defined at $x=0$, the FORTRAN function\n    used to evaluate this returns a value of $1.0$ when $x=0$, this is\n    because\n        \\[ \\lim_{x \\rightarrow 0} \\frac{\\ln(1+x)}{x} = 1 \\].\n\n\n\\subsection{Results}\n\n    \\subsubsection{Trapezoidal Rule}\n    The output from the program \\verb+quad.f+ using the Trapezoidal\n    rule is shown below in in Table~\\ref{tbl:trapezoidal} \n\n    \\begin{table}[h] \n      \\caption{Results of using Trapezoidal rule.} \n      \\label{tbl:trapezoidal} \n      \\begin{center}\n      \\begin{tabular}{|r|r|r|r|} \\hline\n           $n$  &         $h$   &     $Result$ &   $Error$ \\\\ \n       \\hline\n       \\hline\n            10  & .1000000000   &.8227225585   &.255525E-03 \\\\\n           100  & .0100000000   &.8224695905   &.255709E-05 \\\\\n          1000  & .0010000000   &.8224670590   &.255711E-07 \\\\\n         10000  & .0001000000   &.8224670337   &.255709E-09 \\\\\n        100000  & .0000100000   &.8224670334   &.255251E-11 \\\\\n       1000000  & .0000010000   &.8224670334   &.263123E-13 \\\\ \\hline\n       \\end{tabular}\n       \\end{center} \n    \\end{table} \n\n    \\subsubsection{Simpson's Rule}\n    The output from the program \\verb+quad.f+ using Simpson's rule is\n    shown below in Table~\\ref{tbl:simpsons}.\n\n    \\begin{table}[h] \n    \\caption{Results using Simpson's rule.} \n    \\label{tbl:simpsons} \n    \\begin{center}\n    \\begin{tabular}{|r|r|r|r|} \\hline\n            $n$   &          $h$  &      $Result$ &        $Error$ \\\\\n    \\hline \n    \\hline\n           10   &.1000000000   &.8224677660   &.732614E-06 \\\\\n          100   &.0100000000   &.8224670335   &.744940E-10 \\\\\n         1000   &.0010000000   &.8224670334   &.799361E-14 \\\\\n        10000   &.0001000000   &.8224670334   &.310862E-14 \\\\\n       100000   &.0000100000   &.8224670334   &.310862E-14 \\\\\n      1000000   &.0000010000   &.8224670334   &.643929E-14 \\\\ \\hline\n    \\end{tabular}\n    \\end{center}\n    \\end{table} \n  \n\\subsection{Discussion}\n\n    Looking at the results for the Trapezoidal rule calculations \n    in Table 1, we see that as we increase the\n    number of divisions $n$ by one order of magnitude, the error\n    decreases by 2 orders. Therefore, we see that when using the\n    Trapezoidal rule for quadrature, the error is of order $O(n^2)$, as \n    expected.\n\n    Making a comparison with the results for the Simpson's rule\n    calculations shown in Table 2, we see that that as the number of\n    divisions $n$ is increased by an order of magnitude, the error\n    decreases by 4 orders. Therefore, when using Simpson's rule, the\n    error is of order $O(n^4)$. \n    The only problem is that the magnitude of the error stops decreasing\n    after n = 10000. The most likely explanation for this is that we\n    have reached the floating point limit on the number of decimal\n    places which the computer which ran the program can handle.\n\n    Therefore we see that that Simpson's rule is more accurate than the\n    trapezoidal rule for quadrature.\n\n%----------------------------------------------------------------------\n% ROOT FINDING\n%----------------------------------------------------------------------\n\n\\section{Root Finding}\n\n\\subsection{Aims}\n\n    The main aim is to write a FORTRAN program which makes use of the\n    false position method to calculate the non zero root of the \n    equation\n    \\begin{equation}\n        \\label{false}\n        \\int_{0}^{x} t^2 dt = x\n    \\end{equation}\n    and to compare with the analytic solution. The program will make use\n    of the Simpson's rule to evaluate the integral.\n\n\\subsection*{Procedure}\n    Firstly equation~\\ref{false} must be solved analytically.\n    \\begin{eqnarray}\n        \\int_{0}^{x} t^2 dt         & = & x \\nonumber \\\\\n        \\left[\\frac{t^3}{2}\\right]_{0}^{x} - x & = & 0 \\nonumber \\\\\n        \\frac{x^3}{3} - x & = & 0 \\nonumber \\\\\n        x\\left(\\frac{x^2}{3} - 1\\right) & = & 0 \\nonumber \n    \\end{eqnarray}\n    Therefore equation~\\ref{false} has three roots\n        \\[ x = 0, \\pm\\sqrt{3} \\]\n    We are interested in finding the positive root,\n    $x = +\\sqrt{3} \\simeq 1.732050808$, of equation~\\ref{false} numerically.\n\n    The procedure involved writing a FORTRAN program to find the roots\n    of the equation\n        \\[ \\int_{0}^{x} t^2 dt -x = 0 \\].\n    The algorithm used to find the root of this equation was the false\n    position method. Simpson's rule was also used in the program to\n    evaluate the integral in the equation.\n\n    The program outputs a table of results, with varying number of\n    divisions $n$ for the Simpson rule calculations and varying\n    $Tolerance$ for the false position method. The values of $n$ range\n    from $n = 10$ to $n = 10^7$ with each one being an order of\n    magnitude of the previous value. The value for the tolerance of the\n    false position algorithm is simply $1/n$.\n\n    The source code for the program \\verb+root.f+ can be found in\n    Appendix B.\n\n\\subsection{Results}\n    The results from the \\verb+root.f+ program using the false position\n    method is shown in Table~\\ref{tbl:false-position}\n\n    \\begin{table}[h]\n    \\caption{Results using the False Position Method.}\n    \\label{tbl:false-position} \n    \\begin{center}\n    \\begin{tabular}{|r|r|r|r|} \\hline\n         $n$  & $Tolerance$ & $Result$  & $Error$ \\\\\n    \\hline \n    \\hline\n         10   &.1000000000  &1.6831581899   &.488926E-01 \\\\\n        100   &.0100000000  &1.7301619523   &.188886E-02 \\\\\n       1000   &.0010000000  &1.7318112238   &.239584E-03 \\\\\n      10000   &.0001000000  &1.7320371397   &.136679E-04 \\\\\n     100000   &.0000100000  &1.7320476140   &.319354E-05 \\\\\n    1000000   &.0000010000  &1.7320506340   &.173520E-06 \\\\ \n   10000000   &.0000001000  &1.7320507671   &.404475E-07 \\\\ \\hline\n    \\end{tabular}\n    \\end{center}\n    \\end{table} \n\n\\subsection{Discussion}\n    Looking at the results in Table 3, we see that as the number of\n    divisions $n$ (for Simpson's rule) is increased in order of magnitude \n    and the tolerance (for false position method) is made smaller, the\n    error decreases by order $O(n)$.\n\n%----------------------------------------------------------------------\n% MOLECULAR VIBRATIONS\n%----------------------------------------------------------------------\n\n\\section{Molecular Vibrations}\n\n\\subsection{Background}\n\n      When two atoms are bound together in a molecular structure such as\n      the two Hydrogen atoms in a $H_2$ molecule, they vibrate. Since\n      the nuclei (protons in this case), are much heavier than the\n      electrons the approximation that the protons are infinitely\n      heavier than the electrons can be made. Therefore the potential\n      between the protons depends only on the distance between them.\n\n      At large distances, the potential is attractive to a van der Waals\n      interaction and repulsive at short distances due to the Coulombic\n      electrostatic repulsion of like charges, and because of the Pauli\n      exclusion principle which states that no two fermions can occupy\n      the same quantum state.\n\n      The interaction of the potential for a diatomic molecule such as\n      $H_2$ can be summarised in the graph below.\n\n      \\begin{center}\n            \\includegraphics[height=5cm]{potential.eps}\n      \\end{center}\n\n      For a quantum system such as this one, Schrodinger's Equation is\n      usually used to solve for the allowed energies $E_n$ of the molecular\n      system.\n      \\begin{equation}\n       \\left[ \\frac{\\hbar}{2m}\\frac{d^2}{dr^2} + V(r) \\right] = E_n\\psi_n\n      \\end{equation}\n\n      Due to the fact that the mass of the protons is approximated to be\n      infinite, the problem can be solved using classical mechanics and\n      then applying quantisation rules of the ``old'' quantum theory.\n\n      The total energy in classical mechanics is given by the sum of the kinetic and potential\n      energies.\n      \\begin{equation}\n            E = \\frac{p^2}{2m} + V(r)\n      \\end{equation}\n      Solving for the momentum $p$ we get:\n      \\begin{equation}\n            p(r) = \\pm\\sqrt{2m(E-V(r)}\n      \\end{equation}\n      To quantize this classical motion, we consider the potential in\n      phase space. The area enclosed by the phase space trajectory is\n      called the ``action'' is given by $S(E)$, where $E$ is the\n      energy. According the ``old'' quantum theory quantisation rules,\n      for a given energy $E_n$, the action must be only half integral\n      multiples of $\\pi$. \n\n      \\begin{equation}\n      S(E_n) = \\oint \\frac{p(r)}{\\hbar} dr \n      \\end{equation}\n\n      \\begin{equation}\n      S(E_n) = \n             2\\sqrt{\\frac{2m}{\\hbar^2}} \n             \\int_{r_{in}}^{r_{out}} \\sqrt{E_n - V(r)} dr \n      \\end{equation}\n\n      \\begin{equation}\n      S(E_n) = \n             \\left(n + \\frac{1}{2} \\right)\\pi\n      \\end{equation}\n\n      \n\n\\subsection{Aims}\n\n    The main aim is to solve the scaled action equation, to find the quantised\n    scaled energy levels $\\epsilon_n$ for the different quantum levels $n$.\n    \\begin{equation}\n        \\label{main}\n        s(\\epsilon_n) = \n            \\gamma\\int_{x_{in}}^{x_{out}} [\\epsilon_n - v(x)]^{1/2} dx =\n            \\left( n + \\frac{1}{2} \\right)\\pi.\n    \\end{equation}\n    The actual energy levels can then be calculated from $E = V\\epsilon$.\n    The aim is to solve the equation with a quadratic potential $v(x)$\n    both analytically and numerically. Then the potential is to be\n    replaced with the Morse potential which can only be solved\n    numerically. The numerical results of the energy then need to be\n    compared with the experimental results obtain for the quantised\n    energy levels of the $\\mathrm{H_2}$ molecule.\n\n\\subsection{Quadratic Potential Procedure}\n\n    Using a quadratic potential $V(r)$, equation~\\ref{main} needs to be solved.\n    \\[ V(r) = 4V_0 \\left( \\frac{r}{a} - 1 \\right) \n                   \\left( \\frac{r}{a} - 2\\right) \\]\n\n    We need to find the roots of $\\epsilon_n - v(x) = 0$,\n    $x_{in}(\\epsilon_n)$ and $x_{out}(\\epsilon_n)$, where \n    $x = r/a$, and $v(x) = V(x)/V_0$ and therefore $v(x) = 4(x-1)(x-2)$.\n    \\begin{eqnarray}\n        \\epsilon_n - v(x)   & = & 0 \\nonumber \\\\\n        \\epsilon_n - 4(x-1)(x-2) & = & 0 \\nonumber \\\\\n        -4x^2 + 12x - 8 + \\epsilon_n & = & 0 \\nonumber\n    \\end{eqnarray}\n    The roots of a quadratic are given by\n    \\[ x_\\pm = \\frac{-b \\pm \\sqrt{b^2 - 4ac} }{2a}\\]\n    \\begin{eqnarray}\n    x_{\\pm} & = & \\frac{-12 \\pm \\sqrt{144 + 16(\\epsilon_n - 8)} }{-8} \\nonumber \\\\\n    x_{\\pm} & = & \\frac{-3 \\pm \\sqrt{\\epsilon_n + 1}}{-2} \\nonumber\n    \\end{eqnarray}\n    Therefore the roots are given by:\n    \\[ x_- = x_{in}(\\epsilon_n) = \\frac{3 - \\sqrt{\\epsilon_n + 1} }{2} \\]\n    \\[ x_+ = x_{out}(\\epsilon_n) = \\frac{3 + \\sqrt{\\epsilon_n + 1} }{2} \\]\n\n    With the roots of the $\\epsilon_n - v(x) = 0$, know available,\n    equation~\\ref{main} can be solved analytically. Alternatively the\n    a convenience equation can be used to solve equation~\\ref{main}.\n    \\[ \\int_{x_-}^{x_+} \\sqrt{ax^2 + bx + c} dx = \\frac{(4ac - b^2)\\pi}{8a\\sqrt{-a}} \\]\n    \\begin{eqnarray}\n        s(\\epsilon_n) = \\gamma\\int_{x_{in}}^{x_{out}} [\\epsilon_n - v(x)]^{1/2} dx & = &\n                        \\left( n + \\frac{1}{2} \\right)\\pi \\nonumber \\\\\n        \\gamma\\int_{x_{in}}^{x_{out}} \\sqrt{-4x^2 + 12x - 8 + \\epsilon_n } dx & = & \n                        \\left( n + \\frac{1}{2} \\right)\\pi \\nonumber \\\\\n        \\gamma\\left[ \\frac{4(-4)(\\epsilon_n - 8) - 144}{-64} \\right] & = &\n                        \\left( n + \\frac{1}{2} \\right)\\pi \\nonumber \\\\\n        \\gamma\\left[ \\frac{\\epsilon_n + 1}{4} \\right] & = &\n                        \\left( n + \\frac{1}{2} \\right) \\nonumber \\\\\n        \\epsilon_n & = & \\frac{4\\left(n + \\frac{1}{2}\\right)}{\\gamma} - 1 \\nonumber\n    \\end{eqnarray}\n\n    Therefore the analytic solution for the energy $\\epsilon_n$ is given\n    by\n    \\begin{equation}\n    \\label{quadenergy}\n    \\epsilon_n = \\frac{4\\left(n + \\frac{1}{2}\\right)}{\\gamma} - 1 \\nonumber\n    \\end{equation}\n\n    Using this information, a FORTRAN program was written, to solve\n    equation~\\ref{main} for the quadratic potential $v(x) = 4(x-1)(x-2)$.\n    The source code for the program \\verb+quadratic.f+ can be found in \n    Appendix C. The program takes the quantum number n, and a value for the constant\n    $\\gamma$ as input.\n\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=0.8\\columnwidth]{flow.eps}\n        \\caption{Flow chart of quadratic integration algorithm}\n        \\label{fig:flow-chart}\n    \\end{figure} \n\n    Figure~\\ref{fig:flow-chart} shows a very high level architectural design of\n    the FORTRAN program \\verb+quadratic.f+ shown in Appendix C.\n\n\\subsection{Quadratic Potential Results}\n    The table below shows the results of the \\verb+quad.f+ program for\n    the values of $n = 0,1,2,3,4$, and with $\\gamma = 1$. Since the\n    accuracy of this method was investigated for different step sizes\n    and tolerance values in the previous section, the results here all\n    have $10^6$ divisions for Simpson's rule and a tolerance of\n    $10^{-6}$ for the false position algorithm.\n  \n    The column labelled $\\epsilon_n$ is the analytic solution to\n    equation~\\ref{main} for $v(x)$ given by equation~\\ref{quadenergy},\n    whereas the column labelled $\\epsilon_n^{*}$ is the solution given\n    by the FORTRAN program \\verb+quadratic.f+.\n\n    \\begin{table}[h] \n    \\caption{Values of $\\epsilon_n$ for a quadratic potential with $\\gamma = 1$.}\n    \\label{tbl:epsilon} \n    \\begin{center}\n    \\begin{tabular}{|r|r|c|c|} \\hline\n    $n$ & $\\epsilon_n$ & $\\epsilon_n^{*}$ & $Error$ \\\\ \n    \\hline\n    \\hline\n    0   &   1   &   1.0000000008    &   .826897E-09 \\\\ \n    1   &   5   &   5.0000000025    &   .248070E-08 \\\\ \n    2   &   9   &   9.0000000041    &   .413422E-08 \\\\ \n    3   &  13   &  13.0000000058    &   .578873E-08 \\\\   \n    4   &  17   &  17.0000000074    &   .744295E-08 \\\\ \\hline\n    \\end{tabular}\n    \\end{center}\n    \\end{table} \n\n    To look at the numerical stability of the program, we vary the\n    number of divisions $N$ in the Simpson quadrature algorithm, and the\n    tolerance in the false position algorithm. Taking just one of the\n    values of $n$, we have the following results for $n = 1$ and\n    $\\gamma = 1$, in the table below.\n\n    \\begin{table}[h]\n    \\caption{$\\epsilon_n$ for $n=1$, $\\gamma = 1$,\n                    for varying tolerances for quadrature and root\n                    finding algorithms.  }\n    \\label{tbl:epsilon-prime} \n    \\begin{center}\n    \\begin{tabular}{|r|r|c|c|} \\hline\n    $N$ & $Tolerance$ & $\\epsilon_n$ & $Error$  \\\\\n    \\hline\n    \\hline\n              10 &.1000000  &5.0801607150   &.801607E-01 \\\\\n             100 &.0100000  &5.0024839897   &.248399E-02 \\\\\n            1000 &.0010000  &5.0000784582   &.784582E-04 \\\\\n           10000 &.0001000  &5.0000024808   &.248084E-05 \\\\\n          100000 &.0000100  &5.0000000785   &.784505E-07 \\\\\n         1000000 &.0000010  &5.0000000025   &.248070E-08 \\\\ \\hline\n    \\end{tabular}\n    \\end{center}\n    \\end{table} \n\n\n\\subsection{Quadratic Potential Discussion}\n\n    Looking at Table~\\ref{tbl:epsilon}, we see good agreement with the values calculated\n    analytically for $\\epsilon_n$ and those calculated numerically, with \n    an error of approximately $10^{-8}$ for all cases except for when\n    the $n = 0$, when the error is approximately $10^{-9}$. \n    The technique can then be used solve the problem of finding the\n    quantized energy levels with more complicated and more physically\n    realistic potentials such as the Morse potential, which there exists\n    no analytic solution and must therefore be solved numberically.\n\n    Looking at Table~\\ref{tbl:epsilon-prime}, we see the results for varying tolerances for\n    both the quadrature (Simpson's) algorithm, $N$, and the root finding\n    algorithm (false position), $Tolerance$, for $n=1$ and $\\gamma=1$.\n    We see that the algorithms used result in numerically stable\n    solutions by oberving that the error consistently decreases, as $N$\n    is increased and as the $Tolerance$ is decreased.\n    \n\n\\subsection{Morse Potential Procedure}\n\n      The procedure was to modify the program used to calculate\n      $\\epsilon_n$ from using a quadratic potential, to a potential that\n      was closer in shape to what had been observed in experiments.\n      This is the Morse potential given by\n      \\begin{equation}\n      V_{Morse}(r) = V_0\\left[\\left(1-e^{-(r-r_{min})/a}\\right)^2 - 1\\right]\n      \\end{equation}\n      The Morse potential can be normalised ($x=r/a$ and $v(x)=V(r)/V_0$)\n      to get\n      \\begin{equation}\n            v(x) = \\left( 1 - e^{-(x-x_{min})} \\right)^2 - 1\n      \\end{equation}\n      The next step is to analytically find the turning points\n      $x_{in}(\\epsilon_n)$ and $x_{out}(\\epsilon_n)$ of the \n      equation $\\epsilon_n - v(x) = 0$.\n      \\[ \\epsilon_n - \\left[ \\left( 1 - e^{-(x-x_{min})} \\right)^2 - 1 \\right] \n                                                 =  0 \\]\n      Let $z = e^{-(x - x_{min})}$\n      \\begin{eqnarray}\n            \\epsilon_n - [ (1-z)^2 - 1] & = & 0\\nonumber \\\\\n            \\epsilon_n - (z^2 - 2z) & = & 0 \\nonumber \\\\\n            z^2 - 2z - \\epsilon_n & = & 0 \\nonumber\n      \\end{eqnarray}\n      Solve for z using\n      \\begin{eqnarray}\n       z_\\pm & = & \\frac{-b \\pm \\sqrt{b^2 - 4ac} }{2a} \\nonumber \\\\\n       z_\\pm & = & \\frac{2 \\pm \\sqrt{4 - 4(1)(-\\epsilon_n)} }{2} \\nonumber \\\\\n       z_\\pm & = & 1 \\pm \\sqrt{1 + \\epsilon_n} \\nonumber\n      \\end{eqnarray}\n      Now substitute $z$ back in to get\n      \\begin{eqnarray}\n            e^{-(x_{\\pm} - x_{min})} & = & 1 \\pm \\sqrt{1 + \\epsilon_n} \\nonumber \\\\\n            -(x_{\\pm} - x_{min}) & = & \n                        \\ln\\left(1 \\pm \\sqrt{1 + \\epsilon_n}\\right) \\nonumber\\\\\n            x_{\\pm} & = & x_{min} - \n                  \\ln \\left( 1  \\pm \\sqrt{1+\\epsilon_n} \\right) \\nonumber\n      \\end{eqnarray}\n      Therefore $x_{in}(\\epsilon_n) = x_{min} - \\ln(1 + \\sqrt{1-\\epsilon_n})$ and\n      $x_{out}(\\epsilon_n) = x_{min} - \\ln(1 + \\sqrt{1+\\epsilon_n})$.\n\n      The following procedure was then followed:\n      \\begin{itemize}\n            \\item The \\verb+quadratic.f+ program was modified to change\n                  the potential from quadratic to Morse and to add the\n                  new turning points calculated above.\n            \\item The source code for the new program \\verb+morse.f+ can\n                  be found in Appendix D.\n            \\item For the case of $n=0$, the program was run with a\n                  number of different values of a, until a value was\n                  found such that the value given for the energy\n                  $E_n = V_0\\epsilon_n$ was very close to value of\n                  $E_0 = -4.477$ as given in Table 1.5 of Koonin\n                  (experimental result).\n            \\item Using the final value of $a$, the first four quantised\n                  energy levels were calculated with the program and\n                  compared with the experimental results for the\n                  $\\mathrm{H_2}$ spectrum.\n            \\item The choice of starting values for $\\epsilon_n$, is\n                  restricted by the turning points, \\\\\n                  $x_{\\pm}  =  x_{min} - \n                  \\ln \\left( 1  \\pm \\sqrt{1+\\epsilon_n} \\right)$.\n                  We can see from this equation that \n                  $-2 < \\epsilon_n \\le 1$.\n      \\end{itemize}\n\n\\subsection{Morse Potential Results}\n\n      \\subsubsection{Determining the parameter $\\mathbf{a}$}\n      The table below shows the results of inputing different values of\n      $a$ into the \\verb+morse.f+ program. We have the following values:\n      \\begin{itemize}\n            \\item $\\gamma = 33.6567a$\n            \\item $r_{min} = 0.74166 \\: \\mathrm{\\dot{A}}$, \n                  $x_{min} = 0.74166a \\: \\mathrm{\\dot{A}}$\n            \\item $V_0 = 4.747 \\: \\mathrm{eV}$, $(E_n = V_0\\epsilon_n)$\n            \\item $n = 0$\n            \\item $N = 1000$ (Number of divisions in Simpson's Rule)\n            \\item $T = 10_{-3}$ (Tolerance in false position method)\n      \\end{itemize}\n      From experimental results looking at the spectrum of the Hydrogen\n      molecule, we know that for the lowest energy state (when $n=0$),\n      we have $E_0 = -4.477 \\: \\mathrm{eV}$. Therefore, for a given\n      value of $a$, we are looking for \n      $\\epsilon_0 = -4.477/4.747 \\simeq -0.943121971$.\n\n      \\begin{table}[h] \n      \\caption{Values of $\\epsilon_0$ for different values of the parameter $a$.}\n      \\label{tbl:epsilon-zero} \n      \\begin{center}\n      \\begin{tabular}{|c|c|} \\hline\n      $a$ & $\\epsilon_0$ \\\\ \\hline \\hline\n      0.50  &     -.9414586271  \\\\\n      0.60  &     -.9510928378  \\\\\n      0.55  &     -.9467075966  \\\\\n      0.52  &     -.9436775546  \\\\   \n      0.51  &     -.9425895401  \\\\ \n      0.515 &     -.9431387536  \\\\ \\hline \n      \\end{tabular}\n      \\end{center}\n      \\end{table} \n\n      We see from Table~\\ref{tbl:epsilon-zero} that we get closest to the value of\n      $\\epsilon_0$ when $a = 0.515$.\n\n      Using this value of $a$, we can then run the program for the first\n      4 values of $n = 0,1,2,3$ and compare to the experimental results.\n      Since the experimental results are only available to 3 decimal\n      places, it is meaningless to attempt to calculate solutions with\n      more accuracy since we don't have more accurate experimental data\n      to compare with. In all cases the calculations were done with 1000\n      divisions in Simpson's rule and a tolerance of $10^{-3}$ for the\n      root finding false position algorithm.\n\n      The results of the running the program for the first four energy\n      levels are shown in Table~\\ref{tbl:first-four}, where $E_n^{*}$ is the\n      numerical result calculated using the program and $E_n$ is the \n      experimental result from Table 1.5 of Koonin.\n\n      \\begin{table}[h]\n      \\caption{First four quantized energy levels of\n      the spectrum of the $H_2$ molecule.}\n      \\label{tbl:first-four} \n      \\begin{center}\n      \\begin{tabular}{|c|c|c|c|c|} \\hline\n      $n$   &   $\\epsilon_n$  & $E_n^{*}$       &  $E_n$    & $Error$   \\\\\\hline \\hline\n      0     &   -.9431387536  & -4.4770796631   & -4.477    & .796631E-04 \\\\\n      1     &   -.8344090650  & -3.9609398314   & -3.962    & .106017E-02 \\\\ \n      2     &   -.7323362062  & -3.4763999710   & -3.475    & .139997E-02 \\\\\n      3     &   -.6369210780  & -3.0234643571   & -3.017    & .646436E-02 \\\\ \\hline\n      \\end{tabular}\n      \\end{center}\n      \\end{table} \n\n\\subsection{Morse Potential Discussion}\n\n      As can be seen from Table 7, the values of the energy levels of\n      the Hydrogen molecule for quantum levels $n = 0,1,2,3$, have a\n      good agreement with the experimental results. The error was of\n      magnitude $10_{-2}$ for $n = 1,2,3$ and of magnitude $10_{-4}$ for\n      $n = 0$. \n\n      The agreement between calculation and experiment is good,\n      especially considering the use of the old quantum theory in the\n      numerical calculations.\n\n      More insight could have been gained into the accuracy of the\n      numerical techniques used to do the calculations if the\n      experimental data presented for the Hydrogen molecule spectrum was\n      more accurate.\n\n      With all the data now available we can make a plot of the equation\n      \\[ V_{Morse}(r) = V_0\\left[\\left(1-e^{-(r-r_{min})/a}\\right)^2 - 1\\right]. \\]\n      Using the values for $\\gamma$, $a$, $r_{min}$, and $V_0$, shown in\n      the previous section we can plot the Morse potential for the\n      Hydrogren molecule in Figure~\\ref{fig:morse} \n\n        \\begin{figure}\n        \\centering\n        \\includegraphics[width=0.8\\columnwidth]{morse.eps}\n        \\caption{Morse Potential for Hydrogen Molecule} \n        \\label{fig:morse} \n        \\end{figure} \n\n\n      Using the data for the first four quantized energy levels, we can\n      plot these on top of the Morse potential plot, shown in \n      Figure~\\ref{fig:levels}. \n\n        \\begin{figure}[ht] \n        \\centering\n        \\includegraphics[width=0.8\\columnwidth]{levels.eps} \n        \\caption{First Four Quantized Energy Levels} \n        \\label{fig:levels} \n        \\end{figure} \n\n\n%----------------------------------------------------------------------\n% APPENDICES\n%----------------------------------------------------------------------\n\n\\onecolumn\n\n\\appendix[Code Listing: quad.f]\n\\showcode{quad.f} \n\n\\newpage \n\\appendix[Code Listing: root.f] \n\\showcode{root.f} \n\n\\newpage \n\\appendix[Code Listing: quadratic.f] \n\\showcode{quadratic.f}\n\n\\newpage \n\\appendix[Code Listing: morse.f] \n\\showcode{morse.f}\n\n%----------------------------------------------------------------------\n% END DOCUMENT\n%----------------------------------------------------------------------\n\n\\end{document}\n\n%----------------------------------------------------------------------\n", "meta": {"hexsha": "9ec253b5f0d3c1e5f6b3fe0fde2bd98552eb147e", "size": 30136, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "molecules.tex", "max_stars_repo_name": "mikepsn/molecular-vibrations", "max_stars_repo_head_hexsha": "683b3c920d344722b63cf0367880063a9b91926c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "molecules.tex", "max_issues_repo_name": "mikepsn/molecular-vibrations", "max_issues_repo_head_hexsha": "683b3c920d344722b63cf0367880063a9b91926c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "molecules.tex", "max_forks_repo_name": "mikepsn/molecular-vibrations", "max_forks_repo_head_hexsha": "683b3c920d344722b63cf0367880063a9b91926c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3967828418, "max_line_length": 94, "alphanum_fraction": 0.5916179984, "num_tokens": 8795, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813031051514762, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.41955157042199087}}
{"text": "% !TeX root = ./report.tex\n\\maketitle\n%\\listoftodos\n\\begin{abstract}\nThe geometric independent set problem is a special case of the independent set problem where the graph is the intersection graph of a set of geometric objects. The challenge of the geometric independent set problem is to find the biggest set of non-intersecting objects, i.e. the maximum independent set  (MIS). In this report I will present polynomial time approximation schemes (PTAS) for the geometric independent set problem for unit disk graphs (UDG) and for unit height rectangles. The geometric independent set problem is in general $\\NP$- hard and therefore intractable. The algorithms presented here use different approaches to guarantee a polynomial running time for a constant approximation quality.\n\\end{abstract}\n\n\\tableofcontents\n\n\n\n\\section{Introduction}\nThe geometric independent set problem, i.e. finding a (maximum) set of non-intersecting geometric shapes is a problem that can arise in many different fields. In this report I will introduce algorithms to give approximate solutions for the MIS of unit disk graphs as well as for the geometric independent set problem for unit height rectangles. Unit disks may correspond to the area of influence of radio towers where frequencies can only be assigned to radio towers where this areas do not intersect (i.e. an independent set) to prevent interference~\\cite{chamaret}. The maximum independent set of unit height rectangles could correspond to a labelling of a two dimensional map with a uniform font~\\cite{agarwallabel}.\n\\subsection{Maximum independent set problem for graphs}\nAn independent set of a graph is a set of vertices that are not adjacent (connected with an edge). Finding a maximum independent set of an arbitrary graph is known to be an \\NP-complete problem~\\cite{misnp}. The best known exact algorithms have a runtime \\bigo{1.22^n} \\cite{exacta,exactb} (already quite good compared to the \\bigo{n^2 2^n} naive brute force approach resulting from checking every subset of vertices).\n\nIf the graph is an interval intersection graph (see \\Fref{sec:ig}) the MIS can be found in polynomial time (similar to the algorithm described in~\\Fref{sec:greedyalg}) though for many (most) other intersection graphs it is still \\NP-complete but approximate solutions can be found efficiently.\n\n\n\\subsection{Polynomial time approximation scheme}\nAs finding exact solutions for \\NP-hard problems is not feasible in most cases, algorithms that solve a given instance of an intractable problem in polynomial time with a bounded loss in solution quality are of interest. A so called polynomial time approximation scheme (PTAS) is a family of algorithms that find a solution with a solution quality that is bounded by a factor of $(1+\\varepsilon)$ for any $\\varepsilon > 0$. %\\todo{PTAS subsection überarbeiten, ist recht konfus aktuell}\n%\\begin{align*}\n%\\frac{S_{\\text{OPT}}}{\\rho} \\quad \\text{or}\n%\\quad \\frac{S_{\\text{OPT}}}{1\\pm \\varepsilon} \\qquad (S_{\\text{OPT}} \\ldots \\text{quality of optimal solution})\n\nThat is, if the optimal solution is $S_\\text{OPT}$, the algorithm finds a solution with a quality of at least $\\nicefrac{S_\\text{OPT}}{1+\\varepsilon}$ for a maximization problem and a solution with a quality of at most $(1+\\varepsilon)S_\\text{OPT}$ for a minimization problem.\n%\\end{align*} in polynomial time. For maximization problems $\\rho> 1$, for minimization problems $\\rho < 1$  (or $(1+\\varepsilon)$ respectively $(1 - \\varepsilon)$ for some $\\varepsilon > 0$).\nIn both cases the algorithm has runtime polynomial in input-size though the dependency on $\\varepsilon$ is usually not polynomial.\n\nThe subset of problems in \\NP\\ (actually $\\mathcal{NPO}$ -- \\NP-\\ Optimization) with a polynomial time approximation scheme with constant quality bound (with \\bigo{1}-approximation) is also called $\\mathcal{APX}$. If the problem admits $1\\pm \\varepsilon$- approximation schemes (for arbitrarily small $\\varepsilon > 0$) it is in the subset $\\mathcal{PTAS}$ of $\\mathcal{APX}$.\n\\subsection{Intersection graphs}\\label{sec:ig}\nAn intersection graph of a set of objects represents how these objects intersect each other. \\Fref{fig:igex} shows an example of such an arrangement and its corresponding intersection graph.\n  \\begin{figure*}[!h]\n    \\centering\n    \\begin{subfigure}[t]{0.5\\textwidth}\n        \\centering\n\n \\begin{tikzpicture}[scale=0.6]\n \\clip (-1.2,-1.2)rectangle(7.1,4.6);\n \\newcommand{\\centers}{(0,1),(0,0),(5,3),(2,1),(0.5,0.7),(4,3),(1.6,3.5),(6,0.5)}\n \\foreach [count=\\i] \\coord in \\centers{\\draw[thick] \\coord circle(1);}\n \\end{tikzpicture}\n      \\caption{Geometric shapes (unit disks)}\n\\end{subfigure}%\n  ~ \n \\begin{subfigure}[t]{0.5\\textwidth}\n      \\centering\n \\begin{tikzpicture}[scale=0.6]\n \\clip (-1.2,-1.2)rectangle(7.1,4.6);\n    % link centers if circles intersect\n      \\newcommand{\\centers}{(0,1),(0,0),(5,3),(2,1),(0.5,0.7),(4,3),(1.6,3.5),(6,0.5)}\n      \\foreach [count=\\i] \\coord in \\centers{\\draw[gray!30,thick] \\coord circle(1);}  \n        \\foreach[count=\\i] \\a in \\centers {\n      \\foreach[count=\\j] \\b in \\centers {\n        \\ifnum \\j < \\i\n          \\draw[very thick] let \\p1=\\a, \\p2=\\b, \\n1={veclen(\\x1-\\x2,\\y1-\\y2)} in\n            {\\ifdim \\n1 < 2 cm \\a -- \\b \\fi};\n        \\fi\n      }\n    }\n    % draw circles\n    \\foreach \\coord in \\centers{\\fill \\coord circle(3pt);}\n  \\end{tikzpicture}\n        \\caption{Corresponding intersection graph}\n    \\end{subfigure}\n    \\caption{Arrangement of geometric shapes and corresponding intersection graph}\\label{fig:igex}\n\\end{figure*}\n\nIt is also possible to reduce the edge set of the intersection graph to e.g.\\ those edges where the corresponding objects intersect on an area bigger than a certain threshold (e.g. finding feasible locations for base stations where overlapping regions are inefficient). An example of this is in \\Fref{fig:igex2} with a threshold of $20\\%$ of the circle area.\n\\begin{figure}\\centering\n\n\n\\end{figure}\n\n  \\begin{figure*}[!h]\n    \\centering\n    \\begin{subfigure}[t]{0.5\\textwidth}\n        \\centering\n\n\\begin{tikzpicture}[scale=0.35,rotate=90]\n\\newcommand{\\centers}{(0,0),(2,1),(1.6,3.5),(0,5),(5,3),(0.6,7),(4,6)}\n{ \\foreach \\coord in \\centers{\\draw[thick] \\coord circle(2);}}        \n\\newcommand{\\centerss}{(0,0),(1.6,3.5),(5,3),(0.6,7),(4,6)}\n\\end{tikzpicture}\n   \\caption{Geometric shapes (unit disks)}\n\\end{subfigure}%\n  ~ \n \\begin{subfigure}[t]{0.5\\textwidth}\n      \\centering\n\\begin{tikzpicture}[scale=0.35,rotate=90]\n\\newcommand{\\centers}{(0,0),(2,1),(1.6,3.5),(0,5),(5,3),(0.6,7),(4,6)}\n{ \\foreach \\coord in \\centers{\\draw[gray!40, thick] \\coord circle(2);}}        \n{\\draw[ultra thick] (0,0) -- (2,1) -- (1.6,3.5) -- (0,5)-- (0.6,7);}\n{ \\foreach \\coord in \\centers{\\fill \\coord circle(0.15);}}        \n\\end{tikzpicture}\n      \\caption{Corresponding intersection graph}\n    \\end{subfigure}\n    \\caption{Edges in IG correspond to at least $20\\%$ intersecting area of the circles.}\\label{fig:igex2}\n\\end{figure*}\n\n\n\\subsubsection{Construction of intersection graphs from geometric objects}\nGiven an arrangement $\\mathcal A$ of $n$ geometric objects its intersection graph $G=(V,E)$ can be obtained in the following way: \n\\begin{itemize}\n\\item The vertex set $V$ consists of $n$ vertices --- each of them uniquely represents one of the geometric shapes of $\\mathcal A$\n\\item For every pair $s_i, s_j$ of vertices check whether they intersect each other and add the edge $\\langle i, j\\rangle$ to the edge set $E$ if this is the case. \n\\end{itemize}\nObviously the runtime of this scheme is \\bigo{n^2}. The worst case performance of finding an intersection graph is always \\bigo{n^2} as there can be a quadratic amount of intersections (if all objects intersect each other). If there are less intersection this can usually be improved to \\bigo{n \\log n + I} where $I$ is the amount of intersections (once again, with quadratic upper bound) and the other term is from sorting the objects according to some criterion, e.g. the leftmost point of the object on the x-axis. Sweepline algorithms are used for this, the best known is the Bentley--Ottman algorithm for line segments~\\cite{bentleyott} with runtime \\bigo{n \\log n +n I}. \n\n\\subsubsection{Geometric representation of  intersection graph}\n%Every graph can be interpreted as intersection graph (Erdös et al.~\\cite{erdos1966representation} gave a constructive proof with  of some weirdly shaped geometric objects\\todo{genauer erklären},\nFinding a valid representation, i.e. a mapping  $f : V \\to \\mathbb R^d$, from the set of vertices to a vector representation of the geometric objects defined by $x_1, \\ldots x_d \\in \\mathbb R$ (e.g. for disks in the plane $d=3$ ($x-,y-$ coordinates and radius), for rectangles $d=4$ (two points with two coordinates each)) is in many cases a $\\NP$-hard problem \\cite{nphard} and it is therefore not feasible to find a geometric representation of a given graph and use the additional information to simplify the general independent set problem.\n\n\\subsection{Robust algorithms}\nAn algorithm $\\mathcal A$ computes a function $f: \\mathcal G \\to \\mathcal H$. If the algorithm is only able to compute the correct result $f(i)$ for $i \\in \\mathcal U \\subset G$ there are elements in $\\mathcal G$ that are not in $\\mathcal U$ and therefore the algorithm may not compute the correct result (or may not terminate at all).\n\\begin{definition}\n An algorithm $\\mathcal A$ computes $f$ \\textit{robustly on $\\mathcal U$} if:\n\\begin{itemize}\n\\item for all instances $i\\in\\mathcal U$ it returns the correct result $f(i)$\n\\item for all instances $i\\in\\mathcal G\\setminus \\mathcal U$ the algorithm either returns $f(i)$ or a certificate showing that $i\\notin \\mathcal U$.\n\\end{itemize}\n\\end{definition}\n\n\\section{M(W)IS for unit disk graphs (UDG)}\nIn this section I will present a robust PTAS for both, the weighted and unweighted unit disk graph independent set problem as introduced by Nieberg et al.~\\cite{nieberg}. The algorithm does not depend on the geometric representation, though the polynomial runtime is only guaranteed if such a representation exists because it uses the area $\\pi$ of the unit disks to get an upper bound on the amount of disks in an independent set of a certain area.\n\\subsection{Preliminaries}\nA unit disk graph $G=(V,E)$ is a graph where there exists a geometric representation $f:V \\to \\mathbb R^2$ i.e.\\ a function that maps every vertex to a point to the center point on the real Cartesian plane of the disk in the geometric representation such that:\n\\begin{align}\n(u,v) \\in E \\leftrightarrow ||f(u) - f(v)|| \\leq 2.\\label{eq:maxdist}\n\\end{align}\nAs finding this representation is \\NP-hard it is not feasible to compute a valid representation of the given graph. Furthermore it is also \\NP-hard to determine if a valid geometric representation even exists~\\cite{nphard}.\n\nFurthermore, let $\\rho = 1+\\varepsilon$ denote the desired approximation ratio where $\\varepsilon > 0$. \n\\subsection{MIS for unweighted UDG}\\label{sec:misudg}\nThe algorithm is given a UDG $G = (V,E)$ and the desired result is a set $I \\subseteq V$ that has a cardinality that is at least $\\alpha(G)\\rho^{-1}$ where $\\alpha(G)$ is the maximum size of an independent set in $G$.\nThe algorithm starts at an arbitrary node $v\\in V$ and computes the sets\n\\begin{align*}\nN_r = N_r(v) := \\{w\\in V|w \\text{ has distance at most $r$ from $v$}\\}\n\\end{align*} for $r = 0,1,\\ldots$. Starting from $N_0$ the algorithm computes the maximum independent set $I_r \\subset N_r$ of these $r$-neighborhoods until the condition\n\\begin{align}\n|I_{r+1}| > \\rho|I_r| \\label{eq:udgcond}\n\\end{align}is no longer fulfilled - let $\\bar r$ be the smallest $r$ where \\fref{eq:udgcond} is violated. Such a $\\bar r$ must exist and it has a constant upper bound.\n\\Fref{fig:udgalg} shows how these neighborhoods are selected on an example graph.\n\\input{img/NIn.tex}\n\\begin{theorem}[Nieberg et al.~\\cite{nieberg}]\nThere exists a constant $c= c(\\rho)$ such that $\\bar r \\leq c$\n\\end{theorem}\n\\begin{proof}\nDue to \\Fref{eq:maxdist} any vertex $w\\in N_r$  satisfies\n\\begin{align*}\n||f(w) - f(v)|| \\leq 2r. \n\\end{align*}\nit is therefore possible to draw a circle with radius $R = 2r+1$ that contains all disks representing the vertices in $N_r$. This circle also contains the disk representations of the vertices in $I_r$ which have a disjoint area of $\\pi$ each (as their radius equals $1$). This leads to an upper bound on the size of each independent set:\n\\begin{align}\n|I_r| \\leq \\pi R^2 /\\pi = (2r+1)^2 = O(r^2).\\label{eq:udupper}\n\\end{align}\nFrom \\Fref{eq:udgcond}follows:\n\\begin{align}\n|I_r| > \\rho|I_{r-1}| > \\ldots  > \\rho^r|I_0| = \\rho^r.\\label{eq:udglower}\n\\end{align}\nCombining \\eqref{eq:udupper} and \\eqref{eq:udglower} yields\n\\begin{align}\n\\rho^r < |I_r| \\leq O(r^2), \\label{eq:upperboundlol}\n\\end{align}\nan inequality (two of them actually) where the lower bound grows asymptotically faster then the upper bound with increasing $r$ -- therefore there exists a constant upper bound $c(\\rho)$ for $r$.\n\\end{proof}\nThe fact that the size of the independent sets calculated for the various $N_r$ ($r\\leq \\bar r$) implies a polynomial runtime of $\\bigo{n^{C^2}}$ (where $C = \\bigo{r} = \\bigo{1/\\varepsilon^2 \\log (1/\\varepsilon}$).\nThe full algorithm proceeds as follows:\n\\begin{enumerate}\n\\item Calculate the independent set $I_{\\bar r}$ starting from an arbitrary vertex $v$.\n\\item Remove the vertices in $N_{\\bar r +1 }$ from the graph $G$ to get the graph $G' = (V',E') = G\\setminus N_{\\bar r +1}$ (including edges incident to any of the removed vertices).\n\\item Repeat the previous two steps for $G'$ until there is no vertex left i.e.\\ $G' = (\\varnothing,\\varnothing)$.\n\\item Combine all $I_{\\bar r}$ to get a $\\rho$-approximate maximum independent set.\n\\end{enumerate}\n\n\n\n\n\\subsubsection{Proof of correctness \\& approximation guarantee}\n\nThe correctness and approximation guarantee follows from the following two theorems by Nieberg et al.~\\cite{nieberg}:\n\\begin{theorem}\nSuppose that we can compute an independent set $I'\\subset V\\setminus N_{\\bar r+1}$ of the graph $G'$. Then $I:=I_{\\bar r} \\cup I'$ is an independent set for $G$.\n\\end{theorem}\n\\begin{proof}\nA vertex $v\\in I'\\subset V'$ has no neighbor $n\\in N_{\\bar r}$ as the distance between $v$ and any such $n$ is at least $\\bar r +2$ (else it would have been in $N_{\\bar r}$ and removed from the vertex set of $G'$). Therefore $I$ is an independent set. \n\\end{proof}\n\n\\begin{theorem}\nSuppose inductively that we can compute a $\\rho$-approximate independent set $I'\\subset V\\setminus N_{\\bar r+1}$ of the graph $G'$. Then $I:=I_{\\bar r} \\cup I'$ is a  $\\rho$-approximate independent set for $G$.\n\\end{theorem}\n\\begin{proof}\nAs $\\bar r$ is chosen in such a way that the maximum independent set of $N_{\\bar r}$ is a $\\rho$-approximate independent set of $N_{\\bar r +1}$  (ensured by \\Fref{eq:udgcond}):\n\\begin{align*}\n|I_{\\bar r +1}| \\leq \\rho|I_{\\bar r}|.\n\\end{align*}\nTherefore the following holds:\n\\begin{align*}\n\\alpha(G[N_{\\bar r +1}]) \\leq \\rho|I_{\\bar r}|  = \\rho\\alpha(N_{\\bar r}).\n\\end{align*}\nFurthermore it is obvious that the size of an independent set of a graph is at most as large as the sum of the sizes of independent sets of subgraphs that form a partition of the initial graph. Applying this here yields\n\\begin{align*}\n\\alpha(G)& \\leq \\alpha(G[N_{\\bar r +1 }]) + \\alpha(V\\setminus G[N_{\\bar r +1}]) \\leq \\rho|I|\\\\\n\\alpha(G)& \\leq  \\rho|I|,\n\\end{align*} and thus proves that the desired approximation guarantee is fulfilled.\n%\\TODO[maybe make this proof a little easier to understand]\n\\end{proof}\n\\subsection{MWIS for weighted UDG}\\label{sec:mwisudg}\nIf the given UDG has a vector $\\vec w$ assigning positive values $w_i$ to every vertex $v_i$ and the objective is to find an independent set of maximum weight the algorithm described in \\Fref{sec:misudg} can be easily adapted to yield an independent set that has a weight that is at least $\\rho^{-1}$ the weight of the independent set with the maximum weight.\nThe following things have to be adapted:\n\\paragraph{Starting node $v_0$:} Don't start at an arbitrary node $v_0$ but at the node with the heighest weight.\n\\paragraph{Stopping criterion:} Modify the stopping criterion in \\Fref{eq:udgcond} to consider the weight instead of only the size. The function $W: V^n\\to \\mathbb R$ maps vertices to their weight and sets of vertices to the sum of their weight. \n\\begin{align*}\nW(I_{r+1}) > \\rho W(I_r)\n\\end{align*}\nObtaining the bound to get a constant upper bound (as in \\Fref{eq:upperboundlol}) is rather straightforward:\\\\\n\\begin{theorem}[Nieberg et al.~\\cite{nieberg}]\nThere exists a constant $c= c(\\rho)$ such that $\\bar r \\leq c$\n\\end{theorem}\n\\begin{proof}\nThe idea of the proof is the same as for the unweighted case. As the upper bound use:\n\\begin{align*}\nW(I_r) &= \\sum_{i\\in I_r}W(v_i)\\leq \\sum_{i\\in I_r}W(v_0) = |I_r|w_0\n\\intertext{where $w_0$ is the weight of $v_0$ -- the vertex with highest weight. And the lower bound use:}\nW(I_r) &> \\rho W(I_{r-1} > \\ldots > \\rho^r W(I_0) = \\rho^r  w_0\n\\end{align*}As it still holds that $I_r$ is bounded by $\\bigo{r^2}$ (using the area of the unit disks) we get the same upper and lower bounds but with an additional constant factor for the weight of the initial node. \n\\end{proof}\n\n\\subsection{Robustness}\nThe algorithms outlined in \\Fref{sec:misudg} and \\Fref{sec:mwisudg} are PTAS with the desired solution quality as long as the graph really is a unit disk graph. To get a robust PTAS for arbitrary graphs from this there are some minor modifications necessary. Observe, that in both cases the approximation quality as well as the overall correctness did not depend on any properties of a UDG. Only for getting the constant bound on the sizes of the independent sets $I_r$ the area of the disks was used. \\\\\nThe only necessary modification is therefore to look whether an independent set of size $|I_r^*| > (2r+1)^2$ can be found and if this is the case return it as certificate that the given graph is not a UDG. Finding this set is also possible in polynomial time as not the maximum independent set $I_r\\subset N_r$ has to be found (the maximum size of this independent set would be unbounded and therefore impossible to determine in polynomial time) but only an independent subset with a size of at least $(2r+1)^2+1$ is necessary which is still possible in polynomial time.\n\n\\section{MIS for unit height rectangles}\nThe maximum independent set problem for unit height rectangle is a problem that arises when labelling maps. The goal is to find a maximum non-intersecting set of possible labels in the plane to ensure legibility. In this section I will present a $2$-approximation algorithm  with \\bigo{n \\log n} runtime for the unweighted MIS problem for unit height rectangles introduced by Agarwal et al.~\\cite{agarwallabel} which can be improved upon with a dynamic programming approach to get a $(1+\\nicefrac{1}{k})$-approximation algorithm with runtime \\bigo{n \\log n + n^{2k-1}} for $k\\geq 1$. The idea of the improvement will be presented here, for the technical details the original paper has to be consulted. For this algorithms the arrangement of rectangles is required.\n\\subsection{A $2$-approximation algorithm}\nThe set of $n$ rectangles $R$ with unit height is given. The maximum independent set of rectangles is $I_\\text{OPT}$. To get a $2$-approximate independent set, the algorithm partitions the $n$ rectangles into disjunct subsets, calculates the maximum independent set of those subsets and returns the conjunction of those independent sets. To divide the rectangles into sets horizontal lines $\\ell_1, \\ell_2,\\ldots,\\ell_m$ where $m\\leq n$ are drawn such that the following three conditions hold:\n\\begin{itemize}\n\\item The distance between two adjacent lines is $>1$. i.e.\\ bigger than the height of a rectangle\n\\item Each line intersects at least one rectangle\n\\item Each rectangle is intersected by exactly one line\n\\end{itemize}\nTo find the correct positions for the lines, first sort the rectangles according to their vertical coordinates and draw the first line at the top of the rectangle with smallest $y$-coordinate and the following lines at the top of the rectangle with the smallest $y$-coordinate that is not yet intersected by a line.  \\Fref{fig:uhr1a} illustrates this. Now every rectangle has an intersecting line and the initial arrangement of rectangles is partitioned into sets $R_1,\\ldots,R_m$ where for every $1\\leq i \\leq m$ the set $R_i$ contains those rectangles that are intersected by the line $\\ell_i$.\n\nDue to the fact that the distance between two lines is bigger than the height of the rectangles a rectangle in the set $R_i$ can only intersect with rectangles in the sets $R_i$ and $R_i\\pm1$. Therefore the independent sets $I_i$ of the even sets $R_{2n}$ and the odd sets $R_{2n+1}$ ($0\\geq n \\geq \\nicefrac{m}{2}$) can be combined to two independent sets $I_{\\text{odd}} = \\bigcup_{n> 0} I_{2n}$ and $I_{\\text{even}} = \\bigcup_{n\\geq 0} I_{2n+1}$.\n\n\\subsubsection{Greedy algorithm for MIS of intervals}\\label{sec:greedyalg}\nThe MIS of every subset $R_i$ can be found in polynomial time with a greedy algorithm. As can be seen in \\Fref{fig:uhr1c} two rectangles that are intersected by a common horizontal line only intersect each other iff the intervals of their $x$-coordinates intersect each other. Therefore the problem of finding a MIS of the rectangles in one of the sets $R_i$ can be reduced to finding a MIS of the horizontal projection of these rectangles. For this a greedy algorithm with runtime \\bigo{n\\log n} exists. The idea of this algorithm is the following inductive argument: For every point $p$ on the $x$-axis at most one interval in the MIS can be \\textit{active}, i.e.\\ having a start point $s$ and an end point $e$ s.t.\\ $s\\leq p\\leq e$. It follows that if two (or more) intervals intersect each other at one point at most one of these intervals can be added to an independent set. Choosing the interval with the lowest endpoint allows choosing more intervals after this interval (see \\Fref{fig:uhr1d}). \n\n\\begin{figure*}[!h]\n\\centering\n\\begin{subfigure}[t]{0.5\\textwidth}\n\\centering\n\\definecolor{cadmiumred}{rgb}{0.89, 0.0, 0.13}\n\\definecolor{cadmiumgreen}{rgb}{0.01, 0.75, 0.24}\n\\begin{tikzpicture}\n\\draw[very thick,cadmiumred] (1,0) rectangle+(1,1);\n\\draw[very thick,cadmiumred] (6,0) rectangle+(0.5,1);\n\\draw[very thick,cadmiumred] (3.5,0.2) rectangle+(1.5,1);\n\\draw[very thick,cadmiumred] (5.2,0.4) rectangle+(1,1);\n\\draw[very thick,cadmiumred] (3,0.8) rectangle+(0.9,1);\n\n\\draw[very thick,MidnightBlue] (2.2,1.3) rectangle+(1.5,1);\n\\draw[very thick,MidnightBlue] (1,1.4) rectangle+(1.9,1);\n\\draw[very thick,MidnightBlue] (3.5,1.6) rectangle+(2,1);\n\n%\\definecolor{darkpastelgreen}{rgb}\n\\draw[very thick,cadmiumgreen] (0.2,2.5) rectangle+(1.9,1);\n\\draw[very thick,cadmiumgreen] (6,2.5) rectangle+(1.2,1);\n\\draw[very thick,cadmiumgreen] (2.2,2.8) rectangle+(1.3,1);\n\\draw[very thick,cadmiumgreen] (1,2.9) rectangle+(0.7,1);\n\\draw[very thick,cadmiumgreen] (5.3,2.9) rectangle+(0.8,1);\n\\draw[very thick,cadmiumgreen] (3,3) rectangle+(1.5,1);\n\\draw[very thick,cadmiumgreen] (3.6,3.1) rectangle+(1,1);\n\\draw[very thick,cadmiumgreen] (4.7,3.3) rectangle+(0.5,1);\n\n\\draw[very thick,dashed] (0,1.0)--+(7.5,0) node[right] {$\\ell_1$};\n\\draw[very thick,dashed] (0,2.3)--+(7.5,0)node[right] {$\\ell_2$};\n\\draw[very thick,dashed] (0,3.5)--+(7.5,0)node[right] {$\\ell_3$};\n\\end{tikzpicture}\n\\caption{Unit height rectangles partitioned into three sets $\\color{cadmiumred}{R_1},\\color{MidnightBlue}{R_2},\\color{cadmiumgreen}{R_3}$ with intersecting lines $\\ell_1,\\ell_2,\\ell_3$.}\\label{fig:uhr1a}\n\\end{subfigure}%\n  ~ \\vline ~ \n \\begin{subfigure}[t]{0.5\\textwidth}\n      \\centering\n\\begin{tikzpicture}[scale=1]\n\\draw[very thick,gray!50] (3.5,0.2) rectangle+(1.5,1);\n\\draw[very thick,gray!50] (6,0) rectangle+(0.5,1);\n\n\\draw[very thick,gray!50] (2.2,1.3) rectangle+(1.5,1);\n\n\n\n\\draw[ultra thick] (1,0) rectangle+(1,1);\n\\draw[ultra thick] (3,0.8) rectangle+(0.9,1);\n\\draw[ultra thick] (5.2,0.4) rectangle+(1,1);\n\n\\draw[ultra thick] (1,1.4) rectangle+(1.9,1);\n\\draw[ultra thick] (3.5,1.6) rectangle+(2,1);\n\n\n\n\\draw[very thick,gray!50] (3,3) rectangle+(1.5,1);\n\\draw[very thick,gray!50] (6,2.5) rectangle+(1.2,1);\n\\draw[very thick,gray!50] (0.2,2.5) rectangle+(1.9,1);\n\\draw[ultra thick] (1,2.9) rectangle+(0.7,1);\n\\draw[ultra thick] (2.2,2.8) rectangle+(1.3,1);\n\\draw[ultra thick] (3.6,3.1) rectangle+(1,1);\n\\draw[ultra thick] (4.7,3.3) rectangle+(0.5,1);\n\\draw[ultra thick] (5.3,2.9) rectangle+(0.8,1);\n\n\n\\draw[very thick,dashed] (0,1.0)--+(7.5,0) node[right] {$\\ell_1$};\n\\draw[very thick,dashed] (0,2.3)--+(7.5,0)node[right] {$\\ell_2$};\n\\draw[very thick,dashed] (0,3.5)--+(7.5,0)node[right] {$\\ell_3$};\n\\end{tikzpicture}\n\\caption{MIS $I_1,I_2,I_3$ (black) for the sets $R_i$. Note that rectangles from IS of two adjacent sets ($I_i, I_{i\\pm 1}$) may intersect each other.}\n\\end{subfigure}\\\\\n \\begin{subfigure}[t]{0.5\\textwidth}\n\\centering\n\\begin{tikzpicture}[scale=1]\n\\draw[very thick] (1,2.9) rectangle+(0.7,1);\n\\draw[very thick] (3,3) rectangle+(1.5,1);\n\\draw[very thick] (6,2.5) rectangle+(1.2,1);\n\\draw[very thick] (0.2,2.5) rectangle+(1.9,1);\n\\draw[very thick] (2.2,2.8) rectangle+(1.3,1);\n\\draw[very thick] (3.6,3.1) rectangle+(1,1);\n\\draw[very thick] (4.7,3.3) rectangle+(0.5,1);\n\\draw[very thick] (5.3,2.9) rectangle+(0.8,1);\n\\draw[very thick,dashed] (0,3.4)--+(7.5,0);\n\\begin{scope}[yshift=2.2cm]\n\\draw[very thick] (0.2,0) rectangle+(1.9,0);\n\\draw[very thick] (1,0.1) rectangle+(0.7,0);\n\\draw[very thick] (2.2,0) rectangle+(1.3,0);\n\\draw[very thick] (3,0.1) rectangle+(1.5,0);\n\\draw[very thick] (3.6,0.0) rectangle+(1,0);\n\\draw[very thick] (4.7,0.0) rectangle+(0.5,0);\n\\draw[very thick] (5.3,0.0) rectangle+(0.8,0);\n\\draw[very thick] (6,0.1) rectangle+(1.2,0);\n%\\draw[very thick,dashed] (0,1)--+(7.5,0);\n\\end{scope}\n\\end{tikzpicture}\n\\caption{To find a MIS of $R_3$ only the $x$-coordinates have to be considered. Two rectangles intersect iff their projection to a horizontal line (below) intersects.}\n\\label{fig:uhr1c}\n\\end{subfigure}%\n  ~ \\vline ~ \n \\begin{subfigure}[t]{0.5\\textwidth}\n\\centering\n\\begin{tikzpicture}[scale=1]\n\\draw[ultra thick] (1,0) rectangle+(0.7,0);\n\\draw[ultra thick,gray!50] (0.2,0.1) rectangle+(1.9,0);\n\\draw[ultra thick] (2.2,0.2) rectangle+(1.3,0);\n\\draw[ultra thick,gray!50] (3,0.3) rectangle+(1.5,0);\n\\draw[ultra thick] (3.6,0.4) rectangle+(1,0);\n\\draw[ultra thick] (4.7,0.5) rectangle+(0.5,0);\n\\draw[ultra thick] (5.3,0.6) rectangle+(0.8,0);\n\\draw[ultra thick,gray!50] (6,0.7) rectangle+(1.2,0);\n%\\draw[very thick,dashed] (0,1)--+(7.5,0);\n\\end{tikzpicture}\n\\caption{Horizontal projection of rectangles in $R_3$ ordered (in vertical direction) by their endpoint. Greedy algorithm adds interval with nearest endpoint (bottom to top in this figure) that does not intersect rectangles already in the set.}\n\\label{fig:uhr1d}\n\\end{subfigure}\n\n    \\caption{Illustration of the $2$-approximation algorithm for the unit height rectangle MIS problem.}\\label{fig:uhr1}\n\\end{figure*}\n\n\n\\subsubsection{Correctness and proof of approximation quality}\n\\begin{theorem}\nThe set $I_{\\text{even}} = \\bigcup_{n> 0} I_{2n}$ obtained by combining the maximum independent sets $I_{n}$ of the sets $R_{n}$ for even $n$ is also a maximum independent set of $R_{\\text{even}} = \\bigcup_{n>0}R_{2n}$.\n\\end{theorem}\n\\begin{proof}\n The rectangles in this set are independent because a rectangle $r$ from the set $I_x\\subseteq R_x$ can't intersect any other rectangle in the set $I_x$ because if this were the case $I_x$ would not be an independent set. Furthermore the rectangle $r$ can't intersect any rectangle $r'\\in I_\\text{even}\\setminus I_x$ as $r$ and $r'$ both are intersected by a horizontal line with a vertical distance $2+\\varepsilon$ with $\\varepsilon>0$ and therefore the vertical distance between $r$ and $r'$ is at least $\\varepsilon$. As every independent set $I_x$ is the MIS of $R_x$ the combination $I_\\text{even}$ is also the MIS of $R_\\text{even}$. The same arguments apply to the set $I_\\text{odd}\\subseteq R_\\text{odd}$.\\\\\n\\end{proof}\nThe approximation quality guarantee follows from the fact that the MIS $I_\\text{OPT}$ of all the rectangles is at most $I_\\text{even} + I_\\text{odd}$. Therefore choosing the bigger of the sets $I_\\text{even}$ and $I_\\text{odd}$ leads to a $2$-approximation in the case that $|I_\\text{even}| = |I_\\text{odd}|$. If one of the sets has more elements than the other the approximation is even better. \n\\subsubsection{Runtime of $2$-approximation algorithm}\nThe runtime of the algorithm is dominated by the sorting of the rectangles which takes time \\bigo{n \\log n}. Partitioning the sorted rectangles with horizontal lines can be done in \\bigo{n} by iteratively taking the first (i.e.\\ having the smallest $y$-coordinate) not-yet-intersected rectangle and adding a line at it's upper $y$-coordinate. Finding the MIS of every set $R_i$ is also bounded by \\bigo{n\\log n} resulting from the sorting the rectangles in each of the sets of the partition. Selecting the rectangles for the independent sets $I_i$, combining the even and odd independent sets and comparing their sizes can all be done in \\bigo{n}.\n\n\\subsection{Improving to a $(1+\\nicefrac{1}{k})$-approximation algorithm}\nThe algorithm described before separates the rectangles into independent subproblems for which efficient algorithms exist. The idea from Agarwal et al. was to improve this method by increasing the size of these subproblems in a way that still ensures that they can be solved in polynomial time for some fixed $k$. In the $2$-approximation algorithm the MIS of $R_n$ for either even or odd $n$ were discarded completely. The idea of the improved algorithm is to partition the rectangles in the same way as before but to solve the MIS problem for sets of rectangles intersected by $k$ consecutive lines. Those sets are referred to as \\textit{subgroups} and are defined in the following way:\n\\begin{equation*}\nR_i^k = \\bigcup_{n = i}^{i+k-1}R_n.\n\\end{equation*}\nFor some value $k$ there are $k+1$ \\textit{groups} $G_1, \\ldots, G_{k+1}$ that correspond to the sets $R_\\text{odd}$ and $R_\\text{even}$\n\\begin{equation*}\nG_j = R_1^{j-1} \\cup \\bigcup_{i\\geq 0}R_{i(k+1)+j}^k  = R \\setminus \\bigcup_{i\\geq 0} R_{i(k+1)+j}.\n\\end{equation*}\nThe group $G_j$ is therefore the set of all rectangles $R$ except those intersected by every $(k+1)$-th line starting from the $j$-th line. Also all subgroups $R_i^k$ in $G_j$ are independent from each other, i.e.\\ there are no two rectangles in two different subgroups that intersect each other.\nComputing the MIS $I_i \\subseteq G_i$ for all $i\\in \\{1,\\ldots,k+1\\}$ and picking the biggest of those independent sets leads to a $(1+\\nicefrac{1}{k})$-approximate solution, %.\n%The idea behind this technique is the \\textit{shifting technique} introduced by Hochbaum and Maass~\\cite{shifting}.\n%\\begin{theorem}\nas for every $j$ the set $R\\setminus G_j$ contains rectangles intersected by at most $\\lceil \\nicefrac{m}{k+1}\\rceil$ lines %, computing the MIS for each $G_j$ and choosing the largest independent set yields a $(1+\\nicefrac{1}{k})$-approximate solution as%\n and therefore at most $\\nicefrac{|I_\\text{OPT}|}{k+1}$ rectangles can be missed due to the pigeon hole principle. \\\\\n \n To get the maximum independent set for the groups $G_i$ a dynamic programming scheme is used that exceeds the scope of this report. In Agarwal et al.~\\cite[Section 4.2]{agarwallabel} more details can be found.\n%\\end{theorem}\n%\\begin{proof}\n%The method seperates the rectangles into disjunct $k+1$ sets and takes the MIS of $k$ sets. If the biggest MIS obtained by this method does not adhere to the approximation guarantee the independent set of $R \\setminus G_j$ contains more than $\\nicefrac{|I_\\text{OPT}|}{k+1}$ rectangles. \n\n%Assume that the MIS of $G_j$ is bigger than the MIS of $G_i$ for all $i\\in \\{1,\\ldots,k+1\\}\\setminus j$. Furthermore assume that $I_i < I_\\text{OPT} - \\nicefrac{|I_\\text{OPT}|}{k+1}$, i.e. the size of the MIS does not adhere to the $(1+\\nicefrac{1}{k})$-approximation guarantee. If this is the case $I_j$ contains at least $ \\nicefrac{|I_\\text{OPT}|}{k+1}$ rectangles less than the optimal solution and the $k$ other $I_i$ omit even more. As all $I_i$ as well as $I_j$ omit rectangles from disjunct sets of rectangles \n%\\end{proof}\n\n\n\n%\\paragraph*{TEST}I'm citing stuff here\n%\\cite{chamaret}\n%\\cite{mcdiarmid}\n%\\cite{fonseca}\n%\\clearpage\n", "meta": {"hexsha": "6b88540a9859b385e97669aebfda982adfd64575", "size": 32481, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2016-04-13 - Geometric Independent Set/Report/content.tex", "max_stars_repo_name": "oerpli/Presentations", "max_stars_repo_head_hexsha": "1cf226f1b8c73d6e67e885f80e32c929b8420324", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-24T10:57:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-24T10:57:24.000Z", "max_issues_repo_path": "2016-04-13 - Geometric Independent Set/Report/content.tex", "max_issues_repo_name": "oerpli/Presentations", "max_issues_repo_head_hexsha": "1cf226f1b8c73d6e67e885f80e32c929b8420324", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2016-04-13 - Geometric Independent Set/Report/content.tex", "max_forks_repo_name": "oerpli/Presentations", "max_forks_repo_head_hexsha": "1cf226f1b8c73d6e67e885f80e32c929b8420324", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.4156479218, "max_line_length": 1002, "alphanum_fraction": 0.730180721, "num_tokens": 9878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.41955156343075906}}
{"text": "% chap2.tex\n\n\n\\chapter{Network Structure}\\label{chap:nwstruct}\n\nThis chapter discusses different type of networks in practice, their usage and prominent network architectures. We will discuss only few networks which have achieved significant success in recent times. Primarily we will discuss CNN(Convolutional Neural network) as that is the main network used through out this work.\n\n\\section{Networks}\nThe introduction to Neural network has started long ago with Frank Rosenblatt, famous MLP(Multi Layer Perceptron)\\cite{Rosenblatt58theperceptron:}.Working of neural nets today are precisely captured by Rosenblatt.\nIt talks about pathways to connect to output so that for particular input associated pathway gets activated and produces corresponding output.\nFollowing that several networks are suggested directed for specific tasks. For example for image to extract neighborhood relationship, convolution neural networks are suggested. For time series data Recurrent neural networks are suggested. LSTM is recent state of the art for handling time series tasks.\n\nAuto Encoders are suggested as unsupervised nets, which generates low level representation of inputs using only input data. \nRestricted boltzmann machines are another type of network which focuses on convergence by lowering the energy.\nIn Hopfield network every neuron connects to every other neuron in the network.\n\nOther types of networks are Radial Basis Network(RBN), Gated Recurrent Unit(GRU), Deep belief network(DBN), Generative adversial network(GAN).\n\n\n\\subsection{Perceptron}\nThe perceptron has been introduced to handle perceptual recognition, generalization and hence the name Perceptron. In this landmark paper Rosenblatt nicely maps the neurons development in human being to perceptron.\nFor instance connection of nervous system are assumed as random and in neural nets at start mostly random initializations are used.\nThe original system has said to be capable of plasticity, which allows other neuron output to change over time seeing stimulus applied. And if same or similar stimuli is seen large number of times, will tend to form pathways to same sets of responding cells. This almost sums up the current neural nets, however the network construction, random initializations may differ a lot. \nThe perceptron is shown in fig \\ref{fig:percep}\n\\begin{figure}[H]\n\t\\centering\n\t\\subfigure{\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{Images/perceptron}\n\t}\n\t\\caption{\\label{fig:percep} Perceptron}\n\t\\medskip\n\t\\small\n\t\\begin{flushleft}\n\t\t\\textit{Regarded as starting point of neural network evolution perceptron is simplest of neural networks. It has  no hidden layers, just inputs with weights and bias term added together with non linear transformation or activation function produces output. Perceptron was limited in their power due to their non-ability to handle non linear target functions, such as XOR.}\n\t\\end{flushleft}\n\t\n\\end{figure}\n\n\n\\subsection{CNN}\nCNN famously known as Convolutional Neural Network are revolutionary architecture which has provided significant results in many image based learning tasks. CNN takes advantage of neighborhood relationships between data and so image data is natural choice for these networks. see figure \\ref{fig:cnn}.\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\subfigure{\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{Images/cnn}\n\t}\n\t\\caption{\\label{fig:cnn} CNN}\n\t\\medskip\n\t\\small\n\t\\begin{flushleft}\n\t\t\\textit{CNN composition is shown in figure \\ref{fig:cnn}, This is most common network configuration, however there are many different variations suggested from time to time. CNN works well on data which is having neighborhood relationship such as image has spatial relationship between pixels. Input undergoes convolution to get low level representation with shared weights for the convolution. Generally convolution filter size is 3x3. Immediately after convolution layer there would be pooling layer, which reduces the data representation further. Deepness comes by repeating these layers. At last flatten layer reduces representation to number of classes which activates one of its neuron or provide the output probabilities of image belonging to output class vector.}\n\t\\end{flushleft}\n\t\n\\end{figure}\n\n\n\\subsection{RNN}\nRecurrent neural nets are having connections to same hidden layer neurons, and thus capable of storing time series data or feedback to be used with next set of input in sequence.\n\n\\begin{figure}[H]\n\\centering\n\\subfigure{\n\t\\centering\n\t\\includegraphics[scale=0.75]{Images/rnn}\n}\n\\caption{\\label{fig:rnn} RNN}\n\\medskip\n\\small\n\\begin{flushleft}\n\t\\textit{Recurrent neural network are useful in case of sequential data, where data at current instance is dependent on previous data instances. Most popular RNN models are language models, where it generates probabilities of existence of any sentence based on underlying language it trained with. Another important application of RNNs are generative models, where in given one word it generates next word. This is possible by RNN having feedback to same neuron or hidden layers. The feedback give this network immense power as unfolding this network it will act as several deep layers which is dependent on RNN ability to store previous information.}\n\\end{flushleft}\n\n\\end{figure}\n\n\n\\subsection{LSTM}\nLong Short Term Memory(LSTM) is one type of RNN network which uses LSTM cells.\n\n\\subsection{Auto Encoders}\nAuto encoders helps in learning representation by using input as output and just keep encoded layers and grow network as deep as possible. Auto encoder has delivered significant results for various tasks including image classification tasks. Auto encoder LSTM is variant of LSTM with Auto encoding capabilities.\n\n\n\n\n\n%\\renewcommand{\\baselinestretch}{\\spacing}\\normalsize\n\\doublespacing\\normalsize\n", "meta": {"hexsha": "f249dfe363cb71ed04d8d238ad0bc3fc98fa4136", "size": 5785, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/chap2.tex", "max_stars_repo_name": "gaurav-kjain/thesis_work", "max_stars_repo_head_hexsha": "a0c790b89af36d00bd020ff48db8b265ad02f3d7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/chap2.tex", "max_issues_repo_name": "gaurav-kjain/thesis_work", "max_issues_repo_head_hexsha": "a0c790b89af36d00bd020ff48db8b265ad02f3d7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/chap2.tex", "max_forks_repo_name": "gaurav-kjain/thesis_work", "max_forks_repo_head_hexsha": "a0c790b89af36d00bd020ff48db8b265ad02f3d7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.8804347826, "max_line_length": 773, "alphanum_fraction": 0.8117545376, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4195515564723299}}
{"text": "\\subsection{Outlier Detection}\n\\label{sec:outlier-detection}\n\nModels, once properly trained, are used for classification and detection of outliers -- either in incoming \\texttt{INSERT} operations on a running system, or in existing rows (possibly but not necessarily the ones used during the model training phase). % LATER: Citation about databases sizes?\n\nGiven that databases can contain tables with tens or hundreds of columns, simply flagging a row as an outlier is insufficient: users cannot be expected to painstakingly analyze each outlying row. Instead, \\dBoost/ automatically indicates which values in the row caused it to be flagged as an outlier.\n\nThe inter-column correlations are also taken into account during modeling: if the statistical analysis phase detected a correlation between two columns $a$ and $b$, each tuple $t$ will be augmented by an additional field that contains the corresponding pair $(t_a, t_b)$. This field is treated as a single, multidimensional value, and is analyzed similarly to the other values by the models.\n\nAs for statistical modeling, the heuristics that we employ for simple Gaussian and mixture modeling are not new; our contribution rests in the heuristics that we use for histograms (\\ref{sec:outlier-detection-histograms}), and in the description of \\emph{meta-modeling}.\n\n\\subsubsection{Histogram Modeling}\n\\label{sec:outlier-detection-histograms}\nThe histogram-based modeling strategy proceeds in two phases to detect outliers.\n\nFirst, after running through the learning phase, it decides for each histogram whether that histogram is ``peaked'' (i.e.\\ showing a few strong modes) enough to be used to detect outliers. The aim of this phase is to discard histograms where most bins have a similar number of values, and are thus not useful for outlier detection. In practice, we use a simple statistical test to determine whether a histogram is sufficiently modal: if the number of elements that fall into the most populated (``top'') bins is less than some user-specified proportion, the histogram is discarded. Finding how many bins to include in the set of top bins is the most challenging part, and for this paper we explored two thresholding strategies (Figure~\\ref{fig:peakiness}):\n\n\\begin{figure*}\n  \\centering\n  \\paddedgraphics{../../graphics/peakiness.pdf}\n  \\caption{Sample histograms, and corresponding decisions with distribution-dependent (\\(D\\)-independent) and distribution-independent (\\(D\\)-independent) thresholds. Each figure shows a sorted histogram, with the top bins hatched (in dotted green in the distribution-independent case, and in solid orange in the distribution-dependent case). The vertical arrows show the small value \\(r=3\\) in the distribution-dependent case. The weaknesses of the distribution-independent-model show in the third and fourth plots: in the third one the distribution-dependent strategy correctly rejects because of the small \\(r\\); in the fourth the distribution-independent strategy yields an incorrect threshold.}\n  \\label{fig:peakiness}\n\\end{figure*}\n\n\\begin{itemize}\n\\item \\emph{Distribution-independent} -- Given a histogram with $N$ bins, we count only the values in the top bin if $1 \\leq N \\leq 3$, in the top $2$ bins if $4 \\leq N \\leq 5$, and in the top $3$ bins for $3 \\leq N \\leq 16$ (histograms with $N > 16$ bins were previously discarded). This method is stable when the set of bins is static (week days, booleans, \\ldots), but it is sensitive to the addition of removal of bins.\n\\item \\emph{Distribution-dependent} -- We sort the bins in increasing order of bin size $b_i$, and find the index $i_{\\max}$ such that the ratio $r = \\sfrac{b_{i+1}}{b_{i}}$ is maximal (this calculation is safe, because the bin sizes are non-zero integers). If that ratio is under a user-defined threshold, we reject the histogram; otherwise, we consider bins $i_{\\max} .. \\texttt{end}$ to be ``top'' bins.\n\\end{itemize}\n\nFigure~\\ref{fig:peakiness} shows various types of histograms, and lists the conclusions that each of these two approaches yield.\n\nAfter identifying a relevant set of histograms (this operation only needs to run once, at the very beginning of the last pass), we proceed to the actual detection phase. We classify an expanded tuple $X$ as an outlier if any of its values (or set of values, as grouped according to the correlation hints previously obtained) $x_a$ verifies:\n\\begin{align}\nh_a(x_a) \\le \\epsilon \\sum_k h_a(k)\n\\label{eqn:hist-outlier}\n\\end{align}\nwhere $h_a(x)$ designates the number of tuples with value $x$ for field $a$, and $\\epsilon$ is a user-chosen sensitivity parameter.\n\nIn this model, identifying and reporting the outlying attributes is simply a matter of remembering which values $x_a$ failed test \\eqref{eqn:hist-outlier}.\n\n\n\\subsubsection{Simple Gaussian Modeling}\nThe simple Gaussian model measures how much each value differs from the mean computed in the preceding pass. Given a tolerance parameter $\\theta$, a row is deemed an outlier if at least one of its attributes $a$ has a value $v_a$ such that\n\\begin{align}\n  |v_a - \\mu_a| \\ge \\theta \\cdot \\sigma_a\n  \\label{eqn:gaussian-outlier}\n\\end{align}\nwhere $\\mu_a$ and $\\sigma_a$ are the model's parameters for column $a$, as described in Section~\\ref{sec:gaus_model}.\n\nIn this model, detecting which values are responsible for the outlier flag is simply a matter of keeping track of which attributes satisfy Equation~\\eqref{eqn:gaussian-outlier}. The simple Gaussian model does not take correlation hints into account, and thus reports only single-attribute outliers.\n\n\\subsubsection{Mixture Modeling}\nIn the Mixture model, the likelihood of each (possibly multidimensional) field is evaluated using the corresponding GMM\\. This model operates under the assumption that data is accurately modeled by the chosen number of components in the GMM, and in particular that each non-outlying data point is well modeled by one of the Gaussians of the GMM.\n\nThis makes it possible to assign a Gaussian component to each tuple, and then flag as outliers the tuples that are not sufficiently well explained by their corresponding Gaussian (see~\\cite{Roberts1999}). Given a tuple $t$ and its corresponding Gaussian $c$, this means rejecting $t$ if\n\n\\begin{align}\n  \\pi_c \\cdot \\Pr(\\textbf{dist}(t, \\mu_c) > d_0)  \\leq \\theta\n  \\label{eqn:mixture-outlier}\n\\end{align}\nwhere $\\theta$ is a user-defined parameter between 0 and 1, and $d_0$ is the Mahalanobis distance of $t$ to the Gaussian.\n \nAs in the Gaussian Model, providing the user with a list of attributes that caused the row to be flagged as an outlier is simply a matter of tracking correlations that satisfied equation~\\eqref{eqn:mixture-outlier}.\n\n\\subsubsection{Partition-based modeling}\nIn the partition-based case, outliers are detected by the underlying models. To classify a given expanded tuple, each group of correlated attributes is divided between a one-attribute key and a group sub-population attributes. This group of attributes is then passed to the underlying model corresponding to the given value of the key, and the whole original tuple is reported as an outlier if any of its groups of sub-population attributes is marked as such by the underlying models.\n", "meta": {"hexsha": "fb98e768019812fce7ed4b9a6565d8e9580e05c0", "size": 7219, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "raha/tools/dBoost/paper/icde/outlier-detection.tex", "max_stars_repo_name": "adrianlut/raha", "max_stars_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2019-07-05T12:03:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T07:44:58.000Z", "max_issues_repo_path": "raha/tools/dBoost/paper/icde/outlier-detection.tex", "max_issues_repo_name": "adrianlut/raha", "max_issues_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-08T11:19:03.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-08T11:19:03.000Z", "max_forks_repo_path": "raha/tools/dBoost/paper/icde/outlier-detection.tex", "max_forks_repo_name": "adrianlut/raha", "max_forks_repo_head_hexsha": "027ebeaf0ac4b524dc49df94e7bbc7be4391213d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2019-04-21T12:28:33.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T06:42:36.000Z", "avg_line_length": 107.7462686567, "max_line_length": 756, "alphanum_fraction": 0.783210971, "num_tokens": 1669, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4195515495139005}}
{"text": "\n\\documentclass[a4paper,11pt]{article}\n\n\\usepackage{physics}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm, mathtools}\n%\\usepackage{hyperref}\n\\usepackage{color}\n\\usepackage{jheppub}\n\\usepackage[T1]{fontenc} % if needed\n\n% My Documents\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n%\\linespread{1.0}\n%\\setlength{\\parindent}{0em}\n%\\setlength{\\parskip}{0.8em}\n\n\\title{\\textbf{Notes for BH Mimickers Project}}\n\\author{Aditya Vijaykumar}\n\\affiliation{International Centre for Theoretical Sciences, Bengaluru, India.}\n\\emailAdd{aditya.vijaykumar@icts.res.in}\n\n\\begin{document}\n\\maketitle\n\nThe basic aim is to ascertain whether the GWs detected by LIGO were really due to the coalescence of binary black holes. Put another way - we want to assume some simple models of these alternative objects, and constrain what the parameters of these models might be.\n\n\\section{Reviews}\n\n\\subsection{Notes on arXiv:1804.08026 - Constraining black hole mimickers with gravitational wave observations}\n\n\\begin{itemize}\n\t\\item A commonly considered alternative to Black Holes are Boson Stars (hereforth abbreviated as BS; no pun intended). BS are solutions of Einstein equations with the matter term containing a complex scalar field coupled to the metric. One can write the Einstein-Hilbert action describing the BS as follows,\n\t\\begin{equation*}\n\tS = \\int \\dd^4{x} \\sqrt{-g}\\qty[R - \\dfrac{1}{2} \\qty(g^{ab} \\partial_a \\phi \\partial_b \\phi   + V(\\abs{\\phi}^2))]\n\t\\end{equation*}\n\tThe scalar field gives the BS energy to gravitate. It is not exactly very straightforward why the BS should be stable, and what should balance the gravitation. The bottom line, though, is that one can think of scenarios where BS might be stable against gravitational collapse. \\textit{Living Reviews in Relativity} has what seems like a good summary of BS. \\footnote{\\text{https://link.springer.com/article/10.1007\\%2Fs41114-017-0007-y}} \\textit{Gravastars} are another proposed model for such compact objects.\n\t\n\t\\item One is not sure about what electromagnetic signatures such models can have, but one can have hope of detecting (or not detecting) these objects through Gravitational Waves. Such non-BH models will have tidal deformation due to the companion object, as well as deformations due to their own spin. These deformations would change the gravity around these objects, and hence the gravitational waves that are emitted from them. We can hope of detecting these deviations from Black Holes in the inspiral waveform.\n\t\n\tWe choose the inspiral because we think we understand the PN expansion very well. We essentially cut off our analysis before PN starts losing significance. One can't deal with the merger phase very well as full numerical simulations of these models are still at a very nascent stage. \\textcolor{red}{But can one deal with such objects in perturbation theory and obtain ringdown modes for such models?} \\footnote{https://journals.aps.org/prd/pdf/10.1103/PhysRevD.50.6235}\n\t\n\t\\item As opposed to the Fisher Matrix analysis used in other papers, this paper makes use of a full Bayesian method using the best GW waveforms. \\textcolor{red}{What are the problems with the Fisher Matrix analysis and why is this method better?}\n\t\n\t\\item The objects considered in this paper are nonspinning, perfect fluid stars described by a polytropic equation of state. We have,\n\t\\begin{equation*}\n\tp = K \\rho^{1 + 1/n} \\qq{and} \\rho = \\epsilon - n p\n\t\\end{equation*}\n\twhere $ p $ is the pressure, $ \\rho $ is the rest mass density, $ n $ is the polytropic index, $ \\epsilon $ is the energy density. For this analysis, we require the mass-radius relationship and the mass-tidal deformability relationship - these are the quantities that determine the contact frequency for such systems. \\textcolor{red}{Read up why this is so.} The waveforms can be modelled using the quadrupolar tidal deformability, but ascertaining the contact frequency requires higher multipolar moments. The stellar structure is computed by solving TOV and using existing expressions to find tidal deformabilities.\n\t\n\t\\item At the start of the inspiral, we can approximate the system as two-body point particle motion, but as we proceed towards the late inspiral, the tidal effects will become important and the PN expansion will be rendered untrustworthy. To account for the tidal effects, we add tidal corrections to the IMRPhenomD waveforms \\textcolor{red}{How do I access the IMRPhenomD waveforms? Also, what is the idea behind phenomenological waveforms, and what are its shortcomings?} at some order in the expansion. \\textcolor{red}{How do we figure out the order? Naive guess would be that doing a PN-like expansion for these tidally deformed systems would give us valid corrections only at some specific order, and hence we take that.} Even after this, due to the approximations that we have made, we cannot expect the waveform to be valid when the objects come into contact. Hence, we cut off our analysis at that point. We take this point to be the frequency at the first instance when one of the stars has $ \\lambda = 0.2 $ \\textcolor{red}{Why this number and not any number? Is there any calculation which shows that this is a reasonable approximation to make?}, and call it the \\textit{contact frequency}.\n\t\n\t\\item The rest of the paper is mostly technicalities of the data analysis. Plots are drawn of the combined posteriors $ \\Lambda $ and $ n $. \\textcolor{red}{The nitty gritties of the data analysis is something that I don't understand well, and something I need to figure out soon.} And a certain class of models with $ K, n $ are ruled out. The interesting thing is that the authors claim that \\textit{boson stars can approximately thought to be like polytropic stars} by looking at the $ \\Lambda $ vs $ n $ curves, and hence we can constrain the potentials of these boson stars. \\textcolor{red}{But really, is that a fair enough argument? Isn't there a way to be more precise?} We then assume of $ \\phi^4 $ potential and translate the constraints obtained from polytropic stars to constraints on $ m_B, \\lambda_B $ in the $ \\phi^4 $ potential. \n\t\n\t\\item The authors say they want to extend the current work to include gravastar models as also to the spinning case. \\textcolor{red}{What exactly are the complications in doing the same?}\n\\end{itemize}\n\\end{document}", "meta": {"hexsha": "6c3f78a2f08065d803747f805896453a6c616d83", "size": 6533, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "BHmimickers/BHmimickers_notes.tex", "max_stars_repo_name": "adivijaykumar/papers", "max_stars_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "BHmimickers/BHmimickers_notes.tex", "max_issues_repo_name": "adivijaykumar/papers", "max_issues_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "BHmimickers/BHmimickers_notes.tex", "max_forks_repo_name": "adivijaykumar/papers", "max_forks_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 98.9848484848, "max_line_length": 1202, "alphanum_fraction": 0.7795805908, "num_tokens": 1625, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4195490442134738}}
{"text": "\\begin{table*}[!htb]\n\\small\n\\centering\n \\begin{tabular}{|p{7cm}|p{3cm}|p{1.5cm}|p{1.5cm}|}\n \\hline\nModel weights & Decay type & Top-1 Acc & Top-5 Acc\\\\\\hline\\hline\nalexnet: 1.0,\ninception: 1.0\nresnet: 1.0 & exponential & 0.5323 & 0.8203 \\\\\\hline\nalexnet: 0.7,\ninception: 1.0,\nresnet: 1.0 & exponential & 0.5318 & 0.8177 \\\\\\hline\nalexnet: 0.7,\ninception: 0.7,\nresnet: 1.0 & exponential & 0.531 & 0.8177 \\\\\\hline\nalexnet: 0.7,\ninception: 1.0,\nresnet: 0.7 & exponential & 0.5268 & 0.8169 \\\\\\hline\nalexnet: 0.7,\ninception: 1.0,\nresnet: 1.0 & linear & 0.5202 & 0.8165 \\\\\\hline\nalexnet: 1.0,\ninception: 1.0,\nresnet: 0.7 & exponential & 0.5282 & 0.8151 \\\\\\hline\nalexnet: 0.7,\ninception: 1.0,\nresnet: 0.7 & linear & 0.5191 & 0.8142 \\\\\\hline\nalexnet: 1.0,\ninception: 0.7,\nresnet: 1.0 & exponential & 0.5199 & 0.8141 \\\\\\hline\nalexnet: 1.0,\ninception: 1.0,\nresnet: 1.0 & linear & 0.5218 & 0.8140 \\\\\\hline\nalexnet: 1.0,\ninception: 0.7,\nresnet: 0.7 & linear & 0.5279 & 0.8136 \\\\\\hline\n\\end{tabular}\n\\caption{Top 10 bagging ensemble configurations, as ranked by top-5 accuracy over validation set.}\n\\label{tab:top10_configs}\n\\end{table*}\n\n\\subsection{Grid Search Hyperparameters}\n\nWe use grid search to explore the space of hyperparameter values that yield the best top-5 accuracy over validation set. Hyperparameters on the search space are:\\\\\n\n\\noindent {\\bf Model weights.} We define a 'model weight' as the weight for each model in the weighted majority bagging ensemble prediction. This value ranges from 0.0 to 1.0 for each model.  After initially experimenting with varying model contributions in increments of 0.25, we found no gains in validation accuracy for any configuration where weight was less than 0.7.  Therefore, for our final grid search we use either 0.0, 0.7 or 1.0 as the weight for each model in the bagging ensemble.\\\\\n\n\\noindent {\\bf Decay function.} We define 'decay function' as the function over the prediction ranks of each model. We consider three different decay functions:\n\n$$\\text{Constant: } D(r,k) \\begin{cases}\n               1.0 \\text{ if } r < k\\\\\n               0.0 \\text{ otherwise}\n            \\end{cases}$$\n\n$$\\text{Linear: } D(r) = |\\text{prediction\\_classes}| - r$$\n\n$$\\text{Exponential: } D(r) = e^{\\frac{-r}{5}}$$\n \nwhere $r$ is the prediction rank and in the case of ``Constant'', $k$ is a rank cutoff, e.g., $k = 5$ if only the first 5 predictions of that model are considered for the weighted majority vote.  We use two variations of constant decay function, one where $k = 5$, and another where $k = 10$. In our experiments, we find that the best results are obtained when the decay function is either exponential, or constant with $k = 5$.\\\\\n\n\\noindent {\\bf Class-wise confidence.} As described in Section~\\ref{ss:ensembling}, we also consider an heuristic that takes into account the class-wise confidence as calculated over the training set.  This adds a total of four permutations per configuration, as both top-1 and top-5 class-wise confidence is considered.\\\\\n\n\\noindent {\\bf Class-wise accuracy.} The final heuristic we include as part of the grid search space is class-wise accuracy, defined in Section~\\ref{ss:ensembling}.  Similar to class-wise confidence, this hyperparameter too adds four permutations per configuration to the total search space we explore with grid search.\\\\\n\nAn example configuration for the grid search space, together with its top-1 and top-5 accuracy over validation set is given in Figure ~\\ref{fig:gs_config}.  In Table~\\ref{tab:top10_configs} we display the 10 best configurations found by our grid search over the hyperparameters described above. Other configurations and their accuracies over validation set are included in the accompanying source code, under \\texttt{weighted\\_majority/grid\\_search\\_results.txt}.\n\n\\subsection{Ensemble Weight}\n\nThe ensemble value of a single class prediction for an image is given by the formula:\n\n$$E(p,r) = \\sum_{n=1}^{|models|} w_n * c_p * a_p * d(r)$$\n\nwhere $p$ is the prediction class, $r$ is the rank of that class as given by CNN model $n$, $w_n$ is the weight (for majority vote) assigned to that model, $c_p$ is the class-wise confidence score for prediction class $p$, $a_p$ is the class-wise accuracy for prediction class $p$, and $d$ is the contribution of rank $r$ after decay function is applied.\n\nFor example, given the grid search configuration in Figure~\\ref{fig:gs_config}, $c_p$ would be set to 1.0 since class-wise confidence scores are disabled, and $a_p$ would also be set to 1.0 for a similar reason. Further, $d(r)$ would be the result of applying the ``Constant'' decay function with $k = 5$, yielding 0.0 if $r > 5$, and $w_n$ would be 1.0 regardless of model (AlexNet, ResNet, or Inception).  So in this case, the final ensemble value for class $p$ is equal to the weighted majority of the three different CNNs, with equal weight assigned to each.\n\n\\begin{figure}[!ht]\n\\verbatiminput{grid_search_config.txt}\n\\caption{Example configuration explored by grid search, together with resulting top-1 and top-5 accuracy over validation set.}\n\\label{fig:gs_config}\n\\end{figure}\n\n\\subsection{Best Performing CNN Ensembles}\n\nTable~\\ref{tab:top10_configs} shows the top 10 configurations, as ranked by top-5 accuracy over validation set.  Our grid search also explores configurations where class accuracies and class confidence scores for both top-1 and top-5 -- as defined in Section~\\ref{ss:ensembling} -- are considered.  We find, however, that the configurations with highest top-5 accuracy over validation set are obtained when neither of these heuristics are considered.  In addition, our experimental results indicate highest top-5 accuracy over validation set is obtained when all models have similar weights, i.e., the simple weighted majority case.", "meta": {"hexsha": "1a167958ec529e22ad60577e429bda6da3167a10", "size": 5786, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/grid_search.tex", "max_stars_repo_name": "jmftrindade/miniplaces_challenge", "max_stars_repo_head_hexsha": "9325e814571000633e233433006b4e913194a34e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-18T18:31:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-27T09:14:02.000Z", "max_issues_repo_path": "report/grid_search.tex", "max_issues_repo_name": "jmftrindade/miniplaces_challenge", "max_issues_repo_head_hexsha": "9325e814571000633e233433006b4e913194a34e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/grid_search.tex", "max_forks_repo_name": "jmftrindade/miniplaces_challenge", "max_forks_repo_head_hexsha": "9325e814571000633e233433006b4e913194a34e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.0705882353, "max_line_length": 632, "alphanum_fraction": 0.7405807121, "num_tokens": 1683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.4195490359399744}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{latexsym,amsfonts,amssymb,amsthm,amsmath,mathrsfs,mathtools}\n\\usepackage[makeroom]{cancel}\n\\usepackage {tikz}\n\\usepackage{hyperref}\n\\usetikzlibrary {positioning}\n\\usepackage{fdsymbol}\n\n\\usepackage[ruled,vlined]{algorithm2e}\n\n\\setlength{\\parindent}{0in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\textheight}{8.8in}\n\\setlength{\\topmargin}{-0.7in}\n\\setlength{\\headheight}{18pt}\n\n\\newcommand*{\\union}{\\cup}\n\\newcommand*{\\inter}{\\cap}\n\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\n\\definecolor {processblue}{cmyk}{0.96,0,0,0}\n\n\\makeatletter\n\n\\makeatother\n\n\\title{Topics in Algorithms - Assignment 2}\n\\author{Kishlaya Jaiswal}\n\n\\begin{document}\n\n\\maketitle\n\nFollowing are the exercises from \\href{http://math.mit.edu/~goemans/18453S17/matching-nonbip-notes.pdf}{http://math.mit.edu/~goemans/18453S17/matching-nonbip-notes.pdf}\n\n\\subsection*{Exercise 2.1}\n\nConsider the following graph:\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (G_1) at (9,0)  {1};\n  \\node[vertex] (G_2) at (6,0)  {2};\n  \\node[vertex] (G_3) at (3,0) {3};\n  \\node[vertex] (G_4) at (0.927,2.853)   {4};\n  \\node[vertex] (G_5) at (-2.427,1.763)  {5};\n  \\node[vertex] (G_6) at (-2.427,-1.763)  {6};\n  \\node[vertex] (G_7) at (0.927,-2.853)  {7};\n  \\node[vertex] (G_8) at (0.927,5.853)   {8};\n  \\node[vertex] (G_9) at (-5.427,1.763)  {9};\n  \\node[vertex] (G_10) at (-5.427,-1.763)  {10};\n  \\node[vertex] (G_11) at (0.927,-5.853)  {11};\n\n  \\draw (G_1) -- (G_2) -- cycle;\n  \\draw[ultra thick, red] (G_2) -- (G_3) -- cycle;\n  \\draw (G_3) -- (G_4) -- cycle;\n  \\draw[ultra thick, red] (G_4) -- (G_5) -- cycle;\n  \\draw (G_5) -- (G_6) -- cycle;\n  \\draw[ultra thick, red] (G_6) -- (G_7) -- cycle;\n  \\draw (G_7) -- (G_3) -- cycle;\n  \\draw (G_4) -- (G_8) -- cycle;\n  \\draw (G_5) -- (G_9) -- cycle;\n  \\draw (G_6) -- (G_10) -- cycle;\n  \\draw (G_7) -- (G_11) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\nWhen we shrink the blossom, we would get\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (G_1) at (6,0)  {1};\n  \\node[vertex] (G_2) at (3,0)  {2};\n  \\node[vertex] (G_3) at (0,0) {3};\n  \\node[vertex] (G_8) at (0,3)   {8};\n  \\node[vertex] (G_9) at (-3.427,1.763)  {9};\n  \\node[vertex] (G_10) at (-3.427,-1.763)  {10};\n  \\node[vertex] (G_11) at (0,-3)  {11};\n\n  \\draw (G_1) -- (G_2) -- cycle;\n  \\draw[ultra thick, red] (G_2) -- (G_3) -- cycle;\n  \\draw (G_3) -- (G_8) -- cycle;\n  \\draw (G_3) -- (G_9) -- cycle;\n  \\draw (G_3) -- (G_10) -- cycle;\n  \\draw (G_3) -- (G_11) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\nAn augmenting path in the graph $G/B$ is: $1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 11$, which gives the following maximum matching $M^*/B$ in $G/B$\n\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (G_1) at (6,0)  {1};\n  \\node[vertex] (G_2) at (3,0)  {2};\n  \\node[vertex] (G_3) at (0,0) {3};\n  \\node[vertex] (G_8) at (0,3)   {8};\n  \\node[vertex] (G_9) at (-3.427,1.763)  {9};\n  \\node[vertex] (G_10) at (-3.427,-1.763)  {10};\n  \\node[vertex] (G_11) at (0,-3)  {11};\n\n  \\draw[ultra thick, red] (G_1) -- (G_2) -- cycle;\n  \\draw (G_2) -- (G_3) -- cycle;\n  \\draw (G_3) -- (G_8) -- cycle;\n  \\draw (G_3) -- (G_9) -- cycle;\n  \\draw (G_3) -- (G_10) -- cycle;\n  \\draw[ultra thick, red] (G_3) -- (G_11) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\nBut this leads to the augmenting path $1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5 \\rightarrow 6 \\rightarrow 7 \\rightarrow 11$ in $G$ and gives the following matching $M^*$ (which is not a maximum matching):\n\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (G_1) at (9,0)  {1};\n  \\node[vertex] (G_2) at (6,0)  {2};\n  \\node[vertex] (G_3) at (3,0) {3};\n  \\node[vertex] (G_4) at (0.927,2.853)   {4};\n  \\node[vertex] (G_5) at (-2.427,1.763)  {5};\n  \\node[vertex] (G_6) at (-2.427,-1.763)  {6};\n  \\node[vertex] (G_7) at (0.927,-2.853)  {7};\n  \\node[vertex] (G_8) at (0.927,5.853)   {8};\n  \\node[vertex] (G_9) at (-5.427,1.763)  {9};\n  \\node[vertex] (G_10) at (-5.427,-1.763)  {10};\n  \\node[vertex] (G_11) at (0.927,-5.853)  {11};\n\n  \\draw[ultra thick, red] (G_1) -- (G_2) -- cycle;\n  \\draw (G_2) -- (G_3) -- cycle;\n  \\draw[ultra thick, red] (G_3) -- (G_4) -- cycle;\n  \\draw (G_4) -- (G_5) -- cycle;\n  \\draw[ultra thick, red] (G_5) -- (G_6) -- cycle;\n  \\draw (G_6) -- (G_7) -- cycle;\n  \\draw (G_7) -- (G_3) -- cycle;\n  \\draw (G_4) -- (G_8) -- cycle;\n  \\draw (G_5) -- (G_9) -- cycle;\n  \\draw (G_6) -- (G_10) -- cycle;\n  \\draw[ultra thick, red] (G_7) -- (G_11) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\nThis does not contradict theorem $2.2$ because if $M^*$ were to be a maximum matching in $G$, then the theorem says: \\textsl{Let $B$ be a blossom with respect to $M^*$ . Then $M^*$ is a maximum size matching in $G$ if and only if $M^*/B$ is a maximum size matching in $G/B$}. Notice that $B$ was a blossom with respect to initial matching $M$ and not $M^*$ and hence the hypothesis of the theorem is not satisfied.\n\n\\subsection*{Exercise 2.2}\n\nRecall \\textbf{Berge's lemma}: a matching $M$ in a graph $G$ is maximum if and only if there is no augmenting path wrt $M$ in $G$.\n\nFurther note that if a matching matches the vertices in $S$, then augmenting this matching along any augmenting path will still keep the vertices in $S$ matched.\n\nTherefore, suppose a matching $M$ covers $S$; if $M$ is already maximum then we are done. Otherwise, by Berge's lemma there is an augmenting path wrt to $M$. Augment along this path to get a new matching $M'$. Then $|M'| > |M|$ and $M'$ also covers $S$. Thus, repeating this $O(|V|)$ times, we get a maximum matching $M^*$ which covers $S$.\n\n\\subsection*{Exercise 2.3}\n\n\\subsubsection*{(a)}\nBy Tutte's theorem, given any maximum matching $M$, we have\n$$|M| = |U| + \\sum_{i=1}^k \\floor*{\\frac{|K_i|}{2}} = \\frac{1}{2}\\left(|V| + |U| - o(G \\setminus U)\\right) (\\spadesuit)$$\n\nAnd after removing $U$, any maximum matching can $M$ can use atmost $k_i = \\floor*{\\frac{|K_i|}{2}}$ many edges from $K_i$, therefore it is certain that $M$ uses atmost $k_i$ edges from $G[K_i]$. If it uses strictly less than $k_i$ edges from $G[K_i]$ then note that size of $M$ is also strictly less than $|U| + \\sum_{i=1}^k \\floor*{\\frac{|K_i|}{2}}$ which is a contradiction to $(\\spadesuit)$.\n\nHence the vertices in $G[K_i]$ with even $|K_i|$ are perfectly matched whereas with odd $|K_i|$ are perfectly matched except for one vertex.\n\n\\subsubsection*{(b)}\nFirst, suppose some vertex in $u \\in U$ remains unmatched in $M$. Then even if we remove this vertex $u$ from the graph, the number of odd components after removing $U \\setminus \\{u\\}$ remains unchanged, so for the new graph thus obtained, we have the following inequality:\n$$|M| \\leq \\frac{1}{2}((|V|-1) + (|U|-1) - o(G \\setminus U)) = \\frac{1}{2}(|V| + |U| - o(G \\setminus U)) - 1$$\nwhich is again a contradiction to $(\\spadesuit)$.\n\nNow suppose that $u$ is matched to a vertex in $v \\in U$. Then if we remove the vertices $\\{u,v\\}$ from the graph, then the number of odd components after removing $U \\setminus \\{u,v\\}$ remains unchanged and also the size of $M$ decreases by $1$, so for the new graph thus obtained, we have the following inequality:\n$$|M|-1 \\leq \\frac{1}{2}((|V|-2) + (|U|-2) - o(G \\setminus U)) = \\frac{1}{2}(|V| + |U| - o(G \\setminus U)) - 2$$\nwhich is again a contradiction to $(\\spadesuit)$.\n\nThus, each vertex $u \\in U$ is matched to a vertex not in $U$ but since all the vertices in even components are matched among themselves, the only possibility is that $u$ is matched to a vertex in some odd component $K_i$.\n\n\\subsubsection*{(c)}\nFrom the above two results, we get that\n\\begin{itemize}\n    \\item Every vertex in $U$ is matched\n    \\item Every vertex in an even component $K_i$ is matched\n\\end{itemize}\nTherefore, if some $v \\in V$ is unmatched, then it has to belong to some odd component $K_i$.\n\n\\subsection*{Exercise 2.4}\n\nYes there could be several minimizers in the Tutte Berge formula. A simple example is that of two vertices joined by a single edge, in which case maximum matching is of size $1$ and we could choose $U$ to be either of the vertices to get $1 = \\frac{1}{2}(2 + 1 - 1)$.\n\nAnother example with different sizes of $U$: Both $U=\\phi$ and $U = \\{v\\}$ give $2 = \\frac{1}{2}(5 + 0 - 1) = \\frac{1}{2}(5 + 1 - 2)$ in the given graph below:\n\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 ,\ndraw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (G_1) at (8,0) {};\n  \\node[vertex] (G_2) at (5,0)  {v};\n  \\node[vertex] (G_3) at (2,0) {};\n  \\node[vertex] (G_4) at (-0.8,1.5) {};\n  \\node[vertex] (G_5) at (-0.8,-1.5) {};\n\n  \\draw (G_1) -- (G_2) -- cycle;\n  \\draw (G_2) -- (G_3) -- cycle;\n  \\draw (G_3) -- (G_4) -- cycle;\n  \\draw (G_4) -- (G_5) -- cycle;\n  \\draw (G_5) -- (G_3) -- cycle;\n\\end{tikzpicture}\n\\end{center}\n\n\n\\subsection*{Exercise 2.5}\n\nFor a graph $G$ and $S \\subseteq V(G)$, define \\textsl{deficiency of S} $def(S) = o(G \\setminus S) - |S|$. And $def(G) = \\max_{S \\subseteq V} def(S)$.\n\nTherefore, Tutte-Berge formula now translates to: for any maximum matching $M$, $|M| = \\frac{1}{2}(|V| - def(G))$\n\\newline\n\n\\textbf{Parity Lemma} Let $|V| = n$ and $S \\subseteq V$, then $def(S) \\equiv n (\\mod 2)$\n\\begin{proof}\nCounting vertices in $S$ and the components in $G \\setminus S$, we have $|S| + o(G \\setminus S) \\equiv n (\\mod 2)$.\n\\end{proof}\n\n\\textbf{Lemma 2} Let $T$ be a maximal set of maximum deficiency in a graph $G$. Then every component of $G \\setminus T$ is odd and factor-critical.\n\\begin{proof}\nLet $C$ be any component of $G \\setminus T$ and $u \\in C$, then $\\forall S \\subseteq C-u$, we have\n\\begin{align*}\n    def_G(T \\union u \\union S) &= o(G-T-u-S) - (|T|+1+|S|) \\\\\n    &= (o(G \\setminus T) - 1 + o(C-u-S)) - (|T|+1+|S|) \\\\\n    &= o(G \\setminus T) - |T| + o(C-u-S) - |S| - 2 \\\\\n    &= def_G(T) + def_{C-u}(S) - 2 \\\\\n    \\implies def_{C-u}(S) &= def_G(T \\union u \\union S) - def_G(T) + 2\n\\end{align*}\nBy our choice of $T$, $def_G(T \\union u \\union S) < def_G(T)$ and by Parity lemma, $def_G(T \\union u \\union S)$ and $def_G(T)$ have same parity. Thus $def_{C-u}(S) \\leq 0$, $\\forall S \\subseteq C-u$ and hence $C-u$ has a perfect matching (Tutte's theorem) and so $C$ is critical. It follows that $C$ is of odd-size.\n\n(Alternatively, if $C$ is a component of even size, then adding to $T$ any leaf of a spanning tree of $C$ creates a larger set with the same deficiency as $T$ which contradicts the choice of $T$. And hence all components are odd).\n\\end{proof}\n\nNext for any $T \\subseteq V$, we define auxillary bipartite graph $H(T)$ by contracting each component of $G \\setminus T$ to a single vertex and deleting edges within $T$. Let $U$ denote the set of contracted vertices of components then $H(T)$ is a $(T,U)$ bipartite graph with an edge $t-u$ for $t \\in T, u \\in U$ iff $t$ has a neighbour in G in the component of $G \\setminus T$ corresponding to $u$.\n\\newline\n\n\\textbf{Lemma 3} If $T$ is a maximal set of maximum deficiency in a graph $G$. then $H(T)$ contains a matching that covers $T$.\n\n\\begin{proof}\nFor $S \\subseteq T$ , all vertices of $U - N_{H(T)}(S)$ are odd components of $G \\setminus (T \\setminus S)$. By the choice of $T$ , we have $(|U|-|N_{H}(S)|) - |T \\setminus S| \\leq def(T \\setminus S) \\leq def(T)$. Since $def(T) = |U| - |T|$,\nthe inequality simplifies to $|S| \\leq |N_H(S)|$. Thus Hall’s Condition holds, and $H(T)$ has a matching that covers $T$.\n\\end{proof}\n\nNow let $T$ be a maximal set of deficiency $def(G)$. If we show that $def(C) = def(T)$, then for any maximum matching $M$:\n$$|M| = \\frac{1}{2}(n-def(G)) = \\frac{1}{2}(n-def(C)) = \\frac{1}{2}(|V|+|C|-o(G \\setminus C))$$\nand hence $C$ is a minimizer in the Tutte-Berge formula.\n\nWe begin by noting that $T$ is a minimizer of the Tutte-Berge formula and so $2|M| = n - def(G)$ implies that exactly $def(G)$ vertices are not covered by $M$. Furthermore. we have proved in exercise $2.3$ that $M$ matches each vertex of $T$ with a distinct component of $G \\setminus T$ (which are all odd - lemma 2) and also since $M$ is maximum and each of these components is factor-critical (lemma 2), $M$ matches each of these components near-perfectly.\n\nNow consider the bipartite-graph $H(T)$. By lemma 3, there is a $T$-saturating matching and therefore Hall's theorem says $|N_{H(T)}(S)| \\geq |S|$, $\\forall S \\subseteq T$. Because $|N_{H(T)}(\\phi)| = |\\phi|$, we consider a maximal subset $R$ for which the equality is achieved in Hall's condition, so $|N_{H(T)}(R)| = |R|$. Let $R'$ be the union of all vertices of the components of $N_{H(T)}(R)$.\n\\newline\n\n\\begin{figure}[htp]\n    \\centering\n    \\includegraphics[width=12cm]{gallai.jpg}\n    \\caption{Gallai Decomposition}\n    \\label{fig:gallai}\n\\end{figure}\n\n\\textbf{Claim} $D = R \\union R'$, $C = T \\setminus R$ and $B = V \\setminus (T \\union R')$.\n\\begin{proof}\nWe observe that $D$ is defined to be the set of \\textsl{essential} vertices which doesn't have any neighbours in \\textsl{inessential} vertices. We show that the same property holds for $R \\union R'$ as well. Since every maximum matching $M$ matches $T$, and hence $R$, we conclude that $R$ is a subset of essential vertices and so is $R'$ as any maximum matching matches $R$ to distinct components of $G[R']$. Furthermore, both $R$ and $R'$ don't have neighbour in other components of $G \\setminus T$, that is $R \\union R'$ doesn't have a neighbours in \\textsl{inessential} vertices (as $T$ only consists of essential vertices). Therefore, $D = R \\union R'$.\n\nLet $H' = H(T) - (R \\union N_{H(T)}(R))$. For any $S \\subset T \\setminus R$, we have $|N_{H(T)}(S)| > |S|$ (because if there was equality for some set, then we could have added it to $R$ thereby contradicting its maximality). This means even if we delete a vertex $v$ from $N_{H'}(T \\setminus R)$, Hall's condition still holds and so it has a $T \\setminus R$ saturating matching, which omits $v$. This tells us all vertices of $V \\setminus (T \\union R')$ are inessential. This can be seen as follows: fix a vertex $x \\in V \\setminus (T \\union R')$. Let $C$ be the component to which it belongs. By lemma 2, $C$ is factor-critical. So if we delete $x$, then we can find a perfect matching in $C - x$. So we delete this component $C$ and note that it corresponds to deleting a vertex $v \\in N_{H'}(T \\setminus R)$ which has a maximum matching already.\n\nTherefore, we get that $V \\setminus (T \\union R') \\subseteq B$ but note that $T$ only consists of essential vertices. And so $B = V \\setminus (T \\union R')$ which implies $C = T \\setminus R$.\n\\end{proof}\n\nFinally we have $def(T) = o(G \\setminus T) - |T| = (o(G[R']) + o(G[B])) - (|R| + |C|) = (|R| + o(G[B])) - (|R| + |C|) = o(G[B])-|C|$. Since $G[D]$ has a perfect matching, all it's components are even in size. Therefore the only odd components of $o(G \\setminus C) = o(G[B])$. Thus, $def(T) = o(G \\setminus C) - |C| = def(C)$.\n\n\\subsection*{Exercise 2.7}\n\n\\subsubsection*{(1)}\n\nFix any minimizer $U$. Let $u \\in U$ if possible. Since $G$ is factor critical, there is maximum (perfect) matching which leaves $u$ unmatched, which contradicts $2,3(b) -$  any maximum matching $M$ covers $U$.\n\nTherefore, $U = \\phi$\n\n\\subsubsection*{(3a)}\n\nWe prove by induction on number of ears that if $G$ has an odd ear decomposition then $G$ is factor-critical.\n\n\\textsl{Inductive hypothesis}: Given $G$ with $n-$odd ear decomposition $(n \\geq 0)$ then $G$ is factor critical\n\n\\textbf{Base case}: $n=0$. This means that $G$ is just an odd cycle. Then it is clear if we remove any vertex $v$, then we are left with an odd-length path, which has a perfect matching.\n\nSuppose it is true for some $n \\geq 0$. Consider $G$ with $(n+1)$ odd ears. Now we remove a vertex $v$ from $G$. Let the last year be $v_0 - v_1 - \\cdots - v_{2k+1}$, then we have two cases:\n\\begin{itemize}\n  \\item \\textsl{$v$ belongs internally to the last year}. that is $v \\in \\{v_1, \\ldots, v_{2k}\\}$, then note that after removing this vertex, we will left with an odd path and an even path in the last year. WLOG say that $v_0 - \\cdots - v_{i-1}$ is an even-length path and $v_{i+1} - \\cdots - v_{2k}$ is an odd-length path. Then we can add edges $(v_1,v_2), (v_3,v_4), \\ldots$ to our matching. Furthermore, we can also add $(v_{2k}, v_{2k-1}), (v_{2k-2}, v_{2k-3}), \\ldots$ to our matching but this will remove the vertex $v_{2k}$ from the second-last ear. Now consider the graph with only the first $n$ ears, with the vertex $v_{2k}$ removed. By inductive hypothesis this has a perfect matching. Hence combing with the above mentioned edges, we get a perfect matching for $G$ with $v$ removed.\n  \n  \\item \\textsl{$v$ doesn't belong internally to the last year}. In this case, we consider the graph with the last year $(v_1, \\ldots, v_{2k})$ removed. Now when we remove the vertex $v$ then this graph has $n$ ears with one vertex removed, which has a perfect matching by inductive hypothesis. And since $v_1 - \\cdots - v_{2k}$ is an odd-length path, it admits a perfect matching. Hence combining these two matchings we get a perfect matching for the entire graph with $v$ removed.\n\\end{itemize}\n\n\\subsubsection*{(3b)}\n\nSuppose $G$ is factor critical. We want to show that $G$ has an odd-ear decomposition. \n\nWe claim that $G$ must be connected. Suppose not, then let $K$ be any connected-component such that $G \\setminus K \\neq \\phi$. We first note $K$ cannot be even-sized connected-component, because $K \\setminus \\{v\\}$ for any $v \\in K$ doesn't admit a perfect matching. So $K$ is an odd-sized component but then choose $v \\in G \\setminus K$, and so $G \\setminus \\{v\\}$ has a perfect matching which leads to a contradiction as $K$ (being odd in size) cannot admit a perfect matching.\n\nTo proceed with our main proof, we shall use structural induction on $G$.\n\nDenote by $M_v$ the perfect matching obtained after removing $v$ from $G$. Consider any edge $(u,v)$ in $G$ and consider $M_u \\oplus M_v$. It contains an alternating even-length path between $u$ and $v$. Thus alongwith the $(u,v)$ edge, we get an odd cycle in $G$. If $G$ is exactly equal to this odd cycle obtained then we are done (odd ear decomposition with $0$ ears). \n\nOtherwise, we fix a vertex $v$ of this odd cycle. Suppose we have already found $k$ ears so far. Let $H$ be the subgraph induced by this odd cycle and $k$ ears. We shall also assume that no edge in $M_v$ crosses $H$ (and we will maintain this invariant in our inductive step).\n\nSince $G$ was connected, there exists an edge $(a,b)$ crossing $H$ such that $a \\in H$ and $b \\not \\in H$. By our above assumption $(a,b) \\not \\in M_v$. Now $M_b \\oplus M_v$ contains an even-length alternating path from $b$ to $v$. This path crosses $H$ because $v \\in H$ and $b \\not \\in H$, so let $(x,y)$ be the first edge on this path which crosses $H$ (where $x \\not \\in H, y \\in H$). Again by our assumption $(x,y) \\not \\in M_v$. Now we note this $b \\longrightarrow x$ subpath will be of odd-length. Hence the path $a \\rightarrow b \\longrightarrow x \\rightarrow y$ is an odd length path whose internal vertices do not lie in $H$ and hence we have found a new odd-ear to be added to $H$ and we are done.\n\n(It should be noted that there the invariant \"no edge in $M_v$ crosses $H$\" is still maintained because any other edge incident on this new ear cannot be from $M_v$ as this ear itself alternates between edges from $M_v$ and $M_b$. And this same reasoning applies in the base case as well).\n\n\n\\subsubsection*{(2)}\n\nWe shall use the notation and algorithm introduced in the given paper.\n\nNote that we already showed that any factor-critical graph $G$ must be connected (in part $(3b)$). And next note that if $G$ is connected then after shrinking a blossom also, $G'$ remains connected ($\\vardiamondsuit$).\n\nAnother observation that follows from the previous part $(3)$ is that if $G$ is factor-critical then after shrinking any odd-cycle, $G'$ remains factor-critical. This is because if $G$ is factor-critical then starting with the given odd-cycle we can find an odd-ear decomposition (as illustrated in the previous solution). Hence after shrinking this odd-cycle, the first ear becomes an odd-cycle and the subsequent ears remain as it is. And so $G'$ has an odd-ear decomposition implying $G'$ is factor-critical.\n\nTherefore, consider the last step of the given Edmonds algorithm. Using previous part $(1)$, we know that $U=\\phi$ is a minimizer in the Tutte-Burge formula and according to the algorithm: $ODD=U=\\phi$. Now after removing $U=\\phi$ from $G'$, we are left with a single connected component (because $G'$ is connected ($\\vardiamondsuit$)). But after removing $U=ODD$ vertices, all the remaining vertices are $EVEN$ vertices with no edges between them. Thus, there can only be a single $EVEN$ vertex remaning (otherwise $G'$ would be disconnected).\n\nHence the Edmonds algorithm terminates with a single vertex.\n\\newline\n\nFollowing are the exercises from \\href{http://math.mit.edu/\\~goemans/18453S17/flowscuts.pdf}{http://math.mit.edu/\\~goemans/18453S17/flowscuts.pdf}\n\n\\subsection*{Exercise 4.1}\n\nWe first do some basic reductions.\n\n1. We can assume that all entries are fractional (non-integer). This is because, we can choose a small enough $\\epsilon > 0$ and let $A = (a_{ij})$ then we can replace it with:\n\\begin{equation*}\nA =\n\\begin{pmatrix}\na_{1,1}+\\epsilon & a_{1,2}+\\epsilon & \\cdots & a_{1,n-1}+\\epsilon & a_{1,n}-(n-1)\\epsilon \\\\\na_{2,1}+\\epsilon & a_{2,2}+\\epsilon & \\cdots & a_{2,n-1}+\\epsilon & a_{2,n}-(n-1)\\epsilon \\\\\n\\vdots  & \\vdots  & \\ddots & \\vdots  \\\\\na_{m-1,1}+\\epsilon & a_{m-1,2}+\\epsilon & \\cdots & a_{m-1,n-1}+\\epsilon & a_{m-1,n}-(n-1)\\epsilon \\\\\na_{m,1}-(m-1)\\epsilon & a_{m,2}-(m-1)\\epsilon & \\cdots & a_{m,n-1}-(m-1)\\epsilon & a_{m,n}+(m-1)(n-1)\\epsilon\n\\end{pmatrix}\n\\end{equation*}\nNote that the row sums and column sums are unaltered.\n\n2. We can assume all the entries $0 < a_{ij} < 1$. This is because we can write $A = I + F$ where $I$ is the integral part of each entry and $F$ is fractional part of each entry. Then since the row sum was integral, means row sum of both $I$ and $F$ are integral, means row sum of $F$ is integral. Similarly, for column sums as well.\n\\newline\n\nHence we have a matrix $A$ whose all entries are between $0$ and $1$ such that all row and column sums are integer. We construct a graph $G = (V,E)$ as follows: denote $i^{\\text{th}}$ row by a vertex $v_i \\in A$ and $j^{\\text{th}}$ column by another vertex $u_j \\in B$. Then $V = \\{s\\} \\union A \\union B \\union \\{t\\}$ and $E = (\\{s\\} \\times A) \\union (A \\times B) \\union (B \\times \\{t\\})$. Edge capacities are as follows:\n$$\nc(u,v) =\n     \\begin{cases}\n       r_i, &\\text{if } u=s, v=v_i\\\\\n       c_j, &\\text{if } v=t, u=u_j\\\\\n       1, &\\text{otherwise }\\\\\n     \\end{cases}\n$$\nwhere $r_i$ denote the $i^{\\text{th}}$ row sum and $c_j$ denote the $j^{\\text{th}}$ column sum.\n\nWe run Ford-Fulkerson algorithm on this graph $G$ to obtain a max-flow. \\textsl{Observations}:\n\\begin{enumerate}\n    \\item Max flow value $\\leq \\sum_{i} r_i$ (sum of all edge capacities going out of $s$)\n    \\item Set $g(s,v_i)=r_i$, $g(v_i, u_j)=a_{ij}$, and $g(u_j, t)=c_j$, then the value of this flow is $\\sum_{i} r_i$. ($g$ is a possible flow because of the given condition on $A$ about row sums and columns sums). And hence the max-flow value is $\\sum_{i} r_i$.\n    \\item If the capacities are integral, then note that in the Ford-Fulkerson algorithm, we start with flow value $0$ and in each iteration we increment the flow value by the minimum capacity edge on the path, which is an integer. Thus, there exists an integral max-flow $f$.\n\\end{enumerate}\n\nFinally, consider the matrix $A'$ such that $A'_{ij} = f(v_i,u_j)$, flow value along edge $(v_i, u_j)$, then\n\\begin{itemize}\n    \\item Row sums and column sums of $A$ and $A'$ are identical (because of flow conservation for each internal vertex)\n    \\item $A'_{ij} = 0$ (or $1$), and so $A'_{ij} = \\floor{A_{ij}}$ (or $\\ceil{A_{ij}}$) as $0 < A_{ij} < 1$ (from our initial assumption).\n\\end{itemize}\n\n\\textbf{Alternate algorithm}: Here's a more direct approach to find the values of $A'$ (assuming $0 < A_{ij} < 1$):\n\n\\begin{algorithm}[H]\n\\SetAlgoLined\n\\KwResult{0-1 matrix}\n \\For{$i=0; i < n; i++$} {\n    \\For{$j=0; j<r_i$}{\n        \\If{$c_j == 0$}{\n            continue\\;\n        }\n        $a_{ij} \\leftarrow 1$\\;\n        $c_j \\leftarrow c_j - 1$\\;\n        $j \\leftarrow j+1$\\;\n    }\n }\n \\caption{Rounding each entry of A}\n\\end{algorithm}\n(This algorithm demonstrates that the values $a_{ij}$ don't matter. We are just finding some $0/1$ matrix such each row and column has a specified number of $1'$s only - assuming existence of a solution).\n\n\n\\subsection*{Exercise 4.2}\n\nWe construct a graph $G = (V,E)$ as follows:\n$V = \\{s\\} \\union \\{x_{ij} \\mid 1 \\leq i < j \\leq n-1\\} \\union \\{y_i \\mid 1 \\leq i \\leq n-1\\} \\union \\{t\\}$ and add edges:\n\\begin{itemize}\n    \\item $(s, x_{ij})$ of capacity $g_{ij}$, $\\forall 1 \\leq i < j \\leq n-1$\n    \\item $(x_{ij}, y_i)$, $(x_{ij}, y_j)$, both of capacity $g_{ij}$, $\\forall 1 \\leq i < j \\leq n-1$\n    \\item $(y_i, t)$ of capacity $W - w_i$, $\\forall 1 \\leq i < j \\leq n-1$\n\\end{itemize}\nwhere $W = w_n + \\sum_{i=1}^{n-1} g_{i,n}$, denotes the total number of games team $n$ can win. (We remark here that if there is a possible outcome of games such that team $n$ has at least as many victories as all the other teams, then there is also a possible outcome in which team $n$ has as many victories as all other teams but team $n$ wins all the games to be played by them).\n\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 , draw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (s) at (-6,0) {s};\n  \\node[vertex] (G_1) at (-2,4) {};\n  \\node[vertex] (G_2) at (-2,0) {$x_{ij}$};\n  \\node[vertex] (G_3) at (-2,-4) {};\n  \\node[vertex] (H_1) at (2,5) {};\n  \\node[vertex] (H_2) at (2,3) {};\n  \\node[vertex] (H_3) at (2,1) {$y_i$};\n  \\node[vertex] (H_4) at (2,-1) {$y_j$};\n  \\node[vertex] (H_5) at (2,-3) {};\n  \\node[vertex] (H_6) at (2,-5) {};\n  \\node[vertex] (t) at (6,0) {t};\n\n  \\draw (s) -- (G_1);\n  \\draw (s) edge node[above]{$g_{ij}$} (G_2);\n  \\draw (s) -- (G_3);\n\n  \\draw (G_1) -- (H_1);\n  \\draw (G_1) -- (H_2);\n  \\draw (G_2) edge node[above]{$g_{ij}$} (H_3);\n  \\draw (G_2) edge node[above]{$g_{ij}$} (H_4);\n  \\draw (G_3) -- (H_5);\n  \\draw (G_3) -- (H_6);\n\n  \\draw (H_1) -- (t);\n  \\draw (H_2) -- (t);\n  \\draw (H_3) edge node[above]{$W - w_i$} (t);\n  \\draw (H_4) edge node[above]{$W - w_j$} (t);\n  \\draw (H_5) -- (t);\n  \\draw (H_6) -- (t);\n\\end{tikzpicture}\n\\end{center}\n\nHere $x_{ij}$ corresponds to the game between teams $i$ and $j$ and $y_i$ corresponds to team $i$. If there are $x$ games played between team $i$ and $j$, then $x$ units of flow in $x_{ij}$, is divided among $y_i$ and $y_j$ depending upon which team won how many games. Finally, the flow from $y_i$ to $t$ corresponds to the number of games won by team $i$, which can be no more than $W - w_i$, for team $n$ to have at least as many victories as all the other team.\n\nThus, team $n$ has at least as many victories as all the other team iff all games have an outcome, that is all the edges out of $s$ are saturated, implying the maximum flow is of size $\\sum_{1 \\leq i < j \\leq n-1} g_{ij}$.\n\\newline\n\nIt suffices to give a necessary and sufficient condition for team $n$ to lose the game, which is as follows: there exists a subset $R \\subseteq \\{1,\\ldots,n-1\\}$ such that $W < \\frac{w(R) + g(R)}{|R|}$ where $w(R) = \\sum_{i \\in R} w_i$ and $g(R) = \\sum_{i.j \\in R, i<j} g_{ij}$.\n\nTo prove this, suppose that team $n$ loses, which means that the flow is of strictly lesser value and so all the edges out of $s$ are not saturated. So we find the min cut $(S,T)$ ($S$ is nodes reachable from $s$ in the residual graph) in this graph and let $R$ be the team nodes $y_j$ which are reachable from $s$ in the residual graph. We claim that: \n\\begin{enumerate}\n    \\item $R$ is non-empty. Because all edges out of $s$ are not-saturated implies there is a $x_{ij}$ such that $s \\rightarrow x_{ij}$ is an edge in the residual graph. And since total incoming flow in $x_{ij}$ is strictly less than $g_{ij}$, it is clear that $x_{ij} \\rightarrow y_i$ and $x_{ij} \\rightarrow y_j$ are both edges in the residual graph, as both have capacity $g_{ij}$ and cannot get saturated.\n    \n    \\item $x_{ij} \\in S$ iff $y_i, y_j \\in R$. If $x_{ij} \\in S$ then from the above argument it follows that both $y_i ,y_j \\in R$. Conversely if $y_i ,y_j \\in R$ and $x_{ij} \\not \\in S$ then adding this vertex to $S$ decreases the capacity of the cut.\n\\end{enumerate}\n\nFinally, we compare the cuts $(S,T)$ and $(\\{s\\}, G \\setminus \\{s\\})$. \n\\begin{align*}\n    &c(\\{s\\}, G \\setminus \\{s\\}) &&>&& c(S,T) \\\\\n    \\iff &\\sum_{1 \\leq i < j \\leq n-1} g_{ij} &&>&& c(S,T) \\\\\n    \\iff &\\sum_{1 \\leq i < j \\leq n-1} g_{ij} &&>&& \\sum_{i,j \\not \\in R} g_{ij} + \\sum_{i \\in R} (W-w_i) \\\\\n    \\iff &\\sum_{i,j \\in R} g_{ij} &&>&& |R|W - \\sum_{i \\in R} w_i \\\\\n    \\iff &w(R) + r(R) &&>&& |R|W \\\\\n    \\iff &W &&<&& \\frac{w(R) + r(R)}{|R|}\n\\end{align*}\n\n\\subsection*{Exercise 4.3}\n\nLet $G = (V,E)$ be the given graph. We construct a graph $G' = (V',E')$ as follows:\n$V' = \\{s\\} \\union \\{i \\leftrightarrow j \\mid \\{i,j\\} \\in E\\} \\union \\{i \\mid i \\in V\\} \\union \\{t\\}$ and add edges:\n\\begin{itemize}\n    \\item $(s, i \\leftrightarrow j)$ of capacity $1$, $\\forall \\{i,j\\} \\in E$\n    \\item $(i \\leftrightarrow j, i)$, $(i \\leftrightarrow j, j)$, both of capacity $1$, $\\forall \\{i,j\\} \\in E$\n    \\item $(i, t)$ of capacity $p(i)$, $\\forall i \\in V$\n\\end{itemize}\n\n\\begin{center}\n\\begin{tikzpicture}[shorten >=1pt,->]\n  \\tikzstyle{vertex}=[circle ,top color =white , bottom color = processblue!20 , draw,processblue , text=blue , minimum width =1 cm]\n  \\node[vertex] (s) at (-5,0) {s};\n  \\node[vertex] (G_1) at (-2,2) {$k \\leftrightarrow j$};\n  \\node[vertex] (G_2) at (-2,0) {$i \\leftrightarrow j$};\n  \\node[vertex] (G_3) at (-2,-2) {};\n  \\node[vertex] (H_1) at (2,5) {$k$};\n  \\node[vertex] (H_3) at (2,1) {$j$};\n  \\node[vertex] (H_4) at (2,-1) {$i$};\n  \\node[vertex] (H_5) at (2,-3) {};\n  \\node[vertex] (H_6) at (2,-5) {};\n  \\node[vertex] (t) at (6,0) {t};\n\n  \\draw (s) edge node[above] {1} (G_1);\n  \\draw (s) edge node[above]{1} (G_2);\n  \\draw (s) edge node[above]{1} (G_3);\n\n  \\draw (G_1) edge node[above]{1} (H_1);\n  \\draw (G_1) edge node[above]{1} (H_3);\n  \\draw (G_2) edge node[above]{1} (H_3);\n  \\draw (G_2) edge node[above]{1} (H_4);\n  \\draw (G_3) edge node[above]{1} (H_5);\n  \\draw (G_3) edge node[above]{1} (H_6);\n\n  \\draw  (H_1) edge node[above]{p(k)} (t);\n  \\draw  (H_3) edge node[above]{p(j)} (t);\n  \\draw  (H_4) edge node[above]{p(i)} (t);\n  \\draw  (H_5) -- (t);\n  \\draw  (H_6) -- (t);\n\\end{tikzpicture}\n\\end{center}\n\n\\subsubsection*{(a)}\nHere if the node $i \\leftrightarrow j$ has an incoming unit flow then either it will be directed towards $i$ or $j$, which will determine the orientation of this edge as: if it's directed towards $i$ then orient $j \\rightarrow i$ and if it's directed towards $j$ then orient $i \\rightarrow j$. And if $i \\leftrightarrow j$ has an incoming zero flow then that means whatever the orientation of this edge be, it will violate some constraint.\n\nNext, the incoming unit flow in each $i \\in V$ contributes to the in-degree of $i$ and since the capacity of $(i,t)$ edge is $p(i)$, we can't have more than $p(i)$ units of flow incoming into $i$.\n\nThus, the max flow in this graph is of size $|E|$ (that is all the outgoing edges from $s$ are saturated) iff there exists a possible orientation of the edges such that all in-degree constraints are satisfied.\n\\newline\n\n\\subsubsection*{(b)}\nSuppose that graph cannot be oriented, then the max flow is of size strictly less than $|E|$. We consider the min-cut $(S,T)$ ($S$ is nodes reachable from $s$ in the residual graph). Since some outgoing edges from $s$ are not saturated so $S \\setminus \\{s\\}$ is non-empty.\n\nWe note that $i, j \\in S$ iff $i \\leftrightarrow j \\in S$, because if $i \\leftrightarrow j \\in S$ then $(s) \\longrightarrow (i \\leftrightarrow j) \\longrightarrow (j)$ and $(s) \\longrightarrow (i \\leftrightarrow j) \\longrightarrow (i)$ are paths in the residual graph. Conversely, if $i,j \\in S$ and $(i \\leftrightarrow j) \\not \\in S$ then it can be added to $S$ and reduce the cut size.\n\nLet $R$ be the set of vertex nodes $i$ reachable from $s$. Since $S \\setminus \\{s\\}$ is non-empty, $R$ is also non-empty because of the above-mentioned fact.\n\nFinally, we compare the cuts $(S,T)$ and $(\\{s\\}, V' \\setminus \\{s\\})$.\n$$c(\\{s\\}, V' \\setminus \\{s\\}) > c(S,T)$$\n\nBut $c(\\{s\\}, V' \\setminus \\{s\\}) = |E|$ and $c(S,T) = |\\#\\{i \\leftrightarrow j \\mid i \\not \\in R \\wedge j \\not \\in R\\}| + \\sum_{v \\in R} p(v)$ (edges going from $s$ to $i \\leftrightarrow j$ and edges going from $i$ to $t$).\n\nBut $|E| - |\\#\\{i \\leftrightarrow j \\mid i \\not \\in R, j \\not \\in R\\}| = |\\#\\{i \\leftrightarrow j \\mid i \\in R \\vee j \\in R\\}| = |E(R)|$. Hence, $|E(R)| > \\sum_{v \\in R} p(v)$\n\n\\subsection*{Exercise 4.4}\n\n\\textbf{Theorem} Given a digraph $G$ and $s,t \\in G$ with all edge capacities $1$. There is a flow of value $k$ from $s$ to $t$ iff there are $k$-disjoint paths between $s$ and $t$.\n\n\\begin{proof}\nSuppose there are $k$-disjoint paths between $s$ and $t$, then set $f(e)=1$ for all the edges on these paths and $f(e)=0$ otherwise. Since paths were disjoint, this gives us a flow of value $k$.\n\\end{proof}\n\nConversely, suppose there is a flow of value $k$, Choose a vertex $v$ such that $f(s,v)=1$. By conservation there must be a vertex $w$ such that $f(v,w)=1$. Extending this way until we reach $t$, everytime choosing a new edge, we get a path from $s$ to $t$. But now note that there are $k$ vertices such that $f(s,v)=1$. So for each such vertex we can perform the above process and obtain $k$ edge-disjoint paths from $s$ to $t$.\n\\newline\n\nNow, we are given an undirected graph $G$. We find it's \\textsl{maximum adjacency ordering} $v_1, v_2, \\ldots, v_n$. Using claim 4.6 (from the paper), we conclude that $(\\{v_1, \\ldots , v_{n-1}\\}, \\{v_n\\})$ is a $(v_{n-1}, v_n)$ cut. But since the degree of each vertex is atleast $k$, this cut size is also atleast $k$.\n\nFinally, we convert graph $G$ into a digraph by replacing each edge $\\{u,v\\}$ with two edges $(u,v)$ and $(v,u)$ all of capacity $1$. Now by our above argument, the $(v_{n-1}, v_n)$ min cut size is $\\geq k$ and so the max-flow is $\\geq k$. Using above-mentioned theorem, we get that there are atleast $k$ edge-disjoint paths between $v_n$ and $v_{n-1}$.\n\n\n\\subsection*{Exercise 4.5}\n\nWant to show that\n$$u(\\delta(A)) + u(\\delta(B)) \\geq u(\\delta(A \\cup B)) + u(\\delta(A \\cap B))$$\nwhere $u(\\delta(S)) = \\sum_{e \\in \\delta(S)} u(e)$\n\nSince the capacities are non-negative, it suffices to show that each term on the right also appears on the left (same number of times).\n\nTherefore, $u(\\delta(A \\cup B)) + u(\\delta(A \\cap B)) = \\sum_{e \\in \\delta(A \\cup B)} u(e) + \\sum_{f \\in \\delta(A \\cap B)} u(f) = \\sum_{e \\in \\delta(A \\Delta B)} u(e) + 2\\sum_{f \\in \\delta(A \\cap B)} u(f)$. Now each term $u(e)$ where $e \\in \\delta(A \\Delta B)$ is also counted once either for $e \\in A$ or $e \\in B$ on the left. Similarly, each term $u(f)$ where $f \\in A \\cap B$ is counted twice for both $f \\in A$ and $f \\in B$. So $u(\\delta(A)) + u(\\delta(B)) \\geq u(\\delta(A \\cup B)) + u(\\delta(A \\cap B))$.\n\n\n\\subsection*{Exercise 4.6}\n\nSuppose $f$ is submodular then consider $A = S \\cup \\{e\\}, B = T$:\n$$f(S \\cup \\{e\\}) + f(T) \\geq f(T \\cup \\{e\\}) + f(S)$$\nbecause $(S \\cup \\{e\\}) \\cup T = T \\cup \\{e\\}$ and $(S \\cup \\{e\\}) \\cap T = (S \\cap T) \\cup (T \\cap \\{e\\}) = S$ as $S \\subseteq T$ and $e \\not \\in T$. After re-arranging, we get that submodularity implies diminishing returns.\n\\newline\n\nConversely, let $A \\setminus B = \\{a_1, a_2, \\ldots, a_n\\}$ then define $A_0 = A \\inter B$, $A_i = A_{i-1} \\union \\{a_i\\}$, $\\forall i \\geq 1$ and $B_0 = B$, $B_i = B_{i-1} \\union \\{a_i\\}$, $\\forall i \\geq 1$.\n\nNow we note that, $A_i \\subseteq B_i$. Proof by induction: $A \\inter B = A_0 \\subseteq B_0 = B$. Assuming $A_{i-1} \\subseteq B_{i-1}$, $A_{i-1} \\union \\{a_i\\} = A_i \\subseteq B_i = B_{i-1} \\union \\{a_i\\}$. \n\nFurthermore, $a_{i+1} \\not \\in B_i$ by construction. Hence we can apply property of diminishing returns on these sets as:\n\\begin{align*}\n    f(A_1) - f(A_0) &\\geq f(B_1) - f(B_0) \\\\\n    f(A_2) - f(A_1) &\\geq f(B_2) - f(B_1) \\\\\n    &\\vdots \\\\\n    f(A_n) - f(A_{n-1}) &\\geq f(B_n) - f(B_{n-1}) \\\\\n\\end{align*}\n\nAdding them up, we get $f(A_n) - f(A_0) \\geq f(B_n) - f(B_0)$. But $f(A_n) = A$ and $f(B_n) = f(A \\cup B)$. Hence\n$$f(A) - f(A \\cap B) \\geq f(A \\cup B) - f(B)$$\n\nAfter re-arranging, we get that diminishing returns implies submodularity.\n\n\n\\vspace{2in} %Leave more space for comments!\n\n[References: Douglas B. West notes on Gallai Edmonds Structure Theorem for problem 2.5 and discussion with Sricharan AR and Satya P. Nayak for problem 4.4]\n\n\\end{document}\n\n", "meta": {"hexsha": "6e096d107c8dc674fc7bc6553221d33fe647dd31", "size": 37646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "topics_in_algo/assign2_soln.tex", "max_stars_repo_name": "kishlaya/assignments", "max_stars_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-17T09:28:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-14T17:40:34.000Z", "max_issues_repo_path": "topics_in_algo/assign2_soln.tex", "max_issues_repo_name": "kishlaya/assignments", "max_issues_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "topics_in_algo/assign2_soln.tex", "max_forks_repo_name": "kishlaya/assignments", "max_forks_repo_head_hexsha": "1aa76e32d7e5059499a93359cb52118ccbf07028", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.6988155668, "max_line_length": 849, "alphanum_fraction": 0.6515698879, "num_tokens": 13156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.41946180827648066}}
{"text": "%!TEX root = Economics and Behaviour.tex\n\r\n\\section{Strategic form}\n\nIn this first section we will merely consider \\begriff{static games} where all players choose their individual actions simultaneously (see One-Shot games). Yet, the term simultaneously is meant figuratively, it is not decisive that all players act at the same time but that at the time of their choice the decisions of all other players are unknown\\footnote{Some experiments have shown that even if theoretically the decision process should be the same people tend to behave differently if they have knowledge about a decision order  (see Rapoport 1997, Guth, Huck und Rapoport 1998)}.\n\nIn static games of complete, perfect information, a strategic form or normal-form representation of a game is a specification of players' strategy spaces and payoff functions. \\\\\n\nFirst let's take a look at the definition of a strategy, which we will then use to define the strategic form of games: \n\n\\begin{definition}[Strategy]\n\tLet $\\mathcal{H}_{i}$ denote the collection of player $i$'s sets of information, $\\mathcal{A}$ the set of possible actions in the game and $C(H) \\subseteq \\mathcal{A}$ the set of actions possible at information set $H$. A \\begriff{strategy} for player $i$ is a function $s_{i} \\colon \\mathcal{H}_{i} \\rightarrow \\mathcal{A}$ such that\n\t\\[ s_{i}(H) \\in C(H) \\text{ for all } H \\in \\mathcal{H}_{i} \\]\n\\end{definition}\n\nWe call a set of strategies a \\begriff{complete plan} of actions for each situation in a game and with $S_{-i}$ we denote the strategies of all players except player $i$.\\\\\n\n\\begin{definition}[Strategic form representation]\nTo be fully defined a game in \\begriff{strategic form} must specify the set $\\{ N, S, u \\}$ where\n\t\\begin{enumerate}\n\t\t\\item $N$ is the finite number of players and for player $i$ that would mean $i \\in \\{ 1, \\dotsc, N \\}$.\n\t\t\\item For each player $i$ we have a set of strategies $S_{i}$, such that $S = \\bigotimes S_{i}$.\n\t\t\\item For each player $i$ we have an expected utility function $u_{i} : S \\rightarrow \\MdR$, such that $u = \\{ u_{1}, \\dotsc, u_{N} \\}$.\n\t\\end{enumerate}\n\\end{definition}\n\n\n\nTo visualise a static game with two players ($P1$ and $P2$) and a finite number of possible strategies (for simplicity let's assume that there are only two signals and call them $a$ and $b$) one commonly uses the \\begriff{matrix form}, where $u_{i}(x, y)$ represents the utility function for player $i$ given the strategy $x$ for $P1$ and $y$ for $P2$ with $x, y \\in \\{ a, b\\}$.\n\\begin{center}\n\t\\begin{tabular}{|c|c|c|}\n\t\t\\hline\\hline\r  \t\t\t$P1$ / $P2$ & \\textbf{a} & \\textbf{b} \\\\\r         \t\t\\cline{1-3}\r   \t\t\t\t\t\\textbf{a} & $( u_{1}(a, a) , u_{2}(a, a))$ & $(u_{1}(a, b), u_{2}(a, b))$\t\\arrayrulewidth2pt \\\\\r            \t\\cline{1-3}\r   \t\t\t\t\t\\textbf{b} & $( u_{1}(b, a), u_{2}(b, a))$ & $(u_{1}(b, b), u_{2}(b, b))$\\\\ \\hline\\hline\r\t\\end{tabular}\t\n\\end{center}\n\n\\begin{example}[Prisoner's Dilemma] \\label{prisonersdilemma} \\index{Prisoner's Dilemma}\n\t Imagine, two members of a criminal gang are arrested and imprisoned. Each prisoner is in solitary confinement with no means of communicating with the other. The prosecutors lack sufficient evidence to convict the pair on the principal charge. They hope to get both sentenced to a year in prison on a lesser charge. Simultaneously, the prosecutors offer each prisoner a bargain. Each prisoner is given the opportunity either to: betray the other by testifying that the other committed the crime, or to cooperate with the other by remaining silent. The offer is:\n\t\\begin{itemize}\n\t\t\\item If A and B betray each other, each of them serves 6 years in prison\n\t\t\\item If A betrays B but B remains silent, A will be set free and B will serve 9 years in prison (and vice versa)\n\t\t\\item If A and B both remain silent, both of them will only serve 1 year in prison (on the lesser charge)\n\t\\end{itemize}\n\t\n\t\\begin{center}\n\t\t\\begin{tabular}{|l|l|r|}\n\t\t\t\\hline\\hline\r  \t\t\t\tP1 / P2 & \\textbf{defects} & \\textbf{cooperates} \\\\\r         \t\t\t\\cline{1-3}\r   \t\t\t\t\\textbf{defects} & $(-6, -6)$ & $(0, -9)$ \t\\arrayrulewidth2pt \\\\\r            \t\t\\cline{1-3}\r   \t\t\t\t\\textbf{cooperates} & $(-9, 0)$ & $(-1, -1)$ \\\\\n\t\t\t\\hline\\hline\r\t\t\\end{tabular}\t\n\t\\end{center}\n\\end{example}\n\nThere are many different possibilities to extrapolate the Prisoner's Dilemma to apply it in a variety of problems, other interpretations are for example:\n\\begin{itemize}\n\t\\item Collusion on prices\n\t\\item Investing in human capital vs. arming for a war\n\t\\item Buying a SUV vs. a smaller car\n\\end{itemize}\n\nNow that we got to know an example for a game we should discuss some solution concepts and the first obvious choice is the strict dominance.\n\n\\begin{definition}[Strict dominance]\n\tA strategy $s_{i} \\in S_{i}$ is \\begriff{strictly dominant} for player $i$ if for all $s_{i}' \\neq s_{i} (s_{i}'  \\in S_{i})$: \n\t\\[ u(s_{i}, s_{-i}) > u(s_{i}', s_{-i}), \\quad \\forall s_{-i} \\in S_{-i} \\]\t\n\\end{definition}\n\nAnalysing \\hyperref[prisonersdilemma]{Prisoner's Dilemma} one can see that $cooperate$ is strictly dominated by $defect$. Simply the elimination of strictly dominated strategies leads to the prediction that the players choose $(defects, defects)$ even though $(cooperates, cooperates)$ would result in a lower prison sentence. \n\nThis leads us to the elimination of irrational strategies:\n\n\\begin{definition}[Best response]\n\tThe strategy $s_{i}$ is a \\begriff{best response} for player $i$ to the opponent's strategies $s_{-i}$ if\n\t\\[ u_{i}(s_{i}, s_{-i}) \\geq u_{i}(s_{i}', s_{-i}) \\text{ for all } s_{i}' \\in S_{i} \\]\n\tA strategy $s_{i}$ is never a best response if there is no $s_{-i}$ for which $s_{i}$ is a best response.\n\\end{definition}\n\n\\begin{definition}[Rationalisable Strategies]\n\tThe strategies that survive the iterated elimination of strategies that are never a best response are known as player $i$'s \\begriff{rationalisable strategies}.\n\\end{definition}\n\nIteratively eliminating dominated strategies leads to a set of rationalisable strategies; let's take a look for example at the following game:\n\n\t\\begin{center}\n\t\t\\begin{tabular}{|r|r|r|r|}\n\t\t\t\\hline\\hline\r  \t\t\t\tP1 / P2 & \\textbf{l} & \\textbf{m} & \\textbf{r} \\\\\r         \t\t\t\\cline{1-4}\r   \t\t\t\t\\textbf{u} & $(1, 1)$ & $(2, 2)$ & $(2, 0)$ \\arrayrulewidth2pt \\\\\r            \t\t\\cline{1-4}\r   \t\t\t\t\\textbf{m} & $(2, 0)$ & $(0, 1)$ & $(1, 0)$ \\arrayrulewidth2pt \\\\\r            \t\t\\cline{1-4}\r   \t\t\t\t\\textbf{d} & $(0, 2)$ & $(1, 1)$ & $(1, 1)$ \\\\\t\t\t\\hline\\hline\r\t\t\\end{tabular}\t\n\t\\end{center}\n\t\nHere, an iterated elimination leads to $(u, m)$ as rationalisable strategies:\n\\begin{itemize}\n\t\\item For Player 1 $d$ is strictly dominated by $u$ and should therefore never be played.\n\t\\item For Player 2 $r$ is strictly dominated by $m$.\n\t\\item Since Player 1 would never play $d$, $m$ dominates in the iterative subgame $l$\n\t\\item Now knowing Player 2 should play $m$, $u$ is the rational choice for Player 1\n\\end{itemize} \t\n\nImportant to notice is that here, the predictions we derived rely immensely on the rationality of all players.\n\nSince there is not always a strictly dominant strategy we extend our solution concepts with the Nash-Equilibrium.\n\n\\begin{definition}[Nash-Equilibrium] \\label{nashequilibrium} \nA strategy set $s = (s_{1}, \\dotsc, s_{N})$ constitutes a \\begriff{Nash-Equilibrium} of a game if for every $i = 1, \\dotsc, N$ (where $N$ is the number of players)\n\t\\[ u_{i}(s_{i}, s_{-i}) \\geq u_{i}(s_{i}', s_{-i}) \\text{ for all } s_{i}' \\in S_{i} \\]\n\\end{definition}\n\nIn other words, a \\begriff{Nash-Equilibrium} is the mutual best response for every player, therefore a set of strategies in which no player can do better by unilaterally changing their strategy. \\\\\n\n\\begin{example}[Battle of the sexes] \\label{battleofthesexes} \\index{Battle of sexes}\n\t\tImagine a couple that agreed to meet this evening, but both individually cannot recall if they will be attending the opera or a football match. The husband would most of all like to go to the football game. The wife would like to go to the opera. Both would prefer to go to the same place rather than different ones. \\\\ \\\\\n\t\tHence, the Battle of the sexes in strategic form could, of course depending on their utility function, look something like:\n\t\t\\begin{center}\n\t\t\t\\begin{tabular}{|l|l|r|}\n\t\t\t\t\\hline\\hline\r  \t\t\t\t\tM / F & \\textbf{football} & \\textbf{opera} \\\\\r         \t\t\t\t\\cline{1-3}\r   \t\t\t\t\t\\textbf{football} & $(1, 2)$ & $(0, 0)$ \t\\arrayrulewidth2pt \\\\\r            \t\t\t\\cline{1-3}\r   \t\t\t\t\t\\textbf{opera} & $(0, 0)$ & $(2, 1)$ \\\\ \\hline\\hline\r\t\t\t\\end{tabular}\t\n\t\t\\end{center}\n\t\t\n\t\tand the two Nash-Equilibriums in this game are $(opera, opera)$ and $(football, football)$.\n\\end{example}\n\n\\begin{example}[The Beauty-Contest] \\index{Beauty-Contest} \\label{Beauty-Contest}\nJohn Keynes described the action of rational agents in a market using an analogy based on a fictional newspaper contest, in which entrants are asked to choose the six most attractive faces from a hundred photographs. Those who picked the most popular faces are then eligible for a prize. An agent has to consider that not his preferred choice is the optimal strategy but the one with the highest chances to be chosen by all others.\n\\end{example}\nWe can generalise this example to the following \\\\\n\\begin{example}[Guessing-Game] \\index{Guessing-Game} \\label{Guessing-Game}\n\t A Guessing-Game (e.g. the \\hyperref[Beauty-Contest]{Beauty-Contest}) is a game with at least two players in which the sequel can be described as follows:\n\t\\begin{itemize}\n\t\t\\item Every player guesses a number $b_{i} \\in \\{0, 1, 2, \\dotsc, 100 \\}$\n\t\t\\item The player with the closest guess to $p \\cdot \\sum_{i = 1}^{n} \\frac{b_{i}}{n} = p \\cdot \\varnothing$ with $p \\in (0, 1)$ wins\n\t\t\\item In case of tie a random device that is 'fair' decides who wins the prize $P > 0$\n\t\\end{itemize}\n\t\\textbf{1. Question:} Is $(0, \\dotsc, 0)$ a Nash-Equilibrium? \\\\\n\t\\textbf{Answer:} Yes. Assume player $i$ bids $b > 0$ and all others bid $0$.\t\n\t\t\\begin{itemize}\n\t\t\t\\item if bidder $i$ bids $0$ expected win equals $\\frac{1}{n} P $\n\t\t\t\\item we can rewrite $p$ times the mean with\t\n\t\t\t\t\\[ p \\cdot \\varnothing = p \\cdot \\frac{(n - 1)0 + 1 b}{n} = p \\cdot \\frac{b}{n}. \\]\n\t\t\tThen, his expected profit is $0$, as $0$ is closer to $p \\cdot \\varnothing$ then the bet $b > 0$, since\n\t\t\t\\[ \\left| b - p \\cdot \\frac{b}{n} \\right| =  \\left|(n-p) \\cdot \\frac{b}{n} \\right| \\overset{\\substack{p < 1, \\\\ n \\geq 2}}{>} \\left| p \\cdot \\frac{b}{n} \\right| = \\left| 0 - p \\cdot \\frac{b}{n} \\right| \\]\n\t\t\\end{itemize}\n\t\n\t\\textbf{2. Question:} Is $(0, \\dotsc, 0)$ the unique Nash-Equilibrium here? \\\\\n\t\\textbf{Answer:} Yes, and to bring this to proof we take a look at player $i$'s optimal strategy $b_{i}^{*}$ given the optimal responses of all others:\n\t\n\tFirst, as a consequence our proof of the 1. Question the optimal strategy $b_{i}^{*}$ has to be smaller or equal to the others' winning number: $b_{i}^{*} \\leq p \\cdot \\frac{\\sum_{j \\neq i} b_{j}^{*}}{n - 1}$.\n\t\n\tConsidering all players, in terms of summing up over all $i$, yields then\n\t\\[ \\sum_{i = 1}^{n} b_{i}^{*} \\leq p \\cdot \\frac{\\sum_{i = 1}^{n} \\sum_{j \\neq i} b_{j}^{*}}{n - 1} = p \\cdot \\frac{(n - 1) \\sum_{j = 1}^{n} b_{j}^{*}}{n - 1} = p \\cdot \\sum_{j = 1}^{n} b_{j}^{*}. \\]\n\tThus\n\t\t\\[ \\sum_{i = 1}^{n} b_{i}^{*} \\leq p \\cdot \\sum_{i = 1}^{n} b_{i}^{*}, \\quad p \\in (0, 1) \\]\n\thas to hold true and with that $b_{i}^{*} = 0$ for all $i$.\n\t\n\tNow that a Nash-Equilibrium consists of the mutual best responses only $(0, \\dotsc,  0)$ can be a Nash-Equilibrium in this situation. \\\\\n\n\t\\textbf{3. Question:} Is $(0, \\dotsc, 0)$ also a strictly dominant strategy? \\\\\n\t\\textbf{Answer:} No. Imagine following situation: \\\\\n\tIf $48$ of $50$ players bid the number $100$ and the $49$th bids $0$ then the best response for player $50$ is to bid $97$ \\footnote{$97$ is the closest whole number to $p \\cdot \\varnothing$}, which is much larger than 0, so $0$ is not the best answer and therefore cannot be a strictly dominant strategy.\n\\end{example}\n\n\n\\newpage", "meta": {"hexsha": "ef2a25eb25cf0d202574cb817674b1cf30117f44", "size": 11998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/chapter/1.1.-strategic_form.tex", "max_stars_repo_name": "ProxiStyx/Economics-and-Behaviour-WS2015", "max_stars_repo_head_hexsha": "74eee2f6a8db9f3e6949156e0ad2d2f5226aceeb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "source/chapter/1.1.-strategic_form.tex", "max_issues_repo_name": "ProxiStyx/Economics-and-Behaviour-WS2015", "max_issues_repo_head_hexsha": "74eee2f6a8db9f3e6949156e0ad2d2f5226aceeb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/chapter/1.1.-strategic_form.tex", "max_forks_repo_name": "ProxiStyx/Economics-and-Behaviour-WS2015", "max_forks_repo_head_hexsha": "74eee2f6a8db9f3e6949156e0ad2d2f5226aceeb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.4064516129, "max_line_length": 585, "alphanum_fraction": 0.6839473246, "num_tokens": 3865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4194322189454623}}
{"text": "\\chapter{Introduction}\n\nDependent type theories are now well-established as a technology for certifying\nsoftware and formalising mathematics. Yet they remain rough around some edges,\none of which is termination checking. If a type theory is to be consistent as a\nlogic, it must ensure that all recursive programs terminate (and that all\ncorecursive programs are productive). In mainstream dependently typed languages\nsuch as Coq, Agda, Idris and Lean, this termination check is implemented by\nheuristics based on a simple syntactic criterion for termination, the principle\nof structural recursion.\n\nDespite its simplicity, structural recursion is surprisingly powerful in\npractice. Still, it suffers from some flaws that are directly related to its\nsyntactic nature. It makes type checking non-compositional: we cannot always\nreplace a term by another term of the same type because some terms have special\nmeaning to the termination checker. It does not play well with more complex data\ntypes such as the nested inductive type of rose trees. It does not easily\naccommodate corecursive definitions, which require a separate productivity\ncheck. And when structural checkers are extended to handle more complex\nscenarios, such as mutual and nested recursion, they tend to become complex and\ntherefore hard to implement correctly.\n\nTo address the problems with structural recursion, several other termination\nchecking regimes have been proposed. One of these is \\emph{sized types}, an\numbrella term for a family of broadly similar type systems that use type\nannotations to ensure termination. In these systems, inductive types are\nannotated with a size: $\\Nat{n}$, for example, is the type of natural numbers\nwith size $n$. For the moment, we can view $n$ as a natural number and say that\n$\\Nat{n}$ contains only natural numbers $m ≤ n$. This interpretation suggests a\nsimple termination criterion: if, in a recursive definition, we receive an input\nin $\\Nat{n}$ and only recurse on terms in $\\Nat{m}$ for some $m < n$, then the\nrecursion must stop (at the latest) when it reaches the size zero.\n\nSince this termination check is based entirely on type-level information, it\navoids the non-compositionality of syntactic approaches. It also handles nested\ninductive data types well and, when combined with copatterns \\cite{abel2016},\ncan be used to check productivity of corecursive definitions in a similarly\nnatural way. The dependently typed language Agda features an implementation of\nsized types that demonstrates these advantages. \\chapref{background} gives a\nbrief comparison between structural termination checking and Agda's sized types.\n\nMotivated by the desirable properties of sized types, this thesis investigates a\ncustom lambda calculus with sized types called λST, defined in \\chapref{source}.\nThe calculus extends the simply-typed lambda calculus with sized types that\nclosely resemble Agda's. As such, it provides a setting for\n\\enquote*{experiments} with Agda's sized types: investigations of the properties\nof sized types without the surrounding complexity of a full dependently-typed\nlanguage.\n\nOf these properties, two are of special interest. The first is normalisation:\nthe type system should ensure that all programs do actually terminate. This is\nthe raison d'être of sized types and thus the focus of existing work. The\nsecond property we are interested in is size irrelevance: sizes should only be\nused during type checking to ensure termination/productivity and should not\naffect the runtime behaviour of programs. This means that sizes can be erased at\nruntime, which is good for performance.\n\nIn \\chapref{model}, I give a denotational semantics of λST that incorporates a\nnotion of size irrelevance. In the semantics, types are interpreted as reflexive\ngraphs. This technique is usually used to establish parametricity properties,\nfor example of type quantification in System F or Π-types in dependent type\ntheories. It is not surprising that reflexive graphs also yield a model of λST\nsince size irrelevance can be viewed as a parametricity property: it just means\nthat any term which depends on a size is parametric in that size. The model is\nfully formalised in Agda (without sized types); \\chapref{formalisation}\ndiscusses the formalisation and some of its technical challenges.\n\nBefore I settled on the reflexive graph approach, I also investigated two\ncategory-theoretical modelling approaches which looked promising, but turned out\nto be inadequate. \\chapref{negative} briefly discusses these models and their\nproblems.\n", "meta": {"hexsha": "e462c4a24235f07316421fbdbcde2f57493a3141", "size": 4552, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/intro.tex", "max_stars_repo_name": "JLimperg/msc-thesis", "max_stars_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-14T01:30:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-14T01:30:46.000Z", "max_issues_repo_path": "include/intro.tex", "max_issues_repo_name": "JLimperg/msc-thesis", "max_issues_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/intro.tex", "max_forks_repo_name": "JLimperg/msc-thesis", "max_forks_repo_head_hexsha": "a6b4cf13104112c76a07d17a9dd18f3d3589d449", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.2222222222, "max_line_length": 80, "alphanum_fraction": 0.8143673111, "num_tokens": 966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6370307875894138, "lm_q1q2_score": 0.41943221894546223}}
{"text": "\\documentclass{pset_template}\n\n\\title{FSA/Regular Expressions}\n\\date{February 8, 2019}\n\\editorOne{Sanjit Bhat}\n\\editorTwo{Alexander Sun}\n\\lectureNum{3}\n\\contestMonth{February}\n\n\\begin{document}\n\\maketitle\n\n\\section{Fun Facts}\n\\begin{itemize}\n\\item Developed in 1951 by mathematician Stephen Cole Kleene.\n\\item Ken Thompson (one of the guys who developed UNIX) used regular expressions on an early Unix editor.\nThis eventually lead to its use in the famous UNIX tool grep.\n\\item Applications include string searching algorithms,  input verification, and search engines.\n\\item You can even use it inside your programming editor to find where you've put stuff.\n\\end{itemize}\n\n\\section{Background}\n\\paragraph{What are regular expressions?}\nAccording to Wikipedia, regular expressions (regex) are ``a sequence of characters that define a search pattern.''\nIn other words, a regex defines a set of possible strings in a concise manner for\nsome later purpose.\nFor example, reali[sz]e defines the set \\{realize, realise\\} of possible strings.\nThis set can be later used for cross-referencing American-English spellings with\nBritish-English spellings.\n\n\\paragraph{All the regex syntax you need to know.}\nRegex includes \\textit{metacharacters} that define more complex types\nof string matching.\nThe following is a list of all the regex metacharacters you need to know:\n\n\\begin{enumerate}\n\\item \\textbf{|, or, $\\cup$}\nThese are booleans that tell the processor to take the set union of the regexes\non the left- and right-hand sides.\nFor instance, gr(a|e)y, gray or grey, and gr(a$\\cup$e)y all define the set\n\\{gray, grey\\}.\n\n\\item \\textbf{$\\lambda$}\nThe null or empty string.\n\n\\item \\textbf{Quantification}\nDefining the number of something allowed to occur.\nNote that these all operate on a regex left of the operator.\n    \\begin{enumerate}\n    \\item \\textbf{?}\n    Zero or one.\n    E.g., colou?r = \\{color, colour\\}.\n    \\item \\textbf{*}\n    Zero or more.\n    This is also called the Kleene Star (named after the inventor, Stephen Kleene).\n    \\item \\textbf{+}\n    One or more.\n    \\end{enumerate}\n\n\\item \\textbf{.}\nWildcard (a fill in for any character).\nCombine . and * for a.*b, which accepts any string with a and b as the leftmost and rightmost\ncharacters, respectively, with an arbitrary number of arbitrary characters inbetween.\n\n\\item \\textbf{[\\ldots]}\nSet of possible character matches.\nThink the reali[sz]e example above.\nThis can get slightly more complex by using hyphens to define ranges of possible characters.\nE.g., [a-z] means every \\textit{lowercase} char from a to z;\n[abcx-z] means a, b, c, and x, y, z; and [a-cx-z] means a, b, c and x, y, z.\n\n\\item \\textbf{[\\string^\\ldots]}\nSet of characters not contained withing the brackets.\nE.g., [\\string^a-z] matches any character that is not a lowercase character from a to z.\n\n\\item \\textbf{()}\nJust like in math, parentheses imply grouping.\nE.g., if we wanted the set \\{gray, grey\\}, gra|ey would give us \\{gra, ey\\}.\nInstead, using parentheses we can get gr(a|e)y, which gives us the correct regex.\nA more complex example is H(\\\"{a}|ae?)ndel, which matches \\{Handel, H\\\"{a}ndel, Haendel\\}.\n\\end{enumerate}\n\nOrder of operations: Kleene Star (*), concatenation (ab), and union($\\cup$).\nBecause Kleene Star has the highest priority, a.*b accepts a string\nwith an arbitrary number of \\textit{several different arbitrary} characters\n (e.g., \\{acdb, \\ldots\\}), as opposed\nto only an arbitrary number of a single arbitrary character (e.g., \\{accb, \\ldots\\}).\n\n\\paragraph{Practicing the syntax via identity proofs.}\nTo make sure you understand the syntax and order of operations,\nsee if you can prove the following identities:\n\\begin{enumerate}\n\\item (a*)* = a*\n\\item aa* = a*a\n\\item aa* $\\cup \\lambda$ = a*\n\\item a(b $\\cup$ c) = ab $\\cup$ ac\n\\item a(ba)* = (ab)*a\n\\item (a $\\cup$ b)* = (a* $\\cup$ b*)*\n\\item (a $\\cup$ b)* =(a*b*)*\n\\item (a $\\cup$ b)* = a*(ba*)*\n\\end{enumerate}\n\n\\paragraph{How are regex interpreted by the computer?}\nIn a regex, there are two types of chars: literals and metacharacters.\nLiterals define regular characters, while metacharacters indicate\nmore nuanced behaviors.\nAfter creating a regex, a regex processor transforms the characters into an internal\nrepresentation that can be thought of as a Finite State Automata (FSA).\nFSAs are an abstract concept in theoretical computer science consisting of the following:\n\\begin{enumerate}\n\\item A finite number of states, of which exactly one is active at any given time\n\\item Transition rules to change the active state\n\\item An initial state\n\\item One or more final states\n\\end{enumerate}\nWe can draw an FSA by representing each state as a circle, the final state\nas a double circle, the start state as the only state with an incoming arrow,\nand the transition rules as labeled-edges connecting the states.\nFor instance, the following is an FSA diagram for the regex x+y+:\n\n{\\centering\n\\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n   \\node [state,initial, initial text=] (q_0) {A};\n   \\node [state, right of=q_0] (q_1) {B};\n   \\node [state, accepting, right of=q_1] (q_2) {C};\n    \\path[->]\n    (q_0) edge node {x} (q_1)\n    (q_1) edge node {y} (q_2)\n          edge [loop above] node {x} ()\n    (q_2) edge [loop above] node {y} ();\n\\end{tikzpicture}\n\n}\n\nIf you would like to learn more about FSAs, I recommend the Wikipedia page.\nOutside the ACSL bubble, automata and finiteness\nare an important field of research in theoretical CS\\@.\nThey connect back to problems such as P vs. NP and whether a program\nwill stop in a reasonable amount of time or even in an infinite amount of time.\n\n\\paragraph{Testing regex syntax.}\nIf you would like to practice regex and have your code actually\nmatched against strings, I recommend \\href{https://regexr.com/}{this} website.\n\n\\section{Exercises}\n\\subsection{Translate an FSA to a Regular Expression}\n\\label{par:translate}\n\\begin{enumerate}\n\\item Find a simplified Regular Expression for the following FSA:\n\n{\\centering\n\\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n   \\node [state,initial,initial text=] (q_0) {};\n   \\node [state, right of=q_0] (q_1) {};\n   \\node [state, right of=q_1] (q_2) {};\n   \\node [state, accepting, right of=q_2] (q_3) {};\n    \\path[->]\n    (q_0) edge node {0} (q_1)\n    (q_1) edge node {0} (q_2)\n          edge [loop above] node {1} ()\n    (q_2) edge node {1} (q_3);\n\\end{tikzpicture}\n\n}\n\n\\item Find a simplified Regular Expression for the following FSA:\n\n{\\centering\n\\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n   \\node [state,initial,initial text=] (q_0) {};\n   \\node [state, above right=of q_0] (q_1) {};\n   \\node [state, below right=of q_0] (q_2) {};\n   \\node [state, accepting, below right=of q_1] (q_3) {};\n    \\path[->]\n    (q_0) edge node {a} (q_1)\n          edge node {b} (q_2)\n    (q_1) edge node {c} (q_3)\n    (q_2) edge node {c} (q_3);\n\\end{tikzpicture}\n\n}\n\n\\item List all of the following FSAs which represent 1*01*0:\n\n    \\begin{enumerate}\n    \\item\n    \\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n       \\node [state,initial,initial text=] (q_0) {};\n       \\node [state, right of=q_0] (q_1) {};\n       \\node [state, accepting, right of=q_1] (q_2) {};\n        \\path[->]\n        (q_0) edge [loop above] node {1} ()\n              edge node {0} (q_1)\n        (q_1) edge [loop above] node {1} ()\n              edge node {0} (q_2);\n    \\end{tikzpicture}\n\n    \\item\n    \\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n       \\node [state,initial,initial text=] (q_0) {};\n       \\node [state, accepting, right of=q_0] (q_1) {};\n        \\path[->]\n        (q_0) edge [loop above] node {1} ()\n              edge node {0} (q_1);\n    \\end{tikzpicture}\n\n    \\item\n    \\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n       \\node [state,initial,initial text=] (q_0) {};\n       \\node [state, right of=q_0] (q_1) {};\n       \\node [state, accepting, right of=q_1] (q_2) {};\n        \\path[->]\n        (q_0) edge [loop above] node {0,1} ()\n              edge node {1} (q_1)\n        (q_1) edge [loop above] node {0,1} ()\n              edge node {0} (q_2);\n    \\end{tikzpicture}\n\n    \\item\n    \\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]\n       \\node [state,initial,initial text=] (q_0) {};\n       \\node [state, above right=of q_0] (q_1) {};\n       \\node [state, below right=of q_0] (q_2) {};\n       \\node [state, accepting, below right=of q_1] (q_3) {};\n        \\path[->]\n        (q_0) edge node {0} (q_1)\n              edge node {1} (q_2)\n        (q_1) edge [loop above] node {1} ()\n              edge node {1} (q_3)\n        (q_2) edge [loop below] node {0} ()\n              edge node {1} (q_3)\n        (q_3) edge [loop above] node {0} ();\n    \\end{tikzpicture}\n    \\end{enumerate}\n\\end{enumerate}\n\n\\subsection{Simplify a Regular Expression}\n\\label{par:simplify}\n\n\\subsection{Determine which Regular Expressions or FSAs are equivalent}\n\\label{par:equivalent}\n\\begin{enumerate}\n\\item Which, if any, of the following Regular Expressions are equivalent?\n    \\begin{enumerate}\n    \\item (a$\\cup$b)(ab*)(b*$\\cup$a)\n    \\item (aab*$\\cup$bab*)a\n    \\item aab*$\\cup$bab*$\\cup$aaba$\\cup$bab*a\n    \\item aab*$\\cup$bab*$\\cup$aab*a$\\cup$bab*a\n    \\item a*$\\cup$b*\n    \\end{enumerate}\n\\end{enumerate}\n\n\\subsection{Determine which strings are accepted by either an FSA or a Regular Expression}\n\\label{par:accepted}\n\\begin{enumerate}\n\\item Which of the following strings are accepted by the following Regular Expression     ``00*1*1U11*0*0''?\n    \\begin{enumerate}\n    \\item 0000001111111\n    \\item 1010101010\n    \\item 1111111\n    \\item 0110\n    \\item 10\n    \\end{enumerate}\n\\item Which of the following strings match the regular expression\npattern ``[A-D]*[a-d]*[0-9]''?\n    \\begin{enumerate}\n    \\item ABCD8\n    \\item abcd5\n    \\item ABcd9\n    \\item AbCd7\n    \\item X\n    \\item abCD7\n    \\item DCCBBBaaaa5\n    \\end{enumerate}\n\\item Which of the following strings match the regular expression\npattern ``Hi?g+h+[\\string^a-ceiou]''?\n    \\begin{enumerate}\n    \\item Highb\n    \\item HiiighS\n    \\item HigghhhC\n    \\item Hih\n    \\item Hghe\n    \\item Highd\n    \\item HgggggghX\n    \\end{enumerate}\n\\end{enumerate}\n\n\\section{Solutions}\n\n\\subsection{Answers for Section~\\ref{par:translate}}\n\\begin{enumerate}\n\\item 01*01\n\\item (a|b)c or ac $\\cup$ bc\n\\item a. The other choices correspond to 1*0, (0$\\cup$1)*1(0$\\cup$1)*0, and 01*10*$\\cup$10*10*\n\\end{enumerate}\n\n\\subsection{Answers for Section~\\ref{par:equivalent}}\n\\begin{enumerate}\n\\item B is different from the rest because it requires an ending `a'.\nE is different from the rest because it doesn't allow for alternating a's and b's.\nC and D are different because of the third `or' condition.\nUpon very close inspection, A and D are equivalent (check this carefully yourself).\nTherefore, A and D are the answers.\n\\end{enumerate}\n\n\\subsection{Answers for Section~\\ref{par:accepted}}\n\\begin{enumerate}\n\\item 0000001111111 and 10\n\\item ABCD8, abcd5, ABcd9, and DCCBBBaaaa5\n\\item HigghhhC, Highd, and HgggggghX\n\\end{enumerate}\n\\end{document}", "meta": {"hexsha": "301bbef9ab75f7a3684c3a722242e62a08dfd405", "size": 11090, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fsa-regex.tex", "max_stars_repo_name": "sanjit-bhat/AB-ACSL", "max_stars_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-12T03:01:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-12T03:01:29.000Z", "max_issues_repo_path": "fsa-regex.tex", "max_issues_repo_name": "sanjit-bhat/AB-ACSL", "max_issues_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fsa-regex.tex", "max_forks_repo_name": "sanjit-bhat/AB-ACSL", "max_forks_repo_head_hexsha": "ab9bf7e5526cc5863c0173ab518138dada2dc1ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.5448717949, "max_line_length": 114, "alphanum_fraction": 0.6834986474, "num_tokens": 3407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.4194258057560648}}
{"text": "\\documentclass[pre,aps,superscriptaddress,longbibliography,notitlepage]{revtex4-1}\n\n\\usepackage{amsmath,amsfonts,amssymb,bm,graphicx,hyperref,listings,xcolor,float,aligned-overset,hyperref,multirow,rotating}\n\\usepackage[ddmmyyyy,24hr]{datetime}\n\\setlength{\\parindent}{0pt}\n\\raggedbottom\n\n\\begin{document}\n\n\\title{Activity-driven dynamics algorithm}\n\\author{Yann-Edwin Keta}\n\\date{\\today, \\currenttime}\n\\maketitle\n\\tableofcontents\n\n\\section{Introduction}\n\nRef.~\\cite{mandal2020study} introduces ``activity-driven dynamics'' (ADD) from the observation that, for any given set of self-propulsion vectors, the time for the particles to reach a force-balanced state does not grow with the persistence time $\\tau_p$ of self-propulsion. Therefore, on the time scale of $\\tau_p$ and in the limit $\\tau_p \\to \\infty$, the particle configuation instantaneously adapts to changes of the self-propulsion -- the time evolution of the system is driven only by changes in the active forces, hence the name ``ADD''.\\\\\n\nThis separation of time scale, between (1) the evolution of the self-propulsion and (2) the movement towards a corresponding force-balanced state, is exploited in ADD by computing (1) for each time step of $\\mathcal{O}(\\tau_p)$ and (2) accordingly over a $\\tau_p$-independent time. It is therefore possible to reach the large-$\\tau_p$ limit with a dramatic reduction in computation time.\\\\\n\nRef.~\\cite{mandal2020extreme} describes an ``intermittent'' regime at intermediate persistence time and low active driving. Would this regime be the consequence of particles reaching a force-balanced state before the diffusion of self-propulsion directions destabilises the configuration, the ADD alorithm should be relevant to simulate it -- Ref.~\\cite{mandal2020study} applies ADD to study Eshelby-like events, which are presented in Ref.~\\cite{mandal2020extreme} as a characteristic of the intermittent regime.\\\\\n\nWe highlight some similarities with the ``athermal quasi-static random displacement'' (AQRD) method of Ref.~\\cite{morse2020direct} in which a random local strain vector is first associated to each particle, these are then moved quasi-statically in these directions, with a minimisation at each step to find the constrained local minimum of potential energy. This method is equivalent to self-propelled forcing in the limit of zero rotational noise, where the forcing is slower than any other relaxation process.\n\n\\section{ADD for inertial ABPs}\n\n\\subsection{Model}\n\nRefs.~\\cite{mandal2020study,mandal2020multiple} introduce the ADD algorithm for inertial active Brownian particles (ABPs) without thermal noise\n\\begin{eqnarray}\n\\label{orig-abpr}\nm \\ddot{\\boldsymbol{r}}_i(t) = - \\gamma \\dot{\\boldsymbol{r}}_i(t) - \\nabla_i U(t) + \\gamma v_0 \\boldsymbol{u}(\\theta_i(t))\\\\\n\\label{orig-abptheta}\n\\dot{\\theta }_i(t) = \\sqrt{2/\\tau_p} \\, \\eta_i(t)\n\\end{eqnarray}\nwith $\\boldsymbol{r}_i$ and $\\theta_i$ the position and orientation of the $i$-th particle, $m$ the particle mass, $\\gamma$ the friction coefficent, $U$ the interaction potential, $v_0$ the self-propulsion velocity, $\\boldsymbol{u}(\\theta_i) = (\\cos\\theta_i, \\sin\\theta_i)$, $\\tau_p$ the persitence time, and $\\eta_i$ a zero-mean unit-variance Gaussian white noise.\\\\\n\nRef.~\\cite{mandal2020study} highlights that $U$ can in general contain arbitrary many-body interactions.\\\\\n\nWe want to compute the dynamics on a time scaled by the persistence time\n\\begin{equation}\nt^{\\prime} = t/\\tau_p\n\\label{time-scale}\n\\end{equation}\nand thus rewrite Eqs.~\\ref{orig-abpr},~\\ref{orig-abptheta}\n\\begin{eqnarray}\n\\label{scaled-abpr}\nm\\frac{1}{\\tau_p^2} \\frac{\\mathrm{d}^2 \\boldsymbol{r}_i}{{\\mathrm{d}t^{\\prime}}^2}(t^{\\prime}) + \\gamma \\frac{1}{\\tau_p} \\frac{\\mathrm{d}\\boldsymbol{r}_i}{\\mathrm{d}t^{\\prime}}(t^{\\prime}) = - \\nabla_i U(t^{\\prime}) + \\gamma v_0 \\boldsymbol{u}(\\theta_i(t^{\\prime}))\\\\\n\\label{scaled-abptheta}\n\\frac{\\mathrm{d}\\theta_i}{\\mathrm{d}t^{\\prime}}(t^{\\prime}) = \\sqrt{2} \\, \\eta^{\\prime}_i(t^{\\prime})\n\\end{eqnarray}\nwith $\\eta^{\\prime}_i$ a zero-mean unit-variance Gaussian white noise in the scaled time variables ($\\eta_i^{\\prime} = \\sqrt{\\tau_p} \\eta_i$). In the $\\tau_p \\to \\infty$ limit, the left hand side of Eq.~\\ref{scaled-abpr} vanishes and the particle configuration thus always satisfies\n\\begin{equation}\n0 = -\\nabla_i \\left(U - \\sum_i v_0 \\boldsymbol{u}(\\theta_i) \\cdot \\boldsymbol{r}_i\\right) = - \\nabla_i U_{\\rm eff}\n\\label{Ueff}\n\\end{equation}\nhence minimising an effective potential tilted by the active forces $U_{\\rm eff}$.\n\n\\subsection{Numerical implementation}\n\nOrientation dynamics (Eq.~\\ref{scaled-abptheta}) is integrated first over a time step $\\delta t^{\\prime}$\n\\begin{equation}\n\\theta_i(t^{\\prime} + \\delta t^{\\prime}) = \\theta_i(t^{\\prime}) + \\sqrt{2 \\delta t^{\\prime}} \\, \\eta^{\\prime}_i\n\\end{equation}\nwhere $\\eta^{\\prime}_i$ is random number taken from a Gaussian distribution with zero-mean and unit-variance.\\\\\n\nPosition dynamics (Eq.~\\ref{scaled-abpr}) is then integrated with time step $\\Delta t$ to minimise $U_{\\rm eff}$ (Eq.~\\ref{Ueff}) -- this is done for a time $t_{\\rm min}$ until either (i) the total force on each particle falls below a threshold\n\\begin{equation}\n\\sqrt{\\frac{1}{N}\\sum_i \\left|-\\nabla_i U_{\\rm eff}\\right|^2} \\leq F_c\n\\label{force-threshold}\n\\end{equation}\nor (ii) the minimisation time $t_{\\rm min} \\propto \\Delta t$ reaches a threshold\n\\begin{equation}\nt_{\\rm min} \\leq t_{\\rm step}\n\\label{time-threshold}\n\\end{equation}\nand such that, in the $\\tau_p \\to \\infty$ limit, we have $t_{\\rm step} \\ll \\tau_p \\delta t^{\\prime}$.\\\\\n\nIn order to perform this minimisation, authors of Ref.~\\cite{mandal2020study} use the exponential Euler method \\cite{hochbruck2010exponential} on\n\\begin{eqnarray}\n\\dot{\\boldsymbol{v}}_i(t) = -\\frac{\\gamma}{m} \\boldsymbol{v}_i(t) + \\frac{1}{m}\\left[-\\nabla_i U(t) + \\gamma v_0 \\boldsymbol{u}(\\theta_i(t^{\\prime} + \\delta t^{\\prime}))\\right]\\\\\n\\dot{\\boldsymbol{r}}_i(t) = \\boldsymbol{v}_i(t)\n\\end{eqnarray}\nthus yielding\n\\begin{eqnarray}\n\\boldsymbol{v}_i(t + \\Delta t) = \\Gamma \\boldsymbol{v}_i(t) + \\frac{1}{\\gamma}(1 - \\Gamma)\\left[-\\nabla_i U(t) + \\gamma v_0 \\boldsymbol{u}(\\theta_i(t^{\\prime} + \\delta t^{\\prime}))\\right]\\\\\n\\boldsymbol{r}_i(t + \\Delta t) = \\boldsymbol{r}_i(t) + c_1 \\boldsymbol{v}_i(t) + c_2 \\left[-\\nabla_i U(t) + \\gamma v_0 \\boldsymbol{u}(\\theta_i(t^{\\prime} + \\delta t^{\\prime}))\\right]\n\\end{eqnarray}\nwhere\n\\begin{eqnarray}\nc_1 = \\frac{m}{\\gamma} \\left(1 - \\Gamma\\right)\\\\\nc_2 = \\frac{m}{\\gamma^2}\\left(\\frac{\\gamma \\Delta t}{m} - 1 + \\Gamma\\right)\\\\\n\\Gamma = \\exp\\left(-\\frac{\\gamma\\Delta t}{m}\\right)\n\\end{eqnarray}\nand $\\boldsymbol{v}_i$ is the velocity of $i$-th particle.\n\n\\section{ADD for overdamped AOUPs}\n\nRef.~\\cite{mandal2020study} already mentions the applicability of ADD to overdamped active Ornstein-Uhlenbeck particles (AOUPs). We develop here the corresponding equations and numerical implementation.\\\\\n\nWe consider overdamped AOUPs without thermal noise\n\\begin{eqnarray}\n\\label{orig-aoupr}\n\\dot{\\boldsymbol{r}}_i(t) = -\\nabla_i U(t) + \\boldsymbol{p}_i(t)\\\\\n\\label{orig-aoupp}\n\\dot{\\boldsymbol{p}}_i(t) = -D_r \\boldsymbol{p}_i(t) + \\sqrt{2 D D_r^2} \\, \\boldsymbol{\\eta}_i(t)\n\\end{eqnarray}\nwith $\\boldsymbol{r}_i$ and $\\boldsymbol{p}_i$ the position and propulsion vector of the $i$-th particle, $U$ the interaction potential, $D_r = \\tau_p^{-1}$ the rotational diffusivity, $D$ the translational diffusivity, and $\\boldsymbol{\\eta}_i$ a zero-mean unit-variance Gaussian white noise on each component -- note that we have set the mobility $\\mu = 1/\\gamma = 1$.\\\\\n\nOn the time scale (Eq.~\\ref{time-scale})\n\\begin{equation}\nt^{\\prime} = D_r t\n\\end{equation}\nwe then rewrite Eqs.~\\ref{orig-aoupr},~\\ref{orig-aoupp}\n\\begin{eqnarray}\n\\label{scaled-aoupr}\nD_r \\frac{\\mathrm{d}\\boldsymbol{r}_i}{\\mathrm{d}t^{\\prime}}(t^{\\prime}) = -\\nabla_i U(t^{\\prime}) + f \\tilde{\\boldsymbol{p}}_i(t^{\\prime})\\\\\n\\label{scaled-aoupp}\n\\frac{\\mathrm{d}\\tilde{\\boldsymbol{p}}_i}{\\mathrm{d}t^{\\prime}}(t^{\\prime}) = -\\tilde{\\boldsymbol{p}}_i(t^{\\prime}) + \\sqrt{2} \\, \\boldsymbol{\\eta}^{\\prime}_i(t^{\\prime})\\\\\nf = \\sqrt{D D_r}\n\\end{eqnarray}\nwith $\\boldsymbol{\\eta}^{\\prime}_i$ a zero-mean unit-variance Gaussian white noise in the scaled time variables ($\\boldsymbol{\\eta}^{\\prime}_i = \\sqrt{D_r^{-1}} \\boldsymbol{\\eta}_i$). In the $D_r^{-1} \\to \\infty$ limit, at constant $f = \\sqrt{D D_r}$, the left hand side of Eq.~\\ref{scaled-aoupr} vanishes and the particle configuration thus always satisfy\n\\begin{equation}\n0 = -\\nabla_i\\left(U - f \\sum_i \\tilde{\\boldsymbol{p}}_i\\cdot\\boldsymbol{r}_i\\right) = -\\nabla_i U_{\\rm eff}\n\\label{Ueff-aoup}\n\\end{equation}\nhence minimising an effective potential tilted by the active forces $U_{\\rm eff}$.\\\\\n\nWith the initial distribution, corresponding to steady state,\n\\begin{equation}\nP(\\tilde{\\boldsymbol{p}}_i(0)) = \\frac{1}{2 \\pi} \\exp\\left(-\\frac{1}{2} |\\tilde{\\boldsymbol{p}}_i(0)|^2\\right)\n\\end{equation}\npropulsion dynamics (Eq.~\\ref{scaled-aoupp}) is integrated first on a time step $\\delta t^{\\prime}$\n\\begin{equation}\n\\tilde{\\boldsymbol{p}}_i(t^{\\prime} + \\delta t^{\\prime}) = (1 - \\delta t^{\\prime}) \\tilde{\\boldsymbol{p}}_i^{\\prime} + \\sqrt{2 \\delta t^{\\prime}} \\, \\boldsymbol{\\eta}^{\\prime}_i\n\\end{equation}\nwhere $\\boldsymbol{\\eta}^{\\prime}_i = (\\eta^{\\prime}_{i, x}, \\eta^{\\prime}_{i, y})$ are two random numbers taken from a Gaussian distribution with zero-mean and unit-variance.\\\\\n\nPosition dynamics (Eq.~\\ref{scaled-aoupr}) is then integrated with time step $\\Delta t$ to minimise $U_{\\rm eff}$ (Eq.~\\ref{Ueff-aoup}), with the stopping conditions Eqs.~\\ref{force-threshold},~\\ref{time-threshold}\n\\begin{eqnarray}\n\\boldsymbol{r}_i(t + \\Delta t) = \\boldsymbol{r}_i(t) + \\Delta t\\left[-\\nabla_i U(t) + f \\tilde{\\boldsymbol{p}}_i(t^{\\prime} + \\delta t^{\\prime})\\right]\n\\end{eqnarray}\nwhere we have used Euler method, in analogy with Ref.~\\cite{mandal2020study}, although a FIRE minimisation \\cite{bitzek2006structural,guenole2020assessment} of $U_{\\rm eff}$ may also be appropriate.\\\\\n\nAt high packing fraction $\\phi$ and intermediate persitence time $D_r^{-1}$, we expect $|-\\nabla_i U|^2 = \\mathcal{O}(f^2)$ while $|\\dot{\\boldsymbol{r}}_i|^2 \\ll f^2$, therefore Eq.~\\ref{Ueff-aoup} also holds. ADD might thus also be suitable for this regime.\n\n\\section{Limits}\n\nAs we have introduced it, ADD relies on the separation of time scales between the propulsion dynamics and the relaxation to an effective potential energy minimum, hence making $\\tau_p \\to \\infty$ a necessary but not sufficient condition for the procedure to work.\\\\\n\nIn particular, at low density (dilute limit) and intermediate density (\\textit{e.g.}, such that MIPS may be observed), we do not expect the dynamics to be dominated by the minimisation of the effective potential.\n\n\\bibliography{ref}\n\n\\end{document}\n", "meta": {"hexsha": "12a8abd57d2afd90a467c9d1de02ac83226aaeb2", "size": 10815, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Summaries/add_mandal_sollich/main.tex", "max_stars_repo_name": "yketa/PhD_Wiki", "max_stars_repo_head_hexsha": "0ab35f22c03aca34445c555bc82c3bfb33f305ba", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-15T14:07:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-15T14:07:51.000Z", "max_issues_repo_path": "Summaries/add_mandal_sollich/main.tex", "max_issues_repo_name": "yketa/PhD_Wiki", "max_issues_repo_head_hexsha": "0ab35f22c03aca34445c555bc82c3bfb33f305ba", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Summaries/add_mandal_sollich/main.tex", "max_forks_repo_name": "yketa/PhD_Wiki", "max_forks_repo_head_hexsha": "0ab35f22c03aca34445c555bc82c3bfb33f305ba", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-09T16:34:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-09T16:34:29.000Z", "avg_line_length": 68.8853503185, "max_line_length": 546, "alphanum_fraction": 0.7251040222, "num_tokens": 3532, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.5888891307678321, "lm_q1q2_score": 0.4194257990754642}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Third Chapter **********************************\n%*******************************************************************************\n\\chapter{Internal Magnetic Fields}\n\n\\section{Solar Magnetic Field}\\label{mag_intro}\n\nIt is well known through the observation of much surface solar phenomenon like active regions, solar flares, coronal mass ejections etc, that the sun has in its interior, often highly localised, significant magnetic fields. The source of this magnetic field is theorised to be a primordial current which started a dynamo process that is kept going at the expense of continuous dissipation of energy from the solar bulk. It is also widely believed however that mean magnetic field throughout the solar bulk is fairly weak. This chapter is devoted to finding a method to observe signature of this magnetic field in the p-mode frequency spectrum.\n\nMost of high intensity magnetic activity is limited to the solar surface. The tachocline is believed to contain toroidal fields as high as $10^5 \\text{G}$. outside the tachocline the magnetic field is believed to be mostly dipolar such that mean surface magnetic field is about $10\\text{G}$. Very strong time varying local magnetic fields apart from these are also known to exist near the surface, but detection of such time dependent fields is outside the scope of this work; here we shall only investigate the effects of steady fields.\n\n%cite for tachocline B field\n%cite for fairly weak B field\n%cite for core B field\n%cite for dynamo\n\\section{Equation of Motion}\n\nIn the presence of background magnetic field $\\Bv$, the equation of motion is governed by the new operator $\\cL \\rightarrow \\cL + \\dL^{B}$, where $\\dL^B$ is estabished in \\cite{hanasoge17} as below.\n\\begin{align}\n    \\dLB \\boldsymbol{\\xi} &= \\frac{-1}{4\\pi}\\boldsymbol{\\nabla \\cdot} [\\Bv\\Bv\\cdot \\boldsymbol{\\nabla} \\boldsymbol{\\xi} + \\Bv {\\cdot} \\boldsymbol{\\nabla}\\boldsymbol{\\xi}\\Bv - 2 \\Bv\\Bv\\boldsymbol{\\nabla \\cdot}\\boldsymbol{\\xi} - (\\boldsymbol{\\xi \\cdot \\nabla} \\Bv)\\Bv - \\Bv(\\boldsymbol{\\xi \\cdot \\nabla}\\Bv)\\notag\n    \\\\& + B^2 \\boldsymbol{\\nabla \\cdot \\xi I} - \\Bv\\Bv :\\boldsymbol{\\nabla \\xi I} + \\boldsymbol{\\xi \\cdot \\nabla}\\frac{B^2}{2}\\boldsymbol{I}] \n     \\label{eqn:dLB}\n\\end{align}\nwhere the $:$ stands for contraction of two second rank tensors ($\\mathbf{P}:\\mathbf{Q} \\equiv P_{ij}Q_{ji} $).\n\nNote that in above expression $\\Bv$ only appears in the second order. \\cite{goedbloed2004} contains a detailed derivation of this and a proof of self adjointedness for $\\dL^B$.\n\nThis expression can be put in a more convenient form involving the Lorentz stress tensor $\\cH \\equiv \\Bv\\Bv$ as\n\\begin{equation} \\label{eqn: mag_pert_H}\n    \\dLB \\boldsymbol{\\xi} = \\frac{-1}{4\\pi}\\boldsymbol{\\nabla\\cdot} [\\boldsymbol{\\mathcal{H}\\cdot\\nabla \\xi} + (\\boldsymbol{\\nabla \\xi})^T \\boldsymbol{\\cdot \\mathcal{H}} - 2\\boldsymbol{\\mathcal{H}\\nabla \\cdot \\xi} - \\boldsymbol{\\xi \\cdot \\nabla \\mathcal{H}} + \\boldsymbol{\\mathcal{H}:I \\nabla \\cdot \\xi I} - \\cH{:}\\boldsymbol{\\nabla \\xi I} + \\boldsymbol{\\xi \\cdot \\nabla} \\enc{\\frac{\\cH{:}\\boldsymbol{I}}{2}}\\boldsymbol{I}]\n\\end{equation}\n\n\\section{Coupling Matrix}\n\\subsection{Lorentz Stress components}\\label{sec:lorentz_stress_comps}\nThe process of taking integrals over a sphere becomes simplified if we're operating in the Generalised Spherical Harmonics formalism. In this formalism (Appendix \\ref{app_gsh}), magnetic field and Lorentz stress are decomposed as\n$$\\Bv = \\sum_{st}\\sum_{\\alpha} B^{\\alpha}_{st}(r) Y_{st}^{\\alpha}(\\theta,\\phi) \\ev{\\alpha}$$\n$$\\cH = \\sum_{st}\\sum_{\\mu\\nu} h_{st}^{\\mu\\nu}(r) Y^{\\mu+\\nu}_{st}(\\theta,\\phi) \\ev{\\mu}\\ev{\\nu}$$\nwhere the generalised spherical harmonic (GSH) coordinate indices given by Greek symbols run from $-1$ to $+1$.\nEquation (\\ref{eqn:h_B_relation}) relates the components of $\\cH$ to $\\Bv$. $\\cH$ by construction satisfies the symmetry property $h^{\\mu\\nu}_{st} = h^{\\nu\\mu}_{st}$ ($\\because \\cH = \\Bv\\Bv$), and $\\enc{h^{\\mu\\nu}_{st}}^* = (-1)^t h_{s\\bar{t}}^{\\bar{\\mu}\\bar{\\nu}}$, where overbars represent negatives, follows from its realness condition.\n\n\\subsection{Sensitivity Kernels}\\label{sec:mag_kern}\nCoupling matrix element is given as on integral transform over $\\cH$ as\n\\begin{equation}\\label{lor_kernel_intro}\n\\LamB_{k'k} = \\inner{\\xiv_{k'}}{\\dLB\\xiv_{k}}=\\int_0^{R_{\\odot}} dr r^2 \\sum_{\\substack{st \\\\ \\mu\\nu}} \\cB_{st}^{\\mu\\nu}(r) h_{st}^{\\mu\\nu}(r)\n\\end{equation}\nwhere $\\cB_{st}^{\\mu\\nu}$ are the eigenfunction dependent magnetic sensitivity kernels. Prescription for evaluating these kernels and the explicit expressions can be found in \\cite{hanasoge17}. It should be noted however that the coupling integral $\\inner{\\xiv_{k'}}{\\dLB\\xiv_{k}}$ can be reduced to the radial integral form obtained in  (\\ref{lor_kernel_intro}) contains no boundary terms. It is indeed the case that the magnetic field is assumed to vanish at the surface in this analysis. Relaxing this assumption will introduce boundary terms which involve integrals only over the solar surface.\nSince $h_{st}^{\\mu\\nu}$ is symmetric in interchange of $\\mu$ and $\\nu$, we may ascribe the same symmetry to $\\cB_{st}^{\\mu\\nu}$ too without any loss in generality.\n\nUsing the Mathematica package developed for this work \\cite{GSH_repo} which automates manipulation of tensor spherical harmonics via the method of GSHs, the following forms of the kernels were found\n\n\\begin{dmath}\\label{eq:kern_mm}\n\\cB_{st}^{--} = \\frac{(-1)^{m'+1}}{r^2}\\gam{l}\\gam{l'}\\gam{s}\\wigred{-m'}{t}{m} \\enccrl{\\wigred{1}{-2}{1}\\om{l}{0}\\om{l'}{0} \\encsqr{\\enc{U+{\\om{l'}{2}}^2 V}V' - UU'-rV\\dot{V}'} +\\wigred{2}{-2}{0} \\om{l'}{0}\\om{l'}{2}\\encsqr{(U+r\\dot{U})V'-rU\\dot{V}'} +\\wigred{0}{-2}{2} \\om{l}{0}\\om{l}{2}rV\\dot{U}' + \\wigred{3}{-2}{-1} \\om{l}{0}\\om{l'}{0}\\om{l'}{2}\\om{l'}{3}VV'}   \n\\end{dmath}\n\n\\begin{dmath}\\label{eq:kern_0m}\n2\\cB_{st}^{0-} = \\frac{(-1)^{m'}}{r^2}\\gam{l}\\gam{l'}\\gam{s}\\wigred{-m'}{t}{m} \\enccrl{\\wigred{0}{-1}{1}\\om{l}{0}\\encsqr{\\enc{2U+{\\om{l'}{2}}^2 V}U' +{\\om{l'}{0}}^2 \\enc{-2UV'-VV'+rV\\dot{V}'} -r\\enc{U+V-r\\dot{V}'}\\dot{U}'} - \\wigred{1}{-1}{0}\\om{l'}{0}\\encsqr{(-2U+{\\om{l}{0}}^2V)U' + {\\om{l}{0}}^2V\\enc{r\\dot{V}'-V'} + U\\enc{2V' + r (\\dot{U}' - 2\\dot{V}' + r\\ddot{V}')}}  +\\wigred{-1}{-1}{2}\\om{l}{0}\\om{l'}{0}\\om{l}{2}V\\encsqr{U'-V'+r\\dot{V}'} + \\wigred{2}{-1}{-1}\\om{l}{0} \\om{l'}{0} \\om{l'}{2}\\encsqr{V\\enc{U'-3V'+r\\dot{V}'}+2r\\dot{V}V'}}  \n\\end{dmath}\n\n\\begin{dmath}\\label{eq:kern_00}\n\\cB_{st}^{00} = \\frac{(-1)^{m'}}{2r^2}\\gam{l}\\gam{l'}\\gam{s}\\wigred{-m'}{t}{m} \\enc{1+p}\\enccrl{\\frac{1}{2}\\wigred{0}{0}{0}\\encsqr{ \\enc{6U-4{\\om{l}{0}}^2 V-2 r \\dot{U}} \\enc{U'-{\\om{l'}{0}}^2V'} + 2{\\om{l'}{0}}^2 rU\\dot{V}' + r\\enc{\\enc{-4U+2{\\om{l}{0}}^2V+r\\dot{U}}}\\dot{U}'+rU\\ddot{U}' } -\\wigred{-1}{0}{1}\\om{l'}{0}\\om{l}{0} \\encsqr{V\\enc{-4U'+2\\enc{1+{\\om{l'}{0}}^2} V'+r\\enc{\\dot{U}'-2\\dot{V}'}} +2r\\dot{V}\\enc{U'-V'+r\\dot{V}'}}\n} \n\\end{dmath}\n\n\\begin{dmath}\\label{eq:kern_pm}\n2\\cB_{st}^{+-} = \\frac{(-1)^{m'}}{r^2}\\gam{l}\\gam{l'}\\gam{s}\\wigred{-m'}{t}{m}\\enc{1+p} \\enccrl{-2\\wigred{-2}{0}{2}\\om{l}{0}\\om{l}{2} \\om{l'}{0}\\om{l'}{2} VV' + \\wigred{-1}{0}{1}\\om{l'}{0}\\om{l}{0}\\encsqr{-rV\\dot{U}' + U \\enc{U'-V'+r\\dot{V}'}} \n+\\wigred{0}{0}{0}r^2\\encsqr{U\\ddot{U}'-\\dot{U}\\dot{U}'}\n}  \n\\end{dmath}\nwhere $p \\equiv (-1)^{l'+l+s}$, $U,V \\equiv U_{nl},V_{nl}$, and $U',V' \\equiv U_{n'l'},V_{n'l'}$.\n\\clearpage\nKernel components $\\cB_{st}^{\\mu\\nu}$ are found to have these following properties:\n\\begin{enumerate}\n\\item $\\cB_{st}^{\\mu\\nu} = \\cB_{st}^{\\nu\\mu}$ (by construction)\n\\item $\\cB_{st}^{--} = (-1)^{l+l'+s}\\cB_{st}^{++}$\n\\item $\\cB_{st}^{0-} = (-1)^{l+l'+s}\\cB_{st}^{+0}$\n\\item $\\cB_{st}^{00} = \\cB_{st}^{+-}=\\cB_{st}^{-+}=0$ for odd $\\enc{l'+l+s}$\n\\end{enumerate}\n\n\\begin{figure}[t]\n\\includegraphics[scale=0.55,center]{Chapter3/figs/kern_self.eps}\n\\caption{Self coupling Kernels for the modes $\\mode{4}{3}$, $\\mode{1}{10}$, and $\\mode{0}{20}$.}\n\\label{fig:kern_plot}\n\\end{figure}\n\nFigure (\\ref{fig:kern_plot}) shows the four independent components of the sensitivity kernel under self coupling for some modes. It is clear from the plots that for all modes, sensitivity is mostly localised to the solar boundary. This effect is most striking for $\\cB^{+-}_{st}$ across modes. This is a an indirect consequence of the background density profile of the sun which falls almost exponentially fast with respect to radius towards the outer regions of the sun. The low density near the boundary makes the eigenfunction peak distinctly near the boundary. However, as can be seen in equations (\\ref{eq:kern_mm}) - (\\ref{eq:kern_pm}), the kernels depend quadratically on $U$ and $V$, which finally makes them peak at the boundary. This implies that most of the magnetic splitting caused is due to the fields near the surface and acts as limitation to imaging the interior magnetic field precisely via an inversion of frequency splitting data.\n\nWe can see that how it is ultimately the components of $\\cH$ that couple with the sensitivity kernel; components of $\\Bv$ cannot be related to frequency splittings in a straightforward manner like equation (\\ref{lor_kernel_intro}). Hence, any procedure inverting splitting data will first determine the $\\cH$ components. It remains unclear if the magnetic field can be recovered from just the knowledge of components of $\\cH$.\n\n\\section{Synthetic Magnetic Field}\nUsing some basic pieces of information about mean solar magnetic field as given in \\ref{mag_intro}, we can posit the following form of a synthetic magnetic field which will be used for validating our routine of finding frequency splits. We give the following form of the magnetic field which is comoposed of an internal toroidal field concentrated at the core and the tachocline, and a dipolar field which extends from the tachocline to the surface.\n\n\\subsection{Construction of $\\Bv$}\\label{sec:B_construction}\nUsing the identities $\\grad_1 Y_l^m = \\om{l}{0} \\enc{Y_{lm}^{-1} \\ev{-} + Y_{lm}^{1} \\ev{+}}$, $\\ev{r} \\times\\grad_1 Y_l^m = i\\om{l}{0} \\enc{Y_{lm}^{-1} \\ev{-} - Y_{lm}^{1} \\ev{+}}$, and $Y_1^0(\\theta,\\phi) = \\gam{1}\\cos\\theta$ we see following things: (1) A toroidal field $\\Bv = \\alpha(r) \\sin\\theta \\ev{\\phi}$ can be given as $B_{10} = i \\alpha(r) / \\gam{1} \\enc{-1,0,1}$ with all other $B_{st}$ components being $0$, and (2) A dipolar field $\\Bv = \\beta(r) (2\\cos\\theta \\ev{r} + \\sin\\theta\\ev{\\theta})$ with $\\beta \\propto r^{-3}$ can be given as $B_{10} = -\\beta(r)/\\gam{1} \\enc{1,-2,1}$ with all other $B_{st}$ components being $0$. Note that the row vector refers to the GSH coordinate index $\\mu$. This leads to the following final form of $\\Bv$\n\n\\begin{equation}\\label{mag_field}\nB_{st}(r) = \n\\begin{cases}\n-i \\frac{\\alpha(r)}{\\gam{1}} \\gshvec{1}{0}{-1}  - \\frac{\\beta(r)}{\\gam{1}} \\gshvec{b-r\\dot{b}}{-2b}{b-r\\dot{b}}, & \\text{for} (s,t) = (1,0) \\\\\n0, & \\text{for} (s,t) \\neq (1,0)\n\\end{cases}\n\\end{equation}\nwhere $b(r)=1$ where field is perfectly dipolar. The term $r\\dot{b}(r)$ appear as a consequence of fixing the diveregence to zero and is only nonzero in the transition region where $b(r)$ goes from $0$ to $1$. It was can be checked via using $\\grad \\cdot \\Bv = g_{\\alpha\\beta} (\\grad\\Bv)^{\\alpha\\beta}$ (\\cite{GSH_repo} was used) that the two parts in (\\ref{mag_field}) (toroidal and dipolar) satisfy the solenoidal condition independently. We plot the forms of the $\\alpha$, $\\beta$, and $b$ used in our frequency splitting calculations.\n\n\\begin{figure}[t]\n\\begin{subfigure}{0.5\\linewidth}\n\\centering\n\\includegraphics[scale=.5]{Chapter3/figs/alpha_beta}\n\\caption{$\\alpha(r)$ and $b(r) \\beta(r)$ in $G$}\n\\label{fig:alpha_beta}\n\\end{subfigure}\n\\begin{subfigure}{0.5\\linewidth}\n\\centering\n\\includegraphics[scale=0.5,center]{Chapter3/figs/b}\n\\caption{$b(r)$ and $a(r) = b(r)-r\\dot{b}(r)$}\n\\label{fig:a_b}\n\\end{subfigure}\n\\caption{$\\alpha(r)$ is addition of two Gaussians centred at $r=0$ with peak $10^7 G$ and at $r=0.7R_{\\odot}$ with peak $10^5 G$ respectively. $b$ transitions smoothly from $0$ to $1$ as a sigmoid around $r=0.7R_{\\odot}$. $r=0.7R_{\\odot}$ mark is roughly where the tachocline is placed. Figure (\\ref{fig:alpha_beta}) shows the poloidal (dipolar) field $\\beta$ starting to dominate over the toroidal field by atleast three orders of magnitude as $r$ exceeds $\\sim 0.8 R_{\\odot}$.}\n\\end{figure}\n\n\\subsection{Construction of $\\mathcal{H}$}\n\nAfter the form of $\\Bv$ has been ascertained, it is straighforward to derive components of $\\cH$ via taking a tensor product. Decomposing either field in their GSH forms as in \\ref{sec:lorentz_stress_comps}, and using orthonormality relation\n\\begin{equation}\n\\int d\\Omega \\enc{Y_{l_1m_1}^{n_1}}^*Y_{l_2m_2}^{n_2} = \\delta_{l_1l_2}\\delta_{m_1m_2}\\delta_{N_1N_2}\n\\end{equation}\n\nand the triple integral result\n\n\\begin{equation}\\label{eq:triple_integral}\n\\int d\\Omega \\enc{Y_{l_1m_1}^{N_1}}^*Y_{l_2m_2}^{N_2}  Y_{l_3m_3}^{N_3}= (-1)^{m_1+N_1}4\\pi \\gam{l_1}\\gam{l_2}\\gam{l_3} \\wigfull{l_1}{l_2}{l_3}{-m_1}{m_2}{m_3} \\wigfull{l_1}{l_2}{l_3}{-N_1}{N_2}{N_3}\n\\end{equation}\n\none can write\n\\begin{equation}\nh^{\\mu\\nu}_{st} = \\sum_{\\substack{s_1t_1\\\\ s_2t_2}} \\langle Y_{st}^{\\mu+\\nu}, Y_{s_1 t_1}^{\\mu}  Y_{s_2 t_2}^{\\nu}\\rangle B_{s_1t_1}^{\\mu} B_{s_2t_2}^{\\nu}\n\\label{eqn:h_B_relation}\n\\end{equation}\nWhere $\\langle Y_{l_1m_1}^{n_1}, Y_{l_2m_2}^{N_2}  Y_{l_3m_3}^{N_3}\\rangle$ stands for the integral in equation (\\ref{eq:triple_integral}).\nIf $\\Bv$ has only $s=s_0$ and $t=t_0$ features, that is $\\Bv = \\sum_{\\alpha}B_{s_0t_0}^{\\alpha}Y_{s_0t_0}^{\\alpha} \\ev{\\alpha}$, components of $\\cH$ are given by\n\\begin{equation}\\label{eq:single_feature_B}\nh_{st}^{\\mu\\nu} = B^{\\mu}_{s_0 t_0}B^{\\nu}_{s_0 t_0} (-1)^{\\mu + \\nu + t} (2s_0+1) \\gam{s} \\wigfull{s_0}{s}{s_0}{\\mu}{-(\\mu+\\nu)}{\\nu} \\wigfull{s_0}{s}{s_0}{t_0}{-t}{t_0}\n\\end{equation}\n\nFor the axis symmetric magnetic field constructed in \\ref{sec:B_construction}, we may set $s_0=1$ and $t_0=0$. Wigner 3j selection rules given in \\ref{sec:selec_rules} dicate that $\\cH$ can only have $s=0,1,2$ and $t=0$. Then we have the form\n \t\n\\begin{equation}\nh_{s0}^{\\mu\\nu} = 3 \\gam{s} B^{\\mu}_{10}B^{\\nu}_{10} (-1)^{\\mu + \\nu} \\wigfull{1}{s}{1}{\\mu}{-(\\mu+\\nu)}{\\nu} \\wigfull{1}{s}{1}{0}{0}{0}\n\\end{equation}\n\nBut we know that $\\wigfull{1}{s}{1}{0}{0}{0}$ vanishes for odd s. Thus we note here that $\\cH$ has no $s=1$ and has non-zero $s=0$ components, which is different from how differential rotation couples modes. The $s=0$ feature of the Lorentz stress tensor indicates a net shift from the unperturbed mode frequency $\\omega_{{nl}}$ for a particular multiplet $\\mode{n}{l}$ as this term couples with $\\wigfull{l'}{0}{l}{-m}{0}{m}$ which is independent of $m$.", "meta": {"hexsha": "f22be5e70c9f679f9bf575c25bce19e618d53bec", "size": 14736, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "tuneerch/masters_thesis", "max_stars_repo_head_hexsha": "487646d71dc5f1f2bfbb8e29ee4878d14825c344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "tuneerch/masters_thesis", "max_issues_repo_head_hexsha": "487646d71dc5f1f2bfbb8e29ee4878d14825c344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "tuneerch/masters_thesis", "max_forks_repo_head_hexsha": "487646d71dc5f1f2bfbb8e29ee4878d14825c344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.5894039735, "max_line_length": 950, "alphanum_fraction": 0.6750814332, "num_tokens": 5300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.41942579188134776}}
{"text": "In this section we present our causal estimand, identifying assumptions, estimation strategy, and inferential procedure.\n\n\\subsection{Estimand}\n\nOur goal is to estimate the average effect 2014 Medicaid expansion would have had on the non-elderly adult uninsurance rate in states that did not expand Medicaid. Let $A$ indicate treatment assignment, $c$ index a CPUMA, $s$ index the state, and $t$ index the time period. Let $n_1$ be the number of treated CPUMAs, $n_0$ be the number of control CPUMAs, and $n$ be the total number of CPUMAs. Similarly, let and $m = m_1 + m_0$ states (with $m_1$ and $m_0$ defined analogously). Each state has $p_s$ CPUMAs. $A_s=0$ indicates untreated states and $A_s=1$ indicates treated states, when this notation is a superscript if it indicates the potential outcome. Since we are only interested in the counterfactual at time $T = 2014$, we simplify notation by removing this variable and the subscript and write our formal estimand as:\n\n\\begin{equation}\n\\psi = \\psi^1 - \\psi^0 &= n_0^{-1}\\sum_{s, c: A_s = 0} Y_{sc}^{A_s = 1} - Y_{sc}^{A_s = 0} \n\\end{equation}\n\nThe challenge is that we do not observe the counterfactual outcomes for non-expansion CPUMAs had they been in states that expanded their Medicaid programs. We therefore require causal assumptions to tie this counterfactual quantity to our observed data.\\footnote{The 2014 Medicaid expansion occurred simultaneously with the implementation of several other major ACA provisions, including (but not limited to) the creation of the ACA-marketplace exchanges, the individual mandate, health insurance subsidies, and community-rating and guaranteed issue of insurance plans (\\cite{courtemanche2017early}). Almost all states broadly implemented these reforms beginning January 2014. Conceptually we think of the other ACA components as a state-level treatment ($R$) separate from Medicaid expansion ($A$). Therefore, our total estimated effect may also include interactions between these policy changes; however, we do not attempt to separately identify these effects. Because the ACA implementation and Medicaid expansion may vary over time, we do not try to generalize these results beyond 2014.} \n\n\\subsection{Identification}\n\nThe following causal assumptions are necessary (though insufficient) to identify our target parameter from our observed data: the stable unit treatment value assumption (SUTVA), no unmeasured confounding, and no anticipatory treatment effects. We explain these assumptions in detail and their consequences below. We additionally invoke several parametric assumptions to help us identify our causal parameter given the measurement error in our covariates. These assumptions in total are sufficient to identify our causal estimand.\n\nSUTVA has two implications: first, that there is only one version of treatment; second, that $Y_{sc}^{\\mathbf{a}} = Y_{sc}^{\\mathbf{a}'}$ when $a_{sc} = a_{sc}'$, where $\\mathbf{a}$ is the vector of all treatment assignments. We discussed potential violations of the first assumption previously when considering how to reduce Medicaid Expansion to a binary treatment classification. Our solution is to remove states with less restrictive Medicaid eligibility requirements prior to 2014 to approximately satisfy this condition. The second part of this assumption implies that the potential outcomes in each region do not depend on another region's treatment assignment. This is a standard assumption, but is often not realistic in practice. Violations are likely in our setting: for example, \\cite{frean2017premium} find evidence that Medicaid expansion drove previously eligible but uninsured individuals to enroll in Medicaid in both expansion and non-expansion states. Signing the potential bias from this violation requires redefining the causal estimand: for example, we might consider the treatment effect on the untreated given that all states have expanded Medicaid, where the contrast is against where only the observed expansion states expanded Medicaid. If the spillover effects were equal in each region, and the magnitude of the spillovers increase with the total number of treated regions, then the true effect would be larger in absolute magnitude than the estimated effect using the observed data. We could consider other estimands or assumptions to get different predictions about the sign of the bias; however, this is beyond the scope of this paper.\n\nWe next assume that there were no anticipatory treatment effects. Letting treatment occur at time $T$, we have that for $t < T$:\n\n\\begin{align*}\nY_{sct} = Y_{sct}^0\n\\end{align*}\n\nThis assumption is necessary because we will condition on pre-treatment outcomes. If these outcomes were affected by the treatment before it were implemented, these covariates would be endogenous. Anticipatory treatment effects may occur if plans to expand Medicaid induce uninsured but Medicaid-eligible individuals to enroll in Medicaid prior to expansion. We do not think these violations occurred in large enough numbers to substantially affect our results. Instead, we address a more concerning version of this violation: the fact that several states allowed certain counties to expand Medicaid prior to 2014. We test the sensitivity of our results to the exclusion of these states.\n\nThird, we assume no unmeasured confounding; that is, that at time $T$ the potential outcomes for each CPUMA are independent of the state-level treatment assignment conditional on the population-level CPUMA and state-level covariates $X_{sc}$, a $q$ dimensional vector of covariates (which includes pre-treatment outcomes):\n\n\\begin{align*}\nY_{sc}^a \\perp A_{sc} \\mid X_{sc}\n\\end{align*}\n\nWhile unverifiable, we believe it is reasonable here given our rich covariate set. To be explicit, we believe that the pair of potential uninsurance rates for each CPUMA are independent of the treatment assignment conditional on the percentage of uninsured individuals in each year of the pre-treatment period, the percentage of unemployed individuals in each year of the pre-treatment period, the average population growth, the average ratio of households to non-elderly adult population, the state's political composition, the average proportion of households with one, two, or three or more children during the pre-treatment period, the average proportion of households who did not respond about their number children, and the average proportion of individuals during the pre-treatment period with given demographics noted above (age group, sex, white, Hispanic ethnicity, U.S. citizenship, foreign born, income-to-poverty group (including non-response), disability status, urban residence, and educational attainment group). \n\nA key problem we address in this paper is the violation of this assumption due to measurement error in our covariates. Let \n$X = (X_0, X_1)^T$ be the $n$ by $q$ matrix of true covariates (and separating the control from treated units using $X_a$). Because our covariates are estimated using the ACS data, rather than $(Y, X)$, we instead observe $(J,W)$, which consist of estimates of the true outcome and covariate values, where $W$ is structured analogously to $X$. Importantly, $Y_{sc}^a \\perp A_{sc} \\mid X_{sc} \\centernot\\implies J_{sc}^a \\perp A_{sc} \\mid W_{sc}$. The use of these proxies may therefore bias our estimates. We rely on several modeling assumptions to correct for this.\n\nWe first model our observed data as functions of the true values plus mean-zero Gaussian noise: $J_{sc} = Y_{sc} + \\xi_{sc}$ and $W_{sc} = X_{sc} + v_{sc}$, where we assume $\\xi_{sc}$ and $v_{sc}$ are independent though not identically distributed.\\footnote{Our covariates are almost all ratio estimates, which will in general be biased. This bias, however, decreases quickly with the sample size (is $O(n^{-1})$). Given that our CPUMA sample sizes are all over 300, we treat these estimates as unbiased in our analysis.} We assume that these errors are uncorrelated with the true values, i.e. $\\mathbb{E}\\{\\xi_{sc} \\mid Y_{sc}\\} = 0$ (and similarly for all elements of $X$). Second, we assume that $\\xi_{sc}$ are uncorrelated with the errors in the covariate measurements. These assumptions and our model for the observed data are reasonable given that the measurement error in this context is sampling variability. Moreover, our outcomes are measured on a different cross-section than our covariates, so it is reasonable to assume that they are uncorrelated with the measurement errors in the covariates. \n\nWe next assume that the true potential outcomes are linear in the true covariates $X_{sc}$. Specifically, we assume that the following model generates the potential non-elderly adult uninsurance rate under treatment $A = a$:\n\n\\begin{equation}\\label{eqn:outcomemodel}\nY_{sc}^a = \\alpha_a + X_{sc}^T\\beta_a + \\epsilon_{sc} + c_s\n\\end{equation}\n\nWe assume that the errors $\\epsilon_{sc}$ and $c_s$ are mean-zero, independent from each other and across time (i.e., we rule out serial-correlation), and are uncorrelated with the true covariates and the treatment assignment, i.e. $\\mathbb{E}\\{\\epsilon_{sc}c_s \\mid X_{sc}, A_s\\} = \\mathbb{E}\\{\\epsilon_{sc} \\mid X_{sc}, A_s\\} = \\mathbb{E}\\{c_s \\mid X_{sc}, A_s\\} = 0$. We can then identify $\\psi^a$ in terms of our model parameters (see Appendix A); specifically, we have that $\\psi^a = \\alpha_a + \\bar{X}_0^T\\beta_a$, where $\\bar{X}_0$ is the vector of mean covariate values among the control units. Moreover, we can substitute $J_{sc}$ for $Y_{sc}$ in Equation~\\ref{eqn:outcomemodel}, and add $\\xi_{sc}$ to the error term without affecting identification. \n\nWe still have the problem that we observe $W_{sc}$ instead of $X_{sc}$. Let $\\eta_a = \\mathbb{E}\\{X_{sc} \\mid W_{sc}, A_s = a\\}$. By linearity, we know that\n\n\\begin{equation}\n    J_{sc} = \\eta_a(W_{sc})^T\\beta + (X_{sc} - \\eta_a(W_{sc}))^T\\beta + \\xi_{sc} + \\epsilon_{sc} + c_s \n\\end{equation}\n\nIf we knew $\\eta_a$, we could estimate this model using the observed data $(J, W)$. The approach we follow here is known as ``regression calibration'' in the measurement-error literature. In particular, we assume a linear model for $\\eta_a$:\n\n\\begin{align*}\n\\eta_a(W_{sc}) = \\upsilon_a + \\kappa_a^T(W_{sc} - \\upsilon_a)\n\\end{align*}\n\nwhere $\\kappa_a = (\\Sigma_{XX \\mid A = a} + \\Sigma_{vv \\mid A = a})^{-1}\\Sigma_{XX \\mid A = a}$. The assumption motivating this model is that $(X_{sc}, v_{sc}) \\stackrel{iid}\\sim MVN((\\upsilon_a, 0), \\Sigma_a)$ and $\\Sigma_a$ is a $2q$ by $2q$ block-diagonal matrix consisting of $q$ by $q$ matrices $\\Sigma_{XX \\mid A = a}$ and $\\Sigma_{vv \\mid A = a}$ and $0$ in the off-diagonals. Given sufficient auxillary data to estimate $\\kappa_a$, we can then estimate $\\psi$. We discuss this further below and in Appendices A and B (see also \\cite{gleser1992importance}).\n\n\\subsection{Estimation}\n\nWe outline our estimation strategy first emphasizing how estimating the ETC differs from estimating the ETT with respect to variable selection under the ``synthetic controls'' framework and associated assumptions required. Second, we explain our estimation procedure, which modifies the SBW criterion to address the hierarchical data structure. This objective, which we call H-SBW, reduces the variance of our estimator under our assumption of constant variance and constant within-state correlation of model errors. Third, we connect our estimator to the regression calibration literature by generating weights that balance a linear prediction of the true covariates $\\hat{\\eta}_a(W_{sc})$ using the observed covariates $W_{sc}$. Fourth, we test the sensitivity of our estimator to a regression-augmented version, using ridge-regression weights following the suggestion of \\cite{ben2018augmented}; this allows us to achieve better covariate balance by extrapolating beyond the support of the data. We conclude by proposing a model validation procedure that uses pre-treatment outcomes to compare the performance of our estimators on pre-treatment data.\n\n\\subsubsection{Variable selection}\n\nWe seek to generate a set of positive weights that balance the means of covariates for the treated units to the mean covariates for the control units. Assume that we observe the true covariate matrices for the treated data $X_a = (X_{a,1}, ..., X_{a, q})$, and the true outcomes $Y$. Let $\\bar{X}_{0, r}$ be the mean covariate value for the $r$-th covariate in the non-expansion region. Ideally, there exists some $\\gamma^\\star \\in \\Gamma$ satisfying: \n\n\\begin{equation}\\label{eqn:constraint}\n\\Gamma = \\{\\gamma \\in \\mathbb{R}^{n_1}: &\\lvert \\gamma^TX_{1, r} - \\bar{X}_{0, r} \\lvert \\le \\delta_r \\ \\ (r = 1, ..., q), \\ \\gamma_{sc} > 0, \\sum_{s, c: A_{sc} = 1}\\gamma_{sc} = 1\\}\n\\end{equation}\n\nfor $\\delta_r = 0$ for all $r = 1, ..., q$. We could then estimate $\\psi$ as\n\n\\begin{equation}\\label{eqn:psi}\n\\hat{\\psi} = \\sum_{s: A_s = 1}^{m_1}\\sum_{c = 1}^{p_s}\\gamma_{sc}^\\star Y_{sc} - n_0^{-1}\\sum_{s: A_s = 0}^{m_0}\\sum_{c = 1}^{p_s}Y_{sc}\n\\end{equation}\n\nAgain assuming that the potential outcomes are a linear function of the true covariates: $\\mu_a(X_{sc}) = \\alpha_a + X_{sc}^T\\beta_a$, the bias of our estimate of $\\psi^1$ (again assuming we observed $X_{sc}$), is less than or equal to $\\lvert\\beta_1\\rvert^T\\delta = 0$ (see, e.g., \\cite{zubizarreta2015stable}). The challenge is that for any given dataset we have no guarantee that any such $\\gamma^\\star$ exists that exactly balances the covariates. We therefore often require some method of determining which parts of the covariate distribution we wish to prioritize balancing - or which covariates to balance at all - to minimize this bias.\n\nThe synthetic controls approach chooses the $\\gamma$ that minimizes the weighted L2-squared distance of the covariates using a diagonal weighting matrix $V$. $V$ is then chosen to minimize the mean-square error of the weighted difference in pre-treatment outcomes. Letting $Z_a$ be the matrix of pre-treatment outcomes for treatment group $A = a$, the synthetic controls algorithm solves the following optimization problem for a fixed $V$:\n\n\\begin{align}\n\\gamma(V) = \\arg\\min_{\\tilde{\\gamma}(V^\\star)} = (\\bar{X}_1 - X_0^T\\tilde{\\gamma})'V(\\bar{X}_1 - X_0^T\\tilde{\\gamma}) \n\\end{align}\n\nThis is the ``inner'' optimization. $V^\\star$ is then determined in an ``outer'' optimization to minimize the imbalances in the pre-treatment outcomes $Z$:\n\n\\begin{align}\n    V^\\star = \\arg\\min_V (\\bar{Z}_1 - Z_0^T\\gamma(V))'(\\bar{Z}_1 - Z_0^T\\gamma(V))\n\\end{align}\n\nIn applications the covariate matrix $X_a$ may contain some elements of $Z_a$. In cases where $X_a$ contains all pre-treatment outcomes, \\cite{kaul2015synthetic} has shown that the predictor weights $V^\\star$ will give no weight to auxillary covariates (covariates that are not the pre-treatment outcomes). \n\nWhile in practice $V$ is often learned on the same data as the weights, we consider the case where we use cross-validation to choose $V$, as proposed by \\cite{abadie2015comparative}. Assume we can divide our pre-treatment data into a training data from periods $T = 1, ..., T - l - 1$, a validation period from periods $T - l, ..., T - 1$, and a post-treatment period at time $T$. To make this discussion more general, assume that we are evaluating a set of candidate models $\\mathcal{M}$ on the validation data (where for the synthetic controls algorithm we can think of this as the set of all possible weighting matrices $V$). Let $\\bar{Y}^a_{a', t}$ be the mean potential outcome under treatment $A = a$ for treatment group $A = a'$ at time $t$ (where $t$ occurs during the validation period). Let $\\hat{\\bar{Y}}^a_{a'', t}(m)$ be an estimator of that potential outcome at time $t$ using model $m$, which was trained during the training period using data from treatment group $A = a''$. Finally, let $\\bar{Y}_{a'}^a_T$ be the post-treatment estimand, where $\\hat{Y}^a_{a'', T}(m)$ is the estimator using model $m$ trained using validation period data. This learning procedure implicitly assumes that:\n\n\\begin{align*}\nm^\\star = \\min_{m \\in \\mathcal{M}}\\sum_{T - l}^{T-1}\\|\\hat{Y}^0_{0, t}(m) - \\bar{Y}^0_{1, t}\\| = \\min_{m \\in \\mathcal{M}}\\mathbb{E}\\{\\|\\hat{Y}^0_{0, T}(m) - \\bar{Y}^0_{1, T}\\|\\}\n\\end{align*}\n\nIn other words, we select our model using the empirical loss in the validation period as a proxy for the expected loss in the post-treatment time-period.\\footnote{It is possible that multiple models in $\\mathcal{M}$ either perfectly predict the pre-treatment outcomes, or predict them equally well. In this case we would require an additional criteria to choose the optimal model (see, e.g, \\cite{becker2017cross}}. This makes intuitive sense in the typical synthetic controls setting where the estimand is the ETT since we observe $Y^0_{sct}$ for $t < T$. When synthetic controls are used to estimate the ETC, this strategy alone is insufficient as we never observe $Y^1_{sct}$ (or a mean-unbiased proxy) prior to treatment for any unit. We therefore cannot easily use pre-treatment outcomes to optimally select variables or determine relative covariate importance without stronger assumptions.\n\nOne such assumption is the following:\n\n\\begin{align*}\\label{assumption:second}\nm^\\star = \\min_{m \\in \\mathcal{M}}\\sum_{T - l}^{T-1}\\|\\hat{Y}^0_{1, t}(m) - \\hat{Y}^0_{0, t}\\| = \\min_{m \\in \\mathcal{M}}\\mathbb{E}\\{\\|\\hat{Y}^1_{1, T}(m) - \\bar{Y}^1_{0, T}\\|\\}\n\\end{align*}\n\nWe call this assumption ``counterfactual risk invariance.'' In other words, we assume that the model that minimizes the validation-period risk also minimizes the post-treatment risk. This is a very strong assumption for conducting any form of variable selection or covariate weighting in this setting. As a simple example, assume that we can partition $X = (R, S)$, where, for simplicity, we assume $S$ is univariate. Further assume that $Y^0_t \\perp A \\mid R$ for all $t = 1, ..., T$ but that $Y^1_T \\perp A \\mid X$. Again assume that $\\mu_a$ are linear in the covariates with (time-invariant) coefficients $\\beta_{a, r}$ ($r = 1, ..., q$). These assumptions imply that $\\beta_{0, s} = 0$. If our goal is to predict the ETT, then we wish to use the untreated data to predict $\\bar{Y}_{1, T}^0$. We may then conduct some variable selection procedure using our pre-treatment data, learn that covariate $S$ is unimportant, and estimate a model that downweights imabalances in $S$ (or ignores the covariate entirely) but perfectly balances the remaining covariates. This model would give an unbiased estimate of the counterfactual outcome for the treated group absent treatment in time-period $T$. However, if our goal were instead to predict $\\bar{Y}^1_{0, T}$ -- the counterfactual outcome under treatment for the untreated units -- the same procedure applied to the treated data would again downweight $S$ and result in a biased estimate, with bias equal to $(\\gamma^TS_1 - \\bar{S}_0) \\beta_{1, s}$. If $S$ is a strong predictor of treatment assignment, this could lead to substantial bias. \\footnote{We conflate two issues in this discussion: the synthetic controls variable weighting algorithm and variable selection more generally. Provided $S$ is contained in $X$ and exact balancing weights exist with high probability as $n \\to \\infty$, then under our modeling assumptions, the synthetic controls procedure is still consistent for $\\psi^1$ even if the variable weights $V$ are sub-optimal. However, if $S$ is not contained in $X$ at all, then this procedure will not balance these covariates even asymptotically provided that $\\mathbb{E}\\{S \\mid A = 1\\} \\ne \\mathbb{E}\\{S \\mid A = 0\\}$. However, here we take a finite-sample perspective. Imbalances in $S$ will lead to bias, whether or not $S$ is imbalanced due to receiving low weights on the weighting matrix $V$, or omitted from the objective entirely. Moreover, these two conditions are in the case where the optimal weight on covariate $S$, $V_s = 0$.} \n\nAs a practical example, we highlight the potential confounding role of Republican governance for our counterfactual estimate. Republican governance is a strong predictor of a state's decision to expand Medicaid \\cite{courtemanche2017early}. Moreover, existing evidence prior to Medicaid expansion showed that Medicaid take-up rates were lower in more conservative states \\cite{sommers2012understanding}. Yet when generating their synthetic control weights to estimate the ETT, \\cite{courtemanche2017early} and \\cite{kaestner2017effects} do not control for these factors. \\footnote{\\cite{courtemanche2017early} does control for Republican governor in their regression model and they find that it is a statistically significant predictor of 2013 uninsurance rates. One reason they may not control for this in the synthetic control model is practical: it is much harder to balance this covariate using control data without extrapolating from the data.} However, it is clear that if take-up rates depend on governance, we may expect this to be a strong confounder of $Y^1$ and hence confound the ETC, even if arguably it is not a confounder of $Y^0$ (and hence not a confounder for the ETT).\n\nWe demonstrate this in our application by conducting a variable importance analysis. Specifically, we remove the balance constraints from the Republican governance indicators and examine how our estimates of $\\hat{\\psi}^1$ change. Letting $\\hat{\\psi}^1_s$ be the estimate when removing the Republican governance indicators (or more generally, the covariate matrix $S$ where $X = (R, S)$). We subtract our original point estimate $\\hat{\\psi}^1_0$ from $\\hat{\\psi}^1_s$ to generate the difference $\\hat{\\Delta}^1$. This difference tells us about the direction of the bias our estimate of $\\hat{\\psi}^1$ would incur when we do attempt to constrain the imbalance in covariate $S$. Our hypothesis implies that we should expect $\\hat{\\Delta}_s^1 < 0$: that is, keeping all other covariates (roughly) fixed, we expect the predicted uninsurance rate will decrease when as the level of Republican governance decreases. In addition to the Republican governance indicators, we also examine four other covariate groups: pre-treatment uninsurance rates and pre-treatment unemployment rates, and three sets of different demographic indicators, which we detail in Appendix E.\\footnote{We caution that our results do not imply that Republican governance is not an important confounder of $Y^0_{1, T}$ since we do not analyze this directly.} \n\nOverall we emphasize that predicting the outcome under treatment is different, and perhaps more challenging, than predicting the outcome absent treatment. The former requires understanding which covariates matter most to predicting treatment response, which we cannot as naturally learn from pre-treatment outcomes. We instead rely on our prior knowledge and modeling assumptions to choose which covariates to balance and which covariates to prioritize in this balancing. We point out that modeling the ETC requires greater justification of the covariates used to predict treatment response than for the ETT, and that using the standard synthetic controls variable weighting procedure is unlikely to be optimal for this purpose.\\footnote{Our analysis assumes no unmeasured confounding and a linear model for $\\mu_a$. By contrast, synthetic controls are frequently motivated by a linear factor model for $\\mu_0$. \\cite{abadie2010synthetic} and \\cite{ferman2016revisiting} outline conditions where this method is consistent as the number of pre-treatment outcomes goes to infinity, in particular because the method balances the unobserved factor loadings. Analogous to our analysis, if we assume $\\mu_{a, T}$ both follow a linear factor model, identification of the ETC requires that the factors that confound $Y^1_T$ are the same that confound $Y^0_t$. Under this assumption, we might be able to show that the synthetic control estimator is consistent in this setting. However, the tuning procedure to determine the predictor weights may again be sub-optimal from a finite-sample bias perspective, depending again on how the covariates (or unobserved factors) that are most predictive of treatment response vary between treatment groups and on their associations with the potential outcomes.}\n\nGiven these challenges, we therefore use a variation of SBW to estimate the ETC.\\footnote{Specifically, we use a modified implementation of Noah Griefer's ``optweight'' package in R, available on github.com/mrubinst757} SBW minimizes the variance of the weights subject to user-specified balance constraints. The primary advantages of H-SBW over synthetic controls in this setting are that it gives the user finer control over the desired levels of covariate balance, allowing the user to navigate a bias-variance tradeoff with respect to balance and the variability of the weights. Specifically, SBW weights solve the following minimization:\n\n\\begin{equation}\n\\gamma &= \\arg\\min_{\\tilde{\\gamma} \\in \\Gamma} \\quad \\sum_{s: A_s = 1}^{m_1}\\sum_{c = 1}^{p_s} \\tilde{\\gamma}_{sc}^2  \n\\end{equation}\n\nwhere $\\Gamma$ is defined in Equation~\\ref{eqn:constraint}. We can then estimate $\\psi$ using Equation~\\ref{eqn:psi}, substituting $J_{sc}$ for $Y_{sc}$ and plugging in the weights $\\gamma$. By contrast, the synthetic controls algorithm will minimize the weighted L2 distance between the treated and control units in the criterion; this algorithm in general may lead to lower imbalances, but the balance tradeoffs are difficult to control, and the resulting weights may be more extreme. Finally, the algorithm, as formulated in \\cite{abadie2010synthetic} and presented above, may not have a unique solution (but see \\cite{ben2018augmented}, \\cite{becker2017cross}).\n\nFor our primary estimates we lean heavily on assumptions to justify our choice of $\\delta$. We use a priori domain knowledge about which covariates are most likely to be important predictors of treatment response when setting $\\delta$, but also choose $\\delta$ to avoid generating overly extreme weights. For our application, we constrain $\\delta$ to be 0.05 percentage points (out of 100) for pre-treatment outcomes, 0.15 percentage points for pre-treatment unemployment rates, and 25 percentage points for the Republican governance indicators. We believe these covariates are most likely to predict treatment response. While we believe that Republican governance is an important covariate to balance, we are unable to reduce the constraints further given the support of the data. For the remaining covariates, we let $\\delta$ be 0.5 percentage points for average population growth and household to adult ratio, 1 percentage point for female, Hispanic ethnicity, white race, age category, disability, and number of children category; 2 percentage points for urban, citizenship, education category, income-to-poverty category, student, and foreign-born, again choosing these constraints with respect to both feasibility and extreme weight concerns. \n\n\\subsubsection{H-SBW objective}\n\nThe motivation of the SBW criterion is to produce the minimum variance weights for a fixed $\\delta$. This produces the minimum variance estimator within the constraint set if, for example, the errors in the outcome model are independent and identically distributed \\cite{zubizarreta2015stable}. In our setting we allow for possible state-level dependencies, potentially reducing the efficiency of the SBW estimator. To address this possibility, we add the tuning parameter $\\rho \\in [0, 1)$ in the objective below. Assuming a constant variance across units for each error component, $\\rho$ represents a constant (and known) within-state correlation of the errors. \n\n\\begin{equation}\\label{eqn:objective}\n\\gamma &= \\arg\\min_{\\tilde{\\gamma} \\in \\Gamma} \\quad \\sum_{s: A_s = 1}^{m_1}(\\sum_{c = 1}^{p_s} \\tilde{\\gamma}_{sc}^2 + \\sum_{c \\ne d}\\rho \\tilde{\\gamma}_{sc}\\tilde{\\gamma}_{sd})\\\\\n\\end{equation}\n\nFor $\\delta \\to \\infty$, this objective yields the solution:\n\n\\begin{equation}\\label{eqn:sbwsol}\n\\gamma_{sc} \\propto \\frac{1}{(p_s - 1)\\rho + 1}\n\\end{equation}\n\nSetting $\\rho = 0$ returns the SBW solution: $\\gamma_{sc} \\propto 1$. By contrast, when setting $\\rho \\approx 1$, we see that $\\gamma_{sc} \\propto \\frac{1}{p_s}$. In other words, as we increase $\\rho$, this objective downweight CPUMAs in states with large numbers of CPUMAs and upweight CPUMAs in states with small numbers of CPUMAs (all while assigning each CPUMA within a state equal weight). Moreover, when $p_s$ is constant across states this objective will also the SBW solution. In short, as we increase $\\rho$, the objective will attempt to more uniformly disperse weights across states.\n\nAs a brief illustration, we simulate $N = 800$ observations in $m = 40$ regions each with $p_s = 20$ units, and draw $X_{sc} \\sim N(\\mu_s, 1)$, for $\\mu \\in \\{0, 1\\}$ (drawn from a Bernoulli with equal probability); $A_s \\sim Bern(expit(\\bar{X}_s))$, where $\\bar{X}_s$ is the mean covariate value in group $s$. We then generate weights to balance the control to the treated group mean. We run H-SBW variants setting $\\rho = 0$ (which is equivalent to SBW), $\\rho = 0.5$, and $\\rho = 0.99$ all while keeping $\\delta$ fixed at zero. Figure 1 shows the weights summed to the group level for all control regions. The color of each set of bars is the overall variance of the weights. We can see that the weights in general are uniform across units for SBW (the variance is lower); however, the weights are not uniformly dispersed across regions (the sum of weights within each region is not even). As we increase $\\rho$, the weights disperse more evenly across regions. Despite the increase in the variance of the weights, these weights are optimal under our assumed covariance structure. \n\n\\begin{figure}\n\\begin{center}\n    \\includegraphics[scale=0.5]{01_Plots/proofofconcept.png}\n    \\caption{Comparison of SBW and H-SBW: within group sum of weights}\n    \\label{oatepref}\n\\end{center}\n\\end{figure}\n\nThe particular covariance structure we assume is identical to the one proposed by \\cite{kloek1981ols}. In Appendix A, we show that this objective produces the minimum variance estimator under the constraint set for this correlation structure. We note that theoretically we could incorporate any other assumed covariance structure into this objective, though the number of tuning parameters might change. Broadly speaking, we can think of H-SBW being to SBW what generalized least squares (GLS) is to ordinary least squares (OLS): both SBW and OLS can produce unbiased estimates of model parameters; however, H-SBW and GLS can improve the efficiency of our estimates under different assumed correlation structures of the outcome errors.\n\n\\subsubsection{Measurement error}\n\nA second advancement in our estimation procedure comes in our balance constraints: rather than balancing on the observed covariate values $W_{sc}$, we instead balance on the imputed covariate estimates $\\hat{\\eta}_1(W_{sc})$ (we refer to these as the ``adjusted covariates''). This procedure attempts to correct for the estimation error in these CPUMA-level covariates that may bias our estimate of $\\psi^1$. In Appendix A, we consider the super-population target $\\psi^{1, sp} = \\mathbb{E}\\{Y^1 \\mid A = 0\\}$ and show that under the classical errors-in-variables model, the bias for the SBW estimator that balances on the observed covariates $W$ and sets $\\delta = 0$ is equivalent to the bias of a linear combination of coefficient estimates from the OLS-based regression estimator. Specifically, the bias for either estimator is:\n\n\\begin{equation}\n\\mathbb{E}\\{\\hat{\\psi}^{1} - \\psi^{1, sp}\\} = (\\upsilon_0 - \\upsilon_1)^T(\\kappa - I_d)\\beta_1\n\\end{equation}\n\nThe intuition for this result is as follows: exact balancing weights implicitly estimate $\\beta_1$ on a subset of the data where we have sufficient covariate overlap. We can therefore think of SBW as returning a solution to some weighted-least squares problem. Assuming that the outcome model holds across all of the data, WLS and OLS are estimating the same $\\beta_1$; therefore, the bias that effects the least squares solution will have the same effect on the WLS, and therefore SBW, solution. In Appendix A, Proposition 2, we show that if we had access to $\\eta_1$, we can obtain an unbiased estimate of $\\psi^{1, sp}$ by reweighting $\\eta_1(W_{sc})$.\\footnote{For the finite-sample parameter we're targeting, this estimator will have finite-sample bias conditional on $W$ and viewing $X$ as fixed.} Of course, in practice we do not know $\\eta_1$ but must instead estimate it using auxillary data. In Appendix A, Proposition 3, we show that we can obtain a consistent of $\\psi^{1, sp}$ when balancing on an estimate of $\\eta_1$ using auxillary data. \n\nThe key in our application is to estimate $\\eta_a$: at a high-level, we use the ACS micro-data replicate survey weights to estimate the covariance matrix of CPUMA sampling-variability $\\Sigma_{vv, sc}$. Using our observed data to estimate $\\Sigma_{WW \\mid A = a}$ and $\\bar{W}$, we combine these estimates to generate an estimate of $\\eta_a$. This is a technique that comes from the regression-calibration literature (see, e.g., \\cite{gleser1992importance}). We also consider an adjustment procedure that further accounts for the differential measurement error due to the highly variable sample sizes used to calculate each covariate. This procedure allows our adjustment to differentially adjust covariate values depending on the sample-sizes involved in the adjustment procedure. We refer to the first procedure the ``homogeneous adjustment'' and the second procedure the ``heterogeneous adjustment'' because the adjustment is constant for all units in the first case, but varies by unit in the second case. Further details about these procedures are available in Appendix B.\n\nThis is the first application we are aware of to use regression calibration in the context of balancing weights to address the problem of measurement error. We emphasize two critical assumptions for using this procedure in our context: (1) the outcome model is linear in the true covariates; and (2) the measurement error in the outcome is uncorrelated with the measurement error in the covariates. The first assumption is strong, though often used in practice. The second assumption is reasonable, because our outcomes are estimated from a different cross-section than our covariates. \n\n\\subsubsection{Bias-correction for imbalances}\n\nBecause we are unable to reduce the balance constraints to our preferred level without generating very extreme weights, following the recent literature on synthetic controls, we test the sensitivity of our results to the imbalances in the observed (or adjusted) covariates using ridge-regression augmented weights \\cite{ben2018augmented}. Letting $\\matr{\\hat{X}}_1$ be the matrix of adjusted covariates, and $\\gamma^{hsbw}$ be our H-SBW weights, we consider the regression-augmented weights:\n\n\\begin{equation}\n\\gamma^{aug} = \\gamma^{hsbw} + (\\gamma^{hsbw}\\hat{X}_1 - \\bar{W}_0)^T(\\hat{X}_1^T\\Omega^{-1}\\hat{X}_1 + \\lambda I_q)^{-1}\\hat{X}_1^T\\Omega^{-1}\n\\end{equation}\n\nwhere $\\Omega$ is a block diagonal matrix with diagonal entries equal to one and the within-group off diagonals equal to $\\rho$. We choose $\\lambda$ so that the remaining imbalances all fall within 0.5 percentage points. The cost of this procedure is that we must extrapolate off the support of the data, and therefore rely more heavily on our outcome modeling assumptions. We refer to \\cite{ben2018augmented} for more details about this procedure. In our results we consider estimators using SBW ($\\rho = 0$), H-SBW ($\\rho = 1/6$), and ridge-augmented versions of SBW and H-SBW that we call BC-SBW and BC-HSBW. \n\n\\subsection{Model validation}\n\nEarlier we argued that we cannot easily use pre-treatment outcomes to conduct variable selection or to learn about the relative importance of covariates. The challenge with using pre-treatment data in this setting is that it is not obvious why the best model of $\\bar{Y}_{0, t}^0$ $(t = T-l,..., T-1)$ should also be the best model, or even a good model, of $\\bar{Y}^1_{0,T}$. However, for fixed covariates and targeted levels of imbalance $\\delta$, we can use the heuristic that a good model of $\\bar{Y}^1_{0,T}$ should also be a good model of $\\bar{Y}_{0, t}^0$ to compare our models. We can also assume that when comparing two models, one with uniformly better covariate balance than the other, the model with better covariate balance should have lower bias both for $\\bar{Y}_{0, T}^1$ and $\\bar{Y}_{0, t}^0$ if our model assumptions are correct. We justify these comparisons by again assuming that $\\mu_{a, t}$ are linear in $X$ for all time periods $t$. This is a stronger assumption than we require to estimate the ETC, which only requires that $\\mu_{1, T}$ is linear in $X$. However, with this stronger assumption we can use pre-treatment data to at least heuristically compare our models. While we caution that these comparisons may not indicate the best model, we can still use these comparisons to see which models we may trust less.\n\nWe therefore rerun our procedures on pre-treatment data to compare the performance of our models for a fixed level of imbalances $\\delta$. In particular, we train our model on 2009-2011 data to predict 2012 outcomes, and 2010-2012 data to predict 2013 outcomes. We limit to one-year prediction error since our estimand is only one-year forward. We then examine the performance of the H-SBW versus SBW estimators, which only vary with respect to the tuning parameter $\\rho$, the bias-corrected versions, and the covariate adjustment procedure used to determine the weights. \n\nWe expect that the estimators trained on the adjusted data should perform better than the estimators trained on the unadjusted data. If our outcome model is correct, these estimators should achieve better balance across the true covariates and therefore have lower bias than the estimators trained on the unadjusted data. We assume that any difference between the performance of the two adjustments is due to better covariate balance on the true covariates. We therefore use the performance on this data to select which adjustment we prefer in our final results. Conditional on the adjustment, we assume that if the bias-corrected estimators all have uniformly better balance than the uncorrected estimators, these estimators should also perform better than the uncorrected estimators. However, if the assumed outcome models are incorrect, these estimators may suffer from extrapolation bias and perform worse despite achieving better covariate balance. Finally, we expect in general that H-SBW and SBW should have similar performance if we knew the true covariate values. However, in Appendix A, we show that for fixed (unobserved) $X$, these weighting estimators have a finite sample bias that reduces with the square of the weights, suggesting the SBW may have less bias than H-SBW. On the other hand, H-SBW should have less variability given within-state dependencies in the outcomes. From an MSE perspective it is unclear which should be optimal, and given only two-years of pre-treatment data we do not believe we can select which model is better.\n\n\\subsection{Inference}\n\nWe consider $W$ to be fixed (and $X$ as fixed unknown parameters), and we consider inference over repeated samples from some super-population of CPUMAs with a state-level dependency structure.\\footnote{Alternatively, viewing the potential outcomes as fixed and treatment assignment as random, we could consider inference over the randomization distribution of treatment at the state-level.} While placebo tests are frequently used in the synthetic controls literature for inference, we view these as qualitative statistical tests (see, e.g., \\cite{arkhangelsky2019synthetic}) and instead use the leave-one-state-out jackknife to estimate the variance of $\\hat{\\psi}^1$ (\\cite{cameron2015practitioner}). Specifically, we exclude each state and re-calculate the weights holding our targeted mean fixed at $\\bar{W}_0$.\\footnote{When our preferred initial choice of $\\delta$ does not converge, we gradually reduce the constraints until it does.} We compute this estimator in two ways: first, we condition on our covariate adjustment $\\hat{\\eta}_1$. This is our preferred estimator; however, it does not account for the randomness in $\\hat{eta}_1$. We therefore also conduct a second procedure where we re-estimate $\\hat{\\eta}_1$ for each state omitted in the jackknife procedure and provide these results in the Appendix.\n\nTo estimate $Var(\\hat{\\psi}^0 \\mid X, W)$ we use an auxillary regression model and use the CR-2 standard error adjustment (using the ``clubSandwich'' package in R) to estimate the variance of the linear combination $\\bar{W}_0^T\\hat{\\beta}_0$. We can estimate this quantity using the original (unadjusted) data given that $\\mathbb{E}\\{\\bar{W}_0^T\\hat{\\beta}_0\\} = \\psi^0$ (since the regression line runs through the point $(\\bar{W}_0, \\bar{J}_0)$, which are unbiased estimates of $(\\bar{X}_0, \\bar{Y}_0)$). Our total estimate $\\hat{Var}(\\hat{\\psi})$ is simply the sum of these two variance estimates. We use the standard normal quantiles to generate confidence intervals. \n", "meta": {"hexsha": "41265f41fbbb14761df32111c3ecdcec5f974f14", "size": 41206, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "03_Paper/03-methods.tex", "max_stars_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_stars_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "03_Paper/03-methods.tex", "max_issues_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_issues_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "03_Paper/03-methods.tex", "max_forks_repo_name": "mrubinst757/Medicaid-Expansion-Paper", "max_forks_repo_head_hexsha": "5d88f5975c29f0de0ad98fca274c23827c81dd42", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 213.5025906736, "max_line_length": 2514, "alphanum_fraction": 0.7743532495, "num_tokens": 10044, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4193925144200281}}
{"text": "\\BoSSSopen{ParameterStudy/ParameterStudy}\n\\graphicspath{{ParameterStudy/ParameterStudy.texbatch}}\n\n\\BoSSScmd{\nrestart;\n }\n\\BoSSSexeSilent\n\\BoSSScmd{\n/// This guide will give you an example of how to conduct a parameter study with\n/// all the necessary steps.  \n/// \\section{Initialization of solver, processor and workflow}\n/// We start with initializing of the workflow\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Initialization of solver, processor and workflow}\n/// We start with initializing of the workflow.\n }\n\\BoSSSexe\n\\BoSSScmd{\nBoSSSshell.WorkflowMgm.Init(\"Name of Workflow\");\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// This line helps us manage the sessions later on while evaluating the results. \n/// Next, we connect to the database.\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar myDb = CreateTempDatabase();\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// To check all the sessions in the current workflow, use the line:\n }\n\\BoSSSexe\n\\BoSSScmd{\nBoSSSshell.WorkflowMgm.Sessions;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// Now, all the necessary libraries need to be loaded\n }\n\\BoSSSexe\n\\BoSSScmd{\nusing System.Diagnostics;\\newline \nusing BoSSS.Foundation.Grid.RefElements;\\newline \nusing BoSSS.Application.XNSE\\_Solver;\\newline \nusing BoSSS.Platform.LinAlg;\\newline \nusing BoSSS.Solution.XdgTimestepping;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// As an execution queue, we select the first queue defined in \n/// the {\\tt $\\sim$/.BoSSS/etc/BatchProcessorConfig.json}-file:\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar myBatch = ExecutionQueues[0];\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Grid Generation}\n///Firstly, we need to determine the boundaries of our grid/control volume. \n///Is it important to know that the number of nodes (in our case $/code{k}$)\n///needed are equal\n/// to the number of cells $+1$. For instance, for $10$ cells we need $11$ nodes.\n/// In this example we will use the Cartesian $2D$ grid from the database\n/// which requires $x$- and $y$-Nodes. The J term in the code is for doing\n/// a check if the desired resolution of the volume is correctly typed.\n }\n\\BoSSSexe\n\\BoSSScmd{\nint k = 10;\\newline \ndouble[] xNodes = GenericBlas.Linspace(0, 1, k + 1);\\newline \ndouble[] yNodes = GenericBlas.Linspace(0, 1, k + 1);\\newline \nint J           = (xNodes.Length - 1)*(yNodes.Length - 1);\\newline \nstring GridName = string.Format(BoSSSshell.WorkflowMgm.CurrentProject + \"\\_J\" +J);\\newline \n \\newline \nConsole.WriteLine(\"Creating grid with \" + J + \" cells. \");\\newline \n \\newline \nGridCommons g;\\newline \ng      = Grid2D.Cartesian2DGrid(xNodes, yNodes);\\newline \ng.Name = GridName;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Define geometrical boundaries}\n/// After loading the grid and giving the dimensions, we need to adjust\n/// the edges and their names. With the following code we assign every edge with\n/// a number and name. Keep in mind that the name corresponds to the boundary \n///condition (in this case \"Pressure Dirichlet\").\n/// In this particular case we will use inflow profile represented\n/// via tan-function and the angle of inflow will be $30$ degrees.\n }\n\\BoSSSexe\n\\BoSSScmd{\nGridCommons g;\\newline \ng      = Grid2D.Cartesian2DGrid(xNodes, yNodes);\\newline \ng.Name = GridName;\\newline \n \\newline \ng.EdgeTagNames.Add(1, \"wall\");\\newline \ng.EdgeTagNames.Add(2, \"Velocity\\_Inlet\");\\newline \ng.EdgeTagNames.Add(3, \"Pressure\\_Dirichlet\\_back\");\\newline \ng.EdgeTagNames.Add(4, \"Pressure\\_Dirichlet\\_top\");\\newline \n \\newline \ng.DefineEdgeTags(delegate (double[] X) \\{\\newline \n\\btab byte ret = 0;\\newline \n\\btab if (Math.Abs(X[1]-(0.0))<= 1.0e-8)\\newline \n\\btab \\btab ret = 1;\\newline \n\\btab if (Math.Abs(X[0]-(0.0))<= 1.0e-8)\\newline \n\\btab \\btab ret = 2;\\newline \n\\btab if (Math.Abs(X[1]-(1.0))<= 1.0e-8)\\newline \n\\btab \\btab ret = 3;\\newline \n\\btab if (Math.Abs(X[0]-(1.0))<= 1.0e-8)\\newline \n\\btab \\btab ret = 4;\\newline \n\\btab return ret;\\newline \n \\newline \n \\});\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Angle/Velocity Profile}\n/// In this particular case we will use inflow profile represented via tan-function and the angle of inflow will be $30$ degrees.\n }\n\\BoSSSexe\n\\BoSSScmd{\nstring caseName = string.Format(\"k\\{0\\}\\_\\{1\\}\", k, g);\\newline \n \\newline \nConsole.WriteLine(\"setting up: \" + caseName);\\newline \n \\newline \ndouble beta    = 30;\\newline \nstring CosBeta = Math.Cos(beta*Math.PI/180.0).ToString();\\newline \nstring SinBeta = Math.Sin(beta*Math.PI/180.0).ToString();\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// These code lines set up the case name and introduce the sine and cosine \n/// functions to our simulation. Next, we define the velocities in \n/// $x$- and $y$-direction via a tan-function. These velocities and angles are only for this particular example and would not be suited for your simulation.\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar UX = new Formula\\newline \n\\btab (string.Format(\"X=> \\{0\\}*Math.Atan(X[1]*5)*2.0/Math.PI\",CosBeta),false);\\newline \nvar UY = new Formula \\newline \n\\btab (string.Format(\"X=> \\{0\\}*Math.Atan(X[1]*5)*2.0/Math.PI\",SinBeta),false);\n }\n\\BoSSSexe\n\\BoSSScmd{\n///After the velocities and boundary conditions are set. \n///We need to determine all other simulation parameters needed to proceed. \n//The variable $\\textbackslash code\\{ctrl\\}$ is used to store the $\\textbackslash code\\{IBM\\_Control\\}$-object.\\newline \n/// All other parameters are selfexplanatory.\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar ctrl = new XNSE\\_Control();\\newline \n//controls.Add(ctrl);\\newline \n \\newline \nctrl.SessionName = caseName;\\newline \nctrl.SetDatabase(myDb);\\newline \nctrl.SetGrid(g);\\newline \nctrl.SetDGdegree(k);\\newline \nctrl.NoOfMultigridLevels = int.MaxValue;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Boundary conditions/Initial values}\n/// We move on to the part where we define\n/// the boundary conditions and initial values.\n }\n\\BoSSSexe\n\\BoSSScmd{\nctrl.AddBoundaryValue(\"wall\");\\newline \nctrl.AddBoundaryValue(\"Velocity\\_Inlet\");\\newline \nctrl.AddBoundaryValue(\"Pressure\\_Dirichlet\\_back\");\\newline \nctrl.AddBoundaryValue(\"Pressure\\_Dirichlet\\_top\");\\newline \nctrl.AddBoundaryValue(\"Velocity\\_Inlet\",\"VelocityX\",UX);\\newline \nctrl.AddBoundaryValue(\"Velocity\\_Inlet\",\"VelocityY\",UY);\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// and for the initial values\n }\n\\BoSSSexe\n\\BoSSScmd{\nctrl.InitialValues.Add(\"VelocityX\", new Formula (\"X=> 0.0\", false));\\newline \nctrl.InitialValues.Add(\"VelocityY\", new Formula (\"X=> 0.0\", false));\\newline \nctrl.InitialValues.Add(\"Pressure\", new Formula (\"X=> 0.0\", false));\\newline \nctrl.InitialValues.Add(\"Phi\", new Formula (\"X=> -1.0\", false));\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Fluid properties}\n/// Here we set up the density and the Reynolds number,\n/// keep in mind that the calculations are dimensionles, \n/// so leave the values as seen above ($100$ is an example value)\n }\n\\BoSSSexe\n\\BoSSScmd{\ndouble reynolds               = 100;\\newline \nctrl.PhysicalParameters.rho\\_A = 1;\\newline \nctrl.PhysicalParameters.mu\\_A  = 1.0/reynolds;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Simulation options}\n/// We set the simulation parameters, such as time-step size,\n/// end time and number of time-steps.\n }\n\\BoSSSexe\n\\BoSSScmd{\nctrl.TimeSteppingScheme = TimeSteppingScheme.ImplicitEuler;\\newline \ndouble dt               = 7e-2;\\newline \nctrl.dtMax              = dt;\\newline \nctrl.dtMin              = dt;\\newline \nctrl.Endtime            = 1e16;\\newline \nctrl.NoOfTimesteps      = 100;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// for the time-stepping scheme, you can choose either BDF2 or ImplicitEuler.\n/// \\section{Starting of simulation}\n/// You have two possible ways to start a simulation\n/// - locally on the PC via $\\code{myBatch}$\n/// or on the network cluster $\\code{myHPC}$.\n }\n\\BoSSSexe\n\\BoSSScmd{\n \\newline \n//Console.WriteLine(\" Submitting to Cluster: \" + ctrl.SessionName);\\newline \n//ctrl.RunBatch(myHPC);\\newline \n \\newline \nConsole.WriteLine(\" Submitting \" + ctrl.SessionName);\\newline \nctrl.RunBatch(myBatch);\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Evaluation and Error Calculation}\n/// After all of the desired simulation are finished,\n/// you need to evaluate the different parameters and their effect on \n///the whole system. Typing the following command gives you a list of all \n///simulations with their status (FinishedSuccessful or with certain errors)\n }\n\\BoSSSexe\n\\BoSSScmd{\nBoSSSshell.WorkflowMgm.AllJobs.Select(kv => kv.Key + \": \\textbackslash t\" + kv.Value.Status);\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// With the next command line you are able to select a certain \n///session(simulation) and see the different time-steps for control purposes.\n }\n\\BoSSSexe\n\\BoSSScmd{\nBoSSSshell.WorkflowMgm.AllJobs.ElementAt(1).Value.Stdout;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\subsection{$L^2$-Error}\n/// This section introduces the calculation of the $L^2$-Error.\n }\n\\BoSSSexe\n\\BoSSScmd{\n ITimestepInfo[] AllSolutionS = BoSSSshell.WorkflowMgm.AllJobs.Select(kv => kv.Value.LatestSession.Timesteps.Last()).ToArray();\n }\n\\BoSSSexe\n\\BoSSScmd{\nITimestepInfo[] k1\\_SolutionS = AllSolutionS.Where(\\newline \n\\btab  ts = > ts.Fields.Single(\\newline \n\\btab \\btab    f = > f.Identification == \"Pressure\").Basis.Degree == 0).ToArray();\\newline \nITimestepInfo[] k2\\_SolutionS = AllSolutionS.Where(\\newline \n\\btab  ts = > ts.Fields.Single(\\newline \n\\btab \\btab    f = > f.Identification == \"Pressure\").Basis.Degree == 1).ToArray();\\newline \nITimestepInfo[] k3\\_SolutionS = AllSolutionS.Where(\\newline \n\\btab  ts = > ts.Fields.Single(\\newline \n\\btab \\btab    f = > f.Identification == \"Pressure\").Basis.Degree == 2).ToArray();\n }\n\\BoSSSexe\n\\BoSSScmd{\nk1\\_SolutionS.Select(\\newline \n\\btab  ts => ts.Fields.Single(\\newline \n\\btab \\btab    f = > f.Identification == \"Pressure\").Basis.Degree);\n }\n\\BoSSSexe\n\\BoSSScmd{\ndouble[] GridRes;\\newline \nDictionary<string, double[]> L2Errors;\\newline \nDGFieldComparison.ComputeErrors(\\newline \n\\btab  new[]\\{\"VelocityX\",\"VelocityY\"\\}, k1\\_SolutionS, out GridRes, out L2Errors);\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// To check the particular errors, type\n }\n\\BoSSSexe\n\\BoSSScmd{\nGridRes;\n }\n\\BoSSSexe\n\\BoSSScmd{\nL2Errors[\"VelocityX\"];\n }\n\\BoSSSexe\n\\BoSSScmd{\nL2Errors[\"VelocityY\"];\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Plotting of errors}\n/// This section gives a brief example of how to plot the erros \n/// and all the data from the previous simulations.\n }\n\\BoSSSexe\n\\BoSSScmd{\nPlot(GridRes,L2Errors[\"VelocityX\"],\"VelXErr\",\"-oy\",\\newline \n\\btab  GridRes,L2Errors[\"VelocityY\"],\"VelXErr\",\"-xb\",logX:true,logY:true);\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// for a plot with more specifics and more possible adjustments\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar FancyPlot = new Plot2Ddata();\n }\n\\BoSSSexe\n\\BoSSScmd{\nFancyPlot.LogX = true;\\newline \nFancyPlot.LogY = true;\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar k1plot = new Plot2Ddata.XYvalues(\\newline \n\\btab \"VelXErr-k1\",GridRes,L2Errors[\"VelocityY\"]);\n }\n\\BoSSSexe\n\\BoSSScmd{\nArrayTools.AddToArray(k1plot, ref FancyPlot.dataGroups);\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar CL = FancyPlot.ToGnuplot().PlotCairolatex();\n }\n\\BoSSSexe\n\\BoSSScmd{\nCL.PlotNow();\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// \\section{Exporting the session table}\n }\n\\BoSSSexe\n\\BoSSScmd{\nstatic class AddCols \\{\\newline \n\\btab static public object SipMatrixAssembly\\_time(ISessionInfo SI) \\{\\newline \n\\btab \\btab var mcr = SI.GetProfiling()[0];\\newline \n\\btab \\btab var ndS = mcr.FindChildren(\"SipMatrixAssembly\");\\newline \n\\btab \\btab var nd  = ndS.ElementAt(0);\\newline \n\\btab \\btab return nd.TimeSpentInMethod.TotalSeconds  / nd.CallCount;\\newline \n\\btab \\}\\newline \n\\btab static public object Aggregation\\_basis\\_init\\_time(ISessionInfo SI) \\{\\newline \n\\btab \\btab var mcr = SI.GetProfiling()[0];\\newline \n\\btab \\btab var ndS = mcr.FindChildren(\"Aggregation\\_basis\\_init\");\\newline \n\\btab \\btab var nd  = ndS.ElementAt(0);\\newline \n\\btab \\btab return nd.TimeSpentInMethod.TotalSeconds  / nd.CallCount;\\newline \n\\btab \\}\\newline \n\\btab static public object Solver\\_Init\\_time(ISessionInfo SI) \\{\\newline \n\\btab \\btab var mcr = SI.GetProfiling()[0];\\newline \n\\btab \\btab var ndS = mcr.FindChildren(\"Solver\\_Init\");\\newline \n\\btab \\btab var nd  = ndS.ElementAt(0);\\newline \n\\btab \\btab //Console.WriteLine(\"Number of nodes: \" + ndS.Count() + \" cc \" + nd.CallCount );\\newline \n\\btab \\btab return nd.TimeSpentInMethod.TotalSeconds / nd.CallCount;\\newline \n\\btab \\}\\newline \n\\btab static public object Solver\\_Run\\_time(ISessionInfo SI) \\{\\newline \n\\btab \\btab var mcr = SI.GetProfiling()[0];\\newline \n\\btab \\btab var ndS = mcr.FindChildren(\"Solver\\_Run\");\\newline \n\\btab \\btab var nd  = ndS.ElementAt(0);\\newline \n\\btab \\btab return nd.TimeSpentInMethod.TotalSeconds  / nd.CallCount;\\newline \n\\btab \\}\\newline \n\\}\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// this code adds additional/user-defined colums. Now, we want to export he \n/// saved session table in a file.\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar SessTab = BoSSSshell.WorkflowMgm.SessionTable;\n }\n\\BoSSSexe\n\\BoSSScmd{\nSessTab = SessTab.ExtractColumns(AllCols.ToArray());\n }\n\\BoSSSexe\n\\BoSSScmd{\nusing System.IO;\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// Here, we define the filename\n }\n\\BoSSSexe\n\\BoSSScmd{\nvar now           = DateTime.Now;\\newline \nSessTab.TableName = \"SolverRuns--\" + now.Year + \"-\" + now.Month + \"-\" + now.Day;\\newline \nstring docpath    = Path.Combine(CurrentDocDir, SessTab.TableName + \".json\");\n }\n\\BoSSSexe\n\\BoSSScmd{\n/// saving the session table as a file could also be done in our git reposatory\n }\n\\BoSSSexe\n\\BoSSScmd{\nSessTab.SaveToFile(docpath);\n }\n\\BoSSSexe\n\\BoSSScmd{\n///\n }\n\\BoSSSexe\n", "meta": {"hexsha": "f6f18cedf1b70a715fe1dbbd5ff5bf5e77fa678f", "size": 13227, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/handbook/ParameterStudy/ParameterStudy.tex", "max_stars_repo_name": "FDYdarmstadt/BoSSS", "max_stars_repo_head_hexsha": "974f3eee826424a213e68d8d456d380aeb7cd7e9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 22, "max_stars_repo_stars_event_min_datetime": "2017-06-08T05:53:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T13:12:17.000Z", "max_issues_repo_path": "doc/handbook/ParameterStudy/ParameterStudy.tex", "max_issues_repo_name": "FDYdarmstadt/BoSSS", "max_issues_repo_head_hexsha": "974f3eee826424a213e68d8d456d380aeb7cd7e9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-07-20T15:32:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-20T15:34:22.000Z", "max_forks_repo_path": "doc/handbook/ParameterStudy/ParameterStudy.tex", "max_forks_repo_name": "FDYdarmstadt/BoSSS", "max_forks_repo_head_hexsha": "974f3eee826424a213e68d8d456d380aeb7cd7e9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2018-01-05T19:52:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-07T07:49:27.000Z", "avg_line_length": 31.195754717, "max_line_length": 156, "alphanum_fraction": 0.7198155288, "num_tokens": 4049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6859494614282922, "lm_q1q2_score": 0.41937713530808945}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{braket}%量子力学符号\n\\usepackage{geometry}\n\\usepackage{enumerate}\n\\usepackage{natbib}\n\\usepackage{float}%稳定图片位置\n\\usepackage{graphicx,subfig}%画图\n\\usepackage{caption}\n\\usepackage[english]{babel}\n\\usepackage{indentfirst}%缩进\n\\usepackage{enumerate}%加序号\n\\usepackage{multirow}%合并行\n\\usepackage{hyperref}\n\\hypersetup{hypertex=true, colorlinks=true, linkcolor=black, anchorcolor=black, citecolor=black}\n\\title{\\Large \\textbf{VP390 Problem Set 3}\\\\\n\\author{\\textbf{Pan, Chongdan ID:516370910121}\\\\\n}\n}\n\\begin{document}\n\\maketitle\n\\section{Problem 1}\n\\begin{enumerate}[(a)]\n    \\item $|\\Psi(x,t)|^2=\\Psi(x,t)\\Psi^*(x,t)=Ce^{-\\frac{i}{\\hbar}Et}(x^2-a^2)Ce^{\\frac{i}{\\hbar}Et}(x^2-a^2)=C^2(x^2-a^2)^2$\n    \\\\ $|\\Psi(x,t)|^2=\\Phi(x)$ So $\\Psi$ represents a stationary state.\n    \\item $\\int_{-a}^a|\\Psi(x,t)|^2\\mathrm{d}x=\\int_{-a}^a C^2(x^2-a^2)^2\\mathrm{d}x=C^2(\\frac{2a^5}{5}-\\frac{4a^5}{3}+2a^5)=C^2\\frac{16a^5}{15}=1$\n    \\\\$C^2a^5=\\frac{15}{16}$\n    \\item $\\int_{-a/2}^{a/2} C^2(x^2-a^2)^2\\mathrm{d}x=C^2(\\frac{a^5}{80}-\\frac{a^5}{6}+a^5)=\\frac{203}{256}\\approx0.793$\n    \\item Since $\\Phi(x)$ is symmetric about $x$-axis, the probability is 0.5\n    \\item $\\braket{x}_\\Psi=\\int_{-\\infty}^\\infty x|\\Psi(x,t)|^2\\mathrm{d}x=\\int_{-a}^a C^2x(x^2-a^2)^2\\mathrm{d}x=0$\n    So it's time independent\n    \\item $\\bigtriangleup_x=\\sqrt{\\braket{x^2}_\\Psi-\\braket{x}_\\Psi^2}=C\\sqrt{\\int_{-a}^a x^2(x^-a^2)^2\\mathrm{d}x}=C\\sqrt{\\frac{30a^7}{105}-\\frac{84a^7}{105}+\\frac{70a^7}{105}}=\\sqrt{\\frac{a^2}{7}}$\n\\end{enumerate}\n\\section{Problem 2}\n\\begin{enumerate}[(a)]\n    \\item $E_1=13.6$eV, $a_0=\\frac{4\\pi\\epsilon_0\\hbar^2}{me^2}\\approx5.29\\times10^{-2}$nm\n    \\\\$\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi}\\int_0^\\infty\\Psi_{100}(r,\\varphi,\\theta,t)|^2\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\varphi=C^2\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi}\\int_0^\\infty r^2\\sin\\varphi\\exp(-\\frac{2r}{a_0})\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\varphi=2\\times2\\pi C^2\\frac{a^3}{4}$\n    \\\\$C=\\sqrt{\\frac{1}{\\alpha_0^3\\pi}}=1.467\\times10^{15}$\n    \\item $C^2\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi}\\int_0^{a_0} r^2\\sin\\varphi\\exp(-\\frac{2r}{a_0})\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\varphi=\\pi C^2(a^3-5a^3e^{-2})=1-5e^{-2}$\n    \\item The probability for the electron radius is $r$ can be expressed :\n    \\\\$C^2\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi} r^2\\sin\\varphi\\exp(-\\frac{2r}{a_0})\\mathrm{d}\\theta\\mathrm{d}\\varphi=4\\pi C^2r^2\\exp(-\\frac{2r}{a_0})$\n    \\\\$\\frac{\\mathrm{d}r^2\\exp(-\\frac{2r}{a_0})}{\\mathrm{d}r}=2r\\exp(-\\frac{2r}{a_0})-\\frac{2r^2}{a_0}\\exp(-\\frac{2r}{a_0})=0$\n    \\\\$r_1=0, r_2=a_0, r_3=\\infty$, since $r_1$ and $r_3$ can lead to the minium value of $r^2\\exp(-\\frac{2r}{a_0})$, only $r=\\alpha_0$ has the most probability value to find the electron\n    \\item $r_a=\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi}\\int_0^\\infty r\\Psi_{100}(r,\\varphi,\\theta,t)|^2\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\varphi=C^2\\int_{-\\pi/2}^{\\pi/2}\\int_0^{2\\pi}\\int_0^\\infty r^3\\sin\\varphi\\exp(-\\frac{2r}{a_0})\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\varphi$\n    \\\\$=4\\pi C^2\\frac{3a_0^4}{8}=\\frac{3a_0}{2}$\n    \\\\$\\bigtriangleup_r=\\sqrt{\\braket{r^2}_\\Psi-r_a^2}$\n    \\\\$\\braket{r^2}=4\\pi C^2\\int_0^\\infty r^4\\exp(-\\frac{2r}{a_0})\\mathrm{d}r=3\\pi C^2 a_0^5=3a_0^2$\n    \\\\$\\bigtriangleup_r=\\sqrt{3a_0^2-\\frac{9a_0^2}{4}}=\\frac{\\sqrt{3}a_0}{2}$\n    \\\\So the average value of $r$ is $\\frac{3a_0}{2}$, its standard deviation is $\\frac{\\sqrt{3}a_0}{2}$\n\\end{enumerate}\n\\section{Problem 3}\n\\begin{enumerate}[(a)]\n    \\item $\\braket{f,g}=\\int_{-\\infty}^\\infty f^*(u)g(u)\\mathrm{d}u=\\int_{-\\infty}^\\infty (g^*(u))^*f^*(u)\\mathrm{d}u=(\\int_{-\\infty}^\\infty g^*(u)f(u)\\mathrm{d}u)^*=\\braket{g,f}^*$\n    \\item $\\braket{f,\\alpha g}=\\int_{-\\infty}^\\infty f^*(u)\\alpha g(u)\\mathrm{d}u=\\alpha\\int_{-\\infty}^\\infty f^*(u)g(u)\\mathrm{d}u=\\alpha\\braket{f,g}$\n    \\item $\\braket{\\alpha f,g}=\\braket{g,\\alpha f}^*=\\alpha^*\\braket{g,f}^*=\\alpha^*\\braket{f,g}$\n\\end{enumerate}\n\\section{Problem 4}\n    \\begin{enumerate}\n        \\item $\\int_{-\\infty}^\\infty|\\psi|^2\\mathrm{d}x=\\int_0^L\\frac{2}{L}\\sin^2(\\frac{n\\pi x}{L})\\mathrm{d}x=\\frac{2}{L}(\\frac{L}{2}-\\frac{L\\sin 2n\\pi}{4n\\pi})=1$\n        \\\\So it is normalized\n        \\item $\\braket{\\psi_n,\\psi_m}=\\int_0^L\\frac{2}{L}\\sin\\frac{n\\pi x}{L}\\sin\\frac{m\\pi x}{L}\\mathrm{d}x=\\frac{1}{L}\\int_0^L\\cos\\frac{(n-m)\\pi x}{L}-\\cos\\frac{(n+m)\\pi x}{L}\\mathrm{d}x$\n        \\\\$=\\frac{1}{L}[\\frac{L\\sin(n-m)\\pi}{(n-m)\\pi}-\\frac{L\\sin(n+m)\\pi}{(n+m)\\pi}]=0$\n        \\item $\\braket{i\\psi_1,-3\\psi_1+2i\\psi_2-\\psi_3}=3i\\braket{\\psi_1,\\psi_1}-2\\braket{\\psi_1,\\psi_2}-i\\braket{\\psi_1,\\psi_3}=3i$\n        \\item Assume $x=x_1\\psi_1+x_2\\psi_2,y=y_1\\psi_1+y_2\\psi_2$ where\n        \\\\$x_1^2+x_2^2=1,y_1^2+y_2^2=1,x_1y_1+x_2y_2=0$\n        \\\\$x=\\frac{\\sqrt{2}}{2}\\psi_1-\\frac{\\sqrt{2}}{2}\\psi_2,y=\\frac{\\sqrt{2}}{2}\\psi_1+\\frac{\\sqrt{2}}{2}\\psi_2$\n    \\end{enumerate}\n\\section{Problem 5}\n    \\begin{enumerate}\n        \\item $\\braket{\\psi,\\psi}=\\frac{1}{2}[\\braket{e^{-\\frac{i}{\\hbar}E_1t}\\psi_1(x),e^{-\\frac{i}{\\hbar}E_1t}\\psi_1(x)}+\\braket{e^{-\\frac{i}{\\hbar}E_2t}\\psi_2(x),e^{-\\frac{i}{\\hbar}E_2t}\\psi_2(x)}]$\n        \\\\$\\frac{1}{2}(\\braket{\\psi_1,\\psi_1}+\\braket{\\psi_2,\\psi_2})=1$\n        \\\\So it's normalized\n        \\item $\\Psi(x,t)^*\\Psi(x,t)=\\frac{1}{2}(e^{\\frac{i}{\\hbar}E_1t}\\psi_1^*(x)+e^{\\frac{i}{\\hbar}E_2t}\\psi_2^*(x))(e^{-\\frac{i}{\\hbar}E_1t}\\psi_1(x)+e^{-\\frac{i}{\\hbar}E_2t}\\psi_2(x))$\n        \\\\$=\\frac{1}{2}(\\psi_1^*(x)\\psi_1(x)+\\psi_2^*(x)\\psi_2(x))+\\frac{1}{2}(e^{\\frac{i}{\\hbar}(E_1-E_2)t}\\psi_1^*(x)\\psi_2(x)+e^{\\frac{i}{\\hbar}(E_2-E_1)t}\\psi_1(x)\\psi_2^*(x))$\n        \\\\So the $\\Psi$ only describe a particle in a stationary state when $E_1=E_2$\n        \\item $\\Psi(x,t)=\\frac{1}{\\sqrt{2}}(\\cos\\frac{E_1t}{\\hbar}\\psi_1(x)-i\\sin\\frac{E_1t}{\\hbar}\\psi_1(x)+\\cos\\frac{4E_1t}{\\hbar}\\psi_2(x)-i\\sin\\frac{4E_1t}{\\hbar}\\psi_2(x))$\n        \\\\$T=\\frac{2\\pi}{\\omega}=\\frac{h}{E_1}$\n        \\\\if $|\\Psi(x,t+T)|^2=|\\Psi(x,t)|^2=$ then \n        \\\\$\\frac{1}{2}(e^{-\\frac{i}{\\hbar}3t}\\psi_1^*(x)\\psi_2(x)+e^{\\frac{i}{\\hbar}3t}\\psi_1(x)\\psi_2^*(x)=\\frac{1}{2}(e^{-\\frac{i}{\\hbar}3E_1(t+T)}\\psi_1^*(x)\\psi_2(x)+e^{\\frac{i}{\\hbar}3E_1(t+T)}\\psi_1(x)\\psi_2^*(x)$\n        \\\\$T=\\frac{2\\pi}{\\omega}=\\frac{h}{3E_1}$\n        \n    \\end{enumerate}\n\\end{document}", "meta": {"hexsha": "8747b79753cdcaa6374dd431735f5f2b75fcf0ae", "size": 6260, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "VP390ModernPhysics/HW/Assigments/HW3/HW3.tex", "max_stars_repo_name": "PANDApcd/Physics", "max_stars_repo_head_hexsha": "ed8171e5872ecef1d3e3e81935d71bc65063fc95", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "VP390ModernPhysics/HW/Assigments/HW3/HW3.tex", "max_issues_repo_name": "PANDApcd/Physics", "max_issues_repo_head_hexsha": "ed8171e5872ecef1d3e3e81935d71bc65063fc95", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "VP390ModernPhysics/HW/Assigments/HW3/HW3.tex", "max_forks_repo_name": "PANDApcd/Physics", "max_forks_repo_head_hexsha": "ed8171e5872ecef1d3e3e81935d71bc65063fc95", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.5238095238, "max_line_length": 292, "alphanum_fraction": 0.6033546326, "num_tokens": 3076, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.41937713138295624}}
{"text": "\\chapter{Technical Background}\\label{Chapter:Theory}\nThis chapter provides a brief technical overview of the models that we will frequently encounter in the rest of the thesis. A fundamental understanding of these systems is essential for appreciating the problems associated with them and the potential solution for overcoming those problems, which will be discussed in the subsequent chapters. \n\nThe key concepts of \\textbf{attention} and \\textbf{pondering}, whose conceptualization lies in the study of human reasoning are presented in this chapter as well. I elaborate on how these concepts have been the crucial first steps towards making deep neural networks think like human beings, thereby making their decision making process more interpretable. These concepts also serve as the backbone for the first major contribution of this thesis, which is presented in chapter \\ref{Chapter:proposals}.\n\nThis chapter concludes with an overview of formal language theory which is a prerequisite for understanding the theory behind creation of a new dataset - the second major contribution of this thesis which I present in chapter \\ref{Chapter:datasets}.\n\n\\section{RNN - A non linear dynamical system} \\label{RNN}\nWe frequently encounter data that is temporal in nature. A few examples would  be, audio signals, videos signals, time series of a stock price and natural language. While traditional feed-forward neural networks such as a multi-layer perceptron (MLP) \\citep{rosenblatt1962} are excellent at non linear curve fitting and classification tasks, it is unclear as to how they will approach the problem of predicting the value of a temporal signal $T$ at time $t$ given the states $T_{0}, T_{1}....T_{t-1}$ such that the states over time are not i.i.d. This is owing to the fact that a conventional feed-forward network  is acyclic and thus doesn't have any feedback loops rendering it memoryless. Human beings arguably solve such problems by compressing and storing the previous states in a \\lq working\\rq{} memory,\\citep{Miller1956} \\lq chunking\\rq{} it \\citep{neath2013} \\citep{craik2000} and predicting the state $T_t$. \n\nA Recurrent neural network (RNN) \\citep{Hopfield1982}\\citep{Elman1990} overcomes this restriction by having feedback loops which allow information to be carried from the current time step to the next. While the notion of implementing memory via feedback loops might seem daunting at first the architecture is refreshingly simple. In a process known as unrolling a RNN can be seen as a sequence of MLPs (at different time steps) stacked together. More specifically, RNN maintains a memory across time-steps by projecting the information at any given time step, $t$ onto a hidden(latent) state through parameters $\\theta$ which are shared across different time-steps. Figure \\ref{bck:rnn} shows a rolled and unrolled RNN cell and the equations of an RNN are as follows:\n\n\\begin{equation}\\label{nn-dynam}\nc_t = tanh(Ux_t + \\theta c_{t-1}),\n\\end{equation}\n\n\\begin{equation}\ny_t = softmax(Vc_t).\n\\end{equation}\n\n\\begin{figure}\n\t\\begin{minipage}[t]{\\textwidth}\n\t\t\\ifpdf\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/RNN-unrolled-pdf}\n\t\t\\else\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/RNN-unrolled-eps}\n\t\t\\fi\n\t\t\\caption{\\small Schematic of a RNN \\cite{olah}}\n\t\t\\label{bck:rnn}\n\t\\end{minipage}\n\\end{figure}\n\n\\section{BPTT and Vanishing Gradients}\nThe conventional method of training a feedforward neural network is a two step process. The first step is called the \\textbf{forward pass} when values fed at input layer pass through the hidden layers, are acted upon by (linear or non-linear) activations and come out at the output layer. In the second step called the \\textbf{backward pass}  the error computed at the output layer (from the target output) flows backward through the network i.e. by applying the chain rule of differentiation, the error gradient at output layer, is computed with respect to all possible paths right upto input layer and then aggregated. This method of optimization in neural networks is called \\textbf{backpropagation} \\citep{Rumelhart1986}.\n\nIn the case of an RNN the optimization step i.e. the backward pass over the network weights is not just with regards to the parameters at the final time step but over all the time steps across which the weights (parameters) are shared. This is known as Back Propagation Through Time (BPTT) \\citep{Werbos1990} and it gives rise to the problem of vanishing (or exploding) gradients in vanilla RNNs. This concept is better elaborated upon through equation in the following section.\n\n\\subsection{BPTT for Vanilla RNN}\n\\begin{equation}\n\\mathbf{\\mathcal{L}\\left(x,y\\right)} = - \\sum_{t}\\left(y_t \\log\\hat{y_t}\\right)\n\\end{equation}\n\n%\\begin{equation}\n%\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial \\alpha_t} = -\\left(y_t-z_t\\right)\n%\\end{equation}\nThe weight $W_{oh}$ is shared across all time steps. $\\therefore$ adding the derivatives across the sequence:\n\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial W_{oh}} = \\sum_{t}\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial \\hat{y_t}} \\frac{\\partial  \\hat{y_t}}{\\partial W_{oh}}\n\\end{equation}\n\n%\\begin{equation}\n%\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial b_z} = \\sum_{t}\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial z_t} %\\frac{\\partial  z_t}{\\partial b_z}\n%\\end{equation}\nFor time-step t $\\rightarrow$ t+1:\n\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hh}} = \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\hat{y}_{t+1}} \\frac{\\partial  \\hat{y}_{t+1}}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial W_{hh}}\n\\end{equation}\n\n$W_{hh}$ is shared across time steps, we take the contribution from previous time steps as well, for calculating the gradient at time $t+1$. Summing over the sequence we get:\n\n%\\begin{equation}\n%\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hh}} = \\frac{\\partial %\\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\hat{y}_{t+1}} \\frac{\\partial  \\hat{y}_{t+1}}{\\partial \\mathbf{h}_{t+1}} %\\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_t} \\frac{\\partial \\mathbf{h}_t}{\\partial W_{hh}}\n%\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hh}} = \\sum_{\\tau=1}^{t+1}\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\hat{y}_{t+1}} \\frac{\\partial  \\hat{y}_{t+1}}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_{\\tau}} \\frac{\\partial \\mathbf{h}_{\\tau}}{\\partial W_{hh}}\n\\end{equation}\n\nSumming over the whole sequence we get:\n\n\\begin{equation} \\label{vanishing}\n\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial W_{hh}} = \\sum_{t}\\sum_{\\tau=1}^{t+1}\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\hat{y}_{t+1}} \\frac{\\partial  \\hat{y}_{t+1}}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_{\\tau}} \\frac{\\partial \\mathbf{h}_{\\tau}}{\\partial W_{hh}}\n\\end{equation}\n\nFrom equation \\ref{vanishing} it is clear than the gradient of a RNN can be expressed as a recursive product of $\\frac{\\partial h_t}{\\partial h_{t-1}}$. \\textbf{If this derivative is $\\ll 1$ or $\\gg 1$, the gradient would vanish or explode respectively} when the network is trained over longer time-steps. In the former case error back-propagated would be too low to change the weights (the training would freeze) while in the latter it would never converge. \n\nAdditionally revisiting equation \\ref{nn-dynam} and rewriting it as follows:\n\\begin{equation}\\label{ndq}\t\nh^{(t)} = f(x^{(t)}, h^{(t-1)}),\n\\end{equation}\nit is not difficult to see that in the absence of an external input $x^{(t)}$ an RNN induces a a dynamical system. The RNN therefore, can be viewed as a dynamical system with the input as an external force (map) that drives it. A dynamical system can posses a set of points which are invariant under any map. These points are called the \\textbf{attractor states} of a dynamical system. These set of points can contain a single point (fixed attractor), a finite set of points (periodic attractor) or an infinite set of points (strange attractor). The type of attractor in a RNN unit depends on the initialization of the weight matrix for the hidden state \\citep{Bengio1993}. Now under the application of map (input) if $\\frac{\\partial h_t}{\\partial h_{k}}$ (for a large $t - k$ i.e. long term dependency), go to zero one can argue that the state $h_t$ is in the basin of one of the attractor states. This implies that in order to avoid the vanishing gradient problem a RNN cell must stay close to the \\lq boundaries between basins of attraction\\rq{} \\citep{Pascanu2012}.\n\nOwing to this problem of vanishing (or exploding) gradients a vanilla RNN can't keep track of long term dependencies which is arguably critical for tasks such as speech synthesis, music composition or neural machine translation. The architectural modifications which solved the vanishing gradient problem and are the current de-facto RNN cell(s) are presented in the next section.\n\n\n\\iffalse\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hx}} = \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial W_{hx}}\n\\end{equation}\n\n\\begin{equation}\n\\begin{split}\n\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hx}} & = \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial W_{hx}} + \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_t} \\frac{\\partial \\mathbf{h}_t}{\\partial W_{hx}} \\\\\n& = \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial W_{hx}} + \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_t}\\frac{\\partial \\mathbf{h}_t}{\\partial W_{hx}}\n\\end{split}\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial W_{hx}} = \\sum_{\\tau=1}^{t+1} \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_{\\tau}} \\frac{\\partial \\mathbf{h}_{\\tau}}{\\partial W_{hx}}\n\\end{equation}\n\n\\begin{equation}\n\\frac{\\partial \\mathbf{\\mathcal{L}}}{\\partial W_{hx}} = \\sum_{t} \\sum_{\\tau=1}^{t+1} \\frac{\\partial \\mathbf{\\mathcal{L}}\\left(t+1\\right)}{\\partial \\hat{y}_{t+1}} \\frac{\\partial \\hat{y}_{t+1}}{\\partial \\mathbf{h}_{t+1}} \\frac{\\partial \\mathbf{h}_{t+1}}{\\partial \\mathbf{h}_{\\tau}} \\frac{\\partial \\mathbf{h}_{\\tau}}{\\partial W_{hx}}\n\\end{equation}\n\\fi\n\n\\section{Gated RNNs}\nThe problem of vanishing (or exploding) gradients makes a vanilla RNN unsuitable for long term dependency modeling. However, if for instance, the RNN was to compute an identity function then the gradient computation wouldn't vanish or explode since the Jacobian is simply an identity matrix. Now while an identity initialization of recurrent weights by itself isn't  interesting it brings us to the underlying principle behind gated architectures i.e. the mapping from memory state at one time step to the next is close to identity function.\n\n\\begin{figure}[ht] \n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\ifpdf\n\t\t\\includegraphics[width=0.95\\linewidth]{./figs/Lstm-pdf}\n\t\t\\else\n\t\t\\includegraphics[width=0.95\\linewidth]{./figs/Lstm-eps}\n\t\t\\fi\n\t\t\\caption{LSTM\\citep{Zheng2017}}\n\t\t\\label{lstm} \n\t\t\\vspace{4ex}\n\t\\end{subfigure}%% \n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\ifpdf\n\t\t\\includegraphics[width=0.95\\linewidth]{./figs/Gru-pdf}\n\t\t\\else\n\t\t\\includegraphics[width=0.95\\linewidth]{./figs/Gru-eps}\n\t\t\\fi \n\t\t\\caption{GRU \\citep{olah}} \n\t\t\\label{gru}  \n\t\t\\vspace{4ex}\n\t\\end{subfigure}\n\t\\caption{Gated RNNs}\n\t\\label{conf}\n\\end{figure}\n\n\\subsection{LSTM}\nLong Short Term Memory (LSTM) introduced by \\cite{LSTM} is one of the two most widely used gated RNN architectures in use today. The fact that it has survived all the path-breaking innovations in the field of deep learning for over twenty years to still be the state of the art in sequence modeling speaks volumes about the architecture's ingenuity and strong fundamentals. \n\nThe fundamental principle behind the working of a LSTM is, to alter the memory vector only selectively between time steps such that the memory state is preserved over long distances. The architecture is explained as follows:\n\n\n\\begin{equation}\ni= \\sigma(x_t U^{(i)}, m_{t-1}W^{(i)})\n\\end{equation}\n\n\\begin{equation}\nf= \\sigma(x_t U^{(f)}, m_{t-1}W^{(f)})\n\\end{equation}\n\n\\begin{equation}\no= \\sigma(x_t U^{(o)}, m_{t-1}W^{(o)})\n\\end{equation}\n\n\\begin{equation}\n\\widetilde {c_t}= \\tanh(x_t U^{(g)}, m_{t-1}W^{(g)})\n\\end{equation}\n\n\\begin{equation}\nc_t = c_{t-1} \\odot f + \\widetilde{c_t} \\odot i\n\\end{equation}\n\n\\begin{equation}\nm_t = tanh(c_t) \\odot o\n\\end{equation}\n\n\\begin{itemize}\n\t\\item \\textbf{input gate $i^{(t)}$:} The input computes a new cell state based on the current input and the previous hidden state and decides how much of this information to ``let through\" via. a sigmoid activation.\n\t\\item \\textbf{forget gate $f^{(t)}$:} The forget gate decides what to remember and what to forget for the new memory based on the current input and the previous hidden state. The sigmoid activation acts like a switch where 1 implies remember everything while 0 implies forget everything.\n\t\\item \\textbf{output gate $o^{(t)}$:} The output gate then determines determines (via a sigmoid activation) the amount of this internal memory to be exposed to the top layers (and subsequent timesteps) of the network.\n\t\\item \\textbf{The input modulation $g^{(t)}$} computed based on the present input and the previous hidden state (which is exposed to the output) yields candidate memory for the cell state via a tanh layer. The hadamard products of input gate and candidate memories is added to the hadamard product of forget gate and previous cell state to yield the new cell state.\n\t\\item \\textbf{hidden state $m^{(t)}$:} A hadamard product of the hyperbolic tangent of current cell state and output gate yields the current hidden state.\n\\end{itemize}\n\n\\subsection{GRU}\nThe Gated Recurrent Unit (GRU) introduced by \\cite{GRU} are a new type of gated RNN architecture whose details are as follows:\n\n\\begin{equation}\nz_t= \\sigma(x_t U^{(z)}, m_{t-1}W^{(z)})\n\\end{equation}\n\n\\begin{equation}\nr_t= \\sigma(x_t U^{(r)}, m_{t-1}W^{(r)})\n\\end{equation}\n\n\\begin{equation}\n\\widetilde {m_t}= \\tanh(x_t U^{(g)},r_t \\odot m_{t-1}W^{(g)})\n\\end{equation}\n\n\\begin{equation}\nm_t= (1-z_t)m_{t-1} + z_t\\widetilde{m_t} %\\sigma(x_t U^{(i)} m_{t-1}W^{(i)})\n\\end{equation}\n\n\\begin{itemize}\n\t\\item \\textbf{update gate $z_{(t)}$:} The update gate is the filter which decides how much of the activations/memory to be update at any given time step.\n\t\\item \\textbf{reset gate $r_{(t)}$:} The reset gate is similar to the forget gate in a LSTM. When its value is close to zero it allows the cell to forget the previously computed state.\n\t\\item \\textbf{The input modulation $g_{(t)}$} just as in the case of the LSTM  serves the purpose of yielding candidate memories for the new cell state.\n\t\\item \\textbf{hidden state $m_{(t)}$:} The current hidden state is a weighted average of the previous hidden state and the candidate hidden state weighted by ``(1 - update gate)\" and the ``(update gate)\" respectively.\n\\end{itemize}\n\n\nWhile there are a lot of similarities between a GRU and a LSTM the most striking difference is the lack of an output gate in a GRU. Unlike a LSTM a GRU doesn't control how much of its internal memory to expose to the rest of the units in the network. The GRU therefore has fewer parameters due to the lack of an output gate and is computationally less intensive in comparison to a LSTM.\n\n\\section{Seq2Seq Models}\\label{background:s2s}\n\\begin{figure}\n\t\\begin{minipage}[t]{\\textwidth}\n\t\t\\ifpdf\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/s2s-pdf}\n\t\t\\else\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/s2s-eps}\n\t\t\\fi\n\t\t\\caption{Schematic of a Seq2Seq \\citep{manish}}\n\t\t\\label{bck:s2s}\n\t\\end{minipage}\n\\end{figure}\n\nSequence-to-sequence (seq2seq) models introduced by \\cite{Sutskever2014}, \\cite{GRU} are a class of probabilistic generative models that let us learn the mapping from a variable length input to a variable length output. While initially conceived for machine translation, they have been applied successfully to the tasks of speech recognition, question answering and text summarization \\citep{Vinyals2015} \\citep{anderson2018bottom} \\citep{lu2017knowing}.\n\nNeural networks have been shown to be excellent at learning rich representation from data without the need for extensive feature engineering \\citep{Hinton2006}. RNNs are especially adept at learning features and long term dependencies in sequential data (section \\ref{RNN}). The simple yet effective idea behind a seq2seq model is learning a fixed size (latent) representation of a variable length input and then generating a variable length output by conditioning it on this latent representation and the previous portion of the output sequence.\n\n\\begin{equation} \\label{decoder:eqn1}\n\th^{(t)} = f(x^{(t)}, h^{(t-1)}, v)\n\\end{equation}\n\n\\begin{equation} \\label{decoder:eqn2}\n\tP(x^{(t+1)}|x^{(t)}, x^{(t-1)},.....,x^{(1)}) = g(x^{(t)}, h^{(t)}, v)\n\\end{equation}\n\nIt can be seen from equation \\ref{decoder:eqn2} that the decoder is auto-regressive with the long term temporal dependencies captured in its hidden state. The term $\\mathbf{v}$ represents the summary of the entire input state compressed into a fixed length vector (last hidden state of encoder) viz. the \\textbf{latent space}. This encoder- decoder network is then jointly trained via. cross entropy loss between the target and the predicted sequence.\n\n\\subsection{Se2Seq with Attention}\\label{mtv:attn}\nIt was shown by \\cite{Cho2014} that the performance of a basic encoder-decoder model as explained in section \\ref{background:s2s} is inversely related to the increase in length of the input sentence. Therefore in lines with concepts of the selective attention and attentional blink in human beings \\citep{purves2013principles}, \\cite{Bahdanau2014} and later  \\cite{Luong2015} showed that soft selection from source states where most relevant information can be assumed to be concentrated during a particular translation step in neural machine translation (NMT) leads to improved performance. In the \\cite{Bahdanau2014} framework of attention, the equations \\ref{decoder:eqn1} and \\ref{decoder:eqn2} are modified as follows:\n\n\\begin{equation}\\label{attn:eqn1}\nh^{(t)} = f(x^{(t)}, h^{(t-1)}, c^{(t)}),\n\\end{equation}\n\n\\begin{equation} \\label{attn:eqn2}\nP(x^{(t+1)}|x^{(t)}, x^{(t-1)},.....,x^{(1)}) = g(x^{(t)}, h^{(t)}, c^{(t)}).\n\\end{equation}\n\nHere unlike the traditional seq2seq model the probability of emission of the output at time step $t$ isn't conditioned on a fixed summary representation $\\mathbf{v}$ of the input sequence. Rather it is conditioned on a context vector $\\mathbf{c^{(t)}}$ which is distinct at each decoding step. The context vector is calculated using a sequence of encoder outputs $(s^1, s^2, ....,s^N)$ to which the the input sequence is mapped such that an encoder output $s^i$ contains a representation of the entire sequence with maximum information pertaining to the $i_{th}$ word in the input sequence. The context vector is then calculated as follows:\n\n\\begin{equation}\\label{attn:eqn3}\nc^{(t)}  = \\sum_{j=1}^N \\alpha_{tj} s^j,\n\\end{equation}\nwhere:\n\\begin{equation}\\label{attn:eqn4}\n\\alpha_{tj} = \\text{softmax}(e(h^{(t-1)}, s^j)).\n\\end{equation}\nwhere $e$ is a alignment/matching/similarity measure between the decoder hidden state $h^{(t-1)}$ i.e. just before the emission of output $x^{(t)}$. The alignment function can be a dot product of the two vectors or a feed-forward network that is jointly trained with the encoder-decoder model. The $\\alpha_{tj}$ is an attention vector that weighs the encoder outputs at a given decoding step. \\cite{Vaswani2017} view the entire process of attention and context generation as a series of functions applied to the tuple (query, key, value), with the first step being an \\textbf{attentive read} step where a scalar matching score between the query and key ($h^{(t-1)}, s^j$) is calculated followed by computation of attention weights $\\alpha_{tj}$. Weighted averaged of the \\lq values{}\\rq\\ using the attention weights is then done in the \\textbf{aggregation} step.  \n\n\n\\section{Pondering}\\label{bck:ponder}\n\n%\\begin{figure}\n%\t\\begin{minipage}[t]{\\textwidth}\n%\t\t\\ifpdf\n%\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/act-pdf}\n%\t\t\\else\n%\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/act-eps}\n%\t\t\\fi\n%\t\t\\caption{\\small Adaptive Computation Time}\n%\t\t\\label{mtv:ponder}\n%\t\\end{minipage}\n%\\end{figure}\n\n\\begin{figure}[ht] \n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{./figs/act1-eps}\n\t\t\\caption{Fixed Computation Time}\n\t\t\\label{fixed} \n\t\t\\vspace{4ex}\n\t\\end{subfigure}%% \n\t\\begin{subfigure}[b]{0.5\\linewidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.95\\linewidth]{./figs/act2-eps}\n\t\t\\caption{Adpative Computation Time} \n\t\t\\label{adaptive}  \n\t\t\\vspace{4ex}\n\t\\end{subfigure}\n\t\\caption{\\small Schematic of Adaptive Computation Time}\n\t\\label{mtv:ponder}\n\\end{figure}\nThe task of positioning a problem and solving belong to different classes of time complexity with the latter requiring more time than the former. \\cite{Graves2016} argued that for a given RNN unit it is reasonable to allow for variable computation time for each input in a sequence since some parts of the input might be inherently more complex than the others and thereby require more computational steps. A good example of this would be \\textit{spaces between words and ends of sequences}. \n\nHuman beings overcome similar obstacles by allocating more time to a difficult problem as compared to a simpler problem. Therefore a naive solution would be to allow a RNN unit to have a large number of hidden state transitions (without penalty on amount of computations performed) before emitting an output on a given input. The network would therefore learn to allocate as much time as possible to minimize its error thereby making it extremely inefficient. \\cite{Graves2016} proposed the concept of \\textbf{adaptive computation time} to have a trade-off between accuracy and computational efficacy in order to determine the minimum number of state transitions required to solve a problem \\footnote{Theoretically this is akin to halting on a given problem or finding the Kolmogorov Complexity of the data, both of which are unsolvable}.\n\n\\textbf{A}daptive \\textbf{C}omputation \\textbf{T}ime (ACT) achieves the above outlined goals by making two simple modifications to a conventional RNN cell, which are presented as follows:\n\n\\subparagraph{Sigmoidal Halting Unit} If we revisit the equations of a vanilla RNN from section \\ref{RNN}, they can be summarized as:\n\\begin{equation}\n\\begin{aligned}\nh_t &= f(Ux_t + Wc_{t-1}), \\\\\ny_t &= g(Vc_t).\n\\end{aligned}\n\\end{equation}\nACT now allows for \\textit{variable state transitions} ($c_t^1, c_t^2,...., c_t^{N(t)}$) and by extension an \\textit{intermediate output sequence} ($y_t^1, y_t^2,...., y_t^{N(t)}$) at any given input step \\textit{t} as follows:\n\\begin{equation}\n\\begin{aligned}\nc_t^n &= \\begin{cases} f(Ux_t^1 + Wc_{t-1})\\ \\text{if}\\ n = 1 \\\\ f(Ux_t^n + Wc_t^{n-1})\\ \\text{if}\\ n \\neq 1  \\end{cases}, \\\\\ny_t^n &= g(Vc_t^n).\n\\end{aligned}\n\\end{equation}\n\nA sigmoidal halting unit (with its associated weight matrix $S$) is now added to the network in order to yield a halting probability $p_t^n$ at each state transition as follows:\n\\begin{equation}\n\\begin{aligned}\nh_t^n &= \\sigma(Sc_t^n), \\\\\np_t^n &= \\begin{cases} R(t)\\ \\text{if}\\ n = N(t) \\\\ h_t^n\\ \\text{if}\\ n \\neq N(t)  \\end{cases},\n\\end{aligned}\n\\end{equation}\nwhere:\n\\begin{equation}\n\\begin{aligned}\nN(t) &= min\\{m : \\sum_{n=1}^m h_t^n \\geq 1 - \\epsilon\\}, \\\\\nR(t) &= 1 - \\sum_{n=1}^{N(t)-1} h_t^n,\n\\end{aligned}\t\n\\end{equation}\nand $\\epsilon$ is a small constant.\n\nEach ($n^{th}$) hidden state and output transition at input state \\textit{t} are now weighted by the corresponding halting probability $p_t^n$ and summed over all the updates $N(t)$ to yield the final hidden state $c_t$ and output $y_t$ at a given input step. Figure \\ref{mtv:ponder} outlines the difference between a standard RNN cell and an ACT RNN cell by showing variable state transitions for input $x$ and $y$ respectively with the corresponding probability associated with each update step. It can be noted that $\\sum_{n=1}^{N(t)} p_t^n = 1\\ \\text{and}\\ 0 \\leq p_t^n \\leq 1\\ \\forall n$, and therefore, it constitutes a valid probability distribution.\n\n\\subparagraph{Ponder Cost} If we don't put any penalty on the number of state transitions then the network would become computationally inefficient and would \\lq \\textbf{ponder}{}\\rq\\ for long times even on simple inputs in order to minimize its error. Therefore in order to limit the variable state transitions ACT adds a ponder cost $\\mathcal{P}(x)$ to the total loss of the network as follows:\ngiven an input of length $T$ the ponder cost at each time step $t$ is defined as:\n\n\\begin{equation}\n\\rho_t = N(t) +\\ R(t)\n\\end{equation}\n\n\\begin{equation}\n\\begin{aligned}\n\\mathcal{P}(x) &= \\sum_{t=1}^T \\rho_t, \\\\\n\\widetilde{\\mathcal{L}}(x,y) &= \\mathcal{L}(x,y) + \\tau\\mathcal{P}(x),\n\\end{aligned}\t\n\\end{equation}\nwhere $\\tau$ is a penalty term hyperparameter (that needs to be tuned) for the ponder loss.\n\n\\section{Formal Language Theory}\\label{flt}\nThe field of formal language theory (FLT) concerns itself with the syntactic structure of a formal language (=set of strings) without much emphasis on the semantics. More precisely a formal language $L$ is a set of strings with the constituent units/words/morphemes taken from a finite vocabulary $\\Sigma$. It is more apt to define the concept of a formal grammar before proceeding further. A formal grammar $G$ is a quadruple $\\langle \\Sigma, NT, S, R \\rangle$ where $\\Sigma$ is a finite vocabulary as previously defined, $NT$ is a finite set of non-terminals, $S$ the start symbol and $R$ the finite set of valid production rules. A production rule can be expressed as $\\alpha \\rightarrow \\beta$ and can be understood as a substitution of $\\alpha$ with $\\beta$ and $\\alpha, \\beta$ coming from the following sets for a \\textbf{valid} production rule:\n\n\\begin{equation}\\label{term-nonterm}\n\t\\alpha \\in (\\Sigma \\cup NT)^{*}NT(\\Sigma \\cup NT)^{*} \\qquad \\beta \\in (\\Sigma \\cup NT)^{*} \\footnote{The \\lq *\\rq\\ denotes Kleene Closure and for a set of symbols say $X$, $X^{*}$ denotes a set of all strings that can be generated using symbols from X, including the empty string $\\epsilon$ }.\n\\end{equation}\n\nFrom equation \\ref{term-nonterm} it is easy to see that the left hand side of the production rule can never be null ($\\epsilon$) and must contain at-least one non-terminal. Now a formal language $L(G)$ can be defined as the set of all strings  \\textit{generated} by grammar $G$ such that the string consists of morphemes only from $\\Sigma$, and has been generated by a finite set of rule ($R$) application after starting from $S$. The \\textit{decidability} of a grammar, is the verification (by a Turing machine or another similar computational construct e.g. a finite state automaton (FSA)) of whether a given string has been generated by that grammar or not (the \\textit{membership} problem). A grammar is decidable if the membership problem can be solved for all given strings.\n\n\\begin{figure}\n\t\\begin{minipage}[t]{0.8\\textwidth}\n\t\t\\ifpdf\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/chomsky_h-pdf}\n\t\t\\else\n\t\t\\includegraphics[width=\\linewidth,keepaspectratio=true]{./figs/chomsky_h-eps}\n\t\t\\fi\n\t\t\\caption{\\small Chomsky Hierarchy}\n\t\t\\label{mtv:ch}\n\t\\end{minipage}\n\\end{figure}\n\n\\subsection{Chomsky Hierarchy}\\label{flt:ch}\n\\cite{Chomsky1956} introduced a nested hierarchy for different formal grammars of the form $C_1 \\subsetneq C_2 \\subsetneq C_3 \\subsetneq C_4$ as shown in figure \\ref{mtv:ch}. The different classes of grammar are progressively strict subsets of the class just above them in the hierarchy. These classes are not just distinguished by their rules or the languages they generate but also on the computational construct needed to decide the language generated by this grammar. We now take a closer look at the classes in this hierarchy. Please note that for each of these classes the grammar definition is G = $\\langle \\Sigma, NT, S, R \\rangle$.\n\\subparagraph{Recursively Enumerable} This grammar is characterized by no constraints on the production rules $\\alpha \\rightarrow \\beta$. Therefore any valid grammar is recursively enumerable. The language generated by this grammar is called recursively enumerable language (REL) and is accepted by a Turning Machine.\n\\subparagraph{Context-Sensitive} This is a grammar in which the left hand side of the production rule i.e. $\\alpha$ has the same definition as above (equation \\ref{term-nonterm}) but an additional constraint of the form $|\\alpha| \\leq |\\beta|$ is now imposed on the production rules. This is turn leads to $\\beta \\in (\\Sigma \\cup NT)^{+}$, i.e. the right hand side of the production rule is now under Kleene Plus closure \\footnote{$(\\Sigma \\cup NT)^{+} = (\\Sigma \\cup NT)^{*} - \\epsilon$}. The non production of $\\epsilon$ in context-sensitive grammars poses a problem to the hierarchy because the production of null symbol isn't restricted in its subclasses. While keeping the hierarchy as it is \\cite{Chomsky1963} resolved this paradox by defining noncontracting grammmar which is \\textit{weakly equivalent}(generates same set of string) to the context sensitive grammar. Noncontracting grammars allow the $S \\rightarrow \\epsilon$ production. Context sensitive grammars generate context sensitive languages which are accepted by a linear bounded turing machine. While in principle this grammar is decidable, the problem is PSPACE hard and can be so complex, that it is practically intractable \\citep{Jager2012}. \n\\subparagraph{Context-Free} This grammar is described by production rules of the form $A \\rightarrow \\alpha$ where $A \\in NT$ and $\\alpha \\in (\\Sigma \\cup NT)^{*}$, such that $|A|=1$.  Context free grammar lead to context free languages (CFL) which are hierarchical in structure, although it is possible that same CFL can be described by different context free grammars, leading to different hierarchical syntactic structures of the language. A CFG is decidable in cubic time of length of string by push down FSA. A push down automaton employs a running stack of symbols to decide its next transition. The stack can also be manipulated as a side effect of the state transition.\n\\subparagraph{Regular} This grammar is characterized by production rules of the form $A \\rightarrow \\alpha$ or $A \\rightarrow \\alpha B$ where $\\alpha \\in \\Sigma^{*}$ and $(A, B) \\in NT$. The non terminal in production can therefore be viewed as the next state(s) of a finite state automaton (FSA) while the terminals are the emissions. Regular grammars are decidable in linear time of length of string by an FSA.\n\n\n\\subsection{Subregular Hierarchy}\\label{flt:sh}\nThe simplest class of languages encountered in section \\ref{flt:ch} were regular languages that can be described using a FSA. \\cite{Jager2012} however argue that the precursor to human language faculty would require lower cognitive capabilities and it stands to reason that even simpler structures can exist in the \\lq Regular\\rq{} domain. They therefore introduced the concept of subregular languages. If a language can be described by a mechanism even simpler than the FSA then it is a subregular language. While far from the expressive capabilities of regular languages which in turn are the least expressive class in the Chomsky hierarchy, subregular languages provide an excellent benchmark to test basic concept learning and pattern recognition ability of any intelligent system.\n\n\\subparagraph{Strictly local languages.} We start with a string $w$ and we are given a lookup table of k-adjacent characters known as \\textit{k-factors}, drawn from a particular language. The lookup table therefore serves the role of the language description. A language is \\textit{k}-local, if every \\textit{k}-factor seen by a \\textit{scanner} with a windows of size $k$ sliding over the string $w$, can be found in the aforementioned lookup-table. A $SL_k$ language description, is just the set of k-factors prefixed and suffixed by a start and end symbol, say $\\#$. E.g. $SL_2 = \\{\\#A,AB,BA,B\\#\\}$   \n\n\\subparagraph{Locally k-testable languages.} Instead of sliding a scanner over \\textit{k}-factors we consider all the \\textit{k}-factors to be atomic and build \\textit{k}-expression out of them using \\textit{propositional logic}. This language description is locally k-testable. As in the case of strictly local languages, scanner of window size $K$ slides over the string and records for every k-factor in vocabulary its occurrence or nonoccurence in the string. The output of this scanner is then fed to a boolean network which verifies the k-expressions. E.g. 2-expression $(\\neg \\# B) \\wedge A$, is a set of strings that doesn't start with B and consists of atleast one A.\n\n\n\\subparagraph{Remarks on Chomsky Hierarchy:}It is easy to see by looking at the production rules of all the grammars in Chomsky Hierarchy that, solving the languages generated by them requires an understanding of these rules. This allows us to create artificial languages such as SCAN \\citep{Lake2017} which are context-free, in order to test compositionality in deep neural networks. That said, it is worth noticing that while the grammars in Chomsky Hierarchy are finite, the languages they generate can be infinite. For an infinite language one can argue that a model that can infer the grammar from the given strings is the one that will generalize well to unseen strings. However if the language itself only contains a finite number of strings then although the language itself is compositional, it can be solved also by pure memorization.\n", "meta": {"hexsha": "3f6e94a50bed17dceacfc98aaa0b7d2ff613f5d4", "size": 34330, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "background.tex", "max_stars_repo_name": "Anand191/Thesis", "max_stars_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "background.tex", "max_issues_repo_name": "Anand191/Thesis", "max_issues_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "background.tex", "max_forks_repo_name": "Anand191/Thesis", "max_forks_repo_head_hexsha": "f7528269f96cbc7c58588b3ee8443b41473f5815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 90.580474934, "max_line_length": 1214, "alphanum_fraction": 0.7528983396, "num_tokens": 9525, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.611381973294151, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.4193771274578229}}
{"text": "\\documentclass{article}\n\\usepackage[legalpaper, portrait, margin=1in]{geometry}\n\\usepackage{cite}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{algorithm}\n\\usepackage{booktabs}\n\\usepackage{algorithmic}\n\\usepackage{graphicx}\n\\usepackage[font=small]{caption}\n%\\usepackage{subcaption}\n%\\expandafter\\def\\csname ver@subfig.sty\\endcsname{}\n\\usepackage{tabularx}\n\\usepackage{subfig}\n\\usepackage{pgffor}\n\\usepackage{hyperref}\n\\usepackage{soul}\n\n% for tables\n\\newcommand{\\centertab}[1]{\\multicolumn{1}{|c|}{\\textbf{#1} }}\n\\newcommand{\\bigcell}[2]{\\begin{tabular}{@{}#1@{}}#2\\end{tabular}}\n\n\\begin{document}\n\\input{math_definitions}\n\n\n\\section{Time Variable LQR}\n\\newcommand{\\vxt}{\\vx_{[t]}}\n\\newcommand{\\vut}{\\vu_{[t]}}\n\\newcommand{\\vSt}{\\vS_{[t]}}\n\\newcommand{\\vSp}{\\vS_{[t+1]}}\n\\newcommand{\\vQt}{\\vQ_{[t]}}\n\\newcommand{\\vRt}{\\vR_{[t]}}\n\\newcommand{\\vAt}{\\vA_{[t]}}\n\\newcommand{\\vBt}{\\vB_{[t]}}\n\n\\begin{itemize}\n  \\item System: $\\vx_{[t+1]} = \\vA_{[t]} \\vx_{[t]} + \\vB_{[t]} \\vu_{[t]}$\n  \\item Cost:\n    \\begin{align*}\n      J = \\sum_{t=1}^T g(\\vx_{[t]}, \\vu_{[t]})\n        = \\sum_{t=1}^T \\vx_{[t]}^T \\vQ_{[t]} \\vx_{[t]} + \\vu_{[t]}^T \\vR_{[t]} \\vu_{[t]}\n    \\end{align*}\n  \\item Value function:\n    \\begin{align}\n      V(\\vx_{[t]}, t) = \\min_{\\vu_{[t]}}{\\sgroup{\n          g(\\vx_{[t]}, \\vu_{[t]})\n          + \\func{V}{f(\\vx_{[t]}, \\vu_{[t]}, t) } }} \\label{eq:value_function}\n    \\end{align}\n    we assume that the value function takes the following form:\n    \\begin{align*}\n        V(\\vx_{[t]}, t) = \\vx_{[t]}^T \\vS_{[t]} \\vx_{[t]}\n    \\end{align*}\n  \\item solving Eq. \\ref{eq:value_function}:\n    \\begin{align}\n      \\vxt^T \\vSt \\vxt &= \\min_{\\vut} \\vxt^T \\vQt \\vxt + \\vut^T \\vRt \\vut\n          + \\func{f}{\\vxt, \\vut, t}^T \\vSp \\func{f}{\\vxt, \\vut, t}\n          \\label{eq:value_expanded} \\\\\n          &= \\min_{\\vut} \\vxt^T \\vQt \\vxt + \\vut^T \\vRt \\vut\n          + \\group{(\\vAt \\vxt)^T + (\\vBt \\vut)^T} \\vSp \\group{\\vAt \\vxt + \\vBt \\vut}\n           \\nonumber\n    \\end{align}\n    dropping time notation, assume everything depends on $t$, while\n      $\\hat{\\vS} = \\vSp$\n\n      \\renewcommand{\\vxt}{\\vx}\n      \\renewcommand{\\vut}{\\vu}\n      \\renewcommand{\\vSt}{\\vS}\n      \\renewcommand{\\vSp}{\\hat{\\vS}}\n      \\renewcommand{\\vQt}{\\vQ}\n      \\renewcommand{\\vRt}{\\vR}\n      \\renewcommand{\\vAt}{\\vA}\n      \\renewcommand{\\vBt}{\\vB}\n\n    \\begin{align*}\n       Vt =& \\vxt^T \\vQt \\vxt + \\vut^T \\vRt \\vut\n             + (\\vAt \\vxt)^T \\vSp (\\vAt \\vxt)\n             + 2 (\\vAt \\vxt)^T \\vSp (\\vBt \\vut)\n             + (\\vBt \\vut)^T \\vSp (\\vBt \\vut)\n    \\end{align*}\n    solving the minimization problem:\n    \\begin{align}\n      & \\dfrac{\\partial Vt}{\\partial \\vut} =\n          2 \\vRt \\vut + 2 \\vBt^T \\vSp \\vAt \\vxt + 2 \\vBt^T \\vSp \\vBt \\vut = 0 \\nonumber \\\\\n      & \\underbrace{(\\vRt + \\vBt^T \\vSp \\vBt)}_{\\vM}\\vut =\n                        - \\underbrace{\\vBt^T \\vSp \\vAt}_{\\vC} \\vxt  \\nonumber \\\\\n      & \\vut = - \\vM^{-1} \\vC \\vxt   \\label{eq:optimalu}\n    \\end{align}\n    Now we need to solve for $\\vSp$ by replacing \\ref{eq:optimalu} into\n      \\ref{eq:value_expanded}:\n    \\begin{align*}\n      \\vxt^T \\vSt \\vxt & =\n            \\vxt^T \\vQt \\vxt\n          + \\vxt^T \\vAt^T \\vSp \\vAt \\vxt\n          + 2 \\vxt^T \\underbrace{\\group{\\vAt^T \\vSp \\vBt}}_{\\vC^T} \\vut\n          + \\vut^T \\underbrace{\\group{\\vRt + \\vBt^T \\vSp \\vBt}}_{\\vM} \\vut \\\\\n        & =\n            \\vxt^T \\vQt \\vxt\n          + \\vxt^T \\vAt^T \\vSp \\vAt \\vxt\n          - 2 \\vxt^T \\vC^T \\vM^{-1} \\vC \\vxt\n          + \\vxt^T \\vC^T \\vM^{-T} \\vM \\vM^{-1} \\vC \\vxt \\\\\n        & =\n            \\vxt^T \\vQt \\vxt\n          + \\vxt^T \\vAt^T \\vSp \\vAt \\vxt\n          - \\vxt^T \\vC^T \\vM^{-1} \\vC \\vxt \\\\\n        & =\n            \\vxt^T \\group{\\vQt\n                          + \\vAt^T \\vSp \\vAt\n                          - \\vC^T \\vM^{-1} \\vC} \\vxt\n    \\end{align*}\n    Therefore, we have:\n    \\begin{align*}\n      \\vSt & = \\vQt + \\vAt^T \\vSp \\vAt\n                    - \\vC^T \\vM^{-1} \\vC \\\\\n           & = \\vQt + \\vAt^T \\vSp \\vAt\n                    - \\vAt^T \\vSp \\vBt \\group{\\vRt + \\vBt^T \\vSp \\vBt}^{-1} \\vBt^T \\vSp \\vAt \n    \\end{align*}\n\n\\end{itemize}\n\n\n\\end{document}\n", "meta": {"hexsha": "15582cebe7da8657d3101e94d29b9271b44a0463", "size": 4101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/control.tex", "max_stars_repo_name": "danmar3/twodlearn", "max_stars_repo_head_hexsha": "02b23bf07618d5288e338bd8f312cc38aa58c195", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/control.tex", "max_issues_repo_name": "danmar3/twodlearn", "max_issues_repo_head_hexsha": "02b23bf07618d5288e338bd8f312cc38aa58c195", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/control.tex", "max_forks_repo_name": "danmar3/twodlearn", "max_forks_repo_head_hexsha": "02b23bf07618d5288e338bd8f312cc38aa58c195", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6147540984, "max_line_length": 93, "alphanum_fraction": 0.5152401853, "num_tokens": 1789, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.41937712353268963}}
{"text": "\\newpage\\section{Tricks and Lemmas}\n\t\n\t\\theo{https://en.wikipedia.org/wiki/Minkowski's_theorem}{Minkowski's theorem}{Any convex set in $\\R^n$, which is symmetric with respect to the origin and with volume greater than $2^n d(L)$ contains a non-zero lattice point.}\n\t\n\t\n\t\n\t\\subsection{Ad Hocs}\n\t\n\t\t\\begin{enumerate}\n\t\t\t\n\t\t\t\\item $x^2+1 = (x+i)(x-i)$ [USAMO 2014 P1]\n\t\t\t\\item Add. Everything. Up.\n\t\t\t\\item Send SHIT to the infinity. \n\t\t\t\n\t\t\\end{enumerate}\n\t", "meta": {"hexsha": "40478c639cfb107ca554a210986b8f5b92ec02b0", "size": 455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg/sec6_tricks.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "alg/sec6_tricks.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg/sec6_tricks.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 28.4375, "max_line_length": 226, "alphanum_fraction": 0.6791208791, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.4192687479071447}}
{"text": "\\subsection{Decision Trees}\n\\label{decision_trees}\n\n\\noindent{\\bf Description}\nDecision trees (for classification) is a classifier that is considered\nmore interpretable than other statistical classifiers. This implementation\nis well-suited to handle large-scale data and builds a (binary) decision \ntree in parallel.\\\\\n\n\\noindent{\\bf Usage}\n\\begin{tabbing}\n\\texttt{-f} \\textit{path}/\\texttt{decision-tree.dml -nvargs} \n\\=\\texttt{X=}\\textit{path}/\\textit{file} \n  \\texttt{Y=}\\textit{path}/\\textit{file} \n  \\texttt{types=}\\textit{path}/\\textit{file}\\\\\n\\>\\texttt{model=}\\textit{path}/\\textit{file}\n  \\texttt{bins=}\\textit{int}\n  \\texttt{depth=}\\textit{int}\\\\\n\\>\\texttt{num\\_leaf=}\\textit{int}\n  \\texttt{num\\_samples=}\\textit{int}\\\\\n\\>\\texttt{Log=}\\textit{path}/\\textit{file}\n  \\texttt{fmt=}\\textit{csv}$\\vert$\\textit{text}\n\\end{tabbing}\n\n\\begin{tabbing}\n\\texttt{-f} \\textit{path}/\\texttt{decision-tree-predict.dml -nvargs} \n\\=\\texttt{X=}\\textit{path}/\\textit{file} \n  \\texttt{Y=}\\textit{path}/\\textit{file} \n  \\texttt{model=}\\textit{path}/\\textit{file}\\\\\n\\>\\texttt{fmt=}\\textit{csv}$\\vert$\\textit{text}\n  \\texttt{accuracy=}\\textit{path}/\\textit{file}\\\\\n\\>\\texttt{confusion=}\\textit{path}/\\textit{file}\n  \\texttt{predictions=}\\textit{path}/\\textit{file}\n\\end{tabbing}\n\n\\noindent{\\bf Arguments}\n\n\\begin{itemize}\n\\item X: Location (on HDFS) to read the matrix of feature vectors; \neach row constitutes one feature vector.\n\\item Y: Location (on HDFS) to read the one-column matrix of (categorical) \nlabels that correspond to feature vectors in X. Classes are assumed to be\ncontiguously labeled beginning from 1. Note that, this argument is optional\nfor prediction.\n\\item model: Location (on HDFS) that contains the learnt decision tree.\n\\item types: Location (on HDFS) that contains each feature's type. 1 denotes\ncontinuous-valued (scale) and 2 denotes categorical.\n\\item bins (default: {\\tt 50}): Number of thresholds to choose for each \ncontinuous-valued feature (deterimined by equi-height binning). \n\\item depth (default: {\\tt 10}): Maximum depth of the learnt decision tree.\n\\item num\\_leaf (default: {\\tt 1}): Parameter that controls pruning. The tree\nis not expanded if a node receives less than num\\_leaf training examples.\n\\item num\\_samples (default: {\\tt 10}): Parameter that decides when to switch\nto in-memory building of subtrees. If a node $v$ receives less than num\\_samples\ntraining examples then this implementation switches to an in-memory subtree\nbuilding procedure to build the subtree under $v$ in its entirety.\n\\item Log: Location (on HDFS) that collects various useful metrics that indicate\ntraining progress.\n\\item predictions: Location (on HDFS) to store predictions for a held-out test set.\nNote that, this is an optional argument.\n\\item fmt (default: {\\tt text}): Specifies the output format. Choice of \ncomma-separated values (csv) or as a sparse-matrix (text).\n\\item accuracy: Location (on HDFS) to store the testing accuracy from a \nheld-out test set during prediction. Note that, this is an optional argument.\n\\item confusion: Location (on HDFS) to store the confusion matrix\ncomputed using a held-out test set. Note that, this is an optional \nargument.\n\\end{itemize}\n\n\\noindent{\\bf Details}\n \nDecision trees (Breiman et al, 1984) are simple models of\nclassification that,  due to their structure,  are easy to\ninterpret. Given an example feature vector, each node in the learnt\ntree runs a simple test on it. Based on the result of the test, the\nexample is either diverted to the left subtree or to the right\nsubtree. Once the example reaches a leaf, then the label stored at the\nleaf is returned as the prediction for the example.\n\n\\par\n\nBuilding a decision tree from a fully labeled training set entails\nchoosing appropriate tests for each internal node in the tree and this\nis usually performed in a top-down manner. Choosing a test requires\nfirst choosing a feature $j$ and depending on the type of $j$, either\na threshold $\\sigma$, in case $j$ is continuous-valued, or a subset of\nvalues $S \\subseteq \\text{Dom}(j)$ where $\\text{Dom}(j)$ denotes\ndomain of $j$, in case it is categorical. For continuous-valued\nfeatures the test is thus of form $x_j < \\sigma$ and for categorical\nfeatures it is of form $x_j \\in S$, where $x_j$ denotes the $j^{th}$\nfeature value of feature vector $x$. One way to determine which test\nto include, is to compare impurities of the subtrees induced by the\ntest and this implementation uses {\\it Gini impurity}.\n\n\\par\n\nThe current implementation allows the user to specify the maximum\ndepth of the learnt tree using the argument {\\it depth}. It also\nallows for some automated pruning via the argument {\\it num\\_leaf}. If\na node receives $\\leq$ {\\it num\\_leaf} training examples, then a leaf\nis built in its place. Furthermore, for a continuous-valued feature\n$j$ the number of candidate thresholds $\\sigma$ to choose from is of\nthe order of the number of examples present in the training set. Since\nfor large-scale data this can result in a large number of candidate\nthresholds, the user can limit this number via the arguments {\\it\n  bins} which controls the number of candidate thresholds considered\nfor each continuous-valued feature. For each continuous-valued\nfeature, the implementation computes an equi-height histogram to\ngenerate one candidate threshold per equi-height bin. To determine the\nbest value subset to split on in the case of categorical features,\nthis implementation greedily includes values from the feature's domain\nuntil the sum of the impurities of the subtrees induced stops\nimproving.\n\n\\par\n\nLearning a decision tree on large-scale data has received  some\nattention in the literature. The current implementation includes logic\nfor choosing tests for multiple nodes that belong to the same level in\nthe decision tree in parallel (breadth-first expansion) and for\nbuilding entire subtrees under multiple nodes in parallel (depth-first\nsubtree building). Empirically it has been demonstrated that it is\nadvantageous to perform breadth-first expansion for the nodes\nbelonging to the top levels of the tree and to perform depth-first\nsubtree building for nodes belonging to the lower levels of the tree\n(Panda et al, 2009). The parameter {\\it num\\_samples} controls when we\nswitch to  depth-first subtree building. Any node in the decision tree\nthat receives $\\leq$ {\\it num\\_samples} training examples, the subtree\nunder it is built in its entirety in one shot.\n\n\\par\n\n{\\it Description of the model}: The learnt decision tree is represented using a matrix that\ncontains at least 3 rows. Each column in the matrix contains the parameters relevant\nto a single node in the tree. The $i^{th}$ column denotes the parameters for the $i^{th}$ node\nwhose left child is stored in the $2i^{th}$ column and right child is stored in the $2i+1^{th}$\ncolumn. Here is a brief description of what each row in the matrix contains:\n\\begin{itemize}\n\\item $1^{st}$ row: Contains the feature index of the feature that this node looks at if \nthe node is an internal node, otherwise -1.\n\\item $2^{nd}$ row: Contains the type of the feature that this node looks at if the node is\nan internal node, otherwise the label this leaf node is supposed to predict. \n1 denotes continuous-valued feature and 2 denotes categorical.\n\\item $3^{rd}$: Only applicable for internal nodes. Contains the threshold the example's \nfeature value is compared to if the feature chosen for this node is a continuous-valued feature. \nIf on the other hand, the feature chosen for this node is categorical then the size of the \nsubset of values is stored here.\n\\item $4^{th}$ row onwards: Only applicable in the case of internal nodes where the feature\nchosen is a categorical feature. Rows $4, 5 \\ldots$ depict the value subset \nchosen for this node.\n\\end{itemize}\nAs an example, Figure \\ref{dtree} shows a decision tree with $5$ nodes and its matrix\nrepresentation.\n\n\\begin{figure}\n\\begin{minipage}{0.3\\linewidth}\n\\begin{center}\n\\begin{tikzpicture}\n\\node (labelleft) [draw,shape=circle,minimum size=16pt] at (0,0) {$2$};\n\\node (labelright) [draw,shape=circle,minimum size=16pt] at (1,0) {$1$};\n\\node (rootleft) [draw,shape=rectangle,minimum size=16pt] at (0.5,1) {$x_5 \\in \\{2,3\\}$};\n\\node (rootlabel) [draw,shape=circle,minimum size=16pt] at (2.5,1) {$1$};\n\\node (root) [draw,shape=rectangle,minimum size=16pt] at (1.75,2) {$x_3 < 0.45$};\n\n\\draw[-latex] (root) -- (rootleft);\n\\draw[-latex] (root) -- (rootlabel);\n\\draw[-latex] (rootleft) -- (labelleft);\n\\draw[-latex] (rootleft) -- (labelright);\n\n\\end{tikzpicture}\n\\end{center}\n\\begin{center}\n(a)\n\\end{center}\n\\end{minipage}\n\\hfill\n\\begin{minipage}{0.65\\linewidth}\n\\begin{center}\n\\begin{tabular}{c|c|c|c|c|c|}\n& Col 1 & Col 2 & Col 3 & Col 4 & Col 5\\\\\n\\hline\nRow 1 & 3 & 5 & -1 & -1 & -1\\\\\n\\hline\nRow 2 & 1 & 2 & 1 & 2 & 1\\\\\n\\hline\nRow 3 & 0.45 & 2 &  &  & \\\\\n\\hline\nRow 4 &  & 2 &  &  & \\\\\n\\hline\nRow 5 &  & 3 &  &  & \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\begin{center}\n(b)\n\\end{center}\n\\end{minipage}\n\\caption{(a) An example tree and its (b) matrix representation. $x$ denotes an example and $x_j$ the $j^{th}$ feature's value in it.}\n\\label{dtree}\n\\end{figure}\n\n\\vspace{16pt}\n\n\\noindent{\\bf Returns}\n\nThe matrix corresponding to the learnt model is written to a file in the format requested. See\ndetails where the structure of the model matrix is\ndescribed. Depending on what arguments are provided during\ninvocation, decision-tree-predict.dml may compute one or more of\npredictions,  accuracy and confusion matrix in the requested output format.\n\\\\\n\n\\noindent{\\bf Examples}\n\\begin{verbatim}\nhadoop jar SystemML.jar -f decision-tree.dml -nvargs \n                           X=/user/biadmin/X.mtx \n                           Y=/user/biadmin/y.mtx \n                           types=/user/biadmin/types.mtx\n                           model=/user/biadmin/model.mtx\n                           bins=50 depth=10 num_leaf=1\n                           num_samples=250 fmt=csv\n                           Log=/user/biadmin/accuracy.csv\n\\end{verbatim}\n\n\\begin{verbatim}\nhadoop jar SystemML.jar -f decision-tree-predict.dml -nvargs \n                           X=/user/biadmin/X.mtx \n                           Y=/user/biadmin/y.mtx \n                           model=/user/biadmin/model.mtx\n                           fmt=csv\n                           predictions=/user/biadmin/probabilities.csv\n                           accuracy=/user/biadmin/accuracy.csv\n                           confusion=/user/biadmin/confusion.csv\n\\end{verbatim}\n\n\\noindent{\\bf References}\n\n\\begin{itemize}\n\\item B. Panda, J. Herbach, S. Basu, and R. Bayardo. \\newblock{PLANET: massively parallel learning of tree ensembles with MapReduce}. In Proceedings of the VLDB Endowment, 2009.\n\\item L. Breiman, J. Friedman, R. Olshen, and C. Stone. \\newblock{Classification and Regression Trees}. Wadsworth and Brooks, 1984.\n\\end{itemize}\n", "meta": {"hexsha": "f404dfcf1c1fdb6c5160ffab13302b9946ef8d8b", "size": 10881, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "system-ml/docs/Algorithms Reference/DecisionTrees.tex", "max_stars_repo_name": "dusenberrymw/IBM-SystemML", "max_stars_repo_head_hexsha": "fc41ec4f0bd3bc6701c56103afdb409f8b0d9a04", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-18T06:10:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-18T06:10:37.000Z", "max_issues_repo_path": "system-ml/docs/Algorithms Reference/DecisionTrees.tex", "max_issues_repo_name": "dusenberrymw/IBM-SystemML", "max_issues_repo_head_hexsha": "fc41ec4f0bd3bc6701c56103afdb409f8b0d9a04", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "system-ml/docs/Algorithms Reference/DecisionTrees.tex", "max_forks_repo_name": "dusenberrymw/IBM-SystemML", "max_forks_repo_head_hexsha": "fc41ec4f0bd3bc6701c56103afdb409f8b0d9a04", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.9628099174, "max_line_length": 177, "alphanum_fraction": 0.7271390497, "num_tokens": 2960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.4192687479071447}}
{"text": "\\section{Let's Get the Atmosphere Moving}\nIn its current state, CLaUDE has a static planet. This means that the planet remains in place and does not move. However we know that planets move in orbit and more importantly, spin around \nthemselves. But before we start adding layers, let's talk about a term you will hear more often: numerical instability.\n\nNumerical instability occurs when you first run the model. This is due to the nature of the equations. Nearly all equations are continuous, which means that they are always at work. However \nwhen you start the model, the equations were not at work yet. It is as if you suddenly give a random meteor an atmosphere, place it in orbit around a star and don't touch i for a bit. You will \nsee that the whole system oscilates wildly as it adjusts to the sudden changes and eventually it will stabilise. Another term you might encounter is blow up, this occurs when when the model \nsuddenly no longer behaves like it should. This is most likely caused by mistakes in the code or incorrect paramter initialisation. Be wary of the existence of both factors, and do not dismiss \na model if it behaves weirdly as it has just started up.\n\n\\subsection{Equation of State and the Incompressible Atmosphere}\nThe equation of state relates one or more variables in a dynamical system (like the atmosphee) to another. The most common equation of state in the atmosphere is the ideal gas equation as \ndescribed by \\autoref{eq:ideal gas} \\cite{idealGas}. The symbols in that equation represent:\n\n\\begin{itemize}\n    \\item $p$: The gas pressure ($Pa$).\n    \\item $V$: The volume of the gas ($m^3$).\n    \\item $n$: The amount of moles\\footnote{Mole is the amount of particles ($6.02214076 \\cdot 10^{23}$) in a substance, where the average weight of one mole of particles in grams is about the \n    same as the weight of one particle in atomic mass units ($u$)\\cite{mole}} in the gas.\n    \\item $R$: The Gas constant, $8.3144621$ ($J(mol)^{-1}K$) \\cite{idealGas}.\n    \\item $T$: The temperature opf the gas ($K$).\n\\end{itemize}\n\nIf we divide everything in \\autoref{eq:ideal gas} by $V$ and set it to be unit (in this case, set it to be exactly $1 m^3$) we can add in the molar mass in both the top and bottom parts of the \ndivision as show in \\autoref{eq:gas unit}. We can then replace $\\frac{nm}{V}$ by $\\rho$ the density of the gas ($kgm^{-3}$) and $\\frac{R}{m}$ by $R_s$ the specific gas constant (gas constant that varies per \ngas in $J(mol)^{-1}K$) as shown in \\autoref{eq:state gas}. the resulting equation is the equation of state that you get that most atmospheric physicists use when talking about the atmosphere \\cite{simon}.\n\n\\begin{subequations}\n    \\begin{equation}\n        pV = nRT\n        \\label{eq:ideal gas}\n    \\end{equation}\n    \\begin{equation}\n        p = \\frac{nR}{V}T = \\frac{nmR}{Vm}T\n        \\label{eq:gas unit}\n    \\end{equation}\n    \\begin{equation}\n        p = \\rho R_sT\n        \\label{eq:state gas}\n    \\end{equation}\n\\end{subequations}\n\nThe pressure is quite important, as air moves from a high pressure point to a low pressure point. So if we know the density and the temperature, then we know the pressure and we can work out \nwhere the air will be moving to (i.e. how the wind will blow). In our current model, we know the atmospheric temperature but we do not know the density. For simplicities sake, we will now assume\nthat the atmosphere is Incompressible, meaning that we have a constant density. Obviously we know that air can be compressed and hence our atmosphere can be compressed too but that is not \nimportant enough to account for yet, especially considering the current complexity of our model.\n\nThe code that corresponds to this is quite simple, the only change that we need to make in \\autoref{eq:state gas} is that we need to replace $T$ by $T_a$, the temperature of the atmosphere. As\n$T_a$ is a matrix (known to programmers as a double array), $p$ will be a matrix as well. Now we only need to fill in some values. $\\rho = 1.2$\\cite{densityAir}, $R_s = 287$\\cite{specificGasConstantAir}.\n\n\\subsection{The Primitive Equations and Geostrophy}\nThe primitive equations (also known as the momentum equations) is what makes the air move. It is actually kind of an injoke between physicists as they are called the primitive equations but \nactually look quite complicated (and it says $fu$ at the end! \\cite{simon}). The primitive equations are a set of equations dictating the direction in the $u$ and $v$ directions as shown in \n\\autoref{eq:primitive u} and \\autoref{eq:primitive v}. We can make the equations simpler by using and approximation called geostrophy which means that we have no vertical motion, such that the\nterms with $\\omega$ in \\autoref{eq:primitive u} and \\autoref{eq:primitive v} become 0. We also assume that we are in a steady state, i.e. there is no acceleration which in turn means that the \nwhole middle part of the equations are $0$. Hence we are left with \\autoref{eq:primitive u final} and \\autoref{eq:primitive v final}.\n\n\\begin{subequations}\n    \\begin{equation}\n        \\frac{du}{dt} = \\frac{\\delta u}{\\delta t} + u\\frac{\\delta u}{ \\delta x} + v\\frac{\\delta u}{\\delta v} + \\omega\\frac{\\delta u}{\\delta p} = -\\frac{\\delta \\Phi}{\\delta x} + fv\n        \\label{eq:primitive u}\n    \\end{equation}\n    \\begin{equation}\n        \\frac{dv}{dt} = \\frac{\\delta v}{\\delta t} + u\\frac{\\delta v}{ \\delta x} + v\\frac{\\delta v}{\\delta v} + \\omega\\frac{\\delta v}{\\delta p} = -\\frac{\\delta \\Phi}{\\delta y} - fu\n        \\label{eq:primitive v}\n    \\end{equation}\n\n    \\begin{equation}\n        0 = -\\frac{\\delta \\Phi}{\\delta x} + fv\n        \\label{eq:primitive u final}\n    \\end{equation}\n    \\begin{equation}\n        0 = -\\frac{\\delta \\Phi}{\\delta y} - fu\n        \\label{eq:primitive v final}\n    \\end{equation}\n\\end{subequations}\n\n\\autoref{eq:primitive u final} can be split up into to parts, the $\\frac{\\delta \\Phi}{\\delta x}$ part (the gradient force) and the $fv$ part (the coriolis force). The same applies to \n\\autoref{eq:primitive v final}. Effectively we have a balance between the gradient and the coriolis force as shown in \\autoref{eq:pu simple} and \\autoref{eq:pv simple}. The symbols in both of \nthese equations are:\n\n\\begin{itemize}\n    \\item $\\Phi$: The geopotential, potential (more explanation in \\autoref{sec:potential}) of the planet's gravity field ($Jkg^{-1}$).\n    \\item $x$: The change in the East direction along the planet surface ($m$).\n    \\item $y$: The change in the North direction along the planet surface ($m$).\n    \\item $f$: The coriolis parameter as described by \\autoref{eq:coriolis}, where $\\Omega$ is the rotation rate of the planet (for Earth $7.2921 \\cdot 10^{-5}$) ($rad \\ s^{-1}$) and $\\theta$ is the \n    latitude \\cite{coriolis}.\n    \\item $u$: The velocity in the latitude ($ms^{-1}$).\n    \\item $v$: The velocity in the longitude ($ms^{-1}$).\n\\end{itemize}\n\n\\begin{subequations}\n    \\begin{equation}\n        f = 2\\Omega\\sin(\\theta)\n        \\label{eq:coriolis}\n    \\end{equation}\n    \\begin{equation}\n        \\frac{\\delta \\Phi}{\\delta x} = fv\n        \\label{eq:pu simple}\n    \\end{equation}\n    \\begin{equation}\n        \\frac{\\delta \\Phi}{\\delta y} = -fu\n        \\label{eq:pv simple}\n    \\end{equation}\n    \\begin{equation}\n        \\frac{\\delta p}{\\rho \\delta x} = fv\n        \\label{eq:pu simple final}\n    \\end{equation}\n    \\begin{equation}\n        \\frac{\\delta p}{\\rho \\delta y} = -fu\n        \\label{eq:pv simple final}\n    \\end{equation}\n\\end{subequations}\n\nSince we want to know how the atmosphere moves, we want to get the v and u components of the velocity vector (since $v$ and $u$ are the veolicites in longitude and latitude, if we combine them in a \nvector we get the direction of the overall velocity). So it is time to start coding and calculating! If we look back at \\autoref{alg:stream1v2}, we can see that we already have a double for loop.\nIn computer science, having multiple loops is generally considered a bad coding practice as you usually can just reuse the indices of the already existing loop, so you do not need to create a new \none. However this is a special case, since we are calculating new temperatures in the double for loop. If we then also would start to calculate the velocities then we would use new information \nand old information at the same time. Since at index $i - 1$ the new temperature has already been calculated, but at the index $i + 1$ the old one is still there. So in order to fix that we need\na second double for loop to ensure that we always use the new temperatures. We display this specific loop in \\autoref{alg:stream2}. Do note that everything in \\autoref{alg:stream1v2} is still\ndefined and can still be used, but since we want to focus on the new code, we leave out the old code to keep it concise and to prevent clutter. \n\n\\begin{algorithm}[hbt]\n    \\SetAlgoLined\n\n    \\While{\\texttt{TRUE}}{\n        \\For{$lat \\in [-nlat, nlat]$}{\n            \\For{$lon \\in [0, nlon]$}{\n                $u[lat, lon] \\leftarrow -\\frac{p[lat + 1, lon] - p[lat - 1, lon]}{\\delta y} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n                $v[lat, lon] \\leftarrow \\frac{p[lat, lon + 1] - p[lat, lon - 1]}{\\delta x[lat]} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n            }\n        }\n    }\n    \\caption{The main loop of the velocity of the atmosphere calculations}\n    \\label{alg:stream2}\n\\end{algorithm}\n\nThe gradient calculation is done in \\autoref{alg:gradient}. For this to work, we need the circumference of the planet. Herefore we need to assume that the planet is a sphere. While that is not \ntechnically true, it makes little difference in practice and is good enough for our model. The equation for the circumference can be found in \\autoref{eq:circumference} \\cite{circumference}, \nwhere $r$ is the radius of the planet. Here we also use the f-plane approximation, where the coriolis paramter has one value for the northern hemisphere and one value for the southern hemisphere \n\\cite{fplane}.\n\n\\begin{equation}\n    2 \\pi r\n    \\label{eq:circumference}\n\\end{equation}\n\n\\begin{algorithm}\n    \\SetAlgoLined\n    $C \\leftarrow 2\\pi R$ \\;\n    $\\delta y \\leftarrow \\frac{C}{nlat}$ \\;\n\n    \\For{$lat \\in [-nlat, nlat]$}{\n        $\\delta x[lat] \\leftarrow \\delta y \\cos(lat \\cdot \\frac{\\pi}{180})$ \\;\n\n        \\eIf{$lat < 0$}{\n            $f[lat] \\leftarrow -10^{-4}$ \\;\n        }{\n            $f[lat] \\leftarrow 10^{-4}$ \\;\n        }\n    }\n    \\caption{Calculating the gradient $\\delta x$}\n    \\label{alg:gradient}\n\\end{algorithm}\n\nBecause of the geometry of the planet and the construction of the longitude latitude grid, we run into some problems when calculating the gradient. Since the planet is not flat (\"controversial \nI know\"\\cite{simon}) whenever we reach the end of the longitude we need to loop around to get to the right spot to calculate the gradients (as the planet does not stop at the end of the \nlongitude line but loops around). So to fix that we use the modulus (mod) function which does the looping for us if we exceed the grid's boundaries. We do haveanother problem though, the poles. \nAs the latitude grows closer to the poles, they are converging on the center point of the pole. Looping around there is much more difficult so to fix it, we just do not consider that center \npoint in the main loop. The changed algorithm can be found in \\autoref{alg:stream2v2}\n\n\\begin{algorithm}[hbt]\n    \\SetAlgoLined\n\n    \\While{\\texttt{TRUE}}{\n        \\For{$lat \\in [-nlat + 1, nlat - 1]$}{\n            \\For{$lon \\in [0, nlon]$}{\n                $u[lat, lon] \\leftarrow -\\frac{p[(lat + 1) \\text{ mod } nlat, lon] - p[(lat -1) \\text{ mod } nlat, lon]}{\\delta y} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n                $v[lat, lon] \\leftarrow \\frac{p[lat, (lon + 1) \\text{ mod } nlon] - p[lat, (lon -1) \\text{ mod } nlon]}{\\delta x[lat]} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n            }\n        }\n    }\n    \\caption{The main loop of the velocity of the atmosphere calculations}\n    \\label{alg:stream2v2}\n\\end{algorithm}\n\nDo note that the pressure calculation is done between the temperature calculation in \\autoref{alg:stream1v2} and the $u, v$ calculations in \\autoref{alg:stream2v2}. At this point our model shows\na symmetric vortex around the sun that moves with the sun. This is not very realistic as you usually have convection and air flowing from warm to cold, but we do not have that complexity yet \n(due to our single layer atmosphere).\n\n\\subsection{Introducing an Ocean}\nNow we want to introduce an ocean, because most of the Earth is covered by oceans it plays quite an important role in atmospheric physics. To do this we need a new concept called albedo. Albedo\nis basically the reflectiveness of a material (in our case the planet's surface) \\cite{albedo}. The average albedo of the Earth is about 0.3. Now to add an ocean to the grid, we define a few \nareas where the albedo differs. Where you do this does not really matter for the current complexity. Defining the oceans is as easy as hardcoding (what we computer scientists refer to when \nsetting parts of an array to be a specific value, where if you want to change the value you need to change it everywhere instead of doing it in a variable) the albedo value for the specific \nregions as we do in \\autoref{alg:albedo}. Water also takes longer to warm up, so let us change the specific heat capacity ($C_p$ in \\autoref{alg:stream1v2}) from a constant to an array. The new \n$C_p$ can also be found in \\autoref{alg:albedo}, where we have made the specific heat capacity of water one order of magnitude (i.e. $10$ times) larger.\n\n\\begin{algorithm}[hbt]\n    $a \\leftarrow 0.5$ \\;\n    $a[5-55, 9-20] \\leftarrow 0.2$ \\;\n    $a[23-50, 45-70] \\leftarrow 0.2$ \\;\n    $a[2-30, 85-110] \\leftarrow 0.2$ \\;\n    \n    $C_p \\leftarrow 10^7$ \\;\n    $C_p[5-55, 9-20] \\leftarrow 10^8$ \\;\n    $C_p[23-50, 45-70] \\leftarrow 10^8$ \\;\n    $C_p[2-30, 85-110] \\leftarrow 10^8$ \\;\n    \\caption{Defining the oceans}\n    \\label{alg:albedo}\n\\end{algorithm}\n\nNow that we have that defined, we need to adjust the main loop of the program (\\autoref{alg:stream1v2}). For clarity, all the defined constants have been left out. We need to add albedo into the\nequation and change $C_p$ from a constant to an array. The algorithm after these changes can be found in \\autoref{alg:stream2v3}. We multiply by $1 - a$ since albedo represents how much energy is \nreflected instead of absorbed, where we need the amount that is absorbed which is exactly equal to $1$ minus the amount that is reflected.\n\n\\begin{algorithm}[hbt]\n    \\SetAlgoLined\n\n    \\While{\\texttt{TRUE}}{\n        \\For{$lat \\in [-nlat, nlat]$}{\n            \\For{$lon \\in [0, nlot]$}{\n                $T_p[lat, lon] \\leftarrow T_p[lat, lon] + \\frac{\\delta t ((1 - a[lat, lon])S + 4\\epsilon \\sigma (T_a[lat, lon])^4 - 4\\sigma (T_p[lat, lon])^4)}{C_p[lat, lon]}$ \\;\n                $T_a[lat, lon] \\leftarrow T_a[lat, lon] + \\frac{\\delta t (\\sigma (T_p[lat, lon])^4 - 2\\epsilon\\sigma (T_a[lat, lon])^4)}{C_a}$ \\;\n                $t \\leftarrow t + \\delta t$ \\;\n            }\n        }\n    }\n    \\caption{The main loop of the temperature calculations}\n    \\label{alg:stream2v3}\n\\end{algorithm}", "meta": {"hexsha": "f88a7fd8905d4c9922299148e85606ae964076b9", "size": 15127, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex-docs/streams/Stream2.tex", "max_stars_repo_name": "balintf/claude", "max_stars_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex-docs/streams/Stream2.tex", "max_issues_repo_name": "balintf/claude", "max_issues_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex-docs/streams/Stream2.tex", "max_forks_repo_name": "balintf/claude", "max_forks_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.4848484848, "max_line_length": 207, "alphanum_fraction": 0.6963046209, "num_tokens": 4313, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4192687433265391}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsection{Stationary SSD emission}\n\n\\marginpar{Tuesday\\\\ 2020-11-17, \\\\ compiled \\\\ \\today}\n\nLet us start by stating some assumption and definitions:\n%\n\\begin{enumerate}\n    \\item \\(\\rho = \\Sigma / H\\);\n    \\item \\(H = c_s (R^3 / GM)^{1/2} = R c_s / v_\\phi \\);\n    \\item \\(c_s^2 = P / \\rho \\);\n    \\item \\(P = P _{\\text{gas}} + P _{\\text{rad}} = k_B \\rho T / (\\mu m_p) + a T^{4} / 3\\).\n\\end{enumerate}\n\nFrom the center of the disk radiation can travel outward, however it will be optically thick: \\(\\tau = \\int_{0}^{r} \\alpha \\dd{s} >1\\).\nWe can approximate it as \\(\\tau \\approx \\kappa _R \\rho H = \\kappa _R \\Sigma > 1\\), where \\(\\kappa _R\\) is the Rosseland mean opacity.\n\nRadiative transport in a slab can be treated analytically in the diffusion approximation to yield the radiative flux \n%\n\\begin{align}\nF(z) = \\frac{16 \\sigma T^3}{3 \\kappa _R \\rho } \\pdv{T}{z} = - \\frac{4}{3} \\frac{\\sigma}{\\kappa _R \\rho } \\pdv{(T^{4})}{z}\n\\,.\n\\end{align}\n\nWe can define the surface as the height at which \\(\\tau =1\\).\n\nThe flux crossing the \\(z = 0\\) surface is \n%\n\\begin{align}\nF(0) \\approx \\frac{4}{3} \\frac{\\sigma }{\\kappa _R \\rho _c} \\frac{T_c^{4}}{H} \\approx \\frac{4}{3} \\frac{\\sigma T_c^{4}}{\\tau _c}\n\\,.\n\\end{align}\n\n% \\todo[inline]{not zero?}\n\nThe flux at the surface, on the other hand, is\n%\n\\begin{align}\nF(s) \\approx \\frac{4}{3} \\frac{\\sigma}{\\tau _s} T_s^{4} \\approx \\frac{4}{3} \\sigma T_s^{4}\n\\,.\n\\end{align}\n\nSo, their ratio is \n%\n\\begin{align}\n\\frac{F(s)}{F(0)} = \\qty(\\frac{T_s}{T_c})^{4} \\tau _c \n\\,.\n\\end{align}\n\nWe expect \\(T_s < T_c\\), as is natural if flux is going from inside to outside. Then, \\((T_s / T_c)^{4} \\ll 1\\), so unless \\(\\tau _c\\) is extremely large (and, as we will see, it is not) we get \\(F(s) < F(0)\\). \nThe difference \\(F(0) - F(s) \\approx F(0)\\) corresponds to the produced energy \\(D(R)\\), so \n%\n\\begin{align}\n\\frac{4}{3} \\sigma \\frac{T_c^{4}}{\\tau _c} \\approx D(R) = \\frac{3 GM \\dot{M}}{8 \\pi R^3} \\qty[1 - \\qty(\\frac{R _{\\text{in}}}{R})^{1/2}]\n\\,.\n\\end{align}\n\nThis will be another assumption for us. \nAlso, we will use the relations \n%\n\\begin{align}\n\\tau &= \\kappa _R \\Sigma  \\\\\n\\nu \\Sigma &= \\frac{\\dot{M}}{3 \\pi } \\qty[1 - \\qty(\\frac{R _{\\text{in}}}{R})^{1/2}]  \\\\\nv_R &= - \\frac{3 \\nu }{2R} \\qty[1 - \\qty(\\frac{R _{\\text{in}}}{R})^{1/2}]^{-1}  \\\\\n\\kappa _R &= \\kappa _R (\\rho , T, \\dots)  \\\\\n\\nu &= \\nu  (\\rho , T, \\dots) = \\alpha H c_s\n\\,.\n\\end{align}\n\nSince we want to see what the emission will look like, we seek an explicit expression for the surface temperature:\n%\n\\begin{align}\n\\sigma T_s^{4} &= D(R) = \\frac{3 GM \\dot{M}}{8 \\pi R^3} \\qty[1 - \\qty(\\frac{R _{\\text{in}}}{R})^{1/2}]  \\\\\nT_s &= \\qty(\\frac{3 GM \\dot{M}}{8 \\pi \\sigma })^{1/4} R^{-3/4} \\qty[1 - \\qty(\\frac{R _{\\text{in}}}{R})^{1/2}]^{1/4}  \\\\\nT_s &\\approx \\qty(\\frac{3 GM \\dot{M}}{8 \\pi \\sigma R _{\\text{in}}^3 })^{1/4} \\qty( \\frac{R _{\\text{in}}}{R})^{3/4}\n\\marginnote{If  \\(R \\gg R _{\\text{in}}\\).}\n\\label{eq:temperature-accretion-disk}\n\\,.\n\\end{align}\n\nThen, we can see that the temperature decreases as a function of \\(R\\).\n\nLet us define a typical surface temperature \\(T _s^{\\text{typical}}\\) as \n%\n\\begin{align}\nT _s^{\\text{typical}}\n= \n\\qty(\\frac{3 GM \\dot{M}}{8 \\pi \\sigma R _{\\text{in}}^3 })^{1/4}\n\\approx \\SI{e7}{K} \\qty(\\frac{\\dot{M}}{\\SI{e17}{g /s}})^{1/4}\n\\qty(\\frac{M}{M_{\\odot}})^{1/4} \\qty(\\frac{R _{\\text{in}}}{\\SI{e6}{cm}})^{-3/4}\n\\,,\n\\end{align}\n%\nwhich yields soft \\(X\\)-rays, at around \\SI{1}{keV}. \nUsing the complete formula, we find that the temperature is in the form \n%\n\\begin{align}\nT^{4} \\propto \\frac{1}{x^{3/4}} \\qty(1 - \\frac{1}{x^{1/2}})\n\\,,\n\\end{align}\n%\nwhere \\(x = R / R _{\\text{in}}\\). \nWe can maximize this, and we find that the maximum temperature of the disk is found to be \\(T _{\\text{max}} \\approx \\num{.5} T^{\\text{typical}}_s\\). \n\nThere are several radiative processes taking place in an accretion disk: \n\\begin{enumerate}\n    \\item electron scattering;\n    \\item thermal free-free emission (bremsstrahlung).\n\\end{enumerate}\n\nThe latter is dominant, and the characteristic Rosseland mean opacity is \n%\n\\begin{align}\n\\kappa _R^{\\text{bremss}} \\approx \\num{6.6e22} \\rho T^{-7/2} \\SI{}{cm^2 g^{-1}}\n\\,.\n\\end{align}\n\nFor convenience, let us define \n%\n\\begin{align}\nf = 1 - \\sqrt{ \\frac{R _{\\text{in}}}{R}}\n\\,.\n\\end{align}\n\nWe find an algebraic system with all the equations, and finally we get \n%\n\\begin{align}\nH = \\SI{1.7e8}{cm} \\times \\alpha^{-1/10} (\\dot{M}_{16})^{3/20} M^{-3/8} R_{10}^{9/8} f^{3/5}\n\\,,\n\\end{align}\n%\nfrom which we can confirm that \\(R \\gg H\\).\nHere, if a quantity has a subscript such as \\(\\dot{M}_{16}\\), it means that we are normalizing the number to \\SI{e16}{g/s}, or the appropriate cgs unit in general.\nWe can also calculate the central optical depth: \n%\n\\begin{align}\n\\tau _c = 33 \\alpha^{-4/5} \\dot{M}_{16}^{1/5} f^{4/5}\n\\,.\n\\end{align}\n\nAlso, we find that \\(T_s = T_c / 2\\). \n\n\n\\end{document}\n", "meta": {"hexsha": "e72d818223ddfeb543604546ef8495ed11236bd6", "size": 4926, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/compact_objects/nov17.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/compact_objects/nov17.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/compact_objects/nov17.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 33.5102040816, "max_line_length": 211, "alphanum_fraction": 0.6102314251, "num_tokens": 1911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4192687433265391}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Carlos Santos             %    \n% ECE 351-51                %\n% Lab 10                    %\n% 04/14/2020                %\n%                           %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass[12pt]{article}\n\n% Language and font encoding\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{caption}\n\\usepackage{float}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{rotating}\n\\usepackage{setspace}\n\n\n% Sets page size and margins\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\n\n% Useful packages\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{listings}\n\\usepackage{gensymb}\n\\usepackage{graphicx} %package to manage images\n\\usepackage{listings}\n\\usepackage{color}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{gray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mauve}{rgb}{0.58,0,0.82}\n\n\\lstset{frame=tb,\n  language=Python,\n  aboveskip=3mm,\n  belowskip=3mm,\n  showstringspaces=false,\n  columns=flexible,\n  basicstyle={\\small\\ttfamily},\n  numbers=none,\n  numberstyle=\\tiny\\color{gray},\n  keywordstyle=\\color{blue},\n  commentstyle=\\color{dkgreen},\n  stringstyle=\\color{mauve},\n  breaklines=true,\n  breakatwhitespace=true,\n  tabsize=3\n}\n\n%Line Spacing\n\\setstretch{1.5}\n\n%Info for Title Page\n\\title{ECE 351 Lab 10 Report \\\\ Section 52}\n\\date{April 14, 2020}\n\\author{Carlos Santos}\n\\begin{document}\n\n%Make a Title Page\n\\vspace{\\fill}\n\\maketitle\n\\vspace{\\fill}\n\\clearpage\n\n\\maketitle\n\\tableofcontents\n\n\n%Introduction\n\\section{Introduction}\nThis lab's purpose was focused on frequency tools and bode plots using Python.\n%Equations\n\\section{Equations}\n\nTransfer Function:\n\\begin{equation}\n    H(s) = \\frac{\\frac{1}{RC}s}{s^2+\\frac{1}{RC}s+\\frac{1}{LC}}\n\\end{equation}\n\nMagnitude:\n\\begin{equation}\n    H|j\\omega| = \\frac{\\frac{1}{RC}\\omega}{\\sqrt{\\omega ^ 4 + [\\frac{1}{RC}^2 - \\frac{2}{LC}]\\omega ^ 2}+\\frac{1}{LC}^2}\n\\end{equation}\n\nPhase:\n\\begin{equation}\n    <H(J\\omega) = \\frac{\\pi}{2} - tan^{-1}(\\frac{\\frac{1}{RC}\\omega}{-\\omega ^ 2 + \\frac{1}{LC}})\n\\end{equation}\n\n\\begin{equation}\n    x(t) = cos(2\\pi*100t) + cos(2\\pi*3024t) + sin(2\\pi * 50000t)\n\\end{equation}\n\n\\begin{figure}[H]\n\\caption{RLC Circuit}\n\\centering\n\\includegraphics[width=.8\\textwidth]{RLC_Circuit.png}\n\\end{figure}\n\n\n%Methodology\n\\section{Methodology}\n\\begin{enumerate}\n    \\item First find the magnitude and phase equations for the transfer function equation.\n    \\item Turn the magnitude and phase equations into Python equations.\n    \\item Plot the magnitude and phase from $10^3 rad/s \\leq \\omega \\leq 10^6 rad/s$\n    \\item Use scipy.signal.bode to plot the magnitude and phase on a Bode plot.\n    \\item Plot equation 4 from $0\\leq t \\leq 0.01s$\n    \\item Convert equation 4 into the Z-domian using scipy.signal.bilinear().\n    \\item Pass equation 4 through the filer using scipy.signal.lfilter().\n    \\item Lasly. plot the output signal y(t)\n\\end{enumerate}\n\n%Results\n\\section{Results}\n\n\n\\begin{figure}[H]\n\\caption{Task 3.3.1}\n\\centering\n\\includegraphics[width=.8\\textwidth]{hand_solved.png}\n\\end{figure}\n\n\\begin{figure}[H]\n\\caption{Task 3.3.2}\n\\centering\n\\includegraphics[width=.8\\textwidth]{sig_bode.png}\n\\end{figure}\n\n\\begin{figure}[H]\n\\caption{Task 3.3.3}\n\\centering\n\\includegraphics[width=.8\\textwidth]{log_plot.png}\n\\end{figure}\n\n\\begin{figure}[H]\n\\caption{Task 4.3.4}\n\\centering\n\\includegraphics[width=.8\\textwidth]{signal_filtering.png}\n\\end{figure}\n\n\n%Questions\n\\section{Questions}\n\\begin{enumerate}\n    \\item Explain how the filter and filtered output in Part 2 makes sense given the Bode plots from\nPart 1. Discuss how the filter modifies specific frequency bands, in Hz.\n    \\begin{enumerate}\n        \\item By looking at the Bode plot it seems like our filter is a center-band filter. This means it keeps all the frequencies near the middle and discards the rest. This makes sense by looking at the filtered signal plot versus the unfiltered signal plot. It kept all the signals between -1 and 1. Any high frequency signals are going to be clipped.\n    \\end{enumerate}\n    \n\n    \\item Discuss the purpose and workings of\nscipy.signal.bilinear() and scipy.signal.lfilter().\n    \\begin{enumerate}\n        \\item The \"bilinear()\" function converts our equation over to the Z-domain. It returns two items which are the numerator and denominator. The \"lfilter()\" passes the signal through the defined filter and provides the output signal which is filtered.\n    \\end{enumerate}\n    \\item What happens if you use a different sampling frequency in scipy.signal.bilinear() than\nyou used for the time-domain signal?\n    \\begin{enumerate}\n        \\item If sampling frequency is smaller we will get less points on the graph. Likewise the higher the sampling frequency the more points on the graph.\n    \\end{enumerate}\n    \\item Leave any feedback on the clarity of lab tasks, expectations, and deliverables.\n\\end{enumerate}\n    \\begin{enumerate}\n        \\item N/A \n    \\end{enumerate}\n\n\n%Conclusion\n\\section{Conclusion}\nIn conclusion Bode plots helps us visualize the characteristics of a filter. Generating those plots in Python proved to be a simple task given the proper libraries and functions. For Bode plots we need sig.bode(), con.TransferFunction(), and con.bode().\n\n\n\\end{document}", "meta": {"hexsha": "ee7b66af37ddf46e14b4fcc6efecd4eed292de71", "size": 5386, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ECE351_Lab_10_main.tex", "max_stars_repo_name": "carlkid1499/ECE351-Reports", "max_stars_repo_head_hexsha": "8070ef2b32f770d76a98993fbcbd8fd11fa5c27c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ECE351_Lab_10_main.tex", "max_issues_repo_name": "carlkid1499/ECE351-Reports", "max_issues_repo_head_hexsha": "8070ef2b32f770d76a98993fbcbd8fd11fa5c27c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ECE351_Lab_10_main.tex", "max_forks_repo_name": "carlkid1499/ECE351-Reports", "max_forks_repo_head_hexsha": "8070ef2b32f770d76a98993fbcbd8fd11fa5c27c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4316939891, "max_line_length": 355, "alphanum_fraction": 0.7135165243, "num_tokens": 1566, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.8128673155708975, "lm_q1q2_score": 0.41913057674866017}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{graphicx}\n\\usepackage{tcolorbox}\n\n\n\\title{\\vspace{-5.0cm}DD2421 Machine Learning - Lab 1: Decision Trees \\\\ Python version}\n\\author{\\\"Orjan Ekeberg\\\\ Updated 2017 by Martin Hjelm \\& Nils Bore }\n\n\\begin{document}\n\\maketitle\n\n\\section{Preparations}\n\nIn this lab you will use a set of predefined Python functions to\nbuild and manipulate decision trees.  In order to run this, you\nneed to have Python installed.  We also use the Qt graphics library,\nPyQt, for plotting. PyQt comes in different versions 4 or 5. For\nMac users version 5 is recommended. \n\nFor different Windows versions consult the Internet. For Mac use Homebrew \nto install Python and PyQt5. For Ubuntu Python and PyQt are available in the \ndebian package repository. Python and PyQt are also installed on the Unix computers in \nthe computer halls.\n\n\\textbf{Note:} It is possible to do the lab without using the\nplotting functions found in PyQt, but then you will not be able to see the generated\ndecision trees.\n\n\n\\section{MONK datasets}\n\nThis lab uses the artificial MONK dataset from the UC Irvine repository.\nThe MONK's problems are a collection of three binary classification\nproblems MONK-1, MONK-2 and MONK-3 over a six-attribute discrete domain.\nThe attributes \\(a_1, a_2, a_3, a_4, a_5, a_6\\) may take the following values:\n\n\\begin{center}\n  \\begin{tabular}{lll}\n    \\(a_1 \\in \\{1, 2, 3\\}\\) &\n    \\(a_2 \\in \\{1, 2, 3\\}\\) &\n    \\(a_3 \\in \\{1, 2\\}\\)\\\\\n    \\(a_4 \\in \\{1, 2, 3\\}\\) &\n    \\(a_5 \\in \\{1, 2, 3, 4\\}\\) &\n    \\(a_6 \\in \\{1, 2\\}\\)\\\\\n  \\end{tabular}\n\\end{center}\nConsequently, there are 432 possible combinations of attribute values. \nThe \\emph{true} concepts underlying each MONK's problem are given by\ntable \\ref{tab:truemonk}.\n\n\\begin{tcolorbox}\n\\textbf{Assignment 0:}\nEach one of the datasets has properties which makes them hard to learn.\nMotivate which of the three problems is most difficult for a decision\ntree algorithm to learn.\n\\end{tcolorbox}\n\n\\begin{table}\n  \\caption{True concepts behind the MONK datasets \\label{tab:truemonk}}\n  \\begin{center}\n    \\begin{tabular}{|l|l|}\n      \\hline\n      MONK-1 & \\((a_1=a_2)\\vee(a_5=1)\\)\\\\\n      % (attribute\\_1 = attribute\\_2) or (attribute\\_5 = 1)\n      \\hline\n      MONK-2 & \\(a_i=1\\) for exacly two \\(i \\in \\{1, 2, \\ldots, 6\\}\\)\\\\\n      % (attribute\\_n = 1) for EXACTLY TWO choices of n $\\in \\{1,2,...,6\\}$\n      \\hline\n      MONK-3 & \\((a_5=1 \\wedge a_4=1) \\vee (a_5\\ne 4 \\wedge a_2\\ne 3)\\)\\\\\n      %(attribute\\_5  = 3 and attribute\\_4  = 1) or\\\\\n      %(attribute\\_5 != 4 and attribute\\_2 != 3)\\\\\n      \\hline\n    \\end{tabular}\n  \\end{center}\n  MONK-3 has 5\\% additional noise (misclassification) in the training set.\n\\end{table}\n\n\\begin{table}\n  \\caption{Characteristics of the three MONK datasets \\label{tab:monk}}\n  \\begin{center}\n    \\begin{tabular}{|c|c|c|c|c|}\\hline\n      Name & \\# train & \\# test & \\# attributes & \\# classes\\\\ \\hline \\hline\n      MONK-1 & 124 & 432 & 6 & 2\\\\ \\hline\n      MONK-2 & 169 & 432 & 6 & 2\\\\ \\hline\n      MONK-3 & 122 & 432 & 6 & 2\\\\ \\hline\n    \\end{tabular}\n  \\end{center}\n\\end{table}\n\nThe data consists of three separate datasets MONK-1, MONK-2 and\nMONK-3.  Each dataset is further divided into a training and test set,\nwhere the first one is used for learning the decision tree, and the\nsecond one to evaluate its classification accuracy (see table\n\\ref{tab:monk}).  The datasets are available in\nthe file \\verb!monkdata.py!.  In particular, six variables are defined\nwhich contain the datasets:\n\\verb!monk1!, \\verb!monk1test!, \\verb!monk2!,\n\\verb!monk2test!, \\verb!monk3! and \\verb!monk3test!.\nEach dataset is a sequence (more precisely, a \\emph{tuple}) of instances\nof the class \\texttt{Sample}, defined in the same file.\n\nYou can access the data in your own Python scripts by importing\nthe \\texttt{monkdata.py} file as a module like this:\n\\begin{verbatim}\nimport monkdata as m\n\\end{verbatim}\n\nThis makes the variable \\texttt{m} a shorthand for the module so that\nyou can access the datasets by writing \\verb!m.monk1!, etc.\n\n\n\\section{Entropy}\n\nIn order to decide on which attribute to split, decision tree learning\nalgorithms such as ID3 and C4.5 use a statistical property called\n\\emph{information gain}.  It measures how well a particular attribute\ndistinguishes among different target classifications.  Information\ngain is measured in terms of the expected reduction in the\n\\emph{entropy} or impurity of the data.  The entropy of an arbitrary\ncollection of examples is measured by\n\\begin{equation}\n\\textrm{Entropy}(S) = - \\sum_i p_i \\log_2 p_i\n\\label{eq:entropy}\n\\end{equation}\nin which $p_i$ denotes the proportion of examples of class $i$ in $S$. \nThe monk dataset is a binary classification problem (class 0 or 1) and\ntherefore equation (\\ref{eq:entropy}) simplifies to\n\\begin{equation}\n\\textrm{Entropy}(S) = - p_0 \\log_2 p_0 - p_1 \\log_2 p_1\n\\end{equation}\nwhere $p_0$ and $p_1=1-p_0$ are the proportions of examples belonging to class \n$0$ and $1$.\\\\[2ex]\n\n\\begin{tcolorbox}\n\\textbf{Assignment 1:} The file \\verb!dtree.py! defines a function\n\\texttt{entropy} which calculates the entropy of a dataset.  Import\nthis file along with the monks datasets and use it to calculate the\nentropy of the \\emph{training} datasets.\n\\end{tcolorbox}\n\n\n\\begin{center}\n  \\begin{tabular*}{0.9\\textwidth}{|c|c@{\\extracolsep{\\fill}}c|}\n    \\hline\n    Dataset & Entropy & \\\\\n    \\hline\\hline\n    MONK-1 & & \\\\\n    \\hline\n    MONK-2 & & \\\\\n    \\hline\n    MONK-3 & & \\\\\n    \\hline\n  \\end{tabular*}\n\\end{center}\n\n\\begin{tcolorbox}\n\\textbf{Assignment 2:} \nExplain entropy for a uniform distribution \n%and a Gaussian distribution with high and low variance.\nand a non-uniform distribution, present some example distributions with high and low entropy.\n\\end{tcolorbox}\n\n\n\\section{Information Gain}\n\nThe information gain measures the expected reduction in impurity\ncaused by partitioning the examples according to an attribute.\nIt thereby indicates the effectiveness of an attribute in classifying the \ntraining data. The information gain of an attribute $A$, relative to \na collection of examples $S$ is defined as\n\\begin{equation}\n\\textrm{Gain}(S,A) = \\textrm{Entropy}(S) -\n \\sum_{k \\in \\textrm{values}(A)} \\frac{|S_k|}{|S|} \\textrm{Entropy}(S_k)\n\\end{equation}\nwhere $S_k$ is the subset of examples in $S$ for the attribute $A$ has the value $k$.\n\n\n\\begin{tcolorbox}\n\\textbf{Assignment 3:} Use the function \\texttt{averageGain} (defined\nin \\verb!dtree.py!)  to calculate the expected information gain\ncorresponding to each of the six attributes.  Note that the attributes\nare represented as instances of the class Attribute (defined in\n\\verb!monkdata.py!) which you can access via \\verb!m.attributes[0]!,\n..., \\verb!m.attributes[5]!. Based on the results, which attribute \nshould be used for splitting the examples at the root node? \n\\end{tcolorbox}\n\n\\begin{center}\n  Information Gain\\\\[0.5ex]\n  \\begin{tabular*}{\\textwidth}{|c@{\\extracolsep{\\fill}}|c|c|c|c|c|c|}\n    \\hline\n    Dataset & $a_1$ & $a_2$ & $a_3$ & $a_4$ & $a_5$ & $a_6$ \\\\\n    \\hline\n    \\verb!MONK-1 ! & & & & & & \\\\\n    \\hline\n    \\verb!MONK-2 ! & & & & & & \\\\\n    \\hline\n    \\verb!MONK-3 ! & & & & & & \\\\\n    \\hline\n  \\end{tabular*}\n\\end{center}\n\n\\begin{tcolorbox}\n\\textbf{Assignment 4:} \nFor splitting we choose the attribute that maximizes the information gain, Eq.3. \nLooking at Eq.3 how does the entropy of the subsets, $S_k$, look like when the \ninformation gain is maximized? How can we motivate using the information gain\nas a heuristic for picking an attribute for splitting? Think about reduction\nin entropy after the split and what the entropy implies.\n\\end{tcolorbox}\n\n\n\\section{Building Decision Trees}\n\nSplit the \\texttt{monk1} data into subsets according to the selected\nattribute using the function \\texttt{select} (again, defined in\n\\verb!dtree.py!)  and compute the information gains for the nodes on\nthe next level of the tree.  Which attributes should be tested for\nthese nodes?\n\nFor the \\texttt{monk1} data draw the decision tree up to the first two\nlevels and assign the majority class of the subsets that resulted from\nthe two splits to the leaf nodes.  You can use the predefined function\n\\texttt{mostCommon} (in \\verb!dtree.py!) to obtain the majority class\nfor a dataset.\n\nNow compare your results with that of a predefined routine for ID3.\nUse the function \\verb!buildTree(data, m.attributes)! to build the\ndecision tree.  If you pass a third, optional, parameter to\n\\texttt{buildTree}, you can limit the depth of the generated tree.\n\nYou can use \\texttt{print} to print the resulting tree in text form,\nor use the function \\texttt{drawTree} from the file \\verb!drawtree_qt4.py! \nor \\verb!drawtree_qt5.py!, depending on your PyQt version, to draw a graphical \nrepresentation.\n\n\\begin{tcolorbox}\n\\textbf{Assignment 5:} \nBuild the full decision trees for all three Monk datasets using\n\\texttt{buildTree}.  Then, use the function \\texttt{check} to measure the performance\nof the decision tree on both the training and test datasets.\n\nFor example to built a tree for \\texttt{monk1} and compute the performance on the test data\nyou could use\n\\begin{verbatim}\nimport monkdata as m\nimport dtree as d\n\nt=d.buildTree(m.monk1, m.attributes);\nprint(d.check(t, m.monk1test))\n\\end{verbatim}\n\nCompute the train and test set errors for the three Monk datasets for\nthe full trees. Were your assumptions about the datasets correct? Explain the \nresults you get for the training and test datasets.\n\\end{tcolorbox}\n\n\\begin{center}\n  \\begin{tabular*}{0.7\\textwidth}{|c|@{\\extracolsep{\\fill}}c|c|}\n    \\hline\n    & $E_\\textrm{train}$ & $E_\\textrm{test}$ \\\\\n    \\hline\\hline\n    \\verb#MONK-1# & & \\\\\n    \\hline\n    \\verb#MONK-2# & & \\\\\n    \\hline\n    \\verb#MONK-3# & & \\\\\n    \\hline\n  \\end{tabular*}\n\\end{center}\n\n\\section{Pruning}\nThe idea of \\emph{reduced error pruning} is to consider each node in\nthe tree as a candidate for removal.  A node is removed if the\nresulting pruned tree performs at least as well as the original tree\nover a separate \\emph{validation dataset}, i.e. a dataset not used\nduring training.  When a node is removed, the subtree rooted at that\nnode is replaced by a leaf node, to which the majority classification\nof examples in that node is assigned.\n\nFor the purpose of pruning, we have to split our original training\ndata into one training set for building the tree and one validation\nset for pruning.  Notice, that using the test set for validation would\nbe cheating because we would then no longer be able to use the test\nset for independently estimating the true error of our pruned decision\ntree.  Instead, we will randomly partition the original training set into\ntraining and validation set.  This can be done by defining a function\nwhich randomly reorders the data samples and returns the first and second\nparts separately:\n\\begin{verbatim}\nimport random\n\ndef partition(data, fraction):\n    ldata = list(data)\n    random.shuffle(ldata)\n    breakPoint = int(len(ldata) * fraction)\n    return ldata[:breakPoint], ldata[breakPoint:]\n\nmonk1train, monk1val = partition(m.monk1, 0.6)\n\\end{verbatim}\n\nIn the file \\verb!dtree.py! there is a utility function \\texttt{allPruned}\nwhich returns a sequence of all possible ways a given tree can be pruned.\n\nWrite code which performs the complete pruning by repeatedly calling\n\\texttt{allPruned} and picking the tree which gives the best\nclassification performance on the validation dataset.  You should stop\npruning when all the pruned trees perform worse than the current\ncandidate.\n\n\\begin{tcolorbox}\n\\textbf{Assignment 6:}\nExplain pruning from a bias variance trade-off perspective.\n\\end{tcolorbox}\n\n\\begin{tcolorbox}\n\\textbf{Assignment 7:} Evaluate the effect pruning has on the test\nerror for the \\texttt{monk1} and \\texttt{monk3} datasets, in\nparticular determine the optimal partition into training and pruning\nby optimizing the parameter \\texttt{fraction}.  Plot the\nclassification error on the test sets as a function of the parameter\n\\texttt{fraction} $\\in \\{0.3,0.4,0.5,0.6,0.7,0.8\\}$. \\\\\n\nNote that the split of the data is random. We therefore need to compute \nthe statistics over several runs of the split to be able to draw any \nconclusions. Reasonable statistics includes mean and a measure of the spread.\nDo remember to print axes labels, legends and data points as you will not pass without them.\n\\end{tcolorbox}\n\n\n\\end{document}\n", "meta": {"hexsha": "13e15acceea928e3e3825b06bf0ff42ff88c34da", "size": 12392, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "decision trees/dectrees-py.tex", "max_stars_repo_name": "Manu-Fraile/Machine-Learning", "max_stars_repo_head_hexsha": "7428a594b07c23b6b4326ad3f80b11860ac8d507", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "decision trees/dectrees-py.tex", "max_issues_repo_name": "Manu-Fraile/Machine-Learning", "max_issues_repo_head_hexsha": "7428a594b07c23b6b4326ad3f80b11860ac8d507", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "decision trees/dectrees-py.tex", "max_forks_repo_name": "Manu-Fraile/Machine-Learning", "max_forks_repo_head_hexsha": "7428a594b07c23b6b4326ad3f80b11860ac8d507", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2132132132, "max_line_length": 93, "alphanum_fraction": 0.7306326662, "num_tokens": 3661, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.8006919997179627, "lm_q1q2_score": 0.4190984858828991}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{mathtools}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\degrees}{^{\\circ}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 74, Week 14}\n\\maketitle\n\n\n\\section{Mon Lec, 3a}\nLet $a$ be the length of this rectangle that is opposite the wall, and $b$ be the length of the other side. So we have $a+2b \\leq 36$, and we try to maximize $ab$. We can simplify the first equation to $a = 36 - 2b$\n\\newline\nBy AM-GM, we have that $\\frac{2a+b}{2} \\geq \\sqrt{2ab}$, now since we know that $a+2b \\leq 36$, we can subsitute that in.\n$$18 \\geq \\frac{2a+b}{2} \\geq \\sqrt{2ab}$$\nThus the maximum the area $ab$ can be is $18^2/2 = 162$. Now we try to find an $a,b$ such that $ab = 162$.\nLet $a = 9, b = 18$, and $ab=162$, achieving the maximum.\n\n\\section{Mon Lec, 5a}\nWe manipulate $2 \\sqrt x > 3 - \\frac{1}{x}$, and it is equivalent to showing\n$$2 \\sqrt{x} + \\frac{1}{x} \\geq 3$$\nThen apply AM-GM to see that $\\frac{\\sqrt{x}+\\sqrt{x}+1/x}{3} \\geq\n\\sqrt[3]{\\sqrt{x}\\sqrt{x}1/x} = 1$. Rearranging this gives\n$$2 \\sqrt{x} + \\frac{1}{x} \\geq 3$$\nThus we have proven the statement.\n\n\n\\section{Mon Lec, 6}\nWe say two inequalities are equivalent when they are true and false at the same time.\n\\newline\nIn the first equation $(x-a)^2+1>0$, $(x-a)^2$ is non-negative, so the statement is always true.\n$$4ax^2 + 4x + 1 > 0$$\n$$(4a-4)x^2 + (2x+1)^2 > 0$$\nThis inequality holds true when $(4a-4)>0$, so the two inequalities are equivalent when $a > 1$\n\\newpage\n\n\n\\section{Mon Dis, 1a}\nBy AM-GM, $\\frac{a+b}{2} \\geq \\sqrt{ab}$, $\\frac{b+c}{2} \\geq \\sqrt{bc}$, etc.\n\\newline\nWe can multiply these equations to get\n$$\\frac{(a+b)(b+c)...(e+a)}{2^5} \\geq \\sqrt{a^2b^2c^2d^2e^2}$$\n$$(a+b)(b+c)(c+d)(d+e)(e+a) \\geq 32abcde$$\n\n\n\\section{Mon Dis, 1b}\nBy AM-CM, $(\\sum_{n=1}^{2021} n) /2021 \\geq \\sqrt[2021]{2021!}$. We can apply the arithmetic series sum to the lhs:\n$$\\frac{(2021+1)2021}{2 \\times 2021} \\geq \\sqrt[2021]{2021!}$$\n$$(\\frac{2022}{2}) ^ {2021} \\geq 2021!$$\nThus it is proven.\n\n\n\\section{Mon Dis, 3c}\nLet our box intersect the ellipsoid in octant 1 at $(x,y,z)$. Since it is on the ellipsoid we have $\\frac{x^2}{a^2}+\\frac{y^2}{b^2}+\\frac{z^2}{c^2}=1$.\n\\newline\nBy AM-GM inequality we have $$(\\frac{x^2}{a^2}+\\frac{y^2}{b^2}+\\frac{z^2}{c^2})/3 \\geq \\sqrt[3]{\\frac{x^2}{a^2}\\frac{y^2}{b^2}\\frac{z^2}{c^2}}$$\n$$\\frac{1}{3} \\geq \\sqrt[3]{\\frac{x^2y^2z^2}{a^2b^2c^2}}$$\n$$\\frac{1}{27} \\geq \\frac{x^2y^2z^2}{a^2b^2c^2}$$\nNow the volume of our cube is simply $8xyz$ since each side is double the intersection point in octant 1.\n$$\\frac{1}{27a^2b^2c^2} \\geq x^2y^2z^2$$\n$$xyz \\leq abc\\sqrt{\\frac{1}{27}}$$\n$$8xyz \\leq 8abc\\sqrt{\\frac{1}{27}}$$\nThus we have found the maximum value.\n\\end{document}\n", "meta": {"hexsha": "4c8390b20d9aa95f933aec7990864023f94e5ac9", "size": 3317, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week14/main.tex", "max_stars_repo_name": "TianshuangQiu/Math74-Homework", "max_stars_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week14/main.tex", "max_issues_repo_name": "TianshuangQiu/Math74-Homework", "max_issues_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week14/main.tex", "max_forks_repo_name": "TianshuangQiu/Math74-Homework", "max_forks_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.4880952381, "max_line_length": 215, "alphanum_fraction": 0.6596321978, "num_tokens": 1355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.8006919997179627, "lm_q1q2_score": 0.4190984858828991}}
{"text": "% Sample LaTeX file for creating a paper in the Morgan Kaufmannn two\n% column, 8 1/2 by 11 inch proceedings format.\n\n\\documentclass[]{article}\n\\usepackage{proceed2e}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{bm}\n\\usepackage{hyperref}\n\\usepackage{natbib}\n\\usepackage{multirow}\n\\usepackage{fancyhdr}\n\\usepackage{latexsym,amsbsy,amssymb,color,xspace,booktabs}\n\n\\include{macros}\n\\include{local_macros}\n\n\\title{Collaborative Multi-output Gaussian Processes}\n\n\\author{} % LEAVE BLANK FOR ORIGINAL SUBMISSION.\n          % UAI  reviewing is double-blind.\n\n% The author names and affiliations should appear only in the accepted paper.\n%\n\\author{ {\\bf Trung V. Nguyen} \\\\\nANU \\& NICTA \\\\\nCanberra, Australia\\\\\n\\And\n{\\bf Edwin V. Bonilla}  \\\\\nNICTA \\& ANU          \\\\\nSydney, Australia \\\\\n}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\\input{abstract}\n\\end{abstract}\n\n\\section{INTRODUCTION}\n\\input{intro}\n\n\\section{MODEL SPECIFICATION \\label{sec:model}}\n\\input{model}\n\n\\section{INFERENCE \\label{sec:inference}}\n\\input{inference}\n\n\\section{EXPERIMENTS \\label{sec:experiments}}\n\\input{experiments}\n\n\\section{DISCUSSION \\label{sec:discussion}}\n\\input{discussion}\n\n\\subsubsection*{Acknowledgements}\n\\input{acks}\n\n\\bibliographystyle{apalike}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "5d4d3af450ff7ae13f1570b54fbf3156ea268d1a", "size": 1324, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/paper.tex", "max_stars_repo_name": "fkopsaf/cogp", "max_stars_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2015-05-28T13:46:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T11:02:08.000Z", "max_issues_repo_path": "paper/paper.tex", "max_issues_repo_name": "fkopsaf/cogp", "max_issues_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-07-30T08:52:36.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-04T01:44:21.000Z", "max_forks_repo_path": "paper/paper.tex", "max_forks_repo_name": "trungngv/cogp", "max_forks_repo_head_hexsha": "3b07f621ff11838e89700cfb58d26ca39b119a35", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2016-04-03T03:18:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-23T13:28:55.000Z", "avg_line_length": 20.0606060606, "max_line_length": 77, "alphanum_fraction": 0.752265861, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.41905868264495794}}
{"text": "\\documentclass[]{article}\n\\usepackage[left=3cm, right3cm, top=2cm, bottom=3cm]{geometry}\n\n\\usepackage[table]{xcolor}\n\\usepackage{rotating}\n\n\n%opening\n\\author{Matt B\\ae{}kgaard Pedersen}\n\\title{The ProcessJ Type System}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\n\\end{abstract}\n\n\\section{ProcessJ Types}\n\n\\subsection{Primitive Types}\nProcessJ has 11 primitive types shown in Table~\\ref{tab:primitiveTypes}.\n\\begin{table}[!h]\n  \\begin{center}\n    \\caption{ProcessJ primitive types}\n    \\label{tab:primitiveTypes} \n    \\begin{tabular}{|l|l|}\\hline\n      Type Name & Values \\\\ \\hline\\hline\n      byte & \\\\\n      short & \\\\\n      char & \\\\\n      int & \\\\\n      long & \\\\\n      float & \\\\\n      double & \\\\\n      bool & \\{true, false\\}\\\\\n      string & \\\\\n      barrier & \\\\\n      timer & \\\\ \\hline\n    \\end{tabular}\n  \\end{center}\n\\end{table}\n\n\\subsection{Constructed Types}\nIf we count mobile procedures, ProcessJ has 6 constructed types; they are shown in Table~\\ref{tab:constructedTypes}.\n\\begin{table}[!h]\n  \\begin{center}\n    \\caption{ProcessJ constructed types}\n    \\label{tab:constructedTypes} \n    \\begin{tabular}{|l|l|}\\hline\n      Type Name & Representation \\\\ \\hline\\hline\n      Array    & {\\it Array}($\\alpha$, {\\it index})\\\\\n      Record   & {\\it Record}({\\it name},\\{($n_1,t_1$),$\\ldots$,($n_m,t_m$)\\})\\\\\n      Protocol & {\\it Protocol}({\\it name},\\{({\\it tag}$_1$,\\{($n_{1,1},t_{1,1}$),$\\ldots$,($n_{1,m_1},t_{1,m_1}$)\\})\\\\\n               & \\hspace*{2.6cm}$\\vdots$\\\\\n      & \\hspace*{2.475cm}({\\it tag}$_k$,\\{($n_{k,1},t_{k,1}$),$\\ldots$,($n_{k,m_k},t_{1,m_k}$)\\})\\}\\\\\n      Channel  & {\\it Channel}($\\alpha$,{\\it access})\\\\\n      Channel end & {\\it ChannelEnd}($\\alpha$, {\\it end}), $\\alpha$ is a Channel.\\\\ \n      Procedure & {\\it Procedure}({\\it name},($t_1,t_2,\\ldots,t_n$),$t$)\\\\\\hline\n    \\end{tabular}\n  \\end{center}\n\\end{table}\n\n\\newcommand{\\teq}{=_{\\cal T}}\n\\newcommand{\\tev}{\\sim_{\\cal T}}\n\\newcommand{\\tac}{:=_{\\cal T}}\n\\newcommand{\\tlt}{<_{\\cal T}}\n\\newcommand{\\tle}{\\leq_{\\cal T}}\n\n\\section{Helper Functions}\n\n\\subsection{Ceiling}\n\n\\[\n\\lceil \\alpha, \\beta \\rceil := \\left\\{\n\\begin{array}{ll}\n\\alpha & \\beta \\tle \\alpha\\\\\n\\beta  & \\alpha \\tlt \\beta\\\\\n\\bot   & \\mbox{otherwise}\n\\end{array}\\right.\n\\]\n\n\\subsection{$\\tlt$}\n\n\\subsubsection{Primitive Types}\n\nA primitive type $\\alpha$ is ``type-wise less than'' another primitive type $\\beta$, if \na variable of type $\\beta$ can hold any value of type $\\alpha$. This definition seems to be exactly that of assignment compatible -- and it is, but it has to be defined somewhere, so here we go:\n\n\\[\nbyte \\tlt short \\tlt char \\tlt int \\tlt long\n\\]\nas well as \n\\[\nfloat \\tlt double\n\\]\nbut also\n\\[\nint \\tlt float \\wedge long \\tlt double\n\\]\n$\\tlt$ is, of course, transitive, so if $(\\alpha \\tlt \\beta) \\wedge (\\beta \\tlt \\delta) \\Rightarrow \\alpha \\tlt \\delta$.\n\n\\begin{center}\n\\begin{tabular}{|l||l|l|l|l|l|l|l|l|l|l|l|}\\hline\n\\begin{turn}{45}$\\,\\,\\alpha \\tlt \\beta$\\end{turn} & \n\t\\begin{turn}{90}{byte}\\end{turn} & \n\t\\begin{turn}{90}{short}\\end{turn} &\n\t\\begin{turn}{90}{char}\\end{turn} &\n\t\\begin{turn}{90}{int}\\end{turn} &\n\t\\begin{turn}{90}{long}\\end{turn} &\n\t\\begin{turn}{90}{float} \\end{turn}&\n\t\\begin{turn}{90}{double\\quad{}\\quad{}}\\end{turn} &\n\t\\begin{turn}{90}{bool}\\end{turn}&\n\t\\begin{turn}{90}{string}\\end{turn} &\n\t\\begin{turn}{90}{barrier}\\end{turn} &\n\t\\begin{turn}{90}{timer}\\end{turn} \\\\ \\hline\\hline\nbyte    & F & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & F & F & F & F\\\\ \\hline\nshort   & F & F & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & F & F& F & F\\\\ \\hline\nchar    & F & F & F & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & F & F & F & F\\\\ \\hline\nint     & F & F & F & F & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & F & F & F & F\\\\ \\hline\nlong    & F & F & F & F & F & \\cellcolor{gray!25}T & \\cellcolor{gray!25}T & F & F & F & F\\\\ \\hline\nfloat   & F & F & F & F & F & F & \\cellcolor{gray!25}T & F & F & F & F\\\\ \\hline\ndouble  & F & F & F & F & F & F & F & F & F & F & F\\\\ \\hline\nbool    & F & F & F & F & F & F & F & F & F & F & F \\\\ \\hline\nstring  & F & F & F & F & F & F & F & F & F & F & F \\\\ \\hline\nbarrier & F & F & F & F & F & F & F & F & F & F & F \\\\ \\hline\ntimer   & F & F & F & F & F & F & F & F & F & F & F\\\\ \\hline\n\\end{tabular}\n\\end{center}\n\n\\subsubsection{Constructed Types}\n\n\\paragraph{Protocol}\n\n\\[\n\\alpha = Protocol(name_1,\\{(tag_{1,1},\\{(n_{1,1,1},t_{1,1,1}),\\ldots,(n_{1,1,m_{1,1}},t_{1,1,m_{1,1}})\\}),\n\\]\n\\[\n\\hspace*{3.6cm}(tag_{1,2},\\{(n_{1,2,1},t_{1,2,1}),\\ldots,(n_{1,2,m_{1,2}},t_{1,2,m_{1,2}})\\}),\n\\]\n\\[\n\\vdots\n\\]\n\\[\n\\hspace*{3.9cm}(tag_{1,k_1},\\{(n_{1,k_1,1},t_{1,k_1,1}),\\ldots,(n_{1,k_1,m_{1,k_1}},t_{1,k_1,m_{1,k_1}})\\})\\})\n\\]\n\\[\n\\beta = Protocol(name_2,\\{(tag_{2,1},\\{(n_{2,1,1},t_{2,1,1}),\\ldots,(n_{2,1,m_{2,1}},t_{2,1,m_{2,1}})\\}),\n\\]\n\\[\n\\hspace*{3.6cm}(tag_{2,2},\\{(n_{2,2,1},t_{2,2,1}),\\ldots,(n_{2,2,m_{2,2}},t_{2,2,m_{2,2}})\\}),\n\\]\n\\[\n\\vdots\n\\]\n\\[\n\\hspace*{3.9cm}(tag_{2,k_2},\\{(n_{2,k_2,1},t_{3,k_2,1}),\\ldots,(n_{2,k_2,m_{2,k_2}},t_{1,k_2,m_{2,k_2}})\\})\\})\n\\]\n\n\\[\n\\alpha \\tle \\beta \\Leftrightarrow (\\forall i: (1 \\leq i \\leq k_1): \\exists j: (1 \\leq j \\leq k_2): tag_{1,i} = tag_{2,j} \\wedge \n\\]\n\\[\n(m_{1,i} = m_{2,j}) \\wedge \\bigwedge^{m_{1,i}}_{k=1}(n_{1,i,k} = n_{2,i,k}) \\wedge (t_{1,i,k} \\tev t_{2,i,k})\n\\]\n\n\\paragraph{Procedures}\n\nNot sure what goes here yet.\n\n\n\\subsection{$\\tle$}\n\n\\[\n\\alpha \\tle \\beta \\Leftrightarrow (\\alpha \\teq \\beta) \\vee (\\alpha \\tle \\beta)\n\\]\n\n\\section{Primitive Types}\n\n\\subsection{Type Equality ($\\teq$)}\n\n\\[\n\\alpha \\teq \\beta\\ \\Leftrightarrow \\mbox{Primitive}_?(\\alpha) \\wedge \\mbox{Primitive}_?(\\beta) \\wedge \\alpha = \\beta\n\\]\nwhere $\\alpha$ and $\\beta$ are types.\n\n\\subsection{Type Equivalence ($\\tev$)}\n\nFor primitive types, type equivalence is the same as type equality, so for two types $\\alpha$ and $\\beta$:\n\\[\n\\alpha \\tev \\beta \\Leftrightarrow Primitive_?(\\alpha) \\wedge Primitive_?(\\beta) \\wedge \\alpha \\tle \\beta\n\\]\n\n\n\\subsection{Type Assignment Compatibility ($\\tac$)}\n\n\\[\n\\alpha \\tac \\beta \\Leftrightarrow Primitive_?(\\alpha) \\wedge Primitive_?(\\beta) \\wedge  \\beta \\leq \\alpha\n\\]\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Constructed Types}\n\n\\subsection{Type Equality ($\\teq$)}\n\n\\subsubsection{Arrays}\n\\[\n\\alpha = Array(t_1, I_1)\\ \\wedge \\beta =  Array(t_2, I_2)\n\\]\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow Array_?(\\alpha) \\wedge Array_?(\\beta) \\wedge (t_1 \\teq t_2) \\wedge ((I_1 = I_2) \\vee (I_1 = \\bot) \\vee (I_2 = \\bot))\n\\]\n\n\\subsubsection{Records}\n\n\\[\n\\alpha = Record(name_1, \\{(n_{1,1},t_{1,1}),\\ldots,(n_{1,m_1}, t_{1,m_1})\\})\n\\]\n\\[\n\\beta = Record(name_2, \\{(n_{2,1},t_{2,1}),\\ldots,(n_{2,m_2}, t_{2,m_2})\\})\n\\]\n\\paragraph{Name Equality:}\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow Record_?(\\alpha) \\wedge Record_?(\\beta) \\wedge (name_1 = name_2)\n\\]\n\\paragraph{Structural Equality:}\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow Record_?(\\alpha) \\wedge Record_?(\\beta) \\wedge (m_1 = m_2) \\wedge \\bigwedge^{m_1}_{i=1} (t_{1,i} \\teq t_{2,i})\n\\]\n\t\n\\subsubsection{Protocols}\n\n\\subsubsection{Channel}\n\nThe access part of a channel can be {\\it shared}, {\\it shared read}, {\\it shared write}, or {\\it not shared}. \n\\\n\\[\n\\alpha = Channel(t_1, a_1) \\wedge \\beta = Channel(t_2, a_2)\\]\n\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow Channel_?(\\alpha) \\wedge Channel_?(\\beta) \\wedge (t_1 \\teq t_2) \\wedge (a_1 = a_2)\n\\]\n\n\\subsubsection{Channel Ends}\n\nFor channel ends to be equivalent, they have to be the same ends and their channels have to be equivalent:\n\\[\n\\alpha = ChannelEnd(\\delta, end_1) \\wedge \\beta = ChannelEnd(\\gamma, end_2)\n\\]\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow ChannelEnd_?(\\alpha) \\wedge ChannelEnd_?(\\beta) \\wedge Channel_?(\\delta) \\wedge Channel_?(\\gamma) \\wedge (end_1 = end_2)\n\\]\n\n\\subsubsection{Procedures}\n\n\\[\n\\alpha = procedure(name_1, \\{t_{1,1},\\ldots,t_{1,m_1}\\}, t_1) \\wedge\n\\beta = procedure(name_2, \\{t_{2,1},\\ldots,t_{2,m_2}\\}, t_2) \\wedge\n\\]\n\\[\n\\alpha \\teq \\beta \\Leftrightarrow (m_1 = m_2) \\wedge (t_1 \\teq t_2) \\wedge (name_1 = name_2) \\wedge \\bigwedge^{m_1}_{i=1}(t_{1,i} \\teq t_{2,i})\n\\]\n\\subsection{Type Equivalence ($\\teq=v$)}\n\nFor all constructed types $\\alpha$ and $\\beta$, we have:\n\\[\n\\alpha \\tev \\beta \\Leftrightarrow \\alpha \\teq \\beta\n\\]\n\n\\subsection{Type Assignment Compatibility ($\\tac$)}\n\n\\subsubsection{Arrays}\n\n\\[\n\\alpha = Array(t_1, I_1) \\wedge \\beta =  Array(t_2, I_2)\n\\]\n\\[\n\\alpha \\tac \\beta \\Leftrightarrow Array_?(\\alpha) \\wedge Array_?(\\beta) \\wedge\n\\]\n\\[\n((Protocol_?(t_1) \\wedge Protocol_?(t_2) \\wedge (t_2 \\tle t_1)) \\vee\n(\\neg{}Protocol_?(t_1) \\wedge \\neg{}Protocol_?(t_2) \\wedge (t_1 \\teq t_2)\n\\]\n\\subsubsection{Records}\n\n\\[\n\\alpha = Record(name_1, \\{(n_{1,1},t_{1,1}),\\ldots,(n_{1,m_1}, t_{1,m_1})\\})\n\\]\n\\[\n\\beta = Record(name_2, \\{(n_{2,1},t_{2,1}),\\ldots,(n_{2,m_2}, t_{2,m_2})\\})\n\\]\n\n\\[\n\\alpha \\tac \\beta \\Leftrightarrow \\alpha \\tev \\beta\n\\]\n\\subsubsection{Protocols}\n\n\n\n\\subsubsection{Channels}\n\nChannels are non-assignable.\n\n\\subsubsection{Channel Ends}\n\n\\[\n\\alpha = ChannelEnd(\\delta, end_1) \\wedge \\beta = ChannelEnd(\\gamma, end_2)\n\\]\n\\[\n\\alpha \\tac \\beta \\Leftrightarrow (end_1 = end_2) \\wedge\n\\]\n\\[\n ((Protocol_?(\\delta) \\wedge Protocol_?(\\gamma) \\wedge (\\delta \\tle \\gamma)) \\vee\n\\]\n\\[\n(\\neg{}Protocol_?(\\delta) \\wedge \\neg{}Protocol_?(\\gamma) \\wedge (\\delta \\teq \\gamma))\n\\]\n\n\n\\subsubsection{Proceudres}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "cfedc265a5d00ae1baf05f879359489c5f521c3f", "size": 9562, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs+notes/ProcessJ-TypeSystem.tex", "max_stars_repo_name": "a-thoma/processj", "max_stars_repo_head_hexsha": "fbd6c9bacad7e47eab765c9f10c398a9d03d6455", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs+notes/ProcessJ-TypeSystem.tex", "max_issues_repo_name": "a-thoma/processj", "max_issues_repo_head_hexsha": "fbd6c9bacad7e47eab765c9f10c398a9d03d6455", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2019-02-27T22:51:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-25T15:25:09.000Z", "max_forks_repo_path": "docs+notes/ProcessJ-TypeSystem.tex", "max_forks_repo_name": "a-thoma/processj", "max_forks_repo_head_hexsha": "fbd6c9bacad7e47eab765c9f10c398a9d03d6455", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-05-20T04:21:23.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-14T21:15:35.000Z", "avg_line_length": 28.9757575758, "max_line_length": 194, "alphanum_fraction": 0.6051035348, "num_tokens": 3837, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410572017153, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.41905868175484867}}
{"text": "%%\n%% Template appendix.tex\n%%\n\n\\appendix\n\n\\chapter{How to Obtain the Datasets}\n\\label{cha:datasets}\n\nThe following SQL query is used to get the main SDSS dataset containing 2.8 million\nlabelled objects from the Sloan SkyServer:\\footnote{\n\t\\url{http://skyserver.sdss.org/CasJobs/}}\n\n\\begin{minted}[fontsize=\\footnotesize, frame=single, tabsize=4]{sql}\nSELECT\n\t-- right ascension and declination in degrees\n\tp.ra, p.dec,\n\t\n\t-- class of object, expert opinion (galaxy, star, or quasar)\n\tCASE s.class WHEN 'GALAXY' THEN 'Galaxy'\n\t\t\t\t WHEN 'STAR' THEN 'Star'\n\t\t\t\t WHEN 'QSO' THEN 'Quasar'\n\t\t\t\t END AS class,\n\t\n\ts.subclass, -- subclass of object\n\t\n\t-- redshift of object from spectrum with error, expert opinion\n\ts.z AS redshift,\n\ts.zErr AS redshiftErr,\n\ts.zWarning,\n\t\n\t-- PSF and Petrosian mags in 5 bands (ugriz) with error\n\tp.psfMag_u, p.psfMagErr_u,\n\tp.psfMag_g, p.psfMagErr_g,\n\tp.psfMag_r, p.psfMagErr_r,\n\tp.psfMag_i, p.psfMagErr_i,\n\tp.psfMag_z, p.psfMagErr_z,\n\t\n\tp.petroMag_u, p.petroMagErr_u,\n\tp.petroMag_g, p.petroMagErr_g,\n\tp.petroMag_r, p.petroMagErr_r,\n\tp.petroMag_i, p.petroMagErr_i,\n\tp.petroMag_z, p.petroMagErr_z,\n\t\n\t-- extinction values\n\tp.extinction_u, p.extinction_g, p.extinction_r,\n\tp.extinction_i, p.extinction_z,\n\t\n\t-- size measurement in r-band in arc seconds\n\tp.petroRad_r, p.petroRadErr_r\n\nFROM PhotoObj AS p\nJOIN SpecObj AS s\nON s.bestobjid = p.objid\n\nWHERE\n\t-- only include objects with complete and reasonably accurate data\n\tp.psfMagErr_u BETWEEN 0 AND 3\n\tAND p.psfMagErr_g BETWEEN 0 AND 3\n\tAND p.psfMagErr_r BETWEEN 0 AND 3\n\tAND p.psfMagErr_i BETWEEN 0 AND 3\n\tAND p.psfMagErr_z BETWEEN 0 AND 3\n\tAND p.petroMagErr_u BETWEEN 0 AND 3\n\tAND p.petroMagErr_g BETWEEN 0 AND 3\n\tAND p.petroMagErr_r BETWEEN 0 AND 3\n\tAND p.petroMagErr_i BETWEEN 0 AND 3\n\tAND p.petroMagErr_z BETWEEN 0 AND 3\n\tAND p.petroRadErr_r BETWEEN 0 AND 3\n\tAND s.zErr BETWEEN 0 AND 0.1\n\tAND s.zWarning = 0    -- spectrum is ok\n\\end{minted}\n\n\nThe following query is used to extract photometric measurements from all 800 million\nin the database. Since the file is fairly big (around 200 GB in size),\na special request might need to be made.\n\n\\begin{minted}[fontsize=\\footnotesize, frame=single, tabsize=4]{sql}\nSELECT\n\tp.ra, p.dec,\n\tCASE s.class WHEN 'GALAXY' THEN 'Galaxy'\n\t\t\t\t WHEN 'STAR' THEN 'Star'\n\t\t\t\t WHEN 'QSO' THEN 'Quasar'\n\t\t\t\t END AS class,\n\ts.subclass,\n\ts.z AS redshift,\n\ts.zErr AS redshiftErr,\n\ts.zWarning,\n\tp.psfMag_u, p.psfMagErr_u,\n\tp.psfMag_g, p.psfMagErr_g,\n\tp.psfMag_r, p.psfMagErr_r,\n\tp.psfMag_i, p.psfMagErr_i,\n\tp.psfMag_z, p.psfMagErr_z,\n\tp.petroMag_u, p.petroMagErr_u,\n\tp.petroMag_g, p.petroMagErr_g,\n\tp.petroMag_r, p.petroMagErr_r,\n\tp.petroMag_i, p.petroMagErr_i,\n\tp.petroMag_z, p.petroMagErr_z,\n\tp.extinction_u, p.extinction_g, p.extinction_r,\n\tp.extinction_i, p.extinction_z,\n\tp.petroRad_r, p.petroRadErr_r\nFROM PhotoObj AS p\nLEFT JOIN SpecObj AS s\nON s.bestobjid = p.objid\n\\end{minted}\n\n\n\n\n\n\n%\\chapter{Guide to Using mclearn}\n%\\label{cha:mclearn}\n\n%\\section{Installation}\n%\\label{sub:installation}\n\n%\\section{Usage and Examples}\n%\\label{sub:usage}\n\n\n%\\chapter{Vectorisation of the Variance Estimation}\n%\\label{cha:vectorise}\n\n%In estimating the variance of the unlabelled pool, there are two matrices we wish to compute...\n\n\n\n\\chapter{Dust Extinction Vectors} \\index{dust extinction}\n\\label{cha:dustvectors}\n\nThe SDF98 extinction values are given in the SDSS dataset. To calculate the other\ntwo extinction vectors, we start with a reference reddening quantity\n\\begin{IEEEeqnarray*}{lCl}\n\tE_{B-V} &=& \\frac{\\A_r}{2.751}\n\\end{IEEEeqnarray*}\nwhere $\\A_r$ is the SDF98 extinction value in the r-band.\n\nAs a check, we can actually recover the SDF98 extinction vector as follows:\n\\begin{IEEEeqnarray*}{lCl}\n\t\\A_u &=& 5.155 \\cdot E_{B-V} \\\\\n\t\\A_g &=& 3.793 \\cdot E_{B-V} \\\\\n\t\\A_r &=& 2.751 \\cdot E_{B-V} \\\\\n\t\\A_i &=& 2.086 \\cdot E_{B-V} \\\\\n\t\\A_z &=& 1.479 \\cdot E_{B-V}\n\\end{IEEEeqnarray*}\nLater, \\citeN{schlafly11} applied a different extinction curve, giving us the following\ncorrection values:\n\\begin{IEEEeqnarray*}{lCl}\n\t\\A_u &=& 4.239 \\cdot E_{B-V} \\\\\n\t\\A_g &=& 3.303 \\cdot E_{B-V} \\\\\n\t\\A_r &=& 2.285 \\cdot E_{B-V} \\\\\n\t\\A_i &=& 1.698 \\cdot E_{B-V} \\\\\n\t\\A_z &=& 1.263 \\cdot E_{B-V}\n\\end{IEEEeqnarray*}\nRecently, \\citeN{wolf14} remapped the $E_{B-V}$ scale to\n\\begin{IEEEeqnarray*}{lCl}\n\tE'_{B-V} &=&\n\t\\begin{cases}\n\t\tE_{B-V} & \\text{if } E_{B-V} \\in [0, 0.04], \\\\\n\t\tE_{B-V} + 0.5(E_{B-V} - 0.04) & \\text{if } E_{B-V} \\in [0, 0.08], \\\\\n\t\tE_{B-V} + 0.02 & \\text{if } E_{B-V} \\in [0.08, +\\infty].\n\t\\end{cases}\n\\end{IEEEeqnarray*}\nwhich can then be used to calculate a new set of correction values:\n\\begin{IEEEeqnarray*}{lCl}\n\t\\A_u &=& 4.305 \\cdot E'_{B-V} \\\\\n\t\\A_g &=& 3.288 \\cdot E'_{B-V} \\\\\n\t\\A_r &=& 2.261 \\cdot E'_{B-V} \\\\\n\t\\A_i &=& 1.714 \\cdot E'_{B-V} \\\\\n\t\\A_z &=& 1.263 \\cdot E'_{B-V}\n\\end{IEEEeqnarray*}\nEach of these correction values need to be subtracted from the corresponding magnitudes\nto make up for the loss of the scattered light.\n\n\n\n\n\n\\chapter{Supplementary Results}\n\\label{cha:supp}\n\nIn this Appendix, we present results that are not vital to the main narrative but still somewhat\ninteresting.\n\n%\\section{Reliability of Probabilities Estimates}\n%\\label{sec:forest_prob}\n%\n%Figure \\ref{fig:forest_multinom} shows the learning curves\n%\n%We found that the probabilities estimated by both random forests and multinomial regression\n%to be unreliable. [To do: include learning curves of random forest, one-vs-rest, and\n%multinomial regression, and warm-start here, test both SDSS and VST ATLAS]\n%\n%\\begin{figure}[p]\n%\t\\centering\n%\t\\begin{subfigure}{\\textwidth}\n%\t\t\\centering\n%\t\t\\includegraphics[width=\\textwidth]{figures/appendix/sdss_forest_multinom}\n%\t\t\\caption{SDSS dataset}\n%\t\t\\label{fig:sdss_forest_multinom}\n%\t\\end{subfigure}\\\\\n%\t\\begin{subfigure}{\\textwidth}\n%\t\t\\centering\n%\t\t\\includegraphics[width=\\linewidth]{figures/appendix/vstatlas_forest_multinom}\n%\t\t\\caption{VST ATLAS dataset}\n%\t\t\\label{fig:vstatlas_forest_multinom}\n%\t\\end{subfigure}\n%\t\\caption[Reliability of probability estimates]{Learning curves of various classifiers: }\n%\t\\label{fig:forest_multinom}\n%\\end{figure}\n\n\n\\section{Effects of Dust Extinction on Recall}\n\nIn Chapter \\ref{cha:expt1} we tested the effects of three different extinction vectors \non the accuracy rate. Figure \\ref{fig:map_recall_uncorrected} shows how the recall rate is distributed\nover the celestial sphere. Overall, the recall on galaxies is almost perfect, while\nthe recall on stars is fairly average. On the three pages after that, Figures \\ref{fig:map_recall_sfd98}, \\ref{fig:map_recall_sf11}, and \\ref{fig:map_recall_w14} show\nthe improvement on recall after each extinction vector is applied. The interesting bit\nis that there is a patch of stars right next to the Milky Way plane that gets a big improvement\nin recall after reddening correction. Thus the extinction vector would be very important\nif there were more objects that are closer to the Milky Way plane (which is the case in the SkyMapper project).\n\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\textwidth]{figures/appendix/map_recall_uncorrected_Galaxy}\n\t\t\\caption{Recall map of galaxies.}\n\t\t\\label{fig:map_recall_uncorrected_galaxies}\n\t\\end{subfigure}\\\\\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_uncorrected_Star}\n\t\t\\caption{Recall map of stars.}\n\t\t\\label{fig:map_recall_uncorrected_stars}\n\t\\end{subfigure}\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_uncorrected_Quasar}\n\t\t\\caption{Recall map of quasars.}\n\t\t\\label{fig:map_recall_uncorrected_quasars}\n\t\\end{subfigure}\n\t\\caption[Recall maps when there is no corrections]{\n        Recall maps when there is no corrections.}\n\t\\label{fig:map_recall_uncorrected}\n\\end{figure}\n\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\textwidth]{figures/appendix/map_recall_sfd98_Galaxy}\n\t\t\\caption{Recall improvement map of galaxies.}\n\t\t\\label{fig:map_recall_sfd98_galaxies}\n\t\\end{subfigure}\\\\\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_sfd98_Star}\n\t\t\\caption{Recall improvement map of stars.}\n\t\t\\label{fig:map_recall_sfd98_stars}\n\t\\end{subfigure}\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_sfd98_Quasar}\n\t\t\\caption{Recall improvement map of quasars.}\n\t\t\\label{fig:map_recall_sfd98_quasars}\n\t\\end{subfigure}\n\t\\caption[Recall improvement maps with SFD98]{\n        Recall improvement maps when the SFD98 extinction vector is used.}\n\t\\label{fig:map_recall_sfd98}\n\\end{figure}\n\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\textwidth]{figures/appendix/map_recall_sf11_Galaxy}\n\t\t\\caption{Recall improvement map of galaxies.}\n\t\t\\label{fig:map_recall_sf11_galaxies}\n\t\\end{subfigure}\\\\\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_sf11_Star}\n\t\t\\caption{Recall improvement map of stars.}\n\t\t\\label{fig:map_recall_sf11_stars}\n\t\\end{subfigure}\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_sf11_Quasar}\n\t\t\\caption{Recall improvement map of quasars.}\n\t\t\\label{fig:map_recall_sf11_quasars}\n\t\\end{subfigure}\n\t\\caption[Recall improvement maps of when with SF11]{\n        Recall improvement maps of when the SF11 extinction vector is used.}\n\t\\label{fig:map_recall_sf11}\n\\end{figure}\n\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\textwidth]{figures/appendix/map_recall_w14_Galaxy}\n\t\t\\caption{Recall improvement map of galaxies.}\n\t\t\\label{fig:map_recall_w14_galaxies}\n\t\\end{subfigure}\\\\\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_w14_Star}\n\t\t\\caption{Recall improvement map of stars.}\n\t\t\\label{fig:map_recall_w14_stars}\n\t\\end{subfigure}\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.75\\linewidth]{figures/appendix/map_recall_w14_Quasar}\n\t\t\\caption{Recall improvement map of quasars.}\n\t\t\\label{fig:map_recall_w14_quasars}\n\t\\end{subfigure}\n\t\\caption[Recall improvement maps with W14]{\n        Recall improvement maps of when the W14 extinction vector is used.}\n\t\\label{fig:map_recall_w14}\n\\end{figure}\n\n\n\n\\section{Variance of the Mean Reward in Thompson Sampling}\n\nFinally, Figures \\ref{fig:sdss_sigmas} and \\ref{fig:vstatlas_sigmas} show how $\\sigma^2$,\nthe variance of the expected reward, changes with the training set size. As we would expect,\nthe variance decreases exponentially over time, since as we increase\nthe training size, we become more certain of the classifier's accuracy. In addition, the incremental change\nof the accuracy rate shrinks over time as we approach an accuracy of 100\\%.\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{figures/5_thompson/vstatlas_bl_sigmas}\n\t\t\\caption{Balanced pool and logistic regression}\n\t\t\\label{fig:sdss_bl_sigmas}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{figures/5_thompson/sdss_br_sigmas}\n\t\t\\caption{Balanced pool and RBF SVM}\n\t\t\\label{fig:sdss_br_sigmas}\n\t\\end{subfigure}\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{figures/5_thompson/sdss_ul_sigmas}\n\t\t\\caption{Unbalanced pool and logistic regression}\n\t\t\\label{fig:sdss_ul_sigmas}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{figures/5_thompson/sdss_ur_sigmas}\n\t\t\\caption{Unbalanced pool and RBF SVM}\n\t\t\\label{fig:sdss_ur_sigmas}\n\t\\end{subfigure}\n\t\\caption[Variance of the mean reward of heuristics (SDSS)]{\n\t\tVariance (average of 10 trials) of the expected reward in Thompson sampling with the SDSS dataset.}\n\t\\label{fig:sdss_sigmas}\n\\end{figure}\n\n\\begin{figure}[p]\n\t\\centering\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{figures/5_thompson/vstatlas_bl_sigmas}\n\t\t\\caption{Balanced pool and logistic regression}\n\t\t\\label{fig:vstatlas_bl_sigmas}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{figures/5_thompson/vstatlas_br_sigmas}\n\t\t\\caption{Balanced pool and RBF SVM}\n\t\t\\label{fig:vstatlas_br_sigmas}\n\t\\end{subfigure}\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{figures/5_thompson/vstatlas_ul_sigmas}\n\t\t\\caption{Unbalanced pool and logistic regression}\n\t\t\\label{fig:vstatlas_ul_sigmas}\n\t\\end{subfigure}%\n\t\\begin{subfigure}{.5\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{figures/5_thompson/vstatlas_ur_sigmas}\n\t\t\\caption{Unbalanced pool and RBF SVM}\n\t\t\\label{fig:vstatlas_ur_sigmas}\n\t\\end{subfigure}\n\t\\caption[Variance of the mean reward of heuristics (VST ATLAS)]{\n\t\tVariance (average of 10 trials) of the expected reward in Thompson sampling with the VST ATLAS dataset.}\n\t\\label{fig:vstatlas_sigmas}\n\\end{figure}\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"thesis\"\n%%% End: \n", "meta": {"hexsha": "6ce4761df22be7dda71103e5b5171171570cdc94", "size": 13255, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/alasdair/thesis/7_appendix.tex", "max_stars_repo_name": "chengsoonong/mclass-sky", "max_stars_repo_head_hexsha": "98219221c233fa490e78246eda1ead05c6cf7c17", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-06-01T12:09:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-16T05:28:01.000Z", "max_issues_repo_path": "projects/alasdair/thesis/7_appendix.tex", "max_issues_repo_name": "alasdairtran/mclearn", "max_issues_repo_head_hexsha": "98219221c233fa490e78246eda1ead05c6cf7c17", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 165, "max_issues_repo_issues_event_min_datetime": "2015-01-28T10:37:34.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-23T06:55:13.000Z", "max_forks_repo_path": "projects/alasdair/thesis/7_appendix.tex", "max_forks_repo_name": "alasdairtran/mclearn", "max_forks_repo_head_hexsha": "98219221c233fa490e78246eda1ead05c6cf7c17", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-01-24T16:27:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-01T08:54:31.000Z", "avg_line_length": 32.6477832512, "max_line_length": 166, "alphanum_fraction": 0.7513391173, "num_tokens": 4366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4190586733975261}}
{"text": "% !TEX root = ./physics_of_fluids.tex\n% !TEX TS-program = xelatex\n% !TEX encoding = UTF-8 Unicode\n\\chapter{Viscous flows}\n\\label{chap:viscous_flows}\nWhenever the viscous diffusion timescale $\\rho L^2/\\mu$ is short with respect to inertial $L/U$ or imposed $\\omega^{-1}$ timescales, flows will be dominated by viscosity. This situation occurs of course if the viscosity of the material is high, e.g. with mud, magma or glass melt (figure~\\ref{fig:viscous_flows}) but not only. Glaciers were reported to flow as early as 1873 \\citep{Aitken1873}. These so-called \\textit{rivers of ice} indeed flow, albeit very slowly -- typically less than a metre a day -- making inertial phenomena irrelevant (figure~\\ref{fig:viscous_flows}; see also the slow motion footage taken by BBC Earth Lab \\url{https://youtu.be/ghC-Ut0fW4o}). At very small scales where bacteria and algae evolve, diffusion competes and usually overcomes inertial effects. As a result, microorganisms living at such scales have evolved non-intuitive strategies to move as we will see next.\n\nIn all these examples the ratio between the diffusive and inertial timescales -- the Reynolds number Re = $\\rho U L/\\mu$ -- is much smaller than one. Fluid motion can still be described with the Navier-Stokes equations in this context, but we will now see that the condition Re $\\ll$ 1 implies that some terms have not the same order of magnitude than others. Exploiting the low-Re number hypothesis will enable us to obtain the relevant equation for viscous flow motion, the \\textbf{Stokes equation}.\n\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[height=4cm]{Briksdalsbreen.jpg}\n\\includegraphics[height=4cm]{fiberglass.jpg}\n\\includegraphics[height=4cm]{sorin.png}\n\\includegraphics[width=15cm]{salmonella.png}\n\\caption{\\textbf{Flows dominated by viscosity.} Top left : the Briksdalsbreen glacier in Norway is slowly flowing into a lake (photograph by vicrogo, public domain). Top middle: glass fibre manufacturing (photograph Saint-Gobain). Top right: modern optical fibre drawing process allow to produce multilayered fibres \\citep{Abouraddy2007}. Bottom: micron-sized salmonellae swim with the help of a bundle of rotating helicoidal flagellae \\citep{Elgeti2015}.}\n\\label{fig:viscous_flows}\n\\end{center}\n\\end{figure}\n\n\\section{Low-Re number flows}\nWhenever fluids have a high viscosity $\\mu$, or flow at small scale $L$ or with a low velocity $U$, the equations describing their motion can be greatly simplified. This can be seen by non dimensionalising the equations of motions with the natural scales of the problem $\\bU=U\\bu$, $\\bX=L\\bx$ (here we denote dimensioned quantities with capital letters). The pressure can be made dimensionless with a natural viscous scale $P=\\mu\\frac{U}{L}p$ and finally if there is a imposed timescale $\\omega^{-1}$ (e.g. the inverse of the swimming frequency) we may write $T=\\omega^{-1}t$.\n\\begin{equation}\n\\mathrm{Re}_\\omega\\pd{\\bu}{t} + \\mathrm{Re}\\lp\\bu\\cdot\\nabla\\rp\\bu=-\\nabla p+\\Delta \\bu.\n\\label{eq:pre-stokes_equation}\n\\end{equation}\nHere, two Reynolds numbers appear:\n\\begin{equation}\n\\mathrm{Re}_\\omega=\\frac{\\rho L^2 \\omega}{\\mu} \\quad \\text{and} \\quad \\mathrm{Re}=\\frac{\\rho U L}{\\mu},\n\\end{equation}\nwhich each may be interpreted as a ratio of timescales as seen in the introduction of this chapter. Note that for e.g. flagellae propelled microorganisms, the oscillatory Reynolds number $\\mathrm{Re}_\\omega$ involves the relevant velocity scale $L\\omega$ for the fluid set into motion by the oscillating flagella.\n\nIn equation~\\eqref{eq:pre-stokes_equation} each variable has been rescaled with its expected range of variation range. Therefore each of the force terms (right hand side) is $\\mathcal O(1)$ while the unsteady and convective part of momentum variation (left hand side) are respectively of order $\\mathrm{Re}_\\omega$ and $\\mathrm{Re}$. For flows without an imposed frequency (flowing glass melts or glacier flow), these two numbers will be identical. But if the flow is produced by an oscillating object, they can significantly differ. Table~\\ref{tbl:Reynolds} reports an estimation of these two Reynolds numbers for a range of organisms living in aqueous environments, where it can be seen that the double condition $\\mathrm{Re}_\\omega\\ll 1$, $\\mathrm{Re}\\ll 1$ is fulfilled in the realm of microorganisms.\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{ccccccc}\nOrganism & length & velocity & frequency & Re & Re$_\\omega$\\\\\n\\hline\\hline\n\\textbf{Bacterium} & 10 $\\mu$m & 10 $\\mu$m/s & 100 Hz & \\textbf{10$^\\text{-4}$} & \\textbf{10$^\\text{-2}$}\\\\\n\\textbf{Spermatozoon} & 100 $\\mu$m & 100 $\\mu$m/s & 10 Hz & \\textbf{10$^\\text{-2}$} & \\textbf{10$^\\text{-1}$}\\\\\n\\textbf{Ciliate} & 100 $\\mu$m & 1 mm/s & 10 Hz & \\textbf{10$^\\text{-1}$} & \\textbf{10$^\\text{-1}$}\\\\\nTadpole & 1 cm & 10 cm/s & 10 Hz & 10$^\\text{3}$ & 10$^\\text{3}$\\\\\nSmall fish & 10 cm & 10 cm/s & 10 Hz & 10$^\\text{4}$ & 10$^\\text{5}$\\\\\nPenguin & 1 m & 1 m/s & 1 Hz & 10$^\\text{6}$ & 10$^\\text{6}$\\\\\nSperm whale & 10 m & 1 m/s & 0.1 Hz & 10$^\\text{7}$ & 10$^\\text{7}$\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{\\textbf{Reynolds number for different living organisms.} Bacteria, spermatozoa and ciliates are all characterised by Reynolds numbers Re and Re$_\\omega$ much smaller than unity. The flowing fluid in their vicinity is therefore accurately described with the Stokes equation. Data from \\citet{Lauga2020}.}\n\\label{tbl:Reynolds}\n\\end{table}\n\nIn this limit, the Navier-Stokes equation reduces to the much simpler \\textbf{Stokes equation}\\index{Stokes equation}:\n\\begin{equation}\n\\nabla p=\\Delta \\bu\\quad\\text{or, in its dimensioned version:}\\quad\\nabla P=\\mu\\Delta \\bU.\n\\label{eq:stokes_equation}\n\\end{equation}\n\n\\prg{Cauchy equation.} The Stokes equation may also be rewritten as the following \\textit{Cauchy equation}:\n\\begin{equation}\n\\nabla\\cdot\\tensorsym\\sigma=\\matrixsym 0.\n\\end{equation} \nWith this formulation it becomes apparent that viscous flows are \\textit{force free}: in absence of significant inertia, the forces balance each other.\n\n\\section{Stokes flow's properties}\n\\prg{Linearity.} The Stokes equation~\\eqref{eq:stokes_equation} is \\textbf{linear}: this means that elementary solutions can be used to construct more involved ones, either as a weighted sum of individual singular solutions or as a convolution integral between an appropriate Green's function and data boundaries. For example, the knowledge of the velocity $\\bU$ at the boundary $S$ of a fluid domain allows to express the fluid velocity $\\bu$ at any point $\\br$ of the domain as:\n\\begin{equation}\nu_i(\\br)=\\int_S \\mathcal G_{ij}(\\br|\\br_0)U_j(\\br_0)\\,\\mathrm dS(\\br_0).\n\\label{eq:stokes_green_velocity_boundary}\n\\end{equation}\nSimilarly a knowledge of the \\textit{forces}\\footnote{\\textit{Mixed boundary conditions}, constituted of velocity data on part of the boundaries, and forces data on other, can be treated with the same procedure.} $\\bF$ at the domain boundary would lead to the following formal form for the solution:\n\\begin{equation}\nu_i(\\br)=\\int_S g_{ij}(\\br|\\br_0)F_j(\\br_0)\\,\\mathrm dS(\\br_0). \n\\end{equation}\nA practical consequence of these relations is the \\textbf{unicity} of the Stokes flow solution: the boundary conditions uniquely determine the solution. This contrasts with the multitude of solutions that can be encountered for higher Reynolds number and originate (mathematically) from the nonlinear term of the Navier-Stokes equation.\n\\prg{Reversibility.\\index{Stokes reversibility}} Another quite surprising property of Stokes flow is their \\textbf{reversibility}. \n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[width=4cm]{taylor_reversibility_1.png}\n\\includegraphics[width=4cm]{taylor_reversibility_2.png}\n\\includegraphics[width=4cm]{taylor_reversibility_3.png}\n\\caption{\\textbf{Stokes flow kinematic reversibility.} Left: a drop of dye is injected in a quiescent viscous liquid filling the space between two concentric cylinders. Middle: on rotating the inner cylinder with a handle, the dye is stretched and stirred so that it becomes barely visible. Right: reversing the cylinder motion allows to relocate the dye's drop at its initial position almost perfectly (from G.I. Taylor's \\textit{Low-Reynolds-Numbers Flows} movie \\copyright\\ National Committee for Fluid Mechanics Films / Education Development Center).}\n\\label{fig:reversibility}\n\\end{center}\n\\end{figure}\nThis counter-intuitive phenomenon is illustrated on figure~\\ref{fig:reversibility}. A drop of dye mixed by differential rotation in a Taylor-Couette apparatus can be ``unmixed'' by reversing the boundary velocity. From a mathematical point of view, this reversal property can be understood by noting that changing the sign of the boundary velocity in \\eqref{eq:stokes_green_velocity_boundary} simply changes the sign of the solution. Alternatively it can also be noted that the transformation $(\\bu,p)\\to(-\\bu,-p)$ also yields a solution of the Stokes equation~\\eqref{eq:stokes_equation} (provided that the boundary conditions are transformed as well).\n\n\\prg{A paradox?} From a physical point of view, this reversibility is more troublesome: if diffusion is associated with irreversible microscopic phenomena, how can diffusion-dominated flows be reversible? Actually the reversal illustrated figure~\\ref{fig:reversibility} is purely \\textit{kinematic}: while the velocity fields have been reversed and the drop of dye retrieved its overall initial position, molecular diffusion has acted on the microscopic scale as evidenced by the slightly smeared aspect of the final drop, heat has been produced by viscous dissipation and the entropy of the final state is indeed higher than that of the starting state. \n\\section{Moving in a viscous world}\nA paradigm for motion in viscous fluids is the settlement of a sphere, first investigated by Stokes. Arguably lengthy calculations (see tutorial) allow to obtain the expression for the velocity and pressure field around a sphere of radius $R$ settling steadily at velocity $-\\bV^\\infty$ in a quiescent viscous fluid in its reference frame:\n\\begin{subequations}\n\\label{eq:stokes_sphere}\n\\begin{empheq}[left=\\empheqlbrace]{alignat=2}\nu_i &\\,=\\,&& -\\frac{3R}{4}V^\\infty_j\\lp\\frac{\\delta_{ij}}{r}+\\frac{r_ir_j}{r^3}\\rp -\\frac{3R^3}{4}V^\\infty_j\\lp\\frac{\\delta_{ij}}{3r^3}-\\frac{r_ir_j}{r^5}\\rp,\\\\\np-p_\\infty&\\,=\\,&&-\\frac{3\\mu R}{2}\\frac{V^\\infty_jr_j}{r^3}.\n\\end{empheq}\n\\end{subequations}\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics{guazzelli_fixed_sphere.pdf}\n\\includegraphics{guazzelli_moving_sphere.pdf}\n\\caption{\\textbf{Spheres in viscous flows}. Left: A fixed sphere deflects the surrounding flowing fluid. Right: A moving sphere in a still environment pushes the fluid in its vicinity \\citep{Guazzelli2011}.}\n\\label{fig:viscous_spheres}\n\\end{center}\n\\end{figure}\nThese expressions allow to evaluate the stresses at the sphere surface and to deduce the well-known \\textbf{Stokes drag}\\index{Stokes drag}  $\\bF = 6 \\pi \\mu R \\bV^\\infty$ exerted on the sphere.\n\nAn alternative and very useful viewpoint is to present these results in terms of the force $\\mathbf f=-\\bF$ exerted by the sphere on the fluid:\n\\begin{equation}\nu_i \\,=\\, \\underbrace{\\frac{1}{8 \\pi\\mu R}f_j\\lp\\frac{\\delta_{ij}}{r}+\\frac{r_ir_j}{r^3}\\rp}_\\text{Stokeslet contribution} +\\frac{R^2}{8\\pi\\mu R}f_j\\lp\\frac{\\delta_{ij}}{3r^3}-\\frac{r_ir_j}{r^5}\\rp.\n\\label{eq:stokes_force_sphere}\n\\end{equation}\nInterestingly if we were to shrink the size of the sphere to 0 while keeping the force constant, the only remaining term in the flow field would be the first one. This so-called Stokeslet contribution is of fundamental importance in suspension dynamics, bacteria hydrodynamics and more generally in the modelling of viscous flows.\n\\subsection{Point force induced flow: the Stokeslet\\index{Stokeslet}}\nThe Stokeslet is a fundamental solution for the Stokes equation, and describes the flow that would be induced by a point force $\\mathbf f\\, \\delta(\\bx-\\bx_0)$ located at $\\bx = \\bx_0$. The corresponding velocity and pressure fields therefore satisfy the following \\textit{forced Stokes equation}:\n\\begin{equation}\n-\\nabla p + \\mu \\Delta \\bu + \\mathbf f \\,\\delta(\\bx-\\bx_0) = \\matrixsym 0.\n\\label{eq:forced_stokes_equation}\n\\end{equation}\nNote that in this expression $\\mathbf f$ is a constant vector. \n\nThe flow field solution is termed \\textbf{Stokeslet} and is characterized by: \n\\begin{equation}\n\\left.\\bu_{\\text{stokeslet}}\\right|_i(\\bx)=\\frac{1}{8\\mathrm\\pi\\mu}\\mathcal S_{ij}(\\bx |\\bx_0) f_j,\n\\label{eq:stokeslet_velocity_component}\n\\end{equation}\nwith $\\mathcal S_{ij}$ being the \\textit{Oseen-Burgers tensor} defined as:\n\\begin{equation}\n\\mathcal S_{ij}=\\frac{\\delta_{ij}}{r}+\\frac{r_i r_j}{r^3}.\n\\end{equation}\nLet's now see in more details how this solution is constructed. To so so it will prove useful to first introduce the Green's function for Laplace equation $g(\\bx |\\by)$.\n\\prg{Green's function\\index{Green's function} for Laplace equation.} The Green's function $g(x|y)$ for Laplace equation is the function satisfying:\n\\begin{equation}\n\\Delta g(\\bx |\\by) = \\delta\\lp\\bx-\\by\\rp.\n\\end{equation}\nIt is an harmonic function of space except at the point $\\bx=\\by$ where it is singular. Symmetry considerations on this function suggest that it only depends on the radius $r = \\left\\|\\bx-\\by\\right\\|$. On integrating over a small ball containing the singularity we get:\n$$\n\\oiint \\pd{g}{r} \\mathrm dS = 1,\n$$\nso that the Green's function for Laplace equation is:\n\\begin{equation}\ng(\\bx |\\by) = -\\frac{1}{4\\mathrm{\\pi}r}.\n\\end{equation}\n\\prg{Stokeslet obtention.} With the help of the Green's function for Laplace equation, the divergence of the forced Stokes equation~\\eqref{eq:forced_stokes_equation} may be written as\n\\begin{equation}\n\\Delta\\lp p-\\mathbf f\\cdot\\nabla\\lp-\\frac{1}{4\\pi r}\\rp\\rp = 0.\n\\end{equation}\nThe maximum principle for harmonic functions allows us to directly write the pressure as:\n\\begin{equation}\np=\\mathbf f\\cdot\\nabla\\lp-\\frac{1}{4\\pi r}\\rp.\n\\end{equation}\nInjecting this form for the pressure in equation~\\eqref{eq:forced_stokes_equation} we obtain:\n\\begin{equation}\n\\mu \\Delta u_i=\\frac{1}{4\\mathrm\\pi}\\lp\\underbrace{\\delta_{ij}\\pd{}{x_k}\\pd{}{x_k}}_{\\tensorsym I \\Delta}\\lp\\frac{1}{r}\\rp-\\underbrace{\\pd{}{x_i}\\pd{}{x_j}}_{\\nabla\\nabla}\\lp\\frac{1}{r}\\rp\\rp f_j.\n\\label{eq:stokeslet_velocity_laplacian}\n\\end{equation}\nFrom the structure of this relationship, the adventurous reader might tempt to look for a solution of the form:\n\\begin{equation}\n u_i=\\frac{1}{4\\mathrm\\pi}\\lp\\delta_{ij}\\Delta \\mathcal H-\\pd{^2\\mathcal H}{x_ix_j}\\rp f_j.\n\\label{eq:stokeslet_velocity_form}\n\\end{equation}\nNote that this velocity field is solenoidal, as:\n\\begin{equation}\n u_{i,i}=\\frac{1}{4\\mathrm\\pi}\\lp\\Delta \\mathcal H_{,j}-\\Delta \\mathcal H_{,j}\\rp f_j \\equiv 0.\n\\end{equation}\nInjecting~\\eqref{eq:stokeslet_velocity_form} into~\\eqref{eq:stokeslet_velocity_laplacian} we get:\n\\begin{equation}\n\\frac{1}{4\\mathrm\\pi}\\lp\\tensorsym I\\delta-\\nabla\\nabla\\rp\\lp\\mu\\Delta\\mathcal H-\\lp\\frac{1}{r}\\rp\\rp=0.\n\\end{equation}\nThis reduces to the following Poisson equation for $\\mathcal H$\\footnote{Note that we did not consider the integration constants because they would not appear in the velocity field expression anyway.}:\n\\begin{equation}\n\\mu\\Delta\\mathcal H=\\frac{1}{r} \\quad\\text{with solution:}\\quad\\mathcal H=\\tfrac{1}{2\\mu}r.\n\\end{equation}\nNoting that $r=\\lp r_kr_k\\rp^{1/2}$, we deduce:\n\\begin{equation}\nr_{,i}=\\frac{r_{k,i}r_k}{(r_mr_m)^{1/2}}\\equiv\\frac{x_i}{r} \\quad \\text{and similarly} \\quad r_{,ij}=\\frac{\\delta_{ij}}{r}-\\frac{r_ir_j}{r^3},\n\\end{equation}\nto finally obtain the expression of the Stokeslet velocity field~\\eqref{eq:stokeslet_velocity_component} we were looking for:\n\\begin{equation}\n\\bu_\\text{stokeslet}=\\frac{1}{8\\pi\\mu}\\tensorsym S \\mathbf f.\n\\end{equation}\n\\subsection{The motion of slender objects}\nWe have seen that in the limit of radius shrinking down to zero, a sphere applying a force to a viscous fluid generates a Stokeslet flow. But looking back at the full expression for the flow set into motion by a sphere of finite size~\\eqref{eq:stokes_force_sphere}, it is apparent that the total contribution is actually composed of two parts: a Stokeslet and higher-order singularity -- a dipole. Without entering into the details of the derivation, \\citet{Hancock1953} and \\citet{Lighthill1975} proposed to describe the fluid flows around more general, and slender, objects, as integrals of Stokeslets and dipole contribution. More precisely it appears that the force exerted by a viscous fluid on a very long cylinder of radius $R$ and length $L$ depends on the orientation of the flow. If the flow is perpendicular to the filament axis, the force exerted on the cylinder per unit length is:\n\\begin{subequations}\n\\begin{equation}\nf_\\perp \\simeq c_\\perp u_\\perp \\quad \\text{with}\\quad c_\\perp=\\frac{4\\pi\\mu}{\\ln(L/R)}.\n\\end{equation}\nAnd similarly, if the flow is now parallel to the fibre:\n\\begin{equation}\nf_\\parallel \\simeq c_\\parallel u_\\parallel \\quad \\text{with}\\quad c_\\parallel=\\frac{2\\pi\\mu}{\\ln(L/R)}.\n\\end{equation}\n\\end{subequations}\nNote that there is a factor 2 between $f_\\perp$ and $f_\\parallel$. This drag anisotropy has consequences on the settling of slender objects that we shall not detail here, but the interested reader will find detailed and useful accounts in \\citet{Duprat2016} or \\citet{Lauga2020} for example. \n%\\section{Bacterial hydrodynamics}\n%\n%Waving sheet Taylor\n%\n%Scallop theorem\n%\n%Bacteria with flagellae\n%\n%\\section{Flows at the nanoscale}\n%Slip length\n", "meta": {"hexsha": "9dd316daa737379b0c7e7b091837900edd17cce1", "size": 17550, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture/03_viscous_flows.tex", "max_stars_repo_name": "antko/physics-of-fluids", "max_stars_repo_head_hexsha": "307f1c25c59345943a4bce90e031ced5dde105bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lecture/03_viscous_flows.tex", "max_issues_repo_name": "antko/physics-of-fluids", "max_issues_repo_head_hexsha": "307f1c25c59345943a4bce90e031ced5dde105bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lecture/03_viscous_flows.tex", "max_forks_repo_name": "antko/physics-of-fluids", "max_forks_repo_head_hexsha": "307f1c25c59345943a4bce90e031ced5dde105bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.0294117647, "max_line_length": 898, "alphanum_fraction": 0.7635897436, "num_tokens": 5110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044135, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.41905866921886487}}
{"text": "\\documentclass{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath,amsfonts}\n\\usepackage{url}\n\\usepackage{mathpartir}\n\n\\title{Interface for ROSlab and REACT}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\newcommand{\\tr}[1]{\\stackrel{#1}{\\longrightarrow}}\n\nFor the segway robot: so we give a 2 dimensional model.\n%assume the center of the robot's frame is the geometric center of the robot.\\\\\nThis model is obviously (too simple) and idealized but it gives us a starting point.\n\nREACT will provide a global controller that sends commands to the robots.\nThe robots store the commands in a local FIFO buffer until they executed.\nThe commands tells the robot how to move.\nIn this version, the controller tells the robot at which speed to move and rotate.\nFurthermore, we assume the robots have a clock (assumed perfect), the message receptions (and similar computations) take no time.\n\nIf everybody agrees with the semantics, we can proceed to specify a set of ROS messages for the integration of the REACT controller in a system of robots programmed with ROSlab.\nWe can also discuss other types of commands, e.g., trajectory/path to follow, gripping.\n\n\\paragraph{Robot description.}~\\\\\n\nA robot is described by the tuple $(id, \\vec p, \\theta, \\mathit{cmds})$ where\n\\begin{itemize}\n\\item $id$ is a unique identifier.\n\\item $\\vec p$ is the position. In the 2D case, $\\vec p = \\begin{pmatrix} x \\\\ y \\end{pmatrix}$.\n\\item $\\theta$ is the angle between the robot frame and the global frame. In the 2D case, it is a single angle.\n\\item $\\mathit{cmds}$ is a queue of commands. We use $c::C$ to match command $c$ at the head of the queue $C$ and $C::c$ for the tail. $[]$ is the empty queue.\n\\end{itemize}\n\nEach command has the form ``$\\text{move}(v, \\omega, t)$'' where\n$v$ is the speed (along the $x$ axis of the robot frame),\n$\\omega$ is an angular speed (rotation center is $(0,0)^T$ in the robot frame),\n$t$ is the time for witch this command should be executed.\n\n\\paragraph{Semantic for a single robot.}~\\\\\n\nA transition from state $R$ to $R'$ taking time $t$ and with action $a$ is written as $R \\tr{a,t} R'$.\nThe action $a$ is used to synchronize messages.\n$\\tau$ is the silent action.\n$id?c$ means robot with identifier $id$ receive a message.\n$id!c$ means a message is sent to robot with identifier $id$.\n\n\\[\n\\inferrule[idle]\n          { R = (id, \\vec p, \\theta, []) \\\\ dt \\geq 0}\n          { R \\tr{\\tau,dt} R }\n\\]\n\n\\[\n\\inferrule[recv]\n          { R = (id, \\vec p, \\theta, C) \\\\\n            R' = (id, \\vec p, \\theta, C :: c) }\n          { R \\tr{id?c,0} R' }\n\\]\n\n\\[\n\\inferrule[cmd done]\n          { R = (id, \\vec p, \\theta, \\text{move}(v, \\omega, 0) :: C) \\\\\n            R' = (id, \\vec p, \\theta, C) }\n          { R \\tr{\\tau,0} R' }\n\\]\n\n\\[\n\\inferrule[exec]\n    { R = (id, \\vec p, \\theta, \\text{move}(v, \\omega, t) :: C) \\\\\n      R' = (id, \\vec p', \\theta', \\text{move}(v, \\omega, t - dt) :: C ) \\\\\\\\\n      t \\geq dt \\geq 0 \\\\\n      \\theta' = \\theta + \\omega \\cdot dt \\\\\n      \\vec p' = \\vec p + \\left({\\begin{tabular}{cc} $\\cos(\\theta)$ & $\\sin(\\theta)$ \\\\ $\\sin(\\theta)$ & $\\cos(\\theta)$ \\end{tabular}}\\right) \\vec q \\\\\\\\\n      \\text{where } \\vec q = \\left\\{ {\\begin{tabular}{lr} $(v \\cdot dt, 0)$ & if $\\omega = 0$ \\\\\n                                     $(v/\\omega \\cdot \\sin(\\omega \\cdot dt), v/\\omega \\cdot (1- \\cos(\\omega \\cdot dt)))$ & otherwise \\end{tabular}} \\right.\\\\\n    }\n    { R \\tr{\\tau,dt} R' }\n\\]\n\n\\paragraph{Multiple robots.}\n\nWe have transitions of the individual robots are labeled with time.\nWhen synchronising the transitions of multiple robots we simply requires that the time on the transition of every robot agree:\n\n\\[\n\\inferrule[time]\n          { \\forall i \\in I. R_i \\tr{\\tau,t} R_i' }\n          { \\prod_{i \\in I} R_i \\tr{\\tau,t} R_i' }\n\\]\n\n\\noindent\n$||$ denotes the parallel composition, $\\prod$ the index parallel composition.\n\nFor messages, we require:\n\\[\n\\inferrule[msg]\n          { R_a \\tr{id!c,0} R_a' \\\\ R_b \\tr{id?c,0} R_b' \\\\\n            \\forall i \\in I \\setminus \\{a,b\\}. R_i \\tr{\\tau,0} R_i' }\n          { R_a || R_b ~|| \\prod_{i \\in I \\setminus \\{a,b\\}} R_i ~~\\tr{\\tau,0}~~ R_a' || R_b' ~|| \\prod_{i \\in I \\setminus \\{a,b\\}} R_i' }\n\\]\n\nIn this formulation the controller is a special robot with the ability to send messages.\n\n\\end{document}\n", "meta": {"hexsha": "c5aad0ec3dce818ba7da4451ae2561ef8da7e0cb", "size": 4293, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/interface/main.tex", "max_stars_repo_name": "aleksandarmilicevic/react-lang", "max_stars_repo_head_hexsha": "18041bbf1f43668b3f600c2d6daa994264915881", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-03-15T10:31:55.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-27T11:09:29.000Z", "max_issues_repo_path": "doc/interface/main.tex", "max_issues_repo_name": "aleksandarmilicevic/react-lang", "max_issues_repo_head_hexsha": "18041bbf1f43668b3f600c2d6daa994264915881", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-07-22T12:51:50.000Z", "max_issues_repo_issues_event_max_datetime": "2016-08-25T14:08:11.000Z", "max_forks_repo_path": "doc/interface/main.tex", "max_forks_repo_name": "aleksandarmilicevic/react-lang", "max_forks_repo_head_hexsha": "18041bbf1f43668b3f600c2d6daa994264915881", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6756756757, "max_line_length": 177, "alphanum_fraction": 0.631959003, "num_tokens": 1345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.41901221247769027}}
{"text": "%\n% CMPT 354: Database Systems I - A Course Overview\n% Section: Design\n%\n% Author: Jeffrey Leung\n%\n\n\\section{Design}\n\t\\label{sec:design}\n\\subsection{Structure}\n\t\\label{subsec:design:structure}\n\\begin{easylist}\n\t\n\t& Conceptual database design:\n\t\t&& Identify the entities and relationships (see subsection~\\ref{sec:entity-relationship-model})\n\t\t&& Identify the entity and relationship information\n\t\t&& Identify the integrity constraints\n\t\t&& Discuss the conceptual model with the client\n\t\t\n\t& Logical database design:\n\t\t&& Decide on a data model to use\n\t\t&& Choose a DBMS to use\n\t\t&& Create a database schema using the conceptual schema\n\t\t\t&&& Avoid redundant information or inability to record information\n\n\\end{easylist}\n\\subsection{Identification of Tables}\n\t\\label{subsec:design:identification-of-tables}\n\\begin{easylist}\n\n\t& \\emph{Key/Superkey:} Set of attributes with values which uniquely identify an entity in an entity set\n\t\t&& Mathematical definition: A subset $K$ of a relation $R$ is a superkey of $R$ if, for all pairs of tuples $t_1$ and $t_2$, $t_1 \\neq t_2$, then $t_1[K] \\neq t_2[K]$\n\t\t\t&&& I.e. $K$, a set of attributes of relation $R$, is a superkey if, for all distinct pairs of tuples, there are no two tuples with the same values for $K$\n\t\t&& \\emph{Candidate key:} Superkey with no extraneous attributes\n\t\t\t&&& E.g. Class number, teacher + term + meeting times\n\t\t\t&&& \\emph{Primary key:} Candidate key chosen to represent a tuple in the relation (rows in the table)\n\t\t\t\t&&&& Should be chosen from an attribute(s) which never changes (e.g. Social Insurance Number)\n\t\t\t\t&&&& Can be arbitrarily generated for easier classification\n\t\t\t\t&&&& In an entity-relationship diagram: Attributes underlined\n\t\t\t\t\n\\end{easylist}\n\\subsection{Constraints}\n\t\\label{subsec:design:constraints}\n\\begin{easylist}\n\t\t\t\t\n\t& \\emph{Integrity constraint:} Rule which restricts the data in a database\n\t\t&& \\emph{Domain constraint:} Integrity constraint on a given data column of the type of data\n\t\t&& \\emph{Key constraint (integrity constraint):} Integrity constraint which identifies primary keys and candidate keys\n\t\t&& \\emph{Foreign key constraint:} Integrity constraint which references a primary key from another tables\n\t\t\t&&& \\emph{Foreign key:} Attribute(s) which reference a primary key of another entities\n\t\t\t\t&&&& References the entire primary key\n\t\t\t\t&&&& Number of attributes and attribute types must be consistent; attribute names may be different\n\n\\end{easylist}\n\\subsection{Normalization}\n\t\\label{subsec:design:normalization}\n\\begin{easylist}\n\n\t& \\emph{Normalization:} Minimizing redundancy of related information\n\t\t&& Goals:\n\t\t\t&&& Efficient space use\n\t\t\t&&& Efficient processing of data\n\t\t\t&&& Minimal possibility of inconsistent data and therefore data integrity\n\t\n\t& \\emph{Repetition:} Data which is repeated for no use, and which obscures updating\n\t\t&& E.g. A customer can own many accounts; accounts can have many customers. \\\\\n\t\tAccount = \\{customerID, accNumber, balance, type\\} \\\\\n\t\tThere will be multiple rows for each account with multiple customers, so updating the information of one customer's account will require updating multiple records.\n\t\n\t& OTHER:\n\t\t&& \\emph{Lossless join:} A join where only and all of the appropriate data is returned %TODO ?\n\t\t&& \\emph{Lossy join:} A join where extraneous information/records is created %TODO ?\n\t\t\t&& E.g. Decomposing a table into two tables, one of which has no primary key, and joining them together will create multiple records with useless information\n\t\t\t\n\t& Normalized database design:\n\t\t&& Creating the relational database schema:\n\t\t\t&&& Do not use composite attributes or set valued attributes\n\t\t\t&&& Do not assign attributes to relationship sets which are not descriptive\n\t\t&& Decompose the tables and make sure they satisfy at least one normal form (see subsection~\\ref{subsec:design:normal-forms})\n\n\\end{easylist}\n\\subsection{Normal Forms}\n\t\\label{subsec:design:normal-forms}\n\\begin{easylist}\n\n\t& \\emph{First Normal Form:} Placing all data in one table while removing repeating groups\n\t\t&& Adds rows for repeated groups\n\t\t&& Uses a compound primary key\n\t\t&& Creates fixed-length records\n\t\t&& Complies with the relational model\n\t\t&& Disadvantages:\n\t\t\t&&& Redundant data due to repeated information in groups of rows\n\t\t\t&&& An instance of one attribute of the compound primary key cannot be inserted without creating an instance of the other attribute(s) of the compound primary key\n\t\t\t&&& Deleting the last instance of an attribute in a primary key also deletes... %TODO\n\t\t\t&&& Update... %TODO\n\t\t\n\t& \\emph{Second Normal Form:} Removing partial key dependencies from a First Normal Form...\n\t\t&& %TODO\n\t\t&& Any database in 2NF is also in 1NF\n\t\t&& Disadvantages:\n\t\t\t&&& Only considers partial key dependencies; ignores non-key dependencies\n\t\t\t&&& Redundant data\n\t\t\t&&& Insert/delete/update anomalies\n\t\n\t& \\emph{Third Normal Form:} %TODO\n\t\n\t& See \\emph{functional dependencies}, subsection %TODO \\ref{}\n\t\t&& Goals of decomposition:\n\t\t\t&&& Should not result in a lossy join %TODO ref\n\t\t\t\t&&&& %TODO notes\n\t\t\t&&& \\emph{Dependency preservation:} If a set of attributes depends on an attribute, the dependency should be maintained in one table\n\t\t\t&&& Minimal redundancy\n\t\t\t\n\t& \\emph{Boyce-Codd Normal Form (BCNF):} Obtained by simplifying functional dependencies from Third Normal Form\n\t\t&& Ignores multi-valued dependencies\n\t\t&& The only functional dependencies are those where the key of the table determines attributes (excluding trivial dependencies)\n\t\t&& Database is in BCNF if each table is in BCNF\n\t\t&& Strict definition: A relational schema $R$ is in BCNF with respect to a set of dependencies $F$ if, for all... %TODO notes\n\t\n\t\n\\end{easylist}\n\\subsection{Views}\n\t\\label{subsec:relational-model:views}\n\\begin{easylist}\n\n\t& \\emph{View:} External schema which displays a particular set of data\n\t\t&& Convenient for users to access data without referring to multiple tables\n\t\t&& Ensures that users can only access specific data\n\t\t&& Masks changes in the conceptual schema\n\t\t&& Updates may cause problems when derived from multiple tables, and does not include the primary keys of all tables, so they are generally only allowed on views derived from a single table\t\n\n\\end{easylist}\n\\clearpage", "meta": {"hexsha": "cc939107fcd16e707a85b89cc7fd34445970183b", "size": 6259, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cmpt-354-database-systems-i_partial/tex/design.tex", "max_stars_repo_name": "AmirNaghibi/notes", "max_stars_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2019-08-11T08:45:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:37:39.000Z", "max_issues_repo_path": "cmpt-354-database-systems-i_partial/tex/design.tex", "max_issues_repo_name": "AmirNaghibi/notes", "max_issues_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cmpt-354-database-systems-i_partial/tex/design.tex", "max_forks_repo_name": "AmirNaghibi/notes", "max_forks_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-11-18T09:17:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-27T21:44:56.000Z", "avg_line_length": 47.0601503759, "max_line_length": 192, "alphanum_fraction": 0.7434094903, "num_tokens": 1587, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.41901219868391115}}
{"text": "%\\documentclass[10pt]{beamer}\n\\documentclass[handout, 10pt]{beamer} %handout -> collapse pauses\n\n% MANAGE HANDOUT\n%\\usepackage{pgfpages} \n% \\setbeameroption{show notes}\n% \\setbeameroption{show notes on second screen=right}\n\n\\usepackage{../preamble_slides}\n\\usepackage{../macros}\n\n\\usetheme{metropolis}\n\n%%% Remove nav symbols (and shift any logo down to corner)\n\\setbeamertemplate{navigation symbols}{\\vspace{-2ex}}\n\n\\title{Random vectors in high dimensions}\n\\author{Dimitri Meunier}\n\\institute{IIT}\n\n\\begin{document}\n\\maketitle\n\n\\begin{frame}\n  \\frametitle{Plan}\n\n  \\begin{enumerate}\n  \\item Random vectors\n    \\pause\n  \\item Characteristic function\n    \\pause\n  \\item Gaussian vectors\n    \\pause\n  \\item Sub-Gaussian vectors\n    \\pause\n  \\item Uniform probability measure on the sphere\n  \\end{enumerate}\n\\end{frame}\n\n\n\n  \\section{Refresher: random vectors}\n\n  \\begin{frame}\n    \\frametitle{Random Vectors -- moments}\n\n    A real random vector is a measurable function,\n\n    \\begin{align*}\n      X \\colon (\\Omega,\\cA,\\P) &\\to  (\\Rd,\\cB(\\Rd))\\\\\n      w &\\mapsto (X_1(w), \\ldots, X_d(w))\n    \\end{align*}\n\n    \\pause\n\n    \\begin{itemize}\n    \\item $\\E[X] = (\\E[X_1], \\ldots, \\E[X_d])^T \\in \\Rd$\n      \\pause\n      \n    \\item $\\V[X] = \\E[(X-\\E[X])(X-\\E[X])^T] \\pause =  \\E[XX^T] - \\E[X]\\E[X]^T \\in\n      \\R^{d\\times d}$\n      \\pause\n    %\\item $\\mathbb{V}[X]_{ii} = \\mathbb{V}[X_i], i=1,\\ldots,d$\n    \\item $\\V[X]_{ij} = Cov(X_i,X_j), \\quad  i,j=1,\\ldots,d$        \n    \\end{itemize}\n  \\end{frame}\n\n  % \\begin{frame}\n  %   \\frametitle{Random Vectors -- isotropy}\n\n  %   \\textbf{Isotropy:}  $\\E[XX^T] = I_d$\n\n  %   \\pause\n\n  %   Equivalently,   \n \n  %   \\begin{itemize}\n  %   \\item $\\E[\\langle X,\\theta \\rangle^2] = \\|\\theta\\|_2^2$ for all $\\theta \\in\n  %     \\Rd$\n  %   \\item $\\E[\\langle X,\\theta \\rangle^2] = 1$ for all $\\theta \\in S^{d-1}$\n  %   \\end{itemize}\n\n  %   \\textbf{Proof} If $A$ and $B$ are symmetric, $A=B$ if and only if\n  %   $\\theta^TA\\theta = \\theta^TB\\theta$ for all $\\theta \\in \\Rd$.\n  % \\end{frame}\n\n  \\section{Gaussian vectors}\n\n  \\begin{frame}{Characteristic function}\n\n    \\begin{definition}[Characteristic function]\n      if $X$ is a real random vector, the characteristic function of $X$ is the function\n      $\\Phi_{X}: \\mathbb{R}^{d} \\longrightarrow \\mathbb{C}$ defined by\n      $$\n      \\Phi_{X}(\\xi)=\\E[e^{i\\langle \\xi,X \\rangle}] = \\int_{\\Rd} e^{i\\langle \\xi,X \\rangle} \\P_{X}(d x), \\quad \\xi \\in \\mathbb{R}^{d}\n      $$\n\n    where $\\P_X(A) = \\P(X^{-1}(A))$, for all $A \\in \\cB(\\Rd)$. $\\Phi_{X}$ is the Fourier transform of the distribution of $X$.\n    \\end{definition}\n\n    \\pause\n\n    \\begin{theorem}\n      The characteristic function of a real random vector $X$ characterised its\n      distribution: $\\Phi_X = \\Phi_Y \\implies \\P_X = \\P_Y$.\n    \\end{theorem}\n\n    \\pause\n\n    \n    \\begin{corollary}\n      $X=(X_1,\\ldots,X_d)$ has independent coordinates if and only if \\\\\n      $\\Phi_{X}\\left(\\xi_{1}, \\ldots, \\xi_{d}\\right)=\\prod_{i=1}^{d}\n      \\Phi_{X_{i}}\\left(\\xi_{i}\\right)$\n    \\end{corollary}\n  \\end{frame}\n\n  \\begin{frame}{Univariate Gaussian distribution}\n\n    The univariate standard normal (or Gaussian) random variable  $Z \\sim\n    \\cN_1(0,1)$, is the random variable with density function,\n    $$f_Z(x)=(2\\pi)^{-\\frac{1}{2}} e^{-\\frac{1}{2}x^{2}}.$$\n\n    \\pause\n\n    $X \\sim \\cN_1(\\mu,\\sigma^2)$ if $X = \\mu + \\sigma Z$\n    ($\\sigma \\geq 0$) where  $Z \\sim \\cN_1(0,1)$.\n\n    $$f_X(x)=(2\n    \\pi\\sigma^2)^{-\\frac{1}{2}} e^{-\\frac{1}{2\\sigma^2}(x-\\mu)^{2}} \\qquad\n    (\\sigma > 0) $$\n\n    \\pause\n\n      $$\n      \\boxed{\\Phi_{X}(\\xi)=\\exp \\left(i\\xi \\mu -\\frac{\\sigma^{2} \\xi^{2}}{2}\\right), \\quad \\xi \\in \\mathbb{R}}\n      $$\n\n      \\pause\n\n      \\textbf{Proof}. It is sufficient to show that $\\Phi_{Z}(\\xi)=\\exp\n      \\left(-\\frac{\\xi^{2}}{2}\\right)$. For this, use integration by parts to\n      show that $\\Phi_Z$ satisfies $\\Phi_Z'(\\xi) = -\\xi\\Phi_Z(\\xi)$, $\\Phi_Z(0) =\n      1$.\n  \\end{frame}\n\n  \\begin{frame}{Gaussian vectors -- definition}\n    \\begin{definition}\n      Let $X:(\\Omega,\\cA,\\P) \\to \\Rd$ be a real random vector. $X$ is a \\textbf{Gaussian\n        vector} if for all $\\theta \\in \\Rd$, $\\langle X, \\theta \\rangle$ has a\n      univariate normal distribution.\n    \\end{definition}\n\n    \\pause\n\n    \\begin{theorem} $X$ is a Gaussian vector if and only if, there exists a\n      vector $\\mu \\in \\mathbb{R}^{d}$ and a positive semi-definite matrix $K \\in \\R^{d \\times d}$ such that,\n\n      \\begin{equation}\n        \\Phi_{X}(\\xi)=\\exp \\left(i \\mu \\cdot \\xi-\\frac{1}{2} \\xi^t K \\xi\\right),\n        \\qquad \\xi \\in \\Rd.\n      \\end{equation}\n\n      Furthermore, $\\mu = \\E[X]$ and $K = \\mathbb{V}(X)$, we use the notation\n      $X \\sim \\cN_d(\\mu,K)$.\n    \\end{theorem}\n\n    \\pause\n    \\textbf{Proof.}\n  \\end{frame}\n\n  \\begin{frame}{Gaussian vectors -- properties}\n\n    \\begin{corollary}\n      \\begin{itemize}\n      \\item If $X$ is a Gaussian vector, its coordinates are independant if and only if\n        the covariance matrix is diagonal.\n\n        \\pause\n\n      \\item If $X$ is a vector of independent univariate\n        Gaussian variables, $X$ is a Gaussian vector\n\n      %\\item  $X \\sim \\cN_d(0,I_d)$ if and only if its coordinates are i.i.d with\n      %  distribution $\\cN(0,1)$. $X$ is called a \\textbf{standard Gaussian}\n      %  vector.\n      \\end{itemize}\n    \\end{corollary}\n\n    \\pause\n\n    \\begin{proposition}\n      If $X$ is a Gaussian vector, for all $B \\in \\R^{r \\times d}$ and $b\n      \\in \\R^r$, $Y = BX + b$ is also a Gaussian vector.\n    \\end{proposition}\n  \\end{frame}\n\n  \\begin{frame}\n    \\frametitle{Gaussian vectors -- density}\n\n    \\begin{corollary}\n      Let $X \\sim \\cN_d(\\mu,K)$, then $X =\n      K^{1/2}Z + \\mu$, where $Z \\sim \\cN_d(0,I_d)$ and the equality holds in\n      distribution. \n    \\end{corollary}\n\n    \\pause\n\n    \\begin{corollary}\n      \n      If $X \\sim \\cN_d(\\mu,K)$, $X$ admits a density if and only if $K$ is\n      invertible and in that case, its density function is,\n      $$f(x)=|2 \\pi K|^{-\\frac{1}{2}} e^{-\\frac{1}{2}\\|x - \\mu\\|_{K^{-1}}^{2}}$$\n    \\end{corollary}\n  \\end{frame}\n\n  \\begin{frame}{Sub-Gaussian vectors -- definition}\n    \\begin{definition}[Sub-gaussian random vector] A random vector $X$ in\n      $\\mathbb{R}^{d}$ is called sub-gaussian if the one-dimensional marginals\n      $\\langle X, \\theta \\rangle$ are sub-gaussian random variables for all $\\theta \\in \\mathbb{R}^{d} .$ The sub-gaussian norm of $X$ is defined as\n      $$\n      \\|X\\|_{\\psi_{2}}=\\sup _{\\theta \\in S^{d-1}}\\|\\langle X, \\theta\\rangle\\|_{\\psi_{2}}\n      $$\n\n    \\end{definition}\n\n    \\pause\n\n    \\textbf{Examples.}\n    \n    \\begin{itemize}\n    \\item Gaussian vectors\n    \\item Random vectors with \\emph{independent} sub-gaussian coordinates\n    \\item Uniform distribution on the sphere (next section)\n    \\end{itemize}\n  \\end{frame}\n\n  \\begin{frame}{Spherical distribution}\n\n    \\begin{columns}\n      \\begin{column}{0.75\\textwidth}\n\n        \\begin{definition}\n          If $A \\in \\mathcal{B}\\left(S^{d-1}\\right)$, we define the \\emph{wedge}\n          $\\Gamma(A)$ as the Borel set\n          of $\\mathbb{R}^{d}$ defined by\n          $$\n          \\Gamma(A)=\\{r x ; r \\in[0,1] \\text { and } x \\in A\\}\n          $$\n          \\pause\n          The \\textbf{spherical measure} on the sphere is defined by,\n          $$\n          \\omega_{d}(A)=\\lambda_{d}(\\Gamma(A))\n          $$\n        \\end{definition}\n      \\end{column}\n      \\pause\n      \\begin{column}{0.25\\textwidth}  %%<--- here\n        \\begin{center}\n          \\includegraphics[width=1\\textwidth]{wedge.png}\n        \\end{center}\n      \\end{column}\n    \\end{columns}\n\n    \\pause\n\n    It can be shown that $\\omega_d(S^{d-1}) = \\lambda_d(B^d)  = \\frac{\\pi^{d /\n        2}}{\\Gamma\\left(\\frac{d}{2} + 1\\right)} $.\n    \\pause\n\n    \\begin{equation*}\n      \\sigma_{d}(A):= \\omega_d(S^{d-1})^{-1} \\omega_d(A)\n    \\end{equation*}\n\n    is the \\textbf{uniform probability distribution on the sphere}.\n\n  \\end{frame}\n\n  \\begin{frame}{Polar change of variables}\n    \\begin{theorem}\n      \\begin{itemize}\n      \\item $\\sigma_{d}$ is the unique probability measure on the sphere\n        $S^{d-1}$ invariant to the action of vectorial isometries.\n\n        \\pause\n\n      \\item For any measurable function $f: \\Rd \\to \\R$ positive or integrable,\n\n        \\begin{equation*}\n          \\begin{aligned}\n            \\int_{\\R^{d}} f(x) d x &=\\int_{S^{d-1}}\\left(\\int_{0}^{\\infty} f(r \\gamma) dr^{d-1} d r\\right) d \\textcolor{blue}{\\omega_d}(\\gamma) \\\\ \\pause\n            &= \\textcolor{blue}{\\omega_d(S^{d-1})} \\int_{S^{d-1}}\\left(\\int_{0}^{\\infty} f(r \\gamma) dr^{d-1} d r\\right) d \\textcolor{blue}{\\sigma_d}(\\gamma)\n          \\end{aligned}\n        \\end{equation*}\n\n\n      \\end{itemize}\n\n    \\end{theorem}\n\n  \\end{frame}\n\n  \\begin{frame}{Link to the Gaussian distribution}\n    \\begin{proposition}[Exercise 3.3.7] Let us write $X \\sim N_d\\left(0, I_{d}\\right)$ in\n      polar  form as\n      $$\n      X=R \\theta\n      $$\n      where $R=\\|X\\|_{2}$ is the length and $\\theta=X /\\|X\\|_{2}$ is the direction\n      of $X$. Prove the following:\n\n      \\pause\n\n      \\begin{enumerate}\n      \\item the length $R$ and direction $\\theta$ are independent random\n        variables\n        \\pause\n      \\item the direction $\\theta$ is uniformly distributed on the unit sphere\n        $S^{d-1}$\n      \\end{enumerate}\n    \\end{proposition}\n\n  \\end{frame}\n\n  % \\begin{frame}{Gaussian concentration}\n  %   \\begin{itemize}\n  %   \\item recall concentration of the norm\n  %   \\item fine tune the interpretation for Gaussian (+ images)\n  %   \\item Isotropy / Sub-Gaussianity of the uniform sphere r.v.\n  %   \\item Examples of sub-gaussianity\n  %   \\end{itemize}\n  % \\end{frame}\n\\end{document}\n", "meta": {"hexsha": "ed6e9ca8c5b3c34a72255e5a24be0c54ae3dd324", "size": 9672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides_Dim/slides.tex", "max_stars_repo_name": "IsakFalk/vershynin-reading-group-presentation", "max_stars_repo_head_hexsha": "ba9361e3c5cfde459f12a0ac83f0b9dee3c25f6f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-11T15:32:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-11T15:32:50.000Z", "max_issues_repo_path": "slides_Dim/slides.tex", "max_issues_repo_name": "IsakFalk/vershynin-reading-group-presentation", "max_issues_repo_head_hexsha": "ba9361e3c5cfde459f12a0ac83f0b9dee3c25f6f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides_Dim/slides.tex", "max_forks_repo_name": "IsakFalk/vershynin-reading-group-presentation", "max_forks_repo_head_hexsha": "ba9361e3c5cfde459f12a0ac83f0b9dee3c25f6f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9580838323, "max_line_length": 157, "alphanum_fraction": 0.5842638544, "num_tokens": 3330, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.4190054981813376}}
{"text": "\\documentclass[bigger]{beamer}\n\n\\input{header-beam} % change to header-handout for handouts\n\n% ====================\n\\title[Lecture 12]{Logic I F13 Lecture 12}\n\\date{October 22, 2013}\n% ====================\n\n\\include{header}\n\n\\setlength{\\fitchprfwidth}{5em}\n\n\\section{Review}\n\n\\subsec{Satisfaction}{\n\n\\bit \n\\item Atomic wffs like $\\sf Cube(x)$ express the properties we've\n  assigned to the predicate symbol\n\\item More general: any wff $\\sf P(x)$ expresses a property\n\\item Which one? The property of \\emph{satisfying $\\sf P(x)$}.\n\\item \\emph{$\\alpha$ satisfies $\\sf P(x)$ in~$W$} iff $\\sf P(n)$ is true in\n  the world~$W'$ which is just like $W$ except $n$ names $\\alpha$\n\\item Extension of $\\sf P(x)$ in $W$: set of all objects that satisfy\n  $\\sf P(x)$ in $W$.\n\\item Examples:\n\\bit\n\\item $x$ is a small tetrahedron to the left of $b$:\\[\n\\sf Small(x) \\land Tet(x) \\land LeftOf(x, b)\n\\]\n\\item $x$ adjoins  c or d, but not both\n\\[\n\\sf \\lnot(Adjoins(x, c) \\iff Adjoins(x, d))\n\\]\n\\eit\n\\eit\n\n}\n\n\\subsec{Quantifiers and Satisfaction: $\\forall$}{\n\n\\bit\n\\item The sentence\n\\[\\sf\n\\forall x\\, P(x)\n\\]\nsays (is true iff) \n\\bit\n\\item every object in the domain (= world) satisfies P(x)\n\\item P(n) is true for \\emph{whatever} object is named by~n\n\\item extension of P(x) in $W$ is the entire domain\n\\eit\n\\eit\n}\n\n\\subsec{Quantifiers and Satisfaction: $\\exists$}{\n\n\\bit\n\\item The sentence\n\\[\\sf\n\\exists x\\, P(x)\n\\]\nsays (is true iff) \n\\bit\n\\item at least one object in the domain satisfies P(x)\n\\item P(n) is true for \\emph{at least one} object named by~n\n\\item extension of P(x) in $W$ is not empty\n\\eit\n\\eit\n\n}\n\n\\subsec{Expressing ``Everything'', ``Something''}{\n\n\n\\bit\n\\item ``Everything is a large cube''\n\\[ \\sf \\forall x(Large(x) \\land Cube(x)) \\]\n\\item ``Something is a large cube''\n\\[ \\sf \\exists x(Large(x) \\land Cube(x)) \\]\n\\eit\n}\n\n\\subsec{Expressing ``Nothing'', ``Not Everything''}{\n\n\\bit\\item ``Nothing is a large cube'' \\pause\n\\begin{align*}\n& \\sf \\forall x\\,\\lnot(Large(x) \\land Cube(x)) \\\\\n& \\sf \\lnot\\exists x(Large(x) \\land Cube(x))\n\\end{align*}\nAlso: ``Everything is: not a large cube''\n\\item ``Something isn't a large cube'' \\pause\n\\begin{align*}\n& \\sf \\exists x\\,\\lnot(Large(x) \\land Cube(x)) \\\\\n& \\sf \\lnot\\forall x(Large(x) \\land Cube(x))\n\\end{align*}\nAlso: ``Not everything is a large cube''\n\\eit\n}\n\n\\section{Restricted Quantification}\n\n\\subsec{Determiner Phrases}{\n\n\\bit\n\\item Determiners combine with noun phrases to make determiner phrases (DP):\n\\bit\n\\item ``\\emph{A} large terahedron''\n\\item ``\\emph{Three} cubes which are to the left of b''\n\\item ``\\emph{Every} even number''\n\\item ``\\emph{Some} cube(s) between d and e''\n\\item ``\\emph{Most} philosophy majors''\n\\item ``\\emph{Both} small cubes''\n\\eit\n\\eit\n}\n\n\\subsec{Determiner Phrases in Sentences}{\n\n\\bit\n\\item DPs make subjects of sentence, just like names/constants and coordination constructions of them do\n\\bit\n\\item ``\\emph{Claire and Alex} study logic''---``\\emph{Most philosophy majors} study logic''\n\\item ``\\emph{2} is prime''---``\\emph{Some even number} is prime''\n\\item ``\\emph{a} is between b and c''---``\\emph{Every large cube} is between b and c''\n\\eit\n\\item We know how to translate the former---how do we deal with the latter?\n\\eit\n}\n\n\\subsec{Restricted Quantification}{\n\n\\bit\n\\item ``Det A is/are B''\n\\item A is a noun (phrase), B an adjective or article + noun (phrase)\n\\item Translate ``x is an A'' into a wff of FOL: A(x)\n\\item Translate ``x is B''  into a wff of FOL: B(x)\n\\item Combine A(x), B(x) in the right way\n\\eit\n\n}\n\n\\subsec{Some A is B}{\n\n\\bit\n\\item ``Some cube is large''\n\\item ``x is a cube'': $\\sf Cube(x)$\n\\item ``x is large'': $\\sf Large(x)$\n\\item Combine:\n\\[\\sf\n\\uncovers{2-4}{\\exists x}\\uncovers{2-4}{(}Cube(x) \\uncovers{3-4}{{}\\land{}} Large(x)\\uncovers{2-4}{)}\n\\]\n\\items{4} Also:\n\\bit\n\\item ``Some cubes are large''\n\\item ``There are large cubes''\n\\item ``Something large is a cube''\n\\item ``A cube is large''\n\\eit\n\\eit\n\n}\n\n\n\\subsec{Every A is B}{\n\n\\bits\n\\item ``Every cube is large''\n\\item Options:\n\\bens\n\\item[] $\\sf \\forall x(Cube(x) \\phantom{{}\\land{}} Large(x))$\n\\item $\\sf \\forall x(Cube(x) \\land Large(x))$ \\uncovers{7-}{\\color{red}NO}\n\\item $\\sf \\forall x(Cube(x) \\lor Large(x))$ \\uncovers{7-}{\\color{red}NO}\n\\item $\\sf \\forall x(Cube(x) \\to Large(x))$ \\uncovers{7-}{\\color{green}YES}\n\\een\n\\item Also:\n\\bit\n\\item ``All cubes are large''\n\\item ``Any cube is large''\n\\item ``Cubes are large''\n\\item ``If something is a cube, it is large''\n\\eit\n\\eit\n\n}\n\n\\subsec{The Indefinite Article}{\n\n\\bits\n\\item ``A small cube adjoins a''\n\\item[]\n$\\sf \\exists x((Small(x) \\land Cube(x)) \\land Adjoins(x, a))$\n\\item ``a is left of a large tetrahedron''\n\\item[]$\n\\sf \\exists x((Large(x) \\land Tet(x)) \\land LeftOf(a, x))\n$\n\\item ``An even number is a multiple of 2''\n\\item[]\n$\\sf \\forall x(Even(x) \\to MultipleOf(x, (1+1)))$\n\\item ``If a cube adjoins a, it is large''\n\\item[]$\\sf \\forall x((Cube(x) \\land Adjoins(x, a)) \\to Large(x))$\n\\eit\n\n}\n\n\n\\subsec{No A is B}{\n\n\\bits\n\\item ``No cube is large''\n\\item Options:\n\\bens\n\\item[] $\\sf \\phantom{lnot\\forall} x(Cube(x) \\phantom{{}\\land{}} Large(x))$\n\\item $\\sf \\forall x(Cube(x) \\to \\lnot Large(x))$\n\\item $\\sf \\lnot\\exists x(Cube(x) \\land Large(x))$\n\\een\n\\item Also: \n\\bit\n\\item ``No cubes are large''\n\\item ``There are no large cubes''\n\\item ``Nothing large is a cube''\n\\eit\n\\eit\n}\n\n\\subsec{Only As are Bs}{\n\n\\bits\n\\item ``Only cubes are large''\n\\bits\n\\item ``All non-cubes are non-large''\n\\item $\\sf \\forall x(\\lnot Cube(x) \\to \\lnot Large(x))$\n\\item $\\sf \\forall x(Large(x) \\to Cube(x))$\n\\eit\n\\item ``Only a is large''\n\\bits\n\\item ``a is large, and nothing other than a is large''\n\\item $\\sf Large(a) \\land \\forall x(x \\neq a \\to \\lnot Large(x))$\n\\item $\\sf \\forall x(Large(x) \\iff x = a)$\n\\eit\n\\eit\n}\n\n\\subsec{Existential Import}{\n\n\\bit\n\\item Does ``all cubes are small'' have ``there are cubes'' as a consequence?\n\\item Not according to our translations!\n\\[\n\\sf\\forall x(Cube(x) \\to Small(x))\n\\]\nis true if there are no cubes at all.\n\\item (1) ``Everyone who took the exam passed''\\\\\n(2) ``Noone who took the exam failed''\n\\bit\n\\item (1) and (2) are equivalent\n\\item If noone took the exam, then (2) is true \n\\eit\n\\eit\n}\n\n\\subsec{Existential Import and Implicature}{\n\n\\bit\n\\item P \\emph{implies} Q iff Q is a consequence of P \n\\item If P implies Q, then the denial of Q contradicts P\n\\bit\n\\item ``Some A are B'' implies ``There are As''\n\\item ``Some cubes are small'' implies ``There are cubes''\n\\item ``Some cubes are small. There are no cubes'': contradictory\n\\eit\n\\item Does ``All cubes are small'' imply ``There are cubes?''\n\\eit\n}\n\n\\subsec{Existential Import and Implicature}{\n\n\\bit\n\\item P \\emph{implicates} Q if in asserting P, it is (strongly) suggested that Q is true \n\\item Existential import is only \\emph{implicated}, not \\emph{implied}\n\\item Test: No contradiction if implicature is denied:\n\\bit\n\n\\item ``Noone who took the exam failed.\\\\\nIn fact, noone took the exam at all''\n\n\\item ``Some students passed the exam.\\\\\nIn fact, all students passed.''\n\n\\item ``All unicorns are white.\\\\\nAll zero of them.''\n\\eit\\eit\n\n}\n\n\\subsec{Quantifiers and Function Symbols}{\n\n\\bits\n\\item ``The leftmost block in the same row as any cube is small''\n\\bits\n\\item ``For every cube, the leftmost block in the same column as it is small''\n\\item\n\\[\n\\sf \\forall x(Cube(x) \\to Small(lm(x)))\n\\]\n\\eit\n\\item ``Some multiples of 3 are even, and some aren't''\n\\bits\n\\item Note: every multiple of 3 is the multiple of 3 \\emph{by some number}\n\\item ``There is a number such that the multiple of 3 by it is even''\n\\item \n$\n\\sf \\exists x\\,Even(x \\times (1 + (1+1)))\n$\n\\item\n$\n\\sf \\exists x\\, Even(x \\times (1 + (1+1))) \\land \\exists x\\, \\lnot Even(x \\times (1 + (1+1)))\n$\n\\eit\n\\eit\n}\n\n\n\\end{document}\n\n\n\n\n", "meta": {"hexsha": "0f5732719a0e3e89c3caf909a1078e8b8f877c2c", "size": 7734, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "279-lec12.tex", "max_stars_repo_name": "rzach/phil279", "max_stars_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-09-23T13:42:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-21T10:48:55.000Z", "max_issues_repo_path": "279-lec12.tex", "max_issues_repo_name": "rzach/phil279", "max_issues_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "279-lec12.tex", "max_forks_repo_name": "rzach/phil279", "max_forks_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.4363636364, "max_line_length": 104, "alphanum_fraction": 0.657745022, "num_tokens": 2616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632683808533, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.419005478217296}}
{"text": "%% LyX 2.2.3 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[12pt,english]{extarticle}\n\\renewcommand{\\familydefault}{\\rmdefault}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{luainputenc}\n\\usepackage{geometry}\n\\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{setspace}\n\\usepackage[authoryear]{natbib}\n\\doublespacing\n\n\\makeatletter\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{dcolumn}\n\\thispagestyle{empty}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\n\\subsection*{Solve for global min var portfolio}\n\nBegin with portfolio covariance $\\Sigma$ and returns z. The global\nminimum variance portfolio is given by\n\\begin{align*}\n\\min & w'\\Sigma w\\\\\ns.t.1'w= & 1\n\\end{align*}\n\nwhere the last term imposes a unique solution w/o loss of generality.\nThen:\n\\begin{align*}\n0= & \\Sigma w_{g}-\\lambda1\\\\\nw_{g}= & \\lambda\\Sigma^{-1}1\\\\\n1= & \\lambda1'\\Sigma^{-1}1\n\\end{align*}\n\nLet $A=1'\\Sigma^{-1}1$. Then $w_{g}=\\frac{\\Sigma^{-1}1}{A}$\n\n\\subsection*{Proof that $w_{p}\\Sigma w_{g}=\\frac{1}{A}$}\n\nPick any portfolio s.t. wlog $w_{p}'1=1$. Then \n\\begin{align*}\nw_{g}= & \\frac{\\Sigma^{-1}1}{A}\\\\\nw_{p}\\Sigma w_{g}= & \\frac{w_{p}'1}{A}=\\frac{1}{A}\n\\end{align*}\n\n\\subsection*{Delta Method: Derivation of Asymtotic Sample Covariance}\n\nThe result is standard from asymtotic theory. Start with the definition\nof $S_{XY}$ and define $\\sigma_{XY}\\equiv\\left[\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)\\right]$.\nThen:\n\\begin{align*}\nnS_{XY}= & \\sum\\left(X_{i}-\\overline{X}\\right)\\left(Y_{i}-\\overline{Y}\\right)\\\\\nnS_{XY}= & \\sum\\left(\\left(X_{i}-\\mu_{X}\\right)-\\left(\\overline{X}-\\mu_{X}\\right)\\right)\\left(\\left(Y_{i}-\\mu_{Y}\\right)-\\left(\\overline{Y}-\\mu_{Y}\\right)\\right)\\\\\n= & \\sum\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)-\\sum\\left(X_{i}-\\mu_{X}\\right)\\left(\\overline{Y}-\\mu_{Y}\\right)\\\\\n & -\\sum\\left(Y_{i}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)+n\\left(\\overline{Y}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)\\\\\n= & \\sum\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)-n\\left(\\overline{Y}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)\\\\\nn\\left(S_{XY}-\\sigma_{XY}\\right)= & n\\sum\\frac{1}{n}\\left[\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)-\\sigma_{XY}\\right]-n\\left(\\overline{Y}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)\\\\\n\\sqrt{n}\\left(S_{XY}-\\sigma_{XY}\\right)= & \\sqrt{n}\\sum\\frac{1}{n}\\left[\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)-\\sigma_{XY}\\right]-\\sqrt{n}\\left(\\overline{Y}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)\n\\end{align*}\n\nNow apply the asymtotics. By the Central Limit Theorem, $\\sqrt{n}\\left(\\overline{Y}-\\mu_{Y}\\right)\\stackrel{d}{\\to}N\\left(\\cdot\\right)$.\nBy the Weak Law of Large Numbers, $\\left(\\overline{X}-\\mu_{X}\\right)\\stackrel{p}{\\to}0$.\nThus by Slutsky's theorem, $\\sqrt{n}\\left(\\overline{Y}-\\mu_{Y}\\right)\\left(\\overline{X}-\\mu_{X}\\right)\\to0$. \n\nApplying the Central Limit Theorem to the remaining term implies $\\sqrt{n}\\left(S_{XY}-\\sigma_{XY}\\right)\\stackrel{d}{\\to}N\\left(\\cdot\\right)$.\nNote $E\\left[\\sum\\frac{1}{n}\\left[\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)-\\sigma_{XY}\\right]\\right]=0$.\nThe variance is given by:\n\\begin{align*}\nV & \\left[\\left(X_{i}-\\mu_{X}\\right)\\left(Y_{i}-\\mu_{Y}\\right)\\right]=E\\left[\\left(X_{i}-\\mu_{X}\\right)^{2}\\left(Y_{i}-\\mu_{Y}\\right)^{2}\\right]-E\\left[\\left(X_{i}-\\mu_{X}\\right)^{2}\\right]E\\left[\\left(Y_{i}-\\mu_{Y}\\right)^{2}\\right]\n\\end{align*}\n\nDefine $\\sigma_{XXYY}\\equiv E\\left[\\left(X_{i}-\\mu_{X}\\right)^{2}\\left(Y_{i}-\\mu_{Y}\\right)^{2}\\right]$,\n$\\sigma_{X}^{2}\\equiv E\\left[\\left(X_{i}-\\mu_{X}\\right)^{2}\\right]$\nand $\\sigma_{Y}^{2}\\equiv E\\left[\\left(Y_{i}-\\mu_{Y}\\right)^{2}\\right]$.\nThen we have shown:\n\\begin{align*}\n\\sqrt{n}\\left(S_{XY}-\\sigma_{XY}\\right)\\stackrel{d}{\\to} & N\\left(0,\\;\\sigma_{XXYY}-\\sigma_{X}^{2}\\sigma_{Y}^{2}\\right)\n\\end{align*}\n\nAs a special case, let $X$ and $Y$ be drawn from the same distribution.\nDefine $\\sigma_{X^{4}}\\equiv E\\left[\\left(X_{i}-\\mu_{X}\\right)^{4}\\right]$.\nThen:\n\\begin{align*}\n\\sqrt{n}\\left(S_{X}-\\sigma_{X}^{2}\\right)\\stackrel{d}{\\to} & N\\left(0,\\;\\sigma_{X^{4}}-\\sigma_{X}^{4}\\right)\n\\end{align*}\n\nQ.E.D.\n\n\\subsection*{MCMC}\n\n\\subsubsection*{Overview}\n\\begin{itemize}\n\\item Use a Bayesian MCMC approach, with Gibbs sampling\n\\begin{itemize}\n\\item This approach relies heavily on the central limit theorem and other\nasymptotics\n\\item Suppose we pick a test portfolio P of mx1 weights $w_{P}$ from which\nto test our candidate weights for the minimum variance portfolio $w_{G}$\n\\begin{itemize}\n\\item Define $S_{G}$ as the sample variance of $R_{G}$, the returns of\nall assets weighted by $w_{G}$\n\\item Define $S_{GP}$ as the sample covariance of the minimum variance\nportfolio and the test portfolio. For shorthand, designate $S\\equiv\\left\\{ S_{G},\\,S_{GP}\\right\\} $ \n\\begin{itemize}\n\\item Note given $w_{G}$, the test portfolio weights $w_{P}$, and the\ndata $D$, $S$ is fully specified. \n\\item Since $w_{P},\\,D,\\,w_{G}$ only enter the model via $S$, conditioning\non $S$ is equivalent to conditioning on $w_{P}$, $w_{G}$, and $D$\n\\end{itemize}\n\\item Define $\\zeta_{G}^{2}\\equiv\\frac{\\mu_{4G}-\\sigma_{G}^{4}}{n}$, $\\zeta_{P}^{2}\\equiv\\frac{\\mu_{4P}-\\sigma_{P}^{4}}{n}$,\nand $\\zeta_{GP}\\equiv\\frac{\\sigma_{GGPP}-\\sigma_{GP}^{2}}{n}$ (all\nunobserved). For shorthand, designate \n\\begin{align*}\nZ & \\equiv\\begin{bmatrix}\\frac{\\mu_{4G}-\\sigma_{G}^{4}}{n} & \\frac{\\sigma_{GGPP}-\\sigma_{GP}^{2}}{n}\\\\\n\\frac{\\sigma_{GGPP}-\\sigma_{GP}^{2}}{n} & \\frac{\\mu_{4P}-\\sigma_{P}^{4}}{n}\n\\end{bmatrix}\\\\\n & =\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}\n\\end{align*}\n\\item Without imposing additional structure, we must estimate $w_{G}$,\n$\\sigma_{G}^{2}$ and $Z$. In addition, we will find it useful to\ndraw $S_{G}$ given the available data. \n\\end{itemize}\n\\item Unfortunately, directly evaluating the weights leads to intractable\nposteriors. This leads to the following general ``almost MCMC''\nalgorithm:\n\\begin{enumerate}\n\\item Draw a random test portfolio P with overall returns $R_{P}$.\n\\item Draw from $p\\left(\\sigma_{G}^{2}|\\cdot\\right)$, $p\\left(Z|\\cdot\\right)$,\n$p\\left(S_{G}|\\cdot\\right)$ that is, draw from the parameter posteriors\nfor these parameters given all other parameters. Note this fully specifies\na new vector of weights for $w_{G}$, as shown in the following steps.\n\\item Now we partition the portfolio into three components. Assign each\nindex $i\\in1:m$ to one of sets $G1$, $G2$, or $G3$. Then define\nthe following mx1 vectors:\n\\begin{align*}\n\\Omega_{G1}\\equiv & \\omega_{G1}\\left\\{ \\iota\\left(i\\in G1\\right)\\right\\} _{i\\in1:m}\\\\\n\\Omega_{G2}\\equiv & \\omega_{G2}\\left\\{ \\iota\\left(i\\in G2\\right)\\right\\} _{i\\in1:m}\\\\\n\\Omega_{G3}\\equiv & \\omega_{G3}\\left\\{ \\iota\\left(i\\in G3\\right)\\right\\} _{i\\in1:m}\n\\end{align*}\nwhere $\\iota$is an indicator function, and $\\omega_{G1},\\,\\omega_{G2},\\,\\omega_{G3}$\nare scalars. That is, each vector contains a constant value for all\nassigned indices and zero for all other indices.\n\\item Define $w_{G}'\\equiv\\left\\{ \\left(\\Omega_{iG1}+\\Omega_{iG2}+\\Omega_{iG3}\\right)w_{iG}\\right\\} _{i\\in1:m}$.\nThen solve for $\\omega\\equiv\\left\\{ \\omega_{G1},\\,\\omega_{G2},\\,\\omega_{G3}\\right\\} $.\nNote that these parameters are fully specified by the following three\nconditions:\n\\begin{enumerate}\n\\item The sample variance of the new vector of weights is $S_{G}$. That\nis, $V\\left(R_{G}'\\right)=S_{G}$\n\\item The sample covariance of the new vector of weights with the test portfolio\nis $S_{GP}$, or $cov\\left(R_{G}',\\,R_{P}\\right)=S_{GP}$.\n\\item The weights of the new portfolio add to 1. This can be expressed as\n$\\left(\\Omega_{G1}+\\Omega_{G2}+\\Omega_{G3}\\right)\\cdot w_{G}=1$.\n\\end{enumerate}\n\\item Rotate the partition assignments by one unit and epeat steps 1-5\n\\end{enumerate}\n\\end{itemize}\n\\end{itemize}\n\n\\subsubsection*{Likelihood}\n\\begin{itemize}\n\\item The likelihood is derived from a multivariate normal:\n\\begin{align*}\np\\left(S|w_{G},\\,Z,\\,\\sigma_{G}^{2},\\,w_{P}\\right)\\propto & det\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}^{-\\frac{1}{2}}\\exp\\left[-\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)^{'}\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}^{-1}\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)\\right]\\\\\n\\propto & det\\left[Z\\right]^{-\\frac{1}{2}}\\exp\\left[-\\left(S-\\sigma_{G}^{2}1\\right)^{'}Z^{-1}\\left(S-\\sigma_{G}^{2}1\\right)\\right]\n\\end{align*}\n\\end{itemize}\n\n\\subsubsection*{Priors}\n\nThe following conjugate priors allow for tractable posteriro distributions.\nNote that $W^{-1}$ is the matrix-valued Inverse Wishart distribution,\nwhile $N_{+}$ corresponds to the normal distribution truncated at\n0. \n\\begin{align*}\n\\sigma_{G}^{2}\\sim & N_{+}\\left(\\theta_{G},\\,\\delta_{G}^{2}\\right)\\\\\nS_{G}\\sim & N_{+}\\left(\\theta_{SG},\\,\\delta_{SG}^{2}\\right)\\\\\nZ\\sim & W^{-1}\\left(\\Psi,\\;\\nu\\right)\n\\end{align*}\n\nBy the properties of the inverse Wishart, we must pick $\\Psi=\\begin{bmatrix}\\psi_{G} & \\psi_{GP}\\\\\n\\psi_{GP} & \\psi_{P}\n\\end{bmatrix}$, a symmetric positive semi-definite matrix, along with $\\nu$. Also\nnote that the mean of an inverse Wishart distribution is given by$\\frac{\\Psi}{\\nu-3}$\nfor all $\\nu>3$. The hyperparameters for $W^{-1}$ are thereby selected\nas follows:\n\\begin{itemize}\n\\item The asymptotics rely on the existence of a mean to apply the CLT,\nwhich is equivalent to saying that the fourth moments required by\nthe asymptotics exist. Beyond this assertion, we are highly uncertain\nof our priors, so pick $\\nu=3.01$. \n\\item For $\\psi_{G}$, as an extremely rough approximation, the volatility\nof the VIX ,using the CBOE's VVIX contract, on March 10, 2019 is around\n.87, corresponding to a 30-day variance of about .76. Divide by 20\nto get the daily variance, and divide by 510 since we are averaging\nover 510 samples. Again, this is extremely rough, so multiply by 2\nto account for our uncertainty. This leaves a prior for$\\psi_{G}$\nof about 1.5e-4. \n\\item For $\\psi_{P}$, use the same prior as $\\psi_{G}$ but multiply by\n2 to account for the additional uncertainty related to the portfolio\nsampling process.\n\\item For $\\psi_{SG}$, note an error in the sample variance of G will mechanically\naffect the covariance by the square root of the variance error. As\npreviously discussed, the point estimate for the variance error is\nabout 7.5e-5, with a square root of 0.0087. Multiplying by the point\nestimate of the variance of P yields an estimate for the covariance\nof 6.5e-7, with a correlation of .0087 (since both point estimates\nare the same). Divide by 2 to account for general uncertainty regarding\nthe calculation, so $\\psi_{GP}$=3e-7.\n\\end{itemize}\nThe normal distributions implicitly include the degenerate priors\nthat $\\sigma_{G}^{2}>0$ and $S_{G}>0$. This turns out to not affect\nthe tractability of the posterior distributions. The remaining hyperparameters\nare selected as follows:\n\\begin{itemize}\n\\item Use the current value of the VIX for $\\theta_{G}$. As of March 10,\n2019 it was \\textasciitilde{}16\\%, which implies a variance of about\n$\\theta_{G}=.026$. Divide by 20 to account for our use of daily data. \n\\item For $\\delta_{G}^{2}$, start with the variance implied by VVIX of\n0.76. Again, divide by 20 to make the estimate daily, then multiply\nby 2 to account for the uncertainty of our estimate. This yields variance\nof about $0.15$ to serve as our estimate for $\\delta_{G}^{2}$. As\nwe are picking $\\delta^{2}$ based on the uncertainty of our prior,\nwe do not divide by 510.\n\\item For the sample estimates, assume that they have the same properties\nof $\\sigma_{G}^{2}$ except that they are measured with noise. We\ntherefore impose the same value for $\\theta_{SG}$ and multiply the\nvariance of $\\delta_{SG}^{2}$ by 2 to account for the additional\nnoise. \n\\end{itemize}\nFinally, results which were overly sensitive to the priors would call\nthe conclusions into question. Therefore, check the sensitivity of\nthe approach by using a second set of less informative priors.\n\\begin{itemize}\n\\item We still rely on the existence of a mean, so for Z we set $\\nu=3.01$.\nFor the other hyperparameters, set $\\psi_{G}=\\psi_{P}=1.0$ and $\\psi_{GP}=0.0$.\nSet all other hyper-parameters to $1.0$ and retain the truncation\nof the normal distributions. \n\\end{itemize}\n\n\\subsubsection*{Posteriors}\n\\begin{itemize}\n\\item Start with $\\sigma_{G}^{2}$. \n\\begin{itemize}\n\\item Use the property that the convolution of normals is a normal $N\\left(a,b\\right)$\nwhere a is the precision weighted average of the source means and\nb is the inverse sum of the source precisions. As an intermediate\nstep, we must complete the square in order to express the function\nin the correct form. This requires lots of tedious algebra and hence\nis completed in Mathematica. See the file ``Algebra Posteriors''\nfor the specific details. \n\\begin{align*}\np\\left(S_{GP}|Z,\\,\\sigma_{G}^{2},\\,S_{G}\\right)\\propto & det\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}^{-\\frac{1}{2}}\\exp\\left[-\\frac{1}{2}\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)^{'}\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}^{-1}\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)\\right]\\\\\n\\propto & \\exp\\left[-\\frac{1}{2}\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)^{'}\\begin{bmatrix}\\zeta_{G}^{2} & \\zeta_{GP}\\\\\n\\zeta_{GP} & \\zeta_{P}^{2}\n\\end{bmatrix}^{-1}\\left(\\begin{bmatrix}S_{G}\\\\\nS_{GP}\n\\end{bmatrix}-\\begin{bmatrix}\\sigma_{G}^{2}\\\\\n\\sigma_{G}^{2}\n\\end{bmatrix}\\right)\\right]\\\\\n\\propto & \\frac{-\\left(\\frac{(S_{G}(\\zeta_{G}-2\\zeta_{GP}+\\zeta_{P}^{2})+S_{G}(\\zeta_{GP}-\\zeta_{P}^{2})}{(\\zeta_{GP}-\\zeta_{G}^{2})}+\\sigma_{G}^{2}\\right)^{2}}{2\\frac{(\\zeta_{G}^{2}-2\\zeta_{GP}+\\zeta_{P}^{2})\\left(\\zeta_{G}^{2}\\zeta_{P}^{2}-\\zeta_{GP}^{2}\\right)}{\\left(\\zeta_{GP}-\\zeta_{G}^{2}\\right)^{2}}}\\\\\n\\propto & N\\left(\\mu_{G},\\,\\gamma_{G}^{2}\\right)\\\\\n\\mu_{G}\\equiv & -\\frac{(S_{G}(\\zeta_{G}-2\\zeta_{GP}+\\zeta_{P}^{2})+S_{G}(\\zeta_{GP}-\\zeta_{P}^{2})}{(\\zeta_{GP}-\\zeta_{G}^{2})}\\\\\n\\gamma_{G}^{2}= & \\frac{(\\zeta_{G}^{2}-2\\zeta_{GP}+\\zeta_{P}^{2})\\left(\\zeta_{G}^{2}\\zeta_{P}^{2}-\\zeta_{GP}^{2}\\right)}{\\left(\\zeta_{GP}-\\zeta_{G}^{2}\\right)^{2}}\n\\end{align*}\n\\item Now convolute the truncated normal prior by the above normal distribution\nto obtain the posteriors:\n\\begin{align*}\np\\left(\\sigma_{G}^{2}|S,\\,\\zeta^{2}\\right)\\propto & p\\left(S_{GP}|Z,\\,\\sigma_{G}^{2},\\,S_{G}\\right)p\\left(\\sigma_{G}^{2};\\,N_{T}\\left(\\theta_{G},\\,\\delta_{G}^{2}\\right)\\right)\\\\\n\\propto & \\frac{1}{\\gamma}\\exp\\left[-\\frac{\\left(\\sigma_{G}^{2}-\\mu_{G}\\right)}{\\gamma_{G}^{2}}\\right]\\times\\left(\\frac{1}{\\delta_{G}^{2}}\\right)^{\\frac{1}{2}}\\exp\\left[-\\frac{\\left(\\theta_{G}-\\sigma_{G}^{2}\\right)^{2}}{2\\delta_{G}^{2}}\\right]\\times\\frac{\\iota\\left(\\sigma_{G}^{2}>0\\right)}{1-\\Phi\\left(\\frac{-\\theta_{G}}{\\delta_{G}^{2}}\\right)}\\\\\n\\propto & \\exp\\left[-\\frac{\\left(\\sigma_{G}^{2}-\\mu_{G}\\right)}{\\gamma_{G}^{2}}\\right]\\exp\\left[-\\frac{\\left(\\theta_{G}-\\sigma_{G}^{2}\\right)^{2}}{2\\delta_{G}^{2}}\\right]\\times\\iota\\left(\\sigma_{G}^{2}>0\\right)\\\\\n\\\\\n\\propto & p\\left(\\sigma_{G}^{2},\\,N\\left(\\left[\\frac{\\mu_{G}}{\\gamma_{G}^{2}}+\\frac{\\theta_{G}}{\\delta_{G}^{2}}\\right]\\zeta_{G}^{2*},\\;\\zeta_{G}^{2*}\\right)\\iota\\left(\\sigma_{G}^{2}>0\\right)\\right)\\\\\ns.t.\\\\\n\\zeta_{G}^{2*}= & \\left[\\frac{1}{\\gamma_{G}^{2}}+\\frac{1}{\\delta_{G}^{2}}\\right]^{-1}\n\\end{align*}\n\\item Note the truncated part of the distribution is a constant, and does\nnot affect the marginal distribution beyond the indicator function,\nat least up to the constant of proportionality\n\\end{itemize}\n\\item Now for $Z$: \n\\begin{itemize}\n\\item First define:\n\\begin{align*}\n\\Sigma\\equiv & \\begin{bmatrix}\\left(S_{G}-\\sigma_{G}^{2}\\right)^{2} & \\left(S_{G}-\\sigma_{G}^{2}\\right)\\left(S_{GP}-\\sigma_{G}^{2}\\right)\\\\\n\\left(S_{G}-\\sigma_{G}^{2}\\right)\\left(S_{GP}-\\sigma_{G}^{2}\\right) & \\left(S_{GP}-\\sigma_{G}^{2}\\right)^{2}\n\\end{bmatrix}\n\\end{align*}\n\\item Then just plug into the standard formula for the posterior distribution\nof an Inverse Wishart distribution: \n\\begin{align*}\np\\left(\\zeta_{G}^{2}|S,\\,\\zeta_{P}^{2}\\,\\sigma_{G}^{2}\\right)\\propto & p\\left(S_{GP}|Z,\\,\\sigma_{G}^{2},\\,S_{G}\\right)p\\left(Z;\\;W^{-1}\\left(\\nu,\\,\\Psi\\right)\\right)\\\\\n\\propto & p\\left(\\nu+1,\\,\\Psi+\\Sigma\\right)\n\\end{align*}\n\\end{itemize}\n\\item For $S_{G}$: \n\\begin{itemize}\n\\item Start by deriving the distribution of a conditional normal distribution.\nUse the the bivariate normal's property of having a conditional distribution\nwhich is also normal (like a regression). Plugging in:\n\\begin{align*}\n\\mu_{SG}\\equiv & \\sigma_{G}^{2}+\\frac{\\zeta_{GP}}{\\zeta_{P}^{2}}\\left(SGP-\\sigma_{G}^{2}\\right)\\\\\n\\gamma_{SG}^{2}\\equiv & \\zeta_{G}^{2}-\\frac{\\zeta_{GP}^{2}}{\\zeta_{P}^{2}}\\\\\np\\left(S_{GP}|Z,\\,\\sigma_{G}^{2},\\,S_{G}\\right)\\propto & N\\left(\\mu_{SG},\\,\\gamma_{SG}^{2}\\right)\n\\end{align*}\n\\item Now convolute the conditional distribution with the prior to get the\nposterior (truncating the normal as before):\n\\begin{align*}\np\\left(S_{G}|Z,\\,\\sigma_{G}^{2},\\,S_{GP}\\right)\\propto & p\\left(S_{GP}|Z,\\,\\sigma_{G}^{2},\\,S\\right)p\\left(S_{G};\\,N\\left(\\theta_{SG},\\,\\delta_{SG}^{2}\\right)\\right)\\\\\n\\propto & \\left(\\frac{1}{\\gamma_{SG}^{2}}\\right)^{\\frac{1}{2}}\\exp\\left[-\\frac{\\left(S_{G}-\\mu_{SG}\\right)^{2}}{2\\gamma_{SG}^{2}}\\right]\\times\\left(\\frac{1}{\\delta_{SG}^{2}}\\right)^{\\frac{1}{2}}\\exp\\left[-\\frac{\\left(\\theta_{SG}-S_{G}\\right)^{2}}{2\\delta_{SG}^{2}}\\right]\\times\\frac{\\iota\\left(S_{SG}>0\\right)}{1-\\Phi\\left(\\frac{-\\theta_{SG}}{\\delta_{SG}^{2}}\\right)}\\\\\n\\propto & p\\left(\\sigma_{G}^{2},\\,N\\left(\\left[\\frac{\\sigma_{G}^{2}}{\\gamma_{SG}^{2}}+\\frac{\\theta_{SG}}{\\delta_{SG}^{2}}\\right]\\zeta_{SG}^{2*},\\;\\zeta_{SG}^{2*}\\right)\\iota\\left(S_{SG}>0\\right)\\right)\\\\\ns.t.\\\\\n\\zeta_{SG}^{2*}= & \\left[\\frac{1}{\\gamma_{SG}^{2}}+\\frac{1}{\\delta_{SG}^{2}}\\right]^{-1}\n\\end{align*}\n\\end{itemize}\n\\end{itemize}\n\n\\subsubsection*{Mapping draws to weights}\n\nDenote the three partitions of G as$G1$, $G2$, or $G3$, each of\nwhich has weight vector $\\Omega_{Gk}\\in\\mathbb{R}^{M}$ for $k\\in\\left\\{ 1,2,3\\right\\} $.\nNote that for each k, the weights for indices not in the partition\nare equal to 0. These definitions imply $w_{G}'\\equiv\\left\\{ \\left(\\Omega_{iG1}+\\Omega_{iG2}+\\Omega_{iG3}\\right)w_{iG}\\right\\} _{i\\in1:m}$.\nNext, denote the scaling vector$\\omega\\in\\mathbb{R}^{3}\\equiv\\left\\{ \\omega_{G1},\\,\\omega_{G2},\\,\\omega_{G3}\\right\\} $.\nNote that these parameters are fully specified by the following three\nrestrictions:\n\\begin{enumerate}\n\\item The sample variance of the new vector of weights is $S_{G}$. That\nis, $V\\left(R_{G}'\\right)=S_{G}$\n\\item The sample covariance of the new vector of weights with the test portfolio\nis $S_{GP}$, or $cov\\left(R_{G}',\\,R_{P}\\right)=S_{GP}$.\n\\item The weights of the new portfolio add to 1. This can be expressed as\n$\\left(\\Omega_{G1}+\\Omega_{G2}+\\Omega_{G3}\\right)\\cdot w_{G}=1$.\n\\end{enumerate}\nTo solve for the scaling parameters, make the following three definitions.\nNote that each of these quantities is known given the previous value\nof $w_{G}$.\n\\begin{align*}\nw_{s}= & \\left\\{ \\sum_{i\\in1:m}w_{iG}\\iota\\left(i\\in Gk\\right)\\right\\} _{k\\in1:3}\\text{ (3x1)}\\\\\nQ_{G}= & \\begin{bmatrix}S_{G1} & S_{G12} & S_{G13}\\\\\nS_{G12} & S_{G2} & S_{G23}\\\\\nS_{G13} & S_{G23} & S_{G3}\n\\end{bmatrix}\\text{ (3x3)}\\\\\nQ_{PG}= & \\begin{bmatrix}S_{PG1}\\\\\nS_{PG2}\\\\\nS_{PG3}\n\\end{bmatrix}\\text{ (3x1)}\n\\end{align*}\n\nHere, $S_{G1}\\in\\mathbb{R}_{+}$ is the sample variance of the G1\npartition, $S_{G13}\\in\\mathbb{R}$ is the sample covariance between\nthe G1 and G3 portfolios, $S_{PG1}$is the covariance between portfolio\nP and the G1 portfolio, and other variances and covariances are analogous.\n$w_{s}\\in\\mathbb{R}^{3}$ is the sum of the weights of the G1, G2,\nand G3 portfolio partitions.\n\nThen solve:\n\n\\begin{align*}\nS_{G} & =\\omega'Q_{G}\\omega\\\\\nS_{GP} & =\\omega'Q_{PG}\\\\\n1 & =\\omega'1\n\\end{align*}\n\nwhich correspond to the three restrictions. The algorithm does NOT\nobtain the solution by treating the above as a quadratic programming\nproblem. Instead, it uses precise analytical solutions. The specific\nalgebra is tedious and long, and the resulting equations impart little\nintuition. The solution is thus relegated to the code appendix and\nthe algebra to the Mathematica file ``Weights Algebra.''\n\n\\subsection*{Important References}\n\\begin{itemize}\n\\item Wikipedia\n\\begin{itemize}\n\\item Gamma distribution\n\\item Inverse gamma distribution\n\\item Wishart Distribution\n\\item Inverse Wishart Distribution\n\\item Estimation of Covariance Matrices\n\\end{itemize}\n\\item Other web sites\n\\begin{itemize}\n\\item Stack: https://math.stackexchange.com/questions/573694/bayesian-posterior-with-truncated-normal-prior\n\\end{itemize}\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "cb5c76cb33158f824303be340b5475ed7733f652", "size": 21331, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MinVariance2/theory/Some Initial Proofs v.08.tex", "max_stars_repo_name": "clintonTE/CCA", "max_stars_repo_head_hexsha": "a555cc1fa4b6d5f1464de44e2e322d32336d1e3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MinVariance2/theory/Some Initial Proofs v.08.tex", "max_issues_repo_name": "clintonTE/CCA", "max_issues_repo_head_hexsha": "a555cc1fa4b6d5f1464de44e2e322d32336d1e3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MinVariance2/theory/Some Initial Proofs v.08.tex", "max_forks_repo_name": "clintonTE/CCA", "max_forks_repo_head_hexsha": "a555cc1fa4b6d5f1464de44e2e322d32336d1e3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.6069767442, "max_line_length": 369, "alphanum_fraction": 0.6821058553, "num_tokens": 7808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.4189619732164417}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{url}\n\\usepackage[]{hyperref}\n\n\\usepackage{caption}\n\n\\usepackage{listings}\n\n\\usepackage{color}\n\n\\usepackage{pythonhighlight}\n\n% *** GRAPHICS RELATED PACKAGES ***\n%\\usepackage[pdftex]{graphicx}\n\\usepackage{graphicx}\n%\\usepackage[dvips]{graphicx}\n% to place figures on a fixed position\n\\usepackage{float}\n\n\\usepackage[margin=1in]{geometry}\n\n\\title{Hyperbolic Geometry of Complex Networks – Queuing Theory I. Home Assignment II.}\n\\author{Ferenc Nandor Janky - OA8AT9}\n\\date{}\n\n\n\\begin{document}\n\n\\maketitle\n\n\\tableofcontents\n\n\\section{Introduction}\n\nThe task was to study section I, II, III and IV A of~\\cite{HyperbolicGeoNetworks} and in any programming language/tool generate a network according to the model described in the paper \n(in Section IV.A.) with the following parameters: N=5000 (the number of nodes), R=14 (the radius of the disk on which the nodes are uniformly distributed). Then calculate numerically the empirical average degree, and plot on a log-log scale the empirical degree distribution of this generated network.\n\n\\section{Implementation}\nThe implementation of the graph generation and analysis has been done in Python language. The software is available on \\url{https://github.com/fecjanky/QT_home_assignment/blob/master/ha2/toki2.py}.\nThe graph generation has been implemented as described in ~\\cite{HyperbolicGeoNetworks}. The node density on the disc with radius \\emph{R} along the radial polar coordinates followed an exponential distribution $ \\rho~(r) \\simeq e^r $~.\nThe connection probability was analogous to the hyperbolic distance between nodes on the disc given by: $ p(x) = \\Theta(R - x) $\nFor the implementation the following Python libraries have been utilized:\n\\begin{itemize}\n\\item \\verb!matplotlib! , for creating the representation of the generated graph in polar coordinates and for plotting the degree distribution\n\\item \\verb!networkx! , for graph analysis\n\\end{itemize}\n\nThe  generator function of the points is show in listing~\\ref{lst:python}. There were some offset between the simulated and theoretical results (see Section~\\ref{sect:metrics}) and it could have been caused by a bias in the generation of random nodes.\n\n\\newpage\n\n\\begin{lstlisting}[style=mypython,caption={The function used for generating random nodes},label={lst:python}]\n    def lte(a, b):\n        return math.isclose(a, b) or a < b\n\t\n    # use rejection sampling to generate points with a given distribution\n    def generate_points(self, distribution=None):\n        points = []\n        if distribution is None:\n            distribution = lambda r: math.sinh(r) / (math.cosh(self.radius) - 1)\n\n        for i in range(0, self.nodecount):\n            azimuth = random.uniform(0, 2 * math.pi)\n            d_point = (random.uniform(0, self.radius), random.uniform(0, distribution(self.radius)))\n            while True:\n                d_accept = distribution(d_point[0])\n                if lte(d_point[1], d_accept):\n                    break\n                d_point = (random.uniform(0, self.radius), random.uniform(0, distribution(self.radius)))\n            points.append(PolarPoint(radius=d_point[0], azimuth=azimuth))\n        return points\n\\end{lstlisting}\n\n\\section{Results}\n\\subsection{Theoretical metrics}\nTo calculate the theoretical average degree the following equations were used from \\cite{HyperbolicGeoNetworks}:\n\n\\begin{equation}\nN = \\nu~e^{R/2} \\rightarrow \\nu \\simeq 4.559 ,if\\;R=14\\;and\\;N=5000\n\\end{equation}\n\\begin{equation}\nR = 2 \\ln[8 N / (\\pi \\overline{k})] \\rightarrow \\overline{k} \\simeq 11.61, if\\;R=14\\;and\\;N=5000\n\\end{equation}\n\n\\subsection{Empirical metrics}\\label{sect:metrics}\n\nThe polar plot of the generated network can be seen on Figure~\\ref{fig:graph}. The empirical average degree calculated for the generated graph was:\n\\begin{equation}\n\\overline{k}_{sim} =  11.8084\n\\end{equation}\n\nThe relative error between the average obtained from the generated one and the theoretical average was:\n\\begin{equation}\n\\epsilon = \\frac{\\vert \\overline{k} - \\overline{k}_{sim} \\vert}{\\overline{k} } * 100 \\% = 1.71 \\%\n\\end{equation}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/result_graph.png}\n    \\caption{The polar plot of the generated graph according to the rules in \\cite{HyperbolicGeoNetworks}}\n    \\label{fig:graph}\n\\end{figure}\n\n\nFigure~\\ref{fig:graph_stats} shows the empirical degree distribution of the generated network on a log-log scale. It resembles the expected Poissonian distribution.\n \n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/result_graph_stats.png}\n    \\caption{The plot on a log-log scale of the empirical degree distribution of the generated network}\n    \\label{fig:graph_stats}\n\\end{figure}\n\n\nThe average degree as a function of radius from the center on the disc is illustrated on Figure~\\ref{fig:graph_radius} alongside with the theoretical curve. The tangent of the empirical curve is similar however there was a constant offset between them that might have been cause by the bias in the random point generation.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{figures/result_graph_radial_stats.png}\n    \\caption{The plot of the average degree as a function of radial distance of the generated network}\n    \\label{fig:graph_radius}\n\\end{figure}\n\n\n\n\n\\section{Conclusion}\n\nAs a part of this homework a random network has been generated using  hyperbolic geometry based on \\cite{HyperbolicGeoNetworks} to study the\nstructure and function of complex network in purely geometric terms. The edge probability is analogous to the hyperbolic distance between two nodes and if that distance is below a threshold between \nany of two nodes an edge is present between them resulting in similar structure as it would have been created by specifying and edge probability for the random graph and generating edges between them based on that.\nThe simulation results were resembling the theoretical results and also the ones presented in \\cite{HyperbolicGeoNetworks} with around 2\\% relative error.\n\n\n\\bibliographystyle{unsrt}\n\\bibliography{references}\n\n\\end{document}", "meta": {"hexsha": "08ec17f32aa412089b581f2617cb4930744af991", "size": 6196, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ha2/doc/ha2.tex", "max_stars_repo_name": "fecjanky/QT_home_assignment", "max_stars_repo_head_hexsha": "cba71c2d3213b4af8f7dfe633eb83fcc0405ebd8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ha2/doc/ha2.tex", "max_issues_repo_name": "fecjanky/QT_home_assignment", "max_issues_repo_head_hexsha": "cba71c2d3213b4af8f7dfe633eb83fcc0405ebd8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ha2/doc/ha2.tex", "max_forks_repo_name": "fecjanky/QT_home_assignment", "max_forks_repo_head_hexsha": "cba71c2d3213b4af8f7dfe633eb83fcc0405ebd8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9432624113, "max_line_length": 322, "alphanum_fraction": 0.7525823112, "num_tokens": 1539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.546738151984614, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.41896197029837495}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n% \\marginpar{Thursday\\\\ 2019-11-28, \\\\ compiled \\\\ \\today}\n% \\section*{Thu Nov 28 2019}\n\n% We derived \n% %\n% \\begin{align}\n%   \\expval{T} = -\\frac{1}{3} \\frac{E _{\\text{grav}}}{V}\n% \\,,\n% \\end{align}\n% %\n% so now we proceed: we want a relation between kinetic and gravitational energy densities. \nNow, the question we want to as is: is this equilibrium configuration \\textbf{stable}? This is equivalent to asking whether the system is gravitationally bound, \\(E _{\\text{grav}} < 0\\), which as we have shown is equivalent to \\(\\expval{P}> 0\\).  \n\nIn order to answer this question we shall use a statistical-mechanics, microscopic approach. \n\nWe consider a cubic box of volume \\(V = L^3\\) with \\(N\\) particles inside it, each of which has a velocity \\(\\vec{v} = (v_x, v_y, v_z)^{\\top}\\) and a momentum \\(p\\). Let us select a face of the box, which we assume to be perpendicular to the \\(x\\) axis. Each particle will hit it with a frequency \\(t^{-1} = v_x / 2L\\), and each time it does so it imparts upon it a momentum \\(2 p_x\\), since it is reflected backwards.\n\nSumming over all the particles, the rate of momentum transfer (so, the force) in the direction \\(x\\) is given by \n%\n\\begin{align}\n  \\frac{N}{2L} \\expval{2p_x v_x}\n\\,,\n\\end{align}\n%\nso the pressure upon that face will be the force divided by the area of the face\n%\n\\begin{align}\nP_x = \\frac{N}{L} \\expval{p_x v_x} \\frac{1}{L^2} = \\underbrace{\\frac{N}{V}}_{= n} \\expval{p_x v_x}\n\\,.\n\\end{align}\n\nThis will be the same for each direction by isotropicity: \\(P_x = P_y = P_z\\), and by the same argument we can write \\(\\expval{p_x v_x} = \\expval{\\vec{p} \\cdot \\vec{v}} / 3\\): so \n%\n\\begin{align}\n  P = \\frac{n}{3} \\expval{\\vec{p} \\cdot \\vec{v}}\n\\,,\n\\end{align}\n%\n% in full generality. \nwhich, although we will not show it, generalizes to a configuration of any shape, and does not change if we consider quantum-mechanical or relativistic effects.\nThis is a simple expression for the \\textbf{equipartition theorem}, a crucial result in Hamiltonian mechanics. \n\nLet us consider two limits: nonrelativistic and fully relativistic particles.\n\n\\paragraph{Nonrelativistic particles}\n\n% In the nonrelativistic case we have \n% In this case the energy of a particle with momentum \\(p \\approx mv\\) can be expressed as \n% %\n% \\begin{align}\n%   \\epsilon_{p} = mc^2 + \\frac{p^2}{2m}\n% \\,,\n% \\end{align}\n% %\n% where \\(p = mv\\).\nIn this case, since \\(\\gamma \\approx 1\\) the four-momentum of the particles is approximately \n%\n\\begin{align}\np^{\\mu } = \\left[\\begin{array}{c}\n\\gamma mc^2 \\\\ \n\\gamma m \\vec{v}\n\\end{array}\\right]\n\\approx \\left[\\begin{array}{c}\nmc^2 \\\\ \nm \\vec{v}\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nso \\(\\vec{p} = m \\vec{v}\\), which means \\(\\expval{\\vec{p} \\cdot \\vec{v}}  = \\expval{ m v^2}\\). \n\n% In the ultrarelativistic case we have \n% %\n% \\begin{align}\n%   \\epsilon_{p} = pc\n% \\,,\n% \\end{align}\n% %\n% and the velocity is approximately the speed of light. \n\nThen, for a gas of nonrelativistic particles we can write the pressure as \n%\n\\begin{align}\n  P = \\frac{n}{3} \\expval{ m v^2} = \\frac{2}{3} \\rho_{E_K}\n\\,,\n\\end{align}\n%\nwhere \\(\\rho_{E_K} = n m \\expval{ v^2 /2}\\) is the density of translational kinetic energy.\n\nCombining this result with the fact that, as we have seen before, \\(\\expval{P}=- \\rho _{\\text{grav}} / 3\\), we find \n%\n\\begin{align}\n  - \\frac{1}{3} \\rho _{\\text{grav}} = \\frac{2}{3} \\rho_{E_K} \\implies\n  2 E _{\\text{K}} + E _{\\text{grav}} = 0\n\\,,\n\\end{align}\n%\n% in the nonrelativistic approximation. \nwhich is an alternate statement of the \\textbf{nonrelativistic} case of the \\textbf{virial theorem}. \n\nThe total energy is then given by \\(E _{\\text{tot}} = E_k + E _{\\text{grav}} = - E_k\\): this means that in general the system will be \\textbf{bound} --- the kinetic energy is quadratic, so always positive --- and that the hotter it is, the more bound it is.\n\n% We define: \\(\\Delta E _{\\text{tot}} = - \\Delta E _{\\text{K}} = \\frac{1}{2} \\Delta E _{\\text{grav}}\\). \n\n% We know that \n% %\n% \\begin{align}\n%   \\expval{P} = \\frac{1}{3} \\frac{E _{\\text{K}}}{V} = -\\frac{1}{3} \\frac{E _{\\text{grav}}}{V}\n% \\,\n% \\end{align}\n% %\n% by the virial theorem: so the total binding energy is equal to zero, since this gives us \n% %\n% \\begin{align}\n%   E _{\\text{grav}} + E _{\\text{K}} = E _{\\text{tot}} = 0\n% \\,.\n% \\end{align}\n% %\n\n\\paragraph{Relativistic case}\n\nIn this case \\(v \\approx c\\), so \\(\\expval{p \\cdot \\vec{v}} \\approx pc = \\gamma m c\\). We can apply the reasoning from before, but the density of translational kinetic energy is given by \n%\n\\begin{align}\n\\rho_{E_K} = n (E - mc^2) = n (\\gamma -1) mc^2 \\approx n\\gamma mc^2 = npc \n\\,,\n\\end{align}\n%\nso we have \n%\n\\begin{align}\nP = \\frac{n}{3} \\expval{\\vec{p} \\cdot \\vec{v}} = \\frac{\\rho _{E_k}}{3}\n\\,.\n\\end{align}\n\nThen, we can apply the same reasoning as the nonrelativistic case, with the difference of the missing factor 2: we then get \n%\n\\begin{align}\n\\rho_{E_k} + \\rho_{\\text{grav}} = 0 \\implies\nE _{\\text{grav}} + E_k = E _{\\text{tot}} = 0\n\\,,\n\\end{align}\n%\nso the system is \\textbf{unbound}, it does not have any constraint preventing it from dissociating. \n\n% while in the relativistic case we have: \n% %\n% \\begin{align}\n%   P = \\frac{1}{2} n \\expval{pc} = \\frac{1}{3} \\times \\text{translational KE density}\n% \\,.\n% \\end{align}\n\n% We will show that, if a star is made of a gas of classical nonrelativistic particles it tends to be stable, if the particles are relativistic then it tends not to be stable.\n\n% The virial theorem tells us that \n\n\\paragraph{Adiabatic gas}\n\nWe have seen the limiting cases, now let us consider a slightly more general one: a gas undergoing an adiabatic transformation, such that \\(P V^{\\gamma }\\) (with some real number \\(\\gamma \\)) is constant.\\footnote{A more realistic model would allow \\(\\gamma \\) to vary, which it definitely does in the stages of stellar formation and evolution and even across a single transformation. We will not, however, get that deep in the weeds.}\nWe will show that this is equivalent to the equations of state considered in cosmology, where \\(P = w \\rho \\). \nThis will allow us to characterize the gravitational stability of the to-be star depending on the equation of state of the gas. \n\nWe start by differentiating: \\(\\dd \\qty(P V^{\\gamma }) = 0\\), which means that we also have \\(\\dd{ (\\log (P V^{\\gamma }))} = 0\\), which we can expand into\n%\n\\begin{align}\n  \\dd{\\log (V^{\\gamma })} + \\dd{\\log (P)} = \n  \\gamma \\frac{ \\dd{V}}{V} + \\frac{ \\dd{P}}{P} = 0\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{align}\n  - (\\gamma -1 ) P \\dd{V}\n  = P \\dd{V} + V \\dd{P} =\n  \\dd{(PV)} \n\\,.\n\\end{align}\n%\n% and we know that for an adiabatic transformation \n\n% Isentropicity of the trasformation means\nIn an adiabatic transformation the entropy must not change: so, we can write\n%\n\\begin{align}\n  T \\dd{S} = \n  \\dd{E _{\\text{in}}} + P \\dd{V} = 0\n\\,,\n\\end{align}\n%\nwhich we can then write using the relation we derived previously:\n%\n\\begin{align}\n  \\dd{E _{\\text{in}}} &= \\frac{1}{\\gamma -1} \\dd{(PV)} \\\\\n  E _{\\text{in}} &= \\frac{PV}{\\gamma -1}  \\\\\n  P &= (\\gamma - 1) \\frac{E _{\\text{in}}}{V} = (\\gamma - 1) \\rho _{\\text{in}}\n\\,.\n\\end{align}\n%\n% and let us assume that \\(\\gamma \\) is approximately constant in the transformation: this means \n\nWe can then see that if we impose that the transformation be adiabatic, we find the equation of state \\(P  =w \\rho \\), with \\(\\gamma -1 = w\\). \n\n% %\n% \\begin{align}\n%   E _{\\text{in}} = \\frac{PV}{\\gamma -1}\n% \\,,\n% \\end{align}\n% %\n% so \n% %\n% \\begin{align}\n%   P = (\\gamma -1 ) \\frac{E _{\\text{in}}}{V}\n% \\,,\n% \\end{align}\n% %\n% which justifies the relations we used in cosmology, \\(P = w \\rho \\) with \\(w = \\gamma -1\\). \n\n% We can rewrite the equation from before as \nUsing the fact that, as we have shown before, \\(P = - \\rho _{\\text{grav}} / 3\\), this means \n%\n\\begin{align}\n- \\frac{\\rho _{\\text{grav}}}{3} = (\\gamma - 1) \\rho _{\\text{in}} \\implies\n  3(\\gamma -1 ) E _{\\text{in}} + E _{\\text{gr}} = 0\n\\,,\n\\end{align}\n%\nwhich, together with the fact that the total energy of the star after the collapse is the initial energy plus the (negative) gravitational binding energy: \\(E _{\\text{tot}} = E _{\\text{in}} + E _{\\text{gr}}\\), so \n%\n\\begin{align}\n  E _{\\text{tot}} = - (3 \\gamma - 4) E _{\\text{in}}\n\\,,\n\\end{align}\n%\nwhich means that \\(\\gamma > 4/3\\) characterizes a bound system, while \\(\\gamma < 4/3\\) characterizes a free system. \nThis is consistent with what we have seen before: the limiting case \\(\\gamma = 4/3\\) is equivalent to \\(w = 1/3\\), the equation of state of radiation (or ultrarelativistic matter), which as we have already seen is unbound.\n% \\(\\gamma  = 1\\) is equivalent to nonrelativistic matter with \\(w = 0\\), meaning no pressure at all: this matter will then collapse and \n\nFrom classical thermodynamics we know that, for instance, a monoatomic gas has \\(\\gamma = 5 /3\\).\n\n% There are two dangers: one is the fight against the pressure forces, one is the fight against the quantum forces (the Pauli exclusion principle) which do not allow the compression to happen further. \n\n\\section{Jeans instability}\n\n% \nLet us now try to understand the conditions under which a cloud of gas may become unstable and collapse onto itself to form a star (or a planet, for that matter). \n% Now we discuss Jeans instability: \n\nIn general, the gravitational potential energy of a body whose characteristic size is \\(R\\) and whose mass is \\(M\\) is given by\n%\n\\begin{align}\n  E _{\\text{grav}} \n  = - \\int_{x, y \\in V} \\dd[3]{x} \\dd[3]{y} \\rho (x) \\rho (y) \\frac{G}{\\abs{x - y}}  \n  = - f \\frac{GM^2}{R}\n\\,,\n\\end{align}\n%\nwhere \\(f\\) is a numerical factor depending on the mass distribution. \nIf the object at hand is uniform-density sphere, we have \\(f = 3/5\\).\nIn general, the factor is of order 1. \n\nThe kinetic component of the energy, on the other hand, is \n%\n\\begin{align}\n  E _{\\text{K}} = \\frac{3}{2} N k_B T\n\\,.\n\\end{align}\n\n% We can then see that the gravitational energy scales with \\(R^{-1}\\); \n\nThe gravitational cloud is unstable the gravitational energy is larger than the kinetic energy:\n\\todo[inline]{Why should this be? The way \\textcite[]{keetonStarPlanetFormation2014} discusses it makes more sense to me: he studies the response of the total energy to a decrease in radius, and checks that it is positive; if might be the same as what we are doing here but that's not really obvious.}\n%\n\\begin{align}\n  f \\frac{GM^2}{R} > \\frac{3}{2} N k_B T \n\\,,\n\\end{align}\n%\nand the Jeans mass, \\(M_J\\), corresponds to the boundary of the stability region: the number of particles, \\(N\\), depends on it as \\(N = M_J / \\overline{m}\\), where \\(\\overline{m}\\) is the average particle mass.\n\nThe criterion then reads:\n%\n\\begin{align}\n  f \\frac{gM_J^2}{R} &= \\frac{3}{2} \\frac{M_J}{\\bar{m}} k_B T \\\\\n  M_J &= \\frac{3}{2} \\frac{k_B T }{G \\bar{m}} R\n\\,,\n\\end{align}\n%\nwhere we set \\(f =1\\), since we are only interested in an order-of-magnitude calculation.\n% where \\(\\bar{m} = M / N\\). \n% The \\(J\\) denotes the fact that we are considering the specific boundary mass on both sides. Simplifying the formula we find: \n%\n% and we can reframe this in terms of the density, which is defined by \n\nAs usual, we want to reframe our result in terms of densities: the Jeans mass corresponds to a Jeans density times the volume of the sphere:\n%\n\\begin{align}\n  M_J = \\frac{4 \\pi }{3} \\rho _J R^3\n\\,.\n\\end{align}\n\nIn order to find out what this density is we start off by cubing the  \nexpression for the Jeans mass, and then substituting the expression for \\(M_J\\) in terms of \\(\\rho _J\\):\n% and multiply on both sides: \n%\n\\begin{align}\nM_J^3 &= \\qty(\\frac{3 k_B T}{2 G \\bar{m}})^3 R^3\\\\\n&=  \\qty(\\frac{3 k_B T}{2 G \\bar{m}})^3 \\frac{3M_J}{4 \\pi \\rho _J} \\\\  \n  \\rho _J &= \\frac{3}{4 \\pi M_J^2} \\qty(\\frac{3 k_B T}{2 G \\bar{m}})^3\n  \\label{eq:jeans-critical-density-by-mass}\n\\,.\n\\end{align}\n\nAlternatively, we can write \n%\n\\begin{align}\n\\frac{4 \\pi }{3} \\rho _J R^3 &= \\frac{3}{2} \\frac{k_B T}{G \\overline{m}} R \\\\\n\\rho _J &= \\frac{9}{8 \\pi } \\frac{1}{R^2} \\frac{k_B T}{G \\overline{m}}\n\\,. \\label{eq:jeans-density}\n\\end{align}\n%\n\n\nWe will have an instability if the density is larger than this.\nAs we have seen in the previous section, a lower temperature facilitates the collapse. \nIt should be stressed that the precise numerical coefficient will depend on the geometry of the cloud of material, this is not a hard rule but more of a guide for the understanding of the behavior of clouds.\n% So, if we want a collapse, we must decrease the mass\\dots\n\n% When the last scattering happens, the pions are decoupled from the photons. Dark matter behaves differently from conventional matter. \n\n\\todo[inline]{Here appears in the lecture the argument for the fact that the temperature of matter decreases as \\(T \\sim a^{-2}\\); it does not really seem to fit with the rest of the chapter, perhaps it should go earlier?\n\nI'll leave it here, commented out.}\n\n% We have \n% %\n% \\begin{align}\n%   \\dot{\\rho}_r = - 3H \\qty(\\rho _r + P_r)\n% \\,,\n% \\end{align}\n% %\n% and \n% %\n% \\begin{align}\n%   \\dot{\\rho}_m = -3H \\qty(\\rho _m + P_m )\n% \\,,\n% \\end{align}\n% %\n% and \\(P_r = \\rho_r / 3\\), which scale like \\(a^{-4} \\) and also as \\(T^{4}\\), which means \\(T \\sim 1/a\\).  \n% %\n% \\begin{align}\n%   \\dd \\qty(\\rho _m c^2 a^3) + P_m d a^3 = 0\n% \\,,\n% \\end{align}\n% %\n% where we usually approximate \\(\\rho _m c^2 = m_p n_b c^2\\), but we can include more terms: \n% %\n% \\begin{align}\n%   \\rho _m c^2 = m_p n_b c^2 \\qty(1 + (\\gamma -1 )^{-1} \\frac{k_B T}{m_p c^2})\n% \\,,\n% \\end{align}\n% %\n% while the pressure is given by \\(P = n_b k_B T\\): so in the end we find \n% %\n% \\begin{align}\n%   \\dd \\qty(\\qty(m_p n_b c^2 + \\frac{3}{2} m_p n_b \\frac{k_BT}{m_p})a^3) = - n_b k_B T \\dd{a^3}\n% \\,,\n% \\end{align}\n% %\n% which after some computation gives us \n% %\n% \\begin{align}\n%   \\frac{1}{2} \\dd{T } = - T \\frac{ \\dd{a}}{a}\n% \\,,\n% \\end{align}\n% %\n% which implies \\(T_m \\propto a^{-2}\\) after baryogenesis. \n\n% \\todo[inline]{This is for monoatomic baryonic matter, right?}\n\n\\subsubsection{Equations for stellar structure}\n\nIn order to properly study the dynamics of the stellar collapse, however, we need to analyze the differential equations which govern it. \nWe will start out by doing so on a static background, following the original reasoning by Jeans (who, working in the early 1900s, did not know about the expansion of the universe). Then, we will discuss the effects of the universe's expansion on the gravitational instability. \n% Let us start writing equations for the stellar interior.\n\nThe \\textbf{continuity equation}, imposed by mass conservation, is\n%\n\\begin{align}\n  \\partial_{t} \\rho + \\nabla \\cdot \\qty(\\rho \\vec{v}) = 0\n\\,,\n\\end{align}\n%\nwhere \\(\\rho \\) is the matter density while \\(\\vec{v}\\) is the velocity field; the \\textbf{Euler equation}, imposed by momentum conservation (assuming no viscosity), is \n%\n\\begin{align}\n  \\partial_{t} \\vec{v} + \\qty(\\vec{v} \\cdot \\vec{\\nabla}) \\vec{v}\n  = - \\frac{1}{\\rho } \\vec{\\nabla} P - \\vec{\\nabla} \\Phi \n\\,,\n\\end{align}\n%\nwhere \\(P\\) is the pressure while \\(\\Phi \\) is the gravitational potential.\n\nIf we define the \\textbf{convective} time \\textbf{derivative},  \n%\n\\begin{align}\n  \\frac{ \\mathrm{D} }{\\mathrm{D}t} = \\partial_{t} + \\vec{v} \\cdot \\nabla_{x} \\approx u^{\\mu } \\partial_{\\mu }\n\\,,\n\\end{align}\n%\nwe can write the two equations as \n%\n\\begin{align}\n  \\frac{ \\mathrm{D} }{\\mathrm{D}t} \\rho + \\rho \\nabla \\cdot \\vec{v} &= 0 \\\\\n  \\frac{ \\mathrm{D} }{\\mathrm{D}t} \\vec{v} \n  &= - \\frac{\\nabla P}{\\rho } - \\nabla \\Phi \n\\,.\n\\end{align}\n\nLastly, the gravitational field \\(\\Phi \\) must obey Poisson's equation:\n%\n\\begin{align}\n  \\nabla^2 \\Phi = 4 \\pi G \\rho \n\\,.\n\\end{align}\n\nRight now we have five equations (Euler is a vector equation, corresponding to three scalar ones) and six variables: \\(\\rho \\), \\(\\Phi \\), \\(P\\) and the three components of \\(\\vec{v}\\). \nIn order to be able to solve this system we need one more condition; typically this is provided as an equation of state, giving \\(P\\) in terms of the other variables. \n\nOne way to go about this is to consider entropy: we define the entropy density \\(s \\) by the relation \\(S  = s \\rho \\), where \\(S\\) is the (total?) entropy. \n\nWe will consider isentropic processes, in which \n%\n\\begin{align}\n  \\frac{ \\mathrm{D} s}{\\mathrm{D}t} + s \\vec{\\nabla} \\cdot \\vec{v} = 0\n  % \\partial_{t} s + \\vec{v} \\cdot \\vec{\\nabla} s = 0\n\\,.\n\\end{align}\n\nWe introduce this, an additional eqution as well as an additional variable, in order to complete our equations with an equation of state in the form: \n%\n\\begin{align}\nP = P(\\rho , s)\n\\,.\n\\end{align}\n\nNow, then, we are left with seven equations and seven variables: let us solve them!\nThis is in general very hard, no analytic solutions exist.\n\n% Jeans looked for a simple solution, an ansatz, called the background solution and then tried to perturb it: if it is stable than it was a good solution. \nJeans' approach, which we will follow, is to find a fixed background solution and then to perturb it. \nWe are then looking to see whether the perturbation is dampened or amplified. Perturbations are always present, so this will tell us whether the configuration is stable or unstable.\n\n\\subsubsection{Static ansatz}\n\nJeans' first ansatz was \\(\\rho = \\rho_0 = \\const\\), \\(\\vec{v} = 0\\), \\(s = s_0 =  \\const\\), \\(\\Phi = \\Phi_0 = \\const\\), \\(P =P_0 = \\const\\). \n\n% It is obviously wrong! It cannot satisfy the Poisson equation. \nThis is a \\emph{very} simplified model, and it is not even self-consistent: unless \\(\\rho  = 0\\), Poisson's equation cannot be satisfied, but we want to have matter in our proto-star.\nWe will ignore this problem, since despite it we get a physically meaningful result.\nThe equation cannot precisely hold, but in low-density regions it is not that far from equality.\n\n% However, we start from it and add some \\(\\delta \\rho \\), \\(\\delta \\vec{v}\\) (which we just call \\(\\vec{v}\\)), \\(\\delta s\\) and \\(\\delta \\Phi \\); then we only keep the linear terms in these perturbations. \nWe perturb the variables: for each variable we will have \\(x = x_0 + \\delta x\\) (except \\(\\vec{v}\\): since there is no \\(\\vec{v}_0 \\), we just write \\(\\vec{v}\\) instead of \\(\\delta \\vec{v}\\)). \n\nWith this, the equations read:\n%\n\\begin{align}\n  \\partial_{t} \\delta \\rho  +\n  \\rho_0 \\vec{\\nabla} \\cdot \\vec{v} &= 0 \\\\\n  \\partial_{t} \\vec{v} &= - \\frac{1}{\\rho_0 } \\vec{\\nabla} \\delta P - \\vec{\\nabla} \\delta \\Phi \\\\\n  \\nabla^2 \\delta \\Phi &= 4 \\pi G \\delta \\rho  \\\\\n  \\partial_{t} \\delta s &= 0\n\\,.\n\\end{align}\n\n% We can expand\nThe pressure perturbation can be expressed in terms of the density and entropy ones:\n%\n\\begin{align}\n  \\delta P = \\underbrace{\\eval{\\pdv{P}{\\rho }}_{s}}_{= c_s^2} \\delta \\rho + \\pdv{P}{s} \\delta s\n\\,,\n\\end{align}\n%\nwhere we recognize the constant-entropy derivative of the pressure with respect to the density: the square of the adiabatic speed of sound.\n\n% In our study of these equations we will only consider first-order terms in the perturbations. \n\n% We will then consider an exponential solution: \n% %\n% \\begin{align}\n%   \\delta \\rho = \\delta \\rho_0 \\exp(i \\qty(\\vec{k} \\cdot \\vec{x} - \\omega r))\n% \\,,\n% \\end{align}\n% %\n% and similarly for \\(\\vec{v}\\), \\(s\\), \\(\\Phi \\). \n\n% We will see that we will need to stick to \\(\\delta s =0\\), and find a dispersion relation with \\(\\omega \\) and \\(\\vec{k}\\): it will be \n% %\n% \\begin{align}\n%   \\omega^2 = c_s^2 \\vec{k}^2 - 4 \\pi G \\rho \n% \\,,\n% \\end{align}\n% %\n% so if the wavenumber is small enough we will have an imaginary \\(\\omega \\). \n\n\\end{document}\n", "meta": {"hexsha": "6e6fbc0d94e8c1d687cdca934e8469b3f01e90de", "size": 19512, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/astrophysics_cosmology/28nov.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/astrophysics_cosmology/28nov.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/astrophysics_cosmology/28nov.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 38.1839530333, "max_line_length": 435, "alphanum_fraction": 0.6643603936, "num_tokens": 6348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.7772998611746911, "lm_q1q2_score": 0.4189515826160247}}
{"text": "\\documentclass{standalone}\n\\begin{document}\n\t\\subsection{Kernel Size}\n\n\n\tDuring the building of the multi-channel image, I had to compute different image features, that requires the setting of different parameters, like median or standard filter kernel sizes. To achieve the best segmentation, I have performed an optimization step that aims to find the parameters that allow obtaining the best segmentation. \n\n\tNotice that this process is not necessary and a good segmentation can be achieved also by setting these parameters manually.\n\n\tIn order to perform the optimization, I have used \\textsc{scikit-optimize}~\\cite{skopt}, more specifically the \\textsc{gc\\_minimize method}.\n\n\tThis method seeks to perform a Bayesian optimization by using a Gaussian process to approximate an objective function. The function values are assumed to follow a multivariate Gaussian. The covariance of the function values is given by a GP kernel between the parameters. Then a smart choice to choose the next parameter to evaluate can be made by the acquisition function over the Gaussian prior which is much quicker to evaluate~\\cite{skopt}.\n\n\tIn the end, an objective function is minimized. I have used the objective function defined in\\,\\ref{alg:optimize} in which is also reported the whole minimization pseudocode. The used function aim to minimize $1 - IoU$ where the IoU(Intersection over Union) is computed between the output labels and a reference one:\n\t\\begin{equation*}\n\t\t\tIoU = \\frac{Area\\,of\\,Overlap}{Area\\,of\\,Union}\n\t\t\t\\label{eq:IoU}\n\t\\end{equation*}\n\t\t\n\t\n\tI have decided to use the IoU instead of accuracy since the number of pixels concerning the labelled object is very few against the number of pixels related to the background. Thus, the label would be a matrix with a large number of zeros (background) and only a few ones (object). In this case, the standard metric functions have to consider an unbalanced number of samples so the solution was to use the IoU which measures the ratio between the Intersection and Union of the output labels and the binary ground truth~\\cite{PhDtheis}:\n\n\n\t\n\t\\begin{algorithm}[h!]\n\t\n\t\t\\SetAlgoLined\n\t\t\\DontPrintSemicolon\n\t\t\\SetKwRepeat{Do}{do}{while}%\n\t\t\\KwData{Test scans, Ground Truth}\n\t\t\n\t\t\\SetKwFunction{Obj}{objective}\n\t\t\\SetKwProg{Fn}{Function}{:}{}\n\t\t\n\t\t\t\n\t\t\\Fn{\\Obj{$parameters, ref\\_labels, CT\\_scan$}}{{\n\t\t\t\t\n\t\t\t\t$labels$ $\\leftarrow$ segment($CT\\_scan$)\\;\n\t\t\t\tiou = IoU($labels$, $ref\\_labels$)\\;\n\t\t\t}\n\t\t\t\\textbf{return} $ 1 - iou $ \\;\n\t\t}\n\t\t\n\t\t\n\t\t$best\\_parameters\\leftarrow$gc\\_minimize(objective, n\\_calls, n\\_random\\_init)\\;\n\t\t\n\t\t\t\\caption{Parameter Optimization Algorithm}\\label{alg:optimize}\n\t\\end{algorithm}\n\t\t\n\tThis process allows optimizing the parameters to obtain better results. As reference labels, I have used the ones evaluated as gold standard from five experts radiologists at least $2$ years of experience.\n\n\tThis procedure allows only to tune the parameters for better segmentation, but the learning process remains unsupervised.\n\n\\end{document}", "meta": {"hexsha": "0d7316053aaa6055f4e19b7b29f5d57bdab56daa", "size": 3014, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Chapter2/Optimization/Parameters.tex", "max_stars_repo_name": "RiccardoBiondi/SCDthesis", "max_stars_repo_head_hexsha": "2506df1995e5ba239b28d2ca0b908ba55f81761b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/Chapter2/Optimization/Parameters.tex", "max_issues_repo_name": "RiccardoBiondi/SCDthesis", "max_issues_repo_head_hexsha": "2506df1995e5ba239b28d2ca0b908ba55f81761b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Chapter2/Optimization/Parameters.tex", "max_forks_repo_name": "RiccardoBiondi/SCDthesis", "max_forks_repo_head_hexsha": "2506df1995e5ba239b28d2ca0b908ba55f81761b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.8148148148, "max_line_length": 536, "alphanum_fraction": 0.7664233577, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.607663184043154, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.41886564587467434}}
{"text": "\\section{Conclusion and Discussion}\n\n\nIn this lab, we have studied the harmonic oscillation \nand the relations between $T$, $M$, $k$ and $v_{\\max}$. \nNow we analyze the results.\n\n\n\\subsection{Spring Constant}\n\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{|c|c|}\nspring 1 & 2.3311 $\\pm$ 0.013[N/m] \\\\ \\hline\nspring 2 & 2.3206 $\\pm$ 0.0105[N/m] \\\\ \\hline\nspring series & 1.165 $\\pm$ 0.0380[N/m]  \\\\ \\hline\n\\end{tabular}\n\\caption{The spring constant}\n\\end{table}\n\n\nFor the relative uncertainty are all very small,\nthe experiment in this part is very accurate.\n\nBy theory, we can calculate $k_3$, i.e. the $k$ of the spring serial by \n$$ k_{3,theory} = \\frac{k_1 \\cdot k_2 }{k_1 + k_2} =  1.1629 $$ \n\nCompared with $k_3 = 1.1649$  from the experiment,\n$$ u_{k_{3,theory},k_3} = \\frac{1.1649 - 1.1629}{1.1629} \\cdot 100 \\%  = 0.17 \\% $$ \nThe theory data is close to the experiment data.\n\nThe accurate experimental results prove that Hooke’s Law.\n\n\n\n\\subsection{Relation between the period $T$ and the mass $M$}\n\nFrom curve fitting, we find that $T^2$  is linearly dependent with $M$\nThe slope is shown below:\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{|c|c|}\nhorizontal  &  8.3233 $\\pm$  0.2235 [s2/kg] \\\\ \\hline\nincline 1   &  8.4380 $\\pm$  0.0500 [s2/kg] \\\\ \\hline\nincline 2   &  8.3467 $\\pm$  0.2185 [s2/kg] \\\\ \\hline\n\\end{tabular}\n\\caption{Slope}\n\\end{table}\n\nWe find the slopes of three cases are very close to each other, \nso the ratio between $T^2$ and $M$  are independent of the incline degree of the air track.\nWe see all the relative errors are very small,\nthus the result in this part is very accurate.\n\n\\subsection{The relation between $T$ and  $A$}\n\nFrom the failed fitting curve, we find there is no clear linear relation between $T$ and $A$.\nThus, we can conclude that $T$ is independent of $A$.\n\n\n\\subsection{Relation between $ v_{\\max}$ and $A$}\n\nFrom the fitting curve we find that  $v_{\\max}^2$ and $A^2$ is linearly dependent.\nAnd \n$$ k =   23.6964 \\pm 0.3300  $$\n$$ u_{k,r} = 1.39 \\% $$\n\nThe relative uncertainty of the experimental ratio is $1.39\\%$, \nwhich is moderate. \nThus the result is quite precise.\nStill, $v_{\\max}^2$ is more easily affected by the friction force, so the relative uncertainty is quite large. \n", "meta": {"hexsha": "ed0c0834d2869789efbf87318e3a980c721c8c0b", "size": 2238, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "E3/part/7cd.tex", "max_stars_repo_name": "iamwrm/VP141", "max_stars_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-24T11:28:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T11:28:04.000Z", "max_issues_repo_path": "E3/part/7cd.tex", "max_issues_repo_name": "iamwrm/VP141", "max_issues_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "E3/part/7cd.tex", "max_forks_repo_name": "iamwrm/VP141", "max_forks_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2432432432, "max_line_length": 111, "alphanum_fraction": 0.6863270777, "num_tokens": 756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.4188198519633029}}
{"text": "% !TeX root = ../thuthesis-example.tex\n\n% Input your chapter title here\n\\chapter{ADVERSARIAL ATTACKS ON IMAGES}\n\\label{sec:ima}\n\nSince the policy attacks included in this thesis work by perturbing the image observations given in input to the victim policies, this chapter reviews some of the most common image attacks, their threat model and introduces some common defense methods to counter them.\n\n\\section{Adversarial attacks on images}\nSince the advent of deep convolutional networks used for image classification \\cite{NIPS2012_4824}, the computer vision field has been subjected to many important breakthroughs with the aim to further improve the classification accuracy obtained on many images classification tasks \\cite{he2015deep} \\cite{zhang2020resnest}. However, despite their high accuracy, those models lack robustness since they can be easily deceived by adversarial examples \\cite{goodfellow2014explaining}. More formally, an adversarial example is a \\textit{sample input data that has been modified very slightly in a way that is intended to cause a machine learning classifier to misclassify it} \\cite{kurakin2016adversarial}. In fact, to be effective, an adversarial example should be misclassified by deep learning models, but not by the human brain. Therefore, only small changes can be made to the original input image \\textit{x} (legitimate example) to craft the adversarial example \\(x_{adv}\\)=\\textit{x}+\\(\\delta\\), where \\(\\delta\\) is also known as adversarial noise. The distance introduced by the noise between \\textit{x} and \\(x_{adv}\\) is usually defined by the \\(l_{p}\\) norm of the difference between the original and the adversarial sample for some p=0,..,\\(\\infty\\). Hence, an adversarial example \\(x_{adv}\\) has to satisfy the constraint \\(||x_{adv}-x||_p\\leq \\epsilon\\) (adversarial constraint), where smaller \\(\\epsilon\\) values correspond to smaller input perturbations, thus leading to less perceptible changes under the condition that \\(x_{adv}\\) is misclassified. Moreover, images adversarial attacks can be designed to achieve two different goals:\n\\begin{itemize}\n    \\item \\textbf{Untargeted}: Untargeted attacks aim at making the model predict any class different from the correct one without targeting at any desired class. Formally speaking, given a classifier \\textit{f} and the true label \\textit{y}, an adversarial example would cause \\(f(x_{adv})\\neq y\\). Hence, untargeted attacks' goal consists of maximizing the loss of the attacked model respect to the true label \\(y\\), namely, \\(\\max \\: L(x_{adv}, y)\\), under the assumption \\(||x_{adv}-x||_p\\leq \\epsilon\\). Given the relaxed constraints the adversarial examples are subjected to, these kinds of attacks are usually easier to perform.\n    \\item \\textbf{Targeted}: Conversely, targeted attacks try to mislead the model's prediction toward a specific class \\textit{y'}, that is, \\(f(x_{adv})=y'\\), where \\(y'\\neq y\\). The loss function can then be formulated as \\(\\min L(x_{adv}, y')\\) always under adversarial constraints. In this way, given the input \\(x_{adv}\\), it will be more likely that the attacked model would predict the target class \\(y'\\) rather than any other class. More sophisticated policy attacks usually require crafting adversarial observation in a targeted way so to force the victim agent to perform some required actions.\n\\end{itemize}\nFor example, if we want an agent simply to have its performance degraded, attacking under untargeted settings would be enough since preventing it to take the best action would naturally lower its total earned reward. However, if our goal is to control the agent by making it choose some predefined actions such as to lead it to a particular state, then adversarial attacks should be performed under targeted settings. Finally, adversarial attacks are also divided into two main categories depending on how much information is available regarding the model under attack:\n\\begin{itemize}\n    \\item \\textbf{White-box attacks}: Under this setting, the adversary has full access and knowledge of the model, that is, the architecture of the model, its parameters, gradients, and loss respect to the input as well as possible defense mechanisms are known to the attacker \\cite{goodfellow2014explaining}. Thus, it is not particularly difficult to attack models under this condition, and common methods exploit model's output gradients to generate adversarial examples. Only attacks belonging to this category have been evaluated in this work.\n    \\item \\textbf{Black-box attacks}: In this category of attacks, the adversary has zero or very little knowledge about the model. Thus existing methods often rely on training a similar model or an ensemble of them. These methods work because, generally, adversarial examples that fool one model are likely to fool another similar model. Furthermore, in practice, this is the most likely kind of attack, since, in normal circumstances, attackers don't have the possibility to access much of the models' knowledge. Other methods exploit knowledge about the accuracy of the prediction or only the label to craft adversarial examples \\cite{wiel2017decisionbased}.\n\\end{itemize}\nBoth white and black-box attacks are possible when attacking DRL algorithms and it depends on how much knowledge is known regarding the network defining the policy of the agents. Conversely, adversarial defenses aim to protect deep learning models from adversarial attacks, namely, making models more robust against adversarial examples. In this context, research on adversarial robustness resembles a minimax game where attackers constantly try to exploit more powerful techniques to fool deep learning models while, at the same time, defenders have to invent new defense methods to guard against these malicious attacks.\n\n\\subsection{Generating adversarial examples}\nIn the next sections, have been reported some of the most common white-box attacks on images that are often also used to attack DRL agents. Moreover, these methods can also be used to attack images under black-box settings by crafting adversarial examples attacking similar models and then exploiting the transferability propriety of the adversarial examples to fool the target model \\cite{dong2017boosting} or they can be directly applied to perform black-box attacks after estimating gradients by querying the target model \\cite{Chen_2017}.\n\n\\subsection{FGSM}\nFast Gradient Sign Method (FGSM) \\cite{goodfellow2014explaining} is a basic one-step gradient-based approach that is able to find an adversarial example in a single step by maximizing the loss function \\( L(x_{adv}, y)\\) with respect to the input \\(x\\) and then adding back the sign of the output gradients to \\(x\\) so to produce the adversarial example \\(x_{adv}\\)\n\\begin{equation}\nx_{adv}=x+\\epsilon \\cdot sign(\\nabla_x L(x, y)),\n\\end{equation}\nwhere \\(\\nabla_x L(x, y)\\) is the gradient of the loss respect to the input \\(x\\), and the equation is expected to meet the \\(l_{\\infty}\\) norm bound by design. This method works because adding a perturbation to the legitimate input such to maximize its loss respect to the correct label \\textit{y} decreases the likelihood that \\textit{y} could be predicted given the input \\(x_{adv}\\). Mathematically, it moves the adversarial example in one direction toward the border between the true class and some other class \\cite{dong2017boosting}. This method is sometimes implemented without the {\\it sign} operator (FGM) and it yields similar results to the version with sign \\cite{agarwal2018explainable}.\n\n\\subsection{I-FGSM}\nBasic iterative methods \\cite{kurakin2016adversarial} iteratively apply FGSM with a small step size \\(\\alpha\\). Thus, the iterative version of FGSM (I-FGSM) can be expressed as\n\\begin{equation}\nx_{adv}^{t+1}=x_{adv}^{t}+\\epsilon \\cdot \\alpha \\cdot sign(\\nabla_x L(x_{adv}^{t}, y)),\n\\end{equation}\nwhere \\(x_{adv}^{0}=x\\) is the legitimate example. There are several ways to make the adversarial example satisfy the norm bound. For example, \\(x_{adv}\\) could be clipped into the \\(\\epsilon\\) vicinity of x or set \\(\\alpha=\\epsilon/T\\) with \\(T\\) being the number of iterations. \\cite{kurakin2016adversarial} proved that iterative methods exploit much finer perturbations which do not destroy the image even with higher \\(\\epsilon\\) and at the same time confuse the classifier with a higher rate. Their drawback is that iterative methods are a little bit slower than their one-step counterparts.\n%, and more importantly, they show poor performance on transferability, which is a fundamental propriety in black-box attacks.\n\n\\subsection{MI-FGSM}\nMomentum iterative gradient-based methods \\cite{dong2017boosting} integrate momentum into iterative fast gradient method to generate adversarial examples satisfying the \\(l_{p}\\) norm bound. Traditionally, momentum is a technique for accelerating gradient descent algorithms by accumulating a velocity vector in the gradient direction of the loss function across iterations. However, this concept can also be applied to generate adversarial examples and obtain tremendous benefits. As it was for the learning rate update, the first step consists of updating the momentum \\(g_t\\) by accumulating the velocity vector in the gradient direction as \n\\begin{equation}\ng_{t+1}=\\mu \\cdot g_{t} + \\frac{\\nabla_x L(f(x, y)}{||\\nabla_x L(x, y)||_p},\n\\end{equation}\nwhere \\(\\mu\\) is a decay factor. Next, the adversarial example \\(x_{adv}^{t}\\) is perturbed in the direction of the sign of \\(g_{t}\\) with a step size \\(\\alpha\\) as\n\\begin{equation}\nx_{adv}^{t+1}=x_{adv}^{t}+\\alpha \\cdot sign(g_{t+1}).\n\\end{equation}\nIn each iteration, the current gradient \\(\\nabla_x L(x, y)\\) is normalized by the \\(l_{p}\\) distance of itself because the authors noticed that the scale of the gradients in different iterations varies in magnitude.\n\n\\subsection{PGD}\nProjected gradient descent (PGD) \\cite{madry2019deep} is another iterative algorithm that exploits projected gradient descend to iteratively craft adversarial examples as:\n\\begin{equation}\nx_{adv}^{t+1}=\\pi_{x+S}(x_{adv}^{t} +\\alpha \\cdot sign(\\nabla_x L(x_{adv}^{t}, y))),\n\\end{equation}\nwhere S is the set of all the allowed perturbations. Projected gradient descent performs one step of standard gradient descent, and then clips all the coordinates to be within the \\(l_p\\) ball. Moreover, in order to explore a large part of the loss landscape, the algorithm is restarted from many points within the \\(l_p\\) ball around data points taken from the evaluation set. Thanks to this large number of observations, the authors realized that all the local maxima found by PGD have similar loss values, both for normally trained networks and for adversarially trained networks, thus pointing out that robustness against the PGD adversary yields robustness against all first-order adversaries such as SGD based attacks. This conclusion also leads to the fact that as long as the adversary only uses gradients of the loss function with respect to the input, it will not find significantly better local maxima than PGD.\n\n\\subsection{C\\&W}\nThe method proposed by Carlini \\& Wagner \\cite{carlini2016evaluating} relies on the initial formulation of adversarial example and formally defines the problem of finding an adversarial instance for an image \\textit{x} as a minimization problem of a continuous function:\n\\begin{equation} \\label{eq:CW}\n\\min \\: ||\\delta||_p+c \\cdot L(x+\\delta, y),\n\\end{equation}\nunder the condition that \\((x+\\delta)\\in [0,1]^n\\). The function \\(f\\) is an objective function such that \\(L(x+\\delta, y)\\neq y\\) if and only if \\(L(x+\\delta, y)<=0\\). Finally, the term \\textit{c} is a suitable chosen hyper-parameter. Moreover, to ensure that the modification yields a valid image, the adversarial noise \\(\\delta\\) is constrained such that \\(0\\leq x_i+\\delta_i\\leq 1 \\: \\forall i\\) (here assuming image pixels to be in the range [0,1]). One way to do it, is to replace \\((x+\\delta)\\) with \\((1+\\tanh(w))/2\\) so that the optimization problem in (\\ref{eq:CW}) becomes an unconstrained minimization problem in \\textit{w}.\n\n\\section{Defending against adversarial examples}\nExtensive research in developing effective defense mechanisms in order to build robust models and safeguard them against adversarial attacks has also been conducted. One very promising technique is robust training which aims to make a classifier robust against small internal perturbations. Some possible strategies are based on adversarial training by adding generated adversarial examples to the training data \\cite{goodfellow2014explaining}, defensive distillation which consists of retraining a network using previously generated soft-labels \\cite{papernot2016distillation}, or another technique consists of training robust models with regularization such to train the defended model to ignore small perturbations \\cite{hein2017formal}. Another category of defense methods that we are going to examine consists of input transformation. This method is not applied during training but only during inference by transforming the inputs right before feeding them to the classifier with the aim to make adversarial perturbations less effective.\n\n\\subsection{Adversarial training}\nAdversarial training (AT) is a very simple and intuitive defense method to protect a model against adversarial examples. The first step consists of generating adversarial examples using different attack methods on the target model. In the second step, these adversarial examples are merged to the original training set so to form an augmented training set and finally the target model is retrained on the augmented training set. When adversarial examples are crafted with PGD we have PGD-adversarial training which can train very robust deep networks but it is much more expensive than traditional training due to the iterative design of PGD. In contrast, FGSM-adversarial training is typically faster but less effective \\cite{wong2020fast}.\n\n\\subsubsection{JPEG compression}\nJPEG compression \\cite{dziugaite2016study} is a simple input transformation method that converts each input image to JPEG before it is fed to the target network. It has been studied that compressing an image can partially remove possible adversarial perturbations and, at the same time, elude the human perception that no transformation has been applied. However, in practice, this method is not very effective since it degrades the performance of the model while not cleaning completely an image from all the adversarial perturbations. To remedy this problem, \\cite{das2018shield} proposes to vaccinate a policy by retraining it on JPEG compressed images multiple times on multiple compression qualities, and use an ensemble of these models to get the final classification label.\n\n\\subsubsection{Feature squeezing}\nFeature squeezing \\cite{Xu_2018} is another input transformation method that reduces the search space available to an adversary by compressing different features vectors in the original space into a single sample. Digital computers usually represent images as an array of pixels each of them representing a specific color (RGB images) or a shadow of grey (greyscale images). Thus, reducing bit depth can reduce the space that an adversarial has to craft perturbations possibly limiting the drop in accuracy that this compression may lead to. For example, an 8-bit greyscale image provides \\(2^8=256\\) values for each pixel which if reduced to 5-bits we would have only \\(2^5=32\\) values for each pixel that could be changed to create an adversarial example.", "meta": {"hexsha": "68cccc916f552b8b741d2d33dc840516123ca0a2", "size": 15562, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "data/chap03.tex", "max_stars_repo_name": "davide97l/master-thesis", "max_stars_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-02T05:46:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-02T05:46:48.000Z", "max_issues_repo_path": "data/chap03.tex", "max_issues_repo_name": "davide97l/master-thesis", "max_issues_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "data/chap03.tex", "max_forks_repo_name": "davide97l/master-thesis", "max_forks_repo_head_hexsha": "1627af369f754618031aea9ceb99ca044952af16", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 207.4933333333, "max_line_length": 1648, "alphanum_fraction": 0.7939210898, "num_tokens": 3501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.41881985196330285}}
{"text": "\\documentclass[a4paper,10pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{breqn}\n\\usepackage[colorlinks=false]{hyperref}\n\\newcommand{\\pluseq}{\\mathrel{{+}{=}}}\n\\newcommand{\\minuseq}{\\mathrel{{-}{=}}}\n\\newcommand{\\ns}{N_{sp}}\n\\newcommand{\\nr}{N_{reac}}\n\\newcommand{\\Ru}{\\mathcal{R}}\n\\begin{document}\n\\section{State Variables}\n\\begin{dmath} [C]_{k} = \\frac{n_{k}}{V}\\end{dmath} \n\\begin{dmath} \\Phi = \\left\\{T,P,n[1],n[2]\\ldots n[-1 + Ns()]\\right\\}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} \\Phi }{\\text{d} t } = \\left\\{\\frac{\\text{d} T }{\\text{d} t },\\frac{\\text{d} P }{\\text{d} t },\\frac{\\text{d} n }{\\text{d} t }[1],\\frac{\\text{d} n }{\\text{d} t }[2]\\ldots \\frac{\\text{d} n }{\\text{d} t }[-1 + Ns()]\\right\\}\\end{dmath} \n\\section{Source Terms}\n\\begin{dmath} \\frac{\\text{d} n }{\\text{d} t }_{k} = V \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{\\sum_{k=1}^{\\ns} U_{k} \\dot{\\omega}_{k}}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}}\\end{dmath} \nFrom conservation of mass:\n\\begin{dmath} m = \\sum_{k=1}^{\\ns} W_{k} n_{k}\\end{dmath} \n\\begin{dmath} 0 = \\sum_{k=1}^{\\ns} W_{k} \\frac{\\text{d} n }{\\text{d} t }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} n }{\\text{d} t }_{\\ns} = - \\frac{1}{W_{\\ns}} \\sum_{k=1}^{-1 + \\ns} W_{k} \\frac{\\text{d} n }{\\text{d} t }_{k}\\end{dmath} \n\\begin{dmath} n = \\frac{P V}{T \\Ru}\\end{dmath} \nThus...\\begin{dmath} \\dot{\\omega}_{\\ns} = - \\frac{1}{W_{\\ns}} \\sum_{k=1}^{-1 + \\ns} W_{k} \\dot{\\omega}_{k}\\end{dmath} \nAnd...\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} n }{\\text{d} t } = \\sum_{k=1}^{\\ns} \\frac{\\text{d} n }{\\text{d} t }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} n }{\\text{d} t } = \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\frac{\\text{d} n }{\\text{d} t }_{k}\\end{dmath} \nFrom the ideal gas law:\n\\begin{dmath} \\frac{\\text{d} P }{\\text{d} t } = \\frac{\\Ru}{V} \\left(T \\frac{\\text{d} n }{\\text{d} t } + \\frac{\\text{d} T }{\\text{d} t } n\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} P }{\\text{d} t } = \\frac{P}{T} \\frac{\\text{d} T }{\\text{d} t } + T \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\subsection{Other defns}\n\\begin{dmath} [C] = \\frac{P}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} P }{\\text{d} t } = \\frac{P}{T} \\frac{\\text{d} T }{\\text{d} t } + T \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} [C]_{\\ns} = [C] - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\end{dmath} \n\\begin{dmath} [C]_{\\ns} = \\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\end{dmath} \n\\begin{dmath} W = \\sum_{k=1}^{\\ns} W_{k} X_{k}\\end{dmath} \n\\begin{dmath} W = \\frac{1}{[C]} \\sum_{k=1}^{\\ns} W_{k} [C]_{k}\\end{dmath} \n\\begin{dmath} [C]_{\\ns} = \\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\end{dmath} \n\\begin{dmath} W = \\frac{1}{[C]} \\left(\\left([C] - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right) W_{\\ns} + \\sum_{k=1}^{-1 + \\ns} W_{k} [C]_{k}\\right)\\end{dmath} \n\\begin{dmath} W = W_{\\ns} + \\frac{1}{[C]} \\sum_{k=1}^{-1 + \\ns} \\left(- W_{\\ns} + W_{k}\\right) [C]_{k}\\end{dmath} \n\\section{Thermo Definitions}\n\\begin{dmath} {C_{p,k}}^{\\circ} = {C_p}_{k}\\end{dmath} \n\\begin{dmath} {C_p}_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T a_{k,4} + a_{k,3}\\right) + a_{k,2}\\right) + a_{k,1}\\right) + a_{k,0}\\right)\\end{dmath} \n\\begin{dmath} {C_p}_{k} = T^{4} \\Ru a_{k,4} + T^{3} \\Ru a_{k,3} + T^{2} \\Ru a_{k,2} + T \\Ru a_{k,1} + \\Ru a_{k,0}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {C_p} }{\\text{d} T }_{k} = \\Ru \\left(4 T^{3} a_{k,4} + 3 T^{2} a_{k,3} + 2 T a_{k,2} + a_{k,1}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {C_p} }{\\text{d} T }_{k} = \\Ru \\left(T \\left(T \\left(4 T a_{k,4} + 3 a_{k,3}\\right) + 2 a_{k,2}\\right) + a_{k,1}\\right)\\end{dmath} \n\\begin{dmath} \\bar{c_p} = \\sum_{k=1}^{\\ns} \\frac{n_{k} {C_p}_{k}}{n}\\end{dmath} \n\\begin{dmath} {C_{v,k}}^{\\circ} = {C_v}_{k}\\end{dmath} \n\\begin{dmath} {C_v}_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T a_{k,4} + a_{k,3}\\right) + a_{k,2}\\right) + a_{k,1}\\right) + a_{k,0} - 1\\right)\\end{dmath} \n\\begin{dmath} {C_v}_{k} = T^{4} \\Ru a_{k,4} + T^{3} \\Ru a_{k,3} + T^{2} \\Ru a_{k,2} + T \\Ru a_{k,1} + \\Ru a_{k,0} - \\Ru\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {C_v} }{\\text{d} T }_{k} = \\Ru \\left(4 T^{3} a_{k,4} + 3 T^{2} a_{k,3} + 2 T a_{k,2} + a_{k,1}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {C_v} }{\\text{d} T }_{k} = \\Ru \\left(T \\left(T \\left(4 T a_{k,4} + 3 a_{k,3}\\right) + 2 a_{k,2}\\right) + a_{k,1}\\right)\\end{dmath} \n\\begin{dmath} \\bar{c_v} = \\sum_{k=1}^{\\ns} \\frac{n_{k} {C_v}_{k}}{n}\\end{dmath} \n\\begin{dmath} H_k^{\\circ} = H_{k}\\end{dmath} \n\\begin{dmath} H_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T \\left(\\frac{T a_{k,4}}{5} + \\frac{a_{k,3}}{4}\\right) + \\frac{a_{k,2}}{3}\\right) + \\frac{a_{k,1}}{2}\\right) + a_{k,0}\\right) + a_{k,5}\\right)\\end{dmath} \n\\begin{dmath} H_{k} = \\frac{T^{5} a_{k,4}}{5} \\Ru + \\frac{T^{4} a_{k,3}}{4} \\Ru + \\frac{T^{3} a_{k,2}}{3} \\Ru + \\frac{T^{2} a_{k,1}}{2} \\Ru + T \\Ru a_{k,0} + \\Ru a_{k,5}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} H }{\\text{d} T }_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T a_{k,4} + a_{k,3}\\right) + a_{k,2}\\right) + a_{k,1}\\right) + a_{k,0}\\right)\\end{dmath} \n\\begin{dmath} H_k = U_k + \\frac{P V}{n}\\end{dmath} \n\\begin{dmath} U_{k} = - T \\Ru + H_{k}\\end{dmath} \n\\begin{dmath} U_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T \\left(\\frac{T a_{k,4}}{5} + \\frac{a_{k,3}}{4}\\right) + \\frac{a_{k,2}}{3}\\right) + \\frac{a_{k,1}}{2}\\right) + a_{k,0}\\right) - T + a_{k,5}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} U }{\\text{d} T }_{k} = \\Ru \\left(T \\left(T \\left(T \\left(T a_{k,4} + a_{k,3}\\right) + a_{k,2}\\right) + a_{k,1}\\right) + a_{k,0} - 1\\right)\\end{dmath} \n\\begin{dmath} S_k^{\\circ} = S_{k} = \\Ru \\left(T \\left(T \\left(T \\left(\\frac{T a_{k,4}}{4} + \\frac{a_{k,3}}{3}\\right) + \\frac{a_{k,2}}{2}\\right) + a_{k,1}\\right) + \\log{\\left (T \\right )} a_{k,0} + a_{k,6}\\right)\\end{dmath} \n\\section{Definitions}\n\\begin{dmath} \\nu_{k,i} = \\nu^{\\prime\\prime}_{k,i} - \\nu^{\\prime}_{k,i}\\end{dmath} \n\\begin{dmath} \\dot{\\omega}_{k} = \\sum_{i=1}^{\\nr} \\nu_{k,i} q_{i}\\end{dmath} \n\\begin{dmath} q_{i} = R_{i} c_{i}\\end{dmath} \n\\begin{dmath} \\dot{\\omega}_{k} = \\sum_{i=1}^{\\nr} \\nu_{k,i} R_{i} c_{i}\\end{dmath} \n\\section{Rate of Progress}\n\\begin{dmath} R_{i} = {R_f}_{i} - {R_r}_{i}\\end{dmath} \n\\begin{dmath} {R_f}_{i} = {k_f}_{i} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} {R_r}_{i} = {k_r}_{i} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\end{dmath} \n\\section{Third-body effect}\n\\begin{dmath} c_{i}=1\\text{\\quad for elementary reactions}\\end{dmath} \n\\begin{dmath} c_{i}=[X]_{i}\\text{\\quad for third-body enhanced reactions}\\end{dmath} \n\\begin{dmath} c_{i}=\\frac{F_{i} P_{r, i}}{P_{r, i} + 1}\\text{\\quad for unimolecular/recombination falloff reactions}\\end{dmath} \n\\begin{dmath} c_{i}=\\frac{F_{i}}{P_{r, i} + 1}\\text{\\quad for chemically-activated bimolecular reactions}\\end{dmath} \n\\section{Forward Reaction Rate}\n\\begin{dmath} {k_f}_{i} = T^{\\beta_{i}} \\operatorname{exp}\\left({- \\frac{{E_{a}}_{i}}{T \\Ru}}\\right) A_{i}\\end{dmath} \n\\section{Equilibrium Constants}\n\\begin{dmath} {K_c}_{i} = \\left(\\left(\\frac{P_{atm}}{T \\Ru}\\right)^{\\sum_{k=1}^{\\ns} \\nu_{k,i}}\\right) {K_p}_{i}\\end{dmath} \n\\begin{dmath} {K_p}_{i} = \\text{exp}(\\frac{\\Delta S^{\\circ}_k}{\\Ru} - \\frac{\\Delta H^{\\circ}_k}{\\Ru T})\\end{dmath} \n\\begin{dmath} {K_p}_{i} = \\text{exp}\\left(\\sum_{k=1}^{\\ns}\\nu_{ki}\\left(\\frac{S^{\\circ}_k}{\\Ru} - \\frac{H^{\\circ}_k}{\\Ru T}\\right)\\right)\\end{dmath} \n\\begin{dmath} {K_c}_{i} = \\left(\\left(\\frac{P_{atm}}{\\Ru}\\right)^{\\sum_{k=1}^{\\ns} \\nu_{k,i}}\\right) \\operatorname{exp}\\left({\\sum_{k=1}^{\\ns} \\nu_{k,i} B_{k}}\\right)\\end{dmath} \n\\begin{dmath} B_{k}= \\frac{S^{\\circ}_k}{\\Ru} - \\frac{H^{\\circ}_k}{\\Ru T} - ln(T)\\end{dmath} \n\\begin{dmath} B_{k} = T \\left(T \\left(T \\left(\\frac{T a_{k,4}}{20} + \\frac{a_{k,3}}{12}\\right) + \\frac{a_{k,2}}{6}\\right) + \\frac{a_{k,1}}{2}\\right) + \\left(a_{k,0} - 1\\right) \\log{\\left (T \\right )} - a_{k,0} + a_{k,6} - \\frac{a_{k,5}}{T}\\end{dmath} \n\\section{Reverse Reaction Rate}\n\\begin{dmath} {k_r}_{i}=\\frac{{k_f}_{i}}{{K_c}_{i}}\\text{\\quad if non-explicit}\\end{dmath} \n\\begin{dmath} {R_r}_{i}=T^{{\\beta_r}_{i}} \\operatorname{exp}\\left({- \\frac{{E_{a,r}}_{i}}{T \\Ru}}\\right) {A_{r}}_{i} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\text{\\quad if explicit}\\end{dmath} \n\\section{Third-Body Efficiencies}\n\\begin{dmath} [X]_{i} = \\sum_{k=1}^{\\ns} \\alpha_{k,i} [C]_{k}\\end{dmath} \n\\begin{dmath} [X]_{i} = [C] + \\sum_{k=1}^{\\ns} \\left(\\alpha_{k,i} - 1\\right) [C]_{k}\\end{dmath} \n\\begin{dmath} [X]_{i} = [C] + \\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right) \\left(\\alpha_{\\ns,i} - 1\\right) + \\sum_{k=1}^{-1 + \\ns} \\left(\\alpha_{k,i} - 1\\right) [C]_{k}\\end{dmath} \n\\begin{dmath} [X]_{i}=[C] \\alpha_{\\ns,i} + \\sum_{k=1}^{-1 + \\ns} \\left(- \\alpha_{\\ns,i} + \\alpha_{k,i}\\right) [C]_{k}\\text{\\quad for mixture as third-body}\\end{dmath} \n\\begin{dmath} [X]_{i}=[C]\\text{\\quad for all $\\alpha_{ki} = 1$}\\end{dmath} \n\\begin{dmath} [X]_{i}=\\left([C] - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right) \\delta_{\\ns m} + \\left(- \\delta_{\\ns m} + 1\\right) [C]_{m}\\text{\\quad for a single species third-body}\\end{dmath} \n\\section{Falloff Reactions}\n\\begin{dmath} k_{0, i} = T^{\\beta_0} A_{0} \\operatorname{exp}\\left({- \\frac{E_{a, 0}}{T \\Ru}}\\right)\\end{dmath} \n\\begin{dmath} k_{\\infty, i} = T^{\\beta_{\\infty}} A_{\\infty} \\operatorname{exp}\\left({- \\frac{E_{a, \\infty}}{T \\Ru}}\\right)\\end{dmath} \n\\begin{dmath} P_{r, i}=\\frac{[X]_{i} k_{0, i}}{k_{\\infty, i}}\\text{\\quad for the mixture as the third-body}\\end{dmath} \n\\begin{dmath} P_{r, i}=\\frac{k_{0, i}}{k_{\\infty, i}} \\left(\\left([C] - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right) \\delta_{\\ns m} + \\left(- \\delta_{\\ns m} + 1\\right) [C]_{m}\\right)\\text{\\quad for species $m$ as the third-body}\\end{dmath} \n\\begin{dmath} P_{r, i}=\\frac{[C] k_{0, i}}{k_{\\infty, i}}\\text{\\quad for for all $\\alpha_{i, j} = 1$}\\end{dmath} \n\\begin{dmath} F_{i}=1\\text{\\quad for Lindemann}\\end{dmath} \n\\begin{dmath} F_{i}=F_{cent}^{\\frac{1}{\\frac{A_{Troe}^{2}}{B_{Troe}^{2}} + 1}}\\text{\\quad for Troe}\\end{dmath} \n\\begin{dmath} F_{i}=T^{e} d \\left(a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right)\\right)^{X}\\text{\\quad for SRI}\\end{dmath} \n\\begin{dmath} F_{cent} = a \\operatorname{exp}\\left({- \\frac{T}{T^{*}}}\\right) + \\left(- a + 1\\right) \\operatorname{exp}\\left({- \\frac{T}{T^{***}}}\\right) + \\operatorname{exp}\\left({- \\frac{T^{**}}{T}}\\right)\\end{dmath} \n\\begin{dmath} A_{Troe} = - \\frac{0.67 \\log{\\left (F_{cent} \\right )}}{\\log{\\left (10 \\right )}} + \\frac{\\log{\\left (P_{r, i} \\right )}}{\\log{\\left (10 \\right )}} - 0.4\\end{dmath} \n\\begin{dmath} B_{Troe} = - \\frac{1.1762 \\log{\\left (F_{cent} \\right )}}{\\log{\\left (10 \\right )}} - \\frac{0.14 \\log{\\left (P_{r, i} \\right )}}{\\log{\\left (10 \\right )}} + 0.806\\end{dmath} \n\\begin{dmath} X = \\frac{1}{\\frac{\\log^{2}{\\left (P_{r, i} \\right )}}{\\log^{2}{\\left (10 \\right )}} + 1}\\end{dmath} \n\\section{Pressure-Dependent Reactions}\nFor PLog reactions\n\\begin{dmath} k_{1}=T^{\\beta_1} A_{1} \\operatorname{exp}\\left({\\frac{E_{a_1}}{T \\Ru}}\\right)\\text{\\quad at $P_1$}\\end{dmath} \n\\begin{dmath} k_{2}=T^{\\beta_2} A_{2} \\operatorname{exp}\\left({\\frac{E_{a_2}}{T \\Ru}}\\right)\\text{\\quad at $P_2$}\\end{dmath} \n\\begin{dmath} \\log{\\left ({k_f}_{i} \\right )} = \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\log{\\left (k_{1} \\right )}\\end{dmath} \nFor Chebyshev reactions\n\\begin{dmath} \\frac{\\log{\\left ({k_f}_{i} \\right )}}{\\log{\\left (10 \\right )}} = \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} T_{j - 1}\\left(\\tilde{T}\\right) T_{l - 1}\\left(\\tilde{P}\\right) \\eta_{l,j}\\end{dmath} \n\\begin{dmath} \\tilde{T} = \\frac{- \\frac{1}{T_{min}} - \\frac{1}{T_{max}} + \\frac{2}{T}}{- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}}\\end{dmath} \n\\begin{dmath} \\tilde{P} = \\frac{2 \\log{\\left (P \\right )} - \\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}}{\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}}\\end{dmath} \n\\section{Derivatives}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = R_{i} \\frac{\\partial c }{\\partial T }_{i} + \\frac{\\partial R }{\\partial T }_{i} c_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} = \\sum_{i=1}^{\\nr} \\left(\\nu_{k,i} R_{i} \\frac{\\partial c }{\\partial T }_{i} + \\nu_{k,i} \\frac{\\partial R }{\\partial T }_{i} c_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial q }{\\partial n[k] }_{i} = R_{i} \\frac{\\partial c }{\\partial {n_j} }_{i} + \\frac{\\partial R }{\\partial {n_j} }_{i} c_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k} = \\sum_{i=1}^{\\nr} \\left(\\nu_{k,i} R_{i} \\frac{\\partial c }{\\partial {n_j} }_{i} + \\nu_{k,i} \\frac{\\partial R }{\\partial {n_j} }_{i} c_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{i} = R_{i} \\frac{\\partial c }{\\partial P }_{i} + \\frac{\\partial R }{\\partial P }_{i} c_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial \\dot{\\omega} }{\\partial P }_{k} = \\sum_{i=1}^{\\nr} \\left(\\nu_{k,i} R_{i} \\frac{\\partial c }{\\partial P }_{i} + \\nu_{k,i} \\frac{\\partial R }{\\partial P }_{i} c_{i}\\right)\\end{dmath} \n\\section{Rate of Progress Derivatives}\n\\subsection{Molar Derivatives}\n\\begin{dmath} \\frac{d}{d n_{k}} {R_f} = \\left(\\frac{\\partial}{\\partial n_{j}} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\right) {k_f}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C_k]}{\\partial n_j} =\\frac{\\delta_{j k}}{V}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C_{Ns}]}{\\partial n_j} =- \\frac{1}{V}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C_{Ns}]^{\\nu^{\\prime}_{Ns, i}}}{\\partial [n_j]} =- \\frac{\\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} \\frac{n_{k}}{V}\\right)^{\\nu^{\\prime}_{\\ns,i}}\\right) \\nu^{\\prime}_{\\ns,i} \\sum_{k=1}^{-1 + \\ns} \\frac{\\delta_{j k}}{V}}{\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} \\frac{n_{k}}{V}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C_{Ns}]^{\\nu^{\\prime}_{Ns, i}}}{\\partial n_j} =- \\frac{\\nu^{\\prime}_{\\ns,i}}{V} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i} - 1}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial {n_j} }_{i} = {k_f}_{i} \\sum_{k=1}^{\\ns} \\left(- \\frac{\\delta_{\\ns k}}{V} + \\frac{\\delta_{j k}}{V}\\right) \\nu^{\\prime}_{k,i} [C]_{k}^{\\nu^{\\prime}_{k,i} - 1} \\prod_{\\substack{1 \\leq l \\leq k - 1\\\\k + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime}_{l,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial {n_j} }_{i} = \\frac{{k_f}_{i}}{V} \\left(- \\nu^{\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i} - 1} \\prod_{l=1}^{-1 + \\ns} [C]_{l}^{\\nu^{\\prime}_{l,i}} + \\nu^{\\prime}_{j,i} [C]_{j}^{\\nu^{\\prime}_{j,i} - 1} \\prod_{\\substack{1 \\leq l \\leq j - 1\\\\j + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime}_{l,i}}\\right)\\end{dmath} \n\\begin{dmath} S^{\\prime}_{l} = \\nu^{\\prime}_{l,i} [C]_{l}^{\\nu^{\\prime}_{l,i} - 1} \\prod_{\\substack{1 \\leq l \\leq l - 1\\\\l + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime}_{l,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial {n_j} }_{i} = \\frac{{k_f}_{i}}{V} \\left(- S^{\\prime}_{\\ns} + S^{\\prime}_{j}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial {n_j} }_{i} = {k_r}_{i} \\sum_{k=1}^{\\ns} \\left(- \\frac{\\delta_{\\ns k}}{V} + \\frac{\\delta_{j k}}{V}\\right) \\nu^{\\prime\\prime}_{k,i} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i} - 1} \\prod_{\\substack{1 \\leq l \\leq k - 1\\\\k + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime\\prime}_{l,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial {n_j} }_{i} = \\frac{{k_r}_{i}}{V} \\left(- \\nu^{\\prime\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime\\prime}_{\\ns,i} - 1} \\prod_{l=1}^{-1 + \\ns} [C]_{l}^{\\nu^{\\prime\\prime}_{l,i}} + \\nu^{\\prime\\prime}_{j,i} [C]_{j}^{\\nu^{\\prime\\prime}_{j,i} - 1} \\prod_{\\substack{1 \\leq l \\leq j - 1\\\\j + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime\\prime}_{l,i}}\\right)\\end{dmath} \n\\begin{dmath} S^{\\prime\\prime}_{l} = \\nu^{\\prime\\prime}_{l,i} [C]_{l}^{\\nu^{\\prime\\prime}_{l,i} - 1} \\prod_{\\substack{1 \\leq l \\leq l - 1\\\\l + 1 \\leq l \\leq \\ns}} [C]_{l}^{\\nu^{\\prime\\prime}_{l,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial {n_j} }_{i} = \\frac{{k_r}_{i}}{V} \\left(- S^{\\prime\\prime}_{\\ns} + S^{\\prime\\prime}_{j}\\right)\\end{dmath} \nFor all reversible reactions\n\\begin{dmath} \\frac{\\partial R }{\\partial {n_j} }_{i} = - \\frac{{k_r}_{i}}{V} \\left(- S^{\\prime\\prime}_{\\ns} + S^{\\prime\\prime}_{j}\\right) + \\frac{{k_f}_{i}}{V} \\left(- S^{\\prime}_{\\ns} + S^{\\prime}_{j}\\right)\\end{dmath} \n\\subsection{Temperature Derivative}\n\\begin{dmath} {R_f} = {k_f}_{i} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\frac{{k_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} {R_f} = \\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)^{\\nu^{\\prime}_{\\ns,i}}\\right) {k_f}_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial T }_{i} = - \\frac{P \\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)^{\\nu^{\\prime}_{\\ns,i}}\\right) \\nu^{\\prime}_{\\ns,i} {k_f}_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}}{T^{2} \\Ru \\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)} + \\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)^{\\nu^{\\prime}_{\\ns,i}}\\right) \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial T }_{i} = \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} \\prod_{k=1}^{\\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}} - \\frac{[C] \\nu^{\\prime}_{\\ns,i}}{T} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i} - 1} {k_f}_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial T }_{i} = - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\end{dmath} \nFor reactions with explicit reverse Arrhenius coefficients\n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial T }_{i} = - \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i} + \\frac{{R_r}_{i}}{T} \\left({\\beta_r}_{i} + \\frac{{E_{a,r}}_{i}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial T }_{i} = \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i} - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right) - \\frac{{R_r}_{i}}{T} \\left({\\beta_r}_{i} + \\frac{{E_{a,r}}_{i}}{T \\Ru}\\right)\\end{dmath} \nFor non-explicit reversible reactions\n\\begin{dmath} \\frac{\\text{d} {k_r} }{\\text{d} T }_{i} = - \\frac{{k_f}_{i}}{{K_c}_{i}^{2}} \\frac{\\text{d} {K_c} }{\\text{d} T }_{i} + \\frac{1}{{K_c}_{i}} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_r} }{\\text{d} T }_{i} = \\left(- \\frac{1}{{K_c}_{i}} \\frac{\\text{d} {K_c} }{\\text{d} T }_{i} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {K_c} }{\\text{d} T }_{i} = {K_c}_{i} \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_r} }{\\text{d} T }_{i} = \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial T }_{i} = \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {R_r}_{i} - \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial T }_{i} = \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {R_r}_{i} - \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial T }_{i} = - \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {R_r}_{i} + \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i} - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} B }{\\text{d} T }_{k} = T \\left(T \\left(\\frac{T a_{k,4}}{5} + \\frac{a_{k,3}}{4}\\right) + \\frac{a_{k,2}}{3}\\right) + \\frac{a_{k,1}}{2} + \\frac{1}{T} \\left(a_{k,0} - 1 + \\frac{a_{k,5}}{T}\\right)\\end{dmath} \n\\subsection{Pressure derivatives}\n\\begin{dmath} \\frac{\\partial [C]_{k} }{\\partial P } = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C]_{\\ns} }{\\partial P } = \\frac{1}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C_{Ns}]^{\\nu^{\\prime}_{Ns, i}}}{\\partial P } = \\frac{\\nu^{\\prime}_{k,i} [C]_{\\ns}^{\\nu^{\\prime}_{k,i} - 1}}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [C] }{\\partial P } = \\frac{1}{T \\Ru}\\end{dmath} \n\\begin{dmath} {R_f}_{i} = \\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)^{\\nu^{\\prime}_{\\ns,i}}\\right) {k_f}_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{\\nu^{\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i}} {k_f}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{\\nu^{\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i}} {k_f}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{\\nu^{\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime}_{\\ns,i}} {k_f}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\end{dmath} \n\\begin{dmath} {R_r}_{i} = \\left(\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right)^{\\nu^{\\prime\\prime}_{\\ns,i}}\\right) {k_r}_{i} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{\\nu^{\\prime\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime\\prime}_{\\ns,i}} {k_r}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{\\nu^{\\prime\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime\\prime}_{\\ns,i}} {k_r}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{\\nu^{\\prime\\prime}_{\\ns,i} [C]_{\\ns}^{\\nu^{\\prime\\prime}_{\\ns,i}} {k_r}_{i}}{T \\Ru [C]_{\\ns}} \\prod_{k=1}^{-1 + \\ns} [C]_{k}^{\\nu^{\\prime\\prime}_{k,i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru}\\end{dmath} \n\\section{Third-Body\\slash Falloff Derivatives}\n\\subsection{Elementary reactions\n}\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = 0\\end{dmath} \n\\subsection{Third-body enhanced reactions}\n\\begin{dmath} \\frac{\\partial [X]_i }{\\partial T } = - \\frac{[C] \\alpha_{\\ns,i}}{T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial [X]_i }{\\partial {n_j} } = \\frac{1}{V} \\left(- \\alpha_{\\ns,i} + \\alpha_{j,i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial [X]_i }{\\partial P } = \\frac{\\alpha_{\\ns,i}}{T \\Ru}\\end{dmath} \nFor species $m$ as the third-body\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = - \\frac{\\delta_{\\ns m}}{T} [C]\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{1}{V} \\left(- \\delta_{\\ns m} \\delta_{j m} - \\delta_{\\ns m} + \\delta_{j m}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{1}{V} \\left(- \\delta_{\\ns m} + \\delta_{j m}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\frac{\\delta_{\\ns m}}{T \\Ru}\\end{dmath} \nIf all $\\alpha_{j, i} = 1$ for all species j\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = - \\frac{[C]}{T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\frac{1}{T \\Ru}\\end{dmath} \n\\subsection{Unimolecular/recombination fall-off reactions}\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = \\frac{1}{P_{r, i} + 1} \\left(P_{r, i} \\frac{\\partial F_{i} }{\\partial T } + \\frac{\\partial P_{r, i} }{\\partial T } \\left(F_{i} - c_{i}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{1}{P_{r, i} + 1} \\left(P_{r, i} \\frac{\\partial F_{i} }{\\partial {n_j} } + \\frac{\\partial P_{r, i} }{\\partial {n_j} } \\left(F_{i} - c_{i}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\frac{1}{P_{r, i} + 1} \\left(P_{r, i} \\frac{\\partial F_{i} }{\\partial P } + \\frac{\\partial P_{r, i} }{\\partial P } \\left(F_{i} - c_{i}\\right)\\right)\\end{dmath} \n\\subsection{Chemically-activated bimolecular reactions}\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = \\frac{1}{P_{r, i} + 1} \\left(\\frac{\\partial F_{i} }{\\partial T } - \\frac{\\partial P_{r, i} }{\\partial T } c_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{1}{P_{r, i} + 1} \\left(\\frac{\\partial F_{i} }{\\partial {n_j} } - \\frac{\\partial P_{r, i} }{\\partial {n_j} } c_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\frac{1}{P_{r, i} + 1} \\left(\\frac{\\partial F_{i} }{\\partial P } - \\frac{\\partial P_{r, i} }{\\partial P } c_{i}\\right)\\end{dmath} \n\\subsection{Reduced Pressure derivatives}\n\nFor the mixture as the third body\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = \\frac{P_{r, i}}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right) - \\frac{[C] k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{k_{0, i} \\left(- \\alpha_{\\ns,i} + \\alpha_{j,i}\\right)}{k_{\\infty, i} V}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\frac{k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i} \\Ru}\\end{dmath} \nSimplifying:\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = P_{r, i} \\Theta_{P_{r,i}, \\partial T, mix} + \\bar{\\theta}_{P_{r, i}, \\partial T, mix}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{\\bar{\\theta}_{P_{r, i}, \\partial n_j, mix}}{k_{\\infty, i} V} k_{0, i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\bar{\\theta}_{P_{r, i}, \\partial P, mix}\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T, mix} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T, mix} = - \\frac{[C] k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i}}\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j, mix} = - \\alpha_{\\ns,i} + \\alpha_{j,i}\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P, mix} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P, mix} = \\frac{k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i} \\Ru}\\end{dmath} \nFor species $m$ as the third-body\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = \\frac{P_{r, i}}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right) - \\frac{[C] k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{k_{0, i}}{k_{\\infty, i} V} \\left(- \\delta_{\\ns m} + \\delta_{j m}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\frac{k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i} \\Ru}\\end{dmath} \nSimplifying:\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = P_{r, i} \\Theta_{P_{r,i}, \\partial T, spec} + \\bar{\\theta}_{P_{r, i}, \\partial T, spec}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{\\bar{\\theta}_{P_{r, i}, \\partial n_j, spec}}{k_{\\infty, i} V} k_{0, i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\bar{\\theta}_{P_{r, i}, \\partial P, spec}\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T, spec} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T, spec} = - \\frac{[C] k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i}}\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j, spec} = - \\delta_{\\ns m} + \\delta_{j m}\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P, spec} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P, spec} = \\frac{k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i} \\Ru}\\end{dmath} \nIf all $\\alpha_{j, i} = 1$ for all species j\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = \\frac{P_{r, i}}{T} \\left(\\beta_{0} - \\beta_{\\infty} - 1 + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{k_{0, i}}{k_{\\infty, i}} \\frac{\\partial [C] }{\\partial P }\\end{dmath} \nSimplifying:\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = P_{r, i} \\Theta_{P_{r,i}, \\partial T, unity}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\bar{\\theta}_{P_{r, i}, \\partial n_j, unity}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\bar{\\theta}_{P_{r, i}, \\partial P, unity}\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T, unity} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} - 1 + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T, unity} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j, unity} = 0\\end{dmath} \n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P, unity} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P, unity} = \\frac{k_{0, i}}{k_{\\infty, i}} \\frac{\\partial [C] }{\\partial P }\\end{dmath} \nThus we write:\n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial T } = P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial {n_j} } = \\frac{k_{0, i} \\bar{\\theta}_{P_{r, i}, \\partial n_j}}{k_{\\infty, i} V}\\end{dmath} \n\\begin{dmath} \\frac{\\partial P_{r, i} }{\\partial P } = \\bar{\\theta}_{P_{r, i}, \\partial P}\\end{dmath} \nFor\n\\begin{dgroup}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\text{\\quad if mix}\\end{dmath}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\text{\\quad if species}\\end{dmath}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} - 1 + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\text{\\quad if unity}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = - \\frac{[C] k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i}}\\text{\\quad if mix}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = - \\frac{[C] k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i}}\\text{\\quad if species}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = 0\\text{\\quad if unity}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = - \\alpha_{\\ns,i} + \\alpha_{j,i}\\text{\\quad if mix}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = - \\delta_{\\ns m} + \\delta_{j m}\\text{\\quad if species}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = 0\\text{\\quad if unity}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\text{\\quad if mix}\\end{dmath}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\text{\\quad if species}\\end{dmath}\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\text{\\quad if unity}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i} \\Ru}\\text{\\quad if mix}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i} \\Ru}\\text{\\quad if species}\\end{dmath}\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i}}{k_{\\infty, i}} \\frac{\\partial [C] }{\\partial P }\\text{\\quad if unity}\\end{dmath}\n\\end{dgroup}\n\\subsection{Falloff Blending Factor derivatives}\n\n For Lindemann reactions\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = 0\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = 0\\end{dmath} \nFor Troe reactions\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = \\frac{\\partial F_{i} }{\\partial F_{cent} } \\frac{\\text{d} F_{cent} }{\\text{d} T } + \\frac{\\partial F_{i} }{\\partial P_{r, i} } \\frac{\\partial P_{r, i} }{\\partial T }\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = \\frac{\\partial F_{i} }{\\partial P_{r, i} } \\frac{\\partial P_{r, i} }{\\partial {n_j} }\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = \\frac{\\partial F_{i} }{\\partial P_{r, i} } \\frac{\\partial P_{r, i} }{\\partial P }\\end{dmath} \nwhere\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial F_{cent} } = \\frac{F_{i}}{\\frac{A_{Troe}^{2}}{B_{Troe}^{2}} + 1} \\left(\\frac{2 A_{Troe} \\log{\\left (F_{cent} \\right )}}{B_{Troe}^{2} \\left(\\frac{A_{Troe}^{2}}{B_{Troe}^{2}} + 1\\right)} \\left(\\frac{A_{Troe}}{B_{Troe}} \\frac{\\partial B_{Troe} }{\\partial F_{cent} } - \\frac{\\partial A_{Troe} }{\\partial F_{cent} }\\right) + \\frac{1}{F_{cent}}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} F_{cent} }{\\text{d} T } = - \\frac{a}{T^{*}} \\operatorname{exp}\\left({- \\frac{T}{T^{*}}}\\right) - \\frac{\\operatorname{exp}\\left({- \\frac{T}{T^{***}}}\\right)}{T^{***}} \\left(- a + 1\\right) + \\frac{T^{**}}{T^{2}} \\operatorname{exp}\\left({- \\frac{T^{**}}{T}}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P_{r, i} } = \\frac{2 F_{i} A_{Troe} \\log{\\left (F_{cent} \\right )}}{B_{Troe}^{2} \\left(\\frac{A_{Troe}^{2}}{B_{Troe}^{2}} + 1\\right)^{2}} \\left(\\frac{A_{Troe}}{B_{Troe}} \\frac{\\partial B_{Troe} }{\\partial P_{r, i} } - \\frac{\\partial A_{Troe} }{\\partial P_{r, i} }\\right)\\end{dmath} \nAnd\n\\begin{dmath} \\frac{\\partial A_{Troe} }{\\partial F_{cent} } = - \\frac{0.67}{F_{cent} \\log{\\left (10 \\right )}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial B_{Troe} }{\\partial F_{cent} } = - \\frac{1.1762}{F_{cent} \\log{\\left (10 \\right )}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial A_{Troe} }{\\partial P_{r, i} } = \\frac{1}{P_{r, i} \\log{\\left (10 \\right )}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial B_{Troe} }{\\partial P_{r, i} } = - \\frac{0.14}{P_{r, i} \\log{\\left (10 \\right )}}\\end{dmath} \nThus\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial F_{cent} } = - \\frac{F_{i} B_{Troe}}{F_{cent} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}} \\left(2 A_{Troe} \\left(1.1762 A_{Troe} - 0.67 B_{Troe}\\right) \\log{\\left (F_{cent} \\right )} - B_{Troe} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right) \\log{\\left (10 \\right )}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P_{r, i} } = - \\frac{2 F_{i} A_{Troe} \\left(\\frac{0.14 A_{Troe}}{B_{Troe}} + 1\\right) \\log{\\left (F_{cent} \\right )}}{B_{Troe}^{2} P_{r, i} \\left(\\frac{A_{Troe}^{2}}{B_{Troe}^{2}} + 1\\right)^{2} \\log{\\left (10 \\right )}}\\end{dmath} \nAnd\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = F_{i} \\Theta_{F_i, \\partial T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = \\frac{F_{i} k_{0, i} \\Theta_{F_i, \\partial n_j}}{k_{\\infty, i} V} \\bar{\\theta}_{P_{r, i}, \\partial n_j}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = F_{i} \\Theta_{F_i, \\partial P}\\end{dmath} \nWhere\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{B_{Troe}}{F_{cent} P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}} \\left(2 A_{Troe} F_{cent} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (F_{cent} \\right )} + P_{r, i} \\frac{\\text{d} F_{cent} }{\\text{d} T } \\left(2 A_{Troe} \\left(1.1762 A_{Troe} - 0.67 B_{Troe}\\right) \\log{\\left (F_{cent} \\right )} - B_{Troe} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right) \\log{\\left (10 \\right )}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 A_{Troe} B_{Troe} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\end{dmath} \n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 A_{Troe} B_{Troe} \\bar{\\theta}_{P_{r, i}, \\partial P} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\end{dmath} \nFor SRI reactions\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = F_{i} \\left(\\frac{X \\left(- \\frac{\\operatorname{exp}\\left({- \\frac{T}{c}}\\right)}{c} + \\frac{a b}{T^{2}} \\operatorname{exp}\\left({- \\frac{b}{T}}\\right)\\right)}{a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right)} + \\frac{\\partial P_{r, i} }{\\partial T } \\frac{\\text{d} X }{\\text{d} P_{r, i} } \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )} + \\frac{e}{T}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = F_{i} \\frac{\\partial P_{r, i} }{\\partial {n_j} } \\frac{\\text{d} X }{\\text{d} P_{r, i} } \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = F_{i} \\frac{\\partial P_{r, i} }{\\partial P } \\frac{\\text{d} X }{\\text{d} P_{r, i} } \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}\\end{dmath} \nWhere\n\\begin{dmath} \\frac{\\text{d} X }{\\text{d} P_{r, i} } = - \\frac{2 X^{2} \\log{\\left (P_{r, i} \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial X}{\\partial n_j} = \\frac{\\partial P_{r, i} }{\\partial {n_j} } \\frac{\\text{d} X }{\\text{d} P_{r, i} }\\end{dmath} \nAnd\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = F_{i} \\Theta_{F_i, \\partial T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = \\frac{F_{i} k_{0, i} \\Theta_{F_i, \\partial n_j}}{k_{\\infty, i} V} \\bar{\\theta}_{P_{r, i}, \\partial n_j}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = F_{i} \\Theta_{F_i, \\partial P}\\end{dmath} \nWhere\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{X \\left(\\frac{\\operatorname{exp}\\left({- \\frac{T}{c}}\\right)}{c} - \\frac{a b}{T^{2}} \\operatorname{exp}\\left({- \\frac{b}{T}}\\right)\\right)}{a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right)} + \\frac{e}{T} - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (P_{r, i} \\right )}\\end{dmath} \n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (P_{r, i} \\right )}\\end{dmath} \n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 X^{2} \\bar{\\theta}_{P_{r, i}, \\partial P} \\log{\\left (P_{r, i} \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}\\end{dmath} \nSimplifying:\n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial T } = F_{i} \\Theta_{F_i, \\partial T}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial {n_j} } = \\frac{F_{i} k_{0, i} \\Theta_{F_i, \\partial n_j}}{k_{\\infty, i} V} \\bar{\\theta}_{P_{r, i}, \\partial n_j}\\end{dmath} \n\\begin{dmath} \\frac{\\partial F_{i} }{\\partial P } = F_{i} \\Theta_{F_i, \\partial P}\\end{dmath} \nWhere:\n\\begin{dgroup}\n\\begin{dmath} \\Theta_{F_i, \\partial T} = 0\\text{\\quad if Lindemann}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{B_{Troe}}{F_{cent} P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}} \\left(2 A_{Troe} F_{cent} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (F_{cent} \\right )} + P_{r, i} \\frac{\\text{d} F_{cent} }{\\text{d} T } \\left(2 A_{Troe} \\left(1.1762 A_{Troe} - 0.67 B_{Troe}\\right) \\log{\\left (F_{cent} \\right )} - B_{Troe} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right) \\log{\\left (10 \\right )}\\right)\\right)\\text{\\quad if Troe}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{X \\left(\\frac{\\operatorname{exp}\\left({- \\frac{T}{c}}\\right)}{c} - \\frac{a b}{T^{2}} \\operatorname{exp}\\left({- \\frac{b}{T}}\\right)\\right)}{a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right)} + \\frac{e}{T} - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (P_{r, i} \\right )}\\text{\\quad if SRI}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = 0\\text{\\quad if Lindemann}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 A_{Troe} B_{Troe} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\text{\\quad if Troe}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (P_{r, i} \\right )}\\text{\\quad if SRI}\\end{dmath}\n\\end{dgroup}\n\\begin{dgroup}\n\\begin{dmath} \\Theta_{F_i, \\partial P} = 0\\text{\\quad if Lindemann}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 A_{Troe} B_{Troe} \\bar{\\theta}_{P_{r, i}, \\partial P} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\text{\\quad if Troe}\\end{dmath}\n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 X^{2} \\bar{\\theta}_{P_{r, i}, \\partial P} \\log{\\left (P_{r, i} \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}\\text{\\quad if SRI}\\end{dmath}\n\\end{dgroup}\n\\subsection{Unimolecular/recombination fall-off reactions (complete)}\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = \\frac{F_{i} \\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1} + \\left(- \\frac{P_{r, i} \\Theta_{P_{r,i}, \\partial T}}{P_{r, i} + 1} + \\Theta_{F_i, \\partial T} + \\Theta_{P_{r,i}, \\partial T} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1}\\right) c_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{k_{0, i} \\bar{\\theta}_{P_{r, i}, \\partial n_j}}{k_{\\infty, i} V \\left(P_{r, i} + 1\\right)} \\left(F_{i} \\left(P_{r, i} \\Theta_{F_i, \\partial n_j} + 1\\right) - c_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\frac{F_{i} \\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1} + \\left(\\Theta_{F_i, \\partial P} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1}\\right) c_{i}\\end{dmath} \n\\subsection{Chemically-activated bimolecular reactions (complete)}\n\\begin{dmath} \\frac{\\partial c }{\\partial T }_{i} = \\left(- \\frac{P_{r, i} \\Theta_{P_{r,i}, \\partial T}}{P_{r, i} + 1} + \\Theta_{F_i, \\partial T} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1}\\right) c_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial {n_j} }_{i} = \\frac{k_{0, i} \\bar{\\theta}_{P_{r, i}, \\partial n_j} \\left(F_{i} \\Theta_{F_i, \\partial n_j} - c_{i}\\right)}{k_{\\infty, i} V \\left(P_{r, i} + 1\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial c }{\\partial P }_{i} = \\left(\\Theta_{F_i, \\partial P} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1}\\right) c_{i}\\end{dmath} \n\\section{Pressure-dependent reaction derivatives}\nFor PLog reactions\n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\left(\\frac{1}{k_{1}} \\frac{\\text{d} k_1 }{\\text{d} T } + \\frac{1}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} \\left(- \\frac{1}{k_{1}} \\frac{\\text{d} k_1 }{\\text{d} T } + \\frac{1}{k_{2}} \\frac{\\text{d} k_2 }{\\text{d} T }\\right) \\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right)\\right) {k_f}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\left(\\frac{1}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} \\left(- \\frac{1}{T} \\left(\\beta_1 + \\frac{E_{a_1}}{T \\Ru}\\right) + \\frac{1}{T} \\left(\\beta_2 + \\frac{E_{a_2}}{T \\Ru}\\right)\\right) \\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) + \\frac{1}{T} \\left(\\beta_1 + \\frac{E_{a_1}}{T \\Ru}\\right)\\right) {k_f}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\frac{{k_f}_{i}}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial T }_{i} = - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_r} }{\\text{d} T }_{i} = \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\right) {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial T }_{i} = \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\right) {R_r}_{i} - \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial T }_{i} = - \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\right) {R_r}_{i} + \\frac{[C]}{T} \\left(S^{\\prime\\prime}_{\\ns} {k_r}_{i} - S^{\\prime}_{\\ns} {k_f}_{i}\\right) + \\frac{{R_f}_{i}}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_f} }{\\partial P }_{i} = \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) {k_f}_{i}}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru} + \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) {R_f}_{i}}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_r} }{\\partial P }_{i} = \\frac{1}{{K_c}_{i}} \\frac{\\partial {k_f} }{\\partial P }_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_r} }{\\partial P }_{i} = \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) {k_r}_{i}}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) {R_r}_{i}}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial P }_{i} = \\frac{1}{T \\Ru} \\left(- S^{\\prime\\prime}_{\\ns} {k_r}_{i} + S^{\\prime}_{\\ns} {k_f}_{i}\\right) + \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) \\left({R_f}_{i} - {R_r}_{i}\\right)}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \nFor Chebyshev reactions\n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\log{\\left (10 \\right )} {k_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{\\text{d} \\tilde{T} }{\\text{d} T } \\left(j - 1\\right) T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_f} }{\\text{d} T }_{i} = \\log{\\left (10 \\right )} {k_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} - \\frac{2 T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\left(j - 1\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial T }_{i} = \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} - \\frac{2 T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\left(j - 1\\right) - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} {k_r} }{\\text{d} T }_{i} = - \\left(\\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{2 \\log{\\left (10 \\right )}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\left(j - 1\\right) T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}\\right) {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial T }_{i} = - \\left(\\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{2 \\log{\\left (10 \\right )}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\left(j - 1\\right) T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}\\right) {R_r}_{i} - \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial T }_{i} = \\left(\\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{2 \\log{\\left (10 \\right )}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\left(j - 1\\right) T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}\\right) {R_r}_{i} + \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} - \\frac{2 T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\left(j - 1\\right) + \\frac{[C]}{T} \\left(S^{\\prime\\prime}_{\\ns} {k_r}_{i} - S^{\\prime}_{\\ns} {k_f}_{i}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_f} }{\\partial P }_{i} = \\log{\\left (10 \\right )} {k_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{\\text{d} \\tilde{P} }{\\text{d} P } \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_f} }{\\partial P }_{i} = \\log{\\left (10 \\right )} {k_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_f} }{\\partial P }_{i} = \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {k_r} }{\\partial P }_{i} = \\log{\\left (10 \\right )} {k_r}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)}\\end{dmath} \n\\begin{dmath} \\frac{\\partial {R_r} }{\\partial P }_{i} = \\log{\\left (10 \\right )} {R_r}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} + \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru}\\end{dmath} \n\\begin{dmath} \\frac{\\partial R }{\\partial P }_{i} = \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} - \\log{\\left (10 \\right )} {R_r}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} + \\frac{1}{T \\Ru} \\left(- S^{\\prime\\prime}_{\\ns} {k_r}_{i} + S^{\\prime}_{\\ns} {k_f}_{i}\\right)\\end{dmath} \n\\section{Jacobian entries}\n\\subsection{Energy Equation}\n\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}}{\\left(\\frac{P}{T \\Ru} - \\sum_{k=1}^{-1 + \\ns} [C]_{k}\\right) {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} [C]_{k} {C_v}_{k}}\\end{dmath} \n\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}}{[C] {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}}\\end{dmath} \n\\subsection{\\texorpdfstring{$\\dot{T}$}{dTdt} Derivatives}\nMolar derivative\n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{n_j}} = - \\frac{\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}}{[C] {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} - \\left({C_v}_{\\ns} - {C_v}_{k}\\right) [C]_{k}} + \\frac{\\left(\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\right) \\sum_{k=1}^{-1 + \\ns} - \\frac{\\delta_{j k}}{V} \\left({C_v}_{\\ns} - {C_v}_{k}\\right)}{\\left([C] {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} - \\left({C_v}_{\\ns} - {C_v}_{k}\\right) [C]_{k}\\right)^{2}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{n_j}} = \\frac{1}{\\left(\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}\\right)^{2}} \\left(\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\right) \\sum_{k=1}^{-1 + \\ns} - \\frac{\\delta_{j k}}{V} \\left({C_v}_{\\ns} - {C_v}_{k}\\right) - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{n_j}} = \\frac{1}{V \\left(\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}\\right)^{2}} \\left(- {C_v}_{\\ns} + {C_v}_{j}\\right) \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k} - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{n_j}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(- \\frac{1}{V} \\frac{\\text{d} T }{\\text{d} t } \\left(- {C_v}_{\\ns} + {C_v}_{j}\\right) - \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}\\right)\\end{dmath} \nTemperature derivative\n\\begin{dmath} \\frac{\\text{d} T }{\\text{d} t } = - \\frac{\\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}}{\\frac{P {C_v}_{\\ns}}{T \\Ru} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = - \\frac{1}{\\frac{P {C_v}_{\\ns}}{T \\Ru} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right) - \\frac{1}{\\left(\\frac{P {C_v}_{\\ns}}{T \\Ru} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}\\right)^{2}} \\left(- \\frac{P}{T \\Ru} \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{P {C_v}_{\\ns}}{T^{2} \\Ru} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k}\\right) \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = - \\frac{1}{[C] {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right) - \\frac{1}{\\left([C] {C_v}_{\\ns} + \\sum_{k=1}^{-1 + \\ns} \\left(- {C_v}_{\\ns} + {C_v}_{k}\\right) [C]_{k}\\right)^{2}} \\left(- [C] \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k} + \\frac{[C] {C_v}_{\\ns}}{T}\\right) \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = - \\frac{1}{\\left(\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}\\right)^{2}} \\left(- [C] \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k} + \\frac{[C] {C_v}_{\\ns}}{T}\\right) \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k} - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = - \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(- [C] \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k} + \\frac{[C] {C_v}_{\\ns}}{T}\\right) \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\dot{\\omega}_{k} + \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{\\text{d} T }{\\text{d} t } \\left(- [C] \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k} + \\frac{[C] {C_v}_{\\ns}}{T}\\right) - \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{\\text{d} T }{\\text{d} t } \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} \\sum_{k=1}^{\\ns} [C]_{k} - \\sum_{k=1}^{-1 + \\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{\\ns} + \\frac{\\text{d} {C_v} }{\\text{d} T }_{k}\\right) [C]_{k} + \\frac{{C_v}_{\\ns}}{T} \\sum_{k=1}^{\\ns} [C]_{k}\\right) - \\sum_{k=1}^{-1 + \\ns} \\left(\\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(\\frac{\\text{d} U }{\\text{d} T }_{k} - \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{\\text{d} T }{\\text{d} t } \\sum_{k=1}^{\\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{k} + \\frac{{C_v}_{\\ns}}{T}\\right) [C]_{k} + \\sum_{k=1}^{-1 + \\ns} \\left(\\left(- U_{k} + \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(- \\frac{\\text{d} U }{\\text{d} T }_{k} + \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{T}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{\\text{d} T }{\\text{d} t } \\sum_{k=1}^{\\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{k} + \\frac{{C_v}_{\\ns}}{T}\\right) [C]_{k} + \\sum_{k=1}^{-1 + \\ns} \\left(\\left(- U_{k} + \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\left(- {C_v}_{k} + \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \nPressure Derivative\n\\begin{dmath} \\frac{\\partial\\dot{T}}{\\partial{P}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(- \\sum_{k=1}^{-1 + \\ns} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial P }_{k} - \\frac{{C_v}_{\\ns}}{T \\Ru} \\frac{\\text{d} T }{\\text{d} t }\\right)\\end{dmath} \n\\subsection{\\texorpdfstring{$\\dot{P}$}{dPdt} Derivatives}\nTemperature Derivative\n\\begin{dmath} \\frac{\\partial \\dot{ P } }{\\partial T } = \\frac{P}{T} \\left(\\frac{\\text{d} \\dot{T} }{\\text{d} T } - \\frac{1}{T} \\frac{\\text{d} T }{\\text{d} t }\\right) + \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\left(T \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k} + \\dot{\\omega}_{k}\\right)\\end{dmath} \nMolar Derivative\n\\begin{dmath} \\frac{\\partial \\dot{ P } }{\\partial {n_j} } = \\frac{P}{T} \\frac{\\text{d} \\dot{T} }{\\text{d} {n_j} } + T \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}\\end{dmath} \nPressure Derivative\n\\begin{dmath} \\frac{\\partial \\dot{ P } }{\\partial P } = T \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{\\omega} }{\\partial P }_{k} + \\frac{1}{T} \\left(P \\frac{\\text{d} \\dot{T} }{\\text{d} P } + \\dot{T}\\right)\\end{dmath} \n\\subsection{\\texorpdfstring{$\\dot{n_k}$}{dnkdt} Derivatives}\n\\begin{dmath} \\frac{\\partial \\dot{n} }{\\partial {n_j} }_{k} = V \\frac{\\partial \\dot{\\omega} }{\\partial {n_j} }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial \\dot{n} }{\\partial T }_{k} = V \\frac{\\partial \\dot{\\omega} }{\\partial T }_{k}\\end{dmath} \n\\begin{dmath} \\frac{\\partial \\dot{n} }{\\partial P }_{k} = V \\frac{\\partial \\dot{\\omega} }{\\partial P }_{k}\\end{dmath} \n\\section{Jacobian Update Form}\n\\subsection{Temperature Derivatives}\n\\begin{dmath} \\mathcal{J}_{1,1} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(\\frac{\\text{d} T }{\\text{d} t } \\sum_{k=1}^{\\ns} \\left(- \\frac{\\text{d} {C_v} }{\\text{d} T }_{k} + \\frac{{C_v}_{\\ns}}{T}\\right) [C]_{k} + \\sum_{k=1}^{-1 + \\ns} \\left(\\frac{1}{V} \\left(- U_{k} + \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{n} }{\\partial T }_{k} + \\left(- {C_v}_{k} + \\frac{W_{k}}{W_{\\ns}} \\frac{\\text{d} U }{\\text{d} T }_{\\ns}\\right) \\dot{\\omega}_{k}\\right)\\right)\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{2,1} = \\frac{P}{T} \\left(\\frac{\\text{d} \\dot{T} }{\\text{d} T } - \\frac{1}{T} \\frac{\\text{d} T }{\\text{d} t }\\right) + \\Ru \\sum_{k=1}^{-1 + \\ns} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\left(\\frac{T}{V} \\frac{\\partial \\dot{n} }{\\partial T }_{k} + \\dot{\\omega}_{k}\\right)\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{k + 2,1} = V \\sum_{i=1}^{\\nr} \\nu_{k,i} \\frac{\\partial q }{\\partial T }_{i}\\end{dmath} \nConverting to update form:\n\\begin{dmath} \\mathcal{J}_{k + 2,1}\\pluseq V \\nu_{k,i} \\frac{\\partial q }{\\partial T }_{i}\\text{\\quad} k = 1, \\ldots, N_{sp} - 1\\end{dmath} \n\\subsubsection{Explicit reversible reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i} c_{i} + R_{i} \\frac{\\partial c }{\\partial T }_{i}\\end{dmath} \n\\begin{dmath} \\Theta_{\\partial T, i} = \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i} - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right) - \\frac{{R_r}_{i}}{T} \\left({\\beta_r}_{i} + \\frac{{E_{a,r}}_{i}}{T \\Ru}\\right)\\end{dmath} \n\\subsubsection{Non-explicit reversible reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i} c_{i} + R_{i} \\frac{\\partial c }{\\partial T }_{i}\\end{dmath} \n\\begin{dmath} \\Theta_{\\partial T, i} = - \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\right) {R_r}_{i} + \\frac{[C] S^{\\prime\\prime}_{\\ns}}{T} {k_r}_{i} - \\frac{[C] S^{\\prime}_{\\ns}}{T} {k_f}_{i} + \\frac{{R_f}_{i}}{T} \\left(\\beta_{i} + \\frac{{E_{a}}_{i}}{T \\Ru}\\right)\\end{dmath} \n\\subsubsection{Pressure-dependent reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i}\\end{dmath} \nFor PLog reactions:\n\\begin{dmath} \\Theta_{\\partial T, i} = - \\left(- \\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{1}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\right) {R_r}_{i} + \\frac{[C]}{T} \\left(S^{\\prime\\prime}_{\\ns} {k_r}_{i} - S^{\\prime}_{\\ns} {k_f}_{i}\\right) + \\frac{{R_f}_{i}}{T} \\left(\\beta_1 + \\frac{\\left(\\log{\\left (P \\right )} - \\log{\\left (P_{1} \\right )}\\right) \\left(- \\beta_1 + \\beta_2 - \\frac{E_{a_1}}{T \\Ru} + \\frac{E_{a_2}}{T \\Ru}\\right)}{- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}} + \\frac{E_{a_1}}{T \\Ru}\\right)\\end{dmath} \nFor Chebyshev reactions:\n\\begin{dmath} \\Theta_{\\partial T, i} = \\left(\\sum_{k=1}^{\\ns} \\nu_{k,i} \\frac{\\text{d} B }{\\text{d} T }_{k} + \\frac{2 \\log{\\left (10 \\right )}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\left(j - 1\\right) T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}\\right) {R_r}_{i} + \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} - \\frac{2 T_{l - 1}\\left(\\tilde{P}\\right) U_{j - 2}\\left(\\tilde{T}\\right) \\eta_{l,j}}{T^{2} \\left(- \\frac{1}{T_{min}} + \\frac{1}{T_{max}}\\right)} \\left(j - 1\\right) + \\frac{[C]}{T} \\left(S^{\\prime\\prime}_{\\ns} {k_r}_{i} - S^{\\prime}_{\\ns} {k_f}_{i}\\right)\\end{dmath} \n\\subsubsection{Pressure independent reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i}\\end{dmath} \n\\subsubsection{Third-body enhanced reactions}\nFor mixture as third-body:\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = [X]_{i} \\Theta_{\\partial T, i} - \\frac{[C] \\alpha_{\\ns,i}}{T} R_{i}\\end{dmath} \nFor species $m$ as third-body:\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i} \\left(\\left(- \\delta_{\\ns m} + 1\\right) [C]_{m} + \\delta_{\\ns m} [C]_{\\ns}\\right) - \\frac{\\delta_{\\ns m}}{T} [C] R_{i}\\end{dmath} \nIf all $\\alpha_{j,i} = 1$ for all species j:\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = [C] \\left(\\Theta_{\\partial T, i} - \\frac{R_{i}}{T}\\right)\\end{dmath} \n\\subsubsection{Unimolecular\\slash recombination fall-off reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\Theta_{\\partial T, i} c_{i} + \\left(\\frac{F_{i} \\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1} + \\left(- \\frac{P_{r, i} \\Theta_{P_{r,i}, \\partial T}}{P_{r, i} + 1} + \\Theta_{F_i, \\partial T} + \\Theta_{P_{r,i}, \\partial T} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1}\\right) c_{i}\\right) R_{i}\\end{dmath} \n\\subsubsection{Chemically-activated bimolecular reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial T }_{i} = \\left(\\Theta_{\\partial T, i} + \\left(- \\frac{P_{r, i} \\Theta_{P_{r,i}, \\partial T}}{P_{r, i} + 1} + \\Theta_{F_i, \\partial T} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial T}}{P_{r, i} + 1}\\right) R_{i}\\right) c_{i}\\end{dmath} \n\\subsubsection{Reduced Pressure Derivatives}\nFor mixture as third-body:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = - \\frac{[C] k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i}}\\end{dmath} \nFor species $m$ as third-body:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = - \\frac{[C] k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i}}\\end{dmath} \nIf all $\\alpha_{j,i} = 1$ for all species j:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial T} = \\frac{1}{T} \\left(\\beta_{0} - \\beta_{\\infty} - 1 + \\frac{E_{a, 0}}{T \\Ru} - \\frac{E_{a, \\infty}}{T \\Ru}\\right)\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial T} = 0\\end{dmath} \n\\subsubsection{Falloff Blending Function Forms}\nFor Lindemann\n\\begin{dmath} \\Theta_{F_i, \\partial T} = 0\\end{dmath} \nFor Troe\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{B_{Troe}}{F_{cent} P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}} \\left(2 A_{Troe} F_{cent} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (F_{cent} \\right )} + P_{r, i} \\frac{\\text{d} F_{cent} }{\\text{d} T } \\left(2 A_{Troe} \\left(1.1762 A_{Troe} - 0.67 B_{Troe}\\right) \\log{\\left (F_{cent} \\right )} - B_{Troe} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right) \\log{\\left (10 \\right )}\\right)\\right)\\end{dmath} \nFor SRI\n\\begin{dmath} \\Theta_{F_i, \\partial T} = - \\frac{X \\left(\\frac{\\operatorname{exp}\\left({- \\frac{T}{c}}\\right)}{c} - \\frac{a b}{T^{2}} \\operatorname{exp}\\left({- \\frac{b}{T}}\\right)\\right)}{a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right)} + \\frac{e}{T} - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\left(P_{r, i} \\Theta_{P_{r,i}, \\partial T} + \\bar{\\theta}_{P_{r, i}, \\partial T}\\right) \\log{\\left (P_{r, i} \\right )}\\end{dmath} \n\\subsection{Molar Derivatives}\n\\begin{dmath} \\mathcal{J}_{1,j + 2} = \\frac{\\partial\\dot{T}}{\\partial{n_j}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(- \\frac{1}{V} \\frac{\\text{d} T }{\\text{d} t } \\left(- {C_v}_{\\ns} + {C_v}_{j}\\right) - \\sum_{k=1}^{-1 + \\ns} \\frac{1}{V} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{n} }{\\partial {n_j} }_{k}\\right)\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{2,j + 2} = \\frac{\\partial \\dot{ P } }{\\partial {n_j} } = \\frac{P}{T} \\frac{\\text{d} \\dot{T} }{\\text{d} {n_j} } + T \\Ru \\sum_{k=1}^{-1 + \\ns} \\frac{1}{V} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{n} }{\\partial {n_j} }_{k}\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{k + 2,j + 2} = \\frac{\\partial \\dot{n_k} }{\\partial n_{j} } = V \\sum_{i=1}^{\\nr} \\nu_{k,i} \\frac{\\partial q }{\\partial {n_j} }_{i}\\end{dmath} \nConverting to Jacobian Update form:\n\\begin{dmath} \\mathcal{J}_{k + 2,j + 2}\\pluseq V \\nu_{k,i} \\frac{\\partial q }{\\partial {n_j} }_{i}\\end{dmath} \n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right) c_{i} + V R_{i} \\frac{\\partial c }{\\partial {n_j} }_{i}\\end{dmath} \n\\subsubsection{Pressure-dependent reactions}\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = \\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\end{dmath} \n\\subsubsection{Pressure independent reactions}\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = \\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\end{dmath} \n\\subsubsection{Third-body enhanced reactions}\n\\textbf{For mixture as third-body}:\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = [X]_{i} \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right) + \\left(- \\alpha_{\\ns,i} + \\alpha_{j,i}\\right) R_{i}\\end{dmath} \n\\textbf{For species $m$ as third-body}:\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = \\left(\\left(- \\delta_{\\ns m} + 1\\right) [C]_{m} + \\delta_{\\ns m} [C]_{\\ns}\\right) \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right) + \\left(- \\delta_{\\ns m} + \\delta_{j m}\\right) R_{i}\\end{dmath} \n\\textbf{If all $\\alpha_{j,i} = 1$}:\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{k} = [C] \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right)\\end{dmath} \n\\subsubsection{Falloff Reactions}\n\\textbf{Unimolecular\\slash recombination fall-off reactions}:\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{i} = \\frac{k_{0, i} \\bar{\\theta}_{P_{r, i}, \\partial n_j} R_{i}}{k_{\\infty, i} \\left(P_{r, i} + 1\\right)} \\left(F_{i} P_{r, i} \\Theta_{F_i, \\partial n_j} + F_{i} - c_{i}\\right) + \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right) c_{i}\\end{dmath} \n\\subsubsection{Chemically-activated bimolecular reactions}\n\\begin{dmath} V \\frac{\\partial q }{\\partial {n_j} }_{i} = \\frac{k_{0, i} \\bar{\\theta}_{P_{r, i}, \\partial n_j} R_{i}}{k_{\\infty, i} \\left(P_{r, i} + 1\\right)} \\left(F_{i} \\Theta_{F_i, \\partial n_j} - c_{i}\\right) + \\left(\\left(S^{\\prime\\prime}_{\\ns} - S^{\\prime\\prime}_{j}\\right) {k_r}_{i} - \\left(S^{\\prime}_{\\ns} - S^{\\prime}_{j}\\right) {k_f}_{i}\\right) c_{i}\\end{dmath} \n\\subsubsection{Reduced Pressure Derivatives}\n\\textbf{For mixture as third-body}:\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = - \\alpha_{\\ns,i} + \\alpha_{j,i}\\end{dmath} \n\\textbf{For species $m$ as third-body}:\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = - \\delta_{\\ns m} + \\delta_{j m}\\end{dmath} \n\\textbf{If all $\\alpha_{j,i} = 1$}:\n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial n_j} = 0\\end{dmath} \n\\subsubsection{Falloff Blending Function Forms}\nFor Lindemann\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = 0\\end{dmath} \nFor Troe\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 A_{Troe} B_{Troe} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\end{dmath} \nFor SRI\n\\begin{dmath} \\Theta_{F_i, \\partial n_j} = - \\frac{2 X^{2} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (P_{r, i} \\right )}\\end{dmath} \n\\subsection{Pressure Derivatives}\n\\begin{dmath} \\mathcal{J}_{1,2} = \\frac{\\partial\\dot{T}}{\\partial{P}} = \\frac{1}{\\sum_{k=1}^{\\ns} [C]_{k} {C_v}_{k}} \\left(- \\sum_{k=1}^{-1 + \\ns} \\frac{1}{V} \\left(U_{k} - \\frac{W_{k} U_{\\ns}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{n} }{\\partial P }_{k} - \\frac{{C_v}_{\\ns}}{T \\Ru} \\frac{\\text{d} T }{\\text{d} t }\\right)\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{2,2} = \\frac{\\partial \\dot{ P } }{\\partial P } = T \\Ru \\sum_{k=1}^{-1 + \\ns} \\frac{1}{V} \\left(1 - \\frac{W_{k}}{W_{\\ns}}\\right) \\frac{\\partial \\dot{n} }{\\partial P }_{k} + \\frac{1}{T} \\left(P \\frac{\\text{d} \\dot{T} }{\\text{d} P } + \\dot{T}\\right)\\end{dmath} \n\\begin{dmath} \\mathcal{J}_{k + 2,2} = \\frac{\\partial \\dot{n_k} }{\\partial P } = V \\sum_{i=1}^{\\nr} \\nu_{k,i} \\frac{\\partial q }{\\partial P }_{i}\\end{dmath} \nConverting to Jacobian Update form:\n\\begin{dmath} \\mathcal{J}_{k + 2,2}\\pluseq V \\nu_{k,i} \\frac{\\partial q }{\\partial P }_{i}\\end{dmath} \n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = \\left(- \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) c_{i} + R_{i} \\frac{\\partial c }{\\partial P }_{i}\\end{dmath} \n\\subsubsection{Pressure-dependent reactions}\nFor PLOG:\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = \\frac{1}{T \\Ru} \\left(- S^{\\prime\\prime}_{\\ns} {k_r}_{i} + S^{\\prime}_{\\ns} {k_f}_{i}\\right) + \\frac{\\left(- \\log{\\left (k_{1} \\right )} + \\log{\\left (k_{2} \\right )}\\right) \\left({R_f}_{i} - {R_r}_{i}\\right)}{P \\left(- \\log{\\left (P_{1} \\right )} + \\log{\\left (P_{2} \\right )}\\right)}\\end{dmath} \nFor Chebyshev:\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = \\log{\\left (10 \\right )} {R_f}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} - \\log{\\left (10 \\right )} {R_r}_{i} \\sum_{\\substack{1 \\leq l \\leq N_{P}\\\\1 \\leq j \\leq N_{T}}} \\frac{2 \\left(l - 1\\right) T_{j - 1}\\left(\\tilde{T}\\right) U_{l - 2}\\left(\\tilde{P}\\right) \\eta_{l,j}}{P \\left(\\log{\\left (P_{max} \\right )} - \\log{\\left (P_{min} \\right )}\\right)} + \\frac{1}{T \\Ru} \\left(- S^{\\prime\\prime}_{\\ns} {k_r}_{i} + S^{\\prime}_{\\ns} {k_f}_{i}\\right)\\end{dmath} \n\\subsubsection{Pressure independent reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = - \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\end{dmath} \n\\subsubsection{Third-body enhanced reactions}\n\\textbf{For mixture as third-body}:\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = [X]_{i} \\left(- \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) + \\frac{\\alpha_{\\ns,i} R_{i}}{T \\Ru}\\end{dmath} \n\\textbf{For species $m$ as third-body}:\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = \\left(\\left(- \\delta_{\\ns m} + 1\\right) [C]_{m} + \\delta_{\\ns m} [C]_{\\ns}\\right) \\left(- \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) + \\frac{\\delta_{\\ns m} R_{i}}{T \\Ru}\\end{dmath} \n\\textbf{If all $\\alpha_{j,i} = 1$}:\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{k} = [C] \\left(- \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) + \\frac{R_{i}}{T \\Ru}\\end{dmath} \n\\subsubsection{Unimolecular/recombination fall-off reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{i} = \\left(\\frac{F_{i} \\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1} + \\left(\\Theta_{F_i, \\partial P} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1}\\right) c_{i}\\right) R_{i} + \\left(- \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) c_{i}\\end{dmath} \n\\subsubsection{Chemically-activated bimolecular reactions}\n\\begin{dmath} \\frac{\\partial q }{\\partial P }_{i} = \\left(\\left(\\Theta_{F_i, \\partial P} - \\frac{\\bar{\\theta}_{P_{r, i}, \\partial P}}{P_{r, i} + 1}\\right) R_{i} - \\frac{S^{\\prime\\prime}_{\\ns} {k_r}_{i}}{T \\Ru} + \\frac{S^{\\prime}_{\\ns} {k_f}_{i}}{T \\Ru}\\right) c_{i}\\end{dmath} \n\\subsubsection{Reduced Pressure Derivatives}\n\\textbf{For mixture as third-body}:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i} \\alpha_{\\ns,i}}{T k_{\\infty, i} \\Ru}\\end{dmath} \n\\textbf{For species $m$ as third-body}:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i} \\delta_{\\ns m}}{T k_{\\infty, i} \\Ru}\\end{dmath} \n\\textbf{If all $\\alpha_{j,i} = 1$}:\n\\begin{dmath} \\Theta_{P_{r,i}, \\partial P} = 0\\end{dmath} \n\\begin{dmath} \\bar{\\theta}_{P_{r, i}, \\partial P} = \\frac{k_{0, i}}{k_{\\infty, i}} \\frac{\\partial [C] }{\\partial P }\\end{dmath} \n\\subsubsection{Falloff Blending Function Forms}\nFor Lindemann\n\\begin{dmath} \\Theta_{F_i, \\partial P} = 0\\end{dmath} \nFor Troe\n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 A_{Troe} B_{Troe} \\bar{\\theta}_{P_{r, i}, \\partial P} \\left(0.14 A_{Troe} + B_{Troe}\\right) \\log{\\left (F_{cent} \\right )}}{P_{r, i} \\left(A_{Troe}^{2} + B_{Troe}^{2}\\right)^{2} \\log{\\left (10 \\right )}}\\end{dmath} \nFor SRI\n\\begin{dmath} \\Theta_{F_i, \\partial P} = - \\frac{2 X^{2} \\bar{\\theta}_{P_{r, i}, \\partial P} \\log{\\left (P_{r, i} \\right )}}{P_{r, i} \\log^{2}{\\left (10 \\right )}} \\log{\\left (a \\operatorname{exp}\\left({- \\frac{b}{T}}\\right) + \\operatorname{exp}\\left({- \\frac{T}{c}}\\right) \\right )}\\end{dmath} \n\\end{document}\n", "meta": {"hexsha": "f912db139dfd306d24bf75dbedeb6931b82ad1b2", "size": 83009, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "derivations/tex/conv_derivation.tex", "max_stars_repo_name": "arghdos/SPyJac-paper", "max_stars_repo_head_hexsha": "7f65253a3acd3a93141e673c2cdd5810ecc6a0ca", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-31T23:56:50.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-31T23:56:50.000Z", "max_issues_repo_path": "derivations/tex/conv_derivation.tex", "max_issues_repo_name": "arghdos/SPyJac-paper", "max_issues_repo_head_hexsha": "7f65253a3acd3a93141e673c2cdd5810ecc6a0ca", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "derivations/tex/conv_derivation.tex", "max_forks_repo_name": "arghdos/SPyJac-paper", "max_forks_repo_head_hexsha": "7f65253a3acd3a93141e673c2cdd5810ecc6a0ca", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 153.7203703704, "max_line_length": 893, "alphanum_fraction": 0.5747087665, "num_tokens": 38736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5506073655352403, "lm_q1q2_score": 0.4188198519633028}}
{"text": "\\section{History of the Algorithms} \\label{sec:history}\nBack when I was a young naive programmer, I made a thing. Now a few years down the line I made the thing again, but infinitely better. So I have no use for the old thing anymore. But fear not,\nold algorithms (used by CLAuDE) will be collected here. This is just for historical purposes.\n\n\\subsection{Radiation}\n\\subsubsection{Adding Layers}\nRemember \\autoref{eq:atmos change}? We need this equation for every layer in the atmosphere. This also means that we have to adjust the main calculation of the code, which is described  in \n\\autoref{alg:temperature with density}. The $T_a$ needs to change, we need to either add a dimension (to indicate which layer of the atmosphere we are talking about) or we need to add different\nmatrices for each atmosphere layer. We opt for adding a dimension as that costs less memory than defining new arrays \n\\footnote{This has to do with pointers, creating a new object always costs a bit more space than adding a dimension as we need a pointer to the object and what type of object it is whereas with \nadding a dimension we do not need this additional information as it has already been defined}. So $T_a$, and all other matrices that have to do with the atmosphere (so not $T_p$ for instance) \nare no longer indexed by $lat, lon$ but are indexed by $lat, lon, layer$. We need to account for one more thing, the absorbtion of energy from another layer. The new equation is shown in \n\\autoref{eq:atmos change layer}. Here $k$ is the layer of the atmosphere, $k = -1$ means that you use $T_p$ and $k = nlevels$ means that $T_{a_{nlevels}} = 0$ as that is space. Also, let us\nrewrite the equation a bit such that the variables that are repeated are only written once and stuff that is divided out is removed, which is done in \\autoref{eq:atmos change layer improved}.\nLet us also clean up the equation for the change in the surface temperature (\\autoref{eq:surface change}) in \\autoref{eq:surface change improved}.\n\n\\begin{subequations}\n    \\begin{equation}\n        \\label{eq:atmos change layer}\n        \\Delta T_{a_k} = \\frac{\\delta t (\\sigma \\epsilon_{k - 1}T_{a_{k - 1}}^4 + \\sigma \\epsilon_{k + 1}T_{a_{k + 1}}^4 - 2\\epsilon_k\\sigma T_{a_k}^4)}{C_a}\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:atmos change layer improved}\n        \\Delta T_{a_k} = \\frac{\\delta t \\sigma (\\epsilon_{k - 1}T_{a_{k - 1}}^4 + \\epsilon_{k + 1}T_{a_{k + 1}}^4 - 2\\epsilon_kT_{a_k}^4)}{C_a}\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:surface change improved}\n        \\Delta T_p = \\frac{\\delta t (S + \\sigma(4\\epsilon_pT_a^4 - 4T_p^4))}{4C_p}\n    \\end{equation}\n\\end{subequations}\n\nWith the changes made to the equation, we need to make those changes in the code as well. We need to add the new dimension to all matrices except $T_p$ and $a$ as they are unaffected (with \nregards to the storage of the values) by the addition of multiple atmospheric layers. Every other matrix is affected. The new code can be found in \\autoref{alg:temperature layer}. $\\delta z$\n\n\\begin{algorithm}[hbt]\n    \\caption{The main function for the temperature calculations}\n    \\label{alg:temperature layer}\n    \\SetAlgoLined\n    \\SetKwInput{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{amount of energy that hits the planet $S$}\n    \\Output{Temperature of the planet $T_p$, temperature of the atmosphere $T_a$}\n    \\For{$lat \\leftarrow -nlat$ \\KwTo $nlat$}{\n        \\For{$lon \\leftarrow 0$ \\KwTo $nlot$}{\n            \\For{$layer \\leftarrow 0$ \\KwTo $nlevels$}{\n                $T_p[lat, lon] \\leftarrow T_p[lat, lon] + \\frac{\\delta t ((1 - a[lat, lon])S + \\sigma(4\\epsilon[0](T_a[lat, lon, 0])^4 - 4(T_p[lat, lon])^4))}\n                {4C_p[lat, lon]}$ \\;\n                \\uIf{$layer = 0$}{\n                    $T_a[lat, lon, layer] \\leftarrow T_a[lat, lon, layer] + \\frac{\\delta t \\sigma((T_p[lat, lon])^4 - 2\\epsilon[layer](T_a[lat, lon, layer])^4)}\n                    {\\rho[lat, lon, layer]C_a\\delta z[layer]}$ \\;\n                }\\uElseIf{$layer = nlevels - 1$}{\n                    $T_a[lat, lon, layer] \\leftarrow T_a[lat, lon, layer] + \\frac{\\delta t \\sigma(\\epsilon[layer - 1](T_a[lat, lon, layer - 1])^4 - 2\\epsilon[layer](T_a[lat, lon, layer])^4)}\n                    {\\rho[lat, lon, layer]C_a\\delta z[layer]}$ \\;\n                }\\uElse{\n                    $T_a[lat, lon, layer] \\leftarrow T_a[lat, lon, layer] + \\frac{\\delta t \\sigma(\\epsilon[layer - 1](T_a[lat, lon, layer - 1])^4 + \\epsilon[layer + 1]T_a[lat, lon, layer + 1] \n                    - 2\\epsilon[layer](T_a[lat, lon, layer])^4)}{\\rho[lat, lon, layer]C_a\\delta z[layer]}$ \\;\n                }\n            }\n        }\n    }\n\\end{algorithm}\n\nWe also need to initialise the $\\epsilon$ value for each layer. We do that in \\autoref{alg:epsilon}.\n\n\\begin{algorithm}\n    \\caption{Intialisation of the insulation of each layer (also known as $\\epsilon$)}\n    \\label{alg:epsilon}\n    $\\epsilon[0] \\leftarrow 0.75$ \\;\n    \\For{$i \\leftarrow 1$ \\KwTo $nlevels$}{\n        $\\epsilon[i] \\leftarrow 0.5\\epsilon[i - 1]$\n    }\n\\end{algorithm}\n\n\\subsection{Velocity}\n\\subsubsection{The Primitive Equations and Geostrophy} \\label{sec:primitive}\nThe primitive equations (also known as the momentum equations) is what makes the air move. It is actually kind of an injoke between physicists as they are called the primitive equations but \nactually look quite complicated (and it says $fu$ at the end! \\cite{simon}). The primitive equations are a set of equations dictating the direction in the $u$ and $v$ directions as shown in \n\\autoref{eq:primitive u} and \\autoref{eq:primitive v}. We can make the equations simpler by using and approximation called geostrophy which means that we have no vertical motion, such that the\nterms with $\\omega$ in \\autoref{eq:primitive u} and \\autoref{eq:primitive v} become 0. We also assume that we are in a steady state, i.e. there is no acceleration which in turn means that the \nwhole middle part of the equations are $0$. Hence we are left with \\autoref{eq:primitive u final} and \\autoref{eq:primitive v final}.\n\n\\begin{subequations}\n    \\begin{equation}\n        \\label{eq:primitive u}\n        \\frac{du}{dt} = \\frac{\\delta u}{\\delta t} + u\\frac{\\delta u}{ \\delta x} + v\\frac{\\delta u}{\\delta v} + \\omega\\frac{\\delta u}{\\delta p} = -\\frac{\\delta \\Phi}{\\delta x} + fv\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:primitive v}\n        \\frac{dv}{dt} = \\frac{\\delta v}{\\delta t} + u\\frac{\\delta v}{ \\delta x} + v\\frac{\\delta v}{\\delta v} + \\omega\\frac{\\delta v}{\\delta p} = -\\frac{\\delta \\Phi}{\\delta y} - fu\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:primitive u final}\n        0 = -\\frac{\\delta \\Phi}{\\delta x} + fv\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:primitive v final}\n        0 = -\\frac{\\delta \\Phi}{\\delta y} - fu\n    \\end{equation}\n\\end{subequations}\n\n\\autoref{eq:primitive u final} can be split up into to parts, the $\\frac{\\delta \\Phi}{\\delta x}$ part (the gradient force) and the $fv$ part (the coriolis force). The same applies to \n\\autoref{eq:primitive v final}. Effectively we have a balance between the gradient and the coriolis force as shown in \\autoref{eq:pu simple} and \\autoref{eq:pv simple}. The symbols in both of \nthese equations are:\n\n\\begin{itemize}\n    \\item $\\Phi$: The geopotential, potential (more explanation in \\autoref{sec:potential}) of the planet's gravity field ($Jkg^{-1}$).\n    \\item $x$: The change in the East direction along the planet surface ($m$).\n    \\item $y$: The change in the North direction along the planet surface ($m$).\n    \\item $f$: The coriolis parameter as described by \\autoref{eq:coriolis}, where $\\Omega$ is the rotation rate of the planet (for Earth $7.2921 \\cdot 10^{-5}$) ($rad \\ s^{-1}$) and $\\theta$ is the \n    latitude \\cite{coriolis}.\n    \\item $u$: The velocity in the latitude ($ms^{-1}$).\n    \\item $v$: The velocity in the longitude ($ms^{-1}$).\n\\end{itemize}\n\n\\begin{subequations}\n    \\begin{equation}\n        \\label{eq:coriolis}\n        f = 2\\Omega\\sin(\\theta)\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:pu simple}\n        \\frac{\\delta \\Phi}{\\delta x} = fv\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:pv simple}\n        \\frac{\\delta \\Phi}{\\delta y} = -fu\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:pu simple final}\n        \\frac{\\delta p}{\\rho \\delta x} = fv\n    \\end{equation}\n    \\begin{equation}\n        \\label{eq:pv simple final}\n        \\frac{\\delta p}{\\rho \\delta y} = -fu\n    \\end{equation}\n\\end{subequations}\n\nSince we want to know how the atmosphere moves, we want to get the v and u components of the velocity vector (since $v$ and $u$ are the veolicites in longitude and latitude, if we combine them \nin a vector we get the direction of the overall velocity). So it is time to start coding and calculating! If we look back at \\autoref{alg:stream1v2}, we can see that we already have a double \nfor loop. In computer science, having multiple loops is generally considered a bad coding practice as you usually can just reuse the indices of the already existing loop, so you do not need to \ncreate a new one. However this is a special case, since we are calculating new temperatures in the double for loop. If we then also would start to calculate the velocities then we would use new \ninformation and old information at the same time. Since at index $i - 1$ the new temperature has already been calculated, but at the index $i + 1$ the old one is still there. So in order to fix \nthat we need a second double for loop to ensure that we always use the new temperatures. We display this specific loop in \\autoref{alg:stream2}. Do note that everything in \\autoref{alg:stream1v2} \nis still defined and can still be used, but since we want to focus on the new code, we leave out the old code to keep it concise and to prevent clutter. \n\n\\begin{algorithm}[hbt]\n    \\caption{The main loop of the velocity of the atmosphere calculations}\n    \\label{alg:stream2}\n    \\SetAlgoLined\n    \\For{$lat \\in [-nlat, nlat]$}{\n        \\For{$lon \\in [0, nlon]$}{\n            $u[lat, lon] \\leftarrow -\\frac{p[lat + 1, lon] - p[lat - 1, lon]}{\\delta y} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n            $v[lat, lon] \\leftarrow \\frac{p[lat, lon + 1] - p[lat, lon - 1]}{\\delta x[lat]} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n        }\n    }\n\\end{algorithm}\n\nThe gradient calculation is done in \\autoref{alg:gradient}. For this to work, we need the circumference of the planet. Herefore we need to assume that the planet is a sphere. While that is not \ntechnically true, it makes little difference in practice and is good enough for our model. The equation for the circumference can be found in \\autoref{eq:circumference} \\cite{circumference}, \nwhere $r$ is the radius of the planet. Here we also use the f-plane approximation, where the coriolis paramter has one value for the northern hemisphere and one value for the southern hemisphere \n\\cite{fplane}.\n\n\\begin{equation}\n    \\label{eq:circumference}\n    2 \\pi r\n\\end{equation}\n\n\\begin{algorithm}\n    \\caption{Calculating the gradient $\\delta x$ (note that this algorithm is obsolete)}\n    \\label{alg:gradient}\n    \\SetAlgoLined\n    $C \\leftarrow 2\\pi R$ \\;\n    $\\delta y \\leftarrow \\frac{C}{nlat}$ \\;\n\n    \\For{$lat \\in [-nlat, nlat]$}{\n        $\\delta x[lat] \\leftarrow \\delta y \\cos(lat \\cdot \\frac{\\pi}{180})$ \\;\n\n        \\eIf{$lat < 0$}{\n            $f[lat] \\leftarrow -10^{-4}$ \\;\n        }{\n            $f[lat] \\leftarrow 10^{-4}$ \\;\n        }\n    }\n\\end{algorithm}\n\nBecause of the geometry of the planet and the construction of the longitude latitude grid, we run into some problems when calculating the gradient. Since the planet is not flat (\"controversial \nI know\"\\cite{simon}) whenever we reach the end of the longitude we need to loop around to get to the right spot to calculate the gradients (as the planet does not stop at the end of the \nlongitude line but loops around). So to fix that we use the modulus (mod) function which does the looping for us if we exceed the grid's boundaries. We do haveanother problem though, the poles. \nAs the latitude grows closer to the poles, they are converging on the center point of the pole. Looping around there is much more difficult so to fix it, we just do not consider that center \npoint in the main loop. The changed algorithm can be found in \\autoref{alg:stream2v2}\n\n\\begin{algorithm}[hbt]\n    \\caption{The main loop of the velocity of the atmosphere calculations}\n    \\label{alg:stream2v2}\n    \\SetAlgoLined\n    \\For{$lat \\in [-nlat + 1, nlat - 1]$}{\n        \\For{$lon \\in [0, nlon]$}{\n            $u[lat, lon] \\leftarrow -\\frac{p[(lat + 1) \\text{ mod } nlat, lon] - p[(lat -1) \\text{ mod } nlat, lon]}{\\delta y} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n            $v[lat, lon] \\leftarrow \\frac{p[lat, (lon + 1) \\text{ mod } nlon] - p[lat, (lon -1) \\text{ mod } nlon]}{\\delta x[lat]} \\cdot \\frac{1}{f[lat]\\rho}$ \\;\n        }\n    }\n\\end{algorithm}\n\nDo note that the pressure calculation is done between the temperature calculation in \\autoref{alg:stream1v2} and the $u, v$ calculations in \\autoref{alg:stream2v2}. At this point our model shows\na symmetric vortex around the sun that moves with the sun. This is not very realistic as you usually have convection and air flowing from warm to cold, but we do not have that complexity yet \n(due to our single layer atmosphere).", "meta": {"hexsha": "959cf03582514a7f7d837377688ea715834c19f0", "size": 13387, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex-docs/appendices/history.tex", "max_stars_repo_name": "davleop/claude", "max_stars_repo_head_hexsha": "09ee880d502dcad8cc1a8d2fd681978b812d32dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 175, "max_stars_repo_stars_event_min_datetime": "2020-06-15T16:29:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-11T21:53:34.000Z", "max_issues_repo_path": "tex-docs/appendices/history.tex", "max_issues_repo_name": "davleop/claude", "max_issues_repo_head_hexsha": "09ee880d502dcad8cc1a8d2fd681978b812d32dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2020-06-26T06:47:47.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-08T09:17:45.000Z", "max_forks_repo_path": "tex-docs/appendices/history.tex", "max_forks_repo_name": "davleop/claude", "max_forks_repo_head_hexsha": "09ee880d502dcad8cc1a8d2fd681978b812d32dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2020-06-24T10:39:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-12T08:07:56.000Z", "avg_line_length": 64.9854368932, "max_line_length": 199, "alphanum_fraction": 0.6778964667, "num_tokens": 3938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8376199511728003, "lm_q2_score": 0.5, "lm_q1q2_score": 0.41880997558640015}}
{"text": "%!TEX root=report.tex\n\\subsection{k-means clustering}\n\\label{section:result-kmeans}\n\n\\subsubsection{Indentifing the amount of clusters}\nDue to the size of the dataset (64800, 341), and the fact multiple simulated datasets of the same size would be needed to calculate the gap-statistic it was calculated on the HPC cluster that DTU offers for students and faculty.\nIt should be noted that if such a setup had not been available, one could have used smaller subsamples of the data.\n20 simulation samples of size (64800,341) were made using a multivariate uniform distribution. The following is the plot of the resulting gap statistic with its standard deviation.\n\\begin{figure}[H]\n\t\\center\n\t\\includegraphics[width=\\textwidth]{figures/kmeans-gap}\n\t\\caption{Gap-statistics with standard deviation. Note the standard deviation is very small.}\n\t\\label{fig:kmeans-gap}\n\\end{figure}\n\nFrom Figure \\ref{fig:kmeans-gap} it is seen that according to the gap-statistics the optimal amount of cluster, is more than 20. Unfortunately such a high number of clusters are not suitable for visualization. Instead 7 clusters have been chosen; this is based on the large slope change which can be observed in the gap-statistics graph. This is also seems like a suitable number of colors for visualization.\n\n\\begin{figure}[H]\n\t\\center\n\t\\includegraphics[width=\\textwidth]{figures/kmeans-world}\n\t\\caption{Each position is an point with belongs to the cluster, with the closest centroid.}\n\t\\label{fig:kmeans-world}\n\\end{figure}\n\\begin{figure}[H]\n\t\\center\n\t\\includegraphics[width=\\textwidth]{figures/kmeans-centroids}\n\t\\caption{Cluster centroids. The colors correspond to those in Figure \\ref{fig:kmeans-world}}\n\t\\label{fig:kmeans-centroids}\n\\end{figure}\n\nComparing the two plots above a few interesting insights are gained:\n\\begin{itemize}\n\t\\item Orange areas have a slight mass increase. At the south pole it appears that some of the mass loss at the edge actually moves inward towards the South Pole. This may be caused by post glacial rebound as no GIA has been performed.\n\t\\item  Green and blue correlates with extreme and regular seasonality (i.e. rain season in Amazon Basin).\n\t\\item Light green and pink correspond with trending mass loss. The most significant locations appear to be located around the tip of the Western Antarctica along with Greenland's east coast.\n\\end{itemize}\n", "meta": {"hexsha": "80dc031c477f7862f35978972adf7323ab42a457", "size": 2365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Rapport/result-kmeans.tex", "max_stars_repo_name": "AndreasMadsen/grace", "max_stars_repo_head_hexsha": "bf472d30a2fac76145d3f68e819c92da4a1970ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-17T22:52:19.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-17T22:52:19.000Z", "max_issues_repo_path": "Rapport/result-kmeans.tex", "max_issues_repo_name": "AndreasMadsen/grace", "max_issues_repo_head_hexsha": "bf472d30a2fac76145d3f68e819c92da4a1970ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Rapport/result-kmeans.tex", "max_forks_repo_name": "AndreasMadsen/grace", "max_forks_repo_head_hexsha": "bf472d30a2fac76145d3f68e819c92da4a1970ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.9189189189, "max_line_length": 408, "alphanum_fraction": 0.7928118393, "num_tokens": 549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.4188021109546442}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{IV}\n\n\\def\\ntitle{Geometric Aspects of p-adic Hodge Theory}\n\\def\\nlecturer{T.\\ Csige}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2020}\n\n\\input{header}\n\n\\newcommand{\\tilt}{\\flat} % tilting\n\\newcommand{\\perf}{\\mathrm{perf}}\n%\\DeclareMathOperator{\\perf}{perf} % perfection\n\\renewcommand{\\c}[1]{\\mathbf{#1}}\n\\newcommand{\\Mod}{{\\c{Mod}}}\n\\DeclareMathOperator{\\Tor}{Tor} % torsion\n\\DeclareMathOperator{\\Ext}{Ext} % extension\n\\newcommand{\\sh}[1]{\\mathcal{#1}} % sheaf\n\\DeclareMathOperator{\\Spa}{Spa}\n\\renewcommand*{\\O}{\\mathcal{O}}\n\n\n\\newtheorem*{construction}{Construction}\n\n\\iffalse\n\\renewcommand*{\\P}{\\mathbb{P}}\n\\newcommand{\\sh}[1]{\\mathcal{#1}} % sheaf\n\\renewcommand*{\\O}{\\mathcal{O}}\n\\let\\Sp\\Relax\n\\DeclareMathOperator{\\Sp}{Sp} % maximum spectrum\n\\DeclareMathOperator{\\Max}{Max}\n\\DeclareMathOperator{\\Spf}{Spf}\n\\DeclareMathOperator{\\Spa}{Spa}\n\\DeclareMathOperator{\\supp}{supp} % support of a valuation\n\\fi\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\section{Introduction}\n\nCourse structure:\n\\begin{enumerate}\n\\item introduction\n\\item Hodge-Tate decomposition for abelian varieties with good reduction\n\\item Hodge-Tate decomposition in generale (pro-étale cohomology)\n\\item integral aspects\n\\item some additional topics (Hodge-Tate decomposition theorem for rigid analytic varieties)\n\\end{enumerate}\n\n\\subsection{Hodge decomposition over \\(\\C\\)}\n\nLet \\(X\\) be a smooth projective variety over \\(\\C\\). The \\emph{Hodge decomposition} is a direct sum decomposition for all \\(n \\geq 0\\)\n\\[\n  H_{\\mathrm{sing}}^n(X^{\\mathrm{an}}, \\C) = \\bigoplus_{p + q = n} H^{p, q}\n\\]\nwhere LHS is the singular cohomology of the \\(\\C\\)-analytic manifold \\(X^{\\mathrm{an}}\\) (the complex analytification) and on RHS\n\\[\n  H^{p, q} = H^q(X^{\\mathrm{an}}, \\Omega_{X^{\\mathrm{an}}}^p)\n\\]\nwith \\(\\Omega_{X^{\\mathrm{an}}}^p\\) denoting the sheaf of holomorphic \\(p\\)-forms. Moreover, complex conjugation acts on\n\\[\n  H^n_{\\mathrm{sing}}(X^{\\mathrm{an}}, \\C) \\cong H_{\\mathrm{sing}}^n(X^{\\mathrm{an}}, \\Q) \\otimes \\C\n\\]\nvia its action on \\(\\C\\) and \\(H^{p, q} = \\overline{H^{q, p}}\\). This is called a \\emph{pure structure of weight \\(n\\)}.\n\nThese are proven via identifying \\(H^{p, q}\\) with Dolbeault cohomology and using the (very deep) theory of harmonic forms. However, part of the theory can be understood purely algebraically. It is known that \\(H^n_{\\mathrm{sing}}(X^{\\mathrm{an}}, \\C)\\) gives the cohomology of the constant sheaf \\(\\C\\) on \\(X^{\\mathrm{an}}\\). On the other hand, consider the de Rham complex\n\\[\n  \\Omega_{X^{\\mathrm{an}}}^\\bullet = \\O_{X^{\\mathrm{an}}} \\xrightarrow{\\d} \\Omega_{X^{\\mathrm{an}}}^1 \\xrightarrow{\\d} \\Omega_{X^{\\mathrm{an}}}^2 \\to \\cdots\n\\]\nHere \\(\\d\\) is the usual derivation and the higher \\(\\d\\)'s are given by\n\\[\n  \\d (\\omega_1 \\wedge \\omega_2) = \\d \\omega_1 \\wedge\\omega_2 + (-1)^p \\omega_1 \\wedge\\d \\omega_2\n\\]\nfor \\(\\omega_1 \\in \\Omega_{X^{\\mathrm{an}}}^p, \\omega_2 \\in \\Omega_{X^{\\mathrm{an}}}^q\\). Taking hypercohomology\n\\[\n  H^n_{\\mathrm{dR}}(X^{\\mathrm{an}}) := \\H(X^{\\mathrm{an}}, \\Omega_{X^{\\mathrm{an}}}^\\bullet)\n\\]\nwe get the so-called de Rham cohomology group.\n\nEmbedding the constant sheaf \\(\\C\\) into \\(\\O_{X^{\\mathrm{an}}}\\) induces a map \\(\\C \\to \\Omega_{X^{\\mathrm{an}}}^\\bullet\\) of complexes of sheaves. The (holomorphic) Poincaré lemma states that this map is a quasi-isomorphism of sheaves. More precisely, one can cover \\(X^{\\mathrm{an}}\\) by open balls and for any open ball \\(U \\subseteq X^{\\mathrm{an}}\\), the complex\n\\[\n    0 \\to \\C \\to \\O_{X^{\\mathrm{an}}}(U) \\xrightarrow{\\d} \\Omega^1_{X^{\\mathrm{an}}} \\to \\cdots\n\\]\nis exact: any closed differential form can be integrated on an open ball. Thus\n\\[\n  H^n_{\\mathrm{sing}}(X^{\\mathrm{an}}, \\C) \\cong H^n_{\\mathrm{dR}}(X^{\\mathrm{an}}).\n\\]\nThis is the comparison theorem between singular and de Rham cohomology.\n\nNow the complex \\(\\Omega_{X^{\\mathrm{an}}}^\\bullet\\) has a decreasing filtration of subcomplexes\n\\[\n  \\Omega_{X^{\\mathrm{an}}}^{\\geq p} := 0 \\to \\cdots \\to 0 \\to \\Omega^p_{X^{\\mathrm{an}}} \\xrightarrow{\\d} \\Omega_{X^{\\mathrm{an}}}^{p + 1} \\xrightarrow{\\d} \\cdots\n\\]\nWe have that \\(\\operatorname{gr}^p \\Omega^\\bullet_{X^{\\mathrm{an}}} \\cong \\Omega^p_{X^{\\mathrm{an}}}\\). It is well-known that there is a convergent spectral sequence associated to \\(\\Omega_{X^{\\mathrm{an}}}^\\bullet\\) with the filtration above, called the \\emph{Hodge to de Rham spectral sequence}\n\\[\n  E_1^{pq} = H^q(X^{\\mathrm{an}}, \\Omega^p_{X^{\\mathrm{an}}}) \\Rightarrow H^{p + q}_{\\mathrm{dR}}(X^{\\mathrm{an}}).\n\\]\nThe filtration on \\(H^n_{\\mathrm{dR}}(X^{\\mathrm{an}})\\) given by the spectral sequence is called the \\emph{Hodge filtration}.\n\nFact: the Hodge to de Rham spectral sequence degenerates at \\(E_1\\). This together with the comparison theorem gives the Hodge decomposition\n\\[\n  H^n_{\\mathrm{sing}}(X^{\\mathrm{an}}, \\C) = \\bigoplus_{p + q = n} H^q(X^{\\mathrm{an}}, \\Omega_{X^{\\mathrm{an}}}^p)\n\\]\nfor all \\(n\\).\n\n\\subsection{Algebraisation}\n\nOn a complex variety \\(X\\) we may consider the algebraic de Rham complex\n\\[\n  \\Omega_X^\\bullet := \\O_X \\xrightarrow{\\d} \\Omega_X^1 \\xrightarrow{\\d} \\cdots\n\\]\nFor \\(X\\) smooth these are locally free sheaves. The same way as above, we get the algebraic Hodge to de Rham spectral sequence\n\\[\n  E_1^{pq} = H^q(X, \\Omega_X^p) \\Rightarrow H^{p + q}_{\\mathrm{dR}}(X).\n\\]\nHere we use the Zariski topology.\n\nThere are two natural maps\n\\begin{align*}\n  H^q(X, \\Omega_X^p) &\\to H^q(X^{\\mathrm{an}}, \\Omega_{X^{\\mathrm{an}}}^p) \\\\\n  H^{p +q}_{\\mathrm{dR}}(X) &\\to H^{p +q}_{\\mathrm{dR}}(X^{\\mathrm{an}})\n\\end{align*}\nall compatible with the maps in the above spectral sequences. By GAGA the first one is an isomorphism, and by a theorem of Grothendieck the second is also an isomorphism. Hence degeneration of the analytic Hodge to de Rham is equivalent to the degeneration of the algebraic counterpart.\n\nHowever, there is no algebraic Poincaré lemma, the algebraic de Rham complex is not a resolution of \\(\\C\\) and anyway the sheaf cohomology of \\(\\C\\) is trivial in the Zariski topology.\n\n\\subsection{The case of a \\(p\\)-adic base field}\n\nLet \\(p\\) be a prime. Recall \\(\\C_p\\) is the completion of the algebraic closure \\(\\overline Q_p\\) of \\(\\Q_p\\). The Galois group \\(\\gal(\\overline \\Q_p/\\Q_p)\\) acts on \\(\\C_p\\) by continuity. Let \\(K\\) be a finite extension of \\(\\Q_p\\).\n\n\n\n\\printindex\n\\end{document}", "meta": {"hexsha": "b15d900553ee6a27cbd65ff25d05b298c0c5e89b", "size": 6365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "IV/geometric_aspects_of_p-adic_hodge_theory.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "IV/geometric_aspects_of_p-adic_hodge_theory.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "IV/geometric_aspects_of_p-adic_hodge_theory.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 45.4642857143, "max_line_length": 375, "alphanum_fraction": 0.6837391987, "num_tokens": 2177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.41880210788914835}}
{"text": "% !TeX spellcheck = de_DE\n\n\\chapter{Conclusion and Future Work}\n\\label{chap:conclusion}\n\nThis thesis proposed a framework for automatic 3D lane marking reconstruction using multi-view aerial imagery. Standard line detection algorithms are applied to extract lane markings on the aerial images. By exploiting the use of linear regression in image space and with the combination of collinearity condition, lane markings are reconstructed based on their detected positions in images and the viewing geometry. Without the utilization of the neighboring textures, the approach requires initial approximate 3D lines and is highly dependent on quality of pre-known image orientations. Nevertheless, it is robust to partial occlusions of the targeted lines on images and is applicable to the (quasi-)infinite line features as well as in cases of lowly textured neighboring and it improves the DSM at lowly textured road surfaces. \n\n\nFrom simulated experiments in \\cref{sec:simulation}, some conclusions are given:\n\\begin{itemize}\n\t\\item Given approximations with 2 meters bias in Z-direction and sub-pixel random noises in the image coordinates of the detected/measured 2D lines, the proposed approach correctly refined the 3D positions of line segments.\n\t\n\t\\item With the same line orientations in 3D space, the configuration strength increases with the increase of amount of covering images from different views.\n\t\n\t\\item The reconstructed line segments have higher priori precision in horizontal direction than in vertical direction.\n\\end{itemize}\n\n\nFrom experimental results of true data in \\cref{sec:truedata}, some conclusions are given:\n\\begin{itemize}\n\t\\item The DSM profile, i.e. the initial 3D line approximation, is significantly and systematically dozens of centimeters far away from the reconstructed line segments. This indicates the necessity of reconstrucion based on detected 2D lines in image space and the viewing geometry, instead of simply reducing DSM noise by applying mean filter or such.\n\t\n\t\\item The LS-estimated precision of the measurements, involving the lane marking extraction quality as well as the quality of image orientation parameters, is better than 1 pixel.\n\n\t\\item The configuration defect %which is mentioned in \\cref{subsec:LSadj} \n\tbarely happens: 1.when the linear regression functional model between image coordinates $x$ and $y$ are properly set up ---according to the characteristics of the detected lane-lines in image space. 2.when the flight configuration guarantees stereo views whose base-lines are perpendicular to lane-lines orientations in 3D.\n\t\n\t\\item The theoretical precision of the reconstructed line-nodes is within 2.5 cm in vertical direction and within 5 mm in horizontal direction.\n%\t\\item  %The configuration defect in object space %which is mentioned in \\cref{subsec:LSadj} \n%\t%may happen in some of the stereo views in the same strip with the adopted flight configuration in this work.% of flying along the motorways, the detected lane lines lie mainly in flight direction on images.\n%\tWith the adopted flight configuration in this work, the stereo pairs in the same strip, where the lane markings lie nearly on the epipolar plane, barely contribute on increasing the configuration strength for lane marking reconstruction. \n%\t%This indirectly indicates that, under this kind of image configuration, increasing forward overlapping rate does not really increase the configuration strength for 3D lane markings reconstruction. \n\t\n\\end{itemize}\n\n\n%using precisely detected lines with sub-pixel precision as well the bundle adjusted image orientations, the lane markings can be reconstructed with ???centimeter accuracy??? using well configured aerial images.\n\n%With the extracted line in the form of sets of points with sub-pixel accuracy and EOIO accuracy???, linear regression can be applied on reconstructing the 3D line segment position.\n\n%image distortion vs straight line approximation\n\nSome general conclusions are:\n\\begin{itemize}\n\t\\item Image configuration plays an important roll in 3D reconstruction. In the case of this work, being covered by more views whose base-lines are as perpendicular as possible to lane-marking directions, would improve the reconstruction result.\n\t\n\t\\item Lane markings can be exploited to provide information on refining SGM-generated DSM.% Reconstruction based on imaging geometry is necessary.\n\n\t\\item The proposed reconstruction workflow relies on initial approximation with enough accuracy, i.e. a global terrain model like SRTM would not be sufficient as starting height, as the error could be several meters in particular at roads.\n\\end{itemize}\n\n\n\n\n\n\\section*{Future Work}\n\\label{chap:futurework}\n\n%Future improvements could be achieved by:\n\n%having crab angles of $\\approx45\\degree$ in flight.\n%Theoretically this kind of configuration defect may be solved.\n\n%increasing the oblique angle\nThe proposed approach addresses 3D line features reconstruction problems without resorting to their appearances in images. Similar cases are railways. Appling this framwork to such cases may be done in the future. Additionally, it worths trying the framework with images taken from drones instead of from helicopters.\n\n", "meta": {"hexsha": "e5588727328f3030c7d003c44fe128759eb9fbc5", "size": 5210, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/zusammenfassung_und_ausblick.tex", "max_stars_repo_name": "eileen19930711/MyMasterThesis", "max_stars_repo_head_hexsha": "1e6a113c538b5313c7d201a6bbf6aabfbe357a7e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/zusammenfassung_und_ausblick.tex", "max_issues_repo_name": "eileen19930711/MyMasterThesis", "max_issues_repo_head_hexsha": "1e6a113c538b5313c7d201a6bbf6aabfbe357a7e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/zusammenfassung_und_ausblick.tex", "max_forks_repo_name": "eileen19930711/MyMasterThesis", "max_forks_repo_head_hexsha": "1e6a113c538b5313c7d201a6bbf6aabfbe357a7e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.7611940299, "max_line_length": 833, "alphanum_fraction": 0.8119001919, "num_tokens": 1049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.41880210268905105}}
{"text": "\n% !TEX root = scombinatorics.tex\n\\documentclass[scombinatorics.tex]{subfiles}\n\\begin{document}\n\\chapter*{References}\n\\addcontentsline{toc}{chapter}{References}\n\n\\begin{biblist}[]\\normalsize\n\n  \\bib{AK1}{article}{\n    author={Alon, N.},\n    author={Kleitman, D. J.},\n    title={A purely combinatorial proof of the Hadwiger Debrunner $(p,q)$\n    conjecture},\n    % note={The Wilf Festschrift (Philadelphia, PA, 1996)},\n    journal={Electron. J. Combin.},\n    volume={4},\n    date={1997},\n    % number={2},\n    % pages={Research Paper 1, approx. 8},\n    % review={\\MR{1444148}},\n }\n\n \\bib{AK2}{article}{\n    author={Alon, Noga},\n    author={Kleitman, Daniel J.},\n    title={Piercing convex sets and the Hadwiger-Debrunner $(p,q)$-problem},\n    journal={Adv. Math.},\n    volume={96},\n    date={1992},\n    % number={1},\n    % pages={103--112},\n    % issn={0001-8708},\n    % review={\\MR{1185788}},\n    % doi={10.1016/0001-8708(92)90052-M},\n }\n     \n\\bib{ARS}{article}{\n   author={Anstee, R. P.},\n   author={R\\'onyai, Lajos},\n   author={Sali, Attila},\n   title={Shattering news},\n   journal={Graphs Combin.},\n   volume={18},\n   date={2002},\n%  number={1},\n%  pages={59--73},\n%  issn={0911-0119},\n%  doi={10.1007/s003730200003},\n}\n\\bib{DGL}{book}{\n   author={Devroye, Luc},\n   author={Gy\\\"{o}rfi, L\\'{a}szl\\'{o}},\n   author={Lugosi, G\\'{a}bor},\n   title={A probabilistic theory of pattern recognition},\n   publisher={Springer-Verlag},\n   date={1996},\n}\n\\bib{DL}{book}{\n   author={Devroye, Luc},\n   author={Lugosi, G\\'{a}bor},\n   title={Combinatorial methods in density estimation},\n   series={Springer Series in Statistics},\n   publisher={Springer-Verlag},\n   date={2001},\n}\n\\bib{gowers}{article}{\n   author={Gowers, Timothy},\n   title={\\href{https://gowers.wordpress.com/2008/07/31/dimension-arguments-in-combinatorics}{Dimension arguments in combinatorics}},\n   journal={Gowers's Weblog},\n   date={2008}\n}\n\\bib{hodges}{article}{\n  author={Hodges, Wilfrid},\n  title={Encoding orders and trees in binary relations},\n  journal={Mathematika},\n  volume={28},\n  date={1981},\n  % number={1},\n  pages={67--71},\n  % issn={0025-5793},\n  % review={\\MR{632796}},\n  % doi={10.1112/S0025579300015357},\n}\n\\bib{kalai}{article}{\n  author={Kalai, Gil} ,\n  title={\\href{https://gilkalai.wordpress.com/2008/09/28/extremal-combinatorics-iii-some-basic-theorems}{Extremal Combinatorics III: Some Basic Theorems}},\n  journal={Combinatorics and more},\n  date={2008}\n}\n\\bib{matousek}{article}{\n   author={Matou\\v{s}ek, Ji\\v{r}\\'{\\i}},\n   title={Bounded VC-dimension implies a fractional Helly theorem},\n   journal={Discrete Comput. Geom.},\n   volume={31},\n   date={2004},\n  %  number={2},\n  %  pages={251--255},\n  %  issn={0179-5376},\n  %  review={\\MR{2060639}},\n  %  doi={10.1007/s00454-003-2859-z},\n}\n\\bib{LPmatousek}{book}{\n  author={Matousek, J\\v{\\i}ri},\n  author={Gartner, Bernd},\n  title={Understanding and Using Linear Programming},\n  publisher={Springer-Verlag},\n  date={2007},\n  pages={vi+222},\n}\n\\bib{pajor}{book}{\n   author={Pajor, Alain},\n   title={Sous-espaces $l^n_1$ des espaces de Banach},\n%   language={French},\n   series={Travaux en Cours [Works in Progress]},\n   volume={16},\n%   note={With an introduction by Gilles Pisier},\n   publisher={Hermann, Paris},\n   date={1985},\n%   pages={xii+112},\n%   isbn={2-7056-6021-6}\n}\n\\bib{sauer}{article}{\n   author={Sauer, N.},\n   title={On the density of families of sets},\n   journal={J. Combinatorial Theory Ser. A},\n   volume={13},\n   date={1972},\n   pages={145--147},\n}\n\\bib{shelah72}{article}{\n   author={Shelah, Saharon},\n   title={A combinatorial problem; stability and order for models and theories in infinitary languages},\n   journal={Pacific J. Math.},\n   volume={41},\n   date={1972},\n   pages={247--261},\n}\n\\bib{VC}{article}{\n   author={Vapnik, V. N.},\n   author={Chervonenkis, A. Ya.},\n   title={On the uniform convergence of relative frequencies of events to their probabilities},\n   note={Reprint of Theor. Probability Appl. {\\bf 16} (1971), 264--280},\n   conference={title={Measures of complexity},},\n   book={publisher={Springer, Cham},},\n   date={2015},\n   pages={11--30},\n}\n\\end{biblist}\n\\end{document}", "meta": {"hexsha": "f3289cbc8706c1bb736f86f9a05742a483925349", "size": 4149, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bib.tex", "max_stars_repo_name": "LorenzoNot/scombinatorics", "max_stars_repo_head_hexsha": "64392c4f5793019b479376acb5eb248115335b93", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bib.tex", "max_issues_repo_name": "LorenzoNot/scombinatorics", "max_issues_repo_head_hexsha": "64392c4f5793019b479376acb5eb248115335b93", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-07-27T12:37:11.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-27T12:37:11.000Z", "max_forks_repo_path": "bib.tex", "max_forks_repo_name": "LorenzoNot/scombinatorics", "max_forks_repo_head_hexsha": "64392c4f5793019b479376acb5eb248115335b93", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-19T08:23:27.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-19T08:23:27.000Z", "avg_line_length": 27.66, "max_line_length": 155, "alphanum_fraction": 0.6444926488, "num_tokens": 1382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.41880209748895336}}
{"text": "\\documentclass[11pt]{article}\n\n\\input{preamble}\n\n%\\usepackage{tikz}\n%\\usepackage{tikz-qtree}\n\\usepackage{qtree}\n\\usepackage{xfrac}\n\n\\title{Week 4: Naive Bayes, Entropy and Backpropagation}\n\\author{\\url{http://mlvu.github.io}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{preliminaries: probability}\n\nBefore we start, it's helpful to review your general grasp of probability. If the exercises below give you any trouble we recommend that you follow the links provided to brush up a little.\n\n\\qu\n\\begin{enumerate}\n\\item In a few sentences, explain the difference between the Frequentist and the Bayesian interpretation of probability. \\ans{A frequentist considers a probability an objective value: a property of the universe that can be measured by repeated experimentation, like measuring the probability that a bent coin lands heads, by flipping it repeatedly. A Bayesian considers probability an expression of uncertain belief. A Bayesian can talk about the probability that ``John is having an affair''. To a frequentist this is nonsense, because John is either having an affair or he isn't.}{}\n\\item What is the difference between a sample space and an event space? \\ans{A sample space is a space of individual things that can happen (like a die landing on a 6) and an event space is a space of sets of things from the sample space (like a die landing on an even number). Technically, an event space should be a sigma-algebra of a sample space, but for discrete probability distributions, we can think of the event space as a the powerset of the sample space. For continuous probability distributions, we can ignore the technical details.}{}\n\\item What is the difference between a probability distribution and a probability density function? \\ans{A probability function assigns probabilities to events. If the sample space is continuous (like in the case of a normal distribution) all atomic events like ``X is exactly 2.1\" will have zero probability. Instead, we define a \\emph{probability density function}. We then get the probability of a subset of the sample space, like ``X is between 1.95 and 2.15'', by integrating over the probability density function.}{ }\n\\end{enumerate}\t\n\n\\qu In the following, $p$ is a  probability function and $A$ and $B$ are random variables. Which of the following are true?\n\\begin{enumerate}\n\t\\item Joint probability is symmetric: $p(A, B) = p(B, A)$. \\ans{True}{}\n\t\\item Conditional probability is symmetric $p(A \\mid B) = p(B \\mid A)$. \\ans{False. This is not true in general (although it may be true for specific $A$ and $B$).}{}\n\t\\item Two random variables $X$ and $Y$ are conditionally independent on a third $Z$. Once we know $X$ and $Y$, we also know the value of $Z$. \\ans{False.}{}\n\t\\item Two random variables $X$ and $Y$ are conditionally independent on a third $Z$. Once we know $Z$, also knowing $X$ will tell us nothing extra about $Y$. \\ans{True: conditional independence means that given the value of the conditional, $X$ and $Y$ are independent (so knowing the value of one reveals nothing about the other).}{}\n\\end{enumerate}\t\n\n\\qu Assume that the probability that a given patient has diabetes is $0.01$. We have a test for diabetes with a false positive rate of $0.05$: if a patient has no diabetes, the test diagnoses it 5\\% of the time. The false negative rate is $0.1$. \nYou are a doctor, and you administer the test to a patient (knowing nothing else). The test says she has diabetes. What is the probability that she doesn't? Hint: this is a question about Bayes' rule.\nReflect on the result. Is this what you would've expected? If not, where does the unexpected result come from?\n\n\\ans{Let's write down the given probabilities first. We'll use $D$ and $\\neg D$ for the events that the patient has and doesn't have diabetes respectively. We'll use $T$ for the event of the test \\emph{saying} that the patient has diabetes and $\\neg T$ for the test saying that she doesn't.\nWe are given $p(D) = 0.01$, $\\oc{p(T \\mid \\neg D)} = 0.05$ and $p(\\neg T \\mid D) = 0.1$. We can derive $p(\\neg T\\mid \\neg D) = 0.95$ and $p(T \\mid D) = 0.9$.\nNow, we want to know $p(\\neg D \\mid T)$. We'll use Bayes' rule to reverse the conditional probability:\n\\begin{align*}\np(\\neg D \\mid T) &= \\frac{\\oc{p(T \\mid \\neg D)} \\bc{p(\\neg D)} }{p(T)} \\\\\n&= \\frac{\\oc{p(T \\mid \\neg D)} \\bc{p(\\neg D)}}{p(T, D) + p(T, \\neg D)} \\\\\n&= \\frac{\\oc{p(T \\mid \\neg D)} \\bc{p(\\neg D)}}{p(T \\mid D)p(D) + p(T \\mid \\neg D)\\bc{p(\\neg D)}} \\\\\n&= \\frac{\\oc{0.05} \\times \\bc{0.99}}{0.9 \\times 0.01 + \\oc{0.05} \\times \\bc{0.99}} \\\\\n&= \\frac{\\oc{5} \\times \\bc{99}}{90 + \\oc{5}\\times \\bc{99}} \\approx 0.85\n\\end{align*}\nWhether you expected this result is up to you, of course, but it's certainly not what you want form a test like this. And yet, the false positive and false negative rates don't seem extremely high. Inn the last line, I've multiplied everything by 100 so you can see where the imbalance comes from: \\bc{the high prior probability that someone doesn't have diabetes} dominates (in other words, we have high lass imbalance). \nIn order for the test to be reliable, the \\oc{false positive rate} needs to be low enough to make the numerator small in proportion to the denominator.\\footnotemark\n\n\\footnotetext{There's a subtle difference between the phrase \\emph{false positive rate} as we use it here and as we've used it previously. What we described previously (like in lecture 3) is an estimate of the fpr, computed from the test set. What we discuss here is the ``actual'' fpr: an unknown quantity that we would normally only be able to estimate from data.}\n}{}\n\nMore practice? Follow these links:\n\\begin{enumerate}\n\\item \\url{https://seeing-theory.brown.edu/} (especially this one)\n\\item \\url{https://betterexplained.com/articles/a-brief-introduction-to-probability-statistics/}\n\\item \\url{https://www.khanacademy.org/math/probability/probability-geometry/probability-basics/a/probability-the-basics}\n\\item \\url{http://dept.stat.lsa.umich.edu/~moulib/probrefresh.pdf}\n\\end{enumerate}\n\n\n\\section{Naive Bayes}\n\nThe following dataset represents a spam classification problem: we observe 8 emails and measure two binary features. The first is 0 if the word \"pill\" occurs in the e-mail and the second is 1 if the word ``meeting'' occurs. \n\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t ``pill'' &``meeting'' & label\\\\\n\t\t\\hline\n\t\t  \\bc{T} & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & \\rc{Spam} \\\\\n\t\t  F & \\bc{T} & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & \\rc{Spam} \\\\\n\t\t  F & F & \\gc{Ham} \\\\\n\t\t  F & F & \\gc{Ham} \\\\\n\t\t  F & \\bc{T} & \\gc{Ham} \\\\\n\t\t  \\bc{T} & \\bc{T} & \\gc{Ham} \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\n\n\\qu We will build a naive Bayes classifier for this data. What is the defining property of naive Bayes? Why is it called ``naive''?\n\n\\ans{The naive Bayes classifier assumes that the features are independent, \\emph{conditional on the class}. It is called naive, because this assumption is usually untrue. The resulting classifier nevertheless works well in many cases.}{}\n\n\\qu We build a naive Bayes classifier on this data, as described in the lecture. We get an email that contains both words. Which class does the classifier assign?\n\n\\ans{\nCall the class $Y$ and the features $X_p$ and $X_m$. The class probabilities are \n\\[\np(Y\\mid X_p, X_m) = \\frac{p(X_p, X_m\\mid Y)p(Y)}{p(X_p, X_m)} \\p\n\\]\nThe class choice is \n\\[\n\\argmax_Y p(Y\\mid X_p, X_m) = \\argmax_Y p(X_p, X_m\\mid Y)p(Y) \\p\n\\]\n\nThe \\emph{naive Bayes assumption} allows us to break the the probabilities up.\n\n\\[\n\\argmax_Y p(Y\\mid X_p, X_m) = \\argmax_Y p(X_p\\mid Y) p(X_m\\mid Y)p(Y) \\p\n\\]\n\nWe estimate the the class prior $P(Y)$ from the data (i.e. 0.5 for each class). We estimate the likelihood of the data given the class based on the relative frequencies in the data (i.e. $p(X_p\\mid \\text{\\rc{Spam}}) = \\frac{3}{4}$). Since we only care about the class with the maximal probability, we can use Bayes rule without computing the denominator. \n\nThis gives us:\n\\begin{align*}\np(\\text{Spam}\\mid X_p=1, X_m=1) &\\propto p(X_p=1\\mid \\text{Spam})\\;p(X_m=1\\mid \\text{\\rc{Spam}})\\;p(\\text{Spam})\\\\\n\t\t\t\t\t &= \\frac{3}{4}\\frac{1}{4}\\frac{1}{2} = \\frac{3}{32}\\\\\np(\\text{Ham}\\mid X_p=1, X_m=1) &\\propto p(X_p=1\\mid \\text{\\gc{Ham}})\\;p(X_m=1\\mid \\text{\\gc{Ham}})\\;p(\\text{\\gc{Ham}})\\\\\n\t\t\t\t\t &= \\frac{1}{4}\\frac{2}{4}\\frac{1}{2} = \\frac{2}{32}\\\\\t\n\\end{align*}\n\\rc{Spam} gives a higher value (these are not probabilities, just values proportional to the true probabilities), so the classifier classifies the email as \\rc{Spam}.\n}{}\n\t\n\\qu Which probabilities does the classifier assign to each class?\n\\ans{\nFor full class probabilities, we need to apply Bayes' theorem including its denominator:\n\\[\np(Y\\mid X_p, X_m) = \\frac{p(X_p, X_m\\mid Y)p(Y)}{p(X_p, X_m)} \\p\n\\]\nThe denominator expands as\n\\[\np(X_p, X_m) = \\sum_{Y\\in \\{\\text{Spam}, \\text{Ham}\\}} p(X_p, X_m\\mid Y)p(Y)\n\\]\n\nThese are the two unnormalized probabilities ($\\frac{3}{32}$ and $\\frac{2}{32}$) that we've calculated already. Computing the proper probabilities is equivalent to normalizing the unnormalized ones. Thus, the class probabilities assigned are $\\frac{3}{5}$ for \\rc{Spam} and $\\frac{2}{5}$ for \\gc{Ham}.\n}{}\n\nTo improve our accuracy, we add another feature:\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t``pill'' & ``meeting'' & ``hello'' & label\\\\\n\t\t\\hline\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  F & \\bc{T} & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  F & F & F & \\gc{Ham} \\\\\n\t\t  F & F & F & \\gc{Ham} \\\\\n\t\t  F & \\bc{T} & F & \\gc{Ham} \\\\\n\t\t  \\bc{T} & \\bc{T} & \\bc{T} & \\gc{Ham} \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\n\n\\qu For the class Spam, there are no emails recorded that contain the word ``hello''. Why is this a problem?\n\n\\ans{This makes our estimate of the probability $p(X_h=1\\mid \\text{\\rc{Spam}})$ zero. This causes the entire class probability to collapse to 0 even if the other features make Spam very likely.}\n\nWhat solution is suggested in the slides?\n\n\\ans{To add \\emph{pseudo-observations}, so that for each feature each value is observed at least once for each class.}\n\n\n\\qu Implement this solution, and give the class probabilities for an email containing all three words.\n\n\\ans{\nAfter adding the pseudo observations, our dataset looks like this:\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t ``pill'' & ``meeting'' & ``hello'' & label\\\\\n\t\t\\hline\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  F & \\bc{T} & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & F & F & \\rc{Spam} \\\\\n\t\t  F & F & F & \\gc{Ham} \\\\\n\t\t  F & F & F & \\gc{Ham} \\\\\n\t\t  F & \\bc{T} & F & \\gc{Ham} \\\\\n\t\t  \\bc{T} & \\bc{T} & \\bc{T} & \\gc{Ham} \\\\\n\t\t  \\hline\n\t\t  \\bc{T} & \\bc{T} & \\bc{T} & \\rc{Spam} \\\\\n\t\t  F & F & F & \\rc{Spam} \\\\\n\t\t  \\bc{T} & \\bc{T} & \\bc{T} & \\gc{Ham} \\\\\n\t\t  F & F & F & \\gc{Ham} \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\n\nNote that we don't add every possible combination of features (that would be 8 extra instances per class). We just make sure that for every feature there is one email that has F for that feature and \\rc{Spam} as a class, one email that has \\bc{T} for that feature and \\rc{Spam} as a class and the same for \\gc{Ham}.\n\nThis gives us:\n\\begin{align*}\np(&\\text{\\rc{Spam}}\\mid X_p=1, X_m=1, X_h=1) \\\\\n&\\propto p(X_p=1\\mid \\text{\\rc{Spam}})\\;p(X_m=1\\mid \\text{\\rc{Spam}})\\;p(X_h=1\\mid \\text{\\rc{Spam}})\\;p(\\text{\\rc{Spam}})\\\\\n\t\t\t\t\t &= \\frac{4}{6}\\frac{2}{6}\\frac{1}{6}\\frac{1}{2} = \\frac{8}{6^32}\\\\\np(&\\text{\\gc{Ham}}\\mid X_p=1, X_m=1, X_h=1) \\\\\n&\\propto p(X_p=1\\mid \\text{\\gc{Ham}})\\;p(X_m=1\\mid \\text{\\gc{Ham}})\\;p(X_h=1\\mid \\text{\\gc{Ham}})\\;p(\\text{\\gc{Ham}})\\\\\n\t\t\t\t\t &= \\frac{2}{6}\\frac{3}{6}\\frac{2}{6}\\frac{1}{2} = \\frac{12}{6^32}\t\n\\end{align*}\n\nNormalizing these gives us $\\frac{2}{5}$ for \\rc{Spam} and $\\frac{3}{5}$ for \\gc{Ham}.\n}{}\n\n\\section{Entropy}\n\nWe define two probability distributions $p$ and $q$ on a set of four outcomes $\\{a, b, c, d\\}$.\n\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t $p(a)$ & $p(b)$ & $p(c)$ & $p(d)$\\\\ \n\t\t\\hline\n\t\t  $\\sfrac{1}{4}$ & $\\sfrac{1}{4}$ & $\\sfrac{1}{4}$ & $\\sfrac{1}{4}$ \\\\\n\t\\end{tabular}\n\\end{center}\n\n\n\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t $q(a)$ & $q(b)$ & $q(c)$ & $q(d)$\\\\ \n\t\t\\hline\n\t\t  $\\sfrac{1}{2}$ & $\\sfrac{1}{4}$ & $\\sfrac{1}{8}$ & $\\sfrac{1}{8}$ \\\\\n\t\\end{tabular}\n\\end{center}\n\n\n\\qu Could you simulate sampling from these distributions using coinflips as described in the lecture?\n\n\\ans{Yes. $p$ can be simulated by assigning each unique sequence of two coinflips to one of the outcomes. For $q$, we can assign the following sequences to each outcome:\n\n\\begin{center}\n\t\\begin{tabular}{c c c c}\n\t\t $q(a)$ & $q(b)$ & $q(c)$ & $q(d)$\\\\ \n\t\t\\hline\n\t\t  $H$ & $TH$ & $TTH$ & $TTT$ \\\\\n\t\\end{tabular}\n\\end{center}\n}\n\n\\qu Compute the entropy of $p$ and $q$.\n\n\\ans{\n\\begin{align*}\nH(p) &= - \\sum_{y \\in \\{a, b, c, d\\}} p(y) \\log_2 p(y)  \\\\\n&= - 4\\left(\\frac{1}{4} \\log \\frac{1}{4}\\right) = - \\log 4\\times -1 = \\log 4 = 2\\\n\\end{align*}\n\n\\begin{align*}\nH(q) &= - \\sum_{y \\in \\{a, b, c, d\\}} q(y) \\log_2 q(y)  \\\\\n&= - \\frac{1}{2} \\log \\frac{1}{2} -  \\frac{1}{4} \\log \\frac{1}{4} - \\frac{1}{8} \\log \\frac{1}{8} - \\frac{1}{8} \\log \\frac{1}{8}\\\\\n&= \\frac{1}{2} + \\frac{2}{4} + \\frac{3}{8} + \\frac{3}{8} = \\frac{4}{8} + \\frac{4}{8} + \\frac{3}{8} + \\frac{3}{8} = 1.75\n\\end{align*}\n}\n\nThe entropy of $q$ is lower than the entropy of $p$. What does this tell you about the difference between the two distributions?\n\n\\ans{This means that $p$ is more \\emph{uniform} than $q$. In other words, we have more \\emph{information} about what the outcome of a sample from $q$ will be than we do about the outcome of a sample from $p$.}\n\n\n\\qu In the definition of entropy that we use (information entropy), the logarithms have base 2 (i.e. $\\log_2$ instead of $\\log_{10}$ or $\\ln$). This follows directly from our decision to model probability distributions with coinflips. How?\n\n\n\\ans{The logarithm is defined as the expected code length under an idealized optimal binary code. If a binary code assigns a codeword of length of $L$ to an outcome, the probability of sampling that outcome by generating a random code by flipping a coin is $\\left (\\frac{1}{2}\\right)^L = 2^-L$. If we reverse this, to find the optimal code belonging to an event with probability $p(x)$, we get $L = -\\log_2p(x)$}{}\n\n\\section{Backpropagation}\n\n\nWe will practice the backpropagation algorithm as described in the slides. We will use a neural network defined by the following function:\n\\begin{align*}\n\\rc{y} &= \\oc{v_1}h_1 + \\oc{v_2}h2 \\\\\n\\yc{h_1} &= \\sigma(\\gc{k_1}) \\\\\n\\yc{h_2} &= \\sigma(\\gc{k_2}) \\\\\n\\gc{k_1} &= \\oc{w_1}x \\\\\n\\gc{k_2} &= \\oc{w_2}x \n\\end{align*}\n\nWhere $\\sigma$ represents the logistic sigmoid. The network has a single input node $x$ and a single output node $\\rc{y}$. The weights are $\\oc{w_1}$, $\\oc{w_2}$, $\\oc{v_1}$ and $\\oc{v_2}$. We've left out bias nodes to keep things simple.\n\n\n\\qu Draw this network.\n\n{\\centering\n\\includegraphics[width=0.7\\linewidth]{{w4.network}.pdf}\n}\n\nWe will use stochastic gradient descent to train this network. That means we define the loss function for a single instance. We will use basic least-squares loss to train this network for regression. Our loss function for instance $x$ is\n\\[\n\\text{loss}_x(\\oc{w_1}, \\oc{w_2}, \\oc{v_1}, \\oc{v_2}) = \\frac{1}{2}\\left(\\rc{y}-t\\right)^2\n\\]\n\nwhere $t$ is the target value provided by the dataset, and $y$ is the output of the network.\n\nWe see each line in the definition above as a module, with some inputs and some outputs. Using the chain rule, we will express the derivative with respect to weight $w_1$. We will use only \\emph{local derivatives}, expressing the derivative for each module with respect to its inputs, but not working out the derivative beyond that.\n\n\\qu Fill in the gaps:\n\\begin{align}\n\\frac{\\kp \\text{loss}}{\\kp \\oc{w_1}}\n &= \\frac{\\kp \\text{loss}}{\\kp \\rc{y}}\\frac{\\kp \\rc{y}}{\\kp \\yc{h_1}} \\ans{\\frac{\\kp \\yc{h_1}}{\\kp \\gc{k_1}} }{\\ldots}\\frac{\\kp \\gc{k_1}}{\\kp \\oc{w_1}} \\notag \\\\\n &= (\\rc{y} - t) \\times \\ans{\\oc{v_1}}{\\ldots} \\times \\sigma(\\gc{k_1})(1-\\sigma(\\gc{k_1})) \\times \\ans{x}{\\ldots} \\label{line:chain}\n\\end{align}\n\n\\qu  The network has a diamond shape, just as shown in the slide when explaining the multivariate chain rule (in the \\emph{Deep Learning 1} lecture). However, in this case, we don't need the multivariate chain rule. Why not? In what kind of situation would the multivariate chain rule be required?\n\n\\ans{The multivariate chain rule is needed when the output depends on one of the variables for which we are taking the derivative (like $\\oc{w_1}$) along multiple paths in the computation graph. In this case we have a diamond because $\\rc{y}$ depends on $x$ along two paths, but we never take the derivative with respect  to $x$ (the input), only with respect to the weights.\n\nIn a way, we \\emph{are} using the multivariate chain rule, if we write \n\\[\n\\frac{\\kp l}{\\kp \\oc{w_1}} = \\frac{\\kp \\oc{v_1}\\yc{h_1}}{\\kp \\oc{w_1}} + \\frac{\\kp \\oc{v_2}\\yc{h_2}}{\\kp \\oc{w_1}}\n\\]\n(because the sum rule is an instance of the multivariate chain rule) but the second term becomes zero because the numerator is constant with respect to $w_1$.\n\n\nThe multivariate chain rule comes into effect when the output depends on a \\emph{weight} along multiple paths in the computation graph. This happens, for instance, when we compute the loss function over a batch of multiple data points. }{}\n\nWe could take the formulation above and fill in the symbolic expressions for $y$, $k_1$, etc, and come up with a general symbolic formula for the derivative for all inputs. However, that is usually expensive to do for large neural nets. Instead, we leave it as is, and fill in the \\emph{numeric} values for these variables for a specific input and for specific weights. \n\n\\qu Assume that the input is $x = 1$, with target output $t=\\frac{1}{2}$ and that \\oc{all weights} are set at $1$. Do a \\emph{forward pass}: compute the loss and all intermediate values $\\gc{k_1}$, $\\gc{k_2}$, $\\yc{h_1}$, $\\yc{h_2}$ and $\\rc{y}$.\n\nTo simplify calculation, you can use the approximation $\\sigma(1) = \\frac{3}{4}$.\n\n\\ans{\n\\begin{align*}\n\\gc{k_1} &= 1 \\\\\n\\gc{k_2} &= 1 \\\\\n\\yc{h_1} &= \\sfrac{3}{4} \\\\\n\\yc{h_2} &= \\sfrac{3}{4} \\\\\t\n\\rc{y} &= \\sfrac{3}{2} \\\\\n\\text{loss} &= \\frac{1}{2} \\\\\n\\end{align*}\n}{}\n\nNow we do the \\emph{backward pass}. Fill these intermediate values in to the loss function decomposed by the chain rule  from line \\ref{line:chain}, and compute the derivative with respect to $w_1$ for these inputs and weights.\n\n\\ans{\n\\begin{align*}\n\\frac{\\kp \\text{loss}}{\\kp \\oc{w_1}} = 1 \\times 1 \\times \\frac{3}{4}\\frac{1}{4} \\times 1 = \\frac{3}{16}\n\\end{align*}\n}{}\n\n\\end{document}", "meta": {"hexsha": "fc8a173d42e2951c4ea75353c7b16701445055c8", "size": 18596, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week4.tex", "max_stars_repo_name": "mlvu/homework", "max_stars_repo_head_hexsha": "2183b91c2a355279fbe958b1bbc8bd13ea956615", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-02-27T13:25:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-07T07:04:26.000Z", "max_issues_repo_path": "week4.tex", "max_issues_repo_name": "mlvu/homework", "max_issues_repo_head_hexsha": "2183b91c2a355279fbe958b1bbc8bd13ea956615", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week4.tex", "max_forks_repo_name": "mlvu/homework", "max_forks_repo_head_hexsha": "2183b91c2a355279fbe958b1bbc8bd13ea956615", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.5104477612, "max_line_length": 584, "alphanum_fraction": 0.6784792428, "num_tokens": 5988, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7826624688140726, "lm_q1q2_score": 0.4188014572074346}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry} \n\\usepackage{color}\n\\usepackage[usenames,dvipsnames]{xcolor}\n\\usepackage{amsmath,amssymb,amsthm,algorithm,algorithmic,graphicx,yhmath,url,enumitem,lscape}\n\\usepackage{wrapfig,subfigure}\n\n\\newcounter{problem}\n\\newenvironment{problem}{\\refstepcounter{problem} \\noindent {\\bf Problem \\arabic{problem}}}{\\vspace{0.5cm}}\n\\newenvironment{solution}{\\vspace{0.3cm} \\par \\noindent {\\bf Solution}}{}\n\\newenvironment{verification}{\\vspace{0.3cm} \\par \\noindent {\\bf Verification}}{}\n\\newenvironment{hint}{\\vspace{0.3cm} \\par {\\bf Hint:}}{}\n\n\\newcounter{remark}\n\\newenvironment{remark}{\\refstepcounter{remark} \\vspace{0.3cm} \\par \\noindent {\\bf Remark \\arabic{remark}}}{\\vspace{0.3cm}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Rn}{\\mathbb{R}^n}\n\\newcommand{\\Rnn}{\\mathbb{R}^{n \\times n}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\fl}{\\text{fl}}\n\n\n\\title{Teknisk vetenskabliga ber{\\\"a}kningar, Fall 2018 \\\\ Lab Session 9}\n\\author{Carl Christian Kjelgaard Mikkelsen}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\\section{Introduction} \n\nThis note contains the list of problems for our lab session\n\\begin{center}\nWednesday, January 9th, 2019, (kl. 13.00-16.00), Room MA416-426.\n\\end{center}\n\n\\section{The problems}\n\n\\begin{problem} Copy the function {\\tt forward.m} into {\\tt work/MyForward.m}\n  \\begin{enumerate}\n  \\item Extend {\\tt MyForward} to the point where it also returns the exact flop count in a variable {\\tt count}.\n  \\item Derive and verify a formula for the exact flop count.\n  \\item Extend {\\tt MyForward} to the point where it can solve a lower unit triangular linear system $LX=F$ where $F$ is an $m$ by $n$ matrix.\n  \\item Construct a minimal working example {\\tt work/MyForwardMWE.m} which verifies that {\\tt MyForward} is working as advertised. For each column, the script must compute and display the normwise relative error given by\n    \\bes\n    \\frac{\\| X(.,j) - \\hat{X}(:,j) \\|_\\infty}{\\|X(:,j)\\|_\\infty}\n    \\ees\n    as well as the normwise relative residual given by\n     \\bes\n    \\frac{\\| F(.,j) - L \\hat{X}(:,j) \\|_\\infty}{\\|F(:,j)\\|_\\infty}\n    \\ees\n  \\end{enumerate}\n Naturally, large values of the normwise relative error are unfortunate, but the normwise relative residual should be small for forward substitution.\n\\end{problem}\n\n\\begin{problem} Copy the function {\\tt backward.m} into {\\tt work/MyBackward.m}\n  \\begin{enumerate}\n  \\item Extend {\\tt MyBackward} to the point where it also returns the exact flop count in a variable {\\tt count}.\n  \\item Derive and verify a formula for the exact flop count.\n  \\item Extend {\\tt MyBackward} to the point where it can solve a non-singular upper triangular linear system $UX=F$ where $F$ is an $m$ by $n$ matrix.\n  \\item Construct a minimal working example {\\tt work/MyBackward MWE.m} which verifies that {\\tt MyBackward} is working as advertised. For each column, the script must compute and display the normwise relative error given by\n    \\bes\n    \\frac{\\| X(.,j) - \\hat{X}(:,j) \\|_\\infty}{\\|X(:,j)\\|_\\infty}\n    \\ees\n    as well as the normwise relative residual given by\n     \\bes\n    \\frac{\\| F(.,j) - U \\hat{X}(:,j) \\|_\\infty}{\\|F(:,j)\\|_\\infty}\n    \\ees\n  \\end{enumerate}\n Naturally, large values of the normwise relative error are unfortunate, but the normwise relative residual should be small for backward substitution.\n\\end{problem}\n\n\\begin{problem} Copy the function {\\tt factor.m} into {\\tt work/MyFactor.m}\n  \\begin{enumerate}\n  \\item Extend {\\tt MyFactor} to the point where it also returns the exact flop count in a variable {\\tt count}.\n  \\item Derive and verify a formula for the exact flop count\\footnote{It is possible that this question and answer can be helpful: \\url{http://math.stackexchange.com/questions/1640730/order-of-lu-factorisation/1641606#1641606}}.\n  \\item Develop a minimal working example {\\tt MyFactorMWE} which computes an LU factorization $PA=LU$ of a random matrix $A$. The script must compute and display the normwise relative residual given by\n    \\bes\n    \\frac{\\| PA - LU\\|_\\infty}{\\|A\\|_\\infty}\n    \\ees\n    In exact arithmetic, this number should be zero. In floating point arithmetic, we can expect a small value, and large values will almost certainly be caused by programming errors.\n    \\end{enumerate}\n    \\begin{remark} {\\tt MyFactor} will not return the matrix $P$ explicitly. However, the array {\\tt sigma} contains the necessary information. Specifically, if $B = PA$, then MATLAB can construct $B$ using {\\tt B=A(sigma,:)}.\n    \\end{remark}\n\\end{problem}\n\n\\begin{problem} Develop a function {\\tt work/MyGauss.m} which uses the functions {\\tt MyFactor}, {\\tt MyForward}, {\\tt MyBackward} to solve a linear system $AX=F$ where $A$ is a non-singular $m$ by $m$ matrix and $F$ is an $m$ by $n$. Develop a minimal working example {\\tt work/MyGaussMWE.m} which verifies that {\\tt MyGauss} is working as advertised. In particular, the script must compute the normwise relative error and the normwise relative residual for each column. Large normwise relative errors are possible, but large normwise relative residuals strongly suggest programming errors.\n\\end{problem}\n\n\\end{document}\n", "meta": {"hexsha": "00e5740a6ad37db1a065812b9857a8146458ef6c", "size": 5373, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Courses/Numerical Analysis/lab exercises/lab8/specification/lab9.tex", "max_stars_repo_name": "itismesam/Courses-1", "max_stars_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2020-09-30T13:45:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T10:22:19.000Z", "max_issues_repo_path": "Courses/Numerical Analysis/lab exercises/lab8/specification/lab9.tex", "max_issues_repo_name": "itismesam/Courses-1", "max_issues_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Courses/Numerical Analysis/lab exercises/lab8/specification/lab9.tex", "max_forks_repo_name": "itismesam/Courses-1", "max_forks_repo_head_hexsha": "7669c4460be02b8bbaea2ae79182af2667e9e6b2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2020-10-06T07:05:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T10:23:29.000Z", "avg_line_length": 56.5578947368, "max_line_length": 591, "alphanum_fraction": 0.7277126373, "num_tokens": 1583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.8244619242200081, "lm_q1q2_score": 0.4186715467653825}}
{"text": "\\chapter{Multi-layer Kernels in Structured Output Spaces}\n\\label{chap_struct}\n\nThis chapter focuses on evaluating multi-layer arc-cosine kernels on structured output prediction problems. The contents of this chapter are organized as follows; section \\ref{chap5_intro} gives a brief description about the large margin formulation of pattern recognition problem on structured output spaces, section \\ref{chap5_exp} talks about the result of empirical study on multi-class and multi-label classification problems and section \\ref{chap5_conc} concludes the chapter.\n\n\\section{SVM in Structured Output Spaces}\n\\label{chap5_intro}\nTypically machine learning algorithms are designed to produce flat real valued outputs; in the case of classification problems the output is a class label, for regression the output is a real number. For structured output learning algorithms, the output space has structured and interdependent variables, which is usually stored and processed as multi-dimensional arrays. For example, in the case of natural language parsing the output is a parse tree, in the case of image segmentation the output is the four 2D cordinates of bounding box surrounding the object. Two popular algorithms which works well in this domain are Conditional Random Fields(CRF\\nomenclature{CRF}{Conditional Random Field}) proposed by \\cite{crf} et al. and Structural SVMs proposed by \\cite{joachims_struct} et al. In this project, we did our study on structural SVMs.\n\nStructural SVMs are first introduced by \\cite{joachims_struct} et al. in 2005, and  studied by \\cite{joachims_cutting} et al. for simplifying the optimization problem while dealing with exponentially huge number of constraints. In particular, the number of constraints in the formulation of StructSVM is equal to the cardinality of the output space(which is exponential or even infinite). So decomposition methods like SMO\\nomenclature{SMO}{Sequential Minimal Optimization} which process each constraints explicitly is not suitable for these kind of problems. \\cite{joachims_cutting} et al. proved that the optimization problem can be solved efficiently using cutting plane algorithm proposed by \\cite{cutting_plane}. They also proved that the number of iterations are independent of the number of training examples and provided an upper bound on the number of iterations.  \n\n\\subsection{StructSVM : Formulation}\nStructured output prediction describes the problem of learning a function\n\\[ h: \\mathcal{X} \\longrightarrow \\mathcal{Y} \\]\nwhere $\\mathcal{X}$ is the input space and $\\mathcal{Y}$ is the output space(structured). To learn $h$, we assume that a training sample of input-output pairs\n\\[ S = ((x_1, y_1), \\ldots, (x_n, y_n)) \\in (\\mathcal{X} \\times \\mathcal{Y})^n \\]\nis available and drawn i.i.d from a joint distribution P($\\mathcal{X},\\mathcal{Y}$). Following empirical risk minimization principle, we will find an $h \\in \\mathcal{H}$ that minimizes the empirical risk\n\\[ R_s^{\\bigtriangleup} = \\frac{1}{n} \\sum_{i=1}^n \\bigtriangleup(y_i, h(x_i)) \\]\nHere $\\bigtriangleup(y, \\overline{y})$ denotes the \\textbf{loss} associated with predicting $\\overline{y}$ when $y$ is the correct output. The formulation assumes that the loss function is arbitrary and should satisfy the follwing requirments. \n\\begin{equation*}\n\\bigtriangleup(y, \\overline{y}) = \n\\begin{cases}\n > 0 \\textrm{ for } y \\neq \\overline{y} \\\\\n = 0 \\textrm{ for } y = \\overline{y}\n \\end{cases}\n\\end{equation*}\nStructSVM selects an $h \\in \\mathcal{H}$ that minimizes a regularized empirical risk on $S$. The general idea here is to learn a discriminant function $\\mathnormal{f} : \\mathcal{X} \\times \\mathcal{Y} \\longrightarrow \\mathbb{R}$ over input-output pairs from which one derives a prediction by maximizing $\\mathnormal{f}$ over all $y \\in \\mathcal{Y}$ for a given input $x$.\n\\[ h_w(x) =  \\underset{y \\in \\mathcal{Y}}{\\arg\\max} \\mathnormal{f}_w(x,y) \\]\nWe assume that $\\mathnormal{f}_w(x,y)$ is linear in some combined feature space relating x and y, denoted as $\\Psi(x,y)$.\n\\[ \\mathnormal{f}_w(x,y) = (w \\cdot \\Psi(x,y)) \\]\nHere $w \\in \\mathbb{R}^N$ is the parameter vector. Intuitively we can think of $\\mathnormal{f}_w(x,y)$ as a compatibility function that measures how well the output $y$ matches the given input $x$(\\cite{joachims_cutting} et al.). This combined feature representation is required in the formulation, since we assumed that the sample $S$ is drawn from a joint distribution P($\\mathcal{X},\\mathcal{Y}$). Depending upon the structure of the output space, $\\Psi(x,y)$ is defined separately for different problem instances.\n\n\\subsection{Margin Rescaling(MR) Formulation}\nIn order to take the loss into consideration, we modify the soft-margin formulation used in SVMs. The soft-margin formulation is given by\n\\[\\underset{w, \\xi \\geq 0}{\\min} \\quad \\frac{1}{2} \\norm{w}^2 + \\frac{C}{n} \\sum_{i=1}^n \\xi_i \\]\n\\[ \\textrm{s.t } \\forall i \\textrm{, } \\forall \\overline{y} \\in \\mathcal{Y}\\setminus y_i \\textrm{  :  } w^T[\\Psi(x_i, y_i) - \\Psi(x_i, \\overline{y})] \\geq 1 - \\xi_i \\textrm{, } \\xi_i \\geq 0 \\]\nHere $\\xi_i$ is the slack variable and $C$ is the regularization parameter.\n\\[ \\xi_i = \\max\\{ 0, \\max_{y \\in \\mathcal{Y}\\\\y_i}(1 - w^T[\\Psi(x_i, y_i) - \\Psi(x_i, \\overline{y})]) \\} \\]\nAs we have mentioned previously, this optimization problem is intractable for decomposition methods like SMO, since we have $\\mathcal{O}(n|\\mathcal{Y}|)$ constraints in the formulation. In Margin Rescaling\\nomenclature{MR}{Margin Rescaling} formulation, the margin is adjusted according to the loss. In particular, we adjust the position of the hinge by keeping its slope fixed. The loss in MR formulation is computed as\n\\[ \\bigtriangleup_{MR}(y, h_w(x)) =  \\underset{\\overline{y} \\in \\mathcal{Y}}{\\max}\\{ \\bigtriangleup(y, \\overline{y}) - (w^T[\\Psi(x, y) - \\Psi(x, \\overline{y})]) \\}  \\textrm{ } \\geq  \\bigtriangleup(y, h_w(x))\\]\nand slack is obtained as $\\xi = \\max\\{0, \\bigtriangleup_{MR}(y, h_w(x))\\}$. This leads to the following formulation\n\\[\\underset{w, \\xi \\geq 0}{\\min} \\quad \\frac{1}{2} \\norm{w}^2 + \\frac{C}{n} \\sum_{i=1}^n \\xi_i \\]\n\\[ \\textrm{s.t } \\forall \\overline{y_1} \\in \\mathcal{Y} \\textrm{  :  } w^T[\\Psi(x_1, y_1) - \\Psi(x_1, \\overline{y_1})] \\geq \\bigtriangleup(y_1, \\overline{y_1}) - \\xi_1 \\]\n\\[ \\vdots \\]\n\\[ \\textrm{s.t } \\forall \\overline{y_n} \\in \\mathcal{Y} \\textrm{  :  } w^T[\\Psi(x_n, y_n) - \\Psi(x_n, \\overline{y_n})] \\geq \\bigtriangleup(y_n, \\overline{y_n}) - \\xi_n \\]\nIntuitively, the constraints ensures that the score of the correct label $w^T\\Psi(x_i, y_i)$ must be greater than all other scores $w^T\\Psi(x_i, \\overline{y_i}) \\textrm{, } \\forall \\overline{y_i} \\in \\mathcal{Y} \\setminus y_i$ by a required margin. In MR formulation, the margin is $\\bigtriangleup(y_i, \\overline{y_i})$.\n\n\\subsection{Slack Rescaling(SR) Formulation}\nIn Slack Rescaling\\nomenclature{SR}{Slack Rescaling} formulation, the slack variables are rescaled according to the loss. In particular, the slope of the hinge loss function is adjusted while keeping its position fixed. In SR formulation the margin is 1. The loss in SR formulation is computed as\n\\[ \\bigtriangleup_{SR}(y, h_w(x)) =  \\underset{\\overline{y} \\in \\mathcal{Y}}{\\max}\\{ \\bigtriangleup(y, \\overline{y})(1 - (w^T[\\Psi(x, y) - \\Psi(x, \\overline{y})) \\} \\]\nand slack is obtained as $\\xi = \\max\\{0, \\bigtriangleup_{SR}(y, h_w(x))\\}$. This leads to the following formulation\n\\[\\underset{w, \\xi \\geq 0}{\\min} \\quad \\frac{1}{2} \\norm{w}^2 + \\frac{C}{n} \\sum_{i=1}^n \\xi_i \\]\n\\[ \\textrm{s.t } \\forall \\overline{y_1} \\in \\mathcal{Y} \\textrm{  :  } w^T[\\Psi(x_1, y_1) - \\Psi(x_1, \\overline{y_1})] \\geq 1 - \\frac{\\xi_1}{\\bigtriangleup(y_1, \\overline{y_1})} \\]\n\\[ \\vdots \\]\n\\[ \\textrm{s.t } \\forall \\overline{y_n} \\in \\mathcal{Y} \\textrm{  :  } w^T[\\Psi(x_n, y_n) - \\Psi(x_n, \\overline{y_n})] \\geq 1 - \\frac{\\xi_n}{\\bigtriangleup(y_n, \\overline{y_n})} \\]\nBoth of the above formulation has n slack variables, hence it is called n-slack formulation. These formulations can be converted into 1-slack formulation by summing up all the slack variables(\\cite{joachims_cutting} et al.). n-slack formumations have $\\mathcal{O}(n|\\mathcal{Y}|)$ constraints.\n\nThe solution space of this problem is a compact polyhedral convex set. The cutting plane algorithm finds the most violating constraint corresponding to each training example and add it to the working set. After each addition to the working set, we find a solution across all the constraints in working set. This effectively shrinks the size of the version space in a speedy manner. As the iteration continues, the number of constraint violations decreases and the algorithm converges. Every single cut in the convex set corresponds to a constraint violation. Instead of doing a step by step updation, the cutting plane algorithm cuts down a portion of the version space which results in faster convergence.\n\\section{Experiments} \n\\label{chap5_exp}\nEmpirical study was conducted on multi-class and multi-label classification problems. For multi-class problems the loss function used was the absolute difference between labels, and for multi-label problems loss function was the hamming distance between labels expressed in binary form. Since the output space was finite, we used exhaustive search over $\\mathcal{Y}$ in both cases, while finding the most violated constraints. Multi-label and multi-class classification problems are the simplest problem instances that can be studied using StructSVM, since their output space is finite.\n\nThe combined feature map $\\Psi(x,y)$ was constructed as follows. Let $x \\in \\mathbb{R}^d$ and $k$ be the number of classes. Suppose $x$ is represented as $1:x_1, \\ldots, d:x_d$. Then for multi-class problems $\\Psi(x,y)$ was obtained by shifting the indices by $(y-1) \\times d$ positions; i.e.,\n\\[ \\Psi(x,y) = (y-1) \\times d+1:x_1, \\ldots, (y-1) \\times d+d:x_d \\]\nFor multi-label classification problems, we took the binary representation of $y$ and from that we extracted all bit positions that are ON. Then $\\Psi(x,y)$ is computed by applying the same shifting to all the extracted indices.\n\nImplementation was done using \\cite{svm_struct} library, by modifying its API functions for multi-label and multi-class problems. Table \\ref{chap5_tab1} lists the results of empirical study (value shown is the loss in percentage). The synthetic dataset was a multi-class problem instance available in \\cite{svm_struct} library. Here the comparison was made between multi-layer (arc-cosine)kernel machines and commonly used single layer kernel machines.\n\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{table}\n\\centering\n\\begin{tabular}{|c|c|c|}\n\t\\hline\n\t\\textbf{Dataset} & \\textbf{Arc-Cosine Kernel} & \\textbf{Other Kernel(best)}\\\\\n\t\\hline\n\tScene Segentation & 30.35 & 30.60 \\\\\n\t(multilabel - 6 class) & & \\\\\n\t\\hline\n\tVehicle Dataset & 26.48 & 24.90 \\\\\n\t(multiclass - 4 class) & & \\\\\n\t\\hline\n\tIris Dataset & 1.67 & 3.33 \\\\\n\t(multiclass - 3 class) & & \\\\\n\t\\hline\n\tBreast Cancer Wiscosin & 0.98 & 0.98 \\\\\n\t(binary) & & \\\\\n\t\\hline\n\tSynthetic Data & 33.85 & 32.55 \\\\\n\t(multiclass - 7 class) & & \\\\\n\t\\hline\n\\end{tabular}\n\\caption{Performance comparison of multi-layer arc-cosine kernel to other kernels in StructSVM framework.}\n\\label{chap5_tab1}\n\\end{table}\n\\renewcommand{\\arraystretch}{1}\n\n\\section{Conclusion}\n\\label{chap5_conc}\nIn this chapter, we studied multi-layer kernels in structured output spaces. The experimental study was done on multi-label and multi-class problem instances. The results are competetive with single layer kernel machines. Multi-layer architectures are found to be effective in complex pattern recognition tasks. Hence the discriminating power of these multi-layer kernels must be tested in more complex structured output spaces on problems like natural language parsing, protein sequence alignment prediction etc.  \n", "meta": {"hexsha": "175b1efd852de82ac2a7581875d63566f3cd3acb", "size": 11833, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/chapter5.tex", "max_stars_repo_name": "akhilpm/Masters-Project", "max_stars_repo_head_hexsha": "cc10673e695cbc0531f6268d729760705890a116", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/chapter5.tex", "max_issues_repo_name": "akhilpm/Masters-Project", "max_issues_repo_head_hexsha": "cc10673e695cbc0531f6268d729760705890a116", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/chapter5.tex", "max_forks_repo_name": "akhilpm/Masters-Project", "max_forks_repo_head_hexsha": "cc10673e695cbc0531f6268d729760705890a116", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 118.33, "max_line_length": 874, "alphanum_fraction": 0.7441054678, "num_tokens": 3402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4186092317178522}}
{"text": "%!TEX root = main.tex\n\\section{Data}\n\nThe basis of a realistic simulation of global virus outbreak is data on\n\\begin{itemize}\n\t\\item Geographical population densities\n\t\\item Travel connections (commuting and airports)\n\\end{itemize}\n\n\\subsection{Population}\nThe population data used in this report comes from NASA \\cite{nasa-population}. The data is downloadable in a GeoTIFF file-format which is an image file with population encoded in the pixels.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=1.0 \\textwidth]{plots/nasa_population}\n\t\\includegraphics[width=4cm]{plots/nasa_population_colorbar}\n\t\\caption{Plot of population in the world, the used resolution is $0.1 \\times 0.1$ degrees per pixel ($3600 \\times 1800$).}\n\\end{figure}\n\nThe population dataset encodes $99999.0$ as water and $1.0369266$ as unknown population on land. Thus to get a population map, a raster mapping of $(x_i < 99999.0 \\wedge x_i > 1.0369266) \\cdot x_i$ was applied. After this transformation the total world population is just $60,031,128$ (without filtering it is $434,130,384,806$). This is obviously wrong, thus the data is upscaled such the sum is 7.4 billion people, which is the estimated number of people in March 2016 \\cite{wiki-world-population}.\n\n\\subsection{Airport}\n\nThe airport connection data was taken from OpenFlights \\cite{openflights}. The dataset contains 8021 airports with 37181 airline connections as well as the plane types flying the connection (this could potentially be used for estimating passenger counts). Some airports did not have any connections and where thus removed. After this filtering 3256 airports where left.\n\nPlotting the airport connections we see that Europe, East Coast US and East Cost China are the most connected regions. So if a virus spreads takes hold in these areas we would expect it to cause a global outbreak quickly.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=1.0 \\textwidth]{plots/airport_connections.pdf}\n\t\\caption{Plot of all airport connections in the dataset. Because there are so many connections each connection is plotted with a low alpha.}\n\\end{figure}\n\n\\subsection{Aggression}\n\nBased on the location of the airports a Voronoi partition of the of the earths surface is made. From this partitioning one now has geographical regions. The total population of each region can be found by summing over the appropriate pixels in the population dataset. This aggression is the same as done in the GLEaM paper \\cite{GLEaM}.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=1.0 \\textwidth]{plots/voronoi.pdf}\n\t\\caption{Voronoi tessellation based on airport locations. Airports are marked with a dot, region boundaries with lines and dashed lines.}\n\\end{figure}\n\n", "meta": {"hexsha": "4f9985c68898458463bddc9a9382ab2ef0424eb4", "size": 2722, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/data.tex", "max_stars_repo_name": "FrederikWR/course-02443-stochastic-virus-outbreak", "max_stars_repo_head_hexsha": "4f1d7f1fa4aa197b31ed86c4daf420d5a637974e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/data.tex", "max_issues_repo_name": "FrederikWR/course-02443-stochastic-virus-outbreak", "max_issues_repo_head_hexsha": "4f1d7f1fa4aa197b31ed86c4daf420d5a637974e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/data.tex", "max_forks_repo_name": "FrederikWR/course-02443-stochastic-virus-outbreak", "max_forks_repo_head_hexsha": "4f1d7f1fa4aa197b31ed86c4daf420d5a637974e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.8636363636, "max_line_length": 500, "alphanum_fraction": 0.7898603968, "num_tokens": 673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.4186092317178522}}
{"text": "\\subsection{Coercible}\nWe now discuss a possible solution to the problems encountered when defining the sample $ex3_wrong$. We give a predicate that expresses the relation of coercive subtyping:\n\\begin{lstlisting}\nclass Coercible a b where\n  coerce :: a -> b\n\\end{lstlisting}\n\n\\subsection{Coercion for References}\nWe wish to instance the coercion predicate to references. References are:\n\\begin{itemize}\n\\item covariant in the referenced type\n\\item contravariant in the state type\n\\end{itemize}\nThis happens because a reference to some $a$ can be used whenever a reference to an $a$ such that $a \\le a'$ is expected, and also (as seen in the third example above), a reference that works on a state $s'$ can be used whenever a state $s$ such that $s \\le s'$ is available. Of course, the fact that references express not only reading values and states but also writing will make this operation relatively tricky.\n\nAt the moment we will only focus on expressing the coercion relation for the state of the reference; the coercion relation for the value of the reference will be discussed together with inheritance.\n\nThe kind of operation that we wish to perform when coercing a reference to work on a larger memory is summarized in Figure \\ref{fig:ref_coerce}. Whenever we wish to perform some operation on a reference to the smaller memory, we will:\n\\begin{itemize}\n\\item take only the first part of the (larger) input memory \n\\item perform the operation on the obtained smaller memory through the original reference we have coerced\n\\item replace the first part of the (larger) input memory with the (smaller) modified memory\n\\end{itemize}\n\n\\begin{figure}[h]\n\\centerline{\\psfig{file=heap_upcasting.png,height=5cm}} \\caption{Coercing references.\\label{fig:ref_coerce}}\n\\end{figure}\n\nWe instance the coercion predicate for references to perform a single step of coercion, that is for the case when we have a reference to a memory $tl$ and we want to use it where we expect a memory $Cons\\ h\\ tl$:\n\\begin{lstlisting}\ninstance HList tl => Coercible (Ref St tl a) (Ref St (Malloc h tl) a) where\n  coerce ref =\n    StRef (St(\\(Malloc h tl) ->\n                          let (res, tl') = get ref tl\n                          in (res, h `Malloc` tl')))\n          (\\v -> St(\\(Malloc h tl) -> \n            let ((),tl') = set ref tl v\n            in ((),h `Malloc` tl')))\n    where get (StRef (St g) _) = g\n          set (StRef _ s) = \\st -> \\v -> \n                                         let (St s') = s v\n                                         in s' st\n\\end{lstlisting}\n\nNow we can finally rewrite the example above to make use of our new coercion operator:\n\\begin{lstlisting}\nex3 :: forall m0 m1 m2 st . (HList m0, State st, m1 ~ Malloc Int m0, m2 ~ Malloc String m1, Monad (st m2 m2),\n                             Coercible (Ref st m1 Int) (Ref st m2 Int)) => st m0 m2 String\nex3 = do+ i <- new 10\n          s <- new \"Hello\"\n          ((coerce i) :: Ref St (String `Malloc` Int `Malloc` Nil) Int) *= (+2)\n          s *= (++ \" World\")\n          eval s\n\nres3 = runSt ex3 Nil\n\\end{lstlisting}\n", "meta": {"hexsha": "3cb9ddd768624e6d7b05b19acf196ca13875aa75", "size": 3082, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex_v2/5.subtyping.tex", "max_stars_repo_name": "vs-team/Papers", "max_stars_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-04-06T08:46:02.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-19T07:16:23.000Z", "max_issues_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex_v2/5.subtyping.tex", "max_issues_repo_name": "vs-team/Papers", "max_issues_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Before Giuseppe's PhD/Monads/ObjectiveMonad/MonadicObjects/trunk/tex_v2/5.subtyping.tex", "max_forks_repo_name": "vs-team/Papers", "max_forks_repo_head_hexsha": "58fa4a3b4c8185ad30bf9a142002d87ceca756e6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.0701754386, "max_line_length": 415, "alphanum_fraction": 0.6735885788, "num_tokens": 793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.41860922485307567}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\\begin{center}\n\t\\centering\n\t\\includegraphics[width=\\linewidth,height=4cm]{comparison2.png}\n\t\\captionof{figure}{\\label{fig:cvae} Overview of scene sampling and CVAE distribution learning.}\n\\end{center}\n\n\\subsubsection{Overview}\nThe proposed approach consists of image to image comparison with conditional \nvariational autoencoders (CVAE) \\cite{kingma2014semi}, as shown in \\textbf{Fig.} \n\\ref{fig:cvae}. The CVAE is a semi-supervised method for approximating the \nunderlying generative model that produces a set of images and their \ncorresponding class labels in terms of the so-called unobserved latent \nvariables. Each of the input images is described in terms of a probability \ndistribution over the latent variables and the classes. \n\nTheir approach consists of using the probability distributions calculated by \nthe CVAE for each image as a descriptor. The comparison between an image query \nand the 3D scene renderings is with respect to the probability distributions \nobtained from the CVAE. The method consists of data pre-processing, training \nand retrieval described in the following subsections.\n\n\\subsubsection{Data Preprocessing}\nThirteen renderings are obtained for each of the 3D scenes. Each of the 3D \nscenes has a predefined view when loaded into the SketchUp software. This view \nis saved as a 2D view together with twelve views at different angles around the \nscene as in \\cite{Su2015}.\nThe training data set consists of the 3D scene renderings together with the \ntraining images. All images are resized to a resolution of $64\\times64$ and all \npixel values are normalized to the interval $[0,1]$. Image data augmentation is \ncarried out by performing a horizontal flip to all images. The corresponding \ndata space is $X = [0,1]^{64\\times 64 \\times 3}$, while the 3 represents the \ncolor space. \n\n\\subsubsection{Training}\nThe CVAE consists of an encoder and a decoder neural network. The encoder network calculates from an image $x\\in X$ the parameters of a probability distribution over the latent space $Z = \\mathbb{R}^d$ and over the thirty class values in $Y = \\{1,2,3,\\ldots, 30\\}$. The decoder network calculates from a latent variable $z\\in Z$ and a class $y\\in Y$, the parameters of a distribution over the data space $X$ .\n\nThe distributions for the encoder correspond to a normal distribution over $Z$ \nand a categorical distribution over $Y$. A normal distribution over $X$ is \nchosen for the decoder. The probabilistic model used corresponds to the M2 \nmodel described in the article \\cite{kingma2014semi}. Both the encoding and \ndecoding neural networks are convolutional.\n\nThe CVAE is fed with batches of labeled images during training. The loss function is the sum of the negative Evidence Lower Bound (ELBO) and a classification loss. The ELBO is approximated by means of the parametrization trick described in \\cite{kingma2014semi, kingma2013auto} and represents the variational inference objective. The classification loss for their encoding distributions over $Y$ corresponds to the cross entropy between the probability distribution over $Y$ with respect to the input label. \n\n\\subsubsection{Retrieval}\nAfter training, an image $x\\in X$ can be described as a conditional joint \ndistribution over $Z\\times Y$. The density $q_\\phi(z|x)$ corresponds to a \nnormal distribution and $q_\\phi(y|x)$ to a categorical distribution over $Y$, \nwhere $\\phi$ represents the weights of the encoder neural network. The joint \ndensity corresponds to $q_\\phi(z,y|x) = q_\\phi(z|x) q_\\phi(y|x)$.\n\nThe similarity $D$ between an input query image $x^*\\in X$ and a 3D scene in \nterms of its $N$ rendered images $S = \\{x_r\\}_{r=1}^{N}$ is given by the \nminimum symmetrized cross entropy $H_s$ between the query and the rendered \nimages' probability distributions (see \\textbf{Fig.} \\ref{fig:cvae}).\n\n\\begin{multline}\n D(x^*, S)\\min_{r\\in\\{1,2,\\ldots,13\\} }H_s(q_\\phi(z|x^*),q_\\phi(z|x_{r}))\\\\\n+\\alpha H_s(q_\\phi(y|x^*),q_\\phi(y|x_{r})).\n\\end{multline}\n\nThey have used the parameter $\\alpha = 64\\times 64 \\times 3$ to increase the importance of label matching. A ranking of 3D scenes is obtained for each query according to this similarity.\n\n\\subsubsection{Five Runs}\nThey have sent five submissions corresponding to methods who differ only on the architecture of the encoding and decoding neural networks. These are described as follows:\n\\begin{enumerate}\n    \\item \\textbf{CVAE-(1,2,3,4)}: CVAE with different CNN architectures for the encoder and decoder.\n    \\item \\textbf{CVAE-VGG}: CVAE with features from pre-trained VGG \\cite{gkallia2017keras_places365} on the Places data set \\cite{Places88} as part of the encoder.\n    \n\\end{enumerate}\n\n\n\\end{document}", "meta": {"hexsha": "d55d40682fe005fd7d1118cec67bf01ba7d614ed", "size": 4732, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "journal/SceneIBR2019_latex_src/Sections/perez.tex", "max_stars_repo_name": "Hammania689/shrec_2019", "max_stars_repo_head_hexsha": "61b0357482d9a4eae3096abc91f83ab9b803e412", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "journal/SceneIBR2019_latex_src/Sections/perez.tex", "max_issues_repo_name": "Hammania689/shrec_2019", "max_issues_repo_head_hexsha": "61b0357482d9a4eae3096abc91f83ab9b803e412", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "journal/SceneIBR2019_latex_src/Sections/perez.tex", "max_forks_repo_name": "Hammania689/shrec_2019", "max_forks_repo_head_hexsha": "61b0357482d9a4eae3096abc91f83ab9b803e412", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.2631578947, "max_line_length": 508, "alphanum_fraction": 0.7749366019, "num_tokens": 1212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.41860922485307556}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{setspace}\n\n\\usepackage{amsmath, amsfonts, amssymb, graphicx, color, fancyhdr, lipsum, scalerel, stackengine, mathrsfs, tikz-cd, mdframed, enumitem, framed, adjustbox, bm, upgreek, xcolor, hyperref}\n\\usepackage[framed,thmmarks]{ntheorem}\n\n%Replacement for the old geometry package\n\\usepackage{fullpage}\n\n%Input my definitions\n\\input{./mydefs.tex}\n\n%Shade definitions\n\\theoremindent0cm\n\\theoremheaderfont{\\normalfont\\bfseries} \n\\def\\theoremframecommand{\\colorbox[rgb]{0.9,1,.8}}\n\\newshadedtheorem{defn}[thm]{Definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%% Customize Below %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%header stuff\n\\setlength{\\headsep}{24pt}  % space between header and text\n\\pagestyle{fancy}     % set pagestyle for document\n\\lhead{Workshop Notes} % put text in header (left side)\n\\rhead{Nico Courts} % put text in header (right side)\n\\cfoot{\\itshape p. \\thepage}\n\\setlength{\\headheight}{15pt}\n\\allowdisplaybreaks\n\n% Document-Specific Macros\n% Primes and Maximals for the lazy person.\n\\newcommand{\\p}{\\frakp}\n\\newcommand{\\m}{\\frakm}\n\\DeclareMathOperator{\\Spec}{Spec}\n\\DeclareMathOperator{\\supp}{supp}\n\\newcommand{\\SH}{\\mathcal{SH}}\n\\DeclareMathOperator{\\DMack}{DMack}\n\\DeclareMathOperator{\\Sing}{Sing}\n\\DeclareMathOperator{\\SpcBal}{Spc_{Bal}}\n\\newcommand{\\Rep}{\\mathbf{Rep}\\,}\n\n%stable module category stuff\n\\DeclareMathOperator{\\uHom}{\\underline{Hom}}\n\\DeclareMathOperator{\\uExt}{\\underline{Ext}}\n\\DeclareMathOperator{\\uEnd}{\\underline{End}}\n\n%group schemes\n\\newcommand{\\Ga}{\\bbG_a}\n\n\\begin{document}\n%make the title page\n\\title{Workshop Notes\\vspace{-1ex}}\n\\author{Nico Courts}\n\\date{June 24-28, 2019}\n\\maketitle\n\n\\renewcommand{\\abstractname}{Introduction}\n\\begin{abstract}\n\tThese notes were the ones I took while attending the ``Triangulated Categories in Geometry and Representation Theory'' Workshop \n\tat the University of Sydney during the week beginning June 23, 2019.\n\\end{abstract}\n\n\\section{The spectrum of the category of derived Mackey functors}\nThis talk was given by Beren Sanders on a joint work alongside Irakli Patchkoria and Christian Wimmer.\n\nFirst we are going to talk about tensor triangulated geometry. Essentially we are looking at \nan essentially small tensor triangulated category and then we want to talk about the ``geometry''.\nAnalogous to the way we define the spectrum of a ring, we can define \n\\begin{defn}\n\tThe \\textbf{spectrum} of a tensor-triangulated category $\\calK$ is \n\t\\[\\operatorname{Spec}{\\calK}=\\{\\p\\subsetneq \\calK|\\p\\text{is a prime tensor triangulated ideal}\\}\\]\n\\end{defn}\n\nThen if $X\\in\\calK$ is an object, then we can define the support of $X$ to be \n\\[\\operatorname{supp}(X)=\\{\\p\\in\\operatorname{Spec}(\\calK)|x\\notin\\p\\}\\]\n\nWe define the closure of a prime to be the set of primes that are contained in it. There are some great universal properties.\n\n\\begin{lem}\n\t\\begin{itemize}\n\t\t\\item $\\Spec(D(T)^c)\\cong\\Spec(R)$\n\t\t\\item $\\Spec(\\Db(kG-\\mathbf{mod}))\\cong \\Spec(H^\\ast(G,k))$.\n\t\\end{itemize}\n\tThe second result is was generalized by (among others) Julia to group schemes.\t\n\\end{lem}\n\n\\subsection{The Stable Homotopy Category}\nThis is the context for most of the talk for today. Let $\\SH$ be the stable homotopy category.\nThere are a couple sources for objects here. We can consider $\\sigma^\\infty X$, the infinite suspension of a pointed space, \nor a cohomology theory $\\bbE$ (e.g. singular cohomology).\n\n$\\SH$ is a tensor-triangulated category although I missed the tensor structure.\n\n\\begin{thm}[Balmer `10]\n\tThere is a \\textbf{comparison map}, a continuous map\n\t\\[\\rho_\\calK:\\Spec(\\calK)\\to \\Spec(\\End_\\calK(1))\\]\n\twhere $1$ is the monoidal unit (since I haven't set up the macro for the bb font.)\n\\end{thm}\nThe idea here is that the object on the right is more easy to understand in general.\n\nSo for the example of $\\SH^c$, we can compute that the endomorphism ring is $\\bbZ$. \nThen if we look at any prime $\\p\\in\\Spec(\\bbZ)$, the fiber contains all the extraordinary cohomology theories \nthat correspond to computing cohomology over characteristic $p$ fields.\n\n\\subsection{The spectrum of \\texorpdfstring{$\\SH(G)$}{SH(G)}}\nIf $G$ is a finite group, then $\\SH(G)$ is the $G$-equivariant stable homotopy group.\nIn this case, the endomorphism ring is known as the Burnside ring $A(G)$.\n\nDress in `69 computed the spectrum of $A(G)$: For each $H\\le G$, we ahve a ring homomorphism \n\\[f^H:A(G)\\to \\bbZ\\]\nwhere $[X]$ is sent to $|X^H|.$ These induce embeddings:\n\\[(f^H)^\\ast:\\Spec(\\bbZ)\\to\\Spec(A(G))\\]\nwhere $(p)\\mapsto \\p(H,p)$ and $(0)\\mapsto \\p(H,0)$.\n\n\\begin{defn}\n\tLet $O^p(G)$ be the smallest normal subgroup of $G$ such that $G/O^p(G)$ is a $p$-group.\n\\end{defn}\n\\begin{thm}[Dress '69]\n\t$\\p(H,p)=\\p(K,p)$ if and only if $O^p(H)\\sim_G O^p(K).$\n\\end{thm}\n\\begin{rmk}\n\tFor example if $p\\nmid |G|$ then $O^p(H)=H$ for all $H\\le G$. If $G$ is a$p$ group, then $O^p(H)=1$ for all $H$.\n\\end{rmk}\n\n\\subsection{Categorifying Dress' Work}\nFOr each $H\\le G$, we have the \\textbf{geometric $H$-fixed points functor}\n\\[\\Phi^H:\\SH(G)^c\\to \\SH^c\\]\nthat induce embeddings \n\\[(\\Phi^H)^\\ast:\\Spec(\\SH^c)\\hookrightarrow \\Spec(\\SH(G)^c)\\]\nwhere $\\calC_{p,n}\\mapsto \\calP(H,p,n)$. Furthermore the copies of $\\Spec(\\SH^c)$ cover $\\Spec(\\SH(G)^c)$. T\n\\textbf{They do not overlap.}\n\nThe speaker, together with Paul Blamer, computed the spectrum of $\\SH(G)^c$. The picture is interesting, but there is a topological connecting\nthem: In particular when $G=C_p$, $\\calP(1,p,n)\\not\\subseteq \\calP(G,p,n)$ but $\\calP(1,p,n+1)$ is.\n\n\\begin{defn}\n\tFor a finite $p$-group $G$, define the ``blue shift'' to be \n\t\\[\\beta(G,n)\\]\n\twhich is the smallest $i$ such that $\\calP(1,p,n+i)\\subseteq\\calP(G,p,n)$\n\\end{defn}\nIt was shown that for $p$ groups, $\\beta(G,n)$ is the free rank of $G$.\n\\begin{rmk}\n\tFor instance, $\\beta((C_p)^r,n)=r$ and $\\beta(C_{p^r},n)=1$\n\\end{rmk}\n\nThe bottom line here is that the spectrum of the $G$-equivariant can be understood ``locally''\nas $\\Spec(A(G))$.\n\n\\subsection{``Linearization'' of stable homotopy theories}\nSome examples of what we're talking about: We can in some way think of the linearization of $\\SH$ as being $\\D(\\bbZ)$.\nFurthermore, the motivic derived category of $k$ could be the linearization of $\\SH^{\\bbA^1}(k)$.\n\nIn our case, we may want to consider the derived category of Mackey functors on $G$ as the linearization of $\\SH(G)$. Mackey functors \nare functors that behave well with respect to the group/representation theory (e.g. induction and restriction).\n\nOne may think this category is the derived category of the abelian category of $G$-Mackey functors, but \nKaledin (2008) argues that it should be this other category $\\DMack(G)$. The speaker computed the spectrum of this \ncategory as well as developing a different construction.\n\nOne interpretation of the linearization in the earlier cases is that $\\SH$ is the derived category of a circle \nand $D(\\bbZ)$ is the derived category of the Eilenberg-Maclane spectrum $H\\bbZ$. For our example, we can define \n$H\\bbZ_G$ to be $H\\bbZ$ considered as a trivial $G$-module in $\\SH(G)$. Then we say \n\\[\\D(H\\bbZ_G)=\\DMack_{Kal}(G)\\]\nand compute the spectrum.\n\n\\begin{thm}\n\tThe extension of scalars functor \n\t\\[\\SH(G)\\to D(H\\bbZ_G)\\]\n\tinduces an embedding \n\t\\[\\Spec(D(H\\bbZ_G))\\hookrightarrow \\Spec(\\SH(G))\\]\n\tinto the top and bottom layers. \n\\end{thm}\n\nThe main takeaway her is that for $C_p$ the spectrum of the derived category of Mackey functors lies between that \nof $A(C_p)$ and of $\\Spec(\\SH(C_p))$ where the first step splits points into two and the second introduces this chromatic splitting. \n\n\\section{Supports and Cosupports in the Stable Module Category}\nThis series of talks was given by Julia Pevtsova.\n\n\\subsection{Tensor triangulated geometry for finite group schemes}\nLet $A$ be a finite dimensional Hopf algebra and associate to $A$ the category $\\Sing(A)$, the singularity category of $A$ which measures how non-semisimple\n$A$ is. One of the reasons we ways to approach tensor-triangulated geometry is to develop what points are. As a disclaimer, Julia \nsays that there might be some misunderstandings she has here, but that it has been developed by Balmer and Krause.\n\nFor some motivation, let $R$ be a commutative ring, $\\p\\in\\Spec R$ and let $M$ be an $R$-module. We can gain local information \nby looking at $M_\\p$ or $M\\otimes_R k_p$.\n\nNow ler $\\calT=\\D(R)$ where $\\calT^c=\\Dbperf(R)$. Take $Y\\in\\calT$ and $\\p\\in\\Spec(R)$ and we can define $Y_\\p$ or \n$Y\\otimes_R^Lk_p$. Then we define \n\\[\\supp Y=\\{\\p\\in\\Spec R|Y\\otimes_R^Lk_\\p\\ne 0\\}.\\]\n\nThis has some nice properties:\n\\begin{itemize}\n\t\\item (Defection Property) $Y\\simeq 0\\Leftrightarrow \\supp Y=\\varnothing$.\n\t\\item Invariant under $\\otimes, \\oplus,$ cones, and syzygies.\n\\end{itemize}\n\\begin{thm}[Neeman '92]\n\tThe class of localizing subcategories in $\\D(R)$ (here $R$ is Noetherian) are in one to one correspondence via $\\supp$ to the subsets in $\\Spec R$.\n\n\tFurthermore restricting to $\\calT^c$, the thick subcategories in $\\Dbperf(R)$ correspond to specialization closed subsets in $\\Spec R$.\n\\end{thm}\n\n\\subsection{General Definitions and \\texorpdfstring{$\\SpcBal(\\calT^c)$}{SpcBal(Tc)}}\n\\begin{defn}\n\tLet $T$ be a tensor triangulated category. We say that $\\calC\\subseteq\\calT$ is \\textbf{localizing} subcategory if $\\calC$ is a full triangulated \n\tsubcategory that is closed under $\\oplus$.\n\n\t$\\calC\\subseteq \\calT^c$ is \\textbf{thick} if it satisfies the same conditions. \n\n\t$\\calC\\subseteq\\calT$ is a tensor ideal if it absorbs tensor products.\n\\end{defn}\n\n\\begin{rmk}\n\tIn this talk $\\calT$ is symmetric but this works in braided categories.\n\\end{rmk}\n\\begin{defn}\n\tThe \\textbf{Balmer Spectrum of $\\calT^c$} is defined via a map $T^c\\mapsto \\SpcBal(T^c)$ where we send \n\t$M\\mapsto\\supp_{Bal}M$.\n\\end{defn}\n\nNow knowing $\\SpcBal(T^c)$ is equivalent ot classifying thick tensor ideals in $T^c$. When $T^c=\\Dbperf(R)$, \nand $\\p\\in\\Spec R$, the map $R\\to k_\\p$ induces maps \n\\[\\Dbperf(R)\\to \\Dbperf(k_\\p)=\\D\\mathbf{Vect}_{k_\\p}\\]\nand thus \n\\[\\SpcBal \\D\\mathbf{Vect}_{k_\\p}\\to \\SpcBal\\Dbperf(R).\\]\n\n\\subsection{Doing this in modular representation theory}\nClassically we are doing modular representation theory when we have a finite group $G$ and a field $k$ where $\\ch k| |G|$.\nIn essence this is just saying that our representation theory is with non-semisimple rings.\n\nWe can do this theory on a series of objects:\n\\begin{itemize}\n\t\\item Finite groups (as above)\n\t\\item Finite group schemes\n\t\\item Finite supergroup schemes\n\t\\item Small quantum groups\n\t\\item Algebraic group $G$ and algebra $A$ over $G$. Then considering $\\operatorname{Bimon}(G,A)$ is one possibility.\n\t\\item Finite dimension pointed Hopf algebras\n\t\\item Lie superalgebras (characteristic zero).\n\t\\item One can continue the list. The idea here is that you have a big enough endomorphism ring.\n\\end{itemize}\n\nToday we are focusing on finite group schemes (FGS) although we might get to say something about supergroup schemes and quantum groups.\n\n\\subsection{Affine Group Schemes}\n\\begin{defn}\n\tAn \\textbf{affine groups scheme $G$ over $k$} is a representable functor $G$ from commutative $k$-algebras to groups.\n\\end{defn}\n\n\\begin{rmk}\n\t$G(R)\\cong \\Hom_{\\Algk}(k[G],R)$ is how the representation works. $k[G]$ is a commutative Hopf algebra. $G$ is finite if $\\dim_kk[G]<\\infty$.\n\\end{rmk}\n\n\\begin{defn}\n\t\\[kG:=k[G]^\\vee=\\Hom_k(k[G],k)\\]\n\tis the \\textbf{group algebra} corresponding to $G$. This is a finite dimension cocommutative Hopf algebra.\n\\end{defn}\n\n\\begin{rmk}\n\tThere is an equivalence of categories between finite group schemes and finite dimensional cocommutative Hopf algebras using $G\\mapsto kG$. \n\tFurthermore, the category $\\mathbf{Rep}_kG$ is equivalent to $kG$-$\\mathbf{Mod}$ (here uppercase will denote non-finite-dimensional), which we will call $G$-$\\mathbf{Mod}$.\n\\end{rmk}\n\nThen we can define the cohomology for $G$ via the Hochschild cohomology\n\\[\\Ext_G^\\ast(k,k)=H^\\ast(G,k)=H^\\ast(kG,k)\\]\n\nSome examples of these are finite groups, restricted Lie algebras (Lie algebra over fields of positive characteristic that also have a $p^{th}$ power operation). \nTo construct a restricted Lie algebra, One cal let $\\calG$ be some algebraic group. Then $\\operatorname{Lie}\\calG=\\frakg$ is a restricted Lie algebra.\nThe representation theory of such a $\\frakg$ is precisely the representation theory of the (finite-dimensional, cocommutative) Hopf algebra $u(\\frakg)$,\nthe quotient of the universal enveloping algebra that identifies $p^{th}$ powers (in the PBW basis) with the internal $p^{th}$ powers in $\\frakg$.\n\nMore generally one can consider \\textbf{Frobenius kernels}. Let $F:\\calG\\to\\calG$ be the Frobenius map. Then \n$\\calG_{(1)}=\\ker F$ and more generally $\\calG_{(r)}=\\ker F^(r)$, the $r^{th}$ iteration of $F$. These are connected\nfinite group schemes. These things have only a single point! However the group algebra and coordinate algebra really still capture \nall the representation theory of the original group.\n\nIf $\\calG$ is an algebraic group, then we can compute $\\calG_{(1)}$ and $\\operatorname{Lie}\\calG$ and \n\\[k\\calG_{(1)}\\cong u(\\operatorname{Lie}(\\calG)).\\]\n\nWhen $\\calG=\\Ga$, then $k[\\Ga]=k[T]$ where $\\Delta T)=T\\otimes 1+1\\otimes T$ and \n\\[{\\Ga}_{(r)}(R)=\\{a\\in R|a^{p^r}=0\\}.\\]\nNow $k[{\\Ga}_{(r)}]=k[T]/(T^{p^r})$ and $k{\\Ga}_{(r)}=k[u_0\\cdots,u_{r-1}]/(u_0^p,\\dots,u_{r-1}^p)$\n\nRecall that $\\StMod G$ is the category of $G$ representations where homs are considered module factoring through projective objects. This becomes a tensor triangulated category \nwhere the triangles comes from short exact sequences in $\\Rep G$ and tensor is the usual one. The shift functor is the syzygy functor $\\Omega^{-1}$ and the monoidal unit is $k$.\n\n\\begin{rmk}\n\tWe have an exact sequence \n\t\\[\\D(G)\\to \\K(\\mathbf{Inj}(G))\\to\\StMod G\\]\n\tand \n\t\\[\\Dbperf(G)\\to \\Db(G)\\to\\mathbf{stmod} G\\cong\\Dsing(G).\\]\n\tso in a way this measures the lack of regularity in the sense of commutative algebra.\n\\end{rmk}\n\nNow here we can talk about $\\uEnd^\\ast(k)$ as well as \n\\[\\uHom^\\ast(M,N)=\\oplus_n\\uHom(M,\\Omega^{-n}N)\\]\nand \n\\[\\uEnd^\\ast(k)\\cong\\widehat\\Ext_G^\\ast(k,k)=\\hat H^\\ast(G,k)\\]\nwhere the hat denotes Tate cohomology.\n\nNow $\\uEnd^\\ast(k)$ acts on $\\calT$ (on $\\calT^c$) by acting on $\\uHom^\\ast(M,N)$.\n\nTHis leads to to Benson-Iyengar-Krause support theory where \n\\[R=H^\\ast(G,k)\\to\\hat H^\\ast(G,k)\\]\nacts on $\\calT$.\n\nWe can try setting $X=\\Spec R=\\Spec H^\\ast(G,k)$ for the space where the support lives.\n\n\\subsection{\\texorpdfstring{$\\pi$}{pi}-points and local cohomological functors}\nRecall last time we lookedd at $R=H^\\ast(G,k)=\\Ext_G^\\ast(k,k)$ acting (via $\\uEnd^\\ast(k)$ on $\\StMod G$, where $G$ was a finite group scheme.\n\nFor examples we considered $\\frakg=\\operatorname{Lie}\\frakG$ where $\\frakG$ is a reducitive algebraic group. Here \n$H^{odd}(\\frakg,k)=0$ and $H^{ev}(\\frakg,k)\\simeq k[\\calN]$ where $\\calN$ are the set of nilpotents in $\\frakg.$\n\n\\begin{thm}\n\tWhen $\\frakg$ is a restricted Lie algebra,\n\t\\[\\Spec H^\\ast(\\frakg,k)=\\calN^{[p]}=\\{x\\in\\frakg|x^{[p]}=0\\}.\\]\n\\end{thm}\n\\begin{thm}[Suslin-Friedlander-Bendel '97]\n\t\\[\\Spec H^\\ast(GL_{n(r)},k)\\]\n\tis the variety of $r$ duples of $p$-nilpotent commuting matrices.\n\\end{thm}\n\nSome facts about cohomology:\n\\begin{itemize}\n\t\\item $H^\\ast(G,k)$ is a graded commutative algebra.\n\t\\item Friedlander and Suslin in '95 proved $H^\\ast(G,k)$ is finite generated (has FG).\n\\end{itemize}\n\nThe idea to develop the support theory is to look in $X=\\operatorname{Proj}(R)$ and then proceed via either $\\pi$-points or via local cohomological functors (developed by Bens0n, Iyengar, and Krause).\n\n\\begin{ex}\n\tAnother motivational example: let $\\frakg$ be a restricted Lie algebra. Define $X=\\operatorname{Proj}H^\\ast(\\frakg,k)\\simeq\\calN^{[p]}$\n\\end{ex}\n\n\\begin{rmk}\n\t$\\frakg_a=\\operatorname{Lie}\\Ga$ is an algebra that is very small since $u(\\frakg_a)=k[x]/x^p$. Now $\\StMod k[x]/x^p$ is called a ``tt-field'', and for any $x\\in\\calN^{[p]}\\subseteq\\frakg$,\n\tsetting $\\frakg_a=\\langle x\\rangle$ gives us a functor \n\t\\[\\calF_x:\\StMod\\frakg\\to\\StMod\\frakg_a\\]\n\tinduced by inclusion.\n\n\tNow $\\calF_x$ is a tensor triangulated functor and this functor exists for all $x$ in the nilcone (or its image in the projective closure $X$).\n\\end{rmk}\n\\begin{defn}\n\tLet $M\\in\\StMod G$. Then the support is \n\t\\[\\supp M=\\{x\\in\\calN^{[p]}|M|_{\\langle x\\rangle}=\\calF_x(M)\\neq 0\\}\\subseteq X=\\operatorname{Proj}\\calN^{[p]}\\]\n\\end{defn}\n\n\nThe support satisfies all the good properties. (?)\n\nif $G$ is a finite group scheme then as we have seen $kG$ is a finite dimensional cocommutative Hopf algebra.\n\\begin{defn}\n\tIf $K/k$ is an extension, then \n\t\\[\\alpha:K[t]/t^p\\to KG=kG\\otimes_k K\\]\n\tis a $\\pi$-point if it's flat and there is $\\calU\\subseteq G_K$ such that $\\alpha$ factors through $K\\calU$ where $\\calU$ is \n\ta unipotent abelian subgroup scheme of $G_K$.\n\\end{defn}\n\nGiven such a map $\\alpha:K[t]/t^p\\to KG$, we get a functor \n\\[\\calF_\\alpha:\\StMod G\\to\\StMod K[t]/t^p\\]\nwhere the codomain is a tt-field.\n\\begin{rmk}\n\t$\\calF_\\alpha$ is not a tensor functor, but \n\t\\[\\calF_\\alpha(M\\otimes N)\\cong 0\\Leftrightarrow \\calF_\\alpha(M)\\otimes\\calF_\\alpha(N)\\cong 0\\]\n\tand either of these happen if and only if $\\calF_\\alpha$ is zero on $M$ or $N$.\n\\end{rmk}\n\\begin{rmk}\n\tNote that this is a place where things break down for quantum groups. We no longer have factoring through an abelian subgroup.\n\\end{rmk}\n\nNow return again to $X=\\operatorname{Proj}H^\\ast(G,k)$. Then given a $\\pi$-point $\\alpha$, we get maps \n\\[H^\\ast(G,k)\\xrightarrow{-\\otimes_R K}H^\\ast(G,K)\\xrightarrow{\\alpha^\\ast}H^\\ast(K[t]/t^p,K)\\cong K[x]\\otimes\\bigwedge(\\lambda)\\]\nand this map gives us $P_\\alpha$, which is the radical of the kernel of this map. This gives us a map $\\alpha\\mapsto P_\\alpha\\in X$.\n\nThe nice property here is that $\\pi$-points realize all points on $X$:\n\\begin{thm}\n\tFor all $\\p\\in X$, there exists an extension $K/k$ and $\\pi$-point $\\alpha$ such that $P_\\alpha=\\p$.\n\\end{thm}\n\n\\begin{defn}\n\tLet $M\\in\\StMod G$. Then the $\\pi$ support is \n\t\\[\\pi-\\supp M=\\{\\p\\in X|\\calF_{\\alpha_\\p}(M)=\\alpha^\\ast_\\p(M\\otimes_k K)\\ne 0\\}\\]\n\tnotice that the construction here doesn't depent on choice of $\\pi$ point, but that is something to show.\n\\end{defn}\n\\begin{defn}\n\t\\[\\pi-\\operatorname{cosupp}(M)=\\{\\p\\in X|\\calF^{\\alpha_\\p}:=\\alpha_\\p^\\ast(\\Hom_k(K,M))\\ne 0\\}\\]\n\twhere this is computed ve the corestriction functor (this needs clarification).\n\\end{defn}\n\\begin{thm}\n\t$\\pi$-$\\supp(M\\otimes_k N)=\\pi$-$\\supp(M)\\cap\\pi$-$\\supp(N)$.\n\\end{thm}\n\\begin{thm}[BKIP `18]\n\t$\\pi$-$\\supp(M)=\\varnothing$ if and only if $M=0$.\n\\end{thm}\n\n\\subsection{Local Cohomology Functors}\nLet's take a moment to talk about the classical definition of support. When $R=H^\\ast(G,k)=\\Ext^\\ast_G(k,k)$, we can act on \n$\\uHom^\\ast(M,M)$. When $M\\in\\stmod G$, we let $I_M=\\operatorname{Ann}_R\\uHom^\\ast(M,M)$. Then $V(I_M)\\subseteq X$ is the \\textbf{support of \n$M$,} denoted $\\supp M$.\n\nTo generalize this, we are going to let $\\calT=\\StMod G$ and associate to each $\\p\\in X$ a functor \n\\[\\Gamma_\\p:\\calT\\to\\calT\\]\nwhich selects the $\\p$-local, $\\p$-torsion objects.\n\\begin{defn}\n\tIf $M\\in\\StMod G$, we can define the \\textbf{localization map} $M\\to M_\\p$ where \n\t\\[\\uHom^\\ast(C,M_\\p)=\\uHom^\\ast(C,M)_\\p\\]\n\tfor each $C\\in\\calT^c$. (recall $\\calT$ is $R$ linear so hom can be localized regularly.)\n\\end{defn}\n\\begin{defn}\n\tThere exists a functorial map \n\t\\[\\Delta\\Gamma_{V(\\p)}M\\to M\\to L_{V(\\p)}M\\]\n\twhere the left part is universal $\\p$-torsion and the right (I believe) is $\\p$-torsion in the usual way (check the paper).\n\\end{defn}\n\nThen $\\Gamma_\\p$ is found by taking the $\\p$-local and $\\p$-torsion operations in either order.\n\nNow \n\\[\\Gamma_\\p M:=\\Gamma_p k\\otimes_k M\\]\nand so\n\\begin{defn}\n\t$\\supp_{BIK}M=\\{p\\in X:\\Gamma_\\p k\\otimes M\\ne 0\\}$ and $\\operatorname{cosupp}_{BIK}=\\{\\p\\in X|\\Hom_k(\\Gamma_\\p k,M)\\ne 0\\}$\n\\end{defn}\n\nAnd then zooming out, we define \n\\[\\Gamma_\\p(\\calT)=\\Gamma_\\p(\\StMod G)=\\{M\\in\\calT|\\supp_{BIK}(M)\\subseteq\\p\\}\\]\n\n\\begin{prop}\n\t\\begin{itemize}\n\t\t\\item $\\pi$-$\\supp(\\Gamma_\\p k)=\\p$\n\t\t\\item $\\pi$-$\\supp=\\supp_{BIK}$ (formal from detection, tensor product)\n\t\\end{itemize}\n\\end{prop}\n\\begin{cor}[Balmer, Friedlander-P]\n\t$\\SpcBal(\\stmod G)\\cong\\operatorname{Proj}H^\\ast(G,k)$ (even on the level of schemes).\n\\end{cor}\n\n\\subsection{Localizing ideals in \\texorpdfstring{$\\StMod G$}{StMod G}}\nHere we use the BIK local-global principle: to classify localizing $\\otimes$ ideals, we need to know that $\\Gamma_\\p\\calT$ are minimal. The ``wishful thinking''\nhere (which we'll flush out next time) is as follows: if we know $\\pi$-$\\operatorname{cosupp}=\\operatorname{cosupp}_{BIK}$,\nthen we can use ``Neeman's minimality lemma'' which says that $\\calC\\subseteq\\calT$ is minimal if for all $M$ and $N$ in $\\calC$,\n$\\Hom^\\ast_k(M,N)\\ne 0$.\n\nNext time we will see some more and a proof!\n\n\\subsection{Day 3}\nRecall the context: we were letting $X=\\operatorname{Proj}H^\\ast(G,k)$ and $\\calT=\\StMod G$ and then looking at\n\\[\\Gamma_p=\\{M\\in\\calT|\\supp M\\subseteq \\p\\}\\]\n\n\\begin{lem}\n\t$\\m\\in X$ is a closed point. Then $\\Gamma_\\m \\calT$ is minimal.\n\\end{lem}\n\\begin{prf}\n\tWe begin with a fact: $\\m\\in\\pi$-$\\supp M$ if and only if $\\m\\in \\pi$-$\\operatorname{cosupp} M$.\n\n\tTo show that $\\Gamma_\\m T$ is minimal, it suffices to show that $\\Hom_k(M.N)\\ne 0$ for all $M$ and $N$. But \n\t\\[\\pi\\text{-}\\operatorname{cosupp}\\Hom_k(M,N)=\\pi\\text{-}\\supp M\\cap \\pi\\text{-}\\operatorname{cosupp}N\\]\n\tBut since the $\\pi$ support of $M$ is $\\m$ and since $\\m$ lies in the $\\pi$-cosupport of $N$, then the intersection is nonempty.\n\tThus since the cosupport is nontrivial, the module itself is nontrivial.\n\\end{prf}\n\n\\subsection{Reduction to closed points}\nWe want a Koszul object (in rep theory a Carlsson object): for every $b\\in H^d(G,k)\\cong\\uHom^d(k,\\Omega^{-d}k)$, we get an object\n$k//b$ formed by the cone of $b:k\\to\\Omega^{-d}k$. Then for any sequence $\\underline{b}=(b_1,\\dots,b_n)$, we set \n\\[k//\\underline{b}=k//b_1\\otimes\\cdots\\otimes k//b_n.\\]\n\nNow if we have any finite field extension $K/k$ (the idea here is we would like to take $k$ itself, but ), we can choose a $\\m\\in X_K=\\operatorname{Proj}H^\\ast(G,K)$ lying over $\\p\\in H^\\ast(G,k)$.\nThen by taking the additional generators for $\\m$, we can pick a $\\underline b$ such that $\\m=\\sqrt{\\tilde\\p+\\underline b}$ where $\\tilde\\p$ is the lifting of $\\p$ in the bigger ring.\n\nThen we can consider the (Sylow?) functor for restriction of scalars $\\operatorname{Res}^{G_K}_G:\\StMod_K G\\to \\StMod G$\nand look at the image of $\\Gamma_\\m(K//\\underline b)$.\n\\begin{lem}\n\t$\\Gamma_\\m(K//\\underline b)\\downarrow_G\\simeq \\Gamma_\\p k$\n\\end{lem}\n\\begin{cor}\n\tthe image $\\operatorname{Res}_G^{G_K}$ of $\\Gamma_\\m\\StMod_K G$ in $\\Gamma_\\p\\StMod_k G$ is dense.\n\\end{cor}\n\\begin{cor}\n\t$\\Gamma_\\p$ is minimal for all $\\p$.\n\\end{cor}\n\n\\subsection{Support theory}\nThe following is tied closely to the following results:\n\\begin{prop}\n\t$\\pi$-$\\supp M=\\varnothing$ if and only if $M\\cong 0$.\n\n\tThat is, the $\\pi$ support has sufficient strength to detect things (``detection'').\n\\end{prop}\n\\begin{prop}\n\tFor all $\\p\\in X$ there is an $\\alpha$ with $\\calF_\\alpha$ realizing $\\p$.\n\\end{prop}\n\nI am unsure about how this fits in, but she also mentioned the detection of nilpotents in $H^\\ast(G,k)$.\n\\begin{thm}[Quillen '71]\n\tIf $G$ is a finite group, $g\\in H^\\ast(G,k)$ is nilpotent if and only if for all elements in an abelian $p$-group $E\\subseteq G$,$g\\downarrow_E$ is nilpotent.\n\\end{thm}\n\nThis means $H^\\ast(E,k)\\cong k[x_1,\\dots,x_n]\\otimes \\bigwedge^\\ast(\\tau_1,\\dots,\\tau_n)$\n\\begin{thm}[Chouinard '76]\n\tif $G$ is a finite group, then $M$ is projective if any only if for all elementary abelian $E\\le G$.\n\\end{thm}\n\nThough these results we get that Jarrod's work on the lattice of elementary abelian subgroups of specific groups correspond directly to the lattice (modulo conjugacy and some finite \ngroup actions) of affine subspaces in spec of the ring.\n\nNow if $\\frakg$ is a Lie algebra (say $\\frakg=\\operatorname{Lie}\\calG$ where $\\calG$ is a reductive group), \n$H^\\ast(\\frakg,k)=k[\\calN]$. Then fix some Borel subgroup $\\calB\\subseteq \\calG$. Take any $\\lambda\\in \\calG/\\calB$ (which is apparently a flag variety?)\nand extract from this a subalgebra $b_\\lambda\\subseteq\\frakg$. Then extract a functor \n\\[\\calF_\\lambda:\\StMod\\frakg\\to\\StMod b_\\lambda\\]\n\\begin{thm}\n\tThen if $M\\in\\StMod\\frakg$, $M\\cong 0$ if and only if $\\calF_\\lambda(M)=0$ for all $\\lambda.$\n\\end{thm}\nLet $G=\\calG_{(r)}.$\n\\begin{defn}\n\tA \\textbf{one-parameter subroup} is\n\t\\[\\bbG_{a_(r)}\\to\\calG_{(r)}\\]\n\twhere $k\\bbG_{a_{(r)}}\\cong k[u_0,\\dots,u_{r-1}]/(u_0^p,\\dots, u_{r-1}^p)$.\n\\end{defn}\n\\begin{thm}\n\tNilpotence and projectivity are detected on one-parameter subgroups (up to scalar extension).\n\\end{thm}\nHere we define the $\\pi$-point:\n\\[K[t]/t^p\\xrightarrow{t\\mapsto u_{r-1}} k\\bbG_{a_{(r)}}\\to K\\calG\\]\n\n\\brk\n\nBut then we get an isogeny \n\\[\\operatorname{Mor}(\\bbG_{a_{(r)}},G)\\simeq\\operatorname{Spec}H^\\ast(G,k)\\]\n\n\\begin{defn}\n\tA finite group scheme is elementary if \n\t\\[\\calE=\\bbG_{a_{(r)}}\\times(\\bbZ/p)^s\\]\n\\end{defn}\n\\begin{thm}[Suslin '76]\n\t$\\xi\\in H^\\ast(G,k)$ is nilpotent if any only if for all $K/k$ and for any elementary abelian subgroup $\\calE\\subseteq G_K$,\n\tthe restriction $\\xi_K\\downarrow_\\calE$ is nilpotent.\n\\end{thm}\n\n\\section{Smoothness and Properness}\nGreg Stevenson gave this series of lectures.\n\n\\subsection{Beginning definitions}\n\nToday we will be working up to dg categories. In what follows let $k$ be a fixed base field (although it works without being a field, this \nis a nice assumption). Recall the definition of a chain complex $\\cdots\\to X^i\\xrightarrow{d^i} X^{i+1}\\to\\cdots$.\n\nRecall that a chain morphism is a sequence of maps indexed by $\\bbZ$ such that the obvious diagrams commute. Denote by $\\Ch(k)$ the category of chain complexes of $k$\nvector spaces. We have the \\textbf{suspension} or \\textbf{shift functor} in this category, denoted $\\Sigma$. This is an autoequivalence of $\\Ch(k)$.\n\nGiven a chain map $f:X\\to Y$, we define $H^i(X)=\\ker d^i/\\Im d^{i-1}$. This gives us a functor $H^i:\\Ch(k)\\to \\Vectk$. We say that $f$ is a quasi-isomorphisms if it induces\nisomorphisms on cohomology.\n\nWe can form the mapping cone of $f$, $\\cone f$ (think this is kind of a kernel and kind of a cokernel)\n\\[\\cone(f)=(\\Sigma X\\oplus U,(\\begin{smallmatrix}d_{\\Sigma X} & 0\\\\ f & d_Y\\end{smallmatrix}))\\]\n\nRecall the definition of acyclic objects. Then \n\\begin{lem}\n\t$f:X\\to Y$ is a quasi-isomorphism if and only if $\\cone(f)$ is acyclic.\n\\end{lem}\n\\begin{rmk}\n\tThis supports the idea that this is in fact a kernel and cokernel in a way.\n\\end{rmk}\n\nBegin $\\Ch(k)$ admits a symmetric monoidal structure from the total complex of the associated double \ncomplex (with some signs flipped). This defines a functor $-\\otimes -$ into $\\Ch(k)$.\n\nWe also have internal hom (aka the $\\hom$ complex). Here \n\\[\\hom(X,Y)^n=\\prod_{i\\in\\bbZ}\\Hom_k(X^i,Y^{i+n})\\]\nwith differential given by the graded commutator:\n\\[d(f)=d_Y^{i+n} f^i-(-1)^nf^{i+1}d_X^i\\]\n\n\\begin{rmk}\n\tThis is measuring, in a graded way, \n\\end{rmk}\n\\begin{ex}\n\t$Z^0\\hom(X,Y)=\\ker d^0_{\\hom(X,Y)}=\\{\\text{degree zero maps} f| fd=df\\}$. Then we can compute that \n\t\\[H^0\\hom(X,Y)\\]\n\twhich is precisely the homotopy classes of maps from $X$ to $Y$.\n\\end{ex}\n\n\\brk\n\nWe have a tensor hom adjunction (from here let $\\Ch=\\Ch(k)$)\n\\[\\Ch(X\\otimes Y,Z)\\cong \\Ch(X,\\hom(Y,Z))\\]\nfor all $X,Y,Z$ so we have the counit in the form of coevaluation\n\\[\\varepsilon:X\\otimes\\hom(X,Y)\\to Y\\]\nand given a $Z\\in\\Ch$, we can consider \n\\[X\\otimes\\hom(X,Y)\\otimes\\hom(Y,Z)\\xrightarrow{\\varepsilon_Y\\otimes 1}Y\\otimes \\hom(Y,Z)\\xrightarrow{\\varepsilon_Z} Z\\]\nand so via the adjunction we get a composition map \n\\[\\hom(X,Y)\\otimes\\hom(Y,Z)\\xrightarrow{\\circ}\\hom(X,Z).\\]\n\nThis composition map is associative. We also get unit maps $1_X:k\\to\\hom(X,X)$ determined by the image of $\\id_X\\in\\Ch(X,X)$ in $\\hom(X,X)$.\nThese maps act as units for $\\circ$, using the fact that $k$ is the unit of $\\otimes_k$.\n\nSo using $1_X$ and $\\circ$, we get something that looks like a category! This is the primordial example of a dg-category.\n\n\\subsection{Examples and extensions}\nGive $X\\in\\Ch$, we get a monoid $\\hom(X,X)\\in\\Ch$. What does that mean? Well, we have a map $\\hom(X,X)\\otimes\\hom(X,X)\\to\\hom(X,X)$\nwhich is just composition, and a unit $1_X:k\\to\\hom(X,X)$. This is an example of a differential graded algebra. I.e. we have an algebra $A$ equipped with \na degree 1 differential $d$ which is a graded derivation.\nThis is also an example of a dg-category.\n\n\\subsection{dg-categories}\n\\begin{defn}\n\t$\\calA$ is a dg-category if it is given by a collection of objects along with a complex \n\t$\\calA(a,b)\\in\\Ch$ for each $a,b\\in\\calA$ as well as unit maps \n\t\\[1_a:k\\to\\calA(a,a)\\]\n\tand composition maps \n\t\\[\\circ:A(b,c)\\otimes A(a,b)\\to A(a,c)\\]\n\tsuch that composition is associative and unital with respect to the unit maps.\n\\end{defn}\n\\begin{rmk}\n\tThe slick way of saying this is that a dg-category is a category enriched over chain complexes. :)\n\\end{rmk}\n\nThe $\\hom$ complexes make $\\Ch$ into a dg-category. I will call this $\\scrC$. If $A$ is a dga, consider the dg-cat $BA$, \nwhich is the category of a single object with hom set $A$.\n\nIf $B$ is any $k$-linear category we can view it as a dg category $\\tilde B$ with $\\tilde B(b,c)=B(b,c)$ in degree zero.\n\nGiven a dg category $\\calA$, we can do a couple things to get a boring category: first, you can take the underlying category $Z^0\\calA$ that has the same objects \nand the maps are the zeroth cocycles of $A(a,b)$ for each $a$ and $b$. For example $Z^0\\scrC=\\Ch$.\n\nWe can also compute the homotopy category of $\\calA$, denoted $H^0\\calA$ which again has teh same objects, but \n\\[H^0\\calA(a,b)=H^0(\\calA(a,b)).\\]\nNow $H^0\\scrC=K(k)$, the homotopy category of chain complexes.\n\n\\begin{ex}\n\tIf $R$ is a $k$ algebra, then we get a dg category over $k$ $\\scrC(R)$ with objects chain complexes of $R$-modules \n\tand where the hom complexes are $\\hom_R(X,Y)$.\n\\end{ex}\n\n\\subsection{dg modules and derived categories}\nGiven a pair of dg categories $\\calA$ and $\\calB$, a dg functor $F:\\calA\\to \\calB$ consists of an object assignment\nalong with a map of $\\hom$s that preserve units and composition. There is also a notion of being a dg-natural transformation \nand dg-equivalence (this is the part of this we will need), and so on. \n\nLet's finish off today with dg modules. \n\\begin{defn}\n\tGiven a small dg-category $\\calA$ (notice they are always locally small!), a \\textbf{right $A$-dg-module} $X$ is \n\ta dg functor $\\calA^{op}\\to\\scrC$.\n\n\tEquivalently, for all $a\\in\\scrA$, $X(a)\\in\\Ch$ and for every $a,b\\in\\calA$ a map \n\t\\[\\calA(a,b)\\to\\scrC(Xa,Xb)\\]\n\twhich is equivalent via the tensor hom adjunction to a map \n\t\\[\\calA(b,a)\\otimes Xa\\to X_b\\]\n\twhich looks a lot more like a module action. :)\n\\end{defn}\nLet $\\mathbf{Mod}$-$\\calA$ be the category of dg modules and dg natural transformations.\n\n\\brk\n\nRecall that we had $\\mathbf{Mod}$-$\\calA=[\\calA^{op},\\Ch]$. The objects are dg functors and maps are natural transformations with a \nhexagonal naturality diagram (I don't know what htis is).\n\nThis is a honest category, but we can upgrade it to a dg category as follows: for each $X,Y\\in\\mathbf{Mod}$-$\\calA$, we define $\\mathscr{M}od\\calA(X,Y) = \\operatorname{eq}(D)$ where $D$ is the diagram \n\\begin{center}\n\t\\begin{tikzcd}\n\t\t\\prod_{c\\in\\calA}\\Ch(Xc,Yc)\\ar[r,\"\\lambda\",bend right]\\ar[r,\"\\rho\",swap,bend left]& \\prod_{a,b\\in\\calA}\\Ch(\\calA(b,a),\\scrC(Xa,Xb))\n\t\\end{tikzcd}\n\\end{center}\n\n$\\lambda$ is a way to define a right action by precompositon and $\\rho$ is the same but right action and postcomposition. So in a way this is saying the two actions are compatible.\nThis actually ends up being exactly what we usually ask for when we want naturality.\n\n\\begin{rmk}\n\t$Z^0\\scrM od\\calA(X,Y)=\\mathbf{Mod}$-$\\scrA$.\n\\end{rmk}\n\\begin{rmk}\n\t$\\scrM od\\calA(X,Y)=\\int_{a\\in\\calA}\\Ch(Xa,Ya)$, if the notation suits you.\n\\end{rmk}\n\nWe can extend notions of cones, suspension, quasi-isomorphisms, etc, pointwise to $\\scrM od \\calA$. For instance, if $X\\in\\scrM od\\calA$, we define $\\Sigma X$ to be the dg functor \n$A^{op}\\xrightarrow{X}\\Ch\\xrightarrow{\\Sigma}\\Ch$. Again, just define the cone pointwise and since it is functorial (note: this is not true in the \nderived theory, but it still is here.)\n\nWe will call $X$ in $\\scrM od\\calA$ \\textbf{acyclic} if $X(a)$ is acyclic for all $a$.\n\n\\subsection{Some special dg modules}\nWhenever $a\\in\\calA$, there is a corresponding representable dg module $\\hat a=\\calA(-,a)$. The dg functor structure here is given by composition.\nIn this case we get \n\\begin{lem}[Strong Yoneda]\n\tThere is a dg functor $\\calA\\to\\scrM od\\calA$ sending $a\\mapsto \\hat a$ which is dg fully faithful. In fact for every $X\\in\\scrM od\\calA$,\n\t\\[\\scrM od\\calA(\\hat a,X)\\cong X(a).\\]\n\\end{lem}\n\nIn particular, $\\scrM od\\calA(\\hat a,-)$ preserves all things defined pointwise (including quasi-isos, acyclics, etc).\n\n\\begin{defn}\n\tThe derived category $\\D(\\calA)$ is \n\t\\[\\D(\\calA)=\\mathbf{Mod}\\text{-}\\calA[\\text{quasi isomorphisms}]^{-1}=H^0\\scrM od\\calA/{\\text{acyclic complexes}}\\]\n\twhich are analogous to what we usually do with abelian categries.\n\\end{defn}\n\\begin{prop}\n\t$\\D(\\calA)$ is locally small.\n\\end{prop}\n\nInside of $\\D(\\calA)$ we can consider the images of the representable dg functors $\\hat a$. We want to define a thing that sits over this \n\\[\\mathbf{Perf}\\calA\\]\nto be the smallest full dg subcategory of $\\scrM od\\calA$ containing the image of the Yoneda embedding, closed under cones, suspensions, and homotopy retracts.\n\n\\begin{thm}\n\tLet $\\calA$ be a small dg category. Then $\\D(\\calA)$ is a compactly generated triangulated category and the compacts are $\\D(\\calA)^c=H^0\\mathbf{Perf}\\calA$.\n\\end{thm}\n\nIn a sense, you want to remember that $\\mathbf{Perf}\\calA$ determines $\\D(\\calA)$. In particular, fif $\\calA$ and $\\calB$ are \nsmall dg categories and we have a \\textbf{quasi-equivalence} $F:\\mathbf{Perf}\\calA\\to\\mathbf{Perf}\\calB$ (that is, $F$ induces a quasi-isomorphism on $\\scrH om$s)\nand $F$ descends to an essential surjection on the homotopy categories of the $\\mathbf{Perf}$ objects, then $\\D(\\calA)\\xrightarrow{\\sim}\\D(\\calB)$.\n\nIn such a case we say that $\\calA$ and $\\calB$ are \\textbf{derived Morita equivalent}.\n\\begin{ex}\n\tConsider the path algebra of the $A_2$ quiver $kA_2\\cong (\\begin{smallmatrix}\n\t\tk&k\\\\0&k\n\t\\end{smallmatrix})$. Then $\\mathbf{Perf}kA_2\\cong\\scrC^b(\\operatorname{proj} kA_2)$.\n\n\tThis is derived Morita equivalent (in fact just equivalent) to $B\\cong R\\Hom_{kA_2}(S_2\\oplus S_2,S_1\\oplus S_2)$.\n\\end{ex}\n\nIn general, if we let $\\calK$ be a small triangulated category with $\\tilde\\calK$ a dg category such that $\\calK\\cong H^0\\tilde\\calK$ as triangulated categories \nwhere $H^0\\tilde\\calK$ inherits is triangulated structure from $H^0\\scrM od\\hat\\calK.$ This is called an \\textbf{enhancement of $\\calK$.}\n\nCall $g\\in\\calK$ a \\textbf{generator} if the smallest thick subcategory containing $g$ in $\\calK$ is all of $\\calK$. We call $g$ a \\textbf{strong generator} if there exists a uniform bound on the number of cones needed to build\nany object (there is a global bound on the number of cones we have to take to build any object). In this latter case we call $\\calK$ \\textbf{regular} (in the sense of algebraic geometry).\n\n\\begin{thm}[Keller]\n\tIf $g\\in\\calK$ is a generator, then $\\tilde\\calK$, an enhancement of $\\calK$, is quasi equivalent to $\\mathbf{Perf}\\tilde\\calK(g,g).$\n\\end{thm}\n\\begin{rmk}\n\tWhat this is saying is that if $\\calK$ (i.e. $H^0\\tilde\\calK$) ahs a generator then $\\tilde \\calK$ is derived morita equivalent to a dg algebra.\n\\end{rmk}\n\nIn practice, most triangulated categories we care about (at least the algebraic ones -- the topological ones don't work here) come from dg algebras.\n\n\\subsection{Examples, properness, and smoothness}\n\\begin{ex}\n\tLet $R$ be a finitely generated $k$ algebra viewed as a dg algebra concentrated in degree zero. Then we have \n\t\\[\\Ch(R)=\\scrM od R\\supseteq \\Ch^{-,b}(\\operatorname{proj}R)=\\underline\\D^b(R)\\supseteq \\mathbf{Perf} R=\\Ch^b(\\operatorname{proj} R)\\]\n\twhich is analogous to the inclusion \n\t\\[\\D(R)\\supseteq \\D^b(R)\\supseteq\\Dbperf(R)\\]\n\\end{ex}\n\n\\begin{ex}\n\tIf $X$ is a scheme of finite tipe over $k$, then we can define $\\operatorname{Perf} X$ to be the collection of injective resolutions of chain complexes of \n\tquasicoherent sheaves on $X$ such that these complexes are perfect in $\\D_{qc}(X)$. The point here is that \n\t\\[H^0\\operatorname{Perf}X\\cong\\Dbperf(X).\\]\n\\end{ex}\n\n\\subsection{Properness}\nSuppose $\\Lambda$ is a finite dimensional $k$ algebra. If $M,N\\in\\mathbf{Perf}\\Lambda$, then $\\mathbf{Perf}\\Lambda(M,N)\\in\\mathbf{Perf}k$ up to quasi-isomorphism.\nThat is $H^\\ast\\mathbf{Perf}\\Lambda(M,N)$ is finite deimensional over $k$.\n\nIf $X$ is a proper $k$ scheme, then for $E,F\\in\\operatorname{Perf}X$, we have $\\operatorname{Perf}X(E,F)\\in\\mathbf{Perf}k$. That is, the cohomology on a proper scheleme is finite dimensional.\n\n\\begin{defn}\n\tWe say that a dg category over $k$ $A$ is \\textbf{proper} if for all $a,b\\in\\calA,$ $\\calA(a,b)\\in\\mathbf{Perf}k$ up to quasi isomorphism.\n\\end{defn}\n\nAn example of a proper category is $\\operatorname{Perf}\\Lambda$ where $\\Lambda=k[\\varepsilon]/\\varepsilon^2$. But on the other hand, $\\underline\\D^b(\\Lambda)$ is not proper. For instance,\nnotice that a resolution is of $\\Lambda$ with $\\varepsilon$ maps everywhere, but $\\Hom(P,P)$ computes $\\Ext^\\ast(k,k)$, which in every degree is $k$.\n\n\\begin{lem}\n\tProperness is a derived Morita invariant. That is a dg category over $k$ $\\calA$ is proper if and only if $\\operatorname{Perf}\\calA$ is proper.\n\\end{lem}\n\\begin{rmk}\nIn partucular an algebra $\\Lambda$ is proper (i.e. finite dimensional) if and only if $\\operatorname{Perf}\\Lambda$ is.\n\\end{rmk}\n\\begin{thm}[Lipmon?]\n\tIf $X$ is a scheme of finite type over $k$, then $X$ is proper iff $\\operatorname{Perf}X$ is.\n\\end{thm}\n\n\\subsection{Smoothness}\nLet $L=\\bbF_p(t)$ and $R=\\bbF_p(t^{1/p})$. Then $R$ is a field so $\\gldim R=0$, but \n$R\\otimes_LR$ is nologingler finite global dimension since $t^{1/p}\\otimes 1-1\\otimes t^{1/p}$ is nilpotent.\n\n\\begin{defn}\n\tRecall that a $k$ algebra $R$ is \\textbf{smooth} if $R\\in\\operatorname{Perf}R^e$.\n\\end{defn}\n\\begin{lem}\n\tIf $R$ is smooth over $k$, then $\\gldim R<\\infty$.\n\\end{lem}\n\nSome geometry: $X$ of finite type over $k$ is smooth if $X\\times_k \\bar k$ is regular (where $\\bar k$ is the algebraic closure of $k$). If $X$ has enough locally free sheaves (resolution property),\nthen this is equivalent to \n\\[\\Delta_\\ast\\calO_X\\in\\operatorname{Perf}(X\\times_k X)\\]\nwhere $\\Delta$ is the diagonal map $X\\to X\\times X$.\n\nIn an attempt to make a common generalization:\n\\begin{defn}\n\tLet $\\calA$ and $\\calB$ to be two dg-categories over $k$. Define $\\calA\\otimes_k \\calB$ to be the category of pairs of \n\tobjects from $\\calA$ and $\\calB$, written $a\\otimes b$ and make the maps \n\t\\[\\calA\\otimes \\calB(a\\otimes b,a'\\otimes b')=\\calA(a,a')\\otimes \\calB(b,b').\\]\n\\end{defn}\nThen we set $\\calA^e=\\calA^{op}\\otimes_k\\calA$. Then we consider $\\scrM od\\calA^e$ to be the categories of $\\calA,\\calA$-bimodules.\n\n\\begin{ex}\nTHe diagonal $\\calA^e$ modules $\\Delta:\\calA^e\\to\\Ch$ is the map $\\calA(-,-)$, sending a pair $a\\otimes a'$ to $\\calA(a,a')$.\n\\end{ex}\n\\begin{rmk}\n\tThis gives us another definition: $\\calA$ is smooth over $k$ if $\\Delta=\\calA(-,-)\\in\\operatorname{Perf}\\calA^e$.\n\\end{rmk}\n\\begin{lem}\n\tSmoothness is a derived Morita invariant. Thus it agrees with the notion for algebras.\n\\end{lem}\n\\begin{thm}[Lunts-Schn\\\"urer]\n\tIf $X$ is finite type, separable, and has enough locally free sheaves, then $X$ is smooth iff $\\operatorname{Perf}X$ is smooth.\n\\end{thm}\n\nThere are lots more exotic examples including things you wouldn't really expect to be smooth.\n\\begin{thm}[Auslander, Elogin-Lunts-Schn\\\"urer]\n\tIf $\\Lambda$ is a finite dimensional algebra over $k$ such that $\\Lambda/\\operatorname{rad}\\Lambda$ is separable over $k$ (e.g. when $k$ is algebraically closed), then \n\t$\\underline\\Db(\\mathbf{mod}\\,\\Lambda)$ is smooth.\n\\end{thm}\n\\begin{rmk}\n\tNotice that by contrast that $\\operatorname{Perf}\\Lambda$ is smooth if and only if $\\Lambda$ is. This is a smaller object, so violates our geometric intuition.\n\n\tThe upshot here is that we can regard $\\operatorname{Perf}\\Lambda\\hookrightarrow\\underline\\Db(\\Lambda)$ to be a kind of resolution of singularities.\n\\end{rmk}\n\\begin{thm}[Lunts]\n\tIf $X$ is a separable scheme of finite type over a perfect field, then $\\underline\\Db(X)$ is smooth.\n\\end{thm}\nBy Morita invariance, if $E$ is a dg algebra and $\\operatorname{Perf}E$ is smooth, then $E$ is smooth. For instance, take a prime $p\\ge 3$, let $k=\\bbF_p$\nand consider $\\underline\\Db(k C_p)\\cong\\operatorname{Perf}E$ where $E=R\\Hom_{kC_p}(k,k)$.\n\nBut now notice that\n\\[H^\\ast(E)=Ext_{k C_p}^\\ast(k,k)=H^\\ast(C_p,k)=k\\langle\\tau,\\theta\\rangle\\]\nwhere $|\\tau|=1$ and $|\\theta|=2$ and the above is the free graded commutative algebra on these things. Now since $|\\tau|=1$, $\\tau^2=0$, so $H^\\ast E$ has infinite global dimension, so $H^\\ast E$ is not smooth.\n\nIn general, one can't hope to say much about $H^\\ast A$ when $A$ is smooth. However,\n\\begin{thm}[Raedschelder-S.]\n\tIf $A$ is a smooth dg algebra is smooth and connective ($A^{\\ge 1}=0$), then $H^0A$ is smooth.\n\\end{thm}\n\n\\subsection{Regularity and smoothness}\nWhat exactly does smoothness buy us?\n\\begin{thm}\n\tIf $A$ is a smooth dg algebra then $A$ is regular in the sense that $A$ strongly generates $H^0\\operatorname{Perf}A$.\n\\end{thm}\nRegularity buys one quite a lot: we get representability results for cohomological (dg) functors. The idea here is that even if we don't have the infinite coproducts we need for Brown,\nbut somehow the ``needing uniformly finite cones'' of strong generation takes care of this for us.\n\n\\begin{rmk}\n\tIt is not always true that for any Noetherian scheme that $\\Db(X)$ is even regular.\n\n\tThere are many examples of dg categories that are regular but not smooth. For instance, $\\operatorname{Perf}k[[x]]$ is regular, but not smooth.\n\\end{rmk}\n\nSmoothness is also a strong finiteness condition on $\\calA$. \n\\begin{thm}[To\\\"en]\n\tLet $\\calA$ be a smooth dg category. Then there exists a generator $g\\in\\operatorname{Perf}\\calA$ so \n\t$\\calA$ is derived Morita equivalent to $\\operatorname{Perf}\\calA(g,g)$, a dg algebra.\n\\end{thm}\n\n\\subsection{Ideas for proofs}\nSay $\\calA$ is a smooth dg category, so $\\Delta\\in\\operatorname{Perf}\\calA^e$. What are the perfects over the enveloping algebra? For $a\\otimes b\\in \\calA^e$, \nwrite $\\widehat{a\\otimes b}$ for $\\calA(a,-)\\otimes\\calA(-,b)\\in\\operatorname{Perf}\\calA$. But then \n\\[\\operatorname{Perf}\\calA^e=\\operatorname{thick}(\\widehat{a\\otimes b}|a\\otimes b\\in\\calA^e)\\]\nthen the upshot here is that computing the thick subcategory containing something is built out of finitary pieces. That is, \nfor anything in $\\operatorname{Perf}\\calA^e$, $\\Delta\\in\\operatorname{thick}_{\\calA^e}(\\widehat{a_i\\otimes b_i}|i\\in\\calI)$\nwhere $\\calI$ is a finite set.\n\nSo if $X\\in\\operatorname{Perf}\\calA$, consider $X_\\calA\\otimes_\\calA {_\\calA}\\Delta_\\calA\\cong X\\in\\scrM od\\calA$\nbut then \n\\[X=X\\otimes_\\calA \\Delta\\in\\operatorname{thick}_\\calA(X\\otimes_\\calA \\widehat{a_i\\otimes b_i}|i\\in\\calI)\\]\nand futhermore \n\\[X\\otimes_\\calA\\widehat{a_i\\otimes b_i}= X(a_i)\\otimes_k \\hat b_i\\]\nso this is a big direct sum of shifts of $\\calA(-,b_i)$.\n\nThen by Thomason's this implies that $X\\in\\operatorname{thick}(b_i|i\\in\\calI)$, so the $b_i's$ genreate $\\operatorname{Perf}\\calA$, \nwhence $\\calA$ is morita equivalent to $\\oplus_{i,j\\in\\calI}\\calA(b_i,b_j)$. \n\nFinally since $\\Delta$ can be built in some finite number of cones, $X$ can be build in the same (or fewer) number of cones.\n\n\\begin{rmk}\n\tIn general, smoothness and properness are often dual to one another. That is they often come in pairs. FOr example, if $\\Lambda$ is a finite dimensional dg algebra over $k$, then $\\operatorname{Perf}\\Lambda$ is proper.\n\n\tThen $\\operatorname{Perf}k$ is the monoidal unit for a closed monoidal structure on a dg category over $k$ $[\\operatorname{Perf}\\Lambda,\\operatorname{Perf}k]=[\\Lambda,\\operatorname{Perf}k]\\cong\\underline\\Db(\\Lambda^{op})$ and the thing on the right is smooth.\n\tThis is not an exact duality because there are counterexamples but it's mostly correct.\n\\end{rmk}\n\n\n\n\\section{(Bounded) t-structures and approximable categories}\nLet $R$ be a ring. Consider the category $\\D(R)$, the derived category of $R$ modules. This is a triangulated category with \ncoproducts. Write $\\Sigma$ for the suspension.\n\nWe have two (full) subcategories $\\Dpos(R)$ and $\\Dneg(R)$, which are elements such that cohomology \nvanishes below and above zero. Notice that $\\Dneg(R)$ is stable under $\\Sigma$ and $\\Dpos(R)$ is stable \nunder $\\Sigma^{-1}$. Sometimes we write $\\D^{\\ge 1}(R)$ (e.g.).\n\nIt is not too hard to check that $\\Hom(\\Dneg(R),\\D^{\\ge 1}(R))=0$. For each $x\\in\\D(R)$, there is \na triangle \n\\[Y\\to X\\to Z\\]\nwhere $Y\\in\\Dneg(R)$ and $Z\\in\\D^{\\ge 1}(R).$\n\nFinally $\\Dneg(R)\\cap\\Dpos(R)=\\Rmod$.\n\n\\subsection{t-structures}\n\\begin{defn}\n\tA \\textbf{t-structure} on a triangulated category $\\calT$ is a pair of full subcategories $\\calT^{\\ge 0},\\calT^{\\le 0}$ satisfying \n\t\\begin{itemize}\n\t\t\\item $\\Sigma\\calT^{\\le 0}\\subset \\calT^{\\le 0}$\n\t\t\\item other stuff I missed.\n\t\\end{itemize}\n\\end{defn}\n\nThe \\textbf{heart of $\\calT$} is $\\calT^{\\ge 0}\\cap\\calT^{\\le 0}$ which \nis an abelian subcategory of $\\calT.$ We say $\\calT^{\\le 0}$ and $\\calT^{\\ge 0}$ are the \\textbf{aisle and coaisle} of $\\calT$,\nrespectively.\n\\begin{rmk}\n\tThe t-structure is determined entirely by the (co) aisle. This is because\n\t\\[\\calT^{\\ge 0}=(\\calT^{\\le 0})^\\perp:=\\{Y\\in\\calT|\\Hom(\\calT^{\\le -1})\\}\\]\n\\end{rmk}\n\nWe have truncation functors that are right and left adjoints to $\\calT^{\\le 0}\\hookrightarrow\\calT$ and $\\calT^{\\ge 0}\\hookrightarrow\\calT$, respectively.\n\n\\subsection{Aisles vs Pre-Aisles}\nEvery aisle $\\calT^{\\le 0}$ is closed under positive suspensions, taking summands, and extensions. If $\\calT$ has coproducts, then $\\calT^{\\le 0}$ is closed under coproducts.\n\\begin{defn}[Keller-Vossieck]\n\tA subcategory $\\calS\\subseteq\\calT$ is a \\textbf{pre-aisle} if it is closed under extensions, positive suspensions, and taking summands.\n\\end{defn}\n\nA question one may ask is when is a pre-aisle an aisle? Keller-Vossieck said that a pre-aisle $\\calS\\subseteq \\calT$ is an aisle if and only if $\\calS\\hookrightarrow\\calT$\nhas a right adjoint.\n\nLet $S\\subseteq\\calT$ be a set of objects. Write \n\\begin{itemize}\n\t\\item $\\langle S\\rangle$ to be the smallest thick triangulated subcategory of $\\calT$ contatining $S$.\n\t\\item $\\langle\\overline{S}\\rangle$ is the same as above but closed under coproducts.\n\t\\item $\\langle S\\rangle^{(-\\infty,0]}$ is the smallest pre-aisle in $\\calT$ containing $S$\n\t\\item $\\langle\\overline{S}\\rangle^{(-\\infty,0]}$ is what you'd think.\n\\end{itemize}\n\n\\begin{thm}[Neeman]\n\tLet $\\calT$ be a well-generated (whatever that means) category and $S\\subseteq\\calT$ a set of objects. Then \n\tthere exists a t-structure with aisle $\\langle \\overline{S}\\rangle^{(-\\infty,0]}$\n\\end{thm}\n\nAs an example, when $\\calT=\\D(R)$, then $\\calS=\\langle \\overline{R}\\rangle^{(-\\infty,0]}$ is the aisle of the standard t-structure.\n\nAnother example: Let $\\calT=\\Db(R)$ where $R$ is Noetherian. Let $S=\\langle R\\rangle^{(-\\infty,0]}=\\calT_c^{b\\le 0}$ is the aisle of the restricted standard t-structure.\nThis structure is bounded. That is, $\\calT$ is the intersection of the shifted versions of the usual structures.\n\nWhy do we care about bounded t-structures? One reason is that if $\\calT$ has a bounded t-structure, then $\\calT$ is generated by its heart. Another reason is that \nit is an ingredient in Bridgeland stability. Finally is something to do with K theory that will show up in David's talk.\n\n\\subsection{A nontrivial pre-aisle}\nBondal found the following example of a pre-aisle which is not an aisle:\n\\begin{ex}\n\tLet $\\calD=\\Db_{coh}(\\bbP^2(k))$ where $k$ is algebraically closed of characteristic zero. Let \n\t\\[D_1^{\\le 0}\\langle \\calO(1),\\calO(2)\\rangle\\]\n\tand \n\t\\[D_2^{\\le 0}=\\langle\\calO(-1),\\calO(-2)\\rangle.\\]\n\n\tThese are both aisles as well, but $D_1^{\\le 0}\\cap D_2^{\\le 0}$ is a pre-aisle but it can be shown (though significant computation)\n\tto not be an aisle.\n\\end{ex}\n\n\\subsection{Neeman's Great Idea}\nLet $\\calS=\\calT^{\\le 0}$ for some t-structure on $\\calT$. Let $x,y\\in\\calT$. We get as surjective map \n\\[\\left\\{x\\to x\\to y|s\\in\\calS\\right\\}\\twoheadrightarrow\\Hom(x,y^{\\le 0})\\]\nby virtue of the fact that any map from a truncated thing to an object factors through its truncation. Neeman showed that under \na certain equivalence relation we can make this into an isomorphism.\n\nThe quotient $H_\\calS(x,y)\\cong\\Hom(x,y^{\\le 0})$ can be defined for any pre-aisle $\\calS$, so we get a homological functor \n$H_\\calS(-,y):\\calT\\to\\Ab$.\n\n\\begin{prop}[Neeman]\n\tLet $\\calS$ be a pre-aisle. $\\calT-\\calT^{\\le 0}$ for some t-structure on $\\calT$ if and only if $H_\\calS(-,y)$ is representable for all $y\\in\\calT$.\n\\end{prop}\n\\begin{rmk}\n\tNotice that here is where we run into set theoretic issues. One must show that such a functor is set-valued to apply Brown representability.\n\\end{rmk}\n\n\\subsection{Approximating Objects}\n\\begin{defn}\n\tA \\textbf{metric} on a category is a function that assigns a positive real number (length) to every morphism in a way that the triangle inequality is satisfied.\n\\end{defn}\n\nNow every t-structure on $|calT$ gives rise to a metric on $\\calT$. To understand it, it suffices to specify the balls \n\\[B_n=\\{x\\in\\calS|0\\to X\\text{ has length}\\le 1/n\\}\\]\nTaking the balls to be $B_n=\\calT^{\\le -n}$ gives rise to a ``good metric''. I missed the discussion here unfortunately.\n\nRecall the definition of compact generators.\n\n\\begin{defn}\n\tLet $\\calT$ be a triangulated category with coproducts. Then $\\calT$ is \\textbf{approximable} if there exists a compact \n\tgenerator $G\\in\\calT$ and a t-structure and an integer $A>0$ such that \n\t\\begin{itemize}\n\t\t\\item $G\\in T^{\\le A}$ and $\\Hom(G,T^{\\le -A})=0$.\n\t\t\\item For every object $y\\in\\calT^{\\le 0}$, there exists a triangle\n\t\t\\[x\\to y\\to x\\]\n\t\twith $z\\in\\calT^{\\le -1}$ and $x\\in\\calT^{\\ge 0}$ (I think).\n\t\\end{itemize}\n\\end{defn}\n\nSome examples due to Neeman: $\\D(R)$ is approximable. IF $X$ is quasicompact and separated, then $\\D_{qc}(X)$ is approximable. Finally the homotopy category of spectra is approximable.\n\n\\subsection{\\texorpdfstring{$\\calT^b_c$}{Tcb}}\nSuppose that $\\calT$ has a compact generator $G$. Consider the t-structure generated by $G$ (the aisle is generated by $G$). Call $\\calT_c^-$\nthe full subcategory of $\\calT$ such that for all $n>0$ there exists a triangle $x\\to y\\to z$ with $x$ compact and $z\\in\\calT^{\\le -n-1}$. That is, $y$ is being approximated by compact objects.\n\n\\begin{defn}\n\\[\\calT_c^b=\\calT^b\\cap\\calT^-c\\]\n\\end{defn}\n\\begin{rmk}\n\tThe categories above do not depend on the choice of generator.\n\\end{rmk}\n\\begin{rmk}\n\tIf $\\calT$ is approximable, then $\\calT_c^-$ and $\\calT_c^b$ are thick.\n\\end{rmk}\n\nFor some examples, when $\\calT=\\D(R)$, $\\calT^b=\\Db(R)$ and $\\calT_c^-=\\Dneg(R)$. If you look at quasicoherent sheaves you also get something nice.\n\n\\section{Cluster tilting modules for mesh algebras}\n\nThis talk was given by Sira Gratz in conjunction with Erdmann and Lamberti.\n\nThe motivation here is that the clustering aspect comes from combinatorics (e.g. cluster algebras) and the tilting portion \nrefers to tilting theory/modules. \n\nThoughout let $\\Lambda$ be a finite dimensional algebra over $k$. If $\\Lambda$ has a CT-modules, this implies that the representation dimension of $\\Lambda$ is less than or equal to three. What does this mean?\nThat $\\Lambda$ is close to being ``representation finite''. Auslander proved that $\\operatorname{repdim} \\Lambda =2$ iff it is representation finite.\n\nThat is $0\\to T''\\to T'\\to M\\to 0$ exists for any $M$, where $T'$ and $T''$ are indecomposibles. So in some way if you understand the indecomposable theory\nyou can reconstruct the structure of any module using only two ``layers'' of this information.\n\n\\subsection{What are CT-modules?}\n\\begin{defn}\n\tLet $\\calT$ be a triangulated or Abelian category. Then $\\calC\\subseteq\\calT$ is \\textbf{cluster tilting}\n\tif it is functorially finite (This means you have pre-covers and pre-envelopes for every object in your category -- roughly $\\calC$ approximates $\\calT$) and the folowing are equivalent for all $M\\in\\calT$:\n\t\\begin{itemize}\n\t\t\\item $M\\in \\calC$\n\t\t\\item $\\Ext^1(C,M)=0$ for all $C\\in\\calC$\n\t\t\\item $\\Ext^1(M,C)=0$ for all $C\\in\\calC$\n\t\\end{itemize}\n\\end{defn}\n\nIf $\\calT=\\mathbf{mod}$-$\\Lambda$, then $A$ in this category is a CT-modules if $\\operatorname{add}(A)$ is CT.\nA good place to look to start is $\\Lambda$ that are self-injective.\n\n\\begin{thm}[Erdmann-Holm]\n\tIf $\\Lambda$ is self-injective and has a CT-module, then for all $\\Lambda$ modules $M$ have complexity less than 1. \n\\end{thm}\n\\begin{rmk}\n\tBasically this talks about how quickly the dimension of the elements in a ``minimal'' projective resolution grows. Complexity zero means that a module has finite \n\tprojective dimenson and complexity one means that the dimension of the modules in the resolution is bounded.\n\\end{rmk}\n\n\\subsection{Mesh Algebras (of Dynkin type)}\nThe benefit of these algebras is that they have periodic resolutions, so we can apply the previous theorem.\n\nOne example comes from the quiver \n\\begin{center}\n\t\\begin{tikzcd}\n\t\t0\\ar[r,\"\\bar\\alpha\",bend right,swap] & 0 \\ar[l,\"\\alpha\",bend right]\\ar[r,\"\\beta\",bend right] & 2 \\ar[l,\"\\bar\\beta\",bend right,swap]\n\t\\end{tikzcd}\n\\end{center}\n\nThe idea here is you look at a Galois cover of this diagram and then use graph automorphisms to introduce a ``twist'' to \ncreate a mesh algebra. \n\n\\begin{thm}[Geiss-Leckers-Schr\\\"oer]\n\tMesh algebras of type $A,D,$ and $E$ have CT-modules.\n\\end{thm}\n\\begin{thm}[Gratz-Erdmann-Lamberti]\n\tAll mesh algebras (of Dynkin type) have CT-modules.\n\\end{thm}\n\nAnother result:\n\\begin{thm}[Darpo-Iyama]\n\tIf $\\calC$ is $k$-linear and locally bounded such that $\\operatorname{add}(\\calC)$ is Krull-Schmidt $G$ admissibly,\n\tthere is a one-t-one correspondence between $G$-equivariant CT-subacategories of $\\calC$ and CT-subcategories of $\\calC/G$.\n\\end{thm}\n\\subsection{Mutation}\nAlnother result from the original group:\n\\begin{thm}[GLS]\n\tIf $\\Lambda$ is a mesh algebra of type $A,D,$ or $E$, and $T$ is a CT-module in $\\mathbf{mod}$-$\\Lambda$. Let $X$ be a non-projective indecomposable \n\tsummand  then there exists a unique $Y\\not\\cong X$ such that $T/X\\oplus Y$ is CT. There are also some short exact sequences.\n\\end{thm}\n\nThe theory here works on the idea that $\\Ext^1(X,Y)\\cong D\\Ext^1(Y,X)$ which is not in general true. But in our case \nwe get that (if $\\gamma$ is the automorphism of $\\Lambda$ induced by $\\sigma$) that $\\Ext^1(X,Y)\\cong D\\Ext^1(Y,{_\\gamma}X)$, where \n${_\\gamma}X$ is the twisting of the $\\Lambda$ action on $X$ by $\\gamma$.\n\nA futher result is that each of the CT modules are $\\gamma$-equivariant except in the exception case of $P(G_2)$, the mesh algebra \ncorresponding to $D_4$, that has an order 3 automorphism. In this case, there exists such a CT module, but they are not all (something).\n\n\\section{Triangulated Categories (and syzygies) associated to singularities of algebraic varieties.}\nThis talk was given by Jesse Burke.\n\nHere let $P=k[x_0,\\dots,x_n]$ and let $P_j$ be the homogenous degree $j$ polynomials. An ideal $I$ of $P$ is \\textbf{homogeneous} if there \nexists a set of homogeneous generators. A $P$-module is homogeneous if $M=\\oplus M_i$ and $P_j\\otimes M_i$ maps to $M_{j+i}$.\n\nWrite $P(m)_j=P_{m+j}$.\n\n\\subsection{Hilbert and Syzygies}\nHilbert was one of the first to systematically use syzygies. As an example, let $P=k[x_0,\\dots,x_3]$ and let\n\\[R=\\frac{P}{(x_0x_2-x_1^2,x_0x_3-x_1x_2,x_1x_3-x_2^2)}\\]\nwhich gives us an embedding of $\\bbP^1\\hookrightarrow\\bbP^3$.\n\nA free resolution here is \n\\[0\\leftarrow R\\leftarrow P^1\\leftarrow P(-2)^3\\leftarrow P(-3)^2\\leftarrow 0\\]\nIn general it is difficult to look at abunct of equations and talk about what properties a variety has. One thing Hilbert did was \nwrite down the Hilbert series $H(R)=\\sum_n \\dim_k R_nt^n$. Hilbert proved that this is always rational with a particular denominator.\n\nLet $R$ be a graded quotient ring of polynomial ring $P$. A graded free resolution of a graded $R$ module is what you'd expect.\nA graded free resolution is minimal if all differentials have entries in $(x_0,\\dots,x_n)$.\n\n\\subsection{Examples}\n\\begin{ex}\n\tLet $R=k[x,y]$ and $M=k=R/(x,y)$, the residue field. Then we have resolution \n\t\\[0\\to R(-2)\\xrightarrow{\\binom{-y}{x}} R(-1)^2\\xrightarrow{(x,y)} R^1\\to k\\to 0\\]\n\twhich is the same as the Koszul complex.\n\\end{ex}\n\\begin{ex}\n\tNow let $R=k[x,y]/(x^2)$. Then a resolution of $k$ looks like \n\t\\[\\cdots R(-3)^2\\to R(-2)^2\\to R(-1)^2\\to R\\to k\\to 0\\]\n\twhere eventually the maps become periodic (so the syzygies are periodic).\n\\end{ex}\n\\begin{ex}\n\tWhen $R=k[x,y]/(x^2,y^2)$, the $k^{th}$ syzygy is generated by $k$ elements.\n\\end{ex}\n\\begin{ex}\n\tWhen $R=k[x,y]/(x^2,xy)$, You get that the rank grows like the Fibonacci numbers.\n\\end{ex}\n\n\\section{Modular realisations of derived equivalences in representation theory}\nThis talk was given by Daniel Chan on work with Tarig Abdelgadir and Boris Lerner.\n\nWe always work over an algebraically closed field $k$ of characteristic zero. The motto here is that Moduli stacks are a fruitful way to study a finite dimension algebra because \nthey are essentially a machine to construct functors.\n\nAs usualy, we should fix some discrete invariants of a finite dimensional $A$ module. You can start by \nfixing $\\dim M$. Slightly more subtlely, you can fix an idempotent $e$ and fix $\\dim Me$.\n\nRecall the path algebra: start with a quiver $Q$ (directed graph) without oriented cycles.\nLet $kQ$ be the path algebra with $k$-basis all paths of length $\\ge 0$. Multiplication is concatenation or zero.\n\nFor every vertex $v$, there is a path $e_v$ of length zero which is idempotent.\n\n\\subsection{King's Interpretation of Beilinson's derived equivalence}\nLet $Q$ be the Kronecker quiver on two vertices with two arrows between them in the same direction. $A=kQ$. Fix the dimension of our modules to be $(1,1)$.\n\nThis got pretty interesting but also complicated so I just listened. :) If I ever get into stacks this seems like a good guy to read.\n\n\\section{Groups, Spherical Twists and Stability Conditions}\nThis was a three-part lecture given by Asilata Bapat, Anand Deopurkar, and Anthony Licata.\n\nThe goal of this first talk is to paint a picture of the aim of this ``movement''. More specifically, one goal is to use homological algebra\nto prove some things about groups. This will hopefully cement this theory of a thing that group theorists care about.\n\n\\subsection{What kinds of groups?}\nOne kind are Artin-Tits braid groups. We will not use full generality but will suffice here. Fix some finite connected graph (no loops) $\\Gamma$.\nThen this graph yeilds $B_{r_\\Gamma}$, a group given by generators $\\sigma_i$ for each vertex. Then we add the relations \n$\\sigma_i\\sigma_j=\\sigma_j\\sigma_i$ if $i$ and $j$ are not connected by an edge and the braid relation $\\sigma_i\\sigma_j\\sigma_i=\\sigma_j\\sigma_i\\sigma_j$ if they are.\n\nVery little is known about these groups. For instance, there are no known solutions to the word problem (when are two words the same) and the conjugacy problem (when are two elements conjugate). \nPeople also don't know the what the centers of these groups are or whether they have finite representation dimension.\n\nIt is not known whether $B_{r_\\Gamma}$ are linear. However, these groups do act on ``nice'' triangulated categories. For example: \n\\begin{ex}\n\tLet $\\scrP$ denote the $\\bbC$-linear additive category generated by $\\{P_i\\}_{i\\in \\Gamma_0}$ (indexed by the vertices). Then the hom sets are given by \n\t\\[\\Hom_\\scrP(P_i,P_j)=\\left\\{\\begin{array}{lr}\n\t\t\\bbC\\cdot 1\\oplus \\bbC \\cdot x_i, & i=j\\\\\n\t\t\\bbC\\cdot y_{ij}, & (i,j)\\in\\Gamma_1\\\\\n\t\t0, & \\text{otherwise}.\n\t\\end{array}\\right.\\]\n\tTo define the composition, one can think of there as being a graded structure on $\\Hom^\\ast$ given by $\\deg(x_i)=2$ and $\\deg(y_{ij})=2$ and composition respects grading.\n\\end{ex}\n\nNow let $\\calT_\\Gamma=K^b(\\scrP_\\Gamma)$. \n\\begin{thm}[Huerfano-Khovanov]\n\t$B_{r_\\Gamma}$ acts on $\\calT_\\Gamma$.\n\n\tThe generator $\\sigma_i$ acts by twisting in $P_i$:\n\t\\[\\sigma_i(X):=\\cone(P_i\\otimes_\\bbC \\Hom(P_i,X)\\xrightarrow{ev}X)\\]\n\\end{thm}\n\nWe have a couple conjectures:\n\\begin{conj}\n\tThe action above is faithful.\n\\end{conj}\nand even more strongly (and importantly):\n\\begin{conj}\n\tThe moduli space of Bridgeland stability conditions(this word may be wrong) $\\operatorname{Stab}(\\calT)$ is contractible.\n\\end{conj}\n\n\\subsection{What kind of picture are we trying to paint?}\nAs a small (seeming) aside: How does one study mapping class groups of surfaces?\n\nLet $\\Sigma$ be a surface, possibly with boundary and punctures. Then \n\\[\\operatorname{MCG}(\\Sigma)=\\frac{\\operatorname{Diff}_+(\\Sigma)}{\\operatorname{Diff}_0(\\Sigma)}\\]\nof oriented diffeomorphisms of the $\\Sigma$ to itself modulo the ones isotopic to the identity. As an example, if $\\Sigma$ is a disk with \n$n$ punctures, the mapping class group is the braid group.\n\nNow the MCG of $\\Sigma$ acts on:\n\\begin{itemize}\n\t\\item $\\operatorname{Teich}(\\Sigma)$, the Teichm\\\"uller space, or the moduli space of hyperbolic metrics on $\\Sigma.$\n\t\\item The isotopy classes of simple closed (multi-)curves on $\\Sigma$.\n\\end{itemize} \n\nThurston explained how to unify these two actions. The first thing to notice is that the Teichm\\\"uller space comes as a manifold while the other set (call it $S$)\ndoesn't have a clear topology. So in unifying the two, Thurston developed a method of understanding it through charts. The charts are ``train tracks'' which are a bit confusing to me.\nThey each have three distinguished points and they (through four symmetries) are supposed to categorize each of the possible (maybe simple closed) curve in your space.\nI see there being a problem if the distinguished points are not punctures (e.g. if a curve goes through them).\n\nThen Thurston defined a compactification of the Teichm\\\"uller space. You can embed them into $\\bbR^S$, the (nonzero) maps from $S$ to $\\bbR$, which itself embeds (obviously)\ninto its projective closure.\n\nThen the closure of $\\operatorname{Teich}$ is the closure of its image in $\\bbP(\\bbR^S)$. It ends up that the interior is precisely Teich, and the \nboundary has an interpretation as the moduli space of projective measured foliations on $\\Sigma.$\n\nSo in particular, MCG acts on $\\overline{\\operatorname{Teich}}=\\operatorname{Teich}\\sqcup \\text{PMF}$. One can show that Teich is homeomorphic to $\\bbR^n$ and PMF is homeomorphic to $S^{n-1}$, \nso the closure of Teich is homeomorphic to the closed Euclidean ball. This gives us solutions to various algorithmic problems.\n\nFor instance, each $g\\in$MCG$(\\Sigma)$ gives rise to a dynamical system by studying repeated action of $g$ on the closed ball. In particular, one is generally interested in fixed points which yields \nNeelson-Thurston classification of mapping classes into periodic, reduced, and pseudo-Arasov.\n\n\\subsection{Chainging gears}\n\\textbf{Our goal is to try to recreate this construction using as our group the autoequivalence group of a triangulated category $\\Aut(\\calT)$.}\n\nWe need a bit of a starting point here to even give us reason to believe this is the correct approach. Luckily it becomes clear that (Bridgeland) stability conditions naturally play the role of the Teichm\\\"uller space.\nSo then we need to decide what plays the role of $S$, and here we will use spherical (stable) objects.\n\nThat is, we aim to study an action of $\\Aut(\\calT)$ on a compactification of $\\operatorname{Stab}(\\calT)$. We will talk about these in more detail in talks 2 and 3.\nIn particular, talk two will include some (rather technical) definitions for $\\operatorname{Stab}(\\calT)$ and the compactification. In talk three, we will \ndescribe an example that we understand, fully developed in the world of homological algebra.\n\n\\subsection{Definitions and compactification}\nFIx a triangualted category $\\calT$. Recall that \n\\begin{defn}\n\tA Brigeland stability condition on $\\calT$ is $(Z,P)$ where \n\t\\[P=\\{P(\\phi)|\\phi\\in\\bbR\\}\\]\n\t(notice that $P(\\phi)$ is a full subcategory of $\\calT$) satisfying \n\t\\begin{itemize}\n\t\t\\item $P(\\phi+1)=P(\\phi)[1]$\n\t\t\\item If $\\phi_1>\\phi_2$, then $\\Hom(P(\\phi_1),P(\\phi_2))=0$\n\t\t\\item If $E\\in\\calT$ then there exists a unique $\\phi_1>\\phi_2>\\cdots>\\phi_n$ and a uniqu fitration \n\t\t\\[0=E_0\\to E_1\\to\\cdots E_n=E\\]\n\t\twhere each $E_i\\to E_{i+1}$ admits $A_{i+1}\\in P(\\phi_{i+1})$ and maps \n\t\t\\[E_{i+1}\\to A_{i+1}\\to E_i\\]\n\t\tthis is called the Harder-Narasimhan filtration.\n\t\\end{itemize}\n\n\tFurthermore $Z:K_0(\\calT)\\to\\bbC$ such that if $A\\in P(\\phi)$, then $Z(A)=m(A)\\cdot e^{i\\pi\\phi}$ where $m(A)\\in\\bbR_{>0}.$\n\\end{defn}\n\nAs a matter of notation:\n\\begin{itemize}\n\t\\item $P$ is called a \\textbf{slicing} of $\\calT$\n\t\\item $Z$ is called the \\textbf{central charge}\n\t\\item If $\\phi\\in\\bbR$, the objects of $P(\\phi)$ are called \\textbf{semistable of phase $\\phi$} (simple objects of $P(\\phi)$ are called \\textbf{stable})\n\t\\item If $A\\in P(\\phi)$, then $m(A)$ is called the \\textbf{mass} of $A$. In general $m(E):=\\sum m(A_i)$ where $A_i$ are as in the filtration.\n\\end{itemize} \n\nA slicing gives a bounded t-structure on $\\calT$: for any $\\phi\\in\\bbR$, $(P(\\ge\\phi),P(<\\phi+1))$\nform your t structure whose heardt is $P([\\phi,\\phi+1])$. Given any (Z,P), we'll say that $P([0,1])$ is the \\textbf{standard t-structure for $(Z,P)$.}\n\n\\begin{prop}[Bridgeland]\n\tSpecifing $(Z,P)$ on $\\calT$ is equivalent to giving \n\t\\begin{itemize}\n\t\t\\item A bounded t structure on $\\calT$ with heart $\\calA$\n\t\t\\item Two functions $m:\\calA\\setminus\\{0\\}\\to \\bbR_{\\ge 0}$ and $\\text{ph}:\\calA\\setminus\\{0\\}\\to [0,1)$\n\t\tsuch that $Z(A):= m(A)e^{i\\pi\\text{ph}(A)}$ is a group homomorphism $K_0(\\calA)\\to\\bbC$.\n\t\t\\item (HN Condition) This is automatic if objects of $\\calA$ are of finite length.\n\t\\end{itemize}\n\\end{prop}\n\\begin{rmk}\n\tWe can recover $P$ as follows: if $\\phi\\in[0,1),$ then \n\t\\[P(\\phi)=\\{A\\in\\calA|\\text{ph}(A)=\\phi\\text{ and } \\forall 0\\ne B\\subseteq A, \\text{ph}(B)\\le\\text{ph}(A)\\}\\]\n\totherwise if $\\phi\\in[n,n+1)$, $P(\\phi)=P(\\phi-n)[n].$\n\\end{rmk}\n\nSet the space $\\operatorname{Stab}\\calT$ to be the set of all stability conditions $(Z,P)$ on $\\calT$.\n\\begin{thm}[Bridgeland]\n\t$\\operatorname{Stop}(\\calT)$ is a (complex) manifold.\n\\end{thm}\nIn fact, there is a $\\bbC$-action on $\\operatorname{Stab}\\calT$ where if $w=x+iy$ and if $(Z,P)\\in\\operatorname{Stab}(\\calT)$,\nthen $Z\\mapsto e^\\omega Z$ (``scaling mass'') and $P(\\phi)\\mapsto P(\\phi+\\frac{y}{\\pi})$ (``rotating phase''). Then we want to look at $\\operatorname{Stab}\\calT/\\bbC.$\n\n\\subsection{Plugging things into yesterday's talk}\nWe will be replacing Teich with $\\operatorname{Stab}\\calT/\\bbC$, MCG with $\\Aut\\calT$, and the (honest) sphere with the set of spherical objects of $\\calT$ modulo shifts.\n\n\\begin{defn}\n\tAn object $A$ is spherical if\n\t\\[\\Hom^i(A,A)=\\left\\{\\begin{array}{lr}\n\t\tk, & i=0,2\\\\\n\t\t0,& \\text{otherwise}\n\t\\end{array}\\right.\\]\n\\end{defn}\n\n\\subsection{Construction the closure of our space}\nWe consider the map $\\operatorname{Stab}/\\bbC\\xrightarrow{\\iota} \\bbP\\bbR^S$ that sends $\\tau$ to the map $c\\mapsto m_\\tau(c)$. We will also use the morphism \n$S\\xrightarrow{\\delta} \\bbP\\bbR^S$ that sends $A\\in S$ to the map $B\\mapsto \\overline\\hom^\\ast(A,B)$ where the over line denotes we set $\\overline\\hom(A,A)=0$.\n\nSet $\\overline{\\operatorname{Stab}/\\bbC}$ to be the closure of the image of $\\iota$ in $\\bbP\\bbR^S$.\n\n\\subsection{Some conjectures}\nThese are pretty loose/wishful thinking. \n\\begin{conj}\n\t$\\iota$ is an embedding.\n\\end{conj}\n\\begin{conj}\n\t$\\delta$ is an embedding.\n\\end{conj}\n\\begin{conj}\n\tIf $\\overline{\\operatorname{Stab}/\\bbC}=\\operatorname{Stab}\\sqcup \\text{Bdy}$, then $S$ is in the boundary and is dense in the boundary.\n\\end{conj}\n\\begin{conj}\n\t$\\overline{\\operatorname{Stab}/\\bbC}$ is a closed ball which is the union of an open ball $\\operatorname{Stab}/\\bbC$ with boundary a sphere.\n\\end{conj}\n\nThis was really cool. I especially enjoyed the third talk. :)\n\n\\section{Bounded t-structures and negative K-theory of stable infinity categories}\nThis was given by David Gepner. It is joint work with Ben Antieau and Jeremiah Heller.\n\nWe've heard a lot about t structures over this conference. Here we will talk about some obstructions to getting t structures that arise from K theory.\nFirst some conjectures:\n\\begin{conj}[Marco Schlicting]\n\tIf $\\calA$ is a small abelian category then $K_n(\\calA)=0$ for $n<0$.\n\\end{conj}\n\\begin{conj}[A-G-H]\n\tIf $\\calC$ is a small stable $\\infty$-category with a bounted t structure, then $K_n(\\calC)=0$ for all $n<0$.\n\\end{conj}\n\\begin{conj}\n\tIf $\\calC$ is a small stable infinity category with bounded t-structure, then $K_n(\\calC^\\heartsuit)\\simeq K_n(\\calC)$ is an equivalence for all $n\\in\\bbZ$.\n\\end{conj}\n\\begin{rmk}\n\tActually for non-negative $n$, this is the so-called ``theorem of the heart'' that may be due to Neeman. Notice that $K(\\calA)=K(\\Db(\\calA))$ where the bounded \n\tderived category is not the regular category, but the category where we remember the dg structure.\n\\end{rmk}\n\nThe second conjecture above implies both the first and second.\n\\begin{rmk}\n\t$K_0$ is an invariant of the triangulated homotopy category of a dg or stable infinity category. That being said, \n\tthe entire K theory $K(\\calC)$ depends on a dg (or stable) enhancement.\n\\end{rmk}\n\n\\subsection{Background on (stable) \\texorpdfstring{$\\infty$}{infty}-categories}\nThe idea here is that an $\\infty$-category is a category enriched in spaces, where we actually mean that it is enriched up to coherent homotopy.\nSo for every $A,B\\in\\calC$, there is a ``mapping space'' $\\operatorname{Map}(A,B)$ with a composition operator that is only well-defined up to homotopy.\n\n\\begin{defn}\n\tAn infinity category $\\calC$ is \\textbf{stable} if it has finite limits and colimits, a zero object, and a square is a pushout iff it is a pullback.\n\\end{defn}\n\\begin{rmk}\n\tIn case you need help wrapping your head around limits in infinity categories, it is useful to remember that $\\mathbf{Cat}\\hookrightarrow\\mathbf{Cat}_\\infty$\n\tfully faithfully via a map called the \\textbf{nerve}. Furthermore this functor commutes with limits and colimits, so these things kind of what you think they should be.\n\\end{rmk}\n\\begin{rmk}\n\tIf $\\calC$ is stable, then $\\operatorname{Ho}(\\calC)$ (the ordinary category with the same objects, but $\\Hom_{\\text{Ho}(\\calC)}(A,B)=\\pi_0\\operatorname{Map}(A,B))$ is canonically triangualted.\n\\end{rmk}\n\nYou just define $\\Sigma A$ to be the pushout of $0\\leftarrow A\\to 0$ and $\\Omega A$ is defined dually. Here distinguished triangles are the ones that come from just doing what you'd hope: compute the cofibration of the \nmap $A\\to B$ to get $C=B/A$ and then $C/B$ will be the same as $\\Sigma A$.\n\nThen $\\calC$ is stable if and only if it has finite limits, colimits, 0 and $\\Omega=\\Sigma^{-1}$.\n\n\\begin{defn}\n\tA t-structure on a stable infinity category is jsut a t-structure on Ho$(\\calC)$.\n\\end{defn}\n\\begin{rmk}\n\tIf $\\calC$ is a stable infinity category, then $\\calC^\\heartsuit$ is already an abelian (1-)category.\n\\end{rmk}\n\n\\subsection{Alebraic K theory and t-structures}\nK-theory $K:\\mathbf{Cat}_\\infty^{st}\\to\\mathbf{Sp}$ is a functor from stable infinity categories with exact functors (ones that preserve finite (co)limits) to spectra (one can \nalso think graded groups, etc.)\n\nThere are lots of places that algebraic and geometric objects give rise to stable $\\infty$ categories (e.g. $X$, $\\operatorname{Perf}X$, $\\Db(X)$)\n\n\\begin{defn}\n\t$K$ is the unit of the convolutional symmetric monoidal structure on the subcollection of $\\mathbf{Func}(\\mathbf{Cat}_\\infty^{st},\\mathbf{Sp})$ that are localizing.\n\n\tFurthermore, notice that $\\mathbf{Cat}_\\infty^{st}\\hookrightarrow \\mathbf{Func}^{loc}(\\mathbf{Cat}_\\infty^{st},\\mathbf{Sp})$ via the Yoneda embedding and K-theory \n\tis corepresented by $\\operatorname{Perf}(S)$ (lost me here).\n\\end{defn}\n\nHere a functor $F:\\mathbf{Cat}_\\infty^{st}\\to\\mathbf{Sp}$ is localizing if, given a Verdier localization sequence \n\\[\\calA\\hookrightarrow\\calB\\twoheadrightarrow\\calC\\cong(\\calB/\\calA)^{idem}\\]\nthen $F(\\calA)\\to F(\\calB)\\to F(\\calC)$ is an exact triangle of spectra (and $F$ preserves filtered colimits).\n\n\\begin{thm}[Schlichting]\n\tIf $\\calA$ is a small abelian category, then $K_{-1}\\calA=0$ and if $\\calA$ is Noetherican, then $K_{-n}\\calA=0$ for all $n>0.$\n\\end{thm}\n\n\\subsection{Results of A-G-H}\n\\begin{thm}\n\tIf $\\calC$ is a small, stable $\\infty$-category with bounded t-structure, then $K_{-1}(\\calC)=0$.\n\\end{thm}\n\\begin{thm}\n\tIf $\\calC$ is small, stable $\\infty$-category with bounded t-structure with Noetherian heart, then $K_{-n}(\\calC)=0$ for all $n>0$.\n\\end{thm}\n\\begin{thm}[Nonconnective theorem of the Noetherian heart]\n\tIF $\\calC$ is a stable infinty category with bounded t-structure such that $\\calC^\\heartsuit$ is Noetherian, then $K(\\calC^\\heartsuit)\\simeq K(\\calC)$.\n\\end{thm}\t\n\\begin{thm}\n\tLet $R$ be a commutative ring and $A$ a (cohomologically) graded dg $R$-algebra such that $H^0(A)$ is semisimple and $H^i(A)$ is finite generated as a right $H^0(A)$-module,\n\tthen $K_{-n}(A)=0$ for all $n>0$.\n\\end{thm}\n\\begin{thm}\n\tIf $i:\\calA\\to \\calB$ is a fully fairthful exact functor of small stable infinity categories equipped with compatible bounded t-structures. Then set $\\calC$ to be the Verdier quotient $\\calB/\\calA$,\n\tand $\\operatorname{Ind}(\\calC)$ inherits a t-structure which restricts to a bounded t-structure on $\\calC$ if and only if $\\calA^\\heartsuit\\hookrightarrow \\calB^\\heartsuit$ is the inclusion of a Serre subcategory.\n\\end{thm}\n\nA major question/conjecture: Given an abelian category $\\calA$, can one construct an abelian category $\\calB$ containing $\\calA$ as a Serre subcategory such that $K(\\calB)=0$?\n\nA positive answer to this would give tools necessary to answer the conjectures given in the affirmative.\n\n\\section{Local duality for Gorenstein algebras}\nThis talk was given by Henning Krause on recent work by Benson, Iyengar, and Pevtsova.\n\nMuch of Julia's talk sets the scene for this talk! Let $G$ be a finite group, let $k$ be a field. Then if $M$ is a $kG$-module, \nwe can compute $H^\\ast(G,M)=\\Ext^\\ast_{kG}(k,M)$, which is a graded module over $R:=H^\\ast(G,k)$ and this is a finitely generated algebra.\n\nPick any $\\p\\in\\Spec R$ and let $I(\\p)$ be an injective envelope of $R/\\p$. Then the theorem says \n\\begin{thm}[BIKP, '19]\n\tLet $d$ be the Krull dimension of $R/\\p$ where $\\p\\lhd R$ is prime and is not all of $R^{\\ge 0}$. Then \n\t\\[\\Hom_R(H^{\\ast-d-i}(G,M),I(\\p))\\cong\\widehat\\Ext_{kG}^i(M,\\Gamma_\\p(k))\\]\n\tfor all $i\\in\\bbZ$.\n\\end{thm}\n\n\\subsection{Serre Duality}\n\\begin{thm}\nLet $X$ be a projective nonsingular scheme over a field $k$, and let $n=\\dim X$. Then \n\\[\\Hom_k(H^{n-i}(X,\\calF),k)\\cong\\Ext_X^i(\\calF,\\omega_X)\\]\nfor all coherent sheaves $\\calF$ on $X$ and $i\\ge 0$.\n\\end{thm}\n\nA more modern formulation is that $\\Db(\\operatorname{coh}X)$ has a Serre functor, $F=-\\otimes_X^L\\omega_X[n]$.\n\n\\begin{defn}[Bendal-Kapraha, '89]\n\tLet $\\calT$ be a $k$-linear triangular category, hom-finite (what does this mean?) $\\calF:\\calT\\to\\calT$ is a \\textbf{Serre functor}\n\tif $D\\Hom_\\calT(X,Y)\\cong \\Hom_\\calT(Y,\\calF(X))$ which is natural for all $X,Y\\in\\calT$. (here he wrote $D=\\Hom_k(-,k)$).\n\\end{defn}\n\nLet $T\\in\\operatorname{coh}X$ be a tilding object and let $\\Lambda=\\End_X(T)$. Then we have an equivalence \n\\[R\\Hom_X(T,-):\\Db(\\operatorname{coh}X)\\xrightarrow{\\sim}\\Db(\\mathbf{mod}\\Lambda)\\]\nThat is, $\\Db(\\mathbf{mod}\\Lambda)$ has a Serre functor.\n\n\\begin{thm}[Reiten-van den Bergh '01, Happel '87]\n\tLet $\\Lambda$ be a finite dimensional $k$ algebra. Then the following are equivalent:\n\t\\begin{itemize}\n\t\t\\item $\\Db(\\mathbf{mod}\\Lambda)$ has a Serre functor\n\t\t\\item $\\Db(\\mathbf{mod}\\Lambda)$ has Auslander-Reiten triangles\n\t\t\\item $\\gldim \\Lambda<\\infty$.\n\t\\end{itemize}\n\\end{thm}\n\\subsection{Gorenstein Algebras}\n\\begin{defn}\n\tLet $\\Lambda$ be a finite dimensional $k$-algebra. Then $\\Lambda$ is (Iwanaga) Gorenstein if $\\injdim(\\Lambda_\\Lambda)$ and $\\injdim({_\\Lambda}\\Lambda)$ are both finite.\n\\end{defn}\nSome examples of such algebras:\n\\begin{itemize}\n\t\\item If $\\gldim \\Lambda<\\infty$, $\\Lambda$ is Gorenstein.\n\t\\item If $\\Lambda$ is self-injective, $\\Lambda$ is Gorenstein.\n\t\\item If $\\Lambda$ and $\\Gamma$ are both Gorenstein, then $\\Lambda\\otimes_k\\Gamma$ is Gorenstein. For instance the path algebra of a quiver $kQ$ tensored with $k[\\varepsilon]$ the ``dual numbers''.\n\tThe former (usually) has Gorenstein dimension 1 and the latter has Gorenstein dimension 0 (it is self-injective).\n\\end{itemize}\n\nNow let $\\mathbf{Mod}\\Lambda\\supset \\mathbf{mod}\\Lambda\\supset \\mathbf{proj}\\Lambda$ be the $\\Lambda$ modules, finitely generated $\\Lambda$ modules and finitely-generated projectives, respectively.\n\nLet $\\mathbf{GProj}\\Lambda=\\{X\\in\\mathbf{Mod}\\Lambda|\\Ext^i(X,\\Lambda)=0\\text{ for }i>0\\}$ and let $\\mathbf{Gproj}\\Lambda=\\mathbf{GProj}\\Lambda\\cap\\mathbf{mod}\\Lambda$.\n\nFinally $\\uHom_\\Lambda(X,Y)=\\Hom_\\Lambda(X,Y)/P\\Hom_\\Lambda(X,Y)$ as usual.\n\nNotice that if $\\gldim\\Lambda$ is finite, then $\\mathbf{GProj\\Lambda}=\\mathbf{Proj}\\Lambda$ and if $\\Lambda$ is self-injective, \n$\\mathbf{GProj}\\Lambda=\\mathbf{Mod}\\Lambda$, giving us (in a way) two extremes.\n\n\\begin{lem}\n\t$\\mathbf{GProj}\\Lambda$ form a Froebenus category and $\\underline{\\mathbf{GProj}}\\Lambda$ is a compactly generated trianglulated category equivalent to the subcategory of compact objects.\n\\end{lem}\n\nBuchwertz and Orlov ('87 and '04) did work to show that $\\underline{\\mathbf{Gproj}}\\Lambda$ was equivalent to the singularity category of finitely generated $\\Lambda$ modules.\n\nWe have a Nakayama functor $\\nu:-\\otimes_\\Lambda D(\\Lambda):\\mathbf{mod}\\Lambda\\to \\mathbf{mod}\\Lambda$ (it takes projectives to injectives).\n\n\\subsection{Auslander-Reiten Duality}\nWe have a diagram \n\\begin{center}\n\t\\begin{tikzcd}\n\t\t\\Db(\\mathbf{proj}\\Lambda)\\ar[r,hookrightarrow]\\ar[d] & \\Db(\\mathbf{mod}\\Lambda)\\ar[d,\"\\sim\"]\\ar[r,two heads,\"\\nu\"] & \\Dsing(\\lambda)\\ar[d,\"\\bar\\nu\"]\\\\\n\t\t\\Db(\\mathbf{proj}\\Lambda)\\ar[r,hookrightarrow] & \\Db(\\mathbf{mod}\\Lambda)\\ar[r,two heads] & \\Dsing(\\Lambda)\n\t\\end{tikzcd}\n\\end{center}\n\\begin{thm}\n\t$\\nu$ is a Serre functor for $\\Db(\\mathbf{proj}\\Lambda)$ and $\\Sigma^{-1}\\circ\\bar\\nu$ is aSerre functor for $\\Dsing(\\Lambda)$.\n\\end{thm}\n\\begin{rmk}\n\t$\\calF:\\underline{\\mathbf{Gproj}}\\Lambda\\xrightarrow{\\sim}\\underline{\\mathbf{Gproj}}\\Lambda$\n\tis an autoequivalence where $\\calF$ sends \n\t\\[X\\mapsto \\Omega^{-1}\\text{GP}(D\\operatorname{Tr}X)\\]\n\twhere GP is the Gorenstein projective approximation functio and $D$Tr is the dual of the transpose. This is suppsoed to explain \n\thow this is a statement of duality.\n\\end{rmk}\n\n\\subsection{Hochschild cohomology}\n$\\HH^\\ast(\\Lambda)=\\Ext^\\ast_{\\Lambda^e)}(\\Lambda,\\Lambda)$ is a graded commutative ring.\nThen $\\uHom_\\Lambda^\\ast(X,Y)=\\oplus\\uHom_\\Lambda(X,\\Omega^{-i}Y)$ where $X$ and $Y$ are Gorenstein projectives. Then $\\HH^\\ast(\\Lambda)$ acts on $\\underline{\\mathbf{GProj}}$ \nvia \n\\[\\varphi_X:\\HH^\\ast(\\Lambda)\\xrightarrow{-\\otimes_\\Lambda X}\\Ext^\\ast_\\Lambda(X,X)\\xrightarrow{tx\\to px}\\uHom^\\ast(X,X)\\]\nwhere I have no idea what that last map was.\n\nThus $\\uHom^\\ast(X,Y)$ are graded $\\HH^\\ast(\\Lambda)$-modules for all $X$ and $Y$ in $\\underline{\\mathbf{GProj}}\\Lambda$. As an assumption, \nfix $R\\subseteq\\HH^\\ast(\\Lambda)$ to be a homogeneous $k$ subalgebra such that\n\\begin{itemize}\n\t\\item $R$ is connected ($R^0=k$)\n\t\\item $R$ is a finitely generated $k$ algebra.\n\\end{itemize}\nThen for $\\p$ be a homogeneous prime in $R$ and we get an endofunctor $\\Gamma_\\p$ on $\\underline{\\mathbf{GProj}}\\Lambda$ that extracts the $\\p$-local $\\p$-torsion.\n\\begin{thm}[BIKP, '19]\n\tFor $X,Y\\in\\mathbf{GProj}\\Lambda$ where $X$ is finite dimensional and $\\p$ a homogeneous prime with $R/\\p$ of Krull dimension $d$,\n\t\\[\\Hom_R(\\Ext_\\Lambda^\\ast(X,Y),I(\\p))\\cong\\uHom_\\Lambda(Y,\\Omega^d\\,\\Gamma_p \\,\\text{GP}\\,\\nu(X))\\]\n\\end{thm}\n\\begin{prf}\n\tPassage to closed points via $k\\subseteq K$, similar to what we saw in Julia's talk.\n\\end{prf}\n\n\\subsection{Local duality for \\texorpdfstring{$\\Db(\\mathbf{mod}\\Lambda)$}{Db(mod Lambda)}}\nLet $\\calD:=\\Db(\\mathbf{mod}\\Lambda)$ where $\\Lambda$ is Gorenstein, $\\p$ is homogenous prime in $R\\subseteq\\HH^\\ast(\\Lambda)$. Let $\\calD_\\p$ be the $\\p$-localization\nof $\\calD$, whre the objects are the same and $\\Hom_{\\calD_\\p}^\\ast(X,Y)=\\Hom^\\ast_\\calD(X,Y)_\\p$.\n\nThen the $\\p$-localization functor is exact.\n\nNow let\n\\[\\gamma_\\p(\\calD):=\\{X\\in\\calD_\\p|\\End^\\ast_{\\calD_\\p}(X)\\text{ is $\\p$-torsion}\\}\\]\nwhich is a thick subcategory of $\\calD_\\p$.\n\\begin{rmk}\n\tif $\\calT$ is a compactly generated $R$-linear triangualted category. Then \n\t\\[\\gamma_\\p(\\calT)\\xrightarrow{\\sim}(\\Gamma_\\p\\calT)^c\\]\n\tand we get from $\\nu$ a local Nakayama endofunctor $\\nu_\\p$ on $\\gamma_\\p(\\calD)$.\n\\end{rmk}\n\\begin{thm}\n\t$\\Sigma^{-d}\\nu_\\p$ is a Serr functor for $\\gamma_\\p(\\calD)$ and $\\Hom_{R_\\p}(-,I(\\p))$ plays the role of duality.\n\\end{thm}\n\nFor $\\m= R^{>0}$ the maximal ideal, $\\Db(\\mathbf{proj}\\Gamma)\\subseteq\\gamma_\\m(\\calD)$ with equaility if (FG) holds.\n\nThus we get Serre duality for $\\Db(\\mathbf{proj}\\Lambda)$ via $\\nu_\\p$.\n\n\\end{document}", "meta": {"hexsha": "79955c16173c9f05025f44f450f1e01f765b8084", "size": 81697, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Workshop Notes/workshop_notes.tex", "max_stars_repo_name": "NicoCourts/Algebra", "max_stars_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-09-27T17:11:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-29T01:14:02.000Z", "max_issues_repo_path": "Workshop Notes/workshop_notes.tex", "max_issues_repo_name": "NicoCourts/Algebra", "max_issues_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Workshop Notes/workshop_notes.tex", "max_forks_repo_name": "NicoCourts/Algebra", "max_forks_repo_head_hexsha": "2c63123ce11bf8a75bff5530c1048669f29e87f9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-10T00:24:49.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T00:24:49.000Z", "avg_line_length": 52.8783171521, "max_line_length": 260, "alphanum_fraction": 0.7119355668, "num_tokens": 26672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953506426082, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4186092177435279}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{url}\n\\usepackage[margin=0.75in]{geometry}\n\\usepackage{float}\n\\usepackage{graphicx}\n\n\\setlength{\\parskip}{0.7em}\n\\setlength{\\parindent}{0em}\n\n\\begin{document}\n\t\\begin{center}\n    \n    \t% MAKE SURE YOU TAKE OUT THE SQUARE BRACKETS\n\t\t\\LARGE{\\textbf{CSE 6730, Group 37}} \\\\\n        \\vspace{1em}\n        \\Large{Description of parameters governing testing, natural recovery and transmission probability} \\\\\n     \n\t\\end{center}\n    \\begin{normalsize}\n    \n\n   \t\n   \t\\section{Assumptions}\n   \t\\begin{itemize}\n   \t    \\item Only unprotected acts modeled in this analysis\n   \t    \\item No age mixing input preference\n   \t    \\item Partner notification is stratified by sex and age, however in the absence of data on changes in this prevention strategy, the parameters are kept time invariant\n   \t    \\item Only heterosexual partnerships.\n   \t    \\item Treatment ensued immediately following identification of infection, although this may not always happen in practice.\n   \t\\end{itemize}\\\\\n    \n\n\t\n\t\\begin{table}[H]\n\t\\centering\n    \t\\begin{tabular}{ |p{5cm}|p{7cm}|p{5cm}| } \n    \t\t\\hline\n    \t\tParameter/Variable & Description & Distribution  \\\\ \n    \t\t\\hline\n    \t\tPopulation size & Population size for each age group & Uniformly distributed\\\\\n    \t\tTime step &\tTime step implemented in the model & \tA day \\\\\n\t\t\tHigh risk & Fraction of the population defined as high risk\t& 10\\% (Assumption) \\\\\n\t\t\tLow risk & Fraction of the population defined as low risk & 90\\% (Assumption)\\\\\n\t\t\t\\hline\n\t\t\t\\multicolumn{3}{|c|}{Testing symptomatic individuals} \\\\\n\t\t\t\\hline\n\t\t\tWomen &\tTesting of symptomatic  women\t& 1/(52*(0.079+0.072*Beta(4,4)))\\\\\n\t\t\tMen\t& Testing of symptomatic men\t& 1/(52*(0.079+0.072*Beta(4,4)))\\\\\n\t\t\t\\hline\n\t\t\t\n\t\t\t\\multicolumn{3}{|c|}{Casual partners} \\\\\n\t\t\t\\hline\n\t\t\tHigh risk(HR)& Single, 65-79 HR\t& Beta(3,60)\\\\\n \t\t\t\t\t\t & Single, 80-95 HR\t& Beta(3,400)\\\\\n\t\t\tLow risk(LR)\t & Single, 65-79 LR\t& Beta(1,160) \\\\\n \t\t\t\t\t\t & Single, 80-95 LR\t&Beta(1,160)\\\\\n \t\t\t\\hline\n \t\t\t\\multicolumn{3}{|c|}{Among paired} \\\\\n \t\t\t\\hline\n\t\t\tHigh risk(HR)& Single, 65-79 HR\t& Beta(10,70)\\\\\n\t\t\tLow risk(LR) & Single, 80-95 LR\t& Beta(10,100)\\\\\n\t\t\t\\hline\n\t\t\t\n\t\t\\multicolumn{3}{|c|}{Transmission} \\\\\n\t\t\t\\hline\n\t\t\tTransmission probability &Per act probability & Beta(5.5, 50)))\\\\\n\t\t\tWith condom protection & condom effect parameter estimate is 1.6&Beta(5.5,50)^{1.6}\\\\\n    \t\t\\hline\n    \t\t\n\t\t\\multicolumn{3}{|c|}{Natural recovery} \\\\\n\t\t\t\\hline\n\t\t\tWomen & & 1/(52*(1.13+0.5*Beta(4,4.969)))\\\\\n\t\t\tMen & & 1/(52*(1.13+0.5*Beta(4,4.969)))\\\\\n\n    \t\t\\hline\n    \t\n    \t\\multicolumn{3}{|c|}{Treatment Success} \\\\\n    \t    \\hline\n\t\t\tEfficiency of antibiotics & & Beta(190,8)))\\\\\n    \t\t\\hline\n\n    \t\\multicolumn{3}{|c|}{Partner Notification} \\\\\n    \t    \\hline\n\t\t\tWomen&Age65-79&Beta(4,3)\\\\\n\t\t\t&Age80-95&Beta(4,3)\n\t\t\t\\\\\n\t\t\tMen&Age65-79&Beta(4,3)\\\\\n\t\t\t&Age80-95&Beta(4,3)\\\\\n    \t\t\\hline\n        \t\\multicolumn{3}{|c|}{Condom Use} \\\\\n    \t    \\hline\n\t\t\tCasual partners&Weighted prevalence & 0.131\\\\\n\t\t\tPaired & Weighted prevalence & 0.368\n\t\t\t\\\\\n    \t\t\\hline\n    \t\t\n\t\n        \t\n    \t\t   \t\t\n    \t\t\n% https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5477642/\n\n    \t\t\n    \t\\end{tabular}\n    \t\\label{tab:parameter}\n    \t\\caption{Description of parameters governing testing, natural recovery and transmission probability}\n   \\end{table}\n   \n   \twe chose to fix the fraction of the population defined as high risk at constant 10\\%, but accommodate uncertainty in levels of risk behavior by varying the partner change rates by relationship states and age, in each of the risk groups. Defining a set proportion of the population to belong to a risk group and varying partner change rates is a modeling convention\n\n    \n\n\t\n\n\n\\end{normalsize}\n  \n\\end{document}\n", "meta": {"hexsha": "b9368d8b2c7a2fcad9ff17d0b784f249a8d36366", "size": 3767, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Assumptions and Variables.tex", "max_stars_repo_name": "hillegass/discrete-simulation", "max_stars_repo_head_hexsha": "553746f457d76d64167d2048962843fa05d702c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-01-22T20:35:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-22T20:35:54.000Z", "max_issues_repo_path": "Documentation/Assumptions and Variables.tex", "max_issues_repo_name": "hillegass/discrete-simulation", "max_issues_repo_head_hexsha": "553746f457d76d64167d2048962843fa05d702c2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/Assumptions and Variables.tex", "max_forks_repo_name": "hillegass/discrete-simulation", "max_forks_repo_head_hexsha": "553746f457d76d64167d2048962843fa05d702c2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3916666667, "max_line_length": 368, "alphanum_fraction": 0.6418900982, "num_tokens": 1235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032313, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4185954092277163}}
{"text": "% tex file for convolution\n\\subsubsection{Convolution}\n\\par \\indent Our study is structured around event-related neurological \nstimuli, rather than block stimuli as was the case of the data used in \nclass examples. So, we could not repurpose the class approach for \nrepresenting the hemodynamic response to our analysis. \n\n\\par It is assumed that there is a relationship between the hemodynamic \nresponse to the neurological stimuli. Further, there is the assumption that \na single stimulus generates a delayed hemodynamic response that mirrors a \ndouble-gamma function, and that multiple stimuli have an additive nature, as \ndefined below: \n\n\\begin{equation} \\label{eq:convolve}\nr(t)= \\sum_{i=1}^n \\psi_{i} \\phi_{i}(t-t_i)\n\\end{equation}\n\n\\noindent where $\\psi_i$ is the amplitude of the response stimulus (assumed to \nbe always $1$ in our case), and $\\phi_{i}$ is the hemodynamic response started \nat the $i$th stimulation ($t_i$).\n\n\\par We attempted five approaches that can each be grouped into one of three \nsubcategories: \\textbf{(1)} a strict replication of equation \n\\ref{eq:convolve}; \\textbf{(2)} a matrix multiplication equivalent to \n\\textbf{(1)}; and \\textbf{(3)} a complex function that takes advantage of the \nspeed of \\texttt{np.convolve}. This complicated function \\textbf{(3)} first \nsplits the (two-second) intervals between each scan into a given number of \neven slices, then puts the stimulus into the closest slice with respect to \ntime, and finally calls \\texttt{np.convolve} on this much longer time series \nand a detailed hrf function, before reducing it back down to the dimensions of \nthe original scan time series at two-second intervals. Detailed exploration of \nthis matter can be found in Appendix \\ref{app_convolution}.\n\nWe compared these methods for on accuracy and speed. Figure \n\\ref{fig:convolution_a} displays an accuracy comparison, and Table \n\\ref{tab:convolution_a} shows the speed per loop based off of \n\\texttt{iPython}'s \\%\\texttt{timeit} magic command.\n\n\n\n\\begin{figure}[ht]\n\\centering\n\\begin{minipage}[b]{0.45\\linewidth}\n\t\\centering\n\t\\includegraphics[width=.8\\linewidth]{../images/convolution_vs_neural_stimulus}\n\t% needs to be from the event_related_HRF_script2.py \n\t\\caption{\\scriptsize{Different convolution functions vs. \nthe Neural stimulus}}\n\t\\label{fig:convolution_a}\n\n\\end{minipage}\n\\quad\n\\begin{minipage}[b]{0.45\\linewidth}\n\t\\centering\n\t\\begin{tabular}{|l | c|}\n\t\\hline\n\tname in graph       & Speed per loop \\\\\n\t\\hline\n\tnp naive approach & 14.4 $\\mu$s  \\\\\n\tuser 2     \t\t    & 972 ms  \\\\\n\tuser 3     \t\t    & 1.15 s    \\\\\n\tuser 4 (15 cuts)      & 98.3 ms \\\\\n\tuser 4 (30 cuts)      & 185 ms  \\\\\n\tuser 5     \t \t    & 110 ms   \\\\\n\t\\hline\n\t\\end{tabular}\n\t\\vspace{5mm}\n\\captionof{table}{\\scriptsize{Speed to create HRF predictions for \n\tSubject 001, all conditions}}\n\t\\label{tab:convolution_a}\n\t\\end{minipage}\n\\end{figure}\n\n\\par \\noindent The first method in the table, ``np naive approach'', blindly \nplugs our data into the \\texttt{np.convolve} function. This approach is \nill-advised, because our data fails the \\texttt{np.convolve} assumption of \nequidistant spacing for stimuli and scans. It is only demonstrated to showcase \npotential speed. The failure of the ``np naive approach'' was the motivating \nfactor behind the rest of the hemodynamic response convolution analysis. The \n``user 2'' and ``user 3'' functions fall under subcategory \\textbf{(1)}. \n``user 2'' was the first approach designed to approximate the theoretical \nbackground, but it matches the stimulation times and not the scan times.\n``user 3'' is the most theoretically sound model (and is our standard for \naccuracy). ``user 5'' falls under subcategory \\textbf{(2)} and is the matrix \nalgebra version ``user 3'', with identical accuracy and gains in speed. \n``user 4'' falls under subcategory \\textbf{(3)}, the methods that use the\ngrid cut usage of \\texttt{np.convolve} with notations for the number of slices \nbetween each scan. We concluded that \"user 4 (15 cuts)\" was the best approach \nsince it gives us much more speed and very close accuracy to the golden \nstandard --- ``user 3''.\n\n\\subsubsection{Time Correction}\n\n\\par \\indent The fMRI scanner scans each voxel at a slightly different time. \nIn our case, the lowest horizontal slice was scanned first, with the later \nscans obtained progressively in order toward the top of the brain. The signs \nof this linear change in time of scan were observed when we ran simple linear \nregression on the data and found that the hemodynamic response $\\hat{\\beta}$ \nvalues from all conditions were grouped together. We corrected for the time \ndifferences by shifting the times of stimuli ``backwards'' for voxels scanned \nlater to directly correct for the delay of the scan (assuming that each layer \nof the scan took 2/34 of a second).\n\n\\subsubsection{Multiple Conditions}\n\n\\par \\indent Originally, we tried using multiple linear regression to account \nfor the three different types of stimuli (pump, explode, cash-out) and \nexamined if the separation of these stimuli can better describe the response. \nWe did this by creating separate predicted hemodynamic responses for each \ncondition to allow for different amplitudes associated with each type of \ncondition. As will be noted in Section \\ref{model_selection} later, we did \nnot observe a large difference in the results values we obtained from \npredicting the hemodynamic responses together for all conditions, so we did \nnot continue with this exploration. In Figure \\ref{fig:all_cond_time}, we can \nsee the different conditions separated the responses for each condition.\n \n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[scale=.5]{../images/all_cond_time}  \n\\caption{Plotting all predicted HR for conditions.}\n\\label{fig:all_cond_time}\n\\end{figure}\n\n\\par A more detailed discussion about our approach and the theory behind the \nconvolution of the hemodynamic response with the neurological response \ncan be found in Appendix \\ref{app_convolution}.\n\n", "meta": {"hexsha": "cfd4ca2ad4de976e2ec4ffbeceb8e15ea339653b", "size": 5978, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/main_sections/convolution.tex", "max_stars_repo_name": "berkeley-stat159/project-alpha", "max_stars_repo_head_hexsha": "330d025c4eda94d390a82e86deecb791086c9dbf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2015-10-30T23:08:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T03:44:02.000Z", "max_issues_repo_path": "paper/main_sections/convolution.tex", "max_issues_repo_name": "berkeley-stat159/project-alpha", "max_issues_repo_head_hexsha": "330d025c4eda94d390a82e86deecb791086c9dbf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 179, "max_issues_repo_issues_event_min_datetime": "2015-10-25T15:59:56.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-31T02:40:24.000Z", "max_forks_repo_path": "paper/main_sections/convolution.tex", "max_forks_repo_name": "berkeley-stat159/project-alpha", "max_forks_repo_head_hexsha": "330d025c4eda94d390a82e86deecb791086c9dbf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2015-10-20T19:15:10.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-23T19:33:03.000Z", "avg_line_length": 46.3410852713, "max_line_length": 79, "alphanum_fraction": 0.762462362, "num_tokens": 1495, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4185954092277162}}
{"text": "%!TEX root = forallx.tex\n\\addcontentsline{toc}{chapter}{C\\ Quick Reference}\n\\pagestyle{plain}\n{\\LARGE \\bf Quick Reference}\n\n%\\section*{Characteristic Truth Tables}\n\\label{app.CharacteristicTTs}\n\n%KB fordítása kezdet\nGyors Ajánló \n\\hfill\n\\begin{tabular}{c|c}\n\\script{A} & \\enot\\script{A}\\\\\n\\hline\nT & F\\\\\nF & T \n\\end{tabular}\n\\hfill\n\\begin{tabular}{c|c|c|c|c|c}\n\\script{A} & \\script{B} & \\script{A}\\eand\\script{B} & \\script{A}\\eor\\script{B} & \\script{A}\\eif\\script{B} & \\script{A}\\eiff\\script{B}\\\\\n\\hline\nT & T & T & T & T & T\\\\\nT & F & F & T & F & F\\\\\nF & T & F & T & T & F\\\\\nF & F & F & F & T & T\n\\end{tabular}\n\\hfill\n\n\\vfill\n\n\n\\hfill\n\\begin{tabular}{c|c}\n\\script{A} & \\enot\\script{A}\\\\\n\\hline\n1 & 0\\\\\n0 & 1 \n\\end{tabular}\n\\hfill\n\\begin{tabular}{c|c|c|c|c|c}\n\\script{A} & \\script{B} & \\script{A}\\eand\\script{B} & \\script{A}\\eor\\script{B} & \\script{A}\\eif\\script{B} & \\script{A}\\eiff\\script{B}\\\\\n\\hline\n1 & 1 & 1 & 1 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0 & 0\\\\\n0 & 1 & 0 & 1 & 1 & 0\\\\\n0 & 0 & 0 & 0 & 1 & 1\n\\end{tabular}\n\\hfill\n\n\\vfill\n\n\n\\section*{Symbolization}\n\\begin{center}\n\\label{app.symbolization}\n\\begin{tabular*}{\\textwidth}{rl}\n\\multicolumn{2}{c}{\\textsc{Sentential Connectives} (chapter \\ref{ch.SL})}\\\\ \\\\\nSzimbolizáció \nTartozó kapcsolatok (2. fejezet)\n\nIt is not the case that $P$. & $\\enot P$\\\\\nEither $P$, or $Q$. & $(P \\eor Q)$\\\\\nNeither $P$, nor $Q$. & $\\enot(P \\eor Q)$\\ or \\ $(\\enot P \\eand \\enot Q)$\\\\\nBoth $P$, and $Q$. & $(P \\eand Q)$\\\\\nIf $P$, then $Q$. & $(P \\eif Q)$\\\\\n$P$ only if $Q$. & $(P \\eif Q)$\\\\\n$P$ if and only if $Q$. & $(P \\eiff Q)$\\\\\nUnless $P$, $Q$. $P$ unless $Q$. & $(P \\eor Q)$\\\\\n\\\\\n\nNem P. $\\enot P$\\\\\nVagy P, vagy Q  $(P \\eor Q)$\\\\\nNem P, vagy Q  $\\enot(P \\eor Q)$\\ or \\ $(\\enot P \\eand \\enot Q)$\\\\\nP és Q  $(P \\eand Q)$\\\\\nHa P akkor Q $(P \\eif Q)$\\\\\nP csak akkor ha Q  $(P \\eif Q)$\\\\\nP ha és csak ha Q $(P \\eiff Q)$\\\\\nP nélkül Q. Q nélkül P $(P \\eor Q)$\\\\\n\n\\\\\n\\multicolumn{2}{c}{\\label{SymbolizingPredicates}\\textsc{Predicates} (chapter \\ref{ch.QL})}\\\\ \\\\\nAll $F$s are $G$s. & $\\forall x(Fx \\eif Gx)$\\\\\nSome $F$s are $G$s. & $\\exists x(Fx \\eand Gx)$\\\\\nNot all $F$s are $G$s. & $\\enot\\forall x(Fx \\eif Gx)$\\ or\\ $\\exists x(Fx \\eand \\enot Gx)$\\\\\nNo $F$s are $G$s. & $\\forall x(Fx \\eif\\enot Gx)$\\ or\\ $\\enot\\exists x(Fx \\eand Gx)$\\\\\n\\\\\n\nÁllítások (4. fejezet)\n\nMinden F G is $\\forall x(Fx \\eif Gx)$\\\\\nLétezik olyan F ami G $\\exists x(Fx \\eand Gx)$\\\\\nNem mindegyik F G $\\enot\\forall x(Fx \\eif Gx)$\\ or\\ $\\exists x(Fx \\eand \\enot Gx)$\\\\\nF nem egyenlő G-vel $\\forall x(Fx \\eif\\enot Gx)$\\ or\\ $\\enot\\exists x(Fx \\eand Gx)$\\\\\n\n\\\\\n\\multicolumn{2}{c}{\\textsc{Identity} (section \\ref{sec.identity})}\\\\ \\\\\nOnly $j$ is $G$. & $\\forall x(Gx \\eiff x=j)$\\\\\nEverything besides $j$ is $G$. & $\\forall x(x \\neq j \\eif Gx)$\\\\\n%$j$ is more $R$ than anyone else. & $\\forall x(x\\neq j \\eif Rjx)$\\\\\nThe $F$ is $G$. & $\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand Gx)$\\\\\n\\multicolumn{2}{l}{`The F is not G' can be translated two ways:} \\\\\nIt is not the case that the F is G. (wide)& $\\enot\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand Gx)$\\\\\nThe $F$ is non-$G$. (narrow) & $\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand \\enot Gx)$\n\\end{tabular*}\n\\end{center}\n\n\nAzonosság (4.6. rész)\n\nCsak j egyenlő G-vel $\\forall x(Gx \\eiff x=j)$\\\\\nCsak j nem egyenlő G-vel $\\forall x(x \\neq j \\eif Gx)$\\\\\nF egyenlő G-vel $\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand Gx)$\\\\\nAz F nem egyenlő G-vel két féle képpen értelmezhető:\nNem F egyenlő G-vel (tág) $\\enot\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand Gx)$\\\\\nF egyenlő nem G-vel (szűk)  $\\exists x(Fx \\eand \\forall y(Fy \\eif x=y) \\eand \\enot Gx)$\n\n\n% BEGIN: symbolizing cardinality\n\n\\newpage\n\\section*{Using identity to symbolize quantities}\n\n\\subsection*{There are at least \\blank\\ $F$s.}\n\\label{summary.atleast}\n\n\\begin{ekey}\n\\item[one] $\\exists xFx$\n\\item[two] $\\exists x_1\\exists x_2(Fx_1 \\eand Fx_2 \\eand x_1 \\neq x_2)$\n\\item[three] $\\exists x_1\\exists x_2\\exists x_3(Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_2 \\neq x_3)$\n\\item[four] $\\exists x_1\\exists x_2\\exists x_3\\exists x_4 (Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand Fx_4 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_1 \\neq x_4 \\eand x_2 \\neq x_3 \\eand x_2 \\neq x_4 \\eand x_3 \\neq x_4)$\n\\item[n] $\\exists x_1\\cdots\\exists x_n(Fx_1 \\eand\\cdots\\eand Fx_n \\eand x_1 \\neq x_2 \\eand\\cdots\\eand x_{n-1}\\neq x_n)$ \n\\end{ekey}\n\n\nAzonosságok a mennyiségek bemutatására\nLegalább  \\blank\\ $F$s.\nEgy $\\exists xFx$\nKettő $\\exists x_1\\exists x_2(Fx_1 \\eand Fx_2 \\eand x_1 \\neq x_2)$\nHárom $\\exists x_1\\exists x_2\\exists x_3(Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_2 \\neq x_3)$\nNégy $\\exists x_1\\exists x_2\\exists x_3\\exists x_4 (Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand Fx_4 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_1 \\neq x_4 \\eand x_2 \\neq x_3 \\eand x_2 \\neq x_4 \\eand x_3 \\neq x_4)$\nN $\\exists x_1\\cdots\\exists x_n(Fx_1 \\eand\\cdots\\eand Fx_n \\eand x_1 \\neq x_2 \\eand\\cdots\\eand x_{n-1}\\neq x_n)$ \n\n\n\n\\subsection*{There are at most \\blank\\ $F$s.}\n\\label{summary.atmost}\n\nOne way to say `at most $n$ things are $F$' is to put a negation sign in front of one of the symbolizations above and say $\\enot$`at least $n+1$ things are $F$.' Equivalently:\n\\begin{ekey}\n\\item[one] $\\forall x_1\\forall x_2\\bigl[(Fx_1 \\eand Fx_2) \\eif x_1=x_2\\bigr]$\n\\item[two] $\\forall x_1\\forall x_2\\forall x_3\\bigl[(Fx_1 \\eand Fx_2 \\eand Fx_3) \\eif (x_1=x_2 \\eor x_1=x_3 \\eor x_2=x_3)\\bigr]$\n\\item[three] $\\forall x_1\\forall x_2\\forall x_3\\forall x_4\\bigl[(Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand Fx_4) \\eif (x_1=x_2 \\eor x_1=x_3 \\eor x_1=x_4 \\eor x_2=x_3 \\eor x_2=x_4 \\eor x_3=x_4)\\bigr]$\n\\item[n]$\\forall x_1\\cdots\\forall x_{n+1}\n\\bigl[(Fx_1\\eand \\cdots \\eand Fx_{n+1}) \\eif (x_1=x_2 \\eor \\cdots \\eor x_n=x_{n+1})\\bigr]$ \n\\end{ekey}\n\n\n\nLegfeljebb \\blank\\ $F$s.\n\nAz egyik módszer az, hogy azt mondjuk „legfeljebb $n$ dolog az $F$”, egy tagadási jel elhelyezése az egyik elé a fenti szimbólumok közül, és azt mondjuk, hogy $\\enot$ „legalább n + 1 dolog F.” Egyenértékűen:\n\nEgy $\\forall x_1\\forall x_2\\bigl[(Fx_1 \\eand Fx_2) \\eif x_1=x_2\\bigr]$\nKettő $\\forall x_1\\forall x_2\\forall x_3\\bigl[(Fx_1 \\eand Fx_2 \\eand Fx_3) \\eif (x_1=x_2 \\eor x_1=x_3 \\eor x_2=x_3)\\bigr]$\nHárom $\\forall x_1\\forall x_2\\forall x_3\\forall x_4\\bigl[(Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand Fx_4) \\eif (x_1=x_2 \\eor x_1=x_3 \\eor x_1=x_4 \\eor x_2=x_3 \\eor x_2=x_4 \\eor x_3=x_4)\\bigr]$\nN $\\forall x_1\\cdots\\forall x_{n+1}\n\\bigl[(Fx_1\\eand \\cdots \\eand Fx_{n+1}) \\eif (x_1=x_2 \\eor \\cdots \\eor x_n=x_{n+1})\\bigr]$ \n\n\n\n\n\\subsection*{There are exactly \\blank\\ $F$s.}\n\\label{summary.exactly}\n\nOne way to say `exactly $n$ things are $F$' is to conjoin two of the symbolizations above and say `at least $n$ things are $F$' \\eand\\ `at most $n$ things are $F$.' The following equivalent formulae are shorter:\n\\begin{ekey}\n\\item[zero] $\\forall x\\enot Fx$\n\\item[one] $\\exists x\\bigl[Fx \\eand \\enot\\exists y(Fy \\eand x\\neq y)\\bigr]$\n\\item[two] $\\exists x_1\\exists x_2\\bigl[Fx_1 \\eand Fx_2 \\eand x_1 \\neq x_2 \\eand \\enot\\exists y\\bigl(Fy \\eand y\\neq x_1 \\eand y \\neq x_2\\bigr) \\bigr]$\n\\item[three] $\\exists x_1\\exists x_2\\exists x_3\\bigl[Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_2 \\neq x_3 \\eand\\\\\n\\enot\\exists y(Fy \\eand y \\neq x_1 \\eand y \\neq x_2 \\eand y\\neq x_3) \\bigr]$\n\\item[n] $\\exists x_1\\cdots\\exists x_n\\bigl[Fx_1 \\eand\\cdots\\eand Fx_n  \\eand x_1 \\neq x_2 \\eand\\cdots\\eand x_{n-1}\\neq x_n \\eand\\\\\n \\enot\\exists y(Fy \\eand y\\neq x_1 \\eand \\cdots \\eand y\\neq x_n)\\bigr]$ \n%\\item[one] $\\exists x\\forall y\\bigl[Fx \\eand (Fy \\eif y = x)\\bigr]$\n%\\item[two] $\\exists x\\exists y\\forall z\\Bigl(Fx \\eand Fy \\eand \\bigl[Fz \\eif (z=x \\eor z=y)\\bigr] \\eand x \\neq y\\Bigr)$\n%\\item[three] $\\exists x_1\\exists x_2\\exists x_3\\forall y\\Bigl(Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand [Fy \\eif (y=x_1 \\eor y=x_2 \\eor y=x_3)] \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_2 \\neq x_3\\Bigr)$\n%\\item[n] $\\exists x_1\\cdots\\exists x_n\\forall y\\Bigl(Fx_1 \\eand\\cdots\\eand Fx_n \\eand \\bigl[Fy \\eif (y=x_1 \\eor \\cdots \\eor y=x_n)\\bigr] \\eand x_1 \\neq x_2 \\eand\\cdots\\eand x_{n-1}\\neq x_n\\Bigr)$ \n\\end{ekey}\n\n\n\nPontosan \\blank\\ $F$s.\nAz egyik módszer az, hogy azt mondjuk „pontosan n a dolgok F” a fenti szimbólumok közül kettőt összekapcsolunk és azt mondjuk „legalább n dolog F” és „legfeljebb n dolog F”. A következő ekvivalnes formulák rövidebbek :\n\nNulla $\\forall x\\enot Fx$\nEgy $\\exists x\\bigl[Fx \\eand \\enot\\exists y(Fy \\eand x\\neq y)\\bigr]$\nKettő $\\exists x_1\\exists x_2\\bigl[Fx_1 \\eand Fx_2 \\eand x_1 \\neq x_2 \\eand \\enot\\exists y\\bigl(Fy \\eand y\\neq x_1 \\eand y \\neq x_2\\bigr) \\bigr]$\nHárom $\\exists x_1\\exists x_2\\exists x_3\\bigl[Fx_1 \\eand Fx_2 \\eand Fx_3 \\eand x_1 \\neq x_2 \\eand x_1 \\neq x_3 \\eand x_2 \\neq x_3 \\eand\\\\\n\\enot\\exists y(Fy \\eand y \\neq x_1 \\eand y \\neq x_2 \\eand y\\neq x_3) \\bigr]$\nN $\\exists x_1\\cdots\\exists x_n\\bigl[Fx_1 \\eand\\cdots\\eand Fx_n  \\eand x_1 \\neq x_2 \\eand\\cdots\\eand x_{n-1}\\neq x_n \\eand\\\\\n \\enot\\exists y(Fy \\eand y\\neq x_1 \\eand \\cdots \\eand y\\neq x_n)\\bigr]$ \n \n\n\n\\subsection*{Specifying the size of the UD}\n\nRemoving $F$ from the symbolizations above produces sentences that talk about the size of the UD. For instance, `there are at least 2 things (in the UD)' may be symbolized as $\\exists x\\exists y(x \\neq y)$.\n\n\n\nAz F eltávolítása a fenti szimbólumokból mondatokat eredményez amik az UD méretéről szólnak. Például: Legalább két dolog van (UD-ben) amit úgy szimbolizálnánk, hogy $\\exists x\\exists y(x \\neq y)$.\n\n\n%KB fordítása vége\n\n\n\n%  BEGIN: Rules of proof\n% change margins so that all the rules will fit\n\\setlength{\\topmargin}{0 in}\n\\setlength{\\headheight}{0 in}\n\\setlength{\\headsep}{0 in}\n\\setlength{\\textheight}{9 in}\n\\setlength{\\evensidemargin}{0.25 in}\n\\setlength{\\oddsidemargin}{0.25 in}\n\\setlength{\\textwidth}{6 in}\n\\newpage\n% This starts a new page and skips a page if necessary so as\n% to start on an even numbered page.\n% That way, the rules of proof will be on facing pages.\n% It fills it in with a somewhat gratuitous reference table.\n\\ifthenelse{\\isodd{\\thepage}}{\n%\t\\ \\vspace{2 in}\\par\\centerline{[ This page intentionally left blank. ]}\n\\begin{table}\n\tSometimes it is easier to show something by providing proofs than it is by providing models. Sometimes it is the other way round.\n\t\\begin{center}\n\t\\begin{tabular*}{\\textwidth}{p{10em}|p{10em}|p{10em}|}\n\t\\cline{2-3}\n\t & {\\centerline{YES}} & {\\centerline{NO}}\\\\\n\t\\cline{2-3}\n\tIs \\script{A} a tautology? & prove $\\vdash\\script{A}$ & give a model in which \\script{A} is false\\\\\n\t\\cline{2-3}\n\tIs \\script{A} a contradiction? &  prove $\\vdash\\enot\\script{A}$ & give a model in which \\script{A} is true\\\\\n\t\\cline{2-3}\n\tIs \\script{A} contingent? & give a model in which \\script{A} is true and another in which \\script{A} is false & prove $\\vdash\\script{A}$ or $\\vdash\\enot\\script{A}$\\\\\n\t\\cline{2-3}\n\tAre \\script{A} and \\script{B} equivalent? & prove \\mbox{$\\script{A}\\vdash\\script{B}$} and \\mbox{$\\script{B}\\vdash\\script{A}$}  & give a model in which \\script{A} and \\script{B} have different truth values\\\\\n\t\\cline{2-3}\n\tIs the set \\model{A} consistent? & give a model in which all the sentences in \\model{A} are true & taking the sentences in \\model{A}, prove \\script{B} and \\enot\\script{B}\\\\\n\t\\cline{2-3}\n\tIs the argument \\mbox{`\\script{P}, \\therefore\\ \\script{C}'} valid? & prove $\\script{P}\\vdash\\script{C}$ & give a model in which \\script{P} is true and \\script{C} is false\\\\\n\t\\cline{2-3}\n\t\\end{tabular*}\n\t\\end{center}\n\\end{table}\n\t\n\t\\newpage\n}{}\n% eliminate page numbers\n\\pagestyle{empty}\n\\twocolumn\n\n\\label{ProofRules}\n{\\LARGE \\bf Basic Rules of Proof}\n\n\\textsc{Reiteration}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{c}{\\script{A}} \\by{R}{a}\n\\end{proof}\n\n\n\\textsc{Conjunction Introduction}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[n]{b}{\\script{B}}\n\t\\have[\\ ]{c}{\\script{A}\\eand\\script{B}} \\ai{a, b}\n\\end{proof}\n\n\\textsc{Conjunction Elimination}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eand\\script{B}}\n\t\\have[\\ ]{a}{\\script{A}} \\ae{ab}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eand\\script{B}}\n\t\\have[\\ ]{b}{\\script{B}} \\ae{ab}\n\\end{proof}\n\n\\textsc{Disjunction Introduction}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{ab}{\\script{A}\\eor\\script{B}}\\oi{a}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}}\n\t\\have[\\ ]{ba}{\\script{B}\\eor\\script{A}}\\oi{a}\n\\end{proof}\n\n\\textsc{Disjunction Elimination}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{nb}{\\enot\\script{B}}\n\t\\have[\\ ]{a}{\\script{A}} \\oe{ab,nb}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{na}{\\enot\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\oe{ab,nb}\n\\end{proof}\n\n\n\\textsc{Conditional Introduction}\n\n\\nopagebreak\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{a}{\\script{A}} \\by{want \\script{B}}{}\n\t\t\\have[n]{b}{\\script{B}}\n\t\\close\n\t\\have[\\ ]{ab}{\\script{A}\\eif\\script{B}}\\ci{a-b}\n\\end{proof}\n\n\\pagebreak\n\\textsc{Conditional Elimination}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eif\\script{B}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\ce{ab,a}\n\\end{proof}\n\n\\textsc{Biconditional Introduction}\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{a1}{\\script{A}} \\by{want \\script{B}}{}\n\t\t\\have[n]{b1}{\\script{B}}\n\t\\close\n\t\\open\n\t\t\\hypo[p]{b2}{\\script{B}} \\by{want \\script{A}}{}\n\t\t\\have[q]{a2}{\\script{A}}\n\t\\close\n\t\\have[\\ ]{ab}{\\script{A}\\eiff\\script{B}}\\bi{a1-b1,b2-a2}\n\\end{proof}\n\n\\textsc{Biconditional Elimination}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n\t\\have[n]{a}{\\script{B}}\n\t\\have[\\ ]{b}{\\script{A}} \\be{ab,a}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eiff\\script{B}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{b}{\\script{B}} \\be{ab,a}\n\\end{proof}\n\n\n\n\\textsc{Negation Introduction}\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{a}{\\script{A}} \\by{for reductio}{}\n\t\t\\have[n][-1]{b}{\\script{B}}\n\t\t\\have{nb}{\\enot\\script{B}}\n\t\\close\n\t\\have[\\ ]{na}{\\enot\\script{A}}\\ni{a-nb}\n\\end{proof}\n\n\\textsc{Negation Elimination}\n\n\\begin{proof}\n\t\\open\n\t\t\\hypo[m]{na}{\\enot\\script{A}} \\by{for reductio}{}\n\t\t\\have[n][-1]{b}{\\script{B}}\n\t\t\\have{nb}{\\enot\\script{B}}\n\t\\close\n\t\\have[\\ ]{a}{\\script{A}}\\ne{na-nb}\n\\end{proof}\n\n\n\n\n\n\n%PK fordítása kezdet\n\n\\newpage\n\n{\\LARGE \\bf Quantifier Rules}\n\n\\textsc{Existential Introduction}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}\\script{c}}\n\t\\have[\\ ]{c}{\\exists \\script{x}\\script{A}\\script{x}} \\Ei{a}\n\\end{proof}\n\nNote that \\script{x} may replace some or all occurrences of \\script{c} in \\script{A}\\script{c}.\n\n\n\n\\textsc{Existential Elimination}\n\n\\begin{proof}\n\t\\have[m]{a}{\\exists \\script{x}\\script{A}\\script{x}}\n\t\\open\t\n\t\t\\hypo[n]{b}{\\script{A}\\script{c}^\\ast}\n\t\t\\have[p]{c}{\\script{B}}\n\t\\close\n\t\\have[\\ ]{d}{\\script{B}} \\Ee{a,b-c}\n\\end{proof}\n\n$^\\ast$ \\script{c} must not appear in $\\exists\\script{x}\\script{A}\\script{x}$, in \\script{B}, or in any undischarged assumption.\n\n\\textsc{Universal Introduction}\n\n\\begin{proof}\n\t\\have[m]{a}{\\script{A}\\script{c}^\\ast}\n\t\\have[\\ ]{c}{\\forall \\script{x}\\script{A}\\script{x}} \\Ai{a}\n\\end{proof}\n\n$^\\ast$ \\script{c} must not occur in any undischarged assumptions.\n\n\n\\textsc{Universal Elimination}\n\n\\begin{proof}\n\t\\have[m]{a}{\\forall \\script{x}\\script{A}\\script{x}}\n\t\\have[\\ ]{c}{\\script{A}\\script{c}} \\Ae{a}\n\\end{proof}\n\n\n\n\n{\\LARGE \\bf Identity Rules}\n\n\\begin{proof}\n\t\\have[\\ \\,\\,\\,]{x}{\\script{c}=\\script{c}} \\by{=I}{}\n\\end{proof}\n\n\\begin{proof}\n\t\\have[m]{e}{\\script{c}=\\script{d}}\n\t\\have[n]{a}{\\script{A}}\n\t\\have[\\ ]{ea1}{\\script{A}{c}\\circlearrowleft{d}} \\by{=E}{e,a}\n\\end{proof}\n\nOne constant may replace some or all occurrences of the other.\n\n\n\n\n\n\\newpage\n\n{\\LARGE \\bf Derived Rules}\n\n\\textsc{Dilemma}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eor\\script{B}}\n\t\\have[n]{ac}{\\script{A}\\eif\\script{C}}\n\t\\have[p]{bc}{\\script{B}\\eif\\script{C}}\n\t\\have[\\ ]{a}{\\script{C}} \\by{DIL}{ab,ac,bc}\n\\end{proof}\n\n\\textsc{Modus Tollens}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eif\\script{B}}\n\t\\have[n]{a}{\\enot\\script{B}}\n\t\\have[\\ ]{b}{\\enot\\script{A}} \\by{MT}{ab,a}\n\\end{proof}\n\n\\textsc{Hypothetical Syllogism}\n\n\\begin{proof}\n\t\\have[m]{ab}{\\script{A}\\eif\\script{B}}\n\t\\have[n]{bc}{\\script{B}\\eif\\script{C}}\n\t\\have[\\ ]{ac}{\\script{A}\\eif\\script{C}}\\by{HS}{ab,bc}\n\\end{proof}\n\n\n\n{\\LARGE \\bf Replacement Rules}\n{\n\\center\n\n\\textsc{Commutivity} (Comm)\\\\\n$(\\script{A}\\eand\\script{B}) \\Longleftrightarrow (\\script{B}\\eand\\script{A})$\\\\\n$(\\script{A}\\eor\\script{B}) \\Longleftrightarrow (\\script{B}\\eor\\script{A})$\\\\\n$(\\script{A}\\eiff\\script{B}) \\Longleftrightarrow (\\script{B}\\eiff\\script{A})$\n\n\\textsc{DeMorgan} (DeM)\\\\\n$\\enot(\\script{A}\\eor\\script{B}) \\Longleftrightarrow (\\enot\\script{A}\\eand\\enot\\script{B})$\\\\\n$\\enot(\\script{A}\\eand\\script{B}) \\Longleftrightarrow (\\enot\\script{A}\\eor\\enot\\script{B})$\n\n\\textsc{Double Negation} (DN)\\\\\n$\\enot\\enot\\script{A} \\Longleftrightarrow \\script{A}$\n\n\\textsc{Material Conditional} (MC)\\\\\n$(\\script{A}\\eif\\script{B}) \\Longleftrightarrow (\\enot\\script{A}\\eor\\script{B})$\\\\\n$(\\script{A}\\eor\\script{B}) \\Longleftrightarrow (\\enot\\script{A}\\eif\\script{B})$\n\n\\textsc{Biconditional Exchange} ({\\eiff}{ex})\\\\\n$[(\\script{A}\\eif\\script{B})\\eand(\\script{B}\\eif\\script{A})] \\Longleftrightarrow (\\script{A}\\eiff\\script{B})$\n\n\\textsc{Quantifier Negation} (QN)\\\\\n$\\enot\\forall\\script{x}\\script{A} \\Longleftrightarrow \\exists\\script{x}\\enot\\script{A}$\\\\\n$\\enot\\exists\\script{x}\\script{A} \\Longleftrightarrow \\forall\\script{x}\\enot\\script{A}$\n\n}\n\n\n\n", "meta": {"hexsha": "a40e906f023102582bc6786f189c4e42d0551f56", "size": 17243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "forallx-app-quickreference.tex", "max_stars_repo_name": "bodri5/forallxPecs", "max_stars_repo_head_hexsha": "e6b2be067448e3aa14e160585f8cfaf9d06ecdae", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "forallx-app-quickreference.tex", "max_issues_repo_name": "bodri5/forallxPecs", "max_issues_repo_head_hexsha": "e6b2be067448e3aa14e160585f8cfaf9d06ecdae", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2020-05-17T10:58:50.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-27T17:55:06.000Z", "max_forks_repo_path": "forallx-app-quickreference.tex", "max_forks_repo_name": "bodri5/forallxPecs", "max_forks_repo_head_hexsha": "e6b2be067448e3aa14e160585f8cfaf9d06ecdae", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 44, "max_forks_repo_forks_event_min_datetime": "2019-10-29T09:53:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-12T12:14:24.000Z", "avg_line_length": 32.6571969697, "max_line_length": 218, "alphanum_fraction": 0.6549324364, "num_tokens": 7596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.4185953985773608}}
{"text": "% specifies the documnt class. We usually use article but there are others. \n\\documentclass{article}              \n\n% these are standard packages used for the math symbols\n\\usepackage{amsmath,amssymb,amsthm, enumitem, hyperref, tabto} \n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{fancyhdr}\n\\usepackage{lastpage}\n\\usepackage{colortbl}\n\\usepackage[pdftex]{graphicx}\n\\usepackage{float}\n\\graphicspath{ {./Photos/} }\n\n\\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}\n\\definecolor{orange}{rgb}{1.0, 0.65, 0.0}\n\n% These commands below is to make sure the numbering of these are consistent with theorem\n% If you are not sure what something means, delete them, build a new file and see the\n% difference between the files. You can ignore this part for now.\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\\newtheorem{observation}[theorem]{Observation}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{notation}[theorem]{Notation}\n\n% Title of your project\n\\title{%\n  \\Huge Ramanujan's Square \\\\\n  \\LARGE Detailed Analysis\\\\\n  \\Large A DV2136 Project}\n\n% The author command places text right after title\n\\author{by \\\\\n\\Large Afzal (h1810003) \\\\\n\\Large Prannaya Gupta (h1810124) \\\\\n\\Large Yap Yuan Xi (h1810166) \\\\\n}\n\n\\date{\\Large July - September 2019}\n\n\\begin{document}\n\n\\maketitle\n\n\\tableofcontents\n\\newpage\n\\section{An Introduction}\n\n\\subsection{Inspiration}\nWe are working on Ramanujan's Magic Squares because it is a fascinating phenomenon. It is created using the date of the creator. Its an interesting concept and we really want to build upon it. We want to extend on this concept so we can see what may behold. We want to try. And we want to see if this paper bears any fruit at all.\n\n\\newpage\n\\subsection{Magic Squares}\n\n\\subsubsection{Abstract}\nIn real life situations, some problems relating to division of objects equal in numbers and value can be easily solved by constructing a semi magic square or a magic square in accordance with the given conditions. Mathematics is magic if we can either use one formula for a wide range of applications or the formula itself will produce magic properties.\n\n\\subsubsection{A Brief History of the Magic Square}\nMagic squares were known to Chinese mathematicians, and Arab mathematicians, possibly as early as the $7^{th}$ century, when the Arabs conquered northwestern parts of the Indian subcontinent and to learned Indian mathematicians and astronomers, including other aspects of combinatorical mathematics. ‘Cornelius Agrippa’ (1486 B.C. to 1535 B.C.) of China is believed to be the first for construction of magic squares.\n\n\\subsubsection{The Properties of a general Magic Square}\nA general Magic Square is the arrangement of random number within the cell such that sum of each row = each column = each diagonal. The common sum is known as ‘Magic Constant’ or ‘Magic Number’. If the above condition is valid only for the sum of elements of rows and columns and not for the diagonal elements, then that array is known as a semi magic square. All magic squares are semi magic squares. A normal magic square contains the integers from 1 to $n^2$. The constant sum in every row, column and diagonal is called the magic constant or magic sum, S. The magic constant of a normal magic square with continuous numbers depends only on n and has the value $S = \\frac{n(n^2+1)}{2}$\n\n\\subsection{Variants of Magic Squares}\n\\begin{center}\n    \\includegraphics[width=0.3\\textwidth]{Photos/MagicSquareHeirarchy.png}\n\\end{center}\n\\subsubsection{Semimagic Squares}\n    In semimagic squares, the sums of the rows and columns add up to the same number.\n\\subsubsection{(Ordinary) Magic Squares}\n    In ordinary magic squares, the sum of the rows, columns and the diagonals adds up to the same number.\n\\subsubsection{Panmagic Squares}\n    In panmagic squares, the sum of the rows, columns, the diagonals and broken diagonals add up to the same number\n\\subsubsection{Complete Magic Squares}\n    In complete magic squares, the corners, boxes and alternating rows and columns add up to the same sum as well.\n\\subsubsection{Most Perfect Squares}\n    An example of the perfect magic square is the Ramanujan's Square, but including the sums of alternating rows and columns.\n\n\\subsection{The Area of Our Investigation}\nWe are trying to investigate The Ramanujan's Magic Square, a magic square devised by the genius mathematician Srinivasa Ramanujan which has a number of exciting properties.\n\n\\newpage\n\\section{Srinivasa Ramanujan, the creator}\n\\tab Born in 1887, Ramanujan was a young Indian student.\nBy the age of 23 Ramanujan was making important new discoveries in mathematics. Professor G.H. Hardy recognised a touch of pure genius in Ramanujan’s theorems. Hardy recognised his talents and arranged to bring Ramanujan to England. Ramanujan decided to accept Hardy’s offer, and on 17 March, 1914 he set out by ship to England.\n\\subsection{England}\nIn Cambridge, the young Indian set about working on hundreds of new theorems. Hardy said: “I have never met Ramanujan’s equal.”\\cite{studyMagicSquare} However, Ramanujan did not fare so well in his private life. His fragile health suffered. He even became suicidal.\nSadly, Ramanujan never regained his health. He died on 20 April, 1920 in a care home near Madras (now Chennai). He continued working on new theorems even on his death bed. Showing his true Mathematical spirit.\\cite{historyRamanujan}\n\n\\newpage\n\\section{Primary Basis of our Investigation}\n\n\\subsection{Ramanujan's Magic Square}\n\\tab We are investigating Srinivasa Ramanujan's Magic Square. It is noticed that in a normal magic square the columns and rows give the same sum. However in this Magic Square, there are other ways to get the same sum. Like the corners, the diagonals and many more.\n\n\\subsubsection{What we can derive from the square}\n\\tab This is very intriguing to us for its adaptability to any birthday date, and made us want to find out how it works and how this is possible. We want to explore the magic of this mathematical square.\n\n\\newpage\n\\section{How does it work?}\n\n\\subsection{Description}\n\\tab This square has a huge number of possible magic square possibilities. You can consider a huge amount magic square patterns like 'By Row', 'By Column', 'By Quarter'.  Below is a definitive list:\n\n\\begin{itemize}\n  \\item The sum of any column is a number y\n  \\item The sum of any row is the number y\n  \\item The sum of any diagonal is the number y\n  \\item The sum of any 2x2 is the number y (except for those in the middle two columns)\n\\end{itemize}\n\nHowever, the real miracle of this square its ability to seemingly morph from one's birthday. The main magic square used as an example is actually derived from Ramanujan's birth date, 22 December 1887, thus amounting the sum y as 139. This is an interesting graphic and provides a majorly interesting phenomenon.\n\n\\subsection{Graphical Representation}\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale = 0.4]{MagicSquare} \n\\cite{magicSquare}\n\\caption{These diagrams show the ways in which the numbers of the Square add up to 139 in the main Ramanujan Square}\n\\end{center}\n\\end{figure}\n\n\\newpage\n\\subsection{The Solution}\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale = 1.0]{RamanujanSquare}\n\\cite{ramanujanSquare}\n\\caption{This diagram shows the algorithm by which the numbers of the Square add up to 139 in the main Ramanujan Square}\n\\end{center}\n\\end{figure}\n\n\\paragraph{\nLet Me Explain: Consider the first row being the derivation.\n}\n\\begin{equation*}\nSum_{given} = DD + MM + CC + YY\n\\end{equation*}\nwhere DD is the date, MM is the month, CC is the century and YY is the year.\n\n\\paragraph{Now consider the first column.}\n\\begin{equation*}\nSum_{col_1} = DD + (MM-2) + (CC+1) + (YY+1) = DD + MM + CC + YY\n\\end{equation*}\n\\subparagraph{Therefore, $Sum_{col_1} = Sum_{given}$}\n\n\\paragraph{Try it yourself, this applies for every single property we showed, because the numbers are perfectly balanced.}\n\n\\newpage\n\\section{Extensions and Generalisations}\n\n\\subsection{Bigger Squares}\nCan we make the square bigger.\n    \\subsubsection{5x5 Magic Square}\n        Letting H, D, M, C, Y be the hour, the day, the month, the century and the year respectively. \\\\\n        \\def\\arraystretch{2}\n        \\begin{center}\n            \\begin{tabular}{|c|c|c|c|c|}\n                \\hline\n                 H + 0 & D + 0 & M + 0 & C + 0 & Y + 0  \\\\\n                 \\hline\n                 D - 2 & C + 1 & Y + 1 & M + 3 & M - 3 \\\\\n                 \\hline\n                 Y + 2 & M - 1 & D - 1 & H - 2 & C + 2 \\\\\n                 \\hline\n                 M - 3 & H + 1 & C - 3 & Y + 2 & D + 3 \\\\\n                 \\hline\n                 C + 3 & Y - 1 & H + 3 & D - 3 & M - 2 \\\\\n                 \\hline\n            \\end{tabular}\\\\\n        \\textbf{\\\\ Note: This magic square is only pandiagonal and has multiples of one of the numbers}\n        \\end{center}\n    \\subsubsection{6x6 Magic Square}\n        Letting m, H, D, M, C and Y be the minute, the hour, the day, the month, the century and the year respectively. \\\\\n        This table uses the minute of your birth, forming an even larger square. \\\\\n        \\def\\arraystretch{2}\n        \\begin{center}\n            \\begin{tabular}{|c|c|c|c|c|c|}\n                \\hline\n                 m + 0 & H + 0 & D + 0 & M + 0 & C + 0 & Y + 0  \\\\\n                 \\hline\n                 M - 1 & Y + 1 & H - 3 & C + 3 & m - 2 & D + 2\\\\\n                 \\hline\n                 D + 3 & m - 1 & C - 1 & H + 2 & Y - 2 & M - 1\\\\\n                 \\hline\n                 Y + 2 & C - 4 & M - 3 & D + 1 & H + 3 & M + 1\\\\\n                 \\hline\n                 H - 2 & D + 2 & m + 4 & Y - 2 & M - 1 & C - 1 \\\\\n                 \\hline\n                 C - 2 & M + 2 & Y + 3 & m - 4 & D + 2 & H - 1 \\\\\n                 \\hline\n            \\end{tabular} \\\\\n        \\textbf{\\\\ Note: This is only a basic magic square with multiple repeated entries}\n        \\end{center}\n        \n\\subsection{Other Forms}\nAre there any other squares with the same properties?\nThere are many.\\\\\nBut first let us define some stuff.\\\\\nWe set D be Day, M be Month, C be century, Y be year. \\\\\nFor example, if your birthday was on 22 December 1887.\\\\ \nThen, D = 22, M = 12, C = 18, Y = 87.\\\\\n    \\subsubsection{Variation 1: Diagonal}\n        \\def\\arraystretch{2}\n        \\begin{center}\n            \\begin{tabular}{|c|c|c|c|}\n                \\hline\n                \\cellcolor{yellow} D + 0 & Y + 2 & M - 1 & C - 1 \\\\\n                \\hline\n                C - 2 & \\cellcolor{green} M + 0 & Y - 1 & D + 3 \\\\\n                \\hline\n                Y + 1 & D + 1 & \\cellcolor{aqua} C + 0 & M - 2 \\\\\n                \\hline\n                M + 1 & C - 3 & D + 2 & \\cellcolor{orange} Y + 0 \\\\\n                \\hline\n            \\end{tabular}\n        \\end{center}\n    \\subsubsection{Variation 2: Box}\n        \\def\\arraystretch{2}\n        \\begin{center}\n            \\begin{tabular}{|c|c|c|c|}\n                \\hline\n                C - 2 & M + 1 & D + 2 & Y - 1 \\\\\n                \\hline\n                Y + 1 & \\cellcolor{yellow} D + 0 & \\cellcolor{green} M + 0 & C - 1 \\\\\n                \\hline\n                M - 1 & \\cellcolor{aqua} C + 0 & \\cellcolor{orange} Y + 0 & D + 1 \\\\\n                \\hline\n                D + 2 & Y - 1 & C - 2 & M + 1 \\\\\n                \\hline\n            \\end{tabular}\n        \\end{center}\n        \n        \n    \\subsubsection{Variation 3: Column}\n        \\def\\arraystretch{2}\n        \\begin{center}\n            \\begin{tabular}{|c|c|c|c|}\n                \\hline\n                \\cellcolor{yellow} D + 0 & C + 2 & Y - 1 & M - 1 \\\\\n                \\hline\n                \\cellcolor{green} M + 0 & Y - 2 & C - 1 & D + 3 \\\\\n                \\hline\n                \\cellcolor{aqua} C + 0 & D + 2 & M + 1 & Y - 3 \\\\\n                \\hline\n                \\cellcolor{orange} Y + 0 & M - 2 & D + 1 & C + 1 \\\\\n                \\hline\n            \\end{tabular}\n        \\end{center}\n        \n    \\subsubsection{Method of making these squares}\n        Looking at the above Variations. We believe that there is a method in the creation of these kinds of squares.\n        \n        This is the method we found while creating the squares\n        \n        \\begin{enumerate}\n            \\item Set the beginning (Column, Row etc.) \n            \\item Set each box to base of one of the four given variables \n            \\item Set one number to differ\n            \\item Using that number set the others, keeping the beginning unchanged\n            \\item Check if it all add up and make changes if necessary. Repeat this till completion.\n        \\end{enumerate}\n        \n\\subsection{Super Asymmetry}\nIs there any form of derivation of the overall constant without any symmetrical significance?\n\nYes, yes there is.\n\n\\begin{center}\n            \\begin{tabular}{|c|c|c|c|}\n                \\hline\n                \\cellcolor{yellow} D + 0 & \\cellcolor{yellow} M + 0 & \\cellcolor{orange} C + 0 & \\cellcolor{aqua} Y + 0 \\\\\n                \\hline\n                \\cellcolor{orange} Y + 1 & \\cellcolor{aqua} C - 1 & \\cellcolor{orange} M - 3 & \\cellcolor{aqua} D + 3 \\\\\n                \\hline\n                \\cellcolor{aqua} M - 2 & \\cellcolor{orange} D + 2 & \\cellcolor{green} Y + 2 & \\cellcolor{green} C - 2 \\\\\n                \\hline\n                \\cellcolor{green} D + 0 & \\cellcolor{yellow} C + 2 & \\cellcolor{yellow} Y - 1 & \\cellcolor{green} M - 1 \\\\\n                \\hline\n            \\end{tabular}\n        \\end{center}\n\nThe sum of the numbers in the same coloured cell give the same sum.\n\n\\end{document}\n", "meta": {"hexsha": "40eb18bb01900ad734f9636586117fc9cb4b30c4", "size": 13738, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MainFile.tex", "max_stars_repo_name": "ThePyProgrammer/ramanujanianSquare", "max_stars_repo_head_hexsha": "91a4f824e3027ffc0d2eed2494e6c7199d0e461d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MainFile.tex", "max_issues_repo_name": "ThePyProgrammer/ramanujanianSquare", "max_issues_repo_head_hexsha": "91a4f824e3027ffc0d2eed2494e6c7199d0e461d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MainFile.tex", "max_forks_repo_name": "ThePyProgrammer/ramanujanianSquare", "max_forks_repo_head_hexsha": "91a4f824e3027ffc0d2eed2494e6c7199d0e461d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0479452055, "max_line_length": 688, "alphanum_fraction": 0.6467462513, "num_tokens": 3840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.4185953985773608}}
{"text": "\\subsection{Drucker-Prager Plasticity Model with Ductile Damage}\nThe Drucker-Prager plasticity model was developed by Drucker \\citet{drucker_implications_1950} for modelling frictional materials like granular soils and rock. An important aspect of this plasticity model is the use of a pressure dependant yield criterion to account for the increase in yield stress of geomaterials as the in-situ stresses increase. Specifically, the Drucker-Prager material model is formulated and used for materials with compressive yield strength much greater than the tensile yield strength such as one finds in soils and rocks. However, this material model is intended to simulate the material response under essentially monotonic loading which limits the capacity for modeling cyclic loading.\n\nIn addition, the Drucker-Prager model is suitable for using in conjunction with progressive damage and failure models. In this formulation, the Johnson-Cook Damage model is used to model the damage evolution of the rock mass \\citep{Johnson_1985}. At a sufficiently large scale, the damage behaviour of NFR can be thought of as behaving in a ductile capacity. \n\nHere, for the extended Drucker-Prager plasticity model, a linear yield function, $F\\left(\\bar{\\sigma}_{ij}, \\bar{\\epsilon}^{pl}\\right)$, is assumed to be a function of three stress invariants: the Von-Mises equivalent stress, $p\\left(\\bar{\\sigma}_{ij}\\right)$, the hydrostatic stress, $q\\left(\\bar{\\sigma}_{ij}\\right)$, and the third invariant of deviatoric stress, $r\\left(\\bar{\\sigma}_{ij}\\right)$. In addition, the yield function is written in terms of the compressive yield stress, $\\sigma_c^y\\left(\\bar{\\epsilon}^{pl}\\right)$, which is defined by the hardening function and two material parameters: the friction angle, $\\phi$, and a parameter $K$, defined as the ratio of the yield stress in triaxial tension to the yield stress in triaxial compression:\n\n\\begin{equation}\n\\label{eqn:const8c}\n\\begin{split}\nF\\left(\\bar{\\sigma}_{ij}, \\bar{\\epsilon}^{pl}\\right)=\\frac{1}{2}q\\left(\\bar{\\sigma}_{ij}\\right)\\left [ 1+\\frac{1}{K}-\\left ( 1-\\frac{1}{K} \\right )\\left ( \\frac{r\\left(\\bar{\\sigma}_{ij}\\right)}{q\\left(\\bar{\\sigma}_{ij}\\right)} \\right )^3 \\right ]- \\\\\np\\left(\\bar{\\sigma}_{ij}\\right)\\tan\\phi - \\left[1-\\frac{1}{3}\\tan\\phi \\right]\\sigma_c^y\\left(\\bar{\\epsilon}^{pl}\\right)\n\\end{split}\n\\end{equation}\n\n%The hydrostatic stress:\n%\\begin{equation}\n%p\\left(\\bar{\\sigma}_{ij}\\right)=\\frac{1}{3}\\bar{\\sigma}_{kk}\n%\\label{eqn:druc3}\n%\\end{equation}\n\n%The Von-Mises equivalent stress:\n%\\begin{equation}\n%q\\left(\\bar{\\sigma}_{ij}\\right)=\\sqrt{\\frac{3}{2}S_{ij}S_{ji}}\\label{eqn:druc4}\n%\\end{equation}\n\n%Where $S_{ij}$ is known as the stress deviator with $\\delta_{ij}$ being the Kronecker Delta:\n\n%\\begin{equation}\n%S_{ij} = \\bar{\\sigma_{ij}} + p\\left(\\bar{\\sigma}_{ij}\\right)\\delta_{ij}\n%\\label{eqn:druc4-1}\n%\\end{equation}\n\n%The third invariant of deviatoric stress:\n\n%\\begin{equation}\n%r\\left(\\bar{\\sigma}_{ij}\\right)= \\sqrt[3]{\\frac{9}{2}S_{ij} S_{jk} S_{ki}}\n%\\label{eqn:druc4-2}\n%\\end{equation}\n\nThe flow rule in this formulation is non-associated but the flow potential function, $G\\left(\\bar{\\sigma}_{ij}\\right)$, is written in a very similar form as the yield function with dilation angle, $\\psi$, in place of the friction angle. As with the yield function, the flow potential function, is written in terms of three stress invariants and two material parameters, dilation angle and $K$:\n\n\\begin{equation}\nG\\left(\\bar{\\sigma}_{ij}\\right)=\\frac{1}{2}q\\left(\\bar{\\sigma}_{ij}\\right)\\left [ 1+\\frac{1}{K}-\\left ( 1-\\frac{1}{K} \\right )\\left ( \\frac{r\\left(\\bar{\\sigma}_{ij}\\right)}{q\\left(\\bar{\\sigma}_{ij}\\right)} \\right )^3 \\right ]-p\\left(\\bar{\\sigma}_{ij}\\right)\\tan\\psi\\label{eqn:const11}\n\\end{equation}\n\nIn addition to the yield function and the flow rule, the hardening rule is assumed to take the form of the Barcelona model \\citep{lubliner_plastic-damage_1989}. The Barcelona model allows for material hardening before softening and approaches a yield stress of 0 as the plastic strain increases.  This form of the hardening function can be written in terms of three material parameters, initial compressive yield strength $\\sigma_c^{iy}$, $\\alpha$ and $\\beta$:\n\n\\begin{equation}\n%\\sigma_{c}\\left(\\bar{\\epsilon}^{in}\\right)=\\frac{\\sigma_{c}^{iy}-\\sigma_{c}^{p}}{\\left(\\epsilon_{c}^{pp}\\right)^{2}}\\left(\\bar{\\epsilon}^{in}-\\epsilon_{c}^{pp}\\right)^{2}+\\sigma_{c}^{p}\n\\sigma_c=\\sigma_c^{iy}\\left [ \\left ( 1+\\alpha \\right ) e^{-\\beta\\bar{\\epsilon}^{pl}}-\\alpha e^{-2\\beta\\bar{\\epsilon}^{pl}}  \\right ]\n\\label{eqn:param2-1}\n\\end{equation}\n\nThe damage initiation criterion for this material model is based on the Johnson-Cook model of ductile damage initiation \\citep{Johnson_1985}. The standard Johnson-Cook model assumes the equivalent plastic strain when damage is initiated, $\\bar{\\epsilon}_{f}^{pl}\\left(\\eta\\right)$, is a function of triaxiality, $\\eta$, and is written in terms of five material parameters. However, assuming isothermal conditions, neglecting rate effects, and assuming a simplified form of the exponential relationship, the initiation criterion can be reduced to two material parameters, $D_2$ and $D_3$:\n\n\\begin{equation}\n\\bar{\\epsilon}_{f}^{pl}\\left(\\eta\\right)=D_{2}e^{D_{3}\\eta}\\label{eqn:druc8}\n\\end{equation}\n\nAfter the material has experienced yield and material damage has occurred, the stress-strain relationship becomes strongly mesh-dependent because of strain localization due to the energy dissipation decreasing as the mesh is refined. As such, Hillerborg et al. \\citet{Hillerborg_1976} proposed a stress-displacement response based on fracture energy after damage initiation assuming that evolving damage is a linear degradation of the material stiffness in compression. Assuming a linear form, the effective plastic displacement when the material is completely damaged, $\\bar{u}^{pl}_f$, can be specified, and the damage evolution can then be written in terms of the effective plastic displacement, $\\bar{u}^{pl}$:\n\n\\begin{equation}\n\\dot{D}=\\frac{\\dot{\\bar{u}}^{pl}}{\\bar{u}_{f}^{pl}}\\label{eqn:druc9-1}\n\\end{equation}\n\n", "meta": {"hexsha": "547b7fa3ee62fe1f3d800702e49a2b750a3d6994", "size": 6113, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "subsection_Drucker_Prager_Plasticity_Model__.tex", "max_stars_repo_name": "yetisir/up-scaling-dem-simulations", "max_stars_repo_head_hexsha": "9c9043effdb72a608ffec11726af97154751722e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "subsection_Drucker_Prager_Plasticity_Model__.tex", "max_issues_repo_name": "yetisir/up-scaling-dem-simulations", "max_issues_repo_head_hexsha": "9c9043effdb72a608ffec11726af97154751722e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "subsection_Drucker_Prager_Plasticity_Model__.tex", "max_forks_repo_name": "yetisir/up-scaling-dem-simulations", "max_forks_repo_head_hexsha": "9c9043effdb72a608ffec11726af97154751722e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-29T23:14:09.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-29T23:14:09.000Z", "avg_line_length": 91.2388059701, "max_line_length": 758, "alphanum_fraction": 0.7474235236, "num_tokens": 1733, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.5312093733737562, "lm_q1q2_score": 0.4185564366990966}}
{"text": "\\section{Mixture Models \\& Secant Varieties}\n\n\\begin{frame}{ \\emph{``Absence of evidence is not evidence of absence.''} }\n    \\begin{itemize}\n    \\item Suppose $\\mc{P} \\subset \\Delta_{r-1}$ is a model for a random variable $X$ with state space $[r]$.\n    \\item Assume $Y$ is a \\emph{hidden} or \\emph{latent} random variable, with state space $[s]$; for each $j \\in [s]$, the conditional distribution of $X$ given $Y = j$ is $p^{(j)} \\in \\mc{P}$. \n    \\item $Y$ also has some probability distribution $\\pi \\in \\Delta_{s-1}$.\n    \\end{itemize}\n\n    So the joint distribution of $Y$ and $X$ is given by the formula\n    $$ P(Y = j; X = i) = \\pi_{j} \\cdot p_{i}^{(j)}. $$\n\n    \\begin{block}{\\emph{Donald Rumsfeld, 21st US Secretary of Defense}, \\cite{DR2002}}\n        \\emph{``[T]here are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know.''}\n    \\end{block}\n\n\\end{frame}\n\n\\begin{frame}{Mixture Models}\n\n    \\begin{itemize}\n    \\item But as $Y$ is hidden, we can only observe the marginal distribution of $X$, that is\n    $$ P(X = i) = \\sum_{j = 1}^{s} \\pi_{j} \\cdot p_{i}^{(j)}. $$\n    \\item In other words, the marginal distribution of $X$ is the convex combination of the $s$ distributions $p^{(1)}, \\ldots, p^{(s)}$, with weights given by $\\pi$.\n    \\end{itemize}\n\n    \\begin{block}{Definition \\cite{BSSSMD2009}}\n        Let $\\mc{P} \\subset \\Delta_{r-1}$ be a statistical model. The \\emph{$s$-th mixture model} is\n        $$ \\Mixt^{s}(\\mc{P}) := \\Set{ \\sum_{j = 1}^{s} \\pi_{j}\\cdot p^{(j)} | \\pi \\in \\Delta_{s-1},\\ p^{(j)} \\in \\mc{P}, \\text{ for all } j }. $$\n    \\end{block}\n\n\\end{frame}\n\n\\begin{frame}{Mixture Models}\n\n    \\begin{itemize}\n    \\item Mixture models provide ways to build complex models out of simpler ones.\n\n    \\item Basic assumption is that the underlying population to be modelled can be split into $s$ disjoint sub-populations.\n\n    \\item Restricted to each sub-population, the observable $X$ follows a probability distribution from the simple model $\\mc{P}$.\n\n    \\item After marginalisation though, the structure becomes significantly more complex as it is now a convex combination of these simple distributions.\n\n    \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}{Phylogenetic Trees}\n\n    \\begin{itemize}\n        \\item Introduce \\emph{phylogenetic trees}; describe the descent of species from a common ancestor:        \n\n        \\begin{center}\n        \\includegraphics[height=0.75\\textheight]{resources/phylogenetic-tree.pdf}\n        \\end{center}\n\n    \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}{Molecular Phylogenetics}\n\n    \\begin{itemize}\n        \\item Sequence of DNA molecules in a genome is represented as a sequence of letters from the four letter alphabet $\\Sigma = \\{ \\texttt{A}, \\texttt{C}, \\texttt{G}, \\texttt{T} \\}$.\n\n        \\item \\emph{Fix for now} an ancestral nucleotide $\\texttt{Y} \\in \\Sigma$; we assume that the following evolution events occur independently \\cite{EAsalmon}:\n\n        $$ \\texttt{Y} \\overset{ \\pi_{\\texttt{Y}} \\cdot p_{\\texttt{A}}^{(\\texttt{Y})}  }{\\longmapsto}  \\texttt{A}, \\quad \\texttt{Y} \\overset{ \\pi_{\\texttt{Y}} \\cdot p_{\\texttt{C}}^{(\\texttt{Y})}  }{\\longmapsto} \\texttt{C}, \\quad \\texttt{Y} \\overset{ \\pi_{\\texttt{Y}} \\cdot p_{\\texttt{G}}^{(\\texttt{Y})}  }{\\longmapsto} \\texttt{G}, \\quad \\texttt{Y} \\overset{ \\pi_{\\texttt{Y}} \\cdot p_{\\texttt{T}}^{(\\texttt{Y})}  }{\\longmapsto} \\texttt{T}, $$ \n\n        \\item So \\emph{given} $\\texttt{Y}$, we have a joint distribution:\n        \n        $$ \\pi_{\\texttt{Y}} \\cdot [ p_{\\texttt{A}}^{(\\texttt{Y})}, p_{\\texttt{C}}^{(\\texttt{Y})}, p_{\\texttt{G}}^{(\\texttt{Y})}, p_{\\texttt{T}}^{(\\texttt{Y})} ] \\in \\Delta_{3} = \\Delta_{4-1}. $$\n\n    \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}{Example}\n    \\begin{itemize}\n        \\item  $\\texttt{Y}$ is a hidden variable though; could have been anything from $\\Sigma = \\Set{\\texttt{A}, \\texttt{C}, \\texttt{G}, \\texttt{T}}$.\n\n        \\item For \\emph{exactly one given choice} of \\texttt{Y}, we had the distribution $\\Delta_{3}$; need to consider \\emph{all choices} of ancestral nucleotide \\texttt{Y}.\n\n        \\item Hence, we get the mixture model \\cite{EAsalmon}:\n            \\vspace*{-8pt}\n        \\begin{equation*}\n            \\begin{split}\n                &\\Mixt^{4}(\\Delta_{3}) \\\\\n                &= \\Set{\\sum_{ \\texttt{Y} \\in \\Sigma  } \\pi_{\\texttt{Y}} \\cdot p^{(\\texttt{Y})} | \\pi \\in \\Delta_{3},\\ p^{(\\texttt{Y})} \\in \\mc{P} \\subseteq \\Delta_{3}, \\text{ for each \\texttt{Y}} }.\n            \\end{split}\n        \\end{equation*}\n\n    \\end{itemize}\n\n    \\begin{block}{Question?}\n    What is the analogue for mixture models in algebraic statistics?\n    \\end{block}\n\n\\end{frame}\n\n\\begin{frame}{Secant Varieties}\n    \\begin{block}{Answer!}\n        Secant\\footnote{from \\emph{secare}, ``to cut'' in Latin; \\emph{c.f. tangō}, ``to touch''.} varieties \\cite{BSSSMD2009}!\n    \\end{block}\n\n    \\begin{block}{Definitions}\n        \\begin{itemize}\n        \\item Consider two varieties $V, W \\subseteq \\RR^{k}$. The \\emph{join} of $V$ and $W$ is the variety\n        $$ \\mc{J}(V,W) := \\{ \\lambda v + (1-\\lambda)w : v \\in v, w \\in W, \\lambda \\in [0,1] \\}. $$\n\n        \\item If $V = W$, then this is the \\emph{secant variety} of $V$, denoted $\\Sec^{2}(V) = \\mc{J}(V,V)$. The \\emph{$s$-th higher secant variety} is:\n        $$ \\Sec^{1}(V) := V, \\qquad \\Sec^{s}(V) := \\mc{J}(\\Sec^{s-1}(V), V ). $$\n        \\end{itemize}\n    \\end{block}\n\n\\end{frame}\n\n\\begin{frame}{Secant Varieties}\n   \n    \\begin{center}\n        \\includegraphics[height=0.25\\textwidth, angle=0]{resources/secant-line.pdf}\n    \\end{center}\n\n    \\begin{center}\n        \\includegraphics[height=0.35\\textwidth, angle=0]{resources/secant-circle.pdf}\n    \\end{center}\n\n\\end{frame}\n\n\\begin{frame}{More Complicated Phylogenetic Trees}\n\n    \\begin{itemize}\n        \\item Last example only had one extant species; what about if we had three extant species, all coming from the same ancestor?\n\n    \\begin{center}\n        \\includegraphics[width=0.6\\textwidth, angle=0]{resources/three-extant.pdf}\n    \\end{center}\n\n    \\item Now we have to consider: $\\Sec^{4}(\\PP^{3} \\times \\PP^{3} \\times \\PP^{3})$; or equivalently $\\Mixt^{4}(\\Delta_{3} \\times \\Delta_{3} \\times \\Delta_{3})$ \\cite{EAsalmon}.\n\n    \\item Finding the minimal set of polynomials defining $\\Sec^{4}(\\PP^{3} \\times \\PP^{3} \\times \\PP^{3})$ once gave rise to a very important application of algebraic statistics...\n\n    \\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}{The \\emph{Salmon Problem}}\n\n\\begin{block}{Statement}\n    \\emph{Determine the ideal\\footnote{read this as ``set of defining polynomials''.} defining $\\Sec^{4}(\\PP^{3} \\times \\PP^{3} \\times \\PP^{3})$,} \\cite{EAsalmon}.\n\\end{block}\n\n\\begin{block}{Prize}\n    \\begin{itemize}\n    \\item At an IMA workshop in 2007, Elizabeth Allman stated that she would personally catch and smoke copper river salmon from Alaska for whomever solved this problem.\n    \\item Solved in 2010 by Shmuel Friedland \\& Elizabeth Gross \\cite{SFEG2012} (see \\cite{DBLO2011} too for an in-depth discussion).\n    \\end{itemize}\n\\end{block}\n\nSolving this would then provide all polynomial invariants of the statistical model for any binary evolutionary tree, with any number of states \\cite{EAJR2008, DBLO2011}.\n\n\\end{frame}\n\n\\begin{frame}{Revision}\n\nWhy $\\Sec^{4}(\\PP^{3} \\times \\PP^{3} \\times \\PP^{3})$ again?\n\n\\begin{itemize}\n    \\item Three independent variables (nucleotides in extant species) $\\rightsquigarrow$ three factors in product;\n    \\item Each independently assumes one value from $\\Sigma = \\{ \\texttt{A}, \\texttt{C}, \\texttt{G}, \\texttt{T} \\}$ $\\rightsquigarrow$ distribution is a point in $\\PP^{3} = \\PP^{4-1}$;\n    \\item The ancestral nucleotide is unknown, but could assume any of the four values in $\\Sigma$ $\\rightsquigarrow$ mix four such independence models;\n    \\item The model for the three observed nucleotides is therefore\n    \\begin{equation*}\n            \\Sec^{4}(\\PP^{3} \\times \\PP^{3} \\times \\PP^{3}),\\quad \\text{\\emph{c.f.},} \\quad \\Mixt^{4}(\\Delta_{3} \\times \\Delta_{3} \\times \\Delta_{3}).\n    \\end{equation*}\n\\end{itemize}\n\\end{frame}", "meta": {"hexsha": "4825134ea87a29ef177181d570118e9bf29214a2", "size": 8130, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/mixtures-secants.tex", "max_stars_repo_name": "bencwbrown/PGColloquium-06-11-2020", "max_stars_repo_head_hexsha": "853e91be69ff80c3e214ffcd97afe1db2ae458e8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/mixtures-secants.tex", "max_issues_repo_name": "bencwbrown/PGColloquium-06-11-2020", "max_issues_repo_head_hexsha": "853e91be69ff80c3e214ffcd97afe1db2ae458e8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/mixtures-secants.tex", "max_forks_repo_name": "bencwbrown/PGColloquium-06-11-2020", "max_forks_repo_head_hexsha": "853e91be69ff80c3e214ffcd97afe1db2ae458e8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.6741573034, "max_line_length": 441, "alphanum_fraction": 0.6389913899, "num_tokens": 2682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.41849913981694487}}
{"text": "\\chapter{Sales pitches}\n\\label{ch:sales}\n\\newcommand{\\pitch}[1]{\\ii[\\textsf{\\color{blue}\\ref{#1}}.] \\textsf{\\color{blue} \\textbf{\\nameref{#1}.}} \\\\[1ex]} % for now. . .\n\\newcommand{\\buzzword}[1]{\\textbf{\\color{green!40!black} #1}}\n\nThis chapter contains a pitch for each part,\nto help you decide what you want to read\nand to elaborate more on how they are interconnected.\n\nFor convenience, here is again the dependency plot\nthat appeared in the frontmatter.\n\\input{tex/frontmatter/digraph}\n\n\\section{The basics}\n\\begin{itemize}\n\\pitch{part:startout}\nI made a design decision that the first part\nshould have a little bit both of algebra and topology:\nso this first chapter begins by defining a \\buzzword{group},\nwhile the second chapter begins by defining a \\buzzword{metric space}.\nThe intention is so that newcomers get to see two different\nexamples of ``sets with additional structure''\nin somewhat different contexts,\nand to have a minimal amount of literacy as these sorts\nof definitions appear over and over.\\footnote{In particular,\n\tI think it's easier to learn\n\twhat a homeomorphism is after seeing group isomorphism,\n\tand what a homomorphism is after seeing continuous map.}\n\n\\pitch{part:absalg}\nThe algebraically inclined can then delve into\nfurther types of algebraic structures:\nsome more details of \\buzzword{groups},\nand then \\buzzword{rings} and \\buzzword{fields} ---\nwhich will let you generalize $\\ZZ$, $\\QQ$, $\\RR$, $\\CC$.\nSo you'll learn to become familiar with all sorts of other nouns\nthat appear in algebra, unlocking a whole host of objects\nthat one couldn't talk about before.\n\nWe'll also come into \\buzzword{ideals},\nwhich generalize the GCD in $\\ZZ$ that you might know of.\nFor example, you know in $\\ZZ$ that any integer\ncan be written in the form $3a+5b$ for $a,b \\in \\ZZ$,\nsince $\\gcd(3,5)=1$.\nWe'll see that this statement is really\na statement of ideals: ``$(3,5)=1$ in $\\ZZ$'',\nand thus we'll understand in what situations\nit can be generalized, e.g.\\ to polynomials.\n\n\\pitch{part:basictop}\nThe more analytically inclined can instead move into topology,\nlearning more about spaces.\nWe'll find out that ``metric spaces'' are actually too specific,\nand that it's better to work with \\buzzword{topological spaces},\nwhich are based on the so-called \\buzzword{open sets}.\nYou'll then get to see the buddings of some geometrical ideals,\nending with the really great notion of \\buzzword{compactness},\na powerful notion that makes real analysis tick.\n\nOne example of an application of compactness to tempt you now:\na continuous function $f \\colon [0,1] \\to \\RR$\nalways achieves a \\emph{maximum} value.\n(In contrast, $f \\colon (0,1) \\to \\RR$ by $x \\mapsto 1/x$ does not.)\nWe'll see the reason is that $[0,1]$ is compact.\n\\end{itemize}\n\n\\section{Abstract algebra}\n\\begin{itemize}\n\\pitch{part:linalg}\nIn high school, linear algebra is often really unsatisfying.\nYou are given these arrays of numbers,\nand they're manipulated in some ways that don't really make sense.\nFor example, the determinant is defined as this\nfunny-looking sum with a bunch of products that seems\nto come out of thin air. Where does it come from?\nWhy does $\\det(AB) = \\det A \\det B$ with such a bizarre formula?\n\nWell, it turns out that you \\emph{can} explain all of these things!\nThe trick is to not think of linear algebra\nas the study of matrices,\nbut instead as the study of \\emph{linear maps}.\nIn earlier chapters we saw that we got great generalizations\nby speaking of ``sets with enriched structure'' and ``maps between them''.\nThis time, our sets are \\buzzword{vector spaces}\nand our maps are \\buzzword{linear maps}.\nWe'll find out that a matrix is actually just\na way of writing down a linear map as an array of numbers,\nbut using the ``intrinsic'' definitions\nwe'll de-mystify all the strange formulas from high school\nand show you where they all come from.\n\nIn particular, we'll see \\emph{easy} proofs\nthat column rank equals row rank,\ndeterminant is multiplicative, trace is the sum of the diagonal entries.\nWe'll see how the dot product works,\nand learn all the words starting with ``eigen-''.\nWe'll even have a bonus chapter for Fourier analysis\nshowing that you can also explain all the big buzz-words\nby just being comfortable with vector spaces.\n\n\\pitch{part:groups}\nSome of you might be interested in more about groups,\nand this chapter will give you a way to play further.\nIt starts with an exploration of \\buzzword{group actions},\nthen goes into a bit on \\buzzword{Sylow theorems},\nwhich are the tools that let us try to \\emph{classify all groups}.\n\n\\pitch{part:repth}\nIf $G$ is a group, we can try to understand\nit by implementing it as a \\emph{matrix},\ni.e.\\ considering embeddings $G \\injto \\GL_n(\\CC)$.\nThese are called \\buzzword{representations} of $G$;\nit turns out that they can be decomposed into \\buzzword{irreducible} ones.\nAstonishingly we will find that we can\n\\emph{basically characterize all of them}:\nthe results turn out to be short and completely unexpected.\n\nFor example, we will find out that there are finitely\nmany irreducible representations of a given finite group $G$;\nif we label them $V_1$, $V_2$, \\dots, $V_r$,\nthen we will find that $r$ is the number\nof conjugacy classes of $G$, and moreover that\n\\[ |G| = (\\dim V_1)^2 + \\dots + (\\dim V_r)^2 \\]\nwhich comes out of nowhere!\n\nThe last chapter of this part will show you some\nunexpected corollaries.\nHere is one of them:\nlet $G$ be a finite group and create variables $x_g$\nfor each $g \\in G$.\nA $|G| \\times |G|$ matrix $M$ is defined by setting\nthe $(g,h)$th entry to be the variable $x_{g \\cdot h}$.\nThen this determinant will turn out to \\emph{factor},\nand the factors will correspond to the $V_i$ we described above:\nthere will be an irreducible factor of degree $\\dim V_i$\nappearing $\\dim V_i$ times.\nThis result, called the \\buzzword{Frobenius determinant},\nis said to have given birth to representation theory.\n\n\\pitch{part:quantum}\nIf you ever wondered what \\buzzword{Shor's algorithm} is,\nthis chapter will use the built-up linear algebra to tell you!\n\\end{itemize}\n\n\\section{Real and complex analysis}\n\\begin{itemize}\n\\pitch{part:calc}\nIn this part, we'll use our built-up knowledge of\nmetric and topological spaces to give short, rigorous definitions\nand theorems typical of high school calculus.\nThat is, we'll really define and prove most everything you've seen about\n\\buzzword{limits}, \\buzzword{series}, \\buzzword{derivatives}, and \\buzzword{integrals}.\n\nAlthough this might seem intimidating,\nit turns out that actually, by the time we start this chapter,\n\\emph{the hard work has already been done}:\nthe notion of limits, open sets, and compactness\nwill make short work of what was swept under the rug in AP calculus.\nMost of the proofs will thus actually be quite short.\nWe sit back and watch all the pieces slowly come together\nas a reward for our careful study of topology beforehand.\n\nThat said, if you are willing to suspend belief,\nyou can actually read most of the other parts\nwithout knowing the exact details of all the calculus here,\nso in some sense this part is ``optional''.\n\n\\pitch{part:cmplxana}\nIt turns out that \\buzzword{holomorphic functions}\n(complex-differentiable functions)\nare close to the nicest things ever:\nthey turn out to be given by a Taylor series\n(i.e.\\ are basically polynomials).\nThis means we'll be able to prove unreasonably nice results\nabout holomorphic functions $\\CC \\to \\CC$, like\n\\begin{itemize}\n\t\\ii they are determined by just a few inputs,\n\t\\ii their contour integrals are all zero,\n\t\\ii they can't be bounded unless they are constant,\n\t\\ii \\dots.\n\\end{itemize}\nWe then introduce \\buzzword{meromorphic functions},\nwhich are like quotients of holomorphic functions,\nand find that we can detect their zeros by simply drawing\nloops in the plane and integrating over them:\nthe famous \\buzzword{residue theorem} appears.\n(In the practice problems, you will see this even gives\nus a way to evaluate real integrals that can't be evaluated otherwise.)\n\n\\pitch{part:measure}\nMeasure theory is the upgraded version of integration.\nThe Riemann integration is for a lot of purposes not really sufficient;\nfor example, if $f$ is the function equals $1$ at rational numbers\nbut $0$ at irrational numbers,\nwe would hope that $\\int_0^1 f(x) \\; dx = 0$,\nbut the Riemann integral is not capable of handling this function $f$.\n\nThe \\buzzword{Lebesgue integral} will handle these mistakes\nby assigning a \\emph{measure} to a generic space $\\Omega$,\nmaking it into a \\buzzword{measure space}.\nThis will let us develop a richer theory of integration\nwhere the above integral \\emph{does} work out to zero\nbecause the ``rational numbers have measure zero''.\nEven the development of the measure will be an achievement,\nbecause it means we've developed a rigorous, complete way\nof talking about what notions like area and volume mean ---\non any space, not just $\\RR^n$!\nSo for example the Lebesgue integral will let us\nintegrate functions over any \\buzzword{measure space}.\n\n\\pitch{part:prob}\nUsing the tools of measure theory, we'll be able to start\ngiving rigorous definitions of \\buzzword{probability}, too.\nWe'll see that a \\buzzword{random variable} is actually\na function from a measure space of worlds to $\\RR$,\ngiving us a rigorous way to talk about its probabilities.\nWe can then start actually stating results like\nthe \\buzzword{law of large numbers} and \\buzzword{central limit theorem}\nin ways that make them both easy to state and straightforward to prove.\n\n\\pitch{part:diffgeo}\nMultivariable calculus is often confusing\nbecause of all the partial derivatives.\nBut we'll find out that, armed with our good understanding\nof linear algebra, that we're really looking at a \\buzzword{total derivative}:\nat every point of a function $f \\colon \\RR^n \\to \\RR$\nwe can associate a \\emph{linear map} $Df$ which\ncaptures in one object the notion of partial derivatives.\nSet up this way, we'll get to see versions of \\buzzword{differential forms}\nand \\buzzword{Stokes' theorem},\nand we finally will know what the notation $dx$ really means.\nIn the end, we'll say a little bit about manifolds in general.\n\\end{itemize}\n\n\\section{Algebraic number theory}\n\\begin{itemize}\n\\pitch{part:algnt1}\nWhy is $3+\\sqrt5$ the conjugate of $3-\\sqrt5$?\nHow come the norm $\\norm{a+b\\sqrt5} = a^2-5b^2$ used in Pell equations\njust happens to be multiplicative?\nWhy is it we can do factoring into primes in $\\ZZ[i]$\nbut not in $\\ZZ[\\sqrt{-5}]$?\nAll these questions and more will be answered in this part,\nwhen we learn about \\buzzword{number fields},\na generalization of $\\QQ$ and $\\ZZ$ to things like $\\QQ(\\sqrt5)$\nand $\\ZZ[\\sqrt{5}]$.\nWe'll find out that we have unique factorization into prime ideals,\nthat there is a real \\emph{multiplicative norm} in play here,\nand so on.\nWe'll also see that Pell's equation falls out of this theory.\n\n\\pitch{part:algnt2}\nAll the big buzz-words come out now:\n\\buzzword{Galois groups}, the \\buzzword{Frobenius}, and friends.\nWe'll see quadratic reciprocity is just a shadow of\nthe behavior of the Frobenius element,\nand meet the \\buzzword{Chebotarev density theorem},\nwhich generalizes greatly the Dirichlet theorem on the infinitude\nof primes which are $a \\pmod n$.\nTowards the end, we'll also state \\buzzword{Artin reciprocity},\none of the great results of \\buzzword{class field theory},\nand how it generalizes quadratic reciprocity and cubic reciprocity.\n\\end{itemize}\n\n\\section{Algebraic topology}\n\\begin{itemize}\n\\pitch{part:algtop1}\nWhat's the difference between an annulus and disk?\nWell, one of them has a ``hole'' in it,\nbut if we are just given intrinsic topological spaces\nit's hard to make this notion precise.\nThe \\buzzword{fundamental group} $\\pi_1(X)$\nand more general \\buzzword{homotopy group}\nwill make this precise --- we'll find a way to define an abelian group\n$\\pi_1(X)$ for every topological space $X$ which captures the idea\nthere is a hole in the space, by throwing lassos into the space\nand seeing if we can reel them in.\n\nAmazingly, the fundamental group $\\pi_1(X)$ will, under mild conditions,\ntell you about ways to cover $X$ with a so-called\n\\buzzword{covering projection}.\nOne picture is that one can wrap a real line $\\RR$ into a helix shape\nand then project it down into the circle $S^1$.\nThis will turn out to correspond to the fact that $\\pi_1(S^1) = \\ZZ$\nwhich has only one subgroup.\nMore generally the subgroups of $\\pi_1(X)$ will be in\nbijection with ways to cover the space $X$!\n\n\\pitch{part:cats}\nWhat do fields, groups, manifolds, metric spaces, measure spaces,\nmodules, representations, rings, topological spaces, vector spaces,\nall have in common?\nAnswer: they are all ``objects with additional structure'',\nwith maps between them.\n\nThe notion of \\buzzword{category} will appropriately generalize all of them.\nWe'll see that all sorts of constructions and ideas\ncan be abstracted into the framework of a category,\nin which we \\emph{only} think about objects and arrows between them,\nwithout probing too hard into the details of what those objects are.\nThis results in drawing many \\buzzword{commutative diagrams}.\n\nFor example, any way of taking an objection in one category\nand getting another one (for example $\\pi_1$ as above,\nfrom the category of spaces into the category of groups)\nwill probably be a \\buzzword{functor}.\nWe'll unify $G \\times H$, $X \\times Y$, $R \\times S$,\nand anything with the $\\times$ symbol into the notion of a product,\nand then even more generally into a \\buzzword{limit}.\nTowards the end, we talk about \\buzzword{abelian categories}\nand talk about the famous\n\\buzzword{snake lemma}, \\buzzword{five lemma}, and so on.\n\n\\pitch{part:algtop2}\nUsing the language of category theory,\nwe then resume our adventures in algebraic topology,\nin which we define the \\buzzword{homology groups}\nwhich give a different way of noticing holes in a space,\nin a way that is longer to define but easier to compute in practice.\nWe'll then reverse the construction to get so-called\n\\buzzword{cohomology rings} instead,\nwhich give us an even finer invariant for telling spaces apart.\n\\end{itemize}\n\n\\section{Algebraic geometry}\n\\begin{itemize}\n\\pitch{part:ag1}\nWe begin with a classical study of classical \\buzzword{complex varieties}:\nthe study of intersections of polynomial equations over $\\CC$.\nThis will naturally lead us into the geometry of rings,\ngiving ways to draw pictures of ideals,\nand motivating \\buzzword{Hilbert's nullstellensatz}.\nThe \\buzzword{Zariski topology} will show its face,\nand then we'll play with \\buzzword{projective varities}\nand \\buzzword{quasi-projective varieties},\nwith a bonus detour into \\buzzword{Bezout's theorem}.\nAll this prepares us for our journey into schemes.\n\n\\pitch{part:ag2}\nWe now get serious and delve into Grothendiek's definition of\nan \\buzzword{affine scheme}:\na generalization of our classical varieties\nthat lets us start with any ring $A$\nand construct a space $\\Spec A$ on it.\nWe'll equip it with its own Zariski topology\nand then a sheaf of functions on it,\nmaking it into a \\buzzword{locally ringed space};\nwe will find that the sheaf can be understood\neffectively in terms of \\buzzword{localization} on it.\nWe'll find that the language of commutative algebra provides\nelegant generalizations of what's going on geometrically:\nprime ideals correspond to irreducible closed subsets,\nradical ideals correspond to closed subsets,\nmaximal ideals correspond to closed points, and so on.\nWe'll draw lots of pictures of spaces and examples to accompany this.\n\n\\pitch{part:ag3}\nNot yet written! Wait for v2.\n\\end{itemize}\n\n\\section{Set theory}\n\\begin{itemize}\n\\pitch{part:st1}\nWhy is \\buzzword{Russell's paradox} such a big deal\nand how is it resolved?\nWhat is this \\buzzword{Zorn's lemma}\nthat everyone keeps talking about?\nIn this part we'll learn the answers to these questions\nby giving a real description of the \\buzzword{Zermelo-Frankel}\naxioms, and the \\buzzword{axiom of choice},\ndelving into the details of how math is built axiomatically\nat the very bottom foundations.\nWe'll meet the \\buzzword{ordinal numbers} and \\buzzword{cardinal numbers}\nand learn how to do \\buzzword{transfinite induction} with them.\n\n\\pitch{part:st2}\nThe \\buzzword{continuum hypothesis}\nstates that there are no cardinalities\nbetween the size of the natural numbers and the size of the real numbers.\nIt was shown to be \\emph{independent} of the axioms ---\none cannot prove or disprove it.\nHow could a result like that possibly be proved?\nUsing our understanding of the ZF axioms,\nwe'll develop a bit of \\buzzword{model theory}\nand then use \\buzzword{forcing} in order to show\nhow to construct entire models of the universe\nin which the continuum hypothesis is true or false.\n\\end{itemize}\n", "meta": {"hexsha": "852c1a592802eaa43a5ae107bcf55052ea56fc0b", "size": 16715, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "corpus/napkin/tex/frontmatter/salespitch.tex", "max_stars_repo_name": "aDotInTheVoid/ltxmk", "max_stars_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "corpus/napkin/tex/frontmatter/salespitch.tex", "max_issues_repo_name": "aDotInTheVoid/ltxmk", "max_issues_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "corpus/napkin/tex/frontmatter/salespitch.tex", "max_forks_repo_name": "aDotInTheVoid/ltxmk", "max_forks_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.969151671, "max_line_length": 127, "alphanum_fraction": 0.7715225845, "num_tokens": 4272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.41849913981694487}}
{"text": "\\documentclass{article}\n\n\\title{Beck's ``Distributive Laws'' in string}\n\\author{L.Z. Wong}\n\\date\\today\n\n%%% Packages\n\t% Page size and margins\n\t\t\\usepackage[letterpaper, portrait, margin=1in]{geometry}\n\t\t\\usepackage[bottom]{footmisc} % To force footnotes to the bottom\n\n\t%%% Hyperlinks and table of contents\n\t\t% http://tex.stackexchange.com/questions/73862/how-can-i-make-a-clickable-table-of-contents\n\t\t\\usepackage{hyperref}\n\t\t\\hypersetup{\n\t\t\tlinktocpage,\n\t\t    colorlinks = True,\n\t\t    citecolor=black,\n\t\t    filecolor=black,\n\t\t    linkcolor=blue,\n\t\t    urlcolor=blue\n\t\t}\n\n\t\t% For \\cref\n\t\t\\usepackage{cleveref}\n\n\t%%% Figures and captions\n\t\t\\usepackage{caption}\n\t\t\\usepackage{subcaption}\n\n\t%%% Basic math\n\t\t\\usepackage{amsmath,amssymb,amsthm}\n\t\t\\usepackage{mathtools}\n\n\t\t\\numberwithin{equation}{section}\n\n\t%%% Tikz and Tikz-cd\n\t\t\\usepackage{tikz,tikz-cd}\n\t\t\\usetikzlibrary{arrows}\n\t\t% \\usetikzlibrary{external} % To save diagrams in a separate folder\n\t\t% \\tikzexternalize % activate!\n\t\t\\definecolor{vioteal}{RGB}{90,140,220}\n\t\t%\\definecolor{purgray}{RGB}{75,0,215}\n\t\t\\tikzstyle{every picture}=[semithick, scale = 0.7, baseline = (current bounding box.center)]\n\t\t\\tikzset{t/.style= {draw=white, double = teal, ultra thick}} % S\n\t\t\\tikzset{vt/.style= {draw=white, double = vioteal, ultra thick}} % S\n\t\t\\tikzset{s/.style= {draw=white, double = red, ultra thick}} % T\n\t\t\\tikzset{f/.style= {draw=white, double = black, ultra thick}} % Other functors\t\t\n\t\t\\tikzset{s0/.style= {red, semithick}} % S without border\n\t\t\\tikzset{t0/.style= {teal, semithick}} % T without border\n\t\t\\tikzset{f0/.style= {black, semithick}} % other functors without border\n\t\t\\tikzset{ts/.style = {violet, ultra thick} } % TS\n\t\t\\tikzset{s-scope/.style={every path/.style=s}}\t% For scopes. Every path in scope will have style t (above)\n\n\t\t\\tikzset{% for drawing adjunctions in tikz-cd\n\t\t    symbol/.style={%\n\t\t        draw=none,\n\t\t        every to/.append style={%\n\t\t            edge node={node [sloped, allow upside down, auto=false]{$#1$}}}\n\t\t    }\n\t\t}\n\n\t%%% Theorem environments\n\t\t% http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Theorems.html\n\t\t\\newtheorem{theorem}{Theorem}[section]\n\t\t\\newtheorem{lemma}[theorem]{Lemma}\n\t\t\\newtheorem{proposition}[theorem]{Proposition}\n\t\t\\newtheorem{corollary}[theorem]{Corollary}\n\n\t\t\\theoremstyle{definition}\n\t\t\\newtheorem{definition}[theorem]{Definition}\n\n\t\t% \\newenvironment{proof}[1][Proof]{\\begin{trivlist}\n\t\t% \\item[\\hskip \\labelsep {\\bfseries #1}]}{\\end{trivlist}}\n\t\t% \\newenvironment{definition}[1][Definition]{\\begin{trivlist}\n\t\t% \\item[\\hskip \\labelsep {\\bfseries #1}]}{\\end{trivlist}}\n\t\t\\newenvironment{example}[1][Example]{\\begin{trivlist}\n\t\t\\item[\\hskip \\labelsep {\\bfseries #1}]}{\\end{trivlist}}\n\t\t\\newenvironment{remark}[1][Remark]{\\begin{trivlist}\n\t\t\\item[\\hskip \\labelsep {\\bfseries #1}]}{\\end{trivlist}}\n\n\t%%% Categories\n\t\t\\newcommand{\\cat}[1]{\\mathbf{#1}}\n\t\t\\newcommand{\\Set}{\\cat{Set}}\n\t\t\\newcommand{\\Rel}{\\cat{Rel}}\n\t\t\\newcommand{\\Alg}{\\cat{Alg}}\n\t\t\\newcommand{\\Bim}{\\cat{Bim}}\n\t\t\\newcommand{\\Cat}{\\cat{Cat}}\n\t\t\\newcommand{\\Mnd}{\\cat{Mnd}}\n\t\t\\newcommand{\\Dist}{\\cat{Dist}}\n\n\t%%% Variable categories\n\t\t\\newcommand{\\varcat}[1]{\\mathbf{#1}}\n\t\t\\newcommand{\\cA}{\\varcat{A}}\n\t\t\\newcommand{\\cB}{\\varcat{B}}\n\t\t\\newcommand{\\cC}{\\varcat{C}}\n\t\t\n\t\t\\newcommand{\\cX}{\\varcat{X}}\n\t\t\\newcommand{\\cY}{\\varcat{Y}}\n\t\t\\newcommand{\\cZ}{\\varcat{Z}}\n\n\t\t\\newcommand{\\cK}{\\mathcal{K}}\n\n\t\t\\newcommand{\\To}{\\Rightarrow}\n\n\t%%% Tildes\n\t\t\\renewcommand{\\t}[1]{\\tilde{#1}}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n%%% Introductory material\n\n\t\\begin{abstract}\n\t\tThis is a rewrite of Beck's `Distributive Laws' \\cite{beck1969distributive}, making use of string diagrams so that the proofs apply to $2$-categories other than $\\Cat$.\n\t\\end{abstract}\n\n\t\\subsection{Introduction}\n\t\tIn this document, we rewrite portions of Beck's `Distributive Laws' \\cite{beck1969distributive} from a formal point of view, modifying some of the arguments so that they apply to $2$-categories other than $\\Cat$. The structure of the next 3 sections mirrors that of \\cite{beck1969distributive}.\n\n\t\tIn the rest of this section, we review the string diagrammatic calculus, and reformulate some aspects of Street's \\cite{street1972formal} using string diagrams.\n\n\\pagebreak\n\n\\section{Distributive laws, composite and lifted monads}\n\t\\label{main}\n\n\tWe work in a $2$-category $\\cK$. Let $(S,\\eta^S,\\mu^S),(T,\\eta^T,\\mu^T)$ be monads over the same 0-cell $\\cX$. We will denote them using \\underline{S}carlet and \\underline{T}eal strings, resp. The white regions surrounding the strings will stand for $\\cX$.\t \n\n\t\\begin{definition}\n\t\tA \\emph{distributive law of $S$ over $T$} is a 2-cell $\\ell: ST \\Rightarrow TS$\n\t\t\\begin{equation*} % definition\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\node at (-1,2.3) {$S$};\n\t\t\t\t\\node at (1,2.3) {$T$};\n\t\t\t\t\\node at (-1,0) {$\\ell$};\n\t\t\t\t\n\t\t\t\t\\draw [t]\n\t\t\t\t(1,2) \n\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t(-1,-2);\n\n\t\t\t\t\\draw [s] \n\t\t\t\t(-1,2) \n\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t(1,-2);\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{equation*}\n\n\t\tsuch that the following equalities hold:\n\n\t\t\\begin{equation} \\label{eq:dist_units}% unitality\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,1) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-0.5,1) circle (.08);\n\t\t\t\t\t\t\\path (-0.9,1) node {$\\eta^S$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,2) \n\t\t\t\t\t\tto [out = down, in = up]\n\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(1,-0.5) \n\t\t\t\t\t\tto [out = down, in =up ] \n\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\\draw[fill, color=red] (1,-0.5) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad \\qquad \n\t\t\t; \n\t\t\t\\qquad \\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0.5,1) \n\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t(-1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(-1,2) \n\t\t\t\t\t\tto [out = -90, in = 90] \n\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\\draw[fill, color=teal] (0.5,1) circle (.08);\n\t\t\t\t\t\\path (0.95, 1) node {$\\eta^T$};\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad \n\t\t\t= \n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto [out = down, in = up]\n\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(1,2) \n\t\t\t\t\t\tto [out = down, in =up ] \n\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\\draw[fill, color=teal] (-1,-0.5) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\n\t\t\\end{equation}\n\n\t\t\\begin{equation} \\label{eq:SST}% double S\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(-2,2) \n\t\t\t\t\t\t\tto [out=-90, in = 90]\n\t\t\t\t\t\t(1,-4);\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(0,2) \n\t\t\t\t\t\t\tto [out=-90, in=150]\n\t\t\t\t\t\t(1,0) \n\t\t\t\t\t\t\tto [out= 30, in =-90]\n\t\t\t\t\t\t(2,2);\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(1,0) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-2,-4);\n\n\t\t\t\t\t\t\\path (0.9,0.4) node {$\\mu^S$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale = -1]\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-2,2)  \n\t\t\t\t\t\tto [out=-90, in = 90]\n\t\t\t\t\t(1,-4);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(0,2) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(-1.5,-3) \n\t\t\t\t\t\tto [out= 30, in =-90]\n\t\t\t\t\t(2,2);\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(-1.5,-3) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1.5,-4);\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\n\t\t\\begin{equation} \\label{eq:STT} % double T \n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(0,2) \n\t\t\t\t\t\tto [out=-90, in=150]\n\t\t\t\t\t(1,0) \n\t\t\t\t\t\tto [out= 30, in =-90]\n\t\t\t\t\t(2,2);\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,0) \n\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t(-2,-4);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(-2,2) \n\t\t\t\t\t\tto [out=-90, in = 90]\n\t\t\t\t\t(1,-4);\n\n\t\t\t\t\t\\path (1.1,0.4) node {$\\mu^T$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad \n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(0,2) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(-1.5,-3) \n\t\t\t\t\t\tto [out= 30, in =-90]\n\t\t\t\t\t(2,2);\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1.5,-3) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1.5,-4);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(-2,2)  \n\t\t\t\t\t\tto [out=-90, in = 90]\n\t\t\t\t\t(1,-4);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\t\\end{definition}\n\n\tIntuitively, we `braid' $S$ over $T$, in such a way that the expected `topological moves' holds. More precisely, a distributive law can be thought of as a \\emph{local pre-braiding} of $S$ and $T$; `local' indicates it is not necessarily defined for all 1-cells (in our case, it is only defined for $S$ and $T$!), and `pre' indicates it is not necessarily invertible.\n\n\tWe now state the main proposition as a guide to rest of the section. Some new terms in the proposition will be defined in the following subsections where the corresponding equivalences are proved.\n\t\\pagebreak\t\n\t\\begin{proposition}\n\t\tThe following are equivalent:\n\t\t\\begin{enumerate}\n\t\t\t\\item distributive laws $\\ell: ST \\Rightarrow TS$,\n\n\t\t\t\\item multiplications $m: TSTS \\To TS$ making $(TS,\\eta^T \\eta^S, m)$ a monad, such that the 2-cells\n\t\t\t\t\\begin{equation*} S \\xRightarrow{\\eta^T S} TS \\xLeftarrow{T \\eta^S} T \\end{equation*}\n\t\t\t\tare monad morphisms and a middle unitary law holds.\n\n\t\t\t\\item liftings of the monad $T$ to a monad $\\tilde{T}$ over $\\cX^S$,\n\n\t\t\t\\item extensions of the monad $S$ to a monad $\\tilde{S}$ over $\\cX_T$,\n\n\t\t\t\\item certain elements of $\\Mnd\\left(\\Mnd(\\cC) \\right)$.\n\t\t\\end{enumerate}\n\t\\end{proposition}\n\n\tIn \\Cref{comp}, we define some properties satisfied by the composite monad $TS$, and prove $(1\\iff 2)$. \n\n\tIn \\Cref{lift}, we define what it means to have a lift or extension of a monad over the corresponding Eilenberg-Moore or Kleisli objects, and prove $(1 \\iff 3)$. In fact, Beck's paper only mentions the first three points:  (4) is stated in \\cite{cheng2011distributive} without proof, but is equivalent to $(3)$ by duality, as we shall see in \\Cref{lift}\n\n\tIn \\Cref{mndmnd}, we define and show the equivalence between $\\Dist(\\cC)$ and $\\Mnd\\left(\\Mnd(\\cC) \\right)$ in the manner of \\cite{street1972formal}. This equivalence is what we mean by $(1 \\iff 5)$.\n\n\t\\subsection{The composite monad} \\label{comp}\n\t\tLet $S$ and $T$ be monads as above. The composite $TS$ will be denoted by any of the following equivalent diagrams:\n\t\t\\begin{equation} \\label{eq:TS_def}% TS definition\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\n\t\t\t\t\t\\path (0,0) node (TS) {$TS$};\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(TS) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-3);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (T) {$T$};\n\t\t\t\t\t\\path (1,0) node (S) {$S$};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(T) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\n\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (T) {$T$};\n\t\t\t\t\t\\path (1,0) node (S) {$S$};\n\t\t\t\t\t\\path (0,-3) node (TS) {$TS$};\t\n\t\t\t\t\t\\path (0,-2) node (c) {};\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(T) \n\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t(c.center);\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(c.center);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(c.center)\n\t\t\t\t\t\tto\n\t\t\t\t\t(TS);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[yscale=-1]\n\t\t\t\t\t\\path (-1,0) node (T) {$T$};\n\t\t\t\t\t\\path (1,0) node (S) {$S$};\n\t\t\t\t\t\\path (0,-3) node (TS) {$TS$};\t\n\t\t\t\t\t\\path (0,-2) node (c) {};\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(T) \n\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t(c.center);\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(c.center);\t\t\t\t\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(c.center)\n\t\t\t\t\t\tto\n\t\t\t\t\t(TS);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\t\t\n\t\tIt might be helpful to think of the thick purple string as a wire `sleeve' that contains a teal and scarlet wire. Just remember that inside the sleeve, the teal wire is always to the left of the scarlet wire.\n\n\t\tThe units of $S$ and $T$ give rise to 2-cells which we denote in the following (hopefully intuitive) manner:\n\t\t\\begin{equation} \\label{eq:S_T_to_ST}% monad morphisms S, T to TS\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,1) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-0.5);\t\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-0.5) circle (.08);\n\t\t\t\t\t\\node at (-1.75,-0.5) {$T \\eta^S$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (T) {};\n\t\t\t\t\t\\path (0.5,-1.5) node (S) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S.center)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0.5,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(T.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-3) ;\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (0.5,-1.5) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad \\qquad \n\t\t\t;\n\t\t\t\\qquad \\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(-1,1) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-0.5);\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (-1,-0.5) circle (.08);\n\t\t\t\t\t\\node at (-1.75,-0.5) {$\\eta^T S$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,-1.5) node (T) {};\n\t\t\t\t\t\\path (0.5,0) node (S) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S.center)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0.5,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(T.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-3) ;\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (T) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\t\n\t\t\\end{equation}\n\n\t\tA $2$-cell $m:TSTS \\To TS$ may be expressed using various equivalent diagrams, including the following:\n\t\t\\begin{equation} % various m\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-0.5,-1) -- (-0.5,-2) ;\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,-1) -- (1,-2);\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-4) -- (0,-3);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-1) -- (0,-2);\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(1.5,-1) -- (1.5,-2);\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-3) -- (1,-4);\t\t\n\n\t\t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.2]  (-1,-2) rectangle (2,-3);\n\t\t\t\t\t\\node at (0.5,-2.5) {$m$};\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(1,-1) -- (1,-2);\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0.5,-4) -- (0.5,-3);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-1) -- (0,-2);\t\n\n\t\t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.2]  (-0.5,-2) rectangle (1.5,-3);\n\t\t\t\t\t\\node at (0.5,-2.5) {$m$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\n\n\t\t\t\t\t\\node at (0,-2) {$m$};\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t% \\qquad\n\t\t\t% =\n\t\t\t% \\qquad\n\t\t\t% \\begin{aligned}\n\t\t\t% \t\\begin{tikzpicture}\n\t\t\t% \t\t\\draw [ts] \n\t\t\t% \t\t(-0.5,-2) node (v1) {} \n\t\t\t% \t\t\tto [out = -90, in = 150]\n\t\t\t% \t\t(0,-2.5) node (m) {} \n\t\t\t% \t\t\tto [out = 30, in =-90]\n\t\t\t% \t\t(0.5,-2) node (v2) {};\t\t\t\t\t\n\t\t\t% \t\t\\draw [ts]\n\t\t\t% \t\t(0,-3) \n\t\t\t% \t\t\tto\n\t\t\t% \t\t(m.center);\t\n\t\t\t% \t\t\\draw [t]\n\t\t\t% \t\t(-0.75,-1)\n\t\t\t% \t\t\tto [out = -90, in =150]\n\t\t\t% \t\t(v1.center);\n\t\t\t% \t\t\\draw [t]\n\t\t\t% \t\t(0.25,-1)\n\t\t\t% \t\t\tto [out = -90, in =150]\n\t\t\t% \t\t(v2.center);\n\t\t\t% \t\t\\draw [s]\n\t\t\t% \t\t(-0.25,-1)\n\t\t\t% \t\t\tto [out = -90, in =30]\n\t\t\t% \t\t(v1.center);\n\t\t\t% \t\t\\draw [s]\n\t\t\t% \t\t(0.75,-1)\n\t\t\t% \t\t\tto [out = -90, in =30]\n\t\t\t% \t\t(v2.center);\t\t\t\t\t\n\t\t\t% \t\t\\draw [t]\n\t\t\t% \t\t(0,-3)\n\t\t\t% \t\t\tto [out = 210, in =90]\n\t\t\t% \t\t(-0.25,-4);\n\t\t\t% \t\t\\draw [s]\n\t\t\t% \t\t(0,-3)\n\t\t\t% \t\t\tto [out = -30, in =90]\n\t\t\t% \t\t(0.25,-4);\t\n\t\t\t% \t\\end{tikzpicture}\n\t\t\t% \\end{aligned}\n\t\t\t\\qquad = \\qquad \\dots\t\t\t\t\t\t\t\t\t\n\t\t\\end{equation}\n\n\t\t\\begin{definition} % middle unitary law\n\t\t\tWe say that $m:TSTS\\To TS$ satisfies the \\emph{middle unitary law} if\n\t\t\t\\begin{equation} \\label{eq:middle-unit-1}\n\t\t\t \t\\begin{aligned}\n\t\t\t \t\t\\begin{tikzpicture}\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-0.5,-0.5) -- (-0.5,-2) ;\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,-1.5) -- (1,-2);\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(0,-4) -- (0,-3);\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(0,-1.5) -- (0,-2);\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(1.5,-0.5) -- (1.5,-2);\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] (1,-3) -- (1,-4);\t\t\n\n\t\t\t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.2]  (-1,-2) rectangle (2,-3);\n\t\t\t\t\t\t\\node at (0.5,-2.5) {$m$};\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t \\draw[fill, color=teal] (1,-1.5) circle (.08);\n\t\t\t\t\t\t \\draw[fill, color=red] (0,-1.5) circle (.08);\t\n\t\t\t \t\t\\end{tikzpicture}\n\t\t\t \t\\end{aligned}\n\t\t\t \t\\qquad \\qquad = \\qquad \\qquad\n\t\t\t \t\\begin{aligned}\n\t\t\t \t\t\\begin{tikzpicture}\n\t\t\t \t\t\t\\draw [t] (0,0.5) -- (0,-3);\n\t\t\t \t\t\t\\draw [s] (2,0.5) -- (2,-3);\n\t\t\t \t\t\\end{tikzpicture}\t\n\t\t\t \t\\end{aligned}\n\t\t\t \t\\qquad .\n\t\t\t\\end{equation}\n\t\t\tEquivalently, expressed using $\\eta^T S$ and $T \\eta^S$,\n\t\t\t\\begin{equation} \\label{eq:middle-unit-2}\n\t\t\t \t\\begin{aligned}\n\t\t\t \t\t\\begin{tikzpicture}\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(-1,-1) node (v1) {} \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-2) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,-1) node (v2) {};\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(0,-3) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-2);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(v1.center);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(v2.center);\n\n\t\t\t\t\t\t\\draw[fill, color=red, ] (-1,-1) circle (.08);\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (1,-1) circle (.08);\t\n\t\t\t \t\t\\end{tikzpicture}\n\t\t\t \t\\end{aligned}\t \t\n\t\t\t \t\\qquad \\qquad \n\t\t\t \t= \n\t\t\t \t\\qquad \\qquad\n\t\t\t \t\\begin{aligned}\n\t\t\t \t\t\\begin{tikzpicture}\n\t\t\t \t\t\t\\draw[ts]\n\t\t\t \t\t\t(0,0.5) -- (0,-3);\n\t\t\t \t\t\\end{tikzpicture}\n\t\t\t \t\\end{aligned}\t\t\t\t\t \t\n\t\t\t \t\\qquad .\n\t\t\t\\end{equation}\t\t\t\n\t\t\\end{definition}\n\n\t\t\\begin{lemma}[$1 \\longrightarrow 2$]\n\t\t\tA distributive law $\\ell:ST \\To TS$ gives rise to a multiplication $m:TSTS \\To TS$ such that $(TS, \\eta^T \\eta^S, m)$ is a monad,\n\t\t\tthe 2-cells\n\t\t\t\t\\begin{equation*} S \\xRightarrow{\\eta^T S} TS \\xLeftarrow{T \\eta^S} T \\end{equation*}\n\t\t\tare monad morphisms, and the middle unitary law holds. \n\t\t\\end{lemma}\n\t\t\\begin{proof}\n\n\t\tGiven a distributive law $\\ell : ST \\To TS$, define a multiplication $m: TSTS \\To TS$ by\n\t\t\\begin{equation} \\label{eq:m_def} % m for TS\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\n\n\t\t\t\t\t\\node at (0,-2) {$m$};\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t:= \n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-0.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3.5);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\n\t\twith unit  $\\eta^T \\eta^S$\n\t\t\\begin{equation} % unit of TS\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,-0.5) node (TS) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(TS.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-2) ;\t\n\n\t\t\t\t\t\\draw[fill, color=violet] (TS) circle (.08);\n\t\t\t\t\t\\node at (-1.75,-1) {$\\eta^T \\eta^S$};\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(0.5,-0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0.5,-2);\t\n\n\t\t\t\t\t\\draw[fill, color=teal] (-1,-0.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red] (0.5,-0.5) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\\qquad.\n\t\t\\end{equation}\t\t\n\n\t\tAssociativity and unitality of $m$ and $\\eta^T \\eta^S$ follow from the associativity and unitality of of $\\mu^S,\\mu^T, \\eta^S,\\eta^T$:\n\t\t\\begin{equation} % assoc for m\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\begin{scope}[teal, shift={(4,0)}]\n\t\t\t\t\t\t\\path (0,1) node (i1) {};\n\t\t\t\t\t\t\\path (2,1) node (i2) {};\n\t\t\t\t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\path (1,-1) node (m1) {};\n\t\t\t\t\t\t\\path (2,-3) node (m2) {};\n\t\t\t\t\t\n\t\t\t\t\t\t\\path (2,-3.5) node (o1) {};\n\t\t\t\t\t\n\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(i1.center) \n\t\t\t\t\t\t\tto [out=-90, in=150] \n\t\t\t\t\t\t(m1.center)\n\t\t\t\t\t\t\tto [out=30, in=-90] \n\t\t\t\t\t\t(i2.center);\n\t\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(m1.center) \n\t\t\t\t\t\t\tto [out=-90, in=150] \n\t\t\t\t\t\t(m2.center)\n\t\t\t\t\t\t\tto [out=30, in=-90] \n\t\t\t\t\t\t(i3.center);\n\t\t\t\t\t\n\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(m2.center) \n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(o1.center);\n\t\t\t\t\t\\end{scope}\t\n\t\t\t\t\t\t\\begin{scope}[s-scope, shift={(4.9,0)}];\n\t\t\t\t\t\t\\path (0,1) node (i1) {};\n\t\t\t\t\t\t\\path (2,1) node (i2) {};\n\t\t\t\t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\n\t\t\t\t\t\t\\path (1,-1) node (m1) {};\n\t\t\t\t\t\t\\path (2,-3) node (m2) {};\n\t\t\t\t\t\n\t\t\t\t\t\t\\path (2,-3.5) node (o1) {};\n\t\t\t\t\t\n\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(i1.center) \n\t\t\t\t\t\t\tto [out=-90, in=150] \n\t\t\t\t\t\t(m1.center)\n\t\t\t\t\t\t\tto [out=30, in=-90] \n\t\t\t\t\t\t(i2.center);\n\t\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(m1.center) \n\t\t\t\t\t\t\tto [out=-90, in=150] \n\t\t\t\t\t\t(m2.center)\n\t\t\t\t\t\t\tto [out=30, in=-90] \n\t\t\t\t\t\t(i3.center);\n\t\t\t\t\t\n\t\t\t\t\t\t\\path[draw]\n\t\t\t\t\t\t(m2.center) \n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(o1.center);\n\t\t\t\t\t\\end{scope}\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t=\n\t\t\t\\begin{aligned}\n\t\t\t \t\\begin{tikzpicture}\n\t\t\t \t\t\\begin{scope}[teal, shift={(4,0)}]\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1,-1.5) node (m1) {};\n\t\t\t \t\t\t\\path (1.5,-2.5) node (m2) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1.5,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\t\t\t\n\t\t\t \t\t\\begin{scope}[s-scope, shift={(4.9,0)}];\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (4,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2,-2) node (m1) {};\n\t\t\t \t\t\t\\path (2.5,-3) node (m2) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2.5,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\t\t\t \t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t=\n\t\t\t\\begin{aligned}\n\t\t\t \t\\begin{tikzpicture}[xscale=-1]\n\t\t\t \t\t\\begin{scope}[teal, shift={(4.9,0)}];\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (4,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2,-2) node (m1) {};\n\t\t\t \t\t\t\\path (2.5,-3) node (m2) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2.5,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\t\t\t\n\t\t\t \t\t\\begin{scope}[s-scope, shift={(4,0)}]\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1,-1.5) node (m1) {};\n\t\t\t \t\t\t\\path (1.5,-2.5) node (m2) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1.5,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\t\t\t \t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t=\n\t\t\t\\begin{aligned}\n\t\t\t \t\\begin{tikzpicture}[xscale=-1]\n\t\t\t \t\t\\begin{scope}[teal, shift={(4.9,0)}];\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1,-1) node (m1) {};\n\t\t\t \t\t\t\\path (2,-3) node (m2) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\n\t\t\t \t\t\\begin{scope}[s-scope, shift={(4,0)}]\n\t\t\t \t\t\t\\path (0,1) node (i1) {};\n\t\t\t \t\t\t\\path (2,1) node (i2) {};\n\t\t\t \t\t\t\\path (3.5,1) node (i3) {};\t\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (1,-1) node (m1) {};\n\t\t\t \t\t\t\\path (2,-3) node (m2) {};\n\t\t\t\t\t\t\t\t\n\t\t\t \t\t\t\\path (2,-3.5) node (o1) {};\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(i1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m1.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i2.center);\n\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m1.center) \n\t\t\t \t\t\t\tto [out=-90, in=150] \n\t\t\t \t\t\t(m2.center)\n\t\t\t \t\t\t\tto [out=30, in=-90] \n\t\t\t \t\t\t(i3.center);\n\t\t\t\t\t\t\n\t\t\t \t\t\t\\path[draw]\n\t\t\t \t\t\t(m2.center) \n\t\t\t \t\t\t\tto \n\t\t\t \t\t\t(o1.center);\n\t\t\t \t\t\\end{scope}\t\n\t\t\t \t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\t\t\\begin{equation} % unitality\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (0,-1) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (-1,-1) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0.75,-2.25) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (0.75,-2.25) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (-1,-1) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\t\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\t\t\n\t\t\t\t\t\\draw [t] (0,-3) -- (0,0);\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,0) to (1,-3);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0.75,-2.25) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (0.75,-2.25) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=red] (-1,-1) circle (.08);\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (0,-1) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=red] (-1,-1) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\n\t\t\\end{equation}\n\n\t\tThus $(TS, \\eta^T\\eta^S, m)$ is a monad.\n\t\tWe check that $T \\eta^S$ is a monad morphism, leaving the analogous proof for $\\eta^T S$ to the reader:\n\t\t\\begin{equation} \\label{eq:T_to_TS_check} % check mult\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-1);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (1,-1) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3.5);\t\n\t\t\t\t\t\\draw[fill, color=red] (0,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red] (2,-1) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-1.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-1.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0.75,-2.25) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3.5);\t\n\t\t\t\t\t\\draw[fill, color=red] (0.75,-2.25) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red] (2,-1) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-1.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-1.5);\t\t\n\t\t\t\n\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3.5);\t\n\t\t\t\t\t\\draw[fill, color=red] (1,-2.5) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0.5) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-1.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-1.5);\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-2.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-3.5);\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red, ] (0,-2.5) circle (.08);\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\t\t\\begin{equation} % check unit\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-0.5);\t\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-0.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal] (-1,0.5) circle (.08);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0.5) node (S) {};\n\t\t\t\t\t\\path (0.5,-0.5) node (T) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(T.center)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0.5,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(S.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-2) ;\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (T) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal] (S) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad \n\t\t\t=\n\t\t\t\\qquad \n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,-0.5) node (S) {};\n\t\t\t\t\t\\path (0.5,-0.5) node (T) {};\n\n\t\t\t\t\t\\draw[white]\n\t\t\t\t\t(-1,0.5) to (S);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(T.center)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0.5,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(S.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-2) ;\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (T) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal] (S) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,-0.5) node (ST) {};\n\n\t\t\t\t\t\\draw[white]\n\t\t\t\t\t(-1,0.5) to (ST);\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(ST.center) \n\t\t\t\t\t\tto\n\t\t\t\t\t (-1,-2) ;\t\n\n\t\t\t\t\t\\draw[fill, color=violet] (ST) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\t\n\t\t\\end{equation}\t\t\n\n\t\tFinally, we verify that $m$ satisfies the middle unitary law\n\t\t\\begin{equation} % check middle unit law\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (0,-1) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (1,-1) circle (.08);\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-1,0) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.25,-2.25);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0.75,-2.25) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=red] (0.75,-2.25) circle (.08);\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (0.25,-2.25) circle (.08);\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\t\t\n\t\t\t\t\t\\draw [t] (0,-3) -- (0,0);\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] (1,0) to (1,-3);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\t\n\t\t\\end{equation}\n\n\t\t\\end{proof}\n\n\t\t\\begin{lemma}[$2 \\longrightarrow 1$]\n\t\tA multiplication $m: TSTS \\To TS$ satistfying the middle unitary law and such that $T\\eta^S$ and $\\eta^T S$ are monad morphisms gives rise to a distributive law.\n\t\t\\end{lemma}\n\t\t\\begin{proof}\n\t\t\tDefine $\\ell:ST \\To TS$ via\n\t\t\t\\begin{equation} \\label{eq:ell_using_m} % ell def using m\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\node at (-1,0) {$\\ell$};\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(1,-2);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t:=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(0,-4) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(0,0) \n\t\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1.5,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-4);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red] (1.5,-1) circle (.08);\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal] (-0.5,-1) circle (.08);\n\n\t\t\t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.2]  (-1,-1.5) rectangle (2,-3);\n\t\t\t\t\t\t\\node at (1.75,-2.75) {$m$};\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-2.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-1,-1);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (-1,-1) circle (.08);\n\t\t\t\t\t\t\\draw[fill, color=red, ] (1,-1) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad .\n\t\t\t\\end{equation}\n\n\t\tIn light of (\\ref{eq:m_def}), we have drawn additional lines inside $m$ to serve as a reminder of what $m$ ought to \\emph{behave} like.  Doing so makes it easy to believe that this might yield a distributive law. We prove that $\\ell$ is in fact a distributive law, keeping in mind that we have to treat $m$ as a black (or purple) box.\n\n\t\tThe equalities in (\\ref{eq:dist_units}) follow from the unitality of the monad morphisms $\\eta^T S$ and $T \\eta^S$. We illustrate only the proof of the first equality:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,1) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-0.5,1) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(-1,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-1);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (-1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red] (-1,0) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1);\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=violet] (-1,-1) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(1,-3.5) \n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1.5);\t\t\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1.5);\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (1,-1.5) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\t\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,2) \n\t\t\t\t\t\tto [out = down, in = up]\n\t\t\t\t\t(-1,-2);\n\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(1,-0.5) \n\t\t\t\t\t\tto [out = down, in =up ] \n\t\t\t\t\t(1,-2);\t\n\n\t\t\t\t\t\\draw[fill, color=red] (1,-0.5) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\n\t\tBefore proving (\\ref{eq:SST}), we note that the monad morphisms $\\eta^T S$ and $T \\eta^S$ give rise to left and right actions of both $T$ and $S$ on $TS$:\n\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-0.5,-2) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-0.5,-2);\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (-0.5,-2) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t;\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-0.5,-2) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(-0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-0.5,-2);\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (-0.5,-2) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t;\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0.5,-2);\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (0.5,-2) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t;\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0.5,-2);\t\t\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (0.5,-2) circle (.08);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t.\t\t\t\t\t\t\t\t\n\t\t\\end{equation}\n\t\tBut $\\mu^T$ and $\\mu^S$ also induce \\emph{left} $T$ and \\emph{right} $S$ actions on $TS$:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(1,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-3);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t;\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,-3) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-2.5);\t\t\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(-1,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-3);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\n\t\t\\end{equation}\n\n\t\tIn fact, both right $S$ actions are the same, as we show below: (a) follows from the middle unitary law; (b) from the associativity of $m$; (c) is due to $\\eta^T S$ being a monad morphism; (d) is the middle unitary law again.\n\t\t% \\begin{equation*} % proof of the associativity law\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\\draw [t] \n\t\t% \t\t\t(-1,1) \n\t\t% \t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t(0,-2.5) \n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(1,-1);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [t]\n\t\t% \t\t\t(0,-4) \n\t\t% \t\t\t\tto\n\t\t% \t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t% \t\t\t\\draw [s]\n\t\t% \t\t\t(0,1) \n\t\t% \t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t(1,-2.5)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(2,1);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [s] (1,-2.5) -- (1,-4);\t\t\t\t\t\t\n\n\t\t% \t\t\t\\draw[fill, color=teal] (1,-1) circle (.08);\n\n\t\t% \t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.25,-1.5) rectangle (2.25,-3);\t\t\t\t\t\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t\\overset{(a)}{=}\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\t\\path (-1,-0.5)  node (v1) {};\n\t\t% \t\t\t\t\\path (0,-0.5)  node (v2) {};\n\n\t\t% \t\t\t\t\\draw [t] \n\t\t% \t\t\t\t(v1.center) \n\t\t% \t\t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t\t(0,-2.5) \n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(1,0.5);\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(0,-4) \n\t\t% \t\t\t\t\tto\n\t\t% \t\t\t\t(0,-2.5);\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(-1.5,1)\n\t\t% \t\t\t\t\tto [out=-90, in =150]\n\t\t% \t\t\t\t(v1.center)\n\t\t% \t\t\t\t\tto [out=30, in =-90]\n\t\t% \t\t\t\t(0,0.5);\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(-1,0.5)\n\t\t% \t\t\t\t\tto [out=-90, in =150]\n\t\t% \t\t\t\t(v2.center)\n\t\t% \t\t\t\t\tto [out=30, in =-90]\n\t\t% \t\t\t\t(0.5,1);\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(v2.center) \n\t\t% \t\t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t\t(1,-2.5)\n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(2,1);\n\t\t% \t\t\t\t\\draw [s] (1,-2.5) -- (1,-4);\n\n\t\t% \t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.25,-1.5) rectangle (2.25,-3);\t\t\t \t\t\t\t\t\t\n\t\t%  \t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.5,0) rectangle (0.5,-1);\t\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw[fill, color=teal] (1,0.5) circle (.08);\n\t\t% \t\t\t\t\\draw[fill, color=teal] (0,0.5) circle (.08);\n\t\t% \t\t\t\t\\draw[fill, color=red] (-1,0.5) circle (.08);\t\t\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t\\overset{(b)}{=}\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\t\\path (-1,1) node (v1) {};\n\t\t% \t\t\t\t\\path (0,0.5) node (v2) {};\n\t\t% \t\t\t\t\\path (1,-0.5) node (v3) {};\n\t\t% \t\t\t\t\\path (2,-0.5) node (v4) {};\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t] \n\t\t% \t\t\t\t(v1.center)\n\t\t% \t\t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t\t(0,-2.5) \n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(v3.center);\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(0,-4) \n\t\t% \t\t\t\t\tto\n\t\t% \t\t\t\t(0,-2.5);\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(0.5,0.5)\n\t\t% \t\t\t\t\tto [out=-90, in =150]\n\t\t% \t\t\t\t(v3.center)\n\t\t% \t\t\t\t\tto [out=30, in =-90]\n\t\t% \t\t\t\t(2,0.5);\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(1,1)\n\t\t% \t\t\t\t\tto [out=-90, in =150]\n\t\t% \t\t\t\t(v4.center)\n\t\t% \t\t\t\t\tto [out=30, in =-90]\n\t\t% \t\t\t\t(2.5,1);\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(v2.center) \n\t\t% \t\t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t\t(1,-2.5)\n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(v4.center) ;\n\t\t% \t\t\t\t\\draw [s] (1,-2.5) -- (1,-4);\t\t\t\t\t\t\t\n\t\t%  \t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (0.5,0) rectangle (2.5,-1);\t\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.25,-1.5) rectangle (2.25,-3);\t\t\t \n\t\t% \t\t\t\t\\draw[fill, color=teal] (2,0.5) circle (.08);\n\t\t% \t\t\t\t\\draw[fill, color=teal] (0.5,0.5) circle (.08);\n\t\t% \t\t\t\t\\draw[fill, color=red] (0,0.5) circle (.08);\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t\\overset{(c)}{=}\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\t\\path (-1,1) node (v1) {};\n\t\t% \t\t\t\t\\path (0,-0.5) node (v2) {};\n\t\t% \t\t\t\t\\path (1,-0.5) node (v3) {};\n\t\t% \t\t\t\t\\path (2,-0.5) node (v4) {};\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t] \n\t\t% \t\t\t\t(v1.center)\n\t\t% \t\t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t\t(0,-2.5) \n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(v3.center);\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(0,-4) \n\t\t% \t\t\t\t\tto\n\t\t% \t\t\t\t(0,-2.5);\t\t\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(1.5,1)\n\t\t% \t\t\t\t\tto [out=-90, in =150]\n\t\t% \t\t\t\t(v4.center)\n\t\t% \t\t\t\t\tto [out=30, in =-90]\n\t\t% \t\t\t\t(2.5,1);\n\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(v2.center) \n\t\t% \t\t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t\t(1,-2.5)\n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(v4.center) ;\n\t\t% \t\t\t\t\\draw [s] (1,-2.5) -- (1,-4);\t\t\t\t\t\t\n\n\t\t% \t\t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.25,-1.5) rectangle (2.25,-3);\t\t\t \n\t\t% \t\t\t\t\\draw[fill, color=teal] (1,-0.5) circle (.08);\n\t\t% \t\t\t\t\\draw[fill, color=red] (0,-0.5) circle (.08);\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t\\overset{(d)}{=}\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\t\\path (0.5,1) node (v2) {};\n\t\t% \t\t\t\t\\path (2.5,1) node (v4) {};\t\t\t\t\t\n\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [t]\n\t\t% \t\t\t\t(-0.5,-4.5) \n\t\t% \t\t\t\t\tto\n\t\t% \t\t\t\t(-0.5,1);\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t% \t\t\t\t\\draw [s]\n\t\t% \t\t\t\t(v2.center) \n\t\t% \t\t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t\t(1.5,-1)\n\t\t% \t\t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t\t(v4.center) ;\t\t\t\t\n\t\t% \t\t\t\t\\draw [s] (1.5,-1) -- (1.5,-4.5);\t\t\t\t\t\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\t\t\t\t\t\t\t\t\t\t\t\n\t\t% \\end{equation*}\n\t\t\\begin{equation} \\label{eq:right_S}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(2,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(2,-1.5);\n\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-3)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-1.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] (1,-3) -- (1,-4);\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (2,-1.5) circle (.08);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(a)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(2,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(2,-1.5);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-1);\t\t\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-1);\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(0,-2)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-1);\t\t\t\n\t\t\t\t\t\n\n\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-3)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-1.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] (1,-3) -- (1,-4);\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (2,-1.5) circle (.08);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(b)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(2,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(2,-1);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(0,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-1);\t\t\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-1.5);\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t(0,-1) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(1,-2)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,-1);\t\t\t\n\t\t\t\t\t\n\n\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,-1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,-3)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] (0,-3) -- (0,-4);\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (0,-1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-1.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (2,-1) circle (.08);\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(c)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t(1,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-2);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-1.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(1,-2);\n\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,-2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,-3)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,-2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [ts] (0,-3) -- (0,-4);\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (1,-2) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (-1,-2) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(d)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\t\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-3.5)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-1.5);\t\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,0)\n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3.5);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\n\t\t\\end{equation}\n\t\tLikewise, both left $T$ actions are the same. Similar use of the associativity of $m$ and the middle unitary law shows that carrying out the left $S$ then left $T$ actions, or right $T$ then right $S$ actions, both yield $m$:\n\t\t\\begin{equation} \\label{eq:both_action}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(1,-2)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-1);\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,2) -- (1,1);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(2,2) -- (2,0);\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (1,1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (2,0) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(1,-2)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-1);\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(1,1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(2,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(3,1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,2) -- (1,1);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(3,2) -- (3,1);\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (1,1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (3,1) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\t\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,1.5);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(0,-2.5)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0,-1.5);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(1,-2)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-1);\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(1,1) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(2,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(3,1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,2) -- (1,1);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(3,2) -- (3,1);\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (1,1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (3,1) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,-1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(2,0);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(1,-2)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-1);\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-1,2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1,1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,2) -- (1,1);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(2,2) -- (2,0);\t\t\t\n\n\t\t\t\t\t\\draw[fill, color=red, ] (1,1) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (2,0) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\t\t\n\n\t\tWe now prove that $\\ell$ satisfies (\\ref{eq:SST}): (a)\\footnote{To make (a) easier to parse, it might be helpful to trace the path of the two scarlet wires and one teal wire as they enter and exit the purple sleeves in the second diagram. The result should agree with the first diagram.} uses the definition of $\\ell$, followed by the right $S$ action in (\\ref{eq:right_S}); (b) uses (\\ref{eq:both_action}); (c) uses associativity of $m$; (d) uses the middle unitary law; (e) is again the definition of $\\ell$.\n   \t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(5.5,-1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(6,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(6.5,-1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(6,-2.5) -- (6,-3);\t\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(6.5,2.5)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(4.5,-1.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(4.5,-3);\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(5.5,2.5)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(6.5,-1);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4.5,2.5)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(5.5,-1.5);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(a)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0,-1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0.5,-2.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1.5,-1);\n\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(0.5,-3)\n\t\t\t\t\t\tto \n\t\t\t\t\t(0.5,-2.5);\t\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,1);\t\t\t\t\t\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(1,1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(1.5,2);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(0.5,2.5) -- (0.5,2);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1.5,2.5) -- (1.5,2);\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(-0.5,-0.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(0,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(0.5,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-0.5,2.5) -- (-0.5,-0.5);\t\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,0.5) \n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(0.5,-0.5);\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,0.5)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(1.5,-1);\t\t\t\t\t\n\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (-0.5,-0.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (0.5,-0.5) circle (.08);\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (0.5,2) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (1.5,2) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (1.5,-1) circle (.08);\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(b)}{=}\n\t\t\t\\quad\t\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(4.5,-2.5)\n\t\t\t\t\t\tto \n\t\t\t\t\t(4.5,-1.5);\t\t\t\t\t\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(5,1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(5.5,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(6,1.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(5,3) -- (5,1.5);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(6,3) -- (6,1.5);\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(4,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(4.5,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(5.5,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4,3) -- (4,0);\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (4,0) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (5,1.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (6,1.5) circle (.08);\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(c)}{=}\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(5,-2.5)\n\t\t\t\t\t\tto \n\t\t\t\t\t(5,-1.5);\t\t\t\t\t\n\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(4,1.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(4.5,0)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(5,1.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(5,3) -- (5,1.5);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(6,3) -- (6,1);\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(4.5,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(5,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(6,1);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4,3) -- (4,1.5);\n\n\t\t\t\t\t\\draw[fill, color=teal, ] (4,1.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=teal, ] (5,1.5) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (6,1) circle (.08);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(d)}{=}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[ts]\n\t\t\t\t\t(5,-3)\n\t\t\t\t\t\tto \n\t\t\t\t\t(5,-1.5);\t\t\t\t\t\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(4,2.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(4.5,1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(5,2.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4.5,1) -- (4.5,0);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(5.5,2.5) -- (5.5,0);\t\t\t\n\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t(4.5,0) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(5,-1.5)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(5.5,0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal, ] (4.5,0) circle (.08);\n\t\t\t\t\t\\draw[fill, color=red, ] (5.5,0) circle (.08);\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t\\overset{(e)}{=}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(4,2.5) \n\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t(4.5,1)\n\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t(5,2.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4.5,1) -- (4.5,0);\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(5.5,2.5) -- (5.5,0);\t\t\t\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(5.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(4.5,-1.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(4.5,-3);\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(4.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(5.5,-1.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(5.5,-3);\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\n\t\t\t\\quad .\t\t\t\t\t\t\t\t\t\t\n\t\t\\end{equation}\n\n\t\tThe proof that $\\ell$ satisfies (\\ref{eq:STT}) is similar. Thus $\\ell$ is a distributive law.\n\t\t\\end{proof}\t\n\t\t% \\begin{equation} \\label{eq:assoc_m_mu_S} % associativity between m and \\mu^S\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\\draw [t] \n\t\t% \t\t\t(-1,0) \n\t\t% \t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t(0,-1.5);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [s]\n\t\t% \t\t\t(0,-1.5) \n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(1,0);\t\t\t\n\t\t\t\t\t\n\t\t% \t\t\t\\draw[s]\n\t\t% \t\t\t(2,0)\n\t\t% \t\t\t\tto\n\t\t% \t\t\t(2,-1.5);\n\t\t\t\n\t\t% \t\t\t\\draw [ts]\n\t\t% \t\t\t(0,-1.5) \n\t\t% \t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t(1,-3)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(2,-1.5);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [ts] (1,-3) -- (1,-4);\t\t\t\t\n\t\t\t\t\t\n\t\t% \t\t\t\\draw[fill, color=teal, ] (2,-1.5) circle (.08);\t\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t=\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\\draw [t] \n\t\t% \t\t\t(-1,0) \n\t\t% \t\t\t\tto [out = -90, in = 150]\n\t\t% \t\t\t(0,-2.5) \n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(1,-1);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [t]\n\t\t% \t\t\t(0,-4) \n\t\t% \t\t\t\tto\n\t\t% \t\t\t(0,-2.5);\t\t\t\n\t\t\t\n\t\t% \t\t\t\\draw [s]\n\t\t% \t\t\t(0,0) \n\t\t% \t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t(1,-2.5)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(2,0);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [s] (1,-2.5) -- (1,-4);\t\t\t\t\t\t\n\n\t\t% \t\t\t\\draw[fill, color=teal] (1,-1) circle (.08);\n\n\t\t% \t\t\t\\draw[rounded corners, fill = violet, fill opacity = 0.3]  (-1.25,-1.5) rectangle (2.25,-3);\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t=\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\\draw [t]\n\t\t% \t\t\t(-1,-4) \n\t\t% \t\t\t\tto\n\t\t% \t\t\t(-1,0);\t\t\t\n\t\t\t\n\t\t% \t\t\t\\draw [s]\n\t\t% \t\t\t(0,0) \n\t\t% \t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t(1,-1.5)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(2,0);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw [s] (1,-1.5) -- (1,-4);\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\n\t\t% \t\\quad\n\t\t% \t=\n\t\t% \t\\quad\n\t\t% \t\\begin{aligned}\n\t\t% \t\t\\begin{tikzpicture}\n\t\t% \t\t\t\\draw [s]\n\t\t% \t\t\t(0,0) \n\t\t% \t\t\t\tto [out=-90, in =150 ] \n\t\t% \t\t\t(1,-1.5)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(2,0);\t\t\t\t\n\n\t\t\t\t\t\n\t\t% \t\t\t\\draw[s]\n\t\t% \t\t\t(0,-3)\n\t\t% \t\t\t\tto [out = 30, in =-90]\n\t\t% \t\t\t(1,-1.5);\t\n\n\t\t% \t\t\t\\draw[t]\n\t\t% \t\t\t(-1,0)\n\t\t% \t\t\t\tto [out = -90, in =150]\n\t\t% \t\t\t(0,-3);\n\t\t\t\t\t\n\t\t% \t\t\t\\draw[ts]\n\t\t% \t\t\t(0,-3)\n\t\t% \t\t\t\tto\n\t\t% \t\t\t(0,-4);\n\t\t% \t\t\\end{tikzpicture}\n\t\t% \t\\end{aligned}\t\n\t\t% \\end{equation}\n\n\t\t\\begin{lemma}[$1 \\iff 2$]\n\t\t\tThe constructions $(1 \\longrightarrow 2)$ and $(2 \\longrightarrow 1)$ are mutually inverse.\n\t\t\\end{lemma}\n\t\t\\begin{proof}\n\t\t\tStart with a distributive law $\\ell$, define $m$ using (\\ref{eq:m_def}), then define $\\tilde{\\ell}$ using (\\ref{eq:ell_using_m}). The resulting $\\tilde{\\ell}$ is shown below, and reduces to $\\ell$ by unitality of $\\eta^T$ and $\\eta^S$:\n\t\t\t\\begin{equation}\n\t\t\t\t\\tilde{\\ell}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-0.5,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-2.5);\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(0,0) \n\t\t\t\t\t\t\tto [out=-90, in =150 ] \n\t\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1.5,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] (1,-2.5) -- (1,-3.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red] (1.5,-1) circle (.08);\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal] (-0.5,-1) circle (.08);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\node at (0.5,-1.5) {$\\ell$};\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-0.5,-3.5) \n\t\t\t\t\t\t\tto [out = 90, in =-90]\n\t\t\t\t\t\t(1,0);\t\t\t\t\t\t\n\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(-0.5,0) \n\t\t\t\t\t\t\tto [out=-90, in =90 ] \n\t\t\t\t\t\t(1,-3.5);\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad.\n\t\t\t\\end{equation}\n\t\t\tConversely, start with $m$, define $\\ell$ using (\\ref{eq:ell_using_m}), then define $\\tilde{m}$ using (\\ref{eq:m_def}). The resulting $\\tilde{m}$ again reduces to $m$ by repeated application of (\\ref{eq:both_action}):\n\t\t\t\\begin{equation}\n\t\t\t\t\\tilde{m}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1.5,-1.5) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(1,-3) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(1.5,-4) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2,-3);\t\t\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(2,-3) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2.5,-4) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(3,-3);\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(2,-3) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-2.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(1.5,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1.5,-1.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(2.5,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(3,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(3,-3);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1,-3);\n\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(2.5,-4)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-4.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,-4)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1.5,-4.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (1.5,-1.5) circle (.08);\n\t\t\t\t\t\t\\draw[fill, color=red, ] (2.5,-1.5) circle (.08);\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\node at (2,-2) {$m$};\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1.5,-1.5) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1.5,-3.5) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2,-4) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(3,-3);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1,-2.5) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(1.5,-3.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2,-2.5);\t\t\n\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(1.5,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1.5,-1.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(2.5,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(3,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(3,-3);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1,-2.5);\n\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(2,-4)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-4.5);\t\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (1.5,-1.5) circle (.08);\n\t\t\t\t\t\t\\draw[fill, color=red, ] (2.5,-1.5) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red, ] (1,-2.5) circle (.08);\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (3,-3) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\t\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1.5,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2.5,-3.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(3,-2.5);\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(2.5,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-1.5);\n\n\t\t\t\t\t\t\\draw [s]\n\t\t\t\t\t\t(3,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(3,-2.5);\t\t\n\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(2.5,-3.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-4.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red, ] (2.5,-1.5) circle (.08);\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (3,-2.5) circle (.08);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [ts] \n\t\t\t\t\t\t(1.5,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(2.5,-3.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(3.5,-1);\t\t\n\t\t\t\t\t\t\\draw [ts]\n\t\t\t\t\t\t(2.5,-3.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2.5,-4.5);\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\n\t\t\t\t\\quad.\n\t\t\t\\end{equation}\t\t\t\n\t\tThus distributive laws of $S$ over $T$ are in bijective correspondence with multiplications on $TS$.\n\t\t\\end{proof}\n\t\\subsection{Liftings and extensions}\n\t\t\\label{lift}\n\t\tLet $S,T$ be monads on $\\cX$ in a $2$-category $\\cK$. In this section, we assume that $\\cK$ admits the construction of algebras, hence contains EM objects $\\cX^S$ for any monad $(\\cX,Se)$, along with the `free-forgetful' adjunction\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\\phantom{^S}\\cX \\ar[r,bend left,\"F^S\",\"\"{name=A, below}] \n\t\t\t\t\t& \n\t\t\t\t\t\\cX^S \\ar[l,bend left,\"U^S\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\t\\end{tikzcd}\t\t\t\n\t\t\t\\end{aligned}\n\t\t\\end{equation}\n\t\tsuch that $S = U^S F^S$. This composite will be denoted:\n\t\t\\begin{equation} \\label{eq:UF}% UF = S\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\t\n\t\t\t\t\t\\path (0,0) node (S) {$S$};\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(S) \n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-3);\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (U) {$U^S$};\n\t\t\t\t\t\\path (1,0) node (F) {$F^S$};\n\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(F)\n\t\t\t\t\t\tto \n\t\t\t\t\t(1,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(U) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U.south) rectangle (1,-3);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t,\n\t\t\\end{equation}\t\n\t\twhere the red region is $\\cX^S$, and the white regions are $\\cX$. As $S, U^S, F^S$ are each surrounded by different combinations of red and white regions, we can use the same red string to denote all three of them without ambiguity. \n\n\t\tThere is a canonical action $U^S \\varepsilon^S : SU^S \\To U^S$ induced by the counit of the adjunction $F^S \\dashv U^S$:\n\t\t\\begin{equation} \\label{eq:U_action}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\t\\path (0,0) node (F) {};\n\t\t\t\t\t\t\\path (0,-1.5) node {};\t\t\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(U.center) \n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\n\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\t\t\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (0,-3);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t:=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(U.center) \n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\t\tto [out =-90, in =-90]\n\t\t\t\t\t\t(-2,0);\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,0)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(U.center)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\t\tto [out=-90, in =-90]\n\t\t\t\t\t\t(-2,0);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad ,\n\t\t\\end{equation}\t\t\t\n\t\tand the universal property of $\\cX^S$ says that any left $S$-action factors through this. \n\t\tMore precisely, there is a bijection\\footnote{In fact, there is an equivalence of categories. But we don't need the category structure here.}:\n\t\t\\begin{equation}\n\t\t\t\\left\\{\n\t\t\t\\begin{aligned}\n\t\t\t\t\\text{Functors } \\t{G}: \\cY \\to \\cX^S\n\t\t\t\\end{aligned}\n\t\t\t\\right\\}\n\t\t\t\\qquad\n\t\t\t\\cong\n\t\t\t\\qquad\n\t\t\t\\left\\{\n\t\t\t\\begin{aligned}\n\t\t\t\t\\text{Functors } G&: \\cY \\to \\cX \\\\\n\t\t\t\t\\text{with $S$-action } \\sigma&: SG \\To G\n\t\t\t\\end{aligned}\n\t\t\t\\right\\}.\t\n\t\t\\end{equation}\n\t\tThe associated $G$ and $\\t{G}$ satisfy \n\t\t\\begin{equation}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\t& \\phantom{^{S}} \\cX ^S \\ar[d, \"U^S\"]\n\t\t\t\t\\\\\n\t\t\t\t\\cY \\ar[ur,  \"\\tilde{G}\"] \\ar[r, \"G\"'] & \\cX\n\t\t\t\\end{tikzcd}\\qquad,\n\t\t\\end{equation}\t\n\t\tand further, $\\sigma$ factors as:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0.5) node (U) {$G$};\n\t\t\t\t\t\\path (0,-1.5) node {$\\cY$};\n\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t(U)\n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-1.25,-1.75) node {$\\sigma$};\t\n\t\t\t\t\t\\fill[nearly transparent, gray] (U.south) rectangle (1,-3);\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\t\t\t\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,0.5) node (U) {$U^S$};\n\t\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\t\\path (0.5, 0.5) node (G) {$\\tilde{G}$};\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(S)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\t\n\n\t\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t\t(U)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [f]\n\t\t\t\t\t\t(G)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0.5,-3);\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (U.south) rectangle (0.5,-3);\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (G.south) rectangle (2,-3);\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\qquad.\n\t\t\\end{equation}\t\t\n\n\t\t\\begin{definition}\n\t\t\tA \\emph{lift} of $T$ to $\\cX^S$ is a monad $(\\t{T}, \\t{\\eta}^T, \\t{\\mu}^T)$ on $\\cX^S$ such that\n\t\t\t\\begin{align}\n\t\t\t\tU^S \\t{T} &= TU^S, & U^S \\t{\\eta}^T &= \\eta^T U^S, & U^S \\t{\\mu}^T &= \\mu^T U^S.\n\t\t\t\\end{align}\n\t\t\\end{definition}\n\n\t\tThe equation $U^S \\t{T} = TU^S$ can be expressed diagrammatically by saying that we have an \\emph{invertible} $2$-cell\n\t\t\\begin{equation} \\label{eq:TUUT}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-0.5,0) node (U) {$U^S$};\n\t\t\t\t\t\\path (1,0) node (tT) {$\\tilde{T}$};\n\t\t\t\t\t\\path (2,0) node (x) {$\\phantom{U^S}$};\n\t\t\t\t\t\\path (-0.5,-3.75) node {$T$};\n\n\t\t\t\t\t\\draw [t] \n\t\t\t\t\t(tT)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-0.5,-3.5);\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\t\t\\draw [s]\n\t\t\t\t\t(U)\n\t\t\t\t\t\tto [out=-90, in =90 ] \n\t\t\t\t\t(1,-3.5);\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U.south)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(1,-3.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(2,-3.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(x.south);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t,\n\t\t\t\\qquad\n\t\t\t\\text{ with inverse }\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-0.5,0) node (U) {$T$};\n\t\t\t\t\t\\path (1,0) node (tT) {$U^S$};\n\t\t\t\t\t\\path (2,0) node (x) {$\\phantom{U^S}$};\n\t\t\t\t\t\\path (-0.5,-3.75) node {};\n\t\t\t\t\t\\path (1,-3.75) node {$\\tilde{T}$};\n\n\t\t\t\t\t\\draw [t]\n\t\t\t\t\t(U)\n\t\t\t\t\t\tto [out=-90, in =90 ] \n\t\t\t\t\t(1,-3.5);\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(tT)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-0.5,-3.5);\t\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (tT.south)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(-0.5,-3.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(2,-3.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(x.south);\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad .\t\t\t\n\t\t\\end{equation}\n\t\tAgain, we will use the same string for $T$ and $\\t{T}$, as the context will make it clear which we are referring to.\n\n\t\t\\begin{lemma}[$1 \\longrightarrow 3$]\n\t\t\tA distributive law $\\ell:ST \\To TS$ gives rise to a lift $\\t{T}$ of $T$ to $\\cX^S$.\n\t\t\\end{lemma}\n\t\t\\begin{proof}\t\t\n\n\n\t\t\tWe want an endofunctor $\\t{T}: \\cX^S \\to \\cX^S$ such that:\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\t& \\phantom{^{S}} \\cX ^S \\ar[d, \"U^S\"]\n\t\t\t\t\t\\\\\n\t\t\t\t\t\\cX^S \\ar[ur,  dashed, \"\\tilde{T}\"] \\ar[r, \"TU^S\"'] & \\cX\n\t\t\t\t\\end{tikzcd}\n\t\t\t\\end{equation}\t\t\t\t\n\t\t\tBy the universal property of $\\cX^S$, it suffices to produce a left $S$-action on $TU^S$. \t\t\n\t\t\tCombining the canonical action on $U^S$ with the distributive law, we get an action on $TU^S$:\n\t\t\t\\begin{equation} \\label{eq:dist_action}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,0.5) node (U) {};\n\t\t\t\t\t\t\\path (0,-1) node (F) {$\\cX^S$};\n\t\t\t\t\t\t\\path (-1,1) node {$U^S$};\n\t\t\t\t\t\t\\path (-1.5,1) node {$T \\phantom{^S}$};\n\t\t\t\t\t\t\\path (-3,1) node {$S \\phantom{^S}$};\t\t\t\t\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-1.5,0.5) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-2,-1.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-2,-3);\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t\t(U.center) \n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (1,-3);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{equation}\n\t\t\tThis gives an endofunctor $\\t{T}$ satisfying (\\ref{eq:TUUT}). \t\t\t\n\t\t\tWe can then define $\\t{\\eta}^T$ and $\\t{\\mu}^T$ by `pulling' $\\eta^T$ and $\\mu^T$ under $U^S$, and it is easy to check that this gives a monad $(\\t{T},\\t{\\eta}^T,\\t{\\mu}^T)$ that lifts $(T,\\eta^T,\\mu^T)$.\n\t\t\\end{proof}\n\n\t\tNote that in the preceeding construction, the universal property also tells us that\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\\path (0,0) node (F) {};\n\t\t\t\t\t\\path  node {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-1.5,-3);\n\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\n\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (0,-3);\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\\path (1,0) node (F) {};\n\t\t\t\t\t\\path  node {};\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(0,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (1,-3);\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\t\n\t\t\\end{equation}\n\t\tWe may combine this with (\\ref{eq:TUUT}) and the invertibility of (\\ref{eq:U_action}) to express this as:\n\t\t\\begin{equation} \\label{eq:univ_TU}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\\path (0,0) node (F) {};\n\t\t\t\t\t\\path  node {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-1.5,-3);\n\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\n\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (0,-3);\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\\path (0.5,0) node (F) {};\n\t\t\t\t\t\\path  node {};\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-0.5,-2)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1.5,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\n\n\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (0,-3);\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-0.5,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-0.5,-1.5) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-2,-3);\t\n\n\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\tto [out =-90, in =-90]\n\t\t\t\t\t(-2,0);\t\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1.5,-3);\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(-1.5,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(0,0)\n\t\t\t\t\t\tto\n\t\t\t\t\t(U.center)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\tto [out=-90, in =-90]\n\t\t\t\t\t(-2,0);\t\t\t\t\t\n\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad.\t\t\t\t\n\t\t\\end{equation}\n\n\n\t\t\\begin{lemma}[$3 \\longrightarrow 1$]\n\t\t\tA lift $\\t{T}$ of $T$ to $\\cX^S$ gives a distributive law $\\ell:ST \\To TS$.\n\t\t\\end{lemma}\n\t\t\\begin{proof}\t\t\t\n\t\t\tDefine $\\ell:ST \\To TS$ via:\n\t\t\t\\begin{equation} \\label{eq:dist_from_lift}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\node at (-1,0) {};\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-1,-2.5);\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-1,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(1,-2.5);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t:=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(2.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(1,-2.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(2,-2.5);\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out= 90, in =-90]\n\t\t\t\t\t\t(-0.5,2);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\\end{equation}\n\t\t\tIt is easy to check that this satisfies the requirements of a distributive law. \n\t\t\\end{proof}\n\n\t\tObserve that in the preceding proof, we get a distributive law of $S = U^S F^S$ over $T$ by using only $2$-cells between $T,\\t{T}$ and $U^S$. Thanks to the unit of $S$, we did not need $F^S$ to `interact' directly with $T$ or $\\t{T}$! \n\n\t\tFurther, the proof did not use the universal property of $\\cX^S$, merely that the adjunction $F^S \\dashv U^S$ gives rise to $S$. We could have replaced $F^S, U^S$ with any adjunction that gives $S$. In particular, this would work if the red region were just the Kleisli category $\\cX_S$, interpreted as the subcategory of $\\cX^S$ consisting of free $S$-algebras. In that case, the lemma says that in order to get a distributive law of $S$ over $T$, it suffices to define a lift of $T$ over just the \\emph{free} $S$-algebras! This is what Beck does in \\cite{beck1969distributive}.\n\n\t\t\\begin{lemma}[$1 \\iff 3$]\n\t\t\tThe constructions $(1 \\longrightarrow 3)$ and $(3 \\longrightarrow 1)$ are mutually inverse.\n\t\t\\end{lemma} \n\t\t\\begin{proof}\n\t\t\tStarting with a distributive law, we obtain a lift $\\t{T}$ that induces another distributive law. By (\\ref{eq:univ_TU}), the new distributive law is equivalent to the original one:\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(2.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(1,-2.5);\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(2,-2.5);\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out= 90, in =-90]\n\t\t\t\t\t\t(-0.5,2);\t\t\t\t\t\t\n\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t% \\draw [t]\n\t\t\t\t\t\t% (1.5,2) \n\t\t\t\t\t\t% \tto [out = -90, in = 90]\n\t\t\t\t\t\t% (0,-2.5);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t% \\draw [s] \n\t\t\t\t\t\t% (-0.5,2) \n\t\t\t\t\t\t% \tto [out = -90, in = 90 ] \n\t\t\t\t\t\t% (2,-1);\t\t\n\n\t\t\t\t\t\t% \\draw [s0] \n\t\t\t\t\t\t% (2,-2.5) to\n\t\t\t\t\t\t% (2,0.5)\n\t\t\t\t\t\t% \tto [out = 90, in = 180]\n\t\t\t\t\t\t% (2.5,1.5)\n\t\t\t\t\t\t% \tto [out = 0, in = 90]\n\t\t\t\t\t\t% (3,0.5)\n\t\t\t\t\t\t% \tto [out=-90, in =90]\n\t\t\t\t\t\t% (3,-2.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t% \\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t% (2,-2.5) \n\t\t\t\t\t\t% \tto\n\t\t\t\t\t\t% (2,0.5)\n\t\t\t\t\t\t% \tto [out = 90, in = 180]\n\t\t\t\t\t\t% (2.5,1.5)\n\t\t\t\t\t\t% \tto [out = 0, in = 90]\n\t\t\t\t\t\t% (3,0.5)\n\t\t\t\t\t\t% \tto [out=-90, in =90]\n\t\t\t\t\t\t% (3,-2.5);\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(0,-2.5);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(2,-1);\t\t\n\n\t\t\t\t\t\t\\draw [s0] \n\t\t\t\t\t\t(2,-2.5) to\n\t\t\t\t\t\t(2,1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, red] (2,1) circle [radius=0.08];\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(-0.5,-2.5);\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(1.5,-2.5);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad.\n\t\t\t\\end{equation} \n\t\t\tConversely, given a lift $\\t{T}$, we may produce a distributive law via (\\ref{eq:dist_from_lift}), which in turn yields another lift $\\t{\\t{T}}$. By definition of being lifts, $U^S \\t{T} = T U^S = U^S  \\t{\\t{T}}$. So to show $\\t{T} = \\t{\\t{T}}$, it suffices to show that the $S$-actions they induce on $T U^S$ are the same. But this is easy to see: \n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(2.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(1,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1,-3.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-1)\n\t\t\t\t\t\t\tto [out = -90, in =180]\n\t\t\t\t\t\t(3.5,-1.5)\n\t\t\t\t\t\t\tto [out=0, in =-90]\n\t\t\t\t\t\t(4,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(4,2);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(2,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-3.5);\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(0.5,2) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,1.5)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(3,-1)\n\t\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t\t(3.5,-1.5)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(4,-1)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(4,2)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(5,2)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(5,-3.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-3.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out= 90, in =-90]\n\t\t\t\t\t\t(-0.5,2);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-5,2) \n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-4,0)\n\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t(-5.5,-2.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-5.5,-3.5);\t\t\t\t\t\n\n\t\t\t\t\t\\path (-4.5,2) node (U) {};\n\t\t\t\t\t\n\t\t\t\t\t\\draw [s] \n\t\t\t\t\t(U.center) \n\t\t\t\t\t\tto \n\t\t\t\t\t(-4.5,0.5)\n\t\t\t\t\t\tto [out =-90, in =-90]\n\t\t\t\t\t(-6,2);\t\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-7,2)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-4.5,-2.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4.5,-3.5);\t\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-7,2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(-4.5,-2.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4.5,-3.5)\n\t\t\t\t\t\tto\t\t\t\t\t\n\t\t\t\t\t(-2,-3.5)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-2,2)\n\t\t\t\t\t\tto\n\t\t\t\t\t(U.center)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4.5,0.5)\n\t\t\t\t\t\tto [out=-90, in =-90]\n\t\t\t\t\t(-6,2);\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t.\t\t\t\t\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tOn the LHS we have the $S$-action induced by $\\t{\\t{T}}$ (via (\\ref{eq:dist_action})), while on the RHS we have the original action.\n\t\t\\end{proof}\n\n\t\t\\begin{remark} (Extensions to the Kleisli category)\n\t\tSince a Kleisli object in $\\cK$ is simply an EM object for the corresponding monad in $\\cK^{op}$, all the above results hold for Kleisli objects as well if $\\cK^{op}$ admits the construction of algebras.\n\t\t\\end{remark}\n\n\t\\subsection{Monads over monads}\n\t\t\\label{mndmnd}\n\t\tFinally, we sketch a proof that distributive laws are precisely monads in the category of monads in $\\cK$. In fact, there is an equivalence of categories\n\t\t\\begin{equation}\n\t\t\t\\cat{Dist}(\\cK) \\cong \\cat{Mnd}(\\cat{Mnd}(\\cK)).\n\t\t\\end{equation}\n\n\t\t\\cite{hyland2006combining}\n\n\\section{Algebras over the composite monad}\n\t\\label{alg}\n\n\\section{Distributive laws and adjoint functors}\n\t\\label{dist_adjoint}\n\n\\section{Misc.\\ diagrams}\n\t\\[\n\t\t\\begin{tikzpicture}[scale=2]\n\t\t\\node (A) at (-2,0) {$\\cY$};\n\t\t\\node (B) at (1,0) {$\\cX$};\n\t\t\\node (C) at (1,2) {$\\cX^S$};\n\t\t\\node at (-0.5,0) {$\\quad \\Downarrow \\phi$};\n\t\t\\node at (-0.5,1) {\\rotatebox{40}{$ \\quad \\;\\;\\; \\Downarrow \\tilde{\\phi}$}};\n\n\t\t\\path[->,font=\\scriptsize]\n\t\t(A) edge [bend left = 10] node[above] {$G$} (B)\n\t\tedge [bend right=10] node[below] {$G'$} (B);\t\n\n\t\t\\path[->,font=\\scriptsize]\n\t\t(A) edge [bend left=10] node[above] {\\rotatebox{40}{$\\t{G}$}} (C)\n\t\tedge [bend right=10] node[right] {\\rotatebox{40}{$\\t{G}'$}} (C);\t\n\n\t\t\\path[->,font=\\scriptsize] \n\t\t(C) edge node[right]{$U^S$} (B);\n\t\t\\end{tikzpicture}\n\t\\]\n\n$$\n\\begin{tikzpicture}[scale=1.2]\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1.5,2.5) \n\t\t\t\t\t\t\tto [out = -90, in = 90]\n\t\t\t\t\t\t(2.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(1,-2.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(0.5,2.5) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,2)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t(-0.5,2.5) \n\t\t\t\t\t\t\tto [out = -90, in = 90 ] \n\t\t\t\t\t\t(2,-2.5);\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(0.5,2.5) \n\t\t\t\t\t\t\tto [out = -90, in = -110 ] \n\t\t\t\t\t\t(2,0.5)\n\t\t\t\t\t\t\tto [out = 70, in = 180]\n\t\t\t\t\t\t(2.5,2)\n\t\t\t\t\t\t\tto [out = 0, in = 90]\n\t\t\t\t\t\t(3,0.5)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(3,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(2,-2.5) \n\t\t\t\t\t\t\tto [out= 90, in =-90]\n\t\t\t\t\t\t(-0.5,2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\path(-0.5,3) node {$U^S$};\n\t\t\t\t\t\t\\path(0.5,3) node {$F^S$};\n\t\t\t\t\t\t\\path(1.5,3) node {$T$};\n\t\t\t\t\t\t\\path(2.2,-0.35) node {$\\tilde{T}$};\n\t\t\t\t\t\t\\path(1.3,-1.35) node {$\\chi$};\n\t\t\t\t\t\t\\path(2.45,1.2) node {$\\chi^{-1}$};\n\\end{tikzpicture}\n$$\t\n\n\t\\[\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale= 1.5]\n\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\\path (1,0) node (F) {};\n\t\t\t\t\\path (-1,0.5) node {$U^{TS}$};\n\t\t\t\t\\path (-2.5,0.5) node {$TS$};\n\t\t\t\t\\path (0,-1.5) node {$\\cX^{TS}$};\n\t\t\t\t\\path (-1.25,-1.75) node {$\\varepsilon$};\n\t\t\t\t\n\t\t\t\t\\fill[nearly transparent, violet] (U) rectangle (1,-3);\t\t\t\t\t\n\n\t\t\t\t\\draw [ts] \n\t\t\t\t(U.center) \n\t\t\t\t\tto \n\t\t\t\t(-1,-3);\t\n\n\t\t\t\t\\draw[ts]\n\t\t\t\t(-2.5,0)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-2);\t\t\t\t\n\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t=\n\t\t\\quad\t\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale= 1.5]\n\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\\path (-2,0.5) node {$S$};\n\t\t\t\t\\path (-3,0.5) node {$T$};\n\t\t\t\t\\path (-1,0.5) node {$U^{TS}$};\n\t\t\t\t\\path (-3.5,-1) node {$T \\eta^S$};\n\t\t\t\t\\path (-1.5,-1) node {$\\eta^T S$};\t\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\\fill[nearly transparent, violet] (U) rectangle (0,-3);\t\t\n\n\t\t\t\t\\draw [ts] \n\t\t\t\t(U.center) \n\t\t\t\t\tto \n\t\t\t\t(-1,-3);\t\n\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(-2,-1) -- (-2,0);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-3,-1) -- (-3,0);\t\t\t\t\n\n\t\t\t\t\\draw[ts]\n\t\t\t\t(-2,-1)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\\draw[ts]\n\t\t\t\t(-3,-1)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-3);\t\n\t\t\t\t\\draw[fill, color=red, ] (-3,-1) circle (.08);\t\t\t\t\n\t\t\t\t\\draw[fill, color=teal, ] (-2,-1) circle (.08);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t=\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale= 1.5]\n\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\\path (0,0) node (F) {};\n\t\t\t\t\\path (-2,0.5) node {$S$};\n\t\t\t\t\\path (-3,0.5) node {$T$};\n\t\t\t\t\\path (-1,0.5) node {$U^{TS}$};\t\t\t\t\n\t\t\t\t\\path (-0.75,-2.75) node {$\\tau$};\n\t\t\t\t\\path (-0.75,-1.5) node {$\\sigma$};\n\t\t\t\t\n\t\t\t\n\n\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(-2,0)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-1.5);\t\n\n\t\t\t\t\\draw[t]\n\t\t\t\t(-3,0)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-3);\t\t\n\n\t\t\t\t\\draw [ts] \n\t\t\t\t(U.center) \n\t\t\t\t\tto \n\t\t\t\t(-1,-3);\t\n\t\t\t\t\\fill[nearly transparent, violet] (U) rectangle (0,-3);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\\]\t\n\n\t\\[\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale=1.5]\n\t\t\t\t\\path (-1,0) node (U) {};\t\t\t\n\n\t\t\n\t\t\t\t\\draw[t]\n\t\t\t\t(-2,0)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-1.5);\t\n\n\t\t\t\t\\draw[s]\n\t\t\t\t(-3,0)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-3);\t\t\n\n\t\t\t\t\\draw [ts] \n\t\t\t\t(U.center) \n\t\t\t\t\tto \n\t\t\t\t(-1,-3);\t\n\t\t\t\t\\fill[nearly transparent, violet] (U) rectangle (0,-3);\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t=\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale=1.5]\n\t\t\t\t\\path (-1,0) node (U) {};\t\t\t\t\n\n\t\t\t\t\\draw[t]\n\t\t\t\t(-2,-1.5) \n\t\t\t\t\tto [out= 90, in = -90] \n\t\t\t\t(-1.5,0);\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(-1,-2) \n\t\t\t\t\tto [out= 90, in = -90]\n\t\t\t\t(-2.5,0);\n\n\t\t\t\t\\draw[t]\n\t\t\t\t(-2,-1.5)\n\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t(-1,-3);\t\n\n\t\t\t\t\\draw [ts] \n\t\t\t\t(U.center) \n\t\t\t\t\tto \n\t\t\t\t(-1,-3);\t\t\t\n\t\t\t\t\\fill[nearly transparent, violet] (U) rectangle (0,-3);\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\t\t\n\t\\]\n\n\t\\[\n\t\t\\begin{tikzcd}\n\t\t\t\t\t\t&\t(\\cX^S)^{\\t{T}} \\ar[d, \"U^{\\t{T}}\"] \\ar[dr, dashed, \"\\Phi\"]\t&\n\t\t\t\\\\\n\t\t\t\\cX^{TS} \\ar[ur, dashed, \"\\Phi^{-1}\"] \\ar[r, dashed, \"\\tilde{U}^{TS}\"] \\ar[dr, \"U^{TS}\"'] \t&\t\\cX^S  \\ar[d, \"U^S\"] \t& \t\t\\cX^{TS} \\ar[dl, \"U^{TS}\"]\n\t\t\t\\\\\n\t\t\t\t\t\t&\t\\cX \t\t\t&\n\t\t\\end{tikzcd}\n\t\\]\t\n\n\t\\[\n\t\t\\begin{tikzpicture}[scale = 1.5]\n\t\t\t\\path (-1,0) node {$U^S$};\n\t\t\t\\path (0,0) node {$U^{\\tilde{T}}$};\n\t\t\t\\path (-2,0) node {$S$};\n\t\t\t\\path (-2.5,0) node {${{T}}$};\t\t\t\n\t\t\t\\path (-0.5,-3) node {${\\tilde{T}}$};\t\n\t\t\t\\path (0.75,-1) node {$(\\cX^{S})^{\\tilde{T}}$};\t\n\t\t\t\\path (-0.5,-1) node {${\\cX^S}$};\t\n\n\n\t\t\t\\draw[t]\n\t\t\t(-2.5,-0.5)\n\t\t\t\tto [out=-90, in =90]\n\t\t\t(-2.5,-1)\n\t\t\t\tto [out = -90, in =90]\n\t\t\t(0,-3.5);\t\t\n\t\t\t\\draw [t0] \n\t\t\t(0,-0.5) \n\t\t\t\tto \n\t\t\t(0,-3.5);\t\t\t\t\n\n\t\t\t\\draw[s]\n\t\t\t(-2,-0.5)\n\t\t\t\tto [out = -90, in =90]\n\t\t\t(-1,-2)\n\t\t\t\tto\n\t\t\t(-1,-3.5);\t\t\n\t\t\t\\draw[s0]\n\t\t\t(-1,-0.5)\n\t\t\t\tto\n\t\t\t(-1,-3);\t\t\t\n\n\t\t\t\\fill[very nearly transparent, cyan] (0,-0.5) rectangle (1.5,-3.5);\t\t\t\t\t\n\t\t\t\\fill[very nearly transparent, magenta] (-1,-0.5) rectangle (1.5,-3.5);\t\t\t\t\t\t\n\t\t\\end{tikzpicture}\n\t\\]\t\n\n\t\\[\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\t\t&\t\\cX^{TS} \\ar[dr, \"\\hat{U}^{TS}\"] \\ar[dl, shift left, \"U^{\\t{T}}\"]\t&\n\t\t\t\t\\\\\n\t\t\t\t\\cX^S \\ar[ur, shift left, \"F^{\\t{T}}\"] \\ar[dr, shift left, \"U^{S}\"] \t&\t\t& \t\t\\cX^T \\ar[dl, shift left, \"U^T\"]\n\t\t\t\t\\\\\n\t\t\t\t\t\t\t&\t\\cX \\ar[ul, shift left, \"F^S\"]\t\\ar[ur, shift left, \"F^T\"]\t&\n\t\t\t\\end{tikzcd}\n\t\t\\end{aligned}\n\t\t%\\qquad\n\t\t%\\onslide<2->{\t\t\n\t\t% \\begin{aligned}\n\t\t% \t\\begin{tikzpicture}[scale=2.5, font = \\scriptsize]\n\t\t% \t\t\\draw[t] \n\t\t% \t\t\t(-0.5,3) -- (1,1.5) \n\t\t% \t\t\t\tto [out=-45, in =45]\n\t\t% \t\t\t(1,1) -- (-2,-2);\n\t\t% \t\t\\draw[t] \n\t\t% \t\t\t(-1.5,3) -- (0,1.5) \n\t\t% \t\t\t\tto [out=-45,in=45]\n\t\t% \t\t\t(0,1) -- (-3,-2);\n\t\t%\t\t\n\t\t% \t\t\\draw [s]\n\t\t% \t\t\t(-3,3) -- (-1,1) \n\t\t% \t\t\t\tto [out=-45, in =-135]\n\t\t% \t\t\t(-0.5,1) -- (0.5,2) \n\t\t% \t\t\t\tto [out=45, in =135]\n\t\t% \t\t\t(1.5,2) \n\t\t% \t\t\t\tto [out=-45, in =45]\n\t\t% \t\t\t(1.5,1) -- (0.5,0) \n\t\t% \t\t\t\tto [out=-135, in =135]\n\t\t% \t\t\t(0.5,-0.5) -- (2,-2);\n\t\t% \t\t\\draw[s] (-4,3) -- (1,-2);\n\t\t%\n\t\t% \t\t\\fill[nearly transparent, teal]\n\t\t% \t\t\t(-0.5,3) -- (1,1.5) \n\t\t% \t\t\t\tto [out=-45, in =45]\n\t\t% \t\t\t(1,1) -- (-2,-2)\n\t\t% \t\t\t\tto\n\t\t% \t\t\t(-3,-2) -- (0,1)\n\t\t% \t\t\t\tto [out=45, in =-45]\n\t\t% \t\t\t(0,1.5) -- (-1.5,3);\n\t\t%\n\t\t% \t\t\\fill[nearly transparent, red]\n\t\t% \t\t\t(-3,3) -- (-1,1) \n\t\t% \t\t\t\tto [out=-45, in =-135]\n\t\t% \t\t\t(-0.5,1) -- (0.5,2) \n\t\t% \t\t\t\tto [out=45, in =135]\n\t\t% \t\t\t(1.5,2) \n\t\t% \t\t\t\tto [out=-45, in =45]\n\t\t% \t\t\t(1.5,1) -- (0.5,0) \n\t\t% \t\t\t\tto [out=-135, in =135]\n\t\t% \t\t\t(0.5,-0.5) -- (2,-2)\n\t\t% \t\t\t\t-- (1,-2) --  (-4,3);\n\t\t%\n\t\t% \t\t\\path (-4,3.5) node {$U^S$};\n\t\t% \t\t\\path (-3,3.5) node {$F^S$};\t\n\t\t% \t\t\\path (-1.5,3.5) node {$U^T$};\n\t\t% \t\t\\path (-0.5,3.5) node {$F^T$};\t\n\t\t% \t\t\\path (0.1,1.85) node {$U'$};\t\t\n\t\t% \t\t\\path (-0.7,0.5) node {$U^{\\tilde{T}}$};\t\n\t\t% \t\t\\path (0,-0.25) node {$F^{\\tilde{T}}$};\t\t\t\t\t\n\t\t% \t\\end{tikzpicture}\n\t\t% \\end{aligned}\n\t\t%}\n\t\\]\t\n\t\\[\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}[scale=1.5]\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(0,3) -- (1,2) \n\t\t\t\t\t\tto [out=-45, in =45]\n\t\t\t\t\t(1,-0.5) -- (-0.5,-2);\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(-1.5,3) -- (0,1.5) \n\t\t\t\t\t\tto [out=-45,in=45]\n\t\t\t\t\t(0,0) -- (-2,-2);\n\t\t\t\t\n\t\t\t\t\\draw [s]\n\t\t\t\t\t(-3,3) -- (-1,1) \n\t\t\t\t\t\tto [out=-45, in =-135]\n\t\t\t\t\t(-0.5,1) -- (1.5,3) \n\t\t\t\t\t\tto [out=45, in =90]\n\t\t\t\t\t(2,2.9001) \n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,1.5) -- (2,1.5) \n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,-2) -- (2,-2);\n\t\t\t\t\\draw[s] (-4.5,3) -- (0.5,-2);\n\n\t\t\t\t\\fill[very nearly transparent, cyan]\n\t\t\t\t\t(0,3) -- (1,2) \n\t\t\t\t\t\tto [out=-45, in =45]\n\t\t\t\t\t(1,-0.5) -- (-0.5,-2)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-2,-2) -- (0,0)\n\t\t\t\t\t\tto [out=45, in =-45]\n\t\t\t\t\t(0,1.5) -- (-1.5,3);\n\n\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-3,3) -- (-1,1) \n\t\t\t\t\t\tto [out=-45, in =-135]\n\t\t\t\t\t(-0.5,1) -- (1.5,3) \n\t\t\t\t\t\tto [out=45, in =90]\n\t\t\t\t\t(2,2.9001) \n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,1.5) -- (2,1.5) \n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,-2) -- (2,-2)\n\t\t\t\t\t\t-- (0.5,-2) --  (-4.5,3);\n\n\t\t\t\t\\path (-4.5,3.2336) node {$U^S$};\n\t\t\t\t\\path (-3,3.2336) node {$F^S$};\t\t\t\t\t\t\n\t\t\t\t\\path (-1.5,3.2336) node {$U^T$};\n\t\t\t\t\\path (0,3.2336) node {$F^T$};\t\t\t\t\t\n\t\t\t\t\\path (0.6333,1.75) node {$\\hat{U}^{TS}$};\t\t\n\t\t\t\t\\path (1.4334,2.5999) node {$U^S$};\t\n\t\t\t\t\\path (0,0.5) node {$U^{\\tilde{T}}$};\t\n\t\t\t\t\\path (1.25,0.5) node {$F^{\\tilde{T}}$};\t\n\n\t\t\t\t\\draw [cyan, thick] (-0.75,-0.75) circle [radius=0.15];\n\t\t\t\t\\draw [cyan, thick] (0,1.5) circle [radius=0.15];\t\n\t\t\t\t\\draw [magenta, thick] (0,-1.5) circle [radius = 0.15];\n\t\t\t\t\\draw [magenta, thick] (0.75,2.25) circle [radius = 0.15];\t\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\\]\t\t\n\n\\[\n\t\t\t\\begin{tikzpicture}[scale=2]\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(2.5,2.5) -- (-1,-1);\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(0.5,2.5) -- (-3,-1);\n\t\t\t\t\n\t\t\t\t\\draw [s]\n\t\t\t\t\t(-1,2.5) -- (2.5,-1);\n\t\t\t\t\\draw[s] (-3,2.5) -- (0.5,-1);\n\n\t\t\t\t\\fill[very nearly transparent, cyan]\n\t\t\t\t\t(2.5,2.5) -- (-1,-1)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-3,-1) -- (0.5,2.5);\n\n\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-1,2.5)  -- (2.5,-1)\n\t\t\t\t\t\t-- (0.5,-1) --  (-3,2.5);\n\t\t\t\t\n\t\t\t\t\\path (-1.5,0.75) node {$u$};\n\t\t\t\t\\path  (1,0.75) node {$f$};\n\t\t\t\t\\path (-0.25,-0.5)node {$e^{-1}$};\n\t\t\t\t\\path  (-0.25,2) node {$e'$};\n\n\t\t\t\t\\path (-3,2.7669) node {$\\color{gray} U^S$};\n\t\t\t\t\\path (-1,2.7669) node {$\\color{gray} F^S$};\t\t\t\t\t\t\n\t\t\t\t\\path (0.5,2.7669) node {$\\color{gray} U^T$};\n\t\t\t\t\\path (2.5,2.7669) node {$\\color{gray} F^T$};\t\t\t\t\t\n\t\t\t\t\\path (-0.9334,0.0666) node {$\\color{gray} \\hat{U}^{TS}$};\t\t\n\t\t\t\t\\path (0.4667,1.4667) node {$\\color{gray} \\hat{F}^{TS}$};\t\t\n\t\t\t\t\\path (-0.85,1.35) node {$\\color{gray} U^{\\tilde{T}}$};\t\n\t\t\t\t\\path (0.35,0.15) node {$\\color{gray} F^{\\tilde{T}}$};\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\\]\t\n\n\\[\n\t\\begin{aligned}\n\\begin{tikzpicture}[scale=1.5]\n\t\\draw[t]\n\t(0,1) -- (-2.5,-1);\n\t\\draw[f]\n\t(-1.85,1) -- (-1.85,-1);\n\t\\draw[s]\n\t(-2.5,1) -- (0,-1);\n\\end{tikzpicture}\t\n\t\\end{aligned}\n\t\\quad\n\t=\n\t\\quad\n\t\\begin{aligned}\n\\begin{tikzpicture}[scale=1.5]\n\t\\draw[t]\n\t(0,1) -- (-2.5,-1);\n\t\\draw[f]\n\t(-0.65,1) -- (-0.65,-1);\n\t\\draw[s]\n\t(-2.5,1) -- (0,-1);\n\\end{tikzpicture}\t\n\t\\end{aligned}\t\n\\]\n\n\\[\n\t\\begin{aligned}\n\t\\begin{tikzcd}\n\t\t\\cX^S \\ar[r, \"\\t{T}\"] \\ar[d,\"U^S\"']\t\t& \\cX^S \\ar[d, \"U^S\"]\n\t\t\\\\\n\t\t\\cX \\ar[r, \"T\"]\t\t& \\cX\n\t\\end{tikzcd}\n\t\\end{aligned}\n\t\\qquad\n\t\\begin{aligned}\n\t\\begin{tikzcd}\n\t\t\t\t&\t\t\t& \\cX^S \\ar[d, \"U^S\"]\n\t\t\\\\\n\t\t\\cX^S \\ar[urr, \"\\t{T}\"] \\ar[r, \"U^S\"']\t&\t\\cX \\ar[r, \"T\"']\t& \\cX\n\t\\end{tikzcd}\n\t\\end{aligned}\n\\]\n\\[\n\\begin{tikzpicture}[scale=1.5]\n\n\t\\draw[s] \n\t(-1,3.5) -- (-1,0.5) \n\t\tto [out=-90, in =180] \n\t(-0.5,0) \n\t\tto [out=0, in =-90]\n\t(0,0.5) \n\t\t-- \n\t(0,1.5) \n\t\tto [out=90, in =180]\n\t(0.5,2) \n\t\tto  [out=0, in =90]\n\t(1,1.5) -- (1,-1.5);\n\t\n\t\\fill [very nearly transparent, magenta]\n\t(-2.5,3.5)--\n\t(-1,3.5) -- (-1,0.5) \n\t\tto [out=-90, in =180] \n\t(-0.5,0) \n\t\tto [out=0, in =-90]\n\t(0,0.5) \n\t\t-- \n\t(0,1.5) \n\t\tto [out=90, in =180]\n\t(0.5,2) \n\t\tto  [out=0, in =90]\n\t(1,1.5) -- (1,-1.5)\n\t-- (-2.5,-1.5);\t\n\t\\draw[dotted, gray] (-2.5,2.5) -- (3,2.5);\n\t\\draw[dotted, gray] (-2.5,1.5) -- (3,1.5);\n\t\\draw[dotted, gray] (-2.5,0.5) -- (3,0.5);\n\t\\draw[dotted, gray] (-2.5,-0.5) -- (3,-0.5);\n\t\n\t\\path (0,3) node {$\\cX$};\n\t\\path (-2,3) node {$\\cY$};\n\t\\path (-1,3.8) node {$F$};\n\t\\path (1,-1.8) node {$F$};\n\t\\path (-0.2,1) node {$U$};\n\t\\path (0.5,2.2) node {$\\eta$};\n\t\\path (-0.5,-0.2) node {$\\varepsilon$};\n\t\n\t\\path (2,3) node (F) {$F$};\n\t\\path (2,1) node (FUF) {$FUF$};\n\t\\path (2,-1) node (F2) {$F$};\n\t\\path (2.5,2) node {$F \\eta$};\n\t\\path (2.5,0) node {$\\varepsilon F$};\n\t\n\t\\draw[-implies, double equal sign distance] (F) -- (FUF);\n\t\\draw[-implies, double equal sign distance] (FUF) -- (F2);\t\n\t\n\t\\draw[->, gray] (-0.5,3) to[out=150, in =30] (-1.5,3);\n\\end{tikzpicture}\n\\]\n\n $\\eta: 1_{\\mathbf{X}} \\Rightarrow UF$\n\n $\\varepsilon: FU \\Rightarrow 1_{\\mathbf{Y}}$\n\n\\[\n\t\\begin{tikzcd}\n\t\td \\ar[d, mapsto]\t& \t\\mathcal{D} \\ar[d, \"Y\"'] \\ar[r, \"F\"]\t&\t\\mathcal{C}\t&\t\\text{colim}^W F \\,\\cong\\, \\int^d W(d) \\cdot F(d) \n\t\t\\\\\n\t\t\\mathcal{D}(-,d) & {[\\mathcal{D}^{op}, \\mathcal{V}]} \\ar[ur, \"\\hat{F} = \\text{Lan}_Y F\"'] & & W \\,\\cong\\, \\int^d W(d) \\cdot \\mathcal{D}(-,d) \\ar[u, mapsto]\n\t\\end{tikzcd}\n\\]\t\n\n\\[\n\\begin{aligned}\n\t\\begin{tikzcd}\n\t\t\\mathcal{D} \\ar[rr, \"F\"] \\ar[dd, \"p\"'] \\ar[dr, \"Y\"'] & & \\mathcal{C} \n\t\t\\\\\n\t\t& {[\\mathcal{D}^{op}, \\mathcal{V}]} \\ar[ur, \"\\text{Lan}_Y F\"'] &\n\t\t\\\\\n\t\t\\mathcal{D}' \\ar[ur, \"p^* \\circ Y' \" '] & &\n\t\\end{tikzcd}\n\\end{aligned}\n\\quad\n\\cong\n\\quad\n\\begin{aligned}\n\t\\begin{tikzcd}\n\t\t\\mathcal{D} \\ar[rr, \"F\"] \\ar[dd, \"p\"'] & & \\mathcal{C} \n\t\t\\\\\n\t\t& \\phantom{[\\mathcal{D}^{op}, \\mathcal{V}]} &\n\t\t\\\\\n\t\t\\mathcal{D}' \\ar[uurr, \"\\text{Lan}_p F\" '] & &\n\t\\end{tikzcd}\n\\end{aligned}\n\\]\t\n\n\\[\n\t\\begin{tikzcd}\n\t\tX \\ar[d, Rightarrow] \\\\ Y\n\t\\end{tikzcd}\n\\]\t\n\n\\pagebreak\n\\appendix\n\\section{String diagrams}\n\tThis is a quick review of string diagrams. Throughout, we work in a $2$-category $\\cK$ (for example, the category of categories, $\\Cat$) containing\n\t\\begin{itemize}\n\t\t\\item $0$-cells $\\cX,\\cY,\\cZ,\\dots$  (`categories'),\n\t\t\\item $1$-cells $F,G,\\dots$ ('functors'),\n\t\t\\item $2$-cells $\\eta, \\mu, \\dots$ ('natural transformations').\n\t\\end{itemize}\n\n\tIn diagrammatic calculus, $0$-cells are denoted by \\emph{regions}, $1$-cells by \\emph{lines} between regions, and $2$-cells by \\emph{points/nodes} on lines. Thus, the following two diagrams denote the same thing:\n\t\\begin{equation*}\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\\cX \n\t\t\t\t\t\\arrow[r, bend left, \"F\"{name=U}]\n\t\t\t\t\t\\arrow[r, bend right, \"G\"{name=D, below}]\n\t\t\t\t& \\cY\n\t\t\t\t\t\\arrow[Rightarrow, \"\\eta\", from=U, to=D]\n\t\t\t\\end{tikzcd}\n\t\t\t\\qquad\n\t\t\t\\qquad\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\path (0.5,0) node {$\\cX$};\n\t\t\t\t\\path (-1.5,0) node {$\\cY$};\n\t\t\t\t\\path (-0.5,1.5) node (F) {$F$};\n\t\t\t\t\\path (-0.5,-1.5) node (G) {$G$};\n\t\t\t\t\\path (-0.5,0) node (e) {$\\eta$};\n\t\t\t\t\n\t\t\t\t\\draw[black]\n\t\t\t\t\t(F) to (e) to (G);\n\t\t\t\t\t\n\t\t\t\t\\draw [black] (-0.5,0) circle [radius=0.32];\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\\end{equation*}\n\tAll string diagrams in this paper should be read from \\emph{right to left} and \\emph{top to bottom}. This is to agree with the common convention of writing the composite of $G:\\cY \\to \\cZ$ and $F: \\cX \\to \\cY$ as\n\t\\begin{equation*}\n\t\tGF \\quad = \\quad \\cZ \\xleftarrow{G} \\cY \\xleftarrow{F} \\cX \\quad = \\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\node at (0,0) (G) {$G$};\n\t\t\t\t\\node at (2,0) (F) {$F$};\n\n\t\t\t\t\\node at (-1,-1.5) {$\\cZ$};\n\t\t\t\t\\node at (1,-1.5) {$\\cY$};\n\t\t\t\t\\node at (3,-1.5) {$\\cX$};\n\n\t\t\t\t\\draw\n\t\t\t\t(G) -- (0,-3);\n\t\t\t\t\\draw\n\t\t\t\t(F) -- (2,-3);\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}.\n\t\\end{equation*}\t\n\tIn Beck's paper, this composite would be written $FG$.\n\n\tIn practice, many $2$-cells will not be drawn using nodes, but instead indicated by certain configurations of input and output lines. For example:\n\t\\begin{equation*}\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[black]\n\t\t\t\t\t(0,2)\n\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t(0.5,1)\n\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t(1,2);\t\t\n\t\t\t\t\\draw[black]\n\t\t\t\t\t(0.5,1) -- (0.5,0);\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\text{ instead of }\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[black]\n\t\t\t\t\t(0,2)\n\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t(0.5,1)\n\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t(1,2);\t\t\n\t\t\t\t\\draw[black]\n\t\t\t\t\t(0.5,1) -- (0.5,0);\n\t\t\t\t\\draw [black, fill=white] (0.5,1) circle [radius=0.2];\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\qquad\n\t\t\\text{, and }\n\t\t\\qquad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[f]\n\t\t\t\t\t(1,2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,0);\t\t\t\t\t\t\n\t\t\t\t\\draw[f]\n\t\t\t\t\t(0,2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(1,0);\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\text{ instead of }\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[f]\n\t\t\t\t\t(1,2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,0);\t\t\t\t\t\t\n\t\t\t\t\\draw[f]\n\t\t\t\t\t(0,2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(1,0);\n\t\t\t\t\\draw [black, fill=white] (0.5,1) circle [radius=0.2];\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\t\t\n\t\t\\qquad .\n\t\\end{equation*}\n\tIdentity $1$-cells or $2$-cells are also not drawn:\n\t\\begin{equation*}\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\path (0.5,0) node {$\\cX$};\n\t\t\t\t\\path (1,1.5) node {$\\phantom{1_{\\cX}}$};\t\t\t\t\t\t\n\t\t\t\t\\fill[nearly transparent, gray] (2,-0.5) rectangle (0,1);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\text{ instead of }\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\path (0.5,0) node {$\\cX$};\n\t\t\t\t\\path (1,1.5) node {$1_{\\cX}$};\n\t\t\t\t\\draw[black] (1,1) -- (1,-0.5);\n\t\t\t\t\\fill[nearly transparent, gray] (2,-0.5) rectangle (0,1);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\qquad\n\t\t\\text{, and }\n\t\t\\qquad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\path (1,1.5) node {$F$};\n\t\t\t\t\\draw[black] (1,1) -- (1,-0.5);\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\text{ instead of }\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\path (1,1.5) node {$F$};\n\n\t\t\t\t\\draw[black] (1,1) -- (1,-0.5);\n\t\t\t\t\\draw[black, fill=white] (1,0.25) circle [radius=0.2];\n\t\t\t\t\\path (0.5,0.25) node {$1_F$};\t\t\t\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\t\t\n\t\t\\qquad .\n\t\\end{equation*}\n\tAs much as possible, we will rely on the color of $0$- and $1$-cells and the shape of $2$-cells for identification, omitting their names when the context allows.\n\n\tString diagrams may be concatenated vertically and horizontally, in the same way that $2$-cells in a $2$-category have horizontal and vertical composition. For example, the identity $2$-cell $T = 1_T: T \\To T$ may be composed horizontally with the $2$-cell $\\mu: TT \\To T$ to obtain $T \\mu: TTT \\To TT$:\n\t\\begin{equation*}\n\t\t\\begin{tikzpicture}\n\t\t\t\\draw[t]\n\t\t\t(0.5,-1)\n\t\t\t\tto [out=-90, in =150]\n\t\t\t(1,-2)\n\t\t\t\tto [out=30, in =-90]\n\t\t\t(1.5,-1);\n\t\t\t\n\t\t\t\\draw[t]\n\t\t\t(1,-2) -- (1,-2.5);\t\t\n\n\t\t\t\\draw[t]\n\t\t\t(-0.5,-1) -- (-0.5,-2.5);\n\t\t\\end{tikzpicture}\n\t\\end{equation*}\n\tThis may then be composed vertically with $\\mu$ to obtain:\n\t\\begin{equation*}\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzcd}\n\t\t\t\tTTT \\ar[d, Rightarrow, \"T \\mu\"] \\\\ TT \\ar[d, Rightarrow, \"\\mu\"] \\\\ T\n\t\t\t\\end{tikzcd}\n\t\t\\end{aligned}\n\t\t\\qquad\n\t\t\\qquad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t]\n\t\t\t\t(3.5,0)\n\t\t\t\t\tto [out=-90, in = 150]\n\t\t\t\t(4,-1)\n\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t(4.5,0);\n\t\t\t\t\n\t\t\t\t\\draw[t]\n\t\t\t\t(2.5,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(3.5,-2)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(4,-1);\n\t\t\t\t\n\t\t\t\t\\draw[t]\n\t\t\t\t(3.5,-2) -- (3.5,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\\path (2.5,0.5) node {$T$};\n\t\t\t\t\\path (3.5,0.5) node {$T$};\n\t\t\t\t\\path (4.5,0.5) node {$T$};\t\n\t\t\t\t\\path (5.5,-1) node {$T \\mu$};\t\n\t\t\t\t\\path (5.5,-2) node {$\\mu$};\t\n\t\t\t\t\n\t\t\t\t\\draw[dashed] (2,-1.5) -- (6,-1.5);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\\end{equation*}\n\n\tFinally, we outline a general procedure for translating a commutative diagram into a series of equalities of string diagrams:\n\t\\begin{enumerate}\n\t\t\\item Treat the commutative diagram as a directed graph. Identify the source and sink of this graph.\n\t\t\\item For every directed path from source to sink, draw the corresponding string diagram.\n\t\t\\item For every region bounded by two directed paths, write `=' between the corresponding string diagrams.\n\t\\end{enumerate}\n\tAs an example, consider the following commutative diagram, found at the top of p.98 in Beck's paper \\cite{beck1969distributive}:\n\t\\begin{equation}\n\t\t\\begin{tikzcd}\n\t\t\t\t\t& & TST  \\ar[ddrr, \"TST\\eta^S\", blue, Rightarrow]\t& &\n\t\t\t\\\\\n\t\t\t\t\t& & (3)\t& &\n\t\t\t\\\\\n\t\t\tSTT \\ar[uurr,\"\\ell T\", blue, Rightarrow] \\ar[rr, \"\\eta^T ST \\eta^S T \\eta^S\"', Rightarrow] \\ar[dd,\"S \\mu^T\"' ,red, Rightarrow]\t& & TSTSTS \\ar[rr, \"mTS\"', Rightarrow] \\ar[dd, \"TSm\", Rightarrow]\t& & TSTS \\ar[dd, \"m\", blue, Rightarrow]\n\t\t\t\\\\\n\t\t\t\t& (1) & & (2) &\n\t\t\t\\\\\n\t\t\tST  \\ar[rr, \"\\eta^T ST \\eta^S\", red, Rightarrow]\t & & TSTS \t\\ar[rr, \"m\", red, Rightarrow]\t& & TS\n\t\t\\end{tikzcd}\n\t\\end{equation}\n\tThis has source $STT$ at the top-left, sink $TS$ at the bottom right, and 4 directed paths from source to sink related by 3 `commuting regions'. \n\n\tWe get the following equality of 4 string diagrams, starting with the red path on the left, ending with the blue path on the right, and with equalities labelled to indicate which commuting regions they correspond to:\n\t\\begin{equation}\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t]\n\t\t\t\t(0,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-1)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1,0);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-1.5,-1.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(-0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(0.5,-1);\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(-1,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1.5,-1.5);\n\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(0.5,-3) -- (0.5,-4);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-0.5,-3) -- (-0.5,-4);\t\n\t\t\t\t\n\t\t\t\t\\draw[fill, color=red] (1.5,-1.5) circle (.08);\n\t\t\t\t\\draw[fill, color=teal] (-1.5,-1.5) circle (.08);\n\t\t\t\t\n\t\t\t\t\\path (-1,0.5) node {$S$};\n\t\t\t\t\\path (0,0.5) node {$T$};\n\t\t\t\t\\path (1,0.5) node {$T$};\n\t\t\t\t\\path (-2,-1.5) node {$\\eta^T$};\n\t\t\t\t\\path (2,-1.5) node {$\\eta^S$};\t\n\t\t\t\t\\path (0,-1) node {$\\mu^T$};\n\t\t\t\t\\path (-2,-3) node {$m$};\t\t\n\t\t\t\t\n\t\t\t\t\\draw[rounded corners, dashed, black] (1.5,-3.25) rectangle (-1.5,-2.25);\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\overset{(1)}{=}\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t]\n\t\t\t\t(0,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-1.5)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1.5,0);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-1.5,-0.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(-0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(0.5,-1.5);\t\n\n\t\t\t\t\\draw[s]\n\t\t\t\t(1,-0.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(1.5,-1.5)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(2,-0.5);\t\t\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(-1,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1.5,-1.5);\t\t\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(0.5,-3) -- (0.5,-4);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-0.5,-3) -- (-0.5,-4);\t\n\t\t\t\t\n\t\t\t\t\\draw[fill, color=red] (2,-0.5) circle (.08);\n\t\t\t\t\\draw[fill, color=red] (1,-0.5) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\draw[fill, color=teal] (-1.5,-0.5) circle (.08);\n\t\t\t\t\n\t\t\t\t\\path (-1,0.5) node {$S$};\n\t\t\t\t\\path (0,0.5) node {$T$};\n\t\t\t\t\\path (1,0.5) node {$T$};\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\overset{(2)}{=}\n\t\t\\quad\t\t\t\t\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t]\n\t\t\t\t(-1.5,-0.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(-1,-1.5)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(0,0);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-1,-1.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(-0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1,0);\t\n\n\t\t\t\t\\draw[s]\n\t\t\t\t(-1,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0,-1.5)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(0.5,-0.5);\t\t\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(0,-1.5)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1.5,-0.5);\t\t\t\t\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(0.5,-3) -- (0.5,-4);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-0.5,-3) -- (-0.5,-4);\t\n\t\t\t\t\n\t\t\t\t\\draw[fill, color=red] (0.5,-0.5) circle (.08);\n\t\t\t\t\\draw[fill, color=red] (1.5,-0.5) circle (.08);\t\t\t\t\t\t\n\t\t\t\t\\draw[fill, color=teal] (-1.5,-0.5) circle (.08);\n\t\t\t\t\n\t\t\t\t\\path (-1,0.5) node {$S$};\n\t\t\t\t\\path (0,0.5) node {$T$};\n\t\t\t\t\\path (1,0.5) node {$T$};\t\t\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\n\t\t\\quad\n\t\t\\overset{(3)}{=}\n\t\t\\quad\n\t\t\\begin{aligned}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t]\n\t\t\t\t(0,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(-0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1,0);\n\n\t\t\t\t\\draw[s]\n\t\t\t\t(-1,0)\n\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t(0.5,-3)\n\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t(1.5,-1);\t\t\t\t\t\t\n\t\t\n\t\t\t\t\\draw[s]\n\t\t\t\t(0.5,-3) -- (0.5,-4);\n\t\t\t\t\\draw[t]\n\t\t\t\t(-0.5,-3) -- (-0.5,-4);\t\n\t\t\t\t\n\t\t\t\t\\draw[fill, color=red] (1.5,-1) circle (.08);\n\t\t\t\n\t\t\t\t\n\t\t\t\t\\path (-1,0.5) node {$S$};\n\t\t\t\t\\path (0,0.5) node {$T$};\n\t\t\t\t\\path (1,0.5) node {$T$};\n\t\t\t\t\\path (-1,-1.75) node {$\\ell$};\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{aligned}\t\n\t\t\\qquad.\t\t\t\n\t\\end{equation}\n\n\\vfill\n\\pagebreak\n\\section{The formal theory of monads}\n\tIn this appendix, we translate some aspects of the formal theory of monads into string diagrams. Our main references are \\cite{street1972formal}, but we also borrow some notions from \\cite{macdonald2004aspects} and \\cite{kelly1974review}. We begin with the object around which the rest of the section is centered.\n\n\t\\subsection{The category of monads}\n\t\t\\begin{definition} A \\emph{triple} or \\emph{monad} ($\\cX, T, \\eta, \\mu$) in a $2$-category $\\cK$ consists of\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item a $0$-cell $\\cX$,\n\t\t\t\t\\item a $1$-cell $T: \\cX \\to \\cX$,\n\t\t\t\t\t\\begin{equation*}\n\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t\t(1,-1) -- (1,-2.5);\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\path (0.5,-1.75) node {$\\cX$};\n\t\t\t\t\t\t\t\\path (1.5,-1.75) node {$\\cX$};\n\t\t\t\t\t\t\t\\path (1,-0.5) node {$T$};\t\t\t\t\t\t\n\t\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\t\\end{equation*}\n\t\t\t\t\\item two $2$-cells $\\eta: 1_\\cX \\To T$ and $\\mu: TT \\To T$\n\t\t\t\t\t\\begin{equation*}\t\n\t\t\t\t\t\t\\eta\n\t\t\t\t\t\t\\quad =  \\quad\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t\t\t(1,-1.5) -- (1,-2.5);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\draw[fill, color = teal] (1,-1.5) circle[radius=0.08];\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\t\t\\end{aligned}\n\t\t\t\t\t\t\\qquad\n\t\t\t\t\t\t,\n\t\t\t\t\t\t\\qquad\n\t\t\t\t\t\t\\mu\n\t\t\t\t\t\t\\quad =  \\quad\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t\t\t(1,-2)\n\t\t\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t\t\t(1.5,-1);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t\t\t(1,-2) -- (1,-2.5);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\t\t\\end{aligned}\n\t\t\t\t\t\\end{equation*}\n\t\t\t\\end{itemize}\n\t\t\tsuch that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(1,-2)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(1.5,-0.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-2) -- (1,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (0.5,-1) circle (.08);\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-0.5) -- (1,-2.5);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(0.5,-0.5)\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(1,-2)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(1.5,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-2) -- (1,-2.5);\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=teal, ] (1.5,-1) circle (.08);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\text{and}\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(0,0)\n\t\t\t\t\t\t\tto [out=-90, in = 150]\n\t\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(0.5,-1)\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(1,-2)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(2,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-2) -- (1,-2.5);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,0)\n\t\t\t\t\t\t\tto [out=-90, in = 150]\n\t\t\t\t\t\t(1.5,-1)\n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(2,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(0,0)\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(1,-2)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(1.5,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-2) -- (1,-2.5);\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\n\t\t\t\t\\qquad.\n\t\t\t\\end{equation}\n\t\t\tWe may also call this a monad \\emph{on} $\\cX$. Thus, a monad on $\\cX$ is a monoid in the monoidal\\footnote{The fact that $(\\cat{End}(\\cX),\\circ, 1_\\cX)$ is not a \\emph{braided} monoidal category is the reason why distributive laws are required!} category $(\\cat{End}(\\cX), \\circ, 1_\\cX)$.\n\n\t\t\tWe will variously use $(\\cX, T)$, $(T, \\eta,\\mu)$, or often simply $T$, to refer to the monad $(\\cX,T,\\eta,\\mu)$.\n\t\t\\end{definition}\t\n\n\t\t\\begin{definition}\n\t\t\tLet $(T,\\eta,\\mu), (T',\\eta', \\mu')$ be monads on $\\cX$. A \\emph{monad map} is a $2$-cell $\\phi: T \\To T'$ such that\n\t\t\t\\begin{equation}\t\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [vt]\n\t\t\t\t\t\t(-3,-2) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3,-3.5);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-3,-0.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3,-2);\t\n\t\t\t\t\t\t\\draw[fill, color=red, ] (-3,-2) circle (.08);\n\t\t\t\t\t\t\\draw[fill, color=teal] (-3,-0.5) circle (.08);\t\n\t\t\t\t\t\t\\path (-3.5,-2) node {$\\phi$};\t\t\t\t\t\n\t\t\t\t\t\t\\path (-2.5,-2.75) node {$T'$};\n\t\t\t\t\t\t\\path (-2.5,-1.25) node {$T$};\n\t\t\t\t\t\t\\path (-3,0) node {$\\eta$};\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,-0.5) node (ST) {};\n\n\t\t\t\t\t\t\\draw[white]\n\t\t\t\t\t\t(-1,1.75) to (ST);\t\t\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [vt] \n\t\t\t\t\t\t(ST.center) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t (-1,-2) ;\t\n\n\t\t\t\t\t\t\\draw[fill, color=vioteal] (ST) circle (.08);\n\t\t\t\t\t\t\\path (-1,0) node {$\\eta'$};\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\text{ and }\n\t\t\t\t\\qquad\t\t\t\t\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [t] \n\t\t\t\t\t\t(-1,0) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-1.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,0);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-1.5);\t\n\n\t\t\t\t\t\t\\draw [vt]\n\t\t\t\t\t\t(0,-2.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-3.5);\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red, ] (0,-2.5) circle (.08);\n\t\t\t\t\t\t\\path (0,-1.25) node {$\\mu$};\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [vt] \n\t\t\t\t\t\t(-1,-1) \n\t\t\t\t\t\t\tto [out = -90, in = 150]\n\t\t\t\t\t\t(0,-2.5) \n\t\t\t\t\t\t\tto [out = 30, in =-90]\n\t\t\t\t\t\t(1,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [vt]\n\t\t\t\t\t\t(0,-3.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(0,-2.5);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(-1,0)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-1,-1);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw [t]\n\t\t\t\t\t\t(1,0)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(1,-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color=red, ] (-1,-1) circle (.08);\n\t\t\t\t\t\t\\draw[fill, color=red, ] (1,-1) circle (.08);\n\t\t\t\t\t\t\\path (0.1,-2.22) node {$\\mu'$};\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\n\t\t\t\t\\end{aligned}\t\t\n\t\t\t\t\\qquad.\t\t\t\t\n\t\t\t\\end{equation}\t\n\t\t\\end{definition}\n\t\tThis is the definition of a map of monads/triples that is used in \\cite{beck1969distributive} as well as \\cite{kelly1974review}, and which agrees with the definition of a monoid homomorphism between monoids in a monoidal category.\n\t\t\\begin{definition} The category $\\Mnd(\\cX)$ is the category of monads on $\\cX$ and monad maps between them.\n\t\t\\end{definition}\n\n\t\tThere is a more general notion of a morphism between monads in \\cite{street1972formal}, where we allow $T$ and $T'$ to be monads on \\emph{different} $0$-cells:\n\t\t\\begin{definition}\n\t\t\tLet $(\\cX, T)$ and $(\\cY, T')$ be monads in $\\cK$. A \\emph{lax morphism of monads}, or \\emph{monad functor}, $(F,\\phi): (\\cX,T) \\to (\\cY,T')$ consists of a $1$-cell $F: \\cX \\to \\cY$ and a $2$-cell $\\phi: T'F \\To FT$ such that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-2,-0.5) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\\draw[fill, color=teal] (-2,-0.5) circle (.08);\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,0);\t\t\t\n\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\n\t\t\t\t\t\t\\path (-2.5,-2.5) node {$\\cX$};\n\t\t\t\t\t\t\\path (-3.5,-3.5) node {$T$};\n\t\t\t\t\t\t\\path (-1.75,-1) node {$T'$};\n\t\t\t\t\t\t\\path (-1,-2.5) node {$\\cY$};\n\t\t\t\t\t\t\\path (-3,-1.5) node {$\\phi$};\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-3.5,-2)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-2.5,-3);\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (-3.5,-2) circle (.08);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(-2.5,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-1,0);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\text{ and }\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[t]\t\n\t\t\t\t\t\t(-2.5,0.5)\t\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out=30, in = -90]\t\n\t\t\t\t\t\t(-1.5,0.5);\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-3.5,-3);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5,0.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,0.5);\t\n\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[t]\t\n\t\t\t\t\t\t(-2.5,0.5)\t\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(-3.5,-2.5)\n\t\t\t\t\t\t\tto [out=30, in = -90]\t\n\t\t\t\t\t\t(-1.5,0.5);\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-3.5,-2.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-3.5,-3);\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5,0.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,0.5);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\t\n\t\t\t\t\\qquad.\t\t\t\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tAn \\emph{oplax morphism of monads}, or \\emph{monad opfunctor}, $(F,\\phi):(\\cX,T) \\to (\\cY, T')$ consists of $F: \\cX \\to \\cY$ and $\\phi: FT \\To T'F$ such that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-2,-0.5) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\\draw[fill, color=teal] (-2,-0.5) circle (.08);\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,0);\t\n\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\n\t\t\t\t\t\t\\path (-2.5,-2.5) node {$\\cY$};\n\t\t\t\t\t\t\\path (-3.5,-3.5) node {$T'$};\n\t\t\t\t\t\t\\path (-1.75,-1) node {$T$};\n\t\t\t\t\t\t\\path (-1,-2.5) node {$\\cX$};\n\t\t\t\t\t\t\\path (-3,-1.5) node {$\\phi$};\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-3.5,-2)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-2.5,-3);\t\n\t\t\t\t\t\n\t\t\t\t\t\\draw[fill, color=teal] (-3.5,-2) circle (.08);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(-2.5,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4.5,0);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\text{ and }\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\t\n\t\t\t\t\t\t(-2.5,0.5)\t\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out=30, in = -90]\t\n\t\t\t\t\t\t(-1.5,0.5);\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-3.5,-3);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5,0.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,0.5);\t\n\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\t\n\t\t\t\t\t\t(-2.5,0.5)\t\n\t\t\t\t\t\t\tto [out=-90, in =150]\n\t\t\t\t\t\t(-3.5,-2.5)\n\t\t\t\t\t\t\tto [out=30, in = -90]\t\n\t\t\t\t\t\t(-1.5,0.5);\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-3.5,-2.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-3.5,-3);\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0.5)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\t\t\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5,0.5) \n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,0.5);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\t\n\t\t\t\t\\qquad.\t\t\t\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tA \\emph{monad (op)functor transformation} $\\sigma: (F,\\phi) \\To (F',\\phi')$ between monad (op)functors is a $2$-cell $\\sigma: F \\To F'$ such that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\path (-1.5,-3.5) node {$F'$};\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\n\t\t\t\t\t\t\\path (-3.5,-1) node {$\\sigma$};\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\n\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,0);\t\t\t\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-3.08,-1) circle (.08);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\path (-1.5,-3.5) node {$F'$};\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\t\t\t\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-0.5,0);\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-1.93,-2) circle (.08);\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\n\t\t\t\t\\qquad \\qquad\n\t\t\t\t\\left(\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1.5,-3.5) node {$F'$};\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\n\t\t\t\t\t\t\\path (-3.5,-1) node {$\\sigma$};\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\n\n\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,0);\t\t\t\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-3.08,-1) circle (.08);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1.5,-3.5) node {$F'$};\n\t\t\t\t\t\t\\path (-3.5,0.5) node {$F$};\t\t\t\n\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(-1.5,0) \n\t\t\t\t\t\t\tto [out = -90, in=90]\n\t\t\t\t\t\t(-3.5,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(-3.5,0)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1.5,-3);\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t(-3.5, 0)\n\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t(-1.5, -3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,-3)\n\t\t\t\t\t\t\tto\n\t\t\t\t\t\t(-4.5,0);\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[fill, color=red] (-1.93,-2) circle (.08);\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\n\t\t\t\t\\right).\n\t\t\t\\end{equation}\n\t\t\\end{definition}\n\n\t\tThus, for monads $T, T'$ on the same $\\cX$, if $(1_{\\cX}, \\phi):(\\cX,T) \\to (\\cX,T')$ is a monad \\emph{op}functor, then $\\phi: T \\To T'$ is a monad \\emph{map}, and vice versa. This also gives rise to a monad \\emph{functor} $(1_{\\cX}, \\phi):(\\cX,T') \\to (\\cX,T)$, but note the opposite variance (from $T'$ to $T$)!\n\n\t\t\\begin{definition}\n\t\tThe $2$-category of monads, monad functors and monad functor transformations is $\\Mnd(\\cK)$. \n\t\tSimilarly, the $2$-category of monads, monad \\emph{op}functors and monad opfunctor transformations is $\\Mnd^{op}(\\cK)$. \n\t\t\\end{definition}\n\n\t\tLet $\\cK^{op}$ denote the $2$-category obtained by reversing the $1$-cells of $\\cK^{op}$. Monads in $\\cK$ are the same thing as monads in $\\cK^{op}$, so $\\Mnd(\\cK)$ and $\\Mnd(\\cK^{op})$ have the same $0$-cells. By definition, these are also the $0$-cells of $\\Mnd^{op}(\\cK)$). In fact, it is not hard to see that \n\t\t\\begin{equation}\n\t\t\t\\Mnd^{op}(\\cK) = \\big(\\Mnd(\\cK^{op})\\big)^{op}.\n\t\t\\end{equation}\n\n\t\tWhere possible, we work with $\\Mnd^{op}(\\cK)$ instead of $\\Mnd(\\cK)$. Part of the reason is that monad maps have the same `variance' as monad opfunctors: for $\\cX$ a 0-cell of $\\cK$, $\\Mnd(\\cX)$ is a subcategory of $\\Mnd^{op}(\\cK)$ (treated as a $1$-category), \\emph{not} $\\Mnd(\\cK)$.\n\n\t\tWe could also consider monads in $\\cK^{co}$, the $2$-category obtained by reversing $2$-cells of $\\cK$. These are \\emph{co}monads in $\\cK$, and we may define the corresponding categories $\\cat{CoMnd}(\\cX), \\cat{CoMnd}(\\cK), \\cat{CoMnd}^{op}(\\cK)$. To learn about the formal theory of comonads, their co-algebras, and distributive laws between them, simply read all diagrams in this paper from \\emph{bottom to top}.\n\n\t\\vfill\n\t\\pagebreak\n\t\\subsection{Adjunctions in a $2$-category}\n\t\t\\begin{definition} An \\emph{adjunction} $(F,U,\\eta, \\varepsilon)$ in $\\cK$ consists of\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item $1$-cells $F: \\cX \\to \\cY$ and $U: \\cY \\to \\cX$\n\t\t\t\t\t\\begin{equation*}\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t\t\t(1,-1) -- (1,-2.5);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\path (0.5,-1.75) node {$\\cY$};\n\t\t\t\t\t\t\t\t\\path (1.5,-1.75) node {$\\cX$};\n\t\t\t\t\t\t\t\t\\path (1,-0.5) node {$F$};\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (0,-1) rectangle (1,-2.5);\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\\end{aligned}\n\t\t\t\t\t\t\\qquad\n\t\t\t\t\t\t,\n\t\t\t\t\t\t\\qquad\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t\t\t(1,-1) -- (1,-2.5);\t\n\n\t\t\t\t\t\t\t\t\\path (1,-0.5) node {$U$};\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (2,-1) rectangle (1,-2.5);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\\end{aligned}\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{equation*}\n\t\t\t\t\\item $2$-cells $\\eta: 1_\\cX \\To UF$ and $\\varepsilon: FU \\To 1_\\cY$\n\t\t\t\t\t\\begin{equation*}\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t\t\t(1,-2) -- (1,-1)\n\t\t\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t\t\t(1.5, -0.5)\n\t\t\t\t\t\t\t\t\tto [out = 0, in =90]\n\t\t\t\t\t\t\t\t(2,-1) -- (2,-2);\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t\t\t(1,-2) -- (1,-1)\n\t\t\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t\t\t(1.5, -0.5)\n\t\t\t\t\t\t\t\t\tto [out = 0, in =90]\n\t\t\t\t\t\t\t\t(2,-1) -- (2,-2);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\path (1.5,-0.25) node {$\\eta$};\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\t\t\\end{aligned}\n\t\t\t\t\t\t\\qquad\n\t\t\t\t\t\t,\n\t\t\t\t\t\t\\quad\n\t\t\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t\t\t(1,-1) -- (1,-2)\n\t\t\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t\t\t(1.5,-2.5)\n\t\t\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t\t\t(2,-2) -- (2,-1);\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t\t\t(0.5,-3) -- (0.5,-1)-- (1,-1) -- (1,-2)\n\t\t\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t\t\t(1.5,-2.5)\n\t\t\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t\t\t(2,-2) --(2,-1)-- (2.5,-1)--(2.5,-3);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\\path (1.5,-2.25) node {$\\varepsilon$};\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\t\t\\end{aligned}\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{equation*}\n\t\t\t\\end{itemize}\n\t\t\tsuch that\n\t\t\t\\begin{equation}\\label{eq:adjunction}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[scale=2]\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1,-1) -- (1,-2)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.25,-2.25)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(1.5,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(2,-2) -- (2,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) -- (1,-2)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.25,-2.25)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(1.5,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(2,-2) -- (2,-3) \n\t\t\t\t\t\t--(0.5,-3) -- (0.5,-1);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[scale=2]\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1.5,-1) -- (1.5,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1.5,-1) -- (1.5,-3) --(0.5,-3) -- (0.5,-1);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t\\text{and}\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[yscale=-1, scale=2]\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1,-1) -- (1,-2)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.25,-2.25)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(1.5,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(2,-2) -- (2,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) -- (1,-2)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.25,-2.25)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(1.5,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(2,-2) -- (2,-3) \n\t\t\t\t\t\t--(2.5,-3) -- (2.5,-1);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[scale=2]\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1.5,-1) -- (1.5,-3);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1.5,-1) -- (1.5,-3) --(2.5,-3) -- (2.5,-1);\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\qquad.\n\t\t\t\\end{equation}\n\t\t\tWe call $F$ the \\emph{left adjoint}, $U$ the \\emph{right adjoint}, and we write $F \\dashv U$. We also call $\\eta$ the \\emph{unit} of the adjunction, and $\\varepsilon$ the \\emph{counit}.\n\t\t\\end{definition}\n\t\tIn (\\ref{eq:adjunction}), we have dropped all labels, but this should not cause any confusion: $\\cX$ and $\\cY$ can be identified by their colours,  $F$ and $U$ by the colored regions that they border, and $\\eta$ and $\\varepsilon$ by their shapes. \n\n\t\tLet $(F,U,\\eta,\\varepsilon)$ be an adjunction, where $F: \\cX \\to \\cY$. Using the properties of the unit and counit, it is easy to see that we obtain a monad on $\\cX$\\footnote{In fact, we also get a \\emph{co}monad $FU$ on $\\cY$.}:\n\t\t\\begin{equation*}\n\t\t\t(UF, \\eta, U \\varepsilon F)\n\t\t\t\\qquad\n\t\t\t=\n\t\t\t\\qquad\n\t\t\t\\left(\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1.5,-0.5) -- (1.5,-3);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-0.5) -- (1,-3);\t\t\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1.5,-0.5) -- (1.5,-3) --(1,-3) -- (1,-0.5);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t,\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1.5,-3) -- (1.5,-2)\n\t\t\t\t\t\tto [out=90, in =180]\n\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\tto [out= 0, in =90]\n\t\t\t\t\t(2,-2) -- (2,-3);\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(1.5,-3) -- (1.5,-2)\n\t\t\t\t\t\tto [out=90, in =180]\n\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\tto [out= 0, in =90]\n\t\t\t\t\t(2,-2) -- (2,-3);\n\t\t\t\t\t\n\t\t\t\t\t\\fill[white] (1.5,-0.5) rectangle (2,-1);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t,\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-0.5) -- (1,-1.5)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(1.5,-2.5) -- (1.5,-3);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(2.5,-0.5) --(2.5,-1.5)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,-2.5) -- (2,-3);\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1.5,-0.5) -- (1.5,-1.5)\n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\tto [out= 0, in =-90]\n\t\t\t\t\t(2,-1.5) -- (2,-0.5);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(1.5,-0.5) -- (1.5,-1.5)\n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(1.75,-1.75)\n\t\t\t\t\t\tto [out= 0, in =-90]\n\t\t\t\t\t(2,-1.5) -- (2,-0.5) -- (2.5,-0.5) --(2.5,-1.5)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(2,-2.5) -- (2,-3)--(1.5,-3) --(1.5,-2.5) \n\t\t\t\t\t\tto [out=90, in =-90]\n\t\t\t\t\t(1,-1.5) -- (1,-0.5);\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\t\t\t\t\t\t\t\t\n\t\t\t\\right)\n\t\t\\end{equation*}\n\t\tFurther, a pair of composable adjunctions\n\t\t\\begin{equation}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\\cX \\ar[r,bend left,\"F\",\"\"{name=A, below}] \n\t\t\t\t& \n\t\t\t\t\\cY \\ar[l,bend left,\"U\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv] \\ar[r, bend left, \"F'\", \"\"{name=C, below}]\n\t\t\t\t&\n\t\t\t\t\\cZ \\ar[l, bend left, \"U'\", \"\"{name=D,above}] \\ar[from=C, to = D, symbol = \\dashv]\n\t\t\t\\end{tikzcd}\t\t\n\t\t\\end{equation}\n\t\tgive rise to a composite adjunction\n\t\t\\begin{equation}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\\cX \\ar[r,bend left,\"F'F\",\"\"{name=A, below}] \n\t\t\t\t& \n\t\t\t\t\\cZ \\ar[l,bend left,\"UU'\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\\end{tikzcd}\t\t\t\n\t\t\\end{equation}\n\t\twhich in turn yields a monad $UU'F'F$ on $\\cX$. The unit and counit of the composite adjunction are given by\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t] \n\t\t\t\t\t(-1,-0.5) -- (-1,0.5) \n\t\t\t\t\t\tto [out=90, in =180] \n\t\t\t\t\t(-0.5,1) \n\t\t\t\t\t\tto [out=0, in =90] \n\t\t\t\t\t(0,0.5) -- (0,-0.5);\n\t\t\t\t\t\\draw[s] \n\t\t\t\t\t(-1.5,-0.5) -- (-1.5,0.5)\n\t\t\t\t\t\t\tto [out=90, in =180] \n\t\t\t\t\t(-0.5,1.5) \n\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t(0.5,0.5) -- (0.5,-0.5);\n\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\n\t\t\t\t\t(-1,-0.5) -- (-1,0.5) \n\t\t\t\t\t\tto [out=90, in =180] \n\t\t\t\t\t(-0.5,1) \n\t\t\t\t\t\tto [out=0, in =90] \n\t\t\t\t\t(0,0.5) -- (0,-0.5);\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-1.5,-0.5) -- (-1.5,0.5)\n\t\t\t\t\t\t\tto [out=90, in =180] \n\t\t\t\t\t(-0.5,1.5) \n\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t(0.5,0.5) -- (0.5,-0.5);\t\n\t\t\t\t\t\n\t\n\t\t\t\t\t\n\t\t\t\t\t\\path (-0.5,0.5) node {$\\eta'$};\n\t\t\t\t\t\\path (-0.5,1.75) node {$\\eta$};\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t\\text{and}\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-0.5,2) -- (-0.5,1) \n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(0,0.5) \n\t\t\t\t\t\tto [out=0, in =-90]\n\t\t\t\t\t(0.5,1) -- (0.5,2);\n\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,2) -- (-1,1) \n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=0, in =-90]\n\t\t\t\t\t(1,1) -- (1,2);\n\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\n\t\t\t\t\t(-1,2) node (v1) {} -- (-1,1) \n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(0,0) \n\t\t\t\t\t\tto [out=0, in =-90]\n\t\t\t\t\t(1,1) -- (1,2) -- (1.5,2) -- (1.5,-0.5) -- (-1.5,-0.5) -- (-1.5,2) -- (v1);\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-0.5,2) node (v1) {} -- (-0.5,1) \n\t\t\t\t\t\tto [out=-90, in =180]\n\t\t\t\t\t(0,0.5) \n\t\t\t\t\t\tto [out=0, in =-90]\n\t\t\t\t\t(0.5,1) -- (0.5,2) -- (1.5,2) -- (1.5,-0.5) -- (-1.5,-0.5) -- (-1.5,2) -- (v1);\n\n\n\n\t\t\t\t\t\\path (0,1) node {$\\varepsilon$};\n\t\t\t\t\t\\path (0,-0.25) node {$\\varepsilon'$};\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad.\t\t\t\n\t\t\\end{equation}\n\n\t\t\\begin{definition}\n\t\t\tSuppose we have the following pair of adjunctions between $\\cX$ and $\\cY$:\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\t\\cX \\ar[r,bend left,\"F\",\"\"{name=A, below}] \n\t\t\t\t\t\t& \n\t\t\t\t\t\t\\cY \\ar[l,bend left,\"U\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\t\t\\end{tikzcd}\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t,\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\t\\cX \\ar[r,bend left,\"F'\",\"\"{name=A, below}] \n\t\t\t\t\t\t& \n\t\t\t\t\t\t\\cY \\ar[l,bend left,\"U'\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\t\t\\end{tikzcd}\t\n\t\t\t\t\\end{aligned}\n\t\t\t\\end{equation}\n\t\t\talong with $2$-cells $u: U \\To U'$ and $f: F' \\To F$. Then $u$ and $f$ are said to be \\emph{adjoint} if\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[yscale=-1]\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-1) -- (1,-3)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.5,-3.5)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(2,-3) -- (2,-2.5);\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(2,-2.5) -- (2,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(2.5,-1.5)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(3,-2) -- (3,-4);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) -- (1,-3)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.5,-3.5)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(2,-3) -- (2,-2.5) -- (2,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(2.5,-1.5)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(3,-2) -- (3,-4) \n\t\t\t\t\t\t--(5,-4) -- (5,-1);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color = black] (2,-2.5) circle[radius=0.08];\n\t\t\t\t\t\t\\path (2.25,-2.5) node {$f$};\n\t\t\t\t\t\t\\path (3,-4.5) node {$U$};\n\t\t\t\t\t\t\\path (1,-0.5) node {$U'$};\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[yscale=-1]\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-1) -- (1,-2.5);\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1,-2.5) -- (1,-4);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) rectangle (3,-4);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color = black] (1,-2.5) circle[radius=0.08];\n\t\t\t\t\t\t\\path (0.75,-2.5) node {$u$};\n\t\t\t\t\t\t\\path (1,-4.5) node {$U$};\n\t\t\t\t\t\t\\path (1,-0.5) node {$U'$};\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t\\text{and}\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-1) -- (1,-3)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.5,-3.5)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(2,-3) -- (2,-2.5);\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(2,-2.5) -- (2,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(2.5,-1.5)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(3,-2) -- (3,-4);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) -- (1,-3)\n\t\t\t\t\t\t\tto [out= -90, in =180]\n\t\t\t\t\t\t(1.5,-3.5)\n\t\t\t\t\t\t\tto [out = 0, in =-90]\n\t\t\t\t\t\t(2,-3) -- (2,-2.5) -- (2,-2)\n\t\t\t\t\t\t\tto [out= 90, in =180]\n\t\t\t\t\t\t(2.5,-1.5)\n\t\t\t\t\t\t\tto [out=0, in =90]\n\t\t\t\t\t\t(3,-2) -- (3,-4) \n\t\t\t\t\t\t--(-1,-4) -- (-1,-1);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color = black] (2,-2.5) circle[radius=0.08];\n\t\t\t\t\t\t\\path (1.75,-2.5) node {$u$};\n\t\t\t\t\t\t\\path (3,-4.5) node {$F$};\n\t\t\t\t\t\t\\path (1,-0.5) node {$F'$};\t\t\t\t\t\t\n\t\t\t\t\t\t\\path (4,-2.5) node {$\\cX$};\n\t\t\t\t\t\t\\path (0,-2.5) node {$\\cY$};\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[t]\n\t\t\t\t\t\t(1,-1) -- (1,-2.5);\n\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t(1,-2.5) -- (1,-4);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t(1,-1) rectangle (-1,-4);\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\draw[fill, color = black] (1,-2.5) circle[radius=0.08];\n\t\t\t\t\t\t\\path (1.25,-2.5) node {$f$};\n\t\t\t\t\t\t\\path (1,-4.5) node {$F$};\n\t\t\t\t\t\t\\path (1,-0.5) node {$F'$};\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\qquad.\n\t\t\t\\end{equation}\n\t\t\tIf $u$ and $f$ are adjoint, then specifying one determines the other.\n\t\t\\end{definition}\n\n\t\tConsider the following square of 4 adjunctions where $F_i \\dashv U_i$ and $ F'_i \\dashv U'_i$:\n\t\t\\begin{equation}\n\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\t\t&\t\\cZ \\ar[dr, shift left, \"U'_0\"] \\ar[dl, shift left, \"U'_1\"]\t&\n\t\t\t\t\\\\\n\t\t\t\t\\cY_0 \\ar[ur, shift left, \"F'_1\"] \\ar[dr, shift left, \"U_0\"] \t&\t\t& \t\t\\cY_1 \\ar[dl, shift left, \"U_1\"] \\ar[ul, shift left, \"F'_0\"]\n\t\t\t\t\\\\\n\t\t\t\t\t\t\t&\t\\cX \\ar[ul, shift left, \"F_0\"]\t\\ar[ur, shift left, \"F_1\"]\t&\n\t\t\t\\end{tikzcd}\n\t\t\\end{equation}\n\t\tThis yields a pair of composite adjoints between $\\cX$ and $\\cZ$:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\\cX \\ar[r,bend left,\"F'_1 F_0\",\"\"{name=A, below}] \n\t\t\t\t\t& \n\t\t\t\t\t\\cZ \\ar[l,bend left,\"U_0 U'_1\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\t\\end{tikzcd}\t\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t,\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzcd}\n\t\t\t\t\t\\cX \\ar[r,bend left,\"F'_0 F_1\",\"\"{name=A, below}] \n\t\t\t\t\t& \n\t\t\t\t\t\\cZ \\ar[l,bend left,\"U_1 U'_0\",\"\"{name=B,above}] \\ar[from=A, to=B, symbol=\\dashv]\n\t\t\t\t\\end{tikzcd}\t\n\t\t\t\\end{aligned}\n\t\t\t\\qquad.\n\t\t\\end{equation}\n\t\tSuppose we have $u: U_0 U'_1 \\To U_1 U'_0: \\cZ \\to \\cX$ and $f: F'_0 F_1 \\To F'_1 F_0: \\cX \\to \\cZ$ such that $u$ and $f$ are adjoint:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[yscale=-1]\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1.5,-4) --(1.5,-2)\n\t\t\t\t\t\tto [out=90, in =0]\t\t\t\t\t\n\t\t\t\t\t(0.5,-1) \n\t\t\t\t\t\tto [out=180, in =90]\n\t\t\t\t\t(-0.5,-2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,-2.5) \t\t\t\t\t\n\t\t\t\t\t\tto[out=-90, in =0] \n\t\t\t\t\t(-1,-3.5)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-2,-2.5) -- (-2,-0.5);\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-4) -- (1,-2)\n\t\t\t\t\t\tto [out=90, in =0]\n\t\t\t\t\t(0.5,-1.5)\n\t\t\t\t\t\tto [out=180, in =0]\n\t\t\t\t\t(-1,-3)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-1.5,-2.5) -- (-1.5,-0.5);\n\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\n\t\t\t\t\t(2.5,-4) --\t\t\t\t\t\n\t\t\t\t\t(1.5,-4) --(1.5,-2)\n\t\t\t\t\t\tto [out=90, in =0]\t\t\t\t\t\n\t\t\t\t\t(0.5,-1) \n\t\t\t\t\t\tto [out=180, in =90]\n\t\t\t\t\t(-0.5,-2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,-2.5) \t\t\t\t\t\n\t\t\t\t\t\tto[out=-90, in =0] \n\t\t\t\t\t(-1,-3.5)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-2,-2.5) -- (-2,-0.5) -- (2.5,-0.5);\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\n\t\t\t\t\t(2.5,-4)--\t\t\t\t\t\n\t\t\t\t\t(1,-4) -- (1,-2)\n\t\t\t\t\t\tto [out=90, in =0]\n\t\t\t\t\t(0.5,-1.5)\n\t\t\t\t\t\tto [out=180, in =0]\n\t\t\t\t\t(-1,-3)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-1.5,-2.5) -- (-1.5,-0.5) -- (2.5,-0.5);\t\t\n\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (0,-2) node {$f$};\n\t\t\t\t\t\\path (1.5,-4.5) node {$U'_1$};\n\t\t\t\t\t\\path (-1.5,0) node {$U'_0$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (1,-4.5) node {$U_0$};\n\t\t\t\t\t\\path (-2,0) node {$U_1$};\t\t\n\t\t\t\t\t\\path (-2.5,-3.5) node {$\\cX$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (1.5,-1) node {$\\cZ$};\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\,\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,-0.5) to[out=-90, in =90] (-1,-4);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-1,-0.5) to[out=-90, in =90] (1,-4);\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(-1,-4) -- (2,-4) --(2,-0.5);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(1,-4) -- (2,-4) --(2,-0.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-0.5,-2.25) node {$u$};\n\t\t\t\t\t\\path (1,-4.5) node {$U'_0$};\n\t\t\t\t\t\\path (1,0) node {$U'_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (-1,-4.5) node {$U_1$};\n\t\t\t\t\t\\path (-1,0) node {$U_0$};\t\t\t\t\t\t\n\t\t\t\t\t%\\path (-1.5,-2.5) node {$\\cX$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (0,-1) node {$\\cY_0$};\t\n\t\t\t\t\t\\path (0,-3.5) node {$\\cY_1$};\t\n\t\t\t\t\t%\\path (1.5,-2.5) node {$Z$};\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t;\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,-4) -- (1,-2)\n\t\t\t\t\t\tto [out=90, in =0]\n\t\t\t\t\t(0.5,-1.5)\n\t\t\t\t\t\tto [out=180, in =0]\n\t\t\t\t\t(-1,-3)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-1.5,-2.5) -- (-1.5,-0.5);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1.5,-4) --(1.5,-2)\n\t\t\t\t\t\tto [out=90, in =0]\t\t\t\t\t\n\t\t\t\t\t(0.5,-1) \n\t\t\t\t\t\tto [out=180, in =90]\n\t\t\t\t\t(-0.5,-2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,-2.5) \t\t\t\t\t\n\t\t\t\t\t\tto[out=-90, in =0] \n\t\t\t\t\t(-1,-3.5)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-2,-2.5) -- (-2,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\n\t\t\t\t\t(-3,-4)--\t\t\t\t\t\n\t\t\t\t\t(1,-4) -- (1,-2)\n\t\t\t\t\t\tto [out=90, in =0]\n\t\t\t\t\t(0.5,-1.5)\n\t\t\t\t\t\tto [out=180, in =0]\n\t\t\t\t\t(-1,-3)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-1.5,-2.5) -- (-1.5,-0.5) -- (-3,-0.5);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\n\t\t\t\t\t(-3,-4) --\t\t\t\t\t\n\t\t\t\t\t(1.5,-4) --(1.5,-2)\n\t\t\t\t\t\tto [out=90, in =0]\t\t\t\t\t\n\t\t\t\t\t(0.5,-1) \n\t\t\t\t\t\tto [out=180, in =90]\n\t\t\t\t\t(-0.5,-2)\n\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t(0,-2.5) \t\t\t\t\t\n\t\t\t\t\t\tto[out=-90, in =0] \n\t\t\t\t\t(-1,-3.5)\n\t\t\t\t\t\tto [out=180, in =-90]\n\t\t\t\t\t(-2,-2.5) -- (-2,-0.5) -- (-3,-0.5);\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-0.5,-2.5) node {$u$};\n\t\t\t\t\t\\path (1.5,-4.5) node {$F_0$};\n\t\t\t\t\t\\path (-1.5,0) node {$F_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (1,-4.5) node {$F'_1$};\n\t\t\t\t\t\\path (-2,0) node {$F'_0$};\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\t\t\t\n\t\t\t\\end{aligned}\n\t\t\t\\,\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1,-0.5) to[out=-90, in =90] (-1,-4);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-1,-0.5) to[out=-90, in =90] (1,-4);\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(-1,-4) -- (-2,-4) --(-2,-0.5);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(1,-4) -- (-2,-4) --(-2,-0.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (0.5,-2.25) node {$f$};\n\t\t\t\t\t\\path (1,-4.5) node {$F_0$};\n\t\t\t\t\t\\path (1,0) node {$F_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (-1,-4.5) node {$F'_1$};\n\t\t\t\t\t\\path (-1,0) node {$F'_0$};\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad.\t\t\t\t\t\t\t\n\t\t\\end{equation}\n\t\tThen we may define a $2$-cell $e: F_1 U_0 \\To U'_0 F'_1: \\cY_0 \\to \\cY_1$ using either $u$ or $f$:\n\t\t\\begin{equation}\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-1,-0.5) to[out=-90, in =90] (1,-4);\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1,-0.5) to[out=-90, in =90] (-1,-4);\n\t\t\t\t\t\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(-1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(1,-4) -- (-1.5,-4) --(-1.5,-0.5);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(-1,-4) -- (1.5,-4) --(1.5,-0.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (0,-2) node {$e$};\n\t\t\t\t\t\\path (-1,-4.5) node {$U'_0$};\n\t\t\t\t\t\\path (-1,0) node {$F_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (1,-4.5) node {$F'_1$};\n\t\t\t\t\t\\path (1,0) node {$U_0$};\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\n\t\t\t\\qquad\n\t\t\t:=\n\t\t\t\\qquad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(1.5,-4) \n\t\t\t\t\t\tto[out=90, in =70] \n\t\t\t\t\t(0.25,-2.25) \n\t\t\t\t\t\tto [out=-110, in =-90]\n\t\t\t\t\t(-1,-0.5);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(-0.5,-0.5) to[out=-90, in =90] (1,-4);\n\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1.5,-4) \n\t\t\t\t\t\tto[out=90, in =70] \n\t\t\t\t\t(0.25,-2.25) \n\t\t\t\t\t\tto [out=-110, in =-90]\n\t\t\t\t\t(-1,-0.5)-- (-1.5,-0.5) --(-1.5,-4);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(-0.5,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(1,-4) -- (2,-4) --(2,-0.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (0,-2.25) node {$u$};\n\t\t\t\t\t\\path (1,-4.5) node {$U'_0$};\n\t\t\t\t\t\\path (-1,0) node {$F_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (1.5,-4.5) node {$F'_1$};\n\t\t\t\t\t\\path (-0.5,0) node {$U_0$};\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\t\t\t\n\t\t\t\\end{aligned}\n\t\t\t\\quad\n\t\t\t=\n\t\t\t\\quad\n\t\t\t\\begin{aligned}\n\t\t\t\t\\begin{tikzpicture}[yscale=-1]\n\t\t\t\t\t\\draw[t]\n\t\t\t\t\t(-0.5,-0.5) to[out=-90, in =90] (1,-4);\t\t\t\t\n\t\t\t\t\t\\draw[s]\n\t\t\t\t\t(1.5,-4) \n\t\t\t\t\t\tto[out=90, in =70] \n\t\t\t\t\t(0.25,-2.25) \n\t\t\t\t\t\tto [out=-110, in =-90]\n\t\t\t\t\t(-1,-0.5);\n\t\t\t\t\t\n\n\n\t\t\t\t\t\\fill[very nearly transparent, magenta]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(1.5,-4) \n\t\t\t\t\t\tto[out=90, in =70] \n\t\t\t\t\t(0.25,-2.25) \n\t\t\t\t\t\tto [out=-110, in =-90]\n\t\t\t\t\t(-1,-0.5)-- (2,-0.5) --(2,-4);\t\t\n\t\t\t\t\t\\fill[very nearly transparent, cyan]\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t(-0.5,-0.5) \n\t\t\t\t\t\tto[out=-90, in =90] \n\t\t\t\t\t(1,-4) -- (-1.5,-4) --(-1.5,-0.5);\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (0.5,-2.25) node {$f$};\n\t\t\t\t\t\\path (-1,0) node {$U'_0$};\n\t\t\t\t\t\\path (1,-4.5) node {$F_1$};\t\t\t\t\t\t\n\t\t\t\t\t\\path (-0.5,0) node {$F'_1$};\n\t\t\t\t\t\\path (1.5,-4.5) node {$U_0$};\t\t\t\t\t\t\t\t\n\t\t\t\t\\end{tikzpicture}\n\t\t\t\\end{aligned}\t\t\n\t\t\t\\quad.\t\t\t\t\n\t\t\\end{equation}\n\t\tIf $u,f$ are invertible $2$-cells, we may use their inverses $u^{-1},f^{-1}$ to construct $e': F_0U_1 \\To U'_1 F'_0$ in a similar fashion. Finally, if $e$ is invertible, its inverse is $e^{-1}: U'_0F'_1 \\To F_1 U_0$.  We summarize these $2$-cells into the following diagram:\n\t\t\\begin{equation}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(3,2.5) -- (-1.5,-2);\n\t\t\t\t\\draw[t] \n\t\t\t\t\t(0.5,2.5) -- (-4,-2);\n\t\t\t\t\n\t\t\t\t\\draw [s]\n\t\t\t\t\t(-1.5,2.5) -- (3,-2);\n\t\t\t\t\\draw[s] (-4,2.5) -- (0.5,-2);\n\n\t\t\t\t\\fill[very nearly transparent, cyan]\n\t\t\t\t\t(3,2.5) -- (-1.5,-2)\n\t\t\t\t\t\tto\n\t\t\t\t\t(-4,-2) -- (0.5,2.5);\n\n\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t(-1.5,2.5)  -- (3,-2)\n\t\t\t\t\t\t-- (0.5,-2) --  (-4,2.5);\n\t\t\t\t\n\t\t\t\t\\path (-2.25,0.25) node {$u$};\n\t\t\t\t\\path  (1.25,0.25) node {$f$};\n\t\t\t\t\\path (-0.5,-1.5)node {$e^{-1}$};\n\t\t\t\t\\path  (-0.5,2) node {$e'$};\n\t\t\t\t\\path  (-4,3) node {$U_0$};\n\t\t\t\t\\path  (-1.5,3) node {$F_0$};\n\t\t\t\t\\path  (0.5,3) node {$U_1$};\n\t\t\t\t\\path  (3,3) node {$F_1$};\n\t\t\t\t\\path  (-1.5,-0.5) node {$U'_0$};\n\t\t\t\t\\path  (0.5,1) node {$F'_0$};\n\t\t\t\t\\path  (-1.5,1) node {$U'_1$};\n\t\t\t\t\\path  (0.5,-0.5) node {$F'_1$};\t\t\t\t\t\n\t\t\t\\end{tikzpicture}\t\t\n\t\t\\end{equation}\n\t\tWhen drawn in this manner, it is easy to believe that such a square of 4 adjunctions, with $u,f, e$ invertible\\footnote{Since $f$ is adjoint to $u$, it will be invertible if $u$ is. So we would only need to check invertibility of $u$ and $e$.}, leads to a distributive law.\n\t% \\vfill\n\t% \\pagebreak\n\t\\subsection{Algebras for a monad}\n\t\t\\begin{definition} \n\t\t\tLet $(\\cX,S,\\eta^S,\\mu^S)$ be a monad. \n\t\t\tAn \\emph{incoming} or \\emph{left $S$-algebra} $(G,\\lambda)$ consists of a $1$-cell $G: \\cY \\to \\cX$ and a  $2$-cell $\\lambda: SG \\To G$\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0.5) node (U) {$G$};\n\t\t\t\t\t\\path (0,-1.5) node {$\\cY$};\n\t\t\t\t\t\\path (-2.5,-1.5) node {$\\cX$};\n\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t(U)\n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-1.25,-1.75) node {$\\lambda$};\t\n\t\t\t\t\t\\fill[nearly transparent, gray] (U.south) rectangle (1,-3);\t\t\t\n\t\t\t\t\\end{tikzpicture}\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tsuch that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\n\t\t\t\t\t\t\\draw[fill, color=red] (-2,-0.5) circle (.08);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t\\text{ and }\t\t\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-3,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =150]\n\t\t\t\t\t\t(-2.5,-0.5)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(-2,0.5);\t\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2.5,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-1);\t\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-3,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2.5);\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\\end{equation}\n\t\t\tWe call $\\lambda$ a \\emph{left action} of $S$ on $G$. To emphasize the source of $G$, we may call $G$ an $S$-algebra \\emph{from $\\cY$}.\n\n\t\t\tSimilarly, an \\emph{outgoing} or \\emph{right $S$-algebra} $(G,\\rho)$ consists of $G: \\cX \\to \\cY$ and $\\rho: GS \\To G$\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\\path (-1,0.5) node (U) {$G$};\n\t\t\t\t\t\\path (0,-1.5) node {$\\cY$};\n\t\t\t\t\t\\path (-2.5,-1.5) node {$\\cX$};\n\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t(U)\n\t\t\t\t\t\tto \n\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-1.25,-1.75) node {$\\rho$};\t\n\t\t\t\t\t\\fill[nearly transparent, gray] (U.south) rectangle (1,-3);\t\t\t\n\t\t\t\t\\end{tikzpicture}\t\t\t\t\n\t\t\t\\end{equation}\t\t\t\n\t\t\tsatisfying the analogous equalities: \n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\n\t\t\t\t\t\t\\draw[fill, color=red] (-2,-0.5) circle (.08);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t\\text{ and }\t\t\t\t\t\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-3,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =150]\n\t\t\t\t\t\t(-2.5,-0.5)\n\t\t\t\t\t\t\tto [out=30, in =-90]\n\t\t\t\t\t\t(-2,0.5);\t\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2.5,-0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}[xscale=-1]\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-2,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-1);\t\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(-3,0.5)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2.5);\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(-1,0.5)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(-1,-3);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (-1,0.5) rectangle (1,-3);\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\t\t\t\t\t\t\t\n\t\t\t\t\\end{aligned}\n\t\t\t\\end{equation}\t\t\t\n\t\t\tWe call $\\rho$ a \\emph{right $S$-action}, and $G$ an $S$-algebra \\emph{to} $\\cY$.\n\t\t\\end{definition}\n\n\t\t\\begin{example}\n\t\t\tLet $F \\dashv U$, and let $S = UF$ be the resulting monad. Then $U$ is a left $S$-algebra, with a canonical left action $U \\varepsilon : SU \\To U$ induced by the counit of the adjunction:\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\t\t\\path (0,0) node (F) {};\n\t\t\t\t\t\t\t\\path (0,-1.5) node {};\t\t\n\n\t\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t\t(U.center) \n\t\t\t\t\t\t\t\tto \n\t\t\t\t\t\t\t(-1,-3);\t\n\n\t\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t\t(-1,-2);\t\n\t\t\t\t\t\n\n\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta] (U) rectangle (0,-3);\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad\n\t\t\t\t:=\n\t\t\t\t\\qquad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\t\\path (-1,0) node (U) {};\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\draw [s] \n\t\t\t\t\t\t\t(U.center) \n\t\t\t\t\t\t\t\tto \n\t\t\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\t\t\tto [out =-90, in =-90]\n\t\t\t\t\t\t\t(-2,0);\t\n\n\t\t\t\t\t\t\t\\draw[s]\n\t\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t\t(-1.5,-3);\t\n\n\t\t\t\t\t\t\t\\fill[very nearly transparent, magenta]\n\t\t\t\t\t\t\t(-2.5,0)\n\t\t\t\t\t\t\t\tto [out=-90, in =90]\n\t\t\t\t\t\t\t(-1.5,-3)\n\t\t\t\t\t\t\t\tto\n\t\t\t\t\t\t\t(0,-3)\n\t\t\t\t\t\t\t\tto\n\t\t\t\t\t\t\t(0,0)\n\t\t\t\t\t\t\t\tto\n\t\t\t\t\t\t\t(U.center)\n\t\t\t\t\t\t\t\tto\n\t\t\t\t\t\t\t(-1,-1.5)\n\t\t\t\t\t\t\t\tto [out=-90, in =-90]\n\t\t\t\t\t\t\t(-2,0);\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\n\t\t\t\t\\qquad .\t\t\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tThe diagrams that prove that this is an action are very similar to those that prove that $UF$ is a monad.\n\n\t\t\tSimilarly, $F$ is a right $S$-algebra with a canonical right action $\\varepsilon F: FS \\To F$.\t\t\t\n\t\t\\end{example}\n\t\t\n\t\t\\begin{definition}\n\t\t\tLet $(\\cX,S)$ be a monad, and fix a $0$-cell $\\cY$. Let $(G,\\lambda)$, $(G', \\lambda')$ be left $S$-algebras such that $G,G': \\cY \\to \\cX$. \n\t\t\tA \\emph{morphism of left $S$-algebras from $\\cY$} is a $2$-cell $\\sigma: G \\To G'$ such that\n\t\t\t\\begin{equation}\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\t\\path (-1,0.5) node (U) {$G$};\n\t\t\t\t\t\t\\path (-1,-3) node (V) {$G'$};\n\t\t\t\t\t\t\\path (1,-3) node (W) {\\phantom{$G'$}};\n\t\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t\t(S)\n\t\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t\t(-1,-2);\t\n\n\t\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t\t(U)\n\t\t\t\t\t\t\tto \n\t\t\t\t\t\t(V);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\\path (-0.5,-2) node {$\\lambda'$};\n\t\t\t\t\t\t\\path (-0.5,-1) node {$\\sigma$};\t\t\t\t\t\t\n\t\t\t\t\t\t\\fill[nearly transparent, gray] (U.south) rectangle (W.north);\n\t\t\t\t\t\t\\draw[fill, black] (-1,-1) circle [radius=0.08];\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\n\t\t\t\t\\quad\n\t\t\t\t=\n\t\t\t\t\\quad\n\t\t\t\t\\begin{aligned}\n\t\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\path (-1,0.5) node (U) {$G$};\n\t\t\t\t\t\\path (-1,-3) node (V) {$G'$};\n\t\t\t\t\t\\path (1,-3) node (W) {\\phantom{$G'$}};\n\t\t\t\t\t\\path (-2.5,0.5) node (S) {$S$};\n\t\t\t\t\t\n\n\t\t\t\t\t\\draw[s0]\n\t\t\t\t\t(S)\n\t\t\t\t\t\tto [out = -90, in =90]\n\t\t\t\t\t(-1,-1.5);\t\n\n\t\t\t\t\t\\draw [f0] \n\t\t\t\t\t(U)\n\t\t\t\t\t\tto \n\t\t\t\t\t(V);\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\\path (-0.5,-1) node {$\\lambda$};\t\n\t\t\t\t\t\\path (-0.5,-2) node {$\\sigma$};\t\t\t\t\t\t\n\t\t\t\t\t\\fill[nearly transparent, gray] (U.south) rectangle (W.north);\n\t\t\t\t\t\\draw[fill, black] (-1,-2) circle [radius=0.08];\t\t\t\n\t\t\t\t\t\\end{tikzpicture}\n\t\t\t\t\\end{aligned}\t\n\t\t\t\t\\quad.\t\t\t\t\t\t\t\n\t\t\t\\end{equation}\n\t\t\tLeft $S$-algebras from $\\cY$ and their morphisms form a category, which we call $\\Alg^S(\\cY)$.\n\n\t\t\tWe may define morphisms of right $S$-algebras to $\\cY$ in a similar manner. They form a category $\\Alg_S(\\cY)$.\n\t\t\\end{definition}\n\n\t\tFor each $0$-cell $\\cY$ in $\\cK$, the identity $1$-cell $1_{\\cY}$ is a monad on $\\cY$. A left $S$-algebra $(G,\\lambda)$ is precisely a monad functor $(G,\\lambda): (\\cY,1_\\cY) \\to (\\cX,S)$. Similarly, a right $S$-algebra $(G,\\rho)$ is precisely a monad opfunctor $(G,\\rho): (\\cX,S) \\to (\\cY,1_\\cY)$. Morphisms of left or right $S$-algebras are then monad (op)functor transformations. Thus, we could have defined the $1$-categories of left and right algebras via:\n\t\t\\begin{align}\n\t\t\t\\Alg^S(\\cY) &:= \\Mnd(\\cK)\\big((\\cY,1_\\cY), (\\cX, S)\\big), \\\\\n\t\t\t\\Alg_S(\\cY) &:= \\Mnd^{op}(\\cK)\\big((\\cX, S), (\\cY,1_\\cY)\\big) .\n\t\t\\end{align}\n\n\t\\subsection{`Extension of scalars' for monads}\n\n\n\n\\bibliography{biblio}\n\\bibliographystyle{plain}\n\n\\end{document}", "meta": {"hexsha": "01c3fb88ccf3285836902bcad9f5b44db9cf992c", "size": 152743, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "distributive/dist_rewrite.tex", "max_stars_repo_name": "wongliangze/sheaves.github.io", "max_stars_repo_head_hexsha": "cbad3f1b27a881e0adc4912e301d1f79ac03f124", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-01-11T06:01:04.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-24T08:52:32.000Z", "max_issues_repo_path": "distributive/dist_rewrite.tex", "max_issues_repo_name": "wongliangze/sheaves.github.io", "max_issues_repo_head_hexsha": "cbad3f1b27a881e0adc4912e301d1f79ac03f124", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "distributive/dist_rewrite.tex", "max_forks_repo_name": "wongliangze/sheaves.github.io", "max_forks_repo_head_hexsha": "cbad3f1b27a881e0adc4912e301d1f79ac03f124", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-09-15T04:48:39.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-12T03:20:55.000Z", "avg_line_length": 23.3266646304, "max_line_length": 581, "alphanum_fraction": 0.4490614955, "num_tokens": 67540, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.41849913573018516}}
{"text": "\\section{Introduction} % (fold)\n\\label{sec:introduction}\nThere has now been over 60 years since Markov decision processes have proven to\nbe useful in decision making and that associated \\enquote{\\textit{models have \ngained recognition in such diverse fields as ecology, economics,\nand communications engineering}}~\\cite{puterman2014markov}.\nThey are therefore an important topic to study and this report presents\nour key results applied in the framework of a \\emph{Snakes and Ladders} game.\n\nThis report will first present in section~\\ref{sec:model_and_strategy},\na detailed description of our Markov \\emph{model}\nas well as the strategy we followed to get the optimal choice of dice.\nThen, section~\\ref{sec:implementation} will present our concrete \\emph{implementation}\nof the game and its simulations.\nFinally, the most relevant results and strategies comparison as well as\nconclusion and further work discussion will be described in sections~\\ref{sec:results}\nand~\\ref{sec:conclusion}.\n\n% section introduction (end)", "meta": {"hexsha": "cb6b1fc3bae2a44344fb1952e9319c2f3bb2e50d", "size": 1019, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/src/intro.tex", "max_stars_repo_name": "qlete/markov-decision", "max_stars_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-03-21T13:48:00.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-21T13:48:00.000Z", "max_issues_repo_path": "report/src/intro.tex", "max_issues_repo_name": "qlete/markov-decision", "max_issues_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/src/intro.tex", "max_forks_repo_name": "qlete/markov-decision", "max_forks_repo_head_hexsha": "9043e8e014b165dff2ebe9be77f8630d7b8d2237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.6315789474, "max_line_length": 86, "alphanum_fraction": 0.8076545633, "num_tokens": 233, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526660244838, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.4183399695847021}}
{"text": "\\chapter{Preliminary work}\n\\label{chapter:pre_work}\nIn order to compute the metrics explained in the previous chapter, it is necessary to know the position and orientation (pose) of the contact points located on the phalanges of Vizzy.\n\\par\n\nIt is important to note that through the Denavit Hartenberg parameters and the angles of rotation of each joint it is possible to obtain the position and orientation of each sensor in 3D coordinates.\n\n\\par\nIt is known that the tactile sensors have incorporated sensors with Hall-effect that detects changes in the magnetic field caused, either by the magnet in the elastomer or by the Earth's magnetic field.\nIn the case where the sensors are not pressed, the influence of the magnetic field is constant, leaving only the Earth's magnetic field responsible for the change of the magnetic field of the sensor.\n\n\\par\n\nThe idea that came up was that, through the magnetic field readings, be able to discover the position and orientation of the phalanges. To test this idea, an experiment was carried out, in which it consists on obtaining data of the magnetic fields of each sensor placed in each phalanx and the angle of rotation between that same phalanx and the palm of the hand.\nWith these data, a relationship (through a regression) between each of the 3D components of the magnetic field from the sensor and its angle of rotation relative to the hand will be inferred.\n\\par\n\nTo obtain the ground-truth of the rotation angles, it was used \\textit{Aruco} markers that were placed on each of the phalanges. \\textbf{(visible in figure xxx).}\nIt is important to note that the first tests were performed with only one marker on each phalanx, which led to poses with a lot of uncertainties and in some cases the data did not make great sense. To correct these uncertainties were used markers boards ( 4 single markers in a column), which led to results with almost no uncertainty.\n\n\\par\nThese boards give their poses, which with the help of a function of ROS transformations it is obtained the angles of rotation between the board on the phalanx and the board on the anterior phalanx (towards the palm), this is done for each one phalanx of the index finger. These rotation angles will coincide with those of the joints.\n\n\\par\n\nIn the experiments that took place, the palm of Vizzy's hand was turned in the direction of the ground (i.e. the palm of the hand was parallel to the plane of the ground).\nThen, starting from the point where the hand was open, Vizzy began to close his index finger to its final limit, later he opened his finger again until it was fully extended.\nFinally, the data of the tactile sensors and the joint angles were analyzed.\n\nIn order to understand the graphics of the 3D components of the magnetic field as a function of the angles of rotation, the numbering of the finger sensors in \\textbf{Figure xxx}.\n\\par\nThe graphics of the magnetic field components as a function of the angles of rotation are shown in Figures \\ref{fig:1and2Joint} and \\ref{fig:3Joint}. It is noted that there is only a direct relationship between the components of the sensors of each phalanx and the angle of rotation of its previous joint.\n\nIt is yet visible that there are components with more noise than others, such is the example of the Y component of the magnetic field of the Figures \\ref{fig:2Joint_5sensor} and \\ref{fig:3Joint_4sensor}.\nIt is important to note that in this report the equations of these graphics have not yet been defined because it is still necessary to remove the effect of the earth's magnetic field in relation to the orientation of the pulse.\nTo take this effect, will be placed an inertial sensor will be placed on the head of Vizzy. Moreover this work will be developed during the thesis.\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[width=1\\linewidth]{images/1Joint_3sensor.png}\n  \\caption{\\nth{1} Joint and the \\nth{3} Tactile Sensor}\n  \\label{fig:fig:1Joint_3sensor}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[width=1\\linewidth]{images/2Joint_5sensor.png}\n  \\caption{\\nth{2} Joint and the \\nth{5} Tactile Sensor}\n  \\label{fig:2Joint_5sensor}\n\\end{subfigure}\n\\caption{Graphics of the magnetic field components as a function of the \\nth{1} and \\nth{2} rotation angles }\n\\label{fig:1and2Joint}\n\\end{figure}\n\n\\begin{figure}\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[width=1\\linewidth]{images/3Joint_4sensor.png}\n  \\caption{\\nth{3} Joint and the \\nth{4} Tactile Sensor}\n  \\label{fig:3Joint_4sensor}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[width=1\\linewidth]{images/3Joint_6sensor.png}\n  \\caption{\\nth{3} Joint and the \\nth{6} Tactile Sensor}\n  \\label{fig:3Joint_6sensor}\n\\end{subfigure}\n\\caption{Graphics of the magnetic field components as a function of the \\nth{3} rotation angle }\n\\label{fig:3Joint}\n\\end{figure}\n\n", "meta": {"hexsha": "b616bf48269d3a6445162cdf18a44a9b4c0c3d1b", "size": 4946, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/pre_work.tex", "max_stars_repo_name": "LuisMAALMEIDA/IIEEC", "max_stars_repo_head_hexsha": "479694d56de161909c614c90931fae9ef45e91c7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/pre_work.tex", "max_issues_repo_name": "LuisMAALMEIDA/IIEEC", "max_issues_repo_head_hexsha": "479694d56de161909c614c90931fae9ef45e91c7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/pre_work.tex", "max_forks_repo_name": "LuisMAALMEIDA/IIEEC", "max_forks_repo_head_hexsha": "479694d56de161909c614c90931fae9ef45e91c7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.7534246575, "max_line_length": 363, "alphanum_fraction": 0.7875050546, "num_tokens": 1220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832805, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4183085528653654}}
{"text": " \\documentclass[../ewet_cwc_report.tex]{subfiles}\n\n\\begin{document}\n\n\\section{Electrical Design and Controls}\n\\subsection{Introduction}\n\n\\noindent\nIn the small-scale turbine design, it is critical to identify\nthe type of the generator that would be used through the\ndesign process because mechanical designs and modeling are\ntime consuming and constrained by the academic year's available\nman hours. It is important to limit complete change of design\ncourse to one or two instances and even that is only affordable\nat the initial stage of the design. The team did not have a\nready generator solution from previous project and had no\npractical experience in assessing the scale or the needed\nparameters in selecting the generator for such a miniature\ndesign. The only notion that was passed down from previous\nteam was the understanding of the electrical motor KV rating\nand importance of minimizing cogging torque at cut in speed.\nThus, these became the starting point parameters in the\ngenerator selection. The team has encountered several\nchallenges over the power electronics selection process.\nIdeas have been tried and discarded, some because component\nselection process was not taking into the account the\ncomponent's self-power demand, others because the nature of the\ncomponent's operation was not fundamentally understood. In some\ninstances, where a solution was not found by direct approach,\nlike in voltage regulation attempts, the team has paused on that\nfront and shifted attention to better understood sections of the\ndesign, allowing for continuous progress. This approach proved\nto be very effective, and more elegant and natural solutions\nwere found as a result.\n\n\\subsection{Generator and Load}\n\n\\noindent\nFaraday's Law indicates that \\emph{``Any change in the magnetic\n  environment of a coil of wire will cause a voltage (emf) to be\n  induced in the coil''}. Formulation \\eqref{eq:emf} demonstrates\nthe physical relationship described by Faraday using\nmathematical interpretation,\n\n\\begin{equation}\n  \\text{emf} = -N \\frac{\\Delta \\phi}{\\Delta t}\n  \\text{\\,,}\n  \\label{eq:emf}\n\\end{equation}\n\n\\noindent\nwhere $N$ represents the number of turns in the coil,\n$\\Delta\\phi$ represents a change in magnetic flux over time,\nand $\\Delta t$ is the change in time.\n\nMagnetic flux is given by formulation \\eqref{eq:flux},\n\\begin{equation}\n  \\phi = BA \\sin\\theta\n  \\text{\\,,}\n  \\label{eq:flux}\n\\end{equation}\n\n\\noindent\nwhere $B$ representing magnetic field produced by opposing\npermanent magnets of the rotors, $A$ represents area of the\ncoiled wire in the stator and $\\theta$ represents the angle\nbetween the coil area plane and the magnetic field and since\nthe coil area and the magnetic field are orthogonal to each\nother in the AFPMG.\n\nFormulation \\eqref{eq:flux} can be restated as\n\\begin{equation}\n  \\phi = BA\n  \\text{\\,.}\n  \\label{eq:flux-simple}\n\\end{equation}\n\nAccording to Lenz's law, the negative sign of\n\\eqref{eq:emf} indicates that the current produced by the\nchange in magnetic flux creates its own magnetic field that\nopposes the change in flux that produced it. When applying this\nnotion to a generator this indicates that current induced in the\ngenerator coils will provide an opposing force to the one that\nis responsible for the rotation of the generator shaft. Since\nthe force is rotational it could be restated in terms of opposing\ntorque $\\tau_G$ and compared against aerodynamic torque\n$\\tau_W$ extracted from the wind,\n\n\\begin{equation}\n  \\tau_W = \\frac{P_W}{\\omega_{rotor}}\n  = \\frac{\\rho\\pi R^3 C_p\\paren{\\lambda, \\theta} V_W^2}{2\\lambda}\n  \\text{\\,,}\n  \\label{eq:tau-wind}\n\\end{equation}\nwhere $P_W$, in watts, is the power available in the wind and\nis given by \\eqref{eq:power-wind}, $\\omega_{rotor}$ is the\nrotational speed in (\\unit{rad\\per\\s}), $\\rho$ is the air\ndensity in (kg / m3), $C_p$ is the power coefficient expressed\nas a function of the tip speed ratio and pitch angle and is\ngiven by Eqs. \\eqref{eq:tau-r} and \\eqref{eq:lambda-i}:\n\n\\begin{equation}\n  P_w = \\frac{\\rho\\pi R^2 C_p\\paren{\\lambda, \\theta} V_W^2}{2}\\\n  \\text{\\,,}\n  \\label{eq:power-wind}\n\\end{equation}\n\n\\begin{alignat}{3}\n  \\tau_R & = \\frac{P_W \\times C_p}{\\omega_{rotor}}\n  C_p\\paren{\\lambda, \\theta}                               \\\\\n         & = 0.22\\paren{\\frac{116}{\\lambda_i} - 0.040 - 5}\n  e^\\frac{-12.5}{\\lambda_i}\n  \\text{\\,,}\n  \\label{eq:tau-r}\n\\end{alignat}\n\n\\begin{equation}\n  \\lambda_i = \\paren{\\frac{1}{\\lambda + 0.8} -\n    \\frac{0.035}{\\theta^3 + 1}}^{-1}\n  \\text{\\,.}\n  \\label{eq:lambda-i}\n\\end{equation}\n\nIn Equation \\eqref{eq:power-wind}, $R$ is the wind turbine\nrotor radius in meters, $V_W$ is the wind velocity in\n\\unit{\\meter\\per\\s}, and $\\lambda$ is the tip speed ratio (TSR)\ngiven by Equation \\eqref{eq:lambda},\n\n\\begin{equation}\n  \\lambda = \\frac{R \\omega_{rotor}}{V_W}\n  \\text{\\,.}\n  \\label{eq:lambda}\n\\end{equation}\n\nIt could be further inferred that wind turbine operation could\nbe imagined as a system of two opposing torques $\\tau_W$ and\n$\\tau_G$ whenever torques are equal the system is in\nequilibrium and is generating constant power. Any time\n$\\tau_W$ changes in response to change in $V_W$, (for the\nexperimental environment $\\rho$ is assumed constant) there\nexists a new equilibrium state of $\\tau_W$ and $\\tau_G$\ntorques. Simply put, anytime $V_W$ increases it creates\nconditions for a new and greater power equilibrium state, this\nmeans the resistance of the load could be decreased, which will\nincrease the current flow, and thus more power could be\nextracted from the wind.\n\nThe KV rating of the generator is responsible for predicting\nthe magnitude of the generated voltage as a function of the\nrotor speed. In the wind turbine controls it is sometimes\nimportant to maintain relatively low rotational speed and at\nthe same time maintain voltage magnitude that is high enough to\nkeep the microcontroller active. Equations \\eqref{eq:KV} and\n\\eqref{eq:RPM-KV} show this relationship,\n\n\\begin{equation}\n  \\text{KV}_{rating} = \\frac{\\text{rotor speed}}{\\text{voltage}}\n  \\text{\\,,}\n  \\label{eq:KV}\n\\end{equation}\n\n\\begin{equation}\n  V = \\frac{\\text{RPM}}{\\text{KV}_{rating}}\n  \\text{\\,.}\n  \\label{eq:RPM-KV}\n\\end{equation}\n\nCogging torque is a magnetic interaction between the iron teeth\nof the stator and magnets of the rotor in a brushless DC motor\nfor instance. The team did not know how to assess the magnitude\nof such torque and its effect on the cut in speed of the future\nturbine so naturally attempts were made to find a motor with\nlittle to no cogging torque. This led to the discovery of the\naxial flux permanent magnet motor (AFPMM) which could be used\nas a three phase DC generator if coupled with a three-phase\nfull rectifier circuit.\n\nFigure \\ref{img:stator_rotor} shows the single rotor and the\nstator of the 12 pole 9 coil AFPMG used in the prototype. A set\nof two motors were purchased for initial evaluation of the KV\nrating. Using dynamometer, it was experimentally determined\nthat the KV rating of the single motor was 96. This was very\nlow comparing to all other available options that also had the\nappropriate dimensional scale. Evaluating the mechanical\nconstruction of the motor's design, it was observed that it\nappeared to be relatively simple to create a stack of these\nmotors coupled by a single axle. Once the team recognized the\nflexibility in the connection schemes, ability to reduce the\nKV rating to 24 by stacking motors on the single axle, and the\nvirtual absence of cogging torque in this design, two more\nmotors were immediately ordered.\n\\begin{figure}[th]\n  \\centering\n  \\includegraphics[width=0.4\\textwidth]{../_images/stator_rotor.png}\n  \\caption{Stator and rotor}\n  \\label{img:stator_rotor}\n\\end{figure}\n\nFigure \\ref{img:housing} demonstrates the midterm version of\nthe generator design. The housing assembly consists of five\nmain parts: (b and c) front and back bearing supports,\n(d) housing block, (e) stabilizer bar, and (f) yaw pivot\nassembly.\n\n\\begin{figure}[th]\n  \\centering\n  \\includegraphics[width=0.4\\textwidth]{../_images/housing.png}\n  \\caption{Housing assembly}\n  \\label{img:housing}\n\\end{figure}\n\nThe drivetrain assembly is shown in Figure \\ref{img:drivetrain}.\nIt is composed of the central axle (a) that connects four pairs\nof inline rotors (b and c) and two pairs of stators (d and e).\nThe stators are supported by the housing assembly and are\nindependent of the rotation of the rotor assembly. Connected to\neach pair of stators are housing assemblies that contain two\npairs of internally connected full bridge rectifiers potted in\nepoxy. Once the generator selection was settled on, mechanical\ndesign and power electronics work began.\n\\begin{figure}[th]\n  \\centering\n  \\includegraphics[width=0.4\\textwidth]{../_images/drivetrain.png}\n  \\caption{Drivetrain assembly}\n  \\label{img:drivetrain}\n\\end{figure}\n\nFigure \\ref{img:schematic} shows the systems power distribution\nof the most recent design review.\n\nThe load chosen is constructed of a \\qty{200}{\\W} variable\nresistor with coils and contacts throughout to select the\ndesired resistance for the appropriate wind speed and\nscenario. Supplemental resistance was needed for the lower wind\nspeed and lower load conditions, so additional resistors are\ncombined in series to acquire these values. The resistance\nvalues used in the load box vary from \\qty{45}{\\ohm} up to\n\\qty{420}{\\ohm}. A relay bank controlled by a separate Arduino\nfrom the turbine is used to select the load by closing the\ncontacts on the desired resistor value. The Arduino is\nreceiving commands from the turbine through an optically\nisolated TX and RX line. This Arduino will send commands to\nthe turbine if a manual shutdown is required.\n\\begin{figure}[bh]\n  \\centering\n  \\includegraphics[width=\\textwidth]{../_images/schematic.png}\n  \\caption{Pictorial schematic of the turbine's control and load\n    power distribution}\n  \\label{img:schematic}\n\\end{figure}\n\n\\subsection{Control Theory}\nThe pitch control scheme is made up of a methodology called\nFuzzy Logic, as shown in Figure \\ref{img:control}. The\ntachometer measures the RPM of the turbine\nand then the controller determines how far away that the\ncurrent RPM is from the desired RPM of the turbine. The\nprevious RPM record is also taken into consideration when\ndetermining whether to make a pitch adjustment or not. If the\nturbine is rotating too slowly, but is speeding up, the\nalgorithm will wait another cycle to see if the pitch has\ncontinued to increase the RPM, and if not, it will then make\nan appropriate adjustment based on how far away from the\ndesired RPM it is. If the turbine RPM is within acceptable\nbounds to the desired RPM, then no adjustments will be made.\n\nThe tachometer utilizes a Hall effect sensor that counts the\nnumber of pulses it receives, which happens once per\nrevolution, and calculated the period it takes for 20\nrevolutions to occur and determines the RPM from this math.\nThere is a timeout scenario where if 20 revolutions have not\nbeen completed in 5 seconds the loop will break and the RPM\nwill still be calculated, just with less accuracy because the\ntime period over fewer revolutions will be averaged.\n\n\\onecolumn\n\\begin{figure}[th]\n  \\centering\n  \\includegraphics[width=\\textwidth]{../_images/control.png}\n  \\caption{Canonical control model}\n  \\label{img:control}\n\\end{figure}\n\\twocolumn\n\nA current sensor must be used to determine if the load has\nbeen disconnected from the turbine. An ADA260 module\ncommunicates with the Arduino via an I2C connection. When the\nload goes above \\qty{50}{\\mA} the load is detected, and any\ndrop below that will trigger the pitch to adjust to slow the\nblades down to a stop. The minimum load expected at a wind\nspeed of \\qty{5}{\\m\\per\\s} is around \\qty{80}{\\mA} so this is\nnot something that could be accidentally tripped.\n\nThe wind speed sensor determines the wind speed utilizing the\n``hot wire'' method. This method heats up a wire and as the\nwind passes by, it cools the wire off changing its resistance\nand the voltage across it. The voltage is read by the Arduino\nand then the Arduino can determine the wind speed the sensor is\nexperiencing.\n\nDelays are important for the pitch control system because it\ntakes some time for the system to stabilize and the RPM to\ncease any fluctuations. The problem with using the built-in\ndelay functions is that the Arduino cannot do anything else\nwhile this is happening. A modified delay function was made so\nthat crucial measurements can be made in this idle time to\nallow action to be taken if something doesn't look right. The\ncurrent is monitored so if the load is disconnected, the\nturbine can immediately begin slowing down to prevent over\nspeeding the turbine and damaging both the physical and\nelectrical components.\n\nCurrently, the pitch control mechanism is adjusted by a stepper\nmotor, but through testing it has been noticed that the stepper\nmotor has a few flaws, being it is slow, and it draws a lot of\ncurrent. The stepper motor takes more than 20 seconds to move\nfrom one extreme pitch setting to the other. This affects the\nRPM when the load is disconnected because the elimination of\ntorque due to the load results in the turbine increasing by\nseveral hundred RPM during disconnects. With faster pitching\nspeeds, this RPM overshoot can be minimized. Because the\nstepper motor draws around \\qty{300}{\\mA} the added load during\npitch adjustments slows the blades down and results in more\ntime needed for the RPM to stabilize after pitch adjustments\nare made. It is being considered to change to a DC motor with a\ngearbox and H-bridge configuration which alleviates both\nconcerns in preliminary testing, with the current selection\nhaving more speed while also drawing less current.\n\n\\subsection{Voltage Regulation Description}\nThe voltage regulation system consists of four axial flux\nmotors tied in series after their respective voltages have\nbeen rectified. This allows for a high KV rating which is\nimportant for low RPM operation of the Arduino. Two adjustable\nbuck converters are each attached to two rectifier outputs in\nseries, limited to \\qty{22.5}{\\V}. When these two buck\nconverters are connected in series the system total voltage is\nlimited to \\qty{45}{\\V}. Two buck converters connected in\nseries are needed because each is rated for \\qty{52}{\\V},\nallowing for a maximum turbine voltage of \\qty{104}{\\V} which\nis achieved at around \\qty{2400}{RPM} or twice the\n\\qty{1200}{RPM} normal operational speed of the turbine. The\ninitial intent was to achieve a high voltage quickly to run the\nArduino at low RPMs and sustain it for the manual and\nemergency stop scenarios so that the turbine could\nautomatically restart.\n\nUnfortunately, through testing it was discovered that each of\nthe buck convertors requires a minimum of \\qty{4.5}{\\V} to\noperate, which now brings the minimum operating voltage to\n\\qty{9}{\\V} instead of the \\qty{5}{\\V} that the Arduino needs\nto say alive. Applying the KV rating formula from\n\\eqref{eq:KV} gives \\qty{216}{RPM} as the minimum rotational\nspeed for turbine's control system to operate. This would\nrequire the normal operational speed of the turbine to go up by\n\\qtyrange{960}{2160}{RPM}, this is according to CWC 10\\% of\nmaximum speed requirement during load-disconnect shutdown\nprocedure.\n\nBecause during the emergency shutdown it takes time for the\nsystem to respond to the load being disconnected, there exists\na time were RPM continuous to rise. Having only \\qty{240}{RPM}\nbuffer before buck converters' operational limit is surpassed\nby overvoltage, brings a self-restart operation of the turbine\nto the unpredictable operation conditions, where buck converter\nfailure is very likely.\n\nFrom observation, the system can surpass the \\qty{240}{RPM}\nbuffer zone faster than the control system can respond to slow\nitself down. At this time, the team was not able to find a\nsolution for this problem and turbine is designed to be\nmanually restarted after emergency stop. A faster pitch\ncontrol system is being designed, using DC motor, gear box and\nlimit switches to prevent over travel. More tests are needed\nto determine if new pitch control scenario will deliver the\nself-restart capability.\n\n\n\\subsection{Software Development}\nA lot of adjustments and improvements have been made to the\npitch control algorithm. At first there were five choices the\nprogram could make to adjust the pitch: no adjustment and\nsmall/big adjustment to make the blades go faster/slower.\nLater it was observed that if the blades were accelerating\ntowards the desired RPM, there may not need to be any\nadjustment made. The pitch adjustment motor used also requires\npower to use, and so with every pitch adjustment, not only is\nthere a delay required due to the change in aerodynamics, but\nthe additional load that the motor requires will slow the\nturbine down as well, which may need additional time to allow\nfor RPM stabilization. As the wind speed increases, because\nthere is more power in the wind, the turbine reacts more\nquickly to pitch changes, and so the delay times must be\nshortened as wind speed increases. The turbine is also more\nsensitive to pitch changes at high wind speeds and RPM, and so\nthe adjustments made are smaller as the wind speed increase.\nIf the turbine is trying to supply more power than it can\nextract from the wind, which would cause the RPM to drop due to\nblade stall. The blades will pitch back to a previous setting\nto try and reduce or save the stall condition if too many\n``large pitch adjustment faster'' conditions occur\nconsecutively. While the delay functions built into the\nArduino software work well, the current cannot be measured\nduring this delay time, and so if the load is disconnected it\ncould be up to three seconds before it is noticed by the\nsoftware, which could cause the blades to overspeed. A\nmodified delay function had to be created so that sufficient\ndelays could still be implemented, and the current could be\nchecked in case of a disconnect, immediately pitching the\nblades back and breaking the turbine.\n\nWind speed measurement has been more difficult than it was\nanticipated. The Rev C wind speed sensor is very sensitive at\nlow wind speeds, but at high wind speeds the voltage it sends\nout only varies by a couple hundredths of a volt per meter per\nsecond of wind. This made it challenging to know exactly what\nthe wind speed was so a lot of measurements are taken and\naveraged and then compared with previous wind speed\nmeasurements to try and verify if the wind speed is constant\nor it is changing to a higher or lower speed.\n\n\\end{document}\n", "meta": {"hexsha": "39266dab26be02e502b514c00a6c48afd1ceb628", "size": 18541, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CWC_Report/electrical_design/electrical_design.tex", "max_stars_repo_name": "troberson/artemis-project", "max_stars_repo_head_hexsha": "2c3f1b29aad28770e80d104a4ee553411ac27056", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CWC_Report/electrical_design/electrical_design.tex", "max_issues_repo_name": "troberson/artemis-project", "max_issues_repo_head_hexsha": "2c3f1b29aad28770e80d104a4ee553411ac27056", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CWC_Report/electrical_design/electrical_design.tex", "max_forks_repo_name": "troberson/artemis-project", "max_forks_repo_head_hexsha": "2c3f1b29aad28770e80d104a4ee553411ac27056", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.8321513002, "max_line_length": 68, "alphanum_fraction": 0.7823741977, "num_tokens": 4528, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.41830853915844657}}
{"text": "\\subsection{Task 6: Belief Propagation}\n\n\\subsubsection{Experiment on large datasets}\nIn this experiment, we run our radius algorithm in several large datasets. The statistics of these datasets are presented in Table \\ref{t5:table1}\n\n\\begin{table}[!htbf]\n\\caption{Datasets Statistics}\n\\begin{center}\n\\begin{tabular}{|c|c|c|}\n\\hline \\hline\ndataset & number of vertices & number of edges \\\\\n\\hline\nDBLP co-authorship network & 317080  & 1049866  \\\\\nEpinions social network & 131828  & 841372  \\\\\nAmazon product co-purchasing network & 334863 & 925872 \\\\\nEU email communication network & 265214 & 420045 \\\\\nGoogle web graph & 875713 & 5105039 \\\\\nYoutube social network & 1134890 & 2987624 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\label{t5:table1}\n\\end{table}%\n\nSimilar to semi-supervised learning, belief propagation algorithm require the graph to be partially labeled.  However, we don't have such information. Therefore, in this experiment, we randomly assign the prior belief for all nodes. Specifically, we randomly assign 5\\% of the nodes with positive label, i.e. positive prior belief(0.001), and  5\\% of other nodes with negative label, i.e. negative prior belief(-0.001), and the rest with zero belief, meaning that we don't have prior knowledge for these nodes. Then we conduct FABP algorithm on these datasets, the result are shown in Table \\ref{t5:table2} .\n\n\\begin{table}[!htbf]\n\\caption{BP Statistics}\n\\begin{center}\n\\begin{tabular}{|c|c|c|c|}\n\\hline \\hline\ndataset & positively labeled & negatively labeled & unlabeled  \\\\\n\\hline\nDBLP co-authorship network & 164103  & 144259  & 8718 \\\\\nEpinions social network & 22334  & 22575  & 86919 \\\\\nAmazon product co-purchasing network & 158837 & 160524 & 15502 \\\\\nEU email communication network & 127481 & 109616 & 28117 \\\\\nGoogle web graph & 385277 & 389975 & 100461 \\\\\nYoutube social network & 584422 & 508628 & 41840 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\label{t5:table2}\n\\end{table}%\n\n \n\\subsubsection{Observation}\n1. By applying Belief Propagation algorithm on these graphs, most of the unlabeled nodes are successfully assigned either positive or negative belief.\n\n2. We find that for some graphs, larger proportions of nodes gets labeled than other graph. For example, in DBLP co-authorship network and amazon product co-purchasing network,  about 95\\%  of the nodes get labeled using only 10\\% labeled nodes. While for like Epinions social network , only about 30\\% of the nodes get labeled. Once again, we look back at the connectivity of the graph to find the probable cause. We observed that, graph that is well connected is easier to get more nodes assigned with labels. This observation makes sense in that 'beliefs' can be easier to propagate in well connected graphs than those grape with many disconnected components.\n\n\\subsubsection{Proof of Correctness}\nAs mentioned in the previous section, we don't have any labels for these large datasets, therefore we verify the result according to statistics we got in the last section. We can see that the proportion with positive labels and negative labels are approximately same, which resembles the label distribution with our prior belief. Also, we successfully inferenced the belief of other nodes using only 10\\% labeled nodes.\nIn order to verify the accuracy of our algorithm, we run FABP on small matrix we generate. In essence, the FABP tries to solve a linear system $(I - W)x = prior$, therefore we test our FABP against the linear system solver in MATLAB(function linsolve). And the two get nearly identical result(with error less than 0.01) in solving some toy linear systems consisting of 2 by 2 matrix. This demonstrates the correctness  of our algorithm.\n\n\n\n\n", "meta": {"hexsha": "391b58569850f4ec67c6766ee2d053cd21608e94", "size": 3684, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/phase-3/doc/t6_exp.tex", "max_stars_repo_name": "spininertia/graph-mining-rdbms", "max_stars_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/phase-3/doc/t6_exp.tex", "max_issues_repo_name": "spininertia/graph-mining-rdbms", "max_issues_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/phase-3/doc/t6_exp.tex", "max_forks_repo_name": "spininertia/graph-mining-rdbms", "max_forks_repo_head_hexsha": "3b7652a99c1c0e3f4e680e04bfd08fac9708ea3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-16T18:23:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-16T18:23:24.000Z", "avg_line_length": 62.4406779661, "max_line_length": 662, "alphanum_fraction": 0.7714440825, "num_tokens": 935, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4183085391584464}}
{"text": "\\section*{Problem 1 Solution}\n\nWe will create the following simple decay chain graphic, built from the information provided in the problem, to visualize the processes described in the problem.\n\n\\begin{center}\n\\begin{tikzpicture}[node distance=3.25cm]\n\\node (blank) [placeholder]{};\n\\node (fission) [isotope, align=center, right of =blank, xshift=2cm, yshift=0.75cm] {\\large \\textbf{Fission}};\n\\node (tellurium135) [isotope, align=center, left of =blank] {\\large$^{135}$Te};\n\\node (iodine135) [isotope, align=center, below of =tellurium135, right of =tellurium135] {\\large$^{135}$I};\n\\node (xenon135) [isotope, align=center, below of =iodine135, right of =iodine135] {\\large$^{135}$Xe};\n\\node (xenon136) [placeholder, align=center, left of =xenon135, xshift=-0.5cm] {};\n\\node (cesium135) [placeholder, align=center, below of =xenon135, right of =xenon135, xshift=-0.9cm, yshift=1cm]{};\n\\node (yield) [decay, align=center, right of =tellurium135, xshift=3.2cm, yshift=0cm,]{\\large \\textbf{6\\%}};\n\\node (beta-te-i) [decay, align=center, right of =tellurium135, xshift=-0.5cm, yshift=-1.2cm] {\\large$\\beta^-$ \\\\ \\footnotesize $t_{\\nicefrac{1}{2}} = 19.0$ s};\n\\node (beta-i-xe) [decay, align=center, right of =iodine135, xshift=-0.5cm, yshift=-1.2cm] {\\large$\\beta^-$ \\\\ \\footnotesize $t_{\\nicefrac{1}{2}} = 6.6$ h};\n\\node (beta-xe-cs) [decay, align=center, right of =xenon135, xshift=-0.7cm, yshift=-1cm] {\\large$\\beta^-$ \\\\ \\footnotesize $t_{\\nicefrac{1}{2}} = 9.2$ h};\n\\node (abs-xe-cs) [decay, align=center, below of =xenon136, xshift=1.6cm, yshift=2.7cm] {\\large$\\sigma_a \\phi$};\n\n\\draw [farrow] (fission) -- (tellurium135);\n\\draw [farrow] (fission) -- (iodine135);\n\\draw [arrow] (tellurium135) -- (iodine135);\n\\draw [arrow] (iodine135) -- (xenon135);\n\\draw [arrow] (xenon135) -- (cesium135);\n\\draw [arrow] (xenon135) -- (xenon136);\n\n\\end{tikzpicture}\n\\end{center}\n\nStarting off, since this is a problem related to decay, we will start from the usual equation for changes in the number density of radionuclides. (This equation may be more familiar in terms of absolute quantity of a material,$N$, in atoms; $n$ is the number density, found by dividing $N$ by the volume containing the $N$ nuclei)\n\\begin{equation}\n\\label{general}\n\\frac{dn}{dt} = \\text{production} - \\text{loss from decay}\n\\end{equation}\n\nNuclide production may occur directly from the fission reaction or from the decay of other fission products into that nuclide. Nuclide losses will be caused by the decay of the radionuclide, or when that nucleus absorbs neutrons in the reactor's high-neutron-flux environment.\n\nFor $^{135}$Xe, the fission product of interest, we can decompose this differential equation more explicitly as\n\n\\begin{equation}\n\\label{text-dn-xenon}\n\\frac{dn_{\\text{Xe}}}{dt} = \\text{production from }^{135}\\text{I} - \\text{loss from decay of }^{135}\\text{Xe} - \\text{loss from absorption} .\n\\end{equation}\n\nIn this equation, the production due to the decay of iodine is just the activity (per volume) of iodine,\n$$ \\mathcal{A}_{\\text{I}} = \\lambda_{\\text{I}}n_{\\text{I}}, $$\nand the loss due to the decay of xenon is just the activity (per volume) of xenon,\n$$ \\mathcal{A}_{\\text{Xe}} = \\lambda_{\\text{Xe}}n_{\\text{Xe}}. $$\nThe loss due to absorption can be calculated by knowing that the absorption rate of neutrons on $^{135}$Xe is $R = \\Sigma_a \\phi$, where $\\phi$ is the neutron flux in the reactor. Since $\\Sigma_{a,\\text{Xe}}$ is defined as $\\sigma_{a,\\text{Xe}} n_{\\text{Xe}}$, the absorptive losses are\n$$ R_{\\text{Xe,abs}} \\sigma_{a,\\text{Xe}} n_{\\text{Xe}} \\phi .$$\nThe full equation for xenon can be written,\n$$ \\frac{dn_{\\text{Xe}}}{dt} = \\mathcal{A}_{\\text{I}} - \\mathcal{A}_{\\text{Xe}} - R_{\\text{Xe,abs}} $$\nor\n$$ \\frac{dn_{\\text{Xe}}}{dt} = \\lambda_{\\text{I}}n_{\\text{I}} - \\lambda_{\\text{Xe}}n_{\\text{Xe}} - \\sigma_{a,\\text{Xe}} n_{\\text{Xe}} \\phi .$$\nWe factor out $n_{\\text{Xe}}$ from the last two terms to get\n\\begin{equation}\n\\label{dn-xenon}\n\\frac{dn_{\\text{Xe}}}{dt} = \\lambda_{\\text{I}}n_{\\text{I}} - (\\lambda_{\\text{Xe}} + \\sigma_a\\phi) n_{\\text{Xe}}\n\\end{equation}\nIn this form, it is easier to see that the number densities are the only two unknown functions in this differential equation. If we could express $n_{\\text{I}}$ in terms of $t$, we could solve the equation for $n_{\\text{Xe}}$.\n\nTo express $n_{\\text{I}}$ in terms of $t$, we again use equation (\\ref{general}). Proceeding in a similar fashion as we did for xenon, we explicitly write out the equation for iodine akin to equation (\\ref{text-dn-xenon})\n\\begin{equation}\n\\label{text-dn-iodine}\n\\frac{dn_{\\text{I}}}{dt} = \\text{production from fission} + \\text{production from }^{135}\\text{Te} - \\text{loss from decay of }^{135}\\text{Xe}.\n\\end{equation}\nWe have ignored absorptive losses since the thermal absorption cross section for iodine is essentially zero. \n\nThe production of iodine due to fission can be calculated from the iodine-yield of the fission reaction. While this information is not provided, the combined yield, $y$, of iodine and tellurium \\textit{is} given. Since the half-life of $^{135}$Te (19.0 s) is practically insignificant in comparison to the multi-hour half-lives of its daughters (to be exact, $t_{\\nicefrac{1}{2},\\text{Te135}} = 0.0008(t_{\\nicefrac{1}{2},\\text{I135}})$ and $t_{\\nicefrac{1}{2},\\text{Te135}} = 0.0006(t_{\\nicefrac{1}{2},\\text{Xe135}})$), we can treat it as instantaneously decaying into iodine. With this assumption, the production of iodine due to fission is just the fission rate density multiplied by the combined yield of iodine and tellurium. The fission rate density can be found by dividing the power density by the energy per fission, $Q_f$, so\n$$ R_{\\text{I,fission}} = y\\frac{P}{Q_f} .$$\nThe loss from the decay of iodine is just the activity of iodine,\n$$ \\mathcal{A}_{\\text{I}} = \\lambda_{\\text{I}}n_{\\text{I}}. $$\nThe full equation for iodine can be written,\n$$ \\frac{dn_{\\text{I}}}{dt} = R_{\\text{I,fission}} + \\mathcal{A}_{\\text{I}} $$\nor \n\\begin{equation}\n\\label{dn-iodine}\n\\frac{dn_{\\text{I}}}{dt} = y\\frac{P}{Q_f} + \\lambda_{\\text{I}}n_{\\text{I}} .\n\\end{equation}\nConsidering that the power after the power change is $P=P_1$, we can solve for number density of iodine after the change, $n_{\\text{I},1}$.\n\\begin{equation}\n\\label{n-iodine1}\nn_{\\text{I},1}(t) = \\frac{y P_1}{\\lambda_{\\text{I}}Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + n_{\\text{I},1}(0)e^{-\\lambda_{\\text{I}}t}.\n\\end{equation}\n\\begin{center}(for a detailed derivation of this, see the appendix)\\end{center}\nLooking closely at this equation, we find that the only unknown quantity here is $n_{\\text{I},1}(0)$. While using $t=0$ in this equation gives us the trivial solution that $n_{\\text{I},1}(0) = n_{\\text{I},1}(0)$, we note that equation (\\ref{dn-iodine}) could be solved identically for times before the power change by simply replacing $P_1$ by $P_0$. \n\\begin{equation}\n\\label{n-iodine0}\nn_{\\text{I},0}(t) = \\frac{y P_0}{\\lambda_{\\text{I}}Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + n_{\\text{I},0}(0)e^{-\\lambda_{\\text{I}}t}.\n\\end{equation}\nWe are told that our reactor has been operating for a long time. If we assume that this time period is sufficiently long that we can approximate the time of the power change as $t=\\infty$, then equation (\\ref{n-iodine0}) reduces to\n$$ n_{\\text{I},0}(\\infty) = \\frac{y P_0}{\\lambda_{\\text{I}}Q_f} ,$$\nand\n$$ n_{\\text{I},0}(\\infty) = n_{\\text{I},1}(0) .$$\nWe replace this value of $n_{\\text{I},1}(0)$ in equation (\\ref{n-iodine1}) to get\n\\begin{equation}\n\\label{n-iodine1-comp}\nn_{\\text{I},1}(t) = \\frac{y P_1}{\\lambda_{\\text{I}}Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + \\frac{y P_0}{\\lambda_{\\text{I}}Q_f}e^{-\\lambda_{\\text{I}}t}.\n\\end{equation}\nThis equation has $n_{\\text{I}}$ exclusively as a function of $t$, and so we can now use it back in equation (\\ref{dn-xenon}) to find the number density of xenon after the power change. \n\\begin{align*}\n\\frac{dn_{\\text{Xe},1}}{dt}\t&= \\lambda_{\\text{I}}\\left(\\frac{y P_1}{\\lambda_{\\text{I}}Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + \\frac{y P_0}{\\lambda_{\\text{I}}Q_f}e^{-\\lambda_{\\text{I}}t}\\right) - (\\lambda_{\\text{Xe}} + \\sigma_{a,\\text{Xe}}\\phi) n_{\\text{Xe},1} \\\\\n\t\t\t\t\t\t\t&= \\frac{y P_1}{Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + \\frac{y P_0}{Q_f}e^{-\\lambda_{\\text{I}}t} - (\\lambda_{\\text{Xe}} + \\sigma_{a,\\text{Xe}}\\phi) n_{\\text{Xe},1}\\\\\n\\end{align*}\nIn this equation we will introduce a parameter called the \"effective destruction constant\", $\\lambda_{\\text{Xe}}^{\\text{eff}} = \\lambda_{\\text{Xe}} + \\sigma_{a,\\text{Xe}} \\phi. $ The differential equation above becomes\n$$ \\frac{dn_{\\text{Xe},1}}{dt} = \\frac{y P_1}{Q_f}\\left(1-e^{-\\lambda_{\\text{I}}t}\\right) + \\frac{y P_0}{Q_f}e^{-\\lambda_{\\text{I}}t} - \\lambda_{\\text{Xe}}^{\\text{eff}} n_{\\text{Xe},1} $$\n\n\\textbf{Note:} If you've made it this far, you've got the general gist of the problem. Nice work! The remainder get's a little tricky---you need an integrating factor to solve this differential equation---and though the solution looks a bit intimidating, it can begin to reveal some of the complicated behavior of an operating reactor. This is information that will be covered more comprehensively later in the semester, but which is also useful to introduce now. \n\nWhen we use the integrating factor, we find\n\\begin{align*}\nN_{\\text{Xe},1}(t)\t&= N_{\\text{Xe},1}(0)e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t} + \\frac{yP_1}{\\lambda_{\\text{Xe}}^{\\text{eff}}Q_f}\\left(1-e^{-\\lambda_{\\text{Xe}}^{\\text{eff}} t}\\right) - \\frac{yP_1}{(\\lambda_{\\text{Xe}}^{\\text{eff}}-\\lambda_{\\text{I}}) Q_f} \\left(e^{-\\lambda_{\\text{I}}t} - e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t}\\right) + \\frac{yP_0}{(\\lambda_{\\text{Xe}}^{\\text{eff}}-\\lambda_{\\text{I}}) Q_f} \\left(e^{-\\lambda_{\\text{I}}t} - e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t}\\right) \\\\\n\t\t\t\t\t&= N_{\\text{Xe},1}(0)e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t} + \\frac{yP_1}{\\lambda_{\\text{Xe}}^{\\text{eff}}Q_f}\\left(1-e^{-\\lambda_{\\text{Xe}}^{\\text{eff}} t}\\right) - \\left(\\frac{yP_1}{(\\lambda_{\\text{Xe}}^{\\text{eff}}-\\lambda_{\\text{I}}) Q_f} - \\frac{yP_0}{(\\lambda_{\\text{Xe}}^{\\text{eff}}-\\lambda_{\\text{I}}) Q_f}\\right) \\left(e^{-\\lambda_{\\text{I}}t} - e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t}\\right) \\\\\n\t\t\t\t\t&= N_{\\text{Xe},1}(0)e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t} + \\frac{yP_1}{\\lambda_{\\text{Xe}}^{\\text{eff}}Q_f}\\left(1-e^{-\\lambda_{\\text{Xe}}^{\\text{eff}} t}\\right) - \\frac{y\\left(P_1-P_0\\right)}{(\\lambda_{\\text{Xe}}^{\\text{eff}}-\\lambda_{\\text{I}}) Q_f} \\left(e^{-\\lambda_{\\text{I}}t} - e^{-\\lambda_{\\text{Xe}}^{\\text{eff}}t}\\right)\n\\end{align*}\n\\begin{center}(for a detailed derivation of this, see the appendix)\\end{center}\n\nFrom this equation, we see that if $P_1 > P_0$, then the sign of the third term is opposite the case when $P_0 > P_1$. Using typical values for all the constants, including flux and energy per fission, this sign change suggests that power increases and decreases will have opposite effects on the xenon population. If the power increases ($P_1 > P_0$) then the xenon population will temporarily decrease. If instead the power decreases ($P_1 < P_0$) then the xenon population will increase for a while, before xenon losses compensate for the production due to decaying iodine. This behavior can lead to situations where an operator is unable to restart a reactor immediately after shutting down (power has decreased, fission product concentrations temporarily jump, and restarting the reactor is unsafe). This was a contributing factor at Chernobyl.\n\n", "meta": {"hexsha": "d054c6525ec0ee979c0d080a86db8141d3674912", "size": 11485, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/drafts/disc03/disc03_solution01.tex", "max_stars_repo_name": "mitchnegus/NE150-discussion", "max_stars_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercises/drafts/disc03/disc03_solution01.tex", "max_issues_repo_name": "mitchnegus/NE150-discussion", "max_issues_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercises/drafts/disc03/disc03_solution01.tex", "max_forks_repo_name": "mitchnegus/NE150-discussion", "max_forks_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.7083333333, "max_line_length": 849, "alphanum_fraction": 0.6903787549, "num_tokens": 4049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.41830853532674733}}
{"text": "\\section{Introduction}\nGraphs are a natural way to model many of the modern complex\ndatasets that typically have interlinked entities connected with various\nrelationships. Examples include different types of networks, such as\nsocial, biological and technological networks. Tools for rapidly\nquerying and mining graph data are therefore in high demand. Our focus\nis on graph pattern discovery methods that can simultaneously consider\nboth the structure and content (e.g., node labels).\n\nWhereas frequent graph mining has long been a well studied problem, most\nof the prior work has focused on exact pattern discovery.\nGraph mining involves two main steps. The first step is to generate\nnon-duplicate candidate patterns, and the second is to compute the\nfrequency of each candidate pattern. The former task requires graph\nisomorphism testing, whereas the latter requires subgraph isomorphism\nchecking, since we need to count all the occurrences of a smaller graph\nwithin a much larger graph (or a set of graphs). Many efficient methods\nhave been proposed for mining exact labeled graph patterns, including\nboth complete search and sampling based\napproaches~\\cite{gSpan,HWP03,kuramochi2005ffp,FSG01,IWM03,2009-graphsampling}.\nThese exact methods require that there be an exact match between the\nlabels of nodes in the candidate pattern and in the database graph. This\ncan potentially miss many patterns where nodes may share a high label\nsimilarity, but may not match exactly. This is specially true for more\ncomplex labels (e.g., text data), or in cases where the nodes represent\nsome real-world objects (e.g., proteins, IT infrastructure nodes), where\nit may be possible to easily design a meaningful cost or distance matrix  between node ``labels''. Unfortunately, exact isomorphism\nbased methods cannot leverage the rich information from the cost matrix.\nWhat is required is a new class of algorithms that can mine\nfrequent approximate patterns via approximate subgraph isomorphism that\nsatisfies some bound on the overall cost of the match between a candidate\nand the database graph(s). Only a few methods have tackled this\nproblem~\\cite{gapprox,JiaZH11,RAM2008}, but they typically enumerate all\nisomorphisms, and are therefore not scalable to large graphs due to the\ncombinatorial explosion in the number of isomorphisms.\n\nIn this paper we present a new approach to mine frequent approximate\npatterns in the presence of a cost matrix between the labels. In\nparticular we make the following contributions:\n\\begin{itemize}\n\\item We propose a novel approach to effectively prune the space of\n  approximate labeled isomorphisms. Instead of enumerating all the\n  possible isomorphisms, we maintain a set of representatives (nodes in\n  the database that match a candidate pattern) that is linear in the\n  database and pattern size. Pruning is applied on this set to narrow\n  down the search to only viable mappings.\n\\item We propose several iterative label updating methods that yield\n  derived cost matrices on the basis of which more effective \n  pruning can be achieved. These are based on $k$-hop labels, neighbor\n  concatenated labels and a combination of the two.\n\\item Our method handles both arbitrary as well as binary cost matrices.\n\\item We place our work within the pattern sampling paradigm, \n  thereby avoiding complete search, which can be practically \n  infeasible in real-world\n  graphs, not to mention the information overload problem.\n\\end{itemize}\nWe study the effectiveness of the proposed methods on three real-world\ndatasets. The first is a configuration management database graph, \nwhere the nodes represents\nentities comprising the IT infrastructure and the link represents\nrelationships between them; approximate mining yields a richer de-facto IT\npolicies in the company. The second dataset is a graph dataset\nrepresenting 3D protein structures; mined patterns represent approximate\nmotifs. The last dataset comes from a protein interaction network, where\nthe nodes are proteins and edges indicate whether they interact\nphysically (i.e., they may bind together or they may be part of the\nsame protein complex); the mined approximate patterns represent\nmolecular subnetworks and molecular machines (the protein complexes)\nthat take part in important cellular processes. We show that our\nproposed techniques are indeed scalable and fruitful, allowing us\nto mine interesting approximate graph patterns from \nlarge real-world graphs.\n", "meta": {"hexsha": "61d3454c3d68d61b6d8b2a15018abdd9e44c6287", "size": 4455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/introduction.tex", "max_stars_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_stars_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/introduction.tex", "max_issues_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_issues_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/introduction.tex", "max_forks_repo_name": "PranayAnchuri/approx-graph-mining-with-label-costs", "max_forks_repo_head_hexsha": "4bb1d78b52175add3955de47281c3ee0073c7943", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-08T11:17:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-08T11:17:33.000Z", "avg_line_length": 61.0273972603, "max_line_length": 131, "alphanum_fraction": 0.8177328844, "num_tokens": 920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.41829522008211684}}
{"text": "K-corrections and Reddening coefficients\n--------------------------\n\nRegardless of the method used, there are two generic problems when\nfitting light-curves. First, because you are observing a SN that is\nat some redshift, the observed spectral energy distribution (SED)\nis shifted to the red compared to what would be observed at zero redshift.\nAs a result, the filters are sampling a bluer part of the SNIa spectrum.\nK-corrections are needed to take this into account and we therefore\nneed either observed spectra of the SN or some kind of SED template\nto make this calculation. We also need to take into account, if possible,\nof any factors that might alter the shape of the SED (like reddening).\nOnce the SED is known, it is straightforward to compute the K-correction\n(see \\citet{2002PASP..114..803N,2007ApJ...663.1187H}).\n\nSecond, because the SED of a SNIa is significantly different from\na stellar SED and also varies with time, the ratio of selective to\ntotal absorption (:math:`R_{X}`) is going to depend on the redshift of\nthe SN, the epoch of observation, and the amount of host reddening\n(and any other factor that modifies the intrinsic SED). Once the SED\nis known (or assumed), the reddening coefficient :math:`R_{X}` can be deduced.\n\nThe basic problem here is that we need to know the observed SED as\nwell as possible. Currently, SNooPy simply takes the SED of \\citet{2002PASP..114..803N}\nor \\citet{2007ApJ...663.1187H} (user's choice), as the SED. This\nis used to compute initial k-corrections that are simply a function\nof time. If reddening information is known (from a fit value of EBVhost,\nfor instance), the reddening law of \\citet{1989ApJ...345..245C},\nfurther modified by \\citet{1994ApJ...422..158O} is applied to the\nSED before computing the K-correction or reddening coefficient. After\nthis initial fit, the :math:`N-1` colors of the SN are computed and these\ncan be used to warp the SED so that synthetic colors obtained from\nthe SED match the observed colors form the fit (see \\citet{2007ApJ...663.1187H}\n). The hope is that this ``warped'' SED is the best guess at the\ncorrect SED. This step in the fit process may be skipped by using\nthe ``mangle=0`` argument to the ``fit()`` function.\n\n\nDoing the Fit\\label{sub:Doing-the-Fit}\n--------------------------\n\nThe ``fit()`` function is a member of the ``sn`` class.\nThe first argument is a list of observed filters to fit (or by default,\nfit them all). Following this argument, you can specify values for\nany of the parameters, which will keep them fixed during the iteration:\n``Tmax, dm15, s, EBVhost, DM``, and any of the`` fmax``.\nBy default, the fitter will try to fit the observed filter set with\nthe same rest-band filters. It is therefore important that your filter\nnames match the filters provided by the templates: ``Bs,Vs,Rs,Is``\n(for \\citet{2006ApJ...647..501P} templates) or ``u,B,V,g,r,i,Y,J,H``\n(for CSP templates). If your observed filter does not match any of\nthese (either because you are working at high-z and want to do a cross-band\nK-correction, or are working in a different photometric system), you\nneed to specify the ``restbands`` for each observed filter (``restbands``\nis a member variable that acts like a python dictionary and maps observed\nfilters to rest filters). Here is a short example:\n\n\\begin{verbatim}\nIn [1] s = get_sn('04D1oh')\nIn [2] s.restbands['g_m'] = 'B'   ;#  Fit observed g_m data with 'B' (CSP)template\nIn [3] s.fit(['g_m'], EBVhost=0, dm15=1.1)\nIn [4] s.fit(['g_m'], EBVhost=0)\nIn [5] s.restbands['r_m'] = 'V';  s.restbands['i_m'] = 'r';  s.restbands['Jc'] = 'i'\nIn [6] s.fit(['g_m','r_m','i_m','Jc'], dm15=s.dm15, Tmax=s.Tmax)\nIn [7] s.fit(['g_m','r_m','i_m','Jc'])\nIn [8] save(s, \"my_lovely_fit.snpy\")\n\\end{verbatim}\n\nOn line 1, we make a new instance. On line 3, we decide to fit the\nmegacam g filter with a rest-frame CSP B template. On line 3, we fit\nonly the g_m filter and therefore restrict ``EBVhost`` to 0\n(since we don't have any color information). We can also fix :math:`\\Delta m_{15}=1.1`\nfor a first attempt at a fit (this can help if you have pretty low\nS/N data). On line 4, we let :math:`\\Delta m_{15}` go free. On line 5,\nwe specify more rest-band filters. On line 6 we add more filters to\nthe fit and allow the host extinction to vary, though keeping :math:`\\Delta m_{15}`\nand :math:`t_{max}` fixed at the values determined from the previous fit\n(all fitted parameters and their errors are saved as member data of\nthe ``sn`` instance). On line 7, we allow all parameters to vary.\nOn line 8, we save the fit to a file that can be later loaded into\nSNooPy (using something like ``s=load(filename)``).\n\nThe fit is performed using the Lavenberg-Marquardt algorithm for minimizing\n:math:`\\chi^{2}`. Unless you specify otherwise, all the fitting is done\nin flux units (SNooPy takes care of converting magnitudes to fluxes,\nif needed, for both the observations and models). Note that because\nthe Lavenberg-Marquardt algorithm is an non-linear least-squares solving\nroutine, it is not guaranteed to find the global minimum :math:`\\chi^{2}`.\nIt is your responsibility to inspect the fit to make sure it got it\nright.\n\nNow that you have seen the basic workings, we can now move on to the\ndetails of each class so that you can build your own routines inside\nSNooPy, or write python scripts that use these classes to fit light-curves. \n\n\nGetting Help\n--------------------------\n\nPython has an internal help system which utilizes comments at the\nbeginning of functions and classes (so-called docstrings). Simply\nuse the built-in help() function to get help on an item. Here are\nsome examples (output is not shown to save space):\n\n\\begin{verbatim}\nIn [1] help(sn)\nIn [2] help(sn.fit)\nIn [3] help(sn.plot)\nIn [4] help(lc)\n\\end{verbatim}\n\nLine 1 gets help about the entire ``sn`` class, which will list\nall the functions defined therein, including internal ones that are\nnot meant to be used by end users (but of course are available to\nbe hacked, but may lack good documentation). Lines 2 and 3 get more\nspecific help on individual member functions. Line 4 gets help on\nthe ``lc`` (light-curve) class. You can ask for help on any python\nobject (including variables).\n\n\nThe Art of Interpolating \\label{sub:Splining}\n--------------------------\n\nSometimes, you may simply be interested in getting information about\na light-curve independent of model or light-curve template. SNooPy\nhas several interpolation schemes built in. Which ones depends on\nwhether you have ``pymc`` installed (for the Gaussian Processes)\nand how recent your ``numpy`` is (for the polynomials). Use the\ncommand '``list_types()``' to list which are available to you.\nHere are brief explanations of how each scheme works. Unlike the template\nfitting, interpolation is done filter-by-filter, and so the routines\nare accessed at the light-curve instance level, instead of the supernova\ninstance level.\n\n\n\\subsubsection{Gaussian Processes}\n\nIf you have installed the ``pymc`` package, it comes with an\ninterpolating package that uses Gaussian Processes (GP). GP's are\nfantastic for interpolating when you may have missing data (gaps).\nThis is usually where other fitters like Dierckx splines and hypersplines\n(see next sections) go awry. That's not to say that GP somehow magically\nknow what to do in the absense of data, but they tend to not ``go\ncrazy'' like splines and they properly compute the uncertainty in\nthe interpolator when there is missing data. In this way, GP's are\nmore ``honest''.\n\nI'm not going to explain everything about GP's, but suffice it to\nsay that GP's are like ``fuzzy functions''. They have a mean value\n(mean function) and a error (covariance function). In SNooPy's implementation,\nwe employ the Matern covariance function, which has 3 parameters:\n``scale``, ``amp`` (amplitude), and ``diff_degree``\n(degree if differentiability). These are conceptually very easy to\nunderstand: scale is the scale over which the function typically varies\n(on the x-axis). Amplitude is the amount by which the function varies\non these scales. The degree of differentiability is the ``smoothness''\nof the function. These are the only 3 parameters you need to specify\nto the template() function to get a fit (or don't specify them at\nall and take the defaults, which are pretty good for light-curves).\nIf the function does not capture the full behaviour of the light-curve\n(too smooth), try decreasing the scale and increase the amplitude.\nIf it captures too much of the ``noise'', increase the scale, lower\nthe amplitde and/or increase the diff_degree.\n\nHere is an example:\n\n\\begin{verbatim}\ns.B.template(method='gp', scale=10, amp=s.B.mag.std(), diff_degree=3)\n\\end{verbatim}\n\nHere we choose the method (\\textsf{gp} = Gaussian process), set the\nscale to 10 days, compute the standard deviation of the B lightcurve\nand use that as the amplitude, and set the degree of differentiability\nto 3. The downside to GP's is that they are slower to solve than the\nother interpolation methods. But I feel that the error estimates that\ncome out (especially in the regions with gaps) are much more robust.\n\n\n\\subsubsection{Dierckx splines}\n\nSplines are a great way to represent data, but they have one very\nserious drawback: a variable number of parameters. Not only do you\nhave to specify the order of the spline (usually one chooses k=3 for\na cubic spline), you also have to choose how many knot points to use.\nEach knot point has two parameters: its placement on the time axis\nand the coefficient of the spline at that knot point. You can therefore\nhave the number of knot points equal to the number of data points\n(plus 2k end-point knots to properly define the spline on the boundaries)\nand get a spline that's guaranteed to pass through each and every\npoint (an interpolating spline). But real data has noise, so this\nisn't what you want. At the other extreme, you could use the bare\nminimum of 2k+2 knots which would give the smoothest spline, but then\nyou lose any interesting structure in the light-curve.\n\nLuckily, ``scipy`` makes many of the algorithms from Paul Dierckx's\nbook ``Curve and Surface Fitting with Splines'' \\citep{Dierckx1993}\navailable. These algorithms deal with automatic choice of the number\nand placement of the spline knots. They distill the problem down to\none parameter: the smoothing, ``s``. The larger ``s``, the\nsmoother (fewer knots) the curve and the smaller, the more the spline\nwill approach an interpolating spline (s=0). If the weights you provide\nthe spline fitter are proper 1-sigma errors, then setting s to the\nnumber of data points should result in a curve with reduced :math:`\\chi_{\\nu}^{2}\\simeq1`,\nwhich is what we really want. The first time you fit the spline, set\ntask=0 and the routine will choose an initial set of knot points.\nIf you wish to play around with the smoothing parameter, but keep\nthe knots fixed, use task=1; otherwise, new knots will be chosen each\ntime.\n\nIt may be that the resulting spline doesn't ``look right''. Most\nlikely, this is due to badly estimated weights (variances). The solution\nis to vary s until you get something that looks right, but of course,\nthis is purely subjective. With proper 1-sigma errors, one can legitimately\nplay around with s in the range :math:`N-\\sqrt{2N}<s<N+\\sqrt{2N}` until\nthe spline looks acceptable%\n\\footnote{I tend to shy away from this, preferring to remove the subjectivity.\nRather, I would re-examine the weights and decide whether they are\ncorrect. Playing around with s is effectively like globally increasing\nthe errors.%\n}.\n\nAnother way to spline is to impose what you think are sensible knots.\nIn this case, simply specify them as an array with the knots argument\nto the ``template()`` function and set ``task=-1``. In this\ncase, the smoothing is ignored and you get the least-squares spline\nusing these knots. For example:\n\n\\begin{verbatim}\ns.B.template(method='spline', task=0, s=len(s.B.mag))\ns.B.template(method='spline', task=1, s=len(s.B.mag) - sqrt(2*len(s.B.mag)))\n\\end{verbatim}\n\n\n\\subsubsection{Hyperspline}\n\nThe problem of choosing the correct value of s in the previous section\ncan be removed by using another set of spline routines developed by\n\\citet{297968}. Rather than using :math:`\\chi^{2}` as a statistic for\ndetermining the best-fit spline, they use a statistic call the Durbin-Watson\nstatistic. Without getting into the details, this statistic relies\nmore on the auto-correlation in the residuals, which to first order\nis insensitive to the individual errors of the points. In essence,\nyou're using the pattern of the points to tell you what is noise and\nwhat is a true trend.\n\nThis spline method, when it works, is the most automatic of the interpolation\nmethods, requiring no parameters (at least initially). Of course,\nthe Achilles-heal of this method is the presence of correlated errors\namong the data points. But this is likely also a problem with Dierckx\nsplines.\n\nAnother case where hyperspline has problems is when there are large\ngaps in the data. Here, you might want to split up the problem in\nto two (or more) segments and work on them individually. I hope to\nadd this feature eventually. The parameter you'll most likely need\nto play with is ``lopt`` (set the initial number of knots). Set\nit higher if you find the spline is too smooth. \n\n\n\\subsubsection{Polynomials}\n\nIf you have a sufficiently recent version of numpy, you'll have access\nto several types of polynomials: ``polynomial``, ``chebyshev``,\n``laguerre``, ``hermite``, and ``hermiteE``. Simply\nuse any of these as the method argument to template(). The polynomials\nhave only one free parameter: ``n``, the order of the polynomial.\nFor example to fit a Chebyshev polynomial:\n\n\\begin{verbatim}\ns.B.template(method='chebyshev', n=5)\n\\end{verbatim}\n\n\n\\subsubsection{Interactive Fitting}\n\nA new feature is the ability to interactively fit the data using the\n``matplotlib`` library. Simply specify ``interactive=True``\nwhen you call the ``template() ``member function. A window that\nloos like figure XXX will pop up, showing you the light-curve, the\ncurrent fit, and the residuals from the fit. You will then have access\nto certain keystrokes depending on the fitting method. In all cases,\nyou can use the following keys:\n\\begin{itemize}\n\\item 'x': The point closest to the mouse pointer will be masked (red X\nwill cover it and it won't contribute to the fit). If you use 'x'\nagain near this point, you un-mask the data.\n\\item 'r': re-fit the plot (if necessary) and re-draw the plot.\n\\item 'c': (re)compute the light-curve parameters and plot them on the light-curve.\n\\item 'q': quit the interactive plotting and close the graph.\n\\item '?': quick help on what keystrokes are available\n\\end{itemize}\nWhen fitting Gaussian Processes, the following keys can be used:\n\\begin{itemize}\n\\item 's' and 'S': decrease and increase the scale by 10\\%, respectively.\n\\item 'a' and 'A': decrease and increase the amplitude by 10\\%, respectively.\n\\item 'd' and 'D': decrease and increase the degree of differentiability\nby 1\n\\end{itemize}\nWhen fitting with Dierckx splines, the following keys can be used:\n\\begin{itemize}\n\\item 'a': Add a knot point at the cursor position. Note: this will change\nthe ``task`` parameter to -1.\n\\item 'd': Delete knot point closest to the cursor position. Note: this\nwill change the ``task`` parameter to -1.\n\\item 'm': Move the knot point closest to the cursor position to a new position\n(hit 'm' again). Note: this will change the ``task`` parameter\nto -1.\n\\end{itemize}\nWhen fitting with polynomials, the following keys can be used:\n\\begin{itemize}\n\\item 'n' and 'N': decrease and increase the order of the polynomial by\n1\n\\item 'm': specify range over which to fit (press 'm' at beginning and again\nat end). Pressing 'm' twice in the same location will reset to default\nrange.\n\\end{itemize}\n\nSNooPy's Internal Structure\n=========================\n\nThe rest of this document involves the inner workings of SNooPy, more\nappropriate for those who want to work with SNooPy programatically,\nor want to make their own models. Python is object-oriented and SNooPy\nhas been designed%\n\\footnote{If you can call this cobbled-together-late-at-night-while-observing\ncode a design.%\n} with this in mind. As such, the data are organized into a hierarchical\nstructure of objects. The base (or parent) object is the supernova\nitself (the ``sn`` class). It contains scalar variables like\ncoordinates, redshift, Milky-Way reddening, etc. It has functions\nfor plotting, fitting, and saving itself (see section \\ref{sec:Data-Persistance}).\nIt has variables that control the way the light-curves are fit. \n\nThe ``sn`` instance also contains references to a number of light-curves,\none for each filter (the ``lc`` class), which are stored in a\npython dictionary called ``data``. The dictionary is indexed\nby the observed filter name. These lc objects contain the data (time,\nmagnitude, flux, errors, etc), as well as functions for plotting,\ninterpolation, and other useful tasks that apply to one light-curve\nat a time. Each ``lc`` object also has a reference to a ``filter``\nobject that defines the filter response, the zero-point, and lots\nof other goodies. There is also a shortcut for accessing the ``lc``\ninstances: you can refer to them as member variables. So ``s.data{[``'B'{]}}\nand ``s.B`` are equivalent.\n\nLastly, the sn instance also has an object that defines the model\nthat will be used to fit the data. It holds the parameter values,\nerrors, :math:`\\chi^{2}`, etc. It also does all the heavy lifting when\nfitting the model to the data. Because the model is an abstract object,\nit can be replaced with other model objects transparently (so long\nas the replacement model object conforms to the structure expected\nby SNooPy; see section \\ref{sec:Model-class}).\n\nThe outline of the major objects is show in figure \\ref{fig:Object-structure}.\nThis is not exhaustive\n\n\\begin{figure}\n\\includegraphics[width=4in]{object_structure\\lyxdot 001}\n\n\\caption{Object structure in SNooPy.\\label{fig:Object-structure}}\n\\end{figure}\n\n\n\nData Persistence\\label{sec:Data-Persistance}\n=========================\n\nThe current version of ``SNooPy`` gets and saves its data from\nthree possible sources: a ``mySQL`` database, a file that was\ncreated using the ``sn.save()`` function, or a flat text file\nof the proper format. A single convenience function, ``get_sn()``\ncan be used to load a sn object from any of these sources. \n\nFor large datasets, I highly recommend using the mySQL solution: it\nallows for data persistence that is kept separate from one user/computer\ncombination. The major downside is you have to install mySQL (not\ntoo bad) and setup a schema which matches what SNooPy expects (still\nnot too bad) and possibly learning mySQL in the first place (well,\nyou always \\emph{meant} to learn it, didn't you? This is your excuse).\nI'm not going to explain how to install mySQL and setup a schema,\nthat's best left for the SQL documentation. The required schema is\ndetailed in Appendix \\ref{sec:mySQL-Schema}.\n\nIf you don't want the bother of SQL, then you can load initial data\nfrom a flat ascii data file (see section \\ref{sub:flatfile}). When\nyou're done fitting and want to save the sn object, with all its state\nvariables, simply use the ``sn.save('filename')`` function to\nsave the ``sn`` instance as a python pickle file. You can later\nload it in using ``get_sn('filename')``. \n\nWARNING: because the pickle file will contain the entire data structure\nof the SN object, there is no guarantee that pickle files will be\nloadable by different versions of SNooPy. In fact, I can pretty-much\nguarantee that major upgrades of SNooPy will result in non-compatibility\nin pickled files.\n\n\nThe sn Object\\label{sec:The-super-Object}\n=========================\n\n\nConstructor and its options\n--------------------------\n\nSupernova objects are created using the ``sn`` constructor or\nusing the ``get_sn()`` convenience function:\n\n \\begin{verbatim}\ns = sn(name, z=None, ra=None, dec=None)\ns = get_sn('my_favorite_SN.snpy')\n\\end{verbatim}\n\nThe optional arguments ``z``, ``ra``, and ``dec`` are\nused if the supernova does not exist in the sql database. The redshift\n``z`` is required to do the fitting (obviously) and ``ra``,\n``dec`` are needed to compute the galactic extinction from the\nSchlegel maps.\n\n\nCreating an object from a flat file\\label{sub:flatfile}\n--------------------------\n\nIf you don't have or want an SQL database, you can load in data from\na flat file. To do this, simply create a text-file with the following\nformat:\n\n\\begin{verbatim}\n{name} {z} {ra} {decl}\nfilter {filter1}\n{Date1} {magnitude1} {error1}\n{Date2} {magnitude2} {error2}\n...\n{DateN} {magnitudeN} {errorN}\nfilter {filter2}\n...\n\\end{verbatim}\n\n\nThe items in \\{\\}'s are to be filled in. The first line gives the\nname, redshift, and right-ascension and declination in decimal degrees.\nNext, you specify the name of a filter, followed by data points, one\nper line. Then you can input another filter and so on. The filter\nnames have to be recognized by SNooPy (use ``fset.list_filters()``\nto list them). See section \\ref{sub:default_filters} for instructions\non how to add custom filters. Once you've made this file, you simply\nuse ``get_sn()`` to make it into a ``sn`` object.\n\n\\begin{verbatim}\nIn[15]:  SN = get_sn('name_of_the_file.dat')\n\\end{verbatime}\n\n\nMember variables\n--------------------------\n\nThe ``sn`` object has a number of member variables that do one\nof three things: 1) contain data, 2) define a LC fit, or 3) modify\nthe instance's behavior. Each of these is explained in the following\nsections. A member variable is accessed as ``instance.variable``.\nFor instance:\n\n\\begin{verbatim}\nIn[20]:  SN = sn('SN3241')\n<output supressed>\nIn[21]:  Tmax = SN.Tmax\nIn[22]:  first_B_epoch = SN.B.MJD[0] - Tmax\nIn[23]:  Max_B_obs = max(SN.B.mag)\n\\end{verbatim}\n\n\n\\subsubsection{Data}\n\nA ``sn`` instance has a number of member variables that are not\nmeant to be modified directly: they hold data about the SN or the\nlight-curve data. That doesn't mean you \\emph{can't} modify it, but\nmy philosophy has been to leave the observed data alone and build\neverything into the model. The following table lists these variables\nand a short explanation:\n\n\\begin{table}\n\\begin{tabular}{|c|c|>{\\raggedright}p{0.75\\columnwidth}|}\n\\hline \nVariable & type & Description\\tabularnewline\n\\hline \n\\hline \n``z`` & float & Heliocentric redshift of the Supernova%\n\\footnote{The redshift is used to model the time-dilation, shifting of the SEDs,\nand computing the K-corrections. You should therefore use the heliocentric\nredshift of the SN, and \\emph{not} the CMB redshift.%\n}\\tabularnewline\n\\hline \n``ra`` & float & Right Ascension in decimal degrees\\tabularnewline\n\\hline \n``decl`` & float & Declination in decimal degrees\\tabularnewline\n\\hline \n``data`` & dictionary & Holds the light-curve instances. E.g., ``s.data{[``'B'{]}} is\nthe B-band LC data instance. See lc class below. \\tabularnewline\n\\hline \n``model`` & model & The model instance used to do the fitting (see section \\ref{sec:Model-class}).\nThis can be changed either by hand or by using ``self.choose_model()``\nfunction (see section \\ref{sub:Other-Useful-functions}). \\tabularnewline\n\\hline \n``bands`` & list & A list of strings corresponding to the observed bands defined in ``data``.\\tabularnewline\n\\hline \n\\emph{filter} & lc & The LC data instance for band \\emph{filter}. For example, ``s.B``\nis the same as ``s.data{[``'B'{]}}.\\tabularnewline\n\\hline \n``EBVgal`` & float & The Milky-way :math:`E\\left(B-V\\right)` from the Schlegel maps.\\tabularnewline\n\\hline \n``e_EBVgal`` & float & Error in ``EBVgal``.\\tabularnewline\n\\hline \n``ks`` & dictionary & A dictionary of computed k-corrections. The index is the filter name,\nthe value is an array of k-corrections, one for each observed epoch.\\tabularnewline\n\\hline \n\\emph{parameter} & float & Any of the parameters from the model. For example, ``s.dm15``\nis equivalent to ``s.model.parameters{[``'dm15'{]}}\\tabularnewline\n\\hline \ne\\emph{_parameter} & float & Error in any of the model parameters. For example, s.e_Tmax is equivalent\nto s.model.errors{[}'Tmax'{]}\\tabularnewline\n\\hline \n\\end{tabular}\n\n\\caption{Data member variables\\label{tab:sn-member-variables}}\n\\end{table}\n\n\nNote that some of the member data are themselves instances of other\nclasses, most notably the ``lc`` (light-curve) class and ``model``\nclass, which are covered in sections \\ref{sec:Lightcurve-class} and\n\\ref{sec:Model-class}, respectively.\n\n\n\\subsubsection{Proxy Variables}\n\nA number of variables that belong to other classes/structures can\nbe accessed directly from the sn instance. For instance, you could\nrefer to the B ``lc`` instance in two ways: ``s.B`` or ``s.data{[``'B'{]}}.\nYou can also refer to the parameters ``Tmax`` of the current\nmodel in the following three ways: ``s.Tmax`` or ``s.model.Tmax``\nor ``s.model.parameters{[``'Tmax'{]}}. The last cases are the\n'real' locations; the others are simply re-directs that were added\nfor convenience. The re-directs are listed in table \\ref{tab:sn-member-variables}\nin italics.\n\n\n\\subsubsection{Behavior-Modifying Variables\\label{sub:Behaviour-Modifying-Variables}}\n\nThe member variables that modify how the instance behaves are listed\nin table \\ref{tab:behave_var}. They are mostly to do with how the\ndata are fit and plotted.\n\n\\begin{table}\n\\begin{tabular}{|c|c|>{\\raggedright}p{0.75\\columnwidth}|}\n\\hline \nName & type & Description\\tabularnewline\n\\hline \n\\hline \nfilter_order & list & A list of strings corresponding to the order in which the filters\nshould be plotted. Also useful if you want to prevent data from being\nplotted (simply omit the filter)\\tabularnewline\n\\hline \nxrange,yrange & list & X and Y range to plot. Example: ``s.xrange = {[``-20,100{]}}\\tabularnewline\n\\hline \nRv_gal & float & Milky Way reddening law (default: 3.1)\\tabularnewline\n\\hline \nfit_mag & boolean & If true (1), fit in magnitude space, otherwise (0), fit in flux space.\nDefault: 0\\tabularnewline\n\\hline \nrestbands & dictionary & A dictionary-like object, indexed by observed band with value corresponding\nrest-band. Used to specify which template is fit to each observed\nfilter. Example: ``s.restbands{[``'u'{]} = 'B'} means fit observed\nband u with B-band template. If not explicitly set, it is assumed\nthat a restband with the same name as the observed band is used.\\tabularnewline\n\\hline \nreplot & boolean & Replot the LC's after fitting or change in parameter? Default: 1\\tabularnewline\n\\hline \nquiet & boolean & Keep it quiet (non-verbose output)? Default: 1\\tabularnewline\n\\hline \nk_version & string & Which SED template to use: 'H3' for Eric Hsiao's latest, 'N' for Peter\nNugent, '91bg' for Peter Nugent's 91bg SED. Default: H3, unless :math:`\\Delta m_{15}>1.7`,\nin which case '91bg' is used.\\tabularnewline\n\\hline \n\\end{tabular}\n\n\\caption{Behavior modifying variables.\\label{tab:behave_var}}\n\\end{table}\n\n\n\nMember Functions\n--------------------------\n\nThese are the functions that you will use to fit light-curves, get\ninformation about the fit, plot the data, etc. Each function has explicit\narguments (some mandatory, some optional). Also, some of the member\nvariables will alter how a function works (see section \\ref{sub:Behaviour-Modifying-Variables}).\nThe most important functions are listed first, each with its own subsection,\nthen a final section has the less important, but useful functions.\nSome functions are not listed as they are internal to the class. Read\nthe code if you want details about any of the inner workings.\n\n\n\\subsubsection{Plot}\n\n\\texttt{\\textbf{plot(xrange=None, yrange=None, title=None, single=0,\ndm=1, fsize=1.0, linewidth=3, symbols=None, colors=None, relative=0,\nlegend=1, mask=0, label_bad=1)}}\n\nThis function simply plots the data to the screen (or other PGPLOT\ndevice if requested). All the arguments are optional and change the\nbehavior of the plot. You can specify ``xrange`` and ``yrange``\nto modify the extent of the plot. You can output to postscript file\nby specifying ``device=''somefile.ps/CPS''`` (see your local\nPGPLOT documentation for what devices are available). You can give\nthe plot a title by providing a string to that argument, change the\nline width and default symbol size with ``linewidth`` and ``fsize``,\nrespectively. \n\nIf you specify ``single=1``, then all the filters are plotted\non the same graph, with a magnitude offset of ``dm`` between\nthem.\n\nYou can modify the colors and symbols used for each filter by passing\na dictionary of filter-value pairs. For example, \\texttt{colors=\\{'B':'blue',\n'R':'red', 'I':'orange'\\}} and ``symbols=\\{'B':1, 'R':2, 'I':3\\``.}\nSee the ``matplotlib`` documentation for the number-symbol combinations\nor matplotlib documentation for symbols and colors.\n\n\n\\subsubsection{Fit\\label{sub:Fit}}\n\n``\\textbf{fit(bands=None, \\{parameter values\\``, kcorr=True,\nreset_kcorrs=True, mangle=True, margs=\\{\\}, {*}{*}args)}}\n\nThis function is the heart of the software: fitting a light-curve\nto the data by minimizing :math:`\\chi^{2}`. If you wish to restrict which\nfilters are fit, specify ``bands``, a list of filters to fit,\notherwise all filters are fit. So if, for example, you had data in\nB, V, r' (Sloan r), Jc, and Yc, you would specify {[}'B','V','r_s','Jc','Yc'{]}\nas the first argument. This will simultaneously fit the data in these\nfilters to templates specified in the rest-bands member variable.\nSo, if ``restbands``=\\{'B':'B', 'V':V', 'r_s':'R', 'Jc':'I',\n'Yc':'I'\\}, then the data in B would be fit with a B template, V with\na V template, r_s with an R template, Jc with an I template and Yc\nwith an I template (not that you'd really want to do this). \n\nThe arguments \\{parameter values\\} are where you assign values to\nparameters of the model in order to keep them fixed. If a parameter\nis not specified, it is free to vary. The current values are always\nused as starting points. Consult the model documentation to find out\nwhat parameters there are.\n\nThe remaining arguments are:\n\\begin{itemize}\n\\item :math:` ```kcorr``: If true, compute k-corrections after an initial\nfit to find the time of maximum, then fit again. If you want more\ncontrol over how this is done, set ``kcorr=0``, run ``kcorr()``\nmanually, then re-fit again with ``kcorr=0``.\n\\item reset_kcorrs: If true, zero-out any previously determined k-corrections\nbefore the fitting starts. If you have computed your own k-corrections\nand applied them, use ``reset_kcorrs=False`` and ``kcorr=False``.\n\\item ``mangle``: If true, the current model of the photometry is used\nto construct colors as a function of time. The SNIa SED is ``mangled''\nto match these colors before the k-corrections are computed.\n\\item margs: Optionally, you can modify how the k-corrections are performed\nby passing arguments as a dictionary. See section \\ref{sub:kcorr}\nfor optional arguments.\n\\item ``{*``{*}args}: Any optional arguments that the particular model\naccepts. For example, the ``EBV_model`` accepts the ``calibration``\nkeyword argument..\n\\end{itemize}\n\n\\subsubsection{Fit using MCMC\\label{sub:Fit-MCMC}}\n\n``\\textbf{fitMCMC(bands=None, \\{parameter values\\``, kcorr=1,\nreset_kcorrs=True, mangle=True, margs=\\{\\}, Nwalkers=None, threads=1,\nNiter=500, burn=200, tracefile=None, plot_triangle=False, {*}{*}args)}}\n\nThis function is an alternate version of the more traditional ``fit()``\nfunction. The arguments are precisely the same as in the case of fit(),\nwith the following additions and modifications:\n\\begin{itemize}\n\\item ``Nwalkers``: SNooPy uses emcee as the MCMC sampler, which spawns\nNwalkers parallel chains. These chains independently explore the shape\nof parameters space and more are needed as the dimensionality increases.\nIf None, the default is 10 times the number of free parameters.\n\\item ``threads``: on multi-core systems, you can run the parallel\nchains using muiltiple threads. Default is to use 1.\n\\item ``burn``: number of iterations to discard at the beginning of\neach chain, called burn-in time. Default is 200.\n\\item ``Niter``: total number of iterations (including burn-in) to\nrun. Default is 500.\n\\item ``tracefile``: if you want to keep the traces (for MC sampling\nlater), specify a filename here\n\\item ``plot_triangle``: if you have the ``triangle`` module,\nthis will plot a nice graphical representation of the PDF's and covariances.\n\\end{itemize}\nThe other major difference (and reason for using MCMC in the first\nplace) is that you can specify priors for parameters instead of simply\nholding them constant. To do this, specify the parameter as an argument\nto ``fitMCMC()`` and use the following strings to specify simple\npriors:\n\\begin{itemize}\n\\item ``'U,a,b'``: A Uniform prior on the interval (a,b). Replace a\nand b with floats.\n\\item ``'G,m,s'``: A Gaussian prior centered on m and with standard\ndeviation s.\n\\item ``'E,t'``: An exponential prior defined on :math:`(0,\\infty)` with\nscale length t.\n\\item Additionally, the model may have its own priors. For instance, the\ncolor_model allows you to specify special built-in priors using the\nrvprior keyword argument.\n\\end{itemize}\n\n\\subsubsection{Making k-corrections by hand\\label{sub:kcorr}}\n\n\\texttt{\\textbf{kcorr(bands=None, mbands=None, mangle=1, interp=1,\nuse_model=0, min_filter_sep=400, {*}{*}mopts))}}\n\nThis function allows the user to compute k-corrections that are decoupled\nfrom the fitting procedure (you might want to do this to have more\ncontrol over the k-corrections or to play around with the arguments\nwithout re-fitting each time). At its simplest (mangle=0), simply\nuse the SNIa SEDs and filter functions to compute k-corrections. If\nmangle=1, then there are more options.\n\nThe idea is that regardless of what has altered the shape of the supernova's\nSED (extinction or intrinsic variation), the observed colors of the\nsupernova give one a constraint on the overall ``tilt'' of the spectrum.\nIn the case of many bands, you can actually solve for a higher-order\nfit (cubic spline, etc). \n\nSimply call ``kcorr`` and supply it with a list of N filters,\nfrom which the N-1 colors will be constructed. These colors, and the\nfilter pass-bands, will be used to find a spline that, when multiplied\nwith the SED, produces the observed colors. By default, these N-1\ncolors are constructed from bands, but if you want to use only a subset,\nthen specify them in mbands.\n\nTo properly estimate the colors for any given day, one needs to have\na model for the light-curves. If you choose to use a template, then\nfit one beforehand. Otherwise, use the fit_spline() function to fit\na spline (see section \\ref{sub:LCMember-Functions}). If you do nothing,\nGLoEs will be used to interpolate data. Probably not a good idea at\nhigh redshift, where S/N is low. In any case, if you wish to use the\nreal data for the colors where possible, then set interp=0.\n\nWhen using ``mangle=1``, if you have two filters which have very\nsimilar effective wavelengths, but different shapes (V and g, for\ninstance), the splines can become very badly behaved. If min_filter_sep\nis set, then any filter whose effective wavelength is closer than\nmin_filter_sep to another is removed automatically from the set\nof colors.\n\n\n\\subsubsection{Other Useful functions\\label{sub:Other-Useful-functions}}\n\nHere is a list and brief summary of other functions belonging to the\nsn class:\n\\begin{itemize}\n\\item ``*choose_model(model)``*: Choose which model to use.\nAs of now, this is either ````EBV_model``'' or ````max_model``''.\n\\item ``*closest_band(wav, tempbands={[``'B', 'V', 'R', 'I'{]*)}}:\nFor each filter in the data, find the closest rest-frame filter. Returns\none of the strings listed in ``tempbands``. These strings must\nrepresent a valid filter found in the ``filters`` dictionary\n(see .\n\\item ``*compute_w(band1, band2, band3):``* Returns the reddening-free\nmagnitude in the sense that: w = band1 - R(band1,band2,band3){*}(band2\n- band3) for for instance compute_w(V,B,V) would give: w = V - Rv(B-V).\nThis is still in development.\n\\item ``*getEBVgal(self):``* Gets the value of E(B-V) due to\ngalactic extinction. The ra and decl member variables must be set\nbeforehand. \n\\item ``*get_color(band1, band2, nointerp=0):``* return the\nobserved SN color of band1 - band2. Returns a 4-tuple: (MJD, band1-band2,\ne_band1-band2, flag). Flag is one of: 0 - both bands measured at\ngiven epoch; 1 - only one band measured, other interpolated; 2 - extrapolation\n(based on template) needed; 3 - data interpolated or extrapolated\nbeyond template's definition, so not safe to use!\n\\item ``*get_mag_table(bands=None):``* This routine returns\na table of the photometry, where the data from different filters are\ngrouped according to day of observation. When data is missing, a value\nof 99.9 is inserted. Format of table is \\textquotedbl{}MJD mag1 emag1\nmag2 emag2 ... \n\\item ``*get_max(bands, restframe=0, deredden=0):``* After\na model or spline has been fit, determine the maximum magnitude, error,\nand time of maximum for the light-curves specified in ``bands``.\nIf ``rest frame=1``, then remove the K-corrections, thereby converting\nto rest-frame filters. If ``deredden=1``, then remove the galactic\nand host extinction. Otherwise, the maximum of the model array is\nused which, due to roundoff, K-corrections, etc. may not be the true\nmaximum. The function returns a 4-tuple: (``maxes``, ``e_maxes``,\n``T_maxes``, ``restband``). ``maxes`` is an array\nof maxima, ``e_maxes`` an array of their errors, ``T_maxes``\nan array of time of maxima, and ``restband`` is a list of the\nrest-bands used to fit each filter.\n\\item ``*get_rest_max(bands, deredden=0):``* Simply calls\n``get_max()`` with ``restframe=1``, for backward-compatibility.\n\\item ``*get_restbands():``* Automatically populates the rest-bands\nmember data with filters from the ``restbands`` member list,\nwhichever effective wavelength is closest to the observed bands. This\nis run automatically when the sn object is created. \n\\item ``*load(dictionary):``* Given a previously saved dictionary\n(as returned by save()), re-load the parameters.\n\\item \\texttt{\\textbf{lira(Bband, Vband, interpolate=0, tmin=30, tmax=90,\nplot=0):}} Use the Lira law to estimate the extinction. The B-V color\nis constructed as a function of time using filters ``Bband``\nand ``Vband``. The color excess is then estimated to be the median\noffset between (B-V) and the Lira Law in the time window \\texttt{tmin\n< t < tmax}. If ``interpolate=1``, then missing data is interpolated.\nUse ``tmin`` and ``tmax`` to restrict which data are used.\nUse ``plot=1`` to get a graph. The function returns a 3-tuple:\nE(B-V), the error and the fitted slope, which can be used as a diagnostic.\n\\item ``*mask_data():``* Interactively mask out bad data and\nunmask the data as well. The only two bindings are \\textquotedbl{}A\\textquotedbl{}\n(click): mask the data and \\textquotedbl{}u\\textquotedbl{} to unmask\nthe data. \n\\item ``*save():``* This will return the parameters dictionary,\nwhich can be used to save the state of the fit. Use load() to re-load\nthe parameters. \n\\item ``*summary():``* Get a quick summary of the data for this\nSN, along with fitted parameters (if such exist). \n\\item ``*update_sql(attributes=None, dokcorr=1):``* Updates\nthe current information in the SQL database, creating a new SN if\nneeded. If attributes are specified (as a list of strings), then only\nthese attributes are updated. \n\\end{itemize}\n\nLight-curve class\\label{sec:Lightcurve-class}\n=========================\n\nThe light-curve class, ``lc``, is a simpler class than sn (for\nnow). It is available for scripting by importing the ``lc`` module.\nIt basically contains the data of a single filter and a few functions\nto work with the data. Of particular interest might be the light-curve\nfitting functions, which allow one to make templates from well-sampled\nand high S/N data. Depending on the version of ``numpy`` and\nif you have ``pymc`` installed, you can fit light-curves with\nsplines, polynomials, and Gaussian Processes (if you have ``pymc``\ninstalled).\n\n\nMember data\n--------------------------\n\nTable \\ref{tab:lc_member_var} lists the member variables of the ``lc``\nclass. \n\n\\begin{table}\n\\begin{tabular}{|c|c|>{\\centering}p{4in}|}\n\\hline \nname & type & description\\tabularnewline\n\\hline \n\\hline \nband & string & name of the filter that this instance represents\\tabularnewline\n\\hline \nparent & sn inst. & A pointer to the ``sn`` instance that contains this ``lc``\ninstance.\\tabularnewline\n\\hline \nfilter & filter inst. & Instance of the filter object that corresponds to self.band\\tabularnewline\n\\hline \nMJD & float array & Array of observations dates, usually in Modified Julian Day\\tabularnewline\n\\hline \nt & float array & If Tmax has been solved, then this is an array of epochs\\tabularnewline\n\\hline \nmagnitude & float array & Array of observed magnitudes.\\tabularnewline\n\\hline \ne_mag & float array & Array of uncertainties in the magnitudes.\\tabularnewline\n\\hline \nK & float array & Array of k-corrections.\\tabularnewline\n\\hline \nmag & float array & Like magnitude, but if K are defined, then this returns the k-corrected\nmagnitudes (self.magnitude - self.K). Otherwise, it is equivalent\nto self.magnitude.\\tabularnewline\n\\hline \nflux & float array & Automatically generated array of fluxed, based on the magnitudes and\nzero point defined by band.\\tabularnewline\n\\hline \ne_flux & float array & Array of uncertainties in the flux.\\tabularnewline\n\\hline \ntck & list & 3-element list defining a spline: array of knot points, array of spline\ncoefficients, and the order of the spline. This can be used with scipy.integrate.splev()\nto evaluate the spline at any point (see help page for splev).\\tabularnewline\n\\hline \nmodel & float array & A model of the light-curve based on a template fit (generated automatically\nby template()).\\tabularnewline\n\\hline \nmodel_t & float array & The times for the model.\\tabularnewline\n\\hline \nmodel_sigmas & float array & Errors in the model. Generated if do_sigma=1 in the call to template() \\tabularnewline\n\\hline \ndm15, e_dm15 & floats & The computed value of dm15 and its error (if do_sigma=1) from the\nspline. Generated by template()\\tabularnewline\n\\hline \nTmax,e_Tmax & floats & The computed value of Tmax and its error (if do_sigma=1) from the\nspline. Generated by template()\\tabularnewline\n\\hline \nMmax, e_Mmax & floats & The computed value of the maximum magnitude and its error (if do_sigma=1)\nfrom the spline. Generated by template()\\tabularnewline\n\\hline \nmask & int array & The mask defines which data are good. If mask{[}i{]} = 1, then the\ndata at element i is considered good (and will be used in a fit),\notherwise, if it is 0, the data is bad and ignored by fits.\\tabularnewline\n\\hline \n\\end{tabular}\n\n\\caption{Member variables of the lc class\\label{tab:lc_member_var}}\n\\end{table}\n\n\n\nMember Functions\\label{sub:LCMember-Functions}\n--------------------------\n\nThe most useful member functions are given below:\n\\begin{itemize}\n\\item ``*eval(self, times, recompute=0, t_tol=0.1, {*``{**args):}}\nInterpolate (if required) the data to time 'times'. If recompute=1,\nforce a re-computation of the spline coefficients (you can also use\nany of the arguments for mkspline() here). If there is a data point\ncloser than t_tol away from a requested time, that value is used\nwithout interpolation. \n\\item ``*mask_emag(self, max):``* Update the lc's mask to only\ninclude data with e_mag < max. \n\\item ``*mask_epoch(self, tmin, tmax):``* Update the lc's mask\nto only include data between tmin and tmax.\n\\item \\texttt{\\textbf{template(self, fitflux=False, do_sigma=True, Nboot=50,\nmethod=default_method, compute_params=True, interactive=False, {*}{*}args):}}\nGenerate a smooth interpolation template of the data. You can choose\nwhich method to use by specifying ``method``. To get a list of\nmethods available for your setup, use the ``list_types()`` function.\nIf you wish to fit the flux domain, specify fitflux=True. If you set\\texttt{\ncompute_params=True}, the interpolator will attempt to measure the\nfollowing light-curve characteristics and save them as member variables.\nIn order to compute errors in these values, the algorithm may need\nto do bootstrap errors, in which case, ``Nboot`` is the number\nof iterations to use. The computed variables are:\n\n\\begin{itemize}\n\\item ``self.Tmax`` and ``self.e_Tmax``: The time of earliest\nmaximum for the light-curve, with error.\n\\item ``self.Mmax`` and ``self.e_Mmax``: The magnitude at self.Tmax,\nwith error\n\\item ``self.dm15`` and`` self.e_dm15``: The Phillips parameter\n(change in magnitude between Tmax and day 15 in the rest frame of\nthe SN), with error.\n\\end{itemize}\n\nIn the following section, I describe the different interpolation methods\nand their parameters, which you can specify in the call to ``template()``.\nThere is a new argument: ``interactive``. If true, a plot of\nthe light-curve will open and you will be able to interactively fit\nthe data. See section for more details.\n\n\\item ``*plot(self, flux=0):``* Plot the light-curve and possibly\nthe fitting spline. If an interpolatiing template has been fit, a\nsecond panel will show the residuals. \n\\end{itemize}\nNote: If you fit a template and then use the parent sn instance's\nplot() function, the spline will be plotted on top of the data (unless\nthere is already a model defined from a fit(), which takes precedence).\n\n\nModel class\\label{sec:Model-class}\n=========================\n\nThis class is designed to do all the work of fitting a model to data.\nIt uses the Levenberg-Marquardt least-squares algorithm for find the\nminimum :math:`\\chi^{2}`. It is designed to be sub-classed in order to\ncreate specific models. These sub-classes will inherit the basic fitting\ncode and so you can concentrate on setting up the model. In this section,\nI outline the basic structure of the class, so that you can access\nthe underlying machinery to do your own coding (or design your own\nmodel). The casual user need not worry about any of this. SNooPy comes\nwith two models: ``EBV_model`` and ``max_model``.\n\nIf you want to create your own model, your best bet is to simply modify\nthe existing ``model.py`` module and add your own. Simply create\na subclass based on the ``model`` class. You then override ``self.parameters``,\n``self.__init__()``, ``self.guess()``, ``self.setup()``,\n``self.__call__(),`` and ``self.get_max()``. Each is\ndescribed in a separate section below.\n\n\nself.parameters\n--------------------------\n\nThe first thing to define in the model class is the ``self.parameters``\nmember variable. This is a dictionary that contains parameter:value\npairs. The model will use these parameters to build the numerical\nmodel, which is sent to scipy's ``leastsq`` routine. Another\nmember variable that has the same keys is ``self.errors``. This\ndictionary will have the final errors of the fit stored in it. As\nan example, here are the parameters used by the ``EBV_model``\nclass:\n\n\\begin{table}\n\\begin{tabular}{|c|l|}\n\\hline \nVariable & Description\\tabularnewline\n\\hline \n\\hline \nTmax & Time of B maximum (days).\\tabularnewline\n\\hline \ndm15 & The decline rate parameter, :math:`\\Delta m_{15}` (mag.)\\tabularnewline\n\\hline \nEBVhost & Host :math:`E\\left(B-V\\right)` reddening (mag.)\\tabularnewline\n\\hline \nDM & Distance modulus (mag.)\\tabularnewline\n\\end{tabular}\n\n\\caption{Fit parameters of the ``EBVmodel`` instance.\\label{tab:fit_param}}\n\\end{table}\n\n\nThe model can also have a variable number of parameters, as is the\ncase in ``max_model``. In this case, you can dynamically set\nup ``self.parameters`` in the ``self.setup()`` function\n(see below).\n\n\nself.__init__(self, parent)\n--------------------------\n\nNext, you will override the ``self.__init()`` function. The\nonly two arguments are ``self`` and ``parent``. ``self.__init__``\nmust also call the ``model.__init__()`` function as part\nof the initialization. Other than that, you are free to setup whatever\nmember variables you want. ``self.__init__()`` is called\nwhen the ``model`` instance is created, that is, when the ``sn``\nobject is created or when ``sn.choose_model()`` is called.\n\n\nself.setup(self)\n--------------------------\n\nThere are cases when you need to do some setting up after the user\nhas called ``sn.fit()``, but before the actual fitting occurs.\nFor example, in the case of ``max_model``, the number of parameters\ndepends on how many filters the user fits (each filter has its own\nmaximum). So in ``self.setup()``, ``self.parameters`` is\nupdated. This is not needed in ``EBV_model``, because it has\na fixed set of parameters regardless of how many filters are fit.\nHowever, it \\emph{does} do some initial checking to make sure that\nif ``EBVhost`` is a free parameter, the user has asked to fit\nat least two filters.\n\n\nself.guess(self, param)\n--------------------------\n\nBefore the fitting starts, any un-initialized variables (those whose\nvalue are ``None``) need to be set to valid values, presumably\nclose to the actual solution. You must override ``self.guess()``\nto do this. For any parameter ``param``, return an initial guess\nfor this parameter. The ``self.guess()`` function is called after\n``self.setup()``, but just before the fitting starts.\n\n\nself.__call__(self, band, t, {*}{*}args)\n--------------------------\n\nThis is the meat of the model. Given a filter ``band`` and time\n``t`` (which is an array of times), return the model for the\nlight-curve as an array of floats. Now, the question comes up: should\nthe model return magnitudes or fluxes? The answer is: either. You\ncan choose to return a model in magnitudes or fluxes, but you need\nto set the member variable ``self.model_in_mags`` to ``true``\nif your model returns magnitudes, or ``false`` if it returns\nfluxes. \\emph{SNooPy always does the actual least-squares fitting\nin fluxes}.\n\nYou can define any number of optional arguments after ``t`` (replace\n``{*``{*}args} with your arguments). You can then specify these\noptional arguments in the ``sn.fit()`` call and they will propagate\nthrough to the ``__call__()``. For example, ``EBV_model``\nhas the optional ``calibration`` parameter.\n\n\nself.get_max(self, bands, restframe=0, deredden=0)\n--------------------------\n\nThe last member function to override is get_max(). Given a set of\nfilters (``bands``), return the model's value at maximum light.\nIf the optional argument ``restframe=1``, then apply a k-correction\nto the value. If ``deredden=1``, remove any reddening (galactic\nand host, if it is defined). \n\n\nTemplate class\\label{sec:Template-class}\n=========================\n\n\ndm15temp.py\n--------------------------\n\nThis class is basically a wrapper to Prieto's template generator and\nis used to generate templates for the ``sn`` class. It is available\nto scripts by importing the ``dm15temp`` module. The constructor\ndoesn't need any arguments, so you simply make an instance as follows:\n\n\\begin{verbatim}\nt = template()\n\\end{verbatim}\n\nThe instance then has member variables for each filter defining a\ntemplate: ``t.B, t.V, t.R``, and ``t.I``. There are also\nerrors in these quantities: ``t.eB, t.eV, t.eR``, and ``t.eI``.\nThe epoch is contained a variable ``t.t`` Each of these variables\nis a python array. Immediately after creating the instance, there\nwill be no template defined. One has to make it with a specific value\nof :math:`\\Delta m_{15}`:\n\n\\begin{verbatim}\nt.mktemplate(1.1)\n\\end{verbatim}\n\nThis will run Prieto's code and insert the proper values into the\nmember variables. This is all done in C, so is quite fast. The only\nother member function is ``t.eval(band, times, z=0).`` This function\nis used to evaluate the template at specific times (useful for doing\nleast-squares fitting to data). Simply specify which filter as a string\n(``band``) and an array of epochs to evaluate (``times``).\nThe function returns two values: an array of interpolated values of\nthe template and a mask array. This mask will be 1 for interpolation\nand 0 for extrapolation (where you should not use the data). You can\nalso specify a redshift z so that the times are interpreted as observed\nepochs and will be converted to rest-frame epochs before evaluating.\n\n\nCSPtemp.py\n--------------------------\n\nThis is new module and constitutes a new method very similar to Prieto's\ntechnique. The idea is that one has a set of N well-sampled light-curves\nwith pre-maximum data, so that :math:`\\Delta m_{15}`, :math:`T_{max}`, and :math:`m_{max}`\nare all well determined. One then has a set of data points that define\na surface in the 3D parameter space: :math:`\\left(t-T_{max},\\Delta m_{15},m-m_{max}\\right)`.\nThe problem is that this surface is sparsely and heterogeneously sampled.\nPrieto's method solves this in two steps: 1) construct spline representations\nof the N light-curves in the :math:`t-`direction, then interpolate in the\n:math:`\\Delta m_{15}`-direction by way of averaging the splines with an\nadaptive weight function.\n\nThis new generator uses an algorithm developed by Barry Madore called\nGLoEs (Gaussian Local Estimation). In 1-D, one simply interpolates\nby way of a quadratic (or higher-order polynomial) through all the\navailable data points. However, the weights of the points are determined\nusing a Gaussian centered at the desired interpolation point and with\na width sufficient to include the minimum number of points required\nfor the polynomial. In 2D, one uses an elliptical Gaussian in the\nsame way and fits a 2D polynomial to the data points. The advantage\nis that this is done in one step and data can be added without the\nneed to re-train the fitter. The disadvantages are: 1) it's a slower\nprocess and 2) the resulting templates have more freedom to deviate\nfrom the idealized behaviour. For instance, if one asked for a template\nwith :math:`\\Delta m_{15}=1.15`, and actually measured :math:`\\Delta m_{15}`\ndirectly, you would get a slightly different answer. As such, :math:`\\Delta m_{15}`\nbecomes a parameter, rather than a direct measurable.\n\nDespite these very different approaches, the ``CSPtemp.py`` module\nbehaves exactly the same as the older dm15temp.py module as far as\nthe user is concerned. They can be used interchangeably. However,\nCSPtemp.py uses the CSP dataset, so offers a different set of filters.\n\n\nubertemp.py\n--------------------------\n\nIn order to facilitate mixing-and-matching of different filters, a\nmodule had to be created that would allow the user to pick either\nthe CSP or Prieto filters. This is ``ubertemp``. The way you\nchoose which filters to use is by name. Asking for a filter in the\nset ``u,B,V,g,r,i,Y,J,H`` will generate CSP templates. Asking\nfor a filter in the set ``Bs,Vs,Rs,Is`` will generate Prieto\ntemplates (think of the 's' as 'standard' system, as opposed to the\nCSP templates which are in the CSP natural system). So, for example,\nyou could compute a poor-man's S-correction between the CSP natural\nB-band and the standard B-band:\n\n\\begin{verbatim}\nIn[1]:  t = ubertemp.template()\nIn[2]:  t.mktemplate(1.4)\nIn[3]:  B_CSP = t.eval('B', arange(-10,60,1.0))\nIn[4]:  B_std = t.eval('Bs', arange(-10,60,1.0))\nIn[5]:  Scorr = B_CSP - B_std\n\\end{verbatim}\n\nAs far as fitting goes, simply use the ``restbands`` member variable\nto choose which filter you wish to fit with. The model will then take\ncare of generating the appropriate template and fit it to your observations.\n\n\nFilters and Spectra\\label{sec:Filters-and-Spectra}\n=========================\n\nTwo other useful classes are ``filter`` and ``spectrum``.\nThey are available for scripting by importing the ``filters``\nmodule. The filter class inherits from the spectrum class, which is\nthe more general object (a filter can be considered a spectrum of\nsorts).\n\n\nspectrum object\n--------------------------\n\nYou create a spectrum instance with two optional arguments:\n\n\\begin{verbatim}\nspec = spectrum(name, file)\n\\end{verbatim}\n\n\nThe name is just an identifying string. The file contains the spectrum\nas (lambda, flux) pairs, one per line. The member variables are given\nin the following table.\n\n\\begin{table}\n\\begin{tabular}{|c|c|>{\\centering}p{4in}|}\n\\hline \nname & type & description\\tabularnewline\n\\hline \n\\hline \n``name`` & string & Descriptive name for the spectrum\\tabularnewline\n\\hline \n``file`` & string & Filename of the spectral data\\tabularnewline\n\\hline \n``wave`` & float array & Array of wavelengths\\tabularnewline\n\\hline \n``resp`` & float array & Array of fluxes or responses (for filters)\\tabularnewline\n\\hline \nflux & float array & Alias for 'resp'\\tabularnewline\n\\hline \ncomment & string & Any useful comments you want to ad\\tabularnewline\n\\hline \nwavemax,wavemin & float & The minimum and maximum wavelengths defined by this spectrum\\tabularnewline\n\\hline \navewave & float & The average wavelength (useful for filters)\\tabularnewline\n\\hline \n\\end{tabular}\n\n\\caption{Member variables of the spectrum class.}\n\\end{table}\n\n\n\nFilter object\n--------------------------\n\nThe filter object inherits from the spectrum object, so it has all\nits member variables. The filter is created in the same way the spectrum\nis, except it has one additional optional argument:\n\n\\begin{verbatim}\nf = filter(name, file, zp)\n\\end{verbatim}\n\n\nThe argument zp is the zeropoint of this filter. If you know it beforehand,\nspecify it here. Otherwise, you can use the compute_zpt() member\nfunction described below. The zero-point is stored as the member variable\n``f.zp``. The filter class also adds a few extra member functions,\nwhich are described below:\n\\begin{itemize}\n\\item ``*compute_zpt(spectra, mag, zeropad=0):``* Given a single\nspectrum or list of spectrum instances (``spectra``) and a list\nof associated magnitudes (``mag``), compute the zero-points of\nthis filter for these spectra, which are returned as an array. You\ncould average the output to get a good handle on the actual zero-point.\nIf the wavelength range of the filter is not completely inside the\nwavelength range of the spectrum, an exception is raised, unless ``zeropad=1``,\nin which case the spectrum is assumed to be 0 outside the filter range.\n\\item ``*response(wavespec, flux=None, z=0, zeropad=0, photons=1):``*\nGiven an array of spectra, compute the response of the filter across\nthe spectra: :math:`\\int F(\\lambda)S(\\lambda)\\lambda/ch\\: d\\lambda` (if\n``photons=1``), or :math:`\\int F(\\lambda)S(\\lambda)\\: d\\lambda` if\n``photons=0``. You can either specify the spectra as arrays of\nspectrum instances and leave ``flux=None``, or else specify an\narray of wavelength arrays and flux arrays. If the optional redshift,\n``z``, is given, the spectrum is red-shifted before the integration\nis done (actually, the filter is blue-shifted). zeropad has the same\nmeaning as in compute_zpt(). \n\\item ``*synth_mag(wavespec, flux=None, z=0, zeropad=0, photons=1):``*\nGiven an array of spectra, compute the synthetic magnitude through\nthis filter. The zero-point must be defined in the instance (use ``compute_zpt()``\nif needed). If a redshift is specified, the filter is blue-shifted\nby :math:`1/(1+z)` before computing the response (as in ``response()``).\nArguments are the same as ``response()``.\n\\end{itemize}\n\nDefault spectra and filters\\label{sub:default_filters}\n--------------------------\n\nThe ``filters`` module has two variables: ``fset`` and ``spectra``.\n``fset`` (filter set) is a dictionary-like object of pre-defined\nfilters for your use. The filters have pre-defined zero-points, so\ncan be used to compute synthetic magnitudes ``out of the box'' (see\nthe accompanying document ``zeropoints.pdf`` for a discussion\non how there are determined). The filters are organized by observatory/telescope/filter.\nYou can list the observatories using fset.list_observatories(). You\nthen use the observatory name as a member variable to get the observatory.\nEach observatory has a function list_telescopes(). The telescope\nname is used as a member variable to get the telescope, which has\na list_filters() function. Each filter can also have a unique string\nID that can be used directly. Here are some examples to give you an\nidea how it works.\n\n\\begin{verbatim}\nprint fset.list_observatories\nprint fset['B']\nprint fset.LCO.Swope.B\nprint fset.B\nprint fset.LCO.list_telescopes()\nprint fset.LCO.Swope.list_filters()\n\\end{verbatim}\n\nThese filters are loaded at runtime and come from data files distributed\nwith SNooPy. The are located in the source distribution in the folder\n``SNooPy/filters/filters``. In that folder are folders for each\nobservatory. In each observatory foder, there are folders for each\ntelescope/instrument, and in each telescope/instrument folder, there\nare files that contain the filter bandpasses and a file named ``filters.dat``.\nHere is a portion of the folder structure:\n\n\\begin{verbatim}\n|-- filters\n|   |-- APO\n|   |   -- SDSS\n|   |       |-- filters.dat\n|   |       |-- sdss_g.dat\n|   |       |-- sdss_i.dat\n|   |       |-- sdss_r.dat\n|   |       |-- sdss_u.dat\n|   |       |-- sdss_z.dat\n|   |-- CFHT\n|   |   -- Megacam\n|   |       |-- filters.dat\n|   |       |-- g_snls.dat\n|   |       |-- i_snls.dat\n|   |       |-- r_snls.dat\n|   |       |-- z_snls.dat\n\\end{verbatim}The filters.dat file has a table of the filters, their names, and\nzero-points. Here is a sample of the SDSS filters.dat file:\n\n\\begin{verbatim}\nu_s sdss_u.dat 12.4757864 sloan u at APO \ng_s sdss_g.dat 14.2013159905 sloan g at APO \nr_s sdss_r.dat 14.2156544329 sloan r at APO \ni_s sdss_i.dat 13.7775438954 sloan i at APO \nz_s sdss_z.dat 11.8525822106 sloan z at APO\n\\end{verbatim}Columns are separated by white space. The first column is a unique\nID (SNooPy will complain if you use an ID that was previously used).\nThe next column indicates the data file that defines the filter. The\nthird column is the filter zero-point (:math:`zp`), in the sense that \n\\[\nm=-2.5\\log_{10}\\left(\\frac{1}{ch}\\int F\\left(\\lambda\\right)S\\left(\\lambda\\right)\\lambda d\\lambda\\right)+zp\n\\]\nAnother option for the zero-point column is to specify the magnitude\nof a standard spectrum. For instance, you could use the string ````VegaB=0.0``''.\nIn this case, the zero-point is determined by setting the synthetic\nmagnitude of the spectrum ``VegaB`` \\citep{2004AJ....127.3508B}\nto zero. \n\nThe format of the filter response files is simply two columns: wavelength\n(in angstroms) and flux.\n\nYou can add your own filters by making the appropriate folders. You\ncan either add filters to an existing observatory/instrument folder\nor make one of your own. However, you must do this in the source folder\n(not the install folder in ``site-packages``). After you have\nadded your filters, run the ``update-snpy`` script.\n\nThe filters module also comes with some spectra in a dictionary called,\n``standards`` that behaves much like ``fset``. The spectra\nare organized by ``spectra.system.spectrum``. Currently, we have\n3 systems: ``Vega, Smith, and Landolt``. Vega has several SEDs\nfrom CALSPEC. Smith has the standards from \\citet{1996AJ....111.1748F}.\nLandolt has the spectrophotometric standards from \\citet{2005PASP..117..810S}\nEach of these refers to another dictionary of standards. Here's now\nto get their names:\n\n\\begin{verbatim}\nIn[1]:  standards.list_systems()\nIn[2]:  standards.list_SEDs()\nIn[3]:  standards.Landolt.list_SEDs()\n\\end{verbatim}Just like fset, you can refer to an SED by a short-name:\n\n\\begin{verbatim}\nIn[1]:  print spectra['VegaB']\nVegaB:  Vega spectrum from Calspec, version 5 (Bohlin & Gilliand (2004) AJ 127 3508)\n\\end{verbatim}\n\nBecause these are spectum objects, you can do things like compute\nsynthetic magnitudes from any of the filters in SNooPy. For example:\n\n\\begin{verbatim}\nIn[1]:  Bvega = fset['B'].synth_mag(spectra['VebaB'])\nIn[2]:  Bvega = fset['V'].synth_mag(spectra['VebaB'])\nIn[3]:  print Bvega, Vvega, Bvega-Vvega \n0.0418920257375 0.0160448066956 0.0258472190419\n\\end{verbatim}\n\n\nComing Soon(ish)\n=========================\n\nHere is just a list of things which I have planned for the future,\nbut have not yet implemented.\n\\begin{enumerate}\n\\item Incorporate the SCP B-band template in order to compute their stretch\nvalues.\n\\item Use other fitting functions besides B-splines to generate templates\n(polynomials, custom parametric functions, etc).\n\\item Ability to plot the confidence intervals on the fitted parameters\nin different cuts of parameter space.\n\\item Ability to impose priors on the parameters. Right now, there is only\na fixed prior on :math:`\\Delta m_{15}` that can be turned on and off. I'd\nlike to implement arbitrary priors from the user.\n\\item Automatically do a grid-search for the minimum :math:`\\chi^{2}` and plot\nconfidence intervals.\n\\item Make a GUI (in the far far distant future and only if someone buys\nme a really good bottle of Scotch).\n\\end{enumerate}\n\\bibliographystyle{apj}\n\\bibliography{highz_paperI}\n\n\n\\appendix\n\nmySQL Schema\n=========================\n\n\\label{sec:mySQL-Schema}The required ``mySQL`` schema consists\nof a single database called\\noun{ }``SN`` that contains two tables.\nOne is named ``\\noun{SN``}``e`` and the other is ``Photo``.\nSNe holds the global information about each supernova (redshift, ra,\ndec, etc). The ``Photo`` table holds the individual points on\nthe light-curve. You an add extra columns to the tables and other\ntables to your database, these are just the minimum required.\n\n\nSNe Table\n--------------------------\n\nHere is the schema for the SNe table. \n\n\\begin{tabular}{|c|c|c|c|c|c|}\n\\hline \nField & Type & Null & Key & Default & Comment\\tabularnewline\n\\hline \n\\hline \nSNId & int(11) & NO & PRI & NULL & The unique identifier for each SN\\tabularnewline\n\\hline \nname & varchar(20) & NO &  & None & A string identification (use this to retrieve)\\tabularnewline\n\\hline \nz & float & YES &  & NULL & redshift\\tabularnewline\n\\hline \nra & float & YES &  & NULL & Right-ascension in decimal degrees\\tabularnewline\n\\hline \ndecl & float & YES &  & NULL & Declination in decimal degrees\\tabularnewline\n\\hline \nobs1 & int(11) & YES &  & NULL & Epoch of first observation\\tabularnewline\n\\hline \nTmax & double & YES &  & NULL & Time of B-maximum\\tabularnewline\n\\hline \ne_Tmax & double & YES &  & NULL & error in Tmax\\tabularnewline\n\\hline \ndm15 & double & YES &  & NULL & decline-rate parameter\\tabularnewline\n\\hline \ne_dm15 & double  & YES &  & NULL & error in dm15\\tabularnewline\n\\hline \ns & double & YES &  & NULL & stretch\\tabularnewline\n\\hline \ne_s & double & YES &  & NULL & error in s\\tabularnewline\n\\hline \nEBVhost & double  & YES &  & NULL & Host extinction\\tabularnewline\n\\hline \ne_EBVhost & double & YES &  & NULL & error in EBVhost\\tabularnewline\n\\hline \nDM & double & YES &  & NULL & Distance modulus\\tabularnewline\n\\hline \ne_DM & double & YES &  & NULL & error in DM\\tabularnewline\n\\hline \nrchisq & double & YES &  & NULL & reduced chi-squared\\tabularnewline\n\\hline \nobject & blob & YES &  & NULL & storage for ``sn`` object\\tabularnewline\n\\hline \n\\end{tabular}\n\n\nPhoto Table\n--------------------------\n\nHere is the schema for the only other table needed by ``SNooPy``.\n\n\\begin{tabular}{|c|c|c|c|cc|}\n\\hline \nField & Type & Null & Key & Default & Comment\\tabularnewline\n\\hline \n\\hline \nPhotoID & int(11) & NO & PRI & NULL & unique running ID number\\tabularnewline\n\\hline \nSNId & int(11) & YES &  & NULL & cross-identification to the SN\\tabularnewline\n\\hline \nname & varchar(20) & NO &  & NULL & string identification\\tabularnewline\n\\hline \nJD & double & YES &  & NULL & Julian Day of the observation\\tabularnewline\n\\hline \nfilter & varchar(3) & YES &  & NULL & filter identifier\\tabularnewline\n\\hline \nm & double & YES &  & NULL & magnitude\\tabularnewline\n\\hline \ne_m & double & YES &  & NULL & error in m\\tabularnewline\n\\hline \nK & double & YES &  & NULL & K-correction\\tabularnewline\n\\hline \ne_K & double & YES &  & NULL & error in K\\tabularnewline\n\\hline \n\\end{tabular}\n\\end{document}\n", "meta": {"hexsha": "a7946787efd4f319161b9802ef7f0a6a6573744d", "size": 67564, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "depricated/doc/snpy.tex", "max_stars_repo_name": "emirkmo/snpy", "max_stars_repo_head_hexsha": "2a0153c84477ba8a30310d7dbca3d5a8f24de3c6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-01-14T19:40:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-05T12:19:39.000Z", "max_issues_repo_path": "depricated/doc/snpy.tex", "max_issues_repo_name": "emirkmo/snpy", "max_issues_repo_head_hexsha": "2a0153c84477ba8a30310d7dbca3d5a8f24de3c6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2017-04-25T20:06:22.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-09T20:46:41.000Z", "max_forks_repo_path": "depricated/doc/snpy.tex", "max_forks_repo_name": "emirkmo/snpy", "max_forks_repo_head_hexsha": "2a0153c84477ba8a30310d7dbca3d5a8f24de3c6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2017-04-25T19:57:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-12T11:54:19.000Z", "avg_line_length": 44.3915900131, "max_line_length": 115, "alphanum_fraction": 0.742140785, "num_tokens": 17760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.41829521274664994}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{booktabs,amssymb,amsmath,comment,bm,url}\n\\usepackage{graphicx}\n\\usepackage{natbib}\n\\bibliographystyle{abbrvnat}\n\\setcitestyle{authoryear,open={(},close={)}}\n\\newcommand{\\JRT}[1]{\\textcolor{red}{JRT: #1}} \n\n\\title{Error Bar Choices in HERA PSPEC}\n\\author{pspec team}\n\\begin{document}\n\n\\maketitle{}\n\\begin{abstract}\n    In this memo we summarize the math behind several ways to derive error bars on power spectra which are available in the current pipeline of HERA PSPEC.  \n\\end{abstract}\n\n\\section{Foreground/systematics dependent variance}\n\\label{ap:fg_dependent_var}\n\nWe begin with a general expression of the variance on power spectra with the existence of foregrounds or systematics, which includes both the noise variance and the signal-noise coupling term. Given two delay spectra $\\tilde{x}_1 = \\tilde{s} + \\tilde{n}_1$ and $\\tilde{x}_2 = \\tilde{s} + \\tilde{n}_2$, and we express $\\tilde{s} = a + b i$, $\\tilde{n}_1 = c_1 + d_1 i$ and $\\tilde{n}_2 = c_2 + d_2 i$, the power spectra formed from $\\tilde{x}_1^* \\tilde{x}_2$ is \n\\begin{align*}\nP_{\\tilde{x}_1\\tilde{x}_2} & = \\tilde{s}^*\\tilde{s} + \\tilde{s}^*\\tilde{n}_2 + \\tilde{n}_1^*\\tilde{s} + \n\\tilde{n}_1^*\\tilde{n}_2 \\notag \\\\\n& = \\{a^2+b^2 + a(c_1+c_2) + b(d_1+d_2) + c_1c_2 + d_1d_2\\} \\notag \\\\\n& \\phantom{=} + \\{a(d_2-d_1)+b(c_1-c_2)+d_2 c_1-d_1 c_2\\}i \\,.\n\\end{align*}\n\nHere we consider $\\langle s \\rangle = s$, which means $a$ and $b$ are not random variables, but related to the true signal power spectrum by $P_{\\tilde{s}\\tilde{s}} = a^2 +b^2$, and $c_1$, $d_1$, $c_2$ and $d_2$ are i.i.d random normal variables. We then have \n\\begin{align}\n\\label{eq:var_real_ps}\n\\text{var} \\left[\\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2}) \\right] &= \\text{var} \\left[a^2+b^2 + a(c_1+c_2) + b(d_1+d_2) + c_1c_2 + d_1d_2 \\right] \\notag \\\\\n& = 2(a^2+b^2)\\langle c_1^2\\rangle + 2\\langle c_1^2\\rangle^2 \\notag \\\\\n& = \\sqrt{2}P_{\\tilde{s}\\tilde{s}}P_\\text{N} + P_\\text{N}^2 \\notag \\\\\n& = \\sqrt{2}\\langle \\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2})\\rangle P_\\text{N} + P_\\text{N}^2 \\,.\n\\end{align}\nIn the equations above we have used the relation $\\text{var} ( c_1c_2 + d_1d_2) = 2\\langle c_1^2\\rangle^2 = P_\\text{N}^2$, where $P_\\text{N}$ is the analytic noise power spectrum we will refer to again later. We have also used the fact $\\langle \\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2})\\rangle = P_{\\tilde{s}\\tilde{s}}$, therefore we can choose $\\sqrt{2}\\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2}) P_\\text{N} + P_\\text{N}^2$ as a general form of error bars with the existence of foregrounds or systematics. Also, since $\\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2})$ could be negative due to noise randomness, we explicitly exert a zero clipping for negative values of $\\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2})$. This will of course come with excess variance, which is not ideal, but may still be a good first-order approximation in the limit that we don't have good signal or residual systematic models.   \n\nIf we consider the variance on the whole complex values of power spectrum, then \n\\begin{align}\n\\label{eq:var_ps}\n\\text{var} \\left[P_{\\tilde{x}_1\\tilde{x}_2} \\right] &= \\text{var} \\left[a^2+b^2 + a(c_1+c_2) + b(d_1+d_2) + c_1c_2 + d_1d_2 \\right] \\notag \\\\\n&\\phantom{=} +  \\text{var} \\left[a(d_2-d_1)+b(c_1-c_2)+d_2 c_1-d_1 c_2 \\right] \\notag \\\\\n& = 4(a^2+b^2)\\langle c_1^2\\rangle + 4\\langle c_1^2\\rangle^2 \\,.\n\\end{align}\nIt is just the form in \\citet{kolopanis2019simplified}, while they used the notation $P_\\text{N} = 2\\langle c_1^2\\rangle$, thus $\\text{var} \\left[P_{\\tilde{x}_1\\tilde{x}_2} \\right] = 2 P_{\\tilde{s}\\tilde{s}} P_\\text{N} + P_\\text{N}^2$ there. \n\n\\section{Analytic method from QE formalism}\n\\label{ap:analytic}\nThe QE formalism used in HERA PSPEC power spectrum estimation \\footnote{\\url{http://reionization.org/wp-content/uploads/2020/04/HERA044_power_spectrum_normalization_v2.pdf}} naturally leads to an analytic expression of the output covariance between bandpowers. \n\nIn HERA PSPEC, an unnormalized estimator to $\\alpha$th bandpowers $\\hat{q}_\\alpha$ is defined as $\\hat{q}_\\alpha = \\bm{x}_1^\\dagger \\bm{Q}^{12,\\alpha} \\bm{x}_2 = \\sum_{ij} \\bm{x}_{1,i}^*\\bm{Q}^{12,\\alpha}_{ij}\\bm{x}_{2,j}$, where $\\bm{x}_{1}$ and $\\bm{x}_{2}$ are visibilities across frequencies. The key idea here is to propagate the input covariance on visibilities between frequencies into the output covariance on bandpowers between delays. We continue to define three sets of input covariance matrices $\\bm{C}^{12}$, $\\bm{U}^{12}$ and $\\bm{S}^{12}$\n\\begin{align}\n\\bm{C}^{12}_{ij} \\equiv & \\langle \\bm{x}_{1,i} \\bm{x}_{2,j}^* \\rangle - \\langle \\bm{x}_{1,i} \\rangle \\langle \\bm{x}_{2,j}^*\\rangle \\notag\\\\\n\\bm{U}^{12}_{ij} \\equiv & \\langle \\bm{x}_{1,i} \\bm{x}_{2,j}\\rangle - \\langle \\bm{x}_{1,i}\\rangle\\langle \\bm{x}_{2,j}\\rangle \\notag \\\\\n\\bm{S}^{12}_{ij} \\equiv & \\langle \\bm{x}_{1,i}^* \\bm{x}_{2,j}^*\\rangle - \\langle \\bm{x}_{1,i}^*\\rangle \\langle \\bm{x}_{2,j}^*\\rangle \\,,\n\\end{align}\nand we have\n\\begin{align}\n\\langle \\hat{q}_\\alpha \\hat{q}_\\beta \\rangle - \\langle \\hat{q}_\\alpha \\rangle\\langle \\hat{q}_\\beta\\rangle =& \n\\sum_{ijkl}\\langle \\bm{x}_{1,i}^*\\bm{Q}^{12,\\alpha}_{ij}\\bm{x}_{2,j}\\bm{x}_{1,k}^*\\bm{Q}^{12,\\beta}_{kl}\\bm{x}_{2,l}\\rangle - \\langle \\bm{x}_{1,i}^*\\bm{Q}^{12,\\alpha}_{ij}\\bm{x}_{2,j}\\rangle\\langle \\bm{x}_{1,k}^*\\bm{Q}^{12,\\beta}_{kl}\\bm{x}_{2,l}\\rangle\\notag\\\\\n=&\\sum_{ijkl}\\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta}_{kl}(\\langle \\bm{x}_{1,i}^*\\bm{x}_{2,j}\\bm{x}_{1,k}^*\\bm{x}_{2,l}\\rangle - \\langle \\bm{x}_{1,i}^*\\bm{x}_{2,j}\\rangle\\langle \\bm{x}_{1,k}^*\\bm{x}_{2,l}\\rangle)\\notag\\\\\n=&\\sum_{ijkl}\\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta}_{kl}(\\langle \\bm{x}_{1,i}^*\\bm{x}_{1,k}^*\\rangle\\langle \\bm{x}_{2,j}\\bm{x}_{2,l}\\rangle + \\langle \\bm{x}_{1,i}^*\\bm{x}_{2,l}\\rangle \\langle \\bm{x}_{1,k}^*\\bm{x}_{2,j}\\rangle)\\notag\\\\\n=&\\sum_{ijkl}\\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta}_{kl} (\\bm{S}_{ik}^{11}\\bm{U}_{jl}^{22} + \\bm{C}^{21}_{li}\\bm{C}^{21}_{jk})\\notag\\\\\n=&\\sum_{ijkl}( \\bm{Q}^{12,\\alpha}_{ij}\\bm{U}_{jl}^{22}\\bm{Q}^{21,\\beta*}_{lk} \\bm{S}_{ki}^{11} + \\bm{Q}^{12,\\alpha}_{ij}\\bm{C}^{21}_{jk} \\bm{Q}^{12,\\beta}_{kl} \\bm{C}^{21}_{li} ) \\notag\\\\\n=&\\text{tr}(\\bm{Q}^{12,\\alpha} \\bm{U}^{22} \\bm{Q}^{21,\\beta*} \\bm{S}^{11}) + \\text{tr}(\\bm{Q}^{12,\\alpha} \\bm{C}^{21} \\bm{Q}^{12,\\beta} \\bm{C}^{21}) \\,,\n\\end{align}\n\n\\begin{align}\n\\langle \\hat{q}_\\alpha \\hat{q}_\\beta^*\\rangle - \\langle \\hat{q}_\\alpha\\rangle \\langle \\hat{q}_\\beta^*\\rangle =&\n\\sum_{ijkl}\\langle \\bm{x}_{1,i}^*\\bm{Q}^{12,\\alpha}_{ij}\\bm{x}_{2,j}\\bm{x}_{1,k}\\bm{Q}^{12,\\beta*}_{kl}\\bm{x}_{2,l}^*\\rangle - \\langle \\bm{x}_{1,i}^*\\bm{Q}^{12,\\alpha}_{ij}\\bm{x}_{2,j}\\rangle\\langle \\bm{x}_{1,k}\\bm{Q}^{12,\\beta*}_{kl}\\bm{x}_{2,l}^*\\rangle\\notag\\\\\n=&\\sum_{ijkl} \\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta*}_{kl}(\\langle \\bm{x}_{1,i}^*\\bm{x}_{2,j}\\bm{x}_{1,k}\\bm{x}_{2,l}^*\\rangle - \\langle \\bm{x}_{1,i}^*\\bm{x}_{2,j}\\rangle\\langle \\bm{x}_{1,k}\\bm{x}_{2,l}^*\\rangle)\\notag\\\\\n=&\\sum_{ijkl}  \\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta*}_{kl}(\\langle \\bm{x}_{1,i}^*\\bm{x}_{2,l}^*\\rangle \\langle \\bm{x}_{1,k}\\bm{x}_{2,j}\\rangle + \\langle \\bm{x}_{1,i}^*\\bm{x}_{1,k}\\rangle\\langle \\bm{x}_{2,j}\\bm{x}_{2,l}^*\\rangle)\\notag\\\\\n=&\\sum_{ijkl} \\bm{Q}^{12,\\alpha}_{ij}\\bm{Q}^{12,\\beta*}_{kl} ( \\bm{S}_{il}^{12}\\bm{U}_{kj}^{12} + \\bm{C}^{11}_{ki}\\bm{C}^{22}_{jl})\\notag\\\\\n=&\\sum_{ijkl}( \\bm{Q}^{12,\\alpha}_{ij}\\bm{U}_{jk}^{21}\\bm{Q}^{12,\\beta*}_{kl} \\bm{S}_{li}^{21} + \\bm{Q}^{12,\\alpha}_{ij}\\bm{C}^{22}_{jl} \\bm{Q}^{21,\\beta}_{lk} \\bm{C}^{11}_{ki} ) \\notag\\\\\n=&\\text{tr}(\\bm{Q}^{12,\\alpha} \\bm{U}^{21} \\bm{Q}^{12,\\beta *} \\bm{S}^{21}) + \\text{tr}(\\bm{Q}^{12,\\alpha} \\bm{C}^{22} \\bm{Q}^{21,\\beta} \\bm{C}^{11}) \\,,\n\\end{align}\n\n\\begin{align}\n\\langle \\hat{q}_\\alpha^* \\hat{q}_\\beta^*\\rangle - \\langle \\hat{q}_\\alpha^* \\rangle\\langle \\hat{q}_\\beta^*\\rangle=&\n\\sum_{ijkl}\\langle \\bm{x}_{1,i}\\bm{Q}^{12,\\alpha*}_{ij}\\bm{x}_{2,j}^*\\bm{x}_{1,k}\\bm{Q}^{12,\\beta*}_{kl}\\bm{x}_{2,l}^*\\rangle - \\langle \\bm{x}_{1,i}\\bm{Q}^{12,\\alpha*}_{ij}\\bm{x}_{2,j}^*\\rangle\\langle \\bm{x}_{1,k}\\bm{Q}^{12,\\beta*}_{kl}\\bm{x}_{2,l}^*\\rangle \\notag\\\\\n=&\\sum_{ijkl} \\bm{Q}^{12,\\alpha*}_{ij}\\bm{Q}^{12,\\beta*}_{kl}(\\langle \\bm{x}_{1,i}\\bm{x}_{2,j}^* \\bm{x}_{1,k}\\bm{x}_{2,l}^*\\rangle - \\langle \\bm{x}_{1,i}\\bm{x}_{2,j}^*\\rangle\\langle \\bm{x}_{1,k}\\bm{x}_{2,l}^*\\rangle)\\notag\\\\\n=&\\sum_{ijkl}  \\bm{Q}^{12,\\alpha*}_{ij}\\bm{Q}^{12,\\beta*}_{kl}(\\langle \\bm{x}_{1,i}\\bm{x}_{1,k}\\rangle \\langle \\bm{x}_{2,j}^*\\bm{x}_{2,l}^*\\rangle + \\langle \\bm{x}_{1,i}\\bm{x}_{2,l}^*\\rangle\\langle \\bm{x}_{2,j}^*\\bm{x}_{1,k}\\rangle)\\notag\\\\\n=&\\sum_{ijkl} \\bm{Q}^{12,\\alpha*}_{ij}\\bm{Q}^{12,\\beta*}_{kl} ( \\bm{S}_{jl}^{22}\\bm{U}_{ik}^{11} + \\bm{C}^{12}_{il}\\bm{C}^{12}_{kj})\\notag\\\\\n=&\\sum_{ijkl}( \\bm{Q}^{21,\\alpha}_{ji}\\bm{U}_{ik}^{11}\\bm{Q}^{12,\\beta*}_{kl} \\bm{S}_{lj}^{22} + \\bm{Q}^{21,\\alpha}_{ji}\\bm{C}^{12}_{il} \\bm{Q}^{21,\\beta}_{lk} \\bm{C}^{12}_{kj} ) \\notag\\\\\n=&\\text{tr}(\\bm{Q}^{21,\\alpha} \\bm{U}^{11} \\bm{Q}^{12,\\beta*} \\bm{S}^{22}) + \\text{tr}( \\bm{Q}^{21,\\alpha} \\bm{C}^{12} \\bm{Q}^{21,\\beta} \\bm{C}^{12})\\,,\n\\end{align}\nwhere $\\bm{Q}^{12,\\alpha*}_{ij}= \\bm{Q}^{21,\\alpha}_{ji}$.\n\nTherefore the covariance between the real part of $\\hat{q}_\\alpha$ and the real part of $\\hat{q}_\\beta$ is \n\\begin{equation}\n    \\frac{1}{4}\\left\\{ (\\langle \\hat{q}_\\alpha \\hat{q}_\\beta \\rangle - \\langle \\hat{q}_\\alpha \\rangle\\langle \\hat{q}_\\beta \\rangle) + (\\langle \\hat{q}_\\alpha  \\hat{q}_\\beta^* \\rangle - \\langle \\hat{q}_\\alpha \\rangle\\langle \\hat{q}_\\beta ^*\\rangle) + (\\langle \\hat{q}_\\alpha^*  \\hat{q}_\\beta \\rangle - \\langle \\hat{q}_\\alpha^* \\rangle\\langle \\hat{q}_\\beta \\rangle)\n        + (\\langle \\hat{q}_\\alpha ^*  \\hat{q}_\\beta ^*\\rangle - \\langle \\hat{q}_\\alpha^*\\rangle\\langle \\hat{q}_\\beta^*\\rangle) \\right\\}\\,,\n\\end{equation}\nand the covariance between the imaginary part of $\\hat{q}_\\alpha$ and the imaginary part of $\\hat{q}_\\beta$ is \n\\begin{equation}\n    \\frac{1}{4}\\left\\{ (\\langle \\hat{q}_\\alpha \\hat{q}_\\beta \\rangle - \\langle \\hat{q}_\\alpha \\rangle\\langle \\hat{q}_\\beta \\rangle) - (\\langle \\hat{q}_\\alpha  \\hat{q}_\\beta^* \\rangle - \\langle \\hat{q}_\\alpha \\rangle\\langle \\hat{q}_\\beta ^*\\rangle) - (\\langle \\hat{q}_\\alpha^*  \\hat{q}_\\beta \\rangle - \\langle \\hat{q}_\\alpha^* \\rangle\\langle \\hat{q}_\\beta \\rangle)\n        + (\\langle \\hat{q}_\\alpha ^*  \\hat{q}_\\beta ^*\\rangle - \\langle \\hat{q}_\\alpha^*\\rangle\\langle \\hat{q}_\\beta^*\\rangle) \\right\\}\\,.\n\\end{equation}\n\n$\\hat{q}_\\alpha$ should be normalized via multiplying a proper matrix $\\bm{M}$ as \n\\begin{equation}\n\\label{eq:palpha}\n    \\hat{P}_\\alpha = \\sum_{\\beta} \\bm{M}_{\\alpha\\beta} \\hat{q}_\\beta \\,.\n\\end{equation}\nWe then update the results above for $\\hat{P}_\\alpha$. The covariance between the real part of $\\hat{P}_\\alpha$ and the real part of $\\hat{P}_\\beta$ is \n\\begin{align}\n    &\\frac{1}{4} \\sum_{\\gamma\\delta} \\Big\\{ \\bm{M}_{\\alpha\\gamma} \\bm{M}_{\\beta\\delta} (\\langle \\hat{q}_\\gamma q_\\delta \\rangle - \\langle \\hat{q}_\\gamma \\rangle\\langle q_\\delta\\rangle) + \\bm{M}_{\\alpha\\gamma} \\bm{M}_{\\beta\\delta}^* (\\langle \\hat{q}_\\gamma q_\\delta^*\\rangle - \\langle \\hat{q}_\\gamma \\rangle\\langle q_\\delta^*\\rangle) + \\notag\\\\&\n        \\bm{M}_{\\alpha\\gamma}^* \\bm{M}_{\\beta\\delta} (\\langle \\hat{q}_\\gamma^* q_\\delta \\rangle - \\langle \\hat{q}_\\gamma^* \\rangle\\langle q_\\delta \\rangle) + \n        \\bm{M}_{\\alpha\\gamma}^* \\bm{M}_{\\beta\\delta}^* (\\langle \\hat{q}_\\gamma^* q_\\delta^*\\rangle - \\langle \\hat{q}_\\gamma^*\\rangle\\langle q_\\delta^*\\rangle) \\Big\\}\\,,\n\\end{align}\nand the covariance in the imaginary part of $\\hat{P}_\\alpha$ and the imaginary part of $\\hat{P}_\\beta$ is\n\\begin{align}\n    &\\frac{1}{4} \\sum_{\\gamma\\delta} \\Big\\{ \\bm{M}_{\\alpha\\gamma} \\bm{M}_{\\beta\\delta} (\\langle \\hat{q}_\\gamma q_\\delta \\rangle - \\langle \\hat{q}_\\gamma \\rangle\\langle q_\\delta\\rangle) - \\bm{M}_{\\alpha\\gamma} \\bm{M}_{\\beta\\delta}^* (\\langle \\hat{q}_\\gamma q_\\delta^*\\rangle - \\langle \\hat{q}_\\gamma \\rangle\\langle q_\\delta^*\\rangle) - \\notag\\\\&\n        \\bm{M}_{\\alpha\\gamma}^* \\bm{M}_{\\beta\\delta} (\\langle \\hat{q}_\\gamma^* q_\\delta \\rangle - \\langle \\hat{q}_\\gamma^* \\rangle\\langle q_\\delta \\rangle) + \n        \\bm{M}_{\\alpha\\gamma}^* \\bm{M}_{\\beta\\delta}^* (\\langle \\hat{q}_\\gamma^* q_\\delta^*\\rangle - \\langle \\hat{q}_\\gamma^*\\rangle\\langle q_\\delta^*\\rangle) \\Big\\}\\,.\n\\end{align}\n\nRemarkably, the variance of the real part of $\\hat{P}_\\alpha$ is \n\\begin{align}\n\\label{eq:var_in_ps_real}\n    &\\frac{1}{4} \\sum_{\\beta\\gamma} \n    \\Big\\{\\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma} \\big[ \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{U}^{22} \\bm{Q}^{21,\\gamma*} \\bm{S}^{11}) + \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}^{21}\\notag \\\\\n    & \\phantom{=} \\bm{Q}^{12,\\gamma} \\bm{C}^{21}) \\big] \n    \\, + 2\\times \\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma}^* \\big[ \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{U}^{21} \\bm{Q}^{12,\\gamma *} \\bm{S}^{21}) \\, + \\notag\\\\\n    & \\phantom{=} \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}^{11}) \\big]  \n    +\\bm{M}_{\\alpha\\beta}^* \\bm{M}_{\\alpha\\gamma}^* \\big[ \\text{tr}(\\bm{Q}^{21,\\beta} \\bm{U}^{11} \\bm{Q}^{12,\\gamma*} \\notag\\\\\n    & \\phantom{=} \\bm{S}^{22})+ \\text{tr}( \\bm{Q}^{21,\\beta} \\bm{C}^{12} \\bm{Q}^{21,\\gamma} \\bm{C}^{12}) \\big] \\Big\\}\\,,\n\\end{align}\nwhile the variance of the imaginary part of $\\hat{P}_\\alpha$ is\n\\begin{align}\n\\label{eq:var_in_ps_imag}\n   &\\frac{-1}{4} \\sum_{\\beta\\gamma} \\Big\\{ \\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma} \\big[ \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{U}^{22} \\bm{Q}^{21,\\gamma*} \\bm{S}^{11}) + \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}^{21}\\notag \\\\\n   & \\phantom{=} \\bm{Q}^{12,\\gamma} \\bm{C}^{21}) \\big] \n   \\, - 2 \\times \\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma}^* \\big[ \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{U}^{21} \\bm{Q}^{12,\\gamma *} \\bm{S}^{21}) \\, + \\notag\\\\\n   & \\phantom{=} \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}^{11}) \\big]\n    +\\bm{M}_{\\alpha\\beta}^* \\bm{M}_{\\alpha\\gamma}^* \\big[ \\text{tr}(\\bm{Q}^{21,\\beta} \\bm{U}^{11} \\bm{Q}^{12,\\gamma*} \\notag \\\\\n    & \\phantom{=} \\bm{S}^{22}) + \\text{tr}( \\bm{Q}^{21,\\beta} \\bm{C}^{12} \\bm{Q}^{21,\\gamma} \\bm{C}^{12}) \\big] \\Big\\} \\,.\n\\end{align}\n\nTherefore to get the final error bar on power spectrum, we should accurately model input covariance matrices on visibilities and propagate them into output covariance matrix on bandpowers. Especially, in the noise-dominated region, we have good models for the noise from the amplitudes of auto-correlation visibilities. We adopt a white noise model here, where the real and imaginary parts of noise signal are i.i.d., and uncorrelated between different frequency channels, so that we have non-zero diagonal $\\bm{C}_\\text{n}^{11}$ and $\\bm{C}_\\text{n}^{22}$, while $\\bm{C}_\\text{n}^{12}$, $\\bm{U}_\\text{n}^{11}$, $\\bm{U}_\\text{n}^{22}$, $\\bm{U}_\\text{n}^{12}$, $\\bm{S}_\\text{n}^{11}$, $\\bm{S}_\\text{n}^{22}$ and $\\bm{S}_\\text{n}^{12}$ are all zeros! For a baseline $\\bm{b}$ composed by two antennas $a$ and $b$, we express $\\bm{b} \\equiv \\{a,b\\}$, and use the visibilities from auto-baseline $\\{a,a\\}$ and $\\{b,b\\}$ to estimate $\\bm{C}_\\text{n}$ on baseline $\\bm{b}$ as \\citep{2015ApJ...801...51J}\n\\begin{align}\n\\label{eq:auto_vis_noise}\n   \\bm{C}_{\\text{n},ii}(t) \\equiv & \\phantom{-} \\langle V_\\text{n}(\\{a,b\\},\\nu_i,t) V_\\text{n}^*(\\{a,b\\},\\nu_i,t) \\rangle \\notag \\\\\n   & - \\langle V_\\text{n}(\\{a,b\\},\\nu_i,t) \\rangle \\langle V_\\text{n}^*(\\{a,b\\},\\nu_i,t) \\rangle \\notag \\\\\n   \\approx &  \\phantom{-} \\left|\\frac{V(\\{a,a\\}, \\nu_i,t)V(\\{b,b\\}, \\nu_i,t)}{N_\\text{nights} B \\Delta t}\\right| \\,,\n\\end{align}\nwhere $B\\Delta t$ is the product of the channel bandwidth and the integration time. Non-zero parts in Equation \\ref{eq:var_in_ps_real} or \\ref{eq:var_in_ps_imag} give us the noise variance on either real or imaginary parts of power spectra as \n\\begin{equation}\n\\label{eq:analytic_noise_variance}\n\\frac{1}{2} \\sum_{\\beta\\gamma} \n    \\Big\\{\\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma}^* \\big[\\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}_\\text{n}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}_\\text{n}^{11}) \\Big\\}\\,.    \n\\end{equation}\nIn the following we will show it is an equivalent form of $P_\\text{N}^2$ where $P_\\text{N}$ is what we call `Analytic Noise Power Spectrum' estimated in another parallel way given a system temperature input.      \n\nIf we also consider a `Foreground/systematics dependent variance', Equation \\ref{eq:var_in_ps_real} reduces to \n\\begin{align}\n\\label{eq:reduced_var_in_ps_real}\n    & \\frac{1}{2} \\sum_{\\beta\\gamma} \n    \\Big\\{\\bm{M}_{\\alpha\\beta} \\bm{M}_{\\alpha\\gamma}^* \\big[\\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}_\\text{n}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}_\\text{n}^{11}) \n    \\notag \\\\\n    \\phantom{=} & + \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}_\\text{signal}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}_\\text{n}^{11}) \n    \\notag \\\\ \n    \\phantom{=} & + \\text{tr}(\\bm{Q}^{12,\\beta} \\bm{C}_\\text{n}^{22} \\bm{Q}^{21,\\gamma} \\bm{C}_\\text{signal}^{11}) \\big]  \\Big\\}\\,,\n\\end{align}\nwhere\n\\begin{align}\n    \\bm{C}_{\\text{signal}, ij}^{11} = \\bm{C}_{\\text{signal}, ij}^{22} = \\frac{1}{2}\\left[\\bm{x}_{1,i} \\bm{x}_{2,j}^* + \\bm{x}_{2,i} \\bm{x}_{1,j}^*\\right]\\,.\n\\end{align}\nEquation \\ref{eq:reduced_var_in_ps_real} is an equivalent form to $\\sqrt{2}\\text{Re} (P_{\\tilde{x}_1\\tilde{x}_2}) P_\\text{N} + P_\\text{N}^2$. We also apply a similar zero clipping on $\\bm{C}_{\\text{signal}, ij}^{11}$, where rows and columns containing negative diagonal elements are set to be zero.  \n\n\\subsection{Direct Noise Estimation By Differencing Visibility}\n\\label{subsubsec:diff}\nFor $P_\\text{N}$, there are several other ways to calculate it. The signal signal (foregrounds and EoR signal) vary relatively slowly in time (or frequency), so that in a short time range we can assume the signal keeps almost constant. Thus by differencing the visibility between very close LST bins (or frequency channels), the residual is almost noise, like\n\\begin{eqnarray}\n    V(\\bm{b},\\nu,t_1) -  V(\\bm{b},\\nu,t_2) & \\approx & V_\\text{n}(\\bm{b},\\nu,t_1) -  V_\\text{n}(\\bm{b},\\nu,t_2) \\,, \\notag \\\\\n    V(\\bm{b},\\nu_1,t) -  V(\\bm{b},\\nu_2,t) & \\approx & V_\\text{n}(\\bm{b},\\nu_1, t) -  V_\\text{n}(\\bm{b},\\nu_2, t) \\,.\\notag \\\\\n\\end{eqnarray}\nWith the visibility residual $[V_\\text{n}(\\bm{b},\\nu,t_1) -  V_\\text{n}(\\bm{b},\\nu,t_2)]/\\sqrt{2}$ (or $[V_\\text{n}(\\bm{b},\\nu_1, t) -  V_\\text{n}(\\bm{b},\\nu_2, t)]/\\sqrt{2}$), we can propagate it through the pipeline of power spectrum estimation and generate a \"noise-like\" power spectrum $\\bm{P}_\\text{diff}$. These noise-like power spectra from differenced visibility, though highly scattered, can be seen as realizations of noise errors. For example, we take the time-differenced data to construct a noise-like power spectrum\n\\begin{align}\n\\label{eq:pnn}\n    \\bm{P}_\\text{diff} & =\\frac{(\\tilde{n}_{1,t2} - \\tilde{n}_{1,t_1})^*}{\\sqrt{2}}\\frac{(\\tilde{n}_{2,t2} - \\tilde{n}_{2,t_1})}{\\sqrt{2}} \\notag \\\\\n    & = \\{\\frac{(c_{1,t2}-c_{1,t1})}{\\sqrt{2}}\\frac{(c_{2,t2}-c_{2,t1})}{\\sqrt{2}} + \\frac{(d_{1,t2}-d_{1,t1})}{\\sqrt{2}}\\frac{(d_{2,t2}-d_{2,t1})}{\\sqrt{2}}\\} \\notag \\\\\n    & \\phantom{==} + \\{\\frac{(c_{1,t2}-c_{1,t1})}{\\sqrt{2}}\\frac{(d_{2,t2}-d_{2,t1})}{\\sqrt{2}}-\\frac{(c_{2,t2}-c_{2,t1})}{\\sqrt{2}}\\frac{(d_{1,t2}-d_{1,t1})}{\\sqrt{2}}\\}i \\,,\n\\end{align} \nwhere we see $\\langle\\{\\text{Re}(\\bm{P}_\\text{diff})\\}^2 \\rangle \\equiv \\langle \\{\\frac{(c_{1,t2}-c_{1,t1})}{\\sqrt{2}}\\frac{(c_{2,t2}-c_{2,t1})}{\\sqrt{2}} + \\frac{(d_{1,t2}-d_{1,t1})}{\\sqrt{2}}\\frac{(d_{2,t2}-d_{2,t1})}{\\sqrt{2}}\\}^2 \\rangle = \\langle c_1^2\\rangle\\langle c_2^2\\rangle + \\langle d_1^2\\rangle\\langle d_2^2\\rangle = P_\\text{N}^2$. Therefore we could use $|\\text{Re}(\\bm{P}_\\text{diff})|$ as a realization of error bars of $\\bm{P}_{\\tilde{x}_1\\tilde{x}_2}$ in the noise-dominated region. \n\nIntuitively, $\\bm{P}_\\text{diff}$ can be computed from time-differenced or frequency differenced visibility. However, by differencing the neighbouring points in frequency, we actually apply a high-pass filter in the delay space which means we suppress the power at low delay modes. To illustrate it, we replace the original data vector $\\bm{x}_i$ with the difference data vector $\\bm{x}'_i \\equiv V'(\\bm{b},\\nu_i) = \\left[V(\\bm{b},\\nu_{i+1})-V(\\bm{b},\\nu_i)\\right] / \\sqrt{2} \\equiv \\left(\\bm{x}_{i+1} - \\bm{x}_i\\right)/\\sqrt{2}\\, (i=1,\\cdots,N-1)$ and $\\bm{x}'_N = \\bm{x}_N$, and the new estimation of the same bandpower is %%\\acl{We will probably want to use a different notation than tilde to avoid confusion with the delay transform}\n\\begin{eqnarray}\n    \\hat{q}'_\\alpha & \\equiv & \\sum_{ij}\\frac{1}{2}e^{i2\\pi\\eta_\\alpha(\\nu_i - \\nu_j)}\\bm{R}_{1,i}\\bm{R}_{2,j} \\bm{x}'^*_{1,i} \\bm{x}'_{2,j} \\notag \\\\\n    & = &\\sum_{i=1,\\cdots, N-1;j}\\frac{1}{2}e^{i2\\pi\\eta_\\alpha(\\nu_i - \\nu_j)} \\bm{R}_{1,i}\\bm{R}_{2,j} \\frac{(\\bm{x}_{1,i+1}-\\bm{x}_{1,i})^*}{\\sqrt{2}} \\bm{x}'_{2,j} \\notag \\\\\n    & \\phantom{=} & + \\sum_{j} \\frac{1}{2} e^{i2\\pi\\eta_\\alpha(\\nu_N - \\nu_j)} \\bm{R}_{1,N}\\bm{R}_{2,j} \\bm{x}_{1,N}^* \\bm{x}'_{2,j} \\notag \\\\ \n    & = & \\sum_{i=1,\\cdots, N-1;j}\\frac{1}{2} e^{i2\\pi\\eta_\\alpha(\\nu_i - \\nu_j)} \\bm{R}_{1,i}\\bm{R}_{2,j} \\frac{\\bm{x}^*_{1,i+1}}{\\sqrt{2}} \\bm{x}'_{2,j}\\notag \\\\ \n    & \\phantom{=} & - \\sum_{i=1,\\cdots, N-1;j}\\frac{1}{2} e^{i2\\pi\\eta_\\alpha(\\nu_i - \\nu_j)} \\bm{R}_{1,i}\\bm{R}_{2,j} \\frac{\\bm{x}^*_{1,i}}{\\sqrt{2}} \\bm{x}'_{2,j} \\notag \\\\\n    & \\phantom{=} & + \\sum_{j} \\frac{1}{2} e^{i2\\pi\\eta_\\alpha(\\nu_N - \\nu_j)} \\bm{R}_{1,N}\\bm{R}_{2,j} \\bm{x}_{1,N}^* \\bm{x}'_{2,j} \\notag \\\\\n    & \\approx & (e^{-i2\\pi\\eta_\\alpha \\Delta\\nu} -1 )\\sum_{ij} \\frac{1}{2} e^{i2\\pi\\eta_\\alpha(\\nu_i-\\nu_j)} \\bm{R}_{1,i}\\bm{R}_{2,j} \\frac{\\bm{x}^*_{1,i}}{\\sqrt{2}} \\bm{x}'_{2,j} \\notag \\\\\n    & \\approx & (e^{i2\\pi\\eta_\\alpha \\Delta\\nu} -1 )(e^{-i2\\pi\\eta_\\alpha \\Delta\\nu} -1 ) \\notag \\\\\n    & \\phantom{=} &\\sum_{ij} \\frac{1}{4}e^{i2\\pi\\eta_\\alpha(\\nu_i-\\nu_j)} \\bm{R}_{1,i}\\bm{R}_{2,j} \\bm{x}^*_{1,i} \\bm{x}_{2,j} \\notag \\\\\n    & \\approx & \\frac{(2\\pi\\eta_\\alpha\\Delta \\nu)^2}{2} \\hat{q}_\\alpha \\, (\\text{when} \\,\\, \\eta_\\alpha \\Delta\\nu \\ll 1)\\,,\n\\end{eqnarray}\n%%\\acl{This is a slight different calculation from what's done in data analysis, right? Aren't we replacing \\emph{both} $x$ and $y$ with the differenced data?}\\jrt{Yes. I ignore the weighting matrices.}\nwhere we have assumed that the frequency channels are evenly spaced. If $\\eta_\\alpha$ is small (at low delays), we see $\\hat{q}'_\\alpha$ is highly suppressed from the original $\\hat{q}_\\alpha$, which introduce unphysical spectral structures. Thus time-differencing method is preferred to construct such noise-like power spectra.\n\n\\subsection{Noise Power Spectrum}\nThe `analytic' noise power specturm can be also estimated from a system temperature input $T_\\text{sys}$ by  \\citep{cheng2018characterizing,kern2020mitigating}\n\\begin{equation}\n\\label{eq:analytic_P_N}\n    P_\\text{N} = \\frac{X^2 Y \\Omega_\\text{eff} T_\\text{sys}^2}{t_\\text{int} N_\\text{coherent}\\sqrt{2N_\\text{incoherent}}}\\,,\n\\end{equation}\nwhere $X^2Y$ are conversion factors from signal angles and frequencies to cosmological coordinates, $\\Omega_\\text{eff}$ is the effective beam area, $t_\\text{int}$ is the integration time, $N_\\text{coherent}$ is the number of samples averaged at the level of visibility while $N_\\text{incoherent}$ is the numbers of samples averaged at the level of power spectrum.\n\nGenerally, $T_\\text{sys} = T_\\text{signal} + T_\\text{rcvr}$. It can be estimated via the RMS of the differenced visibilities over samples, where we take the differences of raw visibilities in adjacent time and frequency channels to obtain the differenced visibilities first. By the relation  \n\\begin{equation}\n\\label{eq:RMS_Tsys}\nV_\\text{RMS} = \\frac{2k_b \\nu^2 \\Omega_p}{c^2}\\frac{T_\\text{sys}}{B \\Delta t} \\,,\n\\end{equation}\nwe could have a distinct system temperature on one baseline by taking RMS over all its time samples, or a baseline-time averaged system temperature over all times and baselines. Another way to estimate $T_\\text{sys}$ is also using the auto-correlation visibility, since itself is a good measure on the noise level on one antenna, by\n\\begin{equation}\n\\label{eq:auto_Tsys}\n\\sqrt{V(\\{a,a\\}) V(\\{b,b\\})} = \\frac{2k_b \\nu^2 \\Omega_p}{c^2} T_\\text{sys,\\{a,b\\}}\\,.\n\\end{equation}\nCombining both Equation \\ref{eq:RMS_Tsys} and Equation \\ref{eq:auto_Tsys} we derive a relation\n\\begin{equation}\n\\label{eq:auto2RMS}\nV^2_\\text{RMS,\\{a,b\\}} = \\frac{V(\\{a,a\\}) V(\\{b,b\\})}{B \\Delta t}\\,,\n\\end{equation}\nwhich is equivalent to Equation \\ref{eq:auto_vis_noise} for the input noise covariance matrix. Thus the noise power spectrum estimated in this way essentially reduces to a special case of the analytic method we introduced earlier. While the analytic method is more preferred since in Equation \\ref{eq:analytic_P_N} we actually use a spectral-window-averaged system temperature which might lose some information on frequency spectra during the averaging process.   \n\n\\bibliography{bibtex} \n\\end{document}\n", "meta": {"hexsha": "d9b0b837cf40df03d7a212c67fefad33b5e34c37", "size": 24770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples/internal_memos/error_bar_choices/hera_pspec_error_bar_choice.tex", "max_stars_repo_name": "adeliegorce/hera_pspec", "max_stars_repo_head_hexsha": "4d2fe17e2015b02b16683b29e2fd5530066dfd7b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2018-01-28T06:59:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-23T19:23:09.000Z", "max_issues_repo_path": "examples/internal_memos/error_bar_choices/hera_pspec_error_bar_choice.tex", "max_issues_repo_name": "adeliegorce/hera_pspec", "max_issues_repo_head_hexsha": "4d2fe17e2015b02b16683b29e2fd5530066dfd7b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 314, "max_issues_repo_issues_event_min_datetime": "2017-06-30T04:10:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-18T16:34:37.000Z", "max_forks_repo_path": "examples/internal_memos/error_bar_choices/hera_pspec_error_bar_choice.tex", "max_forks_repo_name": "adeliegorce/hera_pspec", "max_forks_repo_head_hexsha": "4d2fe17e2015b02b16683b29e2fd5530066dfd7b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-10-26T00:21:01.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T20:59:18.000Z", "avg_line_length": 106.7672413793, "max_line_length": 996, "alphanum_fraction": 0.6349212757, "num_tokens": 9928, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.41829521274664994}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n      \\subsection{fitc.m}\n\n\\begin{par}\n\\textbf{Summary:} Compute the FITC negative log marginal likelihood and its derivatives with  respect to the inducing inputs (we don't compute the derivatives with respect to the GP hyper-parameters)\n\\end{par} \\vspace{1em}\n\\begin{verbatim}function [nml dnml] = fitc(induce, gpmodel)\\end{verbatim}\n\\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}induce          matrix of inducing inputs                       [M x D x uE]\n                M: number of inducing inputs\n                E: either 1 (inducing inputs are shared across target dim.)\n                   or     E (different inducing inputs for each target dim.)\ngpmodel         GP structure\n  .hyp          log-hyper-parameters                               [D+2 x E]\n  .inputs       training inputs                                    [N   x D]\n  .targets      training targets                                   [N   x E]\n  .noise (opt)  noise\\end{verbatim}\n\\begin{par}\n\\textbf{Output arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}nlml             negative log-marginal likelihood\ndnlml            derivative of negative log-marginal likelihood wrt\n                 inducing inputs\\end{verbatim}\n\\begin{par}\nAdapted from Ed Snelson's SPGP code.\n\\end{par} \\vspace{1em}\n\\begin{par}\nCopyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.\n\\end{par} \\vspace{1em}\n\\begin{par}\nLast modified: 2013-05-21\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{High-Level Steps} \n\n\\begin{enumerate}\n\\setlength{\\itemsep}{-1ex}\n   \\item Compute FITC marginal likelihood\n   \\item Compute corresponding gradients wrt the pseudo inputs\n\\end{enumerate}\n\n\\begin{lstlisting}\nfunction [nlml dnlml] = fitc(induce, gpmodel)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\nridge = 1e-06;                       % jitter to make matrix better conditioned\n\n[N D] = size(gpmodel.inputs); E = size(gpmodel.targets,2);\n[M uD uE] = size(induce);\nif uD ~= D || (uE~=1 && uE ~= E); error('Wrong size of inducing inputs'); end\n\nnlml = 0; dfxb = zeros(M, D); dnlml = zeros(M, D, E); % zero and allocate outputs\n\nfor j = 1:E\n  if uE > 1; u = induce(:,:,j); else u = induce; end\n  b = exp(gpmodel.hyp(1:D,j));                                 % length-scales\n  c = gpmodel.hyp(D+1,j);                                 % log signal std dev\n  sig = exp(2.*gpmodel.hyp(D+2,j));                           % noise variance\n\n  xb = bsxfun(@rdivide,u,b');                 % divide inducing by lengthscales\n  x = bsxfun(@rdivide,gpmodel.inputs,b');     % divide inputs by length-scales\n  y = gpmodel.targets(:,j);                                  % training targets\n\n  Kmm = exp(2*c-maha(xb,xb)/2) + ridge*eye(M);\n  Kmn = exp(2*c-maha(xb,x)/2);\n\n  % Check whether Kmm is no longer positive definite. If so, return\n  try\n    L = chol(Kmm)';\n  catch\n    nlml = Inf; dnlml = zeros(size(params));\n    return;\n  end\n  V = L\\Kmn;                                               % inv(sqrt(Kmm))*Kmn\n\n  if isfield(gpmodel,'noise')\n    Gamma = 1 + (exp(2*c)-sum(V.^2)'+gpmodel.noise(:,j))/sig;\n  else\n    Gamma = 1 + (exp(2*c)-sum(V.^2)')/sig;      % Gamma = diag(Knn-Qnn)/sig + I\n  end\n\n  V = bsxfun(@rdivide,V,sqrt(Gamma)');  % inv(sqrt(Kmm))*Kmn * inv(sqrt(Gamma))\n  y = y./sqrt(Gamma);\n  Am = chol(sig*eye(M) + V*V')';        % chol(inv(sqrt(Kmm))*A*inv(sqrt(Kmm)))\n                % V*V' = inv(chol(Kmm)')*K*inv(diag(Gamma))*K'*inv(chol(Kmm)')'\n  Vy = V*y;\n  beta = Am\\Vy;\n\n  nlml = nlml + sum(log(diag(Am))) + (N-M)/2*log(sig) + sum(log(Gamma))/2 ...\n         + (y'*y - beta'*beta)/2/sig + 0.5*N*log(2*pi);\n\n  if nargout == 2               % ... and if requested, its partial derivatives\n\n    At = L*Am; iAt = At\\eye(M);              % chol(sig*B) [Ed's thesis, p. 40]\n    iA = iAt'*iAt;                                                 % inv(sig*B)\n\n    iAmV = Am\\V;                                                    % inv(Am)*V\n    B1 = At'\\(iAmV);\n    b1 = At'\\beta;                                                  % b1 = B1*y\n\n    iLV = L'\\V;                                 % inv(Kmm)*Kmn*inv(sqrt(Gamma))\n    iL = L\\eye(M);\n    iKmm = iL'*iL;\n\n    mu = ((Am'\\beta)'*V)';\n    bs = y.*(beta'*iAmV)'/sig - sum(iAmV.*iAmV)'/2 - (y.^2+mu.^2)/2/sig + 0.5;\n    TT = iLV*(bsxfun(@times,iLV',bs));\n    Kmn = bsxfun(@rdivide,Kmn,sqrt(Gamma)');                    % overwrite Kmn\n\n    for i = 1:D                               % derivatives wrt inducing inputs\n      dsq_mm = bsxfun(@minus,xb(:,i),xb(:,i)').*Kmm;\n      dsq_mn = bsxfun(@minus,-xb(:,i),-x(:,i)').*Kmn;\n      dGamma = -2/sig*dsq_mn.*iLV;\n\n      dfxb(:,i) = -b1.*(dsq_mn*(y-mu)/sig + dsq_mm*b1) + dGamma*bs ...\n                  + sum((iKmm - iA*sig).*dsq_mm,2) - 2/sig*sum(dsq_mm.*TT,2);\n      dsq_mn = dsq_mn.*B1;                                   % overwrite dsq_mn\n      dfxb(:,i) = dfxb(:,i) + sum(dsq_mn,2);\n      dfxb(:,i) = dfxb(:,i)/b(i);\n    end\n\n    dnlml(:,:,j) = dfxb;\n  end\nend\nif 1 == uE; dnlml = sum(dnlml,3); end % combine derivatives if sharing inducing\n\\end{lstlisting}\n", "meta": {"hexsha": "ff9bc11d494dbe664af74a866787add16fd6ca02", "size": 5208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/fitc.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/fitc.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/fitc.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 36.676056338, "max_line_length": 199, "alphanum_fraction": 0.5360983103, "num_tokens": 1638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872243177519, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4182356184483588}}
{"text": "% -*- mode: latex; TeX-master: \"Vorbis_I_spec\"; -*-\n%!TEX root = Vorbis_I_spec.tex\n% $Id$\n\\section{Floor type 1 setup and decode} \\label{vorbis:spec:floor1}\n\n\\subsection{Overview}\n\nVorbis floor type one uses a piecewise straight-line representation to\nencode a spectral envelope curve. The representation plots this curve\nmechanically on a linear frequency axis and a logarithmic (dB)\namplitude axis. The integer plotting algorithm used is similar to\nBresenham's algorithm.\n\n\n\n\\subsection{Floor 1 format}\n\n\\subsubsection{model}\n\nFloor type one represents a spectral curve as a series of\nline segments.  Synthesis constructs a floor curve using iterative\nprediction in a process roughly equivalent to the following simplified\ndescription:\n\n\\begin{itemize}\n \\item  the first line segment (base case) is a logical line spanning\nfrom x_0,y_0 to x_1,y_1 where in the base case x_0=0 and x_1=[n], the\nfull range of the spectral floor to be computed.\n\n\\item the induction step chooses a point x_new within an existing\nlogical line segment and produces a y_new value at that point computed\nfrom the existing line's y value at x_new (as plotted by the line) and\na difference value decoded from the bitstream packet.\n\n\\item floor computation produces two new line segments, one running from\nx_0,y_0 to x_new,y_new and from x_new,y_new to x_1,y_1. This step is\nperformed logically even if y_new represents no change to the\namplitude value at x_new so that later refinement is additionally\nbounded at x_new.\n\n\\item the induction step repeats, using a list of x values specified in\nthe codec setup header at floor 1 initialization time.  Computation\nis completed at the end of the x value list.\n\n\\end{itemize}\n\n\nConsider the following example, with values chosen for ease of\nunderstanding rather than representing typical configuration:\n\nFor the below example, we assume a floor setup with an [n] of 128.\nThe list of selected X values in increasing order is\n0,16,32,48,64,80,96,112 and 128.  In list order, the values interleave\nas 0, 128, 64, 32, 96, 16, 48, 80 and 112.  The corresponding\nlist-order Y values as decoded from an example packet are 110, 20, -5,\n-45, 0, -25, -10, 30 and -10.  We compute the floor in the following\nway, beginning with the first line:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-1}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nWe now draw new logical lines to reflect the correction to new_Y, and\niterate for X positions 32 and 96:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-2}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nAlthough the new Y value at X position 96 is unchanged, it is still\nused later as an endpoint for further refinement.  From here on, the\npattern should be clear; we complete the floor computation as follows:\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-3}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\n\\begin{center}\n\\includegraphics[width=8cm]{floor1-4}\n\\captionof{figure}{graph of example floor}\n\\end{center}\n\nA more efficient algorithm with carefully defined integer rounding\nbehavior is used for actual decode, as described later.  The actual\nalgorithm splits Y value computation and line plotting into two steps\nwith modifications to the above algorithm to eliminate noise\naccumulation through integer roundoff/truncation.\n\n\n\n\\subsubsection{header decode}\n\nA list of floor X values is stored in the packet header in interleaved\nformat (used in list order during packet decode and synthesis).  This\nlist is split into partitions, and each partition is assigned to a\npartition class.  X positions 0 and [n] are implicit and do not belong\nto an explicit partition or partition class.\n\nA partition class consists of a representation vector width (the\nnumber of Y values which the partition class encodes at once), a\n'subclass' value representing the number of alternate entropy books\nthe partition class may use in representing Y values, the list of\n[subclass] books and a master book used to encode which alternate\nbooks were chosen for representation in a given packet.  The\nmaster/subclass mechanism is meant to be used as a flexible\nrepresentation cascade while still using codebooks only in a scalar\ncontext.\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n\n  1) [floor1_partitions] = read 5 bits as unsigned integer\n  2) [maximum_class] = -1\n  3) iterate [i] over the range 0 ... [floor1_partitions]-1 \\{\n\n        4) vector [floor1_partition_class_list] element [i] = read 4 bits as unsigned integer\n\n     \\}\n\n  5) [maximum_class] = largest integer scalar value in vector [floor1_partition_class_list]\n  6) iterate [i] over the range 0 ... [maximum_class] \\{\n\n        7) vector [floor1_class_dimensions] element [i] = read 3 bits as unsigned integer and add 1\n\t8) vector [floor1_class_subclasses] element [i] = read 2 bits as unsigned integer\n        9) if ( vector [floor1_class_subclasses] element [i] is nonzero ) \\{\n\n             10) vector [floor1_class_masterbooks] element [i] = read 8 bits as unsigned integer\n\n           \\}\n\n       11) iterate [j] over the range 0 ... (2 exponent [floor1_class_subclasses] element [i]) - 1 \\{\n\n             12) array [floor1_subclass_books] element [i],[j] =\n                 read 8 bits as unsigned integer and subtract one\n           \\}\n      \\}\n\n 13) [floor1_multiplier] = read 2 bits as unsigned integer and add one\n 14) [rangebits] = read 4 bits as unsigned integer\n 15) vector [floor1_X_list] element [0] = 0\n 16) vector [floor1_X_list] element [1] = 2 exponent [rangebits];\n 17) [floor1_values] = 2\n 18) iterate [i] over the range 0 ... [floor1_partitions]-1 \\{\n\n       19) [current_class_number] = vector [floor1_partition_class_list] element [i]\n       20) iterate [j] over the range 0 ... ([floor1_class_dimensions] element [current_class_number])-1 \\{\n             21) vector [floor1_X_list] element ([floor1_values]) =\n                 read [rangebits] bits as unsigned integer\n             22) increment [floor1_values] by one\n           \\}\n     \\}\n\n 23) done\n\\end{Verbatim}\n\nAn end-of-packet condition while reading any aspect of a floor 1\nconfiguration during setup renders a stream undecodable.  In addition,\na \\varname{[floor1_class_masterbooks]} or\n\\varname{[floor1_subclass_books]} scalar element greater than the\nhighest numbered codebook configured in this stream is an error\ncondition that renders the stream undecodable.  All vector\n[floor1_x_list] element values must be unique within the vector; a\nnon-unique value renders the stream undecodable.\n\n\\paragraph{packet decode} \\label{vorbis:spec:floor1-decode}\n\nPacket decode begins by checking the \\varname{[nonzero]} flag:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [nonzero] = read 1 bit as boolean\n\\end{Verbatim}\n\nIf \\varname{[nonzero]} is unset, that indicates this channel contained\nno audio energy in this frame.  Decode immediately returns a status\nindicating this floor curve (and thus this channel) is unused this\nframe.  (A return status of 'unused' is different from decoding a\nfloor that has all points set to minimum representation amplitude,\nwhich happens to be approximately -140dB).\n\n\nAssuming \\varname{[nonzero]} is set, decode proceeds as follows:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [range] = vector \\{ 256, 128, 86, 64 \\} element ([floor1_multiplier]-1)\n  2) vector [floor1_Y] element [0] = read \\link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer\n  3) vector [floor1_Y] element [1] = read \\link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer\n  4) [offset] = 2;\n  5) iterate [i] over the range 0 ... [floor1_partitions]-1 \\{\n\n       6) [class] = vector [floor1_partition_class]  element [i]\n       7) [cdim]  = vector [floor1_class_dimensions] element [class]\n       8) [cbits] = vector [floor1_class_subclasses] element [class]\n       9) [csub]  = (2 exponent [cbits])-1\n      10) [cval]  = 0\n      11) if ( [cbits] is greater than zero ) \\{\n\n             12) [cval] = read from packet using codebook number\n                 (vector [floor1_class_masterbooks] element [class]) in scalar context\n          \\}\n\n      13) iterate [j] over the range 0 ... [cdim]-1 \\{\n\n             14) [book] = array [floor1_subclass_books] element [class],([cval] bitwise AND [csub])\n             15) [cval] = [cval] right shifted [cbits] bits\n\t     16) if ( [book] is not less than zero ) \\{\n\n\t           17) vector [floor1_Y] element ([j]+[offset]) = read from packet using codebook\n                       [book] in scalar context\n\n                 \\} else [book] is less than zero \\{\n\n\t           18) vector [floor1_Y] element ([j]+[offset]) = 0\n\n                 \\}\n          \\}\n\n      19) [offset] = [offset] + [cdim]\n\n     \\}\n\n 20) done\n\\end{Verbatim}\n\nAn end-of-packet condition during curve decode should be considered a\nnominal occurrence; if end-of-packet is reached during any read\noperation above, floor decode is to return 'unused' status as if the\n\\varname{[nonzero]} flag had been unset at the beginning of decode.\n\n\nVector \\varname{[floor1_Y]} contains the values from packet decode\nneeded for floor 1 synthesis.\n\n\n\n\\paragraph{curve computation} \\label{vorbis:spec:floor1-synth}\n\nCurve computation is split into two logical steps; the first step\nderives final Y amplitude values from the encoded, wrapped difference\nvalues taken from the bitstream.  The second step plots the curve\nlines.  Also, although zero-difference values are used in the\niterative prediction to find final Y values, these points are\nconditionally skipped during final line computation in step two.\nSkipping zero-difference values allows a smoother line fit.\n\nAlthough some aspects of the below algorithm look like inconsequential\noptimizations, implementors are warned to follow the details closely.\nDeviation from implementing a strictly equivalent algorithm can result\nin serious decoding errors.\n\n\\begin{description}\n\\item[step 1: amplitude value synthesis]\n\nUnwrap the always-positive-or-zero values read from the packet into\n+/- difference values, then apply to line prediction.\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [range] = vector \\{ 256, 128, 86, 64 \\} element ([floor1_multiplier]-1)\n  2) vector [floor1_step2_flag] element [0] = set\n  3) vector [floor1_step2_flag] element [1] = set\n  4) vector [floor1_final_Y] element [0] = vector [floor1_Y] element [0]\n  5) vector [floor1_final_Y] element [1] = vector [floor1_Y] element [1]\n  6) iterate [i] over the range 2 ... [floor1_values]-1 \\{\n\n       7) [low_neighbor_offset] = \\link{vorbis:spec:low:neighbor}{low_neighbor}([floor1_X_list],[i])\n       8) [high_neighbor_offset] = \\link{vorbis:spec:high:neighbor}{high_neighbor}([floor1_X_list],[i])\n\n       9) [predicted] = \\link{vorbis:spec:render:point}{render_point}( vector [floor1_X_list] element [low_neighbor_offset],\n\t\t\t\t      vector [floor1_final_Y] element [low_neighbor_offset],\n                                      vector [floor1_X_list] element [high_neighbor_offset],\n\t\t\t\t      vector [floor1_final_Y] element [high_neighbor_offset],\n                                      vector [floor1_X_list] element [i] )\n\n      10) [val] = vector [floor1_Y] element [i]\n      11) [highroom] = [range] - [predicted]\n      12) [lowroom]  = [predicted]\n      13) if ( [highroom] is less than [lowroom] ) \\{\n\n            14) [room] = [highroom] * 2\n\n          \\} else [highroom] is not less than [lowroom] \\{\n\n            15) [room] = [lowroom] * 2\n\n          \\}\n\n      16) if ( [val] is nonzero ) \\{\n\n            17) vector [floor1_step2_flag] element [low_neighbor_offset] = set\n            18) vector [floor1_step2_flag] element [high_neighbor_offset] = set\n            19) vector [floor1_step2_flag] element [i] = set\n            20) if ( [val] is greater than or equal to [room] ) \\{\n\n                  21) if ( [highroom] is greater than [lowroom] ) \\{\n\n                        22) vector [floor1_final_Y] element [i] = [val] - [lowroom] + [predicted]\n\n\t\t      \\} else [highroom] is not greater than [lowroom] \\{\n\n                        23) vector [floor1_final_Y] element [i] = [predicted] - [val] + [highroom] - 1\n\n                      \\}\n\n                \\} else [val] is less than [room] \\{\n\n\t\t  24) if ([val] is odd) \\{\n\n                        25) vector [floor1_final_Y] element [i] =\n                            [predicted] - (([val] + 1) divided by  2 using integer division)\n\n                      \\} else [val] is even \\{\n\n                        26) vector [floor1_final_Y] element [i] =\n                            [predicted] + ([val] / 2 using integer division)\n\n                      \\}\n\n                \\}\n\n          \\} else [val] is zero \\{\n\n            27) vector [floor1_step2_flag] element [i] = unset\n            28) vector [floor1_final_Y] element [i] = [predicted]\n\n          \\}\n\n     \\}\n\n 29) done\n\n\\end{Verbatim}\n\n\n\n\\item[step 2: curve synthesis]\n\nCurve synthesis generates a return vector \\varname{[floor]} of length\n\\varname{[n]} (where \\varname{[n]} is provided by the decode process\ncalling to floor decode).  Floor 1 curve synthesis makes use of the\n\\varname{[floor1_X_list]}, \\varname{[floor1_final_Y]} and\n\\varname{[floor1_step2_flag]} vectors, as well as [floor1_multiplier]\nand [floor1_values] values.\n\nDecode begins by sorting the scalars from vectors\n\\varname{[floor1_X_list]}, \\varname{[floor1_final_Y]} and\n\\varname{[floor1_step2_flag]} together into new vectors\n\\varname{[floor1_X_list]'}, \\varname{[floor1_final_Y]'} and\n\\varname{[floor1_step2_flag]'} according to ascending sort order of the\nvalues in \\varname{[floor1_X_list]}.  That is, sort the values of\n\\varname{[floor1_X_list]} and then apply the same permutation to\nelements of the other two vectors so that the X, Y and step2_flag\nvalues still match.\n\nThen compute the final curve in one pass:\n\n\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n  1) [hx] = 0\n  2) [lx] = 0\n  3) [ly] = vector [floor1_final_Y]' element [0] * [floor1_multiplier]\n  4) iterate [i] over the range 1 ... [floor1_values]-1 \\{\n\n       5) if ( [floor1_step2_flag]' element [i] is set ) \\{\n\n             6) [hy] = [floor1_final_Y]' element [i] * [floor1_multiplier]\n \t     7) [hx] = [floor1_X_list]' element [i]\n             8) \\link{vorbis:spec:render:line}{render_line}( [lx], [ly], [hx], [hy], [floor] )\n             9) [lx] = [hx]\n\t    10) [ly] = [hy]\n          \\}\n     \\}\n\n 11) if ( [hx] is less than [n] ) \\{\n\n        12) \\link{vorbis:spec:render:line}{render_line}( [hx], [hy], [n], [hy], [floor] )\n\n     \\}\n\n 13) if ( [hx] is greater than [n] ) \\{\n\n            14) truncate vector [floor] to [n] elements\n\n     \\}\n\n 15) for each scalar in vector [floor], perform a lookup substitution using\n     the scalar value from [floor] as an offset into the vector \\link{vorbis:spec:floor1:inverse:dB:table}{[floor1_inverse_dB_static_table]}\n\n 16) done\n\n\\end{Verbatim}\n\n\\end{description}\n", "meta": {"hexsha": "216eb1d6e00b15106a77cdd0de4a71031460e6ce", "size": 14806, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/07-floor1.tex", "max_stars_repo_name": "yinquan529/platform-external-libvorbis", "max_stars_repo_head_hexsha": "de559619fd4dd0d2d9608436696fd44bdf74eba8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 278, "max_stars_repo_stars_event_min_datetime": "2015-11-03T03:01:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-20T18:21:05.000Z", "max_issues_repo_path": "doc/07-floor1.tex", "max_issues_repo_name": "yinquan529/platform-external-libvorbis", "max_issues_repo_head_hexsha": "de559619fd4dd0d2d9608436696fd44bdf74eba8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 374, "max_issues_repo_issues_event_min_datetime": "2015-11-03T12:37:22.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-17T14:18:08.000Z", "max_forks_repo_path": "doc/07-floor1.tex", "max_forks_repo_name": "yinquan529/platform-external-libvorbis", "max_forks_repo_head_hexsha": "de559619fd4dd0d2d9608436696fd44bdf74eba8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 96, "max_forks_repo_forks_event_min_datetime": "2015-11-22T07:47:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T19:52:19.000Z", "avg_line_length": 37.6743002545, "max_line_length": 140, "alphanum_fraction": 0.6866810752, "num_tokens": 4097, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872187162397, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4182356153208834}}
{"text": "\\section{Result}\n\n\\subsection{Measurements for spring constant}\n\nFirst we get the raw length measurement data in Table~\\ref{s1}.\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|p{0.7cm}|p{3cm}||p{0.7cm}|p{3cm}||p{0.7cm}|p{3cm}|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{spring 1 [cm] $\\pm$ 0.01 [cm]} &\n\t\\multicolumn{2}{|c|}{spring 2 [cm] $\\pm$ 0.01 [cm]} &\n\t\\multicolumn{2}{|c|}{serial   [cm] $\\pm$ 0.01 [cm]} \\\\ \\hline\n\t$L_0$ & 0.00  & $L_0$ & 0.00  & $L_0$ & 20.00 \\\\ \\hline\n\t$L_1$ & 2.00  & $L_1$ & 2.01  & $L_1$ & 23.96 \\\\ \\hline\n\t$L_2$ & 3.96  & $L_2$ & 4.00  & $L_2$ & 27.94 \\\\ \\hline\n\t$L_3$ & 5.96  & $L_3$ & 6.03  & $L_3$ & 31.90 \\\\ \\hline\n\t$L_4$ & 8.02  & $L_4$ & 8.06  & $L_4$ & 36.40 \\\\ \\hline\n\t$L_5$ & 10.04 & $L_5$ & 10.08 & $L_5$ & 39.94 \\\\ \\hline\n\t$L_6$ & 12.02 & $L_6$ & 12.10 & $L_6$ & 44.02 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Spring constant measurement data}\n\\label{s1}\n\\end{table}\n\nThen we can calculate the change amount of the spring length by $\\Delta L_i=L_i-L_0$ and get Table \\ref{s2}.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|p{0.7cm}|p{3cm}||p{0.7cm}|p{3cm}||p{0.7cm}|p{3cm}|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{spring 1 [cm] $\\pm$ 0.01 [cm]} &\n\t\\multicolumn{2}{|c|}{spring 2 [cm] $\\pm$ 0.01 [cm]} &\n\t\\multicolumn{2}{|c|}{serial   [cm] $\\pm$ 0.01 [cm]} \\\\ \\hline\n\t$\\Delta L_1$ & 2.00  & $\\Delta L_1$ & 2.01  & $\\Delta L_1$ & 3.96  \\\\ \\hline\n\t$\\Delta L_2$ & 3.96  & $\\Delta L_2$ & 4.00  & $\\Delta L_2$ & 7.94  \\\\ \\hline\n\t$\\Delta L_3$ & 5.96  & $\\Delta L_3$ & 6.03  & $\\Delta L_3$ & 11.90 \\\\ \\hline\n\t$\\Delta L_4$ & 8.02  & $\\Delta L_4$ & 8.06  & $\\Delta L_4$ & 16.40 \\\\ \\hline\n\t$\\Delta L_5$ & 10.04 & $\\Delta L_5$ & 10.08 & $\\Delta L_5$ & 19.94 \\\\ \\hline\n\t$\\Delta L_6$ & 12.02 & $\\Delta L_6$ & 12.10 & $\\Delta L_6$ & 24.02 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Calculated Spring constant measurement data}\n\\label{s2}\n\\end{table}\n\nWe get the mass of the weight object for every $\\Delta L_i$ in Table\n\\ref{massofweight}.\n\nSince the acceleration due to gravity in Shanghai is $9.794 m/s^2$, we calculated\nthe weights of each weight object from its mass, as shown in Table\n\\ref{gravityofweight}. \n\n\\begin{minipage}{0.5\\linewidth}\n\t\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{m [g] $\\pm$ 0.01 [g]} \\\\ \\hline\n\t1 & 4.65  \\\\ \\hline\n\t2 & 9.32  \\\\ \\hline\n\t3 & 14.17 \\\\ \\hline\n\t4 & 18.99 \\\\ \\hline\n\t5 & 23.80 \\\\ \\hline\n\t6 & 28.51 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Mass measurement data.}\n\\label{massofweight}\n\t\\end{table}\n\\end{minipage}\n%\n\\begin{minipage}{0.5\\linewidth}\n\t\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{F [N] $\\pm$ 0.0001 [N]} \\\\ \\hline\n\t1  & 0.0455  \\\\ \\hline \n\t2  & 0.0913  \\\\ \\hline \n\t3  & 0.1388  \\\\ \\hline \n\t4  & 0.1860  \\\\ \\hline \n\t5  & 0.2331  \\\\ \\hline \n\t6  & 0.2792  \\\\ \\hline \n\t\\end{tabular}\n\t\\caption{Weight measurement data.}\n\\label{gravityofweight}\n\\end{table}\n\\end{minipage}\n\n\n% =====================================\n% NOTE: Spring 1\nFor Spring 1, we can have its length change data versus the force affected on it\ndata.  \n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\tNo. & length [cm] $\\pm$ 0.01 [cm] & F [N] $\\pm$ 0.0001 [N] \\\\ \\hline\n\t$\\Delta L_1$ & 2.00  &  0.0455  \\\\ \\hline\n\t$\\Delta L_2$ & 3.96  &  0.0913  \\\\ \\hline\n\t$\\Delta L_3$ & 5.96  &  0.1388  \\\\ \\hline\n\t$\\Delta L_4$ & 8.02  &  0.1860  \\\\ \\hline\n\t$\\Delta L_5$ & 10.04 &  0.2331  \\\\ \\hline\n\t$\\Delta L_6$ & 12.02 &  0.2792  \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$\\Delta L$  vs. Force for Spring 1}\n\\label{s1df}\n\\end{table}\n\nThen we use MATLAB fit tools to find $k_1$\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/k1}\n\t\\caption{Fit curve of spring 1}\n\\end{figure}\n\n$$ k_1 = 2.3311 \\pm 0.013 [N/m] $$\n$$ u_{k_1,r} = 0.55 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n\tSSE: 6.091e-07\t\t\t\t\\\\\n\tR-square: 1\t\t\t\t\t\\\\\n\tAdjusted R-square: 1 \t\t\\\\\n\tRMSE: 0.0003902 \t\t\t\\\\\n\\end{quote}\n\n\n% =====================================\n% NOTE: Spring 2\nFor Spring 2, we can have its length change data versus the force affected on it\ndata.  \n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\tNo. & length [cm] $\\pm$ 0.01 [cm] & F [N] $\\pm$ 0.0001 [N] \\\\ \\hline\n\t$\\Delta L_1$ & 2.01  &  0.0455  \\\\ \\hline\n\t$\\Delta L_2$ & 4.00  &  0.0913  \\\\ \\hline\n\t$\\Delta L_3$ & 6.03  &  0.1388  \\\\ \\hline\n\t$\\Delta L_4$ & 8.06  &  0.1860  \\\\ \\hline\n\t$\\Delta L_5$ & 10.08 &  0.2331  \\\\ \\hline\n\t$\\Delta L_6$ & 12.10 &  0.2792  \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$\\Delta L$  vs. Force for Spring 2}\n\\label{s2df}\n\\end{table}\n\nThen we use MATLAB fit tools to find $k_2$\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/k2}\n\t\\caption{Fit curve of spring 2}\n\\end{figure}\n\n$$k_2 =  2.3206 \\pm 0.0105 [N/m] $$\n$$ u_{k_2,r} = 0.45 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n\tSSE: 4.305e-07 \t\t\t\t\\\\\n\tR-square: 1 \t\t\t\t\\\\\n\tAdjusted R-square: 1 \t\t\\\\\n \tRMSE: 0.0003281 \t\t\t\\\\\n\\end{quote}\n\n% =====================================\n% NOTE: Spring serial\nFor serial, we can have its length change data versus the force affected on it\ndata.  \n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\tNo. & length [cm] $\\pm$ 0.01 [cm] & F [N] $\\pm$ 0.0001 [N] \\\\ \\hline\n\t$\\Delta L_1$ & 3.96  &  0.0455  \\\\ \\hline\n\t$\\Delta L_2$ & 7.94  &  0.0913  \\\\ \\hline\n\t$\\Delta L_3$ & 11.90 &  0.1388  \\\\ \\hline\n\t$\\Delta L_4$ & 16.40 &  0.1860  \\\\ \\hline\n\t$\\Delta L_5$ & 19.94 &  0.2331  \\\\ \\hline\n\t$\\Delta L_6$ & 24.02 &  0.2792  \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$\\Delta L$  vs. Force for serial}\n\\label{ssdf}\n\\end{table}\n\nThen we use MATLAB fit tools to find $k_3$ , in other words, the $k$ of the serial string.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/k3}\n\t\\caption{Fit curve of spring serial}\n\\end{figure}\n\n$$k_3 = 1.165 \\pm 0.0380 [N/m] $$\n$$ u_{k_3,r} = 3.26 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n\tSSE: 2.144e-05 \t\t\t\t\\\\\n\tR-square: 0.9994 \t\t\t\\\\\n\tAdjusted R-square: 0.9993 \t\\\\\n\tRMSE: 0.002315 \t\t\t\t\\\\\n\\end{quote}\n\n% NOTE: k cal\n\nBy theory, we can calculate $k_3$, i.e. the $k$ of the spring serial by \n$$ k_{3,theory} = \\frac{k_1 \\cdot k_2 }{k_1 + k_2} =  1.1629 $$ \n\nCompared with $k_3 = 1.1649$  from the experiment,\n$$ u_{k_{3,theory},k_3} = \\frac{1.1649 - 1.1629}{1.1629} \\cdot 100 \\%  = 0.17 \\% $$ \nThe theory data is close to the experiment data\n\n\\subsection{Relation between the period $T$ and the mass $M$}\n\nIn this part, we investigate in finding the relation between the period $T$ and \nthe mass $M$.\nFirst, we need to collect the mass data needed later for the fit. Shown in Table~\\ref{dataMass}.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{Mass of the object [g] $\\pm$ 0.01 [g]} \\\\ \\hline\n\tobject with I-shape $m_{I-obj}$  & 176.87 \\\\ \\hline\n\tobject with U-shape $m_{U-obj}$  & 188.16 \\\\ \\hline\n\tspring 1 \t\t\t$m_{spr1}$ & 11.23 \\\\ \\hline\n\tspring 2 \t\t\t$m_{spr2}$ & 10.54 \\\\ \\hline \\hline\n\t\\multicolumn{2}{|c|}{Mass of the object [g] $\\pm$ 0.015 [g]} \\\\ \\hline \n\tequivalent mass\t\t$M_{0,I} = m_{I-obj} + \\frac{1}{3} m_{spr1} + \\frac{1}{3} m_{spr2} $ & 184.13 \\\\ \\hline \n\tequivalent mass\t\t$M_{0,U} = m_{U-obj} + \\frac{1}{3} m_{spr1} + \\frac{1}{3} m_{spr2} $ & 195.42 \\\\ \\hline \n\t\\end{tabular}\n\t\\caption{Mass measurement data}\n\\label{dataMass}\n\\end{table}\n\n\nThe the period $T$ measured in different situations are shown in Table~\\ref{dataTime}.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c||c|c||c|c|}\n\t\\hline\n\t\\multicolumn{6}{|c|}{10 periods [ms] $\\pm$ 0.1 [ms]} \\\\ \\hline\n    \\multicolumn{2}{|c||}{horizontal}  &\n     \\multicolumn{2}{|c||}{incline 1}  &\n     \\multicolumn{2}{|c|}{incline 2}  \\\\ \\hline\n\t$m_1$ & 12560.4 & $m_1$ & 12557.8 & $m_1$ & 12560.9 \\\\ \\hline\n\t$m_2$ & 12718.2 & $m_2$ & 12711.1 & $m_2$ & 12722.0 \\\\ \\hline\n\t$m_3$ & 12878.4 & $m_3$ & 12872.2 & $m_3$ & 12885.9 \\\\ \\hline\n\t$m_4$ & 13021.2 & $m_4$ & 13030.3 & $m_4$ & 13034.7 \\\\ \\hline\n\t$m_5$ & 13189.2 & $m_5$ & 13186.0 & $m_5$ & 13179.2 \\\\ \\hline\n\t$m_6$ & 13326.5 & $m_6$ & 13333.3 & $m_6$ & 13336.9 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Measurement data for the $T$ vs. $M$ relation}\n\\label{dataTime}\n\\end{table}\n\nRecall we have the mass data. \nWe need to add the mass of object with I-shape to each $m_i$\nThus, we can have,\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{|c|c|}\n\\hline\n\\multicolumn{2}{|c|}{m [g] $\\pm$ 0.01 [g]} \\\\ \\hline\n1 & 181.52 \\\\ \\hline\n2 & 186.19 \\\\ \\hline\n3 & 191.04 \\\\ \\hline\n4 & 195.86 \\\\ \\hline\n5 & 200.67 \\\\ \\hline\n6 & 205.38 \\\\ \\hline\n\\end{tabular}\n\\caption{Mass measurement data with I-shape and the object.}\n\\label{massofweight1}\n\\end{table}\n\nThus, for horizontal situation, we can get the following table.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\tmass [g] $\\pm$ 0.01 [g] & $T^2$ [$s^2$] $\\pm$ 0.00001 [$s^2$] \\\\ \\hline\n\t$m_1$ = 181.52  & 1.57763 \\\\ \\hline\n\t$m_2$ = 186.19  & 1.61752 \\\\ \\hline\n\t$m_3$ = 191.04  & 1.65853 \\\\ \\hline\n\t$m_4$ = 195.86  & 1.69551 \\\\ \\hline\n\t$m_5$ = 200.67  & 1.73954 \\\\ \\hline\n\t$m_6$ = 205.38  & 1.77595 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$T^2$ vs. $M$ for horizontal situation}\n\\label{T2vsM_0}\n\\end{table}\n\nThen we use MATLAB fit tools to find $slope_{h}$\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/m1}\n\t\\caption{Fit curve of $T^2$ vs. $M$ for horizontal situation}\n\\end{figure}\n\n$$slope_{h} = 8.3233 \\pm 0.2235 [s^2/kg] $$\n$$ u_{slope_{h},r} = 2.69 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n  SSE: 1.042e-05\t\t\t \\\\ \n  R-square: 0.9996 \t\t     \\\\ \n  Adjusted R-square: 0.9995  \\\\ \n  RMSE: 0.001614 \t\t     \\\\\n\\end{quote}\n\nFor incline 1 situation, we can get the following table.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\tmass [g] $\\pm$ 0.01 [g] & $T^2$ [$s^2$] $\\pm$ 0.00001 [$s^2$] \\\\ \\hline\n\t$m_1$ = 181.52  & 1.57698 \\\\ \\hline\n\t$m_2$ = 186.19  & 1.61572 \\\\ \\hline\n\t$m_3$ = 191.04  & 1.65693 \\\\ \\hline\n\t$m_4$ = 195.86  & 1.69788 \\\\ \\hline\n\t$m_5$ = 200.67  & 1.73870 \\\\ \\hline\n\t$m_6$ = 205.38  & 1.77776 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$T^2$ vs. $M$ for incline 1 situation}\n\\label{T2vsM_1}\n\\end{table}\n\nThen we use MATLAB fit tools to find $slope_{i1}$, the slope for incline 1.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/m2}\n\t\\caption{Fit curve of $T^2$ vs. $M$ for incline 1 situation}\n\\end{figure}\n\n$$slope_{i1} = 8.4380 \\pm 0.0500 [s^2/kg] $$\n$$ u_{slope_{i1},r} = 0.59 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n  SSE: 5.119e-07 \t\t\\\\ \n  R-square: 1 \t\t\t\\\\ \n  Adjusted R-square: 1 \t\\\\ \n  RMSE: 0.0003577 \t\t\\\\ \n\\end{quote}\n\nFor incline 2 situation, we can get the following table.\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\tmass [g] $\\pm$ 0.01 [g] & $T^2$ [$s^2$] $\\pm$ 0.00001 [$s^2$] \\\\ \\hline\n\t$m_1$ = 181.52  & 1.57776 \\\\ \\hline\n\t$m_2$ = 186.19  & 1.61849 \\\\ \\hline\n\t$m_3$ = 191.04  & 1.66046 \\\\ \\hline\n\t$m_4$ = 195.86  & 1.69903 \\\\ \\hline\n\t$m_5$ = 200.67  & 1.73691 \\\\ \\hline\n\t$m_6$ = 205.38  & 1.77872 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$T^2$ vs. $M$ for incline 2 situation}\n\\label{T2vsM_2}\n\\end{table}\n\nThen we use MATLAB fit tools to find $slope_{i2}$, the slope for incline 2.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/m3}\n\t\\caption{Fit curve of $T^2$ vs. $M$ for incline 2 situation}\n\\end{figure}\n\n$$slope_{i2} = 8.3467 \\pm 0.2185 [s^2/kg] $$\n$$ u_{slope_{i2},r} = 2.62 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n  SSE: 9.958e-06 \t\t\t\t\\\\\n  R-square: 0.9996 \t\t\t\t\\\\\n  Adjusted R-square: 0.9996 \t\\\\\n  RMSE: 0.001578 \t\t\t\t\\\\\n\\end{quote}\n\n\n\\subsection{Relation between period $T$ and amplitude $A$}\n\nWe get the following raw data from the experiment.\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{ $A$ [cm] $\\pm$ 0.1 [cm]} & ten periods [ms] $\\pm$ 0.1 [ms] \\\\ \\hline\n\t1 &  5.0 & 12566.3 \\\\ \\hline\n\t2 & 10.0 & 12565.2 \\\\ \\hline\n\t3 & 15.0 & 12560.9 \\\\ \\hline\n\t4 & 20.0 & 12562.6 \\\\ \\hline\n\t5 & 25.0 & 12562.8 \\\\ \\hline\n\t6 & 30.0 & 12563.7 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{ten periods $T$ vs. $A$}\n\\label{TvsAraw}\n\\end{table}\n\nThen we can drive it into $T$ vs. $A$\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{ $A$ [m] $\\pm$ 0.001 [m]} & $T$ [s] $\\pm$ 0.00001 [s] \\\\ \\hline\n\t1 & 0.050 & 1.25663 \\\\ \\hline\n\t2 & 0.100 & 1.25652 \\\\ \\hline\n\t3 & 0.150 & 1.25609 \\\\ \\hline\n\t4 & 0.200 & 1.25626 \\\\ \\hline\n\t5 & 0.250 & 1.25628 \\\\ \\hline\n\t6 & 0.300 & 1.25637 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{$T$ vs. $A$}\n\\label{TvsA}\n\\end{table}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/a1}\n\t\\caption{Fit curve of $T$ vs. $A$}\n\\end{figure}\n\n$$ k =  -0.001057 \\pm 0.0025  [s/m] $$\n$$ u_{k,r} = 236.52 \\% $$\n\nGoodness of fit:\n\\begin{quote}\n\t\\centering\n SSE: 1.39e-07 \t\t\t\t  \\\\ \n R-square: 0.2602 \t\t\t  \\\\ \n Adjusted R-square: 0.07529   \\\\ \n RMSE: 0.0001864 \t\t\t  \\\\ \n\\end{quote}\n\nFor the relative uncertainty is quite large, and R-square is 0.2602, which is not very well,\nwe can say that $T$ and $A$ do not have a clear linear relation.\n\n\n\\subsection{Relation between $ v_{\\max}$ and $A$}\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\\hline\n\t$x_{in}$ [cm] $\\pm$ 0.002 [cm] & $x_{out}$ [cm] $\\pm$ 0.002 [cm]  \\\\ \\hline\n\t0.472 & 1.542 \\\\ \\hline\n\t0.482 & 1.540 \\\\ \\hline\n\t0.480 & 1.530 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Data of $x_{in}$ and $x_{out}$ for U-shape}\n\\label{L_inout}\n\\end{table}\n\n\n\\[\n\\begin{split}\n\tx_{in}  & = \\frac{1}{3}\\sum_{i=1}^{3}x_{in,i}    \n\t\t      = \\frac{0.472 + 0.482 + 0.480}{3}      \\\\\n\t        & = (0.4780 \\pm 0.003) \\quad cm          \\\\\n\tu_{r,x_{in}} & = 0.63 \\%                         \\\\\n\tx_{out} & = \\frac{1}{3}\\sum_{i=1}^{3}x_{out,i}   \n\t          = \\frac{1.542 + 1.540 + 1.530}{3}      \\\\\n\t        & = (1.5373 \\pm 0.004) \\quad cm          \\\\\n\tu_{r,x_{out}}& = 0.26  \\%                       \n\\end{split}\n\\]\n\n$$ \\Delta L = (x_{in} + x_{out})/2 = 1.0076 \\pm 0.003 \\quad cm $$\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{ $A$ [cm] $\\pm$ 0.1 [cm]} & $\\Delta t$ [ms] $\\pm$ 0.01 [ms]    \\\\ \\hline\n\t1  &  5.0 & 42.60 \\\\ \\hline\n\t2  & 10.0 & 20.56 \\\\ \\hline\n\t3  & 15.0 & 13.57 \\\\ \\hline\n\t4  & 20.0 & 10.34 \\\\ \\hline\n\t5  & 25.0 &  8.25 \\\\ \\hline\n\t6  & 30.0 &  6.90 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Data for the $ {v_{\\max}}^2$ vs. $A^2$ relation.}\n\\label{A_t}\n\\end{table}\n\nFrom $ \\Delta L = v_{max} \\cdot \\Delta t $ ,\nWe can calculate out $ v_{max} $\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{$A$ [cm] $\\pm$ 0.1 [cm]} \n\t& $\\Delta t$ [ms] $\\pm$ 0.01 [ms]  \n\t& $v_{max}$ [m/s] $\\pm$ 0.0001 [m/s] \\\\ \\hline\n\t1  &  5.0 & 42.60  & 0.2365 \\\\ \\hline\n\t2  & 10.0 & 20.56  & 0.4901 \\\\ \\hline\n\t3  & 15.0 & 13.57  & 0.7425 \\\\ \\hline\n\t4  & 20.0 & 10.34  & 0.9745 \\\\ \\hline\n\t5  & 25.0 &  8.25  & 1.2213 \\\\ \\hline\n\t6  & 30.0 &  6.90  & 1.4603 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Calculated Data for the $ {v_{\\max}}^2$ vs. $A^2$ relation.}\n\\label{A_t_v}\n\\end{table}\n\nFinally, we get the relation between$ {v_{\\max}}^2$ and $A^2$ .\n\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\\hline\n\t\\multicolumn{2}{|c|}{$A^2$ [$cm^2$] $\\pm$ 0.1 [$cm^2$]} \n\t&  $v_{max}^2$ [$m^2/s^2$] $\\pm$ 0.0001 [$m^2/s^2$] \\\\ \\hline\n\t1  &  25.0 & 0.0559 \\\\ \\hline\n\t2  & 100.0 & 0.2402 \\\\ \\hline\n\t3  & 225.0 & 0.5513 \\\\ \\hline\n\t4  & 400.0 & 0.9496 \\\\ \\hline\n\t5  & 625.0 & 1.4917 \\\\ \\hline\n\t6  & 900.0 & 2.1324 \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Calculated Data for the $ {v_{\\max}}^2$ vs. $A^2$ relation.}\n\\label{A2_v2}\n\\end{table}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=13cm]{matlab/fitfig/av1}\n\t\\caption{Fit curve of $ {v_{\\max}}^2$ vs. $A^2$}\n\\end{figure}\n\n$$ k =   23.6964 \\pm 0.3300  $$\n$$ u_{k,r} = 1.39 \\% $$\n\nGoodness of fit: \n\\begin{quote}\n\t\\centering\n  SSE: 0.0003151 \t\t\t\t\\\\\n  R-square: 0.9999          \t\\\\\n  Adjusted R-square: 0.9999 \t\\\\\n  RMSE: 0.008876    \t\t\t\\\\\n\\end{quote}\n\nThus, we can find that there is a linear relation between $ {v_{\\max}}^2$ and $A^2$.\n", "meta": {"hexsha": "66bdf1490bf37d01a02239b48faeb62f5f2bea26", "size": 15884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "E3/part/5r.tex", "max_stars_repo_name": "iamwrm/VP141", "max_stars_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-24T11:28:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T11:28:04.000Z", "max_issues_repo_path": "E3/part/5r.tex", "max_issues_repo_name": "iamwrm/VP141", "max_issues_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "E3/part/5r.tex", "max_forks_repo_name": "iamwrm/VP141", "max_forks_repo_head_hexsha": "c0a5d1992967b1552d6f7ea0806c9244d58f64ac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9647887324, "max_line_length": 108, "alphanum_fraction": 0.5760513725, "num_tokens": 7451, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.4182356121934078}}
{"text": "\\documentclass[a4paper,12pt]{report}\n\n\\usepackage{amsmath,amsfonts,mathtools}\n\\usepackage{hyperref}\n\n\\usepackage{listings}\n\\usepackage{color}\n\n\\definecolor{dkgreen}{rgb}{0,0.6,0}\n\\definecolor{gray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mauve}{rgb}{0.58,0,0.82}\n\n\\begin{document}\n\\title{ECE253 Abridged}\n\\author{Aman Bhargava}\n\\date{September 2019}\n\\maketitle\n\n\\tableofcontents\n\n\\pagebreak\n\n\\chapter{Review: Bit Manipulation}\nHave you ever wanted to be a cool computer person who does things with ones and zero's instead of actual letters and numbers like a normal person? If so, this is the right chapter for you!\n\n\\section{Converting to and from Different Bases}\nBase 10, 2, and 16 are most commonly used. Base 16 is just a way to read base 2 in a more efficient manner. In order to work with bits it's pretty important to know how to convert back and forth because the test is all on paper. \n\n\\subsection{Converting from base 10 $\\to$ base 2}\nYou keep dividing by two, keeping track of the remainder. Eventually the number you will be trying to divide by two will be 1. You keep going until it's zero + remainder(1). Then you read the reaminders upward from that final 1.\n\n\\subsection{Converting from base 2 $\\to$ base 16}\nAny hex number can be expressed as 4 binary digits. Make a correspondence table between quadruplets of binary numbers and hex (1-f, inclusive). To convert to base 16 subdivide from right to left in groups of four binary digits. Pad the leftmost part with leading zeros and convert using the table. \n\n\\subsection{Converting from base 10 $\\to$ base 16 (and vice versa)}\nJust go through base 2 fam.\n\n% \\chapter{Logic Functions and Logic Gates}\n% \\section{Or Gate}\n% \\begin{enumerate}\n% \\item Symbols\n% \\item Switch structure\n% \\item Truth table\n% \\end{enumerate}\n\n% \\section{And Gate}\n\n% \\section{Inverter}\n\n% \\section{XOR}\n\n\n\\chapter{Boolean Algebra}\nHere are the axioms of Boolean Algebra:\n\\begin{enumerate}\n\\item $0 \\cdot 0 = 0$\n\\item $1 \\cdot 1 = 1$\n\\item $0 \\cdot 1 = 1 \\cdot 0 = 0$\n\\item if $x = 0$, $!x = 1$\n\\end{enumerate}\n\n\\paragraph{Dual Form}\n\\begin{enumerate}\n\\item $1 + 1 = 1$\n\\item $0 + 0 = 0$\n\\item $1 + 0 = 0 + 1 = 1$\n\\item if $x = 1$, $!x = 0$\n\\end{enumerate}\n\n\\paragraph{Duality: } In a given logic expression, you can swap $1 \\to 0$ and $\\cdot \\to +$\nand the expression is still valid.\n\n\\section{Useful Boolean Expression Rules}\n\\begin{itemize}\n\\item $x \\cdot 0 = 0$\n\\item $x \\cdot 1 = x$\n\\item $x \\cdot x = x$\n\\item $x \\cdot !x = 0$\n\\item $x \\cdot 0 = 0$\n\\item $!!x = x$\n\\item $x + 1 = 1$\n\\item $x + 0 = x$\n\\item $x + x = x$\n\\item $x + !x = 1$\n\\end{itemize}\n\n\\paragraph{Distributive Properties: }\n$$x \\cdot (y + z) = xy + xz$$\n$$x + (y \\cdot z) = (x+y) \\cdot (x+z)$$\n\n% \\section{Less Obvious Identities}\n% \\begin{itemize}\n% \\item \n% \\end{itemize}\n\n\n\\section{Sum-of-Products (SOP)}\n'Sum' means boolean OR while 'product' means boolean AND. \n\n\\paragraph{Min term: } for $n$ variables, term where all variables appear once is a 'minterm'.\nNote that variables can either be complimented or uncomplimented. \n\nAny boolean function can be represented by the sum of products of minterms - this is just done \nby simply converting the truth table and OR-ing each truth. \n\nThen, you can simplify. Pretty common sense. 'Canonical' just means it's a bunch of midterms\nseparated by OR's.\n\n\\section{Product of Sums (POS)}\n\\paragraph{Max term: } where all $n$ variables appear OR-d. They can be complimented or\nun-complimented. \n\nYou can pretty easily make all the valid max terms from a truth table. To generate a POS\nexpression, you multiply (AND) the maxterms that sum to zero. \n\n% \\section{NAND and NOR Logic Networks (TB 2.7)}\n\n\n% \\section{Three-Way Light Control (TB 2.8.1)}\n\n\n\\chapter{How 2 Verilog}\nA 3-input multiplexer can be made with two 2-input multiplexers.\nNow let's implement this without using two pre-made multiplexers. Let:\n\\begin{itemize}\n\\item \n\\end{itemize}\n\n\\paragraph{Notes on Implementation}\n\\begin{itemize}\n\\item If you want inputs to be registered from switches, you need to assign them SW[<int>]\n\\item Likewise, if you want outputs to be registered to LED's, assign them LEDR[<int>]\n\\end{itemize}\n\n\\subsection{Code: 3-Way Multiplexer}\n\n\\lstset{frame=tb,\n  language=Verilog,\n  aboveskip=3mm,\n  belowskip=3mm,\n  showstringspaces=false,\n  columns=flexible,\n  basicstyle={\\small\\ttfamily},\n  numbers=none,\n  numberstyle=\\tiny\\color{gray},\n  keywordstyle=\\color{blue},\n  commentstyle=\\color{dkgreen},\n  stringstyle=\\color{mauve},\n  breaklines=true,\n  breakatwhitespace=true,\n  tabsize=3\n}\n\n\\begin{lstlisting}\nmodule mux2b2to1 (SW, LEDR); //Two bit 2 to 1 multiplexer  \n   input[4:0] SW, //[4:0] sets switches 0-4 to inputs(?)\n   output[1:0] LEDR, //\n\n   wire S;\n   wire[1:0] a, b, z; //'two bit wide vector'?\n\n   assign a = SW[1:0],\n   assign b = SW[3:2],\n   assign s = SW[4],\n   assign LEDR = z,\n\n   assign z[0] = (~s&a[0]) | (s&b[0]);\n   assign z[1] = (~s & a[1]) | (s&b[1]);\n\nendmodule;\n\\end{lstlisting}\n\n\\paragraph{Can you make the assignment more efficient?}\nWhat if you do this:\n\\begin{lstlisting}\n   // assign z[0] = (~s&a[0]) | (s&b[0]);\n   // assign z[1] = (~s & a[1]) | (s&b[1]);\n   assign z = (~s&a) | (s&b); // NOT CORRECT\n\\end{lstlisting}\n\n\\paragraph{Because $s$ is only 1-bit and $a, b$ are two bits, $s$ is extended with a \\textbf{0}, \nwhich makes the logic incorrect!}\n\n\\paragraph{General Notes on how Syntax Works:}\n\\begin{itemize}\n\\item \\textbf{What is 'assign'? } 'assign' just means you're making a connection (alias?) b/w the\ntwo. \\textbf{Question: } is this necessary for instantiating the variable?\n\\item \\textbf{Assignment arith.} When you create a verilog wire/input with $x = [a:b]$, the number of bits in \n$x$ is $b-a + 1$\n\\item \\textbf{Bit Access: } To access bits, you say $x[n]$ or $x[n:m]$ where $n < m$. The length of the slice\nis $n-m +1$\n\\item \\textbf{Concatenation: } If you want to stitch together multiple bits, you use $x = {SW[9:8], SW[1:0]}$. That\nstatement stitches together two 2-bit chunks ($SW[9:8], SW[1:0]$ to make one 4-bit chunk).\n\\item \\textbf{Order of Operations: } Basically nobody knows... just use parenthesis when you're\nnot sure. And goes before or, though.\n\\end{itemize}\n\n\n\\section{Full Adder}\n\\paragraph{Description: }\nAdding in binary is the same as in decimal, just with fewer options. When adding two single bits,\nwe have three output possibilities: $00, 01, 10$. We call the least significant bit the sum $s$ and\nthe most significant digit the carry $c$.\n\nLet's see the truth table:\n\\begin{tabular}{ll|ll}\n$x$ & $y$ & $C$ & $s$ \\\\\n\\hline\n0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 1 \\\\\n1 & 0 & 0 & 1 \\\\\n1 & 1 & 1 & 0 \\\\\n\\end{tabular}\n\nAs you can see, the sum bit is just $x \\oplus y$ and the carry bit is $xy$. \nThis is a \\textbf{half adder} because it doesn't accept a carry from the last calculation.\n\nA full adder accepts a carry in $C_{in}$, $x$, and $y$, and outputs sum $s$ and carry out $C_{out}$.\n\nLet's see the truth table:\n\\begin{tabular}{lll|ll}\n$x$ & $y$ & $C_{in}$ & $C_{out}$ & $s$ \\\\\n\\hline\n0 & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 1 & 0 & 1 \\\\\n0 & 1 & 0 & 0 & 1 \\\\\n0 & 1 & 1 & 1 & 0 \\\\\n1 & 0 & 0 & 0 & 1 \\\\\n1 & 0 & 1 & 1 & 0 \\\\\n1 & 1 & 0 & 1 & 0 \\\\\n1 & 1 & 1 & 1 & 1 \\\\\n\\end{tabular}\n\nTherefore $$C_{out} = xy + xC_{in} + yC_{in}$$\nand $$s = x \\oplus y \\oplus C_{in}$$\n\n\\paragraph{Ripple Carry Adder: } Then you can string them together by assigning one of these \nadders to each bit of the output and passing the carry out to the carry in of the next bit!\n\n\\paragraph{Specifics for Ripple Carry Adder: }\n\\begin{itemize}\n\\item Max size for output is one more then the two input's sizes because one more order of \nmagnitude in binary is just doubling the number, and the most you can do when adding two \nnumbers of equal length is double them.\n\\item Basically just string them together and you're golden.\n\\end{itemize}\n\n\\paragraph{Review of Outcomes}\n\\begin{itemize}\n\\item $Cout = xy + CinX + CinY$\n\\item $Sum = x \\oplus y \\oplus z$\n\\end{itemize}\n\n\\paragraph{Now let's make it in verilog!}\n\\begin{lstlisting}\nmodule fulladder(x, y, Cin, S, Cout);\n   input x, y, Cin;\n   output S, Cout;\n\n   assign s = x ^ y ^ Cin;\n   assign Cout = (x&y) | (Cin&x) | (Cin&y); // Why no wires here? Bc no physical IO's.\n\\end{lstlisting}\n\n\\paragraph{Now we make a 3-bit adder out of full adders in Verilog!}\n\\begin{lstlisting}\nmodule adder3bit(X, Y, S)\n   input[2:0] X, Y;\n   output[3:0] S;\n   wire[3:0] C; // to connect full adders together\n\n   fulladder U0(X[0], Y[0], C[0], C[1]);\n   fulladder U1(X[1], Y[1], C[1], C[2]);\n   fulladder U2(X[2], Y[2], C[2], C[3]);\n\n   assign S[3] = C[3]; // Final carry bit is the most significant bit of the sum.\n   assign C[0] = 1'b0; // Weird syntax: 1 bit, equal to 0.\nendmodule;\n\\end{lstlisting}\n\nThis is structural verilog - we can't immediately see the bigger picture. We see wires and \nmodules stitched together and we have to figure out what it all means.\n\n\\paragraph{Weird constant syntax: }\n\\begin{itemize}\n\\item $1'b0$: 1 bit constant, in binary, equal to 0.\n\\item $4'hF$: 4 bit constant, in hex, equal to F.\n\\item $4'd9$: 4 bit constant, in decimal, equal to 9.\n\\item $8'h1E$: 8 bit constant, in hex, equal to 1E.\n\\end{itemize}\n\n\\section{7-Segment Display}\n\\paragraph{Prompt: } Design a c ircuit with two inputs $x_1$ and $x_0$ representing a \n2-bit number $x$. Show $x$ on the 7-segment display (ranges from 0-3 inclusive).\n\n\\paragraph{Numbering: } $h_0$ is the top segment. Clockwise increases. $h_6$ is the middle one.\n\n\\paragraph{Note on D1-SoC Board: } Logic 0 makes the light turn on for $h_{0-6}$ and 1 makes \nit turn off ('active low')\n\n\\subsection{Displaying Numbers}\nSections to light up for 0: $h_{0-5}$\nSections to light up for 1: $h_{1-2}$\nSections to light up for 2: $h_{0-1}, h_6, h_{3-4}$\nSections to light up for 3: $h_{0-3}, h_6$\n\n\\paragraph{With active low: }\nSections to power for 0: $h_{6}$\nSections to power for 1: $h_{0}, h_{3-6}$\nSections to power for 2: $.$\nSections to power for 3: \n\n\\paragraph{Truth Table: }\n\\begin{tabular}{ll|lllllll}\n$x_1$ & $x_2$ & $h_6$ & $h_5$ & $h_4$ & $h_3$ & $h_2$ & $h_1$ & $h_0$  \\\\\n\\hline\n0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0  \\\\\n0 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 1  \\\\\n1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0  \\\\\n1 & 1 & 0 & 1 & 1 & 0 & 0 & 0 & 0  \\\\\n\\end{tabular}\n\n\\paragraph{Consolidating the Logic Functions: }\n$$h_0 = (!x_1) \\cdot x_0$$\n$$h_1 = 0$$\n$$h_2 = x_1 \\cdot !x_0$$\n$$h_3 = !x_1 \\cdot x_0$$\n$$h_4 = x_0$$\n$$h_5 = x_1 | x_0$$\n$$h_6 = !x_1$$\n\n\\paragraph{Verilog Code: }\n\\begin{lstlisting}\nmodule seg7(SW, HEX0)\n   input[1:0] X;\n   output[6:0] HEX0;\n   \n   assign HEX0[0] = ~SW[1] & SW[0];\n   // etc.\n\nendmodule\n\\end{lstlisting}\n\n\\paragraph{Implementation Example: }\nDesigna  circuit with 4 inputs $a, b, c, d$ and $s$. \n   if s = 0, show $a+b$ on 7-seg display\n   if s = 1, show $c+d$ on 7-seg display\n\n$${a, b} \\to mux_{2 bit * 2 inputs} \\to fulladd_{cin = 0} \\to HEXO \\to output$$\n\n\\begin{itemize}\n\\item The carry in digit to the full adder is 0\n\\item The carry out from the full adder is the most significant digit of the HEXO input.\n\\item Honestly you could just use a half adder because you don't need a carry-in. \n$C_{out} = xy$, $Sum = x \\oplus y$\n\\end{itemize}\n\n\\paragraph{Cool XOR Fact: } $\\oplus$ returns 1 if the number of true inputs is ODD.\n\n\\section{FPGA's}\nCan do anything.\n\\begin{itemize}\n\\item Field programmable gate arrays: Programmable in the field (i.e. not in the factory necessarily).\n\\item 2-D array of programmable blocks.\n\\item Blocks contain lookup tables (LUT)\n\\item Any two input LUT can be programmed for any two-input logic functions.\n\\item More complex logic comes out when you connect the LUTS - this is what Quartus does. \n\\end{itemize}\n\n\\paragraph{How to encode any two-input thing}\nLet there be 4 sRAM bits $p, q, r, s$. Let the inputs be $a, b$. \n\n$${p, q} \\to mux_{a1} \\to x$$\n$${r, s} \\to mux_{a1} \\to y$$\nWhere $x, y$ are itermediate variables.\n\n$${x, y} \\to mux_{b} \\to output$$\n\nTherefore it takes 4 ram cells for a 2-input LUT. $$n_{ramcells} = 2^{inputs}$$\n\nThere are 85,000 6-LUTS on lab chips.\n\n\\chapter{Karnaugh Maps}\n\\section{Motivation}\nCreating boolean functions to get what you need done is confusing and unlikely to lead to an optimal solution \nwhen there are many variables.\n\nKarnaugh maps are a tool for expressing your truth tables in such a way that makes getting optimal solutions easier\nwith many variables.\n\n\\paragraph{Example 2x2 Karnaugh Map}\n\\begin{tabular}{l|cc}\n& $0$ & $1$ \\\\\n\\hline\n0 & a & b \\\\\n1 & c & d \\\\\n\\end{tabular}\n\n\n\\section{Review of Terminology}\n\n\\begin{itemize}\n\\item \\textbf{Implicant:} Any product term for which the function is true (think 'implies' logic is 1)\n\\item \\textbf{Cover:} A set of implicants that covers all 1's of the function.\n\\item \\textbf{Prime implicant:} Any implicant that, if we delete a literal, is no longer an implicant (largest\n   groups of ones in the K-map)\n\\item \\textbf{Essential prime implicant:} Prime implicant that covers a 1 covered by no other prime implicant.\n\\item \\textbf{Min-cost cover:}\n\\item \\textbf{Cost:}\n\\end{itemize}\n\n\\paragraph{Example: }\n\\begin{tabular}{l|cccc}\n& $00$ & $01$ & $11$ & $10$   \\\\\n\\hline\n0 & 1 & 1 & 1 & 1 \\\\\n1 & 1 & 0 & 0 & 0 \\\\\n\\end{tabular}\n\nLet the left column be the $z$ column and the top be products of $x, y$. \n\nList of implicants:\n\\begin{enumerate}\n\\item $\\bar{z}$ \n\\item $\\bar{x} \\bar{y}$\n\\item $\\bar{x} \\bar{z}$\n\\item $y\\bar{z}$\n\\item $x\\bar{z}$\n\\item $\\bar{y}\\bar{z}$\n\\item $m_{0, 1, 2, 4, 5}$\n\\end{enumerate}\n\nPrime Implicants: Largest group of ones in cardinal maps...\n\n\\paragraph{Cost Defininition: } $n_{gates} + n_{inputs}$\n\n\\section{Procedure for Minimum Cost Cover}\n\\begin{itemize}\n\\item Find essential prime implicants and include in cover\n\\item Select additional prime implicants to include in the cover until all 1's are covered.\n\\end{itemize}\n\n\\section{5 Variable Karnaugh Map}\nUse two 4-variable K-Maps. One for case where $x_5 = 0$, other for $x_5 = 1$.\nMin-term indexing goes by the binary representation of $x_{0-n}$ where $x_n$ is the LEAST significant bit.\n\n\n\\chapter{Storage Elements}\n\\section{Introduction}\nUntil now, the values coming in have dependend on the state (high or low) of the input \nwires to the circuit. There's another option where the inputs dependent on past states \nof the circuit.\n\n\\paragraph{Storage elements } represent a \\textbf{state} of a circuit. When inputs \nchange, new inputs either leave circuit in the same state or change the state. These \ncircuits are called \\textbf{sequential} circuits. Memory elements can be created \nwith logic gates. \n\n\\section{RS Latches}\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{../media/basicLatch.png}\n\\caption{Basic Latch}\n\\label{latch-basic}\n\\end{figure}\n\\subsection{Behavior} \nYou use $S$ to set the output $Q_a$ to $1$ and $R$ to set $Q_a$ to $0$.\n\n\\begin{tabular}{ll|ll}\n$S$ & $R$ & $Q_a$ & $Q_b$ \\\\\n\\hline\n0 & 0 & No change &  \\\\\n0 & 1 & 0 & 1 \\\\\n1 & 0 & 1 & 0 \\\\\n1 & 1 & 0 & 0 \\\\\n\\end{tabular}\n\n$S$ functions as the 'set' signal. \n\n\n\\section{Gated RS Latch}\nAdd an and gate to the inputs so that you can only enter signals to the latch when \nthe $clk$ signal is $1$.\n\n\\subsection{Synchronous Reset}\nThis is when you can only use the reset when the clock is at 1 (basically you just \nAND the $D$ and the $R_n$ for an `active low' reset). Reset behavior is synchronized to the rising edge. \n\n\\subsection{Behavior} \nSame as an RS latch, but you can only send $R$ and $S$ signals when the $clk$ is logic $1$.\n\n\\section{Gated D Latch}\nAlso called `Transparent Latch' or `Level-Sensitive Latch'. \n\n\\subsection{Behavior: } When the clock is $1$, then $Q = D$. $Q$ changes as $D$ changes \nand then when the clock is turned back to $0$, then $Q$ persists in it's last state. \n\n\\section{D Flip-Flops}\n\\paragraph{Symbol: } Same as the D Latch, but there's a triangle instead of $clk$. If \nit's a \\textbf{negative edge} triggered flip-flop, the symbol has a bubble next to the \nclock. \\textbf{Positive edge} appears to be the default. \n\n\\paragraph{Edge-Triggered Flip Flop: } The flip flop only changes when the clock is \non a rising edge or a falling edge. \n\n\\subsection{Master-Slave Flip Flop}\nYou connect a master D-Latch to a slave D-Latch. The clock signals of one is the inverse \nof the clock symbol going into the other one. \n\nThis setup yields a system where you can only change the value of $Q$ for the slave ($Q_s$) \non a rising/falling edge. \n\n\\subsection{Behavior} On rising or falling clock edge, the value of $D$ is stored and \nappears in $Q$.\n\n\\paragraph{Work-Through demonstration: } Let's say you have the inverted clock going \nto the slave. When you're in logic 1 for the clock, the master is in \\textbf{transparent} \nmode. $Q_m = D$. When you switch, the value of the master is stuck and the value of the \nslave is set to $Q_m$. You can't reset the slave value after the transition because the \n\\textbf{opaque} mode of the master. \n\nPretty cool property! \n\n\\subsection{Why it's Useful}\n\nYou can put these in the middle of circuits to save values. Then, you can re-inject inputs \nwhile you wait for the last half of the circuit to finish processing. It's like splitting \nthe circuit into two pieces that can run on different elements simultaneously. \n\nThis is a bit of a dumb way to think about it, but that's the general idea behind how \nthey are actually used. \n\n\n\\section{T Flip-Flop}\nLet's take a D Flip Flop component and loop the value of $Q$ and $\\bar{Q}$ back to the \ninput $D$. Let's make $T$ the new input. $T$ switches the input of $D$ between $Q$ and \n$\\bar{Q}$. \n\n% \\section{Flip-Flop Reset/Preset}\n\n% \\section{Summary of Objects}\n\n\\section{Verilog Implementations}\n\\subsection{Gated D-Latch}\n\\begin{lstlisting}\nmodule D_Latch (D, clock, Q, Qb);   \n   input D, clock;\n   output reg Q, Qb; // `reg` means it's an always block\n\n   always@(D,clock) //defining a block that's sensitive to changes in Q and D.\n   begin\n      if(clock==1'b1)\n      begin // need this begin because you're doing two things in the if block.\n         Q = D;\n         Qb = ~D;\n      end // begin and end function like curly braces in C/C++/Java\n   end //if clock == 0'b1, then verilog maintains previous values. \n\nendmodule\n\\end{lstlisting}\n\n\\subsection{Edge-Triggered Flip Flop}\n\\begin{lstlisting}\nmodule D_ft(D, clock, Q, Qb)\n   input D, clock;\n   output reg Q, Qb;\n\n   // Always blocks tell you what you need to \n   always@(posedge clock) // This means you execute this on the positive edge (posedge is a keyword for that)\n   begin \n      Q <= D; // use '<=' for describing flip flops.\n      Qb <= ~D; // we may get to why in this course but for now it's just a thing...\n   end\nendmodule\n\\end{lstlisting}\n\n\\subsection{Synchronous Reset (Active Low)}\n\\begin{lstlisting}\nalways@(popsedge clock)\nbegin\n   if(resetn == 1'b0)\n   begin\n      Q <= 1'b0;\n      Qb <= 1'b1;\n   end\n   else \n   begin\n      Q <= D;\n      Qb <= ~D;\n   end\nend \n\nendmodule;\n\n\\end{lstlisting}\n\n\\chapter{Finite State Machine}\n\\section{Review}\nA finite state machine (FSM) is an object that changes it properties (outputs) \nbased on inputs over time. For example, a human could be modeled as a state machine \nwhere the input is water over time and the output is the need to go to the bathroom. \n\\textbf{Sequential circuits} are FSM's.\n\n\\subsection{State Diagrams}\n\\paragraph{Example: } $w$ can be $0, 1$. We are trying to find when $w$ has gone \n$1 \\to 0 \\to 1$. \n\\paragraph{Solution: } We can use a shift register to get all \nthe sequential bits of $w$ in, then we use a simple logical expression on the outputs\n$w_0 \\dot \\bar{w_1} \\dot w_2$. \n\n\\paragraph{One-Hot Encoding: } When only one of your bits is one. \\textbf{one cold} \nis the opposite.\n\n\\subsection{Lmao what is an always block actually}\n\\begin{lstlisting}\nalways@(A, B, C)\nbegin\n\nend\n\\end{lstlisting}\n$A, B, C$ are in the sensitivity list, the code inside is `sensitive' to them so \nas they change the internal block is fired. You can only use \\textbf{if} statements \nin here. \n\n\\subsection{Case Statements}\nSame as in pretty much all other programming languages. \n\\begin{lstlisting}\ncase(A)\n   value1:\n      do_something;\n   value2: \n      do_something_else;\n   value3: // multiple lines\n      begin\n         do_something;\n         do_something more;\n      end\n   default:\n      default_behavior;\nendcase\n\\end{lstlisting}\n\n% \\subsection{State Machine Diagrams and Sequantial Diagrams}\n\n\\subsection{Case Statements for State Machines}\nQuick example:\n\\begin{lstlisting}\nmodule FSM(input w, clock, resetn, output z);\n   reg[1:0]y, Y;\n   parameter A = 2'b0, B = 2'b01, C = 2'b10, D = 2'b11;\n   //state table\n   always@(w, y) begin\n      case(y) begin\n         A: begin\n            if(W) \n               Y = B;\n            else  \n               Y = A;\n         end\n         B: begin\n            if(w)\n               Y = B;\n            else \n               Y = C;\n         end\n      endcase\n   end\n\n   always@(posedge clk) begin\n      if(!resetn)\n         y <= A;\n      else  \n         y <= Y;\n   end\n\n   assign z = (y == D);\n\nendmodule\n\\end{lstlisting}\n\\begin{itemize}\n\\item \\textit{parameter} lets you define constants. \n\\end{itemize}\n\n\n\n\\chapter{Introduction to Microprocessors}\n\\section{Computer Organization}\n\\paragraph{A computer } can read, write, and process data. In order to do so, it has the following main parts:\n\\begin{enumerate}\n\\item Input/Output Devices\n\\item Memory\n\\item Processor (includes Arithmetic Logic Unit and Control Unit)\n\\end{enumerate}\nAll of these are connected through an \\textbf{interconnection network}.\n\\subsection{Memory Unit}\nThe memory unit can be broken into three main pieces. Overall, it functions to \\textbf{store programs} and \\textbf{data}. \n\\subsubsection{Primary Memory}\n\\begin{itemize}\n\\item Stores programs\n\\item Relatively fast, called `main memory'\n\\item Made of a collection of \\textbf{bit registers}\n\\end{itemize}\nThe bit registers in memory are read and written in \\textbf{WORDS}. Each word has its own address (consecuitive numbers) and a standardized number \nof bits. \n\n\\subsubsection{Cache}\n\\begin{itemize}\n\\item Smaller, faster RAM unit (RAM = Random Access Memory, all can be accessed at the same speed).\n\\item Holds current parts of a program.\n\\item Packaged with the processor $\\to$ faster to access information from here than from memory.\n\\end{itemize}\n\n\\subsubsection{Secondary Storage}\nBasically just external drives.\n\n\\subsection{Arithmetic Logic Unit (ALU)}\nMost operations are executed here ($+, -, /, \\cdot, \\leq, \\geq, >, <$). Operands are passed here via \\textbf{registers}. Registers are \n1 word long and are very fast to access.\n\n\\subsection{Control Unit}\nCoordinates the rest of the units. Usually distributed throughout the compter. The following main types of operations are coordinated by this unit:\n\\begin{enumerate}\n\\item Storing information in memory as programs and data.\n\\item Moving information to memory for the ALU to process.\n\\item Moving processed information to the output unit.\n\\end{enumerate}\n\n\\chapter{Basic Concepts in Microprocessors}\n\\section{Basic Concepts}\n\\lstset{frame=tb,\n  language=verilog,\n  aboveskip=3mm,\n  belowskip=3mm,\n  showstringspaces=false,\n  columns=flexible,\n  basicstyle={\\small\\ttfamily},\n  numbers=none,\n  numberstyle=\\tiny\\color{gray},\n  keywordstyle=\\color{blue},\n  commentstyle=\\color{dkgreen},\n  stringstyle=\\color{mauve},\n  breaklines=true,\n  breakatwhitespace=true,\n  tabsize=3\n}\n\n\\begin{lstlisting}\nLOAD     R2, LOC     // Copies data from main memory into a register. \nADD      R4, R2, R3  // R4 = R2 + R3 (contents)\nSTORE    R4, LOC     // Copies data from a REGISTER to main memory.\n\nMOVE     R2, R4      // Copy contents of R4 to R2\nCLEAR    R2          // Set contents of R2 to be 0\nADD      R2, R2, R4  // R2 = R2 + R4\nSUB // Same as add but subtraction\nMULTIPLY\nDIVIDE\n\n\nAND      R4, R2, R3  // R4 = R2 & R3\nOR\nNOT\n\\end{lstlisting}\n\nThe processor's \\textbf{PROGRAM COUNTER} (PC) holds the address of the next instruction. Each instruction is 1 word in RISC computers.\n\n\\section{Memory Locations and Addresses}\n1 cell is 1 bit, and n cells is 1 word. Memory is a collection of words, usually from 16-64.\n\\paragraph{Address spaces: } The possible addresses in a $k$-bit address space range from $0\\to 2^{k}-1$\n\\paragraph{Byte-addressable memory } indexes each byte (8 bits) with an integer $0, 1, 2... n$. Therefore, in a 32-bit word system, \nthe address of each word is $0, 4, 8, 12, ...$ in byte addressible memory.\n\n\\textbf{Big endian} means that the lower byte address has the more significant digit while \\textbf{little endian} holds the oppoiste.\n\n\\subsection{Memory Operations}\nREAD and WRITE are the main operations. \n\n\\begin{itemize}\n\\item READing copies the contents of a memory location to a processor register. This is done by specifying \nthe address in memory that the processor wants to read. \n\\item WRITing involves copying the contents of a processor register to a particular \nplace in memory. The process sends the address it wishes to write to and the data it wants to write there.\n\\end{itemize}\n\n\\section{Instruction Sequencing}\nThere are 4 operations needed for running a computer program:\n\\begin{enumerate}\n\\item Data transfers between memory and process (READ and WRITE)\n\\item Arithmetic and logic operators\n\\item Program sequencing and control (branching, subroutines, etc.)\n\\item Input and Output\n\\end{enumerate}\n\n\\subsection{RISC and CISC Instructions}\n\\paragraph{RISC: } Each instruction is 1 word long. All arguments must be in registers already.\n\\paragraph{CISC: } Each instruction can be $\\geq$ 1 word long. This enables more complex operations.\n\n\\section{Branching}\nSo far we have talked about \\textbf{straight line sequencing}. Instructions are executed in the exact order they are written. But what \nif we want to loop?\n\n\\begin{lstlisting}\n// Some computation\nBGT      R4, R5, LOOP      // Go to LOOP if R4 > R5\n// Stuff to be executed if R4 <= R5...\n\nLOOP:\n   // To be executed if R4 > R5\n\n// SIDE NOTE: This is how you use constants:\nSUBTRACT R2, R2, #1 // R2 = R2 - 1\n\\end{lstlisting}\n\n\\section{Addressing Modes}\n% So far we have used register modes ($R2$) and absolute modes ($#1$). \nA register holding the address of some information in memory is a \\textbf{pointer}. Using pointers is called \nthe \\textit{indirect addressing mode}. \n\\begin{lstlisting}\nLOAD     R2, R5         // Loads the stuff from the MEMORY ADDRESS that R5 holds into R2.\nMOVE     R2, R5         // Puts the IMMEDIATE VALUE held in R5 into R2.\nMOVE     R2, #300       // R2 = 300;\nCLEAR    R2             // CLEARS R2 to 0's.\n\nADD      R4, R0, #200   // R0 usually holds 0's. This what MOVE really does.\n\\end{lstlisting}\n\n\\paragraph{Index mode } of addressing is when you use an address register to hold the address of the first word in a list. \n\\begin{lstlisting}\n// Memory address is equal to some value X (let's say address #96 in memory) plus a register value at Ri \nX(Ri) // This is how you address that memory address.\n\\end{lstlisting}\n\n\\section{More on Assembly}\n\\begin{lstlisting}\nTWENTY   EQU   20 // Whenever the assembler sees `TWENTY' it will be replaced by 20.\n\nORIGIN   100      // Inser this at the beginning of a block to specify that code below should be placed in memory starting at address #100\n\nSUM   :  Reserve  4  // 4-byte space reserved @ address 100\nN     :  Dataword    // N = #150 @ address 204\nEnd // ends the program.\n\n%10110101 // how to specify numbers in binary \n0x5f      // hot to specify number in hex\n\\end{lstlisting}\n\n\\section{Stacks}\nSame common datastructure we ran into before in CSC190. Only one end can be read/added to, and it's LIFO (last in, first out).\n\n\\paragraph{The Stack Pointer (SP)} points to the address of the end of the stack (Processor stack). Common practice: stack grows in direction of \n\\textit{decreasing memory addresses}. \nThe push operation works as follows (pushing word in $R_i$):\n\\begin{lstlisting}\nSUB         SP, SP, #4     // Decrementing stack pointer by 4 bytes (1 word).\nSTORE       Ri, SP\n// Now the pop operator:\nLOAD        Ri, SP\nADD         SP, SP, #4\n\\end{lstlisting}\n\n\\section{Subroutines}\nSame as a function. Uses branching, but it knows that it has to return to where it was called from. We use the \\textbf{RETURN} command \nto return to the calling place. The address of the calling place is stored in the \\textbf{LINK REGISTER}.\n\n\\begin{lstlisting}\nCALL        FUNCNAME       // Stores current PROGRAM COUNTER in LINK REGISTER, branches to subroutine.\n// .. some code ..\nFUNCNAME: \n   // .. some code ..\n   RETURN                  // Branches back to address stored in LINK REGISTER\n\\end{lstlisting}\n\n\\subsection{Subroutine Nesting}\nIf you call a function in a function, the LINK REGISTER can only hold one address at a time. Since we need LIFO structure to \ntell us where to branch back to at each successive return, we use the \\textbf{PROCESSOR STACK} to store the further addresses.\n\n\\paragraph{Process for calling a nested function: }\n\\begin{enumerate}\n\\item Return address in LR $\\to$ PROCESSOR STACK @SP.\n\\item Store current address in LR and branch to the next function.\n\\item When you return from the nested function, transfer the original LR pointer back from PROCESSOR STACK @SP.\n\\item Return as normal to address in LR when you're done with the original subroutine.\n\\end{enumerate}\n\n\\subsection{Parameter Passing}\nThis can be done with registers or via the \\textbf{PROCESSOR STACK}. Here are the steps for the PROCESSOR STACK approach:\n\\begin{enumerate}\n\\item Push the arguments you want to pass to the stack in the caller.\n\\item Once in the subroutine, save the contents of current registers to the stack to preserve the state of the calling program.\n\\item Use an offset equal to the number of SAVED REGISTERS to access passed variables.\n\\item Carry out the subroutine.\n\\item Restore the disturbed registers from the stack (pop them off).\n\\item Branch back to the address of the caller and re-establish the SP to what it was originally.\n\\end{enumerate}\n\n\\subsection{Stack Frame}\n\\paragraph{Definition: } The Stack Frame is the space allocated to a subroutine when it is called. It is useful to \nhave a \\textbf{FRAME POINTER} that points to just above the PASSED PARAMETERS (unlike the STACK POINTER SP that points \nto the actual top of the stack that also holds the saved registers). \n\n\\paragraph{FRAME POINTER FP } is a constant for the duration of the subroutine program. It is equal to the STACK POINTER SP \nat the beginning of the subroutine call.\n\n\\section{Flags and Conditionals}\nYou pretty much always want to branch/call a subroutine on a conditional. Here's who they work:\n\\subsection{Comparisons}\n\\textbf{CMP R2, R1} lets you compare the values of two things. It performs the operation $R2 - R1$ and stores attributes of the result in global \\textbf{FLAGS}\n\\subsection{Flags}\nFlags are values you can use to branch. They store attributes of the previous comparison or operation.\n\\begin{enumerate}\n\\item $N$: If the result was negative.\n\\item $Z$: If the result was zero.\n\\item $C$: If the result of an unsigned operation overflows. \n\\item $V$: If the result of a signed operation overflows.\n\\end{enumerate}\n\nThe following Assembly directives make use of the previous comparison's flags:\n\\begin{enumerate}\n\\item $BEQ$: If the previous comparison yielded equality.\n\\item $BLT$: If the previous comparison yielded less than.\n\\item $BGT$: If the previous comparison yielded greater than.\n\\end{enumerate}\n\n\n\n\\chapter{IO Devices}\nYou access IO devices in the same way you might access regular registers. The \\textbf{device interface} gives you a few registers that \nallow you to communicate:\n\\begin{enumerate}\n\\item Data\n\\item Status\n\\item Control\n\\end{enumerate}\n\n\\section{Program Control IO}\nYou use a program called a \\textbf{Program Control Interface} to write and control an IO device. \n\nBecause the processor, input, and output devices may work at different rates, you need to wait for a response to any signal you \nsend to one to make sure it's ready for the next one. These are called \\textbf{STATUS FLAGS}, and reading them is called \\textbf{POLLING}. \n\n\n\\section{Interrupts}\nYou can use the infinite loop approach where you just keep POLLING the STATUS FLAG of an IO device until it's ready. That takes a lot of \ncompute power and you can't do anything during the wait time, which is a problem.\n\n\\paragraph{INTERRUPT SERVICE ROUTINE } is called by an interrupt signal from an IO device. Here is the processor's steps for dealing with one.\n\\begin{enumerate}\n\\item The processor finishes instruction $i$ that it is in the middle of.\n\\item The processor branches to the INTERRUPT ROUTINE. PC $\\to$ PROCESSOR STACK.\n\\item The INTERRUPT ROUTINE is executed.\n\\item The PC is restored from the PROCESSOR STACK.\n\\end{enumerate}\n\n\\subsection{Notes on SUBROUTINE INTERRUPT IMPLEMENTATION: } \nAt the beginning of the subroutine, the processor must send an \\textbf{INTERRUPT ACKNOWLEDGE} make sure that, when the subroutine RETURNS, \nan infinite loop does not occur. Alternatively, the successful execution of the subroutine can implicitly notify the IO device.\n\n\\paragraph{REGISTERS MUST BE RESTORED } because you don't know when the interrupt subroutine will be executed. It could be in the middle of another \nvery sensitive subroutine. \n\n\\subsection{Enable and Disabling Interrupts} \nSometimes you don't want to branch away from the main progam. Therefore, the processor has some STATUS REGISTERS PS that have a bit INTERRUPT INABLE IE \nthat, when set to 0, disable interrupts.\n\n\\textbf{You must set this } to 0 while inside the subroutine to avoid an infinite loop.. \n\n\\paragraph{IO MODE } bit in the control interface of the IO device can also allow you to set whether it sends interrupts or not.\n\n\\subsection{Process for a Single Device Interrupt Call}\n\\begin{enumerate}\n\\item Device raises interrupt\n\\item Processor branches to the interrupt subroutine\n\\item STATUS REGISTER PS is saved to the stack, along with the PROGRAM COUNTER PC.\n\\item STATUS REGISTER PS has INTERRUPT ENABLE IE that is set to 0. \n\\item Subroutine runs.\n\\item STATUS REGISTER PS is restored from the saved version. \n\\end{enumerate}\n\n\\section{Multiple Device Interrupts}\nThe above system works fine when you just have one interrupt at a time or one device performing the interrupts. \n\n\\subsection{Approach One: Naïve Polling}\nYou can just do the same thing as before, just executing the interrupts in the order you poll them if they happen to come at the same time. However, \npolling takes time.\n\n\\subsection{Vectored Inputs}\nIf you allow the interruptor to send a message along with their interrupt, you can have code in the processor that tells it how to \ninterpret the signal.\n\n\\paragraph{INTERRUPT VECTOR TABLE } is stored (usually in the lowest address range). The information in a vectored interrupt contains the \naddress of one of the vectors in that table. The contents of that vector in the table is the address of the interrupt subroutine.\n\n\\subsection{Interrupt Nesting}\nIf an interrupt comes in while executing another interrupt's subroutine, there's a chance that it will be of higher priority. Therefore, \nwe need an interrupt priority system.\n\n\\paragraph{PROCESSOR PRIORITY } is the priority of the current process. Only interrupts with a higher priority are executed. Priority is\ncommunicated in the interrupt vector. \n\n\\section{Processor Control Register}\nWe already know that the INTERRUPT ENABLE IE bit is in the PROCESSOR STATUS register which is one of the PROCESSOR CONTROL REGISTERS.\n\nIPS is where PS is saved automatically at the start of an interrupt. PS is autorestored from here at the end.\n\nIENABLE register enables device specific INTERRUPT ENABLE bits. \n\nIPENDING register shows which interrupts are active. \n\nSince all registers are 1 word long, you can generally have 32 IO devices. \n\nIn order to read and write from PROCESSOR CONTROL REGISTERS, you treat them like regular registers. \n\n\\chapter{Closing Remarks}\n\\section{Multiplexer Synethesis}\nYou can make any logical circuit out of a bunch of multiplexers. The naïve aproach is to have the actual inputs of the \nmultiplexer be constants and the selector inputs be your inputs to the function. \n\n\\paragraph{Shannon's Expansion } allows you to further simplify your naïve multiplexer layout:\n$$f(w_1, ... , w_n) = \\bar{w}_1\\cdot f(0, w_2, ..., w_n) + w_1 \\cdot f(1, w_2, ..., w_n)$$\n\n\\section{Timing Considerations for Flip Flop Circuits}\nWe need to know $F_{max}$, the maximum frequency at which we can run our clocks when using a flip flop.\n\n\\paragraph{Hold time violation } is \n\\paragraph{Timing parameters } \n\\begin{itemize}\n\\item $t_{su}$: \\textbf{Set up time} while data D must be stable for a D-latch or D-fip flop. \n\\item $t_h$: Data must stay stable during \\textbf{hold time}\n\\item $t_{cQ}$: Time from \\textbf{clock signal to Q} for a flip flop.\n\\end{itemize}\n\n\\paragraph{To get clock's $T_{min}$}, you add up the maximum required time for a signal to propagate through the circuit. \n\n\\subsection{Clock Skew}\nClock signal might not arrive at different flip flops at the same time. \n\n\\paragraph{$t_{skew}$} = time of arrival at sink - time of arrival at source.\n\nIf skew time is positive, you can have a higher $F_max$. Negative leads to lower $F_max$. \n\n\\subsection{Process for Timing Analysis}\n\\begin{enumerate}\n\\item Calculate longest path the signal must traverse during a clock cycle. $T_{min} \\geq T_{longest_path}$\n\\item Calculate hold time violation (which is the time the data must be constant for the latch to `save' the data). `'\n\\item Calculate time violation: \n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "8f9c1f1e16a2c350dc86e03c59c0af316efc6aaf", "size": 37560, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/ECE253.tex", "max_stars_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_stars_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2020-10-25T06:03:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-15T02:14:13.000Z", "max_issues_repo_path": "tex/ECE253.tex", "max_issues_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_issues_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/ECE253.tex", "max_forks_repo_name": "AdamCarnaffan/EngSci_Abridged", "max_forks_repo_head_hexsha": "de733823c493d35689cfcd846f87a47e0b05331c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-05-05T14:21:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-06T19:01:31.000Z", "avg_line_length": 35.8396946565, "max_line_length": 298, "alphanum_fraction": 0.713684771, "num_tokens": 10900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7931059462938815, "lm_q1q2_score": 0.4182178702713513}}
{"text": "\\documentclass[]{AVSSimReportMemo}\n\n\n\\newcommand{\\ModuleName}{LowPassFilterTorqueCommand}\n\\newcommand{\\subject}{Low Pass Module on ADCS Control Torque Command}\n\\newcommand{\\status}{Initial documentation.}\n\\newcommand{\\preparer}{H. Schaub}\n\\newcommand{\\summary}{This module provides a low-pass filter that operates on the ADCS control torque vector.     }\n\n\n\\begin{document}\n\n\n\\makeCover\n\n\n%\n%\tenter the revision documentation here\n%\tto add more lines, copy the table entry and the \\hline, and paste after the current entry.\n%\n\\pagestyle{empty}\n{\\renewcommand{\\arraystretch}{2}\n\\noindent\n\\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}\n\\hline\n{\\bfseries Rev}: & {\\bfseries Change Description} & {\\bfseries By} \\\\\n\\hline\nDraft & Initial Documenation & H. Schaub \\\\\n\\hline\n\n\\end{longtable}\n}\n\n\\newpage\n\\setcounter{page}{1}\n\\pagestyle{fancy}\n\n\\tableofcontents\n~\\\\ \\hrule ~\\\\\n\n\\section{Introduction}\nA low-pass filter module provides the ability to apply a frequency based filter to the ADCS control torque vector $\\bm L_{r}$.  The module has the ability to be individually reset, separate from any reset on the ADCS control modules.  The cut-off frequency is given by $\\omega_{c}$, while the filter time step is given by $h$.  \n\n\\section{Initialization}\nPrior to using the module, the filter time step and 1st order filter frequency cut-off value must be set.\n\\begin{gather*}\n{\\tt Config->h} \\\\\n {\\tt Config->wc} \n\\end{gather*}\n\n\\section{Algorithm}\nSince the shown mappings between the Laplace domain and the $Z$-domain \nare approximate, some frequency warping will occur.  If a continuous \nfilter design has a critical frequency $\\omega_{c}$, then the digital \nimplementation might have a slightly different critical frequency.  \nFranklin in Reference~\\citenum{franklin1} compares the continuous and \ndigital filter performances by studying the half-power point.  This \nleads to the following relationship between the continuous time \ncritical filter frequency $\\omega_{c}$ and the digital filter \nfrequency $\\hat\\omega$:\n\\begin{equation}\n\t\\label{eq:wa}\n\t\\tan \\left(\\frac{ w_{c} h}{2}\\right) = \\frac{\\hat\\omega h}{2}\n\\end{equation}\nwhere $h=1/f$ is the digital sample time.  Note that $\\hat\\omega \\approx \n\\omega_{c}$ if the sample frequency is much higher than the critical \nfilter frequency. \n\nThe first-order digital filter formula is given by:\n\\begin{equation}\n\t\ty_{k} = \\frac{1}{2+h \\omega_{c}}\n\t\t\\Big[\n\t\ty_{k-1} (2-h \\omega_{c})  + h \\omega_{c} (x_{k} + x_{k-1})\n\t\t\\Big]\n\\end{equation}\nwhere $x_{k}$ is the current filter input, and $y_{k}$ is the filtered output.\n\n\n\\section{Output}\nThe filter module outputs the standard ADCS control torque output structure.  If the original and filtered ADCS control is to be tracked, then the messages should be given unique names.\n\n\n\\bibliographystyle{unsrt}\n\\bibliography{references}\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "65d05e37d7fedfed750cd6eb1e63f876c7e99f74", "size": 2847, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/fswAlgorithms/attControl/lowPassFilterTorqueCommand/_Documentation/AVS-Sim-LowPassFilterControlTorque-20160108.tex", "max_stars_repo_name": "ian-cooke/basilisk_mag", "max_stars_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/fswAlgorithms/attControl/lowPassFilterTorqueCommand/_Documentation/AVS-Sim-LowPassFilterControlTorque-20160108.tex", "max_issues_repo_name": "ian-cooke/basilisk_mag", "max_issues_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-13T20:52:22.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T20:52:22.000Z", "max_forks_repo_path": "src/fswAlgorithms/attControl/lowPassFilterTorqueCommand/_Documentation/AVS-Sim-LowPassFilterControlTorque-20160108.tex", "max_forks_repo_name": "ian-cooke/basilisk_mag", "max_forks_repo_head_hexsha": "a8b1e37c31c1287549d6fd4d71fcaa35b6fc3f14", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6333333333, "max_line_length": 328, "alphanum_fraction": 0.7432384967, "num_tokens": 782, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788308, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4181499210084444}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[english]{babel} % for hyphenation dictionary\n%\\setdefaultlanguage{english} % polyglossia command for use with XeTeX / LuaTeX\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n% title information\n\\title{Phys 221A -- Quantum Mechanics -- Lec11}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{10}{11}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{More on Path Integrals}\n\nAside: Turns out Yaroslav was wrong about Feynman and Schwinger being perfect prodigies. Feynman wanted to go to Columbia but couldn't get in, went to MIT instead. But they both ended up sharing the Nobel prize, which is funny? Anyway...\n\nSo the propagator $K(\\v r, t; \\v r', t')$ basically tells us all the information we want to know about the system, since\n\\begin{eqn}\n\\psi(\\v r, t) = \\int \\dif^3{r'} K(\\v r, t; \\v r, t') \\psi(\\v r', t').\n\\end{eqn}\nLast time we started breaking up the propagator into multiple integrals \n\\begin{eqn}\nK(\\v r, t; \\v r', t') = \\int \\dif^3{r''} \\cdots \\dif^3{r^{(n)}} \\braket{\\v r,t}{\\v r^{(n)},t^{(n)}} \\cdots \\braket{\\v r'', t''}{\\v r', t'}\n\\end{eqn}\nfor $t' < t'' < \\dots < t^{(n)} < t$. We will take \n\\begin{eqn}\nt^{(\\ell+1)} - t^{(\\ell)} = \\frac{t-t'}{n} \\equiv \\delta,\n\\end{eqn}\nwhere for convenience we denote $t^{(n+1)} = t$. If we write\n\\begin{eqn}\nK_\\ell = \\braket{\\v r^{(\\ell+1)}, t^{(\\ell+1)}}{\\v r^{(\\ell)}, t^{(\\ell)}}\n\\end{eqn}\nthen we can think of the propagator as an integral\n\\begin{eqn}\nK(\\v r, t; \\v r', t') = \\int \\mathcal{D}[\\v r] I[\\v r], \\qquad\nI = K_1 K_2 \\cdots K_n.\n\\end{eqn}\nFurthermore note that when $n$ is large, we can make the approximation\n\\begin{eqn}\n\\vd r_\\ell = \\frac{\\v r^{(\\ell+1)} - \\v r^{(\\ell)}}{\\delta}.\n\\end{eqn}\n\nRecall the propagator for a free particle, which we derived last time (in 1D, here in 3D),\n\\begin{eqn}\nK_0(\\v r, t; \\v r', t') = \\left( \\frac{m}{2\\pi i \\hbar (t-t')} \\right)^{3/2} \\exp \\left[ \\frac{im(\\v r - \\v r')^2}{2\\hbar (t-t')} \\right]. \n\\end{eqn}\nWe will use this to derive a general expression for the path integral. For the general propagator, we have\n\\begin{eqn}\nK(\\v r, t; \\v r', t') = \\matrixel{\\v r}{U(t,t')}{\\v r'},\n\\end{eqn}\nwhere the time evolution operator is given by\n\\begin{eqn}\nU(t,t') = e^{-iH(t-t') / \\hbar} = \\exp \\cbr{ -\\frac{i}{\\hbar} \\left[ \\frac{p^2}{2m} (t-t') + V(\\v r) (t-t') \\right]}.\n\\end{eqn}\nMaking the appropriate approximations (skipping a few steps here), we find\n\\begin{eqn}\nK(\\v r, t; \\v r', t') \\approx K_0(\\v r, t; \\v r', t') e^{-\\frac{i}{\\hbar} V(\\v r) (t-t')}.\n\\end{eqn}\nIn the limit $n \\rightarrow \\infty$ we have\n\\begin{eqn}\nK_\\ell \\approx \\left( \\frac{m}{2\\pi i \\hbar \\delta} \\right)^{3/2} \\exp \\cbr{ \\frac{i}{\\hbar} \\left[ \\frac{1}{2} m \\vd r_\\ell^2 - V(\\bar{\\v r}_\\ell, \\bar t_\\ell) \\right] } \\delta \n\t= \\left( \\frac{m}{2\\pi i \\hbar \\delta} \\right)^{3/2} e^{\\frac{i}{\\hbar} S_\\ell}.\n\\end{eqn}\nwhere\n\\begin{eqn}\n\\bar{\\v r}_\\ell = \\frac{1}{2} (\\v r^{(\\ell+1)} + \\v r^{(\\ell)}), \\qquad\n\\bar t_\\ell = \\frac{1}{2} (t^{(\\ell+1)} + t^{\\ell}).\n\\end{eqn}\nThen in the limit $n \\rightarrow \\infty$ the full propagator becomes\n\\begin{align}\nK(\\v r, t; \\v r', t') &= \\lim_{n \\rightarrow \\infty} \\int \\dif^3{r''} \\cdot \\dif^3{r^{(n)}} \\, K_1 \\cdots K_n \\\\\n\t&= \\lim_{n \\rightarrow \\infty} \\int \\left( \\frac{m}{2\\pi i \\hbar \\delta} \\right)^{3n/2} \\dif^3{r''} \\cdots \\dif^3{r^{(n)}} \\, e^{(i / \\hbar) (S_1 + \\dots + S_n)} \\\\\n\t&= \\int_{\\v r(t)}^{\\v r'(t')} \\mathcal{D} [\\v r(t)] e^{i S[\\v r(t)] / \\hbar},\n\\end{align}\nwhere our new measure is\n\\begin{eqn}\n\\mathcal{D}[\\v r(t)] = \\lim_{n \\rightarrow \\infty} \\left( \\frac{m}{2\\pi i \\hbar \\delta} \\right)^{3n/2} \\dif^3{r''} \\cdots \\dif^3{r^{(n)}}\n\\end{eqn}\nand the full action is just\n\\begin{eqn}\nS[\\v r(t)] = \\sum_{n=0}^\\infty S_n = \\int_t^{t'} \\dif{t''} L(\\v r, \\vd r, t''), \\qquad\nL(\\v r, \\vd r, t) = \\frac{1}{2} m \\vd r^2 - V(\\v r, t).\n\\end{eqn}\n\nClassically, the principle of least action (really extremal action), also called Hamilton's principle, tells us that the classical trajectory is the one which extremizes the action. Quantum mechanically, we find a similar principle holds, only instead we need to sum over all paths, and we find that paths nearest the classical trajectory hold the greatest weight in this sum. Since $\\hbar$ is so darn small, for macroscopic events we find that the nearly-classical paths interfere constructively and we just reproduce Hamilton's principle. In fact, one can show that if we take $\\hbar \\rightarrow 0$, we precisely reproduce classical mechanics because all non-classical paths interfere destructively. It's only for very small-scale events that non-classical paths becomes important. \n\nWhen $\\hbar$ is small, we can employ the saddle-point approximation or SPA as follows. Suppose we have an integral\n\\begin{eqn}\nI(h) = \\int_{-\\infty}^\\infty \\dif{x} \\, e^{i x^2 / h} f(x)\n\\end{eqn}\nwith some function $f(x)$. When $h \\rightarrow 0$ we can use the limit\n\\begin{eqn}\n\\lim_{h \\rightarrow 0} \\frac{e^{i x^2 / h}}{\\sqrt{i\\pi \\hbar}} = \\delta(x)\n\\end{eqn}\nto show that \n\\begin{eqn}\n\\lim_{h \\rightarrow 0} I(h) = f(0).\n\\end{eqn}\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "ed4eedfe33d2982783112488eb0488096b40c878", "size": 5318, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quantum/lec11.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "quantum/lec11.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quantum/lec11.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.649122807, "max_line_length": 784, "alphanum_fraction": 0.6421587063, "num_tokens": 2000, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.418149912927306}}
{"text": "\\section{Simulations}\n\nA comprehensive set of subroutines required to compute and evaluate the transfer\nfunctions    outlined    in    this    report    can     be     obtained    from\nGitHub\\cite{ref:TheComet93}.\n\nThe subroutines are located in the folder \\textit{matlab/mfunctions}, along with\nvarious utility functions. The folder must be appended to MATLAB's path like so:\n\n\\begin{lstlisting}\naddpath([pwd,'/mfunctions']);\n\\end{lstlisting}\n\nThis section provides a short overview  of  what  each  subroutine does and how.\n\n\n\\subsubsection*{Pre-processing}\n\nTypically, the  input  data is never perfect. It might contain noise or it might\nnot have equispaced time values. The function \\textit{preprocess\\_curve} returns\nequispaced time values and smooths the signal.\n\n\\begin{lstlisting}\n% Smooth input data and generate equispaced\n% time vector\n[x, y] = preprocess_curve(xr, yr);\n\\end{lstlisting}\n\nThis is achieved  by  using a combination of MATLAB's \\textit{smooth()} function\nand a custom sliding average  function  to  smooth the beginning and ends of the\nsignal.\n\n\n\\subsubsection*{Characterising the curve}\n\nWith the data prepared (preprocessed), it is now possible to calculate $T_u/T_g$\nor $t_{10}$, $t_{50}$, $t_{90}$, depending on  what  you  wish  to  do next. The\nfunction \\textit{characterise\\_curve()}  can handle both cases for you, like so:\n\n\\begin{lstlisting}\n% Characterises the curve, either using\n% Hudzovic's method or Sani's method.\n[Tu, Tg] = characterise_curve(x, y);\n[t10, t50, t90] = characterise_curve(x, y);\n\\end{lstlisting}\n\nDetermining $T_u$, $T_g$ is achieved by calculating  the  derivative of the data\nto  find  the  point  of  inflection.  The maximum and minimum of the signal  is\ndetermined  by  taking  the  value  of  the  first  and  last  element  in  $y$.\n\nDetermining   $t_{10}$,  $t_{50}$,  $t_{90}$  is  achieved  by  using   MATLAB's\n\\textit{spline()}  function for higher accuracy and  intersecting  the  data  at\n10\\%, 50\\% and 90\\% amplitude.  In  the  case of noisy input data, if the spline\nfails, the fallback method is to simply find the nearest point. The minimum  and\nmaximum of the  input  signal  is  again  determined by using the first and last\nelement in $y$.\n\nBecause L. Sani's approach heavily relies  on  accurately  determining the start\nand  end  values  of  the input step response function, and it  was  found  that\nnoisier input  signals  would  significantly  throw  off  correctly  determining\n$t_{10}$,  $t_{50}$,  $t_{90}$, it is possible to override the  default  min/max\nvalues by passing in a third argument:\n\n\\begin{lstlisting}\n% Override Sani's min/max.\nymax = 37;  % Step function stops at 37\nymin = 15;  % Step function starts at 15\n[t10, t50, t90] = characterise_curve(x, y, [ymin, ymax]);\n\\end{lstlisting}\n\nThe third argument is only valid for L. Sani's method.\n\nIn the case  of  noisy  signals, it is usually better to determine the beginning\nand end values of the step response function manually.\n\n\n\\subsubsection*{Calculating T, r and n}\n\nWith  $T_u$,  $T_g$  or  $t_{10}$,  $t_{50}$,  $t_{90}$  determined,  the  three\nconstants $T$, $r$ and $n$ can be calculated using  either  P.  Hudzovic's or L.\nSani's  transfer function (equations \\ref{eq:hudzovic}  or  \\ref{eq:sani}).  For\nthis, the two functions  \\textit{sani\\_lookup()} and \\textit{hudzovic\\_lookup()}\nmay be used.\n\nBoth  of these functions accept either $T_u/T_g$ or $t_{10}$, $t_{50}$, $t_{90}$\nas parameters. Depending  on  which  one  you  choose  to use, the function will\nperform a different lookup:\n\n\\begin{lstlisting}\n% Hudzovic method, Sani method, and their permutations\n[T, r, n] = hudzovic_lookup(Tu, Tg);\n[T, r, n] = hudzovic_lookup(t10, t50, t90);\n[T, r, n] = sani_lookup(t10, t50, t90);\n[T, r, n] = sani_lookup(Tu, Tg);\n\\end{lstlisting}\n\nNote how it's  also  possible  to  use the $t_{10}$, $t_{50}$, $t_{90}$ approach\nwith  Hudzovic's method,  and  similarly,  use  $T_u/T_g$  with  Sani's  method.\n\nWhen  calling  these  functions  for  the  first time, they will spend some time\ngenerating  the  lookup  curves  discussed in the theory section. This can  take\nabout a minute. They are saved to  disk  and  loaded  again if available, so all\nsubsequent calls will be fast.\n\nThe  \\textit{sani\\_lookup()}  function  will  use  the   interpolation  formulae\n(equation  \\ref{eq:sani_interpolation})   when   passing   $t_{10}$,   $t_{50}$,\n$t_{90}$.   All  other  combinations   will   have   to   use   lookup   curves.\n\n\n\\subsubsection*{Calculating the Transfer Function}\n\nOnce    $T$,    $r$    and    $n$    are    obtained,    the    two    functions\n\\textit{hudzovic\\_transfer\\_function()}  and \\textit{sani\\_transfer\\_function()}\nwill help  convert  those  three  constants into a continuous transfer function:\n\n\\begin{lstlisting}\n% Calculating the transfer functions\nG_hudzovic = hudzovic_transfer_function(T, r, n);\nG_sani = sani_transfer_function(T, r, n);\n\\end{lstlisting}\n\nOf  course,  if  the  parameters  $T$,  $r$   and   $n$  were  determined  using\n\\textit{sani\\_lookup()} then  the  function  \\textit{sani\\_transfer\\_function()}\nmust be used. The same is true for Hudzovic.\n\nOnce the transfer function is obtained,  one can view the step response by using\n\\textit{step()}:\n\n\\begin{lstlisting}\n% Plot step response\n[g, t] = step(G_hudzovic);\nplot(t, g);\n\\end{lstlisting}\n\n\n\\subsubsection*{Fitting}\n\nSo  far,  the  typical  work-flow  for  calculating  the transfer function looks\nsomewhat like the following code:\n\n\\begin{lstlisting}\n% Hudzovic, Tu/Tg\n[Tu, Tg] = characterise_curve(x, y);\n[T, r, order] = hudzovic_lookup(Tu, Tg);\nG = hudzovic_transfer_function(T, r, order);\n\\end{lstlisting}\n\nTo  further  refine  the result, it is possible to perform a least squares curve\nfit  on  a  result  obtained  by  either  method  using   the  \\textbf{original}\n(non-smoothed)   data.    This    can    be    achieved   with   the   functions\n\\textit{hudzovic\\_fit()} and \\textit{sani\\_fit()}.\n\n\\begin{lstlisting}\n% Hudzovic, Tu/Tg, with fitting\n[Tu, Tg] = characterise_curve(x, y);\n[T, r, n] = hudzovic_lookup(Tu, Tg);\n[T, r] = hudzovic_fit(T, r, n, xr, yr);\nG = hudzovic_transfer_function(T, r, order);\n\\end{lstlisting}\n\nHere,  \\textit{xr},  \\textit{yr}  contain  the  ``raw''  data,  and  \\textit{x},\n\\textit{y} contain the pre-processed (smoothed) data.\n\nSimilarly, it is  possible  to  further  refine  a  result obtained by L. Sani's\nmethod using the function \\textit{sani\\_fit()}:\n\n\\begin{lstlisting}\n% Hudzovic, Tu/Tg, with fitting\n[t10, t50, t90] = characterise_curve(x, y);\n[T, r, n] = sani_lookup(t10, t50, t90);\n[T, r] = sani_fit(T, r, n, xr, yr);\nG = sani_transfer_function(T, r, order);\n\\end{lstlisting}\n\nThe fit is currently not  able  to determine the required order by itself, so it\nis necessary to first call \\textit{characterise\\_curve()} on  the  smoothed data\nto retrieve the order. A nice  side  effect  of  doing this is it also gives you\ngood starting values for $T$ and $r$. This  avoids  the  possibility  of falling\ninto a local minimum while fitting the data.\n\n\\input{sections/simulations/image_import}\n\n", "meta": {"hexsha": "2649e62add51deea863bfa944136f8dc28beb4f6", "size": 7101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "versuche/mlab/sections/simulations.tex", "max_stars_repo_name": "TheComet93/laborjournal", "max_stars_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_stars_repo_licenses": ["WTFPL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "versuche/mlab/sections/simulations.tex", "max_issues_repo_name": "TheComet93/laborjournal", "max_issues_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_issues_repo_licenses": ["WTFPL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "versuche/mlab/sections/simulations.tex", "max_forks_repo_name": "TheComet93/laborjournal", "max_forks_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_forks_repo_licenses": ["WTFPL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8032786885, "max_line_length": 80, "alphanum_fraction": 0.7149697226, "num_tokens": 2156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.418149912927306}}
{"text": "%  qd.tex\n%  \n%  This work was supported by the Director, Office of Science, Division\n%  of Mathematical, Information, and Computational Sciences of the\n%  U.S. Department of Energy under contract number DE-AC03-76SF00098.\n%\n%  (C) September 2000-2004\n\\documentclass[11pt]{article}\n\\usepackage{graphicx}\n\\usepackage{amsthm}\n\n\\pagestyle{plain}\n\n\\setlength{\\textwidth}{6.5in}\n\\setlength{\\textheight}{8.5in}\n\\setlength{\\topmargin}{-0.2in}\n\\setlength{\\oddsidemargin}{0.0in}\n\\setlength{\\evensidemargin}{0.0in}\n\n% All thm/def/lem/etc... have same numbering\n\\newtheorem{thm}{Theorem}\n\\newtheorem{defn}[thm]{Definition}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\n\\theoremstyle{definition}\n\\newtheorem{alg}[thm]{Algorithm}\n\n\\newcommand{\\round}{\\mathrm{round}}\n\\newcommand{\\fl}{\\mathrm{fl}}\n\\newcommand{\\err}{\\mathrm{err}}\n\\newcommand{\\ulp}{\\mathrm{ulp}}\n\\newcommand{\\hi}{\\mathrm{hi}}\n\\newcommand{\\lo}{\\mathrm{lo}}\n\\newcommand{\\eps}{\\varepsilon}\n\\newcommand{\\epsqd}{\\varepsilon_\\mathrm{qd}}\n\n\n\\title{Library for Double-Double and Quad-Double Arithmetic\\footnotemark[1]}\n\\author{Yozo Hida\\footnotemark[2] \\and Xiaoye S. Li\\footnotemark[3]\n  \\and David H. Bailey\\footnotemark[3]}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n% change foot note symbols\n\\renewcommand{\\thefootnote}{\\fnsymbol{footnote}}\n\n\\footnotetext[1]{This research was supported by the Director, \n  Office of Science, Division of Mathematical, Information, and\n  Computational Sciences of the U.S. Department of Energy under \n  contract number DE-AC03-76SF00098.}\n\\footnotetext[2]{Computer Science Division, University of California, \n  Berkeley, CA 94720 ({\\tt yozo@cs.berkeley.edu}).}\n\\footnotetext[3]{NERSC, Lawrence Berkeley National Laboratory, 1 Cycloton Rd, \n  Berkeley, CA 94720 ({\\tt xiaoye@nersc.gov}, {\\tt dhbailey@lbl.gov}).}\n\n% change footnote symbols back to numbers\n\\renewcommand{\\thefootnote}{\\arabic{footnote}}\n\n\\vspace{1cm}\n\\begin{abstract}\n  A double-double number is an unevaluated sum of two IEEE double \n  precision numbers, capable of representing at least 106 bits of \n  significand.   Similarly, a quad-double number is an unevaluated sum of \n  four IEEE double precision numbers, capable of representing at least \n  212 bits of significand.  Algorithms for various arithmetic operations \n  (including the four basic operations and various algebraic and \n  transcendental operations) are presented. A C++ implementation of \n  these algorithms is also described, along with its C and Fortran \n  interfaces.  Performance of the library is also discussed.\n\\end{abstract}\n\n\\newpage\n\\tableofcontents\n\\newpage\n\n\\section{Introduction} \\label{sec:intro}\nMultiprecision computation has a variety of application areas, such as\npure mathematics, study of mathematical constants, cryptography,\nand computational geometry. Because of this, many arbitrary precision \nalgorithms and libraries have been developed using only the fixed\nprecision arithmetic. They can be divided into two groups based on\nthe way precision numbers are represented. Some libraries store numbers in a\n{\\em multiple-digit} format, with a sequence of digits coupled with a \nsingle exponent, such as the symbolic computation package\nMathematica, Bailey's MPFUN~\\cite{bai-mp}, Brent's MP~\\cite{brent} and\nGNU MP~\\cite{gnu-mp}.  An alternative approach is to store numbers\nin a {\\em multiple-component} format, where a number is expressed\nas unevaluated sums of ordinary floating-point words, each with its own\nsignificand and exponent.  Examples of this format \ninclude~\\cite{dek71,pri92,she97}.  The multiple-digit approach can \nrepresent a much larger range of numbers, whereas the multiple-component \napproach has the advantage in speed.\n\nWe note that many applications would get full benefit from using merely\na small multiple of (such as twice or quadruple) the working precision,\nwithout the need for arbitrary precision.\nThe algorithms for this kind of ``fixed'' precision can be made\nsignificantly faster than those for arbitrary precision.\nBailey~\\cite{bai-dd} and Briggs~\\cite{kbriggs97} have developed\nalgorithms and software for ``double-double'' precision, twice the \ndouble precision. They used the multiple-component format, where a \ndouble-double number is represented as an unevaluated\nsum of a leading double and a trailing double.\n\nIn this paper we present the algorithms used in the {\\tt qd} library, \nwhich implements both double-double and quad-double arithmetic.\nA quad-double number is an unevaluated sum of four IEEE doubles.\nThe quad-double number $(a_0, a_1, a_2, a_3)$ represents the exact\nsum $a = a_0 + a_1 + a_2 + a_3$, where $a_0$ is the most sigficant component.\nWe have designed and implemented algorithms for basic arithmetic\noperations, as well as some algebraic and transcendental functions.\nWe have performed extensive correctness tests and compared the results \nwith arbitrary precision package MPFUN.\nOur quad-precision library is available at\n{\\tt http://www.nersc.gov/\\~{ }dhbailey/mpdist/mpdist.html}.\nOur quad-double library has been successfully integrated into a parallel \nvortex roll-up simulation code; this is briefly described in\n\\cite{hida00}.  \n\nThe rest of the paper is organized as follows.\nSection~\\ref{sec:prelim} describes some basic properties of IEEE\nfloating point arithmetic and building blocks for our quad-double\nalgorithms. In Section~\\ref{sec:basic} we present the quad-double\nalgorithms for basic operations, including renormization, addition,\nmultiplication and division.\nSection~\\ref{sec:algebraic} and~\\ref{sec:transcendental}\npresent the algorithms for some algebraic operations and transcendental\nfunctions. Section~\\ref{sec:misc} describes some auxiliary functions.\nSection~\\ref{sec:implement} briefly describes our C++ library \nimplementing the above algorithms.\nSection~\\ref{sec:performance} presents the timing results of the\nkernel operations on different architectures.\nSection~\\ref{sec:future} discusses future work.\n\n\\section{Preliminaries} \\label{sec:prelim}\nIn this section, we present some basic properties and algorithms of IEEE \nfloating point arithmetic used in quad-double arithmetic.\nThese results are based on Dekker \\cite{dek71}, Knuth \\cite{knu81}, \nPriest \\cite{pri92}, Shewchuk \\cite{she97}, and others.  In fact, \nmany of the algorithms and diagrams are directly taken from, or based on, \nShewchuk's paper.\n\nAll basic arithmetics are assumed to be performed in IEEE double format, \nwith round-to-even rounding on ties.  For any binary operator \n$\\cdot \\in \\{+, -, \\times, /\\}$, we use $\\fl(a \\cdot b) = a \\odot b$ to denote\nthe floating point result of $a \\cdot b$, and define $\\err(a \\cdot b)$\nas $a \\cdot b = \\fl(a \\cdot b) + \\err(a \\cdot b)$.\nThroughout this paper, $\\eps = 2^{-53}$ is the machine epsilon for\nIEEE double precision numbers, and $\\epsqd = 2^{-211}$ is\nthe precision one expects for quad-double numbers.\n\n\\begin{lem} {\\rm \\cite[p. 310]{she97}}\n  Let $a$ and $b$ be two $p$-bit floating point numbers such that\n  $|a| \\ge |b|$.  Then $|\\err(a+b)| \\le |b| \\le |a|$.\n\\end{lem}\n\n\\begin{lem} {\\rm \\cite[p. 311]{she97}}\n  Let $a$ and $b$ be two $p$-bit floating point numbers.  Then\n  $\\err(a+b) = (a + b) - \\fl(a+b)$ is representable as a $p$-bit\n  floating point number.\n\\end{lem}\n\n\\begin{alg} \\cite[p. 312]{she97}\n  The following algorithm computes $s = \\fl(a+b)$ and $e = \\err(a+b)$, \n  assuming $|a| \\ge |b|$.\n\n  \\vspace{0.1in}\n  \\hfill\n  \\begin{minipage}[t]{4in}\n    {\\sc Quick-Two-Sum}($a, b$) \\\\\n    \\begin{tabular}{rl}\n      1. & $s \\leftarrow a \\oplus b$ \\\\\n      2. & $e \\leftarrow b \\ominus (s \\ominus a)$ \\\\\n      3. & {\\bf return} $(s, e)$\n    \\end{tabular}\n  \\end{minipage}\n\\end{alg}\n\n\\begin{alg} \\cite[p. 314]{she97}\n  The following algorithm computes $s = \\fl(a+b)$ and $e = \\err(a+b)$.\n  This algorithm uses three more floating point operations instead of\n  a branch.\n\n  \\vspace{0.1in}\n  \\hfill\n  \\begin{minipage}[t]{4in}\n    {\\sc Two-Sum}($a, b$) \\\\\n    \\begin{tabular}{rl}\n      1. & $s \\leftarrow a \\oplus b$ \\\\\n      2. & $v \\leftarrow s \\ominus a$ \\\\\n      3. & $e \\leftarrow (a \\ominus (s \\ominus v)) \\oplus (b \\ominus v)$ \\\\\n      4. & {\\bf return} $(s, e)$\n    \\end{tabular}\n  \\end{minipage}\n\\end{alg}\n\n\\begin{alg} \\cite[p. 325]{she97}\n  The following algorithm splits a 53-bit IEEE double precision\n  floating point number into $a_{\\hi}$ and $a_{\\lo}$, each with 26 bits of \n  significand, such that $a = a_\\hi + a_\\lo$.  $a_\\hi$ will contain \n  the first $26$ bits, while $a_\\lo$ will contain the lower $26$ bits.\n\n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{4in}\n    {\\sc Split}($a$) \\\\\n    \\begin{tabular}{rl}\n      1. & $t \\leftarrow (2^{27}+1) \\otimes a$ \\\\\n      2. & $a_\\hi \\leftarrow t \\ominus (t \\ominus a)$ \\\\\n      3. & $a_\\lo \\leftarrow a \\ominus a_\\hi$ \\\\\n      4. & {\\bf return} $(a_\\hi, a_\\lo)$\n    \\end{tabular}\n  \\end{minipage}\n\\end{alg}\n\n\\begin{alg} \\cite[p. 326]{she97}\n  The following algorithm computes $p = \\fl(a \\times b)$ and \n  $e = \\err(a \\times b)$.\n\n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{5in}\n    {\\sc Two-Prod}($a, b$) \\\\\n    \\begin{tabular}{rl}\n      1. & $p \\leftarrow a \\otimes b$ \\\\\n      2. & $(a_\\hi, a_\\lo) \\leftarrow$ {\\sc Split}($a$) \\\\\n      3. & $(b_\\hi, b_\\lo) \\leftarrow$ {\\sc Split}($b$) \\\\\n      4. & $e \\leftarrow ((a_\\hi \\otimes b_\\hi \\ominus p) \\oplus\n             a_\\hi \\otimes b_\\lo \\oplus a_\\lo \\otimes b_\\hi) \\oplus\n             a_\\lo \\otimes b_\\lo$  \\\\\n      5. & {\\bf return} $(p, e)$\n    \\end{tabular}\n  \\end{minipage}  \n\\end{alg}\n\nSome machines have a fused multiply-add instruction (FMA) that\ncan evaluate expression such as $a \\times b \\pm c$ with a single \nrounding error.  We can take advantage of this instruction to compute\nexact product of two floating point numbers much faster.  These \nmachines include IBM Power series (including the PowerPC), on which\nthis simplification is tested.\n\n\\begin{alg}\n  The following algorithm computes $p = \\fl(a \\times b)$ and \n  $e = \\err(a \\times b)$ on a machine with a FMA instruction.\n  Note that some compilers emit FMA instructions for\n  $a \\times b + c$ but not for $a \\times b - c$; in this case, some\n  sign adjustments must be made.\n  \n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{4in}\n    {\\sc Two-Prod-FMA}($a, b$) \\\\\n    \\begin{tabular}{rl}\n      1. & $p \\leftarrow a \\otimes b$ \\\\\n      2. & $e \\leftarrow \\fl(a \\times b - p)$ \\\\\n      3. & {\\bf return} ($p, e$)\n    \\end{tabular}\n  \\end{minipage}\n\\end{alg}\n\nThe algorithms presented are the basic building blocks of quad-double\narithmetic, and are represented in Figures \\ref{quick_two_sum_fig}, \n\\ref{two_sum_fig}, and \\ref{two_prod_fig}.  Symbols for normal \ndouble precision sum and product are in Figure~\\ref{normal_sum_prod_fig}.\n\n\\begin{figure}\n  \\hfill\n  \\begin{minipage}[t]{2in}\n    \\begin{center}\n      \\includegraphics{quick-two-sum.eps}\n      \\caption{\\label{quick_two_sum_fig}{\\sc Quick-Two-Sum}}\n    \\end{center}\n  \\end{minipage}\n  \\begin{minipage}[t]{2in}\n    \\begin{center}\n      \\includegraphics{two-sum.eps}\n      \\caption{\\label{two_sum_fig}{\\sc Two-Sum}}\n    \\end{center}\n  \\end{minipage}\n  \\begin{minipage}[t]{2in}\n    \\begin{center}\n      \\includegraphics{two-prod.eps}\n      \\caption{\\label{two_prod_fig}{\\sc Two-Prod}}\n    \\end{center}\n  \\end{minipage}\n\\end{figure}\n\n\\begin{figure}\n  \\begin{center}\n    \\includegraphics{normal_sum_prod.eps}\n    \\caption{\\label{normal_sum_prod_fig}Normal IEEE double precision sum and product}\n  \\end{center}\n\\end{figure}\n\n\\section{Basic Operations} \\label{sec:basic}\n\\subsection{Renormalization}\nA quad-double number is an unevaluated sum of four IEEE double numbers.\nThe quad-double number $(a_0, a_1, a_2, a_3)$ represents the exact\nsum $a = a_0 + a_1 + a_2 + a_3$.  Note that for any given representable\nnumber $x$, there can be many representations as an unevaluated sum of\nfour doubles.  Hence we require that the quadruple $(a_0, a_1, a_2, a_3)$\nto satisfy\n\\begin{displaymath}\n  |a_{i+1}| \\le \\frac{1}{2}\\ulp(a_i)  \n\\end{displaymath}\nfor $i = 0, 1, 2$, with equality occurring only if $a_i = 0$ or \nthe last bit of $a_i$ is $0$ (that is, round-to-even is used in case\nof ties).  Note that the first double $a_0$ is a double-precision\napproximation to the quad-double number $a$, accurate to almost\nhalf an ulp.\n\n\\begin{lem}\n  For any quad-double number $a = (a_0, a_1, a_2, a_3)$, the normalized \n  representation is unique.\n\\end{lem}\n\nMost of the algorithms described here produce an expansion that\nis not of canonical form -- often having overlapping bits.  \nTherefore, a five-term expansion is produced, and then renormalized\nto four components.\n\n\\begin{alg}\n  \\label{renorm_alg}\n  This renormalization procedure is a variant of Priest's renormalization\n  method \\cite[p. 116]{pri92}.  The input is a five-term expansion with \n  limited overlapping bits, with $a_0$ being the most significant component.  \n\n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{5in}\n    {\\sc Renormalize}($a_0, a_1, a_2, a_3, a_4$) \\\\\n    \\begin{tabular}{rl}\n      1.  & $(s, t_4) \\leftarrow$ {\\sc Quick-Two-Sum}($a_3, a_4$) \\\\\n      2.  & $(s, t_3) \\leftarrow$ {\\sc Quick-Two-Sum}($a_2, s$)   \\\\\n      3.  & $(s, t_2) \\leftarrow$ {\\sc Quick-Two-Sum}($a_1, s$)   \\\\\n      4.  & $(t_0, t_1) \\leftarrow$ {\\sc Quick-Two-Sum}($a_0, s$) \\\\\n      \\\\\n      5.  & $s \\leftarrow t_0$ \\\\\n      6.  & $k \\leftarrow 0$   \\\\\n      7.  & {\\bf for\\footnotemark[1]} $i \\leftarrow 1, 2, 3, 4$ \\\\\n      8.  & \\quad $(s, e) \\leftarrow$ {\\sc Quick-Two-Sum}($s, t_i$) \\\\\n      9.  & \\quad {\\bf if} $e \\ne 0$             \\\\\n      10. & \\quad \\quad $b_k \\leftarrow s$       \\\\\n      11. & \\quad \\quad $s \\leftarrow e$         \\\\\n      12. & \\quad \\quad $k \\leftarrow k + 1$     \\\\\n      13. & \\quad {\\bf end if}  \\\\\n      14. & {\\bf end for} \\\\\n      15. & {\\bf return} $(b_0, b_1, b_2, b_3)$\n    \\end{tabular}\n  \\end{minipage}  \n\\end{alg}\n\n\\footnotetext[1]{In the implementation, this loop is unrolled to several\n  {\\tt if} statements.}\n\nNecessary conditions for this renormalization algorithm to work correctly\nare, unfortunately, not known.  Priest proves that if the input expansion\ndoes not overlap by more than 51 bits, then the algorithm works correctly.\nHowever, this condition is by no means necessary; that the renormalization\nalgorithm (Algorithm \\ref{renorm_alg})\nworks on all the expansions produced by the algorithms below \nremains to be shown.\n\n\\subsection{Addition}\n\\subsubsection{Quad-Double + Double}\nThe addition of a double precision number to a quad-double number\nis similar to Shewchuk's {\\sc Grow-Expansion} \\cite[p. 316]{she97}, but the double \nprecision number $b$ is added to a quad-double number $a$ from\nmost significant component first (rather than from least significant).\nThis produces a five-term expansion which is the exact result, \nwhich is then renormalized.  See Figure~\\ref{qd_add_qd_d_fig}.\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{qd_add_qd_d.eps}\n    \\caption{\\label{qd_add_qd_d_fig}Quad-Double + Double}\n  \\end{center}\n\\end{figure}\n\nSince the exact result is computed, then normalized to four components, \nthis addition is accurate to at least the first 212 bits of the result.\n\n\\subsubsection{Quad-Double + Quad-Double}\nWe have implemented two algorithms for addition.  The first one\nis faster, but only satisfies the weaker (Cray-style) error bound\n$a \\oplus b = (1 + \\delta_1)a + (1 + \\delta_2)b$ where the magnitude\nof $\\delta_1$ and $\\delta_2$ is bounded by $\\epsqd = 2^{-211}$.\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{qd_add.eps}\n    \\caption{\\label{qd_add_fig}Quad-Double + Quad-Double}\n  \\end{center}\n\\end{figure}\n\nFigure \\ref{qd_add_fig} best describes the first addition algorithm of two\nquad-double numbers.  In the diagram, there are three large boxes\nwith three inputs to them.  These are various {\\sc Three-Sum} boxes, \nand their internals are shown in Figure \\ref{three_sum_fig}.\n\n\\begin{figure}\n  \\begin{center}\n    \\includegraphics{three-sum.eps} \\includegraphics{three-sum-2.eps}\n    \\includegraphics{three-sum-3.eps}\n    \\caption{\\label{three_sum_fig}{\\sc Three-Sum}s}\n  \\end{center}\n\\end{figure}\n\nNow for a few more lemmas.\n\\begin{lem}\n  \\label{two_sum_bound}\n  Let $a$ and $b$ be two double precision floating point numbers.\n  Let $M = \\max(|a|, |b|)$.  Then $|\\fl(a+b)| \\le 2M$, and consequently, \n  $|\\err(a+b)| \\le \\frac{1}{2}\\ulp(2M) \\le 2 \\eps M$.\n\\end{lem}\n\n\\begin{lem}\n  \\label{three_sum_bound}\n  Let $x, y,$ and $z$ be inputs to {\\sc Three-Sum}.\n  Let $u, v, w, r_0, r_1,$ and $r_2$ be as indicated in Figure \n  \\ref{three_sum_fig}.  Let $M = \\max (|x|, |y|, |z|)$.  Then\n  $|r_0| \\le 4M$, $|r_1| \\le 8 \\eps M$, and $|r_2| \\le 8 \\eps^2 M$.\n\\end{lem}\n\\begin{proof} This follows from applying Lemma \\ref{two_sum_bound}\nto each of the three {\\sc Two-Sum} boxes.  \nFirst {\\sc Two-Sum} gives $|u| \\le 2M$ and\n$|v| \\le 2\\eps M$.  Next {\\sc Two-Sum} (adding $u$ and $z$) gives\n$|r_0| \\le 4M$ and $|w| \\le 4\\eps M$.  Finally, the last {\\sc Two-Sum}\ngives the desired result.\n\\end{proof}\n\nNote that the two other {\\sc Three-Sum}s shown are simplification\nof the first {\\sc Three-Sum}, where it only computes one or two components, \ninstead of three; thus the same bounds apply.\n\nThe above bound is not at all tight; $|r_0|$ is bounded closer\nto $3M$ (or even $|x| + |y| + |z|$), and this makes the bounds for $r_1$ \nand $r_2$ correspondingly smaller.  However, this suffices for the\nfollowing lemma.\n\n\\begin{lem}\\label{sum_lemma}\n  The five-term expansion before the renormalization step in the\n  quad-double addition algorithm shown in Figure \\ref{qd_add_fig} errs \n  from the true result by less than $\\epsqd M$, where $M = \\max(|a|, |b|)$.\n\\end{lem}\n\\begin{proof}\nThis can be shown by\njudiciously applying Lemmas \\ref{two_sum_bound} and \\ref{three_sum_bound}\nto all the {\\sc Two-Sum}s and {\\sc Three-Sum}s in Figure \\ref{qd_add_fig}.\nSee Appendix \\ref{proof_appendix} for detailed proof.\n\\end{proof}\n\nAssuming that the renormalization\nstep works (this remains to be proven), we can then obtain the error bound\n\\begin{displaymath}\n  \\fl(a+b) = (1 + \\delta_1) a + (1 + \\delta_2) b \\qquad \\textrm{with} \\quad\n  |\\delta_1|, |\\delta_2| \\le \\epsqd.\n\\end{displaymath}\n\nNote that the above algorithm for addition is particularly suited to \nmodern processors with instruction level parallelism, since the first\nfour {\\sc Two-Sum}s can be evaluated in parallel.  Lack of branches \nbefore the renormalization step also helps to keep the pipelines full.\n\nNote that the above algorithm does not satisfy the IEEE-style error\nbound \n\\begin{displaymath}\n  \\fl(a+b) = (1+\\delta)(a+b) \\qquad \\textrm{with} \\quad\n  |\\delta| \\le 2\\epsqd \\textrm{ or so.}\n\\end{displaymath}\nTo see this, let $a = (u, v, w, x)$ and $b = (-u, -v, y, z)$, \nwhere none of $w, x, y, z$ overlaps and $|w| > |x| > |y| > |z|$.\nThen the above algorithm produces $c = (w, x, y, 0)$ instead\nof $c = (w, x, y, z)$ required by the stricter bound.\n\nThe second algorithm, due to J. Shewchuk and S. Boldo, computes the first\nfour components of the {\\em result} correctly.  Thus it satisfies\nmore strict error bound\n\\begin{displaymath}\n  \\fl(a+b) = (1+\\delta)(a+b) \\qquad \\textrm{with} \\quad\n  |\\delta| \\le 2\\epsqd \\textrm{ or so.}\n\\end{displaymath}\nHowever, it has a corresponding speed penalty; it runs significantly slower\n(factor of $2$--$3.5$ slower).\n\nThe algorithm is similar to Shewchuk's {\\sc Fast-Expansion-Sum} \n\\cite[p. 320]{she97}, \nwhere it merge-sorts the two expansions.  To prevent components with\nonly a few significant bits to be produced, a double-length accumulator\nis used so that a component is output only if the inputs gets small \nenough to not affect it.  \n\n\\begin{alg}\n  \\label{double_accum_alg}\n  Assuming that $u, v$ is a two-term expansion, the following algorithm\n  computes the sum $(u, v) + x$, and outputs the significant component\n  $s$ if the remaining components contain more than one double worth\n  of significand. $u$ and $v$ are modified to represent the other\n  two components in the sum.\n\n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{5in}\n    {\\sc Double-Accumulate}($u, v, x$) \\\\\n    \\begin{tabular}{rl}\n      1.  & $(s, v) \\leftarrow$ {\\sc Two-Sum}($v, x$)  \\\\\n      2.  & $(s, u) \\leftarrow$ {\\sc Two-Sum}($u, s$)  \\\\\n      3.  & {\\bf if} $u = 0$ \\\\\n      4.  & \\quad $u \\leftarrow s$ \\\\\n      5.  & \\quad $s \\leftarrow 0$ \\\\\n      6.  & {\\bf end if} \\\\\n      7.  & {\\bf if} $v = 0$ \\\\\n      8.  & \\quad $v \\leftarrow u$ \\\\\n      9.  & \\quad $u \\leftarrow s$ \\\\\n      10. & \\quad $s \\leftarrow 0$ \\\\\n      11. & {\\bf end if}   \\\\\n      12. & {\\bf return} ($s, u, v$) \\\\\n    \\end{tabular}\n  \\end{minipage}  \n\\end{alg}\n\nThe accurate addition scheme is given by the following algorithm.\n\\begin{alg}\n  \\label{accurate_add_alg}\n  This algorithm computes the sum of two quad-double numbers \n  $a = (a_0, a_1, a_2, a_3)$ and $b = (b_0, b_1, b_2, b_3)$.\n  Basically it merge-sorts the eight doubles, and performs\n  {\\sc Double-Accumulate} until four components are obtained.\n\n  \\vspace{0.1in} \\hfill\n  \\begin{minipage}[t]{5in}\n    {\\sc QD-Add-Accurate}($a, b$) \\\\\n    \\begin{tabular}{rl}\n      1.  & $(x_0, x_1, \\ldots, x_7) \\leftarrow$ \n          {\\sc Merge-Sort}$(a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3)$ \\\\\n      2.  & $u \\leftarrow 0$ \\\\\n      3.  & $v \\leftarrow 0$ \\\\\n      4.  & $k \\leftarrow 0$ \\\\\n      5.  & $i \\leftarrow 0$ \\\\\n      6.  & {\\bf while} $k < 4$ {\\bf and} $i < 8$ {\\bf do} \\\\\n      7.  & \\quad $(s,u,v)\\leftarrow$ {\\sc Double-Accumulate}$(u, v, x_i)$ \\\\\n      8.  & \\quad {\\bf if} $s \\ne 0$ \\\\\n      9.  & \\quad \\quad $c_k \\leftarrow s$ \\\\\n     10.  & \\quad \\quad $k \\leftarrow k + 1$ \\\\\n     11.  & \\quad {\\bf end if} \\\\\n     12.  & \\quad $i \\leftarrow i + 1$ \\\\\n     13.  & {\\bf end while} \\\\\n     14.  & {\\bf if} $k < 2$ {\\bf then} $c_{k+1} \\leftarrow v$ \\\\\n     15.  & {\\bf if} $k < 3$ {\\bf then} $c_k \\leftarrow u$ \\\\\n     16.  & {\\bf return} {\\sc Renormalize}$(c_0, c_1, c_2, c_3)$\n    \\end{tabular}\n  \\end{minipage}\n\\end{alg}\n\n\\subsection{Subtraction}\nSubtraction $a - b$ is implemented as the addition $a + (-b)$, \nso it has the same algorithm and properties as that of addition.\nTo negate a quad-double number, we can just simply negate each component.\nOn a modern C++ compiler with inlining, the overhead is\nnoticeable but not prohibitive (say $5\\%$ or so).\n\n\\subsection{Multiplication}\nMultiplication is basically done in a straightforward way, multiplying\nterm by term and accumulating.  Note that unlike addition, there\nare no possibilities of massive cancellation in multiplication, so\nthe following algorithms satisfy the IEEE style error bound\n$a \\otimes b = (1 + \\delta)(a \\times b)$ where $\\delta$ is bounded\nby $\\epsqd$.\n\n\\subsubsection{Quad-Double $\\times$ Double}\nLet $a = (a_0, a_1, a_2, a_3)$ be a quad-double number, and let $b$ be\na double precision number.  Then the product is the sum of four terms, \n$a_0 b + a_1 b + a_2 b + a_3 b$.  Note that $|a_3| \\le \\eps^3 |a_0|$, \nso $|a_3 b| \\le \\eps^3 |a_0 b|$, and thus only the first 53 bits of\nthe product $a_3 b$ need to be computed.  The first three terms are\ncomputed exactly using {\\sc Two-Prod} (or {\\sc Two-Prod-FMA}).\nAll the terms are then accumulated in a similar fashion as addition.\nSee Figure \\ref{qd_mul_qd_d_fig}.\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{qd_mul_qd_d.eps}\n    \\caption{\\label{qd_mul_qd_d_fig}Quad-Double $\\times$ Double}\n  \\end{center}\n\\end{figure}\n\n\\subsubsection{Quad-Double $\\times$ Quad-Double}\nMultiplication of two quad-double numbers becomes a bit complicated, \nbut nevertheless follows the same idea.  Let $a = (a_0, a_1, a_2, a_3)$\nand $b = (b_0, b_1, b_2, b_3)$ be two quad-double numbers.  Assume\n(without loss of generality) that $a$ and $b$ are order 1.\nAfter multiplication, we need to accumulate $13$ terms of order $O(\\eps^4)$\nor higher.\n\\begin{displaymath}\n  \\begin{array}{rcl@{\\qquad}l}\n    a \\times b &\\approx& a_0 b_0 & O(1) \\textrm{ term} \\\\\n    & & +\\; a_0 b_1 + a_1 b_0 & O(\\eps) \\textrm{ terms}\\\\\n    & & +\\;a_0 b_2 + a_1 b_1 + a_2 b_0 & O(\\eps^2) \\textrm{ terms}\\\\\n    & & +\\;a_0 b_3 + a_1 b_2 + a_2 b_1 + a_3 b_0 & O(\\eps^3) \\textrm{ terms}\\\\\n    & & +\\;a_1 b_3 + a_2 b_2 + a_3 b_1 & O(\\eps^4) \\textrm{ terms}\n  \\end{array}\n\\end{displaymath}\nNote that smaller order terms (such as $a_2 b_3$, which is $O(\\eps^5)$)\nare not even computed, since they are not needed to get the first\n212 bits.  The $O(\\eps^4)$ terms are computed using normal double\nprecision arithmetic, as only their first few bits are needed.\n\nFor $i+j \\le 3$, let $(p_{ij}, q_{ij}) = ${\\sc Two-Prod}($a_i$, $b_j$).  \nThen $p_{ij} = O(\\eps^{i+j})$ and $q_{ij} = O(\\eps^{i+j+1})$.\nNow there are one term ($p_{00}$) of order $O(1)$, three \n($p_{01}$, $p_{10}$, $q_{00}$) of order $O(\\eps)$, five \n($p_{02}$, $p_{11}$, $p_{20}$, $q_{01}$, $q_{10}$) \nof order $O(\\eps^2)$, seven of order $O(\\eps^3)$, \nand seven of order $O(\\eps^4)$.\nNow we can start accumulating all the terms by their order, \nstarting with $O(\\eps)$ terms (see Figure \\ref{qd_mul_accum_fig}).\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{qd_mul_accum.eps}\n    \\caption{\\label{qd_mul_accum_fig}Quad-Double $\\times$ Quad-Double accumulation phase}\n  \\end{center}\n\\end{figure}\n\nIn the diagram, there are four different summation boxes.\nThe first (topmost) one is {\\sc Three-Sum}, same as the one in \naddition.  The next three are, respectively, {\\sc Six-Three-Sum}\n(sums six doubles and outputs the first three components), \n{\\sc Nine-Two-Sum} (sums nine doubles and outputs the first two components), \nand {\\sc Nine-One-Sum} (just adds nine doubles using normal arithmetic).\n\n{\\sc Six-Three-Sum} computes the sum of six doubles to three double\nworth of accuracy (i.e., to relative error of $O(\\eps^3)$).  This is\ndone by dividing the inputs into two groups of three, and \nperforming {\\sc Three-Sum} on each group.  Then the two sums\nare added together, in a manner similar to quad-double addition.\nSee Figure \\ref{six_three_sum_fig}.\n\n{\\sc Nine-Two-Sum} computes the sum of nine doubles to double-double\naccuracy.  This is done by pairing the inputs to create four double-double\nnumbers and a single double precision number, and performing\naddition of two double-double numbers recursively until one arrives\nat a double-double output.  The double-double addition (the large square\nbox in the diagram) is the same as David Bailey's algorithm \\cite{bai-dd}.\nSee Figure \\ref{nine_two_sum_fig}.\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{six-three-sum.eps}\n    \\caption{\\label{six_three_sum_fig}{\\sc Six-Three-Sum}}\n  \\end{center}\n\\end{figure}\n\n\\begin{figure}\n  \\begin{center} \n    \\includegraphics{nine-two-sum.eps}\n    \\caption{\\label{nine_two_sum_fig}{\\sc Nine-Two-Sum}}\n  \\end{center}\n\\end{figure}\n\nIf one wishes to trade few bits of accuracy for speed, we don't\neven need to compute the $O(\\eps^4)$ terms; they can affect the\nfirst 212 bits only by carries during accumulation.  \nIn this case, we can compute the\n$O(\\eps^3)$ terms using normal double precision arithmetic, \nthereby speeding up multiplication considerably.\n\nSquaring a quad-double number can be done significantly\nfaster since the number of terms that needs to be accumulated\ncan be reduced due to symmetry.\n\n\\subsection{Division}\nDivision is done by the familiar long division algorithm.\nLet $a = (a_0, a_1, a_2, a_3)$ and $b = (b_0, b_1, b_2, b_3)$ be \nquad-double numbers.  We can first compute\nan approximate quotient $q_0 = a_0 / b_0$.  We then compute\nthe remainder $r = a - q_0 \\times b$, and compute the \ncorrection term $q_1 = r_0 / b_0$.  We can continue this process \nto obtain five terms, $q_0,\\; q_1,\\; q_2,\\; q_3$, and $q_4$.\n(only four are needed if few bits of accuracy is not important).\n\nNote that at each step, full quad-double multiplication and \nsubtraction must be done since most of the bits will be canceled\nwhen computing $q_3$ and $q_4$.  The five-term (or four-term)\nexpansion is then renormalized to obtain the quad-double quotient.\n\n\\section{Algebraic Operations} \\label{sec:algebraic}\n\\subsection{$N$-th Power}\n$N$-th Power computes $a^n$, given a quad-double number $a$ and an\ninteger $n$.  This is simply done by repeated squaring, borrowed\nfrom David Bailey \\cite{bai-dd}. \n\n\\subsection{Square Root}\nSquare root computes $\\sqrt{a}$ given a quad-double number $a$.\nThis is done with Newton iteration on the function\n\\begin{displaymath}\n  f(x) = \\frac{1}{x^2} - a\n\\end{displaymath}\nwhich has the roots $\\pm a^{-1/2}$. This gives rise to the iteration\n\\begin{displaymath}\n  x_{i+1} = x_i + \\frac{x_i (1 - ax_i^2)}{2}.\n\\end{displaymath}\nNote that the iteration does not require division of quad-double\nnumbers.  (Multiplication by $1/2$ can be done component-wise.)\nSince Newton's iteration is locally quadratically convergent, \nonly about two iterations are required if one starts out with\ndouble precision approximation $x_0 = \\sqrt{a_0}$.  (In the\nimplementation it is done three times.)  After $x = a^{-1/2}$ is\ncomputed, we perform a multiplication to obtain $\\sqrt{a} = ax$.\n\n\\subsection{$N$-th Root}\n$N$-th Root computes $\\sqrt[n]{a}$ given a quad-double number $a$\nand an integer $n$.  This is done again by Newton's iteration on\nthe function\n\\begin{displaymath}\n  f(x) = \\frac{1}{x^n} - a\n\\end{displaymath}\nwhich has the roots $a^{-1/n}$. This gives rise to the iteration\n\\begin{displaymath}\n  x_{i+1} = x_i + \\frac{x_i (1 - ax_i^n)}{n}.\n\\end{displaymath}\nThree iterations are performed, although twice is almost sufficient.\nAfter $x = a^{-1/n}$ is computed, we can invert to obtain $a^{1/n} = 1/x$.\n\n\\section{Transcendental Operations} \\label{sec:transcendental}\n\\subsection{Exponential}\nThe classic Taylor-Maclaurin series is used to evaluate $e^x$.  Before\nusing the Taylor series, the argument is reduced by noting that\n\\begin{displaymath}\n  e^{kr + m \\log 2} = 2^m (e^r)^k, \n\\end{displaymath}\nwhere the integer $m$ is chosen so that $m \\log 2$ is closest to $x$.\nThis way, we can make $|kr| \\le \\frac{1}{2} \\log 2 \\approx 0.34657$.\nUsing $k = 256$, we have $|r| \\le \\frac{1}{512} \\log 2 \\approx 0.001354$.\nNow $e^r$ can be evaluated using familiar Taylor series.  The argument\nreduction substantially speeds up the convergence of the series, as\nat most 18 terms are need to be added in the Taylor series.\n\n\\subsection{Logarithm}\nSince the Taylor series for logarithm converges much more slowly than \nthe series for exponential, instead we use Newton's iteration to\nfind the zero of the function $f(x) = e^x - a$.  This leads to \nthe iteration\n\\begin{displaymath}\n  x_{i+1} = x_i + ae^{-x_i} - 1, \n\\end{displaymath}\nwhich is repeated three times.\n\n\\subsection{Trigonometrics}\nSine and cosine are computed using Taylor series after argument reduction.\nTo compute $\\sin x$ and $\\cos x$, the argument $x$ is first reduced modulo\n$2 \\pi$, so that $|x| \\le \\pi$.  Now noting that $\\sin (y + k \\pi /2)$\nand $\\cos (y + k \\pi / 2)$ are of the form $\\pm \\sin y$ or $\\pm \\cos y$\nfor all integers $k$, we can reduce the argument modulo $\\pi/2$ so that\nwe only need to compute $\\sin y$ and $\\cos y$ with $|y| \\le \\pi / 4$.\n\nFinally, write $y = z + m (\\pi / 1024)$ where the integer $m$ is chosen\nso that $|z| \\le \\pi / 2048 \\approx 0.001534$.  Since $|y| \\le \\pi / 4$, \nwe can assume that $|m| \\le 256$.\nBy using a precomputed table\nof $\\sin (m \\pi / 1024)$ and $\\cos (m \\pi / 1024)$, we note that\n\\begin{displaymath}\n  \\sin (z + m \\pi / 1024) = \\sin z \\cos (m \\pi / 1024) + \n  \\cos z \\sin (m \\pi / 1024)\n\\end{displaymath}\nand similarly for $\\cos (z + m \\pi / 1024)$.  Using this argument\nreduction significantly increases the convergence rate of sine, \nas at most 10 terms need be added.\n\nNote that if both cosine and sine are needed, then one can compute\nthe cosine using the formula \n\\begin{displaymath}\n  \\cos x = \\sqrt{1 - \\sin^2 x}.\n\\end{displaymath}\n\nThe values of $\\sin (m \\pi / 1024)$ and $\\cos (m \\pi / 1024)$ are\nprecomputed by using arbitrary precision package such as MPFUN \\cite{bai-mp}\nusing the formula\n\\begin{displaymath}\n    \\sin \\left( \\frac{\\theta}{2} \\right) = \n    \\frac{1}{2} \\sqrt{2 - 2 \\cos \\theta}\n\\end{displaymath}\n\\begin{displaymath}\n    \\cos \\left( \\frac{\\theta}{2} \\right) = \n    \\frac{1}{2} \\sqrt{2 + 2 \\cos \\theta}\n\\end{displaymath}\nStarting with $\\cos \\pi = -1$, we can recursively use the above formula\nto obtain $\\sin (m \\pi / 1024)$ and $\\cos (m \\pi / 1024)$.\n\n\\subsection{Inverse Trigonometrics}\nInverse trigonometric function $\\arctan$ is computed using Newton\niteration on the function $f(x) = \\sin x - a$.\n\n\\subsection{Hyperbolic Functions}\nHyperbolic sine and cosine are computed using\n\\begin{displaymath} \n  \\sinh x = \\frac{e^x - e^{-x}}{2} \\qquad \\cosh x = \\frac{e^x + e^{-x}}{2}\n\\end{displaymath}\nHowever, when $x$ is small (say $|x| \\le 0.01$), the above formula for \n$\\sinh$ becomes unstable, and the Taylor series is used instead.\n\n\\section{Miscellaneous Routines} \\label{sec:misc}\n\\subsection{Input / Output}\n  Binary to decimal conversion of quad-double number $x$ is done by \ndetermining the integer $k$ such that $1 \\le |x 10^{-k}| < 10$, \nand repeatedly extracting digits and multiplying by 10.  To minimize\nerror accumulation, a table of accurately precomputed powers of 10\nis used.  This table is also used in decimal to binary conversion.\n\n\\subsection{Comparisons}\nSince quad-double numbers are fully renormalized after each \noperation, comparing two quad-double number for equality can\nbe done component-wise.  Comparing the size can be done from\nmost significant component first, similar to dictionary ordering\nof English words.  Comparison to zero can be done just by checking\nthe most significant word.\n\n\\subsection{Random Number Generator}\nThe quad-double random number generator produces a quad-double\nnumber in the range $[0, 1)$, uniformly distributed.  This is \ndone by choosing the first 212 bits randomly.  A 31-bit system-supplied\nrandom number generator is used to generate 31 bits at a time, \nthis is repeated $\\lceil 212 / 31 \\rceil = 7$ times to get\nall 212 bits.\n\n\\section{C++ Implementation} \\label{sec:implement}\n  The quad-double library is implemented in ANSI C++, taking full\nadvantage of operator / function overloading and user-defined data \nstructures.  The library should compile fine with ANSI Standard compliant\nC++ compilers.  Some of the test codes may not work with compilers\nlacking full support for templates.  Please see the files {\\tt README}\nand {\\tt INSTALL} for more details on the implementation and build \ninstructions.\n\n  Full C++ implementation of double-double library is included as\na part of the quad-double library, including full support for mixing\nthree types: double, double-double, and quad-double.  In order to use\nthe library, one must include the header file {\\tt qd.h} \nand link the code with the library {\\tt libqd.a}.  \nQuad-double variables are declared as {\\tt qd\\_real}, while double-double\nvariables are declared as {\\tt dd\\_real}.\n\nA sample C++ program is given below.\n\n\\begin{tt}\\begin{verbatim}\n  #include <iostream>\n  #include <qd/qd.h>\n\n  using std::cout;\n  using std::endl;\n\n  int main() {\n    int oldcw;\n    fpu_fix_start(&oldcw);     // see notes on x86 machines below.\n\n    qd_real a = \"3.141592653589793238462643383279502884197169399375105820\";\n    dd_real b = \"2.249775724709369995957\";\n    dd_real r;\n    \n    r = a + b;\n    cout << \"pi + e = \" << r << endl;\n\n    r = sqrt(r + 1.0);\n\n    fpu_fix_end(&oldcw);       // see notes on x86 machines below.\n    return 0;\n  }\n\\end{verbatim}\\end{tt}\n\nNote that strings must be used to assign to a quad-double (or double-double)\nnumbers; otherwise the double precision approximation is assigned.\nFor example, {\\tt a = 0.1} does not assign quad-double precision 0.1, \nbut rather a double precision number 0.1.  Instead, use {\\tt a = \"0.1\"}.\n\nCommon constants such as $\\pi$, $\\pi/2$, $\\pi/4$, $e$, $\\log 2$ are\n provided as {\\tt qd\\_real::\\_pi}, {\\tt qd\\_real::\\_pi2}, \n{\\tt qd\\_real::\\_pi4}, {\\tt qd\\_real::\\_e}, and {\\tt qd\\_real::\\_log2}.\nThese were computed using an arbitrary precision package (MPFUN++ \n\\cite{cha98}), and therefore are accurate to the last bit.\n\n\\noindent{\\bf Note on Intel x86 Processors}.\nThe algorithms in this library assume IEEE double precision floating\npoint arithmetic.  Since Intel x86 processors have extended (80-bit)\nfloating point registers, the round-to-double flag must be enabled in\nthe control word of the FPU for this library to function properly\nunder x86 processors.  The function {\\tt fpu\\_fix\\_start} turns\non the round-to-double bit in the FPU control word, while \n{\\tt fpu\\_fix\\_end} will restore the original state.\n\n\\section{Performance} \\label{sec:performance}\nPerformance of various operations on quad-double numbers on a variety\nof machines are presented in Table \\ref{timing_table}.  The tested\nmachines are\n\\begin{itemize}\n\\item Intel Pentium II, 400 MHz, Linux 2.2.16, g++ 2.95.2 compiler, \n  with {\\tt -O3 -funroll-loops -finline-functions -mcpu=i686 -march=i686} \n  optimizations.\n\\item Sun UltraSparc 333 MHz, SunOS 5.7, Sun CC 5.0 compiler, \n  with {\\tt -xO5 -native} optimizations.\n\\item PowerPC 750 (Apple G3), 266 MHz, Linux 2.2.15, g++ 2.95.2 compiler, \n  with {\\tt -O3 -funroll-\\\\loops -finline-functions} optimizations.\n\\item IBM RS/6000 Power3, 200 MHz, AIX 3.4, IBM xlC compiler, \n  with {\\tt -O3 -qarch=pwr3 -qtune\\\\=pwr3 -qstrict} optimizations.\n\\end{itemize}\n\n\\noindent {\\bf Note}: For some reason, GNU C++ compiler ({\\tt g++}) has\na terrible time optimizing the code for multiplication; it runs more than\n15 times slower than the code compiled by Sun's CC compiler.\n\n\\begin{table}[t]\n  \\begin{center}\n  \\label{timing_table}\n  \\begin{tabular}{|l|c|c|c|c|} \\hline\n    Operation & \n    \\begin{tabular}{c}Pentium II \\\\ 400MHz \\\\ Linux 2.2.16 \\end{tabular} & \n    \\begin{tabular}{c}UltraSparc \\\\ 333 MHz \\\\ SunOS 5.7 \\end{tabular} & \n    \\begin{tabular}{c}PowerPC 750 \\\\ 266 MHz \\\\ Linux 2.2.15 \\end{tabular} & \n    \\begin{tabular}{c}Power3 \\\\  200 MHz \\\\ AIX 3.4 \\end{tabular} \\\\\n    \\hline\n    \\multicolumn{5}{|l|}{{\\em Quad-double}} \\\\ \n    add          &  0.583 &  0.580 &  0.868 &  0.710 \\\\\n    accurate add &  1.280 &  2.464 &  2.468 &  1.551 \\\\\n    mul          &  1.965 &  1.153 &  1.744 &  1.131 \\\\\n    sloppy mul   &  1.016 &  0.860 &  1.177 &  0.875 \\\\\n    div          &  5.267 &  6.440 &  8.210 &  6.699 \\\\\n    sloppy div   &  4.080 &  4.163 &  6.200 &  4.979 \\\\\n    sqrt         & 23.646 & 15.003 & 21.415 & 16.174 \\\\ \\hline\n    \\multicolumn{5}{|l|}{{\\em MPFUN}}\\\\\n    add\t\t &  5.729 &  5.362 &  ---   &  4.651 \\\\\n    mul\t\t &  7.624 &  7.630 &  ---   &  5.837 \\\\\n    div     \t & 10.102 & 10.164 &  ---   &  9.180 \\\\ \\hline\n  \\end{tabular}\n  \\caption{Performance of some Quad-Double algorithms on several machines. \n    All measurements are in microseconds. We include the performance of \n    MPFUN~\\cite{bai-mp} as a comparison. Note, we do not have the MPFUN\n    measurements on the PowerPC, because we do not have a Fortran-90 compiler.}\n  \\end{center}\n\\end{table}\n\nMost of the routines runs noticeably faster if implemented in C, \nit seems that C++ operator overloading has some overhead associated\nwith it -- most notably excessive copying of quad-double numbers.\nThis occurs because operator overloading does not account for\nwhere the result is going to be placed.  For example, \nfor the code \n\\begin{quote}\\begin{tt}c = a + b;\\end{tt}\\end{quote}\nthe C++ compiler often emits the code equivalent to\n\\begin{quote}\\begin{tt}\n\\begin{verbatim}\nqd_real temp;\ntemp = operator+(a, b);     // Addition\noperator=(c, temp);         // Copy result to c\n\\end{verbatim}\n\\end{tt}\\end{quote}\nIn C, this copying does not happen, as one would just write\n\\begin{quote}\\begin{tt}\\begin{verbatim}\nc_qd_add(a, b, c);          // Put (a+b) into c\n\\end{verbatim}\\end{tt}\\end{quote}\nwhere the addition routine knows where to put the result directly.\nThis problem is somewhat alleviated by inlining, but not completely\neliminated.  There are techniques to avoid these kinds of copying~\\cite{c++}, \nbut they have\ntheir own overheads associated with them and is not practical for\nquad-double with only 32 bytes of data\\footnote{These techniques\nare feasible, for larger data structures, such as for much higher\nprecision arithmetics, where copying of data becomes time consuming.}.\n\n\\section{Future Work} \\label{sec:future}\nCurrently, the basic routines do not have a full correctness proof.\nThe correctness of these routines rely on the fact that renormalization\nstep works; Priest proves that it does work if the input does not overlap\nby 51 bits and no three components overlap at a single bit.  Whether\nsuch overlap can occur in any of these algorithm needs to be proved.\n\nThere are improvements due in the remainder operator, which computes\n$a - \\round(a/b) \\times b$, given quad-double numbers $a$ and $b$.\nCurrently, the library does the na\\\"\\i ve method of just divide, round, \nmultiply, and subtract.  This leads to loss of accuracy when $a$ is large\ncompared to $b$.  Since this routine is used in argument reduction for\nexponentials, logarithms and trigonometrics, a fix is needed.\n\nA natural extention of this work is to extend the precision beyond\nquad-double.  Algorithms for quad-double additions and multiplication\ncan be extended to higher precisions, however, with more components, \nasymptotically faster algorithm due to S. Boldo and J. Shewchuk may\nbe preferrable (i.e. Algorithm~\\ref{accurate_add_alg}).\nOne limitation these higher precision expansions have\nis the limited exponent range -- same as that of double.  Hence \nthe maximum precision is about 2000 bits (39 components), \nand this occurs only if the first component is near overflow and the \nlast near underflow.\n\n\\section{Acknowledgements}\nWe thank Jonathan Shewchuk, \nSylvie Boldo, and James Demmel for constructive discussions on \nvarious basic algorithms.  In particular, the accurate version of \naddition algorithm is due to S. Boldo and J. Shewchuk.  Problems with\nremainder was pointed out by J.Demmel.\n\n\\appendix\n\\newpage\n\\section{Proof of Quad-Double Addition Error Bound (Lemma \\ref{sum_lemma})}\n\\label{proof_appendix}\n\n\\noindent\n{\\bf Lemma \\ref{sum_lemma}}. \n\\emph{The five-term expansion before the renormalization step in the\nquad-double addition algorithm shown in Figure \\ref{qd_add_fig} errs \nfrom the true result by less than $\\epsqd M$, where $M = \\max(|a|, |b|)$.}\n\n\\begin{proof}\n  The proof is done by applying Lemmas \\ref{two_sum_bound} and \n\\ref{three_sum_bound} to each of {\\sc Two-Sum}s and {\\sc Three-Sum}s.\nLet $e_0, e_1, e_2, e_3, t_1, t_2, t_3, x_0, x_1, x_2, x_3, x_4, u, v, \nw, z, f_1, f_2$, and $f_3$ be as shown in Figure \\ref{qd_add_proof_fig}.\n\nWe need to show\nthat the five-term expansion $(x_0, x_1, x_2, x_3, x_4)$ errs from the\ntrue result by less than $\\epsqd M$, where $M = \\max(|a_0|, |b_0|)$.\nNote that the only place that any error is introduced is in {\\sc Three-Sum} 7\nand {\\sc Three-Sum} 8, where lower order terms $f_1, f_2,$ and $f_3$ are discarded.  \nHence it suffices to show $|f_1| + |f_2| + |f_3| \\le \\epsqd M$.\n\n\\begin{figure}[h]\n  \\begin{center} \n    \\includegraphics{qd_add_proof.eps}\n    \\caption{\\label{qd_add_proof_fig}Quad-Double + Quad-Double}\n  \\end{center}\n\\end{figure}\n\nFirst note that $|a_1| \\le \\eps M$, $|a_2| \\le \\eps^2 M$,and \n$|a_3| \\le \\eps^3 M$, since the input expansions are assumed to be \nnormalized.  Similar inequalities applies for expansion $b$.\nApplying Lemma \\ref{two_sum_bound} to {\\sc Two-Sum}s 1, 2, 3, 4, we obtain\n\\begin{displaymath}\n  \\begin{array}{rcl@{\\qquad}rcl}\n    |x_0| &\\le& 2M & |e_0| &\\le& 2\\eps M\\\\\n    |t_1| &\\le& 2\\eps M   & |e_1| &\\le& 2\\eps^2 M\\\\\n    |t_2| &\\le& 2\\eps^2 M & |e_2| &\\le& 2\\eps^3 M\\\\\n    |t_3| &\\le& 2\\eps^3 M & |e_3| &\\le& 2\\eps^4 M.\n  \\end{array}\n\\end{displaymath}\n\nNow we can apply Lemma \\ref{two_sum_bound} to {\\sc Two-Sum} 5, to obtain\n$|x_1| \\le 4\\eps M$ and $|u| \\le 4 \\eps^2 M$.  Then we apply Lemma \n\\ref{three_sum_bound} to {\\sc Three-Sum} 6 to obtain\n\\begin{displaymath}\n  \\begin{array}{r@{\\;\\le\\;}l}\n    |x_2| & 16\\eps^2 M \\\\\n    |w| & 32 \\eps^3 M  \\\\\n    |v| & 32 \\eps^4 M.\n  \\end{array}\n\\end{displaymath}\n\nApplying Lemma \\ref{three_sum_bound} to {\\sc Three-Sum} 7, we have\n\\begin{displaymath}\n  \\begin{array}{r@{\\;\\le\\;}l}\n    |x_3| & 128\\eps^3 M \\\\\n    |z| & 256 \\eps^4 M  \\\\\n    |f_1| & 256 \\eps^5 M.\n  \\end{array}\n\\end{displaymath}\n\nFinally we apply Lemma \\ref{three_sum_bound} again to {\\sc Three-Sum} 8\nto get\n\\begin{displaymath}\n  \\begin{array}{r@{\\;\\le\\;}l}\n    |x_4| & 1024\\eps^4 M \\\\\n    |f_2| & 2048 \\eps^5 M  \\\\\n    |f_3| & 2048 \\eps^6 M.\n  \\end{array}\n\\end{displaymath}\n\nThus we have \n\\begin{displaymath}\n  |f_1| + |f_2| + |f_3| \\le 256 \\eps^5 M + 2048 \\eps^5 M + 2048 \\eps^6 M \n  \\le 2305 \\eps^5 M \\le \\epsqd M\n\\end{displaymath}\nas claimed.\n\\end{proof}\n\n\\newpage\n\\bibliographystyle{plain}\n\\bibliography{qd}\n\n\\end{document}\n", "meta": {"hexsha": "f0c2025f3da80549ff439d22fe2983be1e2453a3", "size": 44744, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "qd/docs/qd.tex", "max_stars_repo_name": "Sanaxen/QuadDouble", "max_stars_repo_head_hexsha": "8093a4d86ab37ced87ea3facf1bd34cc2973ede8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "qd/docs/qd.tex", "max_issues_repo_name": "Sanaxen/QuadDouble", "max_issues_repo_head_hexsha": "8093a4d86ab37ced87ea3facf1bd34cc2973ede8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "qd/docs/qd.tex", "max_forks_repo_name": "Sanaxen/QuadDouble", "max_forks_repo_head_hexsha": "8093a4d86ab37ced87ea3facf1bd34cc2973ede8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2007366483, "max_line_length": 89, "alphanum_fraction": 0.6930091185, "num_tokens": 14344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.418149912927306}}
{"text": "\n\\section{Introduction}\n\nAs a convenience to users, we provide a mechanism for declaring\nnested coordinate systems.  This is particularly useful\nfor creating \\emph{substructures} or \\emph{subnets}.  Different\ninstances of a subnet may have the same relative placements\nof nodes, but at different translations and orientations.\n\n\n\\section{Interface}\n\nWe support nested coordinate systems via a \\emph{transformation stack}.\nThe entries in this stack data structures are all affine transformations that\ntake the current coordinate system to the global system.  New transformations\nare \\emph{composed} with the previous top-of-stack, so that if\n$T_0$ is the current transformation to global coordinates and a\ntransformation $S$ is pushed onto the stack, then $T_0 S$ will\nbe the new transformation from current to global coordinates.\n\nThe transformation $T = Ax + b$ is given by a table of twelve entries \nwhich represents the components of the matrix $[A; b]$ in column major \norder.  A vector $x$ is given by a table with coordinate entries at\nindices 1 to 3.  Note that the table can contain additional information\n(e.g. a node name).  Part of the reason the transformation functions\noverwrite the input vector table is so that entries besides those\nat indices 1 to 3 can be retained unchanged.\n\nThe functions provided by this module are\n\\begin{itemize}\n  \\item {\\tt{}xform{\\char95}push(T)}: compose a transformation onto the stack\n  \\item {\\tt{}xform{\\char95}pop}: pop a level off the transformation stack\n  \\item {\\tt{}top{\\char95}xform(x)}: overwrite $x$ with $T_\\mathit{top} x$,\n        where $T_\\mathit{top}$ is the top transform on the stack\n  \\item {\\tt{}xform{\\char95}apply(T,\\ x)}: overwrite $x$ with $Tx$.\n  \\item {\\tt{}xform{\\char95}applyA(t,\\ x)}: overwrite $x$ with $A_T x$,\n        where $A_T$ is the linear part of the affine transform $T$.\n  \\item {\\tt{}xform{\\char95}compose(T,\\ S)}: return $TS$\n  \\item {\\tt{}xform{\\char95}identity}: return the identity transform\n  \\item {\\tt{}xform{\\char95}ox(r),\\ xform{\\char95}oy(r),\\ xform{\\char95}oz(r)}:\n        return right-handed rotations about the coordinate axes\n  \\item {\\tt{}xform{\\char95}translate(z)}: return a translation by the\n        vector $z$\n  \\item {\\tt{}subnet(f)}: return a function which creates a nested\n        coordinate system according to any {\\tt{}ox}, {\\tt{}oy},\n        and {\\tt{}oz} parameters, calls {\\tt{}f}, and then pops the\n        nested coordinate system.\n\\end{itemize}\n\n\n\\section{Implementation}\n\n\\nwfilename{xformstack.nw}\\nwbegincode{1}\\sublabel{NWxfoD-xfoE-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-xfoE-1}}}\\moddef{xformstack.lua~{\\nwtagstyle{}\\subpageref{NWxfoD-xfoE-1}}}\\endmoddef\n\\LA{}data~{\\nwtagstyle{}\\subpageref{NWxfoD-dat4-1}}\\RA{}\n\\LA{}functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}\\RA{}\n\\nwnotused{xformstack.lua}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\\subsection{The transform stack}\n\nThe size of the stack is maintained in the field $n$.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NWxfoD-dat4-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-dat4-1}}}\\moddef{data~{\\nwtagstyle{}\\subpageref{NWxfoD-dat4-1}}}\\endmoddef\nxform_stack = \\{n = 0\\};\n\n\\nwused{\\\\{NWxfoD-xfoE-1}}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\nNote that we compose new transformations onto the stack, interpreting\nthe transformation argument as a transformation into the current coordinates\ninstead of a transformation into the global coordinates.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NWxfoD-fun9-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\endmoddef\nfunction xform_push(T)\n  local n = xform_stack.n + 1\n  if n == 1 then\n    xform_stack[n] = T\n  else\n    xform_stack[n] = xform_compose(xform_stack[n-1], T);\n  end\n  xform_stack.n = n;\nend\n\n\\nwalsodefined{\\\\{NWxfoD-fun9-2}\\\\{NWxfoD-fun9-3}\\\\{NWxfoD-fun9-4}\\\\{NWxfoD-fun9-5}\\\\{NWxfoD-fun9-6}\\\\{NWxfoD-fun9-7}\\\\{NWxfoD-fun9-8}\\\\{NWxfoD-fun9-9}\\\\{NWxfoD-fun9-A}\\\\{NWxfoD-fun9-B}\\\\{NWxfoD-fun9-C}}\\nwused{\\\\{NWxfoD-xfoE-1}}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NWxfoD-fun9-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-2}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\nfunction xform_pop()\n  xform_stack.n = xform_stack.n - 1\nend\n\n\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NWxfoD-fun9-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-3}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\nfunction top_xform(x)\n  local n = xform_stack.n\n  if n > 0 then\n    return xform_apply(xform_stack[n], x)\n  else\n    return x\n  end\nend \n\n\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\n\\subsection{Transformation functions}\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NWxfoD-fun9-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-4}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Overwrite x with Tx\nfunction xform_apply(T, x)\n  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3] + T[10];\n  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3] + T[11];\n  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3] + T[12];\n  x[1] = y1;\n  x[2] = y2;\n  x[3] = y3;\n  return x;\nend\n\n\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NWxfoD-fun9-5}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-5}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Overwrite x with A_T * x\nfunction xform_applyA(T, x)\n  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3]; \n  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3]; \n  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3];\n  x[1] = y1;\n  x[2] = y2;\n  x[3] = y3;\n  return x;\nend\n\n\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\nRecall that \n\\[\n  T(S(x)) = A_T (A_S x + b_S) + b_T = (A_T A_S) x + T(b_T)\n\\]\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NWxfoD-fun9-6}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-6}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return TS\nfunction xform_compose(T, S)\n  local TS = \\{\\};\n  for k = 1,4 do\n    local base = 3*k-3;\n    TS[base+1] = T[1]*S[base+1] + T[4]*S[base+2] + T[7]*S[base+3];\n    TS[base+2] = T[2]*S[base+1] + T[5]*S[base+2] + T[8]*S[base+3];\n    TS[base+3] = T[3]*S[base+1] + T[6]*S[base+2] + T[9]*S[base+3];\n  end\n  TS[10] = TS[10] + T[10];\n  TS[11] = TS[11] + T[11];\n  TS[12] = TS[12] + T[12];\n  return TS;\nend\n\n\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NWxfoD-fun9-7}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-7}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return the identity\nfunction xform_identity()\n  return \\{ 1, 0, 0,\n           0, 1, 0,\n           0, 0, 1,\n           0, 0, 0 \\};\nend\n\n\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\nGetting right hand rotations correct is always a trick.\nImportant note -- remember that the transformation matrix is\ninterpreted as column-major, but is ``typographically'' row\nmajor.  So put on your transposing hat before reading the\nfollowing three functions.\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NWxfoD-fun9-8}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-8}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return a rotation about the x axis\nfunction xform_ox(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ 1,   0,  0,\n           0,   c,  s,\n           0,  -s,  c,\n           0,   0,  0 \\}\nend\n\n\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NWxfoD-fun9-9}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-9}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return a rotation about the y axis\nfunction xform_oy(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ c,   0, -s,\n           0,   1,  0,\n           s,   0,  c,\n           0,   0,  0 \\}\nend\n\n\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NWxfoD-fun9-A}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-A}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return a rotation about the z axis\nfunction xform_oz(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ c,   s,  0,\n          -s,   c,  0,\n           0,   0,  1,\n           0,   0,  0 \\}\nend\n\n\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NWxfoD-fun9-B}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-B}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\n-- Return a translation \nfunction xform_translate(z)\n  return \\{ 1,    0,    0,\n           0,    1,    0,\n           0,    0,    1,\n           z[1], z[2], z[3] \\}\nend\n\n\\nwendcode{}\\nwbegindocs{26}\\nwdocspar\n\n\n\\subsection{{\\tt{}node} and {\\tt{}subnetize} functions}\n\nWe assume that node positions are expressed in the current coordinate\nsystem (at least, that's what we assume for most purposes).\nSo the {\\tt{}nodex} (``node transformed'') function transforms\nthe input coordinates from local to global, and them makes a node.\n\nWe still want to leave the option of expressing node coordinates\ndirectly in the global coordinate system, though.  For instance,\nwe may want to put a node halfway between two other nodes which\nhave already been transformed into global coordinates.  For this\nreason, we leave the {\\tt{}node} function alone.\n\n\\nwenddocs{}\\nwbegincode{27}\\sublabel{NWxfoD-fun9-C}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-C}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NWxfoD-fun9-1}}}\\plusendmoddef\nfunction nodex(p)\n  if p[1] then\n    top_xform(p)\n  end\n  return node(p)\nend\n\n\\nwendcode{}\\nwbegindocs{28}\\nwdocspar\n\n\n\n\\subsection{Test code}\n\n\\nwenddocs{}\\nwbegincode{29}\\sublabel{NWxfoD-xfoC-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-xfoC-1}}}\\moddef{xformtst.lua~{\\nwtagstyle{}\\subpageref{NWxfoD-xfoC-1}}}\\endmoddef\nuse(\"xformstack.lua\")\n\n\\LA{}test transform constructors~{\\nwtagstyle{}\\subpageref{NWxfoD-tesR-1}}\\RA{}\n\\LA{}test composition~{\\nwtagstyle{}\\subpageref{NWxfoD-tesG-1}}\\RA{}\n\\nwnotused{xformtst.lua}\\nwendcode{}\\nwbegindocs{30}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{31}\\sublabel{NWxfoD-tesR-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-tesR-1}}}\\moddef{test transform constructors~{\\nwtagstyle{}\\subpageref{NWxfoD-tesR-1}}}\\endmoddef\n-- First check out the basics\n\nrx45 = xform_ox(45)\nry45 = xform_oy(45)\nrz45 = xform_oz(45)\ntrans = xform_translate \\{1, 2, 3\\}\n\nx1 = xform_apply(rx45,  \\{1, 0, 0\\})\nx2 = xform_apply(ry45,  \\{1, 0, 0\\})\nx3 = xform_apply(rz45,  \\{1, 0, 0\\})\nx4 = xform_apply(trans, \\{1, 0, 0\\})\nx5 = xform_applyA(trans, \\{1, 0, 0\\})\n\nprint(\"Rotate e1 by rx45: \",     x1[1], x1[2], x1[3])\nprint(\"Rotate e1 by ry45: \",     x2[1], x2[2], x2[3])\nprint(\"Rotate e1 by rz45: \",     x3[1], x3[2], x3[3])\nprint(\"Translate e1 by 1,2,3: \", x4[1], x4[2], x4[3])\nprint(\"Apply A e1 by 1,2,3: \",   x5[1], x5[2], x5[3])\n\n\\nwused{\\\\{NWxfoD-xfoC-1}}\\nwendcode{}\\nwbegindocs{32}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{33}\\sublabel{NWxfoD-tesG-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWxfoD-tesG-1}}}\\moddef{test composition~{\\nwtagstyle{}\\subpageref{NWxfoD-tesG-1}}}\\endmoddef\n-- Now check out composition\n\nT = xform_compose(trans, rz45)\nx = xform_apply(T, \\{1, 0, 0\\})\n\nprint(\"Rotate then translate: \", x[1], x[2], x[3])\n\nundoT = xform_compose(xform_oz(-45), xform_translate\\{-1,-2,-3\\})\nxform_apply(undoT, x)\n\nprint(\"After undo operation: \", x[1], x[2], x[3])\n\n\\nwused{\\\\{NWxfoD-xfoC-1}}\\nwendcode{}\n\n\\nwixlogsorted{c}{{data}{NWxfoD-dat4-1}{\\nwixu{NWxfoD-xfoE-1}\\nwixd{NWxfoD-dat4-1}}}%\n\\nwixlogsorted{c}{{functions}{NWxfoD-fun9-1}{\\nwixu{NWxfoD-xfoE-1}\\nwixd{NWxfoD-fun9-1}\\nwixd{NWxfoD-fun9-2}\\nwixd{NWxfoD-fun9-3}\\nwixd{NWxfoD-fun9-4}\\nwixd{NWxfoD-fun9-5}\\nwixd{NWxfoD-fun9-6}\\nwixd{NWxfoD-fun9-7}\\nwixd{NWxfoD-fun9-8}\\nwixd{NWxfoD-fun9-9}\\nwixd{NWxfoD-fun9-A}\\nwixd{NWxfoD-fun9-B}\\nwixd{NWxfoD-fun9-C}}}%\n\\nwixlogsorted{c}{{test composition}{NWxfoD-tesG-1}{\\nwixu{NWxfoD-xfoC-1}\\nwixd{NWxfoD-tesG-1}}}%\n\\nwixlogsorted{c}{{test transform constructors}{NWxfoD-tesR-1}{\\nwixu{NWxfoD-xfoC-1}\\nwixd{NWxfoD-tesR-1}}}%\n\\nwixlogsorted{c}{{xformstack.lua}{NWxfoD-xfoE-1}{\\nwixd{NWxfoD-xfoE-1}}}%\n\\nwixlogsorted{c}{{xformtst.lua}{NWxfoD-xfoC-1}{\\nwixd{NWxfoD-xfoC-1}}}%\n\\nwbegindocs{34}\\nwdocspar\n\n\\nwenddocs{}\n", "meta": {"hexsha": "127ed574a68df9b644148c97cfd700cc14b33d22", "size": 12231, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sugar30/src/tex/xformstack.tex", "max_stars_repo_name": "davidgarmire/sugar", "max_stars_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sugar30/src/tex/xformstack.tex", "max_issues_repo_name": "davidgarmire/sugar", "max_issues_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sugar30/src/tex/xformstack.tex", "max_forks_repo_name": "davidgarmire/sugar", "max_forks_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2335526316, "max_line_length": 321, "alphanum_fraction": 0.6926661761, "num_tokens": 4801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190475, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.41814991292730597}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Wednesday\\\\ 2020-11-18, \\\\ compiled \\\\ \\today}\n\nRecall that \n%\n\\begin{align}\n\\Sigma = \\num{5.2} \\alpha^{-4/5} \\dot{M}_{16}^{7/10} M^{1/4} R^{-3/4} \\SI{}{g / cm^2}\n\\,.\n\\end{align}\n\nIs it true that \\(M_d = M _{\\text{disk}} \\ll M\\), as we assumed? \nWe can calculate it as \n%\n\\begin{align}\nM_d &= \\int_{R _{\\text{in}}}^{R _{\\text{max}}} 2 \\pi R \\Sigma \\dd{R}  \\\\\n&\\approx \\num{e-8} \\alpha^{-4/5} M_{16}^{7/10} M^{1/2} M_{\\odot}\n\\,,\n\\end{align}\n%\nassuming that \\(R _{\\text{max}} \\approx 10 R _{\\text{in}}\\).\nThis is indeed many orders of magnitude below the mass of the stellar source. \n\n\\subsubsection{Regions of the disk}\n\nThe \\(\\alpha \\) parameter comes from the very rough assumption \\(\\nu _{\\text{turb}} = \\alpha c_s H\\), it is a weak point of this model.\nAsking that \\(\\alpha = \\const\\) is just plain wrong. \n\nFurther, we assumed that \\(P = P _{\\text{gas}}\\), and that the Rosseland mean opacity \\(\\kappa _R\\) is only given by free-free absorption. \n\nWe know that for Thompson scattering the cross-section is \\(\\kappa _R^{s} = \\sigma _T / m_p = \\SI{.4}{cm^2 / g}\\). \nWhen is this smaller than the free-free opacity? In dimensionless terms, the equation for \\(\\kappa = \\tau / \\Sigma \\) reads\n%\n\\begin{align}\n\\kappa_{R}^{\\text{ff}} &> \\kappa_R^{s} \\\\\n\\num{6.3} \\dot{M}_{16}^{-1/2} M^{1/4} R_{10}^{-3/4} f^2 &> \\num{.4}  \\\\\nR_{10} &> \\num{.5e-2} \\dot{M}_{16}^{2/3} M^{1/3} f^{8/3} \\\\\nR &> \\num{.5e8} \\dot{M}_{16}^{2/3} M^{1/3} f^{8/3} \\SI{}{cm}\n\\,.\n\\end{align}\n\nFor a white dwarf, this is always the case; we can tell in general that for \\(R \\lesssim \\SI{e8}{cm}\\) electron scattering dominates.\n\nThe temperature decreases with radius as \\(T \\propto R^{-3/2}\\), so for high enough radii it can drop below \\SI{e4}{K}, at which point recombination can occur: at that point free-free absorption cannot occur anymore, and we must account for free-bound and bound-bound transitions. \n\nIf a NS or a BH is accreting, on the other hand, we can have a scattering-dominated internal region.\n\nSo, in terms of the \\textbf{main type of matter-radiation interaction} we will have three regions: going outwards, there is domination of electron scattering, free-free absorption, bound-free/bound-bound absorption. \n\nDoes \\(P _{\\text{gas}}\\) dominate over \\(P _{\\text{rad}}\\)? their ratio is indeed\n%\n\\begin{align}\n\\frac{P _{\\text{rad}}}{P _{\\text{gas}}} = \\frac{ \\frac{1}{3} a T^{4}}{\\frac{k T_c \\Sigma H}{\\mu m_p}} \\approx \\num{3e-3} \\alpha^{1/10} \\dot{M}_{16}^{7/10} R_{10}^{-3/8} f^{7/5} \\ll 1\n\\,.\n\\end{align}\n\nAs \\(R\\) decreases, \\(P _{\\text{rad}}\\) becomes ever more relevant. \nIs there an equality radius? It will definitely be smaller than \\SI{3e8}{cm}. \nDoing the calculation, we find \n%\n\\begin{align}\nR  _{\\text{equality}} \\approx \\num{24} \\alpha^{2/21} \\dot{M}_{16}^{16/21} f^{9/21} \\SI{}{km}\n\\,.\n\\end{align}\n\nThis may sometimes be attained in the innermost region of the disk, right before the ISCO.\n\nSo, in terms of the \\textbf{nature of most of the pressure}, we may have a radiation-dominated region in the innermost part of the disk, but mostly there will be gas pressure domination. \n\n\\paragraph{The shape of the disk}\n\nWe calculate the shape of the disk, \\(H(R)\\), in the innermost radiation-dominated region.\nThe sound speed under radiation domination is\n%\n\\begin{align}\nc_s^2 = \\frac{P}{\\rho } = \\frac{1}{3} \\frac{a T_c^{4}}{\\rho} = \\frac{1}{3} \\frac{4 \\sigma }{c} \\frac{T_c^{4}}{\\rho }\n\\,,\n\\end{align}\n%\nand we know that \n%\n\\begin{align}\n\\frac{4}{3} \\frac{\\sigma T_c^{4}}{\\tau } = \\frac{3 GM \\dot{M}}{8 \\pi R^3} f\n\\,,\n\\end{align}\n%\nwhich means that \n%\n\\begin{align}\nc_s^2 = \\frac{3 GM \\dot{M} \\tau f}{8 \\pi R^3 \\rho c}\n\\,,\n\\end{align}\n%\nand using the fact that, for scattering opacity domination, \n%\n\\begin{align}\n\\tau = \\kappa _R^{s} \\Sigma = \\frac{\\sigma _T}{m_p} \\rho H\n\\,,\n\\end{align}\n%\nwe find \n%\n\\begin{align}\nc_s^2 =  \n\\frac{3 GM \\dot{M} \\sigma _T \\rho H f}{8 \\pi R^3 \\rho  c m_p} =\n\\frac{3 GM \\dot{M} \\sigma _T  H f}{8 \\pi R^3   c m_p}\n\\,,\n\\end{align}\n%\nbut we also know that \\(H = c_s R (R / GM)^{1/2}\\); using this fact we can calculate the sound speed \\(c_s = (H/R)(GM/R)^{1/2} \\). \nUsing this (see equation \\eqref{eq:speed-of-sound-disk-shape}), we get \n%\n\\begin{align}\n\\frac{H^2}{R^2} \\frac{GM}{R} &= \\frac{3 GM \\dot{M} \\sigma _T  H f}{8 \\pi R^3   c m_p} \\\\\nH &= \\frac{3 \\sigma _T \\dot{M} }{8 \\pi c m_p}f \n\\,,\n\\end{align}\n%\nwhich is nearly independent of \\(R\\): the only dependence is inside the factor \\(f\\), which depends on \\(R\\) quite weakly. \nThe shape of the disk is slab-like in the inner region, and concave in the outer part but still quite flat. \n\n\\paragraph{The Eddington limit}\n\nThe Eddington luminosity for electron scattering is \n%\n\\begin{align}\nL _{\\text{Edd}} = \\frac{4 \\pi G M m_p c}{\\sigma _T}\n\\,,\n\\end{align}\n%\nand the corresponding accretion rate is \\(\\dot{M} _{\\text{Edd}} = L _{\\text{Edd}} / c^2\\). \n\nThe critical accretion rate is the one which produces an Eddington luminosity, after accounting for efficiency: \n%\n\\begin{align}\n\\eta \\dot{M} _{\\text{crit}} c^2 = L _{\\text{Edd}}\n\\,,\n\\end{align}\n%\nso \\(\\dot{M} _{\\text{crit}}\\) is larger than \\(\\dot{M} _{\\text{Edd}}\\). \nUsing this, the height of the disk is given by \n%\n\\begin{align}\nH &= \\frac{3}{2} \\dot{M} f \\frac{\\sigma _T}{4 \\pi c m_p } = \\frac{3}{2} \\dot{M} f \\frac{GM}{L _{\\text{Edd}}} \\\\\n&= \\frac{3}{2} \\underbrace{\\frac{GM}{R _{\\text{in}}c^2}}_{\\eta } R _{\\text{in}} \\frac{\\dot{M}}{\\dot{M} _{\\text{Edd}}} f  \\\\\n&= \\frac{3}{2} \\eta R _{\\text{in}} \\frac{\\dot{M}}{\\dot{M} _{\\text{Edd}}} f\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{align}\n\\frac{H}{R _{\\text{in}}} = \\frac{3}{2} \\frac{\\dot{M}}{\\dot{M} _{\\text{crit}}} f\n\\,,\n\\end{align}\n%\nand we can see that \\(H < R _{\\text{in}}\\) iff \\(\\dot{M} < M _{\\text{crit}}\\). \nThen, we see that \\textbf{the accretion rate must be subcritical as long as we want to keep the disk thin}. \n\n\\subsection{The multicolor blackbody}\n\nA final point about disks: each layer of the disk emits roughly a blackbody, which means that the total spectrum is a superposition of several blackbodies, this is called a multicolor blackbody.\n\nThe spectrum emitted by each annulus, as usual, is described by a  Planck function: \n%\n\\begin{align}\nI_\\nu = \\frac{2h}{c^2} \\frac{\\nu^3}{\\exp(\\frac{h \\nu }{k_B T}) - 1}\n\\,,\n\\end{align}\n%\nas long as there is no reprocessing of the radiation from stuff around the disk.\nThis is an interesting process, but for simplicity we will not discuss it. \n\nWhat we measure is the flux: \n%\n\\begin{align}\nF_\\nu = \\int_{4 \\pi } I_\\nu \\cos \\theta \\dd{\\Omega }\n\\,,\n\\end{align}\n%\nwhere \\(\\dd{\\Omega } = 2 \\pi R \\dd{R}/D^2\\), where \\(D\\) is the distance from us. \nThe integral to compute is \n%\n\\begin{align}\nF_\\nu = \\frac{2 \\pi }{D^2} \\cos \\iota \\int_{R _{\\text{in}}}^{R _{\\text{out}}} R \\dd{R} \\frac{\\nu^3}{\\exp(\\frac{h \\nu }{k_B T(R)}) - 1}\n\\,.\n\\end{align}\n\nThis integral can be computed numerically, but we can already gather its main characteristics. \nAs we have seen earlier \\eqref{eq:temperature-accretion-disk}, the temperature looks like \n%\n\\begin{align}\nT(R) = T _{\\text{in}} \\qty( \\frac{R _{\\text{in}}}{R})^{3/4}\n\\,.\n\\end{align}\n\nLet us now estimate the integral in three limits, comparing \\(h \\nu     \\) to \\(k_B T(R _{\\text{in}})\\) and \\(k_B T (R _{\\text{out}})\\) respectively.\n\nThe first interesting limit is the low-energy one: \\(h \\nu \\ll k_B T (R _{\\text{out}}) < k_B T(R)\\) for any \\(R\\).\nThen, the flux is proportional to \n%\n\\begin{align}\nF_\\nu \\propto \\int R \\dd{R} \\frac{\\nu^3}{h \\nu / k_B T(R)} \n\\propto \\nu^2 \\int T(R) R \\dd{R} \n\\propto \\nu^2\n\\,.\n\\end{align}\n\nThe opposite, high energy limit \\(h \\nu \\gg k_B T(R _{\\text{in}})\\) yields an exponential cutoff, since the contribution of the exponential \\(e^{-h \\nu / k_B T(R)}\\) of the term in the integral with \\(T = T _{\\text{in}}\\) is dominant \n%\n\\begin{align}\nF_\\nu \\propto \\nu^3 \\exp(- \\frac{h \\nu }{k_B T _{\\text{in}}})\n\\,.\n\\end{align}\n\nIn the intermediate region, \\(k_B T _{\\text{out}} < h \\nu < k_B T _{\\text{in}}\\). \n\nDefining \\(x = h \\nu / k_B T(R)\\), we find \n%\n\\begin{align}\nF_\\nu \\propto \\int \\frac{\\nu^3 }{e^{x} - 1} R \\dd{R}\n\\,,\n\\end{align}\n%\nbut \\(x \\propto \\nu / T \\propto \\nu R^{3/4}\\), therefore \\(R \\propto x^{4/3} \\nu^{-4/3}\\), which means that (since \\(\\nu \\) is constant in the context of the integral) \\(\\dd{R} \\propto x^{1/3} \\nu^{-4/3} \\dd{x}\\) \n%\n\\begin{align}\nF_\\nu \\propto \\int \\frac{\\nu^3 \\nu^{-8/3}}{e^{x}-1} x^{5/3} \\dd{x} \n\\,,\n\\end{align}\n%\nwhich means that \n%\n\\begin{align}\nF_\\nu \\propto \\nu^{1/3} \\int \\frac{x^{5/3}}{e^{x}-1} \\dd{x}\n\\,.\n\\end{align}\n\nThe integral is approximately one from 0 to \\(\\infty \\), a number. \nThe \\(F \\propto \\nu^{1/3}\\) signature intermediate region is a characteristic of accretion disks.  \n\n\\end{document}\n", "meta": {"hexsha": "bd6608f2174865a179caa20e1a11ea5c75168dd9", "size": 8727, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/compact_objects/nov18.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/compact_objects/nov18.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/compact_objects/nov18.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 35.7663934426, "max_line_length": 281, "alphanum_fraction": 0.6388220465, "num_tokens": 3217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.41779159065203125}}
{"text": "\\subsection{Data field values}\n\\label{subsec:library_of_transformations:instance_level_transformations:data_field_values}\n\n\\begin{figure}\n    \\centering\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\includegraphics{images/05_library_of_transformations/03_instance_level_transformations/06_data_field_values/data_field_value.pdf}\n        \\caption{$Im_{DataField}$ with one object and string value ``some value''}\n        \\label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:ecore}\n    \\end{subfigure}\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\input{images/05_library_of_transformations/03_instance_level_transformations/06_data_field_values/data_field_as_edge_type_value.tikz}\n        \\caption{$IG_{DataField}$ with one node and string value ``some value''}\n        \\label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:groove}\n    \\end{subfigure}\n    \\caption{Visualisation of the transformation of field values from fields typed by data types}\n    \\label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation}\n\\end{figure}\n\nThe previous sections have shown the instance level transformations of the introduction of all kinds of types and their instances. From this section onward, these types and their instances will be enriched by introducing fields. In this section, the instance level transformation belonging to the transformation of a data field is discussed. The type level transformation for data fields can be found in \\cref{subsec:library_of_transformations:type_level_transformations:data_fields}. On the instance level, values for the data fields are introduced.\n\n\\begin{defin}[Instance model $Im_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field}\nLet $Im_{DataField}$ be an instance model typed by $Tm_{DataField}$ (\\cref{defin:library_of_transformations:type_level_transformations:data_fields:tmod_data_field}). Define a set $objects$, which represent the objects that will get a value for the field introduced by $Tm_{DataField}$. Furthermore, define a function $obids$ which maps each of these objects to their corresponding identifier and a function $values$, which maps each of these objects to its value for the field introduced by $Tm_{DataField}$. $Im_{DataField}$ is defined as:\n\\begin{align*}\nObject =\\ &objects \\\\\n\\mathrm{ObjectClass} =\\ & \\begin{cases}\n    (ob, classtype) & \\mathrm{if }\\ ob \\in objects\n\\end{cases}\\\\\n\\mathrm{ObjectId} =\\ & \\begin{cases}\n    (ob, obids(ob)) & \\mathrm{if }\\ ob \\in objects\n\\end{cases}\\\\\n\\mathrm{FieldValue} =\\ & \\begin{cases}\n    ((ob, (classtype, name)), values(ob)) & \\mathrm{if }\\ ob \\in objects\n\\end{cases} \\\\\n\\mathrm{DefaultValue} =\\ & \\{\\}\n\\end{align*}\n\\isabellelref{imod_data_field}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{defin}\n\n\\begin{thm}[Correctness of $Im_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_correct}\n$Im_{DataField}$ (\\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field}) is a valid instance model in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.\n\\isabellelref{imod_data_field_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\nA visual representation of $Im_{DataField}$ with $objects = \\{ob\\}$ and $obids(ob) = someId$ can be seen in \\cref{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:ecore}. In this visualisation, the field value for $ob$ is defined as $values(ob) = \\text{``some value''}$. Although this visualisation only shows one object, it is required to define a value for all objects that contain the field. Failing to do so would result in an invalid instance model after it is combined with another model, as the next definition will show. The correctness proof of $Im_{DataField}$ only is already quite involved, but not be included here for conciseness. It can be found as part of the validated Isabelle proofs.\n\nIn order to make composing transformation functions possible, $Im_{DataField}$ should be compatible with the instance model it is combined with.\n\n\\begin{thm}[Correctness of $\\mathrm{combine}(Im, Im_{DataField})$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_combine_correct}\nAssume an instance model $Im$ that is valid in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Then $Im$ is compatible with $Im_{DataField}$ (in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:compatibility}) if:\n\\begin{itemize}\n    \\item All requirements of \\cref{defin:library_of_transformations:type_level_transformations:data_fields:tmod_data_field_combine_correct} are met, to ensure the combination of the corresponding type models is valid;\n    \\item The class type on which the field is defined by $Tm_{DataField}$ may not be extended by another class type in the type model corresponding to $Im$;\n    \\item All of the objects in the set $objects$ must already be objects in $Im$;\n    \\item All objects typed by the class type on which the field is defined must occur in the set $objects$ and thus have a value in $Im_{DataField}$;\n    \\item For all of the objects in the set $objects$, the identifier set by $obids$ must be the same identifier as set by $Im$ for that object;\n    \\item For all objects in set $objects$, the value set by the $values$ function must be valid.\n\\end{itemize}\n\\isabellelref{imod_data_field_combine_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\n\\begin{proof}\nUse \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\\mathrm{combine}(Im, Im_{DataField})$ is consistent in the sense of \\cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.\n\\end{proof}\n\nAs explained earlier, $Im_{DataField}$ needs to introduce values for all objects that are typed by the class type on which the field is defined. This is enforced by the requirements of \\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_combine_correct}. The proof is not included here for conciseness, but can be found as part of the validated proofs in Isabelle.\n\nThe definitions and theorems for introducing values for fields of data types within Ecore are now complete. \n\n\\subsubsection{Encoding as edges and nodes}\n\nIn the type level transformation of data fields, data fields were encoded in GROOVE as edge types to an primitive type. On the instance level, this edge type will be used and edges will be created to give a value to each node type that has the field defined. The encoding corresponding to $Im_{DataField}$ can then be represented as $IG_{DataField}$, defined in the following definition:\n\n\\begin{defin}[Instance graph $IG_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type}\nLet $IG_{DataField}$ be the instance graph typed by type graph $TG_{DataField}$ (\\cref{defin:library_of_transformations:type_level_transformations:data_fields:tg_data_field_as_edge_type}). Reuse the set $objects$ from $Im_{DataField}$. Moreover, reuse the functions $obids$ and $values$ from $Im_{DataField}$.\nThe objects in the set $objects$ are converted to nodes in $Im_{DataField}$. For each of these objects, an edge of the encoded field is created. This edge targets a node that corresponds to the value set by $values$ for the corresponding object. Finally, the identity of the objects is defined using $obids$. $IG_{DataField}$ is defined as:\n\\begin{align*}\nN =\\ & objects \\cup \\{values(ob) \\mid ob \\in objects\\} \\\\\nE =\\ & \\big\\{\\big(ob, (\\mathrm{ns\\_\\!to\\_\\!list}(classtype), \\langle name \\rangle, fieldtype), values(ob)\\big) \\mid ob \\in objects \\big\\} \\\\\n\\mathrm{ident} =\\ & \\begin{cases}\n    (obids(ob), ob) & \\mathrm{if }\\ ob \\in objects\n\\end{cases}\n\\end{align*}\nwith\n\\begin{align*}\n\\mathrm{type}_n =\\ & \\begin{cases}\n    (ob, \\mathrm{ns\\_\\!to\\_\\!list}(classtype)) & \\mathrm{if }\\ ob \\in objects\n\\end{cases}\n\\end{align*}\n\\isabellelref{ig_data_field_as_edge_type}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{defin}\n\n\\begin{thm}[Correctness of $IG_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_correct}\n$IG_{DataField}$ (\\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type}) is a valid instance graph in the sense of \\cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.\n\\isabellelref{ig_data_field_as_edge_type_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\nA visual representation of $IG_{DataField}$ with $objects = \\{ob\\}$ and $obids(ob) = someId$ can be seen in \\cref{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:groove}. Like the previous visualisation, the field value for $ob$ is defined as $values(ob) = \\text{``some value''}$. Although this visualisation only shows one node, it is required to define a value for all nodes typed by the node type corresponding to the field. Failing to do so would result in an invalid instance graph after it is combined with another graph, as the next definition will show. The correctness proof of $IG_{DataField}$ only is already quite involved, but not be included here for conciseness. It can be found as part of the validated Isabelle proofs.\n\nIn order to make composing transformation functions possible, $IG_{DataField}$ should be compatible with the instance graph it is combined with.\n\n\\begin{thm}[Correctness of $\\mathrm{combine}(IG, IG_{DataField})$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_combine_correct}\nAssume an instance graph $IG$ that is valid in the sense of \\cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}. Then $IG$ is compatible with $IG_{DataField}$ (in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:compatibility}) if:\n\\begin{itemize}\n    \\item All requirements of \\cref{defin:library_of_transformations:type_level_transformations:data_fields:tg_data_field_as_edge_type_combine_correct} are met, to ensure the combination of the corresponding type graphs is valid;\n    \\item The node type on which the corresponding field is defined is not extended by other node types within the type graph corresponding to $IG$;\n    \\item All nodes in $IG$ that are typed by the node type on which the field is defined are also nodes in $IG_{DataField}$;\n    \\item For all nodes shared between $IG$ and $IG_{DataField}$, each node must have the same identifier in both $IG$ and $IG_{DataField}$;\n    \\item For all nodes for which the field is set, the $values$ function must define a valid value;\n    \\item If an primitive type has incoming or outgoing edge types in the type graph corresponding to $IG$, then the lower multiplicity of these edge types must be 0.\n\\end{itemize}\n\\isabellelref{ig_data_field_as_edge_type_combine_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\n\\begin{proof}\nUse \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\\mathrm{combine}(IG, IG_{DataField})$ is valid in the sense of \\cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.\n\\end{proof}\n\nLike the definition for the combination of instance models, the combination of instance graphs also requires the user to set a value for all nodes that are typed by the node type that corresponds to the field type. This is to keep the graph valid.\n\nThe next definitions define the transformation function from $Im_{DataField}$ to $IG_{DataField}$:\n\n\\begin{defin}[Transformation function $f_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type}\nThe transformation function $f_{DataField}(Im)$ is defined as:\n\\begin{align*}\nN =\\ & Object_{Im} \\cup \\{values(ob) \\mid ob \\in Object_{Im}\\}  \\\\\nE =\\ & \\big\\{\\big(ob, (\\mathrm{ns\\_\\!to\\_\\!list}(classtype), \\langle name \\rangle, fieldtype), values(ob)\\big) \\mid ob \\in Object_{Im} \\big\\} \\\\\n\\mathrm{ident} =\\ & \\begin{cases}\n    (obids(ob), ob) & \\mathrm{if }\\ ob \\in Object_{Im}\n\\end{cases}\n\\end{align*}\nwith\n\\begin{align*}\n\\mathrm{type}_n =\\ & \\begin{cases}\n    (ob, \\mathrm{ns\\_\\!to\\_\\!list}(name)) & \\mathrm{if }\\ ob \\in Object_{Im}\n\\end{cases}\n\\end{align*}\n\\isabellelref{imod_data_field_to_ig_data_field_as_edge_type}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{defin}\n\n\\begin{thm}[Correctness of $f_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type_func}\n$f_{DataField}(Im)$ (\\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type}) is a valid transformation function in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph} transforming $Im_{DataField}$ into $IG_{DataField}$.\n\\isabellelref{imod_data_field_to_ig_data_field_as_edge_type_func}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\nThe proof of the correctness of $f_{DataField}$ will not be included here. Instead, it can be found in the validated Isabelle theories.\n\nFinally, to complete the transformation, the transformation function that transforms $IG_{DataField}$ into $Im_{DataField}$ is defined:\n\n\\begin{defin}[Transformation function $f'_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_imod_data_field}\nThe transformation function $f'_{DataField}(IG)$ is defined as:\n\\begin{align*}\nObject =\\ &\\{\\mathrm{src}(e) \\mid e \\in E_{IG}\\} \\\\\n\\mathrm{ObjectClass} =\\ & \\begin{cases}\n    (ob, classtype) & \\mathrm{if }\\ ob \\in \\{\\mathrm{src}(e) \\mid e \\in E_{IG}\\}\n\\end{cases}\\\\\n\\mathrm{ObjectId} =\\ & \\begin{cases}\n    (ob, obids(ob)) & \\mathrm{if }\\ ob \\in \\{\\mathrm{src}(e) \\mid e \\in E_{IG}\\}\n\\end{cases}\\\\\n\\mathrm{FieldValue} =\\ & \\begin{cases}\n    ((ob, (classtype, name)), values(ob)) & \\mathrm{if }\\ ob \\in \\{\\mathrm{src}(e) \\mid e \\in E_{IG}\\}\n\\end{cases} \\\\\n\\mathrm{DefaultValue} =\\ & \\{\\}\n\\end{align*}\n\\isabellelref{ig_data_field_as_edge_type_to_imod_data_field}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{defin}\n\n\\begin{thm}[Correctness of $f'_{DataField}$]\n\\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_tmod_class_func}\n$f'_{DataField}(IG)$ (\\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_imod_data_field}) is a valid transformation function in the sense of \\cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model} transforming $IG_{DataField}$ into $Im_{DataField}$.\n\\isabellelref{ig_data_field_as_edge_type_to_imod_data_field_func}{Ecore-GROOVE-Mapping-Library.DataFieldValue}\n\\end{thm}\n\nOnce more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.", "meta": {"hexsha": "f78aca3f855d6798d2110a1a236c74ec93017aab", "size": 16017, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/05_library_of_transformations/03_instance_level_transformations/06_data_field_values.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/05_library_of_transformations/03_instance_level_transformations/06_data_field_values.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/05_library_of_transformations/03_instance_level_transformations/06_data_field_values.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.5783783784, "max_line_length": 781, "alphanum_fraction": 0.7951551477, "num_tokens": 4137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4177915842563189}}
{"text": "\\chapter{Graphs}\n\n\\textbf{Erdos-Gallai:} $d_1\\geq\\cdots\\geq d_n$ can be degree sequence of simple graph on $n$ vertices iff their sum is even and $\\sum_{i=1}^{k}d_{i}\\leq k(k-1)+\\sum _{i=k+1}^{n}\\min(d_{i},k), \\forall 1\\le k\\le n.$\n\n\\section{Cycles}\n\t\\kactlimport{Basics/DirectedCycle.h}\n\t\\kactlimport{Basics/NegativeCycle (7.3).h}\n\n\\section{DSU}\n\t\\kactlimport{DSU/DSU (7.6).h}\n\n\\section{Trees}\n\t\\kactlimport{Trees (10)/LCAjump (10.2).h}\n\t\\kactlimport{Trees (10)/LCArmq (10.2).h}\n\t\\kactlimport{Trees (10)/HLD (10.3).h}\n\t\\kactlimport{Trees (10)/Centroid (10.3).h}\n\n\t\\subsection{SqrtDecompton}\n\n\t\tHLD generally suffices. If not, here are some common strategies:\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\item Rebuild the tree after every $\\sqrt N$ queries. % https://codeforces.com/contest/1254/submission/65439802\n\t\t\t\\item Consider vertices with $>$ or $<\\sqrt N$ degree separately. % https://codeforces.com/contest/1254/submission/65437007\n\t\t\t\\item For subtree updates, note that there are $O(\\sqrt N)$ distinct sizes among child subtrees of any node.\n\t\t\\end{itemize}\n\n\t\t\\textbf{Block Tree:} Use a DFS to split edges into contiguous groups of size $\\sqrt N$ to $2\\sqrt N.$\n\n\t\t\\textbf{Mo's Algorithm for Tree Paths:} Maintain an array of vertices where each one appears twice, once when a DFS enters the vertex (\\texttt{st}) and one when the DFS exists (\\texttt{en}). For a tree path $u\\leftrightarrow v$ such that \\texttt{st[u]<st[v]},\n\n\t\t\\begin{itemize}\n\t\t\\item If $u$ is an ancestor of $v,$ query \\texttt{[st[u],st[v]]}.\n\t\t\\item Otherwise, query $\\texttt{[en[u],st[v]]}$ and consider $LCA(u,v)$ separately.\n\t\t\\end{itemize}\n\n\t\tSolutions with worse complexities can be faster if you optimize the operations that are performed most frequently. Use arrays instead of vectors whenever possible. Iterating over an array in order is faster than iterating through the same array in some other order (ex. one given by a random permutation) or DFSing on a tree of the same size. Also, the difference between $\\sqrt N$ and the optimal block (or buffer) size can be quite large. Try up to 5x smaller or larger (at least).\n\n\t\t% ex. GP of Nanjing 2020 K\n\n\\section{DFS Algorithms}\n\n\t% \\kactlimport{DFS/SCC (12.1).h}\n\t\\kactlimport{DFS/EulerPath (12.2).h}\n\t\\kactlimport{DFS/SCCT.h}\n\t\\kactlimport{DFS/TwoSAT (12.1).h}\n\t\\kactlimport{DFS/BCC (12.4).h}\n\t\\kactlimport{DFS/MaximalCliques.h}\n\n\\section{Flows}\n\n\t\\textbf{Konig's Theorem:} In a bipartite graph, max matching = min vertex cover.\n\n\t\\textbf{Dilworth's Theorem:} For any partially ordered set, the sizes of the max antichain and of the min chain decomposition are equal. Equivalent to Konig's theorem on the bipartite graph $(U,V,E)$ where $U=V=S$ and $(u,v)$ is an edge when $u<v$. Those vertices outside the min vertex cover in both $U$ and $V$ form a max antichain.\n\n\t% Wikipedia, https://codeforces.com/gym/102428/problem/A, https://maps20.kattis.com/problems/maps20.thewrathofkahn\n\n\t\\kactlimport{Flows (12.3)/Dinic.h}\n\t\\kactlimport{Flows (12.3)/GomoryHu.h}\n\t\\kactlimport{Flows (12.3)/MCMF.h}\n\n\t% \\kactlimport{Flows (12.3)/GlobalMinCut.h}\n\n\\section{Matching}\n\n\t% \\kactlimport{Matching/DFSmatch.h}\n\t\\kactlimport{Matching/Hungarian.h}\n\t\\kactlimport{Matching/UnweightedMatch.h}\n\t\\kactlimport{Matching/WeightedMatch.h}\n\t\\kactlimport{Matching/MaxMatchLexMin.h}\n\t\\kactlimport{Matching/MaxMatchFast.h}\n\t% \\kactlimport{Matching/MaxMatchHeuristic.h}\n\t% \\kactlimport{Matching/UnweightedMatch2.h}\n\n\\section{Advanced}\n\n\t% \\kactlimport{Advanced/MaxClique.h}\n\t\\kactlimport{Advanced/ChordalGraphRecognition.h}\n\t\\kactlimport{Advanced/DominatorTree.h}\n\t\\kactlimport{Advanced/EdgeColor.h}\n\t\\kactlimport{Advanced/DirectedMST.h}\n\t\\kactlimport{Advanced/LCT.h}\n\t\\kactlimport{Advanced/TopTree.h}", "meta": {"hexsha": "9633ce04a3c66cb213529555103b4d1c956c931d", "size": 3697, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Implementations/content/graphs (12)/chapter.tex", "max_stars_repo_name": "maheshschand/USACO", "max_stars_repo_head_hexsha": "52890a77f66f8b779ba2b1da0460b85dd9f38013", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1760, "max_stars_repo_stars_event_min_datetime": "2017-05-21T21:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T13:15:08.000Z", "max_issues_repo_path": "Implementations/content/graphs (12)/chapter.tex", "max_issues_repo_name": "maheshschand/USACO", "max_issues_repo_head_hexsha": "52890a77f66f8b779ba2b1da0460b85dd9f38013", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2018-01-24T02:41:53.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-17T13:09:26.000Z", "max_forks_repo_path": "Implementations/content/graphs (12)/chapter.tex", "max_forks_repo_name": "maheshschand/USACO", "max_forks_repo_head_hexsha": "52890a77f66f8b779ba2b1da0460b85dd9f38013", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 473, "max_forks_repo_forks_event_min_datetime": "2017-07-06T04:53:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T13:03:28.000Z", "avg_line_length": 44.5421686747, "max_line_length": 485, "alphanum_fraction": 0.7362726535, "num_tokens": 1264, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629465, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4177545775764705}}
{"text": "\\documentclass[11pt]{scrartcl} % Font size\n\\input{../structure.tex} % Include the file specifying the document structure and custom commands\n\n%----------------------------------------------------------------------------------------\n%\tTITLE SECTION\n%----------------------------------------------------------------------------------------\n\n\\title{\n\t\\normalfont\\normalsize\n\t\\textsc{Harvard Privacy Tools Project}\\\\ % Your university, school and/or department name(s)\n\t\\vspace{25pt} % Whitespace\n\t\\rule{\\linewidth}{0.5pt}\\\\ % Thin top horizontal rule\n\t\\vspace{20pt} % Whitespace\n\t{\\huge Mean Sensitivity Proofs}\\\\ % The assignment title\n\t\\vspace{12pt} % Whitespace\n\t\\rule{\\linewidth}{2pt}\\\\ % Thick bottom horizontal rule\n\t\\vspace{12pt} % Whitespace\n}\n\n% \\author{\\LARGE} % Your name\n\n\\date{\\normalsize\\today} % Today's date (\\today) or a custom date\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{definition}\nThe sample mean of database $X$ of size $n$ is defined as \n$$f(X) = \\frac{1}{n} \\sum_{i=1}^n x_i.$$\n\\end{definition}\nThese are restricted-sensitivity proofs that only apply when N is known.\nThe library makes use of the Resize component to guarantee this static property.\nIf N is unknown, there is an argument on the DPMean component to estimate the mean by postprocessing plug-in estimates for the count and sum.\n\n\\section{Neighboring Definition: Change One}\n\n% l1 sensitivity\n\\subsection{$\\ell_1$-sensitivity}\n\\begin{theorem}\nSay the space of datapoints $\\mathcal{X}$ is bounded above by $M$ and bounded below by $m$. Then $f(\\cdot)$ has $\\ell_1$-sensitivity in the change-one model bounded above by\n$$ \\frac{M-m}{n}.$$\n\\end{theorem}\n\n\\begin{proof}\nSay $X$ and $X'$ are neighboring databases which differ at data-point $x_j$, and let $\\Delta{f}$ indicate the $\\ell_1$-sensitivity of $f(\\cdot)$. Then\n\\begin{align*}\n\\Delta{f} &= \\max_{X,X'} \\left\\vert f(X) - f(X)' \\right\\vert \\\\\n\t&=  \\max_{X,X'} \\frac{1}{n} \\left\\vert \\left(\\sum_{\\{ i \\in [n] \\vert i \\ne j\\}} x_i\\right) + x_j  - \\left(\\sum_{\\{ i \\in [n] \\vert i \\ne j\\}} x_i'\\right) + x_j'  \\right\\vert \\\\\n\t&= \\max_{X,X'} \\frac{1}{n} \\left\\vert x_j - x_j' \\right\\vert \\\\\n\t&\\le \\frac{M-m}{n}.\n\\end{align*}\n\\end{proof}\n\n% l2 sensitivity\n\\subsection{$\\ell_2$-sensitivity}\n\\begin{theorem}\n\tSay the space of datapoints $\\mathcal{X}$ is bounded above by $M$ and bounded below by $m$.\n\tThen $f(\\cdot)$ has $\\ell_2$-sensitivity in the change-one model bounded above by\n\t $$ \\frac{M-m}{n}. $$\n\\end{theorem}\n\n\\begin{proof}\nThis follows the same logic as the above proof.\n\\end{proof}\n\n\\section{Neighboring Definition: Add/Drop One}\n\\subsection{$\\ell_1$-sensitivity}\n\n\\begin{theorem}\nSay the space of datapoints $\\mathcal{X}$ is bounded above by $M$ and bounded below by $m$.\nThen $f(\\cdot)$ has $\\ell_1$-sensitivity in the add/drop-one model bounded above by\n$$ \\frac{M-m}{n}. $$\n\\end{theorem}\n\n\\begin{proof}\nFor notational ease, let $n$ always refer to the size of database $x$. We must consider both adding and removing an element from $x$. First, consider adding a point:\\\\\n\nLet $X' = X \\cup \\{x\\}$. Without loss of generality, assume the point added is the $(n+1)^{\\text{th}}$ element of database $X'$. Note that\n\\begin{align*}\n\\left \\vert f(X) - f(X)' \\right\\vert &= \\left\\vert \\frac{1}{n} \\sum_{i=1}^n x_i - \\frac{1}{n+1} \\sum_{i=1}^{n+1} x_i \\right\\vert \\\\\n\t&= \\left\\vert \\left(\\frac{1}{n} - \\frac{1}{n+1}\\right) \\sum_{i=1}^n x_i - \\frac{x}{n+1}\\right\\vert \\\\\n\t&= \\frac{1}{n+1} \\left\\vert \\frac{1}{n} \\sum_{i=1}^n x_i - x \\right\\vert \\\\\n\t&\\le \\frac{ \\left\\vert M - m \\right\\vert}{n+1}.\n\\end{align*}\n\nSecond, consider removing a point: \\\\\nLet $X' = X\\textbackslash\\{x\\}$. Without loss of generality assume that the point subtracted is the $n^{\\text{th}}$ element of database $X$.\n\\begin{align*}\n\\left \\vert f(X) - f(X') \\right\\vert &= \\left\\vert \\frac{1}{n-1} \\sum_{i=1}^{n-1} x_i - \\frac{1}{n} \\sum_{i=1}^n x_i \\right\\vert \\\\\n\t&= \\left\\vert \\left(\\frac{1}{n-1} - \\frac{1}{n}\\right) \\sum_{i=1}^{n-1} x_i - \\frac{x}{n}\\right\\vert \\\\\n\t&= \\frac{1}{n} \\left\\vert \\frac{1}{n-1} \\sum_{i=1}^{n-1} x_i  - x \\right\\vert \\\\\n\t&\\le \\frac{\\left\\vert M-m\\right\\vert}{n}.\n\\end{align*}\n\nThen, since $\\forall n > 0,$\n\n$$ \\frac{1}{n+1} < \\frac{1}{n},$$\n\nthe sensitivity of the mean in general is bound from above by \n\n$$ \\frac{M-m}{n}.$$\n\\end{proof}\n\n% l2 sensitivity\n\\subsection{$\\ell_2$-sensitivity}\n\n\\begin{theorem}\nSay the space of datapoints $\\mathcal{X}$ is bounded above by $M$ and bounded below by $m$. Then $f$ has $\\ell_2$-sensitivity in the add/drop-one model bounded above by\n\t$$ \\frac{M-m}{n}. $$\n\\end{theorem}\n\n\\begin{proof}\nThis follows the same logic as the above proof.\n%\tFor notational ease, let $n$ always refer to the size of database $X$. We must consider both adding and removing an element from $X$. First, consider adding a point:\n%\n%\tLet $X' = X \\cup x$. Without loss of generality assume the point added is the $(n+1)^\\text{th}$ element of database X'. Then,\n%\t\\begin{align*}\n%\t\t\\Delta f &= \\max_{X,X'} \\sqrt{(f(X)- f(X)')^2} \\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\frac{1}{n}\\sum_{i=1}^{n}x_i - \\frac{1}{n+1}\\sum_{i=1}^{n+1}x'_i \\right)\\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\left(\\frac{1}{n}\\sum_{i=1}^{n}x_i\\right) - \\left(\\frac{1}{n+1}\\sum_{i=1}^{n}x'_i\\right) - \\frac{x}{n+1} \\right)\\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\frac{ \\left(\\sum_{i=1}^{n}x_i\\right) - nx }{n(n+1)} \\right)\\\\\n%\t\t\t\t\t   &= \\frac{nM - nm}{n(n+1)}\\\\\n%\t\t\t\t\t   &= \\frac{M - m}{n+1}.\n%\t\\end{align*}\n%\n%Second, consider removing an element:\\\\\n%Let $X' = X \\setminus \\{ x \\}$. Without loss of generality assume that the point subtracted is the $n^\\text{th}$ element of database $X$. Then,\n%\t\\begin{align*}\n%\t\t\\Delta f &= \\max_{X,X'} (f(X)- f(X)')^2 \\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\frac{1}{n}\\sum_{i=1}^{n}x_i - \\frac{1}{n-1}\\sum_{i=1}^{n-1}x'_i \\right)\\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\left( \\frac{1}{n}\\sum_{i=1}^{n-1}x_i \\right) + \\frac{x}{n} - \\left( \\frac{1}{n-1}\\sum_{i=1}^{n-1}x'_i \\right) \\right) \\\\\n%\t\t\t\t\t   &= \\max_{X,X'} \\left( \\frac{(n-1)x - \\sum_{i=1}^{n-1}x_i }{n(n-1)} \\right) \\\\\n%\t\t\t\t\t   &= \\frac{(n-1)M - (n-1)m}{n(n-1)} \\\\\n%\t\t\t\t\t   &= \\frac{M-m}{n}\n%\t\\end{align*}\n%\t\n%Then, since $\\forall n > 0,$\n%\n%$$ \\frac{1}{n+1} < \\frac{1}{n},$$\n%\n%the sensitivity of the mean in general is bound from above by \n%\n%$$ \\frac{M-m}{n}.$$\n\\end{proof}\n\n% \\bibliographystyle{alpha}\n% \\bibliography{mean}\n\n\\end{document}", "meta": {"hexsha": "ab0383b6744893e1b1e65554b6853fcab9d32a7b", "size": 6332, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "whitepapers/sensitivities/mean/mean.tex", "max_stars_repo_name": "opendp/smartnoise-core", "max_stars_repo_head_hexsha": "85592371742f984d1a4252c80a17dd5603bd6da8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2021-02-18T07:02:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:10:13.000Z", "max_issues_repo_path": "whitepapers/sensitivities/mean/mean.tex", "max_issues_repo_name": "opendp/smartnoise-core", "max_issues_repo_head_hexsha": "85592371742f984d1a4252c80a17dd5603bd6da8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2021-03-01T21:57:15.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T11:01:03.000Z", "max_forks_repo_path": "whitepapers/sensitivities/mean/mean.tex", "max_forks_repo_name": "opendp/smartnoise-core", "max_forks_repo_head_hexsha": "85592371742f984d1a4252c80a17dd5603bd6da8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2021-02-22T14:18:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T21:56:12.000Z", "avg_line_length": 42.2133333333, "max_line_length": 178, "alphanum_fraction": 0.614813645, "num_tokens": 2301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.4177545735822274}}
{"text": "%\n%\n\n\\chapter{Examples of {\\smart} Applications} \\label{SEC:Examples}\n\\markboth{EXAMPLES OF SMART APPLICATIONS}{}\n\nThis chapter contains a variety of examples to illustrate the various\ncapabilities available in {\\smart}, and how to use them.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{A fixpoint iteration with repeated submodels}\n\nFixpoint iteration schemes can become quite complex.\nIn the following code, two copies of the same Petri net \\Code{b} are used,\nwith different parameters, together with a second Petri net, \\Code{d}.\nThis situation might arise when a particular Petri net models part of a system\nwhich is replicated multiple times with different characteristics.\n%\n\\lstinputlisting[firstline=3]{examples/conv_pns.sm}\n%\nAlthough multiple use of the same Petri net is convenient from the\nuser's point of view, it might actually cause {\\smart} to perform extra work.\nThis is because {\\smart} remembers important, and large, data structures\nthat it must build to compute a measure for a given high-level model,\nso that the data structures can be reused for successive measures.\nFor example, the statement\n\\begin{lstlisting}\nreal x3 := d(i1:=x1, i2:=x2).o1;\n\\end{lstlisting}\ncauses the state space and stationary solution of Petri net \\Code{d}\nto be computed, while statement\n\\begin{lstlisting}\nreal x4 := d(i1:=x1, i2:=x2).o2;\n\\end{lstlisting}\nsimply reuses the previous computation and just computes a different measure.\nHowever, when a model is parameterized, only the data structures\ncorresponding to parameters used in the latest call are kept,\nto avoid excessive memory consumption.\nThus, if an iteration of the \\Code{converge} statement\ncalls \\Code{b(i1:=x3).o1} and \\Code{b(i1:=x4).o1} with \\Code{x3} and\n\\Code{x4} set to different values, the next iteration will\nnot be able to reuse work even if the value of \\Code{x3}, \\Code{x4},\nor both, are the same as in the previous iteration.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Finding the optimal value of a function}\n\nThe \\Code{converge} statement in {\\smart} can be used to obtain the optimal\nvalue of a convex or concave function (or a local optimum for any function\nwith continuous first derivatives).\nThe idea is that, given the values $f_1$, $f_2$, $f_3$, and $f_4$\nof a convex function at four distinct points $x_1 < x_2 < x_3 < x_4$,\nwe can discard the leftmost or the rightmost point (or the two leftmost\nor righmost points if the values are in monotonic order), based on these values;\nwe can then iterate the search within the remaining interval,\nand stop when the four points and the four values are sufficiently close.\nThe following code illustrates how to do this in {\\smart}:\n%\n\\lstinputlisting[firstline=3]{examples/maxima.sm}\n%\nNote that option \\Code{UseCurrent} must be set to \\Code{false} for this\nscheme to work properly, otherwise the values of $x_2$, $x_3$, and $x_4$\nwould be updated using the new values computed for $x_1$, $x_2$, and $x_3$,\nwhich is incorrect.\n\nOf course, instead of using this scheme to discover that the maximum value\nof $x-x^2$ over the interval $[0,1]$ is $0.25$ and is achieved at $x=0.5$\n(or a close approximation of that, since this a numerical iterative method),\nwe can use it, for example, to find the time at which a given measure is\nmaximized in a Petri net model or the value of a rate for which the probability\nof absorption is minimized in a continuous-time model.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Dining philosophers}\n\n\n\nThe dining philosopher model \\cite{Pastor1994} is composed of $N$ subnets equal\nto the one shown in Fig.~\\ref{FIG:dining}.\nThe net represents a philosopher and the philosopher's right fork.\nThe philosopher's left fork, represented by\nthe dotted place $\\mathit{Fork}_{(i+1) \\bmod N}$, is part of the\nsubnet for the next philosopher; it\nis depicted to illustrate how the subnets interact.\nThe corresponding {\\smart} code is as follows:\n%\n\\lstinputlisting[firstline=3]{examples/phils_ex1.sm}\n%\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=1]{figures/phils.pdf}\n  \\caption{Model for a single dining philosopher.}\n  \\label{FIG:dining}\n\\end{figure}\n\n\n\\begin{comment}\n\nIf we wanted to use an advanced symbolic method, we could request this with an\noption statement, which must appear before the two \\Code{print} statements.\nHowever, this also requires to partition the model.\nWe could do so by assigning \\Code{M} philosophers per level:\n\\begin{code}\n\\begin{verbatim}\nspn phils(int N, int M) := {\n  for (int i in {1..N}) {\n    ...\n    partition(1+div(i,M):Idle[i]:WaitL[i]:WaitR[i]:HasL[i]:HasR[i]:Fork[i]);\n  }\n  for (int i in {1..N}) {\n    ...\n  }\n  ...\n};\n# StateStorage MDD_SATURATION\nint N := read_int(\"number of philosophers\");\nint M := read_int(\"number of philosophers per level\");\nprint(\"Number of reachable states: \", phils(N,M).ns, \".\\n\");\nprint(\"Number of state-to-state transitions: \", phils(N,M).na, \".\\n\");\n\\end{verbatim}\n\\end{code}\nOf course, if \\Code{N} is not a multiple of \\Code{M}, the last\nlevel will have fewer than \\Code{M} philosophers.\nAlso, a partition must define at least two levels, thus\n\\Code{N} must be strictly greater than \\Code{M}.\nHaving more philosophers per level decreases the number of levels in the\nMDD, but increases the size of the local state spaces, hence of the\nMDD nodes.\n\nIf we had used a method requiring pregeneration of the local state\nspaces, we would have to add the statement\n\\begin{code}\n\\begin{verbatim}\n    inhibit(Fork[1+mod(i,N)]:Rel[i], HasR[1+mod(i,N)]:Rel[i]);\n\\end{verbatim}\n\\end{code}\nin the second \\Code{for} loop, to ensure that these local state spaces\nare finite.\n\n\\end{comment}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{A flexible manufacturing system}\n\nThe Petri net \\cite{1991PNPM-Decomposition} in Fig.~\\ref{FIG:fms}\nmodels a flexible manufacturing system (FMS).\nThis model is parameterized by the initial number $N$ of tokens in\n$P_1$, $P_2$, and $P_3$.\nThe {\\smart} description for this net is:\n%\n\\lstinputlisting[firstline=3]{examples/fms_ex1.sm}\n%\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=0.5]{figures/FMS-smartman.pdf}\n  \\caption{A flexible manufacturing system.}\n  \\label{FIG:fms}\n\\end{figure}\n\n\n\\begin{comment}\n\nHad we wanted to use a structural solution approach, we could have\npartitioned the model with the statement\n\\begin{code}\n\\begin{verbatim}\npartition(P1:P1wM1:P1M1:M1:P1d:P1s, P12s:P12M3:M3:P12wM3:P12:P1wP2:P2wP1,\n  P2:P2wM2:P2M2:M2:P2d:P2s, P3:P3M2:P3s);\n\\end{verbatim}\n\\end{code}\n(which defines four submodels) and used the options\n\\begin{code}\n\\begin{verbatim}\n# StateStorage MULTI_LEVEL_AVL\n# MarkovStorage MATRIX_DIAGRAM_GENERAL\n\\end{verbatim}\n\\end{code}\nNote, however, that the usually more efficient methods\n\\begin{code}\n\\begin{verbatim}\n# StateStorage MDD_SATURATION\n# MarkovStorage MATRIX_DIAGRAM_KRONECKER\n\\end{verbatim}\n\\end{code}\ncannot be used with the given partition, because some immediate transitions,\nsuch as \\Code{tP1j}, are synchronizing (i.e., they affect multiple submodels).\n\n%We partition the model into 19 levels obtained by assigning\n%each place to a different level, with the exception of\n%the complementary places $M_1$, $M_2$, and $M_3$, placed in the same level\n%as the places $P_1M_1$, $P_2M_2$, and $P_{12}M_3$, respectively.\n\n\\end{comment}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Slotted ring}\n\nFig.~\\ref{FIG:slotted} shows the Petri net for a single node of a slotted\nring network protocol \\cite{Pastor1994}.\nThe overall model is composed of $N$\nsuch subnets connected by merging transitions\n(i.e., $\\mathit{Free}_{(i+1) \\bmod N}$ and $\\mathit{Used}_{(i+1) \\bmod N}$\nreally belong to the ``next'' subnet).\nThe following {\\smart} code shows a decomposition where each\nnode of the ring is in a different level, and the requested\nmeasure is simply the number of states.\n%\n\\lstinputlisting[firstline=3]{examples/slot.sm}\n%\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=0.5]{figures/slot.pdf}\n  \\caption{Model of a slotted ring.}\n  \\label{FIG:slotted}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{A Kanban system}\n\nThis model \\cite{1996WMPN-SNSkanban}, shown in Fig.~\\ref{FIG:kanban},\nis parameterized by the number $N$ of tokens initially\nin $p_{1}$, $p_{2}$, $p_{3}$, and $p_{4}$.\nThe following code shows a partition into four levels, one per kanban station.\nThe output measure is the number of arcs in the state-to-state transition\nmatrix for $N$ varying from $1$ to a maximum specified at runtime.\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=1]{figures/kanban.pdf}\n  \\caption{A kanban system.}\n  \\label{FIG:kanban}\n\\end{figure}\n%\n\\lstinputlisting[firstline=3]{examples/kanban.sm}\n%\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Randomized leader election protocol}\n\nThe randomized asynchronous leader election protocol in \\cite{DolevKR82}\nsolves the following problem: given a ring of $N$ processors, the\nparticipants are required to designate a unique processor as leader by\nsending messages around the ring. The ring is unidirectional, meaning that\nthe processes send messages to their unique successor (e.g. the one to the\nright), and receive messages from their unique predecessor. It is known that\nif the processors are indistinguishable (no unique identifiers are\nassigned), then there is no deterministic algorithm to solve the problem.\n\nThe randomized algorithm works in phases. At the beginning of every round,\neach process flips a coin to decide whether it will continue running for\nelection or not. Initially all processes are valid candidates. After\nchoosing a value ($0 = $ don't run this round, $1 = $ run), this is\ncommunicated to the neighbour to the right. A process is eliminated from the\nrace only if it chose not to run and it's predecessor chose to run. After\nbeing eliminated from the race, a process never becomes eligible again (it\nenters the inactive state), and it is used only to relay messages between\nactive nodes around the ring. They do no initiate any communication.\nTermination is detected by the active processes (at least one active node\nexists at all times) by sending a token around the ring to count the\ninactive nodes. The process that receives its own token with count $N-1$ is\nthe elected leader.\n\nIn our model, each processes has $5$ state variables:\n\\begin{lstlisting}\nstatus[i]       : {start, wait, active, inactive, leader};      // init start\npreference[i]   : {0, 1};                                       // init 0\ncounter[i]      : {0..N-1};                                     // init 0\nsent[i]         : {none, pref, counter};                        // init none\nrecv[i]         : {none, pref, counter};                        // init none\n\\end{lstlisting}\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[scale=0.5]{figures/leaderchart.pdf}\n  \\caption{State transition chart for the \\Code{status} variable.}\n  \\label{FIG:leaderchart}\n\\end{figure}\n\n\\noindent The state-transition diagram for the \\Code{status} of a process is\nshown in Figure \\ref{FIG:leaderchart}.\n\n\\IGNORE{\nThe Petri Net model is shown is Figure \\ref{FIG:leaderfig}\n\\begin{figure}\n  \\CENTERPSSCALE{leaderfig}{0.5}\n  \\caption{Petri net model: the subnet of process $i$.}\n  \\label{FIG:leaderfig}\n\\end{figure}\n}\n\n\\noindent The SMART code for this model is listed below:\n%\n\\lstinputlisting[firstline=3]{examples/leader.sm}\n%\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{A round--robin mutual exclusion protocol}\n\n\\begin{comment}\nThe protocol regulates the access to a shared resource (e.g. a communication\nchannel) for a ring of $N$ processors. The resource manager gives permission\nto use the channel to each process in order, by moving a token around the\nring. When a process has the token, it reads in a message from the channel and\nstores it in its own buffer. It can then release the token to the next processor \nbefore reading the contents of the buffer, or read the buffer first and then \nsend the token to the neighbour.\n\nFigure \\ref{FIG:robinfig} shows the subnet for process $i$. \nEach subnet is initially marked with one token in place $\\id{wait}_i$, \nexcept for process $0$ which starts with one token in $\\id{req}_i$, meaning \nthat it is the first process to have access when the protocol starts.\n\n\\begin{figure}\n  \\CENTERPSSCALE{robinfig}{0.5}\n  \\caption{The round--robin mutual exclusion.}\n  \\label{FIG:robinfig}\n\\end{figure}\n\n\\begin{code}\n\\begin{verbatim}\nspn robin(int N) := {\n  place Res;\n  partition(1:Res);\n  for (int i in {0..N-1}) {\n    place\n        R[i], bufidle[i], buffull[i],\n        pwait[i], pask[i], pok[i], pload[i], psend[i];\n    trans\n        task[i], tbuf[i], t1load[i], t2load[i], t1send[i], t2send[i];\n    partition(\n        i+2:bufidle[i]:buffull[i]:pwait[i]:pask[i]:pok[i]:pload[i]:psend[i],\n        1:R[i]);\n    firing(task[i]:expo(1.0), tbuf[i]:expo(1.0), t1load[i]:expo(1.0),\n        t1send[i]:expo(1.0), t2load[i]:expo(1.0), t2send[i]:expo(1.0));\n  }\n  for (int i in {0..N-1}) {\n    arcs(Res:task[i], pask[i]:task[i], task[i]:R[i], task[i]:pok[i],\n        R[i]:tbuf[i], bufidle[i]:tbuf[i], tbuf[i]:buffull[i], tbuf[i]:Res,\n        buffull[i]:t1load[i], pok[i]:t1load[i], t1load[i]:bufidle[i], t1load[i]:psend[i],\n        buffull[i]:t2load[i], pload[i]:t2load[i], t2load[i]:bufidle[i], t2load[i]:pwait[i],\n        pok[i]:t1send[i], pwait[mod(i+1,N)]:t1send[i], \n        t1send[i]:pload[i], t1send[i]:pask[mod(i+1,N)],\n        psend[i]:t2send[i], pwait[mod(i+1,N)]:t2send[i], \n        t2send[i]:pwait[i], t2send[i]:pask[mod(i+1,N)]);\n  }\n  init(Res:1, pask[0]:1);\n  for (int i in {1..N-1}) {init (pwait[i]:1);}\n  for (int i in {0..N-1}) {init(bufidle[i]:1);}\n}\n\\end{verbatim}\n\\end{code}\n\n\\end{comment}\n", "meta": {"hexsha": "65733abada4cf1188d1922f0c2daf7022d203d1e", "size": 13931, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/examples.tex", "max_stars_repo_name": "asminer/smart", "max_stars_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2018-05-30T23:02:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-19T07:30:46.000Z", "max_issues_repo_path": "manual/examples.tex", "max_issues_repo_name": "asminer/smart", "max_issues_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manual/examples.tex", "max_forks_repo_name": "asminer/smart", "max_forks_repo_head_hexsha": "269747c4578b670e5c3973f93a1e6ec71d95be78", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-07-13T18:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-12T17:54:02.000Z", "avg_line_length": 38.5900277008, "max_line_length": 91, "alphanum_fraction": 0.6944225109, "num_tokens": 3824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.41775456958798407}}
{"text": "\\chapter{QCD primer}\n\\label{chap:qcd}\n\nQuantum chromodynamics is the theory of strong interactions\\footnote{A brief historical review about the development of {\\sffamily QCD} may be found at \\cite{historyqcd}.}. It aims to describe the interactions between elementary constituents, namely the quarks\\footnote{The quarks were firstly predicted in Gell-Mann's Eightfold Way \\cite{gellmann}.}, mediated by the carriers of the color force, the gluons.\n\nThe existence of color charge was proposed as an additional quantum number which would solve the violation of Pauli's exclusion principle for some particular baryons\\footnote{For example, $\\Delta^{++}$, which consists of three up quarks.}. Since the quarks were never experimentally evidenced, it was proposed that the strong interaction constrains the free particles to only exist in color neutral states. This particularity of {\\sffamily QCD} is known as color confinement. Nevertheless, in the partonic picture\\footnote{Feynman proposed that high energy nuclei are made of elementary constituents, generically called partons \\cite{partons}.}, deep inelastic scattering\\footnote{{\\sffamily DIS} is a process during which the structure of a hadron may be probed via interaction with, in general, a lepton.} experiments between an electron and a proton confirmed the already predicted Bjorken scaling\\footnote{Bjorken deduced an expression for the cross-section of the electron by imagining that it interacts electromagnetically with each parton from the proton \\cite{bjorkenimf}.} of the electrons' differential cross-section.\n\nIn essence, {\\sffamily QCD} is an extension of the original $\\textsf{SU}(2)$ gauge theory of Yang and Mills \\cite{yangmills} to local non-Abelian $\\textsf{SU}(3)$ gauge transformations.\n\n\\section{Field content}\nFollowing textbook expositions \\cite{maggiore, peskin, greiner}, the {\\sffamily QCD} Lagrangian $\\mathcal{L}$ is constructed from symmetry principles, namely $\\textsf{SO}(1,3)$ Lorentz invariance and local gauge invariance under $\\textsf{SU}(3)$. The fields should transform according to irreducible representations of these groups. The quark content of the Lagrangian is described by the quark and anti-quark fields $\\psi_{\\alpha,i,f}(x)$ and $\\overline{\\psi}_{\\alpha,i,f}(x)$. They are Dirac spinors (spinorial index $\\alpha$), transform according to the fundamental representation of $\\textsf{SU}(3)$ (color index $i=1,2,3$ or red, green, blue) and come in different flavours (flavour index $f=\\overline{1,N_f}$ or up, down, strange, charm, bottom, up). The gluon fields $A_a^\\mu(x)$ are Lorentz vectors and each correspond to a generator $t^a$ ($a=\\overline{1,8}$) which, in the fundamental representation, is given by the Gell-Mann matrices $t^a=\\lambda^a/2$.\n\n\\section{Gauge transformations} \nThe quark and anti-quark fields must be invariant under local $\\textsf{SU}(3)$ gauge transformations\\footnote{For simplicity, all the field indices will be dropped in the following computations.}\n\\shadedeq{\n    \\psi(x)\\mapsto\\textsf{U}(x)\\psi(x), \\quad \\overline{\\psi}\\mapsto\\overline{\\psi}(x)\\textsf{U}^\\dagger(x) \n}\nwith the group transformation expressible, via exponentiation, from the Lie algebra generators, with space-time dependent group parameters $\\varepsilon^a(x)$, as \n\\boxedeqlabel{gaugetransf}{\n    \\textsf{U}(x)=\\exp{i\\sum_a\\varepsilon^a(x)t^a}\n}\nThe gauge fields\\footnote{For each algebra element $t^a$, one may introduce a gauge field $A_a^\\mu$. These may be then used to construct a Lie-algebra valued gauge potential $A^\\mu$. This potential depends on the chosen representation.} $A_\\mu(x)=\\sum\\limits_a A^a_\\mu(x)t^a$ must transform according to\n\\boxedeqlabel{gaugefields}{\n    A_\\mu(x)\\mapsto\\textsf{U}(x)A_\\mu(x)\\textsf{U}^\\dagger(x)+\\frac{i}{g}\\textsf{U}(x)\\big[\\partial_\\mu\\textsf{U}^\\dagger(x)\\big]\n}\nwhere $g$ denotes the coupling constant. It is important to notice that one may generate gluon fields out of a null one, that is $A_\\mu=0$ by applying a local gauge transformation. Such field configurations take the form\n\\begin{equation*}\n    A_\\mu^{\\text{pure}}=\\frac{i}{g}\\textsf{U}\\big(\\partial_\\mu\\textsf{U}^\\dagger\\big)\n\\end{equation*}\nand are called pure gauge fields \\cite{gelisqft,eichmann}. The corresponding field strength tensor is null $F_{\\mu\\nu}^{\\text{pure}}=0$.\n\nOne may introduce the covariant derivative\\footnote{The covariant derivative has an elegant geometrical interpretation \\cite{torre}: it represents the rate of change when fields from different space-time points are parallel transported along a given path. During this procedure, they are being aligned such that they may be properly compared. The corresponding connection is actually the gauge field.}\n\\begin{equation*}\n    \\textsf{D}_\\mu=\\partial_\\mu-igA_\\mu. \n\\end{equation*}\nFurther, one may define the field strength tensor as the commutator between covariant derivatives\\footnote{Since it arises as a commutator between covariant derivatives, which describe the parallel transport, the field strength tensor may be interpreted as a measure of the path dependence of parallel transport. For this reason, it is also referred to as the curvature \\cite{torre}.}\n\\begin{equation*}\n    F_{\\mu\\nu}=\\frac{i}{g}\\big[\\textsf{D}_\\mu,\\textsf{D}_\\nu\\big],\n\\end{equation*}\nwhich yields an expression in terms of gauge fields\n\\shadedeq{\n    F_{\\mu\\nu}=\\partial_\\mu A_\\nu-\\partial_\\nu A_\\mu-ig\\big[A_\\mu,A_\\nu\\big]\n}\nor equivalently, by color components $F_{\\mu\\nu}=F_{\\mu\\nu}^at^a$, as\n\\begin{equation*}\n    F_{\\mu\\nu}^a=\\partial_\\mu A_\\nu^a-\\partial_\\nu A_\\nu^a+gf^{abc}A_\\mu^bA_\\nu^c,\n\\end{equation*}\nwhere $f^{abc}$ are the structure constants of the Lie algebra $\\mathfrak{su}(3)$. The last term from the above equation, when plugged in the Lagrangian, will give rise to gluonic self-interactions, a particular feature of QCD. The field strength tensor gauge transforms in the usual manner as\n\\shadedeq{\n    F_{\\mu\\nu}(x)\\mapsto \\textsf{U}(x)F_{\\mu\\nu}(x)\\textsf{U}^\\dagger(x)\n}\n\n\\section{QCD Lagrangian} \nOne may now proceed to constructing the Lagrangian. The quark content is that of a free fermionic Lagrangian\\footnote{After replacing the partial derivative with the covariant derivative, the Lagrangian will also contain an interaction term\n\\begin{equation*}\n    \\mathcal{L}_{\\textsf{int}}=g \\overline{\\psi} \\gamma^\\mu A_\\mu^a t^a \\psi.\n\\end{equation*}}, but built with covariant derivatives, in order to satisfy gauge invariance\n\\begin{equation*}\n    \\mathcal{L}_{\\textsf{quarks}}=\\overline{\\psi}(x)\\big(i\\slashed{\\textsf{D}}-\\textsf{M}\\big)\\psi(x),\n\\end{equation*}\nwhere $\\textsf{M}=\\textsf{Diag}\\left\\{m_1,\\ldots,m_{N_f}\\right\\}$ is the diagonal quark mass matrix in flavour space\\footnote{In the Standard Model, the quark mass matrix is no longer diagonal. After spontaneous symmetry breaking, the mixing between different flavoured quark masses is given by the {\\sffamily CKM} matrix \\cite{pdg}.}. \n\nThe dynamics of the gluon fields is described by the following construction\\footnote{It is important to notice that such a construction contains not only standard kinetic terms but also interaction vertices with three gluons, which are proportional to $g$ and four gluons, proportional to $g^2$.}\n\\begin{equation*}\n    \\mathcal{L}_{\\textsf{gluons}}=-\\frac{1}{2}\\textsf{Tr}\\left\\{F_{\\mu\\nu}F^{\\mu\\nu}\\right\\},\n\\end{equation*}\nwhere the color tracing over the contraction of field strength tensors assured gauge invariance. Equivalently, one may rewrite the above expression in terms of color components as\n\\begin{equation*}\n    \\mathcal{L}_{\\textsf{gluons}}=-\\frac{1}{4}F_{\\mu\\nu}^aF^{a,\\mu\\nu},\n\\end{equation*}\nvalid in the fundamental representation, where $\\textsf{Tr}\\left\\{t^at^b\\right\\}=\\delta^{ab}/2$. Therefore, the {\\sffamily QCD} Lagrangian takes the form\n\\boxedeqlabel{qcd6}{\n    \\mathcal{L}_{\\textsf{QCD}}=\\overline{\\psi}(x)\\big(i\\slashed{\\textsf{D}}-\\textsf{M}\\big)\\psi(x)-\\frac{1}{4}F_{\\mu\\nu}^aF^{a,\\mu\\nu}\n}\n\nThe corresponding Yang-Mills action expressed in flat coordinates is given by\n\\begin{align}\\label{yangmills}\n    \\textsf{S}=\\int\\mathrm{d}^4x\\left(-\\frac{1}{2}\\textsf{Tr}\\left\\{F_{\\mu\\nu}F^{\\mu\\nu}\\right\\}\\right),\n\\end{align}\n\n\\section{Field equations} \nThe variational derivatives with respect to the color spinor fields give the colored Dirac equations\n\\begin{equation*}\n    (i\\slashed{\\textsf{D}}-\\textsf{M})\\psi=0,    \n\\end{equation*}\nand similarly for the anti-quark fields\n\\begin{equation*}\n    \\overline{\\psi}(i\\overleftarrow{\\slashed{\\textsf{D}}}-\\textsf{M})=0.    \n\\end{equation*}\nThe Euler-Lagrange equations corresponding to the gluon fields yield the Yang-Mills equations, or equivalently, colored Maxwell equations\\footnote{There is an additional equation, called the Bianchi identity, which follows from the definition and properties of $F_{\\mu\\nu}$. It may be expressed as \\cite{tong}\n\\begin{equation*}\n    \\textsf{D}_\\mu^{\\phantom{*}*}F^{\\mu\\nu}=0,\n\\end{equation*}\nwhere we introduced the dual field strength tensor as\n\\begin{equation*}\n    ^*F^{\\mu\\nu}=\\frac{1}{2}\\epsilon^{\\mu\\nu\\rho\\sigma}F_{\\rho\\sigma}.\n\\end{equation*}}\n\\shadedeq{\n    \\textsf{D}_\\nu F^{\\nu\\mu}=gJ^\\mu\n}\nin which $J^\\mu=\\sum\\limits_a J^{a,\\mu} t^a$ with $J^{a,\\mu}=\\overline{\\psi}\\gamma^\\nu t^a\\psi$ being the color current. The color current is covariantly conserved $\\textsf{D}_\\mu J^\\mu=0$.", "meta": {"hexsha": "cdc254794e8fe9bdd3f1d2641238edc69987e91e", "size": 9302, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FPUB thesis template/qcd.tex", "max_stars_repo_name": "ctp-fpub/LaTeXTemplates", "max_stars_repo_head_hexsha": "8f01709658c05a2271bfb88431dbfc7562454c6f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FPUB thesis template/qcd.tex", "max_issues_repo_name": "ctp-fpub/LaTeXTemplates", "max_issues_repo_head_hexsha": "8f01709658c05a2271bfb88431dbfc7562454c6f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-04-04T17:37:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-04T17:37:37.000Z", "max_forks_repo_path": "FPUB thesis template/qcd.tex", "max_forks_repo_name": "ctp-fpub/LaTeXTemplates", "max_forks_repo_head_hexsha": "8f01709658c05a2271bfb88431dbfc7562454c6f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-04-02T14:54:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-04T16:42:49.000Z", "avg_line_length": 92.099009901, "max_line_length": 1127, "alphanum_fraction": 0.7543539024, "num_tokens": 2740, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4177211413211117}}
{"text": "\\section{Hints on Using the Prover Effectively}\n\n\\begin{frame}\n  \\frametitle{Control the Size of Formulas}\n\n  \\begin{itemize}\n  \\item \\tc{dkblue}{Proof obligations are often large}\n\n    \\begin{itemize}\n    \\o long definitions of actions and invariants\n    \\o \\kw{let} constructions add to complexity when expanded\n    \\end{itemize}\n\n  \\oo \\tc{dkblue}{The backend provers are easily overwhelmed by large formulas}\n\n    \\begin{itemize}\n    \\o may work on top-level operators or deeply inside a long formula\n    \\o even simple proof steps may take an extraordinate amount of time\n    \\end{itemize}\n\n  \\oo \\alert{Use local definitions and \\HIDE\\ them when unnecessary}\n\n    \\begin{itemize}\n    \\o prove facts about a \\kw{let}-bound operator, then \\HIDE\\ it\n    \\end{itemize}\n  \\end{itemize}\n\n  \\vfill\\vfill\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example: Controlling the Size of Expressions}\n\n  \\qquad\\begin{tlablock}\n    \\LEMMA\\\n    \\begin{noj2}\n      & \\begin{conj}\n          x \\in SomeVeryBigExpression\\\\\n          y \\in AnotherBigExpression\n        \\end{conj}\\\\\n      \\biimplies &\n        \\begin{conj}\n            y \\in AnotherBigExpression\\\\\n            x \\in SomeVeryBigExpression\n        \\end{conj}\n\\pause\n        \\hspace{1cm}\\raisebox{0cm}[0pt][0pt]{\\begin{minipage}{3cm}\n          \\begin{beamercolorbox}[rounded=true,shadow=true]{postit}\\footnotesize\n            \\OBVIOUS\\ may take\\\\forever here\n          \\end{beamercolorbox}\n        \\end{minipage}}\n    \\end{noj2}\\\\\n\\pause\n    \\ps{1}{.}\\ \\ \\ \\DEFINE\\ S\\ \\deq\\ SomeVeryBigExpression\\\\\n    \\ps{1}{.}\\ \\ \\ \\DEFINE\\ T\\ \\deq\\ AnotherBigExpression\\\\\n    \\ps{1}{1.}\\ S = SomeVeryBigExpression\\\\\n    \\quad\\OBVIOUS\\\\\n    \\ps{1}{2.}\\ T = AnotherBigExpression\\\\\n    \\quad\\OBVIOUS\\\\\n    \\ps{1}{.}\\ \\ \\ \\HIDE\\ \\DEF\\ S,\\ T\\\\\n    \\ps{1}{3.}\\ \n      \\begin{noj2}\n        & x \\in S \\land y \\in T\\\\\n        \\biimplies & y \\in T \\land x \\in S\n      \\end{noj2}\\\\\n    \\quad\\OBVIOUS\\\\\n    \\ps{1}{4.}\\ \\QED\\qquad\\BY\\ \\ps{1}{1},\\ \\ps{1}{2},\\ \\ps{1}{3}\n  \\end{tlablock}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Avoid Circular Rewrites}\n\n  \\begin{itemize}\n  \\item \\tc{dkblue}{Rewriting is often effective for reasoning about equalities}\n\n    \\begin{itemize}\n    \\o idea: replace left-hand side of equality by right-hand side\n    \\o Isabelle's automatic tactic are based on rewriting\n    \\o for example, use\\ \\ \\tc{dkgreen}{$x' = x-y \\land y'=y$}\\ \\ to eliminate $x'$ and $y'$    \\end{itemize}\n\n\\pause\n\n  \\oo \\tc{dkblue}{Must make sure that rewriting terminates}\n\n    \\begin{itemize}\n    \\o consider\\ \\ \\tc{dkgreen}{$s = f(t) \\land t = g(s)$}\n    \\o Isabelle attempts to reject circular sets of equations\n    \\o if rejected, proof may get stuck\n    \\o if not rejected, proof may never terminate\n    \\end{itemize}\n\n  \\oo \\alert{Use local definitions, and \\HIDE\\ them to break loops}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Circular Rewrites: Example}\n\n  \\qquad\\begin{tlablock}\n    \\ps{4}{5.}\\ r.name = \\str{xyz}\\\\\n    \\quad\\ps{5}{1.}\\ r = [name \\mapsto \"xyz\",\\ value \\mapsto \\alt<1>{r}{\\alert{r}}.value]\\\\\n    \\quad\\quad\\BY\\ \\ps{2}{2}\\\\\n    \\quad\\ps{5}{2.}\\ \\QED\\\\\n    \\quad\\quad\\BY\\ \\ps{5}{1}\n  \\end{tlablock}\n\n\\pause\n\n  \\vfill\\vfill\n\n  \\qquad\\alert{The equation in step $\\ps{5}{1}$ is circular!}\n\n  \\vfill\\vfill\n\n\\pause\n\n  \\qquad\\begin{tlablock}\n    \\ps{4}{5.}\\ r.name = \\str{xyz}\\\\\n    \\quad\\ps{5}{}\\ \\ \\ \\DEFINE\\ rval\\ \\deq\\ r.value\\\\\n    \\quad\\ps{5}{1.}\\ r = [name \\mapsto \"xyz\",\\ value \\mapsto rval]\\\\\n    \\quad\\quad\\BY\\ \\ps{2}{2}\\\\\n    \\quad\\ps{5}{}\\ \\ \\ \\HIDE\\ \\DEF\\ rval\\\\\n    \\quad\\ps{5}{2.}\\ \\QED\\\\\n    \\quad\\quad\\BY\\ \\ps{5}{1}\n  \\end{tlablock}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Establishing Facts About \\CHOOSE}\n\n  \\qquad\\begin{tlablock}\n    \\DEFINE\\ m\\ \\deq\\ \\CHOOSE x \\in S : P(x)\\\\\n    \\DEFINE\\ NoValue\\ \\deq\\ \\CHOOSE x : x \\notin Value\n  \\end{tlablock}\n\n  \\begin{itemize}\n  \\oo \\tc{dkblue}{How to prove a property $Q(m)$ ?}\n\n    \\begin{itemize}\n    \\o \\CHOOSE\\ always denotes some value, even if $P(x)$ holds for no $x \\in S$\n    \\end{itemize}\n\n\\pause\n\n  \\oo \\tc{dkblue}{In practice, must establish the two following facts}\n\n    \\begin{itemize}\n    \\o $\\E x \\in S : P(x)$\n    \\o $\\A x \\in S : P(x) \\implies Q(x)$\n    \\o \\tlaps\\ will then deduce $Q(m)$\n    \\end{itemize}\n\n\\pause\n\n  \\oo \\tc{dkblue}{Important special case: ``null'' values}\n\n    \\begin{itemize}\n    \\o existence of such a value follows from the library theorem\n\n      \\medskip\n\n      \\begin{tlablock}\n        NoSetContainsEverything\\ \\deq\\ \\A S : \\E x : x \\notin S\n      \\end{tlablock}\n    \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{It's Easier To Prove Something If It's True}\n\n  \\begin{itemize}\n  \\item \\tc{dkblue}{All specifications initially contain mistakes}\n\n    \\begin{itemize}\n    \\o errors range from typos to misunderstandings to genuine bugs\n    \\o formal mathematical definitions are hard to get right\n    \\end{itemize}\n\n  \\oo \\tc{dkblue}{\\tlaps\\ is not good at catching specification errors}\n\n    \\begin{itemize}\n    \\o if you are stuck on a proof, is it you, the prover or the specification?\n    \\o even with structured proofs, complexity quickly gets out of hand\n    \\end{itemize}\n\n  \\oo \\tc{dkblue}{Extensively debug your specifications using \\tlc}\n\n    \\begin{itemize}\n    \\o almost all bugs manifest themselves on small instances\n    \\o run \\tlc\\ on many properties and inspect the counter-examples\n    \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Focus On The Theorems You Are Interested In}\n\n  \\begin{itemize}\n  \\item \\tc{dkblue}{\\tlaps\\ currently has limited support for theories}\n\n    \\begin{itemize}\n    \\o set theory and functions are fully supported\n    \\o decision procedure for elementary integer arithmetic\n    \\o very rudimentary support for sequences\n    \\end{itemize}\n\n\\pause\n\n  \\oo \\tc{dkblue}{State facts about ``data'' as assumptions}\n\n    \\begin{itemize}\n    \\o do you want to verify an algorithm or basic mathematics?\n    \\o but --- isn't that dangerous?\n    \\o it is, but you can validate many assumptions using \\tlc\n    \\o override infinite sets with finite ones in the model, e.g.\\ \\ \\tc{dkgreen}{$Nat\\ \\deq\\ 0..50$}\n    \\end{itemize}\n\n\\pause\n\n  \\oo \\alert{Theory support will improve slowly and your help is welcome}\n  \\end{itemize}\n\\end{frame}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"tutorial\"\n%%% End: \n", "meta": {"hexsha": "75014f6a74f038b41511ae3bef5dae1ee8634fda", "size": 6350, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/presentations/2010-ifm/hints.tex", "max_stars_repo_name": "damiendoligez/tlapm", "max_stars_repo_head_hexsha": "13a1993263642092a521ac046c11e3cb5fbcbc8b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 31, "max_stars_repo_stars_event_min_datetime": "2016-08-16T14:58:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-19T18:38:07.000Z", "max_issues_repo_path": "doc/presentations/2010-ifm/hints.tex", "max_issues_repo_name": "damiendoligez/tlapm", "max_issues_repo_head_hexsha": "13a1993263642092a521ac046c11e3cb5fbcbc8b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 49, "max_issues_repo_issues_event_min_datetime": "2020-03-04T18:13:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-07T17:43:24.000Z", "max_forks_repo_path": "doc/presentations/2010-ifm/hints.tex", "max_forks_repo_name": "damiendoligez/tlapm", "max_forks_repo_head_hexsha": "13a1993263642092a521ac046c11e3cb5fbcbc8b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2020-02-26T19:58:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-12T22:18:25.000Z", "avg_line_length": 27.6086956522, "max_line_length": 109, "alphanum_fraction": 0.6371653543, "num_tokens": 2114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.4177211413211116}}
{"text": "\\chapter[Detailed examples of tactics]{Detailed examples of tactics\\label{Tactics-examples}}\n\nThis chapter presents detailed examples of certain tactics, to\nillustrate their behavior.\n\n\\section[\\tt dependent induction]{\\tt dependent induction\\label{dependent-induction-example}}\n\\def\\depind{{\\tt dependent induction}~}\n\\def\\depdestr{{\\tt dependent destruction}~}\n\nThe tactics \\depind and \\depdestr are another solution for inverting\ninductive predicate instances and potentially doing induction at the\nsame time. It is based on the \\texttt{BasicElim} tactic of Conor McBride which\nworks by abstracting each argument of an inductive instance by a variable\nand constraining it by equalities afterwards. This way, the usual \n{\\tt induction} and {\\tt destruct} tactics can be applied to the\nabstracted instance and after simplification of the equalities we get\nthe expected goals.\n\nThe abstracting tactic is called {\\tt generalize\\_eqs} and it takes as\nargument an hypothesis to generalize. It uses the {\\tt JMeq} datatype\ndefined in {\\tt Coq.Logic.JMeq}, hence we need to require it before.\nFor example, revisiting the first example of the inversion documentation above:\n\n\\begin{coq_example*}\nRequire Import Coq.Logic.JMeq.\n\\end{coq_example*}\n\\begin{coq_eval}\nRequire Import Coq.Program.Equality.\n\\end{coq_eval}\n\n\\begin{coq_eval}\nInductive Le : nat -> nat -> Set :=\n  | LeO : forall n:nat, Le 0 n\n  | LeS : forall n m:nat, Le n m -> Le (S n) (S m).\nVariable P : nat -> nat -> Prop.\nVariable Q : forall n m:nat, Le n m -> Prop.\n\\end{coq_eval}\n\n\\begin{coq_example*}\nGoal forall n m:nat, Le (S n) m -> P n m.\nintros n m H.\n\\end{coq_example*}\n\\begin{coq_example}\ngeneralize_eqs H.\n\\end{coq_example}\n\nThe index {\\tt S n} gets abstracted by a variable here, but a\ncorresponding equality is added under the abstract instance so that no\ninformation is actually lost. The goal is now almost amenable to do induction\nor case analysis. One should indeed first move {\\tt n} into the goal to\nstrengthen it before doing induction, or {\\tt n} will be fixed in\nthe inductive hypotheses (this does not matter for case analysis). \nAs a rule of thumb, all the variables that appear inside constructors in\nthe indices of the hypothesis should be generalized. This is exactly\nwhat the \\texttt{generalize\\_eqs\\_vars} variant does:\n\n\\begin{coq_eval} \nUndo 1.\n\\end{coq_eval}\n\\begin{coq_example}\ngeneralize_eqs_vars H.\ninduction H.\n\\end{coq_example}\n\nAs the hypothesis itself did not appear in the goal, we did not need to\nuse an heterogeneous equality to relate the new hypothesis to the old\none (which just disappeared here). However, the tactic works just as well\nin this case, e.g.:\n\n\\begin{coq_eval}\nAdmitted.\n\\end{coq_eval}\n\n\\begin{coq_example}\nGoal forall n m (p : Le (S n) m), Q (S n) m p.\nintros n m p ; generalize_eqs_vars p.\n\\end{coq_example}\n\nOne drawback of this approach is that in the branches one will have to\nsubstitute the equalities back into the instance to get the right\nassumptions. Sometimes injection of constructors will also be needed to\nrecover the needed equalities. Also, some subgoals should be directly\nsolved because of inconsistent contexts arising from the constraints on \nindexes. The nice thing is that we can make a tactic based on\ndiscriminate, injection and variants of substitution to automatically \ndo such simplifications (which may involve the K axiom). \nThis is what the {\\tt simplify\\_dep\\_elim} tactic from\n{\\tt Coq.Program.Equality} does. For example, we might simplify the\nprevious goals considerably:\n% \\begin{coq_eval} \n% Abort.\n% Goal forall n m:nat, Le (S n) m -> P n m.\n% intros n m H ; generalize_eqs_vars H.\n% \\end{coq_eval}\n\n\\begin{coq_example}\ninduction p ; simplify_dep_elim.\n\\end{coq_example}\n\nThe higher-order tactic {\\tt do\\_depind} defined in {\\tt\n  Coq.Program.Equality} takes a tactic and combines the\nbuilding blocks we have seen with it: generalizing by equalities\ncalling the given tactic with the\ngeneralized induction hypothesis as argument and cleaning the subgoals\nwith respect to equalities. Its most important instantiations are\n\\depind and \\depdestr that do induction or simply case analysis on the\ngeneralized hypothesis. For example we can redo what we've done manually\nwith \\depdestr:\n\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\\begin{coq_example*}\nRequire Import Coq.Program.Equality.\nLemma ex : forall n m:nat, Le (S n) m -> P n m.\nintros n m H.\n\\end{coq_example*}\n\\begin{coq_example}\ndependent destruction H.\n\\end{coq_example}\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\nThis gives essentially the same result as inversion. Now if the\ndestructed hypothesis actually appeared in the goal, the tactic would\nstill be able to invert it, contrary to {\\tt dependent\n inversion}. Consider the following example on vectors:\n\n\\begin{coq_example*}\nRequire Import Coq.Program.Equality.\nSet Implicit Arguments.\nVariable A : Set.\nInductive vector : nat -> Type := \n| vnil : vector 0 \n| vcons : A -> forall n, vector n -> vector (S n).\nGoal forall n, forall v : vector (S n), \n  exists v' : vector n, exists a : A, v = vcons a v'.\n  intros n v.\n\\end{coq_example*}\n\\begin{coq_example}\n  dependent destruction v.\n\\end{coq_example}\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\nIn this case, the {\\tt v} variable can be replaced in the goal by the\ngeneralized hypothesis only when it has a type of the form {\\tt vector\n (S n)}, that is only in the second case of the {\\tt destruct}. The\nfirst one is dismissed because {\\tt S n <> 0}.\n\n\\subsection{A larger example}\n\nLet's see how the technique works with {\\tt induction} on inductive\npredicates on a real example. We will develop an example application to the\ntheory of simply-typed lambda-calculus formalized in a dependently-typed style:\n\n\\begin{coq_example*}\nInductive type : Type :=\n| base : type\n| arrow : type -> type -> type.\nNotation \" t --> t' \" := (arrow t t') (at level 20, t' at next level).\nInductive ctx : Type :=\n| empty : ctx\n| snoc : ctx -> type -> ctx.\nNotation \" G , tau \" := (snoc G tau) (at level 20, tau at next level).\nFixpoint conc (G D : ctx) : ctx :=\n  match D with\n    | empty => G\n    | snoc D' x => snoc (conc G D') x\n  end.\nNotation \" G ; D \" := (conc G D) (at level 20).\nInductive term : ctx -> type -> Type :=\n| ax : forall G tau, term (G, tau) tau\n| weak : forall G tau, \n  term G tau -> forall tau', term (G, tau') tau\n| abs : forall G tau tau', \n  term (G , tau) tau' -> term G (tau --> tau')\n| app : forall G tau tau', \n  term G (tau --> tau') -> term G tau -> term G tau'.\n\\end{coq_example*}\n\nWe have defined types and contexts which are snoc-lists of types. We\nalso have a {\\tt conc} operation that concatenates two contexts.\nThe {\\tt term} datatype represents in fact the possible typing\nderivations of the calculus, which are isomorphic to the well-typed\nterms, hence the name. A term is either an application of:\n\\begin{itemize}\n\\item the axiom rule to type a reference to the first variable in a context,\n\\item the weakening rule to type an object in a larger context\n\\item the abstraction or lambda rule to type a function\n\\item the application to type an application of a function to an argument\n\\end{itemize}\n\nOnce we have this datatype we want to do proofs on it, like weakening:\n\n\\begin{coq_example*}\nLemma weakening : forall G D tau, term (G ; D) tau -> \n  forall tau', term (G , tau' ; D) tau.\n\\end{coq_example*}\n\\begin{coq_eval}\n  Abort.\n\\end{coq_eval}\n\nThe problem here is that we can't just use {\\tt induction} on the typing\nderivation because it will forget about the {\\tt G ; D} constraint\nappearing in the instance. A solution would be to rewrite the goal as:\n\\begin{coq_example*}\nLemma weakening' : forall G' tau, term G' tau -> \n  forall G D, (G ; D) = G' ->\n  forall tau', term (G, tau' ; D) tau.\n\\end{coq_example*}\n\\begin{coq_eval}\n  Abort.\n\\end{coq_eval}\n\nWith this proper separation of the index from the instance and the right\ninduction loading (putting {\\tt G} and {\\tt D} after the inducted-on\nhypothesis), the proof will go through, but it is a very tedious\nprocess. One is also forced to make a wrapper lemma to get back the\nmore natural statement. The \\depind tactic alleviates this trouble by\ndoing all of this plumbing of generalizing and substituting back automatically.\nIndeed we can simply write:\n\n\\begin{coq_example*}\nRequire Import Coq.Program.Tactics.\nLemma weakening : forall G D tau, term (G ; D) tau -> \n  forall tau', term (G , tau' ; D) tau.\nProof with simpl in * ; simpl_depind ; auto.\n  intros G D tau H. dependent induction H generalizing G D ; intros.\n\\end{coq_example*}\n\nThis call to \\depind has an additional arguments which is a list of\nvariables appearing in the instance that should be generalized in the\ngoal, so that they can vary in the induction hypotheses. By default, all\nvariables appearing inside constructors (except in a parameter position)\nof the instantiated hypothesis will be generalized automatically but\none can always give the list explicitly.\n\n\\begin{coq_example}\n  Show.\n\\end{coq_example}\n\nThe {\\tt simpl\\_depind} tactic includes an automatic tactic that tries\nto simplify equalities appearing at the beginning of induction\nhypotheses, generally using trivial applications of\nreflexivity. In cases where the equality is not between constructor\nforms though, one must help the automation by giving\nsome arguments, using the {\\tt specialize} tactic for example.\n\n\\begin{coq_example*}\ndestruct D... apply weak ; apply ax. apply ax.\ndestruct D...\n\\end{coq_example*}\n\\begin{coq_example}\nShow.\n\\end{coq_example}\n\\begin{coq_example}\n  specialize (IHterm G0 empty eq_refl).\n\\end{coq_example}\n\nOnce the induction hypothesis has been narrowed to the right equality,\nit can be used directly. \n\n\\begin{coq_example}\n  apply weak, IHterm.\n\\end{coq_example}\n\nIf there is an easy first-order solution to these equations as in this subgoal, the\n{\\tt specialize\\_eqs} tactic can be used instead of giving explicit proof\nterms:\n\n\\begin{coq_example}\n  specialize_eqs IHterm.\n\\end{coq_example}\nThis concludes our example.\n\\SeeAlso The induction \\ref{elim}, case \\ref{case} and inversion \\ref{inversion} tactics.\n\n\\section[\\tt autorewrite]{\\tt autorewrite\\label{autorewrite-example}}\n\nHere are two examples of {\\tt autorewrite} use. The first one ({\\em Ackermann\nfunction}) shows actually a quite basic use where there is no conditional\nrewriting. The second one ({\\em Mac Carthy function}) involves conditional\nrewritings and shows how to deal with them using the optional tactic of the\n{\\tt Hint~Rewrite} command.\n\n\\firstexample\n\\example{Ackermann function}\n%Here is a basic use of {\\tt AutoRewrite} with the Ackermann function:\n\n\\begin{coq_example*}\nReset Initial.\nRequire Import Arith.\nVariable Ack : \n           nat -> nat -> nat.\nAxiom Ack0 : \n        forall m:nat, Ack 0 m = S m.\nAxiom Ack1 : forall n:nat, Ack (S n) 0 = Ack n 1.\nAxiom Ack2 : forall n m:nat, Ack (S n) (S m) = Ack n (Ack (S n) m).\n\\end{coq_example*}\n\n\\begin{coq_example}\nHint Rewrite Ack0 Ack1 Ack2 : base0.\nLemma ResAck0 : \n Ack 3 2 = 29.\nautorewrite with base0 using try reflexivity.\n\\end{coq_example}\n\n\\begin{coq_eval}\nReset Initial.\n\\end{coq_eval}\n\n\\example{Mac Carthy function}\n%The Mac Carthy function shows a more complex case:\n\n\\begin{coq_example*}\nRequire Import Omega.\nVariable g :   \n           nat -> nat -> nat.\nAxiom g0 : \n        forall m:nat, g 0 m = m.\nAxiom\n  g1 :\n    forall n m:nat,\n      (n > 0) -> (m > 100) -> g n m = g (pred n) (m - 10).\nAxiom\n  g2 :\n    forall n m:nat,\n      (n > 0) -> (m <= 100) -> g n m = g (S n) (m + 11).\n\\end{coq_example*}\n\n\\begin{coq_example}\nHint Rewrite g0 g1 g2 using omega : base1.\nLemma Resg0 : \n g 1 110 = 100.\nautorewrite with base1 using reflexivity || simpl.\n\\end{coq_example}\n\n\\begin{coq_eval}\nAbort.\n\\end{coq_eval}\n\n\\begin{coq_example}\nLemma Resg1 : g 1 95 = 91.\nautorewrite with base1 using reflexivity || simpl.\n\\end{coq_example}\n\n\\begin{coq_eval}\nReset Initial.\n\\end{coq_eval}\n\n\\section[\\tt quote]{\\tt quote\\tacindex{quote}\n\\label{quote-examples}}\n\nThe tactic \\texttt{quote} allows using Barendregt's so-called\n2-level approach without writing any ML code. Suppose you have a\nlanguage \\texttt{L} of \n'abstract terms' and a type \\texttt{A} of 'concrete terms' \nand a function \\texttt{f : L -> A}. If \\texttt{L} is a simple\ninductive datatype and \\texttt{f} a simple fixpoint, \\texttt{quote f}\nwill replace the head of current goal by a convertible term of the form \n\\texttt{(f t)}. \\texttt{L} must have a constructor of type: \\texttt{A\n  -> L}. \n\nHere is an example:\n\n\\begin{coq_example}\nRequire Import Quote.\nParameters A B C : Prop.\nInductive formula : Type :=\n  | f_and : formula -> formula -> formula (* binary constructor *)\n  | f_or : formula -> formula -> formula\n  | f_not : formula -> formula (* unary constructor *)\n  | f_true : formula (* 0-ary constructor *)\n  | f_const : Prop -> formula (* constructor for constants *).\nFixpoint interp_f (f:\n                   formula) : Prop :=\n  match f with\n  | f_and f1 f2 => interp_f f1 /\\ interp_f f2\n  | f_or f1 f2 => interp_f f1 \\/ interp_f f2\n  | f_not f1 => ~ interp_f f1\n  | f_true => True\n  | f_const c => c\n  end.\nGoal A /\\ (A \\/ True) /\\ ~ B /\\ (A <-> A).\nquote interp_f.\n\\end{coq_example}\n\nThe algorithm to perform this inversion is: try to match the\nterm with right-hand sides expression of \\texttt{f}. If there is a\nmatch, apply the corresponding left-hand side and call yourself\nrecursively on sub-terms. If there is no match, we are at a leaf:\nreturn the corresponding constructor (here \\texttt{f\\_const}) applied\nto the term. \n\n\\begin{ErrMsgs}\n\\item \\errindex{quote: not a simple fixpoint} \\\\\n  Happens when \\texttt{quote} is not able to perform inversion properly.\n\\end{ErrMsgs}\n\n\\subsection{Introducing variables map}\n\nThe normal use of \\texttt{quote} is to make proofs by reflection: one\ndefines a function \\texttt{simplify : formula -> formula} and proves a \ntheorem \\texttt{simplify\\_ok: (f:formula)(interp\\_f (simplify f)) ->\n  (interp\\_f f)}. Then, one can simplify formulas by doing:\n\\begin{verbatim}\n   quote interp_f.\n   apply simplify_ok.\n   compute.\n\\end{verbatim}\nBut there is a problem with leafs: in the example above one cannot\nwrite a function that implements, for example, the logical simplifications \n$A \\land A \\ra A$ or $A \\land \\lnot A \\ra \\texttt{False}$. This is\nbecause the \\Prop{} is impredicative.\n\nIt is better to use that type of formulas:\n\n\\begin{coq_eval}\nReset formula.\n\\end{coq_eval}\n\\begin{coq_example}\nInductive formula : Set :=\n  | f_and : formula -> formula -> formula\n  | f_or : formula -> formula -> formula\n  | f_not : formula -> formula\n  | f_true : formula\n  | f_atom : index -> formula.\n\\end{coq_example*}\n\n\\texttt{index} is defined in module \\texttt{quote}. Equality on that\ntype is decidable so we are able to simplify $A \\land A$ into $A$ at\nthe abstract level. \n\nWhen there are variables, there are bindings, and \\texttt{quote}\nprovides also a type \\texttt{(varmap A)} of bindings from\n\\texttt{index} to any set \\texttt{A}, and a function\n\\texttt{varmap\\_find} to search in such maps. The interpretation\nfunction has now another argument, a variables map:\n\n\\begin{coq_example}\nFixpoint interp_f (vm:\n                    varmap Prop) (f:formula) {struct f} : Prop :=\n  match f with\n  | f_and f1 f2 => interp_f vm f1 /\\ interp_f vm f2\n  | f_or f1 f2 => interp_f vm f1 \\/ interp_f vm f2\n  | f_not f1 => ~ interp_f vm f1\n  | f_true => True\n  | f_atom i => varmap_find True i vm\n  end.\n\\end{coq_example}\n\n\\noindent\\texttt{quote} handles this second case properly:\n\n\\begin{coq_example}\nGoal A /\\ (B \\/ A) /\\ (A \\/ ~ B).\nquote interp_f.\n\\end{coq_example}\n\nIt builds \\texttt{vm} and \\texttt{t} such that \\texttt{(f vm t)} is\nconvertible with the conclusion of current goal.\n\n\\subsection{Combining variables and constants}\n\nOne can have both variables and constants in abstracts terms; that is\nthe case, for example, for the \\texttt{ring} tactic (chapter\n\\ref{ring}). Then one must provide to \\texttt{quote} a list of\n\\emph{constructors of constants}. For example, if the list is\n\\texttt{[O S]} then closed natural numbers will be considered as\nconstants and other terms as variables. \n\nExample: \n\n\\begin{coq_eval}\nReset formula.\n\\end{coq_eval}\n\\begin{coq_example*}\nInductive formula : Type :=\n  | f_and : formula -> formula -> formula\n  | f_or : formula -> formula -> formula\n  | f_not : formula -> formula\n  | f_true : formula\n  | f_const : Prop -> formula (* constructor for constants *)\n  | f_atom : index -> formula.\nFixpoint interp_f\n (vm:            (* constructor for variables *)\n  varmap Prop) (f:formula) {struct f} : Prop :=\n  match f with\n  | f_and f1 f2 => interp_f vm f1 /\\ interp_f vm f2\n  | f_or f1 f2 => interp_f vm f1 \\/ interp_f vm f2\n  | f_not f1 => ~ interp_f vm f1\n  | f_true => True\n  | f_const c => c\n  | f_atom i => varmap_find True i vm\n  end.\nGoal \nA /\\ (A \\/ True) /\\ ~ B /\\ (C <-> C).\n\\end{coq_example*}\n\n\\begin{coq_example}\nquote interp_f [ A B ].\nUndo.\n  quote interp_f [ B C iff ].\n\\end{coq_example}\n\n\\Warning Since function inversion\nis undecidable in general case, don't expect miracles from it!\n\n\\begin{Variants}\n\n\\item {\\tt quote {\\ident} in {\\term} using {\\tac}}\n\n  \\tac\\ must be a functional tactic (starting with {\\tt fun x =>})\n  and will be called with the quoted version of \\term\\ according to\n  \\ident.\n\n\\item {\\tt quote {\\ident} [ \\ident$_1$ \\dots\\ \\ident$_n$ ] in {\\term} using {\\tac}}\n\n  Same as above, but will use \\ident$_1$, \\dots, \\ident$_n$ to\n  chose which subterms are constants (see above).\n\n\\end{Variants}\n\n% \\SeeAlso file \\texttt{theories/DEMOS/DemoQuote.v}\n\n\\SeeAlso comments of source file \\texttt{plugins/quote/quote.ml}\n\n\\SeeAlso the \\texttt{ring} tactic (Chapter~\\ref{ring})\n\n\n\n\\section{Using the tactical language}\n\n\\subsection{About the cardinality of the set of natural numbers}\n\nA first example which shows how to use the pattern matching over the proof\ncontexts is the proof that natural numbers have more than two elements. The\nproof of such a lemma can be done as %shown on Figure~\\ref{cnatltac}.\nfollows:\n%\\begin{figure}\n%\\begin{centerframe}\n\\begin{coq_eval}\nReset Initial.\nRequire Import Arith.\nRequire Import List.\n\\end{coq_eval}\n\\begin{coq_example*}\nLemma card_nat :\n ~ (exists x : nat, exists y : nat, forall z:nat, x = z \\/ y = z).\nProof.\nred; intros (x, (y, Hy)).\nelim (Hy 0); elim (Hy 1); elim (Hy 2); intros;\n match goal with\n | [_:(?a = ?b),_:(?a = ?c) |- _ ] =>\n     cut (b = c); [ discriminate | transitivity a; auto ]\n end.\nQed.\n\\end{coq_example*}\n%\\end{centerframe}\n%\\caption{A proof on cardinality of natural numbers}\n%\\label{cnatltac}\n%\\end{figure}\n\nWe can notice that all the (very similar) cases coming from the three\neliminations (with three distinct natural numbers) are successfully solved by\na {\\tt match goal} structure and, in particular, with only one pattern (use\nof non-linear matching).\n\n\\subsection{Permutation on closed lists}\n\nAnother more complex example is the problem of permutation on closed lists. The\naim is to show that a closed list is a permutation of another one.\n\nFirst, we define the permutation predicate as shown in table~\\ref{permutpred}.\n\n\\begin{figure}\n\\begin{centerframe}\n\\begin{coq_example*}\nSection Sort.\nVariable A : Set.\nInductive permut : list A -> list A -> Prop :=\n  | permut_refl   : forall l, permut l l\n  | permut_cons   :\n      forall a l0 l1, permut l0 l1 -> permut (a :: l0) (a :: l1)\n  | permut_append : forall a l, permut (a :: l) (l ++ a :: nil)\n  | permut_trans  :\n      forall l0 l1 l2, permut l0 l1 -> permut l1 l2 -> permut l0 l2.\nEnd Sort.\n\\end{coq_example*}\n\\end{centerframe}\n\\caption{Definition of the permutation predicate}\n\\label{permutpred}\n\\end{figure}\n\nA more complex example is the problem of permutation on closed lists.\nThe aim is to show that a closed list is a permutation of another one.\nFirst, we define the permutation predicate as shown on\nFigure~\\ref{permutpred}.\n\n\\begin{figure}\n\\begin{centerframe}\n\\begin{coq_example}\nLtac Permut n :=\n  match goal with\n  | |- (permut _ ?l ?l) => apply permut_refl\n  | |- (permut _ (?a :: ?l1) (?a :: ?l2)) =>\n      let newn := eval compute in (length l1) in\n      (apply permut_cons; Permut newn)\n  | |- (permut ?A (?a :: ?l1) ?l2) =>\n      match eval compute in n with\n      | 1 => fail\n      | _ =>\n          let l1' := constr:(l1 ++ a :: nil) in\n          (apply (permut_trans A (a :: l1) l1' l2);\n            [ apply permut_append | compute; Permut (pred n) ])\n      end\n  end.\nLtac PermutProve :=\n  match goal with\n  | |- (permut _ ?l1 ?l2) =>\n      match eval compute in (length l1 = length l2) with\n      | (?n = ?n) => Permut n\n      end\n  end.\n\\end{coq_example}\n\\end{centerframe}\n\\caption{Permutation tactic}\n\\label{permutltac}\n\\end{figure}\n\nNext, we can write naturally the tactic and the result can be seen on\nFigure~\\ref{permutltac}. We can notice that we use two toplevel\ndefinitions {\\tt PermutProve} and {\\tt Permut}. The function to be\ncalled is {\\tt PermutProve} which computes the lengths of the two\nlists and calls {\\tt Permut} with the length if the two lists have the\nsame length. {\\tt Permut} works as expected.  If the two lists are\nequal, it concludes. Otherwise, if the lists have identical first\nelements, it applies {\\tt Permut} on the tail of the lists.  Finally,\nif the lists have different first elements, it puts the first element\nof one of the lists (here the second one which appears in the {\\tt\n  permut} predicate) at the end if that is possible, i.e., if the new\nfirst element has been at this place previously. To verify that all\nrotations have been done for a list, we use the length of the list as\nan argument for {\\tt Permut} and this length is decremented for each\nrotation down to, but not including, 1 because for a list of length\n$n$, we can make exactly $n-1$ rotations to generate at most $n$\ndistinct lists. Here, it must be noticed that we use the natural\nnumbers of {\\Coq} for the rotation counter. On Figure~\\ref{ltac}, we\ncan see that it is possible to use usual natural numbers but they are\nonly used as arguments for primitive tactics and they cannot be\nhandled, in particular, we cannot make computations with them. So, a\nnatural choice is to use {\\Coq} data structures so that {\\Coq} makes\nthe computations (reductions) by {\\tt eval compute in} and we can get\nthe terms back by {\\tt match}.\n \nWith {\\tt PermutProve}, we can now prove lemmas as \n% shown on Figure~\\ref{permutlem}.\nfollows:\n%\\begin{figure}\n%\\begin{centerframe}\n\n\\begin{coq_example*}\nLemma permut_ex1 :\n  permut nat (1 :: 2 :: 3 :: nil) (3 :: 2 :: 1 :: nil).\nProof. PermutProve. Qed.\nLemma permut_ex2 :\n  permut nat\n    (0 :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: nil)\n    (0 :: 2 :: 4 :: 6 :: 8 :: 9 :: 7 :: 5 :: 3 :: 1 :: nil).\nProof. PermutProve. Qed.\n\\end{coq_example*}\n%\\end{centerframe}\n%\\caption{Examples of {\\tt PermutProve} use}\n%\\label{permutlem}\n%\\end{figure}\n\n\n\\subsection{Deciding intuitionistic propositional logic}\n\n\\begin{figure}[b]\n\\begin{centerframe}\n\\begin{coq_example}\nLtac Axioms :=\n  match goal with\n  | |- True => trivial\n  | _:False |- _  => elimtype False; assumption\n  | _:?A |- ?A  => auto\n  end.\n\\end{coq_example}\n\\end{centerframe}\n\\caption{Deciding intuitionistic propositions (1)}\n\\label{tautoltaca}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{centerframe}\n\\begin{coq_example}\nLtac DSimplif :=\n  repeat\n   (intros;\n    match goal with\n     | id:(~ _) |- _ => red in id\n     | id:(_ /\\ _) |- _ =>\n         elim id; do 2 intro; clear id\n     | id:(_ \\/ _) |- _ =>\n         elim id; intro; clear id\n     | id:(?A /\\ ?B -> ?C) |- _ =>\n         cut (A -> B -> C);\n          [ intro | intros; apply id; split; assumption ]\n     | id:(?A \\/ ?B -> ?C) |- _ =>\n         cut (B -> C);\n          [ cut (A -> C);\n             [ intros; clear id\n             | intro; apply id; left; assumption ]\n          | intro; apply id; right; assumption ]\n     | id0:(?A -> ?B),id1:?A |- _ =>\n         cut B; [ intro; clear id0 | apply id0; assumption ]\n     | |- (_ /\\ _) => split\n     | |- (~ _) => red\n     end).\nLtac TautoProp :=\n  DSimplif;\n   Axioms ||\n     match goal with\n     | id:((?A -> ?B) -> ?C) |- _ =>\n          cut (B -> C);\n          [ intro; cut (A -> B);\n             [ intro; cut C;\n                [ intro; clear id | apply id; assumption ]\n             | clear id ]\n          | intro; apply id; intro; assumption ]; TautoProp\n     | id:(~ ?A -> ?B) |- _ =>\n         cut (False -> B);\n          [ intro; cut (A -> False);\n             [ intro; cut B;\n                [ intro; clear id | apply id; assumption ]\n             | clear id ]\n          | intro; apply id; red; intro; assumption ]; TautoProp\n     | |- (_ \\/ _) => (left; TautoProp) || (right; TautoProp)\n     end.\n\\end{coq_example}\n\\end{centerframe}\n\\caption{Deciding intuitionistic propositions (2)}\n\\label{tautoltacb}\n\\end{figure}\n\nThe pattern matching on goals allows a complete and so a powerful\nbacktracking when returning tactic values. An interesting application\nis the problem of deciding intuitionistic propositional logic.\nConsidering the contraction-free sequent calculi {\\tt LJT*} of\nRoy~Dyckhoff (\\cite{Dyc92}), it is quite natural to code such a tactic\nusing the tactic language as shown on Figures~\\ref{tautoltaca}\nand~\\ref{tautoltacb}. The tactic {\\tt Axioms} tries to conclude using\nusual axioms. The tactic {\\tt DSimplif} applies all the reversible\nrules of Dyckhoff's system. Finally, the tactic {\\tt TautoProp} (the\nmain tactic to be called) simplifies with {\\tt DSimplif}, tries to\nconclude with {\\tt Axioms} and tries several paths using the\nbacktracking rules (one of the four Dyckhoff's rules for the left\nimplication to get rid of the contraction and the right or).\n\nFor example, with {\\tt TautoProp}, we can prove tautologies like\n those:\n% on Figure~\\ref{tautolem}.\n%\\begin{figure}[tbp]\n%\\begin{centerframe}\n\\begin{coq_example*}\nLemma tauto_ex1 : forall A B:Prop, A /\\ B -> A \\/ B.\nProof. TautoProp. Qed.\nLemma tauto_ex2 :\n   forall A B:Prop, (~ ~ B -> B) -> (A -> B) -> ~ ~ A -> B.\nProof. TautoProp. Qed.\n\\end{coq_example*}\n%\\end{centerframe}\n%\\caption{Proofs of tautologies with {\\tt TautoProp}}\n%\\label{tautolem}\n%\\end{figure}\n\n\\subsection{Deciding type isomorphisms}\n\nA more tricky problem is to decide equalities between types and modulo\nisomorphisms. Here, we choose to use the isomorphisms of the simply typed\n$\\lb{}$-calculus with Cartesian product and $unit$ type (see, for example,\n\\cite{RC95}). The axioms of this $\\lb{}$-calculus are given by\ntable~\\ref{isosax}.\n\n\\begin{figure}\n\\begin{centerframe}\n\\begin{coq_eval}\nReset Initial.\n\\end{coq_eval}\n\\begin{coq_example*}\nOpen Scope type_scope.\nSection Iso_axioms.\nVariables A B C : Set.\nAxiom Com : A * B = B * A.\nAxiom Ass : A * (B * C) = A * B * C.\nAxiom Cur : (A * B -> C) = (A -> B -> C).\nAxiom Dis : (A -> B * C) = (A -> B) * (A -> C).\nAxiom P_unit : A * unit = A.\nAxiom AR_unit : (A -> unit) = unit.\nAxiom AL_unit : (unit -> A) = A.\nLemma Cons : B = C -> A * B = A * C.\nProof.\nintro Heq; rewrite Heq; reflexivity.\nQed.\nEnd Iso_axioms.\n\\end{coq_example*}\n\\end{centerframe}\n\\caption{Type isomorphism axioms}\n\\label{isosax}\n\\end{figure}\n\nA more tricky problem is to decide equalities between types and modulo\nisomorphisms. Here, we choose to use the isomorphisms of the simply typed\n$\\lb{}$-calculus with Cartesian product and $unit$ type (see, for example,\n\\cite{RC95}). The axioms of this $\\lb{}$-calculus are given on\nFigure~\\ref{isosax}.\n\n\\begin{figure}[ht]\n\\begin{centerframe}\n\\begin{coq_example}\nLtac DSimplif trm :=\n  match trm with\n  | (?A * ?B * ?C) =>\n      rewrite <- (Ass A B C); try MainSimplif\n  | (?A * ?B -> ?C) =>\n      rewrite (Cur A B C); try MainSimplif\n  | (?A -> ?B * ?C) =>\n      rewrite (Dis A B C); try MainSimplif\n  | (?A * unit) =>\n      rewrite (P_unit A); try MainSimplif\n  | (unit * ?B) =>\n      rewrite (Com unit B); try MainSimplif\n  | (?A -> unit) =>\n      rewrite (AR_unit A); try MainSimplif\n  | (unit -> ?B) =>\n      rewrite (AL_unit B); try MainSimplif\n  | (?A * ?B) =>\n      (DSimplif A; try MainSimplif) || (DSimplif B; try MainSimplif)\n  | (?A -> ?B) =>\n      (DSimplif A; try MainSimplif) || (DSimplif B; try MainSimplif)\n  end\n with MainSimplif :=\n  match goal with\n  | |- (?A = ?B) => try DSimplif A; try DSimplif B\n  end.\nLtac Length trm :=\n  match trm with\n  | (_ * ?B) => let succ := Length B in constr:(S succ)\n  | _ => constr:1\n  end.\nLtac assoc := repeat rewrite <- Ass.\n\\end{coq_example}\n\\end{centerframe}\n\\caption{Type isomorphism tactic (1)}\n\\label{isosltac1}\n\\end{figure}\n\n\\begin{figure}[ht]\n\\begin{centerframe}\n\\begin{coq_example}\nLtac DoCompare n :=\n  match goal with\n  | [ |- (?A = ?A) ] => reflexivity\n  | [ |- (?A * ?B = ?A * ?C) ] =>\n      apply Cons; let newn := Length B in\n                  DoCompare newn\n  | [ |- (?A * ?B = ?C) ] =>\n      match eval compute in n with\n      | 1 => fail\n      | _ =>\n          pattern (A * B) at 1; rewrite Com; assoc; DoCompare (pred n)\n      end\n  end.\nLtac CompareStruct :=\n  match goal with\n  | [ |- (?A = ?B) ] =>\n      let l1 := Length A\n      with l2 := Length B in\n      match eval compute in (l1 = l2) with\n      | (?n = ?n) => DoCompare n\n      end\n  end.\nLtac IsoProve := MainSimplif; CompareStruct.\n\\end{coq_example}\n\\end{centerframe}\n\\caption{Type isomorphism tactic (2)}\n\\label{isosltac2}\n\\end{figure}\n\nThe tactic to judge equalities modulo this axiomatization can be written as\nshown on Figures~\\ref{isosltac1} and~\\ref{isosltac2}. The algorithm is quite\nsimple. Types are reduced using axioms that can be oriented (this done by {\\tt\nMainSimplif}). The normal forms are sequences of Cartesian\nproducts without Cartesian product in the left component. These normal forms\nare then compared modulo permutation of the components (this is done by {\\tt\nCompareStruct}). The main tactic to be called and realizing this algorithm is\n{\\tt IsoProve}.\n\n% Figure~\\ref{isoslem} gives \nHere are examples of what can be solved by {\\tt IsoProve}.\n%\\begin{figure}[ht]\n%\\begin{centerframe}\n\\begin{coq_example*}\nLemma isos_ex1 : \n  forall A B:Set, A * unit * B = B * (unit * A).\nProof.\nintros; IsoProve.\nQed.\n\nLemma isos_ex2 :\n  forall A B C:Set,\n    (A * unit -> B * (C * unit)) =\n    (A * unit -> (C -> unit) * C) * (unit -> A -> B).\nProof.\nintros; IsoProve.\nQed.\n\\end{coq_example*}\n%\\end{centerframe}\n%\\caption{Type equalities solved by {\\tt IsoProve}}\n%\\label{isoslem}\n%\\end{figure}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"Reference-Manual\"\n%%% End: \n", "meta": {"hexsha": "9f4ddc8044c3489d4de0dbb5aa67e08557d13161", "size": 30349, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tacex.tex", "max_stars_repo_name": "JasonGross/test-broken-tar", "max_stars_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tacex.tex", "max_issues_repo_name": "JasonGross/test-broken-tar", "max_issues_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentations/coq-workshop-2014-coq/doc/refman/RefMan-tacex.tex", "max_forks_repo_name": "JasonGross/test-broken-tar", "max_forks_repo_head_hexsha": "6b52b8532879df53386b0f5413485888a1aa886a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6333333333, "max_line_length": 93, "alphanum_fraction": 0.6928729118, "num_tokens": 8907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.4177211413211116}}
{"text": "\\documentclass{scrartcl}\n\n%\\usepackage{natbib}\n\\usepackage{latexrc/macros}\n\n\\addbibresource{biblio.bib}\n\n\\title{Metastability for the Contact Process on $\\integer$}\n\\author{Owen Lynch \\and Kacper Urbański}\n\\DeclareMathOperator{\\expDist}{Exp}\n\n\\usepackage{interval}\n\\newcommand{\\ep}{\\varepsilon}\n\\intervalconfig{soft open fences}\n\\newcommand{\\loi}[2]{\\interval[open left]{#1}{#2}}\n\\newcommand{\\roi}[2]{\\interval[open right]{#1}{#2}}\n\\newcommand{\\Ninf}{\\roi{-N}{\\infty}}\n\\newcommand{\\infN}{\\loi{-\\infty}{N}}\n\\begin{document}\n\n\\maketitle\n\\begin{abstract}\n    Metastability is the coexistence of an equilibrium and a ``quasi-equilibrium'' (metastable) state in a system. If we look at a metastable system in time domain, it \n    initially appears to have stabilized in the ``quasi-equilibrium'' state,\n    until it suddenly relaxes to the true equilibrium. Metastability is a common phenomenon in nature, with examples ranging from physics to economics and social sciences. \n    This work is a summary of a paper by R. Schonmann \\cite{schonmann}, which\n    frames this phenomenon as a rigorous property of an abstract interacting particle system--the contact process on $\\integer$.\n\\end{abstract}\n\n\\section{Overview} \\label{overview}\n\n\\subsection{Metastability}\n\nLet $\\{ \\xi_N(t) \\}_{N\\in\\mathbb{N}}$ be a family of Markov processes. The essential idea behind metastability is that, if we were to discretize (``coarse-grain'') time, increasing $N$ would make the process under consideration look more and more like the Markov process in \\fref{fig:metastability_nutshell}.\n\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics{presentation_owen/metastable_coarse_grain.pdf}\n  \\caption{Metastability in a Nutshell}\n  \\label{fig:metastability_nutshell}\n\\end{figure}\n\nIn other words, the system begins in a so-called ``metastable state'', and has a very small chance to move to the stable state at any time. The stable state is either absorbing, or close-to absorbing; in the case that we will talk about in this paper, the stable state is absorbing.\n\nIn order to make this ``coarse-graining'' happen, we need two things to be true asymptotically.\n\n\\begin{enumerate}\n  \\item The hitting time of the stable state is exponentially distributed.\n  \\item Up until the hitting time, temporal means of measurements made to the process converge to an expectation of those measurements with respect to some stationary distribution.\n\\end{enumerate}\n\nInformally, these two properties allow us to approximate the entire process by sampling from the stationary distribution up until the hitting time, and then putting the system in the absorbing state.\n\nThe difficulty comes in stating these two properties precisely. To do this, suppose that $T_{N}$ is the hitting time of the absorbing state, $\\mu$ is the stationary distribution, \nand $R_{N}$ is a ``time scale'' parameter that satisfies $R_{N}/\\E T_{N} \\to 0$. Then we rewrite the two properties more formally as\n\n\\begin{enumerate}\n  \\item $T_{N} / \\E T_{N} \\to \\expDist(1)$ in distribution as $N \\to \\infty$.\n  \\item For any $f$ cylindrical,\n    \\[ \\int_{S}^{S + R_{N}} f(\\xi_{N}(t)) dt \\to \\mu(f) \\]\n    as $N \\to \\infty$, for any $S + R_{N} < T_{N}$.\n\\end{enumerate}\n\nThis second statement is still very imprecise, and actually mathematically meaningless as currently posed. Also, it turns out that we want a much stronger statement than that. However, we hope that this first statement should ``innoculate'' the reader to the precise statement, which is fairly dense on its own.\n\n\\subsection{The Contact Process on $\\integer$}\n\nWe will use the ``percolation structure'' definition of the contact process, which lends itself better to certain useful constructions.\n\nThis ``percolation structure'', consists of for each $x \\in \\integer$\n\\begin{enumerate}\n  \\item A Poisson process $P_{x}$ with rate 1, which we call the ``death'' process at $x$.\n  \\item A Poisson process $P_{x \\to x+1}$ with rate $\\lambda$, which we call the ``right infection'' process at $x$.\n  \\item A Poisson process $P_{x \\to x-1}$ with rate $\\lambda$, which we call the ``left infection'' process at $x$.\n\\end{enumerate}\n\nWe consider $P_{x}$ to be a random element of $\\powerset(\\real)$, i.e. $t \\in P_{x}$ if and only if the Poisson process ``ticks'' at time $t$.\n\nWe define a ``path'' between $(x,s), (y,t) \\in \\integer \\by \\real$ with $s \\leq t$ to be a sequence\n$(z_{0},r_{0}), \\ldots, (z_{n},r_{n})$ with $r_{i} \\leq r_{i+1}$ such that for all $(z_{i},r_{i}),(z_{i+1},r_{i+1})$, either\n\\begin{enumerate}\n  \\item $r_{i} = r_{i+1}$, $\\abs{z_{i} - z_{i+1}} = 1$, and $r_{i} \\in P_{z_{i} \\to z_{i+1}}$. In this case, we are jumping laterally by one line at a time of infection.\n  \\item $z_{i} = z_{i+1}$, and $[r_{i},r_{i+1}] \\cap P_{z_{i}} = \\emptyset$. In this case, we are moving along a vertical line, uninterrupted by any deaths.\n\\end{enumerate}\n\nDefine $\\xi^{A}(t)$ to be the set of $y$ such that there is a path from $(x,0)$ to $(y,t)$ for some $x \\in A$. If the superscript is omitted, then we assume $A = \\integer$, i.e. $\\xi(t) = \\xi^{\\integer}(t)$.\n\nFor any $A \\ins B$, we define $\\xi_{B}^{A}(t)$ to be the set of $y$ such that there is a path from $(x,0)$ to $(y,t)$ for some $x \\in A$ that stays entirely within $B$. As a special case, we let $\\xi_{N}^{A}(t) = \\xi_{[-N,N]}^{A}$, for $N \\in \\natural$. Note that $\\xi_{B}$ takes values exclusively in $\\powerset(B)$.\n\nOne of the most important facts about the contact process is that there is a critical value of $\\lambda$, $\\lambda_{c}$. For $\\lambda < \\lambda_{c}$, $\\xi(t)$ has a unique extremal invariant measure $\\delta_{\\emptyset}$. At $\\lambda = \\lambda_{c}$ the system undergoes a phase transition - for $\\lambda > \\lambda_{c}$, another extremal invariant measure $\\mu$ appears, with the property that\n\\[ \\mu(f) = \\limas_{T \\to \\infty} \\frac{1}{T} \\int_{0}^{T} \\E f(\\xi(t)) \\dd{t} \\]\nThis measure is not concentrated at $\\emptyset$.\n\nFor $\\xi_{N}(t)$, the only invariant measure is $\\delta_{\\emptyset}$, because $\\emptyset$ is a trap and $\\xi_{N}$ takes values on a finite state space. However, as mentioned before, for $\\lambda > \\lambda_{c}$ an analogue of a phase transition takes place. The system starts being metastable, and stays distributed \\emph{approximately} as $\\mu$, before a sudden fluctuation takes it to $\\emptyset$.\n\nWe assume that the reader has a general familiarity with the contact process, and thus we will use some properties later on in the proofs without explicitly discussing them here.\n\n\\subsection{Summary}\n\nThe object of this paper is to give an overview of the two conditions for metastability for the family of contact processes $\\xi_{N}$, in the supercritical regime $\\lambda > \\lambda_{c}$.\n\n\\section{Main Theorems}\n\n\\subsection{Exponential Distribution of Hitting Time}\n\n\\begin{theorem}[from \\cite{schonmann}]\n  If $T_{N} = \\inf\\set{t > 0 \\st \\xi_{N}(t) \\neq \\emptyset}$, then\n  \\[ \\frac{T_{N}}{\\E T_{N}} \\to \\expDist(1) \\]\n  in distribution.\n\\end{theorem}\n\nTo prove this, we first replace $\\E T_{N}$ by the unique (by monotonicity) $\\beta_{N}$ such that $\\Prob(T_{N} > \\beta_{N}) = \\e^{-1}$. At the end, we will show that $\\frac{\\E T_{N}}{\\beta_{N}} \\to 1$.\n\nLet $G_{N}(t) = \\Prob[\\frac{T_{N}}{\\beta_{N}} > t]$, the cumulative distribution function of $T_{N}/\\beta_{N}$. Similarly, let $G_{N}^{A}(t) = \\Prob[\\frac{T^{A}_{N}}{\\beta_{N}} > t]$. Note that $G_{N}^{A}(t) \\leq G_{N}(t)$ To show that $T_{N}/\\beta_{N}$ converges in distribution to $\\expDist(1)$, we must show that $G_{N}(t) \\to \\e^{-t}$. This can be accomplished by showing that\n\\[ \\limas_{N \\to \\infty} \\abs{G_{N}(t+s) - G_{N}(t)G_{N}(s)} = 0 \\]\nfor all $t,s > 0$.\n\n%Note that $G_{N}(t) = \\Prob[\\xi_{N}(t) \\neq \\emptyset]$, as $\\xi_{N}$ is ``alive'' at time $t$ if and only if $T_{N} > t$. Thus,\n%\n%\\begin{align*}\n%  G_{N}(t+s) &= \\Prob[\\xi_{N}(t+s) \\neq \\emptyset] \\\\\n%             &= \\sum_{A \\neq \\emptyset} \\Prob[\\xi_{N}(t+s) \\neq \\emptyset | \\xi_{N}(t) = A] \\Prob[\\xi_{N}(t) = A] \\\\\n%             &= \\sum_{A \\neq \\emptyset} G_{N}^{A}(s) \\Prob[\\xi_{N}(t) = A] \\\\\n%             &\\leq G_{N}(s) \\sum_{A \\neq \\emptyset} \\Prob[\\xi_{N}(t) = A] \\\\\n%             &= G_{N}(s) G_{N}(t)\n%\\end{align*}\n%\n%Therefore, we are looking to show that $G_{N}(s) G_{N}(t) - G_{N}(t+s) \\to 0$ (we can forget the absolute value signs).\n\nIt is at this point that we introduce a curious little construction, which seems to not make much sense at first but turns out to be the key to the entire proof. Define $F_{b}$ for $b > 0$ by\n\\[ F_{b} = \\left\\{A \\ins \\integer \\st \\frac{\\abs{A \\cap [-b,-1]}}{b} > \\frac{\\rho}{2}, \\frac{\\abs{A \\cap [1,b]}}{b} > \\frac{\\rho}{2}\\right\\} \\]\nwhere $\\rho = \\mu(\\set{\\eta \\st \\eta(0) = 1})$.\n\nIt is not trivial to show that\n\\begin{align*}\n  \\abs{G_{N}(t)G_{N}(s) - G_{N}(t+s)} &\\leq \\Prob[\\xi_{N}(\\beta_{N}t) \\neq \\emptyset] - \\min_{A \\in F_{b}} \\Prob[\\xi_{N}^{A}(\\beta_{N}t) \\neq \\emptyset] \\\\\n  &\\quad \\quad + \\Prob[\\xi_{N}(\\beta_{N}s) \\neq \\emptyset, \\xi_{N}(\\beta_{N}s) \\notin F_{b}]\n\\end{align*}\nHowever, the proof is not terribly interesting, and so we refer the reader to Schonman for the details.\n\nThe intuition for what this equation is claiming is that we can show that starting in $A \\in F_{b}$ is not too different from starting in $[-N,N]$, and we can show that ending \\emph{anywhere} non-empty is not too different from ending up somewhere in $F_{b}$. Then a typical process will have probability $G_{N}(t)$ to end up in $A \\in F_{b}$ at time $\\beta_{N}t$, and then probability $G_{N}(s)$ to end up anywhere non-empty at time $\\beta_{N}(t+s)$, starting in some $A \\in F_{b}$, so total probability to end up non-empty at time $\\beta_{N}(t+s)$ is $G_{N}(t)G_{N}(s)$, as required.\n\nWe will have finished if for any $\\ep > 0$, we can find $b(\\ep)$ and $N(\\ep) > b(\\ep)$  such that for $N \\geq N(\\ep)$ and $A \\in F_{b}$, we have both\n\\begin{align}\n  \\Prob[\\xi_{N}(\\beta_{N}t) \\neq \\emptyset] - \\Prob[\\xi_{N}^{A}(\\beta_{N}t) \\neq \\emptyset] = G_{N}(t) - G_{N}^{A}(t) &< \\ep \\label{eq:firstineq} \\\\\n  \\Prob[\\xi_{N}(\\beta_{N}s) \\neq \\emptyset, \\xi_{N}(\\beta_{N}s) \\notin F_{b}] &< \\ep \\label{eq:secondineq}\n\\end{align}\n\nWe tackle \\eref{eq:firstineq} first. Remember that $\\xi_{N}(t)$ and $\\xi_{N}^{A}$ are defined on the same percolation structure. Therefore, $\\xi_{N}(t) \\supset \\xi_{N}^{A}(t)$, so we have\n\\[ \\Prob[\\xi_{N}(\\beta_{N} t) \\neq \\emptyset] - \\Prob[\\xi_{N}(\\beta_{N} t) \\neq \\emptyset] = \\Prob[\\xi_{N}(\\beta_{N} t) \\neq \\emptyset, \\xi_{N}^{A}(\\beta_{N} t) = \\emptyset] \\leq \\Prob[T_{N} \\neq T_{N}^{A}] \\]\n\nWe discussed this proof in the presentation. In short, at a certain time $t$, $\\xi_{N}(t) = \\xi_{N}^{A}(t) \\neq \\emptyset$, and by picking $b$ large enough, we can ensure that the process is most likely still alive at this time. Then because of the percolation structure definition, for all $s > t$, $\\xi_{N}(s) = \\xi_{N}^{A}(s)$, whence $T_{N} = T_{N}^{A}$ with probability greater than $1 - \\ep$.\n\nEquation~\\ref{eq:secondineq} also relies crucially on the percolation structure. Because of the percolation structure, as long as $\\xi_{N}(t) \\neq \\emptyset$\n\\[ \\xi_{N}(t) = \\xi(t) \\cap [\\min \\xi_{N}(t), \\max \\xi_{N}(t)] \\]\nTo make use of this, we say that $\\xi_{N}(t)$ is ``wide'' if $\\min \\xi_{N}(t) < -N + L$, $\\max \\xi_{N}(t) > N - L$, for some fixed $L$. Then as long as $[-b,b] \\ins [-N+L, N-L]$, for wide $\\xi_{N}(t)$, $\\xi_{N}(t) \\in F_{b}$ if and only if $\\xi(t) \\in F_{b}$. Now, let $D_{b} = F_{b}^{C} \\setminus \\set{\\emptyset}$.\n\\begin{align*}\n  \\Prob[\\xi_{N}(\\beta_{N}s) \\in D_{b}] \\leq&\\; \\Prob[\\xi_{N}(\\beta_{N}s) \\in D_{b}, \\min \\xi_{N}(\\beta_{N}s) < -N + L, \\max \\xi_{N}(\\beta_{N}s) > N - L] \\\\\n                                &+ \\Prob[\\min \\xi_{N}(\\beta_{N}s) \\geq -N + L, \\xi_{N}(\\beta_{N}s) \\neq \\emptyset] \\\\\n                                &+ \\Prob[\\max \\xi_{N}(\\beta_{N}s) \\leq N - L, \\xi_{N}(\\beta_{N}s) \\neq \\emptyset]\n\\end{align*}\nBy what we noted earlier, the first term is less than $\\Prob(\\xi(\\beta_{N}s) \\in D_{b})$, and we can pick $b$ such that this is less than $\\frac{\\ep}{3}$.\n\nIt remains to minimize the last two terms; by symmetry we only show how to minimize the first. Using a percolation structure argument, it is easy to show that as long as $\\xi_{N}(\\beta_{N}s) \\neq \\emptyset$, $\\min \\xi_{N}(t) = \\min \\xi_{\\Ninf}$. Therefore,\n\\begin{align*}\n  \\Prob[\\min \\xi_{N}(\\beta_{N}s) \\geq -N + L, \\xi_{N}(\\beta_{N}) \\neq \\emptyset] &\\geq \\Prob[\\min \\xi_{\\Ninf} \\geq -N+L] \\\\\n  &\\geq \\mu_{\\Ninf}\\set{A \\in \\Ninf \\st A \\cap [-N,-N+L-1] = \\emptyset}\n\\end{align*}\nWe can pick $L$ large enough to make that last term less than $\\frac{\\ep}{3}$, and we have shown that everything can be made as small as we like, so we are done.\n\nThe last thing to do is to show that $\\beta_{N}/\\E T_{N} \\to 1$; this follows from the above proof, as the unique $\\beta$ such that $\\Prob[\\mathrm{Exp}(1) > \\beta] = e^{-1}$ is $1 = \\E[\\mathrm{Exp}(1)]$.\n\n\\subsection{Quasi-stationarity up to the Hitting Time}\n\nRecall our initial description of Quasi-stationarity in Section \\ref{overview}. To make it more precise, we will define\n\\begin{description}\n    \\item[the intermediate timescale] to be a choice of $R_{N} \\in \\real_{+}$ with $R_{N}/\\E[T_{N}] \\to 0$\n    \\item[an observable quantity] to be a cylindrical (local) $f:\\{0,1\\}^\\mathbb{Z} \\rightarrow \\mathbb{R}$\n    \\item[the temporal mean] of observable quantity $f$ to be\n    \\[\n        A^N_{R_N}(s, f) := R_N^{-1}\\int_s^{s+R_N}f(\\xi_N(t))dt\n    \\]\n    \\item[the fixed probability distribution] to be $\\mu$ (the upper invariant measure of $\\xi(t)$)\n\\end{description}\nNote that $A^N_{R_N}$ is a random variable. We will say that this quantity is \\emph{close} to $\\mu(f)$ if the two converge in probabilty when $N \\rightarrow \\infty$.\n\nIt seems like the definitions given above would be sufficient to make our natural language definition of metastability formal. However, it turns out that an additional technical \ncondition is needed. Define\n    \\[\n        \\Lambda(f) :=  \\text{ smallest } B\\subset \\mathbb{Z} \\text{ s.t. } f(A) = f(A\\cap B) \\ \\forall A \\subset \\mathbb{Z}\n    \\]\n    Although this is not strictly true, we can think of $\\Lambda(f)$ as the ``support'' of $f$.\n\nOur theorem will hold for a specific $L(\\varepsilon, f) \\in \\mathbb{N}$, and we need to have that\n\\[\n    L < N \\text{~~and~~} \\Lambda(f) \\subset [-N+L, N-L]\n\\]\nNotice that $L$ does not depend on $N$. Thus, since we chose to grow $N \\rightarrow \\infty$, having to choose this $L$ doesn't restrict our choice of $f$ - it merely sets the minimum\n $N$ we can consider.\n\n We're now ready to give a simplified formulation of what we mean by ``quasi-stationarity''\n \\begin{theorem} [from \\cite{schonmann}]\n        If $\\lambda > \\lambda^*$ there is a sequence $\\{R_N\\}_{N \\in \\mathbb{N}} \\subset \\mathbb{R_+}$ such that:\n        \\begin{enumerate}[(a)]\n            \\item $R_N/\\beta_N \\rightarrow 0$ as $N\\rightarrow \\infty$\n            \\item For all $\\varepsilon > 0$ and $f:\\{0,1\\}^\\mathbb{Z} \\rightarrow \\mathbb{R}$ cylindrical,  $\\exists L(\\varepsilon, f) \\in \\mathbb{N}$ such that\n                  \\[\n                      \\mathbb{P}\\left[ \\max_{\\mathbb{N}_0 \\ni k < K_N}|A_{R_N}(kR_N, f) - \\mu(f)| > \\varepsilon\\right] \\rightarrow 0\n                  \\]\n                  as $N \\rightarrow \\infty$, where $K_N = \\max\\{k \\in \\mathbb{N}_0: kR_N < T_N\\}$ and $\\Lambda(f) \\subset [-N + L, N - L] \\cap \\mathbb{Z}$\n        \\end{enumerate}\n    \\end{theorem}\n\nA full proof of this statement is beyond the scope of this article--we will merely give the reader some insight into its key points.\n\nA central claim is that we can make the exceedance probability (given below) arbitrarily small.\n\\[\n    \\mathbb{P}\\left[ |A_{R_N}(kR_N, f) - \\mu(f)| > \\varepsilon\\right]\n\\]\nWe do so in a way which is uniform across all values of $K_N$ and $\\mathbb{N}_0 \\ni k < K_N$. We estimate this probabilty with a triangle inequality.\n\\footnotesize\n\\begin{equation}\n    \\mathbb{P}\\left[ \\left|R_N^{-1}\\int_{kR_N}^{(k+1)R_N}f(\\xi(t))dt - \\mu(f)\\right| > \\varepsilon/2 \\right] + \n    \\mathbb{P}\\left[ \\left|R_N^{-1}\\int_{kR_N}^{(k+1)R_N}f(\\xi_N(t)) - f(\\xi(t))dt \\right| > \\varepsilon/2\\right]\n    \\label{th2:alternative}\n\\end{equation}\n\\normalsize\nThe first term can be made arbitrarily small, as a consequence of $\\xi(t) \\rightharpoonup \\mu(f)$ and exponentially decaying temporal correlations of $\\xi(t)$.\n\nTo shrink the second term in (\\ref{th2:alternative}) we make extensive use of the graphical model construction of the Contact Process. As before, we say $\\xi_N(t)$ is \\emph{wide} at $t$ if $\\min \\xi_N(t) < -N + L\\ \\land\\ \\max\\xi_N(t) > N - L$.\nBy the fact that we construct all processes on the same percolation structure, and that interactions are between nearest neighbours, we have\n\\begin{lemma}[Shielding by a wide process]\n    If $\\xi_N(t)$ is wide at $t$, then \\[\\xi_N(t) = \\xi(t)\\text{ on }[-N + L, N - L] \\cap \\mathbb{Z}\\]\n    In particular, since $\\Lambda(f) \\subset [-N+L, N-L]$, we have $f(\\xi_N(t)) = f(\\xi(t))$\n\\end{lemma}\nThus, the second term of (\\ref{th2:alternative}) will go to 0 if we're able to make it arbitrarily likely for $\\xi_N$ to be wide. For any given $N$, it is clear that we can find such an $L$, but we must show that we can find a $L$ that works for all $N$.\n\nTo show this, we again make use of the percolation structure. Note that near $-N$, $\\xi_N$ will ``look similar'' to $\\xi_{\\Ninf}$ (this is true as long as $\\xi_N$ is alive). By the same reasoning, $\\xi_N$ will ``look similar'' to $\\xi_{\\infN}$ near $N$.\nHence we set $L$ such that\n    \\[\n        \\mu_{\\Ninf}\\left( \\left\\{ A : A \\cap [-N,-N+L] = \\varnothing \\right\\} \\right)  \\leq \\varepsilon/(16\\norm{f})\n    \\]\nThis makes all possible states of $\\xi_N$ that do not intersect $[-N, -N+L]$ very unlikely (by ``looking similar'' to $\\xi_{\\Ninf}$). By symmetry, this also makes states\nthat do not intersect $[N-L, N]$ very unlikely. As a final stroke, we use translation invariance to notice that we will get exactly the same effect if we set $L$ \n    \\[\n        \\mu_{\\roi{0}{\\infty}}\\left( \\left\\{ A : A \\cap [0,L] = \\varnothing \\right\\} \\right) \\leq \\varepsilon/(16\\norm{f})\n    \\]\nThis concludes our overview of the proof of Theorem 2.\n\n\\printbibliography\n        \n\\end{document}\n\n", "meta": {"hexsha": "ddcd1052ad23d5647175f19bcf0677b62ed2d48e", "size": 18198, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report.tex", "max_stars_repo_name": "olynch/contact_metastability", "max_stars_repo_head_hexsha": "956cb3d7cf30cdc193ea4d3b6ab23b9a6c5315c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report.tex", "max_issues_repo_name": "olynch/contact_metastability", "max_issues_repo_head_hexsha": "956cb3d7cf30cdc193ea4d3b6ab23b9a6c5315c2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report.tex", "max_forks_repo_name": "olynch/contact_metastability", "max_forks_repo_head_hexsha": "956cb3d7cf30cdc193ea4d3b6ab23b9a6c5315c2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.6456692913, "max_line_length": 585, "alphanum_fraction": 0.6595779756, "num_tokens": 6052, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4177211343146409}}
{"text": "%This is a LATEX document\n\n%\\documentstyle[leqno]{article}\n\\documentclass[a4paper, 11pt]{amsart}   \n\\usepackage{color}   \n\\usepackage{comment}   \n   \n\\setlength{\\oddsidemargin}{0.0in}   \n\\setlength{\\evensidemargin}{0.0in}   \n\\setlength{\\textwidth}{6.5in}   \n\\setlength{\\topmargin}{0.0in}   \n\\setlength{\\textheight}{8.5in}      \n\\renewcommand{\\arraystretch}{1.5}   \n   \n%\\newcommand{\\be}{\\begin{equation}}\n%\\newcommand{\\ee}{\\end{equation}}\n\n\\newcommand{\\calO}{{\\cal O}}\n\\newcommand{\\calL}{{\\cal L}}\n\\newcommand{\\calG}{{\\cal G}}\n\\newcommand{\\calH}{H }\n\\newcommand{\\calM}{{\\cal M}}\n\\newcommand{\\calS}{{\\cal S}}\n\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{corollaire}[theorem]{Corollaire}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{question}{Question}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{definition and theorem}[theorem]{Definition and   \nTheorem}   \n\\newtheorem{theoreme_et_definition}[theorem]{Th\\'eor\\`eme et d\\'efinition}\n\\newtheorem{remarque}[theorem]{Remarque}   \n\\newtheorem{remark}[theorem]{%$^* $   \nRemark}   \n\\newtheorem{*remark}[theorem]{$^* $Remark}\n\\newtheorem{exercice}[theorem]{Exercice}\n\\newtheorem{*exercise}[theorem]{$^* $Exercise}\n\\newtheorem{**exercise}[theorem]{$^{** } $Exercise}\n\\newtheorem{exemple}[theorem]{Exemple}\n\\newtheorem{exemples}[theorem]{Exemples}\n\\newtheorem{propriertes}[theorem]{Propri\\'ertes}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{spv}[theorem]{Sneak preview}   \n%\\parindent0pt   \n   \n\\excludecomment{versionA}   \n%\\includecomment{versionA}   \n   \n\\excludecomment{versionAA}   \n%\\includecomment{versionAA}   \n   \n\\begin{document}\n\n\\title[IP for regime-switching stochastic vol models]{Inverse problems for derivative pricing in regime switching volatility models \\\\\n    (hidden Markov model for volatility)\n}\n\n\\author{Raymond Brummelhuis, Serge-Andr\\'e Masson}\n\n\\maketitle\n\n\\section{\\bf Introduction}\n\nFor local volatility models of option pricing (that is, models for which the instantaneous volatility is a function of the underlying asset and of time only) it has been known since Dupire \\cite{Du} that knowledge, at some given date, of all European call options prices for all possible maturities and strikes allows one to reconstruct the local volatility function. It is natural to ask whether a similar result can be true for more general stochastic volatility models in which the volatility process has an independent component from the stochastic process which drives the stock price changes (or, if one prefers and in a Brownian motion setting, models for which volatility changes are not perfectly correlated with price changes). More generally, anticipating a possibly negative answer to this question, one can ask to what extend European call prices for all possible maturities and strikes determine the (parameters of the) volatility process. In this paper we examine this question for models in which the volatility is driven by a not directly observable finite state continuous-time Markov chain.\n\n\\section{\\bf The model}\n\n$\\Rightarrow $ Literature-review: Elliott and co-authors, others (?) \\textcolor{blue}{  - \\`a faire}\n\\medskip\n\n\\subsection{The Regime-Switching Stochastic Vol or RSSV model} Let $(X_t )_{t \\geq 0 } $ be a continuous time Markov chain with finite state space  $\\{ 1, \\ldots , N \\} $, and risk-neutral transition probability rates $q_{ij } $ defined by\n\\begin{equation}\n    \\mathbb{P } (X_{t + dt } = j | X_t = i ) = \\delta _{ij } + q_{ij } dt\n\\end{equation}\nwhere $\\mathbb{P } $ will denote the risk-neutral probability selected by the market for pricing traded assets.\n\\medskip\n\n\\textcolor{blue}{{\\bf Commentaires}:\n    \\begin{itemize}\n        \\item Une fa\\c con plus  propre de formuler ceci: $\\mathbb{P } (X_{t + h } = j | X_t = i ) = \\delta _{ij } + q_{ij }  h + o(h) $, $h \\to 0 $\n        \\item Attention: changement de notation par rapport \\`a celle utilis\\'ee auparavant: $q_{ij } $ en lieu de $a_{ji } $\n        \\item Faire une r\\'emarque sur les diff\\'erentes probabilit\\'es risque-neutres? Le mod\\`ele (\\ref{eq:RSSV_model}) avec un drift $\\nu $ (plus un actif sans risque - compte en banque) n'est pas compl\\`et.\n    \\end{itemize}\n}\n\\medskip\n\nWe consider options written on a frictionlessly traded asset  whose risk-neutral price dynamics is given by\n\\begin{equation} \\label{eq:RSSV_model}\n    dS_t = r S_t dt + \\sigma (X_t ) S_t dW_t ,\n\\end{equation}\nwhere $r $ is the constant risk-free rate and $\\sigma : \\{ 1 , \\ldots , N \\} \\to \\mathbb{R } $ is some given function. We suppose that the Brownian motion $(W_t )_{t \\geq 0 } $ is independent of the Markov chain $(X_t )_{t \\geq 0 } . $\nWe note that the process $(S_t )_{t \\geq 0 } $ has a.s. continuous trajectories (so we don't have to write $S_{t- } $ instead of $S_t $): the jumps are in the, not directly observable, instantaneous volatilities.\n\n\\begin{remark} \\rm{We could also work directly with the Markov chain $\\sigma _t  := \\sigma (X_t ) $, whose state space is $\\{ \\sigma _1 , \\ldots , \\sigma _N \\} $ where $\\sigma _j = \\sigma (j) \\} $ and (infinitessimal) transition probabilities\n        $$\n            \\mathbb{P } (\\sigma _{t + dt } = \\sigma _j | \\sigma _t = \\sigma _k ) = \\delta _{ij } + q_{ij } dt .\n        $$\n        One advantage of using a hidden Markov process $X_t $ defined on an abstract state space is that the model then naturally extends to include for example stochastic risk-free interest rates, by specifying a second function $r : E \\to \\mathbb{R } $ and specifying price dynamics by\n        $$\n            dS_t = r(X_t ) S_t dt + \\sigma (X_t) S_t dW_t .\n        $$\n        Similarly, one could add state-dependend dividend rates. As before, sample paths of $(S_t )_{t \\geq 0 } $ are a.s. continuous: the jumps are in the (Ito-) derivatives of $S_t . $  For now we will take $r $ constant, and concentrate on the regime-switching stochastic volatilty model (\\ref{eq:RSSV_model}).\n    }\n\\end{remark}\n\n\\subsection{Derivative pricing in RSSV models} As explained in the introduction, we are interested in the inverse problem of determining the model parameters $\\sigma _i $, $q_{ij } $ from observed European call option prices for all strikes and maturities. To that effect, we start by reviewing European option pricing in our model. The problem of option pricing in regime-switching models (not only models for stochastic volatility but also for example interest rate en credit risk models) has drawn a lot attention in the mathematical finance literature, notably in papers by Robert Elliott and his co-authors: see \\textcolor{blue}{ [add string of references papers by Elliott et al]} and also \\textcolor{blue}{[other papers?]}. The majority of these are concerned with the direct problem of computing option prices for a given set of parameters, though some papers also examine calibration issues: see for example Xi, Rodrigo and Mamo \\cite{XRM} We will review the PDE approach to pricing, which for the model (\\ref{eq:RSSV_model}) amounts to solving a system of PDEs for the option prices in the different Markov-chain states. We then, following an idea of \\cite{XRM} derive a Dupire-type equation for call-option prices as function of strike and maturity.\n\\medskip\n\nBy risk-neutral pricing, a European derivative written on the asset $S_t $ and paying off an amount of $F(S_T ) $ at its maturity $T $ will have a time-$t $ price given by the discounted risk-neutral expectation\n\\begin{equation}\n    V_t = \\mathbb{E } \\left(  e^{- r (T - t ) } F(S_T ) | \\mathcal{F }^{S, X } _t \\right) %\\mathbb{E } \\left( e^{- r (T - t ) } F(S_T ) | S_t = S, X_t = i \\right) ,   \n\\end{equation}\nwhere $\\mathcal{F }^{S, X } _t $ is the filtration generated by the process $(S_t, X_t )_{t \\geq 0 } . $ Since the latter is Markov, we have that $V_t = V (S_t, X_t , t ) $, where\n\\begin{equation} \\label{eq:European_option_price}\n    V(S, i , t ) = \\mathbb{E } \\left( e^{- r (T - t ) } F(S_T ) | S_t = S, X_t = i \\right) , i = 1, \\ldots , N ,\n\\end{equation}\nremembering that $X_t \\in \\{ 1 , \\ldots , N \\} . $ It will be convenient to collect these $N $ functions into a column vector\n$$\n    V(S, t ) := (V(S, 1 , t ) , \\ldots , V(S, N , t )^T\n$$\n$^T $ standing for \"transpose\", and we will consequently write $V_i (S, t ) $ for $V(S, i , t ) . $\n\\medskip\n\nThe prices $V_i (S , t ) $ satisfy a system of PDEs.\n\n\\begin{theorem} \\label{thm:Dynkin} Suppose that $f = f(S, X, t ) $ is a $C^{2, 1 } $-function\\footnote{two times continuously differentiable with respect to $S $, once with respect to $t $} on $\\mathbb{R } \\times \\{ 1 , \\ldots , N \\} \\times \\mathbb{R } . $ Then\n    \\begin{eqnarray} \\label{eq:Dynkin}\n        &&\\mathbb{E } \\left( df (S_t , X_t , t ) | S_t  = S , X_t = i \\right) \\\\\n        &=&= \\left( \\partial _t f (S , i , t ) + r S \\partial _S f (S, i, t ) + \\frac{1 }{2 } \\sigma (i)^2 S ^2 \\partial _S ^2 f (S, i , t ) + \\sum _{j = 1 } ^N q_{ij }f (S , j , t ) \\right) dt . \\nonumber\n    \\end{eqnarray}\n\\end{theorem}\n\n\\noindent {\\it Proof}. Conditioning first on the Markov chain at $t + dt $ and using that the Markov chain is, by assumption, independent of the Brownian motion, we have\n\\begin{eqnarray} \\nonumber\n    \\mathbb{E } (f(S_{t + dt } , X_{t + dt }, t ) \\, | S_t = S, X_t = i ) &=& \\mathbb{E } \\left( \\mathbb{E } (f (S_{t + dt } , X_{t + dt } , t ) \\,  | X_{t + dt } ) | S_t =S , X_t = i \\right) \\\\\n    &=& \\mathbb{E } \\left( \\sum _{j = 1 } ^N f(S_{t + dt } , j , t ) (\\delta _{ij } + q_{ij } dt ) \\, | S_t = S \\right) \\nonumber \\\\\n    &=& \\sum _{j = 1 } ^N \\mathbb{E } \\left( f(S + r S dt + \\sigma _j S dW_t , j ) \\right) (\\delta _{ij } + q_{ij } dt ) , \\label{proof_Dynkin}\n\\end{eqnarray}\nsince to order $dt $ there can be at most on jump in $[t, t + dt ] . $ By Ito's lemma,\n$$\n    \\mathbb{E } \\left( f(S + r S dt + \\sigma _j S dW_t , j , t ) \\right) = f(S, j , t ) + \\left( \\partial _t f + r S \\partial _S f + \\frac{1 }{2 } \\sigma _j ^2 \\partial _S ^2 f \\right) dt ,\n$$\nwith $f $'s derivatives all evaluated in $(S, j, t ) . $ Substituting this into (\\ref{proof_Dynkin}) and using that $ (dt)^2 = 0 $, we see that only the terms $f(S, j , t ) q_{ij } dt $ and $f(S , i , t ) + \\left( \\partial _t f + r S \\partial _S f + \\frac{1 }{2 } \\sigma _j ^2 \\partial _S ^2 f \\right) dt $ remain which, after subtracting $f(S , i , t ) $, proves (\\ref{eq:Dynkin}). \\hfill $\\Box $\n\\medskip\n\nAssuming we would know that the $V _i (S, t ) $ are $C^{2, 1 } $ as a function of $S $ and $t $, the fact that $e^{-r t } V(S_t, X_t , t ) $ is a martingale, and therefore has drift 0, and theorem \\ref{thm:Dynkin} applied to $e^{- r t } V_i (S, t ) $ immediately implies that they must satisfy the system of PDEs\n\\begin{equation} \\label{eq:pricing_PDE}\n    \\partial _t V_i + \\frac{1 }{2 } \\sigma _i (S , t )^2 S^2 \\partial _S ^2 V_i + r S \\partial _S C + \\sum _i q_{ij } V_j = r V_i , \\ \\ t < T ,\n\\end{equation}\nwith final condition $V(S, T ) = F(S) . $ It is possible to prove directly from (\\ref{eq:European_option_price}) that the $V_i $'s are $C^{2 , 1 } $: see for example \\cite{?}. Alternatively, one can use the theory of linear PDEs: the system (\\ref{eq:pricing_PDE}) with the final condition $F $  has a unique smooth solution \\textcolor{blue}{- reference? Friedman's book on parabolic PDE? - }. By theorem \\ref{thm:Dynkin}, $e^{- r t } V(S_t , X_t , dt ) $ is a local martingale. If $F $ is for example bounded, then so is the solution $(V_i )_i $, which implies that the local martingale is a martingale, so that\n$$\n    e^{-r t } V(S_t , i,  t ) = \\mathbb{E } \\left( e^{- r T } F(S_T ) | S_t, X_t \\right) ,\n$$\nand $V(S_t, X_t , t ) $ is the price of the derivative.\n\\medskip\n\n\\textcolor{blue}{Deux remarques:\n    \\begin{itemize}\n        \\item dernier argument \\`a re-v\\'erifier et \\`a g\\'en\\'eraliser pour un call (dont le pay-off n'est pas born\\'e)\n        \\item Le \"payoff\" $F $ peut en principe \\'etre vectoriel, c'est \\`a dire, d\\'ependant de l'\\'etat de la chaine de Markov \\`a $T $, mais admettre de tels pay-off vectoriel impliqu\\'erait que les \\'etats de la chaine de Markov sont observables, ce qui n'est pas le cas pour notre mod\\`ele, puisqu'on peut pas observer la volatilit\\'e instantann\\'ee $\\sigma (X_T ) $ \\`a $T $\n    \\end{itemize}\n}\n\\medskip\n\nWe now specialize to European call options with (state-independent) pay-off $F(S_T ) = \\max (S_T - K , 0 ) . $ We will denote the value of the call by $C(S , X , t ; K, T ) $ ($X \\in \\{ 1, \\ldots , N \\} $ and also as a column vector $C (S , t ; K , T ) = \\left( C (S, 1, t ; K, T ) , \\ldots , C (S, N, t ; K , T ) \\right) ^T $, where $C_i (S, t ; K, T ) = C(S , i , t ; K, T ) . $ It will satisfy the system\n\\begin{equation} \\label{eq:PDE_call}\n    \\partial _t C + \\frac{1 }{2 } \\Sigma ^2 \\, S^2 \\partial _S ^2 C + r S \\partial _S C + Q C = r C ,\n\\end{equation}\nwhere %$\\Sigma := {\\rm diag } ( \\sigma _1 ^2 , \\ldots , \\sigma _N ^2 ) $, \n\\begin{equation}\n    \\Sigma ^2 = \\begin{pmatrix} \\sigma _1 ^2 & \\      & \\            \\\\\n                \\            & \\ddots & \\            \\\\\n                \\            & \\      & \\sigma _N ^2\n    \\end{pmatrix}\n\\end{equation}\nis the diagonal matrix of the state-dependend volatilities, and $Q = (q_{ij } )_{1 \\leq i, j \\leq N } $ is the matrix of transition probability rates of the Markov chain. The matrix $Q $ is row-stochastic: if $\\mathbf{1 } := (1, 1, \\ldots , 1 )^T $, then\n\\begin{equation}\n    Q \\mathbf{1 } = 0\n\\end{equation}\nSince the model is time-homogeneous, we can write $C (S , t ; K , T ) = C (S, K, T - t) $ (with a slight abuse of notation).\n\\medskip\n\n\nThe inverse problem we are interested in then is the following:\n\n\\begin{question} Suppose that at a given time $t_0 $ we observe all call prices $C_i (S_0 , t_0 ; K, T ) $ for arbitrary strike  $K > 0 $ and maturity $T > t_0 $, where $i $ is the state of the Markov chain in which we are in at time $t_0 . $ How much of the model parameters $N $ (the number of Markov states), $\\sigma _i $ (the state-dependent volatilities) and $q_{ij } $ (the transition probability rates) can we reconstruct ?\n\\end{question}\n\nWe have a total of $1 + n + n^2 - n = n^2 + 1 $ parameters and a continuum of observed prices (in our idealized set-up), so the problem seems at first sight over-determined.\n\\medskip\n\n\\textcolor{blue}{{\\bf Question}: is $2N - 2 = $ maximal size for which the matrix $\\left( (A^j v , ^T A^k w ) \\right) _{j, k } $ is of full rang? Here $A = z \\Sigma + Q $ }\n\n\\subsection{Dupire's equation}\n\n\\begin{theorem} (Xi, Rodrigo and Mamon \\cite{XRM}) Fix $S = S_0 , t = t_0 . $ Then as a function of $(K, T ) $, the vector of prices $C(S , t ; K, S ) $ satisfies the system of PDEs\n    \\begin{equation} \\label{eq:Dupire}\n        \\partial _T C = \\frac{1 }{2 } \\Sigma ^2 \\, K^2 \\partial _K ^2 C - r K \\partial _K C + Q C , \\ \\ T > 0 ,\n    \\end{equation}\n    with initial value $C (S_0 , t_0 , K , 0 ) = \\max (S_0 - K , 0 ) \\mathbf{1 } . $\n\\end{theorem}\n\n\\begin{proof} Xi {\\it et al.} \\cite{XRM} first observe that $C $ is homogeneous of order 1 in $(K, S ) $ by showing that $C (\\lambda S , t ; \\lambda K , T ) $ and $\\lambda C (S , t ; K , T ) $ both satisfy the $N \\times N $-system (\\ref{eq:PDE_call}), %system (\\ref{eq:PDE_call}),   \n    since the (matrix-)coefficients of this system are constant. They both have the the same final value value $\\lambda \\max (S - K , 0 ) $ at $T $, and are therefore identical. The Euler relation\n    $$\n        S \\partial _S C + K \\partial _K C = C\n    $$\n    then allows to express derivatives with respect to $S $ in terms of derivatives with respect to $K $, and (\\ref{eq:Dupire}) follows from (\\ref{eq:PDE_call}). Alternatively, one can use the relation\n    that $C (S, K , T - t_0 ) = S \\, C (1 , K/S , T - t_0 ) $ to derive (\\ref{eq:Dupire}).\n\\end{proof}\n\n\\noindent \\textcolor{blue}{{\\bf Interrogation}: la question se pose si c'est vraiement n\\'ecessaire, pour notre probl\\`eme inverse, d'utiliser une \\'equation de Dupire, dans le sens qu'on peut d\\'eduire, pour ce mod\\`ele, une formule explicite pour la  transformation de Fourier du prix en r\\'esolvant (\\ref{eq:PDE_call}) dans l'espace de Fourier (apr\\`es passage au prix logarithmique $x = \\log S/S_0 $) comme on le fait pour Dupire ci-bas, formule qu'on peut ensuite manipuler en tant que fonction de $K $ ou de $\\log (K/S_0 ) $ ($S_0 $ \\'etant le prix du sous-jacent au moment de l'observation) et de $T . $ On peut peut-\\^etre pour ce mod\\`ele sp\\'ecifique, en quelque sorte \"court-circuiter\" Dupire? \\`A suivre.\n}\n\\medskip\n\n\nPassing to log-coordinates $x = \\log K $ and letting $c (x, T ) := C (S_0 , e^x , T ) $ (suppressing the $S_0  $-dependence from the notions and taking welog $t_0 = 0 $) we find that\n\\begin{equation}\n    \\partial _T c = \\frac{1 }{2 } \\Sigma ^2 \\partial _x ^2 c - \\left(  \\frac{1 }{2 } \\Sigma ^2 + r \\right) \\partial _x c + Q c , \\ \\ T > 0\n\\end{equation}\nwith initial condition $c (x, 0 ) = c_0 (x) := \\max ( S_0 - e^x , 0 ) \\mathbf{1 } . $ It is natural to solve this using the Fourier transform: if we take $r = 0 $ to simplify, and if $\\widehat{c }  (\\xi , T ) $ is the Fourier transform with respect to the $x $-variable of the (vector-valued) call price function $c $, then\n$$\n    \\partial _T \\widehat{c } = - \\left( \\, \\frac{1 }{2 } (\\xi ^2 + i \\xi ) \\Sigma ^2 - Q \\, \\right) \\widehat{c } ,\n$$\nwith initial condition $\\widehat{c } (\\xi , 0 ) . $ If the initial condition would have been an integrable function, the solution is\n\\begin{equation} \\label{eq: FT_call}\n    c(\\xi , T ) = e^{- T ( \\frac{1 }{2 } (\\xi ^2 + i \\xi  )\\Sigma ^2 - Q ) }\\widehat{c } (\\xi , 0 )  \\mathbf{1 } ,\n\\end{equation}\n%where we put $\\zeta := \\zeta (\\xi ) := \\frac{1 }{2 } (\\xi ^2 + i \\xi  ) $ and   \nwhere the exponential is a matrix exponential. In our case, $c (x, 0 ) $ is only a bounded function and thus a tempered distribution, as is its Fourier transform. To show that (\\ref{eq: FT_call}) defines a tempered distribution we have to check that $\\xi \\to \\exp ( - T ( \\frac{1 }{2 } (\\xi ^2 - i \\xi ) \\Sigma ^2 - Q ) ) $ belongs to the Schwarz-class of rapidly decreasing functions. While this is not in doubt, proving it is slightly technical since we are dealing with the exponential of a sum of two non-commuting matrices, and there are no simple opper bounds we are aware off of for example $|| e^{A + B } || $ en termes of $|| e^A || $ and $|| e^B || $ when $A $ and $B $ are non-commuting matrices.\n\n\\begin{lemma} \\textcolor{blue}{ - lemme technique: peut \\^etre saut\\'e en premi\\`ere lecture - } $\\xi \\in \\exp ( - T ( \\frac{1 }{2 } (\\xi ^2 + i \\xi ) \\Sigma ^2 - Q ) ) $ is a rapidly decreasing function of $\\xi $ (with values in the space of $N $-dimensional matrices), and (\\ref{eq: FT_call}) is therefore well-defined as a tempered distribution, for ant tempered distribution $c(x, 0 ) . $\n\\end{lemma}\n\n\\begin{proof} We will exploit the fact that $P(t) := e^{t Q } $ is a row-stochastic non-negative matrix, since\n    $$\n        P_{ij } (t) = \\mathbb{P } (X_t = j | X_0 = i ) ,\n    $$\n    and therefore $\\sum _j P_{ij } (t ) = 1 . $\n    If $|| v ||_{\\infty } := \\max _i |v_i | $ is the sup-norm on $\\mathbb{C }^N $, then any non-negative row-stochastic matrix $P $ is a contraction with respect to this norm:\n    $$\n        || P v ||_{\\infty } \\leq || v ||_{\\infty } ,\n    $$\n    as is easily checked\\footnote{Since $P_{ij } \\geq 0 $, $|| Pv ||_{\\infty } = \\max _i  | \\sum _j P_{ij } |v_j | \\leq \\max _i \\sum _j P_{ij } || v ||_{\\infty } = || v ||_{\\infty } $, since $\\sum _j P_{ij } = 1 . $ }.\n\n    Next, we recall Lie's formula \\textcolor{blue}{(reference \\cite{? })}:\n    $$\n        e^{A + B } = \\lim _{n \\to \\infty } \\left( e^{A/n } e^{B/n } \\right)^n ,\n    $$\n    which implies that $|| e^{A + B } || \\leq \\lim _{n \\to \\infty } || e^{A/n } || ^n \\, || e^{B / n } || ^n $ for any matrix-norm $|| A || $, and in particular for $|| A ||_{\\infty } = \\sup _{|| v ||_{\\infty } = 1 } || A v ||_{\\infty } . $ Applying this with $A = - T (\\xi ^2 + i \\xi ) \\Sigma ^2 $ and $B = T Q $ and using that $|| e^{T Q / n } ||_{\\infty } \\leq 1 $ (in fact, equal to 1, since if $P $ is a stochastic matrix, $P \\mathbf{1 } = \\mathbf{1 } $, which shows that $\\sup _{|| v ||_{\\infty } = 1 } || P v ||_{\\infty } = 1 $), we find that\n    $$\n        \\left | \\left | \\, e^{- T(\\xi ^2 + i \\xi ) \\Sigma ^2 + T Q } \\, \\right | \\right | _{\\infty } \\leq \\lim _{n \\to \\infty } \\, \\left | \\left | \\, e^{ - \\frac{T }{n } (\\xi ^2 + i \\xi ) \\Sigma ^2 } \\, \\right | \\right | _{\\infty } ^n\n    $$\n    If $\\Lambda = {\\rm diag} ( \\lambda _1 , \\ldots , \\Lambda _N ) $ is diagonal, then $|| \\Lambda ||_{\\infty } \\leq \\max _i |\\lambda _i | . $ Applying this to $\\Lambda = \\exp ( - \\frac{T }{2n } (\\xi ^2 + i \\xi ) \\Sigma ^2 ) $ with $\\lambda _j = e^{- (T/2n ) (\\xi ^2 + i \\xi ) \\sigma _j ^2 } $, we see that the right hand side equals\n    $$\n        \\left | \\left | \\, e^{- T(\\xi ^2 + i \\xi ) \\Sigma ^2 + T Q } \\, \\right | \\right | _{\\infty } \\leq \\lim _{n \\to \\infty } \\left( e^{ - \\frac{T }{2n } \\xi ^2 \\min _j \\sigma _j ^2 } \\right) ^n = e^{- T \\xi ^2 (\\min _j \\sigma _j ^2 ) / 2 } ,\n    $$\n    which is rapidly decreasing in $\\xi . $\n\n    We next examine the derivatives with respect to $\\xi \\in \\mathbb{R } $ of $e^{- T (\\xi ^2 + i \\xi ) \\Sigma ^2 + T Q } . $ Again, there is no closed formula for the derivative with respect to $\\xi $, since the matrices $\\Sigma ^2 $ and $Q $ do not commute. We will use the following formula [Wilcox, R. M., Exponential operators and parameter differentiation in quantum physics, J. Math. Phys  (1967)]: if $A(\\xi ) $ is a $C^1 $ matrix-valued function on $\\mathbb{R } $, then\n    $$\n        \\frac{d }{d \\xi } e^{t A (\\xi ) } = \\int _0 ^t e^{(t - s ) A(\\xi ) } A'(\\xi ) e^{s A (\\xi ) } ds .\n    $$\n    Applying this with $t = 1 $ to $A(\\xi ) = - \\frac{1 }{2 } T ((\\xi ^2 + i \\xi ) \\Sigma ^2 - Q ) $ and using our estimate above for the norm of $e^{A(\\xi ) } $ we find\n    $$\n        \\left | \\left | \\frac{d }{d \\xi } e^{A (\\xi ) } \\right | \\right | _{\\infty } \\leq C (|\\xi | + 1 ) \\int _0 ^1 || e^{- s A (\\xi ) } ||_{\\infty } || e^{(1 - s ) A(\\xi ) } ||_{\\infty } ds \\leq C (|\\xi | + 1 ) e^{- T \\xi ^2 (\\min _j \\sigma _j ^2 ) / 2 } ,\n    $$\n    with $C = T || \\Sigma ^2 ||_{\\infty } = T \\max _j \\sigma _j ^2 $, and where the $\\ell ^{\\infty } $-norm can of course be replaced by any other matrix norm. Higher order derivatives cab be treated by iterating Wilcox's formula, e.g.\n    \\begin{eqnarray*}\n        \\frac{d^2 }{d \\xi ^2 } e^{t A (\\xi ) } &=& \\int _0 ^t e^{(t - s ) A } A''(\\xi ) e^{s A } ds + \\int _0 ^t \\left( \\int _0 ^{t - s } e^{(t - s - u ) A } A'(\\xi ) e^{u  A } du \\right) A'(\\xi ) e^{s A } ds \\\\\n        &\\ & + \\left( \\int _0 ^t e^{(t - s ) A } A'(\\xi ) \\int _0 ^s e^{(s - u ) A } A'(\\xi ) e^{u A } du \\right) ds ;\n    \\end{eqnarray*}\n\n\n\\end{proof}\n\nThe fact that $\\Sigma ^2 $ and $Q $ will never commute, except in trivial cases\\footnote{if all $\\sigma _i ^2 $ are distinct, then $[ \\Sigma ^2 , Q ] = 0 $ with $Q \\neq 0 $ implies that $Q $ is a permutation matrix \\textcolor{blue}{(au moins, je crois)}. The row sums of a permutation matrix are all equal to 1, so $Q $ cannot be the generator of a Markov chain then.  If for example $\\sigma _1 ^2 = \\sigma _2 ^2 $, then $\\Sigma ^2 $ can commute with non-zero generator matrices $Q $ whose non-zero elements correspond to transitions between states 1 and 2, but these will then have no effect on the volatility $S_t $} will be the cause of most of the technical problems in this paper, and makes the direct and inverse problem of option pricing in our hidden Markov model interesting and non-trivial, even in the simplest case of a two-state Markov chain.\n\\medskip\n\nThe (distributional) Fourier transform of $c(x, 0 ) = \\max (S_0 - e^x , 0 ) $ can be computed explicitly, and is equal to\n\\begin{equation}\n    \\widehat{c } (\\xi , 0 ) = i S_0 ^{1 - i \\xi } \\left( \\frac{1 }{\\xi + i 0 } - \\frac{1 }{\\xi + i } \\right) ,\n\\end{equation}\nwhere $(\\xi + i 0 )^{-1 } := \\lim _{\\varepsilon \\to 0+ } (\\xi + \\varepsilon )^{-1 }  = {\\rm pv } (1 / \\xi ) - i \\pi \\delta _0 (\\xi ) . $\n\\medskip\n\n\\noindent \\textcolor{blue}{{\\bf D\\'etails du calcul}: $c_0 (x) := \\max (S_0 - e^x , 0 ) $ n'est pas int\\'egrable, mais $c_{\\varepsilon } (x) := e^{\\varepsilon x } \\max (S_0 - e^x , 0 ) $ l'est, pour tout $\\varepsilon > 0 $, et $c_{\\varepsilon } \\to c_0 $ comme distributions temper\\'ees, et donc $\\widehat{c }_{\\varepsilon } \\to \\widehat{c } . $ Or,\n    \\begin{eqnarray*}\n        \\widehat{c }_{\\varepsilon } (\\xi ) &=& \\int _{\\mathbb{R } } c_0 (x) e^{\\varepsilon x - i x \\xi } dx \\\\\n        &=& \\int _{- \\infty } ^{\\log S_0 } \\left( S_0 e^{(\\varepsilon - i \\xi ) x } - e^{(\\varepsilon + 1 - i \\xi ) x } \\right) dx \\\\\n        &=& S_0 \\cdot \\frac{e^{(\\varepsilon - i \\xi ) \\log S_0 } }{\\varepsilon - i \\xi } - \\frac{e^{(\\varepsilon + 1 - i \\xi ) \\log S_0 } }{\\varepsilon + 1 - i \\xi } \\\\\n        &=& i S_0 ^{1 + \\varepsilon - i \\xi } \\left( \\frac{1 }{\\xi + i \\varepsilon } - \\frac{1 }{\\xi + i (1 + \\varepsilon ) } \\right) \\\\\n        &\\to & S_0 ^{1 - i \\xi } \\left( \\frac{1 }{\\xi + i 0 } - \\frac{1 }{\\xi + i } \\right) .\n    \\end{eqnarray*}\n}\nNote that away from $\\xi = 0 $, $\\widehat{c } (\\xi , 0 ) $ can be identified with a non-vanishing locally integrable function. It follows that if we would know all call prices $C_1 (S_0 , 0 ; K , T ) = (C(S_0 , 0 ; K, T ) , e_1 ) $, for all positive $K $ and $T $, assuming without essential loss of generality that at the time of observation $t = 0 $ we are in the hidden Markov state 1, then we would know the function $(c(x, T ) , e_1 ) $ and therefore its Fourier transform $(\\widehat{c } (\\xi , T ) , e_1 ) $ given by (\\ref{eq: FT_call}). Since $\\widehat{c } (\\xi , 0 ) \\neq 0 $ for all $\\xi \\neq 0 $, this implies that we would know the function\n\\begin{equation}\n    \\left( e^{ - T (\\zeta \\Sigma ^2 - Q ) } \\mathbf{1 } , e_1 \\right) ,   \\ \\ (\\xi , T ) \\in \\mathbb{R } \\times \\mathbb{R }_{> 0 } ,\n\\end{equation}\nwhere we put $\\zeta = \\zeta (\\xi ) := \\xi ^2 + i \\xi $, to simplify notations. In particular, evaluating the derivatives $\\partial _T ^k $ at $T = 0 $, we would know\n\\begin{equation} \\label{eq:donn�es_Pb_Inv}\n    \\left( \\, ( - \\zeta \\Sigma ^2 + Q ) ^k \\mathbf{1 } , e_1 \\right) , \\ \\ k = 0, 1, 2, \\ldots\n\\end{equation}\nand the inverse problem we study becomes\n\n\\begin{question} How much of the matrices $\\Sigma ^2 $ and $Q $ can one reconstruct from knowledge of (\\ref{eq:donn�es_Pb_Inv}) (under appropriate conitions on $\\Sigma ^2 $ and on $Q $)?\n\\end{question}\n\nWe note in passing that since (\\ref{eq:donn�es_Pb_Inv}) are polynomials in $\\zeta $, if we know them for all $\\zeta $ of the form $\\zeta = \\xi ^2 - i \\xi $, we know them for all $\\zeta \\in \\mathbb{C } $ (in fact, we only need to know their values on $k + 1 $ different points). %In particular, we can replace $- \\zeta $ by $\\zeta $, as we will sometimes do.   \n\\medskip\n\n\\subsection{Relation between (\\ref{eq:donn�es_Pb_Inv}) and observed option prices} We can take $S_0 = 1 $ without essential loss of generality. We first note that\n$$\n    (\\xi ^2 + i \\xi ) \\widehat{c } (\\xi , 0 ) =   \\xi (\\xi + i ) \\cdot i \\left( \\frac{1 }{\\xi + i 0 } - \\frac{1 }{\\xi + i } \\right) = i ( (\\xi + i ) - \\xi ) = -1 ,\n$$\n(which is equivalent to $(\\partial _x ^2 - \\partial _x ) c(x, 0 ) = \\delta _0 $). Therefore\n$$\n    (\\xi ^2 + i \\xi ) \\widehat{c } (\\xi , T ) %= c(\\xi , T )   \n    = - e^{ T ( - \\frac{1 }{2 } %(\\xi ^2 + i \\xi  )   \n            \\zeta \\Sigma ^2 + Q ) } \\mathbf{1 } ,\n$$\nwhere $\\zeta := \\zeta (\\xi ) := \\xi ^2 + i \\xi $, and\n$$\n    %\\left( \\,   \n    ( - \\zeta \\Sigma ^2 + Q ) ^k \\mathbf{1 } %, e_1 \\right)   \n    = - (\\xi ^2 + i \\xi ) \\frac{\\partial ^k }{\\partial T ^k } %e^{- T ( \\frac{1 }{2 } (\\xi ^2 + i \\xi  )\\Sigma ^2 - Q ) }   \n    \\widehat{c } (\\xi , T ) |_{T = 0 } ,\n$$\nNow\n$$\n    ( - \\zeta \\Sigma ^2 + Q )^k = \\sum _{j = 0 } ^k P^{(k) } _j (\\Sigma ^2 , Q ) (-1 )^j \\zeta ^j ,\n$$\nwhere $P^{(k) } _j (\\Sigma ^2 , Q ) $ s a polynomial in the nonommuting (!) variables $\\Sigma ^2 $ and $Q $: for example, $P^{(k)} _0 (\\Sigma ^2 , Q ) = Q^k $, while\n$$\n    P^{(k)}  _1 (\\Sigma ^2 , Q ) = Q^{k - 1 } \\Sigma ^2 + Q^{k - 2 } \\Sigma ^2 Q + \\cdots + \\Sigma ^2 Q^{k - 1 } .\n$$\nNote that since $Q \\mathbf{1 } = 0 $,\n$$\n    \\left( \\, P^{(k) }  _1 (\\Sigma ^2 , Q ) \\mathbf{1 } , e_1 \\, \\right) = (Q^{k - 1 } \\Sigma ^2 \\mathbf{1 } , e_1 ) ,\n$$\nthat is, only the first term survives when looking at the for us relevant matrix element.\n\nRemembering that $\\zeta = \\xi ^2 + i \\xi $, we therefore have\n\\begin{eqnarray*}\n    P^{(k) } _j (\\Sigma ^2 , Q ) &=& \\frac{(-1 )^j }{(2j )! } \\partial _{\\xi } ^{2j } ( - \\zeta \\Sigma ^2 + Q )^k |_{\\xi = 0 } \\\\\n    &=& - \\frac{(-1 )^j }{(2j )! } \\partial _{\\xi } ^{2j } \\partial _T ^k \\left( \\, (\\xi ^2 + i \\xi ) \\widehat{c } (\\xi , T ) \\right) |_{\\xi = 0 , T = 0 }\n\\end{eqnarray*}\nNow\n$$\n    - \\partial _{\\xi } ^{2j } (\\xi ^2 + i \\xi ) \\widehat{c } (\\xi , T ) = \\mathcal{F }_{x \\to \\xi } \\left( (ix )^{2j } (\\partial _x ^2 - \\partial _x ) c(x, T ) \\right) ,\n$$\nso that we find that\n\\begin{equation} \\label{eq:donn�es_IP_bis}\n    p_{k, j } := \\left( \\, P^{(k) } _j (\\Sigma ^2 , Q ) \\mathbf{1 } , e_1 \\, \\right)  = \\int _{\\mathbb{R } } x^{2j } (\\partial _x ^2 - \\partial _x ) \\partial _T ^k c_1 (x, T ) \\big{\\vert }_{T = 0 } dx\n\\end{equation}\nTransforming variables back to $K = e^x $, we can also write this as\n\\begin{equation}\n    %\\left( \\, p^k _j (\\Sigma ^2 , Q ) \\mathbf{1 } , e_1 \\, \\right) =   \n    p_{k, j } = \\int _0 ^{\\infty } (\\log K )^{2j } \\, \\left( K^2 \\partial _K ^2 \\partial _T ^k C \\right) (1 ; 0 , K, T ) \\, \\frac{dK }{K } \\ \\ (?)\n\\end{equation}\nwhich can obviously be determined from observed option prices.\n\n\\section{\\bf Inverse option pricing problem for a two-state Markov chain} In this subsection we show that if $N = 2 $, then (\\ref{eq:donn�es_IP_bis}) with $k = 1, 2, 3 $ uniquely determine the $\\sigma _k ^2 $  and the $q_{ij} . $ First of all, since the row-sums of $Q $ are 0 ($Q \\mathbf{1 } = 0 $), we have\n$$\n    Q = \\begin{pmatrix} - q_{12 } & q_{12 }    \\\\\n                q_{21 }   & - q _{21 }\n    \\end{pmatrix}\n$$\nso $Q $ is determined by the two parameters $q_{12 } $ and $q_{21 } $ which, together with the two volatilies (squared) $\\sigma _1 ^2 $ and $\\sigma _2 ^2 $ makes for a total of 4 parameters to be determined. Next we look at $(- \\zeta \\Sigma ^2 + Q )^k $ which we expand for $k = 1 , 2 $ and $3 $: we put $\\Sigma ^2 = V $, to simplify the appearance of the formulas and avoid confusion with the powers of $\\Sigma $ which occur (which are forcibly even). For $k = 1 $ there is nothing to do, while for the other $k $'s we find\n$$\n    \\begin{array}{cccc}\n        (- \\zeta V + Q )^2 & =  & \\zeta ^2 V ^2 - (V Q + Q V) \\zeta + Q^2            \\\\\n        (- \\zeta V + Q )^3 & =  & - \\zeta ^3 V^3 + \\zeta ^2 (V^2 Q + V Q V + Q V^2 ) \\\\\n        \\                  & \\  & - \\ \\zeta (Q^2 V + QVQ + V Q^2 ) + Q^3\n    \\end{array}\n$$\nWhen applying this to the vector $\\mathbf{1 } $, all terms starting with a $Q $ on the left will be 0, so (\\ref{eq:donn�es_IP_bis}) will give us\n$$\n    p_{1, 1 } = (V \\mathbf{1 } , e_1 ) = \\sigma _1 ^2 , \\ p_{2, 2 } = (V^2 \\mathbf{1 } , e_1 ) = \\sigma _1 ^4 ,  \\ p_{3, 3 } = (V^2 \\mathbf{1 } , e_1 ) = \\sigma _1 ^6 ,\n$$\nwhich are all dependent. We already observed that $p_{1, 0 } = (Q \\mathbf{1 } , e_1 ) = 0 $, and similarly for the other $p_{k, 0 } . $ Next,\n\\begin{equation} \\label{eq:two_state_1}\n    p_{2, 1 } = (Q V \\mathbf{1 } , e_1 ) , \\ p_{3, 2 } = ((V Q V + Q V^2 ) \\mathbf{1 } , e_1 ) = \\sigma _1 ^2 (Q V \\mathbf{1 } , e_1 ) + (Q V^2 \\mathbf{1 } , e_1 ) ,\n\\end{equation}\nso that the last equation translates into\n\\begin{equation} \\label{eq:two_state_2}\n    (Q V^2 \\mathbf{1 } , e_1 ) = p_{3, 2 } - \\sigma _1 ^2 p_{2, 1 } = p_{3, 2 } - p_{1, 1 } p_{2, 1 } ,\n\\end{equation}\nwhile finally\n\\begin{equation} \\label{eq:two_state_3}\n    p_{3, 1 } = (Q^2 V \\mathbf{1 } , e_1 ) .\n\\end{equation}\nComputing $Q V \\mathbf{1 } = Q (\\sigma _1 ^2 , \\sigma _2 ^2 )^t $ and $Q V^2 \\mathbf{1 } $, the first equation of (\\ref{eq:two_state_1}) and (\\ref{eq:two_state_2}) give\n$$\n    \\begin{array}{ll}\n        q_{12 } \\, (\\sigma _2 ^2 - \\sigma _1 ^2 ) = p_{2, 1 } \\\\\n        q_{12 } \\, (\\sigma _2 ^4 - \\sigma _1 ^2 ) = p_{3, 2 } - p_{1, 1 } p_{2, 1 } .\n    \\end{array}\n$$\nDividing the second equation by the first, we find $\\sigma _2 ^2 + \\sigma _1 ^2 = (p_{3 , 2 } - p_{1, 1 } p_{2, 1 } ) / p_{2, 1 } = (p_{3 , 2 } / p_{2, 1 } ) - p_{1, 1 }  $, so that\n$$\n    \\sigma _2 ^2 = \\frac{p_{3, 2 } }{p_{2, 1 } } - 2 p_{1, 1 } .\n$$\nThe first equation then yields $q_{12 } $:\n$$\n    q_{12 } = \\frac{p_{2, 1 } }{\\sigma _2 ^2 - \\sigma _1 ^2 } = \\frac{(p_{2, 1 } )^2 }{p_{3, 2 } - 3 p_{1, 1 } p_{2, 1 } } .\n$$\nFinally (\\ref{eq:two_state_3}) translates into\n$$\n    (\\sigma _1 ^2 - \\sigma _2 ^2 ) (q_{12 }^2 + q_{12 } q_{21 } ) = p_{3, 1 } ,\n$$\nwith solution\n$$\n    q_{21 } = \\frac{p_{3, 1 } + (\\sigma _2 ^2 - \\sigma _1 ^2 ) q_{12 } ^2 }{q_{12 } (\\sigma _1 ^2 - \\sigma _2 ^2 ) } = \\frac{p_{3, 1 } }{q_{12 } (\\sigma _1 ^2 - \\sigma _2 ^2 ) } - q_{12 } = - \\frac{p_{3, 1 } }{p_{2, 1 } } - q_{12 } .\n$$\n\\textcolor{blue}{Calculs \\`a v\\'erifier encore; formuler tout ceci comme th\\'eor\\`eme;  }\n\n\\begin{theorem} Suppose all call-prices $C (S_0 = 1 , 0 ; K, T ) $ are known. If\n    \\begin{equation}\n        %\\left( \\, p^k _j (\\Sigma ^2 , Q ) \\mathbf{1 } , e_1 \\, \\right) =   \n        p_{k, j } = \\int _0 ^{\\infty } (\\log K )^{2j } \\, \\left( K^2 \\partial _K ^2 \\partial _T ^k C \\right) (1 ; 0 , K, T ) \\, \\frac{dK }{K } ,\n    \\end{equation}\n    then if $N = 2 $, the model parameters are given by ...\n\\end{theorem}\n\n\\begin{thebibliography}{article}\n\n    \\bibitem{XRM} X. Xi, M. Rodrigo and R.S. Mamon, 2012, Parameter estimation of a regime-switching model using an inverse Stieltjes moment approach?, In: {\\it Stochastic Processes, Finance and Control (Festschrift in Honour of Robert Elliott's 70th Birthday)}, Advances in Statistics, Probability and Actuarial Science, Volume I , (eds.: Cohen, S., Madan, D., Siu, T. and Yang, H.), World Scientific, 549-569\n\n\\end{thebibliography}\n\n\\end{document}\n\n\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "87e84f83fc8db7f86e416e1b60d9ad7e7aa1c43f", "size": 34014, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/RSSV_model.tex", "max_stars_repo_name": "Serge-Andre-MASSON/RSSV_model", "max_stars_repo_head_hexsha": "6085426094c67525c32f6063bcce0b1a4d0d8536", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/RSSV_model.tex", "max_issues_repo_name": "Serge-Andre-MASSON/RSSV_model", "max_issues_repo_head_hexsha": "6085426094c67525c32f6063bcce0b1a4d0d8536", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/RSSV_model.tex", "max_forks_repo_name": "Serge-Andre-MASSON/RSSV_model", "max_forks_repo_head_hexsha": "6085426094c67525c32f6063bcce0b1a4d0d8536", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.9547511312, "max_line_length": 1260, "alphanum_fraction": 0.6061327689, "num_tokens": 12209, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.4177211343146409}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n% \\begin{figure}[ht]\n%     \\centering\n%     \\incfig{riemmans-theorem}\n%     \\caption{Riemmans theorem}\n%     \\label{fig:riemmans-theorem}\n% \\end{figure}\n\n\\begin{document}\n\n\\begin{defn}[Power Series]\nA \\textbf{power series} is an infinite sum of monomials\n\\begin{align*}\n\t\\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\n\\end{align*}\nwhere \\(\\left\\{ a_n \\right\\},z_0  \\in \\C\\) and \\(z\\) is a complex variable. We call \\(z_0\\) the \\textbf{center} of the power series.\n\\end{defn}\nNotice that we make no statements thus far in terms of convergence. Furthermore, one can take \\(a_n = 0\\) for \\(n\\geq N\\) in order to express a finite power series.\\\\\n\n\\begin{anki}\nTARGET DECK\nComplex Qual::Complex Analysis\nSTART\nMathJaxCloze\nText: A **power series** is an infinite sum of monomials\n{{c1::\\(\\begin{align*}\n        \t\\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\n        \\end{align*}\\)}}\nwhere \\(\\left\\{ a_n \\right\\},z_0  \\in \\C\\) and \\(z\\) is a complex variable. We call \\(z_0\\) the \\textbf{center} of the power series.\nExtra: One can take \\(a_n = 0\\) for \\(n\\geq N\\) in order to express a finite power series.\nTags: analysis complex_analysis power_series defn\n<!--ID: 1624504053797-->\nEND\n\\end{anki}\n\n\nWe briefly describe a stronger form of convergence before looking closer at the convergence of power series:\n\\begin{defn}[Uniform Convergence]\n\tLet \\(\\left\\{ f_n \\right\\} \\) be a sequence of complex-valued functions on a set \\(\\Omega\\subset \\C\\). The sequence \\(\\left\\{ f_n \\right\\} \\) is \\textbf{uniformly convergent} on \\(E\\) with\n\t\\begin{align*}\n\t\t\\lim_{n \\to \\infty} f_n = f\n\t\\end{align*}\n\tif for every \\(\\varepsilon>0\\), there exists an \\(N \\in \\N\\) such that, for all \\(n\\geq N\\) and \\(z \\in \\Omega\\)\n\t\\begin{align*}\n\t\t\\left| f_n(z) - f(z) \\right| \\leq \\varepsilon.\n\t\\end{align*}\n\\end{defn}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Let \\(\\left\\{ f_n \\right\\} \\) be a sequence of complex-valued functions on a set \\(\\Omega\\subset \\C\\). The sequence \\(\\left\\{ f_n \\right\\} \\) is **uniformly convergent** on \\(E\\) with\n\\(\\begin{align*}\n  \t\\lim_{n \\to \\infty} f_n = f\n  \\end{align*}\\)\n\tif {{c1::for every \\(\\varepsilon>0\\)}}, {{c1::there exists an \\(N \\in \\N\\)}} such that, {{c1::for all \\(n\\geq N\\)}} and {{c1::\\(z \\in \\Omega\\)}}:\n\t{{c1::\\(\\begin{align*}\n\t        \t\\left| f_n(z) - f(z) \\right| \\leq \\varepsilon.\n\t        \\end{align*}\\)}} \nTags: analysis complex_analysis defn complex_convergence\n<!--ID: 1624504053886-->\nEND\n\\end{anki}\n\nOf course, there are less strong and more general notions of convergence:\n\n\\begin{defn}[Absolute Convergence]\n\tA sequence of complex numbers \\(\\left\\{ z_n \\right\\}\\subset \\C \\) \\textbf{absolutely converges} if\n\t\\begin{align*}\n\t\\sum_{n=0}^{\\infty} \\left| z_n \\right| \n\t\\end{align*}\n\tconverges.\n\\end{defn}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: A sequence of complex numbers \\(\\left\\{ z_n \\right\\} \\subset \\C \\) **absolutely converges** if\n {{c1::\\(\\begin{align*}\n        \\sum_{n=0}^{\\infty} \\left| z_n \\right| \n        \\end{align*}\\)}} \n\tconverges.\nExtra: A power series is absolutely convergent at a point \\(z_1\\) if the power series evaluated at \\(z_1\\) is absolutely convergent.\nTags: \n<!--ID: 1624504053923-->\nEND\n\\end{anki}\n\nWe urge the reader to be cautious. The sum above is not a power series, and so it does not make semantic sense for a power series to absolutely converge. However, if we fix \\(z = z_1\\), then we can ask if the power series (absolutely) converges for \\(z = z_1\\).\\\\\n\n\\begin{prop}\n\tAbsolute convergence implies convergence.\n\\end{prop}\n\nObserve that if \\(z = z_1\\) is fixed and the power series is absolutely convergent for that \\(z\\):\n\\begin{align*}\n\t\\sum_{n=0}^{\\infty} \\left| a_n (z-z_0)^{n} \\right| \n\\end{align*}\nthen\n\\begin{align*}\n\t\\sum_{n=0}^{\\infty} \\left| a_n (z-z_0)^{n} \\right| = \\sum_{n=0}^{\\infty} \\left| a_n \\right| \\left| z-z_0 \\right|^{n}.\n\\end{align*}\nWe will use this form when discussing the absolute convergence of a power series at a point. One can verify that the first sum converges if and only if the second sum converges.\n\n\\begin{prop}\n\tGiven a power series\n\t\\begin{align*}\n\t\\sum_{n=0}^{\\infty} a_n (z-z_0)^{n},\n\t\\end{align*}\n\tassume it converges absolutely for some \\(z=z_1\\). Then the power series converges for all \\(z\\) such that \\(\\left| z-z_0 \\right| \\leq \\left| z_1-z_0 \\right| \\).\n\\end{prop}\nThis is a slight simplification. Absolute convergence is uniform in every closed subdisc-- that is, every compact subset within the disc is absolutely convergent. In other words, if a power series absolutely converges for \\(z = z_1\\), it convergences absolutely and locally uniformly within the disc determined by \\(z_1-z_0 \\).\n\n\\begin{thm}\n\tGiven a power series \\(\\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\\) there exists \\(0\\leq R\\leq \\infty\\) such that:\n\t\\begin{itemize}\n\t\t\\item If \\(\\left| z-z_0 \\right| <R\\) the series converges absolutely\n\t\t\\item If \\(\\left| z -z_0\\right| >R\\) the series diverges\n\t\\end{itemize}\n\tUsing the convention that \\(\\frac{1}{0}= \\infty\\) and \\(\\frac{1}{\\infty}=0\\), then \\(R\\) is given by Hadamard's formula:\n\t\\begin{align*}\n\t\t\\frac{1}{R}= \\limsup \\left| a_n \\right|^{1 / n} .\n\t\\end{align*}\n\tThe number \\(R\\) is called the \\textbf{radius of convergence} of the power series, and the region \\(\\left| z-z_0 \\right| <R\\) is the \\textbf{disc of convergence}.\n\\end{thm}\n\nNotice that the theorem above makes no statement as to convergence on the boundary. On the boundary, it is unclear whether we have convergence or divergence.\n\n\\begin{proof}\n\t\n\\end{proof}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Given a power series \\(\\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\\) there exists \\(0\\leq R\\leq \\infty\\) such that:\n\n* {{c1::If \\(\\left| z-z_0 \\right| <R\\) the series converges absolutely}}\n* {{c1::If \\(\\left| z -z_0\\right| >R\\) the series diverges}}\n\nUsing the convention that \\(\\frac{1}{0}= \\infty\\) and \\(\\frac{1}{\\infty}=0\\), then \\(R\\) is given by Hadamard's formula:\n {{c2::\\(\\begin{align*}\n        \t\\frac{1}{R}= \\limsup \\left| a_n \\right|^{1 / n} .\n        \\end{align*}\\)}} \n\tThe number \\(R\\) is called the \\textbf{radius of convergence} of the power series, and the region {{c1::\\(\\left| z-z_0 \\right| <R\\)}}  is the \\textbf{disc of convergence}.\nTags: analysis complex_analysis power_series defn\n<!--ID: 1624504053960-->\nEND\n\\end{anki}\n\n\n\\begin{exmp}[Trigonometric Functions]\n\tConsider the power series given by\n\t\\begin{align*}\n\t\te^{z} &:= \\sum_{n=0}^{\\infty} \\frac{1}{n!}z^{n}\\\\\n\t\t\\cos (z) &:= \\sum_{n=0}^{\\infty} a_n z^{n}\\\\\n\t\t\\sin (z) &:= \\sum_{n=0}^{\\infty} b_n z^{n}\n\t\\end{align*}\n\twhere\n\t\\begin{align*}\n\t\ta_n &= \\begin{cases}\n\t\t\t\\frac{(-1)^{n}}{(2n)!} & n \\equiv 0 \\pmod{2} \\\\\n\t\t\t0 & n \\equiv 1 \\pmod{2}\n\t\t\\end{cases}\\\\\n\t\tb_n &= \\begin{cases}\n\t\t\t0 & n \\equiv 0 \\pmod{2}\\\\\n\t\t\t\\frac{(-1)^{n}}{(2n+1)!} & n \\equiv 1 \\pmod{2}\n\t\t\\end{cases}.\n\t\\end{align*}\n\tThese power series are absolutely convergent in the whole complex plane. One can check that they agree with the usual exponential, cosine, and sine function of the real plane when \\(z\\) is real. Within the context of complex analysis, we instead choose to define the functions by the above series.\n\\end{exmp}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Consider the power series given by\n\t\\begin{align*}\n\t\te^{z} &:= {{c1::\\sum_{n=0}^{\\infty} \\frac{1}{n!}z^{n}}} \\\\\n\t\t\\cos (z) &:= \\sum_{n=0}^{\\infty} a_n z^{n}\\\\\n\t\t\\sin (z) &:= \\sum_{n=0}^{\\infty} b_n z^{n}\n\t\\end{align*}\n\twhere\n\t\\begin{align*}\n\t\ta_n &= {{c2::\\begin{cases}\n\t\t\t\\frac{(-1)^{n}}{(2n)!} & n \\equiv 0 \\pmod{2} \\\\\n\t\t\t0 & n \\equiv 1 \\pmod{2}\n\t\t\\end{cases} }} \\\\\n\t\tb_n &= {{c3::\\begin{cases}\n\t\t\t0 & n \\equiv 0 \\pmod{2}\\\\\n\t\t\t\\frac{(-1)^{n}}{(2n+1)!} & n \\equiv 1 \\pmod{2}\n\t\t\\end{cases} }} .\n\t\\end{align*}\nExtra: These power series are absolutely convergent in the whole complex plane. One can check that they agree with the usual exponential, cosine, and sine function of the real plane when \\(z\\) is real. Within the context of complex analysis, we instead choose to define the functions by the above series.\nTags: analysis complex_analysis power_series\n<!--ID: 1624504053995-->\nEND\n\\end{anki}\n\n\\begin{hw}\n\tShow that \\(e^{z}, \\cos(z), \\sin(z)\\) converge for all \\(z \\in \\C\\). Then show that\n\t\\begin{align*}\n\t\t\\cos(z) = \\frac{1}{2}\\left( e^{iz} + e^{-iz} \\right) \\\\\n\t\t\\sin(z) = \\frac{1}{2i} \\left( e^{iz} - e^{-iz} \\right) .\n\t\\end{align*}\n\tWe call the above formulas the \\textbf{Euler formulas} for the cosine and sine functions.\n\\end{hw}\n\n\\begin{hw}\n\tShow that \\(e^{z}\\) is the only solution to\n\t\\begin{align*}\n\t\tf'(z) = f(z)\n\t\\end{align*}\n\twith \\(f(0) = 1\\). Use this formulation of \\(e^{z}\\) to show that\n\t\\begin{align*}\n\t\te^{a+b} = e^{a}e^{b}\n\t\\end{align*}\n\tMany references choose to define \\(e^{z}\\) as the unique solution to the differential equation above. Proving this bridges the gap between the two definitions, and now either formulation can be used interchangably.\n\\end{hw}\n\n\\begin{prop}\n\t\\begin{align*}\n\t\te^{2 \\pi i} = 1.\n\t\\end{align*}\n\\end{prop}\n\\begin{proof}\n\tObserve that\n\t\\begin{align*}\n\t\te^{z} = (\\cos(z),\\sin(z))\n\t\\end{align*}\n\tand hence\n\t\\begin{align*}\n\t\te^{2\\pi i} = \\left( \\cos(2\\pi i), \\sin(2\\pi i) \\right) = \\left( 1,0 \\right) = 1.\n\t\\end{align*}\n\\end{proof}\n\n\\begin{exmp}[Logarithm]\nWe define the \\textbf{logarithm} to be the inverse function of the exponential:\n\\begin{align*}\n\t\\log: \\C\\setminus\\left\\{ 0 \\right\\} \\to \\C\n\t\\log(e^{z}) := z\n\\end{align*}\nHence by definition, the domain of \\(\\log\\) is the range of \\(e^{z}\\), that is, \\(\\C\\setminus \\left\\{ 0 \\right\\} \\).\\\\\n\nFirst, notice that the logarithm is not injective. To see this, write \\(z = (x,y)\\) and notice that\n\\begin{align*}\n\te^{z} = e^{(x,y)} = e^{(x,0)}e^{(0,y)} = e^{(x,0)}e^{(0,2\\pi k+ y}\n\\end{align*}\nfor \\(k \\in \\Z\\). Hence the real part is unique, but the imaginary part is only unique up to multiples of \\(2\\pi \\). We refer to the real part of the logarithm as the \\textbf{real logarithm}, and note that it is given by\n\\begin{align*}\n\t\\log(e^{(x,0)}) = \\left| z \\right| .\n\\end{align*}\nThe imaginary part is referred to as the \\textbf{argument of \\(z\\)} and is given by\n\\begin{align*}\n\t\\log(e^{(0,y)}) = \\sfrac{z}{\\left| z \\right| }.\n\\end{align*}\nWhen taking the argument of a complex number, we first must choose a \\textbf{branch}-- an interval of length \\(2\\pi \\) in which the argument is to lie. If unstated, then we implicitly are choosing the canonical branch \\(0\\leq \\textrm{arg}(z)<2\\pi \\).\\\\\n\nGeometrically, we can view the argument of \\(z\\) as the angle. Hence, for all \\(z \\in \\C\\setminus\\left\\{ 0 \\right\\} \\), we have\n\\begin{align*}\n\t\\log(z) = (\\log\\left| z \\right|, \\textrm{arg}(z)).\n\\end{align*}\nLet the canonical branch be chosen. This function is not holomorphic on \\(\\C\\setminus \\left\\{ 0 \\right\\}\\), but is holomorphic on \\(\\C\\setminus \\left\\{ z\\in \\R \\mid z \\leq 0 \\right\\} \\). This is because there is a discontinuity on the negative real line.\n\\end{exmp}\n\n\\begin{thm}\n\tThe power series \\(f(z) = \\sum_{n=0}^{\\infty} a_n (z-z_0)^n\\) is a holomorphic function in its disc of convergence. The derivative of \\(f\\) is also a power series obtained by differentiating term by term the series for \\(f\\), that is,\n\t\\begin{align*}\n\t\tf'(z) = \\sum_{n=0}^{\\infty} na_n(z-z_0)^{n-1}\n\t\\end{align*}\n\tMoreover, \\(f'\\) has the same radius of convergence as \\(f\\).\n\\end{thm}\n\\begin{proof}\n\t\n\\end{proof}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: The power series \\(f(z) = \\sum_{n=0}^{\\infty} a_n (z-z_0)^n\\) is a {{c1::holomorphic function}} in its disc of convergence. The derivative of \\(f\\) is also a {{c1::power series}} obtained by {{c1::differentiating term by term the series for \\(f\\)}}, that is,\n {{c1::\\(\\begin{align*}\n        \tf'(z) = \\sum_{n=0}^{\\infty} na_n(z-z_0)^{n-1}\n        \\end{align*}\\)}} \n\tMoreover, \\(f'\\) has the {{c1::same radius of convergence}} as \\(f\\).\nExtra: A power series is infinitely complex differentiable in its disc of convergence, and the higher derivatives are also power series obtained by termwise differentiation.\nTags: analysis complex_analysis power_series complex_analyticity\n<!--ID: 1624504054031-->\nEND\n\\end{anki}\n\n\n\\begin{cor}\n\tA power series is infinitely complex differentiable in its disc of convergence, and the higher derivatives are also power series obtained by termwise differentiation.\n\\end{cor}\nThis is an incredibly powerful statement. Compare this to real analysis-- in real analysis, we cannot infer a function has higher derivatives from the existence of a first derivative. The strength of this tool is that now if we want to show a complex equation is holomorphic in a region, we simply show that it is equal to a power series within the region, then show the region is within the power series' region of convergence. Now we formalize this idea:\n\n\\begin{defn}[Analytic]\n\tA function \\(f\\) defined on an open set is said to be \\textbf{analytic} at a point \\(z_0\\) if there exists a power series centered at \\(z_0\\) with positive radius of convergence such that\n\t\\begin{align*}\n\t\tf(z) = \\sum_{n=0}^{\\infty} a_n(z-z_0)^{n}\n\t\\end{align*}\n\tfor all \\(z\\) in a neighborhood of \\(z_0\\).\\\\\n\n\tIf \\(f\\) has a power series expansion at every point in the open set, it is \\textbf{analytic} on the open set.\n\\end{defn}\nIt follows immediately that an analytic function on \\(\\Omega \\) is holomorphic on \\(\\Omega \\). We will later show the converse.\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: A function \\(f\\) defined on an open set is said to be **analytic** at a point \\(z_0\\) if {{c1::there exists a power series centered at \\(z_0\\)}} with {{c1::positive radius of convergence}} such that\n{{c1::\\(\\begin{align*}\n        \tf(z) = \\sum_{n=0}^{\\infty} a_n(z-z_0)^{n} \n        \\end{align*}\\)}}\nfor all \\(z\\) in a neighborhood of \\(z_0\\).\n\nIf \\(f\\) has {{c1::a power series expansion}} at every point in the open set, it is **analytic** on the open set.\nExtra: An analytic function on \\(\\Omega\\) is holomorphic on \\(\\Omega\\) (the converse also holds)\nTags: analysis complex_analysis defn power_series complex_analyticity\n<!--ID: 1624504054064-->\nEND\n\\end{anki}\n\n\\begin{prop}\n\tIf \\(f,g\\) are power series which converge absolutely on \\(D(z_0,R)\\), then \\(f+g\\) and \\(fg\\) converge absolutely on \\(D(z_0,R)\\). Furthermore, if \\(\\alpha  \\in \\C\\), then \\(\\alpha f\\) converges absolutely on \\(D(z_0,R)\\). In fact, we have:\n\t\\begin{align*}\n\t\t(f+g)(z-z_0) = f(z-z_0) + g(z-z_0)\\\\\n\t\t(fg)(z-z_0) = f(z-z_0)g(z-z_0)\\\\\n\t\t(\\alpha f)(z-z_0) = \\alpha f(z-z_0)\n\t\\end{align*}\n\tfor all \\(z \\in D(z_0,R)\\).\n\\end{prop}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: If \\(f,g\\) are power series which converge absolutely on \\(D(z_0,R)\\), then \\(f+g\\) and \\(fg\\) {{c1::converge absolutely on \\(D(z_0,R)\\)}}. Furthermore, if \\(\\alpha  \\in \\C\\), then {{c1::\\(\\alpha f\\)}} converges absolutely on \\(D(z_0,R)\\). In fact, we have:\n {{c1::\\(\\begin{align*}\n         \t(f+g)(z-z_0) = f(z-z_0) + g(z-z_0)\\\\\n         \t(fg)(z-z_0) = f(z-z_0)g(z-z_0)\\\\\n         \t(\\alpha f)(z-z_0) = \\alpha f(z-z_0)\n         \\end{align*}\\)}} \nfor all \\(z \\in D(z_0,R)\\).\nTags: analysis complex_analysis power_series\n<!--ID: 1624845302985-->\nEND\n\\end{anki}\n\n\nThis leads to the following theorem:\n\\begin{thm}\n\t\\begin{enumerate}[(a).]\n\t\t\\item Let \\(f(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\\) be a non-constant power series with non-zero radius of convergence. If \\(f(0) = 0\\), then there exists a disc of radius \\(s>0\\) such that\n\t\t\t\\begin{align*}\n\t\t\t\tf(z)\\neq 0\n\t\t\t\\end{align*}\n\t\t\tfor all \\(z \\in D(0,s)\\setminus\\left\\{ 0 \\right\\} \\).\n\t\t\\item Suppose that \\(f,g\\) are convergent power series with\n\t\t\t\\begin{align*}\n\t\t\t\tf(z) = \\sum_{n=0}^{\\infty} a_n z^n\\\\\n\t\t\t\tg(z) = \\sum_{n=0}^{\\infty} b_n z^{n}.\n\t\t\t\\end{align*}\n\t\t\tIf \\(f(z)=g(z)\\) in any infinite set \\(A\\) with \\(0 \\in \\overline{A}\\), then \\(f(z)=g(z)\\) everywhere-- i.e. \\(a_n = b_n\\) for all \\(n\\).\n\t\\end{enumerate}\n\\end{thm}\n\\begin{proof}\n\t\n\\end{proof}\nThis theorem is extremely useful for proving the uniqueness of holomorphic functions, as well as distinguishing holomorphic functions.\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: \n* Let \\(f(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\\) be a non-constant power series with non-zero radius of convergence. If \\(f(0) = 0\\), then there exists a {{c1::disc of radius \\(s>0\\)}} such that\n{{c1::\\(\\begin{align*}\n        f(z)\\neq 0\n        \\end{align*}\\)}} \nfor all {{c1::\\(z \\in D(0,s)\\setminus\\left\\{ 0 \\right\\} \\)}}.\n* Suppose that \\(f,g\\) are convergent power series with\n\\(\\begin{align*}\n  f(z) = \\sum_{n=0}^{\\infty} a_n z^n\\\\\n  g(z) = \\sum_{n=0}^{\\infty} b_n z^{n}.\n  \\end{align*}\\)\nIf \\(f(z)=g(z)\\) in {{c2::any infinite set \\(A\\) with \\(0 \\in \\overline{A}\\)}}, then {{c2::\\(f(z)=g(z)\\) everywhere}}-- i.e. {{c2::\\(a_n = b_n\\) for all \\(n\\)::coefficients}}.\nTags: analysis complex_analysis power_series\n<!--ID: 1624845303027-->\nEND\n\\end{anki}\n\n\n\\begin{prop}[Composition of Power Series]\n\tLet\n\t\\begin{align*}\n\t\tf(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\\\\\n\t\tg(z) = \\sum_{n=0}^{\\infty} b_n z^{n}\n\t\\end{align*}\n\tbe convergent power series, and assume that \\(b_0 = 0\\). If \\(f(z)\\) is absolutely convergent for \\(z \\in D(0,R)\\), \\(R>0\\), and there exists an integer \\(s>0\\) so that\n\t\\begin{align*}\n\t\t\\sum_{n=0}^{\\infty} \\left| b_n \\right| s^{n} \\leq R\n\t\\end{align*}\n\tthen\n\t\\begin{align*}\n\t\th(z) = \\sum_{n=0}^{\\infty} a_n \\left( \\sum_{m=0}^{\\infty} b_m z^{m} \\right)^{n}\n\t\\end{align*}\n\tconverges absolutely for \\(z \\in D(0,s)\\), and within this disc satisfies\n\t\\begin{align*}\n\t\th = f\\circ g.\n\t\\end{align*}\n\\end{prop}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Let\n\\(\\begin{align*}\n  \tf(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\\\\\n  \tg(z) = \\sum_{n=0}^{\\infty} b_n z^{n}\n  \\end{align*}\\)\nbe convergent power series, and assume that \\(b_0 = 0\\). If \\(f(z)\\) is {{c1::absolutely convergent}} for {{c1::\\(z \\in D(0,R)\\)}}, \\(R>0\\), and there exists {{c1::an integer \\(s>0\\)}} so that\n{{c1::\\(\\begin{align*}\n        \t\\sum_{n=0}^{\\infty} \\left| b_n \\right| s^{n} \\leq R\n        \\end{align*}\\)}} \nthen\n\\(\\begin{align*}\n  \th(z) = \\sum_{n=0}^{\\infty} a_n \\left( \\sum_{m=0}^{\\infty} b_m z^{m} \\right)^{n}\n  \\end{align*}\\)\n{{c1::converges absolutely}} for {{c1::\\(z \\in D(0,s)\\)}}, and within this disc satisfies\n{{c1::\\(\\begin{align*}\n        \th = f\\circ g.\n        \\end{align*}\\)}} \nTags: analysis complex_analysis power_series\n<!--ID: 1624845303068-->\nEND\n\\end{anki}\n\nThere is a slightly more general form of power series that will be useful when discussing holomorphic functions.\n\n\\begin{defn}[Laurent Series]\nA \\textbf{Laurent series} is an infinite sum of monomials\n\\begin{align*}\n\tf(z) = \\sum_{n-\\infty}^{\\infty} a_n (z-z_0)^{n}\n\\end{align*}\nwhere \\(\\left\\{ a_n \\right\\},z_0  \\in \\C\\) and \\(z\\) is a complex variable. We say that the Laurent series \\textbf{converges absolutely} on \\(\\Omega \\subset \\C\\) if\n\\begin{align*}\n\tf^{+}(z) = \\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\\\\\n\tf^{-}(z) = \\sum_{n=-\\infty}^{-1} a_n (z-z_0)^{n}\n\\end{align*}\nconverges absolutely on \\(\\Omega \\). Notice that if this holds, then\n\\begin{align*}\n\tf = f^{+}+ f^{-}.\n\\end{align*}\n\\end{defn}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: A **Laurent series** is an infinite sum of monomials\n {{c1::\\(\\begin{align*}\n         \tf(z) = \\sum_{n-\\infty}^{\\infty} a_n (z-z_0)^{n}\n         \\end{align*}\\)}} \nwhere \\(\\left\\{ a_n \\right\\},z_0  \\in \\C\\) and \\(z\\) is a complex variable. We say that the Laurent series **converges absolutely** on \\(\\Omega \\subset \\C\\) if\n{{c1::\\(\\begin{align*}\n         \tf^{+}(z) = \\sum_{n=0}^{\\infty} a_n (z-z_0)^{n}\\\\\n         \tf^{-}(z) = \\sum_{n=-\\infty}^{-1} a_n (z-z_0)^{n}\n         \\end{align*}\\)}} \nconverges absolutely on \\(\\Omega \\). Notice that if this holds, then\n {{c1::\\(\\begin{align*}\n        \tf = f^{+}+ f^{-}.\n        \\end{align*}\\)}} \nTags: analysis complex_analysis power_series defn\n<!--ID: 1625522318703-->\nEND\n\\end{anki}\n\n\n\\subsection{Obtaining Convergence and Absolute Convergence}\n\\label{sub:obtaining_absolute_convergence}\nWe will briefly develop a few tools that will help us show a series is absolutely convergent. As discussed earlier, this is a vital step in obtaining holomorphicity of a function.\n\n\\begin{thm}[Weierstrass M test]\n\tLet \\(\\left\\{ f_n \\right\\} \\) be a sequence of real or complex-valued functions, and \\(\\left\\{ A_n \\right\\} \\) a sequence of non-negative real numbers so that\n\t\\begin{align*}\n\t\t\\left| f_n(z) \\right| \\leq A_n\n\t\\end{align*}\n\tfor all \\(z\\) in some region \\(\\Omega\\). If the sum\n\t\\begin{align*}\n\t\t\\sum_{n=0}^{\\infty} A_n\n\t\\end{align*}\n\tconverges, then\n\t\\begin{align*}\n\t\t\\sum_{n=0}^{\\infty} f_n(z)\n\t\\end{align*}\n\tconverges absolutely and uniformly on \\(\\Omega\\).\\\\\n\n\tIn this case, we call \\(A_n\\) a \\textbf{majorant} of the \\textbf{minorant} \\(\\left\\{ f_n \\right\\} \\). \n\\end{thm}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: **Weierstrass M-test**\n\tLet \\(\\left\\{ f_n \\right\\} \\) be a sequence of real or complex-valued functions, and \\(\\left\\{ A_n \\right\\} \\) a sequence of non-negative real numbers so that\n\t{{c1::\\(\\begin{align*}\n\t        \t\\left| f_n(z) \\right| \\leq A_n\n\t        \\end{align*}\\)}} \n\tfor all \\(z\\) in some region \\(\\Omega\\). If\n\t{{c1::\\(\\begin{align*}\n\t        \t\\sum_{n=0}^{\\infty} A_n\n\t        \\end{align*}\\)}} \n\tconverges, then\n\t{{c1::\\(\\begin{align*}\n\t        \t\\sum_{n=0}^{\\infty} f_n(z)\n\t        \\end{align*}\\)}} \n\tconverges absolutely and uniformly on \\(\\Omega\\).\n\nIn this case, we call \\(A_n\\) a **majorant** of the **minorant** \\(\\left\\{ f_n \\right\\} \\). \nTags: analysis complex_analysis power_series\n<!--ID: 1624504054101-->\nEND\n\\end{anki}\n\n\nWe have another useful tool:\n\n\\begin{thm}[Abel's Limit Theorem]\n\tLet \\(G(z)\\) be a power series given by\n\t\\begin{align*}\n\t\tG(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\n\t\\end{align*}\n\tSuppose that the sum below converges:\n\t\\begin{align*}\n\t\t\\sum_{n=0}^{\\infty} a_n = a\n\t\\end{align*}\n\tfor some \\(a \\in \\C\\). Then\n\t\\begin{align*}\n\t\t\\lim_{z \\to 1} G(z) = \\sum_{n=0}^{\\infty} a_n\n\t\\end{align*}\n\tprovided that \\(z\\) remains within a \\textbf{Stolz sector}, that is, satisfies\n\t\\begin{align*}\n\t\t\\frac{\\left| 1-z \\right| }{1-\\left| z \\right| } \\leq M\n\t\\end{align*}\n\tfor some \\(M \\in \\R\\).\n\\end{thm}\nThis is most useful when the radius of convergence of a power series is \\(1\\), as it can be used to find the limit of the power series from within the disc of convergence. Hence, even if the power series does not have a limit on the radius of convergence, we might be able to obtain an \"inner limit\" that we can use for calculations.\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: **Abel's Limit Theorem**\n\tLet \\(G(z)\\) be a power series given by\n\t\\(\\begin{align*}\n\t  \tG(z) = \\sum_{n=0}^{\\infty} a_n z^{n}\n\t  \\end{align*}\\)\n\tSuppose that the sum below converges:\n\t\\(\\begin{align*}\n\t  \t\\sum_{n=0}^{\\infty} a_n = a\n\t  \\end{align*}\\)\n\tfor some \\(a \\in \\C\\). Then\n\t{{c1::\\(\\begin{align*}\n\t        \t\\lim_{z \\to 1} G(z) = \\sum_{n=0}^{\\infty} a_n\n\t        \\end{align*}\\)}} \n\tprovided that \\(z\\) remains within a \\textbf{Stolz sector}, that is, satisfies\n\t{{c1::\\(\\begin{align*}\n\t        \t\\frac{\\left| 1-z \\right| }{1-\\left| z \\right| } \\leq M\t\n\t        \\end{align*}\\)}} \n\tfor some \\(M \\in \\R\\).\nTags:  analysis complex_analysis power_series\n<!--ID: 1624504054138-->\nEND\n\\end{anki}\n\nOne last tool that will be helpful is Stirling's formula.\n\n\\begin{prop}[Stirling's Formula]\n\t\\begin{align*}\n\t\t\\sqrt{2\\pi n} (n^{n}e^{-n}) \\leq n! \\leq e\\sqrt{n} (n^{n}e^{-n})\n\t\\end{align*}\n\tfor all \\(n \\in \\N\\). Furthermore, \\(n!\\) limits towards the lower bound-- that is,\n\t\\begin{align*}\n\t\t\\lim_{n \\to \\infty} \\frac{n!}{\\sqrt{2\\pi n} (n^{n}e^{-n})} =1.\n\t\\end{align*}\n\tSometimes, the approximation is written by\n\t\\begin{align*}\n\t\t\\ln n! \\approx n\\ln n - n.\n\t\\end{align*}\n\\end{prop}\nThis can be useful when comparing power series to show radius of convergence.\n\n\\begin{exmp}[Radius of Convergence of Various Series]\n\tConsider the power series given below by\n\t\\begin{align}\n\t\t\\sum_{n=0}^{\\infty} n! z^{n}\\\\\n\t\t\\sum_{n=0}^{\\infty} \\frac{1}{n!}z^{n}\\\\\n\t\t\\sum_{n=0}^{\\infty} \\frac{n!}{n^{n}}z^{n}\\\\\n\t\\end{align}\n\tThe radius of convergence of the first power series is 0 because \\(\\frac{n^{n}}{e^{n}z^{n}}\\) is unbounded as \\(n\\to \\infty\\). Likewise, \\(\\frac{z^{n}}{n^{n}e^{n}}\\) approaches zero as \\(n\\to \\infty\\) and hence the second series has infinite radius of convergence. A similar trick can be used to show that the third series' radius of convergence is \\(e\\).\\\\\n\n\tIn general the ratio test states that if\n\t\\begin{align*}\n\t\t\\lim_{n \\to \\infty} \\frac{a_{n+1}}{a_n} = A\\geq 0\n\t\\end{align*}\n\tfor positive numbers \\(a_n\\), then\n\t\\begin{align*}\n\t\t\\lim_{n \\to \\infty} a_n^{\\sfrac{1}{n}}=A.\n\t\\end{align*}\n\\end{exmp}\n\n\\begin{exmp}[Binomial Series]\n\tLet \\(\\alpha  \\in \\C\\) be a non-zero complex number. The \\textbf{binomial coefficients} are given by\n\t\\begin{align*}\n\t{\\alpha\\choose{n}} := \\frac{\\alpha (\\alpha-1)\\ldots(\\alpha -n+1)}{n!}\\\\\n\t{\\alpha \\choose{0}}=1\n\t\\end{align*}\n\tand the \\textbf{binomial series} by\n\t\\begin{align*}\n\t\tB_\\alpha (T) := \\sum_{n=0}^{\\infty} {\\alpha \\choose{n}}z^{n} = (1+z)^{\\alpha }.\n\t\\end{align*}\n\tOne can check that the second equality indeed holds, and in fact the radius of convergence of the binomial series is \\(1\\) provided that \\(\\alpha \\) is not an integer \\(\\geq 0\\).\n\\end{exmp}\n\\begin{proof}\n\tObserve that\n\t\\begin{align*}\n\t\t\\left| \\frac{ {\\alpha \\choose{n+1}}}{ {\\alpha \\choose{n}}} \\right| = \\left| \\frac{\\alpha -n}{n+1} \\right| \n\t\\end{align*}\n\tand hence limits to \\(1\\). By the ratio test, the binomial sum has the radius of convergence desired.\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "2a24a30b900ac8138482d524439b9abcb2dc97e6", "size": 25231, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Complex Analysis/Notes/source/2020-02-28-PowerSeries.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Complex Analysis/Notes/source/2020-02-28-PowerSeries.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Complex Analysis/Notes/source/2020-02-28-PowerSeries.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9857369255, "max_line_length": 456, "alphanum_fraction": 0.6426618049, "num_tokens": 9142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8289388083214156, "lm_q1q2_score": 0.41770738050418404}}
{"text": "\\documentclass[13pt,onlymath]{beamer}\n\\usefonttheme{serif}\n\\usepackage{graphicx,amsmath,amssymb,tikz,psfrag,epstopdf,fancyvrb}\n\\usepackage[lighttt]{lmodern}\n%\\usepackage{graphicx,psfrag}\n\n\\input defs.tex\n\n%% formatting\n\n\\mode<presentation>\n{\n\\usetheme{default}\n}\n\\setbeamertemplate{navigation symbols}{}\n\\usecolortheme[rgb={0.13,0.28,0.59}]{structure}\n\\setbeamertemplate{itemize subitem}{--}\n\\setbeamertemplate{frametitle} {\n    \\begin{center}\n      {\\large\\bf \\insertframetitle}\n    \\end{center}\n}\n\n\\newcommand\\footlineon{\n  \\setbeamertemplate{footline} {\n    \\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,leftskip=.8cm,rightskip=.6cm]{structure}\n      \\footnotesize \\insertsection\n      \\hfill\n      {\\insertframenumber}\n    \\end{beamercolorbox}\n    \\vskip 0.45cm\n  }\n}\n\\footlineon\n\n\\AtBeginSection[] \n{ \n    \\begin{frame}<beamer> \n        \\frametitle{Outline} \n        \\tableofcontents[currentsection,currentsubsection] \n    \\end{frame} \n} \n\n%% begin presentation\n\n\\title{\\large \\bfseries Combinatorial Games}\n\n\\author{Jaehyun Park\\\\[3ex]\nCS 97SI\\\\\nStanford University}\n\n\\date{\\today}\n\n\\begin{document}\n\n\\frame{\n\\thispagestyle{empty}\n\\titlepage\n}\n\n\\begin{frame}{Combinatorial Games}\n\\BIT\n\\item Turn-based competitive multi-player games\n\\item Can be a simple win-or-lose game, or can involve points\n\\item Everyone has perfect information\n\\item Each turn, the player changes the current ``state'' using a valid ``move''\n\\item At some states, there are no valid moves\n\\BIT\n\\item The current player immediately loses at these states\n\\EIT\n\\EIT\n\\end{frame}\n\n\n\\section{Simple Games}\n\n\\begin{frame}{Combinatorial Game Example}\n\\BIT\n\\item Settings: There are $n$ stones in a pile. Two players take turns and remove 1 or 3 stones at a time. The one who takes the last stone wins. Find out the winner if both players play perfectly\n\\item State space: Each state can be represented by the number of remaining stones in the pile\n\\item Valid moves from state $x$: $x \\rightarrow (x-1)$ or $x \\rightarrow (x-3)$, as long as the resulting number is nonnegative\n\\item State 0 is the losing state\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Example (continued)}\n\\BIT\n\\item No cycles in the state transitions\n\\BIT\n\\item Can solve the problem bottom-up (DP)\n\\EIT\n\\item A player wins if there is a way to force the opponent to lose\n\\BIT\n\\item Conversely, we lose if there is no such a way\n\\EIT\n\\item State $x$ is a winning state (W) if\n\\BIT\n\\item $(x-1)$ is a losing state,\n\\item OR $(x-3)$ is a losing state\n\\EIT\n\\item Otherwise, state $x$ is a losing state (L)\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Example (continued)}\n\\BIT\n\\item DP table for small values of $n$:\n\n\\begin{center}\n\\begin{tabular}{|c|cccccccc|}\n\\hline\n$n$&0&1&2&3&4&5&6&7 \\\\ \\hline\nW/L&L&W&L&W&L&W&L&W \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\vfill\n\\item See a pattern?\n\\vfill\n\\item Let's prove our conjecture\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Example (continued)}\n\\BIT\n\\item Conjecture: If $n$ is odd, the first player wins. If $n$ is even, the second player wins.\n\\vfill\n\\item Holds true for the base case $n=0$\n\\item In general,\n\\BIT\n\\item If $n$ is odd, we can remove one stone and give the opponent an even number of stones\n\\item If $n$ is even, no matter what we choose, we have to give an odd number of stones to the opponent\n\\EIT\n\\EIT\n\\end{frame}\n\n\n\\section{Minimax Algorithm}\n\n\\begin{frame}{More Complex Games}\n\\BIT\n\\item Settings: a competitive zero-sum two-player game\n\\item Zero-sum: if the first player's score is $x$, then the other player gets $-x$\n\\item Each player tries to maximize his/her own score\n\\item Both players play perfectly\n\\vfill\n\\item Can be solved using a \\emph{minimax} algorithm\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Minimax Algorithm}\n\\BIT\n\\item Recursive algorithm that decides the best move for the current player at a given state\n\\item Define $f(S)$ as the optimal score of the current player who starts at state $S$\n\\item Let $T_1, T_2, \\ldots, T_m$ be states can be reached from $S$ using a single move\n\\item Let $T$ be the state that minimizes $f(T_i)$\n\\item Then, $f(S) = -f(T)$\n\\BIT\n\\item Intuition: minimizing the opponent's score maximizes my score\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Memoization}\n\\BIT\n\\item (Not \\emph{memorization} but \\emph{memoization})\n\\item A technique used to avoid repeated calculations in recursive functions\n\\item High-level idea: take a note (memo) of the return value of a function call. When the function is called with the same argument again, return the stored result\n\\item Each subproblem is solved at most once\n\\BIT\n\\item Some may not be solved at all!\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{Recursive Function without Memoization}\n\\begin{Verbatim}[xleftmargin=25pt]\nint fib(int n)\n{\n    if(n <= 1) return n;\n    return fib(n - 1) + fib(n - 2);\n}\n\\end{Verbatim}\n\\vfill\n\\BIT\n\\item How many times is \\verb,fib(1), called?\n\\EIT\n\\end{frame}\n\n\\begin{frame}[fragile]{Memoization using \\texttt{std::map}}\n\\begin{Verbatim}[xleftmargin=25pt]\nmap<int, int> memo;\nint fib(int n)\n{\n    if(memo.count(n)) return memo[n];\n    if(n <= 1) return n;\n    return memo[n] = fib(n - 1) + fib(n - 2);\n}\n\\end{Verbatim}\n\\vfill\n\\BIT\n\\item How many times is \\verb,fib(1), called?\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Minimax Algorithm Pseudocode}\n\\BIT\n\\item Given state $S$, want to compute $f(S)$\n\\vfill\n\\item If we know $f(S)$ already, return it\n\\item Set return value $x \\leftarrow -\\infty$\n\\item For each valid next state $T$:\n\\BIT\n\\item Update return value $x \\leftarrow \\max\\{x, -f(T)\\}$\n\\EIT\n\\item Write a memo $f(S) = x$ and return $x$\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Possible Extensions}\n\\BIT\n\\item The game is not zero-sum\n\\BIT\n\\item Each player wants to maximize his own score\n\\item Each player wants to maximize the difference between his score and the opponent's\n\\EIT\n\\item There are more than two players\n\\vfill\n\\item All of above can be solved using a similar idea\n\\EIT\n\\end{frame}\n\n\n\\section{Nim Game}\n\n\\begin{frame}{Nim Game}\n\\BIT\n\\item Settings: There are $n$ piles of stones. Two players take turns. Each player chooses a pile, and removes any number of stones from the pile. The one who takes the last stone wins. Find out the winner if both players play perfectly\n\\vfill\n\\item Can't really use DP if there are many piles, because the state space is huge\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Nim Game Example}\n\\BIT\n\\item Starts with heaps of 3, 4, 5 stones\n\\BIT\n\\item We will call them heap A, heap B, and heap C\n\\EIT\n\\vfill\n\\item Alice takes 2 stones from A: $(1, 4, 5)$\n\\item Bob takes 4 from C: $(1, 4, 1)$\n\\item Alice takes 4 from B: $(1, 0, 1)$\n\\item Bob takes 1 from A: $(0, 0, 1)$\n\\item Alice takes 1 from C and wins: $(0, 0, 0)$\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Solution to Nim}\n\\BIT\n\\item Given heaps of size $n_1, n_2, \\ldots, n_m$\n\\item The first player wins if and only if the \\emph{nim-sum} $n_1 \\oplus n_2 \\oplus \\cdots \\oplus n_m$ is nonzero ($\\oplus$ is bitwise XOR operator)\n\\vfill\n\\item Why?\n\\BIT\n\\item If the nim-sum is zero, then whatever the current player does, the nim-sum of the next state is nonzero\n\\item If the nim-sum is nonzero, it is possible to force it to become zero (not obvious, but true)\n\\EIT\n\\EIT\n\\end{frame}\n\n\n\\section{Grundy Numbers (Nimbers)}\n\n\\begin{frame}{Playing Multiple Games at Once}\n\\BIT\n\\item Suppose that multiple games are played at the same time. At each turn, the player chooses a game and make a move. You lose if there is no possible move. We want to determine the winner\n\\EIT\n\\begin{center}\n\\includegraphics[height=0.5\\textheight]{figures/games}\n\nFigure from \\url{http://sps.nus.edu.sg/~limchuwe/cgt/}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Grundy Numbers (Nimbers)}\n\\BIT\n\\item For each game, we compute its \\emph{Grundy number}\n\\item The first player wins if and only if the XOR of all the Grundy numbers is nonzero\n\\BIT\n\\item For example, the Grundy number of a one-pile version of the nim game is equal to the number of stones in the pile (we will see this again later)\n\\EIT\n\\vfill\n\\item Let's see how to compute the Grundy numbers for general games\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Grundy Numbers}\n\\BIT\n\\item Let $S$ be a state, and $T_1, T_2, \\ldots, T_m$ be states can be reached from $S$ using a single move\n\\vfill\n\\item The Grundy number $g(S)$ of $S$ is the smallest nonnegative integer that doesn't appear in $\\{g(T_1), g(T_2), \\ldots, g(T_m)\\}$\n\\BIT\n\\item Note: the Grundy number of a losing state is 0\n\\item Note: I made up the notation $g(\\cdot)$. Don't use it in other places\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Grundy Numbers Example}\n\\BIT\n\\item Consider a one-pile nim game\n\\item $g(0) = 0$, because it is a losing state\n\\item State 0 is the only state reachable from state 1, so $g(1)$ is the smallest nonnegative integer not appearing in $\\{g(0)\\} = \\{0\\}$. Thus, $g(1) = 1$\n\\item Similarly, $g(2) = 2$, $g(3) = 3$, and so on\n\\item Grundy numbers for this game is then $g(n) = n$\n\\BIT\n\\item That's how we got the nim-sum solution\n\\EIT\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Another Example}\n\\BIT\n\\item Let's consider a variant of the game we considered before; only 1 or 2 stones can be removed at each turn\n\\item Now we're going to play many copies of this game at the same time\n\\item Grundy number table:\n\n\\begin{center}\n\\begin{tabular}{|c|cccccccc|}\n\\hline\n$n$&0&1&2&3&4&5&6&7 \\\\ \\hline\n$g(n)$&0&1&2&0&1&2&0&1 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Another Example (continued)}\n\\BIT\n\\item Grundy number table:\n\n\\begin{center}\n\\begin{tabular}{|c|cccccccc|}\n\\hline\n$n$&0&1&2&3&4&5&6&7 \\\\ \\hline\n$g(n)$&0&1&2&0&1&2&0&1 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\vfill\n\\item Who wins if there are three piles of stones $(2, 4, 5)$?\n\\item What if we start with $(5, 11, 13, 16)$?\n\\item What if we start with $(10^{100}, 10^{200})$?\n\\EIT\n\\end{frame}\n\n\\begin{frame}{Tips for Solving Game Problems}\n\\BIT\n\\item If the state space is small, use memoization\n\\item If not, print out the result of the game for small test data and look for a pattern\n\\BIT\n\\item This actually works really well!\n\\EIT\n\\item Try to convert the game into some nim-variant\n\\item If multiple games are played at once, use Grundy numbers\n\\EIT\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "28140ee80f5a4649bb7a5130cea85a3a5094fc1c", "size": 10116, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "97si_slides/combinatorial_games.tex", "max_stars_repo_name": "Charleo85/stanfordacm", "max_stars_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1624, "max_stars_repo_stars_event_min_datetime": "2015-08-11T03:23:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T17:26:03.000Z", "max_issues_repo_path": "97si_slides/combinatorial_games.tex", "max_issues_repo_name": "Charleo85/stanfordacm", "max_issues_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2015-05-03T17:12:19.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-26T01:54:14.000Z", "max_forks_repo_path": "97si_slides/combinatorial_games.tex", "max_forks_repo_name": "Charleo85/stanfordacm", "max_forks_repo_head_hexsha": "1cc79c15e8e0e9c27e1470c7400cdb50aaa6bb82", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 598, "max_forks_repo_forks_event_min_datetime": "2015-05-03T10:50:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T20:25:05.000Z", "avg_line_length": 27.1935483871, "max_line_length": 236, "alphanum_fraction": 0.7172795571, "num_tokens": 3240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4177060989544045}}
{"text": "\\documentclass[11pt]{article}\n%\\usepackage[firstpage]{draftwatermark}\n\\usepackage{times}\n\\usepackage{pdfpages}\n\\usepackage{fullpage}\n\\usepackage{url}\n\\usepackage{hyperref}\n\\usepackage{fancyhdr}\n\\usepackage{graphicx}\n\\usepackage{tabularx}\n\\usepackage{enumitem}\n\\usepackage{indentfirst}\n\\usepackage{subcaption}\n\\usepackage{units}\n\\usepackage{bm}\n\n\\usepackage{./math_bbing}\n\n\n% Highlighting\n\\usepackage{color,soul}\n\\DeclareRobustCommand{\\hlr}[1]{{\\sethlcolor{red}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlg}[1]{{\\sethlcolor{green}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlb}[1]{{\\sethlcolor{blue}\\hl{#1}}}\n\\DeclareRobustCommand{\\hly}[1]{{\\sethlcolor{yellow}\\hl{#1}}}\n\n\\setcounter{secnumdepth}{4}\n\\graphicspath{{images/}}\n\\pagestyle{fancy}\n\n% Conditional for notes\n\\newif\\ifnotes\n\\notesfalse\n\n\n\\newcommand{\\doctitle}{USV Plugins, Theory of Operation}\n\n\\newcommand{\\docnumber}{\\doctitle}\n\n\\addtolength{\\headheight}{2em}\n\\addtolength{\\headsep}{1.5em}\n\\lhead{\\docnumber}\n\\rhead{}\n\n\\newcommand{\\capt}[1]{\\caption{\\small \\em #1}}\n\n\\cfoot{\\small Brian Bingham \\today \\\\ \\thepage}\n\\renewcommand{\\footrulewidth}{0.4pt}\n\n\\newenvironment{xitemize}{\\begin{itemize}\\addtolength{\\itemsep}{-0.75em}}{\\end{itemize}}\n\\newenvironment{tasklist}{\\begin{enumerate}[label=\\textbf{\\thesubsubsection-\\arabic*},ref=\\thesubsubsection-\\arabic*,leftmargin=*]}{\\end{enumerate}}\n\\newcommand\\todo[1]{{\\bf TODO: #1}}\n\\setcounter{tocdepth}{2}\n\\setcounter{secnumdepth}{4}\n\n\\makeatletter\n\\newcommand*{\\compress}{\\@minipagetrue}\n\\makeatother\n\n%\\renewcommand{\\chaptername}{Volume}\n%\\renewcommand{\\thesection}{\\Roman{section}}\n%\\renewcommand{\\thesubsection}{\\Roman{section}-\\Alph{subsection}}\n\n\\begin{document}\n\\input{./Commands}  \n\\input{./defs}\n\\newpage\n% Title Page\n\\setcounter{page}{1}\n\\begin{center}\n{\\huge \\doctitle}\n\\end{center}\n\n\n\\section{Overview}\nThe rigid body dynamics implemented in Gazebo are augmented with environmental forces to simulate an unmanned surface vessel via a set of Gazebo plugins.  These plugins simulate the effects of\n\\begin{itemize}\n\\item Dynamics\n  \\begin{itemize}\n  \\item Maneuvering - added mass, drag, etc.\n  \\item Wave field - motion of the water surface\n  \\end{itemize}\n\\item Thrust - vehicle propulsion\n\\item Wind - windage.\n  \\end{itemize}\n\nThis document is a high-level description of the implementation, but not a full documentation of the models and techniques used.  The code itself is the ultimate documentation; comments have been included in the source to allow for users to adapt and extend these simple techniques for their own purposes.\n\n\\section{Maneuvering Model and Waves}\nThe influence of both maneuvering and wave forces on the motion of the USV is implemented as a single model plugin for Gazebo.  Currently there is only one implementation, but other implementations, with varying fidelity, could be developed in the future.\n\n\\subsection{usv gazebo dynamics plugin}\n\n\\subsubsection{Maneuvering Model}\nThe plugin implements a portion of the nonlinear maneuvering equations from \\cite{fossen11handbook}, \n\\beqn\n\\underbrace{\\bm{M}_{RB}\\dot{\\bm{\\nu}}+\\bm{C}_{RB}(\\bm{\\nu})\\bm{\\nu}}_\\text{rigid-body forces} +\n\\underbrace{\\bm{M}_A\\dot{\\bm{\\nu}}_r + \\bm{C}_A(\\bm{\\nu}_r)\\bm{\\nu}_r + \n\\bm{D}(\\bm{\\nu}_r)\\bm{\\nu}_r}_\\text{hydrodynamic forces}\n= \\bm{\\tau}+\\bm{\\tau}_{wind}+\\bm{\\tau}_{waves}\n\\label{e:fossenmodel}\n\\eeqn\nwhere the state vector $\\bm{\\nu}=[u,v,r]^T$ includes the velocities $u$, $v$ and $r$ are in the surge, sway and yaw directions respectively and  $\\bm{\\nu}_r$ is the velocity vector relative to an irrotational water current $\\bm{\\nu}_c$, i.e., $\\bm{\\nu}=\\bm{\\nu}_r+\\bm{\\nu}_c$.\nThe \\emph{rigid-body forces} components are simulated via the Gazebo physics engine, while the \\emph{hydrodynamic forces} are determined via the plugin.\n\n\nThe six DOF maneuvering model is specified by the following matrices. The added mass matrix expressed as \n\\beqn\n\\bm{M}_{A}= \\left[ \n\\begin{array}{cccccc}\n-X_{\\dot{u}} & 0 & 0 &0 &0 &0 \\\\\n0 & -Y_{\\dot{v}} & 0 &0 &0 &0 \\\\\n0 & 0  &0.1 &0 &0 &0 \\\\\n0 &0 &0 &0.1 &0 &0 \\\\\n0 &0 &0 &0 &0.1 &0 \\\\\n0 &0 &0 &0 & 0 & -N_{\\dot{r}} \n\\end{array} \\right].\n\\eeqn\nThe Coriolis-centripetal matrix for the added mass expressed as \n\\beqn\n\\bm{C}_{A}(\\bm{\\nu}_r)= \\left[ \n\\begin{array}{cccccc}\n0 &0 &0 &0 & 0 & Y_{\\dot{v}}v_r+Y_{\\dot{r}}r \\\\\n0 &0 &0 &0 & 0 & -X_{\\dot{u}}u_r\\\\\n0 &0 &0 &0 &0 &0 \\\\\n0 &0 &0 &0 &0 &0 \\\\\n0 &0 &0 &0 &0 &0 \\\\\n0 &0 &0 & -Y_{\\dot{v}}v_r - Y_{\\dot{r}}r& X_{\\dot{u}}u_r & 0 \n\\end{array} \\right].\n\\eeqn.\nIt is worth noting that $\\bm{C}_A$ includes the nonlinear Munk moment (see \\cite{fossen11handbook} p.121).  Following \\cite{fossen11handbook} the SNAME notation for the hydrodynamic derivatives.  Currently these terms are neglected in the model for simplicity and because of the challenges in estimating and verifying the pertinent parameters.\n\nThe linear and quadratic drag terms\n\\beqn\n\\bm{D}(\\bm{\\nu}_r)= \\left[ \n\\begin{array}{cccccc}\nX_u + X_{u|u|}|u| & 0 & 0 &0 &0 &0\\\\\n0 & Y_v + Y_{v|v|}|v| &0  &0 &0 &0\\\\\n0 &0 &Z_w  &0 &0 &0 \\\\\n0 &0 &0 &K_p  &0 &0 \\\\\n0 &0 &0 &0 &M_q &0 \\\\\n0 &0 &0 &0 &0 & N_r+N_{r|r|}|r|\n\\end{array} \\right].\n\\eeqn\nwhich neglects coupleing between sway and yaw.\n\n\n\\subsubsection{Wave Forcing}\n\nGerstner waves with three components \\cite{tessendorf99simulating}.  Each of the component waves is user-specified by an amplitude, period and direction.  Deep water dispersion is used in simulating the wave behaviors.\n\nTo determine the influence of the wave field on the vessel, the vessel footprint is decomposed into a simple grid, with points at each corner of the vessel.  The vertical displacement is calculated for each of these points.  Using the vessel's position and attitude, the buoyancy force at each location is determined and then applied at that grid point.\n\n\n\\section{Thrust}\nThe external force and torque from the vessel propulsion is implemented in a standalone plugin to allow for independent extension to higher-fidelity thrust configurations and models.\n\n\\subsection{usv gazebo thrust plugin}\nThe plugin subscribes the \\verb+cmd_drive+ topic to receive messages of type UsvDrive (defined in the \\verb+usv_msgs+ package).  These message specify left and right thrust commands where the commands are scaled from $\\{-1.0-1.0\\}$. \n\nTo emulate the thruster behavior, the commands are mapped to a thrust force applied to the model.  Two possible mappings are currently available.  Users select which mapping using the \\verb+mappingType+ SDF tag.\n\nThe axial force is applied at a point vertically separated from the CG as specified by the \\texttt{thrustOffsetZ} parameter.  This results in coupling between the forward thrust and the vehicle pitch.\n\n\\subsubsection{0: Linear thruster map}\nThe command values (-1.0 to 1.0) are scaled linearly to the \\texttt{maxForceFwd} and \\texttt{maxForceRev} SDF parameters.  A total forward thrust is caculated as the sum.  A total torque is calculated assuming the two thrust forces are applied at opposite ends of the \\texttt{boatWidth} parameter.\n\n\\subsubsection{1: GLF thruster map}\n\nIn this mode two generalized logistic functions (GLFs) are used to convert commands to thrust force.  One set of GLF parameters are used for positive commands (0 to 1.0) and a second set of parameters are used for negative commands (-1 to 0).  The form of the GLF used is\n\\begin{equation}\n  T = A + \\frac{K-A}{\\left(C+\\exp(-B(x-M))\\right)^{1/\\nu}}\n\\end{equation}\nwhere $T$ is the thrust force in Newtons, $x$ is the command and the remaining variables are the GLF parameters.  To identify the GLF parameters, the data from \n\\cite{sarda17station} was used---Figure\\ref{f:sarda}.  The Python script for accomplishing this is include in the \\verb+usv_gazebo_plugins+ repository in the \\verb+thrust_curve_fit+ directory.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{images/sarda_tcurve.png}\n  \\caption{Empirical thrust performance data from \\cite{sarda17station}.}\n  \\label{f:sarda}\n\\end{figure}\n\nThe data was fit with two separate GLF functions using the \\verb+scipy.optimize.fmin+ optimization routine to minimize the squared error.  The results are shown in Figure\\ref{f:fit}.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{images/wamv_glf_annote.png}\n  \\caption{GLF fit of empirical data.}\n  \\label{f:fit}\n\\end{figure}\n\n\n\\section{Wind}\n\nThe influence of wind on the motion of the USV is implemented as a standalone model plugin for Gazebo.  Currently there is only one implementation, but other implementations, with varying fidelity, could be developed in the future.\n\n\\subsection{usv gazebo wind plugin}\n\nThe wind forces (x and y) and moment (yaw) are predicted following the models presented by Fossen~\\cite{fossen94guidance}.\n\nThe wind velocity on the vessel ($V_w$) is considered to be a constant velocity and direction.  If desired, this could be extended to include a parameterized wind spectrum the distribution of wind velocities over time, e.g., average wind velocity, gusts, etc.  For the current implementation the constant wind velocity is specified as a three element vector which specifies the wind speed the world-frame x, y and z coordinates with units of \\unitfrac[]{m}{s}.  The z component is ignored.\n\nThe resulting forces and moments on the vessel are determined based on the user-specified force/moment coefficients and the relative wind velocity.  Within the plugin, the relative (or apparent) wind velocity vector $V_R$.  The forces/moment are calculated as\n\\begin{eqnarray}\n  X_{wind} &=& (C_X) V_{R_x} |V_{R_x}| \\\\\n  Y_{wind} &=& (C_Y) V_{R_y} |V_{R_y}| \\\\\n  N_{wind} &=& -2.0 (C_N) V_{R_x} V_{R_y} \\\\\n\\end{eqnarray}\nwhere $C_X$, $C_Y$ and $C_N$ are specified as the three element \\verb+wind_coeff_vector+.  Approximate values for these coefficients are given in \\cite{sarda17station} which can then be tuned to give reasonable response.\n\n%\\newpage\n%\\setcounter{page}{1}\n\\bibliographystyle{ieeetr}\n\\bibliography{refs}\n\n\\end{document}\n", "meta": {"hexsha": "dfd956dd4d7fe8e5ab5208825ca1d5b84067c2ce", "size": 9918, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ros_pkg/robotx_gazebo/docs/theory_of_operation.tex", "max_stars_repo_name": "Choi-Laboratory/Ribbon-Bridge-Simulation", "max_stars_repo_head_hexsha": "1461653b7f0a3a7ca6f1130a80796956e20696c2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 457, "max_stars_repo_stars_event_min_datetime": "2020-03-21T05:27:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T12:05:52.000Z", "max_issues_repo_path": "ros_pkg/robotx_gazebo/docs/theory_of_operation.tex", "max_issues_repo_name": "Choi-Laboratory/Ribbon-Bridge-Simulation", "max_issues_repo_head_hexsha": "1461653b7f0a3a7ca6f1130a80796956e20696c2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2020-05-18T16:48:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T05:43:24.000Z", "max_forks_repo_path": "ros_pkg/robotx_gazebo/docs/theory_of_operation.tex", "max_forks_repo_name": "Choi-Laboratory/Ribbon-Bridge-Simulation", "max_forks_repo_head_hexsha": "1461653b7f0a3a7ca6f1130a80796956e20696c2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 121, "max_forks_repo_forks_event_min_datetime": "2020-03-21T06:43:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T12:27:29.000Z", "avg_line_length": 45.495412844, "max_line_length": 489, "alphanum_fraction": 0.7417826175, "num_tokens": 2962, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.41770609278510157}}
{"text": "\\section{\\hogwild}\n\nPrior to 2011, parallel stochastic gradient methods had been introduced, but\nmost suffered from poor scaling due to the necessity of locks. A naive\nimplementation could look like:\n\\begin{breakablealgorithm}\n  \\caption{Very Naive Parallel Stochastic Gradient}\n  \\label{alg:naivePSG}\n  \\begin{algorithmic}[1]\n    \\Require Number of data points $N$, seperable loss function $f\n    = \\sum_{e \\in E} f_e(x_e)$, Initial $x$.\n    \\For{epoch $= 1 \\to$ MAX\\_EPOCHS}\n      \\State \\#pragma omp parallel for\n      \\For{$k = 1 \\to N$}\n        \\State Choose $i$ uniformly from $\\{1, \\dots, |E|\\}$.\n        \\State \\#pragma omp critical\n        \\Indent\n          \\State Read current parameters $x$.\n          \\State Compute $\\nabla f_i(x)$.\n          \\State $x \\gets x - \\eta \\nabla f_i(x)$.\n        \\EndIndent\n      \\EndFor\n    \\EndFor\n  \\end{algorithmic}\n\\end{breakablealgorithm}\nNote that the version presented above is one with a fixed number of iterations,\nas the discussion of stopping criteria seems to be similar to that of the\nstochastic gradient method, and for extremely large data sets, is often\nheuristic. But it's clear here that such an algorithm would only effectively be\nparallelizing the unform sample of $i$ in $\\{1, \\dots, |E|\\}$, and it's overall\nparallel efficiency would likely be poor. Technically, you can improve the above\nby replacing the critical section with selective locks on components of $x$\nbased on the sparsity pattern of $\\nabla f_i(x)$, but because the process of\nacquiring locks is much more expensive than floating point arithmetic, this\nhelps little.\n\nHowever, in 2011, the article \"\\hogwild: A Lock-Free Approach to Parallelizing\nStochastic Gradient Descent\" by Niu et al. \\cite{2011NRRW} proposed a very\nsimple solution to this problem. Remove the locks!%\n\\footnote{\n  Apparently this was discovered by accident by Feng Niu, one of the original\n  paper's authors, when he was debugging stochastic gradient method code. I wish\n  my troubleshooting was nearly as effective... \\cite{2014Recht}\n} \\clearpage\n\\begin{breakablealgorithm}\n  \\caption{\\hogwild: Asynchronous Stochastic Gradient with replacement}\n  \\label{alg:hogwildwreplacement}\n  \\begin{algorithmic}[1]\n    \\Require Number of data points $N$, seperable loss function $f\n    = \\sum_{e \\in E} f_e(x_e)$, Initial $x$.\n    \\For{epoch $= 1 \\to$ MAX\\_EPOCHS}\n      \\State \\#pragma omp parallel for\n      \\For{$k = 1 \\to N$}\n        \\State Choose $i$ uniformly from $\\{1, \\dots, |E|\\}$.\n        \\State Read current parameters $x$.\n        \\State Compute $\\nabla f_i(x)$.\n        \\State $x \\gets x - \\eta \\nabla f_i(x)$. \\Comment{Must be done\n        atomically}\n      \\EndFor\n    \\EndFor\n  \\end{algorithmic}\n\\end{breakablealgorithm}\nand should we want to sample without replacement the algorithm is easily\nmodified to:\n\\begin{breakablealgorithm}\n  \\caption{\\hogwild: Asynchronous Stochastic Gradient without replacement}\n  \\label{alg:hogwildworeplacement}\n  \\begin{algorithmic}[1]\n    \\Require Number of data points $N$, seperable loss function $f\n    = \\sum_{e \\in E} f_e(x_e)$, Initial $x$.\n    \\For{epoch $= 1 \\to$ MAX\\_EPOCHS}\n      \\State Let $P$ be a random permutation of $\\{1, \\dots, |E|\\}$.\n      \\Comment{i.e. a Fisher-Yates Shuffle.}\n      \\State \\#pragma omp parallel for\n      \\For{$k = 1 \\to N$}\n        \\State $i \\gets P[k]$.\n        \\State Read current parameters $x$.\n        \\State Compute $\\nabla f_i(x)$.\n        \\State $x \\gets x - \\eta \\nabla f_i(x)$. \\Comment{Must be done\n        atomically}\n      \\EndFor\n    \\EndFor\n  \\end{algorithmic}\n\\end{breakablealgorithm}\n\nIt should be noted that although the formal OMP locks have been removed, atomic\noperations are still required in order to prevent mutual exclusion. However, no\nguards have been placed to prevent a thread from overwriting another's\ncomputation midway through, and it's not obvious as to why such a race condition\nwouldn't destroy the performance of the Stochastic Gradient method. However,\nwith certain assumptions one can show that \\hogwild\\ behaves roughly like a noisy\nstochastic gradient method, and thus shares its convergence properties.\n", "meta": {"hexsha": "8876acb74604a56237bc3e87a682487510b22f44", "size": 4130, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/TeXsrc/src/hogwild.tex", "max_stars_repo_name": "abhijit-c/HOGWILD", "max_stars_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/TeXsrc/src/hogwild.tex", "max_issues_repo_name": "abhijit-c/HOGWILD", "max_issues_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/TeXsrc/src/hogwild.tex", "max_forks_repo_name": "abhijit-c/HOGWILD", "max_forks_repo_head_hexsha": "1ae85888fb5c33f0cf01043064d30106e7a3de39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.4086021505, "max_line_length": 81, "alphanum_fraction": 0.7041162228, "num_tokens": 1134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.41770609138461107}}
{"text": "\\chapter{A Non-Equilibrium Green's Function (NEGF) Based Magnetic Tunnel Junction (MTJ) Simulator in MATLAB\\texttrademark}\n\n\\section{Introduction}\n\nThe Non-Equilibrium Green's Function (NEGF) based transport model was proposed in \\cite{Salahuddin2007e,Datta2012b}. This document presents an implementation of a MATLAB\\texttrademark{} based solver that calculates the $I-V$ characteristics of a magnetic tunnel junction (MTJ) using the proposed model. The NEGF model is based on the single band effective mass Hamiltonian ($\\mathcal{H}$) and self-energy ($\\Sigma_{L,R}$) which are used to calculate Green's function ($G$), electron correlation matrix ($G^n$) and charge current density ($J$). Fig.~\\ref{fig:negf_grid} shows the device structure and coordinate system used for modeling MTJs. In a 1-D system, the Hamiltonian may be written for five regions: (a) the left ferromagnet (FM) contact, (b) the right FM contact, (c) the oxide channel, (d) the left FM-oxide interface, and (d) the right oxide-FM interface. Generally, the Hamiltonian, $\\mathcal{H}$, may be written as \\begin{equation}\n\\mathcal{H}=\\left[\\begin{IEEEeqnarraybox}[\\scriptsize][c]{/c/c/c/c/c/c/c/c/c/c/c/}\n\\alpha_{HL1} & \\beta_{HL1} & 0 & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & 0 \\\\\n\\beta^{\\dagger}_{HL1} & \\ddots & \\ddots & \\ddots & ~ & ~ & ~ & ~ & ~ & ~ & \\vdots \\\\\n0 & \\ddots & \\alpha_{HL1} & \\beta_{HL1} & \\ddots & ~ & ~ & ~ & ~ & ~ & \\vdots \\\\\n\\vdots & \\ddots & \\beta^{\\dagger}_{HL1} & \\alpha_{IL} & \\beta_{OX} & \\ddots & ~ & ~ & ~ & ~ & \\vdots \\\\\n\\vdots & ~ & \\ddots & \\beta^{\\dagger}_{OX} & \\alpha_{OX} & \\ddots & \\ddots & ~ & ~ & ~ & \\vdots \\\\\n\\vdots & ~ & ~ & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & ~ & ~ & \\vdots \\\\\n\\vdots & ~ & ~ & ~ & \\ddots & \\ddots & \\alpha_{OX} & \\beta_{OX} & \\ddots & ~ & \\vdots \\\\\n\\vdots & ~ & ~ & ~ & ~ & \\ddots & \\beta^{\\dagger}_{OX} & \\alpha_{IR} & \\beta_{HL2} & \\ddots & \\vdots \\\\\n\\vdots & ~ & ~ & ~ & ~ & ~ & \\ddots & \\beta^{\\dagger}_{FM,R} & \\alpha_{HL2} & \\ddots & 0 \\\\\n\\vdots & ~ & ~ & ~ & ~ & ~ & ~ & \\ddots & \\ddots & \\ddots & \\beta_{HL2} \\\\\n0 & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & \\cdots & 0 & \\beta^{\\dagger}_{HL2} & \\alpha_{HL2}\n\\end{IEEEeqnarraybox}\\right]\\label{eq:genHam}\n\\end{equation}where the number of $\\alpha_{HL1}$, $\\alpha_{OX}$ and $\\alpha_{HL2}$ correspond to the number of grid points to model the left FM contact, the oxide channel, and the right FM contact, respectively, in the direction of electron transport (the \\emph{longitudinal} direction). When a 1-D problem is considered (refer to Fig.~\\ref{fig:negf_grid}), we write \\afterpage{\n\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.75]{ResearchNotes_NEGF/figs/simframe/negf_grid.eps}\n\\caption{Illustration of the reference axis (left) and Non-Equilibrium Green's Function based description of the magnetic tunnel junction (right). The reference axis shows how magnetization angles are named in this work. The coupling between lattice sites are $t_{FM}$ and $t_{OX}$ and individual lattice sites are described by the Hamiltonian $\\alpha_{HL1}$, $\\alpha_{HL2}$ and $\\alpha_{OX}$. The complete Hamiltonian describing the MTJ is written in terms of $t_{FM}$, $t_{OX}$, $\\alpha_{HL1}$, $\\alpha_{HL2}$ and $\\alpha_{OX}$.}\n\\label{fig:negf_grid}\n\\end{figure}\\begin{figure}[!t]\n\\centering\n\\includegraphics[scale=0.75]{ResearchNotes_NEGF/figs/simframe/negf_grid.eps}\n\\caption{Temp holder}\n\\label{fig:bandDiags}\n\\end{figure}\n\\clearpage\n}\\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\alpha_{FM,L} = 2t_{FM,Left}I \\\\\n\\alpha_{HL2}&=&\\alpha_{FM,R} = 2t_{FM,Right}I \\\\\n\\alpha_{OX}&=&\\alpha_{Ch} = 2t_{OX}I \\\\\n\\alpha_{IL}&=&\\frac{\\alpha_{OX}+\\alpha_{FM,L}}{2} \\\\\n\\alpha_{IR}&=&\\frac{\\alpha_{OX}+\\alpha_{FM,R}}{2} \\\\\n\\beta_{HL1}&=&\\beta_{FM,L} = -t_{FM,Left}I \\\\\n\\beta_{HL2}&=&\\beta_{FM,R} = -t_{FM,Right}I \\\\\n\\beta_{OX}&=&-t_{OX}I\n\\end{IEEEeqnarray} where $I$ is the $2\\times{}2$ identity matrix. Then, effective masses are used to write \\begin{IEEEeqnarray}{rCl}\nt_{FM,Left}&=&\\frac{\\hbar^{2}}{2m^{*}_{FM,Left}a^{2}} \\\\\nt_{FM,Right}&=&\\frac{\\hbar^{2}}{2m^{*}_{FM,Right}a^{2}} \\\\\nt_{OX}&=&\\frac{\\hbar^{2}}{2m^{*}_{OX}a^{2}}\n\\end{IEEEeqnarray}where $a$ is the uniform grid spacing, $\\hbar=\\frac{h}{2\\pi}$ is the reduced Planck constant, and $m^{*}_{OX}$, $m^{*}_{FM,Left}$, and $m^{*}_{FM,Right}$ are the effective electron masses in the oxide channel, the left FM contact, and the right FM contact, respectively. Note that the on-site energy at every grid point is represented by a $2\\times{}2$ matrix to handle the spin degeneracy when $\\mathcal{H}$ is written this way.\n\nIn a ferromagnetic material, the conduction bands for up-spin and down -spin electrons are split. As illustrated in Fig.~\\ref{fig:bandDiags}, $U_{b}$ is the barrier height of the tunnel barrier, and $\\Delta_{L}$ and $\\Delta_{R}$ are the splitting energies between the bottom of the conduction bands for up-spin and down-spin electrons in the left FM contact and right FM contact, respectively. The potential barrier of the tunnel oxide is included in $\\mathcal{H}$ by writing \\begin{IEEEeqnarray}{rCl}\n\\alpha_{OX}&=&\\alpha_{Ch}+U_{b}I \\\\\n\\alpha_{IL}&=&0.5\\times\\left(\\alpha_{OX}+\\alpha_{FM,L}+U_{b}\\right) \\\\\n\\alpha_{IR}&=&0.5\\times\\left(\\alpha_{OX}+\\alpha_{FM,R}+U_{b}\\right)\n\\end{IEEEeqnarray}where $I$ is the $2\\times{}2$ identity matrix. Then, to include the conduction band splitting, we rewrite \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\alpha_{FM,L}+U_{split,L} \\\\\n\\alpha_{HL2}&=&\\alpha_{FM,R}+U_{split,R} \\\\\n\\alpha_{IL}&=&0.5\\times\\left(\\alpha_{OX}+\\alpha_{FM,L}+U_{b}+U_{split,L}\\right) \\\\\n\\alpha_{IR}&=&0.5\\times\\left(\\alpha_{OX}+\\alpha_{FM,R}+U_{b}+U_{split,R}\\right) \\\\\nU_{split,L}&=&\\begin{bmatrix}\n0 & 0 \\\\\n0 & \\Delta_{L}\n\\end{bmatrix} \\label{eq:onsiteL} \\\\\nU_{split,R}&=&\\begin{bmatrix}\n0 & 0 \\\\\n0 & \\Delta_{R}\n\\end{bmatrix} \\label{eq:onsiteR}\n\\end{IEEEeqnarray}Eqs.~(\\ref{eq:onsiteL}) and (\\ref{eq:onsiteR}) are written assuming the magnetization directions of the left and right FM contacts are the same and are pointing in the $+\\widehat{z}$ direction of the reference frame. If they are different, we may choose one of the FM contacts (e.g., left FM contact) to be the reference frame and define its magnetization direction to be the $+\\widehat{z}$ direction. Using the left FM contact as the reference frame, the magnetization direction of the right FM contact, $\\widehat{m}$, may be written. In this example, a unitary transformation needs to be performed on $U_{split,R}$ to rewrite it as \\begin{equation}\nU_{split,R} = \\frac{\\left(I-\\vv{\\sigma}\\cdot\\widehat{m}\\right)\\Delta_{R}}{2} \\label{eq:unitaryTrans}\n\\end{equation}where $\\vv{\\sigma}$ is the vector of Pauli spin matrices. Note that for any arbitrarily chosen reference frame, unitary transformation is performed on both $U_{split,L}$ and $U_{split,R}$, using $\\widehat{m}$ to be the magnetization vector direction for the corresponding ferromagnetic contact in the chosen reference frame. By definition, the dot product in Eq.~(\\ref{eq:unitaryTrans}) yields a $2\\times{}2$ matrix that is a linear combination of the Pauli spin matrices given by \\begin{equation}\n\\vv{\\sigma}\\cdot\\widehat{m} = m_{x}\\vv{\\sigma}_{x}+m_{y}\\vv{\\sigma}_{y}+m_{z}\\vv{\\sigma}_{z}\n\\end{equation}where the components of the vectors have been explicitly written. Note that unitary transformations acting on identity matrices does not do anything. Hence, only $U_{split,L}$ and $U_{split,R}$ needs to be modified to obtain $\\mathcal{H}$ when any of the magnetizations do not point along the $+\\widehat{z}$ direction of the chosen reference frame.\n\nThe applied voltage across the MTJ modifies the potential profile along the longitudinal direction of the MTJ and may be modeled as $U_{V}$. The non-zero entries of $U_{V}$ are on its main diagonal and may be calculated using \\begin{equation}\nU_{V}(i,i)=\\left\\lbrace \\,\n\\begin{IEEEeqnarraybox}[][c]{l?s}\n\\frac{qV}{2}I & if $i$ is in $HL1$ or $IL$, \\\\\n\\frac{-qV}{2}I & if $i$ is in $HL2$ or $IR$, \\\\\nqV\\left(\\frac{1}{2}-\\frac{i}{N+1}\\right)I & if $i$ is in $OX$.\n\\end{IEEEeqnarraybox} \\right.\n\\end{equation}where $N$ is the total number of grid points in the OX region. Next, the full Hamiltonian, $\\mathcal{H}_{Full}$, is written as \\begin{equation}\n\\mathcal{H}_{Full}=\\mathcal{H}+U_{V}\n\\end{equation}\n\nThe self-energy matrices, $\\Sigma_{L,R}$, represent the coupling of the external system to the contacts. Based on the construction of $\\mathcal{H}_{Full}$,  the non-zero components $\\Sigma_{L}$ and $\\Sigma_{R}$ are on the top left and bottom right, respectively. The non-zero parts of the self-energies may be written as \\begin{equation}\\label{eq:self_energyL}\n\\Sigma_{L}=\n\\begin{bmatrix}\n-t_{FM,Left}exp\\left(-ik_{L}^{\\uparrow}a\\right) & 0 \\\\\n0 & -t_{FM,Left}exp\\left(-ik_{L}^{\\downarrow}a\\right)\n\\end{bmatrix}\n\\end{equation}\\begin{equation}\\label{eq:self_energyR}\n\\Sigma_{R}=\n\\begin{bmatrix}\n-t_{FM,Right}exp\\left(-ik_{R}^{\\uparrow}a\\right) & 0 \\\\\n0 & -t_{FM,Right}exp\\left(-ik_{R}^{\\downarrow}a\\right)\n\\end{bmatrix}\n\\end{equation} where \\begin{equation}\nk_{L}^{\\uparrow}=cos^{-1}\\left(1-\\frac{E+\\frac{qV}{2}}{2t_{FM,Left}} \\right)\n\\end{equation}\\begin{equation}\nk_{R}^{\\uparrow}=cos^{-1}\\left(1-\\frac{E-\\frac{qV}{2}}{2t_{FM,Right}} \\right)\n\\end{equation}\\begin{equation}\nk_{L}^{\\downarrow}=cos^{-1}\\left(1-\\frac{E+\\frac{qV}{2}-\\Delta_{L}}{2t_{FM,Left}} \\right)\n\\end{equation}\\begin{equation}\nk_{R}^{\\downarrow}=cos^{-1}\\left(1-\\frac{E-\\frac{qV}{2}-\\Delta_{R}}{2t_{FM,Right}} \\right)\n\\end{equation}$E$ is the energy level of interest. This form of Eqs.~(\\ref{eq:self_energyL}) and (\\ref{eq:self_energyR}) are used if the magnetization direction is in the $+\\widehat{z}$ direciton. As before, a unitary transformation needs to be performed on $\\Sigma_{L,R}$ of the FM contact whose magnetization direction is not in the $+\\widehat{z}$ direciton of the reference frame. The matrix for unitary transformation is given by \\begin{equation}\n\\Lambda_{trans} =\n\\begin{bmatrix}\ncos\\left(\\frac{\\theta}{2}\\right)exp\\left(i\\frac{\\phi}{2}\\right) & sin\\left(\\frac{\\theta}{2}\\right)exp\\left(-i\\frac{\\phi}{2}\\right) \\\\\n-sin\\left(\\frac{\\theta}{2}\\right)exp\\left(i\\frac{\\phi}{2}\\right) & cos\\left(\\frac{\\theta}{2}\\right)exp\\left(-i\\frac{\\phi}{2}\\right) \\\\\n\\end{bmatrix}\n\\end{equation} where $\\theta$ and $\\phi$ correspond to the spherical angles of the magnetization vector direction to the Cartesian axis in the reference frame. The self-energy matrices are transformed using \\begin{equation}\n\\Sigma_{L,R}^{new}=\\Lambda_{trans}\\Sigma_{L,R}^{old}\\Lambda_{trans}^{\\dagger}\n\\end{equation}\n\nWith the Hamiltonian ($\\mathcal{H}_{Full}$) and the self-energy matrices ($\\Sigma_{L,R}$), all quantities of interest may be calculated from the following:\n\\begin{align}\n\\textbf{Green's function: } G(E) &= (EI - \\mathcal{H}_{Full} - \\Sigma_L - \\Sigma_R)^{-1} \\\\\n\\textbf{Spectral density: } A &= i(G-G^{\\dagger})=G \\Gamma G^{\\dagger} \\\\\n\\textbf{Electron correlation function: } G^{n}(E) &= G(\\Sigma_{L}^{in} + \\Sigma_{R}^{in})G^{\\dagger} \\label{eq:eCorrFunc} \\\\\n\\textbf{In-scattering function: } \\Sigma_{L,R}^{in}(E) &= \\Gamma_{L,R}(E)f_{L,R}(E) \\\\\n\\textbf{Broadening matrix: } \\Gamma_{L,R}(E) &= i(\\Sigma_{L,R} - \\Sigma_{L,R}^{\\dagger})\n\\end{align} The diagonal elements of $A$ and $G^n$ correspond to the local density of states and electron density, respectively. $\\Sigma^{in}$ is the in-scattering function describing the rate at which electrons enter the device from the $L$ and $R$ contacts, and $f_{L,R}(E)$ are the Fermi functions in the $L$ and $R$ contacts. \\begin{IEEEeqnarray}{rCl}\nf_{L}(E)&=&\\frac{1}{1+exp\\left(\\frac{E-\\mu_{L}}{k_{B}T}\\right)} \\\\\nf_{R}(E)&=&\\frac{1}{1+exp\\left(\\frac{E-\\mu_{R}}{k_{B}T}\\right)}\n\\end{IEEEeqnarray}where $k_{B}$ is the Boltzmann constant, $T$ is the absolute temperature of the system, and $\\mu_{L}$ and $\\mu_{R}$ are the electrochemical potential of the left and right FM contacts, respectively. The charge and spin currents flowing through the MTJ are then calculated using\n\\begin{center}\n\\textbf{\\underline{Charge current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_jcurr}\nJ_{k,k+1} = Real \\left(\\frac{1}{i\\hbar} \\int_{E} \\left( Trace \\left(\\mathcal{H}_{Full,k,k+1}G_{k+1,k}^n - G_{k,k+1}^n\\mathcal{H}_{Full,k+1,k} \\right)\\right) dE \\right)\n\\end{equation}\\begin{center}\n\\textbf{\\underline{Spin current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_js}\\begin{aligned}\n\\vv{J}_{S} &= J_{k,k+1}^{Spin} \\\\\n&= Real \\left(\\frac{1}{i2e\\mu_{0}M_{S}V_{magnet}} \\int_{E} \\left( Trace \\left\\lbrace \\widehat{\\sigma} \\cdot \\left(\\mathcal{H}_{Full,k,k+1}G_{k+1,k}^n - G_{k,k+1}^n\\mathcal{H}_{Full,k+1,k} \\right)\\right\\rbrace\\right) dE \\right)\n\\end{aligned}\\end{equation} where $G^n$ is the electron correlation function calculated as given by Eq.~(\\ref{eq:eCorrFunc}), $e$ is the elementary charge, $\\mu_{0}$ is the permeability of vacuum, $M_{S}$ and $V_{magnet}$ is the saturation magnetization and volume of the magnetic layer the torque is acting on in the MTJ. The charge and spin currents calculated using the NEGF approach are used to determine the spin-transfer torque exerted on the free ferromagnetic layer of the MTJ.\n\n\\section{Extending the 1-D model to higher dimension systems}\\label{sec:extendDim}\n\nThe model presented thus far only models the electron transport in the MTJ considered as a 1-D wire. In real devices, the lateral dimensions may be substantially larger and hence, the 1-D model may not apply. However, the methodology above can still be used for systems with higher order dimensions. The Hamiltonian is written differently for 2-D and for 3-D systems. Let us consider the a 2-D MTJ first. The same approach presented earlier may be used to write $\\mathcal{H}$, except that $\\alpha_{HL1}$, $\\alpha_{HL2}$, $\\alpha_{IL}$, $\\alpha_{IR}$ , $\\alpha_{OX}$, $\\beta_{HL1}$, $\\beta_{HL2}$, $\\beta_{IL}$, $\\beta_{IR}$, and $\\beta_{OX}$ needs to be rewritten. Assume that $N_{t}$ grid points lie in the \\emph{transverse} direction (the direction perpendicular to the longitudinal direction). First, note that every line of grid points in the transverse direction lie in only one of the five defined regions. Using the left FM contact as an example, we rewrite \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\left[ \\begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}\n2\\alpha_{FM,L} & \\beta_{FM,L} & 0 & \\cdots & 0 \\\\\n\\beta^{\\dagger}_{FM,L} & \\ddots & \\ddots & \\ddots & \\vdots \\\\\n0 & \\ddots & \\ddots & \\ddots & 0 \\\\\n\\vdots &\\ddots & \\ddots & \\ddots & \\beta_{FM,L} \\\\\n0 & \\cdots & 0 & \\beta^{\\dagger}_{FM,L} & 2\\alpha_{FM,L}\n\\end{IEEEeqnarraybox}\\right] \\label{eq:modAlph2d} \\\\\n\\beta_{HL1}&=&-t_{FM,Left}I \\label{eq:modBeta2d}\n\\end{IEEEeqnarray}where $I$ is the $2N_{t}\\times2N_{t}$ identity matrix. To account for the conduction splitting, $U_{split,L}$ is added to every $2\\times{}2$ entry on the main diagonal of $\\alpha_{HL1}$. The same approach is used to modify $\\alpha_{HL2}$ and $\\beta_{HL2}$. $\\alpha_{OX}$ and $\\beta_{OX}$ are modified using the same approach given in Eqs.~(\\ref{eq:modAlph2d}) and (\\ref{eq:modBeta2d}), except that $U_{b}I$ is added to every $2\\times{}2$ entry on the main diagonal of $\\alpha_{OX}$. Then, \\begin{IEEEeqnarray}{rCl}\n\\alpha_{IL}&=&0.5\\times\\left(\\alpha_{HL1}+\\alpha_{OX}\\right) \\\\\n\\alpha_{IR}&=&0.5\\times\\left(\\alpha_{HL2}+\\alpha_{OX}\\right)\n\\end{IEEEeqnarray}The rewritten $\\alpha_{HL1}$, $\\alpha_{HL2}$, $\\alpha_{IL}$, $\\alpha_{IR}$ , $\\alpha_{OX}$, $\\beta_{HL1}$, $\\beta_{HL2}$, and $\\beta_{OX}$ are then used to write $\\mathcal{H}$ as given by Eq.~(\\ref{eq:genHam}).\n\nIn a 3-D system, transverse directions forms a 2-D plane of grid points. Hence, $\\alpha_{HL1}$, $\\alpha_{HL2}$, $\\alpha_{IL}$, $\\alpha_{IR}$ , $\\alpha_{OX}$, $\\beta_{HL1}$, $\\beta_{HL2}$, $\\beta_{IL}$, $\\beta_{IR}$, and $\\beta_{OX}$ each models a 2-D plane of grid points. Consider a 2-D plane in the $HL1$ region with $N_{t1}\\times{}N_{t2}$ number of grid points. We write along the direction with $N_{t1}$ points\\begin{IEEEeqnarray}{rCl}\n\\alpha_{1D,HL1}&=&\\left[ \\begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}\n3\\alpha_{FM,L} & \\beta_{FM,L} & 0 & \\cdots & 0 \\\\\n\\beta^{\\dagger}_{FM,L} & \\ddots & \\ddots & \\ddots & \\vdots \\\\\n0 & \\ddots & \\ddots & \\ddots & 0 \\\\\n\\vdots &\\ddots & \\ddots & \\ddots & \\beta_{FM,L} \\\\\n0 & \\cdots & 0 & \\beta^{\\dagger}_{FM,L} & 3\\alpha_{FM,L}\n\\end{IEEEeqnarraybox}\\right] \\label{eq:modAlph2d_alt} \\\\\n\\beta_{1D,HL1}&=&-t_{FM,Left}I \\label{eq:modBeta2d_alt}\n\\end{IEEEeqnarray}where $I$ in Eq.~(\\ref{eq:modBeta2d_alt}) is the $2N_{t1}\\times2N_{t1}$ identity matrix and $\\alpha_{1D,HL1}$ is a $2N_{t1}\\times2N_{t1}$ matrix. We can then write \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\left[ \\begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}\n\\alpha_{1D,HL1} & \\beta_{1D,HL1} & 0 & \\cdots & 0 \\\\\n\\beta^{\\dagger}_{1D,HL1} & \\ddots & \\ddots & \\ddots & \\vdots \\\\\n0 & \\ddots & \\ddots & \\ddots & 0 \\\\\n\\vdots &\\ddots & \\ddots & \\ddots & \\beta_{1D,HL1} \\\\\n0 & \\cdots & 0 & \\beta^{\\dagger}_{1D,HL1} & \\alpha_{1D,HL1}\n\\end{IEEEeqnarraybox}\\right] \\label{eq:modAlph3d} \\\\\n\\beta_{HL1}&=&-t_{FM,Left}I\\label{eq:modBeta3d}\n\\end{IEEEeqnarray}where $I$ in Eq.~(\\ref{eq:modBeta3d}) is the $(2N_{t1}N_{t2})\\times(2N_{t1}N_{t2})$ identity matrix and $\\alpha_{HL1}$ is a $(2N_{t1}N_{t2})\\times(2N_{t1}N_{t2})$ matrix. To account for the conduction band splitting between up-spin and down-spin electrons, $U_{split,L}$ is added to every $2\\times2$ entry along the main diagonal of $\\alpha_{HL1}$. The same approach is used to rewrite $\\alpha_{HL2}$ and $\\beta_{HL2}$. $\\alpha_{OX}$ is rewritten as prescribed by Eqs.~(\\ref{eq:modAlph2d_alt}) and (\\ref{eq:modAlph3d}), while $\\beta_{OX}$ is rewritten as prescribed by Eqs.~(\\ref{eq:modBeta2d_alt}) and (\\ref{eq:modBeta3d}). However, $U_{b}I$, where $I$ here is the $2\\times2$ identity matrix, is added to every $2\\times2$ entry along the main diagonal of $\\alpha_{OX}$. Also, just like in the 2-D system, the interfaces are modeled as \\begin{IEEEeqnarray}{rCl}\n\\alpha_{IL}&=&0.5\\times\\left(\\alpha_{HL1}+\\alpha_{OX}\\right) \\\\\n\\alpha_{IR}&=&0.5\\times\\left(\\alpha_{HL2}+\\alpha_{OX}\\right)\n\\end{IEEEeqnarray}The rewritten $\\alpha_{HL1}$, $\\alpha_{HL2}$, $\\alpha_{IL}$, $\\alpha_{IR}$ , $\\alpha_{OX}$, $\\beta_{HL1}$, $\\beta_{HL2}$, and $\\beta_{OX}$ are then used to write $\\mathcal{H}$ as given by Eq.~(\\ref{eq:genHam}).\n\n\\section{The mode space approach}\n\nNote the size of $\\mathcal{H}$ grows quadratically with the total number of grid points. As the number of dimensions of the system increases, the size of $\\mathcal{H}$ quickly increases as well. Clearly, there may not be enough computer memory to accommodate the numerical program for solving large 3-D systems. Fortunately, the problem for 2-D and 3-D systems may be reduced to multiple 1-D problems using the mode space approach, which drastically reduces the memory requirement for the numerical program. The main reason that allows us to reduce the number of dimensions is that the solutions to the Schr\\\"odinger equation for the MTJ system may be written as \\begin{equation}\n\\psi_{i}=\\psi_{0}\\cdot{}exp(i\\vv{r}\\cdot\\vv{k}_{\\perp})\\cdot{}exp(i\\vv{r}\\cdot\\vv{k}_{\\parallel})\n\\end{equation}where $i=\\sqrt{-1}$, $\\vv{k}_{\\perp}$ is the longitudinal wave vector, and $\\vv{k}_{\\parallel}$ is the transverse wave vector. In other words, $\\alpha_{HL1}$, $\\alpha_{HL2}$, $\\alpha_{OX}$, $\\alpha_{IL}$ and $\\alpha_{IR}$ may be diagonalized and our system of equations going into Eq.~(\\ref{eq:genHam}) may be rewritten such that \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&2t_{FM,Left}I + E_{t} \\\\\n\\alpha_{HL2}&=&2t_{FM,Right}I + \\frac{E_{t}t_{FM,Left}}{t_{FM,Right}} \\\\\n\\alpha_{OX}&=&2t_{OX}I + \\frac{E_{t}t_{FM,Left}}{t_{OX}} \\\\\n\\alpha_{IL}&=&(t_{FM,Left}+t_{OX})I + \\frac{2E_{t}t_{FM,Left}}{(t_{FM,Left}+t_{OX})} \\\\\n\\alpha_{IR}&=&(t_{FM,Right}+t_{OX})I + \\frac{2E_{t}t_{FM,Left}}{(t_{FM,Right}+t_{OX})} \\\\\n\\beta_{HL1}&=&-t_{FM,Left}I \\\\\n\\beta_{HL2}&=&-t_{FM,Right}I \\\\\n\\beta_{OX}&=&-t_{OX}I \\\\\nE_{t}(j,j)&=&\\frac{\\hbar^{2}\\left|\\vv{k}_{\\parallel}(j,j)\\right|^{2}}{2m^{*}_{FM,L}}\n\\end{IEEEeqnarray}The non-zero entries of $E_{t}$ are on its main diagonal, and $I$ is the identity matrix. The size of $I$ is such that the number of entries along each row and column corresponds to twice the number of grid points in the transverse directions of the system. The same system of equations may be solved by considering each $E_{t}$ separately. For each $E_{t}$, $\\mathcal{H}$ is written as in the 1-D case but with \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\alpha_{FM,L} = 2t_{FM,Left}I + E_{t} \\\\\n\\alpha_{HL2}&=&\\alpha_{FM,R} = 2t_{FM,Right}I + \\frac{E_{t}t_{FM,Left}}{t_{FM,Right}}\\\\\n\\alpha_{OX}&=&\\alpha_{Ch} = 2t_{OX}I + \\frac{E_{t}t_{FM,Left}}{t_{OX}} \\\\\n\\alpha_{IL}&=&\\frac{\\alpha_{OX}+\\alpha_{FM,L}}{2} \\\\\n\\alpha_{IR}&=&\\frac{\\alpha_{OX}+\\alpha_{FM,R}}{2} \\\\\n\\beta_{HL1}&=&\\beta_{FM,L} = -t_{FM,Left}I \\\\\n\\beta_{HL2}&=&\\beta_{FM,R} = -t_{FM,Right}I \\\\\n\\beta_{OX}&=&-t_{OX}I\n\\end{IEEEeqnarray} where $I$ is the $2\\times{}2$ identity matrix.\n\nThe transverse mode energies, $E_{t}$, depends on the dimensionality of the system, the number of transverse grid points, and the type of boundary conditions. In Section~\\ref{sec:extendDim}, we have written $\\mathcal{H}$ using box boundary conditions. Let us consider the 2-D case first. It turns out that we may write the mode energies as \\begin{IEEEeqnarray}{rCl}\nE_{t}&=&2t_{FM,Left}\\times\\left(1-cos\\left(k_{\\parallel}a\\right)\\right)\n\\end{IEEEeqnarray}When the box boundary condition is used, the plane wave solution to the Schr\\\"odinger equation must be periodic in the transverse direction. Furthermore, it must go to zero at both ends along the transverse direction due to box boundary conditions. Hence, we can write the plane wave solution as \\begin{IEEEeqnarray}{rCl}\n\\Psi_{\\nu}&=&\\Psi_{0}exp\\left(ik_{\\perp}l_{\\perp}\\right)sin(k_{\\parallel}l_{\\parallel}) \\\\\nk_{\\parallel}(N_{t}+1)a &=& \\nu\\pi \\text{~when~}l_{\\parallel}=(N_{t}+1)a\n\\end{IEEEeqnarray}where $\\nu$ is an integer in [1, $N_{t}$] and $N_{t}$ is the number of grid points in the transverse direction. Then,\\begin{IEEEeqnarray}{rCl}\nE_{t}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{\\nu\\pi}{N_{t}+1}\\right)\\right)\n\\end{IEEEeqnarray} On the other hand, periodic boundary conditions (\\emph{pbc}) may also be used to model devices where the characteristic does not depend on the boundary condition. When using \\emph{pbc}, $\\alpha_{HL1}$ is written as \\begin{IEEEeqnarray}{rCl}\n\\alpha_{HL1}&=&\\left[\\begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/c/}\n2\\alpha_{FM,L} & \\beta_{FM,L} & 0 & \\cdots & 0 & \\beta^{\\dagger}_{FM,L} \\\\ \n\\beta^{\\dagger}_{FM,L} & \\ddots & \\ddots & \\ddots & \\ddots & 0 \\\\ \n0 & \\ddots & \\ddots & \\ddots & \\ddots & \\vdots \\\\ \n\\vdots & \\ddots & \\ddots & \\ddots & \\ddots & 0 \\\\ \n0 & \\ddots & \\ddots & \\ddots & \\ddots & \\beta_{FM,L} \\\\ \n\\beta_{FM,L} & 0 & \\cdots & 0 & \\beta^{\\dagger}_{FM,L} & 2\\alpha_{FM,L} \n\\end{IEEEeqnarraybox}\\right]\n\\end{IEEEeqnarray}and similarly for $\\alpha_{HL2}$, $\\alpha_{IL}$, $\\alpha_{IR}$ , and $\\alpha_{OX}$. The plane wave solution to the Schr\\\"odinger equation is only required to be periodic in the transverse direction. Hence, \\begin{IEEEeqnarray}{rCl}\n\\Psi_{\\nu}&=&\\Psi_{0}exp\\left(ik_{\\perp}l_{\\perp}\\right)exp(ik_{\\parallel}l_{\\parallel}) \\\\\nk_{\\parallel}(N_{t})a &=& 2\\nu\\pi \\text{~when~} l_{\\parallel}=N_{t}a\n\\end{IEEEeqnarray}where $\\nu$ is an integer in [1, $N_{t}$] and $N_{t}$ is the number of grid points in the transverse direction. Then,\\begin{IEEEeqnarray}{rCl}\nE_{t}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{2\\nu\\pi}{N_{t}}\\right)\\right)\n\\end{IEEEeqnarray}\n\nThe transverse mode energies for 3-D systems may be constructed from the same approach we just described. Let us consider the longitudinal direction to be in the $+\\widehat{z}$ direction, and the transverse directions to be $+\\widehat{x}$ and $+\\widehat{y}$. Furthermore, assume there are $N_{t1}$ and $N_{t2}$ grid points in the $x$ and $y$ directions, respectively. We invoke the fact that plane wave solutions to the Schr\\\"odinger equation have the form \\begin{equation}\n\\Psi_{\\nu} = \\Psi_{0}e^{i\\left(k_{x}r_{x} + k_{y}r_{y} + k_{z}r_{z}\\right)}\n\\end{equation}Since $k_{x}$ and $k_{y}$ are decoupled, the combined transverse mode energy is a linear combination of every permutation of the transverse mode energy in the $x$ and $y$ direction ($E_{t,x}$ and $E_{t,y}$, respectively). Hence, every $E_{t,x}$ and $E_{t,y}$ are first obtained by choosing integers $\\nu_{x}$ and $\\nu_{y}$ in the range [1, $N_{t1}$] and [1, $N_{t2}$], respectively. If both directions have box boundary conditions, then we can write \\begin{IEEEeqnarray}{rCl}\nE_{t,x}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{\\nu_{1}\\pi}{N_{t1}+1}\\right)\\right) \\\\\nE_{t,y}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{\\nu_{2}\\pi}{N_{t2}+1}\\right)\\right)\n\\end{IEEEeqnarray}and calculate $E_{t}=E_{t,x}+E_{t,y}$ using every permutation of $E_{t,x}$ and $E_{t,y}$. If both directions have \\emph{pbc}, then use \\begin{IEEEeqnarray}{rCl}\nE_{t,x}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{2\\nu_{1}\\pi}{N_{t1}}\\right)\\right) \\\\\nE_{t,y}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{2\\nu_{2}\\pi}{N_{t2}}\\right)\\right)\n\\end{IEEEeqnarray}instead. If the box boundary condition is applied along the $x$ direction but \\emph{pbc} along the $y$ direction, then use \\begin{IEEEeqnarray}{rCl}\nE_{t,x}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{\\nu_{1}\\pi}{N_{t1}+1}\\right)\\right) \\\\\nE_{t,y}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{2\\nu_{2}\\pi}{N_{t2}}\\right)\\right)\n\\end{IEEEeqnarray}instead. If the box boundary condition is applied along the $y$ direction but \\emph{pbc} along the $x$ direction, then use \\begin{IEEEeqnarray}{rCl}\nE_{t,x}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{2\\nu_{1}\\pi}{N_{t1}}\\right)\\right) \\\\\nE_{t,y}&=&2t_{FM,Left}\\times\\left(1-cos\\left(\\frac{\\nu_{2}\\pi}{N_{t2}+1}\\right)\\right)\n\\end{IEEEeqnarray} The charge and spin currents flowing through the MTJ are calculated for each mode and all contributions are summed together to obtain the actual charge and spin current flowing through the MTJ, giving \n\\begin{center}\n\\textbf{\\underline{Charge current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_jcurr_modeDis}\nJ_{k,k+1} = \\sum_{E_{t}} Real \\left(\\frac{1}{i\\hbar} \\int_{E_{z}} \\left( Trace \\left(\\Upsilon \\right)\\right) \\partial{}E_{z} \\right)\n\\end{equation}\\begin{center}\n\\textbf{\\underline{Spin current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_js_modeDis}\n\\vv{J}_{S} = \\sum_{E_{t}} Real \\left(\\frac{1}{i2e\\mu_{0}M_{S}V_{magnet}} \\int_{E_{z}} \\left( Trace \\left\\lbrace \\widehat{\\sigma} \\cdot \\Upsilon\\right\\rbrace\\right) \\partial{}E_{z} \\right)\n\\end{equation}where $\\Upsilon$ is given by\\begin{equation}\n\\Upsilon=\\mathcal{H}_{Full,k,k+1}(E_{t})G_{k+1,k}^n(E_{t}) - G_{k,k+1}^n(E_{t})\\mathcal{H}_{Full,k+1,k}(E_{t})\n\\end{equation}and $\\mathcal{H}_{Full}$ and $G^{n}$ are now functions of $E_{t}$.\n\n\\section{Approximating mode space calculations in NEGF}\\label{sec:negf_Soln}\n\nIn MTJs, the Fermi level in the FM contacts are deep inside the conduction band and as a result, the grid spacing may need to be very small in order for the numerical solutions to converge (even in the 1-D case). Even for MTJs with $10~\\text{nm}\\times10~\\text{nm}$ cross-sectional area, the number of transverse modes needed to be considered to calculate its $I-V$ characteristic can be in the tens of thousands. Since the NEGF calculations for each transverse mode energy is independent of the others, the numerical simulation can be easily parallelized and executed on a large computer cluster to obtain the results quickly. However, because the data needs to be communicated to every computing node in the cluster, the simulation might be slowed down if the network traffic is too heavy. To overcome this issue, we first note that when the MTJ size is sufficiently large, the number of transverse modes in $k$-space is very dense. Hence, it may be possible to turn the discrete summation in Eqs.~(\\ref{eq:negf_jcurr_modeDis}) and (\\ref{eq:negf_js_modeDis}) into a continuous integral. This approach was proposed in \\cite{Duke1969} and was used by Tsu-Esaki to model resonant tunneling diodes \\cite{Tsu1973a}.\n\nWhen we change the summation over modes in 3-D to a continuous integration, it can be converted as \\begin{equation}\n\\sum_{E_{t,x}}\\sum_{E_{t,y}}\\sum_{E_{t,z}} \\rightarrow \\int\\int\\int\\partial{}k_{x}\\partial{}k_{y}\\partial{}k_{z}\n\\end{equation}However, the triple integral can be converted into a single integral if we integrate over the actual energy of the transverse mode instead. \\begin{equation}\n\\int\\int\\int\\partial{}k_{x}\\partial{}k_{y}\\partial{}k_{z} \\rightarrow \\int\\partial{}k_{\\parallel} \\rightarrow DOS(E_{t}) \\int\\partial{}E_{t}\n\\end{equation}where $DOS(E_{t})$ is the density of states. This can be done if we know the dispersion relation, which is assumed to be quadratic for most problems \\begin{equation}\nE_{t} = \\frac{\\hbar^{2}(\\vv{k}\\cdot\\vv{k})}{2m^{*}_{eff}}=\\frac{\\hbar^{2}(k^{2}_{x}+k^{2}_{y}+k^{2}_{z})}{2m^{*}_{eff}}=\\frac{\\hbar^{2}{}k^{2}_{\\parallel}}{2m^{*}_{eff}}\n\\end{equation}where $m^{*}_{eff}$ is the effective mass of the electron. Rearranging, \\begin{equation}\nk_{\\parallel}=\\frac{\\sqrt{2m^{*}_{eff}E_{t}}}{\\hbar} \\label{eq:kERel}\n\\end{equation}We also need to determine $DOS(E_{t})$. In a 3-D box which has \\emph{pbc} in all three Cartesian coordinate directions. The $k$-states are separated by \\begin{equation}\n\\Delta{}k_{x}=\\frac{\\pi}{L_{x}},~\\Delta{}k_{y}=\\frac{\\pi}{L_{y}},~\\Delta{}k_{z}=\\frac{\\pi}{L_{z}}\n\\end{equation}where $L_{x}$, $L_{y}$ and $L_{z}$ is the length of each side of the confining box. Furthermore, each $k_{x}$, $k_{y}$ and $k_{z}$ falls in the range [$-\\pi$, $\\pi$]. Hence, in $k$-space, each state occupies a volume given by \\begin{equation}\n\\text{Volume~occupied~by~a~state~in~k-space~for~a~3-D~box}=\\frac{2\\pi}{L_{x}}\\times\\frac{2\\pi}{L_{y}}\\times\\frac{2\\pi}{L_{z}}=\\frac{8\\pi^{3}}{\\Omega}\n\\end{equation}where $\\Omega=L_{x}L_{y}L_{z}$. To get the \\emph{density of states}, we need to determine how many states are uncovered when $E_{t}$ changes to $E_{t}+\\partial{}E_{t}$. This corresponds to a change in volume in $k$-space. When $E_{t}$ changes, the volume changes spherically. \\begin{table}[!t]\n\\caption{Summary of $DOS(E_{t})$ calculations}\n\\centering\n\\label{tab:DOS}\n\\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutmode][c]{v/c/v/c/v/c/v/c/v/c/v/c/v}\n\\IEEEeqnarrayrulerow \\\\\n& \\raisebox{-7pt}[0pt][0pt]{Dimensions} && \\raisebox{-7pt}[0pt][0pt]{$\\Omega$} && \\text{Volume~of} && \\text{Volume~of~sphere} && \\text{Number~of~states} && \\raisebox{-7pt}[0pt][0pt]{$DOS(E_{t})$}  \\\\\n& && && \\text{one~state} && \\text{in~}k\\text{-space} && \\text{in~sphere} && \\\\\n\\IEEEeqnarrayrulerow \\\\\n& \\raisebox{-2pt}[0pt][0pt]{3-D} && \\raisebox{-2pt}[0pt][0pt]{$L_{x}L_{y}L_{z}$} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{24pt}{11pt}][c]{c}\\frac{8\\pi^{3}}{\\Omega}\\end{IEEEeqnarraybox} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{24pt}{11pt}][c]{c}\\frac{4\\pi{}k_{\\parallel}^{3}}{3}\\end{IEEEeqnarraybox} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{27pt}{10pt}][c]{c}\\frac{\\Omega{}\\left(2m^{*}_{eff}E_{t}\\right)^{\\frac{3}{2}}}{6\\pi^{2}\\hbar^{3}}\\end{IEEEeqnarraybox} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{20pt}{10pt}][c]{c}\\frac{\\Omega2\\pi(2m^{*}_{eff})^\\frac{3}{2}}{h^{3}}\\sqrt{E_{t}}\\end{IEEEeqnarraybox} \\\\\n\\IEEEeqnarrayrulerow \\\\\n& \\raisebox{-2pt}[0pt][0pt]{2-D} && \\raisebox{-2pt}[0pt][0pt]{$L_{x}L_{y}$} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\\frac{4\\pi^{2}}{\\Omega}\\end{IEEEeqnarraybox} && \\pi{}k_{\\parallel}^{2} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\\frac{\\Omega2\\pi{}m^{*}_{eff}E_{t}}{h^{2}}\\end{IEEEeqnarraybox} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\\frac{\\Omega2\\pi{}m^{*}_{eff}}{h^{2}}\\end{IEEEeqnarraybox} \\\\\n\\IEEEeqnarrayrulerow \\\\\n& \\raisebox{-1.5pt}[0pt][0pt]{1-D} && \\raisebox{-1.5pt}[0pt][0pt]{$L_{x}$} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\\frac{2\\pi}{\\Omega}\\end{IEEEeqnarraybox} && 2k_{\\parallel} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{21pt}{8.5pt}][c]{c}\\frac{\\Omega2\\sqrt{2m^{*}_{eff}E_{t}}}{h}\\end{IEEEeqnarraybox} && \\begin{IEEEeqnarraybox}[\\IEEEeqnarraystrutsize{21pt}{13pt}][c]{c}\\frac{\\Omega}{h}\\sqrt{\\frac{2m^{*}_{eff}}{E_{t}}}\\end{IEEEeqnarraybox} \\\\\n\\IEEEeqnarrayrulerow\n\\end{IEEEeqnarraybox}\n\\end{table}The volume of a sphere is \\begin{equation}\nVolume = \\frac{4\\pi{}k_{\\parallel}^{3}}{3}\n\\end{equation}and the total number of states in that volume is \\begin{equation}\n\\text{Number of states~in~volume}=\\frac{4\\pi{}k_{\\parallel}^{3}}{3}\\times\\frac{\\Omega}{8\\pi^{3}}=\\frac{\\Omega{}k_{\\parallel}^{3}}{6\\pi^{2}} \\label{eq:3dspv}\n\\end{equation}Substituting Eq.~(\\ref{eq:kERel}) into (\\ref{eq:3dspv}), we get \\begin{equation}\n\\text{Number of states~in~volume}=\\frac{\\Omega(2m^{*}_{eff}E_{t})^{\\frac{3}{2}}}{6\\pi^{2}\\hbar^{3}}\n\\end{equation}Then, we can calculate the density of states given as \\begin{equation}\nDOS(E_{t}) = \\frac{\\partial}{\\partial{}E_{t}} \\left(\\text{Number of states~in~volume}\\right)=\\frac{\\Omega2\\pi(2m^{*}_{eff})^\\frac{3}{2}}{h^{3}}\\sqrt{E_{t}}\n\\end{equation}The same process can be repeated to calculate $DOS(E_{t})$ for 2-D and 1-D confinements, and the results are summarized in Table~\\ref{tab:DOS}. Note that the number of states in sphere listed in Table~\\ref{tab:DOS} is missing a factor of 2 compared to the texts found in the literature. In the literature, the factor of 2 is used to account for degeneracy in energy levels. In the NEGF approach used in this work, the degeneracy is handled by writing $\\mathcal{H}$ to include up-spin and down-spin. Hence, the number of states in sphere is as listed in Table~\\ref{tab:DOS}. It is important to note the parabolic dispersion relationship assumption used to obtain these results.\n\nOnce we obtain $DOS(E_{t})$, we may then calculate the charge and spin currents as \\begin{equation}\n\\Upsilon=\\mathcal{H}_{Full,k,k+1}(E_{t})G_{k+1,k}^n(E_{t}) - G_{k,k+1}^n(E_{t})\\mathcal{H}_{Full,k+1,k}(E_{t})\n\\end{equation}\n\\begin{center}\n\\textbf{\\underline{Charge current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_jcurr_modeCont}\nJ_{k,k+1} = Real \\left(\\frac{1}{i\\hbar} \\int_{E_{t}}\\int_{E_{z}} DOS(E_{t})\\cdot\\left( Trace \\left( \\Upsilon \\right)\\right) \\partial E_{z} \\partial E_{t} \\right)\n\\end{equation}\\begin{center}\n\\textbf{\\underline{Spin current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_js_modeCont}\n\\vv{J}_{S} = Real \\left(\\frac{1}{i2e\\mu_{0}M_{S}V_{magnet}} \\int_{E_{t}}\\int_{E_{z}} DOS(E_{t})\\cdot\\left( Trace \\left\\lbrace \\widehat{\\sigma} \\cdot \\Upsilon\\right\\rbrace\\right) \\partial E_{z} \\partial E_{t} \\right)\n\\end{equation}\n\nNote that we can use the same procedure to determine $DOS(E_{t})$ if box boundary conditions are used. When box boundary conditions are used, the number of $k$-states long each $k$ direction is same as when \\emph{pbc} is used. However, the each state is found in [0, $\\pi$] instead of [$-\\pi$, $\\pi$]. It seems as if the volume occupied by each state in $k$-space is smaller. However, the difference in the range over which the states are found needs to be accounted for. In the 3-D case, all $k$-states are in the first octant. In the 2-D case, all $k$-states are in the first quadrant. In the 1-D case, all $k$-states are in the left half. As a result, we get the same number of states in $k$-space sphere regardless of boundary conditions. Hence, $DOS(E_{t})$ is independent of boundary conditions when the grid spacing is sufficiently small. When we simulate an MTJ, we can assume that the electron tunneling probability is independent of the transverse mode energy. Furthermore, we have $L_{x}, L_{y} \\geq 10$~nm and the grid spacing needed for numerical results to converge is usually $a\\leq0.1$ \\AA. Hence, we can approximate the sum over modes as an integral and calculate the charge and spin currents using \\begin{center}\n\\textbf{\\underline{Charge current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_jcurr_mode3D}\nJ_{k,k+1} = Real \\left(\\frac{m^{*}_{eff}A_{MTJ}}{i2\\pi\\hbar^{3}} \\int_{E_{t}}\\int_{E_{z}} \\left( Trace \\left( \\Upsilon \\right)\\right) \\partial E_{z} \\partial E_{t} \\right)\n\\end{equation}\\begin{center}\n\\textbf{\\underline{Spin current density}}\n\\end{center}\n\\begin{equation}\\label{eq:negf_js_mode3D}\n\\vv{J}_{S} = Real \\left(\\frac{m^{*}_{eff}A_{MTJ}}{i\\hbar^{2}4\\pi e\\mu_{0}M_{S}V_{magnet}} \\int_{E_{t}}\\int_{E_{z}} \\left( Trace \\left\\lbrace \\widehat{\\sigma} \\cdot \\Upsilon\\right\\rbrace\\right) \\partial E_{z} \\partial E_{t} \\right)\n\\end{equation}where $A_{MTJ}$ is the cross-sectional area of the MTJ.\n\n\\section{Using spin current in simulation of magnetization dynamics}\n\nIn the free layer of an MTJ, the Landau-Lifshitz-Gilbert (LLG) equation used to model its behavior. The LLG equation is given as \\begin{equation}\n\\frac{\\partial\\widehat{m}}{\\partial t} = -|\\gamma| \\widehat{m}\\times\\vv{H}_{eff} + \\alpha\\left(\\widehat{m}\\times\\frac{\\partial\\widehat{m}}{\\partial t}\\right) + \\vv{STT}\n\\end{equation}where $\\vv{H}_{eff}$ is the effective magnetic field (including all anisotropy fields, externally applied magnetic fields and magnetostatic field) acting on the free layer, which has a magnetization direction given by $\\widehat{m}$. $\\gamma$ is the gyromagnetic ratio (usually $2.211\\times10^{5}$ m$\\cdot$A$^{-1}\\cdot$s$^{-1}$) and $\\alpha$ is the unitless Gilbert's damping factor. As proposed by Slonczewski \\cite{Slonczewski1996c}, the spin-transfer torque is given by \\begin{equation}\n\\vv{STT}=\\widehat{m}\\times\\vv{J}_{S}\\times\\widehat{m}\n\\end{equation}where $\\vv{J}_{S}$ was given in Eqs.~(\\ref{eq:negf_js}), (\\ref{eq:negf_js_modeDis}), (\\ref{eq:negf_js_modeCont}) and (\\ref{eq:negf_js_mode3D}).\n\n", "meta": {"hexsha": "b8ab4a9ab026872474c5cfbb41f0eec0035cf3f6", "size": 37706, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "NEGF.tex", "max_stars_repo_name": "seeder-research/ResearchNotes_NEGF", "max_stars_repo_head_hexsha": "467aa4843da3e68c8b240e8c5a2b9f56f94c7cb1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "NEGF.tex", "max_issues_repo_name": "seeder-research/ResearchNotes_NEGF", "max_issues_repo_head_hexsha": "467aa4843da3e68c8b240e8c5a2b9f56f94c7cb1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NEGF.tex", "max_forks_repo_name": "seeder-research/ResearchNotes_NEGF", "max_forks_repo_head_hexsha": "467aa4843da3e68c8b240e8c5a2b9f56f94c7cb1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-14T02:56:01.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-14T02:56:01.000Z", "avg_line_length": 114.9573170732, "max_line_length": 1230, "alphanum_fraction": 0.698536042, "num_tokens": 13253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.417623796192907}}
{"text": "\\documentclass[class=report, float=false, crop=false]{standalone}\n\\usepackage[subpreambles=true]{standalone}\n\n\\input{preamble}\n\n\\graphicspath{{figures/images/}}\n\n% \\begin{cbunit}\n\n\\begin{document}\n\n\\chapter{Elastic force between ellipsoids}\n\\label{appendix:force}\n\n\\section{Reduced belonging matrix}\n\nAn ellipsoid $\\mathcal{A}$ of centre $\\vec{v}$ and semi-axes $(R_i)_{i=1:3}$ can be described by the matrix\n\\begin{equation}\n\\bar{B}(O,(R_i)_{i=1:3}) \\equiv O \\text{diag}(R_i^{-2})_{i=1:3} O^T\n\\end{equation}\nwhere $O$ is the symmetric rotation matrix corresponding to the change of basis from the ellipsoid frame to the reference frame, such as\n\\begin{equation}\n\\forall \\vec{r} \\in \\mathbb{R}^3, \\begin{cases} (\\vec{r} - \\vec{v})^T \\bar{B} (\\vec{r} - \\vec{v}) < 1 &\\text{ if } \\vec{r} \\in \\mathcal{A} \\setminus \\bar{\\mathcal{A}} \\\\ (\\vec{r} - \\vec{v})^T \\bar{B} (\\vec{r} - \\vec{v}) = 1 &\\text{ if } \\vec{r} \\in \\bar{\\mathcal{A}} \\\\ (\\vec{r} - \\vec{v})^T \\bar{B} (\\vec{r} - \\vec{v}) > 1 &\\text{ if } \\vec{r} \\notin \\mathcal{A} \\end{cases}\n\\end{equation}\nand with which we can write\n\\begin{equation}\n\\mu^2(\\vec{r}\\in\\mathbb{R}^3) = (\\vec{r}-\\vec{v})^T\\bar{B}(O,(R_i)_{i=1:3})(\\vec{r}-\\vec{v})\n\\label{rescaling_factor_squared}\n\\end{equation}\nwhere $\\mu(\\vec{r})$ is the rescaling factor that has to be applied to the axes of $\\mathcal{A}$ for $\\vec{r}$ to be on its surface.\\\\\n\nFor simplicity, we will write $\\bar{B}_{\\mathcal{A}} \\equiv \\bar{B}(O,(R_i)_{i=1:3})$.\\\\\n\nWe have for all $\\vec{r}$ on the surface of $\\mathcal{A}$ that $\\mu^2(\\vec{r})=1$, therefore the surface of $\\mathcal{A}$ is an isosurface of $\\mu^2$. Therefore, we can conclude that the vector\n\\begin{equation}\n\\vec{\\nabla}\\mu^2(\\vec{r}) = 2\\bar{B}_{\\mathcal{A}}(\\vec{r}-\\vec{v})\n\\end{equation}\nis orthogonal to the surface of $\\mathcal{A}$ in $\\vec{r}$.\n\n\\section{Force}\n\nWe assumed that the force exerted on an ellipsoid $\\mathcal{A}$ by an ellipsoid $\\mathcal{B}$ of centre $\\vec{r}_{\\mathcal{A}}$ and $\\vec{r}_{\\mathcal{B}}$ respectively is\n\\begin{equation}\n\\vec{f}_{\\mathcal{A}\\mathcal{B}}^{\\text{el}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = k_e (1 - \\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}))\\frac{d\\mu}{d\\vec{r_{\\mathcal{A}}}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})\n\\end{equation}\naccording to equation \\ref{pre_force_el_ellipsoids}, where $\\mu(\\vec{r}_{\\mathcal{A}},\\vec{r}_{\\mathcal{B}})$ is the rescaling factor that has to be applied to both $\\mathcal{A}$ and $\\mathcal{B}$ for them to be externally tangent.\\\\\n\nContrarily to the case of spheres, we have for ellipsoids that the rescaling factor $\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})$ is not uniquely determined by the positions of their centres. Indeed, if we were to add $\\vec{dr_{\\mathcal{A}}}$ to the position $\\vec{r_{\\mathcal{A}}}$ of the centre of ellipsoid $\\mathcal{A}$, the contact point $\\vec{r_C}$ with ellipsoid $\\mathcal{B}$ would move as well.\\\\\n\nSince we are looking for the first derivative of the quantity $\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})$, we will approximate rescaled ellipsoids by their respective tangent planes at $\\vec{r_C}$ as suggested by \\cite{donev}.\\\\\n\n\\begin{figure}[h!]\n\\centering\n\\includestandalone{figures/tikz/derivative_rescaling_factor}\n\\caption{Ellipsoids rescaled with rescaling factor $\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})$ and their contact plane in plain thick trait. Ellipsoids rescaled with rescaling factor $\\mu(\\vec{r_{\\mathcal{A}}} + \\vec{dr_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})$ and their contact plane in dashed trait.}\n\\label{contact_points_fig}\n\\end{figure}\n\nIf ellipsoid $\\mathcal{A}$ is moved by $\\vec{dr_{\\mathcal{A}}}$, there appears a gap $dh$ between the tangent planes of the rescaled ellipsoids with\n\\begin{equation}\ndh = \\vec{dr_{\\mathcal{A}}}\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C})\n\\label{dh}\n\\end{equation}\nwhere $\\vec{n}_{\\mathcal{A}}(\\vec{r_C})$ is the outward-facing unitary surface vector of ellipsoid $\\mathcal{A}$ in $\\vec{r_C}$.\\\\\n\nTo close this gap, we have to rescale the -- yet rescaled -- ellipsoids with a factor $\\nu$ so that\n\\begin{align*}\n% &d\\nu~(\\vec{r_C} - \\vec{r_{\\mathcal{A}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C}) - d\\nu~(\\vec{r_C} - \\vec{r_{\\mathcal{B}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C}) = dh\\\\\n% \\Leftrightarrow~ &d\\nu~ (\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C}) = dh\\\\\n% \\Leftrightarrow~ &d\\nu = \\frac{dh}{(\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C})}\n\\left((\\vec{r_C} - \\vec{r_{\\mathcal{A}}}) - \\nu (\\vec{r_C} - \\vec{r_{\\mathcal{A}}})\\right)\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C}) - \\left((\\vec{r_C} - \\vec{r_{\\mathcal{B}}}) - \\nu (\\vec{r_C} - \\vec{r_{\\mathcal{B}}})\\right)\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C}) = dh \\Rightarrow 1 - \\nu = \\frac{dh}{(\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C})}\n\\end{align*}\nand\n\\begin{align*}\n\\mu(\\vec{r_{\\mathcal{A}}} + \\vec{dr_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = \\nu\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) \\Rightarrow \\vec{dr_{\\mathcal{A}}}\\cdot\\frac{d\\mu}{\\vec{dr_{\\mathcal{A}}}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = -\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})(1 - \\nu)\n\\end{align*}\nwhich, with equation \\ref{dh}, leads to\n\\begin{align*}\n\\frac{d\\mu}{d\\vec{r_{\\mathcal{A}}}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = -\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})\\frac{\\vec{n}_{\\mathcal{A}}(\\vec{r_C})}{(\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})\\cdot\\vec{n}_{\\mathcal{A}}(\\vec{r_C})}\n\\end{align*}\nWe can then conclude, with equation \\ref{surface_vec_reduced}, that\n\\begin{equation}\n\\frac{d\\mu}{d\\vec{r_{\\mathcal{A}}}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = -\\frac{\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})}{(\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})^T\\bar{B}_{\\mathcal{A}}(\\vec{r_C} - \\vec{r_{\\mathcal{A}}})}\\bar{B}_{\\mathcal{A}}(\\vec{r_C} - \\vec{r_{\\mathcal{A}}})\n\\end{equation}\nTherefore, with equation \\ref{pre_force_el_ellipsoids}, we finally have that\n\\begin{equation}\n\\boxed{\\vec{f}_{\\mathcal{A}\\mathcal{B}}^{\\text{el}}(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}}) = -k_e \\frac{\\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})\\left(1 - \\mu(\\vec{r_{\\mathcal{A}}},\\vec{r_{\\mathcal{B}}})\\right)}{(\\vec{r_{\\mathcal{B}}} - \\vec{r_{\\mathcal{A}}})^T\\bar{B}_{\\mathcal{A}}(\\vec{r_C} - \\vec{r_{\\mathcal{A}}})}\\bar{B}_{\\mathcal{A}}(\\vec{r_C} - \\vec{r_{\\mathcal{A}}})}\n\\label{fel_ellipsoids}\n\\end{equation}\n\n% \\input{references/biblio}\n\n\\end{document}\n\n% \\end{cbunit}", "meta": {"hexsha": "ecb715e1910427429bb1eca64c3d976872dfb790", "size": 6556, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/appendices/app_force.tex", "max_stars_repo_name": "yketa/Umea_2017_Notes", "max_stars_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/appendices/app_force.tex", "max_issues_repo_name": "yketa/Umea_2017_Notes", "max_issues_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/appendices/app_force.tex", "max_forks_repo_name": "yketa/Umea_2017_Notes", "max_forks_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.0105263158, "max_line_length": 410, "alphanum_fraction": 0.6503965833, "num_tokens": 2673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.417623796192907}}
{"text": "\\documentclass[aspectratio=1610]{beamer}\n\\usetheme[sectionpage=progressbar, progressbar=foot]{metropolis} \n\\usefonttheme{professionalfonts}   % required for mathspec\n\\usepackage{mathspec}\n\\usepackage{bm}\n\\usepackage{color}\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\\usepackage{float}\n\n% ALGORITHMIC\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}}\n\n% THEME COLORS REDEF.\n\\definecolor{Magenta}{HTML}{B50B1E}\n\\definecolor{deBlue}{HTML}{0E2646}\n\\setbeamercolor{alerted text}{fg=Magenta}\n\\setbeamercolor{frametitle}{bg=deBlue}\n\n% ENUM ITEM\n\\usepackage{fontawesome}\n\\usepackage{enumitem}\n\\setitemize{label=\\usebeamerfont*{itemize item}%\n\\usebeamercolor[fg]{itemize item}\n\\usebeamertemplate{itemize item}}\n%\\SetLabelAlign{center}{\\strut\\smash{\\parbox[t]\\labelwidth{\\centering#1}}}\n\\definecolor{ProGreen}{RGB}{56,146,94}\n\\definecolor{ConRed}{RGB}{209,28,22}\n\\newcommand*\\pro{%\n  \\item[\\color{ProGreen}\\scalebox{1.5}{\\faThumbsOUp}]}\n\\newcommand*\\con{%\n  \\item[\\color{ConRed}\\scalebox{1.5}{\\faThumbsODown}]}\n\n% FONT\n%\\setsansfont[BoldFont={Fira Sans},\n%Numbers={OldStyle}]{Fira Sans Light}\n%\\setmathsfont(Digits)[Numbers={Lining, Proportional}]{FiraSans Light}\n\n% BIBLIO \n\\usepackage[backend=bibtex,style=authoryear-icomp,maxbibnames=9,maxcitenames=2]{biblatex}\n\\renewcommand*{\\nameyeardelim}{\\addcomma\\addspace}\n\\bibliography{3DRegistration.bib}\n%\\setbeamertemplate{bibliography item}{\\insertbiblabel} %Removes icon in bibliography \n\\renewcommand*{\\cite}{\\parencite}\n\n\n% INTRO\n\\title{3D Rigid Registration}\n\\subtitle{Algorithms survey}\n% \\date{\\today}\n\\author{Pasquale Antonante}\n%\\institute{United Technology Research Center}\n%\\titlegraphic{\\hfill\\includegraphics[height=0.8cm]{imgs/logo_utrc.png}}\n\n%% UTILITIES\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\\newcommand{\\Ealign}{\\bm{q}_i-\\bm{T}\\bm{p}_i}\n\\DeclareMathOperator*{\\argmin}{argmin}\n\\DeclareMathOperator*{\\argmax}{argmax}\n\n\\begin{document}\n\\maketitle\n\n% ===== BEGIN =====\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Introduction                                      %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Introduction}\n%%\n\\begin{frame}[fragile]{Problem definition}\n  \\begin{alertblock}{Surface registration}\n  Surface registration \\textbf{transforms} multiple sets of 3D data points into the same coordinate system so as to \\textbf{align overlapping} components of these sets.\n\\end{alertblock}\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Basic notation}\nLet's consider two point sets $\\bm{P}$ and $\\bm{Q}$ we want to find a rigid transformation $\\bm{T}$ (rotation $\\bm{R}$ and translation $\\bm{t}$) that aligns $\\bm{Q}$ to $\\bm{P}$. \n\nIn general we want to minimize the error $E(\\bm{T})$ \n\\[ \n%E(\\bm{T})=\\sum_i{\\norm{q_i-\\bm{T}p_i}}+E_{\\text{reg}}, \\quad \\text{where}~\nE(\\bm{T})=E_{\\text{align}}+E_{\\text{reg}}, \\quad \\text{where}\n\\bm{T} = \\begin{bmatrix}\n   \\bm{R} & \\bm{t} \\\\\n   \\bm{0}^{T} & 1   \n\\end{bmatrix} \n\\]\n$E_{\\text{align}}$ measure the \\textbf{alignment error} while $E_{\\text{reg}}$ is a \\textbf{regularization} term. \n\n\\framebreak\n\nThere are two main metrics to measure the $E_{\\text{align}}$\n%\\begin{equation}\n\\begin{align}\nE_\\text{pt-to-pt} &= \\sum_i{\\norm{\\Ealign}^2} \\label{pt2pt} \\\\\nE_\\text{pt-to-plane} & = \\sum_i{\\big((\\Ealign)\\cdot\\bm{n}_{q_i}\\big)^2} \\label{pt2pl}\n\\end{align}\n%\\end{equation}\n\n\\framebreak\n\n\\begin{figure}[htbp]\n\\begin{center}\n\\begin{minipage}[b]{0.45\\linewidth}\n  \\centering\n  \\includegraphics[width=\\textwidth,keepaspectratio]{imgs/pt2pt.png}\n  \\caption{Point-to-Point Distance}\n  \\label{fig:pt2pt}\n\\end{minipage}\n\\begin{minipage}[b]{0.45\\linewidth}\n  \\centering\n  \\includegraphics[width=\\textwidth,keepaspectratio]{imgs/pt2plane.png}\n  \\caption{Point-to-Plane Distance}\n  \\label{fig:pt2pl}\n\\end{minipage}\n\\end{center}\n\\caption{Error metrics \\cite{bellekens2014survey}}\n\\end{figure}\n\n\\framebreak\n\nPoint-to-plane proved to be more stable and faster to converge but\\ldots\\textbf{Least Sum of Square Errors} has a closed-form solution!\n\nIf we know the \\textbf{perfect correspondence} of a subset of points (at least 3) we can compute the rigid transformation\n\\begin{itemize}\n  \\item Rotation matrix, e.g. \\cite{schonemann1966generalized}, \\cite{arun1987least}, \\cite{horn1988closed}, \\cite{umeyama1991least}\n  \\item Quaternions, e.g. \\cite{horn1987closed}\n\\end{itemize}\n\nBut \\textbf{true correspondences} are difficult do be found.\n\\end{frame}\n\n\\begin{frame}[allowframebreaks]{(Non)-Convexity Analysis}\nLet's focus on the \\textbf{point-to-point} formulation.\n\nDefine \n\\begin{itemize}\n\\item Transformation function as $T_x(\\alpha)$ that \\textbf{affinely transforms} a point $x$, according to some parameter $\\alpha=(\\bm{R},\\bm{t})$\n\\item The \\textbf{distance-to-a-set operator} $d(x)=\\inf_{y\\in\\mathcal{Y}}\\norm{x-y}$\n\\end{itemize}\n\nThe \\textbf{residual function} $E(\\alpha)=d(T_x(\\alpha))$ is \\emph{convex} if\n\\begin{itemize}\n  \\item \\emph{(Condition 1)}. Domain $D_{\\alpha}$ is a convex set\n  \\item \\emph{(Condition 2)}. The set $\\mathcal{Y}$ is convex\\footnote{Proof in~\\cite{olsson2009branch}}\n\\end{itemize}\n\n\\framebreak\n\nIn our case\n\\begin{itemize}\n  \\item \\emph{Condition 1} cannot be fulfilled for registration with rotation (due to the constraint $\\bm{R}\\bm{R}^T=\\bm{I}$)\n  \\item \\emph{Condition 2} is rarely fulfilled because set $\\mathcal{Y}$  is a scan of complex surfaces\n\\end{itemize}\nTherefore, $E(\\alpha)$ is \\textbf{non-convex}.\n\\end{frame}\n\n%\\begin{frame}{Closed-Form Solution}\n\n%\\end{frame}\n\n\\begin{frame}{Global vs Local}\n\\begin{alertblock}{Global vs. Local}\n3D Rigid Registration can be classified according to the used \\textbf{underlying optimization method}~\\cite{rusu2009fast}:\n\\begin{itemize}\n\\item \\textbf{Global}% (e.g. Genetic Algorithms)\n\\item \\textbf{Local} (e.g. Iterative Closest Point (ICP))\n\\end{itemize}\n\\end{alertblock}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Iterative Closest Points                          %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Iterative Closest Points (ICP)} %[Besl & McKay 92]\n\\begin{frame}[shrink=10]{Basic ICP}\n\\begin{algorithm}[H]\n\\begin{algorithmic}[1]\n%\\STATE Estimate initial registration states\n%\\STATE Apply initial registration\n%\\WHILE{Alignment MSE greater than threshold}\n%\\STATE Compute closest points\n%\\STATE Compute registration $T$\n%\\STATE Apply registration\n%\\ENDWHILE\n\\REQUIRE $\\bm{P}$, $\\bm{Q}$ and initial estimation $\\bm{T}_0$\n\\ENSURE $\\bm{T}$\n\\STATE $\\bm{T}\\gets\\bm{T}_0$\n\\WHILE{not converged}\n  \\FOR{$i\\gets 1$ \\TO $N$}\n    \\STATE $\\bm{m}_i\\gets\\text{FindClosestPointInQ}(\\bm{T}\\bm{p}_i$)\n    \\IF{$\\norm{\\bm{m}_i-\\bm{T}\\bm{p_i}}\\leq d_{\\text{max}}$}\n      \\STATE $\\omega_i\\gets 1$\n    \\ELSE\n      \\STATE $\\omega_i\\gets 0$\n    \\ENDIF\n  \\ENDFOR\n  \\STATE $\\bm{T}\\gets\\argmin\\limits_T \\sum\\limits_i \\omega_i \\norm{\\bm{m}_i-\\bm{T}\\bm{p}_i}$\n\\ENDWHILE\n\\end{algorithmic}\n\\caption{Iterative Closest Points (ICP)}\n\\label{alg:ICP}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}{Considerations}\n\\begin{itemize}[wide, labelsep=2em]\n  \\pro Solves the correspondence problem\n  \\con May get caught in local minima\n  \\con Require (and depends) an initial registration guess\n  \\con Computes closest points set each iteration\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Local Optimization Method}\n%ICP is a \\textbf{local optimization algorithm} and may get caught in local minima.\n\nThere is a lot of work around ICP addressing the local minima issue, some relevant methods are:\n\\begin{itemize}\n\t\\item \\textbf{Robustified Local Methods}\n\t\\item \\textbf{Global Methods} (GA, Particle filtering, Simulated Annealing)\n\t\\item \\textbf{Globally Optimal Methods} (i.e. BnB)\n\\end{itemize}\n\\end{frame}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Global Go-ICP                                     %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{GO-ICP (2016)}\n%%\n\\begin{frame}{Introduction}\nGlobal-ICP (GO-ICP)~\\cite{goicp} optimally solves 3D registration by mixing ICP and BnB.\n\\begin{figure}[htbp]\n\\begin{center}\n  \\includegraphics[width=\\textwidth,height=0.45\\textheight,keepaspectratio]{imgs/GOICP_collaboration.png}\n  \\caption{Collaboration of BnB and ICP.}\n  \\label{fig:goicp_collaboration}\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}[allowframebreaks]{Domain Parametrization}\nTo parametrize the search space let's consider the \\textbf{angle-axis} representation of rotations, obtaining\n\\begin{itemize}\n\t\\item the rotation space $SO(3)$ is parametrized in a solid radius-$\\pi$ ball \n\t\\item the translation is assumed to be within the cube $[-\\xi,\\xi]^3$ (denoted as $C_t$)\n\\end{itemize}\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[width=\\textwidth,height=0.3\\textheight,keepaspectratio]{imgs/GOICP_parametrization.png}\n\\caption{$SE(3)$ space parametrization in GO-ICP}\n\\label{default}\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Bounding Functions}\nFor ease of manipulation, let's use the minimum cube $[−\\pi,\\pi]^3$ that encloses the $\\pi$-ball centered in $\\bm{r}_0$ as $C_r$.\n\n\\begin{theorem}[Uncertainty radius]\nGiven a 3D point $\\bm{p}$, a rotation cube $C_r$ of half side-length $\\sigma_r$ with $r_0$ as the center and examining the maximum distance from $\\bm{R}_{\\bm{r}}\\bm{p}$ to $\\bm{R}_{\\bm{r_0}}\\bm{p}$, we have $\\forall\\bm{r}\\in C_r$,\n\\[ \\norm{\\bm{R}_r\\bm{p}-\\bm{R}_{r_0}\\bm{p}} \\leq 2\\sin(\\min(\\sqrt{3}\\sigma_r/2,\\pi/2))\\norm{\\bm{p}} = \\gamma_r \\]\nOr similarly, given a translation cube $C_t$ with half side-length $\\sigma_t$ centered at $\\bm{t_0}$, we have $\\forall\\bm{t}\\in C_t$\n\\[ \\norm{(\\bm{p}+\\bm{t}) - (\\bm{p}-\\bm{t}_0)} \\leq \\sqrt{3}\\sigma_t = \\gamma_t \\]\n\\end{theorem}\n\\end{frame}\n\n%%\n\\begin{frame}{BnB Bounds}\n%Instead of direct 6D space exploration, a \\textbf{nested BnB} search is proposed:\n%\\begin{itemize}\n%  \\item \\textbf{Outer BnB} searches the rotation space of $SO(3)$\n%  \\item \\textbf{Inner BnB} called by the outer BnB, solves the translation problem\n%\\end{itemize}\n\n%The upper $\\overline{E}$ bound and the lower bound $\\underline{E}$ for both BnB can be derived~\\cite{goicp}. \n\n%\\framebreak\nFor a given rotation cube $C_r$\n\\begin{equation}\n  \\begin{array}{ll} \n  \\overline{E}_r &= \\min\\limits_{\\forall\\bm{t}\\in\\mathcal{C}_t} \\sum\\limits_i e_i (\\bm{R}_{\\bm{r}_0}, \\bm{t})^2 \\\\\n  \\underline{E}_r &= \\min\\limits_{\\forall\\bm{t}\\in\\mathcal{C}_t} \\sum\\limits_i \\max \\big(e_i(\\bm{R}_{\\bm{r}_0},t)-\\gamma_{r_i},0\\big)^2\n  \\end{array}\n\\end{equation}\nSimilarly, for a given translation cube $C_t$\n\\begin{equation}\n\\begin{array}{ll}\n  \\overline{E}_t &= \\sum\\limits_i \\max\\big( e_i(\\bm{R}_{\\bm{r}_0},\\bm{t_0})-\\gamma_{r_i}, 0 \\big)^2 \\\\\n  \\underline{E}_t &= \\sum\\limits_i \\max \\big( e_i(\\bm{R}_{\\bm{r}_0},\\bm{t_0}) - (\\gamma_{r_i} + \\gamma_t),0 \\big)^2\n\\end{array}\n\\label{eq:goicp_outerbound}\n\\end{equation}\nwhere $e_i(\\bm{R},\\bm{t})=\\norm{\\bm{q}_{j^*}-\\bm{R}\\bm{p}_i}$, with $\\bm{q}_{j^*}$ denoted as optimal correspondence of $\\bm{p}_i$; $\\mathcal{C}_r$ and $\\mathcal{C}_t$ are the initial cubes.\n\\end{frame}\n\n%%\n\\begin{frame}[shrink=36]{Go-ICP algorithm}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n  \\begin{algorithm}[H] %% outer\n  \\begin{algorithmic}[1]\n  \\REQUIRE $\\bm{P}$, $\\bm{Q}$, threshold $\\epsilon$, initial cubes $\\mathcal{C}_r$, $\\mathcal{C}_t$\n  \\ENSURE Globally minimal error $E^*$ and corresponding $\\bm{r}^*$, $\\bm{t}^*$\n  \\STATE Put $\\mathcal{C}_r$ into priority queue $Q_r$\n  \\STATE Set $E^*=+\\infty$\n  \\LOOP\n    \\STATE Read out a cube with lowest $\\underline{E}_r$ from $Q_r$\n    \\STATE Quit if $E^*-\\underline{E}_r<\\epsilon$\n    \\STATE Divide the cube into 8 sub-cubes\n    \\FORALL{sub-cube $C_r$}\n      \\STATE Compute $\\overline{E}_r$ for $C_r$ and corresponding optimal $\\bm{t}$ by calling alg.\\ref{alg:goicp_inner} with $\\bm{r}_0$, $\\gamma_r=0$ and $E^*$\n      \\IF{$\\overline{E}_r<E^*$}\n        \\STATE Run ICP with initialization $(\\bm{r}_0,\\bm{t})$\n        \\STATE Update $E^*$, $r^*$ and $t^*$ with ICP results\n      \\ENDIF\n      \\STATE Compute $\\underline{E}_r$ for $C_r$ by calling alg.\\ref{alg:goicp_inner} with $\\bm{r}_0$, $\\gamma_r$ and $E^*$\n      \\IF{$\\underline{E}_r \\geq E^*$}\n        \\STATE Discard $C_r$ and continue the loop\n      \\ENDIF\n      \\STATE Put $C_r$ into $Q_r$\n    \\ENDFOR\n  \\ENDLOOP\n  \\end{algorithmic}\n  \\caption{Go-ICP -- Outer BnB}\n  \\label{alg:goicp_outer}\n  \\end{algorithm}\n\\end{column}\n\n\\begin{column}{0.5\\textwidth}\n\n  \\begin{algorithm}[H] %% inner\n  \\begin{algorithmic}[1]\n  \\REQUIRE $\\bm{P}$, $\\bm{Q}$, threshold $\\epsilon$, initial cube $\\mathcal{C}_t$, rotation $r_0$, rotation uncertainty radii $\\gamma_r$, so-far-best-error $E^*$\n  \\ENSURE Minimal error $E_t^*$ and corresponding $\\bm{t}^*$\n  \\STATE Put $\\mathcal{C}_t$ into priority queue $Q_t$\n  \\STATE Set $E^*_t = E^*$\n  \\LOOP\n    \\STATE Read out a cube with lowest $\\underline{E}_t$ from $Q_t$\n    \\STATE Quit the loop if $E_t^*-\\underline{E}_t<\\epsilon$\n    \\STATE Divide the the cube into 8 sub-cubes\n    \\FORALL{sub-cube $C_T$}\n      \\STATE Compute $\\overline{E}_t$ for $C_t$ by~\\ref{eq:goicp_outerbound} with $\\bm{r}_0$, $\\bm{t}_0$ and $\\gamma_r$\n      \\IF{$\\overline{E}_t<E_t^*$}\n        \\STATE Update $E_t^*=\\overline{E}_t$, $t^*=t_0$\n      \\ENDIF\n      \\STATE Compute $\\underline{E}_t$ for $C_t$ by~\\ref{eq:goicp_outerbound} with $\\bm{r}_0$, $\\bm{T}_0$ and $\\gamma_t$\n      \\IF{$\\underline{E}_t \\geq E_t^*$}\n        \\STATE Discard $C_t$ and continue the loop\n      \\ENDIF\n      \\STATE Put $C_t$ into $Q_r$\n    \\ENDFOR\n  \\ENDLOOP\n  \\end{algorithmic}\n  \\caption{Go-ICP -- Inner BnB}\n  \\label{alg:goicp_inner}\n  \\end{algorithm}\n\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Experiment}\n\\begin{figure}[htbp]\n\\begin{center}\n  \\includegraphics[width=\\textwidth,height=0.5\\textheight,keepaspectratio]{imgs/GOICP_eval.png}\n  \\caption{Running time of the Go-ICP method on the bunny and dragon point-sets with respect to different factors.}\n  \\label{fig:goicp_evaluation}\n\\end{center}\n\\end{figure}\n\\hspace{2em}\n\\begin{figure}[htbp]\n\\begin{center}\n  \\includegraphics[width=\\textwidth,height=0.5\\textheight,keepaspectratio]{imgs/GOICP_timehistogram.png}\n  \\caption{Running time histograms of Go-ICP for the bunny (left) and dragon (right) point-sets.}\n  \\label{fig:goicp_timehistogram}\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n%%\n\\begin{frame}{Go-ICP Trimming}\nIn \\cite{goicp} a \\textbf{trimmed} version of the algorithm is also proposed. Specifically, in each iteration, only a subset $\\bm{S}$ of the data points are used for motion computation.\n\nThis is a strategy to obtain a more robust statistic by excluding some of the extreme values.\n\\end{frame}\n\n\\begin{frame}{Considerations}\n\\begin{itemize}[wide, labelsep=2em]\n  \\pro Finds the global optimal solution\n  \\pro Defines upper and lower bound in domain regions\n  \\pro Not constrained to ICP variants\n  \\pro Parallelism can speed up computation a lot\n  \\con Limited to pt-to-pt distance\n  \\con Computes closest points set each iteration\n  \\con Computationally demanding\n\\end{itemize}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Generalized ICP                                   %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Generalized ICP (2009)}\n%%\n\\begin{frame}[allowframebreaks]{Derivation}\nThe Generalized-ICP~\\cite{gicp} uses \\textbf{probabilistic approach} to increase robustness by changing\n\\[ \\bm{T}\\gets\\argmin\\limits_T \\sum\\limits_i \\omega_i \\norm{\\bm{m}_i-\\bm{T}\\bm{p}_i} \\]\nin the basic ICP algorithm (alg.~\\ref{alg:ICP}).\n\n\\framebreak\n\nFor the purpose of this section let's assume that:\n\\begin{itemize}\n  \\item $\\bm{p}_i$ is a correspondence for $\\bm{q}_i$ (and vice versa) - W.L.O.G.\n  \\item $\\hat{\\bm{P}}=\\{\\hat{\\bm{p}}_i\\}, \\quad \\bm{p}_i \\sim \\mathcal{N}(\\hat{\\bm{p}}_i,\\bm{C}_i^P)$\n  \\item $\\hat{\\bm{Q}}=\\{\\hat{\\bm{q}}_i\\}, \\quad \\bm{q}_i \\sim \\mathcal{N}(\\hat{\\bm{q}}_i,\\bm{C}_i^Q)$\n\\end{itemize}\nwhere $\\bm{C}_i^P$ and $\\bm{C}_i^Q$ are covariance matrices associated with the measured points.\n\n%\\framebreak\n%%(geometrically consistent with no errors due to occlusion or sampling)\n%Assuming \\textbf{perfect correspondences} we have a transformation $\\bm{T}^*$ such that\n%\\[\\hat{\\bm{q}_i}=\\bm{T}^*\\hat{\\bm{p}_i} \\]\n\n%For an arbitrary rigid transformation, $\\bm{T}$, define\n%\\[ d_i^{(\\bm{T})}=\\bm{q}_i-\\bm{T}\\bm{p}_i \\]\n\n%Consider the distribution from which $d(\\bm{T}^*)$ is drawn. Since $\\bm{p}_i$ and $\\bm{q}_i$ are assumed to be drawn from independent Gaussians,\n%\\[ \n%\\begin{array}{ll}\n%d_i^{(\\bm{T}^*)} &\\sim \\mathcal{N}\\Big(\\bm{q}_i - (\\bm{T}^*)\\bm{p}_i,~ \\bm{C}_i^Q +(\\bm{T}^*)\\bm{C}_i^P(\\bm{T}^*)^T \\Big) \\\\\n%&= \\mathcal{N}\\Big( 0,~ \\bm{C}_i^Q +(\\bm{T}^*)\\bm{C}_i^P(\\bm{T}^*)^T \\Big)\n%\\end{array}\n%\\]\n\n\\framebreak\n\n%We can use \\textbf{Maximum likelihood estimation} to iteratively compute $\\bm{T}$\n%\\[ \\bm{T} = \\argmax\\limits_{\\bm{T}} \\prod\\limits_i p\\big( d_i^{(\\bm{T})} \\big)\n%     = \\argmax\\limits_{\\bm{T}} \\sum\\limits_i \\log \\big(\n%     p\\big( d_i^{(\\bm{T})} \\big) \\big)\n%\\]\n%that can be simplified to\n%\\begin{equation}\n%\\bm{T} = \\argmin\\limits_{\\bm{T}} \\sum\\limits_i {d_i^{(\\bm{T})}}^T ( \\bm{C}_i^Q+ \\bm{T} \\bm{C}_i^P \\bm{T}^T)^{-1} d_i^{(\\bm{T})}\n%\\end{equation}\n%This defines the \\textbf{key step} of the Generalized-ICP algorithm.\n\n\nWe can use \\textbf{Maximum likelihood estimation} to iteratively compute $\\bm{T}$\n\\[ \\bm{T} = \\argmax\\limits_{\\bm{T}} \\prod\\limits_i p\\big( \\Ealign \\big)\n     = \\argmax\\limits_{\\bm{T}} \\sum\\limits_i \\log \\big(\n     p\\big( \\Ealign \\big) \\big)\n\\]\nthat can be simplified to\n\\begin{equation}\n\\bm{T} = \\argmin\\limits_{\\bm{T}} \\sum\\limits_i (\\Ealign)^T ( \\bm{C}_i^Q+ \\bm{T} \\bm{C}_i^P \\bm{T}^T)^{-1} (\\Ealign)\n\\end{equation}\nThis defines the \\textbf{key step} of the Generalized-ICP algorithm (Mahalanobis distance).\n\\end{frame}\n\n\\begin{frame}{Results}\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[width=\\textwidth,keepaspectratio]{imgs/gicp.png}\n\\caption{Average error}\n\\label{fig:gicp}\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}{Considerations}\n\\begin{itemize}[wide, labelsep=2em]\n  \\pro Probabilistic approach\n  \\pro Covariance matrices give good flexibility\n  \\con Covariance matrices can be complex to compute\n  \\con Might get caught in local minima\n  \\con Still dependent on initial guess\n  \\con No closed form solution for $\\bm{T}$ is available\n\\end{itemize}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Learning Anisotropic ICP                          %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Learning Anisotropic ICP (2016)}\n\n\\begin{frame}{Principle}\n%Within the generalized ICP framework, we need to have some strategies to determine the values of covariances.\n\n\\begin{figure}[htbp]\n\\begin{center}\n  \\includegraphics[height=0.5\\textheight,keepaspectratio]{imgs/LAICP.png}\n  %\\caption{LA-ICP}\n  \\label{fig:LAICP}\n\\end{center}\n\\end{figure}\n\\textbf{Idea:} Learning Anisotropic ICP \\cite{lee2016learning}, assumes anisotropic Gaussian, and estimates the covariance. The learning scheme does not require manual tuning and the covariance is continually updated from observed data.\n\\end{frame}\n\n\n\\begin{frame}{Pros and Cons}\n\\begin{itemize}[wide, labelsep=2em]\n\\setlength\\itemsep{1em}\n\\pro Assumes anisotropic noise\n\\pro Reduces computational overhead due to covariance matrices\n\\con Still local optimization method\n\\end{itemize}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%       Fast Global Registration                          %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Fast Global Registration (2016)}\n%%\n\\begin{frame}{Introduction}\nLet $\\mathcal{K}=\\{(p,q)\\}$ be a set of \\textbf{correspondences} collected by matching points from $\\bm{P}$ and $\\bm{Q}$.% as described in slide \\ref{fpfh_correspondences}.\n\nWe want to minimize:\n\\begin{equation}\n\\label{eq:fastgo_obj}\nE(\\bm{T})=\\sum_{(p,q)\\in\\mathcal{K}}\\rho({\\norm{q_i-\\bm{T}p_i}})\n\\end{equation}\nwhere $\\rho(\\cdot)$ is a \\textbf{robust penalty function}, i.e. \\alert{scaled Geman-McClure estimator}.\n\\end{frame}\n\n%%\n\\begin{frame}{Scaled Geman-McClure estimator}\nUsing this estimator small residuals are penalized in the LS sense:\n\\begin{equation}\n\\rho(x)=\\frac{\\mu x^2}{\\mu+x^2}\n\\end{equation}\n\\begin{figure}[htbp]\n\\begin{center}\n\\includegraphics[width=\\textwidth,height=0.5\\textheight,keepaspectratio]{imgs/geman_estimator.png}\n\\caption{Geman-McClure estimator vs. Objective function (\\ref{eq:fastgo_obj})}\n\\label{fig:geman}\n\\end{center}\n\\end{figure}\n%The parameter $\\mu$ controls the range within which residuals have a significant effect on the objective.\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Black-Ragarajan duality}\nObjective function (\\ref{eq:fastgo_obj}) is difficult to optimize directly, so the authors used \\textbf{Black-Ragarajan duality} between line process and robust estimation \\cite{black1996unification}.\n\nLet's $\\mathbb{L}=\\{l_{(p,q)}\\}$ a line process over the correspondences, we can write a new objective function optimized over $\\bm{T}$ and $\\mathbb{L}$.\n\\begin{equation}\n\\label{eq:fastgo_fullobj}\nE(\\bm{T},\\mathbb{L})=\\sum_{(p,q)\\in\\mathcal{K}}\\big(l_{(p,q)}\\norm{p-\\bm{T}q}^2+\\Psi(l_{(p,q)})\\big)\n\\end{equation}\nwhere  \n\\[ \\Psi(l_{(p,q)}) = \\mu \\big( \\sqrt{l_{(p,q)}} -1 \\big)^2 \\]\n\nMinimizing (\\ref{eq:fastgo_fullobj}) over $\\mathbb{L}$ we have:\n\\[ \\frac{\\partial{E}}{\\partial{l_{(p,q)}}} = \\norm{p-\\bm{T}q} +\\mu\\frac{\\sqrt{l_{(p,q)}} -1}{\\sqrt{l_{(p,q)}}}  = 0 \\]\nSolving for $l_{(p,q)}$ yields\n\\begin{equation}\\label{eq:fgr_lattice}\n l_{(p,q)} =  \\Bigg( \\frac{\\mu}{\\mu + \\norm{p-\\bm{T}q}^2}  \\Bigg)^2\n \\end{equation}\n\nSubstituting $l_{(p,q)}$ in (\\ref{eq:fastgo_fullobj}) we obtain (\\ref{eq:fastgo_obj}). Thus \\textbf{optimizing objective (\\ref{eq:fastgo_fullobj}) yields a solution $\\bm{T}$ that is also optimal for the original objective (\\ref{eq:fastgo_obj})}.\n\n\\alert{What about the correspondences?}\n\\end{frame}\n\n%%\n\n\\begin{frame}[allowframebreaks]{Fast Point Feature Histogram (FPFH)}\n\\begin{itemize}\n\\item The goal of FPFH is to encode a point's \\textbf{k-neighborhood geometrical properties}.\n\\item The complexity is $O(kN)$, where $k$ is the number of neighbors for each point~\\cite{rusu2009fast}\n\\item It is based on the \\textbf{Simple Point Feature Histogram (SPFH)}\n\\end{itemize}\n\n\\framebreak\n\n\\textbf{Simple Point Feature Histogram (SPFH)}\n\\par\nFor each query point $\\bm{p}_q$, \n\\begin{itemize}\n\\item Compute the $k$-neighborhood set $P_k^q$\n\\item Compute the tuple $(\\alpha,\\phi,\\theta)$ between $\\bm{p}_q$ and each $\\bm{p}_k\\in P_k^q$\n\\begin{equation}\n\\begin{array}{ll}\n\\bm{u} & = \\bm{n}_q \\\\\n\\bm{v} & = \\bm{u} \\times \\frac{(\\bm{p}_k-\\bm{p}_q)}{\\norm{\\bm{p}_k-\\bm{p}_q}} \\\\\n\\bm{w} & = \\bm{u} \\times \\bm{v}\n\\end{array}\t\\qquad \\Rightarrow \\qquad\n\\begin{array}{ll}\n\\alpha & = \\bm{v}\\cdot\\bm{n}_k \\\\\n\\phi & = \\bm{u} \\cdot \\frac{(\\bm{p}_k-\\bm{p}_q)}{\\norm{\\bm{p}_k-\\bm{p}_q}_2} \\\\\n\\theta & = \\arctan(\\bm{w}\\cdot\\bm{n}_q, \\bm{u}\\cdot\\bm{n}_k)\n\\end{array}\n\\end{equation}\n\\item Bin all $(\\alpha,\\phi,\\theta)$ into a histogram\n\\end{itemize}\n\n\\framebreak\n\nTo compute the FPFH histogram feature:\n\\begin{itemize}\n  \\item for each query point $\\bm{p}_q$ compute the SPFH\n  \\item for each point its $k$ neighbors are re-determined, and the neighboring SPFH values are used to weight the final histogram of $\\bm{p}_q$ (called FPFH) as in eq.\\ref{eq:fpfh}\n\\end{itemize}\n\n\\begin{equation}\n\\label{eq:fpfh}\n\\text{FPFH}(\\bm{p}_q)=\\text{SPFH}(\\bm{p}_q)+\\frac{1}{k}\\sum_{i=1}^{k}\\frac{1}{\\omega_k}\\cdot\\text{SPFH}(\\bm{p}_k)\n\\end{equation}\nwhere the weight $\\omega_k$ represents a distance between the query point $\\bm{p}_q$ and a neighbor point $\\bm{p}_k$ in some given metric space.\n\n%\\begin{figure}[htbp]\n%\\begin{center}\n%\\begin{minipage}[b]{0.45\\linewidth}\n%            \\centering\n%            \\includegraphics[width=\\textwidth,height=0.5\\textheight,keepaspectratio]{imgs/DarbouxFrame.png}\n%\t    \\caption{Darboux Frame}\n%            \\label{fig:DarbouxFrame}\n%        \\end{minipage}\n%        \\hspace{0.5cm}\n%        \\begin{minipage}[b]{0.45\\linewidth}\n%            \\centering\n%             \\includegraphics[width=\\textwidth,height=0.3\\textheight,keepaspectratio]{imgs/FPFH_NN.png}\n%\t    \\caption{The influence region diagram for a Point Feature Histogram.}\n%            \\label{fig:FPFH_NN}\n%        \\end{minipage}\n%\\end{center}\n%\\end{figure}\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Correspondences set}\\label{fpfh_correspondences}\nThe correspondence set is build as following, let \n\\begin{itemize}\n\\item $F(\\bm{P})=\\{F(\\bm{p}):\\bm{p}\\in\\bm{P}\\}$ the FPFH of points in $\\bm{P}$\n\\item $F(\\bm{Q})=\\{F(\\bm{q}):\\bm{q}\\in\\bm{Q}\\}$ the FPFH of points in $\\bm{Q}$\n\\end{itemize}\n\n$\\mathcal{K}_1$ is the set containing the nearest neighbor of $F(\\bm{p})$ among $F(\\bm{Q})$, and vice versa.\n\n\\framebreak\n\nWe can improve the correspondences set by applying:\n\\begin{description}\n\\item[Reciprocity test] A correspondence pair $(\\bm{p}, \\bm{q})$ is selected from $\\mathcal{K}_1$ if and only if $F(\\bm{p})$ is the nearest neighbor of $F(\\bm{q})$ among $F(\\bm{P})$ and $F(\\bm{q})$ is the nearest neighbor of $F(\\bm{p})$ among $F(\\bm{Q})$. The resulting correspondence set is denoted by $\\mathcal{K}_2$\n\\item[Tuple test] Randomly pick 3 correspondence pairs $(\\bm{p_1}, \\bm{q_1})$, $(\\bm{p_2}, \\bm{q_2})$, $(\\bm{p_3}, \\bm{q_3})$ from $\\mathcal{K}_2$ and check if the tuples $(\\bm{p_1}, \\bm{p_2}, \\bm{p_3})$ and $(\\bm{q_1}, \\bm{q_2}, \\bm{q_3})$ are compatible\n\\[ \\forall i\\neq j, \\quad \\tau \\le \\frac{\\norm{p_i-p_j}}{\\norm{q_i-q_j}} \\le \\frac{1}{\\tau}, \\quad \\tau=0.9 \\]\nThis is the set used by the algorithm $\\mathcal{K} = \\mathcal{K}_3$\n\\end{description}\n\\end{frame}\n\n%%\n\\begin{frame}{Fast Global Registration Algorithm}\nLet $D$ be the diameter of the largest surface and $\\delta$ the distance threshold for genuine correspondence\n\\begin{algorithm}[H]\n\\begin{algorithmic}[1]\n\\STATE{Compute normals $\\{\\bm{n}_p\\}$ and $\\{\\bm{n}_q\\}$}\n\\STATE{Compute $F(\\bm{P})$ and $F(\\bm{Q})$}\n\\STATE{Compute $\\mathcal{K}=\\mathcal{K}_3$}\n%\\STATE{Build $\\mathcal{K}_1$ by computing nearest neighbors between $\\bm{F}(\\bm{P})$ and $\\bm{F}(\\bm{Q})$}\n%\\STATE{Apply reciprocity test on $\\mathcal{K}_1$ to get $\\mathcal{K}_2$}\n%\\STATE{Apply tuple test on $\\mathcal{K}_2$ to get $\\mathcal{K}_3$}\n\\STATE{$\\bm{T}\\gets \\bm{I},~\\mu\\gets D^2$}\n\\WHILE{not converged or $\\mu>\\delta^2$}\n\\FOR{$(p,q)\\in\\mathcal{K}$}\n\\STATE{Compute $l_{(p,q)}$ using equation~\\ref{eq:fgr_lattice}}\n\\ENDFOR\n\\STATE{Compute $\\bm{T}$ (closed form~\\cite{horn1987closed})}\n\\STATE{Every four iterations $\\mu\\gets \\mu/2$}\n\\ENDWHILE\n\\end{algorithmic}\n\\caption{Fast Global Registration}\n\\label{alg:fastglobalregistration}\n\\end{algorithm}\n\\end{frame}\n\n%%\n\\begin{frame}[allowframebreaks]{Performance}\n\\begin{figure}[htbp]\n\\begin{center}\n\\centering\n\\includegraphics[width=1.5\\textheight,keepaspectratio]{imgs/RMSE_fgr.png}\n\\caption{Average and maximal RMSE achieved by global registration algorithms on synthetic range images with noise level $\\sigma$}\n\\label{fig:fastgo_RMSR}\n\\end{center}\n\\end{figure}\n\\begin{figure}[htbp]\n\\begin{center}\n\\centering\n\\includegraphics[width=1.5\\textheight,keepaspectratio]{imgs/Time_fgr.png}\n\\caption{Running times of global registration methods, measured in seconds}\n\\label{fig:fastgo_time}\n\\end{center}\n\\end{figure}\n\n%\\framebreak\n\n%\\begin{figure}[htbp]\n%\\begin{center}\n%\\centering\n%\\includegraphics[width=1.5\\textheight,keepaspectratio]{imgs/LocalRMSE_fgr.png}\n%\\caption{Controlled comparison with local methods. Perturbation refers to initialization}\n%\\label{fig:fastgo_lacalRMSE} \n%\\end{center}\n%\\end{figure}\n\\begin{figure}[htbp]\n\\begin{center}\n\\centering\n\\includegraphics[width=1.5\\textheight,keepaspectratio]{imgs/LocalTime_fgr.png}\n\\caption{Timing comparison with local algorithms, measured in seconds}\n\\label{fig:fastgo_lacalTime}\n\\end{center}\n\\end{figure}\n\\end{frame}\n\n%%\n\\begin{frame}{Pros and Cons}\n\\begin{itemize}[wide, labelsep=2em]\n\\setlength\\itemsep{1em}\n\\pro Global optimization\n%\\pro Matches ICP performance (both local and global)\n\\pro One order of magnitude faster\n\\pro Does not require initialization\n\\pro Correspondences computed only once but their weight change\n\\con No proof of global convergence in the paper\n\\end{itemize}\n\\end{frame}\n\n% ===== BIB =====\n\n\\begin{frame}[allowframebreaks]{References}\n\\printbibliography\n\\end{frame}\n\n\\end{document}", "meta": {"hexsha": "438d277448464e9a3f84d891a56fb7d1463c7211", "size": 28342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Presentation/3DRegistration.tex", "max_stars_repo_name": "pantonante/3dRegistration", "max_stars_repo_head_hexsha": "96d23c6bef924174b113fc37975423eb13d5872a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2019-01-23T01:31:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T07:05:01.000Z", "max_issues_repo_path": "Presentation/3DRegistration.tex", "max_issues_repo_name": "pantonante/3dRegistration", "max_issues_repo_head_hexsha": "96d23c6bef924174b113fc37975423eb13d5872a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Presentation/3DRegistration.tex", "max_forks_repo_name": "pantonante/3dRegistration", "max_forks_repo_head_hexsha": "96d23c6bef924174b113fc37975423eb13d5872a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2018-07-14T04:34:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-28T11:22:35.000Z", "avg_line_length": 38.1453566622, "max_line_length": 318, "alphanum_fraction": 0.678745325, "num_tokens": 9578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.4176237928072461}}
{"text": "% MARINA VON STEINKIRCH, SPRING/2013\n% http://mysbfiles.stonybrook.edu/~mvonsteinkir/\n\\documentclass[11pt]{article}\n\n\\usepackage{epsfig}\n\\usepackage{color}\n\\usepackage{amsmath}    % Package  for subequations\n\\usepackage{graphicx}   % Package for figures\n\\usepackage{verbatim}   % Package  for program listings\n\\usepackage{hyperref}   % Package  for hypertext links, external documents and URLs\n\\usepackage{amssymb} % For mathematical constructions\n\\usepackage{latexsym} % Package to generate mathematical symbols\n\\usepackage{makeidx} % Package to generate an index in the end\n\n\n\\newcommand{\\ie}{{\\it i.e., }}\n\\newcommand{\\eg}{{\\it e.g., }}\n\n\n\\title{CSE 590: Computational Photography\\\\  Homework \\#2: Image Blending }\n\\author{ \\texttt{ Marina von Steinkirch, steinkirch@gmail.com}\\\\\n\t   \\texttt{State University of New York at Stony Brook}}\n\\date{\\today}\n\n\n\n\n\\begin{document}\n\\maketitle\n\\numberwithin{equation}{section}  \n\n\n\n\n\\section{Introduction}\n\nThis project explores the gradient-domain processing, a technique with many applications including:\n\\begin{itemize}\n\\item blending, \n\\item tone-mapping, \n\\item and non-photorealistic rendering.\n\\end{itemize}  \n\n\\quad\n\nThe  goal of this assignment is to {\\it seamlessly blend} an object  from a source image into a target image. If we naively tried a simple cut and paste, we would see noticeable {\\it seams}.  However, using the {\\it Poisson blending technique} \\cite{pois}, we are able  to achieve better results than just cutting and pasting.  The technique consists on finding values for the target pixels that {\\it maximally preserve the gradient} of the source region, without changing any of the background pixels. In other words, we preserve the integrity of the gradient at the seams.\n\n\\quad \n\nThe Poisson blending technique is solved as a {\\it least squares problem}, \\ie given the pixel intensities of the source image, $s$, and of the target image, $t$, we  solve for {\\it new intensity values},  $v$, within the source region $S$:\n\n\\begin{equation}\nv = \\mbox{ argmin} \\sum_{i \\in S, j \\in N_i, S} \\Bigg ( \\Big ( v_i -v_j\\Big) - \\Big (s_i - s_j \\Big) \\Bigg)^2 +  \\sum_{i \\in S, j \\in N_i, -S} \\Bigg ( \\Big ( v_i -t_j\\Big) - \\Big (s_i - s_j \\Big) \\Bigg)^2. \n\\label{aa}\n\\end{equation}\n\n\\quad\n\nThe idea is to recover an image that is best reflected by this edited gradient. Since the gradient provides us with linear constraints for every pixel in every color channel,\n$$I_{i,j} - I_{i+1,j} = \\frac{\\partial}{\\partial x},$$\nand\n$$I_{i,j} - I_{i,j+1} = \\frac{\\partial}{\\partial y},$$\n we can formulate a {\\it overdetermined system of linear equations}. Moreover, we set the desired {\\it gradient field} $A x$ equals to the constraints defined by the vector field $b$ of the two images. The matrix $A$ can be seen as the representation of the gradient as a  {\\it linear transformation} of the original image $x$. The result is a {\\it large linear system} for each color channel with {\\it one variable per pixel}, $Ax=b$. \n\n\\quad\n\n\\section{Results}\n\n\\quad\n\n\\subsection*{Toy Model: Reconstruction of an Image from its Gradient}\n\nWe start by showing that an image can be reconstructed by its gradient values, where we:\n\\begin{itemize}\n\\item preserve x-y gradients, and\n\\item preserve intensity of one pixel.\n\\end{itemize}\n\n\\quad\n\nFor this objective, we denote the {\\it intensity of the source image} at $(x, y)$ as $s(x,y)$ and the value to solve for as $v(x,y)$ and, for each pixel, we had three objectives: \n\\begin{itemize}\n\\item minimize $\\Bigg (v(x+1,y)-v(x,y)\\Big) - \\Big(s(x+1,y)-s(x,y)\\Big) \\Bigg)^2 $,\n\\item minimize $\\Bigg( \\Big(v(x,y+1)-v(x,y)\\Big) - \\Big(s(x,y+1)-s(x,y)\\Big) \\Bigg)^2 $, \n\\item minimize $\\Big(v(1,1)-s(1,1)\\Big)^2 $, \\ie adding any constant value to $v$.\n\\end{itemize}\n\n\\quad\n\nProcessing the sample image with this recipe return an identical image, with  {\\it root square} equal to $2.3631\\times 10^{-5}$.\n\n\n\n\n\n\\quad\n\n\\subsection*{Poisson Blending}\n\nTo solve the Poisson blending for two images, we implement the following steps:\n\\begin{enumerate}\n\\item we select source and target regions (Fig. \\ref{1}-1 and  \\ref{1}-2),\n\\item we get a mask for the source image, and align the two images and the mask (Fig. \\ref{1}-3 and \\ref{1}-4),\n\\item we solve the blending constraints described in the Eq. \\ref{aa},\n\\item we copy the solved values into the target image, where for RGB images each channel is processed separately. The cut and past and the final blending results can be seen in the Fig. \\ref{1}-5 and  \\ref{1}-6.\n\\end{enumerate}\n\n\\quad\n\nIn the Figs. \\ref{1}, we see that the Poisson blending worked nicely (no seams). This is due the fact that  the penguin is surrounded by snow in the source image, matching the snow in the background of the target image. We also notice that  the overall intensity of the penguin is darker with the Poisson blending technique. This is due the fact that the intensity of the surrounding snow is slightly darker in the target area.\n\n\\quad \n\nThe same successful result can be see in the Fig. \\ref{2}. The figures also  illustrate the noticeable seam in the naive cut and paste cropping.  In the other hand, in the Figs. \\ref{3} and \\ref{4} we see some failure examples of the Poisson blending. This is due the fact that the background of the two chosen images do not match even when taking the gradients.\n\n\\quad\n\n\\begin{figure} [ht]\n\\begin{center}\n\\includegraphics[scale=0.44]{results_poisson/set1/im1.png}  \n\\includegraphics[scale=0.44]{results_poisson/set1/im2.png}\n\\includegraphics[scale=0.44]{results_poisson/set1/im3.png}  \n\\includegraphics[scale=0.44]{results_poisson/set1/im4.png} \n\\includegraphics[scale=0.44]{results_poisson/set1/im5.png}  \n\\includegraphics[scale=0.44]{results_poisson/set1/im6.png}   \n\\caption{Sample example of Poisson blending. (left, top) Source object, (middle, top) background image, (right, top) aligned source, (left, bottom) user input mask, (middle, bottom) cut and paste result, (right, bottom) Poisson blending final result.}\n\\label{1}\n\\end{center}\n\\end{figure}\n\n\n\\quad\n\n\\begin{figure} [ht]\n\\begin{center}\n\\includegraphics[scale=0.29]{results_poisson/set4/im1.jpg}  \n\\includegraphics[scale=0.155]{results_poisson/set4/im2.jpg}\\\\\n\\includegraphics[scale=0.54]{results_poisson/set4/im4.png} \n\\includegraphics[scale=0.39]{results_poisson/set4/im5.png}   \n\\caption{My favorite blending result. (left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}\n\\label{2}\n\\end{center}\n\\end{figure}\n\n\\quad\n\n\n\\begin{figure} [ht]\n\\begin{center}\n\\includegraphics[scale=0.2]{results_poisson/set2/im1.jpg}  \n\\includegraphics[scale=0.2]{results_poisson/set2/im2.jpg}\n\\includegraphics[scale=0.49]{results_poisson/set2/im4.png} \n\\includegraphics[scale=0.44]{results_poisson/set2/im5.png}   \n\\caption{An failure example of Poisson example: the texture of the background of the two images are too distant for a simple gradient mixing. (left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}\n\\label{3}\n\\end{center}\n\\end{figure}\n\n\\quad\n\n\n\n\n\n\n\\begin{figure} [ht]\n\\begin{center}\n\\includegraphics[scale=0.12]{results_poisson/set5/im1.jpg}  \n\\includegraphics[scale=0.28]{results_poisson/set5/im2.jpg}\n\\includegraphics[scale=0.54]{results_poisson/set5/im4.png} \n\\includegraphics[scale=0.47]{results_poisson/set5/im5.png}   \n\\caption{Another failure  example of Poisson example, here the gradient literally changes the color of the Sun, however in the object are not corrected.(left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}\n\\label{4}\n\\end{center}\n\\end{figure}\n\n\\quad\n\n\n\n\n\\subsection*{Mixed Blending}\nTo improve cases where we see failure in the Poisson bending,  we try to implement an adaptation of the Eq. \\ref{aa},\n\\begin{equation}\nv = \\mbox{ argmin} \\sum_{i \\in S, j \\in N_i, S} \\Bigg ( \\Big ( v_i -v_j\\Big) - d_{i,j} \\Bigg)^2 +  \\sum_{i \\in S, j \\in N_i, -S} \\Bigg ( \\Big ( v_i -t_j\\Big) - d_{i,j} \\Bigg)^2,\n\\end{equation}\nwhere $d_{i,j}$ is the value of the gradient from the source or the target image with {\\it larger magnitude}. However this technique  did not show any improvement in the above examples.\n\n\n\\newpage\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\tRef\t\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\\begin{thebibliography}{}\n\n\\bibitem{mike}{\\it Tamara Berg's Class}, {\\it http://www.tamaraberg.com/teaching/Spring13/compphotog/3}\n\n\\bibitem{pois} {\\it Poisson Editing}, Patrick Perez, Michel Gangnet, $\\&$ Andrew Blacke, 2003\n\n\\end{thebibliography}\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "5a72ea09623d59da8846c55965448881b2d82db7", "size": 8871, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gradient/tex/comp_hw2.tex", "max_stars_repo_name": "bt3gl/Computational_Photog_and_Hacking_XBOX_Kinetic", "max_stars_repo_head_hexsha": "eb089cbb601c5359c61275de40b8f203d5b4bc2f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-01-04T00:05:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T17:48:04.000Z", "max_issues_repo_path": "gradient/tex/comp_hw2.tex", "max_issues_repo_name": "bt3gl/Computational_Photog_and_Hacking_XBOX_Kinetic", "max_issues_repo_head_hexsha": "eb089cbb601c5359c61275de40b8f203d5b4bc2f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gradient/tex/comp_hw2.tex", "max_forks_repo_name": "bt3gl/Computational_Photog_and_Hacking_XBOX_Kinetic", "max_forks_repo_head_hexsha": "eb089cbb601c5359c61275de40b8f203d5b4bc2f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-08T21:51:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-08T21:51:42.000Z", "avg_line_length": 42.0426540284, "max_line_length": 574, "alphanum_fraction": 0.712433773, "num_tokens": 2545, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.41753366863408964}}
{"text": "\\chapter{Small oscillations-solutions}\n\\begin{abox}\n\tPractice set 1\n\\end{abox}\n\\begin{enumerate}\n\t\t\\item  A particle of unit mass moves in a potential $V(x)=a x^{2}+\\frac{b}{x^{2}}$, where $a$ and $b$ are positive constants. The angular frequency of small oscillations about the minimum of the potential is\n\t\t{\\exyear{NET JUNE 2011}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\sqrt{8 b}$\n\t\t\\task[\\textbf{B.}]$\\sqrt{8 a}$\n\t\t\\task[\\textbf{C.}] $\\sqrt{8 a / b}$\n\t\t\\task[\\textbf{D.}]$\\sqrt{8 b / a}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tV(x)&=a x^{2}+\\frac{b}{x^{2}} \\Rightarrow \\frac{\\partial V}{\\partial x}=0 \\Rightarrow 2 a x-\\frac{2 b}{x^{3}}=0 \\Rightarrow a x^{4}-b=0 \\Rightarrow x_{0}=\\left(\\frac{b}{a}\\right)^{\\frac{1}{4}}\\\\\n\t\t\\text { Since } \\omega&=\\sqrt{\\frac{k}{m}}, m=1\\\\\n\t\tk&=\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=x_{0}} \\text { where } x_{0} \\text { is stable equilibrium point. }\\\\\n\t\t\\text { Hence } k&=\\frac{\\partial^{2} V}{\\partial x^{2}}=2 a+\\frac{6 b}{x_{0}^{4}}=2 a+\\frac{6 b}{b /}=8 a \\text { at } x=x_{0}=\\left(\\frac{b}{a}\\right)^{\\frac{1}{4}}\\\\\n\t\t\\text { Thus, } \\omega&=\\sqrt{8 a} \\text {. }\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(b)}\n\t\\end{answer}\n\t\t\\item Consider the motion of a classical particle in a one dimensional double-well potential $V(x)=\\frac{1}{4}\\left(x^{2}-2\\right)^{2} .$ If the particle is displaced infinitesimally from the minimum on the $x$-axis (and friction is neglected), then\n\t\t{\\exyear{NET JUNE 2012}}\n\t\\begin{tasks}(1)\n\t\t\\task[\\textbf{A.}] the particle will execute simple harmonic motion in the right well with an angular frequency $\\omega=\\sqrt{2}$\n\t\t\\task[\\textbf{B.}]the particle will execute simple harmonic motion in the right well with an angular frequency $\\omega=2$\n\t\t\\task[\\textbf{C.}]the particle will switch between the right and left wells\n\t\t\\task[\\textbf{D.}]the particle will approach the bottom of the right well and settle there\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tV(x)&=\\frac{1}{4}\\left(x^{2}-2\\right)^{2} \\Rightarrow \\frac{\\partial V}{\\partial x}=\\frac{2}{4}\\left(x^{2}-2\\right) \\times 2 x=0 \\Rightarrow x=0, x=\\pm \\sqrt{2}\\\\\n\t\t\\frac{\\partial^{2} V}{\\partial x^{2}}&=3 x^{2}-2\\\\\n\t\t\\text { At } x=0, \\frac{\\partial^{2} V}{\\partial x^{2}}&<0 \\text { so } V \\text { is maximum. Thus it is unstable point }\\\\\n\t\t\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=\\pm \\sqrt{2}}&=4 \\text { and it is stable equilibrium point with } \\omega=\\sqrt{\\frac{\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=x_{0}}}{\\mu}}=2 \\quad \\because \\mu=1 \\text {. }\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(b)}\t\n\t\\end{answer}\n\t\n\t\t\\item Three particles of equal mass $(\\mathrm{m})$ are connected by two identical massless springs of stiffness constant $(K)$ as shown in the figure\\\\\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[height=1cm,width=5cm]{problem1}\n\t\t\\end{figure}\n\t\tIf $x_{1}, x_{2}$ and $x_{3}$ denote the horizontal displacement of the masses from their respective equilibrium positions the potential energy of the system is\n\t\t{\\exyear{NET DEC 2012}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\frac{1}{2} K\\left[x_{1}^{2}+x_{2}^{2}+x_{3}^{2}\\right]$\n\t\t\\task[\\textbf{B.}]$\\frac{1}{2} K\\left[x_{1}^{2}+x_{2}^{2}+x_{3}^{2}-x_{2}\\left(x_{1}+x_{3}\\right)\\right]$\n\t\t\\task[\\textbf{C.}]$\\frac{1}{2} K\\left[x_{1}^{2}+2 x_{2}^{2}+x_{3}^{2}-2 x_{2}\\left(x_{1}+x_{3}\\right)\\right]$\n\t\t\\task[\\textbf{D.}]$\\frac{1}{2} K\\left[x_{1}^{2}+2 x_{2}^{2}-2 x_{2}\\left(x_{1}+x_{3}\\right)\\right]$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tV&=\\frac{1}{2} K\\left(x_{2}-x_{1}\\right)^{2}+\\frac{1}{2} K\\left(x_{3}-x_{2}\\right)^{2}\\\\\n\t\tV&=\\frac{1}{2} K\\left(x_{2}^{2}+x_{1}^{2}-2 x_{2} x_{1}\\right)+\\frac{1}{2} K\\left(x_{3}^{2}+x_{2}^{2}-2 x_{3} x_{2}\\right)\\\\\n\t\tV&=\\frac{1}{2} K\\left[x_{1}^{2}+2 x_{2}^{2}+x_{3}^{2}-2 x_{2}\\left(x_{1}+x_{3}\\right)\\right]\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\n\t\\end{answer}\n\t\t\\item The time period of a simple pendulum under the influence of the acceleration due to gravity $g$ is $T$. The bob is subjected to an additional acceleration of magnitude $\\sqrt{3} g$ in the horizontal direction. Assuming small oscillations, the mean position and time period of oscillation, respectively, of the bob will be\n\t\t{\\exyear{NET JUNE 2014}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $0^{\\circ}$ to the vertical and $\\sqrt{3} T$\n\t\t\\task[\\textbf{B.}]$30^{\\circ}$ to the vertical and $T / 2$\n\t\t\\task[\\textbf{C.}]$60^{\\circ}$ to the vertical and $T / \\sqrt{2}$\n\t\t\\task[\\textbf{D.}]$0^{\\circ}$ to the vertical and $T / \\sqrt{3}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tT&=2 \\pi \\sqrt{\\frac{l}{g}}\\\\\n\t\tg^{\\prime}&=\\sqrt{3 g^{2}+g^{2}}=\\sqrt{4 g^{2}}=2 g\\\\\n\t\tT^{\\prime}&=2 \\pi \\sqrt{\\frac{l}{2 g}} \\Rightarrow T^{\\prime}=2 \\pi \\sqrt{\\frac{l}{g}} \\cdot \\frac{1}{\\sqrt{2}} \\Rightarrow T^{\\prime}=\\frac{T}{\\sqrt{2}}\\\\\n\t\tT \\cos \\theta&=m g, T \\sin \\theta=\\sqrt{3} m g \\Rightarrow \\tan \\theta=\\sqrt{3} \\Rightarrow \\theta=60^{\\circ}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\t\n\t\\end{answer}\n\t\t\\item A particle of mass $m$ is moving in the potential $V(x)=-\\frac{1}{2} a x^{2}+\\frac{1}{4} b x^{4}$ where $a, b$ are positive constants. The frequency of small oscillations about a point of stable equilibrium is\n\t\t{\\exyear{NET DEC 2014}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\sqrt{a / m}$\n\t\t\\task[\\textbf{B.}]$\\sqrt{2 a / m}$\n\t\t\\task[\\textbf{C.}]$\\sqrt{3 a / m}$\n\t\t\\task[\\textbf{D.}]$\\sqrt{6 a / m}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\because V(x)&=-\\frac{1}{2} a x^{2}+\\frac{1}{4} b x^{4}\t\\\\\n\t\t\\frac{\\partial V}{\\partial x}&=0 \\Rightarrow-a x+b x^{3}=0 \\Rightarrow x\\left[-a+b x^{2}\\right]=0 \\Rightarrow x=\\pm\\left(\\frac{a}{b}\\right)^{\\frac{1}{2}}, 0\\\\\n\t\t\\because \\frac{\\partial^{2} V}{\\partial x^{2}}&=-a+3 b x^{2}\\\\\n\t\t\\text { At } x=0, \\frac{\\partial^{2} V}{\\partial x^{2}}&=-a \\text { (Negative so it is unstable point) }\\\\\n\t\t\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=\\pm\\left(\\frac{a}{b}\\right)^{\\frac{1}{2}}}&=-a+3 b \\frac{a}{b}=2 a \\text { (Positive so it is stable point) }\\\\\n\t\t\\Rightarrow \\omega&=\\sqrt{\\frac{\\frac{\\partial^{2} V}{\\partial x^{2}}}{m}}=\\sqrt{\\frac{2 a}{m}}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(b)}\n\t\\end{answer}\n\t\t\\item A particle of mass $m$, kept in potential $V(x)=-\\frac{1}{2} k x^{2}+\\frac{1}{4} \\lambda x^{4}$ (where $k$ and $\\lambda$ are positive constants), undergoes small oscillations about an equilibrium point. The frequency of oscillations is\n\t\t{\\exyear{NET JUNE 2018}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $\\frac{1}{2 \\pi} \\sqrt{\\frac{2 \\lambda}{m}}$\n\t\t\\task[\\textbf{B.}]$\\frac{1}{2 \\pi} \\sqrt{\\frac{k}{m}}$\n\t\t\\task[\\textbf{C.}]$\\frac{1}{2 \\pi} \\sqrt{\\frac{2 k}{m}}$\n\t\t\\task[\\textbf{D.}]$\\frac{1}{2 \\pi} \\sqrt{\\frac{\\lambda}{m}}$\n\t\\end{tasks}\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\tV&=-\\frac{1}{2} k x^{2}+\\frac{1}{4} \\lambda x^{4}\\\\\n\t\t\\frac{d V}{d x}&=0 \\quad-k x+\\lambda x^{3}=0\\\\\n\t\tx=0, \\quad x^{2}&=\\frac{k}{\\lambda} \\Rightarrow x=x_{0}=\\sqrt{\\frac{k}{\\lambda}}\\\\\n\t\t\\frac{d^{2} V}{d x^{2}}&=-k \\quad \\text { at } x=0 \\quad \\text { so } x=0 \\text { is unstable part }\\\\\n\t\t\\frac{d^{2} V}{d x^{2}}&=2 k \\text { at } x_{0}=\\sqrt{\\frac{k}{\\lambda}} \\text { so } x_{0}=\\sqrt{\\frac{k}{x}} \\text { is stable equation point }\\\\\n\t\t\\omega&=\\sqrt{\\frac{\\left.\\frac{d^{2} V}{d x^{2}}\\right|_{x=x_{0}}}{m}}=\\sqrt{\\frac{2 k}{m}} \\quad f=\\frac{1}{2 \\pi} \\sqrt{\\frac{2 k}{m}}\n\t\t\\end{align*}\n\t\tThe correct option is \\textbf{(c)}\n\t\\end{answer}\n\\end{enumerate}\n\\newpage\n\\begin{abox}\nPractice set 2 solutions\n\\end{abox}\n\\begin{enumerate}\n  \\item A particle is placed in a region with the potential $V(x)=\\frac{1}{2} k x^{2}-\\frac{\\lambda}{3} x^{3}$, where $k, \\lambda>0$.\n  Then,\n\t{\\exyear{GATE 2010}}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] $x=0$ and $x=\\frac{k}{\\lambda}$ are points of stable equilibrium\n\t\\task[\\textbf{B.}]$x=0$ is a point of stable equilibrium and $x=\\frac{k}{\\lambda}$ is a point of unstable equilibrium\n\t\\task[\\textbf{C.}]$x=0$ and $x=\\frac{k}{\\lambda}$ are points of unstable equilibrium\n\t\\task[\\textbf{D.}]There are no points of stable or unstable equilibrium\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nV&=\\frac{1}{2} k x^{2}-\\frac{\\lambda x^{3}}{3} \\Rightarrow \\frac{\\partial V}{\\partial x}=k x-\\lambda x^{2}=0 \\Rightarrow x=0, x=\\frac{k}{\\lambda}\\\\\n&=\\frac{\\partial^{2} V}{\\partial x^{2}}=k-2 \\lambda x\\\\\nA t x&=0, \\frac{\\partial^{2} V}{\\partial x^{2}}=+v e(\\text { Stable })\\\\\n\\text { at } x&=\\frac{k}{\\lambda}, \\frac{\\partial^{2} V}{\\partial x^{2}}=-v e \\text { (unstable) }\n\\end{align*}\nThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\t\\item Two bodies of mass $m$ and $2 m$ are connected by a spring constant $k$. The frequency of the normal mode is\n\t{\\exyear{GATE 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\sqrt{3 k / 2 m}$\n\t\\task[\\textbf{B.}]$\\sqrt{k / m}$\n\t\\task[\\textbf{C.}] $\\sqrt{2 k / 3 m}$\n\t\\task[\\textbf{D.}]$\\sqrt{k / 2 m}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\\omega=\\sqrt{\\frac{k}{\\mu}}&=\\sqrt{\\frac{k}{\\frac{2 m}{3}}}=\\sqrt{\\frac{3 k}{2 m}}\\\\\n\\text { where reduce mass } \\mu&=\\frac{2 m m}{2 m+m}=\\frac{2 m}{3} \\text {. }\n\t\\end{align*}\nThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item A particle of unit mass moves along the $x$-axis under the influence of a potential, $V(x)=x(x-2)^{2}$. The particle is found to be in stable equilibrium at the point $x=2$. The time period of oscillation of the particle is\n{\t\\exyear{GATE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\pi}{2}$\n\t\\task[\\textbf{B.}]$\\pi$\n\t\\task[\\textbf{C.}]$\\frac{3 \\pi}{2}$\n\t\\task[\\textbf{D.}]$2 \\pi$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nV(x)&=x(x-2)^{2} \\Rightarrow \\frac{\\partial V}{\\partial x}=(x-2)^{2}+2 x(x-2)=0 \\Rightarrow x=2, x=\\frac{2}{3}\\\\\n\\frac{\\partial^{2} V}{\\partial x^{2}}&=2(x-2)+2(x-2)+\\left.2 x \\Rightarrow \\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=2}=2 \\times 2=4\\\\\n\\omega&=\\sqrt{\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=2}} \\Rightarrow \\omega=\\frac{2 \\pi}{T}=2 \\Rightarrow T=\\pi\n\\end{align*}\nThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\t\\item Consider two small blocks, each of mass $M$, attached to two identical springs. One of the springs is attached to the wall, as shown in the figure. The spring constant of each spring is $k$. The masses slide along the surface and the friction is negligible. The frequency of one of the normal modes of the system is,\n\t{\\exyear{GATE 2013}}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{GATE1}\n\t\\end{figure}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\sqrt{\\frac{3+\\sqrt{2}}{2}} \\sqrt{\\frac{k}{M}}$\n\t\\task[\\textbf{B.}]$\\sqrt{\\frac{3+\\sqrt{3}}{2} \\sqrt{\\frac{k}{M}}}$\n\t\\task[\\textbf{C.}]$\\sqrt{\\frac{3+\\sqrt{5}}{2}} \\sqrt{\\frac{k}{M}}$\n\t\\task[\\textbf{D.}]$\\sqrt{\\frac{3+\\sqrt{6}}{2}} \\sqrt{\\frac{k}{M}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\tT&=\\frac{1}{2} m \\dot{x}_{1}^{2}+\\frac{1}{2} m \\dot{x}_{2}^{2}\\\\\n\t\tV&=\\frac{1}{2} k x_{1}^{2}+\\frac{1}{2} k\\left(x_{2}-x_{1}\\right)^{2}\\\\\n\t\t&=\\frac{1}{2} k x_{1}^{2}+\\frac{1}{2} k\\left(x_{2}^{2}+x_{1}^{2}-2 x_{2} x_{1}\\right)=\\frac{1}{2} k\\left(2 x_{1}^{2}+x_{2}^{2}-2 x_{2} x_{1}\\right)\\\\\n\t\tT&=\\left(\\begin{array}{cc}\n\t\tm & 0 \\\\\n\t\t0 & m\n\t\t\\end{array}\\right) ; \\quad V=\\left(\\begin{array}{cc}\n\t\t2 k & -k \\\\\n\t\t-k & k\n\t\t\\end{array}\\right)\\\\\n\t\t\\left|\\begin{array}{cc}\n\t\t2 k-\\omega^{2} m & -k \\\\\n\t\t-k & k-\\omega^{2} m\n\t\t\\end{array}\\right|&=0 \\Rightarrow\\left(2 k-\\omega^{2} m\\right)\\left(k-\\omega^{2} m\\right)-k^{2}=0 \\Rightarrow \\omega=\\sqrt{\\frac{3+\\sqrt{5}}{2}} \\sqrt{\\frac{k}{m}}\n\t\\end{align*}\nTHe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item Two masses $m$ and $3 m$ are attached to the two ends of a massless spring with force constant $K$. If $m=100 \\mathrm{~g}$ and $K=0.3 \\mathrm{~N} / \\mathrm{m}$, then the natural angular frequency of oscillation is $H z$.\n\t{\\exyear{GATE 2014}}\n\n\\begin{answer}\n\t\\begin{align*}\n\tf&=\\frac{1}{2 \\pi} \\sqrt{\\frac{k}{\\mu}}\\\\\n\t\\mu&=\\frac{m_{1} \\cdot m_{2}}{m_{1}+m_{2}}=\\frac{3 m \\cdot m}{4 m}=\\frac{3 m}{4}\\\\\n\t\\omega&=\\sqrt{\\frac{4 k}{3 m}}=2 \\Rightarrow f=0.318 \\mathrm{~Hz}\n\t\\end{align*}\n\\end{answer}\n\n\t\\item A particle of mass $m$ is in a potential given by\n\t$$\n\tV(r)=-\\frac{a}{r}+\\frac{a r_{0}^{2}}{3 r^{3}}\n\t$$\n\twhere $a$ and $r_{0}$ are positive constants. When disturbed slightly from its stable equilibrium position it undergoes a simple harmonic oscillation. The time period of oscillation is\n\t{\\exyear{GATE 2014}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $2 \\pi \\sqrt{\\frac{m r_{0}^{3}}{2 a}}$\n\t\\task[\\textbf{B.}]$2 \\pi \\sqrt{\\frac{m r_{0}{ }^{3}}{a}}$\n\t\\task[\\textbf{C.}]$2 \\pi \\sqrt{\\frac{2 m r_{0}^{3}}{a}}$\n\t\\task[\\textbf{D.}]$4 \\pi \\sqrt{\\frac{m r_{0}^{3}}{a}}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nV(r)&=-\\frac{a}{r}+\\frac{a r_{0}^{2}}{3 r^{3}}\\\\\n\\intertext{For equilibrium}\n\\frac{\\partial V}{\\partial r}&=\\frac{a}{r^{2}}-\\frac{3 a r_{0}^{2}}{3 r^{4}}=0, \\quad r=\\pm r_{0}\\\\\n\\frac{\\partial^{2} V}{\\partial r^{2}}&=-\\frac{2 a}{r^{3}}+\\left.\\frac{4 a r_{0}^{2}}{r^{5}}\\right|_{r_{0}}=-\\frac{2 a}{r_{0}^{3}}+\\frac{4 a r_{0}^{2}}{r_{0}^{5}}=\\frac{2 a}{r_{0}^{3}}\\\\\n\\omega&=\\sqrt{\\frac{\\left.\\frac{\\partial^{2} V}{\\partial r^{2}}\\right|_{r_{0}}}{m}} \\Rightarrow T=2 \\pi \\sqrt{\\frac{m r_{0}^{3}}{2 a}}\n\\end{align*}\nThe correct option id \\textbf{(a)}\n\\end{answer}\n\t\\item Two identical masses of $10 \\mathrm{gm}$ each are connected by a massless spring of spring constant $1 \\mathrm{~N} / \\mathrm{m}$. The non-zero angular eigenfrequency of the system is. $. \\mathrm{rad} / \\mathrm{s} .$ (up to two decimal places)\n\t{\\exyear{GATE 2017}}\n\\begin{answer}\n\\begin{align*}\n\\omega=\\sqrt{\\frac{k}{\\mu}}, \\quad \\text { where } \\mu=\\frac{m}{2}=\\frac{10}{2 \\times 1000}=\\frac{1}{200} \\text { and } k=1 N / m, \\quad \\omega=14.14\n\\end{align*}\n\\end{answer}\n\t\\item In the context of small oscillations, which one of the following does NOT apply to the normal coordinates?\n{\t\\exyear{GATE 2018}}\n\\begin{tasks}(1)\n\t\\task[\\textbf{A.}] Each normal coordinate has an eigen-frequency associated with it\n\t\\task[\\textbf{B.}]The normal coordinates are orthogonal to one another\n\t\\task[\\textbf{C.}]The normal coordinates are all independent\n\t\\task[\\textbf{D.}]The potential energy of the system is a sum of squares of the normal coordinates with constant coefficients\n\\end{tasks}\n\\begin{answer}\n Normal co-ordinate must be independent. It is not necessary that it should orthogonal.\\\\\n The correct option is \\textbf{(b)}\t\n\\end{answer}\n\n\\end{enumerate}", "meta": {"hexsha": "f09255d032e31f33fe223edc2a4c6c3767113bd6", "size": 14356, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Classical Mechanics  -CSIR/chapter/small oscillations solutions.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Classical Mechanics  -CSIR/chapter/small oscillations solutions.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Classical Mechanics  -CSIR/chapter/small oscillations solutions.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.859922179, "max_line_length": 329, "alphanum_fraction": 0.6202284759, "num_tokens": 5781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980404, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.41753366800294595}}
{"text": "\\documentclass[class=report, float=false, crop=false]{standalone}\n\\usepackage[subpreambles=true]{standalone}\n\n\\input{preamble}\n\n\\graphicspath{{figures/images/}}\n\n% \\begin{cbunit}\n\n\\begin{document}\n\n\\chapter{Renormalisation group theory}\n\\label{appendix:rg}\n\nThe renormalisation group (RG) theory, attributed to Kenneth G. Wilson \\cite{wilson1971renormalization,wilson1974renormalization,wilson1975renormalization}, relies on coarse-graining arguments near critical points and gives a genuine way of thinking about critical phenomena and provides a theoretical motivation for scaling assumptions. Moreover, this theory allows one to calculate critical exponent although being particularly technical.\\\\\n\nIn this appendix, we mean to present the renormalisation group theory and how it leads to the scaling hypothesis we made, focusing on its implications on numerical simulations scaling. All demonstrations and discussions are based on \\cite{goldenfeld1992lectures} and unpublished documents by Peter Olsson.\n\n\\section{Coarse-graining argument}\n\n\\subsection{Block spins}\n\\label{block_spins}\n\nWe can easily illustrate the RG theory with the Ising model for spins with nearest neighbours interactions. In this model, a system of spins displays a ferromagnetic transition at the temperature $T=T_C$, where the correlation length diverges.\\\\\n\nConsider a system $\\Omega$ of spins on a $d$-dimensional hypercubic lattice, with spacing $a$. We have that the spins are correlated on lengths scales of order $\\xi$, the basic idea is thus to consider that spins on a length scale $la$, with $l$ satisfying\n\\begin{align*}\na \\ll la \\ll \\xi\n\\end{align*}\nact as a single spin, which we will call a \\textit{block spin}.\\\\\n\nWe can then make the assumptions that block spins interact with their nearest block spin neighbours, as do the single spins, with coupling constants -- between spins, and between spins and external field -- somewhat different. Our block spin system is then described by the same Hamiltonian than the single spin spin. However, the spacing between block spins is $l$ times larger than the spacing between single spins, leading to the correlation length\n\\begin{align*}\n\\xi_l = \\frac{\\xi}{l}\n\\end{align*}\nsmaller than the correlation length of the original system. This tells us that the latter system is further from criticality than the former, leading to a reduced temperature\n\\begin{align*}\nt_l \\equiv 1 - \\frac{T}{T_{C,l}} = s(l) \\underbrace{\\left(1 - \\frac{T}{T_C}\\right)}_{t} < t\n\\end{align*}\nwith $s$ a function to determine.\\\\\n\nSince two consecutive scale changes with the factors $l_1$ and $l_2$ are equivalent to a single scale change of factor $l_1l_2$, we have that\n\\begin{align*}\ns(l_1l_2) = s(l_1)s(l_2)\n\\end{align*}\nwhich is satisfied by\n\\begin{align*}\ns(l) = l^y\n\\end{align*}\nfor any $y$, hence the scaling assumptions.\\\\\n\nFurthermore, we realise that the critical temperature, characterising a state where the correlation length is infinite, is a fixed point of the scaling transformation.\n\n\\subsection{Renormalisation group transformations}\n\nWe need to formalise the scaling transformation we have introduced.\\\\\n\nConsider a system $\\Omega$ described by the general Hamiltonian\n\\begin{equation}\n\\mathcal{H} \\equiv -\\beta H_{\\Omega} = \\sum_n K_n \\Theta_n\\{S\\}\n\\end{equation}\nwhere $\\beta = 1/kT$ with $k$ the Boltzmann constant and $T$ the temperature, $K_n$ are the coupling constants, and $\\Theta\\{S\\}$ the local operators on the degrees of freedom $\\{S\\}$.\\\\\n\nWe introduce $\\forall l>1$ the \\textit{renormalisation group transformation} $R_l$ which acts on the coupling constants $[K] \\equiv (K_n)_n$\n\\begin{equation}\nR_l[K] \\equiv [K']\n\\end{equation}\nand which is most often complicated and non-linear. These transformations verify\n\\begin{equation}\n\\forall l_1, l_2 > 1,~ R_{l_1l_2}[K]=R_{l_2}\\cdot R_{l_1}[K]\n\\label{semi_group}\n\\end{equation}\nand do not admit inverses since $l$ has to be greater or equal to $1$, therefore RG transformations form a semi-group.\\\\\n\nRG transformations are coarse-graining transformations which reduce the number $N$ of degrees of freedom by a factor $l^{-d}$ to $N'=Nl^{-d}$, where $d$ is the dimension of the system. Therefore, the degrees of freedom $\\{S_i\\}_{1\\ldots N}$ and the Hamiltonian $\\mathcal{H}$ are replaced by \\textit{block variables} $\\{S'_I\\}_{1\\ldots N'}$ and an effective Hamiltonian $\\mathcal{H'}$ for these new degrees of freedom respectively.\\\\\n\nWe introduce a \\textit{projection operator} $P(S_i,S'_I)$ which satisfies\n\\begin{equation}\ne^{\\mathcal{H}'\\{[K'],S'_I\\}} = \\text{Tr}_{\\{S_i\\}}P(S_i,S'_I)e^{\\mathcal{H}\\{[K],S_i\\}}\n\\end{equation}\nwhere $\\text{Tr}_{\\{S_i\\}}$ denotes the sum over the degrees of freedom $\\{S\\}$, and must fulfil the following requirements\n\\begin{itemize}\n\\item[(i)] $P(S_i,S'_I) \\ge 0$,\n\\item[(ii)] $P(S_i,S'_I)$ reflects the symmetries of the system,\n\\item[(iii)] $\\sum_{\\{S'_I\\}} P(S_i,S'_I) = 1$.\n\\end{itemize}\nIn the context of part \\ref{block_spins}, the projection operator $P$ is the function that associates an up or down spin to a block of spins.\\\\\n\n% We can notice that RG transformations then leave the partition function, and therefore the free energy, of the system unchanged\n% \\begin{align*}\n% Z[K'] &\\equiv \\text{Tr}_{\\{S'_I\\}}e^{\\mathcal{H}'\\{[K'],S'_I\\}}\\\\\n% &= \\text{Tr}_{\\{S'_I\\}}\\text{Tr}_{\\{S_I\\}}P(S_i,S'_I)e^{\\mathcal{H}\\{[K],S_i\\}}\\\\\n% &= \\text{Tr}_{\\{S_i\\}}e^{\\mathcal{H}\\{[K],S_i\\}}\\cdot1\\\\\n% &= Z[K]\n% \\end{align*}\n\n% We define the free energy $Z$\n% \\begin{equation}\n% Z[K]=\\text{Tr}_{\\{S\\}}e^{\\mathcal{H}\\{[K],S_i\\}}\n% \\end{equation}\n% and the function $g$\n% \\begin{equation}\n% g[K] \\equiv \\frac{1}{N}\\ln Z[K]\n% \\end{equation}\n% which is related to the free energy per degree of freedom.\\\\\n\n% Condition (iii) ensures that the partition function, and thus the free energy, remains unchanged\n% \\begin{align*}\n% Z[K'] &\\equiv \\text{Tr}_{\\{S'_I\\}}e^{\\mathcal{H}'\\{[K'],S'_I\\}}\\\\\n% &= \\text{Tr}_{\\{S'_I\\}}\\text{Tr}_{\\{S_I\\}}P(S_i,S'_I)e^{\\mathcal{H}\\{[K],S_i\\}}\\\\\n% &= \\text{Tr}_{\\{S_i\\}}e^{\\mathcal{H}\\{[K],S_i\\}}\\cdot1\\\\\n% &= Z[K]\n% \\end{align*}\n% while the function $g$ is rescaled\n% \\begin{align*}\n% \\frac{1}{N}\\ln Z[K] &= \\frac{l^d}{l^dN}\\ln Z[K']\\\\\n% &= l^{-d} \\frac{1}{N'} \\ln Z[K']\n% \\end{align*}\n% \\textit{i.e.},\n% \\begin{equation}\n% g[K] = l^{-d}g[K']\n% \\end{equation}\n\nWe define the free energy $Z$\n\\begin{equation}\nZ[K]=\\text{Tr}_{\\{S\\}}e^{\\mathcal{H}\\{[K],S_i\\}}\n\\end{equation}\nand the free energy density $f$\n\\begin{equation}\nf[K] = \\frac{1}{L^d} Z[K]\n\\end{equation}\nwhere $L$ is the characteristic dimension of the system, which is the quotient of the free energy by the volume of the system.\\\\\n\nCondition (iii) ensures that the partition function, and thus the free energy, remains unchanged\n\\begin{align*}\nZ[K'] &\\equiv \\text{Tr}_{\\{S'_I\\}}e^{\\mathcal{H}'\\{[K'],S'_I\\}}\\\\\n&= \\text{Tr}_{\\{S'_I\\}}\\text{Tr}_{\\{S_I\\}}P(S_i,S'_I)e^{\\mathcal{H}\\{[K],S_i\\}}\\\\\n&= \\text{Tr}_{\\{S_i\\}}e^{\\mathcal{H}\\{[K],S_i\\}}\\cdot1\\\\\n&= Z[K]\n\\end{align*}\nwhile the free energy density $f$ is rescaled\n\\begin{align*}\n\\frac{1}{L^d}\\ln Z[K] &= \\frac{l^{-d}}{(L/l)^d}\\ln Z[K']\\\\\n&= l^{-d} \\frac{1}{L'} \\ln Z[K']\n\\end{align*}\n\\textit{i.e.},\n\\begin{equation}\nf[K] = l^{-d}f[K']\n\\label{free_energy_scaling}\n\\end{equation}\n\n\\section{Renormalisation group flows}\n\n\\subsection{Fixed points of the coupling constants space}\n\nAn infinite number of iterations of the RG transformations is required in order to eliminate all degrees of freedom of a thermodynamic system in the thermodynamic limit $N\\rightarrow+\\infty$. By doing so, singular behaviour may occur.\\\\\n\nFor any $l>1$, $R_l$ is a function from the coupling constants $[K]$ space to this same space, which we will denote $\\mathcal{K}$. We will call \\textit{renormalisation group flows} the trajectories in the coupling constants space which are obtained by iterating RG transformations. It is likely to find fixed points of the RG transformations in $\\mathcal{K}$, we will then call the \\textit{basin of attraction} of such a fixed point the set of points of $\\mathcal{K}$ from which an infinite number of iterations of RG transformations inevitably lead.\\\\\n\nWe have $\\forall l>1$ that the correlation length $\\xi$ transforms under the RG transformation $R_l$ as\n\\begin{equation}\n\\xi[K'] = \\xi[K]/l\n\\end{equation}\ntherefore, for a fixed point $[K^*]$\n\\begin{align*}\n\\xi[K*] = \\xi[K*]/l\n\\end{align*}\nwhich allows us to distinguishes two cases\n\\begin{itemize}\n\\item[(i)] $\\xi[K^*] = 0$, for which we will call $[K^*]$ a \\textit{\"trivial\" fixed point}, and\n\\item[(ii)] $\\xi[K^*] = +\\infty$, for which we will call $[K^*]$ a \\textit{critical fixed point}.\n\\end{itemize}\nWe can then notice that since $n$ iterations of $R_l$ transform the correlation length as\n\\begin{align*}\n\\xi[K] = l^n \\xi[K^{(n)}]\n\\end{align*}\nwe have that all points in the basin attraction of a critical fixed point $[K^*]$, which satisfy $\\xi[K^{(n)}] \\xrightarrow[n\\rightarrow+\\infty]{} \\xi[K^*] = +\\infty$, have infinite correlation length. This basin of attraction is called the \\textit{critical manifold}.\\\\\n\nWe have implicitly that the critical points were isolated, however this is not necessarily the case. In fact, fixed points are classified according to their codimension, but this does not affect the validity of our demonstration.\\\\\n\nWe note that it is also possible for RG flows to describe limit cycles or strange attractors, but in practice it is almost never the case. We will then neglect these possibilities from now on.\n\n\\subsection{Relevance of variables}\n\nWe are interested in the behaviour of RG flows in the vicinity of a critical fixed point $[K^*]$.\\\\\n\nConsider $[K]$ a point of $\\mathcal{K}$ close to $[K^*]$\n\\begin{align*}\n[K] = [K^*] + [\\delta K]\n\\end{align*}\nthen $\\forall l>1$, $[K]$ transforms under $R_l$ as $R_l[K]=[K']$ with\n\\begin{align*}\n[K']\\{[K^*]+[\\delta K]\\} &= \\underbrace{[K']\\{[K^*]\\}}_{[K^*]} + [\\delta K']\\\\\n\\text{\\textit{i.e.}, } [K']\\{[K^*]+[\\delta K]\\} &= [K^*] + \\underbrace{\\left(\\left.\\frac{\\partial K'_n}{\\partial K_m}\\right|_{K_m = K^*_m} \\right)_{n,m}}_{\\textstyle M^{(l)}} [\\delta K] + \\mathcal{O}\\left([\\delta K]^2\\right)\n\\end{align*}\naccording to Taylor's theorem, where $M^{(l)}$ is the linearised RG transformation in the vicinity of $[K^*]$ and is a real matrix.\\\\\n\nIn practice, $M^{(l)}$ is most often diagonalisable with real eigenvalues. For present purposes, we will assume for the rest of our presentation that it is symmetric without further notice. We advise the interested reader to read part 9.4.4 of \\cite{goldenfeld1992lectures} for corrections to be brought to our theory in the case of a non-symmetric linearised RG transformation.\\\\\n\nWe will denote the eigenvalues and eigenvectors of $M^{(l)}$ by $\\Lambda^{(\\sigma)}_l$ and $\\vec{e}^{\\hspace{1pt}(\\sigma)}$ respectively, where $(\\vec{e}^{\\hspace{1pt}(\\sigma)})_{\\sigma}$ is an orthonormal base of $\\mathcal{K}$ according to the spectral theorem. We can then infer from the semi-group property of equation \\ref{semi_group} that\n\\begin{align*}\n\\forall l,l' >1,~ M^{(l)}M^{(l')} &= M^{(ll')}\\\\\n\\Rightarrow \\forall \\sigma,~ \\Lambda^{(\\sigma)}_l\\Lambda^{(\\sigma)}_{l'} &= \\Lambda^{(\\sigma)}_{ll'}\n\\end{align*}\nwhich we can differentiate with respect to $l'$\n\\begin{align*}\n\\frac{d}{dl'}\\left(\\Lambda^{(\\sigma)}_l\\Lambda^{(\\sigma)}_{l'}\\right) &= \\frac{d}{dl'}\\Lambda^{(\\sigma)}_{ll'}\\\\\n\\Leftrightarrow \\cancelto{0}{\\frac{d\\Lambda^{(\\sigma)}_l}{dl'}}\\Lambda^{(\\sigma)}_{l'} + \\Lambda^{(\\sigma)}_l\\frac{d\\Lambda^{(\\sigma)}_{l'}}{dl'} &= \\frac{d}{dl'} \\Lambda^{(\\sigma)}_{ll'}\\\\\n\\Rightarrow \\Lambda^{(\\sigma)}_l\\left.\\frac{d\\Lambda^{(\\sigma)}_{l'}}{dl'}\\right|_{l'=1} &= \\frac{d\\Lambda^{(\\sigma)}_l}{dl}\n\\end{align*}\n% i really have doubts concerning the resolution of this equation... that's how the book did though\nand therefore write\n\\begin{equation}\n\\Lambda^{(\\sigma)}_l = l^{y_{\\sigma}}\n\\label{eigenvalues_scaling}\n\\end{equation}\nwhere $y_{\\sigma}$ is independent of l.\\\\\n\nFinally, we have that\n\\begin{equation}\n\\begin{aligned}\n[\\delta K'] &= M^{(l)} [\\delta K]\\\\\n&= \\sum_{\\sigma} \\Lambda^{(\\sigma)}_l \\underbrace{\\left(\\vec{e}^{\\hspace{1pt}(\\sigma)}\\cdot[\\delta K]\\right)}_{a^{(\\sigma)}} \\vec{e}^{\\hspace{1pt}(\\sigma)}\\\\\n&= \\sum_{\\sigma} \\underbrace{l^{y_{\\sigma}}a^{(\\sigma)}}_{\\textstyle a^{(\\sigma)}\\prime} \\vec{e}^{\\hspace{1pt}(\\sigma)}\n\\end{aligned}\n\\end{equation}\nfor which we will distinguish 3 cases:\n\\begin{itemize}\n\\item[(i)] $y_{\\sigma} > 0$, which implies that $a^{(\\sigma)}\\prime$ grows as $l$ increases, and for which we will describe the corresponding eigenvalue/direction/eigenvector as \\textit{relevant},\n\\item[(ii)] $y_{\\sigma} < 0$, which implies that $a^{(\\sigma)}\\prime$ shrinks as $l$ increases, and for which we will describe the corresponding eigenvalue/direction/eigenvector as \\textit{irrelevant},\n\\item[(iii)] $y_{\\sigma} = 0$, which implies that $a^{(\\sigma)}\\prime$ does not change as $l$ increases, and for which we will describe the corresponding eigenvalue/direction/eigenvector as \\textit{marginal}.\n\\end{itemize}\nTherefore, if we start at $[K]$ near $[K^*]$, but not in the critical manifold then the flow in directions out of the critical manifold in the vicinity of $[K^*]$ are associated with relevant eigenvalues. The irrelevant eigenvalues correspond to directions into the fixed point, and their corresponding eigenvectors span the critical manifold.\n\n\\subsection{Relation between RG flows and the phase diagram}\n\nStarting from any point in $\\mathcal{K}$, which is equivalent to the phase space, we can determine to which fixed point an infinite number of iterations of RG transformations leads to. The state of the system described by this fixed point then represents the phase at the original point.\\\\\n\nRG theory therefore enables one to investigate the whole phase diagram. We will however focus on critical behaviours and advise the interested reader to read part 9.3.3 of \\cite{goldenfeld1992lectures} about the global properties of RG flows and the different types of fixed points and their significance.\\\\\n\nWe have that points that are slightly off the critical manifolds are repelled from it in the relevant directions. Therefore, it is the same eigenvalues that drive all slightly off-critical systems away from the critical fixed point: this is the origin of universality. Furthermore, we have that the critical behaviour is not determined by the initial values of the coupling constants but only by the flow behaviour.\n\n\\section{Critical scaling}\n\n\\subsection{Scaling behaviour of the free energy density and its derivatives}\n\nWe have that the linearised RG transformation $R_l$ close to the critical fixed point $[K^*]$, $M^{(l)}$, is diagonal in the orthonormal base $(\\vec{e}^{\\hspace{1pt}(\\sigma)})_{\\sigma}$ of $\\mathcal{K}$. We want to investigate the behaviour of the free energy density $f$ and its derivatives close to this critical fixed point, we will then denote $[K^*]\\equiv \\sum_{\\sigma} K^*_{\\sigma}\\vec{e}^{\\hspace{1pt}(\\sigma)}$ and introduce $\\tilde{f}$ such that\n\\begin{equation}\n\\begin{aligned}\nf[K]=f(K_0,\\ldots,K_m)&\\equiv\\tilde{f}(\\tilde{K_0},\\ldots,\\tilde{K_m})=\\tilde{f}[\\tilde{K}]\\\\\n\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\tilde{K_{\\sigma}} &= \\begin{cases} \\frac{K_{\\sigma}-K_{\\sigma}^*}{K_{\\sigma}^*} &\\text{ if } K_{\\sigma}^* \\neq 0 \\\\ K_{\\sigma} &\\text{ if } K_{\\sigma}^* = 0 \\end{cases}\n\\end{aligned}\n\\end{equation}\nand which verifies the following property\n\\begin{align*}\n\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] = \\begin{cases} \\frac{1}{K_{\\sigma}^*} \\frac{\\partial}{\\partial \\tilde{K}_{\\sigma}} \\tilde{f}[\\tilde{K}] &\\text{ if } K_{\\sigma}^* \\neq 0 \\\\ \\frac{\\partial}{\\partial K_{\\sigma}} \\tilde{f}[\\tilde{K}] &\\text{ if } K_{\\sigma}^* = 0 \\end{cases}\n\\end{align*}\nwhich implies\n\\begin{equation}\n\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] \\propto \\frac{\\partial}{\\partial \\tilde{K}_{\\sigma}} \\tilde{f}[\\tilde{K}]\n\\end{equation}\nthis property being also easily demonstrated for cross-derivatives and higher order derivatives.\\\\\n\nAccording to equations \\ref{free_energy_scaling} and \\ref{eigenvalues_scaling}, the free energy density transforms under $n$ iterations of the RG transformation $R_l$ as\n\\begin{equation}\nf[K] = l^{-nd} f[K'] = l^{-nd} \\tilde{f}[\\tilde{K}'] = l^{-nd} \\tilde{f}(l^{ny_0}\\tilde{K}_0,\\ldots,l^{ny_m}\\tilde{K}_m)\n\\end{equation}\nBesides that it has to be greater or equal to $1$, there is no restriction to the values $l$ can take, we then introduce $b$ such that\n\\begin{equation}\nl^n = \\left(\\frac{b}{\\tilde{K}_0}\\right)^{1/y_0} \\geq 1\n\\label{choice_of_l}\n\\end{equation}\ntherefore we have the free energy density and its derivatives\n\\begin{equation}\n\\begin{aligned}\nf[K] &= \\left(\\frac{\\tilde{K}_0}{b}\\right)^{d/y_0}\\tilde{f}\\left(b,\\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_1/y_0}\\tilde{K}_1,\\ldots,\\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_m/y_0}\\tilde{K}_m\\right)\\\\\n\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] &\\propto \\left(\\frac{\\tilde{K}_0}{b}\\right)^{(d-y_{\\sigma})/y_0}\\frac{\\partial}{\\partial K_{\\sigma}}\\tilde{f}\\left(b,\\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_1/y_0}\\tilde{K}_1,\\ldots,\\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_m/y_0}\\tilde{K}_m\\right)\n\\label{free_energy_der_scaling}\n\\end{aligned}\n\\end{equation}\nfor which we will distinguish 2 cases:\n\\begin{itemize}\n\\item[(i)] $\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\vec{e}^{\\hspace{1pt}(\\sigma)}$ is a relevant eigenvector, then if we take $\\tilde{K}_{\\sigma}=0,~\\forall \\sigma \\in \\llbracket1,m\\rrbracket$, we can rewrite equation \\ref{free_energy_der_scaling} as\n\\begin{equation}\n\\begin{aligned}\n\\begin{cases} &f[K] = \\left(\\frac{\\tilde{K}_0}{b}\\right)^{d/y_0}\\tilde{f}\\left(b,0,\\ldots,0\\right) \\\\\n&\\forall \\sigma \\in \\llbracket0,m\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] \\propto \\left(\\frac{\\tilde{K}_0}{b}\\right)^{(d-y_{\\sigma})/y_0}\\frac{\\partial}{\\partial K_{\\sigma}}\\tilde{f}\\left(b,0,\\ldots,0\\right) \\end{cases} \\Rightarrow\\begin{cases} f[K] &\\isEquivTo{\\tilde{K}_0\\rightarrow0} \\tilde{K}_0^{c_0} \\\\ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] &\\isEquivTo{\\tilde{K}_0\\rightarrow0} \\tilde{K}_0^{c_{0,\\sigma}} \\end{cases}\n\\end{aligned}\n\\label{critical_exponents_RG}\n\\end{equation}\nwhere $c_0$ and $c_{0,\\sigma}$ are constants, hence the power-law scaling of the thermodynamic constants close to criticality.\\\\\n\nTherefore, RG theory gives a theoretical explanation of the power-law scaling at criticality, thus supporting our scaling assumptions, and furthermore provides a technique to calculate the corresponding critical exponents. However, as stated in the introduction to this appendix, this calculation remains particularly technical, \"where the renormalization group approach has been successful a lot of ingenuity has been required: one cannot write a renormalization group cookbook\" \\cite{wilson1975renormalization}. We advise the interested reader to read part 9.6 of \\cite{goldenfeld1992lectures} on the application of RG theory to the 2D Ising model.\\\\\n\n\\item[(ii)] $\\exists~ \\sigma \\in \\llbracket1,m-1\\rrbracket,~ \\vec{e}^{\\hspace{1pt}(0)},\\ldots,\\vec{e}^{\\hspace{1pt}(p-1)}$ are revelant eigenvectors -- which implies $y_0,\\ldots,y_{p-1}>0$ -- and $\\vec{e}^{\\hspace{1pt}(p)},\\ldots,\\vec{e}^{\\hspace{1pt}(m)}$ are irrelevant eigenvectors -- which implies $y_p,\\ldots,y_m<0$ --, then we can notice that in equation \\ref{free_energy_der_scaling}\n\\begin{align*}\n\\forall \\sigma \\in \\llbracket p,m\\rrbracket,~ \\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_{\\sigma}/y_0}\\tilde{K}_{\\sigma} \\xrightarrow[\\tilde{K}_0\\rightarrow0]{} 0\n\\end{align*}\ntherefore if $\\tilde{f}$ is analytic in the limit of the vanishing coupling constants in the irrelevant directions, then the results of equation \\ref{critical_exponents_RG} still hold. However, this is often not the case. When $\\tilde{f}$ is singular in the limit that a particular irrelevant variable vanishes, the irrelevant variable is termed a \\textit{dangerous irrelevant variable}.\\\\\n\\end{itemize}\n\nWe want to draw attention to the fact that in the case of the free energy density depending solely on two relevant variables $K_0$ and $K_1$, or on a relevant variable $K_0$ and a non-dangerous irrelevant variable $K_1$, we have close to criticality\n\\begin{equation}\nf[K] = \\left(\\frac{\\tilde{K}_0}{b}\\right)^{d/y_0}\\tilde{f}\\left(b,\\left(\\frac{b}{\\tilde{K}_0}\\right)^{y_1/y_0}\\tilde{K}_1\\right) \\equiv \\tilde{K}_0^{d/y_0}\\tilde{f}_1\\left(\\tilde{K}_0^{-y_1/y_0}\\tilde{K}_1\\right)\n\\label{fitting_function}\n\\end{equation}\nwith a similar result for the derivatives of the free energy density, therefore in the context of numerical simulations of a system close to criticality with two relevant variables not equal to their critical values, it is still possible to determine from the data the fitting function $\\tilde{f}_1$ and then the critical exponent.\\\\\n\nIn the case of $K_1$ being a relevant variable, we will call $\\Delta \\equiv y_1/y_0$ the \\textit{crossover scaling critical exponent} and $z \\equiv \\tilde{K}_1/\\tilde{K}_O^{\\Delta}$ the \\textit{crossover scaling variable} \\cite{PRL99.178001}. What happens if $z$ is non-neglible is that this variable is able to drive the system from the neighbourhood of one fixed point to that of another. Therefore, we may not observe the correct assymptotic behaviour when neglecting the term associated with $K_1$, hence the importance of this correction.\\\\\n\nFurthermore, what has been eluded in our demonstration is that to verify equation \\ref{choice_of_l}, $b$ has to be of the same sign as $\\tilde{K}_0$, therefore in equation \\ref{critical_exponents_RG} the value and most importantly the sign of $\\tilde{f}(b,0,\\ldots,0)$ and its derivatives, and thus the sign of the asymptotic approximation, may change depending on the sign of $\\tilde{K}_0$. What is most often observed is a scaling behaviour at criticality of the type\n\\begin{equation}\n\\begin{aligned}\nf[K] &\\operatorname*{~=~}_{\\tilde{K}_0\\rightarrow0} A^{(0)}_{\\pm} |\\tilde{K}_O|^{c_0} + \\smallO{|\\tilde{K}_O|^{c_0}}\\\\\n\\frac{\\partial}{\\partial K_{\\sigma}}f[K] &\\operatorname*{~=~}_{\\tilde{K}_0\\rightarrow0} A^{(0,\\sigma)}_{\\pm} |\\tilde{K}_O|^{c_{0,\\sigma}} + \\smallO{|\\tilde{K}_O|^{c_{0,\\sigma}}}\n\\end{aligned}\n\\label{absolute_value_scaling}\n\\end{equation}\nwhere the values of $A^{(0)}_{\\pm}$ and $A^{(0,\\sigma)}_{\\pm}$ may change depending on the sign of $\\tilde{K}_0$.\n\n\\subsection{Corrections to scaling}\n\nConsider for a given Hamiltonian that the RG transformation $R_l$ close to the critical fixed point $[K^*]$ is diagonal in the orthonormal base $(\\vec{e}^{\\hspace{1pt}(0)},\\vec{e}^{\\hspace{1pt}(1)})$ with $\\vec{e}^{\\hspace{1pt}(0)}$ a relevant eigenvector and $\\vec{e}^{\\hspace{1pt}(1)}$ an irrelevant eigenvector. We then have, with the notation of equations \\ref{free_energy_der_scaling} and \\ref{fitting_function}, and in the framework of equation \\ref{absolute_value_scaling}, the following relation\n\\begin{equation}\n\\begin{aligned}\nf[K] &\\equiv \\left|\\tilde{K}_0\\right|^{d/y_0}\\tilde{f}_1^{\\pm}\\left(\\left|\\tilde{K}_0\\right|^{-y_1/y_0}\\tilde{K}_1\\right)\\\\\n\\forall \\sigma \\in \\llbracket0,1\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] &\\equiv \\left|\\tilde{K}_0\\right|^{(d-y_{\\sigma})/y_0}\\tilde{f}_{1,\\sigma}^{\\pm}\\left(\\left|\\tilde{K}_0\\right|^{-y_1/y_0}\\tilde{K}_1\\right)\n\\end{aligned}\n\\end{equation}\nIn practice, it is very difficult to access the asymptotic critical regime $\\tilde{K_0}\\rightarrow0$, therefore the irrelevant variable may not be negligible and corrections have to be brought to our scaling assumptions.\\\\\n\nA solution is to assume that $\\tilde{f}_1$ and/or $\\tilde{f}_{1,\\sigma}$ are analytic functions in the limit that their argument, which we will call $x$ for convenience, vanishes -- assumption which is valid if $\\tilde{K}_1$ is not a dangerous irrelevant variable. Therefore, we have a new assymptotic behaviour\n\\begin{equation}\n\\begin{aligned}\nf[K] &\\operatorname*{~=~}_{\\tilde{K}_0\\rightarrow0} \\left|\\tilde{K}_0\\right|^{d/y_0} \\left( A_1 + B_1 \\left|\\tilde{K}_0\\right|^{-y_1/y_0}\\tilde{K}_1 + \\mathcal{O}\\left(x^2\\right)\\right)\\\\\n\\forall \\sigma \\in \\llbracket0,1\\rrbracket,~ \\frac{\\partial}{\\partial K_{\\sigma}} f[K] &\\operatorname*{~=~}_{\\tilde{K}_0\\rightarrow0} \\left|\\tilde{K}_0\\right|^{(d-y_{\\sigma})/y_0} \\left( A_{1,\\sigma} + B_{1,\\sigma} \\left|\\tilde{K}_0\\right|^{-y_1/y_0}\\tilde{K}_1 + \\mathcal{O}\\left(x^2\\right)\\right)\n\\label{scaling_corrections}\n\\end{aligned}\n\\end{equation}\naccording to Taylor's theorem, where $A_1$, $B_1$, $A_{1,\\sigma}$ and $B_{1,\\sigma}$ are -- non-universal -- constants.\\\\\n\nAs expected, the leading behaviour as $\\tilde{K}_0\\rightarrow0$ is a power-law in $\\tilde{K}_0$. We may then distinguish 2 cases:\n\\begin{itemize}\n\\item[(i)] $|y_1|/y_0 > 1$, which implies that the correction becomes smaller as $\\tilde{K}_0\\rightarrow0$,\n\\item[(ii)] $|y_1|/y_0 < 1$, which implies that the correction may not be negligible for small but non-zero $\\tilde{K}_0$. This first order correction is actually singular, since it gives rise to a cusp \\cite{wiki:cusp} at $\\tilde{K}_0 = 0$. Such a correlation is referred as a \\textit{confluent singularity}.\n\\end{itemize}\n\n\\subsection{Finite-size scaling}\n\nNumerical simulations use finite systems of which we will denote $L$ the characteristic length. As the system approaches a critical fixed point, its correlation length $\\xi$ diverges, therefore when $L$ and $\\xi$ are comparable, the thermodynamic properties of the system can not be considered as being those of an infinite system anymore. What is observed is that the transition associated with the critical fixed point appears less sharp.\\\\\n\nTo address this issue, one has to include the characteristic length of the system -- or rather its inverse $1/L$ which vanishes as the system approaches the critical fixed point associated with an infinite system -- in the variables of the free energy density, which will then transform under $n$ iteration of the RG transformation $R_l$ as\n\\begin{equation}\nf[K] = l^{-nd} f[K'] = l^{-nd} \\tilde{f}[\\tilde{K}'] = l^{-nd} \\tilde{f}(l^{ny_0}\\tilde{K}_0,\\ldots,l^{ny_m}\\tilde{K}_m,l^nL^{-1})\n\\end{equation}\nA crossover scaling analysis, as described in the discussion of equation \\ref{fitting_function}, can then be performed.\n\n% \\input{references/biblio}\n\n\\end{document}\n\n% \\end{cbunit}", "meta": {"hexsha": "82d252b875e0a293c90459070de7d755d52a6eec", "size": 26336, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/appendices/app_rg.tex", "max_stars_repo_name": "yketa/Umea_2017_Notes", "max_stars_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/appendices/app_rg.tex", "max_issues_repo_name": "yketa/Umea_2017_Notes", "max_issues_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/appendices/app_rg.tex", "max_forks_repo_name": "yketa/Umea_2017_Notes", "max_forks_repo_head_hexsha": "3b0e564e9054383bd91ff46930afe5543e9845ca", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.7513812155, "max_line_length": 652, "alphanum_fraction": 0.7171172539, "num_tokens": 8391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4175336680029459}}
{"text": "%\n% CMPT 379: Principles of Compiler Design - A Course Overview\n% Section: Parsing Algorithms: Bottom-Up\n%\n% Author: Jeffrey Leung\n%\n\n\\section{Parsing Algorithms: Bottom-Up}\n\t\\label{sec:parsing-algorithms-bottom-up}\n\n\\subsection{Introduction}\n\t\\label{subsec:parsing-algorithms-bottom-up:introduction}\n\\begin{easylist}\n\n& \\textbf{Bottom-up parsing:} Reduction of a string of terminal symbols to the start symbol\n\t&& Simulates a reversed rightmost derivation (see \\textit{shift-reduce parsing})\n\n& \\textbf{LR(k) parsing:} Bottom-up parsing derivation which parses \\textbf{L}eft-to-right to create a \\textbf{R}ightmost derivation with $k$ (usually 1) tokens of lookahead\n\t&& Actions:\n\t\t&&& Shift ($f: u \\rightarrow a$)\n\t\t&&& Reduce ($f: \\textrm{ lookup production  } x \\rightarrow y_1 \\dotsc y_n$)\n\t\t&&& Accept\n\t\t&&& Error\n\n& \\textbf{Dotted rule:} Parser state consisting of a single production rule and a dot ($\\bullet$) where the parser currently is at\n\t&& Notation: $A \\rightarrow B \\bullet C$\n\t&& All symbols to the left of the dot have been read; all symbols to the right of the dot are predicted\n\t&& \\textbf{Configuration/itemset/state:} Set of dotted rules which are all possible productions given an in-progress parse\n\n\t\t&&& E.g. Given a set of production rules and a dotted rule, the resulting configuration set is given in table~\\ref{tab:config-set}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{Configuration Set Example}\n\t\\label{tab:config-set}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | l }\n\t\t\tProduction Rules\n\t\t\t& $T \\rightarrow F$ \\\\\n\t\t\t& $T \\rightarrow T*F$ \\\\\n\t\t\t& $F \\rightarrow id$ \\\\\n\t\t\t& $F \\rightarrow (T)$ \\\\\n\t\t\t\\hline\n\t\t\tDotted Rule\n\t\t\t& $T \\rightarrow T * \\bullet F$ \\\\\n\t\t\t\\hline\n\t\t\t\\hline\n\t\t\t$closure(T \\rightarrow T * \\bullet F)$\n\t\t\t& $T \\rightarrow T * \\bullet F$ \\\\\n\t\t\t(Configuration set)\n\t\t\t& $F \\rightarrow \\bullet (T)$ \\\\\n\t\t\t& $F \\rightarrow \\bullet id$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n& \\textbf{Action/Goto (parsing) table:} Set of states and transitions which provides a programmatic method to parse an input\n\t&& Notations:\n\t\t&&& $\\textrm{action}[s, a]; a \\in T$ where $T$ is the set of terminal states\n\t\t&&& $\\textrm{goto}[s, X]; X \\in N$ where $N$ is the set of non-terminal states\n\n\t&& Layout: See table~\\ref{tab:layout-action-table}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{Layout of an action/goto table}\n\t\\label{tab:layout-action-table}\n\t\\begin{center}\n\t\t\\begin{tabular}{ l | l l | l }\n\t\t\t\\textbf{State} & \\textbf{Actions} (Terminal symbols) & \\$ & \\textbf{Gotos} (Non-terminal symbols) \\\\\n\t\t\t\\hline\n\t\t\t\\textit{Number} & \\textit{Shift STATE or Reduce RULE} & & \\textit{Change to STATE}\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\t&& To create a parsing table, create the layout, then for each itemset/state:\n\t\t&&& If the state transitions to a new state upon symbol $X$, then:\n\t\t\t&&&& If $X$ is a terminal symbol, then write S$\\alpha$ (shift to state $\\alpha$) in the action\n\t\t\t&&&& If $X$ is a non-terminal symbol, then write $\\alpha$ (shift to state $\\alpha$) in the goto\n\t\t&&& If the state results in a reduction to non-terminal symbol $X$, then for each symbol in the $FOLLOW$ set of $X$, write R$\\beta$ (reduce by rule number $\\beta$) in the action\n\t\t&&& If the itemset has an epsilon ($\\epsilon$) rule for symbol $X$ (i.e. $X \\rightarrow \\epsilon$), then for each symbol in the $FOLLOW$ set of $X$, write R$\\beta$ (reduce by rule number $\\beta$) in the action\n\t\t&&& If multiple shifts or reduces are possible for a given input from a given state, then use a comma to separate the possibilities\n\t\t&&& If the itemset reaches the end of input, then in $\\$$, write $acc$ (acceptance) instead of reducing\n\t\t\t\n\n& \\textbf{Closure:} Function to create a configuration set given a dotted rule, where the configuration set consists of the given dotted rule, all dotted rules where the symbol $X$ after the bullet is the input of a production rule (i.e. $f: X \\rightarrow Y$), and all rules which recurse upon $Y_1$\n\t&& Mathematically: Given dotted rule $T \\rightarrow X_1 \\dotsc X_i \\bullet X_{i+1} \\dotsc X_n$, the configuration set consists of rule $T$ as well as all dotted rules $X_{i+1} \\rightarrow \\bullet Y_1 \\dotsc Y_m$\n\t&& Notation: $closure(A \\rightarrow B \\bullet C) = \\{\\}$\n\n& Example of a shift-reduce conflict: Rules $F \\rightarrow id \\bullet; F \\rightarrow id \\bullet T$\n& Example of a reduce-reduce conflict: Rules $F \\rightarrow id \\bullet; T \\rightarrow id \\bullet$\n\n& \\textbf{Successor:} Function on a configuration set and a successive symbol which removes non-matching rules in the configuration set and computes a new closure on the remaining dotted rules\n\t&& Notation: $successor(I, X) = \\{\\}$ where $I$ is a configuration set and $X$ is a successive symbol\n\t&& E.g. Given a set of production rules and a configuration set, an example successor function is given in table~\\ref{tab:successor-example}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{Successor Example}\n\t\\label{tab:successor-example}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | l }\n\t\t\tProduction Rules\n\t\t\t& $S' \\rightarrow T$ \\\\\n\t\t\t& $T \\rightarrow F$ \\\\\n\t\t\t& $T \\rightarrow T*F$ \\\\\n\t\t\t& $F \\rightarrow id$ \\\\\n\t\t\t& $F \\rightarrow (T)$ \\\\\n\t\t\t\\hline\n\t\t\tConfiguration set $I$\n\t\t\t& $S'\\rightarrow \\bullet T$ \\\\\n\t\t\t& $T \\rightarrow \\bullet F$ \\\\\n\t\t\t& $T \\rightarrow \\bullet T * F$ \\\\\n\t\t\t& $F \\rightarrow \\bullet id$ \\\\\n\t\t\t& $F \\rightarrow \\bullet (T)$ \\\\\n\t\t\t\\hline\n\t\t\t\\hline\n\t\t\t$successor(I, \\textrm{``(''})$\n\t\t\t& $F \\rightarrow (\\bullet T)$ \\\\\n\t\t\t(Configuration set)\n\t\t\t& $T \\rightarrow \\bullet F$ \\\\\n\t\t\t& $T \\rightarrow \\bullet T * F$ \\\\\n\t\t\t& $F \\rightarrow \\bullet id$ \\\\\n\t\t\t& $F \\rightarrow \\bullet (T)$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\t&& For an example diagram of a set of production rules and the states generated using the successor function, see figure~\\ref{fig:example-diagram-of-states}\n\n\\begin{figure}[!htb]\n\t\\caption{Example Diagram of States}\n\t\\label{fig:example-diagram-of-states}\n\t\\begin{center}\n\t\t\\includegraphics[width=\\textwidth]{lrk-states-diagram}\n\t\\end{center}\n\\end{figure}\n\n\t&& For an example diagram of a set of production rules (including epsilon rules) and the states generated using the successor function, see figure~\\ref{fig:example-diagram-of-states-epsilon}\n\n\\begin{figure}[!htb]\n\t\\caption{Example Diagram of States with Epsilon Rules}\n\t\\label{fig:example-diagram-of-states-epsilon}\n\t\\begin{center}\n\t\t\\includegraphics[width=\\textwidth]{lrk-states-epsilon-diagram}\n\t\\end{center}\n\\end{figure}\n\n& \\textbf{Viable prefix:} Set of states representing the stack of a shift-reduce parser where combining it with the remaining symbols is a valid state\n\t&& Notation: $\\gamma$ such that $\\gamma | \\omega$ is a valid state for some $\\omega$\n\n& Process of LR(k) parsing:\n\t&& Requires a set of production rules, an action/goto table, and an input string\n\t&& Begin with state $0$ on the stack.\n\t&& From the row number of the current state (given by the top of the stack) and the leftmost symbol in the input, continually take the given action in the action table, given by $\\textrm{action}[]$.\n\t\t&&& If the action is $S\\alpha$, then push state $\\alpha$ onto the stack and consume the leftmost symbol of the input.\n\t\t&&& If the action is $Rr$, then:\n\t\t\t&&&& Find the production rule numbered $r$, with $r: X \\rightarrow Y_1 \\dotsc Y_k$.\n\t\t\t&&&& Pop $k$ states from the stack.\n\t\t\t&&&& Take the state $Z$ at the top of the stack and push state $\\textrm{goto}[Z, X]$ onto the stack.\n\t\t&&& If the action is $\\textrm{ACCEPT}$, then complete the parsing.\n\t\t&&& If no action exists, then return $\\textrm{ERROR}$.\n\n\t&& Example: Given the production rules in figure~\\ref{tab:lrk-productions} and action/goto table in figure~\\ref{tab:lrk-ag-table}, the trace of the LR(0) parse is figure~\\ref{tab:lrk-trace}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{LR(k) Parsing Example: Production Rules}\n\t\\label{tab:lrk-productions}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | l }\n\t\t\t& Production Rules \\\\\n\t\t\t\\hline\n\t\t\t1 & $T \\rightarrow F$ \\\\\n\t\t\t2 & $T \\rightarrow T*F$ \\\\\n\t\t\t3 & $F \\rightarrow id$ \\\\\n\t\t\t4 & $F \\rightarrow (T)$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{LR(k) Parsing Example: Action/Goto Table}\n\t\\label{tab:lrk-ag-table}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | c | c | c | c | c || c | c }\n\t\t\t\\multirow{2}{*}{\\textbf{States}} & \\multicolumn{5}{ c || }{\\textbf{Actions}} & \\multicolumn{2}{c}{\\textbf{Gotos}} \\\\\n\t\t\t& * & ( & ) & id & \\$ & T & F \\\\\n\t\t\t\\hline\n\t\t\t0 & & S5 & & S8 & 2 & 1 \\\\\n\t\t\t1 & R1 & R1 & R1 & R1 & R1 & \\\\\n\t\t\t2 & S3 & & & & ACC & \\\\\n\t\t\t3 & & S5 & & S8 & & 4 \\\\\n\t\t\t4 & R2 & R2 & R2 & R2 & R2 & \\\\\n\t\t\t5 & & S5 & & S8 & & 6 & 1 \\\\\n\t\t\t6 & S3 & & S7 & & & \\\\\n\t\t\t7 & R4 & R4 & R4 & R4 & R4 & \\\\\n\t\t\t8 & R3 & R3 & R3 & R3 & R3 &\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{LR(k) Parsing Example: Trace}\n\t\\label{tab:lrk-trace}\n\t\\begin{center}\n\t\t\\begin{tabular}{ l | r | l }\n\t\t\tStack & Input & Action \\\\\n\t\t\t\\hline\n\t\t\t0 & (id)*id & Shift 5 \\\\\n\t\t\t0, 5 & id)*id & Shift 8 \\\\\n\t\t\t0, 5, 8 & )*id & Reduce using production rule 3: $F \\rightarrow id$ \\\\\n\t\t\t&& Pop 1 symbol from the stack (8) \\\\\n\t\t\t&& Push $goto[5, F] = 1$ onto the stack \\\\\n\t\t\t0, 5, 1 & )*id & R1: $T \\rightarrow F$ \\\\\n\t\t\t&& Pop 1 \\\\\n\t\t\t&& $goto[5, T] = 6$ \\\\\n\t\t\t0, 5, 6 & )*id & S7 \\\\\n\t\t\t0, 5, 6, 7 & *id & R4, $F \\rightarrow (T)$ \\\\\n\t\t\t&& Pop 7, 6, 5 \\\\\n\t\t\t&& $goto[0, T] = 1$ \\\\\n\t\t\t0, 1 & *id & R1: $T \\rightarrow F$ \\\\\n\t\t\t&& Pop 1 \\\\\n\t\t\t&& $goto[0, T] = 2$ \\\\\n\t\t\t0, 2 & *id & S3 \\\\\n\t\t\t0, 2, 3 & id & S8 \\\\\n\t\t\t0, 2, 3, 8 & \\$ & R3: $F \\rightarrow id$ \\\\\n\t\t\t&& Pop 8 \\\\\n\t\t\t&& $goto]3, F] = 4$ \\\\\n\t\t\t0, 2, 3, 4 & \\$ & R2: $T \\rightarrow T*F$ \\\\\n\t\t\t&& Pop 4, 3, 2 \\\\\n\t\t\t&& $goto[0, T] = 2$ \\\\\n\t\t\t0, 2 & \\$ & ACCEPT\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\subsection{LR(0) Parsing}\n\t\\label{subsec:parsing-algorithms-bottom-up:lr0}\n\\begin{easylist}\n\n& \\textbf{LR(0) parsing:} Form of LR(k) parsing where no tokens of lookahead are used, so a reduction is always executed whenever possible\n\t&& \\textbf{LR(0) grammar:} Subset of CFGs where an LR(0) construction can be generated without shift-reduce or reduce-reduce conflicts (i.e. the generated pushdown automata is deterministic)\n\n& Grammar validity:\n\t&& A grammar is LR(0) if and only if no shift-reduce or reduce-reduce conflicts exist in the itemsets\n\t&& A grammar is not LR(0) if and only if at least one shift-reduce or reduce-reduce conflict exists in the itemsets\n\n\\end{easylist}\n\\subsection{SLR(1) Parsing}\n\t\\label{subsec:parsing-algorithms-bottom-up:slr1}\n\\begin{easylist}\n\n& \\textbf{LR(1) parsing:} Form of LR(k) parsing where 1 token of lookahead is available for use\n\n& \\textbf{SLR(1)/SLR/Simple LR parsing:} Subset of LR(0) parsing where each \\textit{production rule} includes all possible $FOLLOW$ terminal symbols using 1 character of lookahead\n\n& \\textbf{SLR(1)/SLR/Simple LR grammar:} Subset of CFGs where an LR(1) construction can be generated without shift-reduce or reduce-reduce conflicts, or conflicts exist but can be resolved due to having a single $FOLLOW$ symbol\n\t&& First/follow:\n\t\t&&& \\textbf{First:} Set of terminal symbols which are the beginning symbols of all strings which can be derived from a given symbol\n\t\t\t&&&& Notation: $FIRST(S) = \\{a, b\\}$ where $S$ is a given symbol and $a, b$ are terminal symbols\n\t\t\t&&&& Example: Given a set of production rules, the First sets of the non-terminal symbols are derived in table~\\ref{tab:first-example}\n\t\t&&& \\textbf{Follow:} Set of terminal symbols which can follow a given symbol\n\t\t\t&&&& Notation: $FOLLOW(S) = \\{a, b\\}$ where $S$ is a given symbol and $a, b$ are terminal symbols\n\t\t\t&&&& Example: Given a set of production rules, the Follow sets of the non-terminal symbols are derived in table~\\ref{tab:follow-example}\n\t\t&&& Example: Given a set of production rules, the First and Follow sets of the non-terminal symbols can be derived as follows:\n\t\t\t&&&& See table~\\ref{tab:first-follow-sets-example-1}\n\t\t\t&&&& See table~\\ref{tab:first-follow-sets-example-2}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{First Example}\n\t\\label{tab:first-example}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r l }\n\t\t\tProduction Rules:\n\t\t\t& $A \\rightarrow Bc | d$ \\\\\n\t\t\t& $B \\rightarrow e$ \\\\\n\t\t\t\\hline\n\t\t\t$FIRST(A) =$ & $\\{d, e\\}$ \\\\\n\t\t\t$FIRST(B) =$ & $\\{e\\}$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{Follow Example}\n\t\\label{tab:follow-example}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r l }\n\t\t\tProduction Rules:\n\t\t\t& $A \\rightarrow Bc$ \\\\\n\t\t\t& $B \\rightarrow Bd | BC$ \\\\\n\t\t\t& $C \\rightarrow e$ \\\\\n\t\t\t\\hline\n\t\t\t$FOLLOW(A) =$ & $\\{ \\$ \\}$ \\\\\n\t\t\t$FOLLOW(B) =$ & $\\{c, d, e\\}$ \\\\\n\t\t\t$FOLLOW(C) =$ & $\\{c\\}$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{First/Follow Sets Example 1}\n\t\\label{tab:first-follow-sets-example-1}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | l }\n\t\t\tProduction Rules\n\t\t\t& $S \\rightarrow AB$ \\\\\n\t\t\t& $A \\rightarrow c | \\epsilon$ \\\\\n\t\t\t& $B \\rightarrow cbB | a$ \\\\\n\t\t\t\\hline\n\t\t\tFirst sets\n\t\t\t& $FIRST(A) = \\{c, \\epsilon\\}$ \\\\\n\t\t\t& $FIRST(B) = \\{c, a\\}$ \\\\\n\t\t\t& $FIRST(S) = FIRST(A) = \\{c, \\epsilon\\}$ \\\\\n\t\t\t\\hline\n\t\t\tFollow sets\n\t\t\t& $FOLLOW(A) = FIRST(B) = \\{c, a\\}$ \\\\\n\t\t\t& $FOLLOW(B) = \\{\\$\\}$ \\\\\n\t\t\t& $FOLLOW(S) = \\{\\$\\}$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{First/Follow Sets Example 2}\n\t\\label{tab:first-follow-sets-example-2}\n\t\\begin{center}\n\t\t\\begin{tabular}{ r | l }\n\t\t\tProduction Rules\n\t\t\t& $S \\rightarrow cAa$ \\\\\n\t\t\t& $A \\rightarrow cB | B$ \\\\\n\t\t\t& $B \\rightarrow bcB | \\epsilon$ \\\\\n\t\t\t\\hline\n\t\t\tFirst sets\n\t\t\t& $FIRST(A) = \\{c, b, \\epsilon\\}$ \\\\\n\t\t\t& $FIRST(B) = \\{b, \\epsilon\\}$ \\\\\n\t\t\t& $FIRST(S) = \\{c\\}$ \\\\\n\t\t\t\\hline\n\t\t\tFollow sets\n\t\t\t& $FOLLOW(A) = \\{a\\}$ \\\\\n\t\t\t& $FOLLOW(B) = FOLLOW(A) = \\{a\\}$ \\\\\n\t\t\t& $FOLLOW(S) = \\{\\$\\}$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\t&& Process to determine whether a shift-reduce conflict can be eliminated by a 1-token lookahead:\n\t\t&&& Find the $FOLLOW$ set of the reduce rule\n\t\t&&& Find the next accepted symbol of the shift rule\n\t\t&&& If the symbol is in the $FOLLOW$ set, then the conflict cannot be eliminated\n\t\t&&& Example: Given the set of production rules in table~\\ref{tab:slr-shift-reduce}, the state $S \\rightarrow A \\bullet xB; B \\rightarrow A \\bullet$ has a shift-reduce conflict which cannot be resolved by 1 token of lookahead, as the parser can still shift or reduce on $x$ because the $FOLLOW$ set of $B$ is $\\{ x, \\$ \\}$\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{SLR Shift-Reduce Conflict Example}\n\t\\label{tab:slr-shift-reduce}\n\t\\begin{center}\n\t\t\\begin{tabular}{ l }\n\t\t\t$S \\rightarrow Ax$ \\\\\n\t\t\t$S \\rightarrow B$ \\\\\n\t\t\t$B \\rightarrow A$ \\\\\n\t\t\t$A \\rightarrow yB$\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n\t&& Example: Given the set of production rules and transition diagram in figure~\\ref{fig:slr-1-parsing-prod-rules-diagram}, the trace of the SLR(1) parse of $id * id$ is table~\\ref{tab:slr-1-parsing-trace}\n\n\\begin{figure}[!htb]\n\t\\caption{SLR(1) Parsing Example: Production Rules and Diagram}\n\t\\label{fig:slr-1-parsing-prod-rules-diagram}\n\t\\begin{center}\n\t\t\\includegraphics[width=\\textwidth]{slr-1-trace-diagram}\n\t\\end{center}\n\\end{figure}\n\n\\end{easylist}\n\\begin{figure}[!htb]\n\t\\caption{SLR(1) Parsing Example: Trace}\n\t\\label{tab:slr-1-parsing-trace}\n\t\\begin{center}\n\t\t\\begin{tabular}{ l | r | l }\n\t\t\tStack and Input & DFA Halt State & Action \\\\\n\t\t\t\\hline\n\t\t\t$| id * id\\$ $ & $1$ & Shift \\\\\n\t\t\t$id | * id\\$ $ & $3 ( \\* \\not\\in FOLLOW(T) )$ & Shift \\\\\n\t\t\t$id * | id\\$ $ & $11$ & Shift \\\\\n\t\t\t$id * id |\\$ $ & $3 (\\$ \\in FOLLOW(T) )$ & Reduce $T \\rightarrow id$ \\\\\n\t\t\t$id * T | \\$ $ & $4 (\\$ \\in FOLLOW(T) )$ & Reduce $T \\rightarrow id * T$ \\\\\n\t\t\t$T | \\$ $ & $5 (\\$ \\in FOLLOW(T) )$ & Reduce $E \\rightarrow T$ \\\\\n\t\t\t$E | \\$ $ & & Accept\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{figure}\n\\begin{easylist}\n\n& Grammar validity:\n\t&& A grammar is SLR(1) if and only if, for each shift-reduce or reduce-reduce conflict in the configuration sets, the $FOLLOW$ sets of the conflicting production rules (not dotted rules) do not intersect\n\t&& A grammar is not SLR(1) if and only if there exists at least one shift-reduce or reduce-reduce conflict in the configuration sets where the $FOLLOW$ sets of the conflicting production rules intersect\n\n\\end{easylist}\n\\subsection{Canonical LR(1) Parsing}\n\t\\label{subsec:parsing-algorithms-bottom-up:canonical-lr1}\n\\begin{easylist}\n\n& \\textbf{LR(1)/Canonical LR(1) parsing:} Subset of LR(0) parsing where each \\textit{dotted rule} includes a 1-character lookahead, rather than each production rule\n\t&& More accurate than SLR(1) parsing\n\t&& Notation: $\\textrm{dotted rule, } \\alpha / \\beta$ where $\\alpha, \\beta$ are the potential $FOLLOW$ characters of the non-terminal symbol if the rule was parsed and reduced\n\t\n& Grammar validity:\n\t&& A grammar is LR(1) if and only if, for each shift-reduce or reduce-reduce conflict, the $FOLLOW$ sets of the dotted rules do not conflict\n\t&& A grammar is not LR(1) if and only if there exists at least one itemset where conflicting dotted rules have intersecting $FOLLOW$ sets\n\n\\end{easylist}\n\\subsection{LALR(1) Parsing}\n\t\\label{subsec:parsing-algorithms-bottom-up:lalr1}\n\\begin{easylist}\n\n& \\textbf{LALR(1) parsing:} Subset of LR(0) parsing which combines states when they share the same dotted rules but have different $FOLLOW$ sets\n\t&& More specific than SLR(1) (as resulting $FOLLOW$ sets may not always be the complete \\\\ $FOLLOW$ set)\n\t&& Simplified/compact version of canonical LR(1)\n\t\n& Grammar validity:\n\t&& A grammar is LALR(1) if and only if, when states with matching dotted rules are merged, for each combination of states, for each matching dotted rule in the resulting configuration set, there are no conflicts in the 1-character lookaheads\n\t&& A grammar is not LALR(1) if and only if, when states with matching dotted rules are merged, the $FOLLOW$ sets contain shift-reduce or reduce-reduce conflicts\n\n\\end{easylist}\n\\clearpage\n", "meta": {"hexsha": "c00902e16b7172b8dc2fd0f1559fc74e07a2a3c6", "size": 18158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cmpt-379-principles-of-compiler-design/tex/parsing-algorithms-bottom-up.tex", "max_stars_repo_name": "AmirNaghibi/notes", "max_stars_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2019-08-11T08:45:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:37:39.000Z", "max_issues_repo_path": "cmpt-379-principles-of-compiler-design/tex/parsing-algorithms-bottom-up.tex", "max_issues_repo_name": "AmirNaghibi/notes", "max_issues_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cmpt-379-principles-of-compiler-design/tex/parsing-algorithms-bottom-up.tex", "max_forks_repo_name": "AmirNaghibi/notes", "max_forks_repo_head_hexsha": "c4640bbcb65c94b8756ccc3e4c1bbc7d5c3f8e92", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-11-18T09:17:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-27T21:44:56.000Z", "avg_line_length": 40.4409799555, "max_line_length": 323, "alphanum_fraction": 0.6620222491, "num_tokens": 5982, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5888891307678321, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4175336577716523}}
{"text": "\\section{Results and Discussion}\n\\label{sec:Results_and_Discussion}\n\\subsection{Speed of Sound}\n\\begin{table}[H]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{1.2}\n\t\\begin{tabular}{r l}\n\t\t\\hline\n\t\t\\textbf{Mean Value $\\overline t$} & $(7.32\\pm0.07)\\cdot10^{-3}$\\ s \\\\\n\t\t\\textbf{Standard Deviation $s$} & $0.3\\cdot10^{-3}$\\ s \\\\\n\t\t\\textbf{Speed of Sound $v$} & $(350\\pm4)\\ \\,^\\text{m}\\!/_\\text{s}$ \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Speed of Sound Results}\n\t\\label{tab:Speed_of_Sound_Results}\n\\end{table}\nThe results came out exactly the same way. The task of calculating the mean value, the error and standard deviation can easily be done in Excel or in QtiPlot. However, the advantage of QtiPlot is that a plot can easily be created with all the relevant data.\n\\subsection{Iron Content}\n\\begin{table}[H]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{1.2}\n\t\\begin{tabular}{r c}\n\t\t\\hline\n\t\t\\textbf{Mean Value} & $(20.6\\pm0.5)\\ \\%$ \\\\\n\t\t\\textbf{Weighted Mean Value} & $(20.4\\pm0.4)\\ \\%$ \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Iron Content Results}\n\t\\label{tab:Iron_Content_Results}\n\\end{table}\nThe mean value and the weighted mean value were calculated with Excel and QtiPlot. Both values are exactly the same. The error bars in the exported plot from QtiPlot (see figure \\ref{fig:Iron_Content}) are extremely helpful to understand the weighted mean value. Doing this in Excel would be pretty challenging.\n\\subsection{Spring Constant}\n\\begin{table}[H]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{1.2}\n\t\\begin{tabular}{r l}\n\t\t\\hline\n\t\t\\textbf{Spring Constant $k$} & $(22.5\\pm0.9)\\ \\,^\\text{N}\\!/_\\text{m}$ \\\\\n\t\t\\textbf{Pretension Force $F_0$} & $(-0.8\\pm0.5)$\\ N \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Spring Constant Results}\n\t\\label{tab:Spring_Constant_Results}\n\\end{table}\nThe linear fitted curve (see figure \\ref{fig:Spring_Constant}) was created with QtiPlot. Furthermore, the results have been calculated using QtiPlot.\n\\newpage\n\\subsection{Pendulum}\n\\begin{table}[H]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{1.2}\n\t\\begin{tabular}{r l}\n\t\t\\hline\n\t\t\\textbf{Amplitude $A$} & $(-1.22\\pm0.03)$\\ m \\\\\n\t\t\\textbf{Damping Constant $\\Gamma$} & $(52\\pm2)\\cdot10^{-3}\\ \\text{s}^{-1}$ \\\\\n\t\t\\textbf{Frequency $f$} & $(55.0\\pm0.2)\\cdot10^{-3}$\\ Hz \\\\\n\t\t\\textbf{Phase $\\delta$} & $(-2.63\\pm0.02)$\\ rad \\\\\n\t\t\\textbf{Offset $y_0$} & $(49\\pm5)\\cdot10^{-3}$\\ m \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Damped Pendulum Results}\n\t\\label{tab:Damped_Pendulum_Results}\n\\end{table}\nCalculating the parameters of the damped pendulum with QtiPlot is easy and does not take a lot of time. Calculating all the parameters with Excel would take quite some time. Furthermore, it would be more prone to errors.\n\\subsection{RC Low-Pass Filter}\n\\begin{table}[H]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{1.2}\n\t\\begin{tabular}{r l}\n\t\t\\hline\n\t\t\\textbf{Capacity $C$ (Output Voltage)} & $(216.9\\pm0.9)\\cdot10^{-9}$\\ F \\\\\n\t\t\\textbf{Capacity $C$ (Phase)} & $(197.5\\pm3.1)\\cdot10^{-9}$\\ F \\\\ \\hline\n\t\\end{tabular}\n\t\\caption{RC Low-Pass Filter Results}\n\t\\label{tab:RC_Low-Pass_Filter_Results}\n\\end{table}\nThe calculated capacities from the output voltage and the phase do not match. Generally, voltage measurements with a cathode ray oscilloscope can be read off more accurately than phase shift measurements. Thus, the capacity value calculated from the output voltage is more trustworthy.\n", "meta": {"hexsha": "adcae7773bb391fb451f322870abb73f89ae540a", "size": 3326, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "glaL3_C_Evaluation_with_Computer/sections/results_discussion.tex", "max_stars_repo_name": "MuellerDominik/Physics-Laboratory-Notebooks", "max_stars_repo_head_hexsha": "02836870e6d97a29b1857c956fbd58eb5933eede", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "glaL3_C_Evaluation_with_Computer/sections/results_discussion.tex", "max_issues_repo_name": "MuellerDominik/Physics-Laboratory-Notebooks", "max_issues_repo_head_hexsha": "02836870e6d97a29b1857c956fbd58eb5933eede", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "glaL3_C_Evaluation_with_Computer/sections/results_discussion.tex", "max_forks_repo_name": "MuellerDominik/Physics-Laboratory-Notebooks", "max_forks_repo_head_hexsha": "02836870e6d97a29b1857c956fbd58eb5933eede", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.5616438356, "max_line_length": 311, "alphanum_fraction": 0.7122669874, "num_tokens": 1127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4175336577716522}}
{"text": "\\chapter{$b$-hadron Lifetimes}\\label{appendix:B_hadron_lifetimes}\n\n$b$-hadrons (hadronically bound states containing at least one $b$-flavor quark) have what are viewed as long lived lifetimes before they decay.\nUsing the charged $B$ meson, $B^{-}$, as an example, with quark content of $B^{-} = \\Ket{\\bar{u}\\, b}$, a decay mediated by the strong force is forbidden by electrical charge conservation.\nThus, the decay must proceed through a flavor-changing charged current mediated by a $W$ boson.\nThus, some possible decays are\n\\[\n \\underbrace{\\bar{u}\\,b}_{B^{-}} \\to \\underbrace{u\\bar{u}}_{\\pi^0} \\left(W^{-} \\to\\right) \\ell^{-} \\bar{\\nu}_{\\ell}, \\qquad \\underbrace{\\bar{u}\\,b}_{B^{-}} \\to \\underbrace{u\\bar{u}}_{\\pi^0} \\left(W^{-} \t\\to \\right) \\underbrace{\\bar{u}d}_{\\pi^-},\n\\]\n%\n\\[\n \\underbrace{\\bar{u}\\,b}_{B^{-}} \\to \\underbrace{c\\bar{u}}_{D^0} \\left(W^{-} \\to \\right) \\ell^{-} \\bar{\\nu}_{\\ell}, \\qquad \\underbrace{\\bar{u}\\,b}_{B^{-}} \\to \\underbrace{c\\bar{u}}_{D^0} \\left(W^{-} \\to \\right) \\underbrace{\\bar{u}d}_{\\pi^-}.\n\\]\nAs the $b$-decay is cross generational, it is ``Cabibbo suppressed'' further increasing the lifetime~\\cite{Vaandering}.\nCabibbo suppression is also relevant in the decays of kaons and charged $D$-mesons.\n\nWith the introduction of the ``strangness'' quantum number, it was observed that the decay rates of particles with nonzero strangness were different then non-strange particles.\nCabibbo suggested~\\cite{Cabibbo:1963yz} that these decays were also mediated by weak interactions but that the participating states (weak eigenstates) were mixtures of the mass eigenstates,\n\\[\n \\Ket{d'} = \\alpha \\Ket{d} + \\beta \\Ket{s},\n\\]\nsuch that through normalization, $\\Braket{d'|d'} = 1$, and absorbing phases, one free parameter remains.\nThe choices of\n\\[\n \\alpha = \\cos\\theta_C, \\qquad \\beta = \\sin\\theta_C,\n\\]\nare made and $\\theta_C$ --- the free parameter --- is empirically determined from fits to data to be $\\theta_C \\approx 0.23~\\mathrm{rad} \\approx 13.15^{\\circ}$.\nWith Glashow, Iliopoulos, and Maiani's (GIM) introduction of a fourth quark, $c$,~\\cite{Glashow:1970gm} the Cabibbo-GIM scheme established the ``Cabibbo-rotated'' weak eigenstates\n\\[\n \\Ket{d'} = \\cos\\theta_C \\Ket{d} + \\sin\\theta_C \\Ket{s}, \\qquad \\Ket{s'} = -\\sin\\theta_C \\Ket{d} + \\cos\\theta_C \\Ket{s}\n\\]\nwhich comprised the flavor doublets\n\\[\n \\begin{pmatrix}\n  u \\\\d'\n \\end{pmatrix}, \\quad\n \\begin{pmatrix}\n  c \\\\s'\n \\end{pmatrix}\n\\]\nthat the $W$ bosons couple to in the same manner as they couple to lepton flavor doublets.\nThe Cabibbo rotation matrix obviously follows,\n\\[\n \\begin{pmatrix}\n  d' \\\\ s'\n \\end{pmatrix}\n =\n \\begin{pmatrix}\n  \\cos\\theta_C & \\sin\\theta_C \\\\ -\\sin\\theta_C & \\cos\\theta_C\n \\end{pmatrix}\n \\begin{pmatrix}\n  d \\\\ s\n \\end{pmatrix}\n\\]\nWith Kobayashi and Maskawa's generalization of the Cabibbo-GIM scheme to three generations~\\cite{Kobayashi:1973fv} the CKM transformation matrix was formed,\n\\[\n \\begin{pmatrix}\n  d' \\\\ s'\\\\ b'\n \\end{pmatrix}\n =\n \\begin{pmatrix}\n  V_{ud} & V_{us} & V_{ub} \\\\\n  V_{cd} & V_{cs} & V_{cb} \\\\\n  V_{td} & V_{ts} & V_{tb} \\\\\n \\end{pmatrix}\n \\begin{pmatrix}\n  d \\\\ s\\\\ b\n \\end{pmatrix}\\,.\n\\]\nTaking the third to first and second generational mixing elements to be small (i.e., in terms of the generalized Cabibbo angles $(\\theta_{12},\\theta_{23},\\theta_{13})$ $\\theta_{13} \\approx \\theta_{23} \\sim 0$), it is seen that the Cabibbo-GIM mixing matrix is recovered.\nIt is seen from the CKM matrix (whose on-diagonal elements are close to unity) that cross-generational decays (off-diagonal elements) are ``Cabibbo suppressed'' while intragenerational decays (on-diagonal elements) are ``Cabibbo favored.''\n\nThus, noting that\n\\[\n \\beta = \\frac{\\abs{\\vec{p}}c}{E}, \\qquad E = \\gamma\\, mc^2,\n\\]\nit is seen that for a hadron with mass $m$, mean lifetime $\\tau$, and 3-momentum $\\abs{\\vec{p}}$, the distance it travels, $x'$, in the lab frame, $O'$, before decaying is,\n\\[\n \\begin{split}\n  x'\t&= v' t'\t\\\\\n  &= \\left(\\beta c\\right) \\left(\\gamma \\tau\\right)\t\\\\\n  &= \\frac{\\abs{\\vec{p}}c^2}{E} \\gamma \\tau\t\\\\\n  &= \\frac{\\abs{\\vec{p}}c^2}{\\gamma\\, mc^2} \\gamma \\tau\t\\\\\n  &= \\frac{\\abs{\\vec{p}}}{m}\\, \\tau.\n \\end{split}\n\\]\nIt is also seen that the characteristic length scale of the particle, where $\\beta\\gamma=1$ and so $p=mc$, is equal to $c\\tau$.\nThe boost of the particle then acts as a scale factor of this length, scaling it up and down.\n", "meta": {"hexsha": "abd5b9ccbb8f533b9d4b9d9422187569376c4b60", "size": 4378, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/appendix/B_hadron_lifetimes.tex", "max_stars_repo_name": "matthewfeickert/feickert-thesis", "max_stars_repo_head_hexsha": "7ab7210359495fe7ea1e610be237560ec35f63a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-09-20T04:40:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-18T20:40:23.000Z", "max_issues_repo_path": "src/appendix/B_hadron_lifetimes.tex", "max_issues_repo_name": "matthewfeickert/feickert-thesis", "max_issues_repo_head_hexsha": "7ab7210359495fe7ea1e610be237560ec35f63a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-10-03T11:36:53.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-03T11:36:53.000Z", "max_forks_repo_path": "src/appendix/B_hadron_lifetimes.tex", "max_forks_repo_name": "matthewfeickert/feickert-thesis", "max_forks_repo_head_hexsha": "7ab7210359495fe7ea1e610be237560ec35f63a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-10-04T21:35:30.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-04T21:35:30.000Z", "avg_line_length": 49.191011236, "max_line_length": 270, "alphanum_fraction": 0.680447693, "num_tokens": 1480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.41753365415083965}}
{"text": "\\chapter{Transfer matrices}\n\\label{Sec:transfer}\nDeterministic particle transport codes solve a\ndiscrete version of the Boltzmann equation, and the\ntransfer matrix approximates the kernel of the integral\noperator in this equation.\nIf $x$ denotes the position,\n$t$ the time, $E'$ the particle energy, $\\Omega'$ the\ndirection of motion, $v$ the magnitude of the velocity (speed), and\n$n(x, t, E', \\Omega')$ the number density, then the\nflux $\\phi = vn$ satisfies the Boltzmann \nequation~\\cite{Lewis}\n\\begin{equation}\n  \\frac{1}{v} \\, \\partial_t \\phi(E', \\Omega') +\n  \\Omega'\\cdot \\nabla \\phi(E', \\Omega') +\n      \\rho\\sigma_t \\phi(E', \\Omega') =\n  \\frac{\\rho}{4\\pi}\n   \\int_{\\Omega} d\\Omega \\, \\int_0^\\infty dE \\, \n      \\calK(E', \\Omega' \\cdot \\Omega \\mid E) \\phi(E, \\Omega).\n  \\label{Boltzmann}\n\\end{equation}\nThe direction $\\Omega'$ is relative to some given \n``north pole''~$\\Omega_0$, and $\\rho$ is the density of the material.\nThe dependence on $x$ and $t$ is suppressed.\nThe first two terms in Eq.~(\\ref{Boltzmann}) give the derivative \nwith respect to distance of\nthe flux in a coordinate system moving with the particles.\nThe parameter\n$\\sigma_t$ is the microscopic total cross section, so the term\n$\\rho\\sigma_t \\phi(E', \\Omega')$ represents the rate of particle loss\nper particle path length.\n\nThe kernel\n$\\calK(E', \\Omega' \\cdot \\Omega \\mid E)$ in Eq.~(\\ref{Boltzmann}) gives the\nrate of production of outgoing particles with energy $E'$ and \ndirection~$\\Omega'$ corresponding to incident particles\nat energy $E$ and direction~$\\Omega$.\nHere, the energies $E$ and $E'$ and the directions $\\Omega$\nand $\\Omega'$ are in the laboratory coordinate system.\nFrom here on,  the notation\n$$\n  \\mu = \\Omega' \\cdot \\Omega\n$$\nis used.\nIt is significant that the dependence of\n$\\calK(E', \\mu \\mid E)$ on $\\mu$\nis axisymmetric, because the orientation of the\ntarget nucleus is unknown.  The primes are placed where they are in\nEq.~(\\ref{Boltzmann}), because the emphasis in this document is on\napproximation of the right-hand side of the equation.  In that setting, it is\nnatural that $E$ denote the energy of the incident particle and $E'$\nthe outgoing particle energy.\n\nFor a given target,\nthe nuclear data in \\xendl\\ is given reaction by reaction,\ne.g., elastic scattering, neutron capture, fission, etc.\nThe transfer matrix approximating $\\calK$ is built\nup by summing over the reactions~$r$\n$$\n  \\calK = \\sum_r \\calK_r.\n$$\nThe reaction kernels $\\calK_r$ themselves are not given in \\xendl,\nbut their component factors are given instead, namely,\n\\begin{enumerate}\n \\item $\\sigma_r(E)$: the cross section for the $r$-th reaction,\n \\item  $M_r(E)$: the multiplicity of the outgoing particle,\n \\item $w_r(E)$: the model weight for these data,\n \\item $\\pi_r(E', \\mu \\mid E)$: the double-differential probability\ndensity of the energy and direction cosine\nfor one outgoing particle. \n\\end{enumerate}\nIn terms of this notation, $\\calK_r$ is the product\n\\begin{equation}\n  \\calK_r(E', \\mu \\mid E) = \\sigma_r(E) M_r(E) w_r(E) \\pi_r(E', \\mu \\mid E).\n  \\label{def_pi}\n\\end{equation}\nThe multiplicity $M_r(E)$ may be constant, e.g., 1 for elastic scattering\nand 2 for $(n, 2n)$ reactions, but the number of fission neutrons\ndepends on the incident energy~$E$.  The default is $M_r(E) = 1$.\n\n\\paragraph{Model weight}\\label{Sec:model-weight}\nThe model weight is usually $w_r(E) = 1$, and that is the\ndefault.  One exception is that data for a single outgoing neutron in\nan $(n, 2n)$ reaction may have $M_r(E) = 2$ and $w_r(E) = 0.5$.\nThe model weight is also used to handle the use of different interpolation\nrules over different ranges of incident energy.  Thus, if the interpolation\nfor $E_1 < E < E_2$ is different from that for $E_2 < E < E_3$,\nthe data may be split into two sets, one with\n$$\n  w_r(E) = \\begin{cases}\n    1 & \\text{for $E_1 \\le E < E_2$,}\\\\\n    0 & \\text{for $E_2 \\le E \\le E_3$,}\n  \\end{cases}\n$$\nand the other with\n$$\n  w_r(E) = \\begin{cases}\n    0 & \\text{for $E_1 \\le E < E_2$,}\\\\\n    1 & \\text{for $E_2 \\le E \\le E_3$.}\n  \\end{cases}\n$$\n\nThe \\xendl\\ nuclear data consist\nof tables of $\\sigma_r(E)$ and $\\pi_r(E', \\mu \\mid E)$ and possibly\n$M_r(E)$ and~$w_r(E)$.\nThe data for $\\pi_r(E', \\mu \\mid E)$ take several forms, and\nthe various data representations are dealt with individually.\n\nThe discretization of Eq.~(\\ref{Boltzmann}) is based, first,\non the specification of a set of energy groups $\\{ \\calE_g\n\\}$ for the incident particles and energy groups $\\{ \\calE'_h\n\\}$ for the emitted particles.  The energy groups for\nneutrons are typically different from those for gammas,\nand yet another set is usually used for charged particles.\nThe flux $\\phi(E, \\Omega)$ inside the integral in\nEq.~(\\ref{Boltzmann}) is discretized according to the energy\ngroups of the incident particle, while $\\phi(E', \\Omega')$\non the left-hand side of Eq.~(\\ref{Boltzmann}) is discretized\naccording the the energy groups of the outgoing particles.\nThese energy groups are also called energy bins.\n\nAccording to the normalization for Legendre expansions used in \\xendl,\nthe angular discretization of $\\pi_r$ in Eq.~(\\ref{def_pi}) is \ngiven by\n\\begin{equation}\n  \\pi_r( E', \\mu \\mid E) =\n   \\sum_{\\ell = 0}^{\\Lmax}\n   \\left(\n     \\ell + \\frac{1}{2}\n   \\right)\n   \\pi_{r\\ell}( E' \\mid E) P_\\ell( \\mu)\n  \\label{def_pi_r}\n\\end{equation}\nwith $P_\\ell( \\mu)$ denoting the $\\ell$-th Legendre polynomial\nand\n\\begin{equation}\n  \\pi_{r\\ell}( E' \\mid E) =\n  \\int_{-1}^1 d\\mu \\, \\pi_r( E', \\mu \\mid E) P_\\ell( \\mu)\n  \\label{def_piell}\n\\end{equation}\nfor $\\ell = 0,$ 1, \\ldots,~$\\Lmax$.\nThe user may specify the order~$\\Lmax$ with the command\ngiven in Section~\\ref{Sec:LegendreOrder}.\n\nThe flux $\\phi(E, \\Omega)$ in Eq.~(\\ref{Boltzmann}) is expanded \ninto spherical harmonics\n\\begin{equation}\n  \\phi(E, \\Omega) =\n  \\sum_{\\ell, m}\n    C_{\\ell, m} \\phi_{\\ell, m}(E) Y_{\\ell, m} (\\Omega)\n \\label{sphHarmonics}\n\\end{equation}\nwith normalization\n$$\n  C_{\\ell, m} = \\frac{1}{\\int d\\Omega \\, [Y_{\\ell, m} (\\Omega)]^2}.\n$$\n\nA discrete approximation to Eq.~(\\ref{Boltzmann}) may be obtained\nby expanding $\\phi(E, \\Omega)$ in spherical harmonics and integrating\nover the outgoing energy group~$\\calE'_h$.\nThis gives an\nequation for the vector of values\n$$\n  \\phi_{\\ell, m}(E'_h).\n$$\nNote that $\\phi_{\\ell, m}(E'_h)$ is a histogram with respect to\nthe energy $E'$ of the outgoing particle, constant on each energy\ngroup~$\\calE'_h$.\nIntegration of the\nright-hand side of Eq.~(\\ref{Boltzmann}) over $\\calE'_h$ gives\n\\begin{equation}\n  \\calI_{h,\\ell} = \\sum_r\n  \\int_0^\\infty dE \\, \\phi_{\\ell, 0}(E)\n  \\int_{\\calE'_h } dE' \\, \\int_{-1}^1 d\\mu \\,\n  \\calK_r(E', \\mu \\mid E) P_\\ell( \\mu ).\n  \\label{binnedBoltzmann}\n\\end{equation}\nThe integral Eq.~(\\ref{binnedBoltzmann}) contains only the spherical\nharmonics with $m = 0$, because the kernel $\\calK_r$ is axisymmetric.\n\nThe unknown flux $\\phi$ appears in Eq.~(\\ref{Boltzmann})\nboth on the left-hand side of the equation and under\nthe integral sign.  It is therefore convenient to\nstart the calculation using an assumed approximate value of\n$\\phi_{\\ell, 0}(E)$ in the integral Eq.~(\\ref{binnedBoltzmann}), namely,\n\\begin{equation}\n  \\phi_{\\ell, 0}(E) \\approx\n    \\widetilde\\phi_{\\ell}(E).\n  \\label{approx_phi}\n\\end{equation}\n\nUpon inserting Eq.~(\\ref{approx_phi}) into Eq.~(\\ref{binnedBoltzmann})\nand taking the incident energy groups $\\calE_g$ one at a time,\nit is found that Eq.~(\\ref{binnedBoltzmann}) may be viewed as the product\nof a matrix with a column vector.  Here, the column vector has the\ncomponents $\\phi_{\\ell, 0}(E'_h)$, and the components of the matrix\nare given by\n$$\n  \\calJ_{g,h,\\ell} = \\frac{ \\calI_{g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }\n$$\nwith\n$$\n    \\calI_{g,h,\\ell} = \\sum_r\n     \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) \n    \\int_{\\calE'_h } dE' \\, \\int_\\mu d\\mu \\, \n     \\calK_r(E', \\mu \\mid E) P_\\ell( \\mu ).\n$$\nThe quantities $\\calJ_{g,h,\\ell}$ constitute the entries of the \\textit{transfer matrix}.\n\nThe above discussion gives one way of defining the transfer matrix,\nbut the \\xndfgen\\ code has three\ndifferent representations, depending\non whether one wants to conserve the number of particles,\nthe energy, or both.  Traditionally, conservation of particle \nnumber has been used for neutron transport, conservation of energy\nfor gammas, and conservation of both energy and number for\ncharged particles.  These cases are taken up in turn.\n\n\\section{Conservation of particle number}\nWith the approximate flux coefficient $\\widetilde\\phi_\\ell$ in Eq.~(\\ref{approx_phi})\nand the representation Eq.~(\\ref{def_pi}) of the kernel $\\calK_r$, the\n$\\ell$-th Legendre coefficient of the contributions of energy\ngroups $\\calE_g$ and $\\calE'_h$ to the integral\nin Eq.~(\\ref{Boltzmann}) by reaction $r$ is given by\n\\begin{equation}\n  \\Inum_{r,g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma_r ( E ) M_r(E) w_r(E) \\widetilde \\phi_\\ell(E) \n    \\int_{\\calE'_h } dE' \\, \\int_\\mu d\\mu \\, \n     P_\\ell( \\mu )\n     \\pi_r(E', \\mu \\mid E).\n  \\label{Inum}\n\\end{equation}\nFor conservation of particle number the elements of the transfer matrix\nare the sums over all reactions,\n\\begin{equation}\n  \\calJ_{g,h,\\ell} = \\frac{ \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n  \\label{cons_num}\n\\end{equation}\nThe \\gettransfer\\ code computes the integrals $\\Inum_{r,g,h,\\ell}$\nreaction by reaction, and the operation Eq.~(\\ref{cons_num}) is performed\nby \\xndfgen.\n\nNote that the number-preserving transfer matrices offer a\nsimple check.  Because the probability density\n$\\pi_r(E', \\mu \\mid E)$ has the normalization\n$$\n  \\int_0^\\infty dE' \\, \\int_{-1}^1 d\\mu \\, \n     \\pi_r(E', \\mu \\mid E) = 1,\n$$\nit follows from Eq.~(\\ref{Inum}) that\n\\begin{equation}\n  \\sum_h \\Inum_{r,g,h,0} =\n    \\int_{\\calE_g} dE \\, \\sigma_r ( E ) M_r(E) w_r(E) \\widetilde \\phi_0(E).\n  \\label{rowSum}\n\\end{equation}\n\n\\section{Conservation of energy}\nWhen conservation of energy is desired, the integral\nEq.~(\\ref{Inum}) is modified by insertion of $E'$ as a weight factor\n\\begin{equation}\n  \\Ien_{r,g,h,\\ell} =\n     \\int_{\\calE_g} dE \\, \\sigma_r ( E ) M_r(E) w_r(E) \\widetilde \\phi_\\ell(E) \n    \\int_{\\calE'_h } dE' \\, E' \\int_\\mu d\\mu  \\, \n     P_\\ell ( \\mu )\n     \\pi_r(E', \\mu \\mid E).\n  \\label{Ien}\n\\end{equation}\nWith the notation that $\\overline {E'_h}$ denotes the midpoint of\nenergy group $\\calE'_h$, the elements of the transfer matrix\nfor energy conservation are the sums over all reactions,\n\\begin{equation}\n  \\widehat \\calJ_{g,h,\\ell} = \\frac{ \\sum_r \\Ien_{r,g,h,\\ell} }\n       { \\overline {E'_h} \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n  \\label{cons_en}\n\\end{equation}\nThe computation of $\\widehat \\calJ_{g,h,\\ell}$ in Eq.~(\\ref{cons_en})\nis done by \\xndfgen\\ using the integrals $\\Ien_{r,g,h,\\ell} $ calculated\nby \\gettransfer.\n\n\\section{Conservation of both particles and energy}\nThe \\xndfgen\\ code also has an option to combine the \nintegrals $\\Inum_{r,g,h,\\ell}$ in Eq.~(\\ref{Inum}) and $\\Ien_{r,g,h,\\ell}$ in Eq.~(\\ref{Ien})\nso as to construct a transfer matrix which conserves both energy\nand particle number.  Energy conservation may be violated\nin the lowest and highest outgoing energy groups, however.\nThe construction is based on the following ideas.\n\nThere are two ways to compute the average energy of particles\nin the outgoing energy group~$\\calE'_h$.  One such average is the midpoint\n$\\overline {E'_h}$ of this group.  Preferably, this value should be\nthe same as the average energy\nderived from the the sums over the reactions~$r$ of the\nintegrals Eqs.~(\\ref{Ien}) and~(\\ref{Inum}),\n\\begin{equation}\n  \\langle E' \\rangle_{g,h} =\n  \\frac{ \\sum_r \\Ien_{r,g,h,0}}{ \\sum_r \\Inum_{r,g,h,0}}.\n  \\label{av_E}\n\\end{equation}\nThis is accomplished, as much as possible, by properly defining\nentries of the transfer matrix corresponding to adjacent outgoing\nenergy groups.\n\nFor each\nincident energy group $\\calE_g$ one iterates through the\noutgoing energy groups~$\\calE'_h$.\nNote that the description of this process in\n\\cite{Omega} and \\cite{ndfgen} assumes that the energy group\nboundaries decrease with increasing index;  the energy\ngroup boundaries are counted in increasing order here and in \\xndfgen.\n\nIf $\\langle E' \\rangle_{g,h} < \\overline {E'_h}$ and $\\calE'_h$\nis not the lowest energy group, make a fraction of the\nsum\n$$\n\\frac{ \\sum_r \\Ien_{r,g,h,\\ell} }\n       { \\overline {E'_h} \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }\n$$\ncontribute to the transfer matrix element $\\calJ_{g,h,\\ell}$, and\nmake the remainder contribute to~$\\calJ_{g,h-1,\\ell}$.\nSpecifically, it is desired to find $j_{g,h}$\nand $j_{g,h-1}$ which conserve particle number\n$$\n  j_{g,h} + j_{g,h-1} = \n  \\frac{ \\sum_r \\Inum_{r,g,h,0} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_0(E) }\n$$\nas well as average energy\n$$\n  \\overline {E'_h}\\, j_{g,h} + \\overline {E'_{h-1}}\\, j_{g,h-1} = \n    \\sum_r \\Ien_{r,g,h,0}.\n$$\nTherefore, set\n$$\n  f_{g,h} =\n   \\frac{ \\langle E' \\rangle_{g,h} - \\overline {E'_{h-1}} }\n    { \\overline {E'_h} - \\overline {E'_{h-1}} }.\n$$\nFor each Legendre coefficient $\\ell$ take as contribution to\n$\\calJ_{g,h,\\ell}$ the quantity\n$$\n  j_{g,h} = \\frac{ f_{g,h} \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E)  },\n$$\nand the contribution to $\\calJ_{g,h-1,\\ell}$ is\n$$\n  j_{g,h-1} = \\frac{ (1 - f_{g,h}) \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n$$\n\nIf $\\langle E' \\rangle_{g,h} < \\overline {E'_h}$ and $\\calE'_h$\nis the lowest energy group, the contribution to $\\calJ_{g,h,\\ell}$\nis simply\n$$\n  \\frac{ \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n$$\nThis maintains conservation of particle number.\n\nIf $\\langle E' \\rangle_{g,h} > \\overline {E'_h}$ and $\\calE'_h$\nis not the highest energy group, these data are used to calculate\ncontributions to the components $\\calJ_{g,h,\\ell}$ and $\\calJ_{g,h+1,\\ell}$\nof the transfer matrix.  Specifically, set\n$$\n  f_{g,h} =\n   \\frac{ \\overline {E'_{h+1}} - \\langle E' \\rangle_{g,h} }\n    { \\overline {E'_{h+1}} - \\overline {E'_h }}.\n$$\nFor each Legendre coefficient $\\ell$ take as contribution to\n$\\calJ_{g,h,\\ell}$ the quantity\n$$\n  j_{g,h} = \\frac{ f_{g,h} \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) },\n$$\nand the contribution to $\\calJ_{g,h+1,\\ell}$ is\n$$\n  j_{g,h+1} = \\frac{ (1 - f_{g,h}) \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n$$\n\nIf $\\langle E' \\rangle_{g,h} > \\overline {E'_h}$ and $\\calE'_h$\nis the highest energy group, the contribution to $\\calJ_{g,h,\\ell}$\nis\n$$\n  \\frac{ \\sum_r \\Inum_{r,g,h,\\ell} }\n       { \\int_{\\calE_g} dE \\, \\widetilde \\phi_\\ell(E) }.\n$$\n\nThe sum of all of these contributions produces the Legendre\ncoefficients $\\calJ_{g,h,\\ell}$ of a transfer matrix which conserves\nparticle number as well as usually conserving energy.\n\n\\section{Control of the conservation option}\nThe \\gettransfer\\ code computes the integrals Eq.~(\\ref{Inum})\nfor the number-preserving transfer matrix or the\nintegrals Eq.~(\\ref{Ien}) for the energy-preserving transfer matrix\nor both, depending on the value of the \\texttt{Conserve}\ninput parameter.  See Section~\\ref{Sec:conserveFlag}.\n The default mode is to\ncompute both integrals.  The actual construction\nof the transfer matrix is performed by \\xndfgen.\n\n\\section{Numerical quadrature}\nThe integrals Eqs.~(\\ref{Inum}) and~(\\ref{Ien}) require some sort\nof numerical quadrature, and the multiple integrals are computed as\na sequence of single integrals.  The user may specify Gaussian quadrature\nof various orders, as explained in Section~\\ref{Sec:QuadratureMethods}.\nThe reason for the use of Gaussian quadrature in place of, say, Simpson's\nrule, is that in the calculations here,\none of the limits of integration may be a computed quantity\nsuch as a threshold energy.  In such cases, computer arithmetic may\ngive rise to attempts to evaluate $\\pi_r(E', \\mu \\mid E)$\nwhere this function is undefined.\n\nThe user may also specify whether or not to employ an adaptive \nversion of one of these Gaussian methods, using\na modification of the\nadaptive quadrature method proposed by Gander and Gautschi~\\cite{Gander}.\nThe default is to use adaptive quadrature---the non-adaptive version\nis intended for debugging.  For an explanation of the quadrature options,\nsee Sections~\\ref{Sec:QuadratureMethods} and~\\ref{Sec:adaptive-quadrature}.\n\nAnother adaptation of the adaptive quadrature of the reference~\\cite{Gander}\nis that in the integrals Eqs.~(\\ref{Inum}) and~(\\ref{Ien}).\n\n\\textbf{Remark.} In the rest of this document the\nsubscript~$r$ is omitted from each of the terms in the kernel\nEq.~(\\ref{def_pi}) and from the integrals\n$\\Inum_{r,g,h,\\ell}$ and $\\Ien_{r,g,h,\\ell}$, because from now on the discussion will be\nabout the treatment of the data, reaction by reaction.\n\n", "meta": {"hexsha": "90b0a2c387f6166347d673cd95567887080f1cd7", "size": 16854, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Merced/Doc/transfer.tex", "max_stars_repo_name": "brown170/fudge", "max_stars_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2019-08-29T23:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T10:16:25.000Z", "max_issues_repo_path": "Merced/Doc/transfer.tex", "max_issues_repo_name": "brown170/fudge", "max_issues_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-08-04T16:14:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T01:54:34.000Z", "max_forks_repo_path": "Merced/Doc/transfer.tex", "max_forks_repo_name": "brown170/fudge", "max_forks_repo_head_hexsha": "4f818b0e0b0de52bc127dd77285b20ce3568c97a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-03-03T22:41:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T22:54:43.000Z", "avg_line_length": 38.9237875289, "max_line_length": 93, "alphanum_fraction": 0.6930105613, "num_tokens": 5507, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.5078118642792044, "lm_q1q2_score": 0.41751739958544676}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{tikz}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{tabularx}\n\\usepackage{multicol}\n\\usepackage{algpseudocode}\n\\usepackage{algorithm}\n\\usepackage{setspace}\n\n% Geometry \n\\usepackage{geometry}\n\\geometry{letterpaper, left=15mm, top=20mm, right=15mm, bottom=20mm}\n\n% Fancy Header\n\\usepackage{fancyhdr}\n\\renewcommand{\\footrulewidth}{0.4pt}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\chead{MAT 381 - Calculus 3}\n\\lfoot{CALU Spring 2021}\n\\rfoot{RDK}\n\n% Add vertical spacing to tables\n\\renewcommand{\\arraystretch}{1.4}\n\n\\onehalfspacing\n\n% Macros\n\\newcommand{\\definition}[1]{\\underline{\\textbf{#1}}}\n\n\\newenvironment{rcases}\n  {\\left.\\begin{aligned}}\n  {\\end{aligned}\\right\\rbrace}\n\n% Begin Document\n\\begin{document}\n\n\\section*{8.9 Improper Intgerals}\n\nThere are typically two types of improper integrals:\n\n\\begin{enumerate}\n\n    \\item The interval of integration is infinite \\\\\n    $ \\int_{1}^{\\infty} \\frac{1}{x^2} \\,dx $\n\n    \\item The integrand is unbounded on the interval of integration \\\\\n    $ \\int_{-1}^{1} \\frac{1}{x} \\,dx $\n\n\\end{enumerate}\n\nHow do you find the integral $\\int_{1}^{\\infty} \\frac{1}{x^2} \\,dx$?\n\nConsider the integral $\\int_{1}^{b} \\frac{1}{x^2} \\,dx$, where $b > 1$ is an arbitrary real number.\n\nThen we can write $\\lim_{b\\to\\infty} \\int_{1}^{b} \\frac{1}{x^2} \\,dx $\n\nChanging the infinity to a variable, and then taking the limit of the integral to infinity allows for a possible solution.\n\n\\subsubsection*{Examples}\n\n\\begin{itemize}\n\n    \\item $ \\int_{0}^{\\infty} \\frac{sin(x)}{x} \\,dx = \\lim_{b\\to\\infty} \\int_{0}^{b} \\frac{sin(x)}{x} \\,dx $\n\n    \\item $ \\int_{-\\infty}^{1} \\frac{e^x}{x^2} \\,dx = \\lim{a\\to\\infty} \\int_{a}^{1} \\frac{e^x}{x^2} \\,dx $\n\n\\end{itemize}\n\n\n\\subsubsection*{Example}\n\nFind, if possible: $ \\int_{1}^{\\infty} \\frac{1}{x^2} \\,dx $\n\n\\begin{enumerate}\n\n    \\item Rewrite as a limit \\\\ $\\lim_{b\\to\\infty} \\int_{1}^{b} \\frac{1}{x^2} \\,dx$\n\n    \\item Solve the integral first: \\\\\n    \\begin{equation*}\n        \\int_{1}^{b} \\frac{1}{x^2} \\,dx \\\\ \n        = -\\frac{1}{x} \\bigg\\rvert_{1}^{b} \\\\\n        = -\\frac{1}{b} + 1 \n    \\end{equation*}\n\n    \\item Then use that to find the limit: \\\\\n    \\begin{equation*}\n        \\lim_{b\\to\\infty} -\\frac{1}{b} + 1 = -\\frac{1}{\\infty} + 1 = 0 + 1 = 1\n    \\end{equation*}\n\n    \\item Thus $ \\int_{1}^{\\infty} \\frac{1}{x^2} \\,dx = 1 $\n\n\\end{enumerate}\n\n\\begin{itemize}\n    \\item An interval is said to \\definition{converge} when it goes to a finite value, and \\definition{diverge} when it evaluates to an infinite value.\n\\end{itemize}\n\n\n\\subsection*{Examples, Infinite Integrals}\n\nEvaluate the following integrals, or state if they if diverge.\n\n\\begin{enumerate}\n\n    \\item \\begin{flalign*}\n        &\\int_{2}^{\\infty} \\frac{1}{x} \\,dx &&\\\\\n        &= \\lim_{b\\to\\infty} \\int_{2}^{b} \\frac{1}{x} \\,dx &&\\\\\n        &= \\lim_{b\\to\\infty}( \\ln(x) \\bigg\\rvert_{2}^{b} ) &&\\\\\n        &= \\lim_{b\\to\\infty}( \\ln(b) - \\ln(2) ) &&\\\\\n        &= \\ln(\\infty) - \\ln(2) = \\infty &&\n    \\end{flalign*}\n    Therefore, the integral diverges.\n\n    \\item \\begin{flalign*}\n        &\\int_{-\\infty}^{0} e^{2x} \\,dx &&\\\\\n        &= \\lim_{a\\to-\\infty} \\int_{-a}{0} e^{2x} \\,dx &&\\\\\n        &= \\lim_{a\\to-\\infty} (\\frac{1}{2} e^{2x} \\bigg\\rvert_{a}^{0}) &&\\\\\n        &= \\lim_{a\\to-\\infty} ( \\frac{1}{2} - \\frac{1}{2e^{2a}} ) &&\\\\\n        &= \\frac{1}{2} - \\frac{1}{2e^{2\\infty}} &&\\\\\n        &= \\frac{1}{2} &&\n    \\end{flalign*}\n    Therefore, the integral converges.\n\n    \\item \\begin{flalign*}\n        & \\int_{-\\infty}^{\\infty} e^{4x} \\,dx &&\\\\\n        & = \\int_{-\\infty}^{0} e^{4x} \\,dx + \\int_{0}^{\\infty} e^{4x} \\,dx &&\\\\\n        & \\int_{-\\infty}^{0} e^{4x} \\,dx = \\lim_{a\\to\\-\\infty} ( \\frac{1}{4} e^{4x} \\bigg\\rvert_{a}^{0}) &&\\\\\n        & = \\lim_{a\\to-\\infty} (\\frac{1}{4} - \\frac{1}{4}e^{4a}) = \\frac{1}{4} &&\\\\\n        & \\int_{0}^{\\infty} e^{4x} \\,dx = \\lim_{b\\to\\infty} ( \\frac{1}{4} e^{4x} \\bigg\\rvert_{0}^{b}) &&\\\\\n        & = \\lim_{b\\to\\infty} (\\frac{1}{4}e^{4b} - \\frac{1}{4}) = \\infty &&\\\\\n        & = \\int_{-\\infty}^{0} e^{4x} \\,dx + \\int_{0}^{\\infty} e^{4x} \\,dx = \\frac{1}{4} + \\infty = \\infty&&\\\\\n    \\end{flalign*}\n    Therefore, the integral diverges.\n\n\\end{enumerate}\n\n\n\n\n\\end{document}", "meta": {"hexsha": "9c57547d062420931ee7e61355806370c4a8596f", "size": 4192, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MAT 381/Notes/08-09/notes.tex", "max_stars_repo_name": "Anthony91501/uwp-2022-spring", "max_stars_repo_head_hexsha": "2ca2b95d3a502551870fe3203ba4e97969d2835f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-01-15T21:17:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T05:53:56.000Z", "max_issues_repo_path": "MAT 381/Notes/08-09/notes.tex", "max_issues_repo_name": "Anthony91501/uwp-2022-spring", "max_issues_repo_head_hexsha": "2ca2b95d3a502551870fe3203ba4e97969d2835f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-29T01:30:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-31T17:51:39.000Z", "max_forks_repo_path": "MAT 381/Notes/08-09/notes.tex", "max_forks_repo_name": "Anthony91501/uwp-2022-spring", "max_forks_repo_head_hexsha": "2ca2b95d3a502551870fe3203ba4e97969d2835f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2022-01-28T19:39:27.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-23T21:09:09.000Z", "avg_line_length": 29.3146853147, "max_line_length": 151, "alphanum_fraction": 0.5763358779, "num_tokens": 1686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7690802423634963, "lm_q1q2_score": 0.4175054253925536}}
{"text": "\\documentclass[a4paper]{article}\n\n%% Language and font encodings\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[T1]{fontenc}\n\n%% Sets page size and margins\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\n\n%% Useful packages\n\\usepackage{titling}\n\\usepackage[table]{xcolor}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\graphicspath{{img/}}\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\n\\usepackage{multirow}\n\\usepackage{array}\n\\usepackage{dcolumn}\n\\usepackage{booktabs}\n\\usepackage{caption}\n\\usepackage{lscape}\n\\usepackage{wrapfig}\n\\usepackage{lipsum}  % generates filler text\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{amssymb}\n\\usepackage{url}\n\\usepackage{listings}\n\\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white\n\\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue\n\\definecolor{mylilas}{RGB}{170,55,241}\n\\usepackage[toc,page]{appendix}\n\n\\pretitle{\\begin{center}\\Huge\\bfseries}\n\\posttitle{\\par\\end{center}\\vskip 0.5em}\n\\preauthor{\\begin{center}\\Large\\ttfamily}\n\\postauthor{\\end{center}}\n\\predate{\\par\\large\\centering}\n\\postdate{\\par}\n\n\\title{THE EQUATIONS OF PLANETARY MOTION AND THEIR NUMERICAL SOLUTION}\n\\author{Jonathan Njeunje, Dinuka Sewwandi de Silva}\n% \\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\thispagestyle{empty}\n\n\\begin{abstract}\nEach day we ask ourselves questions about the big universe and how this great \"mechanics\" function in such an incredible stability over the centuries. Some great minds of Earth's history, such as Isaac Newton worked on the theory of gravitation presented in the Principia, this stood to be a major contribution in answering this question. By utilizing the theory we will focus in setting up the differential equations that describe planetary trajectories in our solar system, linearizing these equations and providing their solution with the help of numerical method implemented from scratch.\n\\end{abstract}\n\n\\section{Introduction}\n\nIn our solar system, all the planets have an elliptic trajectory around the sun and the sun is also non-static and describes a motion about a reference origin, like portrayed on the figure below.\n\\\\\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.6\\textwidth]{Solar.jpg}\n\\caption{Solar System}\n\\label{fig:SolarSystem}\n\\end{figure}\n\n% Figure~\\ref{fig:SolarSystem}\n\nThose elliptical motions (orbits) can best be figured out by understanding the general equation of planetary motion in the Cartesian co-ordinates system. Let us consider the following figure to best picture our scenario.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=.9\\textwidth]{cs.png}\n\\caption{Representation of two bodies under gravitational attraction in Cartesian co-ordinates}\n\\label{fig:cs}\n\\end{figure}\n\n\nIn this project we are going to derive the equations of planetary motion based on the assumption that the masses of the planets can be approximated to point masses. This is reasonable cue to the vast distances between bodies in the solar system.\n\nThen, according to the \\textit{Newton's law of gravitational force} acting on each of the masses we obtain the following. \n\n\\[\\textbf{F} = G\\frac{mm'}{r^2}({\\hat{\\textbf{r}}})\\]\n\\[\\textbf{F'} = G\\frac{mm'}{r^2}({-\\hat{\\textbf{r}}})\\]\n\\\\\nThe respective components F\\textsubscript{x}, F\\textsubscript{y} and F\\textsubscript{z}  of the force \\textbf{F}, are: \n\n\n\\[ F_x = F\\frac{x'-x}{r}; \\] \n\\[ F_y = F\\frac{y'-y}{r}; \\] \n\\[ F_z = F\\frac{z'-z}{r}. \\]\n\\\\\nFurthermore, following \\textit{Newton’s second law of dynamics} we obtain:\n\n\\[ F_x = m\\frac{d^2 x}{dt^2}; \\]\n\\[ F_y = m\\frac{d^2 y}{dt^2}; \\]\n\\[ F_z = m\\frac{d^2 z}{dt^2}.  \\]\n\n\\pagebreak\n\nCombining both set of equations, we finally get:\n\n\\[ \\frac{d^2 x}{dt^2} = Gm'\\frac{x'-x}{r^3}; \\]\n\\[ \\frac{d^2 y}{dt^2} = Gm'\\frac{y'-y}{r^3}; \\]\n\\[ \\frac{d^2 z}{dt^2} = Gm'\\frac{z'-z}{r^3}. \\]\n\n\\begin{equation}\n\\text{Where \\textbf{r}, is given by: \\space\\space\\space} r = \\sqrt{(x'-x)^2+(y'-y)^2+(z'-z)^2}\n\\end{equation}\n\nWhere $G$ is a gravitational force and $m$ and $M$ are masses of the given planet and Sun respectively, $r$ is the distance between the planet and the Sun and $F$ is the force.\n\n\\pagebreak\n\n\\section{IVP - Initial Value Problem}\nBy using the general second order ordinary differential equation system of planetary motion we will now be able to discuss the dynamics of such a motion for all the planets in our solar system including the Sun. In order to reach this realization we designed a global system of equations, accounting for all the interactions of \\textit{j} bodies of masses $m_{1},m_{2}...,m_{j}$ on a given body, $\\alpha$ of mass $m_{\\alpha}$.\n\nThen our system of equation is:\\\\\n\n$$\\dfrac{d^{2}x_{\\alpha}}{dt^{2}}=\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{x_{j}-x_{\\alpha}}{(r_{j,\\alpha})^{3}}$$\n$$\\dfrac{d^{2}y_{\\alpha}}{dt^{2}}=\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{y_{j}-y_{\\alpha}}{(r_{j,\\alpha})^{3}}$$\n$$\\dfrac{d^{2}z_{\\alpha}}{dt^{2}}=\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{z_{j}-z_{\\alpha}}{(r_{j,\\alpha})^{3}}$$\n$$r_{j,\\alpha}=\\sqrt[]{(x_{j}-x_{\\alpha})^{2}+(y_{j}-y_{\\alpha})^{2}+(z_{j}-z_{\\alpha})^{2}}$$\\\\\nwhere,\\\\\n$nb$ - Number of bodies which we consider\\\\\n$G$ - Constant of universal gravitation\\\\\n$m_{j}$ - Mass of body $j$\\\\\n$r_{j,\\alpha}$ - Distance between body $j$ and body $\\alpha$\\\\\n$x_{\\alpha},y_{\\alpha},z_{\\alpha}$ - Cartesian coordinates of body $\\alpha$\\\\\n$x_{j},y_{j},z_{j}$ - Cartesian coordinates of body $j$\\\\\\\\\nWe can convert this system of equations into a standard initial value problem in the following way:\\\\\n$$Y=\\begin{bmatrix}\nx\\\\y\\\\z\\\\v_{x}\\\\v_{y}\\\\v_{z}\n\\end{bmatrix}=\\begin{bmatrix}\nx\\\\y\\\\z\\\\\\dfrac{dx}{dt}\\\\\\dfrac{dy}{dt}\\\\\\dfrac{dz}{dt}\n\\end{bmatrix}$$\nthus,\\\\\n$$\\dfrac{dY}{dt}=F(t,Y)\\Rightarrow\\dfrac{d}{dt}\\begin{bmatrix}\nx\\\\y\\\\z\\\\v_{x}\\\\v_{y}\\\\v_{z}\n\\end{bmatrix}=\\begin{bmatrix}\nv_{x}\\\\v_{y}\\\\v_{z}\\\\\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{x_{j}-x_{\\alpha}}{(r_{j,\\alpha})^{3}}\\\\\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{y_{j}-y_{\\alpha}}{(r_{j,\\alpha})^{3}}\\\\\\sum_{j=1;j\\neq\\alpha}^{nb}Gm_{j}\\dfrac{z_{j}-z_{\\alpha}}{(r_{j,\\alpha})^{3}}\n\\end{bmatrix}$$\\\\\nwhere,\\\\\n$G=6.67E^{-11} m^{3}kg^{1}s^{-2}$  \\\\\n$nb := \\text{number of bodies} = 10 $\\\\\n\n\\pagebreak\n\n\\begin{landscape}\nAfter converting our $2^{nd}$ order system of ODE's to a $1^{st}$ order system of ODE's, system of equations, we needed a set of initial values for our subsequent ODE Solver. This set of initial states is obtained from the JPL (Jet Propulsion Lab) ephemeris database using the HORIZION web interface. This comprised of the initial states positions (both x y z co-ordinates) and velocities (both x y z co-ordinates), masses and mean radius of all 10 major bodies involved in our solar system.\\\\\n\nThe following table summarizes this initial states corresponding to the solar system configuration on April 6th, 2018:\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n% Table generated by Excel2LaTeX from sheet 'IVP (Sec)'\n\\begin{table}[htbp]\n  \\centering\n  \\caption{Initial States from JPL HORIZONS System}\n    \\begin{tabular}{|c|l|r|r|r|r|r|r|r|r|}\n\\cmidrule{3-10}    \\multicolumn{1}{r}{} &            & \\multicolumn{3}{c|}{\\cellcolor[rgb]{ .788,  .788,  .788}\\textbf{POSITION (m)}} & \\multicolumn{3}{c|}{\\cellcolor[rgb]{ .788,  .788,  .788}\\textbf{VELOCITY (m/sec)}} & \\multicolumn{1}{l|}{\\cellcolor[rgb]{ .788,  .788,  .788}\\textbf{(kg)}} & \\multicolumn{1}{l|}{\\cellcolor[rgb]{ .788,  .788,  .788}\\textbf{(m)}} \\\\\n    \\midrule\n    \\multicolumn{1}{|l|}{\\textbf{\\#}} & \\textbf{BODY} & \\multicolumn{1}{l|}{\\textbf{PX}} & \\multicolumn{1}{l|}{\\textbf{PY}} & \\multicolumn{1}{l|}{\\textbf{PZ}} & \\multicolumn{1}{l|}{\\textbf{VX}} & \\multicolumn{1}{l|}{\\textbf{VY}} & \\multicolumn{1}{l|}{\\textbf{VZ}} & \\multicolumn{1}{l|}{\\textbf{MASS}} & \\multicolumn{1}{l|}{\\textbf{RADIUS}} \\\\\n    \\midrule\n    \\rowcolor[rgb]{ .851,  .882,  .949} 1          & SUN        & 1.81899E+08 & 9.83630E+08 & -1.58778E+07 & -1.12474E+01 & 7.54876E+00 & 2.68723E-01 & 1.98854E+30 & 6.95500E+08 \\\\\n    \\midrule\n    2          & MERCURY    & -5.67576E+10 & -2.73592E+10 & 2.89173E+09 & 1.16497E+04 & -4.14793E+04 & -4.45952E+03 & 3.30200E+23 & 2.44000E+06 \\\\\n    \\midrule\n    \\rowcolor[rgb]{ .851,  .882,  .949} 3          & VENUS      & 4.28480E+10 & 1.00073E+11 & -1.11872E+09 & -3.22930E+04 & 1.36960E+04 & 2.05091E+03 & 4.86850E+24 & 6.05180E+06 \\\\\n    \\midrule\n    4          & EARTH      & -1.43778E+11 & -4.00067E+10 & -1.38875E+07 & 7.65151E+03 & -2.87514E+04 & 2.08354E+00 & 5.97219E+24 & 6.37101E+06 \\\\\n    \\midrule\n    \\rowcolor[rgb]{ .851,  .882,  .949} 5          & MARS       & -1.14746E+11 & -1.96294E+11 & -1.32908E+09 & 2.18369E+04 & -1.01132E+04 & -7.47957E+02 & 6.41850E+23 & 3.38990E+06 \\\\\n    \\midrule\n    6          & JUPITER    & -5.66899E+11 & -5.77495E+11 & 1.50755E+10 & 9.16793E+03 & -8.53244E+03 & -1.69767E+02 & 1.89813E+27 & 6.99110E+07 \\\\\n    \\midrule\n    \\rowcolor[rgb]{ .851,  .882,  .949} 7          & SATURN     & 8.20513E+10 & -1.50241E+12 & 2.28565E+10 & 9.11312E+03 & 4.96372E+02 & -3.71643E+02 & 5.68319E+26 & 5.82320E+07 \\\\\n    \\midrule\n    8          & URANUS     & 2.62506E+12 & 1.40273E+12 & -2.87982E+10 & -3.25937E+03 & 5.68878E+03 & 6.32569E+01 & 8.68103E+25 & 2.53620E+07 \\\\\n    \\midrule\n    \\rowcolor[rgb]{ .851,  .882,  .949} 9          & NEPTUNE    & 4.30300E+12 & -1.24223E+12 & -7.35857E+10 & 1.47132E+03 & 5.25363E+03 & -1.42701E+02 & 1.02410E+26 & 2.46240E+07 \\\\\n    \\midrule\n    10          & PLUTO      & 1.65554E+12 & -4.73503E+12 & 2.77962E+10 & 5.24541E+03 & 6.38510E+02 & -1.60709E+03 & 1.30700E+22 & 1.19500E+06 \\\\\n    \\bottomrule\n    \\end{tabular}%\n  \\label{tab:addlabel}%\n\\end{table}%\n\\end{landscape}\n\n\n\\pagebreak\n\n\\section{Numerical method description}\nBefore diving into writing and implementing our own numerical method of ODE Solver we needed to verify our designed IVP model of the solar system by existing and certified ODE solvers such as \"ode45\" and \"ode113\". These two solvers amongst many others where chosen for particular reasons we will discuss in the next section.\\\\\n\nAfter simulating our IVP with the above solvers, we obtained positive results (discussed in the next section) validating our designed IVP model for the solar system.\\\\\n\nThe next step was to implement from scratch our own ODE solver and apply the designed IVP to it. We made the choice of implementing an \\textbf{Explicit Runge-Kutta method (ERK)}. But before we could used this numerical method, we first needed to define our RK-stages $(\\nu)$, RK-nodes $(c_{i})$, RK-weights $(b_{i})$ and RK-matrix $(A=[a_{ij}])$. And, verify its order of convergence, exactness and stability.\n\\\\\\\\The general equations of an ERK is:\\\\\n$$y_{n+1}=y_{n}+h\\sum_{j=1}^{\\nu}b_{j}f(t_n+c_{j}h,\\xi_{j})$$\n\\\\where\\\\  \n\\indent$\\xi_{1}=y_{n}$\\\\\n\\indent$\\xi_{2}=y_{n}+ha_{2,1}f(t_{n},\\xi_{1})$\\\\\n\\indent$\\xi_{3}=y_{n}+ha_{3,1}f(t_{n},\\xi_{1})+ha_{3,2}f(t_{n}+c_{2}h,\\xi_{2})$\\\\\n\\indent\\;\\;\\;\\;\\;\\vdots\\\\\n\\indent$\\xi_{i}=y_{n}+h\\sum_{j=1}^{i-1}a_{i,j}f(t_n+c_{j}h,\\xi_{j}),\\;\\;\\;\\;i=1,\\ldots,\\nu$\\\\\n\\\\and $h$ is the step size of our time span. According to our designed IVP, $\\xi_{i}$ will be a vector of $6*nb = 6*10=60$ elements. Similarly, $y_{n+1}$ also will be a vector of 60 elements.\n\n\\subsection{Definition of our RK method}\nThe chosen ERK for our implementation has the following parameters:\n\n\n\\[ \\nu = 4\\\\ \\]\n\\[ c = \\begin{bmatrix}\n\t0 & .5 & .5 & 1\n\\end{bmatrix} \\]\n\\[ b = \\begin{bmatrix}\n\t1/6 & 1/3 & 1/3 & 1/6\n\\end{bmatrix} \\]\n\\[ A=\n  \\begin{bmatrix}\n    0 & 0 & 0 & 0 \\\\ \n    .5 & 0 & 0 & 0 \\\\ \n    0 & .5 & 0 & 0 \\\\ \n    0 & 0 & 1 & 0\n  \\end{bmatrix} \\]\nThis method is identified as an Explicit Runge-Kutta method due to its lower triangular matrix, A. Additionally, to the above definition, the $\\xi_{i}$'s are as follows:\\\\\n\\indent$\\xi_{1}=y_{n}$\\\\\n\\indent$\\xi_{2}=y_{n}+.5hf(t_{n},\\xi_{1})=y_{n}+.5hf(t_{n},y_{n})$\\\\\n\\indent$\\xi_{3}=y_{n}+.5hf(t_{n}+c_{2}h,\\xi_{2})=y_{n}+.5hf\\Big(t_{n}+.5h,y_{n}+.5hf(t_{n},y_{n})\\Big)$\\\\\n\\indent$\\xi_{4}=y_{n}+hf(t_{n}+c_{3}h,\\xi_{3})=y_{n}+hf\\Big(t_{n}+.5h,y_{n}+.5hf\\Big(t_{n}+.5h,y_{n}+.5hf(t_{n},y_{n})\\Big)\\Big)$\\\\\\\\\nBy applying these $\\xi_{i}$'s on the general ERK formula, we can predict order of convergence of this method.\n\n\n\\subsection{Order of convergence of the chosen RK}\nThe chosen ERK method defined in the previous subsection is of stage, $\\nu=4$ and thus of order 4. This claim can further be verified by applying the ERK on the following IVP; applied under different values of the step size and interpreting the resultant graphs.\\\\\n\nIVP: \\space $y'(t)=-y$; \\space $y_{0}=1$ when $t=0$\\\\\n\nThe ERK will by applied with step sizes: $h=.1/2^k$, \\space with $k=1,2,3,4. $ \\\\\n\nThe exact solution for this IVP is known to be: $y(t)=e^{-t}$ \\\\\n\nAfter running the written MatLab codes for this text, the following graphs were obtained:\n\n\\begin{figure}[!ht]\n\\centering\n\\includegraphics[width=1\\textwidth]{testeer.png}\n\\caption{Error/Error-ratio test}\n\\label{fig:testeer}\n\\end{figure}\n\nBy inspecting the error-ratio plot on the right of the above figure we observe a trend:  $$\\textrm{error-ratio}\\rightarrow 16 = 2^4 = 2^p$$\n\nThis interpretation let us conclude that the order of convergence, $p=4$.\\\\\\\\\nAccording to the definition of exactness, a given method is exact for the polynomials of degree less than or equal to $d$ , where $d$ is the degree of the exactness and usually it is equal to the order of the method. Therefore, the chosen ERK method is exact for the polynomials of degree less than or equal to 4. Because, 4 is the order of convergence of this ERK method.\n\nAdditionally, it can be interpreted from the errors bar chart that the ERK method of oder 4 is exact, as the error is in a close neighborhood of zero. \n\n\\subsection{verification of stability of the chosen RK}\nThe stability of RK method can be define according to the general equation of RK and the following equations. Then apply RK method for the following IVP.\\\\\n$$y'=\\lambda y$$\n$$y(t_{0})=y_{0}$$\nNow consider the equations for the $\\xi$'s. In general its given by:\\\\\n$$\\xi_{k}=y_{n}+h\\lambda\\sum_{i=1}^{k}a_{k,i}f(t_n+c_{i}h,\\xi_{i})$$\\\\\nIn this equation, $\\sum_{i=1}^{k}a_{k,i}f(t_n+c_{i}h,\\xi_{i})$ is a dot product of the $k^{th}$ row of the matrix $A$ and a vector of $\\xi$. Let's define some vectors as follows,\\\\\n$$\\xi=\\begin{bmatrix}\n\\xi_{1}\\\\\\xi_{2}\\\\\\vdots\\\\\\xi_{\\nu}\n\\end{bmatrix},\\;\\; b=\\begin{bmatrix}\nb_{1}\\\\b_{2}\\\\\\vdots\\\\b_{\\nu}\n\\end{bmatrix},\\;\\;\\textbf{1}=\\begin{bmatrix}\n1\\\\1\\\\\\vdots\\\\1\n\\end{bmatrix}$$\nThen, the system of equations for $\\xi$'s can be represented as;\n$$\\xi=y_{n}.\\textbf{1}+h\\lambda A\\xi\\Rightarrow \\xi=(I-h\\lambda A)^{-1}.\\textbf{1}.y_{n}$$ \nBy using this $\\xi$ in the general equation of RK, we can be obtain,\n$$y_{n}=(1+zb^{T}(I-zA)^{-1}\\textbf{1})^{n}y_{0}\\;\\;\\;where\\;\\;z=h\\lambda$$\nThen the stability domain of RK can be find when $\\left|r(z)\\right|<1$ where $r(z)=1+zb^{T}(I-zA)^{-1}\\textbf{1}$.\\\\\\\\\nBy using above condition, can be find the stability domain of the chosen ERK, which is mentioned in subsection $(3.1)$. Therefore,\\\\\\\\\n$I-zA=\n  \\begin{bmatrix}\n    1 & 0 & 0 & 0 \\\\ \n    -.5z & 1 & 0 & 0 \\\\ \n    0 & -.5z & 1 & 0 \\\\ \n    0 & 0 & -z & 1\n  \\end{bmatrix} $ and $(I-zA)^{-1}=\n  \\begin{bmatrix}\n    1 & 0 & 0 & 0 \\\\ \n    .5z & 1 & 0 & 0 \\\\ \n    .25z^{2} & .5z & 1 & 0 \\\\ \n    .25z^{3} & .5z^{2} & z & 1\n  \\end{bmatrix} $\\\\\\\\\\\\\n  $b^{T}(I-zA)^{-1}\\textbf{1}=\\begin{bmatrix}\n  1/6 & 1/3 & 1/3 & 1/6\n  \\end{bmatrix}\\begin{bmatrix}\n    1 & 0 & 0 & 0 \\\\ \n    .5z & 1 & 0 & 0 \\\\ \n    .25z^{2} & .5z & 1 & 0 \\\\ \n    .25z^{3} & .5z^{2} & z & 1\n  \\end{bmatrix}\\begin{bmatrix}\n  1 \\\\ 1 \\\\ 1 \\\\ 1\n  \\end{bmatrix}=1+\\dfrac{z}{2}+\\dfrac{z^{2}}{6}+\\dfrac{z^{3}}{24}$\\\\\\\\\n  $\\Rightarrow r(z)=1+z\\Big(1+\\dfrac{z}{2}+\\dfrac{z^{2}}{6}+\\dfrac{z^{3}}{24}\\Big)=1+z+\\dfrac{z^{2}}{2}+\\dfrac{z^{3}}{6}+\\dfrac{z^{4}}{24}$\\\\\\\\\n  By using Mathematica codes for $r(z)$, the following stability (shaded) region was obtained:\\\\\n  \n\\begin{figure}[!ht]\n\\centering\n\\includegraphics[width=0.5\\textwidth]{StabilityDomain.png}\n\\caption{Stability domain}\n\\label{fig:stability_domain}\n\\end{figure}  \n\nAccording to this stability region it can be concluded that, the chosen ERK method is not A-stable. Because, for a method to be A-stable it must include $\\mathbb{C}^{-}$ in its stability region. Despite the fact that an \nA-stability wasn't reached, necessary stability domain could be achieved. This achieved stability will be useful the next section.\n\n\\pagebreak\n\n\\section{Numerical Results and Discussion}\nAfter a repeated set of simulations we made some adjustments regarding the number of planets considered and the step size to use with the different ODE Solvers.\\\\\n\nThe adjustment made on the number of planet consider, dealt with the non-consideration of planet Pluto. This adjustment was made in order to reduce the computational intensity of our code and enhanced faster calculations.\\\\\n\nThe second adjustment made on the step size, mainly had to constrain the step size to a value of 1. This adjustment was done to obtain better stability with our set of non-stiff ODE Solvers. Mainly, due to the fact that our IVP is a Stiff IVP, and, thereby necessitated (for more appropriate circumstances) a stiff ODE Solver with an A-stability region.\\\\\n\nNonetheless, with the appropriate adjustments, the following satisfactory results were obtained and interpreted as follows: \\\\\n\n\n\\subsection{\\textit{Build-in ode45}}\n\nThe first ODE used was the ode45. This build-in MatLab ODE Solver was chosen to test the IVP model and make sure it is designed correctly. The result obtained, Fig~\\ref{fig:Solar_System_-_ode45}, showed great instability of this ODE Solver due to the stiffness of the IVP. And, the added adjustment couldn't lead to better results.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode45.png}\n\\caption{Solar System Simulation - ode45}\n\\label{fig:Solar_System_-_ode45}\n\\end{figure}\n\nIn the next figure, Fig~\\ref{fig:Solar_System_-_ode45_-_ipsim}, we can observe the instability as the parameters of Mercury tend to decay much faster than that of the other planets. This behavior generated an error caused by the lack of better accuracy.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode45_-_ipsim.png}\n\\caption{Solar System Simulation - ode45 - Inner planets }\n\\label{fig:Solar_System_-_ode45_-_ipsim}\n\\end{figure}\n\nThis ODE Solver couldn't complete the solution and crashed. The following figures show the plot of the distance from the different bodies to the reference point which in this case is not the sun but the origin. \n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode45_-_ip.png}\n\\caption{Distance from origin - ode45 - Inner planet}\n\\label{fig:Solar_System_-_ode45_-_ip}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode45_-_op.png}\n\\caption{Distance from origin - ode45 - Outer planet}\n\\label{fig:Solar_System_-_ode45_-_op}\n\\end{subfigure}\n\\begin{subfigure}{.7\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode45_-_sun.png}\n\\caption{Distance from origin - ode45 - Sun}\n\\label{fig:Solar_System_-_ode45_-_sun}\n\\end{subfigure} \n\\caption{Distance from origin}\n\\label{fig:Solar_System_-_ode45_-_all}\n\\end{figure} \n\n\\pagebreak\n\n\\subsection{\\textit{Build-in ode113}}\nBy observing from the previous method that the modeled IVP had stringent error tolerances, it was necessary to retry the test of the IVP with higher accuracy ODE Solver as ode113. The ode113 is also a MatLab build-in Solver. The figure, Fig~\\ref{fig:Solar_System_-_ode113}, depicts the result obtained.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode113.png}\n\\caption{Solar System Simulation - ode113}\n\\label{fig:Solar_System_-_ode113}\n\\end{figure}\n\nThis result had better stability and calculated a complete solution for a time span corresponding to the period of revolution of the planet Neptune (165 earth years). The result lead to a validation of the IVP model.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode113_-_ipsim.png}\n\\caption{Solar System Simulation - ode113 - Inner planets }\n\\label{fig:Solar_System_-_ode113_-_ipsim}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode113_-_ip.png}\n\\caption{Distance from origin - ode113 - Inner planet}\n\\label{fig:Solar_System_-_ode113_-_ip}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode113_-_op.png}\n\\caption{Distance from origin - ode113 - Outer planet}\n\\label{fig:Solar_System_-_ode113_-_op}\n\\end{subfigure}\n\\begin{subfigure}{.7\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode113_-_sun.png}\n\\caption{Distance from origin - ode113 - Sun}\n\\label{fig:Solar_System_-_ode113_-_sun}\n\\end{subfigure} \n\\caption{Distance from origin}\n\\label{fig:Solar_System_-_ode113_-_all}\n\\end{figure} \n\n\n\n\\subsection{\\textit{Implemented ERK of order 4, ode652}}\nThe final step was to build from scratch an ODE Solver to attain better (or similar) results as those obtained with  ode113.\\\\\n\nThe ODE Solver, ode652, coded on MatLab implemented the ERK of order 4 earlier described in the Numerical method section of this paper. This implementation achieved better stability compared to ode113 and ode45. A complete simulation of a time span equivalent to the period of the planet Neptune was obtained. Fig~\\ref{fig:Solar_System_-_ode652}, shows this result and Fig~\\ref{fig:Solar_System_-_ode652_-_ipsim}, shows a bigger scale of the inner planets of the solar system.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode652.png}\n\\caption{Solar System Simulation - ode652}\n\\label{fig:Solar_System_-_ode652}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode652_-_ipsim.png}\n\\caption{Solar System Simulation - ode652 - Inner planets }\n\\label{fig:Solar_System_-_ode652_-_ipsim}\n\\end{figure}\n\nThe above figure and of the distances from the reference point below, clearly shows a more stable revolution of Mercury. This result is obtained by a solution made with better accuracy compared to those of ode113 and ode45.\n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode652_-_ip.png}\n\\caption{Distance from origin - ode652 - Inner planet}\n\\label{fig:Solar_System_-_ode652_-_ip}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode652_-_op.png}\n\\caption{Distance from origin - ode652 - Outer planet}\n\\label{fig:Solar_System_-_ode652_-_op}\n\\end{subfigure}\n\\begin{subfigure}{.7\\textwidth}\n\\centering\n\\includegraphics[width=1\\textwidth]{Solar_System_-_ode652_-_sun.png}\n\\caption{Distance from origin - ode652 - Sun}\n\\label{fig:Solar_System_-_ode652_-_sun}\n\\end{subfigure} \n\\caption{Distance from origin}\n\\label{fig:Solar_System_-_ode652_-_all}\n\\end{figure} \n\nWith this implementation the stability domain portrait by the chosen ERK of order 4, showed to sufficient (under certain adjustments) for the obtained solution. \n\n\\pagebreak\n\n\\section{Conclusion}\nAs a summary, the implemented method discussed in this paper is a non A-stable method. Nonetheless, this method had a stability region necessary and sufficient for our implementation. The modeled IVP mentioned under section 2 was analyzed to be stiff due to the existence of some its parameters who tend to grow faster than others (Mercury's). Thereby, higher stability needed to be reached for satisfactory result.\\\\\n\nAfter, attempting solutions of the IVP with build-in MatLab ODE Solvers, we realized a very high error dependency of the IVP model. Due to this condition, the choice of implementing the ERK of order 4 was made appropriate because of the better accuracy/stability it provided under certain adjustments.\\\\\n\nFinally, we were able to implement a method, ode652, with much more better stability than certain build-in MatLab methods, ode45 and ode113 of quite similar non A-stability behavior, to solve the modeled IVP of solar system dynamics.\\\\ \n\n\\pagebreak\n\n\\lstset{language=Matlab,%\n    %basicstyle=\\color{red},\n    breaklines=true,%\n    morekeywords={matlab2tikz},\n    keywordstyle=\\color{blue},%\n    morekeywords=[2]{1}, keywordstyle=[2]{\\color{black}},\n    identifierstyle=\\color{black},%\n    stringstyle=\\color{mylilas},\n    commentstyle=\\color{mygreen},%\n    showstringspaces=false,%without this there will be a symbol in the places where there is a space\n    numbers=left,%\n    numberstyle={\\tiny \\color{black}},% size of the numbers\n    numbersep=9pt, % this defines how far the numbers are from the text\n    emph=[1]{for,end,break},emphstyle=[1]\\color{red}, %some words to emphasise\n    %emph=[2]{word1,word2}, emphstyle=[2]{style},    \n}\n\n\\pagebreak\n\n\\begin{thebibliography}{9}\n\n\\bibitem{latexcompanion} \nARIEH ISERLES, University of Cambridge, (1992), \nA First Course in the Numerical Analysis\nof Differential Equations\n\n\\bibitem{NAZA} \nNAZA, (2018), HORIZONS Web-Interface,\n\\\\\\url{https://ssd.jpl.nasa.gov/horizons.cgi#top}\n\n\\bibitem{InfoPlease} \nInfoPlease, (2018), Basic Planetary Data,\n\\\\\\url{https://www.infoplease.com/science-health/solar-system/basic-planetary-data}\n\n\\bibitem{MATLAB} \nMATLAB, (2018), Choose an ODE Solver - MATLAB and Simulink,\n\\\\\\url{https://www.mathworks.com/help/matlab/math/choose-an-ode-solver.html}\n\n\\bibitem{Wikipedia1} \nWikipedia, (25 October 2017), List of Runge–Kutta methods,\n\\\\\\url{https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods}\n\n\\bibitem{Guido} \nGuido Kanschat, (May 2, 2018), Numerical Analysis of Ordinary Differential Equations,\n\\\\\\url{https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods}\n\n\\bibitem{Kyriacos} \nKyriacos Papadatos, (Unknown), THE EQUATIONS OF PLANETARY MOTION AND THEIR SOLUTION,\n\\\\\\url{http://gsjournal.net/Science-Journals/Research%20Papers-Astrophysics/Download/3763}\n\n% \\bibitem{Wikipedia1} \n% Author, (Date), Title,\n% \\\\\\url{url}\n\n\\end{thebibliography}\n\n\\pagebreak\n\n\\begin{appendices}\n\\lstinputlisting{codes/ode652.m}\n\\end{appendices}\n\n\\end{document}", "meta": {"hexsha": "3b74c868c2f604b9682ed18ac491cc87cb57c4ac", "size": 26342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/main.tex", "max_stars_repo_name": "jonathannjeunje/Planetary_Motion-Solar_System", "max_stars_repo_head_hexsha": "d971afb31ed93446c829695e9d233038e84d8acb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/main.tex", "max_issues_repo_name": "jonathannjeunje/Planetary_Motion-Solar_System", "max_issues_repo_head_hexsha": "d971afb31ed93446c829695e9d233038e84d8acb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/main.tex", "max_forks_repo_name": "jonathannjeunje/Planetary_Motion-Solar_System", "max_forks_repo_head_hexsha": "d971afb31ed93446c829695e9d233038e84d8acb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.7814814815, "max_line_length": 592, "alphanum_fraction": 0.7094753625, "num_tokens": 8747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832354982645, "lm_q2_score": 0.7745833789613197, "lm_q1q2_score": 0.41748745575575047}}
{"text": "\\chapter{Lecture 6 May 14th 2018}\n\\label{chp:lecture_6_may_14th_2018}\n% chapter Lecture 6 May 14th 2018\n\n\\section{Subgroups (Continued 2)}\n\\label{sec:subgroups_continued_2}\n% section Subgroups (Continued 2)\n\n\\subsection{Alternating Groups}\n\\label{sub:alternating_groups}\n% subsection Alternating Groups\n\nRecall that $\\forall \\sigma \\in S_n$, with $\\sigma \\neq \\epsilon$, $\\sigma$ can be uniquely decomposed (up to the order) as disjoint cycles of length at least $2$. We will now present a related concept.\n\n\\begin{defn}[Transposition]\\label{defn:transposition}\n\\index{Transposition}\n  A \\hlnoteb{transposition} $\\sigma \\in S_n$ is a cycle of length $2$, i.e. $\\sigma = \\begin{pmatrix} a & b \\end{pmatrix}$, where $a, b \\in \\{1, ..., n\\}$ and $a\\ neq b$.\n\\end{defn}\n\n\\begin{eg}\n  We have that\\sidenote{If we apply the permutations on the right hand side, we have that\n    \\begin{gather*}\n      1 \\quad 2 \\quad 3 \\quad 4 \\quad 5 \\\\\n      \\downarrow \\\\\n      1 \\quad 2 \\quad 3 \\quad 5 \\quad 4 \\\\\n      \\downarrow \\\\\n      1 \\quad 4 \\quad 3 \\quad 5 \\quad 2 \\\\\n      \\downarrow \\\\\n      2 \\quad 4 \\quad 3 \\quad 5 \\quad 1\n    \\end{gather*}\n  }\n  \\begin{equation*}\n    \\begin{pmatrix} 1 & 2 & 4 & 5 \\end{pmatrix} = \\begin{pmatrix} 1 & 2 \\end{pmatrix} \\begin{pmatrix} 2 & 4 \\end{pmatrix} \\begin{pmatrix} 4 & 5 \\end{pmatrix}\n  \\end{equation*}\n  Also, we can show that\\sidenote{\n  \\begin{ex}\n    Show that \\autoref{eq:transposition_eg} is true.\n  \\end{ex}\n\n  \\begin{ex}\n    Play around with the same idea and create a few of your own transpositions. Note that you will only be able to get an odd number of tranpositions (why?).\n  \\end{ex}\n  }\n  \\begin{equation}\\label{eq:transposition_eg}\n    \\begin{pmatrix} 1 & 2 & 4 & 5 \\end{pmatrix} = \\begin{pmatrix} 2 & 3 \\end{pmatrix} \\begin{pmatrix} 1 & 2 \\end{pmatrix} \\begin{pmatrix} 2 & 5 \\end{pmatrix} \\begin{pmatrix} 1 & 3 \\end{pmatrix} \\begin{pmatrix} 2 & 4 \\end{pmatrix}\n  \\end{equation}\n\\end{eg}\n\nObserve that the factorization into transpositions are \\hlimpo{not unique or disjoint}. However, the following property is true.\n\n\\begin{thm}[Parity Theorem]\\label{thm:parity_theorem}\n\\index{Parity Theorem}\n  If a permutations $\\sigma$ has $2$ factorizations\n  \\begin{equation*}\n    \\sigma = \\gamma_1 \\gamma_2 \\hdots \\gamma_r = \\mu_1 \\mu_2 \\hdots \\mu_s,\n  \\end{equation*}\n  where each $\\gamma_i$ and $\\mu_j$ are transpositions, then $r \\equiv s \\mod 2$.\n\\end{thm}\n\n\\marginnote{\n  I have referred to the following source: \\url{https://www.maa.org/sites/default/files/images/upload_library/4/vol1/parity/ParityJOKHistory.html}. In the literature review of the author, there are (at least) 6 approaches to proving the statement, some argued to be better or more intutive than the other. Recent proofs, as mentioned in the article, use a reduction method (or algorithm) to proof an alternate version of our statement. I intended to study the proof, but ran short on time, and so I shall present my understanding of the proof provided in Dummit and Foote's 3rd Edition of Abstract Algebra. My opinion of the proof presented in the said book is that it is not immediately intuitive and relies on subtle connections to the actual statement, which is why I looked into other sources and found the source above.\n\n  For the proof provided by Dummit and Foote, as well as in some of the other proofs that I have come across, the Parity Theorem is presented as a statement that is different from, but equivalent to, our statement here.\n}\n\n\\begin{proof}\n  Let $x_1, x_2, ..., x_n$ be distinct variables. Let $\\Delta$ be the following product:\n  \\begin{equation*}\n    \\Delta = \\prod_{1 \\leq i < j \\leq n} (x_i - x_j).\n  \\end{equation*}\n  For each $\\sigma \\in S_n$, let $\\sigma$ act on $\\Delta$ by permuting the indices of the variables so as to permute the variables themselves, i.e.\n  \\begin{equation*}\n    \\sigma( \\Delta ) = \\prod_{1 \\leq i < j \\leq n} ( x_{\\sigma(i)} - x_{\\sigma(j)} ).\n  \\end{equation*}\n  Then for each $(x_i - x_j)$ in the product $\\Delta$, after applying $\\sigma$, we have that the result is either $(x_k - x_l)$ or $(x_l - x_k)$ for $1 \\leq k < l \\leq n$ but not both. In $\\sigma(\\Delta)$, for each of the factors, if we have $(x_l - x_k)$ for $1 \\leq k < l \\leq n$, rewrite that factor as $- (x_k - x_l)$. Now if we collect all the $(-1)$'s, we get that $\\sigma(\\Delta) = \\pm \\Delta$ depending on \\textbf{whether if there is an odd or even number of factors that are of the form $(x_l - x_k)$ with $k < l$}. From here, we can use the definition of a sign of a permutation (as introduced in class on May 30th, 2018) and write the sign as\n  \\begin{equation*}\n    \\sign(\\sigma) = \\begin{cases}\n      1 & \\text{if } \\sigma(\\Delta) = \\Delta \\\\\n      -1 & \\text{if } \\sigma(\\Delta) = -\\Delta\n    \\end{cases}.\n  \\end{equation*}\n  As mentioned in class, the sign of a permutation is a homomorphism. Now for each $\\sigma \\in S_n$, we can express the permutation as a product of disjoint cycles. Consider the simplest case where $\\sigma$ is a permutation with only one cycle. We know that we can rewrite $\\sigma$ as a product of transpositions. Suppose $\\sigma = \\gamma_1 \\gamma_2 ... \\gamma_r$ for some $r > 0$, where each $\\gamma_i$, $1 \\leq i \\leq r$, is a transposition. We then have that\n  \\begin{equation*}\n    \\sign(\\sigma) = \\sign(\\gamma_1) \\sign(\\gamma_2) ... \\sign(\\gamma_r)\n  \\end{equation*}\n  Note that since transpositions are odd permutations, we essentially have\n  \\begin{equation*}\n    \\sign(\\sigma) = (-1)^r.\n  \\end{equation*}\n  We have that if $\\sign(\\sigma) = 1$, then $r$ must be even, which coincides with our bolded argument above. Similarly, if $\\sign(\\sigma) = -1$, we have that $r$ must be odd. Therefore, if we have that\n  \\begin{equation*}\n    \\sigma = \\gamma_1 \\gamma_2 ... \\gamma_r = \\mu_1 \\mu_2 ... \\mu_s,\n  \\end{equation*}\n  where $s > 0$ and the $\\mu_j$'s, for $1 \\leq j \\leq s$, are transpositions, $r$ and $m$ must either be both even or both odd. In other words, $r \\equiv s \\mod 2$.\n  \n  For cases with more than one cycle, we can consider the individual cycles and the homomorphicity of the sign will extend our above argument for permutations that is a product of more than one disjoint cycle.\\qed\n\\end{proof}\n\n\\begin{defn}[Odd and Even Permutations]\\label{defn:odd_and_even_permutations}\n\\index{Odd Permutations}\\index{Even Permutations}\n  A permutation $\\sigma$ is even (or odd) if it can be written as a product of an even (or odd) number of transpositions. By \\autoref{thm:parity_theorem}, a permutation must either be even or odd, but not both.\n\\end{defn}\n\n\\begin{thm}[Alternating Group]\\label{thm:alternating_group}\n\\index{Alternating Group}\n  For $n \\geq 2$, let $A_n$ denote the set of all even permutations in $S_n$. Then\n  \\begin{enumerate}\n    \\item $\\epsilon \\in A_n$\n    \\item $\\forall \\sigma, \\tau \\in A_n \\enspace \\sigma \\tau \\in A_n$ and $\\exists \\sigma^{-1} \\in A_n$ such that $\\sigma \\sigma^{-1} = \\epsilon = \\sigma^{-1} \\sigma$\n    \\item $\\abs{A_n} = \\frac{1}{2} n!$\n  \\end{enumerate}\n\\end{thm}\n\n\\begin{note}\n  From items 1 and 2, we know that $A_n$ is a subgroup of $S_n$. $A_n$ is called the \\hlnoteb{alternating subgroup of degree $n$}.\n\\end{note}\n\n\\begin{proof}\n  \\begin{enumerate}\n    \\item We have that $\\epsilon = \\begin{pmatrix} 1 & 2 \\end{pmatrix} \\begin{pmatrix} 1 & 2 \\end{pmatrix}$. Thus $\\epsilon$ is even and so $\\epsilon \\in A_n$.\n    \\item $\\forall \\sigma, \\tau \\in A_n$, we may write\n      \\begin{align*}\n        \\sigma &= \\sigma_1 \\sigma_2 \\hdots \\sigma_r \\quad \\text{and} \\\\\n        \\tau   &= \\tau_1 \\tau_2 \\hdots \\tau_s,\n      \\end{align*}\n      where $\\sigma_i, \\tau_j$ are transpositions, and $r, s$ are even integers. Then\n      \\begin{equation*}\n        \\sigma \\tau = \\sigma_1 \\sigma_2 \\hdots \\sigma_r \\tau_1 \\tau_2 \\hdots \\tau_s\n      \\end{equation*}\n      is a product of $(r + s)$ transpositions, and thus $\\sigma \\tau$ is even. Thus $\\sigma \\tau \\in A_n$.\n\n      For the inverse, note that since $\\sigma_i$ is a transposition, we have that $\\sigma_i^2 = \\epsilon$ and thus $\\sigma_i^{-1} = \\sigma_i$. It follows that\n      \\begin{align*}\n        \\sigma^{-1} &= (\\sigma_1 \\sigma_2 \\hdots \\sigma_r)^{-1} \\\\\n          &= \\sigma_r^{-1} \\sigma_{r - 1}^{-1} \\hdots \\sigma_2^{-1} \\sigma_1^{-1} \\\\\n          &= \\sigma_r \\sigma_{r - 1} \\hdots \\sigma_2 \\sigma_1\n      \\end{align*}\n      which is an even permutation and\n      \\begin{equation*}\n        \\sigma \\sigma^{-1} = \\sigma_1 \\sigma_2 \\hdots \\sigma_r \\sigma_r \\hdots \\sigma_2 \\sigma_1 = \\epsilon.\n      \\end{equation*}\n      Thus $\\exists \\sigma^{-1} \\in A_n$ such that it is the inverse of $\\sigma$.\n    \\item Let $O_n$ denote the set of odd permutations in $S_n$.\\marginnote{For the proof of 3, we know that $\\abs{S_n} = n!$, which is twice of the suggested order of $A_n$. Since we took out the even permutations of $S_n$, we just need to make the rest of the permutations, the odd permutations, into a set and prove that $A_n$ and this new set has the same size. One way to show this is by creating a bijection between the two.\n    \n        Also, note that the set of all odd permutations of $S_n$ is not a group, since\n        \\begin{itemize}\n          \\item there is no identity element in this set; and\n          \\item this set is not closed under map composition.\n        \\end{itemize}\n    \n        We have shown that $\\epsilon$ is an even permutation, and so by the \\hyperref[thm:parity_theorem]{Parity Theorem}, it cannot be an odd permutation, and there is only one identity in $S_n$. The set is not closed under map composition since if we compose two odd permutations, we would get an even permutation, which does not belong to this set.\n    } Then we have $S_n = A_n \\cup O_n$, and by the \\hyperref[thm:parity_theorem]{Parity Theorem}, we have that $A_n \\cap O_n = \\emptyset$. Since $\\abs{S_n} = n!$, to prove that $\\abs{A_n} = \\frac{1}{2} n!$, it suffices to show that $\\abs{A_n} = \\abs{O_n}$.\n    \n    Let $\\gamma = \\begin{pmatrix} 1 & 2 \\end{pmatrix}$ and $f : A_n \\to O_n$ such that $f(\\sigma) = \\gamma \\sigma$. Since $\\sigma$ is even, $\\gamma \\sigma$ is odd, and so $f$ is well-defined.\n    \n    Also, if $\\gamma \\sigma_1 = \\gamma \\sigma_2$, then by \\hyperref[propo:cancellation_laws]{Cancellation Laws}, $\\sigma_1 = \\sigma_2$, and hence $f$ is injective.\n    \n    Finally, $\\forall \\tau \\in O_n$, we have that $\\gamma \\tau = \\sigma \\in A_n$. Note that\n  \\begin{equation*}\n    f(\\sigma) = \\gamma \\sigma = \\gamma \\gamma \\tau = \\tau.\n  \\end{equation*}\n  Therefore, $f$ is surjective.\n\n  It follows that $\\abs{A_n} = \\abs{O_n}$. \\qed\n  \\end{enumerate}\n\\end{proof}\n\n% subsection Alternating Groups (end)\n\n\\subsection{Order of Elements}\n\\label{sub:order_of_elements}\n% subsection Order of Elements\n\n\\begin{notation}\n  If $G$ is a group and $g \\in G$, we denote\n  \\begin{equation*}\n    \\lra{g} = \\{ g^k : k \\in \\mathbb{Z} \\}.\n  \\end{equation*}\n  Note that $1 = g^0 \\in \\lra{g}$.\n\n  If $x = g^m, y = g^n \\in \\lra{g}$ where $m, n \\in \\mathbb{Z}$, then\n  \\begin{equation*}\n    xy = g^m g^n = g^{m + n} \\in \\lra{g}\n  \\end{equation*}\n  and we have $\\exists x^{-1} = g^{-m} \\in \\lra{g}$ such that\n  \\begin{equation*}\n    xx^{-1} = g^m g^{-m} = g^0 = 1.\n  \\end{equation*}\n\\end{notation}\n\nAlong with the \\hlnoteb{Subgroup Test}, we have the following proposition:\n\n\\begin{propo}[Cyclic Group as A Subgroup]\\label{propo:cyclic_group_as_a_subgroup}\n  If $G$ is a group and $g \\in G$, then $\\lra{g}$ is a subgroup of $G$.\n\\end{propo}\n\n\\begin{defn}[Cyclic Groups]\\label{defn:cyclic_groups}\n\\index{Cyclic Group}\n  Let $G$ be a group and $g \\in G$. Then we call $\\lra{g}$ the \\hlnoteb{cyclic subgroup} of $G$ generated by $g$. If $G = \\lra{g}$ for some $g \\in G$, then we say that $G$ is a \\hlnoteb{cyclic group}, and $g$ is a \\hldefn{generator} of $G$.\n\\end{defn}\n\n% subsection Order of Elements (end)\n\n% section Subgroups (Continued 2) (end)\n\n% chapter Lecture 6 May 14th 2018 (end)\n", "meta": {"hexsha": "e6adcad1c0306fe09c7da6946c5004d2be85d7a6", "size": 11853, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PMATH347S18/lectures/lec06.tex", "max_stars_repo_name": "japorized/TeX_notes", "max_stars_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-09-28T21:23:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-21T01:41:27.000Z", "max_issues_repo_path": "PMATH347S18/lectures/lec06.tex", "max_issues_repo_name": "japorized/TeX_notes", "max_issues_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-29T17:58:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-29T17:58:51.000Z", "max_forks_repo_path": "PMATH347S18/lectures/lec06.tex", "max_forks_repo_name": "japorized/TeX_notes", "max_forks_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-09-27T20:55:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-27T20:55:58.000Z", "avg_line_length": 57.2608695652, "max_line_length": 824, "alphanum_fraction": 0.6716443095, "num_tokens": 3899, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.4174874498930311}}
{"text": "\\RequirePackage[l2tabu, orthodox]{nag}\n\\documentclass{article}\n\n\\usepackage[letterpaper, margin=1.3cm]{geometry}\n\\usepackage{siunitx}\n\\usepackage{mathtools}\n\\usepackage{multicol}\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage{enumitem}\n\n\\title{ECE 311 Assignment 2}\n\\author{Michael Kwok}\n\\begin{document}\n\n\\maketitle\n\\begin{multicols}{2}\n    \\subsection*{1a}\n    \\[\n        2~surfaces/platter \\times 4~platters = 8~surfaces\n    \\]\n    \\subsection*{1b}\n    \\[\n        1~track/surface * 8~surfaces = 8~tracks\n    \\]\n    \\subsection*{2}\n    \\( 8~platters = 16~surfaces\\)\n    \\begin{align*}\n        800 \\times 8000 + 400 \\times 10000 & = 10400000~sectors/surface    \\\\\n        10400000 \\times 16 \\times 512      & = 8.51968\\times 10^{10}~Bytes \\\\\n                                           & = 85.2~GB\n    \\end{align*}\n    \\subsection*{3}\n    \\(T_{avg} = 5\\si{\\milli\\second} + \\frac{\\frac{1}{2000}\\times 60}{2} = 7.5 \\si{\\milli\\second}\\)\n    \\subsection*{4a}\n    Queue time, seek time and rotational latency are assumed to be 0 as the head is already on the file.\n\n    Transfer time:\n    \\begin{align*}\n         & \\frac{1}{12000} \\times \\frac{1}{1000}\\times 60 \\times \\frac{2\\times 2^{20}}{512} \\\\\n         & = 20.48\\si{\\milli\\second}\n    \\end{align*}\n    \\subsection*{4b}\n    \\begin{align*}\n          & \\left( 6\\times 10^{-3} + \\frac{30}{12000}\\times\\frac{1}{1000}\\times 60 \\right) \\times \\frac{2\\times 2^{20}}{512} \\\\\n        = & 34.8\\si{\\second}                                                                                                 \\\\\n        = & 34836 \\si{\\milli\\second}\n    \\end{align*}\n    \\subsection*{5a}\n    \\[\n        \\frac{10^{15}}{170\\times10^6} \\times \\frac{1}{60}\\times \\frac{1}{60} \\times \\frac{1}{24} \\times \\frac{1}{365} = 0.187 \\text{ years}\n    \\]\n    \\subsection*{5b}\n    \\[\n        \\frac{10^{15}}{14\\times10^6} \\times \\frac{1}{60}\\times \\frac{1}{60} \\times \\frac{1}{24} \\times \\frac{1}{365} = 0.187 \\text{ years}\n    \\]\n    \\subsection*{5c}\n    \\[\n        \\frac{10^{15}}{2\\times 10^{10}} \\times \\frac{1}{365} = 137 \\text{ years}\n    \\]\n    \\subsection*{6}\n    $0001~1010 \\oplus 0000~1001 \\oplus 0001~0010 \\oplus 1010~1011 = 1010~1010 = AA $\n    \\subsection*{7a}\n    Yes it is possible in this situation:\n\n    $B_1$:\n    $1010~1011 \\oplus 1001~0001 \\oplus 0001~1010 = 0010~0000 = 20 $\n\n    $B_2$:\n    $1010~1011 \\oplus 1001~0001 \\oplus 0011~0010 = 0000~1000 = 08 $\n\n    \\subsection*{7b}\n    There is not enough information to restore $B_2$ or $B_3$. Both XOR operations have 2 unknowns, which is not mathematically solveable.\n\n\\end{multicols}\n\\end{document}\n", "meta": {"hexsha": "65cd68452727e02fbfaa0423ccff222a22c0733b", "size": 2592, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignments/ECE311/Assignment2.tex", "max_stars_repo_name": "n30phyte/SchoolDocuments", "max_stars_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignments/ECE311/Assignment2.tex", "max_issues_repo_name": "n30phyte/SchoolDocuments", "max_issues_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignments/ECE311/Assignment2.tex", "max_forks_repo_name": "n30phyte/SchoolDocuments", "max_forks_repo_head_hexsha": "79652ec7e3345d67e67f0cffe3bea468708622bd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6623376623, "max_line_length": 139, "alphanum_fraction": 0.5709876543, "num_tokens": 968, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381372136563, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.4174256936208677}}
{"text": "\nIn this section we formally define the REDFIN microarchitecture and express the\nsemantics of the instruction set as an explicit and symbolic state transformer.\n\n\\begin{figure}[t]\n\\begin{minted}[xleftmargin=10pt]{haskell}\ndata State = State\n  { registers           :: RegisterBank\n  , memory              :: Memory\n  , instructionCounter  :: InstructionAddress\n  , instructionRegister :: InstructionCode\n  , program             :: Program\n  , flags               :: Flags\n  , clock               :: Clock }\n\\end{minted}\n\\vspace{0mm}\n\\begin{minted}[xleftmargin=10pt]{haskell}\ntype Register           = SymbolicValue Word2\ntype Value              = SymbolicValue Int64\ntype RegisterBank       = SymbolicArray Word2 Int64\ntype MemoryAddress      = SymbolicValue Word8\ntype Memory             = SymbolicArray Word8 Int64\n\\end{minted}\n\\vspace{0mm}\n\\begin{minted}[xleftmargin=10pt]{haskell}\ntype InstructionAddress = SymbolicValue Word8\ntype InstructionCode    = SymbolicValue Word16\ntype Program            = SymbolicArray Word8 Word16\n\\end{minted}\n\\vspace{0mm}\n\\begin{minted}[xleftmargin=10pt]{haskell}\ndata Flag               = Condition@\\,@|@\\,@Overflow@\\,@|@\\,@Halt@\\,@...\ntype Flags              = SymbolicArray Flag Bool\ntype Clock              = SymbolicValue Word64\n\\end{minted}\n\\vspace{-3.5mm}\n\\caption{Basic types for modelling REDFIN.\\label{fig-types}}\n\\vspace{-5mm}\n\\end{figure}\n\n\\vspace{-1mm}\n\\subsection{The REDFIN microarchitecture state}\n\\vspace{-0.5mm}\n\nThe main idea of our approach is to use an explicit state transformer\nsemantics of the REDFIN microarchitecture. The \\hs{State} of the entire\nprocessing core is a product of states of every component, see\nFig.~\\ref{fig-types}.\n% The names and types of the components are self-explanatory.\nWe define \\hs{SymbolicValue} and \\hs{SymbolicArray} on top of the SBV\nlibrary~\\cite{SBV} that we use as the SMT translation and verification frontend.\n\n% \\begin{equation*}\n% \\begin{split}\n% S=\\{(r, m, ic, ir, p, f, c) : r \\in R, m \\in M, ic \\in A, \\\\ir \\in I,\n% p \\in P, f \\in F, c \\in C\\},\n% \\end{split}\n% \\end{equation*}\n\n% \\noindent\n% where $R$ is the set of register bank configurations;\n% $M$ is the memory state space;\n% $A$~is the set of instruction addresses (the instruction counter $ic$ stores the\n% address of the current instruction);\n% $I$ is the set of instruction codes (the instruction register $ir$ stores the\n% code of the current instruction);\n% $P$ is the set of programs;\n% $F$ is the set of the flag register configurations; and\n% $C$ is the set of clock values.\n\n% Fig.~\\ref{fig-types} shows the translation of the above into Haskell types. Note\n% that the types are not parameterised: recall that REDFIN is parameterised, e.g.\n% the data width can be chosen depending on mission requirements, whereas we use fixed\n% 64-bit data path for the sake of simplicity. The chosen names are self-explanatory,\n% for example, the data type \\hs{State} directly corresponds to the set of states~$S$.\n\n% \\todo{In principle, any other SMT frontend\n% can be used, but to the best of our knowledge, SBV is the most mature SMT library\n% available for Haskell. \\textbf{No, SBV here is crucial because it does all the actual symbolic execution}} We briefly overview all \\hs{State} components below.\n\n% \\subsubsection{Data values, registers and memory}\n\nThere are~4 registers (addressed by \\hs{Word2}) and 256 memory cells (addressed\nby \\hs{Word8}) that store 64-bit values (\\hs{Int64}). The register bank and\nmemory are represented by symbolic arrays\nthat can be accessed via SBV's functions \\hs{readArray} and \\hs{writeArray}.\n% \\subsubsection{Instructions and programs}\nREDFIN uses 16-bit \\hs{InstructionCode}s, whose 6 leading bits contain the\nopcode, and the remaining 10 bits hold instruction arguments. The \\hs{Program}\nmaps 8-bit instruction addresses to instruction codes.\n\n% \\subsubsection{Status flags and clock}\nThe microarchitecture status \\hs{Flags} support conditional branching, track\ninteger overflow, and terminate the program (we omit a few other flags for\nbrevity).\n% The flag register is a symbolic map from flags to Boolean values.\nThe \\hs{Clock} is a 64-bit counter\nincremented on each clock cycle. Status flags and the clock are used for\ndiagnostic, formal verification and worst-case execution time analysis.\n\n\\subsection{Instruction and program semantics}\n\nWe can now define the formal semantics of REDFIN instructions and programs as a\n\\emph{state transformer} $T : S \\rightarrow S$, i.e. a function that maps\nstates to states. We distinguish instructions and programs by using\nHaskell's list notation, e.g. $T_{\\subhs{nop}}$ is the semantics of the\ninstruction $\\hs{nop} \\in I$, whereas $T_{\\subhs{[}\\subhs{nop}\\subhs{]}}$ is the\nsemantics of the single-instruction program $\\hs{[}\\hs{nop}\\hs{]} \\in P$.\n\n% \\footnote{REDFIN does not have a dedicated \\hs{nop}\n% instruction, but one can use the semantically equivalent instruction \\hs{jmpi 0}\n% instead (i.e. jump to the next instruction).}\n\n\\vspace{-3mm}\n\\noindent\\hrulefill~\\\\\n\\vspace{-4.5mm}\n\n\\noindent\n\\textbf{Definition (program semantics):} The semantics of a program $p \\in P$\nis inductively defined as follows:\n\n% \\begin{itemize}\n% \\item\n    The semantics of the \\emph{empty program} $\\hs{[}\\hs{]} \\in P$ coincides with\n    the semantics of the instruction \\hs{nop} and is the identity state transformer:\n    $T_{\\subhs{[}\\subhs{]}} = T_{\\subhs{nop}} = \\hs{id}$.\n\n    % \\item\n    The semantics of a \\emph{single-instruction program} $\\hs{[}\\hs{i}\\hs{]} \\in P$\n    is a composition of (i) fetching the instruction from\n    the program memory~$T_\\textit{fetch}$, (ii) incrementing the\n    instruction counter~$T_\\textit{inc}$, and (iii) the state transformer\n    of the instruction itself~$T_{\\subhs{i}}$, or, using the order of state\n    components from Fig.~\\ref{fig-types}:\n    \\vspace{-1mm}\n    \\[\n    \\begin{array}{lcl}\n    T_\\textit{fetch} & = & (r, m, ic, ir, p, f, c) \\mapsto (r, m, ic, p[ic], p, f, c + 1)\\\\\n    T_\\textit{inc} & = & (r, m, ic, ir, p, f, c) \\mapsto (r, m, ic + 1, ir, p, f, c)\\\\\n    T_{\\subhs{[}\\subhs{i}\\subhs{]}} & = & T_{\\subhs{i}} \\circ T_\\textit{inc} \\circ T_\\textit{fetch}\\\\\n    \\end{array}\n    \\]\n\n    % \\item\n    % \\vspace{-1mm}\n    The semantics of a \\emph{composite program} $\\hs{i}\\hs{:}\\hs{p} \\in P$,\n    where the operator~\\hs{:}~prepends an instruction $\\hs{i} \\in I$ to a program\n    $\\hs{p} \\in P$, is defined as $T_{\\subhs{i}\\subhs{:}\\subhs{p}} = T_{\\hs{p}} \\circ T_{\\subhs{[}\\subhs{i}\\subhs{]}}$.\n\n% \\end{itemize}\n\n\\vspace{-2mm}\n\\noindent\\hrulefill~\\\\\n\\vspace{-3.5mm}\n\n% \\noindent\nWe represent state transformers in Haskell using the \\emph{state monad}, a\nclassic approach to emulating mutable state in a purely functional programming\nlanguage~\\cite{wadler1990comprehending}. We call our state monad~\\hs{Redfin} and\ndefine it as follows:\n% \\footnote{A generic version of this monad is available in standard module\n% \\hs{Control.Monad.State}.}\n\n\\begin{minted}[xleftmargin=10pt]{haskell}\ndata Redfin a = Redfin\n  { transform :: State -> (a, State) }\n\\end{minted}\n\n\\noindent\nEvery computation with the return type~\\hs{Redfin}~\\hs{a} yields a value of type~\\hs{a}\nand possibly alters the \\hs{State} of the REDFIN microarchitecture. As an example,\nbelow we express the state transformer $T_\\textit{inc}$ using the \\hs{Redfin} monad.\n\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nincrementInstructionCounter :: Redfin ()\nincrementInstructionCounter =\n    Redfin $ \\current -> ((), next)\n  where next = current { instructionCounter =\n          instructionCounter current + 1 }\n\\end{minted}\n\n\\noindent\nIn words, the state transformer looks up the value of the \\hs{instructionCounter}\nin the \\hs{current} state and replaces it in the \\hs{next} state with the\nincremented~value. Such computations directly correspond to REDFIN programs and\ncan be described using Haskell's powerful \\hs{do}-notation:\n\n% The type \\hs{Redfin}~\\hs{()} indicates that the computation does not\n% produce any value as part of the state transformation.\n\n% and can be composed using the operator \\hs{>>}.\n% For example, \\hs{fetchInstruction}\\\\\\hs{>>}~\\hs{incrementInstructionCounter} is\n% the state transformer $T_\\textit{inc} \\circ T_\\textit{fetch}$ assuming that\n% \\hs{fetchInstruction} corresponds to $T_\\textit{fetch}$. We can also use\n\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nreadInstructionRegister@\\,@::@\\,@Redfin@\\,@InstructionCode\nreadInstructionRegister =\n  Redfin $ \\s -> (instructionRegister s, s)\n\\end{minted}\n\\vspace{0.5mm}\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nexecuteInstruction :: Redfin ()\nexecuteInstruction = do\n  fetchInstruction\n  incrementInstructionCounter\n  instructionCode <- readInstructionRegister\n  decodeAndExecute instructionCode\n\\end{minted}\n\n\\noindent\nHere \\hs{readInstructionRegister} reads the instruction code from the current\nstate \\emph{without modifying it}. This function is used in \\hs{executeInstruction},\nwhich defines the semantics of the REDFIN execution cycle. We omit definitions of\n\\hs{fetchInstruction} and \\hs{decodeAndExecute} for brevity. The latter is a\ncase analysis of 47 opcodes that returns the matching instruction. We discuss\nseveral instructions below.\n\n% \\subsubsection{Halting the processor}\nThe instruction~\\hs{halt} sets the flag~\\hs{Halt}, thereby stopping the\nexecution of the current subroutine until a new one is started by a higher-level\nsystem controller that resets \\hs{Halt}.\n\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nhalt :: Redfin ()\nhalt = writeFlag Halt true\n\\end{minted}\n\n\\noindent\nThe auxiliary functions \\hs{writeFlag}, \\hs{readRegister} etc. are simple\nstate transformers manipulating parts of the \\hs{State}.\n\n% \\begin{minted}{haskell}\n% writeFlag :: Flag -> SymbolicValue Bool -> Redfin ()\n% writeFlag flag value = Redfin $ \\s -> ((), s')\n%   where s' = s { flags = writeArray (flags s)\n%                          (flagId flag) value }\n% \\end{minted}\n\n% \\subsubsection{Arithmetics}\nThe instruction \\hs{abs} is more involved:\nit reads a register and writes back the absolute value of its contents.\nThe semantics accounts for the potential integer overflow that leads to the\n\\emph{negative resulting value} when the input is $-2^{63}$ (REDFIN uses the\ncommon two's complement signed number representation). The overflow is flagged\nby setting~\\hs{Overflow}.\n% \\footnote{We use \\hs{Prelude.abs} to distinguish between the instruction\n% and the function from the standard library \\hs{Prelude}; \\hs{fmap} applies\n% \\hs{Prelude.abs} to the result of \\hs{readRegister}.}\n\n\\vspace{-0.5mm}\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nabs :: Register -> Redfin ()\nabs rX = do\n    state  <- readState\n    result <- fmap Prelude.abs (readRegister rX)\n    let (_, state') =\n      transform (writeFlag Overflow true) state\n    writeState $ ite (result .< 0) state' state\n    writeRegister rX result\n\\end{minted}\n\n\\noindent\nSBV's symbolic \\emph{if-then-else} operation~\\hs{ite} \\emph{merges} two possible\nnext states, one of which has the \\hs{Overflow} flag set.\n\n% The\n% auxiliary functions \\hs{readRegister}, \\hs{writeRegister}, \\hs{readState} and\n% \\hs{writeState} are simple state transformers like\n% \\hs{readInstructionRegister} and \\hs{writeFlag}.\n\n% \\subsubsection{Conditional branching}\nAs an example of a control flow REDFIN instruction consider \\hs{jmpi_ct}, which\ntests the~\\hs{Condition} flag, and adds the provided offset to the instruction\ncounter if the flag is set.\n\n\\vspace{-0.5mm}\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\njmpi_ct :: SymbolicValue Int8 -> Redfin ()\njmpi_ct offset = do\n  ic <- readInstructionCounter\n  condition <- readFlag Condition\n  let ic' = ite condition (ic + offset) ic\n  writeInstructionCounter ic'\n\\end{minted}\n\n\\noindent\n% After working through the above examples, it is worth noting that\nWe use our Haskell encoding of the state transformer as a~\\emph{metalanguage}:\nwe operate the REDFIN core as a puppet master, using external meta-notions of\naddition, comparison and let\"/binding. From the processor's\npoint of view, we have infinite memory and act instantly, which gives us unlimited\nmodelling power. For example, we can simulate the processor environment\nin an external tool and feed its result to \\hs{writeRegister} as if it was\nobtained in one clock cycle.\n\n\\vspace{-1mm}\n\\subsection{Symbolic simulation}\n\\vspace{-1mm}\n\nHaving defined the semantics of REDFIN programs, we can perform \\emph{symbolic\nprocessor simulation}. The function \\hs{simulate} takes a number of simulation\nsteps~$N$ and an initial symbolic \\hs{State} as input, and executes\n\\hs{executeInstruction} defined above $N$ times. In each \\hs{state} we\nmerge two possible futures: (i) if the \\hs{Halt} flag is set, we continue the\nsimulation from the \\hs{next} state, (ii) otherwise we remain in the current\n\\hs{state}, since in this case the processor must remain idle.\n\n\\begin{minted}[xleftmargin=10pt,fontsize=\\small]{haskell}\nsimulate :: Int -> State -> State\nsimulate steps s | steps <= 0 = s\n                 | otherwise  =\n  ite halted s (simulate (steps - 1) next)\n where halted = readArray (flags s) (flagId Halt)\n       next   = snd (transform executeInstruction s)\n\\end{minted}\n\n\\noindent\n%TODO: What about program synthesis?\nSymbolic simulation is very powerful. It allows us to formally verify properties\nof REDFIN programs by fixing some parts of the state to constant values (e.g.,\nthe program), and then making assertions on the resulting values of\nthe symbolic part of the state, as demonstrated in the next\nsection~\\S\\ref{sec-verification}.\n\n", "meta": {"hexsha": "72ff3ac2059e260919ea41ba419d1cb04c2067d3", "size": 13590, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/haskell-symposium-2019/tex/state.tex", "max_stars_repo_name": "tuura/redfin", "max_stars_repo_head_hexsha": "8931f3f8cdee7dd877c84563a81ee7f70e92bf3e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-05T19:13:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-05T19:13:46.000Z", "max_issues_repo_path": "papers/haskell-symposium-2019/tex/state.tex", "max_issues_repo_name": "tuura/redfin", "max_issues_repo_head_hexsha": "8931f3f8cdee7dd877c84563a81ee7f70e92bf3e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/haskell-symposium-2019/tex/state.tex", "max_forks_repo_name": "tuura/redfin", "max_forks_repo_head_hexsha": "8931f3f8cdee7dd877c84563a81ee7f70e92bf3e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6871165644, "max_line_length": 161, "alphanum_fraction": 0.7289919058, "num_tokens": 3801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4173729752658859}}
{"text": "\\documentclass[12pt]{article}\n\n\\include{preamble}\n\\usepackage{textcomp}\n\\usepackage{tfrupee} \n\\pdfmapfile{=tfrupee.map}\n\n\\title{Math 241 Fall 2016 \\\\ Midterm Examination Two}\n\\author{Professor Adam Kapelner}\n\n\\date{November 15, 2016}\n\n\\begin{document}\n\\maketitle\n\n\\noindent Full Name \\line(1,0){270} ~~~ Section (A or B)~ \\line(1,0){30}\n\n\\thispagestyle{empty}\n\n\\section*{Code of Academic Integrity}\n\n\\footnotesize\nSince the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.\n\nActivities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:\n\n\\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using a cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.\n\\\\\n\n\\noindent I acknowledge and agree to uphold this Code of Academic Integrity. \\\\\n\n\\begin{center}\n\\line(1,0){250} ~~~ \\line(1,0){100}\\\\\n~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date\n\\end{center}\n\n\\normalsize\n\n\\section*{Instructions}\n\nThis exam is seventy five minutes and closed-book. You are allowed one page (front and back) of a \\qu{cheat sheet.} You may use a graphing calculator of your choice. Please read the questions carefully. If the question reads \\qu{compute,} this means the solution will be a number otherwise you can leave the answer in choose, permutation, exponent, factorial or any other notation which could be resolved to a number with a computer. I advise you to skip problems marked \\qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \\fbox{Box} in your final answers. Good luck!\n\n\\pagebreak\n\n\\problem Many students take probability and statistics to go on to a career as an actuary. In America, this requires passing many exams. The third exam is called the \\qu{models for financial economics} or \\qu{MFE} which consists of 30 multiple choice questions with 5 choices each. Each question is separate from other questions (i.e. self-contained).\n\n\\begin{figure}[htp]\n\\centering\n\\includegraphics[width=3in]{scantron.png}\n\\end{figure}\n\nIn July 2016, the passing rate was $\\approx$72\\% of questions correct. For the purposes of this problem, assume this means 22 of the questions (or more) would have to be correct in order to pass. \\\\\n\nWe first consider the situation where the test-taker guesses the answer to each question by choosing one of the five equally likely choices. \n\n\\benum\n\\subquestionwithpoints{3} Model the result of \\emph{one} question below as a r.v. $X$ which has the value 1 if the answer is correct and 0 if the answer is not correct.  \\spc{1}\n\n\\subquestionwithpoints{2} When guessing the answers to all 30 questions, are the r.v.'s that represent each question's correctness identically distributed? Yes / no. No explanation necessary.  \\spc{0.2}\n\n\\subquestionwithpoints{2} When guessing the answers to all 30 questions, are the r.v.'s that represent each question's correctness independent? Yes / no. No explanation necessary.  \\spc{0.2}\n\n\\subquestionwithpoints{3} Create a r.v. model that represents the total score for all 30 questions.  \\spc{1}\n\n\\subquestionwithpoints{6} Compute the probability that the guesser gets \\textit{exactly} 22 questions correct. Round to three significant digits.  \\spc{4}\n\n\\subquestionwithpoints{3} If the guesser did the exam over and over again, what would his test average approximately be? \\spc{1}\n\n\\subquestionwithpoints{6} Write an computable expression for the probability that the guesser passes the exam. Do not compute it explicitly.  \\spc{3}\n\n\\subquestionwithpoints{5} Regardless of your answer in (g), do you think the guesser has a \\textit{realistic} chance of passing? Yes / no and explain your answer. \\spc{3}\n\n\\subquestionwithpoints{4} In the situtation where the test-taker knows something about some of the topics tested and uses that knowledge to answer some questions but guess on others which he has no knowledge of the topics, would the model built in (d) still be a good model for the test-taker's score on the exam? Yes / no and explain your answer. \\spc{5}\n\n\\eenum\n\n\n\\problem Powerball is an American lottery game offered by 44 states, the District of Columbia, Puerto Rico and the US Virgin Islands. Since October 7, 2015, the game has used 5 white balls picked from 69 possible balls with replacement and onw \\qu{powerball} with 26 possible balls resulting in a matrix from which winning numbers are chosen, resulting in odds of 1 in 292,201,338 of winning a jackpot per play (i.e. about three in a billion). Calculated as a probability, we denote the chance of winning as $p := 3.42 \\times 10^{-9}$. \\\\\n\n\\begin{figure}[htp]\n\\centering\n\\includegraphics[width=3in]{powerball.png}\n\\end{figure}\n\nAssume for simplicity that there is a powerball lottery every day, 365 days per year. Also assume when you buy a powerball lottery ticket, you pick a sequence of valid powerball numbers randomly (i.e. equally likely) for each ball.\n\n\\benum\n\\subquestionwithpoints{3} Create a r.v. $X$ for the outcome of one powerball lottery ticket which realizes 1 if you win and 0 if you lose. \\spc{1}\n\n\n\\subquestionwithpoints{3} Consider the following strategy: buy a powerball ticket every day until you win. Create a r.v. model $X$ that models the number of days it takes to win. \\spc{1}\n\n\\subquestionwithpoints{5} How many years would it take to win on average? Round to the nearest year. \\spc{4}\n\n\\subquestionwithpoints{5} Imagine starting to play when you're 20 years old and stopping when you're 90 years old for a total of 70 years of daily playing. What is the probability of winning (at least once)? Round to two significant digits. \\spc{5}\n\n\n\\subquestionwithpoints{5} Assuming you can play everyday \\emph{forever}, what is the probability you eventually win? \\spc{0.2}\n\n\\subquestionwithpoints{3} If you've been playing for 30 years without winning, do you have a higher chance of winning compared to someone who has just started playing? Yes / no. No explanation needed. \\spc{0.2}\n\n\\subquestionwithpoints{5} Up until this point, we have just been discussing probabilities and modeling the event of winning or losing. Now we will put dollar amounts on these events. The powerball ticket costs \\$2 and the average jackpot is \\$140 million. Create a r.v. $X$ for the payout of \\textit{one} powerball ticket. \\spc{4}\n\n\\subquestionwithpoints{5} Calculate the expected value of $X$, (the r.v. model for the payout of \\emph{one} powerball ticket in dollars). Round to an appropriate number of digits. \\spc{5}\n\n\\subquestionwithpoints{5} Interpret the expected value you calculated in (i) in the scenario where you don't play for 70 years daily but you \\textit{only play once}. \\spc{4}\n\n\\subquestionwithpoints{6} Calculate the standard error of \\emph{one} powerball lottery ticket.  Include units and round to an appropriate number of digits. \\spc{8}\n\n\n\\subquestionwithpoints{4} Let's say you are buying the ticket in India where the currency is rupees (\\rupee). The exchange rate is \\$1 = \\rupee66.80 and you have to pay a flat \\rupee30 fee to purchase an American ticket from overseas. Create a r.v. $R$ for the lottery ticket bought in India with rupees as a function of the r.v. $X$ created in (h).\\spc{2}\n\n\\eenum\n\n\\problem These are some theoretical questions below.\n\n\\benum\n\\subquestionwithpoints{3} If the r.v. $X \\sim $ Deg($c$), prove $\\expe{X} = c$ from the definition of expectation for discrete r.v.'s. \\spc{5}\n\n%\\subquestionwithpoints{3} If $\\Xoneton \\iid$ with finite $\\mu$ and $\\sigma$, derive an expression for $\\se{\\Xbar}$ step-by-step. \\spc{3}\n\n\n\n\\subquestionwithpoints{4} Compute the following expression for $w = 0.24586$:\n\n\\beqn\n\\sum_{\\ell=y}^\\infty \\binom{\\ell - 1}{y - 1} w^y (1-w)^{\\ell - y}  = \\quad\\quad\\quad\\quad\n\\eeqn\\spc{1}\n\n\\subquestionwithpoints{4} Assume $\\expe{X_i} > 0$ and that $\\Xoneton $ are \\textit{identically distributed} but not necessarily independent. Resolve: \\\\\n\n$\\displaystyle\\limitn \\expe{T_n}  = $\\spc{0.3}\n\n\n\\subquestionwithpoints{6} In your pocket you have 10 pennies, 2 nickels, 2 dimes and 3 quarters. You reach into your pocket and grab four coins in your hand. What's the probability you have 4\\textcent~in your hand? \\spc{15}\n\n\n\\subquestionwithpoints{4} [Extra Credit] Resolve the follwing expression for arbitrary r.v. $X$:\n\n\\beqn\n\\bigcup_{x \\in \\supp{X}} \\braces{\\omega : X(\\omega) = x}  = \\quad\\quad\\quad\\quad\n\\eeqn\n\n\\subquestionwithpoints{4} [Extra Credit] Create a r.v. $X$ that has $\\abss{\\supp{X}} = 2$ but whose $\\abss{\\Omega} =  \\aleph_0$.\n\n\\eenum\n\n\n\\end{document}", "meta": {"hexsha": "24880108420e3e89637ddbef3553983898f81805", "size": 9463, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/midterm2/midterm2.tex", "max_stars_repo_name": "kapelner/QC_Math_241_Fall_2016", "max_stars_repo_head_hexsha": "0db51700d0835dd65e109fdb7f243c17ed7a97b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2016-08-21T15:29:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-21T14:08:23.000Z", "max_issues_repo_path": "exams/midterm2/midterm2.tex", "max_issues_repo_name": "kapelner/QC_Math_241_Fall_2016", "max_issues_repo_head_hexsha": "0db51700d0835dd65e109fdb7f243c17ed7a97b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exams/midterm2/midterm2.tex", "max_forks_repo_name": "kapelner/QC_Math_241_Fall_2016", "max_forks_repo_head_hexsha": "0db51700d0835dd65e109fdb7f243c17ed7a97b4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2016-09-01T04:53:52.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-02T04:49:20.000Z", "avg_line_length": 63.5100671141, "max_line_length": 795, "alphanum_fraction": 0.7604353799, "num_tokens": 2498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984137988772, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.4173729609637597}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\title{The Package SPDE for Determining Symmetries of Partial\nDifferential Equations}\n\\date{}\n\\author{Fritz Schwarz \\\\ GMD, Institut F1 \\\\\nPostfach 1240 \\\\ 5205 St. Augustin \\\\\nGERMANY \\\\[0.05in]\nTelephone: +49-2241-142782 \\\\\nEmail: fritz.schwarz@gmd.de}\n\\begin{document}\n\\maketitle\n\nThe package SPDE provides a set of functions which may be applied\nto determine the symmetry group of Lie- or point-symmetries of a\ngiven system of partial differential equations.  Preferably it is\nused interactively on a computer terminal. In many cases the\ndetermining system is solved completely automatically. In some\nother cases the user has to provide some additional input\ninformation for the solution algorithm to terminate. The package\nshould only be used in compiled form.\n\nFor all theoretical questions, a description of the algorithm and\nnumerous examples the following articles should be consulted:\n``Automatically Determining Symmetries of Partial Differential\nEquations'', Computing vol. 34, page 91-106(1985) and vol. 36, page\n279-280(1986), ``Symmetries of Differential Equations: From Sophus\nLie to Computer Algebra'', SIAM Review, to appear, and Chapter 2\nof the Lecture Notes ``Computer Algebra and Differential Equations\nof Mathematical Physics'', to appear.\n\n\n\\section{Description of the System Functions and Variables}\n\nThe symmetry analysis of partial differential equations logically\nfalls into three parts. Accordingly the most important functions\nprovided by the package are:\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| c | c | }\\hline\nFunction name & Operation \\\\ \\hline \\hline\n\\ttindex{CRESYS}\nCRESYS(\\s{arguments}) & Constructs determining system \\\\ \\hline\n\\ttindex{SIMPSYS}\nSIMPSYS() & Solves determining system \\\\ \\hline\n\\ttindex{RESULT}\nRESULT() & Prints infinitesimal generators \\\\\n&  and commutator table \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{SPDE Functions}\n\\end{table}\n\nSome other useful functions for obtaining various kinds of output\nare:\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| c | c |} \\hline\nFunction name & Operation \\\\ \\hline \\hline\n\\ttindex{PRSYS}\nPRSYS() & Prints determining system \\\\ \\hline\n\\ttindex{PRGEN}\nPRGEN() & Prints infinitesimal generators \\\\ \\hline\n\\ttindex{COMM}\nCOMM(U,V) & Prints commutator of generators U and V \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{SPDE Useful Output Functions}\\label{spde:useful}\n\\end{table}\n\nThere are several global variables defined by the system which should\nnot be used for any other purpose than that given in\nTable~\\ref{spde:intt} and~\\ref{spde:op}. The three globals of the type\ninteger are:\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| c | c |}\\hline\nVariable name & Meaning \\\\ \\hline \\hline\n\\ttindex{NN}\nNN & Number of independent variables \\\\ \\hline\n\\ttindex{MM}\nMM & Number of dependent variables \\\\ \\hline\n\\ttindex{PCLASS}\nPCLASS=0, 1 or 2 & Controls amount of output \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{SPDE Integer valued globals}\\label{spde:intt}\n\\end{table}\n\nIn addition there are the following global variables of type\noperator:\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{| c | c |}\\hline\nVariable name & Meaning \\\\ \\hline \\hline\n\\ttindex{X(I)}\nX(I) & Independent variable $x_i$ \\\\ \\hline\n\\ttindex{U(ALFA)}\nU(ALFA) & Dependent variable $u^{alfa}$ \\\\ \\hline\n\\ttindex{U(ALFA,I)}\nU(ALFA,I) & Derivative of $u^{alfa}$ w.r.t. $x_i$ \\\\ \\hline\n\\ttindex{DEQ(I)}\nDEQ(I) & i-th differential equation \\\\ \\hline\n\\ttindex{SDER(I)}\nSDER(I) & Derivative w.r.t. which DEQ(I) is resolved \\\\ \\hline\n\\ttindex{GL(I)}\nGL(I) & i-th equation of determining system \\\\ \\hline\n\\ttindex{GEN(I)}\nGEN(I) & i-th infinitesimal generator \\\\ \\hline\n\\ttindex{XI(I)} \\ttindex{ETA(ALFA)} \\ttindex{ZETA(ALFA,I)}\nXI(I), ETA(ALFA)  & See definition given in the \\\\\nZETA(ALFA,I) & references quoted in the introduction. \\\\ \\hline\n\\ttindex{C(I)}\nC(I) & i-th function used for substitution \\\\ \\hline\n\\end{tabular}\n\\end{center}\n\\caption{SPDE Operator type global variables}\\label{spde:op}\n\\end{table}\n\n\nThe differential equations of the system at issue have to be assigned\nas values to the operator deq i applying the notation which is defined\nin Table~\\ref{spde:op}. The entries in the third and the last line of\nthat Table have obvious extensions to higher derivatives.\n\nThe derivative w.r.t. which the i-th differential equation deq i is\nresolved has to be assigned to sder i. Exception: If there is a single\ndifferential equation and no assignment has been made by the user, the\nhighest derivative is taken by default.\n\nWhen the appropriate assignments are made to the variable deq, the\nvalues of NN and MM (Table~\\ref{spde:useful}) are determined\nautomatically, i.e. they have not to be assigned by the user.\n\n\\ttindex{CRESYS}\nThe function CRESYS may be called with any number of arguments, i.e.\n\n\\begin{verbatim}\n  CRESYS(); or CRESYS(deq 1,deq 2,... );\n\\end{verbatim}\n\n are legal calls. If it is called without any argument, all current\nassignments to deq are taken into account. Example: If deq 1, deq 2\nand deq 3 have been assigned a differential equation and the symmetry\ngroup of the full system comprising all three equations is desired,\nequivalent calls are\n\n\\begin{verbatim}\n  CRESYS();   or   CRESYS(deq 1,deq 2,deq 3);\n\\end{verbatim}\n\nThe first alternative saves some typing. If later in the session the\nsymmetry group of deq 1 alone has to be determined, the correct call\nis\n\n\\begin{verbatim}\n  CRESYS deq 1;\n\\end{verbatim}\n\n\\ttindex{SIMPSYS}\nAfter the determining system has bee created, SIMPSYS which has no\narguments may be called for solving it. The amount of intermediate\noutput produced by SIMPSYS is controlled by the global variable PCLASS\nwith the default value 0. \\ttindex{PCLASS} With PCLASS equal to 0, no\nintermediate steps are shown. With PCLASS equal to 1, all intermediate\nsteps are displayed so that the solution algorithm may be followed\n\\index{tracing ! SPDE package} through in detail. Each time the algorithm\npasses through the top of the main solution loop the message\n\n\\begin{verbatim}\n  Entering main loop\n\\end{verbatim}\n\nis written. PCLASS equal 2 produces a lot of LISP output and is of no\ninterest for the normal user.\n\nIf with PCLASS=0 the procedure SIMPSYS terminates without any\nresponse, the determining system is completely solved.  In some cases\nSIMPSYS does not solve the determining system completely in a single\nrun. In general this is true if there are only genuine differential\nequations left which the algorithm cannot handle at present. If a case\nlike this occurs, SIMPSYS returns the remaining equations of the\ndetermining system. To proceed with the solution algorithm,\nappropriate assignments have to be transmitted by the user, e.g. the\nexplicit solution for one of the returned differential equations. Any\nnew functions which are introduced thereby must be operators of the\nform c(k) with the correct dependencies generated by a depend\nstatement (see the ``REDUCE User's Guide''). Its enumeration has to be\nchosen in agreement with the current number of functions which have\nalreday been introduced.  This value is returned by SIMPSYS too.\n\nAfter the determining system has been solved, the procedure RESULT,\nwhich has no arguments, may be called. It displays the infinitesimal\ngenerators and its non-vanishing commutators.\n\n\n\\section{How to Use the Package}\n\nIn this Section it is explained by way of several examples how the\npackage SPDE is used interactively to determine the symmetry group of\npartial differential equations. Consider first the diffusion equation\nwhich in the notation given above may be written as\n\n\\begin{verbatim}\n  deq 1:=u(1,1)+u(1,2,2);\n\\end{verbatim}\n\nIt has been assigned as the value of deq 1 by this statement.  There\nis no need to assign a value to sder 1 here because the system\ncomprises only a single equation.\n\nThe determining system is constructed by calling\n\n\\begin{verbatim}\n  CRESYS(); or CRESYS deq 1;\n\\end{verbatim}\n\nThe latter call is compulsory if there are other assignments to the\noperator deq i than for i=1.\n\nThe error message\n\n\\begin{verbatim}\n  ***** Differential equations not defined\n\\end{verbatim}\n\nappears if there are no differential equations assigned to any deq.\n\nIf the user wants the determining system displayed for inspection\nbefore starting the solution algorithm he may call\n\n\\ttindex{PRSYS}\n\\begin{verbatim}\n  PRSYS();\n\\end{verbatim}\n\nand gets the answer\n\n\\begin{verbatim}\n  GL(1):=2*DF(ETA(1),U(1),X(2)) - DF(XI(2),X(2),2) -\n         DF(XI(2),X(1))\n\n  GL(2):=DF(ETA(1),U(1),2) - 2*DF(XI(2),U(1),X(2))\n\n  GL(3):=DF(ETA(1),X(2),2) + DF(ETA(1),X(1))\n\n  GL(4):=DF(XI(2),U(1),2)\n\n  GL(5):=DF(XI(2),U(1)) - DF(XI(1),U(1),X(2))\n\n  GL(6):=2*DF(XI(2),X(2)) - DF(XI(1),X(2),2) - DF(XI(1),X(1))\n\n  GL(7):=DF(XI(1),U(1),2)\n\n  GL(8):=DF(XI(1),U(1))\n\n  GL(9):=DF(XI(1),X(2))\n\nThe remaining dependencies\n\n  XI(2) depends on U(1),X(2),X(1)\n\n  XI(1) depends on U(1),X(2),X(1)\n\n  ETA(1) depends on U(1),X(2),X(1)\n\\end{verbatim}\n\nThe last message means that all three functions XI(1), XI(2) and\nETA(1) depend on X(1), X(2) and U(1). Without this information the\nnine equations GL(1) to GL(9) forming the determining system are\nmeaningless. Now the solution algorithm may be activated by calling\n\n\\ttindex{SIMPSYS}\n\\begin{verbatim}\n   SIMPSYS();\n\\end{verbatim}\n\n\\ttindex{PCLASS}\nIf the print flag PCLASS has its default value which is 0 no\nintermediate output is produced and the answer is\n\n\\begin{verbatim}\n  Determining system is not completely solved\n\n  The remaining equations are\n\n  GL(1):=DF(C(1),X(2),2) + DF(C(1),X(1))\n\n  Number of functions is 16\n\n  The remaining dependencies\n\n  C(1) depends on X(2),X(1)\n\\end{verbatim}\n\nWith PCLASS equal to 1 about 6 pages of intermediate output are\nobtained. It allows the user to follow through each step of the\nsolution algorithm.\n\nIn this example the algorithm did not solve the determining system\ncompletely as it is shown by the last message. This was to be expected\nbecause the diffusion equation is linear and therefore the symmetry\ngroup contains a generator depending on a function which solves the\noriginal differential equation. In cases like this the user has to\nprovide some additional information to the system so that the solution\nalgorithm may continue. In the example under consideration the\nappropriate input is\n\n\\begin{verbatim}\n   DF(C(1),X(1)) := - DF(C(1),X(2),2);\n\\end{verbatim}\n\nIf now the solution algorithm is activated again by\n\n\\begin{verbatim}\n  SIMPSYS();\n\\end{verbatim}\n\nthe solution algorithm terminates without any further message, i.e.\nthere are no equations of the determining system left unsolved. To\nobtain the symmetry generators one has to say finally\n\n\\begin{verbatim}\n  RESULT();\n\\end{verbatim}\n\nand obtains the answer\n\n\\begin{verbatim}\n  The differential equation\n\n  DEQ(1):=U(1,2,2) + U(1,1)\n\n\n  The symmetry generators are\n\n  GEN(1):= DX(1)\n\n  GEN(2):= DX(2)\n\n  GEN(3):= 2*DX(2)*X(1) + DU(1)*U(1)*X(2)\n\n  GEN(4):= DU(1)*U(1)\n\n  GEN(5):= 2*DX(1)*X(1) + DX(2)*X(2)\n\n                       2\n  GEN(6):= 4*DX(1)*X(1)\n\n         + 4*DX(2)*X(2)*X(1)\n\n                           2\n           + DU(1)*U(1)*(X(2)  - 2*X(1))\n\n  GEN(7):= DU(1)*C(1)\n\n  The remaining dependencies\n\n  C(1) depends on X(2),X(1)\n\n\n  Constraints\n\n  DF(C(1),X(1)):= - DF(C(1),X(2),2)\n\n\n  The non-vanishing commutators of the finite subgroup\n\n\n  COMM(1,3):= 2*DX(2)\n\n  COMM(1,5):= 2*DX(1)\n\n  COMM(1,6):= 8*DX(1)*X(1) + 4*DX(2)*X(2) - 2*DU(1)*U(1)\n\n  COMM(2,3):= DU(1)*U(1)\n\n  COMM(2,5):= DX(2)\n\n  COMM(2,6):= 4*DX(2)*X(1) + 2*DU(1)*U(1)*X(2)\n\n  COMM(3,5):=  - (2*DX(2)*X(1) + DU(1)*U(1)*X(2))\n\n                          2\n  COMM(5,6):= 8*DX(1)*X(1)\n\n            + 8*DX(2)*X(2)*X(1)\n\n                                2\n            + 2*DU(1)*U(1)*(X(2)  - 2*X(1))\n\\end{verbatim}\n\nThe message ``Constraints'' which appears after the symmetry generators\nare displayed means that the function c(1) depends on x(1) and x(2)\nand satisfies the diffusion equation.\n\nMore examples which may used for test runs are given in the final\nsection.\n\n\\index{ansatz of symmetry generator}\nIf the user wants to test a certain ansatz of a symmetry generator for\ngiven differential equations, the correct proceeding is as follows.\nCreate the determining system as described above. Make the appropriate\nassignments for the generator and call PRSYS() after that.  The\ndetermining system with this ansatz substituted is returned.  Example:\nAssume again that the determining system for the diffusion equation\nhas been created. To check the correctness for example of generator GEN\n3 which has been obtained above, the assignments\n\n\\begin{verbatim}\n  XI(1):=0;  XI(2):=2*X(1);  ETA(1):=X(2)*U(1);\n\\end{verbatim}\n\nhave to be made. If now PRSYS() is called all GL(K) are zero\nproving the correctness of this generator.\n\nSometimes a user only wants to know some of the functions ZETA for for\nvarious values of its possible arguments and given values of MM and\nNN. In these cases the user has to assign the desired values of MM and\nNN and may call the ZETAs after that. Example:\n\n\\begin{verbatim}\n  MM:=1;  NN:=2;\n\n  FACTOR U(1,2),U(1,1),U(1,1,2),U(1,1,1);\n\n  ON LIST;\n\n  ZETA(1,1);\n\n  -U(1,2)*U(1,1)*DF(XI(2),U(1))\n\n  -U(1,2)*DF(XI(2),X(1))\n\n         2\n  -U(1,1) *DF(XI(1),U(1))\n\n  +U(1,1)*(DF(ETA(1),U(1)) -DF(XI(1),X(1)))\n\n  +DF(ETA(1),X(1))\n\n\n  ZETA(1,1,1);\n\n  -2*U(1,1,2)*U(1,1)*DF(XI(2),U(1))\n\n  -2*U(1,1,2)*DF(XI(2),X(1))\n\n  -U(1,1,1)*U(1,2)*DF(XI(2),U(1))\n\n  -3*U(1,1,1)*U(1,1)*DF(XI(1),U(1))\n\n  +U(1,1,1)*(DF(ETA(1),U(1)) -2*DF(XI(1),X(1)))\n\n                2\n  -U(1,2)*U(1,1) *DF(XI(2),U(1),2)\n\n  -2*U(1,2)*U(1,1)*DF(XI(2),U(1),X(1))\n\n  -U(1,2)*DF(XI(2),X(1),2)\n\n         3\n  -U(1,1) *DF(XI(1),U(1),2)\n\n         2\n  +U(1,1) *(DF(ETA(1),U(1),2) -2*DF(XI(1),U(1),X(1)))\n\n  +U(1,1)*(2*DF(ETA(1),U(1),X(1)) -DF(XI(1),X(1),2))\n\n  +DF(ETA(1),X(1),2)\n\\end{verbatim}\n\nIf by error no values to MM or NN and have been assigned the message\n\n\\begin{verbatim}\n  ***** Number of variables not defined\n\\end{verbatim}\n\nis returned. Often the functions ZETA are desired for special values\nof its arguments ETA(ALFA) and XI(K). To this end they have to be\nassigned first to some other variable. After that they may be\nevaluated for the special arguments. In the previous example this may\nbe achieved by\n\n\\begin{verbatim}\n  Z11:=ZETA(1,1)$   Z111:=ZETA(1,1,1)$\n\\end{verbatim}\n\nNow assign the following values to XI 1, XI 2 and ETA 1:\n\n\\begin{verbatim}\n  XI 1:=4*X(1)**2; XI 2:=4*X(2)*X(1);\n\n  ETA 1:=U(1)*(X(2)**2  - 2*X(1));\n\\end{verbatim}\n\nThey correspond to the generator GEN 6 of the diffusion equation which\nhas been obtained above. Now the desired expressions are obtained by\ncalling\n\n\\begin{verbatim}\n  Z11;\n\n                               2\n - (4*U(1,2)*X(2) - U(1,1)*X(2)  + 10*U(1,1)*X(1) + 2*U(1))\n\n  Z111;\n\n                                   2\n - (8*U(1,1,2)*X(2) - U(1,1,1)*X(2)  + 18*U(1,1,1)*X(1) +\n   12*U(1,1))\n\\end{verbatim}\n\n\n\\section{Test File}\n\nThis appendix is a test file. The symmetry groups for various\nequations or systems of equations are determined. The variable PCLASS\nhas the default value 0 and may be changed by the user before running\nit. The output may be compared with the results which are given in the\nreferences.\n\n\\begin{verbatim}\n%The Burgers equations\n\ndeq 1:=u(1,1)+u 1*u(1,2)+u(1,2,2)$\n\ncresys deq 1$ simpsys()$ result()$\n\n%The Kadomtsev-Petviashvili equation\n\ndeq 1:=3*u(1,3,3)+u(1,2,2,2,2)+6*u(1,2,2)*u 1\n\n       +6*u(1,2)**2+4*u(1,1,2)$\n\ncresys deq 1$ simpsys()$ result()$\n\n%The modified Kadomtsev-Petviashvili equation\n\ndeq 1:=u(1,1,2)-u(1,2,2,2,2)-3*u(1,3,3)\n\n       +6*u(1,2)**2*u(1,2,2)+6*u(1,3)*u(1,2,2)$\n\ncresys deq 1$ simpsys()$ result()$\n\n%The real- and the imaginary part of the nonlinear\n%Schroedinger equation\n\ndeq 1:= u(1,1)+u(2,2,2)+2*u 1**2*u 2+2*u 2**3$\n\ndeq 2:=-u(2,1)+u(1,2,2)+2*u 1*u 2**2+2*u 1**3$\n\n%Because this is not a single equation the two assignments\n\nsder 1:=u(2,2,2)$  sder 2:=u(1,2,2)$\n\n%are necessary.\n\ncresys()$ simpsys()$ result()$\n\n%The symmetries of the system comprising the four equations\n\ndeq 1:=u(1,1)+u 1*u(1,2)+u(1,2,2)$\n\ndeq 2:=u(2,1)+u(2,2,2)$\n\ndeq 3:=u 1*u 2-2*u(2,2)$\n\ndeq 4:=4*u(2,1)+u 2*(u 1**2+2*u(1,2))$\n\nsder 1:=u(1,2,2)$ sder 2:=u(2,2,2)$ sder 3:=u(2,2)$\nsder 4:=u(2,1)$\n\n%is obtained by calling\n\ncresys()$ simpsys()$\n\ndf(c 5,x 1):=-df(c 5,x 2,2)$\n\ndf(c 5,x 2,x 1):=-df(c 5,x 2,3)$\n\nsimpsys()$  result()$\n\n% The symmetries of the subsystem comprising equation 1\n%  and 3 are obtained by\n\ncresys(deq 1,deq 3)$ simpsys()$ result()$\n\n% The result for all possible subsystems is discussed in\n% detail in ``Symmetries and Involution Systems: Some\n% Experiments in Computer Algebra'', contribution to the\n% Proceedings of the Oberwolfach Meeting on Nonlinear\n% Evolution Equations, Summer 1986, to appear.\n\\end{verbatim}\n\\end{document}\n", "meta": {"hexsha": "ece7639cc238005b9b22da90d98a252b9fc6f06b", "size": 16764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/spde/spde.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/spde/spde.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/spde/spde.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9866444073, "max_line_length": 73, "alphanum_fraction": 0.6992961107, "num_tokens": 5497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4173278804112119}}
{"text": "\n\\section{Methodology}\n\nThe main estimation strategy is a coach-fixed effect (FE) regression model with team wins as a dependent variable. As control variables, the model includes performance-based metrics that help capture a player's relative skill level. More specifically, it is assumed that a player's Box Plus Minus (BPM) metric from his last season is an overall measure of his ability level. BPM is a \n\nThe coaching impact is captured by the fixed effect ($\\lambda_{k}$), which is a dummy variable designating head coach identity. The resulting fixed effects are algebraically equivalent to deviations from means, so they would represent the additional wins relative to the average. The model also includes player metrics as a control for player ability, and the number of games missed as a proxy for player fitness. \n\nThe model uses Box Plus Minues (BPM) as an overall measure of player ability. More specifically, a player expected level of ability is given by his BPM from the previous season. \n\nFormally, the model can be represented by the following equation: \n\nFor team $i$ in season $t$ under coach $k$,\n\n\\begin{equation}\n\\text{Wins}_{itk} = \\sum_{p=1}^{5}(\\alpha_{p}\\text{BPM}_{p,t-1} + \\beta_{p}\\text{Inj}_{pit}) + \\lambda_{k} + \\epsilon_{itk}\n\\end{equation}\n\nwhere ${BPM}_{p,t-1}$ represents player $p$'s achieved BPM score in season $t-1$, ${Inj}_{p,i,t}$ indicates his number of games missed (presumably due to injury), and $\\lambda_{k}$ is the coach fixed effect. $\\epsilon_{i,t,k}$ is the error term. \n\nFor simplicity, the model assumes a 5-player roster per team. Since players are sorted by minutes played, where Player 1 ($p = 1$) would be the coach's preferred player by the defining characteristic of seeing the most playing time. Player 2 would be the second and Player 5 would be the least in a 5-person rotation. It is important to note that reducing teams to 5 members does not compromise accuracy. Although rosters may extend up to 12 members, coaches mostly rely on a handful of players. Secondary players see significant variation in roles and personnel over the course of a season, so they are excluded from the main estimation. Section 5 considers larger roster sizes and confirms that the results are robust to the inclusion of additional players.\n\nThere is enough reason to believe that neither time or team fixed effects play a significant role because no franchise offers strict advantages over another. Although one might argue that big market teams like the Lakers in Los Angeles and the Knicks in New York may have a slight advantage in attracting talent, expectations are also high for those teams and they often experience periods of downturn.  In addition, the institutional setup of the NBA is such that no team has an edge when it comes to offering higher salaries. Unlike European soccer and other professional sports leagues, the NBA adopts a salary cap where teams have a limit on how much they can spend. Moreover, the structure of the league also compensates \"losing\" teams by granting them priority in selecting players out of college. All of these factors ensure that the league is somewhat balanced out. \n\ncan offer more money than others to attract a player. because of a common salary cap. \\footnote{There are exceptions like for retaining a player of their own.} In addition, the lottery system ensures that weaker teams have the chance to rebuild through the draft. \n\n\\subsection{Solving for Serial Correlation}\n\nThe main challenge arises from the use of performance-based metrics as indicators for player ability, which could pick up some of the coaching effect and lead to potentially understating the impact of coaches over the long run. In order to improve unbiasedness, it imposes a cap on the time span over which the coach effect is examined. In other words, only the first \\textit{three} seasons from each coach-team tenure are observed, filtering out the rest. For example, Phil Jackson's 9-season tenure with the Chicago Bulls (1990 to 1998) is reduced to the first \\textit{three} (1990 to 1992) by eliminating all subsequent seasons. This strategy helps the playing field by assessing all coaches over a fixed time span. The downside is a reduction in sample size, which drops from X to Y observations.\n\nTrimming-off seasons beyond the third has effectively little impact on the accuracy of the estimates. A 3-season tenure is as almost equally informative as a 6-season tenure when it comes to the coach effect. Section 5 helps illustrate this point by showing that results are robust to different time considerations. For simplicity, the main estimation model assumes a 3-season cap because it allows ample time for coaches to leave a footprint without diving into the danger zone of serial correlation.\n\nSomel papers choose to use payroll as a proxy for ability, as opposed to performance-based metrics. However, salaries fail to pick up a great deal of variations, so this paper avoids this alternative. For instance, players may witness a jump in performance from one season to another, yet salaries are sticky over the course of a multi-year contract. Additionally, the NBA is under a salary cap system where pay is not always proportional to on-court value. Many argue that, because of the \"maximum\" contract, the relative impact of a player like Lebron James outweighs the amount of salary-based income he receives. Moreover, star players frequently accept pay cuts to team up with other stars. All of these points make payroll a weak substitute for ability. ", "meta": {"hexsha": "ffa7c019a40b71f87219d7f16159f7004964adec", "size": 5537, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/method.tex", "max_stars_repo_name": "alamine53/paper_NBACoaches", "max_stars_repo_head_hexsha": "0a11f792850f5fdf871b6a2624fb5a523456662c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-15T18:20:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-15T18:20:19.000Z", "max_issues_repo_path": "sections/method.tex", "max_issues_repo_name": "alamine53/paper_NBACoaches", "max_issues_repo_head_hexsha": "0a11f792850f5fdf871b6a2624fb5a523456662c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/method.tex", "max_forks_repo_name": "alamine53/paper_NBACoaches", "max_forks_repo_head_hexsha": "0a11f792850f5fdf871b6a2624fb5a523456662c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 173.03125, "max_line_length": 874, "alphanum_fraction": 0.7946541448, "num_tokens": 1177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.4173278715169855}}
{"text": "% This file is part of the TheCannon project.\n% Copyright 2014 the authors.\n\n\\documentclass[12pt, preprint]{aastex}\n\\usepackage{bm, graphicx, subfigure, amsmath, morefloats}\n\\usepackage{color}\n\\input{vc}\n\n%\\usepackage{natbib}\n\\bibliographystyle{apj}\n\n% naming macros\n\\newcommand{\\documentname}{\\textsl{Article}}\n\\newcommand{\\sectionname}{Section}\n\\renewcommand{\\S}{\\sectionname}\n\\newcommand{\\figurenames}{\\figurename s}\n\\newcommand{\\tc}{\\textsl{The~Cannon}} \n\\newcommand{\\apogee}{\\textsl{APOGEE}} \n\\newcommand{\\apokasc}{\\textsl{APOKASC}} \n\\newcommand{\\galah}{\\textsl{GALAH}}\n\\newcommand{\\segue}{\\textsl{SEGUE}}  \n\\newcommand{\\aspcap}{\\textsl{ASPCAP}} \n\\newcommand{\\gaiaeso}{\\textsl{Gaia-ESO}} \n\\newcommand{\\gaia}{\\textsl{GAIA}} \n\\newcommand{\\rave}{\\textsl{RAVE}} \n\\newcommand{\\matisse}{\\textsl{MATISSE}} \n\\newcommand{\\rotwarn}{\\texttt{ROTATION WARNING}} \n\\newcommand{\\sdss}{\\textsl{SDSS-III}} \n\\newcommand{\\lamost}{\\textsl{LAMOST}} \n\\newcommand{\\aspcapstar}{\\textsl{aspcapStar}} \n\\newcommand{\\apstar}{\\textsl{apStar}} \n\n% math and symbol macros\n\\newcommand{\\set}[1]{\\bm{#1}}\n\\newcommand{\\starlabel}{\\ell}\n\\newcommand{\\starlabelvec}{\\set{\\starlabel}}\n\\newcommand{\\mean}[1]{\\overline{#1}}\n\\newcommand{\\given}{\\,|\\,}\n\\newcommand{\\teff}{\\mbox{$\\rm T_{eff}$}}\n\\newcommand{\\kms}{\\mbox{$\\rm kms^{-1}$}}\n\\newcommand{\\feh}{\\mbox{$\\rm [Fe/H]$}}\n\\newcommand{\\xfe}{\\mbox{$\\rm [X/Fe]$}}\n\\newcommand{\\alphafe}{\\mbox{$\\rm [\\alpha/Fe]$}}\n\\newcommand{\\mh}{\\mbox{$\\rm [M/H]$}}\n\\newcommand{\\logg}{\\mbox{$\\rm \\log g$}}\n\\newcommand{\\noise}{\\sigma_{n\\lambda}}\n\\newcommand{\\scatter}{s_{\\lambda}}\n\\newcommand{\\pix}{\\mathrm{pix}}\n\\newcommand{\\rfn}{\\mathrm{ref}}\n\n\\begin{document}\n\n\\title{\\tc:\\\\ A data-driven model for stellar parameter determination}\n\\author{M.~Ness\\altaffilmark{1},  \nDavid~W.~Hogg\\altaffilmark{1,2,3}, \nH.-W.~Rix\\altaffilmark{1}, \nA.~Ho\\altaffilmark{1}, \nG.~Zasowski\\altaffilmark{4,5}}\n\\altaffiltext{1}{Max-Planck-Institut f\\\"ur Astronomie, K\\\"onigstuhl 17, D-69117 Heidelberg, Germany}\n\\altaffiltext{2}{Center for Cosmology and Particle Physics, Department of Physics,\n             New York University, 4 Washington Pl., room 424, New York, NY, 10003, USA}\n\\altaffiltext{3}{Center for Data Science, New York University, 726 Broadway, 7th Floor, New York, NY 10003, USA}\n\\altaffiltext{4}{NSF Astronomy and Astrophysics Postdoctoral Fellow}\n\\altaffiltext{5}{Department of Physics \\& Astronomy, Johns Hopkins University, Baltimore, MD, 21218, USA}\n\\email{ness@mpia.de}\n\n\\begin{abstract}%\nNew spectroscopic surveys offer the promise of consistent stellar\nparameters and abundances (`stellar labels') for hundreds of thousands\nof stars in the Milky Way. \nThese labels are usually derived by comparisons with physics-based\nmodel spectra, which are technically challenging, and often use only a\nmodest fraction of the spectral pixels. \nIn many cases, however, there is a sub-set of \\emph{reference}\nobjects for which the stellar labels are known with high(er)\nfidelity; this is the case for \\tc.\nFrom the reference stars, \\tc\\ learns by fitting a very flexible\nmodel how the flux in each pixel of a continuum-normalized spectrum\ndepends on the `known' stellar labels; \\tc\\ then exploits this same\ndependence to derive new labels for the non-reference stars.\nWe illustrate \\tc\\ by applying it to the spectra of 56,000 stars from\n\\apogee\\ DR10. \nWe take \\teff, \\logg\\ and \\feh\\ as the labels, and 543 stars in 19\nclusters as the reference objects. \n\\tc\\ is very accurate; its stellar labels compare well to the 37,500\nstars for which \\apogee\\ pipeline (\\aspcap) labels are provided; we\nobtain \\textit{rms} differences of $\\delta\\teff< 100$~K, $\\delta\\logg< 0.2$~dex\nand $\\delta\\feh< 0.1$~dex.\nAside from the modeling of the training-set stars (which could happen\nin another data set or at another wavelength), \\tc\\ makes no use of\nstellar models nor any linelist; its biggest limitation is that it\nrequires a training set that spans the label-space. \nThe method degrades very weakly with signal-to-noise; \\tc\\ delivers\nthe labels with good fidelity even at one ninth the\n\\apogee\\ observing time. \nWe discuss the limitations of \\tc, and point out the potential of this\napproach to bring different spectroscopic surveys onto a consistent\nscale of stellar labels if they have sufficient objects in common.\n\\end{abstract}\n\n\\keywords{%\nmethods: data analysis\n---\nmethods: statistical\n---\nstars: abundances\n---\nstars: fundamental parameters\n---\nsurveys\n---\ntechniques: spectroscopic\n}\n\n\\section{Introduction}\\label{sec:Intro}\n\nThe vast spectroscopic stellar surveys of recent years (e.g., \\segue\\ \\citep{Beers2006}, \\rave\\ \\citep{Steinmetz2006}, \\lamost\\ \\citep{Newberg2012}, \\apogee\\ \\citep{Majewski2012}, \\gaiaeso\\ \\citep{Gilmore2012}, \\galah\\ \\citep{Freeman2012}) hold tremendous astrophysical promise, but at the same time present formidable data analysis and modeling challenges. \nOne of these challenges lies in consistently and accurately determining what we call ``stellar labels'', that is, stellar parameters and element abundances, from survey spectra. \nThese labels are usually determined from comparison of the data with synthetic model spectra, with approaches often \ncustomized specifically to the particular wavelength region of a given survey \\citep[e.g.,][]{ Lee2006, Boeche2011, Liu2014, Meszaros2013, Sm2014}. \n\nThe stellar photosphere models that are relied upon for stellar label determination have physical ingredients that are incomplete and simplified. \nFor computational feasibility, almost always 1D stellar photosphere models are adopted for large surveys, often assumed to be in local thermal equilibrium; these approximations are both severe. \nIn many cases, the model spectra do not account for all relevant molecular opacities, for convection, stellar winds, and the chromosphere. \nAs a consequence, it happens that different research groups obtain discrepant results for same stars, resulting from analysis across different wavelength regions and different input assumptions and methods used \\citep[e.g.,][]{Hinkel2014, Jofre2014, AP1999}. Even when the input assumptions are held fixed, differences in the employed analysis methods lead to substantial differences in assigned labels \\citep[e.g.][]{Sm2014}.\n\nStellar labels are commonly determined by fitting a grid of model spectra (with known labels) to the data using some minimization technique, often restricted to a masked portion of the spectrum that is focused on the absorption line (regions) deemed to be most reliable or relevant. \nStated minimal signal-to-noise requirement to obtain robust labels in this way are $SNR\\sim 100$ per resolution element, especially if the labels are to include individual element abundances. \nOften, a post-calibration procedure is applied to bring the stellar labels derived by such a fitting pipeline in accord with external information of higher fidelity: for example with stellar labels from benchmark stars studied at high resolution or well characterized open and globular cluster stars \\citep[e.g.,][]{Meszaros2013, Kord2013}\nIn practice, different surveys or different pipelines end up delivering labels with different calibrations:\nEither their stellar parameter or their abundances are on slightly different scales; this complicates\ninter-survey comparisons and constitutes major challenge of the era of such large datasets. \n\nIn this paper we propose and lay out a data-driven approach to deriving stellar labels from stellar spectra in the context of large spectroscopic surveys,\nwhich we dub ``\\tc''\\footnote{The name \\tc\\ is inspired by the astronomer Annie Jump Cannon,\nwho was the pioneer in producing stellar classifications without any input of physical models!}.\nThe main practical strengths of \\tc\\ are that it requires no physical model of the spectra, it is enormously fast, it can obtain labels of comparable accuracy to that quoted in current physics-based approaches\n but at far lower signal-to-noise ratio, and it offers a consistent way to cross-calibrate surveys. \nTo achieve this, \\tc\\ relies on the existence of a subset of objects within a survey\n(\\textit{reference objects}), for which the stellar labels are known sufficiently well and cover label space sufficiently.\n\nIn this context, the term ``\\emph{labels}'' refers to the pieces of information\nthat characterize and determine a stellar spectrum; these labels are commonly and sensibly split into \\emph{stellar parameters} and \\emph{element abundances}, although in the context of \\tc\\ it makes sense to treat them on a par. \nIn most cases, it suffices to think of the labels as \\teff , \\logg, and the element abundances \\xfe, although stellar rotation, micro-turbulence, age, and so forth can also be thought of as labels.\nIt is central to the approach we lay out here that objects with the same labels have (nearly) identical spectra and that spectra vary smoothly with label changes. \nThis must be true, if the set of labels is comprehensive enough so that it fully specifies the star; but if the labels are (for example) only \\teff, \\logg\\ and \\feh\\ then this is an approximation.\n\nThere are fundamentally two steps in \\tc. \nThe first step, or \\textit{training step} in \\tc\\ is to create from the spectra of the \\textit{reference objects} a very flexible generative model (with $\\sim 80,000$ parameters) that describes a probability density function (pdf) for the flux at every pixel in the continuum-normalized spectrum as a function of the labels.\nThe second step, or \\textit{test step}, assumes that this same generative model holds for all the other objects in the survey (dubbed \\textit{survey objects}). \nThen, the spectra of the \\textit{survey objects} and the generative model from the \\textit{reference objects}\nallow us to solve for---or infer---the labels of the \\textit{survey objects}. \nTaken together the \\textit{training step} and the \\textit{test step} effect a \\textit{label transfer},\ntransferring the known labels in the reference objects to the survey objects.\n\nTo make such an approach straightforward, we must assume that the \\textit{reference objects} and the \\textit{survey objects} were observed with the identical instrumental set-up, a condition well satisfied with the large surveys listed above. \nWe take the generative model for the continuum normalized flux at each of $N_\\pix$ pixels to be a polynomial function of all the labels, and hence the model is defined by its $N_\\pix$ sets of polynomial coefficients. In practice, there may be different circumstances that make stars suitable reference objects. \nThey may be members of star clusters: there, external data and the fact that clusters are in good approximation single stellar populations (which have to fall onto an isochrone) lend credibility to their stellar labels. \nAlternatively, reference objects could be stars for which labels have been derived separately from spectra of particularly high signal to noise, or at other ``easier'' or more extensive wavelength regimes (for example, in the optical as opposed to the infrared). \nFinally, they may be subsets of stars for which other approaches to get stellar parameters (for example, astroseismology) may provide accurate stellar parameters.\n\nWith this two-step procedure of training on spectra of reference objects and then transferring the label information to the survey objects, \\tc\\ falls into the class of \\emph{supervised methods} in machine learning. \nHowever, what we implement is very different in a crucial way from standard supervised methods for regression, such as support vector machines, random forests, and deep learning.\nThese other methods also try to fit a very flexible model to the training data at training time\nand deploy that model on the test data at test time.\nThe important difference, however, is that \\tc\\ is a \\emph{generative model} of the observed spectra:\nThat is, it constructs, as a function of labels, a probability density function (pdf) for the observed\nflux as a function of wavelength. \nThis makes \\tc\\ a bespoke method, not cleanly falling into any established machine-learning methodology.\nHowever, it gives us the enormous advantage that we can account for the uncertainties in the spectral data,\nincluding all the issues of heteroscedasticity and missing data.\nIt also makes the method agnostic about signal-to-noise.\nThis point is technical, but important:\nIn many real cases the training data will be much higher in signal-to-noise than the test data\n(standard stars tend to be bright and well observed).\nA method that does not properly account for the observational uncertainties will not transfer labels from high signal-to-noise reference objects to lower signal-to-noise survey objects with high fidelity.\nIn what follows, we show that \\tc\\ behaves very well as the signal-to-noise (or observing time) is decreased.\n\nIn this paper we use \\apogee\\ as the sole example. \nHowever, \\tc\\ can be applied to any stellar survey.  \n\nOur most basic implementation of \\tc\\ that we present includes only three labels, but this can easily be extended to additional labels  (for example, \\alphafe, \\xfe) and also more comprehensive models (for example, Gaussian processes). \nAdditionally, as we are using the information in every pixel, this methodology is effective at determining labels at lower signal to noise (SNR) than minimization techniques.\n\n\\tc\\ is similar to the MATrix Inversion for Spectral SythEsis (\\matisse) procedure\nfor derivation of stellar parameters \\citep{RB2006} in that it uses the full spectrum\n(and not just a line list) for label determination.\nHowever, \\matisse\\ employs a large grid of synthetic spectra\nand is thus limited in all the ways that physics-based methods are limited.\nThat said, a big part of why \\tc\\ is successful at lower signal-to-noise\nis that it uses all of the pixels in the data.\n\nWe have adopted a bottom-up approach for \\tc, starting with the most basic implementation and successively adding complexity to the generative model to determine the least complex implementation which works.  \nIn laying out the methodology of this approach we firstly describe the \\apogee\\ dataset and the way we process the data for both reference objects (543 stars) and survey objects ($\\sim$ 56,000 stars from DR10). \nWe then describe perhaps the simplest implementation of label-transfer possible, using a first-order linear model. We found this first-order model to be insufficiently flexible to describe the labels of the stars and so we extended our model to quadratic form, which satisfactorily describes the label-space of the training data.\nThe success of this model is demonstrated by running \\tc\\ through the DR10 data available through the SDSS-3 data server, the results for which we provide in an online machine-readable table. % for about 42,000 DR10 stars. \n\n\\section{Data}\\label{sec:Data}\n\\tc\\ expects (in its simplest form, presented here)\nall spectra---for reference and survey objects---to be continuum normalized in a consistent way,\nand sampled on a consistent rest-frame wavelength grid, with the same line-spread function.\nIt also assumes that the flux variance, from photon noise and other sources, is known at each spectral pixel of each spectrum.\nIn principle, \\tc\\ , as described below, is applicable to any large, homogeneous spectroscopic data set\nmeeting these criteria.\nHere, we use the \\apogee\\ data \\citep{Ahn2014} to illustrate and showcase \\tc.\nBecause all of the exposition of the method underlying \\tc\\ involves specificities of the data,\nwe spell out the characteristics of the \\apogee\\ data and our adjustments to it in \\sectionname~\\ref{sec:Apogee_as_worked_Example}.\n\n\\subsection{Choosing reference objects for the training step}\n\\label{sec:ReferenceObjects}\n\nFor the training step in \\tc\\ we must choose a set of reference (or training) objects for which we have spectra from the survey under consideration and \\emph{also} high-fidelity labels (that is, stellar parameters and element abundances that are deemed both accurate and precise).\nThe set of reference objects is critical, as the label transfer to the survey objects can only be as good as the quality of the reference label set. \nAlso, as \\tc\\ may have to interpolate and extrapolate to new parts of label space as\nit encounters new kinds of spectra among the survey objects, the quality\nof the label transfer depends on the extent to which the reference objects\ncover label space and the density with which they cover it.\nThe performance of a data-driven model like \\tc\\ will depend strongly on the size and quality of its training set of reference objects, much more strongly than the square-root of the number!\n\nIn practice, also for the \\apogee\\ data,\na good set of reference objects can be built from \nmembers of well studied open and globular clusters that have been observed in the context of the survey \\citep{Zaso2013}.\nThere is a variety of reasons why the stellar labels for cluster stars may be particularly accurate and robust.\nFor one, they could have their labels derived from independent, high resolution spectral analysis of these\nstars, e.g. from observations in a well understood portion of the optical wavelength region. The\nlabels for the reference objects only have to be accurate and trustworthy; but they are of course a property of the\nstar, and hence do not have to arise from the survey data at hand. They may have been derived from different data.\n\nFor the case of \\apogee, we will use as reference objects 543 members of 19 globular and open clusters data observed for the\ncalibration of their abundance pipeline \\citep{Meszaros2013}. Some objects were removed from the full list available in \\citep{Meszaros2013} as their cluster memberships were incorrect. In their stellar labels they span the range of $3500<\\teff<5300$~K, $0<\\logg<5$ and $-2.5<\\feh<0.45$. \nExactly which stellar labels we adopt for these reference objects is critical to the subsequent output, and hence \nwe discuss it in detail in \\sectionname~\\ref{sec:ApogeeRefLabels} .\n\n% MKN:  SHOULD THIS BE IN THE MAIN TEXT?  note there are 20 in their list but 1 gc has only 1 star and the abundance looks incorrect to me. DWH: No I don't think we should call this out explicitly in the paper it's more pointing out what I think is an error than adding anything useful.  In fact there are multiple errors in that list as confirmed by people at the APOGEE meeting - they know about them. \n\nAnother reason why cluster members make for good reference objects is because we can expect their stellar parameters to fall onto a single isochrone and to have near-identical abundances (at least for open clusters). This provides additional constraints on the labels.\nWe exploit that expectation in the case of \\apogee\\ and define ``Isochrone-corrected labels'', where we use Padova isochrones at the literature age and \\feh\\ of each cluster (see Figs. \\ref{fig:trainingaspcap} \\& \\ref{fig:trainingisochrone}, and \\sectionname~\\ref{sec:ApogeeRefLabels}).\n\nA spectral survey may also contain other sub-sets of objects with labels of particularly high fidelity that can serve as reference objects, such as the stars with \\logg\\ from Kepler's astroseismology in \\apogee . Or, one could simply choose as reference objects the subset of stars in a survey with the highest signal-to-noise spectra, if one can reasonably assume that the labels derived for those objects from physics-based spectral modeling are accurate. So, there are various sensible ways to choose the set of reference objects.\n\n%run -i fitiso_apogeetempfeh_paperrework2.py\n%makeonisochrone_training_4panel_revb.py\n\\begin{figure}[h!]\n\\centering\n    \\includegraphics[scale=0.33]{./plots/training_aspcap.pdf}\n\\caption{\\aspcap-corrected DR10 labels  for the training step in \\teff-\\logg\\ plane for 543 stars in the 19 clusters for which parameters are provided by APOGEE \\citep{Meszaros2013}. The age and \\feh\\ of the isochrones (in parentheses) is shown in each sub-panel. All labels adopted from the \\aspcap\\ corrected values of DR10 except for the Pleiades. }\n\\label{fig:trainingaspcap}\n\\end{figure}\n\n\\begin{figure}[h!]\n\\centering\n  \\includegraphics[scale=0.33]{./plots/training_mkn2.pdf}\n\\caption{Stellar labels for all reference objects as is \\figurename~\\ref{fig:trainingaspcap}, except that the \\logg\\ values have been adjusted from the \\aspcap-corrected value to exactly match the isochrone, we refer to this set of labels as  ``isochrone-corrected'' labels to differentiate them from the correction in \\figurename~\\ref{fig:trainingaspcap}.  }\n\\label{fig:trainingisochrone}\n\\end{figure}\n\n\\subsection{Consistent Continuum Normalization}\\label{sec:ContNorm}\n\n\\tc, as we present it here, operates on continuum-normalized spectra.\nContinuum-normalization that is based on quantiles of the data (medians or 90-th percentiles or the like)\nare very signal-to-noise dependent, e.g. because pixels that are clearly \\emph{not} continuum in high signal-to-noise\nspectra are completely consistent with being continuum at lower signal-to-noise.\nTherefore, to make \\tc\\ as independent of signal-to-noise (hereafter ``SNR'') as possible,\nwe base the continuum estimation on a pre-tabulated set of wavelength locations that we know\n(iteratively, from running \\tc\\ itself) are not strongly affected by absorption lines.\n\nTo initialize the continuum-pixel determination,\nwe define a preliminary pseudo-continuum normalization by \nusing polynomial fit to an upper quantile (for example, 80 or 90~percent) of the spectra, determined, for example, from a running median.\nThis is effective, but SNR dependent.\n  \nAfter a training step with spectra of reference objects that have been  normalized  by this pseudo-continuum,\nthe \\tc\\ can provide an improved identification of continuum regions in the spectrum: \nwe take those pixels to be continuum that show nearly unity flux in the spectral model's baseline spectrum (see \\sectionname~\\ref{sec:spectralmodel}), and at the same time show almost no dependence in their normalized flux on the stellar labels.\nThat is, for the \\apogee\\ data, we can determine with the \\tc\\ the `true' continuum, using the model derived from the pseudo-continuum normalized spectra for the reference objects provided by \\apogee, as described in \\sectionname~\\ref{sec:results}. This constitutes a data-driven method for finding continuum pixels, and we find it to have only a very small systematic dependence of the spectra on SNR (see \\sectionname~\\ref{sec:ApogeeContinuum}).\n\n\\figurename~\\ref{fig:norm} shows an example of our normalisation which is described further in Section~\\ref{sec:Apogee_as_worked_Example} applied to survey spectra with different labels. To illustrate the result, \\figurename\\ shows typical \\apogee\\ spectra and demonstrates how the spectra \nvary as a function of metallicity at a given temperature , and as a function of temperature at a given metallicity. \nFor a clearer view of individual absorption line features, we use narrower regions marked in this \\figurename, (A) and (B), for all subsequent examination of the spectral data. \n\n%. The continuum pixels used for the Chebyshev polynomial fit are shown in the black points.\n\n%made with makecontin_data2.py\n\\begin{figure}[h!]\n  \\includegraphics[width=\\hsize]{./plots/four_examples3.pdf}\n\\caption{Continuum normalized spectra for stars across a range of stellar labels; at top, two stars of similar temperatures at different metallicities and at bottom, two stars of similar metallicities and different temperatures. The grey shaded regions A and B indicate \\apogee\\ sample wavelength regions used for subsequent \\figurenames\\ in the paper.}\n\\label{fig:norm}\n\\end{figure}\n\n\\subsection{Specifics of the APOGEE Data Set}\n\\label{sec:Apogee_as_worked_Example}\n\nIn the application of \\tc\\ to  \\apogee, we start with the \\aspcapstar\\ and \\apstar\\ files of DR10. This data release comprises 47,000 stars observed in survey mode observed in the H-band, across a wavelength range of $\\approx$ 15200 - 16900 $\\AA$, observed at a resolution of 22,500 \\citep{Majewski2012}. The data is divided between three individual chips and separated spectral regions ($\\approx$ 15150-15800 $\\AA$, 15890 - 16430 $\\AA$ and 16490 - 16900 $\\AA$). The DR10 \\apogee\\ spectra is released in a number of data formats including \\apstar\\ and \\aspcapstar\\ fits files: The \\apstar\\ fits files include combined as well as single visit spectra that are reduced, resampled and shifted back to the rest frame. The \\aspcapstar\\ files include the combined spectra, resampled, reduced, shifted back to the rest frame and pseudo continuum normalized. The \\apstar\\  data, which are not pseudo-continuum normalized by \\apogee\\,  enables us to evaluate the performance of \\tc\\ at lower SNR, by testing using the individual visit spectra provided in these files. \n\nThe pixel-by-pixel inverse variances are critical for all steps of the \\tc\\ : continuum normalization, training step and test step. The error arrays of the uncertainty at each pixel in the spectra are provided by \\apogee\\ in their fits files. We adopt these vectors directly and additionally set any anomalous values in the spectra, with 0 flux or very high error values to an upper large constant limit error value, for computational stability.  \n\nAside from photon noise, a number of other factors can contribute to the errors of any pixel in \\apogee\\ spectra: poor sky subtraction, cosmic rays, reduction induced errors, high persistence and other noise sources. In addition to the variance arrays, one can also use any bad pixel masks, where the\ninverse variance and weighing of that pixel becomes $\\sim$ 0. We find that adopting additional masking from the bad pixel masks degrades our results when using the combined \\aspcapstar\\ spectra. However, our results are improved for individual visit spectra in the \\apstar\\ files when pixels flagged in the bad pixel mask array provided by \\apogee\\ are rejected, by assigning the large weighing in the error on those pixels, for the individual visit spectra. We therefore only implement the bad pixel masks from apogee for our tests on single visit spectra. \n\nThe pixel-by-pixel inverse variances are critical for all steps of the \\tc\\ : continuum normalization, training step and test step.  \nAside from photon noise, a number of other factors can contribute to the errors of any pixel in \\apogee\\ spectra: poor sky subtraction, cosmic rays, reduction induced errors, high persistence and other noise sources. In addition to the variance arrays, one must also use any bad pixel masks, where the \ninverse variance and weighing of that pixel becomes $\\sim$ 0. \n\nThe resampled, reduced and combined spectra are available for 49,200 stars in 150 of the 170 DR10 fields in the \\aspcapstar\\ files. There are a further 4800 stars in 20 fields taken in commissioning only in DR10 which are available in the radial velocity combined but not continuum normalized data format in the \\apstar\\ files and a further 3100 stars taken during commissioning across different fields. \nThe commissioning data, for which the \\aspcap-corrected labels are not all provided in the DR10 release, is only available in the radial velocity combined but not continuum normalized data format in the \\apstar\\ files. \n\nFor the continuum normalisation of \\apogee\\ spectra we implement a least-squares fitting to a low-order Chebyshev polynomial, but fitting only to the determined continuum pixels outlined in Section \\ref{sec:ApogeeContinuum}. We treat each of the three chips separately, and find a 2nd-order Chebyshev polynomial to be sufficient to apply to the data provided by \\apogee. We apply this normalisation to both \\aspcapstar\\ and \\apstar\\ files. Treating the three chips separately, we fit the polynomials over the wavelength regions of (i) 15150-15800 $\\AA$, (ii) 15890 - 16430 $\\AA$ and (iii) 16490 - 16950 $\\AA$. Fitting a polynomial has the disadvantage that they are poorly constrained at the edges of the data. An alternative implementation could use a more sophisticated sine or cosine function in place of a polynomial fit. \n\nWe did attempt to apply the \\tc\\ to the commissioning data, but could not evaluate the fidelity of these results as the line spread function of the commissioning data are different from the main survey and consequently the reference dataset of stars in the training step. \nTherefore, although we similarly process the \\apstar\\ spectra, returning the labels for these stars in our online table of DR10 parameters, the reliability of these is uncertain and they are subsequently flagged as commissioning data (see Table 1).\n\n\\subsubsection{Labels for the Reference Objects in APOGEE}\n\\label{sec:ApogeeRefLabels}\n\nWhich labels to adopt for the reference objects used in \\tc 's training step is a critical issue\nin any survey. We discuss two options here for \\apogee . \n\nFirst, we adopt the DR10 ``\\aspcap\\ corrected'' stellar parameters that are available for each of the reference objects as their labels, in order to place the output of \\tc 's test step for the survey objects on the \\apogee\\ \\aspcap\\ scale (\\figurename~\\ref{fig:trainingaspcap}). ``\\aspcap\\ corrected'' labels were not available for the cluster comprised of main sequence stars, the Pleiades cluster and for this cluster we made our own corrections in \\teff\\ and \\logg\\ and assumed a single literature value for the \\feh\\ label, as described below. \nThe reference set of stars we use is the very same stars used by \\apogee\\ to post-calibrate the output of \\aspcap\\ to a physical stellar parameter scale \\citep{Meszaros2013}.\nAdopting the \\aspcap\\ corrected labels provided and documented by \\apogee\\ has the important advantage \nthat we can test exactly how well we can reproduce the results from \\apogee\\ for the survey stars via label-transfer from only 543 stars.\n\nThe corrections to the labels made by \\apogee\\ based on the cluster data are applied to the immediate output of the \\aspcap\\ pipeline that arose from comparisons to a library of stellar models.\nTemperature corrections are determined by comparing the infrared flux temperatures of the stars \\citep{gonzalez2009}, \\logg\\ corrections are from the offset between \\aspcap\\ results and Kepler results for common stars and \\feh\\ corrections are from the difference between the \\aspcap\\ and  the literature value of each cluster.  \nThe \\apogee\\ corrections determined in \\citet{Meszaros2013} are valid only for stars with \\logg\\ $<$ 3.5 and are not implemented for the dwarfs.  We adopt the \\aspcap\\ corrected \\mh\\ values for these clusters and these are corrected to the \\feh\\ of the clusters and so we adopt this label as an \\feh\\ (that is, this label from \\apogee\\ therefore, does not explicitly use \\feh\\ lines, but is derived from an \\feh\\ correction). \nThe analysis in \\citet{Meszaros2013} is restricted not only to giants but also stars with SNR $>$ 70, determined to be the minimum SNR for reliable stellar parameters by \\apogee.\n\nThese corrections implemented by \\apogee\\ in \\teff, \\logg\\ and  \\feh\\ place the giants in the cluster stars on or near the isochrones (see \\figurenames~7 and 8 in Meszaros et al., (2013)).  \nAs there are no \\aspcap\\ corrections implemented for the 65 main sequence stars among the reference objects that we use, \nwe instead determine temperatures for these dwarfs, which are all in the Pleiades, directly using same correction method \nas in \\citet{Meszaros2013}. \nWe determine the infrared flux temperature for the stars from \\citet{gonzalez2009} and apply a correction to \nthe \\aspcap\\ output based on the offset in the temperature scales. For the dwarf stars in the Pleiades, we find the following relation:\n $T_{\\mbox{corrected}}$= 0.855*T$_{\\mbox{\\textit{\\aspcap}}}$ + 1206.7.\n\nWe do not attempt an individual metallicity correction for each dwarf star in the Pleiades but rather set all \\feh\\ of the dwarf spectra to \\feh\\ = 0.03 \\citep{barrado2001}.\nTests on the input labels to \\tc\\ demonstrate that there is only a small degradation of the results caused by adopting a single \\feh\\ for every cluster star for the literature value of the cluster, instead of individual \\feh\\ values for the stars (that is, from the \\aspcap\\ corrected values). \nTo determine the \\logg\\ for these Pleiades main sequence stars, we shift the stars vertically to their nearest positions on an appropriate age-metallicity Padova isochrone of 150~Myr at $\\feh = 0.03$ \\citep{girardi2000}. \nDue to the high differential reddening to the Pleiades, and the subsequent large temperature errors using the IR flux method that result from this, we only selected the 65 from a total of 72 Pleiades dwarfs, eliminating those with high extinction of SFD (corrected) E(J-K) $>$ 0.30 \\citep{Schlafly2011}.\n\nAdopting the input labels from the \\aspcap-corrected parameters determined from calibrations to literature cluster values also transfers the errors from the \\aspcap\\ pipeline: of $<$ 150K in \\teff,  $<$ 0.2 dex in \\logg\\ and $<$ 0.1 dex in \\feh.   \nThe uncertainties on the input labels will be included as an input parameter of the labels in a future development stage of \\tc. Inclusion of uncertainties may be particularly relevant when introducing multiple labels of individual elements. \n\nFor a comparative analysis to the ``\\aspcap\\ corrected'' labels (Figure \\ref{fig:trainingisochrone}), we adopt a \\logg\\ label for all of the training stars not from the Kepler scale, but rather from the best vertical fits to the isochrone for the ages and metallicities for the clusters from the literature (with the temperatures fixed).\nWe call these the ``Isochrone-corrected labels'', where we use Padova isochrones at the age and \\feh\\ of each cluster. \n\n\\section{The Generative Model of \\tc}\n\\label{sec:spectralmodel}\n\nWe now lay out the spectral model, whose parameters are determined \nfrom the spectra and stellar labels of the reference objects in the training step.\nSuch a generative model is based on two basic notions: first, that the continuum-normalized spectra of\nstars with identical labels look near-identical at every pixel, save for the observational errors\nand some intrinsic scatter. This must be true if the set of labels were exhaustive. \nIn practice, that is an approximation, as e.g. the spectra of stars with identical \\teff , \\logg \\ and \\feh\\ may differ, \nas these stars have different \\alphafe , age or rotation. Second, we presume that the expected flux at every pixel changes continuously\nwith changes in the labels.\nImportantly, the model is a probabilistic generative model that produces,\nfor every object spectrum at every wavelength,\na pdf for the flux, with an expectation value (mean) and a variance.\n\nWe presume there are $N_\\rfn$ reference objects $n$, each of which has\na continuum-normalized flux measurement $f_{n\\lambda}$ at wavelength\n$\\lambda$. Each of the training spectra $n$ has $K$ labels $\\starlabel_{nk}$, each of which\nis (for now) presumed to have negligible uncertainty and contained (possibly with transformations; given below)\nwithin a label vector $\\starlabelvec_n$.\n\nWe then presume that for any star, $n$, at any pixel, $\\lambda$,\nthe flux $f_{n\\lambda}$  can be described as some smooth function of the star's labels $\\starlabel_{nk}$\n($\\teff,\\logg,\\feh,\\cdots$).\nThe observations $f_{n\\lambda}$ will differ from such a model by the observational noise (form all relevant sources), $\\noise$. But even for perfect measurements we presume that there will be\ndeviations from the above approximate model for the true flux, characterized by a scatter $\\scatter$,\nwhich is a property of any particular pixel; we will subsume $\\scatter$ as a contributor to the noise.\n\nGenerally, we take a spectral model to be characterized by a coefficient vector $\\set{\\theta}_\\lambda$\nthat allows to predict the flux at every pixel $f_{n\\lambda}$ for a given label vector \n$\\starlabelvec_n$:\n\\begin{eqnarray}\nf_{n\\lambda} &=&\ng(\\starlabelvec_n |  \\set{\\theta}_\\lambda) + \\mbox{noise}\n\\label{eq:specmodel}\\quad \n\\end{eqnarray}\nAs a specific, but still flexible functional form for the spectral model we presume that it can be written as\na linear function of some vector $\\starlabelvec_n$, which is built from the labels: \n\\begin{eqnarray}\nf_{n\\lambda} &=&\n\\set{\\theta}_\\lambda^T \\cdot \\starlabelvec_n + \\mbox{noise}\n\\label{eq:linearmodel}\\quad\n\\end{eqnarray}\n\nwhere $\\set{\\theta}_\\lambda$ is the set of spectral model coefficients at each $\\lambda$. Each element of $\\starlabelvec_n$ can be some (possibly complicated) function of the full set of $K$ labels, $\\starlabelvec_n$, which\nresults in the flexibility of this model. The noise is an \\textit{rms} combination of the associated uncertainty variance\n$\\sigma_{n\\lambda}^2$ of each of the pixels of the flux from finite photon counts and instrumental effects and the intrinsic variance or scatter of the model at each wavelength of the fit, $s_\\lambda^2$.\nThis model assumes that the noise model is\n$\\mbox{noise} = [s_\\lambda^2+ \\sigma_{n\\lambda}^2]\\,\\xi_{n\\lambda}$,\nwhere each $\\xi_{n\\lambda}$ is a Gaussian random number with zero mean and unit\nvariance.\n\nThe simplest spectral model is that in which the label vector $\\starlabelvec_n$ is\nlinear in the labels, that is, in the vector of the individual labels themselves:\n\\begin{eqnarray}\n\\starlabelvec_n &\\equiv& [1,\n                           \\starlabel_{n1} - \\mean{\\starlabel_1},\n                           \\starlabel_{n2} - \\mean{\\starlabel_2},\n                           \\cdots,\n                           \\starlabel_{nK} - \\mean{\\starlabel_K}]\n\\label{eq:linear}\\quad,\n\\end{eqnarray}\nwhere the first element ``1'' will permit a linear offset in the fitting.\nThe $\\mean{\\starlabel_k}$ are offsets (possibly means of the training data) to\nkeep the model ``pivoting'' around a reasonable point in label space.\nThis model leads to the single-pixel log-likelihood function \n\\begin{eqnarray}\n\\ln p(f_{n\\lambda}\\given\\set{\\theta}^T_\\lambda, \\starlabelvec_n, s_\\lambda^2) &=&\n -\\frac{1}{2}\\,\\frac{[f_{n\\lambda} - \\set{\\theta}^T_\\lambda \\cdot \\starlabelvec_n]^2}{s_\\lambda^2 + \\sigma_{n\\lambda}^2}\n -\\frac{1}{2}\\,\\ln(s_\\lambda^2 + \\sigma_{n\\lambda}^2)\n\\label{eq:like}\\quad.\n\\end{eqnarray}\n\nThe vector $\\set{f}_\\lambda$ is the set of spectral flux values for\nall $N$ objects at the one wavelength $\\lambda$.\nWe can set the coefficients $[\\set{\\theta}_\\lambda,s_\\lambda^2]$ either by\noptimizing the likelihood (\\ref{eq:like}) over all reference objects or by applying priors and\nperforming some form of probabilistic inference (with, say, Markov\nChain Monte Carlo techniques).\nHere we will optimize for now, which can be done separately for each pixel $\\lambda$, where\nwe are treating the spectral model coefficients $\\set{\\theta}_\\lambda$ and the scatter $s_\\lambda^2$ as free parameters, and the\nlabels in the label vector $\\starlabelvec_n$, $\\starlabel_{nk}$ as fixed:\n\nThen, in the training step of \\tc\\ we exploit the fact that we know the $f_{n\\lambda}$\nand the $\\starlabelvec_n$, which permits to solve for the coefficients and the scatter of the spectral model:\n\\begin{eqnarray}\n\\set{\\theta}_\\lambda,s_\\lambda \\leftarrow \\substack{\\mbox{argmax}\\\\{\\set{\\theta}_\\lambda}, s_\\lambda}\n\\sum_{n=1}^N \\ln p(f_{n\\lambda}\\given\\set{\\theta}^T_\\lambda, \\starlabelvec_n, s_\\lambda^2)\n\\label{eq:trainingstep}\n\\end{eqnarray}\nThe linear-in-labels form (\\ref{eq:linear}) has a number of useful properties.\nThe coefficient vector $\\theta_{\\lambda 0}$ has a simple interpretation;\nit is the ``baseline spectrum\" of the spectral model. \nThe next coefficient vectors,  $\\theta_{\\lambda k}$, linear in \\teff , \\logg ~and \\feh,\ndescribe the lowest-order dependence of the spectrum on these labels.\nIn practical terms, the optimization of the model parameters $\\theta_{\\lambda k}$, at fixed scatter\n$s_\\lambda^2$ is a pure linear-algebra operation (weighted least\nsquares); simultaneous optimization of all the parameters\n$[\\set{\\theta}_\\lambda,s_\\lambda^2]$ is only nonlinear in the $s_\\lambda^2$\nparameter.\n\nThe (perhaps) second-simplest spectral model is that in which the\nvector $\\starlabelvec_n$ is quadratic in the labels: so this label vector is described as:\n\\begin{eqnarray}\n\\starlabelvec_n &\\equiv& \\begin{array}{l}[1,\n                          \\starlabel_{n1} - \\bar{\\starlabel_1},\n                          \\starlabel_{n2} - \\bar{\\starlabel_2},\n                          \\cdots,\n                          \\starlabel_{nK} - \\bar{\\starlabel_K},\\\\\n                          (\\starlabel_{n1} - \\bar{\\starlabel_1})\\,(\\starlabel_{n1} - \\bar{\\starlabel_1}),\n                          (\\starlabel_{n1} - \\bar{\\starlabel_1})\\,(\\starlabel_{n2} - \\bar{\\starlabel_2}),\n                          \\cdots,\\\\\n                          (\\starlabel_{nK} - \\bar{\\starlabel_K})\\,(\\starlabel_{nK} - \\bar{\\starlabel_K})]\\quad ,\n\\end{array}\n\\label{eq:quadinlabels}\n\\end{eqnarray}\n\nwhere the quadratic terms contain all possible products exactly once.\n\nFor the training step of \\tc , this quadratic-in-labels form of the spectral model (\\ref{eq:quadinlabels}) is similar to a the linear-in-labels form (\\ref{eq:linear}) in a number\nof ways.\nIt is still the case that optimization of the model, at fixed scatter\n$s_\\lambda^2$ is a pure linear-algebra operation (weighted least\nsquares), except that $\\starlabelvec_n$ has become longer for a given number of labels. \n\nHowever, the test step on the survey (described in the next Section) of the quadratic-in-labels form\n will no longer be simple; it will require non-linear\noptimization to estimate the labels.\n\nThe coefficients $\\theta_{\\lambda 0}$ can still be seen as an estimate of the\n\\emph{baseline spectrum} (provided that the offsets $\\mean{\\starlabel_k}$ are the\nmean tag values); the first-order coefficients $\\theta_{\\lambda k}$ can still\nbe seen as first derivatives of the expected spectrum with respect to\neach of the $k$ labels, but now evaluated at the baseline spectrum; the\nsecond-order coefficients $\\theta_{\\lambda kk'}$ can now be seen as mean\nsecond derivatives of the expected spectrum with respect to pairs of\nlabels $k$ and $k'$.\n\n\\section{\\tc's Test Step: Labeling Survey Spectra}\n\\label{sec:paramestimate}\n\nIn the previous Section, we trained or fit the parameters of\na data-driven probabilistic generative model for stellar spectra from the reference objects\nserving as training data.\nThis model has the property that, given labels (and noise variance estimates), it produces a\npdf for the continuum-normalized flux, that includes both observational and intrinsic\nscatter.\nIn this \\sectionname, we are going to solve the inverse problem:\nwe have spectra, but we don't have labels for them.\nIn this case, we will use inference and the just determined spectral model\nto obtain labels for the untagged survey\nspectra, which we also refer to as the ``test data'' in what follows. \n\nIn the test data there will be $M$ spectra $m$, each of which---as in\nthe training data---has a continuum-normalized flux measurement\n$f_{m\\lambda}$ at each wavelength $\\lambda$, and an\nassociated observational uncertainty variance $\\sigma_{m\\lambda}^2$.\n\nJust as in the training step, we consider the same likelihood function given in\nequation~(\\ref{eq:like}). But now we view it as a function of the \\emph{labels},\ninstead of the function parameters $\\set{\\theta}_\\lambda$ and\nscatter $s_\\lambda^2$.\n\nIn the test step of \\tc\\ we use the spectral model coefficients and scatter,\n($\\set{\\theta}_\\lambda,\\ s_\\lambda^2$), to be exactly those that were determined in the training step.\nWe then take the entire $N_\\pix$ spectrum of survey star $m$, $f_{m\\lambda}$ and optimize for the labels of that star:\n\\begin{eqnarray}\n\\left\\{\\starlabel_{mk}\\right\\} \\leftarrow \\substack{\\mbox{argmax}\\\\{\\left\\{\\starlabel_{mk}\\right\\}}}\n\\sum_{\\lambda=1}^{N_\\pix}\n\\ln p(f_{m\\lambda}\\given\\set{\\theta}^T_\\lambda, \\starlabelvec_m, s_\\lambda^2)\n\\label{eq:teststep}\\quad .\n\\end{eqnarray}\nThe labels $\\starlabel_{mk}$ for each survey star $m$ can be obtained either by maximizing\nthe likelihood function, or else by applying priors\nand performing probabilistic inference.\nAgain, we will optimize here. Our optimization is not convex in general, but in practice it is insensitive to initialization.\nThe right-hand sides of the training step (\\ref{eq:trainingstep}) and test step (\\ref{eq:teststep}) look formally quite analogous.\nBut in the test step we optimize over the labels, considering all pixels of one survey object at a time. In contrast,\nin the training step, we optimize over the spectral model coefficients and scatter, considering all reference objects\nat one pixel at a time.\n\nWhen we use the simple linear-in-labels form (\\ref{eq:linear}) for the\nmean model, the optimization to obtain maximum-likelihood labels\n(given parameters $[\\set{\\theta}_\\lambda, s_\\lambda^2]$) is simple linear\nleast-square fitting.\nThis optimization is obtained by straightforward linear algebra on the\nspectral pixels $y_{m\\lambda}$, and standard frequentist confidence\nintervals can be obtained similarly.\nWhen we use the quadratic-in-labels form (\\ref{eq:quadinlabels}) for the\nspectral, there is no simple linear-algebra operation that\noptimizes the likelihood. \nInstead an optimization function is used, the python curve$\\_$fit routine, which uses a non-linear least squares fit to fit the function to the data. \n\nWe have described how we construct a spectral model from the reference objects in the training step and then \nestimate stellar labels for survey stars with that model in the test step. \nWe now present in \\sectionname~\\ref{sec:results} the results of implementing our model for all \\apogee\\ data, where we applied a quadratic model; linear in the coefficients and non-linear in the label-inference.  \nFor the quadratic model we then show this applied to the DR10 data, including at lower SNR and investigate different input training labels. \n\n\\section{\\tc\\ in Action: Results with APOGEE Data}\n\\label{sec:results}\n\n\nWe now illustrate how \\tc\\ works in practice using \\apogee\\ DR10 data.  %The \\aspcap\\ corrected stellar parameter labels, derived as described in \\citet{Meszaros2013} and Garcia Perez et al., 2015 (in prep) are available for $\\approx$ 38,000 of these stars. \n\nTo apply \\tc\\ to \\apogee\\ data, we first train the quadratic model in Equation~\\ref{eq:quadinlabels} using the reference data and three labels chosen as described in Section~\\ref{sec:ApogeeRefLabels}. We then apply this model to all of the DR10 continuum normalized data, using continuum normalized \\aspcapstar\\ spectra described in Section~ \\ref{sec:ApogeeContinuum}. We use a leave-one-out cross-validation test to explore which complexity the spectral model must have and how comprehensive the set of reference objects should be. We then proceed with the same set of reference objects in the label transfer to the entire DR10 in the test step. In particular, we also apply the test step to spectra from individual APOGEE visits that have far shorter exposure times, and hence lower SNR than the co-added spectra in DR10, in order to explore and illustrate how well \\tc\\ does at modest SNR (with appropriate continuum fitting).\n\n\n\n\\subsection{The Choice of the Spectral Model Complexity}\n\\label{sec:ModelComplexity} \n\nTo evaluate the \\tc 's label-transfer we have to settle on a suitable functional form for the spectral model (\\ref{eq:specmodel}).\nTo start, one could consider picking the simplest -- namely linear-in-label -- spectral model, comprised of only four coefficients at every pixel (\\ref{eq:linear}).\nHowever, through take-one-out tests on the set of reference objects (see \\sectionname~\\ref{sec:take-one-out}), we found that this simple linear model was too inflexible to describe the spectral flux dependence on the labels.\nAs a consequence, the labels that emerged from the test step applied to the reference objects showed large and systematic deviations compared to ``known\" input label values,\nespecially at the extremes of the labels' ranges. \n\nThis is perhaps not surprising, as absorption features, particularly strong lines, are known to vary non-linearly as a function of stellar labels. If one were to insist on a label transfer with a first-order, spectral model, the systematic discrepancies could presumably be reduced by selecting only weak-line regions, but at the severe price of leaving much of the spectral range unexploited. Therefore, we have not pursued the linear-in-labels \\textit{Ansatz} for the spectral model.\n\n\nThe next simplest spectral model, the quadratic-in-labels case,\n presumes that the continuum normalized flux is a general second-order polynomial of the stellar labels, $f_{n\\lambda} =\n\\set{\\theta}_\\lambda^T \\cdot \\starlabelvec_n + \\mbox{noise}$ \n(\\ref{eq:linearmodel}), \nbut where $\\set{\\theta}_\\lambda$ now contains 10 elements at every pixel.\nFor the case of the three labels $(\\teff , \\logg , \\feh)$ the label vector $\\starlabelvec_n$\nbecomes  \n\\begin{eqnarray}\n\\starlabelvec_n &\\equiv&\n[1, \\teff, \\logg, \\feh, \\teff^2, \\teff\\cdot\\logg, \\teff\\cdot\\feh, \\logg^2, \\logg\\cdot\\feh, \\feh^2]\n \\label{eq:quadinthreelabels}\\quad.\n\\end{eqnarray}\nWe will use this quadratic-in-labels spectral model throughout the rest of the paper. \nThe exploration of higher-order polynomials for the spectral model at every pixel, or even a Gaussian process at every pixel, is beyond the scope of this paper. \n \n\\subsection{Validation on Take-One-Out Stars from the Reference Objects}\n\\label{sec:take-one-out}\n\nAs a first illustration of how well \\tc\\ works in practice, we perform a take-one-star out test on the set of reference objects.\nFor the take-one-star out test we train the spectral model iteratively on the spectra of all but one of the $N_\\rfn$ (=543) \nreference objects, and then apply \\tc 's test step to the spectrum of that remaining object. If we repeat this procedure $N_\\rfn$ times, \nwe have a first powerful test of how the result of this parameter transfer compares to the (known) labels for the reference objects.\n Here we only consider three labels $(\\teff , \\logg , \\feh)$, and the results are shown in \\figurename~ref{fig:takeonestarout}.\n\nThis \\figurename\\ immediately shows how well \\tc\\ works, at least in the circumstance at hand.\n\\tc 's purely mathematical approach of label transfer estimates the stellar labels (at least) as well as the astrophysical ASPCAP pipeline,\nover the full label range of our the reference data. The \\textit{rms} of the difference between the ASPCAP and \\tc\\ values for the three labels are\n95~K in $\\teff$, 0.24 in in $logg$, 0.08 in $\\feh$, with biases $\\Delta$ that are 3-7 times smaller.  \nThese variances inherently include some portion the uncertainties on the input labels (from ASCPAP corrected values, \nof \\teff\\ $<$ 150 K, \\logg\\ $<$ 0.2 dex and \\feh\\ $<$ 0.1 dex \\citep{Meszaros2013}.\nThe precision values stated in \\figurename~\\ref{fig:takeonestarout} are the formal uncertainties in the labels arising \nin the test step's optimization; for the SNR of the spectra in this take-one-out test, these errors are very small.\nIt is important to remember that the one left-out object and its spectrum are completely detached from the training step, \nexcept that they have the same experimental set-up and are likely drawn from a part of label space well-represented by the remaining reference objects.\n\nThere are a few outliers in \\figurename~\\ref{fig:takeonestarout}, cluster members of M3 in particular, that are offset in \\teff\\ and \\logg\\ space. \n\nThe Pleiades cluster, which has only spectra for main sequence stars, shows the poorest determination in the \\feh\\ label. We assigned all its members a single \\feh ~as reference labels, unlike the other reference objects, where we used their \\aspcap -corrected labels from DR10.\nThe \\textit{rms} is comparable to the estimated \\apogee\\ errors. The \\logg\\ label has the largest relative \\textit{rms} in the ASPCAP--\\tc\\ comparison, larger than the \\apogee\\ uncertainty, suggesting an internal uncertainty of $<$ 0.1 dex in \\logg\\ determined by \\tc.\nIf we adopt instead of \\aspcap -corrected \\logg labels the isochrone-corrected \\logg 's (see \\sectionname~\\ref{sec:ApogeeRefLabels}), the \\textit{rms} improves by 10\\% in \\teff\\ and \\logg .\n\n% made with takeonestarout_all_stars_diag_6panel.py in code/\n\\begin{figure}[h!]\n\\centering\n    \\includegraphics[scale=0.45]{./plots/takeout_histc.png}\n\\caption{The take-one-star-out cross-validation of the 543 stars in the training dataset using the quadratic model in equation~(\\ref{eq:quadinthreelabels}) and corresponding histograms at right, showing \\tc\\ output -- \\apogee\\ input labels.}\n\\label{fig:takeonestarout}\n\\end{figure}\n\n\nThe outlying stars in \\figurename~\\ref{fig:takeonestarout} may be due to an anomalous scale of the input labels of these stars compared to the other training data, or it may be a consequence of the model being too inflexible to properly model how flux changes with labels across the parameter space of the training dataset. \nThe temperature of the dwarfs is offset low at increasing temperature, compared to the input labels, so the model may be limited in describing the difference between dwarf and giant spectra. \nThere is a flattening at the low metallicity end of the model in \\feh\\ in the output labels at \\feh\\ $<$ -2.2, however this value of \\feh\\ = --2.2 also corresponds to the literature value of this cluster, M5 \\citep{Meszaros2013}. \nThe lower metallicity of the \\aspcap\\ label may represent internal scatter in the \\aspcap\\ results.\nThe fact that \\figurename~\\ref{fig:takeonestarout} shows only very small systematic offsets and such tight scatter leads us to conclude that for the\ncurrent context the quadratic-in-labels spectral model is sufficient in the label transfer. \n\nInterestingly, an analogous take-one-cluster-out test significantly increases the scatter in the label transfer, \nincreasing the \\textit{rms} differences to $<$ 150 K in \\teff, $<$ 0.4 dex in \\logg\\ and $<$ 0.12 dex in \\feh.\nThis indicates that our training set is sufficiently small that each cluster matters for a good label transfer. \nOne particular case in the \\apogee\\ context is the Pleiades cluster: it is the \\textit{only} cluster for which dwarf stars have been observed and hence we can draw reference labels for main sequence stars. \n \nWe now turn to illustrating where the information that led to the accurate label transfer (\\figurename~\\ref{fig:takeonestarout}) came from in the spectra.\n\\figurename~\\ref{fig:coeffs} shows -- across the narrow regions (A) and (B) of the spectra, marked in \\figurename~\\ref{fig:norm} -- the first coefficient vectors $\\theta_{0,1,2,3}$ of the spectral model (those linear in the three labels), which were fit in the training step for the quadratic-in-labels model in equation~(\\ref{eq:quadinlabels}). \n\n\nThe top panel shows the zeroth order-coefficient vector $\\theta_0$, or the baseline spectrum, of the model. \nThe mid panel shows the coefficients that are simply linear in \\teff, \\logg\\ and \\feh.\nIn the top panel of \\figurename~\\ref{fig:coeffs}, the red, blue and green shaded wavelength regions with the 5\\% \nhighest coefficient values $|\\theta_{1,2,3}|$ in the \\feh, \\teff\\ and \\logg\\ labels respectively. \nThese regions indicate where the spectra's flux levels strongly vary with these labels.\nThis also highlights that different parts of the spectrum depend differently on the labels. Note there are many regions where the \\feh\\ label dominates in contribution to the flux.\nFor the first label vector for example in the middle panel of \\figurename~\\ref{fig:coeffs}, \nthere is typically asymmetry for a given absorption feature, in the flux and the labels. \nThere are very few regions where the flux is a function of only one of the labels, and pixels are typically co-variant \n(that is, the same pixel will have a higher flux at both lower \\teff\\ and higher \\feh). \nThis simply reflects well-known co-variances between, for example, temperature and \\feh .\nThe strongest \\logg\\ dependence is typically associated with weak lines including the wings of the \nfeature and the \\feh\\ label, with strong lines, particularly the depth of the line. \n\nThe bottom panel of \\figurename~\\ref{fig:coeffs} shows the scatter vector of the spectral model, \nindicating the dispersion of the flux of the training data around the best-fit spectral model at each pixel. \nThe scatter is small and this indicates that our model is a good representation of the data. \nHowever, the scatter is highest where the most information in the spectra are contained. \nThis implies that either our quadratic-in-labels spectral model is still somewhat too restricted, or that the labels of our training dataset are imperfect or incomplete \n(for example, lacking $[\\alpha / Fe]$ as a label), or a combination of these effects. \nFrom the coefficients of an initial fit of this spectral models (see, for example, the middle panel of \\figurename~\\ref{fig:coeffs}), \nthe continuum pixels have been determined following \\sectionname~\\ref{sec:ContNorm}. \nThese are marked in the black dots in the top panel of the \\figurename, and are used for an iterated, \nconsistent continuum normalisation for all spectra, both of the reference and of the survey objects.\n\n%+\\textbf{HWR: }\\texttt{If that is the place where we praise, based on practical examples, the advantages of \\tc\\ vis-a-vis hand-defined \\textit{indices} of physical models, it should be more extensive... else, defer to discussion. - moved the paragraph on \\tc\\ being a tool to return coefficients so a full model - to the discussion} \n\n  %made with run -i makeplot_scatter_test18_step_revc.py\n\\begin{figure}[h!]\n\\centering\n    \\includegraphics[width=\\hsize]{./plots/R1_continuum5.png}\n  \\caption{The first-order coefficients and scatter across the sample regions of the spectra from \\figurename~\\ref{fig:norm}, A and B. Top panel: the baseline spectra representing the first coefficient from the set of reference spectra; middle panel: the next three coefficients ($\\theta_1$, $\\theta_2$, $\\theta_3$),  which correspond to the labels ($\\teff, \\log, \\feh$); bottom panel: the scatter of the fit with a tenfold expanded vertical scale.  The red, blue and green areas in the top panel encompass the wavelength regions with the 5\\% highest (absolute value) coefficients for the \\feh, \\teff\\ and \\logg\\ labels respectively. This indicates where the flux in these spectrum is particularly sensitive to the labels.  Note the \\feh\\ label is dominant in the contribution level and from the top panel it is clear that there is significant co-variance between the labels and there are only a few regions of \\logg\\ sensitivity. The filled dots in the baseline spectrum in the top penal indicate the wavelengths at which the dependencies on all labels are weak, which we operatively identify as continuum pixels (see \\sectionname~\\ref{sec:ApogeeContinuum}.}\n\\label{fig:coeffs}\n\\end{figure}\n\n\n\\textbf{DWH: caveat about our cross-validation and signal to noise}. \n\n\\subsection{Identification of \\apogee\\ Continuum Pixels}\n\\label{sec:ApogeeContinuum}\n\n\nThe continuum pixels shown in \\figurename~\\ref{fig:coeffs} for wavelength regions A and B, \nhave been determined from the training step with a quadratic-in-labels model operating on\nspectra normalized by their preliminary pseudo-continuum, using the coefficients returned (see \\sectionname~\\ref{sec:ContNorm}). About 35\\% of the pixels in the resulting baseline spectrum  (the vector $\\theta^0_\\lambda$) have flux levels within 1\\% of unity. However, not all these pixels are suitable continuum pixels, as many of them have significant dependencies,  $\\theta^{1,2,3}_\\lambda$, \non the three labels. In practice, a good set of continuum pixels can be identified from the APOGEE spectra using a flux cut in the baseline spectra of the model, 1 $\\pm$ 0.15 (0.985-1.015), combined with the smallest 20 - 30 percentile of the first order coefficients, $\\theta^{1,2,3}_\\lambda$,  which retains between 5-9\\% of pixels. We found empirically that changing the latter percentiles to ($\\theta^{1}_\\lambda$,$\\theta^{2}_\\lambda$,$\\theta^{3}_\\lambda$) $<$ (1e$^{-5}$, 0.0045, 0.0085) returns only 6.5\\% of the piels, but ultimately makes for an even  better match to the \\aspcap label scale; we adopt this procedure. We use the inverse variance weighting of these pixels for the corresponding 2nd order Chebyshev polynomial fit, adding an additional error term that is set to 0 for continuum pixels and a large error value for all other pixels so that the new error term $\\sigma^{'}_\\lambda$ for each pixel becomes:\n$\\sigma^{'}_\\lambda$ = $\\sigma_\\lambda$ + $\\sigma_{0|LARGE}$. \nAs we show explicitly in \\sectionname~\\ref{sec:lowSNR}, we find this to provide a robust continuum normalisation across the stars that are within the parameter range of the training set, across all SNR. \n\n\\subsection{\\tc 's Label Transfer for \\apogee\\ DR10}\n\\label{sec:APOGEE_DR10_comparison}\n\nGoing beyond leave-one-out tests on the set of reference objects, we now apply \\tc\\ to effect a label transfer to the entire \\apogee\\ DR10.\nWe take the spectral model built in the \\apogee\\ cluster stars in \\sectionname~\\ref{sec:ModelComplexity}, \\sectionname~\\ref{sec:take-one-out} and \\sectionname~\\ref{sec:ApogeeContinuum},\nand apply the test step with this model to all DR10 spectra.\nRemarkably, we are able to reproduce well the \\aspcap\\ labels for DR10 spectra. We have run \\tc\\ through all 47,000 stars in 150 fields in DR10 contained in the available \\textit{aspcapstar} files as well as an additional 4800 stars in 20 commissioning fields for which no \\aspcap\\ parameters were provided in DR10, \nmade available in the (non pseudo-continuum normalized) \\textit{apStar} files. \nWe also have run \\tc\\ through the additional commissioning stars available in the \\apstar\\ files across the fields and in total this\n comprises 56,000 DR10 stars in 170 fields. \n\nThese results of \\tc\\ for all DR10 stars for which we return parameters are provided online in \\tablename~\\ref{tab:online}. \nFor the 30,500 stars with parameters provided by DR10, we find we reproduce the \\apogee\\ labels as follows: \n\\teff\\ = +12 K $\\pm$ 87 K , \\logg\\ = --0.04 dex $\\pm$ 0.18 dex and \\feh\\ = +0.01 $\\pm$ 0.10 dex in \\feh. \nThe rms errors are comparable to the error estimates for \\apogee\\ parameters in \\citet{Meszaros2013} \nof $\\delta$(\\teff) $<$ 150 K, $\\delta$(\\logg) $<$ 0.2 dex and $\\delta$(\\feh) $<$ 0.1 dex in. \nThe typical internal precision on the measured parameters from \\tc\\ is $\\delta$(\\teff) $<$ 5.6 K, $\\delta$(\\logg) $<$ 0.01 dex and $\\delta$(\\feh) $<$ 0.006 dex.\n\n\\begin{table*}[!h]\n\\tiny{\n\\centering\n\\caption{Excerpt from full online version of table of parameters for the 56,000 stars released in 170 fields from \\apogee\\'s data release DR10. Stars with \\texttt{ROTATION WARN} = 1 flag set have unphysical stellar parameters and commissioning stars are marked with ``C'', the fidelity of the commissioning stars is uncertain given their different LSF from survey test and training data. Labels are provided for stars with both \\aspcap\\ corrected labels and ``isochrone corrected'' labels, with the results from the ``isochrone corrected'' labels (Figure 9) shown in the excerpt below. The velocity scatter from the \\aspcap\\ results as well as the \\texttt{APOGEE TARGET2} flag are provided in these tables.} \n\n% this table is: /Users/ness/Downloads/Apogee_raw/RevB/play3/mkn_TCA_v1_table1.txt\n\\begin{tabular}{| c | c | c |  c | c | c |  c | c | c | c | c | c | } %51,500\n\\hline\nstar ID & \\tiny{COMMIS} & \\teff\\ & \\logg\\ & \\feh\\ & $\\sigma$(\\teff) & $\\sigma$(\\logg) & $\\sigma$(\\feh) & $\\chi^2$ & \\tiny{VSCATTER} & \\tiny{ROTATION} & \\tiny{TARG2} \\\\\n{2MASS} &  & K &  dex  & dex & K & dex & dex & & kms$^{-1}$&  \\tiny{WARN} & \\tiny{ FLAG}  \\\\    \n\\hline\n\\tiny{21354474+4250256} &  0 &  4858.24 &  4.44 &  0.31 &  7.1  & 0.01 &  0.007  & 1.6  & 0.1 &  0 &  0\\\\\n\\tiny{21354775+4233120}  & 0 &  4687.4  & 2.81 &  0.09  & 9.9  & 0.04  & 0.013  & 1.4 &  0.0 &  0 &  0\\\\\n\\tiny{21355458+4222326}  & 0 &  4803.72  & 2.49 &  -0.37  & 8.0 &  0.02  & 0.008  & 2.6 &  0.0  & 0 &  0\\\\\n\\tiny{21360285+4231145} &  0 &  4572.67 &  1.87  & -0.49 &  9.5  & 0.04  & 0.013  & 1.5  & 0.0  & 0  & 0\\\\\n\\tiny{21360822+4225525} &  0 &  4812.71 &  2.85  & 0.01  & 8.2  & 0.02  & 0.008  & 2.7  & 0.0  & 0 &  0\\\\\n\\tiny{21360941+4212409} &  0 &  4823.58 &  2.71  & -0.45 &  13.2 &  0.04 &  0.013 &  1.2  & 0.0  & 0  & 0\\\\\n\\tiny{21361290+4216213} &  0 &  4717.6 &  2.53  & -0.26  & 6.8  & 0.02  & 0.008  & 2.9  & 0.0  & 0  & 0\\\\\n\\tiny{21361975+4156288} &  0 &  4765.75 &  2.88  & 0.26  & 7.6  & 0.03  & 0.01  & 1.7  & 0.0  & 0 &  0\\\\\n \\hline\n\\end{tabular}\n\\label{tab:online} }\n\\end{table*}  \n \nThe comparison of \\tc\\ with ASPCAP, showing the bias, rms and formal precision for the labels (\\teff , \\logg , \\feh ) in six sample fields, with bulge, disk and halo targeting, is illustrated in \\figurename~\\ref{fig:cal}. As for all stars in the survey with \\aspcap\\ labels, these fields show that we reproduce the \\aspcap\\ corrected stellar parameters with typical rms uncertainties of \\teff\\ $<$ 100 K, \\logg\\ $<$ 0.20 dex and $<$ \\feh\\ $<$ 0.10. These variances are slightly smaller than expected from our cross-validation leave-one-star-out test. This may be because the median of the stellar labels for the D10 survey object are near the median labels of the reference objects from the training step. \nThey are not concentrated to the extreme ends of the range, which have a higher weighting in evaluating the test data with cross validation. \n \\tc 's label transfer also returns values for those $\\approx$ 15\\% of stars in DR10 are that must be main-sequence dwarf stars. \nThese are not shown in \\figurename~\\ref{fig:cal}, as \\apogee\\ does not report ASPCAP corrected dwarf parameters for DR10. \nWe exclude the rapid rotators using the \\aspcap\\ \\rotwarn\\ flag as we can not return parameters for spectral types not included in our training set (see \\sectionname~\\ref{sec:AnomalousSpectra}). \n\nIn \\figurename~\\ref{fig:cal} we show the label differences of \\tc\\ $-$ \\aspcap\\ for the 1400 stars from the six sample fields as a function of \\aspcap\\ \\teff, \\logg\\ and \\feh. There are weak trends; at low \\teff\\ $\\sim$ 3700 K, we find temperatures about 100 K cooler than \\apogee\\ and at low \\logg\\ we find $\\sim$ 0.15 dex larger \\logg\\ than \\apogee. At the lowest metallicities \\feh\\ $<$ --2.0, we typically report higher metallicities on the order of 0.05 to 0.3 dex.\n\n\n%makeplot_fits_v19_bw.py\n\\begin{figure}[!h]\n\\centering\n  \\includegraphics[scale=0.23]{./plots/4431_v19.png}\n    \\includegraphics[scale=0.23]{./plots/4383_v19.png} \\\\\n      \\includegraphics[scale=0.23]{./plots/4399_v19.png}\n        \\includegraphics[scale=0.23]{./plots/4309_v19.png} \\\\\n              \\includegraphics[scale=0.23]{./plots/4311_v19.png}\n        \\includegraphics[scale=0.23]{./plots/4255_v19.png} \n\\caption{\\small{\\aspcap\\ DR10 versus \\tc\\ for six different fields including in the disk, bulge and halo. The number of stars is, for each subfigure is 211 (4431), 207 (4384), 217 (4399), 210 (4309), 198 (4311) 319 (4255) }}\n\\label{fig:cal}\n\\end{figure}\n\n%run -i makeplot_fits_v19_3by3c.py with plotfits_v19('listin.txt')\n\\begin{figure}[!h]\n\\centering\n        \\includegraphics[scale=0.35]{./plots/cplot2.png} \n\\caption{Difference between the labels (\\teff, \\logg, and \\feh) derived through \\tc\\ in the test step and their \\aspcap\\ DR10 values for all the 1400 stars shown in \\figurename~\\ref{fig:cal}. The error bars are dominated by those quoted by \\aspcap. There are systematic offsets at the coolest temperatures.}\n\\label{fig:cplot}\n\\end{figure}\n\n\nWe show \\tc 's resulting label distribution in the \\teff-\\logg\\ plane from \\tc\\ for the stars in DR10 in \\figurename~\\ref{fig:iso}. \nThis \\figurename\\ shows the result when \\aspcap -corrected labels are used for the reference objects in the training step; \\figurename~\\ref{fig:iso2} shows the analogous results but for isochrone-corrected reference labels. There are 37,500 stars in these \\figurenames\\ that remain after excluding stars with the \\rotwarn\\ flag set, with velocity scatter $>$ 10 \\kms\\ and telluric calibration target set. These \\figurenames\\ also show the labels for the 15\\% stars with \\logg $>$ 4 dex that must be main sequence stars.\n Only the stars that have been determined using targeting flags and inspection of the spectra to be dwarfs with rotation, \n have been removed using the \\aspcap\\ rotation warning set flag. \n Were we to force label transfer with \\tc , we find that the labels lie an unphysical space at very low \\feh\\ and \\logg\\ and high \\teff.\n\nIn short, for all stars with good \\aspcap\\ labels, we find excellent agreement between \\tc\\ and \\aspcap\\ by adopting ASCPAP corrected labels in the training step.\nIn addition, we are able to derive plausible parameters for dwarf stars in DR10. However, the \\teff-\\logg\\ plane for these stars shows a deviation from the giant branch of the isochrone at low \\logg\\ (see the right panel of \\figurename~\\ref{fig:iso}). This is a consequence of the input labels of the training spectra. \n\nIf instead we use the isochrone-corrected \\logg\\ labels to fix \\tc 's spectral model\n(see \\sectionname~\\ref{sec:ReferenceObjects}), the results of the label transfer deviate slightly from the \\aspcap\\ scale in each of the parameters. \nHowever, with these new \\logg\\ labels, we find a broad giant branch width that is consistent with expectations in \\teff-\\logg\\ space \ngiven the metallicity of these stars (see the right hand panel of \\figurename~\\ref{fig:iso2}). \n\nThis comparison again illustrates both the power of \\tc\\ to transfer labels, but also its dependence on the choice of suitable reference labels. \n\nCurrently, no priors are incorporated in the \\tc\\ to place the resulting label estimates near physically plausible isochrones. \nNonetheless, almost all stars lie in physical spaces on the isochrones as shown in \\figurenames~\\ref{fig:iso} and \\ref{fig:iso2} validates the labels. \nThe labels for the main sequence stars are presumably much more poorly determined, given the limitations of the reference objects in the training step. \nRemarkably, though, only a handful of stars at low \\feh\\ and low \\logg\\ do not lie near conceivable isochrones. \n\nAt metallicities \\feh\\ $<$ --0.25 the red clump is offset too high in the \\logg\\ label. This is noted in \\citet{bovy2014} who estimate that this offset shifts the red clump and red giant branches 0.2 dex closer together. \nOur \\logg\\ labels in \\figurename~\\ref{fig:iso} are essentially identical to \\apogee\\ ASPCAP labels (offset -0.04 dex in \\logg\\ for DR10) and the left panels show that the red clump stars which should be seen as a density maxima of stars around \\logg\\ $\\sim$ 2.5, \\teff\\ $\\sim$ %  \\includegraphics[scale=0.3]{./plots/takeoneout_diag_test18_222.pdf}K \\citep[e.g.,][]{Zhao2001} \nare offset to higher \\logg\\ than the red clump branch of the Padova isochrone, for stars \\feh\\ $<$ --0.25. \nThis offset is on the order of 0.2 dex at \\feh\\ = -0.5 and is present for both \\aspcap-corrected labels and isochrone-corrected labels. \nThis may indicate that the \\aspcap\\ temperature scale is offset too cool in DR10 (but as a function of \\feh).\n\n% made with makeonisochrone_v18_bw.py\n\\begin{figure}[!h]\n\\centering\n  \\includegraphics[scale=0.25]{./plots/iso1.png}\n  \\hspace{-20pt}\n    \\includegraphics[scale=0.25]{./plots/iso1a.png}\n%    \\includegraphics[scale=0.33]{./plots/isochrone_mkn20b2.pdf}\n\\caption{Labels for the $\\sim$ 38,000 stars from DR10 derived by \\tc\\ based on \\aspcap-corrected labels for the set of reference objects. The set of panels on the left shows \\teff-\\logg\\ in four metallicity bins. There are $\\sim$ 21,600, 14,000, 1700, and 900 stars in the most metal-rich to metal-poor metallicity bins, respectively. The isochrones plotted are 10 Gyr Padova isochrones at the metallicities marked in the upper left hand corners of each sub-panel.  The panel on the right shows all stars coloured in \\feh\\ on the four isochrones. Note the \\logg\\ distribution at low \\logg\\ is narrow and offset from the giant branch. }\n\\label{fig:iso}\n\\end{figure}\n\n\n\\begin{figure}[!h]\n\\centering\n \\includegraphics[scale=0.25]{./plots/iso2.png}\n  \\hspace{-20pt}\n    \\includegraphics[scale=0.25]{./plots/iso2a.png}\n%    \\includegraphics[scale=0.33]{./plots/isochrone_mkn20b2.pdf}\n\\caption{Same as \\figurename~\\ref{fig:iso} but based on the ``isochrone-corrected'' labels for the reference objects. In this case, the labels follow the red giant branch on the isochrones. Note that there is nothing in the mathematics of \\tc\\ (Equation \\ref{eq:specmodel}) that forces resulting labels to lie in physically plausible location in label space. This is illustrated by the tiny fraction of objects that lie between the main sequence and the giant branch. That most labels lie in physically sensible portions of the \\teff-\\logg\\ plane is a testament to both the quality of the label coverage in the set of reference objects and to the power of \\tc\\ approach. This is all the more remarkable as there are basically no main sequence stars among the reference objects.}\n\\label{fig:iso2}\n\\end{figure}\n\n\n\\subsection{Failures: Types of Spectra not Represented among the Reference Objects}\n\\label{sec:AnomalousSpectra}\n\n%run -i makeplot_scatter_test18_coeffs_dwarfs_RevB.py\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[width=\\hsize]{./plots/2dwarfs.png}\n\\caption{Examples of hot rotating dwarfs in the \\apogee\\ DR10 data across regions A and B, comparable to \\figurename~\\ref{fig:coeffs}. These types of stars are \\textit{not} included in our set of reference objects. Therefore, the label transfer by \\tc\\ leads to grossly unphysical label estimates.}\n\\label{fig:dwarfs}\n\\end{figure}\n\n\nThe dwarf spectra in our reference set only come from the Pleiades cluster, at a single metallicity. \nThis restricted sample limits our ability to determine the stellar parameters for dwarf stars. \nGiven these training data, our model \\textit{can} differentiate dwarfs from giants, as long as their spectra are comparable to that of the Pleiades. \nHowever, none of the dwarfs in our training set are hot rotating objects with broad line features. \nThree examples of stars with broad line features that are in the test data but not included in our training dataset are shown in \\figurename~\\ref{fig:dwarfs}.\n\nIt is possible to differentiate these stars with \\tc\\ because they are output in non-physical space in \\teff-\\logg, and present as a group of very metal poor, \\feh\\ $\\sim$ --2.0, low \\logg\\ stars $\\sim$ 0, with cool temperatures $\\sim$ 4000 K. The metal poor solution determined by \\tc\\ reflects the dearth of lines in the spectra for these hot stars, given the training model. This group of stars is flagged in \\aspcap\\ with a \\rotwarn\\ flag set. We therefore are able to exclude these stars from our analysis using this condition. \n \n\n \\subsection{Performance at modest SNR}\n \\label{sec:lowSNR}\n\n\nBy identifying `true' continuum pixels we have been able to implement a simple continuum normalisation that is robust across low and high SNR, which is valid across the parameter range of our training set. To examine how \\tc\\ performs at lower SNR, we have taken individual visits from the \\apstar\\ fits files, when there are $\\ge$ 4 visits, and run \\tc\\ on a single visit spectra, when consistently continuum normalized (\\sectionname~\\ref{sec:ApogeeContinuum}). Note, that we have not simply added noise to the combined DR10 spectra for our low SNR tests, which would bypass the question of how consistently the continuum can be defined at different SNR levels. Instead, we have treated single-visit spectra as (formally) independent survey objects. \\figurename~\\ref{fig:lowsnr} shows a comparison of a sample star for a single visit and combined visits ($>$ 4 total visits). \\figurename~\\ref{fig:SNR} presents the results of \\tc\\ compared to \\apogee\\ for these stars, showing \\textit{only} the \\apogee\\ stars with errors of $<$ 150 K in \\teff\\ and $<$ 0.25 dex in \\logg, across four SNR intervals, from 20 $<$ SNR $<$ 30 to 100 $<$ SNR $<$ 200.\n\nThese \\figurenames\\ illustrate that our approach to continuum normalization works well for both of these SNR regimes and is SNR independent, which is not true for a weighted-quantile normalisation. At the highest SNR (and \\apogee\\ estimates a upper noise floor of 200 although stars do measure above this), the rms difference between \\tc\\ and \\aspcap\\ is comparable to the \\aspcap\\ measurement errors, at 73K in \\teff\\, 0.18 dex in \\logg\\ and 0.11 dex in \\feh. At a SNR of 30-50, the rms error increases to 100 K, 0.2 dex and 0.10 dex in \\teff, \\logg\\ and \\feh\\, respectively. At an SNR of 20-30 the rms error is significantly higher and here the internal errors of \\tc\\ become comparable to typical minimisation methods and at SNR $<$ 20 exceed them. With this method we can return stellar parameters of \\teff, \\logg, \\feh\\ to as good a precisions as minimisation techniques ( \\teff\\ $<$ 100K, \\logg\\ $<$ 0.2 dex, \\feh\\ $< $0.1 dex) with an SNR of $\\ge$ 25. \n \n%run -i makecontin_data1_revc.py\n \\begin{figure}[!h]\n  \\includegraphics[width=\\hsize]{./plots/SNR_continuum6.png}\n  \\caption{Comparison of the continuum normalisation of the same star at high and modest SNR. The \\apogee\\ \\apstar\\ combined visit spectra is shown in the top panel (SNR = 120) and the \\apstar\\ spectra for the 4th visit (SNR = 25) is shown in the second panel. The bottom panel is the ratio of the continuum normalized spectra of the high and medium signal to noise spectra and the blue dashed line is a running median of this ratio over 20 $\\AA$, showing a small bias. The histogram of the ratio is given in at the right of the bottom panel.}\n\\label{fig:lowsnr}\n\\end{figure}\n\n%makeplot_fits_SNRtest.py in /play but changed to makeplot_fits_SNRtest_bw.py\n\\begin{figure}[!h]\n\\centering\n\\includegraphics[scale=0.25]{./plots/SNR100to200.png}\n\\includegraphics[scale=0.25]{./plots/SNR50to100.png}\\\\\n\\includegraphics[scale=0.25]{./plots/SNR30to50.png}\n\\includegraphics[scale=0.25]{./plots/SNR20to30.png}\n    \\caption{Illustration of \\tc's ability to estimate labels for spectra of modest signal to noise. Shown is the comparison of \\tc\\ labels derived for some single visit spectra, compared to the \\aspcap\\ label values derived from the co-added high signal to noise spectra. The single vista spectra are grouped in four different regimes of signal to noise. There are 60 stars in the 300 $<$  SNR $<$ 30 bin, 1200 stars in the 30 $<$ SNR $<$ 50 bin, 1100 stars in the 50 $<$ SNR $<$ 100 bin and 670 stars in the 100 $<$  SNR $<$ 200 bin. Note that the rms difference between those two label estimates increases more slowly than expected from the signal to noise of the single visit spectra: label transfer with \\tc\\  therefore enables label estimates at modest signal-to-noise. Each SNR regime shows the corresponding histograms of \\tc\\ - \\aspcap\\ for each label, at right.}\n\\label{fig:SNR}\n\\end{figure}\n\n\\clearpage\n\\section{Discussion}\n\n% HOGG: here is my proposed outline for the discussion\n% 1. first say what we accomplished and why it ROCKS\n% 2. then go through all of our deep assumptions, one at a time,\n%    and discuss what it would cost and what it would benefit to make weaker assumptions.\n%    This is a framework for discussing future directions without over-promising.\n\nWe have demonstrated with \\tc\\ that it is possible to label stellar\nspectra from extensive homogeneous surveys with stellar parameters \nand abundances (collectively ``stellar labels''), using not physical stellar models but rather a\n\\emph{training set} of reference objects. These reference objects must have trustworthy\nlabels and spectra with the same resolution, line-spread function, and\nwavelength coverage (though not necessarily signal-to-noise) as the data on the \nsurvey objects that require labeling.\nExcept for the fact that the reference objects must have been assigned\nlabels themselves somehow, presumably on the basis of physical models for stellar \nstructure and photospheres, we do not rely on explicit stellar photosphere models\nfor the spectra. \\tc\\  is based on the premise that (continuum-normalized) spectra of stars with the same labels\nlook the same, and that spectra vary smoothly with changing labels. \nThis makes it possible to propose a simple mathematical model for the spectrum as a function of the\nlables, and fix this model in the \\textit{training step}, operating on the spectra of the reference objects.\nIn the subsequent \\textit{test step} that same model can assign labels (and their uncertainties) to all\nother objects in the survey.\n\nIn a first application of \\tc, on the \\apogee\\ DR10 data, we focussed on the three most important labels, \\teff, \\logg, \\feh , and \nderived them for essentially all of the 52,000 DR10 survey stars, based on a training step that involved only 543 reference objects, i.e. 1\\% of the survey.  Remarkably, \\tc ~'s label transfer results in stellar parameter and metallicites that are as precise and accurate as those derived from\n\\apogee 's pipeline ASPCAP. In addition, \\tc\\ appears to produce -- at least in this present circumstance -- plausible labels for 6000 main sequence stars in \\apogee, even though only $\\sim 60$ main sequence stars were used in the training step (all of which are members of the Hyades cluster). \nIt is also remarkable that  the \\logg - \\teff\\  diagram of Fig.~\\ref{fig:iso2}~ shows basically no stars outside\nthe physically plausible regime, although \\tc\\ knows nothing here about stellar evolution save the training step.\n\nOur application to \\apogee\\  illustrated a number of further strengths and practical advantages of such an approach. First, \\tc\\ is computationally very fast. It  trains fast and then delivers labels the 52,000 stars of the\n \\apogee\\ DR10 sample in reasonable time on a single laptop: it takes $<0.1$~s on a 2.6-GHz\nintel core i7 to determine three labels for each survey star, without any\nattempt at code optimization. This is because \\tc\\  only involves linear algebra and in the test step the well-behaved optimization of a few parameters with an analytic model for the spectrum. \n\nSecond, we have explicitly demonstrated that \\tc\\ can deliver labels, at least these three labels, \nwith nearly the same precision at much lower signal-to-noise than commonly deemed necessary. \nThe \\textit{rms} difference between  ASPCAP labels from spectra with $SNR\\ge150$ and \\tc\\ labels\nfor the same stars from $SNR\\sim 50$ survey spectra is only 30\\% larger than the ASPCAP error bars. \n\\tc\\  exploits the information at all pixels and certainly the labels \\teff, \\logg, \\feh\\  affect many different parts of each spectrum. How this SNR behaviour scales to label sets of higher dimension, encompassing e.g. individual abundances, remains to be seen. Part of the reason for this good behavior at low SNR is presumably that\n\\tc\\ contains a generative model of the intensity or flux density.\nGiven labels, the model provides a Gaussian \\textit{pdf} for the flux density at every wavelength.\nThis \\textit{pdf} is convolved (trivially) with the Gaussian uncertainty\nassigned to each pixel measurement in the data when the comparison is\nmade between the observed data in the survey object spectra with the\ngenerative model, straightforwardly accomodating\nheteroscedastic uncertainties from spectrum to spectrum.\n\nThird, \\tc\\ requires and provides a continuum estimate that remains robust \nand unbiased among spectra of different SNR. The training step of \\tc\\ itself identifies the \npixels that have near-unity flux in preliminarily normalized spectra, {\\it and} that show little flux variation with \nlabel changes. Those pixels are, conceptually and practically, good approximations to pixels to which to fit a smooth continuum. Our initial application to \\apogee spectra had indicated that biased continuum fits spectra would be the main source of poor label estimates from lower SNR spectra using \\tc , and may well also be for label estimates based on physical models. \n\nOur initial application of \\tc\\ to \\apogee\\  DR10 data, however, also brought to the fore and illustrated a number of important approximations and limitations.\nWe discuss some of these now, along with the benefits and costs of relaxing\nthese assumptions and approximations. Some of them are attributable to the \nparticular implementation of \\tc , which is just the tip of a large iceberg of potential\nmethods for transfering labels from a set of reference objects to a\nset of unlabeled survey objects. But some limitations are inherent to the overall approach. \nThese approximations mainly revolve around the (reference) labels on the one hand, and the choice \nof the spectral model on the other hand. \n\nThree important issues arise around labels. 1) The labels are so far assumed to be perfectly known, \nbut in reality are both noisy and potentially biased. In turn, we presume that we\nhave simply no infomation on the labels of the survey objects. Yet,\nwe know \\emph{something} about the unlabeled stars (for example, from\nphotometry, and stellar evolution models)\n2) No set of reference objects will cover the label\nspace comprehensively, especially if one considers high-dimensional label spaces (\\apogee 's DR12\npublished 16 labels per star!). 3) Any choice for the dimensionality of the label space, 3D in our sample application, will be incomplete in an astrophysical sense. Clearly, stars with identical \\teff, \\logg, \\feh may have different spectra, e.g.\nbecause they differ in $[\\alpha/Fe]$ or $v_{rot}$.\n\nThe general approach to first but also third issue is to expand the scope of the model. The model currently only generates spectra by providing a \\textit{pdf}\nover spectral pixel intensities given a set of labels.\nSymbolically we could write that \\tc\\ in its current implementation\nlearns or provides a conditional \\textit{pdf}\n$p(f_\\lambda\\given\\starlabelvec,\\set{\\theta}_\\lambda, s_\\lambda^2)$ (see Eq.\\ref{eq:like}).\nGiven a prior on the label space\n$p(\\starlabelvec)$, the \\tc\\ could straightforwardly become a generative model of both\nthe spectral pixel intensities \\emph{and} the labels.\n\nThis would also make it possible to learn the parameters $\\set{\\theta}$ from\nreference objects with noisy labels: at the moment, we effectively \nassume for the reference objects that $p(\\starlabelvec_n)$ is a delta-function \nat the known labels. For noisy labels of the reference objects \nwe would set $p(\\starlabelvec_n)$ instead to reflect the label uncertainties. \nOne would then, however, have to optimize simultaneously\n$\\set{\\theta}_\\lambda$ for \\textit{all} $\\lambda$ pixels and the labels $\\starlabelvec_n$\nfor \\textit{all} $n$ reference objects. Missing labels among some of the reference\nobjects could then be treated pragmatically as simply having very large uncertainties.\n\nThinking of \\tc\\ as a model for both the spectral intensities and the labels\nalso shows how any (much more limited) external information on the labels of the survey\nobjects could be incorporated. One learns from the reference and survey objects\nsimultaneously (effectively, lifting the separation of training and test step),\nby optimizing $\\set{\\theta}_\\lambda$ and $\\starlabelvec_n$, where the index $n$ now \nencorporates the entire survey sample. The difference between reference and survey objects\nnow simply consists in how tighly constrained their $p(\\starlabelvec_n)$. \nFor survey objects, $p(\\starlabelvec_n)$ will likely be broad, e.g. constraining label-combinations\nto physically plausible isochrones. This would combine aspects of \\tc\\ with the approach\ntaken by \\cite{SB2014}.\n\nA generative model of both the spectra \\emph{and} the labels\nwould in principle be much more powerful than the current generative\nmodel of spectra alone.\nThat said, these joint optimizations of parameters and labels would be\nexpensive and multi-modal, so it might not be computationally\ntractable.{\\bf HWR's random thought: Gibbs sampling, separating $\\theta$'s and l's???}\n\nIn this initial implementation of \\tc\\ we restricted ourselves to producing only the maximum-likelihood estimates for both the $\\set{\\theta}_\\lambda$ in the training step, and the $\\starlabelvec_n$\nin the test step, with label errors only coming from the inverse covariance matric at that point.\nBut a full inference would be expensive, especially in the test step\n(labeling the survey objects); the test step model is non-linear and\ninference would require sampling or harsh approximations.\n\nNote that in the application of \\tc\\ to \\apogee\\ we did deal with systematic errors in the reference\nlabels, but did so by adjusting them,  given the unphysically narrow giant branch returned for DR10 data at low \\logg.  We empirically found by adopting a very naive calibration that shifts the stars to the nearest position on the isochrone from the \\aspcap\\ value described in \\sectionname~\\ref{sec:ReferenceObjects}, the stars were returned in a \\teff-\\logg\\ space, across metallicity, in line with expectations of the physical label-space of stars. This suggests that there is some problem with the input labels in either the \\teff\\ or the \\logg\\ dimension adjusted from Kepler results in DR10. \n\n %We have barely scratched the surface with what is possible with this methodology given our restricted training dataset, model and labels. \n %Our training dataset itself is clearly too small, comprising only 545 stars including a set of dwarfs at a single metallicity (+0.03 dex). \n\nThe other two issues raised above, on the dimensionality and on the coverage of label space by the reference objects, are linked: \nthe basic implementation of \\tc\\ presented here considers only three\nlabels (\\teff, \\feh, and \\logg), and we know that the label-space has many more dimensions.\nConceptually, it is trivial to extend \\tc\\ to even much larger numbers of labels per star. \nFor example, a next generation could include \\alphafe\\ or \\xfe\\\nlabels for elements X.\nThe only limitation---and it is a \\emph{substantial} limitation---is\nthat as the label-space grows, we presume that the training set must grow to fill it.\nAfter all, \\tc\\ can only be as good as its training set.\nIn general, the training set needs may scale up as badly as exponentially\nwith the dimensionality of the label space. Therefore, it is at this point an open issue, to \nhow many label-dimensions \\tc\\ continues to be useful and practicable. \n\nBut there are also important, limiting assumptions about the spectral model itself. With the pixel-by-pixel polynomial \\textit{Ansatz} for the spectral model $\\set{\\theta}_\\lambda$\nwe engender two important consequences: first, we need to pick a functional form for the spectral model\n(eq. \\ref{eq:specmodel}), which we took empirically to be a quadratic-in-labels form of Eq. \\ref{eq:linearmodel};\nbut we arrived at that choice by empirical experimentation with this particular data set; but this choice can be generalized.\nIndeed, the polynomial family is probably not the best family of\nfunctions to be exploring, since they extrapolate badly (edge effects)\nand require explicit, qualitative choices about order and cross-terms.\nIt is probably better to eventually move to a non-parametric form for the functions,\nsuch as Gaussian Processes or similar.\nIn this case, model complexity would be controlled by continuous\nparameters and the functional form could become very complex at the pixels where the data in the\ntraining step warrant it.\nThis would be a natural extension of what has been implemented here.\n\nSecond, our current \\textit{Ansatz} treats all\nspectral pixel independently, which they plausibly are only in their noise properties.\nThis approximation was made to make the system fast; training\n(learning) can take place at each wavelength independently and (in\nprinciple) in parallel.\nHowever, it is not a good approximation for many reasons.\nOne of these is that the finite resolution of the spectrograph\ncorrelates nearby pixels; the generative spectral model cannot vary\nsubstantially over wavelength differences that are far smaller than\nthe spectrograph resolution.\nThis point of prior information is not used at all in the model.\n\nA much more complex reason that the independent-pixel assumption is \nimperfect is that there\nare multiple lines from the same element and same ionization state.\nThese are expected to be covariant in any sensible model.\nWe do not make any use of such information; indeed no line list enters\n\\tc\\ at any stage.\nThese decisions were made for good, pragmatic computational reasons.\nA better model would permit itself to know about the spectrograph\nresolution and either know about or discover sets of lines that vary\ntogether.\nHowever, any such generalization will come at substantial computational cost.\n\nBoth the application to \\apogee\\ data and the possibilities to apply \\tc\\ in a broader context, bring the question of suitable sets of reference objects into focus. Indeed, in the long run the biggest practical problem in applyting \\tc\\ may not linked to the mathematics of the method \\textit{per se}, but to the actual availability of sufficiently many and sufficiently diverse reference objects in the survey to cover label space in the training step. In the \\apogee\\ DR10 case at hand the most glaring issue, even with only three labels per star, is \nthat fact that all main sequence stars in the reference set of objects come from only one cluster, without any range in metallicity. With e.g. the DR12 of \\apogee\\ training sets of much higher dimensionality are becoming available (especially [X/H] of individual elements). While this prospect is exciting, it well exacerbate both the question of how to make labels space coverage sufficient for the training step, and how to assert the accuracy of the training labels in the first place. \n\nAs mentioned before, reference objects in general (just) need to satisfy three conditions: they must have trustworthy labels; they must cover label space; and we must have the same type of spectra for them as for the survey objects. This actually leaves quote a number of options in picking reference objects. One could pick a subset of survey objects (sensibly covering label space) where the spectra have exceptionally high SNR, \nlending particular credence to the labels derived from physics-based models. On these, one would train the spectral model and then transfer labels to the remaining survey objects, effectively deriving most of the survey labels from the observations og highest SNR.\nAlternatively, as we did here, one can choose reference objects where special circumstance (cluster membership, astroseismological information) lend particular credence to their labels. \n\nBut, very importantly, the reference labels -- being a property of the star not of the data set at hand -- could come from completely independent sources of information. Even if we understood absolutely nothing about near-IR spectra, but had labels for the 543 reference objects from optical spectroscopy, we could have derived the DR10 labels for \\apogee\\ as well as ASPCAP. This leads to perheps the most exciting long-term prospect of \\tc : bringing\nqualitatively different stellar surveys---surveys that use different\ninstruments, working in different wavelength regions at different\nresolutions and SNRs---onto a consistent stellar parameter and\nchemical abundance scale.\nSo long as different surveys can agree on benchmark stars and best\nvalues for the stellar labels, and so long as those training sets are\nlarge enough and span enough of the label space, \\tc\\ (or a future\nupgrade that implements some of the ideas in this \\sectionname) can be\nused to ensure that all of the surveys are delivering stellar\nparameters on the same system.\n\\tc\\ will not make the data coming from any survey more\n\\emph{accurate}, but it might serve to make the whole industry of\nstellar parameter estimation and element abundance tagging more \\emph{precise} and consistent.\n\nThis prospect of survey self-labelling (e.g. from high SNR to low SNR) and the prospect of cross-survey calibration brings even more urgency to assuring that sufficient calibration observations are in place and that the different major spectroscopic surveys have sufficient sample overlap.\n\n%{\\it IMPORTANT: largely redundant with thigs said previously\n%Although we use \\apogee\\ as an example, \\tc\\ can be applied to\n%any stellar survey.\n%Details of how the spectra are continuum-normalized might have to be\n%customized for different surveys, which will have different\n%line-spread functions and different absorption-line densities, and\n%therefore different statistics.\n%In all other respects, however, \\apogee\\ could be replaced by any spectroscopic\n%survey that meets the following criteria:\n%It must contain a set of reference stars with known labels to serve as\n%a training set.\n%It must deliver a set of spectra represented on a common rest-frame\n%wavelength basis.\n%It must deliver noise variance estimates at every spectral pixel.\n%}\n%\n%{\\it IMPORTANT: need to make sure this gets not lost.. .......\n%We expect to not gain the same advantage for individual elements with the SNR, but it may be possible to combine elements into subgroups (for example, alpha, light elements, neutron capture) of covariant spaces \\citep[e.g.,][]{Ting2012}. In this way we exploit more pixels in the spectra and can operate at significantly lower signal to noise without being penalised in dimensionality of the returned parameter and abundance space. \n%This suggests the possibility to dramatically either reduce the cost of survey, or multiply the number of stars observed by a factor of $\\ge$ 2 for the same scientific gain. }\n%\n%\n%{\\it IMPORTANT: need to make sure this gets not lost.. .......\n%Given that the reference objects might have obtained labels from data\n%in other wavelength regions, the method doesn't require---even\n%implicitly---the existence of explicit physical models at all for the\n%wavelength domain of the spectra used by \\tc.}\n%\n%{\\it IMPORTANT: ought to go somewhere .......\n%In using all of the pixels in the spectrum to obtain the\n%stellar labels, \\tc\\ is not dissimilar from the MATrix Inversion for\n%Spectral SythEsis (\\matisse) procedure for derivation of stellar\n%parameters \\citep{RB2006}.\n%That is, \\matisse\\ does well at low signal-to-noise for the same\n%reason as \\tc:  They both use the full spectral range.\n%However, \\matisse\\ employs a large grid of synthetic spectra and\n%characterises a set of basis vectors which project onto each observed\n%spectrum to determine stellar labels by calculating an optimal\n%combined synthetic spectrum describing the stellar flux.\n%Conversely, we use a data-driven model and do not project onto any\n%subspace or combined theoretical spectrum.\n%}\n\n\\acknowledgements\n\nWe would like to thank Daniel Foreman-Mackey (NYU), \nMorgan Fouesneau (MPIA), Jon Holtzman (NMSU),  Keivan Stassun (Vanderbilt University) and Jennifer Johnson (OSU)\nfor valuable discussions.\nDWH was partially supported by\nthe NSF (grant IIS-1124794), NASA (grant NNX08AJ48G), and the\nMoore--Sloan Data Science Environment at NYU.\nThe research has received funding from the European Research Council under the European\nUnion's Seventh Framework Programme (FP 7) ERC Grant Agreement n.\n[321035].\n\nFunding for SDSS-III has been provided by the Alfred P. Sloan Foundation, the Participating Institutions, \nthe National Science Foundation, and the U.S. Department of Energy Office of Science. The SDSS-III web site is \\url{http://www.sdss3.org/}.\n\nSDSS-III is managed by the Astrophysical Research Consortium for the Participating Institutions of the SDSS-III Collaboration\n including the University of Arizona, the Brazilian Participation Group, Brookhaven National Laboratory, Carnegie Mellon University, \n University of Florida, the French Participation Group, the German Participation Group, Harvard University, the Instituto de Astrofisica \n de Canarias, the Michigan State/Notre Dame/JINA Participation Group, Johns Hopkins University, Lawrence Berkeley National Laboratory, \n Max Planck Institute for Astrophysics, Max Planck Institute for Extraterrestrial Physics, New Mexico State University, New York University, \n Ohio State University, Pennsylvania State University, University of Portsmouth, Princeton University, the Spanish Participation Group, \n University of Tokyo, University of Utah, Vanderbilt University, University of Virginia, University of Washington, and Yale University\n\n\n\\bibliography{tc3.bib}\n\n\n\\end{document}\n", "meta": {"hexsha": "d07a8ed5c751ce88ad4a8bbbb45ad271c05b629b", "size": 100338, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/datadriven.tex", "max_stars_repo_name": "HWRix/TheCannon", "max_stars_repo_head_hexsha": "d4c059e63b61be8cf9327b51970041898a4f4212", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documents/datadriven.tex", "max_issues_repo_name": "HWRix/TheCannon", "max_issues_repo_head_hexsha": "d4c059e63b61be8cf9327b51970041898a4f4212", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/datadriven.tex", "max_forks_repo_name": "HWRix/TheCannon", "max_forks_repo_head_hexsha": "d4c059e63b61be8cf9327b51970041898a4f4212", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.5875, "max_line_length": 1159, "alphanum_fraction": 0.7747015089, "num_tokens": 25122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521105, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.41732786709209224}}
{"text": "\\documentclass[12pt,letterpaper,oneside,reqno]{amsart}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{float}\n\\usepackage{mathrsfs}\n\\usepackage{colonequals}\n\\usepackage[font=small,labelfont=bf]{caption}\n\\usepackage[left=1in,right=1in,bottom=1in,top=1in]{geometry}\n\\usepackage[pdfpagelabels,hyperindex,colorlinks=true,linkcolor=blue,urlcolor=magenta,citecolor=green]{hyperref}\n\\usepackage{setspace}\n\\usepackage{graphicx}\n\\usepackage{spverbatim}\n\\onehalfspacing\n\\emergencystretch=1em\n\n\\linespread{1.25}\n\n\\newcommand \\anglePower [2]{\\langle #1 \\rangle \\sp{#2}}\n\\newcommand \\bernoulli [2][B] {{#1}\\sb{#2}}\n\\newcommand \\curvePower [2]{\\{#1\\}\\sp{#2}}\n\\newcommand \\coeffA [3][A] {{\\mathbf{#1}} \\sb{#2,#3}}\n\\newcommand \\polynomialP [4][P]{{\\mathbf{#1}}\\sp{#2} \\sb{#3}(#4)}\n\n% ordinary derivatives\n\\newcommand \\derivative [2] {\\frac{d}{d #2} #1}                              % 1 - function; 2 - variable;\n\\newcommand \\pderivative [2] {\\frac{\\partial #1}{\\partial #2}}               % 1 - function; 2 - variable;\n\\newcommand \\qderivative [1] {D_{q} #1}                                      % 1 - function\n\\newcommand \\nqderivative [1] {D_{n,q} #1}                                   % 1 - function\n\\newcommand \\qpowerDerivative [1] {\\mathcal{D}_q #1}                         % 1 - function;\n\\newcommand \\finiteDifference [1] {\\Delta #1}                                % 1 - function;\n\\newcommand \\pTsDerivative [2] {\\frac{\\partial #1}{\\Delta #2}}               % 1 - function; 2 - variable;\n\n% high order derivatives\n\\newcommand \\derivativeHO [3] {\\frac{d^{#3}}{d {#2}^{#3}} #1}                % 1 - function; 2 - variable; 3 - order\n\\newcommand \\pderivativeHO [3]{\\frac{\\partial^{#3}}{\\partial {#2}^{#3}} #1}\n\\newcommand \\qderivativeHO [2] {D_{q}^{#2} #1}                               % 1 - function; 2 - order\n\\newcommand \\qpowerDerivativeHO [2] {\\mathcal{D}_{q}^{#2} #1}                % 1 - function; 2 - order\n\\newcommand \\finiteDifferenceHO [2] {\\Delta^{#2} #1}                         % 1 - function; 2 - order\n\\newcommand \\pTsDerivativeHO [3] {\\frac{\\partial^{#3}}{\\Delta {#2}^{#3}} #1} % 1 - function; 2 - variable;\n\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{examp}[thm]{Example}\n\n\\numberwithin{equation}{section}\n\n\\title[Diffie-Hellman Key Exchange via REST]\n{Diffie-Hellman Key Exchange via REST}\n\\author[Petro Kolosov]{Petro Kolosov}\n\\email{kolosovp94@gmail.com}\n\\keywords{\n    Diffie-Hellman Key Exchange, DH key exchange, REST\n}\n\\urladdr{https://razumovsky.me}\n\\subjclass[2010]{26E70, 05A30}\n\\date{\\today}\n\\hypersetup{\n    pdftitle={Diffie-Hellman Key Exchange via REST},\n    pdfsubject={\n        Diffie-Hellman Key Exchange, DH key exchange, REST\n    },\n    pdfauthor={Petro Kolosov},\n    pdfkeywords={\n        Diffie-Hellman Key Exchange, DH key exchange, REST\n    }\n}\n\\begin{document}\n    \\begin{abstract}\n        Discussion on Diffie-Hellman Key Exchange and its implementation via REST.\n    \\end{abstract}\n\n    \\maketitle\n\n    \\tableofcontents\n\n\n    \\section{Introduction} \\label{sec:introduction}\n    Diffie--Hellman (DH) protocol is a method of asymmetric exchange\n    of the cryptographic keys for a group of two or more participants,\n    developed in 1976 by cryptographers Ralph Merkle, Whitfield Diffie and Martin Hellman.\n    In contrast to the symmetric key exchange,\n    the Diffie\\textendash Hellman protocol eliminates the direct transfer of the shared secret\n    between the participants so that each participant computes a shared secret with his own private-public key pair.\n    The Diffie\\textendash Hellman protocol is based on a one-way function of the form\n\n    \\begin{equation}\n        A = G ^ a \\bmod P \\label{eq:equation}\n    \\end{equation}\n\n    where $A$ is the user's public key,\n    $a$ is the user's private key,\n    $P=2Q+1$ is modulus, such that 2048 bits safe-prime because $Q$ is also prime,\n    $G$ is generator such that $G$ is primitive root modulo $P$.\n    We say that $G$ is primitive root modulo $P$ if for each $1 \\leq a \\leq P - 1$ the $A = G ^ a \\bmod P$\n    is unique and belong to the set $\\{1, 2, \\dots, P-1\\}$.\n    The period of such cyclic group $\\mathbb{Z}_{P}$ is $P-1$ then.\n\n    Thus, the safety of the Diffie--Hellman protocol is based on the discrete logarithm problem which is unsolvable\n    in polynomial time if the constants $G$ and $P$ are chosen correctly.\n    Graphically the flow of the Diffie--Hellman protocol can be expressed through the\n    analogy with mixing paints as the picture below shows\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=1\\textwidth]{Pictures/Diffie_Hellman_keyexchange_concept_diagram}\n        ~\\caption{Diffie\\textendash Hellman key exchange concept diagram.}\\label{fig:figure4}\n    \\end{figure}\n    In contrast to the Diffie\\textendash Hellman based on discrete logarithm problem, there is an Elliptic Curve Diffie\\textendash Hellman\n    key exchange, which based on the elliptic curve discrete logarithm problem.\n    Although, the idea is quite same, the difference only in that Elliptic Curve Diffie\\textendash Hellman ensures the same safety\n    as discrete logarithm Diffie\\textendash Hellman with lower value of the prime modulus $P$.\n    For instance, 521 bit modulus used in Elliptic Curve Diffie\\textendash Hellman is equally safe as 2048 bit modulus in\n    discrete logarithm Diffie\\textendash Hellman.\n    To summarize, the flow of Diffie\\textendash Hellman key exchange is as follows.\n    Given 2048 bits public prime modulus $P$ and generator $G$ such that $G$ is primitive root modulo $P$ then\n    \\begin{enumerate}\n        \\item Alice chooses her secret $a$.\n        \\item Alice sends to Bob her public key $A = G^a \\bmod P$.\n        \\item Bob chooses his secret $b$.\n        \\item Bob sends to Alice his public key $B = G^b \\bmod P$.\n        \\item Alice computes common secret $s = B^a \\bmod P$.\n        \\item Bob computes common secret $s = A^b \\bmod P$.\n        \\item Alice and Bob have arrived to the same value\n        \\begin{eqnarray}\n            s = A^b \\bmod P = G^{ab} \\bmod P \\\\\n            s = B^a \\bmod P = G^{ba} \\bmod P\n        \\end{eqnarray}\n    \\end{enumerate}\n\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=1\\textwidth]{Pictures/DH_Key_Exchange}\n        ~\\caption{Diffie\\textendash Hellman key exchange concept diagram.}\\label{fig:figure}\n    \\end{figure}\n\n\n    \\section{Diffie\\textendash Hellman key exchange implementation via REST}\n    \\label{sec:diffie–-hellman-key-exchange-implementation-via-rest}\n    Although, the idea of Diffie\\textendash Hellman key exchange looks quite simple,\n    some remarks on the concrete implementation should be added.\n    Firstly, it is necessary to implement the mechanism of key exchange request between two or more parties.\n    As it discussed above, each user has his own private-public keys pair, so in order to perform request between parties,\n    it should be implemented dedicate REST~\\cite{ong2015materials} web--service endpoint,\n    for instance the \\texttt{POST: api/key-exchange-requests} which takes the request body of the form\n\n    \\input{Files/post-keyexchange-body}\n\n    So, request sender generates on the client side a key pair, keeps private on in the file system and shares the public\n    in request to receiver.\n    Therefore, the second party has received the key exchange request.\n    In order to display all the key exchange requests awaiting the confirmation of decline decisions, it is worth to implement\n    another REST endpoint such that \\texttt{GET: api/key-exchange-requests}, so that requested party will have the list of\n    requests to proceed.\n    This endpoint may return the data structure like follows\n\n    \\input{Files/get-keyexchangerequests-response}\n\n    Finally, requested party should be able to confirm or decline the key exchange request, the\n    \\texttt{DELETE: api/key-exchange-requests} endpoint should be implemented then.\n    The server is able to fetch the request thanks to the body endpoint takes\n\n    \\input{Files/delete-keyexchangerequest-body}\n\n    Therefore, an identifier of awaiting request is passed to the server among with boolean value\n    indicating the confirmation.\n    Under the roof of this operation are also generation of private-public keys pair for the requested party and\n    generation of common secret stored in client's file system.\n    As result, the initial request sender receives a public key as confirmation from requested party.\n    Requested side may get all his public keys via the REST web--service using the resource \\texttt{GET: api/public-keys}\n\n    \\input{Files/get-publickeys-response}\n\n    Now requested participant is able to derive the common secret.\n    In order to provide an example, a simple command line interface is implemented.\n    We have used an Elliptic Curve Diffie\\textendash Hellman implementation \\texttt{ECDiffieHellmanCng Class} from the namespace\n    \\texttt{System.Security.Cryptography} of the .NET base class library.\n    The \\texttt{P-256} curve is used.\n\n    More precisely, the following CLI commands are implemented\n    \\begin{itemize}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole login SENDER\\_EMAIL SENDER\\_PASSWORD}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole key-exchange RECEIVER\\_ID}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole key-exchange-requests}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole confirm-key-exchange REQUEST\\_ID}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole print-public-keys}\n        \\item \\texttt{MangoAPI.DiffieHellmanConsole create-common-secret RECEIVER\\_ID}\n    \\end{itemize}\n    Commands are self-explanatory, therefore we skip the detailed documentation on them.\n    An example of console output straightforward\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=1\\textwidth]{Pictures/Diffie_Hellman_console_output}\n        ~\\caption{Diffie–-Hellman key exchange console output.}\\label{fig:figure7}\n    \\end{figure}\n    In order to repeat the outputs on the screenshot the user may reference to the resources\n    \\begin{itemize}\n        \\item API: \\href{https://back.mangomessenger.company/swagger}{\\texttt{https://back.mangomessenger.company/swagger}}\n        \\item Source: \\href{https://github.com/MangoInstantMessenger/MangoMessengerAPI}{\\texttt{https://github.com/MangoInstantMessenger/MangoMessengerAPI}}\n    \\end{itemize}\n    Finally, both test accounts reached the same base 64 common secret.\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=1\\textwidth]{Pictures/Same_common_secret}\n        ~\\caption{Common secrets.}\\label{fig:figure2}\n    \\end{figure}\n\n    \\bibliographystyle{alpha}\n    \\bibliography{DiffieHellmanKeyExchangeReferences}\n\n\\end{document}\n", "meta": {"hexsha": "1b6a7458021c5c2ac3cc084e5f24c0b784e28f01", "size": 10821, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/DiffieHellmanKeyExchange.tex", "max_stars_repo_name": "kolosovpetro/DiffieHellmanKeyExchange", "max_stars_repo_head_hexsha": "ec4bb90c8b74349789fe553a58dd6be44ff16679", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/DiffieHellmanKeyExchange.tex", "max_issues_repo_name": "kolosovpetro/DiffieHellmanKeyExchange", "max_issues_repo_head_hexsha": "ec4bb90c8b74349789fe553a58dd6be44ff16679", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/DiffieHellmanKeyExchange.tex", "max_forks_repo_name": "kolosovpetro/DiffieHellmanKeyExchange", "max_forks_repo_head_hexsha": "ec4bb90c8b74349789fe553a58dd6be44ff16679", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.8028169014, "max_line_length": 156, "alphanum_fraction": 0.7058497366, "num_tokens": 2976, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.41732786709209213}}
{"text": "\\documentclass[english]{../thermomemo/thermomemo}\n\\usepackage[utf8]{inputenc}\n\n\\title{Volume shift for generic EOS}\n\\author{Morten Hammer}\n\n\\usepackage[normalem]{ulem}\n\n\\usepackage{hyperref}\n\\usepackage{color}\n\n\\definecolor{midnightblue}{RGB}{35,35,132}\n\\definecolor{urlblue}{RGB}{70,130,180}\n\n\\definecolor{shadecolor}{gray}{0.9}\n\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=midnightblue,\n    urlcolor=urlblue,\n    citecolor=midnightblue,\n    linktoc=page\n}\n\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{framed}\n\\usepackage{siunitx,mhchem,todonotes}\n\\newcommand{\\pone}[3]{\\frac{\\partial #1}{\\partial #2}\\bigg|_{#3}}% partial\n                                % derivative with information of\n                                % constant variables\n\\newcommand*{\\vektor}[1]{\\boldsymbol{#1}}%\n\\newcommand{\\dd}[1]{\\mathrm{d}{#1}}\n\n\\DeclareMathOperator*{\\argmin}{arg\\,min }\n\n\n\n\\usepackage[activate={true,nocompatibility},final,kerning=true,tracking=true,spacing=true,stretch=10,shrink=10]{microtype}\n\\microtypecontext{spacing=nonfrench}\n\\SetExtraKerning[unit=space]\n    {encoding={*}, family={bch}, series={*}, size={footnotesize,small,normalsize}}\n    {\\textendash={400,400}, % en-dash, add more space around it\n     \"28={ ,150}, % left bracket, add space from right\n     \"29={150, }, % right bracket, add space from left\n     \\textquotedblleft={ ,150}, % left quotation mark, space from right\n     \\textquotedblright={150, }} % right quotation mark, space from left\n\\SetTracking{encoding={*}, shape=sc}{0}\n\n\\begin{document}\n\\frontmatter\n\n%\\tableofcontents\n\n\\section{Introduction}\nThe volume shift was introduced by P{\\'e}neloux et al. \\cite{Peneloux1982},\n\\begin{equation}\n  c = \\frac{1}{n}\\underset{i}{\\sum}c_i n_i,\n\\label{eq:volumeshift}\n\\end{equation}\nwhere $c_i$ is a component constant representing the component volume\nshift.\n\nDifferent properties change when working with volume translations, see\nJaubert et al. \\cite{Jaubert2016} for details.\n\nThe volume-shift have found application in many cubic based equations\nof state (t-mPR\\cite{Kordas1995}, PSRK\\cite{Fischer1996},\nVTPR\\cite{Collinet2006}, tc-PR/tc-RK\\cite{LeGuennec2016}, \\dots), and\nthe component volume translations $c_i$, are often fixated to match the\nliquid density at $T=0.7T_{\\text{Crit}}$,\n\\section{Volume shifts for generic EOS}\n\nThe residual reduced Helmholtz function of a  generic EOS is found as follows,\n\\begin{align}\n  F(T,V_{\\text{eos}},\\vektor{n}) = \\frac{A^\\text{r}(T,V_{\\text{eos}},\\vektor{n})}{RT}\n  = \\int^\\infty_{V_{\\text{eos}}} \\left[ \\frac{P(T,V_{\\text{eos}}^\\prime,\\vektor{n})}{RT} - \\frac{n}{V_{\\text{eos}}^\\prime} \\right]\\dd{V_{\\text{eos}}^\\prime}\n  \\label{eq:helmholtz_int_eos}\n\\end{align}\nIntroducing the volume shift,\n\\begin{equation}\nV = V_{\\text{eos}}- \\sum n_ic_i = V_{\\text{eos}}- C,\n\\label{eq:v_shift}\n\\end{equation}\nThe residual reduced helmholtz of the volume-shifted (vs) EOS can be\nfound, using $dV = dV_{\\text{eos}}$ at constant $n$ and $T$,\n\\begin{align}\n  F^{\\text{vs}}(T,V,\\vektor{n})\n  &= \\int^\\infty_V \\left[ \\frac{P(T,V^\\prime+C,\\vektor{n})}{RT} - \\frac{n}{V^\\prime} \\right]\\dd{V^\\prime} \\\\ &= \\int^\\infty_V \\left[ \\frac{P(T,V^\\prime+C,\\vektor{n})}{RT} - \\frac{n}{V^\\prime + C} \\right]\\dd{V^\\prime} + n\\int^\\infty_V \\left[\\frac{1}{V^\\prime + C}  - \\frac{1}{V^\\prime} \\right]\\dd{V^\\prime}\\\\ &= \\int^\\infty_{V_{\\text{eos}}} \\left[ \\frac{P(T,V_{\\text{eos}}^\\prime,\\vektor{n})}{RT} - \\frac{n}{V_{\\text{eos}}^\\prime} \\right]\\dd{V_{\\text{eos}}^\\prime} + n\\int^\\infty_V \\left[\\frac{1}{V^\\prime + C}  - \\frac{1}{V^\\prime} \\right]\\dd{V^\\prime}\\\\ &= F(T,V_{\\text{eos}},\\vektor{n})  + n \\ln \\left(\\frac{V}{V_{\\text{eos}}} \\right)\n  \\label{eq:helmholtz_int}\n\\end{align}\nHere we need to treat $V_{\\text{eos}} = V_{\\text{eos}}(V,\\vektor{n})$ with the\nchain rule when differentiating $F^{\\text{vs}}$.\n\nIf we introduce $F^C$ as the corrected residual reduced Helmholtz energy, due to\nthe difference in ideal volume,\n\\begin{align}\n  F^C(V,\\vektor{n}) &= n \\ln \\left(\\frac{V}{V+C} \\right),\n  \\label{eq:F_corr}\n\\end{align}\nthe differentials can be derived in a organized manner.\n\\begin{align}\n  F^C_{V} &= n \\left(\\frac{1}{V} - \\frac{1}{V+C} \\right) = n \\left(\\frac{1}{V} - \\frac{1}{V_{\\text{eos}}} \\right), \\\\\n  F^C_{VV} &= n \\left(-\\frac{1}{V^2} + \\frac{1}{\\left(V+C\\right)^2} \\right) = n \\left(-\\frac{1}{V^2} + \\frac{1}{V_{\\text{eos}}^2} \\right), \\\\\n  F^C_{i} &= \\ln \\left(\\frac{V}{V+C} \\right) - \\frac{nc_i}{V+C} = \\ln \\left(\\frac{V}{V_{\\text{eos}}} \\right) - \\frac{nc_i}{V_{\\text{eos}}}, \\\\\n  F^C_{ij} &= -\\frac{\\left(c_j + c_i \\right)}{V+C} +  \\frac{n c_ic_j}{\\left(V+C\\right)^2} = -\\frac{\\left(c_j + c_i \\right)}{V_{\\text{eos}}} +  \\frac{n c_ic_j}{V_{\\text{eos}}^2}, \\\\\n  F^C_{Vi} &= \\frac{1}{V} - \\frac{1}{V+C} + \\frac{nc_i}{\\left(V+C\\right)^2} =  \\frac{1}{V} - \\frac{1}{V_{\\text{eos}}} + \\frac{nc_i}{V_{\\text{eos}}^2}\n\\end{align}\nIn addition the compositional differentials change for since $V_{\\text{eos}} = V + C$,\n\\begin{align}\n  F^{\\text{eos}}_{i} &= F^{\\text{eos}}_{i} + F^{\\text{eos}}_{V_{\\text{eos}}} c_i , \\\\\n  F^{\\text{eos}}_{Ti} &= F^{\\text{eos}}_{Ti} + F^{\\text{eos}}_{TV_{\\text{eos}}} c_i , \\\\\n  F^{\\text{eos}}_{ij} &= F^{\\text{eos}}_{ij} + F^{\\text{eos}}_{iV_{\\text{eos}}} c_j + F^{\\text{eos}}_{V_{\\text{eos}}j} c_i + F^{\\text{eos}}_{V_{\\text{eos}}V_{\\text{eos}}} c_ic_j .\n\\end{align}\n\n\\subsection{Test of the fugacity coefficient}\nLet us test this for the fugacity coefficient. It is defined as\n\\begin{align}\n  \\ln \\hat{\\varphi}_i^{\\text{vs}} = \\biggl( \\frac{\\partial F^{\\text{vs}}}{\\partial n_i} \\biggr)_{T,V,n_j} - \\ln \\left( Z \\right) = F_{n_i}^{\\text{vs}} - \\ln \\left( Z \\right)\n  \\label{eq:fugacity}\n\\end{align}\nDifferentiating $F^{\\text{vs}}$,\n\\begin{align}\n  F_{n_i}^{\\text{vs}} &= F_{n_i} + F_{V_{\\text{eos}}}c_i  + \\ln \\left(\\frac{V}{V_{\\text{eos}}} \\right) - \\frac{n c_i}{V_{\\text{eos}}} = F_{n_i} + \\ln \\left(\\frac{V}{V_{\\text{eos}}} \\right) - \\frac{P c_i}{RT}\n  \\label{eq:Fni}\n\\end{align}\nCombining Equation \\ref{eq:fugacity} and \\ref{eq:Fni}, we get\n\\begin{align}\n  \\ln \\hat{\\varphi}_i^{\\text{vs}} &= F_{n_i} + \\ln \\left(\\frac{V}{V_{\\text{eos}}} \\right) - \\frac{P c_i}{RT} - \\ln \\left( \\frac{PV}{n RT} \\right) \\\\\n                      &= F_{n_i} - \\ln \\left( \\frac{PV_{\\text{eos}}}{n RT} \\right) - \\frac{P c_i}{RT} \\\\\n  &= \\ln \\hat{\\varphi}_i - \\frac{P c_i}{RT}\n  \\label{eq:fugacity2}\n\\end{align}\nwhich is the same result as reported by P{\\'e}neloux et al.\n\n\n\\section{Correlations used for $c_i$}\nThe $c_i$ for the SRK EOS is calculated from the following equation:\n\\begin{equation}\n  c_i = 0.40768\\frac{R T_{c_i}}{P_{c_i}}\\left(0.29441- Z_{\\text{RA}}\\right)\n\\label{eq:ci}\n\\end{equation}\n\n$Z_{\\text{RA}}$ are tabulated in TPlib. Reid et al. \\cite{Reid1987}\nalso correlate $Z_{\\text{RA}}$ as follows:\n\\begin{equation}\n  Z_{\\text{RA}} = 0.29056 - 0.08775 \\omega\n\\label{eq:zra}\n\\end{equation}\n\nJhaveri and Youngren \\cite{Jhaveri1988} have developed different paramaters for the PR EOS:\n\\begin{equation}\n  c_i^{\\text{PR}} = 0.50033\\frac{R T_{c_i}}{P_{c_i}}\\left(0.25969- Z_{\\text{RA}}\\right)\n\\label{eq:ci_PR}\n\\end{equation}\n\\clearpage\n\\bibliographystyle{plain}\n\\bibliography{../thermopack}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "05b39e24aa6a63320270f4252894c979c6ecec36", "size": 7203, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/memo/peneloux/peneloux.tex", "max_stars_repo_name": "jabirali/thermopack", "max_stars_repo_head_hexsha": "edad37dacaae5a820faa41593267ce6d891a4e52", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/memo/peneloux/peneloux.tex", "max_issues_repo_name": "jabirali/thermopack", "max_issues_repo_head_hexsha": "edad37dacaae5a820faa41593267ce6d891a4e52", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/memo/peneloux/peneloux.tex", "max_forks_repo_name": "jabirali/thermopack", "max_forks_repo_head_hexsha": "edad37dacaae5a820faa41593267ce6d891a4e52", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3915662651, "max_line_length": 636, "alphanum_fraction": 0.6468138276, "num_tokens": 2752, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558604, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.4173132902779757}}
{"text": "\\documentclass[letterpaper,final,12pt,reqno]{amsart}\n\n\\usepackage[total={6.3in,9.2in},top=1.1in,left=1.1in]{geometry}\n\n\\usepackage{times,bm,bbm,empheq,fancyvrb,graphicx}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{longtable}\n\\usepackage{booktabs}\n\n\\usepackage{tikz}\n\\usetikzlibrary{decorations.pathreplacing}\n\n\\usepackage[kw]{pseudo}\n\\pseudoset{left-margin=15mm,topsep=5mm,idfont=\\texttt}\n\n% hyperref should be the last package we load\n\\usepackage[pdftex,\ncolorlinks=true,\nplainpages=false, % only if colorlinks=true\nlinkcolor=blue,   % ...\ncitecolor=Red,    % ...\nurlcolor=black    % ...\n]{hyperref}\n\n\\renewcommand{\\baselinestretch}{1.05}\n\n\\newtheoremstyle{claim}% name\n  {5pt}% space above\n  {5pt}% space below\n  {\\itshape}% body font\n  {}% indent amount\n  {\\itshape}% theorem head font\n  {.}% punctuation after theorem head\n  {.5em}% space after theorem head\n  {\\thmname{#1}\\thmnumber{ #2}\\thmnote{ (#3)}}% theorem head spec\n\\theoremstyle{claim}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\RR}{\\mathbb{R}}\n\n\\newcommand{\\grad}{\\nabla}\n\\newcommand{\\Div}{\\nabla\\cdot}\n\\newcommand{\\trace}{\\operatorname{tr}}\n\n\\newcommand{\\hbn}{\\hat{\\mathbf{n}}}\n\n\\newcommand{\\bb}{\\mathbf{b}}\n\\newcommand{\\be}{\\mathbf{e}}\n\\newcommand{\\bbf}{\\mathbf{f}}\n\\newcommand{\\bg}{\\mathbf{g}}\n\\newcommand{\\bn}{\\mathbf{n}}\n\\newcommand{\\br}{\\mathbf{r}}\n\\newcommand{\\bu}{\\mathbf{u}}\n\\newcommand{\\bv}{\\mathbf{v}}\n\\newcommand{\\bw}{\\mathbf{w}}\n\\newcommand{\\bx}{\\mathbf{x}}\n\n\\newcommand{\\bF}{\\mathbf{F}}\n\\newcommand{\\bV}{\\mathbf{V}}\n\\newcommand{\\bX}{\\mathbf{X}}\n\n\\newcommand{\\bxi}{\\bm{\\xi}}\n\n\\newcommand{\\bzero}{\\bm{0}}\n\n\\newcommand{\\rhoi}{\\rho_{\\text{i}}}\n\n\\newcommand{\\ip}[2]{\\left<#1,#2\\right>}\n\n\\newcommand{\\mR}{R^{\\bm{\\oplus}}}\n\\newcommand{\\iR}{R^{\\bullet}}\n\n\\newcommand{\\pp}{{\\text{p}}}\n\\newcommand{\\qq}{{\\text{q}}}\n\\newcommand{\\rr}{{\\text{r}}}\n\n% numbering\n\\setcounter{tocdepth}{3}\n\\makeatletter\n\\def\\l@subsection{\\@tocline{2}{0pt}{4pc}{5pc}{}}\n\\makeatother\n\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\\numberwithin{table}{section}\n\\numberwithin{theorem}{section}\n\n\n\\begin{document}\n\\title[Geometric multigrid for glacier modeling: New concepts and algorithms]{Geometric multigrid for glacier modeling: \\\\ New concepts and algorithms}\n\n\\author{Ed Bueler}\n\n\\begin{abstract} FIXME: principles in introduction: mass conservation complementarity, solver optimality.  3 examples in sections \\ref{sec:subspace}--\\ref{sec:sia} poisson equation by geometric multigrid from subspace decomp point of view, obstacle problem by multilevel constraint decomposition (MCD), steady and implicitly-evolving SIA geometry by MCD\n\\end{abstract}\n\n\\maketitle\n\n\\tableofcontents\n\n\\thispagestyle{empty}\n%\\bigskip\n\n\\section{Introduction} \\label{sec:intro}\n\nThe construction of effective numerical glacier and ice sheet models is challenging for two fundamental reasons.  First is the complexity of the equations and boundary conditions.  Indeed, the physics of glaciers is nonlinear, nontrivially-coupled, and subject to imperfectly-understood boundary processes, such as contact with ocean water.  The coupling is critical in the sense that mass, momentum, and energy conservation interact in ways which are relevant to glaciological modeling goals, such as when basal sliding, and thus ice velocity, is only determined though a simultaneous momentum and energy solution.  Second, the geometry of glaciers and ice sheets is complex, and in particular the fastest-flowing parts of ice sheets are often located at the geometrically-nontrivial lateral boundary where fjord-like bed geometry is also common.  Numerical models therefore need to perform expensive fine-mesh calculations, so as to accomodate the complicated, changing boundary geometry, while solving relatively-complicated multiphysics equations.\n\nOn the other hand, since the 1980s researchers in numerial methods have developed multigrid methods to solve partial differential equations like those which describe the ice fluid in glaciers.   For simpler problems like scalar elliptic equations and the linear Stokes system, especially on domains which have a simpler geometry, these methods are now in routine use \\cite{Briggsetal2000,Bueler2021,Trottenbergetal2001}.\n\nFIXME Accessible introductions to FE methods are in \\cite{Bueler2021,Elmanetal2014,Johnson2009}.  Closest to our view in section \\ref{sec:subspace} is \\cite[Chapter V]{Braess2007}\n\nFIXME cite for multigrid on classical obstacle \\cite{BrandtCryer1983,Bueler2021,GraeserKornhuber2009}\n\nA brief historical summary of the SIA problem may be helpful.  The model was first solved by a finite difference scheme in \\cite{Mahaffy1976}, and FE solutions are given in \\cite{Calvoetal2002,JouvetBueler2012} among other places.  In fact, large-scale numerical applications of this model are common, and for examples see the high-resolution Greenland ice sheet model in section 4.2 of \\cite{Bueler2016}, or the SIA applications as hybrid ice sheet model components \\cite[for example]{Winkelmannetal2011}.  The idea that the glacier geometry solves an obstacle problem was introduced by \\cite{Calvoetal2002} in the time-dependent, flat-bed case; see also recognition in \\cite{SchoofHewitt2013}.  Existence was extended to non-flat beds by \\cite{JouvetBueler2012}.  However, none of these references use multilevel methods.  Such methods were first applied by Jouvet and others \\cite{Jouvetetal2013}, with further results in \\cite{JouvetGraeser2013}, using a truncated non-smooth Newton multigrid method which tracks the inactive set \\cite{GraeserKornhuber2009}.\n\n\n\\section{Geometric multigrid for the Poisson problem} \\label{sec:subspace}\n\n\\subsection{Finite elements for a simple differential equation} \\label{subsec:poissonfe}  In this section we will consider how to solve a simple differential equation, namely a linear Poisson-like problem\n\\begin{equation}\n- \\big(\\alpha(x)\\,u'(x)\\big)' = f(x) \\quad \\text{on} \\quad 0 \\le x \\le 1, \\label{eq:poisson}\n\\end{equation}\nwith Dirichlet boundary conditions $u(0)=u(1)=0$, using a finite element discretization and a multigrid method.  The data $\\alpha(x)$ and $f(x)$ are assumed to be sufficiently well-behaved for the computations which follow, and we assume $\\alpha(x)$ is bounded and positive so the problem is elliptic \\cite{Evans2010}: $0 < c_1 \\le \\alpha(x) \\le c_2$.  Over the course of the next three sections, this simple problem will evolve into a realistic model for glacier geometry.\n\nOur numerical approximation of \\eqref{eq:poisson} uses a mesh of $m$ interior \\emph{nodes} (points) $x_p$ on $(0,1)$.  The $m+1$ intervals between the nodes are the \\emph{elements}.  The numerical solution $u^h(x)$ is a linear combination of the piecewise-linear \\emph{hat functions} $\\psi_p(x)$, shown in Figure \\ref{fig:finehats}, one for each interior node:\n\\begin{equation}\nu^h(x) = \\sum_{p=1}^m u_p \\psi_p(x). \\label{eq:trialsolution}\n\\end{equation}\nEach hat function $\\psi_p(x)$ is continuous on $[0,1]$, linear on each element, and satisfies $\\psi_p(x_q) = \\delta_{pq}$.  Note that the derivative of $u^h(x)$ is well-defined on the elements, thus almost everywhere, but not at the nodes.\n\nLet $\\mathcal{V}^h$ be the space of continuous and piecewise-linear functions.  The set $\\{\\psi_p(x)\\}_{p=1}^m$ is a \\emph{nodal basis} of $\\mathcal{V}^h$ because the coefficients equal the function values, i.e.~$u_p=u^h(x_p)$.  In a computer program these coefficients will be formed into a (column) vector $\\bu=\\{u_p\\}$ in $\\RR^m$.\n\n\\begin{figure}\n\\includegraphics[width=0.65\\textwidth]{genfigs/finehats.pdf}\n\\caption{Hat functions $\\psi_p(x)$ at interior points $x_p$ form a basis for a vector space $\\mathcal{V}^h$ of piecewise-linear functions.}\n\\label{fig:finehats}\n\\end{figure}\n\nAs usual for numerical solutions of differential equations, we are interested in the fine-mesh limit where $m$ is large.  However, what is the need for a high-resolution mesh in practice, i.e.~a large value of $m$ and small spacing between the nodes $x_p$?  For an ice sheet model, the need is obvious: a high-resolution mesh can capture realistically-bumpy bed topography and/or spatially-varying climatic mass-balance with large, local variations.  These inputs roughly correspond in problem \\eqref{eq:poisson} to variations in the coefficient function $\\alpha(x)$ and the source function $f(x)$, respectively.  That is, we want a high-resolution mesh to capture the fine scales in the model input data.  In addition, as address in sections \\ref{sec:obstacle} and \\ref{sec:sia}, a fine mesh will allow precise modeling of glacier extent and glacier margin location.\n\nOur application of multigrid ideas to glacier problems will use finite element (FE) concepts, and therefore we must rephrase \\eqref{eq:poisson} into \\emph{weak form} using integrals.  (The original equation will then be called the \\emph{strong form}.)  To do this we suppose that the solution $u(x)$ comes from a vector space $\\mathcal{H}$ of functions which have values of zero at $x=0$ and $x=1$, and which are smooth enough to make sense in what follows.  While we will not over-use mathematical language, in fact $\\mathcal{H}=H_0^1[0,1]=W_0^{1,2}[0,1]$ is a Hilbert and Sobolev space \\cite[for example]{Evans2010} consisting of functions with one square-integrable derivative.  Also, we assume $\\alpha(x)$ is in $L^\\infty[0,1]$ and $f(x)$ in $L^2[0,1]$.\n\nThe weak form arises by multiplying both sides of \\eqref{eq:poisson} by a \\emph{test function} from $\\mathcal{H}$ and integrating by parts so that only first derivatives remain.  Denoting the test function as $v(x)$, integrating on $[0,1]$, and using $v(0)=v(1)=0$, we find\n\\begin{equation}\n\\int_0^1 \\alpha(x) u'(x) v'(x)\\,dx = \\int_0^1 f(x) v(x)\\, dx.  \\label{eq:weakpoissonearly}\n\\end{equation}\nWe now write this equation more compactly as\n\\begin{equation}\n  a(u,v) = \\ip{f}{v}, \\label{eq:weakpoisson}\n\\end{equation}\ndefining each side as in \\eqref{eq:weakpoissonearly}; we seek $u$ in $\\mathcal{H}$ so that \\eqref{eq:weakpoisson} holds for all $v$ in $\\mathcal{H}$.  The left side $a(u,v)$ is linear in each argument (\\emph{bilinear}) while the right side defines a \\emph{linear functional} $\\ell[v] = \\ip{f}{v}$ acting on $v$ in $\\mathcal{H}$.  The convenience of such abstract notation will become clearer as we describe multilevel algorithms.\n\nOur FE method seeks a solution $u^h$ in $\\mathcal{V}^h$ of the same weak form \\eqref{eq:weakpoisson}.  The problem is now finite-dimensional:\n\\begin{equation}\n  a(u^h,v) = \\ip{f}{v},  \\label{eq:feweakpoisson}\n\\end{equation}\nfor all test functions $v$ in $\\mathcal{V}^h$.  Because $\\mathcal{V}^h$ is a subset of $\\mathcal{H}$, we can compare $u^h$ and $u$.  In fact, by subtracting \\eqref{eq:feweakpoisson} from \\eqref{eq:weakpoisson} we see that the \\emph{numerical error} $u-u^h$ satisfies $a(u-u^h,v)=0$ for all $v$ in $\\mathcal{V}^h$.  That is, the numerical error is orthogonal, in the sense of $a(\\cdot,\\cdot)$, to the finite-dimensional subspace $\\mathcal{V}^h$.  Standard FE arguments then show that the error goes to zero as $h$ goes to zero \\cite{Braess2007,Elmanetal2014}.\n\nOne may substitute formula \\eqref{eq:trialsolution} for $u^h$ into \\eqref{eq:feweakpoisson} to derive a linear system\n\\begin{equation}\nA \\bu = \\bbf, \\label{eq:linearsystem}\n\\end{equation}\nwhere $A$ is an $m\\times m$ matrix and $\\bbf$ is in $\\RR^m$.  Each equation (row) in system \\eqref{eq:linearsystem} is constructed by using a hat function as a test function; substitution of $v=\\psi_p$ gives the $p$th equation.  The matrix $A$, which has entries $a_{pq} = a(\\psi_p,\\psi_q)$, is symmetric and positive definite.  For the right side one defines entries $f_p = \\ip{f}{\\psi_p}$ to form the vector $\\bbf = \\{f_p\\}$.  For the 1D problem here, only three values $a_{p,p-1}, a_{p,p}, a_{p,p+1}$ are nonzero in row $p$, so $A$ is tridiagonal.  Writing these entries in detail may remind the reader of finite difference approximations of the Laplacian.\n\nDepending on the form of $\\alpha(x)$, the matrix entries\n\\begin{equation}\n  a_{pq} = \\int_0^1 \\alpha(x) \\psi_p'(x) \\psi_q'(x)\\,dx \\label{eq:poissonentries}\n\\end{equation}\nmay be computed exactly or approximately by quadrature.  Similar considerations apply to the values $f_p = \\int_0^1 f(x) \\psi_p(x)\\,dx$.  The errors arising from quadrature have only a slight effect on the accuracy of the whole FE method \\cite{Braess2007}.\n\nThe most straightforward way to solve assembled linear system \\eqref{eq:linearsystem} would be via a ``direct'' method like Gaussian elimination.  In 2D and 3D problems, where the number of unknowns $m$ is large, such direct methods need many more that $O(m)$ operations to solve the system, while, as noted in the introduction, high-resolution ice sheet applications demand optimal $O(m)$ solution methods, or nearly so.  Furthermore, excluding the current section, all of our problems will be nonlinear, thus no finite-time direct method will be available anyway.  Thus we will not assemble matrices, but instead construct rapidly-convergent iterations using easy-to-implement pointwise iterations and multiple mesh levels.\n\nOur solution methods will be phrased in terms of ``residuals'', which need to be clearly defined.  Suppose $w$ in $\\mathcal{V}^h$ is any estimate of the solution $u^h$ of \\eqref{eq:feweakpoisson}.  We define the \\emph{residual} of $w$ as a linear functional acting on $v$ in $\\mathcal{V}^h$:\n\\begin{equation}\n  F(w)[v] = a(w,v) - \\ip{f}{v}.  \\label{eq:residual}\n\\end{equation}\nFinding $u^h$ is equivalent to making all components of its residual, that is\n\\begin{equation}\n  F(u^h)[v]=0 \\qquad \\text{ if and only if } \\qquad a(u^h,v)=\\ip{f}{v} \\label{eq:residualweakequivalence}\n\\end{equation}\nfor all $v$ in $\\mathcal{V}^h$.\n\nGiven an iterate $w$ which does not already solve \\eqref{eq:feweakpoisson}, we will update it using simple operations which make the residual components $F(w)[v]$ smaller.  To do this we will represent $w$ using the basis of hat functions, i.e.~$w = \\sum w_q \\psi_q$ with $w_q = w(x_q)$, and then compute a component in this basis using the linearity of $a(\\cdot,\\cdot)$:\n\\begin{equation}\n  F(w)[\\psi_p] = \\sum_{q=1}^{m} a(\\psi_q,\\psi_p) \\,w(x_q) - \\ip{f}{\\psi_p}.  \\label{eq:residualpoisson}\n\\end{equation}\nThe number of nonzero terms in sum \\eqref{eq:residualpoisson} is equal to the number of hat functions $\\psi_q$ whose support overlaps the support of $\\psi_p$.  This number is at most three in the current 1D case, and for general 2D and 3D meshes the number remains small (if the elements do not have small angles \\cite{Braess2007}).  Thus the computation of a component $F(w)[\\psi_p]$ requires $O(1)$ work, so computing all components of a residual linear functional $F(w)$ requires $O(m)$ work.  This observation about the cost of evaluating a residual is fundamental to all of our methods.\n\n\\subsection{Coarse mesh levels and subspace decompositions} \\label{subsec:coarselevels}  From the above simple FE scheme we now take the first steps to build a \\emph{multilevel} scheme.  Consider an enlarged set of hat functions:\n    $$\\underbrace{\\psi_1(x),\\dots,\\psi_m(x)}_{\\text{existing fine level}},\\underbrace{\\psi_{m+1}(x),\\dots,\\psi_M(x)}_{\\text{\\small coarser levels}}$$\nFor example, two coarser levels, derived from the fine level in Figure \\ref{fig:finehats} by coarsening, are shown in Figure \\ref{fig:coarsehats}.  The first coarsening (top) by-passes every other node on the fine mesh, and the next coarsening (bottom) does this again.\n\n\\begin{figure}\n\\includegraphics[width=0.55\\textwidth]{genfigs/coarsehats.pdf}\n\\smallskip\n\n\\includegraphics[width=0.55\\textwidth]{genfigs/coarsesthats.pdf}\n\\caption{Coarser levels amount to additional sets of hat functions which spread over a greater distance.}\n\\label{fig:coarsehats}\n\\end{figure}\n\nOn 2D and 3D meshes this manner of constructing coarse-mesh hats is less straightforward, and it is more common to start from a coarse mesh and refine level-by-level up to the finest.  In any case, our methods are not restricted to equally-spaced meshes, though models with high-resolution structured meshes \\cite[for example]{Bueler2016,Winkelmannetal2011} are among our target applications.\n\nWe need notation for the levels.  Suppose that the coarsest level is indexed as $j=0$ and the finest as $j=J$, and that the hat functions $\\psi_p^j(x)$, for $p=1,\\dots,m_j$, form the $j$th level.  The interior nodes $x_p^j$ use the same multilevel indexing scheme.  Figures \\ref{fig:finehats} and \\ref{fig:coarsehats} show a three-level scheme ($J=2$) with $m_2=7$ fine-level, $m_1=3$ middle-level, and $m_0=1$ coarsest-level hat functions.  The original mesh has $m_2+1=8$ elements, divisible by four, so three-level coarsening was allowed.  Note that the original fine level has now gained a superscript $J$; the original hats are $\\psi_p^J(x)$ and the original nodes are $x_p^J$.\n\nOn each level the hat functions are linearly-independent and form a basis for a vector space:\n\\begin{equation}\n  \\mathcal{V}^j = \\operatorname{span}\\{\\psi_1^j(x),\\dots,\\psi_{m_j}^j(x)\\} \\subset \\mathcal{H}.  \\label{eq:definevk}\n\\end{equation}\nThese spaces are nested, i.e.~$\\mathcal{V}^{j-1} \\subset \\mathcal{V}^j$, because each hat function can be written as a linear combination of finer-level hats,\n\\begin{equation}\n   \\psi_p^{j-1}(x) = \\sum_{q=1}^{m_j} c_{pq} \\psi_q^j(x). \\label{eq:hatcombination}\n\\end{equation}\nIn fact, the coefficients are\n\\begin{equation}\n  c_{pq} = \\psi_p^{j-1}(x_q^j) \\label{eq:nodalcoefficients}\n\\end{equation}\nbecause $\\{\\psi_q^j\\}$ form a nodal basis.  Nonzero coefficients $c_{pq}$ therefore occur only when a fine-level node $x_q^j$ is in the non-zero set (the open \\emph{support}) of a coarser hat $\\psi_p^{j-1}(x)$.  Statements \\eqref{eq:hatcombination} and \\eqref{eq:nodalcoefficients}, while simple, will be used throughout the paper when we need to pass between levels.\n\nA \\emph{multilevel subspace decomposition} is now described by the vector-space sum:\n\\begin{equation}\n  \\mathcal{V}^h = \\mathcal{V}^0 + \\mathcal{V}^1 + \\dots + \\mathcal{V}^J. \\label{eq:subspacedecomposition}\n\\end{equation}\nThis decomposition will be useful despite the facts that the subspaces are nested.  In fact, the final term $\\mathcal{V}^J$ is actually equal to the whole FE space $\\mathcal{V}^h$.  Equation \\eqref{eq:subspacedecomposition} asserts that a piecewise-linear function in $\\mathcal{V}^h$ \\emph{can} be written as a linear combination of hat functions from all the levels, but there is no unique representation.  A multilevel method will use this decomposition to find the components of the solution in $\\mathcal{V}^h$ via fast computations on all levels $\\mathcal{V}^j$.\n\nUsing our hat function bases, a subspace decomposition provides an approximate \\emph{scale of frequencies} in the following informal sense.  The value of the inner product of a function $g(x)$ with a fine-level hat, $\\ip{g}{\\psi_p^J}$, is, relative to the norm $\\|g\\| = \\ip{g}{g}^{1/2}$, mostly a measure of its high-frequency content at $x_p^J$.  The inner product with a coarser-mesh hat $\\psi_p^j$, by contrast, measures lower frequency content because it averages over many fine-mesh nodes.  If decomposition \\eqref{eq:subspacedecomposition} were instead a Fourier decomposition, with each $\\mathcal{V}^j$ spanned by waves of disjoint frequency ranges, then the sum would be orthogonal and the ``scale of frequencies'' meaning would be exact.  Our decompositions will always involve overlapping and nonorthogonal ranges of frequencies, but multilevel methods will reduce the energy of the high frequencies in the error on each level $\\mathcal{V}^j$.  Doing this on all levels will rapidly reduce the whole error.\n\n\\subsection{Gauss-Seidel, Jacobi, and explicit time-stepping as smoothers} \\label{subsec:smoothers}  Our first solution method for FE problem \\eqref{eq:feweakpoisson}, called \\emph{Gauss-Seidel} (GS) iteration, is sequential and point-wise \\emph{relaxation} of the residual \\eqref{eq:residual}.  Though matrices are often used to present this classical iteration algorithms \\cite[for example]{Bueler2021,Greenbaum1997}, we present it using only residuals and hat functions/  The same approach will be beneficial when we consider nonlinear glacier models.\n\nThe GS algorithm on the $j$th level sweeps through the mesh nodes $x_p^j$, modifying the iterate $w(x)$ by a multiple of $\\psi_p^j$ to make that residual value zero.  That is, at each node we compute $c$ so that\n\\begin{equation}\n  F(w+c\\,\\psi_p^j)[\\psi_p^j] = 0.  \\label{eq:gaussseidelpoint}\n\\end{equation}\nObserve that $a(\\cdot,\\cdot)$ is bilinear and thus that $F(w+c\\,\\psi_p^j)[\\psi_p^j] = F(w)[\\psi_p^j] + c\\, a(\\psi_p^j,\\psi_p^j)$.  Define $\\ell[v] = \\ip{f}{v}$, a linear functional.  In these terms, GS is the following algorithm which modifies $w$ in place:\n\\begin{pseudo*} \\label{ps:gs-sweep}\n\\pr{gs-sweep}(j,w,a,\\ell,\\id{omega}=1)\\text{:} \\\\+\n    $F(w)[\\cdot] := a(w,\\cdot) - \\ell[\\cdot]$ \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        $\\displaystyle c = - F(w)[\\psi_p^j]\\, \\big/ \\,a(\\psi_p^j,\\psi_p^j)$  \\\\\n        $w \\gets w + \\id{omega} \\,c \\,\\psi_p^j$\n\\end{pseudo*}\nSo that such methods will generalize, we regard the bilinear form $a$ and the linear functional $\\ell$ as inputs, and build the residual when needed.\n\nAssuming that value $a(\\psi_p^j,\\psi_q^j)$ and $\\ell[\\psi_p^j] = \\ip{f}{\\psi_p^j}$ are computed in $O(1)$ work, one application of \\pr{gs-sweep} requires $O(m_j)$ work.  Though \\pr{gs-sweep} only works as stated for a linear equation in the form of \\eqref{eq:feweakpoisson}, it can be modified to solve nonlinear systems by applying a few steps of Newton's iteration to each scalar equation $f(c) = F(w+c\\,\\psi_p^j)[\\psi_p^j] = 0$; see section \\ref{sec:sia}.\n\nWhat does a sweep of GS do to an iterate $w$?  By sequentially making the residual zero on each hat function we intend that the residual becomes smaller.  However, modifying $w$ to make the residual zero at one place means that previously-zeroed locations are no longer zero because the equations are non-trivially coupled.  Nonetheless one can prove for the Poisson problem that this iteration, applied soley on the fine level, converges to the solution $u^h$ of \\eqref{eq:feweakpoisson} \\cite[for example]{Greenbaum1997}, but that is not our focus.  Instead, a key observation is that such a sweep is a fast \\emph{smoother} of the (algebraic) error $e=w-u^h$, even when it is slow to make the whole error small.\n\nInformally, the formula for $c$ in \\textsc{gs-sweep} combines neighboring values of $w$ so as to flatten a peak or trough in the error.  An example is shown in Figure \\ref{fig:residualpoints}, where we start with a non-smooth initial iterate $w$ on an $m_J=6$ mesh; its residual $F(w)$ and error $e$ are at the top.  The Figure shows the residual and error after each step in the \\textbf{for} loop in \\pr{gs-sweep}, indicating the location which is zeroed.  (We plot the linear functionals $F(w)$ as piecewise-constant functions with values $F(w)[\\psi_p^J]$.)  While both the residual and error become smaller in norm, the strongest effect is the damping of high frequencies.\n\n\\begin{figure}[t]\n\\includegraphics[width=0.8\\textwidth]{genfigs/residualpoints.pdf}\n\\caption{One Gauss-Seidel (GS) sweep on the fine level adjusts the iterate $w$ so that the residual $F(w)[\\psi_p^J]$ at each successive node $x_p^J$ is zero (left).  The corresponding errors $e=w-u^h$ get significantly smoother (right).}\n\\label{fig:residualpoints}\n\\end{figure}\n\nOne may describe the smoothing property of GS quantitatively by considering the frequencies which are supported on a mesh having spacing $h$.  The highest-frequency faithfully-represented mode is the sawtooth with (spatial) frequency $\\sigma=(2h)^{-1}$.  For a 1D Poisson equation, with one GS sweep multiplies all modes with frequencies higher than $\\frac{1}{2} \\sigma$ by factors of at most $1/\\sqrt{5}\\approx 0.45$ (for sufficiently-fine meshes \\cite[Chapter 4]{Briggsetal2000}).  That is, a GS sweep \\emph{strongly damps the highest half} of the frequencies in the error.  Note that the particular damping factor depends on the dimension and the differential operator.\n\nOne may also adjust the \\emph{relaxation factor} \\id{omega} in \\pr{gs-sweep} away from its default value \\id{omega} $=1$, which yields \\emph{successive over-relaxation} for \\id{omega} $>1$.  This iteration has superior properties as a stand-alone solver \\cite{Greenbaum1997}, but it is no better than GS as a smoother.\n\nAlgorithm \\pr{gs-sweep} has no dependence on the dimension of the problem.  In particular, for any linear elliptic PDE which can be written in weak form \\eqref{eq:weakpoisson}, \\pr{gs-sweep} applies as stated with $m_j$ denoting the number of $j$th-level mesh nodes and $\\psi_p^j$ the corresponding hat functions.  However, the rate of convergence and the smoothing efficiency of GS iterations depend on the details of the PDE, including its dimension.\n\nNote that GS involves repeatedly re-evaluating the pointwise residual, i.e.~computing $F(w)[\\psi_p^j]$ after each update of $w$.  Where each evaluation of a point residual is expensive, for instance when a residual evaluation is non-local \\cite{BuelerMitchell2022}, an alternative is to evaluate the residual vector (i.e.~at all points) once at the start of the iteration.  The resulting \\emph{(weighted) Jacobi} method is parallel in the sense that pointwise updates can then be done in any order.\n\n\\begin{pseudo*} \\label{ps:jacobi-sweep}\n\\pr{jacobi-sweep}(j,w,a,\\ell,\\id{omega}=0.67)\\text{:} \\\\+\n    $F_p = a(w,\\psi_p^j) - \\ell[\\psi_p^j]$ \\qquad\\qquad\\qquad\\qquad \\ct{for all $p$} \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        $\\displaystyle c = - F_p \\, \\big/ \\, a(\\psi_p^j,\\psi_p^j)$  \\\\\n        $w \\gets w + \\id{omega} \\,c \\,\\psi_p^j$\n\\end{pseudo*}\n\nThe Jacobi iteration with relaxation factor \\id{omega} $=1$ is neither a rapid solution method nor an effective smoother---no damping is applied to the highest-frequency sawtooth---but underrelaxation can be a good smoother.  For a 1D Poisson equation and optimal factor \\id{omega} $=\\frac{2}{3}$, the method multiplies all frequencies higher than $\\frac{1}{2} \\sigma$ by at most $\\frac{1}{3}$ \\cite[Chapter 4]{Briggsetal2000}.  Other optimal factors are known for 2D and 3D Poisson equation, and to varying degrees this good smoother performance extends to other PDEs.\n\nThese smoother considerations seem to be separate from how evolving-geometry glacier models have been designed in the past.  Most ice sheet models proceed by explicit time-stepping of their complicated, coupled equations \\cite[for example]{Winkelmannetal2011}.  However, it turns out that such time-stepping is closely related to Jacobi smoothing.  Consider the time-dependent problem corresponding to the $\\alpha=1$ case of \\eqref{eq:poisson}, namely the \\emph{heat equation}\n\\begin{equation}\nu_t = u_{xx} + f, \\qquad u(t,0)=u(t,1)=0, \\label{eq:heat}\n\\end{equation}\nfor $u(t,x)$ and $t>0$, and subject to some initial condition $u(0,x)=g(x)$.  The corresponding FEM weak form follows (as usual) by multiplying by $v$ from $\\mathcal{V}^j$ \\cite[Chapter 8]{Johnson2009},\n\\begin{equation}\n\\frac{d}{dt}\\ip{u^h}{v} = -a(u^h,v) + \\ip{f}{v} = - F(u^h)[v], \\label{eq:feheat}\n\\end{equation}\nwith $F$ given by \\eqref{eq:residual} as before.  Expanding the FEM solution $u^h(t,x)$ in hat functions, we have\n\\begin{equation}\nu^h(t,x) = \\sum_{q=1}^{m_j} u^h(t,x_p^j) \\psi_p^j(x). \\label{eq:trialheat}\n\\end{equation}\nEquation \\eqref{eq:feheat} with $v=\\psi_p^j$ generates an ODE system for the coefficients:\n\\begin{equation}\n\\sum_{q=1}^{m_j} \\ip{\\psi_p^j}{\\psi_q^j} u^h(t,x_p^j) = - F(u^h)[\\psi_p^j] \\label{eq:odeheatearly}\n\\end{equation}\nIdentifying the \\emph{mass matrix} $B$ with entries $b_{pq} = \\ip{\\psi_p^j}{\\psi_q^j}$, which is an easily inverted matrix with $O(1)$ condition number \\cite{Elmanetal2014}, we can write the ODE system as\n\\begin{equation}\nu^h(t,x_p^j)' = - (B^{-1} F(u^h)[\\cdot])_p. \\label{eq:odeheat}\n\\end{equation}\n\nSuppose we discretize time using spacing $\\Delta t$ and then we approximate the consecutive states $u^h(t,x)$, $u^h(t+\\Delta t,x)$ by $w(x)$, $\\tilde w(x)$, respectively.  Then, using the forward Euler method, \\eqref{eq:odeheat} becomes\n\\begin{equation}\n\\frac{\\tilde w_p - w_p}{\\Delta t} = - (B^{-1} F(w)[\\cdot])_p. \\label{eq:forwardeulerheat}\n\\end{equation}\nLet us write this time-step as a pseudocode which takes the current values $w$ and computes the new values $\\tilde w$.  Up to the inversion of the mass matrix $B$, and choosing to compute the updated iterate in-place, this is the same method as \\pr{jacobi-sweep}:\n\\begin{pseudo*} \\label{ps:euler-timestep}\n\\pr{euler-timestep}(j,w,a,\\ell,\\id{deltat})\\text{:} \\\\+\n    $F_p = a(w,\\psi_p^j) - \\ell[\\psi_p^j]$ \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        $\\displaystyle c = - (B^{-1} F)_p$  \\\\\n        $w \\gets w + \\id{deltat}\\, c\\, \\psi_p^j$ \\\\-\n\\end{pseudo*}\nIn particular, the time step \\id{deltat} plays the role of \\id{omega} in \\pr{jacobi-sweep}.  However, the change $c$ to the value $w_p$ is not divided by the diagonal entries $a(\\psi_p^j,\\psi_p^j)$, as in the Jacobi iteration, so for \\emph{conditional stability} \\cite{Bueler2021} one must choose \\id{deltat} $=O(h^2)$.\n\nIn summary, the GS and Jacobi iterations act as smoothers when applied to the Poisson problem \\eqref{eq:poisson}.  Subject to severe stability restrictions on the time step, forward Euler time-stepping for the corresponding heat equation \\eqref{eq:heat} is also a smoother.  Applied on a single mesh level, these methods are all slow to converge.  Optimal solver performance therefore depends on applying such smoothers on different mesh levels.\n\n\\subsection{Multilevel subspace corrections} \\label{subsec:msc}  When a smoother is applied on a given level $j$, whether once or a few times, the error and residual of the iterate no longer contain much energy in high-frequency modes.  It makes sense to switch to smoothing on the $j-1$ level to remove energy in lower frequencies.  That is, we correct the residual on the next-coarser level.\n\nFor example, if we start on the finest level $J$ then we have the following \\emph{multilevel subspace corrections} \\cite{Xu1992} algorithm:\n\\begin{pseudo*} \\label{ps:msc-downslash}\n\\pr{msc-downslash}(w,a,\\ell)\\text{:} \\\\+\n    for $j=J$ downto $0$ \\\\+\n        \\pr{smoother}(j,w,a,\\ell)\n\\end{pseudo*}\nHere \\pr{smoother} stands for \\pr{gs-sweep}, \\pr{jacobi-sweep}, or even \\pr{euler-timestep}.  The reason this downward-only scheme is called ``slash'' is illustrated in Figure \\ref{fig:msccycles}.\n\nIn fact, one can remove lowest error frequencies first by initially computing corrections on the coarsest level:\n\\begin{pseudo*} \\label{ps:msc-upslash}\n\\pr{msc-upslash}(w,a,\\ell)\\text{:} \\\\+\n    for $j=0$ to $J$ \\\\+\n        \\pr{smoother}(j,w,a,\\ell)\n\\end{pseudo*}\nAlternatively, the two slashes can be combined into a ``V'' cycle:\n\\begin{pseudo*} \\label{ps:msc-vcycle}\n\\pr{msc-vcycle}(w,a,\\ell)\\text{:} \\\\+\n    for $j=J$ downto $0$ \\\\+\n        \\pr{smoother}(j,w,a,\\ell) \\\\-\n    for $j=1$ to $J$ \\\\+\n        \\pr{smoother}(j,w,a,\\ell)\n\\end{pseudo*}\nFurthermore one may repeat the smoother on each level, or go up-and-down the mesh hierarchy in a more complicated manner (``W-cycles'', for example); there are many possibilities \\cite{Briggsetal2000,Trottenbergetal2001}.\n\n\\begin{figure}\n\\input{tikz/msccycles.tex}\n\\caption{Subspace corrections may be applied in different orders: \\pr{msc-downslash} (left),  \\pr{msc-upslash} (middle), or \\pr{msc-vcycle} (right).  Each dot in this three-level hierarchy ($J=2$) is a smoother application.}\n\\label{fig:msccycles}\n\\end{figure}\n\nThese MSC cycles improve a fine-level iterate $w^J$ but they do not (generally) exactly solve problem \\eqref{eq:feweakpoisson}.  Instead one should apply them iteratively, testing for convergence using a tolerance on the norm of the fine-level residual.  (An alternative view of MSC algorithms would treat them as preconditioners \\cite{Bueler2021}, but we will not need this view.)  For example, one may require the residual to decrease from its initial value by a certain factor:\n\\begin{pseudo*} \\label{ps:msc-solver}\n\\pr{msc-solver}(w^J,a,\\ell,\\id{rtol}=10^{-4})\\text{:} \\\\+\n    $F_p = a(w^J,\\psi_p^J) - \\ell[\\psi_p^J]$ \\\\\n    $r_0 = \\|F\\|$ \\\\\n    repeat \\\\+\n        \\pr{msc-cycle}(w,a,\\ell) \\qquad\\qquad \\ct{\\pr{cycle}=\\pr{downslash}$|$\\pr{upslash}$|$\\pr{vcycle}} \\\\\n        $F_p = a(w^J,\\psi_p^J) - \\ell[\\psi_p^J]$ \\\\-\n    until $\\|F\\| \\le r_0\\, \\id{rtol}$ \\\\\n    return $w^J$\n\\end{pseudo*}\nNote that the user needs to provide an initial iterate $w^J$ on the fine level.\n\nSuch simply-stated MSC schemes appeared late in the history of multigrid \\cite{Xu1992}, but they contain the core multigrid ideas and consequent performance.  The following theorem applies to linear elliptic PDEs in any dimension, if defined by a symmetric and positive bilinear form.\n\n\\begin{theorem} \\label{thm:mscconvergence} \\cite{Neuss1998}\\,  Let $u^h$ be the exact solution of FE weak form \\eqref{eq:feweakpoisson}.  Suppose $w^{(s)}$ is computed by from $s$ applications of \\pr{msc-downslash}, \\pr{msc-upslash}, or \\pr{msc-vcycle} on the fine ($J$th) level, starting with any $w^{(0)}$.  There is $\\rho<1$, independent of $h$, so that\n\\begin{equation}\n  \\|w^{(s+1)} - u^h\\|_{\\mathcal{H}} \\le \\rho \\|w^{(s)} - u^h\\|_{\\mathcal{H}}.  \\label{eq:mscconvergence}\n\\end{equation}\n\\end{theorem}\n\nEach cycle therefore reduces the error by a mesh-independent factor $\\rho<1$, called the \\emph{multigrid convergence rate} \\cite{Braess2007}.  The proof extends an earlier Jacobi smoothing result \\cite{BraessHackbusch1983} to include GS smoothing; see also \\cite[Thm.~3.10]{GraeserKornhuber2009}.  The convergence rate $\\rho$ does not depend on the fine-mesh spacing $h$, nor on the number of fine-mesh degrees of freedom $m_J$, nor even the number of levels $J$.  It does depend on the element aspect ratios (\\emph{shape regularity} \\cite{Elmanetal2014}) in the mesh, though this is not relevant in 1D, and on the \\emph{ellipticity bound} $\\alpha_0=\\inf_x \\alpha(x)$ of the PDE.  It is common for a V-cycle to have a smaller $\\rho$ than a slash cycle, but the latter do less work per cycle, so in section \\ref{sec:obstacle}, when we present computational results, we will compare computational work and run time and not just cycles.\n\nIt follows from \\eqref{eq:mscconvergence} that if we want the error norm $e^{(s)} = \\|w^{(s)}-u^h\\|_{\\mathcal{H}}$ to be reduced to below some small level $\\eps>0$ then we should do $s>(\\log\\eps - \\log e^{(0)})/\\log \\rho$ iterations.  That is, we need $s=O(|\\log\\eps|)$ iterations.  (Note that $h$ and $J$ are related by logarithms; in our case $h=(m_J+1)^{-1}=2^{-(J+1)}$ so $J = O(\\log m_J) = O(|\\log h|)$.)  On the other hand, the error norms in \\eqref{eq:mscconvergence} are not generally computable.  An error norm is, however, bounded by the computable residual norm up to a (mesh-dependent) matrix condition number \\cite[Chapter 2]{Bueler2016}.\n\nThe pseudocode \\pr{msc-solver} does not, yet, define an efficiently-implementable solver.  Its performance depends on how iterates $w$ and residuals $F=F(w)$ are \\emph{represented on each mesh level}.  For example, if we represent $w$ and $F$ using the fine-level basis $\\{\\psi_p^J\\}$ then one application of \\pr{gs-sweep} is indeed fast, i.e.~$O(m_J)$ operations, with a small constant, because evaluating each $F(w)[\\psi_p^J]$ requires only a few operations.  However, evaluating $F(w)[\\psi_p^j]$ on coarse levels ($j<J$) means computing integrals over the wide support of $\\psi_p^j$, which is nonzero at many fine-mesh nodes $x_p^J$.  For example, \\pr{gs-sweep} on a coarser level $j<J$ is not an efficient operation if $w$ and $F$ are represented on the fine level; it is not an $O(m_j)$ operation with a coefficient which is independent of $j$.  This important concern is addressed via hierarchical representations, which are compatible with our multilevel corrections.\n\n\\subsection{Linear geometric multigrid} \\label{subsec:gmg}  Once the smoother has been applied on the fine level, so that the error and the residual no longer contain much energy in the high-frequency modes, the smoother should then be applied on the next-coarser level.  However, a fast algorithm must use appropriate coarse-level data structures to represent the problem on the new level.  When this idea is applied down the mesh-level hierarchy, we go beyond multilevel subspace corrections and create a true multigrid algorithm.\n\nEfficiency on coarser levels requires addressing two related concerns:\n\\renewcommand{\\labelenumi}{\\emph{\\roman{enumi})}}\n\\begin{enumerate}\n\\item How do we represent an iterate $w$ and a residual $F(w)$ on the $j$th level?\n\\item How does a $j$th-level problem descend to the representation on the $j-1$ level?\n\\end{enumerate}\n\nOur answer to \\emph{i)} is straightforward.  A function $w(x) = \\sum_p w_p \\psi_p^j(x)$ in $\\mathcal{V}^j$ is represented by its nodal values $w_p=w(x_p^j)$, thus $\\bw = \\{w_p\\}$ is a vector in $\\RR^{m_j}$.  Representing a residual $F(w)$, a linear functional in $(\\mathcal{V}^j)'$, is just as simple because the values $F_p = F(w)[\\psi_p^j]$ form a vector $\\bF=\\{F_p\\}$, also in $\\RR^{m_j}$.  It is common to think of $\\bw$ as a column vector and $\\bF$ as a row vector, but this is not essential.\n\nFor \\emph{ii)} we must derive a new equation for the coarser level, one which loses only minimal information when the key quantities are smooth.\\footnote{The equation, standard in multgrid literature, is only novel relative to our story so far.}  Note that for an iterate $w$ in the FE space $\\mathcal{V}^h$, the residual definition \\eqref{eq:residual} can be rewritten as\n\\begin{equation}\n  a(w,v) = \\ell[v] + F(w)[v],  \\label{eq:residualrewrite}\n\\end{equation}\nrecalling $\\ell[v] = \\ip{f}{v}$.  Subtracting the weak form \\eqref{eq:feweakpoisson} from \\eqref{eq:residualrewrite} cancels the source term:\n\\begin{equation}\n  a(w,v) - a(u^h,v) = F(w)[v].  \\label{eq:errorequationearly}\n\\end{equation}\nBecause of the linearity of $a(\\cdot,\\cdot)$ in the first position, we have the (weak-form) \\emph{error equation},\n\\begin{equation}\n  a(e,v) = F(w)[v],  \\label{eq:errorequation}\n\\end{equation}\nfor all $v$ in $\\mathcal{V}^h$, where $e=w-u^h$ is the algebraic error.\n\nRegarded as applying in $\\mathcal{V}^h$, error equation \\eqref{eq:errorequation} is equivalent to the original FE weak form \\eqref{eq:feweakpoisson}; it is not new.  (Just reverse the above derivation.)  However, if the smoother has already been applied to an iterate $w$ then both $e$ and the residual $F(w)$ are smoothed quantities.  That is, both sides of \\eqref{eq:errorequation} should have accurate representations in terms of the coarser hats $\\{\\psi_p^{J-1}\\}$, without using all of the fine-level hats $\\{\\psi_p^{J}\\}$.\n\nMultigrid therefore approximates \\eqref{eq:errorequation} with a \\emph{coarse-level equation} in which all quantities are represented using the coarser-level basis.  To state it we generalize to an arbitrary level $j>0$ and suppose $w^j$ is any iterate in $\\mathcal{V}^j$.  Then \\eqref{eq:errorequation} is approximated on the $j-1$ level as follows:\n\\begin{equation}\n  a(e^{j-1},v) = (R\\ell^j)[v] \\qquad \\text{where} \\qquad \\ell^j = F^j(w^j),  \\label{eq:coarsecorrection}\n\\end{equation}\nfor all $v$ in $\\mathcal{V}^{j-1}$.  Note $F^j(w^j)$ is the residual from the $j$th-level equation, and on the finest level $F^J(w^J)[v] = F(w^J)[v] = a(w^J,v) - \\ip{f}{v}$.  Again, we will represent $e^{j-1}$ in the basis $\\{\\psi_p^{j-1}\\}$, and $R\\ell^j$  in $(\\mathcal{V}^{j-1})'$ by its values $(R\\ell^j)[\\psi_p^{j-1}]$.\n\nIn \\eqref{eq:coarsecorrection} we have used the \\emph{canonical restriction operator} $R$ to transfer the residual.  By definition, $R$ maps a linear functional $\\ell$ in $(\\mathcal{V}^j)'$ to a linear functional in $(\\mathcal{V}^{j-1})'$:\n\\begin{equation}\n  (R \\ell)[v] = \\ell[v], \\label{eq:canonicalrestriction}\n\\end{equation}\nfor all $v$ in $\\mathcal{V}^{j-1}$.  That is, $R \\ell$ acts on $\\mathcal{V}^{j-1}$ in the same manner as $\\ell$, but we will \\emph{represent} $R\\ell$ by its $j-1$ level values.  From \\eqref{eq:hatcombination} and \\eqref{eq:nodalcoefficients},\n\\begin{equation}\n  (R \\ell)[\\psi_p^{j-1}] = \\sum_{q=1}^{m_j} c_{pq}\\, \\ell[\\psi_q^j], \\label{eq:canonicalrestrictionaction}\n\\end{equation}\nwith $c_{pq}=\\psi_p^{j-1}(x_q^j)$.  Note that this \\emph{full-weighting} formula \\cite{Briggsetal2000} requires some computation.\n\nOnce the solution $e^{j-1}$ of \\eqref{eq:coarsecorrection} is found, the update\n\\begin{equation}\n  w^j \\gets w^j + P e^{j-1}  \\label{eq:update}\n\\end{equation}\n``corrects'' the fine-level iterate.  This requires yet another map, the \\emph{canonical prolongation} $P$, which acts on a function $y$ in $\\mathcal{V}^{j-1}$ to give $Py$ in $\\mathcal{V}^j$:\n\\begin{equation}\n  (P y)(x) = y(x). \\label{eq:canonicalprolongation}\n\\end{equation}\nAgain \\eqref{eq:hatcombination} and \\eqref{eq:nodalcoefficients} are used to find the components of $Py$ in the fine-level basis; if $y=\\sum_p y_p \\psi_p^{j-1}$ then $Py = \\sum_q (Py)_q \\psi_q^j$ where\n\\begin{equation}\n  (Py)_q = \\sum_{p=1}^{m_{j-1}} c_{pq}\\, y_p, \\label{eq:canonicalprolongationaction}\n\\end{equation}\nand $c_{pq} = \\psi_p^{j-1}(x_q^j)$ as before.  While no information is lost because $\\mathcal{V}^{j-1} \\subset \\mathcal{V}^j$, and indeed the result $P y$ is the same piecewise-linear function as the input $y$, the representation has changed.\n\nCombining the above ideas with the earlier MSC cycles gives an efficiently-implementable \\emph{geometric multigrid} (GMG) method.  We show a V-cycle, but this includes the slash cycles just by setting parameters.  In addition to sweeps of the GS smoother, it solves the coarse-level correction equation \\eqref{eq:coarsecorrection}, applies update \\eqref{eq:update}, and follows by more smoother sweeps (Figure \\ref{fig:vcycle}).  The following pseudocode modifies the fine-level iterate $w$ in-place, and it can be called repeatedly so as to improve the iterate.\n\\begin{pseudo*} \\label{ps:gmg-vcycle}\n\\pr{gmg-vcycle}(w,a,\\ell,\\id{down}=1,\\id{up}=1)\\text{:} \\\\+\n    $w^J, \\ell^J = w, \\ell$ \\\\\n    for $j=J$ downto $1$ \\\\+\n        $\\text{\\pr{smoother}}^{\\text{\\id{down}}}(j,w^j,a,\\ell^j)$ \\\\\n        $F_p = a(w^j,\\psi_p^j) - \\ell^j[\\psi_p^j]$ \\\\\n        $\\ell^{j-1} = RF$ \\\\\n        $w^{j-1} = 0$ \\qquad\\qquad\\qquad\\qquad\\qquad \\ct{note $w^{j-1}=e^{j-1}$} \\\\-\n    \\pr{gmg-coarsesolve}(w^0,a,\\ell^0) \\\\\n    for $j=1$ to $J$ \\\\+\n        $w^j \\gets w^j + P w^{j-1}$ \\\\\n        $\\text{\\pr{smoother}}^{\\text{\\id{up}}}(j,w^j,a,\\ell^j)$ \\\\-\n    $w = w^J$\n\\end{pseudo*}\n\n\\begin{figure}\n\\input{tikz/vcycle.tex}\n\\caption{A four-level V-cycle with distinguished methods: down-smoother (solid dots), up-smoother (circles), and coarse-level solver (square).}\n\\label{fig:vcycle}\n\\end{figure}\n\nTo summarize this fundamental algorithm (Figure \\ref{fig:vcycle}), after ``down-smoother'' sweeps, here denoted $\\text{\\textsc{smoother}}^{\\text{\\texttt{down}}}$, the correction equation \\eqref{eq:coarsecorrection} is applied on the next-coarser level with a ``new'' source (linear functional) $\\ell^{j-1}$, and a zero initial iterate.  Observe that $\\ell^{j-1}$ is the amount by which the finer-level iterate $w^j$ did not already solve the problem; for example, if $w^J=u^h$ then $\\ell^{J-1}=0$.  After the correction additional ``up-smoother'' sweeps are done to remove high-frequency components from the updated iterate.  Note that memory is needed to hold the states $w^0,\\dots,w^J$ (i.e.~until after all coarse-level corrections).  It is also common to implement \\pr{gmg-vcycle} recursively.\n\nThe default settings give a V-cycle, denoted V(1,1).  If \\id{up} $=0$ we get a V(1,0) down-slash cycle and \\id{down} $=0$ gives a V(0,1) up-slash (Figure \\ref{fig:msccycles}).\n\nThe algorithm calls a solver subroutine on the coarsest $j=0$ level.  This may be a direct solver for a linear problem, but they are not available for our nonlinear glacier problems.  For simplicity and generalizability we suppose \\pr{gmg-coarsesolve} is also implemented as a fixed number of in-place smoother sweeps:\n\\begin{pseudo*} \\label{ps:gmg-coarsesolve}\n\\pr{gmg-coarsesolve}(w,a,\\ell,\\id{coarse}=1)\\text{:} \\\\+\n    $\\text{\\pr{smoother}}^{\\text{\\id{coarse}}}(0,w,a,\\ell)$ \\\\\n\\end{pseudo*}\nIf the coarsest mesh has a single node ($m_0=1$) then, for a linear problem, a single sweep exactly solves the $j=0$ problem.  In general, an accurate solution is fast if $m_0$ is small, but the choice of a coarse-level mesh and solver is nontrivial for realistic problems \\cite{BuelerMitchell2022}.\n\nBefore proceeding, the reader might ask what makes the above V-cycles ``geometric''?  Though the label is partly historical, note that our restriction and prolongation operators arise from the dimensions of the FE mesh via coefficients which use the hat functions ($c_{pq} = \\psi_p^{j-1}(x_q^j)$).  Also, we \\emph{rediscretize} on coarser levels, that is, we use the original bilinear form $a(\\cdot,\\cdot)$ on all levels.  An alternative to rediscretization is the \\emph{Galerkin} approach which forms coarser-level matrices recursively by $A^{j-1} = R A^j P$, starting from $A^J$ which is the fine-level system matrix; see \\cite[Chapter V]{Braess2007} and \\cite[Chapter 6]{Bueler2021}.  Going further away from our approach, in a \\emph{algebraic multigrid} (AMG) method \\cite[Appendix A]{Trottenbergetal2001} the prolongation $P$ is constructed using operations on the entries of $A^J$, and such algorithms invariably define $R=P^\\top$.  On linear elliptic problems the geometric and algebraic approaches are closely-related, in part because AMG has been ``tuned'' to generate prolongations $P$ with similar coefficients, but for our upcoming nonlinear and inequality-constrained problems the geometric approach generalizes directly.  By contrast, AMG can only solve the linear steps in a separately-constructed iteration, e.g.~by requiring an outer Newton iteration.  GMG and AMG approaches are natural competitors for the highest-performance solutions, but we will persevere here with the geometric approach.\n\n\\subsection{On transfer operators} \\label{subsec:transfers}  The operators $R$ and $P$ make no choices, which is the meaning of ``canonical''.  However, their application requires computation because of how we represent functions and functionals on each level.  In fact, full-weighting formulae \\eqref{eq:canonicalrestrictionaction} and \\eqref{eq:canonicalprolongationaction}, which generalize verbatim to unstructured 2D and 3D meshes when the indices $p,q$ denote the nodes of the mesh \\cite[Chapter V]{Braess2007}, arise from the simple fact \\eqref{eq:hatcombination}, that each coarse-level hat function is a linear combination of fine-level hats.\n\nAs linear operators, $R$ and $P$ may be represented as sparse, rectangular matrices, and they are transposes ($P=R^\\top$), but using memory to store them this way is unnecessary.  They are applied in $O(m_j)$ operations via \\eqref{eq:canonicalrestrictionaction} and \\eqref{eq:canonicalprolongationaction}.  However, the two operators differ in their invertibility.  The one-to-one map $P$ has a left inverse; function $y$ in $\\mathcal{V}^{j-1}$ can be exactly recovered from $Py$ because they are the same piecewise-linear function.  In fact, we will only make $P$ explicit to indicate a change in vector representation.  By contrast, $\\ell$ in $(\\mathcal{V}^j)'$ is not recoverable from $R\\ell$ because the values $\\ell[\\psi_q^j]$, i.e.~the action of $\\ell$ on the finer level hats, are averaged onto the coarse level, and thus lost.\n\nIt turns out that five such mesh-level \\emph{transfer} operators are used in this paper, two of which are not even linear.  See Table \\ref{tab:transfers}.  Note they can all be applied in $O(m_j)$ time.\n\n\\begin{table}\n\\begin{tabular}{l|ccccc}\n\\emph{operator}              & \\emph{equation}  & \\emph{domain}          & \\emph{range}\n                  & \\emph{linear} \\\\ \\hline\ncanonical prolongation $P$   & \\eqref{eq:canonicalprolongationaction} & $\\mathcal{V}^{j-1}$    & $\\mathcal{V}^j$\n                  & \\checkmark \\\\\nsolution prolongation $\\hat P$   & \\eqref{eq:solutionprolongation} & $\\mathcal{V}^{j-1}$    & $\\mathcal{V}^j$\n                  &  \\\\\ncanonical restriction $R$    & \\eqref{eq:canonicalrestrictionaction} & $(\\mathcal{V}^j)'$     & $(\\mathcal{V}^{j-1})'$\n                  & \\checkmark \\\\\ninjection restriction $\\iR$    & \\eqref{eq:injectionrestriction} & $\\mathcal{V}^j$        & $\\mathcal{V}^{j-1}$\n                  & \\checkmark \\\\\nmonotone restriction $\\mR$   & \\eqref{eq:monotonerestriction} & $\\mathcal{V}^j$        & $\\mathcal{V}^{j-1}$\n                  &  \\\\\n\\end{tabular}\n\n\\medskip\n\\caption{Transfer operators used in this paper.  The nonlinear $\\mR$ and $\\hat P$ operators are defined in section \\ref{sec:obstacle}.}\n\\label{tab:transfers}\n\\end{table}\n\nWe have now presented a basic GMG algorithm for linear PDEs via a particular FE viewpoint, namely the MSC approach pioneered by Xu \\cite{Xu1992} and others.  The MSC viewpoint is foundational for multilevel, domain-decomposition, and other advanced algorithms \\cite[for example]{Farrelletal2019}.  Our next step might be to show computational results demonstrating the efficiency of a GMG algorithm, giving evidence of optimal $O(m_J)$ time to solve the problem, and indeed such results appear in all of our multigrid references \\cite{Braess2007,Briggsetal2000,Bueler2021,Elmanetal2014,Trottenbergetal2001}.  However, we first introduce a less-standard ``obstacle'' problem because it shows the essential free-boundary character of the glacier geometry problem.  Computational results appear in each of the next three sections.\n\n\n\\section{Multilevel constraint decomposition (MCD) for the classical obstacle problem} \\label{sec:obstacle}\n\n\\subsection{An ice-like model problem} \\label{subsec:obstacleproblem}  We now have a clear view of a multigrid method for a linear equation and from the MSC point of view.  However, as addressed in the Introduction, the main problem of how glacier geometry and ice velocity co-evolve in response to climatic inputs requires an inequality constraint for well-posedness.  This constraint, the fact that the ice surface elevation is above the bed, which generates the land-terminating mass-conservation boundary condition, both makes the problem nonlinear and reduces solution regularity.\n\nTo incorporate such inequality constraints into a multilevel framework, and before actually modeling glaciers in section \\ref{sec:sia}, we introduce the \\emph{classical obstacle problem}, which simply adds an inequality constraint to linear Poisson equation \\eqref{eq:poisson}.  After stating the weak form, which is now solved over a convex \\emph{subset} of the function space, we will modify the MSC approach into the \\emph{multilevel constraint decomposition} (MCD) method.  Each mesh level will host an inequality-constrained problem, and together all the levels will capture the fine-level constraint subset.  The nonlinear SIA model (section \\ref{sec:sia}), and the Stokes model in the second part of the paper \\cite{BuelerMitchell2022}, will use a nonlinear extension of the MCD method.\n\nConsider the same 1D domain and solution space $\\mathcal{H}=H_0^1[0,1]$ as before.  Let $\\varphi(x)$ be a fixed function, the obstacle, from $\\mathcal{H}$.  The strong form of the classical obstacle problem is the following \\emph{complementarity problem} (CP) \\cite{Bueler2021,KinderlehrerStampacchia1980} which says that the solution $u(x)$ is above $\\varphi(x)$ \\emph{and} that a differential equation applies whereever $u$ is strictly above $\\varphi$:\n\\begin{align}\n  u - \\varphi &\\ge 0 \\label{eq:obstaclecp} \\\\\n  -(\\alpha u')'-f &\\ge 0 \\notag \\\\\n  (u-\\varphi)(-(\\alpha u')'-f) &= 0 \\notag\n\\end{align}\nThe third condition, \\emph{complementarity} itself, says that for each $x$ in $[0,1]$ the solution either coincides with the obstacle ($u(x)=\\varphi(x)$) or PDE \\eqref{eq:poisson} holds.  (Both facts can hold at $x$, but in the generic \\emph{nondegenerate} case the obstacle does not itself solve the PDE.)  In the $u=\\varphi$ region the constraint is said to be \\emph{active}, while \\eqref{eq:poisson} holds in the \\emph{inactive} portion where $u>\\varphi$.  One refers to PDE \\eqref{eq:poisson} as the \\emph{interior condition} of the CP.  Note that in the active region the source term is bounded above, $u=\\varphi \\implies f \\le -(\\alpha\\varphi')'$, but the corresponding statement does \\emph{not} hold for the glacier problems in section \\ref{sec:sia} and the second part of the paper \\cite{BuelerMitchell2022}.\n\nBy choosing a source term $f(x)$ which is positive in the middle of the domain and negative near the boundaries we create an ``ice-like'' solution to \\eqref{eq:obstaclecp}.  Figure \\ref{fig:icelike} (top) shows such an exact solution $u(x)$, for the following data:\n\\begin{equation}\n\\varphi(x) = x(1-x), \\quad \\alpha(x)=1, \\quad f(x) = \\begin{cases} 8, & 0.2 < x < 0.8, \\\\\n                                                                 -16, & x<0.2 \\text{ or } x>0.8. \\end{cases}  \\label{eq:icelikedetails}\n\\end{equation}\nFinding the exact formula for $u(x)$, which smoothly-connects five quadratic pieces, is an exercise for the reader.\\footnote{Solved in\\, \\href{https://github.com/bueler/mg-glaciers/blob/master/py/obstacle.py}{\\texttt{github.com/bueler/mg-glaciers/blob/master/py/obstacle.py}}.}  The bottom part of Figure \\ref{fig:icelike} shows a more typical textbook solution of an obstacle problem.\n\n% regenerate:\n%   $ cd py/1D/\n%   $ ./obstacle.py -plain -jfine 7 -o icelike.pdf\n%   $ ./obstacle.py -plain -jfine 7 -o parabola.pdf -problem parabola\n%   $ pdfcrop icelike.pdf icelike.pdf\n%   $ pdfcrop parabola.pdf parabola.pdf\n\\begin{figure}\n\\,\\,\\includegraphics[width=0.8\\textwidth]{fixfigs/icelike.pdf}\n\n\\bigskip\\medskip\n\\includegraphics[width=0.82\\textwidth]{fixfigs/parabola.pdf}\n\n\\medskip\n\\caption{\\emph{Top:} An ice-like configuration of the classical obstacle problem, with $f$ of both signs. \\emph{Bottom:} A traditional configuration with $f=0$.}\n\\label{fig:icelike}\n\\end{figure}\n\nThe solution to \\eqref{eq:obstaclecp} does \\emph{not} depend linearly on the source function $f$.  For example, if $f \\le 0$ and the obstacle is concave-down ($\\varphi'' \\le 0$) then the solution is $u=\\varphi$.  (By the maximum principle \\cite{Evans2010} there are no inactive points in this case.)  In such a case, if $\\tilde u$ solves the problem for $\\tilde f$ then $2\\tilde u$ does not solve the problem for source term $2\\tilde f$.  In this sense the classical obstacle problem is nonlinear even though its interior condition PDE \\eqref{eq:poisson} is linear.\n\nThe glacier problem also has a CP formulation (section \\ref{sec:sia}; see also \\cite{Calvoetal2002}) in which the obstacle is the bed elevation, the solution is the glacier surface elevation, and the source term is the surface mass balance.  In the inactive region, i.e.~on the glacier, the mass conservation equation applies, and the surface mass balance must be negative in the active region off the glacier.\n\n\\subsection{Weak formulation with constraints} \\label{subsec:obstacleweak}  We now define a closed subset which incorporates the constraint:\n\\begin{equation}\n\\mathcal{K}_\\varphi = \\left\\{v \\ge \\varphi\\right\\} \\subseteq \\mathcal{H}.  \\label{eq:Kdefine}\n\\end{equation}\nIf $v$ is in $\\mathcal{K}_\\varphi$ then we say $v$ is \\emph{admissible}.  Note $\\mathcal{K}_\\varphi$ is not a vector space, but it is \\emph{convex}, that is, if $v,w$ are in $\\mathcal{K}_\\varphi$ then any point on the line segment connecting them, $\\theta v + (1-\\theta) w$ for $0 \\le \\theta \\le 1$, is also in $\\mathcal{K}_\\varphi$.  Furthermore, because the inequality is one-sided, $\\mathcal{K}_\\varphi$ is a \\emph{cone} with vertex at $\\varphi$, that is, if $v$ is in $\\mathcal{K}_\\varphi$ then $\\lambda(v-\\varphi) + \\varphi$ is also in $\\mathcal{K}_\\varphi$ for any $\\lambda \\ge 0$; the ray from $\\varphi$ through $v$ is in $\\mathcal{K}_\\varphi$.\n\nDerivation of the weak form involves multiplying the strong form \\eqref{eq:obstaclecp} by a test function and integrating by parts.  The inequalities then enter into the derivation (see \\cite[Chapter 12]{Bueler2021}, \\cite{JouvetBueler2012}, or \\cite{KinderlehrerStampacchia1980} for details), and the result is a single \\emph{variational inequality} (VI),\n\\begin{equation}\n  a(u,v-u) \\ge \\ip{f}{v-u} \\quad \\text{ for all } v \\text{ in } \\mathcal{K}_\\varphi, \\label{eq:obstaclevi}\n\\end{equation}\nusing the same bilinear form \\eqref{eq:weakpoissonearly} for the Poisson equation.  Recalling definition \\eqref{eq:residual}, the VI can be restated using a residual functional:\n\\begin{equation}\n  F(u)[v-u] \\ge 0 \\quad \\text{ for all } v \\text{ in } \\mathcal{K}_\\varphi. \\label{eq:obstacleviresidual}\n\\end{equation}\n\nFormulations \\eqref{eq:obstaclecp} and \\eqref{eq:obstacleviresidual} are equivalent up to the same regularity concerns which relate the strong and weak forms of a PDE.  (See reference \\cite{Evans2010} regarding the solution regularity of PDEs, and \\cite{KinderlehrerStampacchia1980} for the corresponding VI theory.)  However, some intuition for VIs is needed for understanding the current paper, and so, in an attempt to help, we provide a second weak form.  Namely, inequality \\eqref{eq:obstacleviresidual} is equivalent to \\emph{constrained minimization} of an objective functional $I$:\n\\newcommand{\\argmin}{\\mathop{\\mathrm{arg\\text{-}min}}}\n\\begin{equation}\n  u = \\argmin_{w \\text{ in } \\mathcal{K}_\\varphi} I(w) \\quad \\text{where} \\quad I(w) = \\frac{1}{2} a(w,w) - \\ip{f}{w}. \\label{eq:obstaclemin}\n\\end{equation}\nThat is, $u$ is the minimizer, over the constraint set $\\mathcal{K}_\\varphi$, of the scalar, quadratic, and \\emph{coercive} functional $I$.  (Coercive means that $I(w) \\to +\\infty$ as $\\|w\\|_{\\mathcal{H}} \\to \\infty$ \\cite{Evans2010}.)  Note that the unconstrained minimum of $I(w)$ over $\\mathcal{H}$ may lie outside $\\mathcal{K}_\\varphi$; see Figure \\ref{fig:cartoonplane}.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/cartoonplane.pdf}\n\\caption{Variational inequality \\eqref{eq:obstacleviresidual}, equivalently \\eqref{eq:obstaclevigradient}, characterizes the minimum $u$ of $I(w)$ over the shaded convex cone $\\mathcal{K}_\\varphi=\\{v\\ge \\varphi\\} \\subset \\mathcal{H}$.  Conceptually speaking, any vector $v-u$, for $v$ in $\\mathcal{K}_\\varphi$, is within $90^\\circ$ of $F(u) = \\grad I(u)$.}\n\\label{fig:cartoonplane}\n\\end{figure}\n\nThe (Gateaux) derivative of $I$ is a linear functional in $\\mathcal{H}'$,\n\\begin{equation}\n  \\grad I(w)[v] = \\lim_{\\eps\\to 0} \\frac{I(w+\\eps v) - I(w)}{\\eps} = a(u,v) - \\ip{f}{v},  \\label{eq:gradobjective}\n\\end{equation}\nso in fact $\\nabla I = F$.  Thus the VI \\eqref{eq:obstacleviresidual} can re-stated as\n\\begin{equation}\n  \\nabla I(u)[v-u] \\ge 0 \\quad \\text{ for all } v \\text{ in } \\mathcal{K}_\\varphi. \\label{eq:obstaclevigradient}\n\\end{equation}\n\nFormulation \\eqref{eq:obstaclevigradient} permits us to give a clear, geometrical meaning to the VI, as in the Figure.  The solution $u$ sits at a location in $\\mathcal{K}_\\varphi$, often on the boundary, where any vector pointing into the admissible set, namely $v-u$ for $v$ in $\\mathcal{K}_\\varphi$, points ``uphill'' on the graph of $I$.  Identifying $\\mathcal{H}$ and its dual space $\\mathcal{H}'$, one might write \\eqref{eq:obstaclevigradient} as $\\ip{\\nabla I(u)}{v-u} \\ge 0$: the angle between $\\nabla I(u)$ and $v-u$ is at most 90 degrees in the nontrivial cases where $\\nabla I(u)$ is nonzero and thus $u$ is on the boundary of $\\mathcal{K}_\\varphi$.\n\nRecall that elements of $\\mathcal{K}_\\varphi$ are functions on $[0,1]$ (e.g.~Figure \\ref{fig:icelike}).  When the solution $u$ coincides with the obstacle $\\varphi$ on a part of the domain then this shows $u$ is on the boundary of $\\mathcal{K}_\\varphi$, and that arbitrarily-small perturbations $\\delta u$, from $\\mathcal{H}$, put $u+\\delta u$ outside of $\\mathcal{K}_\\varphi$.\n\nGlacier problems (section \\ref{sec:sia} and \\cite{BuelerMitchell2022}) may also be formulated either as CPs like \\eqref{eq:obstaclecp} and VIs like \\eqref{eq:obstacleviresidual}.  However, for general bed elevation functions (obstacles) these glacier problems have no constrained minimization formulation like \\eqref{eq:obstaclemin}, so the VI formulations have no interpretation like \\eqref{eq:obstaclevigradient}.  The essential reason is the lack of a symmetry of the weak form; see \\cite{JouvetBueler2012} for the argument in the SIA case.  However, for glacier problems we will possess a map $F$, from $\\mathcal{K}_\\varphi$ to $\\mathcal{H}'$, and if $u$ solves the VI then, heuristically, $F(u)$ points perpendicularly into $\\mathcal{K}_\\varphi$.  We may visualize the general VI form \\eqref{eq:obstacleviresidual} essentially as in Figure \\ref{fig:cartoonplane}, but without the identification of $F$ as a gradient of any objective functional.\n\nRegardless of how the classical obstacle problem is formulated, a \\emph{free boundary} generally arises in the interior of the domain.  For example, on either side of the midpoint in Figure \\ref{fig:icelike} there are locations where the solution first comes fully in contact with the obstacle.  At these locations both $u=\\varphi$ and $u'=\\varphi'$ hold.  That is, the solution is tangent to the obstacle at the free boundary, and such simultaneous Dirichlet and Neumann conditions occur at a location which must be found as part of the solution \\cite[Chapter V]{KinderlehrerStampacchia1980}.  (The analogous conditions in the glacier problem are that both the ice thickness and the horizontal ice flux go to zero at a grounded glacier margin \\cite{Bueler2016,JouvetBueler2012}.)  The solution of the classical obstacle problem will generally be non-smooth at a free boundary even when the data are arbitrarily smooth.  For example, smoothing the source term $f$ in \\eqref{eq:icelikedetails} by ``mollification'' \\cite{Evans2010}, so that the transition between positive and negative values would be $C^\\infty$, would give a solution nearly the same as shown in Figure \\ref{fig:icelike} (top).  However, the free boundary would remain, and at that free boundary the second derivative $u''$ would jump discontinuously from value $+16=-f$ to value $-2=\\varphi''$.  A similar jump in $u''$ applies at the free boundary in Figure \\ref{fig:icelike} (bottom), from $0=f$ to $-16=\\varphi''$.  In general it is known that for smooth $C^\\infty$ data $f,\\varphi$ the solution $u$ is in the Sobolev space $W^{2,\\infty}$, but it is not in $C^2$ \\cite[section IV.6]{KinderlehrerStampacchia1980}.\n\n\\subsection{Smoothers: projected Gauss-Seidel and Jacobi} \\label{subsec:obstaclesmoothers}  Now consider the FE method for a VI.  On each mesh level we will define an obstacle $\\phi^j$ in $\\mathcal{V}^j$, an admissible set $\\mathcal{K}^j = \\{v \\ge \\phi^j\\} \\subset \\mathcal{V}^j$, and a residual function $F^j$.  (Recall $\\mathcal{V}^j$ is the vector space spanned by the $j$th-level hats $\\psi_p^j$; see section \\ref{sec:subspace}.)  The FE method seeks $y^j$ in $\\mathcal{K}^j$ so that a finite-dimensional VI holds:\n\\begin{equation}\n  F^j(y^j)[v-y^j] \\ge 0 \\quad \\text{ for all } v \\text{ in } \\mathcal{K}^j. \\label{eq:feobstacleviresidual}\n\\end{equation}\n\nIf we were to solve on the fine-level $\\mathcal{V}^J$ only, i.e.~in a single-level method, then we would choose the obstacle $\\phi^J$ to be the piecewise-linear interpolant of the continuum obstacle $\\varphi$, i.e.~$\\phi^J=\\varphi^J$, and $F^J$ as the original residual $F(w)[\\cdot] = a(w,\\cdot) - \\ip{f}{\\cdot}$.  However, in our multilevel method the constructions of $\\phi^j$ and $F^j$ will be nontrivial, even on the finest level.  We will have much more to say regarding the obstacles $\\phi^j$, but in each case the residual will have the simple form $F^j(w)[\\cdot] = a(w,\\cdot) - \\ell^j[\\cdot]$ for some $\\ell^j$ in $(\\mathcal{V}^j)'$.\n\nBefore addressing the multilevel method we propose an iterative method for solving \\eqref{eq:feobstacleviresidual}.  Supposing $w$ in $\\mathcal{K}^j$ is any iterate, such a method modifies $w$ at the $p$th node so that \\eqref{eq:feobstacleviresidual} holds at that node.  Note that if $w$ is admissible then $w+c\\psi_p^j$ is admissible if and only if $w_p + c \\ge \\phi_p$ where $\\phi_p = \\phi^j(x_p^j)$.  (This equivalence holds for piecewise-linear elements, but not generally for higher-order polynomial elements.)\n\nFor clarity we describe the \\emph{projected Gauss-Seidel} (PGS) iterative method using the constrained minimization form \\eqref{eq:obstaclemin}, using a convex scalar function based on the objective functional.  Let\n\\begin{equation}\ni(b) = I^j(w+b\\psi_p^j),\n\\end{equation}\nwhere $I^j(w) = \\frac{1}{2} a(w,w) - \\ell^j[w]$ and $b$ is a real number.  At each point $p$ we seek the minimizer over admissible perturbations,\n\\begin{equation}\n  c = \\argmin_{b \\ge \\phi_p - w_p} \\, i(b).  \\label{eq:pgsminimization}\n\\end{equation}\nThe minimum of $i(b)$ on the admissible interval $\\phi_p - w_p \\le b < \\infty$ occurs either at the critical point $i'(b)=0$ or at the left end of the interval.  Since $i'(b) = F^j(w)[\\psi_p^j] + b a(\\psi_p^j,\\psi_p^j)$ and $i''(b) = a(\\psi_p^j,\\psi_p^j) > 0$,\n\\begin{equation}\n  c = \\max\\left\\{-\\frac{F^j(w)[\\psi_p^j]}{a(\\psi_p^j,\\psi_p^j)}, \\, \\phi_p - w_p\\right\\}  \\label{eq:pgsformula}\n\\end{equation}\nis the solution of \\eqref{eq:pgsminimization}.  In other words, we compute the unconstrained critical point where $i'(b)=0$ and then project it into the admissible interval.  Then we update $w \\gets w + c\\psi_p^j$ and proceed to the next point.\n\nThis minimization view of PGS is not essential, however.  We can derive formula \\eqref{eq:pgsformula} using only VI \\eqref{eq:feobstacleviresidual}, and this will be a useful reference when we consider the glacier model in section \\ref{sec:sia}.  We seek $c$ such that $w+c\\psi_p^j$ is admissible and so that \\eqref{eq:feobstacleviresidual} holds for all admissible $v=w+\\tilde c\\psi_p^j$.  That is, we find $c\\ge \\phi_p-w_p$ so that\n\\begin{equation}\n  F^j(w+c\\psi_p^j)[(w+\\tilde c\\psi_p^j) - (w+c\\psi_p^j)] = (\\tilde c - c) F^j(w+c\\psi_p^j)[\\psi_p^j] \\ge 0,  \\label{eq:pgspointwisevi}\n\\end{equation}\nfor all $\\tilde c\\ge \\phi_p-w_p$.  Inequality \\eqref{eq:pgspointwisevi} is a one-dimensional VI, of form $(\\tilde c - c) \\rho(c) \\ge 0$ for\n\\begin{equation}\n  \\rho(c) = F^j(w+c\\psi_p^j)[\\psi_p^j] = F^j(w)[\\psi_p^j] + c\\,a(\\psi_p^j,\\psi_p^j),  \\label{eq:pgspointwisegfunction}\n\\end{equation}\non the interval $[\\phi_p-w_p,+\\infty)$.  Note that the ellipticity of the Poisson equation implies $a(\\psi_p^j,\\psi_p^j)>0$, thus the pointwise residual $\\rho(c)$ is strictly increasing, and so \\eqref{eq:pgspointwisevi} is a well-posed VI with solution \\eqref{eq:pgsformula}.\n\nThe following pseudocode, a small modification of \\pr{gs-sweep} on page \\pageref{ps:gs-sweep}, implements PGS:\n\\begin{pseudo*} \\label{ps:pgs}\n\\pr{pgs}(j,w,a,\\ell,\\phi,\\id{omega}=1)\\text{:} \\\\+\n    \\ct{check admissibility: $w\\ge \\phi$} \\\\\n    $F(w)[\\cdot] := a(w,\\cdot) - \\ell[\\cdot]$ \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        $c = -F(w)[\\psi_p^j] \\,\\big/\\, a(\\psi_p^j,\\psi_p^j)$ \\\\\n        $w_p \\gets \\max\\{w_p + \\id{omega}\\,c, \\phi_p\\}$\n\\end{pseudo*}\n\nAs noted in section \\ref{sec:subspace}, GS-type multiplicative smoothers re-evaluate the residual after each point update.  This is an acceptable $O(1)$ cost when the residual of an iterate at a point $x_p^j$ is computable from a few neighboring values, as applies here and in section \\ref{sec:sia}.  However, when the residual is nonlocal, and especially when it is both nonlocal and expensive to evaluate, as for the Stokes-based model in \\cite{BuelerMitchell2022}, a GS-type smoother becomes less practical.  An alternative is a Jacobi-type additive smoother in which the residual is evaluated once at all points.  The following modifies \\pr{jacobi-sweep} on page \\pageref{ps:jacobi-sweep}.\n\\begin{pseudo*} \\label{ps:pjacobi}\n\\pr{pjacobi}(j,w,a,\\ell,\\phi,\\id{omega}=0.67)\\text{:} \\\\+\n    \\ct{check admissibility: $w\\ge \\phi$} \\\\\n    $F_p = a(w,\\psi_p^j) - \\ell[\\psi_p^j]$ \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        $c = -F_p \\,\\big/\\, a(\\psi_p^j,\\psi_p^j)$ \\\\\n        $w_p \\gets \\max\\{w_p + \\id{omega}\\,c, \\phi_p\\}$\n\\end{pseudo*}\nWe could also describe this smoother as a projected forward Euler step (section \\ref{sec:subspace}), i.e.~as a step of the common time-evolution method in glacier and ice sheet models \\cite[for example]{Winkelmannetal2011}.\n\nFor appropriate ranges of \\id{omega} both algorithms above are known to converge to the solution $y^j$ of VI problem \\eqref{eq:feobstacleviresidual} \\cite[Proposition 4.5]{GraeserKornhuber2009}, but, of course, slowly on fine meshes.  Regarding the relaxation parameter \\id{omega}, recall that the optimal value for the Poisson equation is \\id{omega} $=2/3$ \\cite{Briggsetal2000}, but finding the most-effective smoother values for obstacle problems is a topic for numerical experimentation.\n\nAssuming each pointwise residual $F(w)[\\psi_p^j]$ is an $O(1)$ operation in the $j$th-level representation, \\pr{pgs} and \\pr{pjacobi} are $O(m_j)$ operations.  The latter remains $O(m_j)$ as long as the vector residual and the diagonal entries can be computed in $O(m_j)$ operations given $w$, even if individual pointwise residuals are not $O(1)$.\n\nHowever, for VI problems the residual norm $\\|F(w)\\|_2$ does not generally go to zero at the convergence of the iterations.  Recalling the CP formulation \\eqref{eq:obstaclecp}, at convergence we have $F(w)[\\psi_p^j] = 0$ where $w(x_p^j) > \\phi(x_p^j)$ (inactive points), but if $w(x_p^j) = \\phi(x_p^j)$ (active points) then $F(w)[\\psi_p^j]$ need only be nonnegative.  Thus the convergence criterion for iterated PGS sweeps is that the norm of the \\emph{CP residual}, the vector\n\\begin{equation}\n  (\\hat \\bF(w))_p = \\begin{cases} F(w)[\\psi_p^j], & w_p > \\phi_p, \\\\\n                                  \\min\\{F(w)[\\psi_p^j],0\\}, & w_p = \\phi_p, \\end{cases} \\label{eq:cpresidual}\n\\end{equation}\nin $\\RR^{m_j}$, should be small.  Thus our convergence criterion will be\n\\begin{equation}\n\\|\\hat\\bF(w)\\|_2 < \\text{\\texttt{rtol}}\\,\\|\\hat\\bF(w^0)\\|_2 \\label{eq:cpconvergencecriterion}\n\\end{equation}\nfor some tolerance \\id{rtol}.\n\nThe above projected iterations will serve as our smoothers, applied one or two times on each level, and as the coarse-level solver as well.  However, we are not yet prepared to build a multilevel method for problem \\eqref{eq:feobstacleviresidual} because the nontrivial construction of the obstacles $\\phi^j$ and residuals $F^j$ remains.  We need to decompose the continuum constraint $\\varphi$ across the mesh-level hierarchy, and we need to construct admissible multilevel corrections.\n\n\\subsection{Multilevel constraint decomposition} \\label{subsec:mcd}  The technique in this section answers the following question:  How do we maintain admissibility throughout a multilevel cycle while not introducing high-frequencies?\n\nConsider the coarse-level correction $e^{j-1}$ in a linear V-cycle (section \\ref{sec:subspace}, equation \\eqref{eq:coarsecorrection}), which is prolonged onto the $j$th level.  For a problem with obstacle $\\varphi^j$ the resulting iterate would need to be admissible, i.e.~$w + P e^{j-1} \\ge \\varphi^j$.  However, as illustrated in Figure \\ref{fig:prolongobstacle}, if the obstacles are interpolants of a (common) continuum obstacle $\\varphi$ then an iterate which is admissible on the $j-1$ level is \\emph{not} necessarily admissible on the $j$ level.  (In the glacier context, a coarse-mesh ice surface may be breached by the fine-mesh bed topography.)  We might try enforcing admissibility by \\emph{truncation}, namely overwriting $\\tilde w = w + Pe^{j-1}$ with $\\max\\{\\tilde w, \\varphi^j\\}$.  However, this reintroduces high frequencies, requiring additional smoother effort to remove, and generally damaging multigrid convergence rates.\n\n\\begin{figure}\n\\qquad \\includegraphics[width=0.75\\textwidth]{genfigs/prolongobstacle.pdf}\n\\caption{If mesh-level obstacles interpolate a common continuum obstacle then an admissible iterate on a coarse level, when prolonged, may not be admissible on a finer level.}\n\\label{fig:prolongobstacle}\n\\end{figure}\n\nOne way forward is the \\emph{multilevel constraint decomposition} (MCD) method of Tai \\cite{Tai2003}, here in the specific form proposed in \\cite{GraeserKornhuber2009}.  Suppose $w^J$ in $\\mathcal{V}^J$, on the finest level, is admissible in the original sense that\n\\begin{equation}\n  w^J \\ge \\varphi^J, \\label{eq:fineadmissibleiterate}\n\\end{equation}\nwhere $\\varphi^J$ interpolates the continuum obstacle.  Define the \\emph{defect constraint} \\cite{GraeserKornhuber2009} of $w^J$ as\n\\begin{equation}\n  \\chi^J = \\varphi^J - w^J.  \\label{eq:defectconstraint}\n\\end{equation}\nNote $\\chi^J \\le 0$.  The meaning of ``defect constraint'' is that if we modify $w^J$ by adding $y$ then the result is admissible if and only if $y$ is above $\\chi^J$:\n\\begin{equation}\n  w^J + y \\ge \\varphi^J  \\qquad \\iff \\qquad y \\ge \\chi^J.  \\label{eq:defectmeaning}\n\\end{equation}\n\nOur MCD method will \\emph{put as much of $\\chi^J$ into the coarsest levels as possible}.  That is, our decomposition of $\\chi^J$ will allow the largest corrections on the inexpensive coarse levels.  For this purpose, following \\cite[equation (4.22)]{GraeserKornhuber2009}, we define a nonlinear \\emph{monotone restriction} operator $\\mR$ from $\\mathcal{V}^j$ to $\\mathcal{V}^{j-1}$.  For $z$ in $\\mathcal{V}^j$, $\\mR z$ is computed by maximizing nodal values of $z$ over the interior of the support of coarser-level hat functions.  That is, if $z = \\sum_q z_q \\psi_q^j$ on the fine level then\n\\begin{equation}\n  \\mR z = \\sum_{p=1}^{m_{j-1}} \\zeta_p \\psi_p^{j-1} \\qquad \\text{where} \\qquad \\zeta_p = \\max \\{z_q \\,:\\, \\psi_p^{j-1}(x_q^j) > 0\\}.  \\label{eq:monotonerestriction}\n\\end{equation}\nObserve that $\\mR z \\ge z$.  Also note that $\\mR$ acts on functions $\\mathcal{V}^j$ while canonical restriction $R$ acts on linear functionals $(\\mathcal{V}^j)'$; see Table \\ref{tab:transfers}.  We then define the \\emph{$j$th-level defect constraint} inductively by\n\\begin{equation}\n  \\chi^j = \\mR \\chi^{j+1}  \\label{eq:chik}\n\\end{equation}\nfor $j=J-1$ down to $j=0$.  These defect constraints have two key properties: $\\chi^j$ is in $\\mathcal{V}^j$ and $\\chi^j \\ge \\chi^{j+1}$.  (One may also write $P \\chi^j \\ge \\chi^{j+1}$.)\n\nThe \\emph{$j$th-level obstacle} is the difference of defect constraints:\n\\begin{equation}\n  \\phi^j = \\chi^j - \\chi^{j-1} \\quad \\text{ for } j=0,1,\\dots,J,  \\label{eq:levelobstacle}\n\\end{equation}\nwhere we also define $\\chi^{-1}=0$ so that $\\phi^0 = \\chi^0$.  Note $\\phi^j$ is in $\\mathcal{V}^j$ and $\\phi^j\\le 0$.\n\n%REGENERATE Figures \\ref{fig:gooddecomposition} and \\ref{fig:icelikedecomposition}:\n%$ ./obstacle.py -jfine 5 -jcoarse 1 -random -randommodes 8 -diagnostics -o defect.pdf\n%fine level 5 (m=63): using 20 V(1,0) cycles -> 38.750 WU\n\\begin{figure}\n\\includegraphics[width=0.75\\textwidth]{fixfigs/decomp_defect.pdf}\n\\caption{Our MCD method writes a fine-level defect constraint $\\chi^J = \\varphi^J - w^J$ as a sum of obstacles $\\phi^j = \\chi^j - \\chi^{j-1}$ on each level.}\n\\label{fig:gooddecomposition}\n\\end{figure}\n\nWe have now decomposed the fine-level defect constraint $\\chi^J$ via a ``telescoping'' sum:\n\\begin{equation}\n  \\sum_{j=0}^J \\phi^j = \\chi^0 + (\\chi^1 - \\chi^0) + (\\chi^2 - \\chi^1) + \\dots + (\\chi^J - \\chi^{J-1}) = \\chi^J.  \\label{eq:telescopingdecomposition}\n\\end{equation}\nAn example is shown in Figure \\ref{fig:gooddecomposition}.  Note that the obstacles $\\phi^j$ are the gaps between the plotted defect constraints $\\chi^j$.  If the $J$th level is a high-resolution mesh and the defect constraint $\\chi^J$ is smooth then $\\phi^J\\approx 0$ because $\\chi^J$ is well-approximated on the $J-1$ level.\n\nFrom the obstacles $\\phi^j$ we define closed, convex \\emph{admissible (correction) sets}\n\\begin{equation}\n\\mathcal{K}^j = \\left\\{v \\ge \\phi^j\\right\\} \\subset \\mathcal{V}^j \\label{eq:defineKj}\n\\end{equation}\nfor $j=0,1,\\dots,J$.  Because $\\phi^j \\le 0$, the zero function is admissible on every level.  On the finest level, note that $\\phi^J$ is not the same as $\\varphi^J$, and so $\\mathcal{K}^J$ does not approximate $\\mathcal{K}_\\varphi$.\n\nWe also define the $j$th-level \\emph{defect constraint set}\n\\begin{equation}\n  \\mathcal{D}^j = \\left\\{v \\ge \\chi^j\\right\\} \\subset \\mathcal{V}^j.  \\label{eq:constraintset}\n\\end{equation}\nFrom the telescoping sum \\eqref{eq:telescopingdecomposition}, the admissible correction sets $\\mathcal{K}^j$ decompose $\\mathcal{D}^j$:\n\\begin{equation}\n  \\mathcal{D}^j = \\mathcal{K}^0 + \\mathcal{K}^1 + \\dots + \\mathcal{K}^j. \\label{eq:constraintdecomposition}\n\\end{equation}\nThat is, every $y$ in $\\mathcal{D}^j$ can be built by choosing a function from each of the sets $\\mathcal{K}^0,\\dots,\\mathcal{K}^j$.  As with \\eqref{eq:subspacedecomposition}, this representation is usually not unique.\n\nSubset equation \\eqref{eq:constraintdecomposition} is close to the core meaning of the MCD method.  As shown in Figure \\ref{fig:innerconeapprox}, this decomposition implies a nesting of cones:\n\\begin{equation}\n  \\mathcal{D}^0 \\subset \\mathcal{D}^1 \\subset \\dots \\subset \\mathcal{D}^J.  \\label{eq:nestedcones}\n\\end{equation}\nIn particular, the fine-level defect constraint set $\\mathcal{D}^J = \\{v \\ge \\chi^J\\}$ is approximated ``from within'' by coarser-level cones, the partial sums $\\mathcal{D}^j = \\sum_{k=0}^j \\mathcal{K}^k$.  The smaller sets $\\mathcal{K}^j$ are also cones, but they are not nested.  However, though $\\mathcal{K}^j$ and $\\mathcal{D}^j$ are cones relative to $\\phi^j$ and $\\chi^j$, respectively, they are not closed under addition, and therefore corrections must be carefully applied, with attention to admissibility of the new iterate \\eqref{eq:defectmeaning}, especially in a V-cycle (see below).\n\n\\begin{figure}\n\\includegraphics[width=0.65\\textwidth]{genfigs/innerconeapprox.pdf}\n\n\\caption{The MCD method approximates the fine-level defect constraint cone $\\mathcal{D}^J = \\{v\\ge \\chi^J\\}$ from inside by coarse-level cones $\\mathcal{D}^j=\\mathcal{K}^0+\\dots+\\mathcal{K}^j$.}\n\\label{fig:innerconeapprox}\n\\end{figure}\n\nLooking forward to the glacier problem in section \\ref{sec:sia}, the fine-mesh obstacle $\\varphi^J$ will be the bed elevation, $w^J$ will be a candidate ice surface elevation on the fine mesh, and $-\\chi^J$ will be the corresponding ice thickness.  With this in mind, Figure \\ref{fig:icelikedecomposition} illustrates the same constraint decomposition as in Figure \\ref{fig:gooddecomposition}, but pictured as a decomposition of the ``ice'' into layers.  (Compared to Figure \\ref{fig:icelike} (top), the ``topography'' $\\varphi^J$ here is bumpy.)  However, the earlier Figure plots the decomposition in the correct sense, so that the functions $\\chi^j$ and $\\phi^j$ are piecewise-linear, and so that the zero correction is admissible on every level.\n\n\\begin{figure}\n\\includegraphics[width=0.7\\textwidth]{fixfigs/icedec_defect.pdf}\n\\caption{A heuristic understanding of Figure \\ref{fig:gooddecomposition}: MCD decomposes the ``ice'' between a fine-mesh iterate $w^J$ and the fine-mesh obstacle $\\varphi^J$.}\n\\label{fig:icelikedecomposition}\n\\end{figure}\n\n\\subsection{MCD coarse-level corrections} \\label{subsec:mcdcorrections}  On each mesh level there is now an obstacle problem, and we will write it in three forms.  The forms are equivalent for the classical obstacle problem, but only one form is suited to the nonlinear glacier problems in section \\ref{sec:sia} and in the second part of the paper \\cite{BuelerMitchell2022}.\n\nSuppose $w^J$ is an admissible iterate on the fine level: $w^J\\ge \\varphi^J$.  Assume that we have already descended from the fine level $J$ to some level $j+1$, computing admissible corrections $y^k$ from each set $\\mathcal{K}^k=\\{v\\ge \\phi^k\\}$, for $k\\ge j+1$.  From the definitions of $\\chi^J$ and $\\mathcal{D}^J$, the function $z = w^J+y^J+\\dots+y^{j+1}$ is admissible in the original sense, i.e.~$z\\ge \\varphi^J$.  Recall that $F(w)[v] = a(w,v) - \\ip{f}{v}$ denotes the continuum residual \\eqref{eq:residual}, and then $I(v) = \\frac{1}{2} a(v,v) - \\ip{f}{v}$ is the corresponding objective function.  The MCD \\emph{coarse-level correction} \\cite{GraeserKornhuber2009,Tai2003} is a function $y$ in $\\mathcal{K}^j=\\{v\\ge \\phi^j\\}$ such that one of the following holds:\n\\begin{itemize}\n\\item general variational inequality:\n\\begin{equation}\n  F(w^J+y^J+\\dots+y^{j+1}+y)[v - y] \\ge 0 \\qquad \\text{for all } v \\text{ in } \\mathcal{K}^j.  \\label{eq:mcdvi}\n\\end{equation}\n\\item constrained minimization:\n\\begin{equation}\n  y = \\argmin_{v \\text{ in } \\mathcal{K}^j} I(w^J+y^J+\\dots+y^{j+1}+v).  \\label{eq:mcdminimization}\n\\end{equation}\n\\item linear variational inequality:\n\\begin{equation}\n  F^j(y)[v - y] \\ge 0 \\qquad \\text{for all } v \\text{ in } \\mathcal{K}^j.   \\label{eq:mcdvilinear}\n\\end{equation}\n\\end{itemize}\nIn the first form $F$ does not need to be linear, and similarly $I$ in the second form does not need to be quadratic.  While these descriptions of the problem define a down-slash cycle (see Figure \\ref{fig:msccycles}), we will show later how to generalize to a V-cycle.  In any case, the goal is to define a a coarse-level correction $y$ in $\\mathcal{K}^j$ for every level in the hierarchy, $j=0,\\dots,J$.\n\nThe third form \\eqref{eq:mcdvilinear} exploits linearity of $F$ to inductively define residual functionals which do not directly refer to the fine-level admissible states $z^j = w^J+y^J+\\dots+y^{j+1}+y$:\n\\begin{align}\n  F^j(y)[\\cdot] &= F(z^j)[\\cdot] \\label{eq:residuallinearlevelderive} \\\\\n                &= a(w^J+y^J+\\dots+y^{j+1}+y,\\cdot) - \\ip{f}{\\cdot} \\notag \\\\\n                &= a(y,\\cdot) + F^{j+1}(y^{j+1})[\\cdot]. \\notag\n\\end{align}\nThat is, we construct each new source term,\n\\begin{equation}\n  \\tilde\\ell^j[\\cdot] = \\begin{cases} - F^{j+1}(y^{j+1})[\\cdot], & j < J, \\\\\n                                      - F(w^J)[\\cdot],   & j = J, \\end{cases} \\label{eq:rhslinearlevel}\n\\end{equation}\nand thereby define a residual functional on each level,\n\\begin{equation}\n  F^j(y)[\\cdot] = a(y,\\cdot) - \\tilde\\ell^j[\\cdot].  \\label{eq:residuallinearlevel}\n\\end{equation}\nHere $F^j$ is actually defined on $\\mathcal{V}^h$, that is, on the whole FE space, and $\\tilde\\ell^j$ is in $(\\mathcal{V}^h)'$.  However, smoothing will occur before each coarse correction, and so we will use the canonical restriction to approximate $\\tilde\\ell^j$ by a linear functional $\\ell^j$ in the coarse-level space $(\\mathcal{V}^j)'$; see \\eqref{eq:restrictedrhslinearlevel} below.\n\nFor the classical obstacle problem, wherein the residual $F(w)[v]$ is built from a symmetric bilinear form $a(w,v)$, the three problems \\eqref{eq:mcdvi}--\\eqref{eq:mcdvilinear} are equivalent:\n   $$\\eqref{eq:mcdvilinear} \\quad \\stackrel{a \\text{ bilinear}}{\\iff\\strut} \\quad \\eqref{eq:mcdvi} \\quad \\stackrel{F=\\grad I}{\\iff\\strut} \\quad \\eqref{eq:mcdminimization}.$$\nThe left equivalence depends on linearity, and the right on symmetry, but VI form \\eqref{eq:mcdvi} in the middle is the most general.  It is the one we will apply for glacier problems.\n\nWhen $F$ is not the gradient of a coercive objective function, e.g.~as in the SIA and Stokes glacier problems, additional structural properties of $F$ are required for well-posedness (e.g.~monotonicity \\cite{Bueler2021conservation,JouvetBueler2012,KinderlehrerStampacchia1980}).  However, we will assume well-posedness and proceed with the numerics.\n\n\\subsection{Linear MCD cycles} \\label{subsec:mcdl}  Now we may implement multilevel cycles for the classical obstacle problem.  Because the interior PDE of this problem is the linear Poisson equation, we solve form \\eqref{eq:mcdvilinear} and name the method \\pr{MCDL}, with L for ``linear''.  A general nonlinear MCD algorithm is applied to glacier problems in section \\ref{sec:sia} and in the second part of the paper \\cite{BuelerMitchell2022}.\n\nWe represent functions and linear functionals in the piecewise-linear spaces $\\mathcal{V}^j$ and $(\\mathcal{V}^j)'$ just as in section \\ref{sec:subspace}.  To address how the correction problem is actually moved onto the coarser level, note that equations \\eqref{eq:rhslinearlevel} and \\eqref{eq:residuallinearlevel} will be applied after smoothing of the previous correction $y^{j+1}$, so we approximate the residual by applying canonical restriction,\n\\begin{equation}\n\\ell^j[\\cdot] = R \\tilde\\ell^j[\\cdot] = \\begin{cases} - R(F^{j+1}(y^{j+1}))[\\cdot], & j < J, \\\\\n                                                      - F(w^J)[\\cdot],   & j = J, \\end{cases} \\label{eq:restrictedrhslinearlevel}\n\\end{equation}\nand then we define $F^j(y)[\\cdot] = a(y,\\cdot) - \\ell^j[\\cdot]$.  In using $\\ell^j$ instead of $\\tilde\\ell^j$ we lose any high-frequency residual information in $y^{j+1}$ which remains after smoothing.\n\nImplementing formulae \\eqref{eq:defectconstraint}, \\eqref{eq:chik}, \\eqref{eq:levelobstacle}, \\eqref{eq:defineKj}, \\eqref{eq:mcdvilinear}, and \\eqref{eq:restrictedrhslinearlevel} produces a V(1,0) down-slash cycle, namely Algorithm 4.7 in \\cite{GraeserKornhuber2009}.\n\nHowever, once all the corrections $y^j$ are computed on the way down, admissible up-smoothing is more forgiving.  For instance, if we have computed $y^1$ in $\\mathcal{K}^1$ and $y^0$ in $\\mathcal{K}^0$ then prolongation and accumulation gives $\\tilde z = P y^0 + y^1$ in $\\mathcal{D}^1 = \\mathcal{K}^0 + \\mathcal{K}^1$, which we may smooth to $z^1$ in $\\mathcal{D}^1$.  In other words, obstacles $\\phi^j$ can be regarded as the down-obstacles while the defect constraints $\\chi^j$ are the up-obstacles; see Figure \\ref{fig:mcdvcycle}.  The observation of this asymmetry permits a better algorithm.  (It also justifies some of the complexity of notation in the previous subsection.)\n\n\\begin{figure}\n\\input{tikz/mcdvcycle.tex}\n\\caption{Going down, \\pr{mcdl-vcycle} computes a correction $y_j$ in $\\mathcal{K}^j = \\{v\\ge \\phi_j\\}$, but its upward-accumulated correction $z_j$ expands into the larger set $\\mathcal{D}^j = \\{v \\ge \\chi_j\\}$.}\n\\label{fig:mcdvcycle}\n\\end{figure}\n\nThe following V-cycle pseudocode uses \\pr{pgs} or \\pr{pjacobi} as the smoother and coarse-level solver.  It takes $F^J$, defined via \\eqref{eq:restrictedrhslinearlevel}, as an argument, and not the original $F$; this V-cycle only knows about the fine-level iterate $w^J$ through $F^J$ and $\\chi^J$.  The result is a fine-level correction $z^J$; see \\pr{mcdl-solver} next.\n\\begin{pseudo*} \\label{ps:mcdl-vcycle}\n\\pr{mcdl-vcycle}(J,a,\\ell^J,\\chi^J,\\id{down}=1,\\id{coarse}=1,\\id{up}=0)\\text{:} \\\\+\n    for $j=J$ downto $j=1$ \\\\+\n      $\\chi^{j-1} = \\mR \\chi^j$ \\qquad\\qquad\\qquad\\qquad \\ct{up-obstacle} \\\\\n      $\\phi^j = \\chi^j - P\\chi^{j-1}$ \\qquad\\qquad\\qquad\\quad \\ct{down-obstacle} \\\\\n      $y^j = 0$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{down}}}(j,y^j,a,\\ell^j,\\phi^j)$ \\qquad\\quad \\ct{in-place smoothing in $\\mathcal{K}^j$} \\\\\n      $F_p = a(y^j,\\psi_p^j) - \\ell^j[\\psi_p^j]$ \\\\\n      $\\ell^{j-1} = - R F$ \\\\-\n    $y^0 = 0$ \\\\\n    $\\text{\\pr{smoother}}^{\\text{\\id{coarse}}}(0,y^0,a,\\ell^0,\\chi^0)$ \\\\\n    $z^0 = y^0$ \\\\\n    for $j=1$ to $j=J$ \\\\+\n      $z^j = P z^{j-1} + y^{j}$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{up}}}(j,z^j,a,\\ell^j,\\chi^j)$ \\qquad\\quad \\ct{in-place smoothing in $\\mathcal{D}^j$} \\\\-\n    return $z^J$\n\\end{pseudo*}\n\nIn agreement with Algorithm 4.7 in \\cite{GraeserKornhuber2009}, the default \\id{down} and \\id{up} settings give a V(1,0) cycle.  However, any V(\\id{down},\\id{up}) cycle is allowed, and we will test V(1,0), V(0,1), and V(1,1)\\footnote{Reference \\cite{GraeserKornhuber2009} describes extending from V(1,0) cycles to V(1,1) cycles by splitting the obstacles $\\phi^j$, but it is not clear how this should be implemented.  In any case, our implementation allows larger coarse-level corrections.} cycles below.  Also, in the implementation the functions $F^j(y)[\\cdot]$ are not passed as functions in the pro\\-gramming-language sense.  Rather, assuming a subroutine which evaluates $a(w,v)$ on each level, the linear functional $\\ell^{j-1}$ is passed, from which $F^{j-1}$ is constructed in the smoother.\n\nThe following in-place solver adds an outer loop which sets-up the fine-level data $\\chi^J$ and $\\ell^J$, calls the V-cycle, and checks for convergence.  Note that one must call this solver with an admissible initial iterate; $w=\\varphi^J$ is one possibility.  Compare \\pr{msc-solver} in section \\ref{sec:subspace}.\n\\begin{pseudo*} \\label{ps:mcdl-solver}\n\\pr{mcdl-solver}(J,w^J,a,f,\\varphi^J,\\id{rtol}=10^{-3},\\id{cyclemax}=100)\\text{:} \\\\+\n    $F(z)[v] := a(z,v) - \\ip{f}{v}$ \\\\\n    $r_0=\\|\\hat\\bF(w^J)\\|$ \\qquad\\qquad\\qquad\\qquad\\qquad \\ct{initial CP residual norm; see \\eqref{eq:cpresidual}} \\\\\n    for $s=1,\\dots,\\id{cyclemax}$ \\\\+\n        $\\chi^J = \\varphi^J - w^J$ \\qquad\\qquad\\qquad\\qquad\\quad \\ct{fine-level defect constraint} \\\\\n        $\\tilde\\ell^J = - F(w^J)$ \\qquad\\qquad\\qquad\\qquad\\qquad \\ct{see \\eqref{eq:restrictedrhslinearlevel}} \\\\\n        $w^J\\gets w^J+\\pr{mcdl-vcycle}(J,a,\\tilde\\ell^J,\\chi^J)$ \\\\\n        if $\\|\\hat\\bF(w^J)\\| \\le \\id{rtol} \\, r_0$ \\\\+\n            break \\\\--\n\\end{pseudo*}\n\n\\subsection{Convergence of the numerical error} \\label{subsec:obstacleconvergence}  All of the pseudocodes in the current section have been implemented in Python.\\footnote{At\\, \\href{https://github.com/bueler/mg-glaciers/}{\\texttt{github.com/bueler/mg-glaciers/}} see the \\texttt{py/1D/} directory and its \\texttt{README.md}.}  To verify these implementations, and to demonstrate the differences in numerical error convergence rates between the obstacle problem and the corresponding unconstrained PDE, we use three exact solutions.  The first two are already shown in Figure \\ref{fig:icelike}; note that the ``ice-like'' case has a discontinuous source $f$, while ``traditional'' has $f=0$, but both have smooth, parabolic obstacles.  The third ``unconstrained'' exact solution is for a variable-coefficient equation $-\\left((2+\\sin(2\\pi x)) u'\\right)'=f$ on the interval $[0,10]$.  (Here the obstacle is low enough so that all points are inactive and all smoothing steps avoid projection.)\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/poisson/convergence.pdf}\n\\caption{MCDL method convergence for three cases with known exact solutions.}\n\\label{fig:convergence}\n\\end{figure}\n\nFigure \\ref{fig:convergence} shows the numerical error norm $\\|u^h-u\\|_2$ as a function of mesh spacing $h$ for runs with \\id{rtol} $=10^{-7}$.  We focus on the convergence rate; the absolute error size is unimportant.  For ``traditional'' it is the best possible, as $O(h^2)$ rate is expected for PDEs \\cite{Elmanetal2014}, as seen here.  The ``ice-like'' rate is poor because of the lower regularity of $f$.  Note that the low regularity of obstacle problem solutions will have a greater effect on 2D or 3D convergence rates.\n\n\\subsection{Performance: results and theory} \\label{subsec:obstacleperformance}  In this section we evaluate the performance of V-cycles computed by our implementation of MCDL.  We will count iterations, measure work units (defined below), and measure run time.  We will conclude that MCDL for the classical obstacle problem is not quite as efficient as GMG for the Poisson equation.  Performance depends weakly on mesh resolution, a result supported by theory, but the performance of MCDL remains far better than single-level approaches.\n\nWe compare the performance of five MCDL solvers:\n\\begin{itemize}\n\\item \\textsf{V(1,0)}: \\id{down} $=1$ and \\id{up} $=0$ in \\pr{mcdl-vcycle}\n\\item \\textsf{V(0,1)}: \\id{down}, \\id{up} $=0,1$\n\\item \\textsf{V(1,1)}: \\id{down}, \\id{up} $=1,1$\n\\item \\textsf{V(0,2)}: \\id{down}, \\id{up} $=0,2$\n\\item \\textsf{V(0,2)-Jacobi}: \\id{down}, \\id{up} $=0,2$, with \\pr{pjacobi} smoothing using \\id{omega} $=0.67$\n\\end{itemize}\nThe first two solvers are down- and up-slash cycles, respectively.  The first four solvers use the default \\pr{pgs} smoother.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/poisson/mcdl-cycles.pdf}\n\\caption{Number of iterations (V-cycles) as a function of $m$.}\n\\label{fig:mcdl-cycles}\n\\end{figure}\n\nWe test these solvers on the ``icelike'' problem shown in Figure \\ref{fig:icelike}, iterating until convergence by the default criterion, \\eqref{eq:cpconvergencecriterion} with \\id{rtol} $=10^{-3}$.  Figure \\ref{fig:mcdl-cycles} shows the number of iterations (cycles) for mesh hierarchies with $J=6,\\dots,15$ refinements, thus $m_J=2^{J+1}-1$ degrees of freedom (nodes) values up to $m_{15}=6.5 \\times 10^4$.  The number of iterations grows slowly in each case, with V(1,1) and V(0,2) tied for the fewest.  As explained when we constructed MCD cycles, the constraints on the up-smoother are less severe than on the down-smoother, and indeed we see that the up-slash V(0,1) cycles are better than down-slash V(1,0).\n\nBy doing logarithmic regression to the data, the Figure shows our result that iterations grow as $O(m^q)$ for $0.10 \\le q \\le 0.12$.  Recalling Theorem \\ref{thm:mscconvergence}, for the Poisson equation this rate would be $O(1) = O(m^0)$ in theory.  When we run our code in an unconstrained case we see that only 5 or 6 V(1,1) cycles are needed for all resolutions, for example (not shown).  Thus more MCDL V-cycles are needed for the obstacle problem than for elliptic PDEs with smooth solutions, and the iterate counts grow slowly with mesh refinement.  This reflects both lower solution regularity and the need to locate the discrete free boundary; we will consider the relevant theory momentarily.\n\nIn terms of relative performance among the solvers, counting iterations is unfair because, for example, one V(1,1) cycle does more work than one V(1,0) or V(0,1).  Thus we compare \\emph{work units} (WU).  By definition, one WU is the amount of computation done by one smoother application on the fine level \\cite{Briggsetal2000}.  Since a $J$th-level smoother sweep is 1 WU, a $J-1$ level sweep is $\\frac{1}{2}$ WU in 1D, and so on geometrically down the hierarchy.  In the limit $J\\to\\infty$, one slash cycle in 1D costs 2 WU,\\footnote{Not counting the work of transfer operators.} by summing the obvious geometric series, and generally a V-cycle costs $O(1)$ WU as a function of $m$.\n\nOur programs count their WU,\\footnote{Our Python implementation has a class for each mesh level.  The mesh hierarchy is a list of such mesh-level objects.  The WU for a level is a class attribute which gets incremented by each smoother sweep.  Computing the total WU at the end of a run is an easy weighted sum.} and Figure \\ref{fig:mcdl-wu} shows the total WU for the same runs.  Just like for iterations, total WU grows as $O(m^q)$ for $0.10 \\le q \\le 0.12$, but we now see that the \\pr{pgs}-based cycles are all comparable, and much stronger than the \\pr{pjacobi} cycles.  However, Jacobi smoothing will remain significant in our applications to glacier problems \\cite{BuelerMitchell2022}.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/poisson/mcdl-wu.pdf}\n\\caption{Number of work units (WU) as a function of $m$.  The \\pr{pgs} smoother is clearly more efficient.}\n\\label{fig:mcdl-wu}\n\\end{figure}\n\nOn the other hand, these MCDL growth rates for work are excellent compared to application of the smoother by itself as a single-level method.  Though most runs in the Figure are unattainable by such a single-level method, we find that 6802, 26986, and 108562 iterations, equivalently WU, are required on the three coarsest resolutions ($J=6,7,8$), respectively, a catastrophic growth rate of $O(m^{1.99})$.  This growth rate is also well-supported by theory; see below.\n% for JJ in 6 7 8; do ./obstacle.py -cyclemax 200000 -sweepsonly -jfine $JJ; done\n\nFinally we look at the time per degree of freedom.  This quantity should be constant, $O(1)=O(m^0)$ for an optimal method.  Figure \\ref{fig:mcdl-timeper} shows the results for the finer $J=9,\\dots,15$ meshes.  Fitting only to the five finest results, because timing for smaller runs is dominated by Python executable start-up costs, the time-per-$m$ is $O(m^r)$ for $0.01 \\le r \\le 0.05$, so mesh dependence is very modest.  Our \\pr{pgs} solvers all require less than 1 millisecond per degree of freedom.  Though this value depends completely on the details of our Python implementation, and on the particular computer, it can be compared to the more expensive computations for the glacier problems in section \\ref{sec:sia} and in the second part of the paper \\cite{BuelerMitchell2022}.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/poisson/mcdl-timeper.pdf}\n\\caption{Run time per degrees of freedom $m$ as a function of $m$.}\n\\label{fig:mcdl-timeper}\n\\end{figure}\n\nMathematical theory allows us to understand most of the above performance results.   Denote the spacing of the fine ($J$th) mesh by $h$.  Let $u^h$ be the exact solution of the finite-dimensional VI which is the direct FE approximation of \\eqref{eq:obstacleviresidual}:\n\\begin{equation}\n  F(u^h)[v-u^h] \\ge 0 \\quad \\text{ for all } v \\text{ in $\\mathcal{V}^h=\\mathcal{V}^J$ such that } v \\ge \\varphi^J. \\label{eq:feobstaclevioriginal}\n\\end{equation}\n(Compare \\eqref{eq:feobstacleviresidual} which we solve on each level in MCD.)  Also recall that for the classical obstacle problem the residual is the gradient of an objective function $I(w)$.\n\nFirst consider the single-level PGS method.  The following theorem describes the rate at which the norm of the algebraic error decreases.\n\n\\begin{theorem} \\cite[Prop.~4.5]{GraeserKornhuber2009}\\,  \\label{thm:pgsconvergence}  Suppose $w^{(s)}$  results from $s$ applications of \\pr{pgs-sweep} on the fine level, starting with any $w^{(0)}$.  There is $C>0$, independent of $h$ and $s$, so that\n\\begin{equation}\n  \\|w^{(s)} - u^h\\|_{\\mathcal{H}}^2 \\le 2 (1-C h^2)^s\\,\\left(I(w^{(0)}) - I(u^h)\\right).  \\label{eq:pgsconvergence}\n\\end{equation}\n\\end{theorem}\n\nInequality \\eqref{eq:pgsconvergence} compares the algebraic error norm of an iterate to the initial objective error.  While the right-hand side looks complicated, the only $s$ dependence is the power on the factor $\\rho_{\\text{PGS}} = \\sqrt{1-Ch^2}$.  The theorem says that the rate at which $\\|w^{(s)} - u^h\\|_{\\mathcal{H}}$ goes to zero, as $s\\to \\infty$, is $O((\\rho_{\\text{PGS}})^s)$.  However, as we refine the mesh, $h\\to 0$, the value of $\\rho_{\\text{PGS}} = 1 - O(h^2)$ goes to one so that the iteration becomes stagnant.  (In MCDL we are using PGS as a coarse solver, an application in which the convergence rate should still be good.)  If we seek to reduce the error norm below $\\eps$ then we expect to need $O(|\\log\\eps|/h^2)$ iterations, a number which increases rapidly as $h\\to 0$.\n\nFor MCD methods an error bound with a far superior rate has been proven by Tai \\cite{Tai2003}.  For our 1D classical obstacle problem, as proven in \\cite[section 5.4]{Tai2003}, using inequality (4.13) of \\cite{GraeserKornhuber2009} to give a form comparable to Theorem \\ref{thm:pgsconvergence}, the result is as follows.\n\n\\begin{theorem} \\label{thm:mcdconvergence}  Suppose $s$ applications of \\pr{mcdl-vcycle}, using $J$ levels in the mesh hierarchy, yields $w^{(s)}$.  There are positive constants $c_0$, $c_1$, independent of $h$ and $J$ and $s$, so that\n\\begin{equation}\n  \\|w^{(s)} - u^h\\|_{\\mathcal{H}}^2 \\le 2 \\left(1-\\frac{c_0}{1+c_1 J}\\right)^s\\,\\left(I(w^{(0)}) - I(u^h)\\right).  \\label{eq:mcdconvergence}\n\\end{equation}\n\\end{theorem}\n\nRecalling our observation (section \\ref{sec:subspace}) that $J = O(|\\log h|)$, the MCD convergence rate\n\\begin{equation}\n  \\rho_{\\text{MCD}} = 1-\\frac{c_0}{1+c_1 J}  = 1 - O(J^{-1}) = 1 - O(|\\log h|^{-1}) \\label{eq:definemcdrate}\n\\end{equation}\nis of completely-different character from $\\rho_{\\text{PGS}}$.  While $\\rho_{\\text{MCD}}$ still goes to one in the mesh refinement limit ($h \\to 0$), it does so very slowly.  That is, instead of having the convergence rate degrade directly with the mesh spacing, it \\emph{determined by the number of levels} in the mesh hierarchy.\n\nWe now have three comparable convergence theorems, namely Theorems \\ref{thm:mscconvergence}, \\ref{thm:pgsconvergence}, and \\ref{thm:mcdconvergence}.  They form a theoretical performance-model framework for the respective solvers, as summarized by Table \\ref{tab:performancemodels}.  Only \\pr{gmg-vcycle} is strictly optimal $O(m)$, but of course it only solves unconstrained PDE problems.  The observed modestly-suboptimal MCDL performance, basically $O(m^{1.1})$ as shown in Figures \\ref{fig:mcdl-cycles}--\\ref{fig:mcdl-timeper}, is completely compatible with the theoretical $O(m\\log m)$ model.\n\n\\newcommand{\\loge}{|\\!\\log\\eps|}\n\\begin{table}[ht]\n\\begin{tabular}{l|ccc}\n\\emph{method}    & \\emph{rate} $\\rho$ & \\emph{iterations}  & \\emph{work (flops)} \\\\ \\hline\n\\pr{pgs}         & $1-O(h^2)$         & $m^2\\, \\loge$    & $m^3\\, \\loge$ \\\\\n\\pr{mcdl-vcycle} & \\quad $1-O(|\\!\\log h|))$ \\quad & \\quad $\\log m\\, \\loge$ \\quad & \\quad $m \\log m\\, \\loge$ \\\\\n\\pr{gmg-vcycle}  & $1-O(1)$           & $\\loge$          & $m\\, \\loge$\n\\end{tabular}\n\n\\medskip\n\\caption{Theoretical performance as $h\\to 0$ and $m=m_J\\to\\infty$, for algebraic error norm reduction by $\\eps$.  Iterations and work are in the $O(\\cdot)$ sense.}\n\\label{tab:performancemodels}  % \\label must be last for correct reference\n\\end{table}\n\nMCD convergence Theorem \\ref{thm:mcdconvergence} actually applies to certain nonlinear VI problems.  However, the proof requires a constrained-minimization formulation and a uniform-ellipticity bound \\cite{Tai2003}, and the glacier problems in section \\ref{sec:sia} and in \\cite{BuelerMitchell2022} satisfy neither hypothesis.  In this paper we will not pursue the theory further, but we will measure the performance of our MCD approaches on glacier problems.  Our standing assumption is that MCDL performance for the 1D classical obstacle problem represents the best-possible result.\n\n\\subsection{Nested iteration} \\label{subsec:obstaclefcycles}  We must consider a technique which can substantially-improve multilevel performance.  In \\emph{nested iteration} \\cite{Trottenbergetal2001} an initial iterate comes from prolonging a converged iterate from a coarser mesh.  If we then solve on each level by V-cycles then the resulting \\emph{full multigrid} method does an \\emph{F-cycle} (Figure \\ref{fig:fcycle}).  That is, an F-cycle results from concatenating V-cycles using the solution prolongation.  Note that while a correction $y^{j-1}$ is prolonged in a V-cycle, now we also need to prolong the iterate $w^{j-1}$ itself, and the result needs to be admissible.\n\n\\begin{figure}\n\\input{tikz/fcycle.tex}\n\\caption{An F-cycle prepends shallower V-cycles, with a new prolongation $\\hat P$ (double lines) generating the initial iterate on each starting level.}\n\\label{fig:fcycle}\n\\end{figure}\n\nThough $w^{j-1} \\ge \\varphi^{j-1}$ is admissible on its level, the information in the finer obstacle $\\varphi^j$ has not yet been ``seen'', so truncation is obligatory for admissibility, and we define \\emph{solution prolongation} using canonical prolongation \\eqref{eq:canonicalprolongation} and truncation:\n\\begin{equation}\n\\hat P w^{j-1} = \\max\\{P w^{j-1}, \\varphi^{j}\\}  \\label{eq:solutionprolongation}\n\\end{equation}\nAfter creating this initial iterate we do one or more V-cycles.  The following pseudocode implements this strategy.  Note there is no convergence criterion; the number of cycles is fixed.\n\\begin{pseudo*} \\label{ps:mcdl-fcycle}\n\\pr{mcdl-fcycle}(J,w^0,a,f,\\varphi,\\id{nicycles}=1)\\text{:} \\\\+\n    $\\varphi^0 = \\ct{interpolant of $\\varphi$}$ \\\\\n    for $j=0,\\dots,J$ \\\\+\n        $\\ell^j[\\cdot] := \\ip{f}{\\cdot}$ \\\\\n        for $s=1,\\dots,\\id{nicycles}$ \\qquad\\qquad\\qquad \\ct{one or more V-cycles} \\\\+\n            $\\chi^j = \\varphi^j - w^j$ \\\\\n            $w^j \\gets w^j+\\pr{mcdl-vcycle}(j,a,\\ell^j,\\chi^j)$ \\\\-\n        if $j < J$ \\\\+\n            $\\varphi^{j+1} = \\ct{interpolant of $\\varphi$}$ \\\\\n            $w^{j+1} = \\hat P w^j$ \\qquad\\qquad\\qquad\\qquad \\ct{initial iterate for next level} \\\\--\n    return $w^J$\n\\end{pseudo*}\nNote that the input $w^0$ could be $\\varphi^0$ or any other admissible iterate on the coarsest level.  Also observe that when \\pr{mcdl-vcycle} is called on the coarsest level it reduces to the coarse solver.\n\nFor PDEs one F-cycle often suffices to reach discretization error \\cite{Trottenbergetal2001}.  However, because obstacle problem solutions have lower regularity, and because multilevel cycles are required to both remove low frequencies from the error \\emph{and} find the discrete free boundary, performance is lower, as we will see.  In practice, the F-cycle can generate an initial fine-level iterate, but application of additional V-cycles, i.e.~of \\pr{mcdl-solver}, is needed to converge according to a residual (or error) norm tolerance.\n\nTo show MCDL F-cycles in the best light, consider the ``traditional'' exact solution shown in Figure \\ref{fig:icelike}.  By using a tight tolerance (\\id{rtol} $=10^{-7}$) and as many V(1,1) cycles as necessary, we first compute the discretization error for this problem on meshes with $J=2,\\dots,12$ (stars in Figure \\ref{fig:perfni}).  Now we run \\pr{mcdl-fcycle} with its defaults, with one V(1,1) cycle per level, and then with two (\\id{nicycles} $=2$).  Note these F-cycles are very fast, with $J\\to\\infty$ asymptotic WU values of 8 and 16, respectively.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/poisson/perfni.pdf}\n\\caption{For the classical obstacle problem, F-cycles with one or two V(1,1) cycles per level do not attain discretization error.}\n\\label{fig:perfni}\n\\end{figure}\n\nHowever, the corresponding figure for an unconstrained problem shows that the F-cycles yield error norms within a factor of two of discretization error (not shown).  That is, in the PDE case the markers are on top of each other for all mesh levels.  Classical obstacle problem F-cycles do generate small errors, especially given the amount of work, but our results here are qualitatively-worse than for the unconstrained Poisson equation.  Furthermore, F-cycle performance on the ``ice-like'' exact obstacle problem solution (Figure \\ref{fig:icelike}), which has lower regularity than ``traditional'', is both worse and less consistent (not shown).  The F-cycle solution can be ``lucky'', or not, when locating the free boundary on coarser levels, and this dominates the fine-level discretization error from one F-cycle.  In summary, nested iterations (F-cycles) are likely to be a useful tool, but they are not as miraculous as expected from smooth PDE cases.\n\nMany variations on V- and F-cycle strategies have not been tested in this section.  Most significantly, reference \\cite{GraeserKornhuber2009} describes monotone, truncated, and Newton-based multigrid methods for obstacle problems which extend the MCD method.  These methods improve performance for the classical problem when the coincidence set (active set) is geometrically complicated, but they require greater implementation effort, essentially because they keep track of the discrete active set.  There is also the discrete complementarity-problem ``PFAS'' method of \\cite{BrandtCryer1983} (see below), while \\cite{Blumetal2004} proposes a ``cascadic'' approach with a conjugate-gradient smoother.\n\n\n\\section{MCD for the shallow-ice geometry problem} \\label{sec:sia}\n\n\\subsection{The shallow-ice obstacle problem} \\label{subsec:siaproblem}  Now we consider a nonlinear obstacle problem which is a model for ice sheets and glaciers, namely the steady and isothermal shallow-ice approximation (SIA)  \\cite{Bueleretal2005,Huybrechtsetal1996,vanderVeen2013}.  We first present the strong form, a nonlinear complementarity problem (CP), and then derive the weak form, a nonlinear variational inequality (VI).\n\nStarting with the data and parameters, we are given a signed \\emph{surface mass balance} function $a(x)$, of size roughly $O(1)$ meters per year, and a \\emph{bed elevation} (topography) function $b(x)$ in meters above sea level, and both are assumed to be time-independent.  Let $n>1$ be the (Glen) power, $\\rhoi$ the ice density, and $g$ the acceleration of gravity.  Assuming isothermal conditions \\cite{GreveBlatter2009}, let $A$ be the (constant) ice softness.\\footnote{The values used in experiments are from \\cite{Huybrechtsetal1996}: $n=3$, $\\rhoi=910 \\,\\text{kg}\\,\\text{m}^{-3}$, $g=9.81 \\,\\text{m}\\,\\text{s}^{-2}$, and $A=10^{-16} \\,\\text{Pa}^n\\,\\text{a}^{-1}$.}  These parameters combine into a positive constant $\\Gamma = 2 A (\\rhoi g)^n / (n+2)$.\n\nThe one-dimensional SIA equation determines the \\emph{ice surface elevation} $s(x)$, also in meters above sea level, on the part of the domain where $s>b$:\n\\begin{equation}\n- \\left(\\Gamma (s-b)^{n+2} |s'|^{n-1} s'\\right)' = a.  \\label{eq:sia}\n\\end{equation}\nNote that $q = -\\Gamma (s-b)^{n+2} |s'|^{n-1} s'$ is the \\emph{ice flux}; the equation is a conservation law for $q$.  However, as in section \\ref{sec:obstacle}, this equation should be understood as a CP:\n\\begin{align}\ns - b &\\ge 0, \\label{eq:siacp} \\\\\n- \\left(\\Gamma (s-b)^{n+2} |s'|^{n-1} s'\\right)' - a &\\ge 0 \\notag \\\\\n(s-b) \\left[-\\left(\\Gamma (s-b)^{n+2} |s'|^{n-1} s'\\right)' - a\\right] &= 0 \\notag\n\\end{align}\nSimilar to \\eqref{eq:obstaclecp}, this applies on a fixed interval $[0,L]$, a superset of the glaciated area, with $L$ of order $O(10)$ to $O(1000)$ kilometers.  The data $a(x)$, $b(x)$ are defined on this entire interval.\n\nThe weak form of \\eqref{eq:siacp} requires a choice of appropriate function spaces.  For this choice it helps to refer to a simpler and better-understood, but still nonlinear, problem.  Let $\\pp=n+1>2$ and consider the $\\pp$-\\emph{Laplacian equation} \\cite{Ciarlet2002,DiBenedetto2012}.  The solution and test functions live in the Sobolev space of functions with zero boundary values and $L^\\pp$-integrable first derivatives:\n\\begin{equation}\n\\mathcal{W} = W_0^{1,\\pp}[0,L]  \\label{eq:defineW}\n\\end{equation}\nThe strong form of the equation is $-(|u'|^{\\pp-2} u')' = f$ and the weak form is\n\\begin{equation}\n\\int_0^L |u'|^{\\pp-2} u' v'\\,dx = \\int_0^L f v\\,dx \\text{ for all $v$ in $\\mathcal{W}$.}  \\label{eq:plaplacianpoisson}\n\\end{equation}\nEquation \\eqref{eq:plaplacianpoisson} is relatively well-understood because the calculus of variations can be applied; see \\cite[section 5.3]{Ciarlet2002} and \\cite{BarrettLiu1993}.  The corresponding obstacle problem for $\\varphi$ in $\\mathcal{W}$ is also well-behaved \\cite{ChoeLewis1991}.  A unique solution $u$ in $\\mathcal{W}$ exists as long as the source $f$ defines a bounded linear functional on $\\mathcal{W}$, for which it suffices that $f$ is in $L^\\qq[0,L]$, for $\\pp^{-1}+\\qq^{-1}=1$, and if the obstacle is in $\\mathcal{W}$.  Note that in the $\\pp>2$ case, corresponding to shear-thinning ice ($n>1$), the $\\pp$-Laplacian operator is \\emph{degenerate} \\cite{DiBenedetto2012} in the sense that $|u'|^{\\pp-2}$ may go to zero.\n\nReturning to the SIA model, assume that $a$ is in $L^\\qq[0,L]$ and $b$ is in $\\mathcal{W}$, including $b(0)=b(L)=0$.  Tentatively we seek a solution $s$ from the admissible set\n\\begin{equation}\n\\mathcal{K}_b = \\left\\{v \\ge b\\right\\} \\subset \\mathcal{W}.  \\label{eq:siaK}\n\\end{equation}\nNow assume $s$ is a well-behaved solution to CP \\eqref{eq:siacp}, multiply \\eqref{eq:sia} by a test function $v$ from $\\mathcal{K}_b$, and integrate by parts.  A nonlinear operator $N:\\mathcal{K}_b \\to \\mathcal{W}'$ appears, namely\n\\begin{equation}\nN(s)[v] = \\int_0^L \\Gamma (s-b)^{\\pp+1} |s'|^{\\pp-2} s' v'\\,dx. \\label{eq:siaNunreg}\n\\end{equation}\n(Regarding the powers, note $n+2=\\pp+1$ and $n-1=\\pp-2$.)  Then by application of the CP we derive our tentative weak form, the nonlinear VI\n\\begin{equation}\nN(s)[v-s] \\ge \\ip{a}{v-s}, \\label{eq:siaVIunreg}\n\\end{equation}\nwhere $\\ip{a}{v} = \\int_0^L a(x) v(x)\\,dx$ is the usual inner product (i.e.~dual pairing \\cite{KinderlehrerStampacchia1980}).\n\nWhy is this at all ``tentative''?  It turns out that the correct function space for \\eqref{eq:siaVIunreg} has not been identified, and actually $\\mathcal{W}$ is inadequate.  This unfortunate situation, which we will not be able to fully resolve, requires some clarification.  Whether written in strong form \\eqref{eq:siacp} or weak form \\eqref{eq:siaVIunreg}, the SIA equation has a well-known ``double nonlinearity'' \\cite{Calvoetal2002}.  As a nonlinear elliptic equation, it has both porous medium \\cite{Evans2010} and $\\pp$-Laplacian types. The SIA operator \\eqref{eq:siaNunreg} does not uniformly act like the $\\pp$-Laplacian because the coefficient $(s-b)^{\\pp+1}$ can degenerate to zero.\n\nLet $H=s-b$ be the \\emph{ice thickness}.  The inequality constraint $s\\ge b$ could be stated as the nonnegativity of thickness, $H\\ge 0$, with the zero function as the obstacle, and the SIA model is often stated this \\cite{Bueler2016,JouvetBueler2012}; see also \\cite{Bueler2021conservation}.  Because the nonlinear form $N(s)$ is doubly-degenerate, when either $H$ goes to zero or the surface slope $|s'|$ goes to zero there is a loss of ellipticity.  It follows that we do not expect the solution $s$ to \\eqref{eq:siaVIunreg} to be in the Sobolev space $\\mathcal{W}$.\n\nFor example, consider the flat-bed exact solution in Figure \\ref{fig:siadatafigure}.  (See section 5.6.3 of \\cite{GreveBlatter2009} or section 5.3 of \\cite{vanderVeen2013} for specific formulas.)  The continuous surface mass balance function $a(x)$ has negative values towards either end of the interval; compare Figure \\ref{fig:icelike}.  This generates a free boundary, an ablation-caused \\emph{glacier margin}, where the gradient is singular.  While $s(x)$ exactly solves \\eqref{eq:sia} on $s>0$, at the margin $s \\to 0$ and also the ice flux goes to zero, $q \\to 0$.  But $s(x)$ is \\emph{not} in $\\mathcal{W}$ because its margin shape goes like $s(x) \\sim |x-x_m|^{1/2}$ if $x_m$ is the position of the margin \\cite{Bueleretal2005}.  (In the case shown, exact margin positions are $x_m=900\\pm 750$ km.)  This shows VI \\eqref{eq:siaVIunreg} cannot be the correct weak form as stated.\n\n\\begin{figure}\n\\includegraphics[width=0.65\\textwidth]{fixfigs/siadatafigure.pdf}\n\\caption{\\emph{Top:} An exact solution $s(x)$ for a flat-bed ($b=0$) ice sheet.  \\emph{Bottom:} The corresponding surface mass balance rate $a(x)$.}\n\\label{fig:siadatafigure}\n\\end{figure}\n\nOn the other hand, a weak solution of \\eqref{eq:siaVIunreg} is known to exist in the sense that a power of the thickness, namely $u=H^{(2n+2)/n}$, is in $\\mathcal{W}$ \\cite{JouvetBueler2012}.  When $b=0$ the solution is unique, but in general uniqueness has not been established.  Unfortunately this transformed-thickness theory requires an awkward expression for the VI in the general-bed case.\n\nAt this point we are motivated to rescue weak form \\eqref{eq:siaVIunreg}, stated in terms of the surface elevation, for two reasons:\n\\begin{enumerate}\n\\item Because the ice acts as a viscous fluid at scales of $O(10)$ meters and larger, the surface elevation $s$ of a real glacier or ice sheet is relatively smooth compared to the bed elevation $b$.  Crevassing and other non-fluid surface effects like sastrugi are small in amplitude compared to bed elevation variations.  Figure \\ref{fig:giscross} shows a typical cross-section of the Greenland ice sheet.\\footnote{Figure help from A.~Aschwanden.  Note approximately $100\\times$ vertical exaggeration.  Data downloaded 4/2021 from BedMachine (\\href{https://nsidc.org/data/IDBMG4/versions/3}{\\texttt{nsidc.org/data/IDBMG4/versions/3}}) \\cite{Morlighemetal2017}.}  While the bed elevation is full of high frequencies, reflecting ice-buried fjord topography, which also generates noisy thickness $H=s-b$, the surface is smoothed by the flow of the ice.  Clearly, we prefer to apply smoothers and transfer operators to $s$, not $H$.\n\\item The key geometry-evolution equation of the Stokes model in the second part of the paper \\cite{BuelerMitchell2022} is the \\emph{surface kinematical equation} (SKE) \\cite{GreveBlatter2009}, which is also stated in terms of $s$.  On the other hand, the momentum balance equation in the Stokes model permits no practical thickness-based formulation.\n\\end{enumerate}\n\n\\begin{figure}\n\\includegraphics[width=0.8\\textwidth]{genfigs/giscross.pdf}\n\\caption{\\emph{Top.}  Cross-section of the Greenland ice sheet at $70^\\circ$N latitude, showing surface $s$ and bed $b$.  \\emph{Bottom.} The corresponding thickness $H=s-b$.  \\emph{Inset.} Location of transect.}\n\\label{fig:giscross}\n\\end{figure}\n\nWith these considerations in mind we propose the following regularization of \\eqref{eq:siaNunreg} and \\eqref{eq:siaVIunreg}, from which we will conjecture a well-posedness theory for the SIA.  Let $\\eps \\ge 0$ be a small reference thickness.  Define $N_\\eps:\\mathcal{K}_b \\to \\mathcal{W}'$ by\n\\begin{equation}\nN_\\eps(s)[v] = \\int_0^L \\Gamma (s-b+\\eps)^{\\pp+1} |s'|^{\\pp-2} s' v'\\,dx. \\label{eq:siaN}\n\\end{equation}\nWe say $s$ in $\\mathcal{K}_b \\subset \\mathcal{W}$ \\emph{solves the regularized SIA weak form} if it satisfies the corresponding nonlinear VI\n\\begin{equation}\nN_\\eps(s)[v-s] \\ge \\ip{a}{v-s} \\label{eq:siaVI}\n\\end{equation}\nfor all $v$ in $\\mathcal{K}_b$.  For each $\\eps>0$ there should be a solution $s_\\eps$ in $\\mathcal{W}$, to \\eqref{eq:siaVI}, perhaps unique in some circumstances.  We suppose that existence would be proved by a uniform-ellipticity argument relative to the corresponding $\\pp$-Laplacian problem, but we do not expect the $\\eps\\to 0$ limit of $s_\\eps$ to be in $\\mathcal{W}$.  (In fact, the above exact solution is a case where $\\|s_\\eps\\|_{\\mathcal{W}} \\to \\infty$ as $\\eps\\to 0$, even though $\\|N_\\eps(s)\\|_{\\mathcal{W}'}$ has a finite limit.)  However, we expect that a limit $s(x)$ exists in the sense that $\\|s_\\eps-s\\|_{L^\\pp}$ goes to zero, and pointwise.  This conjectured situation is consistent with all available numerical evidence, but we make no attempt to prove well-posedness by this or any other strategy.\n\nBy defining $F_\\eps(s)[v] = N_\\eps(s)[v] - \\ip{a}{v}$, the nonlinear VI \\eqref{eq:siaVI} takes the form\n\\begin{equation}\nF_\\eps(s)[v-s] \\ge 0 \\quad \\text{for all } v \\text{ in } \\mathcal{K}_b, \\label{eq:siaVIresidual}\n\\end{equation}\nthe same as the classical obstacle problem VI \\eqref{eq:obstacleviresidual}.  Regarding the intuition behind \\eqref{eq:siaVIresidual}, see Figure \\ref{fig:cartoonplane} and the accompanying text.  For general bed elevation data $b(x)$, note that the $F_\\eps$ in \\eqref{eq:siaVIresidual} is \\emph{not} the gradient of a scalar objective functional.\n\nIn our numerical results below we generally set $\\eps=0$.  Thus the regularization is helpful in theory but not needed in practice.\n\n\\subsection{Nonlinear MCD cycles} \\label{subsec:mcdn}  Next we apply a nonlinear form of the MCD method to the steady SIA VI problem \\eqref{eq:siaVI}.  This follows a well-known multilevel strategy for nonlinear PDEs, the \\emph{full approximation storage} (FAS) scheme  \\cite{Briggsetal2000,Trottenbergetal2001}, as it extends the MCDL method of section \\ref{sec:obstacle} to nonlinear operators.  We believe that the resulting MCDN method reduces implementation complexity relative to methods which track the inactive set \\cite{Bueler2016,Jouvetetal2013,JouvetGraeser2013}, and it leads to robust and scalable numerical solutions when efficient smoothers are available.\n\nSuppose our fine-level FE space is $\\mathcal{V}^J \\subset \\mathcal{W}$, the space of continuous piecewise-linear functions with zero boundary values, based on $J$ levels of refinement as before.  Suppose $b^J$ in $\\mathcal{V}^J$ is the fine-level interpolant of the continuum bed $b$.  Assume $s$ in $\\mathcal{W}$ solves \\eqref{eq:siaVI} or \\eqref{eq:siaVIresidual}, for some $\\eps>0$, and assume that our given iterate $w^J\\approx s$, with $w^J$ in $\\mathcal{V}^J$, is admissible in the sense that $w^J \\ge b^J$.  As in section \\ref{sec:obstacle}, we define the fine-level defect constraint:\n    $$\\chi^J = b^J - w^J, \\qquad \\mathcal{D}^J = \\{v\\ge \\chi^J\\} \\subset \\mathcal{V}^J.$$\n(Recall that a perturbed iterate is admissible, $w^J + z^J \\ge b^J$, if and only if the perturbation $z^J$ is in $\\mathcal{D}^J$.)  Let $N^J$ be an FE approximation of the nonlinear operator $N_\\eps$ in \\eqref{eq:siaN}, but note that the detailed construction of $N^J$ occurs in the next subsection \\ref{subsec:Ndiscretization}.  Let $\\ell^J[v] = \\ip{a}{v}$.  Our goal is to solve the fine-level FE version of VI \\eqref{eq:siaVI} for an admissible perturbation $z^J$ in $\\mathcal{D}^J$,\n\\begin{equation}\nN^J(w^J+z^J)[v-z^J] \\ge \\ell^J[v-z^J] \\quad \\text{for all $v$ in $\\mathcal{D}^J$.} \\label{eq:siaVIFEfinelevel}\n\\end{equation}\nHere $s^J=w^J+z^J$ is the desired surface elevation result, so the argument $v - z^J = (w^J+v)-s^J$ is a difference of admissible surface elevations.\n\nFinite-dimensional nonlinear VI \\eqref{eq:siaVIFEfinelevel} suffices when applying a single-level method.  However, for a multi-level method we need the fundamental MCD idea from section \\ref{sec:obstacle}.  That is, we split the fine-level correction $z^J$ into admissible parts by decomposing the defect constraint set.  Recalling $\\mR$ denotes the monotone restriction operator \\eqref{eq:monotonerestriction} (Table \\ref{tab:transfers}), for $j=1,\\dots,J$ let\n    $$\\chi^{j-1} = \\mR \\chi^j, \\qquad \\phi^j = \\chi^j - \\chi^{j-1},$$\nand define $\\chi^{-1}=0$ so that $\\phi^0=\\chi^0$.  (This is the same as for MCDL.  Note that the telescoping-sum decomposition \\eqref{eq:telescopingdecomposition} holds.)  For $j=0,\\dots,J$ let\n    $$\\mathcal{D}^j = \\{v \\ge \\chi^j\\}, \\qquad \\mathcal{K}^j = \\{v \\ge \\phi^j\\}$$\nbe the up- and down-admissible subsets of $\\mathcal{V}^j$, respectively.  As before, $\\mathcal{D}^j = \\sum_{k=0}^j \\mathcal{K}^k$ for any $j$, and in fact Figure \\ref{fig:gooddecomposition} visualizes the decomposition here if $\\varphi^J$ is replaced by $b^J$.\n\nSuppose we already have admissible perturbations of $w^J$ down to the $j+1$ level which \\emph{approximately} satisfy \\eqref{eq:siaVIFEfinelevel}.  That is, suppose $y^{j+1},\\dots,y^J$ in $\\mathcal{K}^{j+1},\\dots,\\mathcal{K}^J$ have been computed, using smoothers (as described next in subsection \\ref{subsec:pngs}), so that $z^{j+1}=y^{j+1}+\\dots+y^J$ approximately solves \\eqref{eq:siaVIFEfinelevel}.  We now seek a next-coarser-level correction $y$ in $\\mathcal{K}^j$ so that\n\\begin{equation}\nN^{j+1}(w^J+z^{j+1}+y)[v-y] \\ge \\ell^{j+1}[v-y] \\label{eq:siaVIFEprecoarseone}\n\\end{equation}\nfor all $v$ in $\\mathcal{K}^j$.  (The source $\\ell^{j+1}$ is defined later, but note $\\ell^J[v] = \\ip{a}{v}$ on the finest level.)  Subtract $N^{j+1}(w^J+z^{j+1})$ from both sides of \\eqref{eq:siaVIFEprecoarseone} gives\n\\begin{equation}\nN^{j+1}(w^J+z^{j+1}+y)[v-y] - N^{j+1}(w^J+z^{j+1})[v-y] \\ge - \\tilde F^{j+1}[v-y], \\label{eq:siaVIFEprecoarsetwo}\n\\end{equation}\nwhere we define the resulting residual as\n\\begin{equation}\n\\tilde F^{j+1}[v] = N^{j+1}(w^J+z^{j+1})[v] - \\ell^{j+1}[v].\n\\end{equation}\n\nThe effect of the smoothers on the $J$ down to $j+1$ levels should be to make $\\tilde F^{j+1}$ smooth in a CP residual \\eqref{eq:cpresidual} sense, and thus VI \\eqref{eq:siaVIFEprecoarsetwo} should be accurately-representable on the $j$th level.  In fact we will approximate it using the $j$th-level basis $\\{\\psi_p^j\\}$.  To do this we define \\emph{injection restriction} $\\iR:\\mathcal{V}^{j+1} \\to \\mathcal{V}^j$ (Table \\ref{tab:transfers}), which simply keeps the values of the solution at the coarse-level nodes and discards the fine-level nodes in between:\n\\begin{equation}\n  (\\iR v)_p = v_{2p}, \\label{eq:injectionrestriction}\n\\end{equation}\nfor $p=1,\\dots,m_j$.  Note that $\\iR$ preserves admissibility relative to the interpolated bed elevation data on each level: $v\\ge b^{j+1} \\implies \\iR v \\ge b^j$.  Next we define $g^j$ as the latest $j$th-level approximation to the solution $s$:\n\\begin{equation}\ng^j = \\begin{cases} w^J, & j=J \\\\\n                    \\iR(g^{j+1} + y^{j+1}), & j < J.\n      \\end{cases}  \\label{eq:siag}\n\\end{equation}\nThat is, $g^j$ is our estimate of the solution on the $j$th level, before we add a correction which solves the $j$th-level VI.\n\nWe can now be completely precise about the $j$th-level VI.  Given the next-finer correction $y^{j+1}$, and using \\eqref{eq:siag} to define $g^j$ from $g^{j+1}$, let\n\\begin{equation}\n\\ell^j[v] = \\begin{cases} \\ip{a}{v}, & j=J \\\\\n                          N^j(g^j)[v] - R \\left(N^{j+1}(g^{j+1}+y^{j+1}) - \\ell^{j+1}\\right)[v], & j < J,\n            \\end{cases}  \\label{eq:siaell}\n\\end{equation}\na definition which uses canonical restriction $R$ (Table \\ref{tab:transfers}).  Note that a source term just like $\\ell^j$ appears in standard FAS schemes for PDEs \\cite{Trottenbergetal2001}.  From \\eqref{eq:siaVIFEprecoarsetwo}, our $j$th-level correction VI is\n\\begin{equation}\nN^j(g^j+y)[v-y^j] - N^j(g^j)[v-y^j] \\ge - R \\left(N^{j+1}(g^{j+1}+y^{j+1}) - \\ell^{j+1}\\right)[v-y^j]. \\label{eq:siaVIFEFASearly}\n\\end{equation}\nWe can clean-up the appearance by collecting known terms on the right and using definition \\eqref{eq:siaell}; we seek a correction $y^j$ in $\\mathcal{K}^j$ so that\n\\begin{equation}\nN^j(g^j+y^j)[v-y^j] \\ge \\ell^j[v-y^j] \\quad \\text{for all $v$ in $\\mathcal{K}^j$.} \\label{eq:siaVIFEFAS}\n\\end{equation}\n\nFrom \\eqref{eq:siag}, \\eqref{eq:siaell}, and \\eqref{eq:siaVIFEFAS} we can construct a V-cycle comparable to \\pr{mcdl-vcycle} in section \\ref{sec:obstacle}.  On descent we look for corrections $y^j$ from the down-admissible sets $\\mathcal{K}^j$, but going upward we allow corrections $z^j$ from the larger sets $\\mathcal{D}^j$; see Figure \\ref{fig:mcdvcycle}.\n\\begin{pseudo*} \\label{ps:mcdn-vcycle}\n\\pr{mcdn-vcycle}(J,w^J,N,\\ell^J,\\chi^J,\\id{down}=1,\\id{coarse}=1,\\id{up}=0)\\text{:} \\\\+\n    $g^J = w^J$ \\\\\n    for $j=J$ downto $j=1$ \\\\+\n      $\\chi^{j-1} = \\mR \\chi^j$ \\\\\n      $\\phi^j = \\chi^j - P\\chi^{j-1}$ \\\\\n      $y^j = 0$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{down}}}(j,g^j,y^j,N^j,\\ell^j,\\phi^j)$ \\qquad \\ct{smoothing in $\\mathcal{K}^j$} \\\\\n      $F = N^j(g^j+y^j) - \\ell^j$ \\\\\n      $g^{j-1} = \\iR(g^j + y^j)$ \\\\\n      $\\ell^{j-1} = N^{j-1}(g^{j-1}) - R F$ \\\\-\n    $y^0 = 0$ \\\\\n    $\\text{\\pr{smoother}}^{\\text{\\id{coarse}}}(0,g^0,y^0,N^0,\\ell^0,\\chi^0)$ \\\\\n    $z^0 = y^0$ \\\\\n    for $j=1$ to $j=J$ \\\\+\n      $z^j = P z^{j-1} + y^{j}$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{up}}}(j,g^j,z^j,N^j,\\ell^j,\\chi^j)$ \\qquad \\ct{smoothing in $\\mathcal{D}^j$} \\\\-\n    return $z^J$\n\\end{pseudo*}\nThe nonlinear operator $N^j$  is defined in the next subsection \\ref{subsec:Ndiscretization}.  Pointwise smoothers are defined in subsection \\ref{subsec:pngs}.\n\nTo solve \\eqref{eq:siaVI} we will iterate \\pr{mcdn-vcycle} until the CP residual norm has been reduced by a tolerance factor.  Compare the following in-place solver to \\pr{mcdl-solver} in section \\ref{sec:obstacle}.\n\\begin{pseudo*} \\label{ps:mcdn-solver}\n\\pr{mcdn-solver}(J,w^J,N,a,b,\\id{rtol}=10^{-3},\\id{cyclemax}=100)\\text{:} \\\\+\n    $\\ell^J = \\ip{a}{\\cdot}$ \\\\\n    $F(z)[\\cdot] := N^J(z)[\\cdot] - \\ell^J[\\cdot]$ \\\\\n    $r_0=\\|\\hat\\bF(w^J)\\|$ \\\\\n    for $s=1,\\dots,\\id{cyclemax}$ \\\\+\n        $\\chi^J = b^J - w^J$ \\\\\n        $w^J\\gets w^J+\\pr{mcdn-vcycle}(J,w^J,N,\\ell^J,\\chi^J)$ \\\\\n        if $\\|\\hat\\bF(w^J)\\| \\le \\id{rtol} \\, r_0$ \\\\+\n            break \\\\--\n\\end{pseudo*}\n\nWe may also apply nested iteration to generate the initial iterate on the finest level.  The required modifications of \\pr{mcdl-fcycle} in section \\ref{sec:obstacle} are obvious.\n\n\\subsection{Nonlinear operator discretization} \\label{subsec:Ndiscretization}  The discretization of the nonlinear operator $N_\\eps$ in SIA VI \\eqref{eq:siaVI}, to generate either the single-level form \\eqref{eq:siaVIFEfinelevel} or the coarse-level correction form \\eqref{eq:siaVIFEFAS}, proceeds essentially as for the classical obstacle problem VI \\eqref{eq:obstacleviresidual}.  Compared to the linear case there are only two significant differences:\n\\begin{itemize}\n\\item the bed elevation $b$ is used in the operator $N_\\eps$ in \\eqref{eq:siaN}, not only in defining $\\chi^J$, and\n\\item we approximate the integral using quadrature.\n\\end{itemize}\n\nSuppose $w^j$ in $\\mathcal{V}^j \\subset \\mathcal{W}$ is an iterate on the $j$th level, i.e.~an approximation of the surface elevation $s$ solving \\eqref{eq:siaVI}, and expand it in hat functions: $w^j = \\sum w_q \\psi_q^j$.  Because the support of $\\psi_p^j$ is the interval $[x_p^j-h,x_p^j+h]$, the exact value of the nonlinear operator acting on $w^j$ is\n\\begin{equation}\nN_\\eps(w^j)[\\psi_p^j] = \\int_{x_p^j-h}^{x_p^j+h} \\Gamma (w^j-b+\\eps)^{\\pp+1} \\left|(w^j)'\\right|^{\\pp-2} (w^j)'\\, (\\psi_p^j)'\\,dx.  \\label{eq:siaNFEgoal}\n\\end{equation}\n\nLet us define functions for the powers appearing above:\n\\begin{equation}\n\\tau_q(\\xi)  = (\\xi - b_q + \\eps)^{\\pp+1}, \\qquad \\mu(\\xi) = |\\xi|^{\\pp-2} \\xi, \\label{eq:siahelperfcns}\n\\end{equation}\nfor domains $\\xi \\ge b_q$ and $\\xi$ in $\\RR$, respectively.  (Because we approximate $N_\\eps$ using the interpolated bed $b^j$, $\\tau_q$ uses a nodal bed elevation $b_q$.)  These functions are continuously-differentiable with nonnegative derivatives $\\mu'(\\xi) = (\\pp-1) |\\xi|^{\\pp-2}$ and $\\tau_q'(\\xi) = (\\pp+1) (\\xi-b_q + \\eps)^{\\pp}$, respectively.  Observe that exact integration in \\eqref{eq:siaNFEgoal} is impossible for non-integer $\\pp$ and tedious for integers.\n\nOur approximation of \\eqref{eq:siaNFEgoal} exploits the piecewise-linearity of the functions and it uses the trapezoid rule on each element:\n\\begin{align}\nN^j(w^j)[\\psi_p^j] &= \\Gamma \\left(\\frac{\\tau_{p-1}(w_{p-1}) + \\tau_p(w_p)}{2}\\right) \\mu\\left(\\frac{w_p-w_{p-1}}{h}\\right)\\, \\frac{+1}{h}\\, h \\notag \\\\\n    &\\qquad\\quad  + \\Gamma \\left(\\frac{\\tau_p(w_p) + \\tau_{p+1}(w_{p+1})}{2}\\right) \\mu\\left(\\frac{w_{p+1}-w_p}{h}\\right)\\, \\frac{-1}{h}\\, h, \\notag \\\\\n    &= \\frac{\\Gamma}{2h^{\\pp-1}} \\Big[(\\tau_{p-1}(w_{p-1}) + \\tau_p(w_p)) \\mu(w_p-w_{p-1})  \\label{eq:siaNlevel} \\\\\n    &\\qquad\\qquad\\quad - (\\tau_p(w_p) + \\tau_{p+1}(w_{p+1})) \\mu(w_{p+1}-w_p)\\Big]. \\notag\n\\end{align}\nThis defines a map from $w^j$ in $\\{v \\ge b^j\\} \\subset \\mathcal{V}^j$ to $N^j(w^j) \\approx N_\\eps(w^j)$ in $(\\mathcal{V}^j)'$.\n\nFor convergence and performance comparisons will also solve the $\\pp$-Laplacian obstacle problem; see \\eqref{eq:plaplacianpoisson}.  Its operator formula is computed using \\eqref{eq:siaNlevel} but with $\\Gamma = 1$ and $\\tau_q(\\xi)=1$:\n\\begin{equation}\nN^j(w^j)[\\psi_p^j] = h^{1-\\pp} \\left[\\mu(w_p-w_{p-1}) - \\mu(w_{p+1}-w_p)\\right] \\qquad \\text{($\\pp$-\\emph{Laplacian}).}  \\label{eq:plapNlevel}\n\\end{equation}\n\n\\subsection{Projected, nonlinear pointwise smoothers} \\label{subsec:pngs}  To construct smoothers for the SIA MCD VI we will follow the derivation of the PGS smoother in section \\ref{sec:obstacle}.  Although a minimization-based derivation was possible for that classical obstacle problem, we also showed there that a one-dimensional VI \\eqref{eq:pgspointwisevi} produced the PGS formula \\eqref{eq:pgsformula}.  The smoothers here are derived in a similar way, but, because the problem is nonlinear, we will take a fixed number of Newton steps at each point.  Furthermore, where the SIA form degenerates we will apply a line search \\cite{Kelley2003} plus additional protections.  We first describe how to apply a smoother for the coarse-mesh correction VI \\eqref{eq:siaVIFEFAS}, and later note the replacements for the single-level case \\eqref{eq:siaVIFEfinelevel}.\n\nIn \\eqref{eq:siaVIFEFAS}, assuming we are going down in a V-cycle, $\\phi^j$ is the obstacle on the $j$th level, with expansion $\\phi^j = \\sum \\phi_q \\psi_q^j$, and $\\mathcal{K}^j = \\{v \\ge \\phi^j\\} \\subset \\mathcal{V}^j \\subset \\mathcal{W}$ is the constraint set.  Note that $g^j+y^j \\ge b^j$ follows if $y^j$ is in $\\mathcal{K}^j$.  At the node $x_p^j$, our pointwise smoother seeks a scalar $c \\ge \\phi_p - y_p$ solving the following one-dimensional VI:\n\\begin{equation}\nN^j(g^j+y^j+c\\psi_p^j)[(\\tilde c - c) \\psi_p^j] \\ge \\ell^j[(\\tilde c - c) \\psi_p^j] \\label{eq:pngspointwiseviEARLY}\n\\end{equation}\nfor all scalars $\\tilde c$ such that $\\tilde c \\ge \\phi_p - y_p$.\n(Note that $(\\tilde c - c) \\psi_p^j = (g^j+y^j+\\tilde c\\psi_p^j) - (g^j+y^j+c\\psi_p^j)$.)\n\nUsing \\eqref{eq:siaNlevel}, and defining $w_p=g_p+y_p$ and $\\ell_p=\\ell^j[\\psi_p^j]$, we define the following scalar \\emph{pointwise residual} function\n\\begin{align}\n  \\rho(c) &= N^j(g^j+y^j+c\\psi_p^j)[\\psi_p^j] - \\ell^j[\\psi_p^j] \\label{eq:pngspointwiseresidual} \\\\\n       &= \\frac{\\Gamma}{2h^{\\pp-1}} \\Big[(\\tau_{p-1}(w_{p-1}) + \\tau_p(w_p +c)) \\mu(w_p+c-w_{p-1}) \\notag  \\\\\n       &\\hspace{20mm} - (\\tau_p(w_p+c) + \\tau_{p+1}(w_{p+1})) \\mu(w_{p+1}-w_p-c)\\Big] - \\ell_p. \\notag\n\\end{align}\n(When using this formula keep in mind that $w^j = g^j+y^j$ is the current estimate of the ice surface, and $g^j$ is fixed while $y^j$ is the solution variable in \\eqref{eq:siaVIFEFAS}.)  Now, by linearity we may rewrite \\eqref{eq:pngspointwiseviEARLY} as\n\\begin{equation}\n  (\\tilde c - c) \\rho(c) \\ge 0  \\label{eq:pngspointwisevi}\n\\end{equation}\nfor all $\\tilde c \\ge \\phi_p - y_p$.\n\nThe pointwise residual $\\rho(c)$ is differentiable on the admissible interval $[\\phi_p - y_p,+\\infty)$, which always includes $c=0$.  Recall that when we derived the PGS smoother for the classical obstacle problem we used the fact that its pointwise residual was both linear and strictly-increasing, thus the one-dimensional VI \\eqref{eq:pgspointwisevi} was solved by a unique value $c$ in the admissible interval.  Here we would ``want'' $\\rho'(c)$ in \\eqref{eq:pngspointwiseresidual} to always be positive, but this is not true in the SIA, nor in the $\\pp$-Laplacian problem when $\\pp>2$.  However, lower bounds on the derivative $\\rho'(c)$ are possible, as follows.  By the product rule, the mean value theorem, $\\tau_q(x) = (x+b_q+\\eps)^{\\pp+1} \\ge \\eps^{\\pp+1}\\ge 0$ when $x\\ge b_q$, and $\\mu'\\ge 0$,\n\\begin{align}\n  \\rho'(c) &= \\frac{\\Gamma}{2h^{\\pp-1}} \\Big[\\tau_p'(w_p+c) \\left(\\mu(w_p+c-w_{p-1}) -  \\mu(w_{p+1}-w_p-c)\\right) \\label{eq:pngsderivativebound} \\\\\n        &\\qquad\\qquad\\quad + (\\tau_{p-1}(w_{p-1}) + \\tau_p(w_p+c)) \\mu'(w_p+c-w_{p-1}) \\notag \\\\\n        &\\qquad\\qquad\\quad + (\\tau_p(w_p+c) + \\tau_{p+1}(w_{p+1})) \\mu'(w_{p+1}-w_p-c)\\Big] \\notag \\\\\n        &\\ge \\frac{\\Gamma}{2h^{\\pp-1}} \\tau_p'(w_p+c) \\mu'(\\xi_p) (2(w_p+c) - w_{p-1} - w_{p+1}). \\notag\n\\end{align}\n(Note that taking $\\eps=0$ does not change the final bound.)  Recalling that $\\tau_q'$ is also nonnegative, $\\rho'(c)$ can only be negative when\n    $$0 > 2(w_p+c) - w_{p-1} - w_{p+1} \\approx - h^2\\left(w^j(x) + c \\psi_p^j(x)\\right)''\\Big|_{x_p^j},$$\nthat is, when the updated surface $w^j(x) + c \\psi_p^j(x)$ is convex (concave up) at $x_p^j$.  This situation is most likely to occur when $x_p^j$ is at or near the estimated margin location.  Lower bound \\eqref{eq:pngsderivativebound} also applies in the easier $\\pp$-Laplacian case, but then $\\Gamma=1$ and $\\tau_q(\\xi)=1$ so we have $\\rho'(c)\\ge 0$; nonetheless note that $\\rho'(c)$ is \\emph{not} bounded away from zero.\n\nUnlike for the classical obstacle problem, the solution of one-dimensional VI \\eqref{eq:pngspointwisevi} cannot be found exactly.  Instead we set up a Newton iteration to compute $y^j$ at the point $x_p^j$.  In simple form a Newton step would be\n\\begin{equation}\n    c = -\\rho(0) / \\rho'(0), \\qquad y_p \\gets y_p + c. \\label{eq:pngspointNewton}\n\\end{equation}\nHowever, because $\\rho'(0)$ may be arbitrarily small or zero, this step must be ``protected''.\n\nIn the case where $\\rho'(0)=0$ exactly, the flow is not telling us anything about how the current surface should move.  When this happens at an ice-free location $w_p=0$, and if $\\ell_p > 0$, so that accumulation is occurring, we simply increase the surface by a fixed, small distance \\id{caccum}; otherwise we make no change.\n\nIf $\\rho'(0)$ is nonzero then we go ahead and compute $c$.  Now it is relevant that we are solving a one-sided obstacle problem.  If $c$ is negative we limit it (as usual) by enforcing admissiblity.  If $c$ is large and positive we limit it by \\id{cupmax}, with a relatively-large default value.  For clarity we isolate this logic into the following pseudocode in which we seek $c$ in the interval $[\\phi_p-y_p,+\\infty)$, and where we assume $r=\\rho(0)$ and $\\delta=\\rho'(0)$ have already been computed.\n\\begin{pseudo*} \\label{ps:pointupdate}\n\\pr{pointupdate}(r,\\delta,y_p,\\phi_p,\\ell_p,\\id{cupmax}=100\\, m,\\id{caccum}=10\\, m)\\text{:} \\\\+\n    if $\\delta = 0$ \\\\+\n        if $\\ell_p > 0$ and $y_p = 0$ \\\\+\n            return \\id{caccum}  \\qquad\\qquad\\quad \\ct{move upward if accumulation at ice-free} \\\\-\n        return $0$ \\qquad\\qquad\\qquad\\qquad\\qquad \\ct{no information on how to move} \\\\-\n    else \\\\+\n        $c = \\max(- r / \\delta, \\phi_p-y_p)$ \\qquad\\qquad \\ct{admissible Newton step} \\\\\n        return $\\min(c, \\id{cupmax})$ \\qquad\\qquad \\ct{limit large upward steps}\n\\end{pseudo*}\n\nHowever, these protections are found to be insufficient for the best performance.  In the general case where $\\rho'(0)\\ne 0$, and if the $c$ from \\pr{pointupdate} is still of significant magnitude, we have found that a line search using a Armijo-type sufficient decrease criterion \\cite{Kelley2003} improves performance.  This line search requires additional evaluations of the pointwise residual, an acceptable modification of a GS-type smoother.  A key limitation of the line search idea here is that only the pointwise residual gets sufficient decrease; the global residual $\\|\\hat\\bF(g^j+y^j)\\|$ is not directly controlled, and indeed it may increase.\n\nOur pointwise \\emph{projected nonlinear Gauss-Seidel} (PNGS) smoother for the SIA and $\\pp$-Laplacian problems is the following pseudocode.\n\\begin{pseudo*} \\label{ps:pngs}\n\\pr{pngs}(j,g^j,y^j,N^j,\\ell^j,\\phi^j,\\id{newtonits}=2,\\id{ctol}=1 m,\\id{omega}=1)\\text{:} \\\\+\n    \\ct{check admissibility: $y^j \\ge \\phi^j$} \\\\\n    for $p=1,\\dots,m_j$ \\\\+\n        for $k=1,\\dots,\\id{newtonits}$ \\\\+\n            $\\rho_p(c) := N^j(g^j+y^j+c\\psi_p^j)[\\psi_p^j] - \\ell^j[\\psi_p^j]$ \\\\\n            $c = \\pr{pointupdate}(\\rho_p(0), \\rho_p'(0),y_p,\\phi_p,\\ell^j[\\psi_p^j])$ \\\\\n            if $|c| > \\id{ctol}$ \\\\+\n                for $k=0,\\dots,19$ \\\\+\n                    if $|\\rho_p(\\id{omega}\\, 2^{-k} c)| < (1 - 10^{-4}\\, 2^{-k}) |\\rho_p(0)|$ \\\\+\n                        $c \\gets 2^{-k} c$ \\\\\n                        break \\\\---\n            $y_p \\gets y_p + \\id{omega}\\,c$\n\\end{pseudo*}\nThis pseudocode applies to either the SIA or $\\pp$-Laplacian problems.\n\nThere is also a \\emph{projected nonlinear Jacobi} version.  The outer two loops are reversed because the residual and Jacobian must be updated before each sweep.  Furthermore, in a Jacobi smoother the residuals should be evaluated only globally, and as rarely as possible, so the line search is omitted.\n\\begin{pseudo*} \\label{ps:pnjacobi}\n\\pr{pnjacobi}(j,g^j,y^j,N^j,\\ell^j,\\phi^j,\\id{newtonits}=2,\\id{omega}=0.67)\\text{:} \\\\+\n    \\ct{check admissibility: $y^j \\ge \\phi^j$} \\\\\n    for $k=1,\\dots,\\id{newtonits}$ \\\\+\n        $\\rho_p(c) := N^j(g^j+y^j+c\\psi_p^j)[\\psi_p^j] - \\ell^j[\\psi_p^j]$ \\\\\n        $r_p, \\delta_p = \\rho_p(0), \\rho_p'(0)$ \\qquad\\qquad\\qquad\\qquad \\ct{compute and save for all $p$}\\\\\n        for $p=1,\\dots,m_j$ \\\\+\n            $c = \\pr{pointupdate}(r_p, \\delta_p,y_p,\\phi_p,\\ell^j[\\psi_p^j])$ \\\\\n            $y_p \\gets y_p + \\id{omega}\\,c$\n\\end{pseudo*}\nHere the default value of \\id{omega} is just a place-holder; stable values must be determined by experimentation.\n\nThe above formulas and pseudocodes apply to the $\\pp$-Laplacian obstacle problem \\eqref{eq:plaplacianpoisson} with only minimal modifications, namely $\\Gamma=1$ and $\\tau_q(\\xi)=1$ in formulas for $N(w)[v]$ and $\\rho(c)$.  We use \\id{caccum} $=0$, \\id{ctol} $=0.001$, and \\id{cupmax} $=1$ in the $\\pp$-Laplacian version.\n\nFor single-level VI \\eqref{eq:siaVIFEfinelevel}, or for \\eqref{eq:siaVIFEFAS} when up-smoothing after the coarse-level correction, make the following replacements in all of the formulas and pseudocodes in this subsection:\n\\begin{equation}\n   \\phi^j \\to \\chi^j, \\qquad \\mathcal{K}^j \\to \\mathcal{D}^j, \\qquad y^j \\to z^j.  \\label{eq:pngssinglelevelreplacements}\n\\end{equation}\n\nIn the next section we will show results from the MCDN method, using our \\pr{pngs} and \\pr{pnjacobi} smoothers, on the SIA and $\\pp$-Laplacian obstacle problems.  We will see that the margin degeneracy of the SIA problem is problematic for these pointwise smoothers.  Patch-type smoothers, which would in our case solve a $k$-dimensional VI for $k > 1$, have been applied to other multigrid problems \\cite{Farrelletal2019}, and they may be appropriate here as well.  For example, a $k=3$ patch smoother might update the three degrees of freedom $y_{p-1},y_p,y_{p+1}$ simultaneously by solving a $3$-dimensional VI which generalizes \\eqref{eq:pngspointwisevi}.  Testing this strategy is planned for further research.\n\n\\subsection{Convergence and performance results} \\label{subsec:siaperformance}  The convergence of our SIA solver, on the exact SIA solution in Figure \\ref{fig:siadatafigure}, is shown in Figure \\ref{fig:siaconv}.  The smallest errros occur on a mesh of $m=32767$ nodes and spacing $h=55$ m.  The rates of convergence are close to $O(h^1)$ for both $L^1$ and $L^2$ norms, but the latter converges faster because the largest errors are localized along the margin.  It is known that the low margin regularity of the solution reduces the rate of convergence under grid refinement \\cite{Bueleretal2005}, though a more-accurate scheme is capable of an $O(h^{1.47})$ convergence rate in the $L^1$ norm on a related 2D problem.  As we observed earlier, the flat-bed problem is equivalent to a $\\pp$-Laplacian problem for the $\\rr=(2n+2)/n = 8/3$ power of the thickness, so we also measure the $\\pp=4$ norm of the $H^\\rr$ error, which decays slightly faster.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/sia/convergence.pdf}\n\\caption{Convergence of the MCDN method.  See text for an explanation of the $\\|H^\\rr-H_{\\text{exact}}^\\rr\\|_\\pp$ norm.}\n\\label{fig:siaconv}\n\\end{figure}\n\nWe may compare these results to $\\pp$-Laplacian convergence for the $\\pp$-Laplacian obstacle problem, with $\\pp=4$, on an exact solution constructed in a similar way to the classical obstacle problem shown in Figure \\ref{fig:icelike}.  In that case we measure $\\|u-u_{\\text{exact}}\\|_\\pp=O(h^{0.99})$, and as for the SIA case the numerical error norms are not monotonic.  The fact that $\\|H^\\rr-H_{\\text{exact}}^\\rr\\|_\\pp$ goes to zero at a slightly-better rate for the SIA solution reflects the fact that the source term for the SIA is continuous while for the $\\pp$-Laplacian solution it is not.\n\nNext, Figure \\ref{fig:siareshistory} shows a residual norm history for the first 30 iterations of $m=10^3$ runs on the exact solution shown in Figure \\ref{fig:siadatafigure}.  The two runs use a single-level PNGS method and V(0,2) cycles with PNGS smoothing, respectively.  The first few MCDN V-cycles are effective as expected, and the multilevel method reduces the error much more than the single-level method, but it also stagnates and the residuals do not decrease monotonically.  The smoother steps in the multilevel method involve large pointwise changes near the margin, so while the pointwise residuals always decreases because of the line search, the global residual can increase as a result of a smoother sweep.\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/sia/reshistory.pdf}\n\\caption{CP residual norms $\\|\\hat F(w)\\|_2$ for two PNGS-based solutions on a $1024$ element mesh with $h=1.76$ km.}\n\\label{fig:siareshistory}\n\\end{figure}\n\nFIXME what are the asymptotic rates anyway? suppose we initialize with the continuum exact solution; asymptotic rates in Figure \\ref{fig:siaconv} for GS vs Jacobi with a couple of omega values; for comparison, in the $\\pp$-Laplacian with $\\pp=4$ the V(0,2) rates are $0.7772$--$0.9143$ compared to $0.7357$--$0.9224$ here for SIA; so we actually are getting multigrid rates but not good ones\n\n\\begin{figure}\n\\includegraphics[width=0.6\\textwidth]{genfigs/sia/asymprates.pdf}\n\\caption{Asymptotic multigrid convergence rates of the MCDN method on the exact solution shown in Figure \\ref{fig:siadatafigure}.}\n\\label{fig:siaasymp}\n\\end{figure}\n\nFIXME V-cycles and F-cycles counts/WU on Bueler profile; compare to $\\pp$-Laplacian performance\n\nFIXME performance measurements on a random bed\n\n\\subsection{Implicit evolving-geometry solvers} \\label{subsec:siaimplicit}  FIXME use Halfar solution\n\nFIXME can we see cross-over relative to explicit time-stepping?\n\n\n\\small\n\n\\bigskip\n\\bibliography{gmggm}\n\\bibliographystyle{siam}\n\n\\normalsize\n\n%\\clearpage\n\\appendix\n\n\\section{Tables to assist the reader}\n\nThis review has been written attempting to use the simplest effective language and notation, but the new concepts are still substantial, and furthermore a number of different algorithms are discussed.  This Appendix may help the reader in managing the terminology, starting with acronyms in Table \\ref{tab:acronyms} and notation in Table \\ref{tab:notation}.  Tables \\ref{tab:pseudocodespoisson}--\\ref{tab:pseudocodessia} list pseudocodes, for sections \\ref{sec:subspace}--\\ref{sec:sia} respectively, by page number.  All Tables are arranged alphabetically where possible.\n\n\\bigskip\n\n\\renewcommand{\\arraystretch}{1.1}\n\\begin{longtable}{l|l}\n\\toprule\n\\textbf{Acronym} {\\Large$\\strut$} & \\textbf{Definition} \\\\ \\hline\nCP & complementarity problem \\\\\nFAS & full approximation scheme \\\\\nFE & finite element \\\\\nGMG & geometric multigrid \\\\\nGS & Gauss-Seidel \\\\\nMCD & multilevel constraint decomposition \\\\\nMCDL & linear version of MCD \\\\\nMCDN & nonlinear (FAS) version of MCD \\\\\nMSC & multilevel subspace corrections \\\\\nPDE & partial differential equation \\\\\nPGS & projected Gauss-Seidel \\\\\nPNGS & projected nonlinear (Newton) Gauss-Seidel \\\\\nSIA & shallow ice approximation \\\\\nSKE & surface kinematical equation \\\\\nVI & variational inequality \\\\\nWU & work units \\\\ % final \\\\ required\n\\bottomrule\n\\caption{Acronyms.}\n\\label{tab:acronyms}\n\\end{longtable}\n\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{longtable}{l|l}\n\\toprule\n\\textbf{Symbol} {\\Large$\\strut$} & \\textbf{Meaning} \\\\ \\hline\n$a(\\cdot,\\cdot)$ & bilinear form; for Poisson this is the left side of equation \\eqref{eq:weakpoissonearly} \\\\\n$\\mathcal{D}^J$ & defect constraint set; $\\mathcal{D}^J = \\{v \\ge \\chi^J\\}$ \\\\\n$F(w)[\\cdot]$ & residual of iterate $w$; $F(w)[v] = a(w,v) - \\ip{f}{v}$ for Poisson \\\\\n$F^j(w)[\\cdot]$ & $j$th-level residual; $F^j(w)[v] = a(w,v) - \\ell^j[v]$ for Poisson \\\\\n$\\mathcal{H}$ & Hilbert space for the continuum problem; $\\mathcal{H}=H_0^1[0,1]$ for Poisson \\\\\n$I(w)$ & scalar-valued objective function; $I(w) = \\frac{1}{2} a(v,v) - \\ip{f}{v}$ for Poisson \\\\\n$J$ & level index of finest mesh \\\\\n$j$ & index of mesh level; $j=0,1,\\dots,J$ from coarse to fine \\\\\n$\\mathcal{K}_\\varphi$ & continuum constraint set; $\\mathcal{K}_\\varphi = \\{v \\ge \\varphi\\} \\subset \\mathcal{H}$ \\\\\n$\\mathcal{K}^j$ & $j$th-level admissible functions; $\\mathcal{K}^j = \\{v \\ge \\phi^j\\} \\subset \\mathcal{V}^j$ \\\\\n$\\ell[\\cdot]$ & source linear functional, e.g.~$\\ell[v] = \\ip{f}{v}$ \\\\\n$\\ell^j[\\cdot]$ & $j$th-level source; usually a restriction of the $j+1$ level residual \\\\\n$m$ & number of degrees of freedom in discretized problem; $m=m_J$ \\\\\n$m_j$ & number of nodes in $j$th-level; $\\dim \\mathcal{V}^j=m_j$ \\\\\n$P$ & canonical prolongation of functions, $\\mathcal{V}^{j-1} \\to \\mathcal{V}^j$; see Table \\ref{tab:transfers} \\\\\n$\\hat P$ & solution prolongation of functions, $\\mathcal{V}^{j-1} \\to \\mathcal{V}^j$; see Table \\ref{tab:transfers} \\\\\n$R$ & canonical restriction of linear functionals, $(\\mathcal{V}^j)' \\to (\\mathcal{V}^{j-1})'$; see Table \\ref{tab:transfers} \\\\\n$\\iR$ & injection restriction of functions, $\\mathcal{V}^j \\to \\mathcal{V}^{j-1}$; see Table \\ref{tab:transfers} \\\\\n$\\mR$ & monotone restriction of functions, $\\mathcal{V}^j \\to \\mathcal{V}^{j-1}$; see Table \\ref{tab:transfers} \\\\\n$\\mathcal{V}^h$ & finite element function space; $\\mathcal{V}^h = \\mathcal{V}^J$ \\\\\n$\\mathcal{V}^j$ & $j$th-level vector space \\\\\n$(\\mathcal{V}^j)'$ & dual space (linear functionals) of $\\mathcal{V}^j$  \\\\\n$x_p^j$ & $p$th node on $j$th-level mesh \\\\\n$\\varphi(x)$ & obstacle in continuum problem \\\\\n$\\varphi^j(x)$ & $j$th-level interpolant of continuum obstacle; \\emph{not} equal to $\\phi^j$ \\\\\n$\\phi^j(x)$ & $j$th-level obstacle; $\\phi^j=\\chi^j - \\chi^{j-1}$ \\\\\n$\\chi^J(x)$ & fine-level defect obstacle; $\\chi^J = \\varphi^J - w^J$ for iterate $w^J$ \\\\\n$\\chi^j(x)$ & $j$th-level (monotone) restriction of defect obstacle; $\\chi^{j-1} = \\mR \\chi^j$ \\\\\n$\\psi_p^j(x)$ & $j$th-level hat function at $x_p$ \\\\\n$\\ip{\\cdot}{\\cdot}$ & $L^2$ inner product \\\\\n$\\|\\cdot\\|$ & $L^2$ norm; $\\|f\\|=\\ip{f}{f}^{1/2}$ \\\\\n$\\|\\cdot\\|_{\\mathcal{H}}$ & norm on solution space; $\\|f\\|_{\\mathcal{H}}^2 =\\ip{f}{f} + \\ip{f'}{f'}$ for $\\mathcal{H}=H_0^1[0,1]$ \\\\  % final \\\\ required\n\\bottomrule\n\\caption{Notation for sections \\ref{sec:subspace} and \\ref{sec:obstacle}.}\n\\label{tab:notation}\n\\end{longtable}\n\n\\renewcommand{\\arraystretch}{1.1}\n\\begin{longtable}{l|l|l}\n\\toprule\n\\textbf{Name} {\\Large$\\strut$} & \\textbf{Page} & \\textbf{Description} \\\\ \\hline\n\\pr{euler-timestep} & \\pageref{ps:euler-timestep} & forward Euler as a smoother iteration \\\\\n\\pr{gmg-coarsesolve} & \\pageref{ps:gmg-coarsesolve} & geometric multigrid (GMG) coarse-level solver \\\\\n\\pr{gmg-vcycle} & \\pageref{ps:gmg-vcycle} & implementable GMG V-cycle \\\\\n\\pr{gs-sweep} & \\pageref{ps:gs-sweep} & Gauss-Seidel (GS) iteration, a smoother \\\\\n\\pr{jacobi-sweep} & \\pageref{ps:jacobi-sweep} & Jacobi iteration, a smoother \\\\\n\\pr{msc-downslash} & \\pageref{ps:msc-downslash} & multilevel subspace corrections (MSC) slash-cycle, \\\\\n  &  & \\qquad V(1,0); calls a smoother \\\\\n\\pr{msc-solver} & \\pageref{ps:msc-solver} & MSC solver; calls an MSC cycle \\\\\n\\pr{msc-vcycle} & \\pageref{ps:msc-vcycle} & MSC V-cycle, V(1,1) \\\\\n\\pr{msc-upslash} & \\pageref{ps:msc-upslash} & MSC slash-cycle, V(0,1) \\\\\n\\bottomrule\n\\caption{Pseudocodes for the Poisson equation (section \\ref{sec:subspace}).}\n\\label{tab:pseudocodespoisson}\n\\end{longtable}\n\n\\begin{longtable}{l|l|l}\n\\toprule\n\\textbf{Name} {\\Large$\\strut$} & \\textbf{Page} & \\textbf{Description} \\\\ \\hline\n\\pr{mcdl-fcycle} & \\pageref{ps:mcdl-fcycle} & MCD F-cycle (nested iteration); calls \\pr{mcdl-vcycle} \\\\\n\\pr{mcdl-vcycle} & \\pageref{ps:mcdl-vcycle} & multilevel constraint decomposition (MCD) V-cycle \\\\\n  &  & \\qquad in linear case; calls \\pr{p[gs$|$jacobi]-sweep} as smoother \\\\\n\\pr{mcdl-solver} & \\pageref{ps:mcdl-solver} & MCD solver; calls \\pr{mcdl-vcycle} \\\\\n\\pr{pgs} & \\pageref{ps:pgs} & projected GS iteration, a smoother \\\\\n\\pr{pjacobi} & \\pageref{ps:pjacobi} & projected Jacobi iteration, a smoother \\\\ % final \\\\ required\n\\bottomrule\n\\caption{Pseudocodes for the classical obstacle problem (section \\ref{sec:obstacle}).}\n\\label{tab:pseudocodesobstacle}\n\\end{longtable}\n\n\\begin{longtable}{l|l|l}\n\\toprule\n\\textbf{Name} {\\Large$\\strut$} & \\textbf{Page} & \\textbf{Description} \\\\ \\hline\n\\pr{mcdn-vcycle} & \\pageref{ps:mcdn-vcycle} & FAS-type nonlinear MCD V-cycle \\\\\n\\pr{mcdn-solver} & \\pageref{ps:mcdn-solver} & MCD solver; calls \\pr{mcdn-vcycle} \\\\\n\\pr{pnjacobi} & \\pageref{ps:pnjacobi} & projected nonlinear (Newton) Jacobi iteration, a smoother \\\\\n\\pr{pngs} & \\pageref{ps:pngs} & projected nonlinear (Newton) GS iteration, a smoother \\\\\n\\pr{pointupdate} & \\pageref{ps:pointupdate} & pointwise Newton step logic for a degenerate nonlinear operator \\\\ % final \\\\ required\n\\bottomrule\n\\caption{Pseudocodes for the SIA obstacle problem (section \\ref{sec:sia}).}\n\\label{tab:pseudocodessia}\n\\end{longtable}\n\n\\end{document}\n", "meta": {"hexsha": "acd6b4c0d216d7e23e52334feebb0e95b766f8f8", "size": 151820, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/gmggm.tex", "max_stars_repo_name": "bueler/mg-glaciers", "max_stars_repo_head_hexsha": "649c323f18f31a332c0845bf3955d201cd4c3cf8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/gmggm.tex", "max_issues_repo_name": "bueler/mg-glaciers", "max_issues_repo_head_hexsha": "649c323f18f31a332c0845bf3955d201cd4c3cf8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/gmggm.tex", "max_forks_repo_name": "bueler/mg-glaciers", "max_forks_repo_head_hexsha": "649c323f18f31a332c0845bf3955d201cd4c3cf8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 104.7034482759, "max_line_length": 1683, "alphanum_fraction": 0.7186470821, "num_tokens": 48320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41731328455936495}}
{"text": "\\documentclass[aps,notitlepage,nofootinbib,11pt]{revtex4-1}\n\n% linking references\n\\usepackage{hyperref}\n\\hypersetup{\n  breaklinks=true,\n  colorlinks=true,\n  linkcolor=blue,\n  filecolor=magenta,\n  urlcolor=cyan,\n}\n\n%%% header / footer\n\\usepackage{fancyhdr} % easier header and footer management\n\\pagestyle{fancy} % page formatting style\n\\fancyhf{}\n\\usepackage{lastpage} % for referencing last page\n\\cfoot{\\thepage~of \\pageref{LastPage}} % \"x of y\" page labeling\n\\renewcommand{\\headrulewidth}{0pt} % remove horizontal line in header\n\n% figures\n\\usepackage{hyperref} % for linking references\n\\usepackage{graphicx,float} % for figures\n\\usepackage{grffile} % help latex properly identify figure extensions\n\\graphicspath{{./figures/}} % set path for all graphics\n\\usepackage[caption=false]{subfig} % subfigures (\"subfloat\")\n\\newcommand{\\sref}[1]{\\protect\\subref{#1}}\n\n% inline lists\n\\usepackage[inline]{enumitem}\n\\setlist[enumerate,1]{label={(\\roman*)}}\n\n%%% symbols, notations, etc.\n\\usepackage{physics,braket,amssymb} % physics and math packages\n\\usepackage{accents} % for resolving some accent (e.g. tilde) issues\n\\renewcommand{\\t}{\\text} % text in math mode\n\\newcommand{\\f}[2]{\\dfrac{#1}{#2}} % shorthand\n\\newcommand{\\p}[1]{\\left(#1\\right)} % parenthesis\n\\renewcommand{\\sp}[1]{\\left[#1\\right]} % square parenthesis\n\\renewcommand{\\set}[1]{\\left\\{#1\\right\\}} % curly parenthesis\n\\newcommand{\\bk}{\\Braket} % shorthand\n\\renewcommand{\\d}{\\partial} % partial d\n\n\\usepackage{dsfont}\n\\newcommand{\\1}{\\mathds{1}}\n\n\\newcommand{\\Z}{\\mathbb Z}\n\\renewcommand{\\O}{\\mathcal O}\n\n\\usepackage{accents}\n\\newcommand{\\utilde}[1]{\\underaccent{\\tilde}{#1}}\n\n\n\\begin{document}\n\n\\title{Generating new forms of spin-orbit coupling with a 1-D optical\n  lattice clock}\n\n\\author{Michael A. Perlin}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\nThe primary motivation of this work is to use the ${}^{87}$Sr optical\nlattice clock (OLC) to study general forms of spin-orbit coupling.  To\naccomplish this task, we will draw analogies between the OLC and\ntrapped ions, with the hope of facilitating an exchange of ideas and\ntechniques between the trapped ion and optical lattice communities.\nWe will map degrees of freedom between the two systems as follows: the\nquasi-momentum of an atom in the OLC corresponds to the on-site\norbital occupied by a trapped ion in a Coulomb lattice; the band index\nof an OLC atom corresponds to a vibrational (phonon) mode of an ion;\nand the (electronic) clock states of an OLC atom constitute a\npseudo-spin degree of freedom which corresponds to two optical states\nof an ion.  For brevity, we will sometimes refer to the clock states\nas the ``spin'' of the OLC atoms; we will not address the nuclear spin\ndegree of freedom of OLC atoms, and will assume that they are\nnuclear-spin-polarized.\n\nWe start by considering a two level atom in a one-dimensional (1-D)\noptical lattice interrogated by a plane-wave clock laser.  After a\nrotating wave approximation, the dynamics of this system is\neffectively described by the Hamiltonian\n\\begin{align}\n  H\n  = \\f{p^2}{2m} + V_0\\sin^2\\p{k_L z} - \\f12\\delta\\sigma^z\n  - \\f12\\Omega\\p{e^{ikz}\\sigma^+ + e^{-ikz}\\sigma^-},\n  \\label{eq:start}\n\\end{align}\nwhere $p$ and $m$ are respectively the momentum and mass of the atom,\n$V_0$ and $k_L$ are the lattice depth and wavenumber; $z$ is the\nposition along the lattice; $\\delta=\\omega-\\omega_0$ is the detuning\nof the clock laser frequency $\\omega$ from the atomic clock transition\nenergy $\\omega_0$; $\\sigma^j$ with $j\\in\\set{x,y,z}$ is a Pauli matrix\naddressing the spin of the atom;\n$\\sigma^\\pm\\equiv\\p{\\sigma^x\\pm i\\sigma^y}/2$ are spin raising and\nlowering operators; $\\Omega$ is the bare Rabi frequency of the clock\nlaser, and $k$ is the wavenumber of the clock laser along the lattice\naxis.\n\n\n\\section{Quasi-momentum expansion and diagonalization}\n\nThe first two terms of the Hamiltonian in \\eqref{eq:start} have\ndiscrete translational invariance, which means that they may be\ndiagonalized with quasi-momentum and band index as good quantum\nnumbers.  The spatial eigenfunctions of these terms correspond to\nsolutions of the Mathieu equation, whose eigenfunctions\n$\\bk{z|qn}=\\phi_{qn}\\p{z}$ and corresponding energy eigenvalues\n$E_{qn}$ are, in a periodic lattice with $L$ sites, indexed by a\nquasi-momentum $q$ and band index $n$, where $q/k_L\\in\\Z/L$ and\n$n\\in\\mathbb N_0$.  Additionally introducing the index\n$s\\in\\set{\\pm 1}$ to label the ground ($s=-1$) and excited ($s=1$), we\ndefine field operators $c_{qns}$ which act on the vacuum as\n$c_{qns}^\\dag\\ket{\\t{vacuum}}=\\ket{qns}$ and obey the standard\nfermionic commutation relations.  The Hamiltonian in \\eqref{eq:start}\ncan then be written in the general form\n\\begin{align}\n  H\n  = \\sum_{q,n,s}\\p{E_{qn}-\\f12s\\delta}c_{qns}^\\dag c_{qns}\n  - \\f12\\sum_{\\substack{q,n,s\\\\g,m,r}}\n  \\Omega^{qns}_{gmr} c_{gmr}^\\dag c_{qns},\n  \\label{eq:field_operators}\n\\end{align}\nwhere $\\Omega^{qns}_{gmr}\\equiv\\Omega\\bk{gmr|e^{-iskz}|qns}$ is a\ncoupling constant between states $\\ket{qns}$ and $\\ket{gmr}$.  This\ncoupling constant vanishes unless $r=\\bar s\\equiv-s$.  Furthermore, in\nwhat amounts to a stationary phase approximation (see Appendix\n\\ref{sec:laser_coupling}), we can say that\n$\\Omega^{qns}_{gm\\bar s} \\approx \\Omega^{qns}_{gm\\bar s}\n\\delta_{g,q-sk}$, which is a result of a momentum kick $k$ imparted\ninto OLC atoms when they absorb or emit a photon; this approximation\nbecomes exact when the clock photon momentum $k$ is commensurate with\nthe lattice.  Making this substitution, the Hamiltonian in\n\\eqref{eq:field_operators} becomes\n\\begin{align}\n  H\n  = \\sum_{q,n,s}\\p{E_{qn}-\\f12s\\delta}c_{qns}^\\dag c_{qns}\n  - \\f12\\sum_{q,n,s,m}\\Omega^{qns}_{q-sk,m\\bar s}\n  c_{q-sk,m,\\bar s}^\\dag c_{qns}.\n  \\label{eq:kick}\n\\end{align}\nFurther redefining field operators, energies, and coupling constants\n\\begin{align}\n  b_{qns} \\equiv c_{q+sk/2,ns},\n  &&\n  E_{qns} \\equiv E_{q+sk/2,n},\n  &&\n  \\Omega^{qs}_{nm} = \\Omega^{q+sk/2,ns}_{q-sk/2,m\\bar s},\n  \\label{eq:transformation}\n\\end{align}\ndiagonalizes the Hamiltonian in \\eqref{eq:kick} with respect to\nquasi-momentum $q$:\n\\begin{align}\n  H\n  = \\sum_{q,n,s}\\p{E_{qns}-\\f12s\\delta} b_{qns}^\\dag b_{qns}\n  - \\f12\\sum_{q,n,s,m} \\Omega^{qs}_{nm} b_{qm\\bar s}^\\dag b_{qns}.\n  \\label{eq:full_H}\n\\end{align}\nThis redefinition amounts to a gauge transformation of the field\noperators, which shifts the OLC band structure (i.e. dispersion\nrelation; see Figure \\ref{fig:bands}).  Appendix\n\\ref{sec:laser_coupling} covers some useful symmetries of\n$\\Omega^{qs}_{nm}$.\n\n\\begin{figure}\n  \\subfloat[]{\n    \\includegraphics[width=0.45\\textwidth]{qn_bands_V10.pdf}\n    \\label{fig:before}\n  } \\subfloat[]{\n    \\includegraphics[width=0.45\\textwidth]{qns_bands_V10.pdf}\n    \\label{fig:after}\n  }\n  \\caption{Band diagrams of the Sr-87 OLC with a lattice depth\n    $V_0=10E_R$ (where $E_R=k_L^2/2m\\approx22~\\t{kHz}$ is the lattice\n    recoil energy) \\sref{fig:before} before, and \\sref{fig:after}\n    after the gauge transformation in \\eqref{eq:transformation}. The\n    legend in \\sref{fig:after} indicates the clock state (spin) for\n    each line.}\n  \\label{fig:bands}\n\\end{figure}\n\nA few of observations about the Hamiltonian in \\eqref{eq:full_H}.\nFirst, there is no coupling between states with different\n(gauge-transformed) quasi-momenta $q$.  Once initialized, therefore,\nthe single-particle physics of the this OLC is reducible to the\ndynamics within each sub-manifold of states with fixed quasi-momentum\n$q$.  This fact is in analogy with trapped ions which are pinned to a\nsingle site of a Coulomb crystal.  Second, there is no direct coupling\nbetween different states with the same spin $s$; such coupling only\noccurs at second order in the coupling strength $\\Omega$.  In\nprinciple, it is possible to introduce first-order coupling between\nstates with different band index $n$ and the same spin $s$ by\nmodulating the lattice in either phase or amplitude, but for now we\nleave this consideration for future work.  Third, the Hamiltonian in\n\\eqref{eq:full_H} exhibits the standard type of spin-orbit coupling\ninvestigated in the $^{87}$Sr OLC at JILA, in which different\nquasi-momenta $q$ are energetically favorable for different spins $s$.\nThis spin-orbit coupling is similar to that encountered in a condensed\nmatter setting, and can lead to interesting topological physics.\nFinally, the 1-D OLC Hamiltonian exhibits a spin-phonon-like coupling\nbetween spin $s$ and band index $n$, which we will see more clearly in\nSection \\ref{sec:ions}.\n\n\n\\section{Mapping onto trapped ions}\n\\label{sec:ions}\n\nIn this section, we illustrate more clearly the analogy between the\n1-D optical lattice clock and a 1-D crystal of trapped ions.  To\nsimplify our analysis, assume single-particle occupation each\nquasi-momentum in the OLC, which translates to having a single ion per\nsite in a Coulomb crystal.  We will also only consider transitions\nbetween adjacent bands (i.e. vibrational modes). We now define the\n``lowering operators'' $a_{qnm}\\equiv\\sum_s\\op{q,n-1,s}{qns}$; in\naddition to\n\\begin{align}\n  \\bar E_{qn} \\equiv \\f12\\p{E_{qn,+} + E_{qn,-}},\n  &&\n  \\Delta_{qn} \\equiv E_{qn,+} - E_{qn,-},\n\\end{align}\nwhich are the mean energy ($\\bar E_{qn}$) and energy splitting\n($\\Delta_{qn}$) between spin states within one band (i.e. between\n$\\ket{qn,+}$ and $\\ket{qn,-}$); and finally\n\\begin{align}\n  \\Omega_{qn} \\equiv \\Omega^{q,+}_{nn} = \\Omega^{q,-}_{nn},\n  &&\n  \\Lambda_{qn}^x\n  \\equiv \\f12\\p{\\Omega^{q,+}_{n-1,n} + \\Omega^{q,-}_{n-1,n}},\n  &&\n  \\Lambda_{qn}^y\n  \\equiv \\f12\\p{\\Omega^{q,+}_{n-1,n} - \\Omega^{q,-}_{n-1,n}},\n\\end{align}\nwhich are intra-band ($\\Omega_{qn}$) and inter-band ($\\Lambda_{qn}^x$,\n$\\Lambda_{qn}^y$) coupling coefficients, respectively corresponding to\ncoefficients for carrier and side-band transitions.  In terms of these\nquantities, the Hamiltonian from \\eqref{eq:full_H} can be written as\n\\begin{align}\n  H\n  = \\sum_{q,n} \\sp{\\op{qn}\n    \\p{\\bar E_{qn} + \\sp{\\Delta_{qn}-\\delta}S^z - \\Omega_{qn}S^x}\n    - \\Lambda_{qn}^x \\p{a_{qn}^\\dag + a_{qn}}S^x\n    - \\Lambda_{qn}^y i\\p{a_{qn}^\\dag - a_{qn}}S^y},\n  \\label{eq:separated}\n\\end{align}\nwhere we have introduced the on-band spin operators\n$S^j\\equiv\\sigma^j/2$. The full derivation of the Hamiltonian in\n\\eqref{eq:separated} from that in \\eqref{eq:full_H} is provided in\nAppendix \\ref{sec:spin_separation}.\n\nThe operators $a_{qn}+a_{qn}^\\dag$ and $i\\p{a_{qn}^\\dag-a_{qn}}$ in\n\\eqref{eq:separated} can be identified with position and momentum\noperators in a trapped ion Hamiltonian. In this sense we are\nengineering a second type of spin-orbit coupling in the OLC: between\nspin and band modes, which is analogous to coupling between spin and\nvibrational phonon modes in a trapped ion system.\n\n\n\\subsection{Deep lattice approximation}\n\nAs the lattice depth $V_0$ is increased relative to the lattice recoil\nenergy $E_R\\equiv k_L^2/2m$, i.e. when $V_0\\gg E_R$, the energies\n$E_{qns}$ and coupling coefficients $\\Omega^{qs}_{nm}$ lose their\ndependence on quasi-momentum $q$, which implies that\n\\begin{align}\n  \\bar E_{qn} \\to E_n \\equiv \\f1L\\sum_q E_{qn},\n  &&\n  \\Delta_{qn} \\to 0,\n\\end{align}\n\\begin{align}\n  \\Omega_{qn} \\to \\Omega_n \\equiv \\f1L\\sum_q \\Omega_{qn},\n  &&\n  \\Lambda_{qn}^x \\to 0,\n  &&\n  \\Lambda_{qn}^y \\to\n  \\Lambda_n^y \\equiv \\f1L\\sum_q \\Lambda_{qn}^y,\n\\end{align}\nwhere $L$ is the number of lattice sites in the OLC. The fact that\n$\\Lambda_{qn}^x$ vanishes while $\\Lambda_{qn}^y$ is preserved is a\nconsequence of the symmetries of $\\Omega^{qs}_{nm}$, which we derive\nin Appendix \\ref{sec:laser_coupling} and summarize in\n\\eqref{eq:symmetries}. With these simplifications, the single-particle\nHamiltonian in \\eqref{eq:separated} reduces to the simpler form\n\\begin{align}\n  H\n  = \\sum_{q,n}\\sp{\\op{qn}\\p{E_n - \\delta S^z - \\Omega_n S^x}\n    - \\Lambda_n^y i\\p{a_{qn}^\\dag - a_{qn}}S^y}.\n  \\label{eq:deep}\n\\end{align}\nThis Hamiltonian has lost the standard type of spin-orbit coupling\ninvestigated in the 1-D OLC, in that there is no dependence of any\ndynamical variables on the crystal momentum $q$.  Nonetheless, the\nspin-phonon like coupling is preserved through the\n$a_{qn}^\\dag-a_{qn}$ term.\n\n\n\\section{Dynamics}\n\\label{sec:dynamics}\n\nWe now consider the OLC Hamiltonian after diagonalization in\nquasi-momentum, i.e. \\eqref{eq:full_H}, in the interaction picture of\nthe bare energies $E_{qns}-s\\delta/2$:\n\\begin{align}\n  H_I\n  = -\\f12\\sum_{q,n,s,m} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\Delta^{qs}_{nm}+s\\delta}t}\n  b_{qm\\bar s}^\\dag b_{qns},\n  \\label{eq:full_H_I}\n\\end{align}\nwhere $\\Delta^{qs}_{nm}\\equiv E_{qm\\bar s}-E_{qns}$ is the energy gap\nbetween the single-particle states $\\ket{qm\\bar s}$ and $\\ket{qns}$ at\nno detuning ($\\delta=0$). With the ${}^{87}$Sr OLC, in practice the\nRabi frequency $\\Omega$ is much smaller than the energy difference\nbetween two bands, such that\n\\begin{align}\n  \\abs{\\Omega^{qs}_{nm}} < \\Omega\\ll\\abs{\\Delta^{qs}_{nm}}\n  \\label{eq:weak_laser}\n\\end{align}\nfor any $q,n,s$ and $m\\ne n$. Without detuning, all inter-band\ncouplings in \\eqref{eq:full_H_I} therefore vanish by the secular\napproximation. In the trapped ion system, \\eqref{eq:weak_laser}\ncorresponds to having an interrogation laser which is too weak to\nexcite vibrational modes of the ions. While it is possible to set a\nstatic detuning $\\delta$ which bridges the energy difference between\ndifferent bands, doing so will still ultimately result in dynamics\nwhich are reducible to that of a two-level system. In order to induce\nnontrivial multi-band dynamics, we must therefore introduce time\ndependence into the Hamiltonian. A simple means of introducing time\ndependence is to modulate the detuning $\\delta$ or Rabi frequency\n$\\Omega$, which respectively correspond to frequency and amplitude\nmodulation of the clock-state interrogation laser.\n\n\n\\subsection{Frequency modulation}\n\\label{sec:freq_mod}\n\nModulating the detuning as\n$\\delta\\p{t}=\\delta_0-\\tilde\\delta\\cos\\p{\\nu t}$ for some mean\n$\\delta_0$, modulation amplitude $\\tilde\\delta$, and modulation\nfrequency $\\nu$ results in the Hamiltonian\n\\begin{align}\n  H_I\n  = -\\f12\\sum_{\\substack{q,n,s\\\\m,\\kappa}}\n  J\\p{\\kappa,s\\tilde\\delta/\\nu} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\Delta^{qs}_{nm}+s\\delta_0-\\kappa\\nu}t}\n  b_{qm\\bar s}^\\dag b_{qns},\n  \\label{eq:freq_mod_H}\n\\end{align}\nwhere $\\kappa\\in\\Z$ and $J\\p{n,x}$ is the $n$-th order Bessel function\nof the first kind evaluated at $x$. If $\\nu\\gg\\Omega$ and the OLC is\ninitialized in the state $\\ket\\phi=\\ket{q_0n_0s_0}$, then the dynamics\ninduced by \\eqref{eq:freq_mod_H} can be equivalently realized by the\neffective time-independent Hamiltonian\n\\begin{align}\n  H_I^{\\t{eff}}\n  = \\sum_{q,n,s} \\epsilon_{qns}^\\phi b_{qns}^\\dag b_{qns}\n  - \\f12\\sum_{q,n,s,m} J\\p{\\kappa^{qs}_{nm},s\\tilde\\delta/\\nu}\n  \\Omega^{qs}_{nm} b_{qm\\bar s}^\\dag b_{qns},\n  \\label{eq:freq_mod_H_eff}\n\\end{align}\nwhere $\\kappa^{qs}_{nm}\\in\\Z$ minimizes\n$\\abs{\\Delta^{qs}_{nm}+s\\delta_0-\\kappa^{qs}_{nm}\\nu}$ and the reduced\nenergies $\\epsilon_{qns}^\\phi$ satisfy\n\\begin{align}\n  E_{qns} - \\f12s\\delta_0\n  = E_{q_0n_0s_0} - \\f12s_0\\delta_0\n  + \\ell_{qns}^\\phi\\nu + \\epsilon_{qns}^\\phi\n  \\label{eq:reduced_E}\n\\end{align}\nwith $\\ell_{qns}^\\phi\\in\\Z$ and $\\abs{\\epsilon_{qns}^\\phi}<\\nu/2$. The\nderivations of \\eqref{eq:freq_mod_H} and \\eqref{eq:freq_mod_H_eff} are\nprovided in Appendix \\ref{sec:freq_mod_derivation}.\n\n\\begin{figure}[hp]\n  \\captionsetup[subfloat]{farskip=1pt,captionskip=1pt}\n  \\subfloat[First excited band, $V_0=80E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{freq_mod_band_V80.pdf}\n    \\label{fig:freq_mod_band_V80}\n  } \\subfloat[Excited clock state, $V_0=80E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{freq_mod_spin_V80.pdf}\n    \\label{fig:freq_mod_spin_V80}\n  }\n  \\\\\n  \\subfloat[First excited band, $V_0=40E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{freq_mod_band_V40.pdf}\n    \\label{fig:freq_mod_band_V40}\n  } \\subfloat[Excited clock state, $V_0=40E_R$]{\n    \\includegraphics[width=0.45\\textwidth]\n    {freq_mod_spin_V40.pdf}\n    \\label{fig:freq_mod_spin_V40}\n  }\n  \\\\\n  \\subfloat[First excited band, $V_0=10E_R$]{\n    \\includegraphics[width=0.45\\textwidth]\n    {freq_mod_band_V10.pdf}\n    \\label{fig:freq_mod_band_V10}\n  } \\subfloat[Excited clock state, $V_0=10E_R$]{\n    \\includegraphics[width=0.45\\textwidth]\n    {freq_mod_spin_V10.pdf}\n    \\label{fig:freq_mod_spin_V10}\n  }\n  \\caption{Time evolution of states initially in the lowest band\n    ($n=0$) and ground clock state ($s=-1$) subject to the Hamiltonian\n    in \\eqref{eq:freq_mod_H_eff} with a detuning\n    $\\delta=\\Delta\\cos\\p{\\Delta t}$ for $\\Delta$ equal to the mean\n    energy gap between the lowest two bands.  Color indicates the\n    population of the state specified in the captions, which also\n    indicate the lattice depths.  The interaction strength\n    $\\Omega^{0,-}_{1,0}/2\\pi$ is approximately $43~\\t{Hz}$ in a deep\n    lattice with $V_0=80E_R$, $51~\\t{Hz}$ in a medium lattice with\n    $V_0=40E_R$, and $58~\\t{Hz}$ in a shallow lattice with\n    $V_0=40E_R$.  In all cases, $\\Omega=1~\\t{kHz}$.}\n  \\label{fig:freq_mod}\n\\end{figure}\n\nAt zero mean detuning ($\\delta_0=0$), any choice of\n$\\nu=\\Delta^{qs}_{nm}/\\ell$ for $\\ell\\in\\Z$ can, in principle, induce\nmulti-band dynamics.  As an example, Figure \\ref{fig:freq_mod} shows\nthe time evolution of atoms initially in the lowest band and ground\nclock state (i.e. $\\ket{q,0,-}$) subject to a detuning\n$\\delta\\p{t}=\\Delta\\cos\\p{\\Delta t}$, where $\\Delta$ is the mean\nenergy gap between the lowest two bands (vibrational modes).  The\nplots in this figure show the expectation values\n$\\bk{\\op{q}\\otimes\\O_B\\otimes\\O_S}$ over time for\n$\\O_B,\\O_S\\in\\set{\\1,\\op{1}}$ and a variety of lattice depths $V_0$.\nHere $\\O_{B,S}=\\1$ traces out over the corresponding degree of freedom\n(i.e. band or spin), while $\\O_{B,S}=\\op{1}$ appropriately selects out\neither the first excited band or the excited clock state.  The value\nof $\\bk{\\op{q}\\otimes\\op{1}\\otimes\\1}$ thus measures the total\npopulation of atoms in the first excited band (independent of clock\nstate), while $\\bk{\\op{q}\\otimes\\1\\otimes\\op{1}}$ measures the total\npopulation of atoms in the excited clock state (independent of band).\n\nIn a deep lattice ($V_0=80E_R$), the $q$-dependence of the energy gaps\n$\\Delta^{qs}_{nm}$ vanishes. We therefore see no spin-orbit coupling\nin a deep lattice (Figures \\ref{fig:freq_mod_band_V80} and\n\\ref{fig:freq_mod_spin_V80}), as the modulation frequency $\\nu$ is\nresonant with these gaps for all $q$. In the medium depth lattice\n($V_0=40E_R$; Figures \\ref{fig:freq_mod_band_V40} and\n\\ref{fig:freq_mod_spin_V40}), $\\nu$ is only approximately resonant\nwith the energy gaps for all $q$, leading to some spin-orbit\ncoupling. Finally, spin-orbit coupling is most prominent in the\nshallow lattice ($V_0=10E_R$; Figures \\ref{fig:freq_mod_band_V10} and\n\\ref{fig:freq_mod_spin_V10}), in which the energy gaps, and thus OLC\ndynamics, are strongly selective on quasi-momentum. In all cases,\nthere is evidence of spin-phonon-like coupling in the form of common\nfeatures between the excited band and excited clock state populations.\n\n\n\\subsection{Amplitude modulation}\n\\label{sec:amp_mod}\n\nWe can alternately modulate the amplitude of the clock laser as\n$\\Omega\\to\\Omega\\cos\\p{\\nu t}$ for some frequency $\\nu$, which results\nin the Hamiltonian\n\\begin{align}\n  H_I\n  = -\\f14\\sum_{\\substack{q,n,s\\\\m,r}} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\Delta^{qs}_{nm}+s\\delta+r\\nu}t}\n  b_{qm\\bar s}^\\dag b_{qns},\n  \\label{eq:amp_mod_H}\n\\end{align}\nfor $r\\in\\set{-1,1}$. At no detuning, the amplitude modulation\nfrequency $\\nu$ can be chosen to bridge some particular energy gap\n$\\Delta^{qs}_{nm}$ to induce transitions between different\nbands. Similarly to the restriction on dynamics induced by the\ntime-independent OLC Hamiltonian in \\eqref{eq:full_H_I} due to the\nlimitation in \\eqref{eq:weak_laser}, however, in the ${}^{87}$Sr OLC\nthe differences between the different band gaps $\\Delta^{qs}_{nm}$ are\ngenerally larger than the Rabi coupling $\\Omega$. The dynamics of the\nOLC with amplitude modulation of the clock laser at no detuning thus\ngenerally reduces to that of a two-level system.\n\nWhile most choices of detuning $\\delta$ do not change the above\nargument, the symmetric effect of $\\delta$ on different clock states\nmeans that it is possible to engineer four-level dynamics in the OLC\nfor quasi-momenta $q$ with\n$\\Delta^{q,-}_{nm}\\approx\\Delta^{q,+}_{nm}$. Letting\n\\begin{align}\n  \\utilde\\Delta^{qs}_{nm}\n  \\equiv \\Delta^{qs}_{nm} + s\\delta\n  = \\p{E_{qm\\bar s} - \\f12\\bar s\\delta} - \\p{E_{qns} - \\f12s\\delta}\n\\end{align}\nbe the total band gap between $\\ket{qm\\bar s}$ and $\\ket{qns}$ at\ndetuning $\\delta$, if $\\Delta^{0,-}_{nm}=\\Delta^{0,+}_{nm}$ and we set\n$\\delta\\approx\\Delta^{0,\\pm}_{1,0}/2$, for example, then one can work\nout that\n\\begin{align}\n  \\utilde\\Delta^{0,+}_{0,0}\n  = \\utilde\\Delta^{0,-}_{1,0}\n  = \\utilde\\Delta^{0,+}_{1,1}\n  = \\Delta^{0,\\pm}_{1,0}/2\n  \\approx \\delta\n  \\label{eq:gaps}\n\\end{align}\nSetting $\\nu=\\delta$ then simultaneously couples\n$\\ket{0,0,-}\\leftrightarrow\\ket{0,0,+}\n\\leftrightarrow\\ket{0,1,-}\\leftrightarrow\\ket{0,1,+}$, while coupling\nto all higher bands can be neglected by the secular approximation.\n\n\\begin{figure}\n  \\captionsetup[subfloat]{farskip=1pt,captionskip=1pt}\n  \\subfloat[$V_0=10E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{qns_bands_detuned_V10.pdf}\n    \\label{fig:test}\n  } \\subfloat[$V_0=40E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{qns_bands_detuned_V40.pdf}\n    \\label{fig:test2}\n  }\n  \\caption{Band diagrams of the Sr-87 OLC with a detuning\n    $\\delta=\\Delta/2$ for two lattice depths $V_0$.  Legends indicate\n    the clock state (spin) for each line.}\n  \\label{fig:bands_detuned}\n\\end{figure}\n\nFigure \\ref{fig:bands_detuned} shows the band diagrams which results\nfrom setting $\\delta=\\Delta/2$ with lattice depths of $V_0=10E_R$ and\n$V_0=40E_R$. While the energy gaps between the first four energy\nlevels (corresponding to both clock states in the lowest two bands)\nare identical (at $q=0$), the gap to the fifth level (in the third\nband) is different by an amount sufficiently large to make the fifth\nlevel off-resonant for state transition.\n\nFigure \\ref{fig:amp_mod} shows the time evolution of atoms initially\nin the lowest band and ground clock state (i.e. $\\ket{q,0,-}$) subject\nto a static detuning $\\delta=\\Delta/2$ and amplitude modulation with\nfrequency $\\nu=\\Delta/2$. As before, spin-orbit coupling is most\nprominent in a shallow lattice, and is suppressed in a deep lattice;\nspin-phonon-like coupling is present for all lattice depths.\n\nNote that similarly to the case in Section \\ref{sec:freq_mod}, if\n$\\nu\\gg\\Omega$ and the OLC is initialized in the state\n$\\ket\\phi=\\ket{q_0n_0s_0}$, then dynamics induced by\n\\eqref{eq:amp_mod_H} may be equivalently realized by the effective\ntime-independent Hamiltonian\n\\begin{align}\n  H_I^{\\t{eff}}\n  = \\sum_{q,n,s} \\epsilon_{qns}^\\phi b_{qns}^\\dag b_{qns}\n  - \\f14\\sum_{q,n,s,m} C\\p{\\kappa^{qs}_{nm}} \\Omega^{qs}_{nm}\n  b_{qm\\bar s}^\\dag b_{qns}\n\\end{align}\nwhere $\\kappa^{qs}_{nm}\\in\\Z$ minimizes\n$\\abs{\\Delta^{qs}_{nm}+s\\delta_0-\\kappa^{qs}_{nm}\\nu}$;\n$C\\p{\\kappa}\\equiv1$ when $\\abs{\\kappa}=1$ and $C\\p{\\kappa}\\equiv0$\notherwise; and the reduced energies $\\epsilon_{qns}^\\phi$ satisfy\n\\eqref{eq:reduced_E} with $\\ell_{qns}^\\phi\\in\\Z$ and\n$\\abs{\\epsilon_{qns}^\\phi}<\\nu/2$.\n\n\\begin{figure}[h!]\n  \\captionsetup[subfloat]{farskip=1pt,captionskip=1pt}\n  \\subfloat[First excited band, $V_0=80E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_band_V80.pdf}\n    \\label{fig:amp_mod_band_V80}\n  } \\subfloat[Excited clock state, $V_0=80E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_spin_V80.pdf}\n    \\label{fig:amp_mod_spin_V80}\n  }\n  \\\\\n  \\subfloat[First excited band, $V_0=40E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_band_V40.pdf}\n    \\label{fig:amp_mod_band_V40}\n  } \\subfloat[Excited clock state, $V_0=40E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_spin_V40.pdf}\n    \\label{fig:amp_mod_spin_V40}\n  }\n  \\\\\n  \\subfloat[First excited band, $V_0=10E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_band_V10.pdf}\n    \\label{fig:amp_mod_band_V10}\n  } \\subfloat[Excited clock state, $V_0=10E_R$]{\n    \\includegraphics[width=0.45\\textwidth]{amp_mod_spin_V10.pdf}\n    \\label{fig:amp_mod_spin_V10}\n  }\n  \\caption{Plots corresponding to those in Figure \\ref{fig:freq_mod},\n    but for a static detuning $\\delta=-\\Delta/2$ and amplitude\n    modulated clock laser which takes\n    $\\Omega\\to\\Omega\\cos\\p{\\Delta t}$.}\n  \\label{fig:amp_mod}\n\\end{figure}\n\n\n\\newpage\n\\appendix\n\n\\section{Properties of the laser-induced coupling constants}\n\\label{sec:laser_coupling}\n\nSpatial eigenfunctions of atoms on a 1-D periodic lattice are indexed\nby quasi-momentum $q$ and band $n$, and take the form\n\\begin{align}\n  \\bk{z|qn}\n  = \\phi_{qn}\\p{z}\n  = e^{iqz} u_{qn}\\p{z}\n  = e^{iqz} \\sum_{\\kappa=-\\infty}^\\infty c_{qn}^{(\\kappa)} e^{i2k_L z\\kappa},\n\\end{align}\nwhere $k_L$ is the wavenumber of the lattice photons, and all\ncoefficients $c_{qn}^{(\\kappa)}\\in\\mathbb R$.  We can thus expand\n\\begin{align}\n  \\Omega^{qns}_{gm}\n  \\equiv \\Omega\\bk{gm|e^{-iskz}|qn}\n  = \\Omega \\int dz~ e^{i\\p{q-sk-g}z}\n  \\sum_{\\kappa,\\ell} e^{i2k_Lz\\p{\\kappa-\\ell}}\n  c_{gm}^{(\\ell)} c_{qn}^{(\\kappa)},\n\\end{align}\nwhich vanishes unless $g\\approx q-sk$\\footnote{This claim is formally\n  a stationary phase approximation, and becomes exact if $k$ is\n  commensurate with the lattice.} and $\\kappa=\\ell$, so\n$\\Omega^{qns}_{gm}\\approx\\Omega^{qns}_{q-sk,m}\\delta_{g,q-sk}$ only\ncouples the state $\\ket{qns}$ to $\\ket{q-sk,m\\bar s}$.  Defining\n\\begin{align}\n  \\Omega^{qs}_{nm}\n  \\equiv \\Omega^{q+sk/2,ns}_{q-sk/2,m}\n  = \\Omega \\sum_\\kappa c_{q-sk/2,m}^{(\\kappa)} c_{q+sk/2,n}^{(\\kappa)},\n\\end{align}\nwe can say that\n\\begin{align}\n  \\Omega^{qs}_{nm}\n  = \\Omega^{q+sk/2,ns}_{q-sk/2,m}\n  = \\p{\\Omega^{q+sk/2,ns}_{q-sk/2,m}}^*\n  = \\Omega^{q-sk/2,m\\bar s}_{q+sk/2,n}\n  = \\Omega^{q+\\bar sk/2,m\\bar s}_{q-\\bar sk/2,n}\n  = \\Omega^{q\\bar s}_{mn}.\n  \\label{eq:flip_both}\n\\end{align}\nWe can also use the fact that\n$\\phi_{qn}\\p{z}=\\p{-1}^n\\phi_{-q,n}\\p{z}^*$ to say\n\\begin{align}\n  \\Omega^{qs}_{nm}\n  = \\Omega\\int dz~ \\phi_{q-sk/2,m}\\p{z}^* \\phi_{q+sk/2,n}\\p{z}\n  = \\p{-1}^{n+m}\\Omega^{-q,s}_{mn}.\n  \\label{eq:flip_bands}\n\\end{align}\nTo summarize \\eqref{eq:flip_both} and \\eqref{eq:flip_bands}:\n\\begin{align}\n  \\Omega^{qs}_{nm}\n  = \\p{-1}^{n+m} \\Omega^{-q,s}_{mn}\n  = \\p{-1}^{n+m} \\Omega^{-q,\\bar s}_{nm}\n  = \\Omega^{q\\bar s}_{mn}.\n  \\label{eq:symmetries}\n\\end{align}\n\n\n\\section{Separating out the pseudo-spin degree of freedom}\n\\label{sec:spin_separation}\n\nWe start with the 1-D OLC Hamiltonian after diagonalization in\nquasi-momentum, i.e.\n\\begin{align}\n  H\n  = \\sum_{q,n,s}\\p{E_{qns}-\\f12s\\delta} b_{qns}^\\dag b_{qns}\n  - \\f12\\sum_{q,n,s,m} \\Omega^{qs}_{nm} b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nand define\n\\begin{align}\n  \\bar E_{qn} \\equiv \\f12\\p{E_{qn,+} + E_{qn,-}},\n  &&\n  \\Delta_{qn} \\equiv E_{qn,+} - E_{qn,-},\n\\end{align}\n\\begin{align}\n  \\Omega_{qn} \\equiv \\Omega^{q,+}_{nn} = \\Omega^{q,-}_{nn},\n  &&\n  \\Lambda^{qs}_{nm}\n  \\equiv \\Omega^{qs}_{n,n-m} = \\Omega^{q\\bar s}_{n-m,n},\n\\end{align}\nin terms of which\n\\begin{multline}\n  H = \\sum_{q,n,s}\\sp{\\p{\\bar E_{qn} + \\f12 s \\sp{\\Delta_{qn}-\\delta}}\n    b_{qns}^\\dag b_{qns}\n    - \\f12\\Omega_{qn} b_{qn\\bar s}^\\dag b_{qns}} \\\\\n  - \\f12\\sum_{\\substack{q,n,s\\\\0<m\\le n}}\\Lambda^{qs}_{nm}\n  \\p{b_{q,n-m,\\bar s}^\\dag b_{qns} + b_{qns}^\\dag b_{q,n-m,\\bar s}}.\n  \\label{eq:lambda}\n\\end{multline}\nIn order to separate out the spin degree of freedom, we consider only\nat most single-particle occupation of each quasi-momentum, and define\nthe ``lowering operators'' $a_{qnm}\\equiv\\op{q,n-m}{qn}$ in addition\nto the on-band spin operators $S^j\\equiv\\sigma^j/2$ which act only on\nthe spin degree of freedom.  We can rewrite \\eqref{eq:lambda} in terms\nof these operators for single particles as\n\\begin{align}\n  H\n  = \\sum_{q,n} \\op{qn}\\sp{\\bar E_{qn}\n    + \\p{\\Delta_{qn}-\\delta} S^z - \\Omega_{qn} S^x}\n  - \\sum_{\\substack{q,n\\\\0<m\\le n}}\\Lambda^{qs}_{nm}\n  \\p{a_{qnm} S^{\\bar s} + a_{qnm}^\\dag S^s}.\n\\end{align}\nWe now expand\n\\begin{multline}\n  \\sum_s\\Lambda^{qs}_{nm}\\p{a_{qnm} S^{\\bar s} + a_{qnm}^\\dag S^s} =\n  \\Lambda^{q,+}_{nm}\\p{a_{qnm}S^- + a_{qnm}^\\dag S^+}\n  + \\Lambda^{q,-}_{nm}\\p{a_{qnm}S^+ + a_{qnm}^\\dag S^-} \\\\\n  = \\f12S^x \\p{\\Lambda^{q,+}_{nm} + \\Lambda^{q,-}_{nm}} \\p{a_{qnm} +\n    a_{qnm}^\\dag} + \\f12 iS^y \\p{\\Lambda^{q,+}_{nm} -\n    \\Lambda^{q,-}_{nm}} \\p{-a_{qnm} + a_{qnm}^\\dag},\n\\end{multline}\nwhich motivates the definitions\n\\begin{align}\n  \\Lambda_{qnm}^x\n  \\equiv \\f12\\p{\\Lambda^{q,+}_{nm} + \\Lambda^{q,-}_{nm}}\n  = \\f12\\p{\\Omega^{q,+}_{n-m,n} + \\Omega^{q,-}_{n-m,n}}\n  = \\f12\\p{\\Omega^{q,+}_{n-m,n} + \\p{-1}^m\\Omega^{-q,+}_{n-m,n}}, \\\\\n  \\Lambda_{qnm}^y\n  \\equiv \\f12\\p{\\Lambda^{q,+}_{nm} - \\Lambda^{q,-}_{nm}}\n  = \\f12\\p{\\Omega^{q,+}_{n-m,n} - \\Omega^{q,-}_{n-m,n}}\n  = \\f12\\p{\\Omega^{q,+}_{n-m,n} - \\p{-1}^m\\Omega^{-q,+}_{n-m,n}},\n\\end{align}\nsuch that\n\\begin{multline}\n  H = \\sum_{q,n}\\op{qn}\n  \\sp{\\bar E_{qn} + \\p{\\Delta_{qn}-\\delta}S^z - \\Omega_{qn}S^x} \\\\\n  - \\sum_{\\substack{q,n\\\\m>0}}\n  \\sp{\\Lambda_{qnm}^x \\p{a_{qnm}^\\dag + a_{qnm}}S^x\n    + \\Lambda_{qnm}^y i\\p{a_{qnm}^\\dag - a_{qnm}}S^y}.\n\\end{multline}\nLetting $a_{qn}\\equiv a_{qn,1}$;\n$\\Lambda_{qn}^j\\equiv\\Lambda_{qn,1}^j$ for $j=x,y$; and neglecting all\ninter-band (side-band) couplings beyond nearest bands, we arrive at\nthe Hamiltonian given in \\eqref{eq:separated}:\n\\begin{align}\n  H\n  = \\sum_{q,n} \\sp{\\op{qn}\n    \\p{\\bar E_{qn} + \\sp{\\Delta_{qn}-\\delta}S^z - \\Omega_{qn}S^x}\n    - \\Lambda_{qn}^x \\p{a_{qn}^\\dag + a_{qn}}S^x\n    - \\Lambda_{qn}^y i\\p{a_{qn}^\\dag - a_{qn}}S^y}.\n\\end{align}\n\n\n\\section{Frequency modulation of the clock laser}\n\\label{sec:freq_mod_derivation}\n\nIn the interaction picture of the single-particle state energies\n$E_{qns}-s\\delta/2$, the Hamiltonian of the 1-D OLC is\n\\begin{align}\n  H_I\n  = - \\f12\\sum_{q,n,s,m} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\Delta^{qs}_{nm}+s\\delta}t} b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nwhere $\\Delta^{qs}_{nm}\\equiv E_{qm\\bar s}-E_{qns}$ is the energy gap\nbetween the single-particle states $\\ket{qm\\bar s}$ and $\\ket{qns}$ at\nno detuning. If we modulate the detuning as\n$\\delta\\p{t}=\\delta_0-\\tilde\\delta\\cos\\p{\\nu t}$ for some mean\n$\\delta_0$, modulation amplitude $\\tilde\\delta$, and modulation\nfrequency $\\nu$, then the Hamiltonian becomes\n\\begin{align}\n  H_I\n  = - \\f12\\sum_{q,n,s,m} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\utilde\\Delta^{qs}_{nm}t-is\\tilde\\delta\\sin\\p{\\nu t}/\\nu}\n  b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nwhere\n\\begin{align}\n  \\utilde\\Delta^{qs}_{nm}\n  \\equiv \\Delta^{qs}_{nm} + s\\delta_0\n  = \\p{E_{qm\\bar s}-\\f12\\bar s\\delta_0} - \\p{E_{qns}-\\f12s\\delta_0}\n  = \\utilde E_{qm\\bar s} - \\utilde E_{qns}.\n\\end{align}\nis the total band gap between $\\ket{qm\\bar s}$ and $\\ket{qns}$ at the\nmean detuning $\\delta_0$ and\n$\\utilde E_{qns}\\equiv E_{qns}-\\f12s\\delta_0$.\n\nLetting $\\tau\\equiv\\nu t$ and $\\beta\\equiv\\tilde\\delta/\\nu$, the\nexponential $\\exp\\p{is\\beta\\sin\\tau}$ is periodic in $\\tau$ with\nperiod $2\\pi$, which means that we can expand it in a Fourier series\nas\n\\begin{align}\n  e^{-is\\beta\\sin\\tau}\n  = \\sum_{\\kappa=-\\infty}^\\infty e^{-i\\kappa\\tau}\\f1{2\\pi}\n  \\int_{-\\pi}^\\pi dx~ e^{i\\kappa x - is\\beta\\sin x}\n  = \\sum_\\kappa J\\p{\\kappa,s\\beta} e^{-i\\kappa\\tau}\n\\end{align}\nwhere $J\\p{n,x}$ is the $n$-th order Bessel function of the first kind\nevaluated at $x$. It follows that\n\\begin{align}\n  H_I\n  = -\\f12\\sum_{\\substack{q,n,s\\\\m,\\kappa}}\n  J\\p{\\kappa,s\\tilde\\delta/\\nu} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\utilde\\Delta^{qs}_{nm}-\\kappa\\nu}t}\n  b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nwhich is precisely the Hamiltonian given in\n\\eqref{eq:freq_mod_H}. Letting $\\kappa^{qs}_{nm}\\in\\Z$ minimize\n$\\abs{\\utilde\\Delta^{qs}_{nm}-\\kappa^{qs}_{nm}\\nu}$ and assuming that\n$\\nu\\gg\\Omega$, by the secular approximation\n\\begin{align}\n  H_I\n  = -\\f12\\sum_{q,n,s,m}\n  J\\p{\\kappa^{qs}_{nm},s\\tilde\\delta/\\nu} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\utilde\\Delta^{qs}_{nm}-\\kappa^{qs}_{nm}\\nu}t}\n  b_{qm\\bar s}^\\dag b_{qns}.\n  \\label{eq:freq_mod_H_derived}\n\\end{align}\nIf an atom in the OLC is initially in the state\n$\\ket\\phi=\\ket{q_0n_0s_0}$, then the only relevant states for all OLC\ndynamics will be those for which\n\\begin{align}\n  \\utilde E_{qns}\n  = \\utilde E_{q_0n_0s_0} + \\ell_{qns}^\\phi\\nu + \\epsilon_{qns}^\\phi\n  \\label{eq:relevant_condition}\n\\end{align}\nwith $\\ell_{qns}^\\phi\\in\\Z$ and reduced energies $\\epsilon_{qns}^\\phi$\nsatisfying $\\abs{\\epsilon_{qns}^\\phi}\\lesssim\\Omega\\ll\\nu$. For all\nrelevant states, therefore,\n\\begin{align}\n  \\utilde\\Delta^{qs}_{nm} - \\kappa^{qs}_{nm}\\nu\n  = \\utilde E_{qm\\bar s} - \\utilde E_{qns} - \\kappa^{qs}_{nm}\\nu\n  = \\p{\\ell_{qm\\bar s}^\\phi - \\ell_{qns}^\\phi - \\kappa^{qs}_{nm}}\\nu\n  + \\epsilon_{qm\\bar s}^\\phi - \\epsilon_{qns}^\\phi.\n\\end{align}\nAs $\\abs{\\epsilon_{qm\\bar s}^\\phi-\\epsilon_{qns}^\\phi}<\\nu/2$ for all\nrelevant $q,n,s,m$, minimizing\n$\\abs{\\utilde\\Delta^{qs}_{nm}-\\kappa^{qs}_{nm}\\nu}$ forces\n$\\kappa^{qs}_{nm}=\\ell_{qm\\bar s}^\\phi-\\ell_{qns}^\\phi$. The\nHamiltonian in \\eqref{eq:freq_mod_H_derived} is then\n\\begin{align}\n  H_I\n  = -\\f12\\sum_{q,n,s,m}\n  J\\p{\\kappa^{qs}_{nm},s\\tilde\\delta/\\nu} \\Omega^{qs}_{nm}\n  \\exp\\sp{i\\p{\\epsilon_{qm\\bar s}^\\phi-\\epsilon_{qns}^\\phi}t}\n  b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nand, with appropriate choice of interaction picture, is equivalent to\nthe effective Hamiltonian\n\\begin{align}\n  H_I^{\\t{eff}}\n  = \\sum_{q,n,s} \\epsilon_{qns}^\\phi b_{qns}^\\dag b_{qns}\n  - \\f12\\sum_{q,n,s,m} J\\p{\\kappa^{qs}_{nm},s\\tilde\\delta/\\nu}\n  \\Omega^{qs}_{nm} b_{qns}^\\dag b_{qm\\bar s},\n  \\label{eq:freq_mod_H_eff_derived}\n\\end{align}\nwhich has the great advantage over \\eqref{eq:freq_mod_H_derived} of\nlacking time dependence. In using \\eqref{eq:freq_mod_H_eff_derived}\nfor e.g. computing a propagator or otherwise simulating OLC dynamics,\nthere is no need to actually keep track of which states are\n``relevant'', as all irrelevant states will generally have reduced\nenergies $\\epsilon_{qns}^\\phi\\sim\\nu/2\\gg\\Omega$, and therefore\nautomatically decouple from all relevant states. A similar trick can\nbe used to effectively simulate OLC dynamics with amplitude modulation\nas in \\eqref{eq:amp_mod_H}, which results in the Hamiltonian\n\\begin{align}\n  H_I^{\\t{eff}}\n  = \\sum_{q,n,s} \\epsilon_{qns}^\\phi b_{qns}^\\dag b_{qns}\n  - \\f14\\sum_{q,n,s,m} C\\p{\\kappa^{qs}_{nm}} \\Omega^{qs}_{nm}\n  b_{qm\\bar s}^\\dag b_{qns},\n\\end{align}\nfor $C\\p{\\kappa}\\equiv1$ when $\\abs{\\kappa}=1$ and\n$C\\p{\\kappa}\\equiv0$ otherwise.\n\n\\end{document}\n", "meta": {"hexsha": "ca31a7022fe1c8b30edf0f03fed435101f9452d2", "size": 34502, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "olc_soc/olc_writeup.tex", "max_stars_repo_name": "perlinm/rey_research", "max_stars_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "olc_soc/olc_writeup.tex", "max_issues_repo_name": "perlinm/rey_research", "max_issues_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "olc_soc/olc_writeup.tex", "max_forks_repo_name": "perlinm/rey_research", "max_forks_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5905882353, "max_line_length": 77, "alphanum_fraction": 0.6995536491, "num_tokens": 12123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41731327666376455}}
{"text": "\\section{Stochastic Inference of Surface-Induced Effects Using Brownian Motion}\n\\label{chap3}\n\n\\subsection{Confined Brownian motion theory}\n\\label{sec:confined}\nBy observing the experimental trajectory along the $z$-axis of a particle of $1.5 ~ \\mathrm{\\mu m} $ radius as shown in Fig.~\\ref{Fig:exp_z_traj}, one can notice that the particle's height does not get higher than approximately $4 ~ \\mathrm{\\mu m}$. Indeed, due to gravity, a colloid is confined near the surface. This confinement induces near-wall effects, such as hindered mobility and electrostatic interactions. \n\nIn the first part of this chapter, I will detail the theory of confined Brownian motion and how to numerically simulate it. In a second part, I will present how to analyze experimental data. In particular, I will detail a multi-fitting procedure that enables thermal-noise-limited inference of diffusion coefficients spatially resolved at the nanoscale, equilibrium potentials, and forces at the femtonewton resolution.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/traj_z/traj_z.pdf}\n\t\\caption{Experimental trajectory of a polystyrene particle of radius $a = 1.5 ~ \\mathrm{\\mu m}$ in water near a glass wall ($z = 0$) along the $z$-axis --- \\textit{i.e} perpendicular to the wall. \\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/traj_z/graph_ploting.ipynb}{\\faGithub}}\n\t\\label{Fig:exp_z_traj}\n\\end{figure}\n\n\\subsubsection{Gravitational potential}\n\\label{sec:gravit}\n\n\nThe density $\\rho_\\mathrm{p}$ of an observed colloid is different from the medium density $\\rho_\\mathrm{m}$. In our experiment, we used water whose density is $\\rho_\\mathrm{m} = 1000 ~ \\mathrm{kg.m^{-3}}$. Thus, the particles are subject to gravitational potential given by:\n\n\\begin{equation}\n\tU_\\mathrm{g} (z) = \\Delta m g z = \\frac{4}{3}\\pi a ^3 g \\Delta \\rho z ~,\n\t\\label{eq:ug_full}\n\\end{equation}\n\nwhere $\\Delta m$ is the difference between the mass of the particle and that of a fluid sphere of the same size, $\\Delta \\rho = \\rho_\\mathrm{m} - \\rho_\\mathrm{p}$ is the corresponding density difference, and $g$ is the gravitational acceleration. By invoking the definition of the Boltzmann length:\n\n\\begin{equation}\n\t\\ell _\\mathrm{B} = \\frac{k_\\mathrm{B}T}{(4/3) \\pi a ^3 \\Delta \\rho g } ~,\n\t\\label{lB}\n\\end{equation}\n\none can rewrite Eq.~(\\ref{eq:ug_full}) as:\n\n\\begin{equation}\n\tU_\\mathrm{g}(z) = \\frac{k_\\mathrm{B}T}{\\ell _\\mathrm{B}}z ~.\n\t\\label{eq:ug}\n\\end{equation}\n\nThe Boltzmann length $\\ell_\\mathrm{B}$ corresponds to the spatial extent over which the change of gravitational energy equals thermal energy. This distance was first measured by Perrin \\cite{perrin_les_2014}. To do so, using a microscope he counted the number of colloidal particles as a function of the height in the sample. Then, he reconstructed the concentration profile of the colloidal suspension that exponentially decays as $\\mathrm{e}^{- z / \\ell _\\mathrm{B}}$. As an example, for a polystyrene particle of radius $a  = 1.5 ~ \\mathrm{\\mu m}$ in water, one has $\\ell _\\mathrm{B} = 580 ~ \\mathrm{nm}$.\n\nFor systems with $\\ell _\\mathrm{B} \\gg h $, where $h$ is the vertical thickness of the sample, one can consider that the particle does not feel gravity. This is particularly the case when the densities of the colloids and the fluid are equal. In this particular case, one has $\\ell _\\mathrm{B} = \\infty$. Thus, density matching can be a way to do gravity-free experiments. In our experiment, we want to measure confinement-induced effects. Therefore, we need gravity for particles to be driven towards the substrate. As particles get larger or denser, $\\ell _\\mathrm{B}$ decreases and particles are, on average, closer to the substrate. \n\n\n\\subsubsection{Sphere-wall interactions}\n\\label{Section:sphere-wall}\n\n\n\nAs we have seen, external forces such as gravity act on the particles. As Brownian particles are close to a wall, we can also expect some interactions between the particles and the wall. In our case, we suppose that the Brownian particles do not interact with each other, as we consider dilute solutions only. Indeed, the studied particles are at least $50 ~ \\mathrm{\\mu m}$ apart from each other, which corresponds to 10 times their size for the largest beads. \n\nTo describe the interaction between a Brownian particle and the wall, we use the DLVO theory, named after Derjaguin, Landau, Verwey, and Overbeek \\cite{israelachvili_intermolecular_2015}. This theory was first developed to describe the interactions between colloids, and explains the stability of colloidal suspensions. It involves two force components; the Hamaker force which arises from van der Waals interactions between the molecules of the two surfaces and a screened electrostatic force due to a double layer of charges formed near each surface, and involving the ions present in the solution. \n\n\\paragraph{Double layer interactions}\\mbox{}\\\\\n\\label{subsec:double}\n\\vspace{0.10cm}\n\n\nWhen a surface is immersed in water, it usually acquire charges \\cite{israelachvili_intermolecular_2015} due to a high water dielectric constant $\\epsilon = \\epsilon_0 \\epsilon_\\mathrm{r}$, where $\\epsilon_0$ is the vacuum permittivity and $\\epsilon_\\mathrm{r}$ the medium relative permittivity; for water $\\epsilon_\\mathrm{r} = 80$. Commonly, surface charging is done through the ionization of  surface groups\\footnote{For example, the dissociation of protons from surface carboxylic groups \\cite{israelachvili_intermolecular_2015} ($-$COOH $\\rightarrow$ -COO$^-$ + H$^+$) which charges negatively the surface.}, or from the binding of ions from the solution --- for example, adsorption of $-$OH$^-$ onto the water-air interface that charges it negatively. In the bulk, a fluid is electrically neutral; thus the fluid contains as equal number of ions of opposite charges (including the proper stoichiometry due to ionic valencies). However, when a surface is negatively charged, the negative ions are repelled from it, while positive ions are attracted towards it.  Therefore, a double-layer charge distribution is formed near the surface, as shown in Fig.~\\ref{Fig:double_layer}. Experimentally, we use glass slides and polystyrene beads that are both negatively charged in water leading to a repulsive interaction between them. This repulsive force prevents the colloids from sticking together, or to the substrate's surface.\n\nThe DLVO theory states that the electrostatic potential $\\Psi(\\vec{r})$ generated by an ion of one given species $i$ at a distance $\\vec{r}$ satisfies the Poisson equation \\cite{israelachvili_intermolecular_2015}:\n\n\\begin{equation}\n\t\\nabla ^2 \\Psi(\\vec{r}) = -\\frac{1}{\\epsilon_\\mathrm{r} \\epsilon_0}  \\rho_\\mathrm{e}(\\vec{r})~,\n\t\\label{Eq:poisson}\n\\end{equation}\n\nwith:\n\n\\begin{equation}\n\t\\rho_\\mathrm{e}(\\vec{r}) = e \\sum _i z_i c_i (\\vec{r}) ~,\n\t\\label{Eq.3}\n\\end{equation}\n\n\\begin{figure}\n\t\\includegraphics{02_body/chapter3/images/double_layer.pdf}\n\t\\caption{A colloid diffusing near a wall. Both the wall and colloid surfaces charge negatively. As a consequence, a layer of positively-charged ions is attracted towards each surface, forming a double layer.}\n\t\\label{Fig:double_layer}\n\\end{figure}\n\n\nthe local charge density, where $e$ is the elementary charge, and where the index $i$ denotes an ionic species of valence $z_i$ and local ionic concentration $c_i$ (number density). If the solution is at thermodynamic equilibrium, the local ionic density is given by a Gibbs-Boltzmann distribution, as:\n\n\\begin{equation}\n\tc_i(\\vec{r}) = c_i ^0 \\textnormal{exp}\\left(\\frac{-z_i e \\Psi(\\vec{r})}{k_\\mathrm{B} T }\\right) ~,\n\t\\label{Eq.4}\n\\end{equation}\n\n\nwhere $c_i ^0$ is the bulk concentration (number density) of the ionic species $i$. By combining Eqs.~(\\ref{Eq:poisson}),~(\\ref{Eq.3})~and~(\\ref{Eq.4}), one obtains the Poisson-Boltzmann equation:\n\n\\begin{equation}\n\t\\nabla ^2 \\Psi (\\vec{r}) + \\sum_i \\frac{z_i e c_i^0}{\\epsilon_0 \\epsilon_\\mathrm{r}} \\exp \\left( - \\frac{z_i e \\Psi (\\vec{r})}{k_\\mathrm{B}T} \\right) = 0 ~.\n\t\\label{Eq:Poisson-boltzmann}\n\\end{equation}\n\nSince Eq.~(\\ref{Eq:Poisson-boltzmann}) is nonlinear, it is typically solved numerically. However, for some simple configurations such as uniformly-charged plane or sphere it can be solved analytically. To simplify, let us consider that we have a monovalent electrolyte, meaning that the electrolyte is composed of two ions of valencies both equal to 1 --- Na$^+$ Cl$^-$ for example --- and $c_i ^0$ is equal to the bulk electrolytic concentration $c_s^0$. In such a case, Eq.~(\\ref{Eq:Poisson-boltzmann}) simplifies and becomes:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t&\\nabla ^2 \\Psi (\\vec{r}) + \\frac{e c_s ^0}{\\epsilon_0 \\epsilon_\\mathrm{r}} \\left[ \\exp \\left( \\frac{-e\\Psi(\\vec{r})}{k_\\mathrm{B}T} \\right) -  \\exp \\left( \\frac{+e\\Psi(\\vec{r})}{k_\\mathrm{B}T} \\right) \\right] = 0 \\\\\n\t\t&\\nabla ^2 \\Psi (\\vec{r}) + 2 \\frac{e c_s ^0}{\\epsilon_0 \\epsilon_\\mathrm{r}} \\mathrm{sinh}  \\left( \\frac{e\\Psi(\\vec{r})}{k_\\mathrm{B}T} \\right) = 0 ~.\n\t\\end{aligned}\n\\end{equation}\n\n\nAnother situation leading to analytical results, is when $\\Psi$ is small enough such that $e\\Psi \\ll k_\\mathrm{B} T$, which is generally the case when using dilute enough solutions, it is possible, through a Taylor expansion at first order to write:\n\n\\begin{equation}\n\t\\exp \\left( - \\frac{z_i e \\Psi(\\vec{r})}{k_\\mathrm{B}T} \\right) \\simeq 1 - \\frac{z_i e \\Psi (\\vec{r})}{k_\\mathrm{B}T} ~.\n\\end{equation}\n\nIn such case, Eq.~(\\ref{Eq:Poisson-boltzmann}) becomes:\n\n\\begin{equation}\n\t\\nabla ^2 \\Psi (\\vec{r}) + \\sum_i \\frac{z_i e c_i^0}{\\epsilon_0 \\epsilon_\\mathrm{r}}  \\left( 1 - \\frac{z_i e \\Psi (\\vec{r})}{k_\\mathrm{B}T} \\right)  = 0~.\n\t\\label{Eq:poisson_b_3}\n\\end{equation}\n\nIn addition, a fluid is electrically neutral. Therefore, $\\sum_i z_i c_i^0 = 0$. Thus, one can simplify Eq.~(\\ref{Eq:poisson_b_3}) to get the Debye-Hückel equation:\n\n\\begin{equation}\n\t\\nabla^2 \\Psi (\\vec{r}) = \\left[  \\sum_i \\frac{z_i ^2 e^2 c_i^0}{\\epsilon_0 \\epsilon_\\mathrm{r}  k_\\mathrm{B} T}    \\right] \\Psi (\\vec{r}) ~.\n\t\\label{debh1}\n\\end{equation}\n\nOne can identify the term between brackets as the inverse of a length squared. We thus define the Debye length as:\n\n\\begin{equation}\n\t\\ell _\\mathrm{D} =  \\sqrt{ \\sum_i\\frac {\\epsilon_0 \\epsilon_\\mathrm{r} k_\\mathrm{B} T} {z_i ^2 e^2 c_i^0}} ~,\n\t\\label{ld1}\n\\end{equation}\n\nwhich is the characteristic ion-induced screening length of the electrostatic interactions, as we will see below. For a monovalent electrolyte,  at 25 \\textdegree C, the Debye length of an aqueous solution is:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\ell _\\mathrm{D} &= \\sqrt{\\frac{ 2 \\epsilon_0 \\epsilon_\\mathrm{r} k_\\mathrm{B}T}{c_s^0 e^2}}\n\t\t& = \\frac{0.304 }{ \\sqrt{C} } ~\\mathrm{nm} ~,\n\t\\end{aligned}\n\t\\label{ldnacl}\n\\end{equation}\n\n\nwith $C$ the value of the molar concentration in $\\mathrm{mol.L^{-1}}$:\n\n\\begin{equation}\n\tC = \\frac{c_\\mathrm{s} ^0}{N_\\mathrm{A}} 10^{-3} ~. \n\\end{equation}\n\n\nFor example, for NaCl salt in water,  $\\ell_\\mathrm{D} \\approx 100 ~ \\mathrm{nm}$ for a concentration  $C = [\\mathrm{NaCl}] = 9.2 ~ \\mathrm{\\mu mol.L^{-1}}$ and   $\\ell_\\mathrm{D} \\approx 10 ~  \\mathrm{nm}$ for a concentration  $[\\mathrm{NaCl}] = 9.2 ~ \\mathrm{mmol.L^{-1}}$.\n\n\n\nFinally, combining Eqs.~(\\ref{debh1})~and~(\\ref{ld1}),  the Debye-Hückel equation reads:\n\n\\begin{equation}\n\t\\nabla^2 \\Psi (\\vec{r}) = \\kappa^2  \\Psi (\\vec{r}) ~,\n\t\\label{Eq:Debye_hu}\n\\end{equation}\n\nwith $\\kappa = 1/\\ell _\\mathrm{D}$. Using the latter, one can compute the electrostatic potential around a sphere immersed in an ionic solution. Let us consider a sphere of radius $a$ and charge $Qe$, \\textit{i.e.} a charge density $\\sigma = Qe/(4\\pi a^2)$ , $Q$ being the number of charges on the surface. Since the system has a spherical symmetry, one has $\\Psi (\\vec{r}) = \\Psi(r)$ with $r = |\\vec{r}|$. Using the Laplacian operator $\\nabla ^2$ in spherical coordinates, Eq.~(\\ref{Eq:Debye_hu}) becomes:\n\n\\begin{equation}\n\t\\frac{1}{r^2}\\left[\\frac{\\partial}{\\partial r} \\left(r^2 \\frac{\\partial \\Psi(r)}{\\partial r}\\right)\\right] = \\kappa^2  \\Psi (r) ~,\n\\end{equation}\n\nwhich has a general solution:\n\n\\begin{equation}\n\t\\Psi(r) = C_1 \\frac{\\exp(\\kappa r)}{r} + C_2 \\frac{\\exp(-\\kappa r)}{r}~.\n\\end{equation}\n\nThe electrostatic potential vanishes at infinity such that $C_1 = 0$. Therefore, the electrostatic potential (and thus the electrostatic energy potential) takes the form of a Yukawa potential:\n\n\\begin{equation}\n\t\\Psi (r) = C_2 \\frac{\\exp(-\\kappa r)}{r} ~.\n\t\\label{eq:yuka}\n\\end{equation}\n\nAdditionally, invoking the Gauss theorem, at the surface of the charged sphere, the electrostatic potential satisfies:\n\n\\begin{equation}\n\t\\left. \\frac{\\partial{\\Psi (r)}}{\\partial r} \\right|_{r=a} = \\frac{-Qe}{4 \\pi \\epsilon_0 \\epsilon_\\mathrm{r} a^2}  = \\frac{-\\sigma}{\\epsilon_0 \\epsilon_\\mathrm{r}} ~,\n\\end{equation}\n\nwhere we introduced the surface density of charges $\\sigma$. By applying the latter boundary condition to Eq.~(\\ref{eq:yuka}), we find:\n\n\\begin{equation}\n\t\\Psi (r) = \\frac{\\sigma a^2}{\\epsilon_0 \\epsilon_\\mathrm{r}} \\frac{\\exp (\\kappa a)}{1 + \\kappa a} \\frac{\\exp (-\\kappa r)}{r} ~.\n\\end{equation}\n\nThis solution can be used to determine the electrostatic potential between two spheres of radii $a_1$ and $a_2$, and surface charge densities $\\sigma_1$ and $\\sigma_2$, respectively. Supposing that the presence of a second sphere does not modify the distribution of ions in the double layer of the other sphere, one can use the superposition approximation to obtain the potential $U_\\textrm{elec} ^{ss} (z)$ between the two spheres \\cite{bell_approximate_1970}:\n\n\\begin{equation}\n\tU_\\textrm{elec} ^{ss}(z) = \\frac{4\\pi}{\\epsilon_0 \\epsilon_\\mathrm{r}} \n\t\\left(\n\t\\frac{\\sigma_1 a_1 ^2}{1 + \\kappa a_1}\n\t\\right)\n\t\\left(\n\t\\frac{\\sigma_2 a_2 ^2}{1 + \\kappa a_2}\n\t\\right)\n\t\\frac{\\exp(-\\kappa z)}{a_1 + a_2 + z} ~,\n\\end{equation} \nwith $z$ the gap between the two colloids.\nFrom the latter equation, it is possible to write the electrostatic interaction energy $U_\\textrm{elec}$ between a planar wall of charge density $\\sigma_\\textrm{w}$ and a spherical colloid of radius $a$ and surface charge density $\\sigma$, by setting one of the two radii to infinity. Doing so, one gets:\n\n\\begin{equation}\n\t\\frac{U_\\textrm{elec}(z)}{k_\\mathrm{B}T}  = B \\mathrm{e}^{-\\frac{z}{\\ell_\\mathrm{D}}}~,\n\t\\label{Eq:Uelec}\n\\end{equation}\n\nwhere:\n\n\\begin{equation}\n\tB = \\frac{4 \\pi}{ k_\\mathrm{B}T\\epsilon_0 \\epsilon_\\mathrm{r}} \\left( \\frac{\\sigma a^2 }{1 + \\kappa a}  \\right) \\frac{\\sigma_\\mathrm{w}}{\\kappa} ~.\n\\end{equation}\n\nLet us note that, $B$ is often written as \\cite{behrens_charge_2001}:\n\n\\begin{equation}\n\tB = 16 \\epsilon_\\mathrm{r} \\epsilon_0 a \\frac{ k_\\mathrm{B}T }{e^2} \\tanh \\left(\\frac{e\\phi}{4k_\\mathrm{B}T}\\right) \\tanh \\left(\\frac{e\\phi_\\mathrm{w}}{4k_\\mathrm{B}T}\\right) ~,\n\\end{equation}\nwhere $\\phi$ and $\\phi_\\mathrm{w}$ are the Stern potentials of the sphere and wall surface, respectively. Typical values for $B$ range from 1 to 50. In our study, we will use $B$  to characterize the dimensionless magnitude of the electrostatic interaction. Indeed, it is complicated to decouple $\\sigma$ and $\\sigma_\\mathrm{w}$ when the colloid and wall materials are different \\cite{behrens_charge_2001}.\n\n\\paragraph{van der Waals interactions}\\mbox{}\\\\\n\\vspace{0.10cm}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/vdw_scheme.pdf}\n\t\\caption{A colloid of radius $a$ is located at a distance $z$ from the wall. The dielectric constants of the sphere, wall and liquid are respectively $\\epsilon_1$, $\\epsilon_2$, and $\\epsilon_3$. }\n\t\\label{Fig:vdw}\n\\end{figure}\n\nIn the DLVO theory, van der Waals interactions, after integration over all surfaces contribute through a global Hamaker potential energy. This potential is short-ranged and attractive, in our case.The interaction potential reads: \\cite{israelachvili_intermolecular_2015}:\n\n\\begin{equation}\n\tU_\\mathrm{vdW} = -\\frac{A a}{6z} \n\\end{equation}\n\nwhere $A$ is the nonretarded Hamaker constant. For our system, where the particle, medium and wall are different media as schematize in Fig.~\\ref{Fig:vdw}, the Hamaker constant is given by \\cite{israelachvili_intermolecular_2015}:\n\n\\begin{equation}\n\tA = \\frac{3}{4} k_\\mathrm{B}T \\left(\n\t\\frac{\\epsilon_1 - \\epsilon_3}{\\epsilon_1 + \\epsilon_3}\n\t\\right)\n\t\\left(\n\t\\frac{\\epsilon_2 - \\epsilon_3}{\\epsilon_2 + \\epsilon_3}\n\t\\right)\n\t+\n\t\\frac{3h}{4\\pi}\n\t\\int_{\\nu_1}^{\\infty}\n\t\\left(\n\t\\frac{\\epsilon_1 (j\\nu) - \\epsilon_3 (j\\nu)}{\\epsilon_1 (j\\nu) + \\epsilon_3 (j\\nu)}\n\t\\right)\n\t\\left(\n\t\\frac{\\epsilon_2 (j\\nu) - \\epsilon_3 (j\\nu)}{\\epsilon_2 (j\\nu) + \\epsilon_3 (j\\nu)}\n\t\\right)\n\t\\textnormal{d}\\nu ~,\n\\end{equation}\n\nwhere $\\epsilon_1$, $\\epsilon_2$ and $\\epsilon_3$ are the static dielectric constants of the three media, $\\epsilon_{1,2,3} (j\\nu)$ are the  dielectric constant at a imaginary frequency $ j \\nu$. The first term gives the zero-frequency energy of the Van der Waals interaction and the second term the dispersion energy. In the literature, we found for polystyrene colloids in water near a glass substrate $A\\approx k_\\mathrm{B}T$. Since $A$ is positive, the interaction is attractive, moreover, we estimate that the van der Waals forces play a role only within a few nanometers from the surface ($z < 10$ nm), as commonly observed \\cite{prieve_measurement_1999}. In our experiments, the Debye length $\\ell _\\mathrm{D}$ ($>20$ nm) is large enough for the particles to avoid this region. Therefore, in the following, the van der Waals interactions are neglected. It is possible to study the van der Waals interactions with Brownian motion, provided that one adds enough salt to have $\\ell_\\mathrm{D} \\simeq 1$ nm. However, with such a short Debye length, all the colloids would stick to the surface and with each other, as a result of van der Waals forces. Interestingly, we have experimentally observed stuck particles. Further work on these events may lead to interesting insights about the near-wall interactions. Nonetheless, in the case where $A$ needs to be computed a special attention \\cite{parsegian_van_2005}.\n\n\n\n\\paragraph{Total potential and equilibrium distribution}\\mbox{}\\\\\n\\label{test}\n\\vspace{0.10cm}\n\nIf we combine the gravitational and electrostatic energy potentials the particles lie into a total energy potential $U(z)$, given by:\n\n\\begin{equation}\n\tU(z) = U_\\mathrm{g} + U_\\mathrm{elec}~.\n\t\\label{eq:uz}\n\\end{equation}\n\nBy combining Eqs.~(\\ref{eq:ug}),~(\\ref{Eq:Uelec})~and~(\\ref{eq:uz}), and adding the condition that a particle cannot go inside the wall, one finally gets:\n\n\\begin{equation}\n\t\\frac{U(z)}{k_\\mathrm{B}T} =  \\left\\{\n\t\\begin{array}{l}\n\t\t\\displaystyle B\\,\\textrm{e}^{-\\frac{z}{\\ell_\\mathrm{D}}} + \\frac{z}{\\ell_\\mathrm{B}}\\ ,\\quad \\text{ for } z>0 \\\\\n\t\t+\\infty\\ ,\\quad  \\text{ for } z < 0\n\t\\end{array}\n\t\\right. \\ .\n\t\\label{Eq:PDF}\n\\end{equation}\n\nFrom this total potential energy, one can then construct the Gibbs-Boltzmann distribution to write the equilibrium \\gls{PDF} of position $P_{\\mathrm{eq}}(z)$:\n\n\\begin{equation}\n\tP_\\mathrm{eq} (z)  = A \\exp \\left( -\\frac{U(z)}{k_\\mathrm{B}T} \\right) ~,\n\t\\label{Eq.Peq}\n\\end{equation} \n\nwhere $A$ is a normalization constant such that $\\int_{0}^{\\infty}P_\\mathrm{eq}(z)\\textnormal{d}z = 1$. Given an ensemble of heights $z_i$, one can compute $P_\\mathrm{eq}$ using the following Python function \\mintinline{python}{Peq}, where the $A$ is computed using the \\mintinline{python}{np.trapz} function. Examples of a theoretical energy potential and associated \\gls{PDF} of position can be seen in Fig.~\\ref{Fig:potential} for $\\ell_\\mathrm{B} = 500 ~ \\mathrm{nm} $,  $B = 4$ and $\\ell_\\mathrm{D} = 50 ~ \\mathrm{nm}$.\n\n\n\\begin{minted}\n\t[\n\tautogobble,\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tobeytabs=true,\n\ttabsize=2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\nimport numpy as np\n\t\ndef _Peq(z):\n\tif z <= 0:\n\t\treturn 0\n\telse:\n\t\treturn np.exp(-(B * np.exp(-z / ld) + z / lb))\n\t\n\t\ndef Peq(z):\n\tP = np.array([_Peq(zi) for zi in z])\nreturn P / np.trapz(P,z)\n\\end{minted}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/potential/potential_exemple.pdf}\n\t\\caption{ a) In orange potential energy $U_\\mathrm{g}$ (see Eq.~(\\ref{eq:ug})) of a colloid with a Boltzmann length $\\ell_\\mathrm{B} = 500 ~ \\mathrm{nm} $. In blue, the electrostatic potential energy $U_\\mathrm{elec}$ (see Eq.~(\\ref{Eq:Uelec})) is characterized by a dimensionless magnitude $B = 4$ and a Debye length $\\ell_\\mathrm{D} = 50 ~ \\mathrm{nm}$. The dashed line corresponds to the total potential $U$, see Eq.~(\\ref{eq:uz}). b) Corresponding Gibbs-Boltzmann equilibrium distribution of position calculated using the energy potential of panel a). \\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/potential/potential_exemple.ipynb}{\\faGithub}}\n\t\\label{Fig:potential}\n\\end{figure}\n\n\\newpage\n\n\\subsubsection{Local diffusion coefficient}\n\\label{sec:diff}\n\\begin{figure}\n\t\\centering\n\t\\includegraphics{02_body/chapter1/image/libchaber.pdf}\n\t\\caption{Figure extracted from \\cite{faucheux_confined_1994}. On the left is the experimental setup. It is an inverted microscope used in order to track micrometric particles of diameter $2R$ inside a liquid cell of thickness $t$. On the right is the final result, where the authors measure the diffusion parallel (\\textit{i.e.} along $x$ or $y$) coefficient $D_\\parallel$ (see Eqs.~(\\ref{Eq:etax})~and~(\\ref{Eq.hindered})), normalized by the bulk diffusion coefficient $D_0$, as a function the confinement parameter $\\gamma = \\langle z \\rangle_t/a$, with $\\langle z \\rangle_t$ time-averaged particle-wall distance.}\n\t\\label{fig:libchaber}\n\\end{figure}\n\n\nAs we have seen in Chapter~\\ref{sec:chapter1}, for a freely diffusing colloid in the bulk, the diffusion coefficient is given by Eq.~(\\ref{Eq:D_einstein}) and is a constant. However, when a particle is confined by a rigid wall, the diffusion is hindered. This means that the diffusion coefficient varies with the particle-wall distance and becomes anisotropic. A seminal measurement of this effect was done by Faucheux and Libchaber \\cite{faucheux_confined_1994}. As we can see in Fig.~\\ref{fig:libchaber}, using a microscope, they tracked colloids within a parallelepipedic chamber, and measured the thickness-averaged diffusion coefficients for different values of the confinement parameter $\\gamma = \\langle z\\rangle_t / a$, with $\\langle z \\rangle_t$ time-averaged particle-wall distance. As experiments reach equilibrium, $\\langle z \\rangle_t$ is given by the Gibbs-Boltzmann distribution as $\\langle z \\rangle_t = \\int \\textnormal{d}zP_\\mathrm{eq}(z))z$. We observe that the diffusion coefficient parallel to the surface decreases as the particle gets closer to the wall, and seems to saturate around $0.3D_0$ at low $\\gamma$, with $D_0$ the diffusion coefficient in the bulk (see Eq.~\\ref{Eq.D}). \n\\newpage\n\nTo understand the reason for this hindered diffusion coefficient, let us start by writing the diffusion coefficient $D$ using the fluctuation dissipation theorem:\n\n\\begin{equation}\n\tD = \\frac{1}{\\gamma} k_\\mathrm{B}T ~,\n\t\\label{Eq.fluc}\n\\end{equation}\n\nwith the mobility defined as:\n\n\\begin{equation}\n\t\\frac{1}{\\gamma} = \\left| \\frac{v_\\mathrm{sphere}}{F_\\mathrm{drag}} \\right|~,\n\t\\label{Eq.mu}\n\\end{equation}\n\nwhere $v_\\mathrm{sphere}$ is the terminal velocity to an applied force $F_\\mathrm{drag}$. For a spherical colloid of radius $a$ moving at a velocity $v_\\mathrm{sphere}$, the drag force $F_{\\mathrm{drag}} ^\\mathrm{B}$ is given by the Stokes' law:\n\n\\begin{equation}\n\tF_\\mathrm{drag} ^\\mathrm{B} = -c \\pi \\eta a v_\\mathrm{sphere} ~,\n\t\\label{Eq.drag}\n\\end{equation}\n\nwhere $c$ is a constant that depends on the boundary conditions imposed at the surface of the colloid. Typically, one has $c = 6$ for a no-slip boundary conditions and $c = 4$ for a full-slip boundary conditions, such as for air bubbles, for example. Combining Eqs.~(\\ref{Eq.fluc}),~(\\ref{Eq.mu})~and~(\\ref{Eq.drag}) for a freely diffusing no-slip hard sphere in the bulk we retrieve Eq.~(\\ref{Eq:D_einstein}): \n\n\\begin{equation}\n\tD = D_0 = \\frac{k_\\mathrm{B}T}{6\\pi \\eta a} ~.\n\t\\label{Eq.D}\n\\end{equation}\n\nThe Stokes' drag force can be computed by solving the Navier-Stokes equation:\n\n\\begin{equation}\n\t\\rho \\left[ \\frac{\\partial \\vec{v}}{\\partial t} + \\left(\\vec{v} \\cdot \\nabla \\vec{v} \\right) \\right] + \\nabla p = \\eta \\nabla ^2 \\vec{v} ~,\n\t\\label{Eq.Navier}\n\\end{equation}\n\nand the continuity equation for incompressible fluids:\n\n\\begin{equation}\n\t\\nabla \\cdot \\vec{v} = 0~,\n\t\\label{Eq.continuity}\n\\end{equation}\n\nwhere $\\vec{v}$ and $p$ are respectively the velocity and pressure fields, and where $\\rho$ is the liquid density. When the Reynolds number $\\textnormal{Re} = \\rho a v_\\mathrm{sphere} / \\eta \\ll 1$,  the second inertial term is negligibly small compared to the viscous term $\\eta \\nabla ^2 \\vec{v}$. In that case, and at long-enough time for the first inertial term to be negligible, the Eq.~(\\ref{Eq.Navier}) is simplified to the steady Stokes equation:\n\n\\begin{equation}\n\t\\nabla p = \\eta \\nabla ^2 \\vec{v}~.\n\t\\label{Eq.Stokesflow}\n\\end{equation}\n\nBy solving Eqs.~(\\ref{Eq.continuity})~and~(\\ref{Eq.Stokesflow}) with a no-slip boundary condition on the particle surface and the field vanishing at infinity, one can calculate the velocity and the pressure fields in the fluid. By integration of the pressure and viscous stress on the particle surface, one eventually gets the Stokes mobility. However, in the case of a confined particle near a wall there is an additional no-slip condition at the wall surface. At the macro scale, this effect can be seen with a frisbee, indeed, as it gets closer to the ground, hydrodynamic pressure increases due to the increasing air velocity gradient in the gap and one can observe a slowing down of the free fall.\n\nTo get some physical insight on this effect, one can use the lubrication theory to make a scaling of the drag force experience by a particle confined near a wall. As schematized in Fig.~\\ref{fig.shear}, we consider a particle of radius $a$ moving at a velocity $V$. \n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/draw_shear/shear.pdf}\n\t\\caption{Schematic representation of a spherical object of radius $a$ moving towards a wall at velocity $V_\\mathrm{sphere}$ and inducing a fluid velocity $V_\\mathrm{fluid}$} \n\t\\label{fig.shear}\n\\end{figure}\n\nAs we are using the lubrication theory, we suppose that the particle is close to the wall such that $h \\ll a$. In that condition, we suppose that a particle moving towards a wall (\\textit{along the $z$-axis}) at a velocity $V_\\mathrm{sphere}$ induce a fluid velocity $V_\\mathrm{fluid}$ along the $x$-axis, we further suppose that the induced velocity along the $z$-axis is negligible. Moreover, the typical length scale along the $z$-axis is the particle-wall distance $z$; and the distance $L=\\sqrt{az}$ (\\textit{i.e.} Hertz contact), along the $x$-axis. In this approximation, velocity terms along the $z$-axis will be negligible in Eq.~(\\ref{Eq.Stokesflow}), a projection along the $z$-axis thus gives:\n\n\\begin{equation}\n\t\\frac{\\partial p}{\\partial z} = 0 ~.\n\\end{equation}\n\nOn the right-hand side of Eq.~\\ref{Eq.Stokesflow}, the viscous term simplifies to $\\eta \\partial_z^2 V_\\mathrm{fluid} $ as:\n\n\\begin{equation}\n\t\\frac{\\partial^2 V_\\mathrm{fluid}}{\\partial x^2} \\approx \\frac{V_\\mathrm{fluid}}{L^2} \\ll \\frac{V_\\mathrm{fluid}}{h^2} \\approx \\frac{\\partial^2 V_\\mathrm{fluid}}{\\partial z^2}~.\n\\end{equation}\n\nIn the lubrication theory, Eq.~(\\ref{Eq.Stokesflow}) is finally simplified to:\n\n\\begin{equation}\n\t\\frac{\\partial p}{\\partial x} = \\eta \\frac{\\partial ^2 V_\\mathrm{fluid}}{\\partial z^2}~,\n\\end{equation}\n\nwhich scales as:\n\n\\begin{equation}\n\tp \\sim \\eta V_\\mathrm{fluid} \\frac{L}{h^2}~.\n\t\\label{pressure}\n\\end{equation}\n\nTo compute the Stokes mobility, one needs to evaluate the viscous stress $\\sigma$, in the lubrication theory, it reads:\n\n\\begin{equation}\n\t\\sigma = \\eta \\frac{\\partial V_\\mathrm{fluid}}{\\partial z} \\sim \\eta \\frac{V_\\mathrm{fluid}}{h} ~.\n\\end{equation}\n\nWhen the particle is moving towards the wall we thus have $p\\gg \\sigma$, we thus only consider the pressure. To evaluate the mobility, we need to write Eq.~(\\ref{pressure}) as a function of $V_\\mathrm{sphere}$. Using Eq.~(\\ref{Eq.continuity}) one has $V_\\mathrm{fluid} / L \\sim  V_\\mathrm{sphere} / h$, Eq.~(\\ref{pressure}) thus become:\n\n\\begin{equation}\n\tp \\sim \\eta V_\\mathrm{sphere} \\frac{L^4}{h^3}\n\\end{equation}\n\nIntegrating this pressure over the particle surface (\\textit{i.e} over the typical surface $L^2 = ah$) leads a scaling of the drag force:\n\n\\begin{equation}\n\tF_\\mathrm{drag} ^{z\\ll a} \\sim \\eta V_\\mathrm{sphere} \\frac{L^4}{h^3} = \\eta V_\\mathrm{sphere} \\frac{a^2}{z}\n\\end{equation}\n\nThe mobility (see Eq.~(\\ref{Eq.mu})) of the displacement perpendicular to the wall  thus scale as $\\gamma_0^{-1} h/a$, with $\\gamma_0^{-1}$ the bulk mobility. Therefore, the diffusion coefficient of a confined colloid near a wall in the lubrication approximation is hindered and inversely proportional to the particle-wall distance. It is possible to do the same scaling for the parallel mobility by supposing that the particle is moving along the $x$-axis. In that case, one can find that the viscous stress is greater than the pressure and finally find that along the $x$-axis, the parallel mobility follows the same scaling as in bulk and remain constant.\n\nTo recap, a colloid diffusing near a wall experience a local drag force that depends on both its distance $z$ to the wall and direction of motion. Thanks to the linearity of the Stokes equation, one can decompose this local drag force in two contributions, for motions parallel and perpendicular to the wall. As the presence of the wall modifies the drag force with a space-dependent multiplicative factor, the confinement effect is often expressed in terms of effective viscosities:\n\n\\begin{equation}\n\t\\eta _\\bot (z) = {\\eta}{\\lambda _ \\bot (z)}  ~ \\text{, and } ~\\eta _\\parallel (z) =  {\\eta}{\\lambda _ \\parallel (z)}~,\n\\end{equation}\n\nwhere $\\lambda _\\bot$ and $\\lambda _\\parallel$ are respectively the perpendicular and parallel correction factors. Taking into account these corrections, the diffusion coefficients for perpendicular and parallel motions relative to the wall read:\n\n\\begin{equation}\n\tD_\\bot (z) =  \\frac{D_0}{\\lambda _\\bot (z)}  ~, \\text{ and } D_\\parallel (z) = \\frac{D_0}{ \\lambda_\\parallel (z)} ~.\n\t\\label{Eq.hindered}\n\\end{equation}\n\nFor no-slip boundary conditions imposed at both the wall and the surface of the colloid, Brenner \\cite{brenner_slow_1961} has obtained for the perpendicular motion:\n\n\n\\begin{equation}\n\t\\lambda_ \\bot (z) = \\frac{4}{3}  \\mathrm{sinh}\\beta \\sum _{n=1} ^{\\infty} \\frac{n(n+1)}{(2n-1)(2n+3)}\n\t\\left[\n\t\\frac\n\t{\n\t\t2\\mathrm{sinh}(2n + 1)\\beta + (2n +1)\\mathrm{sinh}2\\beta\n\t}\n\t{\n\t\t4\\mathrm{sinh}^2(n + 1 /2)\\beta  - (2n+1)^2 \\mathrm{sinh}^2 \\beta\n\t}\n\t-1\n\t\\right] ~,\n\t\\label{Eq:etaz}\n\\end{equation}\n\nwhere $\\beta = \\cosh ^{-1} ((z+a)/a)$. For the motion of a sphere parallel to a wall, Faxén found \\cite{faxen_fredholm_1924}:\n\n\\begin{equation}\n\t\\lambda_\\parallel(z) = \n\t\\left[\n\t1 - \\frac{9}{16} \\xi + \\frac{1}{8}\\xi^3 - \\frac{45}{256}\\xi^4 - \\frac{1}{16}\\xi^5\n\t\\right]^{-1}~,\n\t\\label{Eq:etax}\n\\end{equation}\n\nwhere $\\xi  = a / (z+a)$. Eqs.~(\\ref{Eq:etaz})~and~(\\ref{Eq:etax}) are exact for all $z$ and shown in Fig.~\\ref{fig.etaz}-a). However, the solution for the perpendicular motion can be complex to compute as it is an infinite series. It requires a software that enables arbitrary-precision floating-point arithmetic\\footnote{Arbitrary-precision floating-point arithmetic enables to evaluate mathematical expressions with any precision, \\textit{i.e.} any number of digits.} --- such as Mathematica or the \\mintinline{python}{mpmath} Python's module, for example. $D_\\bot$ can be evaluated using the following Python snippet, where the \\mintinline{python}|nsum| function is used to compute the summation:  \n \n \\newpage\n\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\nfrom mpmath import nsum \n\t\ndef Dz(eta, z, a):\n  a = (z + a) / a\n  beta = float(acosh(a))\n  summ = nsum(\n    lambda n: (n * (n + 1) / ((2 * n - 1) * (2 * n + 3)))\n    * (\n        (\n          (2 * sinh((2 * n + 1) * xi) + (2 * n + 1) * sinh(2 * beta))\n          / (\n              4 * (sinh((n + 1 / 2) * beta) ** 2)\n              - ((2 * n + 1) ** 2) * (sinh(beta) ** 2)\n          )\n    )\n    - 1\n  ),\n  [0, inf],\n  )\n  summ = float(summ)\n  return kT / (6 * pi * eta * 4 / 3 * float(sinh(beta)) * summ * a)\n\n\\end{minted}\n\nTo simplify the computation of $\\lambda_\\bot$, Honig \\cite{honig_effect_1971}, and Bevan and Prieve \\cite{bevan_hindered_2000} showed that Eq.~(\\ref{Eq:etaz}) can be Padé approximated\\footnote{A Padé aproximant is the approximation of a power series by a rational fraction \\cite{baker_pade_1996}.}, giving:\n\n\\begin{equation}\n\t\\lambda_\\bot =  \\frac{6z^2 + 9az + 2a^2}{6z^2 + 2az}~.\n\t\\label{Eq:etaz_pade}\n\\end{equation}\n\nIn the near-wall regime, such that $z \\ll a$, it is possible to further approximate $\\lambda_\\bot$ by its asymptotic expression:\n\n\\begin{equation}\n\t\\lambda_\\bot (z) \\simeq \\frac{a}{z} ~.\n\t\\label{Eq:etaz_small}\n\\end{equation}\n\nFor the particle parallel motion, \\cite{oneill_slow_1967, chaoui_creeping_2003} found an asymptotic expression as:\n\n\\begin{equation}\n\t\\lambda _\\parallel \\simeq \\left(\\frac{8}{15}\\log\\left(\\frac{z}{a}\\right) - 0.95429\\right)~.\n\t\\label{Eq.etax_small}\n\\end{equation} \n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/theory_lambda/hindered_diffusion.pdf}\n\t\\caption{a)  Parallel and perpendicular normalized diffusion coefficients for a colloidal particle of radius $a = 1.5 ~ \\mathrm{\\mu m}$. b) Perpendicular normalized diffusion coefficient at a distance $z$ from a wall. The solid black line is the exact solution given by the infinite sum of Eq.~(\\ref{Eq:etaz}). The green dashed line is the Padé approximation of Eq.~(\\ref{Eq:etaz_pade}). The blue dahed line is the near-wall asymptotic expression of Eq.~(\\ref{Eq:etaz_small}). c) Relative errors between the two approximations (dashed lines of panel b), same color code) and the exact result (solid line of panel b)).\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/theory_lambda/Hindered_diffusion.ipynb}{\\faGithub}}\n\t\\label{fig.etaz}\n\\end{figure}\n\n\nThe exact result, together with the Padé approximation and the near-wall asymptotic expression for the hindered vertical diffusion are plotted in Fig.~\\ref{fig.etaz}-b). The Padé approximation fits well the exact solution, the near-wall asymptotic expression fits well when $z < a / 10$ typically. To check how precise both approximations are, we plot the relative error in Fig.~\\ref{fig.etaz}-c). The Padé approximation shows precision up to 1\\%. Thus, in the following, when evaluating perpendicular diffusion coefficients, or equivalently vertical effective viscosities, the Padé approximation will be used. \n\n\n%\\subsubsection{Langevin equation for confined Brownian motion}\n%\n%Now that the external forces acting on the particle and hindered diffusion coefficients are known, we rewrite the overdamped Langevin (see Eq.~(\\ref{Eq.overdamped_SDE})) as:\n%\n%\\begin{equation}\n%\tV_t^i \\textnormal{d}t  = -\\mu(z)\\frac{\\partial U(z)}{\\partial x_i}  \\textnormal{d}t + \\sqrt{2D_i (z)}  \\textnormal{d}W ~,\n%\t\\label{Eq:langevin_z}\n%\\end{equation}\n%\n%where $\\mu(z) = 1/ (6 \\pi \\eta_i(z) a)$, and $i$ denotes one of the three spatial directions, $x,~ y$ and $z$, where the previously determined $\\eta_\\parallel$ or $D_\\parallel$ corresponds to the $x$- and $y$-axes, while $\\eta_\\bot$ or $D_\\bot$ corresponds to the $z$-axis, and $ \\textnormal{d}W$ is a Gaussian-distributed satisfying $\\langle \\textnormal{d}W \\rangle = 0$ and $\\langle \\textnormal{d}W ^2 \\rangle = \\textnormal{d}t$. As discussed previously, the potential energy $U$ only varies along the $z$-axis, an thus, the external force only acts on the particle along the $z$-axis while the particle diffuses freely along the $x$- and $y$-axes. \n\n\n\\subsubsection{Fokker-Plank equation}\n\nThe Fokker-Plank equation is an alternative way to describe Brownian motion. Instead of explicitly calculating a Brownian trajectory by solving the Langevin equation, Fokker-Plank equation describes the Probability Density Function $P(X_t, X_0; t)$ in position. Where for simplicity we place ourselve in 1D, with $X_t$ denoting the particle position at a time $t$ and $X_0$ its initial ($t=0$) position. To derive the Fokker-Plank equation, let us start by taking a generic Langevin equation in 1D:\n\n\\begin{equation}\n\t\\textnormal{d}X_t = u(X_t) \\mathrm{d}t + g\\textnormal{d}W ~,\n\t\\label{SDE2}\n\\end{equation}\n\nwhere $u(X_t)$ is the drift velocity due to external forces and $g$ is the magnitude of the random force. Let consider the average value of an arbitrary function $f(X_t)$ for a stochastic process obeying Eq.~(\\ref{SDE2}), which started at position $x_0$ at time $t=0$. By definition, this ensemble average reads \\cite{le_bellac_equilibrium_2004}:\n\n\\begin{equation}\n\t\\langle f(X_t) \\rangle = \\int \\textnormal{d}X_t ~ P(X_t, X_0 ; t) f(X_t) ~,\n\t\\label{fokker1}\n\\end{equation}\n\nwith the initial condition that can be written as:\n\n\\begin{equation}\nP(X_t, X_0; 0) = \\delta (X_t - X_0) ~.\n\\end{equation}\n\nWe now expand $f$ at the first order in the time increment $\\textnormal{d}t$ as:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\left\\langle \\frac{\\textnormal{d}f(X_t)}{\\textnormal{d}t} \\right\\rangle_t  &\\simeq \\left\\langle \\frac{1}{\\textnormal{d}t} \\left( \\frac{\\partial f(X_t)}{\\partial X_t} u(X_t) \\textnormal{d}t + \\frac{\\partial f(X_t)}{\\partial X_t} g \\textnormal{d}W + \\frac{1}{2} \\frac{\\partial^2 f(X_t)}{\\partial X_t^2} g^2  \\textnormal{d}W^2   \\right) \\right\\rangle_t \\\\\n\t\t& = \t\\left\\langle \\frac{1}{\\textnormal{d}t} \\left( \\frac{\\partial f(X_t)}{\\partial X_t} u(X_t) \\textnormal{d}t + \\frac{1}{2} \\frac{\\partial^2 f(X_t)}{\\partial X_t^2} g^2 \\textnormal{d}t \\right)\\right\\rangle_t  \\\\\n\t\t& = \t\\left\\langle \\frac{\\partial f(X_t)}{\\partial X_t} u(X_t) + \\frac{1}{2} g^2 \\frac{\\partial^2 f(X_t)}{\\partial X_t^2} \\right\\rangle_t   ~.\n\t\\end{aligned}\n\t\\label{fokker2}\n\\end{equation}\n\nBy combining Eqs.~(\\ref{fokker1})~and~(\\ref{fokker2}), we get:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\int \\textnormal{d} X_t ~\\frac{\\partial P(X_t, X_0 ; t) }{\\partial t} f(X_t)\n\t\t& = \\left\\langle \\frac{\\partial f(X_t)}{\\partial X_t} u(X_t) + \\frac{1}{2} \\frac{\\partial^2 f(X_t)}{\\partial X_t^2} g^2 \\right\\rangle_t \\\\\n\t\t& = \\int \\textnormal{d}X_t ~ P(X_t, X_0 ; t) G f(X_t) ~,\n\t\\end{aligned}\n\\end{equation}\n\nwhere G is a differential operator called the generator and is defined by its action on a function $f$ as:\n\n\\begin{equation}\n\tGf = \\frac{1}{2} g^2 \\frac{\\partial ^2 f(X_t)}{\\partial X_t^2} + u(X_t) \\frac{\\partial f(X_t)}{\\partial X_t} ~.\n\\end{equation}\n\nUsing the definition of the adjoint of $G$, denoted $G ^\\dagger$, one has:\n\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\int \\textnormal{d} X_t ~\\frac{\\partial P(X_t, X_0 ; t) }{\\partial t} f(X_t) &= \\int \\textnormal{d}X_t ~ P(X_t, X_0 ; t) G f(X_t) \\\\\n\t\t&= \\int \\textnormal{d}X_t ~  G ^\\dagger P(X_t, X_0 ; t) f(X_t) ~.\n\t\\end{aligned}\n\\end{equation}\n\nFrom the latter, we thus have:\n\n\\begin{equation}\n\t\\frac{\\partial P(X_t, X_0 ; t)}{\\partial t} = G^\\dagger P(X_t, X_0 ; t) ~,\n\t\\label{fokker3}\n\\end{equation}\n\nwhich leads to the Forward Fokker-Planck equation \\cite{del_moral_introduction_2010}:\n\n\\begin{equation}\n\t\\frac{\\partial P(X_t, X_0 ; t)}{\\partial t }= \\frac{\\partial ^2}{\\partial X_t^2} \\left[\\frac{g^2 }{2}P(X_t, X_0 ; t)\\right] - \\frac{\\partial}{\\partial X_t} \\left[u(X_t) P(X_t, X_0 ; t)\\right] ~.\n\t\\label{Eq.Forward_Fokker_plank}\n\\end{equation}\n\nThe latter is called Forward because the partial differential equation is written in terms of the variable $X_t$, \\textit{i.e.} the position of the particle, at time $t$. For a  free Brownian motion in bulk, the Fokker-Plank equation reads:\n\n\\begin{equation}\n\t\\frac{\\partial P(X_t, X_0 ; t)}{\\partial t} = D_0 \\frac{\\partial ^2}{\\partial X_t ^2}P(X_t, X_0 ; t) ~.\n\t\\label{fp}\n\\end{equation}\n\n\n\\subsubsection{Fokker-Planck and multiplicative noise}\n\nDue to the hindered diffusion coefficient the magnitude of the random force $g$ now depends on the particle position $X_t$. Therefore, for a displacement between a time $t$ and $t+\\tau$, the integration of the noise term $\\int_t ^{t+\\tau}g(X_t)\\mathrm{d}B_t$ is not trivial and the time at which the random force magnitude $g(X_t)$ is evaluated needs to be answered. In this part we derive the Fokker-Plank equation when the system is subjected to multiplicative noise. Let us write a generic Langevin equation with multiplicative noise:\n\n\\begin{equation}\n\t\\mathrm{d}X_t = u(X_t)\\mathrm{d}t + g(X_t)\\mathrm{d}B_t~.\n\t\\label{sde.multipl}\n\\end{equation}\n\nWe start by deriving Eq.~(\\ref{sde.multipl}) for a time step $\\tau$ such that:\n\n\\begin{equation}\n\tX_{t+\\tau} = X_t + \\int_{t}^{t+\\tau} u(X_{t'})dt' + \\int_{t}^{t+\\tau} g(X_{t'})\\textnormal{d}W_{t'}\n\t\\label{sde.multipl2}\n\\end{equation}\n\nThe expansion of the first term gives $u(X_t)\\tau$ at the first order in $\\tau$. However, for the second term, the position at which $g(X_t)$ is evaluated needs to be addressed. The second integral of Eq.~{(\\ref{sde.multipl2})} is not unequivocally defined as \\cite{sancho_brownian_2011}:\n\n\\begin{equation}\n\t\\int_{t}^{t+\\tau}g(X_{t'})\\textnormal{d}W_{t'}\\textnormal{d}t' \\equiv B([1 - \\alpha] X_t + \\alpha X_{t+\\tau}) \\Delta W(t),\n\t\\label{sde.alpha}\n\\end{equation}\n\nwhere $\\Delta W (t)$ the the Wiener increment:\n\n\\begin{equation}\n\t\\Delta W(t) = \\int_{t}^{t+\\tau} \\textnormal{d} W_{t'},\n\\end{equation}\n\nwhich is a Gaussian process with zero mean and variance $\\langle \\Delta W(t)^2 \\rangle = \\tau $. The parameter $\\alpha$ in Eq.~{(\\ref{sde.alpha})} corresponds to stochastic interpretation of the Langevin equation, and at which point in the interval $[t, t+\\tau]$ the Langevin force magnitude $g$ is evaluated. Theoretically, $\\alpha$ can take any value between 0 and 1. However, two canonical values are usually employed :  $\\alpha = 0$, in the Itô convention \\cite{ito_stochastic_1944}, corresponding to the use of the initial value of $g(X_t)$; $\\alpha = 1/2$, in the Stratonovich convention \\cite{stratonovich_new_1966}, corresponding to the mid-point value $g(X_{t + (1/2)\\tau})$. \n\nTo derive the Fokker-Plank equation we now need to expand Eq.~(\\ref{sde.multipl2}) to first order in $\\tau $. Combining Eqs.~(\\ref{sde.multipl2})~and~(\\ref{sde.alpha}), at the order $\\tau^{1/2}$, Eq~.(\\ref{sde.alpha}) can be approximated by \\cite{sancho_brownian_2011}:\n\n\\begin{equation}\n\tX_{t+\\tau} = X_t + g(X_t)\\Delta W(t)~.\n\t\\label{sde.firsttaylor}\n\\end{equation}\n\nBy combining Eqs.~(\\ref{sde.multipl2})~and~(\\ref{sde.firsttaylor}) one has:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\int_{t}^{t+\\tau} g(X_{t'}) \\textnormal{d}W_{t'} &= g(X_t + \\alpha[X_{t + \\tau} - X_t])\\Delta W(t) \\\\\n\t\t&\\simeq g(X_t + \\alpha g(X_t)\\Delta W(t))\\Delta W(t)\\\\\n\t\t&\\simeq g(X_t) \\Delta W(t) + \\alpha g(X_t)g'(X_t)[\\Delta W(t)]^2,\n\t\\end{aligned}\n\t\\label{sde.taylorend}\n\\end{equation}\n\nwhere $g'(X_t) = \\frac{\\textnormal{d}}{\\textnormal{d} X_t} g(X_t) $. By finally combining Eqs.~(\\ref{sde.multipl2})~and~(\\ref{sde.taylorend}), one can expand Eq.~(\\ref{sde.multipl2}) to the first order in $\\tau$:\n\n\\begin{equation}\n\tX_{t+\\tau } \\simeq X_t + u(X_t)\\tau + g(X_t) \\Delta W(t) + \\alpha g(X_t)g'(X_t)[\\Delta W(t)]^2 ~.\n\\end{equation}\n\nFinally, by writing the Fokker-Plank equation in its standard form:\n\n\\begin{equation}\n\t\\frac{\\partial P(X_t, t)}{\\partial t} = -\\frac{\\partial}{\\partial X_t} K_1 (X_t) P(X_t, t) + \\frac{1}{2}\\frac{\\partial^2}{\\partial X_t^2} K_2P(X_t, t),\n\\end{equation}\n\nwhere $K_1$ and $K_2$ are the first two different moments, and invoking the Kramers-Moyal expansion \\cite{sancho_brownian_2011, stratonovich_new_1966}, $K_1$ and $K_2$ are obtained by:\n\n\\begin{equation}\n\tK_1(X_t) = \\lim\\limits_{\\tau \\rightarrow 0} \\frac{\\langle \\Delta X_t \\rangle}{\\tau}  = u(X_t) + \\alpha g(X_t)g'(X_t)~,\n\\end{equation}\n\nand:\n\n\\begin{equation}\n\tK_2(X_t) = \\lim\\limits_{\\tau \\rightarrow 0} \\frac{\\langle [\\Delta z]^2\\rangle}{\\tau} = g^2(X_t) ~.\n\\end{equation}\n\nThe Fokker-Plank equation with multiplicative noise finally writes:\n\n\\begin{equation}\n\t\\frac{\\partial P(X_t, t)}{\\partial t} = -\\frac{\\partial}{\\partial X_t} \\{u(X_t) + \\alpha g(X_t)g'(X_t)\\} P(X_t, t) + \\frac{1}{2}\\frac{\\partial^2}{\\partial X_t^2} \\{g^2(X_t) \\} P(X_t, t)~.\n\t\\label{final_fokker}\n\\end{equation} \n\ndue to the presence of multiplicative noise, we now have a new drift velocity term that depends on the stochastic interpretation of the Langevin equation. The latter equation rarely has an exact solution, and numerical methods are often used in order to solve it. Considering a toy model of a particle with linear diffusion coefficient $D_\\bot(z) = z/a$, and under a constant force $-F$ (e.g. gravity). Along the $z$-axis, taking the Ito convention ($\\alpha = 0$), Eq.~(\\ref{final_fokker}) can be rewritten as:\n\n\\begin{equation}\n\t\\frac{\\partial P(z, t)}{\\partial t}=  \\frac{\\partial}{\\partial z} \\left\\{ \\frac{F}{\\gamma_\\bot(z)}\\right\\} P(z, t) + \\frac{1}{2}\\frac{\\partial^2}{\\partial z^2} \\left\\{\\frac{z}{a} \\right\\} P(z, t)~.\n\t\\label{Eq.toy}\n\\end{equation}\n\nLau and Lubensky \\cite{lau_state-dependent_2007} derived an exact solution to Eq.~(\\ref{Eq.toy}) using the Ito convention ($\\alpha = 0$) as:\n\n\\begin{equation}\n\tP(z,t) = \\frac{\\sqrt{z_0z\\mathrm{e}^{Ft/(ak_\\mathrm{B}T)}}}{(k_\\mathrm{B}T)^2} \\frac{F^2}{\\left(1 - \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}\\right) ^2} \\mathrm{e}^{-\\frac{F\\left(z + z_0 \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}\\right)}{1 - \\mathrm{e}^{\\frac{Ft}{ak_\\mathrm{B}T}}}} ~.\n\t\\label{sol_exact}\n\\end{equation}\n\nWhere the latter has been obtained by requiring the equilibrium distribution as $\\lim\\limits_{t\\rightarrow+\\infty} = \\mathrm{e}^{-Fz/(k_\\mathrm{B}T)}$. From the analytical solution Eq.~(\\ref{sol_exact}), one can extract the first two moments of $z(t)$ as:\n\n\\begin{equation}\n\t\\langle z (t)\\rangle = z_0 \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}} + \\frac{k_\\mathrm{B}T}{F}\\left(1 - \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}\\right)~,\n\\end{equation}\n\nand:\n\n\\begin{equation}\n\t\\langle z^2 (t)\\rangle = z_0^2 \\mathrm{e}^{-2\\frac{Ft}{ak_\\mathrm{B}T}} + \\frac{4k_\\mathrm{B}Tz_0\\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}}{F} \\left(1 - \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}\\right) + 2 \\left(\\frac{ k_\\mathrm{B}T}{F}\\right)^2\\left(1 - \\mathrm{e}^{-\\frac{Ft}{ak_\\mathrm{B}T}}\\right)^2 ~.\n\\end{equation}\n\n\nIn particular, at long time, where the distribution is dictated by the equilibrium distribution, we have \n\n\\begin{equation}\n\t \\lim\\limits_{t\\leftarrow+\\infty}\\langle z^2 (t)\\rangle = \\left(\\frac{k_\\mathrm{B}T}{F}\\right)^2 ~.\n\\end{equation}\n\nIn the case where $F=m_\\mathrm{p}g$ is the gravitational force, we have $ \\lim\\limits_{t\\leftarrow+\\infty}\\langle z^2 (t)\\rangle = \\ell_{\\mathrm{B}}^2$ the typical length of the system (see Eq.~(\\ref{lB})).\n\n\\subsubsection{Spurious drift}\n\\label{sec:spurious}\n\nNow that we derived the Fokker-Planck equation for multiplicative s noise, we can inspect how the new drift velocity term $\\alpha g(X_t)g'(X_t)$ plays a role, in the case where one wants to simulate near-wall confined Brownian motion, or, infer forces from a measured trajectory. Let first rewrite Eq.~(\\ref{sde.multipl}) along the $z$-axis for a particle confined near a wall:\n\n\\begin{equation}\n\t\\mathrm{d}z = \\frac{F(z)}{\\gamma_\\bot (z)} \\mathrm{d}t + \\sqrt{2 D_\\bot(z)}\\mathrm{d}W ~,\n\\end{equation}\n\nwhere $F(x)=-k_\\mathrm{B}T \\ln (U(z))$ is the force (due to the DLVO interaction and gravity) exerted on the particle if the system was deterministic. Using Eq.~(\\ref{final_fokker}), the average velocity writes:\n\n\\begin{equation}\n\t\\left\\langle \\frac{\\Delta z}{ \\tau} \\right\\rangle  \\equiv \\bar{v}_\\mathrm{d}\n\t=\\left\\langle \\frac{\\mathrm{d}z}{\\mathrm{d}t} \\right\\rangle = \\frac{F(z)}{\\gamma_\\bot (z)} + \\alpha \\frac{\\mathrm{d} D_\\bot(z)}{\\mathrm{d}z} ~. \n\t\\label{drift_alpha}\n\\end{equation}\n\nHowever, one needs to take into account that at long time, the steady-state solution of the Fokker-Plank equation should be given by the Gibbs-Boltzmann equilibrium distribution $P_\\mathrm{eq}(z)$. Different choice of $\\alpha$ gives different drift velocity $\\bar{v}_\\mathrm{d}$ of Eq.~(\\ref{drift_alpha}), nevertheless that would mean that only one value of $\\alpha$ permits recovering the equilibrium distribution. Yet, to my knowledge, the Itô and Stratonovich conventions permit retrieving the correct distribution. \n\nDue to this ambiguity, it is often observed in the literature that $\\alpha$ is numerically inferred to retrieve the correct distribution and forces. Doing so, we find in the literature some $\\alpha =1$, corresponding to an anti-Itô convention, meaning an anticipation of the Langevin equation. However, this is due to a misuse of Eq.~(\\ref{drift_alpha}) since the calculus are done using the Itô or Stratonovich convention.   \n\nTo solve this situation, one needs to take into account that it is not the deterministic force $F(z)$ that should be used in Eq.~(\\ref{drift_alpha}) but the force:\n\n\\begin{equation}\n\tF_\\mathrm{eq} = - \\frac{\\mathrm{d}U_\\mathrm{ss}(z)}{\\mathrm{d}z}\n\t\\label{Feq}\n\\end{equation}\nwhich is computed through the steady-state solution of the Fokker-Planck equation for multiplicative noise, such that:\n\n\\begin{equation}\n\tU_\\mathrm{ss} (z) = - k_\\mathrm{B}T \\ln (P_\\mathrm{ss}(z)),\n\t\\label{Uss}\n\\end{equation}\n\n\nwith $P_\\mathrm{ss}(z)$ the steady-state solution of Eq.~(\\ref{final_fokker}), that can be obtain as follows. Let us start by setting the time derivative $\\partial P_\\mathrm{ss} / \\partial t$ to zero in Eq.~(\\ref{final_fokker}), which now writes along the $z$-axis:\n\n\\begin{equation}\n\t\\frac{\\textnormal{d}}{\\textnormal{d} z} \\left\\{ -u(z) - \\alpha g(z)g'(z) + \\frac{1}{2}\\frac{\\textnormal{d} }{\\textnormal{d} z} g^2(z)  \\right\\} P_\\mathrm{ss}(z)= \\frac{\\textnormal{d} J}{\\textnormal{d} z} = 0~,\n\t\\label{-alpha.1}\n\\end{equation}\n\nwhere $J$ is a probability flux, $u(z) = F/\\gamma_\\bot$, and $g(z)g'(z) = \\mathrm{d}D_\\bot / \\mathrm{d}z $. As $\\partial _z J =0$, $J$ needs to be a constant. Moreover, we need $P_\\mathrm{ss}$ and the moments of $P_\\mathrm{ss}$ to be finite, therefore we require $P_\\mathrm{ss}$ to decay to zero at infinity\\footnote{Using the Riemann integrals, $P_\\mathrm{ss}$ should decay faster than $|z|^{-n-1}$ to have the $n$-th first moment to be finite.}, and in particular $P_\\mathrm{ss}$ and $\\partial_z P_\\mathrm{ss}$ are zero at infinity, and therefore $J=0$ and Eq.~(\\ref{-alpha.1}) becomes:\n\n\\begin{equation}\n\t\\left(-u(z) - \\alpha g(z)g'(z)\\right)P_\\mathrm{ss}(z) + \\frac{1}{2}\\frac{\\partial}{\\partial z} \\left\\{ g^2(z) P_\\mathrm{ss}(z) \\right\\} =0~.\n\t\\label{-alpha.2}\n\\end{equation}\n\nBy invoking $Y=g^2(z)P_\\mathrm{ss}$, Eq.~(\\ref{-alpha.2}) becomes:\n\n\\begin{equation}\n\t-\\frac{u(z) + \\alpha g(z)g'(z)}{g^2(z) / 2} Y(z) + \\frac{\\textnormal{d} }{\\textnormal{d} z} Y(z)=0~,\n\\end{equation}\n\nwhich leads to:\n\n\\begin{equation}\n\tP_\\mathrm{ss}(z) = \\frac{1}{g^2(z)} \\exp \\left[ \\int^{z} \\frac{u(z') + \\alpha g(z')g'(z')}{g^2(z') / 2} \\mathrm{d}z \\right] ~.\n\t\\label{-alpha.3}\n\\end{equation}\n\nUsing the fact that $-\\ln(g^2(z))$ can be written as $-\\int^{z} 2 g(z')g'(z') / g^2(z') \\mathrm{d}z$, Eq.~(\\ref{Uss}) becomes:\n\n\\begin{equation}\n\tU_\\mathrm{ss} = -k_\\mathrm{B}T \\int^{z} \\frac{u(z') + (\\alpha - 1) g(z')g'(z')}{g^2(z') / 2} \\mathrm{d}z~.\n\\end{equation}\n\n\n\nBy combining Eqs.~(\\ref{Feq})~and~(\\ref{Uss}), one has:\n\n\\begin{equation}\n\t\\frac{F_\\mathrm{eq}(z)}{\\gamma_\\bot(z)} = \\frac{F(z)}{\\gamma_\\bot(z)} + (\\alpha - 1)g(z)g'(z)~.\n\t\\label{alpha-1}\n\\end{equation}\n\nThe difference between Eqs.~(\\ref{drift_alpha}) and (\\ref{alpha-1}) gives $g(z)g'(z) = \\mathrm{d}D_\\bot/ \\mathrm{dz}$, and does not depend on the interpretation of the Langevin equation. Finally, we write the overall drift as:\n\n\\begin{equation}\n\t\\bar{v}_\\mathrm{d} = -\\frac{1}{\\gamma_\\bot(z)} \\frac{\\textnormal{d} U(z)}{\\textnormal{d} z} + \\frac{\\mathrm{d} D_\\bot(z)}{\\mathrm{d}z}  = v_\\mathrm{d} + v_\\mathrm{spurious}~,\n\t\\label{Eq.total_drifts}\n\\end{equation}\n\nwhere, to recap, the first term $v_\\textnormal{d}$ is the drift velocity due to deterministic forces (electrostatic and gravitational interactions in our case). The spurious drift velocity $v_\\mathrm{spurious}$ disappears when the diffusion coefficient is homogeneous, and would also disappear along the $x$- and $y$-axes since the diffusion coefficients only depend on the colloid-wall distance $z$ (a derivative with respect to $x$ would replace the one in $z$ in the equivalent of Eq.~(\\ref{Eq.total_drifts}) for the $x$-direction). To conclude on that subject, and as pointed out by Mennella \\textit{et al.} \\cite{mannella_ito_2012}, this derivation is not formal as it requires several approximations. However, the result is still correct. A formal derivation has already been done \\cite{sancho_adiabatic_1982} and is done by taking the Fokker-Planck of the underdamped Langevin equation. Then they formally compute the limit of the underdamped Fokker-Planck equation when the mass of the particle tends to zero, using a mathematical method called adiabatic reduction.\n\nFinally, Using  Eqs.~(\\ref{Eq.hindered})~(\\ref{Eq:etaz_pade})~and~(\\ref{Eq.total_drifts}), the deterministic drift velocity reads:\n\n\\begin{equation}\n\tv_\\textnormal{d} =- \\frac{k_\\mathrm{B}T}{\\gamma_\\bot(z)} \\left[- \\frac{1}{\\ell_\\mathrm{D}} B \\exp \\left(- \\frac{z}{\\ell_\\mathrm{D}}\\right) + \\frac{1}{\\ell_\\mathrm{B}}\\right] ~,\n\\end{equation}\n\nand the spurious drift velocity reads:\n\n\\begin{equation}\n\tv_\\textnormal{spurious} (z)= 2  D_0 a\\frac{2a^2 + 12 az + 21 z^2}{(2 a^2 + 9az + z^2) ^2} ~,\n\t\\label{Eq.spurious_drift}\n\\end{equation}\n\nA typical example of drift velocity $\\bar{v}$ for a colloidal particle of radius $a = 1.5 ~\\mathrm{\\mu m}$ in water, moving near a wall, and interacting with the latter through an electrostatic potential with a Debye length $\\ell_\\mathrm{D} = 50 ~ \\mathrm{nm}$ and a dimensionless magnitude of the interaction $B = 4$, and evolving in a gravity field characterized by a Boltzmann length $\\ell_\\mathrm{B} = 500 ~ \\mathrm{nm}$, is plotted in Fig.~\\ref{fig.spurious}. As one can observe, the spurious drift is not negligible.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/spurious_drift/spurious.pdf}\n\t\\caption{Theoretical drift velocity for a colloidal particle of radius $a = 1.5 ~\\mathrm{\\mu m}$ in water and at a distance $z$ from the wall. The physical parameters $\\ell_\\mathrm{D} = 50 ~ \\mathrm{nm}$, $B = 4 $ and $\\ell_\\mathrm{B} = 500 ~ \\mathrm{nm}$. \\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/spurious_drift/spurious_drift.ipynb}{\\faGithub}} \n\t\\label{fig.spurious}\n\\end{figure}\n\n\n\\subsubsection{Numerical simulations of confined Brownian motion}\n\\label{sec:simconfined}\nWe previously determined that the simulation of a bulk Brownian motion without external forces can be simulated using Eq.~(\\ref{Eq.shortnumlangevin}).\nHowever, in the case of confined Brownian motion, and without density matching, one needs to take into account the hindered mobility, external forces due to gravity and the double-layer interaction, as well as the confinement-induced spurious drift. Putting all that together leads to a new equation for $x_i$ which reads for the motion parallel to wall (\\textit{i.e.} along the $x$- and $y$-axes):\n\n\\begin{equation}\n\tx_i = x_{i-1} +  \\sqrt{2D_\\parallel}w_i ~,\n\t\\label{eq.langevinnearx}\n\\end{equation}\n\nwhere we recall that we approximate the continuous position $X_t$ of a particle at a time $t$ by a discrete-time sequence $x_i$, which is the solution of the equation at a time $t_i = i\\tau$. $\\tau$ being the numerical integration time increment, and $w_i$ is a Gaussian-distributed number of mean value $\\langle w_i \\rangle =0$ and variance $\\langle w_i ^2\\rangle = \\tau$. For the perpendicular motion of the particle (along the $z$-axis), one needs to add the total drift $\\bar{v}_\\textnormal{d}$ of Eq.~(\\ref{Eq.total_drifts}), such that:\n\n\\begin{equation}\n\tz_i = z_{i-1} + \\bar{v}_\\mathrm{d}(z_{i-1}) \\tau + \\sqrt{2D_\\bot}w_i ~,\n\t\\label{eq.langevinnearz}\n\\end{equation}\n\n where $z_i$ is the discrete-time position sequence of a particle along the $z$-axis. Compared to bulk Brownian motion where the time step $\\tau$ can be chosen only according to the desired precision as shown previously on Fig.~\\ref{fig:MSEwi}, confinement adds another constraint. Indeed, the time step should be short enough for the drift $\\bar{v}_\\textnormal{d}$ and local diffusion coefficients to be relatively constant (as detailed later) in the time period $t_{i+1} - t_i = \\tau$ and in the displacement range $\\Delta z = z_{i+1} - z_i$, such that:\n\n\\begin{equation}\n\t\\bar{v}_\\mathrm{d} (z \\in [z_i, z_{i+1}]) \\simeq \\bar{v}_\\mathrm{d} (z_i) ~,\n\t\\label{driftc}\n\\end{equation}\n\nand:\n\n\\begin{equation}\n\tD_{\\bot, \\parallel}(z \\in [z_i, z_{i+1}]) \\simeq D_{\\bot, \\parallel}(z_i) ~.\n\\end{equation}\n\nSince the diffusion coefficient does not vary for the parallel motion, one can consider only the perpendicular motion to determine the optimal simulation time step. Also, as it can be seen in Fig.~\\ref{fig.taumax} the relative variation of the drift velocity $1/\\bar{v}_\\mathrm{d} \\partial_z \\bar{v}_\\mathrm{d}$ reaches higher values than the relative variation of the diffusion coefficient $1/D_\\bot \\partial_z D_\\bot$. Thus, finding $\\tau$ that satisfies Eq.~(\\ref{driftc}) is sufficient. Moreover, the vertical drift velocity varies more when the colloid is near the surface, \\textit{i.e.} in the region where one can approximate the diffusion coefficient $D_\\bot$ using Eqs.~(\\ref{Eq.hindered})~and~(\\ref{Eq:etaz_small}):\n\n\\begin{equation}\n\t\\left.D_\\bot  (z)\\right|_{z\\ll a} = D_ 0 \\frac{z}{a} ~.\n\t\\label{Dsmall}\n\\end{equation}\n\nIn that case, Eq.~(\\ref{Eq.total_drifts}) near the surface simplifies to:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\bar{v}_\\textnormal{d} &\\simeq  \\frac{k_\\mathrm{B}T}{\\gamma_0} \\frac{z}{a} \\left[\\frac{B}{\\ell_\\mathrm{D}} \\exp \\left(-\\frac{z}{\\ell_\\mathrm{D}}\\right) - \\frac{1}{\\ell_{\\mathrm{B}}}  \\right] + \\frac{\\partial}{\\partial z} D_0 \\frac{z}{a} \\\\\n\t\t&= \\frac{D_0}{a} \\left[ 1 + \\frac{Bz}{\\ell_\\mathrm{D}} \\exp \\left(-\\frac{z}{\\ell_\\mathrm{D}}\\right)- \\frac{1}{\\ell_{\\mathrm{B}}}\\right]\n\t\\end{aligned}\n\\end{equation}\n\nBy expanding the exponential term at the first order in $z/\\ell_\\mathrm{D}$, we get:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\bar{v}_\\textnormal{d}  = \\frac{D_0}{a} \\left( 1 + \\frac{B z}{\\ell_\\mathrm{D}} - \\frac{1}{\\ell_{\\mathrm{B}}}\\right)\n\t\\end{aligned}\n\t\\label{drifts_short}\n\\end{equation}\n\nTo satisfy Eq.~(\\ref{driftc}), we need to have a small relative change of the vertical drift velocity in an interval $[z, z+\\Delta z]$ \\cite{matse_state-dependent_nodate}, \\textit{i.e.}:\n\n\\begin{equation}\n\t\\frac{|\\bar{v}_\\mathrm{d} (z + \\Delta z) - \\bar{v}_\\mathrm{d} (z)|}{|\\bar{v}_\\mathrm{d} (z)|} \\ll 1 ~.\n\t\\label{condition_drift}\n\\end{equation}\n\nCombining Eqs.~(\\ref{drifts_short})~and~(\\ref{condition_drift}), we get:\n\n\\begin{equation}\n\t|\\Delta z |\\ll \\left[\\frac{B}{\\ell_{\\mathrm{D}}}\\right]^{-1} + z ~.\n\t\\label{inegality}\n\\end{equation}\n\n\nBesides, invoking the vertical \\gls{MSD} over the time step, as well as Eq.~(\\ref{Dsmall}), one gets:\n\n\\begin{equation}\n\t\\langle \\Delta z ^2 \\rangle (z) = 2 D_\\bot (z) \\tau = 2D_0 \\frac{z}{a}\\tau ~.\n\t\\label{msdshort}\n\\end{equation}\n\nCombining Eqs.~(\\ref{inegality})~and~(\\ref{msdshort}) thus leads to:\n\n\\begin{equation}\n\t\\tau = \\frac{a\\langle \\Delta z ^2 \\rangle }{2 D_0 z} \\ll \\frac{a}{2 D_0 } \\frac{\\left[\\left(\\frac{B}{\\ell_\\mathrm{D}} - \\frac{1}{\\ell_{\\mathrm{B}}}\\right)^{-1} + z\\right] ^2}{z} = \\tau_\\mathrm{max} (z)~.\n\t\\label{taumax}\n\\end{equation}\n\n At this point, there are two different options for the time step in the simulation: the first one is to do an adaptive time step using a local $\\tau(z)$ that satisfies $\\tau(z) \\ll \\tau_{\\textrm{max}}(z)$ for each step of the simulation; the second one is to find the smallest $\\tau_\\mathrm{max}(z)$ and use for all the simulation a time step $\\tau$ satisfying $\\tau \\ll \\mathrm{min}(\\tau_\\mathrm{max}) $. The latter can be evaluated by finding the height $z_\\mathrm{min}$, at which the derivative of $ \\tau_\\mathrm{max}$ nullifies, \\textit{i.e.}:\n\n\\begin{equation}\n\t\\left. \\frac{\\partial \\tau_\\mathrm{max}}{\\partial z} \\right| _{z_\\mathrm{min} }= 0 ~.\n\\end{equation} \n\nSolving the latter gives,\n\n\\begin{equation}\n\tz_\\mathrm{min} = \\left| \\left( \\frac{B}{\\ell_\\mathrm{D}} - \\frac{1}{\\ell_{\\mathrm{B}}}\\right)^{-1} \\right|~.\n\\end{equation}\n\n\nwhich finally gives:\n\n\\begin{equation}\n\t\\mathrm{min}(\\tau_\\mathrm{max}) =  \\frac{2 a}{D_0}  \\left| \\left( \\frac{B}{\\ell_\\mathrm{D}} - \\frac{1}{\\ell_{\\mathrm{B}}}\\right)^{-1} \\right| ~.\n\\end{equation}\n\nIn Fig.~\\ref{fig.taumax}-b) $\\tau_{\\mathrm{max}}$ is plotted as a function of $z$, for $a=1.5 ~\\mathrm{\\mu m}$, $B = 4$ and $\\ell _\\mathrm{D}$ varying between $20$ and $100$ nm. We observe that for this range of values that represents well the experiments that I have performed during my thesis, taking a constant simulation time step $\\tau \\approx 0.01 ~ \\mathrm{s}$ is satisfactory.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/simulation_confined_Brownian_motion/z_traj_sim.pdf}\n\t\\caption{Simulated trajectory along the direction normal to the wall, using Eq.~(\\ref{eq.langevinnearz}) with $\\alpha = 1$ (isothermal convention), of radius $a= 1.5  ~ \\mathrm{\\mu m}$, density $\\rho_\\mathrm{p} = 1050  ~\\mathrm{kg.m^{-3}}$, placed in water near a wall. The particle-wall interaction is characterized by $\\ell_\\mathrm{D} = 50$ nm and $B=4$. \\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/simulation_confined_Brownian_motion/Overdamped_confined_simulation.ipynb}{\\faGithub}} \n\t\\label{fig.z_traj_confined_simulated}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/simulation_confined_Brownian_motion/maximal_tau.pdf}\n\t\\caption{a) Theoretical computation of the relative variation of the drift velocity $\\bar{v}_\\mathrm{d}$ and perpendicular diffusion coefficient $D_\\bot$ as a function particle-wall distance $z$. The parameters are $\\ell_\\mathrm{D}=50$, $B=4$ and $\\ell_{\\mathrm{B}} = 500$ nm b) Optimal numerical integration time step $\\tau_\\mathrm{max}$ as a function of the particle-wall distance $z$ for a particle of radius $a = 1.5 ~\\mathrm{\\mu m}$, with $\\ell_{\\textrm{B}}=500$~nm, $B = 4$, and for different Debye lengths as indicated. The black line connects the minima.\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/simulation_confined_Brownian_motion/maximal_tau.ipynb}{\\faGithub}} \n\t\\label{fig.taumax}\n\\end{figure}\n\n\nWe have developed the numerical simulation of Eqs.~(\\ref{eq.langevinnearx})~and~(\\ref{eq.langevinnearz}) using Python, as part of the Master's internship of Élodie Millan. The interested reader will find more information on  the simulation of confined Brownian motion in complex systems in her forthcoming thesis. A typical trajectory of a water-immersed colloidal particle of radius $a= 1.5  ~ \\mathrm{\\mu m}$ and density $\\rho_\\mathrm{p} = 1050  ~\\mathrm{kg.m^{-3}}$, near a wall with which the electrostatic interaction is characterized by $\\ell_\\mathrm{D} = 50$ nm and $B=4$, is plotted in Fig.~\\ref{fig.z_traj_confined_simulated}. It qualitatively resembles the experimental trajectory that was shown in Fig.~\\ref{Fig:exp_z_traj} as an introduction to the chapter. To check if the spurious drift is correctly implemented, the constraint we have is that the long-time statistics should satisfy Eq.~(\\ref{Eq.Peq}). To compute an experimental probability density function from a set of points, one can use the following Python snippet.\n\n\\newpage\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\ndef pdf(data, bins=10, density=True):\n\t\n  pdf, bins_edge = np.histogram(data, bins=bins, density=density)\n  bins_center = (bins_edge[0:-1] + bins_edge[1:]) / 2\n\t\n  return pdf, bins_center\n\\end{minted}\n\nThe long-time \\gls{PDF} in position, for with and without the spurious drift $v_\\mathrm{spurious}$ are shown in Fig.~\\ref{fig.pdf_vs_alpha}. We see that the spurious drift velocity $v_\\mathrm{spurious}$ permits retrieving the correct distribution. In the case ($v_\\mathrm{spurious} = 0$), we observe that the particle is more likely to be found closer to the surface, as a result of the missing compensating spurious drift of Eq.~(\\ref{Eq.spurious_drift}).\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/simulation_confined_Brownian_motion/Peq_vs_alpha.pdf}\n\t\\caption{Simulated, Long-term Probability Density Function of the height of the particle with or without the spurious drift, as indicated. The solid black line represents the expected Gibbs-Boltzmann distribution. The physical parameters are: $a = 1.5 ~ \\mathrm{\\mu m}$, $\\rho_\\mathrm{p} = 1050 ~\\mathrm{kg.m^{-3}}$, $\\ell_\\mathrm{D} = 21$ nm, $B = 4.8$ and $\\ell_\\mathrm{B} = 577$ nm. \\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/simulation_confined_Brownian_motion/Overdamped_confined_simulation.ipynb}{\\faGithub}}\n\t\\label{fig.pdf_vs_alpha}\n\\end{figure}\n\n\n\\subsection{Experimental study}\n\\label{section:expresults}\nLet us now analyze the experimental data acquired through the Mie tracking (see section \\ref{chap:LM_fit}). In the near-wall Brownian dynamic theory presented section~\\ref{sec:confined}, we considered distance $z$ between the wall and the colloidal particle surface. However, it is not the height measured by the Mie tracking, since the latter measures the distance between the objective-lens focal plane and the particle center. Therefore, we measure the trajectory up to an offset, \\textit{i.e.} the objective-lens focal plane to wall distance. To have the correct measured height, we suppose that the particle does approach very closely to the wall, such that the minimal measured distance is the focal plane to the wall distance. From that assumption, we set the minimal value of $z$ in the trajectory to zero. This is repeated periodically and thus termed the moving-minimum method, and can be calculated using the following Python function.\n\n\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tobeytabs=true,\n\ttabsize=2,\n\tlinenos\n\t]\n\t{python}\ndef movmin(z, window):\n\tresult = np.empty_like(z)\n\tstart_pt = 0\n\tend_pt = int(np.ceil(window / 2))\n\t\n\tfor i in range(len(z)):\n\t\tif i < int(np.ceil(window / 2)):\n\t\t\tstart_pt = 0\n\t\tif i > len(z) - int(np.ceil(window / 2)):\n\t\t\tend_pt = len(z)\n\t\t\t\n\t\tresult[i] = np.min(z[start_pt:end_pt])\n\t\tstart_pt += 1\n\t\tend_pt += 1\n\treturn result\n\\end{minted}\n\nIn the above snippet, \\mintinline{python}{window} represents the number of points used to compute the minimum. As an example, if one chooses \\mintinline{python}{window = 100}, the first value of \\mintinline{python}{result} is the minimum of the first 100 points of \\mintinline{python}{z}. If there is enough data around the point where the minimum is calculated, the ensemble is centered, with a new window of size 100 (\\textit{i.e.} \\mintinline{python}|result[100] = np.min(z[50:150])|. If there is not enough point around the $n$-th point, we then take the average value of the first (or the last) $n$ points. The raw and shifted trajectories are shown  in Fig.~\\ref{fig.rescaled_traj}. Moreover, subtracting the moving minimum has a benefit. Indeed, it can remove some experimental drift due to the mechanical movement of the optical pieces of the microscope. Also, due to the approximation made to use the moving-minimum method, the exact location of the $z=0$ origin is \\textit{a priori} undetermined we need to add to the physical parameters $B$, $\\ell_\\mathrm{D}$ and $\\ell_\\mathrm{B}$ a forth parameter: the height offset $z_\\mathrm{off}$ that accounts for the correction of the wall position.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/traj_rescaled.pdf}\n\t\\caption{Raw trajectories measured using the Mie-tracking technique, and its shifted version (bottom, orange) using the moving-minimum method with a window of $10000$ points.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/graph_ploting.ipynb}{\\faGithub}} \n\t\\label{fig.rescaled_traj}\n\\end{figure}\n\n\\subsubsection{Equilibrium distribution}\n\\label{sec:Eqdistrib}\n\nAs we have done for the simulated trajectory, one can construct the equilibrium probability density function $P_\\mathrm{eq}(z)$ of the position of the particle. As seen in Fig.~\\ref{fig.pdf_exp}, and explained in section \\ref{sec:gravit}, an exponential tail is observed at large distance, which is identified to the sedimentation contribution in Perrin's experiment~\\cite{perrin_les_2014}, but here with the probability density function of a single particle instead of the concentration field. In contrast, near the wall, we observe an abrupt depletion, indicating a repulsive electrostatic contribution. Additionally, we see that the Gibbs-Boltzmann distribution of Eq.~(\\ref{Eq.Peq}) fits the data very well.\n\n\n\nMoreover, as shown in Fig.~\\ref{fig.ld}, we recover the Debye relation, \\textit{i.e.} $\\ell_{\\mathrm{D}}=0.304/\\sqrt{\\textrm{[NaCl]}}$ (see Eq.~(\\ref{ldnacl})), with $\\ell_{\\mathrm{D}}$ in nm, and where [NaCl] is the concentration of salt in mol/L, with a prefactor corresponding to a single monovalent salt in water at room temperature~\\cite{israelachvili_intermolecular_2015}. Besides, we have verified, as shown in Fig.~\\ref{fig.ld}, that the dimensionless parameter $B$ related to surface charges is constant in the studied salt-concentration range, thus excluding any nonlinear effect~\\cite{wang_measurement_2011,oberholzer_grand_1997} in our case. \n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/pdf_exp.pdf}\n\t\\caption{Measured equilibrium probability density function $P_{\\textrm{eq}}$ of the distance $z$ between the particle and the wall. The solid line represents the best fit to the normalized Gibbs-Boltzmann distribution in position, using the total potential energy $U(z)$ of Eq.~(\\ref{Eq:PDF}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~ \\mathrm{nm}$.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/graph_ploting.ipynb}{\\faGithub}}\n\t\\label{fig.pdf_exp}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/ld.pdf}\n\t\\caption{In blue, left axis, measured Debye length $\\ell_\\mathrm{D}$ as a function of salt concentration [NaCl]. The solid line is the expected Debye relation $\\ell_\\mathrm{D}=0.304/\\sqrt{\\textrm{[NaCl]}}$, for a single monovalent salt in water at room temperature. In green, right axis, measured $B$ as a function of salt  concentration [NaCl]. The dashed line represents the mean value of the measured $B$ values.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/resume_ld_measures.ipynb}{\\faGithub}}\n\t\\label{fig.ld}\n\\end{figure}\n\n\n\\subsubsection{Mean Square Displacement}\n\nWe now turn to dynamical aspects, by considering the mean-squared displacement (MSD). We recall that, for the three spatial directions, indexed by $i=x$, $y$, and $z$, corresponding to the coordinates $r_x=x$, $r_y=y$, and $r_z=z$, of the position $\\vec{r}$, and for a given time increment $\\Delta t$, the MSD is defined as:\n\\begin{equation}\n\t\\langle\\Delta r_i(t)^2 \\rangle_t = \\langle[r_i(t+\\Delta t) - r_i(t)]^2\\rangle_t\\ ,\n\t\\label{MSDdef}\n\\end{equation}\nwhere the average $\\langle\\rangle_t$ is performed over time $t$. For a free Brownian motion in the bulk, and in the absence of other forces than the dissipative and random ones, the \\gls{MSD} is linear in time, \\textit{i.e.} $\\langle\\Delta r_i(t)^2 \\rangle_t = 2 D_0 \\Delta t$, where is the bulk diffusion coefficient (see Eq.~(\\ref{Eq.D})) given by the Stokes-Einstein relation~\\cite{einstein_uber_1905}. Further including sedimentation restricts the validity of the linearity of the \\gls{MSD} along the $z$-axis to short times only, \\textit{i.e.} for $\\Delta t\\ll\\ell_{\\textrm{B}}^2/D_0$ such that the vertical diffusion is not yet affected by the gravitational drift.\n\nAs explain in section \\ref{subsec:double} The presence of a rigid wall at $z=0$ adds a repulsive electrostatic force along $z$. It also decreases the mobilities nearby through hydrodynamic interactions (see section \\ref{sec:diff}), where we recall that it leads to effective viscosities $\\eta_\\parallel(z)=\\eta_x(z)=\\eta_y(z)$, and $\\eta_\\bot(z) = \\eta_z(z)$ (see Eq.\\ref{Eq.hindered}). Interestingly, despite the previous modifications, the temporal linearity of the MSD is not altered by the presence of the wall~\\cite{chubynsky_diffusing_2014,prieve_measurement_1999} for $x$ and $y$, as well as at short times for $z$. In such cases, the MSD reads:\n\\begin{equation}\n\t\\langle\\Delta r_i(t)^2 \\rangle_t = 2 \\langle D_i \\rangle \\Delta t\\ ,\n\t\\label{averagediff}\n\\end{equation}\n\nwhere we introduced the average of the local diffusion coefficient:\n\n\\begin{equation}\n\t\\langle D_i(z) \\rangle = \\int_0^{\\infty} \\textrm{d}z\\, D_i(z)P_{\\textrm{eq}}(z) ~,\n\\end{equation}  \n\nagainst the Gibbs-Boltzmann distribution in position. As shown in Fig.~\\ref{fig.MSD}, the MSD measured along $x$ or $y$ is indeed linear in time. By fitting the data to Eq.~(\\ref{averagediff}), using Eqs.~(\\ref{Eq:PDF})~and~(\\ref{Eq:etax}), we extract an average transverse diffusion coefficient $\\langle D_\\parallel \\rangle= \\langle D_x\\rangle=\\langle D_y \\rangle= 0.52\\, D_0$. In contrast, along $z$, we identify two different regimes: one at short times, where the \\gls{MSD} is still linear in time, with a similarly-obtained best-fit value of $\\langle D_z \\rangle= 0.24\\, D_0$; and one at long times, where the MSD saturates to a plateau. This latter behavior indicates that the equilibrium regime has been reached, with the particle having essentially explored all the relevant positions given by the Gibbs-Boltzmann distribution.\n\n\\begin{figure}[t!]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/msd.pdf}\n\t\\caption{Measured mean-squared displacements (MSD, see Eq.~(\\ref{MSDdef})) as functions of the time increment $\\Delta t$, for the three spatial directions, $x$, $y$, and $z$. The solid lines are best fits to Eq.~(\\ref{averagediff}), using Eqs.~(\\ref{Eq:PDF}),~(\\ref{Eq:etaz})~and~(\\ref{Eq:etax}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$,\n\t\tproviding the average diffusion coefficients $\\langle{D_\\parallel}\\rangle= \\langle D_x\\rangle=\\langle D_y \\rangle =0.52\\,D_0$ and $\\langle D_z \\rangle =0.24\\, D_0$. The dashed line is the best fit to Eq.~(\\ref{Eq:plateau}), using Eq.~(\\ref{Eq:PDF}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/graph_ploting.ipynb}{\\faGithub}}\n\t\\label{fig.MSD}\n\\end{figure}\n\n\n\\subsubsection{Non-Gaussian dynamics - displacement distribution}\n\nHaving focused on the \\gls{MSD}, \\textit{i.e.} on the second moment only, we now turn to the full-Probability Density Function $P_i$ of the displacement $\\Delta r_i$. Since the diffusion coefficient $D_i(z)$ varies as a result of the variation of $z$ along the particle trajectory, $P_i$ exhibits a non-Gaussian behavior, as seen in Figs.~\\ref{fig.displacement}-a,b,c,d). We even resolve the onset of a non-Gaussian behavior in $P_x$, by zooming on the large-$\\lvert\\Delta x\\rvert$ wings. At short times, the diffusion coefficient $D_i$ and the drift velocity $\\bar{v}_\\mathrm{d}$, can be considered constant. By writing the initial condition of the particle-wall distance $\\delta(z - z_0)$, the solution of Eq.~(\\ref{final_fokker}) becomes:\n\n\\begin{equation}\n\t\\begin{aligned}\n\t\tP_z(z, z_0, \\Delta t) &= \\exp \\left[  \\frac{\\partial ^2}{\\partial z ^2} D_\\bot(z_0) \\Delta t - \\frac{\\partial}{\\partial z} \\bar{v} _\\mathrm{d} (z_0) \\Delta t \\right] \\frac{1}{2 \\pi} \\int _{-\\infty} ^{\\infty} ~ \\textnormal{d}u \\exp (ju(z-z_0))  \\\\\n\t\t& = \\frac{1}{2\\pi} \\int_{-\\infty}^{\\infty} ~ \\textnormal{d}u \\exp \\left[ -u^2 D_\\bot(z_0)\\Delta t + ju(z-z_0) - ju  \\bar{v} _\\mathrm{d} (z_0) \\Delta t \\right] ~.\n\t\\end{aligned}\n\\end{equation}\n\nThe latter can be reduced at short times to\\cite{matse_state-dependent_nodate, risken_fokker-planck_2012}:\n\n\\begin{equation}\n\tP_z(\\Delta z, z_0, \\Delta t) =   \\frac{1}{\\sqrt{4 \\pi D_i(z_0) \\Delta t}} \\exp \\left[-\\frac{(\\Delta r_i - \\bar{v}_\\mathrm{d}\\Delta t)^2}{4 D_i(z_0) \\Delta t}   \\right]\\ ,\n\t\\label{Pdxshort}\n\\end{equation}\nwhich is a Gaussian distribution with a mean value $\\langle \\Delta z \\rangle =  \\bar{v}_\\mathrm{d}\\Delta t$. The same calculus can be done for the $x$- and $y$-axes, by setting the drift velocity to zero and using $D_\\bot$. Additionally, it has a standard deviation $\\sigma_i(z_0) = \\sqrt{2D_i (z_0) \\Delta t}$. From Eq.~(\\ref{Pdxshort}), we can observe than the total drift $\\bar{v}_\\mathrm{d}$ induces an asymmetry on the displacement along the $z$-axis. However, in our experiment, as we have access to long-enough trajectories to reach equilibrium, the statistics are not conditioned by the initial position, but by the Gibbs-Boltzmann distribution of Eq.~(\\ref{Eq.Peq}). At short times, $P_i$ can thus be modeled by the averaged diffusion Green's function~\\cite{matse_test_2017,hapca_anomalous_2009}:\n\\begin{equation}\n\t\\begin{aligned}\n\t\tP_i(\\Delta r_i, \\Delta t) & = \\int _{0} ^\\infty ~\\textnormal{d} z P_\\mathrm{eq} (z) P(\\Delta r_i, z, \\Delta t) \\\\\n\t\t&= \\int ^\\infty _0 \\mathrm{d}z\\, P_{\\textrm{eq}}(z) \\frac{1}{\\sqrt{4 \\pi D_i(z) \\Delta t}} \\textrm{e}^{-\\frac{\\Delta r_i^2}{4 D_i(z) \\Delta t}     }\\ ,\n\t\\end{aligned}\n\t\\label{Eq:PDzshort}\n\\end{equation}\nagainst the Gibbs-Boltzmann distribution. The latter equation can alternatively be written as an integral over the diffusion coefficient such that:\n\\begin{equation}\n\tP_i(\\Delta r_i , \\Delta t) = \\int_0 ^\\infty \\mathrm{d}D_iP(D_i) \\frac{1}{\\sqrt{4 \\pi D_i \\Delta t}} \\mathrm{e} ^{\\frac{-\\Delta r_i ^2}{4D_i\\Delta t}} \n\\end{equation}\n\nThis equation can be evaluated using the following Python snippet.\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\ndef P_D(B, ld, lb):\n  # Computing the D PDF.\n  z = np.linspace(1e-9, 15e-6, 1000)\n  P_D = Dz(z) * P_eq(z, B, ld, lb)\n  P_D = P_D / np.trapz(P_D, z)  # extra step to ensure PDF normalization\n  return Dz(z), P_D\n\t\n\t\ndef _P_Dz_short_time(Dz, Dt, B, ld, lb):\n  # Using the D PDF to compute P()\n  D_z, P_D = P_D(B, ld, lb)\n  P = P_D / np.sqrt(4 * np.pi * D_z * Dt) * np.exp(-(Dz ** 2) / (4 * D_z * Dt))\n  P = np.trapz(P, D_z)\n  return P\n\t\n\t\n\t# Creating a handy function for easier use with Dz numpy arrays\ndef P_Dz_short_time(Dz, Dt, B, ld, lb):\n  P = np.array([_P_Dz_short_time(i, Dt, B, ld, lb) for i in Dz])\n  P = P / np.trapz(P, Dz) # extra step to ensure PDF normalization\n  return P\n\\end{minted}\n\nIn this snippet, the evaluation is done for $\\Delta z$. However, when computing $P_x(\\Delta x)$ one should just change the \\mintinline{python}{Dz(z)} function to $D_\\parallel$. Since $P$ is a \\gls{PDF}, it should be normalized such that $\\int P = 1$. We added an extra step to ensure \\gls{PDF} normalization along the evaluation.\nAt long enough time, since we have reached equilibrium, the averaged particle's drift should be equal to zero thus leading to a mean value $\\langle \\Delta r_i \\rangle_t  = 0$. As shown in Figs.~\\ref{fig.displacement}-a,c,b,d) Eq.~(\\ref{Eq:PDzshort}) captures the early data very well. At long times, Eq.~(\\ref{Eq:PDzshort}) remains valid only for $P_x$ and $P_y$. Nevertheless, the equilibrium regime being reached, $P_z$ only depends on the Gibbs-Boltzmann distribution. Indeed, in this regime $P_z$ can be written as a convolution of two Gibbs-Boltzmann distribution as in a displacement $\\Delta z = z(t+\\Delta t) - z(t)$, $ z(t+\\Delta t)$ and  $z(t)$ comes from independent draw from the Gibbs-Boltzmann distribution:\n\\begin{equation}\n\t\\lim_{\\Delta t\\rightarrow\\infty}P_z(\\Delta z, \\Delta t) = \\int_0^{\\infty}\\textrm{d}z\\,P_{\\textrm{eq}}(z+\\Delta z)P_{\\textrm{eq}}(z)\\ ,\n\t\\label{auxiliary}\n\\end{equation}\nwhich contains in particular the second moment:\n\\begin{equation}\n\t\\lim_{\\Delta t\\rightarrow\\infty}\\langle\\Delta z ^2\\rangle = \\int _{- \\infty} ^{+ \\infty}\\textrm{d}\\Delta z\\, \\Delta z^2\\int_0^{\\infty}\\textrm{d}z\\, P_{\\textrm{eq}}(z+\\Delta z)P_{\\textrm{eq}}(z) \\ .   \n\t\\label{Eq:plateau}\n\\end{equation}\n\nAs shown in Fig.~\\ref{fig.displacement}-e), Eq.~(\\ref{auxiliary}) captures the long-term data along $z$ very well. Moreover, it possible to show that $\\lim_{\\Delta t\\rightarrow\\infty}\\langle\\Delta z ^2\\rangle \\sim \\ell _\\mathrm{B}^2$. Using this approximation we can evaluate the time $\\tau_c$ needed to attain the equilibrium regime. If a particle diffuses with a diffusion coefficient $\\langle D_\\parallel \\rangle$ it needs, on average a time: \n\n\\begin{equation}\n\t\\tau_c = \\frac{\\ell_\\mathrm{B}^2}{2\\langle D_\\parallel \\rangle},\n\\end{equation}\n\nto diffuse over distance $\\ell_\\mathrm{B}$. By approximating the average coefficient by $\\langle D_\\parallel \\rangle \\sim D_0 \\ell_\\mathrm{B}/ a $, one can find that $\\tau_c$ scales as:\n\n\\begin{equation}\n\t\\tau_c \\sim \\frac{\\ell_\\mathrm{B} a}{D_0} = \\frac{\\eta}{\\Delta \\rho a g} ~.\n\\end{equation}\n\nInterestingly, that means that taking smaller particles that has higher diffusion coefficient do not reach equilibrium faster. Additionally, Eq.~(\\ref{Eq:plateau}) permits to fit the long-term plateau of the \\gls{MSD} shown in Fig.~\\ref{fig.MSD}. Eq.~(\\ref{auxiliary}) can be evaluated using the following Python function.\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]\n\t{python}\ndef _Pdeltaz_long(DZ, B, ld, lb):\n  z = np.linspace(0, 20e-6, 1000)    \n  dP = P_eq(z, B, ld, lb) * P_eq(z + DZ, B, ld, lb)\n  P = trapz(dP,z)\n  return P\n\t\ndef Pdeltaz_long(DZ, B, ld, lb):\n  pdf = np.array([_Pdeltaz_long(i,B, ld, lb) for i in DZ])\n  pdf = pdf / trapz(pdf,DZ)\n  return pdf\n\t\n\\end{minted}\n\nwhere the \\mintinline{python}{P_eq} function has been described in section \\ref{Section:sphere-wall}. \n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/P_displacement.pdf}\n\t\\caption{a, b) Probability density functions $P_i$ of the displacements $\\Delta x$ and $\\Delta z$, at short times. The solid lines are the best fits to Eq.~(\\ref{Eq:PDzshort}), using Eqs.~(\\ref{Eq.Peq}),~(\\ref{Eq:etaz}),~and~(\\ref{Eq:etax}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$. c,d) Normalized probability density functions $P_i\\,\\sigma$ of the normalized displacements $\\Delta x/\\sigma$ and $\\Delta z/\\sigma$, at short times, with $\\sigma^2$ the corresponding MSD (see Fig.~\\ref{fig.MSD}), for different time increments $\\Delta t$ ranging from 0.0167~s to 0.083~s, as indicated with different colors. The solid lines are the best fits to Eq.~(\\ref{Eq:PDzshort}), using Eqs.~(\\ref{Eq:PDF}),~(\\ref{Eq:etaz}),~and~(\\ref{Eq:etax}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$. For comparison, the gray dashed lines are normalized Gaussian distributions, with zero means and unit variances. e) Probability density function $P_z$ of the displacement $\\Delta z$, at long times, averaged over several values of $\\Delta t$ ranging between 25 s and 30~s. The solid line is the best fit to Eq.~(\\ref{auxiliary}), using Eq.~(\\ref{Eq:PDF}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$.}\n\t\\label{fig.displacement}\n\\end{figure}\n\n\n\n\\subsubsection{Local diffusion coefficient}\n\nWe now wish to go beyond the previous average $\\langle D_i\\rangle$ of Eq.~(\\ref{averagediff}), and resolve the local diffusion coefficient $D_i(z)$. To measure local viscosities from experimental trajectories, a binning method is generally employed~\\cite{friedrich_approaching_2011}. This method computes the average $\\langle ( \\Delta r_i^2 ) (z) \\rangle_t$ locally over a $z$-binning grid such that the local diffusion coefficient writes:\n\n\\begin{equation}\n\tD_i(z) = \\frac{\\langle  \\Delta r_i^2  \\rangle _t (z)}{\\Delta t} ~.\n\t\\label{binning}\n\\end{equation}\n\nUsing this method, Vestergard \\textit{et al.} \\cite{vestergaard_estimation_2015} discovered that the obturation time of the camera and the localization error $\\sigma_{\\mathrm{r}_i}$ plays an important role in the determination of the local diffusion coefficient such that Eq.~\\ref{binning} should be rewritten as:\n\n\\begin{equation}\n\tD_i(z) = \\frac{\\langle  \\Delta r_i^2 \\rangle _t (z) - 2 \\sigma_{\\mathrm{r}_i}^2}{2(1 - R)\\Delta t}~.\n\t\\label{binning_vestergaard}\n\\end{equation}\n\nwhere $R$ is a motion blur coefficient that depends on the aperture time of the camera. Let us write $\\tau$ the time lapse between the capture of two images, and $\\zeta(t)$ the state of the camera shutter during this time-lapse. $\\zeta(t) > 0$ indicates that an open shutter while  $\\zeta(t) = 0$ indicates a close shutter. The scale $\\zeta(t)$ is fixed by the normalization condition $\\int_{0}^{\\tau} \\zeta(t)\\textnormal{d}t = 1$. The motion blur coefficient is given by:\n\n\\begin{equation}\n\tR = \\frac{1}{\\tau} \\int_{0}^{\\tau} S(t)[1 - S(t)] \\textnormal{d}t,\n\\end{equation}\n\nwhere $S(t) = \\int_{0}^{t}\\zeta(t') \\textnormal{d}t'$. If the shutter is kept open for the whole duration of the time-lapse, one has $R = 1/6$. The localization error $\\sigma_{\\mathrm{r}_i}$ can be determined from a measured trajectory. Taking into account that Brownian motion should not be correlated, one can measure $\\sigma_{\\mathrm{r}_i}$ by calculating the autocorrelation $x_i(n)$ as a function of the number of time steps $n$ of the particle position $r_i$, which we defined as:\n\n\\begin{equation}\n\tx(n) =  \\langle (r_i(t) - \\langle r_i(t) \\rangle_t  ) (r_i(t + n\\Delta t) - \\langle r_i(t) \\rangle_t) \\rangle_t ~.\n\\end{equation}\n\nIn \\cite{vestergaard_estimation_2015} the localization error (also called Vestergaard error) is written as:\n\n\\begin{equation}\n\t\\sigma_{\\mathrm{r}_i} = \\sqrt{x(1) - \\frac{2 \\langle \\Delta r_i^2 \\rangle_t }{1-R}}\n\\end{equation}\nMoreover,  mechanical drifts (or evaporation driven-flow in the sample) can lead to correlation in the position time-series, such that $\\sigma_{\\mathrm{r}_i}$ increases in the presence of unwanted drifts. In our experience we had $\\sigma_{\\mathrm{r}_x} = \\sigma_{\\mathrm{r}_y} = 12$~nm and $\\sigma_{\\mathrm{r}_z} = 6$~nm. \n\n\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[scale=0.6]{02_body/chapter3/images/diffusion_coefficient/figure_Ronceray.png}\n\t\\caption{Figure from \\cite{frishman_learning_2020}. Quantitative comparison of Surface Force Inference (\\gls{SFI} with other methods on a simulated system mimicking 2D single-molecule trajectories in a complex environment with space-dependent isotropic diffusion. a) The diffusion field (blue gradient) and drift field (white arrows). b) The steady-state distribution function (\\gls{PDF}) of the process. The traces are representative trajectories of $100$ time steps. c-f) Comparison of the performance of \\gls{SFI} and two widely used inference methods: InferenceMAP, a method for single-molecule inference (blue triangles)  \\cite{beheiry_inferencemap_2015}, and grid-based binning with maximum-likelihood estimation \\cite{hoze_heterogeneity_2012, friedrich_approaching_2011} (orange squares). They evaluated the performance of these methods on the approximation of the drift field (c),e)) and diffusion field (d)f)) as a function of the number $N$ of single-molecule trajectories (similar to the ones in panel b)) used. With ideal data (c),d)) and in the presence of measurement noise(e),f)). The performance is evaluated as the average mean-squared error on the reconstructed field along trajectories.  More information about the parameters of their simulation and analysis can be found in their work \\cite{frishman_learning_2020}.}\n\t\\label{fig.ronceray}\n\\end{figure}\n\nAlthough the binning method is well suited for drift measurements, it suffers from a lack of convergence and precision when second moments or local diffusion coefficients have to be extracted. In particular, the binning method did not allow us to measure specifically the local diffusion coefficient in the key interfacial region corresponding to $z<100$~nm. Indeed, as we can observe in Fig.~\\ref{fig.ronceray}-f) the diffusion error on noisy (such as experimental) data does saturate, and the binning method is outperformed by a robust method  recently developed by Frishman and Ronceray \\cite{frishman_learning_2020}. This method uses Stochastic Force Inference (\\gls{SFI}), in order to evaluate spatially varying force fields and diffusion coefficients, from the information contained within the trajectories. \n\nIn practice the \\gls{SFI} method computes a local diffusion estimator:\n\n\\begin{equation}\n\t\\hat{d}(t_i) = \\frac{[\\Delta r_i (t_{i-1}) +\\Delta r_i (t_{i}) ]^2}{4 \\Delta t} + \\frac{\\Delta r_i (t_{i})\\Delta r_i (t_{i-1})}{2\\Delta t},\n\\end{equation}\n\nwhere the second term corresponds to Vestergaard error. Then, by approximating locally the diffusion coefficient by a polynomial function basis (such as $\\sum_0 ^n a_n z^n$). One can use the latter defined estimator in order to fit locally the polynomial coefficient. Once the coefficients estimated, one can compute the diffusion coefficient for any height $z$ in the range of the provided data $r_i$ (\\textit{i.e.} in the range [min($r_i$), max($r_i$)]. Although, the mathematical details of the \\gls{SFI} method are beyond the scope of the presented work as it requires a great knowledge of information theory, we used the \\gls{SFI} method as a tool. We implemented this method, using a fourth-order polynomial base. To simplify the use of the method with our data, we developed a simple Python function \\href{https://github.com/eXpensia/StochasticForceInference/blob/master/fun_SFI.py}{\\faGithub} which can infer the local diffusion coefficient by only one function call.\n\n\\begin{minted}\n\t[\n\tframe=lines,\n\tframesep=2mm,\n\tbaselinestretch=1.2,\n\tfontsize=\\footnotesize,\n\tlinenos\n\t]{text}\n\n\nDx, Dy, Dz, z_D = Compute_diffusion(pos)\n\n\\end{minted}\n\n\n\nwhere \\mintinline{python}{pos}, is the 3D trajectory of a Brownian colloid. It allowed us to infer the local diffusion coefficients $D_i(z)$, down to $z=10$~nm, as shown in Fig.~\\ref{fig.visco}. The results are in excellent agreement with the theoretical predictions, $D_{\\parallel}(z)$ and $D_z(z)$, using  Eqs.~(\\ref{Eq:etaz})~and~(\\ref{Eq:etaz}), thus validating the method.\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/visco.pdf}\n\t\\caption{ Measured local short-term diffusion coefficients $D_i$ of the microparticle, normalized by the bulk value $D_0$, as functions of the distance $z$ to the wall, along both a transverse direction $x$ or $y$ ($D_i=D_\\parallel=D_x=D_y$, blue) and the normal direction $z$ ($D_i=D_z$, green) to the wall. The solid lines are the theoretical predictions, $D_{\\parallel}(z)=D_0\\eta/\\eta_{\\parallel}(z)$ and $D_z(z)=D_0\\eta/\\eta_z(z)$, using the local effective viscosities $\\eta_{\\bot}(z)$ and $\\eta_\\parallel(z)$ of Eqs.~(\\ref{Eq:etaz})~and~(\\ref{Eq:etax}), respectively.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/graph_ploting.ipynb}{\\faGithub}}\n\t\\label{fig.visco}\n\\end{figure}\n\n\\subsubsection{Precise potential inference using multi-fitting technique}\n\\label{sec:multi}\nSo far, through Figs.~\\ref{fig.pdf_exp}-\\ref{fig.visco}, we have successively presented the various measured statistical quantities of interest, as well as their fits to corresponding theoretical models. Therein, we have essentially three free physical parameters, $B$, $\\ell_\\mathrm{B}$, $\\ell_\\mathrm{D}$, describing the particle and its environment, as well as the \\textit{a priori} undetermined location of the $z=0$ origin. These four parameters are actually redundant among the various theoretical models. Therefore, in order to measure them accurately, we in fact perform all the fits simultaneously,\nusing a Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm that is well suited for unconstrained\nnonlinear optimization~\\cite{dai_convergence_2002}. To do so, we construct a global minimizer:\n\\begin{equation}\n\t\\chi ^ 2 = \\sum _{n=1} ^{N} \\chi_n ^ 2\\ ,\n\\end{equation}\nwhere we introduce the minimizer $\\chi _n ^2$ of each set $n$ among the $N$ sets of data, defined as:\n\\begin{equation}\n\t\\chi _n ^2 = \\sum _{i=1} ^{M_n} \\frac{[y_{ni} - f_n(x_{ni}, \\mathbf{b})]^2 }{f_n(x_{ni}\\ , \\mathbf{b})^2}\\ ,\n\\end{equation}\nwith $\\{x_{ni},y_{ni}\\}$ the experimental data of set $n$, $M_n$ the number of experimental data points for set $n$, $f_n$ the model for set $n$, and $\\mathbf{b}=(b_1,b_2,...,b_p)$ the $p$ free parameters. In our case, $p=4$, and $\\{x_{ni},y_{ni}\\}$ represent all the experimental data shown in Figs.~\\ref{fig.pdf_exp}-\\ref{fig.visco}. \n\nDue to strong dependence of the normal diffusion coefficient $D_z$ with $z$, it is possible to find the wall position with a 10 nm resolution, thus overcoming a drawback of the Lorenz-Mie technique which only provides the axial distance relative to the focus of the objective lens. Besides, the three physical parameters globally extracted from the multifitting procedure are: $B = 4.8 \\pm 0.6$, $\\ell_\\mathrm{D} = 21 \\pm 1~ \\mathrm{nm} $, and $\\ell_\\mathrm{B} = 530 \\pm 2~ \\mathrm{nm}$. Using the particle radius $a = 1.518 \\pm 0.006 ~ \\mathrm{\\mu m}$ calibrated from the preliminary fits of the interference patterns to the Lorenz-Mie scattering function (see section \\ref{sec:radius_charac}), and the $\\rho_\\mathrm{p} = 1050 ~ \\mathrm{kg.m^{-3}}$ tabulated bulk density of polystyrene, we would have expected $\\ell_\\mathrm{B}=559 ~ \\mathrm{nm}$ instead, which corresponds to less than $2\\,\\%$ error, and might be attributed to nanometric offsets, such as \\textit{e.g.} the particle and/or wall rugosity. \n\n\\subsubsection{Measuring external forces using the local drifts}\n\\label{sec:force}\nFinally, we investigate the total conservative force $F_z(z)$ acting on the particle along $z$. The first way to measure it is to calculate the gradient of the potential $U$ which is experimentally measured from the position \\gls{PDF} giving:\n\n\n\\begin{equation}\n\tF_z^\\mathrm{eq} = -\\nabla U = k_\\mathrm{B}T \\frac{\\mathrm{d}}{\\mathrm{d} z} \\ln (P_\\mathrm{eq}) ~,\n\t\\label{Eq.conservative_force}\n\\end{equation}\n\nwhere one can use the experimentally measured $P_\\mathrm{eq}$ (see Fig.~\\ref{fig.pdf_exp}). The results of this method are shown in Fig.~\\ref{fig.figure_force_total}. However, it can be interesting to measure the forces using the local drifts as for more complex systems, some non-conservative forces could arise. As the Eq.~(\\ref{Eq.conservative_force}) takes only into account to the potential $U$, only conservative forces can be extracted from the measurement of $P_\\mathrm{eq}$. Non-conservative forces could be measured by the difference between forces obtained through $P_\\mathrm{eq}$ and the local drifts.  \n\n\nLet us now explain the force measurement from drifts. By averaging the overdamped Langevin of Eq.~(\\ref{sde.multipl}) over a fine-enough $z$-binning grid and a short-enough time interval $\\Delta t$, one gets in the Itô convention (corresponding to our definition of $\\Delta z$):\n\\begin{equation}\n\tF_z (z) = 6 \\pi \\eta_z (z ) a \\frac{\\langle\\Delta z\\rangle}{\\Delta t} - k_\\mathrm{B}T \\frac{D_z'(z)}{D_z(z)} \\ ,\n\t\\label{stokes}\n\\end{equation}\nwhere the last term corresponds to the additional contribution due to the non-trivial integration of the multiplicative noise~\\cite{volpe_influence_2010,mannella_comment_2011,mannella_ito_2012, sancho_brownian_2011} (see section \\ref{sec:spurious}), with the prime denoting the derivative with respect to $z$. From the averaged measured vertical drifts $\\langle\\Delta z\\rangle$, and invoking Eqs.~(\\ref{Eq.hindered})~and~(\\ref{Eq:etaz_pade}), one can reconstruct $F_z(z)$ from Eq.~(\\ref{stokes}), as shown in Fig.~\\ref{fig.figure_force_total}. We stress that the statistical error on the force measurement is comparable to the thermal-noise limit~\\cite{liu_subfemtonewton_2016}: \n\\begin{equation}\n\t\\label{tnl}\n\t\\Delta F=\\sqrt{24\\pi k_{\\mathrm{B}}T \\eta_z(z) a/ \\tau_{\\textrm{box}}(z)}\\ ,\n\\end{equation}\nwhere $\\tau_{\\textrm{box}}(z)$ is the total time spent by the particle in the corresponding box of the $z$-binning grid. To corroborate these measurements, we invoke Eq.~(\\ref{Eq:PDF}) and express the total conservative force $F_z(z)=-U'(z)$ acting on the particle along $z$:\n\\begin{equation}\n\t\\displaystyle F_z(z) =  k_{\\mathrm{B}}T\\left(\\frac{B}{\\ell_\\mathrm{D}} \\textrm{e}^{-\\frac{z}{\\ell_\\mathrm{D}}} - \\frac{1}{\\ell_\\mathrm{B}}\\right)\\ .\n\t\\label{Eq:Force}\n\\end{equation} \nUsing the physical parameters extracted from the above multifitting procedure, we plot Eq.~(\\ref{Eq:Force}) in Fig.~\\ref{fig.figure_force_total}. The agreement with the data is excellent, thus showing the robustness of the force measurement. In particular, we can measure forces down to a distance of $40$~nm from the surface. Besides, far from the wall, we are able to resolve the actual buoyant weight $F_{\\textrm{g}} =- 7  \\pm 4 ~ \\mathrm{fN}$ of the particle. This demonstrates that we reach the femtoNewton resolution, and that this resolution is solely limited by thermal noise.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/trajctory_analysis/figure_force_total.pdf}\n\t\\caption{Total normal conservative force $F_z$ exerted on the particle as a function of the distance $z$ to the wall, reconstructed from Eq.~(\\ref{stokes}), using Eq.~(\\ref{Eq:etaz_pade}) for the circles and Eq.~(\\ref{Eq.conservative_force}) for the squares. The solid line corresponds to Eq.~(\\ref{Eq:Force}), with $B=4.8$, $\\ell_{\\mathrm{D}}=21\\,\\mathrm{nm}$ and $\\ell_{\\mathrm{B}}=530\\,\\mathrm{nm}$. The black dashed lines and gray area indicate the amplitude of the thermal noise computed from Eq.~(\\ref{tnl}). The horizontal red dashed line indicates the buoyant weight $F_{\\textrm{g}}=-7$~fN of the particle.~\\href{https://github.com/eXpensia/Confined-Brownian-Motion/blob/main/02_body/chapter3/images/trajctory_analysis/measure_force_experimental.ipynb}{\\faGithub}}\n\t\\label{fig.figure_force_total}\n\\end{figure}\n\n\\subsubsection{Testing on simulated data}\n\nAs detailed in section \\ref{sec:simconfined} we can simulate Brownian motion near a surface. To check if the constructed method works on simulated data where the physical parameters, $B$, $\\ell_\\mathrm{B}$ and $\\ell_\\mathrm{D}$ are known. We thus simulated a Brownian trajectory $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, $\\ell_\\mathrm{B} = 570~\\mathrm{nm}$ and a time-step $\\tau = 1/60$. The multi-fitting method of all the observable measures $B = 4.2 \\pm 0.5$, $\\ell_\\mathrm{D} = 21\\pm 1 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 570 \\pm 1~\\mathrm{nm}$ which is in good agreement with the parameters used for the simulation. A summary of the fitted observables is shown in Fig.~\\ref{fig.simconfined}. The Figs.~\\ref{fig.simconfined}-a-c) shows that the non-Gaussian properties of the displacement are correctly retrieved. Additionally, we correctly measure the local mobility as shown in Fig.~\\ref{fig.simconfined}-d) and the \\gls{MSD} in Fig.~\\ref{fig.simconfined}-e). Finally, we recover the forces using the local drifts as explained in section \\ref{sec:force}. As the simulated trajectory is 10 times longer than the experimental one, we can observe in Fig.~\\ref{fig.simconfined}-f) that the thermal noise is smaller than for the experiment (see Fig.~\\ref{fig.figure_force_total}). Indeed using Eq.~\\ref{tnl} having a trajectory 10 times longer reduces the thermal noise by a factor $\\approx 3$, as expected. This demonstrates that the method developed in this section can correctly retrieve the statistical properties of confined Brownian motion near a wall, and measure surface force at the thermal resolution.\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics{02_body/chapter3/images/simulation_confined_Brownian_motion/method_sim.pdf}\n\t\\caption{Summary of our inference method on simulated data with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 570~\\mathrm{nm}$. The multi-fitting method of all the observable measures $B = 4.2 \\pm 0.5$, $\\ell_\\mathrm{D} = 21\\pm 1 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 570 \\pm 1~\\mathrm{nm}$  a,b) Normalized probability density functions $P_i\\,\\sigma$ of the normalized displacements $\\Delta x/\\sigma$ and $\\Delta z/\\sigma$, at short times, with $\\sigma^2$ the corresponding MSD (see Fig.~\\ref{fig.MSD}), for different time increments $\\Delta t$ ranging from 0.0167~s to 0.083~s, as indicated with different colors. The solid lines are the best fits to Eq.~(\\ref{Eq:PDzshort}), using Eqs.~(\\ref{Eq:PDF}),~(\\ref{Eq:etaz}),~and~(\\ref{Eq:etax}). For comparison, the gray dashed lines are normalized Gaussian distributions, with zero means and unit variances. c) Probability density function $P_z$ of the displacement $\\Delta z$, at long times, averaged over several values of $\\Delta t$ ranging between 25 s and 30~s. The solid line is the best fit to Eq.~(\\ref{auxiliary}), using Eq.~(\\ref{Eq:PDF}).d) Measured local short-term diffusion coefficients $D_i$ of the microparticle, normalized by the bulk value $D_0$, as functions of the distance $z$ to the wall, along both a transverse direction $x$ or $y$ ($D_i=D_\\parallel=D_x=D_y$, blue) and the normal direction $z$ ($D_i=D_z$, green) to the wall. The solid lines are the theoretical predictions, $D_{\\parallel}(z)=D_0\\eta/\\eta_{\\parallel}(z)$ and $D_z(z)=D_0\\eta/\\eta_z(z)$, using the local effective viscosities $\\eta_{\\bot}(z)$ and $\\eta_\\parallel(z)$ of Eqs.~(\\ref{Eq:etaz})~and~(\\ref{Eq:etaz}), respectively.e)Measured mean-squared displacements (MSD, see Eq.~(\\ref{MSDdef})) as functions of the time increment $\\Delta t$, for the three spatial directions, $x$, $y$, and $z$. The solid lines are best fits to Eq.~(\\ref{averagediff}), using Eqs.~(\\ref{Eq:PDF}),~(\\ref{Eq:etaz})~and~(\\ref{Eq:etax})\n\t\tproviding the average diffusion coefficients $\\langle{D_\\parallel}\\rangle= \\langle D_x\\rangle=\\langle D_y \\rangle =0.52\\,D_0$ and $\\langle D_z \\rangle =0.24\\, D_0$. The dashed line is the best fit to Eq.~(\\ref{Eq:plateau}), using Eq.~(\\ref{Eq:PDF}), with $B = 4.8$, $\\ell_\\mathrm{D} = 21 ~ \\mathrm{nm}$, and $\\ell_\\mathrm{B} = 530~\\mathrm{nm}$.f) Total normal conservative force $F_z$ exerted on the particle as a function of the distance $z$ to the wall, reconstructed from Eq.~(\\ref{stokes}), using Eq.~(\\ref{Eq:etaz_pade}) for the circles and Eq.~(\\ref{Eq.conservative_force}) for the squares. The solid line corresponds to Eq.~(\\ref{Eq:Force}), with $B=4.8$, $\\ell_{\\mathrm{D}}=21\\,\\mathrm{nm}$ and $\\ell_{\\mathrm{B}}=530\\,\\mathrm{nm}$. The black dashed lines and gray area indicate the amplitude of the thermal noise computed from Eq.~(\\ref{tnl}). The horizontal red dashed line indicates the buoyant weight $F_{\\textrm{g}}=-7$~fN of the particle.}\n\t\\label{fig.simconfined}\n\\end{figure}\n\n\n\\subsection{Conclusion}\n\nIn this section we have covered the physics we need to take into account when considering confined Brownian motion. We first detailed the gravitational and DLVO interactions to detail the Gibbs-Boltzmann distribution. Then, we detail the space-varying damping due to the hydrodynamic interactions between the wall and the particle. The damping which is now space-varying in the Langevin induces a non-trivial integration of the Langevin force, which induces the appearance of a spurious drift term in the Fokker-Planck equation. We then present a method that permits to estimate how the simulation time-step should be selected, then we show that the spurious drift term is needed to be taken into account to recover the correct equilibrium distribution.\n\nIn a second part, we present a multi-scale statistical analysis for the problem of freely diffusing individual colloids near a rigid wall. Combining the equilibrium distribution in position, time-dependent non-Gaussian statistics for the spatial displacements, a novel method to infer local diffusion coefficients, and a multifitting procedure, allowed us to reduce drastically the measurement uncertainties and reach the nanoscale and thermal-noise-limited femtoNewton spatial and force resolutions, respectively. \n", "meta": {"hexsha": "aab37740301ed7f5ccd7f7f3b682f88f95bb6deb", "size": 104917, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "02_body/chapter3/chapter3.tex", "max_stars_repo_name": "eXpensia/Confined-Brownian-Motion", "max_stars_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "02_body/chapter3/chapter3.tex", "max_issues_repo_name": "eXpensia/Confined-Brownian-Motion", "max_issues_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "02_body/chapter3/chapter3.tex", "max_forks_repo_name": "eXpensia/Confined-Brownian-Motion", "max_forks_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.4092198582, "max_line_length": 1980, "alphanum_fraction": 0.7264599636, "num_tokens": 32695, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.6513548782017746, "lm_q1q2_score": 0.41728129813900167}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{bm}\n\\usepackage{enumitem}\n\\usepackage{float}\n\\usepackage{fullpage}\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\\usepackage{tabularx}\n\n\\title{On Demand Transportation Scheduling \\\\ \\large{Progress Report}}\n\\author{Weini Yu\\\\\\texttt{weiniyu}\\and Zhouchangwan Yu\\\\\\texttt{zyu21}\\and Yutian Li\\\\\\texttt{yutian}}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\nOur project aims to develop an intelligent model that provides a solution to the single vehicle pickup and delivery problem (SVPDP). For now we are only going to look at the pickup and delivery problem of a single vehicle and without considering carpool situation.\n\n\\section{Model}\nWe have approached this problem using an MDP model, with the intuition that at a certain location (state), the driver could choose to take one of the requests that come in (action). For each action the driver receives a reward. At the end of the day, the driver has a total reward for all the rides he or she takes. And through solving this MDP, the driver can figure out which request to take at a location in order to maximize the total reward.\n\n\\subsection{State}\nWe originally had states that include the driver's current location and a list of requests at the location. However, this makes the state space very large ($10^{5}$) which is not desired. Also the relative order of requests does not really matter. So we have simplified it such that it only contains the driver's current location, a zone index number, reducing the state space to $10$. For example, \\texttt{state=1} means that the driver is at location $1$. Note that we are not losing anything by not including requests. Requests are encoded into actions.\n\n\\subsection{Action}\nSince state is the current location the driver is at, the action would be the possible request the driver receives, which is a tuple \\texttt{(source, destination)} where source is the pick up zone index and destination is the drop off zone index. In our specific model, the driver is given $5$ requests to choose from at the start of the game and the end of each ride. So at any step, there are $5$ legal actions. And the driver must choose one from them.\n\nThe requests are generated in the following way. The source location is randomly sampled with lower location indices having a higher weight. The destination location is sampled uniformly randomly. By generating requests in a nonuniform way, we favor locations that have smaller indices and create an imbalance between states. We hope that the agent will figure out some locations are inherently better, and use this knowledge to achieve higher rewards.\n\n\\subsection{Reward}\nThe reward of each action or ride will be $(\\text{fare}-\\alpha\\cdot\\text{travel time})$. The intuition here is that gas cost needs to be subtracted and the longer the travel time is the less happy the customer is so there is the negative impact on the reward. The constant $\\alpha$ balances fare and travel time, and could be seen as a measure of productivity. In our specific model, $\\alpha$ is chosen to be $\\frac{1}{150}$.\n\n\\section{Algorithm}\n\\subsection{Baseline and Oracle}\nBased on this model, we implemented baseline as a driver that randomly picks one request at each step. And the oracle is a driver that knows the true reward function for all the requests, and picks greedily according to it.\n\n\\subsection{Q-learning}\nFor our agent, we used Q-learning as a first step to solve this problem. For a smaller sized problem we could run exhaustive search, but it is clearly not scalable. We chose Q-learning instead of TD learning, because intuitively states do not matter that much in our model. Though some states are inherently better due to the request generation probability, actions are much more important. Besides, if a driver takes a request and returns to the same location, the state is same but clearly the total reward is not.\n\nFor function approximation, we used linear regression to predict the Q value. As a first step, we manually picked a few features.\n\n\\subsubsection{Features}\n\\noindent\\textbf{Distance}:\nThe travel distance is one of the main concern for the drivers. Here we define two features related to the travel distance, the distance from current location to source, and the distance from source to destination.\n\n\\noindent\\textbf{Zone}: Some zones are more attractive to people than others, so the drives may have preference on where they would like to go. Each zone as current location, source, or destination are all considered as features.\n\nWe define indicator features $\\bm{1}\\{\\text{current zone}=z\\}$, $\\bm{1}\\{\\text{source zone}=z\\}$, and $\\bm{1}\\{\\text{destination zone}=z\\}$ for all $z$'s.\n\n\\subsubsection{Training}\n\nUsing features described above, we learned the respective weights using gradient descent. We updated weights using exponential weighted moving average as $w_{i}\\leftarrow w_{i}-\\eta(Q(s,a)-r)\\phi_{i}(s,a)$, where $\\eta=0.1$. Note that we set discount $\\gamma=0$. This is because there is no way for the driver to know the legal actions (requests) available at future states. They are randomly generated only when the driver gets to a new state. $\\max_{a}Q(s,a)$ is hard to define, hence $\\gamma=0$ for simplicity.\n\n\\section{Data Preprocessing}\n\nAt the end of data preprocessing stage, we generate a \\texttt{city.p} pickle file that has everything we need about the environment. It has a list of locations, travel times between locations, fare estimates, and coordinates of the locations.\n\n\\noindent\\textbf{Locations (a.k.a. zone indices)}: We downloaded from Uber Movement travel times in Washington D.C. during second quarter of year 2017. There are 558 zones in total, and we picked the first 10 zones for downsampling.\n\n\\noindent\\textbf{Travel times}: We picked the arithmetic mean travel time as the travel time between zones. The distribution of travel times is shown below.\n\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{images/time.png}\n\\end{center}\n\\caption{Distribution of traveling time.}\n\\end{figure}\n\n\\noindent\\textbf{Coordinates}: We calculated the arithmetic mean longitude and latitude as coordinates of the locations.\n\n\\noindent\\textbf{Fare}: The fares between these 10 locations are requested form Uber Developers API. Given the longitudes and latitudes of any two locations, the low estimate and high estimate of the fare are generated for various types of vehicles. We use the average of the fare for UberX and keep the data in a $10\\times 10$ matrix. The distribution of fare estimates are shown below.\n\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{images/fare.png}\n\\end{center}\n\\caption{Distribution of estimated fare.}\n\\end{figure}\n\n\\section{Example}\n\nFor a concrete example, we assume the driver is at location $s$. Five requests $(s_{i},d_{i})$ for $1\\leq i\\leq 5$ are dispatched to the driver. The driver evaluates $Q(s,(s_{i},d_{i}))$ for all five requests using linear estimator $\\sum_{i}w_{i}\\phi_{i}(s,a)$ and picks the one with the highest estimation. The driver takes this action. Then the reward $r$ is given to the driver, who in turn uses $w_{i}\\leftarrow w_{i}-\\eta(Q(s,a)-r)\\phi_{i}(s,a)$ to perform gradient descent to update the weights $w$.\n\n\\section{Results}\n\nWe trained our algorithm and compared to baseline and oracle. The resulting reward curve is shown below.\n\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width=0.6\\textwidth]{images/reward.png}\n\\end{center}\n\\caption{Reward curve.}\n\\end{figure}\n\nAt first our algorithm is acting randomly because all the weights are just initialized. Then quickly it ramps up and learns the Q function. At iteration 100, it is already receiving twice the reward of baseline, but still about $30\\%$ worse than the oracle.\n\n\\section{Next Steps}\nWe will first implement our Q-learning algorithm on a larger sample size (100 zone locations) to see how it performs as the problem is getting more complicated. We will also considering more advanced learning algorithm. We could try to use a neural network instead of hand craft linear features.\n\n\\end{document}", "meta": {"hexsha": "689065f1770c3f9dac39beb136ec6d7802de6c2b", "size": 8146, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "progress.tex", "max_stars_repo_name": "hotpxl/uber-agent", "max_stars_repo_head_hexsha": "70729f9b09a17336af3a8bc6f51e0b27b10e3fc3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "progress.tex", "max_issues_repo_name": "hotpxl/uber-agent", "max_issues_repo_head_hexsha": "70729f9b09a17336af3a8bc6f51e0b27b10e3fc3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "progress.tex", "max_forks_repo_name": "hotpxl/uber-agent", "max_forks_repo_head_hexsha": "70729f9b09a17336af3a8bc6f51e0b27b10e3fc3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.862745098, "max_line_length": 556, "alphanum_fraction": 0.7809968082, "num_tokens": 1901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.41728128946753373}}
{"text": "\\subsection{The Classical Definition of Entropy}\nJumping right into things, entropy, for large systems, can be defined as\n\\begin{equation}\n    dS=\\frac{\\delta Q_{rev}}{T}\n\\end{equation}\nWhere $dS$ is the change in entropy, $\\delta Q_{rev}$ is heat reversibly flowing to/from a system, and $T$ is the temperature of the system. Just stating it right here, this equation probably seems to make \\textbf{no} sense whatsoever, so let's step back a bit to build up to it.\n\\input{Entropy/reversableprocesses}\n\\input{Entropy/secondlaw}\n\\input{Entropy/thirdlaw}\n\\input{Entropy/carnotrevisited}", "meta": {"hexsha": "ae63c27364fe490a59671c9a9a62e67ed7bec33c", "size": 584, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Entropy/classicaldefinition.tex", "max_stars_repo_name": "RioWeil/SCIE001-thermo-notes", "max_stars_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Entropy/classicaldefinition.tex", "max_issues_repo_name": "RioWeil/SCIE001-thermo-notes", "max_issues_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Entropy/classicaldefinition.tex", "max_forks_repo_name": "RioWeil/SCIE001-thermo-notes", "max_forks_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-30T05:36:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-30T05:36:50.000Z", "avg_line_length": 58.4, "max_line_length": 279, "alphanum_fraction": 0.7705479452, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.41724518995574783}}
{"text": "\n\\section{Particle Filter}\n\\label{sec:particleFilter}\n\nThis course introduced two main techniques for localization of the robots current position, these were Kalman Filter and Particle Filter, as described in chapter \\ref{chp:kalman} and chapter \\ref{chp:partFilter} respectively.\nFor the localization in this project, particle filters were chosen, since it doesn't require landmarks and landmark recognition.\n\nThe implementation of the particle filter was separated into two C\\# classes, namely a \\emph{Particle} class and a \\emph{ParticleFilter} class, as shown in figure \\ref{fig:partUML}.\n\nThe Particle class serves as a definition of the properties of each individual particle, i.e. the X and Y coordinates, its orientation represented in radians by the variable \\emph{theta} and the particle's weight.\nThe constructor of a Particle object takes the world size as arguments, and generates random X- and Y-coordinates within the given world, along with a random orientation.\n\nThe functions \\emph{PostionNoise} and \\emph{ThetaNoise} are functions for adding a Gaussian noise to the particle, in order to simulate motion uncertainties of the robot.\n\n\\myFigure{ParticleFilter/partUML}{UML class diagram of the particle filter}{fig:partUML}{0.4}\n\n\\noindent The ParticleFilter class it self, implements the actual functionality of the particle filter.\nThe constructor calls the function \\emph{GenerateParticleSet()}, which generate a particle set of $N$ particles. While doing so, the function utilized the Map function \\emph{IsPointInSquare()} to avoid placing particles inside a world object.\\\\\\\\\n%\n\\emph{MoveParticles()} takes a distance argument, which corresponds to how much the robot was told to move forward and moves the particles forward the same amount.\nThis is done by calculating exactly how much in the X- and Y-direction the specific particle should move, according to its orientation.\nWhen the particle have been moved, the noise functions of the Particle class is called, to simulate the uncertainties.\nFinally the move function checks if a particle have been moved into a world object, if so, the particle is discarded and replaced by a new particle, with a completely random position and orientation.\nThis feature was chosen to apply some form of particle redistribution.\\\\\\\\\n%\nThe function \\emph{Resample()} implements the resampling process described in chapter \\ref{chp:partFilter}.\nThis is done by setting each particles weight to the probability of particle being correct, given the particle's position and orientation compared to the measured distance at the given resampling time.\nThese weights are then normalized before the actual resampling algorithm is applied.\\\\\\\\\n%\nIn order to give the best approximation of the actual robot position the ParticleFilter provides the function \\emph{getPosition()} which returns a Particle object, because the Particle object hold information about both X,Y-coordinates and orientation.\nThe approximation of the robot position is implemented as the average position and orientation of all the particles in the set, not taking into account the particle's weight or any potential clusters.\nThis was chosen for a fast and easy implementation.\n\n  \n\n\n\\newpage", "meta": {"hexsha": "33ab8a184cad04f6632e4bbd8bfa42ec30c90ffb", "size": 3217, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/chapter/implementation/particleFilter.tex", "max_stars_repo_name": "Rotvig/AI-Robotics-Project", "max_stars_repo_head_hexsha": "af8d96a429df4c55d9716c4ff0453188d9c8c799", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/chapter/implementation/particleFilter.tex", "max_issues_repo_name": "Rotvig/AI-Robotics-Project", "max_issues_repo_head_hexsha": "af8d96a429df4c55d9716c4ff0453188d9c8c799", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/chapter/implementation/particleFilter.tex", "max_forks_repo_name": "Rotvig/AI-Robotics-Project", "max_forks_repo_head_hexsha": "af8d96a429df4c55d9716c4ff0453188d9c8c799", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.9459459459, "max_line_length": 252, "alphanum_fraction": 0.8072738576, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.41724518995574783}}
{"text": "\\vsssub\n\\subsubsection{~$S_{uo}$: Unresolved Obstacles Source Term} \\label{sec:UOST}\n\\vsssub\n\n\\opthead{UOST}{\\ws}{L. Mentaschi}\n\nUnresolved bathymetric and coastal features, such as cliffs, shoals and small islands, \nare a major source of local error in spectral wave models. \nTheir dissipating effects can be accumulated over long distances, and \nneglecting them can compromise the simulation skill on large portions of the domain \n\\citep{tol:Waves01a,tol:WaF02,art:Tuomi2014,art:Mentaschi2015a}. \nIn \\ws\\ \ntwo approaches are available for subscale modelling \nthe dissipation due to unresolved obstacles: \na) a propagation-based approach established for regular grids, described in section \n\\ref{sub:num_obst} \\citep{tol:OMOD03a, tol:OMOD08a}; and b) the \nUnresolved Obstacles Source Term \\citep[UOST,][]{art:Mentaschi2018a,art:Mentaschi2015b}\ndescribed here.\nIn addition to supporting virtually any type of mesh, \nUOST takes into account the directional/spatial layout \nof the unresolved features, which can improve the model skill\nwith respect to the established approach \\citep{art:HMM00,art:Mentaschi2018b}.\n\nUOST relies on the hypothesis that any mesh can be considered as a set of polygons, \ncalled cells, and that the model estimates the average value of the unknowns \nin each cell. \nGiven a cell (let us call it A, figure \\ref{fig:UOST}ab) UOST estimates, for each spectral component, \nthe effect of a) the unresolved features located in A (Local Dissipation, LD); \nb) the unresolved features located upstream of A, and projecting their shadow on A \n(Shadow Effect, SE). For the estimation of SE, \nan upstream polygon A\\textsc{\\char13} is defined for each \ncell/spectral component, as the intersection between the joint cells neighboring A \n(cells B, C and D in figure \\ref{fig:UOST}ab), and the flux upstream of A. \nFor each cell or upstream polygon, and for each spectral component, \ntwo different transparency coefficients are estimated. \n1) The overall transparency coefficient $\\alpha$; and \n2) a layout-dependent transparency $\\beta$, defined as the average transparency \nof cell sections starting from the cell upstream side. \n\nThe source term can be expressed as:\n\n\\begin{equation}\nS_{uo} = S_{ld} + S_{se}\\ ,\n\\end{equation}\n\n\\begin{equation}\nS_{ld} = - \\psi_{ld}(\\mathbf{k}) \\frac{1 - \\beta_l(\\mathbf{k})}{\\beta_l(\\mathbf{k})} \\frac{c_g(\\mathbf{k})}{\\Delta L} N \\ ,\n\\end{equation}\n\n\\begin{equation}\nS_{se} = - \\psi_{se}(\\mathbf{k}) \\bigg[ \\frac{\\beta_u(\\mathbf{k})}{\\alpha_u(\\mathbf{k})} - 1 \\bigg] \\frac{c_g(\\mathbf{k})}{\\Delta L} N \\ ,\n\\end{equation}\n\nwhere $S_{ld}$ and $S_{se}$ are the local dissipation and the shadow effect,\n$N$ is the spectral density, \n$\\mathbf{k}$ is the wave vector, \n$c_g$ is the group velocity, $\\Delta L$ is the path length of the spectral component \nin the cell, and the $\\psi$ factors model the reduction of the dissipation in presence of\nlocal wave growth. \nThe subscripts l and u of $\\alpha$ and $\\beta$ indicate that these coefficients \ncan be referred, respectively, to the cell and to the upstream polygon.\nFor a more detailed explanation on the theoretical framework of UOST, \nthe reader is referred to\n\\citep{art:Mentaschi2015b, art:Mentaschi2018a}.\n\n\n\\begin{figure} \\begin{center}\n\\epsfig{file=./eqs/UOST.eps,angle=0,width=4in}\n\\caption{\na: a square cell (A) and its upstream polygon \n(A\\textsc{\\char13}, delimited by blue line, in light blue color) for a spectral \ncomponent propagating with group velocity $c_g$. \nThe joint BCD polygon represents the neighborhood polygon. \nb: same as a, but for a triangular mesh (the hexagons approximate the median dual cells). \nc: Computation of $\\alpha$ and $\\beta$ for a square cell, $N_s=4$, \nand a spectral component propagating along the x axis. \nd: Like c, but for a hexagonal cell and for a tilted spectral component. \nIn panel d the gray squares represent unresolved obstacles. \n}\n\\label{fig:UOST} \\botline\n\\end{center}\n\\end{figure}\n\n\n\\textbf{Automatic generation of mesh parameters.} \nAn open-source python package (alphaBetaLab, https://github.com/menta78/alphaBetaLab) \nwas developed\nfor the automatic estimation, from real-world bathymetry, of the upstream polygons, \nof the transparency coefficients\n$\\alpha_l$, $\\beta_l$, $\\alpha_u$, $\\beta_u$,\nand of the other parameters needed by UOST.\nalphaBetaLab considers the cells as free polygons, and estimates the transparency coefficients\nfrom the cross section of the unresolved obstacles versus the incident spectral component \n(figure \\ref{fig:UOST}cd).\nThis involves, that it can be applied to any type of mesh, \nincluding unstructured triangular and SMC meshes \n(as of August 2018 only regular and triangular meshes are handled, \nbut support for SMC meshes \nwill be soon added). \nWe need to mention that while UOST would be able to modulate the energy dissipation \nwith the spectral frequency, only the direction is currently considered in alphaBetaLab.\nFor more details on the algorithms implemented in alphaBetaLab, \nthe user is referred to \\cite{art:Mentaschi2018a}. \n\\cite{art:Mentaschi2018c} provides the documentation of the software and of its architecture,\nalong with use guidance and illustrative examples. \n\n\\textbf{Time step settings.} \nIn \\ws\\ the source terms are applied at the end of each global time step.\nTherefore, to work properly on a given cell, \nUOST needs a global time step lower\nor equal to the critical CFL time step of the cell, \ni.e., the amount of time needed by the fastest spectral component to entirely cross the cell.\nOtherwise, part of the energy will leak through the cell without being blocked \\citep{art:Mentaschi2018a}.\n\nIn unstructured grids with cells of very different sizes, the application of UOST to \nall the cells, including the smallest ones, may come with an excedingly small global time step\nthat would affect the economy of the model. \nTo avoid this problem the user can set alphaBetaLab in order to\nneglect cells smaller than a user-defined threshold, and then set in \\ws\\\na global time step equal to the critical CFL time step related with that threshold \n\\citep{art:Mentaschi2018c}.\n\n\n\\begin{table} \\begin{center}\n \\footnotesize\n\\begin{tabular}{|p{4cm}|p{2.5cm}|p{5.5cm}|} \\hline \\hline\nNamelist parameter    &  Description           & default value \\\\\n\\hline\n  UOSTFILELOCAL &  Local $\\alpha$/$\\beta$ input file path   &  obstructions\\_local.\\textit{gridname}.in    \\\\ \\hline\n  UOSTFILESHADOW &  Shadow $\\alpha$/$\\beta$ input file path   & obstructions\\_shadow.\\textit{gridname}.in   \\\\ \\hline\n  UOSTFACTORLOCAL &  Calibration factor for local transparencies  &  1   \\\\ \\hline\n  UOSTFACTORSHADOW &  Calibration factor for shadow transparencies  &  1  \\\\\n\\hline\n\\end{tabular} \\end{center}\n\\caption{UOST parameters, their description and default values. } \\label{tab:UOST}\n\\botline\n\\end{table}\n\n", "meta": {"hexsha": "a7acf513b857028b7fc73836247d4971dd7e174e", "size": 6807, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "WW3/manual/eqs/UOST.tex", "max_stars_repo_name": "minsukji/ci-debug", "max_stars_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "WW3/manual/eqs/UOST.tex", "max_issues_repo_name": "minsukji/ci-debug", "max_issues_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-05-31T15:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:17:45.000Z", "max_forks_repo_path": "WW3/manual/eqs/UOST.tex", "max_forks_repo_name": "minsukji/ci-debug", "max_forks_repo_head_hexsha": "3e8bbbe6652b702b61d2896612f6aa8e4aa6c803", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-01T09:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T09:29:46.000Z", "avg_line_length": 48.9712230216, "max_line_length": 138, "alphanum_fraction": 0.7640664022, "num_tokens": 1837, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.41724518995574783}}
{"text": "\\section{Results}\n\n\\subsection{Stability of Hopfield Network}\n\\begin{figure}[H]\n    \\centering\n    \\captionsetup[subfigure]{width=0.9\\textwidth, justification=raggedright}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/stable}\n        \\caption{By initializing the network to the stored pattern, the network will remain in an equilibrium. The network will never deviate from this state without external interference. If the network is initialized to a noisy state, the network will converge towards the stored pattern.}\n    \\end{subfigure}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/stable-energy}\n        \\caption{With a single stored pattern, the energy will converge towards the lower limit according to \\cref{eq:energy-limits}. In this case with 50 neurons, the lower limit is $-\\frac{50*\\times 49}{2} = -1225$}.\n    \\end{subfigure}\n    \\caption{Initializing a Hopfield network with a single stored pattern ($N = 50$) will cause the network to converge towards the stored pattern.}\n    \\label{fig:stable}\n\\end{figure}\nTo test whether the Hopfield network is stable after reaching an equilibrium we simulated the Hopfield network storing a random pattern using $N=50$ neurons. We initialized the network to the stored pattern, once with and once without added noise, as shown in \\cref{fig:stable}. The network remained stable at the equilibrium point, and converged towards the equilibrium if not perfectly intialized. With a single pattern stored, the energy converged toward the lower limit expressed in \\cref{eq:energy-limits}.\n\n\\subsection{Storing multiple patterns}\n\\begin{figure}[H]\n    \\centering\n    \\captionsetup[subfigure]{width=0.9\\textwidth, justification=raggedright}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/multiple-patterns.eps}\n        \\caption{By initializing the weight matrix $\\bf W$ with multiple patterns, the network is able to restore multiple different patterns. The amount of memories and noise the network is able to handle depends on the size and similarity of the stored patterns. If two stored patterns only differ by a few bits, the network may recall the wrong memory if noise is involved. }\n        \\label{fig:multiple-similarity}\n    \\end{subfigure}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/multiple-patterns-energy.eps}\n        \\caption{The network will always move in the direction of least resistance such that the overall energy decreases, similar to how a ball will always roll downwards into a valley unless there are external forces interfering. Each stored memory corresponds to a local minimum which can be thought of as a valley. As long as the network is initialized to the correct valley, it is able to reconstruct the stored pattern from memory.}\n        \\label{fig:multiple-energy}\n    \\end{subfigure}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/capacity.eps}\n        \\caption{When storing a large amount of random patterns in the network, the robustness decreases and the network will not be able to reliably restore the correct memories. The figure shows the proportion of correct memories, recalled for different number of stored memories and different noise levels.}\n        \\label{fig:multiple-capacity}\n    \\end{subfigure}\n    \\caption{Simulating the Hopfield network with multiple stored patterns.}\n    \\label{fig:multiple}\n\\end{figure}\nTo test whether the network remains stable even with multiple patterns stored in the weights, we simulated a new network storing two uncorrelated random patterns ($N=50$). We simulated using both patterns as initial conditions as well as simulating with and without noise. In total we ran 4 simulations and the results are shown in \\cref{fig:multiple}. The states converged towards the correct pattern in all cases, and remains stable at the equilibrium. The energy in the equilibrium, as shown in \\cref{fig:multiple-energy}, was half the lower limit in \\cref{eq:energy}.\n\nTo test how many pattern we can reliably store, we simulated the Hopfield with different number of memories and noise levels. In \\cref{fig:multiple-capacity} we see how the networks ability to recall the correct memory decreaes as both the number of memories and noise level increases. With low noise levels we found that we can store $6$ memories reliably using $N=50$ neurons. For higher noise levels the robustness quickly decreases.\n \n\n\\subsection{Reconstructing partial QR codes from memory} \\label{sec:qr-codes}\nTo better visualize the Hopfield networks ability to store and restore patterns, we constructed a Hopfield network for storing QR-codes. We stored two QR-codes in the network and initialized the network with only partial information. Fig. \\ref{fig:qr-codes} shows how the network was able to restore the correct QR code from memory, while \\cref{fig:qr-codes-stability} shows how the network remained stable after reaching the equilibrium. \n\\begin{figure}[H]\n    \\centering\n    \\captionsetup[subfigure]{width=0.9\\textwidth, justification=raggedright}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/qr-code}\n        \\caption{The QR-code contains information encoded within the patterns. A QR decoding app, either online or on a smartphone, can be used to decode the \"hidden\" message. Using the Hopfield network we are able to reconstruct a destroyed QR-code from memory.}\n        \\label{fig:qr-codes}\n    \\end{subfigure}\n    \\begin{subfigure}{0.49\\textwidth}\n        \\includegraphics[width=\\textwidth]{figs/qr-code-sim}\n        \\caption{The similarity between the current state of the network and the original QR-code we want it to reconstruct.}\n        \\label{fig:qr-codes-stability}\n    \\end{subfigure}\n    \\caption{By applying the Hopfield network to a very noisy QR-code we are able to reconstruct the original. By using any QR-code reader we are able to decode the original and reconstructed QR-codes, while the middle ones contain too much noise. The same Hopfield network was used to reconstruct both patterns.}\n\\end{figure}\n\n\\subsection{Inverting patterns}\nAccording to the weights, \\cref{eq:weights}, the Hopfield network only stores patterns and not the actual values in the memories. A pattern $\\bf V$ and its inverse $\\mathbf{\\bar{V}} = -1 \\times \\bf V$ would yield the exact same weight matrix. For each stored memory there should be two equilibrium states, one for $\\bf V$ and one for $\\bf \\bar{V}$. To test whether this truly is the case, we used the same Hopfield network as in \\cref{sec:qr-codes} and initialized the states to the second QR code, but inverting all bits. We ran another simulation using the QR-code with two-thirds of its bits inverted. As can be seen from the results in \\cref{fig:inverted-qr} both cases caused the Hopfield network to reconstruct the inverted pattern, and not the ones we originally created. This shows how for each stored pattern there exists two equilibrium points.\n\\begin{figure}[H]\n    \\centering\n        \\includegraphics[width=0.5\\textwidth]{figs/qr-inverted}\n        \\caption{The Hopfield network learns the patterns and the network is not able to distinguish between positive and negative values. The network is not only stable at the initial memories, but also when using the inverted patterns.}\n        \\label{fig:inverted-qr}\n\\end{figure}", "meta": {"hexsha": "b7080cf4e2376dd3f631cc4cdcaa2864d1573d53", "size": 7436, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/project2/results.tex", "max_stars_repo_name": "HaavardM/nevr3004-neural-networks", "max_stars_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/project2/results.tex", "max_issues_repo_name": "HaavardM/nevr3004-neural-networks", "max_issues_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/project2/results.tex", "max_forks_repo_name": "HaavardM/nevr3004-neural-networks", "max_forks_repo_head_hexsha": "7acfe8f6a4fedabd1d2dbfebf2f21e045010f90e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 103.2777777778, "max_line_length": 854, "alphanum_fraction": 0.7682894029, "num_tokens": 1738, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.41724518668734245}}
{"text": "\\documentclass{article}\n\\usepackage{enumerate}\n\\usepackage{amsmath, amsthm, amssymb}\n\\usepackage[margin=1in]{geometry}\n\\usepackage[parfill]{parskip}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\title{Econ C103 Problem Set 5}\n\\author{Sahil Chinoy}\n\\date{February 28, 2017}\n\n\\begin{document}\n\\maketitle{}\n\n\\subsection*{Exercise 1}\n\n\\begin{enumerate}[(a)]\n\t\\item\n\n\tEach agent $i \\in \\{1,2\\}$ has type indicated by the value of the object that they have at the beginning of the game, $\\theta_i \\in \\Theta = [0,1]$, and can send a message from $M_i = \\{0,1\\}$ indicating whether they want to exchange objects. If both agents choose $m_i = 1$, then the trade takes place, which we denote with $x = 1$. So the allocation rule is\n\n\t\\begin{equation*}\n\tx(m) = \n\t\t\\begin{cases} \n\t      0 & \\text{if } m_1 = 0 \\text{ or } m_2 = 0 \\\\\n\t      1 & \\text{if } m_1 = m_2 = 1\n\t   \\end{cases}\n\t\\end{equation*}\n\n\tand each agent's utility is\n\n\t\\begin{equation*}\n\tu_i(x, \\theta_i) = \n\t\t\\begin{cases} \n\t      \\theta_i & \\text{if } x = 0 \\\\\n\t      \\theta_{-i} & \\text{if } x  = 1\n\t   \\end{cases}.\n\t\\end{equation*}\n\n\t\\item\n\n\tTrading will never be Pareto efficient, so the only Pareto efficient outcome is the original allocation, $x = 0$. If $\\theta_1 \\neq \\theta_2$, trading would make one agent worse off, since both agents assign the same value to the objects. If $\\theta_1 = \\theta_2$, then trading won't change either agent's utility and thus won't make either agent strictly better off.\n\n\tEither allocation ($x = 0 \\text{ or } 1$) maximizes the sum of the agents' utilities, which is always $\\theta_1 + \\theta_2$.\n\n\t\\item\n\n\tThe best response of each agent depends on the message the other agent sends and the other agent's type. If $m_{-i} = 0$, then trade will never take place, so it doesn't matter what message the agent chooses; we will pick $m_i = 0$. Then the best response for agent $i$ is\n\n\t\\begin{equation*}\n\t\\sigma_i(m_{-i}, \\theta) = \n\t\t\\begin{cases} \n\t      0 & \\text{if } m_{-i} = 0 \\text{, or } m_{-i} = 1 \\text{ and } \\theta_i \\geq \\theta_{-i} \\\\\n\t      1 & \\text{if } m_{-i} = 1 \\text{ and } \\theta_i < \\theta_{-i} \n\t   \\end{cases}.\n\t\\end{equation*}\n\n\tThus the agent's best response depends on $m_{-i}$ and $\\theta_{-i}$. This means that there is no dominant strategy equilibrium.\n\n\t\\item\n\n\tGiven that the types $\\theta$ are uniformly distributed on $[0,1]$, each agent initially expects the other agent's type to be $\\mathbb{E}[\\theta_{-i}] = 0.5$. This means it is rational to trade, i.e. send the message $m_i = 1$, only if $\\theta_i  < 0.5$. But then the expected payoff from the trade for the \\textit{other} agent is $\\mathbb{E}[\\theta_{-i} | m_{-i} = 1] = 0.25$, and if the first agent expects the other agent to play optimally, their expected payoff is now $\\mathbb{E}[\\theta_{-i} | m_{-i} = 1] = 0.125$, and so on. So trading will never be optimal.\n\n\tSending the message $m_i = 0$ is a Bayes-Nash equilibrium, however, because given that every agent expects the other agents to play $\\sigma_i(\\theta_i) = 0$, a trade can never occur, so it is never in anyone's interest to send the message $m_i = 1$ as it will not change the outcome. Formally, $\\forall m_i \\;\\mathbb{E}[ u_i(x(\\sigma_i, \\sigma_{-i}), \\theta_i) | \\theta_i]  = \\theta_i = \\mathbb{E}[u_i(x(m_i, \\sigma_{-i}), \\theta_i) | \\theta_i]$. So $\\sigma_i(\\theta_i) = 0$ is a Bayes-Nash equilibrium.\n\n\n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "fdd5864228cc169be8a783fe22f4e53afb664dc4", "size": 3390, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw5/hw5.tex", "max_stars_repo_name": "sahilchinoy/econ103", "max_stars_repo_head_hexsha": "ab2ecbb759eb811e953157e7f04f5a003066a62c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-08T22:59:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-08T22:59:12.000Z", "max_issues_repo_path": "hw5/hw5.tex", "max_issues_repo_name": "sahilchinoy/econ103", "max_issues_repo_head_hexsha": "ab2ecbb759eb811e953157e7f04f5a003066a62c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw5/hw5.tex", "max_forks_repo_name": "sahilchinoy/econ103", "max_forks_repo_head_hexsha": "ab2ecbb759eb811e953157e7f04f5a003066a62c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2018-10-29T10:06:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-27T14:30:33.000Z", "avg_line_length": 49.1304347826, "max_line_length": 566, "alphanum_fraction": 0.6749262537, "num_tokens": 1127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.41724518015053136}}
{"text": "\\documentclass{article}\n\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage[UKenglish]{babel}\n\\usepackage{enumitem}\n\\usepackage{fancyhdr}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx}\n\\usepackage[utf8]{inputenc}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{tikz-cd}\n\\usepackage{csquotes}\n\n\\newcommand{\\F}{\\mathbb{F}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\A}{\\mathbb{A}}\n\\renewcommand{\\P}{\\mathbb{P}}\n\n\\newcommand{\\val}[1]{\\left. #1 \\right\\rvert}\n\\newcommand{\\rb}[1]{\\left( #1 \\right)}\n\\renewcommand{\\sb}[1]{\\left[ #1 \\right]}\n\\newcommand{\\cb}[1]{\\left\\{ #1 \\right\\}}\n\\newcommand{\\ab}[1]{\\left\\langle #1 \\right\\rangle}\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\\newcommand{\\two}[2]{\\begin{pmatrix} #1 \\\\ #2 \\end{pmatrix}}\n\\newcommand{\\three}[3]{\\begin{pmatrix} #1 & #2 & #3 \\end{pmatrix}}\n\n\\newcommand{\\notb}[1]{\\rb{\\neg #1}}\n\\newcommand{\\orb}[2]{\\rb{#1 \\lor #2}}\n\\newcommand{\\andb}[2]{\\rb{#1 \\land #2}}\n\\newcommand{\\impb}[2]{\\rb{#1 \\rightarrow #2}}\n\\newcommand{\\iffb}[2]{\\rb{#1 \\leftrightarrow #2}}\n\\newcommand{\\fab}[1]{\\rb{\\forall #1}}\n\\newcommand{\\teb}[1]{\\rb{\\exists #1}}\n\n\\theoremstyle{definition}\\newtheorem{definition}{Definition}[subsection]\n\\theoremstyle{definition}\\newtheorem{remark}[definition]{Remark}\n\\theoremstyle{definition}\\newtheorem*{example}{Example}\n\\theoremstyle{definition}\\newtheorem*{note}{Note}\n\\newtheorem{proposition}[definition]{Proposition}\n\\newtheorem{lemma}[definition]{Lemma}\n\\newtheorem{theorem}[definition]{Theorem}\n\\newtheorem{corollary}[definition]{Corollary}\n\n\\pagestyle{fancy}\n\\lhead{M3P65 Mathematical Logic}\n\\rhead{Autumn 2018}\n\n\\title{M3P65 Mathematical Logic}\n\\author{Lectured by Prof David Evans \\\\ Typeset by David Kurniadi Angdinata}\n\\date{Autumn 2018}\n\n\\setcounter{section}{-1}\n\n\\begin{document}\n\n\\maketitle\n\n\\vfill\n\n\\tableofcontents\n\n\\pagebreak\n\n\\marginpar{Lecture 1 \\\\ Thursday \\\\ 04/10/18}\n\n\\section{Introduction}\n\nThe module is concerned with some of the foundational issues of mathematics, namely propositional logic, predicate logic, and set theory. These topics have applications to other areas of mathematics. Formal logic has applications via model theory and ZFC provides an essential toolkit for handling infinite objects.\n\nIn propositional logic, we look at the way simple propositions can be built into more complicated ones using connectives and make precise how the truth or falsity of the component statements influences the truth or falsity of the compound statement. This is done using truth tables and can be useful for testing the validity of various forms of reasoning. It provides a way of analysing deductions of the form 'If the following statements are true, ..., then so is ...'. A completely symbolic process of deduction and describe the formal deduction system for propositional calculus. The propositional formulas are regarded as strings of symbols and we give rules for deducing a new formula from a given collection of formulas. We want these deduction rules to have the property that anything that could be deduced using truth tables (so by considering truth or falsity of the various statements), can be deduced in this formal way, and vice versa. This is the soundness and completeness of our formal system.\n\nIn predicate logic, we analyse mathematics using quantifiers. We introduce the notion of a first-order structure, which is general enough to include many of the algebraic objects you come across in mathematics, such as groups, rings, and vector spaces. We then have to be precise about the formulas which make statements about these structures, and give a precise definition of what it means for a particular formula to be true in a structure. This is quite intricate, and the clever part is in getting the definitions right, but it corresponds to ordinary mathematical usage. Once this is done, we set up a formal deduction system for predicate logic. This parallels what we did for propositional logic, but is much harder. Nevertheless, the end result is the same. The formulas which are produced by our formal deduction system are precisely the formulas which are true in all first-order structures. This is Gödel's completeness theorem.\n\nSet theory provides the basic foundations and the language in which most of modern mathematics can be expressed, as well as the means for discussing the various notions of sizes of infinity. For example, although the set of natural numbers, the set of integers and the set of real numbers are all infinite, there is a very natural sense in which the first two have the same size, whereas the third is strictly bigger. This is expressed properly in the notion of cardinality. To avoid paradoxes and inconsistencies, we have to be careful about what collections of objects we allow to be called sets. This is done by the Zermelo-Fraenkel axioms, which essentially tell us how we are allowed to create new sets out of old ones. Of course, having laid down these quite rigid rules, we have to show that they are sufficiently flexible to allow us to talk about everyday objects of mathematics. There are also situations in mathematics where an extra axiom is needed, the Axiom of Choice. For example without this axiom, we cannot show that every vector space has a basis. But it also has some slightly counterintuitive consequences, and we shall also look at some of these.\n\nThe lecture notes should be fairly self-contained, but the following books might also be of use. You might find that the notation which they use differs form that used in the lectures. You will be able to find various lecture notes on the internet. Some will be good, others not so good.\n\n\\begin{enumerate}\n\\item P Johnstone, Notes on logic and set theory, 1987\n\\item P J Cameron, Sets, logic and categories, 1999\n\\item A G Hamilton, Logic for mathematicians, 1988\n\\item R Cori and D Lascar, Mathematical logic: a course with exercises parts I and II, 2001\n\\item K Hrbaček and T Jech, Introduction to set theory 3rd edition, 1999\n\\end{enumerate}\n\n$ 1 $ is very concise, but covers a surprising amount. $ 2 $ is friendlier, but skips some of the harder material. $ 4 $ is quite comprehensive and also available in the original French. $ 3 $ is useful for the logic part and $ 5 $ is a very nice introduction to set theory.\n\n\\section{Propositional logic}\n\nLet $ p $ be 'Mr Jones is happy' and $ q $ be 'Mrs Jones is unhappy'. Then 'If Mr Jones is happy, then Mrs Jones is unhappy and if Mrs Jones is unhappy then Mr Jones is unhappy, so Mr Jones is unhappy' is\n$$ \\impb{\\andb{\\impb{p}{q}}{\\impb{q}{\\notb{p}}}}{\\notb{p}}. $$\n\n\\subsection{Propositional formulas}\n\nThe following are \\textbf{truth table rules}.\n\n\\begin{definition}\n\\label{def:1.1.1}\nA \\textbf{proposition} is a statement that is either \\textbf{True} $ \\rb{T} $ or \\textbf{False} $ \\rb{F} $, which can be represented symbolically as \\textbf{propositional variables}\n$$ p, \\quad q, \\quad \\dots \\qquad p_1, \\quad p_2, \\quad \\dots. $$\nWe combine basic propositions into others using \\textbf{connectives}, which are one of\n\\begin{itemize}\n\\item \\textbf{negation 'not'} $ \\rb{\\neg p} $, which has value $ F $ if $ p $ has value $ T $ and has value $ T $ if $ p $ has value $ F $,\n\\item \\textbf{conjunction 'and'} $ \\rb{p \\land q} $, which has value $ T $ iff $ p $ and $ q $ both have value $ T $,\n\\item \\textbf{disjunction 'or'} $ \\rb{p \\lor q} $, which has value $ T $ iff at least one of $ p $ and $ q $ has value $ T $,\n\\item \\textbf{implication 'implies'} $ \\rb{p \\rightarrow q} $, which has value $ F $ iff $ p $ has value $ T $ and $ q $ has value $ F $, and\n\\item \\textbf{biconditional 'iff'} $ \\rb{p \\leftrightarrow q} $, which has value $ T $ iff $ p $ and $ q $ has the same value.\n\\end{itemize}\nThis can be represented in the following \\textbf{truth table}.\n\\begin{center}\n\\begin{tabular}{|c|c|c|c|c|c|}\n\\hline\n$ p $ & $ q $ & $ \\rb{p \\land q} $ & $ \\rb{p \\lor q} $ & $ \\rb{p \\rightarrow q} $ & $ \\rb{p \\leftrightarrow q} $ \\\\\n\\hline\n$ T $ & $ T $ & $ T $ & $ T $ & $ T $ & $ T $ \\\\\n\\hline\n$ T $ & $ F $ & $ F $ & $ T $ & $ F $ & $ F $ \\\\\n\\hline\n$ F $ & $ T $ & $ F $ & $ T $ & $ T $ & $ F $ \\\\\n\\hline\n$ F $ & $ F $ & $ F $ & $ F $ & $ T $ & $ T $ \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{definition}\n\n\\begin{definition}\n\\label{def:1.1.2}\nA \\textbf{propositional formula} is obtained in the following way.\n\\begin{enumerate}\n\\item Any propositional variable is a formula.\n\\item If $ \\phi $ and $ \\psi $ are formulas, then so are\n$$ \\notb{\\phi}, \\qquad \\andb{\\phi}{\\psi}, \\qquad \\orb{\\phi}{\\psi}, \\qquad \\impb{\\phi}{\\psi}, \\qquad \\iffb{\\phi}{\\psi}. $$\n\\item Any formula arises in this way.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{example}\nSome formulas are\n$$ p_1, \\qquad p_2, \\qquad \\notb{p_1}, \\qquad \\impb{p_1}{\\notb{p_2}}, \\qquad \\impb{\\impb{p_1}{\\notb{p_2}}}{p_2}. $$\nSome not formulas are\n$$ p_1 \\land p_2 \\quad \\rb{\\text{missing brackets}}, \\qquad )( \\neg p_1 \\quad \\rb{\\text{not well-formed}}. $$\n\\end{example}\n\nBecause of the brackets, every formula is either a propositional variable or is built from shorter formulas in a unique way. Arguments are often proved by induction on length of the formula, or the number of connectives in the formula.\n\n\\begin{definition}\n\\hfill\n\\begin{enumerate}\n\\item Let $ n \\in \\N $. A \\textbf{truth function} of $ n $ variables is a function $ f : \\cb{T, F}^n \\to \\cb{T, F} $, where $ \\cb{T, F}^n = \\cb{\\rb{x_1, \\dots, x_n} \\mid x_i \\in \\cb{T, F}} $.\n\\item Suppose $ \\phi $ is a formula whose variables are amongst $ p_1, \\dots, p_n $. We obtain a truth function $ F_\\phi : \\cb{T, F}^n \\to \\cb{T, F} $ whose value at $ \\rb{x_1, \\dots, x_n} $ is the truth value of $ \\phi $ when $ p_i $ has value $ x_i $ for $ i = 1, \\dots, n $, computed using the rules in \\ref{def:1.1.1}. $ F_\\phi $ is the \\textbf{truth function of $ \\phi$}.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{example}\n$ \\phi : \\impb{\\impb{p}{\\notb{q}}}{p} $ has the following truth table.\n\\begin{center}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n$ p $ & $ q $ & $ \\notb{q} $ & $ \\impb{p}{\\notb{q}} $ & $ \\phi $ \\\\\n\\hline\n$ T $ & $ T $ & $ F $ & $ F $ & $ T $ \\\\\n\\hline\n$ T $ & $ F $ & $ T $ & $ T $ & $ T $ \\\\\n\\hline\n$ F $ & $ T $ & $ F $ & $ T $ & $ F $ \\\\\n\\hline\n$ F $ & $ F $ & $ T $ & $ T $ & $ F $ \\\\\n\\hline\n\\end{tabular}\n\\end{center}\nSo for example $ F_\\phi\\rb{T, F} = T $. This can also be written in a \\textbf{condensed form} as follows.\n\\begin{center}\n\\begin{tabular}{cccccccccccc}\n$ ( $ & $ ( $ & $ p $ & $ \\rightarrow $ & $ ( $ & $ \\neg $ & $ q $ & $ ) $ & $ ) $ & $ \\rightarrow $ & $ p $ & $ ) $ \\\\\n& & $ T $ & $ F $ & & $ F $ & $ T $ & & & $ T $ & $ T $ & \\\\\n& & $ T $ & $ T $ & & $ T $ & $ F $ & & & $ T $ & $ T $ & \\\\\n& & $ F $ & $ T $ & & $ F $ & $ T $ & & & $ F $ & $ F $ & \\\\\n& & $ F $ & $ T $ & & $ T $ & $ F $ & & & $ F $ & $ F $ & \\\\\n\\end{tabular}\n\\end{center}\n\\end{example}\n\n\\marginpar{Lecture 2 \\\\ Friday \\\\ 05/10/18}\n\n\\begin{example}\nThe truth function of $ \\impb{\\andb{\\impb{p}{q}}{\\impb{q}{\\notb{p}}}}{\\notb{p}} $ is always $ T $.\n\\end{example}\n\n\\begin{definition}\n\\hfill\n\\begin{enumerate}\n\\item A propositional formula is a \\textbf{tautology} if its truth function $ F_\\phi $ always has value $ T $.\n\\item Say that formulas $ \\phi, \\psi $ are \\textbf{logically equivalent} (LE) if they have the same truth function, that is $ F_\\phi = F_\\psi $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{remark}\n\\hfill\n\\label{rem:1.1.5}\n\\begin{enumerate}\n\\item $ \\phi, \\psi $ are LE iff $ \\iffb{\\phi}{\\psi} $ is a tautology.\n\\item Suppose $ \\phi $ is a formula with variables $ p_1, \\dots, p_n $ and $ \\phi_1, \\dots, \\phi_n $ are formulas with variables $ q_1, \\dots q_r $. For each $ i \\le n $ substitute $ \\phi_i $ in place of $ p_i $ in $ \\phi $. Then the result is a formula $ \\theta $, and if $ \\phi $ is a tautology, then so is $ \\theta $.\n\\end{enumerate}\n\\end{remark}\n\n\\begin{example}\nCheck $ \\impb{\\impb{\\notb{p_2}}{\\notb{p_1}}}{\\impb{p_1}{p_2}} $ is a tautology. So by \\ref{rem:1.1.5}(2), if $ \\phi_1 $ and $ \\phi_2 $ are any formulas, then $ \\impb{\\impb{\\notb{\\phi_2}}{\\notb{\\phi_1}}}{\\impb{\\phi_1}{\\phi_2}} $ is a tautology.\n\\end{example}\n\n\\begin{proof}[Proof of \\ref{rem:1.1.5}]\n\\hfill\n\\begin{enumerate}\n\\item Easy.\n\\item Prove $ F_\\phi\\rb{p_1, \\dots, p_r} = F_\\phi\\rb{F_{\\phi_1}\\rb{q_1, \\dots, q_r}, \\dots, F_{\\phi_n}\\rb{q_1, \\dots, q_r}} $ by induction on the number of connectives in $ \\phi $.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{example}\nThe following are LE formulas.\n\\begin{enumerate}\n\\item $ \\andb{p_1}{\\andb{p_2}{p_3}} $ is LE to $ \\andb{\\andb{p_1}{p_2}}{p_3} $.\n\\item $ \\orb{p_1}{\\orb{p_2}{p_3}} $ is LE to $ \\orb{\\orb{p_1}{p_2}}{p_3} $.\n\\item $ \\orb{p_1}{\\andb{p_2}{p_3}} $ is LE to $ \\andb{\\orb{p_1}{p_2}}{\\orb{p_1}{p_3}} $.\n\\item $ \\andb{p_1}{\\orb{p_2}{p_3}} $ is LE to $ \\orb{\\andb{p_1}{p_2}}{\\andb{p_1}{p_3}} $.\n\\item $ \\notb{\\notb{p_1}} $ is LE to $ p_1 $.\n\\item $ \\notb{\\andb{p_1}{p_2}} $ is LE to $ \\orb{\\notb{p_1}}{\\notb{p_2}} $.\n\\item $ \\notb{\\orb{p_1}{p_2}} $ is LE to $ \\andb{\\notb{p_1}}{\\notb{p_2}} $.\n\\end{enumerate}\nBy the first two examples, we usually omit brackets as $ \\rb{p_1 \\land p_2 \\land p_3} $ and $ \\rb{p_1 \\lor p_2 \\lor p_3} $ without ambiguity.\n\\end{example}\n\n\\begin{note}\nBy \\ref{rem:1.1.5} we obtain, for formulas $ \\phi, \\psi, \\chi $, $ \\andb{\\phi}{\\andb{\\psi}{\\chi}} $ is LE to $ \\andb{\\andb{\\phi}{\\psi}}{\\chi} $, etc.\n\\end{note}\n\n\\begin{lemma}\nThere are $ 2^{2^n} $ truth functions of $ n $ variables.\n\\end{lemma}\n\n\\begin{proof}\nA truth function is a function $ F : \\cb{T, F}^n \\to \\cb{T, F} $. $ \\abs{\\cb{T, F}^n} = 2^n $ and for each $ \\bar{x} \\in \\cb{T, F}^n $, $ F\\rb{\\bar{x}} \\in \\cb{T, F} $. Hence the result.\n\\end{proof}\n\n\\begin{definition}\nA set of connectives is \\textbf{adequate} if for every $ n \\ge 1 $, every truth function of $ n $ variables is the truth function of some formula which involves only connectives from the set, and variables $ p_1, \\dots, p_n $.\n\\end{definition}\n\n\\begin{theorem}\n\\label{thm:1.1.9}\nThe set $ \\cb{\\neg, \\land, \\lor} $ is adequate.\n\\end{theorem}\n\n\\begin{proof}\nLet $ G : \\cb{T, F}^n \\to \\cb{T, F} $.\n\\begin{enumerate}\n\\item If $ G\\rb{\\bar{v}} = F $ for all $ \\bar{v} \\in \\cb{T, F}^n $, let $ \\phi = \\andb{p_1}{\\notb{p_1}} $. Then $ F_\\phi = G $.\n\\item Otherwise list the $ \\bar{v} \\in \\cb{T, F}^n $ with $ G\\rb{\\bar{v}} = T $ as $ \\bar{v_1}, \\dots, \\bar{v_r} $. Write $ \\bar{v_i} = \\rb{v_{i1}, \\dots, v_{in}} $, where each $ v_{ij} \\in \\cb{T, F} $. Define\n$$ q_{ij} = \\begin{cases} p_j & v_{ij} = T \\\\ \\notb{p_j} & v_{ij} = F \\end{cases}, \\qquad \\psi_i = \\rb{q_{i1} \\land \\dots \\land q_{in}}, \\qquad \\theta = \\rb{\\psi_1 \\lor \\dots \\lor \\psi_r}. $$\nHence\n\\begin{align*}\nF_\\theta\\rb{\\bar{v}} = T\n& \\iff \\exists i \\le r, \\ F_{\\psi_i}\\rb{\\bar{v}} = T \\\\\n& \\iff \\exists i \\le r, \\ \\forall j \\le n, \\ q_{ij} = T \\\\\n& \\iff \\exists i \\le r, \\ \\forall j \\le n, \\ p_j = v_{ij} \\\\\n& \\iff \\exists i \\le r, \\ \\bar{v} = \\bar{v_i} \\\\\n& \\iff G\\rb{\\bar{v}} = T.\n\\end{align*}\nThus $ F_\\theta = G $.\n\\end{enumerate}\nAs $ \\phi $ and $ \\theta $ were constructed using only $ \\neg, \\land, \\lor $, \\ref{thm:1.1.9} follows.\n\\end{proof}\n\nA formula $ \\theta $ as in case 2 is said to be in \\textbf{disjunctive normal form} (DNF).\n\n\\begin{corollary}\nSuppose $ \\chi $ is a formula whose truth function is not always $ F $. Then $ \\chi $ is LE to a formula in DNF.\n\\end{corollary}\n\n\\begin{proof}\nTake $ G = F_\\chi $ and apply case 2 of \\ref{thm:1.1.9}.\n\\end{proof}\n\n\\begin{example}\nLet $ \\chi $ be $ \\impb{\\impb{p_1}{p_2}}{\\notb{p_2}} $. Then $ F_\\chi\\rb{\\bar{v}} = T $ iff $ \\bar{v} = \\rb{T, F}, \\rb{F, F} $. Thus its DNF is\n$$ \\orb{\\andb{p_1}{\\notb{p_2}}}{\\andb{\\notb{p_1}}{\\notb{p_2}}}. $$\n\\end{example}\n\n\\begin{corollary}\nThe following sets of connectives are adequate.\n\\begin{enumerate}\n\\item $ \\cb{\\neg, \\lor} $.\n\\item $ \\cb{\\neg, \\land} $.\n\\item $ \\cb{\\neg, \\rightarrow} $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item By \\ref{thm:1.1.9} it is sufficient to show that we can express $ \\land $ using $ \\neg, \\lor $, which holds since $ \\andb{p_1}{p_2} $ is LE to $ \\notb{\\orb{\\notb{p_1}}{\\notb{p_2}}} $.\n\\item By \\ref{thm:1.1.9} it is sufficient to show that we can express $ \\lor $ using $ \\neg, \\land $, which holds since $ \\orb{p_1}{p_2} $ is LE to $ \\notb{\\andb{\\notb{p_1}}{\\notb{p_2}}} $.\n\\item By \\ref{thm:1.1.9} it is sufficient to show that we can express $ \\lor $ using $ \\neg, \\rightarrow $, which holds since $ \\orb{p_1}{p_2} $ is LE to $ \\impb{\\notb{p}}{q} $.\n\\end{enumerate}\n\\end{proof}\n\n\\marginpar{Lecture 3 \\\\ Monday \\\\ 08/10/18}\n\n\\begin{example}\nThe following are not adequate.\n\\begin{enumerate}\n\\item $ \\cb{\\land, \\lor} $. If $ \\phi $ is built using $ \\land, \\lor $, then $ F_\\phi\\rb{T, \\dots, T} = T $. Proof by induction on number of connectives.\n\\item $ \\cb{\\neg, \\leftrightarrow} $. (TODO Exercise: proof)\n\\end{enumerate}\n\\end{example}\n\n\\begin{example}\nThe NOR connective $ \\downarrow $ has the following truth table.\n\\begin{center}\n\\begin{tabular}{|c|c|c|}\n\\hline\n$ p $ & $ q $ & $ \\rb{p \\downarrow q} $ \\\\\n\\hline\n$ T $ & $ T $ & $ F $ \\\\\n\\hline\n$ T $ & $ F $ & $ F $ \\\\\n\\hline\n$ F $ & $ T $ & $ F $ \\\\\n\\hline\n$ F $ & $ F $ & $ T $ \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n$ \\rb{p \\downarrow q} $ is LE to $ \\andb{\\notb{p}}{\\notb{q}} $. $ \\cb{\\downarrow} $ is adequate. $ \\rb{p \\downarrow p} $ is LE to $ \\notb{p} $ and $ \\rb{\\rb{p \\downarrow p} \\downarrow \\rb{q \\downarrow q}} $ is LE to $ \\andb{p}{q} $. So as $ \\cb{\\neg, \\lor} $ is adequate, so is $ \\cb{\\downarrow} $.\n\\end{example}\n\n\\subsection{A formal system for propositional logic}\n\nIdea is to try to generate all tautologies from basic assumptions, or axioms, using appropriate deduction rules. A very general definition is the following.\n\n\\begin{definition}\n\\hfill\n\\begin{enumerate}\n\\item A \\textbf{formal deduction system} $ \\Sigma $ has the following ingredients.\n\\begin{enumerate}\n\\item a non-zero \\textbf{alphabet} $ A $ of symbols,\n\\item a non-empty subset $ \\mathcal{F} $ of the set of all finite sequences, or \\textbf{strings}, of elements of $ A $, the \\textbf{formulas} of $ \\Sigma $,\n\\item a subset $ \\mathcal{A} \\subseteq \\mathcal{F} $ called the \\textbf{axioms} of $ \\Sigma $, and\n\\item a collection of \\textbf{deduction rules}.\n\\end{enumerate}\n\\item A \\textbf{proof} in $ \\Sigma $ is a finite sequence of formulas in $ \\mathcal{F} $ $ \\phi_1, \\dots, \\phi_n $ such that each $ \\phi_i $ is either an axiom in $ \\mathcal{A} $ or is obtained from $ \\phi_1, \\dots, \\phi_{i - 1} $ using one of the deduction rules. The last, or any, formula in a proof is a \\textbf{theorem} of $ \\Sigma $.\n\\end{enumerate}\nWrite $ \\vdash_\\Sigma \\phi $ for '$ \\phi $ is a theorem of $ \\Sigma $'.\n\\end{definition}\n\n\\begin{remark}\n\\hfill\n\\begin{enumerate}\n\\item If $ \\phi \\in \\mathcal{A} $, then $ \\vdash_\\Sigma \\phi $.\n\\item We should have an algorithm to test whether a string is a formula and whether it is an axiom. Then a computer can systematically generate all possible proofs in $ \\Sigma $, and check whether something is a proof. Say $ \\Sigma $ is \\textbf{recursive} in this case.\n\\end{enumerate}\n\\end{remark}\n\nThe main example is the following.\n\n\\begin{definition}\n\\label{def:1.2.3}\nThe formal system \\textbf{$ L $} for propositional logic has the following.\n\\begin{enumerate}\n\\item Alphabet. Alphabets are\n\\begin{enumerate}\n\\item variables $ p_1, p_2, \\dots $,\n\\item connectives $ \\neg, \\rightarrow $, and\n\\item punctuation $ ( $, $ ) $.\n\\end{enumerate}\n\\item Formulas. \\textbf{$ L $-formulas} are defined in \\ref{def:1.1.2} for $ \\neg, \\rightarrow $ by\n\\begin{enumerate}\n\\item any variable $ p_i $ is a formula,\n\\item if $ \\phi, \\psi $ are formulas so are $ \\notb{\\phi}, \\impb{\\phi}{\\psi} $, and\n\\item any formula arises in this way.\n\\end{enumerate}\n\\item Axioms. Suppose $ \\phi, \\psi, \\chi $ are $ L $-formulas, then the axioms of $ L $ are\n\\begin{enumerate}[label=(A\\arabic*)]\n\\item $ \\impb{\\phi}{\\impb{\\psi}{\\phi}} $,\n\\item $ \\impb{\\impb{\\phi}{\\impb{\\psi}{\\chi}}}{\\impb{\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\chi}}} $, and\n\\item $ \\impb{\\impb{\\notb{\\psi}}{\\notb{\\phi}}}{\\impb{\\phi}{\\psi}} $.\n\\end{enumerate}\n\\item Deduction rules. \\textbf{Modus Ponens} (MP), from formulas $ \\phi, \\impb{\\phi}{\\psi} $, deduce $ \\psi $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{example}\nSuppose $ \\phi $ is an $ L $-formula. Then $ \\vdash_L \\impb{\\phi}{\\phi} $. Here is a proof in $ L $.\n\\begin{align*}\n1 \\qquad & \\impb{\\phi}{\\impb{\\impb{\\phi}{\\phi}}{\\phi}} & \\rb{\\text{A1}} \\\\\n2 \\qquad & \\impb{\\impb{\\phi}{\\impb{\\impb{\\phi}{\\phi}}{\\phi}}}{\\impb{\\impb{\\phi}{\\impb{\\phi}{\\phi}}}{\\impb{\\phi}{\\phi}}} & \\rb{\\text{A2}} \\\\\n3 \\qquad & \\impb{\\impb{\\phi}{\\impb{\\phi}{\\phi}}}{\\impb{\\phi}{\\phi}} & \\rb{1, 2, \\text{MP}} \\\\\n4 \\qquad & \\impb{\\phi}{\\impb{\\phi}{\\phi}} & \\rb{\\text{A1}} \\\\\n5 \\qquad & \\impb{\\phi}{\\phi} & \\rb{3, 4, \\text{MP}}\n\\end{align*}\n\\end{example}\n\n\\marginpar{Lecture 4 \\\\ Thursday \\\\ 11/10/18}\n\n\\begin{definition}\nSuppose $ \\Gamma $ is a set of $ L $-formulas. A \\textbf{deduction from $ \\Gamma $} is a finite sequence of $ L $-formulas $ \\phi_1, \\dots, \\phi_n $ such that each $ \\phi_i $ is either an axiom, a formula in $ \\Gamma $, or is obtained from previous formulas $ \\phi_1, \\dots, \\phi_{i - 1} $ using the deduction rule MP. Write $ \\Gamma \\vdash_L \\phi $ if there is a deduction from $ \\Gamma $ ending in $ \\phi $. Say $ \\phi $ is a \\textbf{consequence} of $ \\Gamma $. So $ \\emptyset \\vdash_L \\phi $ is the same as $ \\vdash_L \\phi $.\n\\end{definition}\n\n\\begin{theorem}[Deduction theorem]\n\\label{thm:1.2.5}\nSuppose $ \\Gamma $ is a set of $ L $-formulas and $ \\phi, \\psi $ are $ L $-formulas. Suppose $ \\Gamma \\cup \\cb{\\phi} \\vdash_L \\psi $. Then $ \\Gamma \\vdash_L \\impb{\\phi}{\\psi} $.\n\\end{theorem}\n\n\\begin{corollary}[Hypothetical syllogism]\nSuppose $ \\phi, \\psi, \\chi $ are $ L $-formulas and $ \\vdash_L \\impb{\\phi}{\\psi} $ and $ \\vdash_L \\impb{\\psi}{\\chi} $. Then $ \\vdash_L \\impb{\\phi}{\\chi} $.\n\\end{corollary}\n\n\\begin{proof}\nUse deduction theorem with $ \\Gamma = \\emptyset $. Show $ \\cb{\\phi} \\vdash_L \\chi $. Here is a deduction of $ \\chi $ from $ \\phi $.\n\\begin{align*}\n1 \\qquad & \\impb{\\phi}{\\psi} & \\rb{\\text{theorem of } L} \\\\\n2 \\qquad & \\impb{\\psi}{\\chi} & \\rb{\\text{theorem of } L} \\\\\n3 \\qquad & \\phi & \\rb{\\text{assumption}} \\\\\n4 \\qquad & \\psi & \\rb{1, 3, \\text{MP}} \\\\\n5 \\qquad & \\chi & \\rb{2, 4, \\text{MP}}\n\\end{align*}\nThus $ \\cb{\\phi} \\vdash_L \\chi $. By deduction theorem, $ \\emptyset \\vdash_L \\impb{\\phi}{\\chi} $, that is $ \\vdash_L \\impb{\\phi}{\\chi} $.\n\\end{proof}\n\n\\begin{proposition}\n\\label{prop:1.2.7}\nSuppose $ \\phi, \\psi $ are $ L $-formulas. Then\n\\begin{enumerate}\n\\item $ \\vdash_L \\impb{\\notb{\\psi}}{\\impb{\\psi}{\\phi}} $,\n\\item $ \\cb{\\notb{\\psi}, \\psi} \\vdash_L \\phi $, and\n\\item $ \\vdash_L \\impb{\\impb{\\notb{\\phi}}{\\phi}}{\\phi} $.\n\\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item Problem sheet 1.\n\\item By 1 and MP twice.\n\\item Suppose $ \\chi $ is any formula. Then $ \\cb{\\notb{\\phi}, \\impb{\\notb{\\phi}}{\\phi}} \\vdash_L \\chi $ by 2 and MP. Let $ \\alpha $ be any axiom and let $ \\chi $ be $ \\notb{\\alpha} $. Apply deduction theorem to get $ \\cb{\\impb{\\notb{\\phi}}{\\phi}} \\vdash_L \\impb{\\notb{\\phi}}{\\notb{\\alpha}} $. Using A3 and MP we get $ \\cb{\\impb{\\notb{\\phi}}{\\phi}} \\vdash_L \\impb{\\alpha}{\\phi} $. As $ \\alpha $ is an axiom we get from MP $ \\cb{\\impb{\\notb{\\phi}}{\\phi}} \\vdash_L \\phi $. Now use deduction theorem to obtain $ \\vdash_L \\impb{\\impb{\\notb{\\phi}}{\\phi}}{\\phi} $.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{proof}[Proof of \\ref{thm:1.2.5}]\nSuppose $ \\Gamma \\cup \\cb{\\phi} \\vdash_L \\psi $ using a deduction of length $ n $. Show by induction on $ n $ that $ \\Gamma \\vdash_L \\impb{\\phi}{\\psi} $.\n\\begin{enumerate}\n\\item Base step is $ n = 1 $. In this case $ \\psi $ is either an axiom or in $ \\Gamma $ or is $ \\phi $. In the first two cases $ \\Gamma \\vdash_L \\psi $ is a one line deduction. Using the A1 axiom $ \\impb{\\psi}{\\impb{\\phi}{\\psi}} $ and MP we obtain $ \\Gamma \\vdash_L \\impb{\\phi}{\\psi} $. If $ \\phi $ is $ \\psi $ we have $ \\Gamma \\vdash_L \\impb{\\phi}{\\phi} $ by \\ref{def:1.2.3}. This finishes the base case.\n\\item Inductive step. In our deduction of $ \\psi $ from $ \\Gamma \\cup \\cb{\\phi} $ either $ \\psi $ is an axiom, or in $ \\Gamma $, or is $ \\phi $, or $ \\psi $ is obtained from earlier steps using MP. In the first three cases we argue as in the base case to get $ \\Gamma \\vdash_L \\impb{\\phi}{\\psi} $. In the last case there are formulas $ \\chi $, $ \\impb{\\chi}{\\psi} $ earlier in the deduction. We use the inductive hypothesis to get $ \\Gamma \\vdash_L \\impb{\\phi}{\\chi} $ and $ \\Gamma \\vdash_L \\impb{\\phi}{\\impb{\\chi}{\\psi}} $. We have the A2 axiom $ \\impb{\\impb{\\phi}{\\impb{\\psi}{\\chi}}}{\\impb{\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\chi}}} $. This A2 axiom and MP twice we obtain $ \\Gamma \\vdash_L \\impb{\\phi}{\\chi} $ as required, completing the inductive step.\n\\end{enumerate}\n\\end{proof}\n\n\\marginpar{Lecture 5 \\\\ Friday \\\\ 12/10/18}\n\n\\subsection{Soundness and completeness of $ L $}\n\n\\begin{theorem}[Soundness theorem of $ L $]\n\\label{thm:1.3.1}\nSuppose $ \\phi $ is a theorem of $ L $. Then $ \\phi $ is a tautology.\n\\end{theorem}\n\n\\begin{definition}\nA \\textbf{propositional valuation} $ v $ is an assignment of truth values to the propositional variables $ p_1, p_2, \\dots $. So $ v\\rb{p_i} \\in \\cb{T, F} $ for $ i \\in \\N $.\n\\end{definition}\n\n\\begin{note}\nUsing the truth table rules, this assigns a truth value $ v\\rb{\\phi} \\in \\cb{T, F} $ to every $ L $-formula $ \\phi $ satisfying $ v\\rb{\\notb{\\phi}} \\ne v\\rb{\\phi} $, etc. See problem sheet 2, question 3(b).\n\\end{note}\n\nBy induction on the length of a proof of $ \\phi $ it is enough to show\n\\begin{enumerate}\n\\item every axiom is a tautology, and\n\\item MP preserves tautologies, that is if $ \\psi, \\impb{\\psi}{\\chi} $ are tautologies, so is $ \\chi $.\n\\end{enumerate}\n\n\\begin{proof}[Proof of \\ref{thm:1.3.1}]\n\\hfill\n\\begin{enumerate}\n\\item Use truth tables, or argue as follows. For A2, suppose for a contradiction there is a valuation $ v $ with $ v\\rb{\\impb{\\impb{\\phi}{\\impb{\\psi}{\\chi}}}{\\impb{\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\chi}}}} = F $. Then\n\\begin{equation}\n\\label{eq:1}\nv\\rb{\\impb{\\phi}{\\impb{\\psi}{\\chi}}} = T,\n\\end{equation}\nand\n\\begin{equation}\n\\label{eq:2}\nv\\rb{\\impb{\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\chi}}} = F.\n\\end{equation}\nBy $ \\rb{\\ref{eq:2}} $, $ v\\rb{\\impb{\\phi}{\\psi}} = T $ and $ v\\rb{\\impb{\\phi}{\\chi}} = F $. So by the latter, $ v\\rb{\\phi} = T $ and $ v\\rb{\\chi} = F $. By the former, $ v\\rb{\\psi} = T $. This contradicts $ \\rb{\\ref{eq:1}} $. (TODO Exercise: for A1 and A3)\n\\item If $ v $ is a valuation and $ v\\rb{\\psi} = T $ and $ v\\rb{\\impb{\\psi}{\\chi}} = T $ then $ v\\rb{\\chi} = T $.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{theorem}[Generalisation of Soundness theorem of $ L $]\nSuppose $ \\Gamma $ is a set of formulas and $ \\phi $ a formula with $ \\Gamma \\vdash_L \\phi $. Suppose $ v $ is a valuation with $ v\\rb{\\psi} = T $ for all $ \\psi \\in \\Gamma $. Then $ v\\rb{\\phi} = T $.\n\\end{theorem}\n\n\\begin{proof}\nSame proof. (TODO Exercise)\n\\end{proof}\n\n\\begin{theorem}[Completeness theorem of $ L $]\n\\label{thm:1.3.4}\nSuppose $ \\phi $ is a tautology, that is $ v\\rb{\\phi} = T $ for every valuation $ v $. Then $ \\vdash_L \\phi $.\n\\end{theorem}\n\nThe following are steps in the proof.\n\\begin{enumerate}\n\\item If $ v\\rb{\\phi} = T $ for all valuations $ v $, want to show $ \\vdash_L \\phi $.\n\\item Try to prove a generalisation. Suppose that for every $ v $ with $ v\\rb{\\Gamma} = T $, that is $ v\\rb{\\psi} = T $ for all $ \\psi \\in \\Gamma $, we have $ v\\rb{\\phi} = T $. Then $ \\Gamma \\vdash_L \\phi $.\n\\item Equivalently, if $ \\Gamma \\not\\vdash_L \\phi $, show there is a valuation $ v $ with $ v\\rb{\\Gamma} = T $ and $ v\\rb{\\phi} = F $.\n\\end{enumerate}\n\n\\begin{definition}\nA set $ \\Gamma $ of $ L $-formulas is \\textbf{consistent} if there is no $ L $-formula $ \\phi $ such that $ \\Gamma \\vdash_L \\phi $ and $ \\Gamma \\vdash_L \\notb{\\phi} $.\n\\end{definition}\n\n\\begin{proposition}\n\\label{prop:1.3.7}\nSuppose $ \\Gamma $ is a consistent set of $ L $-formulas and $ \\Gamma \\not\\vdash_L \\phi $. Then $ \\Gamma \\cup \\cb{\\notb{\\phi}} $ is consistent.\n\\end{proposition}\n\n\\begin{proof}\nSuppose not. So there is some formula $ \\psi $ with\n\\begin{equation}\n\\label{eq:3}\n\\Gamma \\cup \\cb{\\notb{\\phi}} \\vdash_L \\psi,\n\\end{equation}\nand\n\\begin{equation}\n\\label{eq:4}\n\\Gamma \\cup \\cb{\\notb{\\phi}} \\vdash_L \\notb{\\psi}.\n\\end{equation}\nApply deduction theorem to $ \\rb{\\ref{eq:4}} $, $ \\Gamma \\vdash_L \\impb{\\notb{\\phi}}{\\notb{\\psi}} $. By A3 and MP we obtain $ \\Gamma \\vdash_L \\impb{\\psi}{\\phi} $. By this, $ \\rb{\\ref{eq:3}} $, and MP, $ \\Gamma \\cup \\cb{\\notb{\\phi}} \\vdash_L \\phi $. By deduction theorem, $ \\Gamma \\vdash_L \\impb{\\notb{\\phi}}{\\phi} $. By \\ref{prop:1.2.7}(3), $ \\vdash_L \\impb{\\impb{\\notb{\\phi}}{\\phi}}{\\phi} $. So by these and MP, $ \\Gamma \\vdash_L \\phi $. This contradicts $ \\Gamma \\not\\vdash_L \\phi $.\n\\end{proof}\n\n\\begin{proposition}[Lindenbaum's lemma]\n\\label{prop:1.3.8}\nSuppose $ \\Gamma $ is a consistent set of $ L $-formulas. Then there is a consistent set of formulas $ \\Gamma^* \\supseteq \\Gamma $ such that for every $ \\phi $ either $ \\Gamma^* \\vdash_L \\phi $ or $ \\Gamma^* \\vdash_L \\notb{\\phi} $.\n\\end{proposition}\n\nSometimes say $ \\Gamma^* $ is \\textbf{complete}.\n\n\\begin{proof}\nThe set of $ L $-formulas is countable, so we can list the $ L $-formulas as $ \\phi_0, \\phi_1, \\dots $. It is countable because the alphabet $ \\neg, \\rightarrow, ), (, p_1, p_2, \\dots $ is countable, and the formulas are finite sequences from this alphabet. Define inductively sets of formulas $ \\Gamma_0 \\subseteq \\Gamma_1 \\subseteq \\dots $ where $ \\Gamma_0 = \\Gamma $ and $ \\Gamma^* = \\cup_{i \\in \\N} \\Gamma_i $. Suppose $ \\Gamma_n $ has been defined. If $ \\Gamma_n \\vdash_L \\phi_n $ then let $ \\Gamma_{n + 1} = \\Gamma_n $. If $ \\Gamma_n \\not\\vdash_L \\phi_n $ then let $ \\Gamma_{n + 1} = \\Gamma_n \\cup \\cb{\\notb{\\phi_n}} $. An easy induction using \\ref{prop:1.3.7} shows that each $ \\Gamma_i $ is consistent. Claim that $ \\Gamma^* $ is consistent. If $ \\Gamma^* \\vdash_L \\phi $ and $ \\Gamma^* \\vdash_L \\notb{\\phi} $ then as deductions are finite sequence of formulas, $ \\Gamma_n \\vdash_L \\phi $ and $ \\Gamma_n \\vdash_L \\notb{\\phi} $ for some $ n \\in \\N $, a contradiction. Let $ \\phi $ be any formula. So $ \\phi = \\phi_n $ for some $ n $. If $ \\Gamma^* \\not\\vdash_L \\phi $ then $ \\Gamma_n \\not\\vdash_L \\phi $. So by construction $ \\Gamma_{n + 1} \\vdash_L \\notb{\\phi} $ as $ \\notb{\\phi} = \\notb{\\phi_n} \\in \\Gamma_{n + 1} $. Thus $ \\Gamma^* \\vdash_L \\notb{\\phi} $.\n\\end{proof}\n\n\\marginpar{Lecture 6 \\\\ Monday \\\\ 15/10/18}\n\n\\begin{lemma}\n\\label{lem:1.3.9}\nLet $ \\Gamma^* $ be as above. Then there is a valuation $ v $ such that for every $ L $-formula $ \\phi $, $ v\\rb{\\phi} = T $ iff $ \\Gamma^* \\vdash_L \\phi $.\n\\end{lemma}\n\n\\begin{corollary}\n\\label{cor:1.3.10}\nSuppose $ \\Delta $ is a set of $ L $-formulas which is consistent and $ \\Delta \\not\\vdash_L \\phi $. Then there is a valuation $ v $ with $ v\\rb{\\Delta} = T $ and $ v\\rb{\\phi} = F $.\n\\end{corollary}\n\n\\begin{proof}\nLet $ \\Gamma = \\Delta \\cup \\cb{\\notb{\\phi}} $. By \\ref{prop:1.3.7}, $ \\Gamma $ is consistent. By \\ref{prop:1.3.8} there is $ \\Gamma^* \\supseteq \\Gamma $ which is still consistent and such that for every $ \\chi $ either $ \\Gamma^* \\vdash_L \\chi $ or $ \\Gamma^* \\vdash_L \\notb{\\chi} $. By \\ref{lem:1.3.9} there is a valuation $ v $ with $ v\\rb{\\Gamma^*} = T $. In particular $ v\\rb{\\Delta} = T $ and $ v\\rb{\\notb{\\phi}} = T $. So $ v\\rb{\\phi} = F $.\n\\end{proof}\n\n\\begin{proof}[Proof of \\ref{thm:1.3.4}]\nSuppose $ \\not\\vdash_L \\phi $. Apply \\ref{cor:1.3.10} with $ \\Delta = \\emptyset $. This is consistent due to the Soundness theorem. There is a valuation $ v $ with $ v\\rb{\\phi} = F $.\n\\end{proof}\n\n\\begin{proof}[Proof of \\ref{lem:1.3.9}]\nLet $ \\Gamma^* $ be a consistent set of $ L $-formulas such that for every $ L $-formula $ \\phi $ either $ \\Gamma^* \\vdash_L \\phi $ or $ \\Gamma^* \\vdash_L \\notb{\\phi} $. Want a valuation $ v $ with $ v\\rb{\\phi} = T $ for all $ \\phi \\in \\Gamma^* $, that is $ v\\rb{\\phi} = T $ iff $ \\Gamma^* \\vdash_L \\phi $. Note that for each variable $ p_i $ either $ \\Gamma^* \\vdash_L p_i $ or $ \\Gamma^* \\vdash_L \\notb{p_i} $. So let $ v $ be the valuation with $ v\\rb{p_i} = T $ iff $ \\Gamma^* \\vdash_L p_i $. Prove by induction on the length of $ \\phi $ that $ v\\rb{\\phi} = T $ iff $ \\Gamma^* \\vdash_L \\phi $. Base case for $ \\phi $ is just a propositional variable. This case is by definition of $ v $. Inductive step is the following.\n\\begin{enumerate}\n\\item Assume that $ \\phi $ is $ \\notb{\\psi} $.\n\\begin{itemize}\n\\item[$ \\implies $] $ v\\rb{\\phi} = T $ gives $ v\\rb{\\psi} = F $ since $ v $ is a valuation. By inductive hypothesis, $ \\Gamma^* \\not\\vdash_L \\psi $. Then Lindenbaum property gives $ \\Gamma^* \\vdash_L \\notb{\\psi} $, that is $ \\Gamma^* \\vdash_L \\phi $.\n\\item[$ \\impliedby $] Conversely suppose $ \\Gamma^* \\vdash_L \\phi $. By consistency $ \\Gamma^* \\not\\vdash_L \\psi $. By inductive hypothesis, $ v\\rb{\\psi} = F $. As $ v $ is a valuation we obtain $ v\\rb{\\notb{\\psi}} = T $, that is $ v\\rb{\\phi} = T $.\n\\end{itemize}\n\\item Assume that $ \\phi $ is $ \\impb{\\psi}{\\chi} $.\n\\begin{itemize}\n\\item[$ \\impliedby $] Suppose $ v\\rb{\\phi} = F $. Show $ \\Gamma^* \\not\\vdash_L \\phi $. Then $ v\\rb{\\psi} = T $ and $ v\\rb{\\chi} = F $. By inductive hypothesis, $ \\Gamma^* \\vdash_L \\psi $ and $ \\Gamma^* \\not\\vdash_L \\chi $. If $ \\Gamma^* \\vdash_L \\phi $ then using $ \\Gamma^* \\vdash_L \\psi $ and MP we get $ \\Gamma^* \\vdash_L \\chi $, which is a contradiction. So $ \\Gamma^* \\not\\vdash_L \\phi $.\n\\item[$ \\implies $] Suppose $ \\Gamma^* \\not\\vdash_L \\phi $, that is $ \\Gamma^* \\not\\vdash_L \\impb{\\psi}{\\chi} $. Then $ \\Gamma^* \\not\\vdash_L \\chi $ as $ \\vdash_L \\impb{\\chi}{\\impb{\\psi}{\\chi}} $. Also $ \\Gamma^* \\not\\vdash_L \\notb{\\psi} $ as $ \\vdash_L \\impb{\\notb{\\psi}}{\\impb{\\psi}{\\chi}} $ by \\ref{prop:1.2.7}(1). By inductive hypothesis, $ v\\rb{\\chi} = F $ and $ v\\rb{\\notb{\\psi}} = F $ so $ v\\rb{\\psi} = T $. Thus $ v\\rb{\\phi} = F $, which does the inductive step.\n\\end{itemize}\n\\end{enumerate}\n\\end{proof}\n\n\\begin{corollary}\n\\label{cor:1.3.12}\nSuppose $ \\Delta $ is a set of $ L $-formulas and $ \\phi $ is an $ L $-formula. Then\n\\begin{enumerate}\n\\item $ \\Delta $ is consistent iff there is a valuation $ v $ with $ v\\rb{\\Delta} = T $, and\n\\item $ \\Delta \\vdash_L \\phi $ iff for every valuation $ v $ with $ v\\rb{\\Delta} = T $ we have $ v\\rb{\\phi} = T $.\n\\end{enumerate}\n\\end{corollary}\n\n\\begin{proof}\nTODO Exercise: deduce these from the preliminaries to Completeness theorem - warning that in 2 do not assume that $ \\Delta $ is consistent.\n\\end{proof}\n\n\\begin{theorem}[Compactness theorem for $ L $]\nSuppose $ \\Delta $ is a set of $ L $-formulas. The following are equivalent.\n\\begin{enumerate}\n\\item There is a valuation $ v $ with $ v\\rb{\\Delta} = T $.\n\\item For every finite subset $ \\Delta_0 \\subseteq \\Delta $ there is a valuation $ w $ with $ w\\rb{\\Delta_0} = T $.\n\\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\nBy \\ref{cor:1.3.12} 1 holds iff $ \\Delta $ is consistent. Similarly 2 holds iff every finite subset of $ \\Delta $ is consistent. But if $ \\Delta \\vdash_L \\psi $ and $ \\Delta \\vdash_L \\notb{\\psi} $ then as deductions are finite and therefore only involve finitely many formulas in $ \\Delta $, for some finite $ \\Delta_0 \\subseteq \\Delta $, $ \\Delta_0 \\vdash_L \\psi $ and $ \\Delta_0 \\vdash_L \\notb{\\psi} $.\n\\end{proof}\n\nLet $ P $ be the set of sequences of $ \\cb{T, F} $, that is the set of functions $ f : \\N \\to \\cb{T, F} $. Topologise with basic open sets. For $ a_1, \\dots, a_n \\in \\cb{T, F} $ consider $ O\\rb{a_1, \\dots, a_n} $, all sequences starting $ a_1, \\dots, a_n $. (TODO Exercise: use Compactness theorem to prove $ P $ is compact)\n\n\\marginpar{Lecture 7 \\\\ Thursday \\\\ 18/10/18}\n\nLecture 7 is a problem class.\n\n\\marginpar{Lecture 8 \\\\ Friday \\\\ 19/10/18}\n\n\\section{Predicate logic}\n\nPredicate logic is first-order logic. Plan is the following.\n\\begin{enumerate}\n\\item Introduce the mathematical objects, first-order structures.\n\\item Introduce the formulas, first-order languages.\n\\item Describe a formal system.\n\\item Show that its theorems are precisely the formulas true in all structures. This is Gödel's completeness theorem.\n\\end{enumerate}\n$ 1 $ and $ 2 $ are semantics while $ 3 $ and $ 4 $ are syntax.\n\n\\subsection{Structures}\n\n\\begin{definition}\nSuppose $ A $ is a set and $ n \\ge 1 $ and $ n \\in \\N $. An \\textbf{$ n $-ary relation} on $ A $ is a subset $ \\bar{R} \\subseteq A^n = \\cb{\\rb{a_1, \\dots, a_n} \\mid a_i \\in A} $ of $ n $-tuples. An \\textbf{$ n $-ary function} on $ A $ is a function $ \\bar{f} : A^n \\to A $.\n\\end{definition}\n\n\\begin{example}\n\\hfill\n\\begin{enumerate}\n\\item Ordering $ \\le $ on $ \\R $ is a binary relation on $ \\R $.\n\\item $ + $ on $ \\C $ is a binary function on $ \\C $.\n\\item Even integers as a subset of $ \\Z $ is a unary relation on $ \\Z $.\n\\end{enumerate}\n\\end{example}\n\nIf $ \\bar{R} \\subseteq A^n $ is an $ n $-ary relation and $ a_1, \\dots, a_n \\in A $, write $ \\bar{R}\\rb{a_1, \\dots, a_n} $ to mean $ \\rb{a_1, \\dots, a_n} \\in \\bar{R} $.\n\n\\begin{definition}\nA \\textbf{first-order structure} $ \\mathcal{A} $ consists of\n\\begin{enumerate}\n\\item a non-empty set $ A $, the \\textbf{domain} of $ \\mathcal{A} $,\n\\item a set $ \\cb{\\bar{R_i} \\mid i \\in I} $ of relations on $ A $ for $ \\bar{R_i} \\subseteq A^{n_i} $,\n\\item a set $ \\cb{\\bar{f_j} \\mid j \\in J} $ of functions on $ A $ for $ \\bar{f_j} : A^{m_j} \\to A $, and\n\\item a set $ \\cb{\\bar{c_k} \\mid k \\in K} $ of \\textbf{constants}, just elements of $ A $.\n\\end{enumerate}\nThe sets $ I, J, K $ are indexing sets and can be empty. Usually subsets of $ \\N $. The information $ \\rb{n_i \\mid i \\in I} $, $ \\rb{m_j \\mid j \\in J} $, and the set $ K $ is called the \\textbf{signature} of $ \\mathcal{A} $. Might denote the structure by\n$$ \\mathcal{A} = \\ab{A; \\rb{\\bar{R_i} \\mid i \\in I}, \\rb{\\bar{f_j} \\mid j \\in J}, \\rb{\\bar{c_k} \\mid k \\in K}}. $$\n\\end{definition}\n\n\\begin{example}\n\\hfill\n\\begin{enumerate}\n\\item Orderings on $ A = \\N, \\Z, \\Q, \\R $ where\n$$ I = \\cb{1}, \\qquad J = \\emptyset, \\qquad K = \\emptyset, \\qquad \\bar{R_1}\\rb{a_1, a_2} \\iff a_1 < a_2. $$\n\\item Groups.\n\\begin{enumerate}\n\\item $ \\bar{R} $, the binary relation for equality,\n\\item $ \\bar{m} $, the binary function for multiplication,\n\\item $ \\bar{i} $, the unary function for inversion, and\n\\item $ \\bar{e} $, the constant for identity element.\n\\end{enumerate}\n\\item Rings.\n\\begin{enumerate}\n\\item $ \\bar{R} $, the binary relation for equality,\n\\item $ \\bar{m} $, the binary function for multiplication,\n\\item $ \\bar{a} $, the binary function for addition,\n\\item $ \\bar{n} $, the binary function for negation,\n\\item $ \\bar{0} $, the constant for zero, and\n\\item $ \\bar{1} $, the constant for one.\n\\end{enumerate}\n\\item Graphs.\n\\begin{enumerate}\n\\item $ \\bar{R} $, the binary relation for equality, and\n\\item $ \\bar{E} $, the binary relation for adjacency.\n\\end{enumerate}\n\\end{enumerate}\n\\end{example}\n\n\\subsection{First-order languages}\n\n\\begin{definition}\n\\label{def:2.2.1}\nA \\textbf{first-order language} $ \\mathcal{L} $ has an alphabet of symbols of the following types.\n\\begin{enumerate}\n\\item Variables $ x_0, x_1, \\dots $.\n\\item Punctuation $ ( $, $ ) $, $ , $.\n\\item Connectives $ \\neg $, $ \\rightarrow $.\n\\item \\textbf{Quantifier} $ \\forall $.\n\\item Relation symbols $ R_i $ for $ i \\in I $.\n\\item Function symbols $ f_j $ for $ j \\in J $.\n\\item Constant symbols $ c_k $ for $ k \\in K $.\n\\end{enumerate}\nHere $ I, J, K $ are indexing sets and could have $ J, K = \\emptyset $. Each $ R_i $ comes equipped with an \\textbf{arity} $ n_i $. Each $ f_j $ comes equipped with an arity $ m_j $. The information $ \\rb{n_i \\mid i \\in I} $, $ \\rb{m_j \\mid j \\in J} $, $ K $ is called the signature of $ \\mathcal{L} $. A first-order structure $ \\mathcal{A} $ with the same signature as $ \\mathcal{L} $ is referred to as an $ \\mathcal{L} $-structure.\n\\end{definition}\n\n\\begin{definition}\nA \\textbf{term} of $ \\mathcal{L} $ is defined as follows.\n\\begin{enumerate}\n\\item Any variable is a term.\n\\item Any constant symbol is a term.\n\\item If $ f $ is an $ m $-ary function symbol of $ \\mathcal{L} $ and $ t_1, \\dots, t_m $ are terms, then $ f\\rb{t_1, \\dots, t_m} $ is also a term.\n\\item Any term arises in this way.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{example}\nSuppose $ \\mathcal{L} $ has a binary function symbol $ f $ and constant symbols $ c_1, c_2 $. Some terms are\n$$ c_1, \\qquad c_2, \\qquad x_1, \\qquad f\\rb{c_1, x_1}, \\qquad f\\rb{f\\rb{c_1, x_2}, c_2}, \\qquad f\\rb{x_1, f\\rb{f\\rb{c_1, x_2}, c_2}}. $$\nSome not terms are\n$$ ffx_1 \\quad \\rb{\\text{not well-formed}}. $$\n\\end{example}\n\n\\marginpar{Lecture 9 \\\\ Monday \\\\ 22/10/18}\n\n\\begin{definition}\n\\hfill\n\\begin{enumerate}\n\\item An \\textbf{atomic formula} of $ \\mathcal{L} $ is of the form $ R\\rb{t_1, \\dots, t_n} $ where $ R $ is an $ n $-ary relation symbol of $ \\mathcal{L} $ and $ t_1, \\dots, t_n $ are terms.\n\\item The \\textbf{formulas} of $ \\mathcal{L} $ are defined as follows.\n\\begin{enumerate}\n\\item Any atomic formula is a formula.\n\\item If $ \\phi, \\psi $ are $ \\mathcal{L} $-formulas then $ \\notb{\\phi} $, $ \\impb{\\phi}{\\psi} $, $ \\fab{x}\\phi $ are $ \\mathcal{L} $-formulas, where $ x $ is any variable.\n\\item Every $ \\mathcal{L} $-formula arises in this way.\n\\end{enumerate}\n\\end{enumerate}\n\\end{definition}\n\n\\begin{example}\nSuppose $ \\mathcal{L} $ has a binary function symbol $ f $, a unary relation symbol $ P $, a binary relation symbol $ R $, and constant symbols $ c_1, c_2 $. Some terms are\n$$ x_1, \\qquad c_1, \\qquad f\\rb{x_1, c_1}, \\qquad f\\rb{f\\rb{x_1, c_1}, x_2}. $$\nSome atomic formulas are\n$$ P\\rb{x_1}, \\qquad R\\rb{f\\rb{x_1, c_1}, x_2}. $$\nSome formulas are\n$$ \\fab{x_1}\\impb{R\\rb{f\\rb{x_1, c_1}, x_2}}{P\\rb{x_1}}. $$\n\\end{example}\n\n\\begin{definition}\nSuppose $ \\phi, \\psi $ are $ \\mathcal{L} $-formulas. $ \\teb{x}\\phi $ means $ \\notb{\\fab{x}\\notb{\\phi}} $. $ \\orb{\\phi}{\\psi} $ means $ \\impb{\\notb{\\phi}}{\\psi} $, etc as in propositional logic.\n\\end{definition}\n\n\\begin{definition}\nSuppose $ \\mathcal{L} $ is a first-order language with relation symbols $ R_i $ of arity $ n_i $ for $ i \\in I $, function symbols $ f_j $ of arity $ m_j $ for $ j \\in J $, and constant symbols $ c_k $ for $ k \\in K $. An \\textbf{$ \\mathcal{L} $-structure} is a structure\n$$ \\mathcal{A} = \\ab{A; \\rb{\\bar{R_i} \\mid i \\in I}, \\rb{\\bar{f_j} \\mid j \\in J}, \\rb{\\bar{c_k} \\mid k \\in K}} $$\nof the same signature as $ \\mathcal{L} $.\n\\end{definition}\n\nThere is a correspondence between the relation, function, and constant symbols of $ \\mathcal{L} $ and the actual relations, functions, and constants in $ \\mathcal{A} $, and the arities match up. This correspondence, or $ \\mathcal{A} $, is called an \\textbf{interpretation} of $ \\mathcal{L} $.\n\n\\begin{definition}\nWith the same notation, suppose $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure. A \\textbf{valuation} in $ \\mathcal{A} $ is a function $ v $ from the set of terms of $ \\mathcal{L} $ to $ A $ satisfying\n\\begin{enumerate}\n\\item $ v\\rb{c_k} = \\bar{c_k} $, and\n\\item if $ t_1, \\dots, t_m $ are terms of $ \\mathcal{L} $ and $ f $ is an $ m $-ary function symbol then\n$$ v\\rb{f\\rb{t_1, \\dots, t_m}} = \\bar{f}\\rb{v\\rb{t_1}, \\dots, v\\rb{t_m}}, $$\nwhere $ \\bar{f} $ is the interpretation of $ f $ in $ \\mathcal{A} $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{lemma}\nSuppose $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure and $ a_0, a_1, \\dots \\in A $. Then there is a unique valuation $ v $ in $ \\mathcal{A} $ with $ v\\rb{x_l} = a_l $ for all $ l \\in \\N $, where the variables of $ \\mathcal{L} $ are $ x_0, x_1, \\dots $.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the length of terms. Show that if we let\n\\begin{enumerate}\n\\item $ v\\rb{x_l} = a_l $ for all $ l \\in \\N $,\n\\item $ v\\rb{c_k} = \\bar{c_k} $ for all $ k \\in K $, and\n\\item $ v\\rb{f\\rb{t_1, \\dots, t_m}} = \\bar{f}\\rb{v\\rb{t_1}, \\dots, v\\rb{t_m}} $,\n\\end{enumerate}\nthen $ v $ is a well-defined valuation.\n\\end{proof}\n\n\\begin{example}\nGroups with signature of\n\\begin{enumerate}\n\\item binary relation symbol $ R $ for equality,\n\\item binary function symbol $ m $ for multiplication,\n\\item unary function symbol $ i $ for inversion, and\n\\item constant $ e $ for identity element.\n\\end{enumerate}\nLet $ G $ be a group and $ g, h \\in G $. Let $ v $ be a valuation with $ v\\rb{x_0} = g $ and $ v\\rb{x_1} = h $. Then\n$$ v\\rb{m\\rb{m\\rb{x_0, x_1}, i\\rb{x_0}}} = \\bar{m}\\rb{v\\rb{m\\rb{x_0, x_1}}, v\\rb{i\\rb{x_0}}} = \\bar{m}\\rb{v\\rb{x_0}, v\\rb{x_1}}\\bar{i}\\rb{v\\rb{x_0}} = ghg^{-1}. $$\n\\end{example}\n\n\\begin{definition}\nSuppose $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure and $ x_l $ is any variable. Suppose $ v, w $ are valuations in $ \\mathcal{A} $. We say $ v, w $ are $ x_l $-equivalent if $ v\\rb{x_m} = w\\rb{x_m} $ whenever $ m \\ne l $.\n\\end{definition}\n\n\\begin{definition}\n\\label{def:2.2.9}\nSuppose $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure and $ v $ is a valuation in $ \\mathcal{A} $. Define, for an $ \\mathcal{L} $-formula $ \\phi $, what is meant by $ v $ \\textbf{satisfies} $ \\phi $ in $ \\mathcal{A} $ by the following.\n\\begin{enumerate}\n\\item Suppose $ R $ is an $ n $-ary relation symbol and $ t_1, \\dots, t_n $ are terms of $ \\mathcal{L} $. Then $ v $ satisfies the atomic formula $ R\\rb{t_1, \\dots, t_n} $ iff $ \\bar{R}\\rb{v\\rb{t_1}, \\dots, v\\rb{t_n}} $ holds in $ \\mathcal{A} $.\n\\item Suppose $ \\phi, \\psi $ are $ \\mathcal{L} $-formulas and we already know about valuations satisfying $ \\phi, \\psi $.\n\\begin{enumerate}\n\\item $ v $ satisfies $ \\notb{\\phi} $ in $ \\mathcal{A} $ iff $ v $ does not satisfy $ \\phi $ in $ \\mathcal{A} $.\n\\item $ v $ satisfies $ \\impb{\\phi}{\\psi} $ in $ \\mathcal{A} $ iff it is not the case that $ v $ satisfies $ \\phi $ in $ \\mathcal{A} $ and $ v $ does not satisfy $ \\psi $ in $ \\mathcal{A} $.\n\\item $ v $ satisfies $ \\fab{x_l}\\phi $ in $ \\mathcal{A} $ iff whenever $ w $ is a valuation in $ \\mathcal{A} $ which is $ x_l $-equivalent to $ v $, then $ w $ satisfies $ \\phi $ in $ \\mathcal{A} $.\n\\end{enumerate}\n\\end{enumerate}\n\\end{definition}\n\n\\marginpar{Lecture 10 \\\\ Thursday \\\\ 25/10/18}\n\n\\begin{remark}\n\\ref{def:2.2.9} does not work if we allow empty structure.\n\\end{remark}\n\nIf $ v $ satisfies $ \\phi $, write $ v\\sb{\\phi} = T $. If $ v $ does not satisfy $ \\phi $, write $ v\\sb{\\phi} = F $. If every valuation in $ \\mathcal{A} $ satisfies $ \\phi $, say that $ \\phi $ is \\textbf{true} in $ \\mathcal{A} $ or $ \\mathcal{A} $ is a \\textbf{model} of $ \\phi $ and write $ \\mathcal{A} \\vDash \\phi $. If $ \\mathcal{A} \\vDash \\phi $ for every $ \\mathcal{L} $-structure $ \\mathcal{A} $, we say that $ \\phi $ is \\textbf{logically valid} and write $ \\vDash \\phi $. These are the analogues of tautologies in the propositional logic. Difference is in propositional logic there is an algorithm to decide whether a given formula is a tautology. There is no such algorithm to decide whether a given $ \\mathcal{L} $-formula is logically valid or not, a consequence of Gödel's incompleteness theorem.\n\n\\begin{example}\n\\hfill\n\\begin{enumerate}\n\\item Suppose $ \\mathcal{L} $ has a binary relation symbol $ R $. The $ \\mathcal{L} $-formula $ \\impb{R\\rb{x_1, x_2}}{\\impb{R\\rb{x_2, x_3}}{R\\rb{x_1, x_3}}} $ is true in $ \\mathcal{A} = \\ab{\\N; <} $, where $ R $ is interpreted as $ < $. If not, there is a valuation $ v $ in $ \\mathcal{A} $ such that $ v $ satisfies $ R\\rb{x_1, x_2} $ or $ v $ does not satisfy $ \\impb{R\\rb{x_2, x_3}}{R\\rb{x_1, x_3}} $. So $ v\\sb{R\\rb{x_2, x_3}} = T $ and $ v\\sb{R\\rb{x_1, x_3}} = F $. Let $ v\\rb{x_i} = a_i \\in \\N $. So $ a_1 < a_2 $, $ a_2 < a_3 $, and $ a_1 \\not< a_3 $. As $ < $ is transitive on $ \\N $, this is a contradiction.\n\\item The same formula is not true in the structure $ \\mathcal{B} $ with domain $ \\N $ where we interpret $ R\\rb{x_i, x_j} $ as $ x_i \\ne x_j $. Take a valuation in $ \\mathcal{B} $ with $ v\\rb{x_1} = 1 = v\\rb{x_3} $ and $ v\\rb{x_2} = 2 $. $ v $ does not satisfy the formula in $ \\mathcal{B} $.\n\\item Recall that $ \\teb{x_1}\\phi $ is an abbreviation for $ \\notb{\\fab{x_1}\\notb{\\phi}} $. Suppose $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure and $ \\phi $ an $ \\mathcal{L} $-formula. Let $ v $ be a valuation in $ \\mathcal{A} $. Then $ v $ satisfies $ \\teb{x_1}\\phi $ in $ \\mathcal{A} $ iff there is a valuation $ w $ which is $ x_1 $-equivalent to $ v $ such that $ w $ satisfies $ \\phi $. Suppose $ v $ satisfies $ \\notb{\\fab{x_1}\\notb{\\phi}} $. Using \\ref{def:2.2.9} $ v $ does not satisfy $ \\fab{x_1}\\notb{\\phi} $. So there is valuation $ w $ $ x_1 $-equivalent to $ v $ such that $ w $ does not satisfy $ \\notb{\\phi} $. Such a $ w $ satisfies $ \\phi $. (TODO Exercise: converse)\n\\end{enumerate}\n\\end{example}\n\n\\begin{example}\n$ \\fab{x_1}\\teb{x_2}R\\rb{x_1, x_2} $ is true in $ \\ab{\\Z; <} $ and $ \\ab{\\N; <} $ but not in $ \\ab{\\N; >} $.\n\\end{example}\n\nTODO Exercise: Suppose $ \\phi $ is any $ \\mathcal{L} $-formula. Then\n\\begin{enumerate}\n\\item $ \\impb{\\teb{x_1}\\fab{x_2}\\phi}{\\fab{x_2}\\teb{x_1}\\phi} $ is logically valid, and\n\\item $ \\impb{\\fab{x_2}\\teb{x_1}\\phi}{\\teb{x_1}\\fab{x_2}\\phi} $ is not necessarily logically valid.\n\\end{enumerate}\n\nConsider the propositional formula $ \\chi $ by $ \\impb{p_1}{\\impb{p_2}{p_1}} $. Suppose $ \\mathcal{L} $ is a first-order language and $ \\phi_1, \\phi_2 $ are $ \\mathcal{L} $-formulas. Substitute $ \\phi_1 $ in place of $ p_1 $ and $ \\phi_2 $ in place of $ p_2 $ in $ \\chi $. We obtain an $ \\mathcal{L} $-formula $ \\theta $ by $ \\impb{\\phi_1}{\\impb{\\phi_2}{\\phi_1}} $. Check that as $ \\chi $ is a tautology $ \\theta $ is logically valid. (TODO Exercise)\n\n\\begin{definition}\nSuppose $ \\chi $ is an $ \\mathcal{L} $-formula involving propositional variables $ p_1, \\dots, p_n $. Suppose $ \\mathcal{L} $ is a first-order language and $ \\phi_1, \\dots, \\phi_n $ are $ \\mathcal{L} $-formulas. A \\textbf{substitution instance} of $ \\chi $ is obtained by replacing each $ p_i $ in $ \\chi $ by $ \\phi_i $ for $ i = 1, \\dots, n $. Call the result $ \\theta $.\n\\end{definition}\n\n\\begin{theorem}\n\\hfill\n\\begin{enumerate}\n\\item $ \\theta $ is an $ \\mathcal{L} $-formula, and\n\\item if $ \\chi $ is a tautology then $ \\theta $ is logically valid.\n\\end{enumerate}\n\\end{theorem}\n\n\\marginpar{Lecture 11 \\\\ Friday \\\\ 26/10/18}\n\n\\begin{proof}\nTake an $ \\mathcal{L} $-structure $ \\mathcal{A} $ and a valuation $ v $ in $ \\mathcal{A} $. Use this to define a propositional valuation $ w $ with $ w\\rb{p_i} = v\\sb{\\phi_i} $ for $ i \\le n $. Then prove by induction on the number of connectives in $ \\chi $ that $ w\\rb{\\chi} = v\\sb{\\theta} $. In particular if $ \\chi $ is a tautology, then $ v\\sb{\\theta} = T $. In the inductive step, consider $ \\chi $ is $ \\impb{\\alpha}{\\beta} $. So $ \\theta $ is $ \\impb{\\theta_1}{\\theta_2} $ where $ \\theta_1 $ is obtained from $ \\alpha $ and $ \\theta_2 $ is obtained from $ \\beta $. By inductive hypothesis $ w\\rb{\\alpha} = v\\sb{\\theta_1} $ and $ w\\rb{\\beta} = v\\sb{\\theta_2} $. So $ w\\impb{\\alpha}{\\beta} = v\\sb{\\impb{\\theta_1}{\\theta_2}} $, etc. (TODO Exercise)\n\\end{proof}\n\n\\begin{note}\nNot all logically valid formulas arise in this way.\n\\end{note}\n\n\\begin{example}\n$ \\impb{\\teb{x_2}\\fab{x_1}\\phi}{\\fab{x_1}\\teb{x_2}\\phi} $.\n\\end{example}\n\n\\subsection{Bound and free variables in formulas}\n\n\\begin{definition}\nSuppose $ \\phi, \\psi $ are $ \\mathcal{L} $-formulas and $ \\fab{x_i}\\phi $ occurs as a subformula of $ \\psi $, that is $ \\psi $ is $ \\dots \\fab{x_i}\\phi \\dots $. We say that $ \\phi $ is the \\textbf{scope} of that quantifier $ \\fab{x_i} $ here in $ \\psi $. An occurrence of a variable $ x_j $ in $ \\psi $ is \\textbf{bound} if it is in the scope of a quantifier $ \\fab{x_j} $ in $ \\psi $, or it is the $ x_j $ here. Otherwise it is a free occurrence of $ x_j $. Variables having a free occurrence in $ \\psi $ are called \\textbf{free} variables of $ \\psi $. A formula with no free variables is called a \\textbf{closed} formula or a \\textbf{sentence} of $ \\mathcal{L} $.\n\\end{definition}\n\n\\begin{example}\n\\hfill\n\\begin{enumerate}\n\\item Let $ \\psi_1 $ be $ \\impb{R_1\\rb{x_1, x_2}}{\\fab{x_3}R_2\\rb{x_1, x_3}} $. Then $ x_1 $ and $ x_2 $ are free, and $ x_3 $ is bound with scope $ R_2\\rb{x_1, x_3} $.\n\\item Let $ \\psi_2 $ be $ \\impb{\\fab{x_1}R_1\\rb{x_1, x_2}}{R_2\\rb{x_1, x_2}} $. Then the first $ x_1 $ is bound with scope $ R_1\\rb{x_1, x_2} $, and the second $ x_1 $ and $ x_2 $ are free. Compare with $ \\fab{x_1}\\impb{R_1\\rb{x_1, x_2}}{R_2\\rb{x_1, x_2}} $. Then $ x_1 $ is bound with scope $ \\impb{R_1\\rb{x_1, x_2}}{R_2\\rb{x_1, x_2}} $, and $ x_2 $ is free.\n\\item Let $ \\psi_3 $ be $ \\impb{\\teb{x_1}R_1\\rb{x_1, x_2}}{\\fab{x_2}R_2\\rb{x_2, x_3}} $. Then $ x_1 $ and the second $ x_2 $ are bound with scope $ R_1\\rb{x_1, x_2} $, and the first $ x_2 $ and $ x_3 $ are free.\n\\end{enumerate}\n\\end{example}\n\n\\begin{definition}\nIf $ \\psi $ is an $ \\mathcal{L} $-formula with free variables amongst $ x_1, \\dots, x_n $, we might write $ \\psi\\rb{x_1, \\dots, x_n} $ instead of $ \\psi $. If $ t_1, \\dots, t_n $ are terms, by $ \\psi\\rb{t_1, \\dots, t_n} $ we mean the $ \\mathcal{L} $-formula obtained by replacing each free occurrence of $ x_i $ in $ \\psi $ by $ t_i $.\n\\end{definition}\n\n\\begin{example}\nLet $ \\psi\\rb{x_1, x_2} $ be $ \\impb{\\fab{x_1}R\\rb{x_1, x_2}}{\\fab{x_3}R\\rb{x_1, x_2, x_3}} $, $ t_1 $ be $ f_1\\rb{x_1} $, and $ t_2 $ be $ f_2\\rb{x_1, x_2} $. Then $ x_2 $ and the second $ x_1 $ are free. So $ \\psi\\rb{t_1, t_2} $ is\n$$ \\impb{\\fab{x_1}R_1\\rb{x_1, f_2\\rb{x_1, x_2}}}{\\fab{x_3}R_2\\rb{f_1\\rb{x_1}, f_2\\rb{x_1, x_2}, x_3}}. $$\n\\end{example}\n\n\\begin{theorem}\n\\label{thm:2.3.3}\nSuppose $ \\phi $ is a closed $ \\mathcal{L} $-formula and $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure. Then either $ \\mathcal{A} \\vDash \\phi $ or $ \\mathcal{A} \\vDash \\notb{\\phi} $. More generally, if $ \\phi $ has free variables amongst $ x_1, \\dots, x_n $ and $ v, w $ are valuations in $ \\mathcal{A} $ with $ v\\rb{x_i} = w\\rb{x_i} $ for $ i = 1, \\dots, n $, then $ v\\sb{\\phi} = T $ iff $ w\\sb{\\phi} = T $. Allow $ n = 0 $ here for no free variables.\n\\end{theorem}\n\n\\begin{proof}\nNote that the first statement follows from the generalisation. If $ \\phi $ has no free variables, then for any valuations $ v, w $ in $ \\mathcal{A} $, they agree on the free variables of $ \\phi $ so $ v\\sb{\\phi} = w\\sb{\\phi} $. Prove the generalisation by induction on the number of connectives and quantifiers in $ \\phi $.\n\\begin{enumerate}\n\\item Base case. $ \\phi $ is atomic, so $ \\phi $ is $ R\\rb{t_1, \\dots, t_m} $ for $ t_j $ terms. The $ t_j $ only involve variables amongst $ x_1, \\dots, x_n $. As $ v $ and $ w $ agree on these variables $ v\\rb{t_j} = w\\rb{t_j} $. So\n$$ v\\sb{R\\rb{t_1, \\dots, t_m}} = T \\qquad \\iff \\qquad \\bar{R}\\rb{v\\rb{t_1}, \\dots, v\\rb{t_m}} \\qquad \\iff \\qquad w\\sb{R\\rb{t_1, \\dots, t_m}} = T. $$\n\\item Inductive step. $ \\phi $ is $ \\notb{\\psi} $, $ \\impb{\\psi}{\\chi} $, or $ \\fab{x_i}\\psi $. (TODO Exercise: first two cases) Suppose $ \\phi $ is $ \\fab{x_i}\\psi $. Suppose $ v\\sb{\\phi} = F $. By \\ref{def:2.2.9} there is a valuation $ v' $ $ x_i $-equivalent to $ v $ with $ v'\\sb{\\psi} = F $. The free variables of $ \\psi $ are amongst $ x_1, \\dots, x_n, x_i $. Let $ w' $ be the valuation $ x_i $-equivalent to $ w $ with $ w'\\rb{x_i} = v'\\rb{x_i} $. Then $ v', w' $ agree on the free variables of $ \\psi $. By inductive hypothesis $ v'\\sb{\\psi} = w'\\sb{\\psi} $ so $ w'\\sb{\\psi} = F $. As $ w' $ is $ x_i $-equivalent to $ w $ we obtain $ w\\sb{\\fab{x_i}\\psi} = F $.\n\\end{enumerate}\n\\end{proof}\n\n\\marginpar{Lecture 12 \\\\ Monday \\\\ 29/10/18}\n\n\\begin{remark}\nIf $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure and $ \\psi\\rb{x_1, \\dots, x_n} $ an $ \\mathcal{L} $-formula, whose free variables are amongst $ x_1, \\dots, x_n $, and $ a_1, \\dots, a_n \\in A $ for domain $ A $ then we write $ \\mathcal{A} \\vDash \\psi\\rb{a_1, \\dots, a_n} $ to mean $ v\\sb{\\psi} = T $ for every valuation $ v $ in $ \\mathcal{A} $ with $ v\\rb{x_i} = a_i $ for $ i = 1, \\dots, n $.\n\\end{remark}\n\n\\begin{note}\nBy the proof of \\ref{thm:2.3.3} this holds if $ v\\sb{\\psi} = T $ for some such valuation.\n\\end{note}\n\n\\begin{example}\nAn example where $ \\mathcal{A} \\vDash \\fab{x_1}\\phi\\rb{x_1} $ but we have term $ t $, and a valuation $ v $ in $ \\mathcal{A} $ with $ v\\sb{\\phi\\rb{t}} = F $. Let $ \\phi\\rb{x_1} $ be $ \\impb{\\fab{x_2}R\\rb{x_2, x_2}}{S\\rb{x_1}} $. Scope of $ x_2 $ is $ R\\rb{x_1, x_2} $. Let $ t_1 $ be $ x_2 $, then $ \\phi\\rb{t_1} $ is $ \\impb{\\fab{x_2}R\\rb{x_2, x_2}}{S\\rb{x_2}} $. Suppose $ \\mathcal{A} = \\ab{\\N; \\le, = 0} $. Domain is $ \\N = \\cb{0, 1, \\dots} $, $ R\\rb{x_1, x_2} $ interpreted as $ x_1 \\le x_2 $, and $ S\\rb{x_1} $ interpreted as $ x_1 = 0 $. So $ \\mathcal{A} \\vDash \\fab{x_1}\\phi\\rb{x_1} $ but we choose a valuation $ v\\rb{x_2} = 1 $ then $ v\\sb{\\phi\\rb{t_1}} = F $ in $ \\mathcal{A} $.\n\\end{example}\n\n\\begin{definition}\nLet $ \\phi $ be an $ \\mathcal{L} $-formula, $ x_i $ a variable, $ t $ an $ \\mathcal{L} $-term. We say $ t $ is free for $ x_i $ in $ \\phi $ if there is no variable $ x_j $ in $ t $ such that $ x_i $ has a free occurrence within the scope of a quantifier $ \\fab{x_j} $ in $ \\phi $.\n\\end{definition}\n\nTODO Exercise: Let $ t = f\\rb{x_3, x_2, x_5} $, $ \\phi_1 $ be $ \\impb{\\impb{\\fab{x_2}R\\rb{x_1, x_4}}{K\\rb{x_1}}}{\\fab{x_1}R\\rb{x_1, x_1}} $, and $ \\phi_2 $ be $ \\impb{\\fab{x_2}\\impb{R\\rb{x_2, x_4}}{\\fab{x_1}K\\rb{x_1}}}{\\fab{x_2}R\\rb{x_1, x_1}} $. For which $ t $ is $ t $ free for $ x_1 $?\n\n\\begin{theorem}\n\\label{thm:2.3.6}\nSuppose $ \\phi\\rb{x_1} $ is an $ \\mathcal{L} $-formula, possibly with other free variables. Let $ t $ be a term free for $ x_1 $ in $ \\phi $, then $ \\vDash \\impb{\\fab{x_1}\\phi\\rb{x_1}}{\\phi\\rb{t}} $. In particular, if $ \\mathcal{A} $ is an $ \\mathcal{L} $-structure with $ \\mathcal{A} \\vDash \\fab{x_1}\\phi\\rb{x_1} $ then $ A \\vDash \\phi\\rb{t} $.\n\\end{theorem}\n\n\\begin{lemma}\n\\label{lem:2.3.7}\nWith this notation, suppose $ v $ is a valuation in $ \\mathcal{A} $. Let $ v' $ be the valuation in $ \\mathcal{A} $ which is $ x_1 $-equivalent to $ v $, with $ v'\\rb{x_1} = v\\rb{t} $. Then $ v'\\sb{\\phi\\rb{x_1}} = T $ iff $ v\\sb{\\phi\\rb{t}} = T $.\n\\end{lemma}\n\n\\begin{proof}\nThis is by induction on the number of connectives and quantifiers in $ \\phi $.\n\\begin{enumerate}\n\\item Base case. $ \\phi $ is an atomic formula $ R\\rb{u_1, \\dots, u_m} $ where $ R $ is an $ m $-ary relation symbol and $ u_1, \\dots, u_m $ are terms. Let $ u^*_i $ be the result of substituting $ t $ for $ x_1 $ in $ u_i $. Then, by induction on the length of the terms, each $ u_i^* $ is a term and $ v'\\rb{u_i} = v\\rb{u_i^*} $. Moreover, $ \\phi\\rb{t} $ is $ R\\rb{u_1^*, \\dots, u_m^*} $. Then\n\\begin{align*}\nv'\\sb{\\phi\\rb{x_1}} = T \\qquad\n& \\iff \\qquad \\mathcal{A} \\vDash R\\rb{v'\\rb{u_1}, \\dots, v'\\rb{u_m}} \\\\\n& \\iff \\qquad \\mathcal{A} \\vDash R\\rb{v\\rb{u_1^*}, \\dots, v\\rb{u_m^*}} \\\\\n& \\iff \\qquad v\\sb{\\phi\\rb{t}} = T.\n\\end{align*}\n\\item Inductive step. There are three cases,\n\\begin{enumerate}\n\\item $ \\phi $ is $ \\notb{\\psi} $,\n\\item $ \\phi $ is $ \\impb{\\psi}{\\chi} $, and\n\\item $ \\phi $ is $ \\fab{x_i}\\psi $.\n\\end{enumerate}\nWe leave the first two cases as exercises and do the third. We can assume that $ i \\ne 1 $. Otherwise $ x_1 $ is not free in $ \\phi $ and $ \\phi\\rb{t} $ is just $ \\phi $. The lemma then follows from \\ref{thm:2.3.3}. Note also that as $ t $ is free for $ x_1 $ in $ \\fab{x_i}\\psi $, it follows that $ t $ is free for $ x_1 $ in $ \\psi $ and $ x_i $ is not a variable in $ t $. Suppose first that $ v'\\sb{\\phi\\rb{x_1}} = F $. We show that $ v\\sb{\\phi\\rb{t}} = F $. By \\ref{def:2.2.9}, there is a valuation $ w' $ which is $ x_i $-equivalent to $ v' $ with $ w'\\sb{\\psi\\rb{x_1}} = F $. Note that as $ i \\ne 1 $,\n\\begin{equation}\n\\label{eq:5}\nw'\\rb{x_1} = v'\\rb{x_1} = v\\rb{t}.\n\\end{equation}\nDefine a valuation $ w $ by\n$$ w\\rb{x_j} = \\begin{cases} v\\rb{x_j} & j \\ne 1, i \\\\ w'\\rb{x_i} & j = i \\\\ v\\rb{x_1} & j = 1 \\end{cases}. $$\nSo $ w $ is $ x_1 $-equivalent to $ w' $ and $ x_i $-equivalent to $ v $, noting that $ v, v' $ are $ x_i $-equivalent and $ w, v' $ are $ x_i $-equivalent. As $ x_i $ does not occur in $ t $ we have, by \\ref{thm:2.3.3} and $ \\rb{\\ref{eq:5}} $,\n$$ w\\rb{t} = v\\rb{t} = w'\\rb{x_1}. $$\nWe can now apply the induction hypothesis to $ w $, $ w' $, and $ \\psi $. We obtain that $ w\\sb{\\psi\\rb{t}} = w'\\sb{\\psi\\rb{x_1}} = F $. As $ w, v $ are $ x_i $-equivalent, it follows that\n$$ v\\sb{\\fab{x_i}\\psi\\rb{t}} = F. $$\nSo $ v\\sb{\\phi\\rb{t}} = F $, as required. We now prove the converse direction. We cannot argue by symmetry here. So suppose $ v\\sb{\\phi\\rb{t}} = F $. There is a valuation $ w $ which is $ x_i $-equivalent to $ v $ with $ w\\sb{\\psi\\rb{t}} = F $. Let $ w' $ be the valuation $ x_1 $-equivalent to $ w $ with\n$$ w'\\rb{x_1} = w\\rb{t} = v\\rb{t} = v'\\rb{x_1}. $$\nThe fact that $ w\\rb{t} = v\\rb{t} $ is as before. By the inductive hypothesis, $ w'\\sb{\\psi\\rb{x_1}} = w\\rb{\\psi\\rb{t}} = F $. As $ w' $ is $ x_i $-equivalent to $ v' $ we have\n$$ v'\\sb{\\fab{x_i}\\psi\\rb{x_1}} = F. $$\nSo $ v'\\sb{\\phi\\rb{x_1}} = F $. This completes the inductive step.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{proof}[Proof of \\ref{thm:2.3.6}]\nSuppose $ v $ is a valuation with $ v\\sb{\\phi\\rb{t}} = F $. Show $ v\\sb{\\fab{x_1}\\phi\\rb{x_1}} = F $. Then\n$$ v\\sb{\\impb{\\fab{x_1}\\phi\\rb{x_1}}{\\phi\\rb{t}}} = T. $$\nTake $ v' $ $ x_1 $-equivalent to $ v $ and $ v'\\rb{x_1} = v\\rb{t} $. Then by \\ref{lem:2.3.7}, $ v'\\sb{\\phi\\rb{x_1}} = F $, so $ v\\sb{\\fab{x_1}\\phi\\rb{x_1}} = F $.\n\\end{proof}\n\n\\subsection{The formal system $ K_\\mathcal{L} $}\n\n\\begin{definition}\nSuppose $ \\mathcal{L} $ is a first-order language. The formal system \\textbf{$ K_\\mathcal{L} $} has as formulas $ \\mathcal{L} $-formulas, and the following.\n\\begin{enumerate}\n\\item Axioms. For $ \\phi, \\chi, \\psi $ $ \\mathcal{L} $-formulas,\n\\begin{enumerate}[label=(A\\arabic*)]\n\\item $ \\impb{\\phi}{\\impb{\\psi}{\\phi}} $,\n\\item $ \\impb{\\impb{\\phi}{\\impb{\\psi}{\\chi}}}{\\impb{\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\chi}}} $,\n\\item $ \\impb{\\impb{\\notb{\\phi}}{\\notb{\\psi}}}{\\impb{\\psi}{\\phi}} $,\n\\item[(K1)] $ \\impb{\\fab{x_i}\\phi\\rb{x_i}}{\\phi\\rb{t}} $, where $ t $ is a term free for $ x_i $ in $ \\phi $ and $ \\phi $ can have other free variables, and\n\\item[(K2)] $ \\impb{\\fab{x_i}\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\fab{x_i}\\psi}} $, if $ x_i $ is not free in $ \\phi $.\n\\end{enumerate}\n\\item Deduction rules.\n\\begin{enumerate}\n\\item Modus Ponens (MP), from formulas $ \\phi $ and $ \\impb{\\phi}{\\psi} $ deduce $ \\psi $, and\n\\item \\textbf{Generalisation} (Gen), from formula $ \\phi $ deduce $ \\fab{x_i}\\phi $.\n\\end{enumerate}\n\\end{enumerate}\nA proof in $ K_\\mathcal{L} $ is a finite sequence of $ \\mathcal{L} $-formulas each of which is an axiom, or deduced from previous formulas in the proof using a rule of deduction. A theorem of $ K_\\mathcal{L} $ is the last formula in some proof. Write $ \\vdash_{K_\\mathcal{L}} \\phi $ for $ \\phi $ is a theorem in $ K_\\mathcal{L} $.\n\\end{definition}\n\n\\begin{note}\nBooks do not always use $ K_\\mathcal{L} $, that is they write $ \\vdash \\phi $.\n\\end{note}\n\n\\begin{definition}\nSuppose $ \\Sigma $ is a set of $ \\mathcal{L} $-formulas and $ \\psi $ an $ \\mathcal{L} $-formula. A deduction of $ \\psi $ from $ \\Sigma $ is a finite sequence of formulas, ending with $ \\psi $, each of which is one of\n\\begin{enumerate}\n\\item an axiom,\n\\item a formula in $ \\Sigma $, or\n\\item obtained from earlier formulas in the deduction using MP or Gen, with the restriction that when Gen is applied it does not involve a variable occurring freely in a formula in $ \\Sigma $.\n\\end{enumerate}\nWrite $ \\Sigma \\vdash_{K_\\mathcal{L}} \\psi $ if there is a deduction from $ \\Sigma $ to $ \\psi $.\n\\end{definition}\n\n\\marginpar{Lecture 13 \\\\ Thursday \\\\ 01/11/18}\n\nLecture 13 is a problem class.\n\n\\marginpar{Lecture 14 \\\\ Friday \\\\ 02/11/18}\n\n\\begin{remark}\n\\hfill\n\\begin{enumerate}\n\\item If $ \\Sigma $ consists of closed formulas, do not need to worry about the restriction on Gen.\n\\item $ \\phi \\vdash \\fab{x_1}\\phi $.\n\\end{enumerate}\n\\end{remark}\n\n\\begin{theorem}\n\\label{thm:2.4.4}\nSuppose $ \\phi $ is an $ \\mathcal{L} $-formula which is a substitution instance of a tautology in propositional logic. Then $ \\vdash_{K_\\mathcal{L}} \\phi $.\n\\end{theorem}\n\n\\begin{example}\n$ \\impb{\\notb{\\notb{\\phi}}}{\\phi} $ for an $ \\mathcal{L} $-formula $ \\phi $, as this is a substitution instance of $ \\impb{\\notb{\\notb{p_1}}}{p_1} $. There is a tautology $ \\chi $ with propositional variables $ p_1, \\dots, p_n $ and $ \\mathcal{L} $-formulas $ \\psi_1, \\dots, \\psi_n $ such that $ \\phi $ is obtained from $ \\chi $ by substituting $ \\psi_i $ for $ p_i $ for $ i = 1, \\dots, n $. By Completeness of propositional logic in \\ref{thm:1.3.4} there is a proof in $ L $ of $ \\chi $ by $ \\chi_1, \\dots, \\chi_r $, where each $ \\chi_i $ is a propositional formula, that is in $ L $, and $ \\chi_r = \\chi $. If we substitute $ \\psi_1, \\dots, \\psi_n $ for $ p_1, \\dots, p_n $ in all $ \\chi_j $ we obtain a sequence of $ \\mathcal{L} $-formulas $ \\phi_1, \\dots, \\phi_r $ which is a proof of $ \\phi = \\phi_r $ in $ K_\\mathcal{L} $.\n\\end{example}\n\n\\begin{theorem}[Soundness theorem of $ K_\\mathcal{L} $]\n\\label{thm:2.4.5}\nIf $ \\vdash_{K_\\mathcal{L}} \\phi $ then $ \\vDash \\phi $, that is it is logically valid.\n\\end{theorem}\n\n\\begin{proof}\nLike in the proof for $ L $, we need to show\n\\begin{enumerate}\n\\item axioms are logically valid, and\n\\item deduction rules preserve logical validity.\n\\end{enumerate}\nFor axioms, A1, A2, A3 are substitution instances of propositional tautologies in \\ref{def:2.2.1} so are logically valid by \\ref{thm:2.4.4}. K1 is logically valid by \\ref{thm:2.3.6}. K2 is $ \\impb{\\fab{x_i}\\impb{\\phi}{\\psi}}{\\impb{\\phi}{\\fab{x_i}\\psi}} $ if $ x_i $ is not free in $ \\phi $. Suppose we have valuation $ v $ such that $ v\\sb{\\impb{\\phi}{\\fab{x_i}\\psi}} = F $. So $ v\\sb{\\phi} = T $ and $ v\\sb{\\fab{x_i}\\psi} = F $. So there is a valuation $ v' $ $ x_i $-equivalent to $ v $ with $ v'\\sb{\\psi} = F $. $ v $ and $ v' $ agree on all variables free in $ \\phi $. So by \\ref{thm:2.3.3} $ v\\sb{\\phi} = v'\\sb{\\phi} = T $, so $ v'\\sb{\\impb{\\phi}{\\psi}} = F $. So $ v\\sb{\\fab{x_i}\\impb{\\phi}{\\psi}} = F $. So $ v\\sb{K_2} = T $. For deduction rules, MP is if $ \\vDash \\phi $ and $ \\vDash \\impb{\\phi}{\\psi} $ then $ \\vDash \\psi $, and Gen is if $ \\vDash \\phi $ then $ \\vDash \\fab{x_i}\\phi $. (TODO Exercise)\n\\end{proof}\n\nTODO Exercise: Suppose $ \\Sigma \\vdash \\psi $ then for every valuation $ v $ with $ v\\sb{\\sigma} = T $ for all $ \\sigma \\in \\Sigma $ we have $ v\\sb{\\psi} = T $.\n\n\\begin{corollary}\nThere is no $ \\mathcal{L} $-formula $ \\phi $ with $ \\vdash_{K_\\mathcal{L}} \\phi $ and $ \\vdash_{K_\\mathcal{L}} \\notb{\\phi} $.\n\\end{corollary}\n\n\\begin{theorem}[Deduction theorem]\nSuppose $ \\mathcal{L} $ is a first-order language, $ \\Sigma $ is a set of $ \\mathcal{L} $-formulas, and $ \\phi, \\psi $ are $ \\mathcal{L} $-formulas. Then if $ \\Sigma \\cup \\cb{\\phi} \\vdash \\psi $ then $ \\Sigma \\vdash \\impb{\\phi}{\\psi} $.\n\\end{theorem}\n\n\\begin{proof}\nFollows proof of deduction theorem for $ L $ in \\ref{thm:1.2.5} by induction on the length of the deduction.\n\\begin{enumerate}\n\\item Base case is one line deduction. Argue exactly as in \\ref{thm:1.2.5}. Note that $ \\vdash_{K_\\mathcal{L}} \\impb{\\phi}{\\phi} $ by \\ref{thm:2.4.4}.\n\\item Inductive step. Suppose $ \\psi $ follows from earlier formulas in the deduction using MP or Gen. MP is exactly as in \\ref{thm:1.2.5}. For Gen, suppose $ \\psi $ is obtained using Gen then $ \\psi $ is $ \\fab{x_i}\\theta $ and $ \\Sigma \\cup \\cb{\\phi} \\vdash \\theta $ and $ x_i $ is not free in any formula in $ \\Sigma \\cup \\cb{\\phi} $. By induction we have $ \\Sigma \\vdash \\impb{\\phi}{\\theta} $. By K2 $ \\Sigma \\vdash \\impb{\\fab{x_i}\\impb{\\phi}{\\theta}}{\\impb{\\phi}{\\fab{x_i}\\theta}} $. By Gen $ \\Sigma \\vdash \\fab{x_i}\\impb{\\phi}{\\theta} $ for $ x_i $ not free in any formula in $ \\Sigma $. So by MP we get $ \\Sigma \\vdash \\impb{\\phi}{\\fab{x_i}\\theta} $ which is $ \\Sigma \\vdash \\impb{\\phi}{\\psi} $.\n\\end{enumerate}\n\\end{proof}\n\n\\marginpar{Lecture 15 \\\\ Monday \\\\ 05/11/18}\n\n\\subsection{Gödel's completeness theorem}\n\n\\begin{definition}\nA set $ \\Sigma $ of $ \\mathcal{L} $-formulas is consistent if there is no formula $ \\phi $ with $ \\Sigma \\vdash_{K_\\mathcal{L}} \\phi $ and $ \\Sigma \\vdash_{K_\\mathcal{L}} \\notb{\\phi} $.\n\\end{definition}\n\nBy Soundness theorem \\ref{thm:2.4.5} $ \\emptyset $ is consistent, so $ K_\\mathcal{L} $ is consistent.\n\n\\begin{remark}\nIf $ \\Sigma $ is inconsistent then $ \\Sigma \\vdash \\chi $ for any $ \\mathcal{L} $-formula $ \\chi $.\n\\end{remark}\n\nRecall that a closed $ \\mathcal{L} $-formula is one without free variables, sometimes called a sentence of $ \\mathcal{L} $. Show that if $ \\Sigma $ is a set of closed $ \\mathcal{L} $-formulas which is consistent then there is an $ \\mathcal{L} $-structure $ \\mathcal{A} $ with $ \\mathcal{A} \\vDash \\sigma $ for all $ \\sigma \\in \\Sigma $. For a simplification, suppose that $ \\mathcal{L} $ is countable, that is the variables are $ x_0, x_1, \\dots $ and there are countably many relation, function, and constant symbols. So we can enumerate the $ \\mathcal{L} $-formulas, or any subset thereof, as a list indexed by $ \\N $. Enumerate the closed $ \\mathcal{L} $-formulas as $ \\psi_0, \\psi_1, \\dots $.\n\n\\begin{proposition}\n\\label{prop:2.5.2}\nSuppose $ \\Sigma $ is a consistent set of closed $ \\mathcal{L} $-formulas and $ \\phi $ is a closed $ \\mathcal{L} $-formula.\n\\begin{enumerate}\n\\item (Compare \\ref{prop:1.3.7}) If $ \\Sigma \\not\\vdash_{K_\\mathcal{L}} \\phi $ then $ \\Sigma \\cup \\cb{\\notb{\\phi}} $ is consistent.\n\\item (Compare Lindenbaum's lemma \\ref{prop:1.3.8}) There is a consistent set $ \\Sigma^* \\supseteq \\Sigma $ of closed $ \\mathcal{L} $-formulas such that, for every closed $ \\mathcal{L} $-formula $ \\psi $ either $ \\Sigma^* \\vdash \\psi $ or $ \\Sigma^* \\vdash \\notb{\\psi} $.\n\\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n\\hfill\n\\begin{enumerate}\n\\item As in \\ref{prop:1.3.7}, used deduction theorem and $ \\vdash_{K_\\mathcal{L}} \\impb{\\impb{\\notb{\\phi}}{\\phi}}{\\phi} $.\n\\item Uses $ 1 $ and the enumeration $ \\psi_0, \\psi_1, \\dots $ of the closed $ \\mathcal{L} $-formulas.\n\\end{enumerate}\n\\end{proof}\n\n\\begin{theorem}\n\\label{thm:2.5.3}\nSuppose $ \\Sigma $ is a consistent set of closed $ \\mathcal{L} $-formulas. Then there is a countable $ \\mathcal{L} $-structure $ \\mathcal{A} $ with $ \\mathcal{A} \\vDash \\Sigma $, that is $ \\mathcal{A} \\vDash \\sigma $ for all $ \\sigma \\in \\Sigma $.\n\\end{theorem}\n\n\\begin{theorem}\n\\label{thm:2.5.4}\nLet $ \\Sigma $ be a set of closed $ \\mathcal{L} $-formulas and $ \\phi $ a closed $ \\mathcal{L} $-formula. If every model of $ \\Sigma $ is a model of $ \\phi $, that is if $ \\mathcal{A} \\vDash \\Sigma $ or $ \\mathcal{A} \\vDash \\sigma $ for all $ \\sigma \\in \\Sigma $ then $ \\mathcal{A} \\vDash \\phi $, then $ \\Sigma \\vdash_{K_\\mathcal{L}} \\phi $.\n\\end{theorem}\n\nNotation is $ \\Sigma \\vDash \\phi $. Then $ \\Sigma \\vDash \\phi $ gives $ \\Sigma \\vdash \\phi $. The converse is Soundness theorem.\n\n\\begin{proof}\nMay assume $ \\Sigma $ is consistent, otherwise, everything is a consequence of $ \\Sigma $. By assumption there is no model of $ \\Sigma \\cup \\cb{\\notb{\\phi}} $. So by \\ref{thm:2.5.3}, $ \\Sigma \\cup \\cb{\\notb{\\phi}} $ is inconsistent. So by \\ref{prop:2.5.2}(1), $ \\Sigma \\vdash \\phi $.\n\\end{proof}\n\n\\begin{theorem}[Gödel's completeness theorem for $ K_\\mathcal{L} $, 1929]\nIf $ \\phi $ is an $ \\mathcal{L} $-formula with $ \\vDash \\phi $, then $ \\phi $ is a theorem of $ K_\\mathcal{L} $, that is $ \\vdash_{K_\\mathcal{L}} \\phi $.\n\\end{theorem}\n\n\\begin{proof}\nIf $ \\phi $ is closed this follows from \\ref{thm:2.5.4} with $ \\Sigma = \\emptyset $. Suppose $ \\phi $ has free variables amongst $ x_1, \\dots, x_n $ and consider the closed formula $ \\psi $, $ \\fab{x_1} \\dots \\fab{x_n}\\phi $. As $ \\vDash \\phi $ we obtain $ \\vDash \\psi $. So by the closed case $ \\vdash \\psi $, that is\n\\begin{equation}\n\\label{eq:6}\n\\vdash \\fab{x_1} \\dots \\fab{x_n}\\phi.\n\\end{equation}\nIf $ \\theta $ is any formula then $ \\vdash \\impb{\\fab{x_i}\\theta}{\\theta} $ by the K1 axiom. So from $ \\rb{\\ref{eq:6}} $ and this fact and MP applied $ n $ times we obtain $ \\vdash_{K_\\mathcal{L}} \\phi $.\n\\end{proof}\n\n\\begin{corollary}[Compactness theorem for $ K_\\mathcal{L} $]\n\\label{cor:2.5.6}\nSuppose $ \\Sigma $ is a set of closed $ \\mathcal{L} $-formulas and every finite subset of $ \\Sigma $ has a model. Then $ \\Sigma $ has a model.\n\\end{corollary}\n\n\\begin{proof}\nSuppose $ \\Sigma $ has no model. By \\ref{thm:2.5.3} $ \\Sigma $ is inconsistent so there is a formula $ \\phi $ with $ \\Sigma \\vdash \\phi $ and $ \\Sigma \\vdash \\notb{\\phi} $. Deductions only involve finitely many formulas in $ \\Sigma $. So there is a finite $ \\Sigma_0 \\subseteq \\Sigma $ with $ \\Sigma_0 \\vdash \\phi $ and $ \\Sigma_0 \\vdash \\notb{\\phi} $. But then $ \\Sigma_0 $ is inconsistent so has no model, a contradiction.\n\\end{proof}\n\n\\marginpar{Lecture 16 \\\\ Thursday \\\\ 08/11/18}\n\n\\begin{proof}[Sketch of proof of \\ref{thm:2.5.3}]\nProof is in a series of steps. Notation is cumulative.\n\\begin{enumerate}\n\\item Let $ b_0, b_1, \\dots $ be new constant symbols. Form $ \\mathcal{L}^+ $ by adding these to the symbols of $ \\mathcal{L} $. Regard $ \\Sigma $ as a set of $ \\mathcal{L}^+ $-formulas. Check $ \\Sigma $ is still consistent in the formal system $ K_{\\mathcal{L}^+} $. Note that $ \\mathcal{L}^+ $ is still a countable language.\n\\item Adding witnesses. Use a lemma that there is a consistent set of closed $ \\mathcal{L}^+ $-formulas $ \\Sigma_\\infty \\supseteq \\Sigma $ such that for every $ \\mathcal{L}^+ $-formula $ \\theta\\rb{x_i} $ with one free variable there is some $ b_j $ with\n$$ \\Sigma_\\infty \\vdash_{K_{\\mathcal{L}^+}} \\impb{\\notb{\\fab{x_i}\\theta\\rb{x_i}}}{\\notb{\\theta\\rb{b_j}}}. $$\nThink of $ \\theta\\rb{x_i} $ as $ \\notb{\\chi\\rb{x_i}} $. Then this formula is essentially $ \\impb{\\teb{x_i}\\chi\\rb{x_i}}{\\chi\\rb{b_j}} $, so $ b_j $ witnesses the existence of $ x_i $ satisfying $ x_i $.\n\\item By Lindenbaum's lemma \\ref{prop:2.5.2} there is a consistent set $ \\Sigma^* \\supseteq \\Sigma_\\infty $ of closed $ \\mathcal{L}^+ $-formulas such that for every closed $ \\phi $ either $ \\Sigma^* \\vdash_{K_{\\mathcal{L}^+}} \\phi $ or $ \\Sigma^* \\vdash_{K_{\\mathcal{L}^+}} \\notb{\\phi} $.\n\\item Building a structure. Let $ A = \\cb{\\bar{t}} $ where $ t $ is a closed term of $ \\mathcal{L}^+ $. Note that\n\\begin{enumerate}\n\\item a term is closed if it only involves constant symbols and function symbols, and no variables,\n\\item use the $ \\bar{\\cdot} $ to distinguish when we are thinking of a term as an element of $ A $, and\n\\item as $ \\mathcal{L}^+ $ is countable, $ A $ is countable.\n\\end{enumerate}\nMake $ A $ into an $ \\mathcal{L}^+ $ structure.\n\\begin{enumerate}\n\\item Each constant symbol $ c $ of $ \\mathcal{L}^+ $ is interpreted as $ \\bar{c} \\in A $.\n\\item Suppose $ R $ is an $ n $-ary relation symbol. Define the relation $ \\bar{R} \\subseteq A^n $ by $ \\rb{\\bar{t_1}, \\dots, \\bar{t_n}} \\in \\bar{R} $ iff $ \\Sigma^* \\vdash R\\rb{t_1, \\dots, t_n} $, a closed atomic $ \\mathcal{L}^+ $-formula, where $ t_1, \\dots, t_n $ are closed $ \\mathcal{L}^+ $-terms.\n\\item Suppose $ f $ is an $ m $-ary function symbol. Define a function $ \\bar{f} : A^m \\to A $ by $ \\bar{f}\\rb{\\bar{t_1}, \\dots, \\bar{t_m}} = \\bar{f\\rb{t_1, \\dots, t_m}} $ for closed terms $ t_1, \\dots, t_m $.\n\\end{enumerate}\nCall this structure $ \\mathcal{A} $. Note that if $ v $ is a valuation in $ \\mathcal{A} $ and $ t $ is a closed term, then $ v\\rb{t} = \\bar{t} $ by (a) and (c) here.\n\\item Use the main lemma that for every closed $ \\mathcal{L}^+ $-formula $ \\phi $\n\\begin{equation}\n\\label{eq:7}\n\\Sigma^* \\vdash_{K_{\\mathcal{L}^+}} \\phi \\qquad \\iff \\qquad \\mathcal{A} \\vDash \\phi.\n\\end{equation}\nProof by induction on number of connectives and quantifiers in $ \\phi $.\n\\begin{enumerate}\n\\item Base case. $ \\phi $ is atomic, that is $ \\phi $ is $ R\\rb{t_1, \\dots, t_n} $ for some closed terms $ t_i $, and relation symbol $ R $. $ \\rb{\\ref{eq:7}} $ holds by $ (b) $ in definition of $ \\mathcal{A} $.\n\\item Inductive step. Assume $ \\rb{\\ref{eq:7}} $ holds for closed formulas involving fewer connectives and quantifiers.\n\\begin{enumerate}\n\\item $ \\phi $ is $ \\notb{\\psi} $.\n\\item $ \\phi $ is $ \\impb{\\psi}{\\chi} $.\n\\item $ \\phi $ is $ \\fab{x_i}\\psi $.\n\\end{enumerate}\nIn cases i and ii $ \\psi, \\chi $ are closed. So $ \\rb{\\ref{eq:7}} $ holds for these.\n\\begin{enumerate}\n\\item $ \\phi $ is $ \\notb{\\psi} $, so $ \\mathcal{A} \\vDash \\phi $ iff $ \\mathcal{A} \\not\\vDash \\psi $ by \\ref{thm:2.3.3}, iff $ \\Sigma^* \\not\\vdash \\psi $ by $ \\rb{\\ref{eq:7}} $, iff $ \\Sigma^* \\vdash \\notb{\\psi} $ by step $ 3 $.\n\\item TODO Exercise.\n\\item $ \\phi $ is $ \\fab{x_i}\\psi $.\n\\begin{enumerate}\n\\item $ x_i $ is not free in $ \\psi $. So $ \\psi $ is closed and we can use inductive hypothesis.\n\\item $ x_i $ is free in $ \\psi $. So $ \\psi\\rb{x_i} $ has a single free variable.\n\\end{enumerate}\n\\end{enumerate}\n\\end{enumerate}\nSuppose for a contradiction that $ \\mathcal{A} \\vDash \\phi $ and $ \\Sigma^* \\not\\vdash \\phi $. Then by step $ 3 $ $ \\Sigma^* \\vdash \\notb{\\phi} $. By step $ 2 $, $ \\Sigma^* \\vdash \\impb{\\notb{\\fab{x_i}\\psi\\rb{x_i}}}{\\notb{\\psi\\rb{b_j}}} $ for some constant symbol $ b_j $, that is $ \\Sigma^* \\vdash \\impb{\\notb{\\phi}}{\\notb{\\psi\\rb{b_j}}} $. So $ \\Sigma^* \\vdash \\notb{\\psi\\rb{b_j}} $. $ \\notb{\\psi\\rb{b_j}} $ is closed and by case $ i $, $ \\rb{\\ref{eq:7}} $ applies. We obtain\n\\begin{equation}\n\\label{eq:8}\n\\mathcal{A} \\vDash \\notb{\\psi\\rb{b_j}}.\n\\end{equation}\nThis contradicts $ \\mathcal{A} \\vDash \\fab{x_i}\\psi $. Take a valuation $ v $ is $ \\mathcal{A} $ with $ v\\rb{x_i} = \\bar{b_j} $, then $ v $ does not satisfy $ \\psi $, by $ \\rb{\\ref{eq:8}} $.\n\\end{enumerate}\n\\end{proof}\n\nTODO Exercise: think about this where $ \\Sigma $ consists of the group axioms. What is $ \\mathcal{A} $? Is it a group?\n\n\\marginpar{Lecture 17 \\\\ Friday \\\\ 09/11/18}\n\n\\subsection{Equality}\n\n\\begin{example}\nIn the language of groups, have a binary relation symbol $ E\\rb{x_1, x_2} $ for equality $ x_1 = x_2 $.\n\\end{example}\n\n\\begin{definition}\nSuppose $ \\mathcal{L}^E $ is a first-order language with a distinguished binary relation symbol $ E $.\n\\begin{enumerate}\n\\item An $ \\mathcal{L}^E $-structure in which $ E $ is interpreted as equality $ = $ is a \\textbf{normal} $ \\mathcal{L}^E $-structure.\n\\item The following are the axioms of equality, $ \\Sigma_E $.\n\\begin{enumerate}\n\\item $ \\fab{x_1}E\\rb{x_1, x_2} $.\n\\item $ \\fab{x_1}\\fab{x_2}\\impb{E\\rb{x_1, x_2}}{E\\rb{x_2, x_1}} $.\n\\item $ \\fab{x_1}\\fab{x_2}\\fab{x_3}\\impb{E\\rb{x_1, x_2}}{\\impb{E\\rb{x_2, x_3}}{E\\rb{x_1, x_3}}} $.\n\\end{enumerate}\n\\item For each $ n $-ary relation symbol $ R $ of $ \\mathcal{L}^E $,\n$$ \\fab{x_1}\\dots\\fab{x_n}\\fab{y_1}\\dots\\fab{y_n}\\impb{\\rb{R\\rb{x_1, \\dots, x_n} \\land E\\rb{x_1, y_1} \\land \\dots \\land E\\rb{x_n, y_n}}}{R\\rb{y_1, \\dots, y_n}}. $$\n\\item For each $ m $-ary function symbol $ f $ of $ \\mathcal{L}^E $,\n$$ \\fab{x_1}\\dots\\fab{x_m}\\fab{y_1}\\dots\\fab{y_m}\\impb{\\rb{E\\rb{x_1, y_1} \\land \\dots \\land E\\rb{x_m, y_m}}}{E\\rb{f\\rb{x_1, \\dots, x_m}, f\\rb{y_1, \\dots, y_m}}}. $$\n\\end{enumerate}\n\\end{definition}\n\n\\begin{definition}\n\\hfill\n\\begin{enumerate}\n\\item If $ \\mathcal{A} $ is a normal $ \\mathcal{L}^E $-structure then $ \\mathcal{A} \\vDash \\Sigma_E $.\n\\item Suppose $ \\mathcal{A} = \\ab{A; \\bar{E}, \\dots} $ is an $ \\mathcal{L}^E $-structure and $ \\mathcal{A} \\vDash \\Sigma_E $. Then $ \\bar{E} $ is an equivalence relation on $ A $. Denote, for $ a \\in A $ $ \\widehat{a} = \\cb{b \\in A \\mid \\bar{E}\\rb{a, b}} $, the equivalence class of $ a $. Let $ \\widehat{A} = \\cb{\\widehat{a} \\mid a \\in A} $. Make $ \\widehat{A} $ into an $ \\mathcal{L}^E $-structure $ \\widehat{\\mathcal{A}} $.\n\\begin{enumerate}\n\\item If $ R $ is an $ n $-ary relation symbol and $ \\widehat{a_1}, \\dots, \\widehat{a_n} \\in \\widehat{A} $ then say $ \\bar{R}\\rb{\\widehat{a_1}, \\dots, \\widehat{a_n}} $ holds in $ \\widehat{\\mathcal{A}} $ iff $ \\bar{R}\\rb{a_1, \\dots, a_n} $ holds in $ \\mathcal{A} $. This is well-defined by $ \\Sigma_E $.\n\\item Similarly if $ f $ is an $ m $-ary function symbol and $ \\widehat{a_1}, \\dots, \\widehat{a_m} \\in \\widehat{A} $ let $ \\bar{f}\\rb{\\widehat{a_1}, \\dots, \\widehat{a_m}} = \\widehat{\\bar{f}\\rb{a_1, \\dots, a_m}} $. This is also well-defined by $ \\Sigma_E $.\n\\item If $ c $ is a constant symbol, then interpret $ c $ as $ \\widehat{\\bar{c}} $ in $ \\widehat{A} $, where $ \\bar{c} $ is the interpretation in $ \\mathcal{A} $.\n\\end{enumerate}\nNote that in $ \\widehat{\\mathcal{A}} $ $ \\bar{E}\\rb{\\widehat{a_1}, \\widehat{a_2}} $ iff $ \\bar{E}\\rb{a_1, a_2} $ in $ \\mathcal{A} $, iff $ \\widehat{a_1} = \\widehat{a_2} $. So $ \\widehat{\\mathcal{A}} $ is a normal $ \\mathcal{L}^E $-structure.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{lemma}\n\\label{lem:2.6.3}\nSuppose $ \\mathcal{A} $ is an $ \\mathcal{L}^E $-structure with $ \\mathcal{A} \\vDash \\Sigma_E $. Let $ v $ be a valuation in $ \\mathcal{A} $. Let $ \\widehat{\\mathcal{A}} $ be as given above. Let $ \\widehat{v} $ be the valuation in $ \\widehat{\\mathcal{A}} $ with $ \\widehat{v}\\rb{x_i} = \\widehat{v\\rb{x_i}} $. Then for every $ \\mathcal{L}^E $-formula $ \\phi $ $ \\widehat{v} $ satisfies $ \\phi $ in $ \\widehat{\\mathcal{A}} $ iff $ v $ satisfies $ \\phi $ in $ \\mathcal{A} $. In particular, if $ \\phi $ is closed then $ \\mathcal{A} \\vDash \\phi $ iff $ \\widehat{\\mathcal{A}} \\vDash \\phi $.\n\\end{lemma}\n\n\\begin{note}\nIf $ t $ is any term then $ \\widehat{v}\\rb{t} = \\widehat{v\\rb{t}} $ by definition of $ \\bar{f} $ on the structure $ \\widehat{\\mathcal{A}} $.\n\\end{note}\n\n\\begin{proof}\nThe result \\ref{lem:2.6.3} is proved by induction on the number of connectives and quantifiers in $ \\phi $.\n\\begin{enumerate}\n\\item Base step. $ \\phi $ is an atomic formula $ R\\rb{t_1, \\dots, t_n} $, where $ R $ is an $ n $-ary relation symbol and $ t_1, \\dots, t_n $ are terms. Then $ v\\sb{\\phi} = T $ iff $ \\bar{R}\\rb{v\\rb{t_1}, \\dots, v\\rb{t_n}} $ holds in $ \\mathcal{A} $, iff $ \\bar{R}\\rb{\\widehat{v\\rb{t_1}}, \\dots, \\widehat{v\\rb{t_n}}} $ holds in $ \\mathcal{A} $ by definition of $ \\bar{R} $ in $ \\widehat{\\mathcal{A}} $, iff $ \\bar{R}\\rb{\\widehat{v}\\rb{t_1}, \\dots, \\widehat{v}\\rb{t_n}} $ in $ \\mathcal{A} $, iff $ \\widehat{v}\\sb{\\phi} = T $, as required.\n\\item Inductive step.\n\\begin{enumerate}\n\\item $ \\phi $ is $ \\notb{\\psi} $. (TODO Exercise)\n\\item $ \\phi $ is $ \\impb{\\theta}{\\chi} $ (TODO Exercise)\n\\item $ \\phi $ is $ \\fab{x_i}\\psi $.\n\\begin{itemize}\n\\item[$ \\implies $] If $ v\\sb{\\fab{x_i}\\psi} = F $ there is a $ v' $ $ x_i $-equivalent to $ v $ with $ v'\\sb{\\psi} = F $. Then $ \\widehat{v'} $ is $ x_i $-equivalent to $ \\widehat{v} $ and by the induction hypothesis $ \\widehat{v'}\\sb{\\psi} = F $. So $ \\widehat{v}\\sb{\\fab{x_i}\\psi} = F $.\n\\item[$ \\impliedby $] Suppose $ \\widehat{v}\\sb{\\fab{x_i}\\psi} = F $. So there is a valuation $ w $ in $ \\widehat{\\mathcal{A}} $ which is $ x_i $-equivalent to $ \\widehat{v} $ and $ w\\sb{\\psi} = F $. There is a valuation $ v' $ in $ \\mathcal{A} $ $ x_i $-equivalent to $ v $ with $ \\widehat{v'} = w $. We just change $ v\\rb{x_i} $ so $ \\widehat{v'\\rb{x_i}} = w\\rb{x_i} $. Then $ v'\\sb{\\psi} = F $ by inductive hypothesis. So $ v\\sb{\\fab{x_i}\\psi} = F $.\n\\end{itemize}\n\\end{enumerate}\n\\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}\n\\label{lem:2.6.4}\nSuppose $ \\Delta $ is a set of closed $ \\mathcal{L}^E $-formulas. Then $ \\Delta $ has a normal model, that is a normal $ \\mathcal{L}^E $-structure $ \\mathcal{B} $ with $ \\mathcal{B} \\vDash \\sigma $ for all $ \\sigma \\in \\Delta $, iff $ \\Delta \\cup \\Sigma_E $ has a model.\n\\end{lemma}\n\n\\begin{proof}\n\\hfill\n\\begin{itemize}\n\\item[$ \\implies $] Trivial as $ \\Sigma_E $ holds in a normal $ \\mathcal{L}^E $-structure.\n\\item[$ \\impliedby $] If $ \\mathcal{A} \\vDash \\Delta \\cup \\Sigma_E $ then by \\ref{lem:2.6.3} $ \\widehat{\\mathcal{A}} \\vDash \\Delta $ and $ \\widehat{\\mathcal{A}} $ is a normal $ \\mathcal{L}^E $-structure.\n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}[Compactness theorem for normal models]\nSuppose $ \\mathcal{L}^E $ is a countable language with equality and $ \\Delta $ is a set of closed $ \\mathcal{L}^E $-formulas such that every finite subset of $ \\Delta $ has a normal model. Then $ \\Delta $ has a normal model.\n\\end{theorem}\n\n\\begin{proof}\nEvery normal $ \\mathcal{L}^E $-structure is a model of $ \\Sigma_E $, so every finite subset of $ \\Delta \\cup \\Sigma_E $ has a model. By \\ref{cor:2.5.6} $ \\Delta \\cup \\Sigma_E $ has a model $ \\mathcal{A} $. Then by \\ref{lem:2.6.3} or \\ref{lem:2.6.4} $ \\widehat{\\mathcal{A}} $ is a normal model of $ \\Delta $.\n\\end{proof}\n\nFrom now on, write $ \\mathcal{L}^= $ instead of $ \\mathcal{L}^E $ and $ x_1 = x_2 $ instead of $ E\\rb{x_1, x_2} $ etc.\n\n\\marginpar{Lecture 18 \\\\ Monday \\\\ 12/11/18}\n\n\\begin{theorem}[Countable downward Löwenheim-Skolem theorem]\nSuppose $ \\mathcal{L}^= $ is a countable first-order language with equality, and $ \\mathcal{B} $ a normal $ \\mathcal{L}^= $ structure. Then there is a countable normal $ \\mathcal{L}^= $-structure $ \\mathcal{A} $ such that for every closed $ \\mathcal{L}^= $-formula $ \\phi $ $ \\mathcal{B} \\vDash \\phi $ iff $ \\mathcal{A} \\vDash \\phi $.\n\\end{theorem}\n\n\\begin{example}\n$ \\mathcal{B} = \\ab{\\R; +, \\cdot, 0, 1, \\le, \\exp} $ has $ \\mathcal{A} = ? $.\n\\end{example}\n\n\\begin{proof}\nLet $ \\Sigma $ be the closed $ \\phi $ such that $ \\mathcal{B} \\vDash \\phi $, called the \\textbf{theory} of $ \\mathcal{B} $. Then $ \\Sigma \\supseteq \\Sigma_E $ with the axioms of equality, and $ \\Sigma $ is consistent. By \\ref{thm:2.5.3} $ \\Sigma $ has a countable model $ \\mathcal{C} $. Then $ \\widehat{\\mathcal{C}} $ is a countable normal model of $ \\Sigma $ by \\ref{lem:2.6.3}. So if $ \\phi $ is closed and $ \\mathcal{B} \\vDash \\phi $ then $ \\widehat{\\mathcal{C}} \\vDash \\phi $. Conversely if $ \\phi $ is closed and $ \\mathcal{B} \\not\\vDash \\phi $ then $ \\mathcal{B} \\vDash \\notb{\\phi} $ by \\ref{thm:2.3.3}, so $ \\widehat{\\mathcal{C}} \\vDash \\notb{\\phi} $ so $ \\widehat{\\mathcal{C}} \\not\\vDash \\phi $. Take $ \\mathcal{A} = \\widehat{\\mathcal{C}} $.\n\\end{proof}\n\n\\subsection{Examples and applications}\n\nLinear orders. Let $ \\mathcal{L}^= $ be a first-order language with equality and a binary relation symbol $ \\le $.\n\n\\begin{definition}\nA linear order $ \\mathcal{A} = \\ab{A; \\le_A} $ is a normal model if\n\\begin{enumerate}\n\\item $ \\phi_1 $, $ \\fab{x_1}\\fab{x_2}\\iffb{\\andb{\\rb{x_1 \\le x_2}}{\\rb{x_2 \\le x_1}}}{\\rb{x_1 = x_2}} $,\n\\item $ \\phi_2 $, $ \\fab{x_1}\\fab{x_2}\\fab{x_3}\\impb{\\andb{\\rb{x_1 \\le x_2}}{\\rb{x_2 \\le x_3}}}{\\rb{x_1 \\le x_3}} $, and\n\\item $ \\phi_3 $, $ \\fab{x_1}\\fab{x_2}\\orb{\\rb{x_1 \\le x_2}}{\\rb{x_2 \\le x_1}} $.\n\\end{enumerate}\nIt is \\textbf{dense} if also\n\\begin{enumerate}\n\\setcounter{enumi}{3}\n\\item $ \\phi_4 $, $ \\fab{x_1}\\fab{x_2}\\teb{x_3}\\impb{\\rb{x_1 < x_2}}{\\andb{\\rb{x_1 < x_3}}{\\rb{x_3 < x_2}}} $,\n\\end{enumerate}\nwhere $ \\rb{x_1 < x_2} $ is an abbreviation for $ \\andb{\\rb{x_1 \\le x_2}}{\\rb{x_1 \\ne x_2}} $. It is \\textbf{without endpoints} if\n\\begin{enumerate}\n\\setcounter{enumi}{4}\n\\item $ \\phi_5 $, $ \\fab{x_1}\\teb{x_2}\\rb{x_1 < x_2} $, and\n\\item $ \\phi_6 $, $ \\fab{x_1}\\teb{x_2}\\rb{x_2 < x_1} $.\n\\end{enumerate}\nLet $ \\Delta = \\cb{\\phi_1, \\dots, \\phi_6} $. $ \\mathcal{Q} = \\ab{\\Q; \\le} $ is a normal model of $ \\Delta $. $ \\mathcal{R} = \\ab{\\R; \\le} $ is also a model of $ \\Delta $.\n\\end{definition}\n\nWill prove the following.\n\n\\begin{theorem}\n\\label{thm:2.7.2}\n\\hfill\n\\begin{enumerate}\n\\item For every closed $ \\mathcal{L}^= $-formula $ \\phi $ $ \\mathcal{Q} \\vDash \\phi $ iff $ \\mathcal{R} \\vDash \\phi $.\n\\item There is an algorithm to decide, given a closed $ \\mathcal{L}^= $-formula $ \\phi $, whether $ \\mathcal{Q} \\vDash \\phi $ or $ \\mathcal{Q} \\vDash \\notb{\\phi} $.\n\\end{enumerate}\n\\end{theorem}\n\n\\begin{definition}\n\\label{def:2.7.3}\n\\hfill\n\\begin{enumerate}\n\\item Linear orders $ \\mathcal{A} = \\ab{A; \\le_A} $ and $ \\mathcal{B} = \\ab{B; \\le_B} $ are isomorphic if there is a bijection $ \\alpha : A \\to B $ such that for all $ a, a' \\in A $ $ a \\le_A a' $ iff $ \\alpha\\rb{a} \\le_B \\alpha\\rb{a'} $.\n\\item If $ \\mathcal{A}, \\mathcal{B} $ are isomorphic and $ \\phi $ is closed then $ \\mathcal{A} \\vDash \\phi $ iff $ \\mathcal{B} \\vDash \\phi $.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{theorem}[Cantor]\n\\label{thm:2.7.4}\nIf $ \\mathcal{A}, \\mathcal{B} $ are countable dense linear orders without endpoints, then $ \\mathcal{A}, \\mathcal{B} $ are isomorphic.\n\\end{theorem}\n\n\\begin{lemma}[Łos-Vaught test]\n\\label{lem:2.7.5}\nLet $ \\Sigma = \\Sigma_E \\cup \\Delta $. Then for every closed $ \\mathcal{L}^= $-formula $ \\phi $, we have either $ \\Sigma \\vdash \\phi $ or $ \\Sigma \\vdash \\notb{\\phi} $. Say $ \\Sigma $ is complete.\n\\end{lemma}\n\n\\begin{proof}\nSuppose not. Then as $ \\Sigma $ is consistent, it has a model, we can use \\ref{prop:2.5.2} to get $ \\Sigma_1 = \\Sigma \\cup \\cb{\\notb{\\phi}} $ and $ \\Sigma_2 = \\Sigma \\cup \\cb{\\notb{\\notb{\\phi}}} $ are consistent. So $ \\Sigma \\cup \\cb{\\phi} $ is consistent. By \\ref{thm:2.5.3}, \\ref{lem:2.6.4} it follows that $ \\Sigma_1, \\Sigma_2 $ have countable normal models $ \\mathcal{A}_1, \\mathcal{A}_2 $. So $ \\mathcal{A}_1, \\mathcal{A}_2 $ are countable dense linear orders without endpoints and $ \\mathcal{A}_1 \\vDash \\notb{\\phi} $ and $ \\mathcal{A}_2 \\vDash \\phi $. This contradicts \\ref{thm:2.7.4} and \\ref{def:2.7.3}(2).\n\\end{proof}\n\n\\begin{proof}[Proof of \\ref{thm:2.7.2}(1)]\nShow $ \\mathcal{Q} \\vDash \\phi $ iff $ \\Sigma \\vdash \\phi $.\n\\begin{itemize}\n\\item[$ \\impliedby $] As $ \\mathcal{Q} \\vDash \\Sigma $ this is \\ref{thm:2.4.5}.\n\\item[$ \\implies $] If $ \\Sigma \\not\\vdash \\phi $ then by \\ref{lem:2.7.5} $ \\Sigma \\vdash \\notb{\\phi} $. So $ \\mathcal{Q} \\vDash \\notb{\\phi} $, so $ \\mathcal{Q} \\not\\vDash \\phi $.\n\\end{itemize}\nSimilarly $ \\mathcal{R} \\vDash \\phi $ iff $ \\Sigma \\vdash \\phi $. So $ \\mathcal{R} \\vDash \\phi $ iff $ \\Sigma \\vdash \\phi $, iff $ \\mathcal{Q} \\vDash \\phi $.\n\\end{proof}\n\n\\marginpar{Lecture 19 \\\\ Thursday \\\\ 15/11/18}\n\nLecture 19 is a problem class.\n\n\\end{document}", "meta": {"hexsha": "446279ea38641401546fc95a61cdb223d104b34e", "size": 89592, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "M3P65 Mathematical Logic/M3P65.tex", "max_stars_repo_name": "kckennylau/JMC3", "max_stars_repo_head_hexsha": "1ef0265a73457e0d379c71f9de2218f217e89a8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "M3P65 Mathematical Logic/M3P65.tex", "max_issues_repo_name": "kckennylau/JMC3", "max_issues_repo_head_hexsha": "1ef0265a73457e0d379c71f9de2218f217e89a8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "M3P65 Mathematical Logic/M3P65.tex", "max_forks_repo_name": "kckennylau/JMC3", "max_forks_repo_head_hexsha": "1ef0265a73457e0d379c71f9de2218f217e89a8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.9217391304, "max_line_length": 1265, "alphanum_fraction": 0.637545763, "num_tokens": 33373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.4171881138334759}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{float}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{graphicx}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage[noabbrev,capitalize,nameinlink]{cleveref}\n\\usepackage{natbib}\n\\usepackage{setspace}\n\\usepackage{tikz-cd}\n\n\\newcommand{\\argmin}{\\ensuremath{\\mathop{\\arg\\min}\\limits}}\n\\DeclarePairedDelimiter{\\abs}{\\lvert}{\\rvert}\n\n\\title{Automatic Wound Analysis with Siamese Network}\n\\author{Alex Ruan \\\\ \\texttt{runalex01@gmail.com} \\and Siwei Wang \\\\ \\texttt{siweiw9@gmail.com}}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\\onehalfspacing\n\n\\section{Data Preprocessing} \\label{sec:data_preprocessing}\n\nOur system expects standard 3-channel images as input (dimensions \\(W \\times H \\times 3\\)). We trained our model on images consisting of a rat's abdominal section with one or more wounds. The background was white, and the rat was placed next to a ruler. However, the model can be trained on any labelled dataset to suit a variety of applications.\n\nEach image is resized to a uniform \\(40 \\times 40 \\times 3\\) using bicubic interpolation. For best results, we recommend that input images be larger than this size. We then apply a Gaussian blur with a radius of 2. The Siamese model expects resampled and blurred images as input when predicting labels.\n\nDuring training, the model expects image pairs. The training set is generated by taking all distinct image pairs and labelling the pair with 1 or 0 if the images have the same or different labels, respectively. Suppose our dataset consists of \\(N\\) labelled images with \\(K\\) possible labels. We represent the dataset as image-label pairs \\((X_i, y_i)\\) with \\(0 \\leq i < N\\), \\(X_i \\in [0, 1]^{40 \\times 40 \\times 3}\\), and \\(0 \\leq y_i < K\\). We generate \\(\\binom{N}{2}\\) pairs of the form \\([(X_i, X_j), \\delta(y_i, y_j)]\\) where \\(\\delta\\) denotes Kronecker delta and \\(i \\neq j\\). Define \\(N_i\\) as the number of times label \\(i\\) appears in the training set. Then there are\n\\begin{equation}\n    \\sum_{i = 0}^{K - 1} \\binom{N_i}{2} \\label{eq:same_pairs}\n\\end{equation}\npairs with label 1. For a reasonably balanced dataset with \\(K > 2\\), this number will usually be less than half of \\(\\binom{N}{2}\\). The resulting class imbalance is addressed by assigning appropriate class weights during training.\n\n\\section{Model Architecture} \\label{sec:model_architecture}\n\n\\subsection{Overview} \\label{subsec:overview}\n\nLabel predictions are the result of a 2-step process. The input image is first encoded as a vector representation. The encoding is then compared against a ``typical'' representation for each label. This comparison is carried out with a custom distance metric. The model predicts the label corresponding to the closest representation. In symbols, the model consists of an encoder \\(\\mathcal{E} \\colon [0, 1]^{40 \\times 40 \\times 3} \\to \\mathbf{R}^{2048}\\), a distance metric \\(\\mathcal{D} \\colon \\mathbf{R}^{2048} \\times \\mathbf{R}^{2048} \\to (0, 1)\\), and \\(K\\) ``typical'' representations \\(C_0, \\dotsc, C_{K - 1}\\) with \\(C_i \\in \\mathbf{R}^{2048}\\). Given input image \\(I \\in [0, 1]^{40 \\times 40 \\times 3}\\), the model predicts label\n\\begin{equation}\n    \\argmin_{i = 0}^{K - 1} \\mathcal{D}(\\mathcal{E}(I), C_i) \\label{eq:prediction}\n\\end{equation}\nWe can interpret the prediction process as a generalization of \\(K\\)-means. The image \\(I\\) derives its label by comparing its representation \\(\\mathcal{E}(I)\\) against against \\(K\\) ``centroids'' and choosing the closest one, where distance is defined by \\(\\mathcal{D}\\).\n\nTo train the model, we construct a siamese network with contrastive loss. We would like \\(P_{ij} \\coloneqq \\mathcal{D}(\\mathcal{E}(X_i), \\mathcal{E}(X_j))\\) to approximate \\(Y_{ij} \\coloneqq \\delta(y_i, y_j)\\). Note that this problem is a binary classification task with instance \\((X_i, X_j)\\) and label \\(Y_{ij}\\). Hence, we use cross-entropy loss \\(\\mathcal{L}\\), which is defined as\n\\begin{equation}\n    \\mathcal{L}[(X_i, X_j), Y_{ij}] \\coloneqq -Y_{ij} \\log P_{ij} - (1 - Y_{ij}) \\log (1 - P_{ij}) \\label{eq:cross_entropy}\n\\end{equation}\nto tune our model parameters. The forward pass of the training process is summarized in the diagram below.\n\\begin{equation*}\n    \\begin{tikzcd}\n        X_i \\arrow[rr, \"\\text{encode}\"] &  & \\mathcal{E}(X_i) \\arrow[rrd, \"\\text{dist}\", bend left]   &  &                                  &  & Y_{ij} \\arrow[d]                  \\\\\n        &  &                                                          &  & P_{ij} \\arrow[rr, \"\\text{loss}\"] &  & {\\mathcal{L}[(X_i, X_j), Y_{ij}]} \\\\\n        X_j \\arrow[rr, \"\\text{encode}\"] &  & \\mathcal{E}(X_j) \\arrow[rru, \"\\text{dist}\"', bend right] &  &                                  &  &\n    \\end{tikzcd} \\label{eq:training}\n\\end{equation*}\n\nWe compiled our model with an Adams optimizer (initial learning rate of \\(5 \\times 10^{-5}\\)), a batch size of 5, and saved the model with the lowest validation loss over 30 epochs.\n\n\\subsection{The Encoder} \\label{subsec:the_encoder}\n\nWe use a deep CNN similar to \\citet{tds} to encode an image \\(I\\) as a vector representation. The architecture is fairly standard, consisting of a series of convolutions with ReLU activation followed by max pools. At the end, the image is flattened and passed through a fully connected layer with sigmoid activation. A diagram of the encoder is displayed in \\cref{fig:encoder}.\n\n\\begin{figure}[H]\n    \\centering\n    \\caption{Encoder (CNN) Architecture}\n    \\includegraphics[width=.9\\textwidth]{encoder.png}\n    \\label{fig:encoder}\n\\end{figure}\n\nThe more detailed Keras model summary is reproduced below.\n\\begin{lstlisting}\n_________________________________________________________________\nLayer (type)                 Output Shape              Param #\n=================================================================\nconv2d (Conv2D)              (None, 40, 40, 64)        15616\n_________________________________________________________________\nmax_pooling2d (MaxPooling2D) (None, 20, 20, 64)        0\n_________________________________________________________________\nconv2d_1 (Conv2D)            (None, 20, 20, 128)       401536\n_________________________________________________________________\nmax_pooling2d_1 (MaxPooling2 (None, 10, 10, 128)       0\n_________________________________________________________________\nconv2d_2 (Conv2D)            (None, 10, 10, 128)       409728\n_________________________________________________________________\nmax_pooling2d_2 (MaxPooling2 (None, 5, 5, 128)         0\n_________________________________________________________________\nconv2d_3 (Conv2D)            (None, 5, 5, 256)         295168\n_________________________________________________________________\nflatten (Flatten)            (None, 6400)              0\n_________________________________________________________________\ndense (Dense)                (None, 2048)              13109248\n=================================================================\n\\end{lstlisting}\n\n\\subsection{The Distance Metric} \\label{subsec:the_distance_metric}\n\nDefine a component-wise absolute value function \\(\\alpha \\colon \\mathbf{R}^n \\to \\mathbf{R}^n\\) given by \\((v_1, \\dotsc, v_n) \\mapsto (\\abs{v_1}, \\dotsc, \\abs{v_n})\\). The distance between two representation vectors \\(U, V \\in \\mathbf{R}^{2048}\\) is computed by passing \\(\\alpha(U - V)\\) through a fully-connected layer \\(F\\) with a single output node and sigmoid activation. Then \\(\\mathcal{D}(U, V) \\coloneqq F \\circ \\alpha(U - V)\\). This is the approach used by \\citet{cmu}.\n\nThe intuition is that we wish to jointly learn an encoding \\(\\mathcal{E}\\) and a ``difference'' interpreter \\(F\\) that maps images with the same label close together and maps images with different labels far apart. Recall that \\(F \\coloneqq S \\circ T\\) consists of an affine transformation \\(T \\colon \\mathbf{R}^{2048} \\to \\mathbf{R}\\) followed by sigmoid activation \\(S\\). Hence, we see that \\(F\\) learns to affinely map large differences to very positive values and map small differences to very negative values. Then, \\(S\\) squeezes these values into the \\((0, 1)\\) range.\n\nIn this case, \\(\\alpha(U - V)\\) quantifies how different the representations \\(U\\) and \\(V\\) are from one another. More rigorously, the \\(L^1\\) norm of \\(\\alpha(U - V)\\) captures the \\(L^1\\) distance separating \\(U\\) and \\(V\\). Hence, we may interpret \\(T\\) as assigning a weight to each of the 2048 components that comprise a representation vector. This means that we can penalize a difference in certain components more heavily than in others.\n\nThe ``typical'' representations \\(C_0, \\dotsc, C_{K - 1}\\) are computed after the model is trained. We used the mean encoding of the training images from each label.\n\\begin{equation}\n    C_i \\coloneqq \\frac{1}{N_i} \\sum_{j = 0}^{N - 1} \\delta(y_j, i) \\cdot \\mathcal{E}(X_j) \\label{eq:typical_rep}\n\\end{equation}\nIn this sense, \\(C_i\\) should be close to most images with label \\(i\\) and far away from most images with label \\(j \\neq i\\), as measured by \\(\\mathcal{D}\\).\n\n\\bibliographystyle{abbrvnat}\n\\bibliography{wound}\n\\end{document}\n", "meta": {"hexsha": "d6aa15e66f047b6c513ae6a30ddb6b1318445e15", "size": 9148, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/wound.tex", "max_stars_repo_name": "siweiwang24/wound-analysis", "max_stars_repo_head_hexsha": "1a85c21b4bd425e3cca5cb4b7b26158af32abebf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-13T09:01:09.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-13T09:01:09.000Z", "max_issues_repo_path": "report/wound.tex", "max_issues_repo_name": "siweiwang24/wound-analysis", "max_issues_repo_head_hexsha": "1a85c21b4bd425e3cca5cb4b7b26158af32abebf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/wound.tex", "max_forks_repo_name": "siweiwang24/wound-analysis", "max_forks_repo_head_hexsha": "1a85c21b4bd425e3cca5cb4b7b26158af32abebf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-13T09:01:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-13T09:01:12.000Z", "avg_line_length": 78.8620689655, "max_line_length": 737, "alphanum_fraction": 0.7006996065, "num_tokens": 2532, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4171881050298623}}
{"text": "\\documentclass{article}\n%\\usepackage{polski} %to replace latex keywords in the document to Polish\n\\usepackage[utf8]{inputenc} %sets input encoding to UTF-8, needed for Polish, Japanese, etc.\n\\usepackage[T1]{fontenc} %needed for Polish characters\n\\usepackage{lmodern} %this font handles Polish characters properly\n\\usepackage[cm]{fullpage} %very small margins (around 1.5cm)\n\\usepackage{multicol} %use \\begin{multicols}{#} for # columns\n\\usepackage{amssymb} %big bracets and other useful symbols\n\\usepackage{amsmath} %some mathematical symbols\n\\usepackage{enumitem} %remove vertical space in itemize with: [noitemsep,nolistsep]\n\\usepackage{url} %use \\url{} in the document\n%\\usepackage{tipa} % \\textpolhook{a}\n\n\\newcommand{\\nodata}{\\emph{no data yet}}\n\\newcommand{\\samplecustom}[2]{X_{#1}, \\ldots, X_{#2}}\n\\newcommand{\\sample}{\\samplecustom{1}{n}}\n\n\\newcommand{\\distbernoulli}{\\textrm{Bern}}\n\\newcommand{\\distbinomial}{\\textrm{Bin}}\n\\newcommand{\\distpoisson}{\\textrm{Pois}}\n\\newcommand{\\distgeometric}{\\textrm{G}}\n\\newcommand{\\disthypergeometric}{\\textrm{Hy}}\n\\newcommand{\\distuniform}{\\textrm{U}}\n\\newcommand{\\distnormal}{\\textrm{N}}\n\\newcommand{\\distexponential}{\\textrm{Exp}}\n\\newcommand{\\distgamma}{\\Gamma}\n\\newcommand{\\distchisquare}{\\chi^2}\n\\newcommand{\\diststudentt}{\\textrm{t}}\n\\newcommand{\\distf}{\\textrm{F}}\n\n\\newcommand{\\param}{\\theta}\n\\newcommand{\\estim}{\\hat{\\theta}}\n\\newcommand{\\limit}[2]{\\underset{#1 \\rightarrow #2}{\\lim}}\n\\newcommand{\\mean}{\\overline{X}}\n\\newcommand{\\quantile}[2]{\\textrm{#1-quantile}_{#2}}\n\\newcommand{\\qquantile}[1]{\\quantile{q}{#1}}\n\\newcommand{\\qqquantile}[1]{\\textrm{quantile}_{#1}}\n\\newcommand{\\med}{\\textrm{MED}}\n\\newcommand{\\mad}{\\textrm{MAD}}\n\\newcommand{\\var}{\\textrm{Var}}\n\\newcommand{\\statspace}{\\left( \\mathcal{H}, \\mathcal{A}, \\mathcal{P} = \\left\\{ p_\\theta : \\theta \\in \\Theta \\right\\} \\right)}\n\n\\begin{document}\n\n\\title{Theory and formulas for \\emph{Computer Statistics} course on MiNI on WUT}\n\\date{\\today}\n\\author{Mateusz Bysiek, Computer Science, MiNI, WUT}\n\\maketitle\n\n%\\pagebreak[4]\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Theory}\n\n\\subsection{Review of probability theory}\n\n\\subsubsection{Review of basic probability distributions}\n\\begin{multicols}{2}\n\\input{cs_1_probability}\n\\end{multicols}\n\n\\newpage\n\n\\subsection{Descriptive statistics}\n\n\\subsubsection{Basic notions}\n\\input{cs_2a_basics}\n\n\\newpage\n\n\\begin{multicols}{2}\n\n\\subsubsection{Measures of location: central tendency}\n\\input{cs_2b_measures_central}\n\n\\vfill\n\\columnbreak\n\n\\subsubsection{Measures of location: position}\n\\input{cs_2c_measures_position}\n\n\\subsubsection{Measures of dispersion}\n\\input{cs_2d_measures_dispersion}\n\n\\subsubsection{Measures of shape}\n\\input{cs_2e_measures_shape}\n\n\\end{multicols}\n\n\\newpage\n\n\\subsection{Inferential statistics}\n\n\\subsubsection{Basics, more on probability distributions}\n\n\\begin{multicols}{2}\n\\input{cs_3_probability_adv}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Point estimation}\n\n\\begin{multicols}{2}\n\\input{cs_4_estim_point}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Interval estimation}\n\n\\begin{multicols}{2}\n\\input{cs_5a_estim_interval}\n\\end{multicols}\n\n\\subsubsection{Selected confidence intervals}\n\n\\begin{multicols}{3}\n\\input{cs_5b_estim_interval_example}\n\\end{multicols}\n\n\\subsubsection{Planning experiments}\n\n\\begin{multicols}{2}\n\\input{cs_6_planning}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Hypothesis testing}\n\n\\begin{multicols}{2}\n\\input{cs_7a_tests}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Selected parametric tests}\n\n\\begin{multicols}{2}\n\\input{cs_7b_tests_parametric_example}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Advanced hypothesis testing}\n\n\\begin{multicols}{2}\n\\input{cs_7c_tests_adv}\n\\end{multicols}\n\n\\subsubsection{Selected non-parametric tests}\n\n\\begin{multicols}{2}\n\\input{cs_7d_tests_nonparam_example}\n\\end{multicols}\n\n\\newpage\n\n\\subsubsection{Linear regression}\n\n\\begin{multicols}{2}\n\\input{cs_8_regression}\n\\end{multicols}\n\n\\newpage\n\n\\hspace{0pt}\n\n\\newpage\n\n\\thispagestyle{empty}\n\n\\section{Formulas for the exam}\n\n\\section*{Formulas: confidence intervals}\n\\begin{multicols}{3}\n\\input{cs_5b_estim_interval_example}\n\\end{multicols}\n\n\\section*{Formulas: non-parametric tests}\n\\begin{multicols}{2}\n\\input{cs_7d_tests_nonparam_example}\n\\end{multicols}\n\n\\newpage\n\n\\thispagestyle{empty}\n\n\\section*{Formulas: parametric tests}\n\\begin{multicols}{2}\n\\input{cs_7b_tests_parametric_example}\n\\end{multicols}\n\n\\newpage\n\n\\section{Sources, references}\n\nIf you find any mistakes, please send message to \\url{bysiekm {at} student.mini.pw.edu.pl}\n\n\\vspace{10pt} \\noindent Thanks to\\ldots\n\\begin{itemize}\n  \\item P. Grzegorzewski and M. Gągolewski, for this whole theory and formulas\n  \\item group AP, for many of the formulas\n  \\item Karo, for notes\n  \\item lots of other people, for suggestions, corrections, etc.\n  \\item Wikipedia\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "a95b9d7445f6009b563384abfd7d2183edaef482", "size": 4837, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cs.tex", "max_stars_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_stars_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cs.tex", "max_issues_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_issues_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cs.tex", "max_forks_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_forks_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6028037383, "max_line_length": 125, "alphanum_fraction": 0.7661773827, "num_tokens": 1583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.8152324803738429, "lm_q1q2_score": 0.417167996901458}}
{"text": "\\documentclass{article} \n\n% the purpose of this particular document is to serve as a staging area potential blog posts, for the purpose of editing, revision, and review. \n\n% packages \n\t\\usepackage{amsmath, amsthm, mathtools}\n\t\\usepackage{mdframed}  \n\t\\usepackage{geometry, enumerate} \n\t\\usepackage{parskip}\n\t\\usepackage{graphicx}\n\n% theorems and such \n  \t\\newtheorem{theorem}{Theorem}\n  \t\\newtheorem{corollary}{Corollary}\n  \t\\newtheorem{lemma}[theorem]{Lemma} \n  \t\\newtheorem*{remark}{Remark}\n  \t\\newtheorem*{exe}{Exercise}\n  \t\\newtheorem{prop}{Proposition}\n  \t\\newtheorem{example}{Example}  \n  \t\n% custom commands \n\t\\newcommand{\\ceil}[1]{\\left \\lceil #1 \\right \\rceil}\n\t\\newcommand{\\floor}[1]{\\lfloor #1 \\rfloor}\n\t\\newcommand{\\X}[1]{\\, \\text{mod} \\, #1}\n\t\\newcommand{\\divv}{\\,|\\,}\n\t\\newcommand{\\GCD}[2]{GCD\\,(#1, #2)}\n\t\\newcommand{\\LCM}[2]{LCM\\,(#1, #2)}\n\n\\begin{document} \n\n\\title{Elementary Number Theory : \\S 2} \n\\author{Henry Slayer $|$ University of California, Santa Cruz} \n\\date{}\n\\maketitle\n\n\\section*{Linear Diophantine Equations} \nThe Euclidean algorithm studies the relationships between numbers, comparing their parts, and measuring how two integers can be decomposed into smaller and smaller portions of themselves. This decomposition is governed by the greatest common divisor, which exists hand in hand with the least common multiple, as we have seen. Rising more or less naturally from the interplay between various integers, we encounter linear Diophantine equations. A linear Diophantine equation is an equation of the form \n\\[ax + by = c\\] \nFor integers $a, b, c, x, y$. This probably isn't the first time that you've seen an equation of this form. It's really nothing more than a line in $\\mathbf{R}^2$. However, our approach to these types of equations will likely be different from what's typically done in high school algebra or calculus courses. We are interested in three things \n\\begin{enumerate}[(i)]\n\\item Does $ax + by = c$ have integer solutions? \n\\item Provided it does, how do we find them? \n\\item Given (i) and (ii), can we generalize infinite families of integer solutions? \n\\end{enumerate} \nThe answer to the first question is a blunt consequence of divisibility, and our method of solution will give us direction for the latter two questions. \n\n\\subsubsection*{Solubility of Linear Diophantine Equations} \nWe find that solubility os $ax + by = c$ is a direct consequence of $\\GCD{a}{b}$. \n\\begin{mdframed} \n\\begin{theorem} \nLet $a, b, c, x, y$ be integers. Then, the equation $ax + by = c$ has integer solutions $(x, y)$ if and only if $\\GCD{a}{b}\\divv c$. \n\\end{theorem} \n\\begin{proof} \nFirst, assume that $ax + by = c$ has an integer solution. By the properties of the greatest common divisor, $\\GCD{a}{b}\\divv ax$, $\\GCD{a}{b}\\divv by$, and so $\\GCD{a}{b}$ must also divide $c$. \\\\\nConversely, suppose that $\\GCD{a}{b}\\divv c$. In the penultimate line of Euclid's algorithm, when performed on $a$ and $b$, we will obtain something that looks like \n\\[r_i = q_{i+1}(r_{i+1}) + \\GCD{a}{b}\\]\nPulling the quotient to one side, we obtain \n\\[r_i = q_{i+1}(r_{i+1}) = \\GCD{a}{b}\\]\nNow, the left-hand side of the equation above, through the iterative process of back-substitution, can bring us back to a linear combination of our initial values $a$ and $b$ (as we will show in a subsequent example). Thus, for integers $x_0, y_0$, \n\\[ax_0 + by_0 = \\GCD{a}{b}\\]\nAs $\\GCD{a}{b}\\divv c$, this equation can be scaled to \n\\[ax + by = c\\]\nfor integers $x$ and $y$. \n\\end{proof} \n\\end{mdframed} \nThe converse of the theorem above suggests a method for finding a particular solution to linear diophantine equations. This method is effective, and we do most of the work in the beginning, when we're seeking to determine if $c$ is a multiple of the greatest common divisor.  \n\\begin{mdframed} \n\\begin{example} \nDoes $763x + 129y = 1$ have integer solutions? If so, find a particular solution $(x, y)$. \n\\end{example} \n\\begin{proof}\nWe know that this equation will have integer solutions if 1 is a multiple of the greatest common divisor of 763 and 129. In this case, then, the greatest common divisor must be 1. So, we proceed by Euclid's algorithm. \n\\begin{align}\n763 &= 5(129) + 118 \\\\\n129 &= 1(118) + 11 \\\\\n118 &= 10(11) + 8 \\\\\n11 &= 1(8) + 3 \\\\\n8 &= 2(3) + 2 \\\\ \n3 &= 1(2) + 1\\\\\n2 &= 2(1) + 0 \n\\end{align} \nThe second-to-last line tells us that 763 and 129 have a greatest common divisor of 1, which means that we can find integer solutions for the equation above. To find a particular solution, all that we need to do is reverse the Euclidean algorithm, working our way back up by reverse-substitution. Because Euclid's algorithm gives us a system of equations, we can 'look up' to the line above, and make substitutions to bring ourselves closer to our initial values of $a$ and $b$. Starting with the final line: \n\\begin{align*} \n1 &= 3 - 2(1) \\\\\n &= 3 - (8 - 2(3)) = 3(3) - 8 \\qquad \\quad \\textit{by line 5} \\\\\n &= 3(11 - 8) - 8 = 3(11) - 4(8) \\qquad \\quad \\textit{by line 4} \\\\\n &= 3(11) - 4(118 - 10(11)) = 43(11) - 4(118) \\qquad \\textit{by line 3}  \\\\\n &= 43(129 - 118) - 4(118) = 34(129) - 47(118) \\qquad \\textit{by line 2}\\\\\n &= 43(129) - 47(763 - 5(129)) \\qquad \\quad \\textit{by line 1} \\\\\n &= 278(129) - 47(763)   \n\\end{align*}  \nSo, our particular solution to the equation $736x + 129y = 1$ is $(-47, 278)$. \n\\end{proof} \n\\end{mdframed} \nThis method is extremely effective for finding particular solutions to linear diophantine equations. However, the bookkeeping can certainly get a bit tangled, and it's easy to get lost in the line-by-line calculations. Be sure to check your work along the way. \n\n\\subsubsection*{Families of Solutions} \nSo, we've determined that $ax + by = c$ is solvable, and we've found some integral solution $(x_0, y_0)$, all thanks to the Euclidean algorithm. To characterize \\textit{all} solutions to a given linear diophantine equation, we turn our attention towards a clever use of \\textit{homogeneous} linear diophantine equations, which look like \n\\[ax + by = 0\\] \nSo, suppose that $ax + by = c$ is satisfied by a particular solution $(x_0, y_0)$. If we consider $x$ and $y$ to be 'general solution' terms, it follows, then, that \n\\[ax + by = ax_0 + by_0 = c\\]\nWhich, in turn, means that \n\\[a(x-x_0) + b(y - y_0) = 0\\]\n\\[a(x-x_0) = - b(y - y_0)\\]\nWe interpret this equality to generate 'solution sets' for the linear diophantine form $ax +by = c$, provided that it is solvable. We'll prove the general case for one term, and the second follows by symmetry. \\\\\nBecause we have equality above, we know that $-b(y-y_0)$ must be a multiple of the $\\LCM{a}{b}$. So, assume then that \n\\[a(x - x_0) = n \\cdot \\LCM{a}{b} \\]\nWhich means \n\\[x = x_0 + \\frac{n\\cdot\\LCM{a}{b}}{a}\\]\nFurthermore, the $GCD/LCM$ product formula tells us that $\\frac{\\LCM{a}{b}}{a} = \\frac{b}{\\GCD{a}{b}}$. So, given $ax + by = c$, and a particular solution $(x_0, y_0)$, we can generate all solutions for $x$ by \n\\[x = x_0 + \\frac{n\\cdot b}{\\GCD{a}{b}}\\]\nA similar argument justifies the following for $y$ \n\\[y = y_0 - \\frac{n\\cdot a}{\\GCD{a}{b}}\\] \nWhere the sign has been flipped, and $n$ is the same $n$ as above (as $a(x-x_0) = -b(y - y_0) = n \\cdot \\LCM{a}{b}.$\n\\begin{mdframed}  \n\\begin{theorem} \nLet $a, b, c, x, y$ be integers. Then, the equation $ax + by = c$ has integer solutions when $\\GCD{a}{b}\\divv c$. Based on a particular solution $(x_0, y_0)$, all solutions to this equation can be generated by \n\\[x = x_0 + \\frac{n\\cdot b}{\\GCD{a}{b}}, \\qquad y = y_0 - \\frac{n\\cdot a}{\\GCD{a}{b}}\\]\n\\end{theorem} \n\\end{mdframed} \nWriting these expressions in terms of the $GCD$ is more out of preference rather than necessity. The $GCD$ arises naturally when we perform the Euclidean algorithm, and so it's favorable to capitalize on this construction's computational convenience.\\\\\\\\ We can extend our study of linear diophantine equations into three variables (and more!). The process is mostly the same, so we will simply conclude this section with an example.  \n\n\\subsubsection*{Linear Diophantine Equations in 3 Variables} \nExtending into a 3-variable case can be a bit tricky. For equations of the form $ax + by + cz = d$, we need to work in parts, solving for pariwise sub-relationships that tie the three-variable dynamic together. \\\\ \n\\begin{mdframed} \n\\begin{example} \nLet $x, y, z$ be integers. Characterize all integer solutions to the equation $3x + 5y + 4z = 9$, if such integer solutions exist. \n\\end{example} \n\\begin{proof} \nThe first thing that we want to do is ensure that the $GCD(a, b, c)$ is a divisor of 9. A quick look tells us that because 3 and 5 are prime, they share no common divisors, and neither divide 4. Thus, the three values are pairwise coprime, which means that $GCD(a, b, c) = 1$, and 1 certainly divides 9. So, we know that solutions certainly exist. In order to solve this equation, we're going to want to break it down into two smaller systems. We start by taking a look at $3x + 5y$. We know from solving two-variable LDE's that this linear combination will give us compound moves that are multiples of $\\GCD{a}{b}$. So, we start by solving this subsystem for $\\GCD{3}{5} = 1$. We find (and the reader should be sure to check) that $(2, -1)$ is a particular solution to $3x + 5y = 1$, which means that if $3x + 5y = v$, $x$ and $y$ will be characterized by $(2v, -v)$. So, we store that information for later. It will come in handy. \\\\\nNow that we've established a connection between 3 and 5, we can use that 'common ratio' back in our original equation, which becomes \n\\[v + 4z = 9\\]\nA quick glance tells us that $(1, 2)$ is a particular $(v, z)$ solution, which implies that \n\\[v = 1 + 4n, \\qquad z = 2 - n\\]\nAre our general solutions, which we obtained from the theorem proved earlier. Translating $v$ into the language of $x$ and $y$ by what we had previously established, \n\\[x = 2v = 2 + 8n, \\quad y = -v = -1 -4n, \\quad z = 2 - n\\]\nAnd so, we've obtained general sets of solutions for $3x + 5y + 4z = 9$, by first solving a smaller linear relationship, which we then used as a placeholder to shed light on the larger linear dynamics at play. \n\\end{proof}\n\\end{mdframed} \n\\end{document}", "meta": {"hexsha": "f8f7d3567f7589c6887a2bbc9eaf07c3e562cc54", "size": 10171, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ENT2.tex", "max_stars_repo_name": "hcslayer/Elementary-Number-Theory", "max_stars_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ENT2.tex", "max_issues_repo_name": "hcslayer/Elementary-Number-Theory", "max_issues_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ENT2.tex", "max_forks_repo_name": "hcslayer/Elementary-Number-Theory", "max_forks_repo_head_hexsha": "5e0520285d36cb4ca971be28874c6fe1fbf357a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.65, "max_line_length": 935, "alphanum_fraction": 0.7027824206, "num_tokens": 3172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5312093733737562, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.41716328182755663}}
{"text": "\\section{The discretization of spatial differential operators}\n\n\\begin{myDef}[Conservative Operator]\nFor...\n\\begin{packed_itemize}\n  \\item a list of \\emph{domain variables}, $U := (u_0,\\cdots,u_{\\Lambda-1}) \\in \\ceins(\\Omega)^\\Lambda$ and\n  \\item a list of \\emph{codomain variables}, $W := (w_0,\\cdots,w_{\\Gamma-1}) \\in L^2(\\Omega)^\\Gamma$\n\\end{packed_itemize}\na mapping\n\\[\nOp:\\ceins(\\Omega)^\\Lambda \\rightarrow L^2(\\Omega)^\\Gamma, \\ U \\mapsto W = Op(U)\n\\]\nis called \\emph{conservative operator} if\nevery codomain variable $w_\\gamma$ can be written as\n\\[\n  w_\\gamma = \\divergence{ \\vec{f}_\\gamma(\\vec{x},U) } + q_\\gamma(\\vec{x},U).\n\\]\nThe functions\n\\begin{packed_itemize}\n \\item $ \\vec{f}_\\gamma(\\vec{x},U) \\in \\left( \\ceins (\\real^D \\times \\real^\\Lambda) \\right)^D$\n      are called the flux and\n \\item $  q_\\gamma(\\vec{x},U) \\in L^2(\\real^D \\times \\real^\\Lambda)$\n      are called the source\n\\end{packed_itemize}\nof codomain variable $w_\\gamma$.\n\\label{ConservativeOp}\n\\end{myDef}\n\n\\begin{myNot}[Outer normal]\nFor $\\vec{x} \\in \\partial K_j$, $\\vec{n}_\\vec{x} \\in \\partial \\mathcal{S}_D$ denotes an outer normal\nfield for $K_{\\tau(j)}$, for\nthose points of $\\partial K$ where an outer normal is defined, which may not be the case\nfor a null-subset of $\\partial K$\ni.e. ``edges'' and ``corners''.\n\\end{myNot}\n\n\\begin{myDef}[Conservative operators on product spaces of $DG_p$]\nAgain, like in (\\ref{ConservativeOp}), there is\na list of domain variables,\n$U := (u_0,\\cdots,u_{\\Lambda-1}) \\in DG_{(p_0, \\cdots, p_{\\Lambda-1})} =: Dom$\nand a list of codomain variables\n$W := (w_0,\\cdots,w_{\\Gamma-1}) \\in DG_{(l_0, \\cdots, l_{\\Gamma-1})} =: Cod$.\nA mapping\n\\[\n OP_h :\n DG_{p_0} \\times \\cdots \\times DG_{p_{\\Lambda-1}}\n \\rightarrow\n DG_{l_0} \\times \\cdots \\times DG_{l_{\\Gamma-1}},\n \\\n U \\mapsto W = Op_h(U)\n\\]\nis called a DG-discretization of the conservative operator $Op$\nif the $n$-th DG coordinate of variable $w_\\gamma$ in cell $K_{\\tau(j)}$, $\\tilde{w}_{\\gamma,j,n}$\ncan be written as\n\\[\n  \\tilde{w}_{\\gamma,j,n} =\n  \\int_{\\partial K_{\\tau(j)}}\n       F_\\delta \\ \\phi_{j,n}\n  \\ \\textrm{dS}\n  -\n  \\int_{K_{\\tau(j)}} \\left(\n       \\vec{f}_\\gamma \\cdot \\nabla \\phi_{j,n}\n       -\n       q_i \\ \\Phi_{j,n}\n  \\right) \\ \\textrm{d}\\vec{x}\n  .\n\\]\nThe function $F_\\delta(\\vec{x},U^\\textrm{in},U^\\textrm{out},\\vec{n}_\\vec{x})$ is called the \\emph{Riemannian}\nfor the flux $\\vec{f}_\\gamma(\\vec{x},U)$. Their properties are described in below, see (\\ref{riemannians}).\nHere, for $\\vec{x} \\in \\partial K_{\\tau(j)}$\n\\[\n  U^\\textrm{in} := \\lim_{\\stackrel{\\vec{y} \\rightarrow \\vec{x}}{\\vec{y} \\in K_{\\tau(j)}}}(U(\\vec{y}))\n  \\textrm{ and }\n  U^\\textrm{out} := \\lim_{\\stackrel{\\vec{y} \\rightarrow \\vec{x}}{\\vec{y} \\notin K_{\\tau(j)}}}(U(\\vec{y}))\n  .\n\\]\nBy coordinate mappings, the conservative operator can be written as a mapping\n\\[\n  Op_h: \\real^{dim(Dom)} \\rightarrow \\real^{dim(Cod)}, \\quad \\tilde{U} \\mapsto \\tilde{W}.\n\\]\n\\label{ConservativeOp_h}\n\\end{myDef}\n\n\\begin{myRem}[On Riemannians]\nThe following properties are essential for proper defined Riemannians:\n\\begin{packed_itemize}\n  \\item $F_\\gamma(\\vec{x},U,U,\\vec{n}_{\\vec{x}}) = \\vec{n}_{\\vec{x}} \\cdot \\vec{f}_\\gamma(\\vec{x},U)$,\n  i.e ``$F_\\gamma$ is an approximation to $\\vec{n}_{\\vec{x}} \\cdot \\vec{f}_\\gamma$''\n  \\item $F_\\gamma(\\vec{x},U,V,\\vec{n}_{\\vec{x}}) = -F_\\gamma(\\vec{x},V,U,-\\vec{n}_{\\vec{x}})$\n  \\item $\\left| F_\\gamma(\\vec{x},U,V,\\vec{n}_{\\vec{x}}) - \\vec{n}_{\\vec{x}} \\cdot \\vec{f}_\\gamma(\\vec{x},U) \\right| \\leq L | U-V |$\n  for some Lipschitz constant $L \\in \\realpos$\n\\end{packed_itemize}\n\\label{riemannians}\n\\end{myRem}\n\n\\begin{myDef}[Consistency of operators]\nAn operator $Op_h$ like in (\\ref{ConservativeOp_h}) is called consistent\nwith an operator $Op$ like in (\\ref{ConservativeOp}) with convergence\norder $k$ if\n\\[\n \\left\\| Op_h(Proj_p(U)) - Proj_p( Op(U) ) \\right\\|_2 \\leq h_\\textrm{max}^k \\cdot c(U)\n\\]\nfor any $U \\in \\ceins(\\Omega)^\\Lambda$ and a constant $c(U) \\in \\realpos$ which depends on $U$.\n\\label{consistency_of_operators}\n\\end{myDef}\n\n\\begin{myRem}\nThe motivation for (\\ref{consistency_of_operators}) is the\nfollowing ``approximately'' commutative diagram:\n%\\begin{center}\n\\[\n\\begin{xy}\n  \\xymatrix{\n      H^1(\\Omega)^\\Lambda \\ar[r]^{Op} \\ar[d]_{Proj}  &   (L^2(\\Omega))^\\Gamma  \\ar[d]^{Proj}  \\\\\n      \\prod_\\delta DG_{p_\\delta} \\ar[r]_{Op_h}       &  \\prod_\\gamma DG_{l_\\gamma}\n  }\n\\end{xy}\n% ----------------------------------------#\n\\quad\n\\begin{xy}\n  \\xymatrix{\n      U \\ar@{|->}[rrrr]^{Op} \\ar@{|->}[d]_{Proj} & &             &          &  W  \\ar@{|->}[d]^{Proj}  \\\\\n      U_h \\ar@{|->}[rr]_{Op_h}                   & &  Op_h(U_h)  &  \\approx &  W_h\n  }\n\\end{xy}\n\\]\n(Here, $Proj$ is an abbreviation for\n$( Proj_{p_0}, \\cdots, Proj_{p_{\\Lambda-1}} )$\nand\n$( Proj_{l_0}, \\cdots, Proj_{l_{\\Gamma-1}} )$.\n\\end{myRem}\n\n\\begin{myRem}[Additive component decomposition of conservative operators in BoSSS]\nIn BoSSS, a conservative operator is called\n\\emph{spatial difference operator}\\coderm{BoSSS.Foundation.SpatialDifferenceOperator}\nand is specified as an additive composition of operators, which are called\n\\emph{equation components}\\coderm{BoSSS.Foundation.IEquationComponent}.\nThe domain and codomain variables for the  spatial difference operator, are specified as lists\nof symbolic names\\coderm{BoSSS.Foundation.SpatialDifferentialOperator.DomainVar} \\coderm{BoSSS.Foundation.SpatialDifferentialOperator.CodomainVar}.\nEach equation component itself is a conservative operator with exactly one codomain variable,\ni.e. it maps $\\prod_\\delta DG_{p_\\gamma} \\rightarrow DG_l$.\nThe domain variables of the equation components are specified as some\nsub-list\\coderm{BoSSS.Foundation.IEquationComponent.ArgumentOrdering}\nof the domain variables list of the spatial difference operator.\nThe equation components may be classified into \\emph{fluxes} and \\emph{sources},\nand wether they are either \\emph{linear} or \\emph{nonlinear}:\n\\begin{packed_itemize}\n  \\item nonlinear fluxes\\coderm{BoSSS.Foundation.INonlinearFlux},\\coderm{BoSSS.Foundation.INonlinearFluxEx};\n  \\item nonlinear sources\\coderm{BoSSS.Foundation.INonlinearSource};\n  \\item linear fluxes\\coderm{BoSSS.Foundation.ILinearFlux};\n  \\item linear sources\\coderm{BoSSS.Foundation.ILinearSource};\n\\end{packed_itemize}\nIf more than one equation component is specified for one codomain variable, they are\nadded\\coderm{BoSSS.Foundation.SpatialDifferentialOperator.EquationComponents}.\n\\end{myRem}\n\n\\begin{myRem}[Evaluation of conservative operators in BoSSS]\nA conservative operator, or spatial differential operator $Op_h$ can be evaluated\nin BoSSS\nby\\coderm{BoSSS.Foundation.SpatialDifferentialOperator.Evaluate(...)}\nor\\coderm{BoSSS.Foundation.SpatialDifferentialOperator.Evaluator.Evaluate(...)}.\nIf $Op_h$ is affine-linear, i.e.\n\\[\n  Op_h(\\tilde{U}) = \\mathcal{M} \\cdot \\tilde{U} + b,\n\\]\nthe (sparse) matrix $\\mathcal{M}$ and the affine vector $b$ can\nbe computed\nby\\coderm{BoSSS.Foundation.SpatialDifferentialOperator.ComputeMatrix(...)}.\n\\end{myRem}\n\n\n%\\subsection{Nonlinear fluxes}\n\n%\\subsection{Nonlinear sources}\n\n\n%\\subsection{Linear sources}\n\n%\\subsection{Fluxes for Interior Penalty Methods}\n", "meta": {"hexsha": "6a91c1a160e4796d31651d9384781367bceabf31", "size": 7138, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/notes/0001-L2_Manual/layer_2_fluxes.tex", "max_stars_repo_name": "FDYdarmstadt/BoSSS", "max_stars_repo_head_hexsha": "974f3eee826424a213e68d8d456d380aeb7cd7e9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 22, "max_stars_repo_stars_event_min_datetime": "2017-06-08T05:53:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T13:12:17.000Z", "max_issues_repo_path": "doc/notes/0001-L2_Manual/layer_2_fluxes.tex", "max_issues_repo_name": "leyel/BoSSS", "max_issues_repo_head_hexsha": "39f58a1a64a55e44f51384022aada20a5b425230", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-07-20T15:32:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-20T15:34:22.000Z", "max_forks_repo_path": "doc/notes/0001-L2_Manual/layer_2_fluxes.tex", "max_forks_repo_name": "leyel/BoSSS", "max_forks_repo_head_hexsha": "39f58a1a64a55e44f51384022aada20a5b425230", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2018-01-05T19:52:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-07T07:49:27.000Z", "avg_line_length": 39.6555555556, "max_line_length": 147, "alphanum_fraction": 0.6857663211, "num_tokens": 2406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4170585218676458}}
{"text": "%!TEX root = morusAC.tex\n\n\\section{Trail for Full \\MORUS}\n\\label{sec/fulltrails}\n\nIn the previous section, we presented a linear trail for the reduced ciphers \\MiniMORUS[1280] and \\MiniMORUS[640]. We now turn to the full ciphers \\MORUS[1280] and \\MORUS[640].\n\n\\subsection{Symmetrizing the Trail}\nIn order to build a trail for the full \\MORUS, we proceed exactly as we did for \\MiniMORUS, following the same path down to step and word rotation values, with one difference: in order to move from the one-word registers of \\MiniMORUS to the four-word registers of full \\MORUS, we make every term $S^t_{i,j}$ and $C^t_j$ symmetric, in the sense of \\Cref{sec/introminimorus}.\nThat is, for every $S^t_{i,j}$ (resp. $C^t_j$) component in every trail fragment and every equation, we \\emph{symmetrize} the term by adding in the terms $S^t_{i,j+w}$, $S^t_{i,j+2w}$, $S^t_{i,j+3w}$ (resp. $C^t_{j+w}$, $C^t_{j+2w}$, $C^t_{j+3w}$), where as usual $w$ denotes the word size. For example, if $w=64$ (for \\MORUS[1280]), the term $S^3_{2,0}$ is symmetrized into:\n\\[\nS^3_{2,0} \\oplus S^3_{2,64} \\oplus S^3_{2,128} \\oplus S^3_{2,192}.\n\\]\n\nThus, translating the trail from one of the \\MiniMORUS ciphers to the corresponding full \\MORUS cipher amounts to making every linear combination symmetric---indeed, that was the point of introducing \\MiniMORUS in the first place.\nConcretely, in order to build the full trail equation for \\MORUS, we write symmetric versions of equations $A^t_i$, $B^t_i$, $C^t_i$, $D^t_i$, $E^t_i$ from \\Cref{sec:minitraileq}, and then combine them in exactly the same manner as before.\nThis way, the biased linear combination on \\MiniMORUS[1280] given in \\Cref{sec:minitraileq}, namely:\n\\begin{align*}\n&C^0_{51} \\oplus C^1_{0} \\oplus C^1_{25} \\oplus C^1_{33} \\oplus C^1_{55} \\oplus C^2_{4} \\oplus C^2_{7} \\oplus C^2_{29} \\oplus C^2_{37}\\\\\n\\oplus\\; &C^2_{38} \\oplus C^2_{46} \\oplus C^2_{51} \\oplus C^3_{11} \\oplus C^3_{20} \\oplus C^3_{42} \\oplus C^3_{50} \\oplus C^4_{24}\n\\end{align*}\nultimately yields the following biased symmetrized linear combination on the full \\MORUS[1280]:\n\\begin{align*}\n&C^0_{51} \\oplus C^0_{115} \\oplus C^0_{179} \\oplus C^0_{243} \\oplus C^1_{0} \\oplus C^1_{25} \\oplus C^1_{33} \\oplus C^1_{55} \\oplus C^1_{64} \\oplus C^1_{89}\\\\\n\\oplus\\; & C^1_{97} \\oplus C^1_{119} \\oplus C^1_{128} \\oplus C^1_{153} \\oplus C^1_{161} \\oplus C^1_{183} \\oplus C^1_{192} \\oplus C^1_{217} \\oplus C^1_{225} \\oplus C^1_{247}\\\\\n\\oplus\\; & C^2_{4} \\oplus C^2_{7} \\oplus C^2_{29} \\oplus C^2_{37} \\oplus C^2_{38} \\oplus C^2_{46} \\oplus C^2_{51} \\oplus C^2_{68} \\oplus C^2_{71} \\oplus C^2_{93}\\\\\n\\oplus\\; & C^2_{101} \\oplus C^2_{102} \\oplus C^2_{110} \\oplus C^2_{115} \\oplus C^2_{132} \\oplus C^2_{135} \\oplus C^2_{157} \\oplus C^2_{165} \\oplus C^2_{166} \\oplus C^2_{174}\\\\\n\\oplus\\; & C^2_{179} \\oplus C^2_{196} \\oplus C^2_{199} \\oplus C^2_{221} \\oplus C^2_{229} \\oplus C^2_{230} \\oplus C^2_{238} \\oplus C^2_{243} \\oplus C^3_{11} \\oplus C^3_{20}\\\\\n\\oplus\\; & C^3_{42} \\oplus C^3_{50} \\oplus C^3_{75} \\oplus C^3_{84} \\oplus C^3_{106} \\oplus C^3_{114} \\oplus C^3_{139} \\oplus C^3_{148} \\oplus C^3_{170} \\oplus C^3_{178}\\\\\n\\oplus\\; & C^3_{203} \\oplus C^3_{212} \\oplus C^3_{234} \\oplus C^3_{242} \\oplus C^4_{24} \\oplus C^4_{88} \\oplus C^4_{152} \\oplus C^4_{216}\n\\end{align*}\nWe refer the reader to \\Cref{sec:traileq} for the corresponding linear combination on \\MORUS[640].\n\n\\subsection{Correlation of the Full Trail}\n\nThe symmetrized trail on full \\MORUS may be intuitively understood as consisting of four copies of the original trail on \\MiniMORUS. Indeed, the only difference between full \\MORUS (for either version of \\MORUS) and four independent copies of \\MiniMORUS comes from register-wise rotations, which permute words within a register. But as observed in \\Cref{sec/introminimorus}, register-wise rotations leave symmetric linear combinations invariant; and so, insofar as we only ever use symmetric linear combinations on all registers along the trail, register-wise rotations have no effect.\n\nFollowing the previous intuition, one may expect that the weight of the symmetrized trail should simply be four times the weight of the corresponding \\MiniMORUS trail, namely 64 for both \\MORUS[1280] and \\MORUS[640]. However, reality is a little more complex, as the symmetrized trail does not exactly behave as four copies of the original trail when one considers nonlinear terms.\n\nTo understand why that might be the case, assume a nonlinear term $S^0_{2,0} \\cdot S^0_{3,0}$ arising from some part of the trail, and another term $S^0_{2,0} \\cdot S^0_{3,w}$ arising from a different part of the trail (where $w$ denotes the word size). Then when we XOR the various trail fragments together, in \\MiniMORUS these two terms are actually equal and will cancel out, since register-wise rotations by multiples of $w$ bits are ignored. However in the real \\MORUS these terms are of course distinct and do not cancel each other.\n\nIn the actual trail for (either version of) full \\MORUS, this exact situation occurs when combining trail fragments $\\beta^t_i$ and $\\gamma^t_i$. Indeed, $\\beta^t_i$ requires approximating the term $S^t_{2,i} \\cdot S^t_{3,i}$, while $\\gamma^t_i$ requires approximating the term $S^t_{2,i} \\cdot S^t_{3,i-w}$ (cf. \\Cref{fig:trailcollision}). While in \\MiniMORUS, these terms cancel out, in the full \\MORUS, when adding all symmetric copies of the trail, we end up with the sum:\n{\n\\allowdisplaybreaks[0]\n\\begin{align}\n&S^t_{2,i} \\cdot S^t_{3,i} \\oplus S^t_{3,i} \\cdot S^t_{2,i+w}\n\\oplus S^t_{2,i+w} \\cdot S^t_{3,i+w} \\oplus S^t_{3,i+w} \\cdot S^t_{2,i+2w}\\notag\\\\\n\\oplus\\; &S^t_{2,i+2w} \\cdot S^t_{3,i+2w} \\oplus S^t_{3,i+2w} \\cdot S^t_{2,i+3w}\n\\oplus S^t_{2,i+3w} \\cdot S^t_{3,i+3w} \\oplus S^t_{3,i+3w} \\cdot S^t_{2,i}.\\label{eq:8circle}\n\\end{align}\n}\nIt may be observed that the products occurring in the equation above involve eight terms forming a ring. The weight of this expression can be computed by brute force, and is equal to $3$.\n\n\\begin{figure}[t!]\n  \\substatesfalse\n  % \\substatesfalse to label state words and/or masks\n  \\centering\n  \\begin{subfigure}{.4\\textwidth}\n  \\centering\n  \\begin{tikzpicture}[xscale=0.75,yscale=1.5]%{{{\n    \\printstate\n    \\draw[trail, beta]\n      (C) -- node[right] {$i$} (lll-1)\n      (lll-1) -- (tlll-1) (lll-1) -- (xor-1) (xor-1) -- (xnd-1)\n      (tlll-1) -- (W-20) node[above] {$i$}\n      (xor-1) -- (txor-1) %(txor-1) -- (W-21) node[above] {$i$}\n      %(xnd-1) -- (and-1)\n      (W40) node[below] {\\phantom{$i$}}\n      ;\n    \\draw[trail, gamma]\n      %(W-21) node[above] {$i$}\n      (txor-1) -- (xnd1)\n      (xnd1) -- (xor1) (xor1) -- (lll1)\n      %(xnd1) -- (and1)\n      (xor1) -- (txor1)\n      (txor1) -- (W-24) node[above] {$i$}\n      (lll1) -- (W41) node[below] {$i+b_1$}\n      ;\n    %\\draw[trail, beta,  dotted] (and-1) -- (and-1-|and1);\n    %\\draw[trail, gamma, dotted] (and1)  -- (and-1-|and1) node[above, black] {=};\n    \\node (eq) at ($(and-1|-and1)+(-1,-2.4pt)$) {=};\n    \\draw[beta,{Circle[sep=-1.8pt]}-]  ($(and-1)+(0,-2.4pt)$) -| (eq);\n    \\draw[gamma,{Circle[sep=-1.8pt]}-] ($(and1)+(0,-2.4pt)$) -- (eq);\n  \\end{tikzpicture}%}}}\n  \\caption*{\\MiniMORUS: weight 0 (not 2)} %$S^{j,1}_i, S^{j,4}_i, S^{j+1,1}_{i-1}$ ($w\\!=\\!1$)}\n  \\end{subfigure}\n  \\qquad\n  \\begin{subfigure}{.4\\textwidth}\n  \\centering\n  \\begin{tikzpicture}[xscale=0.75,yscale=1.5]%{{{\n    \\printstate\n    \\draw[trail, beta]\n      (C) -- node[right] {$i$} (lll-1)\n      (lll-1) -- (tlll-1) (lll-1) -- (xor-1) (xor-1) -- (xnd-1)\n      (tlll-1) -- (W-20) node[above] {$i$}\n      (xor-1) -- (txor-1) %(txor-1) -- (W-21) node[above] {$i$}\n      (xnd-1) -- (and-1)\n      (W40) node[below] {\\phantom{$i$}}\n      ;\n    \\draw[trail, gamma]\n      %(W-21) node[above] {$i$}\n      (txor-1) -- (xnd1)\n      (xnd1) -- (xor1) (xor1) -- (lll1)\n      (xnd1) -- (and1)\n      (xor1) -- (txor1)\n      (txor1) -- (W-24) node[above] {$i$}\n      (lll1) -- (W41) node[below] {$i+b_1$}\n      ;\n    \\draw[trail, beta,  dashed] (and-1.east|-tanB-1) -- (tanB-1);\n    \\draw[trail, gamma, dashed] (tanB-1)  -- (tanB1) -- (tanB1-|and1.east);\n  \\end{tikzpicture}%}}}\n  \\caption*{\\MORUS: weight $4 \\times 1$ (not $4 \\times 2$)} %$S^{j,1}_i, S^{j,4}_i, S^{j+1,1}_{i-1}$ ($w\\!=\\!1$)}\n  \\end{subfigure}\n  \\caption{Weight of $\\beta^t_i \\oplus \\gamma^t_i$ for \\MiniMORUS and \\MORUS.}\n  \\label{fig:trailcollision}\n\\end{figure}\n\nFor \\MORUS[1280], since the trail fragment $\\gamma^t_i$ is used four times, this phenomenon adds a contribution of $4 \\cdot 3 = 12$ to the overall weight of the full trail. This results in a total weight of $4 \\cdot 16 + 12 = 76$ (recall that the weight of the trail on \\MiniMORUS[1280] is 16). We have confirmed this by explicitly computing the full trail equation in \\Cref{sec:traileq}, and evaluating its exact weight like we did for \\MiniMORUS in \\Cref{sec:minibias}. That is, since the equation is quadratic, we may view it as a graph, which we split into connected components; we then compute the weight of each connected component separately by brute force, and then add up the weights of all components per the Piling-Up Lemma. Overall, the full trail equation given in \\Cref{sec:traileq} yields a weight of 76 for the full trail on \\MORUS[1280].\n\nIn the case of \\MORUS[640], collisions between rotation constants further complicate the analysis. Specifically, when using trail fragment $\\beta^t_i$, the term $S^t_{2,i} \\cdot S^t_{3,i}$ occurs. As explained previously, a partial collision with the term $S^t_{2,i} \\cdot S^t_{3,i-w}$ from trail fragment $\\gamma^t_i$ results in \\Cref{eq:8circle}. However trail fragment $\\alpha^t_{i+d}$ is once used in the course of the full trail with an offset of $d = b_1+b_4-b_0-b_2$ (relative to $\\gamma^t_i$), which in the case of \\MORUS[640] is equal to $31+13-5-7 = 0 \\;\\text{mod}\\; 32$. This creates another term $S^t_{2,i} \\cdot S^t_{3,i}$, which ultimately destroys one of the four occurrences of \\Cref{eq:8circle}. Therefore, when computing the full trail equation on \\MORUS[640], we get that the weight of the trail is 73 (cf. \\Cref{sec:traileq}).\n\n%TODO: check $\\alpha_i \\oplus \\beta_i \\oplus \\gamma_i$ in step 2 of $\\cipher{MORUS-640}$\n%(maybe not relevant due to overall complexity\\dots)\n\n\\subsection{Taking Variable Plaintext into Account}\n\\label{subsec:variable}\n\nIn our analysis so far, for the sake of simplicity, we have assumed that all plaintext blocks are zero. We now examine what happens if we remove that assumption, and integrate plaintext variables into our analysis. What we show is that plaintext variables only contribute linearly to the trail. In other words, the full trail equation with plaintext variables is equal to the full trail equation with all-zero plaintext XORed with a linear combination of plaintext variables.\n\nTo see this, recall that plaintext bits contribute to the encryption process in two ways (cf. \\Cref{subsec/Spec}):\n\\begin{enumerate}\n\\item They are added to some bits derived from the state to form the ciphertext.\\label{item:1}\n\\item During each encryption step, the \\StateUpdate{} function adds a plaintext block to every register except $S_0$.\\label{item:2}\n\\end{enumerate}\n\nThe effect of \\Cref{item:1} is that whenever we use a ciphertext bit in our full trail equation, the corresponding plaintext bit also needs to be XORed in. Because ciphertext bits only contribute linearly to the trail equation, this only adds a linear combination of plaintext bits to the equation.\n\nRegarding \\Cref{item:2}, recall that the full trail equation is a linear combination of (the symmetrized version of) equations $A^t_i$, $B^t_i$, $C^t_i$, $D^t_i$, $E^t_i$ in \\Cref{sec:minitraileq}. Also observe that in each equation, state bits that are shifted by a word-wise rotation only contribute linearly. Because plaintext bits are XORed into each register at the same time word-wise rotation is performed, this implies that plaintext bits resulting from \\Cref{item:2} also only contribute linearly.\nIn fact in all cases, it so happens that updating the equation to take plaintext variables into account simply involves XORing in the plaintext bit $M^t_i$.\n\nIt may be observed that message blocks in the \\StateUpdate{} function only contribute linearly to the state, and in that regard play a role similar to key bits in an SPN cipher; and indeed in SPN ciphers, it is the case that key bits contribute linearly to linear trails \\cite{eurocryptMatsui93}. In this light the previous result may not be surprising.\n\nIn the end, with variable plaintext, our trail yields a biased linear combination of ciphertext bits and plaintext bits.\nIn regards to attacks, this means the situation is effectively the same as with a biased stream cipher: in particular if the plaintext is known we obtain a distinguisher; and if a fixed unknown plaintext is encrypted multiple times (possibly also with some known variable part) then our trail yields a plaintext recovery attack.\n\n%%% Local Variables:\n%%% TeX-master: \"morusAC\"\n%%% End:\n", "meta": {"hexsha": "6defccc0dd627aabdeb3995e170db49f60b2d828", "size": 12938, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "morusAC_05_Full_trails.tex", "max_stars_repo_name": "ildyria/MiniMorus", "max_stars_repo_head_hexsha": "168b27e059a46714bfe86af0cead20b4f6a51fcb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "morusAC_05_Full_trails.tex", "max_issues_repo_name": "ildyria/MiniMorus", "max_issues_repo_head_hexsha": "168b27e059a46714bfe86af0cead20b4f6a51fcb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "morusAC_05_Full_trails.tex", "max_forks_repo_name": "ildyria/MiniMorus", "max_forks_repo_head_hexsha": "168b27e059a46714bfe86af0cead20b4f6a51fcb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.8322147651, "max_line_length": 854, "alphanum_fraction": 0.6966300819, "num_tokens": 4462, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4170585218676458}}
{"text": "\\documentclass{beamer}\n\\usefonttheme[onlymath]{serif}\n\\usepackage[english]{babel}\t\t\t\t\t\t\t%For internationalization\n\\usepackage[utf8]{inputenc}\t\t\t\t\t\t\t%For character encoding\n\\usepackage{amsmath}\t\t\t\t\t\t\t\t%For mathematical typesetting\n\\usepackage{amssymb}\t\t\t\t\t\t\t\t%For mathematical typesetting\n\\usepackage{graphicx}\t\t\t\t\t\t\t\t%For handling graphics\n\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\bea}{\\begin{equation*}}\n\\newcommand{\\ben}[1]{\\begin{equation}\\label{#1}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\eea}{\\end{equation*}}\n\\newcommand{\\aq}{\\overset{\\sim}{q}}\n\n\\mathchardef\\mhyphen=\"2D\n\n\\title\n{An Introduction to Discontinuous Galerkin Methods}\n\\subtitle{Module 3B: To Higher-Orders - Discrete System}\n\\author[Bevan]\n{J.~Bevan}\n\\institute[UMass Lowell]\n{\n  Department of Mechanical Engineering, Grad Student\\\\\n  University of Massachusetts at Lowell\n}\n\\date[Fall 2014]\n{}\n\\subject{Discontinuous Galerkin}\n\n\\begin{document}\n\\frame{\\titlepage}\n\\frame{\\frametitle{Module 3B: To Higher-Orders - Discrete System}\\tableofcontents}\n\n%NEW SECTION\n\\section{Numerical Quadrature (Gauss)} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item We now have a method for generating a robust arbitrary order solution approximation, but unlike before it isn't practical to analytically pre-calculate all the integrals.\n\\item We can use a numerical quadrature technique to do this instead, able to integrate arbitrary functions\n\\item If we call the interpolation of a function $In f$ then we assume that for a sufficiently accurate interpolation, we can use the interpolation of the function wherever we could use the function itself before. This is in general M-1 order accurate.\n\\be f \\approx In f =\\sum_{i=0}^M f(x_i)L_i(x) \\ee\n\\end{itemize}\n\\be \\int f \\approx \\int In f = \\int \\sum_{i=0}^M f(x_i)L_i(x) =  \\sum_{i=0}^M f(x_i) \\int L_i(x) =  \\sum_{i=0}^M f(x_i)w_i\\ee\n}\n\n%NEW SECTION\n\\section{Hermite Interpolation (and quadrature)} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item Recall: Hermite interpolation includes derivatives of interpolated function as well\n\\item Consider a Hermite interpolation polynomial that includes first derivatives as well, the interpolation would be $2M-1$ accurate. The quadrature using this polynomial would look like:\n\\be \\int f \\, dx \\approx \\sum_{i=0}^M f(x_i)w_i+\\sum_{i=0}^M\\left[ f'(x_i)\\int (x-x_i)L_i^2(x) \\, dx \\right] \\ee\n\\item It turns out if we choose our quadrature/interpolation points to be the Legendre roots, the integral for the second term is zero. Thus no first derivative terms are needed for the Hermite quadrature, even though it is $2M-1$ order accurate.\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Truncation error/exact quadrature} \n\\frame[shrink]{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item It is important to consider error sources from the approximation to the solution and integrals, these can affect convergence\n\\item Three main error sources in quadrature: aliasing, truncation, and inexact quadrature\n\\item Aliasing occurs if the function is not sampled frequently enough, it is assumed that the sol'n is sufficiently smooth and the discretization suitably fine to avoid this in most cases\n\\item Truncation is unavoidable except where the exact function is of equal or lesser order than the interpolation/quadrature. Higher order terms present in the exact function are left off.\n\\item Inexact quadrature occurs when the total polynomial order of the product of the interpolated functions undergoing quadrature exceeds the exactness of the quadrature. For Gauss-Legendre quadrature this isn't a problem for one and even two functions in the integrand. Each function is of order M-1 and the quadrature is exact for 2M-1, so the quadrature is able to exactly integrate the interpolation\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{GL Lagrange Orthogonality} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item A final useful property of the Lagrange basis with Legendre interpolation points is orthogonality\n\\item The product of two $M-1$ order Lagrange bases can be rearranged to be a Legendre poly of order $M$ and a remainder polynomial of order $M-2$\n\\item The remainder polynomial can be expressed as a linear combination of Legendre polys all of order $<M$, all are orthogonal to the order $M$ Legendre, so\n\\be \\int_{-1}^1 L_i(x)L_j(x) \\,dx = \\delta_{ij}w_i \\ee\n\\end{itemize}\n}\n\n\n%NEW SECTION\n\\section{Local Mapping Function (Jacobian)} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item The domain of orthogonality for Legendre polynomials (and by extension GL Lagrange) is $[-1, 1]$\n\\item Elements may be arbitrary sizes though, we'd like to be able to transform $x \\in [x_L, x_R] \\rightarrow X \\in [-1, 1]$ by means of a mapping $x=g(X)$ and it's inverse $X=G(x)$\n\\be x=g(X)=\\frac{X+1}{2}\\Delta x + x_L\\quad ,\\quad X=G(x)=\\frac{2(x-x_L)}{\\Delta x}+1 \\ee\n\\item Applying a change of variables for the mapping\n\\be \\int_{x_L}^{x_R} L_i(x) L_j(x) \\,dx \\rightarrow \\int_{-1}^1 L_i(g(X))L_j(g(X)) g' \\, dX \\ee\n\\item $J=g'=\\frac{\\Delta x}{2}$ is called the determinant of the Jacobian matrix\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Mass Matrix- Diagonalization} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item We have done what seems like quite a bit of tangential work, but it now pays off\n\\be \\sum_{i=0}^M \\frac{d \\aq_i}{dt} \\int_k \\psi_i(x) \\phi_j(x) \\,dx = \\sum_{i=0}^M \\frac{d \\aq_i}{dt} \\int_I L_i(X) L_j(X) \\frac{\\Delta x}{2} \\,dX \\ee\n\\be=   \\frac{\\Delta x}{2} \\sum_{i=0}^M \\frac{d q_i}{dt} \\delta_{ij}w_i =  \\frac{\\Delta x}{2}q_j'w_j \\quad for\\,all\\, j \\ee\n\\item We've reduced the full mass matrix into a diagonal mass matrix with all other terms zero, compared to Module 2 solver case the mass matrix is trivially invertible. We have: $\\frac{\\Delta x}{2}\\mathbf{q' \\,M}$ where $\\mathbf{M}_{jj} = w_j$\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Log differentiation} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item We can get a closed form expression for $L_j'(x)$ in the stiffness term by using logarithmic differentiation\n\\item The main idea is that in general $f'/f = ln(f)$ so applying this to our Lagrange basis\n\\be L_j'(x) = L_j \\sum_{r=0,r\\neq j}^N \\frac{1}{x-x_r} \\ee\n\\item using our previous function code for \"\\textit{Lag(x)}\" we can get a general expression\n\\textit{dLag= @(x,nv) Lag(x,nv).*sum(1./bsxfun(@minus,x,nn(nv,:,:)),3)}\n\\item We need a more involved method for evaluation at the interp points (see dLagrange.m)\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Stiffness Integral} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item We now have a routine for calculating $L_j'$, and suitable quadrature; we can evaluate the stiffness integral\n\\be \\int_k \\, \\sum_{i=0}^M\\left[ c\\aq_i \\psi_i(x)\\right] \\phi'_j(x) \\,dx = \\sum_{i=0}^M c\\aq_i \\int_I L_i(X) L_j'(X) \\,dX \\ee\n\\item No Jacobian term from the mapping. The derivative in the integrand produces a complementary $1/J$ that cancels due to the change of variables.\n\\item No tricks to be had for reducing the stiffness matrix, it is a full matrix. We have: $c\\mathbf{K}_{ji} \\, \\mathbf{\\aq}$ \n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Numerical Flux (Extrapolated)} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item One downside of using Gauss-Legendre points is there are no points on the boundary\n\\item It is easy to calculate the boundary solution values from the solution interpolation at the left end (same idea for the right)\n\\be \\aq(x_L) = \\sum_{i=0}^M \\aq_i L_i(x_L) \\ee\n\\item Call $L_i(x_L) = L_{iL}$, the vector notation is then $\\aq_L = \\mathbf{L}_{iL}^T \\, \\mathbf{\\aq}$\n\\item So that our numerical flux vector is $\\mathbf{\\hat{f}} =c(\\overset{k}{q}_R\\mathbf{L}_{jR}-\\overset{k-1}{q_R}\\mathbf{L}_{jL})$\n\\item Lobatto alternative gives boundary points, but would make the mass matrix a full matrix. Inversion is likely more expensive than interpolation\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Assembly of System} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item We can now combine the mass, stiffness, and numerical flux terms\n\\be \\frac{\\Delta x}{2}\\mathbf{q' \\,M} + \\mathbf{\\hat{f}} -  c\\mathbf{K}_{ji} \\, \\mathbf{\\aq}=0 \\ee\n\\item solving for $q'$\n\\be \\mathbf{\\aq}' = \\frac{2}{\\Delta x} (c\\mathbf{K}_{ji} \\, \\mathbf{\\aq} -\\mathbf{\\hat{f}}) \\mathbf{M}^{-1} \\ee\n\\item it is also possible to represent it componentwise easily thanks to the diagonal mass matrix\n\\be \\aq_j' = \\frac{2}{w_j\\Delta x }(c \\mathbf{K}_{j\\mhyphen}\\mathbf{\\aq}-\\hat{f}_j)\\ee\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{RK4 Time discretization} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item Compared to the simple linear DG solver, we'd like to use a higher order time discretization, Runge-Kutta 4th order: RK4. We can express as a function: $\\mathbf{\\aq}'(\\mathbf{\\aq})$ from our discrete system. RK4 consists of 4 trial steps:\n\n$k_1 =  \\mathbf{\\aq}'(\\mathbf{\\aq}) \\, \\Delta t$\\\\\n$k_2 =  \\mathbf{\\aq}'(\\mathbf{\\aq}+\\frac{k_1}{2}) \\, \\Delta t$\\\\\n$k_3 =  \\mathbf{\\aq}'(\\mathbf{\\aq}+\\frac{k_2}{2}) \\, \\Delta t$\\\\\n$k_4 =  \\mathbf{\\aq}'(\\mathbf{\\aq}+k_3) \\, \\Delta t$\\\\\n$\\mathbf{q}(t+1) = \\mathbf{q} + \\frac{k_1}{6}+ \\frac{k_2}{3}+ \\frac{k_3}{3}+ \\frac{k_4}{6}$\n\\end{itemize}\n}\n\n%NEW SECTION\n\\section{Investigate p-Convergence} \n\\frame{\\frametitle{\\textbf{\\secname}}\n\\begin{itemize}\n\\item How does the p-convergence rate compare with h-convergence?\n\\item Does the smoothness of the initial sol'n seem to effect the rate of convergence? (e.g. sin(x) vs gaussian curve)\n\\item Does h or p refinement seem to be more efficient?\n\\end{itemize}\n}\n\n\\end{document}", "meta": {"hexsha": "a9c08db9f3da8cf44587f5f4a1c200d09a683d17", "size": 9559, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Module 3B/22_6xx-Module3B.tex", "max_stars_repo_name": "sconde/22_6xx-DG-for-PDEs", "max_stars_repo_head_hexsha": "34527e2fa77a193a58bd2f47f781833d70c59315", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 31, "max_stars_repo_stars_event_min_datetime": "2016-03-15T11:40:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-20T00:41:34.000Z", "max_issues_repo_path": "Module 3B/22_6xx-Module3B.tex", "max_issues_repo_name": "LuciaZhang9/22_6xx-DG-for-PDEs", "max_issues_repo_head_hexsha": "e9463ab6faee98af26102949e04ab8be75405154", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-03-15T11:50:32.000Z", "max_issues_repo_issues_event_max_datetime": "2016-03-20T08:48:32.000Z", "max_forks_repo_path": "Module 3B/22_6xx-Module3B.tex", "max_forks_repo_name": "userjjb/22_6xx-DG-for-PDEs", "max_forks_repo_head_hexsha": "34527e2fa77a193a58bd2f47f781833d70c59315", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2016-04-30T00:20:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-14T09:03:21.000Z", "avg_line_length": 52.8121546961, "max_line_length": 404, "alphanum_fraction": 0.7294696098, "num_tokens": 3035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4170585143915245}}
{"text": "\\section{Introduction}\n\nThe interpretation of total-field anomalies on the surface of the Earth is an \nimportant challenge in exploration geophysics due to the nonuniqueness of 3-D magnetic \ninversion. It is well-known that several magnetization distributions in the subsurface \ncan reproduce the same magnetic data with the same accuracy. \nTo overcome this inherent ambiguity, a priori information needs to be introduced \nfor reducing the number of possible solutions that are coherent with the local geology.\nThe available a priori information determines the suitable inversion method to be applied. \nAs explained below, we identified, in the literature, three groups of 3-D magnetic inversion methods.\n\nThe first group of inverse methods approximates the source by a geometrically \nsimple causative body having its geometry defined by a small number of parameters \n\\cite[e.g., ][]{ballantyne-1980,bhattacharyya-1980,silva-1983,medeiros_silva1995}. These methods \nestimate both the geometry and the physical property of the source by solving \na nonlinear inverse problem. Due to the very restrictive parametrization, \nsuch methods usually do not have severe problems with ambiguity.\n\nThe second group of inverse methods is formed by the vast majority of methods. \nThese methods approximate the subsurface by a grid of juxtaposed rectangular prisms having \na constant total-magnetization direction. Some methods presume a purely induced \nmagnetization and the isotropic magnetic susceptibility of the prisms is the quantity estimated by solving a linear inverse problem. \nSome examples of this linear inversion are presented by \\cite{cribb-1976}, \\cite{li_3-d_1996} and \\cite{pilkington_3-d_1997}.\nDifferent approaches have improved this linear inversion to obtain focused images of the subsurface. \nFor example, \\cite{portniaguine_focusing_1999} and \\cite{portniaguine_3d_2002} introduced the minimum gradient support functional, similar to the one proposed by\n\\cite{last-1983} that minimizes the volumes of the sources in a gravity data inversion. \nBy inverting magnetic anomaly and any component of the total anomalous field, this functional estimates a magnetization distribution that generates a non blurry (focused) 3-D image of the geologic bodies in the subsurface.\n\\cite{barbosa_interactive_2006} presented a method for inverting interfering magnetic anomalies produced by multiple sources by combining features of the forward modeling (the interactivity) and traditional inversion (the automatic data fitting). Other studies introduced strategies to constraint the nonuniqueness and delineate the source \\cite[]{tontini,pilkington_3d_2009,shamsipour_3d_2011,cella_inversion_2012,abedi-2015}. \nSome of these methods allowed remanent magnetization \\cite[e.g., ][]{pignatelli-2006}. \nIn this case, the parameters to be estimated are the total-magnetization intensities \nof the prisms. \nIn all these methods, the geometries of the magnetic sources are indirectly retrieved by interpreting the estimated total-magnetization intensity \ndistribution. \nTheoretically, these inversion methods are capable of recovering the geometry of complex \nsources. However, they require a plethora of a priori information to overcome \ntheir nonuniqueness and instability due to the large number of parameters \nto be estimated. Additionally, they are characterized by a high \ncomputational cost associated with the solution of large linear systems.\n\nThe third group of 3-D magnetic inversion methods requires some knowledge about the \nphysical property distribution to estimate the geometry of the sources. \nThey are usually formulated as nonlinear inverse problems. \n\\cite{wang_inversion_1990} approximated the source by a polyhedron and estimate \nthe position of its vertices in the Fourier domain. \n\\cite{wenbin-2017} developed a multiple level-set method to estimate geometry \nof a set of causative bodies with uniform magnetic susceptibility. \n\\cite{hidalgo-2019} inverted the total-field anomaly for estimating the depths to the top of a magnetic basement of a sedimentary basin with known magnetization intensity but unknown magnetization direction. \nAn inverse method in this third group has a small number of parameters to be estimated by inversion and has much less ambiguity in comparison to the second group. \n\nBy following the third group of 3-D magnetic inversion methods, \nwe present a method to estimate the geometry, position and total-magnetization\nintensity of an isolated and uniformly magnetized 3-D source with known\ntotal-magnetization direction.\nOur method is an extension of the methods presented \nby \\cite{oliveirajr-etal2011} and \\cite{oliveirajr-barbosa2013} for inverting, respectively, \ngravity and gravity-gradient data, applied to the total-field anomaly. \nWe approximate the source by a stack of vertically juxtaposed \nright prisms with polygonal horizontal cross-sections and the same number of vertices.\nAll prisms have the same thickness and total-magnetization intensity.\nDifferently from \\cite{oliveirajr-etal2011} and \\cite{oliveirajr-barbosa2013}, \nour method estimates not only the horizontal Cartesian coordinates of the origins and the radii of the vertices describing the horizontal cross-sections of all prisms but also the thickness of all prisms comprising the interpretation model, as well as\ntwo additional parameters: the depth to the top of the shallowest prism and the\ntotal-magnetization intensity of all prisms. \nWe perform a series of inversion runs using different value combinations of these two parameters and compute a goal function associated with each of the trial solutions.\nAmong the estimated models, those producing the \nlowest values of goal function form the set of candidate models.\nTo obtain stable solutions, we use the same set of regularizing functions proposed by \n\\cite{oliveirajr-etal2011} and also propose a new one for constraining the \nthickness of the prisms. \nFollowing \\cite{oliveirajr-etal2011} and \\cite{oliveirajr-barbosa2013}, we refer to the proposed method as \\textit{radial inversion} because our method estimates the radii of the vertices describing the horizontal cross-sections of all prisms.\nTests on synthetic data and on airborne magnetic data collected over the alkaline-carbonatitic complex of Anit{\\'a}polis, in southern Brazil, show the potential of our method in retrieving 3-D magnetic bodies even if they exhibit a variety of shapes and depths. \n\n\n", "meta": {"hexsha": "f6c5cb09bdce11b9ceef2c06a578fe1befdc4ba9", "size": 6438, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/introduction.tex", "max_stars_repo_name": "pinga-lab/magnetic-radial-inversion", "max_stars_repo_head_hexsha": "ac7e04a143ddc29eb4ded78671a5382a2869d5d8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-15T11:35:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:35:41.000Z", "max_issues_repo_path": "manuscript/introduction.tex", "max_issues_repo_name": "pinga-lab/magnetic-radial-inversion", "max_issues_repo_head_hexsha": "ac7e04a143ddc29eb4ded78671a5382a2869d5d8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manuscript/introduction.tex", "max_forks_repo_name": "pinga-lab/magnetic-radial-inversion", "max_forks_repo_head_hexsha": "ac7e04a143ddc29eb4ded78671a5382a2869d5d8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-01T02:14:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T02:14:31.000Z", "avg_line_length": 87.0, "max_line_length": 428, "alphanum_fraction": 0.8241689966, "num_tokens": 1405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4170585143915245}}
{"text": "I put a lot of blood sweat and tears into making my code work.  It is available on my github page: \\url{github.com/jgoodknight}.  I made heavy use of the numpy and scipy libraries~\\cite{scipy,numpy}  There are some details I wish to point out, however, in my thesis and this seems the appropriate place to do so.\n\n\\section{Working with Natural Units: or, Why Mess with SI?}\n\nWhile an experimentalist needs a systems of units he or she can measure, we theorists prefer to have a system of units which is easy to write down, so we can worry less about dropping factors here and there.  Take for example the hydrogen atom Hamiltonian:\n\n\\begin{align*}\n\t\\hat{H} = -\\frac{\\hbar ^2}{2 m_e} \\nabla^2 - \\frac{1}{4 \\pi \\epsilon_0} \\frac{e^2}{r}\n\\end{align*}\nThat is a lot of constants.  Wouldn't it be better if we could just write this out:\n\\begin{align*}\n\t\\hat{H} = -\\frac{1}{2 } \\nabla^2 -  \\frac{1}{r}\n\\end{align*}\nThis easy-to-not-mess-up Hamiltonian can be yours with a little algebra and a bit of thought.\n\n\\subsection{Setting Constants equal to 1}\nThe astute observer will note that one can get the miraculous Hamiltonian Transformation by making the following algebraic declarations:\n\\begin{align*}\n\t\\hbar &= 1 \\\\\n\te &= 1 \\\\\n\tm_e &= 1 \\\\\n\t\\frac{1}{4 \\pi \\epsilon_0} = k_e &= 1\n\\end{align*}\nYou may now be wondering how they can be 1.  You've probably had many professors talk to you for many hours about the painstaking effort that went into determining the exact values of these constants throughout the history of physics, and here I go, willy-nilly just setting them to one: doesn't this throw off all of physics into non-physical nonsense?  Yes and no.\n\nThere is, unsurprisingly, a limit to the number of units you can set to being 1.  This limit is imposed by the fine-structure constant $\\alpha$:\n\\begin{align*}\n\t\\alpha = \\frac{k_e e^2}{\\hbar c}\n\\end{align*}\nWhich, unless you listen to some theoretical cosmologists, is completely constant in our universe and has a value of $^\\sim 1/137$.  So in our system of units we have set all but one of these constants which make up the fine-structure constant to be unity (the absolute limit), so we must get out that $c = \\frac{1}{\\alpha}$ to keep our system of units from describing a universe other than our own.\n\n\n\\subsection{Setting units equal to 1 or: Finding the ``Natural'' units}\nThe only reason we are able to set these units to be one is because we now measure things like energy, distance and time in units which MAKE the constants one.  $\\hbar$ for example is not really just 1; it's 1 atomic-energy-unit-atomic-time-unit or $1 E_a \\cdot t_a$.  To figure out exactly what these atomic units are, we do this for each constant noting that energy will be $E_a = m_a l_a^2/t_a^2$:\n\n\\begin{align*}\n\t\\hbar &= 1 E_a \\cdot t_a = m_a \\frac{l_a^2}{t_a}\\\\\n\tk_e &= 1 \\frac{E_n \\cdot l_a}{q_a ^2}\n\\end{align*}\nWe've already defined our charge units to be $e$ and our mass units to be $m_e$  (although that can easily change).\n\\begin{align*}\n\t\\frac{\\hbar}{m_e} &= \\frac{l_a^2}{t_a}\\\\\n\tk_e e^2 &= m_e \\frac{l_a^2}{t_a^2} \\cdot l_a\n\\end{align*}\nNow with two equations and two unknowns, we begin to solve\n\\begin{align*}\n\t\\frac{\\hbar}{m_e} &= \\frac{l_a^2}{t_a}\\\\\n\tt_a &= \\frac{l_a^2 m_e}{\\hbar} \\\\\n\tt_a^2 &= \\frac{l_a^3 m_e}{k_e e^2} \\\\\n\t\\frac{l_a^4 m_e^2}{\\hbar^2} &= \\frac{l_a^3 m_e}{k_e e^2} \\\\\n\tl_a &= \\frac{\\hbar^2}{m_e k_e e^2}\n\\end{align*}\nWhich the astute observer will note has an $\\alpha$ hidden in there... somewhere:\n\\begin{align*}\n\tl_a &= \\frac{\\hbar}{m_e \\alpha c}\n\\end{align*}\nAnd the even more astute observer will notice that it is the Bohr radius.  This quickly emits the time and then energy units:\n\\begin{align*}\n\t1 l_a &= \\frac{\\hbar}{m_e \\alpha c} = a_0 \\approx 5.29 \\times 10^{-11}\\text{ m} \\\\\n\t1 t_a &= \\frac{\\hbar}{m_e \\alpha^2 c^2 } \\approx 2.419 \\times 10^{-17} \\text{ s} \\\\\n\t1 E_a &= m_e \\alpha^2 c^2 \\approx 4.3597 \\times 10^{-18} \\text{ J}\n\\end{align*}\nwavenumbers come up a lot on spectroscopy so let's figure out what the atomic wavenumber unit is:\n\\begin{align*}\n\t1 \\omega_a &= \\frac{1 E_a}{h c} = 219474.6 \\text{ cm}^{-1} = \\frac{1}{1 l_a} \\\\\n\thc &= 2 \\pi \\hbar c = \\frac{2 \\pi}{\\alpha} = 861.022576 E_a \\cdot l_a\n\\end{align*}\nSo to convert a wavenumber $\\omega$ into an atomic energy unit:\n \\begin{align*}\n\tE_a (\\omega) &= \\frac{\\omega}{1 \\omega_a} \\frac{2 \\pi}{\\alpha} \\\\\n\t&= \\omega \\left( 0.00392310807 \\frac{E_a}{\\text{cm}^{-1}} \\right)\n\\end{align*}\n\n\n\\subsection{Setting other things equal to 1}\nNow let's say you are reading a paper which quotes all of its energy units in wavenumbers, all of its position units in square-root-centimeters and time units in femtoseconds.  How do you make sense of this?\n\nLet's say this particular paper is talking about harmonic oscillators, the Hamiltonian of which looks like so:\n\\begin{align*}\n\t\\hat{H} = \\frac{\\hbar^2 p^2}{2 m\t} + \\frac{1}{2} m \\omega^2 (x - x_0)^2\n\\end{align*}\nIn the paper, however, the author quotes the Hamiltonian as being thus:\n\n\\begin{align*}\n\t\\hat{H} = \\frac{p^2}{2} + \\frac{1}{2} \\omega^2 (x - x_0)^2\n\\end{align*}\nand all energy units are given in terms of wavenumbers.  All-together, these implies 3 unitary unit relationships:\n\\begin{align*}\n\t\\hbar = 1 \\\\\n\thc = 1 \\\\\n\tm = 1\n\\end{align*}\nLuckily, we don't care about coulomb relations so we can just set $c=2 \\pi$ and let the electron charge and Coulomb constant float to strange numbers.  Anyway, as we know from earlier, these really do have units associated with them so we add them in, calling them $j$ units.\n\\begin{align*}\n\t\\hbar = 1 E_j \\cdot t_j \\\\\n\tm = 1 m_j\n\\end{align*}\nThe author has chosen wavenumbers as the units of choice for energy: specifically 100 wavenumbers.\n\\begin{align*}\n\t1 E_j &\\sim 100.0 \\text{ cm}^{-1} \\\\\n\t1 E_j &= h c (100.0 \\text{ cm}^{-1}) = 1.986 \\times 10^{-21} \\text{J}\n\\end{align*}\nwhich also gives us the natural units for time:\n\\begin{align*}\n\t1 t_j = \\frac{\\hbar}{1 E_j} = 5.308837 \\times 10^{-12} \\text{s} = 5.3 \\text{ ps}\n\\end{align*}\n\n\n\\subsection{Conclusion on Units}\nI have shown you the basic derivation for how to get the system of natural units (units with a bunch of constants equal to one)  known as atomic units.  Hopefully you can follow my logic to create any easy-to-derive-with system of units that you desire.  Up for a challenge?  Let the mass and charge float, set $c=1$ and then figure out how to set Boltzmann's constant and the universal gravitational constant equal to 1 also.  These are known as the Planck units and are cool because they set all the fundamental constants of the forces to 1, instead of any property of an object\n\n\n\n\n\n\n\n\n\\section{Discrete Fourier Transform}\nLet's say you want a computer to do the following integral\n\\begin{align}\n\t\\tilde{f} (\\omega) = \\int e^{i \\omega t} f(t) dt\n\\end{align}\nAnd your t values stretch from $0\\rightarrow n \\delta t$.  We could then do the integral like a Riemann Sum:\n\\begin{align}\n\t\\tilde{f} (\\omega) = \\delta t \\sum_{j=0}^{n}  e^{i \\omega j \\delta t} f( j \\delta t )\n\\end{align}\nbut how to discretize $\\omega$?  I'm going to skip over why but say that Numpy's Fast Fourier Transform algorithm takes a list of function values $\\{f_m\\}$ and returns:\n\\begin{align}\n\t\\tilde{f}_k = \\sum_{m=0}^{n - 1}  e^{- 2 \\pi i \\frac{m k}{n}} f_m\n\\end{align}\nwhich implies we get $d\\omega = \\frac{ 2 \\pi }{n \\delta t}$ with $-\\frac{n-1}{2} < k < \\frac{n-1}{2} $.  But we defined our Fourier transforms in terms of the positive exponent.  We're in luck, however, because numpy's inverse FFT algorithm looks like this:\n\\begin{align}\n\t f_m = \\frac{1}{n} \\sum_{k=0}^{n - 1}  e^{2 \\pi i \\frac{m k}{n}} \\tilde{f}_k\n\\end{align}\n\n\n\\section{Choosing the Parameters of Space}\nIn the course of simulation, we have to figure out a proper value for the box we put our wavefunctions in that doesn't affect the observables.  So we need something big enough in position space and big enough in momentum space (small enough $\\Delta x$.  Let's look at a ladder of harmonic oscillators:\n\\begin{align}\n\tH_i = \\frac{1}{2m_i} \\hat{p}^2 + \\frac{1}{2} m_i \\omega_i^2 \\left( x - \\bar{x}_i \\right)^2\n\\end{align}\nfor the sake of simplicity, we'll say that all the oscillators are accessible to each other via transition dipole moments and that oscillator 0 is the leftmost.  The ground state we will say has non-negligible amplitude from $x_0 \\pm n \\sigma_0$ where $\\sigma_0 = \\sqrt{\\frac{\\hbar}{m \\omega_i}}$.\n\nWhen the ground state (or any initial state but we're being simple here) from the 0th state end ups in the oscillator $j$ whose center is furthest away from its center, the center's have distance $\\Delta x_{\\max} =  \\Delta x_{0j} = ( x_j - x_0)$.  Because of the magic of Gaussian wavepackets in harmonic potentials, the wavepacket will distort and swing to the other side of the potential energy surface and settle at the classical turning point intact.  That wavepacket will now have approximate extent of $x_0 + 2 \\Delta x_{\\max} + n \\sigma_0$.  Which, is the furthest out the wavepacket can ever get.  So If we're only \\textbf{simulating a one-interaction experiment},\n\\begin{align}\n\tx_{\\min} &= x_0 - n \\sigma_0 \\\\\n\tx_{\\max} &= x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 \\\\\n\tx_{\\max} - x_{\\min} &= 2 \\Delta x_{\\max} + 2n \\sigma_0\n\\end{align}\nIf, however, we are interacting more than once, things get slightly more complicated.  We have to assume that at some point, the wavepacket centered about $x = x_0 + 2 \\Delta x_{\\max}$ will once again end up in the 0th oscillator.  Which means that it will swing all the way over to center around  $x = x_0 - 2 \\Delta x_{\\max}$ and thus for more than two interactions:\n\\begin{align}\n\tx_{\\min} &= x_0 - 2 \\Delta x_{\\max} - n \\sigma_0 \\\\\n\tx_{\\max} &= x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 \\\\\n\tx_{\\max} - x_{\\min} &= 4 \\Delta x_{\\max} + 2n \\sigma_0\n\\end{align}\n\n\\subsection{Momentum-Space Considerations  }\nAlas, if only computers did not require us to simulate things discretely, we would not have to worry about momentum space but they do and thus we do.  We must chose $N$ points to simulate the system on.  When you discrete Fourier transform a function in $x$, you get values of k ranging from roughly $-\\frac{\\pi}{ dx}$ to $\\frac{\\pi}{dx}$ which means we must chose a $dx$ which is small enough to study the largest momentum the problem will end up seeing.\n\\subsection{One-Interaction}\nHow do we do this?  Well, consider that our rightmost amplitude is at $x = x_0 + 2 \\Delta x_{\\max} + n \\sigma_0$.  For one interaction, the highest momentum we will see is when it gets to the center of the $j$th well.  Thinking classically, that rightmost piece of amplitude will be motionless at the top and then be potential energy-less at the center so we can say:\n\\begin{align}\n\t\\frac{p_{\\max}^2}{2 m_j} = V_j(x_0 + 2 \\Delta x_{\\max} + n \\sigma_0)\n\\end{align}\nSince $p = \\hbar k$ and we already know the form of the potential energy surface:\n\\begin{align}\n\t\\frac{\\left( \\hbar k_{\\max} \\right)^2}{2 m_j} &= \\frac{1}{2} m_j \\omega_j^2 \\left(x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 - x_j \\right)^2 \\\\\n\tk_{\\max} &= \\frac{1}{\\hbar} m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right) = \\frac{\\pi}{dx} \\\\\n\tdx &= \\frac{\\pi \\hbar}{m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right)} = \\frac{x_{max} - x_{\\min}}{N} \\\\\n\t\\frac{\\pi \\hbar}{m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right)} &= \\frac{2 \\Delta x_{\\max} + 2n \\sigma_0}{N}\t\\\\\n\tN &= \\frac{2 m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right)^2 }{\\pi \\hbar}\n\\end{align}\n\n\n\\subsection{Two-Interactions}\nBut what if that wavepacket at it's absolute rightmost position is then suddenly plummeted down to the leftmost 0th potential energy well?  Then there will be a non-trivially larger maximum momentum as it will have much further to travel to get to the center of the potential energy well.\n\\begin{align}\n\t\\frac{\\left( \\hbar k_{\\max} \\right)^2}{2 m_0}  &= V_0(x_0 + 2 \\Delta x_{\\max} + n \\sigma_0) \\\\\n\tk_{\\max} &= \\frac{1}{\\hbar} m_0 \\omega_0 \\left( x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 -x_0 \\right) = \\frac{\\pi}{ dx} \\\\\n\tdx &= \\frac{\\pi \\hbar}{ m_0 \\omega_0 \\left( 2\\Delta x_{\\max} + n \\sigma_0\\right)} = \\frac{x_{max} - x_{\\min}}{N} \\\\\n\t\\frac{\\hbar \\pi}{ m_0 \\omega_0 \\left( 2\\Delta x_{\\max} + n \\sigma_0\\right)} &= \\frac{4 \\Delta x_{\\max} + 2n \\sigma_0}{N}\\\\\n\tN &= \\frac{2 m_0 \\omega_0 \\left(2\\Delta x_{\\max} + n \\sigma_0 \\right)^2}{\\pi  \\hbar}\n\\end{align}\n\n\\subsection{Summarize}\n\\subsubsection{One-Interaction}\n\\begin{align}\n\tx_{\\min} &= x_0 - n \\sigma_0 \\\\\n\tx_{\\max} &= x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 \\\\\n\tN &= \\frac{2 \\pi m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right)^2 }{\\hbar} \\\\\n\tdx &= \\frac{\\hbar}{\\pi m_j \\omega_j \\left( \\Delta x_{\\max} + n \\sigma_0\\right)}\n\\end{align}\n\n\\subsubsection{Two-Interactions}\n\\begin{align}\n\tx_{\\min} &= x_0 - 2 \\Delta x_{\\max} - n \\sigma_0 \\\\\n\tx_{\\max} &= x_0 + 2 \\Delta x_{\\max} + n \\sigma_0 \\\\\n\tN &= \\frac{2 \\pi m_0 \\omega_0 \\left(2\\Delta x_{\\max} + n \\sigma_0 \\right)^2}{\\hbar}\\\\\n\tdx &= \\frac{\\hbar}{\\pi m_0 \\omega_0 \\left( 2\\Delta x_{\\max} + n \\sigma_0\\right)}\n\\end{align}\n\n\\subsubsection{More-Than-Two-Interactions}\nWith a third interaction, one must consider the scenario where the wavepacket at its leftmost is promoted to the rightmost potential energy well where it can again go out to the rightmost edge of the $j$th potential energy well giving us a different maximum distance needed and different maximum potential needed.\n\n\n\n\n\\section{Applying $U(t)$ Numerically: the Split Operator Method}\nLet's say you want to apply an exponential operator to something:\n\\begin{align*}\n\tU = e^{-i t \\mathcal{H} / \\hbar}\n\\end{align*}\nThis does not appear to be terribly difficult at first sight if you know how to take the exponential of whatever $\\mathcal{H}$ is.  Let's just make life difficult and call $\\mathcal{H}$ the Hamiltonian of a quantum system which would make $U$ the time-evolution operator:\n\\begin{align*}\n\tU = e^{-i t / \\hbar \\mathcal{H}(p, x) } = e^{-i t / \\hbar (\\mathcal{T}(p) + \\mathcal{V}(x) ) }\n\\end{align*}\nSo now it appears to be rather difficult as the potential energy is best expressed in the position basis whereas the kinetic energy is best expressed in the momentum basis.  We might consider doing this (to make our lives easier, define $\\lambda = \\frac{- i t}{\\hbar}$) to make things simpler:\n\\begin{align*}\n\tU &= e^{\\lambda (\\mathcal{T} + \\mathcal{V} ) }  = e^{\\lambda \\mathcal{T} } e^{\\lambda  \\mathcal{V} }\n\\end{align*}\nThen we could apply the first bit, Fourier transform, apply the second bit and then inverse Fourier transform back to the original basis.  Is this, correct, though?  Let's look at the Taylor Series for the two.  First the ``correct'' operator:\n\\begin{align*}\n\tU &= e^{\\lambda (\\mathcal{T} + \\mathcal{V} ) } \\\\\n\t&= \\sum_{k=0}^{\\infty} \\frac{\\lambda^k}{k!} (\\mathcal{T} + \\mathcal{V} )^k \\\\\n\t&= 1 + \\lambda (\\mathcal{T} + \\mathcal{V} ) + \\frac{\\lambda^2}{2}(\\mathcal{T}^2 + \\mathcal{V}^2  + \\mathcal{T}\\mathcal{V} + \\mathcal{V}\\mathcal{T}) \\\\\n\t&+ \\frac{\\lambda^3}{6}(\\mathcal{T}^3+ \\mathcal{V}^3 + \\mathcal{T}\\mathcal{V}^2 + \\mathcal{T}^2\\mathcal{V} + \\mathcal{T}\\mathcal{V}\\mathcal{T} + \\mathcal{V}\\mathcal{T}^2 + \\mathcal{V}\\mathcal{T} \\mathcal{V} + \\mathcal{V}^2\\mathcal{T}  ) + O(\\lambda^4)\n\\end{align*}\nNow the proposed correction:\n\\begin{align*}\n\tU &= e^{\\lambda \\mathcal{T} } e^{\\lambda  \\mathcal{V} }  \\\\\n\t&= \\sum_{k=0}^{\\infty} \\frac{\\lambda^k}{k!} \\mathcal{T}^k \\sum_{l=0}^{\\infty} \\frac{\\lambda^l}{l!} \\mathcal{V}^k \\\\\n\t&= 1 + \\lambda (\\mathcal{T} + \\mathcal{V}) + \\frac{\\lambda^2}{2}(\\mathcal{T}^2 + \\mathcal{V}^2 + 2 \\mathcal{T} \\mathcal{V}) + \\frac{\\lambda^3}{6}(\\mathcal{T}^3 + \\mathcal{V}^3  + 3\\mathcal{T}\\mathcal{V}^2 + 3\\mathcal{T}^2 \\mathcal{V}  ) + O(\\lambda^4)\n\\end{align*}\nSo because normally you have commutivity $xy = yx$, because the kinetic and potential operators don't necessarily commute, there is an error term here:\n\\begin{align*}\n\tE &=  e^{\\lambda (\\mathcal{T} + \\mathcal{V} ) } - e^{\\lambda \\mathcal{T} } e^{\\lambda  \\mathcal{V} }  \\\\\n\t&= \\frac{\\lambda^2}{2} ( \\mathcal{T} \\mathcal{V} - \\mathcal{V} \\mathcal{T} ) + O(\\lambda^3) \\\\\n\t&= \\frac{\\lambda^2}{2} [ \\mathcal{T}, \\mathcal{V}] + O(\\lambda^3)\n\\end{align*}\nSo our approximation is good, so long as $\\lambda$ is small enough to keep $\\lambda^2$ sufficiently small.  This can be accomplished by letting $t=N\\Delta t$ and applying the operator for $\\Delta t$, $N$ times.\n\nYou can get even better accuracy at the cost of more Fourier transforms using certain schemes as shown below.  (I will spare you the proofs of these)\n\\begin{align*}\n\tU &\\approx e^{\\lambda \\mathcal{T} / 2 } e^{\\lambda  \\mathcal{V} } e^{\\lambda \\mathcal{T} / 2 } + O(\\lambda^3) \\\\\n\tU &\\approx \\left(  e^{\\gamma \\lambda \\mathcal{T} / 2 } e^{\\gamma \\lambda  \\mathcal{V} } e^{\\gamma \\lambda \\mathcal{T} / 2 } \\right) \\left( e^{(1- 2\\gamma) \\lambda \\mathcal{T} / 2 } e^{(1- 2\\gamma) \\lambda  \\mathcal{V} } e^{(1- 2\\gamma) \\lambda \\mathcal{T} / 2 } \\right) \\left( e^{\\gamma \\lambda \\mathcal{T} / 2 } e^{\\gamma \\lambda  \\mathcal{V} } e^{\\gamma \\lambda \\mathcal{T} / 2 } \\right)+ O(\\lambda^4) \\\\\n\t&= e^{\\gamma \\lambda \\mathcal{T} / 2 } e^{\\gamma \\lambda  \\mathcal{V} } e^{(1-\\gamma) \\lambda \\mathcal{T} / 2 } e^{(1- 2\\gamma) \\lambda  \\mathcal{V} } e^{(1-\\gamma) \\lambda \\mathcal{T} / 2 }  e^{\\gamma \\lambda  \\mathcal{V} } e^{\\gamma \\lambda \\mathcal{T} / 2 } + O(\\lambda^4) \\\\\n\t\\gamma &= \\frac{1}{2 - \\sqrt[3]{2}}\n\\end{align*}\nYou can, in principle, get a splitting method for an arbitrary level of accuracy, but it will involve more computational time.\\footnote{Referenced http://www.pci.uni-heidelberg.de/tc/usr/andreasm/academic/handouthtml/node13.html for part of this derivation}\n\n\\section{Trapezoidal Integration for Perturbation Theory Calculations with Smaller Time Discretization}\n\nThe integral one performs to do one ``interaction'' with a perturbative Hamiltonian $H'(t)$ with a time-independent Hamiltonian $H_0$ is:\n\\begin{align*}\n\t\\ket{\\Psi'(t)} = -\\frac{i}{\\hbar} \\int_{-\\infty}^{t} e^{-\\frac{i}{\\hbar} H_0 (t - \\tau)} H'(\\tau) \\ket{\\Psi (\\tau)} d\\tau\n\\end{align*}\nWhere $\\ket{\\Psi (\\tau)} $ is the underlying wavefunction being interacted with, $\\tau$ represents the different times that the interaction can happen at and $e^{-\\frac{i}{\\hbar} H_0 (t - \\tau)} = U_0 (t, \\tau)$ is the non-perturbative time-evolution operator.  This integral  phenomenologically represents some field represented by $H'$ having being able to interact at many different points in time--all where the field is nonzero.  At each of these points in time (represented by $\\tau$), one must interact the field with the underlying wavefunction and then propagate that wavefunction out to the time-point of interest.  Then, for every $\\tau$ before $t$ there is a contribution to the interacted wavefunction at time $t$ that is averaged over by the integral.\n\nNow it is not hard to imagine that a naive implementation of this integral would be numerically very expensive.  Indeed, if you turn my above paragraph into an algorithm directly, if the perturbation is ``on'' for $N$ time steps, you are storing $O(N^2)$ wavefunctions which gets hairy very quickly.\n\nWe can do better, though and we will: to start with, we will assume that our perturbation can be ``turned on'' at a time $t_0 > -\\infty$ without affecting the calculation at all, the integral reduces to this.\n\\begin{align*}\n\t\\ket{\\Psi'(t)} = -\\frac{i}{\\hbar} \\int_{t_0}^{t} U_0 (t, \\tau) H'(\\tau) \\ket{\\Psi (\\tau)} d\\tau\n\\end{align*}\nnow we shall discretize time: $t_i = t_0 + i \\delta t$ and $\\tau_j = t_0 + j \\delta t$.  $t$ and $\\tau$ have the same initial value because $\\tau$ is never lower than $t$.  Later on we will exploit this to simplify the expression but for now, I shall keep $\\tau$ separate to make it abundantly clear that it is the variable which represents the point at which the perturbation acts on the system.\n\nWe decide to perform the integral with a simple Riemann sum:\n\\begin{align*}\n\t\\int_{t_0}^{t_f} f(t) dt =\\delta t \\sum_{n} f(t_n) + O(\\delta t^2)\n\\end{align*}\nwhich gives us:\n\\begin{align*}\n\t\\ket{\\Psi'(t_i)} = -\\frac{i}{\\hbar} \\delta t  \\sum_{j=0}^{j=i}   U_0 (t_i, \\tau_j) H'(\\tau_j) \\ket{\\Psi (\\tau_j)}\n\\end{align*}\nnow at this point, we decide to try mathematical induction for the heck of it and we calculate\n\\begin{align*}\n\t\\ket{\\Psi'(t_{i+1})} &= -\\frac{i}{\\hbar} \\delta t  \\sum_{j=0}^{j=i+1}   U_0 (t_{i+1}, \\tau_j) H'(\\tau_j) \\ket{\\Psi (\\tau_j)} \\\\\n\t\t\t\t\t\t\t\t\t&= -\\frac{i}{\\hbar} \\delta t \\left[ \\sum_{j=0}^{j=i}   U_0 (\\delta t) U_0 (t_{i}, \\tau_j) H'(\\tau_j) \\ket{\\Psi (\\tau_j)}  + U_0 (t_{i+1}, \\tau_{i+1}) H'(\\tau_{i+1}) \\ket{\\Psi (\\tau_{\\tau_{i+1})}} \\right]\n\\end{align*}\nwhich, since $t_n = \\tau_n $ we can say\n\\begin{align*}\n\t\\ket{\\Psi'(t_{i+1})} = U_0 (\\delta t)\\ket{\\Psi'(t_i)} -\\frac{i}{\\hbar} \\delta t H'(\\tau_{i+1}) \\ket{\\Psi (\\tau_{\\tau_{i+1})}}\n\\end{align*}\nwhich has a really interesting interpretation.  At each time step, we merely take the previous time step's perturbation and propagate it forward one step in time.  Then, we take the perturbation and interact it with the current step of the wavefunction and add it to the propagated step and that is the current step's perturbed wavefunction.  This is a phenomenal savings in space and time of calculation over an naive implementation of the integral.\n\nThis is not without it's problems, however.  The error in this integration is of the order $\\delta t^2$ whereas the error for most split-operator propagation methods (if one is being smart) is of the order $\\delta t^3$.  This is entirely a failing of the Riemann sum algorithm.  Remembering back to High school calculus, though, one might recall another method called trapezoidal rule for integration.\n\\begin{align*}\n\t\\int_{t_0}^{t_f} f(t) dt =\\frac{\\delta t}{2} \\left[ f(t_0) + f(f_f) + 2  \\sum_{n=1}^{n=f-1} f(t_n) \\right] + O(\\delta t^3)\n\\end{align*}\nwhich we make use of to get an even lower error\n\\begin{align*}\n\t\\ket{\\Psi'(t_{i+1})} = U_0 (\\delta t)\\ket{\\Psi'(t_{i})} -\\frac{i}{\\hbar}  \\frac{\\delta t}{2} U_0 (\\delta t) H'(\\tau_{i}) \\ket{\\Psi (\\tau_{i})} -\\frac{i}{\\hbar} \\frac{\\delta t}{2} H'(\\tau_{i+1}) \\ket{\\Psi (\\tau_{i+1})}\n\\end{align*}\n\n\\section{Calculation Method For Heating Calculations}\nTo look at molecular heating, we would care most about the average vibrational quantum number\n\\begin{align*}\n\t\\bar{n}(t) &= \\sum_{n} n \\left| \\bra{g}\\braket{n_{\\gamma} | \\Psi(t)} \\right|^2\n\\end{align*}\nBut then what does the time-dependent wavefunction look like?  We're interested in the exact picture.  The interaction Hamiltonian is\n\\begin{align*}\n\t\\hat{H}'(t) &= E(t)  \\left(\\ket{g}\\bra{e} + \\ket{e}\\bra{g}\\right)\\mu(x)\n\\end{align*}\nand the time-independent Hamiltonian is as above:\n\\begin{align}\n\tH_0 &=  \\sum_n \\hbar \\omega_{\\gamma}  \\left(n + \\frac{1}{2} \\right)  \\ket{n_{\\gamma}}\\ket{g}\\bra{g} \\bra{n_{\\gamma}} \\\\\n   &+ \\sum_m \\left(  \\hbar \\omega_{\\epsilon}  \\left(m + \\frac{1}{2} \\right) + \\omega_e \\right)  \\ket{m_{\\epsilon}} \\ket{e}\\bra{e} \\bra{m_{\\epsilon}}\n\\end{align}\nIf we turn the electronic degrees of freedom, putting it into Matrix form, we then have:\n\\begin{align*}\n\t\\hat{H}(t) &=\n\t\\begin{bmatrix}\n\tH_{\\gamma}(x) & E(t)\\mu(x) \\\\\n\tE(t)\\mu(x) & H_{\\epsilon}(x)\n\t\\end{bmatrix}\n\\end{align*}\nno that won't work since the coefficients of the Pauli matrices won't commute...\n\nLet's try a blast form undergrad and calculate the time-dependent coefficients!  We assume the following form of the time-varying wavefunction:\n\n\\begin{align*}\n\t\\ket{\\Psi(t)} = \\sum_{a} G_a(t) \\ket{a_{\\gamma}} \\ket{g}  + \\sum_{b} E_b(t) \\ket{b_{\\epsilon}} \\ket{e}\n\\end{align*}\nwhere we know the initial conditions are $G_0(0) = 1, G_{a\\neq0}(0) = 0, E_b(0) = 0$.\nWe now take the full time-dependent Schrodinger equation:\n\\begin{align*}\n\t\\frac{d}{dt}\\ket{\\Psi(t)} = -\\frac{i}{\\hbar}\\hat{H}(t)\\ket{\\Psi(t)}\n\\end{align*}\nstarting with the left and simplest side:\n\\begin{align*}\n\t\\frac{d}{dt}\\ket{\\Psi(t)} = \\sum_{a} \\frac{d G_a(t)}{dt} \\ket{a_{\\gamma}} \\ket{g}  + \\sum_{b} \\frac{d E_b(t)}{dt} \\ket{b_{\\epsilon}} \\ket{e}\n\\end{align*}\nThen the right side can be split in twain:\n\\begin{align*}\n\t-\\frac{i}{\\hbar}\\left( \\hat{H}_0 + \\hat{H}'(t)  \\right) \\ket{\\Psi(t)}\n\\end{align*}\nthe easiest part of that being:\n\\begin{align*}\n\t\\hat{H}_0  \\ket{\\Psi(t)} &= \\sum_{a} G_a(t) \\left[E_g + E_{\\gamma}\\left(a + \\frac{1}{2}\\right) \\right]\\ket{a_{\\gamma}} \\ket{g}  \\\\\n\t&+ \\sum_{b} E_b(t) \\left[E_e + E_{\\epsilon}\\left(b + \\frac{1}{2}\\right) \\right] \\ket{b_{\\epsilon}} \\ket{e}\\\\\n\t&= \\sum_{a} G_a(t) \\Omega_{(a)} \\ket{a_{\\gamma}} \\ket{g}  \\\\\n\t&+ \\sum_{b} E_b(t) \\Omega^{(b)} \\ket{b_{\\epsilon}} \\ket{e}\n\\end{align*}\nand now for the interaction term:\n\\begin{align*}\n\t\\frac{\\hat{H}'(t)}{E(t)}  \\ket{\\Psi(t)} &= \\sum_{a} G_a(t) \\mu(x)\\ket{a_{\\gamma}} \\ket{e}  + \\sum_{b} E_b(t) \\mu(x)\\ket{b_{\\epsilon}} \\ket{g}\n\\end{align*}\nwe may find it useful to diagonalize the vibrational eigenstates into the same manifold as the electronic state using the identities: $\\sum_{q}\n\\ket{q_{\\gamma}}\\bra{q_{\\gamma}}$ and $\\sum_{j}\n\\ket{j_{\\epsilon}}\\bra{j_{\\epsilon}}$.  We also define $\\mu_{a}^{b} = \\bra{a_{\\gamma}} \\mu(x) \\ket{b_{\\epsilon}}$:\n\\begin{align*}\n\t\\frac{\\hat{H}'(t)}{E(t)}  \\ket{\\Psi(t)} &= \\sum_{a, q} G_a(t) \\mu_{a}^{q}\\ket{q_{\\epsilon}} \\ket{e}  + \\sum_{b,r} E_b(t) \\mu_{r}^{b}\\ket{r_{\\gamma}} \\ket{g}\n\\end{align*}\nNow we put everything together:\n\\begin{align*}\n\t\\left(\\frac{d}{dt} +\\frac{i}{\\hbar}\\hat{H}_0 \\right)\\ket{\\Psi(t)}  = -\\frac{i}{\\hbar}\\hat{H}''(t)\\ket{\\Psi(t)} \\\\\n\t\\sum_{a} \\left(\\frac{d G_a(t)}{dt} + \\frac{i}{\\hbar}\\Omega_{(a)}\\right)\\ket{a_{\\gamma}} \\ket{g}  + \\sum_{b} \\left(\\frac{d E_b(t)}{dt} + \\frac{i}{\\hbar} \\Omega^{(b)} \\right)\\ket{b_{\\epsilon}} \\ket{e}\\\\\n\t=-E(t)\\frac{i}{\\hbar} \\left[\\sum_{a, q} G_a(t) \\mu_{a}^{q}\\ket{q_{\\epsilon}} \\ket{e}  + \\sum_{b,r} E_b(t) \\mu_{r}^{b}\\ket{r_{\\gamma}} \\ket{g} \\right]\n\\end{align*}\nNow we can pick out specific terms by ket-ing in with $\\ket{g}\\ket{a_{\\gamma}}$ and $\\ket{b}\\ket{b_{\\epsilon}}$.\n\\begin{align*}\n\t\\left(\\frac{d G_a(t)}{dt} + \\frac{i}{\\hbar}\\Omega_{(a)}\\right) &=-E(t)\\frac{i}{\\hbar}  \\sum_{b} E_b(t) \\mu_{a}^{b}\n\\end{align*}\nand then:\n\\begin{align*}\n\t\\left(\\frac{d E_b(t)}{dt} + \\frac{i}{\\hbar} \\Omega^{(b)} \\right) =-E(t)\\frac{i}{\\hbar} \\sum_{a} G_a(t) \\mu_{a}^{b}\n\\end{align*}\n\nThis can be re-cast as a matrix problem,\n\\begin{align*}\n\t\\frac{d}{dt}\\begin{bmatrix}\n\t\tG_a(t) \\\\\n\t\tE_b(t)\n\t\\end{bmatrix}\n\t= -\\frac{i}{\\hbar}\n\t\\begin{bmatrix}\n\t\t\\Omega_{(a)} & E(t) \\mu_{a}^{b} \\\\\n\t\tE(t) \\mu_{a}^{b} & \\Omega^{b}\n\t\\end{bmatrix}\n\t\\cdot\n\t\\begin{bmatrix}\n\t\tG_a(t) \\\\\n\t\tE_b(t)\n\t\\end{bmatrix}\n\\end{align*}\nThen this is put into a numeric first order differential equation solver.  At every point I make sure there is not too much amplitude in the highest vibrational state and then re-start the calculation if so, ensuring no nonphysical results from truncation of the Hilbert Space.\n\n\\section{Notorious RWA: the Rotating Wave Approximation}\n\nThere's another trick we can use to save a lot of computational time called the rotating wave approximation.  Let's take a look at some laser excitation operator:\n\\begin{align*}\n\t\\hat{H}_{+}'(t) = E_0 e^{-i \\omega_c \\tau} e^{\\frac{\\tau^2 }{2 \\sigma^2}}  \\ket{e}\\bra{g}\n\\end{align*}\nif we assume the ground state has zero energy and the excited state has energy/frequency (because $\\hbar=1$ here) $\\Omega$ then we expect the zero and first order perturbation to look like:\n\\begin{align*}\n\t\\ket{\\psi_0 (t)} &= \\ket{g} \\\\\n\t\\ket{\\psi_{+} (t)} &= -\\frac{i}{\\hbar} \\int_{-\\infty}^{t} U(t, \\tau) \\hat{H}_{+}'(\\tau) \\ket{g} d \\tau \\\\\n\t&= -\\frac{iE_0}{\\hbar} \\int_{-\\infty}^{t} U(t, \\tau)e^{-i \\omega_c \\tau} e^{\\frac{\\tau^2  }{2 \\sigma^2}}  \\ket{e} d \\tau \\\\\n\t&= -\\frac{iE_0}{\\hbar} \\int_{-\\infty}^{t} e^{ -i\\Omega (t - \\tau)}e^{-i \\omega_c \\tau} e^{\\frac{\\tau^2 }{2 \\sigma^2}}  \\ket{e} d \\tau \\\\\n\t&= -\\frac{iE_0}{\\hbar} e^{ -i\\Omega t} \\ket{e} \\int_{-\\infty}^{t} e^{-i ( \\omega_c - \\Omega) \\tau} e^{\\frac{\\tau^2 }{2 \\sigma^2}} d \\tau\n\\end{align*}\nso we see that after the excitation perturbation only depends on $\\omega_c - \\Omega$ or the difference between the central frequency of the pulse and the laser.  Which means that we can wrap those two things together and say that the energy of the excited state is zero and that the laser oscillates at a frequency of $\\omega_c - \\Omega$ instead.\n\\begin{align*}\n\t\\ket{\\psi_0 (t)} &= \\ket{g} \\\\\n\t\\ket{\\psi_{+} (t)} &= -\\frac{iE_0}{\\hbar}\\ket{e} \\int_{-\\infty}^{t} e^{-i \\delta \\omega \\tau} e^{\\frac{\\tau^2 }{2 \\sigma^2}} d \\tau\n\\end{align*}\nWhat does that give us computationally?  It means, primarily, that we can use a smaller time step and have the same accuracy, which will greatly speed up the calculation.  One must be careful, though.  It only works for diagonal Hamiltonians.  Once one has a diagonal (or block diagonal) Hamiltonian, one can use this trick to consider the possible transitions between the diagonal states.\n", "meta": {"hexsha": "85e9a7fd6489911bad44c9ac2e12de7a5403d457", "size": 28787, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ComputationalMethods/text.tex", "max_stars_repo_name": "jgoodknight/dissertation", "max_stars_repo_head_hexsha": "012ad400e1246d2a7e63cc640be4f7b4bf56db00", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-21T06:20:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T06:20:42.000Z", "max_issues_repo_path": "ComputationalMethods/text.tex", "max_issues_repo_name": "jgoodknight/dissertation", "max_issues_repo_head_hexsha": "012ad400e1246d2a7e63cc640be4f7b4bf56db00", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ComputationalMethods/text.tex", "max_forks_repo_name": "jgoodknight/dissertation", "max_forks_repo_head_hexsha": "012ad400e1246d2a7e63cc640be4f7b4bf56db00", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.556372549, "max_line_length": 765, "alphanum_fraction": 0.6761385348, "num_tokens": 9977, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4170585080974681}}
{"text": "% !TeX root = ../smc-report.tex\n% !TeX encoding = UTF-8\n% !TeX spellcheck = en_GB\n\n\\section*{PRISM Tutorial Part 3: Dynamic power management}\n\n  \\subsection*{Dynamic power management}\n\n    In this section will be described the modelisation through PRISM \\cite{KNP11} of a \\textit{DPM} (\\textit{Dynamic Power Management}) system, following the PRISM tutorial found at \\cite{prism-tutorial3}. DPMs are used to apply different power usages to some computing device, according to a predefined strategy that takes into account the current state of the device. This kind of systems have been studied largely in literature, for example in \\cite{qiu2001stochastic} where a DPM for a Fujitsu disk drive has been studied.\n    \n    A generic DPM system is made of three distinct components:\n    \n    \\begin{itemize}\n      \\item \\textit{Service Queue} (\\textit{SQ}): holds the requests that the Service Provider will have to serve, in an ordered fashion, and can have finite queue capacity;\n      \\item \\textit{Service Provider} (\\textit{SP}): serves, one at a time, the requests stored in the Service Queue, serving each time the request at the head of the queue;\n      \\item \\textit{Power Manager} (\\textit{PM}): can change the power state of the Service Provider according to certain policies.\n    \\end{itemize}\n    \n    The \\textit{SP} could be anything that is a computing device that serves requests, such as a disk drive as in \\cite{qiu2001stochastic}, but also a CPU or a Web Server.\n    \n    At any given time, the \\textit{SP} is in one of three possible power states, each of which:\n    \n    \\begin{itemize}\n      \\item \\textit{sleep}: the \\textit{SP} is in a low-power consumption mode and is unable to serve any request unless explicitly awaken by the \\textit{PM};\n      \\item \\textit{idle}: the \\textit{SP} is awake but currently not serving any request, so any newly arriving request will be served immediately by the \\textit{SP};\n      \\item \\textit{busy}: the \\textit{SP} is currently serving a request and will be available to serve the next in queue as soon as it's finished.\n    \\end{itemize}\n    \n    Ideally, when in the \\textit{sleep} state the \\textit{SP} will be requiring little to none power, when in the \\textit{idle} state it will require more, as it is awake and ready to serve requests, while when \\textit{busy} it will require even more, as the \\textit{SP} in that case is actively working on a request. The \\textit{PM} is charged with employing a power consumption strategy by switching the \\textit{SP}'s power state, in order to maximise the availability of the service while minimising the overall power consumption.\n    \n    A first PRISM model for a DPM based on \\cite{qiu2001stochastic} is proposed in Code \\ref{lst:power}, as seen in \\cite{prism-tutorial3}.\n    \n    \\begin{center}\n      \\lstinputlisting[language=prism, caption={PRISM code for the model of a DPM based on \\cite{qiu2001stochastic}, with only the \\textit{SQ} and the \\textit{SP} components. Source \\cite{prism-tutorial3}.}, label={lst:power}]{code/power.sm}\n    \\end{center}\n    \n    In this first model version shown in Code \\ref{lst:power}, only the two modules, for the \\textit{SQ} and the \\textit{SP} components, are introduced. This is an already working strategy, even without the \\textit{PM} component, which would only add a smarter policy for the \\textit{SP}'s power management.\n    \n    It is worth noticing that the model shown in Code \\ref{lst:power} is described as a \\textit{Continuous Time Markov Chain} (\\textit{CTMC}), which allows the use of rates when defining the firing of transitions instead of simple probabilities.\n    \n    \\question{Read the section on \\href{http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Synchronisation}{synchronisation} in the manual. Then, have a look at the definition of the \\prism{SQ} and \\prism{SP} modules, and try to understand what they describe.}\n    \\answer{\n      The \\prism{SQ} and \\prism{SP} modules implement, respectively, the \\textit{SQ} and \\textit{SP} components of the DPM system. Both modules synchronise on three different kinds of actions: \\prism{request}, indicating the arrival of a new request, \\prism{serve}, indicating that a request (except the last) has been served, and \\prism{serve_last}, indicating that the last request in the queue has been served.\n      \n      The \\prism{SQ} module keeps a variable, \\prism{q}, that represents the current number of request in the queue, with maximum capacity given by the constant \\prism{q_max}. When, with the predefined arrival rate \\prism{rate_arrive}, a new request arrives (line 26) the queue is updated accordingly, eventually discarding requests in excess in case of a full queue. When a request is served by the \\prism{SP} module, whether it was the last (line 30) or not (line 28), the queue is decreased accordingly. The distinction for these two cases might seem useless on the \\prism{SQ} side, but it will prove useful for the \\prism{SP} module.\n      \n      The \\prism{SP} module only keeps a variable, \\prism{sp}, indicating the current power state (0 meaning \\textit{sleep}, 1 \\textit{idle} and 2 \\textit{busy}), which starts in the \\textit{idle} state. When a new request arrives, the \\textit{SP} is switched to the \\textit{busy} state in case it was \\textit{idle} (line 51), indicating that it started working on that request right away, while if the power state is either \\textit{sleep} or \\textit{busy} then it's kept the same (line 54). When a request that was not the last in the queue is served (line 52), with service rate defined by the variable \\prism{rate_serve}, the \\textit{SP} is kept in the busy state, meaning that it starts working on the next request in line. Otherwise, if the last request is served (line 58), employing the same service rate, the \\textit{SP} is switched back to the \\textit{idle} state.\n      \n      It is worth noticing that, since by definition only the \\textit{PM} component can decide when the \\textit{SP} has to wake, in this first model, if the \\textit{SP} starts in the \\textit{sleep} state, it would have no way of awaking.\n    }\n    \n    \\question{Download the model file \\bash{power.sm} from above and load it into PRISM.\\\\}\n    \\trivialanswer{\n      The model \\bash{power.sm} loaded into PRISM is shown in Figure \\ref{fig:loaded_model}.\n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.8]{loaded_model.png}\n    \t\t\\end{center}\n    \t\t\\caption{Model \\bash{power.sm} loaded into PRISM.}\n    \t\t\\label{fig:loaded_model}\n    \t\\end{figure}\n    }\n    \n    \\question{Use the PRISM simulator to generate some random paths through the model. Notice how, for a CTMC model like this, the elapsed time as the path progresses is displayed in the table. You will probably find that the size of the queue (\\prism{q}) never gets above 1. Why is this? Generate a path by hand where the queue reaches its maximum size (currently \\prism{q_max}=20). What happens when more requests arrive while the queue is full?}\n    \\answer{\n      By repeatedly selecting the ``Simulate'' button in the PRISM simulator with 1 step it can effectively be seen that the queue size almost never exceeds 1. This because of how arrival and service rates are defined: while the arrival rate of new requests is $1.3\\overline{8}$, meaning that on average a new request arrives every $0.72$ seconds, the service rate is $125$, meaning that on average a request is served in $0.008$ seconds. This means that, when a request is in the queue, the service time of that request is, on average, $90$ times faster than the arrival of a new request. So, although possible, it's just highly unlikely that, with rates so defined, a new request arrives before a service is finished.\n      \n      If instead the action \\prism{request} is repeatedly selected in the PRISM simulator in order to force the arrival of new requests before the service, a full queue can be reached. In this case, as expected, more request arrivals end up in the refusal of these new requests, simply no including them in the queue, which remains at it's full capacity (\\prism{q_max}=20 in this case). It is worth noticing that, in case a new request arrives before a service is completed, even though the \\prism{serve} action remains enabled, it's probability distribution remains the same, since these are all exponentially distributed transitions and thus memoryless.\n    }\n    \n    \\question{What is the size of the state space of this model? (i.e from the initial state, how many possible different states can be reached?) Go back to the ``Model'' tab of the GUI, select menu option ``Model | Build model'' and then look at the statistics displayed in the bottom left corner to check your answer.}\n    \\answer{\n      By selecting the ``Build model'' feature, it can be seen that the state space of this model is made of a total of 21 states. Intuitively, these are made of a state where the \\textit{SP} is \\textit{idle} and the queue empty and 20 states where the \\textit{SP} is \\textit{busy} and the queue has a different number of pending requests (from 1 to 20).\n    }\n    \n  \\dashedrule\n  \n  \\subsection*{Adding the power management control}\n  \n    Now we add to the PRISM model shown in Code \\ref{lst:power} and additional module, \\prism{PM}, responsible of implementing the Power Manager. The \\textit{PM} is the component of a DPM that is charged with waking the \\textit{SP} from sleep or putting it back to sleep according to a specific policy that might be dependent of several factors, such as the current state of the \\textit{SP} or of the \\textit{SQ}.\n    \n    Code \\ref{lst:power_policy1} shows the updated model with the added \\prism{PM} module, which employs a fairly naive policy.\n    \n    \\begin{center}\n      \\lstinputlisting[language=prism, caption={PRISM code for the model of a DPM based on \\cite{qiu2001stochastic}, with the \\textit{SQ}, \\textit{SP} and \\textit{PM} components. Source \\cite{prism-tutorial3}.}, label={lst:power_policy1}]{code/power_policy1.sm}\n    \\end{center}\n    \n    \\question{Look at the code we have added to the \\prism{SP} module and at the new \\prism{PM} module. Make sure you understand how they work.}\n    \\answer{\n      The \\prism{PM} module has the function of wake the \\textit{SP} or to put it back to sleep according, in this case, to the current size of the queue.\n      \n      In particular, when in the queue there are at least \\prism{q_trigger} elements the modules \\prism{PM} and  \\prism{SP} can synchronise on the action \\prism{sleep2idle} (lines 56, 57 and 87), effectively waking up the \\textit{SP} in case it was still asleep, as the action name suggests. If, when the awakening is triggered, the queue \\prism{q} is empty then the \\textit{SP} is switched to the \\textit{idle} state, otherwise it's switched directly to the \\textit{busy} state, i.e. working on the request on top of the queue.\n      \n      Whenever, instead, the queue becomes empty, the \\prism{PM} and \\prism{SP} modules can synchronize on the \\prism{idle2sleep} action (lines 59 and 90), effectively waking up the \\textit{SP}.\n      \n      It is worth noticing how the operations of waking the \\textit{SP} up and putting it back to sleep are not immediate but instead, when the corresponding conditions are met, are characterised by rates (\\prism{rate_s2i} and \\prism{rate_i2s}, respectively). Also, in this second version of the model, the \\prism{SP}'s power state is now initialised as 0 (i.e. \\textit{sleep} state), since now, thanks to the \\prism{PM} module, initialising the \\textit{SP} in the \\textit{sleep} state wouldn't end up in a deadlock any more.\n    }\n    \n    \\question{Now use the simulator to generate a trace through this new model. When you create a new path, you have to specify a value for the constant \\prism{q_trigger}, because it is left undefined in the model. Try a value of 5 for now. Does this new model behave as you expect?}\n    \\answer{\n      After a few simulation steps, it can be seen that the model actually behaves as expected. In particular, between 0 and 4 requests the \\textit{SP} has no other option than staying in the \\textit{sleep} state and, thus, the model has just one available transition at each step, that is the arrival of new requests. When the queue reaches 5 requests, the waking condition is met, but sometimes the awakening is not immediate and some additional requests (usually 1 or 2) manage to arrive before the \\textit{SP} is properly awaken: this is due the fact that the awaking rate (\\prism{rate_s2i}) is slightly smaller than the request arrival rate (\\prism{request}), meaning that on average the arrival of a new request is slightly faster than the awakening of \\textit{SP}.\n      \n      Similarly, once the queue has been emptied, the \\textit{SP} can be switched back to \\textit{sleep} right away or it could happen that a request manages to arrive before that happens, forcing the \\textit{SP} to serve it first by switching to the \\textit{busy} state.\n    }\n    \n  \\dashedrule\n    \n  \\subsection*{Analysing the model}\n  \n    We'll analyse now various aspects of the model, exploiting the properties and analyses features that PRISM offers.\n    \n    \\question{\n      Go to the \"Properties\" tab of the GUI, create a new constant called T, of type double and with no defined value. Then add the following property:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/q_max_P.pctl}\n    }\n    \\trivialanswer{\n      The property regarding the full queue added through the PRISM interface is shown in Figure \\ref{fig:q_max_property}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.8]{q_max_property.png}\n    \t\t\\end{center}\n    \t\t\\caption{Full queue property added in PRISM.}\n    \t\t\\label{fig:q_max_property}\n    \t\\end{figure}\n    }\n    \n    \\question{Now, create an \\href{http://www.prismmodelchecker.org/manual/RunningPRISM/Experiments}{experiment} based on this property, plotting a graph of its result for \\prism{q_trigger} equal to 5 and \\prism{T} from 0 up to 20, i.e. for the first 20 seconds of the system.}\n    \\answer{\n      The resulting experiment plot, with steps of $0.5$ seconds, is shown in Figure \\ref{fig:q_max_plot_0-20}.\n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{q_max_plot_0-20.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the full queue between time 0 and 20.}\n    \t\t\\label{fig:q_max_plot_0-20}\n    \t\\end{figure}\n    }\n    \n    \\question{It seems that the transient probability of the queue being full stabilises after a short while. Using another experiment, plot values for the same property on the same graph, this time for \\prism{T} from 20 up to 40, and see if the probability remains the same. To confirm this, now create a property to check the long-run probability of the queue being full, using the \\href{http://www.prismmodelchecker.org/manual/PropertySpecification/TheSOperator}{S operator}. Right click the new property and select ``Verify''. You will need to give a value for \\prism{T} but this is not used so you can enter anything. It turns out that the default iterative method in PRISM (Jacobi) for solving this kind of property does not converge in this case. Switch to the Gauss-Seidel method from the ``Options'' dialog and try again. Check that your result matches the graph.}\n    \\answer{\n      From the extended plot shown in Figure \\ref{fig:q_max_plot_0-40} it seems that the probability of reaching a full queue indeed stabilises.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{q_max_plot_0-40.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the full queue between time 0 and 40.}\n    \t\t\\label{fig:q_max_plot_0-40}\n    \t\\end{figure}\n    \t\n    \tIn order to check the steady-state probability of the queue being full in a more direct fashion, the following property, that exploits the S operator, can be used:\n    \t\n      \\lstinputlisting[language=prism, numbers=none]{code/q_max_S.pctl}\n      \n      By trying to evaluate the property using the default iterative method (Jacobi) the evaluation indeed does not converge and PRISM prompts an error. Instead, using the Gauss-Seidel iterative method, the computed steady-state probability of the queue being full results being $0.0010287642322871614$. Watching at the plot in Figure \\ref{fig:q_max_plot_0-40} it looks like the probability of a full queue stabilises slightly above $0.0010$, which matches with the obtained result.\n    }\n    \n    \\question{Read the section on \\href{http://www.prismmodelchecker.org/manual/ThePRISMLanguage/CostsAndRewards}{costs and rewards} in the manual. Then, look at the rewards that have already been defined in this model.}\n    \\answer{\n      The only reward that has been defined in the model in Code \\ref{lst:power_policy1} is \\prism{queue_size} which, at any given time, is equivalent to the current number of requests present in the queue.\n    }\n    \n    \\question{\n      Add these two properties which can be used to compute the transient and long-run expected queue size, respectively:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/queue_size.pctl}\n    }\n    \\trivialanswer{\n      The properties regarding the queue size added through the PRISM interface are shown in Figure \\ref{fig:queue_size_properties}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.8]{queue_size_properties.png}\n    \t\t\\end{center}\n    \t\t\\caption{Queue size properties added in PRISM.}\n    \t\t\\label{fig:queue_size_properties}\n    \t\\end{figure}\n    }\n    \n    \\question{Plot the expected queue size at time \\prism{T}, for the first 20 seconds of the model. As above, also compute the long-run value and check that it matches the results on the graph.}\n    \\answer{\n      The experiment plot is shown in Figure \\ref{fig:queue_size_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{queue_size_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the queue size between time 0 and 20.}\n    \t\t\\label{fig:queue_size_plot}\n    \t\\end{figure}\n    \t\n    \tEvaluating instead the steady-state property, it can be seen that the number of requests in the queue at steady-state is $3.2038846166301242$, which seems to match to the transient results shown in the plot in Figure \\ref{fig:queue_size_plot}.\n    }\n    \n    \\question{Now create some experiments to analyse the transient and/or long-run expected queue size for a range of different values of the constant \\prism{q_trigger}. How does the performance of the system vary as this changes? What is the ``best'' value of \\prism{q_trigger}?}\n    \\answer{\n      Transient analysis results between time 0 and 40 and for \\prism{q_trigger} between 0 and 21 are shown in Figure \\ref{fig:queue_size-q_trigger_plot_I}. The last value, \\prism{q_trigger}=21, has been included to show what happens in a scenario where the \\textit{SP} never wakes.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{queue_size-q_trigger_plot_I.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the queue size between time 0 and 40 and for \\prism{q\\_trigger} between 0 and 21.}\n    \t\t\\label{fig:queue_size-q_trigger_plot_I}\n    \t\\end{figure}\n      \n      As expected, the average queue size is higher for higher values of \\prism{q_trigger}. After some time this value tends to stabilise, although for higher values of \\prism{q_trigger} it seems as it needs more time in order to reach the steady-state. For \\prism{q_trigger}=21, as expected, the queue fills completely and never gets the change to get emptied. According to the plot in Figure \\ref{fig:queue_size-q_trigger_plot_I} we could say that the ``best'' values for \\prism{q_trigger} are the lowest (from 0 to 5), since for those values the average queue size stabilises earlier, thus producing a more predictable behaviour.\n      \n      In Figure \\ref{fig:queue_size-q_trigger_plot_S} is instead shown the average queue size at steady-state, for the same range of values for \\prism{q_trigger}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{queue_size-q_trigger_plot_S.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the queue size at steady-state for \\prism{q\\_trigger} between 0 and 21.}\n    \t\t\\label{fig:queue_size-q_trigger_plot_S}\n    \t\\end{figure}\n      \n      As expected, the average queue size rises as \\prism{q_trigger} grows and it's exactly 20 for \\prism{q_trigger}$\\geq 21$. But is can also be observed that the growth is not exactly linear: for example for \\prism{q_trigger}=1 the average queue size is $1.734$, while for \\prism{q_trigger}=3 it's $2.383$.\n      \n      Ideally, we would like to have the queue as empty as possible at any time, because that would mean that requests are handled rapidly and there is more room for future requests, while at the same time consuming as few resources as possible, for example by keeping the \\textit{SP} in the \\textit{sleep} state for longer. In Figure \\ref{fig:queue_size_coefficient_plot} we are showing then the \\textit{queue size coefficient}, evaluated as \\prism{q/q_trigger}, in order to find the best trade-off between these two factors. In particular, the coefficient is added to the PRISM model by including the following reward structure:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/queue_size_coefficient.sm}\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{queue_size_coefficient_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the queue size coefficient at steady-state for \\prism{q\\_trigger} between 0 and 21.}\n    \t\t\\label{fig:queue_size_coefficient_plot}\n    \t\\end{figure}\n      \n      The results in Figure \\ref{fig:queue_size_coefficient_plot} shows that, for \\prism{q_trigger}=1 and 2, the coefficient is above 1, meaning that the average queue size is usually higher than the value of \\prism{q_trigger}. For \\prism{q_trigger}$\\geq 3$ instead, the coefficient is lower than zero and decreasing, except for \\prism{q_trigger}=21, which becomes higher again. According to this experiment then, we are able to say that the ``best'' value for \\prism{q_trigger} is $20$, since in this case the queue size coefficient is at it's lowest (looking at the plot in Figure \\ref{fig:queue_size-q_trigger_plot_S} we can see that for \\prism{q_trigger}=20 the average queue size is $10.126$).\n    }\n    \n    \\question{Add a second \\href{http://www.prismmodelchecker.org/manual/ThePRISMLanguage/CostsAndRewards}{reward structure} to the model called ``lost'', which assigns 1 to every transition of the model labelled with action \\prism{request} from a state where the queue is full.}\n    \\answer{\n      The reward ``lost'' is simply included in the PRISM model by adding at the end the following lines:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/lost.sm}\n    }\n    \n    \\question{Now create a new property to check the expected \\textit{cumulated} reward up until time \\prism{T}. Don't forget to specify which reward structure you want in the property. (You might want to look at \\href{http://www.prismmodelchecker.org/manual/PropertySpecification/Reward-basedProperties}{this section} of the manual.) How does this measure vary for different values of \\prism{q_trigger}?}\n    \\answer{\n      In Figure \\ref{fig:lost_plot} are shown the results for the cumulative lost requests between time 0 and 40 and for values of \\prism{q_trigger} between 0 and 20. The experiment is conducted using the following property:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/lost_cumulative.pctl}\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{lost_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the cumulative lost requests between time 0 and 40 and for \\prism{q\\_trigger} between 0 and 20.}\n    \t\t\\label{fig:lost_plot}\n    \t\\end{figure}\n      \n      As expected, the cumulative lost requests are more as time goes on, but also for higher values of \\prism{q_trigger} this values grows at higher rates. This is intuitive since when the \\textit{SP} only wakes up after more requests have arrived in the queue, the chances of reaching the queue saturation are higher.\n    }\n    \n    Let's imagine now to introduce a measure of the actual power consumption. In particular, energy consumption rates are $0.13$, $0.95$ and $2.15$, for the power states \\textit{sleep}, \\textit{idle} and \\textit{busy}, respectively. On top of that, switching from \\textit{sleep} to \\textit{idle} costs $7.0$ energy units, while from \\textit{idle} to \\textit{sleep} costs $0.067$ energy units.\n    \n    \\question{Add a third reward structure to the model representing the power consumption. Use a cumulative reward property to investigate the energy consumption over time of the system.}\n    \\answer{\n      First of all, in order to add the desired reward structure, the following rates have to be included in the model:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/consumption_rates.sm}\n      \n      Then, inside the \\prism{SP} module, the following transitions have to be included:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/consumption_transitions.sm}\n      \n      Finally, the ``consumption'' reward structure can be defined as follows:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/consumption_reward.sm}\n      \n      Experiment results are shown in Figure \\ref{fig:consumption_policy1_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{consumption_policy1_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the cumulative energy consumption between time 0 and 40 and for \\prism{q\\_trigger} between 0 and 20.}\n    \t\t\\label{fig:consumption_policy1_plot}\n    \t\\end{figure}\n      \n      As expected, the cumulative energy consumption grows as time goes on, but it can also be observed that the energy consumption is lower for higher values of \\prism{q_trigger}, which is obvious considering that in these scenarios the \\textit{SP} spends, on average, more time in the \\textit{sleep} state, consuming less energy.\n    }\n    \n  \\dashedrule\n  \n  \\subsection*{Extensions}\n  \n    \\question{\n      Replace the PM module in the existing model with the following:\\\\\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/PM_stochastic_policy.sm}\n    }\n    \\trivialanswer{\n      The model with stochastic policy loaded into PRISM is shown in Figure \\ref{fig:loaded_model_stochastic_policy}.\n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.35]{loaded_model_stochastic_policy.png}\n    \t\t\\end{center}\n    \t\t\\caption{Model with stochastic policy loaded into PRISM.}\n    \t\t\\label{fig:loaded_model_stochastic_policy}\n    \t\\end{figure}\n    }\n    \n    \\question{How well does this power management system perform? What effect does the value of the probability \\prism{p_sleep} have?}\n    \\answer{\n      The results of the experiments concerning the cumulative energy consumption with the stochastic policy are shown in Figure \\ref{fig:consumption_stochastic_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{consumption_stochastic_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the cumulative energy consumption employing the stochastic policy, between time 0 and 40 and for \\prism{p\\_sleep} between 0 and 1, with step $0.1$.}\n    \t\t\\label{fig:consumption_stochastic_plot}\n    \t\\end{figure}\n      \n      Again, the energy consumption grows as the time goes on, but also it tends to be lower for higher values of \\prism{p_sleep}, yielding top performance when \\prism{p_sleep}=1, i.e. when the \\textit{SP} always gets put to sleep after the queue has been emptied. On top of that, we can notice that while for the previous simpler policy the energy consumption, after 40 seconds, could reach, on average, almost 140 units (see Figure \\ref{fig:consumption_policy1_plot}), with this new policy the maximum at \\prism{T}=40 is $32.392$, for \\prism{p_sleep}=0, making this second policy way more performing than the previous one.\n    }\n    \n    \\question{Can you think of any ways of improving these power management strategies? Implement them in the PRISM model and see how well they perform.}\n    \\answer{\n      A possible way of minimising even further the energy consumption is to reverse the idea behind the stochastic policy introduced previously. In particular, we now want to always put the \\textit{SP} to sleep when the queue has been emptied and wake it up only when the queue is full but only with a certain probability. This policy is implemented by the following code for the \\prism{PM} module:\n      \n      \\lstinputlisting[language=prism, numbers=none]{code/PM_custom_policy.sm}\n      \n      The results of the experimentation with this new policy are shown in Figure \\ref{fig:consumption_custom_plot}.\n      \n    \t\\begin{figure}[h!]\n    \t\t\\begin{center}\n    \t\t\t\\includegraphics[scale=0.45]{consumption_custom_plot.eps}\n    \t\t\\end{center}\n    \t\t\\caption{Experiment plot of the cumulative energy consumption employing a new custom policy, between time 0 and 40 and for \\prism{p\\_sleep} between 0 and 1.}\n    \t\t\\label{fig:consumption_custom_plot}\n    \t\\end{figure}\n      \n      It can be observed that, by increasing the value of \\prism{p_sleep}, i.e. the probability of remaining asleep even with a full queue, the cumulated energy consumption tends to be lower. This policy basically tries to minimise the number of times the \\textit{SP} wakes up, being the wake up process a highly consuming action. Clearly, with this policy the number of lost requests is expected to be higher, but in a scenario where energy consumption is a central problem and some lost request is not such a big deal, this might be a good solution. In particular, the ``best'' case would be that with \\prism{p_sleep}=1, but that would mean that the \\textit{SP} never wakes up, which would be unrealistic.\n      \n      In order to further analyse the model, and devise smarter policies, both the energy consumption and the number of lost requests should be taken into account, in order to find the best trade-off.\n    }\n    \n  \\dashedrule\n", "meta": {"hexsha": "622a11bccf661b4002b56a3f314236b75a448235", "size": 30366, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd/courses/smc/body/part_3.tex", "max_stars_repo_name": "oddlord/uni", "max_stars_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "phd/courses/smc/body/part_3.tex", "max_issues_repo_name": "oddlord/uni", "max_issues_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd/courses/smc/body/part_3.tex", "max_forks_repo_name": "oddlord/uni", "max_forks_repo_head_hexsha": "a1226bd41b0208d0aac08c15c3372a759df0cb63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.2586206897, "max_line_length": 873, "alphanum_fraction": 0.7354607126, "num_tokens": 7744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5964331319177488, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.41705850435940756}}
{"text": "\\section{Accelerated Sampling Methods}\n\\label{section:accel}\n\n\\subsection{Accelerated Molecular Dynamics}\n\\label{section:accelmd}\nAccelerated molecular dynamics (aMD)~\\cite{HAME2004mc} is an enhanced-sampling method that\nimproves the conformational space sampling by \nreducing energy barriers separating different states of a system.\nThe method modifies the potential \nenergy landscape by raising energy wells that are below\na certain threshold level, while leaving those above this level unaffected.\nAs a result, barriers separating adjacent energy basins are reduced, allowing the system to sample\nconformational space that cannot be easily accessed in a classical MD simulation.\n\nPlease include the following two references in your work using the NAMD implementation of aMD:\n\\begin{itemize}\n  \\item {Accelerated Molecular Dynamics: A Promising and Efficient Simulation Method for Biomolecules, D.\\,Hamelberg, J.\\,Mongan, and J.\\,A. McCammon. {\\it J. Chem. Phys.}, 120:11919-11929, 2004.}\n  \\item{Implementation of Accelerated Molecular Dynamics in NAMD, Y.\\,Wang, C.\\,Harrison, K.\\,Schulten, and J.\\,A. McCammon, {\\it Comp.~Sci.~Discov.}, 4:015002, 2011.}\n\\end{itemize}\n\n\\subsubsection{Theoretical background}\nIn the original form of aMD~\\cite{HAME2004mc}, when the system's potential energy falls       \nbelow a threshold energy, $E$, a boost potential is added, \nsuch that the modified potential, $V^*({\\bf r})$, is related to the original\npotential, $V({\\bf r})$, via\n\\begin{equation}\nV^*({\\bf r})= V({\\bf r}) + \\Delta V({\\bf r}),\n\\end{equation}\nwhere $\\Delta V({\\bf r})$ is the boost potential, \n\\begin{equation} \n\\Delta V({\\bf r})= \\left \\{\n\\begin{array}{l l}\n0   & \\quad \\quad V({\\bf r})\\geq E \\\\  \n\\frac{(E-V({\\bf r}))^2}{\\alpha+E-V({\\bf r})}  & \\quad \\quad V({\\bf r})<E. \\\\\n\\end{array} \\right. \n\\end{equation}\nAs shown in the following figure, the threshold energy $E$ controls the portion of \nthe potential surface affected by the boost, while the acceleration factor \n$\\alpha$ determines the shape of the modified potential.\n%as $\\alpha$ increases, the modified potential asymptotically approaches the original potential;\n%as $\\alpha$ decreases, the energy surface below $E$ begins to resemble a constant potential.\nNote that $\\alpha$ cannot be set to zero, otherwise the derivative of the modified potential\nis discontinuous.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=7cm]{figures/amd_schematic.jpg}\n  \\caption{Schematics of the aMD method. When the original potential (thick line) falls below a threshold energy $E$ (dashed line),\n          a boost potential is added. The modified energy profiles (thin lines) have smaller barriers separating adjacent\n\t  energy basins. \n\t  %Two parameters, $E$ and $\\alpha$, controls the portion of the affected potential landscape and the\n\t  %shape of the modified potential, respectively.\n\t  }\n  \\label{fig:amd_schematic}\n\\end{figure}\nFrom an aMD simulation, the ensemble average, $\\langle A \\rangle$, of an observable, $A({\\bf r})$, can be calculated\nusing the following reweighting procedure:\n\\begin{equation}\n\\langle A \\rangle =\\frac{\\langle A({\\bf r})\\,\\text{exp} (\\beta \\Delta V({\\bf r})) \\rangle^* }\n{\\langle \\text{exp}  (\\beta \\Delta V({\\bf r})) \\rangle^*},\n\\end{equation}\nin which $\\beta$=$1/k_BT$, and $\\langle ... \\rangle$ and $\\langle...\\rangle^*$ represent \nthe ensemble average in the original and the aMD ensembles, respectively. \n\nCurrently, aMD can be applied in three modes in NAMD: aMDd, aMDT, and aMDdual~\\cite{WANG2011mc}. The boost energy\nis applied to the dihedral potential in the aMDd mode (the default mode), and to the total potential in the aMDT mode.\nIn the dual boost mode (aMDdual)~\\cite{HAME2007mc}, two independent boost energies are applied, one on the dihedral potential and the other\non the (Total - Dihedral) potential.\n\n\\subsubsection{NAMD parameters}\n\nThe following parameters are used to enable accelerated MD:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{accelMD}{Is accelerated molecular dynamics active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies if accelerated MD is active.}\n\n\\item\n\\NAMDCONFWDEF{accelMDdihe}{Apply boost to dihedrals?}{{\\tt on} or {\\tt off}} {{\\tt on}} \n{Only applies boost to the dihedral potential. \nBy default, {\\tt accelMDdihe} is turned on and the boost energy is applied to the dihedral potential of the simulated system.\nWhen {\\tt accelMDdihe} is turned off, aMD switches to the {\\tt accelMDT} mode, and the boost is applied to the total potential.\n}\n\n\\item\n\\NAMDCONF{accelMDE}{Threshold energy $E$}\n{Real number}\n{Specifies the threshold energy $E$ in the aMD equations. \n}\n\n\\item\n\\NAMDCONF{accelMDalpha}{Acceleration factor $\\alpha$}\n{Positive real number}\n{Specifies the acceleration factor $\\alpha$ in the aMD equations. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDdual}{Use dual boost mode?}{{\\tt on} or {\\tt off}}{{\\tt off}}\n{When {\\tt accelMDdual} is on, aMD switches to the dual boost mode. Two independent boost potentials \nwill be applied: one to the dihedral potential that is controlled by the parameters {\\tt accelMDE} and {\\tt accelMDalpha},\nand a second to the (Total - Dihedral) potential that is controlled by the  {\\tt accelMDTE} and {\\tt accelMDTalpha} parameters described below.\n}\n\n\\item\n\\NAMDCONF{accelMDTE}{Threshold energy $E$ in the dual boost mode}\n{Real number}\n{Specifies the threshold energy $E$ used in the calculation of boost energy for the (Total - Dihedral) potential. \nThis option is only available when {\\tt accelMDdual} is turned on.\n}\n\n\\item\n\\NAMDCONF{accelMDTalpha}{Acceleration factor $\\alpha$ in the dual boost mode}\n{Positive real number}\n{Specifies the acceleration factor $\\alpha$ used in the calculation of boost energy for the (Total - Dihedral) potential. \nThis option is only available when {\\tt accelMDdual} is turned on.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDFirstStep}{First accelerated MD step}\n{Zero or positive integer}{0}\n{Accelerated MD will only be performed when the current step is equal to or higher than {\\tt accelMDFirstStep}, and equal to or lower than {\\tt accelMDLastStep}. Otherwise regular MD will be performed.\n}\n\\item\n\\NAMDCONFWDEF{accelMDLastStep}{Last accelerated MD step}\n{Zero or positive integer}{0}\n{Accelerated MD will only be performed when the current step is equal to or higher than {\\tt accelMDFirstStep}, and equal to or lower than {\\tt accelMDLastStep}. Otherwise regular MD will be performed. Note that the accelMDLastStep parameter only has an effect when it is positive. When accelMDLastStep is set to zero (the default), aMD is `open-ended' and will be performed\ntill the end of the simulation. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDOutFreq}{Frequency in steps of aMD output}\n{Positive integer}{1}\n{An aMD output line will be printed to the log file at the frequency specified by {\\tt accelMDOutFreq}.\nThe aMD output will contain the boost potential ($dV$) at the current timestep, \nthe average boost potential ($dVAVG$) since the last aMD output, and various potential energy values at the current timestep.\nThe boost potential $dV$ can be used to reconstruct the ensemble average described earlier.\n}\n\n\\end{itemize}\n\n\n\\subsection{Gaussian Accelerated Molecular Dynamics}\n\\label{section:accelmdg}\nGaussian accelerated molecular dynamics (GaMD) \\cite{MIAO2015mc} is a type of accelerated molecular dynamics (aMD) calculation. It is an enhanced sampling method that works by adding a harmonic boost potential to smoothen the system's potential energy surface. \nBy constructing a boost potential that follows Gaussian distribution, accurate reweighting of the GaMD simulations is achieved using cumulant expansion to the second order.  \n\n\nPlease include the following two references in your work using the NAMD implementation of GaMD:\n\\begin{itemize}\n  \\item {Gaussian Accelerated Molecular Dynamics: Unconstrained Enhanced Sampling and Free Energy Calculation, Y.\\,Miao, V.\\,Feher, and J.\\,A. McCammon. {\\it J. Chem. Theory Comput.}, 11:3584-3595, 2015.}\n  \\item{Gaussian Accelerated Molecular Dynamics in NAMD, Y.T.\\,Pang, Y.\\,Miao, Y.\\,Wang, and J.\\,A. McCammon, {\\it J. Chem. Theory Comput.}, 13:9-19, 2017.}\n\\end{itemize}\n\n\\subsubsection{Theoretical background}\nGaMD enhances conformational sampling of biomolecules by adding a harmonic boost potential to smoothen the system's potential energy surface~\\cite{MIAO2015mc}, as illustrated below:\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=7cm]{figures/GaMD-scheme.jpg}\n  \\caption{Schematic illustration of GaMD. When the threshold energy $E$ is set to the maximum potential ($iE=1$ mode), the system's potential energy surface is smoothened by adding a harmonic boost potential that follows a Gaussian distribution. The coefficient $k_0$, which falls in the range of $0 - 1.0$, determines the magnitude of the applied boost potential.}\n  \\label{fig:gamd_schematic}\n\\end{figure}\n\nConsider a system with $N$ atoms at positions ${\\bf r} = \\big\\{{\\bf r}_1,\\cdots,{\\bf r}_N \\}$. \nWhen the system's potential energy $V({\\bf r})$ is lower than a threshold energy $E$, the following boost potential is added:\n\\begin{equation}\nV^*({\\bf r})= V({\\bf r}) + \\Delta V({\\bf r}),\n\\end{equation}\nwhere $\\Delta V({\\bf r})$ is the boost potential, \n\\begin{equation} \n\\Delta V({\\bf r})= \\left \\{\n\\begin{array}{l l}\n\\frac{1}{2} k \\left( E - V({\\bf r}) \\right)^2,  & \\qquad V({\\bf r})<E \\\\\n0,   & \\qquad V({\\bf r})\\geq E. \\\\  \n\\end{array} \\right. \n\\end{equation}\nwhere $k$ is the harmonic force constant.\n\nAs explained in reference~\\cite{MIAO2015mc}, the two adjustable parameters $E$ and $k$ are automatically determined by the following three criteria. \nFirst, $\\Delta V$ should not change the relative order of the biased potential values, i.e., for any two arbitrary potential values $V_1 (\\bf r)$ and $V_2 (\\bf r)$ found on the original energy surface, if $V_1 ({\\bf r}) < V_2 ({\\bf r})$, \nthen one should have $ V_1^* ({\\bf r}) < V_2^* ({\\bf r})$.\nSecond, the difference between potential energy values on the smoothened energy surface should be smaller than that of the original, \ni.e., if $V_1 ({\\bf r}) < V_2 ({\\bf r})$,  then one should have $ V_2^* ({\\bf r}) - V_1^* ({\\bf r}) < V_2 ({\\bf r}) - V_1 ({\\bf r})$.\nBy combining the above two criteria and plugging in the formula of $V^* ({\\bf r})$ and $\\Delta V$, one obtains\n\\begin{equation}\nV_\\text{max} \\leq E \\leq V_\\text{min} + \\frac{1}{k}\n\\label{eqn:limit}\n\\end{equation}\nwhere $V_\\text{min}$ and $V_\\text{max}$ are the system's minimum and maximum potential energies. To ensure that Eqn.\\,(\\ref{eqn:limit}) is valid, $k$ needs \nto satisfy: $k \\leq \\frac{1}{ V_\\text{max} - V_\\text{min} }$. \nDefine $k \\equiv k_0 \\cdot \\frac{1}{V_\\text{max} - V_\\text{min}}$, then $0 < k_0 \\leq 1$.\nThird, the standard deviation of $\\Delta V$ needs to be small enough (i.e., narrow distribution) to ensure accurate reweighting using cumulant expansion to the second order: \n$\\sigma_{\\Delta V} = k \\left( E - V_\\text{avg} \\right) \\sigma_V \\leq \\sigma_0$, \nwhere $V_\\text{avg}$ and $\\sigma_V$ are the average and standard deviation of the system's potential energies, \n$\\sigma_{\\Delta V}$ is the standard deviation of $\\Delta V$, while $\\sigma_0$ is a user-specified upper limit (e.g., $10 k_B T$) in order to achieve accurate reweighting.\n\n{\\bf iE = 1 mode:} When $E$ is set to $E = V_\\text{max}$ according to Eqn.\\,(\\ref{eqn:limit}), \n$k_0$ is calculated as:\n\\begin{equation}\nk_0 = \\min(1.0, k'_0) = \\min \\left( 1.0, \\frac{\\sigma_0}{\\sigma_V} \\cdot\n\\frac{V_\\text{max} - V_\\text{min}}{V_\\text{max} - V_\\text{avg}} \\right)\n\\label{eqn:mode1}\n\\end{equation}\n\n{\\bf iE = 2 mode:} Alternatively, when $E$ is set to $E = V_\\text{min} + \\frac{1}{k}$, \n$k_0$ is calculated as:\n\\begin{equation}\nk_0 = k''_0 \\equiv \\left( 1 - \\frac{\\sigma_0}{\\sigma_V} \\cdot \n\\frac{V_\\text{max} - V_\\text{min}}{V_\\text{avg} - V_\\text{min}} \\right)\n\\label{eqn:mode2}\n\\end{equation}\nIf $k''_0$ obtained from the above equation is smaller than 0 or greater than 1, then $k_0$ will be calculated using Eqn.\\,(\\ref{eqn:mode1}).\n\nFor more details on GaMD and the corresponding reweighting using cumulant expansion, see reference~\\cite{MIAO2015mc}\\cite{PANG2017mc}. \n\n\\subsubsection{NAMD parameters}\n\nSame as aMD, three modes are available for applying boost potential in GaMD: \n(1) boosting the dihedral energy only, \n(2) boosting the total potential energy, and \n(3) boosting both the dihedral and total potential energy (i.e., ``dual-boost\").\n\nSome parameters from aMD, including: {\\tt accelMD}, {\\tt accelMDdihe}, {\\tt accelMDdual}, {\\tt accelMDFirstStep}, {\\tt accelMDLastStep} and {\\tt accelMDOutFreq} are shared by GaMD (see Section \\ref{section:accelmd} for details).\nThe following is a list of input parameters unique to a GaMD run:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{accelMDG}{Is Gaussian accelerated MD on?}\n{{\\tt on} or {\\tt off}}{{\\tt off}}\n{Specifies whether Gaussian accelerated MD (GaMD) is on. Only available when {\\tt accelMD} is on. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGiE}{Flag to set the threshold energy for adding boost potential}\n{1 or 2}{1}\n{Specifies how the threshold energy $E$ is set in GaMD. A value of 1 indicates that the threshold energy $E$ is set to its lower bound $E = V_\\text{max}$. A value of 2 indicates that the threshold energy is set to its upper bound $E = V_\\text{min} + (V_\\text{max} - V_\\text{min}) / k_0.$\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGcMDPrepSteps}{Number of preparatory cMD steps}\n{Zero or Positive integer}{200,000}\n{The number of preparatory conventional MD (cMD) steps in GaMD. This value should be smaller than {\\tt accelMDGcMDSteps} (see below). Potential energies are not collected for calculating the values of $V_\\text{max}$, $V_\\text{min}$, $V_\\text{avg}$, $\\sigma_V$ during the first {\\tt accelMDGcMDPrepSteps}. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGcMDSteps}{Number of total cMD steps}\n{Zero or Positive integer}{1,000,000}\n{The number of total cMD steps in GaMD. With ${\\tt accelMDGcMDPrepSteps} < t < {\\tt accelMDGcMDSteps}$, $V_\\text{max}$, $V_\\text{min}$, $V_\\text{avg}$, $\\sigma_V$ are collected and at $t = {\\tt accelMDGcMDSteps}$, $E$ and $k_0$ are computed.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGEquiPrepSteps}{Number of preparatory equilibration steps in GaMD}\n{Zero or Positive integer}{200,000}\n{The number of preparatory equilibration steps in GaMD. This value should be smaller than {\\tt accelMDGEquiSteps} (see below). With ${\\tt accelMDGcMDSteps} < t < {\\tt accelMDGEquiPrepSteps}+{\\tt accelMDGcMDSteps}$, GaMD boost potential is applied according to $E$ and $k_0$ obtained at $t={\\tt accelMDGcMDSteps}$. \n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGEquiSteps}{Number of total equilibration steps in GaMD}\n{Zero or Positive integer}{1,000,000}\n{The number of total equilibration steps in GaMD. With ${\\tt accelMDGEquiPrepSteps}+{\\tt accelMDGcMDSteps} < t < {\\tt accelMDGEquiSteps} +{\\tt accelMDGcMDSteps}$, GaMD boost potential is applied, and $E$ and $k_0$ are updated every step.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGStatWindow}{Number of steps to calculate average and standard deviation in GaMD}\n{Integer}{-1}\n{The number of simulation steps used to calculate the average and standard deviation of potential energies, as well as the frequency of recalculating the boost potential during equilibration steps. When it is set to a negative number, all the steps throughout the cMD and equilibration stage (except the preparatory steps) will be used to calculate the average and standard deviation without resetting, and the boost potential will be updated every step during equilibration steps. When used, it is recommended to be set to about 4 times the total number of atoms in the system. Note that {\\tt accelMDGcMDPrepSteps}, {\\tt accelMDGcMDSteps}, {\\tt accelMDGEquiPrepSteps} and {\\tt accelMDGEquiSteps} need to be multiples of {\\tt accelMDGStatWindow}.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGSigma0P}{Upper limit of the standard deviation of the total boost potential in GaMD}\n{Positive real number}{6.0 (kcal/mol)}\n{Specifies the upper limit of the standard deviation of the total boost potential. This option is only available when {\\tt accelMDdihe} is off or when {\\tt accelMDdual} is on.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGSigma0D}{Upper limit of the standard deviation of the dihedral boost potential in GaMD}\n{Positive real number}{6.0 (kcal/mol)}\n{Specifies the upper limit of the standard deviation of the dihedral boost potential. This option is only available when {\\tt accelMDdihe} or {\\tt accelMDdual} is on.\n}\n\n\\item\n\\NAMDCONFWDEF{accelMDGRestart}{Flag to restart GaMD simulation}\n{{\\tt on} or {\\tt off}}{{\\tt off}}\n{Specifies whether the current GaMD simulation is the continuation of a previous run. If this option is turned on, the GaMD restart file specified by {\\tt accelMDGRestartFile} (see below) will be read. \n}\n\n\\item\n\\NAMDCONF{accelMDGRestartFile}{Name of GaMD restart file}\n{UNIX filename}\n{A GaMD restart file that stores the current number of steps, maximum, minimum, average and standard deviation of the dihedral and/or total potential energies (depending on the {\\tt accelMDdihe} and {\\tt accelMDdual} parameters). This file is saved automatically every {\\tt restartfreq} steps. If {\\tt accelMDGRestart} is turned on, this file will be read and the simulation will restart from the point where the file was written.\n}\n\n\\end{itemize}\n\n\n\\subsection{Solute Scaling and REST2}\n\\label{section:rest2}\n\nSolute scaling improves sampling efficiency\nby scaling the intramolecular potential energy of a protein\nto lower barriers separating different confirmations~\\cite{WANG2011E}.\nThe potential is scaled based on a parameter $\\beta$,\n\\begin{equation}\nU^{\\text{SS}}(\\vec{r}) =\n\\beta U_{\\text{pp}}(\\vec{r}) +\n\\sqrt{\\beta} U_{\\text{pw}}(\\vec{r}) +\nU_{\\text{ww}}(\\vec{r}),\n\\end{equation}\nwith $U_{\\text{pp}}$ denoting protein--protein interactions,\n$U_{\\text{pw}}$ denoting protein--water interactions,\nand $U_{\\text{ww}}$ denoting water--water interactions,\neffectively ``heating'' the protein's interatomic interactions\nwhenever $\\beta < 1$.\nThe NAMD implementation is made efficient by rescaling\nthe force field parameters for the affected atoms~\\cite{JO2015}.\nIn particular, this parameter scaling approach makes the calculation\ncompatible with existing CUDA force kernels.\n\nThe NAMD implementation provides additional flexibility to\nsolute scaling by allowing different scaling factors for electrostatics,\nvan der Waals, and bonded interactions, as described in the\nfollowing section.\nSolute scaling can be combined with replica exchange\nto produce a powerful sampling enhancement method\nthat is highly transferable and provides higher efficiency\nthan traditional temperature exchange methods.\nIn the literature, this replica exchange solute scaling method\nis known as REST2, due to its improvement of the earlier\nREST (replica exchange solute tempering) method\nthat directly scaled the temperature of the solute.\nSample files are available in directory {\\tt lib/replica/REST2},\nwith script file {\\tt lib/replica/REST2/rest2\\_remd.namd}\ndemonstrating use of solute scaling with multiple replicas.\n\n\\subsubsection{NAMD parameters}\n\nThe following parameters are used to control solute scaling:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{soluteScaling}{%\nIs replica exchange solute tempering enabled?\n}{%\n{\\tt on} or {\\tt off}}{{\\tt off}\n}{%\nSpecifies whether or not REST2 is enabled.\nIf set on, then {\\tt soluteScaling} must also be set.\n}\n\n\\item\n\\NAMDCONF{soluteScalingFactor}{%\nSolute scaling factor\n}{%\nnon-negative\n}{%\nThis options sets the scaling factor $\\beta$, and is typically set lower\nthan 1 to reduce potential energy barriers for the solute.\n}\n\n\\item\n\\NAMDCONFWDEF{soluteScalingFactorCharge}{%\nSolute scaling factor for electrostatics\n}{%\nnon-negative}{{\\tt soluteScalingFactor}\n}{%\nScaling factor applied to just the electrostatics interactions.\nIf not specified, this is set to {\\tt soluteScalingFactor}.\n}\n\n\\item\n\\NAMDCONFWDEF{soluteScalingFactorVdw}{%\nSolute scaling factor for van der Waals\n}{%\nnon-negative}{{\\tt soluteScalingFactor}\n}{%\nScaling factor applied to just the van der Waals interactions.\nIf not specified, this is set to {\\tt soluteScalingFactor}.\n}\n\n\\item\n\\NAMDCONFWDEF{soluteScalingFile}{%\nPDB file with scaling flags\n}{%\nUNIX filename}{{\\tt coordinates}\n}{%\nPDB file used to flag solute atoms for scaling.\nIf undefined, this defaults to the coordinate PDB file.\n}\n\n\\item\n\\NAMDCONFWDEF{soluteScalingCol}{%\nColumn of PDB file\n}{%\n{\\tt X}, {\\tt Y}, {\\tt Z}, {\\tt O}, or {\\tt B}}{{\\tt O}\n}{%\nColumn of the PDB file used to flag solute atoms for scaling.\nIf undefined, this defaults to the {\\tt O} (occupancy) column.\nA value of 1.0 marks the atom for scaling.\n}\n\n\\item\n\\NAMDCONFWDEF{soluteScalingAll}{%\nApply scaling also to bond and angle interactions?\n}{%\n{\\tt on} or {\\tt off}}{{\\tt off}\n}{%\nIf set on, {\\tt scalingFactor} is applied also to bond and angle interactions.\nOtherwise, {\\tt scalingFactor} is applied only to dihedral, improper,\nand crossterm interactions.\n}\n\n\\end{itemize}\n\n\n\\subsection{Adaptive Tempering}\n\\label{section:adapttemp}\nAdaptive tempering is akin to a single-copy replica exchange method for dynamically updating the simulation temperature. The temperature $T$ is a new random variable in the range $[Tmin,Tmax]$ that is governed by the equation $dE/dT = E-E(T)-1/T+sqrt(2)T\\xi$, where $\\xi$ is Gaussian white noise. The effect is that when the potential energy for a given structure is lower than the (so far calculated) average energy, the temperature is lowered. Conversely when the current energy is higher than the average energy, the temperature is raised. The effect is faster conformational sampling to find minimum energy structures. The method is implemented exactly as described by Zhang and Ma in J. Chem. Phys. 132, 244101 (2010) (using Equation 18 of their paper to calculate the average energy at a given temperature from the histogram of energies). \n\nThe dynamic temperature is realized either by changing the temperature of the Langevin thermostat or by velocity rescaling. \n\n\\subsubsection{NAMD parameters}\n\nThe following parameters are used to adaptive tempering:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{adaptTempMD}{Is adaptive tempering active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies whether or not adaptive tempering is used. If set to on then the following parameters are required to be set: either all of ({\\tt adaptTempTmin}, {\\tt adaptTempTmax}, {\\tt adaptTempBins}, {\\tt adaptTempDt}) or {\\tt adaptTempInFile} (but not both).\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempFreq}{steps between temperature updates}\n{Positive integers}{10}\n{The number of steps between temperature updates. Note that the potential energy at the current is calculated and added to the temperature-energy histogram at every step.\n}\n\n\\item\n\\NAMDCONF{adaptTempTmin}{minimum temperature (K)}\n{Positive real number} \n{Sets the minimum temperature to be used in the simulation.\n}\n\n\\item\n\\NAMDCONF{adaptTempTmax}{maximum temperature (K)}\n{Positive real number}\n{Sets the maximum temperature to be used in the simulation.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempBins}{number of temperature bins}\n{Positive integer}{1000}\n{Sets the number of bins to subdivide the temperature range. Each bin stores the average energy for the given temperature \n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempDt}{stepsize for temperature updates}{Positive real numbers}{$10^{-4}$}\n{Integration timestep for temperature updates. This is unrelated to the simulation timestep and only scales the size of the step taken in temperature space every {\\tt adaptTempFreq} steps.\n}\n\n\\item\n\\NAMDCONF{adaptTempInFile}{adaptive tempering input filename}\n{UNIX filename}\n{The input file containing restart information for adaptive tempering (written out by {\\tt adaptTempRestartFile}).\n}\n\n\\item\n\\NAMDCONF{adaptTempRestartFile}{adaptive tempering restart filename}\n{UNIX filename}\n{The file to write out restart information for adaptive tempering.\n}\n\n\\item\n\\NAMDCONF{adaptTempRestartFreq}{steps between writing restart file}\n{Positive integer}\n{Frequency of writing restart file.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempLangevin}{send temperature updates to langevin thermostat?}\n{{\\tt on} or {\\tt off}}{{\\tt on}}\n{Setting this to on will cause the langevin thermostat to use the updated temperatures from adaptive tempering. Note that either one of adaptTempLangevin or adaptTempRescaling have to be on.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempRescaling}{send temperature to velocity rescaling thermostat?}\n{{\\tt on} or {\\tt off}}{{\\tt on}}\n{Setting this to on will cause the veloctiy rescaling thermostat to use the updated temperatures from adaptive tempering.  Note that either one of adaptTempLangevin or adaptTempRescaling have to be on.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempOutFreq}{steps between printing adaptive tempering output}\n{Positive integers}{10}\n{The number of timesteps between printing adaptive tempering output to the log file.\n}\n\n\\item\n\\NAMDCONFWDEF{adaptTempFirstStep}{step to start adaptive tempering}\n{Non-negative integers}{0}\n{The first timestep from which adaptive tempering will be run.}\n\n\\item\n\\NAMDCONF{adaptTempLastStep}{step to stop adaptive tempering}\n{Positive integers}\n{The last timestep to apply adaptive tempering.}\n\n\\item\n\\NAMDCONFWDEF{adaptTempCgamma}{dynamic bin averaging constant}\n{Non-negative real number}{0.1}\n{The calculation of the mean energy for a given bin is weighted by a factor of 1 - Cgamma / samples to damp out old statistics. Setting Cgamma to zero restores the use of a standard arithmetic mean to calculate the mean energy for each bin.}\n\n\\item\n\\NAMDCONFWDEF{adaptTempRandom}{assign random temperature if we step out of range?}\n{{\\tt on} or {\\tt off}}{{\\tt off}}\n{If set to on and the temperature steps out of [{\\tt adaptTempTmin}, {\\tt adaptTempTmax}], a random temperature in that range is assigned. Otherwise the previous temperature is kept.\n}\n\n%\\item\n%\\NAMDCONFWDEF{adaptTempDebug}{print debug output?}\n%{{\\tt on} or {\\tt off}}{{\\tt off}}\n%{Print adaptive tempering debug output.\n%}\n\n\\end{itemize}\n\n\n\\subsection{Locally enhanced sampling}\n\\label{section:les}\n\nLocally enhanced sampling (LES)~\\cite{ROIT91,SIMM98,SIMM00} increases\nsampling and transition rates for a portion of a molecule by the use of\nmultiple non-interacting copies of the enhanced atoms.  These enhanced\natoms experience an interaction (electrostatics, van der Waals, and\ncovalent) potential that is divided by the number of copies present.\nIn this way the enhanced atoms can occupy the same space, while the\nmultiple instances and reduces barriers increase transition rates.\n\n\\subsubsection{Structure generation}\n\nTo use LES, the structure and coordinate input files must be modified to\ncontain multiple copies of the enhanced atoms.  \\PSFGEN\\ provides the\n{\\tt multiply} command for this purpose.  \\NAMD\\ supports a maximum of 255\ncopies, which should be sufficient.  \n\nBegin by generating the complete molecular structure and guessing\ncoordinates as described in Sec.~\\ref{section:psfgen}.  As the last\noperation in your script, prior to writing the psf and pdb files, add\nthe {\\tt multiply} command, specifying the number of copies desired and\nlisting segments, residues, or atoms to be multiplied.  For example,\n\\verb#multiply 4 BPTI:56 BPTI:57# will create four copies of the last\ntwo residues of segment BPTI.  You must include all atoms to be\nenhanced in a single {\\tt multiply} command in order for the bonded\nterms in the psf file to be duplicated correctly.  Calling {\\tt multiply}\non connected sets of atoms multiple times will produce unpredictable\nresults, as may running other commands after {\\tt multiply}.\n\nThe enhanced atoms are duplicated exactly in the structure---they have\nthe same segment, residue, and atom names.  They are distinguished only\nby the value of the B (beta) column in the pdb file, which is 0 for\nnormal atoms and varies from 1 to the number of copies created for\nenhanced atoms.  The enhanced atoms may be easily observed in VMD with\nthe atom selection \\verb#beta != 0#.\n\n\\subsubsection{Simulation}\n\nIn practice, LES is a simple method used to increase sampling;\nno special output is generated.\nThe following parameters are used to enable LES:\n\n\\begin{itemize}\n\n\\item\n\\NAMDCONFWDEF{les}{is locally enhanced sampling active?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Specifies whether or not LES is active.}\n\n\\NAMDCONF{lesFactor}{number of LES images to use}\n{positive integer equal to the number of images present}\n{This should be equal to the factor used in {\\tt multiply}\n when creating the structure.  The interaction potentials for images is\n divided by {\\tt lesFactor}.  \n}\n\n\\item\n\\NAMDCONFWDEF{lesReduceTemp}{reduce enhanced atom temperature?}{{\\tt on} or {\\tt\noff}}{{\\tt off}}\n{Enhanced atoms experience interaction potentials divided by {\\tt lesFactor}.\nThis allows them to enter regions that would not normally be thermally\naccessible.  If this is not desired, then the temperature of these atoms\nmay be reduced to correspond with the reduced potential.  This option\naffects velocity initialization, reinititialization, reassignment, and\nthe target temperature for langevin dynamics.  Langevin dynamics is\nrecommended with this option, since in a constant energy simulation energy\nwill flow into the enhanced degrees of freedom until they reach thermal\nequilibrium with the rest of the system.  The reduced temperature atoms\nwill have reduced velocities as well, unless {\\tt lesReduceMass} is also\nenabled.}\n\n\\item\n\\NAMDCONFWDEF{lesReduceMass}{reduce enhanced atom mass?}{{\\tt on} or {\\tt off}}{{\\tt off}}\n{Used with {\\tt lesReduceTemp} to restore velocity distribution to\nenhanced atoms.  If used alone, enhanced atoms would move faster than\nnormal atoms, and hence a smaller timestep would be required.}\n\n\\item\n\\NAMDCONFWDEF{lesFile}{PDB file containing LES flags}{UNIX filename} {{\\tt coordinates}}\n{PDB file to specify the LES image number of each atom.\nIf this parameter is not specified, then \nthe PDB file containing initial coordinates specified by \n{\\tt coordinates} is used.}\n\n\\item\n\\NAMDCONFWDEF{lesCol}{column of PDB file containing LES flags}{{\\tt X}, {\\tt Y}, {\\tt Z}, {\\tt O}, or {\\tt B}}{{\\tt B}}\n{Column of the PDB file to specify the LES image number of each atom.\nThis parameter may specify any of the floating point fields of the PDB file, \neither X, Y, Z, occupancy, or beta-coupling (temperature-coupling).  \nA value of 0 in this column indicates that the atom is not enhanced.\nAny other value should be a positive integer less than {\\tt lesFactor}.}\n\n\\end{itemize}\n\n\n\\subsection{Replica exchange simulations}\n\n\\index{replica exchange}\nThe {\\tt lib/replica/}\ndirectory contains Tcl scripts that implement replica exchange\nboth for parallel tempering (temperature exchange) and\numbrella sampling (exchanging collective variable biases).\nThis replaces the old Tcl server and socket connections driving a\nseparate NAMD process for every replica used in the simulation.\n\n{\\bf A NAMD build based on Charm++ 6.5.0 or later using one of the\n``LRTS'' (low-level runtime system) machine layers is required!}\nCurrent LRTS machine layers include mpi, netlrts, verbs (for InfiniBand),\ngemini\\_gni-crayxe, gni-crayxc, and pamilrts-bluegeneq.\n\nOnly temperature-exchange simulations are described below.\nTo employ replicas for umbrella sampling you will need to understand\nthis material, collective variable-based calculations (Sec.\\ \\ref{section:colvars}),\nand basic Tcl programming to adapt the examples in {\\tt lib/replica/umbrella/}\nand {\\tt lib/replica/umbrella2d/} until further\ndocumentation and a tutorial are available.\n\nThis implementation is designed to be modified to implement\nexchanges of parameters other than temperature or via other temperature\nexchange methods.  The scripts should provide a good starting point for\nany simulation method requiring a number of loosely interacting systems.\n\nReplica exchanges and energies are recorded in the .history files\nwritten in the output directories.  These can be viewed with, e.g.,\n``{\\tt xmgrace output/*/*.history}'' and processed via awk or other tools.\nThere is also a script to load the output into VMD and color each\nframe according to replica index.  An example simulation folds\na 66-atom model of a deca-alanine helix in about 10\\,ns.\n\n{\\tt replica.namd}\nis the master script for replica temperature-exchange simulations.  To run:\n\\begin{verbatim}\n          cd example\n          mkdir output\n          (cd output; mkdir 0 1 2 3 4 5 6 7)\n          mpirun namd2 +replicas 8 job0.conf +stdout output/%d/job0.%d.log\n          mpirun namd2 +replicas 8 job1.conf +stdout output/%d/job1.%d.log\n\\end{verbatim}\n\nThe number of MPI ranks must be a multiple of the number of replicas\n(+replicas).  Be sure to increment jobX for +stdout option on command line.\n\n{\\tt show\\_replicas.vmd} is a script for loading replicas into VMD;\nfirst source the replica exchange conf file and then this script, then\nrepeat for each restart conf file or for example just do\n``{\\tt vmd -e load\\_all.vmd}''.\nThis script will likely destroy anything else you are doing in VMD at the\ntime, so it is best to start with a fresh VMD.\n{\\tt clone\\_reps.vmd} provides the {\\tt clone\\_reps} commmand to copy graphical\nrepresentation from the top molecule to all other molecules.\n\n{\\tt sortreplicas}, found in the namd2 binary directory, is a program to un-shuffle\nreplica trajectories to place same-temperature frames in the same file.\nUsage:\n\\begin{verbatim}\n  sortreplicas <job_output_root> <num_replicas> <runs_per_frame> [final_step]\n\\end{verbatim}\nwhere job\\_output\\_root is the job specific output base path, including\n\\%s or \\%d for separate directories as in output/\\%s/fold\\_alanin.job1\nThis will be extended with .\\%d.dcd .\\%d.history for input files and\n.\\%d.sort.dcd .\\%d.sort.history for output files.  The optional final\\_step\nparameter will truncate all output files after the specified step,\nwhich is useful in dealing with restarts from runs that did not complete.\nColvars trajectory files are similarly processed if they are found.\n\nA replica exchange config file should define the following Tcl variables:\n\\begin{itemize}\n\\item {\\tt num\\_replicas}, the number of replica simulations to use,\n\\item {\\tt min\\_temp}, the lowest replica target temperature,\n\\item {\\tt max\\_temp}, the highest replica target temperature,\n\\item {\\tt steps\\_per\\_run}, the number of steps between exchange attempts,\n\\item {\\tt num\\_runs}, the number of runs before stopping\n(should be divisible by {\\tt runs\\_per\\_frame} $\\times$ {\\tt frames\\_per\\_restart}).\n\\item {\\tt runs\\_per\\_frame}, the number of runs between trajectory outputs,\n\\item {\\tt frames\\_per\\_restart}, the number of frames between restart outputs,\n\n\\item {\\tt namd\\_config\\_file}, the NAMD config file containing all parameters,\nneeded for the simulation except {\\tt seed}, {\\tt langevin}, \n{\\tt langevinTemp}, {\\tt outputEnergies},\n{\\tt outputname}, {\\tt dcdFreq},\n{\\tt temperature}, {\\tt bincoordinates}, {\\tt binvelocities},\nor {\\tt extendedSystem}, which are provided by {\\tt replica.namd},\n\n\\item {\\tt output\\_root}, the directory/fileroot for output files,\noptionally including a ``\\%s'' that is replaced with the replica index\nto use multiple output directories,\n\n\\item {\\tt psf\\_file}, the psf file for {\\tt show\\_replicas.vmd}, \n\\item {\\tt initial\\_pdb\\_file}, the initial coordinate pdb file for {\\tt show\\_replicas.vmd},\n\\item {\\tt fit\\_pdb\\_file}, the coodinates that frames are fit to by {\\tt show\\_replicas.vmd} (e.g., a folded structure),\n\\end{itemize}\n\nThe {\\tt lib/replica/example/} directory contains\nall files needed to fold a 66-atom model of a deca-alanine helix:\n\\begin{itemize}\n\\item {\\tt alanin\\_base.namd}, basic config options for NAMD,\n\\item {\\tt alanin.params}, parameters,\n\\item {\\tt alanin.psf}, structure,\n\\item {\\tt unfolded.pdb}, initial coordinates,\n\\item {\\tt alanin.pdb}, folded structure for fitting in {\\tt show\\_replicas.vmd},\n\\item {\\tt fold\\_alanin.conf}, config file for {\\tt replica\\_exchange.tcl} script,\n\\item {\\tt job0.conf}, config file to start alanin folding for 10\\,ns,\n\\item {\\tt job1.conf}, config file to continue alanin folding another 10\\,ns, and\n\\item {\\tt load\\_all.vmd}, load all output into VMD and color by replica index.\n\\end{itemize}\n\nThe {\\tt fold\\_alanin.conf} config file contains the following settings:\n\\begin{verbatim}\nset num_replicas 8\nset min_temp 300\nset max_temp 600\nset steps_per_run 1000\nset num_runs 10000\n# num_runs should be divisible by runs_per_frame * frames_per_restart\nset runs_per_frame 10\nset frames_per_restart 10\nset namd_config_file \"alanin_base.namd\"\nset output_root \"output/%s/fold_alanin\" ; # directories must exist\n\n# the following used only by show_replicas.vmd\nset psf_file \"alanin.psf\"\nset initial_pdb_file \"unfolded.pdb\"\nset fit_pdb_file \"alanin.pdb\"\n\\end{verbatim}\n\n\\subsection{Random acceleration molecular dynamics simulations}\n\nThe ``lib/ramd\" directory stores the tcl scripts and the example files for the implementation of the Random Acceleration Molecular Dynamics (RAMD) simulation method in NAMD. \nThe RAMD method can be used to carry out molecular dynamics (MD) simulations with an additional randomly oriented acceleration applied to the center of mass of one group of atoms (referred to below as ``ligand\") in the system. \nIt can, for example, be used to identify egress routes for a ligand from a buried protein binding site. \nSince its original implementation in the ARGOS \\mycite{L{\\\"u}demann \\ETAL, 2000}{ludemann2000substrates,winn2002comparison} program, the method has been implemented in AMBER 8 \\mycite{Schleinkofer \\ETAL, 2005}{schleinkofer2005mammalian}, and CHARMM \\mycite{Carlsson \\ETAL, 2006}{carlsson2006unbinding}. \nThe first implementation of RAMD in NAMD using a tcl script (available as supplementary material in \\mycite{Vashisth \\ETAL, 2008}{vashisth2008ligand}) provided only limited functionality compared to the AMBER 8 implementation and was followed with an implementation of RAMD and RAMD--MD in NAMD \\mycite{}{cojocaru2012multiple,biedermannova2012single}. Recently the RAMD method was improved in speed by using NAMD vector implementations and streamlining the code. The current implementation is now focused on the RAMD simulation and was used in the $\\tau$RAMD procedure for the estimation of relative drug-target residence times \\mycite{Kokh \\ETAL, 2018}{kokh2018estimation}.\n\nAdditional information is found in the README file in the ``lib/ramd\" directory. \nThe user is encouraged to carefully read this information before starting production runs.\n\nThe two required scripts are stored in ``lib/ramd/scripts\": (i) ramd--5.tcl defines the simulation parameters and passes them from the NAMD configuration file to the main script, (ii) ``ramd--5\\_script.tcl\" adds the randomly oriented force and performs all related computations.\n\nTwo examples for running RAMD are included in the directory ``lib/ramd/example/\". The examples can be started using the RAMD-force.sh shell scripts.\n\nThe specific RAMD simulation parameters to be provided in the NAMD configuration file (listed below) should be preceded by the keyword ``ramd\". \nThe default values for these parameters are only given as guidance. \nThey may not to be suitable for other systems. \n\nMandatory parameter settings:\\\\\n\\begin{itemize}\n\\item\n\\NAMDCONF{ramd lastProtAtom} {Last index of protein atom} {{\\tt positive integer}} { Specifies the index of the last protein atom. } \n\n\\item\n\\NAMDCONF{ramd firstRamdAtom}{ First index of ligand atom } {{\\tt positive integer}} {Specifies the index of the first ligand atom.}\n\n\\item\n\\NAMDCONF{ramd lastRamdAtom}{ Last index of ligand atom } {{\\tt positive integer}} {Specifies the index of the last ligand atom. }\n\n\\item\n\\NAMDCONF{ramd ramdfilename}{Name of ramd output file}{{\\tt Valid file name}}{Specified the name of the file where the ramd logs are written.}\n\\end{itemize}\n\nOptional parameter settings with a default. Depending on your simulation system, you might want to change these settings:\\\\\n\\begin{itemize}\n\\item\n\\NAMDCONFWDEF{ramd firstProtAtom} {First index of protein atom} {{\\tt positive integer}} {{\\tt 1}} { Specifies the index of the first protein atom.}\n \n\\item\n\\NAMDCONFWDEF{ramd ramdSteps} { Set number of steps in RAMD block} {{\\tt positive integer}} {{\\tt 50}} {Specifies the number of steps in 1 RAMD block; the simulations are evaluated every `ramdSteps' steps.} \n\n\\item\n\\NAMDCONFWDEF{ramd forceRAMD} {Set acceleration force} {{\\tt positive decimal}} {{\\tt 16.0}} {Specifies the force to be applied. Replaces the acceleration (accel) specified in previous releases. Defaults to 16 kcal/mol/Angstrom}\n\n\\item\n\\NAMDCONFWDEF{ramd rMinRamd} {Set threshold for distance travelled RAMD} {{\\tt positive decimal}} {{\\tt 0.01}} {Specifies a threshold value for the distance in Angstroms travelled by the ligand in 1 RAMD block. In RAMD simulations the direction of the acceleration is changed if the ligand has travelled less than `rMinRamd' \\AA\\ in the evaluated block. \n%(In combined RAMD-MD simulations, a switch from a RAMD block to a standard MD block is applied if the ligand travelled more than `rMinRamd' \\AA in the evaluated block.)\n}\n\n\\item\n\\NAMDCONFWDEF{ramd forceOutFreq}{Set frequency of RAMD forces output} {{\\tt positive integer}, Must be divisor of {\\tt ramdSteps}} {{\\tt 10}} { Every `forceOutFreq' steps, detailed output of forces will be written.} \n\n\\item\n\\NAMDCONFWDEF{ramd maxDist} {Set center of mass separation} {{\\tt positive decimal}} {{\\tt 50}} { Specifies the distance in Angstroms between the the centers of mass of the ligand and the protein when the simulation is stopped.}\n \n\n\\item\n\\NAMDCONFWDEF{ramd ramdSeed}{Set RAMD seed} {{\\tt positive integer}} {{\\tt 14253}} {Specifies seed for the random number generator for generation of RAMD force directions. Change this parameter if you wish to run different trajectories with identical parameters.}\n\n\\item\n\\NAMDCONFWDEF{ramd debugLevel}{ Set debug level of RAMD} {\\tt integer value } {0} { Activates verbose output if set to an integer greater than 0. Should be used only for testing purposes because the very dense output is full of information only relevant for debugging.}\n\n\\item\n\\NAMDCONFWDEF{ramd namdVersion}{ Set the NAMD version}{\\tt float value } {2.13} { After NAMD version 2.10 a call to {\\em enabletotalforces} is done to enable tcl processing in NAMD}\n\n\\end{itemize}\n\nNote: \nIn the current RAMD implementation, combined RAMD-MD simulations, where RAMD blocks alternate with standard MD blocks are not available. In case you are are interested in this feature, please contact the RAMD developers at mcmsoft@h-its.org\n\nScripts for using RAMD in the $\\tau$RAMD procedure for computing residence times are available at: \\url{https://www.h-its.org/downloads/ramd/}.\n \n\n", "meta": {"hexsha": "041f4625cd881a73bdff1b68724d12680f50a676", "size": 42653, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ug/ug_accel.tex", "max_stars_repo_name": "slvbsp2009/NAMD_XLNX_ACCEL", "max_stars_repo_head_hexsha": "d1afd22915986fa24f8a4b6945d55b9b7b0ca948", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ug/ug_accel.tex", "max_issues_repo_name": "slvbsp2009/NAMD_XLNX_ACCEL", "max_issues_repo_head_hexsha": "d1afd22915986fa24f8a4b6945d55b9b7b0ca948", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ug/ug_accel.tex", "max_forks_repo_name": "slvbsp2009/NAMD_XLNX_ACCEL", "max_forks_repo_head_hexsha": "d1afd22915986fa24f8a4b6945d55b9b7b0ca948", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2040816327, "max_line_length": 845, "alphanum_fraction": 0.7632054017, "num_tokens": 11488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4170484026408801}}
{"text": "\\documentclass{article}\n\n\\title{MIS for $h_g$ and $h_c$}\n\n\\author{Spencer Smith}\n\n\\usepackage{fullpage}\n\\usepackage{longtable}\n\\usepackage{booktabs}\n\\usepackage{multirow}\n\n\\newcommand{\\blt}{- } %used for bullets in a list\n\n\\newcounter{datadefnum} %Datadefinition Number\n\\newcommand{\\ddthedatadefnum}{DD\\thedatadefnum}\n\\newcommand{\\ddref}[1]{DD\\ref{#1}}\n\n\\newcommand{\\colAwidth}{0.2\\textwidth}\n\\newcommand{\\colBwidth}{0.73\\textwidth}\n\n\\renewcommand{\\arraystretch}{1.2} %so that tables with equations do not look crowded\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Introduction}\nThe following document details the Module Interface Specifications for the implemented\nmodules in a program that calculates $h_g$ and $h_c$.\n It is intended to ease navigation through the program for design and maintenance purposes.  Complementary documents include the System Requirement Specifications and Module Guide.\n\n\\section{Module Decomposition}\nThe following table is taken directly from the Module Guide document for this project.\n\\begin{table}[h!]\n\\centering\n\\begin{tabular}{p{0.3\\textwidth} p{0.6\\textwidth}}\n\\toprule\n\\textbf{Level 1} & \\textbf{Level 2}\\\\\n\\midrule\n\n{Hardware-Hiding Module} & ~ \\\\\n\\midrule\n\n{Behaviour-Hiding Module} & Calc Module\\\\\n\\bottomrule\n\n\\end{tabular}\n\\caption{Module Hierarchy}\n\\label{TblMH}\n\\end{table}\n\n\\section*{MIS of Calc Module}\n\n\n%\\subsection{Uses}\n%None\n\n%\\subsubsection{Imported Constants}\n%None\n\n%\\subsubsection*{Imported Data Types}\n%None\n\n%\\subsubsection{Imported Access Programs}\n%None\n\n\\subsection*{Interface Syntax}\n\n%\\subsubsection{Exported Constants}\n%None\n\n%\\subsubsection{Exported Data Types}\n%None\n\n\\subsubsection*{Exported Access Programs}\n\n\\begin{center}\n\\begin{tabular}{p{0.2\\textwidth} p{0.2\\textwidth} p{0.2\\textwidth} p{0.2\\textwidth}}\n  \\toprule\n  \\textbf{Name} & \\textbf{In} & \\textbf{Out} & \\textbf{Exceptions}\\\\\n  \\midrule\n  calc\\underline{{ }{ }}h\\underline{{ }{ }}g & Real, Real, Real & Real & Divide by zero \\\\\n  calc\\underline{{ }{ }}h\\underline{{ }{ }}c & Real, Real, Real & Real & Divide by zero \\\\\n  \\bottomrule\n\\end{tabular}\n\\end{center}\n\n\n\\subsection*{Interface Semantics}\n\n\\subsubsection*{State Variables}\nerr: Int\n\n%\\subsubsection{Assumption}\n%None\n\n%\\subsubsection{Invariant}\n%None\n\n\\subsubsection*{Access Program Semantics}\n\n\\noindent \\textbf{Input:}\\\\\ncalc\\underline{{ }{ }}h\\underline{{ }{ }}g accepts reals representing $k_c$, $h_p$, and $\\tau_c$.\\\\\ncalc\\underline{{ }{ }}h\\underline{{ }{ }}c accepts reals representing $k_c$, $h_b$, and $\\tau_c$.\\\\\n\n\n\\noindent \\textbf{Exceptions:}\\\\\nA divide by zero exception may occur, which is signalled by a return value of -1.0.  The value of err is set to 1 upon encountering this exception.\\\\\n\n\\noindent \\textbf{Output:}\\\\\ncalc\\underline{{ }{ }}h\\underline{{ }{ }}g returns the calculated value of $h_g$.\\\\\ncalc\\underline{{ }{ }}h\\underline{{ }{ }}c returns the calculated value of $h_c$.\\\\\n\n\\end{document}\n", "meta": {"hexsha": "cdd1d28061ac5a6ef743088eebb93804064c20ce", "size": 2907, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "People/Steve/hghc_expanded_example/design_doc/hghc_MIS.tex", "max_stars_repo_name": "Danki567/Drasil", "max_stars_repo_head_hexsha": "d6bd7d0564710ae70b4847301d3d4df3f83fba11", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 114, "max_stars_repo_stars_event_min_datetime": "2017-12-16T04:51:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-20T16:27:51.000Z", "max_issues_repo_path": "People/Steve/hghc_expanded_example/design_doc/hghc_MIS.tex", "max_issues_repo_name": "Danki567/Drasil", "max_issues_repo_head_hexsha": "d6bd7d0564710ae70b4847301d3d4df3f83fba11", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1762, "max_issues_repo_issues_event_min_datetime": "2017-12-02T14:39:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T16:28:57.000Z", "max_forks_repo_path": "People/Steve/hghc_expanded_example/design_doc/hghc_MIS.tex", "max_forks_repo_name": "Danki567/Drasil", "max_forks_repo_head_hexsha": "d6bd7d0564710ae70b4847301d3d4df3f83fba11", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 31, "max_forks_repo_forks_event_min_datetime": "2018-11-25T22:16:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-01T20:15:38.000Z", "avg_line_length": 25.2782608696, "max_line_length": 180, "alphanum_fraction": 0.7292741658, "num_tokens": 897, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584174871563662, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4170483941498148}}
{"text": "\\documentclass[a4paper,twocolumn]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{dsfont}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage{dirtytalk}\n\\usepackage{hyperref}\n\\usepackage{csquotes}\n\\usepackage[style=authoryear]{biblatex}\n\\addbibresource{main.bib}\n\\AtEveryBibitem{\\clearfield{month}}\n\\AtEveryBibitem{\\clearfield{day}}\n\n\\newcommand{\\N}{\\mathbf{N}}\n\\newcommand{\\Z}{\\mathbf{Z}}\n\\newcommand{\\Q}{\\mathbf{Q}}\n\\newcommand{\\R}{\\mathbf{R}}\n\\newcommand{\\C}{\\mathbf{C}}\n\n\\author{Florian Fontan}\n\\title{Advanced Models and Methods in Operations Research \\\\ Project: Kidney exchange}\n\\date{2021--2022}\n\n\\begin{document}\n\n\\maketitle\n\nFor each problem considered, instances and a code skeleton containing an instance parser and a solution checker are provided in the \\texttt{data/} and \\texttt{python/} folders of the project.\n\nThe algorithms must be implemented in the provided files between the tags \\texttt{TODO START} and \\texttt{TODO END}.\n\nThey must be tested on all the provided instances with the command:\n\\texttt{python3 problem.py -i instance.json -c certificate.json}\n\nAnd each solution file must be validated by the provided checker:\n\\texttt{python3 problem.py -a checker -i instance.json -c certificate.json}\n\nThe results must be reproducible.\n\n\\bigskip\n\nThe delivrable must contain:\n\\begin{itemize}\n  \\item A \\emph{short} report describing and justifying the proposed algorithms\n  \\item The code implementing the algorithms\n  \\item The solution files obtained on the provided instances\n\\end{itemize}\n\n\\section*{Introduction}\n\nExcerpts from~\\cite{pansart_algorithms_2020}.\n\nIn a barter market, participants trade goods or services without using money or any other medium of exchange. Usually, barter takes place locally, immediately, between two people and without a state organization. One barter market though is an exception: kidney exchanges are organized by countries’ institutions themselves and can involve many people. Organs\ncannot be sold, and actually cannot be exchanged either: in a kidney exchange program, the traded \\say{items} are the donors, not the kidneys. Agents of the market are patients waiting for a kidney transplant because of a renal disease. Each patient has a relative ready to donate one kidney, but incompatible. In addition, new items can be injected in the market thanks\nto altruistic donors. The role of kidney exchange programs is to find out which exchanges should be carried out, in order to maximize the \\say{common good} while respecting medical, ethical, legal and logistical constraints.\n\nWe consider a kidney exchange program with $n$ participants (patient-donor pairs and altruistic donors) for whom a priori compatibilities are known. We also assume that for each transplant a certain level of \\say{desirability} is provided, possibly aggregating several medical parameters from both the donor and the recipient, and that the objective of the problem is to maximize the total benefit of the chosen transplants. Note that a special case of this problem with unitary weight in fact maximizes the number of transplants. In general maximizing the weight of exchanges can be conflicting with maximizing the number of transplants. Exchanges include cycles of donation of length at most $K$ and chains of donation containing at most $L - 1$ patient-donor pairs (hence $L$ agents).\n\nWe model a kidney exchange program as a directed graph by creating one vertex for each participant and one arc for each possible transplant. Formally, the set $P$ contains one vertex for each patient-donor pairs and the set $N$ one vertex for each altruistic donor. To construct the compatibility graph $D = (V = P \\cup N, A)$, we add an arc $(u, v)$ between $u \\in V$ and $v \\in P$ if the kidney of donor $u$ can be transplanted to patient $v$. A weight function $w: A \\to \\R^+$ represents the medical benefit of each possible transplant. Note that determining the weight function is an upstream work and that $w$ is an input in our case. This graph is generally quite sparse as it is rare for a patient and a donor to be compatible.\n\n\\section{Dynamic Programming}\n\nWe first consider the problem of finding a valid elementary cycle of length at most $K$ and of minimum weight. In this problem, the weight of an arc might by negative.\n\nPropose and implement an algorithm based on Dynamic Programming for this problem.\n\n\\section{Heuristic Tree Search}\n\nWe consider the problem of finding a valid elementary path of length at most $L$ and of minimum weight. In this problem, the weight of an arc might by negative.\n\nPropose and implement an algorithm based on Heuristic Tree Search with Dynamic Programming for this problem.\n\n\\section{Column Generation \\texorpdfstring{\\\\}{}  + Dynamic Programming}\n\nWe consider the kidney exchange problem with only patient-donor pairs and \\emph{without} altruistic donors. Therefore, the exchanges can only be elementary cycles, and not elementary paths.\n\nPropose an exponential formulation and implement an algorithm based on a Column Generation heuristic for this problem.\n\n\\section{Column Generation \\texorpdfstring{\\\\}{} + Heuristic Tree Search}\n\nWe consider the kidney exchange problem with both patient-donor pairs and altruistic donors. Therefore, the exchanges can be elementary cycles or elementary paths.\n\nPropose an exponential formulation and implement an algorithm based on a Column Generation heuristic for this problem.\n\n\\printbibliography%\n\n\\end{document}\n", "meta": {"hexsha": "8f99fcd4d014543ea29054a9e1016d5630a40cc8", "size": 5535, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2021-2022 - M2 ORCO - Advanced OR/Projects/Kidney exchange/subject/main.tex", "max_stars_repo_name": "Arkhist/AdvancedMethodsOR-heuristics-teaching", "max_stars_repo_head_hexsha": "e17efed49220bdbc93c51585f0e18edf262740f9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:48:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-06T05:33:51.000Z", "max_issues_repo_path": "2021-2022 - M2 ORCO - Advanced OR/Projects/Kidney exchange/subject/main.tex", "max_issues_repo_name": "Arkhist/AdvancedMethodsOR-heuristics-teaching", "max_issues_repo_head_hexsha": "e17efed49220bdbc93c51585f0e18edf262740f9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-10T06:51:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T22:52:38.000Z", "max_forks_repo_path": "2021-2022 - M2 ORCO - Advanced OR/Projects/Kidney exchange/subject/main.tex", "max_forks_repo_name": "Arkhist/AdvancedMethodsOR-heuristics-teaching", "max_forks_repo_head_hexsha": "e17efed49220bdbc93c51585f0e18edf262740f9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T06:30:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-07T22:36:08.000Z", "avg_line_length": 59.5161290323, "max_line_length": 787, "alphanum_fraction": 0.7929539295, "num_tokens": 1276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.41704839352818435}}
{"text": "\\chapter{Finite Markov Chains}\\label{C:FiniteMarkovChains}\n\n{\\bf NOTE: No materials from this Chapter will be in Probability Theory I exam!}\\\\[6pt]\n\n{\\em This topic is only introduced briefly in Probability Theory I to give concrete instances of dependent sequence of random variables. \nWe will revisit these ideas in the sequel. You only need to understand the ideas behind:\n\\bit\n\\item Example~\\ref{EX:FlippantFreddy} and \n\\item Example~\\ref{EX:DryWetChain}.\n\\eit\nas done in lectures.}\n\n\n\n\n{\n\\section{Stochastic Processes}\\label{S:StochProc}\n\n\\begin{definition}[Stochastic Process]\nA collection of RVs  \\[\n\\left(X_{\\alpha} \\right)_{\\alpha \\in N} := \\left( \\  X_{\\alpha} : \\alpha \\in \\Az \\  \\right)\n\\]\nis called a {\\bf stochastic process}.  Thus, for every $\\alpha \\in  \\Az$, the index set of the stochastic process, $X_{\\alpha}$ is a RV.  If the index set $ \\Az  \\subset \\Zz$ then we have  a {\\bf discrete time stochastic process}, typically denoted by \n\\[\n\\left(X_i\\right)_{i \\in \\Zz} := \\ldots, X_{-2},X_{-1},X_0, X_1,X_2,\\ldots , \\  \\text{or}\n\\]\n\\[\n\\left( X_i \\right)_{i \\in \\Nz} := X_1,X_2,\\ldots , \\  \\text{or}\n\\]\n\\[\n\\left( X_i \\right)_{i \\in [n]} := X_1,X_2,\\ldots , X_n , \\ \\text{where, } [n]:= \\{1,2,\\ldots,n\\} \\ .\n\\]\nIf $\\Az \\subset \\Rz$ then we have a {\\bf continuous time stochastic process}, typically denoted by $\\{X_t\\}_{t \\in \\Rz}$, etc.  \n\\end{definition}\n\nOf course the above process is quite general and can allow for arbitrary dependence among the RVs.  \nGenerally, we cannot produce useful models without making simplifying assumptions. \nThe absolutely simplest but extremely useful assumption is that of the {\\bf Independent and Identically Distributed or IID Process} or merely {\\bf IID Sequence of RVs} when the index set is a subset of $\\Nz$. \n\nThis is exactly the sequence of RVs associated with our product experiment $\\mathcal{E}^{\\otimes \\infty} := (\\Omega, \\mathcal{F}_{\\mathcal{X}}, P_{\\theta})^{\\otimes \\infty}$.\n    \n\\begin{definition}[Independent and Identically Distributed (IID) Process]\nThe finite or infinite sequence of RVs or the stochastic process $X_1, X_2,\\ldots$ is said to be independent and identically distributed or IID if :\n\\begin{itemize}\n\\item they are an idependently distributed according to \\hyperref[D:IndRVs]{Definition \\ref*{D:IndRVs}}, and\n\\item $F(X_1) = F(X_2) = \\cdots $, ie.~all the $X_i$'s have the same DF $F(X_1)$.\n\\end{itemize}\nThis is perhaps the most elementary class of stochastic processes and we succinctly denote it by\n\\[\n\\left(X_i\\right)_{i \\in [n]} := X_1, X_2,\\ldots, X_n \\overset{\\IID}{\\sim} F, \\quad \\text{or} \\quad \\left(X_i\\right)_{i \\in \\Nz} := X_1, X_2,\\ldots  \\overset{\\IID}{\\sim} F \\ .\n\\]\nWe sometimes replace the DF $F$ above by the name of the RV.\n \\end{definition}\n \n\\begin{definition}[Independently Distributed]\nThe sequence of RVs or the stochastic process $\\left(X_i\\right)_{i \\in \\Nz} := X_1, X_2,\\ldots$ is said to be independently distributed if :\n\\begin{itemize}\n\\item $X_1, X_2,\\ldots$ is independently distributed according to \\hyperref[D:IndRVs]{Definition \\ref*{D:IndRVs}}.\n\\end{itemize}\nThis is a class of stochastic processes that is more general than the IID class.\n\\end{definition}\n\nAs an example of such a class consider the sequence of RVs that are independent but non-identically distributed with each $X_i \\sim \\bernoulli(\\theta_i)$.\n\nWhen a stochastic process $\\left(X_{\\alpha} \\right)_{\\alpha \\in \\Az}$ is not independent it is said to be dependent.  \nSo far we have mostly concerned ourselves with independent processes.  \nIn this chapter we introduce finite Markov chains and their  simulation methods.\nFinit Markov chains are among the simplest stochastic processes with a `first-order' dependence called Markov dependence.\n\n\\section{Introduction}\\label{S:FiniteMCIntro}\nA finite Markov chain is a stochastic process that moves among elements in a finite set $\\Xz$ as follows: when at $x \\in \\Xz$ the next position is chosen at random according to a fixed probability distribution $P(\\cdot | x)$.  We define such a process more formally below.\n\n\\begin{definition}[Finite Markov Chain]\\label{D:TimeHomFiniteMC}\nA stochastic sequence, $$\\left(X_n\\right)_{n \\in \\Zz_+} := (X_0,X_1,\\ldots),$$ is a homogeneous {\\bf Markov chain} with {\\bf state space} $\\Xz$ and {\\bf transition matrix} $P:=\\left(P(x,y)\\right)_{(x,y)\\in \\Xz^2}$ if for all pair of {\\bf states} ${(x,y)\\in \\Xz^2 := \\Xz \\times \\Xz}$, all integers $t \\geq 1$, and all probable historical events $H_{t-1} := \\bigcap_{n=0}^{t-1} \\{ X_n = x_n \\}$ with $\\P \\left(H_{t-1} \\cap \\{X_t = x\\} \\right) > 0$, the following {\\bf Markov property} is satisfied: \n\\begin{equation}\\label{E:FiniteMarkovProperty}\n\\P\\left(X_{t+1} = y | H_{t-1} \\cap \\{X_t = x\\} \\right)=\\P\\left(X_{t+1} = y | X_t = x \\right) =: P(x,y) \\enspace .\n\\end{equation}\n\\end{definition}\nThe Markov property means that the conditional probability of going to state $y$ at time $t+1$ from state $x$ at current time $t$ is always given by the $(x,y)$-th entry $P(x,y)$ of the transition matrix $P$, no matter what sequence of states $(x_0,x_1,\\ldots,x_{t-1})$ preceded the current state $x$.  Thus, the $|\\Xz| \\times |\\Xz|$ matrix $P$ is enough to obtain the state transitions since the $x$-th row of $P$ is the probability distribution $P(x,\\cdot) := \\left( P(x,y) \\right)_{y \\in \\Xz}$.  For this reason $P$ is called a {\\bf stochastic matrix}, i.e.,\n\\begin{equation}\\label{E:StochasticMatrixConds}\nP(x,y) \\geq 0 \\quad \\text{for all } (x,y) \\in \\Xz^2 \\qquad \\text{and} \\quad \\sum_{y \\in \\Xz} P(x,y) = 1 \\quad \\text{for all } x \\in \\Xz \\enspace .\n\\end{equation}\nThus, for a Markov chain $\\left(X_n\\right)_{n \\in \\Zz_+}$, the distribution of $X_{t+1}$ given $X_0,\\ldots,X_t$  depends on $X_t$ alone. Because of this dependence on the previous state, the stochastic sequence, $(X_0,X_1,\\ldots)$, are {\\it not} independent.  We introduce the most important concepts using a simple example.\n\n\\begin{example}[Flippant Freddy]\\label{EX:FlippantFreddy}\nFreddy the flippant frog lives in an enchanted pond with only two lily pads, {\\em rollopia} and {\\em flipopia}.  A wizard gave a  die and a silver coin to help flippant Freddy decide where to jump next.  Freddy left the die on rollopia and the coin on flipopia.  When Freddy got restless in rollopia he would roll the die and if the die landed odd he would leave the die behind and jump to flipopia, otherwise he would stay put.  When Freddy got restless in flipopia he would flip the coin and if it landed Heads he would leave the coin behind and jump to rollopia, otherwise he would stay put.\n\nLet the state space $\\Xz=\\{r,f\\}$, and let $(X_0, X_1,\\ldots)$ be the sequence of lily pads occupied by Freddy after his restless moments.  Say the die on rollopia $r$ has probability $p$ of turning up odd and the coin on flipopia $f$ has probability $q$ of turning up heads.  We can visualise the rules of Freddy's jumps by the following {\\bf transition diagram}:\n\\begin{figure}[htpb]\n\\caption{Transition Diagram of Flippant Freddy's Jumps.\\label{F:FlippantFreddyTransDiag}}\n\\centering   \\makebox{\\includegraphics[width=6.5in]{figures/FlippantFreddyTransDiag}}\n\\end{figure}\n\nThen Freddy's sequence of jumps $(X_0, X_1,\\ldots)$ is a Markov chain on $\\Xz$ with transition matrix:\n\\begin{equation}\\label{E:FlippantFreddyP}\nP \n= \\bordermatrix{~ & r & f \\cr \nr & P(r,r) & P(r,f)\\cr \nf & P(f,r) & P(f,f) }\n= \\bordermatrix{~ & r & f \\cr \nr & 1-p & p \\cr\nf & q & 1-q } \\enspace .\n\\end{equation}\nSuppose we first see Freddy in rollopia, i.e., $X_0=r$.  When he gets restless for the first time we know from the first row of $P$ that he will leave to flippopia with probability $p$ and stay with probability $1-p$, i.e.,\n\\begin{equation}\\label{E:Freddy1Step}\n\\P(X_1=f | X_0=r) = p, \\quad \\P(X_1=r | X_0=r) = 1-p \\enspace .\n\\end{equation}\nWhat happens when he is restless for the second time?  By considering the two possibilities for $X_1$, Definition of conditional probability and the Markov property, we see that,\n\\begin{eqnarray}\n\\P(X_2 = f | X_0 = r) \n&=& \\P(X_2=f, X_1=f | X_0=r) + \\P(X_2=f, X_1=r | X_0=r) \\notag \\\\\n&=& \\frac{\\P(X_2=f, X_1=f , X_0=r)}{\\P(X_0=r)} + \\frac{\\P(X_2=f, X_1=r , X_0=r)}{\\P(X_0=r)} \\notag \\\\\n&=& \\P(X_2=f | X_1=f , X_0=r)\\frac{\\P(X_1=f , X_0=r)}{\\P(X_0=r)} \\notag \\\\\n&& \\qquad + \\P(X_2=f | X_1=r , X_0=r) \\frac{\\P(X_1=r , X_0=r)}{\\P(X_0=r)} \\notag \\\\\n%&=& \\frac{\\P(X_2=f | X_1=f , X_0=r)\\P(X_1=f | X_0=r)\\P(X_0=r)}{\\P(X_0=r)} \\\\\n%&& \\qquad + \\frac{\\P(X_2=f | X_1=r , X_0=r) \\P(X_1=r | X_0=r)\\P(X_0=r)}{\\P(X_0=r)} \\\\\n&=&{\\P(X_2=f | X_1=f , X_0=r)\\P(X_1=f | X_0=r)} \\notag \\\\\n&& \\qquad +{\\P(X_2=f | X_1=r , X_0=r) \\P(X_1=r | X_0=r)} \\notag \\\\\n&=& \\P(X_2=f | X_1=f) \\P(X_1=f | X_0=r) \\notag \\\\\n&& \\qquad+ \\P(X_2=f | X_1=r) \\P(X_1=r | X_0=r) \\notag \\\\\n&=& P(f,f) P(r,f) + P(r,f) P(r,r) \\notag \\\\\n&=& (1-q) p + p (1-p) \\label{E:Freddy2Stepa}\n\\end{eqnarray}\nSimilarly, \n\\begin{equation} \\label{E:Freddy2Stepb}\n\\P(X_2=r | X_0 =r) = P(f,r) P(r,f) + P(r,r) P(r,r) = q p + (1-p)(1-p)\n\\end{equation}\nInstead of elaborate computations of the probabilities of being in a given state after Freddy's $t$-th restless moment, we can store the state probabilities at time $t$ in a row vector:\n\\[\n\\mu_t := \\left(  \\P(X_t = r | X_0 = r), \\P(X_t=f | X_0=r) \\right) \\enspace ,\n\\]\nNow, we can conveniently represent Freddy starting in rollopia by the {\\bf initial distribution} $\\mu_0 = (1,0)$ and obtain the 1-step {\\bf state probability vector} in \\eqref{E:Freddy1Step} from $\\mu_1 = \\mu_0 P$ and the 2-step state probabilities in \\eqref{E:Freddy2Stepa} and \\eqref{E:Freddy2Stepb} by $\\mu_2 = \\mu_1 P = \\mu_0 P P = \\mu_0 P^2$.  In general, multiplying $\\mu_t$, the state probability vector at time $t$, by the transition matrix $P$ on the right updates the state probabilities by another step:\n\\[\n\\mu_{t} = \\mu_{t-1} P \\qquad \\text{for all } t \\geq 1 \\enspace .\n\\]\nAnd for any initial distribution $\\mu_0$,\n\\[\n\\mu_{t} = \\mu_0 P^t  \\qquad \\text{for all } t \\geq 0 \\enspace .\n\\]\nThis can be easily implemented in \\Matlab as follows:\n%\\begin{VrbM}\n%>> p=0.5; q=0.5; P = [1-p p; q 1-q] % assume a fair coin and a fair die\n%P =\n%    0.5000    0.5000\n%    0.5000    0.5000\n%\n%>> mu0 = [1, 0] % inital state vector since Freddy started in rollopia\n%mu0 =     1     0\n%\n%>> mu0*P^0    % intial state distribution at t=0 is just mu0\n%ans =     1     0\n%\n%>> mu0*P^1    % state distribution at t=1\n%ans =    0.5000    0.5000\n%\n%>> mu0*P^2    % state distribution at t=2\n%ans =    0.5000    0.5000\n%\\end{VrbM}\n%Thus for a fair coin and die we get equal probabilities of being in the two states right after the first jump.  Let us see what happens for an unfair coin and die:\n\\begin{VrbM}\n>> p=0.85; q=0.35; P = [1-p p; q 1-q] % assume an unfair coin and an unfair die\nP =\n    0.1500    0.8500\n    0.3500    0.6500\n>> mu0 = [1, 0] % inital state vector since Freddy started in rollopia\nmu0 =     1     0\n>> mu0*P^0    % intial state distribution at t=0 is just mu0\nans =     1     0\n>> mu0*P^1    % state distribution at t=1\nans =    0.1500    0.8500\n>> mu0*P^2    % state distribution at t=2\nans =    0.3200    0.6800\n>> mu0*P^3    % state distribution at t=3\nans =    0.2860    0.7140\n\\end{VrbM}\nNow, let us compute and look at the probability of being in rollopia after having started there for three values of $p$ and $q$ according to the following script: \n\\VrbMf[label=FlippantFreddyRollopiaProbs.m]{scripts/FlippantFreddyRollopiaProbs.m}\n\n\\begin{figure}[htpb]\n\\caption{The probability of being back in rollopia in $t$ time steps after having started there under transition matrix $P$ with (i) $p=q=0.5$ (blue line with asterisks), (ii) $p=0.85$, $q=0.35$ (black line with dots) and (iii) $p=0.15$, $q=0.95$ (red line with pluses).\\label{F:FlippantFreddyRollopiaProbs}}\n\\centering   \\makebox{\\includegraphics[width=6.5in]{figures/FlippantFreddyRollopiaProbs}}\n\\end{figure}\n\nIt is evident from \\hyperref[F:FlippantFreddyRollopiaProbs]{Figure~\\ref*{F:FlippantFreddyRollopiaProbs}} that as $t \\to \\infty$, $\\mu_t$ approaches a distribution, say $\\pi$, that depends on $p$ and $q$ in $P$.  Such a limit distribution is called the {\\bf stationary distribution} and must satisfy the fixed point condition:\n\\[\n\\pi P = \\pi \\enspace ,\n\\]\nthat gives the solution:\n\\[\n\\pi(r) = \\frac{q}{p+q}, \\qquad \\pi(f) = \\frac{p}{p+q} \\enspace .\n\\]\nIn \\hyperref[F:FlippantFreddyRollopiaProbs]{Figure~\\ref*{F:FlippantFreddyRollopiaProbs}} we see that $\\P(X_t=r)$ approaches $\\pi(r) = \\frac{q}{p+q}$ for the three cases of $p$ and $q$:\n\\begin{align*}\n\\text{(i)}& \\ p=0.50, q=0.50, & \\P(X_t=r) & \\to \\pi(r) = \\frac{q}{p+q} =  \\frac{0.50}{0.50+0.50} = 0.5000,\\\\\n\\text{(ii)}& \\  p=0.85, q=0.35, & \\P(X_t=r) & \\to \\pi(r) = \\frac{q}{p+q} =  \\frac{0.35}{0.85+0.35} = 0.2917, \\\\\n\\text{(iii)}& \\ p=0.15, q=0.95, & \\P(X_t=r) & \\to \\pi(r) = \\frac{q}{p+q} = \\frac{0.95}{0.15+0.95} = 0.8636.\n\\end{align*}\n\\end{example}\n\nNow let us generalise the lessons learned from \\hyperref[EX:FlippantFreddy]{Example~\\ref*{EX:FlippantFreddy}}.\n\n\\begin{prop}\\label{P:FiniteMCProbsAtTimet}\nFor a finite Markov chain $\\left(X_t\\right)_{t \\in \\Zz_+}$ with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$, initial distribution $$\\mu_0 := \\left( \\mu_0(s_1), \\mu_0(s_2), \\ldots, \\mu_0(s_k) \\right),$$ where $\\mu_0(s_i) = \\P(X_0=s_i)$, and transition matrix $$P := \\left(P(s_i,s_j)\\right)_{(s_i,s_j)\\in \\Xz^2},$$ we have for any $t \\in \\Zz_+$ that the distribution at time $t$ given by:\n$$\\mu_t := \\left( \\mu_t(s_1), \\mu_t(s_2), \\ldots, \\mu_t(s_k) \\right),$$\nwhere $\\mu_t(s_i) = \\P(X_t=s_i)$, satisfies:\n\\begin{equation}\\label{E:mutismu0Pt}\n\\mu_t = \\mu_0 P^t \\enspace .\n\\end{equation}\n\\begin{proof}\nWe will prove this by induction on $\\Z_+:=\\{0,1,2,\\ldots\\}$.  First consider the case when $t=0$.  Since $P^0$ is the identity matrix $I$, we get the desired equality:\n\\[\n\\mu_0 P^0 = \\mu_0 I = \\mu_0 \\enspace .\n\\]\nNext consider the case when $t=1$.  We get for each $j \\in \\{1,2,\\ldots,k\\}$, that\n\\begin{align*}\n\\mu_1(s_j) &= \\P(X_1 = s_j) = \\sum_{i=1}^k \\P(X_1=s_j,X_0=s_i)\\\\\n&= \\sum_{i=1}^k \\P(X_1=s_j | X_0=s_i) \\P(X_0=s_i) \\\\\n&= \\sum_{i=1}^k P(s_i,s_j) \\mu_0(s_i)\\\\\n&= (\\mu_0 P)(s_j), \\quad \\text{the $j$-th entry of the row vector $(\\mu_0 P)$} \\enspace .\n\\end{align*}\nHence, $\\mu_1=\\mu_0 P$.  Now, we will fix $m$ and suppose that \\eqref{E:mutismu0Pt} holds for $t=m$ and prove that \\eqref{E:mutismu0Pt} also holds for $t=m+1$.  \nFor each $j \\in \\{1,2,\\ldots,k\\}$, we get\n\\begin{align*}\n\\mu_{m+1}(s_j) &= \\P(X_{m+1} = s_j) = \\sum_{i=1}^k \\P(X_{m+1}=s_j,X_m=s_i)\\\\\n&= \\sum_{i=1}^k \\P(X_{m+1}=s_j | X_m=s_i) \\P(X_m=s_i) \\\\\n&= \\sum_{i=1}^k P(s_i,s_j) \\mu_m(s_i)\\\\\n&= (\\mu_m P)(s_j), \\quad \\text{the $j$-th entry of the row vector $(\\mu_m P)$} \\enspace .\n\\end{align*}\nHence, $\\mu_{m+1}=\\mu_m P$.  But $\\mu_{m}=\\mu_0 P^m$ by the induction hypothesis, and therefore:\n\\[\n\\mu_{m+1} = \\mu_m P = \\mu_0 P^m P = \\mu_0 P^{m+1} \\enspace .\n\\]\nThus by the principle of mathematical induction we have proved the proposition.\n\\end{proof}\n\\end{prop}\nThus, multiplying a row vector $\\mu_0$ by $P^t$ on the right takes you from current distribution over the state space to the distribution in $t$ steps of the chain.  \n\nSince we will be interested in Markov chains on $\\Xz =\\{s_1,s_2,\\ldots,s_k\\}$ with the same transition matrix $P$ but different initial distributions, we introduce $\\P_{\\mu}$ and $\\E_{\\mu}$ for probabilities and expectations  given that the initial distribution is $\\mu$, respectively.  When the initial distribution is concentrated at a single initial state $x$ given by:\n$$\\BB{1}_{\\{x\\}}(y) := \\begin{cases} 1 & \\text{if } y=x\\\\ 0 & \\text{if } y \\neq x \\end{cases}$$ \nwe represent it by $e_x$, the $1 \\times k$ ortho-normal basis row vector with a $1$ in the $x$-th entry and a $0$ elsewhere.  \nWe simply write $\\P_x$ for $\\P_{\\BB{1}_{\\{x\\}}}$ or $\\P_{e_x}$ and $\\E_x$ for $\\E_{\\BB{1}_{\\{x\\}}}$ or $\\E_{e_x}$.  Thus, \\hyperref[P:FiniteMCProbsAtTimet]{Proposition~\\ref*{P:FiniteMCProbsAtTimet}} along with our new notations means that:\n\\[\n\\P_x (X_t = y)  = (e_x P^t)(y) = P^t(x,y) \\enspace .\n\\]\nIn words, the probability of going to $y$ from $x$ in $t$ steps is given by the $(x,y)$-th entry of $P^t$, the {\\bf $t$-step transition matrix}.  We refer to the $x$-th row and the $x$-th column of $P$ by $P(x,\\cdot)$ and $P(\\cdot,x)$, respectively.\n\nLet the function $f(x): \\Xz\\to \\Rz$ be represented by the column vector $f := (f(s_1),f(s_2),\\ldots,f(s_k)) \\in \\Rz^{k \\times 1}$.  Then the $x$-th entry of $P^t f$ is:\n\\[\nP^t f(x) = \\sum_{y} P^t(x,y) f(y) = \\sum_{y} f(y) \\P_x (X_t = y) = \\E_x (f(X_t)) \\enspace .\n\\] \nThis is the expected value of $f$ under the distribution of states in $t$ steps given that we start at state $x$.  \nThus multiplying a column vector $f$ by $P^t$ from the left takes you from a function on the state space to its expected value in $t$ steps of the chain. \n\n%Let us look at some more examples of Markov chains.\n\\begin{example}[Dry-Wet Christchurch Weather]\\label{EX:DryWetChain}\nConsider a toy weather model for dry or wet days in Christchurch using a Markov chain with state space $\\{d,w\\}$.  Let the transition diagram in \\hyperref[F:DryWetTransDiag]{Figure~\\ref*{F:DryWetTransDiag}} give the transition matrix $P$ for our dry-wet Markov chain.  \n\\begin{figure}[htpb]\n\\caption{Transition Diagram of Dry and Wet Days in Christchurch.\\label{F:DryWetTransDiag}}\n\\centering   \\makebox{\\includegraphics[width=3.5in]{figures/DryWetTransDiag}}\n\\end{figure}\nUsing \\eqref{E:mutismu0Pt} we can find that the probability of being dry on the day after tomorrow is $0.625$ given that it is wet today as follows:\n\\begin{VrbM}\n>> P=[0.75 0.25; 0.5 0.5] % Transition Probability Matrix\nP =\n    0.7500    0.2500\n    0.5000    0.5000\n>> mu0=[0 1] % it is wet today gives the initial distribution\nmu0 =     0     1\n>> mu0 * P^2 % the distribution in 2 days from today\nans =    0.6250    0.3750\n\\end{VrbM}\nSuppose you sell \\$100 of lemonade at a road-side stand on a hot day but only \\$50 on a cold day.  Then we can compute your expected sales tomorrow if today is dry as follows:\n\\begin{VrbM}\n>> P=[0.75 0.25; 0.5 0.5] % Transition Probability Matrix\nP =\n    0.7500    0.2500\n    0.5000    0.5000\n>> f = [100; 50] % sales of lemonade in dollars on a dry and wet day\nf =\n   100\n    50\n>> P*f % expected sales tomorrow\nans =\n   87.5000\n   75.0000 \n>> mu0 = [1 0] % today is dry\nmu0 =     1     0\n>> mu0*P*f % expected sales tomorrow if today is dry\nans =   87.5000\n\\end{VrbM}\n\\end{example}\n\n\\begin{exercise}[Freddy discovers a gold coin]\\label{EXR:FreddyGoldCoin}\nFlippant Freddy of \\hyperref[EX:FlippantFreddy]{Example~\\ref*{EX:FlippantFreddy}} found a gold coin at the bottom of the pond.  Since this discovery he  jumps around differently in the enchanted pond.  He can be found now in one of three states: flipopia, rollopia and hydropia (when he dives into the pond). His state space is $\\Xz=\\{r,f,h\\}$ now and his transition mechanism is as follows: If he rolls an odd number with his fair die in rollopia he will jump to flipopia but if he rolls an even number then he will stay in rollopia only if the outcome is $2$ otherwise he will dive into hydropia.  If the fair gold coin toss at the bottom of hydropia is Heads then Freddy will swim to flipopia otherwise he will remain in hydropia. Finally, if he is in flipopia he will remain there if the silver coin lands Heads otherwise he will jump to rollopia.\n\nMake a Markov chain model of the new jumping mechanism adopted by Freddy.  Draw the transition diagram, produce the transition matrix $P$ and compute using \\Matlab the probability that Freddy will be in hydropia after one, two, three, four and five jumps given that he starts in hydropia.\n\\end{exercise}\n\n\\begin{exercise}\\label{Exr:NonMarkovProjection1}\nLet $(X_t)_{t\\in\\Zz_+}$ be a Markov chain with state space $\\{a,b,c\\}$, initial distribution $\\mu_0=(1/3,1/3,1/3)$ and transition matrix \n$$P = \n\\bordermatrix{~ & a & b & c \\cr\na & 0 & 1 & 0\\cr\nb & 0 & 0 & 1\\cr\nc & 1 & 0 & 0} \\enspace .\n$$\nFor each $t$, define $Y_t = \\BB{1}_{\\{b,c\\}}(X_t)$.  Show that $(Y_t)_{t\\in\\Zz_+}$ is not a Markov chain.\n\\end{exercise}\n\n\\begin{exercise}\\label{Exr:RegularSampledChainIsMarkov}\nLet $(X_t)_{t\\in\\Zz_+}$ be a (homogeneous) Markov chain on $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$ with transition matrix $P$ and initial distribution $\\mu_0$.  For a given $m \\in \\Nz$, let $(Y_t)_{t\\in\\Zz_+}$ be a stochastic sequence with $Y_t = X_{mt}$.  Show that $(Y_t)_{t\\in\\Zz_+}$ is a Markov chain with transition matrix $P^m$.  This establishes that Markov chains that are sampled at regular time steps are also Markov chains.\n\\end{exercise}\n\n\nUntil now our Markov chains have been {\\bf  homogeneous} in time according to \\hyperref[D:TimeHomFiniteMC]{Definition~\\ref*{D:TimeHomFiniteMC}}, i.e., the transition matrix $P$ does not change with time.  We define inhomogeneous Markov chains that allow their transition matrices to possibly change with time.  Such Markov chains are more realistic as models in some situations and more flexible as algorithms in the sequel.\n\n\\begin{definition}[Inhomogeneous finite Markov chain]\\label{D:TimeInhomFiniteMC}\nLet $P_1,P_2,\\ldots$ be a sequence of $k \\times k$ stochastic matrices satisfying the conditions in \\hyperref[E:StochasticMatrixConds]{Equation~\\ref*{E:StochasticMatrixConds}}.  Then, the stochastic sequence $\\left( X_t \\right)_{t \\in \\Z_+} := (X_0,X_1,\\ldots)$ with finite state space $\\Xz := \\{s_1,s_2,\\ldots,s_k\\}$ is called an inhomogeneous Markov chain with transition matrices $P_1,P_2,\\ldots$, if for all pairs of states $(x,y) \\in \\Xz \\times \\Xz$, all integers $t \\geq 1$, and all probable historical events $H_{t-1} := \\bigcap_{n=0}^{t-1} \\{ X_n = x_n \\}$ with $\\P\\left(H_{t-1} \\cap \\{X_t = x\\} \\right) > 0$, the following {\\bf Markov property} is satisfied: \n\\begin{equation}\\label{E:InHomFiniteMarkovProperty}\n\\P\\left(X_{t+1} = y | H_{t-1} \\cap \\{X_t = x\\} \\right)=\\P\\left(X_{t+1} = y | X_t = x \\right) =: P_{t+1}(x,y) \\enspace .\n\\end{equation}\n\\end{definition}\n\n\\begin{prop}\\label{P:FiniteInHomMCProbsAtTimet}\nFor a finite inhomogeneous Markov chain $\\left(X_t\\right)_{t \\in \\Zz_+}$ with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$, initial distribution $$\\mu_0 := \\left( \\mu_0(s_1), \\mu_0(s_2), \\ldots, \\mu_0(s_k) \\right),$$ where $\\mu_0(s_i) = \\P(X_0=s_i)$, and transition matrices \n$$\\left(P_1,P_2,\\ldots\\right), \\quad P_t := \\left(P_t(s_i,s_j)\\right)_{(s_i,s_j)\\in \\Xz\\times \\Xz}, \\ t \\in \\{1,2,\\ldots\\}$$ we have for any $t \\in \\Zz_+$ that the distribution at time $t$ given by:\n$$\\mu_t := \\left( \\mu_t(s_1), \\mu_t(s_2), \\ldots, \\mu_t(s_k) \\right),$$\nwhere $\\mu_t(s_i) = \\P(X_t=s_i)$, satisfies:\n\\begin{equation}\\label{E:InhomMutismu0Pt}\n\\mu_t = \\mu_0 P_1 P_2 \\cdots P_t \\enspace .\n\\end{equation}\n\\begin{proof}\nLeft as \\hyperref[Exr:ProveInHomMultismu0Pt]{Exercise~\\ref*{Exr:ProveInHomMultismu0Pt}}.\n\\end{proof}\n\\end{prop}\n\n\\begin{exercise}\\label{Exr:ProveInHomMultismu0Pt}\nProve \\hyperref[P:FiniteInHomMCProbsAtTimet]{Proposition~\\ref*{P:FiniteInHomMCProbsAtTimet}} using induction as done for \\hyperref[P:FiniteMCProbsAtTimet]{Proposition~\\ref*{P:FiniteMCProbsAtTimet}}.\n\\end{exercise}\n\n\n\\begin{example}[a more sophisticated dry-wet chain]\\label{EX:DryWetChainHotCold}\nLet us make a more sophisticated version of the dry-wet chain of \\hyperref[EX:DryWetChain]{Example~\\ref*{EX:DryWetChain}} with state space $\\{d,w\\}$ .  In order to take some seasonality into account in our weather model for dry and wet days in Christchurch, let us have two transition matrices for hot and cold days:\n\\[\nP_{\\text{hot}} = \n\\bordermatrix{~ & d & w \\cr\nd & 0.95 & 0.05 \\cr\nw & 0.75 & 0.25},\n\\qquad\nP_{\\text{cold}} = \n\\bordermatrix{~ & d & w \\cr\nd & 0.65 & 0.35 \\cr\nw & 0.45 & 0.55} \\enspace .\n\\]\nWe say that a day is hot if its  maximum temperature is more than $20^{\\circ}$ Celsius, otherwise it is cold.  We use the transition matrix for today to obtain the state probabilities for tomorrow.  If today is dry and hot and tomorrow is supposed to be cold then what is the probability that the day after tomorrow will be wet?  We can use \\eqref{E:InhomMutismu0Pt} to obtain the answer as $0.36$: \n\\begin{VrbM}\n>> Phot = [0.95 0.05; 0.75 0.25] % Transition Probability Matrix for hot day\nPhot =\n    0.9500    0.0500\n    0.7500    0.2500\n>> Pcold = [0.65 0.35; 0.45 0.55] % Transition Probability Matrix for cold day\nPcold =\n    0.6500    0.3500\n    0.4500    0.5500\n>> mu0 = [1 0] % today is dry\nmu0 =     1     0\n>> mu1 = mu0 * Phot % distribution for tomorrow since today is hot\nmu1 =    0.9500    0.0500\n>> mu2 = mu1 * Pcold % distribution for day after tomorrow since tomorrow is supposed to be cold\nmu2 =    0.6400    0.3600\n>> mu2 = mu0 * Phot * Pcold % we can also get the distribution for day after tomorrow directly\nmu2 =    0.6400    0.3600\n\\end{VrbM}\n\\end{example}\n\n\\begin{exercise}\\label{Exr:DryWetChainHotCold}\nFor the Markov chain in \\hyperref[EX:DryWetChainHotCold]{Example~\\ref*{EX:DryWetChainHotCold}}  compute the probability that the day after tomorrow is wet if today is dry and hot but tomorrow is supposed to be cold.\n\\end{exercise}\n\n\\section{Irreducibility and Aperiodicity}\\label{S:IrredAperiod}\nThe utility of our mathematical constructions with Markov chains depends on a delicate balance between generality and specificity.  We introduce two specific conditions called irreducibility and aperiodicity that make Markov chains more useful to model real-word phenomena.\n\n\n\\begin{definition}[Communication between states]\\label{D:Communication} Let $(X_t)_{t\\in\\Zz_+}$ be a homogeneous Markov chain with transition matrix $P$ on state space $\\Xz:=\\{s_1,s_2,\\ldots,s_k\\}$.  \nWe say that a state $s_i$ {\\bf communicates} with a state $s_j$ and write $s_i \\rightarrow s_j$ or $s_j \\leftarrow s_i$ if there exists an $\\eta(s_i,s_j) \\in \\Nz$ such that:\n\\[\n\\P \\left( X_{t+\\eta(s_i,s_j)} = s_j | X_t = s_i \\right) = P^{\\eta(s_i,s_j)} (s_i, s_j) > 0 \\enspace .\n\\] \nIn words, $s_i$ communicates with $s_j$ if you can eventually reach $s_j$ from $s_i$.  If $P^{\\eta} (s_i, s_j)=0$ for every $\\eta \\in \\Nz$ then we say that $s_i$ {\\bf does not communicate} with $s_j$ and write $s_i  \\nrightarrow s_j$ or $s_j  \\nleftarrow s_i$.\n\nWe say that two states $s_i$ and $s_j$ {\\bf intercommunicate} and write $s_i \\leftrightarrow s_j$ if $s_i \\rightarrow s_j$ and $s_j \\rightarrow s_i$.  In words, two states intercommunicate if you can eventually reach one from another and vice versa.  When $s_i$ and $s_j$ do not intercommunicate we write $s_i \\nleftrightarrow s_j$.\n\\end{definition}\n\n\\begin{definition}[Irreducible]\\label{D:Irreducible}\nA homogeneous Markov chain $(X_t)_{t\\in\\Zz_+}$ with transition matrix $P$ on state space $\\Xz:=\\{s_1,s_2,\\ldots,s_k\\}$ is said to be {\\bf irreducible} if $s_i \\leftrightarrow s_j$ for each $(s_i,s_j) \\in \\Xz^2$.  Otherwise the chain is said to be {\\bf reducible}.\n\\end{definition}\n\nWe have already seen examples of reducible and irreducible Markov chains.  For example, Flippant Freddy's family of Markov chains with the $(p,q)$-parametric family of transition matrices, $\\{P_{(p,q)} : (p,q) \\in [0,1]^2\\}$, where each $P_{(p,q)}$ is given by \\hyperref[E:FlippantFreddyP]{Equation~\\ref*{E:FlippantFreddyP}}.  If $(p,q) \\in (0,1)^2$, then the corresponding Markov chain is irreducible because we can go from rollopia to flippopia or vice versa in just one step with a positive probability.  Thus, the Markov chains with transition matrices in $\\{P_{(p,q)} : (p,q) \\in (0,1)^2\\}$ are irreducible.  But if $p$ or $q$ take probability values at the boundary of $[0,1]$, i.e., $p \\in \\{0,1\\}$ or $q \\in \\{0,1\\}$ then we have to be more careful because we may  never get from at least one state to the other and the corresponding Markov chains may be reducible.   For instance, if $p=0$ or $q=0$ then we will be stuck in either rollopia or flippopia, respectively.  However, if $p=1$ and $q \\neq 0$ or $q=1$ and $p \\neq 0$ then we can get from each  state to the other.  Therefore,  only the transition matrices in $\\left\\{P_{(p,q)} : p \\in \\{0\\} \\text{ or } q \\in \\{0\\}\\right\\}$ are reducible.\n\nThe simplest way to verify whether a Markov chain is irreducible is by looking at its transition diagram (without the positive edge probabilities) and checking that from each state there is a sequence of arrows leading to any other state.  %For instance, from the transition diagram in \\hyperref[F:SixLounges]{Figure~\\ref*{F:SixLounges}} of the lounge-hopping Markov chain of \\hyperref[EX:SixLounges]{Example~\\ref*{EX:SixLounges}}, it is clear that if you start at state $6$ you cannot find any arrow going to any other state.  Therefore, the chain is reducible since $6 \\nrightarrow i$ for any $i \\in \\{1,2,3,4,5\\}$.\n\n\\begin{exercise}\\label{EXR:ExsIrreducibleOrNot}\nRevisit all the Markov chains we have considered up to now and determine whether they are reducible or irreducible by checking that from each state there is a sequence of arrows leading to any other state in their transition graphs.\n\\end{exercise}\n\n\\begin{definition}[Return times and period]\nLet $\\Tz(x) := \\{t \\in \\Nz : P^t(x,x)>0\\}$ be the set of {\\bf possible return times} to the starting state $x$.  The {\\bf period} of state $x$ is defined to be $\\gcd(\\Tz(x))$, the greatest common divisor of $\\Tz(x)$.  When the period of a state $x$ is $1$, i.e., $\\gcd(\\Tz(x))=1$, then $x$ is said to be an {\\bf aperiodic state}.\n\\end{definition}\n\n\\begin{prop}\nIf the Markov chain $(X_t)_{t\\in\\Zz_+}$ with transition matrix $P$ on state space $\\Xz$ is irreducible then $\\gcd(\\Tz(x)) = \\gcd(\\Tz(y))$ for any $(x,y) \\in \\Xz^2$.\n\\begin{proof}\nFix any pair of states $(x,y) \\in \\Xz^2$.  Since, $P$ is irreducible, $x \\leftrightarrow y$ and therefore there exists natural numbers $\\eta(x,y)$ and $\\eta(y,x)$ such that $P^{\\eta(x,y)}(x,y)>0$ and $P^{\\eta(y,x)}(y,x)>0$.  Let $\\eta' = \\eta(x,y)+\\eta(y,x)$ and observe that $\\eta' \\in \\Tz(x) \\cap \\Tz(y)$, $\\Tz(x) \\subset \\Tz(y) - \\eta' := \\{t-\\eta' : t \\in \\Tz(y)\\}$ and $\\gcd(\\Tz(y))$ divides all elements in $\\Tz(x)$.  Thus, $\\gcd(\\Tz(y)) \\leq \\gcd(\\Tz(x))$.  By a similar argument we can also conclude that $\\gcd(\\Tz(x)) \\leq \\gcd(\\Tz(y))$.  Therefore $\\gcd(\\Tz(x))=\\gcd(\\Tz(y))$.\n\\end{proof}\n\\end{prop}\n\n\\begin{definition}[Aperiodic]\nA Markov chain $(X_t)_{t\\in\\Zz_+}$ with transition matrix $P$ on state space $\\Xz$ is said to be {aperiodic} if all of its states are aperiodic, i.e., $\\gcd(\\Tz(x))=1$ for every $x \\in \\Xz$.  If a chain is not aperiodic, we call it {\\bf periodic}.\n\\end{definition}\n\nWe have already seen example of irreducible Markov chains that  were either periodic or aperiodic.  For instance, Freddy's Markov chain with $(p,q) \\in (0,1)^2$ is aperiodic since the period of either of its two states is given by $\\gcd(\\{1,2,3,\\ldots\\})=1$.  However, the Markov chain model for a drunkard's walk around a block over the state space $\\{0,1,2,3\\}$ %(\\hyperref[SIM:DrunkardsWalkBlock]{Simulation~\\ref*{SIM:DrunkardsWalkBlock}}) \nis periodic because you can only return to the starting state in an even number of time steps and \n$$\n\\gcd(\\Tz(0))=\\gcd(\\Tz(1))=\\gcd(\\Tz(2))=\\gcd(\\Tz(3))= \\gcd \\left( \\{2,4,6,\\ldots\\} \\right) =2 \\neq 1 \\enspace .\n$$\n\n\\begin{exercise}\\label{EXR:DrunkardsWalkOnKGonIrredAperiod}\nShow that the Markov chain corresponding to a drunkard's walk around a polygonal block with $k$ corners is irreducible for any integer $k>1$.  Show that it is aperiodic only when $k$ is odd and has period $2$ when $k$ is even.\n\\end{exercise}\n\n\\begin{prop}\\label{P:AdditionNonlattice} Let $A=\\{a_1,a_2,\\ldots\\} \\subset \\Nz$ that satisfies the following two conditions:\n\\begin{enumerate}\n\\item $A$ is a {\\bf nonlattice}, meaning that $\\gcd(A)=1$ and\n\\item $A$ is closed undur addition, meaning that if $(a,a') \\in A^2$ then $a+a' \\in A$.\n\\end{enumerate}\nThen there exists a positive integer $\\eta < \\infty$ such that $n \\in A$ for all $n \\geq \\eta$.\n\\begin{proof}\nSee Proofs of Lemma 1.1, Lemma 1.2 and Theorem 1.1 in Appendix of {\\em Pierre Br\\'emaud, Markov Chains, Gibbs Fields, Monte Carlo Simulation, and Queues, Springer, 1999}.\n\\end{proof}\n\\end{prop}\n\n\\begin{prop}\nIf the Markov chain $(X_t)_{t\\in\\Zz_+}$ with transition matrix $P$ on state space $\\Xz$ is irreducible and aperiodic then there is an integer $\\tau$ such that $P^t(x,x)>0$ for all $t \\geq \\tau$ and all $x \\in \\Xz$.\n\\begin{proof}\nTBD\n\\end{proof}\n\\end{prop}\n\n\\begin{prop}\nIf the Markov chain $(X_t)_{t\\in\\Zz_+}$ with transition matrix $P$ on state space $\\Xz$ is irreducible and aperiodic then there is an integer $\\tau$ such that $P^t(x,y)>0$ for all $t \\geq \\tau$ and all $(x,y) \\in \\Xz^2$.\n\\begin{proof}\nTBD\n\\end{proof}\n\\end{prop}\n\n\\begin{exercise}[King's random walk on a chessboard]\\label{EXR:KingRWChessBoard}\nConsider the squares in the chessboard as the state space $\\Xz = \\{ 0,1,2,\\ldots,7\\}^2$ with a randomly walking black king, i.e., for each move from current state $(u,v) \\in \\Xz$ the king chooses one of his $k(u,v)$ possible moves uniformly at random.  \nIs the Markov chain corresponding to the randomly walking black king on the chessboard irredicible and/or aperiodic?  \n%Write a \\Matlab script to simulate a sequence of $n$ states visited by the king if he started from $(0,0)$, the most south-west state on the chessboard.\n\\end{exercise}\n\n\\begin{exercise}[King's random walk on a chesstorus]\\label{EXR:KingRWChessTorus}\nWe can obtain a chesstorus from a pliable chessboard by identifying the eastern edge with the western edge (roll the chessboard into a cylinder) and then identifying the northern edge with the southern edge (gluing the top and bottom end of the cylinder together by turning into a doughnut or torus).  Consider the squares in the chesstorus as the state space $\\Xz = \\{ 0,1,2,\\ldots,7\\}^2$ with a randomly walking black king, i.e., for each move from current state $(x,y) \\in \\Xz$ the king chooses one of his $8$ possible moves uniformly at random according to the scheme: $X_t \\gets X_{t-1}+ W_t$, where $W_t$ is independent and identically distributed as follows:\n\\[ \n\\P(W_t = w) = \n\\begin{cases}\n\\frac{1}{8} & \\text{if } w \\in \\left\\{ (1,1), (1,0), (1,-1), (0,-1), (-1,-1), (-1,0), (-1,1), (0,1) \\right\\} , \\\\\n0 & \\text{ otherwise}.\n\\end{cases}\n\\]\nIs the Markov chain corresponding to the randomly walking black king on the chesstorus irredicible and/or aperiodic?  Write a \\Matlab script to simulate a sequence of $n$ states visited by the king if he started from $(0,0)$ on the chesstorus.\n\\end{exercise}\n\n\\section{Stationarity}\\label{S:Stationarity}\n\nWe are interested in statements about a Markov chain that has been running for a long time.  \nFor any nontrivial Markov chain $(X_0,X_1,\\ldots)$ the value of $X_t$ will keep fluctuating in the state space $\\Xz$ as $t \\to \\infty$ and we cannot hope for convergence to a fixed point state $x^* \\in \\Xz$ or to a $k$-cycle of states $\\{x_1,x_2,\\ldots,x_k\\} \\subset \\Xz$.  However, we can look one level up into the space of probability distributions over $\\Xz$ that give the probability of the Markov chain visiting each state $x \\in \\Xz$ at time $t$, and hope that the distribution of $X_t$ over $\\Xz$ settles down as $t \\to \\infty$.  The Markov chain convergence theorem indeed sattes that the distribution of $X_t$ over $\\Xz$ settles down as $t \\to \\infty$, provided the Markov chain is irreducible and aperiodic.\n\n\\begin{definition}[Stationary distribution]\nLet $\\left( X_t \\right)_{t \\in \\Zz_+}$ be a Markov chain with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$ and transition matrix $P = \\left( P(x,y) \\right)_{(x,y) \\in \\Xz^2}$.  A row vector $$\\pi = \\left( \\pi(s_1), \\pi(s_2), \\ldots, \\pi(s_k) \\right) \\in \\Rz^{1\\times k}$$ is said to be a {\\bf stationary distribution} for the Markov chain, if it satisfies the conditions of being:\n\\begin{enumerate}\n\\item {\\em a probability distribution}: $\\pi(x) \\geq 0$ for each $x \\in \\Xz$ and $\\sum_{x \\in \\Xz} \\pi(x) = 1$, and\n\\item {\\em a fixed point}: $\\pi P = \\pi$, i.e., $\\sum_{x \\in \\Xz} \\pi(x) P(x,y) = \\pi(y)$ for each $y \\in \\Xz$.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{definition}[Hitting times]\nIf a Markov chain $\\left( X_t \\right)_{t \\in \\Zz_+}$ with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$ and transition matrix $P = \\left( P(x,y) \\right)_{(x,y) \\in \\Xz^2}$ starts at state $x$, then we can define the {\\bf hitting time}\n\\[\nT(x,y) = \\min \\{ t \\geq 1: X_t = y \\} \\enspace .\n\\]\nand let $T(x,y) = \\min \\{\\} = \\infty$ if the Markov chain never visits $y$ after having started from $x$.  Let the {\\bf  mean hitting time} \n\\[\n\\tau(x,y) := \\E(T(x,y)) ,\n\\]\nbe the expected time taken to reach $y$ after having started at $x$.  Note that $\\tau(x,x)$ is the {\\bf mean return time} to state $x$.\n\\end{definition}\n\n\\begin{prop}[Hitting times of irreducible aperiodic Markov chains]  \nIf  $\\left( X_t \\right)_{t \\in \\Zz_+}$ is an irreducible aperiodic Markov chain with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$, transition matrix $P = \\left( P(x,y) \\right)_{(x,y) \\in \\Xz^2}$ then for any pair of states ${(x,y) \\in \\Xz^2}$,\n\\[\n\\P\\left( T(x,y) < \\infty \\right) = 1 \\enspace ,\n\\]\nand the mean hitting time is finite, i.e.,\n\\[\n\\tau(x,y) < \\infty \\enspace .\n\\]\n\\end{prop}\n\n\\begin{prop}[Existence of Stationary distribution]\nFor any irreducible and aperiodic Markov chain there exists at least one stationary distribution.\n\\begin{proof}\nTBD\n\\end{proof}\n\\end{prop}\n\n\\begin{definition}[Total variation distance]\\label{D:TotVarDist}\nIf $\\nu_1:=\\left(\\nu_1(x)\\right)_{x\\in \\Xz}$ and $\\nu_2 := \\left(\\nu_2(x)\\right)_{x\\in \\Xz}$ are elements of $\\mathcal{P}(\\Xz)$, the set of all probability distributions on $\\Xz:=\\{s_1,s_2,\\ldots,s_k\\}$, then we define the {\\bf total variation distance} between $\\nu_1$ and $\\nu_2$ as\n\\begin{equation}\\label{E:TotVarDist}\n\\dtv \\left( \\nu_1, \\nu_2 \\right) := \\frac{1}{2} \\sum_{x \\Xz} \\abs \\left( \\nu_1(x) - \\nu_2(x) \\right), \\quad \\dtv : \\mathcal{P}(\\Xz) \\times \\mathcal{P}(\\Xz)  \\to [0,1] \\enspace .\n\\end{equation}\nIf $\\nu_1, \\nu_2, \\ldots$ and $\\nu$ are probability distributions on $\\Xz$, then we say that $\\nu_t$ {\\bf converges in total variation} to $\\nu$ as $n \\to \\infty$ and write $\\nu_t  \\overset{\\mathsf{TV}}{\\longrightarrow} \\nu$, if\n\\[\n\\lim_{t \\to \\infty} \\dtv \\left( \\nu_t, \\nu \\right) = 0 \\enspace .\n\\]\nObserve that if $\\dtv(\\nu_1,\\nu_2)=0$ then $\\nu_1=\\nu_2$. The constant $1/2$ in \\hyperref[E:TotVarDist]{Equation~\\ref*{E:TotVarDist}} ensures that the range of $\\dtv$ is in $[0,1]$.  If $\\dtv(\\nu_1,\\nu_2)=1$ then $\\nu_1$ and $\\nu_2$ have disjoint  supports, i.e., we can partition $\\Xz$ into $\\Xz_1$ and $\\Xz_2$, i.e., $\\Xz=\\Xz_1 \\cup \\Xz_2$ and $\\Xz_1 \\cap \\Xz_2 = \\emptyset$, such that $\\sum_{x \\in \\Xz_1} \\nu_1(x)=1$ and  $\\sum_{x \\in \\Xz_2} \\nu_2(x)=1$.  The total variation distance gets its name from the following natural interpretation:\n\\[\n\\dtv \\left( \\nu_1, \\nu_2 \\right) = \\max_{A \\subset \\Xz} \\abs \\left( \\nu_1(A) - \\nu_2(A) \\right) \\enspace .\n\\]\nThis interpretation means that the total variation distance between $\\nu_1$ and $\\nu_2$ is the maximal difference in probabilities that the two distributions assign to any one event $A \\in \\sigma(\\Xz) = 2^{\\Xz}$. \n\\end{definition}\n\nIn words, \\hyperref[P:MCConvergence]{Proposition~\\ref*{P:MCConvergence}} says that if you run the chain for a sufficiently long enough time $t$, then, regardless of the initial distribution $\\mu_0$, the distribution at time $t$ will be close to the stationary distribution $\\pi$.  This is referred to as the Markov chain {\\bf approaching equilibrium} or {\\bf stationarity} as $t \\to \\infty$.  \n\n\\begin{prop}[Markov chain convergence theorem]\\label{P:MCConvergence}\nLet $\\left( X_t \\right)_{t \\in \\Zz_+}$ be an irreducible aperiodic Markov chain with state space $\\Xz=\\{s_1,s_2,\\ldots,s_k\\}$, transition matrix $P = \\left( P(x,y) \\right)_{(x,y) \\in \\Xz^2}$ and initial distribution $\\mu_0$.  Then for any distribution $\\pi$ which is stationary for the transition matrix $P$, we have\n\\begin{equation}\n\\mu_t \\overset{\\mathsf{TV}}{\\longrightarrow} \\pi  \\enspace .\n\\end{equation}\n\\begin{proof}\nTBD\n\\end{proof}\n\\end{prop}\n\n\\begin{prop}[Uniqueness of stationary distribution]\\label{P:UniqueStationaryDistrn}\nAny irreducible aperiodic Markov chain has a unique stationary distribution.\n\\begin{proof}\nTBD\n\\end{proof}\n\\end{prop}\n\n\n\\begin{exercise}\\label{EXR:SixStatesWith3Blockof2}\nConsider the Markov chain on $\\{1,2,3,4,5,6\\}$ with the following transition matrix:\n\\[\nP = \n\\bordermatrix{ ~ & 1 & 2 & 3 &  4 & 5 & 6 \\cr \n1 & \\frac{1}{2} & \\frac{1}{2} & 0 & 0 & 0 & 0 \\cr\n2 & \\frac{1}{2} & \\frac{1}{2} & 0 & 0 & 0 & 0 \\cr\n3 & 0 & 0 &  \\frac{1}{4} & \\frac{3}{4} & 0 & 0  \\cr\n4 & 0 & 0 &  \\frac{3}{4} & \\frac{1}{4} & 0 & 0  \\cr\n5 & 0 & 0 &  0 & 0 & \\frac{3}{4} & \\frac{1}{4}  \\cr\n6 & 0 & 0 &  0 & 0 & \\frac{1}{4} & \\frac{3}{4}  } \\enspace .\n\\]\nShow that this chain is reducible and it has three stationary distributions:\n\\[\n(1/2,1/2,0,0,0,0), \\quad (0,0,1/2,1/2,0,0), \\quad (0,0,0,0,1/2,1/2) \\enspace .\n\\]\n\\end{exercise}\n\n\\begin{exercise}\\label{EXR:ConvexCombof2StationaryDistrns}\nIf there are two stationary distributions $\\pi$ and $\\pi'$ then show that there is a infinite family of stationary distributions $\\{\\pi_p : p \\in [0,1] \\}$, called the convex combinations of $\\pi$ and $\\pi'$.\n\\end{exercise}\n\n\\begin{exercise}\\label{EXR:ConvergengeinTVFailsforPeriodicDrunkardWalk}\nShow that for a drunkard's walk chain started at state $0$ around a polygonal block with $k$ corners labelled $\\{0,1,2,\\ldots,k-1\\}$, the state probability vector at time step $t$\n\\[\n\\mu_t \\overset{\\mathsf{TV}}{\\longrightarrow} \\pi   \n\\]\nif and only if $k$ is odd.  Explain what happens to $\\mu_t$ when $k$ is even.\n\\end{exercise}\n\n\\section{Reversibility}\n\nWe introduce another specific property called reversibility.  \nThis property will assist in conjuring Markov chains with a desired stationary distibution.\n\n\\begin{definition}[Reversible]\\label{D:Reversible}\nA probability distribution $\\pi$ on $\\Xz = \\{s_1,s_2,\\ldots,s_k\\}$ is said to be a {\\bf reversible distribution} for a Markov chain $\\left(X_t\\right)_{t\\in \\Zz}$ on $\\Xz$ with transition matrix $P$ if for every pair of states $(x,y) \\in \\Xz^2$:\n\\begin{equation}\\label{E:ReversibilityCondition}\n\\pi(x) P(x,y) = \\pi(y) P(y,x) \\enspace .\n\\end{equation}\nA Markov chain that has a reversible distribution is said to be a reversible Markov chain.\n\\end{definition}\n\nIn words, $\\pi(x) P(x,y) = \\pi(y) P(y,x)$ says that if you start the chain at the reversible distribution $\\pi$, i.e., $\\mu_0 = \\pi$, then the probability of going from $x$ to $y$ is the same as that of going from $y$ to $x$.\n\n\\begin{prop}[A reversible $\\pi$ is a stationary $\\pi$]\\label{P:ReversibleIsStationary}\nLet $\\left(X_t\\right)_{t \\in \\Zz_+}$ be a Markov chain on $\\Xz = \\{s_1,s_2,\\ldots,s_k\\}$ with transition matrix $P$.  \nIf $\\pi$ is a reversible distribution for $\\left(X_t\\right)_{t \\in \\Zz_+}$ then $\\pi$ is a stationary distribution for $\\left(X_t\\right)_{t \\in \\Zz_+}$.\n\\begin{proof}\nSuppose $\\pi$ is a reversible distribution for $\\left(X_t\\right)_{t \\in \\Zz_+}$ then $\\pi$ is a probability distribution on $\\Xz$ and $\\pi(x) P(x,y) = \\pi(y) P(y,x)$ for each $(x,y)\\in \\Xz^2$.  \nWe need to show that for any $y \\in \\Xz$ we have $$\\pi(y)=\\sum_{x\\in\\Xz}\\pi(y) P(y,x) \\enspace .$$ \nFix a $y \\in \\Xz$,\n\\begin{eqnarray*}\nLHS \n&=& \\pi(y)= \\pi(y) \\, 1 = \\pi(y) \\, \\sum_{x \\in \\Xz} P(y,x) \\text{, since $P$ is a stochastic matrix} \\\\\\\\\n&=& \\sum_{x \\in \\Xz} \\pi(y) P(y,x) = \\sum_{x \\in \\Xz} \\pi(x) P(x,y) \\text{,  by reversibility} \\\\\n&=& RHS \\enspace .\n\\end{eqnarray*}\n\\end{proof}\n\\end{prop}\n\n\n%\\section{Classical Examples}\n%\\work\n%\\subsection{Random Walks on Graphs}\n\n\\begin{definition}[Graph]\\label{D:Graph}\nA {\\bf Graph} $\\Gz := (\\Vz,\\Ez)$ consists of a {\\bf vertex set} $\\Vz := \\{v_1,v_2,\\ldots,v_k\\}$ together with an {\\bf edge set} $\\Ez := \\{e_1,e_2,\\ldots,e_l\\}$.  Each edge connects two of the vertices in $\\Vz$.  An edge $e_h$ connecting vertices $v_i$ and $v_j$ is denoted by $\\langle v_i, v_j \\rangle$.  Two vertices are {\\bf neighbours} if they share an edge.  \nThe {\\bf negihbourhood} of a vertex $v_i$ denoted by $\\nbhd(v_i):=\\left\\{v_j : \\langle v_i,v_j\\rangle \\in \\Ez \\right\\}$ is the set of neighbouring vertices of $v_i$.  \nThe number of neighbours of a vertex $v_i$ in an undirected graph is called its {\\bf degree} and is denoted by $\\deg(v_i)$.  \nNote that $\\deg(v_i) = \\# \\nbhd(v_i)$.  \nIn a graph we only allow one edge per pair of vertices but in a {\\bf multigraph} we allow more than one edge per pair of vertices.  \nAn edge can be {\\bf directed} to preserve  the order of the pair of vertices they connect or they can be {\\bf undirected}.  \nAn edge can be {\\bf weighted} by being associated with a real number called its weight.  \nWe can represent a directed graph by its {\\bf adjacency matrix} given by:\n\\[\nA := \\left( A(v_i,v_j) \\right)_{(v_i,v_j) \\in \\Vz \\times \\Vz}, \\quad \nA(v_i,v_j) = \n\\begin{cases} \n1 & \\text{if } \\  \\langle v_i, v_j \\rangle \\in \\Ez \\\\\n0 & \\text{otherwise} \\enspace .\n\\end{cases}\n\\]\nThus the adjacency matrix of an undirected graph is symmetric.  \nIn a directed graph, each vertex $v_i$ has {\\bf in-edges} that come into it and {\\bf out-edges} that go out of it.  \nThe number of in-edges and out-edges of $v_i$ is denoted by $\\ideg(v_i)$ and $\\odeg(v_i)$ respectively.  \nNote that a transition diagram of a Markov chain is a weighted directed graph and is represented by the transition probability matrix.\n\\end{definition}\n\n\\begin{model}[Random Walk on an Undirected Graph]\\label{M:RWGraph}\nA random walk on an undirected graph $\\Gz=(\\Vz,\\Ez)$ is a Markov chain with state space $\\Vz:= \\{v_1,v_2,\\ldots,v_k\\}$ and the following transition rules: if the chain is at vertex $v_i$ at time $t$ then it moves uniformly at random to one of the neighbours of $v_i$ at time $t+1$.  If $\\deg(v_i)$ is the degree of $v_i$ then the transition probabilities of this Markov chain is\n\\[\nP(v_i,v_j) = \n\\begin{cases}\n\\frac{1}{\\deg(v_i)} & \\text{if $\\langle v_i, v_j \\rangle \\in \\Ez$}\\\\\n0 & \\text{otherwise} ,\n\\end{cases}\n\\]\n\\end{model}\n\n\\begin{prop}\\label{P:RWUGpi}\nThe random walk on an undirected graph $\\Gz=(\\Vz,\\Ez)$, with vertex set $\\Vz:= \\{v_1,v_2,\\ldots,v_k\\}$ and degree sum $d = \\sum_{i=1}^k{\\deg(v_i)}$ is a reversible Markov chain with the reversible distribution $\\pi$ given by:\n\\[\n\\pi = \\left( \\frac{\\deg(v_1)}{d}, \\frac{\\deg(v_2)}{d}, \\ldots, \\frac{\\deg(v_k)}{d}  \\right) \\enspace .\n\\]\n\\begin{proof}\nFirst note that $\\pi$ is a probability distribution provided that $d > 0$.  \nTo show that $\\pi$ is reversible we need to verify \\hyperref[E:ReversibilityCondition]{Equation~\\ref*{E:ReversibilityCondition}} for each $(v_i,v_j) \\in \\Vz^2$.  \nFix a pair of states $(v_i,v_j) \\in \\Vz^2$, then\n\\begin{eqnarray*}\n\\pi(v_i) P(v_i,v_j) = \n\\begin{cases}\n\\frac{\\deg(v_i)}{d}\\frac{1}{\\deg(v_i)}=\\frac{1}{d}=\\frac{\\deg(v_j)}{d}\\frac{1}{\\deg(v_j)}=\\pi(v_j) P(v_j,v_i) & \\text{ if } \\langle v_i, v_j \\rangle \\in \\Ez\\\\\n0 = \\pi(v_j) P(v_j,v_i) & \\text{ otherwise}.\n\\end{cases}\n\\end{eqnarray*} \nBy \\hyperref[P:ReversibleIsStationary]{Proposition~\\ref*{P:ReversibleIsStationary}} $\\pi$ is also the stationary distribution.\n\\end{proof}\n\\end{prop}\n\n\\begin{exercise}\\label{EXR:DirectlyProveRWUGpi}\nProve \\hyperref[P:RWUGpi]{Proposition~\\ref*{P:RWUGpi}} by directly showing that $\\pi P = \\pi$, i.e., for each $v_i \\in \\Vz$, $\\sum_{i=1}^k \\pi(v_i) P(v_i, v_j) = \\pi(v_j)$.\n\\end{exercise}\n\n\\begin{example}[Random Walk on a regular graph]\\label{EX:RWRegGraph}\nA graph $\\Gz=(\\Vz,\\Ez)$ is called regular if every vertex in $\\Vz=\\{v_1,v_2,\\ldots,v_k\\}$ has the same degree $\\delta$, i.e., $\\deg(v_i)=\\delta$ for every $v_i \\in \\Vz$.  \nConsider the random walk on a regular graph with symmetric transition matrix \n\\[\nQ(v_i,v_j) = \n\\begin{cases} \n\\frac{1}{\\delta} & \\text{ if } \\langle v_i,v_j \\rangle \\in \\Ez \\\\\n0 & \\text{ otherwise}\n\\end{cases} \\enspace .\n\\]\nBy \\hyperref[P:RWUGpi]{Proposition~\\ref*{P:RWUGpi}}, the stationary distribution of the random walk on $\\Gz$ is the uniform distribution on $\\Vz$ given by\n\\[\n\\pi \n= \\left( \\frac{\\delta}{\\delta \\#\\Vz }, \\ldots , \\frac{\\delta}{\\delta \\#\\Vz}  \\right) \n= \\left( \\frac{1}{\\#\\Vz}, \\ldots , \\frac{1}{\\#\\Vz} \\right) \n\\enspace .\n\\]\n\\end{example}\n\n\n\\begin{example}[Triangulated Quadrangle]\\label{EX:TriangulatedQuadrangle}\nThe random walk on the undirected graph \n$$\\Gz=(\\{1,2,3,4\\}, \\{\\langle 1,2 \\rangle, \\langle 3,1 \\rangle, \\langle 2,3 \\rangle, \\langle 2,4 \\rangle, \\langle 4,3\\rangle\\})$$ depicted below with adjacency matrix $A$ is a Markov chain on $\\{1,2,3,4\\}$ with transition matrix $P$:\n$$ \nA = \n\\bordermatrix{~ & 1 & 2 & 3 & 4 \\cr\n1 & 0 & 1 & 1 & 0 \\cr\n2 & 1 & 0 & 1 & 1\\cr\n3 & 1 & 1 & 0 & 1\\cr\n4 & 0 & 1 & 1 & 0} ,\n\\quad\nP = \n\\bordermatrix{~ & 1 & 2 & 3 & 4 \\cr\n1 & 0 & \\frac{1}{2} &  \\frac{1}{2} & 0 \\cr\n2 & \\frac{1}{3} & 0 &  \\frac{1}{3} &  \\frac{1}{3} \\cr\n3 & \\frac{1}{3} &  \\frac{1}{3} & 0 &  \\frac{1}{3} \\cr\n4 & 0 &  \\frac{1}{2} &  \\frac{1}{2} & 0 } ,\n\\quad\n\\makebox{\\includegraphics[width=2.5in]{figures/TriQuadrangle}}\n\\enspace .$$ \nBy \\hyperref[P:RWUGpi]{Proposition~\\ref*{P:RWUGpi}}, the stationary distribution of the random walk on $\\Gz$ is\n\\[\n\\pi = \\left( \\frac{\\deg(v_1)}{d}, \\frac{\\deg(v_2)}{d}, \\frac{\\deg(v_3)}{d}, \\frac{\\deg(v_4)}{d} \\right) \n= \\left( \\frac{2}{10}, \\frac{3}{10}, \\frac{3}{10}, \\frac{2}{10} \\right) \\enspace .\n\\] \n\\end{example}\n\n%\\begin{exercise}\\label{EXR:DrunkardAroundBlockFairReversible}\n%Show that the Drunkard's walk around the block from \\hyperref[SIM:DrunkardsWalkBlock]{Simulation~\\ref*{SIM:DrunkardsWalkBlock}} is a random walk on the undirected graph $\\Gz=(\\Vz,\\Ez)$ with $\\Vz=\\{0,1,2,3\\}$ and $\\Ez=\\{\\langle 0,1 \\rangle,\\langle 1,2 \\rangle,\\langle 2,3 \\rangle,\\langle 0,3 \\rangle \\}$.  What is its reversible distribution?\n%\\end{exercise}\n\n\\begin{example}[Drunkard's biased walk around the block]\\label{SIM:DrunkardsBiasedWalkBlock}\nConsider the Markov chain $\\left(X_t\\right)_{t \\in \\Zz_+}$ on $\\Xz=\\{0,1,2,3\\}$ with initial distribution $\\BB{1}_{\\{3\\}}(x)$ and transition matrix \n$$P = \n\\bordermatrix{~ & 0 & 1 & 2 & 3 \\cr \n0 & 0 & 1/3 & 0 & 2/3\\cr\n1 & 1/3 & 0 & 2/3 & 0\\cr\n2 & 0 & 1/3 & 0 & 2/3\\cr\n3 & 1/3 & 0 & 2/3 & 0 } \\enspace .\n$$\nDraw the transition diagram for this Markov chain that corresponds to a drunkard who flips a biased coin to make his next move at each corner.  The stationary distribution is $\\pi = (1/4,1/4,1/4,1/4)$ (verify $\\pi P= \\pi$).  \n\nWe will show that $\\left(X_t\\right)_{t \\in \\Zz_+}$ is not a reversible Markov chain.  \nSine $\\left(X_t\\right)_{t \\in \\Zz_+}$ is irreducible (aperiodicity is not necessary for uniqueness of $\\pi$) $\\pi$ is the unique stationary distribution.  \nDue to \\hyperref[P:ReversibleIsStationary]{Proposition~\\ref*{P:ReversibleIsStationary}}, $\\pi$ has to be a reversible distribution in order for $\\left(X_t\\right)_{t \\in \\Zz_+}$ to be a reversible Markov chain.  \nBut reversibility fails for $\\pi$ since,\n\\[\n\\pi(0) P(0,1) = \\frac{1}{4} \\times \\frac{1}{3} = \\frac{1}{12} < \\frac{1}{6} = \\frac{1}{4} \\times \\frac{2}{3} = \\pi(1)P(1,0) \\enspace .\n\\]\n\\end{example}\n\n\\begin{exercise}\\label{EXR:PiKingRWChessTorus}\nFind the stationary distribution of the Markov chain in \\hyperref[EXR:KingRWChessTorus]{Exercise~\\ref*{EXR:KingRWChessTorus}}.\n\\end{exercise}\n\n\\begin{model}[Random Walk on a Directed Graph]\\label{M:RWDGraph}\nA random walk on a directed graph $\\Gz=(\\Vz,\\Ez)$ is a Markov chain with state space $\\Vz:= \\{v_1,v_2,\\ldots,v_k\\}$ and transition matrix given by:\n\\[\nP(v_i,v_j) = \n\\begin{cases}\n\\frac{1}{\\odeg(v_i)} & \\text{if $\\langle v_i, v_j \\rangle \\in \\Ez$}\\\\\n0 & \\text{otherwise} ,\n\\end{cases}\n\\]\n\\end{model}\n\n\\begin{example}[Directed Triangulated Quadrangle]\\label{EX:DirectedTriangulatedQuadrangle}\nThe random walk on the directed graph \n$$\\Gz=(\\{1,2,3,4\\}, \\{\\langle 1,2 \\rangle, \\langle 3,1 \\rangle, \\langle 2,3 \\rangle, \\langle 2,4 \\rangle, \\langle 4,3\\rangle\\})$$ depicted below with adjacency matrix $A$ is a Markov chain on $\\{1,2,3,4\\}$ with transition matrix $P$:\n$$ \nA = \n\\bordermatrix{~ & 1 & 2 & 3 & 4 \\cr\n1 & 0 & 1 & 0 & 0 \\cr\n2 & 0 & 0 & 1 & 1 \\cr\n3 & 1 & 0 & 0 & 0 \\cr\n4 & 0 & 0 & 1 & 0},\n\\quad\nP = \n\\bordermatrix{~ & 1 & 2 & 3 & 4 \\cr\n1 & 0 & 1 & 0 & 0 \\cr\n2 & 0 & 0 & \\frac{1}{2} & \\frac{1}{2} \\cr\n3 & 1 & 0 & 0 & 0 \\cr\n4 & 0 & 0 & 1 & 0},\n\\quad\n\\makebox{\\includegraphics[width=2.5in]{figures/DirTriQuadrangle}}\n\\enspace .$$ \n\\end{example}\n\n\\begin{exercise}\\label{EXR:DirectedTriangulatedQuadrangleNoReversiblePi}\nShow that the there is no reversible distibution for the Markov chain in \\hyperref[EX:DirectedTriangulatedQuadrangle]{Example~\\ref*{EX:DirectedTriangulatedQuadrangle}}. \n\\end{exercise}\n\n\\begin{example}[Random surf on the word wide web]\\label{EX:RandomSurferwww}\nConsider the huge graph with vertices as webpages and hyper-links as undirected edges.  \nThen \\hyperref[M:RWGraph]{Model~\\ref*{M:RWGraph}} gives a random walk on this graph.  \nHowever if a page has no links to other pages, it becomes a sink and therefore terminates the random walk.  \nLet us modify this random walk into a {\\bf random surf} to avoid getting stuck.  \nIf the random surfer arrives at a sink page, she picks another page at random and continues surfing at random again.  \nGoogle's PageRank formula uses a random surfer model who gets bored after several clicks and switches to a random page.  \nThe PageRank value of a page reflects the chance that the random surfer will land on that page by clicking on a link.  \nThe stationary distribution of the random surfer on the world wide web is a very successful model for ranking pages.\n\\end{example}\n\n", "meta": {"hexsha": "9e380dd02447e50e55038fd34986feeceab100b6", "size": 53288, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "matlab/csebook/stub211MarkovChains.tex", "max_stars_repo_name": "raazesh-sainudiin/computational-statistical-experiments", "max_stars_repo_head_hexsha": "edb33db9a05b32645e8337c03729c0b8d02fa728", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-19T07:54:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-14T13:55:18.000Z", "max_issues_repo_path": "matlab/csebook/stub211MarkovChains.tex", "max_issues_repo_name": "raazesh-sainudiin/computational-statistical-experiments", "max_issues_repo_head_hexsha": "edb33db9a05b32645e8337c03729c0b8d02fa728", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "matlab/csebook/stub211MarkovChains.tex", "max_forks_repo_name": "raazesh-sainudiin/computational-statistical-experiments", "max_forks_repo_head_hexsha": "edb33db9a05b32645e8337c03729c0b8d02fa728", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2018-07-18T07:47:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-19T11:28:24.000Z", "avg_line_length": 66.61, "max_line_length": 1206, "alphanum_fraction": 0.6847695541, "num_tokens": 18920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.4169687645103322}}
{"text": "\\chapterimage{head1} % Chapter heading image\r\n\r\n\\chapter{Voltage on Neuron Morphology}\r\n\r\n\\section{Introduction}\r\n\r\nThe standard algorithm used to compute the Voltage on neurons' morphology\r\n is the Hines algorithm [8]. This algorithm is based on the Thomas \r\n algorithm [4], which solves tridiagonal systems. Although the use of\r\n  GPUs to compute the Thomas algorithm has been deeply studied \r\n  [5], the differences among these two algorithms,\r\n   Hines and Thomas, makes us impossible to use the last one as this \r\n   can not deal with the sparsity of the Hines matrix.\r\n\r\nPrevious works [13] have explored the use of other algorithms based on\r\n the Stone's method [10]. Unlike Thomas algorithm, this method is\r\n  parallel. However, it is in need of a higher number of operations \r\n  ($20 n \\log n$) with respect to the ($8n$) operations of the Thomas\r\n   algorithm to solve one single system of size $n$. Also, the use of \r\n   parallel methods present some additional drawbacks to be dealt with.\r\n    For instance, it would be difficult to compute those neurons that\r\n     compromise a size bigger than the maximum number of threads per CUDA block (1024) or shared memory (48KB). Other problems are the computationally expensive operations such as atomic accesses and synchronizations necessary to compute this method. Each neuron presents a particular morphology and so a different scheduling (preprocessing) must be applied to each of them which makes even more difficult its implementation.\r\n\r\nUnlike the work presented in [13], where a relatively low number of \r\nneurons (128) is computed using single precision operations, in \\cite{cuHines}\r\n the authors are able to execute a very high number of neurons \r\n (up to hundreds of thousands) using double precision operations. \r\n They have used the Hines algorithm, which is the optimum method in \r\n terms of number of operations, avoiding high expensive computational\r\n  operations, such as synchronizations and atomic accesses. The code\r\n   is able to compute a high number of systems (neurons) of any size in\r\n    one call (CUDA kernel), using one thread per Hines system instead of\r\n     one CUDA block per system. Although multiple works have explore the\r\n      use of GPUs to compute multiple independent problems in parallel\r\n       without transforming the data layout [10], the \r\n       particular characteristics of the sparsity of the Hines matrices\r\n        forces us to modify the data layout to efficiently exploit the \r\n        memory hierarchy of the GPUs (coalescing accesses to GPU memory).\r\n         These modifications have not been explored previously, which are\r\n          deeply described and analyzed in the present work.\r\n\r\n\r\n\\section{GPU and cuSPARSE}\r\n\r\nAlthough GPUs are traditionally associated to interactive applications involving high\r\nrasterization performance, they are also widely used to accelerate much more general\r\napplications (now called General Purpose Computing on GPU (GPGPU)) which\r\nrequire an intense computational load and present parallel characteristics. The main\r\nfeature of these devices is a large number of processing elements integrated into a single chip, which reduces significantly the cache memory. These processing elements\r\ncan access to a local high-speed external DRAM memory, connected to the computer\r\nthrough a high-speed I/O interface (PCI-Express). Overall, these devices can offer a\r\nhigher main memory bandwidth and can use data parallelism to achieve a higher floating point throughput than CPUs\r\n\r\nThe \\cite{cuSPARSE} library contains a set of basic linear algebra subroutines used for\r\nhandling sparse matrices. It is implemented on top of the NVIDIA CUDA runtime (which is part of the CUDA Toolkit) and is designed to be called from C and C++.\r\nThe library routines can be classified into four categories:\r\n\r\n\\begin{itemize}\r\n    \\item Level 1 : operations between a vector in sparse format and a vector in dense\r\n    format\r\n    \\item Level 2 : operations between a matrix in sparse format and a vector in dense\r\n    format\r\n    \\item Level 3 : operations between a matrix in sparse format and a set of vectors in\r\n    dense format (which can also usually be viewed as a dense tall matrix)\r\n    \\item Conversions: operations that allow conversion between different matrix formats,\r\n    and compression of csr matrices.\r\n\\end{itemize}\r\n\r\nThe cuSPARSE library allows developers to access the computational resources of the\r\nNVIDIA graphics processing unit (GPU), although it does not auto-parallelize across\r\nmultiple GPUs. As we will see in subsequent sections this library contains the reference\r\nsolver for tridiagonal linear systems in GPU, gtsvStridedBatch which is going to be a\r\ngreat reference in order to evaluate our implementations.\r\n\r\n\r\n\\vspace{10ex}\r\n\\section{Tridiagonal Linear Systems}\r\nThe state-of-the-art method to solve tridiagonal systems is the called Thomas algorithm [28]. Thomas algorithm is a specialized application of the Gaussian elimination\r\nthat takes into account the tridiagonal structure of the system. Thomas algorithm\r\nconsists of two stages, commonly denoted as forward elimination and backward substitution.\r\n\r\nGiven a linear $Au = y$ system, where $A$ is a tridiagonal matrix:\r\n\r\n\\begin{equation}\r\n    A=\\left[\\begin{array}{cccccc}\r\n        b_{1} & c_{1} & & & & 0 \\\\\r\n        a_{2} & b_{2} & c_{2} & & & \\\\\r\n        & & \\cdot & \\cdot & & \\\\\r\n        & & \\cdot & \\cdot & \\cdot & \\\\\r\n        & & & a_{n-1} & b_{n-1} & c_{n-1} \\\\\r\n        & & & & a_{n} & b_{n}\r\n        \\end{array}\\right]\r\n\\end{equation}\r\n\r\nThe forward stage eliminates the lower diagonal as follows:\r\n\r\n\\begin{equation}\r\n    \\begin{aligned}\r\n        c_{1}^{\\prime}=\\frac{c_{1}}{b_{1}}, \\quad c_{i}^{\\prime}=\\frac{c_{i}}{b_{i}-c_{i-1}^{\\prime} a_{i}} & \\text { for } i=2,3, \\ldots, n-1 \\\\\r\n        y_{1}^{\\prime}=\\frac{y_{1}}{b_{1}}, \\quad y_{i}^{\\prime}=\\frac{y_{i}-y_{i-1}^{\\prime} a_{i}}{b_{i}-c_{i-1}^{\\prime} a_{i}} & \\text { for } i=2,3, \\ldots, n-1\r\n    \\end{aligned}\r\n\\end{equation}\r\n\r\nand then the backward stage recursively solve each row in reverse order:\r\n\r\n\\begin{equation}\r\n    u_{n}=y_{n}^{\\prime}, u_{i}=y_{i}^{\\prime}-c_{i}^{\\prime} u_{i+1} \\text { for } i=n-1, n-2, \\ldots, 1\r\n\\end{equation}\r\n\r\nOverall, the complexity of Thomas algorithm is optimal: $8n$ operations \r\nin $2n - 1$ steps.\r\n\r\nCyclic Reduction (CR) is a parallel alternative to Thomas algorithm.\r\nIt also consists of two phases (reduction and substitution). In each intermediate step\r\nof the reduction phase, all even-indexed (i) equations \r\n$a_{i} x_{i-1}+b_{i} x_{i}+c_{i} x_{i+1}=d_{i}$ are\r\nreduced. The values of $a_i$, $b_i$, $c_i$ and $d_i$ are updated in \r\neach step according to:\r\n\r\n\\begin{equation}\r\n    \\begin{array}{c}\r\n        a_{i}^{\\prime}=-a_{i-1} k_{1}, b_{i}^{\\prime}=b_{i}-c_{i-1} k_{1}-a_{i+1} k_{2} c_{i}^{\\prime}=-c_{i+1} k_{2}, y_{i}^{\\prime}=y_{i}-y_{i-1} k_{1}-y_{i+1} k_{2} \\\\\r\n        k_{1}=\\frac{a_{i}}{b_{i-1}}, k_{2}=\\frac{c_{i}}{b_{i+1}}\r\n    \\end{array}\r\n\\end{equation}\r\n\r\nAfter $log_2 n$ steps, the system is reduced to a single equation that is\r\n solved directly. All odd-indexed unknowns $x_i$ are then solved in the \r\n substitution phase by introducing the already computed $u_{i−1}$ and \r\n $u_{i+1}$ values:\r\n\r\n\\begin{equation}\r\n    u_{i}=\\frac{y_{i}^{\\prime}-a_{i}^{\\prime} x_{i-1}-c_{i}^{\\prime} x_{i+1}}{b_{i}^{\\prime}}\r\n\\end{equation}\r\n\r\nOverall, the CR algorithm needs $17n$ operations and $2 \\log_2 n - 1$ \r\nsteps. Figure \\ref{fig:22} graphically illustrates its access pattern.\r\n\r\n\\vspace{5ex}\r\n\\begin{figure}[htbp]\r\n    \\centering\r\n    \\includegraphics[width = 0.35\\textwidth]{fig-22}\r\n    \\label{fig:22}\r\n    \\caption{Access pattern of the CR algorithm}\r\n\\end{figure}\r\n\r\nParallel Cyclic Reduction (PCR) is a variant of CR, which only has\r\nsubstitution phase. For convenience, we consider cases where $n = 2^s$\r\n, that involve $s = \\log_2 n$ steps. Similarly to CR $a$, $b$, $c$ and $y$ \r\nare updated as follows, for $j = 1, 2, \\cdots, s$ and $k = 2^{j-1}$:\r\n\r\n\\begin{equation}\r\n    \\begin{array}{c}\r\n        a_{i}^{\\prime}=\\alpha_{i} a_{i}, b_{i}^{\\prime}=b_{i}+\\alpha_{i} c_{i-k}+\\beta_{i} a_{i+k} \\\\\r\n        c_{i}^{\\prime}=\\beta_{i} c_{i+1}, y_{i}^{\\prime}=b_{i}+\\alpha_{i} y_{i-k}+\\beta_{i} y_{i+k} \\\\\r\n        \\alpha_{i}=\\frac{-a_{i}}{b_{i-1}}, \\beta_{i}=\\frac{-c_{i}}{b_{i}}\r\n    \\end{array}\r\n\\end{equation}\r\n\r\nfinally the solution is achieved as:\r\n\r\n\\begin{equation}\r\n    u_{i}=\\frac{y_{i}^{\\prime}}{b_{i}}\r\n\\end{equation}\r\n\r\nEssentially, at each reduction stage, the current system is transformed into two smaller\r\nsystems and after $\\log_2 n$ steps the original system is reduced to $n$ \r\nindependent equations. Overall, the operation count of PCR is $12n log_2 n$. \r\nFigure \\ref{fig:23} sketches the corresponding access pattern.\r\n\r\n\\vspace{5ex}\r\n\\begin{figure}[htbp]\r\n    \\centering\r\n    \\includegraphics[width = 0.35\\textwidth]{fig-23}\r\n    \\label{fig:23}\r\n    \\caption{Access pattern of the PCR algorithm}\r\n\\end{figure}\r\n\r\nWe should highlight that apart from their computational complexity these algorithms differ in their data access and synchronization patterns, which also have a strong\r\ninfluence on their actual performance. For instance, in the CR algorithm synchronizations are introduced at the end of each step and its corresponding memory access\r\npattern may cause bank conflicts. PCR needs less steps and its memory access pattern\r\nis more regular.\r\n\r\nIn fact, hybrid combinations that try to exploit the best of each algorithm have\r\nbeen explored. Figure \\ref{fig:24} illustrates the access pattern of the\r\nCR-PCR combination proposed in [13]. CR-PCR reduces the system to a certain size\r\nusing the forward reduction phase of CR and then solves the reduced (intermediate)\r\nsystem with the PCR algorithm. Finally, it substitutes the solved unknowns back into\r\nthe original system using the backward substitution phase of CR. Indeed, this is the\r\nmethod implemented by the gtsvStridedBatch routine into the cuSPARSE package.\r\n\r\n\\vspace{5ex}\r\n\\begin{figure}[htbp]\r\n    \\centering\r\n    \\includegraphics[width = 0.38\\textwidth]{fig-24}\r\n    \\label{fig:24}\r\n    \\caption{Access pattern of the CR-PCR algorithm}\r\n\\end{figure}\r\n\r\n\r\n\\vspace{10ex}\r\n\\section{Hines Algorithm}\r\nIn this section, we describe the numerical framework behind the computation of the\r\nVoltage on neurons morphology. It follows the next general form:\r\n\r\n\\begin{equation}\r\n    C \\frac{\\partial V}{\\partial t}+I=f \\frac{\\partial}{\\partial x}\\left(g \\frac{\\partial V}{\\partial x}\\right)\r\n\\end{equation}\r\n\r\nwhere $f$ and $g$ are functions on $x$-dimension and the current $I$ and \r\ncapacitance $C$ depend on the voltage $V$. Discretizing the previous \r\nequation on a given morphology we obtain a system that has to be solved \r\nevery time-step. This system must be solved at each point:\r\n\r\n\\begin{equation}\r\n    a_{i} V_{i+1}^{n+1}+d_{i} V_{i}^{n+1}+b_{i} V_{i-1}^{n+1}=r_{i}\r\n\\end{equation}\r\n\r\nwhere the coefficients of the matrix are defined as follow:\r\n\r\nupper diagonal: \r\n\r\n\\begin{equation}\r\n    a_{i}=-\\frac{f_{i} g_{i+\\frac{1}{2}}}{2 \\Delta_{x}^{2}}\r\n\\end{equation}\r\n\r\nlower diagonal: \r\n\r\n\\begin{equation}\r\n    b_{i}=-\\frac{f_{i} g_{i+\\frac{1}{2}}}{2 \\Delta_{x}^{2}}\r\n\\end{equation}\r\n\r\ndiagonal: \r\n\r\n\\begin{equation}\r\n    d_{i}=\\frac{C_{i}}{\\Delta_{t}}-\\left(a_{i}+b_{i}\\right)\r\n\\end{equation}\r\n\r\nrhs: \r\n\r\n\\begin{equation}\r\n    r_{i}=\\frac{C_{i}}{\\Delta_{t}} V_{i}^{n}-I-a_{i}\\left(V_{i-1}^{n}-V_{i}^{n}\\right)-b_{i}\\left(V_{i+1}^{n}-V_{i}^{n}\\right)\r\n\\end{equation}\r\n\r\nThe $a_i$ and $b_i$ are constant in the time, and they are computed once at start up.\r\nOtherwise, the diagonal (d) and right-side-hand (rhs) coefficients are updated every\r\ntime-step when solving the system.\r\n\r\nThe discretization above explained is extended to include branching, where the\r\nspatial domain (neuron morphology) is composed of a series of one-dimension sections\r\nthat are joined at branch points according to the neuron morphology.\r\n\r\nFor sake of clarity, we illustrate a simple example of a neuron morphology in Figure \\ref{fig:25}. It is important to note that the graph formed by the neuron morphology is an\r\nacyclic graph, i.e. it has no loops. The nodes are numbered using a scheme that gives\r\nthe matrix sparsity structure that allows to solve the system in linear time.\r\n\r\n\\vspace{5ex}\r\n\\begin{figure}[htbp]\r\n    \\centering\r\n    \\includegraphics[width = 0.6\\textwidth]{fig-25}\r\n    \\label{fig:25}\r\n    \\caption{Example of a neuron morphology and its numbering (left-top and bottom)\r\n    and sparsity pattern corresponding to the numbering followed (top-right)}\r\n\\end{figure}\r\n\r\nThe Hines matrices feature the following properties: they are symmetric, the diagonal\r\ncoefficients are all nonzero and per each off-diagonal element, there is one off-diagonal\r\nelement in the corresponding row and column (see row/column 7, 12, 17 and 22 in\r\nFigure \\ref{fig:25}).\r\n\r\nGiven the aforementioned properties, the Hines systems ($Ax = b$) can be efficiently\r\nsolved by using an algorithm similar to Thomas algorithm for solving tri-diagonal systems. This algorithm, called Hines algorithm, is almost identical to the Thomas algorithm except by the sparsity pattern given by the morphology of the neurons whose\r\npattern is stored by the $p$ vector. An example of the sequential code used to implement\r\nthe Hines algorithm is illustrated in pseudo-code in Algorithm 1.\r\n\r\n\r\n\\vspace{5ex}\r\n\\begin{figure}[htbp]\r\n    \\centering\r\n    \\includegraphics[width = 1.0\\textwidth]{hines}\r\n    \\label{fig:hines}\r\n\\end{figure}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "14864a95403c069465fbc3d95fef5fc0d920b546", "size": 13572, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/chapter1.tex", "max_stars_repo_name": "CrazyIvanPro/cuHinesBatch", "max_stars_repo_head_hexsha": "d284c0c5de395c499619a3961bf1544df504c565", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/chapter1.tex", "max_issues_repo_name": "CrazyIvanPro/cuHinesBatch", "max_issues_repo_head_hexsha": "d284c0c5de395c499619a3961bf1544df504c565", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/chapter1.tex", "max_forks_repo_name": "CrazyIvanPro/cuHinesBatch", "max_forks_repo_head_hexsha": "d284c0c5de395c499619a3961bf1544df504c565", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.5436241611, "max_line_length": 426, "alphanum_fraction": 0.7120542293, "num_tokens": 3688, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4169687614286824}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{February 8 2019}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\\newtheorem{claim}{Claim}\n\n\\DeclareMathOperator{\\Int}{Int}\n\\DeclareMathOperator{\\grad}{grad}\n\\DeclareMathOperator{\\Ker}{Ker}\n\\DeclareMathOperator{\\Ima}{Im}\n\\DeclareMathOperator{\\Vol}{vol}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\mb}[1]{\\mathbf{#1}}\n\\newcommand{\\hlfspc}[0]{\\mathbb{H}}\n\\newcommand{\\loint}[0]{\\operatorname{L}\\int}\n\\newcommand{\\hiint}[0]{\\operatorname{U}\\int}\n\\newcommand{\\indic}[1]{\\chi_{#1}}\n\n\\begin{document}\n\n\\maketitle\n\nRecall that if \\(\\dim V = n\\), then \\(\\dim \\Omega^n(V) = 1\\). Furthermore, every \\(\\omega \\in \\Omega^n(\\reals^n)\\) is a multiple of \\(\\det\\).\n\nMore generally, we have the following lemma:\n\\begin{lemma}\n  If \\(\\omega \\in \\Omega^n(V)\\), and \\(v_1,...,v_n \\in V\\), let\n  \\begin{equation}\n    w_i = \\sum_{j = 1}^na_{ij}v_j\n  \\end{equation}\n  Then, if \\(A = (a_{ij}) \\in \\reals^{n \\times n}\\),\n  \\begin{equation}\n    \\omega(w_1,...,w_n) = \\det(A)\\omega(v_1,...,v_n)\n    \\label{thisthing}\n  \\end{equation}\n\\end{lemma}\n\\begin{proof}\n  Let's express things in terms of an \\(n\\)-form on \\(\\reals^n\\). Define \\(\\eta \\in \\Omega^n(\\reals^n)\\) by equation \\ref{thisthing} as on the columns of \\(A\\) (being a function taking in \\(n\\) vectors) as\n  \\begin{equation}\n    \\eta((a_{11},...,a_{1n}),(a_{21},...,a_{2n}),...,(a_{n_1},...,a_{nn})) = \\omega\\left(\\sum a_{1j}v_i, ... \\sum a_{nj}v_j\\right)\n    \\label{star}\n  \\end{equation}\n  We have that, for some \\(\\lambda \\in \\reals\\)\n  \\begin{equation}\n    \\eta = \\lambda\\det \\implies \\eta(e_1,...,e_n) = \\lambda \\det(e_1,...,e_n) = \\lambda = \\omega(v_1,...,v_n)\n  \\end{equation}\n  But this tells us that\n  \\begin{equation}\n    \\omega(w_1,...,w_n) = w(v_1,...,v_n)\\det(a_j)\n    \\label{eq2}\n  \\end{equation}\n  since the left hand side of equation \\ref{eq2} is equal to equation \\ref{star}. One thing that's good to point out is the following: suppose \\(v_1,...,v_n\\) were linearly dependent. This would tell us that \\(\\omega(v_1,...,v_n)\\) and hence \\(\\omega(w_1,...,w_n)\\) would be zero.\n\\end{proof}\nIn general, this shows us that if \\(\\dim V = n\\), any nonzero \\(\\omega \\in \\Omega^n(V)\\) divides the set of all bases of \\(V\\) into two groups:\n\\begin{itemize}\n  \\item Those where \\(\\omega(v_1,...,v_n) > 0\\)\n  \\item Those where \\(\\omega(v_1,...,v_n) < 0\\)\n\\end{itemize}\nAnother way of saying the same thing without using differential forms is saying that \\((v_1,...,v_n)\\) and \\((\\omega_1,...,\\omega_n)\\) are in the same group if one can be transformed into the other with a matrix \\(A\\) having positive determinant.\n\n\\section{Orientations of \\(V\\)}\n\n\\begin{definition}\nDefine an \\underline{orientation of \\(V\\)} to be a choice of one of these two groups.\nWe can consider this as providing an equivalence relation: two bases are equivalent if they belong to the same group. We will write these as\n\\begin{itemize}\n  \\item \\([v_1,...,v_n]\\) to denote the equivalence class of \\(v_1,...,v_n\\)\n  \\item \\(-[v_1,...,v_n]\\) to denote the equivalence class of the opposite group\n\\end{itemize}\n\\end{definition}\n\\begin{definition}\n  The \\underline{standard orientation} of \\(\\reals^n\\) is \\([e_1,...,e_n]\\)\n\\end{definition}\nFor example, in \\(\\reals^3\\), the standard orientation is given by \\([e_1, e_2, e_3]\\), giving the physics right hand rule: if you put your index and middle fingers in the direction of \\(e_1, e_2\\), your thumb points in the direction of \\(e_3\\).\n\nSuppose \\(V\\) has an inner product \\(T\\). In this case, we can consider orthonormal bases with respect to \\(T\\). So consider two different orthonormal bases \\(v_1,...,v_n\\) and \\(w_1,...,w_n\\) with respect to \\(T\\). That is,\n\\begin{equation}\n  T(v_i, v_j) = T(w_i, w_j) = \\delta_{ij}\n\\end{equation}\nSo we can write one in terms of the other, i.e. find \\(A = (a_{ij})\\) such that\n\\begin{equation}\n  w_i = \\sum_{a_{ij}}v_j\n\\end{equation}\nwhere \\(\\det A = \\pm 1\\). How do we see that? Well, let's compute:\n\\begin{equation}\n  T(w_i, w_j) = T\\left(\\sum_ka_{ik}v_k, \\sum_\\ell a_{j\\ell}v_\\ell\\right) = \\sum_{k, \\ell}a_{ik}a_{j\\ell}T(v_k, v_\\ell) = \\sum_{k, \\ell}a_{ik}a_{j\\ell}\\delta_{k\\ell} = \\sum_ka_{ik}a_{jk} = \\delta_{ij}\n\\end{equation}\nSo everything is zero here unless \\(i = j, k = \\ell\\), in which this becomes\n\\begin{equation}\n  (AA^T)_{ij} = \\delta_{ij} \\implies AA^T = I \\implies \\det A^2 = 1 \\implies \\det A = \\pm 1\n\\end{equation}\nas desired. We can now obtain the following result\n\\begin{lemma}\n  Given inner product \\(T\\) and orientation \\(\\mu\\) for \\(V\\), there is a unique \\(\\omega \\in \\Omega^n(V)\\) such that \\(\\omega(v_1,...,v_n) = 1\\) whenever \\(v_1,...,v_n\\) are an orthonormal basis and \\([v_1,...,v_n] = \\mu\\).\n\\end{lemma}\nThe point is, if have an orthonromal basis \\(v_1,...,v_n\\) where \\(\\omega(v_1,...,v_n) = 1\\) and take \\textit{another} orthonormal basis \\(w_1,...,w_n\\), then\n\\begin{equation}\n  \\omega(w_1,...,w_n) = \\pm\\omega(v_1,...,v_n) = \\pm 1\n\\end{equation}\nwhich, of course, will be \\(1\\) if \\((w_1,...,w_n) \\in \\mu\\).\n\\textit{This} is what we're going to call volume. More precisely, we call \\(\\omega\\) the \\underline{volume form} on \\(V\\). Of course, this is determined by an inner product and an orientation.\n\nFor example, the volume element (form) of \\(\\reals^n\\) determined by the standard inner product and the standard orientation is \\(\\det\\).\nWe're usually going to use the word ``form'' to mean an alternating tensor at every point, but it doesn't matter, as alternating tensor and form can be used interchangeably.\n\nOne thing to mention before we leave this stuff is\n\\subsection{The Cross Product}\nWe have that\n\\begin{equation}\n  \\det\\begin{pmatrix}\n    v_{11} & v_{12} & v_{13} \\\\\n    v_{21} & v_{22} & v_{23} \\\\\n    w_{1} & w_{2} & w_{3}\n  \\end{pmatrix} = \\langle v_1 \\times v_2, w \\rangle\n\\end{equation}\nwhere \\(v_1 \\times v_2\\) denotes the cross product. It turns out you can do the same thing with \\(n - 1\\) vectors in \\(\\reals^n\\). Define \\(\\varphi \\in \\Omega^1(V) = \\mc{T}^1(V) = V^*\\), i.e. let \\(\\phi\\) be a linear function from \\(\\reals^n \\to \\reals\\), where\n\\begin{equation}\n  \\varphi(w) = \\det\\begin{pmatrix} v_1 \\\\ ... \\\\ v_{n - 1} \\\\ w \\end{pmatrix}\n\\end{equation}\nThen there is a unique \\(z \\in V\\) such that \\(\\varphi(w) = \\langle z, w \\rangle\\). This is something you proved last year in linear algebra... I hope...\nSo we'll call \\(z\\) the \\underline{cross product} of \\(v_1,...,v_{n - 1}\\), \\(v_1 \\times v_2 \\times ... \\times v_{n - 1}\\).\nNote that the cross product is an alternating multilinear form. It also satisfies the distributive property.\n\nWh do we want to use this? Well, we want to start proving the following:\n\\begin{equation}\n  \\int_{\\text{cube}}f(x_1,...,x_n)dx_1 \\wedge ... \\wedge dx_n = \\int_{\\text{cube}}f dx_1...dx_n\n\\end{equation}\nAnd we'll get to that next time...\n\n\\end{document}\n", "meta": {"hexsha": "7ac030ada059ff921313340c4d6c106ecf365f98", "size": 7544, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/february8.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/february8.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/february8.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.4465408805, "max_line_length": 280, "alphanum_fraction": 0.6655620361, "num_tokens": 2659, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704502361149, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.4169687503558143}}
{"text": "\\documentclass{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n% \\usepackage{amscd, amsfonts, amsmath, amssymb, amstext, amsthm, caption, epsfig, fancyhdr, float, graphicx, latexsym, mathtools, multicol, multirow, algorithm, chngcntr}\n\\usepackage[english]{babel}\n\\usepackage{booktabs}\n\n\\usepackage{amsmath,amssymb}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subfig}\n\\usepackage{xspace}\n\\usepackage{fourier}\n\n\\usepackage{tikz}\n\\usetikzlibrary{shapes,arrows}\n\\usepackage{tkz-graph}\n\\usetikzlibrary{automata,arrows,positioning,calc}\n\\usetikzlibrary{positioning}\n\\usetikzlibrary{fit}\n\\usetikzlibrary{backgrounds}\n\\usetikzlibrary{calc}\n\\usetikzlibrary{shapes}\n\\usetikzlibrary{mindmap}\n\\usetikzlibrary{decorations.text}\n\\usetikzlibrary{snakes}\n\n% \\theoremstyle{definition} % insert bellow all blocks you want in normal text\n% \\newtheorem{definition}{Definition}\n\n\n\n% tikzmark command, for shading over items\n\\newcommand{\\tikzmark}[1]{\\tikz[overlay,remember picture] \\node (#1) {};}\n% Define block styles\n\\tikzstyle{decision} = [diamond, draw, fill=blue!20,\n    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]\n\\tikzstyle{block} = [rectangle, draw, fill=blue!20,\n    text width=5em, text centered, rounded corners]\n\\tikzstyle{line} = [draw]\n\\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,\n    minimum height=2em]\n\n\\usepackage[most]{tcolorbox}\n\n\\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow\n\n\n% Distributions.\n\\newcommand*{\\UnifDist}{\\mathsf{Unif}}\n\\newcommand*{\\ExpDist}{\\mathsf{Exp}}\n\\newcommand*{\\DepExpDist}{\\mathsf{DepExp}}\n\\newcommand*{\\GammaDist}{\\mathsf{Gamma}}\n\\newcommand*{\\LognormalDist}{\\mathsf{LogNorm}}\n\\newcommand*{\\WeibullDist}{\\mathsf{Weib}}\n\\newcommand*{\\ParetoDist}{\\mathsf{Par}}\n\\newcommand*{\\NormalDist}{\\mathsf{Norm}}\n\n\\newcommand*{\\GeometricDist}{\\mathsf{Geom}}\n\\newcommand*{\\NegBinomialDist}{\\mathsf{NegBin}}\n\\newcommand*{\\PoissonDist}{\\mathsf{Poisson}}\n\\newcommand*{\\BivariatePoissonDist}{\\mathsf{BPoisson}}\n\\newcommand*{\\CyclicalPoissonDist}{\\mathsf{CPoisson}}\n\n\\newcommand*{\\iid}{\\textbf{iid}\\@\\xspace}\n\\newcommand*{\\pdf}{\\textbf{pdf}\\@\\xspace}\n\\newcommand*{\\cdf}{\\textbf{cdf}\\@\\xspace}\n\\newcommand*{\\pmf}{\\textbf{pmf}\\@\\xspace}\n\\newcommand*{\\abc}{{\\textbf{abc}}\\@\\xspace}\n\\newcommand*{\\smc}{\\textbf{smc}\\@\\xspace}\n\\newcommand*{\\mcmc}{\\textbf{mcmc}\\@\\xspace}\n\\newcommand*{\\ess}{\\textbf{ess}\\@\\xspace}\n\\newcommand*{\\mle}{\\textbf{mle}\\@\\xspace}\n\\newcommand*{\\bic}{\\textbf{bic}\\@\\xspace}\n\\newcommand*{\\kde}{\\textbf{kde}\\@\\xspace}\n\\newcommand*{\\glm}{\\textbf{glm}\\@\\xspace}\n\\newcommand*{\\xol}{\\textbf{xol}\\@\\xspace}\n\\newcommand*{\\cpu}{\\textbf{cpu}\\@\\xspace}\n\\newcommand*{\\gpu}{\\textbf{gpu}\\@\\xspace}\n\\newcommand*{\\arm}{\\textbf{arm}\\@\\xspace}\n\n\\def \\si {\\sigma}\n\\def \\la {\\lambda}\n\\def \\al {\\alpha}\n% \\def\\e*{\\end{eqnarray*}}\n\\def \\di{\\displaystyle}\n\n\\def \\E{\\mathbb E}\n\\def \\N{\\mathbb N}\n\\def \\Z{\\mathbb Z}\n\\def \\NZ{\\mathbb{N}_0}\n\\def \\I{\\mathbb I}\n\\def \\w{\\widehat}\n\\def \\P {\\mathbb P}\n\\def \\V{\\mathbb V}\n\n\n\\newcommand{\\CL}{\\mathbb{C}}\n\\newcommand{\\RL}{\\mathbb{R}}\n\\newcommand{\\nat}{{\\mathbb N}}\n\\newcommand{\\Laplace}{\\mathscr{L}}\n\\newcommand{\\e}{\\mathrm{e}}\n\\newcommand{\\ve}{\\bm{\\mathrm{e}}} % vector e\n\n\\renewcommand{\\L}{\\mathcal{L}} % e.g. L^2 loss.\n\n\\newcommand{\\ih}{\\mathrm{i}}\n\\newcommand{\\oh}{{\\mathrm{o}}}\n\\newcommand{\\Oh}{{\\mathcal{O}}}\n\\newcommand{\\Exp}{\\mathbb{E}}\n\n\\newcommand{\\Norm}{\\mathcal{N}}\n\\newcommand{\\LN}{\\mathcal{LN}}\n\\newcommand{\\SLN}{\\mathcal{SLN}}\n\n\\renewcommand{\\Pr}{\\mathbb{P}}\n\\newcommand{\\Ind}{\\mathbb I}\n\\newcommand\\bfsigma{\\bm{\\sigma}}\n\\newcommand\\bfSigma{\\bm{\\Sigma}}\n\\newcommand\\bfLambda{\\bm{\\Lambda}}\n\\newcommand{\\stimes}{{\\times}}\n\\def \\limsup{\\underset{n\\rightarrow+\\infty}{\\overline{\\lim}}}\n\\def \\liminf{\\underset{n\\rightarrow+\\infty}{\\underline{\\lim}}}\n\n\n\n\n% vertical separator macro\n\\newcommand{\\vsep}{\n  \\column{0.0\\textwidth}\n    \\begin{tikzpicture}\n      \\draw[very thick,black!10] (0,0) -- (0,7.3);\n    \\end{tikzpicture}\n}\n\\newcommand\\blfootnote[1]{%\n  \\begingroup\n  \\renewcommand\\thefootnote{}\\footnote{#1}%\n  \\addtocounter{footnote}{-1}%\n  \\endgroup\n}\n\n% More space between lines in align\n% \\setlength{\\mathindent}{0pt}\n\n% Beamer theme\n\\usetheme{ZMBZFMK}\n\\usefonttheme[onlysmall]{structurebold}\n\\mode<presentation>\n\\setbeamercovered{transparent=10}\n\n% align spacing\n\\setlength{\\jot}{0pt}\n\n\\setbeamertemplate{navigation symbols}{}%remove navigation symbols\n\n\\title[BLOCKASTICS]{Blockchain miner's risk management}\n\\author{Pierre-O. Goffard}\n\\institute[ISFA]{Institut de Science Financières et d'Assurances\\\\\n \\texttt{pierre-olivier.goffard@univ-lyon1.fr}\n}\n\\date{\\today}\n% \\titlegraphic{\\includegraphics[width=2.5cm]{../../Figures/bfs_logo.png}} \n\n\\begin{document}\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\\begin{frame}\n  \\tableofcontents\n\\end{frame}\n\n\\section{Introduction}\n\\begin{frame}{Blockchain}\nA decentralized data ledger made of blocks maintained by achieving consensus in a P2P network.\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n% \\small\n\n\\begin{itemize}\n  \\item Decentralized\n  \\item Public/private\n  \\item Permissionned/permissionless\n  \\item Immutable\n  \\item Incentive compatible\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{center}\n\\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=01cm]\n\\tikzstyle{every edge}=[snake=expanding waves,segment length=1mm,segment angle=10, draw]\n\n\\tikzstyle{full node}=[circle, fill=tublue,draw=tublue,thick,text=black,scale=0.8]\n\\tikzstyle{light node}=[circle, fill=white,draw=tublue,thick,text=black,scale=0.8]\n\\node[full node]    (1)                     {};\n\\node[full node]    (2)[above right of=1]         {};\n\\node[full node]    (3)[above left of=1]         {};\n\\node[full node]    (4)[below of=1]         {};\n\\node[full node]    (5)[right of=4]         {};\n\\node[full node]    (6)[below of=4]         {};\n\\node[light node]    (7)[left of=1]         {};\n\\node[light node]    (8)[right of=2]         {};\n\\node[light node]    (9)[left of=4]         {};\n\\node[light node]    (10)[above right of=5]         {};\n\\node[light node]    (11)[ right of=5]         {};\n\\node[light node]    (12)[ below right of=5]         {};\n% \\node[light node]    (4)[above of=2]         {};\n\\path\n\n(1) edge node{} (2)\n    edge node{} (3)\n    edge node{} (7)\n    ;\n\\path\n(5) edge node{} (10)\n    edge node{} (11)\n    edge node{} (12)\n    ;\n    \\path\n(4) edge node{} (5)\n    edge node{} (1)\n    edge node{} (9)\n    edge node{} (6)\n    ;\n    \\path\n(2) edge node{} (8)   \n    ;\n\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\n\\vspace{0.2cm}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Focus of the talk]\nPublic and permissionless blockchain equipped with the Proof-of-Work protocol.\n\\end{tcolorbox}\n\\end{frame}\n\n\\begin{frame}{Consensus protocols}\nThe mechanism to make all the nodes agree on a common data history.\\\\\n\\vspace{0.3cm}\nThe three dimensions of blockchain systems analysis\n\\begin{enumerate}\n  \\item Efficiency\n  \\begin{itemize}\n    \\item Throughputs\n    \\item Transaction confirmation time\n  \\end{itemize}\n  \\item Decentralization\n  \\begin{itemize}\n    \\item Fair distribution of the accounting right\n  \\end{itemize}\n  \\item Security \n  \\begin{itemize}\n    \\item Resistance to attacks\n  \\end{itemize}\n\\end{enumerate}\n\\footnotesize\n\\begin{thebibliography}{1}\n\\bibitem{Fu2020}\nX.~Fu, H.~Wang, and P.~Shi, ``A survey of blockchain consensus algorithms:\n  mechanism, design and applications,'' {\\em Science China Information\n  Sciences}, vol.~64, nov 2020.\n\\end{thebibliography}\n\\end{frame}\n\\begin{frame}{Applications of blockchain: Cryptocurrency}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n   \n{\\footnotesize\n\\begin{thebibliography}{1}\n\\bibitem{Na08}\nS.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at\n  \\href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},\n  2008.\n\\end{thebibliography}  \n}\n\\end{column}\n\\begin{column}{0.5\\textwidth}  %%<--- here\n    \\begin{center}\n     \\includegraphics[width=0.5\\textwidth]{../../Figures/bitcoin-6284869_1920.png}\n     \\end{center}\n\\end{column}\n\\end{columns}\n\n\\begin{itemize}\n  \\item Transaction anonymity\n  \\item Banking and reliable currency in certain regions of the world\n  \\item Money Transfer worldwide (at low fare)\n  \\item No need for a thrusted third party\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Decentralized finance}\nDEFI creates new financial architecture\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\begin{itemize}\n\\item[+] Non custodial\n\\item[+] Anonymous\n\\item[+] Permisionless\n\\item[+] openly auditable\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth} \n\\begin{itemize}\n\\item[-] Unregulated\n\\item[-] Tax evasion\n\\item[-] Fraud\n\\item[-] Money laundering\n\\end{itemize} \n\\end{column}\n\\end{columns}\n\\vspace{0.5cm}\nExtends the Bitcoin promises to more complex financial operations\n\\begin{itemize}\n  \\item Collateralized lending\n  \\item Decentralized Exchange Platform\n  \\item Tokenized assets\n  \\item Fundraising vehicle (ICO, STO, ...)\n\\end{itemize}\n\\vspace{0.3cm}\n\\scriptsize\n\\begin{thebibliography}{1}\n\n\\bibitem{werner2021sok}\nS.~M. Werner, D.~Perez, L.~Gudgeon, A.~Klages-Mundt, D.~Harz, and W.~J.\n  Knottenbelt, ``Sok: Decentralized finance (defi),'' 2021.\n\n\\end{thebibliography}\n\n\\end{frame}\n\\begin{frame}{What's inside a block?}\nA block consists of \n\\begin{itemize}\n\\item a header \n\\item a list of \"transactions\" that represents the information recorded through the blockchain. \n\\end{itemize}\nThe header usually includes \n\\begin{itemize}\n\\item the date and time of creation of the block, \n\\item the block height which is the index inside the blockchain, \n\\item the hash of the block \n\\item the hash of the previous block. \n\\end{itemize}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Question]\nWhat is the hash of a block?\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Cryptographic Hash function}\n\\small\nA function that maps data of arbitratry size (message) to a bit array of fixed size (hash value)\n$$\nh:\\{0,1\\}^\\ast\\mapsto \\{0,1\\}^d. \n$$\nA good hash function is\n\\begin{itemize}\n\\item deterministic\n\\item quick to compute\n\\item One way\n\\begin{itemize}\n  \\scriptsize\n\\item[$\\hookrightarrow$] For a given hash value $\\overline{h}$ it is hard to find a message $m$ such that \n$$\nh(m) = \\overline{h}\n$$\n\\end{itemize}\n\\item Colision resistant \n\\begin{itemize}\n\\item[$\\hookrightarrow$] Impossible to find $m_1$ and $m_2$ such that \n$$\nh(m_1) = h(m_2)\n$$\n\\end{itemize}\n\\item Chaotic\n$$m_1\\approx m_2\\Rightarrow  h(m_1) \\neq h(m_2)$$\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{SHA-256}\nThe SHA-256 function which converts any message into a hash value of $256$ bits.\n\\begin{tcolorbox}[enhanced,drop shadow, title=Example]\nThe hexadecimal digest of the message\n$$\n\\texttt{Moritz Voss is the man}\n$$\nis \n\\footnotesize\n$$\n\\texttt{50f3257a3d22a56247a8978fd2505e8cdd64e1cb06e52c941d09e234722dc275}\n$$\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Mining a block}\n\\begin{figure}[!ht]\n    \\includegraphics[width = \\textwidth]{../../Figures/block_not_mined.png}\n    \\captionsetup{width=0.8\\textwidth}\n    \\centering\n    \\caption{A block that has not been mined yet.}\n    \\label{fig:block_not_mined}\n\\end{figure}\n\\end{frame}\n\\begin{frame}{Mining a block}\nThe maximum value for a 256 bits number is\n$$\nT_\\text{max} = 2^{256}-1 \\approx 1.16e^{77}.\n$$\nMining consists in drawing at random a nonce \n$$\n\\text{Nonce} \\sim \\text{Unif}(\\{0,\\ldots, 2^{32}-1\\}),\n$$\nuntil \n$$\nh(\\text{Nonce}|\\text{Block info})<T,\n$$\nwhere $T$ is referred to as the target.\n\\begin{tcolorbox}[enhanced,drop shadow, title=Difficulty of the cryptopuzzle]\n$$\nD = \\frac{T_{\\max}}{T}.\n$$\n\\end{tcolorbox}\n\n\\end{frame}\n\\begin{frame}{Mining a block}\nIf we set the difficulty to $D = 2^4$ then the hexadecimal digest must start with at least $1$ leading $0$\n\\begin{figure}[!ht]\n    \\includegraphics[width = \\textwidth]{../../Figures/block_mined.png}\n    \\captionsetup{width=0.8\\textwidth}\n    \\centering\n    \\caption{A mined block with a hash value having on leading zero.}\n    \\label{fig:block_mined}\n\\end{figure}\nThe number of trial is geometrically distributed\n\\begin{itemize}\n\\item Exponential inter-block times\n\\item Lenght of the blockchain = Poisson process\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Bitcoin protocol}\n\\begin{itemize}\n  \\item One block every 10 minutes on average\n  \\item Depends on the hashrate of the network\n  \\item Difficulty adjustment every 2,016 blocks ($\\approx$ two weeks)\n  \\item Reward halving every 210,000 blocks\n\\end{itemize}\nCheck out \\url{https://www.bitcoinblockhalf.com/}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Risky business]\nSteady operational cost VS infrequent capital gains\n\\end{tcolorbox}\n\\end{frame}\n\n\\section{Insurance risk theory}\n\\begin{frame}{Cramer-Lunberg risk model}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\scriptsize\nThe financial reserves of a nonlife insurance company is given by\n\\begin{equation*}\nR_t = u +ct - \\sum_{i = 1}^{N_t}U_i\\text{, }t\\geq0,\n\\end{equation*}\noù \n\\begin{itemize}\n  \\item $u>0$ the initial reserves\n  \\item $c$ is the premium rate\n  \\item $(N_t)_{t\\geq0}$ is the claim frequency up to time $t\\geq0$.\n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$]  Poisson process with intensity $\\lambda$\n  \\end{itemize}\n  \\item The $U_i$'s are the claim amounts\n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$] Nonnegative random variables, \\textbf{i.i.d.}, and independent from $N_t$\n  \\end{itemize}\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{tikzpicture}\n  %Origin and axis\n  \\coordinate (O) at (0,0);\n  \\draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\\scriptsize$t$}] (xmax);\n  \\draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\\scriptsize$R_t$}] (ymax);\n   %Initial reserves\n  \\draw (0,2) node[black,left] {\\scriptsize$u$} node{};\n % % %Length of the honest chain\n  \\draw[thick, tublue,-] (0,2) -- (2,3) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (2,3) -- (2,1) node[pos=0.5, left] {\\scriptsize\\color{black}$U_1$};\n  \\draw[thick, tublue] (2,1) -- (3,1.5) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (3,1.5) -- (3, 0.5) node[pos=0.5, left] {\\scriptsize\\color{black}$U_2$};\n  \\draw[thick, tublue] (3,0.5) -- (5, 1.5) node[pos=0.5, above] {};\n   \\draw[thick, dashed, tublue] (5,1.5) -- (5, -0.5) node[pos=0.5,above left] {\\scriptsize\\color{black}$U_3$};\n\n  %Block finding Times \n  \\draw (2,0) node[black,below] {\\scriptsize$T_1$} node{ \\color{black}$\\bullet$};\n  \\draw (3,0) node[black,below] {\\scriptsize$T_2$} node{ \\color{black}$\\bullet$};\n  \\draw (5,0) node[black,below left] {\\scriptsize$\\tau_u$} node{ \\color{black}$\\bullet$};\n\\end{tikzpicture}\n\\end{column}\n\\end{columns}\n\n\\end{frame}\n\\begin{frame}{Ruin probability}\n\\scriptsize\nDefine the ruin time as\n$$\n\\tau_u = \\inf\\{t\\geq0\\text{ ; }R_t <0\\}\n$$\nand the ruin probability as\n$$\n\\psi(u,t) = \\mathbb{P}(\\tau_u < t)\\text{ et }\\psi(u) = \\mathbb{P}(\\tau_u < \\infty)\n$$\nFind $u$ such that \n$$\n\\mathbb{P}(\\text{Ruin}) = \\alpha\\text{ (0.005)},\n$$\nwith\n$$\nc=(1+\\eta)\\lambda\\mathbb{E}(U),\n$$\nwhere \n$$\\eta>0\\text{ (net profit condition)}$$  \notherwise \n$$\\psi(u)=1.$$\n\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Asmussen_2010}\nS.~Asmussen and H.~Albrecher, {\\em Ruin Probabilities}.\n\\newblock {WORLD} {SCIENTIFIC}, sep 2010.\n\n\\end{thebibliography}\n\n\\end{frame}\n\n\n\\section{Application to blockchain miner risk management}\n\\begin{frame}{Dual risk model}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\scriptsize\nConsider a miner \n\\begin{itemize}\n  \\item of hashrate $p\\in(0,1)$\n  \\item that owns $u\\geq0$ at $t = 0$ \n  \\item spends $c = \\pi_W\\cdot W\\cdot p$ per time unit  \n  \\item who finds $p \\lambda$ blocks on average per time unit, where $\\lambda$ is the average number of blocks found by the network\n\\end{itemize}\nThe wealth of such a miner is given by\n$$\nR_t = u - c\\cdot t + N_t\\cdot b,\\text{ (Dual risk model)}\n$$\noù \n\\begin{itemize}\n  \\item $(N_t)_{t\\geq0}$ is a Poisson process with intensity $p\\cdot\\lambda$\n  \\item $b$ is the block finding reward (6.25 BTC) \\url{bitcoinhalf.com}\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{tikzpicture}\n  %Origin and axis\n  \\coordinate (O) at (0,0);\n  \\draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\\scriptsize$t$}] (xmax);\n  \\draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\\scriptsize$R_t$}] (ymax);\n   %Initial reserves\n  \\draw (0,3) node[black,left] {\\scriptsize$u$} node{};\n % % %Length of the honest chain\n  \\draw[thick, tublue,-] (0,3) -- (2,1) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (2,1) -- (2,2) node[pos=0.5, above left] {\\scriptsize\\color{black}$b$};\n  \\draw[thick, tublue] (2,2) -- (3.5,0.5) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (3.5,0.5) -- (3.5, 1.5) node[pos=0.5, above left] {\\scriptsize\\color{black}$b$};\n  \\draw[thick, tublue] (3.5,1.5) -- (5, 0) node[pos=0.5, above] {};\n\n  %Block finding Times \n  \\draw (2,0) node[black,below] {\\scriptsize$T_1$} node{ \\color{black}$\\bullet$};\n  \\draw (3.5,0) node[black,below] {\\scriptsize$T_2$} node{ \\color{black}$\\bullet$};\n  \\draw (5,0) node[black,below] {\\scriptsize$\\tau_u$} node{ \\color{black}$\\bullet$};\n\\end{tikzpicture}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}{Expected profit if no failure}\n\\scriptsize\n\nThe ruin time is defined as\n$$\n\\tau_u  = \\inf\\{t\\geq0\\text{ ; }R_t \\leq0\\}\n$$\n\\begin{itemize}\n  \\item Risk measure\n  $$\n  \\psi(u,t) = \\mathbb{P}(\\tau_u \\leq t)\n  $$\n  \\item Profitability measure\n  $$\n  V(u,t) = \\mathbb{E}(R_t\\mathbb{I}_{\\tau_u > t})\n  $$\n\\end{itemize} \n\\end{frame}\n\\begin{frame}{A miner's dilemma} \n\\scriptsize\nUse $\\psi$ and $V$ to compare mining solo to\n\\begin{itemize}\n  \\item pool mining\n\\tiny\n  \\begin{thebibliography}{1}\n\n\\bibitem{rosenfeld2011analysis}\nM.~Rosenfeld, ``Analysis of bitcoin pooled mining reward systems,'' 2011.\n\n\\bibitem[Albrecher et~al.(2022)Albrecher, Finger, and\n  Goffard]{albrecher:hal-03336851}\nHansj{\\\"o}rg Albrecher, Dina Finger, and Pierre-Olivier Goffard.\n\\newblock {Blockchain mining in pools: Analyzing the trade-off between\n  profitability and ruin}.\n\\newblock to appear in Insurance; Mathematics and Economics, April 2022.\n\\newblock URL \\url{https://hal.archives-ouvertes.fr/hal-03336851}.\n\n\n\\end{thebibliography}\n  \\item \\scriptsize deviating from the prescribed protocol (selfish mining)\n\n  \\tiny\n  \\begin{thebibliography}{1}\n  \\bibitem{Eyal2014}\nI.~Eyal and E.~G. Sirer, ``Majority is not enough: Bitcoin mining is\n  vulnerable,'' in {\\em Financial Cryptography and Data Security},\n  pp.~436--454, Springer Berlin Heidelberg, 2014.\n\n\\bibitem[Albrecher and Goffard(2022)]{Hansjoerg2022}\nHansjoerg Albrecher and Pierre-Olivier Goffard.\n\\newblock On the profitability of selfish blockchain mining under consideration\n  of ruin.\n\\newblock \\emph{Operations Research}, 70(1):179--200, jan\n  2022.\n\\newblock \\url{10.1287/opre.2021.2169}.\n\\end{thebibliography}\n\\end{itemize}\nAnalytical expressions for \n$$\n\\widehat{\\psi}(u,t)= \\mathbb{E}[\\psi(u,T)]\\text{ and }\\widehat{V}(u,t)= \\mathbb{E}[V(u,T)],\n$$\nwhere $T\\sim\\text{Exp}(t)$.\n\\end{frame}\n\n\\begin{frame}{Solo mining}\n\\scriptsize\n\\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (profit and ruin when mining solo)]\nFor $u\\geq0$, with \n\\begin{equation*}\n\\widehat{\\psi}(u,t) = e^{\\rho^\\ast u},\n\\end{equation*}\nand \n\\begin{equation*}\n\\widehat{V}(u,t) = u+(p\\lambda b-c)t\\left(1-e^{\\rho^\\ast u }\\right),\n\\end{equation*}\nwhere $\\rho^\\ast$ is the only nonnegative solution of\n\\begin{equation}\\label{eq:equation_rho}\n-c\\rho + p\\lambda(e^{b\\rho}-1) = 1/t.\n\\end{equation}\n\\end{tcolorbox}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Lambert function]\nThe solution $\\rho^\\ast$ of \\eqref{eq:equation_rho} is given by \n\\begin{equation*}\n  \\rho^{\\ast}=-\\frac{p \\lambda t+1}{ct}\n  -\\frac{1}{b} \\,{\\rm W} \\left[-\\frac{p\\lambda\n    \\,b}{c}\\,{e^{-b\\,\\left(\\frac{p \\lambda t+1}{ct}\\right)}}\n  \\right],\n  \\end{equation*}\n  where $W(.)$ denotes the Lambert function.\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Sketch of the proof}\n\\scriptsize\nThe time-horizon is random with $T\\sim\\text{Exp}(t)$, we condition upon the events occuring in $(0,h)$, with $h<u/c$ so that ruin cannot occur before $h$. Three possibilities\n\\begin{itemize}\n  \\item[(i)] $T>h$ and no blocks $(0,h)$\n  \\item[(ii)] $T<h$ and no blocks $(0,T)$\n  \\item[(iii)] One block found before $T$ and $h$\n\\end{itemize}\nThe expected profit $\\widehat{V}(u,t)$ satisfies\n\\begin{eqnarray*}\n  \\widehat{V}(u,t)& =&e^{-h(1/t + p\\lambda)}\\,\\widehat{V}(u-ch,t)+\\int\\limits_0^h\\frac1t\\, e^{-s(1/t + p\\lambda)}\\,(u-cs)ds\\\\\n  &+&\\int\\limits_0^h p\\lambda\\, e^{-s(1/t + p\\lambda)}\\,\\widehat{V}(u-cs+b,t)ds.\n  \\end{eqnarray*}\n  \\end{frame}\n\\begin{frame}{Sketch of the proof}\n\\scriptsize\nDifferentiating with respect to $h$ and setting $h=0$, we get\n\\begin{equation}\\label{eq:ODE}\nc\\widehat{V}'(u,t) + \\left(\\frac{1}{t} +  p\\lambda\\right)\\widehat{V}(u,t) - p\\lambda \\widehat{V}(u+b,t) - \\frac{u}{t} =0,\n\\end{equation}\nEquation \\eqref{eq:ODE} is an advanced differential equation\n\\blfootnote{\\tiny \n H.~L. Smith, {\\em An introduction to delay differential equations with\n  applications to the life sciences}.\n\\newblock Springer, New York, 2011.\n}\nwith boundary conditions\n$$\n\\widehat{V}(0,t) = 0 \\text{ such that } 0\\leq \\widehat{V}(u,t)\\leq u-ct+p\\lambda b t \\text{ for }u>0.\n$$  \nConsider solutions of the form \n\\begin{equation}\\label{eq:potential_solution}\n\\widehat{V}(u,t) = Ae^{\\rho u }+Bu + C,\\text{ }u \\ge 0, \n\\end{equation}\nwhere $A, B,C$ and $\\rho$ are constants to be determined. Substituting \\eqref{eq:potential_solution} in \\eqref{eq:ODE} together with boundary conditions\n\\begin{equation*}\n\\begin{cases}\n0&=ct\\rho + \\left(1+p\\lambda t\\right)-p\\lambda te^{\\rho b}, \\\\\n0&= B\\left(1+tp\\lambda\\right)-p\\lambda tB - 1,\\\\\n0&=Bct+C(1+tp\\lambda) - p\\lambda t Bb-p\\lambda tC, \\\\\n0&=A+C.\n\\end{cases}\n\\end{equation*}\n\\end{frame}\n\\begin{frame}{Sketch of the proof}\n\\scriptsize\nWe get $A = -t(p\\lambda b - c)$, $B = 1$, $C = t(p\\lambda b - c)$ and $\\rho$ verifies\n$$\nc\\rho + \\left(1+p\\lambda t\\right)-p\\lambda te^{\\rho b} = 0,\n$$\nThe latter has two solutions on the real line, one negative and the other is positive. As $A<0$, we must take  $\\rho^\\ast<0$ to ensure that $\\widehat{V}(u,t)>0$. Substituting $A,B,C$ and $\\rho^{\\ast}$ in \\eqref{eq:potential_solution} yields the result.\\\\\n\nSimilarly, the ruin probability satisfies\n\\begin{equation*}\\label{psii}\nc\\widehat{\\psi}'(u,t)+(p \\lambda+1/t)\\,\\widehat{\\psi}(u,t)-p \\lambda\\,\\widehat{\\psi}(u+b,t)=0\n\\end{equation*}\nwith initial condition $\\widehat{\\psi}(0,t)=1$ and boundary condition $\\lim_{u\\to\\infty}\\widehat{\\psi}(u,t)=0$.\n\\end{frame}\n\\begin{frame}{Mining pool?}\n\\scriptsize\nLet $I\\subset\\{1,\\ldots, n\\}$ be a set of miners with cumulated hashpower\n$$\np_I = \\sum_{i\\in I }p_i,\n$$\n\\begin{itemize}\n  \\item A pool manager coordinates the joint effort\n  \\item Miners show their work by submitting partial solutions (\\textit{share})  \n\\end{itemize}\nThe pool manager chooses\n\\begin{itemize} \n  \\item the participant remuneration system\n  \\item the relative difficulty $q\\in(0,1)$ of finding a \\textit{share} VS finding a proper solution\n  \\item the amount of management fees $f$\n  \\end{itemize} \n\\end{frame}\n\\begin{frame}{Remuneration system}\n\\scriptsize\nMiners must be compensated pro-rata to their contribution to the mining effort. \n\\begin{tcolorbox}[enhanced,drop shadow, title=Proportional scheme]\nA \\text{round} is the time elapsed between two block discovery \n\\begin{itemize} \n  \\item $s_i$ is the number of \\textit{shares} submitted by $i\\in I$ during the \\textit{round}\n  \\item Each miner receives \n  $$\n  (1-f)\\cdot b\\cdot\\frac{s_i}{\\sum_{i\\in I}s_i},\n  $$\n  at the end the round, where $f$ is the pool manager's cut.\n  \\item The system is deemed fair if $\\frac{s_i}{\\sum_{i\\in I}s_i}\\approx\\frac{p_i}{\\sum_{i\\in I}p_i}$\n\\end{itemize}\n\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{What's wrong about going proportional}\n\\scriptsize\n\\begin{tcolorbox}[enhanced,drop shadow, title=Remarque]\nThis scheme is not incentive compatible\n\\end{tcolorbox}\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Schrijvers2017}\nO.~Schrijvers, J.~Bonneau, D.~Boneh, and T.~Roughgarden, ``Incentive\n  compatibility of bitcoin mining pool reward functions,'' in {\\em Financial\n  Cryptography and Data Security}, pp.~477--498, Springer Berlin Heidelberg,\n  2017.\n\n\\end{thebibliography}\n\\scriptsize\n\n\\begin{itemize}\n  \\item The duration of \\textit{rounds} is random \n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$] A \\textit{share} loses value when the \\textit{round} last for too long $\\Rightarrow$ \\textit{pool hoping} \\tiny\n    \\begin{thebibliography}{1}\n\n\\bibitem{rosenfeld2011analysis}\nM.~Rosenfeld, ``Analysis of bitcoin pooled mining reward systems,'' 2011.\n\n\\end{thebibliography}\n\\scriptsize\n    \\item[$\\hookrightarrow$] Apply a discount factor to \\textit{shares} \\tiny\n    \\begin{thebibliography}{1}\n\\bibitem{slush}\nslush pool, ``Reward system specifications,'' 2021.\n\\end{thebibliography}\n  \\end{itemize}\n  \\item A miner may postpone the communication of a solution\n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$] to wait for her proportion of submitted \\textit{shares} to improve \n  \\end{itemize} \n  \\item No risk transfer from miner to pool manager\n    \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$] $f$ must be small\n  \\end{itemize} \n\\end{itemize}\n\\end{frame}\n\\begin{frame}{The Pay-per-Share (PPS) system}\n\\scriptsize\nThe manager pays\n$$\nw = (1-f)\\cdot q \\cdot b \n$$ \nfor every \\textit{share} and keeps the block finding reward.\n\\vspace{1cm}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\nMiner's wealth\n$$\nR_t^i = u_i-ct + M_t^i w,\\text{ }t\\geq0.\n$$\nwhere \n\\begin{itemize}\n   \\item $(M_t^i)_{t\\geq0}$ is a Poisson process with intensity $p_i \\mu= p_i\\lambda / q$\n   \\item $\\mu$ is the average number of \\textit{shares} submitted by the network\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\nManager's wealth\n$$\nR_t^I = u_I - M_t^I w+N_t^I b,\\text{ }t\\geq0.\n$$\nwhere \n\\begin{itemize}\n   \\item $(M_t^I)_{t\\geq0}$ is a Poisson process with intensity $p_I\\mu =p_I\\lambda / q$\n   \\item $(N_t^I)_{t\\geq0}$ is a Poisson process with intensity $p_I\\lambda$\n\\end{itemize}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}{Pool manager's risk}\n\\scriptsize\nLet us consider randomized rewards\n$$\nR_t= u - \\sum_{i=1}^{M_t} W_i +\\sum_{j=1}^{N_t} B_j,\\text{ }t\\geq0.\n$$\nwhere\n\\begin{itemize}\n  \\item $(M_t)_{t\\geq0}$ and $(N_t)_{t\\geq0}$ are Poisson processes with intensity $\\mu^\\ast=\\mu- \\lambda$ and $\\lambda$\n  \\item $(W_i)_{i\\geq0}$ and $(B_j)_{j\\geq0}$ are two independent sequence of \\iid exponential random variables with mean $w$ and $b^\\ast = b-w$.\n\\end{itemize}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Poisson process superposition]\nA block discovery triggers the payment of a \\textit{share} to the miners\n\\begin{itemize}\n\\item The intensity of $M_t$ is given by $\\mu^\\ast=\\mu- \\lambda$ \n\\item The block finding reward is then $b^\\ast = b-w$ \n\\end{itemize}\nA distinction is made here between jumps up and down.\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Pool manager's risk}\n\\scriptsize\n\\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Profits and loss of a pool manager)]\nThe ruin probability is given by\n\\begin{equation*}\\label{psiexpe}\n    \\widehat{\\psi}(u,t) = (1-Rw)  e^{-R u},\\;u\\ge 0,\n\\end{equation*}\nand the expected wealth is\n\\begin{equation*}\\label{Vcombexpe}\n    \\w{V}(u,t) = (1 - Rw)[w-t(\\lambda b^\\ast-\\mu^\\ast w)] e^{-R u}+u+t(\\lambda b^\\ast-\\mu^\\ast w),\n\\end{equation*}\nwhere $R$ is the only solution to \n\\begin{equation*} \\label{VLunde}\n    -(t^{-1}+\\lambda+\\mu^\\ast)+\\lambda(1+b^\\ast r)^{-1}+\\mu^\\ast(1-wr)^{-1}=0,\n\\end{equation*}\nwith positive real part.\n\\end{tcolorbox}\n\\tiny\n  \\begin{thebibliography}{1}\n\n\\bibitem{albrecher2021blockchain}\nH.~Albrecher, D.~Finger, and P.-O. Goffard, ``Blockchain mining in pools:\n  Analyzing the trade-off between profitability and ruin,'' 2021.\n\n\n\\end{thebibliography}\n\\end{frame}\n\\begin{frame}[allowframebreaks]{Sketch of the proof}\n\\scriptsize\nConditionning upon the events that occur during $(0,h)$. Four possibilities\n\\begin{itemize}\n  \\item[(i)] $T>h$ and no jumps $(0,h)$\n  \\item[(ii)] $T<h$ and no jumps $(0,T)$\n  \\item[(iii)] an upward jump $(0,h)$\n  \\item[(iv)] a downward jump $(0,h)$\n\\end{itemize}\n  \\begin{eqnarray*}\\label{neu0}\n      \\w{V}(u,t)&=& e^{-(\\frac{1}{t}+\\lambda+\\mu^\\ast)h}\\w{V}(u,t) + \\frac{1}{t}\\int_0^h e^{-{s}/{t}}e^{-(\\lambda +\\mu^\\ast) s} u\\,ds\\\\\n      & +& \\lambda\\int_0^he^{-\\lambda s} e^{-({1}/{t}+\\mu^\\ast) s} \\int_0^\\infty\\w{V}(u+x,t)\\,dF_{B}(x)\\,ds\\\\\n      &  +&\\mu^\\ast \\int_0^he^{-\\mu^\\ast s} e^{-({1}/{t}+\\lambda) s}\\int_0^u \\w{V}(u-y,t) \\,dF_W(y)\\,ds.\n  \\end{eqnarray*}\n  Differentiating with respect to $h$ and letting $h\\rightarrow 0$, yields\n  \\begin{equation} \\label{inteq}\n    \\lambda\\int_0^\\infty\\w{V}(u+x,t)\\,dF_{B}(x)-(\\lambda+\\mu^\\ast+{1}/{t})\\w{V}(u,t)+\\mu^\\ast\\int_0^u \\w{V}(u-y,t) \\,dF_W(y)+{u}/{t}=0,\\quad u\\ge 0,\n  \\end{equation}\n  with boundary conditions $\\w{V}(u,t)=0$ pour tout $u<0$ et $0\\leq\\w{V}(u,t)\\leq u+(\\lambda b^\\ast - \\mu^\\ast w)t$. Consider solutions of the form\n  $$\n  Ce^{-ru}+d_1u+d_0\n  $$\n  \\begin{itemize}\n    \\item Gathering the terms in factor of $e^{-r u}$ yields an equation for $r$ with\n    $$\n    -(t^{-1}+\\lambda+\\mu^\\ast)+\\lambda(1+b^\\ast r)^{-1}+\\mu^\\ast(1-wr)^{-1}=0\n    $$\n    with nonnegative solution $R>0$, negative is impossible because $0\\leq\\w{V}(u,t)\\leq u+(\\lambda b^\\ast - \\mu^\\ast w)t$\n    \\item Gathering the terms in factor of $u$, yields $d_1 = 1$\n    \\item Gathering the terms in factor of $1$, yields\n    $$\n    d_0 = t(\\lambda b^\\ast-\\mu^\\ast w)\n    $$\n    \\item Gathering the terms in factor of $e^{-u/w}$, yields\n    $$\n    C = (1 - Rw)[w-t(\\lambda b^\\ast-\\mu^\\ast w)]\n    $$\n  \\end{itemize}\n\\end{frame}\n\\begin{frame}{Problem related to mining pools}\n\\begin{itemize}\n  \\item Arm race, ramping electricity consumption and e-waste generation\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{bertucci2020mean}\nC.~Bertucci, L.~Bertucci, J.-M. Lasry, and P.-L. Lions, ``Mean field game\n  approach to bitcoin mining,'' 2020.\n\n\\bibitem{Alsabah2018}\nH.~Alsabah and A.~Capponi, ``Bitcoin mining arms race: R{\\&}d with\n  spillovers,'' {\\em {SSRN} Electronic Journal}, 2018.\n\n\\end{thebibliography}\n\\end{itemize}\n\\begin{itemize}\n  \\item \\normalsize A threat on decentralization?\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Cong2020}\nL.~W. Cong, Z.~He, and J.~Li, ``Decentralized mining in centralized pools,''\n  {\\em The Review of Financial Studies}, vol.~34, pp.~1191--1235, apr 2020.\n\n\\bibitem{li2019mean}\nZ.~Li, A.~M. Reppen, and R.~Sircar, ``A mean field games model for\n  cryptocurrency mining,'' 2019.\n\\end{thebibliography}\n\\end{itemize}\n\\end{frame}\n% \\begin{frame}\n% \\cite{albrecher:hal-03336851,Hansjoerg2022}\n% \\bibliography{../../blockastics}\n% \\bibliographystyle{plainnat}\n% \\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "8063ba9db8121f8f78442f88bc91cb345b3b6ac6", "size": 30809, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/Seminar/seminar.tex", "max_stars_repo_name": "LaGauffre/BLOCKASTICS", "max_stars_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/Seminar/seminar.tex", "max_issues_repo_name": "LaGauffre/BLOCKASTICS", "max_issues_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/Seminar/seminar.tex", "max_forks_repo_name": "LaGauffre/BLOCKASTICS", "max_forks_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-21T08:20:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T08:20:38.000Z", "avg_line_length": 31.8603929679, "max_line_length": 254, "alphanum_fraction": 0.6873640819, "num_tokens": 11036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.41686222347051866}}
{"text": "\\documentclass[11pt]{article}\n\t\\usepackage[fleqn]{amsmath}\n\t\\usepackage{float}\n\t\\usepackage{caption}\n\t\\usepackage{graphicx}\n\t\\usepackage[margin=1in]{geometry}\n\t\\usepackage{color}\n\t\\title{Project 2 Report}\n\t\\author{Group 29: Feiyu Zheng(fz114) \\& Xueyang Chen(xc186)}\n\t\\date{\\today}\n\\begin{document}\n\t\\maketitle\n\t\\section*{1. How do we do feature extraction?}\n\t\tWe use each single pixel in the graph as a feature, and the name/key for each feature is its location. If it is a white space, we assign the value of this feature to 0, otherwise 1.\n\n\t\\section*{2. How do we implement each algorithm?}\n\t\t\\subsection*{Naive Bayes:}\n\t\t\t\\flushleft{}Since we need to use Bayes Rule equation to predict the probabilities of each outcome(label), we have to implement it in the coding. For Baye Rule, \\\\(\\textcolor{red}{a}) \\textcolor{blue}{probability of outcome(specific label) given a feature set of a sample} is equal to the product of (\\textcolor{red}{b}) \\textcolor{blue}{probability of outcome(specific label)} and (\\textcolor{red}{c}) \\textcolor{blue}{probability of this data given outcome is a specific label} divided by (\\textcolor{red}{d}) \\textcolor{blue}{the probability of the data}.\\\\\n\t\t\t\\flushleft{}Because we only need to know which outcome(label) has the greatest probability, we compare the value of each outcome(label) for the same data(sample). Since (\\textcolor{red}{d}) \\textcolor{blue}{the probabilities of the data} are always the same, we just need to compare the value of (\\textcolor{red}{b}) \\textcolor{blue}{probability of outcome(specific label)} times (\\textcolor{red}{c}) \\textcolor{blue}{probability of this data given outcome is a specific label}.\\\\\n\t\t\t\\flushleft{}Because multiplying many probabilities together often results in underflow, we will instead compute log probabilities.\\\\\n\t\t\t\n\t\t\t\\flushleft{}For (\\textcolor{red}{b}) \\textcolor{blue}{probability of outcome(specific label)}, we use the number of samples with specific label divided by total number of samples. Then, calculate its log value.\\\\\n\t\t\t\n\t\t\t\\flushleft{}For (\\textcolor{red}{c}) \\textcolor{blue}{probability of this data given outcome is a specific label}, it is the same as the product of (\\textcolor{red}{e}) \\textcolor{blue}{the probability of each feature given a specific outcome(label)}. We calculate each (\\textcolor{red}{e}) \\textcolor{blue}{probability of a single feature given a specific probability(label)}, and then multiply their log values.\\\\\n\t\t\t\n\t\t\t\\flushleft{}For (\\textcolor{red}{e}) \\textcolor{blue}{probability of a single feature given a specific probability(label)},  we count the total times a specific feature has value 0 with a specific label, and divided by the total number of samples with this specific label. Since we only have two possible values for each feature(0 and 1), if a specific feature has value 1, then we use 1 minus the probability we have above to get the answer. Lastly, we convert the value to log value.\\\\\n\t\t\t\n\t\t\t\\flushleft{}{}We sum all log values we get above to get our log probability of a specific label for a data. The label with greatest probability is our final prediction.\\\\\n\t\t\t\n\t\t\t\\flushleft{}When we do the training process, we use a smoothing parameter \\textcolor{blue}{k} to improve the accuracy of prediction. We have a set of 10 different \\textcolor{blue}{k} values, and each iteration runs with one k value. After 10 iterations, we assign \\textcolor{blue}{k} to the value with best accuracy.\n\t\t\n\t\t\\subsection*{Perceptron:}\n\t\t\t\\flushleft{}For all training data, we pick them one by one to do the following training process:\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item[(1)]For each training data, we have A features vectors and B labels. Then we initialize the weight as a BxA matrix which contains small values (0.5 in our project). Multiplying the weight matrix by the features vectors will yield a vector that contains a value corresponding to each label. Among these values, we choose the label with the largest value as our prediction\n\t\t\t\t\\item[(2)] We compare our prediction with the actual answer and take different actions depending on the comparison result.\\\\\n\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\\item[(a)] If the label we predict is right, then we don’t modify the weight and jump to the next picture.\n\t\t\t\t\t\\item[(b)] If the label we predict is not the same with the actual label,\n\t\t\t\t\t\\begin{itemize}\n\t\t\t\t\t\t\\item[(i)] we increase the weight value used for the real label if the current result for the real label is less than zero.\n\t\t\t\t\t\t\\item[(ii)] we decrease the weight value used for the prediction label if the current result for that label is greater than zero.\n\t\t\t\t\t\\end{itemize}\n\t\t\t\t\\end{itemize}\n\t\t\t\t\\item[(3)] We keep doing the above two steps until the algorithm reaches the iteration limits we predefined or there is no weight value change for all training data.\n\t\t\t\\end{itemize}\n\n\t\\section*{3. The learning curve for each case.}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Accuracy Digit (Naive Bayes).jpg}\n\t\t\t\\caption{Accuracy of Using Naive Bayes on Digit Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Accuracy Digit (Perceptron).jpg}\n\t\t\t\\caption{Accuracy of Using Perceptron on Digit Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Accuracy Face (Naive Bayes).jpg}\n\t\t\t\\caption{Accuracy of Using Naive Bayes on Face Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Accuracy Face (Perceptron).jpg}\n\t\t\t\\caption{Accuracy of Using Perceptron on Face Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\flushleft{}As above Figure 1-4 show, we can see that the accuracy goes up as we are using more and more training data and we can also see a trend that the amount of data needed to increase the accuracy is increasing as the accuracy keeps increasing. As we are getting higher and higher accuracy, it’s harder and harder to increase the accuracy by adding more training data.\n\t\t\\flushleft{}The following Figure 5-7 are the visualization of trained weight in the perceptron algorithm. With 100\\% training data, the algorithm can already classify some labels by some points and know the general shape of a type of images.\n\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.3]{Weight Visualization Digit 1.jpg}\n\t\t\t\\caption{Perceptron Weight Visualization of Digit 1}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.3]{Weight Visualization Digit 3.jpg}\n\t\t\t\\caption{Perceptron Weight Visualization of Digit 3}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.4]{Weight Visualization Face.jpg}\n\t\t\t\\caption{Perceptron Weight Visualization of Face}\\label{fig:1}\n\t\t\\end{figure}\n\n\t\\section*{4. Our observation on statistics.}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Digit Average Training Time.jpg}\n\t\t\t\\caption{Training Time of Perceptron and Naive Bayes When Using Digit Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.8]{Face Average Training Time.jpg}\n\t\t\t\\caption{Training Time of Perceptron and Naive Bayes When Using Face Data}\\label{fig:1}\n\t\t\\end{figure}\n\t\t\\flushleft{}Figure 8-9 show the time needed for training. We can see that as the number of training data gets larger and larger, the time needed for perceptron algorithms increases much faster than the naive bayes.\n\t\t\\flushleft{}In Figure 1-4, the gray lines show the standard deviation as the number of data points increases during training. We can see a general pattern that as the size of training data increases, the prediction error is getting smaller and smaller and for Naive Bayes, the prediction error is always 0 when using 100\\% training data.\n\n\n\t\\section*{5. What can be improved in the future if it does not work well or does not have a high accuracy}\n\t\t\\flushleft{}We can choose the better features which are more related to the result. For instance, the number of non-white space in a row or column, or the location of the farest gray space in each line.\n\t\t\n\t\t\n\\end{document}", "meta": {"hexsha": "8e8f47ee1d0145b7718de5361866a8f57bbaa1c8", "size": 8119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/Project 2.tex", "max_stars_repo_name": "ChaserZ98/Face-and-Digit-Classification", "max_stars_repo_head_hexsha": "99ada173eaf26d7a1066833201470a8b48151132", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX/Project 2.tex", "max_issues_repo_name": "ChaserZ98/Face-and-Digit-Classification", "max_issues_repo_head_hexsha": "99ada173eaf26d7a1066833201470a8b48151132", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX/Project 2.tex", "max_forks_repo_name": "ChaserZ98/Face-and-Digit-Classification", "max_forks_repo_head_hexsha": "99ada173eaf26d7a1066833201470a8b48151132", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.8785046729, "max_line_length": 562, "alphanum_fraction": 0.7512008868, "num_tokens": 2173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.416862215070342}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Wednesday\\\\ 2020-4-22, \\\\ compiled \\\\ \\today}\n\n% Last time we considered the spontaneous breaking of a \\emph{global} symmetry: we saw the appearance, corresponding to the breaking of the \\(U(1)\\) symmetry, of massless Goldstone bosons.\n% Each broken generator has a corresponding Goldstone boson.\n\n% We had a quadratic term in the Lagrangian, and a quartic term. \n\nWhat would \\(\\mu^2<0\\) physically mean? It would be a tachyonic particle.\n\nThe field \\(\\sigma (x)\\) is called the \\textbf{Higgs field}; the would-be Goldstone boson disappears yielding the longitudinal polarization of \\(A_{\\mu } (x)\\). \n% The Vacuum Expectation Value goes from 0 to \\(v\\): in this case we have broken the \\(U(1)\\) symmetry.\n\n% The imaginary part of the field \\(\\phi \\) corresponds to a massless scalar field.\n\n% Every time we have a certain global symmetry described by a group \\(G\\) with generators \\(t^{a}\\), which is broken to a subgroup \\(G'\\) (which can also be just the identity) with generators \\(t^{i}\\), we can identify the broken generators with Goldstone bosons.\n\n% We have the Dirac equation \\(\\qty(i \\slashed{\\partial} - m) \\psi =0\\), where \\(\\psi \\) has a global \\(U(1)\\) symmetry. \n% This can\\emph{not} be generalized to a local \\(U(1)\\) symmetry, unless we introduce a compensating gauge field.\n\n% Let us consider the Lagrangian from yesterday for the scalar field with a kinetic, quadratic and quartic term. Can we do \\(\\partial_{\\mu } \\to \\DD_{\\mu }\\) as we did with QED, to generalize the \\(U(1)\\) symmetry of \\(\\phi \\)?\n\n% We can do it and encounter no issues. \n\n% What if \\(\\mu^2<0\\)? The result is surprising: we do as before, perturbing around the vacuum \\(\\phi = v\\), writing \\(\\phi = v + \\sigma (x) + i \\eta (x)\\). \n% This is around pages 92--93 of the notes.\n\n% We start from \\(\\phi \\), which has 2 dof since it is a complex scalar, and \\(A_{\\mu }\\), which also has 2 dof since it is a massless vector. \n\n% We would expect to get the fields \\(\\sigma \\) and \\(\\eta \\): however, the field \\(\\eta \\) does not appear, it is ``eaten up'' by the vector field \\(A_{\\mu }\\).\n% We only find a massive real scalar \\(\\sigma (x)\\), which has 1 dof, and a massive vector boson \\(A_{\\mu }\\), which has 3 dof.\n\n% This is the \\emph{transmutation}, the scalar degree of freedom is absorbed to a degree of freedom in the vector field.\n\nWe are curing two different problems: we have found massive gauge bosons, and removed the unphysical Goldstone bosons.\n\n\\subsubsection{A more general formulation: \\(SU(2)\\) symmetry breaking}\n\nThis section follows Peskin pretty closely \\cite[sec.\\ 16.2]{peskinConceptsElementaryParticle2019}.\n\nWe can repeat this in the general case, with the group \\(G\\) being broken to \\(G'\\). Suppose, for clarity, that this is \\(SU(2)\\) being broken to \\(U(1)\\).\n\nThe three vectors \\(A^{a}_{\\mu }\\) generate rotations around the axes \\(x^{a}\\) respectively, as \\(a = 1, 2, 3\\). \n\nThe adjoint representation of \\(SU(2)\\) is given by three real scalar fields \\(\\phi^{a}\\); their covariant derivative is given by \n%\n\\begin{align}\n\\DD_{\\mu } \\phi^{a} \n= \\partial_{\\mu } \\phi^{a}\n+ g \\epsilon^{abc} A^{b}_{\\mu } \\phi^{c}\n\\,,\n\\end{align}\n%\nsince the representation matrices in the adjoint representation are \\((t^{b}_{G})_{ac} = i f^{abc}\\). \n\nWe want to choose a potential \\(V(\\phi )\\) which is minimized by a configuration with \\(\\expval{\\abs{\\phi^{a}}} = v\\). \nA vacuum for this potential is, for example, given by \\(\\phi^{a }= v \\delta^{a3}\\): it retains some rotational invariance (around the \\(\\hat{3}\\) axis), but invariance for rotations around the other two axis is broken. \n\nA perturbative expansion around such a vacuum will then be given by \n%\n\\begin{align}\n\\phi (x) = \\qty(\\pi^{1} (x), \\pi^{2}(x), v + h(x))\n\\,,\n\\end{align}\n%\nwhere \\(\\pi^{1, 2}\\) are the would-be goldstone bosons, which will contribute to the longitudinal components of \\(A^{1,2}_{\\mu }\\), the bosons which become massive. \n\nOn the other hand, \\(A^{3}_{\\mu } \\) remains massless. \nAs we go to the unitary gauge we can eliminate \\(\\pi^{1, 2}\\): so we get \n%\n\\begin{align}\n\\phi (x) = (0, 0, v + h(x))\n\\,.\n\\end{align}\n\nWe know that \n%\n\\begin{align}\n\\DD_{\\mu } \\phi^{a} \n&= \\partial_{\\mu } h \\delta^{3a} \n+ g \\epsilon^{abc} A^{b}_{\\mu } \\phi^{c}  \\\\\n&= \\partial_{\\mu } h \\delta^{3a}\n+ g \\epsilon^{ab3} A^{b}_{\\mu } (v + h(x))\n\\,.\n\\end{align}\n\nThe kinetic term of \\(\\phi^{a}\\) will then become: \n%\n\\begin{align}\n\\frac{1}{2} \\qty(\\DD_{\\mu } \\phi^{a})^2\n&= \\frac{1}{2} \\DD_{\\mu } \\left[\\begin{array}{ccc}\n0 & 0 & v+h\n\\end{array}\\right]\n\\DD^{\\mu } \\left[\\begin{array}{c}\n0 \\\\ \n0 \\\\ \nv+h\n\\end{array}\\right]  \\\\\n&= \\frac{1}{2} \\qty[\n    g \\epsilon^{ab3} A^{b}_{\\mu } (v+h) \n    + \\partial_{\\mu } h \\delta^{a3}\n]^2  \\marginnote{Square entails contraction of both \\(a\\) and \\(\\mu \\).}\\\\\n&= \\frac{g^2 v^2}{2} \\epsilon^{ab3} A^{b}_{\\mu } \\epsilon^{ad3} A^{d, \\mu } + \\mathcal{O}(h) \\\\\n&= \\frac{g^2 v^2}{2} \\qty(A^{1}_{\\mu } A^{\\mu 1} + A^{2}_{\\mu } A^{\\mu 2 } ) + \\mathcal{O}(h)\n\\,.\n\\end{align}\n\nSo, \\(A^{1, 2}\\) became massive, with mass \\(M_W^2 = g^2 v^2\\), while \\(A^{3}\\) remained massless.\n\nAs \\(SU(2)\\) is broken to \\(U(1)\\), the 3 generators \\(A_{\\mu }^{a}\\), with \\(a = 1, 2, 3\\) are broken to give two massive vector bosons (\\(W^{\\pm}\\)) and one massless vector boson (the photon), while the real field \\(\\sigma \\) is the Higgs field.\n\nThe two \\(W\\) bosons are not actually the components \\(A^{1, 2}\\): instead, we choose them to be the eigenvalues of rotations around the \\(z\\) axis: \n%\n\\begin{align}\nW^{\\pm}_{\\mu } = \\frac{1}{\\sqrt{2}} \\qty(A^{1}_{\\mu } \\mp i A^{2}_{\\mu }) \n\\,,\n\\end{align}\n%\nsince the rotation matrix around the \\(z\\) axis in the spin-1 representation is given by \n%\n\\begin{align}\nJ^{3} = \\left[\\begin{array}{ccc}\n0 & -i & 0 \\\\ \ni & 0 & 0 \\\\ \n0 & 0 & 0\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nwhose eigenvectors are indeed \\((1, \\mp i, 0)\\) with eigenvalues \\(\\pm 1\\). \n\nThis is called the \\textbf{Georgi-Glashow model}. It predicts two massive bosons of the \\(V-A\\) interaction. \nHowever, it does not work well phenomenologically. \n\n\\subsubsection{Hypercharge: why the GG model does not work}\n\nThis was a computationally easy example to clarify what this mechanism looks like, not the one we actually will use: we will have to choose another symmetry group.\n\nThe issue lies with the fact that we are associating electric charge with the generator of rotations about \\(\\hat{3}\\).\nWe know that an electron current can be turned into an electronic neutrino current, and that the neutrino is electrically neutral.\nThey must belong to the same isospin multiplet in order for this to happen.\nIsospin (\\(I\\)) is what we call rotation in the three-dimensional space the \\(SU(2)\\) symmetry was initially defined in. \nRotation about the \\(\\hat{3}\\) axis then corresponds to the operator \\(I_3\\); the algebra of these operators is that of a rotation representation, \\([I_i, I_j] = i \\epsilon_{ijk} I_k\\).\nWhen we say ``isospin multiplet'' we mean that the value of \\(I^2 = j (j+1)\\) is fixed; then the value of \\(I_3\\) will go from \\(-j\\) to \\(j\\).\n\nWe cannot have a doublet with only \\(\\nu \\) and \\(e^{-}\\) because of the fact that the neutrino is neutral: the eigenvalues of the rotation about the \\(3\\) axis would have to be \\(0\\) and \\(1\\).\nWe need a particle with eigenvalue \\(-1\\) with respect to rotations about the \\(\\hat{3}\\) axis, so with positive charge.\n\nWe then predict the existence of a heavy electron \\(E^{+}\\), such that the triplet looks like \n%\n\\begin{align}\n\\left[\\begin{array}{c}\nE^{+} \\\\ \n\\nu  \\\\ \ne^{-}\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nwhere the eigenvalues of this rotation around the \\(\\hat{3}\\) axis are \\(-1, 0, 1 \\) respectively.\nThis heavy electron was not observed; the experimental bound is at \\(M_{E^{+}}\\leq \\SI{400}{GeV}\\) currently. \nWe would expect to then see processes like \\(u + E^{+} \\to d + \\nu \\), but we do not.\n\n\\todo[inline]{Is the positron \\(e^{+}\\) not a candidate for this? Why do we say that this particle would need to be ``heavy''? Or are we already implicitly considering antiparticles maybe?}\n\nThis will be a way to unify electromagnetic and weak interactions, and we will get to use a single coupling constant for our new electroweak theory.\n\n\\subsection{Electroweak symmetry breaking}\n\nThe correct symmetry group for the electroweak theory, as Glashow showed in 1961, is \n%\n\\begin{align}\nSU(2)_{L} \\otimes U(1) _{\\text{hypercharge}}\n\\,,\n\\end{align}\n%\nwhere the hypercharge is usually denoted as \\(Y\\).\nWe have three vector fields for \\(SU(2)\\), which we call \\(A_{\\mu}^{i}\\), and also a vector field for \\(U(1)\\): \\(B_{\\mu }\\).\nNote that these do not have a direct correspondence with the fields we get after SSB: hypercharge is different from electromagnetic charge.\n\nThe pair neutrino-electron is a \\(I = 1/2\\) doublet under \\(SU(2) \\times U(1)\\), we will see that one component of this doublet has charge \\(+\\) while the other has charge 0: its transformation will look like \n%\n\\begin{align}\n\\left[\\begin{array}{c}\n\\nu_{L} \\\\ \ne^{-}_{L}\n\\end{array}\\right]\n\\to \n\\underbrace{e^{-i \\vec{\\alpha} \\cdot \\vec{\\sigma} / 2}}_{SU(2)}\n\\underbrace{e^{-i \\beta  /2 }}_{U(1)}\n\\left[\\begin{array}{c}\n\\nu_{L} \\\\ \ne^{-}_{L}\n\\end{array}\\right]\n\\,.\n\\end{align}\n\nThe bosons in this theory start off as massless, and therefore the fields \n%\n\\begin{align}\nW^{\\pm}_{\\mu } = \\frac{1}{\\sqrt{2}}  \\qty(A^{1}_{\\mu } \\mp i A^{2}_{\\mu })\n\\,\n\\end{align}\n%\nare massless as well. However, we want massive \\(W\\) bosons with \\(M_W \\sim \\SI{100}{Gev}\\)! \nAt the end of the sixties Weinberg and Salam introduced the Higgs mechanism in this theory. \nThe idea is to interpret the scalar field as a \\(I= 1/2\\) representation of rotation: it will transform under the symmetries of the theory as \n%\n\\begin{align}\n\\varphi =\n\\left[\\begin{array}{c}\n\\varphi^{+} \\\\ \n\\varphi^{0}\n\\end{array}\\right]\n\\to \ne^{i \\vec{\\alpha} \\cdot \\vec{\\sigma} /2}\ne^{i \\beta / 2}\n\\left[\\begin{array}{c}\n\\varphi^{+} \\\\ \n\\varphi^{0}\n\\end{array}\\right]\n\\,.\n\\end{align}\n\nSo, the lepton doublet has a charge \\(-1/2\\) with respect to the \\(U(1)\\) symmetry, while the field has a symmetry \\(+1/2\\). \n\nSuppose the potential of the field reads: \n%\n\\begin{align}\nV(\\phi ) = - \\mu^2 \\abs{\\phi }^2 + \\lambda \\abs{\\phi }^{4}\n\\,,\n\\end{align}\n%\nwhose minimum is defined by \n%\n\\begin{align}\n0= - 2 \\mu^2 \\phi + 4 \\lambda \\phi \\abs{\\phi }^2\n\\,,\n\\end{align}\n%\ntherefore the minimum is a sphere (since the two complex fields correspond to four real degrees of freedom) with \\(\\abs{\\phi }^2 =  \\abs{\\phi^{+}}^2 + \\abs{\\phi^{0}}^2 = \\mu^2 / 2 \\lambda \\); so we define \\(v = \\mu / \\sqrt{\\lambda }\\).\n\nUp to a rotation, the VEV of our field will be \n%\n\\begin{align}\n\\expval{\\phi }_{0} = \\frac{1}{\\sqrt{2}}\n\\left[\\begin{array}{c}\n0 \\\\ \nv\n\\end{array}\\right]\n\\,.\n\\end{align}\n\nThis vacuum breaks the \\(SU(2)_L \\times U(1)_{Y}\\) symmetry. \nWe can expand around it in the following manner: \n%\n\\begin{align}\n\\phi (x) \n= \n\\left[\\begin{array}{c}\n\\pi^{+}(x) \\\\ \n\\frac{v + h(x) + i \\pi^{3}(x)}{\\sqrt{2}}\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nwhere \\(\\pi^{+} = (\\pi^{1} + i\\pi^{2}) / \\sqrt{2}\\) is a complex perturbation encompassing two real degrees of freedom. \n\nAs we did before, we can gauge away the unphysical Goldstone bosons \\(\\pi^{1, 2, 3}\\); the real field \\(h(x)\\) remains. \n\nHow do the bosons of this theory \\textbf{couple to fermions}? The couplings can only have specific forms, fixed by gauge invariance: the covariant derivative will read: \n%\n\\begin{align}\n\\DD_{\\mu } \\Psi  = \n\\qty(\\partial_{\\mu } \n- i g A^{a}_{\\mu } I^{a} \n- i g' B_{\\mu } Y\n)\\Psi \n\\,,\n\\end{align}\n%\nwhere \\(g\\) and \\(g'\\) are the coupling of \\(SU(2)\\) weak isospin and \\(U(1)\\) hypercharge respectively; \\(I^{a}\\) are the generators of \\(SU(2)\\) in the \\(SU(2)\\) representation acting on \\(\\Psi \\), and \\(Y\\) is the hypercharge, a scalar. \n\nIn principle, \\(g\\) and \\(g'\\) are independent, so we keep them distinct. Let us now apply \\(\\DD_{\\mu } \\) to the field \\(\\phi \\) around the vacuum with only the \\(h \\) perturbation, as \n%\n\\begin{align}\n\\DD_{\\mu } \\phi = \\qty(\\partial_{\\mu } \n- i g A^{a}_{\\mu } I^{a} \n- i g' B_{\\mu } Y\n) \\left[\\begin{array}{c}\n0 \\\\ \n\\frac{v + h(x)}{\\sqrt{2}}\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nof which we take the square norm, up to zeroth order in \\(h\\): \n%\n\\begin{align}\n\\abs{\\DD_{\\mu } \\phi }^2\n&= \\frac{1}{2} \\left[\\begin{array}{cc}\n0 & v\n\\end{array}\\right]\n\\qty(g A^{a}_{\\mu } \\frac{\\sigma^{a}}{2} + g' B_{\\mu } \\frac{1}{2})\n\\qty(g A^{b, \\mu } \\frac{\\sigma^{b}}{2} + g' B^{\\mu } \\frac{1}{2})\n\\left[\\begin{array}{c}\n0 \\\\ \nv\n\\end{array}\\right] \\qty(+ \\mathcal{O}(h)) \\\\\n&= \\frac{1}{2} \\underbrace{ g^2v^2  \\frac{1}{4} \n\\qty(A^{1}_{\\mu } A^{1, \\mu } + A^{2}_{\\mu } A^{2, \\mu })}_{\\underbrace{(gv/2)^2}_{M_W^2} W^{+}_{\\mu } W^{\\mu, -}}\n+ \\frac{1}{2} \\frac{v^2}{4} \n\\qty(- g A^{3}_{\\mu } + g' B_{\\mu })^2\n\\,.\n\\end{align}\n\nSo, we have found two massive \\(W^{\\pm}\\) bosons, and the \\textbf{combination} \\(- g A^{3}_{\\mu } + g' B_{\\mu }\\) has also gained mass. \n\nLet us define \\(\\theta_{w}\\), the Weinberg angle, by \\(\\tan \\theta_{w} = g ' / g\\). \nThen we will have \n%\n\\begin{align}\n\\cos \\theta_{w} = \\frac{g}{\\sqrt{g^2 + g^{\\prime 2}}}\n\\qquad \\text{and} \\qquad\n\\sin \\theta_{w} = \\frac{g'}{\\sqrt{g^2 + g^{\\prime 2}}}\n\\,,\n\\end{align}\n%\nand we define the electromagnetic field \\(A_{\\mu }\\) and the \\(Z_{\\mu }\\) boson by the two orthogonal combinations: \n%\n\\begin{align}\nA_{\\mu } &= \\sin \\theta_{w} A^{3}_{\\mu } + \\cos \\theta_{w} B_\\mu \\\\\nZ_{\\mu } &= \\cos \\theta_{w} A^{3}_{\\mu } - \\sin \\theta_{w} B_\\mu  \n\\,,\n\\end{align}\n%\nso that the kinetic term reads \n%\n\\begin{align}\n\\frac{1}{2} \\frac{v^2}{4} \\qty(- g A^{3}_{\\mu } + g' B_{\\mu })^2 \n&= \\frac{m_Z^2}{2} Z^{\\mu }Z_{\\mu } \n\\,,\n\\end{align}\n%\nwhere \\(m_Z^2 = (g^2 + g^{\\prime 2}) v^2/ 4 \\), while there is no mass term for \\(A\\): so, \\(m_A = 0\\).\n\nThe residual gauge symmetry can be identified with \\(U(1)_{\\text{em}}\\).\nWhen the symmetry is broken, we are left with a long-range interaction and a short range one.\n\n% Do note that \\(U(1)\\)-hypercharge \\emph{is} broken.\n% However, a certain combination of the generators gives us the \\(U(1)\\) electromagnetic.\nThe combination under which the vacuum is invariant is \n%\n\\begin{align}\nT^{3} + Y\n\\,,\n\\end{align}\n%\nwhere \\(T^{3}\\) is the third generator of \\(SU(2)\\), while \\(Y\\) is the generator of hypercharge.\nThis corresponds to \n%\n\\begin{align}\n\\phi \\to e^{i \\vec{\\alpha} \\cdot \\vec{\\sigma} / 2} e^{i \\beta /2} \\phi \n\\,,\n\\end{align}\n%\nwith \\(\\alpha^{3} = \\beta \\): this is due to the fact that \n%\n\\begin{align}\n\\frac{1}{2} \\qty(\\sigma^{3} + \\mathbb{1}) =  \\left[\\begin{array}{cc}\n1 & 0 \\\\ \n0 & 0\n\\end{array}\\right]\n\\,,\n\\end{align}\n%\nwhose exponential leaves the second component of \\(\\phi = (0, v/\\sqrt{2})\\) invariant.\n\nIn summary, the SSB has the form \n%\n\\begin{align}\nSU(2)_L \\times U(1)_{Y} \\to U(1)_{\\text{em}}\n\\,,\n\\end{align}\n%\nand it yields the two \\(W^{\\pm}\\) bosons, each with mass \\(gv/2\\), and the \\(Z\\) boson with mass \\(\\sqrt{g^2+g^{\\prime 2}} v/2\\). \nThe masses of the \\(W\\) and \\(Z\\) bosons are related by: \n%\n\\begin{align}\nm_W = m_Z \\cos \\theta_{w}\n\\,,\n\\end{align}\n%\nso if we can devise some experiment which will measure \\(\\theta_{w}\\) we can predict \\(m_W / m_Z\\). \n\nThe full expression of the covariant derivative reads, using the notation \\(c_w = \\cos \\theta_{w}\\), \\(s_w = \\sin \\theta_{w}\\) and \\(\\sigma^{\\pm} = \\qty(\\sigma^{1} \\mp i \\sigma^{2}) / \\sqrt{2}\\):\n\\todo[inline]{not sure about the last one} \n%\n\\begin{align}\n\\DD_{\\mu } \\Psi &= \\qty[\n    \\partial_{\\mu } \n    -i \\frac{g}{\\sqrt{2}} \\qty(W^{+}_{\\mu } \\sigma^{+}+ W^{-}\\sigma^{-})\n    - ig \\qty(c_{w} Z_\\mu + s_{w}A_{\\mu }) I^{3}\n    - ig \\qty(- s_{w} Z_\\mu + c_{w} A_{\\mu }Y)\n] \\Psi  \\\\\n&= \\qty[\\partial_{\\mu } \n    - i \\frac{g}{\\sqrt{2}} \\qty(W^{+}_{\\mu } \\sigma^{+}+ W^{-}\\sigma^{-})\n    - i e A_{\\mu }Q \n    - i \\frac{g}{c_w} Z_\\mu Q_Z\n] \\Psi \n\\,,\n\\end{align}\n%\nwhere we defined \\(e = g s_w = g' c_w \\), and \n%\n\\begin{align}\nQ = I^{3} + Y \n\\qquad \\text{and} \\qquad\nQ_Z = I^{3} - s_w^2 Q\n\\,.\n\\end{align}\n\n\\todo[inline]{The next bit is not super clear.}\n\nIf the mass of the fermion described by \\(\\Psi \\) is zero we can decouple the left- and right-handed parts of the spinor. \nWe will get interactions between the left handed components, not between the right-handed components, since the \\(W^{\\pm}\\) do not couple with them.\n\\todo[inline]{How does that come about exactly?}\n\nWe recover the \\(V-A\\) structure: the left- and right-handed spinors have different quantum numbers with respect to \\(SU(2)_L\\) and \\(U(1)_Y\\) but the same \\(Q\\), which is the quantum number corresponding to \\(U(1)_{\\text{em}}\\). \n\nThe \\(\\psi_{L}\\) are \\(SU(2)_L\\) \\textbf{doublets}, with \\(I = 1/2\\); the \\(\\psi_{R}\\) are \\(SU(2)_L\\) \\textbf{singlets}, with \\(I = 0\\).\n\nWe then choose the values of the hypercharge such that the values of \\(Q\\) are compatible with experiment. \n\n\\begin{figure}[H]\n\\centering\n\\begin{tabular}{cccc}\nParticle & \\(I^{3}\\) & \\(Y\\) & \\(Q\\)\\\\\n\\hline\n\\(\\nu_{e, L}\\) & \\(+ 1 /2\\) & \\(- 1/2\\)& \\(0\\) \\\\\n\\(\\nu_{e, R}\\) & \\(0\\) & \\(0\\)& \\(0\\) \\\\\n\\(e^-_{L}\\) & \\(- 1 /2\\) & \\(- 1/2\\)& \\(-1\\) \\\\\n\\(e^-_{R}\\) & \\(0\\) & \\(-1\\)& \\(-1\\) \\\\\n\\(u^-_{L}\\) & \\(+ 1 /2\\) & \\(1/6\\)& \\(2/3\\) \\\\\n\\(u^-_{R}\\) & \\(0\\) & \\(2/3\\)& \\(2/3\\) \\\\\n\\(d^-_{L}\\) & \\(-1 /2\\) & \\(1/6\\)& \\(-1/3\\) \\\\\n\\(d^-_{R}\\) & \\(0\\) & \\(-1/3\\)& \\(-1/3\\) \\\\\n\\end{tabular}\n\\label{tab:fermions-quantum-numbers}\n\\caption{Electroweak quantum numbers of the fermions.}\n\\end{figure}\n\n% A combination which is broken is \n% %\n% \\begin{align}\n% Q_{z} = T^{3} - \\sin^2 (\\theta_{w}) Q\n% \\,,\n% \\end{align}\n% %\n% where \\(\\theta_{w}\\) is the Weak, or Wonder angle, defined by \n% %\n% \\begin{align}\n% \\tan(\\theta_{w}) = \\frac{g'}{g}\n% \\,,\n% \\end{align}\n% %\n% where \\(g'\\) and \\(g\\) are the coupling constants relative to \\(U(1)\\) and \\(SU(2)\\) respectively.\n\n% The model is called the Glashow-Weinberg-Salam model. This is the Standard Model of the electroweak interaction.\n\n% How is this unification since we have two coupling constants? The constants are not the coupling constants of weak and electromagnetic interaction. The photon is given by\n% %\n% \\begin{align}\n% A_{\\mu } = \\sin(\\theta_{w}) A^{3}_{\\mu } + \\cos(\\theta_{w}) B_{\\mu }\n% \\,,\n% \\end{align}\n% %\n% while the orthogonal combination is \n% %\n% \\begin{align}\n% Z^{0}_{\\mu } = \\cos(\\theta_{w}) A^{3}_{\\mu } - \\sin(\\theta_{w}) B_{\\mu }\n% \\,,\n% \\end{align}\n% %\n% so we cannot decouple the weak and electromagnetic bosons.\n% This is why the symmetry is called the electroweak symmetry.\n\nIn terms of \\(SU(2)_L\\) multiplets, we separate: \n%\n\\begin{align}\n\\left[\\begin{array}{c}\n\\nu_{L} \\\\ \ne^{-}_{L}\n\\end{array}\\right]\n&&\ne^{-}_{R}\n&& \n\\left[\\begin{array}{c}\nu_L \\\\ \nd_L\n\\end{array}\\right]\n&&\nu_R\n&&\nd_R\n\\,.\n\\end{align}\n\nThis is a \\textbf{generation} (or family) of fermions: the ``electronic'' one, and we have two more: the muonic and tauonic ones.\n\n\\todo[inline]{Is this next bit useful?}\nIf \\(\\mu^2\\) is a function of \\(T\\), then we can get a phase transition.\nThis is called the electroweak phase transition.\n\n\\end{document}\n", "meta": {"hexsha": "1173c8c90df302fb118d6b5dd3c16bd1b288d61b", "size": 19030, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/astroparticle_physics/apr22.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/astroparticle_physics/apr22.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/astroparticle_physics/apr22.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 36.7374517375, "max_line_length": 263, "alphanum_fraction": 0.6322122964, "num_tokens": 6610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.41686221427155623}}
{"text": "\\section{Background}\n\n\n\\subsection{Basic Failure Model in Reliability Study}\n\nIn reliability study, the time when the first failure occurs in often assumed \nto follow a probability density function (pdf) if time is a continuous value, or \na probability mass function (pmf) if time is a discrete value. \\citep{MusaBook} \n \nThe value of time is a continuous value if its unit is a {\\it time unit} (e.g. \nsecond) and the value could be any real number.  The value of time is \na discrete value if its unit is a {\\it natural unit} (e.g. number of \noperations) or its unit is a {\\it time unit} but the user only cares the \nstatus of a system at discrete time (e.g. every second).\n\nAlthough the precise definition of failure varies in different systems, \nmeasures of failures can be consistently defined in terms of a pdf or a\npmf.  Assuming that the pdf of a system is $f(t)$, measures of failures can be \ndefined as in Figure \\ref{eq:measure_of_failures} \n\\citep{MusaBook}.  Measures of failures can be defined in terms of pmf \nsimilarly.\n\n\\begin{figure}\n\\begin{subequations} \n\\begin{align}\n    R(t) & = \\int_{t}^{\\infty} f(x) dx = 1- \\int_{0}^{t} f(x) dx  \\label{subeq1}\\\\\n   MTTF & = \\int_{0}^{\\infty} tf(t)dt  = \\int_{0}^{\\infty} R(t)dt \n\\label{mttf}\\\\\n   h(t) & = \\lim_{\\Delta t\\rightarrow 0} \\frac{R(t)-R(t+\\Delta t)}{\\Delta t \nR(t)}  = \\frac{f(t)}{R(t)}\n\\end{align}\n\\end{subequations}\n\\caption{Measures of Failures}\n\\label{eq:measure_of_failures}\n\\end{figure}\n\nIn the above, the reliability during a specific time, $R(t)$, is the \nprobability that a system can survive without failure throughout that time.  \nThe Mean Time to Failure (MTTF) is the average time when the first failure \noccurs.  The hazard rate at time $t$ is the failure rate at that time given \nthe condition that the system has survived for $t$ time.  Equation \n\\ref{failure_check} checks that the average failure rate ($\\lambda$) is the \nreciprocal of MTTF.\n\n\\begin{equation}\n \\lambda = \\int_{0}^{\\infty} h(t) dt = \\int_{0}^{\\infty} \\frac{f(t)}{R(t)}  dt \n=  \\frac{\\int_{0}^{\\infty} f(t) dt}{\\int_{0}^{\\infty} R(t) dt} = \\frac{1}{MTTF}\n\\label{failure_check}\n\\end{equation}\n\n\n\n\n\\subsection{Traditional Software Rejuvenation Models}\n\n\\subsubsection{The Basic Model}\n\n\nThe basic software rejuvenation model proposed by\n\\citep{huang1995software} is modelled by the state transition diagram in \nFigure \\ref{fig:model_classic_1}.  Huang et. al defines the following 4 states:\n\n\\begin{description}\n  \\item[S] The robust {\\tt start} state in which the system will not fail.\n  \\item[W] The failure probable {\\tt working} state in which the system may \nfail at a certain probability.\n  \\item[F] The {\\tt failure} state when the system reaches its boundary condition.\n  \\item[R] The {\\tt rejuvenation} state when the system is plan to \nrestart to a clean state.\n\\end{description}\n\n\\citep{huang1995software} decides the rejuvenation thresholds using the \nfollowing process.  \n\n\\begin{enumerate}\n  \\item compute the probabilistic {\\it mean} rates of every state transitions \nsomehow.\n  \\item calculate the probability of the system being in each state, based on \nthe state transition rates computed above.\n  \\item calculate the {\\it expected} total time of the system in state $s$ \nduring an interval of $L$ time units as $T_s(L) = p_s \\times L$, where $p_s$ is \nthe probability the system being in state $s$ calculated in the second step.\n  \\item calculate the cost of downtime during interval $L$ as $Cost(L) = (p_f \n\\times c_f + p_r \\times c_r) \\times L$, where $p_f$ and $p_r$ are probabilities \nthe system in state $F$ and $R$ respectively, and $c_f$ and $c_r$ are unit cost \nof the system in state $F$ and $R$ respectively.\n  \\item determine the optimal rejuvenation thresholds by finding the optimal \ntransition rate between state $W$ to state $F$ so that the cost of downtime is \nminimum.\n\\end{enumerate} \n\nThe original software rejuvenation model, proposed by \n\\citet{huang1995software}, has shown its significance in long running billing \nsystems, scientific applications, and telecommunication systems \n\\citep{huang1995software}. Readers may have noticed that the above estimation \nmethodology gives an approximate statistical estimation for a long running \nsystem because the usage of {\\it mean} state transition rates and the {\\it \nexpected} time of being in each state.  By {\\it long running system}, we refer \nto a system whose expected in-service time is a statistically long time regards \nto its MTTF, repair time, and rejuvenation time.\n\n\n\\begin{figure}\n  \\centering         \n        \\subfigure[Traditional Model 1]{\n            \\label{fig:model_classic_1}\n            \\includegraphics[scale=0.5]{model_1.png}\n        }\\\\\n        \\subfigure[Traditional Model 2]{\n            \\label{fig:model_classic_2}\n            \\includegraphics[scale=0.5]{model_2.png}\n        }\\\\\n    \\caption{Traditional Software Rejuvenation Models}\n   \\label{fig:model_traditional}\n\\end{figure}\n\n\\subsubsection{A Modified Model}\n\n\\citet{dohi2000statistical} modifies the original model given \nby \\citet{huang1995software} with the following modifications:\n\n\\begin{enumerate}\n  \\item As shown in Figure \\ref{fig:model_classic_2}, the completion of repair process\n  is immediately followed by the software rejuvenation process.\n  \\item Assuming that every state transition is a stochastic processes.  For each state $S$, define a \n  probability density function $F_s(t)$, which represents the probability that the system will stay in that\n  state for time $t$. \n\\end{enumerate} \n\nThe first modification is made to distinguish the process of system cleanup and process resuming\nfrom other repair tasks, the former of which is required in both the repair process and the rejuvenation\nprocess in practice.  The second assumption is made so that the model is a Semi-Markov process,\na well studied stochastic process with off-the-shelf analysis techniques.  Although \\citet{huang1995software}\ndo not mention the relationship between their model and Markov process, \\citet{dohi2000statistical}\nshow that if the modified model gives the same analysis result as the one\ngiven in \\citet{huang1995software} if (i) remove assumption 1; and (ii) assume \nthat the sojourn times in all states are exponentially distributed.\n\n\\citet{dohi2000statistical} decides the optimal software rejuvenation thresholds by looking for\nthe one that maximise the system availability, the ratio of uptime and total time.  Same as the\nmethodology in \\citet{huang1995software}, instead of precisely describe state transition \nprobabilities, $mean$ time of staying in the {\\tt start} state, the {\\tt failure} state, and the\n{\\tt rejuvenation} state is used.  The expected time of staying the failure probable {\\tt working} state\nis calculated by equation \\ref{mttf}.\n\nThe methodology given in \\citet{dohi2000statistical}  does not give a general cost\nanalysis as the one in \\citet{huang1995software}.  It also suffers the problem of using\n$mean$ times.  Despite those two limitations, \\citet{dohi2000statistical} \nderived a non-parametric statistical algorithms to estimate the optimal \nsoftware rejuvenation thresholds that maximise the system availability, based \non statistical complete sample data of failure times.\n\n\n\n\\begin{comment}\nThe basic assumption of software rejuvenation is that software systems will \nbecome failure-probable after a period of execution.  In other words, failure \nrate is a function about the execution time t.  In contrast, the probabilistic \nstate transition model \n\\url{\nhttp://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.176.2557&rep=rep1&type=\npdf} (FTCS 1995, citation: 711) employs the statistical mean rate of the \ntransition rate between states.  \n\n   The same model is used in the book \n\\url{http://onlinelibrary.wiley.com/doi/10.1002/9780470050118.ecse394/full} \n(published in 2007)\n\n   The same problem appears in the model used in \n\\url{http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=897287} (HASE 2000, \ncitation: 60) and \n\\url{http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=895436} (PRDC 2000, \ncitation: 90), which extends the original model to be a semi-Markov process, \nwhere time is a continuous value.\n      \n\nModels that use the statistical mean rate can only be used to estimate the \nexpected average behaviors (e.g. downtime) over a statistically long time.  A \nmore serious problem is that, treating failure rate as a constant in model \nanalysis violates the basic assumption of software rejuvenation.  After all, if \nthe failure rate is independent of the execution time, restarting the system \nwill not help at all but increase the downtime.\n\nThe link ( http://srejuv.ee.duke.edu/papers.htm ) gives a list of papers (until \n2010) on software rejuvenation.  I am surprised that the classic general failure \nmodel used in reliability analysis has not been applied to the model analysis of \nsoftware rejuvenation.\n\\end{comment}\n", "meta": {"hexsha": "b5a3351698c7b0432b16f0f0e38b99fee4364699", "size": 8916, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "s1024484/Paper/Rejuvenation/classicmodels.tex", "max_stars_repo_name": "Jiansen/TAkka", "max_stars_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-09-11T14:35:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T06:36:09.000Z", "max_issues_repo_path": "s1024484/Paper/Rejuvenation/classicmodels.tex", "max_issues_repo_name": "Jiansen/TAkka", "max_issues_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "s1024484/Paper/Rejuvenation/classicmodels.tex", "max_forks_repo_name": "Jiansen/TAkka", "max_forks_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.1746031746, "max_line_length": 109, "alphanum_fraction": 0.7562808434, "num_tokens": 2336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4168622100714679}}
{"text": "\r\n\r\n\\input{\"/Users/brandonwilliams/Documents/LaTeX Includes/hwpreamble.tex\"}\r\n\\input{\"/Users/brandonwilliams/Documents/LaTeX Includes/extrapackages.tex\"}\r\n\\input{\"/Users/brandonwilliams/Documents/LaTeX Includes/extracommands.tex\"}\r\n\r\n\r\n\\begin{document}\r\n\r\n\r\n\\title{\\Large Classifying Spaces and Representability Theorems}\r\n\\author{\\large Brandon Williams}\r\n\r\n\\maketitle\r\n\r\n\r\n\r\nWe will use the following notation for some common categories:\r\n\\begin{enumerate}\r\n  \\item[$\\CW$] - The category of CW-complexes and continuous functions\r\n  \\item[$\\hCW$] - The category of CW-complexes and homotopy classes of continuous functions\r\n  \\item[$\\hCWp$] - The category of based CW-complexes and based homotopy classes of base point preserving continuous functions\r\n  \\item[$\\Set$] - The category of sets and functions\r\n  \\item[$\\Setp$] - The category of based sets and base point preserving functions\r\n\\end{enumerate}\r\n\r\n\r\n\\section{The Brown Representability Theorem}\r\n\r\nA contravariant functor $F : \\mathscr C \\rightarrow \\Set$ is said to be representable if there exists an object $X$ in $\\mathscr C$ (called a classifying object) and a natural isomorphism\r\n\\[ \\eta : \\hom_{\\mathscr C} (-, X) \\longrightarrow F \\]\r\nExamples:\r\n\\begin{enumerate}\r\n  \\item Clearly $\\hom(-,X)$ is a representable functor on any category $\\mathscr C$.\r\n  \\item Singular cohomology $H^n(-;G)$ on $\\hCW$ is representable since\r\n  \\[ H^n(X;G) \\cong [X,K(G,n)] \\]\r\n  where $K(G,n)$ is the $n$-th Eilenberg-MacLane space of $G$. \r\n  \\item For a topological group $G$ let us define a functor $k_G : \\hCWp \\rightarrow \\Setp$ by\r\n  \\[ k_G(X) = \\lcb \\text{isomorphism classes of principal $G$-bundles over $X$} \\rcb \\]\r\n  For a morphism $X \\stackrel{[f]}{\\longrightarrow} Y$ the induced morphism $k_G([f]) : k_G(Y) \\rightarrow k_G(X)$ is given by\r\n  \\[ k_G([f])(\\xi) = f^* \\xi \\]\r\n  As we will discuss later, it turns out that there is a space $BG$ such that\r\n  \\[ k_G(-) \\simeq [-,(BG,*)] \\]\r\n\\end{enumerate}\r\nWhen $\\mathscr C = \\hCWp$ we have necessary and sufficient conditions for a contravariant functor $F : \\hCWp \\rightarrow \\Setp$ to be representable. This is the content of the Brown Representability Theorem. Before stating the theorem, we define two properties the functor $F$ might have. \r\n\r\nLet $\\lcb X_\\alpha \\rcb$ be a collection of spaces, and let $i_\\beta : X_\\beta \\rightarrow \\vee_\\alpha X_\\alpha$ be the natural inclusions (recall that the coproduct in $\\hCWp$ is the wedge construction, so these are the maps provided by the coproduct). We say that $F$ satisfies the wedge axiom if for any collection of spaces $\\lcb X_\\alpha \\rcb$, the map $i : F(\\vee_\\alpha X_\\alpha) \\rightarrow \\prod_\\alpha F(X_\\alpha)$ induced by the maps $F(i_\\beta) : F(\\vee_\\alpha X_\\alpha) \\rightarrow F(X_\\beta)$ is bijective.\r\n\r\nNow let $(X;A,B)$ be a CW-triad, i.e. $A$ and $B$ are subcomplexes such that $X = A \\cup B$. Let $j_A,j_B$ denote the inclusions of $A \\cap B$ into the respective spaces, and let $i_A,i_B$ denote the inclusions of the respective spaces into $X$. Then we say that $F$ satisfies the Mayer-Vietoris axiom if for any CW-triad $(X;A,B)$ and for any $x \\in F(A),y \\in F(B)$ such that\r\n\\[ F(j_A)(x) = F(j_B)(y) \\in F(A \\cap B) \\]\r\nthere exists an element $z \\in F(X)$ such that\r\n\\[ F(i_A)(z) = x \\ \\ \\ \\ \\ F(i_B)(z) = y \\]\r\nNotice that it is exactly this property that would allow us to conclude that $\\image \\subset \\ker$ in the middle group of the Mayer-Vietoris sequence:\r\n\\[ \\cdots \\longleftarrow H^k(A \\cap B) \\longleftarrow H^k(A) \\oplus H^k(B) \\longleftarrow H^k(X) \\longleftarrow \\cdots \\]\r\n\r\nWe can now state the Brown Representability Theorem:\r\n\\begin{lem}[Brown]\r\nA contravariant functor $F : \\hCWp \\rightarrow \\Setp$ is representable if and only if $F$ satisfies the wedge axiom and the Mayer-Vietoris axiom.\r\n\\end{lem}\r\n\r\nThe idea of the proof is to construct a CW-complex $(Y,y_0)$ and element $u \\in F(Y)$ such that the natural transformation\r\n\\[ T_u : [ - , (Y,y_0)] \\longrightarrow F(-) \\]\r\n\\[ T_u(X)([f]) = F([f])(u) \\]\r\nis actually an equivalence. The necessity of F to satisfiy the wedge and Mayer-Vietoris axioms is easy enough to prove. First we recall some basic constructions. For based spaces $(X,x_0),(Y,y_0)$ the smash product is defined to be\r\n\\[ X \\wedge Y = \\frac{X \\times Y}{X \\vee Y} = \\frac{X \\times Y}{\\lcb x_0 \\rcb \\times Y \\cup X \\times \\lcb y_0 \\rcb} \\]\r\nThis is a based space by taking the base point to be the image of $X \\vee Y$ under the quotient map. For an unbased space $X$ let $X^+$ denote $X$ union a disjoint point, which is then considered to be the base point of $X^+$. This seems to be a nice candidate for the product in the category of based spaces, but is not the product; the regular topological product is still the categorical product. However, the smash product is very useful due to the adjoint relation\r\n\\begin{equation}\r\n\\label{smashmapadjoint}\r\n[(X \\wedge Y,*),(Z,z_0)] \\cong [(X,x_0), (Y,y_0)^{(Z,z_0)}] \r\n\\end{equation}\r\nIt is easy to see that $X \\wedge I^+ \\simeq (X \\times I) / (\\lcb x_0 \\rcb \\times I)$, so we see that a based homopty $H : X \\times I \\rightarrow Y$ between maps $X \\rightarrow Y$ descends to a map $H : X \\wedge I^+ \\rightarrow Y$. Conversely, any based map $H : X \\wedge I^+ \\rightarrow Y$ is also a based homotopy when considered as a map $H : X \\times I \\rightarrow Y$.\r\n\r\n\\begin{lem}\r\nThe functor $[-,(Y,y_0)]$ satisfies the wedge axiom and the Mayer-Vietoris axiom.\r\n\\end{lem}\r\n\\begin{proof}\r\n\\sloppyspace\r\n\\begin{enumerate}\r\n\r\n  \\item[W.)] The maps $i_\\beta^* : [\\vee_\\alpha X_\\alpha] \\rightarrow [X_\\alpha,Y]$ induce a map $i : [\\vee_\\alpha X_\\alpha] \\rightarrow \\prod_\\alpha [X_\\alpha,Y]$ as noted before. Let $\\lcb [f_\\alpha] \\rcb \\in \\prod_\\alpha [X_\\alpha,Y]$, then we can fit the $f_\\alpha$'s together to form a map $f : \\vee_\\alpha X_\\alpha \\rightarrow Y$ such that $f \\circ i_\\alpha = f_\\alpha$. If we change an $f_\\alpha$ by a homotopy, then $f$ also changes by a homotopy, hence we have $i([f]) = \\lcb [f_\\alpha] \\rcb$, and so $i$ is surjective.\r\n  \r\n  Suppose $[f],[g] \\in [\\vee_\\alpha X_\\alpha,Y]$ such that $i([f]) = i([g])$. If we define $f_\\alpha = f \\circ i_\\alpha$ and $g_\\alpha = g \\circ i_\\alpha$, then we have $f_\\alpha \\simeq g_\\alpha$, so let $H^\\alpha : X_\\alpha \\wedge I^+ \\rightarrow Y$ be the homotopies. These fit together to give us a map $H : \\vee_\\alpha (X_\\alpha \\wedge I^+) \\rightarrow Y$ such that $H|_{X_\\alpha \\times 0} = f_\\alpha$ and $H|_{X_\\alpha \\times 1} = g_\\alpha$. But, since $\\vee_\\alpha (X_\\alpha \\wedge I^+) \\cong (\\vee_\\alpha X_\\alpha) \\wedge I^+$, we have that $H$ is a map $(\\vee_\\alpha X_\\alpha) \\times I^+ \\rightarrow Y$ such that $H_0 = f$ and $H_1 = g$, hence $[f] = [g]$, and so $i$ is injective.\r\n  \r\n  \\item[MV.)] Let $(X;A,B)$ be a CW-triad, and let $[f] \\in [(A,x_0),(Y,y_0)]$ and $[g] \\in [(B,x_0),(Y,y_0)]$ such that $f|_{A \\cap B} \\simeq g|_{A \\cap B}$. Let $\\widetilde{H} : (A \\cap B) \\wedge I^+ \\rightarrow Y$ be a homotopy between $f$ and $g$. Since $A \\cap B \\hookrightarrow A$ is a cofibration we can extend this homotopy to $H : A \\wedge I^+ \\rightarrow Y$ such that $H_0 = f$. Let $\\widetilde{f} = H_1$, then we see that $[f]=[\\widetilde{f}] \\in [(A,a_0),(Y,y_0)]$, but now $\\widetilde{f}|_{A \\cap B} = g|_{A \\cap B}$ (not just homotopic, but equal). Now we can easily extend this to a map $h : (X,x_0) \\rightarrow (Y,y_0)$ such that $h|_A = \\widetilde{f}$ and $h|_B = g$, and this verifies MV.\r\n\\end{enumerate}\r\n\\end{proof}\r\n\r\n\r\n\r\nWe will say that an element $u \\in F(Y)$ is $n$-universal if $T_u(S^q) : [(S^q,*),(Y,y_0)] \\rightarrow F(S^q)$ is an isomorphism for $q<n$ and an epimorphism for $q=n$ (recall that $T_u$ is the natural transformation defined earlier). This element is called universal if it is $n$-universal for all $n$.\r\n\r\n\r\n\\begin{thm}\r\n\\label{mapping-of-universal-elements}\r\nIf $f : (X,x_0) \\rightarrow (Y,y_0)$ is a morphism in $\\CWp$, and $u \\in F(X),v \\in F(Y)$ are universal elements such that $F(f)(v) = u$, then\r\n\\[ f_* : \\pi_*(X,x_0) \\longrightarrow \\pi_*(Y,y_0) \\]\r\nis an isomorphism.\r\n\\end{thm}\r\n\\begin{proof}\r\nWe have the following commutative diagram:\r\n\\[\r\n\\xymatrix\r\n{\r\n\\pi_q(X,x_0) = [(S^q,*),(X,x_0)] \\ar[rr]^{f_*} \\ar[rd]_{T_u(S^q)} & & [(S^q,*),(Y,y_0)] = \\pi_q(Y,y_0) \\ar[ld]^{T_v(S^q)} \\\\\r\n& F(S^q) \r\n}\r\n\\]\r\nTo see this let $[g] \\in [(S^q,*),(X,x_0)]$, then $f_*([g]) = [f \\circ g]$ and \r\n\\[ T_v(S^q)(f \\circ g) = F(f \\circ g)(v) = F(g) \\circ F(f) (v) = F(g)(u) = T_u(S^q)(g) \\]\r\nBy assumption we have $T_u(S^q)$ and $T_v(S^q)$ are bijective, so we must have that $f_*$ is bijective, hence it is an isomorphism.\r\n\\end{proof}\r\n\r\n\r\nMost of the steps of the proof of the Brown Representability Theorem come from trying to construct universal elements, and the proofs of the lemmas that lead to such a construction are very similar to the proof of the Whitehead's theorem. We only state this theorem for now:\r\n\r\n\\begin{lem}\r\nFor any contravariant functor $F : \\hCWp \\rightarrow \\Setp$ there exists a CW-complex $(Y,y_0)$ and universal element $u \\in F(Y)$. In fact, with a choice of $(Y,y_0)$ and universal $u \\in F(Y)$, the natural transformation $T_u : [-,(Y,y_0)] \\rightarrow F$ is an equivalence.\r\n\\end{lem}\r\n\r\nThe following lemma is useful for when trying to make the construction of classifying spaces into a functorial construction.\r\n\r\n\\begin{lem}\r\n\\label{inducedmapclassifyingspaces}\r\nLet $F,F' : \\hCWp \\rightarrow \\Setp$ be two contravariant functors with classifying spaces $(Y,y_0),(Y',y'_0)$ and universal elements $u,u'$ respectively. If $T : F \\rightarrow F'$ is a natural transformation, then there is a map $f : (Y,y_0) \\rightarrow (Y',y'_0)$, unique up to homotopy, such that the diagram\r\n\\[\r\n\\xymatrix\r\n{\r\n  [(X,x_0),(Y,y_0)] \\ar[r]^{f_*} \\ar[d]_{T_u(X)} & [(X,x_0),(Y',y'_0)] \\ar[d]^{T_{u'}(X)} \\\\\r\n  F(X) \\ar[r]_{T(X)} & F'(X)\r\n}\r\n\\]\r\ncommutes for all $(X,x_0) \\in \\hCWp$.\r\n\\end{lem}\r\n\r\n\\begin{cor}\r\nThe classifying space of $F$ is unique up to homotopy equivalence.\r\n\\end{cor}\r\n\\begin{proof}\r\nSuppose $F$ has two classifying spaces $(Y,y_0)$ and $(Y',y'_0)$ with universal elements $u,u'$ respectively. If we let $T : F \\rightarrow F$ be the identity natural transformation, then \\ref{inducedmapclassifyingspaces} gives us a map $f : (Y,y_0) \\rightarrow (Y',y'_0)$ and commutative diagram (with $X = S^q$):\r\n\\[\r\n\\xymatrix\r\n{\r\n  \\pi_q(Y,y_0) = [(S^q,*),(Y,y_0)] \\ar[r]^{f_*} \\ar[d]_{T_u(S^q)} & [(S^q,*),(Y',y'_0)] = \\pi_q(Y',y'_0) \\ar[d]^{T_{u'}(S^q)} \\\\\r\n  F(S^q) \\ar[r]_{T(S^q)=\\id_{F(S^q)}} & F(S^q)\r\n}\r\n\\]\r\nSince $T_u(S^q)$ and $T_{u'}(S^q)$ are bijective (by the universality of $u$ and $u'$), we see that $f_*$ must be bijective, and hence an isomorphism. By Whitehead's theorem we have that $f$ is a homotopy equivalence.\r\n\\end{proof}\r\n\r\n\r\n\\section{Universal Bundles}\r\n\r\n\r\nWe now want to apply these ideas to the theory of vector bundles. Before we can do this we recall some basic facts from the theory of fiber bundles. Let $\\xi : F \\rightarrow E \\stackrel{\\pi}{\\rightarrow} B$ be a fiber bundle with structural group $G \\subset \\Diff(F)$. Then we have an atlas $U_\\alpha \\subset B$, $\\varphi_\\alpha : U_\\alpha \\times F \\stackrel{\\sim}{\\longrightarrow} \\pi^{-1}(U_\\alpha)$. This atlas determines transition functions:\r\n\\[ g_{\\alpha\\beta} : U_\\alpha \\cap U_\\beta \\rightarrow G \\]\r\nsuch that\r\n\\[ \\psi_{\\alpha\\beta} := \\varphi_\\beta^{-1} \\circ \\varphi_\\alpha : (U_\\alpha \\cap U_\\beta) \\times F \\rightarrow (U_\\alpha \\cap U_\\beta) \\times F \\]\r\n\\[ \\psi_{\\alpha\\beta}(p,v) = (p, g_{\\alpha\\beta}(p)(v)) \\]\r\nIf $G$ acts on another space $X$ on the left, then we can form the associated fiber bundle $\\xi_X : X \\rightarrow E' \\rightarrow B$ from the data\r\n\\[ \\widetilde{\\psi}_{\\alpha\\beta} : (U_\\alpha \\cap U_\\beta) \\times X \\rightarrow (U_\\alpha \\cap U_\\beta) \\times X \\]\r\n\\[ \\widetilde{\\psi}_{\\alpha\\beta}(p,x) = (p,g_{\\alpha\\beta}(p) \\cdot x) \\]\r\nIn particular, $\\xi_G$ is a principal $G$-bundle, called the associated principal $G$-bundle.\r\n\r\nOn the other hand, suppose $\\xi : G \\rightarrow E \\stackrel{\\pi}{\\rightarrow} B$ is a principal $G$-bundle, and suppose $G$ acts on a space $X$ on the left. We can define an action of $G$ on $E \\times X$ by:\r\n\\[ g \\cdot (p,x) = (pg^{-1},gx) \\]\r\nLet $E \\times_G X$ denote the quotient $(E \\times X)/G$, and define $\\pi_X : E \\times_G X \\rightarrow B$ by $\\pi_X[p,x] = \\pi(p)$. This makes a fiber bundle denoted by\r\n\\[ \\xi[X] : X \\rightarrow E \\times_G X \\rightarrow B \\]\r\nThis is called the associated fiber bundle.\r\n\r\nIt turns out these two constructions are inverses of each other, as stated in the following two theorems:\r\n\r\n\\begin{thm}\r\nLet $\\xi : F \\rightarrow E \\rightarrow B$ be a fiber bundle in which the structural group $G$ acts freely and transitively on $F$, then\r\n\\[ \\xi \\cong \\xi_G[F], \\]\r\nthat is the associated fiber bundle of the associated principal $G$-bundle is equivalent to the original fiber bundle.\r\n\\end{thm}\r\n\r\n\\begin{thm}\r\nLet $\\xi : G \\rightarrow E \\rightarrow B$ be a principal $G$-bundle and $X$ a space on which $G$ acts freely and transitively. Then\r\n\\[ \\xi \\cong \\xi[X]_G, \\]\r\nthat is the associated principal $G$-bundle of the associated fiber bundle is equivalent to the original principal $G$-bundle.\r\n\\end{thm}\r\n\r\nThese theorems allow us to reduce the classification of (real, complex, quaternionic) vector bundles over a space to the classification of principal ($\\GL(n),\\U(n),\\Sp(n)$)-bundles.\r\n\r\nFor a topological group $G$ let us define a contravariant functor $k_G : \\hCWp \\rightarrow \\Setp$ by\r\n\\[ k_G(X) = \\lcb \\text{isomorphism classes of principal $G$-bundles over $X$} \\rcb \\]\r\nFor $X \\stackrel{[f]}{\\longrightarrow} Y$ we define $k_G([f]) : k_G(Y) \\rightarrow k_G(X)$ by\r\n\\[ k_G([f])(\\xi) = f^*\\xi \\]\r\nThis function is well-defined by the fact that pullbacks of bundles under homotopic maps are equivalent. The base point of $k_G(X)$ is the equivalence class of the trivial $G$-bundle $G \\rightarrow G \\times X \\rightarrow X$.\r\n\r\n\\begin{thm}\r\nThe functor $k_G$ satisfies the wedge axiom and the Mayer-Vietoris axiom.\r\n\\end{thm}\r\n\r\nTherefore to each topological group $G$ there is a CW-complex $BG$ (determined up to homotopy type) and a principal $G$-bundle $G \\rightarrow EG \\rightarrow BG$ (this is the universal element) such that the natural transformation\r\n\\[ T_G : [-,(BG,*)] \\rightarrow k_G(-) \\]\r\ndefined by $T_G(X)([f]) = \\lcb f^*EG \\rcb$ is an equivalence. Therefore principal $G$-bundles are classified by homotopy classes of maps into $BG$. For this reason we call $BG$ the classifying space of $G$ and $EG \\rightarrow BG$ the universal bundle of $G$. All principal $G$-bundles are pullbacks of the universal bundle. The classifying spaces $\\BO(n)$, $\\BU(n)$ and $\\BSp(n)$ are very important in $K$-theory, and we can easily find explicit constructions of these spaces (not done here). One form of the Bott periodicity theorem in $K$-theory can be stated as\r\n\\[ \\mathbb Z \\times \\BU  \\simeq \\Omega^2 \\BU  \\]\r\n\\[ \\mathbb Z \\times \\BO  \\simeq \\Omega^4 \\BSp \\]\r\n\\[ \\mathbb Z \\times \\BSp \\simeq \\Omega^4 \\BO  \\]\r\n\r\nLet us now see how $B-$ can be turned into a functor. For now we will think of $B-$ as a functor from $\\TopGrp$, the category of topological groups and continuous homomorphisms (these spaces are automatically based at the identity and homomorphisms preserve this point), to $\\hCWp$. Clearly $B-$ will take a topological group $G$ to its classifying space $BG$. If $h : G \\rightarrow G'$ is a morphism of topological groups, then we can define a natural transformation $T : k_G \\rightarrow k_{G'}$ is the following way. Give a space $X$ and a principal $G$-bundle $\\xi$ over $X$ with transition functions $\\lcb g_{\\alpha\\beta} \\rcb$, let $T(X)(\\xi)$ be the principal $G'$-bundle over $X$ given by transition functions $\\lcb h \\circ g_{\\alpha\\beta} \\rcb$. Then \\ref{inducedmapclassifyingspaces} gives us an induced map $(BG,*) \\rightarrow (BG',*)$, which we call $Bh$.\r\n\r\nNow let us apply this machinery to the case of $G$-bundles over the suspension, $\\Sigma X$, of a space $X$. Here we are taking the reduced suspension $\\Sigma X = X \\wedge S^1$. By the adjoint relation \\eqref{smashmapadjoint} we see that principal $G$-bundles over $\\Sigma X$ are in one-to-one correspondence with\r\n\\[ [(\\Sigma X,*),(BG,*)] \\cong [(X,*),(\\Omega BG,*)] \\]\r\nWe can write $\\Sigma X$ as the union of two contractible pieces that intersect in a space that deformation retracts onto $X$:\r\n\\[ CX^+ = \\lcb [x,t] \\in \\Sigma X \\st t \\in (1/4,1] \\rcb \\ \\ \\ \\ \\ \\ CX^- = \\lcb [x,t] \\in \\Sigma X \\st t \\in [0,3/4) \\rcb \\]\r\n\\[ CX^+ \\cap CX^- = \\lcb [x,t] \\in \\Sigma X \\st t \\in (1/4,3/4) \\rcb \\simeq X \\]\r\nTherefore every $G$-bundle over $\\Sigma X$ can be constructed from a map $CX^+ \\cap CX^- \\rightarrow G$. For a map $f : X \\rightarrow G$ let us define $\\widetilde{f} : CX^+ \\cap CX^- \\rightarrow G$ by $\\widetilde{f}[x,t] = f(x)$, and let $\\xi(f)$ denote the $G$-bundle constructed via $\\widetilde{f}$.\r\n\\begin{lem}\r\nTwo maps $f_0,f_1 : (X,x_0) \\rightarrow (G,1)$ are homotopic rel $x_0$ if and only if $\\xi(f_0) = \\xi(f_1)$.\r\n\\end{lem}\r\nThis lemma tells us that the natural transformation\r\n\\begin{equation}\r\n\\label{suspension-classifying-natural-equivalent}\r\nT : [-,(G,1)] \\rightarrow k_G \\circ \\Sigma\r\n\\end{equation}\r\nis injective. It can also be shown that $T$ is actually a natural equivalence, hence principal $G$-bundles over $\\Sigma X$ are classified by homotopy classes of maps of $X$ into $G$.\r\n\\begin{cor}\r\n$G$ is homotopy equivalent to $\\Omega BG$.\r\n\\end{cor}\r\n\\begin{proof}\r\nWe have the following sequence of naturally equivalent functors\r\n\\[ [-,\\Omega BG] \\longrightarrow [\\Sigma-,BG] \\longrightarrow k_G \\circ \\Sigma(-) \\]\r\nSince naturally equivalent functors have homotopy equivalent classifying spaces we see that $\\Omega BG$ is the classifying object of $k_G \\circ \\Sigma$. The natural equivalence of \\eqref{suspension-classifying-natural-equivalent} now shows that $\\Omega BG$ is homotopy equivalent to $G$.\r\n\\end{proof}\r\nSo we can think of $B-$ as a one-sided inverse to $\\Omega$ when applied to certain spaces. By the adjoint relation \\eqref{smashmapadjoint} we have\r\n\\[ \\pi_n(G) \\cong \\pi_n(\\Omega BG) \\cong \\pi_{n+1}(BG) \\]\r\nIn particular, if $G$ is discrete, then\r\n\\[ \\pi_n(BG) \\cong \\pi_{n-1}(G) = \\begin{cases} G & n=1 \\\\ 0 & n>1 \\end{cases} \\]\r\nhence $BG$ is a $K(G,1)$ space.\r\n\r\n\\begin{lem}\r\nFor any topological group $G$, the total space $EG$ of the universal bundle is weakly contractible.\r\n\\end{lem}\r\n\\begin{proof}\r\n\\end{proof}\r\n\r\n\r\n\r\n\\section{Examples}\r\n\r\n\r\nHere we will construct the universal bundles for some topological groups. Let us take the simplest non-trivial topological group, $G = S^1 = U(1)$. Then $BU(1)$ is a space such that $\\pi_n(BU(1)) \\cong \\pi_{n-1}(G)$, so $BU(1)$ must be a $K(\\mathbb Z,2)$ space. This space must be homotopy equivalent to $\\mathbb CP^\\infty$, infinite complex projective space.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "1eb092d390daf6d2b76181d92e40847ca1cc21ff", "size": 18864, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "classifying-spaces-and-representability-theorems/classifying-spaces-and-representability-theorems.tex", "max_stars_repo_name": "mbrandonw/my-math-notes", "max_stars_repo_head_hexsha": "d208af0e6edd6293bbc939aa033bb9b5c0bedbce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2017-04-20T15:25:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T03:01:32.000Z", "max_issues_repo_path": "classifying-spaces-and-representability-theorems/classifying-spaces-and-representability-theorems.tex", "max_issues_repo_name": "mbrandonw/my-math-notes", "max_issues_repo_head_hexsha": "d208af0e6edd6293bbc939aa033bb9b5c0bedbce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "classifying-spaces-and-representability-theorems/classifying-spaces-and-representability-theorems.tex", "max_forks_repo_name": "mbrandonw/my-math-notes", "max_forks_repo_head_hexsha": "d208af0e6edd6293bbc939aa033bb9b5c0bedbce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-07-11T13:27:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-13T16:46:16.000Z", "avg_line_length": 74.2677165354, "max_line_length": 867, "alphanum_fraction": 0.6776929601, "num_tokens": 6133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165382362518, "lm_q2_score": 0.7905303186696748, "lm_q1q2_score": 0.4168597110116939}}
{"text": "\\documentclass[DM,lsstdraft, authoryear,toc]{lsstdoc}\n% lsstdoc documentation: https://lsst-texmf.lsst.io/lsstdoc.html\n\\input{meta}\n\n% Package imports go here.\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n% Local commands go here.\n\\newcommand{\\rmd}{\\mathrm{d}^2}\n%If you want glossaries\n%\\input{aglossary.tex}\n%\\makeglossaries\n\n\\title{Gaussian-Aperture and PSF photometry}\n\n% Optional subtitle\n% \\setDocSubtitle{A subtitle}\n\n\\author{%\nArun Kannawadi\n}\n\n\\setDocRef{DMTN-190}\n\\setDocUpstreamLocation{\\url{https://github.com/lsst-dm/dmtn-190}}\n\n\\date{\\vcsDate}\n\n% Optional: name of the document's curator\n% \\setDocCurator{The Curator of this Document}\n\n\\setDocAbstract{%\nRubin Science Pipelines of the Gaussian-Aperture and PSF photometry algorithm for consistent galaxy colors\n}\n\n% Change history defined here.\n% Order: oldest first.\n% Fields: VERSION, DATE, DESCRIPTION, OWNER NAME.\n% See LPM-51 for version number policy.\n\\setDocChangeRecord{%\n  \\addtohist{1}{YYYY-MM-DD}{Unreleased.}{Arun Kannawadi}\n}\n\n\n\\begin{document}\n\n% Create the title page.\n\\maketitle\n% Frequently for a technote we do not want a title page  uncomment this to remove the title page and changelog.\n% use \\mkshorttitle to remove the extra pages\n\n% ADD CONTENT HERE\n% You can also use the \\input command to include several content files.\n\\section{Notation}\n\\begin{itemize}\n    \\item $g({\\bf x})$: unobservable pre-seeing galaxy profile\n    \\item $G({\\bf x})$: observable image of galaxy with a Gaussian PSF\n    \\item $I({\\bf x})$: observed image of the galaxy with some PSF\n    \\item $K({\\bf x})$: convolution kernel that converts $I({\\bf x})$ to $G({\\bf x})$, with a desired Gaussian PSF.\n\\end{itemize}\n\n\\section{GAaP flux}\nBased on Eq. A16 of \\cite{Kuijken2015}, the GAaP flux with an aperture parameter ${\\bf W}$ is defined as follows:\n\\begin{align}\n  F_{\\bf W} &\\equiv \\int\\rmd{\\bf x}\\, g({\\bf x})\\exp\\left( -\\frac{1}{2}{\\bf x}^T{\\bf W}^{-1}{\\bf x} \\right) \\\\\n        &= \\frac{1}{2}\\frac{\\det({\\bf W})^{1/2}}{\\det({\\bf W}-p^2{\\bf 1})^{1/2}}\\times 2\\int\\rmd{\\bf x} G(\\bf x) \\exp\\left(-\\frac{1}{2}{\\bf x}^T({\\bf W}-p^2{\\bf 1})^{-1}{\\bf x}\\right),\n  \\label{eq:A16}\n\\end{align}\nwhere $G({\\bf x})$ is the image of $g({\\bf x})$ after convolution by a Gaussian PSF of size $p$.\nThe integral is computed using \\texttt{computeFixedMomentsFlux}\\footnote{\n  Note: \\texttt{computeFixedMomentsFlux} computes the flux of an image $I({\\bf x})$ weighted by an aperture ${\\bf Q}$ as $2\\int\\rmd{\\bf x}\\, I({\\bf x})\\exp\\left(-\\frac{1}{2} {\\bf x}^T {\\bf Q}^{-1}{\\bf x}\\right)$, with a factor 2 in the normalization. This is such that if $I({\\bf x})$ is a Gaussian with shape ${\\bf Q}$ and has a total flux $F$, the integral evaluates to $F$.} \n  by passing the PSF-Gaussianize image and shape parameter $({\\bf W}-p^2{\\bf 1})$.\nThe factor multiplying the integral, especially $\\det({\\bf W}-p^2{\\bf 1})^{1/2}$, is required to keep $F_{\\bf W}$ PSF-independent.\nWe refer to this factor, the square root of the ratio of determinants, as \\texttt{fluxScaling}. We scale the \\texttt{instFlux} value from the \\texttt{computeFixedMomentsFlux} method with \\texttt{fluxScaling}.\n\nFor circular apertures, $\\texttt{fluxScaling} = \\frac{1}{2}\\frac{\\sigma_w^2}{\\sigma_w^2-p^2}$, \nwhere ${\\bf W} = \\sigma_w^2 \\bf{1}$. In the GAaP plugin, $\\sigma_w$ values are specified in the \\texttt{sigmas} config parameter..\n\n\\section{Propagating noise covariance}\nLet us calculate the covariance $C^G$ between the errors on two pixel values $G({\\bf x})$ and $G({\\bf y})$. Rewriting Eq. A9 of \\cite{Kuijken2015}, we get\n\\begin{equation}\n  Cov(G({\\bf x}), G({\\bf y})) = \\int\\int\\rmd{\\bf x}'\\rmd{\\bf y}'\\, Cov(I({\\bf x}'),I({\\bf y}'))\\, K({\\bf x}-{\\bf x}')K({\\bf y}-{\\bf y}')\n\\end{equation}\n\nIn KiDS papers, including \\cite{Kuijken2015}, translational invariance is assumed and $Cov(I({\\bf x}'),I({\\bf y}'))$ is expressed as a function of $({\\bf x}'-{\\bf y}')$ alone and an appropriate covariance matrix is constructed empirically.\n\nHowever, in Rubin science pipelines, because we keep track of only the variance , our model for $Cov(I({\\bf x}'), I({\\bf y}')) = \\sigma^2({\\bf x}')\\delta_D({\\bf x'}-{\\bf y}')$, where $\\sigma^2({\\bf x}')$ is given by the variance plane. This is incorrect strictly speaking, as the noise \\emph{is} correlated on the coadds. However, we proceed with the information we have available. Substituting this in the above equation, we get\n\\begin{equation}\n  Cov(G({\\bf x}), G({\\bf y})) = \\int\\rmd{\\bf x}'\\, \\sigma^2({\\bf x}') K({\\bf x}-{\\bf x}')K({\\bf y}-{\\bf x}')\n\\end{equation}\n\nThe kernel $K$ is expected to be compact, and if the variance plane is slowly varying, we can approximate $\\sigma^2({\\bf x}')$ by the variance value at the centroid of the source, say $\\sigma^2$. This approximation is further justified because of Gaussian weighting we will employ in Eq.~\\ref{eq:A17}, which makes the effective kernel even more compact. Redefining ${\\bf x}' \\rightarrow {\\bf x} - {\\bf x}'$ ($\\rmd{\\bf x}' \\rightarrow \\rmd{\\bf x}'$ because the dimensionality is even), we get\n\\begin{equation}\n  Cov(G({\\bf x}), G({\\bf y})) \\approx \\sigma^2 \\xi_K({\\bf r}) \\equiv C^G({\\bf r}),\n\\end{equation}\nwhere ${\\bf r} = {\\bf y}-{\\bf x}$. Thus, the covariance is the auto-correlation function of the kernel $K$ $\\xi_K({\\bf r}) \\equiv \\int\\rmd{\\bf x}\\, K({\\bf x})K({\\bf x}+{\\bf r})$  scaled by the variance $\\sigma^2$ at the location of the source. The auto-correlation function is computed by the \\texttt{\\_computeKernelAcf} static method.\n\n\\section{Estimating uncertainties}\nEq. A17 of~\\cite{Kuijken2015} says\n\\begin{equation}\n    \\text{Var}(F_{\\bf W}) = \\frac{\\det({\\bf W})}{\\det({\\bf W}-p^2\\bf{1})} \\pi \\det({\\bf W}-p^2{\\bf 1})^{1/2} \\int\\rmd {\\bf x}\\, C^G({\\bf x}) \\exp\\left(-\\frac{1}{4}{\\bf x}^T({\\bf W}-p^2{\\bf 1})^{-1}{\\bf x}\\right).\n    \\label{eq:A17}\n\\end{equation}\nNote the missing factor of $2^{1/2}$, which is an error in \\cite{Kuijken2015}.\nSince we represent\n\\begin{equation}\n    C^G({\\bf r}) = \\sigma^2 \\xi_{K}({\\bf r}),\n\\end{equation}\nwe get\n\\begin{equation}\n  \\text{Var}(F_{\\bf W}) = \\frac{\\det({\\bf W})}{\\det({\\bf W}-p^2\\bf{1})}\\left(\\frac{1}{2}\\right)^2 \\times 4\\pi \\sigma^2 \\det({\\bf W}-p^2{\\bf 1})^{1/2} \\times \\int\\rmd {\\bf r}\\, \\xi_{K}({\\bf r}) \\exp\\left(-\\frac{1}{2}{\\bf r}^T(2({\\bf W}-p^2{\\bf 1}))^{-1}{\\bf r}\\right).\n\\end{equation}\nWe categorize them into three terms, separated by $\\times$. \n\\begin{enumerate}\n  \\item The naive calculation of flux variance by \\texttt{computeFixedMomentsFlux} yields the middle term $4\\pi \\sigma^2 \\det({\\bf W}-p^2{\\bf 1})^{1/2}$ (given by \\texttt{instFluxErr}$^2$).\n  \\item The factor $\\frac{1}{4}\\frac{\\det({\\bf W})}{\\det({\\bf W}-p^2\\bf{1})}$ appears because of the scaling factor in $F_{\\bf W}$ (Eq. A16 of \\cite{Kuijken2015}).\n  \\item The square root of the integral is computed by \\texttt{\\_getFluxErrScaling} and referred to as \\texttt{fluxErrScaling}. This is the actual contribution due to correlations in the noise introduced by PSF-Gaussianization procedure. This is computed using \\texttt{computeFixedMomentsFlux} on the auto-correlation function, with $2 \\times$ the shape parameter of aperture used to measure $F_{\\bf W}$.\n  \n  If the PSF had been Gaussian to begin with, or if we were neglecting the effects of correlated noise on flux uncertainties, $K({\\bf r}) = \\delta_D({\\bf r})$. This leads to the integral evaluating to 1.\n\\end{enumerate}\n\nNote that from the definition of $\\xi_K({\\bf r})$, it follows that\n\\begin{align}\n  \\int\\rmd{\\bf r}\\, \\xi_K({\\bf r}) &= \\int\\rmd{\\bf r}\\, \\int\\rmd{\\bf x}\\, K({\\bf x})K({\\bf x}+{\\bf r})\\\\ \n                                   &= \\int\\rmd{\\bf x}\\, K({\\bf x}) \\int\\rmd{\\bf r}\\, K({\\bf x}+{\\bf r})\\\\\n                                   &= \\left[ \\int\\rmd{\\bf x}\\, K({\\bf x})\\right]^2\n                                   \\label{eq:integral_acf}\n\\end{align}\n\nIn a similar manner, the integral for \\texttt{fluxErrScaling} can also be expressed as\n\\begin{equation}\n  \\int\\rmd {\\bf r}\\, \\xi_{K}({\\bf r}) \\exp\\left(-\\frac{1}{2}{\\bf r}^T(2({\\bf W}-p^2{\\bf 1}))^{-1}{\\bf r}\\right) =\n  \\left[ \\int\\rmd{\\bf x}\\int\\rmd{\\bf y} K({\\bf x}-{\\bf y}) \\exp\\left(-\\frac{1}{2}{\\bf y}^T({\\bf W}-p^2{\\bf 1})^{-1}{\\bf y}\\right)\\right]^2.\n\\end{equation}\nThe proof follows by considering $\\int\\rmd{\\bf x} f({\\bf x}) = \\tilde{f}(0)$, where $\\tilde{f}$ is the Fourier transform of $f$.\n\n\\subsection{Special case of Gaussian kernels}\nSuppose $I({\\bf x})$ has a circular Gaussian PSF of size $s$ and the target PSF is a Gaussian PSF of size $p = fs$ ($f>1$), then the kernel $K$ is also a Gaussian of size $s(f^2-1)^{1/2}$. \nIn the GAaP plugin, the values for $f$ are given by \\texttt{scalingFactors}.\n\nSince flux-conservation implies $\\int\\rmd{\\bf x}\\, K({\\bf x}) = 1$, we can immediately write\n\\begin{equation}\n  K({\\bf x}) = \\frac{1}{2\\pi (f^2-1)s^2} \\exp\\left(-\\frac{{\\bf x}^T{\\bf x}}{2(f^2-1)s^2}\\right)\n\\end{equation}\n\nThe auto-correlation function $\\xi_K({\\bf r})$ is then given by \n\\begin{equation}\n  \\xi_K({\\bf r}) = \\frac{1}{4\\pi(f^2-1)s^2}\\exp\\left(-\\frac{{\\bf r}^T{\\bf r}}{4(f^2-1)s^2}\\right).\n\\end{equation}\nThis is easy to see by first recognizing that $\\xi_K({\\bf r})$ must be a Gaussian with size $\\sqrt{2}$ times larger than that of $K$ and the normalization factor follows that $\\xi_K({\\bf r})$ must integrate to 1 if $K$ integrates to 1 (see Eq.~\\ref{eq:integral_acf}).\n\nThe square of the \\texttt{fluxErrScaling} parameter is then given by the Gaussian integral\n\\begin{equation*}\n  \\int\\rmd{\\bf r}\\,\\xi_K({\\bf r})\\exp(-\\frac{{\\bf r}^T{\\bf r}}{4(\\sigma^2-p^2)}),\n\\end{equation*}\nwhere $\\sigma$ is the size of the Gaussian aperture for the pre-seeing source $g({\\bf x})$. In the GAaP plugin, these values are given by \\texttt{sigmas} config parameter.\n\nThe exponents of the Gaussians is simplified as follows.\n\\begin{equation}\n  \\frac{{-\\bf r}^T{\\bf r}}{4}\\left(\\frac{1}{(f^2-1)s^2} + \\frac{1}{(\\sigma^2-f^2s^2)} \\right)\n  = \\frac{{-\\bf r}^T{\\bf r}}{4}\\left( \\frac{\\sigma^2 - s^2}{s^2(f^2-1)(\\sigma^2-f^2s^2)} \\right)\n\\end{equation},\nwhere $p$ is replaced by $fs$. Evaluating the Gaussian integral, we get\n\\begin{align}\n  \\texttt{fluxErrScaling}^2 &= \\frac{1}{4\\pi (f^2-1)s^2} \\times \\frac{\\pi 4s^2(f^2-1)(\\sigma^2-f^2s^2)}{\\sigma^2-s^2} \\\\\n  &= \\frac{\\sigma^2-f^2s^2}{\\sigma^2-s^2}\n\\end{align}\nAs a consistency check, we get $\\texttt{fluxErrScaling} = 1$ for $f=1$, i.e., if we do not carry out the PSF-Gaussianization procedure. For $f>1$, $\\texttt{fluxErrScaling} < 1$. As an aside, if $\\xi_K({\\bf r}) \\ge 0$ for all ${\\bf r}$ (as in the Gaussian kernel case), \\texttt{fluxErrScaling} is guaranteed to be less than 1. In other words, the naive flux uncertainty overestimates the true uncertainty. For naive errors to be an underestimation of true errors, it is necessary that the kernel should be negative for sufficiently small $|{\\bf r}|$. Intuitively, this makes sense; non-negative valued kernel smoothes the noise in the image, reducing its power, whereas as kernel with both positive and negative values has the potential to amplify the random fluctuations in different pixels.\n\n\\appendix\n% Include all the relevant bib files.\n% https://lsst-texmf.lsst.io/lsstdoc.html#bibliographies\n\\section{References} \\label{sec:bib}\n\\renewcommand{\\refname}{} % Suppress default Bibliography section\n\\bibliography{local,lsst,lsst-dm,refs_ads,refs,books}\n\n% Make sure lsst-texmf/bin/generateAcronyms.py is in your path\n\\section{Acronyms} \\label{sec:acronyms}\n\\input{acronyms.tex}\n% If you want glossary uncomment below -- comment out the two lines above\n%\\printglossaries\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "494302b3916a577abb86b251dfb9767322af4653", "size": 11514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DMTN-190.tex", "max_stars_repo_name": "lsst-dm/dmtn-190", "max_stars_repo_head_hexsha": "45464f0c4aff347d770e55a38130790c6265ad4e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DMTN-190.tex", "max_issues_repo_name": "lsst-dm/dmtn-190", "max_issues_repo_head_hexsha": "45464f0c4aff347d770e55a38130790c6265ad4e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DMTN-190.tex", "max_forks_repo_name": "lsst-dm/dmtn-190", "max_forks_repo_head_hexsha": "45464f0c4aff347d770e55a38130790c6265ad4e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.5721925134, "max_line_length": 791, "alphanum_fraction": 0.6697064443, "num_tokens": 3995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4168262221204278}}
{"text": "\\XtoCBlock{Atan2}\r\n\\label{block:Atan2}\r\n\\begin{figure}[H]\\includegraphics{Atan2}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\ny & \\tabularnewline\r\n\\hline\r\nx & \\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & Result of atan2(y/x)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nComputation of the angle between the inputs x and y.\r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Atan2_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!4880}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 4880 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & Atan2\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & Atan2\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *y;\r\n     int8          *x;\r\n     int8          Out;\r\n} ATAN2_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Test_Atan2_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!4881}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 4881 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & Atan2\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & Atan2\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *y;\r\n     int16         *x;\r\n     int16         Out;\r\n} ATAN2_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Test_Atan2_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!4882}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 4882 \\tabularnewline\r\n\\textbf{Revision} & 1.0 \\tabularnewline\r\n\\textbf{C filename} & Atan2\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & Atan2\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *y;\r\n     int32         *x;\r\n     int32         Out;\r\n} ATAN2_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Test_Atan2_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!4883}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 4883 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Atan2\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & Atan2\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *y;\r\n     float32       *x;\r\n     float32       Out;\r\n} ATAN2_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Test_Atan2_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!4884}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 4884 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Atan2\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & Atan2\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *y;\r\n     float64       *x;\r\n     float64       Out;\r\n} ATAN2_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Math/Doc/Test_Atan2_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "7419c42a7e54a683cac833a3f3432e0d963eb388", "size": 4729, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Math/Doc/Atan2.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Math/Doc/Atan2.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Math/Doc/Atan2.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5674157303, "max_line_length": 80, "alphanum_fraction": 0.7073377035, "num_tokens": 1513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4168262201754227}}
{"text": "%% LaTeX Beamer presentation template (requires beamer package)\n%% see http://bitbucket.org/rivanvx/beamer/wiki/Home\n%% idea contributed by H. Turgut Uyar\n%% template based on a template by Till Tantau\n%% this template is still evolving - it might differ in future releases!\n\n\\documentclass{beamer}\n\\mode<presentation>\n{\n% \t\\usetheme{Singapore}\n\t\\usetheme{Dresden}\n\t\\setbeamertemplate{footline}[frame number]\n\t\\usefonttheme{serif}\n\n\t\\setbeamertemplate{navigation symbols}{}\n    \\setbeamertemplate{caption}[numbered]\n% \t\\setbeamercovered{transparent}\n}\n\n\\usepackage{cancel}\n\\usepackage{amsmath}\n\\usepackage{graphics}\n\n\\usepackage{ulem}\n\\normalem\n\n\\usepackage{wasysym}\n\n\\usepackage{mdframed}\n\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\n\\usepackage{multicol}\n\n\\title{Graph Decomposition (2)}\n\\subtitle{--- BFS and its Applications}\n\n\\author{Hengfeng Wei}\n\\institute{hengxin0912@gmail.com}\n\n\\date{\\today}\n\n% Delete this, if you do not want the table of contents to pop up at\n% the beginning of each subsection:\n\\AtBeginSubsection[]\n{\n\t\\begin{frame}<beamer>\n\t\t\\frametitle{Outline}\n\t\t\\tableofcontents[currentsection]\n\t\\end{frame}\n}\n\n\\AtBeginSection[]\n{\n\t\\begin{frame}<beamer>\n\t\t\\frametitle{Outline}\n\t\t\\tableofcontents[currentsection]\n\t\\end{frame}\n}\n% If you wish to uncover everything in a step-wise fashion, uncomment\n% the following command:\n\n%\\beamerdefaultoverlayspecification{<+->}\n\n\\begin{document}\n\n\\begin{frame}\n\t\\titlepage\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Outline}\n\t\\tableofcontents\n% You might wish to add the option [pausesections]\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%\n\\section{BFS: Algorithm}\n\n\\begin{frame}{Problem}\n  \\begin{exampleblock}{Problem: Shortest Path}\n    Given an undirected graph $G = (V, E)$ and a source vertex $s$,\n    to compute distance $\\delta(s, u)$ for each vertex $u$.\n  \\end{exampleblock}\n\n  \\[\n    \\delta(s,u) \\equiv \\# \\textrm{ of edges of the shortest path between } s\n    \\textrm{ and } u.\n  \\]\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{BFS on Undirected Graph}\n  BFS with source vertex $s$:\n  \\begin{itemize}\n    \\item exploring every vertex $u$ reachable from $s$\n    \\item \\textcolor{purple}{computing $\\delta(s,u)$, for all reachable $u$}\n  \\end{itemize}\n\n  \\vspace{0.50cm}\n  BFS as a framework:\n  \\begin{itemize}\n    \\item Prim's MST algorithm\n    \\item Dijkstra's SSSP algorithm\n  \\end{itemize}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{A Physical Algorithm of BFS (\\textsf{Phys-BFS})}\n  \\begin{columns}\n    \\column{0.50\\textwidth}\n\t  \\begin{figure}[htp]\n\t    \\centering\n\t\t\\includegraphics[width = 0.85\\textwidth]{figure/bfs-graph.pdf}\n\t  \\end{figure}\n    \\column{0.50\\textwidth}\n\t  \\begin{figure}[htp]\n\t    \\centering\n\t\t\\includegraphics[width = 0.50\\textwidth]{figure/bfs-physical-alg.pdf}\n\t  \\end{figure}\n  \\end{columns}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Edge Properties of \\textsf{Phys-BFS}}\n  \\begin{mdframed}[linecolor = blue, leftmargin = 2cm, rightmargin = 2cm]\n    \\[ (u,v) \\in E \\Rightarrow d(u) \\le d(v) \\le d(u) + 1 \\]\n  \\end{mdframed}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{A Parallel Algorithm of BFS (\\texttt{Para-BFS})}\n  \\begin{description}\n    \\item[graph:] network of computers\n    \\item[vertex:] computer\n    \\item[edge:] network connections\n  \\end{description}\n\n  \\vspace{0.50cm}\n  \\begin{center}\n  \tTo disseminate a computer virus from computer $s$.\n  \\end{center}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Color Properties in \\texttt{Para-BFS}}\n  \\begin{displaymath}\n\t\\textrm{states of computers} = \\left\\{ \\begin{array}{ll}\n\t\\texttt{WHITE} & \\textrm{if healthy}\\\\\n\t\\texttt{GRAY} & \\textrm{if infected}\n\t\\end{array} \\right.\n  \\end{displaymath}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{A Parallel Algorithm of BFS (\\texttt{Para-BFS})}\n  \\begin{algorithm}[H]\n    \\caption{A Parallel Algorithm of BFS (\\texttt{Para-BFS}).}\n    \\begin{multicols}{2}[\\columnsep = -50pt]\n    \\begin{algorithmic}[]\n    {\\footnotesize\n      \\Procedure{Para-BFS}{$G, s$}\n\t\t\\ForAll{$u \\in V$}\n\t\t  \\State color[$u$] $\\gets$ \\texttt{WHITE}\n\t\t  \\State d[$u$] $\\gets$ $\\infty$\n\t\t\\EndFor\n\n\t\t\\Statex\n\t\t\\State color[$s$] $\\gets$ \\texttt{GRAY}\n\t\t\\State d[$s$] $\\gets$ $\\infty$\n\n\t\t\\Statex\n\t\t\\State \\textcolor{purple}{\\textrm{Q} $\\gets$ $\\{ s \\}$}\n\t\t\\While{\\textrm{Q} $\\neq$ $\\emptyset$}\n\t\t    \\State \\textcolor{purple}{$u$ $\\gets$ Deq(\\textrm{Q})}\n\t\t\t\\ForAll{$(u,v) \\in E$}\n\t\t\t  \\If{color[$v$] = \\texttt{WHITE}}\n\t\t\t    \\State \\textcolor{blue}{color[$v$] = \\texttt{GRAY}}\n\t\t\t    \\State d[$v$] = d[$u$] + 1\n\t\t\t    \\State \\textcolor{purple}{Enq(\\textrm{Q}, $v$)}\n\t\t\t  \\EndIf\n\t\t\t\\EndFor\n\t\t\t\\State \\textcolor{blue}{color[$u$] $\\gets$ \\texttt{BLACK}}\n\t\t  \\EndFor\n\t\t\\EndWhile\n      \\EndProcedure\n    }\n    \\end{algorithmic}\n    \\end{multicols}\n  \\end{algorithm}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Color Properties of \\texttt{Para-BFS}}\n  States of vertices:\n  \\begin{description}\n    \\item [\\texttt{WHILE:}] undiscovered\n    \\item [\\texttt{GRAY:}]\tdiscorvered but\n    \\item [\\texttt{BLACK:}]\tdiscorvered and all its neighbors has been\n    discorvered\n  \\end{description}\n\n  \\begin{center}\n  \t\\texttt{WHITE} $\\Rightarrow$ \\texttt{GRAY} $\\Rightarrow$ \\texttt{BLACK}\n  \\end{center}\n\n  \\begin{enumerate}\n    \\item $(u,v) \\in E$, $u$ is \\texttt{BLACK} $\\Rightarrow$ $v$ is either\n    \\texttt{BLACK} or \\texttt{GRAY}\n    \\item \\texttt{GRAY} vertex may have adjacent \\texttt{WHITE} vertices\n    \\\\ $\\Rightarrow$ ``frontier'' between discovered and undiscovered vertices\n    \\item Invariant: at any time, all \\texttt{GRAY} vertices are in the Queue\n  \\end{enumerate}\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Correctness Proof \\texttt{Para-BFS}}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{BFS Algorithm}\n\n\\end{frame}\n%%%%%%%%%%%%%%%%%%%\n\\section{BFS: Properties}\n\n%%%%%%%%%%%%%\n\\begin{frame}{Color Properties}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Queue Properties}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Correctness Proof}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{Edges Properties}\n\n\\end{frame}\n% %%%%%%%%%%%%%%%%%\n\\section{BFS: Applications}\n\n%%%%%%%%%%%%%\n\\begin{frame}{Testing Bipartiteness}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{}\n\n\\end{frame}\n%%%%%%%%%%%%%\n\\begin{frame}{}\n\n\\end{frame}\n%%%%%%%%%%%%%%%%%%\n\\section*{Summary}\n\\begin{frame}{}\n  \\begin{figure}[htp]\n    \\begin{center}\n      \\includegraphics[width=0.618\\textwidth]{figure/thankyou.jpg}\n    \\end{center}\n  \\end{figure}\n\\end{frame}\n%%%%%%%%%%\n\\end{document}\n", "meta": {"hexsha": "b41f9763007b68492c666879242a5508179b6e47", "size": 6362, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg-ta-by-years/alg-ta-2014/algorithm-tutorial-bfs-20141121/src/tutorial-20141121-bfs.tex", "max_stars_repo_name": "hengxin/algorithm-ta-tutorial", "max_stars_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2017-03-29T08:22:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-02T15:12:15.000Z", "max_issues_repo_path": "alg-ta-by-years/alg-ta-2014/algorithm-tutorial-bfs-20141121/src/tutorial-20141121-bfs.tex", "max_issues_repo_name": "courses-at-nju-by-hfwei/algorithm-ta-tutorial", "max_issues_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg-ta-by-years/alg-ta-2014/algorithm-tutorial-bfs-20141121/src/tutorial-20141121-bfs.tex", "max_forks_repo_name": "courses-at-nju-by-hfwei/algorithm-ta-tutorial", "max_forks_repo_head_hexsha": "0bb0376d96f388671597903fc833f68d7946020e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-10-10T08:47:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-18T07:58:43.000Z", "avg_line_length": 24.2824427481, "max_line_length": 78, "alphanum_fraction": 0.6485381955, "num_tokens": 2087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.4168033634040591}}
{"text": "\\documentclass{article}\n\\usepackage{parskip}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\setlength{\\parindent}{0cm}\n\n\\begin{document}\n\n\\title{CPSC 413 Notes}\n\\author{Andrew Helwer}\n\\date{Winter 2011}\n\\maketitle\n\n\\section{Correctness of Iterative Algorithms}\n\n\\begin{itemize}\n\\item Precondition: a list of conditions that input must satisfy to be valid\n\\item Postcondition: a relationship between initial and final state\n\\item Assertion: a condition that holds during a certain point in execution\n\\item Loop Invariant: an assertion satisfied at the beginning of a loop\n\\item Loop Variant: an assertion satisfied at the end of the loop\n\\item Partial Correctness: precondition $\\Rightarrow$ postcondition over the\nalgorithm\n\\item Bound Function $B$:\n\\begin{itemize}\n\\item Maps program variables to $\\mathbb{Z}$\n\\item Loop variant implies $|B|$ has decreased by at least one\n\\item If $|B| \\leq 0$ then the loop invariant is not satisfied\n\\end{itemize}\n\\item Termination: a bound function exists for every loop in the algorithm\n\\item Correctness: a partially correct algorithm that terminates\n\\end{itemize}\n\n\\section{Correctness of Recursive Algorithms}\n\n\\begin{itemize}\n\\item Recursive algorithms are guaranteed to terminate by their nature\n\\item Correctness of recursive algorithms is shown by structural induction\n\\item Structural Induction:\n\\begin{itemize}\n\\item Show correctness to hold for all base cases\n\\item Assume correctness for input of size $n$, then show for size $n+1$\n\\end{itemize}\n\\end{itemize}\n\n\\section{Asymptotic Notation}\n\n\\begin{itemize}\n\\item $f(n) \\in O(g(n))$: $f$ bounded above by $g$\n\\item $f(n) \\in \\Omega (g(n))$: $f$ bounded below by $g$\n\\item $f(n) \\in \\Theta (g(n))$: $f$ bounded above and below by $g$\n\\end{itemize}\n\n\\section{Greedy Algorithms}\n\n\\begin{itemize}\n\\item Greedy Choice Property: optimal solution includes locally optimal choice\n\\item Greedy Algorithm: solves a problem exhibiting the greedy choice property\n\\item Greedy algorithms are the fastest-running solutions to a problem\n\\item Correctness of greedy algorithms is shown thus:\n\\begin{enumerate}\n\\item Prove correct output always exists given valid input\n\\item Describe how to solve trivial instances\n\\item Describe a greedy strategy involving a greedy choice\n\\item Prove some correct output includes the greedy choice\n\\item Prove adding the greedy choice to correct output gives correct output\n\\item Describe a recursive algorithm implementation\n\\item Prove correctness of the algorithm using structural induction\n\\end{enumerate}\n\\item Most early steps merely serve to simplify the structual induction step\n\\end{itemize}\n\n\\section{Divide-and-Conquer Algorithms}\n\n\\begin{itemize}\n\\item Problems are broken down into multiple problems of the same type\n\\item Once the problems become small enough, they are solved efficiently\n\\item The solved subproblems are then combined to form a total solution\n\\item Correctness of divide-and-conquer algorithms is shown thus:\n\\begin{enumerate}\n\\item Describe trivial instances and how to solve them\n\\item Describe how sub-instances should be formed from nontrivial ones\n\\item Describe how a solution is formed from sub-instance solutions\n\\item Describe a recursive algorithm implementation\n\\item Prove correctness of the algorithm using structural induction\n\\end{enumerate}\n\\end{itemize}\n\n\\section{The Master Theorem}\n\n\\begin{itemize}\n\\item The master theorem allows bounds to easily be placed on recurrences\n\\item The theorem is defined as follows:\n\nLet $a \\geq 1$ and $b > 1$ be constants, $f(n)$ be a function, and let $T(n)$\nbe defined over the nonnegative integers by the recurrence:\n\n\\begin{equation*}\nT(n) = aT \\left( \\frac{n}{b} \\right) +f(n)\n\\end{equation*}\n\nThen $T(n)$ may be bounded asymptotically as follows based on $f(n)$:\n\n\\begin{itemize}\n\\item If $f(n) = O(n^{\\log_ba-\\epsilon})$ for some $\\epsilon > 0$, then $T(n) =\n\\Theta(n^{\\log_ba})$\n\\item If $f(n) = \\Theta(n^{\\log_ba})$ then $T(n) = \\Theta(n^{\\log_ba}\\log n)$\n\\item $f(n) = \\Omega(n^{\\log_ba+\\epsilon})$ for some $\\epsilon > 0$ and\n$af(n/b) \\leq cf(n)$ for some constant $c<1$ and all sufficiently large $n$,\nthen $T(n) = \\Theta(f(n))$\n\\end{itemize}\n\n\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "af6a481744db4b333aada1c7c0499abd15869677", "size": 4186, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cpsc413/notes/cpsc413notes.tex", "max_stars_repo_name": "edwardchen123/UofC", "max_stars_repo_head_hexsha": "ecc49eee798772e560397fb00ad692e6f664c19b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-11T10:17:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-11T10:17:41.000Z", "max_issues_repo_path": "cpsc413/notes/cpsc413notes.tex", "max_issues_repo_name": "edwardchen123/UofC", "max_issues_repo_head_hexsha": "ecc49eee798772e560397fb00ad692e6f664c19b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cpsc413/notes/cpsc413notes.tex", "max_forks_repo_name": "edwardchen123/UofC", "max_forks_repo_head_hexsha": "ecc49eee798772e560397fb00ad692e6f664c19b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.7777777778, "max_line_length": 79, "alphanum_fraction": 0.7642140468, "num_tokens": 1111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.41680335994763457}}
{"text": "\\chapter{Dump Data Format}\\label{dump.chapter}\n\n\\noindent \nFor representing structured data in files, \\CmdStan uses the dump format\nintroduced in \\SPLUS and used in \\R and \\JAGS (and in \\BUGS, but with\na different ordering).   A dump file is structured as a sequence of\nvariable definitions.  Each variable is defined in terms of its\ndimensionality and its values.   There are three kinds of variable\ndeclarations, one for scalars, one for sequences, and one for general\narrays.\n\n\\section{Creating Dump Files}\n\nDump files can be created from R using RStan.  The function is\n\\code{stan\\_rdump} in package \\code{rstan}.\n\nUsing R's native \\code{dump()} function can produce dump files which\nStan cannot read in.  The underlying cause is that R supports\ncomplicated data structures, some of which are not used in \\CmdStan.\nFor example, R's \\code{dump()} can write a numerical vector with names\nfor each element.\n\n\\section{Scalar Variables}\n\nA simple scalar value can be thought of as having an empty list of\ndimensions.  Its declaration in the dump format follows the \\SPLUS\nassignment syntax.  For example, the following would constitute a\nvalid dump file defining a single scalar variable \\code{y} with value\n17.2.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny <- 17.2\n\\end{Verbatim}\n\\end{quote}\n%\nA scalar value is just a zero-dimensional array value.\n\n\n\\section{Sequence Variables}\\label{sequence-variables.section}\n\nOne-dimensional arrays may be specified directly using the \\SPLUS\nsequence notation.  The following example defines an integer-value and\na real-valued sequence.\n%\n\\begin{quote}\n\\begin{Verbatim}\nn <- c(1,2,3)\ny <- c(2.0,3.0,9.7)\n\\end{Verbatim}\n\\end{quote}\n%\nArrays are provided without a declaration of dimensionality because\nthe reader just counts the number of entries to determine the size of\nthe array.\n\nSequence variables may alternatively be represented with \\R's\ncolon-based notation.  For instance, the first example above could\nequivalently be written as\n%\n\\begin{quote}\n\\begin{Verbatim} \nn <- 1:3\n\\end{Verbatim}\n\\end{quote}\n% \nThe sequence denoted by \\code{1:3} is of length 3, running from 1 to 3\ninclusive.  The colon notation allows sequences going from high to\nlow, as in the first of the following examples, which is equivalent to\nthe second.\n%\n\\begin{quote}\n\\begin{Verbatim}\nn <- 2:-2\nn <- c(2,1,0,-1,-2)\n\\end{Verbatim}\n\\end{quote}\n%\n\nAs a special case, a sequence of zeros can also be\nrepresented in the dump format by \\code{integer(x)} and\n\\code{double(x)}, for type int and double, respectively.\nHere \\code{x} is a non-negative integer to specify the\nlength. If \\code{x} is \\code{0}, it can be ommitted. The\nfollowing are some examples.\n%\n\\begin{quote}\n\\begin{Verbatim}\nx1 <- integer()\nx2 <- integer(0)\nx3 <- integer(2)\ny1 <- double()\ny2 <- double(0)\ny3 <- double(2)\n\\end{Verbatim}\n\\end{quote}\n%\n\n\n\\section{Array Variables}\\label{array-variables.section}\n\nFor more than one dimension, the dump format uses a dimensionality\nspecification.  For example,\n%\n\\begin{quote}\n\\begin{verbatim}\ny <- structure(c(1,2,3,4,5,6), .Dim = c(2,3))\n\\end{verbatim}\n\\end{quote}\n%\nThis defines a $2 \\times 3$ array.  Data is stored in column-major\norder, meaning the values for \\code{y} will be as follows.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny[1,1] = 1     y[1,2] = 3     y[1,3] = 5    \ny[2,1] = 2     y[2,2] = 4     y[2,3] = 6\n\\end{Verbatim}\n\\end{quote}\n%\nThe \\code{structure} keyword just wraps a sequence of values and a\ndimensionality declaration, which is itself just a sequence of\nnon-negative integer values.  The product of the dimensions must equal\nthe length of the array.\n\nIf the values happen to form a contiguous sequence of integers,\nthey may be written with colon notation.  Thus the example above is\nequivalent to the following.\n%\n\\begin{quote}\n\\begin{verbatim}\ny <- structure(1:6, .Dim = c(2,3))\n\\end{verbatim}\n\\end{quote}\n%\nThe same applies to the specification of dimensions, though it is\nperhaps less likely to be used. In the above example,\nc(2,3) could be written as \\code{2:3}.\n\nArrays of more than two dimensions are written in a last-index major form.\nFor example, \n%\n\\begin{quote}\n\\begin{verbatim}\nz <- structure(1:24, .Dim = c(2,3,4))\n\\end{verbatim}\n\\end{quote}\n%\nproduces a three-dimensional \\code{int} (assignable to \\code{real})\narray \\code{z} with values\n%\n\\begin{quote}\n\\begin{verbatim}\nz[1,1,1] =  1   z[1,2,1] =  3   z[1,3,1] =  5\nz[2,1,1] =  2   z[2,2,1] =  4   z[2,3,1] =  6\n\nz[1,1,2] =  7   z[1,2,2] =  9   z[1,3,2] = 11\nz[2,1,2] =  8   z[2,2,2] = 10   z[2,3,2] = 12\n\nz[1,1,3] = 13   z[1,2,3] = 15   z[1,3,3] = 17\nz[2,1,3] = 14   z[2,2,3] = 16   z[2,3,3] = 18\n\nz[1,1,4] = 19   z[1,2,4] = 21   z[1,3,4] = 23\nz[2,1,4] = 20   z[2,2,4] = 22   z[2,3,4] = 24\n\\end{verbatim}\n\\end{quote}\n\nThe sequence of values inside \\code{structure} can also be\n\\code{integer(x)} or \\code{double(x)}. In particular, if one\nor more dimensions is zero, \\code{integer()} can be put inside\n\\code{structure}.  For instance, the following example is supported\nby the dump format.\n\n\\begin{quote}\n\\begin{verbatim}\ny <- structure(integer(), .Dim = c(2, 0))\n\\end{verbatim}\n\\end{quote}\n\n\n\\section{Matrix- and Vector-Valued Variables}\n\nThe dump format for matrices and vectors, including arrays of matrices\nand vectors, is the same as that for arrays of the same shape.\n\n\\subsection{Vector Dump Format}\n\nThe following three declarations have the same dump format for their\ndata.\n%\n\\begin{quote}\n\\begin{Verbatim}\nreal a[K];\nvector[K] b;\nrow_vector[K] c;\n\\end{Verbatim}\n\\end{quote}\n\n\\subsection{Matrix Dump Format}\n\nThe following declarations have the same dump format.\n%\n\\begin{quote}\n\\begin{Verbatim}\nreal a[M,N];\nmatrix[M,N] b;\n\\end{Verbatim}\n\\end{quote}\n\n\\subsection{Arrays of Vectors and Matrices}\n\nThe key to undertanding arrays is that the array indexing comes before\nany of the container indexing.  That is, an array of vectors is just\nthat --- provide an index and get a vector.  See the chapter on array and matrix types in the user's guide section of the languag emanual for more information.\n\nFor the dump data format, the following declarations have the same\narrangement.\n%\n\\begin{quote}\n\\begin{Verbatim}\nreal a[M,N];\nmatrix[M,N] b;\nvector[N] c[M];\nrow_vector[N] d[M];\n\\end{Verbatim}\n\\end{quote}\n%\nSimilarly, the following also have the same dump format.\n%\n\\begin{quote}\n\\begin{Verbatim}\nreal a[P,M,N];\nmatrix[M,N] b[P];\nvector[N] c[P,M];\nrow_vector[N] d[P,M];\n\\end{Verbatim}\n\\end{quote}\n\n\\section{Integer- and Real-Valued Variables}\n\nThere is no declaration in a dump file that distinguishes integer\nversus continuous values.  If a value in a dump file's definition of a\nvariable contains a decimal point (e.g., \\code{132.3}) or uses\nscientific notation (e.g., \\code{1.323e2}), Stan assumes that the\nvalues are real.\n\nFor a single value, if there is no decimal point, it may be assigned\nto an \\code{int} or \\code{real} variable in Stan.  An array value may\nonly be assigned to an \\code{int} array if there is no decimal point\nor scientific notation in any of the values.  This convention is\ncompatible with the way \\R writes data.\n\nThe following dump file declares an integer value for \\code{y}.\n%\n\\begin{quote}\n\\begin{Verbatim} \ny <- 2\n\\end{Verbatim}\n\\end{quote}\n% \nThis definition can be used for a Stan variable \\code{y} declared as\n\\code{real} or as \\code{int}.  Assigning an integer value to a real\nvariable automatically promotes the integer value to a real value.\n\nInteger values may optionally be followed by \\code{L} or \\code{l},\ndenoting long integer values.  The following example, where the type is\nexplicit, is equivalent to the above.\n%\n\\begin{quote}\n\\begin{Verbatim} \ny <- 2L\n\\end{Verbatim}\n\\end{quote}\n\nThe following dump file provides a real value for \\code{y}.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny <- 2.0\n\\end{Verbatim}\n\\end{quote}\n%\nEven though this is a round value, the occurrence of the decimal\npoint in the value, \\code{2.0}, causes Stan to infer that \\code{y} is\nreal valued.  This dump file may only be used for variables \\code{y}\ndeclared as real in Stan.\n\n\\subsection{Scientific Notation}\n\nNumbers written in scientific notation may only be used for real\nvalues in Stan.  R will write out the integer one million as\n\\code{1e+06}.  \n\n\n\n\n\\subsection{Infinite and Not-a-Number Values}\n\nStan's reader supports infinite and not-a-number values for scalar\nquantities (see the section of the reference manual section of the\nlanguage manaul for more information on Stan's numerical data types).\nBoth infinite and not-a-number values are supported by Stan's\ndump-format readers.\n%\n\\begin{center}\n\\begin{tabular}{r||c|c}\n{\\it Value} & {\\it Preferred Form} & {\\it Alternative Forms} \\\\ \\hline \\hline\npositive infinity & \\code{Inf} & \\code{Infinity},\n\\code{infinity}\n\\\\\nnegative infinity & \\code{-Inf} & \\code{-Infinity},\n\\code{-infinity}\n\\\\\nnot a number & \\code{NaN} & \n\\end{tabular}\n\\end{center}\n%\nThese strings are not case sensitive, so \\code{inf} may also be used\nfor positive infinity, or \\code{NAN} for not-a-number.\n\n\\section{Quoted Variable Names}\n\nIn order to support \\JAGS data files, variables may be double quoted.\nFor instance, the following definition is legal in a dump file.\n%\n\\begin{quote}\n\\begin{Verbatim}\n\"y\" <- c(1,2,3)\n\\end{Verbatim}\n\\end{quote}\n\n\\section{Line Breaks}\n\nThe line breaks in a dump file are required to be consistent with\nthe way \\R reads in data.  Both of the following declarations are\nlegal.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny <- 2\ny <-\n3\n\\end{Verbatim}\n\\end{quote}\n%\nAlso following \\R, breaking before the assignment arrow are not\nallowed, so the following is invalid.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny\n<- 2  # Syntax Error\n\\end{Verbatim}\n\\end{quote}\n\nLines may also be broken in the middle of sequences declared\nusing the \\code{c(...)} notation., as well as between the comma\nfollowing a sequence definition and the dimensionality declaration.\nFor example, the following declaration of a $2 \\times 2 \\times 3$\narray is valid.\n%\n\\begin{quote}\n\\begin{Verbatim}\ny <-\nstructure(c(1,2,3,\n4,5,6,7,8,9,10,11,\n12), .Dim = c(2,2,\n3))\n\\end{Verbatim}\n\\end{quote}\n%\nBecause there are no decimal points in the values, the resulting dump\nfile may be used for three-dimensional array variables declared as\n\\code{int} or \\code{real}.\n\n\\section{BNF Grammar for Dump Data}\n\nA more precise definition of the dump data format is provided\nby the following (mildly templated) Backus-Naur form grammar.\n\n{\\small \n\\begin{verbatim}\n definitions ::= definition+\n\n definition ::= name <- value optional_semicolon\n\n name ::= char* \n        | ''' char* ''' \n        | '\"' char* '\"'\n\n value ::= value<int> | value<double>\n\n value<T> ::= T \n            | seq<T>\n            | zero_array<T>\n            | 'structure' '(' seq<T> ',' \".Dim\" '=' seq<int> ')'\n            | 'structure' '(' zero_array<T> ',' \".Dim\" '=' seq<int> ')'\n\n seq<int> ::= int ':' int\n            | cseq<int>\n\n zero_array<int> ::= \"integer\" '(' <non-negative int>? ')'\n\n zero_array<real> ::= \"double\" '(' <non-negative int>? ')'\n\n seq<real> ::= cseq<real>\n\n cseq<T> ::= 'c' '(' vseq<T> ')'\n\n vseq<T> ::= T\n           | T ',' vseq<T>\n\\end{verbatim}\n}\n\\noindent\nThe template parameters \\code{T} will be set to either \\code{int} or\n\\code{real}.  Because Stan allows promotion of integer values to real\nvalues, an integer sequence specification in the dump data format may\nbe assigned to either an integer- or real-based variable in Stan.\n\n\n", "meta": {"hexsha": "57a0ea5fba5814621cc96a4735c4b53e944960a6", "size": 11346, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/docs/cmdstan-guide/dump-format.tex", "max_stars_repo_name": "mcol/cmdstan", "max_stars_repo_head_hexsha": "f85d83576280447bb3765d38c0dc765147833058", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-04T17:15:40.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-04T17:15:40.000Z", "max_issues_repo_path": "src/docs/cmdstan-guide/dump-format.tex", "max_issues_repo_name": "mcol/cmdstan", "max_issues_repo_head_hexsha": "f85d83576280447bb3765d38c0dc765147833058", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/docs/cmdstan-guide/dump-format.tex", "max_forks_repo_name": "mcol/cmdstan", "max_forks_repo_head_hexsha": "f85d83576280447bb3765d38c0dc765147833058", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9501187648, "max_line_length": 159, "alphanum_fraction": 0.7121452494, "num_tokens": 3365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.4168033495783606}}
{"text": "\\usepackage{algpseudocode}\n\\lstset{language=Python,numbers=left,resetmargins=true,xleftmargin=8pt,basicstyle=\\small,numberstyle=\\scriptsize}\n\\usetikzlibrary{svg.path}\n\\excludecomment{solution}\n\\input{mixed/fig/tikzsettings}\n\n\\title{Numerical Linear Algebra}\n\\author{Guido Kanschat}\n\\date{\\today}\n\n\\def\\esp#1{V_{#1}}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\\chapter{Dense Algebraic Eigenvalue Problems}\n\\begin{intro}\n  We refer to problems in linear algebra which allow storing the\n  complete matrix as \\define{dense linear algebra}. They are typically\n  characterized by dimensions into the hundreds, possibly thousands,\n  and any entry in the matrix may have a nonzero value. Such matrices\n  are typically stored as a rectangular or quadratic array of numbers,\n  and we can perform manipulations based on the matrix entry.\n\n  In contrast, we will turn to \\define{sparse linear algebra} in the\n  later chapters, where dimensions got up to millions and billions\n  ($10^9$). Since currently no computer on earth can store a matrix\n  with $10^{18}$ entries, those matrices will be characterized by the\n  fact that each row only contains very few nonzero entries, or that\n  the matrix is not stored, but only available algorithmically in the\n  form of a function performing the action $\\vx\\mapsto \\mata\n  \\vx$. Thus, access to and manipulation of matrix entries is not\n  possible, and we have to focus on methods only using the properties\n  of the matrix as a linear mapping.\n\\end{intro}\n\n\\section{Mathematical background}\n\\subsection{Definition of Eigenvalue Problems}\n\\input{def-evp}\n\\section{Well-posedness of the EVP and bounds on eigenvalues}\n\\input{conditioning}\n\n\\section{Vector iterations}\n\\input{vector-iterations}\n\n\\section{Subspace iterations and the QR method}\n\\input{qr}\n\n%\\input{orthopoly}\n\n\\chapter{Solving Large Sparse Linear Systems}\n\n\\section{Motivation: discretization of partial differential equations}\n\n\\input{sparse}\n\n\\section{Basic iterative methods}\n\\input{iterations}\n\n\\section{Krylov-space methods}\n\\input{Krylov}\n\n\\chapter{Large Sparse Eigenvalue Problems}\n\n\\appendix\n\\chapter{Basics from Linear Algebra}\n\\section{Bases and matrices}\n\\subsection{Matrix notation for bases}\n\\input{bases}\n\\subsection{Similarity transformations}\n\\input{similarity}\n\\section{Inner products and orthogonality}\n\\input{inner}\n\\section{Projections}\n\\input{projections}\n\n\\chapter{Basics from Numerical Analysis}\n\n\\section{QR decomposition}\n\\input{qr-decomposition}\n\n\\section{Matrix norms and spectral radius}\n\n\\begin{Definition}{spectral-radius}\n  The \\define{spectral radius} of a matrix $\\mata\\in\\Cnn$ is the\n  maximal absolute value of its eigenvalues, that is\n  \\begin{gather}\n    \\rho(\\mata) = \\max_{\\lambda\\in\\sigma(\\mata)} \\abs{\\lambda}.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma*}{spectral-radius}{Properties of the spectral radius}\n  For any matrix norm $\\norm\\cdot$ and for any matrix $\\mata\\in\\Cnn$ there holds\n  \\begin{gather}\n    \\rho(\\mata) = \\lim_{k\\to\\infty} \\norm{\\mata^k}^{1/k}.\n  \\end{gather}\n\n  The sequence $\\vx^{(k)} = A^k\\vx$ converges to zero for all\n  $\\vx\\in\\C^n$ if and only if $\\rho(\\mata)<1$.\n\n  For any $\\epsilon>0$\n  there is a matrix norm $\\norm\\cdot$ such that\n  \\begin{gather}\n    \\norm{\\mata} \\le (1+\\epsilon) \\rho(\\mata) \\qquad \\forall \\mata\\in\\Cnn.\n  \\end{gather}\n\\end{Lemma*}\n\n\\bibliographystyle{alpha}\n\\bibliography{all}\n\\printindex\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "ef31d46602f7d8e5de940f5782f9c3854a60da05", "size": 3450, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "nla/top.tex", "max_stars_repo_name": "guidokanschat/notes", "max_stars_repo_head_hexsha": "d13f1265ad5be4d584265b7579fc267df8ebe78a", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nla/top.tex", "max_issues_repo_name": "guidokanschat/notes", "max_issues_repo_head_hexsha": "d13f1265ad5be4d584265b7579fc267df8ebe78a", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-05-24T07:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-31T12:58:14.000Z", "max_forks_repo_path": "nla/top.tex", "max_forks_repo_name": "guidokanschat/notes", "max_forks_repo_head_hexsha": "d13f1265ad5be4d584265b7579fc267df8ebe78a", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-05-15T19:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-05T19:07:29.000Z", "avg_line_length": 29.7413793103, "max_line_length": 113, "alphanum_fraction": 0.7550724638, "num_tokens": 950, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.4168033390819023}}
{"text": "\\documentclass[oneside]{memoir}\n\\usepackage{fontspec}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{microtype}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{bm}\n\\usepackage{multirow}\n\\usepackage[euler-digits,euler-hat-accent]{eulervm}\n\\usepackage[bibstyle=numeric,backend=biber, sorting=none]{biblatex}\n\\addbibresource[datatype=bibtex]{../methods.bib}\n\n\\setlrmarginsandblock{3.5cm}{2.5cm}{*}\n\\setulmarginsandblock{2.5cm}{*}{1}\n\\checkandfixthelayout \n\n\\newcommand\\ddfrac[2]{\\frac{\\displaystyle #1}{\\displaystyle #2}}\n\n\\setmainfont{TeX Gyre Pagella}\n\n\\usepackage{xcolor}\n\n\\hypersetup{\n    pdfauthor={Tomáš Raček},\n    pdfpagemode=UseOutlines,\n    colorlinks,\n    linkcolor={red!50!black},\n    citecolor={blue!50!black},\n    urlcolor={blue!80!black}\n}\n\n\\def\\chapterheadstart{}\n\n\\begin{document}\n\n\\chapter*{Short description of the methods}\n\\addcontentsline{toc}{chapter}{Short description of the methods}\nThis section shortly describes the main idea of each method implemented in Atomic Charge Calculator~II. Methods here are ordered according to the publication date.\n\nFor clarity, we use unifying naming scheme (which may differ from the one used in the original publication); the symbols used throughout the chapter: $q_i$ stands for charge on $i$th atom, $Q$ is the total molecular charge, $N$ is the number of atoms in a molecule and $R_{i, j}$ represents the Euclidean distance between atoms $i$ and $j$.\n\n\\section*{DelRe}\n\\label{sec:methods_delre}\nMethods of Del Re \\cite{DelRe1958} starts with the definition of a linear system in the form:\n\n\\begin{equation}\n\\label{eq:delre_main}\n\\delta_i = \\delta_i^0 + \\sum_{j}\\gamma_{i, j}\\delta_j\n\\end{equation}\n\nwhere $j$ iterates over atoms bonded to $i$. $\\delta_i^0$ is an atom parameter, whereas $\\gamma_{i, j}$ is a bond parameter. Solving for $\\delta_i$ allow us to derive bond charges:\n\n\\begin{equation}\n\\label{eq:delre_bond}\nq_{i, j} = \\ddfrac{\\delta_i - \\delta_j}{2\\epsilon_{i, j}}\n\\end{equation}\n\nwhere $\\epsilon_{i, j}$ is another bond parameter. Finally, charge for each atom is computed as the sum of all involved bond charges. \n\n\\section*{PEOE}\n\\label{sec:methods_peoe}\n\nPartial equalization of orbital electronegativity \\cite{Gasteiger1978, Gasteiger1980} is an iterative scheme in which the charges are moved along the bonds from the more electropositive atom to the more electronegative one. The amount of charge shifted is proportional to the difference of the electronegativities of the bonding partners. As effective electronegativity is defined here as a function of charge:\n\n\\begin{equation}\n\\label{eq:peoe_chi}\n\\chi_i^\\alpha = A_i + B_iq^\\alpha + C_i(q_i^\\alpha)^2\n\\end{equation}\n\nits value for each atom must be recomputed as it enters the next iteration.\n\nThe main idea of a charge transfer is expressed through the following equation:\n\n\\begin{equation}\n\\label{eq:peoe_main}\nq_i^\\alpha = \\left(\\sum_j \\ddfrac{\\chi_j^\\alpha - \\chi_i^\\alpha}{D_i} + \\sum_k \\ddfrac{\\chi_i^\\alpha - \\chi_k^\\alpha}{D_k}\\right)\\cdot{\\left(\\ddfrac{1}{2}\\right)}^\\alpha\n\\end{equation}\n\nwhere $j$ are atoms bonded to atom $i$ with higher electronegativity and $k$ are atoms bonded to atom $i$ with lower electronegativity.\n\nSince the generated charges produce an electrostatic field which further hinders the charge transfer, the dampening factor $(1/2)^\\alpha$ was introduced to account for that fact. Usually, six iterations of \\ref{eq:peoe_chi} followed by \\ref{eq:peoe_main} are necessary for charges to converge.\n\nFinally, total atomic charge $q_i$ is the sum of charge transfers across all the iterations:\n\n\\begin{equation}\n\\label{eq:peoe_total}\nq_i = \\sum_\\alpha q_i^\\alpha\n\\end{equation}\n\n\\section*{Charge2}\n\\label{sec:methods_charge2}\n\nCharge2 \\cite{Abraham1982} is an iterative method in which charge increments from neighbor atoms are added to a central one.\n\n\\begin{align}\n\\label{eq:charge2_main}\nq_i &= q_i(\\alpha) + q_i(\\beta) + q_i(\\gamma)\\\\\nq_i(\\alpha) &= \\sum_j \\ddfrac{\\chi_j - \\chi_i}{a}\\\\\nq_i(\\beta) &= \\sum_k \\ddfrac{(\\chi_k - \\chi_H)P_i}{b}\\\\\nq_i(\\gamma) &= \\sum_l \\ddfrac{(\\chi_l - \\chi_H)P_i}{bc}\\\\\n\\end{align}\n\nwhere\n\\begin{equation}\n\\label{eq:charge2_aux}\nP_i = P_i^0\\left(1 + \\alpha(q_i^0 - q_i)\\right)\n\\end{equation}\n\nand $j, k$ and $l$ represents atoms one, two or three bonds apart from atom $i$, $a, b, c$ and $P^0$ are atom parameters, $q^0$ is a formal charge, $\\chi_H$ is an electronegativity of hydrogen, and $\\alpha$ is a common parameter.\n\n\\section*{EEM}\n\\label{sec:methods_eem}\nContrary to the partial electronegativity equalization methods like PEOE or MPEOE, full electronegativity equalization is fundamental to the Mortier's Electronegativity Equalization Method \\cite{Mortier1986}.\n\nAccording to the Sanderson's principle, the electronegativity of each atom gets equalized when atoms bond to form a molecule:\n\n\\begin{equation}\n\\label{eq:eem_sanderson}\n\\overline{\\chi} = \\chi_1 = \\ldots = \\chi_N\n\\end{equation}\n\nThe electronegativity of an atom in a molecule is expressed as:\n\n\\begin{equation}\n\\label{eq:eem_main}\n\\chi_i = A_i + B_iq_i + \\sum_{i \\neq j} \\ddfrac{q_j}{R_{i, j}}\n\\end{equation}\n\nwhere\n\n\\begin{align}\nA_i &= \\chi_i^0 + \\Delta\\chi_i\\\\\nB_i &= 2(\\eta_i^0 + \\Delta\\eta_i)\n\\end{align}\n\n$\\chi^0$ is an electronegativity of an isolated atom, $\\eta^0$ is a hardness of an isolated atom. $\\Delta$ symbols represent corrections for the molecular environment.\n\nFinally, charge conservation principle holds:\n\n\\begin{equation}\n\\label{eq:eem_sum}\nQ = \\sum_i q_i\n\\end{equation}\n\nRewriting \\ref{eq:eem_main} for every atom in molecule subject to \\ref{eq:eem_sanderson} and \\ref{eq:eem_sum} yields a system of $N + 1$ linear equations:\n\n\\begin{gather}\n\t\\label{eq:eem_system}\n\t\\begin{bmatrix}\n\t\tB_1\t\t\t    & R_{1,2}^{-1}  & \\cdots\t& R_{1,N}^{-1}\t& 1 \\\\\n\t\tR_{2,1}^{-1}\t& B_2\t\t\t& \\cdots\t& R_{2,N}^{-1}\t& 1 \\\\\n\t\t\\vdots\t\t\t& \\vdots\t\t& \\ddots\t& \\vdots\t\t& \\vdots \\\\\n\t\tR_{N,1}^{-1}\t& R_{N,2}^{-1}\t& \\cdots\t& B_N\t\t\t& 1 \\\\\n\t\t1\t\t\t    & 1\t\t    \t& \\cdots\t& 1\t\t    \t& 0 \\\\\n\t\\end{bmatrix}\n\t\\cdot\n\t\\begin{bmatrix}\n\t\tq_1 \\\\\n\t\tq_2 \\\\\n\t\t\\vdots \\\\\n\t\tq_N \\\\\n\t\t-\\overline{\\chi}\n\t\\end{bmatrix}\n\t=\n\t\\begin{bmatrix}\n\t\t-A_1\\\\\n\t\t-A_2\\\\\n\t\t\\vdots \\\\\n\t\t-A_N\\\\\n\t\tQ\\\\\n\t\\end{bmatrix}\n\\end{gather}\n\n\\section*{MPEOE}\n\\label{sec:methods_mpeoe}\n\nModified Partial Equalization of Orbital Electronegativity \\cite{No1990} differs from original \\hyperref[sec:methods_peoe]{PEOE} by expressing electronegativity as a linear function of charge, so that \\ref{eq:peoe_chi} is modified to:\n\n\\begin{equation}\n\\label{eq:mpeoe_chi}\n\\chi_i^\\alpha = A_i + B_iq^\\alpha\n\\end{equation}\n\nOther than that, the dampening factor $(1/2)^\\alpha$ is a now considered as a bond type dependent parameter $f_{x, y}$ changing \\ref{eq:peoe_main} to:\n\n\\begin{equation}\n\\label{eq:mpeoe_main}\nq_i^\\alpha = \\sum_j \\ddfrac{\\chi_j^\\alpha - \\chi_i^\\alpha}{D_i}f_{i, j}^\\alpha + \\sum_k \\ddfrac{\\chi_i^\\alpha - \\chi_k^\\alpha}{D_k}f_{i, k}^\\alpha\n\\end{equation}\n\n\\section*{QEq}\n\\label{sec:methods_qeq}\n\nCharge Equilibration (QEq) \\cite{Rappe1991} is similar to \\hyperref[sec:methods_eem]{EEM}. However, originally, it was meant as an iterative scheme as parameter $J_{i, i}$ for hydrogen was defined to be charge-dependent.\n\n\\begin{equation}\n\\label{eq:qeq_main}\n\\chi_i = \\chi_i^0 + J_{i, i}^0q_i + \\sum_{i \\neq j} J_{i,j}q_j\n\\end{equation}\n\nIn the original publication values for the Coulomb repulsion term $J_{i, j}$ were obtained using \\textit{ab-initio} calculations. To simplify the process, several empirical terms were developed to substitute $J_{i, j}$ with some simple expression.\n\nThe system of linear equations is constructed and solved for $q$ similarly to the one in \\hyperref[eq:eem_system]{EEM}.\n\n\\section*{ABEEM}\n\\label{sec:methods_abeem}\n\nAtom-bond Electronegativity Equalization Method \\cite{Yang1997} extends original \\hyperref[sec:methods_eem]{EEM} to also include bond electronegativities into the equalization scheme. Electronegativity of atom $i$ is expressed as:\n\n\\begin{equation}\n\\label{eq:abeem_atom}\n\\chi_i = A_i + B_iq_i + C_i\\sum_{i-j}q_{i-j} + k\\sum_{i \\neq j}\\ddfrac{q_j}{R_{i, j}} + k \\sum_{k-l \\neq i-j}\\ddfrac{q_{k-l}}{R_{i, k-l}}\n\\end{equation}\n\nwhere $A, B$ and $C$ are atom parameters, $k$ is a common parameter, $q_{i-j}$ denotes the charge on the bond $i-j$. Distance to a bond is computed to its center proportional to the covalent radius of the constituent atoms. Electronegativity of a bond $i-j$ has the following form:\n\n\\begin{equation}\n\\label{eq:abeem_bond}\n\\chi_{i-j} = A_{i-j} + B_{i-j}q_{i-j} + C_{i-j, i}q_i + D_{i-j, j}q_j + k\\sum_{k\\neq i, j}\\ddfrac{q_k}{R_{i-j, k}} + k\\sum_{k-l\\neq i-j}\\ddfrac{q_{k-l}}{R_{i-j,k-l}}\n\\end{equation}\n\nwhere $A, B, C$ and $D$ are bond parameters and $k$ is a common parameter.\n\nSolving the system of linear equations provides us with the atomic and bond charges. The bond charges are then added onto the constituent atoms proportionally to their covalent radii yielding the final atomic charges.\n\n\\section*{GDAC}\n\\label{sec:methods_gdac}\n\nFurther modification of \\hyperref[sec:methods_mpeoe]{MPEOE} method is coined Geometry-dependent Atomic Charges \\cite{Cho2001}. GDAC modifies the dampening term $f_{x, y}$ to be geometry dependent:\n\n\\begin{equation}\nf_{x, y} = 1 - \\ddfrac{R_{x, y}}{R_x^{\\text{vdw}} + R_y^{\\text{vdw}}}\n\\end{equation}\n\nwhere $R^{\\text{vdw}}_x$ stands for the van der Waals radius of atom $x$.\n\n\\section*{MGC}\n\\label{sec:methods_mgc}\n\nMolecular Graph Charge model (MGC) \\cite{Oliferenko2000, Oliferenko2001} uses molecular graph representation of the molecule as it is inspired by electrical circuits and Kirchhoff's current laws. Therefore, no atomic coordinates are employed.\n\nMGC constructs auxiliary matrix $\\bm{S}$ in the following way:\n\\begin{equation}\n\\label{eq:mgc_main}\n\\bm{S} = -\\bm{A} + \\bm{D} + \\bm{I}\n\\end{equation}\n\nwhere $\\bm{A}$ is a connectivity matrix, $\\bm{D}$ represents diagonal degree matrix and $\\bm{I}$ is a standard identity matrix.\n\nEqualized electronegativities are obtained from those of isolated atoms as a solution to the system of linear equations.\n\n\\begin{equation}\n\\label{eq:mgc_system}\n\\bm{S\\chi} = \\bm{\\chi}^0\n\\end{equation}\n\nFinally, partial atomic charges are computed as a difference between equalized and standard electronegativities of respective atoms, divided by the average electronegativity $\\chi_M$ (geometric average).\n\n\\begin{equation}\n\\label{eq:mgc_charges}\n\\bm{q} = \\ddfrac{\\bm{\\chi} - \\bm{\\chi}^0}{\\bm{\\chi}_M}\n\\end{equation}\n\n\\section*{SFKEEM}\n\\label{sec:methods_sfkeem}\n\nSelfconsistent Functional Kernel Equalized Electronegativity Method \\cite{Chaves2006} develops on \\hyperref[sec:methods_eem]{EEM}'s main idea. However, it incorporates different hardness matrix. The electronegativity equalization principle in SFKEEM is expressed as:\n\n\\begin{equation}\n\\label{eq:sfkeem_main}\n\\chi_i = A + 2B_iq_i + \\sum_{i \\neq j} 2\\sqrt{B_iB_j}\\mathrm{sech}(\\sigma R_{i, j})\n\\end{equation}\n\nwhere $A, B$ and $\\sigma$ are empirical parameters and $\\mathrm{sech}$ is a hyperbolic secant function.\n\n\\section*{KCM}\nKirchhoff Charge Model \\cite{Yakovenko2008} builds a Laplacian matrix $\\bm{L}$ as:\n\n\\begin{equation}\n\\label{eq:ksm_laplacian}\n\\bm{L} = \\bm{B}^T \\bm{W} \\bm{B}\n\\end{equation}\n\nwhere $\\bm{B}$ is an incidence matrix and $\\bm{W}$ is a diagonal \"softness\" matrix with elements $w_{i, i} = 1 / (\\eta_i + \\eta_j)$, where $\\eta$ stands for hardness of an atom.\n\nAtomic charges are derived using the following expression:\n\n\\begin{equation}\n\\label{eq:kcm_charges}\n\\bm{q} = (\\bm{L}^{-1} - \\bm{I})\\bm{\\chi^0}\n\\end{equation}\n\nwhere $\\bm{L}^{-1}$ is an inverse of $\\bm{L}$ and $\\bm{\\chi^0}$ represents a vector of electronegativities of isolated atoms.\n\n\\section*{DENR}\n\\label{sec:methods_denr}\n\nDynamic electronegativity relaxation \\cite{Shulga2008} is an iterative 2D scheme in which charges are derived using a Laplacian matrix:\n\n\\begin{equation}\n\\label{eq:denr_main}\n\\bm{q}^{(n + 1)} = (\\bm{I} + c\\Delta t\\cdot \\bm{B}_0)^{-1}\\cdot(\\bm{q}^{(n)} - c\\Delta t\\cdot \\bm{a}_0)\n\\end{equation}\n\nwhere $\\bm{B}_0 = \\bm{L}\\bm{\\eta}_0$ and $\\bm{a}_0 = \\bm{L}\\bm{\\chi}_0$. Note that $\\bm{\\eta}_0$ is a diagonal matrix of atomic hardnesses.\n\n\\section*{TSEF}\n\\label{sec:methods_tsef}\n\nTopologically Symmetrical Energy Function \\cite{Shulga2008} has electronegativity equalization principle as its base but changes off-diagonal term to include bond distance rather than Euclidean distance making TSEF conformationally independent.\n\n\\begin{equation}\n\\label{eq:tsef_main}\n\\phi_{i, j} = \\alpha \\cdot K\\mathrm{(MDP_{i, j})}\\cdot\\ddfrac{1}{0.84\\cdot\\mathrm{MDP}_{i, j} + 0.46}\n\\end{equation}\n\nwhere $\\mathrm{MDP}$ stands for \\textit{minimal distance path}, i.e., minimal number of bonds between two atoms, $K$ is parameter and $\\alpha$ is a unit conversion factor.\n\n\\section*{SMP/QEq}\n\\label{sec:methods_smpqeq}\n\nSelf-Consistent Charge Equilibration Method \\cite{Zhang2009} builds upon the idea of the original \\hyperref[sec:methods_qeq]{QEq}, electronegativity of an atom is formalized as a function of charge, thus the whole scheme is a iterative one. The main equation follows:\n\n\\begin{equation}\n\\label{eq:smpqeq_main}\n\\chi_i(q_i) = A_i + 2\\lambda(q_i)q_i + \\sum_{i\\neq j} J_{i, j}q_j\n\\end{equation}\n\nwhere\n\n\\begin{equation}\n\\label{eq:smpqeq_lambda}\n\\lambda(q_i) = B_i + C_iq_i + D_i(q_i)^2\n\\end{equation}\n\nand\n\n\\begin{equation}\n\\label{eq:smpqeq_J}\nJ_{i, j} = \\left(\\ddfrac{1}{(2\\sqrt{B_iB_j})^3} + R_{i,j}^3\\right)^{-1/3}\n\\end{equation}\n\nwhere $A, B, C$ and $D$ are atom parameters.\n\n\\section*{VEEM}\n\\label{sec:methods_veem}\n\nValence electrons equilibration method \\cite{Wu2011} calculates atomic charges based on the number of valence electrons of individual atoms and atomic groups.\n\nFirst, equalized electronegativity is calculated for the whole molecule:\n\n\\begin{equation}\n\\label{eq:veem_en}\n\\chi_{ve} = \\ddfrac{\\sum_i \\chi_iN_{ve, i}}{\\sum_i N_{ve, i}}\n\\end{equation}\n\nwhere $\\chi_i$ is an electronegativity of isolated atom $i$; $N_{ve, i}$ stands for the number of valence electrons of atom $i$.\n\nFinally, the partial atomic charge of atom $i$ is computed as:\n\n\\begin{equation}\n\\label{eq:veem_q}\nq_i = N_{ve, i}\\ddfrac{\\chi_{ve} - \\chi_i}{\\chi_{ve}}\n\\end{equation}\n\n\\section*{EQeq}\n\\label{sec:methods_eqeq}\nExtended charge equilibration method \\cite{Wilmer2012} builds upon original \\hyperref[sec:methods_qeq]{QEq} scheme, which is modified to take the following form (the simplest, non-periodic case without different charge centers):\n\n\\begin{equation}\n\\label{eq:eqeq_main}\n\\chi_i = \\chi_i^0 + J_i^0q_i + \\ddfrac{K}{2}\\sum_{i \\neq j} q_j\\left(\\ddfrac{1}{R_{i, j}} + O_{i, j}\\right)\n\\end{equation}\n\nwhere\n\\begin{eqnarray}\n\\label{eq:eqeq_default}\n\\chi_i^0 &=& \\ddfrac{\\mathrm{IP}_i + \\mathrm{EA}_i}{2}\\\\\nJ_i^0 é &=& \\mathrm{IP}_i - \\mathrm{EA}_i\n\\end{eqnarray}\n\nK is a constant; IP and EA stand for ionization potential and electron affinity, respectively, and\n\n\\begin{equation}\n\\label{eq:eqeq_overlap}\nO_{i, j} = \\exp{\\left(-\\ddfrac{J_{i, j}^2R_{i, j}^2}{K^2}\\right)}\\cdot\\left(\\ddfrac{J_{i, j}}{K} - \\ddfrac{J_{i, j}^2R_{i, j}}{K^2} - \\ddfrac{1}{R_{i, j}}\\right)\n\\end{equation}\n\nwhere $J_{i, j}$ is a geometric mean of $J_i^0$ and $J_j^0$.\n\n\\section*{EQeq+C}\nBond-order-corrected Extended Charge Equilibration Method \\cite{MartinNoble2015} follows exactly the same procedure as \\hyperref[sec:methods_eqeq]{EQeq}, however, after the computation is done, some corrections are added to the original charges, i.e.:\n\n\\begin{equation}\n\\label{eq:eqeqc_main}\nq_i = q_i^0 + \\sum_{j \\neq i} T_{i, j}B_{i, j}\n\\end{equation}\n\nwhere $q_i^0$ is original charge from EQeq, and\n\n\\begin{eqnarray}\n\\label{eq:eqeqc_terms}\nT_{i, j} &=& D_i - D_j\\\\ \nB_{i, j} &=& \\exp\\left[-\\alpha\\left(R_{i, j} - r_i - r_j\\right)\\right]\n\\end{eqnarray}\n\nwhere $D$ is an atom parameter, $\\alpha$ is a common parameter and $r$ stands for covalent radius.\n\n\\section*{SQE}\n\n\nSplit-charge Equilibrium method \\cite{Nistor2006} is based on the electronegativity equalization principle. However, unlike EEM or QEq, it does not perform equalization on a level of individual atoms but switches the problem to a bond domain by defining \\textit{split-charges}, i.e., charges located on the bonds. The final atomic charge as a sum of the split-charges of the bonds that a particular atom forms. Formally, the atomic charge on atom $i$ is expressed as:\n\n\\begin{gather}\n    \\label{eq:sqe_sum}\n    q_i = \\sum_{j \\in \\mathrm{BA}(i)} p_{i, j}\n\\end{gather}\n\nwhere $\\mathrm{BA}(i)$ is a set of atoms bonded to atom $i$, and $p_{i, j}$ is a split-charge on the bond $i - j$.\n\nSQE method written in the form of the system of linear equations is described by Equation~\\ref{eq:sqe}:\n\n\\begin{gather}\n    \\label{eq:sqe}\n    \\left(THT^T + \\mathrm{diag}(\\kappa)\\right)q_{sp} = T\\chi\n\\end{gather}\n\nwhere $q_{sp}$ is a vector of split-charges, $T$ is an incidence matrix describing the molecular topology, $\\mathrm{diag}(\\kappa)$ is a diagonal matrix with bond hardnesses, $\\chi$ is a vector of atomic electronegativities, and $H$ is a hardness matrix that describes the interactions between the atoms.\n\nTo reconstruct the atomic charges $q$ from the split-charges, the following transformation is made:\n\n\\begin{gather}\n    \\label{eq:sqe_atomic}\n    q = T^Tq_{sp}\n\\end{gather}\n\n\\section*{SQE+q0}\nSQE+q0 \\cite{Verstraelen2012}, an extension to SQE, adds formal charges to work as initial seeds for the computation of partial atomic charges which might help in molecules that contain charged functional groups. This change is expressed in Equations~\\ref{eq:sqe_q0} and \\ref{eq:sqe_q0_atomic}:\n\n\\begin{gather}\n    \\label{eq:sqe_q0}\n    \\left(THT^T + \\mathrm{diag}(\\kappa)\\right)q_{sp} = T(\\chi - Hq_0 + \\eta * q_0)\n\\end{gather}\n\nwhere $q_0$ is a vector of initial formal charges, $\\eta$ is a vector of atomic hardnesses (i.e., $J_{i, i}$ terms), and $*$ is an element-wise product. Equation~\\ref{eq:sqe_atomic} is then trivially modified to:\n\n\\begin{gather}\n    \\label{eq:sqe_q0_atomic}\n    q = T^Tq_{sp} + q_0\n\\end{gather}\n\n\\section*{SQE+qp}\nSQE+qp replaces the formal charges $q_0$ with the parameterized ones $q_p$. To preserve the total charge of the molecule, these parameterized values must be normalized first:\n\n\\begin{align}\n    \\label{eq:sqe_qp_norm}\n    q_{pn} &= q_p - \\frac{1}{N}\\left(1^Tq_p - Q\\right)\\\\\n\\end{align}\n\nwhere $1^T$ is a row vector of ones and $N$ is the number of atoms in a molecule. The rest of the procedure is analogous as in SQE+q0:\n\n\\begin{align}\n    \\label{eq:sqe_qp}\n    \\left(THT^T + \\mathrm{diag}(\\kappa)\\right)q_{sp} &= T(\\chi - Hq_{pn} + \\eta * q_{pn})\\\\\n    q &= T^Tq_{sp} + q_{pn}\n\\end{align}\n\n\n\\chapter*{Complexity of implemented approaches}\n\\addcontentsline{toc}{chapter}{Complexity of implemented approaches}\n\nThe following table summarizes information about computational costs of the implemented methods, both in terms of time and memory complexity (expressed using ${\\mathcal O}$ notation). The symbol $N$ denotes the number of atoms, $M$ is the number of bonds.\n\\bigskip\n\n\\begin{center}\n\\begin{tabular}{lll}\n\\toprule\nMethod & Time & Memory\\\\\n\\midrule\nDelRe & $N^3$ & $N^2$\\\\\nPEOE  & $N + M$ & $N$\\\\\nCharge2 & $N + M$ & $1$\\\\\nEEM* & $N^3$ & $N^2$\\\\\nMPEOE & $N + M$& $N$\\\\\nQEq* & $N^3$ & $N^2$ \\\\\nABEEM & $(N + M)^3$ & $(N + M)^2$\\\\\nGDAC & $N + M$ & $N$\\\\\nMGC & $N^3$& $N^2$\\\\\nSFKEEM* & $N^3$& $N^2$\\\\\nKCM & $N^3$ & $N^2$\\\\\nDENR & $N^3$& $N^2$\\\\\nTSEF & $N^3$ & $N^2$ \\\\\nSMP/QEq* & $N^3$& $N^2$\\\\\nVEEM & $N$& $1$ \\\\\nEQeq* & $N^3$ & $N^2$ \\\\\nEQeq+C* & $N^3$ & $N^2$\\\\\nSQE & $M^3$ & $M^2$\\\\\nSQE+q0 & $M^3$ & $M^2$\\\\\nSQE+qp & $M^3$ & $M^2$\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\n\\bigskip\n\nMethods marked with * can utilize \\textit{cutoff} and \\textit{cover} complexity reductions described in the next section.\n\n\\chapter*{Assessment of charges quality}\n\\addcontentsline{toc}{chapter}{Assessment of charges quality}\n\nIn order to compare two sets of charges, two descriptors are commonly used. The first one is the Pearson's correlation coefficient ($R$); the second one is the root mean square deviation ($RMSD$). In the following sections, we denote the charge sets as $X = (x_1, \\ldots, x_n)$ and $Y = (y_1, \\ldots, y_n)$, $\\overline{x}$ and $\\overline{y}$ represent the arithmetic means of $x_i$ and $y_i$ values, respectively.\n\n\\section*{Pearson's correlation coefficient (R)}\n\nPearson's correlation coefficient describes the linear dependence between two sets of values. Its value ranges from -1 (negative correlation) through 0 (no correlation) to 1 (positive correlation). Sometimes, the value of squared Pearson's correlation coefficient ($R^2$) is used.\n\n\\begin{align*}\nR(X, Y) = \\ddfrac{\\sum_{i = 1}^n (x_i - \\overline{x})\\cdot(y_i - \\overline{y})}{\\sqrt{\\sum_{i = 1}^n(x_i - \\overline{x})^2}\\cdot\\sqrt{\\sum_{i = 1}^n(y_i - \\overline{y})^2}}\n\\end{align*}\n\n\\section*{Root mean square deviation (RMSD)}\n\nRoot mean square deviation is another measure which can be used to compare two sets of values. When RMSD is zero, the sets are identical. Otherwise, a smaller value indicates higher similarity.\n\n\\begin{align*}\nRMSD(X, Y) =\\sqrt{ \\ddfrac{1}{n}\\sum_{i = 1}^n (x_i - y_i)^2}\n\\end{align*}\n\n\\chapter*{Cutoff and cover approaches}\n\\addcontentsline{toc}{chapter}{Cutoff and cover approaches}\n\nSolving the electronegativity equalization system of linear equations can be troublesome for very large structures as it requires, in general, ${\\mathcal O}(N^3)$ steps and ${\\mathcal O}(N^2)$ memory. The original AtomicChargeCalculator (ACC) introduced two \\textit{divide and conquer} complexity reduction algorithms to overcome this issue. Since ACC only supports EEM, these approaches were called \\textit{EEM Cutoff} and \\textit{EEM Cover}. ACC~II extended these approaches to other applicable methods, referencing them simply as \\textit{cutoff} and \\textit{cover}.\n\nHere, we provide the description of these approaches as stated in the ACC publication's \\cite{Ionescu2015} \\href{https://static-content.springer.com/esm/art%3A10.1186%2Fs13321-015-0099-x/MediaObjects/13321_2015_99_MOESM1_ESM.pdf}{Additional file 1}:\n\n\\begin{quote}\n\n\\section*{EEM Cutoff}\nFor each atom in the molecule, ACC generates a fragment made up of all atoms within a cutoff\nradius $R$ of the original atom. The values of the inter-atomic distances and EEM parameters are\nobtained in the same way as when solving the full EEM matrix. The total fragment charge $Q_F$\nis a quota of the total molecular charge $Q$, proportional to the number of atoms in the fragment\n($N_F$), and irrespective of the nature of these atoms:\n\n\\begin{align*}\nQ_F = \\frac{Q\\cdot N_F}{N}\n\\end{align*}\n\nThen ACC solves the EEM matrix equation for this fragment, and returns the charge for the\natom used when generating the fragment. The same procedure is applied for all fragments,\nobtaining a set of charges for all the atoms in the molecule. Then, each atomic charge $q_i$\nis corrected by the addition of:\n\n\\begin{align*}\n\\frac{Q - \\sum_{i = 1}^N q_i}{N}\n\\end{align*}\n\nso that the sum of all atomic charges equals the total molecular charge $Q$.\n\n\\section*{EEM Cover}\nThe EEM Cover approach builds on the principles of EEM Cutoff to split the EEM matrix into\nsmaller matrices. However, EEM Cover generates fragments only for a subset of atoms in the\nmolecule. The procedure selects fragment-generating atoms so that: (i) no two such atoms are\nconnected to each other, and (ii) each atom in the molecule has at least one neighbor (within\ntwo bonds) which was selected. This procedure ensures that each atom in the molecule will\neventually contribute to at least one fragment, and thus the entire volume of the molecule is\ncovered. ACC solves the EEM matrix equation for each fragment, and returns a list of charge\ncontributions for all atoms encountered in the calculations. The charge on each atom in the\nmolecule is then computed as the sum of its charge contributions from all fragments where the\natom is present. Further, each atomic charge $q_i$ is corrected by the addition of:\n\n\n\\begin{align*}\n\\frac{Q - \\sum_{i = 1}^N q_i}{N}\n\\end{align*}\n\nso that the sum of all atomic charges equals the total molecular charge $Q$.\n\n\\end{quote}\n\n\\section*{Time and space complexity}\n\nFor a given sphere radius $R$, these approaches effectively reduce the time and space complexity to ${\\mathcal O}(R^6N + R^2N\\log N)$ and ${\\mathcal O}(R^4N + N\\log N)$, respectively. \\cite{Ionescu2015}\n\n\\section*{Accuracy}\n\nEmploying these approximative schemes may introduce some loss of accuracy when comparing with the original charges. Their assessment was made for original ACC for EEM \\cite{Ionescu2015} or in \\cite{Sehnal2015} where author states that \"according to tests, the EEM Cover method produces results that are practically identical to solving the EEM matrix for the full original system\". Here, we present a simplified\\footnote{Only for $R = 12~$\\AA\\,, which is used in ACC II.} version of the table taken from \\cite{Sehnal2015}:\n\n\\begin{table}[h]\n\\renewcommand{\\thetable}{1}\n\\begin{center}\n\\begin{tabular}{lrrrr}\n\\toprule\n\\textbf{PDB ID} & \\textbf{\\# of atoms} & \\textbf{Total charge} & \\textbf{R} & \\textbf{RMSD}\\\\\n\\midrule\n\\multirow{3}{*}{1lfg} & \\multirow{3}{*}{5884}  &   0 & 0.9998 & 0.0080\\\\\n                      &                        & -10 & 0.9999 & 0.0064\\\\\n                      &                        &   8 & 0.9997 & 0.0094\\\\\n\\midrule\n\\multirow{3}{*}{35tu} & \\multirow{3}{*}{13934} &   0 & 0.9999 & 0.0039\\\\\n                      &                        & -10 & 1.0000 & 0.0034\\\\\n                      &                        &   8 & 0.9999 & 0.0045\\\\\n\\midrule\n\\multirow{3}{*}{1tye} & \\multirow{3}{*}{21013} &   0 & 1.0000 & 0.0033\\\\\n                      &                        & -10 & 1.0000 & 0.0030\\\\\n                      &                        &   8 & 0.9999 & 0.0037\\\\\n\\midrule\n\\multirow{3}{*}{1aoc} & \\multirow{3}{*}{28708} &   0 & 1.0000 & 0.0021\\\\\n                      &                        & -10 & 1.0000 & 0.0019\\\\\n                      &                        &   8 & 1.0000 & 0.0024\\\\\n\\bottomrule\n\\end{tabular}\n\\caption{Comparison of Full EEM vs. EEM Cover method for computing partial atomic charges. Parameters EX-NPA\\_6-31Gd\\_gas \\cite{Ionescu2013} were used in the computation.}\n\\end{center}\n\\end{table}\n\n\\chapter*{Notes on the implementation}\n\\addcontentsline{toc}{chapter}{Notes on the implementation}\n\nFollowing section presents some notes and discusses differences in implementation of the some methods compared to the description used in original publication.\n\n\\section*{GDAC}\nOnly a subset of the parameters is used.\n\n\\section*{QEq}\nThe scheme is not iterative, expression for $J_{i,j}$ is taken from \\cite{Louwen1998} as in \\hyperref[sec:methods_smpqeq]{SMP/QEq}:\n\n\\begin{equation}\n\\label{eq:qeq_louwen}\nJ_{i, j} = \\left(\\ddfrac{1}{(2\\sqrt{B_iB_j})^3} + R_{i,j}^3\\right)^{-1/3}\n\\end{equation}\n\n\\section*{EQeq and EQeq+C}\nOnly the non-periodic case without non-zero charge centers is supported.\n\n\\section*{SQE, SQE+q0, SQE+qp}\nThe off-diagonal term in the hardness matrix has the form following form taken from \\cite{Verstraelen2013}:\n\n\\begin{gather}\nJ_{i, j} = \\frac{\\mathrm{erf}{\\left(R_{i, j}{({2w_i^2 + 2w_j^2})^{-1/2}}\\right)}}{R_{i, j}}\n\\end{gather}\n\n\\chapter*{Applications of charges}\n\\addcontentsline{toc}{chapter}{Applications of charges}\n\nPartial atomic charges, obtained by empirical charge calculation methods, can be applied for example in the following fields:\n\n\\begin{itemize}\n\\item descriptors for QSAR and QSPR modelling \\cite{Svobodova2011, Varekova2013, Geidl2015, Dixon1993, Zhang2006, Gross2002, Ghafourian2000, Dudek2006, Karelson1996}\n\\item pharmacophore design \\cite{Todeschini2008, Galvez1994, Stalke2011}\n\\item virtual screening \\cite{Mannhold2006, Macdougall2007, Clement2000}\n\\item molecular docking \\cite{Park2006, Nebgen2018, Rimac2017}\n\\item similarity searches \\cite{Kearsley1996, Nikolova2003, Holliday2003}\n\\item conformers generation \\cite{Vainio2007}\n\\item molecular dynamics \\cite{Rappe1991, Chenoweth2008, Nejad2018, Lee2018}\n\\item study of mechanisms of chemical actions \\cite{Ionescu2012, Rimac2017, Wheeler2019}\n\\end{itemize}\n\n\\printbibliography\n\\end{document}\n", "meta": {"hexsha": "e005c26d16bf85ba16a6f83f93639439dae04633", "size": 28016, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "resources/methods/methods.tex", "max_stars_repo_name": "krab1k/ChargeCompute", "max_stars_repo_head_hexsha": "a44fa9beb8112e40173047546e1ef60e55dbdc13", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T00:19:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-16T02:18:31.000Z", "max_issues_repo_path": "resources/methods/methods.tex", "max_issues_repo_name": "krab1k/ChargeCompute", "max_issues_repo_head_hexsha": "a44fa9beb8112e40173047546e1ef60e55dbdc13", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "resources/methods/methods.tex", "max_forks_repo_name": "krab1k/ChargeCompute", "max_forks_repo_head_hexsha": "a44fa9beb8112e40173047546e1ef60e55dbdc13", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-12-03T13:10:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-01T05:47:52.000Z", "avg_line_length": 42.3842662632, "max_line_length": 568, "alphanum_fraction": 0.7163049686, "num_tokens": 9076, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4167278730588962}}
{"text": "\\documentclass[bigger]{beamer}\n\n\\input{header-beam} % change to header-handout for handouts\n\n% ====================\n\\title[Lecture 18]{Logic I F13 Lecture 18}\n\\date{November 19, 2013}\n% ====================\n\n\\include{header}\n\n\\setlength{\\fitchprfwidth}{14em}\n\n\\section{Review}\n\n\\subsec{Rules for $\\forall$}{\n\n\\fitchctx{\n\\nline[$k.$]{\\forall x\\, A(x)}\\\\\n\\fpline{\\quad A(b)}[\\lalle{$k$}]\n}\n\n\\bigskip \n\n\\fitchctx{\n\\boxedsubproof[$m$.]{c}{}{\\ellipsesline \\\\ \\nline[$n.$]{A(c)}}\n\\fpline{\\quad \\forall x\\,A(x)}[\\lalli{$m$--$n$}]}\n\n\\bit\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Rules for $\\forall$}{\n\\setlength{\\fitchctxwidth}{13em}\n\n\\fitchctx{\n\\boxedsubproof[$m$.]{c}{A(c)}{\\ellipsesline \\\\ \\nline[$n.$]{B(c)}}\n\\fpline{\\quad \\forall x(A(x) \\to B(x))}[\\lalli{$m$--$n$}]}\n\n\n\\bit\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Rules for $\\exists$}{\n\n\\fitchctx{\\pline[$m.$]{A(b)}\\\\\n\\fpline{\\quad \\exists x\\, A(x)}[\\lexii{$m$}]}\n\n\\bigskip\n\n\\fitchctx{\n\\pline[$k$.]{\\exists x\\, A(x)}\\\\\n\\boxedsubproof[$m$.]{c}{A(c)}{\\ellipsesline \\\\ \\nline[$n.$]{B}}\n\\fpline{\\quad B}[\\lexie{k}{$m$--$n$}]}\n\\bit\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Everybody Loves my Baby}{\n\n\\setlength{\\fitchprfwidth}{13em}\n\n\\href{http://www.youtube.com/watch?v=cxS0FpTNir0}{Red Nichols (1935)}\\\\\n\\href{http://www.youtube.com/watch?v=TyD9rZ2bOq4}{Doris Day (1955)}\\\\\n\\href{http://www.youtube.com/watch?v=Y4wWpeGaNBw}{Brigitte Bardot (1968)}\n\n\\pause\n\\bigskip\n\n\\fitchprf{\\tline{Everybody loves my baby}\\\\\n\\tline{My baby loves noone but me}}{\n\\tline{My baby is me}}\n\n\\bigskip\n\n\\fitchprf{\\pline{\\forall x\\, Loves(x, b)}\\\\\n\\pline{\\forall x(Loves(b, x) \\lif x = i)}}{\n\\pline{b = i}}\n}\n\n\\section{Strategies for Proofs with Quantifiers}\n\n\\setlength{\\fitchprfwidth}{8em}\n\n\\subsec{Strategy for Proving Universal Sentences}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline\\\\\n\\pline[5.]{\\forall x\\, A(x)}[?]\n} &\nSuppose we want to prove $\\sf\\forall x\\, A(x)$.  For this, we have to use $\\forall$Intro.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Proving Universal Sentences}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{}}{\n\\boxedsubproof[2.]{c}{}{\n\\ellipsesline\\\\\n\\pline[4.]{A(c)}\n}\n\\pline[5.]{\\forall x\\, A(x)}[\\lalli{2--4}]\n} &\nFor $\\forall$Intro, we need a subproof that ends with a substitution instance of\n$\\sf \\forall x\\, A(x)$ where we replace every free occurrence of x in\nA(x) by a \\emph{new} constant c. c has to be boxed in the assumption\nline.  This always works, so do it earlier rather than later.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Proving Universal Sentences}{\n\n\\setlength{\\fitchprfwidth}{10em}\n\n\\begin{tabular}{@{}l@{}p{10em}@{}}\n\\fitchprf{\\pline[1.]{}}{\n\\boxedsubproof[2.]{c}{A(c)}{\n\\ellipsesline\\\\\n\\pline[4.]{B(c)}\n}\n\\pline[5.]{\\forall x(A(x) \\to B(x))}[\\lalli{2--4}]\n} &\nIf the wff after the universal quantifier is a conditional, we can use the special form of $\\forall$Intro instead of using a $\\to$Intro inside the boxed subproof.\n\\end{tabular}\n}\n\n\n\\setlength{\\fitchprfwidth}{8em}\n\n\\subsec{Strategy for Proving Existential Sentences}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline\\\\\n\\pline[3.]{\\exists x\\, A(x)}[?]\n} &\nWe want to prove $\\sf \\exists x\\, A(x)$.  For this, we can often use\n$\\exists$Intro.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Proving Existential Sentences}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline\\\\\n\\pline[2.]{A(b)}\\\\\n\\pline[3.]{\\exists x\\, A(x)}[\\lexii{2}]\n} &\nFor $\\exists$Intro, we need a substitution instance A(b) of A(x).\nAny b will do. But save this strategy for last, just like $\\lor$Intro. Often you can only  prove A(b) if\nyou're in a subproof, and b is a boxed constant in a surrounding subproof.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Proving Existential Sentences}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{}}{ \\ellipsesline\\\\ \\pline[2.]{A(b,\n    b)}\\\\ \\pline[3.]{\\exists x\\, A(x,\n    b)}[\\lexii{2}]\\\\ \\pline[4.]{\\exists x\\, A(b,\n    x)}[\\lexii{2}]\\\\ \\pline[5.]{\\exists y\\exists x\\, A(y,\n    x)}[\\lexii{4}]\\\\ \n\\pline[6.]{\\exists x\\, A(x, x)}[\\lexii{2}]} & If b occurs more than once in your sentence,\nyou don't have to replace all occurrences of b by x.\n\\end{tabular}\n}\n\\subsec{Strategy for Using Existential Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\exists x\\, A(x)}}{\n\\ellipsesline\\\\\n\\pline[4.]{B}[?]\n} &\nSuppose you want to prove some sentence B, and you are ready to use\n$\\sf\\exists x\\, A(x)$. ($\\sf\\exists x\\, A(x)$ might be something you've\nproved, or is a premise, or an assumption of a subproof).\n\\end{tabular}\n}\n\n\\subsec{Strategy for Using Existential Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\exists x\\, A(x)}}{\n\\boxedsubproof[2.]{c}{A(c)}{\n\\ellipsesline\\\\\n\\pline[3.]{B}\n}\n\\pline[4.]{B}[\\lexie{1}{2--3}]\n} &\nTo get B from $\\sf\\exists x\\, A(x)$, set up a subproof where you assume\nA(c). c has to be \\emph{new} (in particular, it can't be in B), and boxed.\nIn the subproof, look for a proof of B.  This always works, so do it earlier rather than later.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Using Universal Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\forall x\\, A(x)}}{\n\\ellipsesline} &\nTo use a universal sentence which you've proved, assumed, or is one of\nyour premises, use $\\forall$Elim. \n\\end{tabular}\n}\n\n\\subsec{Strategy for Using Universal Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\forall x\\, A(x)}}{\n\\ellipsesline \\\\\n\\pline[$7$.]{A(b)}[\\lalle{1}]\n} &\nTo do that, you can write down any substitution instance of A(x), i.e.,\nA(b) where b is any constant. You can always do that, but it's best to wait until you know which A(b) you need.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Using Universal Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\forall x\\forall y\\forall z\\, A(x, y, z)}}{\n\\ellipsesline \\\\\n\\pline[$7$.]{A(a, b, c)}[\\lalle{1}]\n}&\n\\raggedright If there is more than one $\\forall$ (they have to be\ntogether ``in a block''), you can replace all variables at once. Here\nwe replaced x by a, y by b, and z by c.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Using Universal Premises}{\n\n\\begin{tabular}{lp{10em}}\n\\fitchprf{\\pline[1.]{\\forall x\\forall y\\forall z\\, A(x, y, z)}}{\n\\ellipsesline \\\\\n\\pline[$7$.]{A(c, a, c)}[\\lalle{1}]\n} &\nYou don't have to keep the alphabetical order, and the constants don't\nall have to be distinct.  E.g., here line 7 comes from line 1 by replacing\nx by c, y by a, and z by c.\n\\end{tabular}\n}\n\n\\subsec{Tips}{\n\n\\bit\n\\item Use the strategies for $\\forall$Intro and $\\exists$Elim as early as possible, and those for $\\forall$Elim and $\\exists$Intro as late as possible\n\\item \\emph{When you have a choice between a rule with a subproof and one without, pick the one with the subproof.} (Except indirect proof for a sentence without $\\lnot$!)\n\\item If you're thinking of looking for a proof of A(b) to get $\\sf\\exists x\\, A(x)$ using $\\exists$Intro, you can test if A(b) is a consequence of the premises and assumptions using \\textbf{FO~Con}\n\\item If you type ``$\\sf: x > b$'', click on $\\sf\\forall x\\,A(x)$, select $\\forall$Elim, and check the step, Fitch will fill in A(b) in the line\n\\item If you type ``$\\sf: b > x$'', click on A(b), select $\\exists$Intro, and check the step, Fitch will fill in $\\sf\\exists x\\,A(x)$ in the line\n\\eit\n}\n\n\\subsec{Examples}{\n\nWe'll now apply these strategies (and some strategies we remember from \npropositional proofs) to give proofs of\n\\begin{align*}\\sf\n\\sf\\lnot \\forall x\\, A(x) & \\sf\\leftrightarrow \\exists x\\, \\lnot A(x)\\\\\n\\sf\\exists x (A(x) \\to B) & \\sf\\leftrightarrow (\\forall x\\, A(x) \\to B)\\\\\n\\end{align*}\n\\fitchprf{\\pline{\\forall x\\exists y\\, R(x, y)}\\\\\n\\pline{\\forall x\\forall y(R(x, y) \\to R(y, x)}}{\n\\pline{\\forall x\\, R(x, x)}}\n\n}\n\\end{document} \n\n\n\n\n\n", "meta": {"hexsha": "8f8d6b1d5a0e3a70308ee830b84051bae5672363", "size": 7813, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "279-lec18.tex", "max_stars_repo_name": "rzach/phil279", "max_stars_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-09-23T13:42:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-21T10:48:55.000Z", "max_issues_repo_path": "279-lec18.tex", "max_issues_repo_name": "rzach/phil279", "max_issues_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "279-lec18.tex", "max_forks_repo_name": "rzach/phil279", "max_forks_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6077738516, "max_line_length": 198, "alphanum_fraction": 0.6632535518, "num_tokens": 2768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.41672786948497575}}
{"text": "% Created 2022-01-04 Tue 01:03\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{awesomebox}\n\\usepackage{booktabs}\n\\usepackage{placeins}\n\\usepackage{siunitx}\n\\usepackage{minted}\n\\usetheme[progressbar=frametitle]{metropolis}\n\\usepackage{tikz}\n\\usepackage{tikz-3dplot}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=newest}\n\\usepackage{spot}\n\\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings}\n\\usepgfplotslibrary{groupplots}\n\\newcommand{\\gv}[1]{\\ensuremath{\\mbox{\\boldmath$ #1 $}}}\n\\newcommand{\\bv}[1]{\\ensuremath{\\mathbf{#1}}}\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\\newcommand{\\abs}[1]{\\left\\lvert#1\\right\\rvert}\n\\newcommand{\\bigqm}[1][1]{\\text{\\larger[#1]{\\text{?}}}}\n\\newcommand{\\order}[1]{\\mathcal O \\left( #1 \\right)} % order of magnitude\n\\definecolor{scarlet}{rgb}{1.0, 0.13, 0.0}\n\\definecolor{shamrockgreen}{rgb}{0.0, 0.62, 0.38}\n\\definecolor{royalblue}{rgb}{0.25, 0.41, 0.88}\n\\definecolor{metropolisorange}{RGB}{235,129,27}\n\\definecolor{metropolisblue}{RGB}{35,55,59}\n\\usetheme{default}\n\\author{\\emph{Tejaswin Parthasarathy}, Mattia Gazzola}\n\\date{\\today}\n\\title{Elastica : Timesteppers}\n\\subtitle{ME447: Comp. Design \\& Dyn. of Soft Syst}\n\\hypersetup{\n pdfauthor={\\emph{Tejaswin Parthasarathy}, Mattia Gazzola},\n pdftitle={Elastica : Timesteppers},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 28.0.50 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\\tikzset{>=latex}\n\\section{Time-marching algorithms}\n\\label{sec:org3fd3f69}\n\\begin{frame}[label={sec:orgc24348f}]{Motivation}\n\\begin{example}[Solve the following ODE]\n\\[ \\frac{dx}{dt} = 2x \\quad x(0) = 1 \\]\n\\end{example}\n\\begin{block}{We can!}\n\\[ x(t) = e^{2t}\\]\n\\end{block}\n\\end{frame}\n\n\\begin{frame}[label={sec:orgb6c16ac}]{Motivation}\n\\begin{example}[Solve the following ODE]\n\\[ \\frac{dx}{dt} = \\sin(\\cos x^{\\frac{4}{3}}) + 4\\sin^2(t) \\quad x(0) = 1 \\]\n\\end{example}\n\n\\begin{block}<2->{We can!}\nUse a time-marching algorithm that can solve the above equation, albeit numerically\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org79f0b8c}]{Introduction}\n\\begin{itemize}\n\\item As seen in the last lecture, all our (temporal/spatial) rate of frame change\nvectors (that effect rotations) are precisely of this form\n\\end{itemize}\n\nMore generally, we can solve problems of the form\n\\[ \\frac{\\partial \\mathbf{u}}{\\partial t} = \\mathbf{F}(\\mathbf{u}, t) \\]\nwhich is a partial differential equation (PDE), wherein \\(\\mathbf{F}\\) is\nany arbitrary function.\n\\end{frame}\n\\begin{frame}[label={sec:org38ebce7}]{Examples}\n\\begin{itemize}\n\\item Population dynamics (Lotka-Volterra)\n\\[ \\begin{aligned}\n\t  y'_1 &= y_1 (\\alpha_1 - \\beta_1 y_2) \\quad \\text{(prey)} \\\\\n\t  y'_2 &= y_2 (-\\alpha_2 + \\beta_2 y_1) \\quad \\text{(predator)}\n\t  \\end{aligned} \\]\n\\item Chemical reactions (stiff)\n\\item Newton's equations of motion (our focus)\n\\[  m\\ddot{\\gv{x}} = F(\\gv{x},t) \\]\n\\end{itemize}\n\\note{:B\\_note:\n\\begin{itemize}\n\\item Need not be time variable\n\\end{itemize}}\n\\end{frame}\n\\begin{frame}[label={sec:orgd98aec1}]{Introduction}\n\\begin{itemize}\n\\item We investigate three different (classes of) time-marching algorithms for\nautonomous problems (?!):\n\\begin{itemize}\n\\item Euler's method (or Euler forward/backward)\n\\item Runge-Kutta-4/RK4 (multi-stage methods)\n\\item Position Verlet (symplectic, area preserving integrators)\n\\end{itemize}\n\\item We develop time marching methods that compute approximations to \\(u(t)\\)\nat specfic time points, \\(t^0, t^1, \\cdots, t^n\\).\n\\begin{itemize}\n\\item We only consider a uniform timestep size \\(dt  \\rightarrow t^n = n \\cdot\n       dt\\).\n\\end{itemize}\n\\item Finally, we \\emph{compare} these methods based on general and problem-specific properties\\ldots{}\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:orgb10ecc6}]{Problem statement}\n\\begin{itemize}\n\\item Need function \\(\\gv{u} : [0, T] \\to \\mathbb{R}^n\\) so that\n\\begin{itemize}\n\\item \\(\\gv{u}^{(k)}(t) = \\gv{f}(t, \\gv{u}, \\gv{u}', \\cdots , \\gv{u}^{(k-1)})\\) (\\alert{explicit})\n\\end{itemize}\nor\n\\begin{itemize}\n\\item \\(\\gv{f}(t, \\gv{u}, \\gv{u}', \\cdots , \\gv{u}^{(k-1)}, \\gv{u}^{(k)}) = \\gv{0}\\) (\\alert{implicit})\n\\end{itemize}\nwhere we find a solution to a \\(k\\)-th order ordinary differential\nequation. Typically \\(k = 1,2\\)\n\\item Meaningful only when accompanied by \\(k\\) initial conditions\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:orgfa4ae8a}]{Some properties of ODEs}\n\\begin{itemize}\n\\item \\alert{Autonomous} ODE?\n\\begin{itemize}\n\\item \\(\\gv{f}\\) does not explicitly depend on time \\(t\\)\n\\item An ODE can be made autonomous by introducing an extra variable (More on\nthis later)\n\\end{itemize}\n\\item \\alert{Linear} ODE?\n\\begin{itemize}\n\\item \\(\\gv{f}(\\gv{u}, t) =  \\bv{A}(t)\\gv{u} + \\underbrace{\\gv{b}}_{\\text{forcing}}\\)\n\\end{itemize}\n\\item \\alert{Linear, homogenous} ODE?\n\\begin{itemize}\n\\item \\(\\gv{f}(\\gv{u}, t) =  \\bv{A}(t)\\gv{u}\\)\n\\end{itemize}\n\\item \\alert{Constant-coefficient} ODE?\n\\begin{itemize}\n\\item \\(\\gv{f}(\\gv{u}, t) =  \\bv{A}\\gv{u}\\)\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:org2600374}]{Numerical methods: Euler's forward method}\n\\begin{columns}\n\\begin{column}{0.5\\columnwidth}\n\\begin{itemize}\n\\item Simplest timestepping scheme\n\\item First-order approximation at time \\(t_0\\)\n\\begin{itemize}\n\\item Geometrical description\n\\item Taylor series expansion\n\\end{itemize}\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n\t\\begin{tikzpicture}[\n\tdeclare function={func(\\x)=sin(deg(pi*\\x));},\n\tdeclare function={funcder(\\x)=pi*cos(deg(pi*\\x));}]\n\t\\begin{axis}%\n\t\t[grid=none,\n\t\taxis x line=bottom,\n\t\taxis y line=left,\n\t\tdomain=0.41:0.57,\n\t\txmin=0.38,\n\t\txmax=0.6,\n\t\tymin=0.95,\n\t\tymax=1.01,\n\t\txlabel={$t$},\n\t\tylabel={$u(t)$},\n\t\tticks=none,\n\t\theight=1.12\\textwidth,\n\t\tenlargelimits=false,\n\t\t]\n\t\t\\addplot[smooth, very thick,\n\t\tcolor=metropolisorange]{func(x)};\n\t\t% For each in pgfplots is painful, see\n\t\t% https://tex.stackexchange.com/q/264168\n\t\t\\addplot[thick, color=metropolisblue, mark=*] coordinates\n\t\t{ (0.41, {func(0.41)}) ({0.45}, {func(0.41) + funcder(0.41)*0.04}) };\n\t\t\\foreach \\a in {0.45, 0.49,..., 0.57}\n        {\\edef\n\t\t\\temp{\n\t\t% \\noexpand\\addplot coordinates { (\\x,0.96) (\\x,1.02)};\n\t\t\\noexpand\\addplot[thick, color=metropolisblue, mark=*] coordinates\n\t\t{ (\\a, {func(\\a - 0.04) + funcder(\\a - 0.04)*0.04}) ({\\a + 0.04}, {func(\\a) + funcder(\\a)*0.04}) };\n\t\t}\\temp\n\t\t}\n\n\t\t%\\pgfplotsinvokeforeach {0.41, 0.45,..., 0.53}{\n\t\t% \\addplot{\\a*x^2};\n\t\t% \\addplot coordinates { (#1, {func(#1)}) ({#1 + 0.04}, {func(#1) + funcder(#1)*0.04}) };\n\t\t% \\addplot coordinates { (#1, #1) (#1 + 0.04, #1 + 0.04) };\n\t\t% \\draw (axis cs:#1, func(#1)) -- (axis cs:{#1 + 0.04}, {func(#1) + funcder(#1)*0.04});\n\t\t% }\n\t\\end{axis}\n\t\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\[ u(t_{0}+dt)=u(t_{0})+dt \\cdot u'(t_{0})+{\\frac {1}{2}}dt^{2} \\cdot u''(t_{0})+O(dt^{3}). \\]\n\\begin{itemize}\n\\item First order because local slope approximation is \\(\\order{dt}\\)\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[label={sec:org3b4075b}]{General explicit time stepping schemes}\n\\begin{itemize}\n\\item Explicit schemes approximate the next iterate \\(t^{n+1}\\) using:\n\\end{itemize}\n\\[ \\gv{u}^{n+1} = \\sum_{i=0}^{k} \\alpha_i \\gv{u}^{n-i} + \\sum_{j=0}^{r} \\beta_j \\frac{\\partial \\gv{u}^{n-j}}{\\partial t} \\]\n  which for \\(k=1\\) and \\(r=0\\) looks something along these lines:\n\\[ \\gv{u}^{n+1} = \\alpha_0 \\gv{u}^{n} + \\alpha_1 \\gv{u}^{n-1} + \\beta_0 \\frac{\\partial \\gv{u}^{n}}{\\partial t} \\]\n\\begin{itemize}\n\\item Derivation of schemes other than Euler method follow a similar line of reasoning, while\ndetails vary\\footnote{By a \\alert{lot}}\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:org4bc84f4}]{Some more time stepping schemes}\nWith \\(\\dot{x} = f(x)\\),\n\\begin{block}{Euler forward}\n\\[ x^{n+1} = x^{n} + f(x^{n}) \\cdot dt \\]\n\\end{block}\n\\begin{block}{Euler backward}\n\\[ x^{n+1} = x^{n} + f(x^{n+1}) \\cdot dt \\]\n\\end{block}\n\\begin{columns}\n\\begin{column}{0.5\\columnwidth}\n\\begin{block}{Midpoint method}\n\\begin{equation*}\n\\begin{aligned}\nx^{*}&= x^{n} + f({x}^{n}) \\cdot \\frac{dt}{2} \\\\\nx^{n+1} &= x^{n} + f({x}^{*}) \\cdot dt \\\\\n\\end{aligned}\n\\end{equation*}\n\\end{block}\n\\end{column}\n\\begin{column}{0.4\\columnwidth}\n\\begin{center}\n\t\\begin{tikzpicture}[\n\tdeclare function={func(\\x)=sin(deg(pi*\\x));},\n\tdeclare function={funcder(\\x)=pi*cos(deg(pi*\\x));}]\n\t\\begin{axis}%\n\t\t[grid=none,\n\t\taxis x line=bottom,\n\t\taxis y line=none,\n\t\tdomain=0.43:0.49,\n\t\txmin=0.41,\n\t\txmax=0.51,\n\t\tymin=0.975,\n\t\tymax=1.005,\n\t\tticks=none,\n\t\theight=1.1\\textwidth,\n\t\tenlargelimits=false,\n\t\tclip=false]\n\t\t\\addplot[smooth, very thick,\n\t\tcolor=metropolisorange]{func(x)} node[pos=0.1, above, anchor=south east]\n\t\t{{\\scriptsize$x(t)$}};\n\n\t\t% Draw derivatve from yn to yn+1 first\n\t\t% 0.44 to 0.48\n\t\t\\addplot[color=metropolisblue, mark=*] coordinates\n\t\t{ (0.44, {func(0.44)}) ({0.48},\n\t\t{func(0.44) + 0.04*funcder(0.46)-0.004}) }\n\t\tnode[pos=0, below right, anchor=west]{{\\scriptsize $y^n$}}\n\t\tnode[below right, anchor=north west]{{\\scriptsize $y^{n+1}$}}\n\t\tnode[right, anchor=south west]{Estd.};\n\n\t\t% Draw actual derivatve line\n\t\t\\addplot[color=royalblue, thick] coordinates\n\t\t{ (0.44, {func(0.46) - 0.02*funcder(0.46) }) (0.48,\n\t\t{func(0.46) + 0.02*funcder(0.46)}) } node[above]{Actual};\n\n\t\t% Draw connections to ground now\n\t\t\\addplot[dashed] coordinates\n\t\t{ (0.44, {func(0.44)}) (0.44,\\pgfkeysvalueof{/pgfplots/ymin})}\n\t\tnode [above right, anchor=south west]{{\\scriptsize$t^{n}$}};\n\n\t\t\\addplot[dashed] coordinates\n\t\t{ (0.46, {func(0.46)}) (0.46,\\pgfkeysvalueof{/pgfplots/ymin})}\n\t\tnode [below, anchor=north]{{\\scriptsize$t^{n} + \\frac{dt}{2}$}};\n\n\t\t\\addplot[dashed] coordinates\n\t\t{ (0.48, {func(0.48)}) (0.48,\\pgfkeysvalueof{/pgfplots/ymin})}\n\t\tnode [above right, anchor=south west]{{\\scriptsize$t^{n+1}$}};\n\n\t\\end{axis}\n\t\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}[label={sec:org3bf8753}]{Some more time stepping schemes}\n\\begin{block}{Runge Kutta-4}\n\\begin{equation*}\n\\begin{aligned}\n{k}_1 &= {f}({x}^{n}) \\cdot dt \\\\\n{k}_2 &= {f}({x}^{n} + 0.5 \\cdot {k}_1)\\cdot dt \\\\\n{k}_3 &= {f}({x}^{n} + 0.5 \\cdot {k}_2)\\cdot dt \\\\\n{k}_4 &= {f}({x}^{n} + {k}_3)\\cdot dt \\\\\n{x}^{n+1} &= {x}^{n} + \\frac{{k}_1+2{k}_2+2{k}_3+{k}_4}{6}\n\\end{aligned}\n\\end{equation*}\n\\end{block}\n\\begin{block}{Position/Velocity Verlet}\n\\begin{itemize}\n\\item Later on we introduce these two schemes in the context of integrating\nsecond order ODEs\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orgb1d9e79}]{Function evaluations}\n\\begin{itemize}\n\\item Our first attempt at comparing schemes is the number of functional\nevaluations for one time step\\ldots{}\n\\item Why? \\(f(x)\\) can be expensive to evaluate (e.g. calculating the effect\nof the energy diffusion on millions to billions of\ngrid points in an astrophysical simulation)\n\\end{itemize}\n\\begin{table}[htbp]\n\\caption{\\label{tab_sym_snake_params}Number of function evaluations for schemes}\n\\centering\n\\begin{tabular}{lr}\n\\toprule\nScheme & \\(n[f(x)]\\)\\\\\n\\midrule\nEuler fwd & 1\\\\\nEuler bwd & Solve!\\\\\nMidpoint & 2\\\\\nRK4 & 4\\\\\nVerlet* & 1\\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\\end{frame}\n\\begin{frame}[label={sec:orge2303a5}]{Convergence/ Consistency}\nSuppose the numerical solution at some time \\(t\\) is \\(\\gv{u}\\), and the\nexact solution at the same time is \\(\\tilde{\\gv{u}}\\).\n\\begin{definition}[Convergence]\nA numerical method is said to be convergent if the numerical solution\napproaches the exact solution as the step size \\(dt\\) goes to 0.\n\\end{definition}\nThe methods we just looked at are all convergent.\n\\begin{definition}[Consistency]\nA numerical method is said to be consistent if the error, \\(e_{dt}:=\\lVert\\tilde{\\gv{u}}-\\gv{u} \\rVert\\) is such that\n\\[ \\lim_{dt \\to 0} \\frac{e_{dt}}{dt} = 0\\]\n\\end{definition}\n\\end{frame}\n\\begin{frame}[label={sec:org2500b2a}]{Order of convergence}\n\\begin{definition}[Order of accuracy]\nThe numerical solution \\(\\gv{u}\\) is said to be \\(p^{\\text{th}}\\)-order\naccurate if the error, \\(e(dt):=\\lVert\\tilde{\\gv{u}}-\\gv{u} \\rVert\\)\nis proportional to the step-size \\(dt\\), to the \\(p^{\\text{th}}\\) power. That\nis\n\\[ e(dt)=\\lVert\\tilde{\\gv{u}}-\\gv{u} \\rVert\\leq C(dt)^{p} \\]\nwhere the constant \\(C\\) is independent of \\(dt\\) and usually depends on\nthe solution \\(\\gv{u}\\)\n\\end{definition}\n In the big O notation an \\(p^{\\text{th}}\\)-order accurate numerical method\n is notated as\n\\[ \\lVert\\tilde{\\gv{u}}-\\gv{u} \\rVert = \\order{h^p}\\]\n\\end{frame}\n\\begin{frame}[label={sec:org984fd76}]{Order of convergence : Importance}\n\\begin{columns}\n\\begin{column}{0.32\\columnwidth}\n\\begin{block}{First order}\n\\begin{center}\n\\begin{tabular}{ll}\n\\toprule\n\\(dt\\) & \\(e(dt)\\)\\\\\n\\midrule\n\\(10^{-1}\\) & \\(1\\)\\\\\n\\(10^{-2}\\) & \\(10^{-1}\\)\\\\\n\\(10^{-3}\\) & \\(10^{-2}\\)\\\\\n\\(10^{-4}\\) & \\(10^{-3}\\)\\\\\n\\(10^{-5}\\) & \\(\\spot<2>{10^{-4}}\\)\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{block}\n\\end{column}\n\n\\begin{column}{0.32\\columnwidth}\n\\begin{block}{Second order}\n\\begin{center}\n\\begin{tabular}{ll}\n\\toprule\n\\(dt\\) & \\(e(dt)\\)\\\\\n\\midrule\n\\(10^{-1}\\) & \\(1\\)\\\\\n\\(10^{-2}\\) & \\(10^{-2}\\)\\\\\n\\(10^{-3}\\) & \\(10^{-4}\\)\\\\\n\\(10^{-4}\\) & \\(10^{-6}\\)\\\\\n\\(10^{-5}\\) & \\(\\spot<2>{10^{-8}}\\)\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{block}\n\\end{column}\n\\begin{column}{0.32\\columnwidth}\n\\begin{block}{Fourth order}\n\\begin{center}\n\\begin{tabular}{ll}\n\\toprule\n\\(dt\\) & \\(e(dt)\\)\\\\\n\\midrule\n\\(10^{-1}\\) & \\(1\\)\\\\\n\\(10^{-2}\\) & \\(10^{-4}\\)\\\\\n\\(10^{-3}\\) & \\(10^{-8}\\)\\\\\n\\(10^{-4}\\) & \\(10^{-12}\\)\\\\\n\\(10^{-5}\\) & \\(\\spot<2>{10^{-16}}\\)\\\\\n\\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{block}\n\\end{column}\n\\end{columns}\n\\begin{alertblock}<2->{Better returns for same timestep!}\n\\end{alertblock}\n\\end{frame}\n\n\\begin{frame}[label={sec:org9ae791f}]{Order of convergence : Implementation}\n\\begin{block}{Model problem definition}\nLet's solve this problem, and test out methods for convergence:\n\\[ \\frac{dy}{dt} = -y \\quad,\\quad  y(0) = 1 \\]\nwhich as we know has the analytical solution \\(\\tilde{y}(t) = e^{-t}\\) \\(\\rightarrow\\)\nerror known at every \\(dt\\)\n\nNotice:\n\\begin{itemize}\n\\item We choose a simple problem to understand performance/convergence\n\\begin{itemize}\n\\item More complicated problems usually follow suit\n\\end{itemize}\n\\item We are solving an eigenvalue problem, just like the last lecture (rotations)\n\\end{itemize}\n\n\\alert{ACTIVITY}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org2bd73fe}]{Order of accuracy : Results}\n% Need to run the notebook first\n\\begin{center}\n\t\\begin{tikzpicture}\n\t\t\\begin{loglogaxis}[\n\t\t\tenlargelimits=true,\n\t\t\tgrid=both,\n\t\t\tgrid style={line width=.1, draw=gray!20},\n\t\t\tmajor grid style={line width=.2,draw=gray!50},\n\t\t\txlabel=$dt$,\n\t\t\tylabel=$e(dt)$,\n\t\t\theight=1.0\\textheight\n\t\t\t]\n\t\t\t% Euler backward/forward\n\t\t\t\\addplot [mark=*, mark size=2.5, scarlet, very thick]\n\t\t\ttable {code/data/euler_bwd_ooa.txt} node [midway, above left, anchor=south east]\n\t\t\t{Euler bwd/fwd};\n\t\t\t\\addplot [metropolisblue, dashed, thick]\n\t\t\ttable {code/data/euler_bwd_ooa_slopes.txt};\n\n\t\t\t% Midpoitn\n\t\t\t\\addplot [mark=*, mark size=2.5, royalblue, very thick]\n\t\t\ttable {code/data/midpoint_method_ooa.txt} node [pos=0.8, below , anchor=north west]\n\t\t\t{Midpoint};\n\t\t\t\\addplot [metropolisblue, dashed, thick]\n\t\t\ttable {code/data/midpoint_method_ooa_slopes.txt};\n\n\t\t\t% RK4\n\t\t\t\\addplot [mark=*, mark size=2.5, metropolisorange, very thick]\n\t\t\ttable {code/data/rk4_ooa.txt} node [midway, below right, anchor=north west]\n\t\t\t{RK4};\n\t\t\t\\addplot [metropolisblue, dashed, thick]\n\t\t\ttable {code/data/rk4_ooa_slopes.txt};\n\n\t\t\\end{loglogaxis}\n\t\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:orga06aaa8}]{Order of accuracy : Results}\n\\begin{table}[htbp]\n\\caption{\\label{tab_sym_snake_params}Order of accuracy for different schemes}\n\\centering\n\\begin{tabular}{lr}\n\\toprule\nScheme & \\(p\\)\\\\\n\\midrule\nEuler & 1\\\\\nMidpoint & 2\\\\\nRK4 & 4\\\\\nVerlet* & ?\\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\\end{frame}\n\\begin{frame}[label={sec:org70a597c}]{Bottomline}\n\\begin{itemize}\n\\item Order of accuracy is a measure of ``goodness'' of algorithm\n\\item Higher-order accurate algorithms commit less error for a given \\(h\\).\n\\item But they are costly (in terms number of function evaluations, and\nultimately number of operations performed)\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:org492de25}]{Higher order ODEs}\nWe consider a harmonic oscillator, i.e. a linear spring-mass system:\n\\[ \\ddot{x} + \\omega^2 x = 0\\]\n\\begin{columns}\n\\begin{column}{0.6\\columnwidth}\n\\begin{itemize}\n\\item \\(\\omega^2 = \\frac{k}{m} \\equiv 1\\)\n\\item Consider \\(x(0) = 1, \\dot{x}(0) = 0\\) (need two ICs)\n\\item Solution is analytically known to be\n\\end{itemize}\n\\[ x(t) = \\cos(t) \\quad \\dot{x}(t) = -\\sin(t) \\]\n\\begin{itemize}\n\\item Notice : solution is bounded\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.4\\columnwidth}\n\\tikzset{boxstyle/.style={draw,outer sep=0pt,thick}}\n% https://tex.stackexchange.com/a/13952\n\\begin{center}\n\t\\begin{tikzpicture}[scale=1]\n\t\\tikzstyle{spring}=[thick,decorate,color=metropolisblue, decoration={zigzag,pre length=4,post length=4,segment length=10}]\n\t\\tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=8,minimum height=3]\n\n\t\\node (M) [boxstyle, minimum width=50, minimum height=50, color=metropolisblue] {$m$};\n\n\t\\node (ground) [ground,anchor=north,yshift=-10,minimum width=80] at (M.south) {};\n\t\\draw (ground.north east) -- (ground.north west);\n\t\\draw [thick] (M.south west) ++ (8pt,-5pt) circle (5pt) (M.south east) ++ (-8pt,-5pt) circle(5pt);\n\t% \\draw [thick] (M.south west) ++ (8,-5) circle[radius=5pt];\n\t% \\draw [thick]\n\n\t\\node (wall) [ground, rotate=-90, minimum width=80, xshift=-10, yshift=-80] {};\n\t\\draw (wall.north east) -- (wall.north west);\n\n\t% Syntax ($(A)!(C)!(B)$), specifies the projection of (C) on the line\n\t% from (A) to (B),\n\t% <name>.<number> syntax https://tex.stackexchange.com/a/426804\n\t\\draw [spring] (M.180) -- ($(wall.north east)!(M.180)!(wall.north west)$)\n\tnode [midway, above]{$kx$};\n\n\t% Draw x position beginning and end\n\t% Interesection of north east ground with horizontal wall and 10 pt line\n\t\\draw [thick, color=metropolisblue] ($(wall.south west)!(ground.north west)!(wall.north west)$) --\n\t++ (0pt,-5pt) coordinate (c) -- ++(0pt,-5pt);\n\t\\draw [thick, color=metropolisblue, ->] (c) -- ($(M.south west)!(c)!(M.north west)$)\n\tnode[right]{$x$};\n\n\t\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org5b1d4e0}]{Conservation laws in typical higher order ODEs}\nThe system is \\alert{Hamiltonian} as the energy is conserved:\n\\[ \\underbrace{H(x(t), \\dot{x}(t))}_{\\text{Hamiltonian/total energy}} = \\underbrace{x^2(t)}_{\\text{Potential energy}} +\n   \\underbrace{\\dot{x}^2(t)}_{\\text{Kinetic energy}} \\equiv 1\\]\n\nThe solution can be represented in the time domain (left) or in the phase\nportrait (right)\n\\begin{columns}\n\\begin{column}{0.5\\columnwidth}\n\\begin{center}\n\t\\begin{tikzpicture}\n\t\\begin{axis}%\n\t\t[grid=both,\n\t\tminor tick num=4,\n\t\tgrid style={line width=.1pt, draw=gray!10},\n\t\tmajor grid style={line width=.2pt,draw=gray!50},\n\t\taxis lines=middle,\n\t\tdomain=0:7,\n\t\tx label style={at={(axis description cs:1.1,0.5)},anchor=east},\n\t\ty label style={at={(axis description cs:-0.1,.5)},rotate=90,anchor=south},\n\t\txlabel={$t$},\n\t\tylabel={$u(t)$},\n\t\twidth=1.1\\textwidth,\n\t\ttitle style={at={(0.5,0)},anchor=north,yshift=-0.1},\n\t\ttitle={Time domain},\n\t\tenlargelimits=true,\n\t\t% enlargelimits={abs=0.2}\n\t\t]\n\t\t\\addplot[samples=200,smooth,metropolisorange,very thick]{cos(deg(x))}\n\t\tnode[pos=0.1, right]{{\\small $x(t)$}};\n\t\t\\addplot[samples=200,smooth,metropolisblue,very thick]{-sin(deg(x))}\n\t\tnode[pos=0.99, below left, anchor=north east]{{\\small $\\dot{x}(t)$}};\n\t\\end{axis}\n\t\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\begin{column}{0.5\\columnwidth}\n\\begin{center}\n\t\\begin{tikzpicture}\n\t\\begin{axis}%\n\t\t[grid=both,\n\t\tminor tick num=4,\n\t\tgrid style={line width=.1pt, draw=gray!10},\n\t\tmajor grid style={line width=.2pt,draw=gray!50},\n\t\taxis lines=middle,\n\t\twidth=1.1\\textwidth,\n\t\txmin=-1.1, xmax=1.1, ymin=-1.1, ymax=1.1,\n\t\taxis equal,\n\t\tx label style={at={(axis description cs:0.98,0.5)},anchor=south east},\n\t\ty label style={at={(axis description cs:0.5,0.98)},anchor=west},\n\t\txlabel={\\textcolor{metropolisorange}{$x$}},\n\t\tylabel={\\textcolor{metropolisblue}{$\\dot{x}$}},\n\t\ttitle style={at={(0.5,-0.2)},anchor=south},\n\t\t% title style={at={(0.5,0.0)},anchor=north},\n\t\ttitle={Phase portrait},\n\t\tenlargelimits=true,\n\t\tdisabledatascaling\n\t\t]\n\t\t\\draw[very thick, black] (axis cs: 0, 0) circle [radius=1];\n\t\t\\draw[thick, black, ->] (axis cs:0, 0)--(axis cs:0.707106, 0.707106);\n\t\t\\draw [thick,->] (0.4,0) arc (0:45:0.4) node [midway, right]{{\\scriptsize $t$}};\n\t\\end{axis}\n\t\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[label={sec:org8359662}]{Conversion to lower order ODE}\nLet's convert the second order ODE to two first order ODEs, by considering \\(y = \\dot{x} \\Rightarrow\\)\n\\[ \\begin{pmatrix} \\dot{x} \\\\ \\dot{y} \\end{pmatrix} = \\begin{bmatrix} 0 & 1\\\\-1\n   & 0 \\end{bmatrix} \\begin{pmatrix} {x} \\\\ {y} \\end{pmatrix} \\]\n\n\\begin{itemize}\n\\item You can reuse the same schemes!\n\\item Alternatively, we can develop schemes for the second order equation\ndirectly : \\alert{Example using Taylor series}\n\\end{itemize}\n\n\\begin{block}{Position Verlet scheme}\n\\begin{itemize}\n\\item For integrating equations similar to \\(\\ddot{\\gv{x}} = \\gv{f}(\\gv{x})\\),\nwith \\(\\gv{y} = \\dot{\\gv{x}}\\)\n\\end{itemize}\n\\begin{equation*}\n\\begin{aligned}\n\\gv{x}^* &= \\gv{x}^n + 0.5\\cdot dt \\cdot \\gv{y}^n \\\\\n\\gv{y}^{n+1} &= \\gv{y}^n + dt \\cdot \\gv{f}\\left( \\gv{x}^*\\right) \\\\\n\\gv{x}^{n+1} &= \\gv{x}^* + 0.5\\cdot dt \\cdot \\gv{y}^{n+1}\n\\end{aligned}\n\\end{equation*}\n\\end{block}\n\\note{:B\\_note:\n\\begin{itemize}\n\\item Show derivation using\n\\end{itemize}\n\\[ f(x+h) = f(x) + f'(x)h + f''(x)h^2/2! + \\cdots \\quad\n\tf(x - h) = f(x) - f'(x) h + f''(x)h^2/2! + \\cdots \\]\nand add them up}\n\\end{frame}\n\\begin{frame}[label={sec:org61a1641}]{More schemes}\nAnother example of a scheme for this model equation is\n\\begin{block}{Velocity Verlet algorithm}\n\\begin{equation*}\n\\begin{aligned}\n\\gv{y}^* &= \\gv{y}^n + 0.5\\cdot dt \\cdot \\gv{f}\\left( \\gv{x}^n\\right) \\\\\n\\gv{x}^{n+1} &= \\gv{x}^{n} + dt \\cdot \\gv{y}^{*} \\\\\n\\gv{y}^{n+1} &= \\gv{y}^* + 0.5\\cdot dt \\cdot \\gv{f}\\left( \\gv{x}^{n+1}\\right) \\\\\n\\end{aligned}\n\\end{equation*}\n\\end{block}\n\\begin{block}{How do these schemes fare?}\n\\begin{itemize}\n\\item Position and Velocity Verlet have \\(p = 2\\) (second-order accurate) for\nboth position \\(\\gv{x}\\) and velocity \\(\\gv{y}\\)\n\\item But Position Verlet has only \\alert{one} function evaluation!\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org4f35c6d}]{Energy-preserving/symplectic schemes}\n\\begin{block}{Why do we even care about these schemes?}\n\\begin{itemize}\n\\item Clearly, RK4 has higher order of convergence and it must be better?\n\\end{itemize}\n\\end{block}\n\\begin{block}{Answer}\n\\begin{itemize}\n\\item Position and Velocity Verlet schemes are symplectic (area-preserving) schemes\n\\item They preserve in the phase-portrait of a Hamiltonian system \\(\\Rightarrow\\)\nThey always conserve energy by design!\n\\end{itemize}\n\n\\alert{ACTIVITY}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orga5817e9}]{Energy-preserving/symplectic schemes}\n\\begin{itemize}\n\\item The harmonic equation arises from Newton's fundamental laws of motion,\nwithout dissipative forces \\(\\Rightarrow\\) energy needs to be conserved\n\\item RK4 slowly dissipates energy \\(\\Rightarrow\\) unphysical!\n\\item Euler forward increases energy without bounds, even when physics dictates\nbounded solutions (counter examples?)\n\\item Verlet schemes conserve energy even for large \\(dt\\)\n\\begin{itemize}\n\\item There are still errors (it still has \\(p = 2\\) ) in the \\emph{phase}\n\\item \\alert{DEMO}\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:org0a9e1a4}]{But why is it energy preserving?\\footnote{Peter Young, \\href{https://young.physics.ucsc.edu/242/leapfrog.pdf}{Course Notes:Physics 115/242}}}\n\\begin{itemize}\n\\item Because it preserves the area in the \\(x-p\\) phase space (thus the area-preserving\nproperty seen earlier)\n\\item Why area preservation? \\(\\Rightarrow\\) \\alert{Liouville's theorem}\n\\item On one application of the time-stepping scheme (map), an initial rectangle\nwith side lengths \\(dx , dp\\) gets stretched to a parallelogram with\nsides \\(dx^\\prime, dp^\\prime\\)\n\\end{itemize}\n\n\\begin{columns}\n\\begin{column}{0.6\\columnwidth}\nNew area \\(dA^\\prime = \\det \\bv{J} dA\\), where \\(\\bv{J}\\) is\n\\[ \\bv{J} =\t\\begin{bmatrix}\n\t\\frac{\\partial x^\\prime}{\\partial x} & \\frac{\\partial x^\\prime}{\\partial p}  \\\\\n\t\\frac{\\partial p^\\prime}{\\partial x} & \\frac{\\partial p^\\prime}{\\partial p}  \\\\\n\t\\end{bmatrix} \\]\n\nIn the case of symplectic schemes, we require \\(\\det \\bv{J} = 1\\)\n\\end{column}\n\\begin{column}{0.4\\columnwidth}\n\\begin{figure}[htbp]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{images/area_preserve.png}\n\\caption{Area preservation}\n\\end{figure}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}[label={sec:org18a66f7}]{Area preserviation of Verlet and Euler algorithms}\nFrom a different perspective,\n\\(\\begin{pmatrix} \\delta x_1 \\\\ \\delta v_1 \\end{pmatrix} = \\bv{J}\\begin{pmatrix} \\delta x_0\n   \\\\ \\delta v_0 \\end{pmatrix}\\)\nwhere subscripts denote number of applications of the time-stepping scheme.\nBreak it down to\n\\(\\bv{J} = \\bv{C}\\bv{B}\\bv{A}\\).\n\\begin{columns}\n\\begin{column}{0.5\\columnwidth}\n\\begin{alertblock}{Euler forward}\n\\begin{equation*}\n\\begin{aligned}\n\\bv{A} &= \\begin{bmatrix} 1 & h\\\\ hF^\\prime(x_0) & 1 \\end{bmatrix}\\\\\n\\bv{B} &= \\begin{bmatrix} 1 & 0\\\\ 0 & 1 \\end{bmatrix} \\\\\n\\bv{C} &= \\begin{bmatrix} 1 & 0\\\\ 0 & 1 \\end{bmatrix}\n\\end{aligned}\n\\end{equation*}\n\\end{alertblock}\n\\end{column}\n\\begin{column}{0.5\\columnwidth}\n\\begin{alertblock}{Position verlet}\n\\begin{equation*}\n\\begin{aligned}\n\\bv{A} &= \\begin{bmatrix} 1 & \\tfrac{h}{2}\\\\ 0 & 1 \\end{bmatrix}\\\\\n\\bv{B} &= \\begin{bmatrix} 1 & 0 \\\\ hF^\\prime(x_{1/2}) & 1 \\end{bmatrix}\\\\\n\\bv{C} &= \\begin{bmatrix} 1 & \\tfrac{h}{2}\\\\ 0 & 1 \\end{bmatrix}\\\\\n\\end{aligned}\n\\end{equation*}\n\\end{alertblock}\n\\end{column}\n\\end{columns}\nCalculate \\(\\det \\bv{J}\\)\\ldots{}\n\\end{frame}\n\\begin{frame}[label={sec:orga4bc767}]{Bottomline}\n\\begin{itemize}\n\\item The evolution of dynamics of the soft filament also relies on some form of energy\nconservation (translational/rotational/bending/twist/shear/stretch) as the\ngoverning equations are Newton's laws\n\\item We need symplectic algorithms for maintaining relevance to the physical world\n\\end{itemize}\n\n\\alert{Counterpoint} In reality, there is always dissipation (frictional forces,\n viscous forces, drag forces not included in either of the above, etc.)\n\\end{frame}\n\\begin{frame}[label={sec:org907601a}]{Why did forward Euler blow-up?}\n\\begin{itemize}\n\\item Because it was unstable\\ldots{}related to the stability of a method (alternatively instability)\n\\end{itemize}\n\\begin{block}{Euler forward algorithm}\n\\begin{itemize}\n\\item Find out what happens to the numerical solution using forward Euler when applied to\n\\(\\dot{y}(t) = \\lambda y(t)\\)\n\\item Why? Eigenvalue problem, easy to extend analysis to general matrices\n\\end{itemize}\n\\begin{equation*}\n\\begin{aligned} y_k & = y_{k-1} + h \\lambda y_{k-1} \\\\ &= (1 + h\n\\lambda)y_{k-1} \\\\ &= (1 + h \\lambda)^{k}y_{0}\n\\end{aligned}\n\\end{equation*}\n\\begin{itemize}\n\\item So stability \\(\\Leftrightarrow\\) \\(\\abs{1 + h \\lambda} \\leq 1\\)\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org91666ec}]{Why did forward Euler blow-up?}\n\\begin{itemize}\n\\item \\(\\abs{1 + h \\lambda}\\) is the \\alert{amplification factor}\n\\item The condition on the amplification factor implies the existence of a\n\\alert{stability region} in the complex plane\n\\item \\alert{DEMO}\n\\end{itemize}\n% This file was created by matplotlib2tikz v0.7.4.\n\\begin{center}\n\\begin{tikzpicture}[scale=0.45]\n\t\\begin{groupplot}[group style={group size=3 by 1}]\n\t\\nextgroupplot[\n\ttitle={Euler forward},\n\tgrid=both,\n\tgrid style={line width=.1pt, draw=gray!10},\n\tmajor grid style={line width=.2pt,draw=gray!50},\n\taxis equal,\n\txmin=-2.2, xmax=0.2,\n\tymin=-1.2, ymax=1.2,\n\tminor tick num=4,\n\txlabel={\\(\\displaystyle \\mathrm{Re}\\)},\n\tylabel={\\(\\displaystyle \\mathrm{Im}\\)},\n\tenlargelimits=false,\n\tdisabledatascaling\n\t]\n\n\t\\draw[very thick, metropolisblue, fill=metropolisorange, fill opacity=0.3]\n\t(axis cs: -1, 0) circle [radius=1];\n\t% \\addplot [very thick, metropolisorange, fill=metropolisorange, fill opacity=0.3]\n\t% table {code/data/euler_fwd_stability.txt};\n\n\t\\nextgroupplot[\n\ttitle={Euler backward},\n\tgrid=both,\n\tgrid style={line width=.1pt, draw=gray!10},\n\tmajor grid style={line width=.2pt,draw=gray!50},\n\taxis equal,\n\txmin=-0.2, xmax=2.2,\n\tymin=-1.2, ymax=1.2,\n\tminor tick num=4,\n\txlabel={\\(\\mathrm{Re}\\)},\n\tenlargelimits=false,\n\tdisabledatascaling\n\t]\n\t% \\addplot [fill=metropolisorange, fill opacity=0.3]\n\t% table [row sep=\\\\]{\n\t% -0.5 -1.5\\\\\n\t% 2.5 -1.5\\\\\n\t% 2.5 1.5\\\\\n\t% -0.5 1.5\\\\\n\t% -0.5 -1.5};\n\t\\filldraw[fill=metropolisorange, fill opacity=0.3]\n\t(axis cs: -1, -2) rectangle (3,2);\n\t\\draw[very thick, metropolisblue, fill=white, fill opacity=0.6]\n\t(axis cs: 1, 0) circle [radius=1];\n\t% \\addplot [thick, metropolisorange] table {code/data/euler_bwd_stability.txt};\n\n\t\\nextgroupplot[\n\ttitle={Runge-Kutta--4},\n\tgrid=both,\n\tgrid style={line width=.1pt, draw=gray!10},\n\tmajor grid style={line width=.2pt,draw=gray!50},\n\taxis equal,\n\txmin=-3, xmax=1,\n\tymin=-3, ymax=3,\n\tminor tick num=4,\n\txlabel={\\(\\mathrm{Re}\\)},\n\tenlargelimits=false,\n\tdisabledatascaling,\n\t]\n\t\\addplot [thick, metropolisblue, fill=metropolisorange,\n\tfill opacity=0.3] table {code/data/rk4_stability.txt};\n\t\\end{groupplot}\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org31e4784}]{What about backward Euler?}\n\\begin{block}{Backward Euler algorithm}\n\\begin{itemize}\n\\item Find out what happens to the numerical solution using backward Euler when applied to\n\\(\\dot{y}(t) = \\lambda y(t)\\)\n\\end{itemize}\n\\begin{equation*}\n\\begin{aligned} y_k & = y_{k-1} + h \\lambda y_{k} \\\\\ny_k (1 - h \\lambda) &= y_{k-1} \\\\\ny_k &= \\frac{1}{(1 - h \\lambda)}y_{k-1} \\\\\ny_k &= \\left( \\frac{1}{1 - h \\lambda} \\right)^k y_{0}\n\\end{aligned}\n\\end{equation*}\n\\begin{itemize}\n\\item So stability \\(\\Leftrightarrow\\) \\(\\abs{1 - h \\lambda} \\geq 1\\)\n\\item Backward Euler can be stable even when the ODE is not!\n\\item \\alert{DEMO}\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:orgc276ff8}]{What about Verlet ?}\n\\begin{block}{Can it blow up?}\n\\end{block}\n\\begin{block}<2->{It can!}\n\\begin{itemize}\n\\item But only for non-hamiltonian systems\n\\item For hamiltonian systems, it always conserves a positive semi-definite\nquantity and hence should not blow up\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org70d82df}]{Bottomline}\n\\begin{itemize}\n\\item Stability is another measure of how ``good'' a time-marching algorithm is\n\\item For \\alert{explicit} schemes, main concern in time-step selection is usually\n\\alert{stability} (but also accuracy)\n\\item For \\alert{implicit} schemes, \\alert{accuracy} determines the time-step selection\n\\end{itemize}\n\\end{frame}\n\\begin{frame}[label={sec:org58363b5}]{Stiff ODEs}\n\\begin{block}{What are stiff problems?}\n\\begin{itemize}\n\\item Hard to define exactly\n\\item Usually when there are \\alert{multiple time scales} in our problem\n\\end{itemize}\n\\end{block}\n\\begin{alertblock}{DEMO}\n\\begin{itemize}\n\\item In the above demo, stiffness results from the presence of a fast decay\ncomponent, but slow evolution of the total solution (slow--fast time scale)\n\\item In the case of a stable ODE system \\(\\dot{\\gv{y}}(t) = \\bv{J}_{f}(\\gv{y}(t))\\)\nstiffness can arise if \\(\\bv{J}_f\\) has eigenvalues of very different\nmagnitude (what is this called again?)\n\\end{itemize}\n\\end{alertblock}\n\\end{frame}\n\\begin{frame}[label={sec:org0e9270d}]{Stiff ODEs}\n\\begin{itemize}\n\\item Why not just \\emph{small} or \\emph{large} magnitude?\n\\begin{itemize}\n\\item Because discrepancy in time scales is the problem\n\\item If all time scales are similar, then we can deal with that one time\nscale (non-dimensionalization of the problem helps)\n\\item If there are many, then some (usually fast ones) may be considered uninteresting.\n\\end{itemize}\n\\end{itemize}\n\\begin{block}{Explicit methods}\n\\begin{itemize}\n\\item What was the problem in applying explicit methods to stiff problems?\n\\begin{itemize}\n\\item Fastest time scale governs timestep \\(\\Rightarrow\\) small timesteps\n\\(\\Rightarrow\\) inefficient.\n\\end{itemize}\n\\item \\alert{Accuracy} (in terms of capturing the slow timescale) could be achieved\nwith large timesteps\n\\item \\alert{Stability} demands a small time step\n\\end{itemize}\n\\end{block}\n\\end{frame}\n\\begin{frame}[label={sec:org7de5eb0}]{Stiff ODEs}\n\\begin{block}{Implicit methods}\n\\begin{itemize}\n\\item Large time steps?\n\\begin{itemize}\n\\item Definitely.\n\\end{itemize}\n\\item \\alert{Stability} is not a problem\n\\item \\alert{Accuracy} suffers.\n\\end{itemize}\n\\end{block}\n\\begin{block}{So even here we have an issue.}\n\\end{block}\n\\begin{block}{Bottomline}\nStiff problems are hard to tackle (there are still ingenious ways to\npartially offset the cost of solving a stiff problem)\n\\end{block}\n\\end{frame}\n\n\\begin{frame}[label={sec:org7b18dab}]{Summary}\n\\begin{table}[htbp]\n\\caption{\\label{tab_sym_snake_params}Properties of different explicit schemes}\n\\centering\n\\begin{tabular}{lrrl}\n\\toprule\nScheme & \\(p\\) & \\(n[f(x)]\\) & Energy preserving?\\\\\n\\midrule\nEuler & 1 & 1 & No\\\\\nMidpoint & 2 & 2 & No\\\\\nRK4 & 4 & 4 & No\\\\\nVerlet & 2 & 1 & Yes\\\\\n\\bottomrule\n\\end{tabular}\n\\end{table}\n\\end{frame}\n\\begin{frame}[label={sec:org2e22f4e}]{Credits}\n\\begin{block}{A good chunk of the material in these slides are taken from Prof. Andreas Kloeckner's CS450 lectures}\n\\end{block}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "9346a973d6fe51cbd384ce2415fc15ccb0a17b10", "size": 33936, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/05_timeintegration/05_timeintegration.tex", "max_stars_repo_name": "tp5uiuc/soft_systems_course", "max_stars_repo_head_hexsha": "c9585c8fdc7fbc2fd539b4a1ed5e3b43a889a1ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-01-12T21:54:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T09:31:40.000Z", "max_issues_repo_path": "lectures/05_timeintegration/05_timeintegration.tex", "max_issues_repo_name": "tp5uiuc/soft_systems_course", "max_issues_repo_head_hexsha": "c9585c8fdc7fbc2fd539b4a1ed5e3b43a889a1ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/05_timeintegration/05_timeintegration.tex", "max_forks_repo_name": "tp5uiuc/soft_systems_course", "max_forks_repo_head_hexsha": "c9585c8fdc7fbc2fd539b4a1ed5e3b43a889a1ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6, "max_line_length": 179, "alphanum_fraction": 0.6846416785, "num_tokens": 12257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.41672786275325824}}
{"text": "\\documentclass[a4paper]{article}\r\n\r\n%% Language and font encodings\r\n\\usepackage[english]{babel}\r\n\\usepackage[utf8x]{inputenc}\r\n\\usepackage[T1]{fontenc}\r\n\r\n%% Sets page size and margins\r\n\\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\r\n\r\n%% Useful packages\r\n\\usepackage{amsmath}\r\n\\usepackage{amsfonts}\r\n\\usepackage{graphicx}\r\n\\usepackage[colorinlistoftodos]{todonotes}\r\n\\usepackage[colorlinks=true, allcolors=blue]{hyperref}\r\n\r\n\\title{Judson's Abstract Algebra: Chapter 3}\r\n\\date{}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\\section*{1}\r\n\r\nSuppose $3x \\equiv 2 \\mod 7$. Then $x \\in \\{z: z = 3 + 7n, n \\in \\mathbb{Z}\\}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nSuppose $5x + 1 \\equiv 13 \\mod 23$. Then $x \\in \\{z: z = 7 + 23n, n \\in \\mathbb{Z}\\}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nSuppose $5x + 1 \\equiv 13 \\mod 26$. Then $x \\in \\{z: z = 18 + 26n, n \\in \\mathbb{Z}\\}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nSuppose $9x \\equiv 3 \\mod 5$. Then $x \\in \\{z: z = 2 + 5n, n \\in \\mathbb{Z}\\}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nSuppose $5x \\equiv 1 \\mod 6$. Then $x \\in \\{z: z = 5 + 6n, n \\in \\mathbb{Z}\\}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nSuppose $3x \\equiv 1 \\mod 6$. There are no solutions.\r\n\r\n\r\n\\section*{6}\r\n\r\nGive a multiplication table for the group $U(12)$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nNote that $U(12) = \\{ 1, 5, 7, 11 \\}.$\r\n\r\n$$\r\n\\begin{tabular}{ l | l l l l l }\r\n  * & 1 & 5 & 7 & 11 \\\\\r\n  \\hline      \r\n  1 & 1 & 5 & 7 & 11 \\\\\r\n  5 & 5 & 1 & 11 & 7 \\\\\r\n  7 & 7 & 11 & 1 & 5 \\\\\r\n  11 & 11 & 7 & 5 & 1 \\\\\r\n\\end{tabular}\r\n$$\r\n\r\n\r\n\r\n\\section*{7}\r\n\r\nLet $S = \\mathbb{R} \\setminus \\{ -1 \\}$ and define a binary operation on $S$ by $a * b = a + b + ab$. Prove that $(S, *)$ is an abelian group.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $a, b, c \\in S$. The identity is 0 since $a * 0 = a + 0 + 0a = a$. The inverse of $a$ is given by \r\n\r\n$$ a^{-1} = \\frac{-a}{1+a}$$\r\n\r\nsince\r\n\r\n\\begin{align*}\r\na * a^{-1} &= a * \\frac{-a}{1+a} \\\\\r\n&= a + \\frac{-a}{1+a} + \\frac{-a^2}{1+a} \\\\\r\n&= \\frac{a + a^2}{1+a} - \\frac{a + a^2}{1+a} \\\\\r\n&= 0\r\n\\end{align*}\r\n\r\nand $a \\neq -1$.\r\n\r\nConsider\r\n\r\n\\begin{align*}\r\n(a * b) * c &= (a + b + ab) * c \\\\\r\n&= a + b + ab + c + c (a + b + ab) \\\\\r\n&= a + b + c + ab + ac + bc + abc \\\\\r\n&= a + (b + c + bc) + (ab + ac + abc) \\\\\r\n&= a + (b * c) + a (b * c) \\\\\r\n&= a * (b * c).\r\n\\end{align*}\r\n\r\nThis shows associativity.\r\n\r\n\\section*{8}\r\n\r\nGive an example of two elements $A$ and $B$ in $GL_2(\\mathbb{R})$ with $AB \\neq BA$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n$$A=\r\n  \\begin{pmatrix}\r\n    1 & 1 \\\\\r\n    0 & 1\r\n  \\end{pmatrix}\r\n  B=\r\n  \\begin{pmatrix}\r\n    1 & 0 \\\\\r\n    1 & 1\r\n  \\end{pmatrix}.\r\n$$\r\n\r\nNotice\r\n\r\n$$AB =   \r\n  \\begin{pmatrix}\r\n    2 & 1 \\\\\r\n    1 & 1\r\n  \\end{pmatrix}\r\n$$\r\n\r\nwhile \r\n\r\n$$BA = \r\n  \\begin{pmatrix}\r\n    1 & 1 \\\\\r\n    1 & 2\r\n  \\end{pmatrix}\r\n$$\r\n\r\n\\section*{9}\r\n\r\nProve that the product of two matrices in $SL_2(\\mathbb{R})$ has determinant one.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $A,B \\in SL_2(\\mathbb{R})$. This follows from the basic property of determinants\r\n\r\n$$\\det (AB) = \\det(A) \\det(B) = 1 \\cdot 1 = 1.$$\r\n\r\n\\section*{10}\r\n\r\nProve that the set of matrices of the form\r\n$$\r\n  \\begin{pmatrix}\r\n    1 & x & y \\\\\r\n    0 & 1 & z \\\\\r\n    0 & 0 & 1\r\n  \\end{pmatrix}\r\n$$\r\n\r\nis a group under matrix multiplication. This group, known as the \\textit{Heisenburg group}, is important in quantum physics. Matrix multiplication in the Heisenberg group is defined by\r\n\r\n$$\r\n  \\begin{pmatrix}\r\n    1 & x & y \\\\\r\n    0 & 1 & z \\\\\r\n    0 & 0 & 1\r\n  \\end{pmatrix}\r\n  \\begin{pmatrix}\r\n    1 & x' & y' \\\\\r\n    0 & 1 & z' \\\\\r\n    0 & 0 & 1\r\n  \\end{pmatrix}\r\n=\r\n  \\begin{pmatrix}\r\n    1 & x + x' & y + y'+ xz' \\\\\r\n    0 & 1 & z + z' \\\\\r\n    0 & 0 & 1\r\n  \\end{pmatrix}\r\n$$\r\n\r\nThe proof that this set of matrices forms a group is straightforward. Associativity follows from the associativity of matrix multiplication. The identity element is the usual identity matrix. Each matrix in the set is upper triangular and has an inverse (if this is not obvious, then the matrices can be easily put in reduced row echelon form).\r\n\r\n\r\n\\section*{11}\r\n\r\nProve that $\\det(AB) = det(A)det(B)$ in $GL_2(\\mathbb{R})$ Use this result to show that the binary operation in the group $GL_2(\\mathbb{R})$ is closed; that is, if $A$ and $B$ are in $GL_2(\\mathbb{R})$, then $AB \\in GL_2(\\mathbb{R})$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nWe already used this basic property of determinants in problem 9. We will prove it for $2 \\times 2$ matrices here. Recall the definition of the determinant for a $2 \\times 2$ matrix \r\n$$A = \r\n  \\begin{pmatrix}\r\n    a & b \\\\\r\n    c & d \\\\\r\n  \\end{pmatrix}\r\n$$\r\n  \r\nis given by $\\det(A) = ad - bc$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $A,B$ be $2 \\times 2$ matrices where  \r\n\r\n$$A = \r\n  \\begin{pmatrix}\r\n    a & b \\\\\r\n    c & d \\\\\r\n  \\end{pmatrix}\r\n  B = \r\n  \\begin{pmatrix}\r\n    a' & b' \\\\\r\n    c' & d' \\\\\r\n  \\end{pmatrix}\r\n$$\r\n\r\nand \r\n\r\n$$AB = \r\n  \\begin{pmatrix}\r\n    aa' + bc' & ab' + bd'\\\\\r\n    a'c + c'd & b'c + dd' \\\\\r\n  \\end{pmatrix}.\r\n$$\r\n\r\nNotice that \r\n\r\n\\begin{align*}\r\n\\det(AB) &= (aa' + bc')(b'c + dd') - (ab' + bd')(a'c + c'd) \\\\\r\n&= aa'b'c + aa'dd' + bc'b'c + bc'dd' - ab'a'c - ab'c'd - bd'a'c - bd'c'd \\\\\r\n&= (ad - bc) (a'd' - b'c') \\\\\r\n&= \\det(A) \\det(B)\r\n\\end{align*}\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $C,D \\in GL_2(\\mathbb{R})$. Then $\\det(C) \\neq 0$ and $\\det(D) \\neq 0$. By the property proved above $\\det{CD} = \\det{C}\\det{D}$. Since $\\det{C} \\neq 0$ and $\\det{D} \\neq 0$ we know that $\\det{CD} \\neq{0}$ hence $CD \\in GL_2(\\mathbb{R})$ and $GL_2(\\mathbb{R})$ is closed.\r\n\r\n\r\n\\section*{12}\r\n\r\nLet $\\mathbb{Z}_2^n = \\{ (a_1, a_2, ..., a_n) : a_i \\in \\mathbb{Z}_2 \\}$ Define a binary operation on $\\mathbb{Z}_2^n$ by \r\n\r\n$$(a_1, a_2, ..., a_n) + (b_1, b_2, ..., b_n) = (a_1+b_1, a_2+b_2, ..., a_n+b_n).$$\r\n\r\nProve that $\\mathbb{Z}_2^n$ is a group under this operation. This group is important in algebraic coding theory.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $(a_1, a_2, ..., a_n), (b_1, b_2, ..., b_n), (c_1, c_2, ..., c_n) \\in \\mathbb{Z}_2^n$. Notice that the identity is in $\\mathbb{Z}_2^n$ since\r\n\r\n$$(a_1, a_2, ..., a_n) + (0, 0, ..., 0) =  (a_1, a_2, ..., a_n).$$\r\n\r\nAlso note that each element has an inverse\r\n\r\n$$(a_1, a_2, ..., a_n) + (-a_1, -a_2, ..., -a_n) = (0, 0, ..., 0).$$\r\n\r\nAssociativity follows from the associativity of modular arithmetic\r\n\r\n\r\n\\begin{align*}\r\n((a_1, a_2, ..., a_n) + (b_1, b_2, ..., b_n)) + (c_1, c_2, ..., c_n) &= (a_1+b_1, a_2+b_2, ..., a_n+b_n) + (c_1, c_2, ..., c_n) \\\\\r\n&= ((a_1+b_1) + c_1, (a_2+b_2) + c_2, ..., (a_n+b_n) + c_n) \\\\ \r\n&= (a_1 + (b_1+c_1), a_2 + (b_2+c_2), ..., (a_n + (b_n+c_n)) \\\\\r\n&= (a_1, a_2, ..., a_n) + ((b_1, b_2, ..., b_n) + (c_1, c_2, ..., c_n)).\r\n\\end{align*}\r\n\r\n\r\n\\section*{13}\r\n\r\nShow that $\\mathbb{R}^{*} = \\mathbb{R} \\setminus \\{ 0 \\}$ is a group under the operation of multiplication.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $x \\in \\mathbb{R}^{*}$. Notice that, since multiplication of two non-zero real numbers is non-zero,$\\mathbb{R}^{*}$ is closed. Associativity follows from the associativity of the multiplication of real numbers. The identity is 1. Notice that $x^{-1} = \\frac{1}{x}$ since\r\n\r\n$$xx^{-1} = x \\frac{1}{x} = 1.$$\r\n\r\nHence, $\\mathbb{R}^*$ is a group\r\n\r\n\r\n\\section*{14}\r\n\r\nGiven the groups $\\mathbb{R}^*$ and $\\mathbb{Z}$ let $G = \\mathbb{R} \\times \\mathbb{Z}$. Define a binary operation $\\circ$ on $G$ by $(a,m) \\circ (b,n) = (ab, m+n)$. Show that $G$ is a group under this operation.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nThis proof is straightforward since the two contributing groups are operated on independently. Associativity follows from the associativity of $\\mathbb{R}^*$ and $\\mathbb{Z}$. The identity is $(1,0)$. The inverse of $(x, n) \\in \\mathbb{R}^* \\times \\mathbb{Z}$ is $(1/x, -n)$.\r\n\r\n\\section*{15}\r\n\r\nThe dihedral group of six elements is the smallest non-abelian group. Here is the Cayley table\r\n\r\n\\begin{tabular}{ l | l l l l l l }\r\n  * & e & a & b & c & d & f \\\\\r\n  \\hline      \r\n  e & e & a & b & c & d & f \\\\\r\n  a & a & e & d & f & b & c \\\\\r\n  b & b & f & e & d & c & a \\\\\r\n  c & c & d & f & e & a & b \\\\\r\n  d & d & c & a & b & f & e \\\\\r\n  f & f & b & c & a & e & d\r\n\\end{tabular}\r\n\r\n\r\n\\section*{16}\r\n\r\nGive a specific example of some group $G$ and elements $g, h \\in G$ where $(gh)^n \\neq g^n h^n$. \r\n\r\n\\vspace{\\baselineskip}\r\n\r\nWe need to find a group that is not abelian. Consider $GL_2(\\mathbb{R})$. Let \r\n\r\n$$A = \r\n  \\begin{pmatrix}\r\n    1 & 2 \\\\\r\n    3 & 2\r\n  \\end{pmatrix},\r\n  B = \r\n  \\begin{pmatrix}\r\n    2 & 1 \\\\\r\n    2 & 3\r\n  \\end{pmatrix}.\r\n$$\r\n\r\nNotice that \r\n\r\n$$A^{-1} = \r\n  \\begin{pmatrix}\r\n    -1/2 & 1/2 \\\\\r\n    3/4 & -1/4\r\n  \\end{pmatrix},\r\n  B^{-1} = \r\n  \\begin{pmatrix}\r\n    3/4 & -1/4 \\\\\r\n    -1/2 & 1/2 \r\n  \\end{pmatrix}\r\n$$\r\n\r\nso $A, B \\in GL_2(\\mathbb{R})$. Then notice that \r\n\r\n$$A^n B^n = \\begin{pmatrix}\r\n    102 & 101 \\\\\r\n    154 & 155\r\n  \\end{pmatrix} \\neq \r\n    \\begin{pmatrix}\r\n    106 & 105 \\\\\r\n    150 & 151 \r\n  \\end{pmatrix} = (AB)^n.$$\r\n  \r\n  \r\n\\section*{18}\r\n\r\nShow that there are $n!$ permutations of a set containing $n$ items.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider a permutation of a set as a reordering. For the first element of the reordering there are $n$ options, for the second element there are $n-1$ options, ..., for the $n-1$th element there are 2 options, and for the $n$th element there is 1 option. Hence there are $n(n-1) ... (2)(1) = n!$ permutations of a set with $n$ elements.\r\n  \r\n\r\n\\section*{24}\r\n\r\nLet $a$ and $B$ be elements in a group $G$. Prove that $ab^na^{-1} = (aba^{-1})^n$ for $n \\in \\mathbb{Z}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n$$ab^na^{-1} = a b ... b  a^{-1} = a  b a^{-1} a ... a^{-1} a b a^{-1} = (aba^{-1})^n.$$\r\n\r\n\r\n\\section*{25}\r\n\r\nLet $U(n)$ be the group of units in $\\mathbb{Z}_n$. If $n > 2$, prove that there is an element $k \\in U(n)$ such that $k^2 = 1$ and $k \\neq 1$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $n > 2$. There are two parts to the proof. First we will show that $U(n)$ has an even number of elements. Then we will show that if a group has an even number of elements there is $g$ in the group such that $g^2 = e$. \r\n\r\n\\vspace{\\baselineskip}\r\n\r\nRecall that for each $x \\in \\mathbb{Z}_n x \\neq 0$ that $x \\in U(n)$ if $\\gcd(k,n) = 1$. This means that the number of elements in $U(n)$ is given by $\\phi(n)$ where $\\phi$ is Euler's totient function. Note that for $n > 2$ that $\\phi$ is even (see comment below for sketch of proof).\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nWe use a similar argument to prove the second statement. Assume that a group $G$ has an even number of elements. We can pair each element $g \\in G$ with its inverse. Note that $e = e^{-1}$ isn't paired with any other element. Since $G$ has an even number of elements there must be one other element, $a$, such that $a^2 = e$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nNote that $\\phi(mn) = \\phi(m) \\phi(n)$ and that if $p$ is prime then $\\phi(p) = p-1$. Combining these facts and the Fundamental Theorem of Arithmetic yields the desired statement.\r\n\r\n\r\n\r\n\r\n\\section*{26}\r\n\r\nProve that the inverse of $g1 g2 ... g_n$ is $g_n^{-1} g_{n-1}^{-1} ... g_1^{-1}$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n\\begin{align*}\r\n(g1 g2 ... g_{n-1} g_n) (g_n^{-1} g_{n-1}^{-1} ... g_2^{-1} g_1^{-1}) &= g1 g2 ... g_{n-1} g_{n-1}^{-1} ... g_2^{-1} g_1^{-1} \\\\\r\n\\vdots \\\\\r\n&= g_1 g_2 g_2^{-1} g_1^{-1} \\\\\r\n&= g_1 g_1^{-1} \\\\\r\n&= e.\r\n\\end{align*}\r\n\r\n\r\n\\section*{27}\r\n\r\nProve the remainder of Proposition 3.6: if $G$ is a group and $a,b \\in G$, then the equation $xa = b$ has unique solutions in $G$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nAssume that $xa = b$ has more than one solution. Call two solutions $x_1, x_2$. Note that \r\n\r\n\\begin{align*}\r\nx_1 a &= b \\\\\r\nx_1 a a^{-1} &= b a^{-1} \\\\\r\nx_1 &= b a^{-1}\r\n\\end{align*}\r\n\r\nand \r\n\r\n\\begin{align*}\r\nx_2 a &= b \\\\\r\nx_2 a a^{-1} &= b a^{-1} \\\\\r\nx_2 &= b a^{-1}\r\n\\end{align*}\r\n\r\nThen, since the group operation is well-defined $x_1 = x_2$, a contradiction. This proves that solutions to $xa = b$ in $G$ are unique.\r\n\r\n\r\n\\section*{28}\r\n\r\nProve Theorem 3.8. In a group, the usual laws of exponents hold; that is, for all $g, h \\in G$,\r\n\r\n$$g^m g^n = g^{m+n} \\text{ for all } m,n \\in \\mathbb{Z};$$\r\n$$(g^m)^n = g^{mn} \\text{ for all } m,n \\in \\mathbb{Z};$$\r\n$$(gh)^n = (h^{-1} g^{-1})^{-n} \\text{ for all } n \\in \\mathbb{Z}$$\r\n\r\nFurthermore, if $G$ is abelian, then $(gh)^n = g^n h^n$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nTo prove the first statement, notice that (we will index for clarity where $g_i = g$)\r\n\r\n$$g^m g^n = g_1 g_2 ... g_m g_1 ... g_n =  g^{m+n}.$$\r\n\r\nTo prove the second statement consider \r\n\r\n$$(g^m)^n = g^m ... g^m.$$\r\n\r\nFrom the first statement it follows that \r\n\r\n$$(g^m ... g^m = g^{m+...+m} = g^{mn}.$$\r\n\r\nTo prove the second statement first note that\r\n\r\n$$gh = (h^{-1} g^{-1})^{-1}.$$\r\n\r\nIt follows from the second statement that \r\n\r\n$$(gh)^n = ((h^{-1} g^{-1})^{-1})^n = (h^{-1} g^{-1})^{-n}.$$\r\n\r\nAssume $G$ is abelian. Consider \r\n\r\n$$(gh)^n = gh .. gh = g...g h...h = g^n h^n.$$\r\n\r\n\\section*{29}\r\n\r\nProve the right and left cancellation laws for a group $G$; that is , show that in the group $G$, $ba = ca$ implies $b = c$ and $ab = ac$ implies $b = c$ for elements $a,b,c \\in G$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nThis is a straightforward application of the existence of inverses in a  group.\r\n\r\nConsider\r\n\r\n\\begin{align*}\r\nba &= ca \\\\\r\nbaa^{-1} &= caa^{-1} \\\\\r\nbe &= ce \\\\ \r\nb &= c\r\n\\end{align*}\r\n\r\n\\begin{align*}\r\nab &= ac \\\\\r\na^{-1}ab &= a^{-1}ac \\\\\r\neb &= ec \\\\\r\nb &= c\r\n\\end{align*}\r\n\r\n\r\n\\section*{30}\r\n\r\nShow that if $a^2 = e$ for all elements $a$ in a group $G$, then $G$ must be abelian\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $a,b \\in G$. Consider\r\n\r\n$$(ab)(ab) = e = (aa)(bb)$$\r\n$$abab = aabb$$\r\n$$ ba = ab.$$\r\n\r\n\r\n\\section*{31}\r\n\r\nShow that if $G$ is a finite group of even order, then there is an $a \\in G$ such that $a$ is not the identity and $a^2 = e$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nAssume that a group $G$ has an even number of elements. We can pair each element $g \\in G$ with its inverse. Note that $e = e^{-1}$ isn't paired with any other element. Since $G$ has an even number of elements there must be one other element, $a$, such that $a^2 = e$.\r\n\r\n\r\n\\section*{32}\r\n\r\nLet $G$ be a group and suppose that $(ab)^2 = a^2b^2$ for all $a$ and $b$ in $G$. Prove that $G$ is an abelian group.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n$$(ab)^2 = a^2b^2$$\r\n\r\n$$abab = aa bb$$\r\n\r\nmultiplying on the left by $a^{-1}$ yields\r\n\r\n$$bab = abb$$\r\n\r\nand multiplying on the left by $b^{-1}$ yields\r\n\r\n$$ba = ab.$$\r\n\r\nHence, $G$ is an abelian group.\r\n\r\n\r\n\\section*{41}\r\n\r\nLet $G$ be the group of $2 \\times 2$ matrices under addition and \r\n\r\n$$ H = \\left\\{\r\n  \\begin{pmatrix}\r\n    a & b \\\\\r\n    c & d\r\n  \\end{pmatrix} : a + d = 0\\right\\}.\r\n$$\r\n\r\nProve that $H$ is a subgroup of $G$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nNote that the identity is in $H$ since $0 + 0 = 0$. Consider the sum of two matrices in H\r\n\r\n$$\\begin{pmatrix}\r\n    a & b \\\\\r\n    c & d\r\n  \\end{pmatrix}\r\n  +\r\n  \\begin{pmatrix}\r\n    a' & b' \\\\\r\n    c' & d'\r\n  \\end{pmatrix}\r\n  =\r\n  \\begin{pmatrix}\r\n    a + a' & b + b' \\\\\r\n    c + c' & d + d'\r\n  \\end{pmatrix}.\r\n$$\r\n\r\nNote that since $a + a' + d + d' = 0$ we know that the sum of the matrices is also a member of $H$. Note that the inverse of a matrix $A \\in H$ is given by $-A$. Let \r\n\r\n$$A = \r\n  \\begin{pmatrix}\r\n    a & b \\\\\r\n    c & d\r\n  \\end{pmatrix}.\r\n$$\r\n\r\nNote that since $-a + -d = 0$ that $-A \\in H$. This proves that $H$ is a subgroup of $G$.\r\n\r\n\r\n\\section*{44}\r\n\r\nProve that the intersection of two subgroups of a group $G$ is also a subgroup of $G$\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $H$ and $K$ be subgroups of $G$. Note that since $H$ and $K$ are subgroups, the identity element is in both and hence the identity is in $H \\cap K$. Let $x,y \\in H \\cap K$. Note that $xy \\in H$ since $x,y \\in H$ and similarly $xy \\in K$ since $x,y \\in K$. Therefore, $xy \\in H \\cap K$. Note that $x^{-1} \\in H$ since $x \\in H$ and $x^{-1} \\in K$ since $x \\in K$. Therefore, $x^{-1} \\in H \\cap K$. This shows that $H \\cap K$ is a subgroup of $G$.\r\n\r\n\r\n\r\n\\section*{45}\r\n\r\nProve or disprove: if $H$ and $K$ are subgroups of a group $G$, then $H \\cup K$ is a subgroup of $G$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider the following counterexample. Note that $2\\mathbb{Z}$ and $3\\mathbb{Z}$ are both subgroups of $\\mathbb{Z}$ under addition. It is clear that $2\\mathbb{Z} \\cup 3\\mathbb{Z}$ is not a subgroup of $\\mathbb{Z}$ because it is not closed under addition. For example $2,3 \\in 2\\mathbb{Z} \\cup 3\\mathbb{Z}$ but their sum $5 \\not\\in 2\\mathbb{Z} \\cup 3\\mathbb{Z}$\r\n\r\n\r\n\\section*{48}\r\n\r\nLet $a$ and $b$ be elements of a group $G$. If $a^4b = ba$ and $a^3 = e$, prove that $ab = ba$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n\\begin{align*}\r\nba &= a^4b \\\\\r\n&= a^3 ab \\\\\r\n&= ab.\r\n\\end{align*}\r\n\r\n\r\n\\section*{49}\r\n\r\nNote that this is a duplicate of problem 48.\r\n\r\nLet $a$ and $b$ be elements of a group $G$. If $a^4b = ba$ and $a^3 = e$, prove that $ab = ba$.\r\n\\vspace{\\baselineskip}\r\n\r\nConsider\r\n\r\n\\begin{align*}\r\nba &= a^4b \\\\\r\n&= a^3 ab \\\\\r\n&= ab.\r\n\\end{align*}\r\n\r\n\r\n\\section*{51}\r\n\r\nIf $xy = x^{-1} y^{-1}$ for all $x$ and $y$ in $G$, prove that $G$ must be abelian.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nNote \r\n\r\n$$x = xe = x^{-1}e = x^{-1}.$$\r\n\r\nConsider\r\n\r\n$$xy = (xy)^{-1} = y^{-1} x^{-1} = yx.$$\r\n\r\n\r\n\\section*{54}\r\n\r\nLet $H$ be a subgroup of $G$. If $g \\in G$, show that $gHg^{-1} = \\{ghg^{-1}: h \\in H \\}$ is also a subgroup of $G$.\r\n\r\n\\vspace{\\baselineskip}\r\n\r\nLet $g \\in G$ and $h_1, h_2 \\in H$. Notice that $e = geg^{-1}$ and hence $e \\in gHg^{-1}$. Notice that $gHg^{-1}$ is closed since $gh_1g^{-1} g h_2 g^{-1} = g h_1 h_2 g^{-1}$ and $H$ is closed. Note that $g h_1 g^{-1} g h_1^{-1} g^{-1} = e$. Hence, for all $x \\in H$ $x^{-1} \\in H$ as well. This proves that $gHg^{-1}$ is a subgroup of $G$.\r\n\r\n\r\n\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "ccf6d5ad91b80b9495e40a2b733c17d38c068ea8", "size": 17739, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "judson-solutions/Chapter03.tex", "max_stars_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_stars_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-10-20T22:41:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-12T10:11:45.000Z", "max_issues_repo_path": "judson-solutions/Chapter03.tex", "max_issues_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_issues_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2017-10-19T17:09:07.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-26T03:44:24.000Z", "max_forks_repo_path": "judson-solutions/Chapter03.tex", "max_forks_repo_name": "agdenadel/judson-abstract-algebra-solutions", "max_forks_repo_head_hexsha": "7e9e9c7126741f31c32bed97a8278b3866afbd63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-12T10:11:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-25T20:25:48.000Z", "avg_line_length": 26.5952023988, "max_line_length": 450, "alphanum_fraction": 0.5631659056, "num_tokens": 6704, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.41665554974225155}}
{"text": "% ===============================================================================\r\n\\documentclass[a4paper]{article}\r\n%\\documentclass{sig-alternate}\r\n\\usepackage{amssymb,amsmath}\r\n\\usepackage[margin=0.5in]{geometry}\r\n\r\n\\newcommand{\\I}{\\mathbb{I}}\r\n\\renewcommand{\\vec}[1]{\\mathbf{#1}}\r\n\\newcommand{\\Sim}{\\mathrm{Sim}}\r\n\\newcommand{\\ExpNCall}[1]{\\text{Exp-}#1\\text{-Call@}k}\r\n\\newcommand{\\TlessK}{T_{\\!\\!\\:k\\text{-}1}}\r\n\\def\\argmax{\\operatornamewithlimits{\\!arg \\;\\! max\\,}}\r\n\r\n\r\n% ===============================================================================\r\n\\begin{document}\r\n\r\n% ===============================================================================\r\n\\appendix\r\n\\section{Full derivation}\r\n\\subsection{Optimizing objective}\r\nWe want to choose $S_k^*$ that maximizes the objective:\r\n\\begin{align*}\r\n  \\ExpNCall{n}(S_k,\\vec{q})\r\n  = \\mathbb{E}[R_k\\geq n|s_1,\\dots,s_k,\\vec{q}]\r\n\\end{align*}\r\n\r\n\\noindent\r\nBy taking a greedy approach, we select $s_k^*$ given $S_{k-1}^*$:\r\n\\begin{align}\r\n  s_k^* & = \\argmax_{s_k} \\mathbb{E}[R_k\\geq n|S_{k-1}^*,s_k,\\vec{q}] \\nonumber\\\\\r\n% \r\n  & = \\argmax_{s_k} P(R_k\\geq n|S_{k-1}^*,s_k,\\vec{q}) \\label{note1}\\\\\r\n%\r\n  & = \\argmax_{s_k} \\!\\sum_{T_k} \\Bigl( P(t|\\vec{q}) \\,P(t_k|s_k) \\Bigl( \\prod_{i=1}^{k-1} P(t_i|s_i^*) \\Bigr) \\cdot P(R_k\\geq n|T_k,S_{k-1}^*,s_k,\\vec{q}) \\Bigr) \\label{note2}\\\\\r\n%\r\n  & = \\argmax_{s_k} \\!\\sum_{T_k} P(t|\\vec{q}) \\,P(t_k|s_k) \\Bigl( \\prod_{i=1}^{k-1} P(t_i|s_i^*) \\Bigr) \\cdot \\Bigl( \\mbox{$\\underbrace{P(r_k\\!\\geq\\!0|R_{k-\\!1}\\!\\geq\\!n,t_k,t)}_{1}$} P(\\!R_{k-\\!1}\\!\\geq\\!n|\\TlessK) \\nonumber \\\\[-1.5mm]\r\n  & \\hspace{55mm} + P(r_k=1|R_{k-1}\\!=\\!n\\!-\\!1,t_k,t) P(\\!R_{k-\\!1}\\!=\\!n\\!-\\!1|\\TlessK) \\Big) \\label{note3}\\\\\r\n%\r\n  & = \\argmax_{s_k} \\Bigg( \\sum_{\\TlessK} \\bigg[ \\mbox{$\\underbrace{ \\!\\sum_{t_k} \\!\\!P(t_k|s_k) }_{1}$} \\bigg] P(t|\\vec{q}) \\Bigl( \\prod_{i=1}^{k-1} P(t_i|s_i^*) \\Bigr) P(R_{\\!k-\\!1}\\geq\\!n|\\TlessK) + \\nonumber \\\\[-1.5mm]\r\n  & \\hspace{20mm} \\sum_{\\TlessK} \\bigg[ \\sum_{t_k} P(t_k|s_k) P(r_k=1|t_k,t) \\bigg] P(t|\\vec{q}) \\Bigl( \\prod_{i=1}^{k-1} P(t_i|s_i^*) \\Bigr) P(\\!R_{k-\\!1}\\!=\\!n\\!-\\!1|\\TlessK) \\Bigg) \\nonumber\\\\\r\n%\r\n  & = \\argmax_{s_k} \\sum_{t} P(t|\\vec{q}) P(t_k\\!=\\!t|s_k) \\bigg[ \\sum_{t_1, \\dots, t_{k-1}}  P(R_{k-\\!1}\\!=\\!n\\!-\\!1|\\TlessK) \\prod_{i=1}^{k-1} P(t_i|s_i^*) \\bigg] \\label{note4}\\\\\r\n%\r\n  & = \\argmax_{s_k} \\sum_{t} \\!P(t|\\vec{q}) P(t_k\\!=\\!t|s_k) P(R_{k-\\!1}\\!=\\!n\\!-\\!1|S_{k-1}^*) \\label{eq.ncall}\r\n\\end{align}\r\n\r\n\\noindent\r\nNote: \\\\\r\n(1) Since $( R_k \\geq n )$ can only be zero or one in probability. \\\\\r\n(2) Marginalize out $T_k$. \\\\\r\n(3) Split $( R_k \\geq n )$ into two disjoint events $(r_k \\! \\geq \\! 0, R_{k\\!-\\!1}\\!\\geq \\!n)$, $(r_k\\!=\\!1, R_{k\\!-\\!1}\\!=\\!n\\!-\\!1)$, conditioned on $R_{k-1}$. \\\\\r\n(4) Drop the first line as it does not involve $s_k$ and has no influence in determining $s_k^*$. \\\\\r\nNote that $\\sum_{t_k} \\!\\! P(t_k|s_k) P(r_k\\!\\!=\\!\\!1|t_k,t) = \\sum_{t_k} \\!\\! P(t_k|s_k) \\I[t_k\\!=\\!t] \\! = \\! P(t_k\\!\\!=\\!\\!t|s_k)$, where $t$ is implicitly conditioned and is not explicitly shown here. \\\\\r\n(5) This objective is recursively defined. \\\\\r\n\r\nBy similar reasoning, the probability needed in~\\eqref{eq.ncall} is recursively defined as\r\n\\begin{align*}\r\nP(R_k=n|S_k,t)=\r\n\\begin{cases}\r\nn \\geq 1, k > 1:  &  \\bigl( 1\\!-\\!P(t_k\\!=\\!t|s_k) \\bigr) P(R_{k-1}\\!=\\!n|S_{k-1},t) \\nonumber \\\\\r\n  & \\hspace{5mm} + P(t_k\\!=\\!t|s_k) P(R_{k-\\!1}\\!=\\!n\\!-\\!1|S_{k-\\!1},t) \\\\\r\n%%\r\nn = 0, k > 1:   & \\bigl( 1\\!-\\!P(t_k\\!=\\!t|s_k) \\bigr) P(R_{k-\\!1}\\!=\\!0|S_{k-\\!1},t) \\\\\r\n%%\r\nn = 1, k = 1:   & P(t_1\\!=\\!t|s_1) \\\\\r\nn = 0, k = 1:   & 1 - P(t_1\\!=\\!t|s_1)\r\n\\end{cases}\r\n%       \\bigl 1-P(t_1\\!=\\!t|s_1) \\bigr) = \\bigl 1-P(t_1\\!=\\!t|s_1) \\bigr) \\\\\r\n%  & \\hspace{2mm} P(R_1\\!=\\!1|S_1,t) = P(t_1\\!=\\!t|s_1)\r\n\\end{align*}\r\n\r\nFor expected $n$-call@$k$ where $n \\! \\leq \\! k/2$, by unrolling its recursive definition in \\eqref{eq.ncall}, the explicit objective is\r\n\\begin{align}\r\n  & s_k^* = \\argmax_{s_k} \\sum_t \\Biggl( P(t|\\vec{q}) \\, P(t_k=t|s_k) \\sum_{j_1, \\dots, j_{n-\\!1}} \\hspace{-14mm} \\prod_{\\hspace{14.5mm} l \\in \\{j_1, \\dots, j_{n-\\!1}\\}} \\hspace{-14mm} P(t_l\\!=\\!t|s_l^*) \\hspace{-13mm} \\prod_{\\substack{i=1 \\\\ \\hspace{14mm} i \\notin \\{j_1, \\dots, j_{n-\\!1}\\}}}^{k-1} \\hspace{-13mm} \\!\\bigl( 1 - P(t_i\\!=\\!t|s_i^*) \\bigr) \\!\\Biggr) \\label{eq.ncall.alt}\r\n\\end{align}\r\nwhere $j_1, \\dots, j_{n-1} \\in \\{1,\\ldots,k-1\\}$ satisfy \r\nthat $j_i < j_{i+1}$ (i.e.,\r\nan ordered permutation of $n-1$ result set indices). \\\\\r\n\r\nSimilarly, for expected $n$-call@$k$ where $n \\! > \\! k/2$, the explicit objective is\r\n\\begin{align}\r\n  & s_k^* = \\argmax_{s_k} \\sum_t \\Biggl( P(t|\\vec{q}) \\, P(t_k=t|s_k) \\sum_{j_n, \\dots, j_{k-\\!1}} \\hspace{-14mm} \\prod_{\\hspace{14.5mm} l \\in \\{j_n, \\dots, j_{k-\\!1}\\}} \\hspace{-14mm} \\bigl(1 - P(t_l\\!=\\!t|s_l^*) \\bigr) \\hspace{-13mm} \\prod_{\\substack{i=1 \\\\ \\hspace{14mm} i \\notin \\{j_n, \\dots, j_{k-\\!1}\\}}}^{k-1} \\hspace{-13mm} P(t_i\\!=\\!t|s_i^*) \\!\\Biggr) \\label{eq.ncall.alt2}\r\n\\end{align}\r\nwhere $j_n, \\dots, j_{k-1} \\in \\{1,\\ldots,k-1\\}$ satisfy \r\nthat $j_i < j_{i+1}$ (i.e.,\r\nan ordered permutation of $k-n$ result set indices).\r\n\r\n% ===============================================================================\r\n\\subsection{Relation to MMR: expected n-call@k when $n>k/2$}\r\n\r\nAssuming that $\\forall i \\; P(t_i|s_i) \\in \\{0,1\\}$ and $P(t|\\vec{q}) \\in \\{0,1\\}$. It is possible to write\r\n\\begin{align*}\r\n  \\hspace{-13mm} \\prod_{\\hspace{14.5mm} l \\in \\{j_n, \\dots, j_{k-\\!1}\\}} \\hspace{-14mm} \\bigl( 1 - \\!P(t_l\\!=\\!t|s_l^*) \\bigr) \r\n  = 1 - \\Biggl( 1 - \\hspace{-14mm} \\prod_{\\hspace{14.5mm} l \\in \\{j_n, \\dots, j_{k-\\!1}\\}} \\hspace{-13mm} \\bigl( 1 - P(t_l\\!=\\!t|s_l^*) \\bigr) \\Biggr)\r\n  = 1 - \\Bigl( \\max_{l \\in \\{j_n, \\dots, j_{k-\\!1}\\}} P(t_l\\!=\\!t|s_l^*) \\Bigr)\r\n\\end{align*}\r\n\r\nThis allows us to rewrite~\\eqref{eq.ncall.alt2}\r\n\\begin{align}\r\n & s_k^* = \\, \\argmax_{s_k} \\sum_t \\Biggl( P(t|\\vec{q}) P(t_k\\!=\\!t|s_k)  \\sum_{\\hspace{-1mm} j_n, \\dots, j_{k-\\!1}} \\hspace{-13.5mm} \\prod_{\\substack{i=1 \\\\ \\hspace{14mm} i \\notin \\{j_n, \\dots, j_{k-\\!1}\\}}}^{k-1} \\hspace{-13mm} P(t_i\\!=\\!t|s_i^*) \\nonumber \\\\[-1.5mm]\r\n & \\hspace{25mm} - \\!P(t|\\vec{q}) P(t_k\\!=\\!t|s_k) \\sum_{j_n, \\dots, j_{k-\\!1}} \\hspace{-14mm} \\prod_{\\substack{i=1 \\\\ \\hspace{14mm} i \\notin \\{j_n, \\dots, j_{k-\\!1}\\}}}^{k-1} \\hspace{-13mm} P(t_i\\!=\\!t|s_i^*) \\max_{l \\in \\{j_n, \\dots, j_{k-\\!1}\\}} P(t_l\\!=\\!t|s_l^*) \\Biggr) \\label{eq.ncall.alt3}\r\n\\end{align}\r\n\r\nAssuming $m$ relevant documents are already selected in the $k-1$ collection, then the top term (specifically $\\prod_i$) is non-zero $\\binom{m}{n-1}$ times.  For the\r\nbottom term, it takes $n-1$ relevant documents to satisfy its\r\n$\\prod_i$, and one additional relevant document to satisfy the\r\n$\\max_l$ making it non-zero $\\binom{m}{n}$ times.  Factoring out the\r\n$\\max$ element from the bottom and pushing the $\\sum_t$ inwards (all legal\r\ndue to the $\\{0,1\\}$ subtopic probability assumption),~\\eqref{eq.ncall.alt3} becomes\r\n\\begin{align}\r\n s_k^* & = \\argmax_{s_k} \\left[ \\sum_t P(t|\\vec{q}) P(t_k\\!=\\!t|s_k) \\binom{m}{n-1} \\right]\r\n - \\left[ \\sum_t P(t|\\vec{q}) P(t_k\\!=\\!t|s_k) \\binom{m}{n} \\underbrace{\\max_{s_i \\in S_{k-1}^*} P(t_i\\!=\\!t|s_i)}_{1} \\right] \\nonumber\\\\\r\n & = \\argmax_{s_k} \\binom{m}{n-1} \\underbrace{\\sum_t P(t|\\vec{q}) P(t_k\\!=\\!t|s_k)}_{\\textrm{relevance}: \\; \\Sim_1(s_k,\\vec{q})}\r\n - \\binom{m}{n} \\max_{s_i \\in S_{k-1}^*} \\underbrace{\\sum_t P(t_i\\!=\\!t|s_i) \\!P(t|\\vec{q}) P(t_k\\!=\\!t|s_k)}_{\\textrm{diversity}: \\; \\Sim_2(s_k,s_i,\\vec{q})} \\label{note9}\\\\\r\n & = \\argmax_{s_k} \\!\\! \\frac{n}{m\\!+\\!1} \\Sim_1(s_k,\\vec{q}) - \\frac{m\\!-\\!n\\!+\\!1}{m+1} \\max_{s_i \\in S_{k-1}^*} \\! \\Sim_2(s_k,s_i,\\vec{q}) \\label{note10}\r\n\\end{align}  \r\n\r\n\\noindent\r\nNote: \\\\\r\n(9) We can rearrange \"$\\sum_t P(t|\\vec{q}) \\max_{s_i} \\cdots$\" as \"$\\max_{s_i} \\sum_t P(t|\\vec{q}) \\cdots$\" since the $\\sum_t P(t|\\vec{q})$ 'selects' the only $t$ for which $P(t|\\vec{q}) = 1$. \\\\\r\n(10) Normalize by dividing the equation by $\\binom{m}{n-1} + \\binom{m}{n} = \\binom{m+1}{n}$ (Pascal's rule). \\\\\r\nThe result is the same as the case where $n \\leq k/2$. \\\\\r\n\r\nThe reason that we do not remove the max term in~\\eqref{note9} is that this allows us to compare the objective with MMR directly. Also, leaving the max term suggests an approximate form for the case where the subtopic probabilities are non-deterministic (not strictly 0 or 1), and approaches~\\eqref{note9} as the probabilities become more deterministic. \\\\\r\n\r\nIn practice, under the greedy approach of the expected n-call@k in selecting $S_k^*$, we expect that there are already $n$ relevant documents chosen in the set $S_{k-1}^* = \\{s_1^*, \\dots, s_{k-1}^*\\}$ (where $n << k$). In expectation, $m = n$ and hence the optimizing objective can be thought to be\r\n\\begin{align}\r\n s_k^* = \\argmax_{s_k} \\!\\! \\frac{n}{n\\!+\\!1} \\Sim_1(s_k,\\vec{q}) - \\frac{1}{n+1} \\max_{s_i \\in S_{k-1}^*} \\! \\Sim_2(s_k,s_i,\\vec{q}) \\label{eq.ncall.final}\r\n\\end{align} \r\n\r\nFrom~\\eqref{eq.ncall.final}, it is simple to see that the diversification level decreases with $n$.\r\n\r\n% ===============================================================================\r\n\\section{Additional derivation}\r\n\\subsection{Alternative derivation for expected 2-call@k}\r\n\r\n\\begin{align*}\r\n  s_k^* & = \\argmax_{s_k} \\mathbb{E} \\!\\left[ R_k \\geq 2 \\left| S_{k-1}^*, s_k, \\vec{q} \\right.\\right] \\\\\r\n%%  \r\n  & = \\argmax_{s_k} \\mathbb{E} \\!\\Bigg[ (r_1=1 \\wedge r_2=1) \\vee (r_1=0 \\wedge r_2=1 \\wedge r_3=1) \\vee (r_1=1 \\wedge r_2=0 \\wedge r_3=1) \\,\\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=0 \\wedge r_2=0 \\wedge r_3=1 \\wedge r_4=1) \\vee (r_1=0 \\wedge r_2=1 \\wedge r_3=0 \\wedge r_4=1) \\,\\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=1 \\wedge r_2=0 \\wedge r_3=0 \\wedge r_4=1) \\vee \\dots \\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=0 \\wedge \\dots \\wedge r_{k-2}=0 \\wedge r_{k-1}=1 \\wedge r_k=1) \\,\\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=0 \\wedge \\dots \\wedge r_{k-3}=0 \\wedge r_{k-2}=1 \\wedge r_{k-1} = 0 \\wedge r_k=1) \\vee \\dots \\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=1 \\wedge r_2=0 \\wedge \\dots \\wedge r_{k-1}=0 \\wedge r_k=1) \\Bigg| S_{k-1}^*, s_k, \\vec{q} \\,\\Bigg] \\\\\r\n%%  \r\n  & = \\argmax_{s_k} \\mathbb{E} \\!\\Bigg[ (r_1=1 \\wedge r_2=1) \\vee (r_1=0 \\wedge r_2=1 \\wedge r_3=1) \\vee (r_1=1 \\wedge r_2=0 \\wedge r_3=1) \\,\\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=0 \\wedge r_2=0 \\wedge r_3=1 \\wedge r_4=1) \\vee (r_1=0 \\wedge r_2=1 \\wedge r_3=0 \\wedge r_4=1) \\,\\vee \\\\\r\n  & \\hspace{21.7mm} (r_1=1 \\wedge r_2=0 \\wedge r_3=0 \\wedge r_4=1) \\vee \\dots \\vee \\\\\r\n  & \\hspace{21.7mm} \\left.\\left. \\bigvee_{j=1}^{k-1} \\left( r_k=1 \\wedge \\bigwedge_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} r_i=0 \\wedge r_j=1 \\right) \\right| S_{k-1}^*, s_k, \\vec{q} \\,\\right] \\\\\r\n%%\r\n  & = \\argmax_{s_k} \\sum_{j=1}^{k-1} P \\!\\!\\left(\\left. r_k=1 \\wedge \\bigwedge_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} r_i=0 \\wedge r_j=1 \\right| S_{k-1}^*, s_k, \\vec{q} \\,\\right) \\\\\r\n  & = \\argmax_{s_k} \\sum_{j=1}^{k-1} \\left( \\sum_{t_1, \\dots, t_k, t} P(t|\\vec{q}) \\, P(t_k|s_k) \\mathbb{I} [t_k=t] \\, P(t_j|s_j^*) \\mathbb{I} [t_j=t] \\prod_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} P(t_i|s_i^*) \\mathbb{I} [t_i \\neq t] \\right) \\\\\r\n  & = \\argmax_{s_k} \\sum_t P(t|\\vec{q}) \\, P(t_k=t|s_k) \\sum_{j=1}^{k-1} \\left( P(t_j=t|s_j^*) \\prod_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} \\left( 1 - P \\! \\left( t_i=t|s_i^* \\right) \\right) \\right)\r\n\\end{align*}\r\n\r\n\\noindent\r\nAssuming that $\\forall i \\; P(t_i|s_i) \\in \\{0,1\\}$ and $P(t|\\vec{q}) \\in \\{0,1\\}$, the objective becomes:\r\n\\begin{align}\r\n  s_k^* & = \\argmax_{s_k} \\sum_t P(t|\\vec{q}) \\, P(t_k = t | s_k) \\sum_{j=1}^{k-1} \\left( P(t_j=t|s_j^*) \\prod_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} \\left( 1 - P \\! \\left( t_i=t|s_i^* \\right) \\right) \\right) \\nonumber \\\\\r\n  & = \\argmax_{s_k} \\sum_t P(t|\\vec{q}) \\, P(t_k = t | s_k) \\sum_{j=1}^{k-1} \\left( P(t_j=t|s_j^*) \\left[ 1 - \\left( 1 - \\prod_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} \\left( 1 - P \\! \\left( t_i=t|s_i^* \\right) \\right) \\right) \\right] \\right) \\nonumber \\\\\r\n  & = \\argmax_{s_k} \\sum_t P(t|\\vec{q}) \\, P(t_k = t | s_k) \\sum_{j=1}^{k-1} \\left[ P \\! \\left( t_j=t|s_j^* \\right) - P \\! \\left( t_j=t|s_j^* \\right) \\left( 1 - \\prod_{\\substack{i=1 \\\\ i \\neq j}}^{k-1} \\left( 1 - P \\! \\left( t_i=t|s_i^* \\right) \\right) \\right) \\right] \\nonumber \\\\\r\n%%\r\n  & = \\argmax_{s_k} \\sum_t P(t|\\vec{q}) \\, P(t_k = t | s_k) \\sum_{j=1}^{k-1} P(t_j=t|s_j^*) \\nonumber \\\\\r\n  & \\hspace{10mm} - \\sum_t P(t|\\vec{q}) \\, P(t_k = t | s_k) \\sum_{j=1}^{k-1} P(t_j=t|s_j^*) \\max_{\\substack{ i \\in [1, k-1] \\\\ i \\neq j}} P(t_i=t|s_i^*) \\nonumber\r\n\\end{align}\r\n\r\n\\noindent\r\nNoting that this is of the same form as~\\eqref{eq.ncall.alt3}, albeit much simpler.\r\n\r\n\\end{document}\r\n\r\n\r\n\r\n", "meta": {"hexsha": "0ea3a01e3c7d7901e17528853593153f852db505", "size": 12504, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/ACM_TIST_diversity/appendix_SIGIR2012.tex", "max_stars_repo_name": "antoine-tran/diversify", "max_stars_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/ACM_TIST_diversity/appendix_SIGIR2012.tex", "max_issues_repo_name": "antoine-tran/diversify", "max_issues_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/ACM_TIST_diversity/appendix_SIGIR2012.tex", "max_forks_repo_name": "antoine-tran/diversify", "max_forks_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-04T16:27:43.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-04T16:27:43.000Z", "avg_line_length": 71.0454545455, "max_line_length": 385, "alphanum_fraction": 0.5563819578, "num_tokens": 5854, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410572017153, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.41662964692325466}}
{"text": "\\section{Methodology}\r\n    \r\n    \\frame{\\sectionpage}\r\n    \r\n    \\begin{frame}{Presentation of the econometric model}\r\n\\par The model to be generated in this research is based on Ramon A. Castillo's analysis of changes in the macroeconomic environment, where he applies the study of the determinants of remittances and the effects of the sending and receiving or receiving countries.\\par\r\n\r\n\\textbf{Vector Autoregressive Model (VAR).}\\par\r\nThe VAR or also called multivariate models originate in the eighties with (Sims, 1980), which raises \\textit{\"the importance of the dynamic relationships of economic phenomena at the macroeconomic level, subsistence of structural models, where there is a simultaneity between economic variables\"}.\\par\r\nVAR models have proven to be useful in empirical research analysis, when there is evidence of simultaneity between a group of variables, and that their relationships are transmitted over a given period. In addition, \"that one of the advantages of these models is that, by not imposing any restriction on the structural version of the model, specification errors are not incurred that may cause empirical work.\" (Pérez, 2008). A VAR model captures the dynamic interactions of a set of K time series variables.\\par\r\n\r\n\\textbf{Error Correction Model (VEC).}\\par\r\nVEC models, unlike VARs, are characterized by containing cointegrated variables, that is:\\par\r\n\\textit{“Variables that have a long-term equilibrium relationship between them, in which the analysis has been refined, since it includes both the dynamics of adjustment of the variables in the short term, when an unexpected shock occurs that causes another to temporarily move away of its long-term equilibrium relationship, such as the reestablishment of the equilibrium relationship in the long term, the information it provides on the speed of adjustment towards such equilibrium is quite useful; therefore they provide more information than VARs”} (Eilyn and Torres, 2004).\\par\r\nIf the variables are stationary, it is possible to proceed with the estimation of a VAR model. On the other hand, if the variables are stationary in difference and have a cointegration relationship, then a specification problem is generated in the VAR model, and a VEC must be continued.\\par\r\n\r\n\\textbf{Stationarity and order of integration.}\\par\r\n•\tThe first step in the analysis of the time series is to verify its stationarity. A time series is said to be stationary if it meets the following characteristics.\\par\r\n•\tIts mean is constant over time.\\par\r\n•\tIts variance is also constant over time.\\par\r\n\r\n \\begin{equation}\r\n var(Y_{t} = E[(Y_{t}-u_{y})^2]=\t\\sigma^2\r\n \\end{equation}\r\n \r\n•\tThe covariance of order k is not related to time and the distance between the observations is the same.\\par\r\n\r\n  \\begin{equation}\r\n \\gamma_{k}=E[(Y_{t}-u_{y})(Y_{t+k}-u_{y})]\r\n \\end{equation}\r\n \r\nThis is due to the fact that if a time series does not satisfy the previous characteristics, it is non-stationary. When we speak of an integrated time series, it is a non-stationary series, so the order of integration is the number of times the series has to be differentiated to reach stationarity.\\par\r\nWhen it is not necessary to obtain first differences for the stochastic process to be called zero-order integrated. A non-stationary series, it is necessary to differentiate it so that it is, if it only differs once and stationarity is reached, it is integrated of order one. In general, the order of integration I(d) suggests the number of times they had to apply for the process to be considered stationary.\\par\r\nAn integrated process I(d) is known as a process that has a unit root, in which differentiation is used to make it stationary. In order to have a formal certainty to define the order of integration of a variable, statistical tests are used to detect the presence of a unit root, which proves the existence of a unit root, such as the Augmented Dickey Fuller and Phillips- Perron.\\par\r\n\\end{frame}\r\n\r\n    \\frame{\\sectionpage}\r\n    \\begin{frame}{Econometric technique to use}\r\n\r\n\\textbf{Johansen Cointegration Test:}\\par\r\nThe peculiarity of this method is that it allows more than one cointegration relation in a system of variables. This test can be performed in two different approaches, with eigenvalues or with trace. When cointegration relationships are tested, the VEC model is estimated, the method of which is based on the Johansen methodology, and the steps to follow for said methodology are listed below.\\par\r\n\\begin{enumerate}\r\n\\item Estimate a VAR in levels with the endogenous variables.\r\n\\item The optimal number of lags is chosen in the estimation of the VAR. In this sense (Cuevas, 2010) asserts that \\textit{“the length of the lag is decisive, because the behavior of the residuals and the empirical results are sensitive to the order of the model (number, of lags selected), as it can cause specification problems\".} \r\n\\end{enumerate}\r\n\\textbf{Information Criteria.}\\par\r\nThe most used criteria are:\\par\r\n• \\textbf{Akaike Information Criteria} (AIC):\\par\r\n \\begin{equation}\r\n AIC = Tln|S_{h}(p)|+2pn\r\n \\end{equation}\r\n• \\textbf{Schwartz Information Criteria} (SIC):\\par\r\n  \\begin{equation}\r\n SIC = Tln|S_{h}(p)|+(pn^2)lnT\r\n \\end{equation}\r\n• \\textbf{Hannan-Quinn} (HQ):\\par\r\n   \\begin{equation}\r\n HQ(n) = log\\sigma^2_{u}(n)+\\frac{2logT}{T}n\r\n \\end{equation}\r\nWhere:\\par\r\np = number of lags\\par\r\nn = number of equations\\par\r\nT = number of observations\\par\r\n\\textbf{Diagnostic tests.}\\par\r\n\\begin{enumerate}\r\n\\item Apply the tests to the residuals to the VAR model. After determining the optimal number of lags for the model, the next step is to run a series of diagnostic tests that determine that the model does not have statistical problems that invalidate the estimation results.\\par\r\n\\begin{enumerate}\r\n\\item The autocorrelation in the residuals suggests that: \\textit{“the model is a poor representation of the generated process and that some other representation can be found including variables, lags in the model, extending the time period or getting other data”} (Lutkepohl and Kratzig, 2004). The test most used to test autocorrelation is LM, whose null hypothesis (H0) to be tested is: no serial correlation in the lag of order p.\\par\r\n\\item. Another test that is essential to evaluate the diagnosis of the model is the absence of heteroscedasticity (non-constant variance) in the residuals. The hypotheses to be tested are\\par \r\n\\begin{center}\r\n\\textbf{H0}: The residuals are homoscedastic \\par \r\n\\textbf{H1}: The residuals are heteroscedastic.\\par\r\n\\end{center}\r\n\\item Another of the diagnostic tests for the verification of VAR processes refers to the normality of the waste, using the Jarque-Bera test. The hypotheses of this test are the following:\\par\r\n\r\n\\begin{equation}\r\n H_{0} : E(u_{t}^s)^3 = 0 \r\n  \\end{equation} \r\n  \\begin{equation}\r\n H_{1} : E(u_{t}^s)^3 \\neq 0\r\n \\end{equation} \r\n\r\nThe null hypothesis is rejected based on the value of the probability JB, given the level of significance with which one works, for example, with a significance level of 5 percent, the null hypothesis will not be rejected if the probability is higher than 0.05, therefore, there is a normal distribution in the residuals.\\par\r\n\\end{enumerate}\r\n\\item At the selected VAR in levels, the cointegration test is applied (minus one to the optimal lag). The particularity of this method is that it allows more than one cointegration relationship in a system of variables. This test can be performed in two different approaches, with eigenvalues or with trace.\\par\r\n\\end{enumerate}\r\n\\end{frame}\r\n\r\n    \\frame{\\sectionpage}\r\n    \\begin{frame}{Description of the databases}\r\nThe data to be used are focused on the period from January 1996 to December 2019 for the variables presented in the following section. In the same way, the dichotomous variables created for the structural changes that occurred over time are explained.\\par\r\nFirst, the remittances sent are shown in their tiered series:\\par\r\nAs can be seen in the previous series, there is an accelerated rebound from the first quarter of 2003 until achieving a small stabilization, hence a decrease in the fourth quarter of 2009 to reach the acceleration that we have observed in recent years.  Second, the Gross Domestic Product of Mexico is shown in levels:\\par\r\n\tIn the previous series, the upward trend can be observed from 1996 to 2009, where economic growth is affected by the world economic crisis of that year. The following is the Gross Domestic Product of the United States in levels:\\par\r\nThe trend is similar to that of Mexico's GDP, but in a smoother way, however, the structural change is noticeable due to the economic crisis of 2009.  Finally, it is shown at the Real Exchange Rate between the Mexican Peso (MXN) and the United States Dollar (USD) in levels:\\par\r\n\\end{frame}\r\n\r\n    \\frame{\\sectionpage}\r\n    \\begin{frame}{Definition of the variables}\r\nIn the first place, as the dependent variable, Family Remittances were chosen in their entirety from the first quarter of 1996 to the fourth quarter of 2019. Said database is measured in millions of dollars and was obtained from the Economic Information System of the Banco de México.\\par\r\nSecond, as an independent variable that represents the recipient country of remittance income, the Gross Domestic Product of Mexico was chosen. Said database is based on 2013 at constant prices and measured in millions of pesos. The data series was obtained from the Instituto Nacional de Estadística y Geografía.\\par\r\nThird, as an independent variable that represents the country that issued the remittances, the Gross Domestic Product of the United States was chosen. It is measured in millions of dollars at constant prices. The series was obtained from the Bureau of Economic Analysis. Finally, the Real Exchange Rate Index was taken as the result of the quotient between the exchange rate variations and the Price and Quotation Index with respect to hundred eleven countries. This database was obtained from the Economic Information System of Banco de México.\\par\r\nAs mentioned in previous sections, the period ranges from the first quarter of 1996 to the fourth quarter of 2019\\footnote{Accumulating a total of 96 observations for each variable.} . At the time of analyzing the data series, eight dichotomous variables were elaborated that were taken as exogenous to control the structural changes that occurred over time. \\par\r\nIn the case of Remittances, the following variables were elaborated:\\par\r\n\\begin{itemize}\r\n\\item \\textbf{DREMESASMI:} In the first quarter of 2003, as it was the quarter where the expansion of the domestic market in the country began and there was a decrease in inflation.\\par\r\n\\item \\textbf{DREMESASREC:} In the fourth quarter of 2009 due to the global economic and financial recession that spanned from 2008 to 2009.\\par\r\n\r\n Within the Mexican GDP variable, the following variable was elaborated:\\par\r\n \r\n\\item\t\\textbf{DPIBMEXREC:} In the first quarter of 2009, due to the global economic and financial recession that spanned from 2008 to 2009.\\par\r\n\r\n Within the United States GDP variable, the following variable was elaborated:\\par\r\n\r\n\\item \\textbf{DPIBEUAREC:} In the second quarter of 2009, due to the global economic and financial recession that spanned from 2008 to 2009.\\par\r\n\r\nAnd within the Real Exchange Rate variable, the following variables were elaborated:\\par\r\n\r\n\\item \\textbf{DTCREALIG:} In the second quarter of 2002, due to the increase in imports by farmers in the United States and the increase in prices.\\par\r\n\\item \\textbf{DTCREALEST:} In the fourth quarter of 2004, since there was a slight stabilization from that year until 2007.\\par\r\n\\item \\textbf{DTCREALFD:} In the fourth quarter of 2014 due to the strengthening of the US dollar and there was an impact on emerging markets.\\par\r\n\\item \\textbf{DTCREALPP:} In the fourth quarter of 2016, due to the adjustment of oil prices.\r\n \\end{itemize}\r\n\\end{frame}\r\n", "meta": {"hexsha": "b2c2a07c8708b6ca9c75f40bc57fb9206cfa7505", "size": 11988, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "METHODOLOGY.tex", "max_stars_repo_name": "luisevillarrealgtz/remittances-R", "max_stars_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "METHODOLOGY.tex", "max_issues_repo_name": "luisevillarrealgtz/remittances-R", "max_issues_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "METHODOLOGY.tex", "max_forks_repo_name": "luisevillarrealgtz/remittances-R", "max_forks_repo_head_hexsha": "e86f865e81c894595bda3d74114af1368ff80a75", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.904, "max_line_length": 583, "alphanum_fraction": 0.7814481148, "num_tokens": 2828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4166296344599344}}
{"text": "\\section{Conventions}\n\\label{sec:conventions}\n\nItalic is used for scalars and vectors: {\\em{$p$}}, $q$.\nIt is easy to distinguish which are which by context.\nBold maths is used for rank 2 tensors:\n$\\tenrtwo{I}$,\n$\\tenrtwo{R}$,\n$\\tenrtwo{\\sigma}$.\nScript is used for rank 4 tensors:\n$\\tenrfour{C}$.\n\n`$\\cdot$' denotes dot product, single contraction:\n$x^s=\\mathbold{R}^c \\cdot x^c$.\n\n`:' denotes double product, double contraction:\n$\\tenrtwo{\\sigma} = \\tenrfour{C} : \\tenrtwo{\\epsilon}$.\n\n`$\\otimes$' denotes tensor product:\n$\\mathbold{I}\\otimes\\mathbold{I}=\n\\delta_{ij}\\delta_{kl}$.\n\n\\subsection{Space coarray}\n\\label{sec:space:coarray}\n\nThe space coarray is the centre part of the whole\nlibrary.\nThe idea is that 3D space is partitioned into identical\ncells of some sort.\nThe cells are used to store and update some physically\nrelevant properties.\nAn important consideration is how many properties can\na cell store.\nAt present the coarray is defined as shown in\nEqn. \\eqref{eq:coarray}:\n\n\\begin{equation}\n\\texttt{\ncoarray(l1:u1,l2:u2,l3:u3,props)[col1:cou1,col2:cou2,col3:*]\n}\n\\label{eq:coarray}\n\\end{equation}\n%\nwhere \\texttt{l1}\\ldots\\texttt{u3}\nare the lower and the upper\nspatial bounds of the array, counted in cells;\n\\texttt{props} is the number of properties a cell should\nhold; \\texttt{col1}\\ldots\\texttt{col3} are the lower\nand the upper cobounds of the coarray.\nNote that the last codimension is never specified,\ni.e. it is always left as an asterix, \\texttt{*}, to\nallow for different number of images at runtime.\n\nA typical definition of the coarray might look like\n\n\\begin{equation}\n\\texttt{\ncoarray(1:10,1:10,1:10,2)[1:8,1:8,1:*]\n}\n\\nonumber\n\\end{equation}\n%\nwhich, when run on 512 images, will have the final\ncodimension of 8.\nThis array has 2 cell state types, which can be e.g.\nthe (unique) grain number, and a possible fracture state.\n\nThe library has two state types defined:\n\\texttt{cgca\\_state\\_type\\_grain} for grain states,\ni.e. grain numbers, and\n\\texttt{cgca\\_state\\_type\\_frac} for fracture states.\nSo \\texttt{coarray(:,:,:,cgca\\_state\\_type\\_grain)} is\nthe local grain array, and\n\\texttt{coarray(:,:,:,cgca\\_state\\_type\\_frac)} is\nthe local fracture array.\n\n\\subsection{Cellular neighbourhood}\n\nWe use a square 3D cellular array.\nThis means that a cell has a\n$3 \\times 3 \\times 3 - 1 = 26$\ncell nearest neighbourhood.\nThere are a number of problems with such\nneighbourhood.\nNot all neighbouring cells are `equal'.\nIf one imagines a $3\\times 3 \\times 3$ cube\nof cubic cells, then the central cell will\nhave 6 neighbours sharing a face with it,\n12 neighbours sharing an edge and 8 neighbours\nsharing an edge.\nMore importantly, there are\nthree distinct angles between the pairs of the\nnearest neighbourhood vectors, i.e. vectors\nconnecting the centres of the central cell,\nand of each neighbouring cell \\cite{shterenlikht2013c}.\n\nPerhaps a better idea of a neighbourhood can\nbe constructed by imagining the central cell\nas a 26-faced polyhedra.\nExamples are rhombicuboctahedron or\npseudo-rhombicuboctahedron, also called\nelongated square gyrobicupola, Johnson solid\nJ37, see Fig. \\ref{fig:j37}.\n\n\\begin{figure}\n\\begin{tabular}{cc}\n\\includegraphics[width=0.4\\textwidth]{octa.jpg}\n&\n\\includegraphics[width=0.4\\textwidth]{gyro.png}\n\\\\\n(a) & (b)\n\\end{tabular}\n\\caption{\n26-face polyhedra: (a) Rhombicuboctahedron, an Archimedian\nsolid, (b) Elongated square gyrobicupola, or\npseudo-rhombicuboctahedron, Johnson solid, J37.\nFrom: http://en.wikipedia.org/wiki/Rhombicuboctahedron and\nhttp://en.wikipedia.org/wiki/Elongated\\_square\\_gyrobicupola.\n}\n\\label{fig:j37}\n\\end{figure}\n\nImportantly, the cell state is determined\nby the states of its neighbours, not the\nother way round.\nThis helps develop a parallel model using\nhalo arrays.\n\n", "meta": {"hexsha": "cb30d4cb38b94d0d86e6e7757721240b3c076bfc", "size": 3752, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/cgca_conventions.tex", "max_stars_repo_name": "lcebaman/casup", "max_stars_repo_head_hexsha": "240f25f07d8ea713b9fbed9814d0ac56d0141f86", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/cgca_conventions.tex", "max_issues_repo_name": "lcebaman/casup", "max_issues_repo_head_hexsha": "240f25f07d8ea713b9fbed9814d0ac56d0141f86", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/cgca_conventions.tex", "max_forks_repo_name": "lcebaman/casup", "max_forks_repo_head_hexsha": "240f25f07d8ea713b9fbed9814d0ac56d0141f86", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0852713178, "max_line_length": 61, "alphanum_fraction": 0.7606609808, "num_tokens": 1140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4165956693713733}}
{"text": "\\documentclass[./Thesis.tex]{subfiles}\n\\begin{document}\n\n\\chapter{Termination}\n\\label{chap:termination}\n\n\\epigraph{\n  What can be asserted without evidence can also be dismissed without evidence.\n}{Christopher Hitchens \\cite{hitchens-quote}}\n\n\\begin{code}[hide]\n  module Termination where\n  open import Relation.Nullary using (¬_)\n  open import Relation.Nullary.Decidable using (False)\n  open import Relation.Nullary.Negation using (contradiction)\n  open import Data.Empty using (⊥)\n  open import AKS.Nat using (ℕ; zero; suc; _∸_; _*_; _<_; _≤_; lte; _≟_)\n  open import AKS.Nat using (+-comm; suc-injective-≡; n≮0; 0≤n; n<1+n; ≤-refl) renaming (n≤m⇒n<m⊎n≡m to n≤m⇒n<m∨n≡m)\n  open import Data.Sum using () renaming (inj₁ to or₁; inj₂ to or₂)\n  open import AKS.Binary using (𝔹⁺)\n  open 𝔹⁺\n  open import AKS.Nat.Divisibility using (_div_; Euclidean; Euclidean✓)\n  open Euclidean using () renaming (q to quotient)\n  open import Relation.Binary.PropositionalEquality\n    using (_≡_; _≢_; module ≡-Reasoning)\n    renaming (refl to ≡-refl; sym to ≡-sym; cong to ≡-cong; cong₂ to ≡-cong₂)\n  open ≡-Reasoning\n  open import Data.Unit using (tt)\n  open import Polynomial.Simple.AlmostCommutativeRing.Instances using (module Nat)\n  open import Polynomial.Simple.Reflection using (solve)\n  open Nat.Reflection using (∀⟨_⟩)\n  open import Data.List using ([]; _∷_; List)\n  open import Function using (_$_)\n  open import AKS.Unsafe using (BOTTOM)\n\\end{code} % $\n\\section{A Correctness Interlude}\n\\label{sec:a-correctness-interlude}\nThe previous chapter omitted a critical flaw in its analysis. The code below is\nrejected by the \\Agda{} compiler. The compiler's \\textit{termination checker} \\cite{agda}\nfails as \\Agda{} can not infer that the result of non-zero integer division by\n$2$ always returns an integer strictly smaller than the input. The termination\nchecker ensures than every function is total. In other words,\nthe termination checker disallows infinite loops. This termination proof\nis obvious but termination proofs can quickly become complex. In general checking\ntermination, commonly called the halting problem, is undecidable. \n\\begin{code}[hide]\n  module Bad₁ where\n    {-# TERMINATING #-}\n\\end{code}\n\\begin{code}\n    ⟦_⇑⟧⁺ : ∀ (n : ℕ) {≢0 : False (n ≟ 0)} → 𝔹⁺\n    ⟦ suc n ⇑⟧⁺ with suc n div 2\n    ... | Euclidean✓ (suc q) 0 _ _ = ⟦ suc q ⇑⟧⁺ 0ᵇ\n    ... | Euclidean✓ zero    1 _ _ = 𝕓1ᵇ\n    ... | Euclidean✓ (suc q) 1 _ _ = ⟦ suc q ⇑⟧⁺ 1ᵇ\n\\end{code}\nThis checker is a keystone of the correctness of the logic of \\Agda{}. Consider\nthe following function with a similar call graph. Instead of the input\ndecreasing to some base case it doubles with every recursive call. This function can\nbe used to prove falsehood, thus a logic with unconstrained recursion is\ninconsistent.\n\\begin{code}[hide]\n  module Bad₂ where\n    {-# TERMINATING #-}\n\\end{code}\n\\begin{code}\n    increasing : ℕ → ⊥\n    increasing n with 2 * n\n    ... | q = increasing q\n\n    false : ⊥\n    false = increasing 0\n\\end{code}\nIn fact, the example above can be simplified in the code below. In English\nthis code expresses the famous fallacy of circular reasoning ``false is true\nbecause false is true''.\n\\begin{code}[hide]\n  module Bad₃ where\n    {-# TERMINATING #-}\n\\end{code}\n\\begin{code}\n    false : ⊥\n    false = false\n\\end{code}\nThankfully none of these false expressions are accepted by the \\Agda{} compiler.\nThis begs the question how does \\Agda{} determine which recursive functions to\naccept? Unfortunately the \\Agda{} compiler can not solve the halting problem so\nit must be restrictive. The compiler only accepts recursive\ncalls that are \\textit{structurally decreasing}, a small\nsubset of the set of recursive functions. A recursive call is structurally\ndecreasing if the call occurs on a strict sub expression \\cite{agda}. The\nexpression $\\AgdaInductiveConstructor{suc} \\, n$ is a strict sub-expression of\n$\\AgdaInductiveConstructor{suc} \\,\n  (\\AgdaInductiveConstructor{suc} \\,\n    (\\AgdaInductiveConstructor{suc} \\, n))\n$,\nbut $\\AgdaInductiveConstructor{suc} \\, n$ is not a strict sub-expression of\n$\\AgdaInductiveConstructor{suc} \\, n$.\nAddition, our first example of recursion, is acceptable as\n$n <_{sub} \\AgdaInductiveConstructor{suc} \\, n$.\n\\begin{code}[hide]\n  module Add where\n\\end{code}\n\\begin{code}\n    _+_ : ℕ → ℕ → ℕ\n    zero + m = m\n    (suc n) + m = suc (n + m)\n\\end{code}\n\\begin{code}[hide]\n  open import AKS.Nat using (_+_)\n\\end{code}\nThe following inductive definition of the Fibonacci function\nhas structurally decreasing calls as\n$\\AgdaInductiveConstructor{suc} \\, n <_{sub} \\AgdaInductiveConstructor{suc} \\, (\\AgdaInductiveConstructor{suc} \\, n)$\nand\n$n <_{sub} \\AgdaInductiveConstructor{suc} \\, (\\AgdaInductiveConstructor{suc} \\, n)$.\n\\begin{code}\n  fib : ℕ → ℕ\n  fib zero = 0\n  fib (suc zero) = 1\n  fib (suc (suc n)) = fib (suc n) + fib n\n\\end{code}\nSo far all the recursive functions described have been\n\\textit{primitive recursive} \\cite{soare}. This is a large class, but the set of\nstructurally decreasing functions is larger than the set of primitive\nrecursive functions. The Ackerrmann function is the canonical example of\nfunction which is not primitive recursive.\n\\begin{code}\n  ack : ℕ → ℕ → ℕ\n  ack zero m = suc m\n  ack (suc n) zero = ack n (suc zero)\n  ack (suc n) (suc m) = ack n (ack (suc n) m)\n\\end{code}\n\\Agda{} accepts this definition as the recursive\ncalls are decreasing lexicographically.\nThe recursive call in the second case decreases in the first argument so\nthe second argument increasing is acceptable\n$\n(n, \\, \\AgdaInductiveConstructor{suc} \\, \\AgdaInductiveConstructor{zero})\n<_{sub}\n(\\AgdaInductiveConstructor{suc} \\, n, \\, \\AgdaInductiveConstructor{zero})\n$.\nFor a similar reason the outer call in the third case is acceptable\n$\n(n, \\, \\AgdaFunction{ack} \\, (\\AgdaInductiveConstructor{suc} \\, n) \\, m)\n<_{sub}\n(\\AgdaInductiveConstructor{suc} \\, n, \\, \\AgdaInductiveConstructor{suc} \\, m)\n$.\nThe inner call is acceptable as the second argument decreases while the first\nstays constant, this is lexicographic order\n$\n(\\AgdaInductiveConstructor{suc} \\, n, \\, m)\n<_{sub}\n(\\AgdaInductiveConstructor{suc} \\, n, \\, \\AgdaInductiveConstructor{suc} \\, m)\n$. \\\\\n\\section{Well-Founded Relations}\n\\label{sec:well-founded-relations}\nAn astute reader may have noticed a pattern. \\Agda{} accepts your recursive\ndefinition if it can infer a structural \\textit{well-founded relation}\n\\cite{soare}. A well-founded relation is a binary relation $\\prec$ that has no\ninfinitely descending chains $\\dots \\prec x_k \\prec \\dots \\prec x_1 \\prec x_0$.\nFor instance the strict ordering over the naturals is well-founded\nas every chain will eventually reach $0$.\n\\begin{align}\n  \\label{eqn:wellfounded-natural}\n  0 < 1 < 2 < 3 < 4 < 5\n\\end{align}\nThe non-strict ordering is not well-founded as an infinite chain of the\nreflexivity axiom can be constructed.\n\\begin{align}\n  \\label{eqn:non-wellfounded-natural}\n  \\dots \\leq 0 \\leq \\dots \\leq 0 \\leq 0\n\\end{align}\nUnfortunately, these relation chains do not capture the full structure of well-founded\nrelations. A well-founded relation often has multiple elements that could be\nappended to the chain. This idea is illustrated in the well-founded tree\nrooted at 3 found in figure \\ref{fig:wellfounded-tree}.\n\\begin{figure}[h]\n  \\centering\n  \\begin{tikzpicture}\n    \\Tree\n    [.3\n      {$0 < 3$}\n      [.{$1 < 3$}\n        {$0 < 1$}\n      ]\n      [.{$2 < 3$}\n        {$0 < 2$}\n        [.{$1 < 2$}\n          {$0 < 1$}\n        ]\n      ]\n    ]\n  \\end{tikzpicture}\n  \\caption{A well-founded tree }\n  \\label{fig:wellfounded-tree}\n\\end{figure}\nThese trees encapsulate the full structure of a well-ordering relation.\nTherefore, if we could express this tree as an \\Agda{} datatype, we could supply\nour own well-ordering relation even when \\Agda{} can not infer it. The final\ndatatype that represents well-founded trees is somewhat puzzling at first\nglance. So to introduce it we start with a sensible datatype and make small\nchanges to the definition until we have reached the correct representation.\nThese trees are general trees, trees that can have an arbitrary number\nof children. They are often called rose trees in functional programming\nliterature. They make for a good starting datatype.\n\\begin{code}[hide]\n  module Tree₁ where\n\\end{code}\n\\begin{code}\n    data RoseTree : Set where\n      Node : List RoseTree → RoseTree\n\\end{code}\nWe then apply a \\textit{continuation passing style} \\cite{harper} transformation to the\nrecursive call. Instead of having a list of children we have a continuation that\ncan be invoked with the index of the requested child.\n\\begin{code}[hide]\n  module Tree₂ where\n\\end{code}\n\\begin{code}\n    data RoseTree : Set where\n      Node : (ℕ → RoseTree) → RoseTree\n\\end{code}\nUnfortunately, this makes our definition unusable as now every rose tree must have\ninfinite size. From a \\textit{game theotertic} perspective, a consumer may request\nthe first child of every node repetitively.\n\\begin{code}\n    rosetree-uninhabited : RoseTree → ⊥\n    rosetree-uninhabited (Node children) = rosetree-uninhabited (children 0)\n\\end{code}\nAny well founded tree is necessarily finite as each node always has a finite\nnumber of children ``less'' than itself. We can solve this by adding an upper\nbound and ensuring that any index is less than the bound.\n\\begin{code}[hide]\n  module Tree₃ where\n\\end{code}\n\\begin{code}\n    data RoseTree (bound : ℕ) : Set where\n      Node : (∀ {lower : ℕ} → lower < bound → RoseTree lower)\n           → RoseTree bound\n\\end{code}\nNote that the definition above does not make use of any properties specific to\nnatural numbers. The definition simply requires a binary relation.\nBy parameterizing the datatype by the relation we\narrive at our finial definition. This is often called the accessibility\npredicate so we update the names accordingly.\n\\begin{code}\n  data Acc {A : Set} (_≺_ : A → A → Set) (bound : A) : Set where\n    acc : (∀ {lower : A} → lower ≺ bound → Acc _≺_ lower)\n        → Acc _≺_ bound\n\\end{code}\nContinuing with the game theoretic analysis proving a relation is well-founded\nfor a specific bound is a simple game. A game where the prover\ncontinually asks for a lower bound and wins when it is impossible for the\nother player to supply a lower bound. This game plays out below for a bound of $3$.\n\\begin{code}\n  3-well-founded : Acc _<_ 3\n  3-well-founded = acc λ l₁<3 → acc λ l₂<l₁ → acc λ l₃<l₂ → acc λ l₄<l₃ →\n    contradiction l₄<l₃ (end l₁<3 l₂<l₁ l₃<l₂)\n\\end{code}\n\\begin{code}[hide]\n    where\n\\end{code}\n\\begin{code}\n    end : ∀ {l₁ l₂ l₃ l₄} → l₁ < 3 → l₂ < l₁ → l₃ < l₂ → ¬ (l₄ < l₃)\n    end {2} {1} {0} {l₄} l₁<3 l₂<l₁ l₃<l₂ l₄<l₃ = contradiction l₄<l₃ n≮0 \n\\end{code}\n\\section{Win Every Game}\n\\label{sec:win-every-game}\nNow we turn to proving that any natural forms a rooted well-founded tree under the\nstrict ordering relation. Usually proving a property holds for any $n$ is harder\nthen proving that property holds for specific $n$. This concept applies to\nproving that every natural is well-founded. Specifically our choice of\nless than relation is poorly suited for this task. We will define an inductive\nordering relation and show that our original definition of ordering is a\nsubrelation of the inductive-definition. Then if the inductive definition is\nwell-founded the subrelation will be as well. This last idea is shown below.\n\\begin{code}[hide]\n  module Sub₁ where\n\\end{code}\n\\begin{code}\n    subrelation\n        : ∀ {A : Set} {_≺₁_ _≺₂_ : A → A → Set} {n}\n        → (∀ {a b} → a ≺₂ b → a ≺₁ b)\n        → Acc _≺₁_ n\n        → Acc _≺₂_ n\n    subrelation ≺₂⇒≺₁ (acc down) =\n      acc λ x≺₂n → subrelation ≺₂⇒≺₁ (down (≺₂⇒≺₁ x≺₂n))\n\\end{code}\nNext we turn to the inductive ordering relation. The key idea behind this\ndefinition is that each $\\AgdaInductiveConstructor{≤-step}$ constructor adds one\nto the right bound. The base case is the reflexivity axiom so the number of\n$\\AgdaInductiveConstructor{≤-step}$ constructors is the distance between the\nleft and right bound. The old definition internalizes this concept into the\ndefinition as the $k$ in\n$a \\, \\AgdaDatatype{≤} \\, b = a \\, \\AgdaFunction{+} \\, k \\, \\AgdaDatatype{≡} \\, b$.\n\\begin{code}\n    data _≤ⁱ_ (n : ℕ) (m : ℕ) : Set where\n      ≤-same : n ≡ m → n ≤ⁱ m\n      ≤-step : ∀ {o} → suc o ≡ m → n ≤ⁱ o → n ≤ⁱ m\n\n    _<ⁱ_ : ℕ → ℕ → Set\n    n <ⁱ m = suc n ≤ⁱ m\n\n    2≤ⁱ4 : 2 ≤ⁱ 4\n    2≤ⁱ4 = ≤-step {o = 3} ≡-refl (≤-step {o = 2} ≡-refl (≤-same ≡-refl))\n\\end{code}\nThis concept also hints at how to show that the old definition is a subrelation\nof the inductive definition. Count $k$ down to $0$ adding a\n$\\AgdaInductiveConstructor{≤-step}$. We first transform\n$a \\, \\AgdaFunction{+} \\, k \\, \\AgdaDatatype{≡} \\, b$ into\n$k \\, \\AgdaFunction{+} \\, a \\, \\AgdaDatatype{≡} \\, b$ as $\\AgdaFunction{\\_+\\_}$\nis defined on the first argument. So it can simplify terms like\n$0 \\, \\AgdaFunction{+} \\, a$ into $a$ automatically.\n\\begin{code}\n    ≤⇒≤ⁱ : ∀ {a b} → a ≤ b → a ≤ⁱ b\n    ≤⇒≤ⁱ {a} {b} (lte k a+k≡b) = loop a b k $ begin\n      k + a ≡⟨ +-comm k a ⟩ a + k ≡⟨ a+k≡b ⟩ b ∎\n      where\n      loop : ∀ a b k → k + a ≡ b → a ≤ⁱ b\n      loop a b zero 0+a≡b = ≤-same $ begin\n        a ≡⟨⟩ 0 + a ≡⟨ 0+a≡b ⟩ b ∎\n      loop a (suc b) (suc k) 1+k+a≡1+b = ≤-step ≡-refl $ loop a b k $ begin\n        k + a ≡⟨ suc-injective-≡ 1+k+a≡1+b ⟩ b ∎\n\\end{code}\n\\begin{code}\n    <⇒<ⁱ : ∀ {a b} → a < b → a <ⁱ b\n    <⇒<ⁱ {a} {b} a<b = ≤⇒≤ⁱ {suc a} {b} a<b\n\\end{code}\nNext we need to prove that any natural forms a rooted well-founded tree under\nthe inductively defined ordering. This requires a set of mutually recursive\nfunctions.\n\\begin{code}\n    <ⁱ-well-founded : ∀ {n} → Acc _<ⁱ_ n\n    <ⁱ-count-down : ∀ {m n} → m <ⁱ n → Acc _<ⁱ_ m\n\\end{code}\nThe first accepts the ``player'' supplied proof that some number $m$\nis less than the bound. Then the second function counts $n$ down to $m$ until\nthey are equal. Then it asks the player for a proof that there is some number\nsmaller than $m$. Note that every case in $\\AgdaFunction{<ⁱ-count-down}$ peals\noff exactly one $\\AgdaFunction{suc}$ so \\Agda{} is able to infer that the\nfunctions are structurally decreasing.\n\\begin{code}\n    <ⁱ-well-founded {n} = acc (λ x<ⁱn → <ⁱ-count-down x<ⁱn)\n    <ⁱ-count-down {m} {suc .m} (≤-same ≡-refl) = <ⁱ-well-founded {m}\n    <ⁱ-count-down {m} {suc n} (≤-step ≡-refl m≤n) = <ⁱ-count-down {m} {n} m≤n\n\\end{code}\nLastly we bring all the puzzle pieces together and prove that our original\ndefinition of ordering is well founded.\n\\begin{code}\n    <-well-founded : ∀ {n} → Acc _<_ n\n    <-well-founded {n} = subrelation <⇒<ⁱ <ⁱ-well-founded\n\\end{code}\n\\begin{code}[hide]\n  open Sub₁ using (<-well-founded)\n\\end{code}\n\\section{Lie No More}\n\\label{sec:lie-no-more}\nNow we can return to our function that upcasts a natural number to a binary\nencoded number. In order to use the mechanism developed above we must first\nprove a lemma that integer division by $2$ is strictly less than the input.\nThankfully this lemma is simple enough for an automated ring solver to prove.\n\\begin{code}\n  div-< : ∀ n q r {q≢0 : False (q ≟ 0)} → n ≡ r + 2 * q → q < n\n\\end{code}\n\\begin{code}[hide]\n  div-< n (suc q) r ≡-refl = lte (q + r) (∀⟨ q ∷ r ∷ [] ⟩)\n\\end{code}\nNext we define a helper function that has an accessibility predicate on the\ninput. Eventually we lose the game as $\\Floor{1 / 2} = 0$ and we can not call\nthe helper function on $0$ by assumption. Thankfully this lines up perfectly\nwith our desired base case.\n\\begin{code}\n  ⟦_,_⇑⟧ʰ : ∀ (n : ℕ) (acc : Acc _<_ n) {≢0 : False (n ≟ 0)} → 𝔹⁺\n  ⟦ suc n , acc down ⇑⟧ʰ with suc n div 2\n  ... | Euclidean✓ (suc q) 0 pf _ = ⟦ suc q , down (div-< (suc n) (suc q) 0 pf) ⇑⟧ʰ 0ᵇ\n  ... | Euclidean✓ zero    1 _ _ = 𝕓1ᵇ\n  ... | Euclidean✓ (suc q) 1 pf _ = ⟦ suc q , down (div-< (suc n) (suc q) 1 pf) ⇑⟧ʰ 1ᵇ\n\n  ⟦_⇑⟧⁺ : ∀ (n : ℕ) {≢0 : False (n ≟ 0)} → 𝔹⁺\n  ⟦ suc n ⇑⟧⁺ = ⟦ suc n , <-well-founded ⇑⟧ʰ\n\\end{code}\n\\section{Binary Search}\n\\label{sec:binary-search}\nConsider the following binary search for the value $10$ in the array\n$\n\\rowarrowsep=-2pt\n\\begin{gmatrix}[b]\n  1 & 5 & 8 & 10 & 11 & 20\n\\end{gmatrix}\n$ depicted in equation \\ref{eqn:binary-search}. The search starts with the bounds of the entire array\n$\\textcolor{blue}{[} 0, 5 \\textcolor{blue}{]}$.\nThen it updates the interval to the left half of the array\n$\\textcolor{green}{[} 3, 5 \\textcolor{green}{]}$.\nIt finally narrows in on the correct answer the interval\n$\\textcolor{red}{[} 3, 3 \\textcolor{red}{]}$.\nAs with all the examples described in this chapter this\nalgorithm terminates because the intervals are decreasing under a well-founded\nrelation, strict interval inclusion.\n\\begin{align}\n  \\label{eqn:binary-search}\n  \\begin{gmatrix}[b]\n    \\hspace{0.4em} \\Line{blue} &\n    1 &\n    5 &\n    8 &\n    \\Line{green} \\hspace{0.4em} \\Line{red} &\n    10 &\n    \\Line{red} &\n    11 &\n    20 &\n    \\Line{green} \\hspace{0.4em} \\Line{blue} \\hspace{0.4em}\n  \\end{gmatrix}\n\\end{align}\nAn interval $i_2$ strictly includes\nan interval $i_1$ if $i_1$ is a proper subset of $i_2$. If the set is finite\nthen this relation is clearly well founded. Unfortunately working with sets is\ntricky in a type theory. So we limit our definition of an\ninterval to sets of naturals. Then our intervals are uniquely represented by\ntheir \\textit{infimum} (lower bound) and \\textit{supremum} (upper bound).\n\\begin{code}\n  record Interval : Set where\n    constructor [_,_∣_]\n    field\n      inf : ℕ\n      sup : ℕ\n      inf≤sup : inf ≤ sup\n  open Interval\n\\end{code}\nNow we have two bounds to manipulate so there are two possible ways to create an\ninterval smaller than another. Firstly to lower the supremum and secondly to\nraise the infimum.\n\\begin{code}\n  data _⊂_ (i₁ : Interval) (i₂ : Interval) : Set where\n    downward : inf i₂ ≤ inf i₁ → sup i₁ < sup i₂ → i₁ ⊂ i₂\n    upward : inf i₂ < inf i₁ → sup i₁ ≤ sup i₂ → i₁ ⊂ i₂\n\\end{code}\nOften authors prove termination for their binary search algorithm by instead\nthinking about how the distance between the left and right bound decreases. We\nadopt this technique to show that interval inclusion is a subrelation of\n$\\AgdaFunction{\\_<\\_}$. Although it is not technically a subrelation. It is a\nsubrelation generated by the function $\\AgdaFunction{width}$.\n\\begin{code}\n  width : Interval → ℕ\n  width i = sup i ∸ inf i\n\n  ⊂⇒< : ∀ {i₁ i₂} → i₁ ⊂ i₂ → width i₁ < width i₂\n\\end{code}\n\\begin{code}[hide]\n  open import AKS.Unsafe using (trustMe)\n\n  ∸-monoˡ-< : ∀ {l₁ h₁ l₂ h₂} → l₁ ≤ h₁ → l₂ ≤ h₂ → l₂ ≤ l₁ → h₁ < h₂ → h₁ ∸ l₁ < h₂ ∸ l₂\n  ∸-monoˡ-< {l₁} {h₁} {l₂} {h₂} l₁≤h₁ l₂≤h₂ l₂≤l₁ h₁<h₂ = lte ((h₂ ∸ l₂) ∸ suc (h₁ ∸ l₁)) trustMe\n\n  ∸-monoʳ-< : ∀ {l₁ h₁ l₂ h₂} → l₁ ≤ h₁ → l₂ ≤ h₂ → l₂ < l₁ → h₁ ≤ h₂ → h₁ ∸ l₁ < h₂ ∸ l₂\n  ∸-monoʳ-< {l₁} {h₁} {l₂} {h₂} l₁≤h₁ l₂≤h₂ l₂<l₁ h₁≤h₂ = lte ((h₂ ∸ l₂) ∸ suc (h₁ ∸ l₁)) trustMe\n\n  ⊂⇒< {[ inf-i₁ , sup-i₁ ∣ inf-i₁≤sup-i₁ ]} {[ inf-i₂ , sup-i₂ ∣ inf-i₂≤sup-i₂ ]} (downward inf-i₂≤inf-i₁ sup-i₁<sup-i₂)\n    = ∸-monoˡ-< inf-i₁≤sup-i₁ inf-i₂≤sup-i₂ inf-i₂≤inf-i₁ sup-i₁<sup-i₂\n  ⊂⇒< {[ inf-i₁ , sup-i₁ ∣ inf-i₁≤sup-i₁ ]} {[ inf-i₂ , sup-i₂ ∣ inf-i₂≤sup-i₂ ]} (upward inf-i₂<inf-i₁ sup-i₁≤sup-i₂)\n    = ∸-monoʳ-< inf-i₁≤sup-i₁ inf-i₂≤sup-i₂ inf-i₂<inf-i₁ sup-i₁≤sup-i₂\n  -- ⊂⇒< = BOTTOM\n\\end{code}\nAs the types of our elements are different we need to generalize\n$\\AgdaFunction{subrelation}$. We add a function to covert between the types.\nTechnically the function is a \\textit{functor} \\cite{awodey}\nfrom the \\textit{category} with $\\AgdaFunction{\\_≺₂\\_}$ as morphisms to the\ncategory with $\\AgdaFunction{\\_≺₁\\_}$ as morphisms.\n\\begin{code}\n  subrelation\n      : ∀ {A : Set} {B : Set}\n          {_≺₁_ : A → A → Set}\n          {_≺₂_ : B → B → Set}\n          {f : B → A}\n          {n : B}\n      → (∀ {x y} → x ≺₂ y → f x ≺₁ f y)\n      → Acc _≺₁_ (f n)\n      → Acc _≺₂_ n\n\\end{code}\n\\begin{code}[hide]\n  subrelation ≺₂⇒≺₁ (acc down) =\n    acc λ x≺₂n → subrelation ≺₂⇒≺₁ (down (≺₂⇒≺₁ x≺₂n))\n\\end{code}\nAlthough we will not be implementing binary search in this thesis, this concept\nwill prove useful as it allows us to write terminating code that counts up to\nsome fixed value.\n\\begin{code}\n  ⊂-well-founded : ∀ {i} → Acc _⊂_ i\n  ⊂-well-founded = subrelation ⊂⇒< <-well-founded\n\n  count-up-to : ℕ → List ℕ\n  count-up-to n = loop 0 0≤n ⊂-well-founded\n\\end{code}\n\\begin{code}[hide]\n    where\n\\end{code}\nCounting up is simply always choosing to tighten the left bound of the interval.\nEventually the user reaches the upper bound and interval becomes $[ n, n ]$.\nThis interval can not be shortened and the recursion terminates as shown below.\n\\begin{code}\n    loop : ∀ (x : ℕ) (x≤n : x ≤ n) (acc : Acc _⊂_ [ x , n ∣ x≤n ]) → List ℕ\n    loop x x≤n (acc next) with n≤m⇒n<m∨n≡m x≤n\n    ... | or₂ x≡n = x ∷ []\n    ... | or₁ x<n = x ∷ loop (1 + x) x<n (next [1+x,n]⊂[x,n])\n\\end{code}\n\\begin{code}[hide]\n      where\n\\end{code}\n\\begin{code}\n      [1+x,n]⊂[x,n] : [ 1 + x , n ∣ x<n ] ⊂ [ x , n ∣ x≤n ]\n      [1+x,n]⊂[x,n] = upward n<1+n ≤-refl\n\\end{code}\n\\begin{code}\n  zero-to-three : count-up-to 3 ≡ 0 ∷ 1 ∷ 2 ∷ 3 ∷ []\n  zero-to-three = ≡-refl\n\\end{code}\n\n\\end{document}\n", "meta": {"hexsha": "b5c0d9e299ccef4d27ef2c718b844ccd20887aa5", "size": 21034, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/Termination.lagda.tex", "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_issues_repo_path": "tex/Termination.lagda.tex", "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/Termination.lagda.tex", "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.527938343, "max_line_length": 120, "alphanum_fraction": 0.6779499857, "num_tokens": 7198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4165956693713733}}
{"text": "\\section{Fermi break-up simulation for light nuclei.}\n\n\\hspace{1.0em}For light nuclei ($A \\leq 16$) the values of excitation\nenergy per nucleon are often comparable with nucleon binding\nenergy. Thus a light excited nucleus breaks into two or more fragments\nwith branching given by available phase space.  To describe a process of\nnuclear disassembling the so-called Fermi break-up model is used\n\\cite{Fermi50}, \\cite{Kretz61}, \\cite{EG67}.  This statistical approach\nwas first used by Fermi \\cite{Fermi50} to describe the multiple\nproduction in high energy nucleon collision.\n\nThe initial information for calculation of break-up stage consists from\nthe atomic mass number $A$, charge $Z$ and number of neutrons $N$ of\nresidual (e. g. after cascade or fission) nucleus and its excitation\nenergy $U$. The total energy of nucleus in the rest system will be\n$E=U+M(A,Z)$.\n\n\\subsection{Masses of nuclei.} \n\n\\hspace{1.0em}The tabulated values (calculated according to the liquid drop\nmodel) \\cite{CAM57} of mass defects  $\\Delta M(A,Z)$\nare used to calculate the masses of nuclei $M(A,Z)$ in ground states.\n\n\\subsection{ Allowed channel.} \n\n\\hspace{1.0em}The channel will be allowed for decay, if the total\nkinetic energy $E_{kin}$ of all fragments of the given channel at the\nmoment of break-up is positive. This energy can be calculated according\nto equation:\n\\begin{equation}\n\\label{FBS1}E_{kin} = U+M(A,Z)-E_{Coulomb} - \\sum_{b=1}^{n}(m_b+\\epsilon_{b}),\n\\end{equation} \n$m_{b}$ and $\\epsilon_{b}$ are masses and excitation energies of fragments, \nrespectively, $E_{Coulomb}$ is the Coulomb barrier for the given channel. It \nis approximated by\n\\begin{equation}\n\\label{FBS2}E_{Coulomb} = \\frac{3}{5} \\frac{e^2}{r_{0}}(1 + \n\\frac{V}{V_{0}})^{-1/3}\n(\\frac{Z^2}{A^{1/3}}-\\sum_{b=1}^{n}\\frac{Z^2}{A_b^{1/3}}),\n\\end{equation}\nwhere $V_0$ is the volume of the system corresponding to the normal\nnuclear matter density and $\\kappa = \\frac{V}{V_0}$ is a parameter (\n$\\kappa = 1$ is used).\n\n\\subsection{Break-up probability.} \n\n\\hspace{1.0em}The total  probability per unit time for nucleus to\nbreak-up into $n$ componets in the final state (i.e. residual nucleus,\nif it will be, nucleons, deutrons, tritons, alphas etc) is given by\n\\begin{equation}\n\\label{FBS3}W(E,n) = (V/\\Omega)^{n-1}\\rho_{n}(E),\n\\end{equation}\nwhere $\\rho_{n}(E)$ is the density of a number of final states, $V$ is\nthe volume of decaying system and $\\Omega = (2\\pi h)^{3}$ is the\nnormalization volume.  The density $\\rho_{n}(E)$ can be defined a\nproduct of three factors:\n\\begin{equation}\n\\label{FBS4}\\rho_{n}(E)=M_{n}(E)S_nG_n.\n\\end{equation}\nThe first one is the phase space factor defined as\n\\begin{equation}\n\\label{FBS5}M_{n} = \\int_{-\\infty}^{+\\infty}...\\int_{-\\infty}^{+\\infty}\n\\delta(\\sum_{b=1}^{n} {\\bf p_{b}}) \\delta(E-\\sum_{b=1}^{n}\\sqrt{p^2+m^2_b})\n\\prod_{b=1}^{n} d^3p_b,\n\\end{equation}\nwhere ${\\bf p_b}$ are fragments momenta. The second one is the spin\nfactor\n\\begin{equation}\n\\label{FBS6} S_n = \\prod_{b=1}^{n}(2s_b+1),\n\\end{equation}\nwhich gives the number of states with different spin orientations.  The\nlast one is the permutation factor\n\\begin{equation}\n\\label{FBS7}G_n = \\prod_{j=1}^{k}\\frac{1}{n_j !},\n\\end{equation}\nwhich takes into account identity of components in final state ($n_j$ is\na number of components of $j$- type particles and $k$ is defined by $n =\n\\sum_{j=1}^{k}n_{j}$). E.g. if in final state we have $n = 6$ particles\nand from them there are $2$-alphas, $3$-nucleons and $1$-deutrons, then\n$G_{6} = 1/(2! 3! 1!) = 1/12$.\n\nIn non-relativistic case (Eq. ($\\ref{FBS10}$) the integration in\nEq. ($\\ref{FBS5}$) can be evaluated analiticaly (see e. g. \\cite{BBB58})\nand the probability for a nucleus with energy $E$ disassembling into $n$\nfragments with masses $m_b$, where $b = 1,2,3,...,n$ equals\n\\begin{equation}\n\\label{FBS8} W(E_{kin},n) = \nS_nG_n (\\frac{V}{\\Omega})^{n-1}(\\frac{1}{\\sum_{b=1}^{n}m_b}\n\\prod_{b=1}^{n}\nm_{b})^{3/2}\n \\frac{2\\pi^{3(n-1)/2}}{\\Gamma(3(n-1)/2)}E_{kin}^{3n/2-5/2}, \n\\end{equation}\nwhere $\\Gamma(x)$ is the gamma function ($\\Gamma(3(n-1)/2 =  (3(n-1)/2\n- 1)!$).\n\n\\subsection{Fermi break-up model parameter.} \n\n\\hspace{1.0em}Thus the Fermi break-up model has only one free parameter\n$V$ is the volume of decaying system, which can be calculated as\nfollowing:\n\\begin{equation}\n\\label{FBS9} V = 4\\pi R^3/3 = 4\\pi r_{0}^3 A/3,\n\\end{equation}\nwhere $r_{0} = 1.4 $ fm is used.\n\n\\subsection{ Fragment characteristics.}\n\nWe take into account the formation of fragments in their ground and\nlow-lying excited states, which are stable for nucleon\nemission. However, several unstable fragments with large lifetimes:\n$^{5}He$, $^{5}Li$, $^{8}Be$, $^{9}B$ etc are also considered.  Fragment\ncharacteristics $A_b$, $Z_b$, $s_b$ and $\\epsilon_b$ are taken from\n\\cite{AS81}.\n\n\n\\subsection{ MC procedure.} \n\n\\hspace{1.0em}The nucleus break-up is described by the Monte Carlo (MC)\nprocedure. We randomly (according to probability Eq. ($\\ref{FBS8}$) and\ncondition Eq. ($\\ref{FBS1}$)) select decay channel. Then for given\nchannel we calculate kinematical quantities of each fragment according\nto $n$-body phase space distribution:\n\\begin{equation}\n\\label{FBS10}M_{n} = \\int_{-\\infty}^{+\\infty}...\\int_{-\\infty}^{+\\infty}\n\\delta(\\sum_{b=1}^{n} {\\bf p_{b}}) \\delta(\\sum_{b=1}^{n}\n\\frac{p^2_b}{2m_b}-E_{kin})\n\\prod_{b=1}^{n} d^3p_b.\n\\end{equation}\nThe Kopylov's sampling procedure \\cite{Kopylov70} is applied.  The angular\ndistributions for emitted fragments are considered as isotropical.\n\nWe take into account that the chargeless fragments are not affected by\nCoulomb field. When fragment fly away to infinity its total kinetic\nenergy can be approximated by the sum of its translational motion and\nthe contribution to the energy erasing from its Coulomb repulsion.\n", "meta": {"hexsha": "223d692d70369b0deab03dd33437be8c9d3cf0f8", "size": 5764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant4/hadronic/theory_driven/FermiBreakup/FermiBreakSim.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant4/hadronic/theory_driven/FermiBreakup/FermiBreakSim.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant4/hadronic/theory_driven/FermiBreakup/FermiBreakSim.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.3823529412, "max_line_length": 78, "alphanum_fraction": 0.7135669674, "num_tokens": 1958, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300048, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.41659566937137327}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{subcaption}\n\\usepackage{bm}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{8cm}\n\\setlength{\\figureheight}{6cm}\n\n\\newlength\\squarefigurewidth\n\\newlength\\squarefigureheight\n\n\\setlength{\\squarefigurewidth}{4cm}\n\\setlength{\\squarefigureheight}{4cm}\n\n\\newlength\\smallsquarefigurewidth\n\\newlength\\smallsquarefigureheight\n\n\\setlength{\\smallsquarefigurewidth}{3.25cm}\n\\setlength{\\smallsquarefigureheight}{3.25cm}\n\n\\newlength\\smallfigurewidth\n\\newlength\\smallfigureheight\n\n\\setlength{\\smallfigurewidth}{6.25cm}\n\\setlength{\\smallfigureheight}{4cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\model}{\\mc{M}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\trans}{^\\top}\n\\newcommand{\\mat}[1]{\\bm{\\mathrm{#1}}}\n\\renewcommand{\\vec}[1]{\\bm{\\mathrm{#1}}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\renewcommand{\\epsilon}{\\varepsilon}\n\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\cov}{cov}\n\\DeclareMathOperator{\\diag}{diag}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\begin{document}\n\n\\section*{Bayesian model selection}\n\nConsider the regression problem, where we want to predict the values\nof an unknown function $y\\colon \\R^d \\to \\R$ given examples $\\data =\n\\bigl\\{ (\\vec{x}_i, y_i) \\bigr\\}_{i = 1}^N$ to serve as training data.\nIn Bayesian linear regression, we made the following assumption about\n$y(\\vec{x})$:\n\\begin{equation}\n  y(\\vec{x}) = \\phi(\\vec{x})\\trans \\vec{w} + \\epsilon(\\vec{x}),\n\\end{equation}\nwhere $\\phi(\\vec{x})$ is a now explicitly-written feature expansion of\n$\\vec{x}$.  We proceed in the normal Bayesian way: we place Gaussian\npriors on our unknowns, the parameters $\\vec{w}$ and the residuals\n$\\vec{\\epsilon}$, then derive the posterior distribution over\n$\\vec{w}$ given $\\data$, which we use to make predictions.\n\nOne question left unanswered is how to choose a good feature expansion\nfunction $\\phi(\\vec{x})$.  For example, a purely linear model could\nuse $\\phi(\\vec{x}) = [1, \\vec{x}]\\trans$, whereas a quadratic model\ncould use $\\phi(\\vec{x}) = [1, \\vec{x}, \\vec{x}^2]\\trans$, etc.  In\ngeneral, arbitrary feature expansions $\\phi$ are allowed.  How can I\nselect between them?  Even more generally, how do I select whether I\nshould use linear regression or a completely different probabilistic\nmodel to explain my data?  These are questions of \\emph{model\n  selection,} and naturally there is a Bayesian approach to it.\n\nBefore we continue our discussion of model selection, we will first\ndefine the word \\emph{model,} which is often used loosely without\nexplicit definition.  A model is a parametric family of probability\ndistributions, each of which can explain the observed data.  Another\nway to explain the concept of a model is that if we have chosen a\nlikelihood $p(\\data \\given \\theta)$ for our data, which depends on a\nparameter $\\theta$, then the model is the set of all likelihoods (each\none of which is a distribution over $\\data$) for every possible value\nof the parameter $\\theta$.\n\nIn the case of linear regression, the weight vector $\\vec{w}$ defines\nthe parametric family, and the model is the set of distributions\n\\begin{equation*}\n  \\bigl\\{ p(\\vec{y} \\given \\mat{X}, \\vec{w}, \\sigma^2) \\bigr\\}\n  =\n  \\bigl\\{ \\mc{N}(\\vec{y}; \\mat{X}\\vec{w}, \\sigma^2 \\mat{I}) \\bigr\\},\n\\end{equation*}\nindexed by all possible $\\vec{w}$.  Each one of these is a potential\nexplanation of the observed values $\\vec{y}$ given $\\vec{X}$.  In the\ncase of flipping a coin $n$ times with an unknown bias $\\theta$ and\nobserving the number of heads $x$, the model is\n\\begin{equation*}\n  \\bigl\\{ p(x \\given n, \\theta) \\bigr\\}\n  =\n  \\bigl\\{ \\mathrm{Binomial}(x, n, \\theta) \\bigr\\},\n\\end{equation*}\nwhere there is one binomial distribution for every possible $\\theta\n\\in (0, 1)$.  In the Bayesian method, we maintain a belief over which\nelements in the model we consider plausible by reasoning about\n$p(\\theta \\given \\data)$ via Bayes' theorem.\n\nSuppose now that I have at my disposal a finite set of models\n$\\{\\model_i\\}_i$ that I may use to explain my observed data $\\data$,\nand let us write $\\theta_i$ for the parameters of model $\\model_i$.\nHow do we know which model to prefer?  We work out the posterior\nprobability over the models via Bayes' theorem!  We have:\n\\begin{equation*}\n  \\Pr(\\model_i \\given \\data)\n  =\n  \\frac{p(\\data \\given \\model_i)\\Pr(\\model_i)}\n       {\\sum_j p(\\data \\given \\model_j)\\Pr(\\model_j)}.\n\\end{equation*}\nHere $\\Pr(\\model_i)$ is a prior distribution over models that we have\nselected; a common practice is to set this to a uniform distribution\nover the models.  The value $p(\\data \\given \\model_i)$ may also be\nwritten in a more-familiar familiar form:\n\\begin{equation*}\n  p(\\data \\given \\model_i)\n  =\n  \\int\n  p(\\data \\given \\theta_i, \\model_i)\n  p(\\theta_i \\given \\model_i)\n  \\intd{\\theta_i}.\n\\end{equation*}\nThis is exactly the denominator when applying Bayes' theorem to find\nthe posterior $p(\\theta_i \\given \\data, \\model_i)$!\n\\begin{equation*}\n  p(\\theta_i \\given \\data, \\model_i)\n  =\n  \\frac{p(\\data \\given \\theta_i, \\model_i) p(\\theta_i \\given \\model_i)}\n       {\\int\n         p(\\data \\given \\theta_i, \\model_i)\n         p(\\theta_i \\given \\model_i)\n         \\intd{\\theta_i}.\n       }\n  =\n  \\frac{p(\\data \\given \\theta_i, \\model_i) p(\\theta_i \\given \\model_i)}\n       {p(\\data \\given \\model_i)},\n\\end{equation*}\nwhere we have simply conditioned on $\\model_i$ to be explicit.  In the\ncontext of model selection, the term $p(\\data \\given \\model_i)$ is\nknown as the \\emph{model evidence} or simply \\emph{evidence.}  One\ninterpretation of the model evidence is the probability that your\nmodel could have generated the observed data, under the chosen prior\nbelief over its parameters $\\theta_i$.\n\nSuppose now that we have exactly two models for the observed data that\nwe wish to compare: $\\model_1$ and $\\model_2$, with corresponding\nparameter vectors $\\theta_1$ and $\\theta_2$ and prior probabilities\n$\\Pr(\\model_1)$ and $\\Pr(\\model_2)$. In this case it is easiest to\ncompute the \\emph{posterior odds}, the ratio of the models'\nprobabilities given the data:\n\\begin{equation*}\n  \\frac{\\Pr(\\model_1 \\given \\data)}\n       {\\Pr(\\model_2 \\given \\data)}\n  = \\frac{\\Pr(\\model_1) p(\\data \\given \\model_1)}\n         {\\Pr(\\model_2) p(\\data \\given \\model_2)}\n  = \\frac{\\Pr(\\model_1) \\int p(\\data \\given \\theta_1, \\model_1)\n          p(\\theta_1 \\given \\model_1) \\intd{\\theta_1}}\n         {\\Pr(\\model_2) \\int p(\\data \\given \\theta_2, \\model_2)\n          p(\\theta_2 \\given \\model_2) \\intd{\\theta_2}},\n\\end{equation*}\nwhich is simply the prior odds multiplied by the ratio of the evidence\nfor each model.  The latter quantity is also called the \\emph{Bayes\n  factor} in favor of $\\model_1$.  Publishing Bayes factors allows\nanother practitioner to easily substitute their own model priors and\nderive their own conclusions about the models being considered.\n\n\\subsection*{Example}\n\nWikipedia gives a truly excellent example of Bayesian model selection\nin\npractice.\\footnote{\\url{http://en.wikipedia.org/wiki/Bayes_factor#Example}}\nSuppose I am presented with a coin and want to compare two models for\nexplaining its behavior.  The first model, $\\model_1$, assumes that\nthe heads probability is fixed to $\\nicefrac{1}{2}$.  Notice that this\nmodel does not have any parameters.  The second model, $\\model_2$,\nassumes that the heads probability is fixed to an unknown value\n$\\theta \\in (0, 1)$, with a uniform prior on $\\theta$: $p(\\theta\n\\given \\model_2) = 1$ (this is equivalent to a beta prior on $\\theta$\nwith $\\alpha = \\beta = 1$).  For simplicity, we choose a uniform model\nprior: $\\Pr(\\model_1) = \\Pr(\\model_2) = \\nicefrac{1}{2}$.\n\nSuppose we flip the coin $n = 200$ times and observe $x = 115$ heads.\nWhich model should we prefer in light of this data?  We compute the\nmodel evidence for each model.  The model evidence for $\\model_1$ is\nquite straightforward, as it has no parameters:\n\\begin{equation*}\n  \\Pr(x \\given n, \\model_1)\n  =\n  \\mathrm{Binomial}(n, x, \\nicefrac{1}{2})\n  =\n  \\binom{200}{115}\n  \\frac{1}{2^{200}}\n  \\approx\n  0.005956.\n\\end{equation*}\nThe model evidence for $\\model_2$ requires integrating over the\nparameter $\\theta$:\n\\begin{align*}\n  \\Pr(x \\given n, \\model_2)\n  &=\n  \\int\n  \\Pr(x \\given n, \\theta, \\model_2)\n  p(\\theta \\given \\model2)\n  \\intd{\\theta}\n  \\\\\n  &=\n  \\int_{0}^{1}\n  \\binom{200}{115}\n  \\theta^{115}\n  (1 - \\theta)^{200 - 115}\n  \\intd{\\theta}\n  \\\\\n  &=\n  \\frac{1}{201}\n  \\approx\n  0.004975.\n\\end{align*}\nThe Bayes factor in favor of $\\model_1$ is approximately $1.2$, so the\ndata give very weak evidence in favor of the simpler model $\\model_1$.\n\nAn interesting aside here is that a frequentist hypothesis test would\nreject the null hypothesis $\\theta = \\frac{1}{2}$ at the $\\alpha =\n0.05$ level. The probability of generating at least 115 heads under\nmodel $\\model_1$ is approximately $0.02$ (similarly, the probability\nof generating at least 115 tails is also $0.02$), so a two-sided test\nwould give a $p$-value of approximately $4\\%$.\n\n\\subsection*{Occam's razor}\n\nOne spin on Bayesian decision theory is that it automatically gives a\npreference towards simpler models, in line with Occam's razor.  One\nway to see this is to consider the model evidence $p(\\data \\given\n\\model)$ as a probability distribution over datasets $\\data$.  More\ncomplex models can explain more datasets, so the support of this\ndistribution is wider in the sample space.  But note that the\ndistribution must normalize over the sample space as well, so we pay a\nprice for generality.  When moving from a simpler model to a more\ncomplex model, the probability of some datasets that are well\nexplained by the simpler model must inevitably decrease to ``give up''\nprobability mass for the newly explained datasets in the widened\nsupport of the more-complex model.  The model selection process then\ndrives us to select the model that is ``just complex enough'' to\nexplain the data at hand, an in-build Occam's razor.\n\nIn the coin flipping example above, model $\\model_1$ can only explain\ndatasets with empirical heads probability reasonably near\n$\\frac{1}{2}$.  An observation of 200 heads, for example, would have\nastronomically small probability under this model.  The second model\n$\\model_2$ can explain \\emph{any} set of observations by selecting an\nappropriate $\\theta$.  The price for this generality, though, is that\ndatasets with a roughly equal number of heads and tails have a smaller\nprior probability under the model than before.\n\n\\subsection*{Model selection for Bayesian linear regression}\n\nA common application for model selection is for selecting between\nfeature expansion functions $\\phi(\\vec{x})$ in Bayesian linear\nregression.  Here the model $\\model_i$ could for example correspond\nto order-$i$ polynomial regression with\n\\begin{equation*}\n  \\phi_i(\\vec{x})\n  =\n  [1, \\vec{x}, \\vec{x}^2, \\dotsc \\vec{x}^i]\\trans.\n\\end{equation*}\nAfter selecting a set of these models to compare, as well as a prior\nprobability for each, the only remaining task is to compute the\nevidence for each model in observed data $(\\mat{X}, \\vec{y})$.  In our\ndiscussion of Bayesian linear regression, we have actually already\ncomputed the desired quantity:\n\\begin{equation*}\n  p(\\vec{y} \\given \\mat{X}, \\sigma^2, \\model_i)\n  =\n  \\mc{N}\\bigl(\\vec{y};\n  \\phi_i(\\mat{X})\\vec{\\mu},\n  \\phi_i(\\mat{X})\\mat{\\Sigma}\\phi_i(\\mat{X})\\trans + \\sigma^2\\mat{I}\\bigr),\n\\end{equation*}\nwhere I have explicitly written the basis expansion in $\\phi_i$.\n\nNote that the model $\\phi_i$ can also easily explain all datasets\nwell-explained by the models $\\phi_j$ for $j < i$, by simply setting\nthe weights on higher-order terms to zero.  Again, however, the\nsimpler model will be preferred due the Occam's razor effect described\nabove.\n\n\\section*{Bayesian Model Averaging}\n\nNote that a ``full Bayesian'' treatment of a problem would eschew\nmodel selection entirely.  Instead, when making predictions, we should\ntheoretically use the sum rule to marginalize the unknown model, e.g.:\n\\begin{equation*}\n  p(y_\\ast \\given \\vec{x}_\\ast, \\data)\n  =\n  \\sum_i\n  p(y_\\ast \\given \\vec{x}_\\ast, \\data, \\model_i)\n  \\Pr(\\model_i \\given \\data).\n\\end{equation*}\nSuch an approach is called \\emph{Bayesian model averaging.}  Although\nthis is sometimes seen, model selection is still used widely in\npractice.  The reason is that the computational overhead of using a\nsingle model is much lower than having to continually retrain multiple\nmodels, and that Bayesian model averaging uses a mixture distribution\nfor predictions, which can have annoying analytic properties (for\nexample, the predictive distribution could be multimodal).\n\n\\end{document}\n", "meta": {"hexsha": "ba43d47f48f88321a423c00d67fc51a05d911a0f", "size": 13825, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_notes/Bayesian Model Selection/notes.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "lecture_notes/Bayesian Model Selection/notes.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "lecture_notes/Bayesian Model Selection/notes.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 38.8342696629, "max_line_length": 79, "alphanum_fraction": 0.7288969259, "num_tokens": 4036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.4165895476388214}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{texyousei}\n\\usepackage{tabularx}\n\n\\lhead{}\n\\chead{The Schur Complement for Fractional Sobolev Preconditioning}\n\\rhead{}\n\n\\usepackage{comment}\n\\excludecomment{oops}\n\n\\setlength{\\leftmargini}{0.3in}\n\n\\DeclarePairedDelimiter{\\inner}{\\langle}{\\rangle}\n\\newcommand{\\ddx}{\\frac{d}{dx}}\n\\newcommand{\\ddy}{\\frac{d}{dy}}\n\\newcommand{\\ddn}{\\frac{d}{dn}}\n\\newcommand{\\ddm}{\\frac{d}{dm}}\n\\newcommand{\\sgn}[1]{\\ \\textrm{sgn}\\left(#1\\right)}\n\\newcommand{\\calDf}{\\mathcal{D}_f}\n\n\\begin{document}\n\n\\maketitle{The Schur Complement for Fractional Laplacians}{}\n\n\\thispagestyle{empty}\n\n\\section{Fractional Laplacian inverse approximation}\n\\label{sec:FractionalLaplacianInverseApproximation}\n\nRecall that we now have a relatively efficient way to invert the fractional Laplacian $\\Delta^{s}$ by factoring the inverse as $(\\Delta^{-1}) (\\Delta^{2 - s}) (\\Delta^{-1})$; the two occurrences of $\\Delta^{-1}$ are then be assembled as sparse cotan Laplacians, while the middle term has a positive power $2-s$ and can therefore be multiplied using hierarchical matrices. From here on, let $A = \\Delta^{s}$, let $A^{-1} = (\\Delta^{-1}) (\\Delta^{2 - s}) (\\Delta^{-1})$, and assume that we can multiply with $A^{-1}$ as a black box.\n\n\\section{The Schur complement}\n\nFor a general block matrix\n$$M = \n\\left[\n\\begin{array}{cc}\nA & B \\\\\nC & D\n\\end{array}\n\\right]\n$$\nthe Schur complement of the block $A$ is defined by $$M / A = D - C A^{-1} B.$$ Note that if $C$ has dimensions $k \\times n$, then $M / A$ has dimensions $k \\times k$. Then, if $A$ is invertible, then we have the following block expression for the inverse of $M$:\n$$\nM^{-1} = \\left[\n\\begin{array}{cc}\nA^{-1} + A^{-1} B (M / A)^{-1} C A^{-1} & -A^{-1} B (M / A)^{-1} \\\\\n-(M / A)^{-1} C A^{-1} & (M / A)^{-1}\n\\end{array}\n\\right]\n$$\nThus, in theory, we can invert the whole matrix $M$ by only inverting $A$ and $(M/A)$. (Analogous expressions exist for the complement $(M/D)$, but these expressions are not useful to us.)\n\n\\subsection{Application to the fractional Laplacian}\n\nWe would like to invert the saddle matrix\n$$G = \n\\left[\n\\begin{array}{cc}\nA & C^T \\\\\nC & 0\n\\end{array}\n\\right]\n$$\nwhere $C$ is a $k \\times 3|V|$ matrix whose rows contain the differentials of $k$ real-valued constraint functions, or alternatively, $C$ is the Jacobian of a constraint function $\\Phi : \\R^{3|V|} \\to \\R^k$.\n\nThen, the expression for the complement becomes $$G / A = -C A^{-1} C^{\\top}.$$ Note that we only have the ability to multiply $A^{-1}$ with column vectors, so we will have to apply the approximation from Section \\ref{sec:FractionalLaplacianInverseApproximation} once per column of $C^{\\top}$, or in other words, once per constraint.\n\nAs for the inverse, the only block that we need to apply is the top-left block, as this is the only block that contributes to the projected gradient; the other blocks either contribute to Lagrange multipliers that are unneeded for the flow, or are multiplied with entries that are always zero in the input. Thus, we only need the expression for the top-left block, which becomes $$A^{-1} + A^{-1} C^{\\top} (M/A)^{-1} C A^{-1}.$$ We cannot assemble this block explicitly (nor would we want to for efficiency reasons), but we can multiply by this block by applying each of the operators in order, producing the expression $$G^{-1} x = A^{-1} x + A^{-1} C^{\\top} (M / A)^{-1} C A^{-1} x.$$ This has the appearance of a ``correction'' being applied to the otherwise unconstrained projection $A^{-1} x$. Though $A^{-1}$ occurs 3 times in this expression, we only need to apply $A^{-1}$ twice, since the initial value of $A^{-1}x$ can be reused for both terms.\n\nWe do need to invert $(M/A)$, which is a dense matrix. However, it is of size $k \\times k$, matching the number of real-valued constraints, so as long as this number is a small constant, the cost is negligible. Importantly, though, this means that this method will not scale to larger numbers of constraints (e.g. one constraint per triangle).\n\n\\subsection{Barycenter constraints}\n\nAt first, it seems reasonable to include barycenter constraints in the rows of $C$; this matches the way in which we've traditionally organized the saddle matrix in the past. But in fact, there is no need to do this. The above expressions for the Schur complement require that $A$ is invertible, and because $A$ is a fractional Laplacian, this is only true if we augment $A$ itself with barycenter constraints to factor out the null space of translations. This is exactly what we do with the approximation of Section \\ref{sec:FractionalLaplacianInverseApproximation} -- we include barycenter constraints on the two integer Laplacians to make them invertible.\n\nAs such, including barycenter constraints in $C$ would not only be redundant, but would also require three additional applications of $A^{-1}$ as part of evaluating $A^{-1}C^{\\top}$. Conceptually, we can instead organize the saddle matrix this way: \n$$\n\\left[\n\\begin{array}{cc}\n\\left[\n\\begin{array}{cc}\nA & B^{\\top} \\\\\nB & 0\n\\end{array}\\right] & C^{\\top} \\\\\nC & 0\n\\end{array}\n\\right]\n$$\nwhere $B$ specifically corresponds to the rows for the barycenter constraint, and $C$ contains all the other constraints. Thus, the same saddle matrix is being inverted, but we save on applications of $A^{-1}$ by handling $B$ with the fractional Laplacian itself -- which we would need to do anyway to make it invertible.\n\n\\end{document}\n\n", "meta": {"hexsha": "10ac56228b754703d0d4c31ad1f5687e4fbb7f05", "size": 5433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/schur.tex", "max_stars_repo_name": "Conrekatsu/repulsive-surfaces", "max_stars_repo_head_hexsha": "74d6a16e6ca55c8296fa5a49757c2318bea62a84", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2021-12-13T09:58:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T11:03:01.000Z", "max_issues_repo_path": "notes/schur.tex", "max_issues_repo_name": "Conrekatsu/repulsive-surfaces", "max_issues_repo_head_hexsha": "74d6a16e6ca55c8296fa5a49757c2318bea62a84", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/schur.tex", "max_forks_repo_name": "Conrekatsu/repulsive-surfaces", "max_forks_repo_head_hexsha": "74d6a16e6ca55c8296fa5a49757c2318bea62a84", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2022-02-25T06:46:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T05:46:53.000Z", "avg_line_length": 56.59375, "max_line_length": 954, "alphanum_fraction": 0.7161789067, "num_tokens": 1547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4165895413352821}}
{"text": "\\documentclass[11pt,letterpaper]{article}\n\n\\usepackage[pdftex]{graphicx}\n\\usepackage{natbib}\n\\usepackage{fullpage}\n\\usepackage{lineno}\n\\usepackage{multirow}\n\\usepackage{wrapfig}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{sidecap}\n\\usepackage{hyperref}\n\n\\begin{document}\n\n\\setlength{\\parindent}{0mm}\n\\setlength{\\parskip}{0.4cm}\n\n\\bibliographystyle{apalike}\n\n%\\modulolinenumbers[5]\n%\\linenumbers\n\n\\title{\\textbf{GEMINI} test descriptions}\n\\author{Matthew D. Zettergren, PhD\\\\ Associate Professor of Engineering Physics\\\\ Center for Space and Atmospheric Physics\\\\ Physical Sciences Department \\\\Embry-Riddle Aeronautical University\\\\mattzett@gmail.com\\\\zettergm@erau.edu}\n\\maketitle\n\n\\tableofcontents\n\n\\pagebreak\n\n\n\\section{Purpose of this document}\n\nThe \\textbf{G}eospace \\textbf{E}nvironment \\textbf{M}odel of \\textbf{I}on-\\textbf{N}eutral \\textbf{I}nteractions (GEMINI) is a general-purpose, three-dimensional (3D) terrestrial ionospheric model capable of describing most processes relevant to the ionosphere at medium to small spatial scales (200 m to 10000 km).  The main source code repository for GEMINI can be found at \\url{https://github.com/gemini3d/GEMINI}.  This document describes the formulation of tests used to verify the GEMINI build and functioning.  \n\n\n\\section{Diffusion solver test problem, Dirichlet conditions}\n\nAs discussed in the formulation document \\url{https://github.com/gemini3d/GEMINI-docs/blob/master/formulation/GEMINI.pdf}, the parabolic portions of the energy equations are solved using implicit finite difference methods (including TRBDF2 and backward Euler).  These are tested via solution of a simple heat equation describing the evolution of temperature $T(z,t)$ in space and time subject to uniform thermal conduction:\n\\begin{equation}\n\\frac{\\partial T}{\\partial t} - \\lambda \\frac{\\partial^2 T}{\\partial z^2} = 0.\n\\end{equation}\nFor purposes of testing we solve this equation on the \\emph{bounded} domain $0 \\le x \\le 1$.  Invoking separation of variables we presume $T(z,t)=Z(z) \\mathcal{T}(t)$ and substitute back into the original equation:  \n\\begin{equation}\n\\frac{1}{\\lambda \\mathcal{T}} \\frac{\\partial \\mathcal{T}}{\\partial t} - \\frac{1}{Z} \\frac{\\partial^2 Z}{\\partial z^2} = 0.\n\\end{equation}\nEach term depends solely on one of the independent variables $x,t$, which implies that for this relation to be valid for all $x,t$ then each term must be equal to a constant.  \n\\begin{eqnarray}\n\\frac{1}{\\lambda \\mathcal{T}} \\frac{d \\mathcal{T}}{d t} &=& -k^2 \\\\\n- \\frac{1}{Z} \\frac{d^2 Z}{d z^2} &=& k^2.\n\\end{eqnarray}\nNote also that since we have dependence on only one variable that we have converted the derivatives into \\emph{ordinary} derivatives.  The solutions to these ODEs read:\n\\begin{eqnarray}\n\\mathcal{T}(t) &=& A e^{-k^2 \\lambda t} \\\\\nZ(z) &=& A' \\sin kz + B' \\cos kz\n\\end{eqnarray}\nThe elemental solution ($k$ arbitrary) is given by: \n\\begin{equation}\n\\tilde{T}(z,t)=Z(z) \\mathcal{T}(t) = e^{-k^2 \\lambda t} \\left( A'' \\sin kz + B'' \\cos kz \\right)\n\\end{equation}\nFrom this equation it is seen that the time scale for decay of a mode with wavenumber $k$ is given by \n\\begin{equation}\n\\tau = \\frac{1}{k^2 \\lambda}\n\\end{equation}\n\nFurther progress toward a general solution requires specific initial and boundary conditions.  For our test problem we assume that the temperature goes to zero on the boundaries ($z \\in \\{0,1\\}$).  Let us also assume that the initial temperature of the system is given by:  $T(z,0) = f(z)$.  First employing the condition $T(0,t)=0$, we find that $B''=0$.  The other boundary condition $T(1,t)=0$ sets restrictions on the argument/eigenvalues of the sine function, namely that $k=n \\pi, n \\in \\mathbb{Z}^+$ is a set of roots for the sine function.  The elemental solution is then:\n\\begin{equation}\n\\tilde{T}_n(z,t)= A_n e^{-n^2 \\pi^2 \\lambda t} \\sin \\left( n \\pi z \\right)\n\\end{equation}\nAny integer value chosen for $n$ results in a legitimate solution for the original partial differential equation; therefore, the general solution is a linear superposition of all such solutions.  \n\\begin{equation}\nT(z,t)= \\sum_{n=1}^{\\infty} A_n ~ e^{-n^2 \\pi^2 \\lambda t} \\sin \\left( n \\pi z \\right).\n\\end{equation}\nThe initial condition can now be applied to solve for the coefficients $A_n$ by leveraging orthogonality of the sine functions.  That is by making use of the fact that:\n\\begin{equation}\n\\left< \\sin(n \\pi z) | \\sin (n' \\pi z) \\right> = \\int_0^1 \\sin(n \\pi z) \\sin (n' \\pi z) dz = \\frac{1}{2} \\delta_{nn'},\n\\end{equation}\nwe may produce a solution for $A_n$ from the series solution.  The initial condition is represented in summation form (a Fourer sine series) as:  \n\\begin{equation}\nT(z,0) = f(z) = \\sum_{n=1}^{\\infty} A_n ~ \\sin \\left( n \\pi z \\right).\n\\end{equation}\nTaking the scalar product of both sides with $\\sin (n' \\pi z)$ gives:\n\\begin{equation}\n\\left< f(z) | \\sin (n' \\pi z) \\right> = \\sum_{n=1}^{\\infty} A_n ~ \\left< \\sin(n \\pi z) | \\sin (n' \\pi z) \\right> = \\sum_n = \\frac{A_n}{2} \\delta_{nn'} = \\frac{A_{n'}}{2}\n\\end{equation}\nThus the coefficients are:  \n\\begin{equation}\nA_{n'} = 2 \\left< f(z) | \\sin (n' \\pi z) \\right> = 2 \\int_0^1 f(z) \\sin (n' \\pi z) dz\n\\end{equation}\n\nFor purposes of testing it is easiest to pick a test problem with boundary conditions that are represented by a finite sum - one way this can be accomplished is by choosing a boundary condition that is an eigenfunction for this particular problem.  Additionally to fully test the algorithms we should should several different modes in order to illustrate different decay times, for example:  \n\\begin{equation}\n f(z) = \\sin(2 \\pi z) + \\sin(8 \\pi z).\n\\end{equation}\nFrom this, and orthogonality of the sine function it follows that:\n\\begin{equation}\nA_{n'} = \\left\\{ \\begin{array}{cc} 2 & n \\in \\{2,8\\} \\\\ 0 & \\mathrm{otherwise}  \\end{array} \\right. ,\n\\end{equation}\nand that the general solution for this specific set of boundary and initial conditions is:  \n\\begin{equation}\nT(z,t) = e^{-4 \\pi^2 \\lambda t} \\sin \\left( 2 \\pi z \\right)+e^{-64 \\pi^2 \\lambda t} \\sin \\left( 8 \\pi z \\right)\n\\end{equation}\n\nEnergy diffusion in GEMINI is only performed in the field-aligned direction.  Thus, for a 3D system we are effectively just executing a sequence of 1D diffusion equation solutions.  \n\n\n\\section{Diffusion solver test problem, Dirichlet/Neumann (mixed) conditions}\n\nFor this test case we consider a system similar to the previous section but with Neumann boundary conditions asserted at the boundary located at $z=1$, namely:\n\\begin{equation}\n  \\frac{\\partial T}{\\partial z} \\left( z=1, t\\right) = 0,\n\\end{equation} \nwhich changes the modal structure of the solutions as described below.  Taking the results of the separation of variables as before:\n\\begin{eqnarray}\n\\mathcal{T}(t) &=& A e^{-k^2 \\lambda t} \\\\\nZ(z) &=& A' \\sin kz + B' \\cos kz\n\\end{eqnarray}\nWe see that the $z=0$ boundary conditions still leads to $B'=0$, while the remaining conditions is one on the derivative of our solution:\n\\begin{equation}\n    \\frac{\\partial T}{\\partial z} \\left( z=1, t\\right) = AA' e^{-k^2 \\lambda t} k \\cos kz = 0\n\\end{equation}\nFor $t \\ne 0$, we have:  \n\\begin{equation}\n\\cos kz = 0\n\\end{equation}\nwhich implies that the condition $k=(2n+1) \\pi /2, n \\in \\mathbb{Z}^+$ must hold so that the Solution reads:\n\\begin{equation}\nT(z,t)= \\sum_n A_n e^{-\\left( \\frac{(2n+1)^2 \\pi^2}{4}\\right) \\lambda t} \\sin \\left( \\frac{(2n+1)\\pi}{2} z \\right)\n\\end{equation}\n\nFor our initial conditions we again choose two different harmonics, corresponding to $n \\in \\{ 2,8\\}$ so that the initial condition is:\n\\begin{equation}\n f(z) = \\sin \\left( \\frac{5\\pi}{2} z \\right) + \\sin \\left( \\frac{17 \\pi}{2} z \\right)\n\\end{equation}\nyielding a full solution of the form:\n\\begin{equation}\nT(z,t) = e^{- \\frac{25\\pi^2}{4} \\lambda t} \\sin \\left( \\frac{5 \\pi}{2} z \\right)+e^{- \\frac{289 \\pi^2}{4} \\lambda t} \\sin \\left( \\frac{17 \\pi}{2} z \\right)\n\\end{equation}\n\n\n\\section{Potential solver test problem}\n\nThe elliptic potential solver is tested using a simplified 2D test problem, Laplace's equation:\n\\begin{equation}\n\\frac{\\partial^2 \\Phi}{\\partial x^2} + \\frac{\\partial^2 \\Phi}{\\partial y^2} = 0, \n\\end{equation}\non the domain $0 \\le x \\le 1, 0 \\le y \\le 1$ with the boundary conditions $\\Phi(x,0)-=\\Phi(0,y)=\\Phi(1,y)=0, \\Phi(x,1)=f(x)$.  Exploying separation of variables $\\Phi(x,y)=X(x)Y(y)$ we find the ODE solutions for $X(x)$ and $Y(y)$ to be:\n\\begin{eqnarray}\nX(x) &=& A \\sin kx + B \\cos kx \\\\\nY(y) &=& A' \\sinh ky + B' \\cosh ky\n\\end{eqnarray}\nThe boundary conditions dictate the following constraints:  $\\Phi(0,y)=0 \\implies B=0, \\Phi(x,0) \\implies B'=0, \\Phi(1,y)=0 \\implies k=n \\pi$.  Thus we have the general solution:\n\\begin{equation}\n\\Phi(x,y) = \\sum_n A_n \\sinh (n \\pi y) \\sin (n \\pi x)\n\\end{equation}\nAgain choosing our boundary conditions for this test problem so that only one term in the series survives we may choose:\n\\begin{equation}\nf(x) = \\sin(2 \\pi x).\n\\end{equation}\nWhich gives:\n\\begin{equation}\nf(x) = \\sum_n A_n \\sinh (n \\pi) \\sin (n \\pi x),\n\\end{equation}\nfor the potential evaluated at the non-grounded boundary.  By orthogonality the coefficients are:  \n\\begin{equation}\nA_n = \\frac{2}{\\sinh (n \\pi)} \\left< f(x) | \\sin (n \\pi x) \\right>; \n\\end{equation}\nhowever the only nonzero coefficient occurs for $n=2$:\n\\begin{equation}\nA_2 = \\frac{2}{\\sinh (2 \\pi)} \\left< \\sin(2 \\pi x) | \\sin (2 \\pi x) \\right> = \\frac{1}{\\sinh(2 \\pi)}; \n\\end{equation}\nThe solution for this set of boundary conditions is, thus: \n\\begin{equation}\n\\Phi(x,y) = \\frac{\\sinh (2 \\pi y)}{\\sinh(2 \\pi)} \\sin (2 \\pi x)\n\\end{equation}\n\nAll potential solutions currently in GEMINI are two-dimensional so this particular test problem is representative of each.  \n\n\n\\section{Advection solver test problem}\n\nThe advection solver in GEMINI deals with problems of the form:\n\\begin{equation}\n\\frac{\\partial \\rho}{\\partial t} + \\frac{\\partial}{\\partial z} \\left( \\rho v \\right) = 0,  \n\\end{equation}\nand higher dimensional equivalents (implemented through directional splitting).  For constant velocity (assumed to be given) a simpler equation, which can be solved analytically, results.  \n\\begin{equation}\n\\frac{\\partial \\rho}{\\partial t} + v \\frac{\\partial \\rho}{\\partial z} = 0,  \n\\end{equation}\nThis equation can be seen to be equivalent to the wave equation by differentiating with respect to time and space respectively giving:  \n\\begin{eqnarray}\n\\frac{\\partial^2 \\rho}{\\partial t^2} + v \\frac{\\partial^2 \\rho}{\\partial t \\partial z} &=& 0 \\\\\n\\frac{\\partial^2 \\rho}{\\partial z \\partial t} + v \\frac{\\partial^2 \\rho}{\\partial z^2} &=& 0\n\\end{eqnarray}\nEliminating the cross partial derivatives from these equations gives the familiar wave equation.  \n\\begin{equation}\n\\frac{\\partial^2 \\rho}{\\partial t^2} - v^2 \\frac{\\partial^2 \\rho}{\\partial z^2} = 0,  \n\\end{equation}\nThe solution to this particular equation is a wave of the form:\n\\begin{equation}\n\\rho(z,t)=f(z-vt),\n\\end{equation}\nwhere the function $f$ is arbitrary, generally speaking, but dictated by the specific initial conditions of the problem of interest.  This solution can be verified by direct substitution, or derived by separation of variables - analogous to the test problems above.  For an initial condition given by:\n\\begin{equation}\n\\rho(z,0)=e^{-\\frac{z^2}{2 \\sigma_z^2}}\n\\end{equation}\nThe solution at later times is:\n\\begin{equation}\n\\rho(z,t)=e^{-\\frac{(z-vt)^2}{2 \\sigma_z^2}}\n\\end{equation}\nFor testing purposes it is useful to numerical solve this on a periodic domain, e.g. $0 \\le x \\le 1$.\n\nGEMINI advects mass, momentum, and energy in all three dimensions, representative of the equation:  \n\\begin{eqnarray}\n\\frac{\\partial \\rho}{\\partial t} + v_x \\frac{\\partial \\rho}{\\partial x} + v_y \\frac{\\partial \\rho}{\\partial y} + v_z \\frac{\\partial \\rho}{\\partial z} &=& 0 %\\\\  \n%\\frac{\\partial \\rho}{\\partial t} + \\mathbf{v} \\cdot \\nabla \\rho &=& 0 \\\\  \n\\end{eqnarray}\nFor initial conditions given by:\n\\begin{equation}\n\\rho(z,0)=e^{-\\frac{x^2}{2 \\sigma_x^2}}e^{-\\frac{y^2}{2 \\sigma_y^2}}e^{-\\frac{z^2}{2 \\sigma_z^2}}\n\\end{equation}\nthe solution at later time is:\n\\begin{equation}\n\\rho(z,t)=e^{-\\frac{(x-v_x t)^2}{2 \\sigma_x^2}}e^{-\\frac{(y - v_y t)^2}{2 \\sigma_y^2}}e^{-\\frac{(z-v_z t)^2}{2 \\sigma_z^2}}\n\\end{equation}\n\n\n\\section{Error reporting}\n\nPlease create an issue on our GitHub website \\url{https://github.com/gemini3d/} if you find an error in our documentation or codes.  \n\n\n\\section{Contributors}\n\nMajor contributors to GEMINI source code and testing include:  M. Hirsch, G. Grubbs, and M. Burleigh.\n\n\n\\pagebreak\n%\\setcounter{page}{1}\n\n%\\bibliography{GEMINI.bib}\n\n\n\\end{document}\n", "meta": {"hexsha": "0cee2a5ef860520aa461139c90f9cd15eb47a841", "size": 12616, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "test_descriptions/GEMINItests.tex", "max_stars_repo_name": "paulinchin/GEMINI-docs", "max_stars_repo_head_hexsha": "992cafe8d81aef762fd0b186e63defb5a6720055", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-20T22:19:12.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-20T22:19:12.000Z", "max_issues_repo_path": "test_descriptions/GEMINItests.tex", "max_issues_repo_name": "paulinchin/GEMINI-docs", "max_issues_repo_head_hexsha": "992cafe8d81aef762fd0b186e63defb5a6720055", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-02-12T19:46:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-12T19:46:36.000Z", "max_forks_repo_path": "test_descriptions/GEMINItests.tex", "max_forks_repo_name": "paulinchin/GEMINI-docs", "max_forks_repo_head_hexsha": "992cafe8d81aef762fd0b186e63defb5a6720055", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-12T16:49:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-12T16:49:55.000Z", "avg_line_length": 51.2845528455, "max_line_length": 580, "alphanum_fraction": 0.7077520609, "num_tokens": 4054, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.41658953818351246}}
{"text": "\\section{Theoretical Properties}\n\\label{sec:properties}\nIn this section, we see how the simplicity of the Elo-MMR formulas enables us to rigorously prove that the rating system is incentive-compatible, robust, and computationally efficient.\n\n%\\aram{erase this?} First, we discuss some properties that Elo-MMR has in common with the published systems of Codeforces and Topcoder, as well as the classical two-player systems Elo and Glicko. All of these systems propagate belief changes forward in time, never backward. This approach is simple, efficient, and has the benefit of never retroactively changing ratings from the past, nor the ratings of players who are not actively competing. In practice, Elo-MMR and Glicko also converge to the right results slightly faster than the others, by including an uncertainty parameter that starts high for new players.\n\\vspace{-.6em}\n\\subsection{Incentive-compatibility}\n\\label{sec:mono}\n\n%\\aram{erase this?} \\emph{Aligned incentives} is one of our system's most important properties, so we devote this section to motivating, stating, and proving it. The main result, \\Cref{thm:mono}, essentially guarantees that a player who seeks to improve their rating will never want to lose rounds, even if given the benefit of hindsight.\n\n%To see that a \"rational\" rating system may fail monotonicity we begin with two examples.\n\n%First, let's imagine a setting in which players typically maintain their \"momentum\"; that is, a player whose skill is improving rapidly, is expected to continue improving rapidly. A strategic player may then fake some momentum by intentionally performing at a weaker level, before returning to their actual level. The system may then believe that the player will continue to improve, granted inflated ratings until strong evidence arises to the contrary. This type of exploit was discovered in both the Topcoder rating system and the Pokemon Go rating system~\\cite{forivsektheoretical, pokemongo}.%To show that this example is not just a hypothetical, \\aram{cite Glicko-2, Topcoder, Pokemon Go}\\cite{forivsektheoretical}.\n\n%Next, we present a more subtle example. Consider a setting that presents players the choice between an easy challenge, which grants 1 point for partial success and 5 points for full success, or a hard challenge which grants 2 points for partial success and 10 points for full success.\\footnote{This reward model is frequently used in coding competitions such as the International Olympiad of Informatics.} Experts with a high chance of a full success in the hard challenge should take it, whereas novices are likely to do better with the easy challenge. Let's suppose that, as a result, only experts attempt the hard challenges, and let's further suppose that a fraction of them fail to get a full success. Thus, there is a contingent of players with 2 points, all of whom are experts. If the rating system is powerful enough to know this, it may classify the 2-point players as stronger than the 5-point players, incentivizing a strategic novice to go for the lower point value!\n\n%In summary, rating systems that are too powerful risk incentivizing players to perform cheap imitations of expert player behaviour, even when it undermines the game designer's objective for the player (e.g., to score more points). \n\nTo demonstrate the need for incentive-compatibility, let's look at the consequences of violating this property in the Topcoder and Glicko-2 rating systems. These systems track a ``volatility'' for each player, which estimates the variance of their performances. A player whose recent performance history is more consistent would be assigned a lower volatility score, than one with wild swings in performance. The volatility acts as a multiplier on rating changes; thus, players with an extremely low or high performance will have their subsequent rating changes amplified.\n\nWhile it may seem like a good idea to boost changes for players whose ratings are poor predictors of their performance, this feature has an exploit. By intentionally performing at a weaker level, a player can amplify future increases to an extent that more than compensates for the immediate hit to their rating. A player may even ``farm'' volatility by alternating between very strong and very weak performances. After acquiring a sufficiently high volatility score, the strategic player exerts their honest maximum performance over a series of contests. The amplification eventually results in a rating that exceeds what would have been obtained via honest play. This type of exploit was discovered in Glicko-2 as applied to the Pokemon Go video game~\\cite{pokemongo}. Table 5.3 of ~\\cite{forivsektheoretical} presents a milder violation in Topcoder competitions.\n\nTo get a realistic estimate of the severity of this exploit, we performed a simple experiment on the first five years of the Codeforces contest dataset (see \\Cref{sec:datasets}). In \\Cref{fig:topcoder-gaming}, we plot the rating evolution of the world's \\#1 ranked competitive programmer, Gennady Korotkevich, better known as {\\tt tourist}. In the \\emph{control} setting, we plot his ratings according to the Topcoder and Elo-MMR($1$) systems. We contrast these against an \\emph{adversarial} setting, in which we have {\\tt tourist} employ the following strategy: for his first 45 contests, {\\tt tourist} plays normally (exactly as in the unaltered data). For his next 45 contests, {\\tt tourist} purposely falls to last place whenever his Topcoder rating is above 2975. Finally, {\\tt tourist} returns to playing normally for an additional 15 contests.\n\nThis strategy mirrors the Glicko-2 exploit documented in~\\cite{pokemongo}, and does not require unrealistic assumptions (e.g., we don't demand {\\tt tourist} to exercise very precise control over his performances). Compared to a consistently honest {\\tt tourist}, the volatility farming {\\tt tourist} ended up \\emph{523 rating points ahead} by the end of the experiment, with almost 1000 rating points gained in the last 15 contests alone. Transferring the same sequence of performances to the Elo-MMR($1$) system, we see that it not only is immune to such volatility-farming attacks, but it also penalizes the dishonest strategy with a rating loss that decays exponentially once honest play resumes.\n\n\\begin{figure}\n\\begin{minipage}{0.50\\textwidth}\n    \\includegraphics[width=0.95\\textwidth]{images/topcoder.eps}\n    \\includegraphics[width=0.95\\textwidth]{images/elo-mmr.eps}\n\\end{minipage}\n    \\caption{Volatility farming attack on the Topcoder system.}\n    \\label{fig:topcoder-gaming}\n\\end{figure}\n\nRecall that a key purpose of modeling volatility in Topcoder and Glicko-2 was to boost rating changes for inconsistent players. Remarkably, Elo-MMR achieves the same effect: we'll see in \\Cref{sec:robust} that, for $\\rho\\in [0,\\infty)$, Elo-MMR($\\rho$) also boosts changes to inconsistent players. And yet, we'll now prove that no strategic incentive for purposely losing exists in \\emph{any} version of Elo-MMR.\n\nTo this end, we need a few lemmas. Recall that, for the purposes of the algorithm, the performance $p_i$ is defined to be the unique zero of the function $Q_i(p) := \\sum_{j \\succ i} l_j(p) + \\sum_{j \\sim i} d_j(p) + \\sum_{j \\prec i} v_j(p)$, whose terms $l_j,d_j,v_j$ are contributed by opponents against whom $i$ lost, drew, or won, respectively. Wins (losses) are always positive (negative) contributions to a player's performance score:\n\\begin{lemma}\n\\label{lem:mono-term}\nAdding a win term to $Q_i(\\cdot)$, or replacing a tie term by a win term, always increases its zero. Conversely, adding a loss term, or replacing a tie term by a loss term, always decreases it.\n\\end{lemma}\n\n\\begin{proof}\nBy \\Cref{lem:decrease}, $Q_i(p)$ is decreasing in $p$. Thus, adding a positive term will increase its zero whereas adding a negative term will decrease it. The desired conclusion follows by noting that, for all $j$ and $p$, $v_j(p)$ and $v_j(p)-d_j(p)$ are positive, whereas $l_j(p)$ and $l_j(p)-d_j(p)$ are negative.\n\\end{proof}\n\nWhile not needed for our main result, a similar argument shows that performance scores are monotonic across the round standings:\n\n\\begin{theorem}\nIf $i \\succ j$ (that is, player $i$ beats $j$) in a given round, then player $i$ and $j$'s performance estimates satisfy $p_i > p_j$.\n\\end{theorem}\n\n\\begin{proof}\nIf $i \\succ j$ with $i,j$ adjacent in the rankings, then\n\\[Q_i(p) - Q_j(p) = \\sum_{k\\sim i}(d_k(p) - l_k(p)) + \\sum_{k\\sim j}(v_k(p) - d_k(p)) > 0.\\]\nfor all $p$. Since $Q_i$ and $Q_j$ are decreasing functions, it follows that $p_i > p_j$. By induction, this result extends to the case where $i,j$ are not adjacent in the rankings.\n\\end{proof}\n\nWhat matters for incentives is that performance scores be \\emph{counterfactually} monotonic; meaning, if we were to alter the round standings, a strategic player will always prefer to place higher:\n\\begin{lemma}\n\\label{lem:mono-perf}\nIn any given round, holding fixed the relative ranking of all players other than $i$ (and holding fixed all preceding rounds), the performance $p_i$ is a monotonic function of player i's prior rating and of player $i$'s rank in this round.\n\\end{lemma}\n\n\\begin{proof}\nMonotonicity in the prior rating follows directly from monotonicity of the self-tie term $d_i$ in $Q_i$. Since an upward shift in the rankings can only convert losses to ties to wins, monotonicity in contest rank follows from \\Cref{lem:mono-term}. \n\\end{proof}\n\nHaving established the relationship between round rankings and performance scores, the next step is to prove that, even with hindsight, players will always prefer their performance scores to be as high as possible:\n\n\\begin{lemma}\n\\label{lem:mono-rate}\nHolding fixed the set of contest rounds in which a player has participated, their current rating is monotonic in each of their past performance scores.\n\\end{lemma}\n\n\\begin{proof}\nThe player's rating is given by the zero of $L'$ in \\Cref{eq:multiplicities}. The pseudodiffusions of \\Cref{sec:skill-drift} modify each of the $\\beta_k$ in a manner that does not depend on any of the $p_k$, so they are fixed for our purposes. Hence, $L'$ is monotonically increasing in $s$ and decreasing in each of the $p_k$. Therefore, its zero is monotonically increasing in each of the $p_k$.\n\nThis is almost what we wanted to prove, except that $p_0$ is not a performance. Nonetheless, it is a function of the performances: specifically, a weighted average of historical ratings which, using this same lemma as an inductive hypothesis, are themselves monotonic in past performances. By induction, the proof is complete.\n\\end{proof}\n\nFinally, we conclude that a rating-maximizing player is always motivated to improve their round rankings, or raw scores:\n\n\\begin{theorem}[Incentive-compatibility]\n\\label{thm:mono}\nHolding fixed the set of contest rounds in which each player has participated, and the historical ratings and relative rankings of all players other than $i$, player $i$'s current rating is monotonic in each of their past rankings.\n\\end{theorem}\n\n\\begin{proof}\nChoose any contest round in player $i$'s history, and consider improving player $i$'s rank in that round while holding everything else fixed. It suffices to show that player $i$'s current rating would necessarily increase as a result.\n\nIn the altered round, by \\Cref{lem:mono-perf}, $p_i$ is increased; and by \\Cref{lem:mono-rate}, player $i$'s post-round rating is increased. By \\Cref{lem:mono-perf} again, this increases player $i$'s performance score in the following round. Proceeding inductively, we find that performance scores and ratings from this point onward are all increased.\n\\end{proof}\n\nIn the special cases of Elo-MM$\\chi$ or Elo-MMR($\\infty$), the rating system is ``memoryless'': the only data retained for each player are the current rating $\\mu_{i,t}$ and uncertainty $\\sigma_{i,t}$; detailed performance history is not saved. In this setting, we present a natural monotonicity theorem. A similar theorem was previously stated for the Codeforces system, albeit in an informal context without proof~\\cite{Codeforces}.\n\n\\begin{theorem}[Memoryless Monotonicity]\nIn either the Elo-MM$\\chi$ or Elo-MMR($\\infty$) system, suppose $i$ and $j$ are two participants of round $t$. Suppose that the ratings and corresponding uncertainties satisfy $\\mu_{i,t-1} \\ge \\mu_{j,t-1},\\; \\sigma_{i,t-1} = \\sigma_{j,t-1}$. Then, $\\sigma_{i,t} = \\sigma_{j,t}$. Furthermore:\n\nIf $i \\succ j$ in round $t$, then $\\mu_{i,t} > \\mu_{j,t}$.\n\nIf $j \\succ i$ in round $t$, then $\\mu_{j,t} - \\mu_{j,t-1} > \\mu_{i,t} - \\mu_{i,t-1}$.\n\\end{theorem}\n\n\\begin{proof}\nThe new contest round will add a rating perturbation with variance $\\gamma_t^2$, followed by a new performance with variance $\\beta_t^2$. As a result,\n\\[\\sigma_{i,t}\n= \\left( \\frac{1}{\\sigma_{i,t-1}^2 + \\gamma_t^2} + \\frac{1}{\\beta_t^2} \\right)^{-\\frac 12}\n= \\left( \\frac{1}{\\sigma_{j,t-1}^2 + \\gamma_t^2} + \\frac{1}{\\beta_t^2} \\right)^{-\\frac 12}\n= \\sigma_{j,t}.\\]\n\nThe remaining conclusions are consequences of three properties: memorylessness, incentive-compatibility (\\Cref{thm:mono}), and translation-invariance (ratings, skills, and performances are quantified on a common interval scale relative to one another).\n\nSince the Elo-MM$\\chi$ or Elo-MMR($\\infty$) systems are memoryless, we may replace the initial prior and performance histories of players with any alternate histories of our choosing, as long as our choice is compatible with their current rating and uncertainty. For example, both $i$ and $j$ can be considered to have participated in the same set of rounds, with $i$ always performing at $\\mu_{i,t-1}$. and $j$ always performing at $\\mu_{j,t-1}$. Round $t$ is unchanged.\n\nSuppose $i \\succ j$. Since $i$'s historical performances are all equal or stronger than $j$'s, \\Cref{thm:mono} implies $\\mu_{i,t} > \\mu_{j,t}$.\n\nSuppose $j \\succ i$. By translation-invariance, if we shift each of $j$'s performances, up to round $t$ and including the initial prior, upward by $\\mu_{i,t-1} - \\mu_{j,t-1}$, the rating changes between rounds will be unaffected. Players $i$ and $j$ now have identical histories, except that we still have $j\\succ i$ at round $t$. Therefore, $\\mu_{j,t-1} = \\mu_{i,t-1}$ and, by \\Cref{thm:mono}, $\\mu_{j,t} > \\mu_{i,t}$. Subtracting the equation from the inequality proves the second conclusion.\n\\end{proof}\n\n\\subsection{Robust response}\n\\label{sec:robust}\n\nAnother desirable property in many settings is robustness: a player's rating should not change too much in response to any one contest, no matter how extreme their performance. The Codeforces and TrueSkill systems lack this property, allowing for unbounded rating changes. Topcoder achieves robustness by clamping any changes that exceed a cap, which is initially high for new players but decreases with experience.\n\nWhen $\\rho>0$, Elo-MMR($\\rho$) achieves robustness in a natural, smoother manner. To understand how, we look at the interplay between Gaussian and logistic factors in the posterior. Recall the notation in \\Cref{eq:multiplicities}, describing the loss function and weights.\n\n\\begin{theorem}\n\\label{thm:robust}\nIn the Elo-MMR($\\rho$) rating system, let\n\\[\\Delta_+ := \\lim_{p_t\\rightarrow+\\infty} \\mu_{t}-\\mu_{t-1},\n\\quad\\Delta_- := \\lim_{p_t\\rightarrow-\\infty}\\mu_{t-1}-\\mu_{t}.\n\\]\nThen, for $\\Delta_\\pm \\in \\{\\Delta_+, \\Delta_-\\}$,\n\\[\\frac{\\pi}{\\beta_t\\sqrt 3}\n\\left(w_0 + \\frac{\\pi^2}{6}\\sum_{k\\in\\cH_{t-1}}w_k \\right)^{-1}\n\\le \\Delta_\\pm\n\\le \\frac{\\pi}{\\beta_t\\sqrt 3}\\frac{1}{w_0}.\\]\n%Then $\\Delta_{min} \\le \\Delta < \\Delta_{max}$, where\n%\\begin{align*}\n%\\Delta_{min} + \\frac{2\\pi\\beta_t\\beta_0^2}{\\sqrt 3}(\\sum_{k\\in\\mathcal R}\\frac{1}{\\beta_k})\\tanh\\frac{\\Delta_{min}\\pi}{4\\sqrt 3 \\beta_t} &= \\frac{\\pi\\beta_0^2}{\\beta_t\\sqrt 3}\n%\\\\\\Delta_{max} &= \\frac{\\pi\\beta_0^2}{\\beta_t\\sqrt 3}\n%\\end{align*}\n\\end{theorem}\n\n\\begin{proof}\nThe limits exist, by monotonicity. Using the fact that $0 < \\frac{d}{dx}\\tanh(x) \\le 1$, differentiating $L'$ in \\Cref{eq:multiplicities} yields\n\\[\\forall s\\in\\mathbb R,\\; w_0 \\le L''(s)\n\\le w_0 + \\frac{\\pi^2}{6}\\sum_{k\\in\\cH_{t-1}}w_k.\\]\n\nNow, the performance at round $t$ adds a new term with multiplicity one to $L'(s)$: its value is\n$\\frac{\\pi}{\\beta_k\\sqrt{3}} \\tanh \\frac{(s-p_k)\\pi}{\\beta_k\\sqrt{12}}$.\n\nAs a result, for every $s\\in\\mathbb R$, in the limit as $p_t\\rightarrow\\pm\\infty$, $L'(s)$ increases by $\\mp\\frac{\\pi}{\\beta_t\\sqrt 3}$. Since $\\mu_{t-1}$ was a zero of $L'$ without this new term, we now have\n$L'(\\mu_{t-1}) \\rightarrow \\mp\\frac{\\pi}{\\beta_t\\sqrt 3}.$ Dividing by the former inequalities yields the desired result.\n\\end{proof}\n\nThe proof reveals that the magnitude of $\\Delta_{\\pm}$ depends inversely on that of $L''$ in the vicinity of the current rating, which in turn is related to the derivative of the $\\tanh$ terms. If a player's performances vary wildly, the tanh terms will be widely dispersed, so any potential rating value will necessarily be in the tail ends of most of the terms. Tails contribute very small derivatives, enabling a larger rating change. Conversely, the $\\tanh$ terms of a player with a very consistent performance history will contribute large derivatives, so the bound on their rating change will be small.\n\nThus, Elo-MMR naturally caps the rating changes of all players, and the cap is smaller for consistent performers. The cap will increase after an extreme performance, providing a similar ``momentum'' to the Topcoder and Glicko-2 systems, but without sacrificing incentive-compatibility (\\Cref{thm:mono}).\n\nWe can compare the lower and upper bound in \\Cref{thm:robust}: their ratio is on the same order as the fraction of the total weight that is held by the normal term. Recall that $\\rho$ is the weight transfer rate: larger $\\rho$ results in more weight being transferred into $w_0$; in this case, the lower and upper bound tend to stay close together. Conversely, the momentum effect is more pronounced when $\\rho$ is small. In the extreme case $\\rho=0$, $w_0$ vanishes for experienced players, so a sufficiently volatile player would be subject to correspondingly large rating updates. In the extended version of this paper, we quantify an asymptotic steady state for the weights, and argue that $1/\\rho$ can be thought of as a momentum parameter.\n\n\\subsection{Runtime analysis and optimizations}\n\\label{sec:runtime}\nLet's look at the computation time needed to process a round with participant set $\\mathcal P$, where we again omit the round subscript. Each player $i$ has a participation history $\\cH_i$.\n\nEstimating $P_i$ entails finding the zero of a monotonic function with $O(|\\mathcal P|)$ terms, and then obtaining the rating $\\mu_i$ entails finding the zero of another monotonic function with $O(|\\cH_i|)$ terms. Using either of the Illinois or Newton methods, solving these equations to precision $\\epsilon$ takes $O(\\log\\log\\frac 1\\epsilon)$ iterations. As a result, the total runtime needed to process one round of competition is\n\\[O\\left(\\sum_{i\\in\\mathcal P}(|\\mathcal P| + |\\cH_i|) \\log\\log\\frac 1\\epsilon\\right).\\]\nThis complexity is more than adequate for Codeforces-style competitions with thousands of contestants and history lengths up to a few hundred. Indeed, we were able to process the entire history of Codeforces on a small laptop in less than half an hour. Nonetheless, it may be cost-prohibitive in truly massive settings, where $|\\mathcal P|$ or $|\\cH_i|$ number in the millions. Fortunately, it turns out that both functions may be compressed down to a bounded number of terms, with negligible loss of precision.\n\n\\paragraph{Adaptive subsampling}\nIn \\Cref{sec:bayes_model}, we used Doob's consistency theorem to argue that our estimate for $P_i$ is consistent. Specifically, we saw that $O(1/\\epsilon^2)$ opponents are needed to get the typical error below $\\epsilon$. Thus, we can subsample the set of opponents to include in the estimation, omitting the rest. Random sampling is one approach. A more efficient approach chooses a fixed number of opponents whose ratings are closest to that of player $i$, as these are more likely to provide informative match-ups. On the other hand, if the setting requires incentive-compatibility to hold exactly, then one must avoid choosing different opponents for each player.\n\n\\paragraph{History compression}\nSimilarly, it's possible to bound the number of stored factors in the posterior. Our skill-evolution algorithm decays the weights of old performances at an exponential rate. Thus, the contributions of all but the most recent $O(\\log\\frac 1\\epsilon)$ terms are negligible. Rather than erase the older logistic terms outright, we recommend replacing them with moment-matched Gaussian terms, similar to the transfers in \\Cref{sec:skill-drift} with $\\kappa_t=0$. Since Gaussians compose easily, a single term can then summarize an arbitrarily long prefix of the history.\n\nSubstituting $1/\\epsilon^2$ and $\\log\\frac 1\\epsilon$ for $|\\cP|$ and $|\\cH_i|$, respectively, the runtime of Elo-MMR with both optimizations becomes\n\\[O\\left(\\frac {|\\mathcal P|}{\\epsilon^2} \\log\\log\\frac 1\\epsilon\\right).\\]\n\nIf the contests are \\emph{extremely large}, so that $\\Omega(1/\\epsilon^2)$ opponents have a rating and uncertainty in the same $\\epsilon$-width bucket as player $i$, then it's possible to do even better: up to the allowed precision $\\epsilon$, the corresponding terms can be treated as duplicates. Hence, their sum can be determined by counting how many of these opponents win, lose, or tie against player $i$. Given the pre-sorted list of ranks of players in the bucket, two binary searches would yield the answer. In practice, a single bucket might not contain enough participants, so we sample enough buckets to yield the desired precision.\n\n\\paragraph{Simple parallelism}\nSince each player's rating computation is independent, the algorithm is embarrassingly parallel. Threads can read the same global data structures, so each additional thread contributes only $O(1)$ memory overhead.\n\n% \\subsection{erase all this, or present in a different way?}\n\n% Imagine a player who performs very consistently over a long period of time, repeatedly achieving $p_i = 1000$ until convergence. Now, perhaps as a result of attending an intensive training camp in Petrozavodsk, their skill changes dramatically. From this point on, they consistently achieve $p_i = 3000$.\n\n% How does each rating system respond to the first such surprise occurrence? Elo-MMR treats the new result as a fluke, an outlier that ought to be ignored. The player gains 48 points; as a result of the parameters we set, this is the maximum possible for an experienced player as $p_i \\rightarrow \\infty$. In practice, ratings may change by more than 48, as the maximum depends on existing fluctuations in their history; here we're looking at the extreme example of a player with a history of always performing at exactly $p_i = 1000$.\n\n% \\begin{figure}\n%     \\centering\n%     \\includegraphics[width=\\columnwidth]{images/ResponsePlot.png}\n%     \\caption{An accelerated convergence effect in the presence of sustained improved performances.}\n%     \\label{fig:accelerated}\n% \\end{figure}\n\n% Had we tried to perform outlier reduction in a memoryless fashion, we would continue to increase the rating by 48 per match, oblivious to the possibility that the player truly did experience a sudden improvement. In Elo-MMR, the outlier status of a performance is treated as tentative. If later matches support the hypothesis of having improved, the rating will increase by an additional 63 points, followed by over 100 points in each of the third and following matches, as plotted by the blue curve above.\n\n% After six consecutive matches with $p_i = 3000$, the rating is 1875 and very unstable (even though $\\sigma_i$ is unchanged!). The system is no longer sure which to trust: the extensive history at level 1000, or the smaller number of recent matches at level 3000. Depending on what comes next, the player's rating can very quickly fall toward 1000 or rise toward 3000. However, note that in either case, the change will not overshoot, say to 5000, unless enough new evidence is accumulated at that level. As the $p_i=3000$ streak continues, the seventh match on the blue curve jumps by a whopping 566 points. As the player's rating converges to 3000, the old $p_i = 1000$ data acquires outlier status, thus speeding convergence.\n\n% In contrast, while a system such as Codeforces does not compute $p_i$ values in quite in the same way, we can obtain a good approximation by removing outlier reduction from Elo-MMR, effectively treating the performances to be averaged as normal instead of logistic measurements. This makes the system effectively memoryless, since it turns out that each match simply moves the rating about 16\\% closer to the new $p_i$ value, independent of the history. With this change, we obtain the orange curve, which jumps a whopping 320 points at the very first performance. Indeed, there is no limit: if you could find players whose ratings are extremely high, and beat them even once, your rating would take arbitrarily large leaps.\n\n% Note that this is not quite true of Topcoder, which incorporates a hack that caps the maximum rating change: if Topcoder's update formula demands too large a change, the cap kicks in. In contrast, Elo-MMR's cap is a natural and smooth consequence of its update formula and is sensitive to whether a change is charting new territory, or merely confirming a plausible hypothesis. Topcoder does attempt to make the magnitude of its updates sensitive to the amount of fluctuation in a player's history, using a volatility measure, but this measure does not account for the direction of the changes, resulting in the non-monotonicity flaw mentioned above.\n\n% Notwithstanding arguments that a high rating ought to properly be earned over multiple matches rather than a single fluke, the other danger is that these observations also hold in reverse: one bad day on Codeforces can seriously damage one's rating and negate several rounds of steady progress. By using heavy-tailed logistic distributions everywhere, Elo-MMR understands that unusually high or low performances do occasionally occur, and one round in isolation is never a reliable signal.\n\n% Interestingly, despite the slow start, the blue curve ultimately converges faster than the orange one. Since Elo-MMR uses its memory to dynamically adapt its view of potential outliers, it overtakes the orange curve as soon as new evidence outweighs the old hypothesis!\n\n% \\subsection{Inflation and division boundary artifacts: erase or rewrite?}\n\n% The code and ratings of real Codeforces members as computed by Elo-MMR are available at https://github.com/EbTech/EloR. Original Codeforces ratings are at http://codeforces.com/ratings. One striking difference is massive inflation in the Codeforces system. Gennady Korotkevich, best known by his competitive programming handle ``tourist'', has been the reigning world champion for years. Toward the end of 2011, his rating reached a new ceiling of about 2700 according to both systems. However, as of this writing, his rating on Elo-MMR has increased by about 300 additional points, while on Codeforces it increased by almost 900. To get a sense of the magnitude of this change, 900 points is the difference between an average member and a Grandmaster! Indeed, most of the variance in the Codeforces system is concentrated at the top, with much smaller rating differences between beginner and intermediate members. This is caused by certain ad hoc elements of the system that are not founded on any rigorous model.", "meta": {"hexsha": "526bc0e604afea5f2bf9926c1472a0b62c7905c5", "size": 27627, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/source/sections/s5_properties.tex", "max_stars_repo_name": "kiwec/Elo-MMR", "max_stars_repo_head_hexsha": "bf64ea75e8c0dbb946d379b9bee1753e604b388a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 57, "max_stars_repo_stars_event_min_datetime": "2021-02-12T18:28:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T10:59:36.000Z", "max_issues_repo_path": "paper/source/sections/s5_properties.tex", "max_issues_repo_name": "cesartxt/Elo-MMR", "max_issues_repo_head_hexsha": "7ef860d599e8325ae1f615ce08120369b39bfecc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2021-05-09T15:42:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T08:41:23.000Z", "max_forks_repo_path": "paper/source/sections/s5_properties.tex", "max_forks_repo_name": "cesartxt/Elo-MMR", "max_forks_repo_head_hexsha": "7ef860d599e8325ae1f615ce08120369b39bfecc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2021-02-13T13:21:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T23:08:41.000Z", "avg_line_length": 128.4976744186, "max_line_length": 1016, "alphanum_fraction": 0.772432765, "num_tokens": 6802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.41636610048195377}}
{"text": "\\XtoCBlock{PT1}\r\n\\label{block:PT1}\r\n\\begin{figure}[H]\\includegraphics{PT1}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Input In(k)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & Output Out(k)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nV & Gain\\tabularnewline\r\n\\hline\r\nfc & Cut off frequency of low pass filter\\tabularnewline\r\n\\hline\r\nts\\_fact & Multiplication factor of base sampling time (in integer format)\\tabularnewline\r\n\\hline\r\nmethod & Discretization method\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nFirst order low pass:\n\n    G(s) = V/(s/w + 1)\r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/PT1_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8} & 8 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP16} & 16 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{FiP32} & 32 Bit Fixed Point Implementation\\tabularnewline\r\n\\textbf{Float32} & 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{Float64} & 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8}\r\n\\index{Block ID!3312}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8 \\tabularnewline\r\n\\textbf{ID} & 3312 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PT1\\_FiP8.c \\tabularnewline\r\n\\textbf{H filename} & PT1\\_FiP8.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     int8          Out;\r\n     int8          b0;\r\n     int8          b1;\r\n     int8          a0;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int8          in_old;\r\n} PT1_FIP8;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PT1_FiP8.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16}\r\n\\index{Block ID!3313}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16 \\tabularnewline\r\n\\textbf{ID} & 3313 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PT1\\_FiP16.c \\tabularnewline\r\n\\textbf{H filename} & PT1\\_FiP16.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     int16         Out;\r\n     int16         b0;\r\n     int16         b1;\r\n     int16         a0;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int16         in_old;\r\n} PT1_FIP16;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PT1_FiP16.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32}\r\n\\index{Block ID!3314}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32 \\tabularnewline\r\n\\textbf{ID} & 3314 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PT1\\_FiP32.c \\tabularnewline\r\n\\textbf{H filename} & PT1\\_FiP32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & \\tabularnewline\r\n\\hline\r\nb1 & \\tabularnewline\r\n\\hline\r\na0 & \\tabularnewline\r\n\\hline\r\nsfrb & \\tabularnewline\r\n\\hline\r\nsfra & \\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     int32         Out;\r\n     int32         b0;\r\n     int32         b1;\r\n     int32         a0;\r\n     int8          sfrb;\r\n     int8          sfra;\r\n     int32         in_old;\r\n} PT1_FIP32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PT1_FiP32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float32}\r\n\\index{Block ID!3315}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float32 \\tabularnewline\r\n\\textbf{ID} & 3315 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PT1\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & PT1\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Coefficient b0\\tabularnewline\r\n\\hline\r\nb1 & Coefficient b1\\tabularnewline\r\n\\hline\r\na0 & Coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float32       *In;\r\n     float32       Out;\r\n     float32       b0;\r\n     float32       b1;\r\n     float32       a0;\r\n     float32       in_old;\r\n} PT1_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PT1_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{Float64}\r\n\\index{Block ID!3316}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & Float64 \\tabularnewline\r\n\\textbf{ID} & 3316 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & PT1\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & PT1\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nb0 & Coefficient b0\\tabularnewline\r\n\\hline\r\nb1 & Coefficient b1\\tabularnewline\r\n\\hline\r\na0 & Coefficient a0\\tabularnewline\r\n\\hline\r\nin\\_old & In(k-1)\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     float64       *In;\r\n     float64       Out;\r\n     float64       b0;\r\n     float64       b1;\r\n     float64       a0;\r\n     float64       in_old;\r\n} PT1_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/Control/Doc/Test_PT1_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "66a30c56a98b5bf0e34492c1b11bc2382f20a1b4", "size": 6782, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/Control/Doc/PT1.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/Control/Doc/PT1.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/Control/Doc/PT1.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4837545126, "max_line_length": 90, "alphanum_fraction": 0.6843114126, "num_tokens": 2199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6224593452091672, "lm_q1q2_score": 0.4163507688938753}}
{"text": "\\chapter{Control Structures}\n\nTo make our code capable representing any computation, certain control structures are required. We need a way of running a particular command conditionally on some other information. And we need a way of executing the same code more than once.\n\n\\section{if-else}\n\n\\index{if}\n\nConditional execution in JavaScript is implemented using the if-else structure, or just called an if-statement. To use an if-statement I first need a quantity that reduces to a boolean value: either true or false. This value becomes the condition under which a particular piece of code is executed if it is true. The condition is placed between the set of open and closed parenthesis. Immediately following the parenthesis is the piece of code that will be executed if the condition is true. The code is grouped together using an open-closed set of curly brackets.\n\n\\codejs{\\source{js/if_true.js}}\n\nI can also specify that something is done if the value is \\textit{not} true, which will fall under the \\texttt{else} part. Not true is the same as saying false.\n\n\\codejs{\\source{js/if_nottrue.js}}\n\nEven though the above example is completely valid, it can be simplified since there are no operations done in the top part of the if-else. I can use the logical 'not', \\texttt{!}, to negate the boolean values. True becomes false, and false becomes true. This flips the roles of the if-else blocks, and so I can get rid of the 'else' part, while keeping the same logic. That is, this version of the control structure is equivalent to the previous one.\n\n\\codejs{\\source{js/if_nottrue2.js}}\n\nIn the following example, I am testing to see if a particular number is even or odd, and I want it to print something different in each case. To see if a number is even, I used the modulus operator. If the number divided by 2 has a zero remainder, then the modulus will return zero, and I know that 2 is a factor of the number. The \\texttt{===} operator returns true if \\texttt{myNumber \\% 2} is zero, and false if it is not zero. You should always give an if-statement a boolean value, and so comparison operators can be used to convert numbers to booleans. The comparison has the lowest order of operations, and so it will be done last.\\\\\n\n\\codejs{\\source{js/odd.js}}\n\nAll of the operations together, \\texttt{myNumber \\% 2 === 0}, becomes the condition of the if-statement. Only the first thing following the condition is associated with the 'true' case. The piece of code immediately following the else is not executed if the condition is true, but it is if the condition is false. If you wish to have multiple commands associated with the condition, curly braces are used to group the code together.\\\\\n\n\\codejs{\\source{js/odd_2.js}}\n\nHere I not only print out whether the number is even, but divide it by two if it is even. If it is odd, I subtract 1 from the number before dividing so that the result is still an integer. If I had not put curly braces around each set of code, then the interpreter would not have understood that I wanted the second statement in each block to only be executed for that condition.\\\\\n\n\\section{nested if-else}\n\nAny code can be placed in an if-statement, including more if-statements. A common problem is that a variable could have several possible values, and something different should happen for each value.\n\n\\codejs{\\source{js/hello_foo.js}}\n\nThe first if-statement checks for one value. If it is that value it does the thing it should for it. If it's not that value, it goes to the \\texttt{else} part. The only thing in the else of the first if-statement is another if-statement that checks for another value. If it's the second value it does that thing, but if it's not it goes to the else of the second if-statement.\\\\\n\nHowever, any structure of nested if-else statements is valid.\n\n\\codejs{\\source{js/ifrainy.js}}\n\nWhat will be printed above given the values of \\texttt{daylight}, \\texttt{clouds}, and \\texttt{rain}? Does the value of \\texttt{lights} affect what's printed, or when would it? What would the values have to be in order for them to decide to \"go swimming\"?\\\\\n\nCertain logic can sometimes be expressed in more that one way. Boolean algebra can be used to rewrite if-else structures into a series of equivalent  if-statements using the logical operators.\n\n\\codejs{\\source{js/ifrainy2.js}}\n\nWhile this is logically equivalent to the first structure, it checks and rechecks the same values at each if-statement. It is also harder to see which scenarios, or cases, have a prescribed activity. And what if a \\texttt{!} was accidentally omitted? While the choice of which types of structures to use is up to you, your choice should be guided by both the purpose of the structure, and how easy it is to understand and debug if it doesn't work as expected.\\\\\n\nLet's look at exactly how an if-else can be re-written with logical operators, or vice-versa. A single 'and' operation can be thought of as a nested if-else statement where both conditions have to be true for the result to be true. If either condition is false (or both), the result is false. The two if-else structures in the following example are equivalent.\n\n\\index{and}\n\n\\codejs{\\source{js/and.js}}\n\nFor an 'or' operation, if at least one of the conditions is true (or both), then the result is true. This can be represented by a series of if-else statements. The only time the result is false is if both conditions are false.\n\n\\index{or}\n\n\\codejs{\\source{js/or.js}}\n\nThese kind of examples also help to explain what is called short-circuit behavior in boolean operators. Take a look back at the 'and' example. If the value of \\texttt{a} was false, then the first if-else structure would never even check the value \\texttt{b} because it would have immediately gone to the else part. The same is true with the \\texttt{\\&\\&} operator. If \\texttt{a} is false, then the value of \\texttt{b} doesn't matter and so it doesn't check it. For the \\texttt{||} operator, if the first value is true, then the value of the second doesn't matter since only one of them has to be true for the result to be true.\\\\\n\nIt may seem like we don't need to worry about short circuit behavior as programmers, since why should we care if it checks a value or not. For the most part it doesn't matter for writing programs. However, if you make a function call in the condition of an if-statement, short-circuit behavior could matter if that function call does something in addition to being a condition.\n\n\\section{while}\n\n\\index{while loop}\n\nThe iteration control structure has to be tied to a conditional structure, so that it knows when to stop. A \\texttt{while} loop initially behaves similarly to an if-statement. The condition is placed in the parenthesis immediately following the \\texttt{while} keyword. If the condition is false, then execution skips the code in the braces. If the condition is true, it executes the code in the braces, but after it's done it re-evaluates the condition. It continues to execute the code in the braces, and evaluates the condition, until the condition is false.\\\\\n\n\\codejs{\\source{js/countto5.js}}\n\n\nIn the above example, the variable \\texttt{x} is called the loop control variable. Its initial value of \\texttt{0} causes the condition \\texttt{x < 5} to be true, and so it then executes the code in the braces. The only thing it does is to add 1 to the variable. It then checks the condition again, which is still true. It keeps repeating this process adding 1 to \\texttt{x} each time, until it gets to 5. When \\texttt{x} is 5, the condition becomes false since 5 is not less than 5. The loop executed the code a total of 5 times before it stopped.\\\\\n\n\nA loop will continue to repeat itself for as long as the condition is true. If nothing occurs to cause the condition to be false, the loop will run for as long as the program is capable: this is called an infinite loop.\\\\\n\n\\codejs{\\source{js/infiniteloop.js}}\n\nThe above example will run forever, even though it might look very similar to the first example. The issue is that the variable being changed inside the loop is different than the variable being used in the condition. \\texttt{x < 5} will always be true, and thus it will loop forever.\\\\\n\nA while loop does not necessarily have to proceed in a linear fashion. How many times does the following loop repeat, and what is the final value of \\texttt{x}?\n\n\\codejs{\\source{js/powersof2loop.js}}\n\n\nConsider the following loop as a brain teaser.\n\n\\codejs{\\source{js/zigzagloop.js}}\n\nDoes this loop ever stop? If so, how many times does it loop? Just by looking at the terminating condition, and assuming it does stop eventually, what must be the final value of \\texttt{x}?\n\n\\section{for}\n\n\\index{for loop}\n\nThe 'for' loop is a shorter way of writing a linear while loop. If I know ahead of time exactly how many times I want the loop to repeat, there is a regular pattern I can follow. First, create a variable that starts at zero. The loop condition is as long as that variable is less than the number of times I want it to loop. And after each loop I add 1 to the variable.\n\n\\codejs{\\source{js/countto5for.js}}\n\nWhen you write a for loop, the stuff inside the parenthesis is not just the loop condition. It also contains the initial value of the loop control variable, and the increment operation done after each time through the loop. In every other way this for loop works exactly the same as the while loop. It loops exactly 5 times.\\\\\n\nNow, what numbers get printed to the console? The first time through the loop the value of \\texttt{x} is 0, so 0 gets printed. The 1, 2, 3, and 4. After it prints the 4 the increment \\texttt{x++} adds 1 to x, making it 5. But \\texttt{5 < 5} is false, and so the loop doesn't repeat. Even though the final value is 5, it never gets printed.", "meta": {"hexsha": "5dcaaeb84d4e6cc2a4d9e2ceb26639ff4af9cb0f", "size": 9804, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX_files/ControlStructures.tex", "max_stars_repo_name": "kcdodd/ecsp-book", "max_stars_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-07-27T18:34:02.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-27T18:34:02.000Z", "max_issues_repo_path": "TeX_files/ControlStructures.tex", "max_issues_repo_name": "kcdodd/ecsp-book", "max_issues_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX_files/ControlStructures.tex", "max_forks_repo_name": "kcdodd/ecsp-book", "max_forks_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 92.4905660377, "max_line_length": 640, "alphanum_fraction": 0.7714198286, "num_tokens": 2341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593312018545, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.416350767741873}}
{"text": "\\documentclass[11pt,oneside]{article}    %use\"amsart\"insteadof\"article\"forAMSLaTeXformat\n\\usepackage{geometry}        %Seegeometry.pdftolearnthelayoutoptions.Therearelots.\n\\geometry{letterpaper}        %...ora4paperora5paperor...\n%\\geometry{landscape}        %Activateforforrotatedpagegeometry\n%\\usepackage[parfill]{parskip}        %Activatetobeginparagraphswithanemptylineratherthananindent\n\\usepackage{graphicx}                %Usepdf,png,jpg,orepsßwithpdflatex;useepsinDVImode\n                                %TeXwillautomaticallyconverteps-->pdfinpdflatex        \n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\n%----macros begin---------------------------------------------------------------\n\\usepackage{color}\n\\usepackage{amsthm}\n\n\\def\\conv{\\mbox{\\textrm{conv}\\,}}\n\\def\\aff{\\mbox{\\textrm{aff}\\,}}\n\\def\\E{\\mathbb{E}}\n\\def\\R{\\mathbb{R}}\n\\def\\Z{\\mathbb{Z}}\n\\def\\tex{\\TeX}\n\\def\\latex{\\LaTeX}\n\\def\\v#1{{\\bf #1}}\n\\def\\p#1{{\\bf #1}}\n\\def\\T#1{{\\bf #1}}\n\n\\def\\vet#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\\def\\mat#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\n\\def\\lin{\\mbox{\\rm lin}\\,}\n\\def\\aff{\\mbox{\\rm aff}\\,}\n\\def\\pos{\\mbox{\\rm pos}\\,}\n\\def\\cone{\\mbox{\\rm cone}\\,}\n\\def\\conv{\\mbox{\\rm conv}\\,}\n\\newcommand{\\homog}[0]{\\mbox{\\rm homog}\\,}\n\\newcommand{\\relint}[0]{\\mbox{\\rm relint}\\,}\n\n%----macros end-----------------------------------------------------------------\n\n\\title{Accelerated intersection of geometric objects\n\\footnote{This document is part of the \\emph{Linear Algebraic Representation with CoChains} (LAR-CC) framework~\\cite{cclar-proj:2013:00}. \\today}\n}\n\\author{Alberto Paoluzzi}\n%\\date{}                            %Activatetodisplayagivendateornodate\n\n\\begin{document}\n\\maketitle\n\\nonstopmode\n\n\\begin{abstract}\nThis module contains the first experiments of a parallel implementation of the intersection of (multidimensional) geometric objects. The first installment is being oriented to the intersection of line segment in the 2D plane. A generalization of the algorithm, based on the classification of the containment boxes of the geometric values, will follow quickly.\n\\end{abstract}\n\n\\tableofcontents\n\n%===============================================================================\n\\section{Introduction}\n%===============================================================================\n\nAn easily parallelizable implementation of the accelerated intersection of geometric objects is given in this module. Our first aim is to implement a specialized version for simplices, that generalizes the $nD$-trees of points (that are 0-simplices), to $(d-1)$-dimensional simplices in $d$-space, starting with the intersection of line segments in the plane. Our plan is to follow with an implementation for intersection of general \\emph{non convex} sets.\n\n\n%===============================================================================\n\\section{Implementation}\n%===============================================================================\n\nThe first implementation of this module concerns the computation of the intersection points among a set of line segment in the 2D plane. The containment boxes of the input segments are iteratively classified against the 1-dimensional centroid of smaller and smaller buckets of data. \n\nAt the end of the classification, where the same geometric object may be inserted in several different buckets, a \\emph{brute-force} intersection is applied to each final subset. Finally, the duplicated intersection points are removed, and a 1-dimensional LAR data structure is generated, with 1-cells given by the split line segments. \n\nA complete LAR of the plane partition generated by the arrangment of lines is then computed by: (a) generating the maximal 2-connected components of such 1-dimensional graph; and (b) by traversing in counter-clockwise order the generated subgraphs to report the 2-dimensional cells of the plane partition.\n\nThe splitting algorithm may be easily parallelized, since both during their generation and at the end of this one, the various buckets of data can be dispatched to different processors for independent computation, followed by elimination of duplicates. In particular, a standard \\emph{map-reduce} software infrastructure may be used for this parallelization purpose.\n\n\n\\subsection{Construction of independent buckets}\n%===============================================================================\n\n\n\\paragraph{Containment boxes}\n\nGiven as input a list \\texttt{randomLineArray} of pairs of 2D points, the function \\texttt{containment2DBoxes} returns, in the same order, the list of \\emph{containment boxes} of the input lines. A \\emph{containment box} of a geometric object of dimension $d$ is defined as the minimal $d$-cuboid, equioriented with the reference frame, that contains the object. For a 2D line it is given by the tuple $(x1,y1,x2,y2)$, where $(x1,y1)$ is the point of minimal coordinates, and $(x2,y2)$ is the point of maximal  coordinates.\n\n%-------------------------------------------------------------------------------\n@D Containment boxes\n@{\"\"\" Containment boxes \"\"\"\ndef containment2DBoxes(randomLineArray):\n    boxes = [eval(vcode(4)([min(x1,x2),min(y1,y2),max(x1,x2),max(y1,y2)]))\n            for ((x1,y1),(x2,y2)) in randomLineArray]\n    return boxes\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Splitting the input above and below a threshold}\n%-------------------------------------------------------------------------------\n@D Splitting the input above and below a threshold\n@{\"\"\" Splitting the input above and below a threshold \"\"\"\ndef splitOnThreshold(boxes,subset,coord):\n    theBoxes = [boxes[k] for k in subset]\n    threshold = centroid(theBoxes,coord)\n    ncoords = len(boxes[0])/2\n    a = coord%ncoords\n    b = a+ncoords\n    below,above = [],[]\n    for k in subset:\n        if boxes[k][a] <= threshold: below += [k]\n    for k in subset:\n        if boxes[k][b] >= threshold: above += [k]\n    return below,above\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Iterative splitting of box buckets}\n%-------------------------------------------------------------------------------\n@D Iterative splitting of box buckets\n@{\"\"\" Iterative splitting of box buckets \"\"\"\ndef splitting(bucket,below,above, finalBuckets,splittingStack):\n    if (len(below)<4 and len(above)<4) or len(set(bucket).difference(below))<7 \\\n        or len(set(bucket).difference(above))<7: \n        finalBuckets.append(below)\n        finalBuckets.append(above)\n    else: \n        splittingStack.append(below)\n        splittingStack.append(above)\n\ndef geomPartitionate(boxes,buckets):\n    geomInters = [set() for h in range(len(boxes))]\n    for bucket in buckets:\n        for k in bucket:\n            geomInters[k] = geomInters[k].union(bucket)\n    for h,inters in enumerate(geomInters):\n        geomInters[h] = geomInters[h].difference([h])\n    return AA(list)(geomInters)\n\ndef boxBuckets(boxes):\n    bucket = range(len(boxes))\n    splittingStack = [bucket]\n    finalBuckets = []\n    while splittingStack != []:\n        bucket = splittingStack.pop()\n        below,above = splitOnThreshold(boxes,bucket,1)\n        below1,above1 = splitOnThreshold(boxes,above,2)\n        below2,above2 = splitOnThreshold(boxes,below,2)                      \n        splitting(above,below1,above1, finalBuckets,splittingStack)\n        splitting(below,below2,above2, finalBuckets,splittingStack)      \n        finalBuckets = list(set(AA(tuple)(finalBuckets)))\n    parts = geomPartitionate(boxes,finalBuckets)\n    return AA(sorted)(parts)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Brute force intersection within the buckets}\n%===============================================================================\n\n\n\n\n\\paragraph{Intersection of two line segments}\n%-------------------------------------------------------------------------------\n@D Intersection of two line segments\n@{\"\"\" Intersection of two line segments \"\"\"\ndef segmentIntersect(boxes,lineArray,pointStorage):\n    def segmentIntersect0(h):\n        p1,p2 = lineArray[h]\n        line1 = '['+ vcode(4)(p1) +','+ vcode(4)(p2) +']'\n        (x1,y1),(x2,y2) = p1,p2\n        B1,B2,B3,B4 = boxes[h]\n        def segmentIntersect1(k):\n            p3,p4 = lineArray[k]\n            line2 = '['+ vcode(4)(p3) +','+ vcode(4)(p4) +']'\n            (x3,y3),(x4,y4) = p3,p4\n            b1,b2,b3,b4 = boxes[k]\n            if not (b3<B1 or B3<b1 or b4<B2 or B4<b2):\n            #if True:\n                m23 = mat([p2,p3])\n                m14 = mat([p1,p4])\n                m = m23 - m14\n                v3 = mat([p3])\n                v1 = mat([p1])\n                v = v3-v1\n                a=m[0,0]; b=m[0,1]; c=m[1,0]; d=m[1,1];\n                det = a*d-b*c\n                if det != 0:\n                    m_inv = mat([[d,-b],[-c,a]])*(1./det)\n                    alpha, beta = (v*m_inv).tolist()[0]\n                    #alpha, beta = (v*m.I).tolist()[0]\n                    if -0.0<=alpha<=1 and -0.0<=beta<=1:\n                        pointStorage[line1] += [alpha]\n                        pointStorage[line2] += [beta]\n                        return list(array(p1)+alpha*(array(p2)-array(p1)))\n            return None\n        return segmentIntersect1\n    return segmentIntersect0\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Brute force bucket intersection}\n%-------------------------------------------------------------------------------\n@D Brute force bucket intersection\n@{\"\"\" Brute force bucket intersection \"\"\"\ndef lineBucketIntersect(boxes,lineArray, h,bucket, pointStorage):\n    intersect0 = segmentIntersect(boxes,lineArray,pointStorage)\n    intersectionPoints = []\n    intersect1 = intersect0(h)\n    for line in bucket:\n        point = intersect1(line)\n        if point != None: \n            intersectionPoints.append(eval(vcode(4)(point)))\n    return intersectionPoints\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Accelerate intersection of lines}\n%-------------------------------------------------------------------------------\n@D Accelerate intersection of lines\n@{\"\"\" Accelerate intersection of lines \"\"\"\ndef lineIntersection(lineArray):\n    lineArray = [line for line in lineArray if len(line)>1]\n    from collections import defaultdict\n    pointStorage = defaultdict(list)\n    for line in lineArray:\n        p1,p2 = line\n        key = '['+ vcode(4)(p1) +','+ vcode(4)(p2) +']'\n        pointStorage[key] = []\n    boxes = containment2DBoxes(lineArray)\n    buckets = boxBuckets(boxes)\n    intersectionPoints = set()\n    for h,bucket in enumerate(buckets):\n        pointBucket = lineBucketIntersect(boxes,lineArray, h,bucket, pointStorage)\n        intersectionPoints = intersectionPoints.union(AA(tuple)(pointBucket))\n    frags = AA(eval)(pointStorage.keys())\n    params = AA(COMP([sorted,list,set,tuple,eval,vcode(4)]))(pointStorage.values())      \n    return intersectionPoints,params,frags  ### GOOD: 1, WRONG: 2 !!!\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Generation of LAR representation of split segments}\n%===============================================================================\nThe function \\texttt{lines2lar} is used to generate a 1-dimensional LAR complex from\nan array of lines, i.e.~of pairs of 2D points. For every \\emph{line} in \\texttt{frags}\nis computed an \\emph{ordered} list \\texttt{outline} of \\emph{symbolic} intersection points, including \nthe first and last vertex of the line, and every interior point generated by the list \\texttt{params[k]}.\n\nThen, for every symbolic representation \\texttt{key} of a point in \\texttt{outline}, a \ndictionary vertex is either created or retrieved, and a corresponding edge is orderly created, using the index of the point.\nAt the same time, the vertices created in this way are accumulated within the \\texttt{V} array.\nFinally, each edge in EV is extended to contain a second vertex index using the subsequent edge.  \n\nThe third stage finalizes the vertex set of the output LAR, by identifying the closest vertices, i.e.~those at distance\nless or equal to the current resolution, set to \\texttt{10**(-PRECISION)}, by searching via the \\texttt{scipy.spatialKDTree} the pairs of vertices at less than this distance.\n\nA fourth stage identifies the possibly duplicated edges. Some of these could appear, e.g., when importing a set of adjacent boxes from some drawing program, to generate an array of lines, to be mutually intersected and transformed into a LAR data structure.\n\n\\paragraph{Create the LAR of fragmented lines}\n%-------------------------------------------------------------------------------\n@D Create the LAR of fragmented lines\n@{\"\"\" Create the LAR of fragmented lines \"\"\"\nfrom scipy import spatial\n\ndef lines2lar(lineArray,normalize=False):\n    _,params,frags = lineIntersection(lineArray)\n    vertDict = dict()\n    index,defaultValue,V,EV = -1,-1,[],[]\n    \n    for k,(p1,p2) in enumerate(frags):\n        outline = [vcode(4)(p1)]\n        if params[k] != []:\n            for alpha in params[k]:\n                if alpha != 0.0 and alpha != 1.0:\n                    p = list(array(p1)+alpha*(array(p2)-array(p1)))\n                    outline += [vcode(4)(p)]\n        outline += [vcode(4)(p2)]\n    \n        edge = []\n        for key in outline:\n            if vertDict.get(key,defaultValue) == defaultValue:\n                index += 1\n                vertDict[key] = index\n                edge += [index]\n                V += [eval(key)]\n            else:\n                edge += [vertDict[key]]\n            EV.extend([[edge[k],edge[k+1]] for k,v in enumerate(edge[:-1])])\n    \n    model = (V,EV)\n    if normalize == True:\n         model = larModelNormalization(model)\n    return larSimplify(model)\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\subsection{Biconnected components of a 1-complex}\n%===============================================================================\n\nAn implementation of the Hopcroft-Tarjan algorithm~\\cite{Hopcroft:1973:AEA:362248.362272} for computation of the biconnected components of a graph is given here.\n\n\n\n\\paragraph{Biconnected components}\n%-------------------------------------------------------------------------------\n@D Biconnected components\n@{\"\"\" Biconnected components \"\"\"\n@< Adjacency lists of 1-complex vertices @>\n@< Main procedure for biconnected components @>\n@< Hopcroft-Tarjan algorithm @>\n@< Output of biconnected components @>\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Adjacency lists of 1-complex vertices}\n%-------------------------------------------------------------------------------\n@D Adjacency lists of 1-complex vertices\n@{\"\"\" Adjacency lists of 1-complex vertices \"\"\"\nimport larcc \ndef vertices2vertices(model):\n    V,EV = model\n    csrEV = larcc.csrCreate(EV)\n    csrVE = larcc.csrTranspose(csrEV)\n    csrVV = larcc.matrixProduct(csrVE,csrEV)    \n    cooVV = csrVV.tocoo()\n    data,rows,cols = AA(list)([cooVV.data, cooVV.row, cooVV.col])\n    triples = zip(data,rows,cols)\n    VV = [[] for k in range(len(V))]\n    for datum,row,col in triples:\n        if row != col: VV[col] += [row]\n    return AA(sorted)(VV)\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Main procedure for biconnected components}\n%-------------------------------------------------------------------------------\n@D Main procedure for biconnected components\n@{\"\"\" Main procedure for biconnected components \"\"\"\ndef biconnectedComponent(model):\n    W,_ = model\n    V = range(len(W))\n    count = 0\n    stack,out = [],[]\n    visited = [None for v in V]\n    parent = [None for v in V]\n    d = [None for v in V]\n    low = [None for v in V]\n    for u in V: visited[u] = False\n    for u in V: parent[u] = []\n    VV = vertices2vertices(model)\n    for u in V: \n        if not visited[u]: \n            DFV_visit( VV,out,count,visited,parent,d,low,stack, u )\n    return W,[component for component in out if len(component) > 1]\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Hopcroft-Tarjan algorithm}\n%-------------------------------------------------------------------------------\n@D Hopcroft-Tarjan algorithm\n@{\"\"\" Hopcroft-Tarjan algorithm \"\"\"\ndef DFV_visit( VV,out,count,visited,parent,d,low,stack,u ):\n    visited[u] = True\n    count += 1\n    d[u] = count\n    low[u] = d[u]\n    for v in VV[u]:\n        if not visited[v]:\n            stack += [(u,v)]\n            parent[v] = u\n            DFV_visit( VV,out,count,visited,parent,d,low,stack, v )\n            if low[v] >= d[u]:\n                out += [outputComp(stack,u,v)]\n            low[u] = min( low[u], low[v] )\n        else:\n            if not (parent[u]==v) and (d[v] < d[u]):\n                stack += [(u,v)]\n                low[u] = min( low[u], d[v] )\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Output of biconnected components}\n%-------------------------------------------------------------------------------\n@D Output of biconnected components\n@{\"\"\" Output of biconnected components \"\"\"\ndef outputComp(stack,u,v):\n    out = []\n    while True:\n        e = stack.pop()\n        out += [list(e)]\n        if e == (u,v): break\n    return list(set(AA(tuple)(AA(sorted)(out))))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/biconnected1} \n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/biconnected2} \n\n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/biconnected3} \n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/biconnected4} \n   \\caption{Two random line arrangements, and the biconnected components extracted by their LAR 1-complexes.}\n   \\label{fig:biconnected}\n\\end{figure}\n\n\n\\subsection{2D cells from biconnected components}\n%===============================================================================\n\nIt is very easy,  using the LAR representation of topology, to compute the 2-cells of the plane partitions~(see Figures~\\ref{fig:biconnected}b and~\\ref{fig:biconnected}c) induced by the biconnected components extracted from a graph (1-complex).\n\nIn particular, let us consider the CSR (Compressed Sparse Row) representation of the characteristic matrix $M_1$, here usually denoted as \\texttt{EV}, in order to remark that we represent the edges on the rows, and the vertices on the columns of the matrix. As such it is a binary matrix. So, we can readily reconstruct the topology of 2-cells by associating to each non-zero (sparse) matrix element $\\texttt{angle\\_EV}(h,k)$ the angle in radians that the edge $e_h$ forms with the orizontal line, when it incides on the vertex $v_k$. \n\nOf course, if $e_h = (v_{k_1},v_{k_2})$, then it will be \n\\[\n\\texttt{angle\\_EV}(h,k_2) = \\texttt{angle\\_EV}(h,k_1)+\\pi = -\\texttt{angle\\_EV}(h,k_1)\n\\]\n\nTherefore, the columns of $\\texttt{angle\\_EV}$, i.e.~the rows of $\\texttt{angle\\_VE} := \\texttt{angle\\_EV}^t$,\nafter being sorted on their angles $\\alpha$, and associated with the angle differences $\\Delta\\alpha$, will provide a basis of elementary $1-cochains$ that evaluate to zero for each closed 1-cochain, i.e. for every cycle supported by the linear space of 1-chains on the given line arrangment.\n\n\n\\paragraph{Slope of edges}\n\n\\paragraph{Circular ordering of edges around vertices}\n%-------------------------------------------------------------------------------\n@D Slope of edges\n@{\"\"\" Circular ordering of edges around vertices \"\"\"\nfrom larcc import *\n\ndef edgeSlopeOrdering(model):\n    V,EV = model\n    VE,VE_angle = larcc.invertRelation(EV),[]\n    for v,ve in enumerate(VE):\n        ve_angle = []\n        if ve != []:\n            for edge in ve:\n                v0,v1 = EV[edge]\n                if v == v0:     x,y = list(array(V[v1]) - array(V[v0]))\n                elif v == v1:    x,y = list(array(V[v0]) - array(V[v1]))\n                angle = math.atan2(y,x)\n                ve_angle += [180*angle/PI]\n        pairs = sorted(zip(ve_angle,ve))\n        #VE_angle += [TRANS(pairs)[1]]\n        VE_angle += [[pair[1] for pair in pairs]]\n    return VE_angle\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Ordered incidence relationship vertices to edges}\n\nAs we have seen, the \\texttt{VE\\_angle} list of lists reports, for every vertex in \\texttt{V}, the list of incident edges, \\emph{counterclockwise ordered} around the vertex. Therefore the \\texttt{ordered\\_csrVE} function, given below, returns the ``compressed sparse row'' matrix, row-indexed by vertices and column-indexed by edges, and such that in position $(v,e)$ contains the index $\\ell$ of the next edge (after $e$, say) in the counterclockwise ordering of edges around $v$.\n\n%-------------------------------------------------------------------------------\n@D Ordered incidence relationship of vertices and edges\n@{\"\"\" Ordered incidence relationship of vertices and edges \"\"\"\ndef ordered_csrVE(VE_angle):\n    triples = []\n    for v,ve in enumerate(VE_angle):\n        n = len(ve)\n        for k,edge in enumerate(ve):\n            triples += [[v, ve[k], ve[ (k+1)%n ]]]\n    csrVE = triples2mat(triples,shape=\"csr\")\n    return csrVE\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Faces from biconnected components}\nSince edges in the plane partition induced by a line arrangement are $(d-1)$-cells, they are located on the boundary of \\emph{two} $d$-cells (faces) of the partition. Hence, the traversal algorithm of the data structure storing the relevant information may be driven by signing the two extremes (vertices) of each edge as either already visited or not.\n\n\n%-------------------------------------------------------------------------------\n@D Faces from biconnected components\n@{\"\"\" Faces from biconnected components \"\"\"\n\ndef firstSearch(visited):\n    for edge,vertices in enumerate(visited):\n        for v,vertex in enumerate(vertices):\n            if visited[edge,v] == 0.0:\n                visited[edge,v] = 1.0\n                return edge,v\n    return -1,-1\n\ndef facesFromComps(model):\n    V,EV = model\n    # Remove zero edges\n    EV = list(set([ tuple(sorted([v1,v2])) for v1,v2 in EV if v1!=v2 ]))\n    FV = []\n    VE_angle = edgeSlopeOrdering((V,EV))\n    csrEV = ordered_csrVE(VE_angle).T\n    visited = zeros((len(EV),2))\n    edge,v = firstSearch(visited)\n    vertex = EV[edge][v]\n    fv = []\n    while True:\n        if (edge,v) == (-1,-1):\n            break #return [face for face in FV if face != None]\n        elif (fv == []) or (fv[0] != vertex):\n            \n            fv += [vertex]\n            nextEdge = csrEV[edge,vertex]\n            v0,v1 = EV[nextEdge]\n            \n            try:\n                vertex, = set([v0,v1]).difference([vertex])\n            except ValueError:\n                print 'ValueError: too many values to unpack'\n                break\n                \n            if v0==vertex: pos=0\n            elif v1==vertex: pos=1\n                        \n            if visited[nextEdge, pos] == 0:\n                visited[nextEdge, pos] = 1\n                edge = nextEdge                \n        else:\n            FV += [fv]\n            fv = []\n            edge,v = firstSearch(visited)\n            vertex = EV[edge][v]\n        FV = [face for face in FV if face != None]\n    return V,FV,EV\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Txample}\nThe \\emph{ordered} \\texttt{csrVE} (vertex-edge) matrix generated by the example of file \\texttt{test/py/inters/test07.py} is shown in dense format in the example script below.\nLet us notice the each non-zero element $\\texttt{csrVE}(k,h)$ stores the index of the previous edge \ninciding on the vertex $v_k$ \\emph{before} the edge $e_h$. The traversal of the data structure is made accordingly, in order to extract the vertices of all the faces (minimal edge cycles) generated by a line arrangement in the plane.\n\n%-------------------------------------------------------------------------------\n@D Example of VE matrix with nextEdge indices @{\ncsr2DenseMatrix(csrVE)\n>>> array([\n    [12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11,  0,  0,  0], \n    [ 1,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0], \n    [ 0, 14,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0], \n    [ 0,  0,  6,  5,  0,  2,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0], \n    [ 0,  0,  0, 10,  0,  0,  0,  0,  0,  3,  9,  0,  0,  0,  0,  0], \n    [ 0,  0,  0,  0, 15,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  4], \n    [ 0,  0,  0,  0, 12,  4,  0,  0,  0,  0,  0,  0,  5,  0,  0,  0], \n    [ 0,  0,  0,  0,  0,  0,  7,  8,  6,  0,  0,  0,  0,  0,  0,  0], \n    [ 0,  0,  0,  0,  0,  0,  0,  7,  0,  0,  0,  0,  0,  0,  0,  0], \n    [ 0,  0,  0,  0,  0,  0,  0,  0, 10,  0,  8,  0,  0,  0,  0,  0], \n    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  9,  0,  0,  0,  0,  0,  0], \n    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 13,  0, 14, 11,  0], \n    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 15,  0, 13]])\n@}\n%-------------------------------------------------------------------------------\n\n\n\\subsection{Transformation of an array of lines in a 2D LAR complex}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\paragraph{Transformation of an array of lines in a 2D LAR complex}\n\nThe whole transformation of an array of lines into a two-dimensional \\texttt{LAR} complex is executed by the function \\texttt{larFromLines}. The function returns the model triple \\texttt{V,FV,EV}. The last element in \\texttt{FV} is the \\emph{ordered} boundary chain. just notice that \n\n%    import networkx as nx\n%    G=nx.Graph()\n%    G.add_nodes_from(range(len(V)))\n%    G.add_edges_from(EV)\n%    g = [subgraph.edges() for subgraph in nx.biconnected_component_subgraphs(G, copy=True)\n%            if len(subgraph.edges())>1]\n\n%-------------------------------------------------------------------------------\n@D Transformation of an array of lines in a 2D LAR complex @{\n\"\"\" Transformation of an array of lines in a 2D LAR complex \"\"\"\ndef larFromLines(lines,normalize=False):\n    def larPairSimplify((V,EV)):\n        V,EVs = biconnectedComponent((V,EV))\n        EV = CAT(EVs)\n        V,EV = larRemoveVertices(V,EV)\n        return V,EV\n    \n    V,EV = lines2lar(lines,normalize)\n    V,EV = larPairSimplify((V,EV))  #TODO:  toggle to check the generated FV\n    V,polygons,EV = larPair2Triple((V,EV))\n    FV = AA(list)(AA(set)(AA(CAT)(polygons)))\n    return V,FV,EV,polygons\n\"\"\"\ndef normalize(lines):\n\tvs = CAT(lines)\n\txs,ys = TRANS(vs)\n\tw0,w1,w2,w3 = [min(xs), min(ys), max(xs), max(ys)]\n\t# viewport aspect-ratio checking, setting a computed-viewport 'v'\n\tar = (w2-w0)/(w3-w1)\n\tif ar >1 : v0,v1,v2,v3 = 0,0,1,1./ar\n\telse: v0,v1,v2,v3 = 0,0,ar,1\n\ta,b,c,d = v2*w0, v3*w1, w2-w0, w3-w1\n\tM = mat(\n\t[[\tv2/c,\t0,\t0 ],\n\t [\t0,\t v3/d,\t0 ],\n\t [\t-a/c,-b/d,\t1 ]])\n\tws = [[x,y,1] for x,y in vs]\n\tW = (array(ws) * M)[:,:2].tolist()\n\tmyLines = [[W[2*k],W[2*k+1]] for k in range(len(W)/2)]\n\treturn myLines, M\n\t\ndef larFromLines(lines,normal=False):\n    def larPairSimplify((V,EV)):\n        V,EVs = biconnectedComponent((V,EV))\n        EV = CAT(EVs)\n        V,EV = larRemoveVertices(V,EV)\n        return V,EV\n    \n    theLines,M = normalize(lines)\n    V,EV = lines2lar(theLines,False)\n    V,EV = larPairSimplify((V,EV))  #TODO:  toggle to check the generated FV\n    V,polygons,EV = larPair2Triple((V,EV))\n    FV = AA(list)(AA(set)(AA(CAT)(polygons)))\n    if not normal:\n    \tW = (array([v+[1.0] for v in V]) * M.I)[:,:2].tolist()\n    else: W = V\n    return W,FV,EV,polygons\n\"\"\"\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\subsection{Pruning LAR models from parts out of proper resolution}\n%===============================================================================\n\nPruning of clusters of too close vertices is executed by taking a LAR model as input, \nexecuting the following computations, and producing a new simplified LAR model.\n\n\\paragraph{Pruning away clusters of close vertices}\nFirst, reduce the array of vertices \\texttt{pts} to its \\emph{quotient set} with respect to the transitive closure of the relation of ``nearness''. Two vertices are ``near'' when their (Euclidean) distance is less than a given \\texttt{RADIUS}. The subgraphs of the graph of this relation are \\emph{contracted} in a single point, set to the centroid of the vertices of the subgraph. The function \\texttt{W} takes as input the array \\texttt{pts} of vertex points, and returns: (a) the array \\texttt{newV} of new vertices; (b) the list of lists \\texttt{close} of sorted indices of pairs of close vertices, removed from duplicates; (c) the list of \\texttt{clusters} of \\texttt{pts} indices; (d) the integer  \\texttt{vmap} array, mapping old vertex indices to new vertex indices.\n\n%-------------------------------------------------------------------------------\n@D Pruning away clusters of close vertices\n@{\"\"\" Pruning away clusters of close vertices \"\"\"\nfrom scipy.spatial import cKDTree\n\ndef pruneVertices(pts,radius=0.001):\n    tree = cKDTree(pts)\n    a = cKDTree.sparse_distance_matrix(tree,tree,radius)\n    #print a.keys()\n    close = list(set(AA(tuple)(AA(sorted)(a.keys()))))\n    import networkx as nx\n    G=nx.Graph()\n    G.add_nodes_from(range(len(pts)))\n    G.add_edges_from(close)\n    clusters, k, h = [], 0, 0\n    \n    subgraphs = list(nx.connected_component_subgraphs(G))\n    V = [None for subgraph in subgraphs]\n    vmap = [None for k in xrange(len(pts))]\n    for k,subgraph in enumerate(subgraphs):\n        #group = subgraph.nodes()\n        group = list(subgraph.nodes())\n        if len(group)>1: \n            V[k] = CCOMB([pts[v] for v in group])\n            for v in group: vmap[v] = k\n            clusters += [group]\n        else: \n            oldNode = group[0]\n            V[k] = pts[oldNode]\n            vmap[oldNode] = k\n    return V,close,clusters,vmap\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Export a simplified LAR model}\nNext, update the arrays of compressed characteristic matrices of a Linear Algebraic Representation. The standard approach is to read row-wise the arrays of matrices of incidence of cells on vertices; translate every index using the \\texttt{vmap} array, mapping old vertex indices to new ones; remove repeated indices and substitute them with a single instance; check if the new index list has lenght greater or equal to the number of vertices of the simplex of the proper dimension. Finally, write an output cell if and only if the previous test is true.\n\n%-------------------------------------------------------------------------------\n@D Return a simplified LAR model\n@{\"\"\" Return a simplified LAR model \"\"\"\ndef larSimplify(model,radius=0.001):\n    if len(model)==2: V,CV = model \n    elif len(model)==3: V,CV,FV = model \n    else: print \"ERROR: model input\"\n    \n    W,close,clusters,vmap = pruneVertices(V,radius)\n    celldim = DIM(MKPOL([V,[[v+1 for v in CV[0]]],None]))\n    newCV = [list(set([vmap[v] for v in cell])) for cell in CV]\n    CV = list(set([tuple(sorted(cell)) for cell in newCV if len(cell) >= celldim+1]))\n    CV = sorted(CV,key=len) # to get the boundary cell as last one (in most cases)\n\n    if len(model)==3:\n        celldim = DIM(MKPOL([V,[[v+1 for v in FV[0]]],None]))\n        newFV = [list(set([vmap[v] for v in facet])) for facet in FV]\n        FV = [facet for facet in newFV if len(facet) >= celldim]\n        FV = list(set(AA(tuple)(AA(sorted)(FV))))\n        areas = integr.signedSurfIntegration((V,CV,FV),signed=False)\n        CV = [CV[k] for k in range(len(CV)) if not isclose(areas[k],0.0)]\n        return W,CV,FV\n    else: return W,CV\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Test of pruning clusters of close vertices}\nHere a list of random 2D points is generated. Then the set of vertices is pruned by updating it to its quotient set with respect to the transitive closure of a relation of ``nearness'' within an Euclidean distance of given \\texttt{RADIUS}. The pruning of vertices is performed by the \\texttt{pruneVertices} function, with input the array \\texttt{pts} of points. The dictionary \\texttt{vmap}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test13.py\n@{\"\"\" Test of pruning clusters of close vertices \"\"\"\nfrom larlib import *\nfrom scipy import rand\nfrom scipy.spatial import cKDTree\nPOINTS = 1000\nRADIUS = 0.01\n\npts = [rand(2).tolist() for k in range(POINTS)]\nVIEW(STRUCT(AA(MK)(pts)))\nV,close,clusters,vmap = pruneVertices(pts,RADIUS)\ncircles = [T([1,2])(pts[h])(CIRCUMFERENCE(RADIUS)(18)) for h,k in close]\nconvexes = [JOIN(AA(MK)([pts[v] for v in cluster])) for cluster in clusters]\nW = COLOR(CYAN)(STRUCT(AA(MK)(V)))\nVIEW(STRUCT(AA(MK)(pts)+AA(COLOR(YELLOW))(circles)))\nVIEW(STRUCT(AA(COLOR(RED))(convexes)+AA(MK)(pts)+AA(COLOR(YELLOW))(circles)+[W]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Test for exporting a simplified LAR model}\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test14.py\n@{\"\"\" Test for exporting a simplified LAR model \"\"\"\nfrom larlib import *\nfilename = \"test/svg/inters/closepoints.svg\"\nlines = svg2lines(filename)\n\nV,EV = lines2lar(lines)\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,EV))))\npts = V\nRADIUS = 0.05\nV,close,clusters,vmap = pruneVertices(pts,RADIUS)\ncircles = [T([1,2])(pts[h])(CIRCUMFERENCE(RADIUS)(18)) for h,k in close]\nconvexes = [JOIN(AA(MK)([pts[v] for v in cluster])) for cluster in clusters]\nW = COLOR(CYAN)(STRUCT(AA(MK)(V)))\nVIEW(STRUCT(AA(COLOR(RED))(convexes)+AA(MK)(pts)+AA(COLOR(YELLOW))(circles)+[W]))\n\nV,FV,EV,polygons = larFromLines(lines)\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,FV+EV)) + AA(MK)(V)))\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,0.5))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test15.py\n@{\"\"\" Testing containments between non intersecting cycles \"\"\"\nfrom larlib import *\n\nfilename = \"test/svg/inters/facade.svg\"\nlines = svg2lines(filename)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n\nV,EV = lines2lar(lines)\nV,EVs = biconnectedComponent((V,EV))\n# candidate face\nFVs = AA(COMP([list,set,CAT]))(EVs)\n\nlatticeArray = computeCycleLattice(V,EVs)\n\nfor k in range(len(latticeArray)):\n    print k,latticeArray[k]\n\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FVs],submodel,0.15)) \n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test16.py\n@{\"\"\" Generating the LAR of a set of non-intersecting cycles \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/inters/')\nfrom test15 import *\n\ncells = cellsFromCycles(latticeArray)\nCV = AA(COMP([list,set,CAT]))(EVs)\nEVdict = dict(zip(EV,range(len(EV))))\nFE = [[EVdict[edge] for edge in cycle] for cycle in EVs] \nedges = [CAT([FE[cycle] for cycle in cell]) for cell in cells]\nFVs = [[CV[cycle] for cycle in cell] for cell in cells]\nFV = AA(CAT)(FVs)\n\nn = len(cells)\nchains = allBinarySubsetsOfLenght(n)\n\ncycles = STRUCT(MKPOLS((V,EV)))\ncsrBoundaryMat = larBoundary(FV,EV)\nfor chain in chains:\n    chainBoundary = COLOR(RED)(STRUCT(MKPOLS((V,[EV[e] \n                        for e in chain2BoundaryChain(csrBoundaryMat)(chain)]))))\n    VIEW(STRUCT([cycles, chainBoundary]))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test17.py\n@{\"\"\" Generating the LAR of a set of non-intersecting cycles \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/inters/')\nfrom test16 import *\n\nlar = (V,FV,EV)\n\nbcycles,_ = boundaryCycles(range(len(EV)),EV)\npolylines = [[V[EV[e][1]] if e>0 else V[EV[-e][0]] for e in cycle ] for cycle in bcycles]\npolygons = [polyline + [polyline[0]] for polyline in polylines]\n\ncomplex = SOLIDIFY(STRUCT(AA(POLYLINE)(polygons)))\ncsrBoundaryMat = larBoundary(FV,EV)\nfor chain in chains:\n    chainBoundary = COLOR(RED)(STRUCT(MKPOLS((V,[EV[e] \n                        for e in chain2BoundaryChain(csrBoundaryMat)(chain)]))))\n    VIEW(STRUCT([complex, chainBoundary]))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test18.py\n@{\"\"\" Orienting a set of non-intersecting cycles \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/inters/')\nfrom test17 import *\n\ncells,bridgeEdges = connectTheDots((V,EV))\nCVs = orientBoundaryCycles((V,EV),cells)\n\nprint \"\\nCVs =\",CVs\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test19.py\n@{\"\"\" Generating the LAR of a set of non-intersecting cycles \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/inters/')\nfrom test17 import *\n\nW,EW = boundaryCycles2vertexPermutation( (V,EV) )\nVIEW(EXPLODE(1.2,1.2,1.2)(MKPOLS((W,EW))))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test20.py\n@{\"\"\" Generating the Triangulation of a set of non-intersecting cycles \"\"\"\nfrom larlib import *\n\nsys.path.insert(0, 'test/py/inters/')\nfrom test17 import *\n\ntriangleSet = larTriangulation( (V,EV) )\n\nVIEW(STRUCT(AA(JOIN)(AA(AA(MK))(CAT(triangleSet)))))\nVIEW(SKEL_1(STRUCT(AA(JOIN)(AA(AA(MK))(CAT(triangleSet))))))\n\nmodel = V,EV\nW,FW = lar2boundaryPolygons(model)\npolygons = [[W[u] for u in poly] for poly in FW]\nVIEW(STRUCT(AA(POLYLINE)(polygons)))\n\ntriangleSet,triangledFace = [],[]\nfor polygon in polygons:  \n    triangledPolygon = []\n    polyline = []\n    for p in polygon:\n        polyline.append(Point(p[0],p[1]))\n    cdt = CDT(polyline)\n\n    triangles = cdt.triangulate()\n    trias = [ [[t.a.x,t.a.y,0],[t.c.x,t.c.y,0],[t.b.x,t.b.y,0]] for t in triangles ]\n    triangleSet += [AA(REVERSE)(trias)]\n@}\n%-------------------------------------------------------------------------------\n\n%===============================================================================\n\\section{Exporting the module}\n%===============================================================================\n\n%-------------------------------------------------------------------------------\n@O larlib/larlib/inters.py\n@{\"\"\" Module for pipelined intersection of geometric objects \"\"\"\nfrom larlib import *\nfrom triangulation import *\nfrom scipy import mat\n\n@< Coding utilities @>\n@< Generation of random lines @>\n@< Containment boxes @>\n@< Splitting the input above and below a threshold @>\n@< Iterative splitting of box buckets @>\n@< Intersection of two line segments @>\n@< Brute force bucket intersection @>\n@< Accelerate intersection of lines @>\n@< Create the LAR of fragmented lines @>\n@< Biconnected components @>\n@< Slope of edges @>\n@< Ordered incidence relationship of vertices and edges @>\n@< Faces from biconnected components @>\n@< SVG input parsing and transformation @>\n@< Simplified SVG parsing and normalization @>\n@< LAR 2D model normalization @>\n@< Transformation of an array of lines in a 2D LAR complex @>\n@< Pruning away clusters of close vertices @>\n@< Return a simplified LAR model @>\n@}\n%-------------------------------------------------------------------------------\n\n\n%===============================================================================\n\\section{Examples}\n%===============================================================================\n\n\n\n\n\\paragraph{Generation of random line segments and their boxes}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test01.py\n@{\"\"\" Generation of random line segments and their boxes \"\"\"\nfrom larlib import *\n\nrandomLineArray = randomLines(200,0.3)\nVIEW(STRUCT(AA(POLYLINE)(randomLineArray)))\n\nboxes = containment2DBoxes(randomLineArray)\nrects= AA(box2rect)(boxes)\ncyan = COLOR(CYAN)(STRUCT(AA(POLYLINE)(randomLineArray)))\nyellow = COLOR(YELLOW)(STRUCT(AA(POLYLINE)(rects)))\nVIEW(STRUCT([cyan,yellow]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Split segment array in four independent buckets}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test02.py\n@{\"\"\" Split segment array in four independent buckets \"\"\"\nfrom larlib import *\n\nrandomLineArray = randomLines(200,0.3)\nVIEW(STRUCT(AA(POLYLINE)(randomLineArray)))\nboxes = containment2DBoxes(randomLineArray)\nbucket = range(len(boxes))\nbelow,above = splitOnThreshold(boxes,bucket,1)\nbelow1,above1 = splitOnThreshold(boxes,above,2)\nbelow2,above2 = splitOnThreshold(boxes,below,2)\n\ncyan = COLOR(CYAN)(STRUCT(AA(POLYLINE)(randomLineArray[k] for k in below1)))\nyellow = COLOR(YELLOW)(STRUCT(AA(POLYLINE)(randomLineArray[k] for k in above1)))\nred = COLOR(RED)(STRUCT(AA(POLYLINE)(randomLineArray[k] for k in below2)))\ngreen = COLOR(GREEN)(STRUCT(AA(POLYLINE)(randomLineArray[k] for k in above2)))\n\nVIEW(STRUCT([cyan,yellow,red,green]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\paragraph{Generation and random coloring of independent line buckets}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test03.py\n@{\"\"\" Generation and random coloring of independent line buckets \"\"\"\nfrom larlib import *\n\nlines = randomLines(200,0.3)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n\nboxes = containment2DBoxes(lines)\nbuckets = boxBuckets(boxes)\n\ncolors = [CYAN, MAGENTA, WHITE, RED, YELLOW, GRAY, GREEN, ORANGE, BLACK, BLUE, PURPLE, BROWN]\nsets = [COLOR(colors[k%12])(STRUCT(AA(POLYLINE)([lines[h] \n            for h in bucket]))) for k,bucket in enumerate(buckets) if bucket!=[]]\n\nVIEW(STRUCT(sets))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Construction of \\texttt{LAR = (V,EV)} of random line arrangement}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test04.py\n@{\"\"\" LAR of random line arrangement \"\"\"\nfrom larlib import *\n\nlines = randomLines(30,0.2)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n\nintersectionPoints,params,frags = lineIntersection(lines)\n\nmarker = CIRCLE(.005)([4,1])\nmarkers = STRUCT(CONS(AA(T([1,2]))(intersectionPoints))(marker))\nVIEW(STRUCT(AA(POLYLINE)(lines)+[COLOR(RED)(markers)]))\n\nV,EV = lines2lar(lines)\nmarker = CIRCLE(.01)([4,1])\nmarkers = STRUCT(CONS(AA(T([1,2]))(V))(marker))\n#markers = STRUCT(CONS(AA(T([1,2]))(intersectionPoints))(marker))\npolylines = STRUCT(MKPOLS((V,EV)))\nVIEW(STRUCT([polylines]+[COLOR(MAGENTA)(markers)]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Splitting of othogonal lines}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test05.py\n@{\"\"\" LAR from splitting of othogonal lines \"\"\"\nfrom larlib import *\n@< Orthogonal example @>\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@D Orthogonal example @{\nlines = [[[0,0],[6,0]], [[0,4],[10,4]], [[0,0],[0,4]], [[3,0],[3,4]], \n[[6,0],[6, 8]], [[3,2],[6,2]], [[10,0],[10,8]], [[0,8],[10,8]]]\n\nVIEW(EXPLODE(1.2,1.2,1)(AA(POLYLINE)(lines)))\n\nV,EV = lines2lar(lines)\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,EV))))\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.25\\linewidth,width=0.325\\linewidth]{images/ortho1} \n   \\includegraphics[height=0.25\\linewidth,width=0.325\\linewidth]{images/ortho2} \n   \\includegraphics[height=0.25\\linewidth,width=0.325\\linewidth]{images/ortho3} \n   \\caption{Splitting of orthogonal lines: (a) exploded input; (a) exploded output; (c) biconnected components.}\n   \\label{fig:ortho}\n\\end{figure}\n\n\n\n\\paragraph{Random coloring of the generated 1-complex LAR}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test06.py\n@{\"\"\" Random coloring of the generated 1-complex \"\"\"\nfrom larlib import *\n\nlines = randomLines(800,0.2)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n\nV,EV = lines2lar(lines)\ncolors = [CYAN, MAGENTA, WHITE, RED, YELLOW, GRAY, GREEN, ORANGE, BLACK, BLUE, PURPLE, BROWN]\nsets = [COLOR(colors[k%12])(POLYLINE([V[e[0]],V[e[1]]])) for k,e in enumerate(EV)]\n\nVIEW(STRUCT(sets))\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.49\\linewidth]{images/colored1} \n   \\includegraphics[width=0.49\\linewidth]{images/colored2} \n   \\caption{Splitting of intersecting lines: (a) random input; (a) splitted and colored LAR output.}\n   \\label{fig:ortho}\n\\end{figure}\n\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/lineintersect1} \n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/lineintersect2} \n   \\caption{The intersection of 5000 random lines in the unit interval, with \\texttt{scaling} parameter equal to \\texttt{0.1}}\n   \\label{fig:example}\n\\end{figure}\n\n\n    \n\n\\paragraph{Biconnected components from orthogonal LAR model}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test07.py\n@{\"\"\" Biconnected components from orthogonal LAR model \"\"\"\nfrom larlib import *\ncolors = [CYAN, MAGENTA, WHITE, RED, YELLOW, GREEN, ORANGE, BLACK, BLUE, PURPLE]\n\n@< Orthogonal example @>\nmodel = V,EV\nV,EVs = biconnectedComponent(model)\nHPCs = [STRUCT(MKPOLS((V,EV))) for EV in EVs]\n\nsets = [COLOR(colors[k%10])(hpc) for k,hpc in enumerate(HPCs)]\nVIEW(STRUCT(sets))\nVIEW(STRUCT(MKPOLS((V,CAT(EVs)))))\n\n#V,EV = larRemoveVertices(V,CAT(EVs))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{2-complex from orthogonal line segments}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test08.py\n@{\"\"\" 2-complex from orthogonal line segments \"\"\"\nfrom larlib import *\ncolors = [CYAN, MAGENTA, WHITE, RED, YELLOW, GREEN, ORANGE, BLACK, BLUE, PURPLE]\n\n@< Orthogonal example @>\nmodel = V,EV\nV,EVs = biconnectedComponent(model)\nHPCs = [STRUCT(MKPOLS((V,EV))) for EV in EVs]\n\nsets = [COLOR(colors[k%10])(hpc) for k,hpc in enumerate(HPCs)]\nVIEW(STRUCT(sets))\n\nEV = sorted(CAT(EVs))\nVIEW(STRUCT(MKPOLS((V,EV))))\n\nV,FV,EV = facesFromComps((V,EV))\n\nareas = surfIntegration((V,FV,EV))\nboundaryArea = max(areas)\nFV = [FV[f] for f,area in enumerate(areas) if area!=boundaryArea]\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,FV+EV)) + AA(MK)(V)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d0} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d1} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d2} \n\n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d3} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d4} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/random2d5} \n   \\caption{\\texttt{LAR} complex generation random lines. (a) the input random lines; (b) maximal biconnected graph extracted from the 1D LAR of intersected lines; (c) 2D cells of such \\emph{regularized} 2-complex; (d) 2-cells, drawn exploded; (e) boundaries of 2D cells; (f) regularized cellular 2-complex extracted from lines.}\n   \\label{fig:ortho}\n\\end{figure}\n\n\\paragraph{Biconnected components from random LAR model}\n%-------------------------------------------------------------------------------\n@O test/py/inters/test09.py\n@{\"\"\" Biconnected components from orthogonal LAR model \"\"\"\nfrom larlib import *\ncolors = [CYAN, MAGENTA, YELLOW, RED, GREEN, ORANGE, PURPLE, WHITE, BLACK, BLUE]\n\nlines = randomLines(100,.8)\nV,EV = lines2lar(lines)\nmodel = V,EV\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n\nV,EVs = biconnectedComponent(model)\nHPCs = [STRUCT(MKPOLS((V,EV))) for EV in EVs]\nsets = [COLOR(colors[k%10])(hpc) for k,hpc in enumerate(HPCs)]\nVIEW(STRUCT(sets))\n\nEV = CAT(EVs)\nV,EV = larRemoveVertices(V,EV)\nV,FV,EV = facesFromComps((V,EV))\nareas = surfIntegration((V,FV,EV))\nboundaryArea = max(areas)\nFV = [FV[f] for f,area in enumerate(areas) if area!=boundaryArea]\n\npolylines = [[V[v] for v in face+[face[0]]] for face in FV]\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,EV)) + AA(MK)(V) + AA(FAN)(polylines) ))\n\ncolors = [CYAN, MAGENTA, WHITE, RED, YELLOW, GRAY, GREEN, ORANGE, BLACK, BLUE, PURPLE, BROWN]\nsets = [COLOR(colors[k%12])(FAN(pol)) for k,pol in enumerate(polylines)]\nVIEW(STRUCT(sets))\n\n\nVIEW(EXPLODE(1.2,1.2,1)((AA(FAN)(polylines))))\nVIEW(EXPLODE(1.2,1.2,1)((AA(POLYLINE)(polylines))))\n\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV],submodel,0.1))\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/illustrator1} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/illustrator2} \n   \\includegraphics[height=0.325\\linewidth,width=0.325\\linewidth]{images/illustrator3} \n   \\caption{\\texttt{LAR} complex generation from \\texttt{SVG} file. (a) the input set of lines; (b) imported in \\texttt{pyplasm} environment; (c) the extracted \\emph{regularized} 2-complex, drawn exploded.}\n   \\label{fig:ortho}\n\\end{figure}\n\n\\paragraph{Simplified SVG parsing and normalization}\nThe easiest method for the input of SVG primitives, to be transformed into a \\emph{line soup}, in order to subsiquently generate a 2D cellular complex, mainly oriented to sudent use, is to drag a SVG file into the input window of the web service \\href{ http://cvdlab.github.io/svg2lines}{ http://cvdlab.github.io/svg2lines}.\nThe file is transformed into quadruples of comma-separated numbers, each corresponding to the pair of extreme point coordinates of a line.\nThis text may be saved into a text file, possibly decorated with the suffix \\texttt{.lines}, to be read and normalized into the coordinate space $[0,1] \\times [0,1]$ by the following function \\texttt{lines2lines}, and then used by other \n\\texttt{larlib} functions (for example, by \\texttt{lines2lar} (see \\texttt{test/py/inters/test10.py}).\n\n%-------------------------------------------------------------------------------\n@D Simplified SVG parsing and normalization\n@{\"\"\" Simplified SVG parsing and normalization \"\"\"\ndef lines2lines(filename):\n    stringLines = [line.strip() for line in open(filename)]\n    lines = [AA(eval)(string.split(',')) for string in stringLines]\n    lines = [[[x1,-y1],[x2,-y2]] for x1,y1,x2,y2 in lines]  # overturning y axis\n    def stretch(line):\n        c = CCOMB(line)\n        L = mat(line)\n        return (((L-c)*1.001)+c).tolist()\n    lines  = [stretch(line) for line in lines]\n        \n    #< SVG input normalization transformation #>    \n    \n    #V,EV = lines2lar(lines,normalize=True)\n    #lines = [[ eval(vcode(5)(V[u])), eval(vcode(5)(V[v])) ] for u,v in EV]\n    return lines\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{SVG input parsing and transformation}\n\nWe postulate here that the input file \\texttt{test/py/inters/test.svg} should contain only \\texttt{<line>} primitives, so we skip any other content. Such primitives are parsed by matching against regular expressions, and their \\texttt{x1,y1,x2,y2} attributes are extracted and stored into the \\texttt{lines} variable.\nAn isomorphic window-viewport transformation is then performed, to transform the data within the standard unit 2D square $[0,1]^2$.\nThe input vertices are finally set to a fixed resolution, using the \\texttt{vcode(4)} function. \n\n%-------------------------------------------------------------------------------\n@D SVG input parsing and transformation\n@{\"\"\" SVG input parsing and transformation \"\"\"\nfrom larlib import *\nimport re # regular expression\n\ndef svg2lines(filename,containmentBox=[],rect2lines=True):\n    stringLines = [line.strip() for line in open(filename)]   \n    \n    # SVG <line> primitives\n    lines = [string.strip() for string in stringLines if re.match(\"<line \",string)!=None]   \n    outLines = \"\"   \n    for line in lines:\n        searchObj = re.search( r'(<line )(.+)(\" x1=\")(.+)(\" y1=\")(.+)(\" x2=\")(.+)(\" y2=\")(.+)(\"/>)', line)\n        if searchObj:\n            outLines += \"[[\"+searchObj.group(4)+\",\"+searchObj.group(6)+\"], [\"+searchObj.group(8) +\",\"+ searchObj.group(10) +\"]],\"\n    if lines != []:\n        lines = list(eval(outLines))\n              \n    # SVG <rect> primitives\n    rects = [string.strip() for string in stringLines if re.match(\"<rect \",string)!=None]   \n    outRects,searchObj = \"\",False \n    for rect in rects:\n        searchObj = re.search( r'(<rect x=\")(.+?)(\" y=\")(.+?)(\" )(.*?)( width=\")(.+?)(\" height=\")(.+?)(\"/>)', rect)\n        if searchObj:\n            outRects += \"[[\"+searchObj.group(2)+\",\"+searchObj.group(4)+\"], [\"+searchObj.group(8)+\",\"+searchObj.group(10)+\"]],\"\n    \n    if rects != []:\n        rects = list(eval(outRects))\n        if rect2lines:\n            lines += CAT([[[[x,y],[x+w,y]],[[x+w,y],[x+w,y+h]],[[x+w,y+h],[x,y+h]],[[x,y+h],[x,y]]] for [x,y],[w,h] in rects])\n        else: \n            lines += [[[x,y],[x+w,y+h]] for [x,y],[w,h] in rects]\n            \n    lines = [[[p1[0],-p1[1]],[p2[0],-p2[1]]] for [p1,p2] in lines]  # overturning y axis\n    \n    #< SVG input normalization transformation #>\n    #V,EV = larModelNormalization(lines2lar(lines))\n    #lines = [[V[u],V[v]] for u,v in EV]\n    \n    containmentBox = box\n    \n    return lines\n@}\n%-------------------------------------------------------------------------------\n    \n\\paragraph{LAR 2D model normalization}\n%-------------------------------------------------------------------------------\n@D LAR 2D model normalization\n@{\"\"\" LAR 2D model normalization \"\"\"\ndef larModelNormalization(model):\n    V,EV = model\n    xs,ys = TRANS(V)\n    box = [min(xs), min(ys), max(xs), max(ys)]\n    \n    # viewport aspect-ratio checking, setting a computed-viewport 'b'\n    b = [None for k in range(4)]\n    if (box[2]-box[0])/(box[3]-box[1]) > 1:  \n        b[0]=0; b[2]=1; \n        bm=(box[3]-box[1])/(box[2]-box[0]); \n        b[1]=.5-bm/2; b[3]=.5+bm/2\n    else: \n        b[1]=0; b[3]=1; \n        bm=(box[2]-box[0])/(box[3]-box[1]); \n        b[0]=.5-bm/2; b[2]=.5+bm/2\n    \n    # isomorphic 'box -> b' transform to standard unit square\n    W = [[ ((x1-box[0])*(b[2]-b[0]))/(box[2]-box[0]) , \n           ((y1-box[1])*(b[3]-b[1]))/(box[1]-box[3]) + 1]\n        for [x1,y1] in V]\n    return W,EV\n\ndef larModelNormalization(model):\n    V,EV = model\n    xs,ys = TRANS(V)\n    w0,w1,w2,w3 = [min(xs), min(ys), max(xs), max(ys)]\n    \n    # viewport aspect-ratio checking, setting a computed-viewport 'v'\n    ar = (w2-w0)/(w3-w1)\n    if ar >1 : v0,v1,v2,v3 = 0,0,1,1./ar\n    else: v0,v1,v2,v3 = 0,0,ar,1\n    \n    a,b,c,d = v2*w0, v3*w1, w2-w0, w3-w1\n    W = [[(v2*x - a)/c, (v3*y - b)/d] for x,y in V]\n    return W,EV\n@}\n%------------------------------------------------------------------------------- \n\n\n    \n\\paragraph{SVG input normalization transformation}\nThe normalization transformation maps the input \\texttt{lines} to the $[0,1]^2$ viewport, i.e. to the standard unit square.\n\n%-------------------------------------------------------------------------------\n@D SVG input normalization transformation\n@{\"\"\" SVG input normalization transformation \"\"\"\n# window-viewport transformation\nxs,ys = TRANS(CAT(lines))\nbox = [min(xs), min(ys), max(xs), max(ys)]\n\n# viewport aspect-ratio checking, setting a computed-viewport 'b'\nb = [None for k in range(4)]\nif (box[2]-box[0])/(box[3]-box[1]) > 1:  \n    b[0]=0; b[2]=1; bm=(box[3]-box[1])/(box[2]-box[0]); b[1]=.5-bm/2; b[3]=.5+bm/2\nelse: \n    b[1]=0; b[3]=1; bm=(box[2]-box[0])/(box[3]-box[1]); b[0]=.5-bm/2; b[2]=.5+bm/2\n\n# isomorphic 'box -> b' transform to standard unit square\nlines = [[[ \n((x1-box[0])*(b[2]-b[0]))/(box[2]-box[0]) , \n((y1-box[1])*(b[3]-b[1]))/(box[1]-box[3]) + 1], [\n((x2-box[0])*(b[2]-b[0]))/(box[2]-box[0]), \n((y2-box[1])*(b[3]-b[1]))/(box[1]-box[3]) + 1]]  \n      for [[x1,y1],[x2,y2]] in lines]\n\n# line vertices set to fixed resolution\nlines = eval(\"\".join(['['+ vcode(4)(p1) +','+ vcode(4)(p2) +'], ' for p1,p2 in lines]))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{2-complex extraction from svg file}\nThe input \\texttt{lines} arrangments produces a 1-dimensional complex stored into the \\texttt{LAR} model \\texttt{V,EV}. Then the \\emph{dangling edges} are removed from \\texttt{EV\\_},\nand the whole data set is renumbered, in order to remove the unused vertices, using the \\texttt{larRemoveVertices} function.\nFinally the 2-cells are computed and stored in \\texttt{FV}, and the positive areas of every 2cells are computed, so allowing for identify and removal of the exterior face, \ncorresponding to the boundary of the complex.\nThe polygonal boundary of the complex is finally drawn.\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test10.py\n@{\"\"\" Biconnected components from orthogonal LAR model \"\"\"\nfrom larlib import *\n\nfilename = \"test/svg/inters/plan.svg\"\n#filename = \"test/py/inters/building.svg\"\n#filename = \"test/py/inters/complex.svg\"\nprint \nlines = svg2lines(filename)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n    \nV,FV,EV,polygons = larFromLines(lines)\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,FV[:-1]+EV)) + AA(MK)(V)))\n\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV[:-1]],submodel,0.05))\n\n\nverts,faces,edges = polyline2lar([[ V[v] for v in FV[-1] ]])\nVIEW(STRUCT(MKPOLS((verts,edges))))\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test10a.py\n@{\"\"\" Biconnected components from orthogonal LAR model \"\"\"\nfrom larlib import *\n\nprint \"\\n drag your SVG file to  http://cvdlab.github.io/svg2lines\"\nprint \"then save it to <path/filename>.lines\"\nfilename = raw_input('filename =')\n\n#filename = \"test/svg/inters/plan.lines\"\n#filename = \"test/py/inters/building.svg\"\n#filename = \"test/py/inters/complex.svg\"\n\nlines = lines2lines(filename)\nVIEW(STRUCT(AA(POLYLINE)(lines)))\n    \nV,FV,EV,polygons = larFromLines(lines)\nVIEW(EXPLODE(1.2,1.2,1)(MKPOLS((V,FV[:-1]+EV)) + AA(MK)(V)))\n\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV[:-1]],submodel,0.05))\n\n\nverts,faces,edges = polyline2lar([[ V[v] for v in FV[-1] ]])\nVIEW(STRUCT(MKPOLS((verts,edges))))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.2425\\linewidth,width=0.2425\\linewidth]{images/svg1} \n   \\includegraphics[height=0.2425\\linewidth,width=0.2425\\linewidth]{images/svg2} \n   \\includegraphics[height=0.2425\\linewidth,width=0.2425\\linewidth]{images/svg3} \n   \\includegraphics[height=0.2425\\linewidth,width=0.2425\\linewidth]{images/svg4} \n   \\caption{\\texttt{LAR} complex generation from \\texttt{SVG} file. (a) the input set of lines parsed from an \\texttt{SVG} file; (b) the intersection of lines; (c) the extracted \\emph{regularized} 2-complex, drawn exploded; (d) the boundary \\texttt{LAR}.}\n   \\label{fig:ortho}\n\\end{figure}\n\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test11.py\n@{\"\"\" Fast Polygon Triangulation based on Seidel's Algorithm \"\"\"\n# data generated by test10.py on file polygon.svg\nfrom larlib import *\n\nV,FV,EV = ([[0.222, 0.889],\n  [0.722, 1.0],\n  [0.519, 0.763],\n  [1.0, 0.659],\n  [0.859, 0.233],\n  [0.382, 0.119],\n  [0.519, 0.348],\n  [0.296, 0.53],\n  [0.0, 0.059]],\n [[0, 1, 2, 3, 4, 5, 6, 7, 8]],\n [[2, 3], [6, 7], [0, 8], [3, 4], [1, 2], [7, 8], [4, 5], [5, 6], [0, 1]])\n \nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV],submodel,0.5))\n\n \nxord = TRANS(sorted(zip(V,range(len(V)))))[1]\ntrapezoids = zip(xord[:-1],xord[1:])\nvert2forw_trap = dict()\nvert2back_trap = dict()\n\nfor k,(a,b) in enumerate(trapezoids[1:-1]):\n    print k,(a,b)\n    vert2back_trap[a]=k\n    vert2forw_trap[a]=k+1\n    vert2back_trap[b]=k+1\n    vert2forw_trap[b]=k+2\nvert2forw_trap[trapezoids[0][0]] = 0\nvert2back_trap[trapezoids[-1][1]] = len(trapezoids)-1\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O test/py/inters/test12.py\n@{\"\"\" Biconnected components from orthogonal LAR model \"\"\"\nfrom larlib import *\n\nV = [[0.395, 0.296], [0.593, 0.0], [0.79, 0.773], [0.671, 0.889], [0.79, 0.0], [0.593, 0.296], [0.593, 0.593], [0.395, 0.593], [0.0, 0.889], [0.0, 0.0]]\nFV = [[0, 5, 4, 1], [1, 9, 0], [8, 7, 0, 9], [7, 8, 3, 2, 4, 5, 6]]\nEV = [[0, 1], [8, 9], [6, 7], [4, 5], [1, 4], [3, 8], [5, 6], [2, 3], [1, 9], [0, 9], [0, 5], [0, 7], [7, 8], [2, 4]]\npolylines = [[V[v] for v in face+[face[0]]] for face in FV]\nVIEW(EXPLODE(1.1,1.1,1)(MKPOLS((V,EV)) + AA(MK)(V) + AA(FAN)(polylines) ))\n\nVV = AA(LIST)(range(len(V)))\nsubmodel = STRUCT(MKPOLS((V,EV)))\nVIEW(larModelNumbering(1,1,1)(V,[VV,EV,FV],submodel,.6))\n\nVIEW(EXPLODE(1.1,1.1,1)(AA(POLYLINE)(polylines)))\n@}\n%-------------------------------------------------------------------------------\n\n\\appendix\n%===============================================================================\n\\section{Code utilities}\n%===============================================================================\n\n\\paragraph{Coding utilities}\n\nSome utility fuctions used by the module are collected in this appendix. Their macro names can be seen in the below script.\n\n%-------------------------------------------------------------------------------\n@D Coding utilities\n@{\"\"\" Coding utilities \"\"\"\n@< Generation of all binary subsets of lenght n @>\n@< Generation of a random point @>\n@< Generation of a random line segment @>\n@< Transformation of a 2D box into a closed polyline @>\n@< Computation of the 1D centroid of a list of 2D boxes @>\n@< Pyplasm XOR of FAN of ordered points @>\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Generation of all binary subsets of lenght n}\n\n%-------------------------------------------------------------------------------\n@D Generation of all binary subsets of lenght n\n@{\"\"\" Generation of all binary subsets of lenght n \"\"\"\ndef allBinarySubsetsOfLenght(n):\n\tout = [list(('{0:0'+str(n)+'b}').format(k)) for k in range(1,2**n)]\n\treturn AA(AA(int))(out)\n@}\n%-------------------------------------------------------------------------------\n\n\\subparagraph{Example}\n\\begin{verbatim}\nIn [9]: allBinarySubsetsOfLenght(3)\nOut[9]: [[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]\n\\end{verbatim}\n\n\n\\paragraph{Generation of random lines}\nThe function \\texttt{randomLines} returns the array \\texttt{randomLineArray} with a given number of lines generated within the unit 2D interval. The \\texttt{scaling} parameter is used to scale every such line, generated by two randow points, that could be possibly located to far from each other, even at the distance of the diagonal of the unit square.\n\nThe arrays \\texttt{xs} and \\texttt{ys}, that contain the $x$ and $y$ coordinates of line points, are used to compute the minimal translation \\texttt{v} needed to transport the entire set of data within the positive quadrant of the 2D plane. \n\n%-------------------------------------------------------------------------------\n@D Generation of random lines\n@{\"\"\" Generation of random lines \"\"\"\ndef randomLines(numberOfLines=200,scaling=0.3):\n    randomLineArray = [redge(scaling) for k in range(numberOfLines)]\n    [xs,ys] = TRANS(CAT(randomLineArray))[:2]\n    xmin, ymin = min(xs), min(ys)\n    v = array([-xmin,-ymin])\n    randomLineArray = [[list(v1[:2]+v), list(v2[:2]+v)] for v1,v2 in randomLineArray]\n    return randomLineArray\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Generation of a random point}\nA single random point, codified in floating point format, and with a fixed (quite small) number of digits, is returned by the \\texttt{rpoint2d()} function, with no input parameters.\n%-------------------------------------------------------------------------------\n@D Generation of a random point\n@{\"\"\" Generation of a random point \"\"\"\ndef rpoint2d():\n    return eval( vcode(4)([ random.random(), random.random() ]) )\n@}\n%-------------------------------------------------------------------------------\n    \n\\paragraph{Generation of a random line segment}\nA single random segment, scaled about its centroid by the \\texttt{scaling} parameter, is returned by the \\texttt{redge()} function, as a tuple ot two random points in the unit square.\n%-------------------------------------------------------------------------------\n@D Generation of a random line segment\n@{\"\"\" Generation of a random line segment \"\"\"\ndef redge(scaling):\n    v1,v2 = array(rpoint2d()), array(rpoint2d())\n    c = (v1+v2)/2\n    pos = rpoint2d()\n    v1 = (v1-c)*scaling + pos\n    v2 = (v2-c)*scaling + pos\n    return tuple(eval(vcode(4)(v1))), tuple(eval(vcode(4)(v2)))\n@}\n%-------------------------------------------------------------------------------\n    \n\\paragraph{Transformation of a 2D box into a closed polyline}\nThe transformation of a 2D box into a closed rectangular polyline, given as an ordered sequwncw of 2D points, is produced by the function \\texttt{box2rect}\n%-------------------------------------------------------------------------------\n@D Transformation of a 2D box into a closed polyline\n@{\"\"\" Transformation of a 2D box into a closed polyline \"\"\"    \ndef box2rect(box):\n    x1,y1,x2,y2 = box\n    verts = [[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]]\n    return verts\n@}\n%-------------------------------------------------------------------------------\n    \n\\paragraph{Computation of the 1D centroid of a list of 2D boxes}\nThe 1D \\texttt{centroid} of a list of 2D boxes is computed by the function given below.\nThe direction of computation (either $x$ or $y$) is chosen depending on the value of the \\texttt{xy} parameter. \n%-------------------------------------------------------------------------------\n@D Computation of the 1D centroid of a list of 2D boxes\n@{\"\"\" Computation of the 1D centroid of a list of 2D boxes \"\"\"    \ndef centroid(boxes,coord):\n    delta,n = 0,len(boxes)\n    ncoords = len(boxes[0])/2\n    a = coord%ncoords\n    b = a+ncoords\n    for box in boxes:\n        delta += (box[a] + box[b])/2\n    return delta/n\n\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Pyplasm XOR of FAN of ordered points}\n\n%-------------------------------------------------------------------------------\n@D Pyplasm XOR of FAN of ordered points\n@{\"\"\" XOR of FAN of ordered points \"\"\" \ndef FAN(points): \n    pairs = zip(points[1:-2],points[2:-1])\n    triangles = [MKPOL([[points[0],p1,p2],[[1,2,3]],None]) for p1,p2 in pairs]\n    return XOR(triangles)\n \nif __name__==\"__main__\":\n    pol = [[0.476,0.332],[0.461,0.359],[0.491,0.375],[0.512,0.375],[0.514,0.375],\n    [0.527,0.375],[0.543,0.34],[0.551,0.321],[0.605,0.314],[0.602,0.307],[0.589,\n    0.279],[0.565,0.244],[0.559,0.235],[0.553,0.227],[0.527,0.239],[0.476,0.332]]\n\n    VIEW(EXPLODE(1.2,1.2,1)(FAN(pol)))\n@}\n%-------------------------------------------------------------------------------\n\n\n\\bibliographystyle{amsalpha}\n\\bibliography{inters}\n\n\\end{document}\n", "meta": {"hexsha": "d9bf371e361ff21d7cb358436e0446e1ffbc477a", "size": 69055, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/tex/inters.tex", "max_stars_repo_name": "Ahdhn/lar-cc", "max_stars_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-10T02:06:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-10T02:06:27.000Z", "max_issues_repo_path": "src/tex/inters.tex", "max_issues_repo_name": "Ahdhn/lar-cc", "max_issues_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-02-20T21:57:07.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T07:18:11.000Z", "max_forks_repo_path": "src/tex/inters.tex", "max_forks_repo_name": "Ahdhn/lar-cc", "max_forks_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-04T10:47:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-10T17:32:50.000Z", "avg_line_length": 42.339055794, "max_line_length": 774, "alphanum_fraction": 0.5648251394, "num_tokens": 18876, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.41635075015544526}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% LaTeX Example: Project Report\n%\n% Source: http://www.howtotex.com\n%\n% Feel free to distribute this example, but please keep the referral\n% to howtotex.com\n% Date: March 2011\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% How to use writeLaTeX:\n%\n% You edit the source code here on the left, and the preview on the\n% right shows you the result within a few seconds.\n%\n% Bookmark this page and share the URL with your co-authors. They can\n% edit at the same time!\n%\n% You can upload figures, bibliographies, custom classes and\n% styles using the files menu.\n%\n% If you're new to LaTeX, the wikibook is a great place to start:\n% http://en.wikibooks.org/wiki/LaTeX\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Edit the title below to update the display in My Documents\n%\\title{Project Report}\n%\n%%% Preamble\n\\documentclass[paper=a4, fontsize=11pt]{scrartcl}\n\\usepackage[T1]{fontenc}\n\\usepackage{fourier}\n\n\\usepackage[english]{babel}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t% English language/hyphenation\n\\usepackage[protrusion=true,expansion=true]{microtype}\n\\usepackage{amsmath,amsfonts,amsthm} % Math packages\n\\usepackage[pdftex]{graphicx}\n\\usepackage{url}\n\\usepackage{caption}\n\\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}\n\\usepackage{subcaption}  % For placing two subfigures side by side\n\n%%% Custom sectioning\n\\usepackage{sectsty}\n\\usepackage{multirow}\n\\allsectionsfont{\\centering \\normalfont\\scshape}\n\n%%% Inserting landscape pages\n\\usepackage{pdflscape}\n\n\n%%% Custom headers/footers (fancyhdr package)\n\\usepackage{fancyhdr}\n\\pagestyle{fancyplain}\n\\fancyhead{}\t\t\t\t\t\t\t\t\t\t\t% No page header\n\\fancyfoot[L]{}\t\t\t\t\t\t\t\t\t\t\t% Empty\n\\fancyfoot[C]{}\t\t\t\t\t\t\t\t\t\t\t% Empty\n\\fancyfoot[R]{\\thepage}\t\t\t\t\t\t\t\t\t% Pagenumbering\n\\renewcommand{\\headrulewidth}{0pt}\t\t\t% Remove header underlines\n\\renewcommand{\\footrulewidth}{0pt}\t\t\t\t% Remove footer underlines\n\\setlength{\\headheight}{13.6pt}\n\\setlength{\\fboxrule}{1mm}\n\\setlength{\\fboxsep}{5mm}\n\n%%% Equation and float numbering\n\\numberwithin{equation}{section}\t\t% Equationnumbering: section.eq#\n\\numberwithin{figure}{section}\t\t\t% Figurenumbering: section.fig#\n\\numberwithin{table}{section}\t\t\t\t% Tablenumbering: section.tab#\n\n\n%%% Maketitle metadata\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} \t% Horizontal rule\n\n\\title{\n\t\t%\\vspace{-1in}\n\t\t\\usefont{OT1}{bch}{b}{n}\n\t\t\\horrule{0.5pt} \\\\[0.2cm]\n\t\t\\LARGE Deriving an analytical expression for the local extrema of a bivariate B-spline of degree 2\\\\\n        -\\\\\n        \\normalsize Another tool for characterising sawtooth crash precursors\n\t\t\\horrule{2pt} \\\\[0.3cm]\n}\n\\author{D. VEZINET}\n\\date{\\today}\n\n% Graphics path\n\\graphicspath{ {./} }\n\n%%% Begin document\n\\begin{document}\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\\section{General expression of the surface and gradient}\n\n\n\\begin{figure}[hbtp]\n    \\centering\n    \\includegraphics[scale=0.35]{Fig_Grid.png}\n    \\caption{\\small Grid element on which we want to check the existence of a point of null gradient}\n    \\label{Fig:Grid}\n\\end{figure}\n\n\nOn the mesh element illustrated in \\ref{Fig:Grid} (disregarding boundary effects, i.e.: assuming no basis function is missing) a bivariate B-spline of degree 2 can be written:\n$$\n\\begin{array}{ll}\nF(x,y) &= \\sum_{i=0}^{9}C_{i}F_i(x,y)\\\\\n&=\n\\begin{array}{ll}\n& C_{00}f_{x0..3}(x)f_{y0..3}(y) + C_{01}f_{x1..4}(x)f_{y0..3}(y) + C_{02}f_{x2..5}(x)f_{y0..3}(y)\\\\\n+& C_{10}f_{x0..3}(x)f_{y1..4}(y) + C_{11}f_{x1..4}(x)f_{y1..4}(y) + C_{12}f_{x2..5}(x)f_{y1..4}(y)\\\\\n+& C_{20}f_{x0..3}(x)f_{y2..5}(y) + C_{21}f_{x1..4}(x)f_{y2..5}(y) + C_{22}f_{x2..5}(x)f_{y2..5}(y)\n\\end{array}\n\\end{array}\n$$\n\nWhere $f_{x0..3} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{(x-x0)^2}{(x2-x0)(x1-x0)} & \\text{ ,  if  } & x \\in [x0,x1]\\\\\n\\frac{(x-x0)(x2-x)}{(x2-x0)(x2-x1)} + \\frac{(x-x1)(x3-x)}{(x2-x1)(x3-x1)} & \\text{ ,  if  } & x \\in [x1,x2]\\\\\n\\frac{(x3-x)^2}{(x3-x2)(x3-x1)} & \\text{ ,  if  } & x \\in [x2,x3]\n\\end{array}\n\\right.\n$\n\nSo $\\frac{\\partial f_{x0..3}}{\\partial x} =\n\\left\\{\n\\begin{array}{lll}\n\\frac{2(x-x0)}{(x2-x0)(x1-x0)} & \\text{ ,  if  } & x \\in [x0,x1]\\\\\n\\frac{-2x+(x0+x2)}{(x2-x0)(x2-x1)} + \\frac{-2x+(x1+x3)}{(x2-x1)(x3-x1)} & \\text{ ,  if  } & x \\in [x1,x2]\\\\\n\\frac{-2(x3-x)}{(x3-x2)(x3-x1)} & \\text{ ,  if  } & x \\in [x2,x3]\n\\end{array}\n\\right.\n$\n\nWe want to know for which points inside the mesh element of interest (i.e. $(x,y) \\in [a2,a3]\\times[b2,b3]$) we have:\n$$\n\\begin{array}{ccc}\n\\underline{\\nabla}F = 0 &\\Leftrightarrow &\n\\left \\{\n\\begin{array}{llc}\n\\sum_{i=0}^9 C_i f_{y...}(y)\\frac{\\partial f_{x...}}{\\partial x}(x) = 0 & (1)\\\\\n\\sum_{i=0}^9 C_i f_{x...}(x)\\frac{\\partial f_{y...}}{\\partial y}(y) = 0 & (2)\n\\end{array}\n\\right.\n\\end{array}\n$$\n\nWe will treat case (1) in the following and deduce the similar expression for case (2).\n\n%\\frac{(x-x0)^2}{(x2-x0)(x1-x0)}\n\n\\newpage\n\\begin{landscape}\n\\section{Calculations}\n\n\\paragraph{\\textbf{Trivial case}} If all $C_i$ are zero then the gradient is zero everywhere on the mesh element.\n\n\\paragraph{\\textbf{Non-trivial case for (1)}} ... and assuming that all the knots are different\n$$\n\\begin{array}{lll}\n0 & = & \\frac{(y3-y)^2}{(y3-y2)(y3-y1)} \\left( C_{00}\\frac{-2(x3-x)}{(x3-x2)(x3-x1)} + C_{01}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)(x3-x2)} + \\frac{-2x+(x2+x4)}{(x3-x2)(x4-x2)} \\right) + C_{02}\\frac{2(x-x2)}{(x4-x2)(x3-x2)}  \\right)\\\\\n& & + \\left( \\frac{(y-y1)(y3-y)}{(y3-y1)(y3-y2)} + \\frac{(y-y2)(y4-y)}{(y3-y2)(y4-y2)} \\right) \\left( C_{10}\\frac{-2(x3-x)}{(x3-x2)(x3-x1)} + C_{11}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)(x3-x2)} + \\frac{-2x+(x2+x4)}{(x3-x2)(x4-x2)} \\right) + C_{12}\\frac{2(x-x2)}{(x4-x2)(x3-x2)} \\right)\\\\\n& & + \\frac{(y-y2)^2}{(y4-y2)(y3-y2)} \\left( C_{20}\\frac{-2(x3-x)}{(x3-x2)(x3-x1)} + C_{21}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)(x3-x2)} + \\frac{-2x+(x2+x4)}{(x3-x2)(x4-x2)} \\right) + C_{22}\\frac{2(x-x2)}{(x4-x2)(x3-x2)} \\right)\\\\\n\n& = & \\frac{(y3-y)^2}{(y3-y1)} \\left( C_{00}\\frac{-2(x3-x)}{(x3-x1)} + C_{01}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)} + \\frac{-2x+(x2+x4)}{(x4-x2)} \\right) + C_{02}\\frac{2(x-x2)}{(x4-x2)}  \\right)\\\\\n& & + \\left( \\frac{(y-y1)(y3-y)}{(y3-y1)} + \\frac{(y-y2)(y4-y)}{(y4-y2)} \\right) \\left( C_{10}\\frac{-2(x3-x)}{(x3-x1)} + C_{11}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)} + \\frac{-2x+(x2+x4)}{(x4-x2)} \\right) + C_{12}\\frac{2(x-x2)}{(x4-x2)} \\right)\\\\\n& & + \\frac{(y-y2)^2}{(y4-y2)} \\left( C_{20}\\frac{-2(x3-x)}{(x3-x1)} + C_{21}\\left( \\frac{-2x+(x1+x3)}{(x3-x1)} + \\frac{-2x+(x2+x4)}{(x4-x2)} \\right) + C_{22}\\frac{2(x-x2)}{(x4-x2)} \\right)\\\\\n\n& = & \\frac{(y3-y)^2}{(y3-y1)} \\left( x\\left( \\frac{2C_{00}}{(x3-x1)} + \\frac{-2C_{01}}{(x3-x1)} + \\frac{-2C_{01}}{(x4-x2)} + \\frac{2C_{02}}{(x4-x2)} \\right) +  \\frac{-2x3C_{00}}{(x3-x1)} + \\frac{C_{01}(x1+x3)}{(x3-x1)} + \\frac{C_{01}(x2+x4)}{(x4-x2)} + \\frac{-2x2C_{02}}{(x4-x2)} \\right)\\\\\n& & + \\left( \\frac{(y-y1)(y3-y)}{(y3-y1)} + \\frac{(y-y2)(y4-y)}{(y4-y2)} \\right) \\left( x\\left( \\frac{2C_{10}}{(x3-x1)} + \\frac{-2C_{11}}{(x3-x1)} + \\frac{-2C_{11}}{(x4-x2)} + \\frac{2C_{12}}{(x4-x2)} \\right) +  \\frac{-2x3C_{10}}{(x3-x1)} + \\frac{C_{11}(x1+x3)}{(x3-x1)} + \\frac{C_{11}(x2+x4)}{(x4-x2)} + \\frac{-2x2C_{12}}{(x4-x2)} \\right)\\\\\n& & + \\frac{(y-y2)^2}{(y4-y2)} \\left( x\\left( \\frac{2C_{20}}{(x3-x1)} + \\frac{-2C_{21}}{(x3-x1)} + \\frac{-2C_{21}}{(x4-x2)} + \\frac{2C_{22}}{(x4-x2)} \\right) +  \\frac{-2x3C_{20}}{(x3-x1)} + \\frac{C_{21}(x1+x3)}{(x3-x1)} + \\frac{C_{21}(x2+x4)}{(x4-x2)} + \\frac{-2x2C_{22}}{(x4-x2)} \\right)\n\\end{array}\n$$\n\nSo, by introducing $\\left \\{ \\begin{array}{l} A_{x,i} = \\frac{2(C_{i0}-C_{i1})}{(x3-x1)} + \\frac{2(C_{i2}-C_{i1})}{(x4-x2)}\\\\ B_{x,i} = \\frac{C_{i1}(x1+x3)-2x3C_{i0}}{(x3-x1)} + \\frac{C_{i1}(x2+x4)-2x2C_{i2}}{(x4-x2)} \\end{array} \\right.$, we can write:\n$$\n\\begin{array}{lll}\n0 & = & \\frac{(y3-y)^2}{(y3-y1)} \\left( xA_{x,0} + B_{x,0} \\right) + \\left( \\frac{(y-y1)(y3-y)}{(y3-y1)} + \\frac{(y-y2)(y4-y)}{(y4-y2)} \\right) \\left( xA_{x,1} + B_{x,1} \\right) + \\frac{(y-y2)^2}{(y4-y2)} \\left( xA_{x,2} + B_{x,2} \\right)\\\\\n& = & y^2 \\left( \\frac{xA_{x,0} + B_{x,0}}{y3-y1} - \\frac{xA_{x,1} + B_{x,1}}{y3-y1} - \\frac{xA_{x,1} + B_{x,1}}{y4-y2} + \\frac{xA_{x,2} + B_{x,2}}{y4-y2} \\right)\\\\\n& & + y\\left( -2y3\\frac{xA_{x,0} + B_{x,0}}{y3-y1} + \\frac{y3+y1}{y3-y1}\\left( xA_{x,1} + B_{x,1} \\right) + \\frac{y4+y2}{y4-y2}\\left( xA_{x,1} + B_{x,1} \\right) - 2y2\\frac{xA_{x,2} + B_{x,2}}{y4-y2} \\right)\\\\\n& & + y3^2\\frac{xA_{x,0} + B_{x,0}}{y3-y1} - y3y1\\frac{xA_{x,1} + B_{x,1}}{y3-y1} - y4y2\\frac{xA_{x,1} + B_{x,1}}{y4-y2} + y2^2\\frac{xA_{x,2} + B_{x,2}}{y4-y2}\\\\\n\n& = & y^2 \\left( \\frac{x\\left(A_{x,0}-A_{x,1}\\right) + B_{x,0}-B_{x,1}}{y3-y1} + \\frac{x\\left(A_{x,2}-A_{x,1}\\right) + B_{x,2}-B_{x,1}}{y4-y2} \\right)\\\\\n& & + y\\left( \\frac{(y3+y1)\\left( xA_{x,1} + B_{x,1} \\right) - 2y3\\left(xA_{x,0} + B_{x,0}\\right)}{y3-y1} + \\frac{(y4+y2)\\left( xA_{x,1} + B_{x,1} \\right) - 2y2\\left(xA_{x,2} + B_{x,2}\\right)}{y4-y2} \\right)\\\\\n& & + \\frac{y3^2\\left(xA_{x,0} + B_{x,0}\\right) - y3y1\\left(xA_{x,1} + B_{x,1}\\right)}{y3-y1} + \\frac{y2^2\\left(xA_{x,2} + B_{x,2}\\right) - y4y2\\left(xA_{x,1} + B_{x,1}\\right)}{y4-y2}\n\\end{array}\n$$\n\n\\end{landscape}\n\n\\newpage\n\\section{Overview of the reduced set of equations}\nHence, we can write that a point with gradient zero will have:\n$$\n\\left \\{\n\\begin{array}{l}\ny^2 P_2(x) + yP_1(x) + P_0(x) = 0\\\\\nx^2 Q_2(y) + xQ_1(y) + Q_0(y) = 0\n\\end{array}\n\\right.\n$$\n\nWhere:\n$$\n\\left \\{\n\\begin{array}{ll}\nP_2(x) = x\\left( \\frac{A_{x,0}-A_{x,1}}{y3-y1} + \\frac{A_{x,2}-A_{x,1}}{y4-y2} \\right) + \\frac{B_{x,0}-B_{x,1}}{y3-y1} + \\frac{B_{x,2}-B_{x,1}}{y4-y2}  & = xa_{P2} + b_{P2}\\\\\nP_1(x) = x\\left( \\frac{(y3+y1)A_{x,1} - 2y3A_{x,0}}{y3-y1} + \\frac{(y4+y2)A_{x,1} - 2y2A_{x,2}}{y4-y2} \\right) + \\frac{(y3+y1)B_{x,1} - 2y3B_{x,0}}{y3-y1} + \\frac{(y4+y2)B_{x,1} - 2y2B_{x,2}}{y4-y2}  & = xa_{P1} + b_{P1}\\\\\nP_0(x) = x\\left( \\frac{y3^2A_{x,0} - y3y1xA_{x,1}}{y3-y1} + \\frac{y2^2A_{x,2} - y4y2A_{x,1}}{y4-y2} \\right) + \\frac{y3^2B_{x,0} - y3y1xB_{x,1}}{y3-y1} + \\frac{y2^2B_{x,2} - y4y2B_{x,1}}{y4-y2}  & = xa_{P0} + b_{P0}\n\\end{array}\n\\right.\n$$\n\nAnd:\n$$\n\\left \\{\n\\begin{array}{ll}\nQ_2(y) = y\\left( \\frac{A_{y,0}-A_{y,1}}{x3-x1} + \\frac{A_{y,2}-A_{y,1}}{x4-x2} \\right) + \\frac{B_{y,0}-B_{y,1}}{x3-x1} + \\frac{B_{y,2}-B_{y,1}}{x4-x2}  & = ya_{Q2} + b_{Q2}\\\\\nQ_1(y) = y\\left( \\frac{(x3+x1)A_{y,1} - 2x3A_{y,0}}{x3-x1} + \\frac{(x4+x2)A_{y,1} - 2x2A_{y,2}}{x4-x2} \\right) + \\frac{(x3+x1)B_{y,1} - 2x3B_{y,0}}{x3-x1} + \\frac{(x4+x2)B_{y,1} - 2x2B_{y,2}}{x4-x2}  & = ya_{Q1} + b_{Q1}\\\\\nQ_0(y) = y\\left( \\frac{x3^2A_{y,0} - x3x1xA_{y,1}}{x3-x1} + \\frac{x2^2A_{y,2} - x4x2A_{y,1}}{x4-x2} \\right) + \\frac{x3^2B_{y,0} - x3x1xB_{y,1}}{x3-x1} + \\frac{x2^2B_{y,2} - x4x2B_{y,1}}{x4-x2}  & = ya_{Q0} + b_{Q0}\n\\end{array}\n\\right.\n$$\n\nIn the following, we will explore the various cases of this set of equations, keeping in mind that we are looking for a solution in $[x2,x3]\\times[y2,y3]$\n\n\\newpage\n\\section{Cases of the reduced set of equations}\n\n\\subsection{$P_2(x) = 0$}\n\nNecessarily, if $P_2(x)=0$ then:\n$$\nx\\left( \\frac{A_{x,0}-A_{x,1}}{y3-y1} + \\frac{A_{x,2}-A_{x,1}}{y4-y2} \\right) = -\\frac{B_{x,0}-B_{x,1}}{y3-y1} + \\frac{B_{x,2}-B_{x,1}}{y4-y2}\\\\\n$$\n\n\\paragraph{\\textbf{Case 01}} $\\frac{A_{x,0}-A_{x,1}}{y3-y1} + \\frac{A_{x,2}-A_{x,1}}{y4-y2} = 0$\\\\\n%Then $\\frac{2}{y3-y1}\\left( \\frac{(C_{00}-C_{01})}{(x3-x1)} + \\frac{(C_{02}-C_{01})}{(x4-x2)} - \\frac{(C_{10}-C_{11})}{(x3-x1)} + \\frac{(C_{12}-C_{11})}{(x4-x2)} \\right)\n%+ \\frac{2}{y4-y2}\\left( \\frac{(C_{20}-C_{21})}{(x3-x1)} + \\frac{(C_{22}-C_{21})}{(x4-x2)} - \\frac{(C_{10}-C_{11})}{(x3-x1)} + \\frac{(C_{12}-C_{11})}{(x4-x2)} \\right) = 0$\nThen:\n\\begin{enumerate}\n\\item If $\\frac{B_{x,0}-B_{x,1}}{y3-y1} + \\frac{B_{x,2}-B_{x,1}}{y4-y2} \\neq 0$, no possible solution\n\\item If $\\frac{B_{x,0}-B_{x,1}}{y3-y1} + \\frac{B_{x,2}-B_{x,1}}{y4-y2} = 0$, all x are solution\n\\end{enumerate}\n\nThus, some solutions are accessible in $[x2,x3]\\times[y2,y3]$ in the second case.\n\n\\paragraph{\\textbf{Case 02}} $\\frac{A_{x,0}-A_{x,1}}{y3-y1} + \\frac{A_{x,2}-A_{x,1}}{y4-y2} \\neq 0$\\\\\nThen $x_0 = -\\frac{\\frac{B_{x,0}-B_{x,1}}{y3-y1} + \\frac{B_{x,2}-B_{x,1}}{y4-y2}}{\\frac{A_{x,0}-A_{x,1}}{y3-y1} + \\frac{A_{x,2}-A_{x,1}}{y4-y2}}$\\\\\nThus, a solutions is accessible in $[x2,x3]\\times[y2,y3]$ only if $x_0 \\in [x2,x3]\\times[y2,y3]$.\\\\\n\n\\paragraph{\\textbf{Consequences}}\n\nLet $P_2(x_0)=0$ with $x_0 \\in [x2,x3]$, then:\n$$\n\\left \\{\n\\begin{array}{ll}\nyP_1(x_0) + P_0(x_0) = 0 & (1)\\\\\nx_0^2 Q_2(y) + x_0Q_1(y) + Q_0(y) = 0 & (2)\n\\end{array}\n\\right.\n$$\n\n\\begin{enumerate}\n\\item if $P_1(x_0)=0$ and $P_0(x_0)\\neq0$, no solution\n\\item if $P_1(x_0)=0$ and $P_0(x_0)=0$, eq.$(1)$ gives no constraint on y\n\\item if $P_1(x_0)\\neq0$ then $y_0 = -\\frac{P_0(x_0)}{P_1(x_0)}$, then sol = $(x_0,y_0)$ if $\\left\\{\\begin{array}{l}(x_0,y_0) \\in [x2,x3]\\times[y2,y3]\\\\x_0^2 Q_2(y_0) + x_0Q_1(y_0) + Q_0(y_0) = 0 \\end{array}\\right.$\n\\end{enumerate}\n\nIn case 2, we have to use eq. $(2)$ to get a value for y, which will give the same three possibilities (it is a degree 1 polynomial in y):\n\\begin{enumerate}\n\\item No solution if the coef. of y is zero but the rest is non-zero\n\\item All y are solution if the coef. of y is zero and the rest is zero too\n\\item There exist a unique solution $y_0 = -rest/coef.$, check whether it lies in $[y2,y3]$\n\\end{enumerate}\n\n\n\\newpage\n\\subsection{$Q_2(y) = 0$}\n\nSimilarly to the previous case, $Q_2(y) = 0$ is only possible if:\n\\begin{enumerate}\n\\item If $\\frac{B_{y,0}-B_{y,1}}{x3-x1} + \\frac{B_{y,2}-B_{y,1}}{x4-x2} \\neq 0$, no possible solution\n\\item If $\\frac{B_{y,0}-B_{y,1}}{x3-x1} + \\frac{B_{y,2}-B_{y,1}}{x4-x2} = 0$, all y are solution\n\\item Otherwise $y_0 = -\\frac{\\frac{B_{y,0}-B_{y,1}}{x3-x1} + \\frac{B_{y,2}-B_{y,1}}{x4-x2}}{\\frac{A_{y,0}-A_{y,1}}{x3-x1} + \\frac{A_{y,2}-A_{y,1}}{x4-x2}}$ is the unique solution\n\\end{enumerate}\n\nAnd if there is a solution $y_0 \\in [y2,y3]$, then:\n\\begin{enumerate}\n\\item if $Q_1(y_0)=0$ and $Q_0(y_0)\\neq0$, no solution\n\\item if $Q_1(y_0)=0$ and $Q_0(y_0)=0$, eq.$(2)$ gives no constraint on x\n\\item if $Q_1(y_0)\\neq0$ then $x_0 = -\\frac{Q_0(y_0)}{Q_1(y_0)}$, then sol = $(x_0,y_0)$ if $\\left\\{\\begin{array}{l}(x_0,y_0) \\in [x2,x3]\\times[y2,y3]\\\\y_0^2 P_2(x_0) + y_0P_1(x_0) + P_0(x_0) = 0 \\end{array}\\right.$\n\\end{enumerate}\n\nIn case 2, we have to use eq. $(1)$ to get a value for x, which will give the same three possibilities (it is a degree 1 polynomial in y):\n\\begin{enumerate}\n\\item No solution if the coef. of x is zero but the rest is non-zero\n\\item All y are solution if the coef. of x is zero and the rest is zero too\n\\item There exist a unique solution $x_0 = -rest/coef.$, check whether it lies in $[x2,x3]$\n\\end{enumerate}\n\n\\newpage\n\\subsection{$P_2(x)\\neq0 \\text{ and } Q_2(y)\\neq0$}\n\nIn this general case, we have to check the existence of solutions to two degree 2 polynomials:\n$$\n\\begin{array}{ll}\n& \\left \\{\n\\begin{array}{ll}\n\\Delta_y(x) = P_1^2(x) - 4P_2^2(x)P_0^2(x) \\geq 0 & (1)\\\\\n\\Delta_x(y) = Q_1^2(y) - 4Q_2^2(y)Q_0^2(y) \\geq 0 & (2)\n\\end{array}\n\\right.\\\\\n\\Leftrightarrow & \\left \\{\n\\begin{array}{ll}\nx^2 \\left( a_{P1}^2-4a_{P2}a_{P0} \\right) + x\\left( 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} \\right) + b_{P1}^2-4b_{P2}b_{P0} \\geq 0 & (1)\\\\\ny^2 \\left( a_{Q1}^2-4a_{Q2}a_{Q0} \\right) + y\\left( 2a_{Q1}b_{Q1} - 4a_{Q2}b_{Q0} - 4a_{Q0}b_{Q2} \\right) + b_{Q1}^2-4b_{Q2}b_{Q0} \\geq 0 & (2)\n\\end{array}\n\\right.\n\\end{array}\n$$\n\nWhich means, by defining $\\left\\{\\begin{array}{l}\\delta_x = \\left( 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} \\right)^2-4\\left( a_{P1}^2-4a_{P2}a_{P0} \\right)\\left(b_{P1}^2-4b_{P2}b_{P0}\\right)\\\\\n\\delta_y = \\left( 2a_{Q1}b_{Q1} - 4a_{Q2}b_{Q0} - 4a_{Q0}b_{Q2} \\right)^2-4\\left( a_{Q1}^2-4a_{Q2}a_{Q0} \\right)\\left(b_{Q1}^2-4b_{Q2}b_{Q0}\\right)\\end{array}\\right.$:\n\\begin{enumerate}\n\\item If $\\left\\{\\begin{array}{l}a_{P1}^2-4a_{P2}a_{P0}=0\\\\ 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} > 0\\end{array}\\right.$ then $x \\in [x_0,\\infty]\\cap[x2,x3]$, with $x_0=-\\frac{b_{P1}^2-4b_{P2}b_{P0}}{2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2}}$\n\\item If $\\left\\{\\begin{array}{l}a_{P1}^2-4a_{P2}a_{P0}=0\\\\ 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} < 0\\end{array}\\right.$ then $x \\in [-\\infty,x_0]\\cap[x2,x3]$, with $x_0=-\\frac{b_{P1}^2-4b_{P2}b_{P0}}{2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2}}$\n\\item If $\\left\\{\\begin{array}{l}a_{P1}^2-4a_{P2}a_{P0}=0\\\\ 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} = 0\\end{array}\\right.$ then $\\left\\{\\begin{array}{l}b_{P1}^2-4b_{P2}b_{P0}=0 \\Rightarrow \\text{ all x solutions}\\\\ b_{P1}^2-4b_{P2}b_{P0} \\neq 0 \\Rightarrow \\text{ no solution}\\end{array}\\right.$\n\\item If $\\left\\{\\begin{array}{l}\\delta_x < 0\\\\a_{P1}^2-4a_{P2}a_{P0} > 0 \\end{array}\\right.$, then all $x \\in [x2,x3]$ are solution\n\\item If $\\left\\{\\begin{array}{l}\\delta_x < 0\\\\a_{P1}^2-4a_{P2}a_{P0} < 0 \\end{array}\\right.$, then no solution\n\\item If $\\left\\{\\begin{array}{l}\\delta_x \\geq 0\\\\a_{P1}^2-4a_{P2}a_{P0} > 0 \\end{array}\\right.$, then $x \\in \\left([-\\infty,x_1] \\cup [x_2,\\infty]\\right) \\cap [x2,x3]$ with $x_{1,2}=\\frac{-\\left( 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} \\right) \\pm \\sqrt{\\delta_x}}{2\\left( a_{P1}^2-4a_{P2}a_{P0} \\right)}$\n\\item If $\\left\\{\\begin{array}{l}\\delta_x \\geq 0\\\\a_{P1}^2-4a_{P2}a_{P0} < 0 \\end{array}\\right.$, then $x \\in [x_1,x_2] \\cap [x2,x3]$ with $x_{1,2}=\\frac{-\\left( 2a_{P1}b_{P1} - 4a_{P2}b_{P0} - 4a_{P0}b_{P2} \\right) \\pm \\sqrt{\\delta_x}}{2\\left( a_{P1}^2-4a_{P2}a_{P0} \\right)}$\n\\end{enumerate}\n\nAnd idem for y\n\n\\newpage\n\\begin{landscape}\n\\paragraph{\\textbf{Consequences}} Now let $I_x = [x_1,x_2] \\subset [x2,x3]$ and $I_y = [y_1,y_2] \\subset [y2,y3]$ be the two intervals satisfying $\\Delta_y(x)\\geq0$ and $\\Delta_x(y)\\geq0$, then:\n$$\n\\begin{array}{ll}\n&\n\\left \\{\n\\begin{array}{l}\ny = \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)}\\\\\nx = \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)}\n\\end{array}\n\\right.\\\\\n\\Leftrightarrow &\n\\left \\{\n\\begin{array}{l}\n2yP_2\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right) = -P_1\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right) \\pm \\sqrt{\\Delta_y\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right)}\\\\\n2xQ_2\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right) = -Q_1\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right) \\pm \\sqrt{\\Delta_x\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right)}\n\\end{array}\n\\right.\\\\\n\\Leftrightarrow &\n\\left \\{\n\\begin{array}{l}\n2y\\left( a_{P2}\\left( -Q_1(y) \\pm \\sqrt{\\Delta_x(y)} \\right) + 2Q_2(y)b_{P2} \\right) = -\\left( a_{P1} \\left(-Q_1(y) \\pm \\sqrt{\\Delta_x(y)} \\right) + 2Q_2(y)b_{P1} \\right) \\pm 2Q_2(y)\\sqrt{\\Delta_y\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right)}\\\\\n2x\\left( a_{Q2}\\left(-P_1(x) \\pm \\sqrt{\\Delta_y(x)} \\right) + 2P_2(x)b_{Q2} \\right) = -\\left( a_{Q1} \\left(-P_1(x) \\pm \\sqrt{\\Delta_y(x)} \\right) + 2P_2(x)b_{Q1} \\right) \\pm 2P_2(x)\\sqrt{\\Delta_x\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right)}\n\\end{array}\n\\right.\\\\\n\\Leftrightarrow &\n\\left \\{\n\\begin{array}{l}\n2y\\left( a_{P2}\\left( -a_{Q1}y - b_{Q1} \\pm \\sqrt{\\Delta_x(y)} \\right) + 2b_{P2}\\left(a_{Q2}y+b_{Q2}\\right) \\right) = -\\left( a_{P1} \\left(-a_{Q1}y - b_{Q1} \\pm \\sqrt{\\Delta_x(y)} \\right) + 2b_{P1}\\left( a_{Q2}y+b_{Q2}\\right) \\right) \\pm 2Q_2(y)\\sqrt{\\Delta_y\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right)}\\\\\n2x\\left( a_{Q2}\\left(-a_{P1}x-b_{P1} \\pm \\sqrt{\\Delta_y(x)} \\right) + 2b_{Q2}\\left(a_{P2}x+b_{P2}\\right) \\right) = -\\left( a_{Q1} \\left(-a_{P1}x-b_{P1} \\pm \\sqrt{\\Delta_y(x)} \\right) + 2b_{Q1}\\left(a_{P2}x+b_{P2}\\right) \\right) \\pm 2P_2(x)\\sqrt{\\Delta_x\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right)}\n\\end{array}\n\\right.\\\\\n\\Leftrightarrow &\n\\left \\{\n\\begin{array}{l}\ny^2 \\left( -2a_{P2}a_{Q1}+4b_{P2}a_{Q2} \\right) + y\\left( -2a_{P2}b_{Q1}+2b_{P2}b_{Q2}-a_{P1}a_{Q1}+2b_{P1}a_{Q2} \\pm 2a_{P2}\\sqrt{\\Delta_x(y)} \\right) + \\left( -a_{P1}b_{Q1} + 2b_{P1}b_{Q2} \\pm a_{P1}\\sqrt{\\Delta_x(y)} \\right) \\mp 2Q_2(y)\\sqrt{\\Delta_y\\left( \\frac{-Q_1(y) \\pm \\sqrt{\\Delta_x(y)}}{2Q_2(y)} \\right)}\\\\\nx^2 \\left( -2a_{Q2}a_{P1}+4b_{Q2}a_{P2} \\right) + x\\left( -2a_{Q2}b_{P1}+2b_{Q2}b_{P2}-a_{Q1}a_{P1}+2b_{Q1}a_{P2} \\pm 2a_{Q2}\\sqrt{\\Delta_y(x)} \\right) + \\left( -a_{Q1}b_{P1} + 2b_{Q1}b_{P2} \\pm a_{Q1}\\sqrt{\\Delta_y(x)} \\right) \\mp 2P_2(x)\\sqrt{\\Delta_x\\left( \\frac{-P_1(x) \\pm \\sqrt{\\Delta_y(x)}}{2P_2(x)} \\right)}\n\\end{array}\n\\right.\n\\end{array}\n$$\n\n\n... And this is as far as I get analytically, any idea ? any reference ?\n\n\\end{landscape}\n\n\n%%% End document\n\\end{document}\n", "meta": {"hexsha": "8e0787297ecc0ccae9d4cf87ae43a2e17aa359fa", "size": 20395, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/Integral_1D_D3_D3.tex", "max_stars_repo_name": "WinstonLHS/tofu", "max_stars_repo_head_hexsha": "c95b2eb6aedcf4bac5676752b9635b78f31af6ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2017-07-09T10:29:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T02:44:50.000Z", "max_issues_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/Integral_1D_D3_D3.tex", "max_issues_repo_name": "WinstonLHS/tofu", "max_issues_repo_head_hexsha": "c95b2eb6aedcf4bac5676752b9635b78f31af6ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 522, "max_issues_repo_issues_event_min_datetime": "2017-07-02T21:06:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T08:07:57.000Z", "max_forks_repo_path": "Notes_Upgrades/Bsplines_GeneralExpressions/Integral_1D_D3_D3.tex", "max_forks_repo_name": "Didou09/tofu", "max_forks_repo_head_hexsha": "4a4e1f058bab8e7556ed9d518f90807cec605476", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2017-07-02T20:38:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-04T00:12:30.000Z", "avg_line_length": 51.8956743003, "max_line_length": 340, "alphanum_fraction": 0.5936258887, "num_tokens": 10015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4163507419382325}}
{"text": "\\appendix\n\\section{Appendix MPC-L} \\label{AppendixA}\nAs introduced in Section \\ref{subsection:failed_tests}, during the single static obstacle avoidance testing phase, we have encountered some issues regarding the validation of the sixth requirement on the speed range specified in Section \\ref{System_Requirements}. In particular, after verifying that the MPC we were developing was unable to perform well at low speeds (under 40 $km/h$), we have decided to split the main problem into two sub-problems consisting of two different speed ranges which would be managed by two different MPCs.\nThis choice has allowed us to continue the validation relative to MPC-H, which is the one managing high speeds (from 40 to 100 $km/h$), avoiding going back to modify the parameters of the controller to find an optimal solution (if it exists) working in the whole range of speeds.\n\nThis Appendix, instead, is dedicated to the development of the MPC-L, which manages the speeds ranging from 10 to 40 $km/h$. After validating the MPC-H, we have come back to its parameters definition and then we have set up a testing procedure where we have applied several different combinations acting on prediction horizon, sample time, and output variables weights of the cost function, aimed to find an appropriate solution.\nThe test setup and outcomes can be found in the Documentation folder of the repository\\footnote{The ``MPC-L-Test\\_Report001\",\\space``MPC-L-Test\\_Report002\",\\space``MPC-L-Test\\_Report0005\", and ``MPC-L-Test\\_Specification\\_Report\" files generated by Simulink Test are included in the Documentation/Test Reports/MPC-L\\_Test\\_Reports/ file path.}.\\\\\nThanks to this iterations, we have found a suitable set of parameters working at 20 $km/h$, that is reported in the following table:\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{|l|l|}\n\\hline\nPrediction Horizon & 10               \\\\ \\hline\nSample Time        & 0.02             \\\\ \\hline\nWOV                & {[}30 30 8 30{]} \\\\ \\hline\n\\end{tabular}\n\\caption{Best configuration found for MPC-L}\n\\label{tab:MPC_L_Config}\n\\end{table}\nWith the configuration reported in Table \\ref{tab:MPC_L_Config}, we have run the test for the static obstacle avoidance in the scenarios already used in Section \\ref{chap:static_obstacle_avoidance_tests}, setting a constant speed of 20 $km/h$. The results of this test, as usual, are reported in the Documentation folder\\footnote{The ``MPC-L\\_Static\\_Obstacle\\_Avoidance-Test\\_Report\" and ``MPC-L\\_Static\\_Obstacle\\_Avoidance-Test\\_Specification\\_Report\" files generated by Simulink Test are included in the Documentation/Test Reports/MPC-L\\_Test\\_Reports/ file path.}.\nEven if this configuration seems to work pretty well on most of the scenarios, we have still found that in some situations the controller loses stability and starts oscillating, as shown in Figure \\ref{fig:mpc_l_test}.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\textwidth,keepaspectratio]{Figures/mpc_l_test_169.png}\n    \\caption{Output Trajectory of the Vehicle with MPC-L controller in 135° scenario}\n    \\label{fig:mpc_l_test}\n    \\end{figure}\n    \n   \nIn order to get the best out of this controller, further tuning is required but we have decided to stop here because this goes beyond the didactic purpose of this particular project. ", "meta": {"hexsha": "1c37f9b243f5228ea034367efa9b7870afdb983b", "size": 3308, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Report/Chapters/14-Appendix.tex", "max_stars_repo_name": "meltinglab/dynamic-obstacle-avoidance", "max_stars_repo_head_hexsha": "2290754436864a817851c71803d5275445cbcdb1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-05-24T07:00:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-19T16:44:04.000Z", "max_issues_repo_path": "Documentation/Report/Chapters/14-Appendix.tex", "max_issues_repo_name": "meltinglab/dynamic-obstacle-avoidance", "max_issues_repo_head_hexsha": "2290754436864a817851c71803d5275445cbcdb1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/Report/Chapters/14-Appendix.tex", "max_forks_repo_name": "meltinglab/dynamic-obstacle-avoidance", "max_forks_repo_head_hexsha": "2290754436864a817851c71803d5275445cbcdb1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-20T19:24:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T17:58:16.000Z", "avg_line_length": 106.7096774194, "max_line_length": 569, "alphanum_fraction": 0.7759975816, "num_tokens": 790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259584, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.41629360514283714}}
{"text": "\n% This LaTeX was auto-generated from an M-file by MATLAB.\n% To make changes, update the M-file and republish this document.\n\n\n\n    \n    \n      \\subsection{concat.m}\n\n\\begin{par}\n\\textbf{Summary:} Compute a control signal $u$ from a state distribution $x\\sim\\mathcal N(x|m,s)$. Here, the predicted control distribution and its derivatives are computed by concatenating a controller \"con\" with a saturation function \"sat\", such as gSat.m.\n\\end{par} \\vspace{1em}\n\n\\begin{verbatim}function [M, S, C, dMdm, dSdm, dCdm, dMds, dSds, dCds, dMdp, dSdp, dCdp] ...\n         = conCat(con, sat, policy, m, s)\\end{verbatim}\n    \n\\begin{verbatim}Example call: conCat(@congp, @gSat, policy, m, s)\\end{verbatim}\n    \\begin{par}\n\\textbf{Input arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}con       function handle (controller)\nsat       function handle (squashing function)\npolicy    policy structure\n  .maxU   maximum amplitude of control signal (after squashing)\nm         mean of input distribution                             [D x 1]\ns         covariance of input distribution                       [D x D]\\end{verbatim}\n\\begin{par}\n\\textbf{Output arguments:}\n\\end{par} \\vspace{1em}\n\\begin{verbatim}M         control mean                                           [E   x   1]\nS         control covariance                                     [E   x   E]\nC         inv(s)*cov(x,u)                                        [D   x   E]\ndMdm      deriv. of expected control wrt input mean              [E   x   D]\ndSdm      deriv. of control covariance wrt input mean            [E*E x   D]\ndCdm      deriv. of C wrt input mean                             [D*E x   D]\ndMds      deriv. of expected control wrt input covariance        [E   x D*D]\ndSds      deriv. of control covariance wrt input covariance      [E*E x D*D]\ndCds      deriv. of C wrt input covariance                       [D*E x D*D]\ndMdp      deriv. of expected control wrt policy parameters       [E   x   P]\ndSdp      deriv. of control covariance wrt policy parameters     [E*E x   P]\ndCdp      deriv. of C wrt policy parameters                      [D*E x   P]\\end{verbatim}\n\\begin{verbatim}where P is the total number of policy parameters\\end{verbatim}\n\\begin{par}\nCopyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.\n\\end{par} \\vspace{1em}\n\\begin{par}\nLast modified: 2012-07-03\n\\end{par} \\vspace{1em}\n\n\n\\subsection*{High-Level Steps} \n\n\\begin{enumerate}\n\\setlength{\\itemsep}{-1ex}\n   \\item Compute unsquashed control signal\n   \\item Compute squashed control signal\n\\end{enumerate}\n\n\\begin{lstlisting}\nfunction [M, S, C, dMdm, dSdm, dCdm, dMds, dSds, dCds,  dMdp, dSdp, dCdp] ...\n  = conCat(con, sat, policy, m, s)\n\\end{lstlisting}\n\n\n\\subsection*{Code} \n\n\n\\begin{lstlisting}\nmaxU=policy.maxU; % amplitude limit of control signal\nE=length(maxU);   % dimension of control signal\nD=length(m);      % dimension of input\n\n% pre-compute some indices\nF=D+E; j=D+1:F; i=1:D;\n% initialize M and S\nM = zeros(F,1); M(i) = m; S = zeros(F); S(i,i) = s;\n\nif nargout < 4   % without derivatives\n  [M(j), S(j,j), Q] = con(policy, m, s);  % compute unsquashed control signal v\n  q = S(i,i)*Q; S(i,j) = q; S(j,i) = q';  % compute joint covariance S=cov(x,v)\n  [M, S, R] = sat(M, S, j, maxU);         % compute squashed control signal u\n  C = [eye(D) Q]*R;                       % inv(s)*cov(x,u)\nelse             % with derivatives\n  Mdm = zeros(F,D); Sdm = zeros(F*F,D); Mdm(1:D,1:D) = eye(D);\n  Mds = zeros(F,D*D); Sds = kron(Mdm,Mdm);\n\n  X = reshape(1:F*F,[F F]); XT = X';                  % vectorized indices\n  I=0*X;I(j,j)=1; jj=X(I==1)'; I=0*X;I(i,j)=1;ij=X(I==1)'; ji=XT(I==1)';\n\n  % 1. Unsquashed controller --------------------------------------------------\n  [M(j), S(j,j), Q, Mdm(j,:), Sdm(jj,:), dQdm, Mds(j,:), ...\n    Sds(jj,:), dQds, Mdp, Sdp, dQdp] = con(policy, m, s);\n  q = S(i,i)*Q; S(i,j) = q; S(j,i) = q';  % compute joint covariance S=cov(x,v)\n\n  % update the derivatives\n  SS = kron(eye(E),S(i,i)); QQ = kron(Q',eye(D));\n  Sdm(ij,:) = SS*dQdm;      Sdm(ji,:) = Sdm(ij,:);\n  Sds(ij,:) = SS*dQds + QQ; Sds(ji,:) = Sds(ij,:);\n\n  % 2. Apply Saturation -------------------------------------------------------\n  [M, S, R, MdM, SdM, RdM, MdS, SdS, RdS] = sat(M, S, j, maxU);\n\n  % apply chain-rule to compute derivatives after concatenation\n  dMdm = MdM*Mdm + MdS*Sdm; dMds = MdM*Mds + MdS*Sds;\n  dSdm = SdM*Mdm + SdS*Sdm; dSds = SdM*Mds + SdS*Sds;\n  dRdm = RdM*Mdm + RdS*Sdm; dRds = RdM*Mds + RdS*Sds;\n\n  dMdp = MdM(:,j)*Mdp + MdS(:,jj)*Sdp;\n  dSdp = SdM(:,j)*Mdp + SdS(:,jj)*Sdp;\n  dRdp = RdM(:,j)*Mdp + RdS(:,jj)*Sdp;\n\n  C = [eye(D) Q]*R; % inv(s)*cov(x,u)\n  % update the derivatives\n  RR = kron(R(j,:)',eye(D)); QQ = kron(eye(E),[eye(D) Q]);\n  dCdm = QQ*dRdm + RR*dQdm;\n  dCds = QQ*dRds + RR*dQds;\n  dCdp = QQ*dRdp + RR*dQdp;\nend\n\\end{lstlisting}\n", "meta": {"hexsha": "ab0e745e75cc92e977d98f764596b5d8952e34da", "size": 4851, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/tex/conCat.tex", "max_stars_repo_name": "SJTUGuofei/pilco-matlab", "max_stars_repo_head_hexsha": "a0b48b7831911837d060617903c76c22e4180d0b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2016-12-17T15:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-09T16:59:27.000Z", "max_issues_repo_path": "doc/tex/conCat.tex", "max_issues_repo_name": "sahandrez/quad_pilco", "max_issues_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-24T11:02:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T11:09:45.000Z", "max_forks_repo_path": "doc/tex/conCat.tex", "max_forks_repo_name": "sahandrez/quad_pilco", "max_forks_repo_head_hexsha": "2c99152e3a910d147cd0a52822da306063e6a834", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2017-04-19T06:55:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-19T10:19:12.000Z", "avg_line_length": 40.0909090909, "max_line_length": 258, "alphanum_fraction": 0.5716347145, "num_tokens": 1637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4161086328964721}}
{"text": "% !TEX root = main.tex\n% !TEX spellcheck = en-US\n\\section{Preliminaries}\n\\label{sec:preliminaries}\n\\subsection{Notations} Let $\\ppt$ denote probabilistic polynomial-time and $\\secpar \\in \\NN$ be the\nsecurity parameter. All adversaries $\\adv$  are stateful. \nSince every algorithm $\\adv$ takes as input\nthe public parameters we skip them when describing $\\adv$'s input. \n\nFor an algorithm $\\adv$, let\n$\\image (\\adv)$ be the image of $\\adv$ (the set of valid outputs of $\\adv$), let\n$\\RND{\\adv}$ denote the set of random tapes of correct length for $\\adv$\n(assuming the given value of $\\secpar$), and let $r \\sample \\RND{\\adv}$ denote\nthe random choice of the randomiser $r$ from $\\RND{\\adv}$. We denote by $\\negl$\n($\\poly$) an arbitrary negligible (resp.~polynomial) function.\n\nProbability ensembles $X = \\smallset{X_\\secpar}_\\secpar$ and $Y =\n\\smallset{Y_\\secpar}_\\secpar$, for distributions $X_\\secpar, Y_\\secpar$, have\n\\emph{statistical distance} $\\SD$ equal $\\epsilon(\\secpar)$ if $\\sum_{a \\in\n  \\supp{X_\\secpar \\cup Y_\\secpar}} \\abs{\\prob{X_\\secpar = a} - \\prob{Y_\\secpar =\n    a}} = \\epsilon(\\secpar)$. We write $X \\approx_\\secpar Y$ if $\\SD(X_\\secpar,\nY_\\secpar) \\leq \\negl$. For values $a(\\secpar)$ and $b(\\secpar)$ we write\n$a(\\secpar) \\approx_\\secpar b(\\secpar)$ if $\\abs{a(\\secpar) - b(\\secpar)} \\leq\n\\negl$.\n\nFor a probability space $(\\samplespace, \\eventspace, \\probfunction)$ and event\n$\\event{E} \\in \\eventspace$ we denote by $\\nevent{E}$ an event that is\ncomplementary to $\\event{E}$,\ni.e.~$\\nevent{E} = \\samplespace \\setminus \\event{E}$.\n\nDenote by $\\RELGEN = \\smallset{\\REL}$ a family of relations. We assume that if\n$\\REL$ comes with any auxiliary input, the later is benign. Directly from the\ndescription of $\\REL$ one learns security parameter $\\secpar$ and description of the\ngroup $\\GRP$, if the relation is a relation of group elements (as it usually is\nin case of zkSNARKs).\n\n\\ourpar{Bilinear groups.} We use the  standard bracket notation for groups $\\GRP_{\\gi}$. i.e., we\nwrite $\\bmap{a}{\\gi}$ to denote $a g_{\\gi}$ where $g_{\\gi}$ is a fixed generator\nof $\\GRP_{\\gi}$. \nA bilinear group generator $\\pgen (\\secparam)$ returns public parameters $ \\pp =\n(p, \\GRP_1, \\GRP_2, \\GRP_T, \\pair, \\gone{1}, \\gtwo{1})$, where $\\GRP_1$,\n$\\GRP_2$, and $\\GRP_T$ are additive cyclic groups of prime order $p = 2^{\\Omega\n  (\\secpar)}$, $\\gone{1}, \\gtwo{1}$ are generators of $\\GRP_1$, $\\GRP_2$, resp.,\nand $\\pair: \\GRP_1 \\times \\GRP_2 \\to \\GRP_T$ is a non-degenerate\n$\\ppt$-computable bilinear pairing $\\pair (\\gone{a}, \\gtwo{b}) := \\gone{a} \\bullet\n\\gtwo{b}= \\gtar{a b}$. We assume the bilinear pairing to be Type-3,\ni.e., that there is no efficient isomorphism from $\\GRP_1$ to $\\GRP_2$ or from\n$\\GRP_2$ to $\\GRP_1$. \n%We freely use the bracket notation with matrices, e.g., if $\\vec{A} \\vec{B} = \\vec{C}$ then\n%$\\vec{A} \\grpgi{\\vec{B}} = \\grpgi{\\vec{C}}$ and $\\gone{\\vec{A}}\\bullet\\gtwo{\\vec{B}} = \\gtar{\\vec{C}}$. \n\n\n\\begin{lemma}[Difference lemma,~{\\cite[Lemma 1]{EPRINT:Shoup04}}]\n\t\\label{lem:difference_lemma}\n\tLet $\\event{A}, \\event{B}, \\event{F}$ be events defined in some probability\n\tspace, and suppose that $\\event{A} \\land \\nevent{F} \\iff \\event{B}\n\t\t\\land \\nevent{F}$.  Then \n\t$\n\t\t\\abs{\\prob{\\event{A}} - \\prob{\\event{B}}} \\leq \\prob{\\event{F}}\\,.\n\t$\n\\end{lemma}\n\\subsection{Algebraic Group Model}\nThe algebraic group model (AGM) introduced in \\cite{C:FucKilLos18} lies between\nthe standard model and generic group model. In the AGM it is assumed\nthat an adversary $\\adv$ can output a group element $\\gnone{y} \\in \\GRP$ if\n$\\gnone{y}$ has been computed by applying known group operations to group elements\ngiven to $\\adv$ as input.  More precisely, the AGM requires that\nwhenever $\\adv(\\gnone{\\vec{x}})$ outputs a group element $\\gnone{y}$ then it\nalso outputs $\\vec{c}$ such that $\\gnone{y} = \\vec{c}^\\top \\cdot\n\\gnone{\\vec{x}}$. Both $\\plonk$ and $\\sonic$ have been shown secure using the\nAGM. An adversary that works in the AGM is called \\emph{algebraic}.\n\n\\subsection{Polynomial commitment}\n\\label{sec:poly_com}\nIn the polynomial commitment scheme $\\PCOM = (\\kgen, \\com, \\open, \\verify)$ the\ncommitter $\\committer$ can convince the receiver $\\receiver$ that some\npolynomial $\\p{f}$ which $\\committer$ committed to evaluates to $s$ at some\npoint $z$ chosen by $\\receiver$. $\\PCOM$'s subroutines are defined as follows \n\\begin{description}\n\\item[$\\kgen(1^\\secpar, \\maxdeg)$:] The key generation algorithm\n  $\\kgen(1^\\secpar, \\maxdeg)$ takes in a security parameter $1^\\secpar$ and a\n  parameter $\\maxdeg$ which determines the maximal degree of the committed\n  polynomial. It outputs a structured reference string $\\srs$ (including a\n  commitment key).\n\\item[$\\com(\\srs, \\p{f})$:] The commitment algorithm $\\com(\\srs, \\p{f})$ takes\n  in $\\srs$ and a polynomial $\\p{f}$ with maximum degree $\\maxdeg$, and outputs\n  a commitment $c$.\n\\item[$\\open(\\srs, z, s, \\p{f})$:] The opening algorithm\n  $\\open(\\srs, z, s \\p{f})$ takes as input $\\srs$, an evaluation point $z$, a\n  value $s$ and the polynomial $\\p{f}$. It outputs an opening $o$.\n\\item[$\\verify(\\srs, c, z, s, o)$:] The verification algorithm takes in $\\srs$,\n  a commitment $c$, an evaluation point $z$, a value $s$ and an opening $o$. It\n  outputs 1 if $o$ is a valid opening for $(c, z, s)$ and 0 otherwise.\n\\end{description}\n\n$\\plonk$ and $\\sonic$ use variants of the KZG polynomial commitment scheme\n\\cite{AC:KatZavGol10}. We denote the first by $\\PCOMp$ and the latter by\n$\\PCOMs$. Due to page limit, we omit their presentation here and refer to\n\\cref{fig:pcomp} and \\cref{fig:pcoms} in the \\cref{sec:pcom}.  In this paper we\nuse evaluation binding, commitment of knowledge, and, newly introduced, unique\nopening and hiding properties. Formal definitions of these could be find in\n\\cref{sec:pcom}, here we briefly introduce them.\n\\begin{compactdesc}\n  \\item[Evaluation binding] intuitively, this property assures that no adversary\n    could provide two valid openings for two different evaluations of the same\n    commitment in the same point. \n  \\item[Commitment of knowledge] when a commitment scheme is ``of\n    knowledge'' then if an adversary produces a (valid) commitment $c$, which it\n    can open, then it also knows the underlying polynomial $\\p{f}$ which commits\n    to that value.  \\cite{CCS:MBKM19} shows, using AGM, that $\\PCOMs$ is a\n    commitment of knowledge.  The same reasoning could be used to show that\n    property for $\\PCOMp$.\n  \\item[Unique opening] this property assures that there is\n    only one valid opening for the committed polynomial and given evaluation\n    point. This property is crucial in showing forking simulation-extractability\n    of $\\plonk$ and $\\sonic$. We show that the $\\plonk$'s and $\\sonic$'s\n    polynomial commitment schemes satisfy this requirement in\n    \\cref{lem:pcomp_op} and \\cref{lem:pcoms_unique_op} respectively.\n  \\item[Hiding] assures that no adversary is able to tell anything about the\n    polynomial given only its commitment and bounded number of evaluations.\n\\end{compactdesc}\n\n\n\\subsection{Zero-Knowledge Proof Systems}\nLet $\\RELGEN(\\secparam) = \\smallset{\\REL}$ be a family of\n$\\npol$ relations. Denote by $\\LANG_\\REL$ the language determined by $\\REL$.\nLet $\\prover$ be a \\emph{prover} and $\\verifier$ be the \\emph{verifier}, both $\\ppt$ algorithms. We allow our proof system to have\na setup, i.e.~there is a $\\kgen$ algorithm that takes as input the relation\ndescription $\\REL$ and outputs a common reference string $\\srs$. We assume that\nthe $\\srs$ defines the relation and for universal prove systems, such as Plonk\nand Sonic, we treat both the reference string and the relation as universal.\n\nWe denote by $\\ip{\\prover(\\srs, \\inp, \\wit)}{\\verifier(\\srs,\\inp)}$ a\n\\emph{transcript} (also called \\emph{proof}) $\\zkproof$ of a conversation\nbetween $\\prover$ with input $(\\srs, \\inp, \\wit)$ and $\\verifier$ with input\n$(\\srs, \\inp)$. We write\n$\\ip{\\prover (\\srs, \\inp, \\wit)}{\\verifier(\\srs, \\inp)} = 1$ if in the end of\nthe transcript the verifier $\\verifier$ returns $1$ and say that $\\verifier$\naccepts it.  For non-interactive proof systems we abuse notation and write\n$\\verifier(\\srs, \\inp, \\zkproof) = 1$ to denote a fact that $\\zkproof$ is\naccepted by the verifier.  \n\nA proof system $\\proofsystem = (\\kgen, \\prover, \\verifier, \\simulator)$ for\n$\\RELGEN$ is required to have three properties: completeness, soundness and zero\nknowledge, which are defined as follows:\n% \\begin{description}\n\n\\ourpar{Completeness.}\n%\\item[Completeness]\n  An interactive proof system $\\proofsystem$ is\n  \\emph{complete} if an honest prover always convinces an honest verifier, that\n  is for all $\\REL \\in \\RELGEN(\\secparam)$ and $(\\inp, \\wit) \\in \\REL$\n\t\\[\n\t\t\\condprob{\\ip{\\prover (\\srs, \\inp, \\wit)}{\\verifier (\\srs,\n        \\inp)} = 1}{\\srs \\gets \\kgen(\\REL)} = 1\\,.\n\t\\]\n    % \\item[Soundness]\n\\ourpar{Soundness.}\n    We say that $\\proofsystem$ for $\\RELGEN$ is \\emph{sound} if no\n  $\\ppt$ prover $\\adv$ can convince an honest verifier $\\verifier$ to accept a\n  proof for a false statement $\\inp \\not\\in\\LANG$. More precisely, for\n  all $\\REL \\in \\RELGEN(\\secparam)$\n\t\\[\n    \\condprob{\\ip{\\adv(\\srs, \\inp)}{\\verifier(\\srs, \\inp)} = 1 \\land \\inp\n      \\not\\in \\LANG_\\REL}{\\srs \\gets \\kgen(\\REL), \\inp \\gets \\adv(\\srs)} \\leq\n    \\negl\\,;\n\t\\]\n%\\end{description}\nSometimes a stronger notion of soundness is required---except requiring that the\nverifier rejects proofs of statements outside the language, we request from the\nprover to know a witness corresponding to the proven statement. This property is\ncalled \\emph{knowledge soundness}.%\\markulf{Commented out the formal definition as we don't use it.}\n \n\\ourpar{Zero knowledge.}  We call a proof system $\\proofsystem$\n\\emph{zero-knowledge} if for any $\\REL \\in \\RELGEN(\\secparam)$, and adversary\n$\\adv$ there exists a $\\ppt$ simulator $\\simulator$ such that for any\n$(\\inp, \\wit) \\in \\REL$\n\\begin{multline*}\n\t  \\left\\{\\ip{\\prover(\\srs, \\inp, \\wit)}{\\adv(\\srs, \\inp, \\wit)}\n      \\,\\left|\\, \\srs \\gets \\kgen(\\REL)\\COMMENT{, (\\inp, \\wit) \\gets \\adv(\\REL,\n          \\srs)}\\vphantom{\\simulator^\\adv}\\right.\\right\\} \\approx_\\secpar\n\t\t%\\\\\n\t\t\\left\\{\\simulator^{\\adv}(\\srs, \\inp)\\,\\left|\\, \\srs \\gets\n        \\kgen(\\REL)\\COMMENT{, (\\inp, \\wit) \\gets \\adv(\\REL,\n          \\srs)}\\vphantom{\\simulator^\\adv}\\right.\\right\\}\\,.\n\\end{multline*}\n\t%\nWe call zero knowledge \\emph{perfect} if the distributions are equal and\n\\emph{computational} if they are indistinguishable for any $\\ppt$ distinguisher.\n\n% \\end{description}\nAlternatively, zero-knowledge can be defined by allowing the simulator to use\nthe trapdoor $\\td$ that is generated along the $\\srs$. In this paper we distinguish\nsimulators that requires a trapdoor to simulate and those that do not. We call\nthe former \\emph{SRS-simulators}. We say that a protocol is zero knowledge in\nthe standard model if its simulator does not require the trapdoor.\n\n% Occasionally, a weaker version of zero knowledge is sufficient. So called\n% \\emph{honest verifier zero knowledge} (HVZK) assumes that the verifier's\n% challenges are picked at random from some predefined set. Although weaker, this\n% definition suffices in many applications. Especially, an interactive\n% zero-knowledge proof that is HVZK and \\emph{public-coin} (i.e.~the verifier\n% outputs as challenges its random coins) can be made non-interactive and\n% zero-knowledge in the random oracle model by using the Fiat--Shamir\n% transformation.\n\nIn security reductions in this paper it is sometimes needed to produce\nsimulated NIZK proofs without knowning the trapdoor, just by\nprogramming the random oracle. We call protocols which allow for such kind of\nsimulation \\emph{trapdoor-less zero-knowledge} (TLZK). More precisely,\n\n\\begin{definition}[Trapdoor-less zero-knowledge proof system]\n  Let $\\ps = (\\kgen, \\prover, \\verifier, \\simulator)$ be a NIZK proof\n  system and $\\ro$ a random oracle. Let $\\simulator$ be ana pair of\n  algorithms: $\\simulator_\\ro$ that takes random oracle queries and\n  answers them, $\\simulator_\\prover$ that takes as input an SRS $\\srs$\n  and instance $\\inp$ and outputs a proof $\\zkproof_\\simulator$.  We\n  call $\\ps$ \\emph{trapdoor-less zero-knowledge} if for any adversary\n  $\\adv$, $\\eps_0 \\approx \\eps_1$, where\n  \\begin{align}\n    \\eps_b = \\Pr\\left[\n    \\begin{aligned}\n      \\adv^{\\oracleo_b}(\\srs) = 0\n    \\end{aligned}\n    \\, \\left| \\,\n    \\begin{aligned}\n      \\srs \\sample \\kgen(\\secpar)\n    \\end{aligned}\n    \\right.\\right]\n  \\end{align}\n  where $\\oracleo_b$ takes two types of adversary's queries:\n  \\begin{description}\n  \\item[random oracle calls:] on $\\adv$'s query $x$, $\\oracleo_b$\n    responds with $\\ro(x)$ if $b = 0$, and with $y \\gets\n    \\simulator_\\ro(\\srs, x)$, if $b = 1$.\n  \\item[proof calls:] on $\\adv$'s query $\\inp, \\wit$ responds\n  with a real proof $\\zkproof_\\prover \\gets\n  \\prover(\\srs, \\inp, \\wit)$ if $b = 0q$ or a simulated proof $\\zkproof_\\simulator \\gets \\simulator (\\srs,\n  \\inp)$ if $b = 1$. \n  \\end{description} \n\\end{definition}\n\n% In our simulation soundness proof (but not simulation extractability\n% \\hamid{you mean forking simulation extractability?}) we need an\n% additional property of the zero-knowledge proof system which we call\n% $k$-programmable ZK.\n\\begin{definition}[$k$-programmable ZK]\n  \\label{def:kzk}\n  Let $\\ps$ be a $(2\\mu + 1)$-message ZK proof system and let $\\ps_\\fs$ be its\n  Fiat--Shamir variant. We say that $\\ps_\\fs$ is $k$-programmable ZK if there\n  exists a simulator $\\simulator_\\fs$ that\n  \\begin{compactenum}\n  \\item produces proofs indistinguishable from proofs output by an honest\n    prover;\n  \\item $\\simulator_\\fs$ programs the random oracle \\emph{only} for\n    challenges from round $k$ to $\\mu + 1$.\n  \\end{compactenum}\n\\end{definition}\nWe note that $\\plonk$ is $2$-programmable ZK, $\\sonic$ is $1$-programmable ZK,\nand $\\marlin$ is $1$-programmable ZK. This follows directly from the proofs of\ntheir standard model zero-knowledge property in\n\\cref{lem:plonk_hvzk,lem:sonic_hvzk, lem:marlin_hvzk}. \n\n\\oursubsub{Idealised verifier and verification equations} Let\n$(\\kgen, \\prover, \\verifier)$ be a proof system.\n% or a polynomial commitment\n% scheme\\hamid{might be unclear as we are defining polynomial commitments as\n%   $(\\kgen, \\com, \\open, \\verify)$.}.\nObserve that the $\\kgen$ algorithm provides an SRS which can be interpreted as a\nset of group representation of polynomials evaluated at trapdoor\nelements. E.g.~for a trapdoor $\\chi$ the SRS contains\n$\\gone{\\p{p_1}(\\chi), \\ldots, \\p{p_k}(\\chi)}$, for some polynomials\n$\\p{p_1}(X), \\ldots, \\p{p_k}(X) \\in \\FF_p[X]$. On the other hand, the verifier\n$\\verifier$ accepts if a (possibly set of) verification equation\n$\\vereq_{\\inp, \\zkproof}$ (note that the verification equation changes relate to\nthe instance $\\inp$ and proof $\\zkproof$), which can also be interpreted as a\npolynomial in $\\FF_p[X]$ whose coefficients depend on messages sent by the\nprover, zeroes at $\\chi$. Following \\cite{EPRINT:GabWilCio19} we call verifiers\nwho checks that $\\vereq_{\\inp, \\zkproof}(\\chi) = 0$ \\emph{real verifiers} as\nopposed to \\emph{ideal verifiers} who accepts only when\n$\\vereq_{\\inp, \\zkproof}(X) = 0$. That is, while a real verifier accepts when a\npolynomial \\emph{evaluates} to zero, an ideal verifier accepts only when the\npolynomial \\emph{is} zero.\n\nAlthough ideal verifiers are impractical, they are very useful in our\nproofs. More precisely, we show that\n\\begin{compactenum}\n\\item the idealised verifier accepts an incorrect proof (what ``incorrect''\n  means depends on the situation) with at most negligible probability (and many\n  cases---never);\n\\item when the real verifier accepts, but not the idealised one, then we show\n  how to use a malicious $\\prover$ to break the underlying security assumption\n  (in our case---a variant of $\\dlog$.)\n\\end{compactenum}\n\nAnalogously, idealised verifier can also be defined for polynomial commitment scheme.\n\n\\oursubsub{Sigma protocols}\nA sigma protocol $\\sigmaprot = (\\prover, \\verifier, \\simulator)$ for a relation\n$\\REL \\in \\RELGEN(\\secparam)$ is a special case of an interactive proof where a\ntranscript consists of three messages $(a, b, z)$, where $b$ is a challenge\nprovided by the verifier. Sigma protocols are honest verifier zero-knowledge in\nthe standard model and specially-sound. That is, there exists an extractor\n$\\ext$ which given two accepting transcripts $(a, b, z)$, $(a, b', z')$ for a\nstatement $\\inp$ can recreate the corresponding witness if $b \\neq b'$.\nMore formally:\n% \\begin{description}\n\n\\ourpar{Special soundness.}\n% \\hamid{The last (short) sentence looks a little unclear.}\nA sigma protocol $\\sigmaprot$ is \\emph{specially-sound}\n  if for any adversary $\\adv$ the probability\n\\[\n\\Pr\\left[\n\\begin{aligned}\n& \\verifier(\\REL, \\inp, (a, b, z)) = %\\\\\n\\verifier(\\REL, \\inp, (a, b', z')) = 1 \\\\\n& \\land b \\neq b' \\land \\REL(\\inp, \\wit) = 0 \\\\\n\\end{aligned}\n\\,\\left|\\,\n\\begin{aligned}\n& (\\inp, (a, b, z), (a, b', z')) \\gets \\adv(\\REL), \\\\ %\\\\\n& \\wit \\gets \\ext(\\REL, \\inp, (a, b, z), (a, b', z'))\\\\\n\\end{aligned}\n\\right.\\right]\n\\]\nis upper-bounded by some negligible function $\\negl$.\n%\\end{description}\n\nAnother property that sigma protocols may have is a unique response\nproperty \\cite{C:Fischlin05} which states that no $\\ppt$ adversary can\nproduce two accepting transcripts that differ only on the last\nelement. More precisely, \n%\\begin{description} \n\\ourpar{Unique response property.} Let\n$\\sigmaprot = (\\prover, \\verifier, \\simulator)$ be a sigma-protocol for\n$\\REL \\in \\RELGEN(\\secparam)$ with proofs of the form\n$(a, b, z)$. We say that $\\sigmaprot$ has the unique response property if for\nall $\\ppt$ algorithms $\\adv$, it holds that,:\n\\[ \\condprob{\\verifier (\\REL, \\inp, (a, b, z)) = \\verifier (\\REL, \\inp, (a, b,\n\tz')) = 1 \\land z \\neq z'}{(\\inp, a, b, z, z') \\gets \\adv(\\REL)} \\leq \\negl\\,.  \\]\n%\\end{description} \nIf this property holds even against unbounded adversaries, it is called\n\\emph{strict}, cf.~\\cite{INDOCRYPT:FKMV12}. Later on we call protocols that\nfollows this notion \\emph{ur-protocols}. For the sake of completeness we note\nthat many sigma protocols, like e.g.~Schnorr's protocol \\cite{C:Schnorr89},\nfulfil this property.\n\n\\subsection{From interactive to non-interactive---the Fiat--Shamir transform}\nConsider a $(2\\mu + 1)$-message, public-coin, honest verifier zero-knowledge (HVZK)\ninteractive proof system\n$\\proofsystem = (\\kgen, \\prover, \\verifier, \\simulator)$ for\n$\\REL \\in \\RELGEN(\\secparam)$.  Let $\\zkproof$ be a proof performed by the\nprover $\\prover$ and verifier $\\verifier$ compound of messages\n$(a_1, b_1, \\ldots, a_{\\mu}, b_{\\mu}, a_{\\mu + 1})$, where $a_i$ comes from\n$\\prover$ and $b_i$ comes from $\\verifier$.  Denote by $\\ro$ a random oracle.\nLet $\\proofsystem_\\fs = (\\kgen_\\fs, \\prover_\\fs, \\verifier_\\fs, \\simulator_\\fs)$\nbe a proof system such that\n\\begin{compactitem}\n  \\item $\\kgen_\\fs$ behaves as $\\kgen$.\n  \\item $\\prover_\\fs$ behaves as $\\prover$ except after sending message\n    $a_i$, $i \\in \\range{1}{\\mu}$, the prover does not wait for\n    the message from the verifier but computes it locally setting $b_i\n    = \\ro(\\zkproof[0..i])$, where $\\zkproof[0..j] = (\\inp, a_1, b_1, \\ldots,\n    a_{j - 1}, b_{j - 1}, a_j)$. (Importantly, $\\zkproof[0..\\mu + 1] =\n    (\\inp, \\zkproof)$).\n  \\item $\\verifier_\\fs$ behaves as $\\verifier$ but does not provide\n    challenges to the prover's proof. Instead it computes the\n    challenges locally as $\\prover_\\fs$ does. Then it verifies the\n    resulting transcript $\\zkproof$ as the verifier $\\verifier$ would. \n  \\item $\\simulator_\\fs$ behaves as $\\simulator$, except when\n    $\\simulator$ picks challenge $b_i$ before computing message $\\zkproof[0, i]$, $\\simulator_\\fs$ programs the\n    random oracle to output $b_i$ on $\\zkproof[0, i]$.\n  \\end{compactitem}\n\n\\noindent\nThe Fiat--Shamir heuristic states that $\\proofsystem_\\fs$ is a zero-knowledge\nnon-interactive proof system for $\\REL \\in \\RELGEN(\\secparam)$.\n\n\\subsection{Non-malleability definitions for NIZKs}\n\\label{sec:simext_def}\nReal life applications often require a NIZK proof system to be\nnon-malleable. That is, no adversary seeing a proof $\\zkproof$ for a statement\n$\\inp$ should be able to provide a new proof $\\zkproof'$ related to $\\zkproof$.\n\\emph{Simulation extractability} formalizes a strong version of non-malleability\nby requiring that no adversary can produce a valid proof without knowing the\ncorresponding witness. This must hold even if the adversary is allowed to see\npolynomially many simulated proofs for any statements it wishes.\n\n%\\chaya{remove reference to forking soundness. quantify for $\\ext_\\se$}\n\\begin{definition}[Forking simulation-extractable NIZK, \\cite{INDOCRYPT:FKMV12}]\n\t\\label{def:simext}\n  Let $\\ps_\\fs = (\\kgen_\\fs, \\prover_\\fs, \\verifier_\\fs, \\simulator_\\fs)$ be a non-interactive proof system. \n%  HVZK proof system\\hamid{$\\ps_\\fs$ is the Fiat-Shamir variant of the underlying proof system. So maybe we mean the underlying proof system is HVZK?}. \nWe say that $\\ps_\\fs$ is \\emph{forking\n    simulation-extractable} with \\emph{extraction error} $\\nu$ if for any $\\ppt$\n  adversary $\\adv$ that is given oracle access to a random oracle $\\ro$ and\n  simulator $\\simulator_\\fs$, and produces an accepting transcript of $\\ps$ with\n  probability $\\accProb$, where\n\t\\[\n\t\t\\accProb = \\Pr \\left[\n\t\t\\begin{aligned}\n\t\t\t& \\verifier_\\fs(\\srs, \\inp_{\\advse}, \\zkproof_{\\advse}) = 1,\\\\\n\t\t\t& (\\inp_{\\advse}, \\zkproof_{\\advse}) \\not\\in Q\n\t\t\\end{aligned}\n\t\t\\, \\left| \\,\n\t\t\\begin{aligned}\n\t\t\t& \\srs \\gets \\kgen_\\fs(\\REL), r \\sample \\RND{\\advse}, \\\\\n\t\t\t& (\\inp_{\\advse}, \\zkproof_{\\advse}) \\gets \\advse^{\\simulator_\\fs,\n\t\t\t\\ro} (\\srs; r)\n\t\t\\end{aligned}\n\t\t\\right.\\right]\\,,\n\t\\]\n\tthere exists an extractor $\\extse$ such that\n\t\\[\n\t\t\\extProb = \\Pr \\left[\n\t\t\\begin{aligned}\n\t\t\t& \\verifier_\\fs(\\srs, \\inp_{\\advse}, \\zkproof_{\\advse}) = 1,\\\\\n\t\t\t& (\\inp_{\\advse}, \\zkproof_{\\advse}) \\not\\in Q,\\\\\n\t\t\t& \\REL(\\inp_{\\advse}, \\wit_{\\advse}) = 1\n\t\t\\end{aligned}\n\t\t\\, \\left| \\,\n\t\t\\begin{aligned}\n\t\t\t& \\srs \\gets \\kgen_\\fs(\\REL), r \\sample \\RND{\\advse},\\\\\n\t\t\t& (\\inp_{\\advse}, \\zkproof_{\\advse}) \\gets \\advse^{\\simulator_\\fs,\n\t\t\t\\ro} (\\srs; r) \\\\\n\t\t\t& \\wit_{\\advse} \\gets \\ext_\\se (\\srs, \\advse, r, \\inp_{\\advse}, \\zkproof_{\\advse},\n\t\t\tQ, Q_\\ro) \n\t\t\\end{aligned}\n\t\t\\right.\\right]\n\t\\]\n\tis at at least \n\t\\[\n\t\t\\extProb \\geq \\frac{1}{\\poly} (\\accProb - \\nu)^d - \\eps(\\secpar)\\,,\n\t\\]\n\tfor some polynomial $\\poly$, constant $d$ and negligible $\\eps(\\secpar)$ whenever\n  $\\accProb \\geq \\nu$. List $Q$ contains all $(\\inp, \\zkproof)$ pairs where\n  $\\inp$ is an instance provided to the simulator by the adversary and\n  $\\zkproof$ is the simulator's answer. List $Q_\\ro$ contains all $\\advse$'s\n  queries to $\\ro$ and $\\ro$'s answers.\n\\end{definition}\n\n% Consider a sigma protocol $\\sigmaprot = (\\prover, \\verifier, \\simulator)$ that\n% is special-sound and has a unique response property. Let $\\sigmaprot_\\fs =\n% (\\prover_\\fs, \\verifier_\\fs, \\simulator_\\fs)$ be a NIZK obtained by applying the\n% Fiat--Shamir transform to $\\sigmaprot$. Faust et al.~\\cite{INDOCRYPT:FKMV12}\n% show that every such $\\sigmaprot_\\fs$ is forking simulation-extractable. This result is\n% presented in \\cref{sec:forking_lemma} along with the instrumental forking lemma,\n% cf.~\\cite{CCS:BelNev06}.\n\n\\iffalse\n\\noindent \\textbf{Simulation sound NIZKs.}\nAnother notion for non-malleable NIZKs is \\emph{simulation soundness}. It allows the adversary to see simulated proof, however, in contrast to simulation\nextractability it does not require an extractor to provide a witness for the\nproven statement. Instead, it is only necessary, that an adversary who sees\nsimulated proofs cannot make the verifier accept a proof of an incorrect\nstatement. More precisely,\n\\chaya{this definition will go}\n\\begin{definition}[Simulation soundness]\n  \t\\label{def:simsnd}\n    Let $\\ps = (\\kgen, \\prover, \\verifier, \\simulator)$ be a NIZK proof and\n    $\\ps_\\fs = (\\kgen_\\fs, \\prover_\\fs, \\verifier_\\fs, \\simulator_\\fs)$ be $\\ps$\n    transformed by the Fiat--Shamir transform. We say that $\\ps_\\fs$ is\n    \\emph{simulation-sound}\n    for any $\\ppt$ adversary $\\adv$ that is given oracle access to a random\n    oracle $\\ro$ and simulator $\\simulator_\\fs$, probability\n    \\[\n      \\ssndProb =\n      \\Pr\\left[\n        \\begin{aligned}\n          & \\verifier_\\fs(\\srs, \\inp_{\\adv}, \\zkproof_{\\adv}) = 1,\\\\\n          & (\\inp_{\\advse}, \\zkproof_{\\advse}) \\not\\in Q,\\\\\n          & \\neg \\exists \\wit_{\\adv}: \\REL(\\inp_{\\adv}, \\wit_{\\adv}) = 1\n        \\end{aligned}\n        \\, \\left| \\,\n          \\vphantom{\\begin{aligned}\n          & \\verifier_\\fs(\\srs, \\inp_{\\adv}, \\zkproof_{\\adv}) = 1,\\\\\n          & (\\inp_{\\advse}, \\zkproof_{\\advse}) \\not\\in Q,\\\\\n          & \\neg \\exists \\wit_{\\adv}: \\REL(\\inp_{\\adv}, \\wit_{\\adv}) = 1\n        \\end{aligned}}\n      \\begin{aligned}\n        & \\srs \\gets \\kgen(\\REL), r \\sample \\RND{\\advse},\\\\\n        & (\\inp_{\\advse}, \\zkproof_{\\advse}) \\gets \\advse^{\\simulator_\\fs,\n          \\ro} (\\srs; r)\n      \\end{aligned}\n\t\t\\right.  \\right]\n    \\]\n    is at most negligible.  List $Q$ contains all $(\\inp, \\zkproof)$ pairs where\n  $\\inp$ is an instance provided to the simulator by the adversary and\n  $\\zkproof$ is the simulator's answer. \n\\end{definition}\n\n  \\label{rem:simext_to_simsnd}\n  We note that the probability $\\ssndProb$ \\cref{def:simsnd} can be expressed in\n  terms of simulation-extractability. More precisely, the\n  condition $\\neg \\exists \\wit: \\REL(\\inp_\\adv, \\wit_\\adv) = 1$ can be substituted with\n  $\\REL(\\inp_\\adv, \\wit_\\adv) = 0$, where $\\wit_\\adv$, returned by a possibly unbounded\n  extractor, is either a witness to $\\inp_\\adv$ (if there exists any) or $\\bot$ (if\n  there is none). More precisely,\n\\[\n      \\ssndProb =\n      \\Pr\\left[\n        \\begin{aligned}\n          & \\verifier_\\fs(\\srs, \\inp_{\\adv}, \\zkproof_{\\adv}) = 1,\\\\\n          & (\\inp_{\\advse}, \\zkproof_{\\advse}) \\not\\in Q,\\\\\n          & \\REL(\\inp_{\\adv}, \\wit_{\\adv}) = 0\n        \\end{aligned}\n        \\, \\left| \\,\n      \\begin{aligned}\n        & \\srs \\gets \\kgen(\\REL), r \\sample \\RND{\\advse},\\\\\n        & (\\inp_{\\advse}, \\zkproof_{\\advse}) \\gets \\advse^{\\simulator_\\fs,\n          \\ro} (\\srs; r)\\\\\n        & \\wit_{\\adv} \\gets \\ext(\\srs, \\advse, r, \\inp_{\\advse}, \\zkproof_{\\advse},\n\t\t\tQ, Q_\\ro,) \n      \\end{aligned}\n\t\t\\right.  \\right].\n\\]\nThe only necessary input to the unbounded extractor $\\ext$ is the instance\n$\\inp_\\adv$ (the rest is given for the consistency with the simulation extractability\ndefinition). \n%\nWith the probabilities in \\cref{def:simext} holding regardless of whether the extractor\nis unbounded or not, we obtain the following equality\n$ \\ssndProb = \\accProb - \\extProb$.\n\n% In \\cref{cor:simext_to_ssnd} we show that (under some mild conditions) this is enough\n% to conjecture that probability $\\ssndProb$ is not only at most negligible, but\n% also, in some parameters, exponentially smaller than $(1 - \\extProb)$\n% (probability of extraction failure in \\cref{def:simext}).\n\n\\fi\n", "meta": {"hexsha": "3a16298241aca8d526f5a229492f72a05235a07a", "size": 26932, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ECsubmission/prelim.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ECsubmission/prelim.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ECsubmission/prelim.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6240601504, "max_line_length": 153, "alphanum_fraction": 0.6937472152, "num_tokens": 8498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4160257004378983}}
{"text": "\\documentclass[acmsmall,nonacm, screen]{acmart}\n\\acmConference[]{}{}{}\n\n\\usepackage{xspace}\n\\usepackage{enumitem}\n\\setlist[itemize]{leftmargin=*}\n\n\\newcommand{\\lang}{Sized CC$_\\omega$\\xspace}\n\\newcommand{\\CICE}{CIC$_\\mathrm{E}$\\xspace}\n\\newcommand{\\our}{my\\xspace}\n\\newcommand{\\Our}{My\\xspace}\n\\newcommand{\\we}{I\\xspace}\n\\newcommand{\\We}{I\\xspace}\n\n% Each submission (referred to as “abstract” below) should include the student author’s name and e-mail address;\n% institutional affiliation; research advisor’s name; ACM student member number; category (undergraduate or graduate)\n\\title{Towards a Syntactic Model of Sized Dependent Types}\n\\author{Jonathan Chan}\n\\email{jcxz@cs.ubc.ca} % why doesn't this show up?\n\\affiliation{\n  \\institution{University of British Columbia}\n  \\city{Vancouver}\n  \\country{Canada},\n  \\href{mailto:jcxz@cs.ubc.ca}{jcxz@cs.ubc.ca} \\\\\n  Graduate student (MSc.) advised by William J. Bowman\n}\n\n\\begin{document}\n\\maketitle\n\n\\section{Termination Checking for Dependent Type Theories}\n\nThe types-as-propositions paradigm associates certain type theories with formal logical systems,\nand consequently types in those theories with propositions in those logics.\nFurthermore, well-typed programs are associated with proofs of the corresponding proposition.\nMany dependent type theories, for instance, correspond to higher-order logics,\nand having an automated type checker means having the ability to automatically verify proofs.\n\nOne must be careful, however, not to allow nonterminating programs,\nbecause they correspond to logical inconsistencies, i.e. proofs of falsehood.\nAdditionally, in dependent type checkers where programs may be evaluated during type checking,\nfailure to rule out nonterminating programs leads to nonterminating type checking.\nContemporary proof assistants based on dependent type theories, such as Coq, Agda, Lean, Idris,\nand many more, typically restrict recursive functions to \\emph{structurally-recursive} ones,\nwhere the argument of recursive calls must be \\emph{syntactically} smaller,\npeeling away layers of constructors until a base case is reached.\nType checkers in these proof assistants use \\emph{guard predicates}~\\citep{guard-predicate} to ensure the restriction.\n\nHowever, the guard predicate is often \\emph{too} restrictive to accept a variety of recursive functions\nfor which termination is otherwise evident to the discerning programmer.\nIn particular, functions recurring on subarguments that have first been passed to other functions\nknown not to add any more layers of constructors must surely terminate,\nbut since the recursive argument is not \\emph{syntactically} the subargument,\nthe guard predicate does not hold.\n\nSome type checkers will inline function definitions for the purpose of termination checking,\nbut this reliance on other function definitions makes code non-modular,\nand inlining very large definitions could severely negatively impact type checking performance.\nFurthermore, the syntactic nature of the guard predicate makes it sensitive to minor syntactic changes,\nand a subtle refactoring of a function inlined in later functions could affect whether\nthose functions even pass termination checking at all!\nIn short, a syntactic guard predicate goes against good programming practices.\n\n\\section{Type-Based Termination Checking}\n\nAn alternative to syntactic termination checking is to instead use \\emph{type-based} termination checking,\nwhere if a recursive function type checks without involving any other termination conditions,\nthen it is guaranteed to terminate.\nOne such method uses \\emph{sized types}~\\citep{hughes}, where inductive types carry additional size information.\nIntuitively, the size is a measure of how many layers a member of that type contains,\nand constructors must have a greater size than its subarguments.\nThe types of functions then carry information about whether it affects the size of its argument,\nmeaning that no inlining is required --- only the type is needed, not the whole definition.\n\nSized types have been implemented in Agda and can be enabled with the \\texttt{-\\hspace{0em}-sized-types} pragma.%\n\\footnote{Unfortunately, the implementation is inconsistent due to the presence of an \\emph{infinite size},\nwhich is defined to be the size strictly greater than all other sizes, including itself.}\nIt encludes sophisticated features like first-class sizes and bounded size quantification.\nThere is also a large body of theoretical work on sized types in various type systems,\nbut none of them quite satisfy all of the desirable features.\n\n\\begin{itemize}\n  \\item \\citet{cic-hat}, \\citet{cic-hat-minus-nat}, \\citet{cic-hat-minus}, and \\citet{cc-hat-omega}\n    introduce and prove consistent a lineage of Calculi of (Co)Inductive Constructions (CIC) with sized types,\n    but only prenex size quantification is possible: one cannot, for instance,\n    pass around a higher-order function quantifying over a size.\n  \\item \\citet{abel-diss}, \\citet{flationary}, and \\citet{f-omega-cop}\n    introduce not only higher-rank size quantification but also bounded size quantification,\n    the latter of which eliminates the need for complex monotonicity checks or syntactic approximations thereof.\n    However, these type systems extend System F$_{\\omega}$ rather than a dependent type theory.\n  \\item \\citet{nbe-sized} prove normalization of a higher-rank sized dependent type theory with naturals,\n    but without bounded size quantification.\n\\end{itemize}\n\n\\textbf{In ongoing work, \\we seek to prove the logical consistency of \\lang,\na higher-rank sized dependent type theory with bounded size quantification.}\nRather than using very involved set-theoretic methods like in Sacchini's dissertation~\\citep{cic-hat-minus}\nor the normalization by evaluation technique in~\\citet{nbe-sized}\nwhich requires a typed definitional equality judgement in the type theory,\n\\we instead define a \\emph{syntactic model}~\\citep{syntactic-models} into Extensional CIC (\\CICE)~\\citep{CCE}.\nThat is, \\we need to define a compiler from \\lang to \\CICE, then prove that it is \\emph{type-preserving}:\ngiven some well-typed term in \\lang, if both the term and its type are translated to \\CICE,\nthen the translated term should also be well typed against the translated type.\nBecause \\CICE is known to be consistent, and an inconsistency in \\lang\nimplies the existence of an inconsistency in \\CICE via the type-preserving compilation,\ninconsistency of \\lang would be a contradiction.\n\n\\section{Syntactic Model of \\texorpdfstring{\\lang}{Sized CCω}}\n\n\\lang is a Generalized Calclulus of Constructions with definitions (CC$\\omega$)~\\citep{universes} ---\nthat is, a Calculus of Constructions with untyped equality, a cumulative universe hierarchy, and \\texttt{let} expressions ---\nextended with bounded and unbounded size quantification, abstraction, and application,\nas well as size expressions consisting of size variables, a base size, and a size successor operation.\n\\We further add naturals and W types only, but these should scale directly to inductive types in general.\n\nIn \\lang, the natural type and W types are parametrized by some size, and their constructors quantify\nover a bounded size representing the strictly smaller size of recursive subarguments.\nIn \\CICE, \\we define a \\texttt{Size} inductive type representing the sizes in \\lang,\nand an indexed inductive type \\texttt{\\_$\\leqslant$\\_} on \\texttt{Size}\nrepresenting the ordering relation used in bounded quantification and abstraction.\nThe natural type and W types then compile to corresponding inductive types literally parametrized by \\texttt{Size},\nand whose constructors take proofs of strict inequality of two \\texttt{Size}s.\n\nThe majority of the remaining translation is straightforward,\nespecially for universes, functions, \\texttt{let} expressions, and \\texttt{case} expressions.\nBounded size quantification and abstraction correspond to quantification and abstraction\nover a \\texttt{Size} and an inequality, and correspondingly for unbounded ones.\nBut what about fixpoints?\n\nThe typing rule for fixpoints in \\lang has as premise the well-typedness of its body\nin an environment where the fixpoint itself is in scope, but quantifying over a smaller size.\nThe key insight is that fixpoints now correspond to \\emph{well-founded induction} over sizes,\nrather than structural induction.\nTo show that well-founded induction indeed holds for \\texttt{Size},\n\\we first show that all \\texttt{Size}s satisfy an \\emph{accessibility predicate}~\\citep{wfind};\nwell-founded induction then follows by a structurally-inductive proof over the predicate.\nFixpoints in \\lang then translate immediately to applications of well-founded induction.\n\nNow that a translation from \\lang to \\CICE is established, \\we show that it is type preserving.\nBecause \\lang uses an untyped equality judgement, \\we can use standard techniques for showing type preservation~\\citep{compiling}.\nAn important proof detail is that equality reflection (and therefore extensionality) is required\nto show an $\\eta$-equivalence rule for \\texttt{case} expressions\nand to show that proofs of accessibility are equal,\nwhich are properties used to prove that the translations of an applied fixpoint and its reduction in \\lang\nare definitionally equal in \\CICE.\n\n\\section{Status and Future Work}\n\nThe work is not yet done;\nthere remain unresolved problems with the model,\nand additional features to add that one would expect\nfrom a practically-useable sized dependent type theory.\n\n\\subsection{Universe Levels and \\texttt{Size}}\n\nTo be able to assign sizes to \\emph{general inductive types} such as W types,\nwhich conceptually can have transfinitely many recursive subarguments,\n\\texttt{Size} itself must be able to express the same transfinitivity.\nTherefore, its inductive definition in \\CICE mirrors that of \\emph{Brouwer ordinals}~\\citep{ordinals},\nalthough the domain of the function in the size corresponding to the limit ordinal is an arbitrary type $A$\nrather than merely the usual natural numbers.\n\\texttt{Size} itself must then live in a universe higher than that of $A$,\naccording to the usual well-formedness restrictions on inductive types.\n\nRecall that the natural type and W types in \\lang are parametrized by \\texttt{Size}.\nGiven a W type with type parameters $A : \\texttt{Type}_\\ell$ and $B : A \\rightarrow \\texttt{Type}_\\ell$,\nthe type used in limit sizes for the W type would also be $A$.\nMeanwhile, the naturals aren't transfinite, so we simply have $A \\coloneq \\bot : \\texttt{Type}_0$, the uninhabited type.\nUnfortunately, since \\texttt{Size} itself would then live in\n\\texttt{Type}$_{\\ell+1}$ and \\texttt{Type}$_1$, respectively,\nso must the W type and the natural type,\nrather than in \\texttt{Type}$_{\\ell}$ and \\texttt{Type}$_0$ as one would expect.\nIntuitively, \\texttt{Size} itself must be ``large enough'' (in the type universe sense)\nto include all sizes of naturals and elements of W types,\nwhich makes it ``too large'' to live in the same universe as what it should include.\n\nOne unsatisfactory solution would be to accept the natural type and W types living in larger universes\nthan they normally would in an unsized dependent type theory.\nAnother solution would be to parametrize \\texttt{Size} itself by the limit size's type $A$,\nwhich would allow it to live in the same universe as $A$.\nHowever, the translation of sizes and size quantifications and abstractions would have\nan underdetermined parameter, and sizes used for one inductive could not be used for another.\n\n\\subsection{The Infinite Size}\n\nIn nearly all past work on sized types, including the Agda implementation,\nthere is a notion of an infinite size $\\infty$ that is strictly larger than all sizes,\nincluding itself: the relation $\\infty < \\infty$ holds.\n\\lang does not have the infinite size, because this property would make sizes no longer well-founded,\nundermining all efforts to interpret fixpoints as applications of well-founded induction.\nIn fact, this is why sized types are inconsistent in Agda:\ndependent types make it possible to internalize the order on sizes as an inductive type within Agda itself,\nfrom which well-foundedness can be proven, yielding falsehood when combined with $\\infty < \\infty$.\nFinding a suitable replacement for uses of $\\infty$ that capture its convenience while retaining consistency\nremains an open problem.\nOne possibility is to use an existentially size-quantified inductive type in place of the $\\infty$-sized inductive%\n%\\footnote{Dually, the $\\infty$-sized \\emph{coinductive} type would be \\emph{universally} size-quantified.},\nbut it appears this might require a nonconstructive axiom that does not compute.\n\n\\subsection{Coinductive Types}\n\nAside from termination checking, sized types are also used for\n\\emph{productivity checking} of \\emph{corecursive} definitions,\nmaking reasoning about corecursive constructions much easier.\nIf \\lang is indeed consistent, \\we expect that extending the language and the proofs\nto include sized coinductive types would be relatively straightforward.\n\n\\bibliography{SRC}\n\\bibliographystyle{ACM-Reference-Format}\n\\end{document}", "meta": {"hexsha": "bb9f191cef86682515a153fff6f71f6e0b941564", "size": 13115, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SRC/SRC.tex", "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SRC/SRC.tex", "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SRC/SRC.tex", "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.4523809524, "max_line_length": 130, "alphanum_fraction": 0.7996950057, "num_tokens": 3022, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.41602568692216635}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#5}\n\\newcommand{\\hmwkDueDate}{Due on 20th November, 2018}\n\\newcommand{\\hmwkClass}{Advanced Quantum Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n(\\textbf{Acknowledgements} - I would like to thank Chandramouli Chowdhury, Sarthak Duary and Junaid Majeed for discussions.)\n\\\\\n\n\\begin{homeworkProblem}[1]\n\t\\textbf{Part (a)}\\\\\n\tWe first note that,\n\t\\begin{align*}\n\t\\lambda e^{-t/\\tau} \\mel{n}{x^2}{m} &= \\lambda e^{-t/\\tau}  \\mel{n}{\\dfrac{(a_+ + a_-)^2}{2m\\omega}}{m} \\\\\n\t&=\\lambda e^{-t/\\tau}  \\mel{n}{\\dfrac{a_+^2 + a_-^2 + a_+ a_- + a_- a_+}{2m\\omega}}{m}\\\\\n\t&= \\lambda e^{-t/\\tau} \\dfrac{1}{2 m \\omega} \\qty[\\sqrt{(m+1)(m+2)} \\delta_{n,m+2} + \\sqrt{m(m-1)} \\delta_{n, m-2} + (2m-1) \\delta_{n,m}]\n\t\\end{align*}\n\tAs is evident from above, a state $ \\ket{m} $ can transition into  $ \\ket{m}, \\ket{m+2}, \\ket{m-2} $ and no other states under a potential with spatial dependence that goes as $ x^2 $. In general, the $ k $-th order coefficient $ c^k_n(t) $ will have $ k $ terms of the form $ \\mel{.}{x^2}{.} $. If we start out with ground state $ \\ket{0} $, the final state will have contributions from the following states order by order\n\t\\begin{align*}\n\t\\order{\\lambda} &\\rightarrow \\ket{0}, \\ket{2} \\\\\n\t\\order{\\lambda^2} &\\rightarrow \\ket{0}, \\ket{2}, \\ket{4} \\\\\n\t\\order{\\lambda^3} &\\rightarrow \\ket{0}, \\ket{2}, \\ket{4}, \\ket{6} \\\\ \n\t\\therefore \\order{\\lambda^k} &\\rightarrow \\ket{0}, \\ket{2}, \\ket{4}, \\ldots \\ket{2k}\n\t\\end{align*}\n\tHence, we see that the $ \\ket{n} $ as mentioned in the question should be such that $ n $ is even, and the leading order contribution to the probability will $ \\sim (\\lambda^{n/2})^2 \\sim \\lambda^n $.\\\\\n\t\n\t\\textbf{Part (b)}\\\\\n\tAs described above, upto $ \\order{\\lambda^2} $ in probability (ie upto $ \\order{\\lambda} $ in the coefficients), $ \\ket{2} $ is the only excited state that can be reached. From $ (5.7.17) $ of Sakurai, we have the relations, (with $ \\ket{i,t_0;t} = \\sum c_n(t) \\ket{n} $)\n\t\\begin{equation*}\n\tc_n^0 (t) = \\delta_{ni} \\qq{,} c_n^1 (t) = -i \\int_{t_0}^{t} e^{i \\omega_{ni} t'} V_{ni}(t') dt'\n\t\\end{equation*}\n\tLet's calculate $ c_n^1 (t) $,\n\t\\begin{align*}\n\tc_n^1 (t) &=  -i \\lambda \\int_{0}^{t} e^{i n \\omega t'} \\mel{n}{ x^2}{0} e^{-t'/\\tau} dt' \\\\\n\t&= \\dfrac{-i \\lambda}{2 m \\omega} (\\sqrt{2} \\delta_{n,2} + \\delta_{n,0}) \\int_{0}^{t} e^{i n \\omega t'}  e^{-t'/\\tau} dt'\\\\\n\tc_n^1 (t) &= \\dfrac{-i \\lambda}{2 m \\omega} (\\sqrt{2} \\delta_{n,2} + \\delta_{n,0} )\\dfrac{e^{i n \\omega t}  e^{-t/\\tau} - 1}{i n \\omega - 1/\\tau} \\\\\n\t\\implies c_2^1 (t) &= \\dfrac{-i \\lambda }{\\sqrt{2} m \\omega}  \\dfrac{e^{2 i \\omega t}  e^{-t/\\tau} - 1}{2 i \\omega - 1/\\tau} \\implies  \\abs{c_2^1 (t)}^2 = \\dfrac{\\lambda^2 }{{2} m^2 \\omega^2}  \\dfrac{ e^{-2t/\\tau} + 1 - 2 e^{-t / \\tau } \\cos 2 \\omega t}{4 \\omega^2 + 1/\\tau^2} \n\t\\end{align*}\n\t$ \\abs{c_2^1}^2 $ is the required probability.\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[2]\n\t\n\tWe don't need to apply any perturbation theory in this problem, and it can be solved exactly. The Hamiltonian is $ H = \\lambda S_1 \\cdot S_2 = \\lambda( S^2 - S_1^2 - S_2^2 ) $. We consider the action of the Hamiltonian on the singlet state $ \\ket{0 0} = \\dfrac{\\ket{+ -} - \\ket{- +}}{\\sqrt{2}}$ and $ \\ket{1 0 }  = \\dfrac{\\ket{+ -} + \\ket{- +}}{\\sqrt{2}} $. We know $ H \\ket{00} = -3\\lambda /4 \\ket{00}  $ and $ S^2 \\ket{10} = \\lambda/4 \\ket{10} $. Initially the system is in $ \\ket{+-} = \\dfrac{\\ket{00} + \\ket{10}}{\\sqrt{2}} $. Then we know, by the usual rules of time-evolution,\n\t\\begin{align*}\n\t\\ket{\\psi_f(t)} = e^{i H t} \\ket{+-} &= \\dfrac{e^{i\\lambda t/4}}{\\sqrt{2}} \\ket{10} + \\dfrac{e^{-i3\\lambda t/4}}{\\sqrt{2}} \\ket{00}\\\\\n\t&= \\qty(\\dfrac{e^{i\\lambda t/4}  +{e^{-i3\\lambda t/4}}}{2}) \\ket{+-} + \\qty(\\dfrac{e^{i\\lambda t/4}  - {e^{-i3\\lambda t/4}}}{2}) \\ket{-+}\\\\\n\t\\implies \\abs{\\ip{+-}{{\\psi_f(t)}}}^2 &= \\abs{\\qty(\\dfrac{e^{i\\lambda t/4}  +{e^{-i3\\lambda t/4}}}{2})}^2  = \\dfrac{1 + \\cos \\lambda t}{2} =  P(\\ket{+-})\\\\\n\t\\implies \\abs{\\ip{-+}{{\\psi_f(t)}}}^2 &= \\abs{\\qty(\\dfrac{e^{i\\lambda t/4}  - {e^{-i3\\lambda t/4}}}{2})}^2  = \\dfrac{1 - \\cos \\lambda t}{2} = P(\\ket{-+})\\\\\n\t\\implies \\abs{\\ip{++}{{\\psi_f(t)}}}^2 &= 0 =  P(\\ket{++})\\\\\n\t\\implies \\abs{\\ip{--}{{\\psi_f(t)}}}^2 &= 0 =  P(\\ket{--})\n\t\\end{align*}\n\twhere $ P(\\ket{}) $ denotes probability of initial state to be in state $ \\ket{} $.\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[3]\n\t\\textbf{Part (a)}\\\\\n\tFrom $ (5.7.17) $ of Sakurai, we have the relations, (with $ \\ket{i,t_0;t} = \\sum c_n(t) \\ket{n} $)\n\t\\begin{equation*}\n\tc_n^0 (t) = \\delta_{ni} \\qq{,} c_n^1 (t) = -i \\int_{t_0}^{t} e^{i \\omega_{ni} t'} V_{ni}(t') dt' \n\t\\end{equation*}\n\tFor our problem, we have $ V = \\lambda \\delta (x - vt) $. We insert $ 1 = \\int dx \\ket{x} \\bra{x} $ such that $ V_{ni}(t) = \\int V(t) u_i^* (x) u_n (x) dx $. We have initial state $ u_i (x) $ and final state $ u_f(x) $. Hence, we can write the above coefficients as,\n\t\\begin{align*}\n\tc_f^1 (t) &= -i \\lambda \\int_{-\\infty}^{\\infty} dx \\int_{0}^{t} dt' e^{i (E_i - E_f) t'} \\delta(x - vt') u_i^* (x) u_f (x)  \\\\\n\t &= -i \\lambda \\int_{-\\infty}^{\\infty} dx  e^{i (E_i - E_f) x/v}  u_i^* (x) u_f (x) \n\t\\end{align*}\n\tHence the probability is just $ \\abs{c_f^1}^2 $\n\t\n\t\\textbf{Part (b)}\\\\\n\tWe now write,\n\t\\begin{equation*}\n\t\\delta(x-vt) = \\dfrac{1}{2 \\pi v} \\int_{- \\infty}^{\\infty} d\\omega  e^{i\\omega (x/v - t)}\n\t\\end{equation*}\n\t\\begin{align*}\n\t\\therefore c_f^1 (t) &= -i \\lambda \\int_{-\\infty}^{\\infty} dx \\int_{0}^{t} dt' e^{i (E_i - E_f) t'} \\dfrac{1}{2 \\pi v} \\int_{- \\infty}^{\\infty} d\\omega  e^{i\\omega (x/v - t')} u_i^* (x) u_f (x)  \\\\\n\t&= \\dfrac{-i \\lambda}{2 \\pi v} \\int_{-\\infty}^{\\infty} dx \\int_{0}^{t} dt' e^{i (E_{if} - \\omega) t'}  \\int_{- \\infty}^{\\infty} d\\omega  e^{i\\omega x/v} u_i^* (x) u_f (x)  \\\\\n\t&=  \\dfrac{-i \\lambda}{2 \\pi v} \\int_{-\\infty}^{\\infty} dx \\int_{- \\infty}^{\\infty} d\\omega \\delta(E_{fi} - \\omega)  e^{i\\omega x/v } u_i^* (x) u_f (x)4\n\t\\end{align*}\n\tIntegrating the above will give us the same expression as that is Part (a). We notice that there is this $ \\delta (E_{fi} - \\omega) $ term, which basically ensures energy conservation.\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[4]\n\tThe ground state wavefunction for a hydrogen-like atom is given by,\n\t\\begin{equation*}\n\t\\ket{0_Z} = \\dfrac{1}{\\sqrt{\\pi}} \\qty(\\dfrac{Z}{a_0})^{3/2} e^{-Zr/a_0}\n\t\\end{equation*}\n\tWe need to find $ \\abs{\\ip{0_2}{0_1}}^2 $,\n\t\\begin{align*}\n\t\\ip{0_2}{0_1} &= \\dfrac{1}{\\pi} \\qty(\\dfrac{2}{a_0^2})^{3/2} \\int_{0}^{2\\pi} d \\phi \\int_{0}^{\\pi} -d(\\cos\\theta)  \\int_{0}^{\\infty} dr r^2 e^{-3r/a_0} \\\\\n\t&= \\dfrac{1}{\\pi} \\qty(\\dfrac{2}{a_0^2})^{3/2} (4 \\pi) \\qty(\\dfrac{2 a_0^3}{27})\\\\\n\t\\ip{0_2}{0_1} &= \\sqrt{8} \\dfrac{8}{27}\\\\\n\t\\implies \\abs{\\ip{0_2}{0_1}}^2 &\\approx 0.7\n\t\\end{align*}\n\tSo, the probability is close to $ 0.7 $.\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{homeworkProblem}[5]\n\t\\textbf{Part (a)}\\\\\n\tWe first note for $ \\ket{\\psi_I(t)} = \\sum_{n} {c_n(t) \\ket{\\alpha_n}} $\n\t\\begin{align*}\n\ti \\pdv{\\ket{\\psi_I}}{t} &= i \\pdv{(e^{iH_0t} \\ket{\\psi_S})}{t} \\\\\n\t&= i \\qty[e^{iH_0t}\\pdv{\\ket{\\psi_S}}{t}  + iH_0 e^{iH_0t} \\ket{\\psi_S}]\\\\\n\t&= -e^{iH_0t} (H_0 + V) \\ket{\\psi_S} - H_0 e^{iH_0t} \\ket{\\psi_S}\\\\\n\t&=e^{iH_0t}  V \\ket{\\psi_S}\\\\\n\t\\end{align*}\n\t\n\t\\begin{align*}\n\ti \\pdv{\\ket{\\psi_I}}{t} &= V_I \\ket{\\psi_I}\\\\\n\ti \\pdv{\\ip{\\alpha_n}{\\psi_I}}{t} &=  \\mel{\\alpha_n}{V_I}{\\psi_I}\\\\\n\t\\dot{c_n} &= -i  \\mel{\\alpha_n}{V_I}{\\psi_I}\\\\\n\t\\dot{c_n} &= -i  \\mel{\\alpha_n}{V}{\\alpha_m} e^{i{(E_n - E_m)t}} c_m\n\t\\end{align*}\n\tSo for the given problem, we have\n\t\\begin{align*}\n\t\\ket{\\psi_I(t)} &=  {c_1(t) \\ket{1} + c_2(t) e^{iEt} \\ket{2}}\t\\\\\n\t\\dot{c_1} = -i V_{11} c_1 - i V_{12} e^{-iEt} c_2 = - i \\gamma e^{i (\\omega-E) t} c_2  &\\qq{and} \\dot{c_2} = -i V_{21}  e^{iEt}  c_1 - i V_{22}c_2 = -i \\gamma e^{i(E-\\omega)t} c_1\n\t\\end{align*} \n\tTo solve the above equations, we make the substitution $  c_1 = b_1 e^{i\\Delta t} $ and $c_2 = b_2 e^{-i \\Delta t}  $, where $ 2 \\Delta = \\omega - E$. We then have the equations in terms of $ b $'s,\n\t\\begin{equation*}\n\ti \\dot{b_1} = \\Delta b_1 + \\gamma b_2 \\qq{and} i \\dot{b_2} = \n\t\\gamma b_1 - \\Delta b_2\n\t\\end{equation*}\n\tThese are coupled equations, and we can solve these by making the substitution $ b_1 = A e^{i \\Omega t} $ and $  b_2 = B e^{i \\Omega t} $. We then have,\n\t\\begin{align*}\n\t- A \\Omega = \\Delta A + \\gamma B &\\qq{and} - B \\Omega = \\gamma A - \\Delta B \\\\\n\t\\qq{For non-trivial solutions,} -\\dfrac{\\gamma}{\\Delta + \\Omega} &= \\dfrac{\\Delta - \\Omega}{\\gamma} \\implies \\Omega = \\pm \\sqrt{\\gamma^2 + \\Delta^2} = \\pm \\Omega_0\\\\\n\t\\implies c_1 = A_1 e^{i(\\Delta + \\Omega_0)t} + A_2 e^{i(\\Delta - \\Omega_0)t} &\\qq{and}  c_2 = B_1 e^{i(-\\Delta + \\Omega_0)t} + B_2 e^{i(-\\Delta - \\Omega_0)t}\n\t\\end{align*}\n\tWe are told that at $ t=0 $, the system is in state $ \\ket{1} \\implies c_1(0) = 1, c_2(0) = 0 \\implies A_1 = 1 - A_2, B_1 = - B_2$. We also know that $ \\dot{c}_2(0) = - i \\gamma c_1 (0) $ and $ \\dot{c}_1(0) = - i \\gamma c_2 (0)  $ which means,\n\t\\begin{align*}\n\t-i (1-A_1) \\Omega_0 +i A_1 \\Omega_0 +i \\Delta =0 &\\implies A_1 = \\frac{\\Omega_0 -\\Delta }{2 \\Omega_0 } \\qq{and}  A_2 = -\\frac{\\Omega_0 -\\Delta }{2 \\Omega_0 }\\\\\n\t2 i B_1 \\Omega_0 =-i \\gamma &\\implies B_1 = -\\frac{\\gamma }{2 \\Omega_0 } \\qq{and} B_2 = 1 + \\frac{\\gamma }{2 \\Omega_0 } \\\\\n\t \\implies c_1 =  \\frac{\\Omega_0 -\\Delta }{2 \\Omega_0 } e^{i(\\Delta + \\Omega_0)t} -\\frac{\\Omega_0 -\\Delta }{2 \\Omega_0 } e^{i(\\Delta - \\Omega_0)t} &\\qq{and}  c_2 = -\\frac{\\gamma }{2 \\Omega_0 }  e^{i(-\\Delta + \\Omega_0)t} + \\qty(1 + \\frac{\\gamma }{2 \\Omega_0 }) e^{i(-\\Delta - \\Omega_0)t}\n\t\\end{align*}\n\twhere $ \\Delta = \\dfrac{\\omega - E}{2} $ and $ \\Omega_0 = \\sqrt{\\gamma^2 + \\Delta^2} $\\\\. We calculate $ \\abs{c_2(t)}^2 $ using Mathematica, and we get,\n\t\\begin{equation*}\n\t \\abs{c_2(t)}^2 = \\frac{\\gamma ^2 \\sin ^2(t \\Omega_0 )}{\\Omega_0 ^2} \\qq{and}\t\\abs{c_1(t)}^2 = 1 - \\frac{\\gamma ^2 \\sin ^2(t \\Omega_0 )}{\\Omega_0 ^2}\n\t \\end{equation*}\n\t\\textbf{Part (b)}\\\\\n\tTo prove to all orders in perturbation, we consider $ \\omega = E \\implies \\Omega_0 = \\gamma \\implies \\abs{c_2(t)}^2 = {\\sin ^2(t \\gamma)} $. From the Dyson series, we have,\n\t\\begin{equation*}\n\tc_2^n (t) =  \\bra{2} (-i)^n \\int_{0}^{t} dt' \\ldots \\int_{0}^{t^{(n-1)}} dt^n V_I (t') \\ldots V_I(t^{(n)}) \\ket{1}\n\t\\end{equation*}\n\tInserting a complete set of state before each $ V_I $\n\t\\begin{equation*}\n\tc_2^n (t) =  \\bra{2} (-i)^n \\int_{0}^{t} dt' \\ldots \\int_{0}^{t^{(n-1)}}  dt^n V_I (t') (\\ket{1} \\bra{1} + \\ket{2} \\bra{2}) \\ldots  (\\ket{1} \\bra{1} + \\ket{2} \\bra{2}) V_I(t^{(n)}) \\ket{1}\n\t\\end{equation*}\n\tThere is a constraint that the initial state should be $ \\ket{1} $ and the final state should be $  \\ket{2} $. Since, $  \\ket{1} \\rightarrow \\ket{2} $ and $  \\ket{2} \\rightarrow \\ket{1} $ at each application of $ V_I $, terms with even $ n $ will vanish. For terms with odd $ n $, let's first consider $ n=3 $\n\t\\begin{align*}\n\tc_2^3 (t) &=   (-i)^3 \\int_{0}^{t} dt' \\int_{0}^{t'} dt'' \\int_{0}^{t''} dt'''  \\mel{2}{V_I(t')}{1} \\mel{1}{V_I(t'')}{2} \\mel{2}{V_I(t''')}{1} \\\\\n\t&=   (-i)^3 \\int_{0}^{t} dt' \\int_{0}^{t'} dt'' \\int_{0}^{t''} dt'''  \\mel{2}{V_I(t')}{1} \\mel{1}{V_I(t'')}{2} \\mel{2}{V_I(t''')}{1}\\\\\n\t&=   (-i\\gamma)^3 \\int_{0}^{t} dt' \\int_{0}^{t'} dt'' \\int_{0}^{t''} dt'''  e^{iEt'} \\mel{2}{V(t')}{1} e^{iEt''} \\mel{1}{V(t'')}{2} e^{iEt''} \\mel{2}{V(t''')}{1} \\\\\n\t&=   (-i \\gamma)^3 \\int_{0}^{t} dt' \\int_{0}^{t'} dt'' \\int_{0}^{t''} dt'''  e^{iEt'} e^{-iEt'}  e^{iEt''}  e^{-iEt''}  e^{iEt''} e^{-iEt''} \\\\\n\t&=   (-i \\gamma)^3 \\dfrac{t^3}{3!} \n\t\\end{align*}\n\tWe see that because $ \\omega = E $, all the matrix elements become independent of $ t $, and we get a very simple answer for $ c_2^n = (-i \\gamma)^n \\dfrac{t^n}{n!}  $. Hence,\n\t\\begin{equation*}\n\tc_2 (t) = \\sum_{\\qq{odd n}}(-i \\gamma)^n \\dfrac{t^n}{n!} = -i \\sin t \\gamma  \\implies  \\abs{c_2(t)}^2  = \\sin^2 t \\gamma\n\t\\end{equation*}\n\tHence the formula is verified.\n\\end{homeworkProblem}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "d67d2a5a1da18012ac182fc2e849951086371531", "size": 15239, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/qmech/assign_5/assign_5.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/qmech/assign_5/assign_5.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/qmech/assign_5/assign_5.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2132963989, "max_line_length": 582, "alphanum_fraction": 0.6024673535, "num_tokens": 6483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.41599268295986397}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{fullpage}\n\\usepackage{amsthm}\n\\usepackage{amsfonts,amsmath, amssymb,latexsym,mathrsfs}\n\\usepackage[margin=1.15in]{geometry}\n\\usepackage{enumitem}\n\\setlength{\\parindent}{0pt}\n\\usepackage{tikz-cd}\n\\usepackage{fancyhdr}\n\n\n\n\n\\theoremstyle{definition}\n\\newtheorem{thm}{Theorem}[section]\n\n\\newtheorem{prop}{Proposition}[section]\n\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\n\\theoremstyle{remark}\n\\newtheorem*{remark}{Remark}\n\n\\theoremstyle{definition}\n\\newtheorem{example}{Example}[section]\n\n\n\\theoremstyle{definition}\n\\newtheorem{lem}{Lemma}[section]\n\n\n\\theoremstyle{definition}\n\\newtheorem{cor}{Corollary}[section]\n\n\n\\date{}\n\\title{Final Exam Summary(After Exam 2)}\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Power Series}\n\\begin{definition}\n\tA power series about $x = a$ is a sum of constants times powers of $(x - a)$: \n\t$C_0 + C_1(x - a) + C_2(x - a)^2 + \\ldots + C_n(x - a)^n + \\ldots =\t\\sum_{n\n\t=0}^{\\infty}\tC_n(x - a)^n$.\n\\end{definition}\n\nIf we fix a specific value of $x$, we can just consider plugging x with the value we have, and convergence here makes sense.\n\n\\begin{definition}\nFor a fixed value of $x$, if this sequence of partial sums converges to a limit $L$, that is, if\n$\\lim_{n \\to \\infty}S_n(x) = L$, then we say that the power series converges to $L$ for this value of $x$.\n\\end{definition}\n\nBased on the discussion we will see that, The interval of convergence for a power series is usually centered at a point $x=a$, and extends the same length to both side, thus we denote this length as radius of convergence.\\\\\n\nMoreover, each power series falls into one of the three following cases, characterized by its \\textcolor{red}{radius of convergence}, $R$.\n\\begin{itemize}\n\\item The series converges only for $x = a$; the radius of convergence is defined to be $R = 0$.\n\\item The series converges for all values of $x$; the radius of convergence is defined to be\n$R = \\infty$.\n\\item There is a positive number $R$, called the radius of convergence, such that the series\nconverges for $|x - a| < R$ and diverges for $|x - a| > R$. \n\\end{itemize}\nThe interval of convergence is the interval between $a - R$ and $a + R$, including any\nendpoint where the series converges.\n\\\\\n\nThen there is a question arises, how to find this radius of convergence then?\\\\\n\nThis question can be determined by considering using \\textcolor{red}{ratio test} on the series, assuming $x\\neq a$.\nThe details are included in Chapter 9.5 in the book.\n\n\\section{Taylor Polynomial and Taylor Series}\n\\subsection{Taylor Polynomial}\nIf we try to approximate the function locally using a polynomial, there is one thing we want to acquire, i.e. we want the polynomial $P(x)$ with the property that $P^{(n)}(a)=f^{(n)}(a)$ if we approximate the function at the point $x=a$. Considering merely the situation about $x=0$, recall what we did in the class, we will have the following.\n\n\\textcolor{red}{Taylor Polynomial of Degree $n$ Approximating $f(x)$ for $x$ near $0$} is \\[f(x) \\approx P_n(x)\n\t= f(0) + f'(0)x + \\frac{f''(0)}{2!}x^2 + \\frac{f'''(0)}{3!}x^3 + \\frac{f^{(4)}(0)}{4!} x^4 + \\ldots + \\frac{f^{(n)}(0)}{n!} x^n\\]\n\tWe call $P_n(x)$ the Taylor polynomial of degree $n$ centered at $x = 0$, or the Taylor poly\n\tnomial about $x = 0$.\\\\\n\t\nMore generally, \\textcolor{red}{Taylor Polynomial of Degree $n$ Approximating $f(x)$ for $x$ near $a$} is \\[f(x) \\approx P_n(x)\n= f(a) + f'(a)(x-a) + \\frac{f''(a)}{2!}(x-a)^2 + \\frac{f'''(a)}{3!}(x-a)^3  + \\ldots + \\frac{f^{(n)}(a)}{n!} (x-a)^n\\]\nWe call $P_n(x)$ the Taylor polynomial of degree $n$ centered at $x = a$, or the Taylor poly\nnomial about $x =a$.\\\\\n\nNotice that Taylor Polynomial of Degree $n$ Approximating $f(x)$ for $x$ near $a$ will have the property that $P_n^{(m)}(a)=f^{(m)}(a)$ for $0 \\leq m \\leq n$.\n\n\\subsection{Taylor Series}\n\nNotice that in the Taylor polynomial, if we let $n$ here goes to infinity, we will get a series $P(x)$ with $P^{(m)}(a)=f^{(m)}(a)$ for $0 \\leq m < \\infty$ and thus we will expect that the series gives a good approximation about $f(x)$ around $a$, and actually when it converges, it is exactly the value you will get in $f(x)$, and this is called the Taylor Series.\n\n\\textcolor{red}{Taylor Series for $f(x)$ about $x=0$} is \\[f(x) = f(0) + f'(0)x + \\frac{f''(0)}{2!}x^2 + \\frac{f'''(0)}{3!}x^3 + \\frac{f^{(4)}(0)}{4!} x^4 + \\ldots + \\frac{f^{(n)}(0)}{n!} x^n+ \\ldots \\]\nWe call $P_n(x)$ the Taylor polynomial of degree $n$ centered at $x = 0$, or the Taylor poly\nnomial about $x = 0$.\\\\\n\nMore generally, \\textcolor{red}{Taylor Series for $f(x)$ about $x=a$} is \\[f(x) = f(a) + f'(a)(x-a) + \\frac{f''(a)}{2!}(x-a)^2 + \\frac{f'''(a)}{3!}(x-a)^3  + \\ldots + \\frac{f^{(n)}(a)}{n!} (x-a)^n+ \\ldots \\]\nWe call $P_n(x)$ the Taylor polynomial of degree $n$ centered at $x = a$, or the Taylor poly\nnomial about $x =a$.\\\\\n\n\nMoreover, there are \\textcolor{red}{several important cases} that we consider, each of them is an Taylor expansion of a function about $x=0$:\n\\begin{itemize}\n\\item \\[e^{x}= 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!} + \\frac{x^5}{5!} + \\frac{x^6}{6!} + \\frac{x^7}{7!} + \\frac{x^8}{8!} + \\cdots\\text{ converges for all } x\\]\n\\item \\[\\sin(x)=\\sum\\limits_{n=0}^\\infty \\dfrac{x^{2n+1}}{(2n+1)!}\\cdot(-1)^n = x-\\dfrac{x^3}{3!}+\\dfrac{x^5}{5!}-\\dfrac{x^7}{7!}+\\dots\\text{ converges for all } x\\]\n\\item \\[\\cos(x)=\\sum\\limits_{n=0}^\\infty \\dfrac{x^{2n}}{(2n)!}\\cdot(-1)^n = 1-\\frac{x^2}{2!}+\\frac{x^4}{4!}-\\frac{x^6}{6!}+\\dots \\text{ converges for all } x\\]\n\\item \\[(1 + x)^p = \\sum_{k=0}^{\\infty} \\binom{p}{k} x^k= \\sum_{k=0}^{\\infty} \\frac{p!}{k!(p-k)!} x^k=\\]\\[1 + px + \\frac{p(p - 1)}{2!}x^2 + \\frac{p(p - 1)(p - 2)}{3!}x^3 + \\cdots \\text{ converges for } -1 < x < 1.\\]\n\\item \\[\\ln(1+x) =\\sum_{n = 0}^{\\infty}\\frac{(-1)^nx^{n+1}}{n+1}= x-\\frac{x^2}{2}+\\frac{x^3}{3}-\\frac{x^4}{4}+\\cdots,\\]\n\n\\end{itemize}\n\nMoreover, we can definitely find Taylor Series based on the existing series using \\textcolor{red}{four methods}:\n\\begin{itemize}\n\t\\item Substitude\n\t\nExample: Taylor Series about $x=0$ for $f(x)=e^{-x^2}$\t\n\t\n\t\\item Differentiate \n\t\nExample: Taylor Series about $x=0$ for $f(x)=\\frac{1}{(1-x)^2}$\t\n\n\t\\item Integrate\n\t\nExample: Taylor Series about $x=0$ for $f(x)=\\arctan x$ (Hint: What is $\\frac{d}{dx}(\\arctan x)$?)\t\t\t\n\t\\item Multiply\n\t\n\tExample: Taylor Series about $x=0$ for $f(x)=x^2 \\sin x$\\\\\n\tExample: Taylor Series about $x=0$ for $f(x)=\\sin x \\cos x$\\\\\n\tExample: Taylor Series about $x=0$ for $f(x)=e^{\\sin x}$\\\\\n\n\\end{itemize}\n\n\\section{Parametric Equations and Polar Coordinate}\n\\subsection{Parametric Equations}\nTo represent the motion of a particle in the $xy$-plane we use two equations, $x=f(t)$ and $y=g(t)$, then at the time $t$ the particle is at the location $(f(t),g(t)$. In this case, we call the equations for $x$ and $y$ the parametric equations, with parametrization $t$.\n\nRemember that, in parametric equation, for the same line, the parametrization is not unique, and the different parametrization encodes two information:\\\\\n1. Speed of the particle.\\\\\n2. Direction of the motion.\\\\\n\n\\subsubsection{Special Parametric Equations}\n\n\\begin{itemize}\n\\item \\textcolor{red}{Parametric Equations for a Straight Line}\n\nAn object moving along a line through the point $(x_0, y_0)$, with $dx/dt = a$ and $dy/dt = b$,\nhas parametric equations\n$x = x_0 + at, y = y_0 + bt$.\nThe slope of the line is $m = b/a$.\n\\item\\textcolor{red}{Parametric Equations for a circle with radius $k$}\n\nAn object moving along a circle of radius $k$ counterclockwise has parametric equations\n$x = k\\cos(t), y = k\\sin(t)$.\n\\end{itemize}\n\n\n\\subsubsection{Slope and concavity of the curve}\nAs we discussed in class, we can think of this as a result due to chain rule if we have that $y=F(x)$ as well. \n\nBut to summarize, we have the \\textcolor{red}{slope} of the parametrized curve to be \n\\[\\frac{dy}{dx}=\\frac{dy/dt}{dx/dt}\\]\nand the \\textcolor{red}{concavity} of the parametrized curve to be\n\\[\\frac{d^2y}{dx^2}=\\frac{(dy/dx)/dt}{dx/dt}\\]\n\n\\subsubsection{Speed and distance}\n\nThe \\textcolor{red}{instantaneous speed} of a moving object is defined to be\n$$v = \\sqrt{(dx/dt)^2 + (dy/dt)^2} =\\sqrt{(v_x)^2 + (v_y)^2}$$.\nThe quantity $v_x = dx/dt$ is the instantaneous velocity in the $x$-direction; $v_y = dy/dt$ is the\ninstantaneous velocity in the $y$-direction.\nAnd we call that $(v_x,v_y)$ to be the velocity vector.\n\nMoreover, the \\textcolor{red}{distance} traveled from time $a$ to $b$ is $$\\int^b_a v(t) dt = \\int_a^b \\sqrt{(dx/dt)^2 + (dy/dt)^2} dt$$\n\n\\subsection{Polar Coordinate}\n\nPolar coordinates is the coordinates determined by specifying the distance of the point to origin and the angle measured counterclockwise from positive $x$-axis to the line joining the line connecting the point and the origin.\n\n\\subsubsection{Relation between Cartesian and Polar}\n\n\\textcolor{red}{Cartesian to Polar}: $$(x,y) \\to (r= \\sqrt{x^2 + y^2}, \\theta) \\text{ (Here we have that } \\tan \\theta = \\frac{y}{x} \\text{)}$$\nNote that $\\theta$ does not have to be $\\arctan(\\frac{y}{x})$!\n\nPolar to Cartesian: $$(r,\\theta) \\to (x=r \\cos \\theta, y=r \\sin \\theta)$$\n\n\\subsubsection{Slope, Arc length and Area in Polar Coordinates}\n\nBy the relation $x=r \\cos \\theta, y=r \\sin \\theta$, given a curve $r=f(\\theta)$, we have that $x=f(\\theta) \\cos \\theta, y=f(\\theta) \\sin \\theta$, and thus are parametrized equations of parameter $\\theta$. Therefore we have that the \\textcolor{red}{slope} of to be \n\\[\\frac{dy}{dx}=\\frac{dy/d\\theta}{dx/d\\theta}\\]\n\nThe \\textcolor{red}{arc length} from angle $a$ to $b$ is $$\\int_a^b \\sqrt{(dx/d\\theta)^2 + (dy/d\\theta)^2} d\\theta=\\int_a^b \\sqrt{r^2 + (dr/d\\theta)^2} d\\theta$$\n\nMoreover, due to the fact that the \\textcolor{red}{area of the sector} is $1/2 r^2 \\theta$, we have that for a curve $r = f(\\theta)$, with \\textcolor{red}{$f(\\theta)$ continuously of the same sign}, the area of the region enclosed is $$\\frac{1}{2}\\int^{b}_{a}f(\\theta)^2 d\\theta$$\n\n\n\\end{document} ", "meta": {"hexsha": "d55f46cadbf8fe8fd292fdab0b3757441bdfab6f", "size": 9958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "m116wn21/Note/FinalReview/finalsummary.tex", "max_stars_repo_name": "yiwchen/yiwchen.github.io", "max_stars_repo_head_hexsha": "80ba7f9b24fa6a666d2d7f0f4b4c41a9aa1822c8", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "m116wn21/Note/FinalReview/finalsummary.tex", "max_issues_repo_name": "yiwchen/yiwchen.github.io", "max_issues_repo_head_hexsha": "80ba7f9b24fa6a666d2d7f0f4b4c41a9aa1822c8", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "m116wn21/Note/FinalReview/finalsummary.tex", "max_forks_repo_name": "yiwchen/yiwchen.github.io", "max_forks_repo_head_hexsha": "80ba7f9b24fa6a666d2d7f0f4b4c41a9aa1822c8", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5422885572, "max_line_length": 365, "alphanum_fraction": 0.6716208074, "num_tokens": 3449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.8006920020959544, "lm_q1q2_score": 0.4159765674053582}}
{"text": "\\documentclass[paper=a4, fontsize=11pt]{scrartcl} \n\n\\usepackage[T1]{fontenc} \n\\usepackage[english]{babel}\n\\usepackage{amsmath,amsfonts,amsthm}\n\n\\usepackage{pstricks}\n\\usepackage{auto-pst-pdf}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{multicol}\n\\usepackage{multirow}\n\\usepackage{hhline}\n\n\\usepackage{lipsum}\n\n\\usepackage{graphicx}\n\\usepackage{float}\n  \\floatplacement{figure}{H}\n  \\floatplacement{table}{H}\n  \n\\usepackage{sectsty} \n\\allsectionsfont{\\centering \\normalfont\\scshape} \n\n\\usepackage{fancyhdr} % Custom headers and footers\n\\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers\n\\fancyhead{} % No page header - if you want one, create it in the same way as the footers below\n\\fancyfoot[L]{} % Empty left footer\n\\fancyfoot[C]{} % Empty center footer\n\\fancyfoot[R]{\\thepage} % Page numbering for right footer\n\\renewcommand{\\headrulewidth}{0pt} % Remove header underlines\n\\renewcommand{\\footrulewidth}{0pt} % Remove footer underlines\n\\setlength{\\headheight}{13.6pt} % Customize the height of the header\n\n\\usepackage[labelformat=empty]{caption}\n\\usepackage{color}\n\\usepackage{listings}\n\\lstset{ %\nlanguage=bash,                % choose the language of the code\nbasicstyle=\\footnotesize,       % the size of the fonts that are used for the code\nnumbers=left,                   % where to put the line-numbers\nnumberstyle=\\footnotesize,      % the size of the fonts that are used for the line-numbers\nstepnumber=1,                   % the step between two line-numbers. If it is 1 each line will be numbered\nnumbersep=5pt,                  % how far the line-numbers are from the code\nbackgroundcolor=\\color{white},  % choose the background color. You must add \\usepackage{color}\nshowspaces=false,               % show spaces adding particular underscores\nshowstringspaces=false,         % underline spaces within strings\nshowtabs=false,                 % show tabs within strings adding particular underscores\nframe=single,           % adds a frame around the code\ntabsize=2,          % sets default tabsize to 2 spaces\ncaptionpos=b,           % sets the caption-position to bottom\nbreaklines=true,        % sets automatic line breaking\nbreakatwhitespace=false,    % sets if automatic breaks should only happen at whitespace\nescapeinside={\\%*}{*)}          % if you want to add a comment within your code\n}\n\\usepackage{hyperref}\n\n\n\\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\n\\setlength\\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text\n\n%----------------------------------------------------------------------------------------\n%\tTITLE SECTION\n%----------------------------------------------------------------------------------------\n\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} % Create horizontal rule command with 1 argument of height\n\n\\title{\t\n\\normalfont \\normalsize \n\\textsc{Computational Science} \\\\ [25pt] % Your university, school and/or department name(s)\n\\horrule{0.5pt} \\\\[0.2cm] % Thin top horizontal rule\n\\small Homework - Introduction to Frontiers of Computational Science\\\\ % The assignment title\n%\\horrule{2pt} \\\\[0.5cm] % Thick bottom horizontal rule\n}\n\n\\author{\\small{Ridlo W. Wibowo || 1215011069}} % Your name\n\n\\date{\\small\\today} % Today's date or a custom date\n\n\n\\begin{document}\n\\maketitle % Print the title\n\n\\section{Problem 1}\nSolve the following equations:\n\\begin{equation}\n\\label{eq:satu}\n\\frac{d}{dt} x_1(t) = \\dot{x}_1 =  \\mu(-x_1(t) +   x_2(t)         )\n\\end{equation}\n\\begin{equation}\n\\label{eq:dua}\n\\frac{d}{dt} x_2(t) = \\dot{x}_2 =  \\mu( x_1(t) - 2x_2(t) + x_3(t))\n\\end{equation}\n\\begin{equation}\n\\label{eq:tiga}\n\\frac{d}{dt} x_3(t) = \\dot{x}_3 =  \\mu(            x_2(t) - x_3(t))\n\\end{equation}\nwhere $x_i(0) = x^0_i$ ($i=1,2,3$).\\\\\n\n\n\\textbf{Answer}\\\\\nif we sum all the equations we obtain:\n\\begin{equation}\n\\label{eq:jwb1}\n\\dot{x}_1 + \\dot{x}_2 + \\dot{x}_3 = 0\n\\end{equation}\nthen if we substract \\eqref{eq:satu} with \\eqref{eq:tiga}, we obtain:\n\\begin{equation}\n\\label{eq:jwb2}\n\\dot{x}_1 - \\dot{x}_3 = -\\mu(x_1 - x_3)\n\\end{equation}\nalso, we can sum \\eqref{eq:satu} and \\eqref{eq:dua} then substract it with two times \\eqref{eq:dua}, and we will get:\n\\begin{equation}\n\\label{eq:jwb2}\n\\dot{x}_1 - 2\\dot{x}_2 + \\dot{x}_3 = -3 \\mu(x_1 - 2x_3 + x_3)\n\\end{equation}\n\nthe solution:\n\\begin{equation}\n\\label{eq:sol1}\n(x_1 + x_2 + x_3)_{(t)} = (x_1 + x_2 + x_3)_{(0)}\n\\end{equation}\n\\begin{equation}\n\\label{eq:sol2}\n(x_1 - x_3)_{(t)} = (x_1 - x_3)_{(0)} e^{-\\mu t}\n\\end{equation}\n\\begin{equation}\n\\label{eq:sol3}\n(x_1 - 2x_2 + x_3)_{(t)} = (x_1 - 2x_2 + x_3)_{(0)} e^{-3 \\mu t}\n\\end{equation}\n\nif we add two times \\eqref{eq:sol1} with \\eqref{eq:sol3}:\n\\begin{equation}\n(x_1 + x_3)_{(t)} = \\frac{1}{3} x_1^{(0)} ( 2 + e^{-3\\mu t}) + \\frac{2}{3} x_2^{(0)} ( 1 - e^{-3\\mu t}) + \\frac{1}{3} x_3^{(0)} (2 + e^{-3\\mu t})\n\\end{equation}\noperate with \\eqref{eq:sol2}:\n\\begin{equation}\n\\label{eq:fin1}\nx_1^{(t)} = \\frac{1}{6} x_1^{(0)} ( 2 + e^{-3\\mu t} + e^{-\\mu t}) + \\frac{1}{3} x_2^{(0)} ( 1 - e^{-3\\mu t}) + \\frac{1}{6} x_3^{(0)} ( 2 + e^{-3\\mu t} - e^{-\\mu t})\n\\end{equation}\n\\begin{equation}\n\\label{eq:fin2}\nx_3^{(t)} = \\frac{1}{6} x_1^{(0)} ( 2 + e^{-3\\mu t} - e^{-\\mu t}) + \\frac{1}{3} x_2^{(0)} ( 1 - e^{-3\\mu t}) + \\frac{1}{6} x_3^{(0)} ( 2 + e^{-3\\mu t} + e^{-\\mu t})\n\\end{equation}\nif we substract \\eqref{eq:sol1} with \\eqref{eq:sol3}:\n\\begin{equation}\n\\label{eq:fin3}\nx_2^{(t)} = \\frac{1}{3} x_1^{(0)} ( 1 - e^{-3\\mu t}) + \\frac{1}{3} x_2^{(0)} ( 1 + 2e^{-3\\mu t}) + \\frac{1}{3} x_3^{(0)} ( 1 - e^{-3\\mu t})\n\\end{equation}\n\nso we get the solutions for this problem in equation \\eqref{eq:fin1}, \\eqref{eq:fin2}, and \\eqref{eq:fin3}. We also can use eigenvalue problem to get the same result.\n\n%\\begin{figure}\n%\t\\centering\n%\t\\includegraphics[width=0.8\\textwidth]{verlet2.png}\n%\t\\caption{Comparison of the result from Verlet algorthm using different $\\Delta t$.}\n%\\end{figure}\n\n\\newpage\n\\section{Problem 2}\nCheck if $\\begin{pmatrix} 1 \\\\ 1 \\\\ 1\\end{pmatrix}$, $\\begin{pmatrix} 1 \\\\ 0 \\\\ -1\\end{pmatrix}$, and $\\begin{pmatrix} 1 \\\\ -2 \\\\ 1\\end{pmatrix}$ are orthogonal to each others. Normalize and check the unitary condition.\\\\\n\n\n\\textbf{Answer}:\\\\\nfor orthogonality we can use dot product to each pair of vector:\n$v_{i} \\cdot v_{j} = 0$ for $i \\neq j$, easily we can prove that all combination resulting zero dot product. For example:\\\\\n$ v_1 \\cdot v_2 = \\begin{pmatrix} 1 \\\\ 1 \\\\ 1 \\end{pmatrix} \\cdot \\begin{pmatrix} 1 \\\\ 0 \\\\ -1 \\end{pmatrix} = 1\\cdot 1 + 1 \\cdot 0 + 1 \\cdot -1 = 0 $\\\\\n\nNormalize vector would be $(e_1, e_2, e_3)$:\\\\\n$\\frac{1}{\\sqrt{3}} \\begin{pmatrix} 1 \\\\ 1 \\\\ 1 \\end{pmatrix}$, $\\frac{1}{\\sqrt{2}} \\begin{pmatrix} 1 \\\\ 0 \\\\ -1 \\end{pmatrix}$, and $\\frac{1}{\\sqrt{6}} \\begin{pmatrix} 1 \\\\ -2 \\\\ 1 \\end{pmatrix}$\n\nChecking unitary relation\\\\\n$Q = \\begin{pmatrix} \\frac{1}{\\sqrt{3}} & \\frac{1}{\\sqrt{2}} & \\frac{1}{\\sqrt{6}} \\\\ \n\\frac{1}{\\sqrt{3}} & 0 & \\frac{-2}{\\sqrt{6}} \\\\\n\\frac{1}{\\sqrt{3}} & \\frac{-1}{\\sqrt{2}} & \\frac{1}{\\sqrt{6}}\n\\end{pmatrix}$\\\\\n\n\nif we inverse it using $Q^{-1} = \\frac{1}{\\det(Q)} (adj(Q))$, this matrix will become:\\\\\n\n\n$Q^{-1} = \n\\begin{pmatrix} \n\\frac{1}{\\sqrt{3}} & \\frac{1}{\\sqrt{3}} & \\frac{1}{\\sqrt{3}}\\\\ \n\\frac{1}{\\sqrt{2}} & 0 & \\frac{-1}{\\sqrt{2}} \\\\\n\\frac{1}{\\sqrt{6}} & \\frac{-2}{\\sqrt{6}} & \\frac{1}{\\sqrt{6}}\n\\end{pmatrix}$\\\\\n\n\nand the unitary relation is proven $Q^{-1} = Q^{T}$\n\n\n\\begin{postscript}\n\\psset{fillstyle=solid}\n\\psscalebox{0.75}{%\n\\begin{pspicture}(-5.25,-5.25)(5.25,5.25)%\n  \\pscircle*[linecolor=cyan]{5}\n  \\psgrid[subgriddiv=0,gridcolor=lightgray,gridlabels=0pt]\n  \\Huge\\sffamily\\bfseries\n  \\rput(-4.5,4.5){A} \\rput(4.5,4.5){B}\n  \\rput(-4.5,-4.5){C}\\rput(4.5,-4.5){D}\n  \\rput(0,0){auto-pst-pdf}\n  \\rmfamily\n  \\rput(0,-3.8){PSTricks}\n  \\rput(0,3.8){\\LaTeX}\n\\end{pspicture}}\n\\end{postscript}\n\n\\scalebox{1} % Change this value to rescale the drawing.\n{\n\\begin{pspicture}(0,-2.69)(5.38,2.69)\n\\psframe[linewidth=0.04,dimen=outer](5.38,2.69)(0.0,-2.69)\n\\psframe[linewidth=0.04,dimen=outer](4.34,1.53)(1.2,-1.61)\n\\psframe[linewidth=0.04,dimen=outer](2.18,1.31)(1.48,0.61)\n\\psframe[linewidth=0.04,dimen=outer](3.16,-0.79)(2.48,-1.47)\n\\end{pspicture} \n}\n\n\\end{document}", "meta": {"hexsha": "098b18bb0b315bc4ca51e7ee72df751e877d821e", "size": 8516, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CFD/tugas4/CFD_fourth.tex", "max_stars_repo_name": "ridlo/kuliah_sains_komputasi_3", "max_stars_repo_head_hexsha": "18c94cbd0154d8f80110b8e012356ea445308c3c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CFD/tugas4/CFD_fourth.tex", "max_issues_repo_name": "ridlo/kuliah_sains_komputasi_3", "max_issues_repo_head_hexsha": "18c94cbd0154d8f80110b8e012356ea445308c3c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CFD/tugas4/CFD_fourth.tex", "max_forks_repo_name": "ridlo/kuliah_sains_komputasi_3", "max_forks_repo_head_hexsha": "18c94cbd0154d8f80110b8e012356ea445308c3c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0178571429, "max_line_length": 221, "alphanum_fraction": 0.6370361672, "num_tokens": 3244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.8006920020959544, "lm_q1q2_score": 0.41597656740535816}}
{"text": "\\section{Data} \\label{sec:data}\n\n\nIn this paper I've selected 11 differenct stocks, to run my analysis on. The companies are:\n\\textit{Apple, General Electric, Boeing, Walmart, Coca Cola, JP Morgan Chase, Chevron, Cardinal Health, Exxon Mobile, IBM, Intel}. The companies have been chosen because they represent different sectors of the economy, and all of them have been going concerns for +30 years. The data covers the period: January 1990 to June 2019. The data consists of daily the Adjusted Close price. The data is acquired using a public API provided by \\textit{Quandle}.\n\n\\begin{table}[ht]\n\\centering\n\\caption{Summary statistics of all 11 stocks}\n\\input{tables/describe.tex}\n\\label{tab:rawdata}\n\\end{table}\n\nTable \\ref{tab:rawdata} shows summary statistics of the raw data. On average 7114 observations is present for the total time period of 30 years. Figure \\ref{fig:historicaltraces} presents all 11 traces. From this figure we can quickly deduce that the timeseries does not show stationarity, and in the long run follows an upward trend. For the analysis carried out in this paper, a transformation of the data is therefore necessary.\nInstead of investigating stock prices, the focus will be on daily percentage change in stock prices. The summary statistics of this is shown in figure \\ref{tab:cleandata}. Where the count of this now cleansed data is 7113. Additional to finding the percentage change of daily stock prices, rows containing NaN-values have been purged. In the appendix figure \\ref{fig:returns_boxplots} shows the boxplot of the individual stocks expected daily return\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[scale=0.45]{figures/historicaltraces.png}\n\\caption{Historical trace plots of all 11 stocks}\n\\label{fig:historicaltraces}\n\\end{figure}\n\n\\begin{table}[ht]\n\\centering\n\\caption{Summary statistics of all 11 stocks, percentage change}\n\\input{tables/cleandescribe.tex}\n\\label{tab:cleandata}\n\\end{table}\n\n\\subsection{Structural Breaks in the data}\n\n\nThis paper assumes that the underlying data generating process of the stock market experiences structural breaks. To confirm this whether or not the data display structural breaks we continue with a visual inspection of the expected returns and covariances of the returns.\n\nFigure \\ref{fig:structuralbreaksmeans} displays the bi-annual means of 4 stocks, these being Apple, General Electric, Boeing and Walmart. The displayed stocks are chosen randomly, and it is confirmed in the data that the same pattern is present in the other stocks. The figure shows the expected daily return on each of the stocks for a given year in the sequence: $1992, 1992, 1994, \\cdots, 2018$. So for each of the calculated means, we have a one year period, where no mean is calculated. This is to avoid, that a possible structural break could be between two years an disturb the picture. This figure shows, as suspected, that the returns does not seem to adhere to the CAPM assumptions, of a single a vector of expected returns $\\mu$, since this would imply that for each year each stock would have the approximately same expected return, which is not what the data displays. The same is true for the covariance matrix $\\Omega$ which can be seen in the appendix figure \\ref{fig:structuralbreakscovariances}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[scale=0.45]{figures/structural_breaks_means.png}\n\\caption{Bi-annual means of 4 stocks}\n\\label{fig:structuralbreaksmeans}\n\\end{figure}\n", "meta": {"hexsha": "a8cfc001b92a1339dffa9986a27bbe86f581d70b", "size": 3458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/data.tex", "max_stars_repo_name": "JakartaLaw/ACFS", "max_stars_repo_head_hexsha": "dd7e6107ae22e987923dd5b81a8605d88650fce9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-04T01:20:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-04T01:20:46.000Z", "max_issues_repo_path": "chapters/data.tex", "max_issues_repo_name": "JakartaLaw/ACFS", "max_issues_repo_head_hexsha": "dd7e6107ae22e987923dd5b81a8605d88650fce9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-03-24T17:21:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-13T20:09:54.000Z", "max_forks_repo_path": "chapters/data.tex", "max_forks_repo_name": "JakartaLaw/ACFS", "max_forks_repo_head_hexsha": "dd7e6107ae22e987923dd5b81a8605d88650fce9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-07T07:34:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-07T07:34:46.000Z", "avg_line_length": 78.5909090909, "max_line_length": 1013, "alphanum_fraction": 0.7969924812, "num_tokens": 823, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813031051514763, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.41587819377588336}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage[utf8]{luainputenc}\n\\usepackage{aeguill}\n\\usepackage{setspace}\n\n\\tikzstyle{edge} = [fill,opacity=.5,fill opacity=.5,line cap=round, line join=round, line width=50pt]\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\pgfdeclarelayer{background}\n\\pgfsetlayers{background,main}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{9 février, 2015}\n\\maketitle\n{\\bfseries hypergraph} $H$ is a set $V$ called the vertex set together with nonempty subsets of $V$ called edges.\n\\subsubsection*{example}\n\\begin{enumerate}\n\\item\nevery  graph is a hypergraph. in a graph all edges are size $2$. \n\\item\n$H: V=\\{1,2,3,4\\}, E=\\{\\{1,2,4\\},\\{2,3,4\\},\\{3,4,5\\}\\}$\n\\item\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n\\node[main_node] (1) at (-1,-1) {};\n\\node[main_node] (2) at (0,-1) {};\n\\node[main_node] (3) at (1,-1) {};\n\\node[main_node] (4) at (0,1) {};\n\\node[main_node] (5) at (1,1) {};\n\\begin{pgfonlayer}{background}\n\\draw[edge,color=yellow] (1) -- (2) -- (3);\n\\begin{scope}[transparency group,opacity=.5]\n\\draw[edge,opacity=1,color=green] (2) -- (3) -- (5);\n%\\fill[edge,opacity=1,color=green] (v3.center) -- (v5.center) -- (v6.center) -- (v3.center);\n\\end{scope}\n\\draw[edge,color=red,line width=40pt] (4) -- (5);\n\\end{pgfonlayer}\n\\end{tikzpicture}\n\\end{enumerate}\nif each edge has the same size then they are called {\\bfseries $k$-uniform}. degree still makes sense,as does multi vs simple\n\nwe can associate a bipartite graph to any hypergraph\n\n\nthe bipartite graph of $H$ has partites $V$ and $E$. it has edges from $v_i$ to $e_j$ if $v_i\\in e_j$\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n\\node[main_node] (5) at (-1,-1) {5};\n\\node[main_node] (6) at (0.5,1) {a};\n\\node[main_node] (4) at (0,-1) {4};\n\\node[main_node] (3) at (1,-1) {3};\n\\node[main_node] (1) at (0,1) {1};\n\\node[main_node] (2) at (1,1) {2};\n\\node[main_node] (7) at (-1.5,-1) {d};\n\\node[main_node] (8) at (0.5,-1) {c};\n\\node[main_node] (9) at (.5,0) {b};\n\\begin{pgfonlayer}{background}\n\\draw[edge,color=yellow] (5) -- (4) -- (3);\n\\begin{scope}[transparency group,opacity=.5]\n\\draw[edge,opacity=1,color=green] (2) -- (3) -- (4);\n%\\fill[edge,opacity=1,color=green] (v3.center) -- (v5.center) -- (v6.center) -- (v3.center);\n\\end{scope}\n\\draw[edge,color=red,line width=40pt] (1) -- (2);\n\\draw[edge,color=purple,line width=40pt] (5)--(5);\n\\end{pgfonlayer}\n\\end{tikzpicture}\n\\tikz\\path [graphs/.cd, nodes={shape=circle, draw, text=black,inner sep=1pt,outer sep=0pt}]\n%  graph [tree layout] { 1 -- a,a--2,2--b,b--3,3--c,b---4,4--c,5--d,c--5 }\n  graph [tree layout] {1--a--2--b--3--c--5--d, b--4--c}\n  [shift=(0:1)];\n\\subsubsection*{question}\ncan we construct a hypergraph out of a bipartite graph? no in general.\n\nrestriction: cannot have an isolated vertex on the edge side of hypergraph.\n\n$\\{\\text{hpergraphs}\\}\\leftrightarrow\\{\\text{hypergraphs w/ no isolated right side vertices}\\}$\n\n\\section*{adjacency matrices}\nthey still exist\n\na hypergraph $H=(V,E)$ is an $|V|\\times|E|$ matrix $A(H)$ such that $a_{ij}=1$ if $v_i\\in e_j$ or else $a_{ij}=0$\n\nexample:\n\\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n\\node[main_node] (5) at (-2,-2) {5};\n\\node[main_node] (6) at (1,2.3) {b};\n\\node[main_node] (4) at (0,-2) {4};\n\\node[main_node] (3) at (2,-2) {3};\n\\node[main_node] (3) at (2.5,-2) {e};\n\\node[main_node] (1) at (0,2) {1};\n\\node[main_node] (2) at (2,2) {2};\n\\node[main_node] (7) at (-1,0) {c};\n\\node[main_node] (8) at (1,-2) {d};\n\\node[main_node] (9) at (1.3,-.) {a};\n\\begin{pgfonlayer}{background}\n\\draw[edge,color=yellow] (5) -- (4) -- (3);\n\\begin{scope}[transparency group,opacity=.5]\n\\draw[edge,opacity=1,color=green] (2) -- (5) -- (4);\n%\\fill[edge,opacity=1,color=green] (v3.center) -- (v5.center) -- (v6.center) -- (v3.center);\n\\end{scope}\n\\draw[edge,color=red,line width=40pt] (1) -- (2);\n\\draw[edge,color=purple,line width=40pt] (1)--(3);\n\\draw[edge,color=blue,line width=40pt] (3)--(3);\n\\end{pgfonlayer}\n\\end{tikzpicture}\n\nthe transpose of $A(h)$ has another hypergraph associated to it called the dual of $H$. Denoted $H^*$. note $H^{**}=H$.\n\n\\subsection*{question:} how do hypergraph adjacency matrices compare to ``regular'' adjacency matrices?\n\nhypergraph:\nno symmetry, $A^T(H)\\ne A(H)$\nand $H^*\\ne H$\n\ngraph:\n$A^T(G)=A(G)$, $G^*=G$\n\nit turns out that the matrices are \\emph{very}  different. \n\\end{document}\n \n", "meta": {"hexsha": "907ff8d0c4fc3c4503e69fd7d87efc862f7fa08a", "size": 4633, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-02-09.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-02-09.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-02-09.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3664122137, "max_line_length": 125, "alphanum_fraction": 0.6602633283, "num_tokens": 1764, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.41587818339711075}}
{"text": "% !Mode:: \"TeX:UTF-8\"\n% !TEX program  = xelatex\n\\section{Conclusions and Discussions}\\label{S:conclusions}\nFrom this article, we introduce projectile motion and quadratic equation through a real world problem --- \\emph{what angle should we throw a football for maximum range}, then we give a proper and accurate definition of quadratic equation, from which we derive quadratic formula for solving quadratic equations. Furthermore, we list some useful applications of the quadratic equation and implement them in \\texttt{Python}.\n", "meta": {"hexsha": "bed411cab069f1ab71b0592efaf60ad6d9f8421c", "size": 529, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MA320/sections/quadratic_equation/conclusions.tex", "max_stars_repo_name": "iydon/homework", "max_stars_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2019-10-20T08:18:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-11T12:14:56.000Z", "max_issues_repo_path": "MA320/sections/quadratic_equation/conclusions.tex", "max_issues_repo_name": "iydon/homework", "max_issues_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2022-01-13T03:04:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T00:49:10.000Z", "max_forks_repo_path": "MA320/sections/quadratic_equation/conclusions.tex", "max_forks_repo_name": "iydon/homework", "max_forks_repo_head_hexsha": "253d4746528ef62d33eba1de0b90dcb17ec587ed", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-11-02T05:46:01.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-12T23:11:28.000Z", "avg_line_length": 105.8, "max_line_length": 421, "alphanum_fraction": 0.797731569, "num_tokens": 113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.41587817987003717}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Percentage Price Oscillator} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{The percentage price oscillator (PPO) is a momentum indicator that measures the difference between two moving averages as a percentage of the larger moving average. The moving averages are a 26-period and 12-period exponential moving average (EMA). The Percentage Price Oscillator is shown with a signal line, a histogram and a centerline. Signals are generated with signal line crossovers, centerline crossovers, and divergences. A bullish reversal of an asset is identify when the PPO cross above zero line.\n                 And a bearish reversal when the PPO cross below the zero line.\n}\n\n\\howtotrade\n{The strategy is to identify asset's price cycles.\nBullish Reversal - when PPO is above zero \\&\nBearish Reversal - when PPO is below zero.\n}\n\n\\ruleparameters %You can include however many arguments (in groups of 4) as you want!\n{Short term look back Length}{12}{Short term look back length used to compute EMA.}{$\\lookbacklength_{s}$}\n{Long term look back Length}{26}{Long term look back length used to compute EMA.}{$\\lookbacklength_{l}$}\n{Signal look back Length}{9}{Look back length used to generate Signal line.}{$S_{l}$}\n\\stoptable %must be included or Tex engine runs infinitely\n\n\\newpage\n\\section{Equation}\nBelow are the equations which govern how this specific trading rule calculates a trading position.\n\n\\begin{equation}\n    PPO = \\frac{EMA(\\lookbacklength_{s}) -         EMA(\\lookbacklength_{l})}{EMA(\\lookbacklength_{l})} \\times 100\n\\end{equation}\n\\begin{equation}\n    Signal = EMA(S_{l})\n\\end{equation}\n\\\\ % creates some space after equation\nwhere:\n\n$EMA(\\lookbacklength_{s})$: is the short term exponentially weighted average.\n\n$EMA(\\lookbacklength_{l})$: is the long term exponentially weighted average.\n\n$EMA(S_{l})$: is the exponentially weighted average computed to generate signal line.\n\n\\keyterms\n\\furtherlinks %The footer\n\\end{document}", "meta": {"hexsha": "f55dbfd7d6f6543610c9307d7f7b593b0cf660e0", "size": 2114, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/PercentagePriceOscillator.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/PercentagePriceOscillator.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/PercentagePriceOscillator.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 44.0416666667, "max_line_length": 526, "alphanum_fraction": 0.7686849574, "num_tokens": 536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.41587673215067095}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Relative Strength Index} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{The Relative Strength Index (RSI), developed by J. Welles Wilder, is a momentum indicator that measures the speed and change of price movements. It is an extremely popular indicator that is used to indicate overbought and oversold signals. RSI is considered overbought when above 70 and oversold when below 30. RSI can also be used to identify the general trend of an asset.\n                It can also be used for identifying bullish and bearish divergences.}\n\\ruleparameters %You can include however many arguments (in groups of 4) as you want!\n{Overbought}{70}{Overbought Condition}{$O_b$}\n{Oversold}{30}{Oversold Condition}{$O_s$}\n{Time Length}{14 Days}{Time frame on which the RSI is calculated}{$L$}\n\\stoptable %must be included or Tex engine runs infinitely\n\n\n\\section{Equation}\nBelow are the equations which govern how this specific trading rule calculates a trading position.\n\n\\begin{equation}\nRSI = 100-\\frac{100}{(1+RS)}\n\\end{equation}\n\\\\\nwith:\n\n$RSI$: is the relative strength index at $\\currenttime$\n\n$RS$: is the relative strength which is calculated using below formula.\n\n\\begin{equation}\nRS = \\frac{AvgU}{AvgD}\n\\end{equation}\n\\\\\nwith:\n\n$AvgU$ : average of all upward movements in the last $L$ price bars\n\n$AvgD$ : average of all downward movements in the last $L$ price bars\n\n$\\L$ : Time Length\n\n\\keyterms\n\\furtherlinks %The footer\n\\end{document}", "meta": {"hexsha": "e1edb0ba01ba6a1fae2fafbf5b0c3eed57d72632", "size": 1610, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/RelativeStrengthIndex.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/RelativeStrengthIndex.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/RelativeStrengthIndex.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 34.2553191489, "max_line_length": 391, "alphanum_fraction": 0.7633540373, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4158424290564837}}
{"text": "\\documentclass{article}\n\n\\usepackage{hyperref}\n\\usepackage{multicol}\n\\usepackage{listings}\n\n\\usepackage{ddphonism}\n\n\\title{The \\textsf{ddphonism} package\\footnote{This\n\t\tdocument corresponds to \\textsf{ddphonism} v0.2, dated 2019/09/01.}}\n\\author{Celia Rubio Madrigal\\footnote{Email: \\href{mailto:celirubio.m@gmail.com}{\\texttt{celirubio.m@gmail.com}}}}\n\\date{September 1, 2019}\n\n\n\\begin{document}\n\t\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\tThis is a music-related package focused on notation from the Twelve-Tone System, also called Dodecaphonism. It provides \\LaTeX{} algorithms that produce typical dodecaphonic diagrams based off a musical series, or row sequence, of variable length.\n\t\t\n\t\t\\begin{center}\n\t\t\t\\textbf{Keywords}\n\t\t\\end{center}\n\t\n\t\t\\textit{twelve tone system, dodecaphonism, music, mathematics, matrix, row, series, permutation, diagram, clock diagram, notation, algorithm, schoenberg, contemporary music, 20th century}\n\t\\end{abstract}\n\n\t\\tableofcontents\n\t\n\t\\section{Introduction}\n\tThere are hundreds of music tools and software online which are able to produce different music notations. However, I have never seen a \\LaTeX{} tool that can do the same. This package is not only about notation, but it also calculates mathematically how this notation should work.\n\t\n\tIt is said that a twelve-tone matrix is the only thing a twelve-tone composer should need, because it provides the whole serial spectrum with which they may work. I wanted \\LaTeX{} users to be able to generate them automatically.\n\t\n\tBut I also think that a twelve-tone matrix is not enough, that there exist several other notations with which they may understand their series and their potential. These are the diagrams that can be obtained with this package:\n\t\n\t\\begin{multicols}{2}\n\t\t\\dmatrix{4,3,2,1,0}\n\t\t\n\t\t\\ddihedral{4,5,7,1,6,3,8,2,11,0,9,10}\n\t\t\n\t\t\\ddiagram[arrow shift = 4]{4,5,7,1,6,3,8,2,11,0,9,10}\n\t\t\n\t\t\\darrows{4,5,7,1,6,3,8,2,11,0,9,10}\n\t\t\n\t\t\\bigskip\n\t\t\\drow{4,3,2,1,0}\n\t\\end{multicols}\n\t\n\t\\section{Using the \\textsf{ddphonism} package}\n\tThese are the commands provided by \\textsf{ddphonism}. The main parameter in every command is the row sequence.\n\t\n\t\\newcommand{\\I}[1]{\\item[\\texttt{$\\backslash$#1}]\\quad}\t\n\t\\newcommand{\\Ii}[1]{\\item[\\textsf{#1}]\\quad}\n\t\\begin{itemize}\n\t\t\\I{dmatrix} produces a twelve-tone matrix of arbitrary length, as shown in \\href{https:matrices.netlify.com}{this website}. For example, \\verb|\\dmatrix{0,2,1,4,3,6,5}| produces the matrix \\dmatrix{0,2,1,4,3,6,5}\n\n\t\t\\begin{itemize}\n\t\t\t\\Ii{sep} scales the matrix.\n\t\t\t\\Ii {vsep} scales the matrix vertically.\n\t\t\t\\Ii {hsep} scales the matrix horizontally.\n\t\t\t\\Ii{lines} draws lines between rows and columns.\n\t\t\t\\Ii{outside lines} only draws the outside lines.\n\t\t\t\\Ii{inside lines} only draws the inside lines.\n\t\t\t\\Ii{vlines} only draws the vertical lines.\n\t\t\t\\Ii{hlines} only draws the horizontal lines.\n\t\t\\end{itemize}\n\t\t\\verb|\\dmatrix[lines,sep=0.75]{0,2,1,4,3,6,5}| produces the matrix\n\t\t\n\t\t\\dmatrix[lines,sep=0.75]{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{no tikz} deletes the tikz environment and lets the user write it instead.\n\t\t\\end{itemize}\n\t\t\n\t\t\\I{ddiagram} produces a twelve tone clock diagram of arbitrary length, as shown in \\href{https:diagramas.netlify.com}{this website}. For example, \\verb|\\ddiagram{0,2,1,4,3,6,5}| produces the diagram\\\\ \n\t\t\\ddiagram{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{name} writes a name at the center of the diagram.\n\t\t\t\\Ii{up} lets the user choose which number is up north. The default value is the first number in the row.\n\t\t\t\\Ii{arrow shift} lets the user choose where the arrow should fall on the line. The values range from 0 to 10. The default value is 2.5.\n\t\t\\end{itemize}\n\t\t\n\t\t\\verb|\\ddiagram[name=P, up=5, arrow shift=5]{0,2,1,4,3,6,5}| produces the diagram\\\\\n\t\t\\ddiagram[name=P, up=5, arrow shift=5]{0,2,1,4,3,6,5}\n\t\t\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{no numbers} deletes the numbers around the diagram.\n\t\t\t\\Ii{no arrow} deletes the arrow inside the diagram.\n\t\t\\end{itemize}\n\t\t\n\t\t\\verb|\\ddiagram[no numbers, no arrow]{0,2,1,4,3,6,5}| produces the diagram\\\\\n\t\t\\ddiagram[no numbers, no arrow]{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{xshift} shifts the figure horizontally.\n\t\t\t\\Ii{yshift} shifts the figure vertically.\n\t\t\t\\Ii{no tikz} deletes the tikz environment and lets the user write it instead.\n\t\t\tThe option \\textsf{up} does not work anymore and the up position becomes 0.\n\t\t\tIt is recommended that the user passes the option \\textsf{ddiagram} to the environment:\n\t\t\t\\begin{verbatim}\n\t\t\t\\begin{tikzpicture}[ddiagram]\n\t\t\t\\ddiagram[no tikz]{0,2,1,4,3,6,5}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\end{verbatim} produces the same diagram as  \\verb|\\ddiagram{0,2,1,4,3,6,5}|.\n\t\t\\end{itemize}\n\t\t\n\t\t\\I{ddihedral} produces a dihedral representation of a series of arbitrary length. For example, \\verb|\\ddihedral{0,2,1,4,3,6,5}| produces the diagram\\\\\n\t\t\\ddihedral{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{t} applies the transformation \\textit{transposition} to the diagram.\n\t\t\t\\Ii{s} applies the transformation \\textit{inversion} to the diagram.\n\t\t\t\\Ii{c} applies the transformation \\textit{cyclic shift} to the diagram.\n\t\t\t\\Ii{v} applies the transformation \\textit{retrograde} to the diagram.\n\t\t\t\n\t\t\tThe transformations are applied in that exact order.\n\t\t\\end{itemize}\n\t\t\n\t\t \\verb|\\ddihedral[s=1, c=4]{0,2,1,4,3,6,5}| produces the diagram\\\\\n\t\t\\ddihedral[s=1, c=4]{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{no italics} removes the italics from the diagram name.\n\t\t\t\\Ii{new t} renames the transformation \\textit{transposition}.\n\t\t\t\\Ii{new s} renames the transformation \\textit{inversion}.\n\t\t\t\\Ii{new c} renames the transformation \\textit{cyclic shift}.\n\t\t\t\\Ii{new v} renames the transformation \\textit{retrograde}.\n\t\t\\end{itemize}\n\t\n\t\\verb|\\ddihedral[no italics, new v=R, v=1]{0,2,1,4,3,6,5}| produces the diagram\\\\\n\t\\ddihedral[no italics, new v=R, v=1]{0,2,1,4,3,6,5}\n\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{no tikz} deletes the tikz environment and lets the user write it instead. It is recommended that the user passes the option \\textsf{ddihedral} to the environment:\n\t\t\t\\begin{verbatim}\n\t\t\t\\begin{tikzpicture}[ddihedral]\n\t\t\t\\ddihedral[no tikz]{0,2,1,4,3,6,5}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\end{verbatim} produces the same diagram as  \\verb|\\ddihedral{0,2,1,4,3,6,5}|.\n\t\t\\end{itemize}\n\t\t\n\t\t\\I{darrows} produces the arrows from the \\verb|\\ddihedral| diagram. For example,\n \t\t\\verb|\\darrows{0,2,1,4,3,6,5}| produces the arrows\\\\\n \t\t\\darrows{0,2,1,4,3,6,5}\n \t\t\n \t\t\\begin{itemize}\n \t\t\t\\Ii{no tikz} deletes the tikz environment and lets the user write it instead.\n \t\t\\end{itemize}\n\t\t\n\t\t\\I{drow} produces a twelve-tone row sequence as a permutation in its matrix form. For example, \\verb|\\drow{0,2,1,4,3,6,5}| produces the row\n\t\t\n\t\t\\drow{0,2,1,4,3,6,5}\n\t\t\n\t\t\\begin{itemize}\n\t\t\t\\Ii{sep} lets the user choose the column separation.\n\t\t\\end{itemize}\n\t\t\n\t\t\\verb|\\drow[sep=10pt]{0,2,1,4,3,6,5}| produces the row\n\t\t\n\t\t\\drow[sep=10pt]{0,2,1,4,3,6,5}\n\t\t\n\t\\end{itemize}\n\t\n\t\\section{The package code}\t\n\t\\lstset{\n\t\tlanguage=[Latex]Tex,\n\t\t%\n\t\tbasicstyle=\\footnotesize\\sffamily,\n\t\tkeywordstyle=\\footnotesize\\sffamily,\n\t\tidentifierstyle=\\footnotesize\\sffamily,\n\t\tcommentstyle=\\footnotesize\\sffamily,\n\t\tstringstyle=\\footnotesize\\sffamily,\n\t\tescapechar=¬,\n\t\t%\t\t\n\t\tnumberstyle=\\footnotesize\\sffamily,%\\ttfamily\\tiny\\color[gray]{0.3},\n\t\tnumbers=left,\n\t\tstepnumber=2,\n\t\tnumbersep=15pt,\n\t\t%\n\t\tcolumns=flexible,\n\t\tshowstringspaces=false,\n\t\ttabsize=4,\n\t}\n\t\\lstinputlisting{ddphonism.sty}\n\t\n\\end{document}\n", "meta": {"hexsha": "2ddc249ef0395ded5a70e428bc7551e12b2e4807", "size": 7457, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ddphonism.tex", "max_stars_repo_name": "celrm/ddphonism", "max_stars_repo_head_hexsha": "312ff5f2f0584923accaa28adbfd532223457ae6", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-27T04:45:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T04:45:19.000Z", "max_issues_repo_path": "ddphonism.tex", "max_issues_repo_name": "celrm/ddphonism", "max_issues_repo_head_hexsha": "312ff5f2f0584923accaa28adbfd532223457ae6", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ddphonism.tex", "max_forks_repo_name": "celrm/ddphonism", "max_forks_repo_head_hexsha": "312ff5f2f0584923accaa28adbfd532223457ae6", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0418848168, "max_line_length": 282, "alphanum_fraction": 0.7124849135, "num_tokens": 2655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4158424290564837}}
{"text": "\\section{Galois correspondence of covering spaces}\nFor this section, fix a Galois cover $p: Y \\longrightarrow X$.\n\n\\begin{lemma}\n\\label{lemma:compositionOfCovers}\n  If $p$ factors through a space $Z$ as\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rd, \"p_1\"] \\ar[dd, \"p\"']\\\\\n        & Z \\ar[ld,\"p_2\"] \\\\\n      X\n    \\end{tikzcd}\n  \\end{equation*}\n  and if $p_2$ is a cover, then so is $p_1$.\n  In this case, we say that $Z$ is a cover \\emph{lying between $Y$ and $X$.}\n\\end{lemma}\n\\begin{qbox}\n  Prove Lemma \\ref{lemma:compositionOfCovers} by drawing pictures.\n\\end{qbox}\n\n\\begin{lemma}\n\\label{lemma:lemma2}\n  If $p_2:Z \\rightarrow X$ be a cover. Let $f$, $g$ be simplicial maps $Y \\rightarrow Z$ that fit into a commutative diagram\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rr, shift left, \"f\"] \\ar[rr, shift right, \"g\"']  \\ar[rd, \"p\"']\n      & & Z \\ar[ld,\"p_2\"] \\\\\n      & X\n    \\end{tikzcd}\n  \\end{equation*}\n  If $f(y_0) = g(y_0)$ for some vertex $y_0$ in $Y$ then $f = g$.\n\\end{lemma}\n\\begin{qbox}\n  Prove Lemma \\ref{lemma:lemma2} for vertices i.e. show that $f(y) = g(y)$ for all vertices $y$ in $Y$. To do this, take a path $\\gamma$ in $Y$ from $y_0$ to $y$, push it down to $X$ via $p$ and lift it up to $Z$ via $p_2$. Use induction on the length of $\\gamma$.\n\\end{qbox}\n\n\n\\begin{proposition}\n  If $Z$ is a cover lying between $Y$ and $X$, then $p_1: Y \\rightarrow Z$ is a Galois cover.\n\\end{proposition}\n\\begin{proof}\n  We have already shown that $p_1$ is a cover in Lemma \\ref{lemma:compositionOfCovers}.\n  In order to show that it is Galois we will use the criterion of Theorem \\ref{theorem:GaloisCriterion}:\n  ``$p_1$ is Galois if and only if $\\Gal(Y|Z)$ acts freely, transitively on all the fibers.''\n  First note that every deck transformation of $Y \\rightarrow Z$ is also a deck transformation of $Y \\rightarrow X$\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rr, \"\\varphi\"] \\ar[rd, \"p_2\"] \\ar[rdd, \"p\"']\n      & & Y \\ar[ld,\"p_2\"'] \\ar[ldd, \"p\"]\\\\\n      & Z \\ar[d] \\\\\n      & X\n    \\end{tikzcd}\n  \\end{equation*}\n  Hence $\\Gal(Y|Z)$ is a subgroup of $\\Gal(Y|X)$.\n  We want to show that $\\Gal(Y|Z)$ acts freely, transitively on the fibers $p_2^{-1}(Z)$.\n  The freeness is by Theorem \\ref{theorem:freenessGaloisAction} so we only need to prove transitivity.\n\n  Pick an arbitrary element $z$ in $Z$ and let $y_1$ and $y_2$ be elements in the fiber $p_2^{-1}(z)$.\n  As $Y \\rightarrow X$ is Galois, there is a deck transformation $\\varphi \\in \\Gal(Y|X)$ such that $\\varphi(y_1) = y_2$.\n\n  \\textbf{Claim:} $\\varphi$ is in $\\Gal(Y|Z)$.\n\n  To prove this claim, apply Lemma \\ref{lemma:lemma2} to the following commutative diagram\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rr, shift left, \"p_1\"] \\ar[rr, shift right, \"p_1 \\circ \\varphi\"']  \\ar[rd, \"p\"']\n      & & Z \\ar[ld,\"p_2\"] \\\\\n      & X\n    \\end{tikzcd}\n  \\end{equation*}\n  Check that we can apply lemma 2: 1) $\\varphi$ is a deck transformation of $p$, hence the diagram commutes. 2) $p_1(y_1) = p_1 \\circ \\varphi(y_1) = z$.\n  By Lemma \\ref{lemma:lemma2}, $p_1 = p_1 \\circ \\varphi$ i.e. $\\varphi$ is a deck transformation in $\\Gal(Y|Z)$.\n  Hence, the action of $\\Gal(Y|Z)$ on the fibers of $p_2$ is transitive.\n\\end{proof}\n\n\\begin{proposition}\n  If $Z$ is a cover lying between $Y$ and $X$, and $p_2:Z \\rightarrow X$ is Galois, then $\\Gal(Y|Z)$ is a normal subgroup of $\\Gal(Y|X)$, and\\footnote{This is equivalent to saying that the following sequence is exact. \\begin{equation*}\n    1 \\rightarrow \\Gal(Y|Z) \\rightarrow \\Gal(Y|X) \\rightarrow \\Gal(Z|X) \\rightarrow 1\n  \\end{equation*}}\n    \\begin{align*}\n      \\Gal(Z|X) \\cong \\Gal(Y|X) / \\Gal(Y|Z).\n    \\end{align*}\n\\end{proposition}\n\\begin{proof}\n  Let $\\varphi \\in G$ be a deck transformation in $\\Gal(Y|X)$. We will first show that $\\varphi$ descends to a deck transformation in $\\Gal(Z|X)$ i.e. there is a $\\psi$ that fits in the commutative diagram\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rrrr, \"\\varphi\"] \\ar[rd, \"p_1\"']\n      & & & &\n      Y  \\ar[ld, \"p_1\"]\\\\\n      & Z \\ar[rr, shift left, \"\\psi\"] \\ar[rd,\"p_2\"']\n      & & Z \\ar[ld,\"p_2\"] \\\\\n      & &  X\n    \\end{tikzcd}\n  \\end{equation*}\n  To do this, pick an element $y \\in Y$ and let $ z = p_1(y)$.\n  Because $Z \\rightarrow X$ is Galois, there is a unique deck transformation $\\psi \\in \\Gal(Z|X)$ which sends $p_1(y)$ to $p_1(\\varphi(y))$.\n  We need to show that $p_1 \\circ \\varphi = \\psi \\circ p_1$.\n  For this, apply Lemma \\ref{lemma:lemma2} to the following commutative diagram\n  \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rr, shift left, \"\\psi \\circ p_1\"] \\ar[rr, shift right, \"p_1 \\circ \\varphi\"']  \\ar[rd, \"p\"']\n      & & Z \\ar[ld,\"p_2\"] \\\\\n      & X\n    \\end{tikzcd}\n  \\end{equation*}\n  \\begin{qbox}\n    Finish the above argument. Then show that $\\varphi \\mapsto \\psi$ defines a group homomorphsism $\\Gal(Y|X) \\rightarrow \\Gal(Z|X)$ with kernel $\\Gal(Y|Z)$ thereby completing the proof.\n  \\end{qbox}\n\\end{proof}\n\n\n\n\n\n\\begin{proposition}\n  If $Z$ is a cover lying between $Y$ and $X$ and $\\Gal(Y|Z)$ is a normal subgroup of $\\Gal(Y|X)$, then $p_2:Z \\rightarrow X$ is Galois.\n\\end{proposition}\n  \\begin{qbox}\n    Using $Z \\cong Y/H$, $X \\cong Y/G$, argue that $X \\cong Z/(G/H)$. Use this to prove the Proposition.\n  \\end{qbox}\n\n\n\n\n\n\\begin{theorem}[Galois Correspondence of Covering Spaces]\n  There is a 1-1 correspondence between the subgroups of $\\Gal(Y|X)$ and covers of $X$ that lie between $Y$ and $X$, given by the following maps\n  \\begin{align*}\n    \\{\\mbox{ subgroups of $\\Gal(Y|X)$ } \\} &\\longleftrightarrow  \\{\\mbox{ covers lying between $Y$ and $X$ } \\}\\\\\n    H &\\longmapsto Y/H \\\\\n    \\Gal(Y|Z) & \\longmapsfrom Z\n  \\end{align*}\n  Under this correspondence, the normal subgroups of $\\Gal(X|Y)$ correspond to Galois covers of $X$.\n\\end{theorem}\n\\begin{qbox}\n  We have proved all the parts of this theorem. Write down the proof explicitly and see how the various pieces fit together.\n\\end{qbox}\n\n\\begin{remark}\n  There is a subtle point here about what the correspondence is between. On the right hand side, the objects are not spaces $Z$ but the triangles of the form \\begin{equation*}\n    \\begin{tikzcd}\n      Y \\ar[rd, \"p_1\"] \\ar[dd, \"p\"']\\\\\n        & Z \\ar[ld,\"p_2\"] \\\\\n      X\n    \\end{tikzcd}\n  \\end{equation*}\n\\end{remark}\n\n\n\\begin{qbox}\n  Explicitly right down the Galois correspondence for\n  \\begin{enumerate}\n    \\item The covers of $S^1 \\vee S^1$ in Figure \\ref{fig:CoveringsOfS1S1}.\n    \\item The cover $\\bbr^1 \\rightarrow S^1$.\n  \\end{enumerate}\n\\end{qbox}\n\n\n\n\n\n\n\n\n\n\n\\iffalse\n\\section*{Review the following for tomorrow}\nFor tomorrow's class, please review/lookup \\emph{presentation of a group}. The following statements should make sense to you\n\\begin{align*}\n  \\bbz &= \\langle a \\rangle \\\\\n  \\bbz/n &= \\langle a | a^n \\rangle \\\\\n  \\bbz \\times \\bbz &= \\langle a, b | ab a^{-1} b^{-1} \\rangle \\\\\n  D_{2n} &= \\langle r, s | r^n, s^2, (rs)^2 \\rangle && \\mbox{ where $D_{2n}$ is the Dihedral group.}\n\\end{align*}\n\n\n\n\n\n\n\n\n\\section{Lifting properties of covering spaces}\n\n\nWe have a complete description of what the covers lying between $X$ and $Y$ are.\n\n\\begin{theorem}\n  \\label{theorem:liftingOfCovers}\n  Consider covering maps\n  \\begin{equation*}\n    \\begin{tikzcd}\n      & X \\ar[d,\"p\"] \\\\\n      Z \\ar[r, \"p'\"']& Y\n    \\end{tikzcd}\n  \\end{equation*}\n  along with vertices $x \\in X, y \\in Y, z \\in Z$ with $p(x) = z = p'(y)$. There exists a map $p'':Z \\rightarrow X$ which factors $p'$ with $p'(z) = y$ if and only if\n  \\begin{align*}\n    p'_*\\pi_1(Z,z) \\le p_* \\pi_1(X,x).\n  \\end{align*}\n  In this case, the lift $p''$ is unique.\n\\end{theorem}\n\n  \\begin{corollary}\n    A simply connected space has no non-trivial (connected) covers.\n  \\end{corollary}\n\n  A map between spaces $p:X \\rightarrow Y$ naturally induces a map between fundamental groups\n  \\begin{equation*}\n    p_*: \\pi_1(X,x) \\rightarrow \\pi_1(Y,y)\n  \\end{equation*}\n\n  \\fi\n", "meta": {"hexsha": "dbe46124f4e0fa50e9bb6323fb6d91af096576cf", "size": 7877, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "03.tex", "max_stars_repo_name": "apurvnakade/mc2019-Galois-correspondence-of-covering-spaces", "max_stars_repo_head_hexsha": "0daace3a630f99a117be973eab11bc547dc6fb44", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "03.tex", "max_issues_repo_name": "apurvnakade/mc2019-Galois-correspondence-of-covering-spaces", "max_issues_repo_head_hexsha": "0daace3a630f99a117be973eab11bc547dc6fb44", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "03.tex", "max_forks_repo_name": "apurvnakade/mc2019-Galois-correspondence-of-covering-spaces", "max_forks_repo_head_hexsha": "0daace3a630f99a117be973eab11bc547dc6fb44", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4675925926, "max_line_length": 264, "alphanum_fraction": 0.6362828488, "num_tokens": 2837, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.41575764770067064}}
{"text": "\\chapter{Background Independence in Quantum Gravity}\\label{chap:BGindependence}\nBefore we come to an end, we briefly want to discuss the issue of background independence in the context of quantum gravity and emphasize that our calculations in the background field approximation have to be treated very carefully. The formulas presented in the scope of this chapter are taken from \\cite{PawlowskiNPgaugeLecture}.\\\\\nThroughout this work we used a linear split of the metric  into some background $\\bar{g}_{\\mu\\nu}$ and a fluctuation field $h_{\\mu\\nu}$. This changes nothing about the fact, that in general, the flowing action $\\Gamma_k = \\Gamma_k[\\bar{g} + h]$ is still a functional of the full metric $g$, but from a computational point of view it may be easier accessible, since we can expand it in powers of the fluctuations on the given background, i.\\,e.\n\\begin{equation}\n\t\\Gamma_k\\left[\\bar{g} + h\\right] = \\Gamma_k\\left[\\bar{g}\\right] +  \\Gamma_k^{(0,1)}\\left[\\bar{g}\\right]\\cdot h + \\frac{1}{2}\\Gamma_k^{(0,2)}\\left[\\bar{g}\\right]\\cdot h^2 +\\mathcal{O}(h^3),\n\\label{eqn:vertex_expansion}\n\\end{equation}\nwhere we introduced the shorthand notation $\\Gamma_k^{(n,m)} = \\frac{\\delta^{n+m}\\Gammak}{\\delta^n\\bar{g}_{\\mu\\nu}\\delta^mh_{\\mu\\nu}}$ to distinguish derivatives w.\\,r.\\,t. the background and the fluctuation field. But since this split is only a mathematical trick to be able to perform calculations in a more efficient way, there should be some relation between the correlations of the fluctuation field and those of the background field.\nThis idea is encoded in the \\textit{Nielsen identities}, given by\n\\begin{equation}\n\t \\mathrm{NI}=\\frac{\\delta \\Gamma}{\\delta \\bar{g}_{\\mu \\nu}}-\\frac{\\delta \\Gamma}{\\delta h_{\\mu \\nu}}-\\left\\langle\\left[\\frac{\\delta}{\\delta \\bar{g}_{\\mu \\nu}}-\\frac{\\delta}{\\delta \\hat{h}_{\\mu \\nu}}\\right]\\left(\\mathcal{S}_{\\mathrm{gf}}+\\mathcal{S}_{\\mathrm{gh}}\\right)\\right\\rangle= 0.\n\\end{equation}\nHere $h_{\\mu\\nu}=\\langle\\hat{h}_{\\mu\\nu}\\rangle$. The difference between the background derivatives and the fluctuation derivatives is connected to derivatives of the gauge fixing sector. At finite $k$ the regulator, which plays a crucial role in our approach to the subject, introduces another background dependence. This leads us to the \\textit{modified Nielsen identities}:\n\\begin{equation}\n\t\\mathrm{mNI}=\\mathrm{NI}-\\frac{1}{2} \\operatorname{Tr}\\left[\\frac{\\delta}{\\delta\\sqrt{g}} \\frac{\\delta \\sqrt{\\bar{g}} R_{k}[\\bar{g}]}{\\delta \\bar{g}_{\\mu \\nu}} G_{k}\\right]=0.\n\\end{equation}\nIn background field approximation we assume $\\frac{\\delta\\Gammak}{\\delta h}\\approx\\frac{\\delta\\Gammak}{\\delta \\bar{g}}$, this violates the Nielsen identities and therefore background independence is lost. This may seem contradictory at first sight, since in background field approximation we only deal with a single metric. Nevertheless, up until now, the background field approximation is somehow the standard approach to calculations in this area.\nAs already mentioned in the introduction, more recently some progress has been made in surmounting the background field approximation. Results based on vertex expansions in powers of the fluctuation field, such as in (\\ref{eqn:vertex_expansion}), were used to determine the flow of the couplings by computation of the flow of the $n$-point functions. Details can be found in \\cite{ChristiansenLitimPawlowskiReichert2018,MeibohmPawlowskiReichert2015}. The results obtained from this approach differ to some extend strictly from the results found in computations in background field approximations. For future projects, one should keep these problems concerning the background field approximation in mind.", "meta": {"hexsha": "bf8d4479dc9f07f73c772ad72abeca360a20d2c3", "size": 3674, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/content/06_background_independence.tex", "max_stars_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_stars_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-22T15:05:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-22T15:05:57.000Z", "max_issues_repo_path": "Thesis/content/06_background_independence.tex", "max_issues_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_issues_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/content/06_background_independence.tex", "max_forks_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_forks_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-25T05:06:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-25T05:06:03.000Z", "avg_line_length": 204.1111111111, "max_line_length": 703, "alphanum_fraction": 0.7656505171, "num_tokens": 975, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239133, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.41571566302826823}}
{"text": "\\documentclass[12pt, a4]{article}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[a4paper, total={16cm, 22cm}]{geometry}\n\n\\usepackage{graphicx}\n\\graphicspath{ {./screenshots/} }\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\lhead{Business Intelligence Lab}\n\\rhead{Mini Project}\n\\rfoot{\\thepage}\n\n\\usepackage{hyperref}\n\\usepackage[section]{placeins}\n\n\\title{\n  \\vspace{-1.0cm}\n  \\textbf{Logistic Regression with Rust}\n}\n\\author{\n  Arpit Bhat\\\\\n  \\textit{501808}\n  \\and\n  Archit Bhonsle\\\\\n  \\textit{501810}\n  \\and\n  Shalmali Kulkarni\\\\\n  \\textit{501835}\n}\n\\date{}\n\n\\begin{document}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\\section{Problem Statement}\n\nWe aim to create a desktop application using GTK, a toolkit to create GUI apps\nthat guides use through the a simplified version of the machine learning pipeline. The algorithm we'll be using is logistic regression which is used in\nvarious simple classification tasks.\n\n\\section{Dataset}\n\nThe dataset we've chosen is reduced version of a larger dataset with 76\nattributes found here:\n\\url{https://archive.ics.uci.edu/ml/datasets/Heart+Disease}.\nThis reduced dataset has 14 attributes (described in detail in table\n\\ref{table:attributes}) and one target variable which indicates whether heart\ndisease is present or not. The reduced dataset has numeric, discrete,\ncontinuous and binary attributes all of which can be represented as numbers\nwhich in our case are 64-bit floating point values. This is an assumption that helps us optimize our model and skip certain steps like mapping nominal attributes to unique numbers.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{| l | l |}\n  \\hline\n  Column   & Attribute                                            \\\\\n  \\hline\n  age      & Age in years                                         \\\\\n  sex      & Sex of person: 0 is female, 1 is male                \\\\\n  cp       & Chest pain type                                      \\\\\n  trestbps & Resting blood pressure (in mm Hg)                    \\\\\n  chol     & Serum cholesterol in mg/dl                           \\\\\n  fbs      & 1 if fasting blood sugar $>$ 120 mg/dl else 0        \\\\\n  restecg  & Resting electrocardiograph results                   \\\\\n  thalch   & Maximum heart rate achieved (in mm Hg)               \\\\\n  exang    & 1 if exercise induced angina else 0                  \\\\\n  oldpeak  & ST depression induced by exercise relative to rest   \\\\\n  slope    & The slope of the peak exercise ST segment            \\\\\n  ca       & Number of major vessels (0-3) colored by fluoroscope \\\\\n  thal     & 3 = normal; 6 = fixed defect; 7 = reversable defect  \\\\\n  target   & 1 if heart disease is present 0 otherwise            \\\\\n  \\hline\n\\end{tabular}\n\\caption{Attributes in the heart dataset}\n\\label{table:attributes}\n\\end{table}\n\n\\section{Model}\n\nThe model we use here is\n\\href{https://en.wikipedia.org/wiki/Logistic_regression}{logistic regression}.\nIt is a model used for binary classification problems like the heart disease\nproblem we are tackling here. A fundamental part of this model is the sigmoid function which maps an arbitary number of real values to a probability between 0 and 1:\n\n\\[ \\frac{1}{1 + e^{-x}} \\]\n\nThe cost function we use is:\n\n\\[ J(\\theta) = \\frac{1}{m} \\sum_{i = 1}^{m}\n  \\left(\n    y^{(i)}\\log\\left(h_{\\theta}(x^{(i)})\\right) +\n    \\left(1 - y^{(i)}\\right)\\log\\left(1 - h_{\\theta}(x^{(i)})\\right)\n  \\right)\n\\]\n\nAnd thus in gradient descent, which is basically applying this repeatedly:\n\n\\[\n  \\theta_{j} := \\theta_{j} -\n  \\alpha \\frac{\\delta}{\\delta\\theta_{j}} J(\\theta)\n\\]\n\nAfter resolving the derivative using calculus the equation becomes:\n\n\\[\n  \\theta_{j} := \\theta_{j} -\n  \\frac{\\alpha}{m} \\sum_{i = 1}^{m} x_{j}^{(i)}\n  \\left(h_{\\theta}(x^{(i)}) - y^{(i)} \\right)\n\\]\n\n\\\n\n\\section{Creating the model and testing}\n\nThe core code for the model is encapsulated inside the following\n\\texttt{forward\\_backward} function:\n\n\\begin{verbatim}\nfn forward_backward(\n    weights: &Array2<f64>,\n    bias: &f64,\n    x_train: &Array2<f64>,\n    y_train: &Array2<f64>,\n) -> (f64, Array2<f64>, f64) {\n    // forward\n    let y_head: Array2<f64> = sigmoid(weights.t().dot(x_train)\n        .mapv(|x| x + bias));\n    let loss = (y_train * &(y_head.mapv(|z| z.ln()))\n        + &((y_train.mapv(|z| 1. - z)) * &y_head.mapv(|z| (1. - z).ln())))\n        .mapv(|z| -1. * z);\n    let cost = loss.sum() / x_train.ncols() as f64;\n\n    // backward\n    let d_weights = (x_train.dot(&(&y_head - y_train).t()))\n        .mapv(|z| z / x_train.ncols() as f64);\n    let d_bias = (&y_head - y_train).sum() / x_train.ncols() as f64;\n\n    (cost, d_weights, d_bias)\n}\n\\end{verbatim}\n\nHere, \\texttt{y\\_head} is $h_{\\theta}(x^{(i)})$ or the hypothesis. \\texttt{loss}\nis $J(\\theta)$ and \\texttt{cost} is the average loss. This comprises the\n``forward'' step. In the ``backward'' step we calculate the change in the weights,\n\\texttt{d\\_weights} and the change in bias as \\texttt{d\\_bias}.\n\nThese values are then used by the \\texttt{update} function which tweaks the\nweights and the biases for the specified \\texttt{iterations}. Thus, the model\nis trained.\n\n\\begin{verbatim}\nfn update(\n    weights: Array2<f64>,\n    bias: f64,\n    x_train: Array2<f64>,\n    y_train: Array2<f64>,\n    learning_rate: f64,\n    iterations: usize,\n) -> (Vec<f64>, Array2<f64>, f64) {\n    let mut costs: Vec<f64> = Vec::new();\n    let mut weights = weights;\n    let mut bias = bias;\n\n    for _ in 0..iterations {\n        let (cost, d_weight, d_bias) = forward_backward(\n            &weights, &bias, &x_train, &y_train);\n        weights -= &d_weight.mapv(|x| learning_rate * x);\n        bias -= learning_rate * d_bias;\n\n        costs.push(cost);\n    }\n\n    (costs, weights, bias)\n}\n\\end{verbatim}\n\n\\section{Using the application}\n\nThe application has three pages. Each page has represents one section of the\nmachine learning pipeline.\n\n\\begin{enumerate}\n  \\item{In the first step, as shown in figure \\ref{fig:choose}, we select our\n        dataset. We can we review it in the tabular view and inspect it's\n        various attributes.}\n  \\item{After that we perform preprocessing on this data. As one may observe\n        in the tabular view some attributes go in the high 100s while some\n        are simple binary values, 0 and 1. If we give this data to the model\n        it may cause problems. To counter this we normalize the data. This is\n        demonstrated in figure \\ref{fig:preprocessing}.}\n  \\item{In the third step, as shown in the figure \\ref{fig:model}, we actually\n        train our model. We specify the learning rate and the number of\n        iterations. Once trained a graph of the model's cost as the it goes\n        through various iterations is graphed. Based on this we can evaluate\n        the model. Once trained we can test the model against the testing data.\n        Then the various metrics like accuracy, precision, recall and f1-score\n        are shown.}\n\\end{enumerate}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=120mm]{choose}\n\\caption{Choose Page}\n\\label{fig:choose}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=120mm]{preprocessing}\n\\caption{Preproccessing Page}\n\\label{fig:preprocessing}\n\\end{figure}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=120mm]{model}\n\\caption{Model Page}\n\\label{fig:model}\n\\end{figure}\n\n\\section{Analyzing the results}\n\nThe results of various values of the hyperparameters, learning rate and\niterations are show in table \\ref{table:hyperparams}.\n\n\\begin{table}[h]\n  \\centering\n  \\begin{tabular}{| p{2cm} | p{2cm} || p{2cm} | p{2cm} | p{2cm} | p{2cm} |}\n    \\hline\n    LR & Iterations & Accuracy & Precision & Recall & F1-Score \\\\\n    \\hline\n    0.1 & 100  & 79.1\\% & 90.2\\% & 76.7\\% & 82.9\\%  \\\\\n    0.1 & 1000 & 80.2\\% & 90.2\\% & 78.0\\% & 83.6\\%  \\\\\n    1   & 100  & 80.1\\% & 90.2\\% & 78.0\\% & 83.6\\%  \\\\\n    1   & 1000 & 83.5\\% & 92.2\\% & 81.0\\% & 86.2\\%  \\\\\n    10  & 100  & 74.2\\% & 68.6\\% & 83.3\\% & 75.3\\%  \\\\\n    10  & 1000 & 76.9\\% & 70.6\\% & 85.7\\% & 77.4\\%  \\\\\n    \\hline\n  \\end{tabular}\n\\caption{Metrics for various hyperparameters}\n\\label{table:hyperparams}\n\\end{table}\n\nAs we can see, the model with the learning rate of 1 and 1000 iterations\nperforms the best. The learning rate of 0.1 is too slow and it takes 1000 to\nmatch the performance of the (1, 1000) model. The learning rate of 10 is too\nfast which is also apparent from it's cost vs iterations graph. Ideally, we'd\nlike a mechanism that reduces the learning rate whenever the cost stops\ndecreasing. This is known as an ``adaptive learning rate''.\n\n\\section{Setup}\n\nRegardless of the operating system you're on you might need a dataset to test\nthis on. The app only supports datasets with numeric columns so other datasets\nmight crash the app. To download \\texttt{heart.csv} used in this report, click\non\n\\href{https://downgit.github.io/#/home?url=https://github.com/ArchitBhonsle/gtk-rs-experiment/blob/main/data/heart.csv}{this} link.\n\n\\subsection{Windows}\n\n\\begin{enumerate}\n  \\item{Go\n        \\href {https://downgit.github.io/#/home?url=https://github.com/ArchitBhonsle/gtk-rs-experiment/tree/main/windows-package}\n        {here}.}\n  \\item{In the downloaded folder double click on the\n        \\texttt{gtk-rs-experiment.exe}.}\n\\end{enumerate}\n\n\\subsection{Linux}\n\nThis may or may not work based on the libraries installed on your system.\n\n\\begin{enumerate}\n  \\item{Go to \\href{https://downgit.github.io/#/home?url=https://github.com/ArchitBhonsle/gtk-rs-experiment/blob/main/linux-executable}{this}\n        link.}\n  \\item{Open the location of the downloaded executable in the file explorer and\n        right click and open a terminal there.}\n  \\item{Enter the command \\texttt{chmod +x ./linux-executable} followed by\n        \\texttt{./linux-executable}.}\n\\end{enumerate}\n\n\n\\end{document}\n", "meta": {"hexsha": "7e2d0a3357be41b471e4dbf47e80e29a2ba80ea0", "size": 9792, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report.tex", "max_stars_repo_name": "ArchitBhonsle/gtk-rs-experiment", "max_stars_repo_head_hexsha": "b6894ee00da2d4a2d757d4b1e40fe07e92fe1c9d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report.tex", "max_issues_repo_name": "ArchitBhonsle/gtk-rs-experiment", "max_issues_repo_head_hexsha": "b6894ee00da2d4a2d757d4b1e40fe07e92fe1c9d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report.tex", "max_forks_repo_name": "ArchitBhonsle/gtk-rs-experiment", "max_forks_repo_head_hexsha": "b6894ee00da2d4a2d757d4b1e40fe07e92fe1c9d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7655172414, "max_line_length": 180, "alphanum_fraction": 0.6658496732, "num_tokens": 2877, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.41571564779647535}}
{"text": "\\documentclass[a4paper,11pt]{amsbook}\r\n\\usepackage{amsmath}\r\n\\usepackage{../HBSuerDemir}\r\n\\usepackage{fullpage}\r\n\\pagestyle{headings}\r\n\\usepackage{fancyhdr}\r\n\r\n\\begin{document}\r\n\\hPage{b2p2/480}\r\n\r\n\r\nof the field is tangent to the curve at that point.\\\\\r\n$$DE: \\displaystyle\\frac{dx}{P}=\\frac{dy}{0}$$ or\\\\\r\n$$\\displaystyle O(x,y)dx-P(x,y)dy=0$$\r\n\\paragraph{}\r\nThe orthogonal trajectories of the vector lines are called\\\\\r\nequipotential curves of the field with $DE$. $Pdx+0dy=0$.\\\\\r\n\\begin{exmp}\r\nFind the family of vector lines (stream lines)\\\\\r\nof the vector field.\\\\\r\n$F=2xyi-(x^{2}-y^{2})j$\\\\\r\n\\\\\r\nand the equipotential curves.\r\n\\end{exmp}\r\n\\begin{hSolution}\r\n$$\\displaystyle\\frac{dx}{2xy}=\\frac{dy}{-(x^{2}-y^{2})}$$\\\\\r\n$$\\Longrightarrow (x^{2}-y^{2})dx+2xydy=0$$\\\\\r\n$$GS: x^{2}+y^{2}=cx$$ (circles)\\\\\r\n\\paragraph{}\r\nThen the DE of the equipotential curves will be\\\\\r\n$$(x^{2}-y^{2})dy-2xydx=0$$\\\\\r\nwith solution\\\\\r\n$$\\displaystyle x^{2}+y^{2}=cy$$\\\\\r\n\r\n\\end{hSolution}\r\n\\textbf{Exercises(6.3)}\\\\\r\n\\\\\r\n36. Find the $DE$ of the family of parabolas having the origin as\\\\ \r\nfocus and $x=-p$ as directerix.\\\\\r\n\\\\\r\n37.Find the curve having length of subnormal equal to 3 and\\\\\r\n passing through the point $(1,4)$.\\\\\r\n\\\\\r\n38.Find the equation in polar coordinates of the curves such\\\\\r\nthat the tangent of the angle $\\psi$ between the radius vector\\\\\r\n\\end{document}", "meta": {"hexsha": "ec2e3682d448d254804b13b854c2a8c7a2371f70", "size": 1367, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw2/non-merged/MEHMET YUSUF BAYAM_38234_assignsubmission_file_/b2p2-480/SuerDemirb2p2-480/b2p2-480.tex", "max_stars_repo_name": "yildirimyigit/cmpe220_2016_3", "max_stars_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-05-15T22:03:34.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-15T22:03:34.000Z", "max_issues_repo_path": "hw2/non-merged/MEHMET YUSUF BAYAM_38234_assignsubmission_file_/b2p2-480/SuerDemirb2p2-480/b2p2-480.tex", "max_issues_repo_name": "yildirimyigit/cmpe220_2016_3", "max_issues_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw2/non-merged/MEHMET YUSUF BAYAM_38234_assignsubmission_file_/b2p2-480/SuerDemirb2p2-480/b2p2-480.tex", "max_forks_repo_name": "yildirimyigit/cmpe220_2016_3", "max_forks_repo_head_hexsha": "4e71a0ed20d76b93c144c2f9c0fbbd52c04b5ae3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.7173913043, "max_line_length": 69, "alphanum_fraction": 0.6613021214, "num_tokens": 478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.41566175819432744}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{algorithm}\n\\usepackage{graphicx}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{url}\n\n\\newlength\\tindent\n\\setlength{\\tindent}{\\parindent}\n\\setlength{\\parindent}{0pt}\n\\renewcommand{\\indent}{\\hspace*{\\tindent}}\n\n\\newtheorem{thm}{Theorem}\n\\newtheorem{cor}{Corollary}[thm]\n\\newtheorem{lemma}{Lemma}[thm]\n\n\\title{Job Scheduling Problem}\n\\author{Daniel Braithwaite}\n\n\\begin{document}\n\t\\pagenumbering{gobble}\n\t\\maketitle\n\t\\newpage\n  \t\\pagenumbering{arabic}\n  \t\t\t\n\t\\section{Deterministic Algorithm}\n\t\t\\subsection{Approximation Ratio}\n\t\t\tSay we have $m$ computers, we start by assuming our scheduler has been given $m$ simple jobs, assuming our algorithm wants to be optimal and considering that we cant see what is coming next we will assign one of these simple jobs to each of the $m$ machines. Now that it has scheduled the simple jobs we give it a single complex job. No matter which machine we assign the complex job to we end up with a total cost of 15 minutes where we could have a total cost of 10 minutes.\\newline\n\t\t\t\n\t\t\tThis gives us an approximation ratio of $\\frac{15}{10} = 1.5$.\n\t\t\t\n\t\t\t\\begin{lemma}\n\t\t\t\tNo deterministic algorithm online algorithm for scheduling jobs can have a better ratio than 1.5\n\t\t\t\\end{lemma}\n\t\t\t\n\t\t\t\\begin{proof}\n\t\t\t\tWe assume that our algorithm is always making the optimal choice when given a job. We clearly will want to assign incoming jobs to computers that don't already have a job on them. So we see we will assign the $m$ simple jobs to each of the $m$ computers. Given that we don't know about incoming jobs we cant arrange the tasks differently if the last one to be received is a complex job. So this leaves us with a solution with a cost of 15. Giving us a ratio of 1.5\n\t\t\t\\end{proof}\n\t\t\t\t\n\t\t\\subsection{Algorithm}\n\t\t\tWe want to design an algorithm with the best approximation ratio of 1.5. We can see how we want to do this by referencing the proof in the previous section. We just want to assign the incoming job to the machine with the least total time as this will give us the best distribution across the machines.\\newline\n\t\t\n\t\t\tWe only have one input for the algorithm which is the machines. Assume we have a method that gives us the next job $getNextJob()$, and a method that tells us if we have any jobs left $haveJobsLeft()$\t\n\t\t\n\t\t\t\\begin{algorithm}\n\t\t\t\t\\begin{algorithmic}[1]\n\t\t\t\t\t\\Procedure{deterministicJobSchedule}{$m$}\n\t\t\t\t\t\t\\While{$haveJobsLeft()$}\n\t\t\t\t\t\t\t\\State $j \\gets getNextJob()$\n\t\t\t\t\t\t\t\\State $i \\gets$ machine with smallest queue\n\t\t\t\t\t\t\t\\State assign j to $m[i]$\n\t\t\t\t\t\t\\EndWhile\n\t\t\t\t\t\\EndProcedure\n\t\t\t\t\\end{algorithmic}\n\t\t\t\\end{algorithm}\n\t\n\t\t\\subsection{Complexity}\n\t\t\tSay we have $n$ jobs, then the outer loop will repeat $n$ times. Along with this we see that finding the machine with the smallest queue requires us to iterate through all the machines which will take $m$ steps where $m$ is the number of machines we have. Giving us a total complexity of\n\t\t\t\n\t\t\t\\begin{align*}\n\t\t\t\t\\theta(nm)\n\t\t\t\\end{align*}\n\t\t\t\t\t\n\t\t\\subsection{Testing}\n\t\t\tWhen testing this algorithm I generated worst case input to graph so that we could see the algorithm had an approximation ratio of 1.5. I also tested the program on randomly generated data with three different numbers of machines (5, 10, 20) so we could see that the algorithm never exceeded the approximation ratio of 1.5. As we can see in the graph below both these things hold and that the approximation ratio is as expected.\n\t\t\t\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\vspace{3mm}\n\t\t\t\t\\begin{center}\n\t\t\t\t\t\\includegraphics[scale=0.4]{Approx.png}\n\t\t\t\t\\end{center}\n\t\t\t\\end{figure}\n\t\t\n\t\t\n\t\\section{Probabilistic Algorithm}\t\t\t\t\n\t\t\\subsection{Algorithm}\n\t\t\tFor this algorithm I am randomly assigning simple tasks and deterministic assigning complex tasks. This was because since complex tasks are bigger randomly assigning them will have more chance of making an issue where as simple tasks in the wrong place wont put out the solution by much. Assuming we are given a random distribution of simple and complex job this will also give us a significant speed increase from the deterministic algorithm\\newline\n\t\t\n\t\t\tWe will assume we have a method that gives us the next job $getNextJob()$, and a method that tells us if we have any jobs left $haveJobsLeft()$. Along with $uniformRandomInt(m)$, which returns a random number between 0 and m (not including m)\n\t\t\t\\begin{algorithm}\n\t\t\t\t\\begin{algorithmic}[1]\n\t\t\t\t\t\\Procedure{probilisticJobSchedule}{$m$}\n\t\t\t\t\t\t\\While{$haveJobsLeft()$}\n\t\t\t\t\t\t\t\\State $j \\gets getNextJob()$\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\If{$j$ is simple}\n\t\t\t\t\t\t\t\t\\State $i \\gets uniformRandomInt(m)$\n\t\t\t\t\t\t\t\\Else\n\t\t\t\t\t\t\t\t\\State $i \\gets$ machine with smallest queue\n\t\t\t\t\t\t\t\\EndIf\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\\State assign j to $m[i]$\n\t\t\t\t\t\t\\EndWhile\n\t\t\t\t\t\\EndProcedure\n\t\t\t\t\\end{algorithmic}\n\t\t\t\\end{algorithm}\t\n\t\n\t\t\\subsection{Approximation Ratio}\n\t\t\tWe see that the approximation ratio for our probabilistic algorithm is the same as that for the deterministic algorithm by the following reasoning using the same worst case scenario as before.\\newline\n\t\t\t\n\t\t\tIf we get given $m$ simple jobs then given that we are uniformly distributing them across the machines when we get given the complex job the only thing to do is put it on a computer with a simple job and get a total cost of 15. We know that the optimal solution is 10. Giving us the approximation ratio of 1.5.\n\t\n\t\t\\subsection{Complexity}\n\t\t\tThe loop for this algorithm will repeat $n$ times where we have $n$ jobs. The probabilistic part of this algorithm will have a constant time complexity. And the deterministic part will have a complexity of $m$ where $m$ is the number of machines. \n\t\t\t\n\t\t\t\\begin{align*}\n\t\t\t\t\\theta(nm)\n\t\t\t\\end{align*}\n\t\t\t\n\t\t\\subsection{Testing}\n\t\t\tI tested this algorithm on random input and for each used three different numbers of machines. The solutions start of being wildly incorrect but as the input size grows the algorithm gets more accurate. The graph also shows that almost always having 5 machines will gives you better results than having 10 or 20. We can observer in the graph below that the approximation ratio is as we expected. We see that practically all of the plotted data falls below 1.5 and the few about can be explained by the fact that the expected ratio was calculated using the expected output of the algorithm, the fact that the algorithm is randomized means that we will sometimes get an output that is way off expected. \n\t\t\t\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\vspace{3mm}\n\t\t\t\t\\begin{center}\n\t\t\t\t\t\\includegraphics[scale=0.4]{Prob.png}\n\t\t\t\t\\end{center}\n\t\t\t\\end{figure}\n\t\t\t\n\t\t\t\\break\n\t\t\t\n\t\\section{Comparison}\n\t\t\\subsection{Approximation Ratios}\n\t\t\tWe can graph the approximation ratios of the two algorithms to see that deterministic algorithm out performs the probabilistic but not by a lot.\n\t\t\t\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\vspace{3mm}\n\t\t\t\t\\begin{center}\n\t\t\t\t\t\\includegraphics[scale=0.4]{CompareRatios.png}\n\t\t\t\t\\end{center}\n\t\t\t\\end{figure}\n\t\t\t\n\t\t\t\\break\n\t\t\t\n\t\t\\subsection{Complexity}\n\t\t\tIf we compare the order cost of both the algorithms we see that the probabilistic algorithm and deterministic algorithms have the same order cost but if we examine the graph below we see that the probabilistic algorithmic out performs the deterministic one.\n\t\t\t\n\t\t\t\\begin{figure}[h]\n\t\t\t\t\\vspace{3mm}\n\t\t\t\t\\begin{center}\n\t\t\t\t\t\\includegraphics[scale=0.4]{CompareComplexity.png}\n\t\t\t\t\\end{center}\n\t\t\t\\end{figure}\n\t\t\t\n\t\t\t\\break\t\t\n\t\t\t\n\t\t\\subsection{Summary}\n\t\t\tWhile the deterministic algorithm gives a consistently good solution most of the time it is only slightly better if not the same as the probabilistic algorithm. Along with this we see that the probabilistic algorithm is considerably faster than the deterministic one.\\newline\n\t\t\t\n\t\t\tThe key difference between the two is that the probabilistic one will randomly assign the simple tasks to machines, this hopefully causes enough variance in the solution so that we can avoid arriving at a sub optimal solution. By only randomly assigning the simple tasks we are introducing variation but also minimizing risk. If a simple task is randomly assigned to a bad position then the offset caused by that isn't as much as if we assigned a complex task to a bad position.\n\t\t\t\n\t\\section{Alternative Solutions Considered}\n\t\t\\subsection{Probabilistic Algorithm}\n\t\t\tOne possible solution I considered was rather than only randomly assigning simple tasks, just randomly assign any task but only $\\alpha$ percent of the time. However in testing this didn't perform as optimally as the solution given in this report.\n\t\t\t\n\t\\section{Further Improvements}\n\t\t\\subsection{Deterministic Algorithm}\n\t\t\tA simple way to improve the effective of the deterministic algorithm would be to use a heap to store the computers. This would give is $log(m)$ time instead of $m$ time (where $m$ is the number of machines)\n\t\t\n  \t\n\\end{document}", "meta": {"hexsha": "cd84734a5031107eb9d1e284e826cabfbb735b78", "size": 8920, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Undergraduate/COMP361/Assignment 4/Report/report.tex", "max_stars_repo_name": "danielbraithwt/University", "max_stars_repo_head_hexsha": "50c6a904e1c53c03bce9928975607c35fd741e33", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Undergraduate/COMP361/Assignment 4/Report/report.tex", "max_issues_repo_name": "danielbraithwt/University", "max_issues_repo_head_hexsha": "50c6a904e1c53c03bce9928975607c35fd741e33", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-12-09T00:17:19.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-09T00:28:42.000Z", "max_forks_repo_path": "Undergraduate/COMP361/Assignment 4/Report/report.tex", "max_forks_repo_name": "danielbraithwt/University", "max_forks_repo_head_hexsha": "50c6a904e1c53c03bce9928975607c35fd741e33", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-23T23:02:31.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-23T23:02:31.000Z", "avg_line_length": 54.7239263804, "max_line_length": 704, "alphanum_fraction": 0.7437219731, "num_tokens": 2224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.41566175515829146}}
{"text": "\\chapter{Foundations of Image Analysis for Motion Estimation}\\label{chap:found_mot_est}\n\n\\section{What are keypoints?}\nAccording to Trucco \\& Verri (1998) \\cite{book} a local keypoint is defined as a local, meaningful, detectable part of an image. In the following, the term keypoint will be used for local keypoint. A keypoint is a local feature of an image, a part with some properties that differentiates it from other parts of the image. By meaningful, they mean that the feature is associated to interesting scene elements such as sharp intensity variations created by the contours of the objects in the scene. To be detectable they state that location algorithms must exist, if not, a keypoint would be of no use.\n\n\\section{Detecting Keypoints}\nThere is a wide variety of keypoint detectors, each with their own way of finding keypoints. There are multiple types of keypoint detectors, some focus on corner detection like Harris, FAST and Shi-Tomasi. SIFT and SURF on the other hand are scale-space detectors. The advantage of corner detectors is that they are quite invariant to view changes, on the other hand, scale changes pose a problem. Scale-space detectors try to detect keypoints on different scales of the image to find scale invariant keypoints\n\n\n\\section{Keypoint Descriptors}\nThe detection of keypoints is not enough. We need a way to compare these keypoints or rather the image patches around a keypoint and its hypothetical counterpart in the second frame. To do this, we can compare the color or gray values directly, or we can transform them into keypoint descriptors and compare these.\\bigskip\n\nOnce again, there are lots of different keypoint descriptors that can be divided in continuous and binary keypoint descriptors. A continuous keypoint descriptor is nothing more than a high-dimensional real-valued vector describing the surroundings of the keypoint. While a binary keypoint descriptor is an vector of bits. The use of bits has the advantage that Hamming distance can be used to compare descriptors, which is very efficient. Also, storing binary values is cheaper than real values (using floating point).\n\nAn important feature of keypoint descriptors is their robustness, SIFT and SURF (continuous descriptors) for instance are robust to illumination, rotation and scale changes. BRIEF (binary descriptor) on the other hand is only robust to illumination, so illumination and scale changes are a problem when using BRIEF. ORB (binary descriptor) tried to eliminate this shortcoming of BRIEF and is invariant to illumination and rotation.\n\n\\section{Oriented FAST and rotated BRIEF (ORB)}\\label{sec:orb}\nORB is based on a combination of the FAST keypoint detector and the BRIEF keypoint descriptor. With ORB, Rublee et al. (2011) \\cite{6126544} didn't just develop a combination of FAST and BRIEF, but enhanced it with extra features to make it rotation invariant and resistant to noise while maintaining the focus on speed.\n\n\\subsection{FAST Keypoint Orientation (oFAST)}\nFeatures from Accelerated Segment Test or FAST, proposed by Rosten \\& Drummond \\cite{10.1007/11744023_34} is a keypoint detector developed with real-time applications in mind. It has thus, as the name suggest, good speed performance. However, the problem with FAST is that there is no orientation component. This is the first thing added by Rublee et al. (2011) \\cite{6126544}.\\bigskip\n\n\\subsubsection{Features from Accelerated Segment Test (FAST)}\nTo detect if pixel $p$ is a corner, the pixels on circle with radius $r$ around $p$ are considered, see Figure \\ref{fig:fastcircle}. In ORB, $r$ equals 9, which is called FAST-9. The intensity of $p$ is $I_p$. To decide if $p$ is a corner, FAST uses a threshold value $t$. If there exists a set of $n$ (usually 12) contiguous pixels on the circle that are either all brighter than $I_p + t$ or all darker than $I_p - t$, then $p$ is considered a corner.\\bigskip\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=1\\textwidth]{figures/fast_circle.jpg}\n    \\caption{Fast with radius 3}\n    \\captionsource{Source: \\cite{10.1007/11744023_34}}\n    \\label{fig:fastcircle}\n\\end{figure}\n\nTo make this process even faster, a high-speed test was introduced to eliminate a large number of non-corners. This high-speed test checks only four pixels, the ones on top, bottom, left and right. In Figure \\ref{fig:fastcircle} these are pixels 1, 5, 9 and 13. At least three out of four of these pixels have to be either all brighter than $I_p + t$ or all darker than $I_p - t$. If this is not the case, there is no possibility for $p$ to be a corner. If this is the case, the full test will decide whether the $p$ is a corner.\\bigskip\n\nThe problem with FAST is that it doesn't produce a value to indicate how much of a corner a certain pixel is. To cope with this shortcoming, ORB uses a Harris corner measure \\cite{Harris1988ACC} to sort the keypoints detected by the FAST detector. After using FAST with a low threshold value (to ensure at least $N$ keypoints are detected), it sorts the corners based on the Harris measure, leaving only the top $N$ points. As FAST doesn't produce multi-scale features, a scale pyramid is used to calculate FAST features at each level in the pyramid.\n\n\\subsubsection{Orientation using Intensity Centroid}\nORB uses Intensity Centroid \\cite{ROSIN1999291}, a measure of corner orientation. It uses geometric moments to determine the corner orientation. Rosin defines the momentum as: \n\\begin{equation}\n    m_{pq} = \\sum_{x,y} x^p y^q I(x, y),\n\\end{equation}\nthe centroid can then be found by:\n\\begin{equation}\n    C = (\\frac{m_{10}}{m_{00}},\\frac{m_{01}}{m_{00}}).\n\\end{equation}\nPlacing $O$ at the center of the corner, a vector $\\Vec{OC}$ can be created, the corner orientation is then:\n\\begin{equation}\n    \\theta = \\mathrm{atan2}(m_{01}, m_{10})\n\\end{equation}\nwhere $\\mathrm{atan2}(x, y)$ or 2-argument arctangent is defined as the angle in the Euclidean plane, given in radians, between the positive x axis and the ray to the point $(x, y) \\neq (0, 0)$ \\cite{unknown-author-2022}. \\autoref{fig:atan2} shows a graph of this function.\\bigskip\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=1\\textwidth]{figures/atan2.png}\n    \\caption{Graph of $\\mathrm{atan2}(x,y)$ over $y/x$}\n    \\label{fig:atan2}\n\\end{figure}\n\nORB improves the rotation invariance even more by making sure that the moments are computed with $x$ and $y$ remaining within a circular region of radius $r$. \\cite{6126544} found the patch size to be a fit value for $r$. This means $x$ and $y$ run from $[-r, r]$. $\\mid C\\mid$ approaching 0 makes the measure become unstable, but this is rarely the case for FAST corners \\cite{6126544}.\n\n\\subsection{Rotation-Aware BRIEF (rBRIEF)}\nWe now have keypoints and their orientation, the next step is to compute the descriptor using BRIEF. As stated before, BRIEF is not invariant to rotation, which is why ORB introduced a modification: Rotation-Aware BRIEF.\n\n\\subsubsection{Binary Robust Independent Elementary Features (BRIEF)}\nBRIEF \\cite{10.1007/978-3-642-15561-1_56} uses a small number of pairwise comparisons to classify patches from which it makes a bit vector. They defined the test $\\tau$ on patch $\\boldsymbol{p}$ like this:\n\\begin{equation}\n    \\tau(\\boldsymbol{p};\\boldsymbol{x},\\boldsymbol{y}) := \\left\\{\\begin{array}{ll}\n         1\\quad : \\boldsymbol{p}(\\boldsymbol{x}) < \\boldsymbol{p}(\\boldsymbol{y})\\\\\n         0\\quad : \\boldsymbol{p}(\\boldsymbol{x}) \\geq \\boldsymbol{p}(\\boldsymbol{y})\n    \\end{array} \\right.,\n\\end{equation}\nwith $\\boldsymbol{p}(\\boldsymbol{x})$ the pixel intensity in a smoothed version of $\\boldsymbol{p}$ at $\\boldsymbol{x} = (u, v)^T$. The BRIEF descriptor is then defined as the $n$-dimensional bitstring\n\\begin{equation}\n    f_n(\\boldsymbol{p}) := \\sum_{1\\leq i\\leq n} 2^{i-1}\\tau(\\boldsymbol{p};\\boldsymbol{x},\\boldsymbol{y}) .\n\\end{equation}\n\nRelying on the experiments of \\cite{10.1007/978-3-642-15561-1_56}, ORB will use $n = 256$, a Gaussian distribution around the center of the patch and smooth the image using an integral image where each test point is a $5 \\times 5$ subwindow of a $31 \\times 31$ pixel patch. Based on experimental results in \\cite{10.1007/978-3-642-15561-1_56} and their own these showed to be performing well.\n\n\\subsubsection{Steered BRIEF}\nAs stated before, BRIEF is not robust when it comes to in-plane rotations. Even small rotations over a few degrees drops the amount of inliers significantly \\cite{6126544}. ORB tackles this problem by introducing Steered BRIEF which steers the BRIEF descriptor according to the orientation of the keypoint. \\bigskip\n\nTo get to the steered BRIEF operator, a $2\\times n$ matrix is defined as follows, $n$ being the amount of binary tests:\n\\begin{equation}\n    \\MS = \\begin{pmatrix}\n    x_1,...,x_n \\\\\n    y_1,...,y_n\n    \\end{pmatrix}\n\\end{equation}\n\nThe steered version $\\MS_\\theta$ of $\\MS$ is constructed using the rotation matrix $\\MR_\\theta$, $\\theta$ being the orientation of the patch:\n\\begin{equation}\n    \\MS_\\theta = \\MR_\\theta \\MS\n\\end{equation}\nThe steered BRIEF operator is now\n\\begin{equation}\n    g_n(\\boldsymbol{p},\\theta):=f_n(\\boldsymbol{p})\\mid(x_i,y_i)\\in \\MS_\\theta\n\\end{equation}\n\nA lookup table is constructed for values of $\\theta = 2k\\pi/30, k \\in \\mathbb{N}_0$. If the keypoint orientation $\\theta$ is consistent across views, the correct set of points $\\MS_\\theta$ will be used to compute the descriptor.\n\n\\subsubsection{rBRIEF}\nHowever, the benefit of rotational invariance comes at a price. Rublee et al. (2011) \\cite{6126544} noticed a loss of variance and high correlation among the binary tests. To cope with these shortcomings, they developed a learning method to choose a good subset of binary tests. The goal is to have high variance of the bit feature and means close to 0.5, as well as being uncorrelated. To do this, they look at all binary tests.\\bigskip\n\n\\cite{6126544} proposes the following greedy algorithm to get a set of uncorrelated tests with a mean close to 0.5:\n\\begin{enumerate}\n    \\item Run each test  against all training patches.\\smallskip\n    \\item Order the tests by their distance from a mean of 0.5, forming the vector $\\vt$.\\smallskip\n    \\item Greedy search:\\smallskip\n    \\begin{enumerate}\n        \\item Put the first test into the result vector $\\vr$ and remove it from $\\vt$.\\smallskip\n        \\item Take the next test from $\\vt$, and compare it against all tests in $\\vr$. If its absolute correlation is greater than a threshold, discard it; else add it to $\\vr$.\\smallskip\n        \\item Repeat the previous step until there are 256 tests in R. If there are fewer than 256, raise the threshold and try again.\\smallskip\n    \\end{enumerate}\n\\end{enumerate}\n\nThey showed that this is a good method to ensure high diversity and low correlation between the bit features.\\bigskip\n\nRublee et al.\\cite{6126544} is the perfect paper for a more detailed explanation of ORB, along with an evaluation and comparison with SURF and SIFT. \n\n\n\\section{Matching Keypoints}\nAs of now, we have a method to find good keypoints in an image and a way to describe the keypoint, a descriptor. To make point-to-point correspondences between the keypoints, we need a way to match them. There are multiple ways to do this.\n\n\\subsection{Brute force}\nWhen searching for matches using brute force, all possible keypoints of the second frame are matched with a keypoint from the first set. The best match is then selected for that specific keypoint. There are several distance measures to check how good a certain match is, e.g. L1, L2, Hamming. This is repeated for every keypoint of the first frame until they are all matched with a keypoint from the second frame.\n\n\\subsection{Fast Library for Approximate Nearest Neighbors (FLANN)}\nFLANN is a library in C++ used for finding the nearest neighbour in a high dimensional space. When looking at a descriptor as a vector in a high dimensional space, finding its nearest neighbour is as good as finding the most similar descriptor and thus finding a good match between keypoints.\n", "meta": {"hexsha": "814a016a403e85a145e60f89d8860f12dada3b3e", "size": 12071, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/3b-theoreticalBackgroundMotionEstimation.tex", "max_stars_repo_name": "BavoPersyn/thesis-NTNU", "max_stars_repo_head_hexsha": "9b2f3643e5e28424db774e87237fad7eb409e584", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/3b-theoreticalBackgroundMotionEstimation.tex", "max_issues_repo_name": "BavoPersyn/thesis-NTNU", "max_issues_repo_head_hexsha": "9b2f3643e5e28424db774e87237fad7eb409e584", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/3b-theoreticalBackgroundMotionEstimation.tex", "max_forks_repo_name": "BavoPersyn/thesis-NTNU", "max_forks_repo_head_hexsha": "9b2f3643e5e28424db774e87237fad7eb409e584", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 92.8538461538, "max_line_length": 600, "alphanum_fraction": 0.7642283158, "num_tokens": 3123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7549149868676284, "lm_q1q2_score": 0.4156617521222554}}
{"text": "\n\n\\subsection{Stochastic Environment Model}\\label{subsec:stochasticEnvModel}\nModel-based agents require a concrete implementation of a model of their world, in order to maintain their internal state \\cite[p.~50]{AIAMA}. The agent's internal state can be thought of as its opinion of what state the world might be in, and its model describes how it believes the world changes over time \\cite{AIAMA}. Chapter \\ref{chapter:Background} outlines the background behind potential models of the stochastic world, including both how internal state can be represented and how internal state can be updated.\\par\nHidden Markov Models and Dynamic Bayesian Networks were identified as suitable models, due to the fact that they provide a succinct and flexible representation of hidden stochastic world state, as well as efficient online state estimation updating algorithms. We chose to use a Dynamic Bayesian Network (DBN), due to the fact that it can use conditional independence relations between variables to reduce the number of probabilities needed to be calculated to perform accurate inference \\cite[p.~63]{KollerPGM}. DBNs also facilitate the incorporation of extra variables with arbitrary conditional independence relations. This was desirable, since we plan future work to extend the model to include extra variables, such as battery level, once a basic implementation was shown to work as intended.\n\nThe 2-Time Slice DBN shown in Figure \\ref{fig:FirstDBNUsed} describes the agent's world model. A first-order Markov assumption is made, where the current state only depends on the state directly preceding it. Grey coloured variables are \\textit{hidden state variables} and are assumed to not be directly observable. Green coloured variables are \\textit{control actions} taken by the agent and the peach coloured variables are \\textit{evidence variables}, which are assumed to be observable and depend on the hidden world state. \n%The agent's location and the search status hidden state variables are mainly included for technical reasons\n\\note{maybe re-position figure so text wraps}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width = 0.9\\linewidth]{Chapters/MultiAgentTargetDetection/Figs/DBNs/DBNWithMultipleObservable.PNG}\n     \\caption{First Version of the DBN representing the agent world model}\n    \\label{fig:FirstDBNUsed}\n\\end{figure}\nA number of conditional probabilities are specified here in order to describe the factored joint distribution of the world model fully. The full tables are omitted as they are sparse. For brevity, we use the abbreviation Loc for Location.\n\n\n\n%\\begin{figure}[H]\n\\scriptsize\n\\begin{equation}\\label{eqn:EvidenceVarsProbs}\n    %\\centering\n    p(SensorReading_t | AgentLoc_{t}, TargetLoc_{t})  = \n    \\begin{cases}\n    \\alpha \\quad \\text{ if } SensorReading_t=1 \\text{ and } TargetLoc_t \\neq AgentLoc_t\n    \\\\\n    1-\\beta \\quad \\text{ if } SensorReading_t=1 \\text{ and } TargetLoc_t = AgentLoc_t\n    \\\\\n    \\beta \\quad \\text{ if } SensorReading_t=0 \\text{ and } TargetLoc_t = AgentLoc_t\n    \\\\\n    1-\\alpha \\quad \\text{ if } SensorReading_t=0 \\text{ and } TargetLoc_t \\neq AgentLoc_t\n    \\end{cases}\n    %\n\\end{equation}\n\\begin{center}\n    \\normalsize\n    Conditional Probability Distribution for the $Evidence$ Variable.\n\\end{center}\n%\\caption{Conditional Probability Distribution for the $Evidence$ Variable}\n%\\end{figure}\n\n\n%\\begin{figure}[H]\n\\scriptsize\n\\begin{equation}\\label{eqn:TargetLocProbs}\n    p(TargetLoc_{t} | TargetLoc_{t-1}) =\n    \\begin{cases}\n    1 \\quad \\text{ if } TargetLoc_{t}=TargetLoc_{t-1}\n    %agent returns correct target Loc.} \n    \\\\\n    0 \\quad \\text { otherwise. }\n    \\end{cases}\n\\end{equation}\n%\\caption{Conditional Probability Distribution for the $TargetLocation$ Variable}\n%\\end{figure}\n\\begin{center}\n\\normalsize\n    Conditional Probability Distribution for the $TargetLocation$ Variable\n\\end{center}\n\n\n\n\n\n%\\begin{figure}[H]\n\\scriptsize\n%\\begin{equation}\\label{eqn:SearchStatus}\n    \\begin{gather}\\label{eqn:SearchStatus}\n        p(SearchStatus_t | SearchStatus_{t-1}, Action_{t-1}) = \\\\\n        \\begin{cases}\n        1 \\quad \\text{ if } SearchStatus_t = terminated\\_x_i \\text{ and } SearchStatus_{t-1} = terminated\\_x_i \n        \\\\\n        1 \\quad \\text{ if } Action_t = terminate\\_x_i \\text{ and } SearchStatus_{t-1}=ongoing \\text{ and } SearchStatus_{t} = terminated\\_x_i\n        \\\\\n        1 \\quad \\text{ if } Action_t = move\\_x_i \\text{ and } SearchStatus_{t-1}=ongoing \\text{ and } SearchStatus_t=ongoing\n        %agent returns correct target location.} \n        \\\\\n        0 \\quad \\text { otherwise. }\n        \\end{cases}\n    \\end{gather}\n%\\end{equation}\n%\\caption{Conditional Probability Distribution for the $SearchStatus$ Variable}\n%\\end{figure}\n\\begin{center}\n    \\normalsize\n    Conditional Probability Distribution for the $SearchStatus$ Variable\n\\end{center}\n\n\n\n\n%\\begin{figure}[H]\n\\scriptsize\n    \\begin{equation}\\label{eqn:AgentLocation}\n        p(AgentLoc_t | AgentLoc_{t-1}, Action_{t}) = \n        \\begin{cases}\n        1 \\quad \\text{ if } Action_t = move\\_x_i \\text{ and } AgentLoc_t = x_i\n        \\\\\n        1 \\quad \\text{ if } Action_t = terminate\\_x_i \\text{ and } AgentLoc_t = AgentLoc_{t-1}\n        \\\\\n        0 \\quad \\text{otherwise}\n        \\end{cases}\n    \\end{equation}\n%\\caption{Conditional Probability Distribution for the $AgentLocation$ Variable}\n%\\end{figure}\n\\begin{center}\n    \\normalsize\n    Conditional Probability Distribution for the $AgentLocation$ Variable\n\\end{center}\n\n\\normalsize\nThe semantics of the equations listed above is given here: \n\\begin{enumerate}\n    \\item Equation \\ref{eqn:EvidenceVarsProbs} uses two parameters, $\\alpha$ and $\\beta$, to represent the probability of making a false positive and false negative sensor reading, respectively. These are assumed to have been calculated by using pre-calibrated values of the sensor. This model is does not stipulate any restrictions on the sensor other than that it must return a reading indicating that the target is present or not.\n    \\item  Equation \\ref{eqn:TargetLocProbs} simply states that the location of the target does not change, even though it is hidden. This could be modified to allow for mobile target detection in the case of a non-stationary target by introducing non-unity probabilities in a transition matrix for different values of $TargetLoc_t$ and $TargetLoc_{t-1}$.\n    \\item The first line of Equation \\ref{eqn:SearchStatus} states that once the agent terminates the search, it remains over. The second line states that if the agent requests an ongoing search to terminate, then it does so deterministically. The third line states that if the agent chooses to move in an ongoing search, then the search remains ongoing.\n    \\item Equation \\ref{eqn:AgentLocation} states that the agent moves to new locations deterministically. It also indicates that should the agent choose to terminate the search, then the environment enters a terminal state, indicating that the search is over.\n\\end{enumerate}\n\n\nNote that despite the fact that some hidden state variables cannot be observed directly, it is still possible to infer their value exactly based on their starting state. For example, the position of the agent is a deterministic function of its actions and previous position. %These variables could have been treated as variables that are internal to the agent rather than part of the hidden world state and could have been omitted for the sake of clarity.\n%many authors \n%\\note{need to outline why I have included them - mainly because evidence probability depends on agent location as well as source location}\n\n\n%\\subsection{Analysis of Stochastic Environment Model}\n%\\note{talk about evolution of belief given a sequence of null observations}", "meta": {"hexsha": "e01910ba0c841aac44fa1410806ba005e16abf17", "size": 7751, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/StochasticEnvironmentModel.tex", "max_stars_repo_name": "DavidLSmyth/ResearchMScThesis", "max_stars_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/StochasticEnvironmentModel.tex", "max_issues_repo_name": "DavidLSmyth/ResearchMScThesis", "max_issues_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-06-18T11:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-18T11:59:42.000Z", "max_forks_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/StochasticEnvironmentModel.tex", "max_forks_repo_name": "DavidLSmyth/ResearchMScThesis", "max_forks_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.5546875, "max_line_length": 796, "alphanum_fraction": 0.7555154174, "num_tokens": 1865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.41566175212225537}}
{"text": "\\chapter{Examples for Cyclic Sextic Fields}\n\\label{chap:chap-seven}\nIn this chapter, we will give some examples for cyclic sextic field, using our results or methods given by chapter \\ref{chap:chap-six} to a series of  problems: discriminant, integral basis, decomposition of prime, unit group and class number etc. For the first example in cyclotomic field, there exists a complete theory for that. But as a cyclic sextic number field, using the methods given by chapter \\ref{chap:chap-six}, we also got the structures of it. More precisely, we discover two subfields of it, and then calculate the discriminant which is equal to the result in cyclotomic fields' theorem. Then we also give the prime decomposition of it based on our theorems in section \\ref{sec:primdsex}. Also, we calculate the class number using the general theory. To solve the second field in section \\ref{sec:rcsfexam}, we use almost all preliminaries we mentioned before. We first determine the Galois group of it, then we calculate the polynomial discriminant of it, based on the discriminant formula, then we find two subfields of it. After that, we also find its integral basis and get the prime decompositions. Also, we have tried to calculate the class number of it using general theory, and get the same result as M\\\"{a}ki did. The third section is another example given by A Bremner and B Spearman\\citep{bremner2010cyclic} with sextic trinomial, but unfortunately, we haven't got the final results.\n\n\\section{7-th Cyclotomic Field}\n\\subsection{Cyclotomic Fields}\nLet $\\zeta_n$ denote a fixed primitive $n^{\\text{th}}$ root of unity, and let $\\mathbb{Q}(\\zeta_n)$ be the number field generated by all the $n^{\\text{th}}$ root of unity. The field $\\mathbb{Q}(\\zeta_n)$ is called the $n^{\\text{th}}$ \\textbf{cyclotomic field}. A following result is very import theorem.\n\\begin{theorem}\nLet $\\phi(n)$ denote the (Euler) totient of $n$, then $\\mathbb{Q}(\\zeta_n)$ is an Abelian extension of $\\mathbb{Q}$ of degree $\\phi(n)$. More precisely, there is an isomorphism:\n\\begin{eqnarray*}\n(\\mathbb{Z}/n)^{\\times}&\\rightarrow & \\operatorname{Gal}(\\mathbb{Q}(\\zeta_n)/\\mathbb{Q})\\\\\n\\bar{a}&\\mapsto & \\sigma_a,\n\\end{eqnarray*}\nwhere $\\sigma_a(\\zeta_n)=\\zeta_n^a$\n\\end{theorem}\nSince a sub-extension of an Abelian extension is also Abelian, cyclotomic fields and their subfields already give us an abundant supply of Abelian extensions of $\\mathbb{Q}$.\nMore formally, we have the \n\\begin{theorem}[Kronecker-Weber]\\label{thm:kronecker}\nEvery finite abelian extension of $\\mathbb{Q}$ is contained in a cyclotomic field.\n\\end{theorem}\n\n\\subsection{7-th Cyclotomic Field}\nNow let us consider the simplest cyclic sextic field, a 7-th cyclotomic field. As we all know, $K_6=\\mathbb{Q}(\\zeta_7)$ is generated by $\\zeta_7$, which is a root of unity, and its minimal polynomial is $$f(x)=x^6+x^5+x^4+x^3+x^2+x+1.$$\n\nFirst of all, we would know its structure. As we known in Section \\ref{sec:unitccsf}, this field is a CM-field, i.e. a totally imaginary extension of a totally complex cyclic cubic field. Write as before, we have $K_6=\\mathbb{Q}(\\sqrt{m},\\theta)$, where $m$ is a negative squarefree integer. Now we need to find the minimal polynomials for $\\sqrt{m}$ and $\\theta$.\n\nNote that $\\zeta_7^i$ is complex conjugate to $\\zeta_7^{-i}$, so let $\\xi=\\zeta_7+\\frac{1}{\\zeta_7}$, then $\\xi$ is a real number\\footnote{One can find that $\\xi=2\\cos\\frac{2\\pi}{7}$.}. Since $\\zeta_7$ is a root of the minimal polynomial, then we have $$\\zeta_7+\\frac{1}{\\zeta_7}+\\zeta_7^2+\\frac{1}{\\zeta_7^2}+\\zeta_7^3+\\frac{1}{\\zeta_7^3}+1=0,$$ Substitute $\\xi$ into the equation, we have \\begin{equation}\\label{eqn:xi}\ng(\\xi)=\\xi^3+2\\xi^2-2\\xi-1=0\n\\end{equation}\nLet $x=\\xi-\\frac{2}{3}$, we can change it into the standard form, i.e. $$x^3-x^2-2x+\\frac{13}{27},$$\nwhere we can get $e=7,u=-1,v=1$, hence, the cyclic cubic subfield defined by $\\xi$, where $\\xi$ is a solution of equation \\ref{eqn:xi}. i.e. $K^+=K_3=\\mathbb{Q}(\\xi)$.\n\nFrom theorem \\ref{thm:ccpoly}, we got the discriminant of $K_3$ is $49=f_3^2$, and since $v=1$, we got that $(1,\\xi,\\xi^2)$ is a power integral basis of $K_3$.\n\nOn the other hand, note that the automorphism $\\sigma_2:\\zeta_7\\rightarrow\\zeta_7^2$ generates the subgroup of order 3. Thus consider $\\omega=\\zeta_7+\\zeta_7^2+\\zeta_7^4$.\nFrom the properties of root of unity, we have following two equations: $$(\\zeta_7+\\zeta_7^2+ \\zeta_7^4)+(\\zeta_7^3+\\zeta_7^6+\\zeta_7^{12})=-1,$$\n$$(\\zeta_7+\\zeta_7^2+ \\zeta_7^4)(\\zeta_7^3+\\zeta_7^6+\\zeta_7^{12})=3-1=2$$\n\nThen $\\omega$ satisfies a quadratic equation: $$h(x)=x^2+x+2=0,$$ hence $\\mathbb{Q}(\\omega)$ is a quadratic subfield, and $K_2=\\mathbb{Q}(\\sqrt{-7})$. Then the discriminant of $K_2$ is $-7=f_2$. From theorem \\ref{thm:sexdisccom}, we have the discriminant of $K_6$ is $d(K_6)=(-7)\\times(7)^2\\times(7)^2=-7^5$.\n\nA famous result for discriminant of $\\mathbb{Q}(\\zeta_p)$, where $p$ is a prime, is that $\\operatorname{Disc}(\\mathbb{Q}(\\zeta_p))=(-1)^{(p-1)/2}p^{p-2}$. In this field, we have $\\operatorname{Disc}(\\mathbb{Q}(\\zeta_7))=(-1)^{3}7^{7-2}=-7^5$, which coincides our result.\n\nTo sum up, we got that $K_6=\\mathbb{Q}(\\xi,\\sqrt{-7})$. As for the prime decomposition, the discriminant has only one prime divisor, namely $7$, hence only $7$ is ramified in $K_6$. what's more, since $7$ is common factor of $f_2$ and $f_3$, hence it is totally ramified. In fact, since $K_6$ is monogenic, we have $(x+6)^6 (\\operatorname{mod} 7)$. For other primes, we just need to consider the decomposition in subfields, the using the result in section \\ref{sec:primdsex}. For example, consider $p=37$, note that $$\\left(\\frac{-7}{37}\\right)=(-1)^{(37-1)/2}\\left(\\frac{7}{37}\\right)=(-1)^{(7-1)(37-1)/4}\\left(\\frac{37}{7}\\right)=-\\left(\\frac{2}{7}\\right)=1$$ Hence $37$ is ramified in $K_2$. On the other hand, similarly, consider we just need to verify that $49^{(37-1)/3}\\equiv 1 (\\operatorname{mod }37)$ or not. However, $49^{(37-1)/3}\\equiv 12^{12} \\equiv (-4)^6\\equiv (-10)^2\\equiv 26\\not\\equiv 1 (\\operatorname{mod} 37)$, hence $37$ is inert in $K_2$. Hence, $37=\\wp_1\\wp_2$.\n\nAs for the unit group of $K_6$, we first refer a theorem  \\citep{Xianke2006ANT} which is a corollary of theorem \\ref{thm:unitcomplexsec} as follows:\n\\begin{theorem}\nLet $m=p^s$, where $p$ is an odd prime, $s\\in\\mathbb{N^*}$, then $K=\\mathbb{Q}(\\zeta_m)$ has the same system of fundamental units to $K^+=\\mathbb{Q}(\\zeta_m+\\zeta_m^{-1})$.  \n\\end{theorem}\n\nSo from Dirichrlet Theorem \\ref{thm:Dirichlet}, $U(K_6)=\\mu(K_6)\\times \\mathbb{Z}^2$, where $\\mu(K_6)=\\langle\\zeta_7\\rangle$ is the root of unity of $K$ and the fundamental units are the same to $K_3$. The fundamental units in $K_3$ are $$(-1+\\xi+\\xi^2,2-\\xi^2)=(1+\\zeta_7+\\zeta_7^2+\\zeta_7^{-1}+\\zeta_7^{-2},-\\zeta_7^{-2}-\\zeta_7^{2}).$$\n\nAs for the class number, firstly, we compute the Minkowski's bound, and we get $$C(K_6)=\\left(\\frac{4}{\\pi}\\right)^3\\frac{6!}{6^6}\\sqrt{|-7^5|}=4.13$$\nHence $Cl(K_6)=\\langle[\\wp]|\\wp|2\\text{ or }3\\rangle$\n\nnow we consider the decomposition of $2$ and $3$. since $\\left(\\frac{-7}{2}\\right)=1$, hence it splits in $K_2$. On the other hand, $x^3+x^2-2x-1\\equiv x^3+x^2+1 (\\operatorname{mod} 2)$, i.e. it's inert in $K_3$, hence $2=\\wp_1\\wp_2$\\footnote{Here we haven't use cubic reciprocity, since there is no definition for $p=2$(in fact it only define in $p=3k+1$, like quadratic reciprocity defined in $p=2k+1$).}. In fact, $\\wp_1=(2,1+\\xi+\\xi^3),\\wp_2=(2,1+\\xi^2+\\xi^3)$, since $1+\\xi^2+\\xi^3$ is conjugate to $1+\\xi+\\xi^3$, hence $[\\wp_1]=[\\wp_2]=1$.\n\nFor $p=3$, it's easy to see that $\\left(\\frac{-7}{3}\\right)=-1$ and $x^3+x^2-2x-1$ is irreducible in $\\mathbb{F}_3$, hence $p=3$ is inert in $K_6$. To sum up, we have the class number is $1$.\n\n\n\\section{A Real Cyclic Sextic Field}\\label{sec:rcsfexam}\nConsider the sextic field $K_6$ generated by a root of $$f(x)=x^6-x^5-6x^4+6x^3+8x^2-8x+1.$$ First note that $f(x)$ is irreducible over $\\mathbb{Q}$, since $f(x)\\equiv x^6+x^5+1 (\\operatorname{mod} 2)$. In order to verify the Galois group of the splitting field of $f$, we should first compute the resolvent polynomials. Let $p_1=x_1+x_2$, $p_2=x_1+x_2+x_3$, then use the numerical method, we have the approximate root of $f$ are: $$(r_1,r_2,r_3,r_4,r_5,r_6)=(-1.97766,-1.46610,0.14946,0.73068,1.65248,1.91115)$$\nThen, \\begin{eqnarray*}\nR_{p_1,f}(y)&=&\\prod_{p_{1i}\\in orb(p)}(y-p_{1i}(r_1,\\dots,r_6))\\\\\n&=& x^{15}-5x^{14}-14x^{13}+98x^{12}+7x^{11}-567x^{10}+280x^9+1404x^8\\\\\n&&-818x^7-1596x^6+735x^5+700x^4-203x^3-77x^2+11x+1\\\\\n&=&(x^3-x^2-2 x+1)(x^6-2 x^5-10 x^4+6 x^3+30 x^2+17 x+1)\\\\\n&&(x^6-2 x^5-10 x^4+27 x^3-12 x^2-4 x+1)\n\\end{eqnarray*} \n\nSo we have $(3,6^2)$ cycle, from table \\ref{tab:allorbits}, we have that the Galois group of $f$ is either $C_6$ or $D_6$. Then we calculate $R_{p_2,f}$,\n\\begin{eqnarray*}\nR_{p_2,f}(y)&=&\\prod_{p_{2i}\\in orb(p)}(y-p_{2i}(r_1,\\dots,r_6))\\\\\n&=& x^{20} + 2 x^{19} - 106 x^{18} - 600 x^{17} - 593 x^{16} + 3252 x^{15} - 6530 x^{14}\\\\\n&& -2589 x^{13} + 4875 x^{12} - 675 x^{11} - 1759 x^{10} + 3349 x^9 + 5376 x^8 + 1260 x^7 \\\\\n&&+ 1188 x^6 + 865 x^5 + 316 x^4 + 77 x^3 + 23 x^2 + 11 x + 1\n\\\\\n&=&(x^2 - x + 1) (x^6 - 12 x^5 + 3 x^4 + 7 x^3 + 6 x^2 - 2 x + 1) \\\\\n&&(x^6 + 8 x^5 + 25 x^4 + 2 x^3 + 5 x^2 + 2 x + 1) \\\\\n&&(x^6 + 7 x^5 - 8 x^4 + 4 x^3 + 27 x^2 + 12 x + 1)\n\\end{eqnarray*}  \nSo we have $(2,6^3)$ cycle, from table \\ref{tab:allorbits}, we have that the Galois group of $f$ is $C_6$, also we know $K_6$ is totally real.\n\nThe polynomial discriminant of $f$ could be given by formula \\ref{prop:disctri}, in fact, $\\operatorname{Disc}(f)=453789=3^3\\times7^5$\nNote that, $d(K_6)=f_2f_3^2f_6^2$ by theorem \\ref{thm:sexdisc}, since $f_6=\\operatorname{lcm}(f_2,f_3)$, hence we have $f_2^3|d(K_6)$ and $f_3^4|d(K_6)$. The relation between $d(K_6)$ and $\\operatorname{Disc}(f)$ is showed in lemma \\ref{lem:discpoly-field}, i.e. $\\operatorname{Disc}(f)=a^2d(K_6)$, here we have $$3^3\\times 7^5=a^2 f_2f_3^2f_6^2,$$ from the requirements we mentioned above, we have $$a^2f_3^4|3^3\\times7^5,$$ this force $f_3=7$, and $a=1$ or $a=3$. Then $a^2f_2^3f_3^2|3^3\\times7^5$, i.e. $$a^2f_2^3|3^3\\times7^3.$$ If $a=3$, then $f_2=7$, and for this case $d(K_6)=7^5$, and we get $3^3d(K_6)=\\operatorname{Disc}(f)$. An contradiction! Hence, $a=1$, and we could get $f_2=3\\times7$.\n\nTo sum up, we have $f_2=21,f_3=7$. So we can immediately get the quadratic subfield is $\\mathbb{Q}(\\sqrt{21})$, with minimal polynomial $g(x)=x^2-x-5$, and integer ring $\\mathbb{Z}\\left[\\frac{1+\\sqrt{21}}{2}\\right]$. \\footnote{In fact, since $\\phi(21)=\\phi(3)\\times\\phi(7)=12$ and $6|12$, actually this cyclic sextic field is a subfield of the cyclotomic field $\\mathbb{Q}(\\zeta_21)$.}  As for the cyclic cubic subfield, since $e=f_3=7$, and $v=1$, hence we have the minimal polynomial of $\\theta$, $h(x)=x^3-x^2-2x+\\frac{13}{27}$ with power integral $(1,\\theta,\\theta^2)$. To sum up, $$K_6=\\mathbb{Q}(\\theta,\\sqrt{21})$$\n\nSince $d(K_6)=\\operatorname{Disc}(f)$, hence $K_6$ has a power integral basis, wlog, let $r$ be a root of $f$, then $(1,r,r^2,\\dots,r^5)$ is a integral basis. On the other hand, we have another integral basis given by theorem \\ref{thm:intbasis_sex}.\n\nThe prime decomposition is quite easy, $7$ is totally ramified in $K_6$, since it is ramified in both two subfield. In fact, $f(x)\\equiv (x+1)^6 (\\operatorname{mod} 7)$. Hence $7O_{K_6}=\\wp^6$, where $\\wp=(7,r+1)$. $3$ is ramified in $K_2$, and inert in $K_3$, hence $2O_{K_6}=\\wp'^2$. The other prime's situation could be solved through theorem \\ref{thm:csf-unramified}.\n\nAs for the class number, we first compute the Minkowski's bound, $$C_{K_{6}}=(4/\\pi)^{0}\\frac{6!}{6^6}\\sqrt{453789}=10.4,$$ now we should consider $p=2,3,5,7$. we can find that $2$ is inert in $O_{K_6}$. $7$ is totally ramified with $\\wp=(7,r+1)$, while $N(r+1)=7$\\footnote{calculate through $f(x-1)$}, $(r+1)\\subset(7)$, hence $\\wp=(r+1)$ is a principal ideal.\n\nAs for $p=3$, we have $f(x)\\equiv(2+x+x^2+x^3)^2 (\\operatorname{mod} 3)$, hence $\\wp'=(3,2+r+r^2+r^3)$, $N(2+r+r^2+r^3)=3$ hence $\\wp'=(2+r+r^2+r^3)$. Similar result for $p=5$. Finally, we get $h(K_6)=1$.\n\n\\section{Sextic Trinomials}\nAs expected, increasing the degree of a polynomial will increase its complexity. In the case of sextics, however, the number of possible Galois groups jumps up to sixteen. We can once again find a list of these groups in Cohen's book and we expect $S_6$ to be the most frequently occurring group. \n\nIt is much more preferable to work with sextic trinomials rather than general sextics. Again, we can reduce the possible unique forms of these trinomials to only $x^6+ax+b,x^6+ax^2+b,x^6+ax^3+b$. Note that the last of these three forms can be simplified to a quadratic in $x^3$.\n\nIt has already been shown by A Bremner and B Spearman \\citep{bremner2010cyclic} that up to scaling, there exists a single, unique sextic trinomial with Galois group isomorphic to $C_6$; which was given as\n$$f(x)=x^6+133x+209$$\n\nNow we focus on this example, i.e. $K_6$ is the splitting field of $f(x)$. First of all, since $f(x)\\equiv x^6+x+1(\\operatorname{mod} 2)$, hence $f(x)$ is irreducible over $\\mathbb{Q}$.  Then, we can compute the discriminant of the polynomial, from formula \\ref{for:nxpxq}, we have $$\\operatorname{Disc}(f)=(-1)^{\\frac{4\\times5}{2}}\\cdot 5^5\\cdot 133^6+(-1)^{\\frac{6\\times5}{2}}\\cdot 6^6\\cdot 209^5=-19^5\\times83^2\\times277^2.$$\n\nWe have $d(K_6)=f_2f_3^2f_6^2$ by theorem \\ref{thm:sexdisc}, since $f_6=\\operatorname{lcm}(f_2,f_3)$, hence we have $f_2^3|d(K_6)$ and $f_3^4|d(K_6)$. The relation between $d(K_6)$ and $\\operatorname{Disc}(f)$ is showed in lemma \\ref{lem:discpoly-field}, i.e. $\\operatorname{Disc}(f)=a^2d(K_6)$. Whatever, $f_3^4|d(K_6)$ force that $f_3=19$ and $-19|f_2$. There are several possible cases for $d(K_6)$:\n\\begin{equation*}\n\\left\\{ \\begin{array}{l}\nf_3=19,f_2=-19;\\\\\nf_3=19,f_2=-19\\times 83;\\\\\nf_3=19,f_2=-19\\times 277;\\\\\nf_3=19,f_2=-19\\times 83\\times 277.\n\\end{array} \\right.\n\\end{equation*}\nTo recognize the case for the field generated by a root of $f$, we need another method. However, this example is still under solving.\n\n", "meta": {"hexsha": "cb3e6a15b444dacaf3d806b771100a0ed4bcf0d4", "size": 14111, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter/chap-seven.tex", "max_stars_repo_name": "daidahao/sustcthesis", "max_stars_repo_head_hexsha": "af536c6559c5a8a3c1315438b99d166153665187", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2019-03-17T08:46:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-12T02:50:26.000Z", "max_issues_repo_path": "chapter/chap-seven.tex", "max_issues_repo_name": "daidahao/sustcthesis", "max_issues_repo_head_hexsha": "af536c6559c5a8a3c1315438b99d166153665187", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter/chap-seven.tex", "max_forks_repo_name": "daidahao/sustcthesis", "max_forks_repo_head_hexsha": "af536c6559c5a8a3c1315438b99d166153665187", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2015-06-17T06:55:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-17T01:21:27.000Z", "avg_line_length": 120.6068376068, "max_line_length": 1410, "alphanum_fraction": 0.6841471193, "num_tokens": 5411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.41566173491631403}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** Second Chapter *****************************\n%*******************************************************************************\n\n\\chapter{Formulations of the Relativistic Hydrodynamics}  %Title of the Second Chapter\n\n\\ifpdf\n    \\graphicspath{{Chapter2/Figs/PDF/}{Chapter2/Figs/}}\n\\else\n    \\graphicspath{{Chapter2/Figs/}}\n\\fi\n\n\n%********************************** %First Section  **************************************\n\\section{Relativistic Hydrodynamics} %Section - 2.1\nIn the previous chapter, we explored the formulation of the left hand side of the Einstein equations.\nIn this chapter, we focus on the right hand side of the equations,\nspecifically the 3+1 treatment of perfect fluid in conservative form \\cite{marti1991numerical,rezzolla2013relativistic}.\n\n\\subsection{Perfect fluid}\n\\label{section2.1.1}\nIn this section, we consider relativistic \\textit{perfect fluid} (i.e. no viscous effects and heat fluxes).\nThe energy-momentum tensor of perfect fluid is given by\n\\begin{align}\n    T^{\\mu\\nu} = \\rho h u^\\mu u^\\nu + p g^{\\mu\\nu},\n\\end{align}\nwhere $\\rho$ is the rest-mass density, \n$u^\\mu$ is the fluid 4-velocity,\n$h = 1 + \\epsilon + \\frac{p}{\\rho}$ is the enthalpy, \n$p$ is the pressure, \nand $\\epsilon$ is the specific internal energy.\\\\\nThe \\textit{Lorentz factor} $W$ of the fluid with respects to the Eulerian observers is given by \nthe projection of fluid 4-velocity $u^\\mu$ to $n^\\mu$\n\\begin{align}\n    W \\coloneqq - n_{\\mu} u^\\mu = \\alpha u^t.\n\\end{align}\nThus, the spatial 4-velocity of a fluid measured by Eulerian observers is\n\\begin{align}\n    v^\\mu \\coloneqq \\frac{\\gamma_{\\nu}{}^{\\mu} u^\\nu} {W},\n\\end{align}\nor in component form\n\\begin{align}\n    v^t &= 0, & v^i &=  \\frac{u^i}{W} + \\frac{\\beta^i}{\\alpha}, \\\\\n    v_t &= \\beta_i v^i, & v_i &= \\frac{u_i}{W}.\n\\end{align}\nAs a result, the \\textit{Lorentz factor} can also be written as\n\\begin{align}\n    W = \\frac{1}{\\sqrt{1-v_i v^i}}.\n\\end{align}\nThe dynamics of fluid are governed by the equations of rest-mass conservation and energy momentum conservation.\nThe system is closed by the equation of state (EOS) of the fluid,\nwhich reflects the thermodynamic properties of the fluid at a macroscopic level.\nHere, we consider two common analytic equation of state as follows:\n\\begin{enumerate}\n    \\item Ideal-gas\n    \\begin{align}\n        p = (\\Gamma-1)\\rho \\epsilon,\n    \\end{align}\n    where $\\Gamma$ is the polytropic index of the gas.\n    \\item Polytropic EOS \n    \\begin{align}\n        p = K\\rho^\\Gamma,\n    \\end{align}\n    where $\\Gamma$ again is the polytropic index the gas, and $K$ is a constant of proportionality.\n\\end{enumerate}\n\n\\subsection{Rest-mass conservation}\n\\label{section2.1.2}\nThe general-relativistic conservation of rest-mass is given by\n\\begin{align}\n    \\nabla_\\mu J^\\mu &= 0, & J^\\mu &\\coloneqq \\rho u^\\mu,\n\\end{align}\nwhere $J^\\mu$ is the rest-mass current density.\nUnder 3+1 decomposition, the rest-mass conservation can be written as\n\\begin{align}\\label{eq:mass_cons}\n    \\partial_t \\left(\\sqrt{\\gamma}D\\right) + \\partial_i \\left[\\sqrt{\\gamma} D \\left(\\alpha v^i - \\beta^i \\right) \\right] = 0,\n\\end{align}\nwhere\n\\begin{align}\n    D \\coloneqq \\rho \\alpha u^t = \\rho W,\n\\end{align}\nis the conserved quantity.\n\n\\subsection{Energy and momentum conservation}\n\\label{section2.1.3}\nOther than the conservation of rest-mass, the energy and momentum conservation of the fluid must also be satisfied\n\\begin{align}\n    \\nabla_\\nu T^{\\mu\\nu} = 0.\n\\end{align}\nFollowing the 3+1 decomposition of stress-energy tensor introduced in equation (\\ref{eq:T_decompose}),\nthe fluid quantities in the case of perfect fluid become\n\\begin{align}\n    S^{\\mu\\nu} &= \\rho h W^2 v^\\mu v^\\nu + p \\gamma^{\\mu\\nu}, \\\\\n    S^\\mu &= \\rho h W^2 v^\\mu, \\\\\n    E &= \\rho h W^2 - p.\n\\end{align}\nThe conservation of energy and momentum hence leads to\n\\begin{align}\n    &\\partial_t \\left( \\sqrt{\\gamma} S_j \\right) + \\partial_i \\left[\\sqrt{\\gamma} \\left(\\alpha S^i{}_j - \\beta^i S_j\\right) \\right]\n    = \\sqrt{\\gamma} \\left(\\frac{1}{2} \\alpha S^{ik} \\partial_j \\gamma_{ik} + S_i \\partial_j \\beta^i - E \\partial_j \\alpha\\right), \\label{eq:mom_cons} \\\\\n    &\\partial_t \\left( \\sqrt{\\gamma} E \\right) + \\partial_i \\left[ \\sqrt{\\gamma} \\left(\\alpha S^i - \\beta^i E \\right) \\right]\n    = \\sqrt{\\gamma} \\left(\\alpha K_{ij} S^{ij} - S^i \\partial_i \\alpha \\right). \\label{eq:E_cons}\n\\end{align}\nEquation (\\ref{eq:E_cons}) can also be written as\n\\begin{align}\n    &\\partial_t \\left( \\sqrt{\\gamma} \\tau \\right) + \\partial_i \\left[\\sqrt{\\gamma} \\left(\\alpha\\left(S^i - D v^i \\right) - \\beta^i \\tau \\right)\\right]\n    = \\sqrt{\\gamma} \\left(\\alpha K_{ij} S^{ij} - S^i \\partial_i \\alpha \\right). \\label{eq:tau_cons},\n\\end{align}\nto obtain better numerical accuracy,\nwhere the conserved quantity $\\tau$ is defined as\n\\begin{align}\n    \\tau \\coloneqq E - D.\n\\end{align}\n\n\\subsection{Conservative form of hydrodynamics equations}\n\\label{section2.1.4}\nHere, we summarize \\cref{eq:mass_cons,eq:mom_cons,eq:tau_cons} and express in conservative form\n\\begin{align}\n    \\partial_t \\left(\\sqrt{\\gamma} \\mathbf{Q} \\right) \\partial_i \\left(\\sqrt{\\gamma} \\mathbf{F}^i \\right) = \\sqrt{\\gamma} \\mathbf{S},\n\\end{align}\nwhere the conserved variables $\\mathbf{Q}$, flux terms $\\mathbf{F}^i$ and source terms $\\mathbf{S}$ are\n\\begin{align}\n    & \\mathbf{Q} =\n    \\begin{pmatrix}\n    D \\\\\n    S_j \\\\\n    \\tau\n    \\end{pmatrix}\n    =\n    \\begin{pmatrix}\n    \\rho W \\\\ \n    \\rho h W^2 v_j \\\\ \n    \\rho h W^2 - p - D\n    \\end{pmatrix},\\\\\n    & \\mathbf{F}^i =\n    \\begin{pmatrix}\n    D\\left(\\alpha v^i -\\beta^i \\right) \\\\\n    S_j \\left( \\alpha v^i - \\beta^i \\right) + \\alpha \\delta^i{}_j p \\right) \\\\\n    \\tau left( \\alpha v^i - \\beta^i \\right) + \\alpha p v^i \\right) \n    \\end{pmatrix},\\\\\n    & \\mathbf{S} =\n    \\begin{pmatrix}\n    0 \\\\\n    \\frac{1}{2} \\alpha S^{ik} \\partial_j \\gamma_{ik} + S_i \\partial_j \\beta^i - E \\partial_j \\alpha \\\\\n    \\alpha K_{ij} S^{ij} - S^i \\partial_i \\alpha\n    \\end{pmatrix},\n\\end{align}\nwhich is commonly known as the \"\\textit{Valencia formulation}\" of the relativistic-hydrodynamics equatons. \\\\\nThe characteristic speeds of such system is given by\n\\begin{align}\\label{eq:valencia}\n    \\lambda_0 &= \\alpha v^i - \\beta^i \\qquad \\text{(triple eigenvalue)},\\\\\n    \\lambda_{\\pm} &= \\frac{\\alpha}{1-v^2 c_s^2} \\left\\{ v^i \\left(1-c_s^2 \\right) \n    \\pm c_s^2 \\sqrt{\\left(1-v^2 \\right) \\left[\\gamma^ii \\left(1- v^2 c_s^2 \\right) - {v^i}^2\\left(1-c_s^2 \\right) \\right]} \\right\\},\n\\end{align}\nwhere $\\lambda_{\\pm}$ measures the propagation speeds of the \\textit{acoustic waves} of the system,\nand $\\lambda_0$ corresponds to the propagation speed of \\textit{matter waves}.\n\n\\subsection{Conserved to Primitive variables conversion} \n\\label{section2.1.5}\nIt is not trivial to convert the conserved variables $\\left(D,S_i,\\tau\\right)$ introduced in section \\ref{section2.1.4}\nto primitive variables $\\left(\\rho, W, v^i, p\\right)$ in relativistic hydrodynamics.\nOne must solve non-linear equations numerically.\nIn \\texttt{Gmunu}, we adopted the routine used in \\cite{galeazzi2013implementation}.\nThe implementation details are included here:\n\\begin{Step}\n    \\item Calculate the rescaled variables and some useful relations which are fixed during the iterations\n    \\begin{align}\n        S &\\coloneqq \\sqrt{S_i S^i}, \\\\\n        r &\\coloneqq \\frac{S}{D}, & q &\\coloneqq \\frac{\\tau}{D}, & k &\\coloneqq \\frac{S}{\\tau + D}.\n    \\end{align}\n    \\item Determine the bounds of the root\n    \\begin{align}\n        z_- &\\coloneqq \\frac{k/2}{\\sqrt{1-k^2/4}}, & z_+ &\\coloneqq \\frac{k}{\\sqrt{1-k^2}}.\n    \\end{align}\n    \\item In the inverval $\\left[z_-, z_+ \\right]$, we solve\n    \\begin{align}\\label{eq:cons2prim_root}\n        f(z) = z - \\frac{r}{\\hat{h}(z)},\n    \\end{align}\n    where\n    \\begin{align}\n        \\hat{h}(z) &= \\left(1+\\hat{\\epsilon}(z) \\right) \\left( 1+ \\hat{a}(z) \\right),\n    \\end{align}\n    \\begin{align}\n        \\hat{\\epsilon}(z) &= \\hat{W}(z)q - zr + \\frac{z^2}{1+\\hat{W}(z)},\n        & \\hat{a}(z) &= \\frac{\\hat{p}(z)}{\\hat{\\rho}(z)\\left( 1 + \\hat{\\epsilon}(z) \\right) },\n    \\end{align}\n    \\begin{align}\n        \\hat{p}(z) &= p\\left(\\hat{\\rho}(z), \\hat{\\epsilon}(z) \\right),\n        & \\hat{\\rho}(z) &= \\frac{D}{\\hat{W}(z)},\n        & \\hat{W}(z) &= \\sqrt{1+z^2}.\n    \\end{align}\n    Equation (\\ref{eq:cons2prim_root}) is solved using Illinois algorithm in \\texttt{Gmunu}.\n    Note that during the iterations, we enforce the density $\\rho$ and the specific energy $\\epsilon$ fail into the validity region of the EOS,\n    i.e., we evalue the updated $\\rho$ and $\\epsilon$ with \n    $\\hat{\\rho}(z) = \\max\\left(\\min\\left(\\rho_\\max{},\\hat{\\rho}\\right),\\rho_\\min{}\\right)$ and\n    $\\hat{\\epsilon}(z) = \\max\\left(\\min\\left(\\epsilon_\\max{},\\hat{\\epsilon}\\right),\\epsilon_\\min{}\\right)$.\n    \\item With the root $z_0$ of \\cref{eq:cons2prim_root},\n    we can then work out the primitive variables $\\left(\\rho, \\epsilon, p\\right)$ respectively with the equations used in step 3.\n    For the velocity $v^i$, it can be obtained with $z$ by\n    \\begin{align}\n        \\hat{v}^i(z) = \\frac{S^i/D}{\\hat{h}(z)\\hat{W}(z)}.\n    \\end{align}\n\\end{Step}\n\n%********************************** %Second Section  *************************************\n\\section{The reference-metric formalism} %Section - 2.2\n\\label{section2.2}\nThe reference-metric formalism, a generalization of the \"\\textit{Valencia}\" formulation, was original proposed by Montero \\cite{montero2014general} in 2014 for general relativistic hydrodynamics (GRHD)\nand later extended to ideal magnetohydrodynamics.\nWith the conformal decomposition introduced in section \\ref{section1.3.1},\nthe determinant of the spatial metric can be rewritten as\n\\begin{align}\\label{eq:reference_metric_1}\n    \\begin{split}\n    \\sqrt{\\gamma} &= \\psi^6 \\sqrt{\\tilde{\\gamma}} \\\\\n    &= \\sqrt{\\hat{\\gamma}} \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}},\n    \\end{split}\n\\end{align}\nwhere $\\hat{\\gamma}_{ij}$ is the \\textit{time-independent reference metric}\nwhich can be chosen to fit the mesh grid in curvilinear coordinate.\nTherefore, the \"\\textit{Valencia}\" formulation in equation (\\ref{eq:valencia}) can be generalized as\n\\begin{align}\n    \\partial_t \\mathbf{q} + \\hat{\\nabla}_i \\mathbf{f}^i = \\mathbf{s},\n\\end{align}\nwhere $\\hat{\\nabla}_i$ is the corvariant derivatives sociated with the time-independent reference metric $\\hat{\\gamma}_{ij}$,\n$\\left(\\mathbf{q},\\mathbf{f}^i,\\mathbf{s}\\right)$ are the $\\textit{conformally rescaled}$ conserved variables,\nfluxes and source terms respectively.\\\\\nComparing to the \"\\textit{Valencia}\" formulation,\nthe hydrodynamical equations in reference-metric approach are numerically more accurate in curvilinear coordinates in multi-dimensional simulation,\nespecially when symmetry is imposed.\nEquation (\\ref{eq:reference_metric_1}) can be further written as\n\\begin{align}\n    \\partial_t \\mathbf{q} + \\frac{1}{\\sqrt{\\hat{\\gamma}}}\\partial_j \\left(\\sqrt{\\hat{\\gamma}} \\mathbf{f}^j \\right) = \\mathbf{s} + \\mathbf{s}_{geom},\n\\end{align}\nwhere $\\mathbf{s}_{geom}$ are the \\textit{geometrical} source terms \nwhich contain the 3-Christoffel symbols $\\hat{\\Gamma}^i{}_{jk}$ associated with the reference metric $\\hat{\\gamma}_{ij}$. \\\\\nNote that the momentum conservation in this expression satisfy to \\textit{machine precision} rather than to the level of truncation error \ndue to the fact that the geometrical source terms $\\mathbf{s}_{geom}$ are identically vanishing \nfor the components associated with ignorable coordinates in the metric.\n\n\\subsection{General relativistic hydrodynamics (GRHD) equations}\n\\label{section2.2.1}\nThe equations of relativistic hydrodynamics in reference-metric approach is given by\n\\begin{align}\n    \\partial_t \\left( q_{D} \\right) + \\frac{1}{\\sqrt{\\hat{\\gamma}}} \\partial_j \\left[ \\sqrt{\\hat{\\gamma}} \\left( f_{D} \\right)^j \\right]\n    &= 0, \\\\\n    \\partial_t \\left( q_{S_i} \\right) + \\frac{1}{\\sqrt{\\hat{\\gamma}}} \\partial_j \\left[ \\sqrt{\\hat{\\gamma}} \\left( f_{S_i} \\right)^j \\right]\n    &= s_{S_i} + \\hat{\\Gamma}^l{}_{ik}\\left( f_{S_l} \\right)^k, \\\\\n    \\partial_t \\left( q_{\\tau} \\right) + \\frac{1}{\\sqrt{\\hat{\\gamma}}} \\partial_j \\left[ \\sqrt{\\hat{\\gamma}} \\left( f_{\\tau} \\right)^j \\right]\n    &= s_{\\tau}, \\\\\n\\end{align}\nThe conformally rescaled conserved quantities $\\mathbf{q}$ are\n\\begin{align}\n    q_D & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} D = \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left( \\rho W \\right), \\\\\n    q_{S_i} & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} S_i = \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left( \\rho h W^2 v_i \\right), \\\\\n    q_\\tau & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\tau = \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left( \\rho h W^2 - p - D \\right).\n\\end{align}\nThe flux terms $\\mathbf{f}^i$ are\n\\begin{align}\n    \\left(f_D \\right)^i & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left( D \\hat{v}^i \\right), \\\\\n    \\left(f_{S_j} \\right)^i & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left(S_j \\hat{v}^i + \\delta^i{}_j \\alpha p \\right), \\\\\n    \\left(f_\\tau \\right)^i & \\coloneqq \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \\left(\\tau \\hat{v}^i + \\alpha p v^i \\right),\n\\end{align}\nwhere $\\hat{v}^i \\coloneqq \\alpha v^i -\\beta^i$.\\\\\nFinally, the source terms $\\mathbf{s}$ are\n\\begin{align}\n    s_D &= 0, \\\\\n    s_{S_i} &= \\alpha \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}} \n    \\left[ - T^{00} \\alpha\\partial_i \\alpha + T^0{}_k \\hat{\\nabla}_i \\beta^k\n    + \\frac{1}{2} \\left( T^{00} \\beta^j \\beta^k + 2 T^{0j} \\beta^k + T^{jk} \\right) \\hat{\\nabla}_i \\gamma_{jk} \\right], \\\\\n    s_\\tau &= \\alpha \\psi^6 \\sqrt{\\tilde{\\gamma}/\\hat{\\gamma}}\n    \\left[ T^{00} \\left(K_{ij}\\beta^i \\beta^j - \\beta^k \\partial_k \\alpha \\right)\n    + 2 T^{0j} \\left( 2 K_{jk} \\beta^k - \\partial_j \\alpha \\right) \n    + T^{ij} K_{ij} \\right].\n\\end{align}\n", "meta": {"hexsha": "efe447c2dee29cb7d49a84e3a28b5f4cc94e73b7", "size": 13910, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter2/chapter2.tex", "max_stars_repo_name": "alanlam1002/MPhil_thesis", "max_stars_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter2/chapter2.tex", "max_issues_repo_name": "alanlam1002/MPhil_thesis", "max_issues_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter2/chapter2.tex", "max_forks_repo_name": "alanlam1002/MPhil_thesis", "max_forks_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-04T05:39:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-04T05:39:22.000Z", "avg_line_length": 50.3985507246, "max_line_length": 201, "alphanum_fraction": 0.645938174, "num_tokens": 4604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.41565459927447623}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath,amsfonts,tikz,hyperref}\n\\usepackage{fontenc}\n\\usepackage{graphicx}\n\\usepackage[euler-digits]{eulervm}\n\\title{FinElt Quick Start Guide}\n\\author{William McLean}\n\\date{\\today}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\maketitle\nTo use FinElt you need to install \\href{www.julialan.org}{Julia}~and \n\\href{www.geuz.org/gmsh/}{Gmsh}~\\cite{Gmsh}.  Versions for Windows or \nOS~X can be downloaded from the project websites.  Under Linux, you\nmight be able to use your distribution's package manager.  For \nexample, I develop FinElt on \\href{www.fedoraproject.org}{Fedora~31}, \nand can simply do\n\\begin{verbatim}\n# dnf install julia gmsh \n\\end{verbatim}\nAt the time of writing (January 2020), this command installs Julia~1.2.0 and\nGmsh~4.4.1.\n\nWhatever platform you are using, once Julia is installed you can \neasily set up FinElt:\n\\begin{verbatim}\njulia> Pkg.clone(\"https://github.com/billmclean/FinElt.jl\")\n\\end{verbatim}\nThis guide will walk you through two examples.  The first is a \n``hello world'' problem, that explains the basic usage of FinElt.\nThe second is more elaborate and shows more of the capabilities of \nthe package.  The source code for both problems is in the \n\\texttt{examples/keyhole} directory of the package on github.\nYou should copy this directory to a convenient location.\n\nAfter working through these two examples, I recommend that you \ndownload and study the \n\\href{http://www.geuz.org/gmsh/doc/texinfo/gmsh.pdf}{Gmsh manual}.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{First Example}\n\nConsider the keyhole-shaped region~$\\Omega$ shown in \nFigure~\\ref{fig: simple bvp}, with boundary~$\\Gamma=\\partial\\Omega$.  \nWe seek the solution~$u$ of the Poisson problem\n\\begin{equation}\\label{eq:  simple bvp}\n\\begin{aligned}\n-\\nabla^2 u&=4&&\\text{in $\\Omega$,}\\\\\nu&=0&&\\text{on $\\Gamma$,}\n\\end{aligned}\n\\end{equation}\nwhere $\\nabla^2u=\\nabla\\cdot(\\nabla u)=u_{xx}+u_{yy}$ denotes the \nLaplacian of~$u$. Recall that the Sobolev space~$H^1(\\Omega)$ \nconsists of the functions in~$L_2(\\Omega)$ whose first-order, weak \npartial derivatives also belong to~$L_2(\\Omega)$, and that \n\\[\nH^1_0(\\Omega)=\\{\\,v\\in H^1(\\Omega):\\text{$u=0$ on~$\\partial\\Omega$}\n\t\\,\\}.\n\\]\nThe first Green identity asserts that\n\\begin{equation}\\label{eq: first Green}\n\\int_\\Omega\\nabla u\\cdot\\nabla v=\\int_\\Omega(-\\nabla^2 u)v\n\t+\\int_{\\partial\\Omega}\\frac{\\partial u}{\\partial n}\\,v,\n\\end{equation}\nwhere $\\boldsymbol{n}$ denotes the outward unit normal to~$\\Omega$,\nand consequently we say that $u\\in H^1_0(\\Omega)$ is a \\emph{weak \nsolution} of the boundary-value problem~\\eqref{eq:  simple bvp} if\n\\begin{equation}\\label{eq: weak bvp}\n\\int_\\Omega\\nabla u\\cdot\\nabla v=\\int_\\Omega 4v\n\t\\quad\\text{for all $v\\in H^1_0(\\Omega)$.}\n\\end{equation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}\n\\caption{A simple boundary-value problem.}\n\\label{fig: simple bvp}\n\\begin{center}\n\\begin{tikzpicture}[scale=1.5]\n\\draw[blue, thick] (-1,0) -- (-1,-2) -- (1,-2) -- (1,0);\n\\draw[blue, thick] (1,0) arc \n[radius=sqrt(2), start angle=-45, end angle=225];\n\\node at (0,0.5) {$-\\nabla^2u=4$};\n\\node[above,right] at (1,2) {$u=0$};\n\\end{tikzpicture}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}\n\\caption{Reading the geometry description file into Gmsh}\n\\label{fig: open file}\n\\begin{center}\n\\includegraphics[scale=0.3]{images/open_geo_file.png}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{The Gmsh options window.}\n\\label{fig: options}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/options.png}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{A triangulation of $\\Omega$.}\n\\label{fig: triangulation}\n\\begin{center}\n\\includegraphics[scale=0.3]{images/triangulation.png}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\paragraph{Geometry description.}\nTo compute a numerical approximation to this weak solution, we start \nby triangulating $\\Omega$.  Use a text editor to read the \ngeometry description file~\\verb!keyhole.geo! and observe how the \ndomain~$\\Omega$ is defined by first specifying the coordinates of \npoints around its boundary, and then specifying how these points are \nconnected by line segments or circular arcs whose union is~$\\Gamma$.  \nNotice that Gmsh thinks of $\\Omega$ as a surface in 3D (lying in the \nplane~$z=0$).\n\nStart Gmsh and use the \\verb!File! menu to open \n\\verb!keyhole.geo! as shown in Figure~\\ref{fig: open file}.  \nFrom the \\verb!Tools! menu, open the \\verb!Options! window, select \n\\verb!Geometry! in its left pane, and tick the checkbox to display \n\\verb!Point labels!; see Figure~\\ref{fig: options}.  The main Gmsh \nwindow should now display the keyhole domain~$\\Omega$ and show the \nlocations of the points defined in \\verb!keyhole.geo!.\n\n\\paragraph{Mesh generation.}\nTo generate a triangulation, click on the \\verb!+! next to \nthe \\verb!Mesh! label in the left pane of the main Gmsh window and \nthen click on \\verb!2D!.  The result should look something like \nFigure~\\ref{fig: triangulation}.  From the \\verb!File! menu, select \nthe \\verb!Export ...! option to create a text file \n\\verb!keyhole.msh!.  \n\n\\paragraph{Important:} FinElt does not support more recent Gmsh file \nformats, so when the \\verb!MSH Options!  window opens you must select \n\\verb!Version 2 ASCII! from the drop-down menu.\n\n\\paragraph{Finite element solution.}\nLet $\\Omega_h$ denote the triangulated domain, where, in the customary\nway, $h$ is the maximum diameter of the triangles.  Since $\\Omega_h$ \nis a polygon it can only approximate $\\Omega$, whose boundary \n$\\Gamma$ contains circular arcs.  We introduce the finite element \nspace~$\\mathcal{S}_h$ made up of the functions \n$v:\\Omega_h\\to\\mathbb{R}$ that are continuous, piecewise-linear and \nvanish on~$\\partial\\Omega_h$.  The finite element \nsolution~$u_h\\in\\mathcal{S}_h$ is then defined by requiring that\n\\begin{equation}\\label{eq: finite elt problem}\n\\int_{\\Omega_h}\\nabla u_h\\cdot\\nabla v=\\int_{\\Omega_h} 4v\n\t\\quad\\text{for all $v\\in\\mathcal{S}_h$,}\n\\end{equation}\nwhich is a finite-dimensional approximation to the variational \nproblem~\\eqref{eq: weak bvp}.\n\n\\paragraph{Julia script.}\nUse a text editor to read the file \\verb!keyhole.jl!.  This \nJulia script begins by reading the mesh data file \\verb!keyhole.msh! \nand creating a data structure called \\verb!mesh! that stores (amongst \nother things) the coordinates of the vertices of the triangulation as \nwell as the connectivity matrix that specifies which points make up \neach triangle.  Look in the file\n\\verb!src/FinElt/Gmsh.jl! to see how this data structure is defined via \nthe \\verb!Mesh! type.  \n\nThe script then creates a second data structure~\\verb!vp! that \ndescribes the variational problem; look in \\verb!FinElt/FEM.jl!.  We \nspecify that an essential (that is, Dirichlet) boundary condition \napplies over all of~$\\Gamma$.  (Zero boundary values are assumed by \ndefault.)  Next, we specify the bilinear form on the LHS \nof~\\eqref{eq: finite elt problem}, and the linear functional on the \nRHS.\n\nOnce \\verb!vp! is completely specified, the script generates the \n(sparse) linear system for the degrees of freedom, that is, the \nvalues of~$u_h$ at the interior nodes of the triangulation.  This \nlinear system is solved using the \\verb!\\! operator and the full \nnodal vector~\\verb!u! is constructed by including the values at both \nthe free and fixed nodes (the latter being all zeros).  As output, \nthe script writes a postprocessing file \\verb!keyhole.pos!.\n\n\\paragraph{Output and visualization.}\nExecute the script in the usual way:\n\\begin{verbatim}\njulia> include(\"keyhole.jl\")\n\\end{verbatim}\nTo visualize the solution, return to the Gmsh main window.  From \nthe \\verb!File! menu, select \\verb!Open! and choose \n\\verb!keyhole.pos!; the result should look like \nFigure~\\ref{fig: postprocess}.  \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}\n\\caption{View after merging the postprocessing file.}\n\\label{fig: postprocess}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/postprocess.png}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{The Warp plugin.}\n\\label{fig: Warp}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/warp.png}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{View after warping the surface.}\n\\label{fig: warped surface}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/warped_surface.png}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{View after using the mouse to rotate the surface in 3D.}\n\\label{fig: 3D view}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/3Dview.png}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nIn the left pane of the Gmsh window, under \\verb!Post-processing!, \nare two check boxes labelled \\verb!u!~and \\verb!u_warp!.\nUncheck the second of these; the display should now look more \nreasonable.  However, because Gmsh is really a 3D mesh generator, \nwhen solving a 2D problem we have to use something \nof a kludge to obtain a surface plot of the solution.  From the \n\\verb!Tools! menu, open the \\verb!Plugins! window,  \nscroll to the bottom of its left pane and select \\verb!Warp!.  In the \nright pane, change \\verb!View! from \\verb!-1! to \\verb!0!, and change \n\\verb!OtherView! from~\\verb!-1! to~\\verb!1!; see Figure~\\ref{fig: \nWarp}.  After clicking the \\verb!Run! button, you should see something \nlike Figure~\\ref{fig: warped surface}.  By left-clicking and dragging \nthe display, you can rotate the surface to obtain a view like the one \nin Figure~\\ref{fig: 3D view}.\n\n\\paragraph{Exercise.} \nSolve the problem again using a finer mesh.  Hint: select \\verb!Mesh! \nin the left pane of the \\verb!Options! window, choose the \n\\verb!General! tab and adjust the \\verb!Min/Max element size!.  You \nmight also want to go to the \\verb!Visibility! tab and\nuncheck the \\verb!Surface edges! box \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{Second Example}\nSuppose now that $\\Omega$ is the keyhole-shaped region with an \ninterior circular hole shown in Figure~\\ref{fig: complicated bvp}.\nWe want to find $u$ satisfying $-\\nabla\\cdot(a\\nabla u)=f$ \nin~$\\Omega$, where the coefficient $a(x)$ and source term~$f(x)$ are \npiecewise constant: $a=1$~and $f=1$ in the part of~$\\Omega$ that is \nshaded light blue, whereas $a=10$~and $f=4$ in the part shaded \nlight green. In addition, we impose Dirichlet boundary conditions on \nthe parts of~$\\Gamma=\\partial\\Omega$ coloured dark blue or black, and \nNeumann conditions on the part coloured violet or red.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}\n\\caption{A more complicated boundary-value problem.}\n\\label{fig: complicated bvp}\n\\begin{center}\n\\begin{tikzpicture}[scale=1.5]\n\\path[fill=blue!10] (-1,0) -- (-1,-2) -- (1,-2) -- (1,0)\narc [radius=sqrt(2), start angle=-45, end angle=225];\n\\draw[blue,thick] (1,0)  \narc [radius=sqrt(2), start angle=-45, end angle=225];\n\\draw[red,thick,fill=white] (0,1) circle [radius=sqrt(2)/2];\n\\draw[green!40,fill=green!40] (-0.5,-0.5) -- (-0.5,-1.5) -- \n(0.5,-1.25) -- (0.5, -0.75) -- (-0.5,-0.5);\n\\draw[black,thick] (-1,-2) -- (1,-2);\n\\node[above,blue] at (0,2.4142) {$u=-|\\boldsymbol{x}|/2$};\n\\node[below] at (0,-2) {$u=0$};\n\\draw[violet,ultra thick] (-1,0) -- (-1,-2);\n\\node[left,violet] at (-1.0,-1.0) \n{$\\dfrac{\\partial u}{\\partial n}=-1$};\n\\draw[violet,ultra thick] (1,0) -- (1,-2);\n\\node[right,violet] at (1.0,-1.0) \n{$\\dfrac{\\partial u}{\\partial n}=-1$};\n\\node[red] at (0,1) {$\\dfrac{\\partial u}{\\partial n}=0$};\n\\node at (-4,2) {$-\\nabla\\cdot(a\\nabla u)=f$};\n\\draw[blue!10,fill=blue!10] (-4.5,1) -- (-3.5,1) -- (-3.5,0) \n-- (-4.5,0) -- (-4.5,1);\n\\node at (-4,0.75) {$a=1$};\n\\node at (-4,0.25) {$f=1$};\n\\draw[green!40,fill=green!40] (-4.5,-1) -- (-3.5,-1) -- (-3.5,-2) \n-- (-4.5,-2) -- (-4.5,-1);\n\\node at (-4,-1.25) {$a=10$};\n\\node at (-4,-1.75) {$f=4$};\n\\end{tikzpicture}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}\n\\caption{The computed solution for the second example.}\n\\label{fig: second soln}\n\\begin{center}\n\\includegraphics[scale=0.4]{images/complic_keyhole.png}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\paragraph{Weak formulation.}\nDefine the trial set~$\\mathcal{S}$ and test space~$\\mathcal{T}$ by\n\\begin{align*}\n\\mathcal{S}&=\\{\\,v\\in H^1(\\Omega):\n\\text{$v=-|x|/2$ for $x\\in\\text{DarkBlue}$, $v=0$ for \n$x\\in\\text{Black}$}\\,\\},\\\\\n\\mathcal{T}&=\\{\\,u\\in H^1(\\Omega):\n\\text{$v=0$ for $x\\in\\text{DarkBlue}\\cup\\text{Black}$}\\,\\}.\n\\end{align*}\nBased on the first Green identity~\\eqref{eq: first Green}, the weak \nsolution~$u\\in\\mathcal{S}$ satisfies\n\\begin{multline*}\n\\int_{\\text{LightBlue}}\\nabla u\\cdot\\nabla v\n\t+10\\int_{\\text{LightGreen}}\\nabla u\\cdot\\nabla v\\\\\n\t=\\int_{\\text{LightBlue}}v+\\int_{\\text{LightGreen}}4v\n\t-\\int_{\\text{Violet}}v\n\\quad\\text{for all $v\\in\\mathcal{T}$.}\n\\end{multline*}\n\n\\paragraph{Finite element approximation.} \nWe approximate $\\Omega$ by a triangulated polygon~$\\Omega_h$ and \ndefine a finite dimensional trial set~$\\mathcal{S}_h$ that consists \nof all continuous, piecewise-linear functions~$v$ such that \n\\[\nv(\\boldsymbol{x})=\\begin{cases}\n-|\\boldsymbol{x}|/2,&\n\\text{$\\boldsymbol{x}$ is a node in~$\\text{DarkBlue}_h$,}\\\\\n0,&\\text{$\\boldsymbol{x}$ is a node in~$\\text{Black}_h$,}\\\\\n\\end{cases}\n\\]\nwhere $\\text{DarkBlue}_h$~and $\\text{Black}_h$ are the parts\nof the boundary of~$\\Omega_h$ corresponding to $\\text{DarkBlue}$~and \n$\\text{Black}$.  The finite dimensional test \nspace~$\\mathcal{T}_h$ is the set of~$\\mathcal{S}_h$ consisting of \nthose~$v$ that vanish on~$\\text{DarkBlue}_h$ and\non~$\\text{Black}_h$.  The finite element \nsolution~$u_h\\in\\mathcal{S}_h$ is then defined by\n\\begin{multline*}\n\\int_{\\text{LightBlue}_h}\\nabla u_h\\cdot\\nabla v\n\t+10\\int_{\\text{LightGreen}_h}\\nabla u_h\\cdot\\nabla v\\\\\n\t=\\int_{\\text{LightBlue}_h}v+\\int_{\\text{LightGreen}_h}4v\n\t-\\int_{\\text{Violet}_h}v\n\\quad\\text{for all $v\\in\\mathcal{T}_h$.}\n\\end{multline*}\n\n\\paragraph{Computing and visualizing the solution.}  \nUse a text editor to look at the geometry description \nin \\verb!complic_keyhole.geo!, and then look at the source code in\n\\verb!complic_keyhole.jl!.  Notice that the Julia script runs Gmsh \ntwice, using the latter's command-line interface.  (The \n\\verb!-format msh22! option is needed to generate the older file format.)\nThe first call performs the mesh generation, creating the file \n\\verb!complic_keyhole.msh!, and the second runs the Gmsh \nscript \\verb!complic_keyhole.script! to display a surface plot of the \nsolution.  Thus, the whole process requires only the single command\n\\begin{verbatim}\njulia> include(\"complic_keyhole.jl\")\n\\end{verbatim}\nto produce the output shown in Figure~\\ref{fig: second soln}.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{thebibliography}{0}\n\\bibitem{Gmsh}\nC.~Geuzaine and J.-F.~Remacle. Gmsh: a three-dimensional finite \nelement mesh generator with built-in pre- and post-processing \nfacilities. \\emph{International Journal for Numerical Methods in \nEngineering} 79(11), pp.~1309--1331, 2009.\n\\end{thebibliography}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{document}\n", "meta": {"hexsha": "3543f333ccfb805563be5495618cb6c8f2cd66c0", "size": 15412, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/quickstartguide.tex", "max_stars_repo_name": "billmclean/FinElt.jl", "max_stars_repo_head_hexsha": "5153f1624fe1c7dcadd646d60c716e6153fedb2a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-07-18T20:04:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-30T21:29:09.000Z", "max_issues_repo_path": "doc/quickstartguide.tex", "max_issues_repo_name": "billmclean/FinElt.jl", "max_issues_repo_head_hexsha": "5153f1624fe1c7dcadd646d60c716e6153fedb2a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/quickstartguide.tex", "max_forks_repo_name": "billmclean/FinElt.jl", "max_forks_repo_head_hexsha": "5153f1624fe1c7dcadd646d60c716e6153fedb2a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-06-29T15:15:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T18:01:08.000Z", "avg_line_length": 40.9893617021, "max_line_length": 76, "alphanum_fraction": 0.6826498832, "num_tokens": 4796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160664, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4156545992744762}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% =================================================================================================\n% create checkpoint file\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   import cdblib\n   checkpoint_file = 'tests/semantic/output/geodesic-lsq-midpt.json'\n   cdblib.create (checkpoint_file)\n   checkpoint = []\n\\end{cadabra}\n\\egroup\n\n% =================================================================================================\n\\section*{Geodesic mid-point for arc-length}\n\n\\input{metric.cdbtex}\n\\input{geodesic-lsq.cdbtex}\n\nThis code uses the results of {\\tts geodesic-lsq} and {\\tts metric} to show that the 2nd and 3rd\norder estimates for $L^2_{PQ}$ can be recovered using a mid-point estimate. For the 3rd order estimate\nwe have\n\\begin{align*}\n   g_{ab}(x) &= \\cdb{gab4.601} + \\BigO{\\eps^4}\\\\\n   L^2_{PQ}  &= \\cdb{lsq4.301} + \\BigO{\\eps^4}\n\\end{align*}\nThe code below verifies that\n\\begin{equation*}\n   L^2_{PQ} = g_{ab}(\\bar x) Dx^{a} Dx^{b} + \\BigO{\\eps^4}\n\\end{equation*}\nwhere $\\bar x$ is the \\emph{coordinate} midpoint of the geodesic\n\\begin{equation*}\n   {\\bar x^a} = \\frac{1}{2}\\left(x^{a}_{P} + x^{a}_{Q}\\right)\n\\end{equation*}\nThis result holds true only for the 2nd and 3rd order estimates. Note that the \\emph{coordinate} midpoint\nis not the \\emph{geometric} midpoint of the geodesic.\n\nIt might be interesting to see if the higher order estimates could\nbe recovered by sampling the metric at points other than the mid point.\n\n\\clearpage\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).\n\n   \\nabla{#}::Derivative.\n\n   g_{a b}::Metric.\n   g^{a b}::InverseMetric.\n\n   R_{a b c d}::RiemannTensor.\n\n   import cdblib\n\n   gab = cdblib.get('g_ab','metric.json')\n\n   lsq2 = cdblib.get('lsq2','geodesic-lsq.json')\n   lsq3 = cdblib.get('lsq3','geodesic-lsq.json')\n   lsq4 = cdblib.get('lsq4','geodesic-lsq.json')\n   lsq5 = cdblib.get('lsq5','geodesic-lsq.json')\n\n   substitute (gab,$x^{a}->(p^{a}+q^{a})/2$)   # evaluate rnc gab at mid-point\n   distribute (gab)\n\n   defgab := g_{a b} -> @(gab).\n\n   mid := g_{a b} (q^{a}-p^{a}) (q^{b}-p^{b}).\n\n   substitute     (mid,defgab)\n   distribute     (mid)\n   sort_product   (mid)\n   rename_dummies (mid)\n   canonicalise   (mid)\n\n   tst2 := @(lsq2) - @(mid).                             # cdb (tst2.201,tst2)\n   tst3 := @(lsq3) - @(mid).                             # cdb (tst3.201,tst3)\n   tst4 := @(lsq4) - @(mid).                             # cdb (tst4.201,tst4)\n   tst5 := @(lsq5) - @(mid).                             # cdb (tst5.201,tst5)\n\n   substitute     (tst2,$Dx^{a} -> q^{a}-p^{a}$)\n   substitute     (tst2,$x^{a} -> p^{a}$)\n   distribute     (tst2)\n   sort_product   (tst2)\n   rename_dummies (tst2)\n   canonicalise   (tst2)                                 # cdb (tst2.202,tst2)\n\n   substitute     (tst3,$Dx^{a} -> q^{a}-p^{a}$)\n   substitute     (tst3,$x^{a} -> p^{a}$)\n   distribute     (tst3)\n   sort_product   (tst3)\n   rename_dummies (tst3)\n   canonicalise   (tst3)                                 # cdb (tst3.202,tst3)\n\n   substitute     (tst4,$Dx^{a} -> q^{a}-p^{a}$)\n   substitute     (tst4,$x^{a} -> p^{a}$)\n   distribute     (tst4)\n   sort_product   (tst4)\n   rename_dummies (tst4)\n   canonicalise   (tst4)                                 # cdb (tst4.202,tst4)\n\n   substitute     (tst5,$Dx^{a} -> q^{a}-p^{a}$)\n   substitute     (tst5,$x^{a} -> p^{a}$)\n   distribute     (tst5)\n   sort_product   (tst5)\n   rename_dummies (tst5)\n   canonicalise   (tst5)                                 # cdb (tst5.202,tst5)\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Reformatting}\n\n\\begin{cadabra}\n   def truncateR (obj,n):\n\n   # I would like to assign different weights to \\nabla_{a}, \\nabla_{a b}, \\nabla_{a b c} etc. but no matter\n   # what I do it appears that Cadabra assigns the same weight to all of these regardless of the number of subscripts.\n   # It seems that the weight is assigned to the symbol \\nabla alone. So I'm forced to use the following substitution trick.\n\n       Q_{a b c d}::Weight(label=numR,value=2).\n       Q_{a b c d e}::Weight(label=numR,value=3).\n       Q_{a b c d e f}::Weight(label=numR,value=4).\n       Q_{a b c d e f g}::Weight(label=numR,value=5).\n\n       tmp := @(obj).\n\n       substitute (tmp, $\\nabla_{e f g}{R_{a b c d}} -> Q_{a b c d e f g}$)\n       substitute (tmp, $\\nabla_{e f}{R_{a b c d}} -> Q_{a b c d e f}$)\n       substitute (tmp, $\\nabla_{e}{R_{a b c d}} -> Q_{a b c d e}$)\n       substitute (tmp, $R_{a b c d} -> Q_{a b c d}$)\n\n       ans = Ex(0)\n\n       for i in range (0,n+1):\n          foo := @(tmp).\n          bah = Ex(\"numR = \" + str(i))\n          keep_weight (foo, bah)\n          ans = ans + foo\n\n       substitute (ans, $Q_{a b c d e f g} -> \\nabla_{e f g}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d e f} -> \\nabla_{e f}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d e} -> \\nabla_{e}{R_{a b c d}}$)\n       substitute (ans, $Q_{a b c d} -> R_{a b c d}$)\n\n       return ans\n\n   tst2 = truncateR (tst2,2)  # cdb (tst2.301,tst2)\n   tst3 = truncateR (tst3,3)  # cdb (tst3.301,tst3)\n   tst4 = truncateR (tst4,4)  # cdb (tst4.301,tst4)\n   tst5 = truncateR (tst5,5)  # cdb (tst5.301,tst5)\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{Errors is mid-point estimates for $L^2_{PQ}$}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\left(L^2_{PQ} - g_{ab}(\\bar x) Dx^a Dx^b\\right)_2 = \\cdb{tst2.301} \\end{dmath*}\n   \\begin{dmath*} \\left(L^2_{PQ} - g_{ab}(\\bar x) Dx^a Dx^b\\right)_3 = \\cdb{tst3.301} \\end{dmath*}\n   \\begin{dmath*} \\left(L^2_{PQ} - g_{ab}(\\bar x) Dx^a Dx^b\\right)_4 = \\cdb{tst4.301} \\end{dmath*}\n   \\begin{dmath*} \\left(L^2_{PQ} - g_{ab}(\\bar x) Dx^a Dx^b\\right)_5 = \\cdb{tst5.301} \\end{dmath*}\n\\end{dgroup*}\n\n% =================================================================================================\n% export checkpoints in json format\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   for i in range( len(checkpoint) ):\n      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)\n\\end{cadabra}\n\\egroup\n\n\\end{document}\n\n", "meta": {"hexsha": "e14b88ac8be1afc9399a15291e7d903c7ae235b8", "size": 6295, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/geodesic-lsq-midpt.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/geodesic-lsq-midpt.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/geodesic-lsq-midpt.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8440860215, "max_line_length": 124, "alphanum_fraction": 0.535822081, "num_tokens": 2185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4156291453808692}}
{"text": "%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.\r\n%% Do not edit unless you really know what you are doing.\r\n\\documentclass[twoside,english]{paper}\r\n\\usepackage{lmodern}\r\n\\renewcommand{\\ttdefault}{lmodern}\r\n\\usepackage[T1]{fontenc}\r\n\\usepackage[latin9]{inputenc}\r\n\\usepackage[a4paper]{geometry}\r\n\\geometry{verbose,tmargin=3cm,bmargin=2.5cm,lmargin=2cm,rmargin=2cm}\r\n\\usepackage{color}\r\n\\usepackage{babel}\r\n\\usepackage{float}\r\n\\usepackage{bm}\r\n\\usepackage{amsthm}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{graphicx}\r\n\\usepackage{esint}\r\n\\usepackage[unicode=true,pdfusetitle,\r\n bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,\r\n breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]\r\n {hyperref}\r\n\\usepackage{breakurl}\r\n\r\n\\makeatletter\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\r\n%% Because html converters don't know tabularnewline\r\n\\providecommand{\\tabularnewline}{\\\\}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\r\n\\numberwithin{equation}{section}\r\n\\numberwithin{figure}{section}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\r\n\\usepackage{babel}\r\n\r\n\\@ifundefined{showcaptionsetup}{}{%\r\n \\PassOptionsToPackage{caption=false}{subfig}}\r\n\\usepackage{subfig}\r\n\\makeatother\r\n\r\n\r\n\\usepackage{listings}\r\n\r\n\\begin{document}\r\n\r\n\\title{The APFEL DIS Module}\r\n\r\n\\author{Valerio Bertone$^{a,b}$}\r\n\r\n\\institution{$^{a}$PH Department, TH Unit, CERN, CH-1211 Geneva 23, Switzerland\\\\$^{b}$Rudolf Peierls Centre for Theoretical Physics, 1 Keble Road, University of Oxford,\r\nOX1 3NP Oxford, UK}\r\n\\maketitle\r\n\r\n\\begin{abstract} In this document I will descrive the old and the new\r\nDIS module embedded in APFEL.\r\n\\end{abstract}\r\n\\tableofcontents{}\r\n\r\n\\newpage{}\r\n\r\n\\section{Computing DIS Structure Functions on a Grid: the New DIS Module}\r\n\r\nIn order to speed up and optimize the compution of the DIS structure\r\nfunctions in {\\tt APFEL} we decided to use the same technology used\r\nfor the PDF evolution. In fact, up to version 2.0.0, the computation\r\nof such observables in {\\tt APFEL} was perfomed by directly\r\nconvoluting PDFs with the coefficient functions by mean of a numerical\r\nintegration.\r\n\r\nNow the aim is that of precomputing on a grid the convolution of the\r\ncoefficient functions with a set of interpolating polynomials. This\r\nway, the time consuming task of precomputing the coefficient functions\r\nof the grid needs to be done only once and the numerical convolution\r\nwith any PDF set is instead very fast. In addition, as we will see\r\nbelow, this approach provides a very natural framework to combine\r\nprecomputed coefficient functions and evolution operators, so that any\r\nprediction of structure functions at any scale $Q$ can be obtained\r\nvery quickly by convolution with PDFs at some initial scale $Q_0$.\r\nUltimately, this is particularly suitable for PDF fits.\r\n\r\n\\subsection{Zero Mass Structure Functions}\r\n\r\nA structure function in the Zero-Mass (ZM) scheme is given by the\r\nfollowing convolution:\r\n\\begin{equation}\r\n  F(x,Q) = \\sum_{i=g,q}x\\int_x^1\\frac{dy}y\r\n  C_i\\left(\\frac{x}{y},\\alpha_s(Q)\\right)q_i(y,Q)\\,,\r\n\\end{equation}\r\nNow, defining $t = \\ln (Q^2)$,\r\n$\\widetilde{C}_i^{(n)}(y,t) = yC_i^{(n)}(y,\\alpha_s(Q))$ and\r\n$\\widetilde{q}_i(y,t) = y q_i(y,Q)$, the integral above can be written\r\nas:\r\n\\begin{equation}\\label{exact}\r\n  F(x,t) = \\sum_{i=g,q}\\int_x^1\\frac{dy}y\r\n  \\widetilde{C}_i\\left(\\frac{x}{y},t\\right)\\widetilde{q}_i(y,t)\\,.\r\n\\end{equation}\r\nBut, using a suitable interpolation basis, we can write:\r\n\\begin{equation}\r\n  \\tilde{q}_i(y,t)=\\sum^{N_{x}}_{\\alpha=0}w_{\\alpha}^{(k)}(y)\\tilde{q}_i(x_{\\alpha},t)\\,,\r\n\\end{equation}\r\nso that eq. (\\ref{exact}) becomes:\r\n\\begin{equation}\r\n  F(x,t) =\r\n  \\sum_{i=g,q}\\sum^{N_{x}}_{\\alpha=0}\\left[\\int_x^1\\frac{dy}y\r\n    \\widetilde{C}_i\\left(\\frac{x}{y},t\\right)\r\n    w_{\\alpha}^{(k)}(y)\\right]\\tilde{q}_i(x_{\\alpha},t)\\,.\r\n\\end{equation}\r\nNow let's assume that $x$ is on the grid, so that $x = x_\\beta$. This\r\nway we have:\r\n\\begin{equation}\r\n  F(x_\\beta,t) =\r\n  \\sum_{i=g,q}\\sum^{N_{x}}_{\\alpha=0}\\underbrace{\\left[\\int_{x_\\beta}^1\\frac{dy}y\r\n      \\widetilde{C}_i\\left(\\frac{x_\\beta}{y},t\\right)\r\n      w_{\\alpha}^{(k)}(y)\\right]}_{\\Gamma_{i,\\beta\\alpha}(t)}\\tilde{q}(x_{\\alpha},t)\\,.\r\n\\end{equation}\r\n\r\nUsing the same arguments presented in the evolution code notes, we\r\nhave that:\r\n\\begin{equation} \r\n  \\Gamma_{i,\\beta\\alpha}(t) \\neq 0\r\n  \\quad\\mbox{for}\\quad\\beta\\leq\\alpha\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\r\n  \\Gamma_{i,\\beta\\alpha}(t) = \\int_{c}^d\\frac{dy}y\r\n  \\widetilde{C}_i\\left(y,t\\right)\r\n  w_{\\alpha}^{(k)}\\left(\\frac{x_\\beta}{y}\\right)\r\n\\end{equation}\r\nwith:\r\n\\begin{equation}\\label{bounds2}\r\n  c =\r\n  \\mbox{max}(x_\\beta,x_\\beta/x_{\\alpha+1}) \\quad\\mbox{and}\\quad d =\r\n  \\mbox{min}(1,x_\\beta/x_{\\alpha-k}) \\,.\r\n\\end{equation}\r\nThe same symmetries holding for the splitting function case hold also\r\nhere.\r\n\r\n\\subsubsection{Coefficient Functions Treatment}\r\n\r\nThe structure of the DIS coefficient functions is very similar to\r\nthat of splitting functions with only one small complication, that is\r\nthe presence of a more divergent singular term. In practice the\r\nstructure of the DIS coefficient functions is the following:\r\n\\begin{equation}\\label{CFstructure}\r\n  \\widetilde{C}_{i}(x,t) =\r\n  xC_{i}^{R}(x,t) + xC_{i}^{S1}(t)\\left[\\frac{1}{1-x}\\right]_+ +\r\n  xC_{i}^{S2}(t)\\left[\\frac{\\ln(1-x)}{1-x}\\right]_+ +\r\n  xC_{i}^{L}(t)\\delta(1-x)\\,.\r\n\\end{equation} \r\nThe term proportional to $C_{i}^{S2}$ can be treated, considering\r\nthat:\r\n\\begin{equation}\r\n  \\begin{array}{rcl} \\displaystyle\r\n    \\int_c^ddy\\left[\\frac{\\ln(1-y)}{1-y}\\right]_+f(y) &=&\\displaystyle\r\n                                                          \\int_c^ddy\\frac{\\ln(1-y)}{1-y}\\left[f(y)-f(1)\\theta(d-1)\\right]\\\\ \\\\\r\n                                                      &+&\\displaystyle \\frac12 f(1) \\ln^2(1-c)\\theta(d-1)\r\n\\end{array}\r\n\\end{equation}\r\nOn the same line of splitting functions, we know that the coefficient\r\nfunctions ha the following perturbative expansion:\r\n\\begin{equation}\r\n  C_{i}^{J}(x,t) =\r\n  \\sum_{n=0}^{N}a_s^{n}(t)C_{i}^{J,(n)}(x)\\qquad\\mbox{with}\\qquad\r\n  J=R,S1,S2,L\r\n\\end{equation}\r\n\r\nTherefore one has that:\r\n\\begin{equation}\\label{Kernels}\r\n\\begin{array}{c}\r\n  \\displaystyle \\Gamma_{j,\\beta\\alpha}(t) = \\\\ \\\\\r\n  \\displaystyle \\sum_{n=0}^{N} a_s^{n}(t)\r\n  \\bigg\\{\\int^{d}_{c}dy\\left[{C}_{i}^{R,(n)}(y)w_{\\alpha}\\left(\\frac{x_\\beta}{y}\\right)+\\frac{{C}_{i}^{S1,(n)}+{C}_{i}^{S2,(n)}\\ln(1-y)}{1-y}\\left(w_{\\alpha}\\left(\\frac{x_\\beta}{y}\\right)-\\delta_{\\beta\\alpha}\\theta(d-1)\\right)\\right]\\\\\r\n  \\\\ \\displaystyle\r\n  +\\left[{C}_{i}^{S1,(n)}\\ln(1-c)\\theta(d-1)+\\frac12{C}_{i}^{S2,(n)}\\ln^2(1-c)\\theta(d-1)+{C}_{i}^{L,(n)}\\right]\\delta_{\\beta\\alpha}\\bigg\\}\\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nCalling:\r\n\\begin{equation}\r\n\\begin{array}{c} \r\n  \\displaystyle \\Gamma_{i,\\beta\\alpha}^{(n)}(t) = \\\\ \\\\\r\n  \\displaystyle\r\n  \\int^{d}_{c}dy\\left[{C}_{i}^{R,(n)}(y)w_{\\alpha}\\left(\\frac{x_\\beta}{y}\\right)+\\frac{{C}_{i}^{S1,(n)}+{C}_{i}^{S2,(n)}\\ln(1-y)}{1-y}\\left(w_{\\alpha}\\left(\\frac{x_\\beta}{y}\\right)-\\delta_{\\beta\\alpha}\\theta(d-1)\\right)\\right]\\\\\r\n  \\\\ \\displaystyle\r\n  +\\left[{C}_{i}^{S1,(n)}\\ln(1-c)\\theta(d-1)+\\frac12{C}_{i}^{S2,(n)}\\ln^2(1-c)\\theta(d-1)+{C}_{i}^{L,(n)}\\right]\\delta_{\\beta\\alpha}\\,,\r\n\\end{array}\r\n\\end{equation}\r\n we have that:\r\n\\begin{equation}\\label{splittingexp} \r\n  \\Gamma_{i,\\beta\\alpha}(t) =\r\n  \\sum_{n=0}^{N} a_s^{n}(t) \\Gamma_{i,\\beta\\alpha}^{(n)}\\,,\r\n\\end{equation} \r\nand the integrals $\\Gamma_{i,\\beta\\alpha}^{(n)}$ do not depend on the\r\nenergy therefore, once the grid (and the number of active flavours)\r\nhas been fixed, they can be evaluate once and for all at the beginning\r\nand used for the convolution at any scale.\r\n\r\nNow, assuming to have computed the evolution operator\r\n$M_{ij,\\alpha\\beta}(t,t_0)$ between the scales $t=\\ln(Q^2)$ and\r\n$t_0=\\ln(Q_0^2)$ on the same grid where we have computed the operator\r\n$\\Gamma_{i,\\beta\\alpha}(t)$, one can esily combine the two obtaining\r\nthe prediction for the structure function $F$ on the grid in terms of\r\nPDFs at the initial scale $Q_0$ just by performing the following\r\nconvolution:\r\n\\begin{equation}\\label{CFtimesEvolution}\r\n  F(x_\\alpha,t) =\r\n  \\Gamma_{i,\\alpha\\beta}(t) M_{ij,\\beta\\gamma}(t,t_0)\r\n  \\tilde{q}_j(x_{\\gamma},t_0)\r\n\\end{equation} \r\nwhere a sum of the repeated indeces is understood.\r\n\r\nBefore proceeding to treatment of the massive coefficient functions,\r\nwe stress that in the massless scheme, for obviuos kinematical\r\nreasons, there is no need to distinguish between charged- and\r\nneutral-current coefficient functions. The difference between the two\r\ncases appears only at the level of structure functions where the\r\ncoefficient functions are comvoluted with different combinations of\r\nPDFs and combined according to the structure of the couplings to\r\nquarks of the $Z/\\gamma^*$ vector bosons in the neutral-current case\r\nand the $W^\\pm$ in the charged-current case.\r\n\r\nIt is opportune at this point to mention that, when considering\r\ncharged-current observables at NLO in the massive scheme, there is a\r\nfurther contribution to be added to eq.~(\\ref{CFstructure}) that has\r\nthe form:\r\n\\begin{equation} C_{i}^{SL}(t)\\frac{d}{dx}\\delta(1-x)\\,.\r\n\\end{equation} Starting from the relation:\r\n\\begin{equation} x\\frac{d}{dx}\\delta(x) = -\\delta(x)\\,,\r\n\\end{equation} one can easily show that:\r\n\\begin{equation}\\label{KeyIdentity} \\frac{d}{dx}\\delta(1-x) =\r\n\\left[\\frac{\\delta(1-x)}{1-x}\\right]_+\\,.\r\n\\end{equation} To make sure that this identity is correct, we try to\r\nconvolute both the r.h.s. and the l.h.s. of eq.~(\\ref{KeyIdentity})\r\nwith the test function $f(x)$, such that $f(1) = 0$, to see what is\r\nthe result and whether the results are equal. Using the l.h.s. we\r\nhave:\r\n\\begin{equation} \\int_x^1dy\\,f(y)\\,\\frac{d}{dx}\\delta(1-y) =\r\n\\underbrace{f(y)\\delta(1-y)\\Big{|}_{x}^1}_{=0} -\r\n\\int_x^1dy\\frac{df(y)}{dy}\\delta(1-y) =\r\n-\\frac{df(y)}{dy}\\bigg{|}_{y=1}\\,,\r\n\\end{equation} while using the r.h.s.(\\footnote{Since the delta\r\nfunction selects the point $y=1$ in the following integral, the\r\n``incomplete'' integral of plus-prescripted function does not give\r\nrise to any residual logarithm of the form $\\ln(1-x)$.}):\r\n\\begin{equation}\r\n\\begin{array}{c}\r\n  \\displaystyle\r\n  \\int_x^1dy\\,f(y)\\,\\left[\\frac{\\delta(1-y)}{1-y}\\right]_+ =\r\n  \\int_x^1dy\\frac{f(y)-f(1)}{1-y}\\delta(1-y) = \\lim_{\\epsilon\\rightarrow\r\n  0^+} \\int_x^1dy\\frac{f(y)-f(1)}{1-y}\\delta(1-\\epsilon-y) =\\\\ \\\\\r\n  \\displaystyle - \\lim_{\\epsilon\\rightarrow 0^+}\r\n  \\frac{f(1)-f(1-\\epsilon)}{\\epsilon} =\r\n  -\\frac{df(y)}{dy}\\bigg{|}_{y=1}\\,.\r\n\\end{array}\r\n\\end{equation} \r\nSo the results are equal and the distributions in\r\neq.~(\\ref{KeyIdentity}) when convoluted with a test function extract\r\nits derivative in $y=1$, up to a minus sign.\r\n\r\nAt the end of the day one has to include inside the curly brackets of\r\neq.~(\\ref{Kernels}) the term:\r\n\\begin{equation}\r\n  - C_{i}^{SL,(n)}\\frac{dw_\\alpha^{(k)}(x_\\beta)}{dx}\r\n\\end{equation}\r\n\r\nIn addition, when using a Lagrange interpolation, one can show that\r\nthe first derivative of the Lagrange polynomials have the form:\r\n\\begin{equation}\\label{LagrangFirstDerivative}\r\n  \\frac{d\r\n    w_\\alpha^{(k)}(x_\\rho)}{dx} = \\left\\{\r\n    \\begin{array}{ll} \\displaystyle \\sum_{\\sigma=0\\atop\r\n      \\sigma\\neq\\alpha}^k\\frac{1}{x_\\alpha-x_\\sigma} & \\quad \\rho = \\alpha\r\n      \\\\ \\\\ \\displaystyle \\frac{1}{x_\\alpha-x_\\rho}\r\n      \\prod_{\\sigma=0\\atop\\sigma\\neq\\alpha,\\rho}^k\\frac{x_\\rho -\r\n      x_\\sigma}{x_\\alpha-x_\\sigma} & \\quad \\rho \\neq \\alpha\r\n    \\end{array} \\right.\r\n\\end{equation}\r\nThe relation in eq.~(\\ref{LagrangFirstDerivative}) is proved in the\r\n``Lagrange\\_derivative.pdf'' notes.\r\n\r\n\\subsection{Massive Structure Functions}\r\n\r\nNow we can proceed considering the massive structure functions. When\r\ncomputing structure functions in the massive scheme, there is a\r\nfurther complication that complicates a fast precomputation of the\r\ncefficient functions on the $x$-space grid and it is the fact that the\r\ncoefficients of the perturbative expansion of the massive coefficient\r\nfunctions carry an intrinsic dependence on the scale of the process.\r\nThis prevents a scale independent pre-tabulation of the coefficient\r\nfunctions on on $x$-space grid.\r\n\r\nOne possible way out is to pre-tabulate the coefficient functions, not\r\nonly on an $x$-space grid, but also on a $Q$-space grid, where $Q$ is\r\nthe scale at which the structure functions are evaluated. Actually the\r\nmost efficient way of precomputing the massive coefficient functions\r\nis on $\\xi$-space grid, where $\\xi$ is defined as:\r\n\\begin{equation}\r\n  \\xi = \\frac{Q^2}{m_H^2}\\,.\r\n\\end{equation}\r\nwhere $m_H$ is the mass of the heavy quark under consideration.  In\r\nfact, for dimentional reasons, massive coefficient functions depend on\r\nthe scale $Q$ through $\\xi$. Neglecting for the moment the dependence\r\non the renormalization and on the factorization scales, the massive\r\ncoefficient functions allow for the following expansion:\r\n\\begin{equation}\r\n  C_i(x,Q,m_H) = \\sum_n a_s^n(t)C_i^{(n)}(x,\\xi)\\,.\r\n\\end{equation}\r\nGiven this relation, the massive analogous of the\r\neq.~(\\ref{splittingexp}) is:\r\n\\begin{equation}\\label{splittingexp}\r\n  \\Gamma_{i,\\beta\\alpha}(Q,m_H) =\r\n  \\sum_n a_s^{n}(t) \\Gamma_{i,\\beta\\alpha}^{(n)}(\\xi)\\,.\r\n\\end{equation}\r\nIn order not to recompute the operator\r\n$\\Gamma_{i,\\beta\\alpha}^{(n)}(\\xi)$ any time that $\\xi$ changes, we\r\ncan tabulate the on a grid in $\\xi$,\r\n$\\{\\xi_1,\\dots,\\xi_\\tau,\\dots,\\xi_{N_\\xi}\\}$, defining:\r\n\\begin{equation}\r\n  \\Gamma_{i,\\beta\\alpha,\\tau}^{(n)} =\r\n  \\Gamma_{i,\\beta\\alpha}^{(n)}(\\xi_\\tau),.\r\n\\end{equation}\r\nand then interpolate to obtain the operator for a generic value of\r\n$\\xi$. We have chosen to use a linear interpolation so that:\r\n\\begin{equation}\r\n  \\Gamma_{i,\\beta\\alpha}^{(n)}(\\xi) =\r\n  c^{(0)}(\\xi)\\Gamma_{i,\\beta\\alpha,\\tau}^{(n)} +\r\n  c^{(1)}(\\xi)\\Gamma_{i,\\beta\\alpha,\\tau+1}^{(n)}\\,,\r\n\\end{equation}\r\nwith:\r\n\\begin{equation}\r\n  c^{(0)}(\\xi) = \\frac{\\ln\\xi_{\\tau+1} -\r\n    \\ln\\xi}{\\ln\\xi_{\\tau+1} - \\ln\\xi_\\tau}\\quad\\mbox{and}\\quad\r\n  c^{(1)}(\\xi) = \\frac{\\ln\\xi - \\ln\\xi_\\tau}{\\ln\\xi_{\\tau+1} -\r\n    \\ln\\xi_\\tau} \\,,\r\n\\end{equation}\r\nprovided that $\\xi_\\tau \\leq \\xi < \\xi_{\\tau+1}$.\r\n\r\nTo conclude, once the operators $\\Gamma_{i,\\beta\\alpha,\\tau}^{(n)}$\r\nhave been precomputed, the operator for a generic value of $\\xi$ can\r\nbe quickly computed by interpolation.\r\n\r\n\\subsubsection{Neutral Current Coefficient Functions}\r\n\r\nAs far as the neutral current coefficient functions are concerned,\r\nbeyond LO(\\footnote{We remind that, in the neutral current case, the\r\nLO is order $\\alpha_s$.}), a close analytical form is not available\r\nand only a semi-analitical form~\\cite{Laenen:1992xs} which is not\r\nsuitable for a fast numerical implementation. The authors of\r\nRef.~\\cite{Alekhin:2003ev} have used a simple parametrization to fit\r\nthe exact coefficient functions. Such parametrization is actually\r\nmeant to be used in Mellin space, however it can equally be used in\r\n$x$ space providing a fast and accurate enough alternative to the\r\noriginal implemetation. The parametrization of\r\nRef.~\\cite{Alekhin:2003ev} has the form:\r\n\\begin{equation}\r\n  C(x,\\xi) =\r\n  \\theta(\\rho-x)(\\rho-x)^{-\\kappa}\\sum_{k=0}^K\r\n  a_k(\\rho)x^k\\quad\\mbox{with}\\quad\\rho = \\frac{\\xi}{\\xi+4}\\,,\r\n\\end{equation}\r\nand the authors provide the numerical values of $\\kappa$, $K$ and\r\n$a_k(\\rho)$ for all the relevant coefficient functions at LO\r\n($\\mathcal{O}(\\alpha_s)$) and NLO ($\\mathcal{O}(\\alpha_s^2)$)\r\ntabulated on a $\\xi$-space grid for large enough range in $\\xi$.  Note\r\nthe presence of the $\\theta$-function that has the scope of reducing\r\nthe phase scace available for the process due the production of two\r\nheavy quarks in the final state.\r\n\r\nIn {\\tt APFEL} we make use of the parametrization above only for the\r\nNLO coefficient functions as the exact form of the LO ones is\r\navailable in Ref.~\\cite{Forte:2010ta} and compact enough for an\r\nefficient implementation. In addition, also for the pure singlet NLO\r\ncoefficient functions (sometimes called gluon-radiation terms) we\r\nemploy the analytical expressions given in Appendix A of\r\nRef.~\\cite{Buza:1995ie}.\r\n\r\nWe finally remark that massive coeffient functions for the neutral\r\ncurrent structure functions are presently known only for $F_2$ and\r\n$F_L$. For the parity-violating structure function $F_3$ we thus use\r\nthe massless coefficient functions.\r\n\r\nAs far as the massless limit of the massive (massive-zero) coefficient\r\nfunctions is concerned, exact expressions up to\r\n$\\mathcal{O}(\\alpha_s^2)$ have been evaluated in\r\nRef.~\\cite{Buza:1995ie} and reported in Appendix D. Such expressions\r\nare implemented in {\\tt APFEL}\r\n\r\nAs in the massive case, massive-zero coefficient functions are know\r\nonly for $F_2$ and $F_L$ and again for the $F_3$ structure function we\r\nuse the massless coefficient functions.\r\n\r\n\\subsubsection{Charged Current Coefficient Functions}\r\n\r\nWe can now consider the charged-current sector. In this case, massive\r\ncoeffincient functions are know only up to $\\mathcal{O}(\\alpha_s)$\r\n(NLO), therefore a proper computation of charged-current structure\r\nfunctions the NNLO version of the FONLL scheme (called FONLL-C) is\r\nimpossible. However, the best we can do when computing charged-current\r\nstructure functions in the FONLL-C scheme is to set the NNLO\r\ncontributions to zero in the massive sectors but keeping those in the\r\nmassless sector, as well as using NNLO evolution for PDFs and\r\n$\\alpha_s$.\r\n\r\nThe charged-current massive structure functions, like the other\r\nstructure functions, are given by the convolution of PDFs with\r\ncoefficient functions. Considering the heavy-quark $H$ structure\r\nfunctions in the approximation of diagonal CKM matrix, the definitions\r\nare:\r\n\\begin{equation}\\label{F1}\r\n  F_1^H(x,Q,m_H)=\\frac12\\int_{\\chi}^{1}\\frac{dy}{y}\\left[C_{1,q}(y,\\xi)s\\left(\\frac{\\chi}{y},Q\\right)+C_{1,g}(y,\\xi)g\\left(\\frac{\\chi}{y},Q\\right)\\right]\r\n\\end{equation}\r\n\\begin{equation}\\label{F2}\r\n  F_2^H(x,Q,m_H)=\\chi\\int_{\\chi}^{1}\\frac{dy}{y}\\left[C_{2,q}(y,\\xi)s\\left(\\frac{\\chi}{y},Q\\right)+C_{2,g}(y,\\xi)g\\left(\\frac{\\chi}{y},Q\\right)\\right]\r\n\\end{equation}\r\n\\begin{equation}\\label{F3}\r\n  F_3^H(x,Q,m_H)=\\int_{\\chi}^{1}\\frac{dy}{y}\\left[C_{3,q}(y,\\xi)s\\left(\\frac{\\chi}{y},Q\\right)+C_{3,g}(y,\\xi)g\\left(\\frac{\\chi}{y},Q\\right)\\right]\r\n\\end{equation}\r\nwith:\r\n\\begin{equation}\r\n  \\chi = x\\left(1+\\frac{m_H^2}{Q^2}\\right) =\r\n  \\frac{x}{\\lambda}\\,,\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n  \\lambda = \\frac{Q^2}{Q^2+m_H^2} =\r\n  \\frac{\\xi}{1+\\xi}\\,.\r\n\\end{equation}\r\nNow, defining:\r\n\\begin{equation}\r\n  F_L^H(x,Q,m_H) = F_2^H(x,Q,m_H) - 2xF_1^H(x,Q,m_H)\\,,\r\n\\end{equation}\r\nwe have that:\r\n\\begin{equation}\\label{FL}\r\n  F_L^H(x,Q,m_H)=\\chi\\int_{\\chi}^{1}\\frac{dy}{y}\\left[C_{L,q}(y,\\xi)s\\left(\\frac{\\chi}{y},Q\\right)+C_{L,g}(y,\\xi)g\\left(\\frac{\\chi}{y},Q\\right)\\right]\\,,\r\n\\end{equation}\r\nwhere we have defined:\r\n\\begin{equation}\\label{clll}\r\n  C_{L,q(g)}(y,\\xi) =\r\n  C_{2,q(g)}(y,\\xi)-\\lambda C_{1,q(g)}(y,\\xi)\r\n\\end{equation}\r\n\r\nAll the coefficient functions entering the structure functions above\r\nadmit a perturbative expansion that at N$^N$LO reads:\r\n\\begin{equation}\r\n  C_{k,q(g)}(y,\\xi) = \\sum_{n=0}^N a_s^n(Q)\r\n  C_{k,q(g)}^{(n)}(y,\\xi)\\,,\\quad k = 1,2,3,L\\,.\r\n\\end{equation}\r\nIn the following we will truncate the expansion at NLO.\r\n\r\nAfter the definitions above we can write down, first the LO\r\ncoefficient functions. While at LO the gluon coefficient functions are\r\nall zero ($C_{k,g}^{(0)}(y,\\xi)=0$), the quark coefficient functions\r\nare:\r\n\\begin{equation}\r\n\\begin{array}{l}\r\n  \\displaystyle C^{(0)}_{1,q}(x,\\xi) = \\delta(1-x)\\,,\\\\\r\n  \\\\ \\displaystyle C^{(0)}_{2,q}(x,\\xi) = \\delta(1-x) \\,,\\\\ \\\\\r\n  \\displaystyle C^{(0)}_{3,q}(x,\\xi) = \\delta(1-x) \\,,\\\\ \\\\\r\n  \\displaystyle C^{(0)}_{L,q}(x,\\xi) = (1-\\lambda)\\delta(1-x) \\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nThe NLO charged-current massive coefficient have been computed and\r\nreported in Appendix A of Ref.~\\cite{Gluck:1996ve}. However, before\r\nbeing implemented in {\\tt APFEL} they need some manipulation. We start\r\ndefining:\r\n\\begin{equation}\r\n  K_A=\\frac{1}{\\lambda}(1-\\lambda)\\ln(1-\\lambda)\\,.\r\n\\end{equation}\r\nIn addition, in order to consider factorization scale variations, we\r\nalso need to consider the splitting function:\r\n\\begin{equation}\r\n  P_{qq}^{(0)}(z) =\r\n  C_F\\left[\\frac{1+z^2}{(1-z)_+}+\\frac32\\delta(1-z)\\right]=C_F\\left[\\frac{2}{(1-z)_+}-(1+z)+\\frac32\\delta(1-z)\\right]\\,,\r\n\\end{equation}\r\nand we also define:\r\n\\begin{equation}\r\n  K_F^2 =\\frac{Q^2}{\\mu_F^2}\\,.\r\n\\end{equation}\r\n\r\nThe explicit expressions of the NLO quark coefficient functions read:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{1,q}&=&\\displaystyle 2C_F \\bigg\\{\r\n                   \\bigg(-4-\\frac{1}{2\\lambda}-2\\zeta_2-\\frac{1+3\\lambda}{2\\lambda}K_A+\\frac32\r\n                   \\ln\\frac{K_F^2}{\\lambda}\\bigg)\\delta(1-z)\\\\ \\\\ &-&\\displaystyle\r\n                                                                      \\frac{(1+z^2)\\ln z}{1-z} +\r\n                                                                      \\left(-\\ln\\frac{K_F^2}{\\lambda}-2\\ln(1-z)+\\ln(1-\\lambda\r\n                                                                      z)\\right)(1+z)+(3-z)+\\frac{1}{\\lambda^2}+\\frac{z-1}{\\lambda}\\\\ \\\\\r\n               &+&\\displaystyle 2 \\left[\\frac{2\\ln(1-z)-\\ln(1-\\lambda\r\n                   z)}{1-z}\\right]_++\r\n                   2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\left[\\frac{1}{1-z}\\right]_+\\\\\r\n  \\\\ &+& \\displaystyle\r\n         \\frac{\\lambda-1}{\\lambda^2}\\left[\\frac{1}{1-\\lambda z}\\right]_+\r\n         +\\frac{1}{2}\\left[\\frac{1-z}{(1-\\lambda z)^2}\\right]_+\\bigg\\}\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{2,q}&=&\\displaystyle 2C_F \\bigg\\{\r\n                   \\bigg(-4-\\frac{1}{2\\lambda}-2\\zeta_2-\\frac{1+\\lambda}{2\\lambda}K_A+\\frac32\r\n                   \\ln\\frac{K_F^2}{\\lambda}\\bigg)\\delta(1-z)\\\\ \\\\ &-&\\displaystyle\r\n                                                                      \\frac{(1+z^2)\\ln z}{1-z} +\r\n                                                                      \\left(2-\\ln\\frac{K_F^2}{\\lambda}-2\\ln(1-z)+\\ln(1-\\lambda\r\n                                                                      z)\\right)(1+z)+\\frac{1}{\\lambda}\\\\ \\\\ &+&\\displaystyle 2\r\n                                                                                                                \\left[\\frac{2\\ln(1-z)-\\ln(1-\\lambda z)}{1-z}\\right]_++\r\n                                                                                                                2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\left[\\frac{1}{1-z}\\right]_+\\\\\r\n  \\\\ &+& \\displaystyle\r\n         \\frac{2\\lambda^2-\\lambda-1}{\\lambda}\\left[\\frac{1}{1-\\lambda\r\n         z}\\right]_+ +\\frac{1}{2}\\left[\\frac{1-z}{(1-\\lambda\r\n         z)^2}\\right]_+\\bigg\\}\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{3,q}&=&\\displaystyle 2C_F \\bigg\\{\r\n                   \\bigg(-4-\\frac{1}{2\\lambda}-2\\zeta_2-\\frac{1+3\\lambda}{2\\lambda}K_A+\\frac32\r\n                   \\ln\\frac{K_F^2}{\\lambda}\\bigg)\\delta(1-z)\\\\ \\\\ &-&\\displaystyle\r\n                                                                      \\frac{(1+z^2)\\ln z}{1-z} +\r\n                                                                      \\left(1-\\ln\\frac{K_F^2}{\\lambda}-2\\ln(1-z)+\\ln(1-\\lambda\r\n                                                                      z)\\right)(1+z)+\\frac{1}{\\lambda}\\\\ \\\\ &+&\\displaystyle 2\r\n                                                                                                                \\left[\\frac{2\\ln(1-z)-\\ln(1-\\lambda z)}{1-z}\\right]_++\r\n                                                                                                                2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\left[\\frac{1}{1-z}\\right]_+\\\\\r\n  \\\\ &+& \\displaystyle \\frac{\\lambda-1}{\\lambda}\\left[\\frac{1}{1-\\lambda\r\n         z}\\right]_+ +\\frac{1}{2}\\left[\\frac{1-z}{(1-\\lambda\r\n         z)^2}\\right]_+\\bigg\\}\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{L,q} &=&\\displaystyle 2C_F\r\n                    (1-\\lambda)\\bigg\\{\r\n                    \\bigg(-4-\\frac{1}{2\\lambda}-2\\zeta_2-\\frac{1+\\lambda}{2\\lambda}K_A+\\frac32\r\n                    \\ln\\frac{K_F^2}{\\lambda}\\bigg)\\delta(1-z)\\\\ \\\\ &-&\\displaystyle\r\n                                                                       \\frac{(1+z^2)\\ln z}{1-z} +\r\n                                                                       \\left(-\\ln\\frac{K_F^2}{\\lambda}-2\\ln(1-z)+\\ln(1-\\lambda\r\n                                                                       z)\\right)(1+z)+3\\\\ \\\\ &+&\\displaystyle 2\r\n                                                                                                 \\left[\\frac{2\\ln(1-z)-\\ln(1-\\lambda z)}{1-z}\\right]_++ 2\r\n                                                                                                 \\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\left[\\frac{1}{1-z}\\right]_+\\\\\r\n  \\\\ &-& \\displaystyle 2\\left[\\frac{1}{1-\\lambda z}\\right]_+\r\n         +\\frac{1}{2}\\left[\\frac{1-z}{(1-\\lambda z)^2}\\right]_+\\bigg\\} + 2C_F\r\n         \\left[\\lambda K_A \\delta(1-z) + (1+\\lambda)z\\right]\r\n\\end{array}\\,.\r\n\\end{equation}\r\n\r\nIn order to proceed with our manipulations we need to define the\r\ngeneralized or incomplete +-prescription:\r\n\\begin{equation}\r\n\\begin{array}{c}\r\n  \\displaystyle \\int_x^1 dz\\left[f(z)\\right]_+g(z) =\r\n  \\int_x^1\r\n  dz\\,f(z)\\left[g(z)-g(1)\\right]-g(1)\\underbrace{\\int_0^xdz\\,f(z)}_{-R_f(x)}=\\\\\r\n  \\\\ \\displaystyle \\int_x^1\r\n  dz\\left\\{\\left[f(z)\\right]_++R_f(x)\\delta(1-z)\\right\\}g(z)\\,.\r\n\\end{array}\r\n\\end{equation} \r\nwhere the +-prescription in the r.h.s of the equation above should be\r\nunderstood in the usual way independently of the integration bounds.\r\n\r\nOften the residual $R_f(x)$ function can be evaluated analytically by\r\nperforming the integral, however sometimes it need to be evaluated\r\nnumerically performing the integral in a numerical way. In particular\r\nthe $+$-prescripted functions that enter the expressions above give\r\nrise to the following residual functions that can be computed\r\nanalytically:\r\n\\begin{equation}\r\n  -\\int_0^x\\frac{dz}{1-z} = \\ln(1-x)\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  -\\int_0^xdz\\frac{\\ln(1-z)}{1-z} = \\frac12\r\n  \\ln^2(1-x)\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  -\\int_0^x\\frac{dz}{1-\\lambda z} =\r\n  \\frac{1}{\\lambda}\\ln(1-\\lambda x)\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  -\\int_0^xdz\\frac{1-z}{(1-\\lambda z)^2} =\r\n  \\frac{1}{\\lambda^2}\\ln(1-\\lambda\r\n  x)+\\frac{1-\\lambda}{\\lambda}\\frac{x}{1-\\lambda x}\\,,\r\n\\end{equation}\r\nwhile we do not know how to solve analytically the integral:\r\n\\begin{equation}\r\n  R(x)=-\\int_0^xdz\\frac{\\ln(1-\\lambda z)}{1-z}\r\n\\end{equation}\r\ntherefore we will compute it numerically.\r\n\r\nAs a consequence, when convoluting the coefficient functions above\r\nwith PDFs in the point $x$, we can treat the $+$-prescripted functions\r\nusing the standard definition at the price of adding to the local\r\nterms the following functions:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{1,q}&\\rightarrow& \\displaystyle\r\n                             C^{(1)}_{1,q} +\r\n                             2C_F\\bigg[2\\ln^2(1-x)-2R(x)+2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\ln(1-x)\\\\\r\n  \\\\ &&\\displaystyle +\\frac{\\lambda-1}{\\lambda^3}\\ln(1-\\lambda\r\n        x)+\\frac{1}{2\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1-\\lambda}{2\\lambda}\\frac{x}{1-\\lambda x}\\bigg]\\delta(1-z)\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{2,q}&\\rightarrow& \\displaystyle\r\n                             C^{(1)}_{2,q} +\r\n                             2C_F\\bigg[2\\ln^2(1-x)-2R(x)+2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\ln(1-x)\\\\\r\n  \\\\ &&\\displaystyle\r\n        +\\frac{2\\lambda^2-\\lambda-1}{\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1}{2\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1-\\lambda}{2\\lambda}\\frac{x}{1-\\lambda x}\\bigg]\\delta(1-z)\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{3,q}&\\rightarrow& \\displaystyle\r\n                             C^{(1)}_{3,q} +\r\n                             2C_F\\bigg[2\\ln^2(1-x)-2R(x)+2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\ln(1-x)\\\\\r\n  \\\\ &&\\displaystyle +\\frac{\\lambda-1}{\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1}{2\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1-\\lambda}{2\\lambda}\\frac{x}{1-\\lambda x}\\bigg]\\delta(1-z)\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{L,q}&\\rightarrow& \\displaystyle\r\n                             C^{(1)}_{L,q} +\r\n                             2C_F(1-\\lambda)\\bigg[2\\ln^2(1-x)-2R(x)+2\\left(-1+\\ln\\frac{K_F^2}{\\lambda}\\right)\\ln(1-x)\\\\\r\n  \\\\ &&\\displaystyle -\\frac{2}{\\lambda}\\ln(1-\\lambda\r\n        x)+\\frac{1}{2\\lambda^2}\\ln(1-\\lambda\r\n        x)+\\frac{1-\\lambda}{2\\lambda}\\frac{x}{1-\\lambda x}\\bigg]\\delta(1-z)\r\n\\end{array}\\,.\r\n\\end{equation}\r\n\r\nNow let us consider the gluon coefficient functions, that read:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{1,g}&=&\\displaystyle\r\n                   2T_R\\bigg\\{[z^2+(1-z)^2]\\left[\\ln\\left(\\frac{1-z}{z}\\right)\r\n                   -\\frac12\\ln(1-\\lambda) +\\frac12\\ln\\frac{K_F^2}{\\lambda} \\right]+\\\\ \\\\\r\n               &&\\displaystyle 4z(1-z) - 1+\\\\ \\\\ &&\\displaystyle\r\n                                                    (1-\\lambda)\\left[-4z(1-z) + \\frac{z}{1-\\lambda z} +2z(1-2\\lambda\r\n                                                    z)\\ln\\frac{1-\\lambda z}{(1-\\lambda)z}\\right]\\bigg\\}\\\\\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{2,g}&=&\\displaystyle 2T_R\r\n                   \\bigg\\{[z^2+(1-z)^2]\\left[\\ln\\left(\\frac{1-z}{z}\\right)\r\n                   -\\frac12\\ln(1-\\lambda) +\\frac12\\ln\\frac{K_F^2}{\\lambda} \\right]+\\\\ \\\\\r\n               &&\\displaystyle 8z(1-z)- 1+\\\\ \\\\ &&\\displaystyle\r\n                                                   (1-\\lambda)\\left[-6(1+2\\lambda) z(1-z)+\\frac{1}{1-\\lambda z} +\r\n                                                   6\\lambda z(1-2\\lambda z)\\ln\\frac{1-\\lambda\r\n                                                   z}{(1-\\lambda)z}\\right]\\bigg\\}\\\\\r\n\\end{array}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{3,g}&=&\\displaystyle 2T_R\r\n                   \\bigg\\{[z^2+(1-z)^2]\\left[ 2\\ln\\left(\\frac{1-z}{1-\\lambda\r\n                   z}\\right)+\\frac12\\ln(1-\\lambda)\r\n                   +\\frac12\\ln\\frac{K_F^2}{\\lambda}\\right]+\\\\ \\\\ &&\\displaystyle\r\n                                                                    (1-\\lambda)\\left[2 z(1-z) - 2z[1-(1+\\lambda )z]\\ln\\frac{1-\\lambda\r\n                                                                    z}{(1-\\lambda)z}\\right]\\bigg\\}\\,,\r\n\\end{array}\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{L,g}&=&\\displaystyle 2T_R\r\n                   \\bigg\\{(1-\\lambda)[z^2+(1-z)^2]\\left[\\ln\\left(\\frac{1-z}{z}\\right)\r\n                   -\\frac12\\ln(1-\\lambda) +\\frac12\\ln\\frac{K_F^2}{\\lambda} \\right]+\\\\ \\\\\r\n               &&\\displaystyle 4(2-\\lambda)z(1-z)+\\\\ \\\\ &&\\displaystyle\r\n                                                           (1-\\lambda)\\left[-2(3+4\\lambda) z(1-z)+ 4\\lambda z(1-2\\lambda\r\n                                                           z)\\ln\\frac{1-\\lambda z}{(1-\\lambda)z}\\right]\\bigg\\}\\,.\r\n\\end{array}\r\n\\end{equation}\r\nSince these functions do not contain any $+$-prescripted functions,\r\nthey can be implemented as they are.\r\n\r\nWe now consider the massless limit of the above massive coefficient\r\nfunctions. We start considering that:\r\n\\begin{equation}\r\n\\begin{array}{l} \r\n  \\lambda \\rightarrow 1\\\\ K_A \\rightarrow 0\r\n\\end{array}\\,,\r\n\\end{equation}\r\nas consequence we find that the quark coefficient functions tend to:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{1,q}\r\n  \\displaystyle\\mathop{\\longrightarrow}_{m_H\\rightarrow 0}\r\n  C^{0,(1)}_{1,q} &=&\\displaystyle 2C_F \\bigg\\{\r\n                      -\\left(\\frac{9}{2}+2\\zeta_2-\\frac32 \\ln K_F^2\\right)\\delta(1-z)\\\\ \\\\\r\n                  &-&\\displaystyle \\frac{(1+z^2)\\ln z}{1-z} -\\left(\\ln(1-z)+\\ln\r\n                      K_F^2\\right)(1+z)+3\\\\ \\\\ &+&\\displaystyle 2\r\n                                                   \\left[\\frac{\\ln(1-z)}{1-z}\\right]_+ -\\left(\\frac{3}{2}-2\\ln\r\n                                                   K_F^2\\right)\\left[\\frac{1}{1-z}\\right]_+\\bigg\\}\r\n\\end{array}\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{2,q}\\displaystyle\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n  0}C^{0,(1)}_{2,q}&=&\\displaystyle 2C_F \\bigg\\{\r\n                       -\\left(\\frac{9}{2}+2\\zeta_2-\\frac32 \\ln K_F^2\\right)\\delta(1-z)\\\\ \\\\\r\n                   &-&\\displaystyle \\frac{(1+z^2)\\ln z}{1-z} -\\left(\\ln(1-z)+\\ln\r\n                       K_F^2\\right)(1+z)+2z+3\\\\ \\\\ &+&\\displaystyle 2\r\n                                                       \\left[\\frac{\\ln(1-z)}{1-z}\\right]_+ -\\left(\\frac{3}{2}-2\\ln\r\n                                                       K_F^2\\right)\\left[\\frac{1}{1-z}\\right]_+\\bigg\\}\r\n\\end{array}\r\n\\end{equation}\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  C^{(1)}_{3,q}\\displaystyle\\mathop{\\longrightarrow}_{m_H\\rightarrow 0}\r\n  C^{0,(1)}_{3,q}&=&\\displaystyle 2C_F \\bigg\\{\r\n                      -\\left(\\frac{9}{2}+2\\zeta_2-\\frac32 \\ln K_F^2\\right)\\delta(1-z)\\\\ \\\\\r\n                  &-&\\displaystyle \\frac{(1+z^2)\\ln z}{1-z} -\\left(\\ln(1-z)+\\ln\r\n                      K_F^2\\right)(1+z)+z+2\\\\ \\\\ &+&\\displaystyle 2\r\n                                                     \\left[\\frac{\\ln(1-z)}{1-z}\\right]_+ -\\left(\\frac{3}{2}-2\\ln\r\n                                                     K_F^2\\right)\\left[\\frac{1}{1-z}\\right]_+\\bigg\\}\r\n\\end{array}\r\n\\end{equation}\r\n\\begin{equation} C^{(1)}_{L,q}\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n0} C^{0,(1)}_{L,q} = 4C_F z\r\n\\end{equation}\r\n\r\nThe local term to be added to the quark coefficient functions,\r\nconsidering that:\r\n\\begin{equation}\r\n  R(x) \\mathop{\\longrightarrow}_{m_H\\rightarrow 0}\r\n  \\frac12\\ln(1-x)^2\\,,\r\n\\end{equation}\r\nare:\r\n\\begin{equation}\r\n  C^{0,(1)}_{1,q}\\rightarrow C^{0, (1)}_{1,q} +\r\n  2C_F\\left[\\ln^2(1-x)-\\left(\\frac32-2\\ln\r\n      K_F^2\\right)\\ln(1-x)\\right]\\delta(1-z)\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  C^{0, (1)}_{2,q}\\rightarrow C^{0, (1)}_{2,q} +\r\n  2C_F\\left[\\ln^2(1-x)-\\left(\\frac32-2\\ln\r\n      K_F^2\\right)\\ln(1-x)\\right]\\delta(1-z)\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  C^{0, (1)}_{3,q}\\rightarrow C^{0, (1)}_{3,q} +\r\n  2C_F\\left[\\ln^2(1-x)-\\left(\\frac32-2\\ln\r\n      K_F^2\\right)\\ln(1-x)\\right]\\delta(1-z)\\,,\r\n\\end{equation}\r\nwhile no local term needs to be added to $C^{0, (1)}_{L,q}$.\r\n\r\nNow we turn to the gluon coefficient functions where we need to know\r\nthat:\r\n\\begin{equation} \r\n  \\ln(1-\\lambda)\r\n  \\mathop{\\longrightarrow}_{m_H\\rightarrow 0}\r\n  -\\ln\\left(\\frac{Q^2}{m_H^2}\\right)\r\n\\end{equation}\r\nso that:\r\n\\begin{equation}\r\n  C^{(1)}_{1,g}\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n    0} C^{0, (1)}_{1,g} =\r\n  2T_R\\left\\{[z^2+(1-z)^2]\\left[\\ln\\left(\\frac{1-z}{z}\\right) +\\frac12\r\n      \\ln\\left(\\frac{Q^2}{m_H^2}\\right) +\\frac12\\ln K_F^2\\right]+ 4z(1-z) -\r\n    1\\right\\}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  C^{(1)}_{2,g}\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n    0} C^{0, (1)}_{2,g} =\r\n  2T_R\\left\\{[z^2+(1-z)^2]\\left[\\ln\\left(\\frac{1-z}{z}\\right) +\\frac12\r\n      \\ln\\left(\\frac{Q^2}{m_H^2}\\right) +\\frac12\\ln K_F^2\\right]+ 8z(1-z) -\r\n    1\\right\\}\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  C^{(1)}_{3,g}\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n    0} C^{0, (1)}_{3,g} = 2T_R[z^2+(1-z)^2]\\left[-\\frac12\r\n    \\ln\\left(\\frac{Q^2}{m_H^2}\\right) +\\frac12\\ln K_F^2\\right]\\,,\r\n\\end{equation}\r\n\\begin{equation}\r\n  C^{(1)}_{L,g}\\mathop{\\longrightarrow}_{m_H\\rightarrow\r\n    0} C^{0,(1)}_{L,g} = 2T_R\\left[4z(1-z)\\right]\\,.\r\n\\end{equation}\r\nWe also note that in the limit $m_H\\rightarrow 0$, the covolution\r\nintegrals in eqs.~(\\ref{F1}), (\\ref{F2}), (\\ref{F3}) and~(\\ref{FL})\r\nwill extend from $x$ to 1 rather than from $\\chi$ to 1.\r\n\r\nAs clear from the definitions in eqs.~(\\ref{F1}), (\\ref{F2}),\r\n(\\ref{F3}) and~(\\ref{FL}), in order to compute a give structure\r\nfunctions for some given value of $x$, one needs to convolute the\r\ncoefficient functions that we have written above with PDFs in the\r\nrescaled point $\\chi=x/\\lambda > x$, so in particular the convolution\r\nintegral extends from $\\chi$ to 1. This is a kinematical consequence\r\nof the mass of the heavy quark involved that reduces the phase space\r\navailable for the process.\r\n\r\nFrom the point of view of the implementation of the FONLL scheme in\r\n{\\tt APFEL}, given that the massive scheme needs to be combined with\r\nthe massless and the massive-zero schemes whose convolution integrals\r\nextend from $x$ to 1, it would be convinient to rewrite\r\neqs.~(\\ref{F1}), (\\ref{F2}), (\\ref{F3}) and~(\\ref{FL}) in such a way\r\nthat the lower interagration bound is $x$ rather than $\\chi$. To this\r\nend, let us consider the integral:\r\n\\begin{equation}\r\n  I=\\int_\\chi^1\\frac{dy}{y}\r\n  C(y)f\\left(\\frac{\\chi}{y}\\right)\\,,\r\n\\end{equation}\r\nwhere $\\chi=x/\\lambda$. By the change of integration variable\r\n$z = \\lambda y$, we can rewrite the integral above as:\r\n\\begin{equation}\r\n  I=\\int_x^\\lambda\\frac{dz}{z}\r\n  C\\left(\\frac{z}{\\lambda}\\right)f\\left(\\frac{x}{y}\\right) =\r\n  \\int_x^1\\frac{dz}{z}\r\n  \\widetilde{C}(z,\\lambda)f\\left(\\frac{x}{y}\\right)\\,,\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n  \\widetilde{C}(z,\\lambda)=\\theta(\\lambda-z)C\\left(\\frac{z}{\\lambda}\\right)\\,.\r\n\\end{equation}\r\nIn this way we have achived the goal of expressing the ``reduced''\r\nconvolution in eqs.~(\\ref{F1}), (\\ref{F2}), (\\ref{F3}) and~(\\ref{FL})\r\nas a ``standard'' convolution between $x$ and 1. The price to pay is\r\nto consider the massive coefficient functions during the integration\r\nas explicit functions of the variable $z/\\lambda$ and to cut off the\r\nregion $z>\\lambda$ by means of the Heaviside $\\theta$-function.  Of\r\ncourse, this does not neet to be done in the massive-zero case as the\r\nconvolution already extends between $x$ and $1$.\r\n\r\n\\section{Target Mass Corrections}\r\n\r\nKinematic corrections due to the finite mass of the target proton\r\n$M_p$ which recoils against the photon might be relevant in the\r\nsmall-energy region. The leading contributions to such corrections\r\nhave been computed long time ago in Ref.~\\cite{Georgi:1976ve} and,\r\ndenoting the target-mass corrected struture functions with\r\n$\\widetilde{\\quad}$, they take the form:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  \\displaystyle \\widetilde{F}_2(x,Q) &=&\r\n                                         \\displaystyle \\frac{x^2}{\\xi^2 \\tau^{3/2}} F_2(\\xi,Q) + \\frac{6\\rho\r\n                                         x^3}{\\tau^2} I_2(\\xi,Q)\\,,\\\\ \\\\ \\displaystyle \\widetilde{F}_L(x,Q) &=&\r\n                                                                                                                \\displaystyle F_L(\\xi,Q)+\\frac{x^2(1-\\tau)}{\\xi^2 \\tau^{3/2}}\r\n                                                                                                                F_2(\\xi,Q) + \\frac{\\rho x^3(6-2\\tau)}{\\tau^2} I_2(\\xi,Q)\\,,\\\\ \\\\\r\n  \\displaystyle x\\widetilde{F}_3(x,Q) &=& \\displaystyle \\frac{x^2}{\\xi^2\r\n                                          \\tau} \\xi F_3(\\xi,Q) + \\frac{4\\rho x^3}{\\tau^{3/2}} I_3(\\xi,Q)\\,,\r\n\\end{array}\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n  \\rho = \\frac{M_p^2}{Q^2}\\,,\\qquad \\tau = 1 + 4\\rho\r\n  x^2\\,,\\qquad \\xi = \\frac{2x}{1+\\sqrt{\\tau}}\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\r\n  I_2(\\xi,Q) = \\int_\\xi^1dy \\frac{F_2(y,Q)}{y^2}\\,,\r\n  \\qquad I_3(\\xi,Q) = \\int_\\xi^1dy \\frac{yF_3(y,Q)}{y^2}\\,.\r\n\\end{equation}\r\nUsing the interpolation formula, we have that:\r\n\\begin{equation}\r\n  \\frac{F_2(y,Q)}{y^2} = \\sum_{\\alpha}\r\n  \\frac{F_2(x_\\alpha,Q)}{x_\\alpha^2} w_\\alpha^{(k)}(y)\\,,\r\n\\end{equation}\r\ntherefore:\r\n\\begin{equation}\r\n  I_2(\\xi,Q) = \\sum_{\\alpha}\r\n  \\frac{F_2(x_\\alpha,Q)}{x_\\alpha^2} \\int_\\xi^1dy\\,w_\\alpha^{(k)}(y)\\,,\r\n\\end{equation}\r\nwhile:\r\n\\begin{equation}\r\n  I_3(\\xi,Q) = \\sum_{\\alpha} \\frac{x_\\alpha\r\n    F_3(x_\\alpha,Q)}{x_\\alpha^2} \\int_\\xi^1dy\\,w_\\alpha^{(k)}(y)\\,.\r\n\\end{equation} In turn, again using the interpolation formula, we can\r\nwrite:\r\n\\begin{equation}\r\n  J_\\alpha(\\xi)\\equiv\\int_\\xi^1dy\\,w_\\alpha^{(k)}(y) =\r\n  \\sum_{\\beta=0}^{N_x}\r\n  \\underbrace{\\left[\\int_{x_\\beta}^1dy\\,w_\\alpha^{(k)}(y)\\right]}_{J_{\\beta\\alpha}}\r\n  w_\\beta^{(k)}(\\xi)\\,.\r\n\\end{equation}\r\nConsidering the fact that:\r\n\\begin{equation}\\label{nonzero}\r\n  w_{\\alpha}^{(k)}(y) \\neq 0\r\n  \\quad\\mbox{for}\\quad x_{\\alpha-k} < y < x_{\\alpha+1}\\,,\r\n\\end{equation}\r\nit follows that:\r\n\\begin{equation}\r\n  J_{\\beta\\alpha} = 0\\quad\\mbox{for}\\quad \\beta >\r\n  \\alpha\r\n\\end{equation}\r\nand thus:\r\n\\begin{equation}\r\n  J_\\alpha(\\xi)=\\sum_{\\beta=0}^\\alpha J_{\\beta\\alpha}\r\n  w_\\beta^{(k)}(\\xi)\\,.\r\n\\end{equation}\r\nIn addition, we can simplify the integral as follows:\r\n\\begin{equation}\r\n  J_{\\beta\\alpha} = \\int_c^d dy\\,w_\\alpha^{(k)}(y)\\,,\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n  c =\r\n  \\mbox{max}(x_\\beta,x_{\\alpha-k})\\quad\\mbox{and}\\quad d =\r\n  \\mbox{min}(1,x_{\\alpha+1})\\,.\r\n\\end{equation}\r\nIn conclusion, we can treat $J_{\\beta\\alpha}$ exactly in the same\r\nmanner as the regular part of a massless coefficient function or a\r\nsplitting function and thus it can be precomputed and stored.\r\n\r\nAt the end of the day we have that:\r\n\\begin{equation}\r\n  I_2(\\xi,Q) = \\sum_{\\alpha=0}^{N_x}\r\n  \\sum_{\\beta=0}^\\alpha w_\\beta^{(k)}(\\xi) J_{\\beta\\alpha}\r\n  \\frac{F_2(x_\\alpha,Q)}{x_\\alpha^2} \\,,\r\n\\end{equation}\r\nthat can also be written as:\r\n\\begin{equation}\r\n  I_2(\\xi,Q) = \\sum_{\\beta=0}^{N_x}\r\n  \\underbrace{\\left[\\sum_{\\alpha=\\beta}^{N_x} J_{\\beta\\alpha}\r\n      \\frac{F_2(x_\\alpha,Q)}{x_\\alpha^2}\\right]}_{I_2(x_\\beta,Q)}\r\n  w_\\beta^{(k)}(\\xi) \\,.\r\n\\end{equation}\r\nSimilarly:\r\n\\begin{equation}\r\n  I_3(\\xi,Q) = \\sum_{\\beta=0}^{N_x}\r\n  \\underbrace{\\left[\\sum_{\\alpha=\\beta}^{N_x} J_{\\beta\\alpha}\r\n      \\frac{x_\\alpha F_3(x_\\alpha,Q)}{x_\\alpha^2}\\right]}_{I_3(x_\\beta,Q)}\r\n  w_\\beta^{(k)}(\\xi) \\,.\r\n\\end{equation}\r\nGathering all pieces we finally find:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  \\displaystyle \\widetilde{F}_2(x,Q) &=&\r\n                                         \\displaystyle \\sum_{\\beta=0}^{N_x} \\left[\\frac{x^2}{\\xi^2 \\tau^{3/2}}\r\n                                         F_2(x_\\beta,Q) + \\frac{6\\rho x^3}{\\tau^2}\r\n                                         I_2(x_\\beta,Q)\\right]w_\\beta^{(k)}(\\xi)\\,,\\\\ \\\\ \\displaystyle\r\n  \\widetilde{F}_L(x,Q) &=& \\displaystyle \\sum_{\\beta=0}^{N_x} \\left[\r\n                           F_L(x_\\beta,Q)+\\frac{x^2(1-\\tau)}{\\xi^2 \\tau^{3/2}} F_2(x_\\beta,Q) +\r\n                           \\frac{\\rho x^3(6-2\\tau)}{\\tau^2} I_2(x_\\beta,Q)\r\n                           \\right]w_\\beta^{(k)}(\\xi)\\,,\\\\ \\\\ \\displaystyle x\\widetilde{F}_3(x,Q)\r\n                                     &=& \\displaystyle \\sum_{\\beta=0}^{N_x} \\left[ \\frac{x^2}{\\xi^2 \\tau}\r\n                                         x_\\beta F_3(x_\\beta,Q) + \\frac{4\\rho x^3}{\\tau^{3/2}} I_3(x_\\beta,Q)\r\n                                         \\right]w_\\beta^{(k)}(\\xi)\\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nFor the equations above is clear that in the case when $M_p = 0$, that\r\nimplies $\\rho = 0$, $\\tau = 1$ and $\\xi = x$, all structure functions\r\nreduce to the uncorrected formulas.\r\n\r\nWhen considering the extraction of the DIS operator times the\r\nevolution operator like in eq.~(\\ref{CFtimesEvolution}), one should be\r\ncareful with $I_2$ and $I_3$. Condidering that:\r\n\\begin{equation}\r\n  F(x_\\alpha,Q) =\r\n  \\sum_{\\gamma,\\delta}\\sum_{i,j}\\Gamma_{i,\\alpha\\gamma}(Q)\r\n  M_{ij,\\gamma\\delta}(Q,Q_0) \\tilde{q}_j(x_{\\delta},Q_0)\r\n\\end{equation}\r\nwe have that:\r\n\\begin{equation}\r\n  I(x_\\beta,Q) = \\sum_{\\alpha=\\beta}^{N_x}\r\n  J_{\\beta\\alpha} \\frac{F(x_\\alpha,Q)}{x_\\alpha^2} =\r\n  \\sum_{\\gamma,\\delta}\\sum_{i,j} \\left[\\sum_{\\alpha=\\beta}^{N_x}\r\n    \\frac{J_{\\beta\\alpha}\\Gamma_{i,\\alpha\\gamma}(Q) }{x_\\alpha^2}\\right]\r\n  M_{ij,\\gamma\\delta}(Q,Q_0)\\tilde{q}_j(x_{\\delta},Q_0)\\,,\r\n\\end{equation}\r\n\r\n\\section{Renormalization and Factorization Scale Variation}\r\n\r\nIn the previous sections, when discussing the implementation of the\r\nstructure functions in {\\tt APFEL}, we assumed that the\r\nrenormalization scale $\\mu_R$ and the factorization scale $\\mu_F$ were\r\nidentified to the scale pf the process $Q$. In this section, we want\r\nto relax this assumption and to do so we the expansion of the DGLAP\r\nand RG equation for $\\alpha_s$ up to NLO, that is:\r\n\\begin{equation}\r\n  \\frac{\\partial f_{i}}{\\partial\\ln\\mu_F^2} =\r\n  \\frac{\\alpha_s(\\mu_F)}{4\\pi}\\left[ P_{ij}^{(0)}(x) +\r\n    \\frac{\\alpha_s(\\mu_F)}{4\\pi} P_{ij}^{(1)}(x) + \\dots\\right]\\otimes\r\n  f_j(x,\\mu_F)\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\r\n  \\frac{\\partial\r\n  }{\\partial\\ln\\mu_R^2}\\left(\\frac{\\alpha_s}{4\\pi}\\right) =\r\n  -\\left(\\frac{\\alpha_s(\\mu_R)}{4\\pi}\\right)^2\\left[ \\beta_0 +\r\n    \\frac{\\alpha_s(\\mu_R)}{4\\pi}\\beta_1 + \\dots\\right]\\,.\r\n\\end{equation}\r\nDefining:\r\n\\begin{equation}\r\n  \\xi_R\\equiv\\frac{\\mu_R}{Q}\\,,\\quad\\xi_F\\equiv\\frac{\\mu_F}{Q}\\quad\\mbox{and}\\quad\r\n  a_s=\\frac{\\alpha_s}{4\\pi}\r\n\\end{equation}\r\nwhere $Q$ is constant, and defining:\r\n\\begin{equation}\r\n  t_R \\equiv \\ln\\xi_R^2\\quad\\mbox{and}\\quad t_F \\equiv\r\n  \\ln\\xi_F^2\\,,\r\n\\end{equation}\r\nthe equations above can be written as:\r\n\\begin{equation}\\label{DGLAPsimp}\r\n  \\frac{\\partial f_{i}}{\\partial t_F}\r\n  = a_s(t_F)\\left[ P_{ij}^{(0)} + a_s(t_F) P_{ij}^{(1)} +\r\n    \\dots\\right]\\otimes f_j(t_F)\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\\label{BETAsimp}\r\n  \\frac{\\partial a_s}{\\partial t_R} =\r\n  -a_s^2(t_R)\\left[ \\beta_0 + a_s(t_R)\\beta_1 + \\dots\\right]\\,.\r\n\\end{equation}\r\nNow, expanding $f_i(t)$ around $t=t_F$ we have:\r\n\\begin{equation}\\label{expDGLAP}\r\n  f_i(t) = f_i(t_F)+\\frac{\\partial\r\n    f_{i}}{\\partial t}\\bigg|_{t=t_F} (t-t_F) + \\frac12 \\frac{\\partial^2\r\n    f_{i}}{\\partial t^2}\\bigg|_{t=t_F} (t-t_F)^2 + \\dots\r\n\\end{equation}\r\nUsing eqs.~(\\ref{DGLAPsimp}) and~(\\ref{BETAsimp}), we have that:\r\n\\begin{equation}\r\n\\begin{array}{l} \r\n  \\displaystyle \\frac{\\partial f_{i}}{\\partial\r\n  t}\\bigg|_{t=t_F} = \\left[ a_s(t_F) P_{ij}^{(0)} + a_s^2(t_F)\r\n  P_{ij}^{(1)}\\right]\\otimes f_j(t_F) + \\mathcal{O}(a_s^3)\\\\ \\\\\r\n  \\displaystyle \\frac{\\partial^2 f_{i}}{\\partial t^2}\\bigg|_{t=t_F} =\r\n  a_s^2(t_F)\\left[ P_{il}^{(0)}\\otimes P_{lj}^{(0)} - \\beta_0\r\n  P_{ij}^{(0)} \\right]\\otimes f_j(t_F) + \\mathcal{O}(a_s^3)\r\n\\end{array}\r\n\\end{equation}\r\nChosing $t=0$ in eq.~(\\ref{expDGLAP}), we finally have:\r\n\\begin{equation}\\label{expDGLAP1}\r\n  f_i(0) = \\left\\{1-a_s(t_F) t_F\r\n    P_{ij}^{(0)} + a_s^2(t_F)\\left[-t_F P_{ij}^{(1)}+ t_F^2 \\frac12\\left(\r\n        P_{il}^{(0)}\\otimes P_{lj}^{(0)} - \\beta_0 P_{ij}^{(0)}\r\n      \\right)\\right]\\right\\}\\otimes f_j(t_F) + \\mathcal{O}(a_s^3)\\,.\r\n\\end{equation}\r\nNow, using eq.~(\\ref{BETAsimp}), we easily find:\r\n\\begin{equation}\\label{BETAexp} \r\n  a_s(t_F)=\r\n  a_s(t_R)\\left[1+a_s(t_R)\\beta_{0}(t_R-t_F)+\\mathcal{O}(a_s^2)\\right]\\,,\r\n\\end{equation}\r\nwhich can be plugged into eq.~(\\ref{expDGLAP1}) to give:\r\n\\begin{equation}\\label{expDGLAP2}\r\n  f_i(0) = \\left\\{1-a_s(t_R) t_F\r\n    P_{ij}^{(0)} + a_s^2(t_R)\\left[-t_F P_{ij}^{(1)}+ t_F^2 \\frac12\\left(\r\n        P_{il}^{(0)}\\otimes P_{lj}^{(0)} + \\beta_0 P_{ij}^{(0)} \\right)-\r\n      t_Ft_R\\beta_{0}P_{ij}^{(0)}\\right]\\right\\}\\otimes f_j(t_F) +\r\n  \\mathcal{O}(a_s^3)\\,.\r\n\\end{equation}\r\nFinally, setting $t_F=0$ in eq.~(\\ref{BETAexp}), we find:\r\n\\begin{equation}\\label{BETAexp1} \r\n  a_s(0)=\r\n  a_s(t_R)\\left[1+a_s(t_R)\\beta_{0}t_R+\\mathcal{O}(a_s^2)\\right]\\,,\r\n\\end{equation}\r\n\r\nConsidering that and NNLO the ZM structure functions are written in\r\nterms of PDFs and coefficient functions as:\r\n\\begin{equation}\\label{NonZeroScales}\r\n  F(t_R,t_F) / x = \\left[\\sum_{k=0}^{2} a_s^k(t_R)\r\n    \\widetilde{\\mathcal{C}}_i^{(k)}(t_R,t_F)\\right]\\otimes f_i(t_F)\r\n  +\\mathcal{O}(a_s^3)\\,,\r\n\\end{equation}\r\nand that, up to subleading terms, the structure functions must be\r\nrenormalization and factorization scale independent, this requires\r\nthat:\r\n\\begin{equation}\\label{invariance}\r\n  F(t_R,t_F) = F(0,0)\\,.\r\n\\end{equation} \r\nBut since:\r\n\\begin{equation}\\label{ZeroScales}\r\n  F(0,0) / x = \\left[\\sum_{k=0}^{2}\r\n    a_s^k(0) \\widetilde{C}_i^{(k)}\\right]\\otimes\r\n  f_i(0)+\\mathcal{O}(a_s^3)\\,,\r\n\\end{equation} \r\nwhere $\\widetilde{C}_i^{(k)}$ are the well-know ZM coefficient\r\nfunctions, using eqs.~(\\ref{expDGLAP2}) and~(\\ref{BETAexp1}) in\r\neq.~(\\ref{ZeroScales}) and finally imposing the identity in\r\neq.~(\\ref{invariance}), we can find the explicit espression of the\r\n``generalized'' coefficient functions\r\n$\\widetilde{\\mathcal{C}}_i^{(k)}(t_R,t_F)$. In fact:\r\n\\begin{equation}\r\n  \\begin{array}{rcl}\r\n    F(0,0)/x &=&\\bigg\\{ \\widetilde{C}_j^{(0)} \\\\ \\\\\r\n             &+&\\displaystyle a_s(t_R)\\left[\\widetilde{C}_j^{(1)}- t_F\r\n                 \\widetilde{C}_i^{(0)} \\otimes P_{ij}^{(0)}\\right]\\\\ \\\\\r\n             &+&\\displaystyle a_s^2(t_R)\\bigg[\\widetilde{C}_j^{(2)} + t_R\\beta_0\r\n                 \\widetilde{C}_j^{(1)} -t_F \\left(\\widetilde{C}_i^{(0)} \\otimes\r\n                 P_{ij}^{(1)}+\\widetilde{C}_i^{(1)} \\otimes P_{ij}^{(0)}\\right)\\\\ \\\\\r\n             &+&\\displaystyle \\frac{t_F^2}2 \\widetilde{C}_i^{(0)} \\otimes \\left(\r\n                 P_{il}^{(0)}\\otimes P_{lj}^{(0)} + \\beta_0 P_{ij}^{(0)} \\right)-\r\n                 t_Ft_R\\beta_{0}\\widetilde{C}_i^{(0)} \\otimes\r\n                 P_{ij}^{(0)}\\bigg]\\bigg\\}\\otimes f_j(t_F)+\\mathcal{O}(a_s^3)\\,.\r\n\\end{array}\r\n\\end{equation}\r\nFinally, using the identity in eq.~(\\ref{invariance}), it is easy to\r\nfind that:\r\n\\begin{equation}\\label{generalizedCF}\r\n\\begin{array}{rcl}\r\n  \\displaystyle\r\n  \\widetilde{\\mathcal{C}}_j^{(0)}(t_R,t_F) &=& \\displaystyle\r\n                                               \\widetilde{C}_j^{(0)} \\\\ \\\\ \\displaystyle\r\n  \\widetilde{\\mathcal{C}}_j^{(1)}(t_R,t_F) &=& \\displaystyle\r\n                                               \\widetilde{C}_j^{(1)}-t_F \\widetilde{C}_i^{(0)} \\otimes P_{ij}^{(0)}\r\n  \\\\ \\\\ \\displaystyle \\widetilde{\\mathcal{C}}_j^{(2)}(t_R,t_F) &=&\r\n                                                                   \\displaystyle \\widetilde{C}_j^{(2)} + t_R\\beta_0 \\widetilde{C}_j^{(1)}\r\n                                                                   -t_F \\left(\\widetilde{C}_i^{(0)} \\otimes\r\n                                                                   P_{ij}^{(1)}+\\widetilde{C}_i^{(1)} \\otimes P_{ij}^{(0)}\\right)\\\\ \\\\\r\n                                           &+&\\displaystyle\\frac{t_F^2}2 \\widetilde{C}_i^{(0)} \\otimes \\left(\r\n                                               P_{il}^{(0)}\\otimes P_{lj}^{(0)} + \\beta_0 P_{ij}^{(0)} \\right)-\r\n                                               t_Ft_R\\beta_{0}\\widetilde{C}_i^{(0)} \\otimes P_{ij}^{(0)}\\,.\r\n\\end{array}\r\n\\end{equation}\r\nTherefore, in the ZM-VFNS, in order to perform scale variation we need\r\nto precompute the additional convolutions:\r\n$\\widetilde{C}_i^{(0)} \\otimes P_{ij}^{(0)}$,\r\n$\\widetilde{C}_i^{(0)} \\otimes P_{ij}^{(1)}$,\r\n$\\widetilde{C}_i^{(1)} \\otimes P_{ij}^{(0)}$ and\r\n$\\widetilde{C}_i^{(0)} \\otimes P_{il}^{(0)} \\otimes P_{lj}^{(0)}$.\r\n\r\nIn order to proceed, it is opportune to specify the basis in which\r\nPDFs are expressed. As usual, the most natural choice is the QCD\r\nevolution basis\r\n$\\{\\Sigma,g,V,V_{3},V_{8},V_{15},V_{24},V_{35},T_{3},T_{8},V_{15},T_{24},T_{35}\\}$\r\nand thus the indices $i$, $j$ and $l$ in eq.~(\\ref{generalizedCF}) run\r\nbetween 1 and 13 over this basis. The advantage of this basis is the\r\nfact that the splitting function matrix $P_{ij}$ is almost completely\r\ndiagonalized. The starting point, is the usual definition that, up to\r\na factor $x$ and omitting the convolution symbol $\\otimes$, can be\r\nwritten as:\r\n\\begin{equation}\\label{StructFuncDef}\r\nF=\\langle e_q^2 \\rangle \\left\\{C_gg +\\sum_{i=u}^{t}\\underbrace{\\theta(Q^2-m_i^2)\\left[C_{\\rm PS}+\\frac{e_i^2}{\\langle e_q^2\r\n      \\rangle}C_+\\right]}_{\\hat{C}_i}q_i^+\\right\\}\\,,\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n\\langle e_q^2 \\rangle = \\sum_{i=u}^t e_i^2\\theta(Q^2-m_i^2)\\,.\r\n\\end{equation}\r\nNow, in order to express the structunre function in\r\neq.~(\\ref{StructFuncDef}) in the evolution basis, we need to find the\r\ntranformation such that:\r\n\\begin{equation}\\label{Rotation}\r\nq_i^+ = \\sum_{j=1}^6T_{ij}f_j\\,,\r\n\\end{equation}\r\nwhere $f_j$ belongs to the evolution basis, that is: $f_1=\\Sigma$,\r\n$f_2=T_3$, $f_3=T_8$ and so on. One can show that the\r\ntrasformation matrix $T_{ij}$ can be written as:\r\n\\begin{equation}\\label{TransDef}\r\n\\begin{array}{l}\r\n\\displaystyle T_{ij}=\\theta(j-i)\\frac{1-\\delta_{ij}j}{j(j-1)}\\quad j\\geq 2\\,,\\\\\r\n\\\\\r\n\\displaystyle T_{i1} = \\frac{1}{6}\\,,\r\n\\end{array}\r\n\\end{equation}\r\nwith $\\theta(j-i)=1$ for $j\\geq i$ and zero otherwise.\r\nIn addition, one can show that:\r\n\\begin{equation}\r\n\\sum_{j=1}^6T_{ij} = 0\\,,\\quad\\mbox{and}\\quad \\sum_{i=1}^6T_{ij} = \\delta_{1j}\\,.\r\n\\end{equation}\r\nNow, we can plug eq.~(\\ref{Rotation}) into eq.~(\\ref{StructFuncDef})\r\nand, using eq.~(\\ref{TransDef}), we get:\r\n\\begin{equation}\\label{StructFuncDefEvol}\r\nF=\\langle e_q^2 \\rangle \\left\\{C_gg +\\frac16\\left(C_++n_f C_{\\rm PS}\\right)\\Sigma+\\sum_{j=2}^{6}\\frac{1}{j(j-1)}\\left[\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j\\right]f_j\\right\\}\\,,\r\n\\end{equation}\r\nwhere we have transmuted the sum over $u$, $d$ and so on into a sum\r\nbetween 1 and 6 and where we have defined:\r\n\\begin{equation}\r\nn_f = \\sum_{i=1}^6\\theta(Q^2-m_i^2)\\,.\r\n\\end{equation}\r\nNow we need to express the term in sqauer brackets in terms of the\r\nusual coefficient functions $C_+$ and $C_{\\rm PS}$, in particular:\r\n\\begin{equation}\r\n\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j = \\sum_{i=1}^j \\theta(Q^2-m_i^2)\\left(C_{\\rm PS}+\\frac{e_i^2}{\\langle e_q^2\r\n      \\rangle}C_+\\right) - j \\theta(Q^2-m_j^2)\\left(C_{\\rm PS}+\\frac{e_j^2}{\\langle e_q^2\r\n      \\rangle}C_+\\right)\\,.\r\n\\end{equation}\r\nHere we can distinguish two case, the first is $Q^2<m_j^2$ and under\r\nthis assumption we have:\r\n\\begin{equation}\r\n\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j = C_++n_fC_{\\rm PS}\\,.\r\n\\end{equation}\r\nIf instead $Q^2 \\geq m_j^2$, then:\r\n\\begin{equation}\r\n\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j = K_j C_+\\,,\r\n\\end{equation}\r\nwith:\r\n\\begin{equation}\r\nK_j=\\frac{1}{\\langle e_q^2\\rangle}\\left(\\sum_{i=1}^{j}e_i^2-je_j^2\\right)=\\frac{1}{\\langle e_q^2\\rangle}\\left(\\sum_{i=1}^{j-1}e_i^2-(j-1)e_j^2\\right)\\,.\r\n\\end{equation}\r\nWe can express both cases in one single formula as:\r\n\\begin{equation}\\label{SumCoef}\r\n\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j = \\theta(m_j^2-Q^2-\\epsilon)\\left[ C_++n_f C_{\\rm PS}\\right]\r\n+\\theta(Q^2-m_j^2)\\left[K_jC_+\\right]\\,.\r\n\\end{equation}\r\nwhere $\\epsilon$ is a small parameter that ensures that the case\r\n$Q^2=m_j^2$ is included in the second term of the r.h.s. of\r\neq.~(\\ref{SumCoef}). Eq.~(\\ref{SumCoef}) can aslo be written as:\r\n\\begin{equation}\\label{SumCoef}\r\n\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j = \\theta(n_f-j)\\left[K_jC_+\\right]+\\theta(j-n_f-1)\\left[ C_++n_f C_{\\rm PS}\\right]\\,.\r\n\\end{equation}\r\nIn addition, one can easily see that:\r\n\\begin{equation}\\label{SingletReduction}\r\nf_j = \\theta(n_f-j)f_j+\\theta(j-n_f-1)\\Sigma\\,,\r\n\\end{equation}\r\nand thus:\r\n\\begin{equation}\r\n\\sum_{j=2}^{6}\\frac{1}{j(j-1)}\\left[\\sum_{i=1}^j\\hat{C}_i-j\\hat{C}_j\\right]f_j\r\n= C_+\\left[\\sum_{j=2}^{nf}\\frac{K_j}{j(j-1)}f_j\\right]+\\left[\\sum_{j=n_f+1}^{6}\\frac{1}{j(j-1)}\\right] \\left[ C_++n_f C_{\\rm PS}\\right]\\Sigma\\,,\r\n\\end{equation}\r\nbut:\r\n\\begin{equation}\r\n\\sum_{j=n_f+1}^{6}\\frac{1}{j(j-1)}=\\frac{1}{n_f}-\\frac{1}{6},.\r\n\\end{equation}\r\nMoreover:\r\n\\begin{equation}\r\n\\frac{K_j}{j(j-1)} = \\frac{1}{\\langle e_q^2\\rangle}\\frac{1}{j(j-1)}\\left(\\sum_{i=1}^je_i^2-je_j^2\\right)=\\frac{1}{\\langle e_q^2\\rangle}\\underbrace{\\frac{1}{j(j-1)}\\sum_{i=1}^6e_i^2\\left[\\theta(j-i)-j\\delta_{ij}\\right]}_{d_j}\\,.\r\n\\end{equation}\r\nFinally, putting all pieces together, we find:\r\n\\begin{equation}\\label{StructureFunctionEvol}\r\nF=\\langle e_q^2 \\rangle \\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]+C_+\\sum_{j=2}^{n_f} d_j f_j\\,.\r\n\\end{equation}\r\nIt is interesting to separate the contributions coming from the\r\ndifferent flavors. To do so, we just need to separate the\r\ncontributions coming from, say the $k$-th charge $e_k^2$ and this is\r\neasily done applying the following replacement:\r\n\\begin{equation}\r\ne_i^2\\rightarrow \\delta_{ik}e_i^2\\,.\r\n\\end{equation}\r\nIn this way we have that:\r\n\\begin{equation}\r\n\\langle e_q^2 \\rangle \\rightarrow \\theta(Q^2-m_k^2) e_k^2\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\r\nd_j \\rightarrow \\frac{e_k^2\\left[\\theta(j-k)-j\\delta_{kj}\\right]}{j(j-1)}=\\theta(Q^2-m_k^2) e_k^2\\frac{\\left[\\theta(j-k)-j\\delta_{kj}\\right]}{j(j-1)}\\,,\r\n\\end{equation}\r\nso that the $k$-th component of the structure function $F$ is:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\nF^{(k)} &=&\\displaystyle  \\theta(Q^2-m_k^2) e_k^2\\left\\{\\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]+C_+\\sum_{j=2}^{n_f}\r\n            \\frac{\\left[\\theta(j-k)-j\\delta_{kj}\\right]}{j(j-1)} f_j\r\n            \\right\\}\\\\\r\n\\\\\r\n&=& \\displaystyle \\theta(Q^2-m_k^2) e_k^2\\left\\{\\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]-\\frac{1}{k}C_+f_k+C_+\\sum_{j=k+1}^{n_f}\r\n            \\frac{1}{j(j-1)} f_j\r\n            \\right\\}\r\n\\end{array}\r\n\\end{equation}\r\nand it is such that:\r\n\\begin{equation}\r\nF = \\sum_{k=1}^6 F^{(k)}\\,.\r\n\\end{equation}\r\n\r\nIn {\\tt APFEL} we split the total structure functions into a light\r\ncomponent and three heavy quark components. The light components is\r\ndefined as:\r\n\\begin{equation}\r\nF^l = \\sum_{k=1}^3 F^{(k)}= \\langle e_l^2 \\rangle \\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]+C_+\\sum_{j=2}^{n_f} d_j^{(l)} f_j\\,.\r\n\\end{equation}\r\nwhere:\r\n\\begin{equation}\r\n\\langle e_l^2\\rangle = \\sum_{i=1}^3e_i^2\\,,\r\n\\end{equation}\r\nand:\r\n\\begin{equation}\r\nd_j^{(l)}=\r\n\\frac{1}{j(j-1)}\\sum_{i=1}^3e_i^2\\left[\\theta(j-i)-j\\delta_{ij}\\right]=\r\n\\left\\{\r\n\\begin{array}{ll}\r\n\\frac{1}{2}(e_u^2-e_d^2)\\,,\\quad& j= 2 \\\\\r\n\\\\\r\n\\frac{1}{6}(e_u^2+e_d^2-2e_s^2)\\,,\\quad& j= 3 \\\\\r\n\\\\\r\n\\frac{\\langle e_l^2\\rangle}{j(j-1)}\\,,\\quad & j\\geq 4\r\n\\end{array}\r\n\\right.\\,,\r\n\\end{equation}\r\nno need of the $\\theta$-functions as the scale $Q$ will always be above\r\nthe strange threshold. This way the explicit form of $F^l$ is:\r\n\\begin{equation}\\label{LightSF}\r\nF^l = \\langle e_l^2 \\rangle \\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]+\\frac{1}{2}(e_u^2-e_d^2)C_+T_3+\\frac{1}{6}(e_u^2+e_d^2-2e_s^2)C_+T_8+\\langle e_l^2 \\rangle C_+\\sum_{j=4}^{n_f} \\frac{1}{j(j-1)} f_j\\,.\r\n\\end{equation}\r\n\r\nThe heavy-quark components are instead defined as:\r\n\\begin{equation}\\label{HeavySF}\r\n\\begin{array}{rcl}\r\nF^c &=& \\displaystyle \\theta(Q^2-m_c^2) e_c^2\\left\\{\\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]-\\frac{1}{4}C_+T_{15}+C_+\\sum_{j=5}^{n_f}\r\n            \\frac{1}{j(j-1)} f_j\r\n            \\right\\}\\,,\\\\\r\n\\\\\r\nF^b &=& \\displaystyle \\theta(Q^2-m_b^2) e_b^2\\left\\{\\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]-\\frac{1}{5}C_+T_{24}+C_+\\sum_{j=6}^{n_f}\r\n            \\frac{1}{j(j-1)} f_j\r\n            \\right\\}\\,,\\\\\r\n\\\\\r\nF^t &=& \\displaystyle \\theta(Q^2-m_t^2) e_t^2\\left\\{\\left[C_g g +\\left(C_{\\rm PS} +\\frac1{n_f}C_+\r\n  \\right) \\Sigma\\right]-\\frac{1}{6}C_+T_{35}\\right\\}\\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nTo conclude the treatment of all the structure functions, we should\r\nadda that eq.~(\\ref{StructureFunctionEvol}) is valid only for $F_2$\r\nand $F_L$. However, $F_3$ can be easily derived following the very\r\nsame steps with the only differences are that: the distributions\r\n$\\{\\Sigma,T_3,T_8,T_{15},T_{24},T_{35}\\}$ must be replaced with\r\n$\\{V,V_3,V_8,V_{15},V_{24},V_{35}\\}$, $C_+$ must be replaced with\r\n$C_-$, the gluon and the pure-singlet coefficient functions are\r\nidentically zero and the squared electric charges replaced with the\r\nappropriate electroweak charges $c_i$. Following this recipe, we find:\r\n\\begin{equation}\\label{StructureFunctionEvolF3}\r\nF_3=\\langle c_q^2 \\rangle \\frac1{n_f}C_- V+C_-\\sum_{j=2}^{n_f} d_j g_j\\,,\r\n\\end{equation}\r\nwhere $g_j$ belongs to $\\{V,V_3,V_8,V_{15},V_{24},V_{35}\\}$.\r\n\r\nEq.~(\\ref{StructureFunctionEvol}), explicitly written in\r\neqs.~(\\ref{LightSF}) and~(\\ref{HeavySF}), is the final result that\r\nallows us to implement the scale variation formulae given in\r\neq.~(\\ref{generalizedCF}) in {\\tt APFEL}. The good aspect of\r\neq.~(\\ref{StructureFunctionEvol}) if the fact that it is written in\r\nterms of the fundamental coefficient functions $C_g$, $C_+$ and\r\n$C_{\\rm PS}$ and PDFs appear in the evolution basis where the\r\nsplitting-function matrix diagonalizes. In particular, up to\r\n$\\mathcal{O}(\\alpha_s^2)$, we have that:\r\n\\begin{equation}\r\n\\begin{array}{ll}\r\n  P_{ij}^{(k)} \\rightarrow P_{ij}^{(k)} &\\quad i,j=g,q(\\Sigma)\\\\\r\n  P_{ij}^{(k)} \\rightarrow \\delta_{ij}P_+^{(k)} &\\quad i,j=T_{3},T_{8},V_{15},T_{24},T_{35}\\\\\r\n  P_{ij}^{(k)} \\rightarrow \\delta_{ij}P_-^{(k)} &\\quad i,j=V,V_{3},V_{8},V_{15},V_{24},V_{35}\r\n\\end{array}\r\n\\end{equation}\r\nAlso, defining:\r\n\\begin{equation}\r\nC_q=C_{\\rm PS} +\\frac{1}{n_f}C_+\\,,\r\n\\end{equation}\r\nwe can connect eq.~(\\ref{ZeroScales}) and\r\neq.~(\\ref{StructureFunctionEvol}) by observing that:\r\n\\begin{equation}\r\n\\begin{array}{ll} \r\n  \\widetilde{C}_j^{(k)} \\rightarrow \\langle e_q^2\\rangle C_j^{(k)}\r\n  &\\quad j=g,q(\\Sigma)\\\\\r\n  \\widetilde{C}_j^{(k)}\r\n  \\rightarrow d_jC_+^{(k)} &\\quad j=T_{3},T_{8},T_{15},T_{24},T_{35}\\\\\r\n  \\widetilde{C}_j^{(k)}\\rightarrow d_jC_-^{(k)} &\\quad j=V_{3},V_{8},V_{15},V_{24},V_{35}\r\n\\end{array}\r\n\\end{equation}\r\nwhere we have also considered the ``minus'' distributions that appear\r\nin the $F_3$ structure function. Of course, the same relations must\r\nhold also for eq.~(\\ref{NonZeroScales}):\r\n\\begin{equation}\r\n\\begin{array}{ll}\r\n  \\widetilde{\\mathcal{C}}_j^{(k)} \\rightarrow\r\n  \\langle e_q^2\\rangle \\mathcal{C}_j^{(k)} &\\quad j=g,q(\\Sigma)\\\\\r\n  \\widetilde{\\mathcal{C}}_j^{(k)} \\rightarrow d_j\\mathcal{C}_+^{(k)}\r\n                         &\\quad j=T_{3},T_{8},T_{15},T_{24},T_{35}\\\\\r\n  \\widetilde{\\mathcal{C}}_j^{(k)} \\rightarrow d_j\\mathcal{C}_-^{(k)}\r\n                         &\\quad j=V_{3},V_{8},V_{15},V_{24},V_{35}\r\n\\end{array}\r\n\\end{equation}\r\nwith\r\n\\begin{equation}\r\n\\mathcal{C}_q=\\mathcal{C}_{\\rm PS} +\\frac{1}{n_f}\\mathcal{C}_+\\,.\r\n\\end{equation}\r\nIn addition, in the following, we will make use of the following identity:\r\n\\begin{equation}\r\n  P_-^{(0)}=P_+^{(0)}=P_{qq}^{(0)}\\,.\r\n\\end{equation}\r\nNow, considering that $C_{\\rm PS}$ starts at\r\n$\\mathcal{O}(\\alpha_s^2)$, we can write:\r\n\\begin{equation}\r\n\\begin{array}{l}\r\n  \\displaystyle C_-^{(0)}(x) = C_+^{(0)}(x) =\r\n  \\Delta_{\\rm SF}\\delta(1-x)\\\\\r\n  \\displaystyle C_j^{(0)}(x) = \\left(\\Delta_{\\rm\r\n  SF}/n_f\\right)\\delta_{qj}\\delta(1-x) \\quad \\mbox{for } j=q,g\r\n\\end{array}\r\n\\end{equation}\r\nwhere $\\Delta_{\\rm SF}=1$ for $F_2$ and $F_3$ and\r\n$\\Delta_{\\rm SF} = 0$ for $F_L$.  From eq.~(\\ref{generalizedCF}) it\r\nfollows that:\r\n\\begin{equation}\\label{NonSingletCF}\r\n\\begin{array}{rcl}\r\n  \\displaystyle \\mathcal{C}_\\pm^{(0)}(t_R,t_F) &=&\r\n                                                   \\displaystyle \\Delta_{\\rm SF}\\delta(1-x) \\\\ \\\\ \\displaystyle\r\n  \\mathcal{C}_\\pm^{(1)}(t_R,t_F) &=& \\displaystyle\r\n                                     C_\\pm^{(1)}-\\Delta_{\\rm SF} t_F P_{qq}^{(0)} \\\\ \\\\ \\displaystyle\r\n  \\mathcal{C}_\\pm^{(2)}(t_R,t_F) &=& \\displaystyle C_\\pm^{(2)} +\r\n                                     t_R\\beta_0 C_\\pm^{(1)} -t_F \\left(\\Delta_{\\rm SF}\r\n                                     P_\\pm^{(1)}+C_\\pm^{(1)} \\otimes P_{qq}^{(0)}\\right)\\\\ \\\\\r\n                                               &+&\\displaystyle\\Delta_{\\rm SF} \\frac{t_F^2}2 \\left(\r\n                                                   P_{qq}^{(0)}\\otimes P_{qq}^{(0)} + \\beta_0 P_{qq}^{(0)} \\right)-\r\n                                                   \\Delta_{\\rm SF} t_Ft_R\\beta_{0}P_{qq}^{(0)}\\,,\r\n\\end{array}\r\n\\end{equation}\r\nthat can be rearranged as:\r\n\\begin{equation}\\label{NonSingletCF1}\r\n\\begin{array}{rcl}\r\n  \\displaystyle \\mathcal{C}_\\pm^{(0)}(t_R,t_F) &=&\r\n                                                   \\displaystyle \\Delta_{\\rm SF}\\delta(1-x) \\\\ \\\\ \\displaystyle\r\n  \\mathcal{C}_\\pm^{(1)}(t_R,t_F) &=& \\displaystyle\r\n                                     C_\\pm^{(1)}-\\Delta_{\\rm SF} t_F P_{qq}^{(0)} \\\\ \\\\ \\displaystyle\r\n  \\mathcal{C}_\\pm^{(2)}(t_R,t_F) &=& \\displaystyle C_\\pm^{(2)} +\r\n                                     t_R\\beta_0 C_\\pm^{(1)} -t_F C_\\pm^{(1)} \\otimes P_{qq}^{(0)}\\\\ \\\\\r\n                                               &+&\\displaystyle\\Delta_{\\rm SF}\\frac{t_F^2}2 \\left(\r\n                                                   P_{qq}^{(0)}\\otimes P_{qq}^{(0)} - \\beta_0 P_{qq}^{(0)} \\right)-\r\n                                                   \\Delta_{\\rm SF} t_F\\left[P_\\pm^{(1)} - (t_F-t_R)\\beta_{0}\r\n                                                   P_{qq}^{(0)}\\right]\\,.\r\n\\end{array}\r\n\\end{equation}\r\nThe term in square brackets in the r.h.s. of the third line\r\ncorresponds to what we would call $\\mathcal{P}_\\pm^{(1)}(t_R,t_F)$,\r\nthat is the NLO splitting function in the presence of scale variations\r\n($\\mu_R\\neq\\mu_F$). This quantity is already evaluated by {\\tt APFEL}\r\nand thus does not need to be recomputed.\r\n\r\nNow, let us consider the singlet sector that, cosidering the fact\r\nthat becomes:\r\n\\begin{equation}\\label{SingletCF}\r\n\\begin{array}{rcl}\r\n  \\displaystyle {\\mathcal{C}}_j^{(0)}(t_R,t_F) &=&\r\n                                                   \\displaystyle \\frac{\\Delta_{\\rm SF}}{n_f}\\delta_{qj}\\delta(1-x) \\\\ \\\\\r\n  \\displaystyle {\\mathcal{C}}_j^{(1)}(t_R,t_F) &=& \\displaystyle\r\n                                                   {C}_j^{(1)}- \\frac{\\Delta_{\\rm SF}}{n_f} t_F P_{qj}^{(0)} \\\\ \\\\ \\displaystyle\r\n  {\\mathcal{C}}_j^{(2)}(t_R,t_F) &=& \\displaystyle {C}_j^{(2)} +\r\n                                     t_R\\beta_0 {C}_j^{(1)} -t_F {C}_i^{(1)} \\otimes P_{ij}^{(0)}\\\\ \\\\\r\n                                               &+&\\displaystyle\\frac{\\Delta_{\\rm SF}}{n_f} \\frac{t_F^2}2 \\left(\r\n                                                   P_{qi}^{(0)}\\otimes P_{ij}^{(0)} - \\beta_0 P_{qj}^{(0)} \\right)-\r\n                                                   \\frac{\\Delta_{\\rm SF}}{n_f} t_F\\widetilde{P}_{qj}^{(1)}\\,.\r\n\\end{array}\r\n\\end{equation}\r\nfor $j=g,q$. Taking into account eq.~(\\ref{NonSingletCF1}) and\r\nconsidering also the fact that $C_{\\rm PS}^{(0)}=C_{\\rm PS}^{(1)}=0$\r\n($i.e.$ $C_{\\rm PS}$ is $\\mathcal{O}(\\alpha_s^2)$), it is easy to see\r\nthat:\r\n\\begin{equation}\\label{PureSingletCF}\r\n\\begin{array}{rcl}\r\n  \\displaystyle {\\mathcal{C}}_{\\rm PS}^{(0)}(t_R,t_F)\r\n  &=& \\displaystyle 0 \\\\ \\\\ \\displaystyle {\\mathcal{C}}_{\\rm\r\n  PS}^{(1)}(t_R,t_F) &=& \\displaystyle 0 \\\\ \\\\ \\displaystyle\r\n  {\\mathcal{C}}_{\\rm PS}^{(2)}(t_R,t_F) &=& \\displaystyle {C}_{\\rm\r\n                                            PS}^{(2)}-t_FC_g^{(1)}\\otimes\r\n  P_{gq}^{(0)}+\\frac{\\Delta_{\\rm SF}}{n_f}\\frac{t_F^2}{2}P_{qg}^{(0)}\\otimes P_{gq}^{(0)}-\\frac{\\Delta_{\\rm SF}}{n_f}t_F\\left[\\widetilde{P}_{qq}^{(1)}-\\widetilde{P}_{+}^{(1)}\\right]\\\\\r\n\\end{array}\r\n\\end{equation}\r\nand also that:\r\n\\begin{equation}\\label{SingletCFg}\r\n\\begin{array}{rcl}\r\n  \\displaystyle {\\mathcal{C}}_g^{(0)}(t_R,t_F) &=&\r\n                                                   \\displaystyle 0 \\\\ \\\\ \\displaystyle {\\mathcal{C}}_g^{(1)}(t_R,t_F) &=&\r\n                                                                                                                          \\displaystyle {C}_g^{(1)}- \\frac{\\Delta_{\\rm SF}}{n_f} t_F P_{qg}^{(0)} \\\\ \\\\\r\n  \\displaystyle {\\mathcal{C}}_g^{(2)}(t_R,t_F) &=& \\displaystyle\r\n                                                   {C}_g^{(2)} + t_R\\beta_0 {C}_g^{(1)} -t_F {C}_i^{(1)} \\otimes\r\n                                                   P_{ig}^{(0)}\\\\ \\\\ &+&\\displaystyle\\frac{\\Delta_{\\rm SF}}{n_f} \\frac{t_F^2}2 \\left(\r\n                                                                         P_{qi}^{(0)}\\otimes P_{ig}^{(0)} - \\beta_0 P_{qg}^{(0)} \\right)-\r\n                                                                         \\frac{\\Delta_{\\rm SF}}{n_f} t_F\\widetilde{P}_{qg}^{(1)}\\,,\r\n\\end{array}\r\n\\end{equation}\r\nwhere the term ${C}_i^{(1)} \\otimes P_{ig}^{(0)}$ in the r.h.s. of the\r\nthird line of eq.~(\\ref{SingletCFg}) should be interpreted as:\r\n\\begin{equation} \r\n  {C}_i^{(1)} \\otimes P_{ig}^{(0)} =\r\n \\frac{1}{n_f}{C}_{+}^{(1)}\\otimes P_{qg}^{(0)} + {C}_g^{(1)} \\otimes\r\n  P_{gg}^{(0)}\\,.\r\n\\end{equation}\r\n\r\nNow we consider the massive scheme. In the neutral-current sector the\r\nleading-order coefficient functions $C_i^{(0)}$ are identically equal\r\nto zero and this simplifies substantially the structure of the massive\r\ncoefficient functions in the presence of scale variations:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n  \\displaystyle \\mathcal{C}_j^{(0)}(t_R,t_F) &=&\r\n                                                 \\displaystyle 0 \\\\ \\\\ \\displaystyle \\mathcal{C}_j^{(1)}(t_R,t_F) &=&\r\n                                                                                                                      \\displaystyle C_j^{(1)} \\\\ \\\\ \\displaystyle\r\n  \\mathcal{C}_j^{(2)}(t_R,t_F) &=& \\displaystyle C_j^{(2)} + t_R\\beta_0\r\n                                   C_j^{(1)} -t_F C_i^{(1)} \\otimes P_{ij}^{(0)}\\,.\r\n\\end{array}\r\n\\end{equation}\r\nIn addition, the factorization scale variation terms are already\r\npresent in the implementation of the massive coefficient functions in\r\n{\\tt APFEL}. As a consequence, only the renormalization variation\r\nterms need to be implemented. This is a great facilitation because the\r\nrenormalization variation terms do not require any further convolution\r\nand thus no additional terms need to be computed during the\r\ninitialization phase.\r\n\r\nAs far as the massive charged-current sector is concerned, no\r\n$\\mathcal{O}(a_s^2)$ are presently available and thus only the first\r\ntwo lines of eq.~(\\ref{generalizedCF}) are actually needed. Also in\r\nthis case the factorization scale variation terms are already present\r\nin the implementation and again this avoids the precomputation of\r\nadditional terms.\r\n\r\nNow let us discuss how to implement in {\\tt APFEL} the additional\r\nterms needed to perform scale variations. The only terms that are a\r\nbit more complicated to implement are those that require a convolution\r\nbetween two splitting functions of between a plitting functions and a\r\ncoefficient functions. More in particular, we only need to compute the\r\nterms: $P_{ij}^{(0)}(x)\\otimes P_{jk}^{(0)}(x)$ and\r\n$C_{i}^{(1)}(x)\\otimes P_{ij}^{(0)}(x)$. In pricinple, these terms\r\ncould be evaluated analitically by computing the explicit convolution\r\nbetween the know expressions that are involved. However, it seems\r\neasier in {\\tt APFEL} to compute these terms numerically using the\r\ningredients that have already been evaluated in the initialization\r\nstage. To show how to reduce these terms to known quantity, let us\r\ncosider the following convolution:\r\n\\begin{equation}\r\n  F(x_\\alpha)=x_\\alpha C(x_\\alpha)\\otimes Q(x_\\alpha) =\r\n  x_\\alpha\\int_{x_\\alpha}^1\\frac{dy}{y}C(y)Q\\left(\\frac{x_\\alpha}{y}\\right)\r\n  =\\int_{x_\\alpha}^1\\frac{dy}{y}yC(y)\\frac{x_\\alpha}{y}Q\\left(\\frac{x_\\alpha}{y}\\right)\r\n  =\r\n  \\int_{x_\\alpha}^1\\frac{dy}{y}\\widetilde{C}(y)\\widetilde{Q}\\left(\\frac{x_\\alpha}{y}\\right)\\,,\r\n\\end{equation}\r\nwhere $x_\\alpha$ is node of the $x$-space grid of {\\tt APFEL} and\r\n$\\widetilde{C}(y)=yC(y)$ and $\\widetilde{Q}(y)=yQ(y)$. Now, using the\r\nwell-known interpolation formula we can write:\r\n\\begin{equation}\r\n  \\int_{x_\\alpha}^1\\frac{dy}{y}\\widetilde{C}(y)\\widetilde{Q}\\left(\\frac{x_\\alpha}{y}\\right)\r\n  =\r\n  \\sum_{\\beta}\\underbrace{\\left[\\int_{x_\\alpha}^1\\frac{dy}{y}\\widetilde{C}(y)w_{\\beta}^{(k)}\\left(\\frac{x_\\alpha}{y}\\right)\\right]}_{\\Gamma_{\\alpha\\beta}}\\widetilde{Q}(x_\\beta)\\,,\r\n\\end{equation}\r\nwhere $w_{\\beta}^{(k)}$ are the usual interpolation functions of\r\ndegree $k$. Now suppose that in turn:\r\n\\begin{equation} \r\n  \\widetilde{Q}(x_\\beta)=x_\\beta P(x_\\beta)\\otimes\r\n  f(x_\\beta) =\r\n  \\int_{x_\\beta}^1\\frac{dz}{z}\\widetilde{P}(z)\\widetilde{f}\\left(\\frac{x_\\beta}{z}\\right)=\\sum_{\\gamma}\\underbrace{\\left[\\int_{x_\\beta}^1\\frac{dz}{z}\\widetilde{P}(z)w_{\\gamma}^{(k)}\\left(\\frac{x_\\beta}{z}\\right)\\right]}_{\\Pi_{\\beta\\gamma}}\\widetilde{f}(x_\\gamma)\\,,\r\n\\end{equation}\r\nit follows that:\r\n\\begin{equation}\r\n  F(x_\\alpha)=\\widetilde{C}(x_\\alpha)\\otimes\r\n  \\widetilde{P}(x_\\alpha)\\otimes \\widetilde{f}(x_\\alpha) =\r\n  \\sum_{\\beta,\\gamma}\r\n  \\Gamma_{\\alpha\\beta}\\Pi_{\\beta\\gamma}\\widetilde{f}(x_\\gamma)\\,.\r\n\\end{equation} \r\nThe formula above clearly shows that the missing pieces can be easily\r\nobtained by properly multimplying the precomputed splitting function\r\nmatrices $\\Pi_{ij,\\alpha\\beta}$ and the coefficient function matrices\r\n$\\Gamma_{i,\\alpha\\beta}$ accordind to the scale variation formulas\r\nderived above.\r\n\r\nAs an alternative to the numerical convolution of the new pieces\r\narising when including renormalization- and factorization-scale\r\nvariations, one can try to compute the analytically the convolutions\r\nabove. In fact, all the terms involved in the new convolutions are\r\nusually simple enough to make the analytic computation possible using,\r\nfor instance, {\\tt Mathematica}. This is advantageous because it\r\navoids any inaccuracy of numerical origin coming from the numerical\r\nconvolution of the operators involved. In order to do so, we only need\r\nto know how to treat some particular term that appear in the\r\ncombinations. In particular, we need to be able to treat terms in\r\nwhich Dirac $\\delta$-functions and $+$-prescripted functions are\r\npresent at the same time. The most trivial convolutions are those\r\ninvolving one or two $\\delta$-functions, that is:\r\n\\begin{equation}\\label{ConvolutionDelta}\r\n\\begin{array}{l}\r\n\\displaystyle \\delta(1-x)\\otimes\\delta(1-x) = \\delta(1-x)\\,,\\\\\r\n\\\\\r\n\\displaystyle \\left(\\frac{\\ln^n(1-x)}{1-x}\\right)_+\\otimes\\delta(1-x)\r\n  = \\left(\\frac{\\ln^n(1-x)}{1-x}\\right)_+\\quad n\\geq0\\,,\r\n\\end{array}\r\n\\end{equation}\r\nthat can be easily proven in Mellin space where the convolution\r\n$\\otimes$ becomes a simple product and the $\\delta$-function\r\ncorresponds to the unity. The Mellin-space method can be used also in\r\nthe cases where two $+$-prescripted functions are involved. Up to\r\n$\\mathcal{O}(\\alpha_s^2)$ there are only two possible combinations,\r\nthat are:\r\n\\begin{equation}\\label{ConvolutionPlus}\r\n\\begin{array}{l}\r\n\\displaystyle \\left(\\frac{1}{1-x}\\right)_+\\otimes\r\n  \\left(\\frac{1}{1-x}\\right)_+= 2\r\n  \\left(\\frac{\\ln(1-x)}{1-x}\\right)_+-\\frac{\\ln(x)}{1-x}-\\zeta(2)\\delta(1-x)\\,,\\\\\r\n\\\\\r\n\\displaystyle \\left(\\frac{1}{1-x}\\right)_+\\otimes\r\n  \\left(\\frac{\\ln(1-x)}{1-x}\\right)_+= \\frac32\\left(\\frac{\\ln^2(1-x)}{1-x}\\right)_+-\\zeta(2) \\left(\\frac{1}{1-x}\\right)_+-\\frac{\\ln(x)\\ln(1-x)}{1-x}+\\zeta(3)\\delta(1-x)\\,.\r\n\\end{array}\r\n\\end{equation}\r\nThe relations in eq.~(\\ref{ConvolutionPlus}) can be obtained\r\nrearranging, in Mellin space, the terms is such a way to reconstruct\r\nthe Mellin-transform of well-known terms.\r\n\r\nNow, given the LO splitting functions (with expansion parameter\r\n$\\alpha_s/4\\pi$ and such that they can be used to evolve the singlet\r\ncombination $\\{q^+,g\\}$):\r\n\\begin{equation}\r\n\\begin{array}{l}\r\n\\displaystyle P_{qq}^{(0)}(x) = 2 C_F \\left[2\r\n  \\left(\\frac{1}{1-x}\\right)_+ - (1 + x) +\\frac{3}{2} \\delta(1 -\r\n  x)\\right]\\,,\\\\\r\n\\\\\r\n\\displaystyle P_{qg}^{(0)}(x) = 4 n_f T_R \\left[x^2 + (1 - x)^2\\right]\\,,\\\\\r\n\\\\\r\n\\displaystyle P_{gq}^{(0)}(x) = 2 C_F \\left[\\frac{1+ (1 -\r\n  x)^2}{x}\\right]\\,,\\\\\r\n\\\\\r\n\\displaystyle P_{gg}^{(0)}(x) = 4 C_A \\left[\\left(\\frac{1}{1-x}\\right)_+\r\n  - 2 + x - x^2 + \\frac{1}{x}\\right] + \\frac{11 C_A - 4 n_f T_R}{3}\r\n  \\delta(1 - x)\\,,\r\n\\end{array}\r\n\\end{equation}\r\nwe can compute the additional terms involving only combinations of\r\nsplitting functions. In particular, we need to compute:\r\n\\begin{equation}\\label{NSP0P0}\r\nP_{qq}^{(0)}(x) \\otimes P_{qq}^{(0)}(x)\\,,\r\n\\end{equation}\r\ninvolved in the $\\mathcal{O}(\\alpha_s^2)$ non-singlet coefficient\r\nfunctions, and:\r\n\\begin{equation}\\label{SGP0P0}\r\n\\begin{array}{l}\r\nP_{qg}^{(0)}(x) \\otimes P_{gq}^{(0)}(x)\\,,\\\\\r\n\\\\\r\n\\displaystyle P_{qi}^{(0)}(x) \\otimes P_{ig}^{(0)}(x)=P_{qq}^{(0)}(x) \\otimes\r\n  P_{qg}^{(0)}(x)+P_{qg}^{(0)}(x) \\otimes P_{gg}^{(0)}(x)\\,.\r\n\\end{array}\r\n\\end{equation}\r\npresent in the pure-singlet and in the gluon coefficient functions,\r\nrespectively.\r\n\r\nThe convolution in eq.~(\\ref{NSP0P0}) can be easily computed by hand\r\nusing eqs.~(\\ref{ConvolutionDelta}) and~(\\ref{ConvolutionPlus}) and\r\nthe result is:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\nP_{qq}^{(0)}(x) \\otimes P_{qq}^{(0)}(x) &=&\\displaystyle 4\r\n                                            C_F^2\\bigg[8\\left(\\frac{\\ln(1-x)}{1-x}\\right)_++6\\left(\\frac{1}{1-x}\\right)_+-4\\frac{\\ln(x)}{1-x}-4(1+x)\\ln(1-x)\\\\\r\n\\\\\r\n&+&\\displaystyle 3(1+x)\\ln(x)-(x+5)+\\left(\\frac{9}{4}-4\\zeta(2)\\right)\\delta(1-x)\\bigg]\\,.\r\n\\end{array}\r\n\\end{equation}\r\nAs for eq.~(\\ref{SGP0P0}), where no convolutions of the kinds given in\r\neqs.~(\\ref{ConvolutionDelta}) and~(\\ref{ConvolutionPlus}) are present,\r\nwe can safely use {\\tt Mathematica}, obtaining:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\nP_{qg}^{(0)}(x) \\otimes P_{gq}^{(0)}(x)&=&\\displaystyle C_F n_f\r\n                                           T_R\\left[\\frac{8}{3} \\left(-4 x^2-3 x+\\frac{4}{x}+3\\right)+16 (x+1) \\ln(x)\\right]\\,,\\\\\r\n\\\\\r\nP_{qi}^{(0)}(x) \\otimes P_{ig}^{(0)}(x)&=&\\displaystyle n_f T_R C_A\r\n                                           \\left[16 \\left(2 x^2-2\r\n                                           x+1\\right) \\ln\r\n                                           (1-x)+16(4 x+1) \\ln\r\n                                           (x)+\\frac{4}{3} \\left(-40\r\n                                           x^2+26 x+17+\\frac{8}{x}\\right)\r\n                                           \\right]\\\\\r\n\\\\\r\n&+&\\displaystyle n_f T_R C_F \\left[16 \\left(2 x^2-2 x+1\\right) \\ln\r\n    (1-x)-8 \\left(4 x^2-2 x+1\\right) \\ln (x)+4\\left(4 x-1\\right)\\right]\\\\\r\n\\\\\r\n&+&\\displaystyle n_f^2 T_R^2 \\left[-\\frac{16}{3} (2 x^2-2 x+1)\\right]\r\n\\end{array}\r\n\\end{equation}\r\n\r\nNow we need to consider the additional terms involving combinations of\r\nsplitting functions and coefficient functions. Let us start\r\nconsidering $F_L$ and it is the easiest case. Here we have:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n\\displaystyle C_{L,\\pm}^{(1)}(x) &=& \\displaystyle 4 C_F x\\,,\\\\\r\n\\\\\r\n\\displaystyle C_{L,q}^{(1)}(x) &=& \\displaystyle  \\frac1{n_f} C_{L,\\pm}^{(1)}(x)\\,,\\\\\r\n\\\\\r\n\\displaystyle C_{L,g}^{(1)}(x) &=& \\displaystyle  4 T_Rx(1-x)\\,,\r\n\\end{array}\r\n\\end{equation}\r\nand for the non-singlet case we need to compute:\r\n\\begin{equation}\r\nC_{L,\\pm}^{(1)}(x)\\otimes P_{qq}^{(0)}(x) = 4C_F^2 \\left[ (x+2)+4 x \\ln (1-x)-2 x \\ln(x)\\right]\\,.\r\n\\end{equation}\r\nFor the pure-singlet and the gluon coefficient functions, instead, we\r\nneed to compute:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\nC_{L,g}^{(1)}(x)\\otimes P_{gq}^{(0)}(x) &=& \\displaystyle C_F T_R \\left[\\frac{32}{3} \\left(2 x^2-3+\\frac{1}{x}\\right)-32 x \\ln (x)\\right]\\,,\\\\\r\n\\\\\r\nC_{L,i}^{(1)}(x)\\otimes P_{ig}^{(0)}(x) &=& \\displaystyle  C_A T_R\r\n                                            \\left[64 x (1-x) \\ln\r\n                                            (1-x)-128 x \\ln\r\n                                            (x)+\\frac{16}{3} \\left(23\r\n                                            x^2-19 x-6 + \\frac{2}{x}\\right)\\right]\\\\\r\n\\\\\r\n&+&\\displaystyle C_F T_R \\left[\\frac{16}{3} x \\ln\r\n                                            (x)-\\frac{8}{3} \\left(2\r\n                                            x^2-x-1\\right)\\right]\\\\\r\n\\\\\r\n&+&\\displaystyle n_fT_R^2\\left[-\\frac{64}{3}x(1-x)\\right]\\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nNow we consider $F_2$, for which we have:\r\n\\begin{equation}\r\n\\begin{array}{rcl}\r\n\\displaystyle C_{2,\\pm}^{(1)}(x) &=& \\displaystyle \r\n                                     2C_F \\bigg[2 \\left(\\frac{\\ln(1-x)}{1-x}\\right)_+-\\frac{3}{2}\\left(\\frac{1}{1-x}\\right)_+\r\n                                     -2\\frac{\\ln\r\n                                     (x)}{1-x}-(x+1) \\left[\\ln (1-x)-\\ln\r\n                                     (x)\\right] \\\\\r\n\\\\\r\n&+&\\displaystyle 2 x+3 - \\left(2 \\zeta(2)+\\frac{9}{2}\\right) \\delta(1-x)\\bigg] \\,,\\\\\r\n\\\\\r\n\\displaystyle C_{2,q}^{(1)}(x) &=& \\displaystyle  \\frac1{n_f} C_{\\pm,2}^{(1)}(x) \\,,\\\\\r\n\\\\\r\n\\displaystyle C_{2,g}^{(1)}(x) &=& \\displaystyle  4 T_R \\left[\\left(x^2+(1-x)^2\\right) [\\ln\r\n                                   (1-x)-\\ln (x)]-8x^2+8 x-1\\right] \\,.\r\n\\end{array}\r\n\\end{equation}\r\nAlso in this case we need to compute $C_{2,\\pm}^{(1)}(x)\\otimes\r\nP_{qq}^{(0)}(x)$ and $C_{2,i}^{(1)}(x)\\otimes P_{ig}^{(0)}(x)$.\r\n\r\n\\section{Implementation of the Semi-Inclusive $e^+e^-$ Annihilation}\r\n\r\nThe implementation of the Semi-Inclusive $e^+e^-$ Annihilation (SIA)\r\nin {\\tt APFEL} is not very complicated. The reason for that is the\r\nfact that SIA is structurally identical to DIS. In fact, we can regard\r\nSIA as the time-like counterpart of DIS and the differences are only\r\nat the level of coefficient functions and splitting functions.\r\nConsidering that {\\tt APFEL} already implement the time-like\r\nevolution~\\cite{Bertone:2015cwa} ($i.e.$ the time-like splitting\r\nfunctions), the only thing to do is implement the respective\r\ncoefficient functions. Presently the coefficient functions for SIA are\r\nknown up to $\\mathcal{O}(\\alpha_s^2)$ (NNLO) in the zero-mass scheme\r\nand they have been computed in Ref.~\\cite{Mitov:2006wy} and the\r\n$x$-space expressions of interest for the implementation in {\\tt\r\n  APFEL} reported in Appendix C.\r\n\r\nThe way in which the SIA expressions are reported is slightly\r\ndifferent from the standard way in which we are used to see the DIS\r\nexpressions. We would like to reduce the SIA expressions to the same\r\nform of DIS in such a way to use the DIS module of {\\tt APFEL} also\r\nfor the SIA cross sections. In particular the SIA cross section is\r\nRef.~\\cite{Mitov:2006wy} expressed in terms of the three structure\r\nfunctions: $F_T$, $F_L$ and $F_A$. However, comparing the SIA cross\r\nsection with the DIS cross sections it is easy to realize that\r\ndefining:\r\n\\begin{equation}\\label{SIAtoDIS}\r\n\\begin{array}{l} F_2(x,Q) = F_T(x,Q) + F_L(x,Q)\\,,\\\\ F_L(x,Q) =\r\nF_L(x,Q)\\,,\\\\ F_A(x,Q) = xF_3(x,Q)\\,,\r\n\\end{array}\r\n\\end{equation} the SIA cross section reduces to the same structure of\r\nthe DIS cross section.\r\n\r\nAssuming that:\r\n\\begin{equation}\r\n  F_k(x,Q) = \\sum_{j=q,g} x\\int_x^1\\frac{dy}{y}\r\n  c_{k,j}(\\alpha_s(Q),x)\\mathcal{D}_j\\left(\\frac{x}{y},Q\\right)\\,,\\quad\\mbox{with}\\quad\r\n  k = 2,L,3\\,,\r\n\\end{equation} \r\n(note that, to uniform the notation, we understood the factor $x$ in\r\nfront of $F_3$) where $\\mathcal{D}_j$ is the fragmentation function of\r\nthe flavour $j$ and where the coefficient functions $c_{k,j}$ allow\r\nfor the perturbative expansion:\r\n\\begin{equation}\r\n  c_{k,j}(\\alpha_s(Q),x) = \\sum_{n=0}^N \\alpha_s^n(Q)\r\n  c_{k,j}^{(n)}(x)\\,,\r\n\\end{equation}\r\nwe have that the leading-order cofficient functions are trivially:\r\n\\begin{equation}\r\n\\begin{array}{l}\r\n  c_{k,g}^{(0)}(x) = 0 \\,,\\quad k = 2,L,3\\,,\\\\ \\\\\r\n  c_{L,q}^{(0)}(x) = 0\\,, \\\\ \\\\ c_{2,q}^{(0)}(x) = c_{3,q}^{(0)}(x) =\r\n  \\delta(1-x)\\,.\r\n\\end{array}\r\n\\end{equation}\r\n\r\nNow we consider the NLO coefficient functions. Their explicit\r\nexpressions are give in eqs.~(C.13)-(C.17) of Ref.~\\cite{Mitov:2006wy}\r\nbut, in order to write them in a form suitable for the implementation\r\nin {\\tt APFEL}, we need to isolate the regular, soft-divergent and\r\nlocal terms and finally combine them according to\r\neq.~(\\ref{SIAtoDIS}).\r\n\r\n\\begin{equation}\r\n\\begin{array}{lcl}\r\n  \\displaystyle c_{L,q}^{(1)}(x) = 2C_F & &\\\\ \\\\\r\n  \\displaystyle c_{L,g}^{(1)}(x) = 2C_F\\frac{4(1-x)}{x} & &\\\\ \\\\\r\n  \\displaystyle c_{2,q}^{(1)}(x) = c_{T,q}^{(1)}(x) + c_{L,q}^{(1)}(x)\r\n                                        &=& \\displaystyle\r\n                                            2C_F\\bigg[2\\left(\\frac{\\ln(1-x)}{1-x}\\right)_+-\\frac{3}{2}\\left(\\frac{1}{1-x}\\right)_+\r\n                                            - (1+x)\\ln(1-x)\\\\ \\\\ & &\\displaystyle +2\\frac{1+x^2}{1-x}\\ln x\r\n                                                                     +\\frac{5}{2} -\\frac{3}{2} x\r\n                                                                     +\\left(4\\zeta_2-\\frac{9}{2}\\right)\\delta(1-x)\\bigg]\\\\ \\\\ \\displaystyle\r\n  c_{2,g}^{(1)}(x) = c_{T,g}^{(1)}(x) + c_{L,g}^{(1)}(x) &=&\r\n                                                             \\displaystyle 4C_F\\frac{1+(1-x)^2}{x} \\ln[x^2(1-x)]\\\\ \\\\ \\displaystyle\r\n  c_{3,q}^{(1)}(x) &=& \\displaystyle\r\n                       2C_F\\bigg[2\\left(\\frac{\\ln(1-x)}{1-x}\\right)_+-\\frac{3}{2}\\left(\\frac{1}{1-x}\\right)_+\r\n                       - (1+x)\\ln(1-x)\\\\ \\\\ & &\\displaystyle +2\\frac{1+x^2}{1-x}\\ln x\r\n                                                +\\frac{1}{2} -\\frac{1}{2} x\r\n                                                +\\left(4\\zeta_2-\\frac{9}{2}\\right)\\delta(1-x)\\bigg]\\\\ \\\\ \\displaystyle\r\n  c_{3,g}^{(1)}(x) = 0\r\n\\end{array}\r\n\\end{equation}\r\n\r\nIt is interesting to notice that, as expected, the soft-singular part\r\nof the quark coefficient functions is exactly the same as in DIS and\r\nthis allows us to reuse part of the DIS coefficient functions.\r\n\r\n\\section{Polarized DIS cross section and structure functions}\r\n\r\nLet us consider the differential cross sections for unpolarized and\r\npolarized Deep-Inelastic Scattering (DIS) (see {\\it e.g.} Eq.~(19.16) of\r\nSec.~19 in Ref.~\\cite{Agashe:2014kda}):\r\n\\begin{equation}\r\n\\begin{array}{lcl}\r\n\\displaystyle \\frac{d^2\\sigma^i}{dxdy}\r\n& = &\r\n\\displaystyle \\frac{2\\pi\\alpha^2}{xyQ^2}\\eta^i\r\n\\left[\r\n+Y_+ F_2^i \\mp Y_- x F_3^i - y^2 F_L^i\r\n\\right]\r\n\\\\ \\\\\r\n\\displaystyle \\frac{d^2\\Delta\\sigma^i}{dxdy}\r\n& = &\r\n\\displaystyle \\frac{2\\pi\\alpha^2}{xyQ^2}\\eta^i\r\n\\left[\r\n-Y_+ g_4^i \\mp Y_- 2x g_1^i + y^2 g_L^i\r\n\\right]\r\n\\mbox{\\,,}\r\n\\end{array}\r\n\\end{equation}\r\nwhere $i={\\rm NC, CC}$, $Y_{\\pm}=1 \\pm (1-y)^2$, $\\eta^{\\rm NC}=1$,\r\n$\\eta^{\\rm CC}=(1\\pm \\lambda)^2\\eta_W$ (with $\\lambda=\\pm 1$ is the \r\nhelicity of the incoming lepton and $\\eta_W=\\frac{1}{2}\r\n\\left(\\frac{G_FM_W}{4\\pi\\alpha}\\frac{Q^2}{Q^2+M_W^2} \\right)^2$), and \r\n\\begin{equation}\r\n\\begin{array}{lcl}\r\n\\displaystyle F_L^i & = & \\displaystyle F_2^i - 2xF_1^i\\\\ \\\\\r\n\\displaystyle F_L^i & = & \\displaystyle g_4^i - 2xg_5^i\r\n\\mbox{\\,.}\r\n\\end{array}\r\n\\end{equation}\r\nBecause the same tensor structure occurs in the spin-dependent and \r\nspin-independent parts of the DIS hadronic tensor (in the limit $M^2/Q^2\\to 0$),\r\nthe polarized cross section can be obtained from the unpolarized cross section\r\nwith the following replacement\r\n\\begin{equation}\r\n\\displaystyle F_2^i \\rightarrow -2g_4^i\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \r\n\\displaystyle F_3^i \\rightarrow +4g_1^i\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\\r\n\\displaystyle F_L^i \\rightarrow -2g_L^i \r\n\\mbox{\\,.}\r\n\\end{equation}\r\nNote that the extra factor two is due to the fact that the total cross section \r\nis an average over initial-state polarizations.\r\n\r\nThe {\\it polarized} structure functions $g_4$, $g_1$ and $g_L$ \r\nare expressed as a convolution of coefficient functions, $\\Delta c_{k,j}$,\r\nand polarized PDFs, $\\Delta f_j$, (summed over all flavors $j$)\r\n\\begin{equation}\r\ng_k(x,Q) \r\n=\r\n\\sum_{j=q,g}x \\int_x^1 \\frac{dy}{y} \\Delta c_{k,j}(\\alpha_s(Q),x)\r\n\\Delta f_j\\left(\\frac{x}{y},Q\\right)\r\n\\mbox{\\,,}\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\\r\n{\\rm with} \r\n\\ \\ k=4,1,L\r\n\\mbox{\\,.}\r\n\\end{equation} \r\nThe coefficient functions $\\Delta c_{k,j}$ allow for the usual perturbative\r\nexpansion\r\n\\begin{equation}\r\n\\Delta c_{k,j}(\\alpha_s(Q),x) \r\n=\r\n\\sum_{n=0}^N\\alpha_s^n(Q)\\Delta c_{k,j}^{(n)}(x)\r\n\\,\\mbox{,}\r\n\\end{equation}\r\nwhere the coefficients $\\Delta c_{k,j}^{(n)}(x)$ are known up to NLO,\r\n{\\it i.e.} $n=1$ (see {\\it e.g.}~\\cite{deFlorian:2012wk} and references \r\ntherein). At LO they are \r\n\\begin{equation}\r\n\\begin{array}{lcl}\r\n\\Delta c_{4,q}^{(0)}(x) = \\Delta c_{1,q}^{(0)}(x) &=& \\delta(1-x)\r\n\\\\ \\\\\r\n\\Delta c_{L,q}^{(0)}(x) &=& 0\r\n\\,\\mbox{,}\r\n\\\\ \\\\\r\n\\Delta c_{k,g}^{(0)}(x) &=& 0\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\\r\n{\\rm with} \\ k=4,1,L\r\n\\,\\mbox{.}\r\n\\end{array}\r\n\\end{equation}\r\nAt NLO they read \r\n\\begin{equation}\r\n\\begin{array}{lcl}\r\n  %C4q\r\n  \\displaystyle \\Delta c_{4,q}^{(1)}(x) \r\n  &=& \r\n  \\displaystyle 2C_F\\,\r\n  \\bigg\\{\r\n  2\\left[\\frac{\\ln(1-x)}{1-x}\\right]_+ \r\n  - \\frac{3}{2}\\left[\\frac{1}{1-x}\\right]_+\r\n  - (1+x)\\ln(1-x)\r\n  \\\\ \\\\ \r\n  & &\\displaystyle - \\frac{1+x^2}{1-x}\\ln x\r\n  + 3 + 2x\r\n  -\\left(\\frac{9}{2} + 2\\zeta_2\\right)\\delta(1-x)\\bigg\\}\r\n  \\,\\mbox{,}\r\n  \\\\ \\\\ \r\n  %C4g\r\n  \\displaystyle \\Delta c_{4,g}^{(1)}(x) \r\n  &=& \r\n  0\r\n  \\,\\mbox{,} \r\n  \\\\ \\\\\r\n  %C1q\r\n  \\displaystyle \\Delta c_{1,q}^{(1)}(x) \r\n  &=& \r\n  \\displaystyle 2C_F\\,\r\n  \\bigg\\{\r\n  2\\left[\\frac{\\ln(1-x)}{1-x}\\right]_+ \r\n  - \\frac{3}{2}\\left[\\frac{1}{1-x}\\right]_+\r\n  - (1+x)\\ln(1-x)\r\n  \\\\ \\\\ \r\n  & &\\displaystyle - \\frac{1+x^2}{1-x}\\ln x\r\n  + 2 + x\r\n  -\\left(\\frac{9}{2} + 2\\zeta_2\\right)\\delta(1-x)\\bigg\\}\r\n  \\,\\mbox{,}\r\n  \\\\ \\\\ \r\n  %C1g\r\n  \\displaystyle \\Delta c_{1,g}^{(1)}(x) \r\n  &=&\r\n  \\displaystyle 4T_R\r\n  \\bigg\\{(2x - 1)\\ln \\frac{1-x}{x} - 4x +3 \\bigg\\} \r\n  \\,\\mbox{,}\r\n  \\\\ \\\\ \r\n  %CLq\r\n  \\displaystyle \\Delta c_{L,q}^{(1)}(x) \r\n  &=& \r\n  2C_F\\, 2x \r\n  \\,\\mbox{,}\r\n  \\\\ \\\\\r\n  %CLg\r\n  \\displaystyle \\Delta c_{L,g}^{(1)}(x) \r\n  &=& \r\n  0 \r\n  \\,\\mbox{.}\r\n\\end{array}\r\n\\end{equation}\r\n\r\nIn the NC case the couplings can be written as:\r\n\\begin{equation}\r\n\\begin{array}{l}\r\n\\displaystyle B_q(Q^2) = -e_qA_q(V_e\\pm \\lambda A_e)P_Z+V_qA_q(V_e^2+A_e^2\\pm2\\lambda V_eA_e)P_Z^2 \\,\\mbox{,}\\\\\r\n\\\\\r\n\\displaystyle D_q(Q^2) = \\pm\\frac12 \\lambda e_q^2 - e_qV_q(A_e\\pm\\lambda V_e)P_Z +\\frac12(V_q^2+A_q^2)\\left[2V_eA_e\\pm\\lambda (V_e^2+A_e^2)\\right]P_Z^2\\,\\mbox{.}\r\n\\end{array}\r\n\\end{equation}\r\nwhere $\\lambda$ corresponds to the polarization of the incoming\r\nlepton. It should be stressed that $B_q$ multiplies $g_4$ and $g_L$\r\nwhile $D_q$ multiplies $g_1$.\r\n\r\n\\section{The $\\chi$ Prescription in FONLL}\r\n\r\nAs is well known, the original formulation of the FONLL matched scheme\r\ngives rise to discontinuities in correspondence of the heavy quark\r\nthresholds arising from uncontrolled subleading terms. Such subleading\r\nterms can however be numerically important especially arond the charm\r\nthreshold where the numerical value of the strong coupling $\\alpha_s$\r\nis large. In order to remedy this unwanted feature different\r\nprescriptions have been introduced and traditionally the FONLL schem\r\nDIS has been implemented using the so-called damping factor which\r\ndirectly suppresses the unwanted subleading terms by means of a\r\nfunction that goes smoothly to zero at the threshold and below and\r\ntends to one for energies much larger than the threshold itself.\r\n\r\nAs an alternative to the damping factor, one can damp the subleading\r\nterms close to the threshold by mimicing in the subtraction terms the\r\nphase-space suppression given by the presence of one or more heavy\r\nquarks in the final state. This is easily done juct by introducing the\r\nso-called slow-rescaling variable $\\chi$, that in the NC case is:\r\n\\begin{equation}\r\n\\chi=x\\left(1+\\frac{4m_H^2}{Q^2}\\right)=\\frac{x}{\\eta}\\,,\r\n\\end{equation}\r\n$m_H$ being the mass of the heavy quark, in the convolution between\r\ncoefficient functions and PDFs in the zero-mass and in the\r\nmassless-limit bits of the FONLL structure function. In other words,\r\nthe usual zero-mass Mellin convolution becomes:\r\n\\begin{equation}\r\nx\\int_x^1\\frac{dy}{y}C\\left(\\frac{x}{y}\\right)f(y)\\rightarrow x\\int_\\chi^1\\frac{dy}{y}C\\left(\\frac{\\chi}{y}\\right)f(y)=x\\int_\\chi^1\\frac{dy}{y}C(y)f\\left(\\frac{\\chi}{y}\\right)\\,.\r\n\\end{equation}\r\nThe question is how to treat the new integral on a discreet $x$-space\r\ngrid. What we have done so far for the massive integarls like that in\r\nthe r.h.s. of the equation above is re-express it in terms of the\r\nphysical Bjorken $x$ as:\r\n\\begin{equation}\r\nx\\int_\\chi^1\\frac{dy}{y}C(y)f\\left(\\frac{\\chi}{y}\\right)\r\n\\end{equation}\r\n\r\n\r\n\\newpage\r\n\r\n\\begin{thebibliography}{alp}\r\n\r\n%\\cite{Alekhin:2003ev}\r\n\\bibitem{Alekhin:2003ev}\r\n  S.~I.~Alekhin and J.~Blumlein,\r\n  %``Mellin representation for the heavy flavor contributions to deep inelastic structure functions,''\r\n  Phys.\\ Lett.\\ B {\\bf 594} (2004) 299\r\n  [hep-ph/0404034].\r\n  %%CITATION = HEP-PH/0404034;%%\r\n  %63 citations counted in INSPIRE as of 12 Feb 2015\r\n\r\n%\\cite{Laenen:1992xs}\r\n\\bibitem{Laenen:1992xs}\r\n  E.~Laenen, S.~Riemersma, J.~Smith and W.~L.~van Neerven,\r\n  %``O(alpha-s) corrections to heavy flavor inclusive distributions in electroproduction,''\r\n  Nucl.\\ Phys.\\ B {\\bf 392} (1993) 229.\r\n  %%CITATION = NUPHA,B392,229;%%\r\n  %154 citations counted in INSPIRE as of 12 Feb 2015\r\n\r\n%\\cite{Forte:2010ta}\r\n\\bibitem{Forte:2010ta}\r\n  S.~Forte, E.~Laenen, P.~Nason and J.~Rojo,\r\n  %``Heavy quarks in deep-inelastic scattering,''\r\n  Nucl.\\ Phys.\\ B {\\bf 834} (2010) 116\r\n  [arXiv:1001.2312 [hep-ph]].\r\n  %%CITATION = ARXIV:1001.2312;%%\r\n  %98 citations counted in INSPIRE as of 12 Feb 2015\r\n\r\n%\\cite{Buza:1995ie}\r\n\\bibitem{Buza:1995ie}\r\n  M.~Buza, Y.~Matiounine, J.~Smith, R.~Migneron and W.~L.~van Neerven,\r\n  %``Heavy quark coefficient functions at asymptotic values Q**2 >> m**2,''\r\n  Nucl.\\ Phys.\\ B {\\bf 472} (1996) 611\r\n  [hep-ph/9601302].\r\n  %%CITATION = HEP-PH/9601302;%%\r\n  %164 citations counted in INSPIRE as of 12 Feb 2015\r\n\r\n%\\cite{Gluck:1996ve}\r\n\\bibitem{Gluck:1996ve}\r\n  M.~Gluck, S.~Kretzer and E.~Reya,\r\n  %``The Strange sea density and charm production in deep inelastic charged current processes,''\r\n  Phys.\\ Lett.\\ B {\\bf 380} (1996) 171\r\n   [Erratum-ibid.\\ B {\\bf 405} (1997) 391]\r\n  [hep-ph/9603304].\r\n  %%CITATION = HEP-PH/9603304;%%\r\n  %88 citations counted in INSPIRE as of 12 Feb 2015\r\n\r\n%\\cite{Georgi:1976ve}\r\n\\bibitem{Georgi:1976ve}\r\n  H.~Georgi and H.~D.~Politzer,\r\n  %``Freedom at Moderate Energies: Masses in Color Dynamics,''\r\n  Phys.\\ Rev.\\ D {\\bf 14} (1976) 1829.\r\n  %%CITATION = PHRVA,D14,1829;%%\r\n  %925 citations counted in INSPIRE as of 25 Feb 2015\r\n\r\n%\\cite{Bertone:2015cwa}\r\n\\bibitem{Bertone:2015cwa}\r\n  V.~Bertone, S.~Carrazza and E.~R.~Nocera,\r\n  %``Reference results for time-like evolution up to $\\mathcal{O}(\\alpha_s^3)$,''\r\n  JHEP {\\bf 1503} (2015) 046\r\n  [arXiv:1501.00494 [hep-ph]].\r\n  %%CITATION = ARXIV:1501.00494;%%\r\n  %1 citations counted in INSPIRE as of 16 Mar 2015\r\n\r\n%\\cite{Mitov:2006wy}\r\n\\bibitem{Mitov:2006wy}\r\n  A.~Mitov and S.~O.~Moch,\r\n  %``QCD Corrections to Semi-Inclusive Hadron Production in Electron-Positron Annihilation at Two Loops,''\r\n  Nucl.\\ Phys.\\ B {\\bf 751} (2006) 18\r\n  [hep-ph/0604160].\r\n  %%CITATION = HEP-PH/0604160;%%\r\n  %39 citations counted in INSPIRE as of 16 Mar 2015\r\n\r\n%\\cite{Agashe:2014kda}\r\n\\bibitem{Agashe:2014kda}\r\n  K.~A.~Olive {\\it et al.} [Particle Data Group Collaboration],\r\n  %``Review of Particle Physics,''\r\n  Chin.\\ Phys.\\ C {\\bf 38} (2014) 090001.\r\n  %doi:10.1088/1674-1137/38/9/090001\r\n  %%CITATION = doi:10.1088/1674-1137/38/9/090001;%%\r\n  %2477 citations counted in INSPIRE as of 10 Dec 2015\r\n\r\n%\\cite{deFlorian:2012wk}\r\n\\bibitem{deFlorian:2012wk}\r\n  D.~de Florian and Y.~R.~Habarnau,\r\n  %``Polarized semi-inclusive electroweak structure functions at next-to-leading-order,''\r\n  Eur.\\ Phys.\\ J.\\ C {\\bf 73} (2013) 3,  2356\r\n  %doi:10.1140/epjc/s10052-013-2356-3\r\n  [arXiv:1210.7203 [hep-ph]].\r\n  %%CITATION = doi:10.1140/epjc/s10052-013-2356-3;%%\r\n  %5 citations counted in INSPIRE as of 10 Dec 2015\r\n\r\n\\end{thebibliography}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "e5808b8accc5b5eb6b52a5c21e23c8bdaff5283b", "size": 94790, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/DIS.tex", "max_stars_repo_name": "intrepid42/apfelxx", "max_stars_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/DIS.tex", "max_issues_repo_name": "intrepid42/apfelxx", "max_issues_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/DIS.tex", "max_forks_repo_name": "intrepid42/apfelxx", "max_forks_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3757778842, "max_line_length": 266, "alphanum_fraction": 0.6007912227, "num_tokens": 33524, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.41562913884060065}}
{"text": "\n\n\n\\section{Model Input for Structures}\n\\subsection{Enabling Structures ({\\em param.in})}\nHydraulic stuctures are enabled in \\url{param.in} using the parameter {\\em ihydraulics}. This is a binary\nflag with 1 indicating that structures are to be used and 0 indicating that they will be ignored.\n\n\\subsection{Defining Structures ({\\em hydraulics.in})}\nBelow is an annotated example \\url{hydraulics.in} file. The line numbers are not part of the original file\nand the comments (parts after the \"`!\"') are not required.\n\n\\begin{samepage}\n\\verbatiminput{hydraulics.in}\n\\end{samepage}\n\\subsubsection{Global header (example line 1-2)}\nThe first two lines of \\url{hydraulics.in} include two global parameters, \nthe total number of structures and the nudging factor.\n\nThe gate equations are not enforced exactly. We have found that this specification is not fully stable, particularly when gates\nare abruptly installed or open. Instead we use a relaxation formulation:\n\n$$Q(t+\\frac{\\Delta t}{2})= (1-\\chi) Q(t) + (\\chi) Q_{\\text{s}}(\\eta(t),\\mathbf{u}(t),\\phi(t+1))$$\n\nwhere $Q_s$ is the explicit flow calculation for the structure based on state variables and parameters at time $t$.\n\nIn other words, rather than being set exactly to the gate value, the (coupled) flow boundaries will be nudged a fraction $\\chi$ towards this value. \nThe nudging factor can also be interpreted as a time constant. Using a small value like 0.1 will provide maximum stability, but is too slow\nto respond to tidal fluctuations. \n\n\\subsubsection{Structure geometry}\nAfter the global parameters, the next lines (3-10 in the example) represent the identification and geometry of the structure:\n\\begin{enumerate}\n\\item [Line 3] An index and name for the structure. The indices must be sequential and the maximum length of name is 32 characters\n\\item [Line 4] The number of node pairs in the definition, the upstream reference node and the downstream reference node. All use global node numbers.\n\\item [Line 5-10] For each node pair in the string defining the structure, the member of the pair on the upstream and downstream side. \nThe start and end must be on land boundaries. The concept of a node pair is illustrated by the unprimed and primed nodes in Figure \\ref{fig:structmesh}\n\\end{enumerate}\n\n\\subsubsection{Parameters and coefficients}\n\\label{sec:gate_spec}\nAfter the geometric information are some parameters that are specific to the structure type.\nIn the example, this happens to fall on lines 11-14 although this would be different with different geometry\nor in a \\url{hydraulics.in} with multiple gates.\nThe first of these lines controls this input with the structure type being listed on the first of these lines. \nAll parameters are specified {\\em per unit}. For all structures except the hydraulic tranfer, \nthe number of duplicate units is controlled by the variable {\\em nduplicate}. \n\nMany of the structures have invert elevations among their parameters. The datum for this elevation is the same\nas the datum for the elevation state variable $\\eta$ in the model.\n\n\\paragraph{transfer}\nA transfer is a coupled boundary condition (outflow and inflow). The only parameter is the prescribed flow.\n\\begin{verbatim}\nstruct_type        ! type of structure (transfer)\nnduplicate         ! number of duplicate units\nflow               ! flow in cms\n\\end{verbatim}\n\n\\paragraph{orifice,radial}\n\\begin{verbatim}\nstruct_type        ! type of structure (orifice, radial)\nnduplicate         ! number of duplicate units\nelev width height  ! invert elevation (m), width, height (rectangular)\ncoef op_down op_up ! flow coeficient, operating coefficient down and up\n\\end{verbatim}\n\n\\paragraph{radial\\_rh}\nA {\\em radial\\_rh} gate has a flow coefficient that has both\na constant term and a linear variation in the gate height:\n\\begin{verbatim}\nstruct_type        ! type of structure (radial_rh)\nnduplicate         ! number of duplicate units\nelev width height  ! invert elevation (m), width (m), height (m)\ncoef coef_linear   ! constant, linear height-based parameters of flow coef.\nop_down op_up      ! op coef down/up\n\\end{verbatim}\n\n\\paragraph{weir}\nAn orifice is submerged, rectangular orifice (outflow and inflow). \n\\begin{verbatim}\nstruct_type        ! type of structure (weir)\nnduplicate         ! number of duplicate units\nelev width height  ! invert elevation, width of  a single unit, height\ncoef op_down op_up ! flow coef., operating coefficients down and up\n\\end{verbatim}\n\n\\paragraph{culvert}\nAn culvert is a round culvert\n\\begin{verbatim}\nstruct_type        ! type of structure (culvert)\nnduplicate         ! number of duplicate units\nelev width         ! invert elevation, radius\ncoef op_down op_up ! flow coeficient, operating coeficient down and up\n\\end{verbatim}\n\n\\paragraph{weir\\_culvert}\nThis is a combination of weir and culvert\n\\begin{verbatim}\nstruct_type           ! type of structure (culvert)\nweir_nduplicate       ! number of duplicate weir units\nweir_elev weir_width  ! invert elevation, radius\nweir_coef weir_op_down weir_op_up ! flow, operating coefs for weir\npipe_nduplicate       ! number of duplicate culvert/pipe units\npipe_elev pipe_width              ! invert elevation, radius\npipe_coef pipe_op_down pipe_op_up ! flow, operating coefs for culvert\n\\end{verbatim}\n\n\\subsubsection{Enabling time series control}\n\\label{sec:timeflag}\nThe final line (line 15 in the example) of each structure definition is a flag (1=True, 0=False) indicating whether a time history (\\url{*.th}) file will be used to make many of the parameters time-varying -- effectively replacing the values loaded in \n\\url{hydraulics.in}. Time series control is covered in Section \\ref{sec:timeseries}.\n\n\\subsection{Time Series Files ({\\em *.th})}\n\\label{sec:timeseries}\nIf you set the time series flag for a gate coefficient to 1=True as indicated in \\ref{sec:timeflag}, time series control is\nenabled for the gate. You need to provide an input file named \\url{[gate_name].th} where {\\em [gate\\_name]} \nis identical to the name used in the gate definition.\n\nThe file \\url{[gate_name].th} is a multivariate time history.As with all \\url{*.th} files the first column  is time in elapsed seconds since the start of the run and the other columns are space delimited.\nOne quirk compared to other SCHISM inputs is that the times can be irregular and interpolation \nfor gate variables is based on constant repetition of the previous value, not on linear interpolation. This, we feel, is more typical of the actuator on a gate; some things (like \"`installation\"') are\nalso not meaningful at intermediate values.\n\nThe other parameters that are included depend on the gate type, and the columns for each type are given below. \nMost of the variables are identical to the ones listed in \\url{hydraulics.in} and described in\nSection \\ref{sec:gate_spec}. Howerver, there is one special variable {\\em install} that is always \nlocated in the column immediately after the time column. This variable takes on integer values and must be zero or one. \nSetting the installation to zero removes the structure, restoring the original algorithm.\n \n\\begin{description}\n\\item[transfer] time  install(int) flow    ! Install = \\(0,1\\)\n\\item[culvert,weir] time install(int) nduplicate(int) op\\_down op\\_up elev width\n\\item[orifice,radial,radial\\_rh] time install(int) nduplicate(int) op\\_down op\\_up elev width height\n\\item[weir\\_culvert] time install (int) ndup\\_weir (int) op\\_down\\_weir op\\_up\\_weir elev\\_weir width\\_weir ndup\\_pipe (int) down\\_op\\_pipe up\\_op\\_pipe elev\\_pipe radius\\_pipe\n\\end{description}\n\nBelow is a sample \\url{dcc.th}, corresponding to the radial gate used in the original example \\url{hydraulics.in}:\n\\begin{samepage}\n\\verbatiminput{dcc.th}\n\\end{samepage}\n\n\n", "meta": {"hexsha": "becb49c108ff8fee6edde4ebc909f5ab1c5bb99e", "size": 7725, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/struct_input.tex", "max_stars_repo_name": "water-e/BayDeltaSCHISM", "max_stars_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-15T20:59:16.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-15T20:59:16.000Z", "max_issues_repo_path": "documents/struct_input.tex", "max_issues_repo_name": "water-e/BayDeltaSCHISM", "max_issues_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 17, "max_issues_repo_issues_event_min_datetime": "2018-06-05T16:01:48.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-20T18:52:48.000Z", "max_forks_repo_path": "documents/struct_input.tex", "max_forks_repo_name": "water-e/BayDeltaSCHISM", "max_forks_repo_head_hexsha": "b532b51ef58a6ef3dbb4e74f82008a46db0f7686", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-06-04T16:45:56.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-29T23:01:47.000Z", "avg_line_length": 53.6458333333, "max_line_length": 252, "alphanum_fraction": 0.7673786408, "num_tokens": 1876, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4156291315518877}}
{"text": "\\chapter{Machine Learning Background}\n\\label{chapter:background}\n\nThis chapter is intended to be a gentle introduction to the use of machine learning techniques and neural networks for supervised classification and regression. This is required for two reasons: most researchers are aware of neural networks, as it is a well known topic, but Convolutional Neural Networks are less covered in the teaching literature \\footnote{For example, there is currently only one book for Deep Learning by Goodfellow et al. \\cite{Goodfellow2016deep}}. The topic of Deep Learning is understood by many as just \"more layers\" in a network, without considering the recent advances in the field starting from 2012. Small contributions like the Rectified Linear Unit (ReLU) or the ADAM optimizer, or bigger ones like Dropout and Batch Normalization, have allowed to push the limits of neural networks.\n\nWe aim to fill the gap in that common knowledge, and to provide a self-contained thesis that can be read by specialists that do not know neural networks in detail. We also made the effort to cover in detail many practical issues when training neural networks, such as how to tune hyper-parameters, and the proper machine learning model iteration loop from the point of view of the neural network designer, as well as the best practices when using machine learning models.\n\nWe also summarize my experience training neural networks, as it is a process that contains equal parts of science and art. The artistic part is quite of a problem, as it introduces \"researcher degrees of freedom\" that could skew the results. One must always be aware of this.\n\nTraining a neural network is not an easy task, as it requires a minimum the following steps:\n\n\\begin{description}\n\t\\item[Preprocessing] Training set must be carefully prepared. Input and output data must be normalized, typically to the $[0,1]$ or $[-1, 1]$ ranges, else the network might not converge.\n\tThe initial training set must also be split into at least two sets: Training and Testing. Typically a third Validation set is also included in the split, in order to monitor network performance during training, and to detect overfitting.\n\t\\item[Architectural Design] An appropriate network architecture has to be designed, or reused from previous designs. The learning capacity of a network must match or surpass the capacity required by the task to be learned. A big problem is that the task capacity is usually unknown and is difficult to estimate, which means network designers must use a trial-and-error approach. The learning capacity is related to the number of parameters (weights) in the network, but this relationship is not simple \\footnote{A clear example is the general decreasing trend in the number of parameters in networks for ImageNet classification.}.\n\t\\item[Training] The network must be trained using gradient descent with respect to a loss function. A key parameter controlling the convergence of this algorithm is the learning rate $\\alpha$. If $\\alpha$ is too big, then training might diverge \\footnote{Divergence is signalled by a loss value going to infinity, or becoming NaN (Not a Number).}, while if $\\alpha$ is too small, then convergence may be slow. The optimal value of the learning rate has to be found by experimentation on a validation set.\n\t\\item[Testing] After the network has been trained and the loss indicates convergence, then the network must be tested. Many computational frameworks include the testing step explicitly during training, as it helps to debug issues. The testing step requires a validation set and metrics on this set are reported continuously during training.\n\t\\item[Production Use] After many iterations of neural network development, once performance on various test sets is satisfactory, the network can be used in a production setting to perform predictions as needed.\n\\end{description}\n\n\nIt requires careful preparation of training data, then an appropriate network architecture has to be designed or reused from a previous design. \n\n\\section{Classical Neural Networks}\n\nThe basic unit of a neural network is the neuron, which computes the function:\n\\marginnote{Activation Notation}\n\n\\begin{equation}\n\t\\begin{split}\n\t\tz(\\textbf{x}) &= \\sum_i \\textbf{w}_i \\textbf{x}_i + b = \\textbf{w} \\cdot \\textbf{x} + b  \\\\\n\t\ta(\\textbf{x}) &= g(z(\\textbf{x}))\n\t\t\\label{background:neuron}\t\n\t\\end{split}\n\\end{equation}\n\nWhere $\\textbf{x}$ is a input vector of $n$ elements, $\\textbf{w}$ is a learned weight vector, and $b$ is a scalar bias that completes an affine transformation of the input. $g(x)$ is a scalar activation function, which is intended to introduce non-linear behavior into the network. A neural network with no activation function can just compute a linear combination of its input, and therefore is very limited on what tasks can be learned.\n\n$a(\\textbf{x})$ is called the activation\\footnote{Do not confuse activation and activation function} of a neuron, while $z(\\textbf{x})$ is usually called the pre-activation of a neuron, or just the output value before the activation is applied. This notation will be useful later.\n\n\\marginnote{Multilayer Perceptron} A neural network is then made by \"stacking\" a certain number of \"layers\", where each layer contains a predefined number of neurons. This is also called a Multilayer Perceptron (MLP). \nIt is common to then represent inputs and outputs to each layer as vectors (or tensors), as this allows for explicit vector representation that can be easily accelerated in CPUs and GPUs. As an example, a three layer network would compute:\n\n\\begin{align*}\n\tz_1 &= \\Theta_1 \\cdot \\textbf{x} + B_1\\\\\n\ta_1 &= g(z_1)\\\\\n\tz_2 &= \\Theta_2 \\cdot a_1 + B_2\\\\\n\ta_2 &= g(z_2)\\\\\n\tz_3 &= \\Theta_3 \\cdot a_2 + B_3\\\\\n\ta_3 &= g(z_3)\n\\end{align*}\n\nWhere now the $\\Theta_i = \\{ \\textbf{w}_j \\}_j$ is a matrix that contains the weights (row-wise) for the $i$-th layer, the input $\\textbf{x}$ is a column vector and biases are stored in a row vector $\\textbf{B}_i$. It should be noted that the number of neurons in each layer does not have to be the same, and the number of neurons in the last layer defines the output dimensionality of the network. Note than an alternate notation of $\\Theta$ can include Biases $\\textbf{B}$ as well, which is useful for a more direct implementation.\n\nTraining most machine learning models consists of minimizing a loss function $L$, which changes the model parameters in a way that the predictive performance of the model increases. In a sense, the loss function measures how well the model is doing with the current value of the parameter set. As neural networks usually have a large\\footnote{AlexNet has 60 million trainable parameters (weights), ResNet has 20 million parameters, and VGG-16 has 138 million parameters.} number of parameters (the number of weights), unconstrained optimization algorithms are used to minimize the loss. The most common optimization algorithm is gradient descent.\n\nGradient descent uses the theoretical implications that the gradient of a scalar function points in the direction of maximum increase rate of that function. Then it is intuitive to think the rate of maximum decrease is exactly the opposite direction that of the gradient. Then gradient descent is an iterative algorithm that updates the parameters with the following relation:\n\\vspace*{1em}\n\\begin{equation}\n\t\\Theta_{n+1} = \\Theta_{n} - \\alpha \\nabla L(\\hat{y}, y)\n\t\\label{background:simpleGD}\n\\end{equation}\n\nWhere $\\hat{y} = h_{\\Theta_{n}}(\\textbf{x})$ is the neural network output computed over inputs $\\textbf{x}$ from a given dataset, with parameters $\\Theta_n$, and loss function $L(\\hat{y}, y)$. A key parameter in gradient descent is the \\marginnote{Learning Rate} learning rate $\\alpha$, which controls the \"speed\" at which the network learns. Intuitively the learning rate is a step size, as the gradient only provides a direction on which the parameters can be moved to decrease the loss, but not a magnitude on how much to move. This parameter has to be tuned in a validation set. If the learning rate is larger than necessary, then the loss value could oscillate or diverge. If the learning rate is too small, then convergence will be slow. The proper value of the learning rate will make convergence at an appropriate rate.\n\n\\subsection{Training as Optimization}\n\nTraining any machine learning model is typically formulated as an optimization problem. The most common formulation is the minimization of an objective function. This is typically called the \\textit{loss function}, and it is designed in such a way that the model performance improves when the loss function decreases.\n\nAs previously mentioned, once a ML model is constructed, a loss function must be defined so the model can be trained. Gradient descent \\marginnote{Gradient Descent} is the most common algorithm to train DNNs:\n\\vspace*{1em}\n\\begin{equation}\n\\Theta_{n+1} = \\Theta_{n} - \\alpha \\nabla L(\\hat{y}, y)\n\\label{background:fullGD}\n\\end{equation}\n\nWhere $\\hat{y} = h_{\\Theta_{n}}(\\textbf{x})$ is the neural network output computed over inputs $\\textbf{x}$ from a given dataset, with parameters $\\Theta_n$, and loss function $L(h_{\\Theta_{n}}(\\textbf{x}), y)$. Gradient descent is an iterative algorithm and Eq \\ref{background:fullGD} is executed for a predefined number of steps $n$. The value of the loss function at each step must be monitored as a simple check that the loss function is being minimized and is decreasing after each step.\n\nThe quality of the solutions obtained by gradient descent depends on several factors:\n\n\\begin{description}\n\t\\item[Gradient Quality] Gradients must be of \"high quality\", which typically means that they must have many non-zero values. A related common problem is the vanishing gradient problem, specially in deeper networks, where the function composition nature of a DNN makes the gradients very small, slowing down or preventing training. Low quality gradients have many zero elements that prevent many parameters from converging to their optimal values.\n\t\n\t\\item[Learning Rate] Setting the right value of the learning rate is a key factor to using gradient descent successfully. Typical values of the learning rate are $ \\alpha \\in [0, 1]$, and common starting values are $10^{-1}$ or $10^{-2}$.\n\tIt is important that the learning rate is set to the right value before training, as a larger than necessary learning rate can make the optimization process fail (by overshooting the optimum or making the process unstable), a lower learning rate can converge slowly to the optimum, and the \"right\" learning rate will make the process converge at an appropriate speed.\n\tThe learning rate can also be changed during training, and this is called  Learning Rate Schedule\\marginnote{Learning Rate Schedule}. Common approaches are to decrease the learning rate by a factor after a certain number of iterations, or to decay the learning rate by a factor after each step.\n\t\n\t\\item[Loss Surface] The geometry and smoothness of the loss surface is also key to good training, as it defines the quality of the gradients. The ideal loss function should be convex on the network parameters, but typically this is not the case for outputs produced by DNNs. Non-convexity leads to multiple local optima where gradient descent can become \"stuck\". In practice a non-convex loss function is not a big problem, and many theoretical results show that the local optima in deep neural networks are very similar and close in terms of loss value.\n\\end{description}\n\nGradient descent makes several implicit assumptions: the dataset fits into the computer's RAM, and that computing the loss function for the whole dataset is not an expensive operation. One forward pass of the complete network is required for each data point in the training set, and with complex neural networks and datasets of considerable size, these assumptions do not hold true.\n\n\\marginnote{Gradient Descent Variations} A simple way to overcome this problem is to only use part of the training set at a time during the training process. Assuming that the training set can be split into equal sized and non-intersecting sets, called batches, then we can iterate over batches, compute the loss function for a batch, compute the gradients, and apply one step of gradient descent. This is called Mini-Batch Gradient Descent (MGD):\n\\vspace*{1em}\n\\begin{equation}\n\\Theta_{n+1} = \\Theta_{n} - \\alpha \\nabla L(h_{\\Theta_{n}}(\\textbf{x}_{i:j}), y)\n\\label{background:SGD}\n\\end{equation}\n\nWhere $\\textbf{x}_{i:j}$ denotes that the neural network $h_{\\Theta_{n}}(\\textbf{x})$ and loss function $L$ are only evaluated for inputs $\\textbf{x}_k$ where $k = [i, i + 1, i + 2, \\dots, j]$. Then each batch is made by setting different values if $i$ and $j$, constrained to $i > j$ and $B = j - i$. The hyper-parameter $B$ is denoted the Batch Size \\marginnote{Batch Size}. Typically batches are made by setting $B$ to a given value and using values $i, j = \\{ (0, B), (B, 2B), (2B, 3B), \\dots, (cB, n) \\}$. Note that not all batches have the same size due that $B$ might not divide $|Tr|$ exactly. That means the last batch can be smaller. A variation of MGD is Stochastic Gradient Descent (SGD), where simply $B$ is set to one.\nAfter approximately $\\frac{|Tr|}{B}$ iterations of gradient descent, the learning process will have \"seen\" the whole dataset. This is called an Epoch \\marginnote{Epochs}, and corresponds to one single pass over the complete dataset. Typically training length is controlled by another hyper-parameter, the Number of Epochs $M$.\n\nSetting the value of the Batch Size $B$ is one hyper-parameter that controls the tradeoff between more RAM use during training, or more computation. It must be pointed out that MGD and SGD all introduce noise into the learning process, due to the approximation of the true gradient with the per-batch gradient. Larger values of $B$ use more RAM, but require less number of iterations, and additionally it reduces noise in the gradient approximation. Smaller values of $B$ require less RAM but more iterations and provide a more stable gradient approximation. It is common that $B$ is set such as the training process fills the maximum amount of RAM available\\footnote{While training on a GPU, it is typical that the amount of GPU RAM is the only limitation to set $B$. The same applies while training on CPU but with system RAM.}.\n\nThe exact equations that compute gradients of the loss $\\nabla L$ depend on network architecture. The back-propagation \\cite[1em]{bishop2006pattern} algorithm is commonly referred to as a way to hierarchically compute gradients in multi-layer neural networks. In practice this algorithm is rarely used, as modern neural network frameworks such as TensorFlow and Theano use automatic differentiation \\cite{baydin2017automatic} (AD) to compute gradients of the loss function automatically, making the developer's life much easier, as exotic architectures can be easily experimented.\n\n\\subsection{Loss Functions}\n\nWe now describe the most common loss functions used to train Neural Networks. A loss function is a scalar function $\\mathbb{R}^n \\times \\mathbb{O} \\rightarrow R^{+} \\cup 0$ that gives a score to a set of predictions from a learning algorithm (typically a classifier or a regressor). Set $\\mathbb{O}$ defines the ground truth labels, and in the case of regression it is typically $\\mathbf{R}$, $[0, 1]$ or $[-1, 1]$. For classification then $\\mathbb{O}$ is the set of classes, converted to a numerical form.\n\nThe most basic loss function is the mean squared error (MSE), typically used for regression:\n\n\\begin{equation}\n\tMSE(\\hat{y}, y) = n^{-1} \\sum_{i=0}^{n} (\\hat{y}_i - y_i)^2\n\\end{equation}\n\nThe MSE loss penalizes the predicted values $\\hat{y}$ that diverge from the ground truth values $y$. The error is defined just as the difference between $\\hat{y}$ and $y$, and squaring is done to get a smooth positive value. One problem with the MSE is that due to the square term, large errors are penalized more heavily than smaller ones. This produces a practical problem where using the MSE loss might lead the convergence of the output to a mean of the ground truth values instead of predicting values close to them.\nThis issue could be reduced by using the Mean Absolute Error (MAE), which is just the mean of absolute values of errors:\n\n\\begin{equation}\n    MAE(\\hat{y}, y) = n^{-1} \\sum_{i=0}^{n} |\\hat{y}_i - y_i|\n\\end{equation}\n\nThe MSE is also called the $L_2$ loss, while the MAE is named as $L_1$ loss, both defined as the order of the norm applied to the errors. Note that the MAE/$L_1$ loss is not differentiable at the origin, but generally this is not a big issue. The $L_1$ loss can recover the median of the targets, in contrast to the mean recovered by the $L_2$ loss.\n\nFor classification, the cross-entropy loss function is preferred, as it produces a much smoother loss surface, and it does not have the outlier weighting problems of the MSE. Given a classifier that outputs a probability value $\\hat{y}^c$ for each class $c$, then the categorical cross-entropy loss function is defined as:\n\n\\begin{equation}\n\tCE(\\hat{y}, y) = -\\sum_{i=0}^n \\sum_{c=0}^C y_i^c \\log \\hat{y}_i^c\n\\end{equation}\n\nMinimizing the cross-entropy between ground truth probability distribution and the predicted distribution is the equivalent to minimizing the Kullback-Leibler divergence \\cite{mackay2003information}. For the case of binary classification, then there is a simplification usually called binary cross-entropy:\n\n\\begin{equation}\nBCE(\\hat{y}, y) = -\\sum_{i=0}^n \\left[ y_i  \\log \\hat{y}_i + (1 - y_i) \\log (1 - \\hat{y}_i) \\right]\n\\end{equation}\n\nIn this case $\\hat{y}$ is the probability of the positive class.\n\n\\subsection{Activation Functions}\n\nThere is a large selection of activation functions that can be used. A small summary is shown in Table \\ref{background:activations}. The most common \"classic\" activation functions are the sigmoid and the hyperbolic tangent (TanH). These activation functions dominated the neural networks literature before 2010, as they produce the well known problem of vanishing gradient.\n\nThe vanishing gradient problem \\marginnote{Vanishing Gradient Problem} happens when the gradient of the activation function becomes zero, and this is problematic because the network stops training. Looking at Figure \\ref{background:saturatingActivations}, it can be seen that the activation function \"saturates\" when the input is small or large, making the gradient effectively zero. Stacking multiple layers that use sigmoid or TanH activation functions amplifies this effect and prevent the use of a large number of layers.\n\nFor this reason, sigmoid and TanH are called saturating activation functions \\marginnote{Saturating Activation Functions}. This sparked the development of non-saturating activation functions, and the most well known of such functions is the Rectified Non-Linear Unit (ReLU) \\cite{glorot2011deep}. The ReLu is a very simple function given by:\n\n\\begin{equation}\n    g(x) = \\max(0, x)\n    \\label{background:relu}\n\\end{equation}\n\nThis \\marginnote{Rectified Linear Unit (ReLU)} activation function has constant output of zero for negative input, and a linear output for positive inputs. It should be noted that the ReLU is not differentiable at $x = 0$, as the slope at each side of the origin is different, but this usually poses no practical problem.\n\nUse of the ReLU as activation function is one reason why Deep Learning is possible now. The breakthrough paper by Krizhevsky et al. \\cite[-8em]{krizhevsky2012imagenet} mentions that using the ReLU as an activation function requires 4 times less iterations for GD to converge at the same loss value when compared to a sigmoid activation. There are multiple reports that using ReLU activations leads to loss surfaces that are easier to optimize and are less prone to local minima. One reason for this behavior is that the ReLU makes a network prefer sparse outputs.\n\n\\begin{table}[t]\n\t\\centering\n\t\\begin{tabular}{@{}lll@{}}\n\t\t\\hline\n\t\tName\t\t\t\t\t& Range \t\t\t& Function\\\\\n\t\t\\hline\n\t\tLinear\t\t\t\t\t& $[-\\infty, \\infty]$\t& $g(x) = x$\\\\\n\t\tSigmoid\t\t\t\t\t& $[0, 1]$\t\t\t& $g(x) = (1 + e^{-x})^{-1}$\\\\\n\t\tHyperbolic Tangent\t\t& $[-1, 1]$\t\t\t& $g(x) = (e^{2x} -1)(e^{-2x} + 1)^{-1}$\\\\\n\t\t\\hline\n\t\tReLU\t\t\t\t\t& $[0, \\infty]$\t\t& $g(x) = \\max(0, x)$\\\\\n\t\tSoftPlus\t\t\t\t& $[0, \\infty]$\t\t& $g(x) = \\ln(1 + e^x)$\\\\\n\t\tSoftMax\t\t\t\t\t& $[0, 1]^n$\t\t& $g(\\textbf{x}) = (e^{x_i}) (\\sum_k e^{x_k})^{-1}$\\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Summary of commonly used activation functions.}\n\t\\label{background:activations}\n\\end{table}\n\n\\begin{marginfigure}[-8em]\n\t\\begin{tikzpicture}\n\t \t\\begin{axis}[width = 0.9\\textwidth, xlabel=, ylabel=Activation, ymin = -1.1, ymax = 1.1, legend style={at={(0.5, -0.3)},anchor=north}]\n\t \t\t\\addplot+[mark=none] {1.0 / (1.0 + exp(-x))};\n\t \t\t\\addlegendentry{Sigmoid}\n\t \t\t\\addplot+[mark=none] {tanh(x)};\n\t \t\t\\addlegendentry{TanH}\n\n\t \t\\end{axis}\n\t \\end{tikzpicture}\n\t \\caption{Saturating Activation Functions}\n\t \\label{background:saturatingActivations}\n\\end{marginfigure}\n\nAnother commonly used activation function is the softmax \\cite{bishop2006pattern}, and unlike the previously seen activations, it is not a scalar function. Instead the softmax takes a vector and transforms the input into a discrete probability distribution. This is very useful for multi-class classification, as a neural network can then output a probability distribution over class labels in $[0, 1, 2, \\cdots, C]$. Then recovering the discrete class can be performed as taking the class with maximum probability. The vector definition of the softmax activation function is:\n\n\\begin{equation}\n\tg(\\textbf{x}) = \\left[ \\frac{e^{x_i}}{\\sum_j e^{x_j} } \\right]_i\n\t\\label{background:softmax}\n\\end{equation}\n\nGiven a softmax output $\\textbf{a}$, the class decision can be obtained by:\n\\vspace*{1em}\n\\begin{equation}\n\tc = \\argmax_i a_i\n\\end{equation}\n\n\\begin{marginfigure}\n    \\begin{tikzpicture}\n    \\begin{axis}[width = 0.9\\textwidth, xlabel=, ylabel=Activation, ymin = -0.1, ymax = 4.0, xmin = -4.0, xmax = 4.0, legend style={at={(0.5, -0.3)},anchor=north}]\n    \\addplot+[mark=none] {max(0, x)};\n    \\addlegendentry{ReLU}\n    \\addplot+[mark=none] {ln(1 + exp(x))};\n    \\addlegendentry{Softplus}\n    \\end{axis}\n    \\end{tikzpicture}\n    \\caption{Non-Saturating Activation Functions}\n    \\label{background:nonSaturatingActivations}\n\\end{marginfigure}\n\nLooking at Equation \\ref{background:softmax} one can see that softmax outputs are then \"tied\" by the normalization value in the denominator. This produces a comparison operatiog between the inputs, and the biggest softmax output will always be located at the largest input relative to the other inputs. Inputs to a softmax  are typically called logits. As the softmax operation is differentiable, its use as an activation function then produces a loss surface that is easier to optimize.\n\nSoftmax combined with a categorical cross-entropy loss function is the base building block to construct DNN classifiers.\n\nAs the ReLU is not differentiable at $x = 0$ and it has constant zero output for negative inputs, this could produce a new kind of problem called \"dying ReLU\", where neurons that use ReLU can stop learning completely if they output negative values. As the activations and gradients become zero, the neuron can \"get stuck\" and not learn anymore. While this problem does not happen very often in practice, it can be prevented by using other kinds of activation functions like the Softplus function, which can be seen as a \"softer\" version of the ReLU that only has a zero gradient as the limit when $x \\rightarrow -\\infty$. Figure \\ref{background:nonSaturatingActivations} shows the Softplus versus the ReLU activation functions. The Softplus function is given by:\n\n\\begin{equation}\n\tg(x) = \\ln(1 + exp(x))\n\\end{equation}\n\nAnother similar activation function is the Exponential Linear Unit:\n\\vspace*{-0.1cm}\n\\begin{equation}\n\tg(x) = \n\t\\begin{cases}\n\t\tx       \t\t\t& \\quad \\text{if } x \\geq 0\\\\\n\t\t\\gamma (e^x - 1) \t& \\quad \\text{if } x < 0\\\\\n\t\\end{cases}\n\\end{equation}\n\nThere is a clear trend in recent literature about the use of learnable activations, where the activation function has a parameter that can be tuned during learning. Examples of this are the PReLU, Leaky ReLU and the MaxOut.\n\nAs a general rule, most deep neural networks use exclusively the ReLU as activation function, and when designing new networks, it should be preferred as it completely avoids the vanishing gradient problem.\n\n\\subsection{Weight Initialization}\n\nSGD gives a way to iteratively improve the weight matrix to reduce some loss function that controls how and what the model is learning. But it does not specify the initial values of the weights. These are typically initialized by setting them to a random value drawn from some probability distribution. Weights cannot be initialized to zero, since this would lead to all neurons producing a zero value, and the network outputting constant zero, producing a failed learning process. Randomizing weights breaks the \"symmetry\" of initializing them to a particular value. If initial weights are too large, it could produce chaotic behavior (exploding gradients) and make the training process fail. There are many distributions that are used to draw initial weights:\n\n\\begin{description}\n\t\\item[Uniform] Draw the weights from a Uniform distribution with a fixed range, parametrized by a scale parameter $s$. Popular values for $s$ are $s \\in [0.1, 0.01, 0.05]$, and a common heuristic is to set $s = n^{-0.5}$, where $n$ is the dimensionality of the input to the layer.\n        \\vspace*{1em}\n\t\t\\begin{equation}\n\t\t\tw \\sim U(-s, s)\n\t\t\\end{equation}\n\t\\item[Gaussian] Draw the weights from a Gaussian distribution with a fixed standard deviation. Popular values are $\\sigma \\in [0.1, 0.01, 0.05]$\n        \\vspace*{1em}\n\t\t\\begin{equation}\n\t\t\tw \\sim N(0, \\sigma)\n\t\t\\end{equation}\n\t\\item[Glorot or Xavier] Named after Xavier Glorot \\cite{glorot2010understanding}. Draw the weights from:\n\t\t\\begin{equation}\n\t\t\tw \\sim U(-s, s) \\qquad s^2 = \\frac{6}{F_{in} + F_{out}}\n\t\t\\end{equation}\n         Where $F_{in}$ is the number of input elements to the neuron, and $F_{out}$ is the number of output elements. This initialization scheme is based on the intuition that variance of the input and output should be approximately equal for a stable behavior at the beginning of training, which implies that initial weights are scaled differently depending on the dimensionality of the inputs and outputs.\n\t\\item[Orthogonal] Draw weights from a random orthogonal matrix, after applying gain scaling \\cite[-6em]{saxe2013exact}. This method is theoretically grounded and guarantees that convergence will be achieved in a number of iterations that is independent of network depth. The weight matrix is generated by first generating a random matrix with elements $w_{ij} \\sim N(0, 1)$, then performing Singular Value Decomposition on $w$, and then picking either the $U$ or $V$ matrices depending on the required output dimensionality. Finally this matrix is scaled by a gain factor $g$ that depends on the activation function, in order to ensure stable learning dynamics.\n\\end{description}\n\nBiases $b$ can also be initialized with the same scheme as weights, but there is no problem if bias are initialized to zero, and some authors prefer this. We have shown a small subset of weight initialization schemes available in the literature, and overall there is no consensus if one is superior to another, and in general it does not matter much which one is chosen, as other learning tools\\footnote{Like Batch Normalization, Dropout, and Non-Saturating Activation Functions.} can be used to provide superior training stability. Before these techniques were known, the neural network designed had to carefully adjust the weight initialization scheme in order for learning to converge to a useful solution.\n\n\\subsection{Data Normalization}\n\nOne key technique that always must be used \\footnote{My experience from answering Stack Overflow questions is that too many people do not normalize their data, making training their networks much more difficult.} is data normalization. As the input and output data typically comes from real sources, it is contaminated by non-ideal behaviors, like different scales for each feature, or simply are in a range that typical neural networks have issues modeling.\n\nThe scale of input features is an important issue as if inputs have different ranges, then the weights associated to those features will be in different scales. Since we usually use fixed learning rates, this leads to the problem that some parts of a neuron learn at different speeds than others, and this issue propagates through the network, making learning harder as the network becomes deeper.\n\nThe scale of outputs poses a different but easier problem. The designer has to make sure that the range of the activation of the output layer matches the range of the desired targets. If these do not match, then learning will be poor or not possible. Matching the ranges will make sure that learning happens smoothly.\n\n\\begin{description}\n\t\\item[Min-Max Normalization] Normalize each component of the input vector by subtracting the minimum value of that component, and divide by the range. This produces values in the $[0, 1]$ range.\n    \n\t\t\\begin{equation}\n\t\t\t\\hat{x} = \\frac{x - \\min_i x_i}{\\max_i x_i - \\min_i x_i}\n\t\t\\end{equation}\n\t\t\n\t\\item[Z-Score Normalization] Subtract the sample mean $\\mu_x$ and divide by the sample standard deviation $\\sigma_x$. This produces values that are approximately in the $[-1, 1]$ range.\n    \n\t\t\\begin{equation}\n\t\t\t\\hat{x} = \\frac{x - \\mu_x}{\\sigma_x}\n\t\t\\end{equation}\n        \\begin{equation}\n            \\mu_x = n^{-1} \\sum x_i \\qquad \\sigma_x = \\sqrt{(n-1)^{-1} \\sum (x_i - \\mu_x)^2}\n        \\end{equation}\n        \n    \\item[Mean Substraction] Typically used to train models that take images as inputs \\cite{krizhevsky2012imagenet}. Images are represented either as tensors $(W, H, C)$ with values in the $[0, 255]$ or $[0, 1]$ range, and they are normalized by computing the mean image over the training set, or the individual per-channel means over the training set, and subtracting this mean from each image, which overall will produce values in the $[-128, 128]$ or $[-0.5, 0.5]$ range.\n\\end{description}\n\n\\subsection{Regularization}\n\nRegularization is a way to control the learning capacity of a machine learning model, by imposing constraints or prior information to bias the model to a preferred configuration. There are many ways to regularize neural networks, and in this section we will describe two modern regularization techniques: Dropout and Batch Normalization.\n\nA common view of regularization from statistical learning theory is that it controls the number of trainable parameters, which is related to overfitting \\cite[-5em]{bishop2006pattern}, but a more recent view \\cite[-2em]{luo2018understanding} is that the number of parameters does not completely explain overfitting and the expected predictive performance at inference time.\n\nDropout \\marginnote{Dropout} is a technique pioneered by Srivastava et al \\cite[1em]{srivastava2014dropout}. The authors of Dropout noticed that when a neural network overfits, the neurons inside it \\textit{co-adapt} or their outputs become correlated. This reduces model efficiency and generalization greatly. They proposed that this co-adaptation can be broken by introducing noise in the activations, and they choose a model that produces a mask $\\mathbf{m}$ of length $n$ where each element is Bernoulli distributed with probability $p$: $m_i \\sim \\text{Bernoulli}(p)$.\n\nThen this mask is multiplied with the activations of a particular layer, which has the effect of \\textit{turning off} some activations of a layer, and letting others pass unchanged. This is called the dropout mechanism. During training the masks at each Dropout layer are randomly sampled at each iteration, meaning that these masks change during training and mask different activations at an output. This breaks any correlations between activations in one layer and the one before it (where the Dropout layer is placed), meaning that more strong features can be learned and co-adaptation of neurons is prevented.\n\nAt inference or test time, Dropout layers do not perform any stochastic dropping of neurons, and instead they just multiply any incoming activation by $p$, which accounts for all activations being present during inference, unlike at training time. This also prevents any kind of stochastic effect during inference. It should also be noted that Dropout can also be used with its stochastic behavior at inference time, which produces very powerful model uncertainty estimates, as it was proven by Gal et al 2015. \\cite{gal2015dropout}.\n\nUsing Dropout layers in a neural network, typically before fully connected ones, has the effect of reducing overfitting and improving generalization significantly.\n\nDropout can also be seen as a way of Bayesian model averaging \\cite{gal2016uncertainty} as when dropping neurons at training time, new architectures with less neurons are produced, which are then averaged at inference time, which is a theoretical explanation of why Dropout works and improves generalization. Note that while the number of effective parameters during training is reduced by Dropout (by a factor of $p$) due to the dropping of activations, during inference/testing the number of parameters does not change, and all parameters are used to make a prediction.\n\nAnother technique that can be used for regularization is Batch Normalization \\cite[1em]{ioffe2015batch}. This technique was not specifically designed to reduce overfitting in neural networks, but to increase convergence speed while training. The authors of Batch Normalization also noticed that it has a powerful regularization effect, and most current deep neural networks are trained with it, as it improves generalization almost \"for free\".\n\nBatch Normalization \\marginnote{Batch Normalization} is based on the concept of internal covariate shift reduction. Given a set of layers, the covariate is the empirical probability distribution of their outputs. Covariate shift is the change of that distribution as training progresses. Internal covariate shift is the covariate shift of the hidden layers of a neural network. The intuition for Batch Normalization is that drastic internal covariate shift is prejudicial for neural network training, as it is more likely to saturate non-linearities, and unstable activation distributions will need more training iterations to converge successfully. Both situations causes slow training convergence.\n\nReducing the internal covariate shift can be achieved by normalizing the activations (before applying a non-linearity). As typical decorrelation methods like PCA or ZCA whitening are too expensive to use during neural network training (specially with high dimensional data), the Batch Normalization authors proposed two simplifications.\n\nThe first is to perform Component-Wise Normalization along the features. Given a vector of activations $\\textbf{x}$, as a middle step for layer output computation, then each component of that vector should be normalized independently, by using a simple mean and standard deviation normalization: \n\\vspace*{1em}\n\\begin{equation}\n    \\mu_{B} = |B|^{-1} \\sum x_i \\qquad \\sigma^2_{B} = |B|^{-1} \\sum (x_i - \\bar{x})\n\\end{equation}\n\nThe normalization happens along the features dimension of the a mini-batch of activations. This allow for an efficient implementation using SGD. Normalizing a mini-batch $\\textbf{x} \\in B$ of size $|B|$ is performed as:\n\\vspace*{1em}\n\\begin{equation}\n    \\hat{x}_i = \\frac{x_i - \\mu_{B}}{\\sqrt{\\sigma^2_{B} + \\epsilon}}\n\\end{equation}\n\nWhere $\\epsilon = 0.001$ is a small constant to prevent division by zero. Normalizing activations has the unintended effect of destroying the representation capability of the network, but it can be easily restored with a linear transformation:\n\\vspace*{1em}\n\\begin{equation}\n    y_i = \\gamma_i \\hat{x}_i + \\beta_i\n\\end{equation}\n\nWhere $\\gamma_i$ and $\\beta_i$ are scalar parameters that are learned using gradient descent\\footnote{These parameters are added to the set of learnable parameters in a layer}. It should be noted that this transformation does not correspond to a fully connected layer, as these are per-feature scaling and bias coefficients for the activation instead.\n\nAt inference time, mini-batch statistics are not available, as many inference calls use a single test sample. Fixed normalization coefficients can then be estimated from the training set and used during inference. This is performed as part of the learning process as a exponentially averaged running mean and variance of the mini-batch activation statistics, but with an unbiased variance estimate $\\frac{n}{n-1} E[\\sigma^2_{B}]$ used instead.\n\nRecently more advanced versions of activation normalization schemes have appeared in the literature, such as Layer Normalization \\cite[-7em]{ba2016layer}, Instance Normalization, and Group Normalization \\cite[-2em]{wu2018group}. These methods expand Batch Normalization to specific use cases and make it less dependent on mini-batch sizes.\n\nThe inclusion of Batch Normalization in neural network architectures is considered to be a good practice, and most modern neural network architectures (like ResNet, GoogleNet, DenseNets, etc) use it. Using batch normalization has a regularizing effect, generally improving performance. There is strong evidence that this is due to a smoother loss surface \\cite[-6em]{santurkar2018does} as the result of activation normalization, and not to a reduction in the covariate shift, as the original paper argues.\n\nLuo et al. \\cite{luo2018understanding} provide a theoretical framework for the understanding of the regularization effect of Batch Normalization. They find that Batch Normalization is an implicit regularized that can be decomposed into population normalization and gamma decay, the latter being an explicit regularizer. These results show that Batch Normalization of CNNs shares many properties of regularization.\n\nClassical regularization techniques for machine learning models can also be used for neural networks, and the most common ones are $L_1$ and $L_2$ regularization \\marginnote{$L_1$ and $L_2$ Regularization or Weight Decay} (also called Weight Decay). Both of them add a term $\\lambda \\sum_i ||w_i||^p$ to the loss function, which penalizes large weights that are not supported by evidence from the data. $p$ is the order of the norm that is being computed over the weights.\n\n\\subsection{Optimizers}\n\nOptimizers are algorithms that perform minimization of the loss function through gradient descent, as mentioned previously. The standard formulation of SGD uses a constant learning rate, but in practice this does not have to be the case, and a rich literature\\cite{ruder2016overview} exists on optimization methods that scale the learning rate with gradient information, so an individual learning rate is used for each trainable parameter in $\\Theta$.\n\nThe most straightforward way to incorporate this idea is to use the square root of the sum of past squared gradients as a scaling factor for the learning rate. An optimizer using this idea is AdaGrad \\cite{duchi2011adaptive}, with the update rule:\n\\vspace*{1em}\n\\begin{align}\n    g_n &= \\nabla L(h_{\\Theta_{n}}(\\textbf{x}_{i:j}), y)\\nonumber \\\\\n    r_n &= r_{n-1} + g_n \\odot g_n\\nonumber\\\\\n    \\Theta_{n+1} &= \\Theta_{n} - \\alpha \\frac{g_n}{\\epsilon + \\sqrt{r_n}}\n    \\label{background:AdaGrad}\n\\end{align}\n\nWhere $\\odot$ represents component-wise multiplication, and $\\epsilon$ is a small constant for numerical stability and to prevent division by zero. The gradient is divided scaled component-wise by the square root of sum of gradients as well, in order to scale the learning rate for each parameter independently. AdaGrad works most of the time, but the use of a complete history of gradients makes it unstable, since any gradient disturbance at the beginning of training would over-reduce the gradients and prevent the model from reaching its full potential.\n\nAn alternative to AdaGrad is RMSProp \\cite{tieleman2012lecture}, where instead of keeping a sum of the full history of squared gradients, a moving exponential weighted average is kept, so older squared gradient are given less importance than more recent ones. The update rule is:\n\\vspace*{1em}\n\\begin{align}\n    r_n &= \\rho r_{n-1} + (1 - \\rho) g_n \\odot g_n\\nonumber\\\\\n    \\Theta_{n+1} &= \\Theta_{n} - \\alpha \\frac{g_n}{\\sqrt{\\epsilon + r_n}}\n    \\label{background:RMSProp}\n\\end{align}\n\nWhere $\\rho$ is a decay parameter that controls the weight of past squared gradients through the moving average, usually it is set to $0.9$ or $0.99$. RMSProp is more stable than AdaGrad due to better control of the history of squared gradients, and allows a model to reach a better optima, which improves generalization. It is regularly used by practitioners as one of the first methods to start training a model.\n\nAnother advanced Optimizer algorithm is Adam \\cite[-1cm]{kingma2014adam}, which stands for \\textit{adaptive moments}. Adam combines improvements of RMSProp with direct application of momentum in the gradient update. The authors of Adam found that the exponentially weighted averages are biased, and correct this bias using a term that depends on the decay parameter of the exponential weight averages. Additionally, Adam applies an exponential weighted average to the gradient itself, which is equivalent to performing momentum on the gradient update. The update rule is:\n\\vspace*{1em}\n\\begin{align}\n    s_n &= \\rho_1 s_{n-1} + (1 - \\rho_1) g_n\\nonumber\\\\\n    r_n &= \\rho_2 r_{n-1} + (1 - \\rho_2) g_n \\odot g_n\\nonumber\\\\\n    \\Theta_{n+1} &= \\Theta_{n} - \\alpha \\frac{s_n}{\\epsilon + \\sqrt{r_n}} \\frac{1 - \\rho_2^n}{1 - \\rho_1^n}\n    \\label{background:Adam}\n\\end{align}\n\nWhere $s_n$ is the biased estimate of the gradient and $r_n$ is the biased estimate of the squared gradients, both obtained with an exponential moving average with different decay rates $\\rho_1$ and $\\rho_2$. The factors $1 - \\rho_1^n$ and $1 - \\rho_2^n$ are used to correct bias in the exponential moving averages. These computations are done component-wise.\n\nOverall Adam performs considerably better than RMSProp and AdaGrad, training models that converge faster and sometimes obtain slightly better predictive performance, but this is not always the case. Recent advances have shown that Adam can be improved as there are some theoretical issues \\cite{reddi2018convergence} that have been fixed.\nAdam is generally preferred by practitioners when training a newly designed model, as it requires less tuning of the learning rate.\n\nThe use of advanced Optimizer algorithms makes tuning the learning rate an easier task, and in some cases it allows the use of larger learning rates, which translates into faster convergence and lower training times. The only disadvantage of using Optimizers is that sometimes the learning process does not converge to the \\textit{best} optimum\\footnote{For example, it is well known in the community that using Adam on a VGG-like network fails to converge, and we have experimentally confirmed this, the loss just does not decrease, plain SGD works perfectly.}, and there are increased memory usage to store the exponentially weighted averages, usually by $100 \\%$ for RMSProp and AdaGrad, and by $200 \\%$ for Adam, which can constraint the kind of models that can be trained on a GPU.\n\n\\subsection{Performance Evaluation}\n\nThe idea of using machine learning models is to learn to generalize, that is, learn a model from a limited set of data that is useful for samples that the model has never seen during training. A useless model only performs well in the training set.\n\nAn \\marginnote{Cross Validation} important part of designing a machine learning model is related to its desired performance. This is measured by the loss function during training, but just minimizing it in the training set does not guarantee any kind of performance in new and unseen samples. For this an additional set is needed, called the test set. A model is trained on the training set, and its performance evaluated on the test set, which provides an unbiased estimate of the generalization performance of the model. This is typically called Cross Validation.\n\nTypically \\marginnote{Train, Validation, and Test Splits} the available data is randomly split into three datasets: the Training set, the Validation set, and the Test set. The fractions for each split vary, but it is ideal to make the biggest split for the training set, at least 50 \\% of the available data, and use the rest in equal splits for the validation and test sets.\n\nThe validation set is used to evaluate performance during hyper-parameter selection, and only after fixing these values, a final evaluation on the test set can be performed. This prevents any kind of bias in samples in the training or validation set from affecting conclusions about model performance.\n\nOverfitting \\marginnote{Overfitting} is the problem where the model learns unwanted patterns and/or noise from the training data, and fails to generalize outside of its training set. Detecting overfitting is key during training any machine learning model, and is the reason why validation or test sets are used, as it is the only known way to detect overfitting.\n\nDuring the training process, the loss and metrics on the training set is typically tracked and displayed to the designer, and after each epoch, loss and associated metrics can be computed on the validation set. The overall pattern of both training and validation loss tells a picture about that is happening, we cover three cases:\n\n\\begin{description}\n    \\item[Training Loss Decreasing, Validation Loss Decreasing] Indicates that the model is learning and also generalizing well. This is the ideal case.\n    \\item[Training Loss Decreasing, Validation Loss Increasing] Indicates that the model is overfitting, as more noise is learned from the training set, which does not generalize to the validation set.\n    \\item[Training Loss Not Decreasing, Validation Loss Not Decreasing] The model is not overfitting, but it indicates that the model does not fit the data. A model with more learning capacity might be needed, as the current model cannot really predict the data given the input features. For example, if fitting a linear model to data with a quadratic shape. This case might also indicate that the input features might not be well correlated to the desired output or that the learning problem is ill-defined.\n\\end{description}\n\nFor classification problems, the loss is typically the cross-entropy and its variations, but humans prefer to evaluate performance with the accuracy \\marginnote{Accuracy} metric, as it is directly interpretable:\n\\vspace*{1em}\n\\begin{equation}\n    \\text{ACC}(\\hat{y}, y) = n^{-1} \\sum \\mathbb{1}[y = \\hat{y}]\n\\end{equation}\n\nAccuracy is just the fraction of samples that are correctly classified, that is, the predicted label $\\hat{y}$ is the same as the ground truth label $y$. Note that the accuracy metric is completely meaningless for regression problems, as a continuous output equality is ill-defined. One way to define accuracy for continuous outputs is to consider equality if prediction differs from ground truth by not more than a given $\\epsilon$, or to use pearson's correlation coefficient $R$, or the $R^2$ coefficient of determination.\n\n\\subsection{Hyper-parameter Tuning}\n\nHyper-parameters are all parameters in a model that need to be decided before starting the learning process, and that cannot be directly learned (as in by a learning algorithm) from data. The values of these parameters must be decided by the human designer. This also includes the neural network architecture.\n\nA general way to tune these parameters is to use Grid Search \\marginnote{Grid Search}. For this process, a range of values is defined for each parameter $P_i$, and each range is discretized to a finite set of values that will be tested. Then a grid is built by all possible combinations of parameter values $S = P_0 \\times P_1 \\times P_2 \\times \\cdots \\times P_n$. For each value in the parameter space $S$, a model is trained and evaluated on the validation set. The set of parameters that produces the lowest validation loss is used to build the full model, but this is not the only possible criteria.\nIt is common that many sets of parameters provide the same or similar performance than the best model, so other criteria could be used, such as minimizing the number of total weights in the model, or maximizing computational performance subject to a given learning performance.\n\nGrid Search is computationally expensive, as making the grid will exponentially explode the number of parameter sets that have to be tried, and training a neural network for each of these parameter sets is also computationally expensive. A common observation after performing grid search is that some parameters are not really important, having only a small or zero effect on learning performance.\n\nFor\\marginnote[-2em]{Random Search} this reason, Random Search \\cite{bergstra2012random} was proposed, where instead of using discrete values for the parameters, probability distributions are used to model each parameter, and during the search process, a parameter set is drawn by sampling each parameter distribution, and a model trained and evaluated.\nRandom Search has the advantage of minimizing the use of computational budget on uninteresting parameters, and it has been experimentally proven to obtain the same or slightly better models than Grid Search, with less computational budget. Note that since the exploration of the parameter space is random, the bias from parameter values set by the designer can potentially be reduced, and even work in other datasets for which random search is being performed.\n\nTwo parameters deserve special consideration due to their effect on the learning process: the learning rate (LR) and the number of training epochs.\n\n\\begin{description}\n    \\item[Learning Rate] This parameter controls the \"speed\" over which learning is performed, as it scales the gradient, which effectively makes it a kind of step size in the parameter space. Valid learning rate values are typically in the $[0, 1]$ range, but small values are mostly used in practice. If a large LR is used, then learning could diverge (producing infinite or NaN loss values), if a too small LR is used, learning happens but very slowly, taking a large number of epochs to converge. The \\textit{right} LR value will produce fast learning, with a loss curve that is similar to exponential decay. Figure \\ref{background:effectLR} shows typical loss curves with different learning rates. The case of a high LR shows that in the case where learning does not fail, but the loss decreases and stays approximately constant after a certain number of epochs. Note that the LR does not have to be a constant, and it can be varied during training. The typical method is to decrease the LR by a factor after a \\textit{plateau} of the loss curve has been detected, which potentially could allow the loss to decrease further.\n    \n    \\begin{marginfigure}\n        \\begin{tikzpicture}\n            \\begin{axis}[width = \\textwidth, xlabel={Epochs}, ylabel={Loss},\n            xmin = 0.0, xmax = 100.0, ymin = 0.0, ymax = 10.0,\n            legend style={at={(0.5, 2.0)},anchor=north}]\n                \\addplot+[mark=none, domain=0:100] {10 - 0.09 * x + 0.5 * rnd};\n                \\addlegendentry{Low LR}\n                \\addplot+[mark=none, domain=0:100] {exp(2.5 - 0.1 * x) + 0.4 * rnd};\n                \\addlegendentry{Correct LR}\n                \\addplot+[mark=none, domain=0:100] {exp(2.0 - 0.05 * x) + 2 + 0.6 * rnd};\n                \\addlegendentry{High LR}\n            \\end{axis}\n        \\end{tikzpicture}\n        \\caption{Effect of Learning Rate on the Loss Curve during Training}\n        \\label{background:effectLR}\n    \\end{marginfigure}\n    \n    Learning rate can be tuned using grid or random search, but a faster way is to guess an initial LR, train different models and vary the learning rate manually, decreasing or increasing it accordingly to the previously mentioned rules. A common heuristic \\cite{Goodfellow2016deep} is that if learning fails, decrease the LR by a factor of ten until the loss starts to decrease consistently, and adjust further by small steps to produce the ideal loss curve. Typical learning rates used in the literature are negative power of 10, like $\\alpha = [0.1, 0.01, 0.001]$.\n    \n    \\item[Number of Epochs] This parameter controls the length of the training process. If a model is trained for a short number of epochs, then it might not have converged, meaning that the loss could have continued to decrease if trained for longer, while training for more epochs than necessary risks overfitting, assuming no regularization was used.\n    \n    The number of training epochs can be tuned by experimenting manually in a similar way as the learning rate. The designer could set an initial number of epochs (say, 10) and then increase or decrease it accordingly if the loss shows no signs of convergence \\footnote{A model has converged when the training process shows that the loss function can no longer decrease, and the loss shows a wiggling behavior, staying approximately constant.}, or if the model overfits.\n    \n    Related to this parameter is the early stopping criterion, \\marginnote[0.5cm]{Early Stopping} where validation loss is monitored after each epoch, and training stopped if the validation loss starts to increase consistently after a tunable number of epochs. This prevents overfitting and would only require to tune a reasonable minimum number of epochs. The designer should also make sure to tune the learning rate appropriately, as the constant loss that indicates convergence could also be caused by a learning rate that is too high.\n\\end{description}\n\nNote that both the value of learning rate and number of epochs depend on the actual loss function that is being minimized, any change to the loss implies retuning both parameters, as the actual loss surface or landscape is what defines the learning rate and length of training.\n\n\\section{Convolutional Neural Networks}\n\nConvolutional Neural Networks (usually abbreviated CNNs or ConvNets) were introduced by Yann LeCun \\cite{lecun1998gradient} in the 90's, initially for the task of handwritten object recognition, but they have been successfully applied to other vision tasks, like Object Detection and Localization, Semantic and Instance Segmentation, and Image Super-Resolution, etc. CNNs have revolutionized computer vision, as now many visual tasks can be learned using neural networks that are specifically designed for image processing.\n\nThis kind of networks are designed to process images as inputs and they have an optimized network structure to exploit three common properties of images:\n\n\\begin{description}\n\t\\item[Local Statistics] In images the correlation between neighboring pixels in a region is higher than the correlation of far away pixels. This observation also has a biological counterpart as the receptive field in the visual cortex, where cells are excited by patterns in regions of the visual field.\n\t\n\tThis property is implemented by a CNN by using neurons that are connected to a neighboring region in the input image. This is represented by a convolution filter or kernel, which can be square or rectangular. After convolution of the input image with a certain number of filters (one for each neuron), such layer produces the same number of output images called feature maps.\n\t\n\t\\item[Translation Invariance] Generally the filters in that \\textit{look} into a neighboring region of the input image do not depend on a spatial position in the image. Filters are generic and should be useful in any part of the image. This is one kind of translation invariance, since instead of connecting a neuron with all pixels of the input image, which increases the number of parameters, we can only learn the weights associated to the filter, and run it over the whole input image in a sliding window manner, which is effectively the convolution operation.\n\t\n\tAnother kind of translation invariance is downsampling. When the network \\textit{looks} for relevant features to detect or recognize objects, the convolution filter might produce high responses at several neighboring positions. One way to filter these high responses is to perform pooling on a feature map, which will only keep the high responses and discard irrelevant information, as well as reducing the dimensions of a feature map.\n\tThis allows the network to concentrate on important features, and since pooling is invariant to small translations (inside the pooling region), this introduces a small degree of translation invariance into the network design.\n\t\n\t\\item[Feature Extraction] In most computer vision tasks, features are used to discriminate relevant parts of an image. These features are manually engineered by researchers, which is a labor intensive task. Instead, a CNN can learn relevant features to the problem by means of learning the weights of convolution filters.\n\tThis is a very important property of CNNs, features can automatically be learned directly from the training data, since the feature extraction and classifier modules are both part of the same neural network, which can be trained end-to-end. This means that relevant features for each vision problem can be learned directly from the data, without any manual engineering and with minimal preprocessing \\footnote{In general this preprocessing consists of dataset augmentation and input/output normalization.}.\n\\end{description}\n\nThe basic design of CNNs introduces two new types of layers: Convolution and Pooling layers.\n\nImages are usually represented as multi-dimensional arrays or tensors, \\marginnote{Image Representation} with shapes $(W, H, C)$, where $W$ is the width, $H$ is the height, and $C$ is the channels dimension, \\footnote{This is also referred as depth dimension in some papers.} which is one for a grayscale image, and three for a RGB color image. This representation also allows for arbitrary numbers of channels, and it will be useful later on.\n\n\\subsection{Convolutional Layers}\n\nFor a convolutional layer \\marginnote{Convolutional Layer}, the output $y$ is given by:\n\\vspace*{1em}\n\\begin{equation}\n    y = f(\\mathbf{x} \\ast \\mathbf{F} + b)\n\\end{equation}\n\nWhere $\\ast$ is the convolution operation, $x$ is the input image, $\\mathbf{F}$ is the convolution filter (weights), $b$ is a bias and $f$ is a non-linear activation function that is applied element-wise to the output. In other words, a convolution layer takes an image as input, convolves it with a filter, adds a bias, and then passes the convolved image through a non-linear activation function. The output of a this kind of layer is called a \\textit{convolutional feature map} \\marginnote{Convolutional Feature Map}, as it represents visual features of an image (a map).\n\nIn practice, convolutional layers use more than one filter per layer, as this allows to learn different kinds of features at the same time, and later it allows the learning of feature hierarchies \\cite{zeiler2014visualizing}. This is represented as a layer taking inputs of shape $(W, H, C)$, and the output having shape $(W, H, K)$, where $K$ is the number of filters in the convolution layer. Each filter is convolved individually with the input image, and the result after applying bias and activation function is stored in the channels dimension of the output, stacking all feature maps into a 3D volume. Convolutional layers can also take feature maps as inputs, which forms the feature hierarchy previously mentioned.\n\nAnother important detail of a convolutional layer is that both bias and weights on the filter are learned using gradient descent. They are not hand tuned as previously was done for image processing, like to make edge detection or sharpness filters. The filter in a convolutional layer is not necessarily a two dimensional matrix, as when the input image or feature map has $K > 1$ channels, then the filter must have a matching shape $(W, H, K)$, so convolution can be possible. When the filter has multiple channels, convolution is performed individually for each channel using the classical convolution operation from image processing \\cite[-1em]{gonzalezDIP2006}.\n\nThe filter size (width and height) in a convolutional layer is a hyper-parameter that must be tuned for specific applications, and generally it must be a odd integer, typical values are $3 \\times 3$ or $5 \\times 5$, but some networks such as AlexNet \\cite{krizhevsky2012imagenet} used filter sizes up to $11 \\times 11$. The width and height of a filter do not have to be the same, but generally square filters are used.\n\nConvolution is normally performed with a stride of 1 pixel \\marginnote[1em]{Stride}, meaning that the convolution sliding window is moved by one pixel at a time, but different strides can also be used which is a kind of sub-sampling of the feature map.\n\nThe output dimensions of a convolutional layer are defined by the filter sizes, as convolution is only typically performed for pixels that lie inside the image region, and out of bound pixels are not considered (at the edges of the image). Padding \\marginnote{Padding} can be added to the input image or feature map in order to output the same spatial dimensions as the input.\n\nFor a $N \\times N$ filter and a $W \\times W$ input image or feature map, with padding of $P$ pixels and stride $S$, the output has dimensions $O$:\n\\vspace*{1em}\n\\begin{equation}\n    O = \\frac{W - N + 2P}{S} + 1\n\\end{equation}\n\n\\subsection{Pooling Layers}\n\nA pooling layer is used to introduce a small degree of translation invariance to the network design, and to control the flow of information through the network, by performing down-sampling on feature maps. This works by forcing the network during learning to produce meaningful features that will pass through the pooling operation. \n\nPooling works by partitioning \\marginnote{Down-sampling} an input feature map of size $W \\times H$ in non-overlapping regions of the same size $D \\times D$, and then performing a aggregation operation on each region, producing a scalar value, and then replacing each region with this aggregated scalar value, effectively performing down-sampling, as the output of the pooling operation has size $\\frac{W}{D} \\times \\frac{H}{D}$. $W$ and $H$ must be divisible by $D$ or else padding is required. Pooling can be performed in overlapping regions, as well as with a stride $S > 1$, depending on the designer's needs.\n\nTwo types of aggregation operations are used in the CNN literature:\n\n\\begin{description}\n    \\item[Max-Pooling] The maximum value in each region $R$ is kept and used as output:\n        \\vspace*{1em}\n        \\begin{equation}\n            y = \\max_{x \\in R} x \n        \\end{equation}\n        \n        The concept of Max-Pooling is that only the maximum activation in each region of the feature map will pass, suppressing the non-maximums. While it works well in practice, there are issues since small disturbances to the activations in a feature map will lead to big changes after Max-Pooling. Passing gradients through this operation is not simple, as the position of the maximum has to be tracked for correct gradient propagation.\n    \\item[Average Pooling] Output the average value in each region $R$:\n        \\vspace*{1em}\n        \\begin{equation}\n            y = D^{-2} \\sum_{x \\in R} x\n        \\end{equation}\n        Taking the average of each region could be preferable to the maximum, as it has a less chaotic effect on the output when there are small disturbances, unlike max-pooling. This operation also has the effect of passing important information through, and it is more friendly to gradient propagation, as the average operation is differentiable.\n\\end{description}\n\nNote that the pooling operation operates independently for each channel in a feature map, and the channels dimension is unaffected, as only spatial dimensions ($W$ and $H$) are down-sampled. Pooling defines the receptive field size of the network, as using more down-sampling operations will increase the receptive field exponentially.\n\nDepending on the size of the input image (usually fixed at design time), there is a limited number of pooling operations with down-sampling that can be placed in a network. If a model contains pooling operations with down-sampling of $D \\times D$ for an input of $W \\times H$, then the maximum number of pooling operations is $\\log_D \\min \\{ W, H\\}$. Any down-sampling layer inserted above this limit will be operating on a $1 \\times 1$ feature map, making the operation useless. This computation does not consider padding or slight down-sampling performed by convolution operations without padding.\n\nNote that pooling operations have no trainable parameters, they are effectively computations that do not learn anything, but they influence what other trainable layers learn.\n\n\\subsection{Convolutional Network Architectures}\n\nNow that we have defined the basic building blocks of convolution and pooling, we can define a full convolutional neural network.\n\nA convolutional neural network (CNN) is any neural network that uses convolutional layers in its design, typically as the first layers in the architecture. The effect of using these layers is that the learn to extract relevant features from the input image. The combination of convolutional and pooling layers forms a natural feature hierarchy \\cite{zeiler2014visualizing}, where low level features (edges, lines, etc) are extracted in the convolutional layers closest to the input, and more complicated features (object parts, ) are extracted in subsequent layers.\n\nThis feature hierarchy is a natural result of applying convolution and pooling over feature maps, as convolution over the input image can only extract very simple features, while convolution on a feature map that contains these simple features can then do further processing to extract more complex ones. As the network becomes deeper in terms of the number of convolutional layers, the complexity of features that can be modeled increases.\n\nFigure \\ref{background:lenet5} shows LeNet-5 \\cite{lecun1998gradient}, one of the first CNNs successfully used to recognize digits from the MNIST dataset. This network contains a first convolutional layer of six $5 \\times 5$ filters, connected to a $2 \\times 2$ pooling layer that subsamples by a weighted average and passes the output through a sigmoid activation function. Then another convolutional layer of sixteen $5 \\times 5$ filters, also connected to a $2 \\times 2$ max-pooling layer. The output of the last layer is then flattened\\footnote{Array is reshaped to become one-dimensional.} and output to two fully connected layers (an MLP), that outputs to a softmax activation function.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width = 0.95 \\textwidth]{chapters/images/lenet5.jpg}\n    \\caption[Architecture of LeNet-5]{Architecture of LeNet-5, Figure extracted from LeCun et al. 1998}\n    \\label{background:lenet5}\n\\end{figure}\n\nLeNet was a big innovation for the time, since it obtains a $0.95 \\%$ error rate on the MNIST dataset (corresponding to $99.05 \\%$ accuracy), which is very close to human performance. Other kinds of classifiers such as K-Nearest-Neighbors with euclidean distance obtained $5 \\%$ error rates, which shows the advantages of a CNNs.\n\nLeNet set that initial standard for CNN design, starting with convolution and max-pooling blocks that are repeated a certain number of times, and perform feature extraction, followed by a couple of fully connected layers that perform classification or regression of those learned features. The network can be trained end-to-end using gradient descent.\n\nA second milestone in CNNs is AlexNet \\cite[-5em]{krizhevsky2012imagenet}, which is one of the first real deep neural networks trained on a large scale dataset. This network was designed to compete in the ImageNet Large Scale Visual Recognition Challenge \\cite[-2em]{russakovsky2015imagenet}, where the task is to classify variable-sized images over 1000 different classes, with a training set containing 1.2 million images. It is a very difficult task due to the large training set, large number of classes, and many visual confusion between classes. \\footnote[][2em]{For example, ImageNet contains many different races of dogs and cats, which a human cannot always visually distinguish.}\n\nAlexNet unexpectedly won the ILSVRC competition in 2012, where most contenders were using classical computer vision methods and manually engineered features, but Kryzhevsky et al. showed that neural networks are competitive for this problem, and this is proven by the margin with the second place, of around $10 \\%$ top-5 accuracy less than AlexNet.\n\nThe architecture of AlexNet is shown in Figure \\ref{background:alexnet}, the network has 15 layers and approximately 60 million trainable parameters. AlexNet obtains $83.6$ \\% top-5 accuracy on the ImageNet 2012 dataset, while the second place winner of the same competition obtains $73.8$ \\% top-5 accuracy, showing the superior performance and capability of a deep neural network.\n\n\\begin{table}[t]\n    \\centering\n    \\begin{tabular}{@{}lll@{}}\n        \\hline\n        Name\t\t\t\t\t& Operation \t\t\t\t\t\t\t& Output Shape\\\\\n        \\hline\n        Input\t\t\t\t\t& Input image\t\t\t\t\t\t\t& $(224, 224, 3)$ \\\\\n        \\hline\n        Conv-1\t\t\t\t\t& Conv($96$, $11 \\times 11$, $S = 2$)\t& $(55, 55, 96)$ \\\\\n        MP-1\t\t\t\t\t& Max-Pool($2 \\times 2$)\t\t\t\t& $(27, 27, 96)$ \\\\\n        Conv-2\t\t\t\t\t& Conv($256$, $5 \\times 5$, $S = 1$)\t& $(27, 27, 256)$ \\\\\n        MP-2\t\t\t\t\t& Max-Pool($2 \\times 2$,)\t\t\t\t& $(13, 13, 256)$ \\\\\n        Conv-3\t\t\t\t\t& Conv($384$, $3 \\times 3$, $S = 1$)\t& $(13, 13, 384)$ \\\\\n        Conv-4\t\t\t\t\t& Conv($384$, $3 \\times 3$, $S = 1$)\t& $(13, 13, 384)$ \\\\\n        Conv-5\t\t\t\t\t& Conv($256$, $3 \\times 3$, $S = 1$)\t& $(13, 13, 256)$ \\\\\n        MP-3\t\t\t\t\t& Max-Pool($2 \\times 2$,)\t\t\t\t& $(7, 7, 256)$ \\\\\n        Flatten\t\t\t\t\t& Flatten()\t\t\t\t\t\t\t\t& $(7 \\times 7 \\times 256)$\\\\\n        \\hline\n        FC-1\t\t\t\t\t& FC($4096$, RELU)\t\t\t\t\t\t& $(4096)$\\\\\n        Dropout-1\t\t\t\t& Dropout($0.5$)\t\t\t\t\t\t& $(4096)$\\\\\n        FC-2\t\t\t\t\t& FC($4096$, ReLU)\t\t\t\t\t\t& $(4096)$\\\\\n        Dropout-2\t\t\t\t& Dropout($0.5$)\t\t\t\t\t\t& $(4096)$\\\\\n        \\hline\n        FC-3\t\t\t\t\t& FC($1000$, Softmax)\t\t\t\t\t& $(1000)$\\\\\n        \\hline\n    \\end{tabular}\n    \\caption[Architecture of AlexNet as defined in Krizhevsky et al 2012]{Architecture of AlexNet as defined in Krizhevsky et al 2012. ReLU activations are used in each Convolutional Layer.}\n    \\label{background:alexnet}\n\\end{table}\n\nProgress in the ImageNet competition has been constant over the years, producing advances in CNN architecture engineering. Pretty much all of the contenders after 2012 were using CNNs. In 2013 the VGG group at Oxford made a deeper version of AlexNet, which is typically just called VGG \\cite{simonyan2014very}, with over 144 million parameters and obtaining $92 \\%$ top-5 accuracy. The VGG networks use a simpler structure, with only $3 \\times 3$ filters, and combining two consecutive convolutions both with $3 \\times 3$ filters to simulate a bigger $5 \\times 5$ filter.\n\nIn 2014 Google entered the competition with their GoogleNet \\cite{szegedy2015going} architecture, which uses what they called the Inception module, that contains convolutions of multiple filter sizes combined with max pooling in a parallel structure, including $1 \\times 1$ convolutions to learn features across channels/depth and $3 \\times 3$ and $5 \\times 5$ convolutions to learn spatial structure. GoogleNet obtains $93.3$ \\% top-5 accuracy with 22 layers.\n\nIn 2015 Microsoft Research proposed Deep residual networks\\cite{he2016deep}, which use a slightly different architecture that allows the network to be much more deep than possible before. A residual function is modeled as $F(x) + x$, where $x$ is the input to a set of layers, and $F(x)$ is the output of those layers. This addition operation is implemented as a skip connection that outputs the sum of the input and the output of a set of layers. The authors hypothesize that optimizing such structure is easier than the optimization process for a normal CNN, and they show this by building a much deeper (over 150) layer network that obtains $95.5$ \\% top-5 accuracy.\n\n\\subsection{Discussion}\n\nDifferent patterns in CNN architectures have emerged over the years, and overall there are some design choices that can be learned. In general a deeper network performs better, because it can learn higher level features which is only possible with a deep feature hierarchy. Seems that filters sizes do not have to be big (as in AlexNet), as most state of the art ImageNet CNNs use $3 \\times 3$ and sometimes $5 \\times 5$ filters. Even $1 \\times 1$ filters are useful in order to influence information in the channels dimension.\n\nA common pattern in the CNNs presented in this Section is that the number of filters increases with depth, and this makes sense, as deeper networks have smaller filter sizes and this has to be compensated by having more filters, which can represent a more rich feature hierarchy. There could be a one-to-one match between some features and specific filters, so in order to have more complex features, more filters are needed.\n\nOverall, designing a neural network architecture for a specific task always requires a degree of experimentation. Designers should start with a small network, and expand it as needed, but only doing this kind of experimentation by evaluating on a evaluation set, and obtaining a final performance measure in a test set.\n\nNeural network architectures can also be automatically designed by an algorithm. Popular choices are genetic algorithms \\cite[-4em]{stanley2002evolving}, and newer techniques like Neural Architecture Search \\cite[1em]{zoph2018learning} and Differentiable Architecture Search \\cite[1em]{liu2018darts}.\n\nIn general automatic architecture design techniques have trouble achieving results that outperform the state of the art, as measured by classification performance in many common datasets (like ImageNet, CIFAR-10/100), only recent techniques are able to automatically produce an architecture that outperforms manually crafted architectures, so it can be expected that neural networks will be increasingly designed by algorithms and not by humans.\n\nThese kind of techniques are contributing to the long term goal of \\textit{automatic machine learning}\\cite[1em]{quanming2018taking}, where only labeled data is provided and the hyper-parameters of the architecture are automatically tuned in a validation subset, which has the potential of expanding the use of machine learning techniques to non-technical users.", "meta": {"hexsha": "277da73270a026fa403282eec19acb787e323645", "size": 75138, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/background.tex", "max_stars_repo_name": "mvaldenegro/phd-thesis", "max_stars_repo_head_hexsha": "ebc92c443d2100ccd030a118e5a1c24f0c4b105d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/background.tex", "max_issues_repo_name": "mvaldenegro/phd-thesis", "max_issues_repo_head_hexsha": "ebc92c443d2100ccd030a118e5a1c24f0c4b105d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-09T12:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:33:21.000Z", "max_forks_repo_path": "chapters/background.tex", "max_forks_repo_name": "mvaldenegro/phd-thesis", "max_forks_repo_head_hexsha": "ebc92c443d2100ccd030a118e5a1c24f0c4b105d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 122.5742251223, "max_line_length": 1129, "alphanum_fraction": 0.775213607, "num_tokens": 17286, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.5888891307678319, "lm_q1q2_score": 0.4156291315518875}}
{"text": "%\n% set up on June 2013\n%\n\\chapter{Van der Waals Interaction in Density Functional Theory}\n%\n%\nThe dispersion or Van der Waals interaction is classical in Chemistry. \nGiven two widely separated systems, an instantaneous dipole moment on \none system induces a dipole moment on the other. The attraction between \nthese moments results in an interaction is expressed as following:\n\\begin{equation}\n \\label{VDW_DFT_eq:1}\n E_{VDW} = -\\frac{C_{6}}{R^{6}}\n\\end{equation}\nwhere $C_{6}$ is some constant whose value depends on the systems\ninvolved, and $R$ is the distance between the two separated systems.\n\n%\n% let's state that in density functional theory \n% it's hard to include VDW\n%\n\n\\section{XDM Model}\n%\n%\n\n\\subsection{Oringinal Idea for XDM Model}\n%\n%\n%\nThe XDM model is promoted by A. D. Becke and his colleagues. It's \ntrying to provide a clear model to explain the Van der Waals interaction\nin Density functional theory. Basically, it trys to give an answer to\nthe following question, that How do ``instantaneous'' dipole moments arise \nin systems which may have a zero permanent dipole moment? For example, \nin the noble gas system? XDM model suggests that the ``instantaneous'' \ndipole moments actually arise from the assymetrical exchange hole.\n\nConsider an electron with $\\sigma$ spin in an molecular system. As it moves \nthrough the system it is accompanied by an exchange hole whose shape depends \non the electron’s instantaneous position $r_{1}$. The hole is given by the\nexpression(This is constructed based on the Slater determinant. \nsee \\ref{DHF_in_density_matrices} for more information):\n\\begin{equation}\n\\label{XDM_exchange_hole}\n h_{X\\sigma}(r_{1},r_{2}) = -\\frac{\n\\sum_{ij}\\varphi_{i\\sigma}(r_{1})\\varphi_{i\\sigma}(r_{2})\\varphi_{j\\sigma}(r_{1})\n\\varphi_{j\\sigma}(r_{2})}{\\rho_{\\sigma}(r_{1})}\n\\end{equation}\nwhere $i,j$ are both occupied electron orbitals. Here $r_{2}$ defines the shape \nof the hole and $r_{1}$ is called the ``reference'' point. The spin exchange \nenergy $E_{X}$ is related to the exchange hole by:\n\\begin{equation}\n \\label{XDM_exchange_energy}\nE_{X\\sigma} = \\frac{1}{2}\\int dr_{1}dr_{2} \\rho_{\\sigma}(r_{1}) \n\\frac{h_{X\\sigma}(r_{1},r_{2})}{r_{12}}\n\\end{equation}\n\nThe exchange-hole definition enables us to visualize the effects of self-interaction \ncorrection and exchange. When an electron is at $r_{1}$, the hole measures the depletion \nof probability with respect to the total electron density of finding another same-spin \nelectron at $r_{2}$. The probability of finding\nanother same-spin electron at $r_{1} = r_{2}$ is completely extinguished because of the \nPauli principle. In general, the depletion of the electron density because of the Fermi hole\nis same with the integration of electron density itself:\n\\begin{equation}\n \\label{XDM_eq:1}\n\\int dr_{2} h_{X\\sigma}(r_{1},r_{2}) = -\\int dr_{1} \\rho(r_{1}) = -1\n\\end{equation}\nTherefore, the electron density plus its Fermi hole has zero charge overall.\n\nHowever, the hole is not, in general, spherically symmetric around $r_{1}$. Only in a uniform \nelectron gas it has spherical symmetry. Thus the electron density plus its Fermi hole,\nalthough it's zero charge overall, since it's not symmetrical therefore it will produce\na dipole moment for the reference point of $r_{1}$. We note that such induced dipole moment\nis not affecting total energy. Since in equation \\ref{XDM_exchange_hole}, the hole only\nsenses the spherical average around $r_{1}$ (see \\ref{hole_function_pair_distribution} \nfor more details that why the hole function is symmetrical); therefore such assymetrical\ndeformation of the hole does not alter the exchange enegry.\n\nBased on the above analysis, we can define some ``operator'' to evaluate the dipole \nmoment triggered by the aspherical exchange hole:\n\\begin{equation}\n \\label{XDM_model}\nd_{X\\sigma}(\\bm{r_{1}}) = \n\\frac{\n\\sum_{ij}\\varphi_{i\\sigma}(r_{1})\\varphi_{j\\sigma}(r_{1})}{\\rho_{\\sigma}(r_{1})}\n\\left[ \\int dr_{2} \\varphi_{i\\sigma}(r_{2})\n\\varphi_{j\\sigma}(r_{2}) \\bm{r_{2}} \\right] - \\bm{r_{1}}\n\\end{equation}\nThis term is used to describe the difference between position of $\\bm{r_{1}}$ and\nthe average exchange hole at $\\bm{r_{1}}$. \n\nBased on this operator form, the induced dipole could be expressed as:\n\\begin{equation}\n\\label{XDM_eq:0}\n \\langle d_{X\\sigma}\\rangle = \\int \\rho_{\\sigma}(r_{1})d_{X\\sigma}(\\bm{r_{1}}) dr_{1}\n\\end{equation}\nThis is the hypothesis for the whole XDM model.\n\nNow let's derive the induced dipole for multiple systems from such assumption. \nSuggest that we have two  separated systems A and B and they are far away from \neach other ($R$ is large enough)\ncomparing with their size. If the system B is approaching to A then there will be\nan induced electric field generated because of the assymetrical deformation of the \nexchange hole. This electric field could be expressed as\\footnote{This expression \ncould be got from the classic induced dipole moment expression}:\n\\begin{equation}\n \\label{XDM_eq:2}\n\\bm{E} = \\frac{(3\\bm{d}_{X\\sigma}\\cdot \\bm{R})\\bm{R}}{R^{5}} - \n\\frac{\\bm{d}_{X\\sigma}}{R^{3}}\n\\end{equation}\nHere $\\bm{d}_{X\\sigma}$ is defined in \\ref{XDM_model}.\n\nFor system B, let's assume that it's Polarizability is $\\alpha_{B}$ The corresponding \ninduced diploe moment is:\n\\begin{equation}\n\\label{XDM_eq:3}\n \\bm{d}_{ind} = \\alpha_{B} \\bm{E}\n\\end{equation}\n\nThen the dipole energy on the point of $\\bm{r_{1}}$could be expressed as:\n\\begin{equation}\n \\label{XDM_eq:4}\nV = \\frac{\\bm{d}_{X\\sigma}\\cdotp \\bm{d}_{ind}}{R^{3}} - \n\\frac{3 (\\bm{d}_{X\\sigma}\\cdotp \\bm{R})(\\bm{d}_{ind}\\cdotp \\bm{R})}{R^{5}}\n\\end{equation}\n\nNow we can bring \\ref{XDM_eq:2} and \\ref{XDM_eq:3} into the \\ref{XDM_eq:4} and omit\nthese terms with $R^{10}$, we can get:\n\\begin{equation}\n \\label{XDM_eq:5}\n V= -\\alpha_{B}\\frac{\\bm{d}_{X\\sigma}\\cdotp \\bm{d}_{X\\sigma}}{R^{6}}\n-3\\alpha_{B}\\frac{(\\bm{d}_{X\\sigma}\\cdotp \\bm{R})^{2}}{R^{8}}\n\\end{equation}\n \nThe average dipole moment energy could be got by integrating over the angles:\n\\begin{align}\n\\label{XDM_eq:6}\n V^{avg} &= -\\frac{\\alpha_{B}}{4\\pi}\\int^{\\pi}_{0} \\int^{2\\pi}_{0} \\sin\\theta d\\theta d\\phi \n\\left[ \\frac{\\bm{d}_{X\\sigma}\\cdotp \\bm{d}_{X\\sigma}}{R^{6}}\n+3\\alpha_{B}\\frac{(\\bm{d}_{X\\sigma}\\cdotp \\bm{R})^{2}}{R^{8}}\\right]   \\nonumber \\\\\n&= -2\\frac{\\alpha_{B}d_{X\\sigma}^{2}}{R^{6}}\n\\end{align}\nBy integrating over $r_{1}$ (the reference point), we can have:\n\\begin{equation}\n\\label{XDM_eq:7}\n U_{\\sigma} = \\int \\rho(r_{1}) V^{avg} dr_{1} = \n-2\\frac{\\alpha_{B}\\langle d_{X\\sigma}^{2}\\rangle}{R^{6}}\n\\end{equation}\nWhere $\\langle d_{X\\sigma}^{2}\\rangle$ is\n \\begin{equation}\n \\langle d_{X\\sigma}^{2}\\rangle = \\int \\rho_{\\sigma}(r_{1})d_{X\\sigma}(\\bm{r_{1}})\\cdotp \nd_{X\\sigma}(\\bm{r_{1}}) dr_{1}\n\\end{equation}\ncomparing with \\ref{XDM_eq:0}.\n\nSo far the dipole moment is only given for one spin state, for spin-resolved state\nit has:\n\\begin{equation}\n \\label{XDM_eq:8}\n\\langle d_{X}^{2} \\rangle = \\langle d_{X\\alpha}^{2}\\rangle + \\langle d_{X\\beta}^{2}\\rangle\n\\end{equation}\ntherefore the spin-resolved energy is expressed as:\n\\begin{equation}\n \\label{XDM_eq:9}\nU = -2\\frac{\\alpha_{B}\\langle d_{X}^{2}\\rangle}{R^{6}}\n\\end{equation}\nand the coefficient of $C_{6}$ in \\ref{VDW_DFT_eq:1} is given as:\n\\begin{equation}\n C_{6} = -2\\alpha_{B}\\langle d_{X}^{2}\\rangle\n\\end{equation}\n\nHowever, in the original paper Becke etc. found that \\ref{XDM_eq:9} yields four times larger result \ncompared with experimental data, therefore, they take a heuristic approach to modify \\ref{XDM_eq:9}\ninto:\n\\begin{equation}\n \\label{XDM_eq:10}\nU = -\\frac{\\alpha_{B}\\langle d_{X}^{2}\\rangle}{2R^{6}}\n\\end{equation}\nso the corresponding $C_{6}$ is changing to:\n\\begin{equation}\n\\label{XDM_eq:12}\n C_{6} = -\\frac{1}{2}\\alpha_{B}\\langle d_{X}^{2}\\rangle\n\\end{equation}\n\n\nExpression \\ref{XDM_eq:10} describes the dipole energy for B induced from A, and symmetrically;\nwe also have dipole energy for A induced from B; which is:\n\\begin{equation}\n \\label{XDM_eq:11}\nU_{AB} = -\\frac{\\alpha_{A}\\langle d_{BX}^{2}\\rangle}{2R^{6}}\n\\end{equation}\nIf A and B are different system, then how can we count \\ref{XDM_eq:10} and \\ref{XDM_eq:11} \ntogether?\n\nFor this case, Becke etc. defined the $C_{6}$ parameter as:\n\\begin{equation}\n \\frac{2}{C_{6}} = \\frac{1}{C_{6,AB}} + \\frac{1}{C_{6,BA}}\n\\end{equation}\nBy bring \\ref{XDM_eq:11} into this expression, we can have the final $C_{6}$ expression:\n\\begin{equation}\n \\label{XDM_eq:13}\nC_{6} = \\frac{\\alpha_{A}\\alpha_{B}\\langle d_{AX}^{2}\\rangle\\langle d_{BX}^{2}\\rangle}\n{\\alpha_{A}\\langle d_{BX}^{2}\\rangle + \\alpha_{B}\\langle d_{AX}^{2}\\rangle}\n\\end{equation}\n\n\n\n \n\n\n\n", "meta": {"hexsha": "c83c94bfda158e64687f76defd5e0d63289e50ac", "size": 8575, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "theory/chemistry/vdw.tex", "max_stars_repo_name": "murfreesboro/fenglai-note", "max_stars_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-16T07:23:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T07:23:48.000Z", "max_issues_repo_path": "theory/chemistry/vdw.tex", "max_issues_repo_name": "murfreesboro/fenglai-note", "max_issues_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theory/chemistry/vdw.tex", "max_forks_repo_name": "murfreesboro/fenglai-note", "max_forks_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0700934579, "max_line_length": 100, "alphanum_fraction": 0.7167346939, "num_tokens": 2801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.5660185351961016, "lm_q1q2_score": 0.4155252658600209}}
{"text": "%!TEX root = kPtx_paper.tex\n\\section*{Methods}\n\\subsection*{Design and Simulation Setup}\nSimulations were performed to validate and characterize the proposed k-space domain parallel transmit pulse design method,\nwith comparisons to a least-squares spatial-domain design \\cite{Grissom:2006:MRM}.\nRF pulses were designed for a simulated 24-channel loop transmit array (Figure \\ref{fig:Coil}) that is being built for a 7 Tesla scanner optimized\nfor imaging the human cortex.  \n24-channel complex-valued $B_1^+$ maps used in the pulse designs were simulated in a male human head model using \nAnsys High Frequency Structure Simulator (Canonsburg, PA, USA) with 1.5 mm isotropic resolution. \nFigure \\ref{fig:Target}a shows the target pattern for all pulse designs which comprised an ellipse centered on the ventricles with AP/HF/LR semi-axes of 4.8/3.2/3.2 cm,\n\\textcolor{blue}{with zero phase.}\\revbox{R1.1} \nThe pattern was smoothed by a Fermi filter that was applied in the frequency domain to match the target pattern's effective resolution to the excitation k-space trajectory's 5 mm resolution.\nThis choice of target pattern was motivated by imaging applications for the 7 Tesla scanner \nin which midbrain signals will be saturated for high-resolution, highly-accelerated imaging of the cortex. \nPulses were designed to excite the entire ellipse and achieve zero excitation in voxels in the cerebrum but outside the ellipse. \nThe smoothed target pattern and the $B_1^+$ maps were downsampled from their original 128$\\times$128$\\times$96 grids (1.5 mm isotropic resolution) to \n64$\\times$64$\\times$48 grids (3 mm isotropic resolution),\nand RF designs were performed with the 64$\\times$64$\\times$48 grid size. \n\n\n\n\n\\par A SPINS excitation k-space trajectory \\cite{malik2012tailored} (Figure \\ref{fig:Target}b) with 5 mm max resolution was used for the designs. \nThe SPINS trajectory comprised three segments with radii ranging between 1-0.625, 0.625-0.375, and 0.375-0 cycles/cm, respectively.\nThe number of polar and azimuthal rotations were 15.5/2.125, 20.66/2.833, 15.5/2.125 for each segment, respectively.\nThe SPINS trajectories were first designed analytically and the final gradient waveforms and excitation k-space trajectories were designed from them \nusing the minimum-time gradient waveform design method \\cite{lustig2008fast}, \nfor a 15 {\\textmu}s dwell time and subject to the scanner's gradient amplitude and slew rate constraints of 200 mT/m and 700 T/m/s, respectively (Figure \\ref{fig:Target}c). \nThe durations of the three segments after minimum-time gradient design were 4.174, 4.326, and 1.5 ms, respectively.\nWith the exception of the simulations across undersampling factors, \nall pulse designs used this 10 ms trajectory.\nWith this trajectory and the 64$\\times$64$\\times$48 design grid size, \nthe dimensions of the $\\bm{W}$ matrix were 16,632 RF pulse samples, \nby 196,608 target k-space locations. \n\n\n\n\\par All pulse designs and Bloch equation simulations were performed in MATLAB (Mathworks, Natick, MA, USA).\nFor spatial domain designs, \nRF pulses were solved using an iterative least-squares conjugate-gradient descent method with 35 iterations,\nwhich was accelerated by NUFFTs \\cite{Fessler:2003fk}. \nExcept for the off-resonance-compensated designs described below, \nall spatial domain designs were parallelized using 16 threads that simultaneously computed the forward and backward \nNUFFTs across transmit coils. \nThe proposed k-space domain algorithm was implemented based on code for the non-Cartesian GRAPPA method of Ref. \\cite{luo2019grappa},\nas a function that takes as input the $B_1^+$ maps and a normalized excitation k-space trajectory.\n%, \\textcolor{blue}{and optional MATLAB structures of algorithm parameters such as the Tikhonov regularization parameter\n%and inclusion and patch widths, and off-resonance parameters such as the off-resonance field map, the time vector and the number of time segments.}\\revbox{R1.X} \nWithin that function the Fourier transforms of the $B_1^+$ products are calculated,\nand a C-based \\textcolor{blue}{MATLAB Executable (MEX)}\\revbox{R1.6} function is invoked to solve for the non-zero elements of each column of $\\bm{W}$,\nwith linear interpolation of the Fourier transforms of the $B_1^+$ map products to obtain the entries of the $\\bm{S}^H\\bm{S}$ matrices. \nThose elements are then inserted into a sparse $\\bm{W}$ matrix, which is the single output of the main function. \nParallelization was implemented across patches within the C-based MEX function using the \\textcolor{blue}{Open Multi-Processing (OpenMP)}\\revbox{R1.6} library. \nThe final pulses are calculated by multiplying the sparse $\\bm{W}$ matrix into the Fourier transform of the target pattern. \nThis code, the $B_1^+$ maps, and a demo script are available at https://github.com/wgrissom/kpTx. \nAll pulse designs were performed on a server (Colfax International, Santa Clara, CA, USA) \nwith 512 GB RAM and two 24-core 2.1 GHz Intel Xeon CPUs which provide up to 94 threads (Intel Corporation, Santa Clara, CA, USA). \nDesigns were performed five times for each case, and the mean computation time was recorded.\nFor the k-space domain designs, the design time comprised the time to compute the sparse $\\bm{W}$ matrix, \nand the time to multiply it into the target pattern to obtain the pulses.\nThe resulting pulses were Bloch equation-simulated and compared to the target pattern on the finer 128$\\times$128$\\times$96 grid to capture Gibbs ringing. \nWhen calculating excitation errors, the magnitude root-mean-square error (RMSE) was calculated in voxels within the cerebrum,\nexcept for an $\\approx$5 mm-thick transition band around the edge of the elliptical target region.\n\n\\subsection*{k-Space Algorithm Parameters}\nTo evaluate how accuracy and compute time depend on k-space-domain design parameters and parallelization,\npulse designs were done across numbers of threads (i.e., how many patches were solved simultaneously; 1 to 32), \npatch widths (1 to 16 cycles/FOV), and inclusion widths (2 to 8 cycles/FOV). \nThe number of threads were varied while holding the patch width and inclusion width both at 4 cycles/FOV.\nThe patch width was varied while holding the number of threads at 16, and the inclusion width at 4 cycles/FOV,\nand the inclusion width was varied (2, 4, 6, and 8 cycles/FOV) while holding the number of threads at 16, and the patch width at 4 and 8 cycles/FOV. \nThe sizes of the $\\bm{W}$ matrices were also recorded, holding patch width constant at 4 cycles/FOV and varying the inclusion width. \n\n\\subsection*{L-Curves}\nTo compare the tradeoff between excitation error (measured by root-mean-square error)\nand integrated RF root-mean-square (RMS) amplitude for spatial and k-space domain designs,\npulse designs were repeated while varying Tikhonov regularization parameters ($\\lambda$ in Equation \\ref{eq:Solution}) \nover five orders of magnitude. \nThe k-space domain designs were repeated four times to investigate the two main sources of error:\nfinite patch and inclusion widths, \nand $B_1^+$ map product interpolation when building the $\\bm{S}^H\\bm{S}$ matrices. \nSpecifically, for each $\\lambda$ a design was performed using patch and inclusion widths of four (`Patch/Inclusion Widths = 4')\nwith interpolated $B_1^+$ map products (`Interpolated Matrices'),\npatch and inclusion widths covering the entire design grid (`Patch/Inclusion Widths = $\\infty$') with interpolated $B_1^+$ map products,\npatch and inclusion widths of four without $B_1^+$ map product interpolation (`Exact Matrices'; \n$B_1^+$ maps were phase-modulated to each trajectory location before Fourier transform),\nand patch and inclusion widths covering the entire design grid without $B_1^+$ map product interpolation. \nNote that the last case is equivalent to the original k-space domain method of Ref. \\cite{Katscher:2003:Magn-Reson-Med:12509830}.\nFor each design, flip angle RMSE (calculated using the spatial domain NUFFT) and root-mean-square RF amplitude were\nrecorded.\n\n\\subsection*{Gibbs Ringing}\nGibbs ringing commonly arises in spatial domain parallel pulse designs when the resolution of the \ndesign grid is similar to that of the excitation k-space trajectory. \nThe proposed k-space-domain method is implemented without wraparound or circulant end conditions in excitation k-space, \nso Gibbs ringing should be suppressed even when using a design grid that is only slightly wider than the trajectory. \nTo demonstrate this, \nthe target pattern and $B_1^+$ maps were further down-sampled to 32$\\times$32$\\times$24 (6 mm isotropic-resolution),\nand the outermost leaves of the SPINS trajectory which had duration 2.1 ms were excluded so that the maximum excitation \nresolution matched the 6 mm target pattern and $B_1^+$ map resolution. \nUsing this shorter 7.9 ms trajectory, \npulses were designed by the spatial domain method using both 32$\\times$32$\\times$24 and 64$\\times$64$\\times$48 grid sizes,\nand by the k-space-domain method for 32$\\times$32$\\times$24 grid size.\nThe Tikhonov regularization parameters for the 32$\\times$32$\\times$24 designs were set so that the RMS RF amplitudes produced \nby the k-space domain and spatial domain designs matched.\nThe designed pulses were then evaluated against the target pattern using the 128$\\times$128$\\times$96 grid size,\nto visualize the ringing.\n\n\\subsection*{Excitation k-Space Undersampling}\nAn important application of parallel transmission is the reduction of multidimensional pulse durations by excitation k-space undersampling.\n\\textcolor{blue}{To compare the spatial domain and k-space domain methods across undersampling factors,\nthe number of polar and azimuthal rotations in each segment of the SPINS trajectory were increased and reduced relative to the reference design described above, \nby factors of 0.5, 2, and 4. \nThat is, for a reduction factor of 0.5, the number of polar and azimuthal rotations in the trajectory were doubled for each of the three segments,\nand they were halved for a reduction factor of 2.\nThis yielded pulse durations of 20.5 ms (reduction factor 0.5), 5.3 ms (reduction factor 2), and 2.6 ms (reduction factor 4).} \\revbox{R2.1}\n\n\\subsection*{Off-Resonance}\nTo compare the off-resonance-compensated k-space domain designs with off-resonance-compensated spatial domain designs,\nwe incorporated a Gaussian ($\\sigma = 3$ cm) field map centered above the frontal sinus, \nwhich was designed to mimic the characteristic susceptibility-induced $B_0$ inhomogeneity in this part of the human brain. \nThe field maps were than scaled so that the maximum off-resonance reached +200 Hz and +400 Hz.\nA time-segmented approximate off-resonance model was calculated using the method of Ref. \\cite{fessler2005toeplitz} with $L = 4$ time segments,\nand this model was used in both spatial domain and k-space domain designs. \nBoth spatial domain and k-space domain designs used 32 parallel threads. \n\n\n", "meta": {"hexsha": "ce12a65bf3cc0c1631dc9517177c75433b32f869", "size": 10902, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/Manuscript_r1/Method.tex", "max_stars_repo_name": "wgrissom/kpTx", "max_stars_repo_head_hexsha": "b0f89ad298c8814570fa6df758d97ea3832b28d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-17T21:17:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-04T20:54:24.000Z", "max_issues_repo_path": "manuscript/Manuscript_r1/Method.tex", "max_issues_repo_name": "wgrissom/kpTx", "max_issues_repo_head_hexsha": "b0f89ad298c8814570fa6df758d97ea3832b28d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-12-01T10:38:17.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-03T11:18:22.000Z", "max_forks_repo_path": "manuscript/Manuscript_r1/Method.tex", "max_forks_repo_name": "wgrissom/kpTx", "max_forks_repo_head_hexsha": "b0f89ad298c8814570fa6df758d97ea3832b28d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 85.171875, "max_line_length": 190, "alphanum_fraction": 0.791597872, "num_tokens": 2653, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4155252658600208}}
{"text": "% !TEX root = ../00_thesis.tex\n\n% ------------------------------------------------------------------------------\n\\section{Single Mode Schedule Synthesis}\n\\label{sec:single_mode}\n% ------------------------------------------------------------------------------\n\\squarepar{%}\n\t\\TTW statically synthesizes the schedule of all tasks, messages, and communication rounds to meet real-time constraints by solving a MILP formulation.\n\tThis section presents how to solve it efficiently and ensure that the resulting schedule minimizes the number of communication rounds~\\objective{1}.\n\n\tThe schedule of a mode \\modeany is computed for one hyperperiod, after which it repeats itself.\n\tTo minimize the number of rounds used while handling computational complexity, we solve the problem sequentially, as described in~\\cref{alg:outerlayer}.\n\tEach formulation considers a fixed number of rounds $R_{\\mode{}}$ to be scheduled, starting with $R_{\\mode{}}=0$. The number of rounds is incremented until a feasible solution is found, or until the maximum number of rounds $R_{max}$ (the number of rounds that can ``fit'' into one hyperperiod) is reached.\n\tThus, \\cref{alg:outerlayer} guarantees by construction that if the problem is feasible, the synthesized schedule is optimal in terms of number of rounds used.%\n}\n\n\\begin{algorithm}\n\\begin{algorithmic}\n\\smaller\n\\Require\n\tmode \\mode{},\\;\n\t$\\app \\in \\mode{}$,\\;\n\t$\\tau.\\map$,\\;\n\t$\\tau.e$, \\;\n\t\\nslotsmax, \\;\n\t\\Toffset\n\\Ensure\n\t\\sched{M}\n\n\\State $LCM \\gets$ \\textit{hyperperiod}(\\mode{})\n\\State $R_{max} \\gets floor(LCM/\\Toffset)$\n\\State $R_{\\mode{}} \\gets 0$\n\n\\While{$R_{\\mode{}} \\leq R_{max}$}\n\t\\State formulate the MILP for mode \\mode{} using $R_{\\mode{}}$ rounds\n\t\\State [ \\sched{M}, \\textit{feasible} ] = \\textit{solve}( MILP )\n\t\\If {\\textit{feasible}}\n\t\t\\Return \\sched{M}\n\t\\EndIf\n\t\\State $R_{\\mode{}} \\gets R_{\\mode{}}+1$\n\\EndWhile\n\\State \\Return 'Problem infeasible'\n\\end{algorithmic}\n\\caption{\\small Pseudo-code of the single-mode schedule synthesis}\n\\label{alg:outerlayer}\n\\end{algorithm}\n\nThe MILP formulation contains a set of classical scheduling constraints:\n% \\begin{itemize}\n%\n% \t\\item\n\tThe precedence constraints between tasks and messages must be respected;\n\t%\n\t% \\item\n\tApplications end-to-end deadlines must be satisfied;\n\t%\n\t% \\item\n\tNodes process at most one task simultaneously;\n\t%\n\t% \\item\n\tCommunication rounds must not overlap;\n\t%\n\t% \\item\n\tRounds must not be allocated more then \\nslotsmax messages.\n%\n% \\end{itemize}\n\tThese constraints can be easily formulated using our system model (full formulation in \\cref{appendix:ttw_artifacts}).\n\tHowever, one must also guarantee that the allocation of messages to rounds is valid, \\ie\n\t\\begin{description}\n\t\t\\squarepar{%}\n\t\t\t\\item [\\constraint{1}]\n\t\t\tMessages must be served in rounds that start after their release time.%\n\t\t\t\\item [\\constraint{2}]\n\t\t\tMessages must be served in rounds that finish before their deadline.%\n\t\t}\n\t\\end{description}%\nIn other word, we must integrate the bin-packing problem of messages to rounds within the MILP formulation.\nThis is non-trivial and a major difference with the existing approaches for wired architectures~(\\eg \\cite{craciunas2016Combined}).\n\nTo address this challenge, we first formulate the constraints \\constraint{1} and \\constraint{2} using \\emph{arrival}, \\emph{demand}, and \\emph{service} functions, \\af \\df and \\sf, using network calculus~\\cite{leboudec2001Network}.\nThose functions count the number of message instances released, with passed deadlines, and served since the beginning of the hyperperiod, respectively.\nThese functions are illustrated in \\cref{fig:afdfsf}.\nIt must hold that\n\\begin{flalign}\n\\label{eq:df<sf<af}\n&\\forall\\, m_i \\in \\messageset, \\;\\forall\\, t,\n&&\\df_i(t) \\leq \\sf_i(t) \\leq \\af_i(t)\n&&\\\\\n\\label{eq:af_def}\n&\\text{with},\n&&\\af_i: \\; t \\;\n\t\\longmapsto \\; \\left \\lfloor{\\frac{t-m_i.o}{m_i.p}}\\right \\rfloor \t+ 1\n\t&&\\\\\n\\label{eq:df_def}\n&\\text{and},\n&&\\df_i: \\; t \\;\n\t\\longmapsto \\; \\left \\lceil{\\frac{t-m_i.o-m_i.d}{m_i.p}}\\right \\rceil\n\t&&\n\\end{flalign}\n\nHowever, as the service function stays constant between the rounds, we can formulate \\constraint{1} and \\constraint{2} as follows\\\\\n$\\forall\\, m_i \\in \\messageset, \\; \\forall\\, j \\in [1 .. R_{\\mode{}}], $\n\\begin{flalign}\n\\label{eq:af_const}\n&\\textup{\\constraint{1}} \\quad  : \\quad\n\t&\\sf_i(r_j.t + \\Tround) \\, &\\leq \\, \\af_i(r_j.t)\n\t&&\n\\\\\n\\label{eq:df_const}\n&\\textup{\\constraint{2}} \\quad  : \\quad\n\t&\\sf_i(r_j.t)  \\, &\\geq \\, \\df_i(r_j.t + \\Tround)\n\t&&\n\\end{flalign}\n\n\\begin{figure}\n\\centering\n\\includegraphics[scale=1]{afdfsf}\n\\caption{Representation of arrival, demand, and service functions of message $m_i$.\nThe lower part shows the five round, $r_1$ to $r_5$, scheduled for the hyperperiod.\n\\capt{%\n$m_i$ is allocated a slot in the colored rounds, \\ie $r_1$, $r_2$, and $r_4$.\nThe allocation of $m_i$ to $r_3$ instead of $r_2$ would be invalid, as $r_3$ does not finish before the message deadline, \\ie it violates \\constraint{2}.\nHowever, the allocation of $m_i$ to $r_5$ instead of $r_1$ would be valid and result in $r_0.B_i = 0$.}\n}\n\\label{fig:afdfsf}\n\\end{figure}\n\n\nThe arrival and demand functions are step functions. They cannot be used directly in an MILP formulation, however\n\\begin{flalign}\n\\label{eq:af=k}\n&\\forall \\; k \\in \\mathbb{N}, \\quad\n&&\\af_i(t) = k\n\t\\quad \\Leftrightarrow \\quad\n\t0 \\, \\leq \\, t - m_i.o - (k-1)m_i.p \\,<\\, m_i.p &&\\\\\n&\\text{and} %\\hspace{30pt}\n&&\\df_i(t) = k\n\\label{eq:df=k}\n\t\\quad \\Leftrightarrow \\quad\n\t0 \\, < \\, t - m_i.o - m_i.d - (k-1)m_i.p \\,\\leq\\, m_i.p &&\n\\end{flalign}\n\nFor each message $m_i\\in \\messageset$ and each round $r_j$, $j \\in [1..R_{\\mode{}}]$, we introduce two integer variables $k^a_{ij}$ and $k^d_{ij}$ that we constraint to take the values of \\af and \\df at the time points of interest (respectively $r_j.t$ and $r_j.t + \\Troundj$). That is,\n\\begin{align}\n\\label{eq:ka} %\\qquad\n0 \\, \\leq \\, r_j.t\n\t&-m_i.o - (k^a_{ij}-1)m_i.p \\,<\\, m_i.p\\\\\n\\label{eq:kd} %\\qquad\n0 \\, < \\, r_j.t\n\t&+\\Troundj - m_i.o - m_i.d - (k^d_{ij}-1)m_i.p \\,\\leq\\, m_i.p\\\\\n\\notag\n\\text{Thus,} \\hspace{15pt} &\\eqref{eq:ka} \\quad \\Leftrightarrow  \\quad\n\t \\af_i(r_j.t) = k^a_{ij} \\\\\n\\notag\n\t&\\eqref{eq:kd} \\quad \\Leftrightarrow \\quad\n\t\\df_i(r_j.t + \\Troundj) = k^d_{ij}\n\\end{align}\n\nFinally, we must express the service function \\sf, which counts the number of message instances served \\emph{at the end} of each round.\nRemember that $r_k.B_s$ denotes the allocation of the $s$-{th} slot of $r_k$ (\\ie the $id$ of the message allocated to the slot).\nFor any time $t \\in \\; [ \\; r_{j}.t + \\Troundj \\, ; \\,  r_{j+1}.t + \\Troundj \\; [$, the number of instances of message $m_i$ served is\n\\begin{align*}\n\t\\sum_{\\substack{k = 1}}^{j} \\;\\;\n\t\\sum_{\\substack{s = 1}}^{B}\n\t \\; r_k.B_s\n\t \\quad s.t. \\; B_s = i\n\\end{align*}\n\nIt may be that $m.o + m.d > m.p$, resulting in $\\df(0)=-1$ (\\cref{eq:df_def}), like it is the case in \\cref{fig:afdfsf}. This ``means'' that a message released at the each of one hyperperiod will have its deadline in the \\emph{next} hyperperiod.\nTo account for this situation, we introduce, for each message $m_i$, a variable $r_0.B_i$ set to the number of such ``leftover'' message instances at $t=0$. Finally, for each message $m_i \\in \\messageset$, and  $t \\in \\; [ \\; r_{j}.t + \\Troundj \\, ; \\,  r_{j+1}.t + \\Troundj \\; [$,\n\\begin{flalign}\n\\label{eq:sf_def}\n\\sf_i: \\; t \\;\n\t&\\longmapsto \\;\n\t\\sum_{\\substack{k = 1 \\\\[2pt]s.t. \\; r_k.t + \\Troundk \\, < \\, t}}^{j}\\;\\;\n\t\\sum_{\\substack{s = 1 \\\\[2pt]s.t. \\; B_s = i}}^{B}\n\t r_k.B_s - r_0.B_i\n\\end{flalign}\n\nUltimately, \\constraint{1} and \\constraint{2} can be formulated as MILP constraints using \\cref{eq:ka,eq:kd}, and the following two equations:\n\\begin{align}\n&\n\\eqref{eq:af_const}\\quad\t \\Leftrightarrow\n\t\\quad\n\t\\sum_{k = 1}^j\n\t\\sum_{\\substack{s = 1 \\\\[2pt]s.t. \\; B_s = i}}^{B}\n\t \\; r_k.B_s - r_0.B_i \\; \\leq\\;  k^a_{ij}\n\\\\\n&\n\\eqref{eq:df_const}\\quad\t \\Leftrightarrow\n\t\\quad\n\t\\sum_{k = 1}^{j-1}\n\t\\sum_{\\substack{s = 1 \\\\[2pt]s.t. \\; B_s = i}}^{B} \\; r_k.B_s - r_0.B_i\n\t\\; \\geq\\;\n\tk^d_{ij}\n\\end{align}\n\n\n\\fakepar{Objective function}\nWithin our scheduling framework, the MILP does not need to optimize any objective function. Indeed, we mainly want to minimize of the number of rounds $R$ used in the schedule, which is achieved by incrementally increasing the number of rounds until a valid schedule is found~(\\cref{alg:outerlayer}).\n\nHowever, when considering the multi-mode case~(\\cref{sec:multi_mode}), it is beneficial to maximize the message deadlines, as illustrated in \\cref{fig:msg_deadline_maximization}.\nIn a nutshell, it relaxes the constraints that are inherited between different modes, and therefore improve the schedulability of the whole problem.\nConcretely, the deadline maximization is achieved by setting the following objective to the MILP solver\n\\begin{align}\n&obj \\; = \\; \\sum_{m_i\\in \\messageset} \\, m_i.d\n\\end{align}\n\n\n\\begin{figure}\n\t\\begin{subfigure}[t]{.48\\linewidth}\n\t\\centering\n\t\\includegraphics[scale=1]{msg_deadline_base}\n\t\\caption{%\n\tExample schedule without deadline maximization.\n\t}\n\t\\label{subfig:msg_deadline_base}\n\t\\end{subfigure}%\n\t\\hfill\n\t\\begin{subfigure}[t]{.48\\linewidth}\n\t\\centering\n\t\\includegraphics[scale=1]{msg_deadline_maximized}\n\t\\caption{%\n\tExample schedule with deadline maximization}\n\t\\label{subfig:msg_deadline_maximized}\n\t\\end{subfigure}\n\t\\caption{Illustration of the impact of the message deadlines maximization.\n\t\\capt{%\n\t\tIf~\\cref{subfig:msg_deadline_base} is a valid schedule, then \\cref{subfig:msg_deadline_maximized} is also valid, but it\n\t\trelaxes the constraints on other modes which also contain message $m$.\n\t\tMaximizing the message deadlines improves the schedulability of the multi-mode problem~(\\cref{sec:multi_mode}).\n\t}}\n\t\\label{fig:msg_deadline_maximization}\n\\end{figure}\n", "meta": {"hexsha": "55995422cbe4f432df17b71f897ed92d41c10588", "size": 9772, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "50_TTW/5_single_mode.tex", "max_stars_repo_name": "romain-jacob/doctoral-theis", "max_stars_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "50_TTW/5_single_mode.tex", "max_issues_repo_name": "romain-jacob/doctoral-theis", "max_issues_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "50_TTW/5_single_mode.tex", "max_forks_repo_name": "romain-jacob/doctoral-theis", "max_forks_repo_head_hexsha": "fd21e9f0cddeda91821eb061c9ab12df9f610da9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5829787234, "max_line_length": 307, "alphanum_fraction": 0.6910560786, "num_tokens": 3211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4155252658600208}}
{"text": "\\documentclass{article} % For LaTeX2e\n\\usepackage{nips12submit_e,times}\n%\\documentstyle[nips12submit_09,times,art10]{article} % For LaTeX 2.09\n\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n\\title{Chapter 3\\\\Conditional Probability and Independence}\n\n\n\\author{\n%Min Xiao \\\\\n%Department of Computer and Information Science\\\\\n%Temple University\\\\\n%Philadelphia, PA 19122 \\\\\n%\\texttt{minxiao@temple.edu} \n}\n\n% The \\author macro works with any number of authors. There are two commands\n% used to separate the names and addresses of multiple authors: \\And and \\AND.\n%\n% Using \\And between authors leaves it to \\LaTeX{} to determine where to break\n% the lines. Using \\AND forces a linebreak at that point. So, if \\LaTeX{}\n% puts 3 of 4 authors names on the first line, and the last on the second\n% line, try using \\AND instead of \\And before the third author name.\n\n\\newcommand{\\fix}{\\marginpar{FIX}}\n\\newcommand{\\new}{\\marginpar{NEW}}\n\n\\nipsfinalcopy % Uncomment for camera-ready version\n\n\\begin{document}\n\n\n\\maketitle\n\n\\section{Summary}\n\n\\begin{itemize}\n\\item The {\\em conditional probability} of A given C is\n\\begin{align}\nP(A|C) = \\frac{P(A\\cap C)}{P(C)}, P(C) >0\n\\end{align}\n\\item The {\\em multiplication rule}. For any events A and C, \n\\begin{align}\nP(A \\cap C) & = P(C) \\cdot P(A|C) \\\\\n& = P(A) \\cdot P(C|A)\n\\end{align}\n\\item The {\\em law of total probability}. Suppose $C_1, C_2, \\ldots, C_m$ are disjoint events such that $C_1 \\cup C_2 \\cup \\cdots \\cup C_m = \\Omega$. The probability of an arbitrary event A can be expressed as:\n\\begin{align}\nP(A) = P(A|C_1)P(C_1)+P(A|C_2)P(C_2)+\\cdots+P(A|C_m)P(C_m)\n\\end{align}\n\\item {\\em Bayes' rule}. Suppose the events $C_1, C_2, \\ldots, C_m$ are disjoint and $C_1 \\cup C_2 \\cup \\cdots \\cup C_m = \\Omega$. The conditional probability of $C_i$, given an arbitrary event $A$, can be expressed as: \n\\begin{align}\nP(C_i|A) = \\frac{P(A|C_i)\\cdot P(C_i)}{P(A|C_1)P(C_1)+P(A|C_2)P(C_2)+\\cdots +P(A|C_m)P(C_m)}\n\\end{align}\n\\item Independence vs Dependence \n\\begin{itemize}\n\\item An event A is called independent of B if\n\\begin{align}\nP(A|B) = P(A)\n\\end{align}\n\\item To show that A and B are independent it suffices to prove just one of the following:\n\\begin{align}\nP(A|B) = & P(A) \\\\\nP(B|A) = & P(B) \\\\\nP(A\\cap B) = & P(A)P(B)\n\\end{align}\nwhere A may be replaced by $A^c$ and B replaced by $B^c$, or both. If one of these statements holds, all of them are true. If two events are not independent, they are dependent. \n\\item Independence of two or more events. Events $A_1, A_2, \\ldots, A_m$ are called independent if \n\\begin{align}\nP(A_1\\cap A_2 \\cap A_3 \\cdots A_m) = P(A_1) P(A_2) \\cdots P(A_m)\n\\end{align}\nand this statement also holds when any number of the events $A_1, A_2, \\ldots, A_m$ are replaced by their complements throught the formula.  \n\\end{itemize}\n\\end{itemize}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "1c2f5d1601cf0556e3c24b45e297d17dd97f3148", "size": 2828, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CIS2033/2033/HW/Chapter3/Chapter3_summary.tex", "max_stars_repo_name": "nymph332088/nymph332088.github.io", "max_stars_repo_head_hexsha": "4897065325b7656539572f2a80f67c8fc80b4110", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CIS2033/2033/HW/Chapter3/Chapter3_summary.tex", "max_issues_repo_name": "nymph332088/nymph332088.github.io", "max_issues_repo_head_hexsha": "4897065325b7656539572f2a80f67c8fc80b4110", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CIS2033/2033/HW/Chapter3/Chapter3_summary.tex", "max_forks_repo_name": "nymph332088/nymph332088.github.io", "max_forks_repo_head_hexsha": "4897065325b7656539572f2a80f67c8fc80b4110", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.9135802469, "max_line_length": 220, "alphanum_fraction": 0.7072135785, "num_tokens": 953, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.4153467384575067}}
{"text": "\\section{Conclusion}\n\nIn this paper we have introduced a novel approach to understanding the quality\nof an algorithm by exploring the space in which their well-performing datasets\nexist. Following a detailed explanation of its internal mechanisms, a case study\nin \\(k\\)-means clustering was offered as validation for the method. The method\nutilises biological operators to traverse the space of all possible datasets in\nan organic way with a minimal external framework attached. The generative nature\nof the proposed method also provides transparency and richness to the solution\nwhen compared to other contemporary techniques for artificial data generation as\nthe entire history of individuals is preserved.\n\nThe evolutionary dataset optimisation method is dependent on a number of\nparameters set out in this paper and perhaps the most important of which is the\nchoice of distribution families, \\(\\mathcal{P}\\); these families set out the\ngeneral statistical shape of the columns of the datasets that are produced and\nalso control the present data types. The relationship between columns and their\nassociated distribution is not causal and appropriate methods should be\nemployed to understand the structure and characteristics of the data produced\nbefore formal conclusions are made as set out in the examples provided.\n", "meta": {"hexsha": "0e15f2c736bab008360f2f6aa2e34efe7d8a99e5", "size": 1321, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/conclusion.tex", "max_stars_repo_name": "daffidwilde/edo-paper", "max_stars_repo_head_hexsha": "5bd803f7fe52a7043ce39fbec0ae7974ce89029a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/conclusion.tex", "max_issues_repo_name": "daffidwilde/edo-paper", "max_issues_repo_head_hexsha": "5bd803f7fe52a7043ce39fbec0ae7974ce89029a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/conclusion.tex", "max_forks_repo_name": "daffidwilde/edo-paper", "max_forks_repo_head_hexsha": "5bd803f7fe52a7043ce39fbec0ae7974ce89029a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.9047619048, "max_line_length": 80, "alphanum_fraction": 0.829674489, "num_tokens": 241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.41534673535163363}}
{"text": "\\nwfilename{_src/day/2019/01.nw}\\nwbegindocs{0}\\newpage% ===> this file was generated automatically by noweave --- better not edit it\n\\chapter{Day 1: The Tyranny of the Rocket Equation}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/1}}\n\\nwenddocs{}\\nwfilename{_src/gap/2019/01.nw}\\nwbegindocs{0}\\section{GAP Solution}\n\n\\begin{marginfigure}\n\\[\n \\text{fuel} := \\text{mass} \\backslash 3 - 2\n\\]\n\\end{marginfigure}\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW2vDOcF-3gOu99-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-1}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{\\relax}{NW2vDOcF-3gOu99-2}\\nwenddeflinemarkup\nFuelRequiredModule := function( mass )\n    return Int( Float( mass / 3 ) ) - 2;\nend;;\n\n\n\\nwalsodefined{\\\\{NW2vDOcF-3gOu99-2}\\\\{NW2vDOcF-3gOu99-3}\\\\{NW2vDOcF-3gOu99-4}}\\nwnotused{Day01.g}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW2vDOcF-3gOu99-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-2}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW2vDOcF-3gOu99-1}{NW2vDOcF-3gOu99-3}\\nwenddeflinemarkup\nPartOne := function( )\n    local input, line, mass, sum;;\n    sum := 0;\n    input := InputTextFile ( \"./input/day01.txt\" );\n    line := ReadLine( input );\n    repeat\n        mass := Int( Chomp( line ) );\n        sum := sum + FuelRequiredModule( mass );\n        line := ReadLine( input );\n    until line = fail or IsEndOfStream( input );\n    return sum;\nend;;\n\n\n\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW2vDOcF-3gOu99-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-3}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW2vDOcF-3gOu99-2}{NW2vDOcF-3gOu99-4}\\nwenddeflinemarkup\nTotalFuelRequiredModule := function( mass )\n    local fuel;;\n    fuel := FuelRequiredModule( mass );\n    if IsPosInt( fuel ) then\n        return fuel + TotalFuelRequiredModule( fuel );\n    else\n        return 0;\n    fi;\nend;;\n\n\n\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW2vDOcF-3gOu99-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-4}}}\\moddef{Day01.g~{\\nwtagstyle{}\\subpageref{NW2vDOcF-3gOu99-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwprevnextdefs{NW2vDOcF-3gOu99-3}{\\relax}\\nwenddeflinemarkup\nPartTwo := function( )\n    local input, line, mass, sum;;\n    sum := 0;\n    input := InputTextFile ( \"./input/day01.txt\" );\n    line := ReadLine( input );\n    repeat\n        mass := Int( Chomp( line ) );\n        sum := sum + TotalFuelRequiredModule( mass );\n        line := ReadLine( input );\n    until line = fail or IsEndOfStream( input );\n    return sum;\nend;;\n\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\\nwenddocs{}\\nwfilename{_src/day/2019/04.nw}\\nwbegindocs{0}\\newpage\n\\chapter{Day 4: Secure Container}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/4}}\n\\nwenddocs{}\\nwfilename{_src/haskell/2019/04.nw}\\nwbegindocs{0}\\section{Haskell Solution}\n\n\\subsection{Input}\n\nMy puzzle input was the range \\text{236491-713787}, which I converted into a\nlist of lists of \\hs{digits}.\n\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW2iNnUA-1GvnV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-1GvnV-1}}}\\moddef{Input~{\\nwtagstyle{}\\subpageref{NW2iNnUA-1GvnV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}}\\nwenddeflinemarkup\ninput :: [[Int]]\ninput = digits 10 <$> [236491 .. 713787]\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\n\\subsection{Part One}\n\nFor part one, there must be two adjacent digits that are the same, i.e. there\nexists at least one \\hs{group} of \\hs{length} \\hs{>= 2}.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW2iNnUA-2cQo0j-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-2cQo0j-1}}}\\moddef{has a double~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2cQo0j-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nany ((>= 2) . length) . group\n\\nwnotused{has a double}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\nIt must also be the case that the \\hs{digits} never decrease,\ni.e. the password \\hs{isSorted}.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW2iNnUA-2iOjQS-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{\\relax}{NW2fbesT-2iOjQS-1}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} :: Int\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} = length $ filter isPossiblePassword input\n  where\n    isPossiblePassword :: [Int] -> Bool\n    isPossiblePassword = liftM2 (&&) isSorted hasDouble\n    hasDouble :: Eq a => [a] -> Bool\n    hasDouble = any ((>= 2) . length) . group\n\\nwalsodefined{\\\\{NW2fbesT-2iOjQS-1}\\\\{NW2fbesT-2iOjQS-2}\\\\{NW2fbesT-2iOjQS-3}\\\\{NW2fbesT-2iOjQS-4}}\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW2iNnUA-2iOjQS-1}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\n\\subsection{Part Two}\n\nFor part two, the password still \\hs{isSorted}, but must also have a strict\ndouble, i.e. at least one \\hs{group} of \\hs{length} \\hs{== 2}.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW2iNnUA-ntEfn-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-ntEfn-1}}}\\moddef{has a strict double~{\\nwtagstyle{}\\subpageref{NW2iNnUA-ntEfn-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nany ((== 2) . length) . group\n\\nwnotused{has a strict double}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW2iNnUA-4P9qKy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-4P9qKy-1}}}\\moddef{Part Two~{\\nwtagstyle{}\\subpageref{NW2iNnUA-4P9qKy-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{\\relax}{NW2fbesT-4P9qKy-1}\\nwenddeflinemarkup\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} :: Int\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} = length $ filter isPossiblePassword input\n  where\n    isPossiblePassword :: [Int] -> Bool\n    isPossiblePassword = liftM2 (&&) isSorted hasDouble\n    hasDouble :: Eq a => [a] -> Bool\n    hasDouble = any ((== 2) . length) . group\n\\nwalsodefined{\\\\{NW2fbesT-4P9qKy-1}}\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwindexuse{\\nwixident{partTwo}}{partTwo}{NW2iNnUA-4P9qKy-1}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\n\n\\subsection{Full Solution}\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW2iNnUA-15Rjc8-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2iNnUA-15Rjc8-1}}}\\moddef{Day04.hs~{\\nwtagstyle{}\\subpageref{NW2iNnUA-15Rjc8-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nmodule AdventOfCode.Year2019.Day04 where\n\nimport Control.Monad (liftM2)\nimport Data.Digits (digits)\nimport Data.List (group)\nimport Data.List.Ordered (isSorted)\n\n\\LA{}Input~{\\nwtagstyle{}\\subpageref{NW2iNnUA-1GvnV-1}}\\RA{}\n\n\\LA{}Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}\\RA{}\n\n\\LA{}Part Two~{\\nwtagstyle{}\\subpageref{NW2iNnUA-4P9qKy-1}}\\RA{}\n\\nwnotused{Day04.hs}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\\nwenddocs{}\\nwfilename{_src/day/2019/08.nw}\\nwbegindocs{0}\\newpage\n\\chapter{Day 8: }\\todor{Add missing title}\n\\todoo{Copy description}\n\\marginnote{\\url{https://adventofcode.com/2019/day/8}}\n\\nwenddocs{}\\nwfilename{_src/haskell/2019/08.nw}\\nwbegindocs{0}\\section{Haskell solution}\n\n\\subsection{Pixels}\n\n\nA pixel can be black, white, or transparent.\n\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW2fbesT-2M5oYw-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-2M5oYw-1}}}\\moddef{Define a Pixel data type~{\\nwtagstyle{}\\subpageref{NW2fbesT-2M5oYw-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\ndata \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1}\n  = \\nwlinkedidentc{Black}{NW2fbesT-2M5oYw-1}\n  | \\nwlinkedidentc{White}{NW2fbesT-2M5oYw-1}\n  | \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1}\n  deriving (Enum, Eq)\n\\nwindexdefn{\\nwixident{Pixel}}{Pixel}{NW2fbesT-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{Black}}{Black}{NW2fbesT-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{White}}{White}{NW2fbesT-2M5oYw-1}\\eatline\n\\nwindexdefn{\\nwixident{Transparent}}{Transparent}{NW2fbesT-2M5oYw-1}\\eatline\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\nShow black pixels as spaces, white ones as hashes, and transparent as dots.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW2fbesT-QyGx2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-QyGx2-1}}}\\moddef{Implement \\hs{Show} for \\code{}Pixel\\edoc{}~{\\nwtagstyle{}\\subpageref{NW2fbesT-QyGx2-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\ninstance Show \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1} where\n  show \\nwlinkedidentc{Black}{NW2fbesT-2M5oYw-1} = \" \"\n  show \\nwlinkedidentc{White}{NW2fbesT-2M5oYw-1} = \"#\"\n  show \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1} = \".\"\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW2fbesT-QyGx2-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW2fbesT-QyGx2-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW2fbesT-QyGx2-1}\\nwindexuse{\\nwixident{White}}{White}{NW2fbesT-QyGx2-1}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\n\\subsection{Type aliases}\n\nDefine a {\\Tt{}\\nwlinkedidentq{Layer}{NW2fbesT-LSl4Q-1}\\nwendquote} as a list of {\\Tt{}\\nwlinkedidentq{Row}{NW2fbesT-LSl4Q-1}\\nwendquote}s, and a {\\Tt{}\\nwlinkedidentq{Row}{NW2fbesT-LSl4Q-1}\\nwendquote} as a list of {\\Tt{}\\nwlinkedidentq{Pixel}{NW2fbesT-2M5oYw-1}\\nwendquote}s.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW2fbesT-LSl4Q-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-LSl4Q-1}}}\\moddef{Define a few convenient type aliases~{\\nwtagstyle{}\\subpageref{NW2fbesT-LSl4Q-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\ntype \\nwlinkedidentc{Image}{NW2fbesT-LSl4Q-1} = [\\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1}]\n\ntype \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1} = [\\nwlinkedidentc{Row}{NW2fbesT-LSl4Q-1}]\n\ntype \\nwlinkedidentc{Row}{NW2fbesT-LSl4Q-1} = [\\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1}]\n\\nwindexdefn{\\nwixident{Image}}{Image}{NW2fbesT-LSl4Q-1}\\eatline\n\\nwindexdefn{\\nwixident{Layer}}{Layer}{NW2fbesT-LSl4Q-1}\\eatline\n\\nwindexdefn{\\nwixident{Row}}{Row}{NW2fbesT-LSl4Q-1}\\eatline\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Row}}{Row}}}\\nwidentuses{\\\\{{\\nwixident{Pixel}}{Pixel}}}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW2fbesT-LSl4Q-1}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\subsection{Parsers}\n\nParse an {\\Tt{}\\nwlinkedidentq{Image}{NW2fbesT-LSl4Q-1}\\nwendquote}, i.e. one or more {\\Tt{}\\nwlinkedidentq{Layer}{NW2fbesT-LSl4Q-1}\\nwendquote}s comprised of \\hs{height}\n{\\Tt{}\\nwlinkedidentq{Row}{NW2fbesT-LSl4Q-1}\\nwendquote}s of \\hs{width} {\\Tt{}\\nwlinkedidentq{Pixel}{NW2fbesT-2M5oYw-1}\\nwendquote}s.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW2fbesT-4aeb4o-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-4aeb4o-1}}}\\moddef{Parse an image~{\\nwtagstyle{}\\subpageref{NW2fbesT-4aeb4o-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{image}{NW2fbesT-4aeb4o-1} :: Int -> Int -> Parser \\nwlinkedidentc{Image}{NW2fbesT-LSl4Q-1}\n\\nwlinkedidentc{image}{NW2fbesT-4aeb4o-1} width height = some layer\n  where\n    layer :: Parser \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1}\n    layer = count height row\n    row :: Parser \\nwlinkedidentc{Row}{NW2fbesT-LSl4Q-1}\n    row = count width pixel\n\\nwindexdefn{\\nwixident{image}}{image}{NW2fbesT-4aeb4o-1}\\eatline\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{image}}{image}}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Row}}{Row}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW2fbesT-4aeb4o-1}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW2fbesT-4aeb4o-1}\\nwindexuse{\\nwixident{Row}}{Row}{NW2fbesT-4aeb4o-1}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\nParse an encoded black, white, or transparent pixel.\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW2fbesT-1aCFXy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-1aCFXy-1}}}\\moddef{Parse a pixel~{\\nwtagstyle{}\\subpageref{NW2fbesT-1aCFXy-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\npixel :: Parser \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1}\npixel =\n  (char '0' *> pure \\nwlinkedidentc{Black}{NW2fbesT-2M5oYw-1} <?> \"A black pixel\")\n    <|> (char '1' *> pure \\nwlinkedidentc{White}{NW2fbesT-2M5oYw-1} <?> \"A white pixel\")\n    <|> (char '2' *> pure \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1} <?> \"A transparent pixel\")\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW2fbesT-1aCFXy-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW2fbesT-1aCFXy-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW2fbesT-1aCFXy-1}\\nwindexuse{\\nwixident{White}}{White}{NW2fbesT-1aCFXy-1}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\n\\subsection{Part One}\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW2fbesT-2iOjQS-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-2iOjQS-1}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{NW2iNnUA-2iOjQS-1}{NW2fbesT-2iOjQS-2}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} :: IO Int\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} =\n  do\n    \\LA{}Parse a $25 \\times 6$ \\code{}image\\edoc{} from the input~{\\nwtagstyle{}\\subpageref{NW2fbesT-276JRG-1}}\\RA{}\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW2fbesT-2iOjQS-1}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NW2fbesT-276JRG-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-276JRG-1}}}\\moddef{Parse a $25 \\times 6$ \\code{}image\\edoc{} from the input~{\\nwtagstyle{}\\subpageref{NW2fbesT-276JRG-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-2iOjQS-1}}\\nwenddeflinemarkup\nlayers <- parseInput (\\nwlinkedidentc{image}{NW2fbesT-4aeb4o-1} 25 6) \"input/2019/day08.txt\"\n\\nwused{\\\\{NW2fbesT-2iOjQS-1}}\\nwidentuses{\\\\{{\\nwixident{image}}{image}}}\\nwindexuse{\\nwixident{image}}{image}{NW2fbesT-276JRG-1}\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\n\nFind the \\hs{layer} with the fewest zeros\\todoo{sp?}, i.e. {\\Tt{}\\nwlinkedidentq{Black}{NW2fbesT-2M5oYw-1}\\nwendquote} pixels.\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NW2fbesT-2iOjQS-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-2iOjQS-2}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{NW2fbesT-2iOjQS-1}{NW2fbesT-2iOjQS-3}\\nwenddeflinemarkup\n    let layer = head $ sortBy (compare `on` numberOf \\nwlinkedidentc{Black}{NW2fbesT-2M5oYw-1}) layers\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Black}}{Black}}}\\nwindexuse{\\nwixident{Black}}{Black}{NW2fbesT-2iOjQS-2}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\n\nReturn the product of the number of ones ({\\Tt{}\\nwlinkedidentq{White}{NW2fbesT-2M5oYw-1}\\nwendquote} pixels) and the number of\ntwos ({\\Tt{}\\nwlinkedidentq{Transparent}{NW2fbesT-2M5oYw-1}\\nwendquote} pixels) in that \\hs{layer}.\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NW2fbesT-2iOjQS-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-2iOjQS-3}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{NW2fbesT-2iOjQS-2}{NW2fbesT-2iOjQS-4}\\nwenddeflinemarkup\n    let ones = numberOf \\nwlinkedidentc{White}{NW2fbesT-2M5oYw-1} layer\n    let twos = numberOf \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1} layer\n    pure $ ones * twos\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Transparent}}{Transparent}}\\\\{{\\nwixident{White}}{White}}}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW2fbesT-2iOjQS-3}\\nwindexuse{\\nwixident{White}}{White}{NW2fbesT-2iOjQS-3}\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\n\nReturn the number of elements equivalent to a given one, in a given list of\nlists of elements of the same type. More specifically, return the number of\n{\\Tt{}\\nwlinkedidentq{Pixel}{NW2fbesT-2M5oYw-1}\\nwendquote}s of a given color in a given {\\Tt{}\\nwlinkedidentq{Layer}{NW2fbesT-LSl4Q-1}\\nwendquote}.\n\n\\todoo{There's gotta be a Data.List function for this..}\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NW2fbesT-2iOjQS-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-2iOjQS-4}}}\\moddef{Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{NW2fbesT-2iOjQS-3}{\\relax}\\nwenddeflinemarkup\n  where\n    numberOf :: Eq a => a -> [[a]] -> Int\n    numberOf x = sum . fmap (length . filter (== x))\n\\nwindexdefn{\\nwixident{partOne}}{partOne}{NW2fbesT-2iOjQS-4}\\eatline\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\n\\subsection{Part Two}\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NW2fbesT-4P9qKy-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-4P9qKy-1}}}\\moddef{Part Two~{\\nwtagstyle{}\\subpageref{NW2iNnUA-4P9qKy-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwprevnextdefs{NW2iNnUA-4P9qKy-1}{\\relax}\\nwenddeflinemarkup\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} :: IO String\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} =\n  do\n    layers <- parseInput (\\nwlinkedidentc{image}{NW2fbesT-4aeb4o-1} 25 6) \"input/2019/day08.txt\"\n    pure\n      $ unlines . map (concatMap show)\n      $ foldl decodeLayer (transparentLayer 25 6) layers\n  where\n    decodeLayer :: \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1} -> \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1} -> \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1}\n    decodeLayer = zipWith (zipWith decodePixel)\n    decodePixel :: \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1} -> \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1} -> \\nwlinkedidentc{Pixel}{NW2fbesT-2M5oYw-1}\n    decodePixel \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1} below = below\n    decodePixel above _ = above\n\\nwindexdefn{\\nwixident{partTwo}}{partTwo}{NW2fbesT-4P9qKy-1}\\eatline\n\\nwused{\\\\{NW2iNnUA-15Rjc8-1}\\\\{NW2fbesT-19Srvv-1}}\\nwidentdefs{\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwidentuses{\\\\{{\\nwixident{image}}{image}}\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Pixel}}{Pixel}}\\\\{{\\nwixident{Transparent}}{Transparent}}}\\nwindexuse{\\nwixident{image}}{image}{NW2fbesT-4P9qKy-1}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW2fbesT-4P9qKy-1}\\nwindexuse{\\nwixident{Pixel}}{Pixel}{NW2fbesT-4P9qKy-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW2fbesT-4P9qKy-1}\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\n\\subsection{Miscellaneous}\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NW2fbesT-dIQyV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-dIQyV-1}}}\\moddef{A transparent layer~{\\nwtagstyle{}\\subpageref{NW2fbesT-dIQyV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2fbesT-19Srvv-1}}\\nwenddeflinemarkup\ntransparentLayer :: Int -> Int -> \\nwlinkedidentc{Layer}{NW2fbesT-LSl4Q-1}\ntransparentLayer width height = replicate height (replicate width \\nwlinkedidentc{Transparent}{NW2fbesT-2M5oYw-1})\n\\nwused{\\\\{NW2fbesT-19Srvv-1}}\\nwidentuses{\\\\{{\\nwixident{Layer}}{Layer}}\\\\{{\\nwixident{Transparent}}{Transparent}}}\\nwindexuse{\\nwixident{Layer}}{Layer}{NW2fbesT-dIQyV-1}\\nwindexuse{\\nwixident{Transparent}}{Transparent}{NW2fbesT-dIQyV-1}\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\n\n\\subsection{Full solution}\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NW2fbesT-19Srvv-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2fbesT-19Srvv-1}}}\\moddef{Day08.hs~{\\nwtagstyle{}\\subpageref{NW2fbesT-19Srvv-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nmodule AdventOfCode.Year2019.Day08\n  ( \\nwlinkedidentc{main}{NW2fbesT-19Srvv-1},\n    \\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4},\n    \\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1},\n  )\nwhere\n\nimport AdventOfCode.Util (parseInput)\nimport Control.Applicative ((<|>))\nimport Data.Function (on)\nimport Data.List (sortBy)\nimport Text.Trifecta ((<?>), Parser, char, count, some)\n\n\\LA{}Define a Pixel data type~{\\nwtagstyle{}\\subpageref{NW2fbesT-2M5oYw-1}}\\RA{}\n\n\\LA{}Implement \\hs{Show} for \\code{}Pixel\\edoc{}~{\\nwtagstyle{}\\subpageref{NW2fbesT-QyGx2-1}}\\RA{}\n\n\\LA{}Define a few convenient type aliases~{\\nwtagstyle{}\\subpageref{NW2fbesT-LSl4Q-1}}\\RA{}\n\n\\nwlinkedidentc{main}{NW2fbesT-19Srvv-1} :: IO ()\n\\nwlinkedidentc{main}{NW2fbesT-19Srvv-1} =\n  do\n    putStrLn \"[2019] Day 8: Space \\nwlinkedidentc{Image}{NW2fbesT-LSl4Q-1} Format\"\n    putStr \"Part One: \"\n    print =<< \\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4}\n    putStrLn \"Part Two: \"\n    putStrLn =<< \\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1}\n\n\\LA{}Part One~{\\nwtagstyle{}\\subpageref{NW2iNnUA-2iOjQS-1}}\\RA{}\n\n\\LA{}Part Two~{\\nwtagstyle{}\\subpageref{NW2iNnUA-4P9qKy-1}}\\RA{}\n\n\\LA{}Parse an image~{\\nwtagstyle{}\\subpageref{NW2fbesT-4aeb4o-1}}\\RA{}\n\n\\LA{}Parse a pixel~{\\nwtagstyle{}\\subpageref{NW2fbesT-1aCFXy-1}}\\RA{}\n\n\\LA{}A transparent layer~{\\nwtagstyle{}\\subpageref{NW2fbesT-dIQyV-1}}\\RA{}\n\\nwindexdefn{\\nwixident{main}}{main}{NW2fbesT-19Srvv-1}\\eatline\n\\nwnotused{Day08.hs}\\nwidentdefs{\\\\{{\\nwixident{main}}{main}}}\\nwidentuses{\\\\{{\\nwixident{Image}}{Image}}\\\\{{\\nwixident{partOne}}{partOne}}\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwindexuse{\\nwixident{Image}}{Image}{NW2fbesT-19Srvv-1}\\nwindexuse{\\nwixident{partOne}}{partOne}{NW2fbesT-19Srvv-1}\\nwindexuse{\\nwixident{partTwo}}{partTwo}{NW2fbesT-19Srvv-1}\\nwendcode{}\\nwfilename{_src/day/2021/02.nw}\\nwbegindocs{0}\\newpage\n\\chapter{Day 2: Dive!}\n\\marginnote{\\url{https://adventofcode.com/2021/day/2}}\n\nNow, you need to figure out how to pilot this thing.\n\nIt seems like the submarine can take a series of commands like {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 1}, {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ 2}, or {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ 3}:\n\\begin{itemize}\n\\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ x} increases the horizontal position by \\hs{x} units.\n\\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ x} increases the depth by \\hs{x} units.\n\\item {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ x} decreases the depth by \\hs{x} units.\n\\end{itemize}\n\nNote that since you're on a submarine, {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote} and {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote} affect your \\textbf{depth}, and so they have the opposite result of what you might expect.\n\nThe submarine seems to already have a planned course (your puzzle input). You should probably figure out where it's going. For example:\n\\begin{minted}{text}\n  forward 5\n  down 5\n  forward 8\n  up 3\n  down 8\n  forward 2\n\\end{minted}\n\nYour horizontal position and depth both start at \\hs{0}. The steps above would then modify them as follows:\n\\begin{itemize}\n  \\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 5} adds \\hs{5} to your horizontal position, a total of \\hs{5}.\n  \\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ 5} adds \\hs{5} to your depth, resulting in a value of \\hs{5}.\n  \\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 8} adds \\hs{8} to your horizontal position, a total of \\hs{13}.\n  \\item {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ 3} decreases your depth by \\hs{3}, resulting in a value of \\hs{2}.\n  \\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ 8} adds \\hs{8} to your depth, resulting in a value of \\hs{10}.\n  \\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 2} adds \\hs{2} to your horizontal position, a total of \\hs{15}.\n\\end{itemize}\n\nAfter following these instructions, you would have a horizontal position of 15 and a depth of 10. (Multiplying these together produces \\hs{150}.)\n\nCalculate the horizontal position and depth you would have after following the planned course. \\textbf{What do you get if you multiply your final horizontal position by your final depth?}\n\n\\newthought{Part Two}\n\nBased on your calculations, the planned course doesn't seem to make any sense. You find the submarine manual and discover that the process is actually slightly more complicated.\n\nIn addition to horizontal position and depth, you'll also need to track a third value, \\textbf{aim}, which also starts at \\hs{0}. The commands also mean something entirely different than you first thought:\n\n\\begin{itemize}\n\\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ x} increases your aim by \\hs{x} units.\n\\item {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ x} decreases your aim by \\hs{x} units.\n\\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ x} does two things:\n  \\begin{itemize}\n  \\item It increases your horizontal position by \\hs{x} units.\n  \\item It increases your depth by your aim \\textbf{multiplied by} \\hs{x}.\n  \\end{itemize}\n\\end{itemize}\n\nAgain note that since you're on a submarine, {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote} and {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote} do the opposite of what you might expect: ``down'' means aiming in the positive direction.\n\nNow, the above example does something different:\n\\begin{itemize}\n\\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 5} adds \\hs{5} to your horizontal position, a total of \\hs{5}. Because your aim is \\hs{0}, your depth does not change.\n\\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ 5} adds \\hs{5} to your aim, resulting in a value of \\hs{5}.\n\\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 8} adds \\hs{8} to your horizontal position, a total of \\hs{13}. Because your aim is \\hs{5}, your depth increases by $8*5=40$.\n\\item {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ 3} decreases your aim by \\hs{3}, resulting in a value of \\hs{2}.\n\\item {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ 8} adds \\hs{8} to your aim, resulting in a value of \\hs{10}.\n\\item {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ 2} adds \\hs{2} to your horizontal position, a total of \\hs{15}. Because your aim is \\hs{10}, your depth increases by $2*10=20$ to a total of \\hs{60}.\n\\end{itemize}\n\nAfter following these new instructions, you would have a horizontal position of \\hs{15} and a depth of \\hs{60}. (Multiplying these produces \\hs{900}.)\n\nUsing this new interpretation of the commands, calculate the horizontal position and depth you would have after following the planned course. \\textbf{What do you get if you multiply your final horizontal position by your final depth?}\n\\nwenddocs{}\\nwfilename{_src/haskell/2021/02.nw}\\nwbegindocs{0}\\newpage\n\\section{Haskell solution}\n\nA {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} is a change in horizontal position and a change in depth,\nrepresented by \\hrefootnote{https://hackage.haskell.org/package/linear/docs/Linear-V2.html\\#t:V2}{a 2-dimensional vector}, \\hrefootnote{https://hackage.haskell.org/package/base/docs/Data-Monoid.html\\#t:Sum}{monoidal under addition}.\n\n\\nwenddocs{}\\nwbegincode{1}\\sublabel{NW2Kouyk-1OzTRH-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-1}}}\\moddef{Define some data types~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwprevnextdefs{\\relax}{NW2Kouyk-1OzTRH-2}\\nwenddeflinemarkup\nnewtype \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} = \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} \\{unDirection :: V2 Int\\}\n  deriving stock (Eq, Show)\n  deriving\n    (Semigroup, Monoid)\n    via (Sum (V2 Int))\n\n\\nwindexdefn{\\nwixident{Direction}}{Direction}{NW2Kouyk-1OzTRH-1}\\eatline\n\\nwalsodefined{\\\\{NW2Kouyk-1OzTRH-2}\\\\{NW2Kouyk-1OzTRH-3}}\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{Direction}}{Direction}}}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\nThe {\\Tt{}\\LA{}known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}\\RA{}\\nwendquote} are {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}, {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}, and {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW2Kouyk-38STh2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}}\\moddef{known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1r7xob-1}}\\nwprevnextdefs{\\relax}{NW2Kouyk-38STh2-2}\\nwenddeflinemarkup\n\\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2}, \\nwlinkedidentc{down}{NW2Kouyk-38STh2-3}, \\nwlinkedidentc{up}{NW2Kouyk-38STh2-4} :: Int -> \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}\n\\nwalsodefined{\\\\{NW2Kouyk-38STh2-2}\\\\{NW2Kouyk-38STh2-3}\\\\{NW2Kouyk-38STh2-4}}\\nwused{\\\\{NW2Kouyk-1r7xob-1}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{down}}{down}}\\\\{{\\nwixident{forward}}{forward}}\\\\{{\\nwixident{up}}{up}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-38STh2-1}\\nwindexuse{\\nwixident{down}}{down}{NW2Kouyk-38STh2-1}\\nwindexuse{\\nwixident{forward}}{forward}{NW2Kouyk-38STh2-1}\\nwindexuse{\\nwixident{up}}{up}{NW2Kouyk-38STh2-1}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n{\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ x} increases the horizontal position by \\hs{x} units.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW2Kouyk-38STh2-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-2}}}\\moddef{known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1r7xob-1}}\\nwprevnextdefs{NW2Kouyk-38STh2-1}{NW2Kouyk-38STh2-3}\\nwenddeflinemarkup\n\\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2} = \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} . flip V2 0\n\\nwindexdefn{\\nwixident{forward}}{forward}{NW2Kouyk-38STh2-2}\\eatline\n\\nwused{\\\\{NW2Kouyk-1r7xob-1}}\\nwidentdefs{\\\\{{\\nwixident{forward}}{forward}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-38STh2-2}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n{\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}\\hs{ x} increases the depth by \\hs{x} units.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW2Kouyk-38STh2-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-3}}}\\moddef{known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1r7xob-1}}\\nwprevnextdefs{NW2Kouyk-38STh2-2}{NW2Kouyk-38STh2-4}\\nwenddeflinemarkup\n\\nwlinkedidentc{down}{NW2Kouyk-38STh2-3} = \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} . V2 0\n\\nwindexdefn{\\nwixident{down}}{down}{NW2Kouyk-38STh2-3}\\eatline\n\\nwused{\\\\{NW2Kouyk-1r7xob-1}}\\nwidentdefs{\\\\{{\\nwixident{down}}{down}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-38STh2-3}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n{\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote}\\hs{ x} decreases the depth by \\hs{x} units, i.e. {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote} with a \\hs{negate}d \\hs{x}.\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW2Kouyk-38STh2-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-4}}}\\moddef{known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1r7xob-1}}\\nwprevnextdefs{NW2Kouyk-38STh2-3}{\\relax}\\nwenddeflinemarkup\n\\nwlinkedidentc{up}{NW2Kouyk-38STh2-4} = \\nwlinkedidentc{down}{NW2Kouyk-38STh2-3} . negate\n\\nwindexdefn{\\nwixident{up}}{up}{NW2Kouyk-38STh2-4}\\eatline\n\\nwused{\\\\{NW2Kouyk-1r7xob-1}}\\nwidentdefs{\\\\{{\\nwixident{up}}{up}}}\\nwidentuses{\\\\{{\\nwixident{down}}{down}}}\\nwindexuse{\\nwixident{down}}{down}{NW2Kouyk-38STh2-4}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\nDefine a {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} parser using the {\\Tt{}\\LA{}known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}\\RA{}\\nwendquote}.\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW2Kouyk-1r7xob-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1r7xob-1}}}\\moddef{Define a Direction parser~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1r7xob-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{direction}{NW2Kouyk-1r7xob-1} :: Parser \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}\n\\nwlinkedidentc{direction}{NW2Kouyk-1r7xob-1} = dir <*> (fromInteger <$> natural)\n  where\n    dir =\n      symbol \"\\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2}\" $> \\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2}\n        <|> symbol \"\\nwlinkedidentc{down}{NW2Kouyk-38STh2-3}\" $> \\nwlinkedidentc{down}{NW2Kouyk-38STh2-3}\n        <|> symbol \"\\nwlinkedidentc{up}{NW2Kouyk-38STh2-4}\" $> \\nwlinkedidentc{up}{NW2Kouyk-38STh2-4}\n\n\\LA{}known directions~{\\nwtagstyle{}\\subpageref{NW2Kouyk-38STh2-1}}\\RA{}\n\\nwindexdefn{\\nwixident{direction}}{direction}{NW2Kouyk-1r7xob-1}\\eatline\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{direction}}{direction}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{down}}{down}}\\\\{{\\nwixident{forward}}{forward}}\\\\{{\\nwixident{up}}{up}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-1r7xob-1}\\nwindexuse{\\nwixident{down}}{down}{NW2Kouyk-1r7xob-1}\\nwindexuse{\\nwixident{forward}}{forward}{NW2Kouyk-1r7xob-1}\\nwindexuse{\\nwixident{up}}{up}{NW2Kouyk-1r7xob-1}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\nThe puzzle input is a list of {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote}s.\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NW2Kouyk-2ga90v-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-2ga90v-1}}}\\moddef{Parse the input~{\\nwtagstyle{}\\subpageref{NW2Kouyk-2ga90v-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\n\\nwlinkedidentc{getInput}{NW2Kouyk-2ga90v-1} :: IO [\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}]\n\\nwlinkedidentc{getInput}{NW2Kouyk-2ga90v-1} = parseInput (some \\nwlinkedidentc{direction}{NW2Kouyk-1r7xob-1}) $(inputFilePath)\n\\nwindexdefn{\\nwixident{getInput}}{getInput}{NW2Kouyk-2ga90v-1}\\eatline\n\\nwnotused{Parse the input}\\nwidentdefs{\\\\{{\\nwixident{getInput}}{getInput}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{direction}}{direction}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-2ga90v-1}\\nwindexuse{\\nwixident{direction}}{direction}{NW2Kouyk-2ga90v-1}\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\n\\subsection{General solution}\n\nThe general solution of the puzzle is to sum a list of additive monoids, extract the final position, and compute the \\hs{product} of the horizontal position and depth.\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NW2Kouyk-1ULoeY-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1ULoeY-1}}}\\moddef{Solve the puzzle~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1ULoeY-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{solve}{NW2Kouyk-1ULoeY-1} :: Monoid m => (m -> V2 Int) -> [m] -> Int\n\\nwlinkedidentc{solve}{NW2Kouyk-1ULoeY-1} extract = product . extract . mconcat\n\\nwindexdefn{\\nwixident{solve}}{solve}{NW2Kouyk-1ULoeY-1}\\eatline\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{solve}}{solve}}}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\n\\subsection{Part One}\n\nFor Part One, the additive monoid is {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote}.\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NW2Kouyk-4G9gVP-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-4G9gVP-1}}}\\moddef{Solve Part One~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4G9gVP-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} :: [\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}] -> Int\n\\nwlinkedidentc{partOne}{NW2fbesT-2iOjQS-4} = \\nwlinkedidentc{solve}{NW2Kouyk-1ULoeY-1} unDirection\n\\nwindexdefn{\\nwixident{partOne}}{partOne}{NW2Kouyk-4G9gVP-1}\\eatline\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{partOne}}{partOne}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{solve}}{solve}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-4G9gVP-1}\\nwindexuse{\\nwixident{solve}}{solve}{NW2Kouyk-4G9gVP-1}\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\n\\subsection{Part Two}\n\nFor Part Two, the additive monoid is {\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote}, i.e. an integer.\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NW2Kouyk-1OzTRH-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-2}}}\\moddef{Define some data types~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwprevnextdefs{NW2Kouyk-1OzTRH-1}{NW2Kouyk-1OzTRH-3}\\nwenddeflinemarkup\nnewtype \\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2} = \\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2} Int\n  deriving stock (Eq, Show)\n  deriving\n    (Semigroup, Monoid)\n    via (Sum Int)\n\n\\nwindexdefn{\\nwixident{Aim}}{Aim}{NW2Kouyk-1OzTRH-2}\\eatline\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{Aim}}{Aim}}}\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n{\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}\\hs{ x} increases the horizontal position by \\hs{x} units and increases the depth by the aim multiplied by \\hs{x}, forming a \\hrefootnote{https://hackage.haskell.org/package/monoid-extras/docs/Data-Monoid-SemiDirectProduct.html\\#t:Semi}{semi-direct product} of {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} (the sub-monoid) and {\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote} (the quotient monoid).\n\nDefine how {\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote} acts on {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote}.\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NW2Kouyk-1OzTRH-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-3}}}\\moddef{Define some data types~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwprevnextdefs{NW2Kouyk-1OzTRH-2}{\\relax}\\nwenddeflinemarkup\ninstance Action \\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2} \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} where\n  act (\\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2} a) (\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} (V2 x y)) = \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} (V2 x (y + a * x))\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentuses{\\\\{{\\nwixident{Aim}}{Aim}}\\\\{{\\nwixident{Direction}}{Direction}}}\\nwindexuse{\\nwixident{Aim}}{Aim}{NW2Kouyk-1OzTRH-3}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-1OzTRH-3}\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\nUse the \\hs{Action} to construct the semi-direct product {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote}$\\ \\rtimes_\\phi\\ ${\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote}.\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NW2Kouyk-4XKPl9-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}}\\moddef{Define the semi-direct product~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwprevnextdefs{\\relax}{NW2Kouyk-4XKPl9-2}\\nwenddeflinemarkup\n\\nwlinkedidentc{phi}{NW2Kouyk-4XKPl9-1} :: \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} -> Semi \\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} \\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2}\n\\nwindexdefn{\\nwixident{phi}}{phi}{NW2Kouyk-4XKPl9-1}\\eatline\n\\nwalsodefined{\\\\{NW2Kouyk-4XKPl9-2}\\\\{NW2Kouyk-4XKPl9-3}\\\\{NW2Kouyk-4XKPl9-4}}\\nwused{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwidentdefs{\\\\{{\\nwixident{phi}}{phi}}}\\nwidentuses{\\\\{{\\nwixident{Aim}}{Aim}}\\\\{{\\nwixident{Direction}}{Direction}}}\\nwindexuse{\\nwixident{Aim}}{Aim}{NW2Kouyk-4XKPl9-1}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-4XKPl9-1}\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\n{\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote}, i.e. a {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} with a depth change of \\hs{0}, doesn't affect the aim.\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NW2Kouyk-4XKPl9-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-2}}}\\moddef{Define the semi-direct product~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwprevnextdefs{NW2Kouyk-4XKPl9-1}{NW2Kouyk-4XKPl9-3}\\nwenddeflinemarkup\n\\nwlinkedidentc{phi}{NW2Kouyk-4XKPl9-1} dir@(\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} (V2 _ 0)) = inject dir\n\\nwused{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{phi}}{phi}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-4XKPl9-2}\\nwindexuse{\\nwixident{phi}}{phi}{NW2Kouyk-4XKPl9-2}\\nwendcode{}\\nwbegindocs{26}\\nwdocspar\n\n{\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote} or {\\Tt{}\\nwlinkedidentq{down}{NW2Kouyk-38STh2-3}\\nwendquote}, i.e. a {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} with a horizontal change of \\hs{0} and a non-zero depth change \\hs{y}, results in an aim change of \\hs{y} units.\n\n\\nwenddocs{}\\nwbegincode{27}\\sublabel{NW2Kouyk-4XKPl9-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-3}}}\\moddef{Define the semi-direct product~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwprevnextdefs{NW2Kouyk-4XKPl9-2}{NW2Kouyk-4XKPl9-4}\\nwenddeflinemarkup\n\\nwlinkedidentc{phi}{NW2Kouyk-4XKPl9-1} (\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1} (V2 0 y)) = embed (\\nwlinkedidentc{Aim}{NW2Kouyk-1OzTRH-2} y)\n\\nwused{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwidentuses{\\\\{{\\nwixident{Aim}}{Aim}}\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{phi}}{phi}}}\\nwindexuse{\\nwixident{Aim}}{Aim}{NW2Kouyk-4XKPl9-3}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-4XKPl9-3}\\nwindexuse{\\nwixident{phi}}{phi}{NW2Kouyk-4XKPl9-3}\\nwendcode{}\\nwbegindocs{28}\\nwdocspar\n\nSince {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} is not specific enough to prevent them, add a catch-all clause to handle invalid directions, e.g. {\\Tt{}\\nwlinkedidentq{forward}{NW2Kouyk-38STh2-2}\\nwendquote} and {\\Tt{}\\nwlinkedidentq{up}{NW2Kouyk-38STh2-4}\\nwendquote} simultaneously.\n\n\\nwenddocs{}\\nwbegincode{29}\\sublabel{NW2Kouyk-4XKPl9-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-4}}}\\moddef{Define the semi-direct product~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwprevnextdefs{NW2Kouyk-4XKPl9-3}{\\relax}\\nwenddeflinemarkup\n\\nwlinkedidentc{phi}{NW2Kouyk-4XKPl9-1} _ = error \"Invalid \\nwlinkedidentc{direction}{NW2Kouyk-1r7xob-1}\"\n\\nwused{\\\\{NW2Kouyk-2ZOhXn-1}}\\nwidentuses{\\\\{{\\nwixident{direction}}{direction}}\\\\{{\\nwixident{phi}}{phi}}}\\nwindexuse{\\nwixident{direction}}{direction}{NW2Kouyk-4XKPl9-4}\\nwindexuse{\\nwixident{phi}}{phi}{NW2Kouyk-4XKPl9-4}\\nwendcode{}\\nwbegindocs{30}\\nwdocspar\n\nTo solve Part Two, lift each {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote} in the input to {\\Tt{}\\nwlinkedidentq{Direction}{NW2Kouyk-1OzTRH-1}\\nwendquote}$\\ \\rtimes_\\phi\\ ${\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote}. To extract the final position, forget the {\\Tt{}\\nwlinkedidentq{Aim}{NW2Kouyk-1OzTRH-2}\\nwendquote} tag.\n\n\\nwenddocs{}\\nwbegincode{31}\\sublabel{NW2Kouyk-2ZOhXn-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-2ZOhXn-1}}}\\moddef{Solve Part Two~{\\nwtagstyle{}\\subpageref{NW2Kouyk-2ZOhXn-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW2Kouyk-1375sF-1}}\\nwenddeflinemarkup\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} :: [\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}] -> Int\n\\nwlinkedidentc{partTwo}{NW2fbesT-4P9qKy-1} = \\nwlinkedidentc{solve}{NW2Kouyk-1ULoeY-1} (unDirection . untag) . map \\nwlinkedidentc{phi}{NW2Kouyk-4XKPl9-1}\n  where\n    \\LA{}Define the semi-direct product~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4XKPl9-1}}\\RA{}\n\\nwindexdefn{\\nwixident{partTwo}}{partTwo}{NW2Kouyk-2ZOhXn-1}\\eatline\n\\nwused{\\\\{NW2Kouyk-1375sF-1}}\\nwidentdefs{\\\\{{\\nwixident{partTwo}}{partTwo}}}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{phi}}{phi}}\\\\{{\\nwixident{solve}}{solve}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-2ZOhXn-1}\\nwindexuse{\\nwixident{phi}}{phi}{NW2Kouyk-2ZOhXn-1}\\nwindexuse{\\nwixident{solve}}{solve}{NW2Kouyk-2ZOhXn-1}\\nwendcode{}\\nwbegindocs{32}\\nwdocspar\n\\subsection{Full solution}\n\n\\nwenddocs{}\\nwbegincode{33}\\sublabel{NW2Kouyk-1375sF-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW2Kouyk-1375sF-1}}}\\moddef{Day02.hs~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1375sF-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\n\\{-# LANGUAGE DerivingVia #-\\}\n\\{-# LANGUAGE MultiParamTypeClasses #-\\}\n\nmodule AdventOfCode.Year2021.Day02 where\n\nimport AdventOfCode.Input (parseInput)\nimport AdventOfCode.TH (defaultMain, inputFilePath)\nimport Control.Applicative ((<|>))\nimport Data.Functor (($>))\nimport Data.Monoid.Action (Action (..))\nimport Data.Monoid.SemiDirectProduct.Strict (Semi, embed, inject, untag)\nimport Data.Semigroup (Sum (..))\nimport Linear (V2 (..))\nimport Text.Trifecta (Parser, natural, some, symbol)\n\n\\LA{}Define some data types~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1OzTRH-1}}\\RA{}\n\n\\nwlinkedidentc{main}{NW2fbesT-19Srvv-1} :: IO ()\n\\nwlinkedidentc{main}{NW2fbesT-19Srvv-1} = $(defaultMain)\n\n\\nwlinkedidentc{getInput}{NW2Kouyk-2ga90v-1} :: IO [\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}]\n\\nwlinkedidentc{getInput}{NW2Kouyk-2ga90v-1} = parseInput (some \\nwlinkedidentc{direction}{NW2Kouyk-1r7xob-1}) $(inputFilePath)\n\nexample :: [\\nwlinkedidentc{Direction}{NW2Kouyk-1OzTRH-1}]\nexample =\n  [ \\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2} 5,\n    \\nwlinkedidentc{down}{NW2Kouyk-38STh2-3} 5,\n    \\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2} 8,\n    \\nwlinkedidentc{up}{NW2Kouyk-38STh2-4} 3,\n    \\nwlinkedidentc{down}{NW2Kouyk-38STh2-3} 8,\n    \\nwlinkedidentc{forward}{NW2Kouyk-38STh2-2} 2\n  ]\n\n\\LA{}Solve Part One~{\\nwtagstyle{}\\subpageref{NW2Kouyk-4G9gVP-1}}\\RA{}\n\n\\LA{}Solve Part Two~{\\nwtagstyle{}\\subpageref{NW2Kouyk-2ZOhXn-1}}\\RA{}\n\n\\LA{}Solve the puzzle~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1ULoeY-1}}\\RA{}\n\n\\LA{}Define a Direction parser~{\\nwtagstyle{}\\subpageref{NW2Kouyk-1r7xob-1}}\\RA{}\n\\nwnotused{Day02.hs}\\nwidentuses{\\\\{{\\nwixident{Direction}}{Direction}}\\\\{{\\nwixident{direction}}{direction}}\\\\{{\\nwixident{down}}{down}}\\\\{{\\nwixident{forward}}{forward}}\\\\{{\\nwixident{getInput}}{getInput}}\\\\{{\\nwixident{main}}{main}}\\\\{{\\nwixident{up}}{up}}}\\nwindexuse{\\nwixident{Direction}}{Direction}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{direction}}{direction}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{down}}{down}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{forward}}{forward}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{getInput}}{getInput}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{main}}{main}{NW2Kouyk-1375sF-1}\\nwindexuse{\\nwixident{up}}{up}{NW2Kouyk-1375sF-1}\\nwendcode{}\\nwbegindocs{34}\\nwdocspar\n\\nwenddocs{}\n\n\\nwixlogsorted{c}{{A transparent layer}{NW2fbesT-dIQyV-1}{\\nwixd{NW2fbesT-dIQyV-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Day01.g}{NW2vDOcF-3gOu99-1}{\\nwixd{NW2vDOcF-3gOu99-1}\\nwixd{NW2vDOcF-3gOu99-2}\\nwixd{NW2vDOcF-3gOu99-3}\\nwixd{NW2vDOcF-3gOu99-4}}}%\n\\nwixlogsorted{c}{{Day02.hs}{NW2Kouyk-1375sF-1}{\\nwixd{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{c}{{Day04.hs}{NW2iNnUA-15Rjc8-1}{\\nwixd{NW2iNnUA-15Rjc8-1}}}%\n\\nwixlogsorted{c}{{Day08.hs}{NW2fbesT-19Srvv-1}{\\nwixd{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Define a Direction parser}{NW2Kouyk-1r7xob-1}{\\nwixd{NW2Kouyk-1r7xob-1}\\nwixu{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{c}{{Define a few convenient type aliases}{NW2fbesT-LSl4Q-1}{\\nwixd{NW2fbesT-LSl4Q-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Define a Pixel data type}{NW2fbesT-2M5oYw-1}{\\nwixd{NW2fbesT-2M5oYw-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Define some data types}{NW2Kouyk-1OzTRH-1}{\\nwixd{NW2Kouyk-1OzTRH-1}\\nwixd{NW2Kouyk-1OzTRH-2}\\nwixd{NW2Kouyk-1OzTRH-3}\\nwixu{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{c}{{Define the semi-direct product}{NW2Kouyk-4XKPl9-1}{\\nwixd{NW2Kouyk-4XKPl9-1}\\nwixd{NW2Kouyk-4XKPl9-2}\\nwixd{NW2Kouyk-4XKPl9-3}\\nwixd{NW2Kouyk-4XKPl9-4}\\nwixu{NW2Kouyk-2ZOhXn-1}}}%\n\\nwixlogsorted{c}{{has a double}{NW2iNnUA-2cQo0j-1}{\\nwixd{NW2iNnUA-2cQo0j-1}}}%\n\\nwixlogsorted{c}{{has a strict double}{NW2iNnUA-ntEfn-1}{\\nwixd{NW2iNnUA-ntEfn-1}}}%\n\\nwixlogsorted{c}{{Implement \\hs{Show} for \\code{}Pixel\\edoc{}}{NW2fbesT-QyGx2-1}{\\nwixd{NW2fbesT-QyGx2-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Input}{NW2iNnUA-1GvnV-1}{\\nwixd{NW2iNnUA-1GvnV-1}\\nwixu{NW2iNnUA-15Rjc8-1}}}%\n\\nwixlogsorted{c}{{known directions}{NW2Kouyk-38STh2-1}{\\nwixd{NW2Kouyk-38STh2-1}\\nwixd{NW2Kouyk-38STh2-2}\\nwixd{NW2Kouyk-38STh2-3}\\nwixd{NW2Kouyk-38STh2-4}\\nwixu{NW2Kouyk-1r7xob-1}}}%\n\\nwixlogsorted{c}{{Parse a $25 \\times 6$ \\code{}image\\edoc{} from the input}{NW2fbesT-276JRG-1}{\\nwixu{NW2fbesT-2iOjQS-1}\\nwixd{NW2fbesT-276JRG-1}}}%\n\\nwixlogsorted{c}{{Parse a pixel}{NW2fbesT-1aCFXy-1}{\\nwixd{NW2fbesT-1aCFXy-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Parse an image}{NW2fbesT-4aeb4o-1}{\\nwixd{NW2fbesT-4aeb4o-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Parse the input}{NW2Kouyk-2ga90v-1}{\\nwixd{NW2Kouyk-2ga90v-1}}}%\n\\nwixlogsorted{c}{{Part One}{NW2iNnUA-2iOjQS-1}{\\nwixd{NW2iNnUA-2iOjQS-1}\\nwixu{NW2iNnUA-15Rjc8-1}\\nwixd{NW2fbesT-2iOjQS-1}\\nwixd{NW2fbesT-2iOjQS-2}\\nwixd{NW2fbesT-2iOjQS-3}\\nwixd{NW2fbesT-2iOjQS-4}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Part Two}{NW2iNnUA-4P9qKy-1}{\\nwixd{NW2iNnUA-4P9qKy-1}\\nwixu{NW2iNnUA-15Rjc8-1}\\nwixd{NW2fbesT-4P9qKy-1}\\nwixu{NW2fbesT-19Srvv-1}}}%\n\\nwixlogsorted{c}{{Solve Part One}{NW2Kouyk-4G9gVP-1}{\\nwixd{NW2Kouyk-4G9gVP-1}\\nwixu{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{c}{{Solve Part Two}{NW2Kouyk-2ZOhXn-1}{\\nwixd{NW2Kouyk-2ZOhXn-1}\\nwixu{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{c}{{Solve the puzzle}{NW2Kouyk-1ULoeY-1}{\\nwixd{NW2Kouyk-1ULoeY-1}\\nwixu{NW2Kouyk-1375sF-1}}}%\n\\nwixlogsorted{i}{{\\nwixident{Aim}}{Aim}}%\n\\nwixlogsorted{i}{{\\nwixident{Black}}{Black}}%\n\\nwixlogsorted{i}{{\\nwixident{Direction}}{Direction}}%\n\\nwixlogsorted{i}{{\\nwixident{direction}}{direction}}%\n\\nwixlogsorted{i}{{\\nwixident{down}}{down}}%\n\\nwixlogsorted{i}{{\\nwixident{forward}}{forward}}%\n\\nwixlogsorted{i}{{\\nwixident{getInput}}{getInput}}%\n\\nwixlogsorted{i}{{\\nwixident{Image}}{Image}}%\n\\nwixlogsorted{i}{{\\nwixident{image}}{image}}%\n\\nwixlogsorted{i}{{\\nwixident{Layer}}{Layer}}%\n\\nwixlogsorted{i}{{\\nwixident{main}}{main}}%\n\\nwixlogsorted{i}{{\\nwixident{partOne}}{partOne}}%\n\\nwixlogsorted{i}{{\\nwixident{partTwo}}{partTwo}}%\n\\nwixlogsorted{i}{{\\nwixident{phi}}{phi}}%\n\\nwixlogsorted{i}{{\\nwixident{Pixel}}{Pixel}}%\n\\nwixlogsorted{i}{{\\nwixident{Row}}{Row}}%\n\\nwixlogsorted{i}{{\\nwixident{solve}}{solve}}%\n\\nwixlogsorted{i}{{\\nwixident{Transparent}}{Transparent}}%\n\\nwixlogsorted{i}{{\\nwixident{up}}{up}}%\n\\nwixlogsorted{i}{{\\nwixident{White}}{White}}%\n", "meta": {"hexsha": "a520befea7846a1a3305ac457f5af99087238fac", "size": 51432, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_src/tex/allcode.tex", "max_stars_repo_name": "yurrriq/advent-of-code", "max_stars_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-11-04T10:32:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-05T07:36:22.000Z", "max_issues_repo_path": "_src/tex/allcode.tex", "max_issues_repo_name": "yurrriq/aoc19", "max_issues_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_src/tex/allcode.tex", "max_forks_repo_name": "yurrriq/aoc19", "max_forks_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-26T19:27:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-26T19:27:21.000Z", "avg_line_length": 82.2912, "max_line_length": 706, "alphanum_fraction": 0.7541413906, "num_tokens": 22270, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.41523761499918116}}
{"text": "\\subsection{Model parameters estimation}\n\\label{S:PARAMESTIMATION}\n\nThe default values for the parameters are either defined from heuristic knowledge or from statistics computed on the data itself (see~Table \\ref{table:defaultparamreal}).\nEach value is only an initial guess which has to be refined using an optimization algorithm (see Section~\\ref{SS:THModelParameterEstimation}). \nThe algorithm will estimate the model parameter values from the data.\n% that estimates the model parameters from the data.\\\\\n\n\\begin{table}[h!]\n\\caption{Default values for model parameters. $\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ corresponds to the empirical standard deviation calculated using observed data from the first data sample to the last data sample of index $\\mathtt{T}$. Note that default value for synthetic data are different, see~Table \\ref{table:defaultsynthetic} for details.} \n\\centering\n\\begin{tabular}{r|ll}\n\\toprule\n$\\bm{\\theta}$ name  & $\\bm{\\theta}^{0}$ & $\\bm{\\theta}$ bounds \\\\\\cmidrule(lr){1-3}\n$\\sigma_{w}^{\\mathtt{LL}}$  &  $0$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{LT}} $ &  $10^{-7}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{LA}} $ &  $10^{-8}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{LcT}} $ &  $10^{-7}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{LcA}} $ &  $10^{-7}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{TcA}} $ &  $10^{-8}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{P}} $ &  $0$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{w}^{\\mathtt{AR}} $ &  $10^{-1}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$ & $[0,\\text{Inf}]$ \\\\\n$\\sigma_{w,0}^{\\mathtt{KR}}  $ &  $10^{-1}\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$  & $[0,\\text{Inf}]$ \\\\\n$\\sigma_{w,1}^{\\mathtt{KR}}  $ &  $0$  &  $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\sigma_{v}$ &  $0.05\\times\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$  &  $[0,\\text{Inf}]$ \\\\\n$\\phi^{\\mathtt{AR}} $ &  $0.75$ & $[0,1]$ \\\\\n$p^{\\mathtt{P}} $ &  $[365.24, 1, 182.62]$\\footnote{One different default value for the period is given for each periodic component.} & $[\\text{NaN},\\text{NaN}]$ \\\\\n$p^{\\mathtt{KR}} $ &  $365.24$ & $[\\text{NaN},\\text{NaN}]$ \\\\\n$\\ell^{\\mathtt{KR}} $ &  $2/\\mathtt{L}^{\\mathtt{KR}}$ (see \\S\\ref{SSS:KR})& $[0,\\text{Inf}]$ \\\\\n$\\phi^{\\cdot|\\cdot} $ &  $0.01$  &  $[-\\text{Inf}, \\text{Inf}]$\\\\\n$\\mu_{b}^{\\mathtt{LI}}$ &  $0$  &  $[-\\text{Inf}, \\text{Inf}]$\\\\\n$\\sigma_{b}^{\\mathtt{LI}}$ &  $\\hat{\\sigma}_{y_{obs(1:\\mathtt{T})}}$  &  $[0, \\text{Inf}]$\\\\\\bottomrule\n\n\\end{tabular}\n\\label{table:defaultparamreal}\n\\end{table}\n\n\n\nIn order to access the model parameter estimation menu from OpenBDLM, type  \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!} (see Listing~\\ref{LST:ModelParametersEstimationMenu}).\nThe optimization algorithm is either the Newton-Raphson (choice \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}) or the Stochastic Gradient Descent  (choice \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!2!}) algorithms (see Section~\\ref{SS:THModelParameterEstimation}). \\begin{lstlisting}[ frame = single, basicstyle = \\mlttfamily \\scriptsize, caption = {OpenBDLM model parameter estimation menu}, label = LST:ModelParametersEstimationMenu ,  float =ht, linewidth=\\linewidth, captionpos=b]\n-------------------------------------------\n/ Learn model parameters\n-------------------------------------------\n\n     1 ->  Newton-Raphson\n     2 ->  Stochastic Gradient Ascent\n\n     Type R to return to the previous menu\n\n     choice >> \n\\end{lstlisting}\n By default, OpenBDLM uses all the data as the training set (see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.Trainingperiod=[1 Inf]!).\nOpenBDLM transform the model parameters to perform the optimization in an unbounded model parameter space (see Section~\\ref{SS:THSpaceTransformation}).\nUndefined bounds (\\lstinline[basicstyle = \\mlttfamily \\small ]![NaN, NaN]!)  for a parameter means that the parameter is assumed to be known and thus, it will be excluded from the parameter estimation process.\nBy default, OpenBLDM assumes that the parameters for the period of the periodic component and the process noise standard deviation associated with the baseline and the periodic component have values fixed to 0 and are not optimized.\\\\\n\nThe model parameter can be learned by maximizing either the likelihood (Maximum Likelihood Estimation, MLE), or the posterior function (Maximum A Posteriori estimation, MAP) (see Section~\\ref{SS:THModelParameterEstimation}). \nNote that MAP requires a valid prior for each unknown model parameters.\nIn the case of of MAP, OpenBDLM supports gaussian prior only.\nThe default option is MLE (see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.isMAP=false!).\nThere is the possibility to use the prediction capacity to drive the optimization process\\footnote{The use of the prediction capacity is only available using the Stochastic Gradient Descent optimization.} (see  \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.isPredCap! and \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.SplitPercent!). The model parameter estimation framework computes point estimate of the model parameters. \nHowever, it is also possible provide confidence intervals around the point estimate using the Laplace approximation\\footnote{Laplace approximation is currently only available using the Newton-Raphson optimization.} (see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.isLaplaceApproximation = true!).\nNote that computing the Laplace approximation can significantly increase the computation time and it is not recommended when the number of model parameters is large.\\\\\n\nNote also that Newton-Raphson and Stochastic Gradient Descent techniques are sensitive to the initial model parameters values. \n%The algorithm can reach a local maximum, instead of the global maximum.\nTherefore, it is advised to run the optimizations several times with different starting model parameters values in order to check if the proposed solution is the best attainable solution.\nIf \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.isMute = false!, outputs on the \\MATLAB{} command line window allows to monitor the optimization process (see Listings~\\ref{LST:OpenBLDMModelParameterLearning}-\\ref{LST:OpenBLDMModelParameterLearningSGD}).\nAt each iteration, the quantity displayed are: the current value of the target function, the name as well as the current value of the unknown model parameter being optimized, the change in model parameters, the change in the target function, and the convergence status (\\lstinline[basicstyle = \\mlttfamily \\small ]!1! if the model parameter converged according to the convergence criteria, \\lstinline[basicstyle = \\mlttfamily \\small ]!0! otherwise).\\\\\n\nThe optimization stops when all the parameters converged, or if the maximum number of iterations (see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.maxIterations!) (or epochs for Stochastic Gradient Descent algorithm, see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.maxEpochs!) / the maximum time (see \\lstinline[basicstyle = \\mlttfamily \\small ]!misc.options.maxTime!) is reached.\nThe values of the parameters are saved in the variable \\lstinline[basicstyle = \\mlttfamily \\small ]!model!.\n \n \\begin{lstlisting}[ frame = single, basicstyle = \\mlttfamily \\scriptsize, caption = {OpenBLDM output example when running Newton-Raphson algorithm.}, label = LST:OpenBLDMModelParameterLearning,  float =h!, linewidth=\\linewidth, captionpos=b]\n    \\Start Newton-Raphson max. algorithm (finite difference method)\n\n      Training period:                             1-Inf [days]\n      Maximal number of iteration:                 100\n      Total time limit for calibration :           60 [min]\n      Convergence criterion:                       1e-07*LL\n      Nb. of search levels for \\lambda:            4*2\n\n           Initial LL: 36626.8381\n                       AR|M1|1         AR|M1|1         |M1|1            \n      parameter names: \\phi            \\sigma_w        \\sigma_v         \n       initial values: +7.50e-01       +1.74e-02       +8.70e-03       \n--------------------------\n    Loop #1 : |M1|1 | \\sigma_v \n       delta_param: -0.0040755 \n    log-likelihood : 36994.6374\n    param change   : 0.0087002 -> 0.0046247\n\n                    AR|M1|1         AR|M1|1         |M1|1           \n   parameter names: \\phi            \\sigma_w        \\sigma_v        \n    current values: +7.50e-01       +1.74e-02       +4.62e-03      \n  current f.o. std: +0.00e+00       +0.00e+00       +1.93e-04      \n      previous dLL: +1.00e+06       +1.00e+06       +3.68e+02      \n         converged:         0               0               0      \n--------------------------\n    Loop #2 : AR|M1|1 | \\sigma_w \n       delta_param: 0.0046034 \n    log-likelihood : 40998.3934\n    param change   : 0.0174 -> 0.022003\n\n                    AR|M1|1         AR|M1|1         |M1|1           \n   parameter names: \\phi            \\sigma_w        \\sigma_v        \n    current values: +7.50e-01       +2.20e-02       +4.62e-03      \n  current f.o. std: +0.00e+00       +5.26e-05       +1.93e-04      \n      previous dLL: +1.00e+06       +4.00e+03       +3.68e+02      \n         converged:         0               0               0      \n--------------------------\n\\end{lstlisting}\n\n\n\n \\begin{lstlisting}[ frame = single, basicstyle = \\mlttfamily \\scriptsize, caption = {OpenBLDM output example when running Stochastic Gradient Ascent algorithm.}, label = LST:OpenBLDMModelParameterLearningSGD,  float =h!, linewidth=\\linewidth, captionpos=b]\n    \\Start SGD algorithm (finite difference method)\n\n      Optimization mode                           MLE\n      Optimizer                                   MMT\n      Metric                                      logpdf\n      Learning Rate mode                          hessian\n      Training period:                            1 - Inf [days]\n      Validation set portion:                     30 [%]\n      Training set:                               13556 [data points]\n      Validation set:                             5810 [data points]\n      Mini batch:                                 3873 [data points]\n      Number of max epoch:                        30+1 [epochs]\n      Total time limit for calibration:           60 [min]\n\n    Epoch #1\n             Metric: 25972.5904\n                    AR|M1|1         AR|M1|1         |M1|1           \n   parameter names: \\phi            \\sigma_w        \\sigma_v        \n    initial values: +7.50e-01       +1.74e-02       +8.70e-03       \n\n--------------------------\n    Epoch #2\n            Metric: 33933.8856\n   parameter names: AR|M1|1         AR|M1|1         |M1|1           \n    current values: +9.61e-01       +2.00e-02       +5.66e-03      \n      param change: +2.11e-01       +2.61e-03       -3.04e-03      \n  initialize param:         0               0               0      \n\n\n--------------------------\n    Epoch #3\n            Metric: 33933.8856\n   parameter names: AR|M1|1         AR|M1|1         |M1|1           \n    current values: +9.61e-01       +2.00e-02       +5.66e-03      \n      param change: +0.00e+00       +0.00e+00       +0.00e+00      \n  initialize param:         1               0               0 \n\\end{lstlisting}\n\n\n\n\n\n\n\n\n\n\n\\subsubsection{Model parameter estimation functions}\n\n\\begin{description}[style=unboxed]\\setlength\\itemsep{0em}\n\\item[Pilot function for optimization] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data,model,estimation,misc]=piloteOptimization(data,model,estimation,misc)\n  \\end{lstlisting}\n\n\\item[Estimates model parameter using Newton-Raphson algorithm] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[optim,model]=NewtonRaphson(data,model,misc)\n  \\end{lstlisting}\n  \n \\item[Estimates model parameter using Stochastic Gradient Descent algorithm] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[optim,model] = SGD(data,model,misc,varargin)\n  \\end{lstlisting} \n\n \\item[Reads model parameter properties ] \\leavevmode\n \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[arrayOut]=readParameterProperties(cellIn,Position)\n  \\end{lstlisting} \n\n \\item[Writes model parameter properties ] \\leavevmode\n \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[cellOut]=writeParameterProperties(cellIn,arrayIn,Position)\n  \\end{lstlisting} \n\n \\item[Approximates the target function, as well as the first and second derivative of the logarithm of the target function with respect to parameter values ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[logpdf,Glogpdf,Hlogpdf, delta_grad] = logPosteriorPE(data,model,misc,varargin)\n  \\end{lstlisting} \n\n \\item[Computes the gradient and hessian of the gaussian prior distribution of each model parameter ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[logprior,Glogprior,Hlogprior]= logPriorDistr(P,Mu,Sigma,varargin)\n  \\end{lstlisting} \n\n \\item[Computes numerical hessian H of a function ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\nH=numerical_hessian(x,fX,varargin)\n  \\end{lstlisting} \n\n \\item[Defines transformation functions and their derivatives according to provided bounds for the model parameters ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[fct_TR,fct_inv_TR,grad_TR2OR,hessian_TR2OR]=parameter_transformation_fct(model,param_idx_loop)\n  \\end{lstlisting} \n\n \\item[Performs Switching Kalman filter on time series ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[x,V,VV,S,loglik,U,D]=SwitchingKalmanFilter(data,model,misc)\n  \\end{lstlisting} \n\n \\item[Computes the first and second derivative of the logarithm of the likelihood function with respect to parameter values] \\leavevmode\n \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[grad,hessian,fail_gradHess,delta_grad] = gradHess(data, model,misc,pTR,pOR,log_lik_0,grad_TR2OR,delta_grad,param_idx_loop)\n \\end{lstlisting} \n\n \\item[Computes the optimal parameter step size for the approximation of the numerical derivative of the likelihood and compute the terms required to approximate the numerical derivative using finite-difference method] \\leavevmode\n \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[delta_grad,fail_delta_grad,log_lik_1,log_lik_2] = StepSizeOptimization(model,data,misc,pOR,log_lik_0,delta_grad,param_idx_loop)\n \\end{lstlisting} \n\n \\item[Splits the full dataset into train and test dataset (for Stochastic Gradient Descent only) ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[data_train,data_valid] = dataSplit(data,idxTrain,alpha_split,varargin)\n  \\end{lstlisting} \n\n \\item[Computes the metric function (for Stochastic Gradient Descent only) ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[metricVL,idxMaxM,logpdf_test,logpdf_train] = metricFct(data_train,data_test,model,misc,parameterSearch,parameterSearchTR)\n  \\end{lstlisting} \n\n \\item[paramGrid (for Stochastic Gradient Descent only) ] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[xM,momentumM,RMSpropM,gradM,learningRateM, mmtHessM, hessM]= paramGrid(x,momentum,RMSprop,grad,learningRate,mmtHess,hess)\n  \\end{lstlisting} \n  \n  \\item[ADAM optimizer (for Stochastic Gradient Descent only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[xsearch,xsearchTR,momentumTR,RMSpropTR] = ADAM(xsearchTRprev,momentumTRprev,RMSpropTRprev,grad,step,beta_1,beta_2,epsilon,Niter,fctInvTR)  \n  \\end{lstlisting} \n    \n\\item[MMT optimizer (for Stochastic Gradient Descent only)] \\leavevmode\n  \\begin{lstlisting}[ basicstyle = \\mlttfamily \\small, breaklines=true]\n[xsearch,xsearchTR,momentumTR] = MMT(xsearchTRprev,momentumTRprev,grad,step,beta,fctInvTR)\n\\end{lstlisting} \n    \n  \n\\end{description}\n\n\\begin{figure}[!h]\n  \\centering\n  \\captionsetup{justification=centering}\n\\scalebox{0.7}{\n\\begin{tikzpicture}\n\n\\node[parababyblueeyes](inputOptimization){ \\begin{tabular}{c} \\lstinline[ basicstyle = \\mlttfamily \\small]!data! \\\\ \\phantom{}  \\lstinline[ basicstyle = \\mlttfamily \\small]!model.param_properties! \\phantom{} \\end{tabular}};\n\\node[esbabyblueeyes](piloteOptimization)[below of = inputOptimization, yshift = -1cm]{\\phantom{} piloteOptimization.m \\phantom{}};\n\\node[testbabyblueeyes](testNRSGD)[below of = piloteOptimization, yshift = -1.5cm]{\\begin{tabular}{c} NR or  \\\\ SGD ?  \\end{tabular}};\n\\node[esbabyblueeyes](SeeNewtonRaphson)[below of = testNRSGD, yshift = -1cm, xshift = -3.5cm]{\\phantom{} see Figure~\\ref{FIG:NewtonRaphsonWorkflow} \\phantom{}};\n\\node[esbabyblueeyes](SeeSGD)[below of = testNRSGD, yshift = -1cm, xshift = 3.5cm]{\\phantom{} see Figure~\\ref{FIG:SGDWorkflow} \\phantom{}};\n\\node[parababyblueeyes](outputOptimization)[below of = inputOptimization, yshift = -8cm]{\\phantom{}  \\lstinline[ basicstyle = \\mlttfamily \\small]!model.param_properties! \\phantom{}};\n\n\\path[->, draw, thick] (inputOptimization)edge(piloteOptimization);\n\\path[->, draw, thick] (piloteOptimization)edge(testNRSGD);\n\\path[->, draw, thick] (testNRSGD.east) -| (1.5cm,-4.5cm) -| node[pos=0.25, above]{ SGD} (SeeSGD.north);\n\\path[->, draw, thick] (testNRSGD.west) -| (-1.5cm,-4.5cm) -| node[pos=0.25, above]{NR} (SeeNewtonRaphson.north);\n\\path[->, draw, thick] (SeeNewtonRaphson.south) |- (0cm,-8cm) -|  (outputOptimization.north);\n\\path[->, draw, thick] (SeeSGD.south) |- (0cm,-8cm) -|  (outputOptimization.north);\n\\end{tikzpicture} } \n\\caption{Model parameter estimation workflow} \\label{FIG:ModelParameterEstimationWorkflow}\n\\end{figure}\n\n\n\\begin{figure}[!h]\n  \\centering\n  \\captionsetup{justification=centering}\n\\scalebox{0.7}{\n\\begin{tikzpicture}\n\n\\node[esbabyblueeyes](NewtonRaphson){\\phantom{} NewtonRapshon.m \\phantom{}};\n\\node[esbabyblueeyes](readParameterEstimation)[below of = NewtonRaphson, yshift = -1cm]{\\phantom{} readParameterEstimation.m \\phantom{}};\n\\node[esbabyblueeyes](paramtransform)[below of = readParameterEstimation , yshift = -1cm]{\\phantom{}  parameter\\_transformation\\_fct.m \\phantom{}};\n\\node[esbabyblueeyes](logposterior)[below of = paramtransform  , yshift = -1cm]{\\phantom{}  logPosteriorPE.m \\phantom{}};\n\\node[esbabyblueeyes](logPrior)[right of = logposterior , xshift=4cm, yshift = 0.75cm]{\\phantom{}  logPriorDistr.m \\phantom{}};\n\\node[esbabyblueeyes](gradHess)[right of = logposterior , xshift=3.75cm, yshift = -0.75cm]{\\phantom{}  gradHess.m \\phantom{}};\n\\node[esbabyblueeyes](SSO)[right of = gradHess , xshift=3cm, yshift = 0cm]{\\phantom{}  stepSizeOptimization.m \\phantom{}};\n\\node[esbabyblueeyes](SKF)[below of = SSO , xshift=0cm, yshift = -1cm]{\\phantom{}  SwitchingKalmanFilter.m \\phantom{}};\n\\node[esbabyblueeyes](writeParameterEstimation)[below of = logposterior, yshift = -1.5cm]{\\phantom{} writeParameterEstimation.m \\phantom{}};\n\n\n\\path[->, draw, thick] (NewtonRaphson)edge(readParameterEstimation);\n\\path[->, draw, thick] (readParameterEstimation)edge(paramtransform);\n\\path[->, draw, thick] (paramtransform)edge(logposterior);\n\\path[->, draw, thick] (logposterior.east) -| (3cm,-5.25cm) --  (logPrior.west);\n\\path[->, draw, thick] (logposterior.east) -| (3cm,-6.75cm) --  (gradHess.west);\n\\path[->, draw, thick] (gradHess)edge(SSO);\n\\path[->, draw, thick] (SSO)edge(SKF);\n\\path[->, draw, thick] (logposterior)edge(writeParameterEstimation);\n\n\\end{tikzpicture} } \n\\caption{Model parameter estimation Newton-Raphson workflow} \\label{FIG:NewtonRaphsonWorkflow}\n\\end{figure}\n\n\n\\begin{figure}[h]\n  \\centering\n  \\captionsetup{justification=centering}\n\\scalebox{0.7}{\n\\begin{tikzpicture}\n\n\\node[esbabyblueeyes](SGD){\\phantom{} SGD.m \\phantom{}};\n\\node[esbabyblueeyes](readParameterEstimation)[below of = SGD, yshift = -1cm]{\\phantom{} readParamaterEstimation.m \\phantom{}};\n\\node[esbabyblueeyes](paramtransform)[below of = readParameterEstimation , yshift = -1cm]{\\phantom{}  parameter\\_transformation\\_fct.m \\phantom{}};\n\\node[esbabyblueeyes](metric1)[below of = paramtransform , yshift = -1cm]{\\phantom{}  metricFct.m \\phantom{}};\n\\node[esbabyblueeyes](split)[below of =metric1 , yshift = -1cm]{\\phantom{}  dataSplit.m \\phantom{}};\n\\node[esbabyblueeyes](logposterior)[below of = split  , yshift = -1cm]{\\phantom{}  logPosteriorPE.m \\phantom{}};\n\\node[esbabyblueeyes](logPrior)[right of = logposterior , xshift=4cm, yshift = 0.75cm]{\\phantom{}  logPriorDistr.m \\phantom{}};\n\\node[esbabyblueeyes](gradHess)[right of = logposterior , xshift=3.75cm, yshift = -0.75cm]{\\phantom{}  gradHess.m \\phantom{}};\n\\node[esbabyblueeyes](SSO)[right of = gradHess , xshift=3cm, yshift = 0cm]{\\phantom{}  stepSizeOptimization.m \\phantom{}};\n\\node[esbabyblueeyes](SKF)[below of = SSO , xshift=0cm, yshift = -1cm]{\\phantom{}  SwitchingKalmanFilter.m \\phantom{}};\n\\node[esbabyblueeyes](grid)[below of = logposterior, yshift = -1cm]{\\phantom{} paramGrid.m \\phantom{}};\n\\node[esbabyblueeyes](adam)[below of = grid, yshift = -1cm]{\\phantom{} \\begin{tabular}{c} ADAM.m  \\\\ MMT.m  \\end{tabular}};\n\\node[esbabyblueeyes](metric2)[below of = adam , yshift = -1cm]{\\phantom{}  metricFct.m \\phantom{}};\n\\node[esbabyblueeyes](writeParameterEstimation)[below of = metric2, yshift = -1cm]{\\phantom{} writeParameterEstimation.m \\phantom{}};\n\n\n\\path[->, draw, thick] (NewtonRaphson)edge(readParameterEstimation);\n\\path[->, draw, thick] (readParameterEstimation)edge(paramtransform);\n\\path[->, draw, thick] (paramtransform)edge(metric1);\n\\path[->, draw, thick] (metric1)edge(split);\n\\path[->, draw, thick] (split)edge(logposterior);\n\\path[->, draw, thick] (logposterior.east) -| (3cm,-9.25cm) --  (logPrior.west);\n\\path[->, draw, thick] (logposterior.east) -| (3cm,-10.75cm) --  (gradHess.west);\n\\path[->, draw, thick] (gradHess)edge(SSO);\n\\path[->, draw, thick] (SSO)edge(SKF);\n\\path[->, draw, thick] (logposterior)edge(grid);\n\\path[->, draw, thick] (grid)edge(adam);\n\\path[->, draw, thick] (adam)edge(metric2);\n\\path[->, draw, thick] (metric2)edge(writeParameterEstimation);\n\n\\end{tikzpicture} } \n\\caption{Model parameter estimation Stochastic gradient descent workflow} \\label{FIG:SGDWorkflow}\n\\end{figure}", "meta": {"hexsha": "32341a4b808f574dde62f12d0de2dbf9ffdabf26", "size": 22639, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pdf_doc/section/OpenBDLMParamEstimation.tex", "max_stars_repo_name": "CivML-PolyMtl/OpenBDLM", "max_stars_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-19T23:42:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T17:32:11.000Z", "max_issues_repo_path": "doc/pdf_doc/section/OpenBDLMParamEstimation.tex", "max_issues_repo_name": "bhargobdeka/OpenBDLM", "max_issues_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pdf_doc/section/OpenBDLMParamEstimation.tex", "max_forks_repo_name": "bhargobdeka/OpenBDLM", "max_forks_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-10-18T07:18:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:26:06.000Z", "avg_line_length": 64.8681948424, "max_line_length": 607, "alphanum_fraction": 0.685807677, "num_tokens": 6816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41523760538085014}}
{"text": "\n\\documentclass[a4paper,11pt]{article}\n\n\\usepackage{physics}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm, mathtools}\n%\\usepackage{hyperref}\n\\usepackage{color}\n\\usepackage{jheppub}\n\\usepackage[T1]{fontenc} % if needed\n\n% My Documents\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\\def\\a{\\alpha}\n\\def\\b{\\beta}\n\\def\\g{\\gamma}\n\\def\\s{\\sigma}\n%\\linespread{1.0}\n%\\setlength{\\parindent}{0em}\n%\\setlength{\\parskip}{0.8em}\n\n\\title{\\textbf{Correlated Quantum Many-Body Systems}}\n\\author{Aditya Vijaykumar}\n\\affiliation{International Centre for Theoretical Sciences, Bengaluru, India.}\n\\emailAdd{aditya.vijaykumar@icts.res.in}\n\n\\begin{document}\n\\maketitle\n\n\\section{What is the problem?}\nWant to understand and describe the propertiees of a quantum many body system with many moving parts. \n\nInterested in describing the properties of a system: Mostly inclined towards {\\bf linear response properties}. For example, the response of current through a resistor ($V = I R$). These can give us unperrturbed properties of a system.\n\n\\section{What are the moving parts: The constitutents of the system}\nThese can be ions, electons, stars, fluids, etc. We describe them using some effective theory, obviously not at the molecular level. This again, depends on the experiment we do, i.e, at what {\\bf energy we probe the system}. These degrees of freedom are effective degrees of freedom. Once we have described the constituents, we need to understand the physics of them, i.e, the {\\bf effective ``microscropic\" description}. \n\\subsection{Physics of few constituents}\nOne question that one can ask: is classical mechanics enough to describe the system or does one need to use quantum mechanics. If for example is talking about sand particles one can do with CM. But for an elecron in a wire, one needs to essentially solve some QM.\n\\begin{itemize}\n\t\\item {\\bf CM}: Works by stating the position and momentum at any time and solve Newton's laws. For multiple particles, one can solve multiple equations. However in principle one can choose to follow one of the particle and understand it alone. \n\t\n\t\\item {\\bf QM}: In QM superposition and {\\bf entanglement} doesn't allow us to understandpars of the system individually. This is a major departure from CM. Entangement doesn't have any classical analogue.\\\\\n\t{\\bf Example:} Consider a state, \n\t\\be\n\t\\ket{\\psi} = \\frac{\\ket{\\uparrow \\downarrow} + \\ket{ \\downarrow \\uparrow}}{\\sqrt{2}}\n\t\\ee\n\tWe define the density matrix as $\\rho = \\ket{\\psi} \\bra{\\psi}$. The reduced density matrix is obtained by integrating out one spin,\n\t\\be\n\t\\rho_{red}^{(1)} = \\braket{\\uparrow|\\rho|\\uparrow_2} + \\braket{\\downarrow|\\rho|\\downarrow_2}\n\t\\ee\n\tWe define something called entanglement entropy $S_{ent}=-\\mbox{Tr}[\\rho_{red}^{(1)} \\log\\rho_{red}^{(1)}  ]$. If EE is zero then it's not an entangled state. Here it is zero because $\\psi$ is  a tensor product state $\\psi_1 \\otimes \\psi_2$. \n\t\n\tTo understand the dynamics of a system we study the following related to that. Some of them include\n\t\n\t\\subsubsection{Symmetries:} Tells aout the ``isotropies\" in a system. For example,\n\t\\be\n\tT_{\\vec a}\\ket{\\vec x} = \\ket{\\vec x + \\vec a}\n\t\\ee\n\tThis operator preserves the probabilities, and thus is unitary. It's the translation operator. Say a hamiltonian has a translational symmetry, then one can't really distinguish between $ \\ket{x} $ and $ \\ket{x + a} $. Thus,\n\t\\begin{equation*}\n\t[H, T_{\\vec a}] = 0 \\implies T_a^{\\dagger} H T_a = H\n\t\\end{equation*}\n\tThis brings a restriction n the dynamics of a system. In this particular case, it just means that the hamiltonian remains invariant under translations.\t\n\n\\end{itemize}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \t\t\tIsing Model\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Ising Model}\nThe constituents in this system are spin $1/2$ particles. We have $N$ such spin half particles here. The $ i^{th} $ spin half is descrbed by two states $\\ket{\\sigma_i} \\equiv \\ket{1}, \\ket{0} \\equiv \\ket{\\uparrow}, \\ket{ \\downarrow } $. These are often called {\\bf qbits}. The basis stats are spanned by objects like, \n\\begin{equation*}\n\\ket{\\sigma_1 \\sigma_2 \\cdots \\sigma_n}\n\\end{equation*}\nGiven this one can construct all operators in the system\n\\begin{equation*}\nA_i = \\sum_{\\alpha \\beta} A^{\\alpha \\beta}_i \\ket{\\alpha_i} \\bra{\\beta_i}\n\\end{equation*}\nThe operators above are local (depends on a particular site), and the claim is that these operators can be generated using the Pauli matrices $1, \\sigma_x, \\sigma_y, \\sigma_z$, which satisfy,\n\\be\n[\\sigma_i^{\\alpha}, \\sigma_j^{\\beta}] = 2 i \\delta_{ij} \\epsilon^{\\alpha \\beta \\gamma}\\sigma_i^{\\gamma} \n\\ee\nWe now describe the symmetries of the system, (no matter what we choose we have to satisfy $S^{\\dagger} H S = H$)\n\\begin{itemize}\n\t\\item One dimensional Translation: We want translation symmetry in units of $n \\in$ Integer. \tThese can be realized in a lattice with lattice constant $a$. \n\t\n\t\\item Given by the operator $X = \\prod_i \\s_i^X$. What does this do? It's essentially a rotation in spin space about the $X$ axis by $\\frac{\\pi}{2}$. We have the Pauli matrices as, \n\t\\begin{equation*}\n\t\\s_x = \\left( \\begin{array}{cc}\n\t1 & 0 \\\\\n\t0 & 1\n\t\\end{array}\n\t \\right) \\implies \\s^x \\ket{\\uparrow} = \\ket{\\downarrow}\n\t\\end{equation*}\n\tThis also gives, \n\t\\begin{equation*}\n\t\\s^x \\s^z \\s^x = - \\s^z\n\t\\end{equation*}\n\tWe can also compute for spins at different sites, \n\t\\begin{equation*}\n\tX^{\\dagger} \\s_i^z \\s_j^z X = \n\t\tX^{\\dagger} \\s_i^z X X^{\\dagger} \\s_j^z X  = \\s_i^z \\s_j^z\n\t\\end{equation*}\n\tThus to make it commute with the Hamiltonian we either choose an even number of $\\s_z$ or work with $\\s_x$. \n\\end{itemize}\nOne Hamiltonian that respects all the symmetries of the system, \n\\begin{equation*}\nH = - J \\sum_i \\s_i^z \\s_{i + 1}^z - \\Gamma \\sum_i \\s_i^x\n\\end{equation*}\nWe are interested in determining the ground state and low energy properties of the system. The numbers $J$ and $ \\Gamma $ are called coupling constants. For our case we take them to be positive. We vary the constant $\\Gamma/J$  and ask how the ground state energy changes.\\\\ \\\\\n In the limit where $J \\to 0$, we have a non-interacting Hamiltonian,\n \\be\n H = \\sum_i \\s_i^x\n \\ee\nThe two states having energy $+$ and $-$  in the $Z$ basis are repectively, \n\\begin{equation*}\n\\ket{\\leftarrow}_x \\equiv \\frac{\\ket{\\uparrow} - \\ket{\\downarrow}}{\\sqrt{2}}, \\quad \n\\ket{\\rightarrow}_x \\equiv\\frac{\\ket{\\uparrow} + \\ket{\\downarrow}}{\\sqrt{2}}\n\\end{equation*}\nThe ground state is,\n\\be\n\\ket{GS} = \\ket{\\rightarrow \\rightarrow \\cdots \\rightarrow}\n\\ee\nThe energy of the ground state is, \n\\be\nE_{GS} = - \\Gamma N\n\\ee\nN being the number of spins. The first excited state is, \n\\begin{equation*}\n\\ket{1}_{ex} = \\ket{\\rightarrow \\rightarrow \\cdots \\underbrace{\\leftarrow}_{i} \\cdots \\rightarrow} \n\\end{equation*}\nAll the first excited states have the energy, \n\\be\nE_1 = E_{GS} + 2 \\Gamma\n\\ee\n\n\nWe now ask the action of $\\s^z$ on $\\ket{\\leftarrow}$ and $\\ket{\\rightarrow}$,\n\\begin{equation*}\n\\s^z \\ket{\\rightarrow} = \\ket{\\leftarrow}, \\quad \n\\s^z \\ket{\\leftarrow} = \\ket{\\rightarrow}\n\\end{equation*}\n\nNow we consider the action of the operator, \n\\begin{equation*}\n\\s_i^z \\s_{i+1}^z + \\s_{i-1}^z \\s_i^z \n\\end{equation*}\nThis takes the first excited state in the equation above ($\\ket{1_{ex}} \\equiv \\ket{i}$) to $\\ket{i-1}$ or $\\ket{i+1}$ (keeps the energy invariant). Thus the hamiltonian can be written as, \n\\begin{equation*}\nH = \\sum_i \\ket{i-1} \\bra{i} + \\ket{i+1}\\bra{i}\n\\end{equation*}\nIn fourier space this becomes,\n\\begin{equation*}\n\\ket{k} = \\frac{1}{\\sqrt N} \\sum_i e^{i k r_i} \\ket{i}\n\\end{equation*}\nThese are the eigenstates of this Hamiltonian, an dit an be shown that, \n\\begin{equation*}\nH \\ket{k} = E_k \\ket{k} \\implies E_k = E_1 - J \\cos ka\n\\end{equation*}\nFor soft $k$, \n\\begin{equation*}\nE_k = (E_1 - J) + \\frac{J a k^2}{2}\n\\end{equation*}\nThe first term is some shift, but the second one looks like an inverse of mass. Now using this we wish to compute the EE for a state broken into two halves. Thus for small $J$ it's almost a classical state with nearly zero EE since it's a state that can be broken into product state ($\\ket{\\rightarrow \\cdots \\rightarrow}$). This is the reason why one is able to construct a free particle state. \n\nThe question now is: The properties of ground state with lot of entanglement, and what kind of excited states they give rise to? \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "ae0999bfad6f9376964a3659d4ecc882f93bc04e", "size": 8595, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "seminars/subhro/subhro.tex", "max_stars_repo_name": "adivijaykumar/papers", "max_stars_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "seminars/subhro/subhro.tex", "max_issues_repo_name": "adivijaykumar/papers", "max_issues_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "seminars/subhro/subhro.tex", "max_forks_repo_name": "adivijaykumar/papers", "max_forks_repo_head_hexsha": "71b10b9d3b825871cca606f5728642946bc313aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.765625, "max_line_length": 422, "alphanum_fraction": 0.70831879, "num_tokens": 2644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41523760538085014}}
{"text": "\\subsection{Transfer}\r\n\\label{sec:721Transfer}\r\n\r\n\\sectlof\r\nWe continue with the notation and indices from the `\\hyperref[sec:Mint]{Mint}' section.\\\\\r\n\\\\\r\nSuppose Alice wishes to transfer ownership of the ERC-721 token with tokenId `$\\alpha$' to Bob, but under zero-knowledge.\\\\\r\n\\\\\r\nIn the `Mint' section, we saw how Alice can create an `ERC-721 commitment' $Z_\\alpha$ within the Shield contract which:\r\n\\begin{itemize}\r\n  \\item hides an underlying ERC-721 token with tokenId `$\\alpha$'; and\r\n  \\item hides and binds Alice as the owner of $Z_\\alpha$ (and hence of $\\alpha$) through an ownership keypair $(sk_A^Z, pk_A^Z)$.\r\n\\end{itemize}\r\n\\ \\\\\r\nRecall our privacy intentions:\\\\\r\nAlice wishes to be able to transfer ownership of an ERC-721 token under zero-knowledge, so that the following become private:\r\n\t\\begin{center}\r\n\t\t\\begin{framed}\r\n      \\begin{enumerate}\r\n        \\item All details of the ERC-721 token (the `asset').\r\n        \\item The identity of the sender of the token (`Alice').\r\n        \\item The identity of the receiver of the token.\r\n      \\end{enumerate}\r\n    \\end{framed}\r\n  \\end{center}\r\nRecall that minting a token commitment does not yet afford Alice any privacy (see the warning in Figure~\\ref{fig:nfMintWarning}). Only with subsequent transfers will the whereabouts of $\\alpha$ and the owner of $\\alpha$ be hidden.\r\n\r\nFor Alice to transfer ownership of $\\alpha$ within the Shield contract, under zero knowledge, she follows the steps in Figure~\\ref{fig:nfTransferAlgorithm}.\r\n\r\n\\begin{figure}[htbp]\r\n  \\ContinuedFloat*\r\n\t\\begin{center}\r\n\t\t\\begin{framed}\r\n      \\begin{tabular}{p{16cm}}\t\r\n       \\textbf{ Non-fungible transfer algorithm} \\\\\r\n        \\\\\r\n        \\midrule\r\n        \\textbf{Bob's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\item Before Alice can send him anything, Bob must register his public keys $pk_B^Z$ and $pk_B^W$ against both his public Ethereum address $pk_B^E$ and his unique name `Bob' within the \\hyperref[sec:pkd]{PKD}.\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\midrule\r\n        \\textbf{Alice's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item Generate a random salt $\\sigma_{\\vec{AB}}$.\r\n          \\item Lookup Bob's `zkp' public key $pk_B^Z$ from the PKD.\r\n          \\item Compute $Z_B := h(\\;\\alpha\\;|\\;pk^Z_B\\;|\\;\\sigma_{\\vec{AB}}\\;)$, a token commitment which represents $\\alpha$.\r\n          \\item Compute $N_A := h(\\;\\sigma_{A}\\;|\\;sk^Z_A\\;)$, the nullifier of Alice's commitment $Z_A$.\r\n          \\item Get $\\psi_{Z_A}$ -- the sister-path of $Z_A$ -- from the Shield contract (see Details below).\r\n          \\item Get the latest Merkle root from the Shield contract: $\\roott_{n+m-1}$ (see Details below).\r\n          \\item Set public inputs $x = (\\;N_A,\\;\\roott_{n+m-1},\\;Z_B)$\r\n          \\item Set private inputs $\\omega = (\\alpha,\\;\\psi_{Z_A},\\;sk_A,\\;\\sigma_{A},\\;pk_B,\\;\\sigma_{\\vec{AB}})$\r\n          \\item Select $C_{nft-transfer}(\\;\\omega,\\;x\\;)$ -- the set of constraints which are satisfied if and only if:\r\n          \\begin{enumerate}\r\n            \\item $pk_A$ equals $h(\\;sk_A\\;)$; (Proof of knowledge of the secret key to $pk_A$) (see Details for why $pk_A$ isn't an input to $C$)\r\n            \\item $Z_A$ equals $h(\\;\\alpha\\;|\\;pk_A\\;|\\;\\sigma_A\\;)$ (Proof of the constituent values of $Z_A$) (see Details for why $Z_A$ isn't an input to $C$)\r\n            \\item $\\roott_{n+m-1}$ equals $h\\br*{\\psi_{1}\\;|...|\\;h\\br*{\\psi_{d-2}\\;|\\;h\\br*{\\psi_{d-1}\\;|\\;Z_A}\\;}...}$ (Proof that $Z_A$ belongs to the on-chain Merkle Tree)\r\n            \\item $N_A$ equals $h(\\;\\sigma_{A}\\;|\\;sk^Z_A\\;)$ (Proof $N_A$ is indeed the nullifier of $Z_A$)\r\n            \\item $Z_B$ equals $h(\\;\\alpha\\;|\\;pk^Z_B\\;|\\;\\sigma_{\\vec{AB}}\\;)$ (Proof that $Z_B$ contains the same asset as $Z_A$)\r\n          \\end{enumerate}\r\n          \\item Generate $\\pi := P(\\;p_C\\;,\\;x,\\;\\omega\\;)$; a proof of knowledge of satisfying arguments $(\\omega, x)\\;s.t.\\;C(\\omega, x) = 1$. Recall: $p_C$ -- the proving key for $C$ -- will be stored on Alice's computer.\r\n           \r\n          The pair $(\\pi, x)$ is the zk-SNARK which attests to knowledge of private inputs $\\omega$ without revealing them.\r\n          \\item Send $(\\pi, x)$ to the Shield contract for verification.\r\n           \r\n          Using web3: \\texttt{nfTokenShield.transfer(proof, inputs, vkId)}\r\n          %remember where the count (enumi) is up to and store it in ongoingEnumCounter:\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\midrule\r\n        \\textbf{Shield contract's steps:}\\\\\r\n        \\begin{enumerate}\r\n          %resume counter\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item Verify the proof as correct: call a Verifier contract to verify the \\texttt{(proof, inputs)} pair against the verification key represented by \\texttt{vkId}.\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\hline\r\n        ... \r\n\t\t\t\\end{tabular}\r\n\t\t\\end{framed}\r\n\t\\end{center}\r\n\\caption{Non-Fungible Transfer Algorithm}\r\n\\label{fig:nfTransferAlgorithm}\r\n\\end{figure}\r\n\r\n%continue on next page\r\n\\begin{figure}[htbp]\r\n  \\ContinuedFloat %to continue\r\n\t\\begin{center}\r\n\t\t\\begin{framed}\r\n      \\begin{tabular}{p{16cm}}\r\n       \\textbf{ Verifier contract's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item Compute \\texttt{result = verify(proof, inputs, vkId)}.\r\n          \r\n          I.e. Verify the \\texttt{(proof, inputs)} pair against the verification key.\r\n          \\item Return \\texttt{result}$\\in$\\texttt{\\{false, true\\}} to the Shield contract.\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\midrule\r\n        \\textbf{Shield contract's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item If \\texttt{result = false}, revert.\r\n          \\item Else:\r\n          \\begin{enumerate}\r\n            \\item Check $\\roott_{n+m-1}$ is in $\\rootsList$. (Revert if not).\r\n            \\item Check $N_A$ is not already in its list of `spent' nullifiers. (Revert if not).\r\n            \\item Add $Z_B$ to the next empty leaf of the Merkle Tree.\r\n            \\item Recalculate the path to the root of the Merkle Tree from $Z_B$ for future users.\r\n            \\item Append the newly calculated root $\\roott_{n+m}$ to the ever-increasing array $\\rootsList$\r\n            \\item Similarly append the nullifier $N_{A}$ to the ever-increasing array $\\bm N$.\r\n          \\end{enumerate}\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\midrule\r\n        \\textbf{Alice's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item Store relevant data in her local database, including the leafindex of $Z_B$.\r\n          \\item Send Bob important data privately via Whisper (using his public key $pk^W_B$):\r\n          \\begin{enumerate}\r\n            \\item The salt $\\sigma_{\\vec{AB}}$ of $Z_B$.\r\n            \\item The public key of Bob, $pk^Z_B$, used by Alice in the preimage of $Z_B$ (for completeness, so Bob can check the correctness of $Z_B$ himself).\r\n            \\item The tokenId $\\alpha$.\r\n            \\item $Z_B$.\r\n            \\item The leafIndex of $Z_B$ within the on-chain Merkle Tree $M$ (so Bob can locate it).\r\n          \\end{enumerate}\r\n          \\setcounter{ongoingEnumCounter}{\\value{enumi}}\r\n        \\end{enumerate}\r\n        \\ \\\\\r\n        \\midrule\r\n        \\textbf{Bob's steps:}\\\\\r\n        \\begin{enumerate}\r\n          \\setcounter{enumi}{\\value{ongoingEnumCounter}}\r\n          \\item Check the correctness of the information provided by Alice:\r\n          \\begin{enumerate}\r\n            \\item Check $Z_B$ equals $h(\\;\\alpha\\;|\\;pk^Z_B\\;|\\;\\sigma_{\\vec{AB}}\\;)$\r\n            \\item Check that $Z_B$ is stored at the leafIndex of $M$ which Alice claimed.\r\n          \\end{enumerate}\r\n          \\item Store relevant data in his local database, including whether or not his `correctness checks' passed.\r\n          \\setcounter{ongoingEnumCounter}{0} %reset for next figure\r\n        \\end{enumerate} \r\n\t\t\t\\end{tabular}\r\n\t\t\\end{framed}\r\n\t\\end{center}\r\n\\caption{Non-Fungible Transfer Algorithm} %same caption as the first part of this figure\r\n%\\label{fig:nfTransferAlgorithm} - no label in this second part of the figure\r\n\\end{figure}\r\n\r\n\r\n\\newpage\r\n\\subsubsection{Details}\r\n\\label{sec:721TransferDetails}\r\n\r\nWe refer to the numbered steps of Figure~\\ref{fig:nfTransferAlgorithm}.\r\n\r\n\\textbf{Step $1$}\r\n\\ \\\\\r\nThis is handled at the time Bob creates an account through the \\hyperref[sec:ui]{UI}.\\\\\r\n\\\\\r\n\\textbf{Step $2$}\r\n\\ \\\\\r\nThis is handled within the \\hyperref[sec:ui]{UI} microservice (or within the api-gateway).\\\\\r\n\\\\\r\n\\textbf{Step $3$}\r\n\\ \\\\\r\nThis is handled within the api-gateway when a call is made by Alice to transfer to Bob.\\\\\r\n\\\\\r\n\\textbf{Steps $4 - 5$}\r\n\\ \\\\\r\nThese steps are handled within \\hyperref[sec:nf-token-controller]{\\texttt{nf-token-controller.js}}.\\\\\r\n\\\\\r\n\\textbf{Steps $6 - 7$}\r\n\\ \\\\\r\nThese calls to the Shield contract are handled within \\hyperref[sec:nf-token-zkp]{\\texttt{nf-token-zkp.js}}.\\\\\r\n\\\\\r\nIt is important at this stage to note that there are an unknown number of other parties utilising the Shield contract.\r\nHence, the dynamic array of tokens $\\bm{Z}$ might have grown since Alice appended her $Z_A$ as the $n^{th}$ leaf of $M$ (during the \\hyperref[sec:721Mint]{Mint} explanation).\\\\\r\nSuppose there have been $m-1$ additional tokens added to $M$ since Alice added $Z_A$.\r\nThat is,\\\\\r\n\\begin{align*}\r\n  \\bm{Z}_{n+m-1} = (Z_0, Z_1,...,Z_{n-1}, Z_A, Z_{n+1},..., Z_{n+m-1})\r\n\\end{align*}\r\nWe denote the corresponding Merkle Tree which holds tokens $\\bm{Z}_{n+m-1}$ by $M_{n+m-1}$.\r\nWe denote its root by $\\roott_{n+m-1}$; an element of $\\rootsList = (\\roott_0, \\roott_1,...,\\roott_{n+m-1})$.\\\\\r\n\\\\\r\n\\begin{align*}\r\n  \\begin{forest}\r\n    [{$\\roott_{n+m-1}:= h\\br*{\r\n                        h\\br*{\r\n                          h\\br*{\r\n                            h\\br*{\r\n                              Z_0,Z_1\r\n                            },\r\n                            ...\r\n                          },\r\n                          h\\br*{\r\n                            h\\br*{\r\n                              Z_{n-1},Z_A\r\n                            },\r\n                            h\\br*{\r\n                              Z_{n+1},...\r\n                            }\r\n                          }\r\n                        },\r\n                        h\\br*{\r\n                          h\\br*{\r\n                            h\\br*{\r\n                              Z_{n+m-1},0\r\n                            },\r\n                            0\r\n                          },\r\n                          0\r\n                        }\r\n                      }\r\n                    $}\r\n      [{$ h\\br*{\r\n            h\\br*{\r\n              h\\br*{\r\n                Z_0,Z_1\r\n              },\r\n              ...\r\n            },\r\n            h\\br*{\r\n              h\\br*{\r\n                Z_{n-1},Z_A\r\n              },\r\n              h\\br*{\r\n                Z_{n+1},...\r\n              }\r\n            }\r\n          }\r\n        $}\r\n        [{$ h\\br*{\r\n              h\\br*{\r\n                Z_0,Z_1\r\n              },\r\n              ...\r\n            }\r\n          $}\r\n          [{$ h\\br*{\r\n                Z_0,Z_1\r\n              }\r\n            $}\r\n            [{$Z_0$}][{$Z_1$}]\r\n          ]\r\n          [...\r\n            [...][...]\r\n          ]\r\n        ]\r\n        [{$ h\\br*{\r\n              h\\br*{\r\n                Z_{n-1},Z_A\r\n              },\r\n              h\\br*{\r\n                Z_{n+1},...\r\n              }\r\n            }\r\n          $}\r\n          [{$ h\\br*{\r\n                Z_{n-1},Z_A\r\n              }\r\n            $}\r\n            [{$Z_{n-1}$}][{$Z_A$}]\r\n          ]\r\n          [{$ h\\br*{\r\n                Z_{n+1},...\r\n              }\r\n            $}\r\n            [$Z_{n+1}$][...]\r\n          ]\r\n        ]\r\n      ]\r\n      [{$ h\\br*{\r\n            h\\br*{\r\n              h\\br*{\r\n                Z_{n+m-1},0\r\n              },\r\n              0\r\n            },\r\n            0\r\n          }\r\n        $}\r\n        [{$ h\\br*{\r\n              h\\br*{\r\n                Z_{n+m-1},0\r\n              },\r\n              0\r\n            }\r\n          $}\r\n          [{$ h\\br*{\r\n                Z_{n+m-1},\r\n                0\r\n              }\r\n            $}\r\n            [{$Z_{n+m-1}$}][0]\r\n          ]\r\n          [0\r\n            [0][0]\r\n          ]\r\n        ]\r\n        [0\r\n          [0\r\n            [0][0]\r\n          ]\r\n          [0\r\n            [0][0]\r\n          ]\r\n        ]\r\n      ]\r\n    ]\r\n  \\end{forest}\r\n\\end{align*}\r\n\r\n\\noindent\r\nAlice retrieves the value of the current Merkle root, $\\roott_{n+m-1}$, from the Shield contract.\\\\\r\n\\\\\r\nSince Alice knows that $Z_A$ is at leaf-index $n$ of $M_{n+m-1}$, Alice can also retrieve the path from the leaf $Z_{n}=Z_A$ to the root $\\roott_{n+m-1}$. Path computations are done in \\texttt{zkp/src/compute-vectors.js}.\\\\\r\n\\\\\r\nWe denote this path:\r\n\\begin{align*}\r\n  \\phi_{Z_A} = [\\phi_{d-1}, \\phi_{d-2},..., \\phi_{1}, \\phi_0]\r\n\\end{align*}\r\nNote that $\\phi_0 = \\roott_{n+m-1}$.\\\\\r\n\\\\\r\nAlice also retrieve's the `sister-path' of this path:\r\n\\begin{align*}\r\n  \\psi_{Z_A} = [\\psi_{d-1}, \\psi_{d-2},..., \\psi_{1}, \\psi_0]\r\n\\end{align*}\r\nwhere $\\psi_0 = \\phi_0 = \\roott_{n+m-1}$\\\\\r\n\\\\\r\nFor ease of reading, let's focus only on the nodes of $M_{n+m-1}$ which Alice cares about for the purposes of transferring to Bob:\r\n\r\n\\begin{align*}\r\n  \\begin{forest}\r\n    [{$\\roott_{n+m-1}:=\\phi_0=\\psi_0$}\r\n      [{$\\phi_1$}\r\n        [{$\\psi_2$}\r\n          [...\r\n            [...][...]\r\n          ]\r\n          [...\r\n            [...][...]\r\n          ]\r\n        ]\r\n        [{$\\phi_2$}\r\n          [{$\\phi_3$}\r\n            [{$\\psi_4$}][{$Z_A$}]\r\n          ]\r\n          [{$\\psi_3$}\r\n            [...][...]\r\n          ]\r\n        ]\r\n      ]\r\n      [{$\\psi_1$}\r\n        [...\r\n          [...\r\n            [...][0]\r\n          ]\r\n          [0\r\n            [0][0]\r\n          ]\r\n        ]\r\n        [0\r\n          [0\r\n            [0][0]\r\n          ]\r\n          [0\r\n            [0][0]\r\n          ]\r\n        ]\r\n      ]\r\n    ]\r\n  \\end{forest}\r\n\\end{align*}\r\n\r\n\r\n\\noindent\r\nEquipped with $\\psi_{Z_A}$, Alice can prove that she owns a token commitment at one of the leaves of $M_{n+m-1}$, without revealing that it is \"$Z_n$ located at leaf-index $n$\".\\\\\r\n\\\\\r\n\\textbf{Steps $8 - 9$}\r\n\\ \\\\\r\nThese steps are handled within \\hyperref[sec:nf-token-controller]{\\texttt{nf-token-controller.js}}.\\\\\r\n\\\\\r\nAs a reminder, we let:\r\n\\begin{center}\r\n  \\begin{tabular}{l l}\r\n    $x = (N_{A},\\\r\n          \\roott_{n+m-1},\\\r\n          Z_B)$ & Public Inputs used to generate the Proof\\\\\r\n    $\\omega = (\\alpha,\\\r\n              \\psi_{Z_A},\\\r\n              sk_A,\\\r\n              \\sigma_{A},\\\r\n              pk_B,\\\r\n              \\sigma_{\\vec{AB}})$ & Private Inputs used to generate the Proof\\\\\r\n  \\end{tabular}\r\n\\end{center}\r\n\\ \\\\\r\n\\textbf{Steps $10 - 11$}\r\n\\ \\\\\r\nThese steps are handled within a \\hyperref[sec:zokrates]{ZoKrates} container.\\\\\r\n\\\\\r\nAlice uses the $C_{nft-transfer}$ (or $C$) -- the set of constraints for a non-fungible transfer, located in \\texttt{zkp/code/gm17/nft-transfer} (see \\hyperref[sec:trustedSetup]{Trusted Setup}). $C_{nft-transfer}(\\;\\omega,\\;x\\;)$ returns a value of $true$ if Alice provides a set of valid `satisfying' arguments $(\\omega, x)$ to $C$.\\\\\r\n\\\\\r\nLet's elaborate on each of the checks and calculations constraining the inputs to $C$ (we highlight public inputs in \\textbf{bold} below):\r\n\\begin{enumerate}\r\n  \\item Calculate $h(sk_A) =: pk_A'$.\\\\\r\n    Note that this newly calculated $pk_A'$ should equal $pk_A$ (Alice's public key), but we don't need to pass $pk_A$ as a private input and explicitly check that $pk_A'=pk_A$; a check on the correctness of $sk_A$ (and hence $pk_A'$) is implicitly achieved in the next two steps:\r\n  \\item Calculate $h(\\alpha\\;|\\;pk_A'\\;|\\;\\sigma_A) =: Z_A'$.\\\\\r\n    Note again that this newly calculated $Z_A'$ should equal $Z_A$ (Alice's token commitment), but we don't need to pass $Z_A$ as a private input and explicitly check that $Z_A'=Z_A$; a check on the correctness of $Z_A$ (and hence $Z_A'$) is implicitly achieved in the next step:\r\n  \\item Check inputs $\\psi_{Z_A}=[\\psi_{d-1}, \\psi_{d-2},..., \\psi_{1}, \\bm{\\psi_{0}=\\roott_{n+m-1}}]$ and the newly calculated $Z_A'$ satisfy:\\\\\r\n    $h\\br*{\\psi_{1}\\;|...|\\;h\\br*{\\psi_{d-2}\\;|\\;h\\br*{\\psi_{d-1}\\;|\\;Z_A'}\\;}...} = \\roott_{n+m-1} ( =: \\bm{\\psi_{0}})$\\\\\r\n    Given the one-way nature of our hashing function $h$, the only feasible way we could have arrived at the correct value of $\\roott_{n+m-1}$ is if the sister-path $\\psi_{Z_A}$ is correct, and if $Z_A'$ is correct, which (working backwards) must mean that $sk_A$ is correct.\r\n\r\n    How does the circuit know the value of $\\roott_{n+m-1}$ is correct? It doesn't; but it is a `public input', and we can rely upon the Shield smart contract to check the correctness of all public inputs.\\\\\r\n  \\\\\r\n  We've therefore shown in the steps so far, that:\r\n  \\begin{itemize}\r\n    \\item[--] Alice is the owner of a token commitment (because she knows its secret key)\r\n    \\item[--] Said token commitment is indeed a leaf of the on-chain Merkle Tree $M_{n+m-1}$.\r\n  \\end{itemize}\r\n\r\n  Alice commits to spending her token $Z_A$ in the next step:\r\n  \\item Check inputs $\\sigma_{A}, sk_A, \\bm{N_A}$ satisfy:\r\n    $h(\\sigma_{A}\\;|\\;sk_A) = \\bm{N_{A}}$\\\\\r\n    $N_A$ is referred to as a `nullifier' because it is understood by all participants to be an indisputable commitment to spend (`nullify') a token commitment. Remember that the token commitment being spent isn't revealed; the earlier steps have allowed Alice to demonstrate hidden knowledge of the secret key $sk_A$ of a token commitment which does indeed exist. By including $sk_A$ in the nullifier's preimage, Alice is binding herself as the executor of this transfer. By including $\\sigma_A$, Alice is specifying a serial number which is unique to the token $Z_A$ (thereby distinguishing this nullifier from those which would nullify any other token commitments she may own).\\\\\r\n  \\item Check inputs $\\alpha, pk_B, \\sigma_{\\vec{AB}}, \\bm{Z_B}$ satisfy:\r\n    $h(\\alpha\\;|\\;pk_B\\;|\\;\\sigma_{\\vec{AB}}) = \\bm{Z_B}$\\\\\r\n    This final step constrains the same asset $\\alpha$ to be included in $Z_B$ as was included in $Z_A$.\\\\\r\n    You might notice that the circuit doesn't actually constrain Alice to use the correct values for Bob's public key $pk_B$, nor the serial number $\\sigma_{\\vec{AB}}$ as inputs to the circuit. Alice is free to transfer ownership of the token commitment to anyone.\r\n\\end{enumerate}\r\nNotice how each stage is linked to the last, and that at each of the `Check' stages, private inputs are being reconciled against at least one public input (highlighted in \\textbf{bold} to help you notice). By structuring the circuit $C$ in this way, we are able to share only the public inputs with the Shield contract (along with a `proof' $\\pi_{C,x,\\omega}$). We'll see shortly that the Shield contract checks the correctness of each of the public inputs against its current states.\\\\\r\n\\\\\r\n\r\n\\noindent\r\nIf all of the above constraints are satisfied by the public and private inputs, ZoKrates will generate the proof $\\pi_{C,x,\\omega}$; a proof of knowledge of satisfying arguments $(\\omega, x) \\ s.t. \\ C(\\omega, x) = 1$.\\\\\r\n\\\\\r\n\\textbf{Step $12$}\r\n\\ \\\\\r\nThis transaction is handled within \\hyperref[sec:nf-token-zkp]{\\texttt{nf-token-zkp.js}}.\\\\\r\n\\\\\r\nHaving generated $\\pi_{C,x,\\omega}$, Alice then sends the following to the Shield contract from her anonymous Ethereum address $\\Xi_{A,1}$:\r\n\\begin{align*}\r\n  &\\pi_{C,x,\\omega}\\\\\r\n  &x = (N_{A}, \\roott_{n+m-1}, Z_B)\r\n\\end{align*}\r\n\\\\\r\nRecall that everyone knows the checks and calculations which have been performed in the circuit $C_{nft-transfer}$, because it is a public file in the Nightfall repository. Further, everyone knows the verification key $vk_C$ which uniquely represents this circuit, because it has been publicly stored in the Verifier Registry contract. Therefore, when this anonymous caller (Alice) shares the pair $(x, \\pi_{C,x,\\omega})$, and the `unique id' of the relevant verification key $vk_C$; everyone will interpret this information as the caller's intention to transfer, and everyone will be convinced that the caller knows the secret key which permits them to transfer ownership of a token commitment.\\\\\r\n\\\\\r\n\r\n\r\n\r\n\\textbf{Steps $13 - 15$}\r\n\\ \\\\\r\nThe Verifier Registry contract already has stored within it the verification key $vk_C$.\r\nIt runs a verification function $V(vk_C, \\pi_{C,x,\\omega}, x)$.\r\n\\begin{align*}\r\n  V: (vk_C, \\pi_{C,x,\\omega}, x) \\to \\{0,1\\}\r\n\\end{align*}\r\nwhere:\r\n\\[\r\n    V=\r\n\\begin{cases}\r\n    1,& \\text{if } \\pi_{C,x,\\omega} \\text{ and } x \\text{ satisfy } vk_C\\\\\r\n    0,& \\text{otherwise}\r\n\\end{cases}\r\n\\]\r\n\\ \\\\\r\n\r\n\r\n\\textbf{Steps $16 - 17$}\r\n\\ \\\\\r\nIf the Verifier contract returns $1$ ($true$) (verified) to the Shield contract, then the Shield contract will be satisfied that Alice's proof and public inputs represent her commitment to relinquish ownership of a token commitment, and to transfer ownership of the underlying asset to someone via the newly proposed token commitment $Z_B$. If the Verifier contract returns $0$, then the transaction will revert.\\\\\r\n\\\\\r\nLet's suppose Alice's $(x, \\pi_{C,x,\\omega})$ pair is verified.\\\\\r\n\\\\\r\nFollowing verification of the proof, the Shield contract will do the following:\r\n\\begin{enumerate}\r\n  \\item Check $\\roott_{n+m-1}$ is in $\\rootsList$.\\\\\r\n    (If not, the transfer will fail)\r\n  \\item Check $N_A$ is not already in the list of nullifiers, which we denote $\\bm{N}$.\\\\\r\n    (If $N_A$ is already in $\\bm{N}$, the transfer will fail)\r\n  \\item Append the commitment $Z_B$ to the ever-increasing array of tokens, $\\bm{Z}_{n+m}$, so that $\\bm{Z}_{n+m}=(Z_0, Z_1, ... Z_{n-1}, Z_A, Z_{n+1}, ... Z_{n+m-1}, Z_B)$\\\\\r\n  \\item Recalculate a Merkle Root $\\roott_{n+m}$ of $M_{n+m}$\\\\\r\n    \\\\\r\n    \\begin{align*}\r\n      \\begin{forest}\r\n        [{$\\roott_{n+m}:= h\\br*{\r\n                            h\\br*{\r\n                              h\\br*{\r\n                                h\\br*{\r\n                                  Z_0,Z_1\r\n                                },\r\n                                ...\r\n                              },\r\n                              h\\br*{\r\n                                h\\br*{\r\n                                  Z_{n-1},Z_A\r\n                                },\r\n                                h\\br*{\r\n                                  Z_{n+1},...\r\n                                }\r\n                              }\r\n                            },\r\n                            h\\br*{\r\n                              h\\br*{\r\n                                h\\br*{\r\n                                  Z_{n+m-1}, Z_B\r\n                                },\r\n                                0\r\n                              },\r\n                              0\r\n                            }\r\n                          }\r\n                        $}\r\n          [{$ h\\br*{\r\n                h\\br*{\r\n                  h\\br*{\r\n                    Z_0,Z_1\r\n                  },\r\n                  ...\r\n                },\r\n                h\\br*{\r\n                  h\\br*{\r\n                    Z_{n-1},Z_A\r\n                  },\r\n                  h\\br*{\r\n                    Z_{n+1},...\r\n                  }\r\n                }\r\n              }\r\n            $}\r\n            [{$ h\\br*{\r\n                  h\\br*{\r\n                    Z_0,Z_1\r\n                  },\r\n                  ...\r\n                }\r\n              $}\r\n              [{$ h\\br*{\r\n                    Z_0,Z_1\r\n                  }\r\n                $}\r\n                [{$Z_0$}][{$Z_1$}]\r\n              ]\r\n              [...\r\n                [...][...]\r\n              ]\r\n            ]\r\n            [{$ h\\br*{\r\n                  h\\br*{\r\n                    Z_{n-1},Z_A\r\n                  },\r\n                  h\\br*{\r\n                    Z_{n+1},...\r\n                  }\r\n                }\r\n              $}\r\n              [{$ h\\br*{\r\n                    Z_{n-1},Z_A\r\n                  }\r\n                $}\r\n                [{$Z_{n-1}$}][{$Z_A$}]\r\n              ]\r\n              [{$ h\\br*{\r\n                    Z_{n+1},...\r\n                  }\r\n                $}\r\n                [$Z_{n+1}$][...]\r\n              ]\r\n            ]\r\n          ]\r\n          [{$ h\\br*{\r\n                h\\br*{\r\n                  h\\br*{\r\n                    Z_{n+m-1}, Z_B\r\n                  },\r\n                  0\r\n                },\r\n                0\r\n              }\r\n            $}\r\n            [{$ h\\br*{\r\n                  h\\br*{\r\n                    Z_{n+m-1}, Z_B\r\n                  },\r\n                  0\r\n                }\r\n              $}\r\n              [{$ h\\br*{\r\n                    Z_{n+m-1}, Z_B\r\n                  }\r\n                $}\r\n                [{$Z_{n+m-1}$}][{$Z_B$}]\r\n              ]\r\n              [0\r\n                [0][0]\r\n              ]\r\n            ]\r\n            [0\r\n              [0\r\n                [0][0]\r\n              ]\r\n              [0\r\n                [0][0]\r\n              ]\r\n            ]\r\n          ]\r\n        ]\r\n      \\end{forest}\r\n    \\end{align*}\r\n\r\n    Note that the Shield contract only needs to calculate the hashes on the path from $Z_B$ to the root.\r\n\r\n  \\item Append $\\roott_{n+m}$ to the ever-increasing array $\\rootsList$\r\n  \\item Similarly append the nullifier $N_{A}$ to the ever-increasing array $\\bm N$.\r\n\\end{enumerate}\r\n\\ \\\\\r\n\r\n\\textbf{Steps $18 - 19$}\r\n\\ \\\\\r\nThe api-gateway routes the data resulting from a transfer to her local database.\\\\\r\n\\\\\r\nSimilarly, the api-gateway ensures any sensitive data (data which is private to Alice alone) is filtered before Alice sends data to Bob.\\\\\r\n\\\\\r\nData which is crucial to Bob verifying his ownership of the new $Z_B$ is encrypted with Bob's public whisper key $pk^W_B$ and broadcast to the Whisper network.\\\\\r\n\\\\\r\n\r\n\\textbf{Steps $20 - 21$}\r\n\\ \\\\\r\nNightfall uses web3.shh to use Whisper. Bob's logged-in application will listen for all Whisper messages, and will try to decrypt all messages with his private whisper key $sk^W_B$. If decryption is successful, the data will be stored in the relevant database on Bob's local machine.\\\\\r\n\\\\\r\n\\hyperref[sec:nf-token-zkp]{\\texttt{nft-token-zkp.js}} includes functions to cross-reference the data Bob has received from Alice against the data stored in the Shield contract.\\\\\r\n\\\\\r\nBob will store all important information in his private database.\r\n\r\n", "meta": {"hexsha": "d027cbdf0e994278be161e50db42899962044972", "size": 26737, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/whitepaper/protocols/ERC721/transfer721.tex", "max_stars_repo_name": "hadasz/nightfall", "max_stars_repo_head_hexsha": "10b7aaffab72889620b7bc36a216ce7cfaffa17e", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/whitepaper/protocols/ERC721/transfer721.tex", "max_issues_repo_name": "hadasz/nightfall", "max_issues_repo_head_hexsha": "10b7aaffab72889620b7bc36a216ce7cfaffa17e", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/whitepaper/protocols/ERC721/transfer721.tex", "max_forks_repo_name": "hadasz/nightfall", "max_forks_repo_head_hexsha": "10b7aaffab72889620b7bc36a216ce7cfaffa17e", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2608024691, "max_line_length": 698, "alphanum_fraction": 0.5146052287, "num_tokens": 7258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.5078118642792044, "lm_q1q2_score": 0.41517402345734483}}
{"text": "%-------------------------------------------------------------------------------\n%\tNAME:\treport.tex\n%\tAUTHOR: Connor Beardsmore - 15504319\n%\tLAST MOD:\t01/05/17\n%\tPURPOSE:\tFCC Assignment Report\n%\tREQUIRES:\tNONE\n%-------------------------------------------------------------------------------\n\n\\documentclass[]{article}\n\\usepackage[ margin=3cm ]{geometry}\n\\usepackage{graphicx}\n\\usepackage{fancyhdr}\n\\usepackage{float}\n\\usepackage{hyperref}\n\\usepackage{transparent}\n\\usepackage{multicol}\n\\usepackage{amsmath}\n\\usepackage[final]{pdfpages}\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{algorithmicx}\n\\usepackage{algpseudocode}\n\\usepackage{amssymb}\n\\usepackage[style=chicago-authordate,backend=biber]{biblatex}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\lhead{Connor Beardsmore - 15504319}\n\\rhead{FCC200}\n\\lfoot{May 2017}\n\\rfoot{\\thepage}\n\n\\pagenumbering{arabic}\n\\graphicspath{{./images/}}\n\n\\addbibresource{bib/references.bib}\n\\nocite{*}\n\n%-------------------------------------------------------------------------------\n% CODE HIGHLIGHTING FOR LISTINGS\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{backcolour}{rgb}{0.99,0.99,0.99}\n\n\\lstdefinestyle{mystyle}{\n\tbackgroundcolor=\\color{backcolour},   \n\tcommentstyle=\\color{codegreen},\n\tkeywordstyle=\\color{magenta},\n\tnumberstyle=\\tiny\\color{codegray},\n\tstringstyle=\\color{codepurple},\n\tbasicstyle=\\footnotesize,\n\tbreakatwhitespace=false,         \n\tbreaklines=true,                 \n\tcaptionpos=b,                    \n\tkeepspaces=true,                 \n\tnumbers=left,                    \n\tnumbersep=5pt,                  \n\tshowspaces=false,                \n\tshowstringspaces=false,\n\tshowtabs=false,                  \n\ttabsize=2\n}\n\n\\lstset{style=mystyle}\n\n\n%-------------------------------------------------------------------------------\n\\begin{document}\n%-------------------------------------------------------------------------------\n% TITLE PAGE\n\n\\includepdf[]{./images/cover_page.pdf}\n\n\\begin{titlepage}\n\t\\begin{center}\n\t\t\\vspace*{1cm}\n\t\t\\LARGE\\textbf{FCC200 Report}\n\t\t\\break\n\t\tRSA Cryptosystem Implementation\n\t\t\\vspace{1cm}\n\t\t\\break\n\t\t\\Large\\textbf{Connor Beardsmore - 15504319} \n\t\t\\vspace{15cm}\n\n\t\t\\normalsize\n\t\tCurtin University \\\\\n\t\tScience and Engineering \\\\\n\t\tPerth, Australia \\\\\n\t    May 2017\n\t    \n\t\\end{center}\n\\end{titlepage}\n\n%-------------------------------------------------------------------------------\n% BINARY MODULAR EXPONENTIATION\n\\vspace*{-0.8cm}\n\\section*{\\hfil RSA Implementation\\hfil}\n\n\\subsection*{Modular Exponentiation}\n\\noindent\nModular exponentiation is used to calculate the remainder when a base \\textit{b} is raised to an exponent \\textit{e} and reduced by some modulus \\textit{m}. The simple right-to-left method provided by \\cite{alttext} utilizes exponentiation by squaring. The full Java code for the implementation of this method is illustrated below. The running time of this algorithm is $O(log\\;e)$ which provides a significant improvement over more simplistic methods of time complexity $O(e)$ (\\cite{maintext}). This calculation is a core component of RSA and thus its efficiency is crucial to the speed of the RSA implementation.\n\n\\vspace{0.2cm}\n\\lstinputlisting[language=C,linerange={59-92} ]{../../rsa/numberTheory.c}{}\n\n\\noindent\nThe code above was utilized to calculate the following example:\n\n$$236^{239721}\\;mod\\;2491=236$$\n\n\\vspace{0.2cm}\n\\noindent\nThe running of this code provided the following output:\n\n\\begin{figure}[H]\n\t\t\\centering\n\t\\includegraphics[height=\\textheight/10,width=\\textwidth/3]{exponentiation.png}\n\t\\caption{Modular Exponentiation Example}\n\\end{figure}\n\n\\pagebreak\n\n%-------------------------------------------------------------------------------\n% RSA IMPLEMENTATION\n\\vspace*{-0.8cm}\n\n\\subsection*{RSA Testing}\n\nThe implemented RSA cipher works correctly with any key generated by the system. The recovered plaintext in Figure 4 is identical to the original plaintext of Figure 2, as confirmed by the Linux \\textit{diff} command. No major problems were encountered during the implementation phase. The bytes visible in the ciphertext are not readable as plaintext and as a result, standard text editors cannot appropriately display the information.\n\n\\vspace{0.5cm}\n\\begin{figure}[H]\n\t\\includegraphics[height=\\textheight/6,width=\\textwidth]{rsa_plain1.png}\n\t\\includegraphics[height=\\textheight/6,width=\\textwidth]{rsa_plain2.png}\t\n\t\\caption{RSA Plaintext}\n\t\\centering\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\includegraphics[width=\\textwidth]{rsa_cipher1.png}\n\t\\includegraphics[width=\\textwidth]{rsa_cipher2.png}\t\n\t\\caption{RSA Ciphertext}\n\t\\centering\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\includegraphics[height=\\textheight/6,width=\\textwidth]{rsa_plain1.png}\n\t\\includegraphics[height=\\textheight/6,width=\\textwidth]{rsa_plain2.png}\t\n\t\\caption{RSA Recovered Plaintext}\n\t\\centering\n\\end{figure}\n\n\\pagebreak\n\n%-------------------------------------------------------------------------------\n% ADDITIONAL QUESTIONS\n\n\\vspace*{-0.8cm}\n\\section*{\\hfil Additional Questions\\hfil}\n\n\\subsection*{Signature Forgery}\n\nRSA can be utilized as a message signature scheme to provide authentication to messages. If Alice wants to send a signed message to Bob, she first produces a \\textit{hash value} of the message $H(m)$, then raises this to the power $d(modulo\\;n)$ and attaches it to the message as a signature. When Bob receives the message, he utilizes the same hashing function, raises the result to the power of $e(modulo\\;n)$ and compares to the message signature ($H(m)=H(m')$). If they are the same, Bob can be assured that the message was signed by Alice or someone with knowledge of Alice's private key.\\\\\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=\\textheight/7,width=12cm]{rsasignature.png}\n\t\\caption{RSA Signature Scheme (\\cite{alttext})}\n\\end{figure}\n\n\\noindent\nIn this scheme, it is not possible to completely ensure the message was sent by Alice. If Bob has some alternate message $m''$ with a hash value $H(m'')$ matching that of Alice's $H(m)$ as discussed in \\cite{RSA}, Bob can pretend to be Alice. He can simply resend Alice's signature he received onwards and the receiver of this message will believe that the message was sent by Alice. He can then perform malicious actions such as replay attacks depending on his intent. This can only occur if Bob finds a hash collision where $H(m)=H(m')$. It is however unlikely for Bob to create a \\textit{meaningful} message with a hash value matching Alice's (\\cite{alttext}). This is analogous to the idea of Birthday attacks mentioned in \\cite{lecture3}.\\\\\n\n\\noindent\nTo prevent this situation from occurring, the hash function utilized for the digital signature must be strongly collision resistant (\\cite{RSA}). Strong collision resistance asserts that there exists no $m$ and $m'$ where $m!=m'$ so that $H(m)=H(m')$. Thus if the hash function adheres to this property, the above situation cannot occur.\n\n\\break\n\\subsection*{Birthday Attack}\n\n\\vspace{0.5cm}\n\\begin{center}\n\\textit{In a group of 23 randomly selected people, the probability that two\\\\ of them share the same birthday is larger than 50\\%}\n\\end{center}\n\\vspace{0.5cm}\n\n\\noindent\nFirstly, the probability that two people have different birthdays is found:\n\n$$1-\\frac{1}{365}=\\frac{364}{365}=0.99726$$\n\n\\vspace{0.5cm}\n\\noindent\nThis can be extended to determine if three people have different birthdays:\n\n$$1-\\frac{2}{365}=\\frac{363}{365}=0.99452$$\n\n\\vspace{0.5cm}\n\\noindent\nUtilizing conditional probability (\\cite{lecture2}) we can construct the probability that all 23 people have different birthdays. This is simply represented as a series of fractions with their product producing the resultant probability:\n\n$$1\\times(1-\\frac{1}{365})(1-\\frac{2}{365})...(1-\\frac{22}{365})=0.493$$\n\n\\vspace{0.5cm}\n\\noindent\nTo find the probability that two of the people have the same birthday, we inverse this number by subtracting from the total probability (1):\n\n$$1-0.493=0.507=50.7\\%$$\n\n\\vspace{0.5cm}\n\\noindent\nIt is thus evident that the probability of two people in a set of 23 random selected sharing the same birthday is greater than 50\\%.\n\n\\pagebreak\n\n%-------------------------------------------------------------------------------\n% RSA CODE\n\n\\vspace*{-0.8cm}\n\\begin{center}\n\t\\section*{RSA Source Code}\n\\end{center}\n\n\\subsection*{makefile}\n\\lstinputlisting[language=make,linerange={} ]{../../rsa/Makefile}\\pagebreak{}\n\\subsection*{numberTheory.h}\n\\lstinputlisting[language=C,linerange={} ]{../../rsa/numberTheory.h}\\pagebreak{}\n\\subsection*{numberTheory.c}\n\\lstinputlisting[language=C,linerange={} ]{../../rsa/numberTheory.c}\\pagebreak{}\n\\subsection*{main.h}\n\\lstinputlisting[language=C,linerange={} ]{../../rsa/main.h}\\pagebreak{}\n\\subsection*{main.c}\n\\lstinputlisting[language=C,linerange={} ]{../../rsa/main.c}\\pagebreak{}\n\n%-------------------------------------------------------------------------------   \n% REFERENCES\n\n\\break\n\\setlength\\bibitemsep{4\\itemsep}\n\\printbibliography[title={References}]\n\n%-------------------------------------------------------------------------------\n\\end{document}   \n%-------------------------------------------------------------------------------:", "meta": {"hexsha": "0d8173cd149aa32346fcf00b5b21ad214cd2b1ae", "size": 9201, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/Assignment 2/report.tex", "max_stars_repo_name": "cbeardsmore/cryptoo", "max_stars_repo_head_hexsha": "583439e509c92d430485ee87497822fe6cbdcc4d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documentation/Assignment 2/report.tex", "max_issues_repo_name": "cbeardsmore/cryptoo", "max_issues_repo_head_hexsha": "583439e509c92d430485ee87497822fe6cbdcc4d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documentation/Assignment 2/report.tex", "max_forks_repo_name": "cbeardsmore/cryptoo", "max_forks_repo_head_hexsha": "583439e509c92d430485ee87497822fe6cbdcc4d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7090163934, "max_line_length": 745, "alphanum_fraction": 0.6675361374, "num_tokens": 2348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7931059438487663, "lm_q1q2_score": 0.4151277898727939}}
{"text": "\\section{Nested hierarchy as the random variability structure}\n\\label{sec:variabilityModel}\n\\label{math:variability}\n\nThis section describes the variability structure of the random effects and the related naming convention. It is largely based on the discussions and conclusions from the Copenhagen focus meeting \\cite{Copenhagen:2013}. Accordingly, in the following we will distinguish: \n\\begin{itemize}\n\\item\n(related to the observations) -- \\textit{residual variability}, also known as \\textit{intra-individual variability} and\n\\item\n(related to the parameters) -- \\textit{inter-individual} and \\textit{inter-occasion variabilities}\n\\end{itemize}\nThe former is described in the section \\ref{sec:residualErrorModel}, while the latter is described in this section.\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=70mm]{Subject-level}\n \\caption{Inter-individual variability typically occurring in an experiment, here $\\log(V_{i=1\\cdots5})$ i.e. values for five subjects, varying around a typical value $\\log(V_{pop})$, are shown.}\n \\label{fig:subjectLevelVariability}\n\\end{figure}\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=120mm]{Subject-occasion-level}\n \\caption{Subject variability level, $(0)$, and within-subject (or occasion) variability level, $(-1)$, typically occurring in an experiment, with index $i$ for subjects and $k$ for occasion. Here two subjects only are visualised, each of them having four or three occasions, respectively.}\n \\label{fig:subjectOccasionLevelVariability}\n\\end{figure}\n\n\\subsection{Motivation}\nOne way to look at variability is to consider the following simple experiment: in this experiment, we estimate the volume of distribution in five subjects. Following a drug administration we collect blood samples over a time interval and estimate each subject's PK parameters. The result will be a set of five individual estimates such as those in Figure \\ref{fig:subjectLevelVariability}. The values vary around a certain typical/population value. It is apparent that the only variability source is the fact that these are different persons, i.e. we have a rough estimate of the so called \\textit{inter-individual} variability.\\\\\nAs an extension of this setup, we can now consider different number of occasions, when the PK parameters are estimated for each subject. If we restrict the discussion to two subjects only, each of them having three or four occasions, respectively, we can illustrate the results such those in Figure \\ref{fig:subjectOccasionLevelVariability}. Repeatedly performing the same experiment for each subject is equivalent to create an additional level of variability, the \\textit{inter-occasion within individual} variability.\\\\ \nSimilarly, one can add e.g. 'country' as a new variability level. If a clinical trial has been conducted in various countries, it is reasonable to ask if the geographic location influences the outcome of the study. \n\n\\subsection{General case}\nAs a generalisation of the examples described above, one can derive the \\textit{nested hierarchy} (also known as \\textit{inclusion hierarchy}) of the variability structure of random effects. It can be visualised as a tree or alternatively using a Venn diagram, see Figures \\ref{IOVgeneral_tree}, \\ref{IOVgeneral_venn}. \\\\\nThe tree representation consists of \\textit{nodes} and \\textit{links} or \\textit{edges}. It has the advantage that it visualises the whole structure explicitly from the top level, the \\textit{root} node, down to lowest level of the variability. It provides immediate insights needed to understand or to verify the setup of a trial design. However, in case of a very complex structure, with high number of levels and/or subjects, it can become very large, making the tree difficult to represent in a typical document. It this case showing only partial branches will be more helpful, e.g. Figure \\ref{IOVgeneral_tree}. On the contrary, the Venn diagram visualises the levels only, and it might be more suited for the complex cases. Usually, the variability structure consists of only one or two levels, e.g. \\textit{individual} or  \\{\\textit{individual}, \\textit{occasion}\\}, see examples below. \n\n\nThe \\textit{root}, i.e. the top node in the tree structure, stands for the population/typical value of a parameter. Following the current nomenclature, every subsequent variability level is either 'positive' or 'negative' dependent on its position relative to the 'subject level', denoted as 0 -- the level 'zero'. Each level has a covariance matrix associated with it, i.e. \n\\begin{itemize}\n\\item \n$\\Omega^{+n}$ -- for levels above the 'zero' level -- their names will vary according to the nature of the levels. For example the variability on country level is called 'between-country variability'.\n\\item \n$\\Omega^0$ -- also called BSV (between subject variability) or IIV (inter-individual variability).\n\\item \n$\\Omega^{-n}$ -- for levels below the 'zero' level -- called WSV (within-subject variability) or IOV (inter-occasion variability).\n\\end{itemize}\nThe number of levels will vary dependent on the nature of the study. Cases without or with only positive/negative levels are possible. Please note that \\pharmml doesn't require or use numbers to be assigned to the various levels of variability. Instead the user can define meaningful identifiers.\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=120mm]{IOV-general-TREE}\n \\caption{General nested hierarchy of the variability structure -- as tree. Note that \\pharmml doesn't require or use numbers to be assigned to the various levels of variability. Instead the user can define meaningful identifiers.}\n \\label{IOVgeneral_tree}\n\\end{figure}\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=100mm]{IOV-general-VENN}\n \\caption{General nested hierarchy of the variability structure -- as Venn diagram.}\n \\label{IOVgeneral_venn}\n\\end{figure}\n\n\n\\paragraph{Example 1}\nThis example handles the simplest scenario, with only one level of variability: \\textit{subject}--level, see Figure \\ref{tree_IOV0}. The following symbols are used\n\\begin{itemize}\n\\item\n$i$ -- subject index, $1\\le i \\le N$\n\\end{itemize} \nwith $N_l$ -- number of subjects.\\\\\nThe typical parameter model, without covariate, reads as follows:\n\\begin{align*}\n& \\log(V_i) = \\log(V_{pop}) + \\eta_i^{(0)}  \n\\end{align*} \nor alternatively:\n\\begin{align*}\n& V_i = V_{pop} \\,e^{\\eta_i^{(0)}}  \n\\end{align*} \nwith $\\eta_i^{(0)} \\sim \\mathcal{N}\\big(0,\\Omega^{(0)}\\big)$.\n\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=120mm]{tree_IOV0}\n \\caption{Example 1 -- single level of variability: \\textit{subject}-- level}\n \\label{tree_IOV0}\n\\end{figure}\n\n\\paragraph{Example 2}\nIn this example there are three levels of variability: \\{\\textit{centre, subject, occasion}\\}, see Figure \\ref{tree_IOV1}. Following symbols are used:\n\\begin{itemize}\n\\item\n$l$ -- centre index, $1\\le l \\le L$\n\\item\n$i$ -- subject index, $1\\le i \\le N_l$\n\\item\n$k$ -- occasion index, $1\\le k \\le N_{li}$\n\\end{itemize} \nwith\n\\begin{itemize}\n\\item\n$L$ -- number of centres\n\\item\n$N_l$ -- number of subjects in centre \\textit{l}\n\\item\n$N_{li}$ -- number of occasions in subject \\textit{i} in centre \\textit{l}\n\\end{itemize} \nThe parameter model, without covariate, reads as follows:\n\\begin{align*}\n& \\log(V_{lik}) = \\log(V_{pop}) + \\eta_l^{(1)} + \\eta_{li}^{(0)} + \\eta_{lik}^{(-1)}  \n\\end{align*} \nor alternatively:\n\\begin{align*}\n& V_{lik} = V_{pop} \\, e^{\\eta_l^{(1)}} e^{\\eta_{li}^{(0)}} e^{\\eta_{lik}^{(-1)}}  \n\\end{align*} \nwith\n\\begin{align*}\n & \\eta_l^{(1)} \\sim \\mathcal{N}\\big(0,\\Omega^{(1)}\\big), \\quad \\eta_{li}^{(0)} \\sim \\mathcal{N}\\big(0,\\Omega^{(0)}\\big),\n\\quad \\eta_{lik}^{(-1)} \\sim \\mathcal{N}\\big(0,\\Omega^{(-1)}\\big) \n\\end{align*}\n\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=120mm]{tree_IOV1}\n \\caption{Example 1 -- three levels of variability: \\{\\textit{centre, subject, occasion}\\}}\n \\label{tree_IOV1}\n\\end{figure}\n\n\n\\paragraph{Example 3}\nIn this example there are four levels of variability: \\{\\textit{country, centre, subject, occasion}\\}, see Figure \\ref{tree_IOV2}. The symbol list is extended by one for 'country' as follows:\n\\begin{itemize}\n\\item\n$m$ -- country index, $1\\le m \\le M$\n\\item\n$l$ -- centre index, $1\\le l \\le N_m$\n\\item\n$i$ -- subject index, $1\\le i \\le N_{ml}$\n\\item\n$k$ -- occasion index, $1\\le k \\le N_{mli}$\n\\end{itemize} \nwith\n\\begin{itemize}\n\\item\n$M$ -- number of countries\n\\item\n$N_m$ -- number of centres in country \\textit{m}\n\\item\n$N_{ml}$ -- number of subjects in centre \\textit{l} in country \\textit{m}\n\\item\n$N_{mli}$ -- number of occasions in subject \\textit{i} in centre \\textit{l} in country \\textit{m}\n\\end{itemize} \nThe parameter model reads as follows:\n\\begin{align*}\n& \\log(V_{mlik}) = \\log(V_{pop}) + \\eta_m^{(2)} + \\eta_{ml}^{(1)} + \\eta_{mli}^{(0)} + \\eta_{mlik}^{(-1)}  \n\\end{align*} \nor alternatively:\n\\begin{align*}\n& V_{mlik} = V_{pop} \\, e^{\\eta_m^{(2)}} e^{\\eta_{ml}^{(1)}} \\; e^{\\eta_{mli}^{(0)}} \\; e^{\\eta_{mlik}^{(-1)}}  \n\\end{align*} \nwith\n\\begin{align*}\n & \\eta_m^{(2)} \\sim \\mathcal{N}\\big(0,\\Omega^{(2)}\\big), \\quad \\eta_{ml}^{(1)} \\sim \\mathcal{N}\\big(0,\\Omega^{(1)}\\big), \\quad\n \\eta_{mli}^{(0)} \\sim \\mathcal{N}\\big(0,\\Omega^{(0)}\\big), \\quad \\eta_{mlik}^{(-1)} \\sim \\mathcal{N}\\big(0,\\Omega^{(-1)}\\big) \n\\end{align*} \n\n\n\n\\begin{figure}[htb!]\n\\centering\n  \\includegraphics[width=120mm]{tree_IOV2}\n \\caption{Example 2 -- four levels of variability:  \\{\\textit{country, centre, subject, occasion}\\}}\n \\label{tree_IOV2}\n \\end{figure}\n\n", "meta": {"hexsha": "b09c8529c843c84f30a55fd0773a22f88d35892a", "size": 9505, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "input/variabilityLevels_specSection.tex", "max_stars_repo_name": "pharmml/pharmml-spec", "max_stars_repo_head_hexsha": "b102aedd082e3114df26a072ba9fad2d1520e25f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-01-26T13:17:54.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-26T13:17:54.000Z", "max_issues_repo_path": "input/variabilityLevels_specSection.tex", "max_issues_repo_name": "pharmml/pharmml-spec", "max_issues_repo_head_hexsha": "b102aedd082e3114df26a072ba9fad2d1520e25f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "input/variabilityLevels_specSection.tex", "max_forks_repo_name": "pharmml/pharmml-spec", "max_forks_repo_head_hexsha": "b102aedd082e3114df26a072ba9fad2d1520e25f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.7005649718, "max_line_length": 894, "alphanum_fraction": 0.7340347186, "num_tokens": 2722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4150926072451481}}
{"text": "\\documentclass[ignorenonframetext,notheorems,aspectratio=1610]{beamer}\n\\usetheme[compress]{Madrid}\n\\useoutertheme{infolines}\n\\usecolortheme{iwr}\n\\usepackage{../mathsim}\n\\input{./fig/tikzsettings}\n\\mathtoolsset{showonlyrefs}\n\\excludecomment{solution}\n\\externaldocument{main}\n\n\\makeatletter\n\\def\\blocktheorem#1#2(#3){\\begin{block}{#3 \\capitalizewords{#1}%\n      \\def\\tmp{#2}\\ifx\\tmp\\empty{}\\else (#2)\\fi}}\n\\def\\endblocktheorem{\\end{block}}\n\\makeatother\n\\def\\mylabel#1{}\n\\let\\label\\mylabel\n%\\renewcommand{\\label}[1]{}\n\\renewcommand{\\eqref}[1]{(\\ref{#1})}\n\\renewcommand{\\define}[1]{\\textbf{#1}}\n\\begin{document}\n\\frame{\\tableofcontents[hideallsubsections]}\n\\section{From elliptic to mixed problems}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\\frame {\\input {blocks/Notation-vector-diff-operators.tex}}\n\\frame {\\input {blocks/Definition-strain-tensor.tex}}\n\\frame {\\input {blocks/Definition-hooke.tex}}\n\\frame {\\input {blocks/Definition-weak-lame-navier.tex}}\n\\frame {\\input {blocks/Problem-frobenius.tex}}\n\\frame {\\input {blocks/Assumption-korn-inequality.tex}\n  \\input {blocks/Lemma-korn.tex}}\n\\frame {\\small\\input {blocks/Problem-elasticity-standard.tex}}\n\n\\begin{frame}\n  \\frametitle{Example: hanging sheet}\n  \\centering\n  \\begin{tabular}{ccc}\n    \\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-0}\n    &\\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-1}\n    &\\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-2}\n    \\\\\n    $\\lambda = 1$&$\\lambda = 10$&$\\lambda = 100$\n    \\\\\\\\\n    \\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-3}\n    &\\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-4}\n    &\\includegraphics[width=.25\\textwidth]{./graph/elasticity/stalactite-5}\n    \\\\\n    $\\lambda = 1000$&$\\lambda = 10000$&$\\lambda = 100000$\n  \\end{tabular}\n\\end{frame}\n\\frame {\\input {blocks/Definition-displacement-pressure.tex}}\n\\frame {\\input {blocks/Definition-lame-navier-strong.tex}}\n\\frame {\\input {blocks/Definition-saddle-point-operators.tex}}\n\\frame {\\input {blocks/Definition-saddle-point-abstract.tex}}\n\\frame {\\input {blocks/Notation-saddle-point-form.tex}}\n\\frame {\\input {blocks/Definition-schur-complement.tex}\n  \\input {blocks/Lemma-schur-complement1.tex}}\n\\frame {\\input {blocks/Lemma-schur-definiteness.tex}}\n\\frame {\\input {blocks/Definition-stokes-eq1.tex}}\n\\frame {\\input {blocks/Definition-solenoidal.tex}}\n\\frame {\\input {blocks/Lemma-stokes-equivalence.tex}}\n\\frame {\\input {blocks/Definition-stokes-eq2.tex}}\n\\frame {\\input {blocks/Definition-stokes-boundary2.tex}}\n\\frame {\\input {blocks/Lemma-divergence-compatibility.tex}\n\\input {blocks/Notation-pressure-constant.tex}}\n\\frame {\\input {blocks/Theorem-minimization.tex}}\n\\frame {\\input {blocks/Definition-reduced-problem.tex}\n\\input {blocks/Lemma-reduced-wellposedness.tex}}\n\\frame {\\input {blocks/Theorem-lagrange-multiplier.tex}}\n\\frame {\\input {blocks/Problem-lagrange-multiplier.tex}}\n\\frame {\\input {blocks/Corollary-stokes-lagrange.tex}}\n\n\\section{Conditions for well-posedness}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\\frame {\\input {blocks/Problem-unbounded-inverse.tex}}\n\\frame {\\input {blocks/Problem-lax-milgram-not-applicable.tex}}\n\\frame {\\input {blocks/Theorem-la-invertible.tex}}\n\\frame {\\input {blocks/Theorem-svd.tex}}\n\\frame {\\input {blocks/Corollary-svd-order.tex}}\n\\frame {\\input {blocks/Definition-ker-range-rn.tex}\n\\input {blocks/Definition-orthogonal1.tex}}\n\\frame {\\input {blocks/Lemma-ker-coker-rn.tex}\n\\input {blocks/Corollary-ker-coker-iso.tex}\n\\input {blocks/Corollary-svd-infsup.tex}}\n\\frame {\\input {blocks/Definition-infsup1.tex}\n\\input {blocks/Lemma-infsup2.tex}\n\\input {blocks/Problem-inf-sup-equivalence.tex}}\n\\frame {\\input {blocks/Definition-polar-orthogonal.tex}\n\\input {blocks/Lemma-orthogonal-closed.tex}\n\\input {blocks/Theorem-orthogonal-complement.tex}}\n\\frame {\\input {blocks/Definition-orthogonal-projection.tex}}\n\\frame {\\input {blocks/Lemma-polar-orthogonal-hilbert.tex}}\n\\frame {\\input {blocks/Theorem-closed-range.tex}}\n\\frame {\\input {blocks/Theorem-open-mapping.tex}\n\\input {blocks/Lemma-closed-infsup.tex}}\n\\frame {\\input {blocks/Theorem-infsup-well-equivalence.tex}}\n\\frame {\\input {blocks/Corollary-infsup-well-posedness1.tex}}\n\\frame {\\input {blocks/Theorem-infsup-well-posedness2.tex}}\n\\frame {\\input {blocks/Theorem-infsup-mixed1.tex}}\n\\frame {\\input {blocks/Theorem-infsup-mixed2.tex}}\n\\frame {\\input {blocks/Problem-inhomogeneous-continuity.tex}}\n\\frame {\\input {blocks/Assumption-mixed-elliptic.tex}}\n\n\\subsection{Galerkin approximation of mixed problems}\n\n\\frame {\\input {blocks/Definition-kerbh.tex}}\n\\frame {\\input {blocks/Definition-mixed-galerkin.tex}}\n\\frame {\\input {blocks/Theorem-galerkin-mixed-u-kerbh.tex}}\n\\frame {\\input {blocks/Corollary-galerkin-mixed-u-kerb.tex}}\n\\frame {\\input {blocks/Theorem-galerkin-mixed-existence-p.tex}}\n\\frame {\\input {blocks/Problem-infsup-uniform.tex}}\n\\frame {\\input {blocks/Lemma-fortin.tex}}\n\\frame {\\input {blocks/Assumption-mixed-elliptic-stabilized.tex}}\n\\frame {\\input {blocks/Theorem-mixed-stabilized-well-posed.tex}}\n\\frame {\\input {blocks/Definition-mixed-residual.tex}}\n\\frame {\\input {blocks/Corollary-mixed-residual-bounded.tex}}\n\\frame {\\input {blocks/Lemma-stabilized-mixed-approximation.tex}}\n\\frame {\\input {blocks/Corollary-stabilized-mixed-convergence.tex}}\n\n\\section{Stokes equations}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\n\\frame {\\input {blocks/Lemma-stokes-a-elliptic.tex}}\n\\frame {\\input {blocks/Lemma-stokes-helmholtz.tex}\n  \\input {blocks/Lemma-stokes-grad.tex}}\n\\frame {\\input {blocks/Corollary-stokes-iso.tex}\n  \\input {blocks/Theorem-stokes-infsup.tex}}\n\\frame {\\input {blocks/Theorem-stokes-convergence.tex}}\n\\frame {\\input {blocks/Corollary-stokes-convergence2.tex}}\n\\frame {\\input {blocks/Problem-checker-board.tex}}\n\n\\begin{frame}\n  \\frametitle{Example: one-dimensional $P_1-P_1$ elements}\n  \\begin{center}\n      \\includegraphics[width=.7\\textwidth]{./fig/p1-p1-1d}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Small patches with Dirichlet boundary}\n  \\begin{center}\n    \\hfill\n    \\includegraphics[width=.3\\textwidth]{./fig/patch1.tikz}\n    \\hfill\n    \\includegraphics[width=.3\\textwidth]{./fig/patch2.tikz}\n    \\hfill\\mbox{}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Checkerboard modes}\n  \n\\end{frame}\n\n\\subsection{MINI element}\n\\frame {\\input {blocks/Definition-barycentric-coordinates.tex}}\n\n\\begin{frame}\n  \\frametitle{The $P_1$ element in barycentric coordinates}\n  \\begin{columns}\n    \\begin{column}{.5\\textwidth}\n      \\begin{center}\n        \\includegraphics[width=.6\\textwidth]{./fig/p1-p.tikz}\n      \\end{center}\n    \\end{column}\n    \\begin{column}{.5\\textwidth}\n      \\begin{gather*}\n        \\phi_i = \\lambda_i,\n        \\quad i=0,1,2\n      \\end{gather*}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{The $P_2$ element in barycentric coordinates}\n  \\begin{columns}\n    \\begin{column}{.5\\textwidth}\n      \\begin{center}\n        \\includegraphics[width=.6\\textwidth]{./fig/p2-p.tikz}\n      \\end{center}\n    \\end{column}\n    \\begin{column}{.5\\textwidth}\n      \\begin{xalignat*}2\n        \\phi_{ii} &= 2\\lambda_i^2 - \\lambda_i,\n        &i&=0,1,2\\\\\n        \\phi_{ij} &= 4\\lambda_i\\lambda_j\n        &j&\\neq i\n      \\end{xalignat*}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{The $P_3$ element in barycentric coordinates}\n  \\begin{columns}\n    \\begin{column}{.5\\textwidth}\n      \\begin{center}\n        \\includegraphics[width=.6\\textwidth]{./fig/p3-p.tikz}\n      \\end{center}\n    \\end{column}\n    \\begin{column}{.5\\textwidth}\n      \\begin{xalignat*}2\n        \\phi_{iii} &= \\tfrac12 \\lambda_i(3\\lambda_i-1)(3\\lambda_i-2)\n        &i&=0,1,2\\\\\n        \\phi_{ij} &= \\tfrac92\\lambda_i\\lambda_j(3\\lambda_j-1)\n        &j&\\neq i\\\\\n        \\phi_0 &= 27\\lambda_0\\lambda_1\\lambda_2\n      \\end{xalignat*}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\\frame {\\input {blocks/Notation-piecewise-polynomial-spaces.tex}}\n\\frame {\\input {blocks/Definition-h1-bubble-space.tex}}\n\\frame {\\input {blocks/Definition-mini-element-p.tex}}\n\\frame {\\input {blocks/Lemma-fortin-construction-1.tex}}\n\\frame {\\input {blocks/Assumption-h1-stable-interpolation.tex}}\n\\frame {\\input {blocks/Definition-locally-quasi-uniform.tex}\n  \\input {blocks/Assumption-locally-quasi-uniform.tex}}\n\\frame {\\input {blocks/Theorem-mini-stability.tex}}\n\\frame {\\input {blocks/Notation-broken-bilinear-form.tex}}\n\\frame {\\input {blocks/Lemma-mini-stabilized.tex}}\n\\frame {\\input {blocks/Problem-quadrilateral-mini.tex}}\n\\frame {\\input {blocks/Problem-mini-3d.tex}}\n\\frame {\\input {blocks/Definition-higher-order-bubble.tex}}\n\\frame {\\input {blocks/Theorem-higher-order-bubble.tex}\n  \\input {blocks/Corollary-pk-bubble.tex}}\n\n\\subsection{P2-P0}\n\n\\frame {\\input {blocks/Definition-p2-p0-element.tex}\n  \\input {blocks/Lemma-p2-p0-stability.tex}}\n\\frame {\\input {blocks/Theorem-p2-p0-convergence.tex}}\n\\frame {\\input {blocks/Problem-q2-q0.tex}}\n\\frame {\\input {blocks/Lemma-bubble-discontinuous.tex}}\n\\frame {\\input {blocks/Corollary-bubble-p2.tex}\n  \\input {blocks/Corollary-pk-pk2.tex}}\n\n\\frame {\\input {blocks/Theorem-discontinuous-pressure-normal-velocity.tex}}\n\\frame {\\input {blocks/Corollary-qk-pk1.tex}}\n\\frame {\\input {blocks/Definition-moment-dofs-qk-2d.tex}}\n\\frame {\\input {blocks/Definition-moment-dofs-qk-3d.tex}}\n\\frame {\\input {blocks/Example-qk-pk1.tex}}\n\n\\subsection{The Hood-Taylor elements}\n\n\\frame {\\input {blocks/Definition-hood-taylor.tex}}\n\\frame {\\input {blocks/Example-hood-taylor-triangle.tex}}\n\\frame {\\input {blocks/Example-hood-taylor-quad.tex}}\n\\frame {\\input {blocks/Definition-macro-equivalence.tex}}\n\\frame {\\input {blocks/Problem-reference-macros.tex}}\n\\frame {\\input {blocks/Definition-macro-spaces.tex}}\n\\frame {\\input {blocks/Definition-verfuerth-norm.tex}}\n\\frame {\\input {blocks/Definition-macro-seminorm.tex}}\n\\frame {\\input {blocks/Lemma-macro1.tex}}\n\\frame {\\input {blocks/Lemma-macro-local.tex}}\n\\frame {\\input {blocks/Problem-macro-local.tex}}\n\\frame {\\input {blocks/Lemma-verfuerth1.tex}}\n\\frame {\\input {blocks/Lemma-verfuerth2.tex}}\n\\frame {\\input {blocks/Theorem-hood-taylor-stability.tex}}\n\n\\frame {\\input {blocks/Lemma-patch-test-triangle.tex}}\n\\frame {\\input {blocks/Lemma-patch-test-quad.tex}}\n\n\\subsection{Almost incompressible elasticity}\n\n\\frame {\\input {blocks/Lemma-reduced integration.tex}}\n\\frame {\\input {blocks/Theorem-mixed-stabilized-well-posed.tex}}\n\\frame {\\input {blocks/Corollary-stabilized-mixed-convergence.tex}}\n\n\\section{Mixed formulation of elliptic problems}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\n\\frame {\\input {blocks/Definition-primal-mixed.tex}}\n\\frame {\\input {blocks/Definition-hdiv.tex}}\n\\frame {\\input {blocks/Definition-dual-mixed.tex}}\n\\frame {\\input {blocks/Theorem-Hdiv-separable.tex}\n  \\input {blocks/Theorem-Hdiv-trace.tex}}\n\\frame {\\input {blocks/Problem-trace-dnu.tex}}\n\\frame {\\input {blocks/Theorem-Hdiv-trace-surjective.tex}\n  \\input {blocks/Theorem-Hdiv-trace-kernel.tex}}\n\\frame {\\input {blocks/Theorem-Hdiv-helmholtz.tex}}\n\\frame {\\input {blocks/Problem-mixed-inhomogeneous-bc.tex}}\n\\frame {\\input {blocks/Lemma-darcy-reduced-wellposed.tex}}\n\\frame {\\input {blocks/Lemma-darcy-infsup.tex}\n  \\input {blocks/Theorem-darcy-well-posed.tex}}\n\\frame {\\small\\input {blocks/Theorem-infsup-mixed2.tex}}\n\n\\subsection{Discretization of dual mixed problems}\n\n\\frame {\\input {blocks/Lemma-normal-continuity.tex}}\n\\frame {\\input {blocks/Definition-rt-simplex.tex}}\n\\frame {\\input {blocks/Example-rt-simplex.tex}}\n\\frame {\\input {blocks/Lemma-rt-simplex-1.tex}}\n\\frame {\\input {blocks/Lemma-rt-simplex-dimension.tex}}\n\\frame {\\input {blocks/Lemma-rt-simplex-unisolvence.tex}}\n\n\\frame {\\input {blocks/Definition-bdm-simplex.tex}}\n\\frame {\\input {blocks/Example-bdm-simplex.tex}}\n\\frame {\\input {blocks/Lemma-bdm-simplex-unisolvence.tex}}\n\\frame {\\input {blocks/Definition-canonical-interpolation.tex}}\n\\frame {\\input {blocks/Lemma-commuting-diagram-hdiv.tex}}\n\n\\subsection{Quarilaterals and hexahedra}\n\n\\frame {\\input {blocks/Notation-recap-reference-transform.tex}}\n\\frame {\\input {blocks/Definition-Piola-transform.tex}}\n\\frame {\\input {blocks/Lemma-Piola-transform-integrals.tex}\n  \\input {blocks/Problem-Piola-transform-integrals.tex}}\n\\frame {\\input {blocks/Notation-tensor-product-polynomials.tex}}\n\\frame {\\input {blocks/Definition-rt-quad.tex}}\n\\frame {\\input {blocks/Example-rt-quad.tex}}\n\\frame {\\input {blocks/Lemma-rt-quad-1.tex}}\n\\frame {\\input {blocks/Definition-bdm-quad.tex}}\n\\frame {\\input {blocks/Example-bdm-quad.tex}}\n\\frame {\\input {blocks/Lemma-bdm-quad.tex}\n  \\input {blocks/Problem-bdm-quad.tex}}\n\\frame {\\input {blocks/Corollary-darcy-convergence-affine.tex}}\n\\frame {\\input {blocks/Definition-abf-quad.tex}}\n\n\\section{Divergence conforming DG}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\n\\subsection{The interior penalty method}\n\\frame {\\input {blocks/Definition-dg-faces.tex}\n  \\input {blocks/Definition-dg-spaces.tex}}\n\\frame {\\input {blocks/Definition-broken-integrals.tex}}\n\\frame {\\input {blocks/Notation-dg-operators.tex}}\n\\frame {\\input {blocks/Definition-ip.tex}}\n\\frame {\\input {blocks/Definition-ip-norm.tex}\n  \\input {blocks/Problem-ip-norm.tex}}\n\\frame {\\input {blocks/Lemma-ip-stability.tex}\n  \\input {blocks/Problem-ip-stability.tex}}\n\\frame {\\input {blocks/Lemma-ip-consistence.tex}}\n%\\frame {\\input {blocks/Theorem-ip-convergence.tex}}\n\n\\subsection{Formulation with lifting operators}\n\n\\frame {\\input {blocks/Definition-dg-lifting.tex}\n  \\input {blocks/Lemma-ip-lifting-bounded.tex}}\n\\frame {\\input {blocks/Definition-ip-lifting.tex}\n  \\input {blocks/Lemma-ip-equivalence.tex}}\n\\frame {\\input {blocks/Definition-ip-residual.tex}}\n\\frame {\\input {blocks/Lemma-ip-lifting-strang.tex}}\n\\frame {\\input {blocks/Lemma-ip-lifting-residual-2.tex}}\n\\frame {\\input {blocks/Lemma-ip-lifting-residual-1.tex}}\n\\frame {\\input {blocks/Theorem-ip-lifting-h1.tex}}\n\\frame {\\input {blocks/Theorem-ip-lifting-l2.tex}}\n\n\\subsection{Divergence conforming IP}\n\n\\frame {\\input {blocks/Definition-hdiv-ip.tex}}\n\\frame {\\input {blocks/Lemma-dg-fortin.tex}}\n\\frame {\\input {blocks/Corollary-hdivdg-infsup.tex}}\n\\frame {\\input {blocks/Theorem-hdivdg-convergence.tex}}\n\n\\subsection{Duality}\n\n\\frame {\\input {blocks/Definition-dual-stokes.tex}\n  \\input {blocks/Assumption-stokes-regularity.tex}}\n\\frame {\\input {blocks/Definition-hdivdg-residual-operators.tex}}\n\\frame {\\input {blocks/Lemma-hdivdg-residual-1.tex}\n  \\input {blocks/Corollary-hdivdg-residual-2.tex}}\n\\frame {\\input {blocks/Theorem-hdivdg-l2.tex}\n  \\input {blocks/Problem-hdivdg-l2.tex}}\n\n\\section{Maxwell}\n\\frame {\\input {blocks/Notation-curl.tex}}\n\\frame {\\input {blocks/Lemma-curl-green.tex}}\n\\frame {\\input {blocks/Definition-Maxwell-boundary.tex}}\n\\frame {\\input {blocks/Definition-curl-traces.tex}}\n\\frame {\\input {blocks/Theorem-curl-traces.tex}}\n\\frame {\\input {blocks/Definition-Maxwell-mixed-0.tex}}\n\n\\section{The de Rham complex}\n\\frame{\\tableofcontents[currentsection,hideothersubsections]}\n\n\\frame {\\input {blocks/Notation-hlambda.tex}}\n\\frame {\\input {blocks/Notation-hlambda-2d.tex}}\n\\frame {\\input {blocks/Notation-hlambda-norm.tex}}\n\\frame {\\input {blocks/Theorem-de-rham.tex}}\n\\frame {\\input {blocks/Lemma-hlambda-0.tex}}\n\n\\frame {\\input {blocks/Theorem-div-curl-well-posed.tex}\n  \\input {blocks/Problem-darcy-derham.tex}}\n\n\\subsection{Polynomial complexes for simplicial meshes}\n\n\\frame {\\input {blocks/Notation-pk-complex.tex}}\n\\frame {\\input {blocks/Definition-Koszul-complex.tex}}\n\\frame {\\input {blocks/Lemma-kd-plus-dk.tex}\n  \\input {blocks/Lemma-d-kappa-injective.tex}}\n\\frame {\\input {blocks/Theorem-polynomial-exact.tex}\n  \\input {blocks/Corollary-pk-complexes.tex}}\n\\frame {\\input {blocks/Definition-pk-plus.tex}}\n\\frame {\\input {blocks/Lemma-pk-plus-d.tex}}\n\\frame {\\input {blocks/Lemma-pr-pr-plus.tex}}\n\\frame {\\input {blocks/Theorem-dimension-pr-lambda.tex}}\n\n\\subsection{Degrees of freedom and bases for simplicial meshes}\n\n\\frame {\\input {blocks/Definition-mesh-pk.tex}\n  \\input {blocks/Definition-spanned-simplex.tex}\n  \\input {blocks/Definition-subsimplices.tex}}\n\\frame {\\input {blocks/Definition-pr-f.tex}}\n\\frame {\\input {blocks/Lemma-subsimplex-polynomials.tex}\n  \\input {blocks/Problem-subsimplex-polynomials.tex}}\n\\frame {\\input {blocks/Example-h1-moment-dofs.tex}}\n\\frame {\\input {blocks/Definition-v-of-f.tex}\n  \\input {blocks/Definition-w-of-f.tex}}\n\\frame {\\input {blocks/Lemma-pr-geometric.tex}}\n\\frame {\\input {blocks/Theorem-decomp-pr-plus.tex}}\n\\frame {\\input {blocks/Example-rt-complex-decomp.tex}}\n\\frame {\\input {blocks/Theorem-decomp-pr.tex}}\n\\frame {\\input {blocks/Example-bdm-complex-decomp.tex}}\n\\frame {\\input {blocks/Lemma-qr-complex.tex}}\n\\frame {\\input {blocks/Definition-pr-complex-1d.tex}}\n\\frame {\\input {blocks/Definition-tensor-dofs.tex}}\n\\frame {\\input {blocks/Lemma-2d-tensor-rt-nedelec.tex}}\n\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "0199f02b325112eaeacee591331613f1b4828db9", "size": 17035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mixed/slides.tex", "max_stars_repo_name": "ahumanita/notes", "max_stars_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mixed/slides.tex", "max_issues_repo_name": "ahumanita/notes", "max_issues_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mixed/slides.tex", "max_forks_repo_name": "ahumanita/notes", "max_forks_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.7086247086, "max_line_length": 75, "alphanum_fraction": 0.7369533314, "num_tokens": 5062, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.4150926059463297}}
{"text": "\\documentclass[Thesis.tex]{subfiles}\n\\begin{document}\n\\chapter{Verification and Benchmarking}\n\\label{chp:verfication}\n\\glsresetall\n\n\nThis chapter is dedicated to presenting some of the tests that we have done to\nverify that the software we have developed is indeed functioning as advertised.\nThese types of tests are more large scale (integration tests) compared to low\nlevel unit tests which is a part of the source code for QFLOW. By checking that\nwe can reproduce known benchmarks and observe behavior that is consistent with\nour expectations we hope to increase the amount of trust assigned to the implementation.\n\n\\section{Setup}\n\nWe focus our tests on the idealized harmonic oscillator system in $D = 3$ dimensions\nwith $N$ non-interacting particles, i.e.\\ the Hamiltonian given by\n\\cref{eq:ho-no-interaction-hamiltonian}:\n\n\\begin{align}\n    \\hat H_0 &= \\sum_{i=1}^N\\qty(-\\frac{1}{2}\\laplacian_i +\n    \\frac{1}{2}r_i^2),\n\\end{align}\nwhere we have $\\hbar = m = \\omega = 1$, and\n$r_i^2 = x_i^2 + y_i^2+z_i^2$. This has the ground state given by\n\\cref{eq:Phi-non-inter}, generalized to $N$ particles in three dimension and\nomitting normalization constants:\n\n\\begin{align}\n        \\Phi(\\mat X) &= \\exp[-\\frac{1}{2}\\sum_{i=1}^N r_i^2],\n\\end{align}\nwhere as before we have defined $\\mat X$ as\n\n\\begin{align}\n  \\mat X &\\defeq \\mqty(\\vx_1\\\\\\vx_2\\\\\\vdots\\\\\\vx_N) \\defeq \\mqty(x_1&y_1&z_1\\\\x_2&y_2&z_2\\\\\\vdots&\\vdots&\\vdots\\\\x_N&y_N&z_N)\n\\end{align}\n\nFor the trail wave function we shall use two different ones. First, the simple\nGaussian form of the ground state itself:\n\n\\begin{align}\n  \\psi_G(\\mat X) = \\exp(-\\alpha\\sum_{i = 1}^N r_i^2),\n\\end{align}\nwith $\\alpha$ the only variational parameter. Learning the ideal parameters\nshould be trivial in this case, and we should expect perfect results.\n\nSecond, we use an ansatz resulting from a Gaussian-binary \\gls{rbm}~\\cite{Flugsrud-2018}, presented in \\cref{eq:rbm-def}:\n\n\n\\begin{align}\n  \\psi_{RBM}(\\vX) &=\n        \\exp[-\\sum_i^{M} \\frac{\\qty(X_i-a_i)^2}{2\\sigma^2}]\n        \\prod_j^H \\qty(1 + \\exp[b_j+\\sum_i^M \\frac{X_iW_{ij}}{\\sigma^2}]),\n\\end{align}\nwhere $M = \\text{\\# of particles}\\times \\text{\\# of dimensions}$ is the number of degrees of freedom and $H$ is\nthe number of hidden nodes (set to 4 through this section). Note also that $X_i$\nin the above refers to the $i$'th degree of freedom, counting through $\\mat X$\nin row major order. The variational parameters are $\\vb a, \\vb b$ and $\\mat W$,\nand we hold $\\sigma^2=1$ constant in this case.\n\nWe use this wave function simply to make learning the true ground state slightly\nmore challenging than proposing a simple Gaussian straight away. Note that\nsetting $\\vb{a}, \\vb b$ and $\\mat W$ all to zero yields the correct ground state in this particular case.\n\n\\section{Energy Estimates and Statistics}\n\nWe start by verifying that we can reproduce the expected values for $\\expval{E_L}$,\n$\\expval{r}$ and $\\expval{r^2}$ for the ideal harmonic oscillator. We still use\n$D=3$ dimensions and set $N=100$ particles.\n\n\\Cref{tab:verify-energy-estimates} shows the energy obtained using $\\psi_G$ with\ntwo different values of $\\alpha_G$. For the optimal choice $\\alpha_G = 0.5$ we\nget the exact analytic ground state energy, $\\flatfrac{\\expval{E_L}}{N} =\n\\flatfrac{D}{2}$. The reported variance is entirely due to the limited\nprecision of $\\SI{64}{bit}$ floating point numbers.\n\nFor the non-optimal $\\alpha_G=0.51$ we get a larger energy, as we would expect.\nFurthermore, we get a reported \\gls{sem} of $\\sim \\SI{2e-5}{\\au}$. This\nincludes a correction from the automated blocking mechanism\nby~\\textcite{Jonsson-2018}. The results were obtained using $2^{23}$ \\gls{mc}\nsamples, so by the standard prescription for \\gls{sem} we should have\ngotten $\\flatfrac{\\SI{8e-4}{\\au}}{\\sqrt{2^{23}}} \\approx \\SI{3e-7}{\\au}$. This\nlarge discrepancy can be explained by the presence of a large amount of\nautocorrelation in the energy estimates. Inherent to \\gls{mci} is\nsome degree of autocorrelation, but the reason for this large amount is because\nof the large number of particles and how sampling is implemented. Each \\gls{mc}\nstep we move only a single particle. For large $N$ this means it takes a\nlot of samples to substantially change the positions of all particles. For smaller\n$N$ the correction from blocking is smaller, albeit still present. This\nexemplifies the importance of a proper calculation of statistical errors. Every\n\\gls{sem} presented in this thesis will include this correction.\n\n\n\\begin{table}[h]\n  \\centering\n  \\caption[Ground state energies of the ideal harmonic oscillator]{\\label{tab:verify-energy-estimates}Estimated ground state energy\n    using $\\psi_G$ with two different values for $\\alpha_G$. The energies,\n    standard deviations and variances are\n    given per particle, and were produced using \\gls{is} and\n    $2^{23}$ samples. Statistical errors are corrected for autocorrelation using\n    blocking. Energies in atomic units $[\\si{\\au}]$.\\citesource{writing/scripts/verify-energy-stats.py}}\n  \\input{scripts/verify-energy-stats.py.table1.tex}\n\\end{table}\n\nMoving from energy to distance metrics, \\cref{tab:verify-radius-estimates} shows\nthe mean radial displacement and its squared sibling for all the particles in the system.\nThe results were obtained using $\\alpha_G=0.5$ and $2^{23}$ \\gls{mc} samples. For\nreference, the table also states the exact analytic results. Unlike the energy,\nwhich for the ideal $\\alpha_G$ is independent of position, these results are not\nperfectly accurate. However, the results are correct to five significant digits,\nand both $\\expval{r}$ and $\\expval{r^2}$ are within a few \\glspl{sem} from\nthe analytic value. We take this as further confirmation of both the integration\nimplementation and the validity of the statistical estimates.\n\n\\begin{table}[h]\n  \\centering\n  \\caption[Radial metrics of the ideal harmonic oscillator]{\\label{tab:verify-radius-estimates}Estimates for the mean radial\n    displacement, $\\expval{r}$, and the mean squared radial displacement,\n    $\\expval{r^2}$. For reference the exact analytic results are listed as well\n    ($\\expval{r}=\\flatfrac{2}{\\sqrt{\\pi\\omega}}$ and\n    $\\expval{r^2}=\\flatfrac{D}{2}$), which can be easily verified by computing\n    the corresponding integrals directly. Lengths in dimensionless units of $a_{ho}$.\\citesource{writing/scripts/verify-energy-stats.py}}\n  \\input{scripts/verify-energy-stats.py.table2.tex}\n\\end{table}\n\n\\section{One-body Density}\n\nBecause the wave functions we typically encounter tend to be multidimensional,\nvisualizing them can be quite challenging. One way of reducing the\ndimensionality is to integrate out the positions for all but one particle. The\nresult is a \\gls{pdf} called the one-body density:\n\n\\begin{align}\n  \\label{eq:one-body-density-def}\n  \\rho(\\vx_1) = \\idotsint \\dd{\\vx_2}\\dd{\\vx_2}\\dots\\dd{\\vx_N} \\abs{\\Psi(\\vX)}^2,\n\\end{align}\nwhere we have arbitrarily chosen to keep particle index $1$. This gives the\n\\gls{pdf} for where one might expect to find particle $1$,\naveraged over all possible configurations of the other particles.\n\nAs a validating example, we consider the simple Gaussian wave function $\\psi_G$.\nWe get:\n\n\\begin{align}\n  \\rho(\\vx_1) &= \\idotsint \\dd{\\vx_2}\\dd{\\vx_2}\\dots\\dd{\\vx_N} \\abs{\\psi_G(\\vX)}^2\\\\\n  &= e^{-2\\alpha r_1^2}\\idotsint \\dd{\\vx_2}\\dd{\\vx_2}\\dots\\dd{\\vx_N} \\,e^{-2\\alpha\\sum_{i=2}^N r_i^2}\\\\\n    &= C e^{-2\\alpha r_1^2},\\label{eq:ver-annon-1}\n\\end{align}\nwhere $C$ is a normalization constant. Perhaps unsurprisingly, the particle will\ntend to be located close to the center of the potential well, with exponentially\ndecreasing probability for increasing radii.\n\nWe can perform the integral in \\cref{eq:one-body-density-def} for any wave\nfunction using \\gls{mci}. We simply make a histogram of the\nparticles position as we sample a large amount of configuration.\\footnote{A\ntechnical caveat is that when we discretize the radius $r_1$ into bins for the\nhistogram we must account for the different volumes (or areas or lengths in two\nand one dimensions) of the bins. Greater $r$ will correspond to greater volumes,\nand because of this they will receive a correspondingly greater proportion of\nthe samples. Dividing the bin counts by their respective volumes fixes this.}\n\\Cref{fig:verify-onebody} shows the resulting plot of $\\rho(r_1)$ in a harmonic\noscillator with $N=100$ three-dimensional particles, using $2^{23}$\nsamples. After normalizing both the result and \\cref{eq:ver-annon-1} the two\ncurves are indistinguishable, showing that our implementation is indeed correct.\n\n\\begin{figure}[h]\n  \\centering\n  \\resizebox{0.7\\linewidth}{!}{%\n    \\input{scripts/verify-onebody-density.py.tex}\n  }\n  \\caption[One-body density of the ideal harmonic oscillator]{\\label{fig:verify-onebody}One-body density of a particle in a\n    harmonic oscillator potential, as described by $\\psi_G$ with $\\alpha=0.5$.\n    The curve is indistinguishable from the analytic result. The small\n    discrepancy around $r_1=0$ is an artifact of the vanishing volume of the\n    inner most bins, and the discrepancy becomes increasingly negligible with\n    more samples. This result used $2^{23}$ \\gls{mc} samples.\\citesource{writing/scripts/verify-onebody-density.py}}\n\\end{figure}\n\n\\section{Two-body Density}\n\nSimilarly to the one-body density, we can integrate out all degrees of freedom\nexcept for two particles. This will give us a two-dimensional \\gls{pdf} showing\nhow the two particles are likely to be located relative to each other.\n\nMathematically we define it in a similar way,\n\n\\begin{align}\n  \\label{eq:two-body-density-def}\n  \\rho(\\vx_1, \\vx_2) = \\idotsint \\dd{\\vx_3}\\dd{\\vx_4}\\dots\\dd{\\vx_N} \\abs{\\Psi(\\vX)}^2,\n\\end{align}\nwhich for $N$ non-interacting particles governed by $\\psi_G$ can be solved\nanalytically:\n\n\\begin{align}\n  \\label{eq:two-body-analytic}\n  \\rho(\\vx_1, \\vx_2) = Ce^{-2\\alpha\\qty(r_1^2 + r_2^2)}.\n\\end{align}\n\nAgain we can perform the integral numerically using \\gls{mci}.\n\\Cref{fig:verify-twobody} shows a contour plot of the density along with the\nexact contour lines from \\cref{eq:two-body-analytic} indicated by the dashed\nlines. Visually distinguishing the two is a little harder now, as we have turned\nto colors to visualize the three-dimensional plot. Still, the two sets of\ncontour lines are very much in agreement, indicating that the implementation is\ncorrect.\n\n\\begin{figure}[h]\n  \\centering\n  \\resizebox{0.7\\linewidth}{!}{%\n    \\input{scripts/verify-twobody-density.py.tex}\n  }\n  \\caption[Two-body density of the ideal harmonic oscillator]{\\label{fig:verify-twobody}Contour plot of the two-body density of\n$N=10$ particles in a harmonic oscillator potential, as described by $\\psi_G$\nwith $\\alpha=0.5$. The dotted lines are the contours given by\n\\cref{eq:two-body-analytic}. Again the numerical result follows closely that of\nthe exact result. This result used $2^{25}$ \\gls{mc} samples.\\citesource{writing/scripts/verify-twobody-density.py}}\n\\end{figure}\n\n\n\\section{Optimization}\n\n\\subsection{Integration Test}\nThe simplest complete test is to initialize $\\psi_G$ with a non-optimal\nparameter, e.g.\\ $\\alpha=0.3$, and attempt to learn the optimal value.\nOptimizing this is trivially accomplished, and\n\\cref{fig:verify-gaussian-simplest} shows a training progression using $N=10$\nparticles. The hyperparameters have here been artificially tuned to avoid\nimmediate convergence to $\\alpha =0.5$ so as to better illustrate\nthe process.\n\nIf we allow the training to progress a little further (or use more optimal\nhyperparameters), it eventually finds\n$\\alpha = 0.5$ to within machine precision and we get\n$\\flatfrac{\\expval{E_L}}{N} = \\flatfrac{D}{2}$ with exactly zero variance. While\nthis test is not the most challenging, it is nevertheless a useful check.\n\n\\begin{figure}[h]\n  \\centering\n    \\resizebox{\\linewidth}{!}{%\n      \\input{scripts/verify-simple-gaussian.py.tex}\n    }\n  \\caption[Learning progression using \\gls{vmc} on the ideal harmonic\n  oscillator]{\\label{fig:verify-gaussian-simplest}Example progression of\n    optimizing the variational parameter $\\alpha$, using $\\psi_G$ as the trial wave function.\n    Hyperparameters have been tuned so that we can see what happens, as opposed\n    to immediate convergence to the perfect result.\\citesource{writing/scripts/verify-simple-gaussian.py}}\n\\end{figure}\n\n\\subsection{Learning Rate Dependency}\n\\label{sec:verify-learning-rate-dep}\n\nSuccessful training is highly dependent on using the correct hyperparameters.\nAmong the most important are the ones controlling the optimization scheme, such\nas the learning rate in \\gls{sgd}. The following plots aim at illustrating this\ndependency, while also serving as a check that the implemented optimization\nschemes work as expected.\n\nImportantly, these results are not meant to infer that some schemes or learning\nrates are superior to others. Which scheme works best for a given learning\nproblem will depend on a number of factors, such as the magnitude of the\ngradients, number of parameters, variance in gradient estimates etc.\n\n\n\\subsubsection{Simple Problem - $\\psi_G$}\n\n\\Cref{fig:verify-lr-gaussian} shows the absolute error of $\\psi_G$ during\ntraining with several different schemes. For standard SGD we see that a learning\nrate around $\\eta = 0.1$ (with $\\eta$ defined as in \\cref{eq:gradient-decent-definition}) performs best among these results, and SGD with $\\eta\n=0.01$ is the slowest to converge. Naturally, values of $0.01<\\eta<0.1$\nperform somewhere between the two.\n\nFrom these results alone it might seem like\nlarger learning rates always perform better. To an extent this is true, as it\nallows for more rapid learning. However, setting $\\eta$ too high can lead to\ndivergence and unpredictable behavior. In less extreme cases, it can also keep\nus from converging properly onto the correct parameters by oscillating around\nthe ideal values.\n\nWe have also included some runs using ADAM. Here we have more parameters to play\nwith, but only a few are shown here. In this trivial learning example it is hard\nto beat properly tuned SGD, but we see how ADAM is able to follow closely. In\nthis particular case, we saw large improvements by reducing $\\beta_1$, which\neffectively reduces the momentum applied. An important fact is also that ADAM is\ndesigned to be used with many parameters, with individual learning rates per\nparameter. This enhancement does not show itself in this single-parameter example.\n\n\n\\begin{figure}[h]\n  \\centering\n    \\resizebox{\\linewidth}{!}{%\n      \\input{scripts/verify-learning-rate-gaussian.py.tex}\n    }\n  \\caption[Comparison of optimization schemes on a simple problem]{\\label{fig:verify-lr-gaussian}Example training progression using\n    $\\psi_G$ as trial wave function with different optimization schemes. With\n    sufficient time, all algorithms tend towards zero error.\\citesource{writing/scripts/verify-learning-rate-gaussian.py}}\n\\end{figure}\n\n\\subsubsection{More Complex Problem - $\\psi_{RBM}$}\n\nWe run the same test as above, now with $\\psi_{RBM}$ as the trial wave function\ninstead. We do this to illustrate a common pitfall of gradient-based\noptimization -- local minima. \\cref{fig:verify-lr-rbm} shows three runs\nplateauing around an error $\\sim 10^{-6}\\si{\\au}$. Interestingly, the worst\nresult is obtained with the middle most value of $\\eta$. This shows the random\nnature of SGD, in that it is quite unpredictable when and where we might get\nstuck due to a local minimum. Repeating the same experiment with different random\nseeds does not consistently reproduce this particular result.\n\nSimilarly, we see that one of the ADAM runs did in fact stumble on to a\ndifferent, better local minimum. While this is also subject to randomness, we\nfind that ADAM tends to be at least as good as SGD whenever we have more than\none parameter to learn. This is to be expected, as ADAM can account for\ndifferent scales and variability in the components of the parameter gradient.\n\n\\begin{figure}[h]\n  \\centering\n    \\resizebox{\\linewidth}{!}{%\n      \\input{scripts/verify-learning-rate-rbm.py.tex}\n    }\n  \\caption[Comparison of optimization schemes on a complicated problem]{\\label{fig:verify-lr-rbm}Example training progression using\n    $\\psi_{RBM}$ as trial wave function with different optimization schemes. We\n    see evidence of learning getting stuck in local minima due to the overly\n    complex wave function anstaz.\\citesource{writing/scripts/verify-learning-rate-rbm.py}}\n\\end{figure}\n\n\n\\section{Sampling}\n\\label{sec:verify-sampling}\n\nWe will now investigate the behavior of the implemented sampling strategies.\n\n\\subsection{Step Dependency}\n\nSimilarly to the learning rate in optimization schemes, the \\gls{mc} samplers\nare highly dependent on an appropriate step parameter (see\n\\cref{alg:metropolis-simple,alg:metropolis-importance}).\\footnote{We\n  intentionally stick to calling these \\say{step} parameters, without\n  specifically mentioning which of the two ($\\Delta x$ or $\\Delta t$) we mean. When\nnecessary we will make it clear which type of step parameter is meant.} We want to use a\nstep size that balances two opposing attributes:\n\n\\begin{itemize}\n\\item Particles should be sufficiently mobile.\n  \\begin{itemize}\n  \\item Unchanging configurations lead to biased energy estimates with high\n    autocorrelation.\n  \\end{itemize}\n\\item New configurations should be accepted as much as possible.\n  \\begin{itemize}\n  \\item Rejections imply wasted computation time as well as increased autocorrelation.\n  \\end{itemize}\n\\end{itemize}\n\n\n\\Cref{fig:verify-sampling-step} shows how the \\gls{ar} changes with\ndifferent step sizes. For both Metropolis and \\gls{is}, the \\gls{ar} tends\nto $\\SI{100}{\\percent}$ for low step sizes, and to $\\SI{0}{\\percent}$ for large\nvalues. Both algorithms show a similar pattern in the middle region, with\na steeper decline for \\gls{is}. A good trade-off between the above\nconsiderations is achieved when the \\gls{ar} is somewhere in the range\n\\SIrange{50}{99}{\\percent}, with the exact best value dependent on the\nparticular problem at hand.\n\n\\begin{figure}[h]\n  \\centering\n    \\resizebox{\\linewidth}{!}{%\n      \\input{scripts/verify-sampling-step.py.tex}\n    }\n    \\caption[Comparison of sampling strategies]{\\label{fig:verify-sampling-step}\\emph{Solid lines:} Acceptance rate of\n    Metropolis and \\gls{is} as a function of step size. Note that the\n  interpretation of the step size is different for the two algorithms. \\emph{Dashed\n  lines:} \\gls{sem} of energy estimates obtained using the corresponding\n  sampling algorithm and step size, using $\\psi_G$ with $\\alpha=0.51$.\\citesource{writing/scripts/verify-sampling-step.py}}\n\\end{figure}\n\n\nThe dotted lines show the \\gls{sem} obtained using the\ncorresponding sampler and step size, when calculating the local energy with\n$\\psi_G$ and $\\alpha=0.51$.\\footnote{The value $\\alpha=0.51$ was used to avoid\n  the zero variance of the ideal value $\\alpha=0.5$, but still behaving\n  similarly to the real system.} The errors were calculated using $2^{21}$ \\gls{mc}\nsamples and corrected for autocorrelation using blocking~\\cite{Jonsson-2018}.\n\nWe see Metropolis tending to very small errors in the range shown, with a large\nspike around $\\delta \\approx 0.01$. We believe step sizes around this critical\npoint allows enough movement for the system to randomly get into unlikely\nstates, but still so small that getting out of these states takes a long time,\nleading to a significant portion of samples from unimportant states. The low\nerror for both high and low step sizes can be explained by both extremes\nresulting in similar behavior; no effective change. When the system remains\nunchanged, either from rejected samples or effectively equivalent ones (for high\nand low step sizes, respectively), the resulting local energies must necessarily\nbe very similar as well. Neither case is desirable considering accurate\nintegration results. Recall that the \\gls{sem} is a statistical measure of\nthe \\emph{precision} of the local energy estimate, and not a measure of its\n\\emph{accuracy}.\\footnote{The number $3.14159$ is more precise than the number\n$6$, but if the true value is $6.28$, then the latter is more accurate.}\\\\\n\n\\Gls{is} shows different behavior with respect to the \\gls{sem}.\nFor the entire range of good step size choices, \\gls{is} results in\nsmaller statistical errors. This is to be expected, and \\gls{is} will\ntherefore be preferred whenever it is available to us.\n\nStill, we would like to explain the behavior for non-optimal step sizes. The\nerror shows a spike as the step size decreases, in a similar way as seen for\nMetropolis. Although not shown fully, the error also explodes once the\nacceptance rate goes below a few percent. We believe this behavior is a result\nof how the update rule for \\gls{is} is dependent on both the step\nsize and its square root.\n\nFor small step sizes, the square root term will dominate, and the algorithm\neffectively decays into standard Metropolis. The location of the spike is\nshifted towards smaller step sizes (approximately the square of the Metropolis\nspike location), and the spike is wider because the square root function grows\nslower than linearly.\n\nFinally, the unstable behavior for large step sizes can be explained the other\nway. The little remaining movement is dominated by the drift force, and the\nsystem will quickly get stuck in a local maximum of the wave function, and then be\nunable to get out again. These are maxima with large probability amplitudes,\nresulting in large values for the local energy and correspondingly large errors.\n\n\\end{document}\n", "meta": {"hexsha": "6e62da8eb3b21c20dfc7c12914056278125aef89", "size": 21554, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writing/Verification.tex", "max_stars_repo_name": "johanere/qflow", "max_stars_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-07-24T21:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-11T18:18:24.000Z", "max_issues_repo_path": "writing/Verification.tex", "max_issues_repo_name": "johanere/qflow", "max_issues_repo_head_hexsha": "5453cd5c3230ad7f082adf9ec1aea63ab0a4312a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2019-02-19T10:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-18T09:42:13.000Z", "max_forks_repo_path": "writing/Verification.tex", "max_forks_repo_name": "bsamseth/FYS4411", "max_forks_repo_head_hexsha": "72b879e7978364498c48fc855b5df676c205f211", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-11-04T15:17:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-03T16:37:38.000Z", "avg_line_length": 50.7152941176, "max_line_length": 143, "alphanum_fraction": 0.764034518, "num_tokens": 5614, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863698, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.41502598342688785}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{geometry}\n\\geometry{\na4paper,\ntotal={170mm,257mm},\nleft=20mm,\ntop=20mm,\n}\n\n\\title{Thermodynamics}\n\\author{Neo Wang}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Formulas}\n\n\\begin{itemize}\n    \\item Boyle's Law: $P_1V_1=P_2V_2$\n    \\item $k=1.38\\times 10^{-23}J/K$\n    \\item Ideal Gas Law 1: $PV=nRT$\n    \\item Ideal Gas Law 2: $PV=NkT$ where $P$ is the absolute pressure of a gas, $V$ is the volume it occupies, $N$ is the number of atoms and molecules in the gas, and $T$ is its absolute temperature. $k$ is the \\textit{Boltzmann constant}.\n    \\item Mechanical equivalent of heat: motion and heat are interchangable.\n    \\item Charles' Law: $$\\frac{V_1}{T_1}=\\frac{V_2}{T_2}$$\n    \\item First law of thermodynamics: $$\\Delta U = Q - W$$\n    \\item $\\propto$ means proportional to\n    \\item $T\\propto KE$\n    \\item $$R=8.314\\frac{J}{molK}$$\n    \\item $$P\\Delta V=\\textrm{Work}$$\n    \\item $$U = \\frac{3}{2}nRT=\\frac{3}{2}NK_BT$$\n    \\item $$e_{carnot} = 1 - \\frac{T_C}{T_H}$$\n\\end{itemize}\n\n\\section{Solving}\n\\begin{itemize}\n    \\item Work done by an ideal gas (PV diagrams)\n    \\begin{itemize}\n        \\item $$W_{BY}=\\int_{V_i}^{V_F}PdV$$\n        \\item Isochoric ($\\Delta V = 0$)\n        \\item $W_{BY}=0J$. There is no area under the curve.\n        \\item Isobaric ($\\Delta P = 0$)\n        \\item If P is constant then $$W_{BY}=P\\Delta V=P(V_F-V_i)$$\n        \\item Isothermal ($\\Delta T = 0$)\n        \\item Issue is temperature doesn't show up in the integral!\n        \\item Remember that if we have an ideal gas then $$W_{BY}=\\int_{V_i}^{V_F}PdV=\\int_{V_i}^{V_F}\\frac{nRT}{V}dV=nRT\\ln(\\frac{V_F}{V_i})$$\n        \\item Adiabatic = (Q = 0)\n        \\item $$\\Delta E_{int}=Q_{ON}-W_{BY}=W_{BY}=-\\Delta E_{INT}=-nC_V\\Delta T$$\n        \\item Note that this is steeper than the isotherm.\n    \\end{itemize}\n    \\item Carnot Cycle and Heat Engines\n    \\begin{itemize}\n        \\item $$e_{carnot} = 1 - \\frac{T_C}{T_H}$$\n        \\item $$T_C=573K, T_H=773K$$\n        \\item If we plug this into the formula, we get $1-\\frac{573}{773} = 26\\%$\n        \\item A carnot engine is at temperatures 400K and 700K.\n        \\item If 14000J of heat is absorbed by the engine, how much heat is discarded into the cold reservoir. $Q_H=14000J$\n        \\item To solve this we use $$\\frac{T_H}{T_C}=\\frac{|Q_H|}{|Q_C|}$$\n        \\item Where T is temperature and Q is heat. H is our hot, and C is our cold.\n        \\item \n    \\end{itemize}\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "0ebb4958c88297c90a49646dc5299d949c767fb6", "size": 2534, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/physics/thermodynamics/main.tex", "max_stars_repo_name": "WHS-Resources/WHS-Resources", "max_stars_repo_head_hexsha": "255306f11e159ee39d58f479b64935ecac792991", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/physics/thermodynamics/main.tex", "max_issues_repo_name": "WHS-Resources/WHS-Resources", "max_issues_repo_head_hexsha": "255306f11e159ee39d58f479b64935ecac792991", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-01-14T05:47:20.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-16T21:02:54.000Z", "max_forks_repo_path": "notes/physics/thermodynamics/main.tex", "max_forks_repo_name": "WHS-Resources/WHS-Resources", "max_forks_repo_head_hexsha": "255306f11e159ee39d58f479b64935ecac792991", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-13T20:58:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-13T20:58:04.000Z", "avg_line_length": 37.2647058824, "max_line_length": 241, "alphanum_fraction": 0.6266771902, "num_tokens": 912, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.41500277383360856}}
{"text": "% Full title as you would like it to appear on the page\n\\chapter{Long paper 1 chapter title}\n% Short title that appears in the header of pages within the chapter\n\\chaptermark{Short chapter title}\n\n\\section{Abstract}\nConcise introduction, motivation, results, and conclusions.\n\n\\section{Introduction}\nExamples of citations: we knew X from \\cite{Croote201616022} and Y from \\cite{Croote20181306}.\n\n\\section{Results}\n\\subsection{Result 1}\nHere is a reference to Figure \\ref{fig:paper1_fig1}.\nWe found bacteria, roughly 5 \\si{\\mu}m in length, that live at 95\\degree C for roughly 90\\% of the year. More symbols: \\$, \\#, 10\\textsuperscript{5}, $\\alpha$, $\\beta$, $\\gamma$, $\\kappa$, \\textbf{bold}, \\textit{italics}.\nQuotation marks are \"correctly oriented\" thanks to the csquotes package.\nNow an inline equation: $E = mc^2$. Now a reference to Equation \\ref{eqn:paper1_eqn1}:\n\\begin{equation}\\label{eqn:paper1_eqn1}\nd_t = \\frac{c - pn_t}{n_t}\n\\end{equation}\n\n\\begin{figure}[hbt!]\n\\centering\n\\includegraphics[width=14cm, keepaspectratio]{figs/paper1/fig1.png}\n\\caption[Short figure caption for List of Figures]{Long figure caption text that explains everything.}\n\\label{fig:paper1_fig1}\n\\end{figure}\n\nThere will be more text here.\n\nMore text here.\n\nMore text here.\n\nMore text here.\n\nMore text here.\n\nMore text here.\n\n\\subsection{Result 2}\nWe discovered something else. Here is a reference to Table \\ref{tab:paper1_tab1}.\n\n\\renewcommand{\\arraystretch}{2}  % make spacing nicer\n\\begin{table}[hbt!]\n\\centering\n\\begin{tabularx}{\\textwidth}{c|c|c|c}  % 4 columns center-justified\n   \\textbf{Col 1} & \\textbf{Col 2} & \\textbf{Col 3} & \\textbf{Col 4} \\\\\n   \\hline  % horizontal line\n   Text in Row 1a & Text in Row 1b & Text in Row 1c & Lots of text in Row 1d \\\\\n                  & Row 1.5b & Row 1.5c & Row 1.5d \\\\\n   \\hline\n   Row 2a & Row 2b & Row 2c & Row 2d \\\\\n   \\hline\n   Row 3a & Row 3b & Row 3c & Row 3d \\\\\n\\end{tabularx}\n\\caption[Short table caption for List of Tables]{Long table caption explaining everything.}\n\\label{tab:paper1_tab1}\n\\end{table}\n\nMore text here.\n\nMore text here.\n\nMore text here.\n\nMore text here.\n\n\\begin{sloppypar}\nFixAwkwardSpacingWithSloppypar FixAwkwardSpacingWithSloppypar FixAwkwardSpacingWithSloppypar FixAwkwardSpacingWithSloppypar FixAwkwardSpacingWithSloppypar.\n\\end{sloppypar}\n\nMore text here.\n\nMore text here.\n\n\\section{Conclusions}\nThe end of the paper.\n", "meta": {"hexsha": "0c9be64b4e1069c26abb8b410b8c8e21bc0a276d", "size": 2385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch_paper1.tex", "max_stars_repo_name": "dcroote/stanford-thesis-example", "max_stars_repo_head_hexsha": "2f89058fbc73e9887c659ed1197b73fce7d9333a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2019-06-17T17:23:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T16:43:45.000Z", "max_issues_repo_path": "ch_paper1.tex", "max_issues_repo_name": "dcroote/stanford-thesis-example", "max_issues_repo_head_hexsha": "2f89058fbc73e9887c659ed1197b73fce7d9333a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch_paper1.tex", "max_forks_repo_name": "dcroote/stanford-thesis-example", "max_forks_repo_head_hexsha": "2f89058fbc73e9887c659ed1197b73fce7d9333a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2019-06-19T20:31:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T20:44:15.000Z", "avg_line_length": 30.1898734177, "max_line_length": 221, "alphanum_fraction": 0.7350104822, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.41500275640941686}}
{"text": "% This is part of the TFTB Tutorial.\n% Copyright (C) 1996 CNRS (France) and Rice University (US).\n% See the file tutorial.tex for copying conditions.\n\n  This chapter presents some useful definitions that constitute the\nbackground of time-frequency analysis (most of the information presented in\nthis tutorial are extracted from \\cite{FLA93}). After a brief recall on\ntime-domain and frequency-domain representations, we introduce the concepts\nof time and frequency localizations, time-bandwidth product and the\nconstraint associated to this product (the Heisenberg-Gabor\ninequality). Then, the instantaneous frequency and the group delay are\npresented as a first solution to the problem of time localization of the\nspectrum. We carry on by defining non-stationarity from its opposite,\nstationarity, and show how to synthesize such non-stationary signals with\nthe toolbox. Finally, we show that in the case of multi-component signals,\nthese mono-dimensional functions (instantaneous frequency and group delay)\nare not sufficient to represent these signals ; a two-dimensional\ndescription (function of time {\\em and} frequency) is necessary.\n\n\n\\section{Time representation and frequency representation}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  The time representation is usually the first (and the most natural)\ndescription of a signal we consider, since almost all physical signals are\nobtained by receivers recording variations with time.\n\n  The frequency representation, obtained by the {\\it Fourier transform}\n\\index{Fourier transform}\n\\[X(\\nu) = \\int_{-\\infty}^{+\\infty} x(t)\\ e^{-j2\\pi \\nu t}\\ dt,\\]\nis also a very powerful way to describe a signal, mainly because the\nrelevance of the concept of frequency is shared by many domains (physics,\nastronomy, economics, biology \\ldots) in which periodic events occur.\n\n  But if we look more carefully at the spectrum $X(\\nu)$, it can be viewed\nas the coefficient function obtained by expanding the signal $x(t)$ into\nthe family of infinite waves, $\\exp\\{j2\\pi \\nu t\\}$, which are completely\nunlocalized in time. Thus, the spectrum essentially tells us which\nfrequencies are contained in the signal, as well as their corresponding\namplitudes and phases, but does not tell us at which times these\nfrequencies occur.\n\n\n\\section{Localization and the Heisenberg-Gabor\\\\ principle}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\markright{Localization and the Heisenberg-Gabor principle}\n  A simple way to characterize a signal simultaneously in time and in\nfrequency is to consider its mean localizations and dispersions in each of\nthese representations. This can be obtained by considering $|x(t)|^2$ and\n$|X(\\nu)|^2$ as probability distributions, and looking at their mean values\nand standard deviations : \\index{average time}\\index{average\nfrequency}\\index{time spreading}\\index{frequency spreading}\n%\\begin{xalignat}{2}\n$$\n\\begin{array}{rcll}\nt_m   &=& \\frac{1}{E_x}\\ \\int_{-\\infty}^{+\\infty} t\\ |x(t)|^2\\ dt  & \n\\mbox{\\it average time}\\\\\t  \n\\nu_m &=& \\frac{1}{E_x}\\ \\int_{-\\infty}^{+\\infty} \\nu\\ |X(\\nu)|^2\\ d\\nu  & \n\\mbox{\\it average frequency}\\\\ \nT^2   &=& \\frac{\n4\\pi}{E_x}\\ \\int_{-\\infty}^{+\\infty} (t-t_m)^2\\ |x(t)|^2\\ dt\n&  \\mbox{\\it time spreading}\\\\ \nB^2   &=& \\frac{4\\pi}{E_x}\\ \\int_{-\\infty}^{+\\infty} (\\nu-\\nu_m)^2\\\n|X(\\nu)|^2\\ d\\nu &  \\mbox{\\it frequency spreading}\n\\end{array}\n$$\n%\\end{eqnarray*}\n%\\end{xalignat}\n\nwhere $E_x$ is the \\index{energy} {\\it energy} of the signal, assumed to be\nfinite (bounded) :\n\\[E_x = \\int_{-\\infty}^{+\\infty} |x(t)|^2\\ dt < + \\infty.\\]\nThen a signal can be characterized in the time-frequency plane by its mean\nposition $(t_m, \\nu_m)$ and a domain of main energy localization whose area\nis proportional to the {\\it time-bandwidth product} $T\\times B$.\\\\\n\\index{time-bandwidth product}\n\n\\subsection{Example 1} \n%'''''''''''''''''''''\n\\label{ex1}\nThese time and frequency localizations can be evaluated thanks to the\nM-files \\index{\\ttfamily loctime}{\\ttfamily loctime.m} and \\index{\\ttfamily\nlocfreq}{\\ttfamily locfreq.m} of the Toolbox. The first one gives the\naverage time center ($t_m$) and the duration ($T$) of a signal, and the\nsecond one the average normalized frequency ($\\nu_m$) and the normalized\nbandwidth ($B$). For example, for a linear chirp with a gaussian amplitude\nmodulation, we obtain (see fig. \\ref{Ns2fig1})\\,:\n\\begin{verbatim}\n     >> sig=fmlin(256).*amgauss(256);\n     >> [tm,T]=loctime(sig)           --->  tm=128     T=32\n     >> [num,B]=locfreq(sig)          --->  num=0.249  B=0.0701\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ns2fig1.eps}}\n\\caption{\\label{Ns2fig1}Linear chirp with a gaussian amplitude modulation}\n\\end{figure}\n\n  One interesting property of this product $T\\times B$ is that it is lower\nbounded :\n\\[T \\times B \\geq 1.\\]\n\\index{Heisenberg-Gabor inequality} This constraint, known as the {\\it\nHeisenberg-Gabor inequality}, illustrates the fact that a signal can not\nhave simultaneously an arbitrarily small support in time and in\nfrequency. This property is a consequence of the definition of the Fourier\ntransform. The lower bound $T\\times B = 1$ is reached for gaussian\nfunctions :\n\\[x(t) = C \\exp{[-\\alpha(t - t_m)^2 + j2\\pi \\nu_m(t-t_m)]}\\]\n%with $C \\in \\mathbb{R}$, $\\alpha \\in \\mathbb{R}_{+}$. Therefore, the\nwith $C \\in \\Rset$, $\\alpha \\in \\Rset_{+}$. Therefore, the\ngaussian signals are those which minimize the time-bandwidth product\naccording to the Heisenberg-Gabor inequality.\\\\\n\n\\subsection{Example 2}\n%'''''''''''''''''''''\n\n To check the Heisenberg-Gabor inequality numerically, we consider a\ngaussian signal and calculate its time-bandwidth product (see\nfig. \\ref{Ns2fig2})\\,: \n\\begin{verbatim}\n     >> sig=amgauss(256);\n     >> [tm,T]=loctime(sig); \n     >> [fm,B]=locfreq(sig);\n     >> [T,B,T*B]             --->  T=32  B=0.0312  T*B=1\t       \n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ns2fig2.eps}}\n\\caption{\\label{Ns2fig2}gaussian signal : lower bound of the\nHeisenberg-Gabor inequality}\n\\end{figure}\nHence, the time-bandwidth product obtained, when using the file\n\\index{\\ttfamily amgauss}{\\ttfamily amgauss.m}, is minimum.\n\n\\section{Instantaneous frequency}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\label{anasig}\n\\index{instantaneous frequency}\n\\index{analytic signal}\n\\index{Hilbert transform}\n  Another way to describe a signal simultaneously in time and in frequency\nis to consider its {\\it instantaneous frequency}. In order to introduce such a\nfunction, we must define first the concept of {\\it analytic signal}.\n\n  For any real valued signal $x(t)$, we associate a complex valued signal\n$x_a(t)$ defined as\n\\[x_a(t) = x(t) + j HT(x(t))\\]\nwhere $HT(x)$ is the {\\it Hilbert transform} of $x$ ($x_a$ can be obtained\nusing the M-file {\\ttfamily hilbert.m} of the Signal Processing\nToolbox). $x_a(t)$ is called the analytic signal associated to $x(t)$. This\ndefinition has a simple interpretation in the frequency domain since $X_a$\nis a single-sided Fourier transform where the negative frequency values\nhave been removed, the strictly positive ones have been doubled, and the DC\ncomponent is kept unchanged :\n\\begin{eqnarray*}\n\tX_a(\\nu) = 0 \\ \\ \\ \\ \\ \\ &\\mbox{if}& \\nu < 0 \\\\\n\tX_a(\\nu) = X(0)\\ \\ &\\mbox{if}& \\nu = 0 \\\\\n\tX_a(\\nu) = 2X(\\nu) &\\mbox{if}& \\nu > 0 \n\\end{eqnarray*}\n($X$ is the Fourier transform of $x$, and $X_a$ the Fourier transform of\n$x_a$). Thus, the analytic signal can be obtained from the real signal by\nforcing to zero its spectrum for the negative frequencies, which do not\nalter the information content since for a real signal, $X(-\\nu)=X^*(\\nu)$.\n\n\\index{instantaneous amplitude}\n From this signal, it is then possible to define in a unique way the\nconcepts of {\\it instantaneous amplitude} and {\\it instantaneous frequency} by :\n\\begin{eqnarray*}\na(t) &=& |x_a(t)| \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\mbox{\\it  instantaneous amplitude} \\\\\nf(t) &=& \\frac{1}{2\\pi} \\frac{d\\arg{x_a(t)}}{dt}\\ \\mbox{\\it  instantaneous\nfrequency}  \n\\end{eqnarray*}\nAn estimation of the instantaneous frequency is given by the M-file\n\\index{\\ttfamily instfreq}{\\ttfamily instfreq.m} of the Time-Frequency\ntoolbox :\\\\\n\n   {\\bf Example} (see fig. \\ref{Ns3fig1})\n\n\\begin{verbatim}\n     >> sig=fmlin(256); t=(3:256);\n     >> ifr=instfreq(sig); plotifl(t,ifr);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns3fig1.eps}}\n\\caption{\\label{Ns3fig1}Estimation of the instantaneous frequency of a\nlinear chirp}\n\\end{figure}\nAs we can see from this plot, the instantaneous frequency shows with\nsuccess the evolution with time of the frequency content of this signal.\n\n\n\\section{Group delay}\n%~~~~~~~~~~~~~~~~~~~~\n\\index{group delay}\n  The instantaneous frequency characterizes a local frequency behavior as a\nfunction of time. In a dual way, the local time behavior as a function of\nfrequency is described by the {\\it group delay} :\n\\[t_x(\\nu) = -\\frac{1}{2\\pi}  \\frac{d\\arg{X_a(\\nu)}}{d \\nu}.\\]\nThis quantity measures the average time arrival of the frequency $\\nu$. The\nM-file \\index{\\ttfamily sgrpdlay}{\\ttfamily sgrpdlay.m} of the\nTime-Frequency Toolbox gives an estimation of the group delay of a signal\n(do not mistake it for the file {\\ttfamily grpdelay.m} of the signal\nprocessing toolbox which gives the group delay of a digital filter). For\nexample, with signal {\\ttfamily sig} of the previous example, we obtain\n(see fig. \\ref{Ns4fig1})\\,:\n\\begin{verbatim}\n     >> sig=fmlin(256); fnorm=0:.05:.5;\n     >> gd=sgrpdlay(sig,fnorm); plot(gd,fnorm);\n\\end{verbatim}\n\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns4fig1.eps}}\n\\caption{\\label{Ns4fig1}Estimation of the group delay of the previous chirp}\n\\end{figure}\n\nBe careful of the fact that in general, instantaneous frequency and group\ndelay define two different curves in the time-frequency plane. They are\napproximatively identical only when the time-bandwidth product $T\\times B$\nis large. To illustrate this point, let us consider a simple example. We\ncalculate the instantaneous frequency and group delay of two signals, the\nfirst one having a large $T\\times B$ product, and the second one a small\n$T\\times B$ product (see fig. \\ref{Ns4fig2})\\,:\n\\begin{verbatim}\n     >> t=2:255; \n     >> sig1=amgauss(256,128,90).*fmlin(256,0,0.5);\n     >> [tm,T1]=loctime(sig1); [fm,B1]=locfreq(sig1); \n     >> T1*B1              --->  T1*B1=15.9138\n     >> ifr1=instfreq(sig1,t); f1=linspace(0,0.5-1/256,256);\n     >> gd1=sgrpdlay(sig1,f1); plot(t,ifr1,'*',gd1,f1,'-')\n     >> sig2=amgauss(256,128,30).*fmlin(256,0.2,0.4);\n     >> [tm,T2]=loctime(sig2); [fm,B2]=locfreq(sig2); \n     >> T2*B2              --->  T2*B2=1.224\n     >> ifr2=instfreq(sig2,t); f2=linspace(0.2,0.4,256);\n     >> gd2=sgrpdlay(sig2,f2); plot(t,ifr2,'*',gd2,f2,'-')\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ns4fig2.eps}}\n\\caption{\\label{Ns4fig2}Estimation of the instantaneous frequency (stars)\nand group delay (line) of two different chirps with different amplitude\nmodulations. The first plot corresponds to a large $T\\times B$ product\nwhile the second corresponds to a small one}\n\\end{figure}\nOn the first plot, the two curves are almost superimposed (i.e. the\ninstantaneous frequency is the inverse transform of the group delay),\nwhereas on the second plot, the two curves are clearly different.\n\n\n\\section{About stationarity}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\index{stationarity}\n  Before talking about non-stationarity, which is a 'non-property', we must\ndefine what we call {\\it stationarity}.\n\n  A deterministic signal is said to be {\\it stationary} if it can be\nwritten as a discrete sum of sinusoids :\n\n\\begin{eqnarray*}\nx(t)&=&\\sum_{k \\in \\Nset} A_k \\cos{[2\\pi \\nu_k t + \\Phi_k]} \\ \\ \\ \\\n\\mbox{ for a real signal} \\\\   \nx(t)&=&\\sum_{k \\in \\Nset} A_k \\exp{[j(2\\pi \\nu_k t + \\Phi_k)]} \n\\mbox{for a complex signal}  \n\\end{eqnarray*}\ni.e. as a sum of elements which have constant instantaneous amplitude and\ninstantaneous frequency.\n\n  In the random case, a signal $x(t)$ is said to be {\\it wide-sense\nstationary} (or stationary up to the second order) if its expectation is\nindependent of time and its autocorrelation function $E[x(t_1)x^*(t_2)]$\ndepends only on the time difference $t_2-t_1$. We can then show that the\nassociated analytic signal has constant instantaneous amplitude and\nfrequency expectations, which can be connected to the deterministic case.\n\n\\index{non-stationarity} \nSo a signal is said to be {\\it non-stationary} if one of these fundamental\nassumptions is no longer valid. For example, a finite duration signal, and\nin particular a {\\it transient signal} (for which the length is short\ncompared to the observation duration), is non-stationary.\n\n\n\\section{How to synthesize a mono-component non-stationary signal}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  One part of the Time-Frequency Toolbox is dedicated to the generation of\nnon-stationary signals. In that part, three groups of M-files are available\\,:\n\n\\begin{enumerate}\n\\item The first one allows to synthesize different amplitude\nmodulations. These M-files begin with the prefix '{\\ttfamily am}'. For\nexample, {\\ttfamily amrect.m} computes a rectangular amplitude modulation,\n{\\ttfamily amgauss.m} a gaussian amplitude modulation \\ldots\n\n\\item The second one proposes different frequency modulations.  These\nM-files begin with '{\\ttfamily fm}'. For example, {\\ttfamily fmconst.m} is\na constant frequency modulation, {\\ttfamily fmhyp.m} a hyperbolic frequency\nmodulation \\ldots\n\n\\item The third one is a set of pre-defined signals. Some of them begin\nwith '{\\ttfamily ana}' because these signals are analytic (for example\n{\\ttfamily anastep, anabpsk, anasing} \\ldots), other have special names\n({\\ttfamily doppler, atoms} \\ldots).\n\\end{enumerate}\n\n  The first two groups of files can be combined to produce a large class of\nnon-stationary signals, multiplying an amplitude modulation and a frequency\nmodulation.\\\\\n\n {\\bf Examples}  \n\nWe can multiply the linear frequency modulation of Example 1 (see page\n\\pageref{ex1}) by a gaussian amplitude modulation (see\nfig. \\ref{Ns6fig1})\\,:\n\\begin{verbatim}\n     >> fm1=fmlin(256,0,0.5);\n     >> am1=amgauss(256);\n     >> sig1=am1.*fm1; plot(real(sig1));\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns6fig1.eps}}\n\\caption{\\label{Ns6fig1}Mono-component non-stationary signal with a linear\nfrequency modulation and a gaussian amplitude modulation}\n\\end{figure}\nBy default, the signal is centered on the middle (256/2=128), and its\nspread is $T=32$. If you want to center it at an other position {\\ttfamily\nt0}, just replace {\\ttfamily am1} by {\\ttfamily amgauss(256,t0)}. A second\nexample can be to multiply a pure frequency (constant frequency modulation)\nby a one-sided exponential window starting at {\\ttfamily t=100} (see\nfig. \\ref{Ns6fig2})\\,:\n\\begin{verbatim}\n     >> fm2=fmconst(256,0.2);\n     >> am2=amexpo1s(256,100);\n     >> sig2=am2.*fm2; plot(real(sig2));\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns6fig2.eps}}\n\\caption{\\label{Ns6fig2}Mono-component non-stationary signal with a\nconstant frequency modulation and a one-sided exponential amplitude\nmodulation} \n\\end{figure}\n\nAs a third example of mono-component non-stationary signal, we can consider\nthe M-file \\index{\\ttfamily doppler}{\\ttfamily doppler.m} : this function\ngenerates a modelization of the signal received by a fixed observer from a\nmoving target emitting a pure frequency (see fig. \\ref{Ns6fig3}).\n\\begin{verbatim}\n     >> [fm3,am3]=doppler(256,200,4000/60,10,50);\n     >> sig3=am3.*fm3; plot(real(sig3));\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns6fig3.eps}}\n\\caption{\\label{Ns6fig3}Doppler signal}\n\\end{figure}\nThis example corresponds to a target (a car for instance) moving straightly\nat the speed of 50\\,m/s, and passing at 10\\,m from the observer (the\nradar\\,!). The rotating frequency of the engine is 4000\\,revolutions per\nminute, and the sampling frequency of the radar is 200\\,Hz.\\\\\n\n  In order to have a more realistic modelization of physical signals, we\nmay need to add some complex noise on these signals. To do so, two M-files\n\\index{\\ttfamily noisecg}({\\ttfamily noisecg} an \\index{\\ttfamily\nnoisecu}{\\ttfamily noisecu}) of the Time-Frequency Toolbox are proposed :\n{\\ttfamily noisecg.m} generates a complex white or colored gaussian noise,\nand {\\ttfamily noisecu.m}, a complex white uniform noise. For example, if\nwe add complex colored gaussian noise on the signal {\\ttfamily sig1} with a\nsignal to noise ratio of -10\\,dB (see fig. \\ref{Ns6fig4})\n\\begin{verbatim}\n     >> noise=noisecg(256,.8);\n     >> sign=sigmerge(sig1,noise,-10); plot(real(sign));\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns6fig4.eps}}\n\\caption{\\label{Ns6fig4}Gaussian transient signal ({\\ttfamily sig1})\nembedded in a -10\\,dB colored gaussian noise} \n\\end{figure}\nthe deterministic signal {\\ttfamily sig1} is now almost imperceptible from\nthe noise.\n\n\n\\section{What about multi-component non-stationary signals ?}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  \n  The notion of instantaneous frequency implicitly assumes that, at each\ntime instant, there exists only a single frequency component. A dual\nrestriction applies to the group delay : the implicit assumption is that a\ngiven frequency is concentrated around a single time instant. Thus, if\nthese assumptions are no longer valid, which is the case for most of the\nmulti-component signals, the result obtained using the instantaneous\nfrequency or the group delay is meaningless.\\\\\n\n  {\\bf Example} \n\nFor example, let us consider the superposition of two linear frequency\nmodulations :\n\\begin{verbatim}\n     >> N=128; x1=fmlin(N,0,0.2); x2=fmlin(N,0.3,0.5);\n     >> x=x1+x2;\n\\end{verbatim}\nAt each time instant $t$, an ideal time-frequency representation should\nrepresent two different frequencies with the same amplitude. The results\nobtained using the instantaneous frequency and the group delay are of\ncourse completely different, and therefore irrelevant (see\nfig. \\ref{Ns7fig1})\\,: \n\\begin{verbatim}\n     >> ifr=instfreq(x); subplot(211); plot(ifr);\n     >> fn=0:0.01:0.5; gd=sgrpdlay(x,fn); \n     >> subplot(212); plot(gd,fn);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=6cm\n\\centerline{\\epsfbox{figure/ns7fig1.eps}}\n\\caption{\\label{Ns7fig1}Estimation of the instantaneous frequency (first\nplot) and group-delay (second plot) of a multi-component signal}\n\\end{figure}\nSo these one-dimensional representations, instantaneous frequency and group\ndelay, are not sufficient to represent all the non-stationary signals. A\nfurther step has to be made towards two-dimensional mixed representations,\njointly in time and in frequency. Even if no gain of information can be\nexpected since it is all contained in the time or in the frequency\nrepresentation, we can obtain a better structuring of this information, and\nan improvement in the intelligibility of the representation.\n\n  To have an idea of what can be made with a time-frequency decomposition,\nlet us anticipate the following and have a look at the result obtained on\nthis signal with the Short Time Fourier Transform (see\nfig. \\ref{Ns7fig2})\\,:\n\\begin{verbatim}\n     >> tfrstft(x);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ns7fig2.eps}}\n\\caption{\\label{Ns7fig2}Squared modulus of the short-time Fourier transform\nof the previous multi-component non-stationary signal}\n\\end{figure}\nHere two ``time-frequency components'' can be clearly seen, located around\nthe locus of the two frequency modulations.\n\n", "meta": {"hexsha": "11766ff3c6e19fdc8b514b3e8a9ffcf864abe867", "size": 19855, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tftb/tutorial/nonstat.tex", "max_stars_repo_name": "sangyoonHan/extern", "max_stars_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2018-03-28T01:50:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T07:24:14.000Z", "max_issues_repo_path": "tftb/tutorial/nonstat.tex", "max_issues_repo_name": "sangyoonHan/extern", "max_issues_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tftb/tutorial/nonstat.tex", "max_forks_repo_name": "sangyoonHan/extern", "max_forks_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2018-03-28T01:50:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T09:09:40.000Z", "avg_line_length": 43.9269911504, "max_line_length": 80, "alphanum_fraction": 0.7249055653, "num_tokens": 5634, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953797290153, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.41498494508913575}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{epsfig}\n\\usepackage{pdfsync}\n\\usepackage{amsfonts}\n\n\\begin{document}\n\n\\title{Documentation for the Multivariate Normal Gibbs sampler}\n\\author{Anand}\n\\maketitle\n\nThe Gibbs samplers in \\texttt{Normal.py} can be applied to parameters $x$ whose children are distributed as follows: For each child $c_i$,\n\\begin{eqnarray*}\n\t(c_i | x, F_i, a_i, \\tau_i) \\sim \\textup{N}(F_i x + a_i, \\tau_i).\n\\end{eqnarray*}\n\n\\section{Conjugate}\\label{conj}\nThe sampling method \\texttt{cMVNormalWithMVNormalChildren} applies if $x$'s prior is normal:\n\\begin{eqnarray*}\n\t(x|\\mu_p,\\tau_p) \\sim \\textup{N}(\\mu_p,\\tau_p).\n\\end{eqnarray*}\nIn this case, the log conditional probability up to constants not involving $x$, $\\sum_i \\log p_i(c_i|x,\\ldots) +\\log p_x(x|\\ldots)$, is equal to\n\\begin{eqnarray*}\n\t-\\frac{1}{2}(c_i-F_ix-a_i)^T\\tau_i(c_i-F_ix-a_i) - \\frac{1}{2}(x-\\mu_p)^T\\tau_p(x-\\mu_p),\n\\end{eqnarray*}\nwhich after completing the square yields\n\\begin{eqnarray*}\n\t(x|\\{c_i\\},\\ldots)\\sim\\textup{N}(\\mu,\\tau),\\\\\n\t\\tau = \\tau_p + \\sum_i F_i^T \\tau_i F_i,\\\\\n\t\\mu = \\tau^{-1}(\\tau_p\\mu_p + \\sum_i F_i^T\\tau_i(x_i-a_i)).\n\\end{eqnarray*}\n\nThis sampling method's constructor arguments are:\n\\begin{itemize}\n\t\\item \\texttt{parameter}: The parameter representing $x$. \n\t\\item \\texttt{F\\_dict}: A dictionary, indexed by child objects, whose values are nodes whose values are the $F$ matrices. \n\t\\item \\texttt{a\\_dict}: Same as \\texttt{F\\_dict}, but the values of the nodes are the $a$ arrays.\n\t\\item \\texttt{tau\\_dict}: The obvious.\n\t\\item \\texttt{prior\\_mu}: A node whose value is the prior mean of $x$.\n\t\\item \\texttt{prior\\_tau}: Same as \\texttt{prior\\_mu}, but with the precision matrix.    \n\\end{itemize}\n\n\\section{Nonconjugate}\\label{non}\nThe sampling method \\texttt{cMVNormalWithMVNormalChildren} applies if $x$'s prior $p_x(x)$ is non-normal. In this case, the log joint probability of $x$ up to unimportant constants, $\\sum_i \\log p_i(c_i|x,\\ldots) + \\log p_x(x)$, is equal to\n\\begin{eqnarray*}\n\t-\\sum_i\\frac{1}{2}(c_i-F_ix-a_i)^T\\tau_i(c_i-F_ix-a_i) +\\log p_x(x).\n\\end{eqnarray*}\nA Metropolis-Hastings step algorithm for this distribution which tends to be efficient is the following:\n\\begin{enumerate}\n\t\\item Propose a value $x^p$ for $x$ as if it had an uninformative prior ($\\tau_p = \\epsilon I$, with $\\epsilon << 1$). That is,\n\t\\begin{eqnarray*}\n\t\t(x_p|\\{c_i\\},\\ldots)\\sim\\textup{N}(\\mu,\\tau),\\\\\n\t\t\\tau = \\sum_i F_i^T \\tau_i F_i,\\\\\n\t\t\\mu = \\tau^{-1}\\sum_i F_i^T\\tau_i(x_i-a_i).\n\t\\end{eqnarray*}\t\n\t\\item Accept the jump with probability\n\t\\begin{eqnarray*}\n\t\t\\min\\left\\{1,\\frac{p_x(x^p)}{p_x(x)}\\right\\}.\n\t\\end{eqnarray*}\n\\end{enumerate}\n\nThis sampling method's constructor arguments are simply:\n\\begin{itemize}\n\t\\item \\texttt{parameter}: The parameter representing $x$. \n\t\\item \\texttt{F\\_dict}: A dictionary, indexed by child objects, whose values are nodes whose values are the $F$ matrices. \n\t\\item \\texttt{a\\_dict}: Same as \\texttt{F\\_dict}, but the values of the nodes are the $a$ arrays.\n\t\\item \\texttt{tau\\_dict}: The obvious.\n\\end{itemize}\n\n\\section{Things that would be nice for Gibbs sampling in general}\nI started a class called Gibbs in \\texttt{PyMC2/special\\_SamplingMethods/GibbsSampler.py}, but couldn't figure out how to make it work well. It would be nice if:  \n\\begin{itemize}\n\t\\item We come up with some consistent class factory for making conjugate/ nonconjugate pairs of Gibbs samplers, maybe similar to what we're doing in distributions.py.\t\n\t\\item The accessory dictionaries that get passed in to the constructor should be allowed to contain parameters, nodes, or simple ndarrays. The PyMC objects should have their values extracted automatically somehow.\n\t\\item Are we willing to insist on consistent parent keying schemes, to avoid having to pass in the accessory dictionaries? If so, we need to standardize across all Gibbs samplers and distributions.py. Compatibility for weird models will require heavy use of utility nodes.\n\t\\item Each Gibbs sampler holds a OneAtATimeMetropolis instance called `default' or something which it uses if a Gibbs step fails.\n\\end{itemize} \n\\end{document}", "meta": {"hexsha": "200fc4f5e2ab2de9e2bb4b849ea074c43850f7fd", "size": 4150, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PyMC2/sandbox/Normal.tex", "max_stars_repo_name": "rsumner31/pymc3-23", "max_stars_repo_head_hexsha": "539c0fc04c196679a1cdcbf4bc2dbea4dee10080", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-01T02:47:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-01T02:47:20.000Z", "max_issues_repo_path": "PyMC2/sandbox/Normal.tex", "max_issues_repo_name": "rsumner31/pymc3-23", "max_issues_repo_head_hexsha": "539c0fc04c196679a1cdcbf4bc2dbea4dee10080", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-08-17T06:58:38.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-17T06:58:38.000Z", "max_forks_repo_path": "PyMC2/sandbox/Normal.tex", "max_forks_repo_name": "rsumner31/pymc3-23", "max_forks_repo_head_hexsha": "539c0fc04c196679a1cdcbf4bc2dbea4dee10080", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5316455696, "max_line_length": 273, "alphanum_fraction": 0.7339759036, "num_tokens": 1321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4149849311581832}}
{"text": "\\documentclass[noinfoline]{imsart}\n%\\documentclass[10pt,letterpaper]{article}\n\n\n\\usepackage{bm}\n\\usepackage{geometry}\n\\usepackage{graphics,epsfig,rotate,lscape,graphicx,amsmath,amsthm,amssymb,float,amsfonts,amsbsy,hyperref,delarray,sectsty,amsfonts,amscd,pifont}\n\\usepackage{color,multirow}\n\\usepackage{algorithmic}\n\\usepackage{algorithm}\n\n\n\n\\geometry{letterpaper,left=1.2in,right=1.2in,top=1.2in,bottom=1.1in}\n\\bibliographystyle{plain}\n\\allowdisplaybreaks\n%\\def\\references{\\bibliography{C:/hanstex/macros/bib/11-1-11}}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{corollary}{Corollary}\n\\newtheorem{Prop}{Proposition}\n\\newtheorem{aside}{Aside}\n\\newtheorem{claim}{Claim}\n\\newtheorem{conjecture}{Conjecture}\n\\newtheorem{definition}{Definition}\n\\newtheorem{proposition}{Proposition}\n\n\\newcommand{\\bea}{\\begin{eqnarray*}}\n\\newcommand{\\eea}{\\end{eqnarray*}}\n\\newcommand{\\ed}{\\end{document}}\n\\newcommand{\\no}{\\noindent}\n\\newcommand{\\et}{\\textit{et al. }}\n\\newcommand{\\btab}{\\begin{tabular}}\n\\newcommand{\\etab}{\\end{tabular}}\n\\newcommand{\\bc}{\\begin{center}}\n\\newcommand{\\ec}{\\end{center}}\n\\newcommand{\\np}{\\newpage}\n\\newcommand{\\la}{\\label}\n\\newcommand{\\bi}{\\begin{itemize}}\n\\newcommand{\\ei}{\\end{itemize}}\n\\newcommand{\\bfi}{\\begin{figure}}\n\\newcommand{\\efi}{\\end{figure}}\n\\newcommand{\\ben}{\\begin{enumerate}}\n\\newcommand{\\een}{\\end{enumerate}}\n\\newcommand{\\bdes}{\\begin{description}}\n\\newcommand{\\edes}{\\end{description}}\n\\newcommand{\\bay}{\\begin{array}}\n\\newcommand{\\eay}{\\end{array}}\n\\newcommand{\\bs}{\\boldsymbol}\n\\newcommand{\\mb}{\\boldsymbol}\n\\newcommand{\\nn}{\\nonumber}\n\\newcommand{\\sm}{\\vspace{.2cm}}\n\\newcommand{\\bla}{\\textcolor{black}}\n\\newcommand{\\blu}{\\textcolor{blue}}\n\\newcommand{\\red}{\\textcolor{red}}\n\n\\def\\stackunder#1#2{\\mathrel{\\mathop{#2}\\limits_{#1}}}\n\\renewcommand{\\labelenumi}{(\\roman{enumi})}\n\\newcommand{\\Comment}[1]{\\textcolor{blue}{\\textsc{#1}}}\n\n\n\\def\\Ver{1}\n\\def\\LongVer{0}\n%%------------------------------ begin long version\n%\\if\\Ver\\LongVer{\n%{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n%\n%{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n%} \\fi\n%%------------------------------ end long version\n\n\n\n\n\\newcommand{\\be}{\\begin{eqnarray}}\n\\newcommand{\\ee}{\\end{eqnarray}}\n\\renewcommand{\\baselinestretch}{1}%{1.7}\n\n%====================================================================================\n\\begin{document}\n%============================================================\n\n\n\n\\begin{frontmatter}\n\n\\title{A general spline representation for nonparametric and semiparametric density estimates using diffeomorphisms}\n\\runtitle{Diffeomorphisms for density estimation}\n\n\\begin{aug}\n  \\author{\\fnms{Ethan}  \\snm{Anderes}\\thanksref{a}\\ead[label=e1]{anderes@stat.ucdavis.edu}}\n    \\and\n  \\author{\\fnms{Marc} \\snm{Coram}\\thanksref{b}\\ead[label=e2]{mcoram@stanford.edu}}\n\n  \\runauthor{Anderes and Coram}\n\n % \\affiliation{University of California, Davis and Stanford University}\n\n  \\address[a]{Department of Statistics, University of California, Davis CA 95616, USA. \\printead{e1}}\n\n  \\address[b]{Department of Health Research and Policy (Biostatistics),  Stanford University, Palo Alto, CA 94305, USA. \\printead{e2}}\n\n\\end{aug}\n\n\\begin{abstract}\nA theorem of McCann \\cite{mcc:95} shows that for any two absolutely continuous probability measures on $\\Bbb R^d$ there exists a monotone transformation sending one probability measure to the other.\nA consequence of this theorem, relevant to statistics,  is that density estimation can be recast in terms of transformations. In particular, one can fix any absolutely continuous probability measure, call it $\\Bbb P$, and then reparameterize the whole class of absolutely continuous probability measures as monotone transformations from $\\Bbb P$.\nIn this paper we utilize this reparameterization of densities, as monotone transformations from some $\\Bbb P$, to construct semiparametric and nonparametric density estimates. We focus our attention on classes of transformations, developed in the image processing and computational anatomy literature,  which are smooth,  invertible and which have attractive computational properties.\n The techniques developed for this class of transformations allow us to show that a penalized maximum likelihood estimate (PMLE) of a smooth transformation from $\\Bbb P$ exists and has a finite dimensional characterization, similar to those results found in the spline literature.\n These results are derived utilizing  an Euler-Lagrange characterization of the PMLE which also establishes a surprising connection to a generalization of Stein's lemma for characterizing the normal distribution.\n\\end{abstract}\n\n\\begin{keyword}\n\\kwd{Euler-Lagrange}\n\\kwd{density estimation}\n\\kwd{penalized maximum likelihood}\n\\kwd{diffeomorphism}\n\\end{keyword}\n\n\\end{frontmatter}\n\n\n\n\n\n%\n%\\thispagestyle{empty}\n%\n%\\begin{center}\n%{\\Large {\\bf A general spline representation for nonparametric and semiparametric density estimates using diffeomorphisms.}}\n%\n%\\vspace{.5in}\n%\n%Ethan Anderes$^{1}$  and Marc Coram$^{2}$\\\\\n%\n%\\vspace{.25in}\n%\n%${}^1$Department of Statistics, University of California, Davis, CA 95616,\n%USA\\\\e-mail: {\\tt anderes@stat.ucdavis.edu}\n%\n%\\vspace{.25in}\n%\n%${}^2$Health Research and Policy Department, Stanford University, Palo Alto, CA 94304,\n%USA\n%\n%\n%\\end{center}\n%\n%\\begin{footnotetext}[1]\n%{Supported in part by National Science Foundation grant DMS-1007480}\n%\\end{footnotetext}\n%\\begin{footnotetext}[2]\n%{Supported in part by National Institute of Health grant 5UL1 RR02574404}\n%\\end{footnotetext}\n%\n%\\newpage\n%\n%\\begin{abstract}\n%A theorem of McCann \\cite{mcc:95} shows that for any two absolutely continuous probability measures on $\\Bbb R^d$ there exists a monotone transformation sending one probability measure to the other.\n%A consequence of this theorem, relevant to statistics,  is that density estimation can be recast in terms of transformations. In particular, one can fix any absolutely continuous probability measure, call it $\\Bbb P$, and then reparameterize the whole class of absolutely continuous probability measures as monotone transformations from $\\Bbb P$.\n%In this paper we utilize this reparameterization of densities, as monotone transformations from some $\\Bbb P$, to construct semiparametric and nonparametric density estimates. We focus our attention on classes of transformations, developed in the image processing and computational anatomy literature,  which are smooth,  invertible and which have attractive computational properties.\n% The techniques developed for this class of transformations allow us to show that a penalized maximum likelihood estimate (PMLE) of a smooth transformation from $\\Bbb P$ exists and has a finite dimensional characterization, similar to those results found in the spline literature.\n% These results are derived utilizing  an Euler-Lagrange characterization of the PMLE which also establishes a surprising connection to a generalization of Stein's lemma for characterizing the normal distribution.\n%\\end{abstract}\n%\n%\\noindent{\\it Key words and phrases}: Density estimation, Euler-Lagrange, penalized maximum likelihood,  diffeomorphism.\n%\n%\\vspace{.2in}\n%\n%\\noindent {\\bf MSC 2010 Subject Classification: 62G07}\n%\n%\\thispagestyle{empty}\n%\n%\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%\\newpage\n\n\\section{Introduction}\n\n\\setcounter{page}{1}\n\n  Smooth invertible transformations, or deformations, are fast becoming important tools in modern data analysis.\n  They have been used with spectacular success in the field of computational anatomy where time varying vector field flows, which generate deformations, are used to statistically analyze medical fMRI images and quantify abnormal morphological structure\n  (see  \\cite{alla:07,\n Beg:2006ly,\n conf/miccai/BegMTY03,\n  Beg:2005qf,\n   cao:05,\n   dup:98,\n Grenander:1998:CAE:309082.309089,\n Miller:1999bh,\n Miller:2006zr,\n Miller:2001ve,\n Trouve:1998ys,\n ty:dq,\n vaillant:04,\nyou:10,\nYounes:2008}, and references therein).\n  % (see  \\cite{you:10} and references therein).\n  In cosmology, deformations  are used to model gravitational distortions of the cosmic microwave background from  dark matter density fluctuations and have resulted in a deeper understanding of cosmic structure \\cite{Das:2011uq}.\n%Moreover, finding good transformations of the data is an important part of almost any data analysis (variance stabilizing transformations, for example).\nTransformations or deformations also have the power\n to recast the generic problem of density estimation to that of deformation estimation.  In particular, one can fix any absolutely continuous probability measure, call it $\\Bbb P$, and then reparameterize the whole class of absolutely continuous probability measures as monotone transformations from $\\Bbb P$ (this follows by results in \\cite{mcc:95}).  The advantage of this new viewpoint is the flexibility in choosing the target measure $\\Bbb P$ which can encode  prior information on the shape of true sampling distribution.\n For example, if it is known that the data is nearly Gaussian then choosing a  Gaussian $\\Bbb P$  along with a strong penalty on transformations that are far from the identity allows one to construct penalized maximum likelihood estimates which effectively shrink the resulting nonparametric estimate in the direction of the Gaussian target $\\Bbb P$. Moreover, when there is no knowledge about the true sampling measure, one can simply choose any absolutely continuous $\\Bbb P$ and still construct a completely nonparametric density estimate.\n\n\n%\n%  density estimation can be obtained by fixing a target probability measure, then estimating a deformation which pushes forward the sampling distribution to the target measure. Such a density estimate  can generate nonparametric and semiparametric density estimates while  also incorporating  shape information for the unknown sampling distribution.\n%\n  Recent work in \\cite{and:11}, \\cite{AnderesNychka} and  \\cite{ElMoselhy20127815} utilize  this idea of representing classes of  probability measures as deformations $\\phi:\\Bbb R^d\\rightarrow \\Bbb R^d$ of a known target probability measure $\\Bbb P$ on $\\Bbb R^d$.\n The principle difficulty when working with such models is the construction of a rich class of deformations   which are nonparametric, smooth,  invertible and which are amenable to optimization. In \\cite{and:11} and \\cite{AnderesNychka} the authors the utilize  the class of quasi-conformal maps to generate penalized maximum likelihood estimates of $\\phi$. However, these tools were only developed for $\\Bbb R^2$ with no clear generalization for higher dimension.\n In \\cite{ElMoselhy20127815} the authors use polynomial approximations to $\\phi$ which could potentially violate the invertabliltiy requirements on $\\phi$.\nIn this paper,  we circumvent these challenges by adapting the powerful tools developed by Grenander, Miller,  Younes, Trouv\\'e and co-authors in the image processing and computational anatomy literature   (see \\cite{you:10} and the references therein) to generate estimates of  $\\phi$ with all the required properties: nonparametric flexibility, smoothness, invertability and computational tractability.\nWe establish the existence of a penalized maximum likelihood estimate of $\\phi$  which has a finite dimensional characterization  similar to those results found in the spline literature (see \\cite{wahba:90}). This finite dimensional characterization is a key component  of the numerical computation of these estimates which are nominally defined as a infinite  dimensional minimizer of a penalized likelihood. Moreover, our results are derived utilizing  an Euler-Lagrange characterization of the PMLE which also establishes a surprising connection to a generalization of Stein's lemma for characterizing the normal distribution.\n\nWe start the paper in Section \\ref{rich} with an overview of using the  dynamics of time varying vector field flows to generate a rich class of diffeomorphisms. Then in sections \\ref{pmle} and \\ref{EL} we define our penalized maximum likelihood estimate (PMLE) of $\\phi$ and prove not  only existence, but also establish a  finite dimensional characterization which is key for numerically computing the resulting density estimate. In Section \\ref{steinSection} we notice a surprising connection with the Euler-Lagrange equation for the PMLE of $\\phi$ and a generalization of Stein's lemma for characterizing the normal distribution (see \\cite{stein:04}). In sections \\ref{npe} and \\ref{spe} we give examples of our new density estimate, first as a nonparametric density estimate and second as a semiparametric density estimate where a finite dimensional model is used for the target probability measure $\\Bbb P$. We finish the paper with an appendix which contains some technical details used for the proofs of the existence of the PMLE and for the finite dimensional characterization.\n\n\n%%%%%%%%%%%%%\n% section\n%%%%%%%%%%%%%%%%\n\\section{A rich class of diffeomorphisms}\n\\label{rich}\n\n In this section we give a brief overview of using the  dynamics of time varying vector field flows to generate rich classes of diffeomorphisms. These time varying flows have been utilized   in the field of computational anatomy and image processing (see \\cite{Younes:2008}, and references therein) and have been shown to be very powerful  for developing algorithms which optimize a diverse range of objective functions defined over classes of diffeomorphism.  It is these tools that we adapt for density estimation and statistics.\n\n\n\nA map $\\phi\\colon \\Omega \\rightarrow\\Bbb R^d$ is said to be a $C^k(\\Omega,\\Bbb R^d)$ diffeomorphism of the open set $\\Omega \\subset \\Bbb R^d$ if  $\\phi$ is one-to-one, maps onto $\\Omega$, and  $\\phi, \\phi^{-1}\\in C^{k}(\\Omega,\\Bbb R^d)$.  In what follows we generate classes of diffeomorphisms by time varying vector field flows. In particular, let  $\\{ v_t\\}_{t\\in [0,1]}$  be a time varying vector field in $\\Bbb R^d$, where $t$ denotes  `time' so that for each $t$, $v_t$ is a function mapping $\\Omega$ into $\\Bbb R^d$. Under mild smoothness conditions there exists a unique class of diffeomorphisms of $\\Omega$, denoted $\\{ \\phi_t^v\\}_{t\\in [0,1]}$, which satisfy the following ordinary differential equation\n\\begin{align}\n\\label{ood}\n \\partial_t \\phi_t^v(x) &= v_t(\\phi_t^v(x))\n \\end{align}\n with boundary condition $\\phi_0^v(x)=x$, for all $x\\in \\Omega$ (see Theorem \\ref{ExistFlow} below). The interpretation of these flows is that $\\phi_t(x)$ represents the position of a particle at time $t$, which originated from location $x$ at time $t=0$, and flowed according the the instantaneous velocity given by $v_t$. It will be convenient to consider the diffeomorphism that maps time $t$ to some other time $s$, this will be denoted $\\phi_{ts}^{ v}(x)\\equiv \\phi_{s}^{v}( {\\phi_{t}^{ v}}^{-1}(x)) $.\n\nFor the remainder of the paper we will assume that at each time $t$, $v_t$ will be a member of a  Hilbert space of vector fields mapping  $\\Omega$ into $\\Bbb R^d$ with inner product denoted by $\\langle\\cdot, \\cdot \\rangle_V$ and norm by $\\|  \\cdot \\|_V$.\nIndeed, how one chooses the Hilbert space $V$ will determine the smoothness properties of the resulting class of deformations $\\{\\phi_t\\}_{t\\in[0,1]}$.  Once the Hilbert space $V$ is fixed we can define the following set of time varying vector fields.\n\n\\begin{definition}\n\\label{defV01}\n Let  $V^{[0,1]}$ denote the space of measurable functions $v_t(x)\\colon [0,1]\\times \\Omega\\rightarrow \\Bbb R^d$ such that $v_t\\in V$ for all $t\\in [0,1]$ and $\\int_0^1 \\| v_t\\|^2_V dt <\\infty $.\n\\end{definition}\nOne clear advantage of this class  is that it can be endowed with a Hilbert space inner product if $V$ is a Hilbert space. Indeed,\n $V^{[0,1]}$ is a Hilbert space with inner product  defined by $\\langle v,h \\rangle_{V^{[0,1]}} \\equiv\\int_0^1 \\langle  v_t, h_t\\rangle_V dt$ (see Proposition \\ref{Hspace} in the Appendix or Proposition 8.17 in \\cite{you:10}).\nFor the remainder of the paper we typically use $v$ or $w$ to denote  elements of  $ V^{[0,1]}$ and  $v_t$ or $w_t$ to denote the corresponding elements of $V$ at any fixed time $t$.\nAn important theorem found in \\cite{you:10} relates the smoothness of $V$ to the smoothness of the resulting diffeomorphism.\nBefore we state the theorem, some definitions will be prudent. The Hilbert space $V$ is said to be continuously embedded in another normed space $H$ (denoted $V\\hookrightarrow H$) if $V\\subset H$ and there exists a constant $c$ such that\n\\[ \\| v \\|_H \\leq c \\| v\\|_V \\]\nfor all $v\\in V$ where $\\|\\cdot \\|_H$ denotes the norm in $H$.\n Also we let $C_0^k(\\Omega,\\Bbb R^d)$ denote the subset of $C^k(\\Omega,\\Bbb R^d)$ functions whose partial derivatives of order $k$ or less all have continuous extensions to zero at the boundary $\\partial \\Omega$.\n\\begin{theorem}[\\cite{you:10}, \\cite{dup:98}]\n\\label{ExistFlow}\nIf $V\\hookrightarrow C_0^k(\\Omega,\\Bbb R^d)$, then for any $v\\in V^{[0,1]}$ there exists a unique class of $C^k(\\Omega,\\Bbb R^d)$ diffeomorphisms $\\{\\phi^v_t\\}_{t\\in[0,1]}$ which satisfy (\\ref{ood}) and  $\\phi_0^v(x) = x$ for all $x\\in \\Omega$.\n\\end{theorem}\n\nTo derive our finite dimensional characterization we will make the additional assumption that $V$ is a reproducing kernel Hilbert space of vector fields. This will guarantee the existence of a reproducing kernel\n $K( x,y)\\colon \\Omega \\times \\Omega \\rightarrow \\Bbb R^{n\\times n}$ which can be used to compute the evaluation functional. In particular, $K$ has the property that for any $x\\in \\Omega$ and $f\\in V$ the following identity holds $\\langle  K(x,\\cdot) p , f\\rangle _V=  p^T f(x)$ for all column vectors $p\\in \\Bbb R^d$.\n To simplify the following computations we will only work with kernels of the form $K(x,y) = R(x,y)I_{d\\times d}$ where $R:\\Omega\\times\\Omega\\rightarrow \\Bbb R$ is a positive definite function and $I_{d\\times d}$ is the $d$-by-$d$ identity matrix.\n\n Now the class of diffeomorphisms we consider in this paper  corresponds to the set of all time varying vector field flows evaluated at $t=1$: $\\phi^v_1$, where $v$ ranges through $V^{[0,1]}$. The class $V^{[0,1]}$ will be completely specified by the reproducing kernel $R(x,y)I_{d\\times d}$ which has the flexibility to control the smoothness of the resulting maps $\\phi_1^v$ through Theorem \\ref{ExistFlow}.\n %%%%%%%%%%%%%%%%%%\n%\n%%%%%%%%%%%%\n\\section{Penalized maximum likelihood estimation}\n\\label{pmle}\n\n\nFormally, we model our data   $X_1,\\ldots, X_n$ as independent samples of an {\\it unknown} diffeomorphism $\\phi^v_1$ of a {\\it known} probably distribution $\\Bbb P$ on $\\Bbb R^d$. In particular,\n\\begin{equation}\n\\label{model1}\nX_1,\\ldots,X_n\\overset{iid}\\sim \\Bbb P\\circ \\phi_1^v\n\\end{equation}\nwhere  $\\phi^v_1$ is generated by a time varying vector field flow $\\{\\phi^v_t\\}_{t\\in[0,1]}$ which satisfies (\\ref{ood}) and $v\\in V^{[0,1]}$.\n%where $\\Bbb P$ is a known measure on $\\Bbb R^d$ (or at least known up to some finite dimensional parameterization) and $\\phi$ is an unknown smooth bijection of $\\Bbb R^d$.\nAs remarked in the introduction, by simply choosing any absolutely continuous measure  $\\Bbb P$ the\nmodel (\\ref{model1}) is still completely nonparametric.  The advantage is that when partial information exists on the sampling distribution of the data, it can potentially be encoded in the choice of $\\Bbb P$.\nThe notation $\\Bbb P\\circ \\phi^v_1$, in (\\ref{model1}), is taken to mean that the probability of $X\\in A$ is given by   $ \\Bbb P(\\phi^v_1(A))$ where $\\phi_1^v(A)=\\{ \\phi(x)\\colon x\\in A \\}$. An important observation is that the model (\\ref{model1}) implies that $\\phi_1^v(X)\\sim \\Bbb P$. Therefore, one can imagine estimating $\\phi_1^v$ by attempting to ``deform'' the data $X_1,\\ldots,X_n$ by a transformation which satisfies\n\\[ \\phi_1^v(X_1),\\ldots,\\phi_1^v(X_n)\\overset{iid}\\sim \\Bbb P. \\]\n %In this way the model (\\ref{model1}) is can be seen to be exceedingly flexible and, depending on how one models $\\phi$ and $\\Bbb P$,  can range from fully nonparametric to small perturbations of parametric models.\n%One of the main difficulties when working with such a model is the invertibility condition on the maps $\\phi$. The nonlinearity of this condition in $\\Bbb R^d$ when $d>1$ makes constructing rich classes and optimizing over such classes difficult.\n%One of the early attempts at circumventing such difficulties, found in \\cite{and:11}, utilized  the class of quasi-conformal maps to generate penalized maximum likelihood estimates of $\\phi$. However, these tools were only developed for $\\Bbb R^2$ with no clear generalization for higher dimension.\n%In this paper we adapt the powerful tools developed by Grenander, Miller,  Younes, Trouv\\'e and co-authors in the image processing and computational anatomy literature   (see \\cite{you:10} and the references therein) and\n%apply them to the estimation of $\\phi$ from data $X_1,\\ldots, X_n$. Indeed, these techniques allow us to show that a penalized maximum likelihood estimate of $\\phi$ exists and that the solution has a finite dimensional characterization, similar to those results found in the spline literature (see \\cite{wahba:90}).\n%\n%\nIn this section, we construct a penalized maximum likelihood estimate (PMLE) of $\\hat v$ given the data (\\ref{model1}), whereby obtaining an estimate $ \\Bbb P\\circ \\phi^{\\hat v}_1$ of the true sampling  distribution.\n\nThe target probability measure $\\Bbb P$ is assumed to have a bounded density with respect to Lebesque measure on $\\Bbb R^d$.\nTherefore, by writing the density of $\\Bbb P$ as $\\exp H$ for some  function $H\\colon\\mathbb R^d\\rightarrow \\mathbb R\\cup \\{-\\infty\\}$, the probability measure $\\Bbb P\\circ \\phi^v_1$ has density given by\n \\[ d\\,\\Bbb P\\circ \\phi_1^v(x)  =\\det (D\\phi_1^v(x))  \\exp H \\circ \\phi_1^v(x) dx  \\]\n where $\\det (D\\phi^v_1(x))$ is defined as the  determinant of the Jacobian of $\\phi^v_1$ evaluated at $x\\in \\Omega$ (always positive by the orientation preserving nature of $\\phi^v_1$).\nSince $\\phi_1^v$ ranges over an infinite dimensional space of diffeomorphisms, the  likelihood for $v$ given the data  will typically be unbounded as $v$ ranges in $V^{[0,1]}$. The natural solution is to regularize the log likelihood using the corresponding  Hilbert space norm on $V^{[0,1]}$ with a  multiplicative tuning factor $\\lambda/2$.\nThe penalized log-likelihood (scaled by $1/n$) for the unknown vector field $v$ flow given data $X_1,\\ldots, X_n\\overset{iid}\\sim \\Bbb P\\circ \\phi^v_1$ is then given by\n \\begin{equation}\n \\label{energy1}\n E_\\lambda(v)\\equiv  \\frac{1}{n} \\sum_{k=1}^n \\log\\text{det}[D\\phi(X_k) ]+H\\circ\\phi(X_k)  - \\frac{\\lambda}{2}  \\int_0^1 \\| v_t \\|_V^2 dt.\n \\end{equation}\n The estimated vector field $\\hat v$ is chosen to be any element of $V^{[0,1]}$ which maximizes $E_\\lambda$ over $V^{[0,1]}$.\n The following theorem establishes that such a $\\hat v$ exists.\n %%%%%%%%%%%\n % begin claim\n %%%%%%%%%%%%\n\\begin{claim}\n\\label{claim1}\nLet $V$ be a  Hilbert space which is  continuously  embedded in $C_0^2(\\Omega, \\Bbb R^d)$ where $\\Omega$ is a bounded open subset of $\\Bbb R^d$. Suppose $e^{H(\\cdot)}$ is a bounded and continuous density  on $\\Omega$. Then there exists a time varying vector field $\\hat v \\in V^{[0,1]}$ such that\n\\begin{equation}\n\\label{exist}\nE_\\lambda(\\hat v)=\\sup_{v\\in V^{[0,1]}}E_\\lambda(v).\n\\end{equation}\n\\end{claim}\n%%%%%%%%%%\n% begin proof\n%%%%%%%%%%%%\n\\begin{proof}\n\n\n\nWe first establish $\\sup_{v\\in V^{[0,1]}}E_\\lambda(v)<\\infty$ by splitting the energy $E_\\lambda$ into three parts\n\\begin{equation}\n\\label{decomp}\nE_\\lambda(v)=\\underbrace{\\frac{1}{n}\\sum_{k=1}^n   \\log\\text{det} D\\phi_1^v(X_k) }_{=:E_1(v)}+ \\underbrace{\\frac{1}{n}\\sum_{k=1}^n H\\circ\\phi_1^v(X_k)}_{=:E_2(v)}  \\underbrace{-\\frac{\\lambda}{2} \\int_0^1 \\| v_t \\|_V^2 dt.}_{=:E_3(v)}\n\\end{equation}\nNotice that each term is well defined and finite whenever $v\\in V^{[0,1]}$, since\nthe assumption $V\\hookrightarrow C_0^2(\\Omega, \\Bbb R^d)$ is sufficient for  Theorem 8.7   in \\cite{you:10} to apply to the class  $ V^{[0,1]}$. In particular, for any  $v\\in V^{[0,1]}$  there exists a unique class of $C^1$ diffeomorphisms of $\\Omega$, $\\{\\phi_t^v\\}_{t\\in [0,1]}$, which satisfies (\\ref{ood}) (also see Theorem 2.5 in \\cite{dup:98}).\nThe term $E_2(v)$ is clearly bounded from above since  $\\sup_{x\\in\\Omega}H(x)<\\infty$ by assumption.\nFor the remaining two terms notice that  the determinant of the Jacobian is given by   $ \\log\\det D\\phi_1^v(x)  = \\int_0^1  \\text{div}\\,  v_t (\\phi_t^v(x))dt$ (by equation (\\ref{div}) in the Appendix).\nTherefore\n\\begin{align}\nE_1(v) + E_3(v) & = \\frac{1}{n}\\sum_{k=1}^n   \\int_0^1 \\left(  \\text{div}\\,  v_t (\\phi_t^v(X_k))  - \\frac{\\lambda}{2}   \\| v_t \\|_V^2\n\\right)dt \\nonumber\\\\\n & \\leq \\frac{1}{n}\\sum_{k=1}^n   \\int_0^1 \\left( \\sup_{x\\in \\Omega} |\\text{div}\\,  v_t (x)|  - \\frac{\\lambda}{2}   \\| v_t \\|_V^2\n\\right)dt \\nonumber \\\\\n & \\leq    \\int_0^1 \\left( c\\| v_t \\|_V  - \\frac{\\lambda}{2}   \\| v_t \\|_V^2\n\\right)dt, \\,\\,\\text{by the assumption $V\\hookrightarrow C_0^2(\\Omega, \\Bbb R^d)$} \\nonumber \\\\\n& \\leq \\frac{c^2}{2\\lambda}<\\infty. \\nonumber\n\\end{align}\n\nNow let $v^1,v^2,\\ldots$ be any maximizing sequence that satisfies $\\lim_{m\\rightarrow \\infty} E(v^m) = \\sup_{v\\in V^{[0,1]}}E_\\lambda(v)$. Since $\\sup_{v\\in V^{[0,1]}}E_\\lambda(v)<\\infty $  we can construct the sequence $v^m$ so that there exists an $M<\\infty$ such that $\\| v^m \\|_{V^{[0,1]}}\\leq M$ for all $m$. Since $\\Omega$ is bounded, closed finite balls in $V^{[0,1]}=L^2([0,1],V)$ are weakly compact (by \\cite{dup:98}). Therefore we may  extract a subsequence from $v^m$ (relabeled by $m$) which weakly converges to  a $\\hat v \\in V^{[0,1]}$. In particular, $\\langle v^m, w \\rangle_{V^{[0,1]}}\\rightarrow \\langle \\hat v, w \\rangle_{V^{[0,1]}}$ for all $w\\in V^{[0,1]}$. Furthermore we have lower semicontinuity of the norm\n\\begin{equation}\n\\label{liminf}\n \\liminf_{m\\rightarrow \\infty} \\| v^m \\|^2_{V^{[0,1]}} \\geq  \\| \\hat v \\|^2_{V^{[0,1]}}.\n\\end{equation}\nNow by Theorem 3.1 in \\cite{dup:98}\n %------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n\\cite{dup:98}  applies since the assumption $[W_0^{3,2}(\\Omega)]^3$ (where $\\Omega\\subset \\Bbb R^3$ in their paper) is only used to establish that $[W_0^{3,2}(G)]^3\\hookrightarrow C_0^1(G)$. Since we are assuming $V\\hookrightarrow C_0^2(\\Omega, \\Bbb R^d)\\hookrightarrow C_0^1(\\Omega, \\Bbb R^d)$ we are free to use the results in \\cite{dup:98} .\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%------------------------------ end long version\n we have that  $\\phi^{v^m}_t(x) \\rightarrow \\phi^{\\hat v}_t(x)$ uniformly in $t\\in [0,1]$ as $m\\rightarrow \\infty$.\nThis allows us to show that $\\log \\det D\\phi_1^{v^m}(x)\\overset{m\\rightarrow\\infty}\\longrightarrow \\log \\det D\\phi_1^{\\hat v}(x)$ for every $x\\in \\Omega$. To see why, one can use similar reasoning as in \\cite{cao:05}. First write\n\\begin{align*}\n|\\log \\det D\\phi_1^{v^m}(x)- \\log \\det D\\phi_1^{\\hat v}(x)| &= \\left| \\int_{0}^1 \\text{div}\\, v_t^m(\\phi_t^{v^m}(x)) -  \\text{div}\\, \\hat v_t(\\phi_t^{\\hat v}(x)) dt \\right|\n=I + I\\!I\n%\\\\\n%& \\leq \\underbrace{\\left| \\int_{0}^1 \\text{div}\\, v_t^m(\\phi_t^{v^m}(x)) -  \\text{div}\\, v^m_t(\\phi_t^{\\hat v}(x)) dt \\right|}_{\\equiv I} \\\\\n%& \\qquad\\qquad\\qquad + \\underbrace{\\left| \\int_{0}^1 \\text{div}\\,  v^m_t(\\phi_t^{\\hat v}(x)) -  \\text{div}\\, \\hat v_t(\\phi_t^{\\hat v}(x)) dt \\right|.}_{\\equiv I\\!I}\n\\end{align*}\nwhere the first term $I$ satisfies\n\\begin{align*}\nI &\\equiv \\left| \\int_{0}^1 \\text{div}\\, v^m_t(\\phi_t^{v^m}(x)) -  \\text{div}\\, v^m_t(\\phi_t^{\\hat v}(x)) dt \\right| \\\\\n&\\leq \\int_{0}^1 \\|\\text{div}\\, v^m_t\\|_{1,\\infty} \\bigl|\\phi_t^{v^m}(x) -  \\phi_t^{\\hat v}(x)\\bigr| dt  \\\\\n&\\leq   \\int_{0}^1 c\\| v^m_t\\|_{V} \\bigl|\\phi_t^{v^m}(x) -  \\phi_t^{\\hat v}(x)\\bigr| dt,\\,\\,\\text{since $V\\hookrightarrow C_0^2(\\Omega,\\Bbb R^d)$} \\\\\n&\\leq  c\\|  v^m\\|_{V^{[0,1]}} \\Bigl[\\int_{0}^1 \\underbrace{\\bigl|\\phi_t^{v^m}(x) -  \\phi_t^{\\hat v}(x)\\bigr|^2}_\\text{ $= o(1)$ uniformly in $t$} dt\\Bigr]^{1/2},\\,\\,\\text{by H\\\"older.} \\\\\n&\\rightarrow 0,\\,\\text{ since $\\| v^m\\|_{V^{[0,1]}}\\leq M$ for all $m$.}\n\\end{align*}\nFor the second term $I\\!I$ notice that  the map sending $v\\mapsto \\int_0^1 \\text{div}\\, v_t(y_t) dt$ is a bounded linear functional on $V^{[0,1]}$ (using the fact that $V\\hookrightarrow C_0^1(\\Omega, \\Bbb R^d)$) where $y_t \\equiv \\phi_t^{\\hat v}(x)$. By the Riesz representation theorem there exists a $w^{\\hat v}\\in V^{[0,1]}$ such that $\\int_0^1 \\text{div}\\, v_t(y_t) dt = \\langle v,w^{\\hat v} \\rangle_\\text{\\tiny $V^{[0,1]}$}$. Therefore  %there exists a $w^{\\hat v}\\in  V^{[0,1]}$ such that\n \\begin{align*}\nI\\!I\n&\\equiv \\left| \\int_{0}^1 \\text{div}\\, v_t^m(\\phi_t^{\\hat v}(x)) -  \\text{div}\\, \\hat v_t(\\phi_t^{\\hat v}(x)) dt \\right|\\\\\n&=   \\Bigl| \\langle v^m -  \\hat v, w^{\\hat v}\\rangle_{V^{[0,1]}}\\Bigr|\\rightarrow 0, \\,\\,\\text{by weak convergence.}\n\\end{align*}\nCombining the results for $I$ and $I\\!I$ we can conclude that $\\log \\det D\\phi_1^{v^m}(x)\\overset{m\\rightarrow\\infty}\\longrightarrow \\log \\det D\\phi_1^{\\hat v}(x)$ for every $x\\in \\Omega$.\n\nTo finish the proof notice that\n\\begin{align}\n\\sup_{v\\in V^{[0,1]}} E_\\lambda(v) &= \\lim_{m\\rightarrow \\infty} E(v^m)= \\limsup_{m\\rightarrow \\infty} E(v^m)\\nonumber\\\\\n&= \\frac{1}{n}\\sum_{k=1}^n   \\log\\text{det} D\\phi_1^{\\hat v}(X_k)+ \\frac{1}{n}\\sum_{k=1}^n H\\circ\\phi_1^{\\hat v}(X_k) -\\frac{\\lambda}{2} \\liminf_{m\\rightarrow \\infty} \\int_0^1 \\| v^m_t \\|_V^2 dt \\nonumber\\\\\n%&\\phantom{\\frac{1}{n}\\sum_{k=1}^n   \\log\\text{det} D\\phi_1^{\\hat v}(X_k)+ \\frac{1}{n}\\sum_{k=1}^n H\\circ\\phi_1^{\\hat v}(X_k) \\frac{1}{n}\\sum_{k=1}^n H\\circ\\phi_1^{\\hat v}(X_k) }\\text{ since $H$ is continuous} \\\\\n&\\leq \\frac{1}{n}\\sum_{k=1}^n   \\log\\text{det} D\\phi_1^{\\hat v}(X_k)+ \\frac{1}{n}\\sum_{k=1}^n H\\circ\\phi_1^{\\hat v}(X_k) -\\frac{\\lambda}{2}  \\int_0^1 \\| \\hat v_t \\|_V^2 dt,\\,\\,\\text{ by (\\ref{liminf})}\\nonumber \\\\\n&= E_\\lambda(\\hat v) \\nonumber\n\\end{align}\n\n  \\end{proof}\n%%%%%%%%%%\n% end proof\n%%%%%%%%%%%%\n\n\nOne of the important facts about any vector field flow $\\hat v\\in V^{[0,1]}$ which maximizes $E_\\lambda$  is that the resulting estimated transformation  $\\phi_1^{\\hat v}$ is a geodesic (or minimum energy) flow with respect to the vector field norm $\\int_0^1 \\| \\hat v_t\\|^2_V dt$. To see this is first notice that the parameterization of time $t=1$ maps, $\\phi_1^v$, by vector fields $v\\in V^{[0,1]}$ is a many-to-one  parameterization.\n%In particular there are multiple paths or flows which agree at time $t=0$ and at $t=1$, but differ at all times between.\nIn other words there exist multiple pairs of vector fields $v,w\\in V^{[0,1]}$ such that $\\phi_1^v =\\phi^w_1$ but $v\\neq w$. Notice, however, that the log-likelihood term in $E_\\lambda$ only depends on   $\\phi_1^{\\hat v}$. This implies that any maximizer $\\hat v$ of $E_\\lambda$ must simultaneously minimize  the penalty $\\int_0^1 \\| \\hat v_t\\|^2_V dt$ over the class of all $w\\in V^{[0,1]}$ which has the same terminal value, i.e.\\! $\\phi^{\\hat v}_1=\\phi^w_1$.\n Consequently, the PMLE estimate $\\hat v$ must be a geodesic flow. An important consequence  is that  geodesic flows $\\{ \\hat v_t \\}_{t\\in [0,1]}$ are completely determined by the initial vector field $\\hat v_0$.  This will become particularly important in the next section where the initial velocity field will be completely parameterized by $n$ coefficient vectors.\n\n%\n%Notice  we are characterizing the map $\\phi_t^{ v}$,  at time $t=1$, by the of vector fields $v_t$ as  $t$ ranges throughout $[0,1]$.  This implies that   characterizing maps $\\phi_1^{ v}$ by elements $v\\in V^{[0,1]}$ is  many-to-one parameterization. In particular, there exist distinct elements $v,w\\in V^{[0,1]}$ with identical terminal maps, i.e.\\!   $\\phi_1^v=\\phi^w_1$. Since the log-likelihood term only depends on   $\\phi_1^{\\hat v}$,  the penalty $\\int_0^1 \\| \\hat v_t\\|^2_V dt$ must attain a minimum over the class of all vector fields which have the same terminal value  $\\phi_1^{\\hat v}$ . Consequently, the PMLE estimate $\\hat v$ must be a geodesic flow. An important consequence  is that  geodesic flows $\\{ \\hat v_t \\}_{t\\in [0,1]}$ are completely determined by the initial vector field $\\hat v_0$.  This will become particularly important in the next section where the initial velocity field will be completely parameterized by $n$ coefficient vectors.\n%\n%\n%%%%%%%%%%%%%%%%%%\n%\n%%%%%%%%%%%%\n\\section{Spline representation from Euler-Lagrange}\n\\label{EL}\n\nIn this section we work under the additional assumption that $V$ is a reproducing kernel Hilbert space. This assumption allows one to derive the Euler-Lagrange equation for any maximizer $\\hat v$ of which satisfies (\\ref{exist}). This leads to a finite dimensional characterization of  $\\hat v$  which  parallel those results found in the spline literature for function estimation.\n\n\n%%%%%%%%%\n%begin claim\n%%%%%%%%%%%\n\\begin{claim}\n\\label{claim2}\nLet $V$ be a  reproducing kernel Hilbert space, with  kernel $R(x,y)I_{d\\times d}$, continuously  embedded in $C_0^3(\\Omega, \\Bbb R^d)$  where $\\Omega$ is bounded open subset of $\\Bbb R^d$. Suppose $e^{H(\\cdot)}$ is a $C^1(\\bar \\Omega,\\Bbb R)$ density  on $\\Omega$. Then any time varying vector field $\\hat v \\in V^{[0,1]}$ which satisfies (\\ref{exist}) also satisfies the following\n Euler-Lagrange equation:\n \\begin{align}\n \\label{ELeq}\n \\hat v_t(x)&=  \\frac{1}{\\lambda n}\\sum_{k=1}^n \\beta^T_{k,t} R(x,X_{k,t})  +  \\frac{1}{\\lambda n}\\sum_{k=1}^n   \\nabla_{y}^T R(x,y)\\Bigr|_{y= X_{k,t}}\n\\end{align}\nwhere $X_{k,t}\\equiv \\phi_t^{\\hat v} (X_k)$,\n$ \\beta_{k,t}\\equiv   \\nabla H(X_{k,1}) D\\phi^{\\hat v}_{t1}(X_{k,t})  +\\nabla \\log\\det D\\phi^{\\hat v}_{t1} (X_{k,t})$ and $\\nabla_y^T = (\\partial_{y_1},\\ldots, \\partial_{y_d})^T$  is the transpose of the gradient operator applied to the $y$ variable.\n\\end{claim}\n%%%%%%%%%%\n% begin proof\n%%%%%%%%%%%%\n\\begin{proof}\nLet $E_1, E_2$ and $E_3$ decompose $E_\\lambda$ as in (\\ref{decomp}). Notice first that if  $h\\in V^{[0,1]}$  and $\\epsilon \\in \\Bbb R$ then $2 E_3(\\hat v+\\epsilon h) = {\\lambda}\\| \\hat v \\|^2_{V^{[0,1]}} + \\epsilon 2 \\lambda\\langle v,h \\rangle_{V^{[0,1]}}  +\\epsilon^2{\\lambda}\\| h \\|^2_{V^{[0,1]}} $. Therefore $E_3(\\hat v+\\epsilon h)$ is differentiable with respect to $\\epsilon$ with derivative given by\n\\begin{equation}\n \\label{dderE1}\n{\\partial_\\epsilon}  E_3(\\hat v+\\epsilon h)\\bigr|_{\\epsilon=0}\n=  \\int_0^1 \\langle h_t,\\lambda \\hat v_t \\rangle_V dt.\n\\end{equation}\n%Proposition \\ref{proo} (in the Appendix)\nIn addition, Theorem 8.10 of \\cite{you:10}\n implies that  $\\phi^{\\hat v+\\epsilon h}_1(x)$  is differentiable at $\\epsilon = 0$. % with derivative given by  (\\ref{111}) in the Appendix.\n %with derivative given by\n%\\begin{align}\n%{\\partial_\\epsilon}  \\phi^{\\hat v+\\epsilon h}_{1}(x)\\bigr|_{\\epsilon =0}  &= \\int_0^1  \\bigl\\{D\\phi^{ \\hat v}_{u1} h_u \\bigr\\}\\circ{\\phi^{ \\hat v}_{u}(x)}\\,   du. \\label{zzz}\n% \\end{align}\nNow, the assumption  $H\\in C^1(\\bar\\Omega)$ combined with equation (\\ref{111}), in the Appendix, gives % that  $E_2(\\hat v+\\epsilon h)$ is differentiable at $\\epsilon = 0$ and\n\\begin{align}\n\\partial_\\epsilon E_2(\\hat v+\\epsilon h)\\bigr|_{\\epsilon=0} \\nonumber\n%&= -\\frac{1}{n}\\sum_{k=1}^n \\partial_\\epsilon H(\\phi_1^{\\hat v+\\epsilon h}(X_k)) \\bigr|_{\\epsilon=0}  \\nonumber\\\\\n&= -\\frac{1}{n}\\sum_{k=1}^n  \\nabla H(\\phi_1^{\\hat v }(X_k)) \\cdot {\\partial_\\epsilon}  \\phi^{\\hat v+\\epsilon h}_{1}(X_k)\\bigr|_{\\epsilon = 0} \\nonumber \\\\\n&= -\\frac{1}{n}\\sum_{k=1}^n  \\nabla H(\\phi_1^{\\hat v }(X_k)) \\cdot \\int_0^1  \\bigl\\{D\\phi^{ \\hat v}_{u1} h_u \\bigr\\}\\circ{\\phi^{ \\hat v}_{u}(X_k)}\\,   du \\nonumber \\\\\n%&= -\\frac{1}{n}\\sum_{k=1}^n \\int_0^1   \\nabla H( X_{k,1}) \\cdot  \\bigl\\{D\\phi^{ \\hat v}_{u1} (X_{k,u}) h_u (X_{k,u})\\bigr\\}\\,   du \\nonumber \\\\\n&= -\\frac{1}{n}\\sum_{k=1}^n \\int_0^1  \\bigl\\{  \\nabla H( X_{k,1}) D\\phi^{\\hat v}_{u1}(X_{k,u}) \\bigr\\} \\cdot  h_u (X_{k,u})\\,   du \\nonumber \\\\\n%&= -\\frac{1}{n}\\sum_{k=1}^n \\int_0^1\\bigl\\langle \\nabla H(q_{k,1}),  \\bigl\\{D\\phi^v_{t,1}h_t \\bigr\\}(q_{k,t}) \\bigr\\rangle_d \\,dt, \\quad\\text{by Lemma \\ref{variationofphi}}\\\\\n%&= -\\frac{1}{n}\\sum_{k=1}^n \\int_0^1\\bigl\\langle  \\bigl[D\\phi^v_{t,1}(q_{k,t})\\bigr]^{T}\\nabla H(q_{k,1}),  h_t(q_{k,t}) \\bigr\\rangle_d \\,dt \\\\\n&=  \\int_0^1\\Bigl\\langle  h_u(\\cdot),  -\\frac{1}{n}\\sum_{k=1}^n \\bigl\\{ \\nabla H( X_{k,1}) D\\phi^{\\hat v}_{u1}(X_{k,u}) \\bigr\\}^T R(\\cdot,X_{k,u})\\Bigr\\rangle_V \\,du  \\label{derE2}\n\\end{align}\nFinally, Proposition \\ref{proo}, from the Appendix, implies $E_3(\\hat v+\\epsilon h )$ is differentiable at $\\epsilon = 0$ with derivative given by\n\\begin{align}\n\\partial_\\epsilon  E_1(\\hat v+\\epsilon h)\\bigr|_{\\epsilon=0} \\nonumber\n&  =- \\frac{1}{n} \\sum_{k=1}^n  \\partial_\\epsilon  \\log \\det D\\phi_{1}^{\\hat v+\\epsilon h }(X_k)\\bigr|_{\\epsilon = 0} \\nonumber\\\\\n&=- \\frac{1}{n} \\sum_{k=1}^n\n \\int_0^1  \\Bigl[ h_u \\cdot \\nabla \\log\\det D\\phi_{u1}^{\\hat v}  + \\text{\\rm div}\\, h_u\\Bigr] \\circ  \\phi^{\\hat v}_{u}(X_k)  \\, du \\nonumber\\\\\n% &=- \\frac{1}{n} \\sum_{k=1}^n    \\int_0^1 \\Bigl\\langle h_u(\\cdot), \\nabla \\log\\det D\\phi_{u1}^{\\hat v}(X_{k,u})  R(\\cdot,X_{k,u}) \\Bigr\\rangle_V+ \\langle h_u(\\cdot) ,\\nabla_{y} R(\\cdot,y)\\bigr|_{y=X_{k,u}}\\Bigr\\rangle_V \\,du  \\\\\n&= \\int_0^1 \\Bigl\\langle h_u(\\cdot), - \\frac{1}{n} \\sum_{k=1}^n \\left\\{ \\nabla \\log\\det D\\phi_{u1}^{\\hat v}(X_{k,u})\\right\\}^T  R(\\cdot,X_{k,u})+\\nabla_{y}^T R(\\cdot,y)\\bigr|_{y=X_{k,u}}\\Bigr\\rangle_V \\,du \\label{derE3}\n\\end{align}\n{\\em Remark:} the above equation requires $\\partial_{x_i } ( e_i\\cdot h_u(x))  = \\partial_{x_i}   \\langle e_i R(\\cdot, x),  h_u\\rangle_V=  \\langle e_i  \\partial_{x_i} R(\\cdot, x),  h_u\\rangle_V$ which follows since $\\text{div}\\, h_u \\in V$ by the assumption $V\\hookrightarrow C_0^2(\\Omega,\\Bbb R^d)$ (see \\cite{aro:50}).\nNow from (\\ref{dderE1}),  (\\ref{derE2}) and (\\ref{derE3}), the energy $ E_\\lambda(\\hat v+\\epsilon h)$ is differentiable with respect to $\\epsilon$ at $0$ and\n\\begin{equation}\n\\label{EEEl}\n0={\\partial_\\epsilon}  E_\\lambda(\\hat v+\\epsilon h)\\bigr|_{\\epsilon=0}= \\langle \\mathcal E ^{\\hat v},h \\rangle_{V^{[0,1]}}\n\\end{equation}\nwhere\n\\begin{equation}\n\\label{CalE}\n \\mathcal E ^{\\hat v}_t =\\lambda \\hat v_t   - \\frac{1}{n}\\sum_{k=1}^n \\beta^T_{k,t}  R(\\cdot,X_{k,t})  - \\frac{1}{n}\\sum_{k=1}^n \\nabla_{y}^T R(\\cdot,y)\\bigr|_{y=X_{k,t}}\n \\end{equation}\nwith $\\beta_{k,t}\\equiv  \\nabla H( X_{k,1}) D\\phi^{\\hat v}_{t1}(X_{k,t})  + \\nabla \\log\\det D\\phi_{t1}^{\\hat v}(X_{k,t}) $.\nSince $h\\in V^{[0,1]}$ was arbitrary, equation (\\ref{EEEl}) implies $\\mathcal E^{\\hat v}=0$, which then gives (\\ref{ELeq}). {\\em Remark:} we are using the fact that the zero function in a reproducing kernel space is point-wise zero since the evaluation functionals are bounded.\n\\end{proof}\n%%%%%%%%%%\n% end proof\n%%%%%%%%%%%%\n\n\n   There are a few things things to note here. First, the Euler-Lagrange equation  (\\ref{ELeq}) only implicitly characterizes $\\hat v$ since it appears on both sides of the equality ($\\beta_{k,t}$ and $X_{k,t}$ also  depend on $\\hat v$). Regardless,  (\\ref{ELeq}) is useful since it implies that $\\hat v$ must lie within a known $n\\times d$ dimensional sub-space of $V^{[0,1]}$. In particular, as discussed at the end of Section \\ref{pmle}, the estimate $\\{ \\hat v_t\\}_{t\\in [0,1]}$ is completely characterized by it's value at time $t=0$, i.e.\\! $\\hat v_0$ (by the geodesic nature of $\\hat v$). Restricting equation (\\ref{ELeq}) to  $t=0$ one obtains\n   \\begin{align}\n \\label{ELeq0}\n \\hat v_0(x)&=  \\frac{1}{\\lambda n}\\sum_{k=1}^n \\beta^T_{k,0} R(x,X_{k})  +  \\frac{1}{\\lambda n}\\sum_{k=1}^n   \\nabla_{y}^T R(x,y)\\Bigr|_{y= X_{k}}.\n\\end{align}\n  Simply stated, $\\hat v_0$ has a finite dimensional spline characterization with spline knots set at the observations $X_1,\\ldots, X_n$. Therefore to recover $\\{ \\hat v_t \\}_{t\\in[0,1]}$ one simply needs to find the $n$ row vectors $\\beta_{1,0},\\dots, \\beta_{n,0}$ which satisfy the following fixed point equation\n        \\begin{equation}\n \\label{InitialMom}\n  \\beta_{k,0}= \\nabla H(\\phi^{\\hat v}_1(X_k))  D\\phi^{\\hat v}_{1}(X_k)+ \\nabla \\log\\det D\\phi^{\\hat v}_{1} (X_k)\n  \\end{equation}\n for all $k=1,\\ldots,n$.\n\n\n\n%%%%%%\n% section\n%%%%%%%%%\n\\section{Connection to Stein's Method}\n\\label{steinSection}\n\nThe Euler-Lagrange equation given in (\\ref{ELeq}) has a surprising connection with a generalization of Stein's lemma for characterizing the normal distribution (see \\cite{stein:04}). The main connection is that the Euler Lagrange equation for the PMLE estimate $\\hat v_t$, simplified at initial time $t=0$ and terminal time $t=1$, can be reinterpreted as an empirical version of a generalization of Stein's lemma. This is interesting in it's own right, however, the connection may also bear theoretical fruit for deriving asymptotic estimation bounds on the nonparametric and semiparametric estimates derived from $\\hat v$. In this section we make this connection explicit  with the goal of of motivating and explaining the Euler-Lagrange equation for $\\hat v$ derived above.\n\nTo relate $\\hat v_t$ at $t=0$ with Stein's lemma, and more generally Stein's method for distributional approximation,  first notice that (\\ref{InitialMom}) implies the coefficients $\\beta_{k,0}$,  from the implicit equation  (\\ref{ELeq0}) for  $\\hat v$, satisfy\n$\\beta_{k,0}% &= \\bigl[D\\phi^{\\hat v}_{1}(X_k)\\bigr]^T \\nabla H(\\phi^{\\hat v}_1(X_k))^T+ \\nabla \\log\\det D\\phi^{\\hat v}_{1} (X_k) \\\\\n = \\nabla \\log \\hat f(X_k)\n$ where  $\\hat f= e^{ H\\circ \\phi^{\\hat v}_1}  |D\\phi_1^{\\hat v}| $ is the estimated density of $X$ using the pullback of the target measure with the estimated diffeomorphisms $\\phi^{\\hat v}_1$.\n Now by computing the inner product of  both sides of the Euler-Lagrange equation (\\ref{ELeq0}) with any vector field $u\\in V$ and applying the reproducing property of the kernel $R(\\cdot,\\cdot)$ one derives\n \\begin{align}\n\\lambda \\langle \\hat v_0, u\\rangle_V% &= \\frac{1}{n}\\sum_{k=1}^n\\bigl\\{ \\beta_{k,0} u(X_k) + \\text{div}\\, u(X_k)\\bigr\\}\\nonumber \\\\\n&=\\Bbb E_n\\bigl\\{ \\nabla \\log \\hat f(X)\\cdot  u(X) + \\text{div}\\, u(X)\\bigr\\}. \\label{stein2}\n%\\\\&\\approx E_{f}\\bigl\\{ \\nabla \\log \\hat f(X)\\cdot u(X) + \\text{div}\\, u(X)\\bigr\\}  \\label{stein2}\n\\end{align}\nwhere $\\Bbb E_n$ denotes  expectation with respect to the empirical measure generated by the data: $\\frac{1}{n}\\sum_{k=1}^n \\delta_{X_k}$.\nTo relate with Stein first let $\\Bbb E$ denote expectation with respect to the population density $f =    e^{ H\\circ \\phi} |D\\phi| $ given in our basic model (\\ref{model1}). Notice that a generalization of Stein's lemma shows that if the densities $f$ and $\\hat f$ give rise to the same probability measure then\n\\begin{equation}\n\\label{ste}\n0= \\Bbb E\\bigl\\{ \\nabla \\log \\hat f(X) \\cdot u(X) + \\text{div}\\, u(X)\\bigr\\}\n \\end{equation}\nfor all $u$ in a large class of test functions $\\mathcal U$ (see Proposition 4 in \\cite{stein:04}).\nFor example, a simple consequence of Lemma 2 in \\cite{stein:81} implies that when $\\hat f$ is the density of a  $d$ dimensional Gaussian  distribution $\\mathcal N_d(\\hat\\mu,1)$  and $X\\sim \\mathcal N_d(\\mu,1)$ then $\\hat\\mu = \\mu$ implies $ \\Bbb E\\bigl\\{ -  (X-\\hat\\mu) \\cdot u(X) + \\text{div}\\, u(X) \\bigr\\} =0$\nfor any bounded function $u:\\Bbb R^d \\rightarrow \\Bbb R^d$ with bounded gradient. Stein's method, on the other hand, generally refers to  a technique for  bounding the distance between two probability measures $f$ and $\\hat f$ using bounds on departures from a characterizing equation, such as  (\\ref{ste}) for example (see \\cite{chen:05} for an exposition). The bounds typically take the form\n\\begin{align} \\sup_{h\\in \\mathcal H} \\left| \\int ( h f - h \\hat f ) \\right| &\\leq \\sup_{u\\in \\mathcal U} \\bigl| \\Bbb E\\bigl\\{ \\nabla \\log \\hat f(X)\\cdot u(X) + \\text{div}\\, u(X)\\bigr\\} \\bigr| \\label{ssmethod}\n \\end{align}\nwhere $\\mathcal H$ and $\\mathcal U$ are two class of functions related through a set of differential equations.\n %Setting up this equation shows how deviations from (\\ref{ste}) controls the distance distance of $f$ from $\\hat f$ (measured by the left hand side of (\\ref{ssmethod})).\n  In our case, applying a H\\\"older's inequality to the Euler-Lagrange equation (\\ref{stein2}) gives a bound on  right hand side of (\\ref{ssmethod}) in terms of a regularization measurement on the PMLE $\\hat v$ and an empirical process error:\n    \\begin{align}\n    \\label{reg1}\n     \\sup_{u\\in \\mathcal U} \\bigl| \\Bbb E\\bigl\\{ \\nabla \\log \\hat f(X) \\cdot u(X) + \\text{div}\\, u(X)\\bigr\\} \\bigr|   &\\leq \\underbrace{ \\lambda \\| \\hat v_0\\|_V   \\sup_{u\\in \\mathcal U} \\|  u \\|_V}_\\text{regularization at $t=0$} + \\underbrace{\\sup_{u\\in \\mathcal U} \\bigl| (\\Bbb E -\\Bbb E_n) \\nu_{\\hat f,u}\\bigr|}_\\text{ empirical process error}\n \\end{align}\n where $\\nu_{\\hat f,u} = \\nabla \\log \\hat f(X) u(X) + \\text{div}\\, u(X)$.\n This makes it clear that  theoretical control of the PMLE estimate $\\hat v_t$ at time $t=0$, using the Euler-Lagrange equation characterization (\\ref{ELeq0}), allows asymptotic control of the distance between the estimated density $\\hat f$ and the true density $f$.\n\n At terminal time $t=1$, there is a similar connection with Stein's lemma. In contrast to time $t=0$, which quantifies the distance between the estimated  and population densities $\\hat f$ and $f$,  time $t=1$ quantifies the distance between $\\phi(X)$ (the target measure) with $\\phi_1^{\\hat v}(X)$ (the push forward of the true population distribution though the estimated map).  To make the connection, one follows  the same line of argument as above to  find that  for any $u\\in V$\n\\begin{align}\n\\lambda \\langle \\hat v_1, u\\rangle_V &=  {\\Bbb E}^{\\hat v}_n\\bigl\\{ \\nabla H(X)\\cdot u(X ) + \\text{div}\\, u(X)\\bigr\\} \\label{stein}\n\\end{align}\nwhere ${\\Bbb E}^{\\hat v}_n$ denotes  expectation with respect to the empirical measure $\\frac{1}{n}\\sum_{i=1}^n \\delta_{\\phi^{\\hat v}_1(X_k)}$, which is simply the push forward of the empirical measure $\\frac{1}{n}\\sum_{i=1}^n \\delta_{X_k}$ through the estimated map $\\phi^{\\hat v}_1$.\nNow the analog to (\\ref{reg1})  becomes\n   \\begin{align}\n   \\label{reg2}\n    \\sup_{u\\in \\mathcal U} \\bigl| {\\Bbb E^{\\hat v}}\\bigl\\{ \\nabla H(X)\\cdot  u(X) + \\text{div}\\, u(X)\\bigr\\} \\bigr|   &\\leq \\underbrace{ \\lambda \\| \\hat v_1\\|_V  \\sup_{u\\in \\mathcal U} \\|  u \\|_V }_\\text{regularization at $t=1$} +\\, {\\sup_{u\\in \\mathcal U} \\bigl| (\\Bbb E^{\\hat v} -\\Bbb E_n^{\\hat v}) \\gamma_{u}\\bigr|}\n \\end{align}\n where $\\gamma_{u} = \\nabla H(X) u(X) + \\text{div}\\, u(X)$ and $\\Bbb E^{\\hat v}$ denotes expectation with respect to the push forward of the population density $f =    e^{ H\\circ \\phi} |D\\phi| $ though the estimated map $\\phi_1^{\\hat v}$.\nSince the target measure $\\Bbb P$ is assumed to have density $e^H$, this bounds the distributional distance between $\\phi^{\\hat v}_1(X)$ and $\\Bbb P$ when $X\\sim \\Bbb P\\circ \\phi$.\n\n\n%The hithro discussions is to view the Euler-Lagrange equation in more heuristic meantful way. However, it also no only a potentially new method for deriving asymptotics but ...\n%also a possible new view of maximum likelihood esitmation, the score esentiialy giving a Stein's equation.\n\n%%%%%%%%%%%%%%%%%\n% section\n%%%%%%%%%\n\\section{Nonparametric example}\n\\label{npe}\n%Talk about how the complete form of the maximum is difficult to numerically construct with current algorithms since the geodesics need to fix the endpoint and also the sheer around the endpoints. Therefore we simplify the form of the maximum, effectvely creating a basis set (similar to B-splines). However, a novel featuer of our fixed point equation is that we can tell when we have enough knots.\n\nIn this section we utilize the finite dimensional characterization of the PMLE $\\hat v$ at time $t=0$, given in (\\ref{ELeq0}), to construct nonparametric density estimates of the form $\\hat f= e^{ H\\circ \\phi^{\\hat v}_1}  |D\\phi_1^{\\hat v}| $ from {\\em iid} samples $X_1,\\ldots, X_n$.\n%  {\\em iid} samples $X_1,\\ldots, X_n$ from some population density $f$.\n%under the model $f =    e^{ H\\circ \\phi} |D\\phi| $ given in  (\\ref{model1}).\nAs was discussed in the introduction, so long as the target measure $\\Bbb P$ is absolutely continuous, the assumption that   $X_1,\\ldots, X_n \\overset{iid}\\sim \\Bbb  P\\circ \\phi$ encompasses all absolutely continuous measures. Since the class of diffeomorphisms $\\{\\phi_1^v\\colon v\\in V^{[0,1]}\\}$ is nonparametric, the estimate $\\hat f= e^{ H\\circ \\phi^{\\hat v}_1}  |D\\phi_1^{\\hat v}| $ is inherently nonparametric regardless of the choice of target probability measure $\\Bbb P$ (with density $e^H$). In effect, the choice of target $\\Bbb P$ specifies a shrinkage direction for the nonparametric estimate: larger values of $\\lambda$ shrink $\\hat f$ further toward the target $\\Bbb P$.\nIn this section we illustrate the nonparametric nature of the density estimate $\\hat f$, whereas the next section explores semiparametric estimation with parametric models on the target $\\Bbb P$.     One  key feature of our methodology is the use of the Euler-Lagrange equation (\\ref{ELeq}) as a stopping criterion for a gradient based optimization algorithm for constructing $\\hat v$. In fact, to avoid computational challenges associated with generating geodesics  with initial velocities given by (\\ref{ELeq0}), we consider a finite dimensional subclass of $V^{[0,1]}$ which have geodesics that are amenable to computation (and for which gradients are easy to compute). The key is that we use the Euler-Lagrange identity (\\ref{ELeq}) to measure the richness of the subclass, within the larger infinite dimensional Hilbert space $V^{[0,1]}$, whereby allowing a dynamic choice  of the approximating dimension for a target resolution level.\n\n\nClaim~\\ref{claim2} shows that the PMLE vector field $\\hat{v}\\in V^{[0,1]}$ obeys a parametric form determined up to the identification of the $n$ functions $t\\mapsto \\beta_{k,t}$ as $t$ ranges in $[0,1]$. Moreover, the whole path of coefficients $\\beta_{k,t}$ is determined from the initial values $\\beta_{k,0}$, by the geodesic nature of $\\hat v$.\nIn this way, we are free to optimize, over the vectors $\\{\\beta_{1,0}, \\ldots, \\beta_{n,0}\\}\\subset \\Bbb R^d$ using equation (\\ref{ELeq0})\n%when the velocity fields of the form $\\frac{1}{\\lambda n}\\sum_{k=1}^n \\beta_{k,0}^T R(x,X_{k})  +  \\frac{1}{\\lambda n}\\sum_{k=1}^n   \\nabla_{y} R(x,y)\\bigr|_{y= X_{k}}$\n and are guaranteed that the global maximum, over the full infinite dimensional space $\\{ \\phi_1^v\\colon v\\in V^{[0,1]}\\}$, has this form.  Unfortunately, deriving geodesic maps with this type of initial velocity field is challenging.\n%In what follows we consider a subclass of initial vector fields which allow easy numerics, then use the Euler-Lagrane equation to determine if the subclass if sufficiently rich within the larger infinite dimensional space.\nTo circumvent this difficulty we choose an approximating  subclass of vector fields at time $t=0$ which are parametrized by the selection of $N$ knots $\\{\\kappa_{1},\\ldots, \\kappa_N\\} \\subset \\Omega$ and $N$ initial momentum row vectors $\\{\\eta_{1},\\ldots, \\eta_N\\} \\subset  \\mathbb{R}^d$ and have the form:\n\\begin{equation}\n\\label{knots}\n v_0(x)= \\sum_{k=1}^N \\eta^T_{k} R(x,\\kappa_{k}).\n \\end{equation}\nThe knots $\\{ \\kappa_1,\\ldots, \\kappa_N\\}$ need not be located at the data points $\\{X_1,\\ldots, X_n \\}$. Indeed, we will see that alternative configurations of knots can be numerically beneficial. The key point is that vector fields at time $t=0$, which satisfy (\\ref{knots}), generate geodesics with respect to norm $\\bigl[\\int_0^1 \\| v^t  \\|^2_V dt \\bigr]^{1/2}$ that are easy to compute. Moreover, the variational derivatives of the terminal map $\\phi^v_1$ with respect to the initial $\\eta$ coefficients and the knots $\\kappa$ are easily computed when utilizing  similar techniques  as those developed in \\cite{vaillant:04} and \\cite{alla:07}. This enables efficient gradient based algorithms for optimizing the PMLE criterion over the class generated by (\\ref{knots}).\n\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[height = 2.2in]{pics/fig01/density_justn}\n\\includegraphics[height = 2.2in]{pics/fig01/agreement_justn}\\\\\n\\includegraphics[height = 2.2in]{pics/fig01/density_n_pm_h}\n\\includegraphics[height = 2.2in]{pics/fig01/agreement_n_pm_h}\\\\\n\\caption{In this example we compare two different knot configurations, in (\\ref{knots}), for generating nonparametric density estimates using approximate solutions to the  Euler-Lagrange equation (\\ref{ELeq}). The left column of images shows two different density estimates (red), based on the same data set (blue), using two different knot configurations (top-left uses $10$ knots, bottom-left uses $30$ knots). The right column of images show the corresponding  diagnostic curves which characterize the richness of the approximating subclass generated by the knots. The fact that the two diagnostic curves shown bottom-right are similar suggests that the $30$ knots used generate the approximating subclass by (\\ref{knots}) is sufficiently rich to reach the stationary points of the penalized log likelihood $E_\\lambda$ given in (\\ref{energy1}).\nSee Section \\ref{npe} for details.\n \\label{f2}\n }\n\\end{figure}\n\n\n\nAs a first illustration, we show that the na\\\"ive choice of initial knots obtained by setting $\\{\\kappa_1,\\ldots, \\kappa_N\\}=\\{ X_1,\\ldots,X_n\\}$ in (\\ref{knots})  is {\\em not} sufficient to solve  (\\ref{ELeq}); then show how it can be easily fixed using the Euler-Lagrange methodology.\n Our data set, shown with blue sticks in Figure~\\ref{f2}, consists of $n=10$ independent samples from a mixture of two normals, truncated so the support is $[0,1]$.  Our target probability measure $\\Bbb P$ is set to the uniform distribution on  $[0,1]$ (smoothly tapering to zero $0$ outside of $[0,1]$ for numerical convenience).\n%At this sample size, we do not expect an accurate estimate of the sampling density, of course, but we can use this case to illustrate that by suitable selection of knots we can approximate the PMLE.\n  For simplicity we choose the Gaussian kernel $R(x,y)=\\exp\\bigl(-\\frac{(x-y)^2}{2\\sigma^2}\\bigr)$, with $\\sigma=0.1$, to generate the RKHS $V$ and use the  penalty parameter $\\lambda$ set to $10$. The top left plot in Figure~\\ref{f2} shows the non-parametric density estimate $\\hat f= e^{ H\\circ \\phi^{\\hat v}_1}  |D\\phi_1^{\\hat v}| $ in red, generated by applying a gradient based optimization algorithm applied to the subclass (\\ref{knots}) where the knots $\\{\\kappa_1,\\ldots, \\kappa_N\\}=\\{X_1,\\ldots, X_n\\}$ are kept fixed and the coefficients $\\eta_1,\\ldots, \\eta_N$ are optimized by minimizing the penalized log likelihood function $E_\\lambda (v)$ given in (\\ref{energy1}).\n To diagnose the richness of subclass (\\ref{knots}) within the full Hilbert space we define the function $\\mathcal D_t^v(x)$ for any $v\\in V^{[0,1]}$ and any $t\\in [0,1]$ as follows\n \\begin{equation}\n \\label{diag1}\n \\mathcal D_t^v(x) \\equiv    \\frac{1}{ n}\\sum_{k=1}^n \\bigl[\\beta_{k,t}^v\\bigr]^T R(x, X_{k,t}^v )  +  \\frac{1}{ n}\\sum_{k=1}^n   \\nabla_{y}^T R(x,y)\\Bigr|_{y= X_{k,t}^v}\n \\end{equation}\nwhere $X_{k,t}^v\\equiv \\phi_t^{v} (X_k)$ and\n$ \\beta_{k,t}^v\\equiv   \\nabla H(X^v_{k,1}) D\\phi^{v}_{t1}(X_{k,t}^v)  +\\nabla \\log\\det D\\phi^{ v}_{t1} (X^v_{k,t})$.\nThe function $\\lambda v_t - \\mathcal D_t^v$ serves as a diagnostic criterion in the sense that\n  the Hilbert norm of $\\lambda v_t - \\mathcal D_t^v$ gives  the maximal rate of change of the penalized log-likelihood $E_\\lambda(v)$, within the full infinite dimensional Hilbert space $V^{[0,1]}$. In particular,\n \\[   \\biggl[\\int_0^1\\|\\underbrace{ \\lambda v_t-\\mathcal D_t^v}_\\text{\\scriptsize diagnostic } \\|_{V}^2dt\\biggr]^{1/2} = \\sup_\\text{\\small $\\{ u\\colon \\| u \\|_{V^{[0,1]}}= 1 \\}$} \\left[\\frac{d}{d\\epsilon} E_\\lambda (v+\\epsilon u)\\right]_{\\epsilon = 0} .   \\]\n Therefore if   $\\lambda v_t(x)-\\mathcal D_t^v(x) = 0$ for all $t\\in [0,1]$ and $x\\in \\Bbb R^d$, then $v$ satisfies the Euler-Lagrange equation. Discrepancies between $\\lambda v_t(x)$ and $\\mathcal D_t^v$ when optimizing over the subclass (\\ref{knots}) indicates the subclass that is insufficient rich to reach the stationary points of $E_\\lambda(v)$.\n The diagnostic plots in this example, which correspond to our density estimate shown in the upper-left image of Figure~\\ref{f2},  are shown in the upper-right plot of Figure~\\ref{f2} where $\\lambda v_0(x)$ is plotted in  black and $\\mathcal D_0^v(x)$ is plotted as a dashed green line. The large amount of discrepancy between $\\lambda v_0(x)$  and $\\mathcal D_0^v(x)$ indicates that the knots $\\{\\kappa_1,\\ldots, \\kappa_N\\}=\\{ X_1,\\ldots,X_n\\}$  are insufficient.\n\n\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[height = 2.2in]{pics/fig02/density_justn}\n\\includegraphics[height = 2.2in]{pics/fig02/agreement0_justn}\\\\\n\\includegraphics[height = 2.2in]{pics/fig02/density_subsample}\n\\includegraphics[height = 2.2in]{pics/fig02/agreement0_subsample}\n\\caption{\n \\label{f3}\n In this example we demonstrate that a small number of knots, in (\\ref{knots}), can be enough to approximate solutions to the  Euler-Lagrange equation (\\ref{ELeq}). The left column of images shows two different density estimates (red), based on the same data set  of size $n=240$ (grey histogram), using two different knot configurations (top-left uses $240$ knots, bottom-left uses $20$ knots). The right column of images show the corresponding  diagnostic curves which characterize the richness of the approximating subclass generated by the knots. The fact that the two diagnostic curves shown bottom-right are nearly identical suggests that the $20$ knots  used generate the approximating subclass by (\\ref{knots}) is sufficiently rich to reach the stationary points of the penalized log-likelihood $E_\\lambda$ given in (\\ref{energy1}).\nSee Section \\ref{npe} for details.\n }\n \\end{figure}\n\n\n\n\nTo generate  knots which are sufficiently rich, in this first example,  we apply a discrete approximation at initial time $t=0$ to the gradient term $ \\nabla_{y}^T R(x,y) $ appearing in  the Euler-Lagrange equation (\\ref{ELeq}).\n For this approximation we use $N=3n$ knots in the pattern given by the following approximation\n\\begin{align}\n \\hat v_0(x)&=  \\frac{1}{\\lambda n}\\sum_{k=1}^n \\beta^T_{k,0} R(x,X_{k})  +  \\frac{1}{\\lambda n}\\sum_{k=1}^n   \\nabla^T_{y} R(x,y)\\Bigr|_{y= X_{k}} \\\\\n & \\approx \\frac{1}{\\lambda n}\\sum_{k=1}^n \\beta^T_{k,0} R(x,\\kappa_{k})  +  \\frac{1}{\\delta \\lambda n}\\sum_{k=1}^n   R(x,\\kappa_{n+k})-R(x,\\kappa_{2n+k}) \\\\\n & = \\sum_{k=1}^N \\eta^T_{k} R(x,\\kappa_{k}) \\label{eq:etakappa}\n\\end{align}\nwhere\n$\\kappa_{k}\\equiv\\begin{cases}\nX_{k} & \\text{if $k \\in 1 \\dots n$} \\\\\nX_{k}+\\frac{\\delta}{2} & \\text{if $k \\in n+1 \\dots 2n$} \\\\\nX_{k}-\\frac{\\delta}{2} & \\text{if $k \\in 2n+1\\dots 3n$}\n\\end{cases}$ and $\\eta_{k}\\equiv\\begin{cases}\n\\frac{1}{\\lambda n} \\beta_{k,0} & \\text{if $k \\in 1 \\dots n$} \\\\\n\\frac{1}{\\delta \\lambda n} & \\text{if $k \\in n+1 \\dots 2n$} \\\\\n-\\frac{1}{\\delta \\lambda n} & \\text{if $k \\in 2n+1 \\dots 3n$} \\\\\n\\end{cases}$\nwith $\\delta=10^{-4}$.\n%Illustrate the method by showing that the diagnostic curves can tell you when you have enough knots and talk about .\n With this new set of knots, the resulting PMLE over the new class is show at bottom left in Figure~\\ref{f2}. Notice that now the diagnostic function $\\lambda v_0 -\\mathcal D_0^v$ (the difference between the black and green line in the bottom-right plot of Figure~\\ref{f2}) is much closer to zero. Indeed, for every $t\\in [0,1]$ the diagnostic function $\\lambda v_t -\\mathcal D_t^v$ is similarly close to zero (not pictured). This implies that the maximal rate of change  of the penalized log-likelihood within the infinite dimensional Hilbert space $V^{[0,1]}$, at our estimate, is very small and hence our knots are sufficiently rich.\n\n\n\n\nIn the previous example we used $N=3n$ knots in (\\ref{knots}) to construct a sufficiently rich class for solving the Euler-Lagrange equation (\\ref{ELeq}). Now we demonstrate that with larger data sets and smaller smoothness penalties one can actually use a smaller set of knots, $N\\ll n$, to approximate the solutions to Euler-Lagrange equation (\\ref{ELeq}). The histograms in the left column of Figure~\\ref{f3} show $n=240$ {\\em iid}  samples from the same truncated mixture of normals used in the previous example. The resulting density estimates, shown in red,  use a smoothness penalty set to $\\lambda=1/4$. The estimate shown top-left  utilizes  $N=n=240$ knots set at the data points whereas the estimate shown bottom-left  uses $N=20$ knots randomly selected from the data.  The right column\nshows the corresponding diagnostic plots ($\\lambda v_0$ shown in black  and $\\mathcal D_0^v$ shown in green). The relative agreement of the diagnostic curves in the bottom-right plot suggests that 20 knots are reasonably adequate for finding approximate solutions to the Euler-Lagrange equation. We expect this situation to improve as the number of data points increase. This has the potential to dramatically decrease the computational load when applying this estimate to extremely large data sets.\n\n\n\n\n\n\n%%%%%%%%%%\n% section\n%%%%%%%%%%%%%%%\n\\section{Semiparametric example}\n\\label{spe}\n\nIn this section we demonstrate how the PMLE $\\phi_1^{\\hat v}$ can be used to generate semiparametric estimation procedures obtained by assuming a parametric model on the target distribution $\\Bbb P$ then introduce a nonparametric diffeomorphism to the target model.\nIndeed, any parametric model $\\{\\Bbb P_\\theta\\colon \\theta\\in \\Theta\\subset \\Bbb R^m\\}$ can  be extended to a   semiparametric class by considering diffeomorphisms of the data to the parametric target as follows: $\\{\\Bbb P_\\theta \\circ \\phi^{v}_1 \\colon \\theta\\in \\Theta, v\\in V^{[0,1]}\\}$.\nSince the  model $X_1,\\ldots, X_n\\overset{iid}\\sim \\Bbb P_\\theta\\circ \\phi^v_1$ implies $\\phi^v_1(X_1),\\ldots, \\phi_1^v(X_n)\\overset{iid}\\sim \\Bbb P_\\theta$ it is natural to alternate the optimization of $\\theta$ and $\\phi$ to compute the estimates $\\hat \\theta$ and $\\hat \\phi$ under this semiparametric model. This optimization routine is outlined explicitly in Algorithm \\ref{alg2}.\n\n\\begin{algorithm}[h!]\n\\caption{Compute the semiparametric estimates $\\hat\\theta, \\hat \\phi$}\n\\label{alg2}\n\\begin{algorithmic}[1]\n\\STATE {{Set} $i=0$ and {initialize} $(\\theta^0,\\phi^0)$.}\n\\STATE { {Set}  $\\phi^{i+1}$ to the PMLE of $\\phi$ defined in Section \\ref{pmle} under the model $X_1, \\ldots, X_n \\overset{iid}\\sim \\Bbb P_{\\theta^i}\\circ \\phi$}.\n\\STATE {{Set} $\\theta^{i+1}$ to the maximum likelihood estimate  of $\\theta\\in \\Theta$ under the following model for the transformed data points:\n\\[ \\phi^{i+1}(X_1), \\ldots, \\phi^{i+1}(X_n) \\overset{iid}\\sim \\Bbb P_{\\theta}\\]}\n\\STATE {{If} $\\theta^i\\approx \\theta^{i+1}$ and $\\phi^i\\approx \\phi^{i+1}$ {then return} $(\\hat\\theta, \\hat\\phi)\\leftarrow(\\theta^{i+1},\\phi^{i+1})$; {else\nset} $i\\leftarrow i+1$ and {return} to \\mbox{step {\\footnotesize 2}.}}\n\\end{algorithmic}\n\\end{algorithm}\n\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[height = 2.2in]{pics/fig04/normal_target_density}\n\\includegraphics[height = 2.2in]{pics/fig04/normal_target_agreement0}\\\\\n\\includegraphics[height = 2.2in]{pics/fig04/mixture_target_density}\n\\includegraphics[height = 2.2in]{pics/fig04/mixture_target_agreement0}\n\\caption{\nIn this example we demonstrate that by parametrically modeling the target distribution one can  produce flexible semiparametric density estimates.\nThe left column of histograms show the data (the same histogram plotted twice) sampled from the population density shown in black. Two semiparametric estimates are shown in red which correspond to different parametric targets. The estimated target distribution is shown in green on the left column of images. The right column of images show the corresponding  diagnostic curves which characterize the richness of the approximating subclass generated by the knots ($\\lambda v_0$ is plotted in  black and $\\mathcal D_0^v$ is plotted in dashed-green).  See Section \\ref{spe} for details.\n \\label{f4} }\n \\end{figure}\n\n\nTo illustrate the semiparametric nature of our estimate we sample from a population density which is a mixture of a $\\chi^2$ density (with $20$ degrees of freedom) and a Gaussian density ($\\mu = 55$ and $\\sigma = 3$) shown in black on the left column of plots in Figure \\ref{f4}. The data  comprises $n=200$ independent samples from this mixture, the histogram of which is shown on the left column of plots in Figure \\ref{f4}.\n We consider two different semiparametric estimates of the population density. The first uses a basic  location-scale Gaussian family to the parametric target model\n $\\{ \\Bbb P_\\theta \\colon \\theta \\in\\Theta \\} \\equiv \\{ \\Bbb G_{\\mu,\\sigma} \\colon   \\mu \\in \\Bbb R,  \\sigma \\in \\Bbb R^+ \\}$ where $\\Bbb G_{\\mu,\\sigma}$ denotes the Gaussian measure centered at $\\mu$ with variance $\\sigma^2$.\n The second example uses a\n mixture of two Gaussian measures $\\{ \\Bbb P_\\theta \\colon \\theta \\in\\Theta \\} \\equiv \\{ \\alpha\\,\\Bbb G_{\\mu_1,\\sigma_1} +(1-\\alpha)\\,\\Bbb G_{\\mu_2,\\sigma_2} \\colon  \\mu_1, \\mu_2 \\in \\Bbb R,  \\sigma_1,\\sigma_2 \\in \\Bbb R^+,   0< \\alpha < 1 \\}$.\nAs in Section \\ref{npe} we use a Gaussian reproducing kernel to generate the Hilbert space $V$. In this example, however, we use a wider kernel, with standard deviation set to half the sample standard deviation of the data.  This is done to illustrate the flexibility in the estimated density obtained by simply changing the kernel width and the penalty parameter $\\lambda$ (which is decreased to $1/2500$ in this example).\nWider kernels tend to produce estimates which have restricted local variability but can still have sufficient flexibility to model large amplitude variations over large spatial scales.\n\nThe estimate obtained from the basic location-scale Gaussian family is shown in red in the top-left plot of Figure \\ref{f4}. Conversely, the estimated density which uses the mixture target model is shown in red in the bottom-left plot of Figure \\ref{f4}.   The corresponding estimated target density $d\\Bbb P_{\\hat \\theta}/dx$ is shown in green on the left two plots.\nTo numerically approximate the PMLE initial velocity field $\\hat v_0$, needed in step 2 of Algorithm \\ref{alg2},  we used the approximating subclass for the initial velocity field given in the form (\\ref{knots}) with $200$ knots located at the data values.\nThe corresponding time zero diagnostic plots are shown in the right column of Figure \\ref{f4} (green for $\\lambda v_0$ and black for $\\mathcal D_0^v$).\n Notice that in both cases the semiparametric estimates do a good job at estimating the population density.\nIn the case of the location-scale Gaussian target the estimated target density does a poor job of explaining the true density. However, the presence of a nonparametric diffeomorphism allows this model to fit nearly as well as a fit from a mixture model. Notice also that the semiparametric estimate based on the location-scale Gaussian target overestimates the true sampling density between the two modes. This seems due to the fact that the estimation procedure prefers an overly dispersed target density which  allows the estimated diffeomorphism to effectively add  mass around the smaller mode. The situation seem to be corrected when using a mixture.\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%\n\\section{Discussion}\n\n%The use of smooth invertible transformations or diffeomorphisms are fast becoming important tools in modern data analysis. For example, time varying vector field flows which generate a class of diffeomorphisms  are being used with spectacular success in the computational anatomy literature  (see \\cite{you:10} and the references therein). In the field of spatial statistics, on the other hand, diffeomorphisms are used to model nonstationary  random fields with a locally varying geometric anisotropy \\cite{Sampson:1992fk}. %In the field of cosmology, diffeomorphisms model the lensing distortion of background images from the gravitational effect of dark matter (see \\cite{Dod} for example).\n% In this paper, we use diffeomorphisms to recast the problem of density estimation to that of  diffeomorphism estimation, extending an idea  from \\cite{and:11}  to general dimension $\\Bbb R^d$.  The basic structure of our methodology is to fix a target probability measure then estimate a diffeomorphism which pushes forward the sampling distribution to the target measure. The resulting PMLE density estimate can generate nonparametric and semiparametric density estimates while  also incorporating  shape information for the unknown sampling distribution.\nIn this paper,  we adapt the powerful tools developed by Grenander, Miller,  Younes, Trouv\\'e and co-authors in the image processing and computational anatomy literature   (see \\cite{you:10} and the references therein) to generate a PMLE of a deformation to a target measure with all the required properties: smoothness, invertability and computational tractability.\nThe two main theoretical contributions of this paper are found in Claim \\ref{claim1}  and Claim \\ref{claim2}. Claim 1 establishes the existence of the diffeomorphism PMLE  over a Hilbert space generating the initial velocity fields which give rise to the geodesic diffeomorphisms. Claim 2 shows that the PMLE  has a finite dimensional  spline characterization  when the initial velocities are restricted to reproducing kernel Hilbert spaces.\nThis finite dimensional characterization, although similar in spirit to spline function estimation, is completely different in that it holds for the initial velocity fields which generate the geodesic diffeomorphisms.\n  A secondary contribution of this paper is the realization that the Euler-Lagrange equation for the PMLE also allows one to construct a diagnostic for approximating sub-models of the initial velocity field which are more amenable to computation. This diagnostic can be used to test whether a sub-model is sufficiently rich to reach the stationary points of the penalized maximum likelihood over the  full infinite dimensional Hilbert space.  This has the potential for significant computational savings when applying the estimate to large data sets in high dimension.\nIn Section \\ref{steinSection} we make an explicit connection between the Euler-Lagrange equation for the PMLE and Stein's method for bounding distances between two probability measures.\nThis connection is used to motivate and explain the Euler-Lagrange equation and also hints at a new approach for deriving a theoretical understanding of the PMLE.\nThe paper concludes with  two illustrative examples which are not intended to be a compete simulation analysis but instead to illustrate the estimate and give a hint at the potential applicability of this new methodology. Indeed, the flexibility provided by both the diffeomorphism and the target measure make the methodology potentially applicable to a wide range of problems:\nfrom manifold estimation to density estimation on manifolds and from nonparametric measures of goodness of fit to\n heteroscedastic regression.\n\n%Indeed, there are many more directions of future research and we hope the results in this paper spur development into this area.\n%Clearly the theoretical development of the estimate is a natural direction. Also, for the estimate to become widely applicable there also needs to be a study of adaptive choices of smoothing penalty $\\lambda$. Of course, cross validation is the natural first choice but others may be equally competatives.  In addition, we have only given brief glimpse at the possibilities for the target model which can possibly be extended to density estimates on manifolds   manifolds and more general shape constrained models.\n% In general one can also use regression target models, then the diffeomorphism scold potentially model heterogsigsatiscisy or left out interactions.\n%We close by mentioning that The connection with Stein's method is particularly enticing as  a potential way to further the theoretical understanding of the estimate.\n\n\n\n\\appendix\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Technical Details}\n\\label{TD}\n\n\nThis section serves to present some technical details which are used  in the proofs of Claim \\ref{claim1} and Claim \\ref{claim2}.   Some of these results can be found in the current literature. In particular,  Proposition \\ref{Hspace}, most of Proposition \\ref{PropDef} and equation (\\ref{111}) can be found in \\cite{you:10}.   However, the main goal of this section is to establish  equation (\\ref{888}) in Proposition \\ref{proo}  which is key to establishing Claim \\ref{claim2}.\nWe mention that all of the derivations presented in this section rely heavily on techniques developed by  Younes, Tr\\'ouve, Miller and co-authors (see \\cite{you:10} and references therein).\n\n\n\n%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n\n\\begin{definition}\nHere are some basic definitions and basic facts. Let $\\Omega \\subset \\Bbb R^d$ be an open set.\n\\begin{enumerate}\n\\item $C^0(\\Omega)$ is the set of continuous functions on $\\Omega$.\n\\item $C^0(\\bar\\Omega)$ is the set of continuous functions on $\\bar\\Omega$.\n\\item $C^k(\\Omega)$ is the set of functions have all derivatives of order $\\leq k$ continuous in $\\Omega$.\n\\item $C^k(\\bar\\Omega)$ is the set of functions in $C^k(\\Omega)$ all of whose derivatives of order $\\leq k$ have continuous extensions to $\\bar\\Omega$.\n\\item The {\\em support } of a function $f$ is the closure of the set on which $f\\neq 0$.\n%\\item $C_0^k(\\Omega)$ is the set of functions in $C^k(\\Omega)$ with compact support in $\\Omega$. \\textcolor{blue}{Note:} this seems to differ a bit from the defintion in Younes who says that $C_0^k(\\Omega)$ is the set of functions in $C^k(\\Omega)$ which vanish on  $\\partial\\Omega$.\n\\item A complete normed linear space is called a {\\em Banach space}.\n\\item For $f\\in C^k(\\bar\\Omega)$ set\n\\[ \\| f \\|_{C^k(\\bar \\Omega)}\\equiv \\| f \\|_{k,\\infty}\\equiv \\sum_{j=0}^k \\sup_{|\\beta|=j}\\sup_{\\Omega} |D^\\beta f|.\\]\n\\item If $f\\in C^\\alpha(\\bar\\Omega)$ and $g\\in C^\\beta(\\bar\\Omega)$ then $fg \\in C^{\\beta\\wedge \\alpha}(\\bar\\Omega)$ and\n\\[ \\|fg  \\|_{\\beta\\wedge \\alpha,\\infty}\\leq c \\|f  \\|_{ \\alpha,\\infty}\\|g  \\|_{\\beta,\\infty}  \\]\nwhere $c$ only depends on $d,\\alpha, \\beta$.\n\\item  $C^k(\\bar\\Omega)$ are Banach spaces with respect to the norm $\\| \\cdot \\|_{k,\\infty}$.\n\\end{enumerate}\n\\end{definition}\n\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%------------------------------ end long version\n\nTo set notation  let $C^k(\\Omega, \\Bbb R^d)$ denote the set of functions, mapping an open set $\\Omega\\subset \\Bbb R^d$ into $\\Bbb R^d$, which have continuous derivatives of order $\\leq k$ (so that $C^0(\\Omega, \\Bbb R^d)$ is the continuous functions on $\\Omega$ mapping into $\\Bbb R^d$).\nAlso let $C^k(\\bar\\Omega,\\Bbb R^d)$ denote the set of functions in $C^k(\\Omega,\\Bbb R^d)$ whose derivatives of order $\\leq k$ have continuous extensions to $\\bar\\Omega$. Finally, $C_0^k(\\Omega,\\Bbb R^d)$ is the set of functions in $C^k(\\bar\\Omega,\\Bbb R^d)$ whose derivatives of order $\\leq k$ take the value $0$ on the boundary $\\partial \\Omega$. It is a well known fact that  $C^k(\\bar\\Omega,\\Bbb R^d)$ is a Banach space with respect to the norm:  $ \\| f \\|_{C^k(\\bar \\Omega)}\\equiv \\| f \\|_{k,\\infty}\\equiv \\sum_{j=0}^k \\sup_{|\\beta|=j}\\sup_{\\Omega} |D^\\beta f|$.\n\n\n\n{\\em Remark:} The norm $\\| v\\|_V\\equiv \\int_0^1 \\| v_t\\|^2_V dt $ given in Definition \\ref{defV01} is technically only a semi-norm since one is free to change $v_t$  on a set of $t\\in[0,1]$ with Lebesque measure zero (and not effect the norm on $V^{[0,1]}$). This is easily fixed by identifying  $V^{[0,1]}$ with the set of equivalence classes of measurable functions where $\\{v_t\\}_{t\\in [0,1]}$ and $\\{w_t\\}_{t\\in [0,1]}$ are said to be in the same equivalence class if $\\| v_t-w_t \\|_V=0$ for almost every $t\\in [0,1]$. For the remainder of the paper we treat this identification as implicit with the understanding that $\\{v_t\\}_{t\\in[0,1]}$  denotes a representer of the equivalence class to which is belongs. The following proposition establishes the Hilbert space structure of $V^{[0,1]}$ (stated without proof in 8.17 of \\cite{you:10}).\n\n\\begin{proposition}\n\\label{Hspace}\nIf $V$ is a Hilbert space with inner product $\\langle\\cdot, \\cdot \\rangle_V$, then\n$V^{[0,1]}$ is a Hilbert space with inner product  defined by $\\langle v,h \\rangle_{V^{[0,1]}} \\equiv\\int_0^1 \\langle  v_t, h_t\\rangle_V dt$.\n\\end{proposition}\n\n\\begin{proof}\nNotice first that $\\| v_t\\|_V$ and $\\langle  v_t, h_t\\rangle_V$ are measurable functions of $t$ (this can be taken to be implicit in definitional requirement for membership in $V^{[0,1]}$: that $\\int_0^1 \\| v_t \\|^2_Vdt <\\infty$). Now, with the exception of completeness, all the properties of a Hilbert space inner product are inherited from $\\langle  \\cdot , \\cdot\\rangle_V$ and the linear properties of Lebseque integration over $[0,1]$.\nTo show completeness  let $v^n\\in V^{[0,1]}$ be a Cauchy sequence so that $\\int_0^1 \\| v_t^m - v_t^n \\|^2_V dt\\rightarrow 0$. By the completeness of $V$ there exists a Borel set $B\\subset[0,1]$ such that for all $t\\in B$ there exists a $v_t\\in V$ such that $\\|v_t^n - v_t\\|_V\\rightarrow 0$. On $t\\in [0,1]\\setminus B$ we are free to set $v_t\\equiv 0$ (the zero element of $V$). For this $v_t$ we have that $\\|v^n_t - v_t \\|_{V^{[0,1]}}^2\\equiv \\int_0^1 \\| v_t^n - v_t \\|^2_V dt\\rightarrow 0$. Therefore $V^{[0,1]}$ is complete.\n\\end{proof}\n\n\n\n%%%%%%%%%%%%%%%%%\n%begin  proposition\n%%%%%%%%%%%%%%%%%%\n\\begin{proposition}\n\\label{PropDef} Let $\\Omega$ be an open bounded subset of $\\Bbb R^d$ and $V$ be a Hilbert space such that  $V\\hookrightarrow C_0^1(\\Omega,\\Bbb R^d)$. If   $v\\in V^{[0,1]}$ then there exists a unique  class of $C^1$ diffeomorphisms of $\\Omega$,  $\\{\\phi_{t}^v\\}_{t\\in [0,1]}$, such that  $\\phi_t^v(x)\\in C^0 ([0,1]\\times \\overline \\Omega,\\Bbb R^d)$ and  which satisfy the ordinary differential equation $\n \\partial_t \\phi_t^v(x) = v_t(\\phi_t^v(x)) $ with boundary condition $\\phi_0^v(x)=x$, for all $x\\in \\Omega$.\nMoreover,\n \\begin{equation}\n \\label{div}\n  \\log\\det D\\phi_{st}^v(x)  = \\int_s^t  \\text{\\rm div}\\,  v_u (\\phi_{su}^v(x))du.\n  \\end{equation}\n \\end{proposition}\n%%%%%%%%%%%%%%%%\n%begin proof\n%%%%%%%%%%%%\n\\begin{proof}\n%\n%%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n\nWe first show that there exists a $\\delta>0$ and a solution $\\phi^v_t(x)$   to the ordinary differential equation $ \\partial_t \\phi_t^v(x) = v_t(\\phi_t^v(x)) $ on $(t,x)\\in [0,\\delta]\\times\\Omega$  with boundary condition $\\phi_0^v(x)=x$ (for all $x\\in \\Omega$) which is in $C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$.  For any map $\\varphi_t(x)\\in C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$ we define the operator $\\Gamma(\\varphi)\\equiv x + \\int_0^t v_s(\\varphi_s(x))ds $ (extending $v_s$ to $0$ beyond $\\Omega$ if necessary). Notice  $\\Gamma$ maps $C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$ into $C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$  since\n\\begin{align*}\n|x + \\int_0^t v_s(\\varphi_s(x))ds  - y - \\int_0^w v_s(\\varphi_s(y))ds |\n&\\leq |x-y| + \\int_t^w | v_s(\\phi_s(x))-v_s(\\varphi_s(y))  |ds \\\\\n&\\leq |x-y| + c\\int_t^w \\| v_s \\|_V|\\phi_s(x)-\\varphi_s(y)  |ds \\\\\n&\\rightarrow 0, \\quad\\text{by DCT as $t\\rightarrow w$ and $x\\rightarrow y$}\n\\end{align*}\nand also by the fact that $|x + \\int_0^t v_s(\\varphi_s(x))ds| \\leq \\sup_{x\\in \\Omega}|x| +  c\\int_0^1 \\|v_s\\|_V ds <\\infty$.\nWe show that $\\delta$ can be chosen to make $\\Gamma$ a contraction with respect to sup norm on $C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$\n\\begin{align}\n\\|\\Gamma(\\varphi) - \\Gamma(\\varphi^\\prime) \\|_{\\infty} &\\leq \\int_0^t |v_s(\\varphi_s(x))-  v_s(\\varphi^\\prime_s(x)) |ds \\nonumber\\\\\n&\\leq \\int_0^t c\\|v_s\\|_V|\\varphi_s(x)-  \\varphi^\\prime_s(x) |ds\\nonumber \\\\\n&\\leq \\|\\varphi-  \\varphi^\\prime \\|_\\infty  \\int_0^\\delta c\\|v_s\\|_V ds \\label{Contract}\n\\end{align}\nIf we choose $\\delta$ so that $\\int_0^\\delta c\\|v_s\\|_V ds < \\gamma<1$ then the above inequality shows that $\\Gamma$ is contraction operator on the Banach space $C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$. In fact, for reasons that will become obvious later we notice that since $\\int_0^{t} c\\| v_s \\|_Vds$ is uniformly continuous for all $t\\in[0,1]$ we can choose a $\\delta$ such that $c\\int_{t}^{t+\\delta} \\|v_s\\|_V ds < \\gamma<1$ uniformly over all $t\\in [0,1]$. Therefore there exists a unique fixed point $\\phi_t(x) \\in C^0 ([0,\\delta]\\times \\overline \\Omega,\\Bbb R^d)$ which satisfies\n\\[ \\phi_t(x) = x + \\int_0^t v_s(\\phi_s(x))ds. \\]\nNow to extend  the definition of $\\phi_t(x)$ to $ t\\in [0,2\\delta]$ notice one can repeat the same argument to get the existence of $\\phi_{\\delta t}(x)$ which satisfies $\\partial_t \\phi_{\\delta t}(x) = v_t(\\phi_{\\delta t}(x)) $ on $(t,x)\\in [\\delta,2\\delta]\\times\\Omega$  with boundary condition $\\phi_{\\delta \\delta}(x)=\\phi_\\delta(x)$.\nIn particular simply set\n\\begin{equation}\n\\phi_t^v(x)\\equiv \\begin{cases}\n\\phi_t(x) & \\text{when $t\\in[0,\\delta]$}\\\\\n\\phi_{\\delta t}(x) & \\text{when $t\\in[\\delta,2\\delta]$}\n\\end{cases}\n\\end{equation}\nNow repeat the argument over successive intervals $[k\\delta, (k+1) \\delta]$. Notice that this can lead to kinks at the endpoints $k\\delta$, but this can be fixed by working with overlapping intervals and using the uniqueness of the fixed point.\nThis method then produces a unique   $\\phi_t^v(x)\\in C^0 ([0,1]\\times \\overline \\Omega,\\Bbb R^d)$ and  which satisfy the ordinary differential equation $\n \\partial_t \\phi_t^v(x) = v_t(\\phi_t^v(x)) $ with boundary condition $\\phi_0^v(x)=x$, for all $x\\in \\Omega$.\n\n\nNow we need to show that for all $t\\in [0,1]$, $\\phi_t$ is a $C^1$ diffeomorphism of $\\Omega$.\n\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\n\nFirst note that if $v\\in V^{[0,1]}$ and $V\\hookrightarrow C_0^1(\\Omega, \\Bbb R^d)$ then $ \\| v_t \\|_{1,\\infty} \\leq c \\| v_t \\|_{V} $. Now by H\\\"older, $\\int_0^1 \\| v_t \\|_{V} dt \\leq \\|v \\|_{V^{[0,1]}}<\\infty$  so that the arguments for  Theorem 8.7   in \\cite{you:10} to apply to the class  $ V^{[0,1]}$. In particular, there exists a unique  class of $C^1$ diffeomorphisms of $\\Omega$, $\\phi_t^v(x)\\in C^0 ([0,1]\\times \\overline \\Omega,\\Bbb R^d)$, which satisfy the ordinary differential equation $\\partial_t \\phi_t^v(x) = v_t(\\phi_t^v(x))$\n with boundary condition $\\phi_0^v(x)=x$, for all $x\\in \\Omega$. Moreover, by Proposition 8.8 in \\cite{you:10} we have that\n \\begin{align}\n    \\partial_t D\\phi_{st}^v(x)  =  D v_t (\\phi_{st}^v(x))  D\\phi_{st}^v(x) \\label{gg}\n\\end{align}\nwhere $\\det D\\phi_{ss}^v(x)=Id_d$.\nSince $D\\phi_{st}^v(x)$ is nonsingular and differentiable in $t$ we have that (see  (6.5.53) of \\cite{hor:91}, for example)\n\\begin{align*}\n\\partial_t \\log \\det D\\phi_{st}^v(x)&= \\text{trace}\\bigl\\{ [D\\phi_{st}^v(x)]^{-1}   \\partial_t D\\phi_{st}^v(x)  \\bigr\\} \\\\\n& = \\text{trace}\\bigl\\{ [D\\phi_{st}^v(x)]^{-1}  D v_t (\\phi_{st}^v(x))  D\\phi_{st}^v(x) \\bigr\\} ,\\,\\,\\text{by (\\ref{gg})} \\\\\n& = \\text{trace}\\bigl\\{ D v_t (\\phi_{st}^v(x))  \\bigr\\} \\\\\n& = \\text{div}\\, v_t (\\phi_{st}^v(x)).\n\\end{align*}\nTherefore $\\log \\det D\\phi_{st}^v(x)$ is differentiable everywhere on $t\\in [0,1]$ with derivative given by $ \\text{div}\\, v_t (\\phi_{st}^v(x))$.\n\nSince $v_t(x)$ is measurable with respect to both arguments $t$ and $x$ (by definition) and limits of measurable functions are measurable, the function $\\text{div}\\,v_t(x)$  is also measurable. Since $\\phi^v_{st}(x)$ is continuous with respect to both $t$ and $x$,  $\\text{div}\\, v_t (\\phi_{st}^v(x))$ is also measurable.\nNotice that $\\text{div}\\, v_t (\\phi_{st}^v(x))$  is also Lebesque integrable since $|\\text{div}\\, v_t (\\phi_{st}^v(x))| \\leq c\\| v_t \\|_V$ by the embedding $V\\hookrightarrow C_0^1(\\Omega,\\Bbb R^d)$ and the fact that that  $\\int_0^1 \\| v_t \\|_{V} dt \\leq \\|v \\|_{V^{[0,1]}}<\\infty$.\n%. Therefore\n%\\begin{align*}\n %\\int_0^1|\\text{div}\\, v_t (\\phi_{st}^v(x))| dt &\\leq   \\int_0^1 \\| v_t \\|_{1,\\infty}  \\leq  c  \\| v \\|_{V^{[0,1]}} <\\infty.\n %\\end{align*}\n% Therefore $\\text{\\rm div}\\,v_t(x)$ is indeed Lebesque integrable as was to be shown.\nTherefore by Theorem 7.21 of \\cite{rud:66} we have that\n\\[\\log \\det D\\phi_{st}^v(x) =  \\int_s^t  \\text{div}\\, v_u (\\phi_{su}^v(x))  du\\]\nsince $\\log \\det D\\phi_{ss}^v(x) = 0$. \\end{proof}\n\n\n\n\n%%%%%%%%%\n% begin lemma\n\\begin{lemma} If $V\\hookrightarrow C_0^1(\\Omega,\\Bbb R^d)$ and $v,w\\in V^{[0,1]}$, then\n\\begin{align}\n% \\|\\phi_{st}^v\\|_\\infty &\\leq \\sup_{x\\in \\Omega} |x| \\label{firstEE} \\\\\n \\|\\phi_{st}^v - \\phi_{st}^w    \\|_{\\infty}& \\leq c \\| v-w \\|_\\text{\\tiny $V^{[0,1]}$} \\exp{\\left( c\\| v \\|_\\text{\\tiny $V^{[0,1]}$} \\right)}\n  \\label{222}\n\\end{align}\nwhere $c$ is a constant which does not depend on $v, w, s$ or $t$.\nMoreover, if we additionally suppose $V\\hookrightarrow C_0^2(\\Omega, \\Bbb R^d)$ then\n\\begin{align}\n  \\label{777}\n\\| \\phi_{st}^v - \\phi_{st}^w \\|_{1,\\infty}\\leq \\| v-w \\|_\\text{\\tiny $V^{[0,1]}$}  F\\bigl( {\\|v\\|_\\text{\\tiny $V^{[0,1]}$}},{\\|w\\|_\\text{\\tiny $V^{[0,1]}$}}\\bigr)\n\\end{align}\nwhere $F(\\cdot,\\cdot)$ is  a finite  function on $\\Bbb R\\times \\Bbb R$, monotonically increasing in both arguments, which does not depend on $v, w, s$ or $t$.\n\\end{lemma}\n%%%%%%%%\n% end lemma\n%%%%%%%%%%\n\n\n%%%%%%%%%%%%\n% begin proof\n%%%%%%%%%%%%%%%%%\n\\begin{proof}\nThe inequality (\\ref{222})  follows directly from Grownwell's lemma  applied to the following inequality\n\\begin{align*}\n|\\phi_{st}^v(x) - \\phi_{st}^w(x)| &= \\left| \\int_{s}^t v_u (\\phi_{su}^v(x)) -  w_u (\\phi_{su}^w(x)) du\\right|\\\\\n&\\leq \\int_{s}^t |v_u (\\phi_{su}^v(x)) -  v_u (\\phi_{su}^w(x)) |du + \\int_{s}^t |v_u (\\phi_{su}^w(x)) -  w_u (\\phi_{su}^w(x)) |du\\\\\n%& \\leq   \\int_{s}^t \\|v_u\\|_{1,\\infty} |\\phi_{su}^v(x) -  \\phi_{su}^w(x)| du  + \\int_0^1 \\|  v_u - w_u \\|_{\\infty} du \\\\\n& \\leq \\int_{s}^t c\\|v_u\\|_{V} |\\phi_{su}^v(x) -  \\phi_{su}^w(x)|du  +  c\\|v - w  \\|_{V^{[0,1]}}\n\\end{align*}\nwhere the last inequality follows from the assumption $V\\hookrightarrow C_0^1(\\Omega, \\Bbb R^d)$.\n%%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n Therefore\n \\[  |\\phi_{st}^v(x) - \\phi_{st}^w(x)| \\leq  c_2\\|v - w  \\|_{V^{[0,1]}} \\exp\\left( \\int_{s}^t \\|v_u\\|_{1,\\infty}  du \\right) \\]\n by Grownwell's lemma.  This proves (\\ref{222}).\n {\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\n\n\n\n\n\n To prove (\\ref{777}) notice that for any vector $h\\in \\Bbb R^d$ we have that $\\partial_t D \\phi_{st}^v(x)h= Dv_t (\\phi_{st}^v(x))D \\phi_{st}^v(x)h $ where $ D \\phi_{ss}^v(x)h = h$ (by Proposition 8.8 in \\cite{you:10} and also  \\cite{dup:98}). Therefore\n \\begin{align}\n \\label{uugg}\n D \\phi_{st}^v(x)h -  D \\phi_{st}^w(x)h = \\int_s^t \\Bigl[  Dv_u (\\phi_{su}^v(x))D \\phi_{su}^v(x)h -  Dw_u (\\phi_{su}^w(x))D \\phi_{su}^w(x)h \\Bigr]\\,du\n \\end{align}\n where we are using the fact that $D \\phi_{st}^v(x)h$  is differentiable with respect to $t$ everywhere in $[0,1]$ and with  Lebseque integrable derivative   (and using Theorem 8.21 of \\cite{rud:66}).\n Now notice that the integrand of (\\ref{uugg}) satisfies\n  \\begin{align*}\n\\bigl| &Dv_u (\\phi_{su}^v(x))D \\phi_{su}^v(x)h -  Dw_u (\\phi_{su}^w(x))D \\phi_{su}^w(x)h  \\bigr| \\leq I + I\\!I\n\\end{align*}\nwhere\n\\begin{align*}\nI &=  \\left| Dv_u (\\phi_{su}^v(x)) \\Bigl\\{ D \\phi_{su}^v(x)h - D \\phi_{su}^w(x)h \\Bigr\\}  \\right| \\leq   c\\bigl\\| v_u\\bigr\\|_{V} \\Bigl|   D \\phi_{su}^v(x)h - D \\phi_{su}^w(x)h  \\Bigr|\n\\end{align*}\nand\n\\begin{align*}\nI\\!I & =  \\left|\\Bigl\\{ Dv_u (\\phi_{su}^v(x)) -  Dw_u (\\phi_{su}^w(x))  \\Bigr\\} D \\phi_{su}^w(x)h  \\right| \\\\\n&\\leq   \\Bigl\\{ \\| v_u \\|_{2,\\infty} \\| \\phi_{su}^v - \\phi_{su}^w \\|_\\infty   + \\bigl\\| v_u-w_u\\bigr \\|_{1,\\infty} \\Bigr\\} \\,  \\bigl\\| \\phi_{su}^w\\bigr\\|_{1,\\infty} \\, |h |\\\\\n&\\leq \\Bigl\\{   c \\| v_u \\|_{V^{\\phantom{[}}}  \\|v-w\\|_{V^{[0,1]}} \\exp\\left(c\\| w \\|_{V^{[0,1]}} \\right)   + c\\bigl\\| v_u-w_u\\bigr \\|_{V} \\Bigr\\}\\,  \\bigl\\| \\phi_{su}^w\\bigr\\|_{1,\\infty} \\, |h |\n%-----\n \\end{align*}\n %%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\nWe are using the fact that for any $v_t\\in V$ we have that $\\bigl |Dv_t (x) h \\bigr |\\leq \\| v_t \\|_{1,\\infty } | h| $ for any $ h,  x \\in \\Bbb R^d$.  Also we are using the fact that for any $v_t\\in V$ we have that $\\bigl |(Dv_t (x) - Dv_t(y))h \\bigr |\\leq \\| v_t \\|_{2,\\infty }|x-y| | h| $ for any $ h,  x \\in \\Bbb R^d$.\n  {\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\nwhere the last inequality follows by (\\ref{222}). To bound $I\\!I$ further notice $\n  \\|\\phi_{st}^v\\|_{1,\\infty} \\leq c_1\\exp{\\left( c\\| v \\|_\\text{\\tiny $V^{[0,1]}$} \\right)}$. To see why,\napply Gronwall's lemma to the following inequality\n\\begin{align*}\n|\\phi_{st}^v(x) - \\phi_{st}^v(y)| &= \\left| x-y + \\int_{s}^t v_u (\\phi_{su}^v(x)) -  v_u (\\phi_{su}^v(y)) du\\right|\\\\\n& \\leq  |x-y| + \\int_{s}^t c\\, \\|v_u\\|_{V^{\\phantom{[}}} |\\phi_{su}^v(x) -  \\phi_{su}^v(y)| du\n\\end{align*}\nwhich yields $| \\phi_{st}^v(x) - \\phi_{st}^v(y) |\\leq |x-y| \\exp{\\left( c\\| v \\|_\\text{\\tiny $V^{[0,1]}$} \\right)}$.\n  Since $\\phi_{st}^v(x)$ is differentiable with respect to $x$ everywhere in $\\Omega$, for each multi-index $\\beta$ such that $|\\beta|=1$ there exists a direction $h^\\beta\\in \\Bbb R^d$ (with $|h^\\beta|=1$) such that\n \\begin{align*}\n |D^\\beta \\phi_{st}^v(x) | &= \\lim _{\\epsilon \\downarrow 0} \\frac{|\\phi_{st}^v(x+\\epsilon h^\\beta) - \\phi_{st}^v(x)|}{\\epsilon}  \\leq  \\exp{\\left( c\\| v \\|_\\text{\\tiny $V^{[0,1]}$} \\right)}.\n \\end{align*}\n Combining the above inequality with the fact that $ \\|\\phi_{st}^v\\|_\\infty \\leq \\sup_{x\\in \\Omega} |x| $ gives  the desired inequality\n $ \\|\\phi_{st}^v\\|_{1,\\infty} \\leq c_1\\exp{\\left( c\\,\\| v \\|_\\text{\\tiny $V^{[0,1]}$} \\right)}$. Applying this to $ I\\!I $ gives\n \\begin{align*}\n I\\!I &\\leq \\Bigl\\{  c \\| v_u \\|_{V}  \\|v-w\\|_{V^{[0,1]}} \\exp\\left(c \\| w \\|_{V^{[0,1]}} \\right)   + c \\bigl\\| v_u-w_u\\bigr \\|_{V} \\Bigr\\}\\, c_1\\exp{\\left( c \\| w \\|_\\text{\\tiny $V^{[0,1]}$} \\right)} |h|\n \\end{align*}\n Therefore\n \\begin{align*}\n\\int_s^t I\\!I\\, du\n&\\leq c_1 c |h| \\|v-w \\|_{V^{[0,1]}}\\Bigl\\{\\|v\\|_{V^{[0,1]}} \\exp\\bigl( 2c\\| w \\|_{V^{[0,1]}} \\bigr)  +  \\exp\\bigl( c\\| w \\|_{V^{[0,1]}} \\bigr)  \\Bigr\\}\\\\\n%&\\leq  c_1 |h|  \\|v-w\\|_{V^{[0,1]}} \\exp\\left(c_3\\| w \\|_{V^{[0,1]}} \\right) \\Bigl[ c_5 \\| v \\|_{V^{[0,1]}}  \\exp\\left(c_2\\| w \\|_{V^{[0,1]}} \\right)   + c_4  \\Bigr] \\\\\n& =  |h|  \\|v-w\\|_{V^{[0,1]}}  F\\left(\\|v \\|_{V^{[0,1]}} ,\\| w\\|_{V^{[0,1]}}\\right)\n\\end{align*}\nwhere $F(x,y)$ is monotone and finite in both $x$ and $y$. Now by equation (\\ref{uugg}) we have that\n\\begin{align*}\n\\bigl|D \\phi_{st}^v(x)h -  D \\phi_{st}^w(x)h\\bigr | & \\leq \\int_s^t I du + \\int_s^t I\\!I du \\\\\n&\\leq  \\int_s^t c\\bigl\\| v_u\\bigl\\|_{V} \\bigl|   D \\phi_{su}^v(x)h - D \\phi_{su}^w(x)h  \\bigr| du \\\\\n&\\qquad\\qquad +  |h|  \\|v-w\\|_{V^{[0,1]}}  F\\bigl(\\|v \\|_{V^{[0,1]}},\\| w\\|_{V^{[0,1]}}\\bigr).\n\\end{align*}\nBy Gronwell's lemma we have that\n\\[\\bigl|D \\phi_{st}^v(x)h -  D \\phi_{st}^w(x)h\\bigr | \\leq  |h|  \\|v-w\\|_{V^{[0,1]}}  F\\bigl(\\|v \\|_{V^{[0,1]}},\\| w\\|_{V^{[0,1]}}\\bigr) \\exp\\bigl ( c \\bigl\\| v\\bigl\\|_{V^{[0,1]}} \\bigr) . \\]\nNow by taking a supremum over $x\\in \\Omega$, $|h|=1$ and combining with (\\ref{222}) gives (\\ref{777}), after redefining $F$ to accommodate the extra term $\\exp ( c \\bigl\\| v\\bigl\\|_{V^{[0,1]}} )$.\n\n\n%Therefore by Gronwall's lemma we have that\n%$ |\\phi_{st}^v(x) - \\phi_{st}^v(y)|\\leq |x-y| \\exp\\left( \\int_{s}^t   \\|v_u\\|_{1,\\infty} du \\right)$ which establishes  (\\ref{555}).\n\n\n\n\n\\end{proof}\n%%%%%%%%%%%%\n%  end proof\n%%%%%%%%%%%%%%%\n\n%%%%%%%\n% begin lemma\n%%%%%%%%%\n\\begin{proposition}\n\\label{proo}\nIf $v,h \\in V^{[0,1]}$ and $V\\hookrightarrow C_0^1(\\Omega,\\Bbb R^d)$ then for all $x\\in \\Omega$ and $s,t\\in [0,1]$\n\\begin{align}\n{\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{st}(x)  &= \\int_s^t  \\bigl\\{D\\phi^{ v+\\epsilon h}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v+\\epsilon h}_{su}(x)}\\,   du. \\label{111}\n % & =   \\int_0^1 [D\\phi_1(x)]  [D\\phi_t(x)]^{-1} h_t ( \\phi^{\\hat v+\\epsilon h}_{t}(x))   dt.\n \\end{align}\n %%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\nIf, in addition, $V\\hookrightarrow C_0^2(\\Omega,\\Bbb R^d)$ then ${\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_t(x)  $ is locally Lipschitz continuous in $\\epsilon$   (with respect to sup-norm over $x\\in \\Omega$).\n   {\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\nIf, in addition,  $V\\hookrightarrow C_0^3(\\Omega,\\Bbb R^d)$ then\n\\begin{align}\n  \\label{888}\n\\partial_\\epsilon  \\log \\det D\\phi_{1}^{v+\\epsilon h }(x)\\bigr|_{\\epsilon = 0} & = \\int_0^1  \\Bigl[ h_u \\cdot \\nabla \\log\\det D\\phi_{u1}^v  + \\text{\\rm div}\\, h_u\\Bigr] \\circ  \\phi^v_{u}(x)  \\, du\n\\end{align}\n\\end{proposition}\n\n\n\n\n%%%%%%%%%%%%\n% begin proof\n\\begin{proof} The assumption that $v,h \\in V^{[0,1]}$ and $V\\hookrightarrow C_0^1(\\Omega,\\Bbb R^d)$ are sufficient to apply\nTheorem 8.10 of \\cite{you:10} which gives\n\\begin{align*}\n{\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{st}(x) \\bigr|_{\\epsilon = 0} &= \\int_s^t  \\bigl\\{D\\phi^{ v}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v}_{su}(x)}\\,   du.\n % & =   \\int_0^1 [D\\phi_1(x)]  [D\\phi_t(x)]^{-1} h_t ( \\phi^{\\hat v+\\epsilon h}_{t}(x))   dt.\n \\end{align*}\n Now since ${\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{st}(x) = {\\partial_\\xi}  \\phi^{ v+\\epsilon h+\\xi h}_{st}(x)\\bigr|_{\\xi = 0} $ one immediately obtains (\\ref{111}).\n\n %%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n\n    Now we can prove the local Lipschitz continuity of  ${\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_t  $ in $\\epsilon$  (with respect to sup-norm). Let $\\xi, \\epsilon\\in (-M, M)$ for some $0<M<\\infty$ and fix $v,h\\in V^{[0,1]}$ and write\n\\begin{align}\n\\left \\| \\partial_\\epsilon  \\phi^{ v+\\epsilon h}_{st} -  \\partial_\\xi   \\phi^{ v+\\xi h}_{st}  \\right\\|_{\\infty} & = \\left \\| \\int_s^t  \\bigl\\{D\\phi^{ v+\\epsilon h}_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\epsilon h}_{su}(x)}-  \\bigl\\{D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\xi h}_{su}(x)}\\,   du    \\right\\|_{\\infty}\\nonumber \\\\\n& \\leq  \\left\\| \\int_s^t  \\bigl\\{D\\phi^{ v+\\epsilon h}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v+\\epsilon h}_{su}(x)}-  \\bigl\\{D\\phi^{ v+\\xi h }_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\epsilon h}_{su}(x)}\\,   du    \\right\\|_{\\infty}\\label{hhhh1}  \\\\\n& \\qquad+ \\left\\| \\int_s^t  \\bigl\\{D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\epsilon h}_{su}(x)}-  \\bigl\\{D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v+\\xi h}_{su}(x)}\\,   du    \\right\\|_{\\infty}  \\label{hhhh2}\n\\end{align}\nThe integrand of the first  term (\\ref{hhhh1}) can be bounded by noticing that   $V\\hookrightarrow C_0^{2}(\\Omega, \\Bbb R^d)$ implies\n\\begin{align}\n  \\Bigl| \\bigl\\{D\\phi^{ v+\\epsilon h}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v+\\epsilon h}_{su}(x)}- & \\bigl\\{D\\phi^{ v+\\xi h }_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\epsilon h}_{su}(x)}\\Bigr| \\nonumber\\\\\n  &\\leq \\|  (D\\phi_{ut}^{ v+\\xi h} -D \\phi_{ut}^{ v+\\epsilon h})h_u   \\|_\\infty  \\nonumber\\\\\n  &\\leq  \\|  \\phi_{ut}^{ v+\\xi h} - \\phi_{ut}^{v+\\epsilon h}  \\|_{1,\\infty}  \\| h_u\\|_{\\infty} \\nonumber\\\\\n&\\leq |\\xi -\\epsilon| \\|  h  \\|_{V^{[0,1]}}  F\\bigl( {\\|v+\\xi h\\|_\\text{\\tiny $V^{[0,1]}$}},{\\|v+\\epsilon h\\|_\\text{\\tiny $V^{[0,1]}$}}\\bigr)   \\| h_u\\|_{V},\\,\\,\\text{by (\\ref{777})} \\nonumber\\\\\n&\\leq c_1 |\\xi -\\epsilon|   \\| h_u\\|_{V}\n\\label{uuuu}\n\\end{align}\nwhere $c_1$ is a finite constant which depends on $v$ and $h$ but not on   $\\xi$ or $\\epsilon$.\nThe integrand of the second term  (\\ref{hhhh2}) can be bounded as follows:\n\\begin{align}\n \\Bigr|\\bigl\\{D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\}\\circ{\\phi^{v+\\epsilon h}_{su}(x)}-  &\\bigl\\{D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\}\\circ{\\phi^{ v+\\xi h}_{su}(x)}\\Bigl| \\nonumber   \\\\\n  &\\leq   \\bigl\\| D\\phi^{v+\\xi h}_{ut} h_u \\bigr\\|_{1,\\infty} \\bigl| \\phi^{v+\\epsilon h}_{su}(x)-  \\phi^{ v+\\xi h}_{su}(x)  \\bigr| \\nonumber   \\\\\n &\\leq  c_2 |\\xi -\\epsilon|  \\| D\\phi^{v+\\xi h}_{ut} h_u \\|_{1,\\infty} ,\\,\\,\\text{by (\\ref{222})} \\nonumber   \\\\\n&\\leq  c_2 |\\xi -\\epsilon|   \\| h_u \\|_{1,\\infty} \\| \\phi^{v+\\xi h}_{ut} \\|_{2,\\infty}  \\nonumber   \\\\\n&\\leq  c_2 c_3|\\xi -\\epsilon|   \\| h_u \\|_{V}   \\label{fine}\n\\end{align}\nwhere $c_2, c_3$  are finite constants which depends on $v$ and $h$ but not on   $\\xi$ or $\\epsilon$ (the existence of $c_3$ follows again from  Theorem 8.9 of \\cite{you:10}). Combining (\\ref{uuuu}) and (\\ref{fine}) with (\\ref{hhhh1}) and (\\ref{hhhh2}) shows that $ \\partial_\\epsilon  \\phi^{ v+\\epsilon h}_{st}$  is locally Lipschitz in $\\epsilon$.\n\n   {\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\n\n\n\n\n To show (\\ref{888}) notice  that partial derivatives on $x$ can pass under the integral in (\\ref{111})  to compute $D {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{1}$. This follows by first noticing that  $V\\hookrightarrow C_0^{2}(\\Omega, \\Bbb R^d)$ implies\n  \\begin{align}\n  \\sup_{u\\in[0,1]} \\bigl\\| \\phi_{ut}^{v+\\epsilon h} \\bigr\\|_{2,\\infty}&\\leq c_1 \\exp\\left({c_2 \\|  {v\\|_{V^{[0,1]}}+M\\| h} \\|_{V^{[0,1]}}}\\right) \\label{811}\n  \\end{align}\n  for all $|\\epsilon|< M$, by equation (8.11) of \\cite{you:10}.\n  %%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\nHere is the above inequality with an extra step.\n \\begin{align}\n  \\sup_{u\\in[0,1]} \\| \\phi_{ut}^{v+\\epsilon h} \\|_{p+1,\\infty}&\\leq c_1 \\exp\\left({c_2 \\|  {v+\\epsilon h} \\|_{V^{[0,1]}}}\\right)\\\\\n  &\\leq c_1 \\exp\\left({c_2 \\|  {v\\|_{V^{[0,1]}}+M\\| h} \\|_{V^{[0,1]}}}\\right) <\\infty \\label{811}\n  \\end{align}\n Note that   (8.11) of  \\cite{you:10} can be proved using\n \\begin{align}\n \\label{rrmark}\n  \\| \\phi_{st}^v(x) - \\phi_{ss}^v(x) \\|_{p,\\infty}\n  &\\leq\\int_s^t \\|  v_u(\\phi_{su}^v(x))   \\|_{p,\\infty} du\n \\end{align}\n and then applying Proposition 8.4 of \\cite{you:10} along with Gronwall's identity and induction. Notice that when $p\\geq 1$ equation (\\ref{rrmark}) can be obtained, not from the identity $\\phi_{st}^v(x) - \\phi_{ss}^v(x)= \\int_s^t  v_u(\\phi_{su}^v(x))    du$, but from the identity\n \\[ D^\\beta\\phi_{st}^v(x) - D^\\beta\\phi_{ss}^v(x)= \\int_s^t    D^\\beta(v_u(\\phi_{su}^v(x)))   du.\\]\n which follows from Proposition 8.8 of  \\cite{you:10}.\n   {\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%%------------------------------ end long version\nTherefore when fixing $v, h\\in V^{[0,1]}$ the function $ \\| D\\phi^{v+\\epsilon h}_{ut} h_u \\|_{1,\\infty}$ is bounded above by a finite constant over $(u,\\epsilon)\\in[0,1]\\times (-M,M)$. With an additional application of Proposition 8.4 of \\cite{you:10} we also have that\n  $ \\bigl\\| \\{D\\phi^{v+\\epsilon h}_{ut} h_u\\}\\circ \\phi_{su}^{v+\\epsilon h} \\bigr\\|_{1,\\infty}<\\infty$ uniformly over $(u,\\epsilon)\\in[0,1]\\times (-M,M)$.\nTherefore, indeed, partial derivatives on $x$ can pass under the integral in (\\ref{111})  to obtain\n\\begin{equation}\n\\label{pass}\nD {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{1}(x) = \\int_0^1 D\\bigl[ \\{D\\phi_{u1}^{v+\\epsilon h} h_u  \\}\\circ \\phi_u^{v+\\epsilon h} (x)\\bigr]  du.\n\\end{equation}\n\nNow we show that $D {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{1}(x)$ is continuous  over $(x,\\epsilon)\\in \\Omega\\times (-M,M)$. This will allow us to switch the order of $D$ and $\\partial_\\epsilon$ and establish (\\ref{888}). The same reasoning which allows $D$ to pass under the integral in (\\ref{111})  also allows us to pass limits on $x$ and $\\epsilon$ under the integral in (\\ref{pass}). Therefore it will be sufficient to show the integrand, $ D\\bigl[ \\{D\\phi_{u1}^{v+\\epsilon h} h_u  \\}\\circ \\phi_u^{v+\\epsilon h}(x)  \\bigr]$,  in (\\ref{pass}) is continuous  over $(x,\\epsilon)\\in \\Omega\\times (-M,M)$.\nTo see why   the integrand in (\\ref{pass})  is continuous first note that $ \\phi^{ v+\\epsilon h}_{st}$ is a $C^2$ diffeomorphism (by a similar proof Theorem 8.7 in \\cite{you:10}). Secondly, under the assumption $V\\hookrightarrow C_0^3(\\Omega, \\Bbb R^d)$ one can extend (\\ref{777}) to bound  $\\| \\phi_{st}^{v+\\epsilon h} - \\phi_{st}^{v+\\xi h} \\|_{2,\\infty}$ by $c|\\xi - \\epsilon|$, where $c$ is a finite constant which may depend on $v,h$ but not on $\\xi, \\epsilon$. These two facts imply that $ D\\bigl[ \\{D\\phi_{u1}^{v+\\epsilon h} h_u  \\}\\circ \\phi_u^{v+\\epsilon h}(x)  \\bigr]$ is indeed continuous in $(x,\\epsilon)\\in \\Omega\\times (-M,M)$ which implies that $D {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{1}(x)$ is also.\n\nThe continuity of $D {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{1}(x)$ over $(x,\\epsilon)\\in \\Omega\\times (-M,M)$ implies  $ \\partial_\\epsilon D \\phi^{ v+\\epsilon h}_{st}$ exists and   $D {\\partial_\\epsilon}  \\phi^{ v+\\epsilon h}_{st}  =  {\\partial_\\epsilon} D \\phi^{ v+\\epsilon h}_{st}$ (see \\cite{cou:36}, page 56). Then since $D\\phi_{st}^{v+\\epsilon h}$ is nonsingular (by the diffeomorphic property) and differentiable  with respect to $\\epsilon$ we have that\n\\begin{align*}\n\\partial_\\epsilon  \\log \\det D\\phi_{st}^{v+\\epsilon h }(x)&= \\text{trace}\\bigl\\{ [D\\phi_{st}^{v+\\epsilon h}(x)]^{-1}   \\partial_\\epsilon D\\phi_{st}^{v+\\epsilon h}(x) \\bigr\\} \\\\\n &= \\text{trace}\\bigl\\{ [D\\phi_{st}^{v+\\epsilon h}(x)]^{-1}  D \\partial_\\epsilon \\phi_{st}^{v+\\epsilon h}(x)  \\bigr\\} .\n\\end{align*}\nTherefore, by (\\ref{pass}),\n\\begin{align*}\n\\partial_\\epsilon  \\log \\det D\\phi_{1}^{v+\\epsilon h }(x)\\bigr|_{\\epsilon = 0} %& =\\text{trace}\\left\\{  \\bigl[ D\\phi_1^v(x) \\bigr]^{-1} \\int_0^1 D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_u^v(x)  \\bigr]  du  \\right\\} \\\\\n%& =\\text{trace}\\left\\{  \\bigl[ D\\phi_1^v(x) \\bigr]^{-1} \\int_0^1 D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_u^v\\circ \\phi_1^{-1}\\circ \\phi_1(x)  \\bigr]  du  \\right\\} \\\\\n& =\\text{trace}\\left\\{  \\bigl[ D\\phi_1^v(x) \\bigr]^{-1} \\int_0^1 D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_{1u}^v\\circ \\phi^v_1(x)  \\bigr]  du  \\right\\} \\\\\n& =\\text{trace}\\left\\{  \\bigl[ D\\phi_1^v(x) \\bigr]^{-1} \\int_0^1 D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_{1u}^v(y)\\bigr]\\Bigr|_{y=\\phi^v_1(x)}     du\\, D\\phi^v_1(x)  \\right\\} \\\\\n%& = \\int_0^1\\text{trace}\\left\\{  D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_u^v\\circ \\phi_1^{-1}(y)\\bigr]\\Bigr|_{y=\\phi^v_1(x)}   \\right\\}    du   \\\\\n& = \\int_0^1\\text{trace}\\left\\{  D\\bigl[ \\{D\\phi_{u1}^v h_u  \\}\\circ \\phi_{1u}^v(y)\\bigr]\\Bigr|_{y=\\phi^v_1(x)}   \\right\\}    du .\n\\end{align*}\nNow notice that\n\\begin{align*}\n\\text{trace}\\, D \\bigl[ \\{  D\\phi_{u1}^v h_u\\}\\circ \\phi^v_{1u}\\bigr]\n&= \\text{trace}\\, \\bigl[ \\{  D (D\\phi_{u1}^v h_u)\\}\\circ \\phi^v_{1u} D(\\phi^v_{1u})\\bigr] \\\\\n&= \\text{trace}\\, \\bigl[    \\{D  (D\\phi_{u1}^v  h_u) \\} (D\\phi_{u1}^v )^{-1}\\bigr]\\circ \\phi^v_{1u} \\\\\n &=\\bigl\\langle  h_u\\circ  \\phi^v_{1u} ,(\\nabla \\log\\det D\\phi_{u1}^v )\\circ  \\phi^v_{1u} \\bigr\\rangle_d + (\\text{div}\\, h_u) \\circ  \\phi^v_{1u} .\n\\end{align*}\nThe last line follows from the identity: $\\text{trace}\\, \\bigl[    \\{D  [D\\phi_{u1}^v h_u] \\} (D\\phi_{u1}^v)^{-1}\\bigr]= \\bigl\\langle  h_u,\\nabla \\log\\det D\\phi_{u1}^v \\bigr\\rangle_d + \\text{trace}(D h_u)$.\n%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n$\\text{trace}\\, \\bigl[    \\{D  D\\phi h \\} (D\\phi)^{-1}\\bigr]= \\bigl\\langle  h,\\nabla \\log\\det D\\phi \\bigr\\rangle_d + \\text{div}\\, h$. This is easily seen to be true using a symbolic mathematical program. For example the following {\\sc{Matlab}} code works\n\\begin{quote}\n\\tt{syms x y;\\\\\nf1=sym('f1(x,y)');\\\\\nf2=sym('f2(x,y)'); \\\\\nh1=sym('h1(x,y)'); \\\\\nh2=sym('h2(x,y)'); \\\\\nF=[f1;f2]; \\\\\nh=[h1;h2]; \\\\\nDF=jacobian(F,[x y]);\\\\\nLHS=trace( jacobian(DF*h,[x y])*inv(DF) );\\\\\nRHS=(jacobian(log(det(DF)),[x y])  )*h + trace(jacobian(h,[x y]));\\\\\nsimplify(LHS-RHS)\\\\\n\\%Note that this simplifies to zero!!!!!}\n\\end{quote}\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%------------------------------ end long version\nTherefore\n \\begin{align*}\n\\partial_\\epsilon  \\log \\det D\\phi_{1}^{v+\\epsilon h }(x)\\bigr|_{\\epsilon = 0} & = \\int_0^1  \\Bigl[ h_u \\cdot \\nabla \\log\\det D\\phi_{u1}^v   + \\text{div}\\, h_u  \\Bigr]\\circ  \\phi^v_{u}(x)  du.\n\\end{align*}\n\n\n\\end{proof}\n%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n%%%%%%%%%%%%%%%\n\\section{Radial kernel derivatives}\nThe following lemma shows how to simplify the evolution of $q,m, A$ and $b$ in the above equations when the reproducing kernel $R(x,y)$ is a radial kernel $R(|x-y|)$.\n\\begin{lemma}\nLet $R$ be a real valued function defined on $[0,\\infty)$ such that  $R(|\\cdot|)\\in C^4(\\Bbb R)$. If $x\\neq y$ are in $\\Bbb R^d$, then\n\\begin{align}\n\\nabla_x R(|x-y|)&=R^\\prime(|x-y|)\\frac{(x-y)}{|x-y|} \\label{yy1}\\\\\n\\nabla_y \\otimes \\nabla_x R(|x-y|)&=(x-y)\\otimes (y-x) \\left[ \\frac{R^{\\prime\\prime}(|x-y|)}{|x-y|^2}  -  \\frac{R^{\\prime}(|x-y|)}{|x-y|^3} \\right]  - \\frac{R^{\\prime}(|x-y|) }{|x-y|} \\text{\\rm Id}_d  \\label{yy2} \\\\\n\\nabla_{y} [\\nabla_y \\cdot \\nabla_x R(|x-y|)]&= \\frac{y-x}{|x-y|}\\left[-R^{\\prime\\prime\\prime}(|x-y|)+ (1-d)\\frac{R^{\\prime\\prime}(|x-y|)}{|x-y|} -   (1-d)\\frac{R^{\\prime}(|x-y|)}{|x-y|^2}  \\right].  \\label{yy3}\n\\end{align}\nWhen $x=y$,\n\\begin{align}\n\\nabla_x R(|x-y|)\\Bigr|_{x=y}&=0   \\label{yy4}\\\\\n\\nabla_y \\otimes \\nabla_x R(|x-y|)\\Bigr|_{x=y}&= -\\text{\\rm Id}_d  R^{\\prime\\prime}(0)  \\label{yy5}\\\\\n\\nabla_{y} [\\nabla_y \\cdot \\nabla_x R(|x-y|)]\\Bigr|_{x=y}&=0.    \\label{yy6}\n\\end{align}\nFinally notice that $\\nabla_y \\otimes \\nabla_x R(|x-y|)=-\\nabla_x \\otimes \\nabla_x R(|x-y|)$.\n\\end{lemma}\n\n%%%%%%%%%%%%%%%\n\\begin{proof}\nThe equation (\\ref{yy1}) holds by noticing that $\\nabla_x |x-y|= (x-y)/|x-y|$. Then equation  (\\ref{yy4}) holds since $R^{\\prime}(|x-y|)\\rightarrow 0$ as $|x-y|\\rightarrow 0$. The second equation (\\ref{yy2}) follows since\n\\[ \\nabla_y \\otimes \\nabla_x R(|x-y|)=  \\nabla_y  [(x-y) F(|x-y|)]=-e_i F(|x-y|)+ F^\\prime(|x-y|) \\frac{(y-x)\\otimes (x-y)}{|x-y|}\\]\nwhere $F(y)=R^\\prime(y)/y$ and $e_i=(0,\\ldots,1,\\ldots,0)$ (with the $1$ in the $i^\\text{th}$ coordinate) so that\n\\[ F^\\prime(y)=\\frac{R^{\\prime\\prime}(y)y- R^{\\prime}(y)}{y^2} =\\frac{R^{\\prime\\prime}(y)}{y}-\\frac{ R^{\\prime}(y)}{y^2}.\\]\nAlso notice that $ F^\\prime(|x-y|) \\frac{(y-x)\\otimes (x-y)}{|x-y|}\\rightarrow 0$ as $|x-y|\\rightarrow 0$ since each coordinate is bounded by $F^\\prime(|x-y|) |x-y|= R^{\\prime\\prime}(|x-y|)- R^\\prime(|x-y|)/|x-y|\\rightarrow R^{\\prime\\prime}(0)- R^{\\prime\\prime}(0)=0$. Now since $F(|x-y|)\\rightarrow R^{\\prime\\prime}(0)$ as $|x-y|\\rightarrow 0$, we also get equation (\\ref{yy5}).\n\n\nFinally notice that (\\ref{yy3}) follows since\n\\[ \\nabla_y \\cdot \\nabla_x R(|x-y|)=\\text{trace}\\bigl\\{\\nabla_y \\otimes \\nabla_x R(|x-y|) \\bigr\\}=-R^{\\prime\\prime}(|x-y|)+(1-d)\\frac{R^\\prime(|x-y|)}{|x-y|}\\]\nNow when $x\\neq y$\n\\[ \\nabla_y [ \\nabla_y \\cdot \\nabla_x R(|x-y|)]=-R^{\\prime\\prime\\prime}(|x-y|)\\frac{y-x}{|x-y|}+(1-d) F^\\prime(|x-y|) \\frac{y-x}{|x-y|}. \\]\nTo study the case when $x=y$ we can form the difference quotient to compute  $\\frac{\\partial }{\\partial y_i} \\nabla_y \\cdot \\nabla_x R(|x-y|)$\n\\begin{align}\n\\left[\\frac{\\partial }{\\partial y_i} \\nabla_y \\cdot \\nabla_x R(|x-y|)\\right]_{x-y=0}&=\\frac{ \\nabla_y \\cdot \\nabla_x R(|\\epsilon e_i|)-\\nabla_y \\cdot \\nabla_x R(0) }{\\epsilon} \\\\\n&=\\frac{-R^{\\prime\\prime}(\\epsilon)+(1-d){R^\\prime(\\epsilon)}/{\\epsilon}  +d R^{\\prime\\prime}(0) }{\\epsilon} \\\\\n&=\\frac{-R^{\\prime\\prime}(0)+ O(\\epsilon^2)+(1-d){R^{\\prime\\prime}(0)} + O(\\epsilon^2)  +d R^{\\prime\\prime}(0) }{\\epsilon}\\label{IamSmall} \\\\\n&=O(\\epsilon)\n\\end{align}\nwhere (\\ref{IamSmall}) following since $R^\\prime(0)=R^{\\prime\\prime\\prime}(0)=0$.\n\\end{proof}\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%------------------------------ end long version\n\n\n%%------------------------------ begin long version\n\\if\\Ver\\LongVer{\n{\\flushleft\\textcolor{blue}{$\\downarrow$---------begin long version---------}}\\newline\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%  Geodesic flows\n%%%%%%%%%%%%%%\n\\section{Numerical techniques: geodesic and transpose flows}\nHere we explicitly show how to generate Geodesic flows.\n\n\n\n%%%%%%%%%%%%%%%%%\n\\subsection{Geodesic flow  when  $v^t(x)=\\sum_{j=1}^N \\eta^t_j R(x,\\kappa^t_j) $ on $\\Bbb R^1$}\nSuppose $v^t(x)$ is a vector field on $\\Bbb R$ such that $v^t(x)=\\sum_{j=1}^N \\eta^t_j R(x,\\kappa^t_j)$.\nWe give formal arguments that  show how to generate the full path of coefficients $\\{\\eta^t_j: t\\in [0,1], j=1,\\ldots, N\\}$ and knots $\\{\\kappa^t_j: t\\in [0,1], j=1,\\ldots, N\\}$ from the $t=0$ values when the vector field flow minimizes $\\frac{1}{2}\\int_0^1 \\| v^t  \\|^2_R dt$ under the endpoint constraints $\\kappa_j^{0}=X_j$ and $\\kappa_j^{1}=\\phi^1(X_k)$. {\\em Imagine restricting all the flows to having this form, then minimizing the PMLE. The minimum fixes $\\phi_\\text{optim}^1$ and the flow vector field also minimizes  $\\frac{1}{2}\\int_0^1 \\| v^t  \\|^2_R dt$ under the endpoint constraints $\\kappa_j^{0}=X_j$ and $\\kappa_j^{1}=\\phi_\\text{optim}^1(X_k)$}\n\nStart by noticing that\n\\begin{align*}\n\\frac{1}{2}\\int_0^1 \\| v^t  \\|^2_V dt &=  \\frac{1}{2}\\int_0^1  \\langle \\sum_{i=1}^N R(\\kappa_i,\\cdot ) \\eta_i, \\sum_{j=1}^N R(\\kappa_j,\\cdot ) \\eta_j\\rangle dt \\\\\n&= \\frac{1}{2}\\int_0^1 \\sum_{i=1}^N \\sum_{j=1}^N \\eta_i^T \\eta_j R(\\kappa_i,\\kappa_j) dt\n\\end{align*}\nwhere $\\eta\\equiv (\\eta_1,\\ldots,\\eta_N)^T$ and $R=(R(\\kappa_i,\\kappa_j))_{i,j = 1}^N$ (where we are suppressing the time variable $t$ dependence on $\\eta_j$ and $x_j$). Notice that for $i=1,\\ldots, N$ we have $\\dot \\kappa_i = v(\\kappa_i)= \\sum_{j=1}^N R(\\kappa_i,\\kappa_j) \\eta_j=\\sum_{j=1}^N R_{i,j} \\eta_j =: R\\eta$ where $\\kappa = (\\kappa_1,\\ldots, \\kappa_N)^T$.\nIn particular, if $\\ell\\in \\{ 1,2,\\ldots, d \\}$ then $\\dot \\kappa_{i,\\ell} =\\sum_{j=1}^N R(\\kappa_i,\\kappa_j) \\eta_{j,\\ell} =  R_{i,:} \\eta_{:,\\ell}$. Therefore $ R^{-1} \\dot \\kappa_{:,\\ell} =\\eta_{:,\\ell}$.\n\\[ \\frac{1}{2}\\int_0^1 \\| v^t  \\|^2_V dt =  \\frac{1}{2}\\int_0^1 \\sum_{i,j=1}^N (\\dot\\kappa_i^T\\dot\\kappa_j) \\bigl(R^{-1}\\bigr)_{i,j} \\, dt  =  \\frac{1}{2}\\int_0^1 \\dot\\kappa^T R^{-1} \\dot\\kappa \\, dt  = \\int_0^1 L(\\kappa,\\dot\\kappa) dt   \\]\nwhere $L(\\kappa,\\dot\\kappa) =\\dot\\kappa^T R^{-1} \\dot\\kappa/2= \\sum_{i,j=1}^N \\dot\\kappa_j^T\\dot\\kappa_j \\bigl(R^{-1}\\bigr)_{i,j} /2$.\n Now take a time varying perturbation $\\kappa^t +\\epsilon h^t$ which does not perturb the endpoints. In particular $h^0(\\kappa^0_k)=h^1(\\kappa^1_k)=0$ for all $k=1,\\ldots, N$. Now formally since vector field flow minimizes $\\frac{1}{2}\\int_0^1 \\| v^t  \\|^2_R dt$ under the endpoint constraints $\\kappa_j^{0}=X_j$ and $\\kappa_j^{1}=\\phi_1(X_k)$ we get\n\\begin{align*}\n0&=\\frac{d}{d\\epsilon} \\left[\\int_0^1 L(\\kappa+\\epsilon h,\\dot \\kappa+\\epsilon \\dot h)dt\\right]_{\\epsilon = 0}\n%&=\\int_0^1\\frac{d}{d\\epsilon} \\Bigl[ L(\\kappa+\\epsilon h,\\dot \\kappa+\\epsilon \\dot h)\\Bigr]_{\\epsilon = 0} dt\\\\\n=\\int_0^1\\sum_{i=1}^N \\Bigl[ \\nabla_{\\kappa_i}L(\\kappa,\\dot \\kappa)\\cdot h_i + \\nabla_{\\dot\\kappa_i}L(\\kappa,\\dot \\kappa)\\cdot \\dot h_i\\Bigr]  dt  \\\\\n&=\\int_0^1\\sum_{i=1}^N  \\left[ \\nabla_{\\kappa_i} L(\\kappa,\\dot \\kappa) - \\frac{d}{dt} \\nabla_{\\dot\\kappa_i}L (\\kappa,\\dot \\kappa)\\right] \\cdot h_i  \\, dt\n\\end{align*}\nwhere the last line follows by integration by parts and the assumption that $h$ is zero at the endpoints. Since the perturbation direction $h$ was arbitrary (with the endpoint constraints) we get Euler-Lagrange equation\n\\begin{equation}\n\\label{EL}\n \\frac{d}{dt}\\nabla_{\\dot\\kappa_i} L(\\kappa,\\dot \\kappa) =  \\nabla_{\\kappa_i} L(\\kappa,\\dot \\kappa)\n\\end{equation}\nfor all $i=1,\\ldots, N$.\nIn less compact notation for each knot $i=1,\\ldots, N$ and coordinate $\\ell = 1,\\ldots, d$\n\\begin{equation}\n\\label{EL}\n \\frac{d}{dt}\\bigl[\\nabla_{\\dot\\kappa_i} L(\\kappa,\\dot \\kappa)\\bigr]_\\ell = \\bigl[ \\nabla_{\\kappa_i} L(\\kappa,\\dot \\kappa)\\bigr]_{\\ell}\n\\end{equation}\n\nNow, notice  $ \\nabla_{\\dot\\kappa} L(\\kappa,\\dot \\kappa) = R^{-1}\\dot \\kappa = \\eta$ and the $i^\\text{th}$ value of $\\nabla_{\\kappa} L(\\kappa,\\dot \\kappa) $ can be computed as follows\n\\begin{align*}\n\\bigl[\\nabla_{\\kappa_i} L(\\kappa,\\dot \\kappa)]_{\\ell} & = \\frac{\\partial}{ \\partial \\kappa_{i,\\ell}} \\frac{ \\dot\\kappa^T R^{-1} \\dot\\kappa}{2}  = \\sum_{p=1}^d \\left[-\\frac{1}{2} \\dot\\kappa^T_{:,p} R^{-1} \\frac{\\partial R}{\\partial \\kappa_{i,\\ell}}  R^{-1} \\dot\\kappa_{:,p} \\right] = \\sum_{p=1}^d  \\left[-\\frac{1}{2} \\eta_{:,p}^T \\frac{\\partial R}{\\partial \\kappa_{i,\\ell}}  \\eta_{:,p} \\right]\\\\\n&= \\sum_{p=1}^d \\sum_{j=1}^N \\left[-\\frac{\\eta_{i,p} \\eta_{j,p}}{2} \\frac{\\partial }{\\partial \\kappa_{i,\\ell}}R(\\kappa_i,\\kappa_j)  -\\frac{\\eta_{i,p} \\eta_{j,p }}{2}  \\frac{\\partial }{\\partial \\kappa_{i,\\ell}}R(\\kappa_j,\\kappa_i)   \\right]\\\\\n&= -\\sum_{j=1}^N ({\\eta_i}^T \\eta_j) \\frac{\\partial }{\\partial \\kappa_{i,\\ell}}R(\\kappa_i,\\kappa_j)\n\\end{align*}\nwhere the last line follows when $R(x,y) = R(|x-y|)$ so that $R^{(1,0)}(x,y)= - R^{(0,1)}(x,y)$, $R^{(1,0)}(x,y)= - R^{(1,0)}(y,x)$ and $R^{(1,0)}(x,y)=  R^{(0,1)}(y,x)$.\nTherefore we can simplify the Euler-Lagrange equation (\\ref{EL}) to the following update equation for $\\eta$\n\\begin{equation}\n\\label{updateEta}\n\\frac{d\\eta_i}{dt} = - \\sum_{j=1}^N \\underbrace{({\\eta_i}^T\\eta_j)}_{1\\times 1}\\underbrace{ \\nabla^T_{\\kappa_i}R(\\kappa_i,\\kappa_j)}_{d\\times 1}. \\end{equation}\nNotice that we consider $\\eta_i$ and $\\kappa_i$ as $d\\times 1$ column vectors and $\\nabla_{\\kappa_i}$ as a $1\\times d$ row vector.\nWe also trivially have the update equation for the knots\n\\begin{equation}\n\\label{updateKnots}\n\\frac{d\\kappa_i}{dt}=\\sum_{j=1}^N \\eta_j \\underbrace{R(\\kappa_i,\\kappa_j)}_{1\\times 1} .\n\\end{equation}\nAt the map level one gets, for any fixed $x$\n\\begin{equation}\n\\frac{d\\phi(x)}{dt} = \\sum_{j=1}^N \\eta_j R(\\phi(x),\\kappa_j)\n\\end{equation}\n (note that $\\phi(x)$ takes values in $\\Bbb R^d$).\nTaking a gradient with respect to $x$ gives:\n\\begin{equation}\n\\frac{d\\nabla_x\\phi(x)}{dt} = \\sum_{j=1}^N \\underbrace{\\eta_j}_{d\\times 1} \\underbrace{\\{ \\nabla_{\\phi(x)}R(\\phi(x),\\kappa_j)\\}}_{1\\times d} \\underbrace{ \\nabla_x {\\phi(x)}}_{d\\times d}\n\\end{equation}\n\n\n%%%%%%%\n\\subsection{Perturbing $\\eta$ and $\\kappa$ at $t=0$}\nNotice that since the full path of $\\eta$ and $\\kappa$ is determined at time $t=0$ one can perturb these values at time zero  $\\eta^0+\\epsilon \\delta \\eta^0$ and $\\kappa^0+ \\epsilon \\delta \\kappa^0$. If $\\epsilon$ is infinitesimal, this results in perturbations $\\delta \\kappa$, $\\delta \\eta$ at all times.\nTaking the derivatives (with respect to $\\epsilon$) on both sides of (\\ref{updateEta}) and (\\ref{updateKnots}) one gets the following linear ODE characterization of $\\delta\\eta$\n%\\begin{align}\n%\\frac{d\\delta \\eta_i}{dt} &= -\\sum_{j=1}^N \\delta\\eta_i \\,  \\eta_j R^{(1,0)}(\\kappa_i,\\kappa_j) +  {\\delta\\eta_j}\\,  \\eta_i R^{(1,0)}(\\kappa_i,\\kappa_j) \\nonumber \\\\\n%&\\qquad - \\sum_{j=1}^N \\delta\\kappa_i\\, {\\eta_i}  \\eta_j R^{(2,0)}(\\kappa_i,\\kappa_j)+ \\delta\\kappa_j\\, {\\eta_i}  \\eta_j R^{(1,1)}(\\kappa_i,\\kappa_j).\n%\\end{align}\n\\begin{align}\n\\frac{d\\delta \\eta_i}{dt} = -&\\sum_{j=1}^N \\bigl[ \\delta\\eta^T_i \\eta_j +\\eta^T_i \\delta\\eta_j    \\bigr] \\nabla^T_{\\kappa_i}R(\\kappa_i,\\kappa_j) \\\\\n&-\\sum_{j=1}^N \\eta^T_i \\eta_j  \\bigl[  \\{\\nabla^T_{\\kappa_i}\\nabla_{\\kappa_i}R(\\kappa_i,\\kappa_j)\\} \\delta\\kappa_i +  \\underbrace{ \\{\\nabla^T_{\\kappa_i}\\nabla_{\\kappa_j}R(\\kappa_i,\\kappa_j)\\} }_{d\\times d}\\delta\\kappa_j \\bigr].\n\\end{align}\nSimilarly one gets the following linear ODE characterization of $\\delta\\kappa$\n\\begin{align}\n\\frac{d\\delta\\kappa_i}{dt}=&\\sum_{j=1}^N \\delta\\eta_j\\, R(\\kappa_i,\\kappa_j) + \\eta_j \\bigl[ \\{\\nabla_{\\kappa_i} R(\\kappa_i,\\kappa_j)\\} \\delta\\kappa_i + \\{\\nabla_{\\kappa_j} R(\\kappa_i,\\kappa_j)\\} \\delta\\kappa_j   \\bigr].\n\\end{align}\nAt the map level one also gets perturbations $\\delta \\phi_\\ell$ and $\\delta \\nabla\\phi_\\ell$ (where $\\phi_\\ell := \\phi(X_\\ell)$ and $\\nabla\\phi_\\ell := \\nabla\\phi(X_\\ell)$ and $\\ell=1,\\ldots, n$) with initial conditions $\\delta \\phi_\\ell^0 \\equiv 0$ and  $\\delta \\nabla \\phi^0_\\ell \\equiv 0$.\nTo get these notice\n\\begin{align}\n\\frac{d\\delta\\phi_\\ell}{dt} &= \\sum_{j=1}^N \\delta\\eta_j R(\\phi_\\ell,\\kappa_j) +\\eta_j\\bigl[ \\{\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\} \\delta\\phi_\\ell   +  \\{\\nabla_{\\kappa_j}R(\\phi_\\ell,\\kappa_j)\\} \\delta\\kappa_j  \\bigr]\n\\end{align}\nFinally we get\n\\begin{align}\n\\frac{d\\delta\\nabla\\phi_\\ell}{dt}\n&= \\sum_{j=1}^N  \\delta\\eta_j  \\{ \\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\} \\nabla{\\phi}_\\ell   \\\\\n&+ \\sum_{j=1}^N \\eta_j \\bigl\\{ \\underbrace{\\delta\\phi^T_\\ell}_{1\\times d} \\underbrace{[\\nabla_{\\phi_\\ell}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)]}_{d\\times d} +   \\delta\\kappa_j^T [\\nabla_{\\kappa_j}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)]     \\bigr\\} \\underbrace{\\nabla {\\phi_\\ell}}_{d\\times d}  \\\\\n&+ \\sum_{j=1}^N \\eta_j \\{ \\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\} \\delta\\nabla {\\phi}_\\ell\n\\end{align}\n\n\\subsection{Simplify the ode flow for $(\\delta \\eta,\\delta \\kappa, \\delta \\phi, \\delta \\nabla \\phi)$}\n\\label{simplifiedODE}\nLet's simplify the above ode's to expose the linear structure.\n\nHere is the equation for $\\delta \\eta_i$:\n\\begin{align*}\n\\frac{d\\delta \\eta_i}{dt} &= \\sum_{j=1}^N \\underbrace{ \\bigl[ \\nabla^T_{\\kappa_i}R(\\kappa_i,\\kappa_j)\\bigr]}_{d\\times 1} \\underbrace{\\bigl[-  \\eta_j^T   \\bigr]}_{1\\times d}\\delta\\eta_i  \\\\\n&+ \\sum_{j=1}^N  \\bigl[\\nabla^T_{\\kappa_i}R(\\kappa_i,\\kappa_j)\\bigr] \\bigl[- \\eta^T_i     \\bigr]\\delta\\eta_j\\\\\n&+\\sum_{j=1}^N \\bigl[-\\eta^T_i \\eta_j\\bigr]  \\bigl[  \\nabla^T_{\\kappa_i}\\nabla_{\\kappa_i}R(\\kappa_i,\\kappa_j)  \\bigr]\\delta\\kappa_i \\\\\n&+\\sum_{j=1}^N {\\bigl[-\\eta^T_i \\eta_j\\bigr]}  \\bigl[   \\underbrace{ \\{\\nabla^T_{\\kappa_i}\\nabla_{\\kappa_j}R(\\kappa_i,\\kappa_j)\\} }_{d\\times d}\\bigr]\\delta\\kappa_j .\n\\end{align*}\n\n\nHere is the equation for $\\delta \\kappa_i$:\n\\begin{align*}\n\\frac{d\\delta\\kappa_i}{dt}&=\\sum_{j=1}^N  \\bigl[R(\\kappa_i,\\kappa_j)\\bigr] \\delta\\eta_j  \\\\\n&+\\sum_{j=1}^N \\underbrace{\\bigl[\\eta_j\\bigr]}_{d\\times 1} \\underbrace{\\bigl[ \\nabla_{\\kappa_i} R(\\kappa_i,\\kappa_j)\\bigr]}_{1\\times d} \\delta\\kappa_i \\\\\n&+\\sum_{j=1}^N \\bigl[\\eta_j\\bigr] \\bigl[ \\nabla_{\\kappa_j} R(\\kappa_i,\\kappa_j) \\bigr] \\delta\\kappa_j.\n\\end{align*}\nHere is the equation for $\\delta \\phi_\\ell$:\n\\begin{align}\n\\frac{d\\delta\\phi_\\ell}{dt} &= \\sum_{j=1}^N \\bigl[R(\\phi_\\ell,\\kappa_j)\\bigr] \\delta\\eta_j  \\\\\n&+ \\sum_{j=1}^N \\underbrace{\\bigl[\\eta_j\\bigr]}_{d\\times 1} \\underbrace{\\bigl[ \\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{1\\times d}  \\delta\\phi_\\ell \\\\\n& + \\sum_{j=1}^N \\bigl[\\eta_j\\bigr]\\bigl[   \\nabla_{\\kappa_j}R(\\phi_\\ell,\\kappa_j) \\bigr] \\delta\\kappa_j .\n\\end{align}\n\nWe can write the matrix $\\nabla \\phi^t(X_\\ell)$ as $\\bigl[\\partial_{x_1}\\phi^t(X_\\ell), \\ldots,\\partial_{x_d}\\phi^t(X_\\ell )\\bigr]$ where for each $p=1,\\ldots, d$ the quantity $\\partial_{x_p}\\phi^t(X_\\ell)$ is a column vector. Therefore\n\\begin{align*}\n\\frac{d\\delta\\partial_{x_p}\\phi_\\ell}{dt}\n&= \\sum_{j=1}^N\\underbrace{\\bigl[ \\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{1\\times d} \\underbrace{\\bigl[\\partial_{x_p}{\\phi}_\\ell \\bigr]}_{d \\times 1}  \\delta\\eta_j \\\\\n&+ \\sum_{j=1}^N \\underbrace{\\bigl[ \\eta_j\\bigr]}_{d\\times 1} \\underbrace{\\bigl[\\partial_{x_p} {\\phi_\\ell^T}\\bigr]}_{1\\times d} \\underbrace{\\bigl[\\nabla_{\\phi_\\ell}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times d}  \\delta\\phi_\\ell  \\\\\n&+ \\sum_{j=1}^N \\underbrace{\\bigl[\\eta_j\\bigr]}_{d\\times 1}   \\underbrace{\\bigl[\\partial_{x_p} {\\phi_\\ell^T}\\bigr]}_{1\\times d}  \\underbrace{\\bigl[\\nabla^T_{\\phi_\\ell}\\nabla_{\\kappa_j}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times d}  \\delta\\kappa_j    \\\\\n&+ \\sum_{j=1}^N \\underbrace{\\bigl[\\eta_j\\bigr]}_{d\\times 1} \\underbrace{\\bigl[ \\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{1\\times d} \\delta\\partial_{x_p} {\\phi}_\\ell\n\\end{align*}\n\n\n%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%\n\\subsection{Transpose flow when  $v^t(x)=\\sum_{j=1}^N \\eta^t_j R(x,\\kappa^t_j) $ on $\\Bbb R^1$}\n\nThe previous equations give the forward flow\n\\begin{equation}\n\\frac{d}{dt} \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta \\nabla\\phi^t   \\end{array}\\right]\n= U_t  \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\nabla\\phi^t   \\end{array}\\right]\n\\end{equation}\nNow we need to derive the transpose flow\n\\begin{equation}\n\\label{simSys}\n\\frac{d}{dt} \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta \\nabla\\phi^t   \\end{array}\\right]\n= -U_t^T  \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\nabla\\phi^t   \\end{array}\\right]\n\\end{equation}\nwhere $U_t$ is a matrix which depends on $\\eta^t_i, \\kappa^t_i, \\phi^t(X_\\ell) $ and $\\nabla\\phi^t(X_\\ell)$ but not on  $\\delta\\eta^t, \\delta\\kappa^t, \\delta\\phi^t(X_\\ell), \\delta \\nabla\\phi^t(X_\\ell)$.\nBefore we derive the transpose flow lets simplify the system (\\ref{simSys}). Notice that by examining the equation given in Section \\ref{simplifiedODE} we get the following block for of the matrix $U_{t}$\n\\begin{equation}\n\\frac{d}{dt} \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\partial_{x_1} \\phi^t  \\\\ \\vdots \\\\ \\delta\\partial_{x_d} \\phi^t   \\end{array}\\right]\n=\n\\begin{bmatrix}\nU_{\\eta,\\eta} & U_{\\eta,\\kappa} & 0 &  0 & \\cdots  &  0\\\\\nU_{\\kappa,\\eta} & U_{\\kappa,\\kappa} & 0 &  0 & \\cdots  &  0\\\\\nU_{\\phi,\\eta} & U_{\\phi,\\kappa} & U_{\\phi,\\phi} & 0 & \\cdots  &  0\\\\\nU_{\\partial_{x_1} \\phi,\\eta} & U_{\\partial_{x_1} \\phi,\\kappa} & U_{\\partial_{x_1} \\phi,\\phi} & U_{\\partial_{x_1} \\phi,\\partial_{x_1} \\phi} & \\cdots  & 0 \\\\\n&&\\vdots & &\\diagdown& \\\\\nU_{\\partial_{x_d} \\phi,\\eta} & U_{\\partial_{x_d} \\phi,\\kappa} & U_{\\partial_{x_d} \\phi,\\phi} & 0 & \\cdots  & U_{\\partial_{x_d} \\phi,\\partial_{x_d} \\phi}\n\\end{bmatrix}\n  \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\partial_{x_1} \\phi^t \\\\ \\vdots \\\\ \\delta\\partial_{x_d} \\phi^t \\end{array}\\right]\n\\end{equation}\nwhere $U_{\\kappa,\\eta}= \\bigl[ R(\\kappa_i,\\kappa_j) \\bigr]_{i,j}$ for example. Now the transpose flow is given by \\textcolor{red}{I think I need a minus sign in the equation below...}\n\\begin{equation}\n\\frac{d}{dt} \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\partial_{x_1} \\phi^t  \\\\ \\vdots \\\\ \\delta\\partial_{x_d} \\phi^t   \\end{array}\\right]\n=\n\\begin{bmatrix}\nU_{\\eta,\\eta}^T   & U_{\\kappa,\\eta}^T & U_{\\phi,\\eta}^T &  U_{\\partial_{x_1} \\phi,\\eta}^T & \\cdots  &  U_{\\partial_{x_d} \\phi,\\eta}^T \\\\\nU_{\\eta,\\kappa}^T & U_{\\kappa,\\kappa}^T & U_{\\phi,\\kappa}^T &  U_{\\partial_{x_1} \\phi,\\kappa}^T & \\cdots  &  U_{\\partial_{x_d} \\phi,\\kappa}^T\\\\\n0 & 0 & U_{\\phi,\\phi}^T & U_{\\partial_{x_1} \\phi,\\phi}^T & \\cdots  &  U_{\\partial_{x_d} \\phi,\\phi}^T\\\\\n0 & 0 & 0 & U_{\\partial_{x_1} \\phi,\\partial_{x_1} \\phi}^T & \\cdots  & 0 \\\\\n&&\\vdots & &\\diagdown& \\\\\n0 & 0 &0 & 0 & \\cdots  & U_{\\partial_{x_d} \\phi,\\partial_{x_d} \\phi} ^T\n\\end{bmatrix}\n  \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\partial_{x_1} \\phi^t \\\\ \\vdots \\\\ \\delta\\partial_{x_d} \\phi^t \\end{array}\\right]\n\\end{equation}\nTo unpack this matrix representation of the transpose flow lets start by interpreting the equation for $\\delta\\partial_{x_p} \\phi^t$:\n\\begin{align}\n\\frac{d\\delta\\partial_{x_p}\\phi_\\ell}{dt}\n=&   \\text{ $\\ell^{\\text{th}}$ segment of: $U_{\\partial_{x_p} \\phi,\\partial_{x_p} \\phi} ^T\\delta\\partial_{x_p}\\phi$}\n= \\sum_{j=1}^N \\underbrace{\\bigl[ \\nabla^T_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times 1} \\underbrace{\\bigl[\\eta_j^T\\bigr]}_{1\\times d}  \\delta\\partial_{x_p} {\\phi}_\\ell\n\\end{align}\nnotice that I didn't switch the $i$ and the $j$ here.\n\\begin{align}\n\\frac{d\\delta\\phi_\\ell}{dt} &= \\text{ $\\ell^{\\text{th}}$ segment of: } U_{\\phi,\\phi}^T\\delta\\phi  + U_{\\partial_{x_1} \\phi,\\phi}^T\\delta\\partial_{x_1} \\phi + \\cdots  +  U_{\\partial_{x_d} \\phi,\\phi}^T\\delta\\partial_{x_d} \\phi \\\\\n&=  \\sum_{j=1}^N  \\underbrace{\\bigl[ \\nabla^T_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times 1}\\underbrace{\\bigl[\\eta_j^T\\bigr]}_{1\\times d} \\delta\\phi_\\ell \\\\\n&\\quad+\\sum_{j=1}^N \\underbrace{\\bigl[\\nabla_{\\phi_\\ell}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times d} \\underbrace{\\bigl[\\partial_{x_1} {\\phi_\\ell}\\bigr]}_{d\\times 1} \\underbrace{\\bigl[ \\eta_j^T\\bigr]}_{1\\times d} \\delta\\partial_{x_1} \\phi_\\ell \\\\\n &\\qquad\\vdots \\nonumber\\\\\n &\\quad+ \\sum_{j=1}^N \\underbrace{\\bigl[\\nabla_{\\phi_\\ell}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_j)\\bigr]}_{d\\times d} \\underbrace{\\bigl[\\partial_{x_d} {\\phi_\\ell}\\bigr]}_{d\\times 1} \\underbrace{\\bigl[ \\eta_j^T\\bigr]}_{1\\times d} \\delta \\partial_{x_d}  \\phi_\\ell\n\\end{align}\nFor the transpose flow for $\\kappa$ we get\n\\begin{align}\n\\frac{d\\delta\\kappa_i}{dt} &= \\text{ $i^{\\text{th}}$ segment of: }U_{\\eta,\\kappa}^T\\delta\\eta + U_{\\kappa,\\kappa}^T\\delta\\kappa + U_{\\phi,\\kappa}^T\\delta\\phi +  U_{\\partial_{x_1} \\phi,\\kappa}^T\\delta\\partial_{x_1} \\phi + \\cdots  +  U_{\\partial_{x_d} \\phi,\\kappa}^T\\delta\\partial_{x_d} \\phi \\\\\n&= \\sum_{j=1}^N  \\bigl[  \\nabla^T_{\\kappa_i}\\nabla_{\\kappa_i}R(\\kappa_i,\\kappa_j)  \\bigr] \\bigl[-\\eta^T_i \\eta_j\\bigr] \\delta\\eta_i +\\sum_{j=1}^N   \\bigl[   \\underbrace{ \\{\\nabla^T_{\\kappa_i}\\nabla_{\\kappa_j}R(\\kappa_j,\\kappa_i)\\} }_{d\\times d}\\bigr]{\\bigl[-\\eta^T_i \\eta_j\\bigr]}\\delta\\eta_j  \\\\\n&\\quad+\\sum_{j=1}^N  \\underbrace{\\bigl[ \\nabla^T_{\\kappa_i} R(\\kappa_i,\\kappa_j)\\bigr]}_{d\\times 1} \\underbrace{\\bigl[\\eta_j^T\\bigr]}_{1\\times d} \\delta\\kappa_i +\\sum_{j=1}^N \\bigl[ \\nabla_{\\kappa_i}^T R(\\kappa_j,\\kappa_i) \\bigr]  \\bigl[\\eta_i^T\\bigr] \\delta\\kappa_j \\\\\n&\\quad  + \\sum_{\\ell=1}^N \\bigl[   \\nabla^T_{\\kappa_i}R(\\phi_\\ell,\\kappa_i) \\bigr] \\bigl[\\eta_i^T\\bigr]\\delta\\phi_\\ell \\\\\n&\\quad + \\sum_{\\ell=1}^N \\underbrace{\\bigl[\\nabla_{\\kappa_i}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_i)\\bigr]}_{d\\times d}     \\underbrace{\\bigl[\\partial_{x_1} {\\phi_\\ell}\\bigr]}_{d\\times 1}  \\underbrace{\\bigl[\\eta_i^T\\bigr]}_{1 \\times d}  \\delta\\partial_{x_1}\\phi_\\ell  \\\\\n &\\qquad\\vdots \\nonumber\\\\\n&\\quad + \\sum_{\\ell=1}^N \\underbrace{\\bigl[\\nabla_{\\kappa_i}^T\\nabla_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_i)\\bigr]}_{d\\times d}     \\underbrace{\\bigl[\\partial_{x_d} {\\phi_\\ell}\\bigr]}_{d\\times 1}  \\underbrace{\\bigl[\\eta_i^T\\bigr]}_{1 \\times d}  \\delta\\partial_{x_d}\\phi_\\ell .\n\\end{align}\nFinally, for $\\eta$ we get\n\\begin{align}\n\\frac{d\\delta\\eta_i}{dt} &= \\text{ $i^{\\text{th}}$ segment of: }  U_{\\eta,\\eta}^T\\delta\\eta + U_{\\kappa,\\eta}^T\\delta\\kappa + U_{\\phi,\\eta}^T\\delta\\phi +  U_{\\partial_{x_1} \\phi,\\eta}^T\\delta\\partial_{x_1} \\phi + \\cdots  +  U_{\\partial_{x_d} \\phi,\\eta}^T\\delta\\partial_{x_d} \\phi \\\\\n&=   \\sum_{j=1}^N  \\underbrace{\\bigl[-  \\eta_j   \\bigr]}_{d\\times 1} \\underbrace{ \\bigl[ \\nabla_{\\kappa_i}R(\\kappa_i,\\kappa_j)\\bigr]}_{1\\times d} \\delta\\eta_i  + \\sum_{j=1}^N  \\bigl[- \\eta_j     \\bigr] \\bigl[\\nabla_{\\kappa_j}R(\\kappa_j,\\kappa_i)\\bigr] \\delta\\eta_j   \\\\\n&\\quad+\\sum_{j=1}^N  \\bigl[R(\\kappa_j,\\kappa_i)\\bigr] \\delta\\kappa_j  \\\\\n &\\quad+ \\sum_{\\ell=1}^N \\bigl[R(\\phi_\\ell,\\kappa_i)\\bigr] \\delta\\phi_\\ell \\\\\n &\\quad+\\sum_{\\ell=1}^N\\underbrace{\\bigl[\\partial_{x_1}{\\phi}_\\ell^T \\bigr]}_{1 \\times d}  \\underbrace{\\bigl[ \\nabla^T_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_i)\\bigr]}_{d\\times 1}  \\delta\\partial_{x_1}\\phi_\\ell\\\\\n &\\qquad\\vdots \\nonumber\\\\\n&\\quad+\\sum_{\\ell=1}^N\\underbrace{\\bigl[\\partial_{x_d}{\\phi}_\\ell^T \\bigr]}_{1 \\times d}  \\underbrace{\\bigl[ \\nabla^T_{\\phi_\\ell}R(\\phi_\\ell,\\kappa_i)\\bigr]}_{d\\times 1}  \\delta\\partial_{x_d}\\phi_\\ell\n\\end{align}\n\n\n\\paragraph{Deriving the transpose flow:}\nIt will be useful to write out how this flows forward in discrete time:\n\\begin{equation}\n\\label{forwardTT}\n \\left[\\begin{array}{c} \\delta\\eta^1_i\\\\ \\delta \\kappa^1_i \\\\ \\delta\\phi^1(X_\\ell) \\\\ \\delta \\nabla\\phi^1(X_\\ell)   \\end{array}\\right]\n = \\Bigl[I+\\epsilon U_{t_N} \\Bigr]\\times \\cdots \\times  \\Bigl[I+\\epsilon U_{t_0} \\Bigr]  \\left[\\begin{array}{c} \\delta\\eta^0_i\\\\ \\delta \\kappa^0_i \\\\ \\delta\\phi^0(X_\\ell) \\\\ \\delta \\nabla\\phi^0(X_\\ell)   \\end{array}\\right].\n\\end{equation}\nTo derive the transpose flow note the effect of the rate of change on the energy notice that when perturbing $\\eta^0_i$ and $\\kappa^0_i$ one gets a perturbation  $\\phi^t(X_\\ell) +\\epsilon \\delta \\phi^t(X_\\ell)$. Notice that $\\delta \\phi$ is a Eulerian specification of a flow field.  To switch to Lagrangian specification on defines $u^t(x)$ as satisfying the identity\n\\[ u^t (\\phi^t(x))=\\delta \\phi^t(x)\\]\nEarlier we derive the rate of change of the log likelihood at time $t=1$ with respect to Lagrangian coordinates as follows\n\\[  \\frac{1}{n} \\sum_{\\ell=1}^n \\text{div}\\, u (\\phi^1(X_\\ell)) + \\bigl\\langle \\nabla H (\\phi^1(X_\\ell)), u^1(\\phi^1(X_\\ell))\\bigr\\rangle.  \\]\n To switch to the Eulerian specification notice that $D\\delta \\phi^1 (x) =  Du^1 (\\phi^1(x)) D\\phi^1(x) $. Therefore $\\text{trace} ([D\\delta \\phi^1 (x)][ D\\phi^1(x)]^{-1} ) = \\text{trace}\\bigl( Du^1 (\\phi^1(x))\\bigr)  =  \\text{div}\\, u (\\phi^1(x))$ and hence the rate of change of the log likelihood can be computed as\n\\begin{equation}\n\\label{Eulerian}\n\\frac{1}{n} \\sum_{\\ell=1}^n \\text{trace} ([ D\\phi^1(X_\\ell)]^{-1} [D\\delta \\phi^1 (X_\\ell)]) + \\bigl\\langle \\nabla H (\\phi^1(X_\\ell)), \\delta \\phi^1(X_\\ell)\\bigr\\rangle\n\\end{equation}\n\n\\textcolor{red}{Don't forget about the regularization term}\n\nNot to see how to get the transpose flow notice that equation (\\ref{Eulerian}) shows that\n\\begin{align*}\n\\frac{d}{d\\epsilon}\\Bigr|_{\\epsilon = 0}& \\text{loglike}(\\eta_i^0+\\epsilon \\delta \\eta_i^0, \\kappa^0_i+\\epsilon \\delta \\kappa_i^0) \\\\\n&=\\underbrace{ \\left[ 0,0,\\frac{\\nabla H (\\phi^1(X_\\ell))}{n}, \\frac{[\\nabla\\phi^1(X_\\ell)]^{-1}}{n}  \\right]}_{\\text{ the gradient w.r.t the parameters at time $t=1$}} \\left[\\begin{array}{c} \\delta\\eta^1_i\\\\ \\delta \\kappa^1_i \\\\ \\delta\\phi^1(X_\\ell) \\\\ \\delta \\nabla\\phi^1(X_\\ell)   \\end{array}\\right] \\\\\n&\\underset{=}{ \\text{by (\\ref{forwardTT})}} \\underbrace{ \\left[ 0,0,\\frac{\\nabla H (\\phi^1(X_\\ell))}{n}, \\frac{[\\nabla\\phi^1(X_\\ell)]^{-1}}{n}  \\right] \\Bigl[I+\\epsilon U_{t_N} \\Bigr]\\times \\cdots \\times  \\Bigl[I+\\epsilon U_{t_0} \\Bigr] }_{\\text{ the gradient w.r.t the parameters at time $t=0$}}  \\left[\\begin{array}{c} \\delta\\eta^0_i\\\\ \\delta \\kappa^0_i \\\\ \\delta\\phi^0(X_\\ell) \\\\ \\delta \\nabla\\phi^0(X_\\ell)   \\end{array}\\right]\n\\end{align*}\nNow to compute the gradient w.r.t the parameters at time $t=0$, call it $\\nabla \\ell^0$, one can take a transpose:\n\\begin{equation}\n\\label{oouoo}\n\\nabla \\ell^0 =\\Bigl[I+\\epsilon U_{t_0}^T \\Bigr]\\times \\cdots \\times \\Bigl[I+\\epsilon U_{t_N}^T \\Bigr] \\left[ 0,0,\\frac{\\nabla H (\\phi^1(X_\\ell))}{n}, \\frac{[\\nabla\\phi^1(X_\\ell)]^{-1}}{n}  \\right]^T.\n\\end{equation}\nNotice that the above formula gives us a continuos ODE flow for the likelihood as follows:\n\\begin{equation}\n\\label{likeforward}\n\\frac{d}{dt} \\nabla\\ell^t = -U_t^T   \\nabla\\ell^t\n\\end{equation}\nwith initial condition set at time $t=1$ as follows $ \\nabla\\ell^1 = \\left[ 0,0,\\frac{\\nabla H (\\phi^1(X_\\ell))}{n}, \\frac{[\\nabla\\phi^1(X_\\ell)]^{-1}}{n}  \\right]^T$. Indeed, to flow (\\ref{likeforward}) forward in time one would use the formula: $\\nabla \\ell^{t+\\epsilon} = \\nabla \\ell^{t} + \\epsilon  [-U_t^T]   \\nabla\\ell^t$. To flow  (\\ref{likeforward}) backward in time one would use the formula: $\\nabla \\ell^{t-\\epsilon} = \\nabla \\ell^{t} - \\epsilon  [-U_t^T]   \\nabla\\ell^t = (I + \\epsilon  U_t^T)  \\nabla\\ell^t$ which has discrete analog:\n\\[ \\nabla \\ell^{t_0} =  [I + \\epsilon  U_{t_{0}}^T]\\times\\cdots\\times [I + \\epsilon  U_{t_N}^T] \\nabla\\ell^{t_N}\n\\]\nwhich agrees with (\\ref{oouoo}).\n\\begin{algorithm}[h!]\n\\caption{Compute the gradient of the log likelihood at initial $\\eta_\\text{\\tiny init},\\kappa_\\text{\\tiny init}$}\n\\label{alg2}\n\\begin{algorithmic}[1]\n\\STATE {Solve $(\\eta^t,\\kappa^t, \\phi^t, \\nabla \\phi^t)^T$ {\\it forward in time},  starting at $t=0$ and finishing at $t=1$, with the ODE given in equations. Use initial conditions $(\\eta^0,\\kappa^0,\\phi^0_i, \\nabla \\phi_i^0)^T= (\\eta_\\text{\\tiny init},\\kappa_\\text{\\tiny init}, X_i, I)^T$.}\n\\STATE{Solve $(\\delta\\eta^t,\\delta\\kappa^t, \\delta\\phi^t, \\delta\\nabla \\phi^t)^T$ {\\it backward in time}, starting at $t=1$ and finishing at $t=0$, by running the ODE\n\\begin{equation}\n\\frac{d}{dt} \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta \\nabla\\phi^t   \\end{array}\\right]\n= -U_t^T  \\left[\\begin{array}{c} \\delta\\eta^t\\\\ \\delta \\kappa^t \\\\ \\delta\\phi^t \\\\ \\delta\\nabla\\phi^t   \\end{array}\\right]\n\\end{equation}\nwith initial conditions\n$(\\delta \\eta^1,\\delta \\kappa^1, \\delta\\phi^1, \\delta{\\nabla \\phi}^1)^T:= \\bigl(0,0,{\\nabla H (\\phi^1(X_\\ell))}/{n}, {[\\nabla\\phi^1(X_\\ell)]^{-1}}/{n}\\bigr ) $. Note: you will need to simultaniously  solve $(\\eta^t,\\kappa^t, \\phi^t, \\nabla \\phi^t)^T$ {\\it backward in time} down from $t=1$  to compute $U_t$.}\n\\STATE{Return: $\\delta\\eta_\\text{\\tiny init} = \\delta \\eta^0$ and $\\delta\\kappa_\\text{\\tiny init} = \\delta \\kappa^0$.}\n\\end{algorithmic}\n\\end{algorithm}\n\n\n%\n{\\flushleft\\textcolor{blue}{$\\uparrow$------------end long version---------}}\\newline\n} \\fi\n%%------------------------------ end long version\n\n\n\\bibliography{refs}\n\n\\end{document}\n", "meta": {"hexsha": "96fd24b6a0b2fc5bdf71b667c3d27a5c1208a45b", "size": 133483, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/MultiDefDensity.tex", "max_stars_repo_name": "EthanAnderes/MleDensityWarp", "max_stars_repo_head_hexsha": "25b6cb971bb086e61bdef88e9cb2d545da8cb8eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/MultiDefDensity.tex", "max_issues_repo_name": "EthanAnderes/MleDensityWarp", "max_issues_repo_head_hexsha": "25b6cb971bb086e61bdef88e9cb2d545da8cb8eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/MultiDefDensity.tex", "max_forks_repo_name": "EthanAnderes/MleDensityWarp", "max_forks_repo_head_hexsha": "25b6cb971bb086e61bdef88e9cb2d545da8cb8eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.1074766355, "max_line_length": 1085, "alphanum_fraction": 0.6729171505, "num_tokens": 47344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.41498492418780636}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROBLEM 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{Problem 2}\n\nThree unknown fission products $A$, $B$ and $C$ are produced by a reactor. \n$B$ is stable and has a very large absorption cross section at the energies found in the reactor. \nThe population of isotope $B$ is fed by other known fission products. \nIsotope $C$ decays relatively quickly into isotope $A$, which then decays again in short order. \n$C$ has a neglible absorption cross section, while $A$'s cross section is large. \n\nFor each isotope, plot the behavior of the isotope's concentration after the reactor is turned on, left for a long time, then first dropped to some non-zero power, and finally shut-down.\n\n", "meta": {"hexsha": "d10a83587a0aad1c4a89fcf3dd854a824f576e80", "size": 716, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/drafts/disc13/disc13_exercise02.tex", "max_stars_repo_name": "mitchnegus/NE150-discussion", "max_stars_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercises/drafts/disc13/disc13_exercise02.tex", "max_issues_repo_name": "mitchnegus/NE150-discussion", "max_issues_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercises/drafts/disc13/disc13_exercise02.tex", "max_forks_repo_name": "mitchnegus/NE150-discussion", "max_forks_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.6666666667, "max_line_length": 186, "alphanum_fraction": 0.688547486, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.41493311159247626}}
{"text": "\\section{Queuing Model (90 pts)\\label{sec:7}}\n\n    The last section concentrates on theoretical foundations. We apply different modelling techniques and observe how\n    the real system's results differ from computed ones. Explanations for discrepancies and overlaps between computed\n    values and measured results are given.\n\n    This section includes the M/M/1 and M/M/m model (which use data from experiment \\ref{sec:4} as the basis) as well as\n    a network of queues which tries to attain results for configurations of experiment \\ref{sec:3}.\n\n    For M/M/1 and M/M/m models the following parameters are part of the system.\n\n    Input Parameters:\n    \\begin{itemize}\n        \\item $\\mu$: The service rate of the system. It is calculated from the maximally observed average throughput\n              from any single run for a given amount of worker threads in experiment \\ref{sec:4} disregarding the\n              response time reported. This number is divided by twice the number of worker threads for M/M/m models. The\n              actual value used is documented in the respective table.\n        \\item $\\lambda$: The arrival rate of jobs. It is taken directly from observed results of the average throughput\n              for both middlewares for all repetitions of an experiment. This number is included in the table as well.\n        \\item $m$: The number of services. It is only relevant for the M/M/m models. The service count is double the\n              amount of worker threads configured as two \\mw{}s are used.\n    \\end{itemize}\n\n    Output Parameters:\n    \\begin{itemize}\n        \\item $\\rho$: The traffic intensity. For the M/M/m model this is equivalent to $U$, the average utilization of\n              each server.\n        \\item $\\mathbb{E}[n]$: Expected number of jobs in the system.\n        \\item $\\mathbb{E}[n_q]$: Expected number of jobs in the queue.\n        \\item $\\mathbb{E}[w]$: Expected waiting time for elements in the queue.\n        \\item $\\mathbb{E}[r]$: Expected response time of the system.\n        \\item $p_0$: Probability of zero jobs in the system. Only relevant for the M/M/m model.\n        \\item $\\varrho$: Probability of queueing. Only relevant for the M/M/m model.\n    \\end{itemize}\n\n    Choosing the service rate and arrival rate as described gives for all following calculations the guarantee that\n    $\\rho < 1$ holds as the averaged throughput for all repetitions is expected to be lower than any maximally\n    observed value. This is a stability parameter which needs to hold for calculations to be valid as the system would\n    otherwise not be fulfilling the requirements of an M/M/1 or M/M/m model.\n\n    \\subsection{M/M/1\\label{subsec:7_mm1}}\n        The M/M/1 model is a simple model which is based on the idea of only containing a single queue and service. Jobs to\n        this system arrive with a mean arrival rate of $\\lambda$ and are processed by the service with the mean service\n        rate $\\mu$.\n\n        In table \\ref{tab:mm1} the computed results for all combinations of worker threads with clients are presented\n        for the M/M/m model. Comparing the received numbers with measured data it becomes clear this model is\n        insufficient to describe the real system's behaviour.\n\n        The following observations are made:\n\n        \\begin{enumerate}\n            \\item The trend to a decreased response time for more worker threads to various amounts of utilizations\n                  matches for both, the M/M/1 model and the real system. It can be observed that the model predicts\n                  response times more to either extreme, either too low or too high yet a reasonable amount of\n                  overlapping cases exist. All of them are in the area of 99\\% utilization. This shows a very narrow\n                  region of prediction and thusly is not a great model to predict real system behaviour. The response\n                  time the model predicts is compared with the response time of the middleware to a request sent out by\n                  memtier.\n            \\item The queue times are in direct correlation to the response times in this model and as such coupled\n                  together. This shows in the model predictions where the queue times are in many cases a couple hundred\n                  microseconds quicker than the respective response time. This estimate is not valid in the real model\n                  as network communication is not modelled. The real system must not only process the packet it must\n                  also distribute the SET requests to each \\srv{} connected, wait for replies and then send back the\n                  response to memtier. This is simply not modelled by M/M/1.\n            \\item The queue sizes show also a trend towards smaller sizes for more clients with increasing amounts of\n                  worker threads. Queues are mostly modelled too large compared with the real system and therefore\n                  overestimate the amount of queueing. This is expected as a single queue is used by the model. As such\n                  the observation of the number of elements in the system being larger by at most one element compared\n                  to the number of queues can be explained.\\newline\n                  The trend is stems from the model's formulae. The queue size is only determined by $\\rho$ and as such\n                  actually independent of the number of clients and worker threads. This also shows in some predictions\n                  such as 192 and 288 clients for 32 worker threads having larger queues than 16 and 8 worker threads.\n            \\item As can be seen, the estimated number of jobs is always at most one larger than the queue size. This is\n                  a fragment of the model's base design and is clearly not reflected by the real system's behaviour\n                  where multiple workers are active.\n        \\end{enumerate}\n\n        The model is at most a basic approximation as it is a sequential, single queue with a single service actor\n        whereas the middleware is a model of multiple concurrent services with two queues.\n\n        \\begin{table}\n            \\footnotesize{\n                \\begin{tabular}{lllrrrrrrrrrrrr}\n                    \\toprule\n                    & & & & & \\multicolumn{2}{c}{$\\mathbb{E}[n_q]$} & \\multicolumn{2}{c}{$\\mathbb{E}[w]$} & \\multicolumn{2}{c}{$\\mathbb{E}[r]$} & \\\\\n                    \\cmidrule(lr){6-7}\n                    \\cmidrule(lr){8-9}\n                    \\cmidrule(lr){10-11}\n                    Clients  & WT & $\\mu$    & $\\lambda$ & $\\rho$ & Est.   & Act.   & Est.  & Act.  & Est.  & Act.  & $\\mathbb{E}[n]$ \\\\\n                    \\midrule\n                    6        & 8  & 6750.87  & 2840.73   & 0.42   & 0.31   & 0.09   & 0.11  & 0.06  & 0.26  & 1.31  & 0.73            \\\\\n                             & 16 & 8716.58  & 2841.71   & 0.33   & 0.16   & 0.08   & 0.06  & 0.06  & 0.17  & 1.32  & 0.48            \\\\\n                             & 32 & 10385.53 & 2804.17   & 0.27   & 0.10   & 0.09   & 0.04  & 0.06  & 0.13  & 1.34  & 0.37            \\\\\n                             & 64 & 11582.18 & 2795.49   & 0.24   & 0.08   & 0.09   & 0.03  & 0.07  & 0.11  & 1.38  & 0.32            \\\\\n                    \\addlinespace\n                    12       & 8  & 6750.87  & 4967.22   & 0.74   & 2.05   & 0.21   & 0.41  & 0.08  & 0.56  & 1.62  & 2.78            \\\\\n                             & 16 & 8716.58  & 4912.86   & 0.56   & 0.73   & 0.21   & 0.15  & 0.08  & 0.26  & 1.64  & 1.29            \\\\\n                             & 32 & 10385.53 & 4916.40   & 0.47   & 0.43   & 0.21   & 0.09  & 0.08  & 0.18  & 1.64  & 0.90            \\\\\n                             & 64 & 11582.18 & 4838.18   & 0.42   & 0.30   & 0.21   & 0.06  & 0.09  & 0.15  & 1.69  & 0.72            \\\\\n                    \\addlinespace\n                    24       & 8  & 6750.87  & 5955.95   & 0.88   & 6.61   & 2.12   & 1.11  & 0.71  & 1.26  & 3.13  & 7.49            \\\\\n                             & 16 & 8716.58  & 6153.06   & 0.71   & 1.69   & 0.48   & 0.28  & 0.16  & 0.39  & 3.00  & 2.40            \\\\\n                             & 32 & 10385.53 & 6152.46   & 0.59   & 0.86   & 0.46   & 0.14  & 0.15  & 0.24  & 3.01  & 1.45            \\\\\n                             & 64 & 11582.18 & 6065.54   & 0.52   & 0.58   & 0.47   & 0.09  & 0.15  & 0.18  & 3.06  & 1.10            \\\\\n                    \\addlinespace\n                    48       & 8  & 6750.87  & 6680.07   & 0.99   & 93.37  & 12.72  & 13.98 & 3.81  & 14.12 & 6.25  & 94.36           \\\\\n                             & 16 & 8716.58  & 8187.97   & 0.94   & 14.55  & 4.80   & 1.78  & 1.17  & 1.89  & 4.81  & 15.49           \\\\\n                             & 32 & 10385.53 & 8378.60   & 0.81   & 3.37   & 1.24   & 0.40  & 0.30  & 0.50  & 4.65  & 4.17            \\\\\n                             & 64 & 11582.18 & 8169.17   & 0.71   & 1.69   & 1.29   & 0.21  & 0.32  & 0.29  & 4.77  & 2.39            \\\\\n                    \\addlinespace\n                    96       & 8  & 6750.87  & 6664.63   & 0.99   & 76.29  & 36.64  & 11.45 & 11.01 & 11.60 & 13.45 & 77.28           \\\\\n                             & 16 & 8716.58  & 8616.11   & 0.99   & 84.77  & 27.00  & 9.84  & 6.27  & 9.95  & 10.03 & 85.76           \\\\\n                             & 32 & 10385.53 & 10010.38  & 0.96   & 25.72  & 10.18  & 2.57  & 2.03  & 2.67  & 8.09  & 26.68           \\\\\n                             & 64 & 11582.18 & 9935.81   & 0.86   & 5.18   & 3.54   & 0.52  & 0.72  & 0.61  & 7.87  & 6.03            \\\\\n                    \\addlinespace\n                    192      & 8  & 6750.87  & 6690.24   & 0.99   & 109.35 & 84.64  & 16.35 & 25.32 & 16.49 & 27.76 & 110.34          \\\\\n                             & 16 & 8716.58  & 8626.25   & 0.99   & 94.51  & 74.92  & 10.96 & 17.38 & 11.07 & 21.13 & 95.50           \\\\\n                             & 32 & 10385.53 & 10327.79  & 0.99   & 177.87 & 55.18  & 17.22 & 10.69 & 17.32 & 16.93 & 178.87          \\\\\n                             & 64 & 11582.18 & 11251.22  & 0.97   & 33.02  & 19.76  & 2.94  & 3.51  & 3.02  & 14.20 & 34.00           \\\\\n                    \\addlinespace\n                    288      & 8  & 6750.87  & 6721.23   & 1.00   & 225.78 & 132.57 & 33.59 & 39.48 & 33.74 & 41.90 & 226.78          \\\\\n                             & 16 & 8716.58  & 8681.94   & 1.00   & 249.59 & 122.78 & 28.75 & 28.31 & 28.86 & 32.04 & 250.58          \\\\\n                             & 32 & 10385.53 & 10366.39  & 1.00   & 540.53 & 103.15 & 52.14 & 19.91 & 52.24 & 26.13 & 541.52          \\\\\n                             & 64 & 11582.18 & 11469.24  & 0.99   & 100.56 & 61.54  & 8.77  & 10.73 & 8.85  & 21.87 & 101.55          \\\\\n                    \\bottomrule\n                \\end{tabular}\n                \\caption{M/M/1 calculations for given configurations of Experiment 4 using the formulae listed in\n                         the book, Box 31.1. Numbers are rounded to two decimal places for presentation\n                         purposes which for the case of $\\rho$ makes the system seem unstable yet the actual numbers are\n                         $< 1$.\\label{tab:mm1}}\n            }\n        \\end{table}\n\n    \\subsection{M/M/m\\label{subsec:7_mmm}}\n        The M/M/m model is an extension to the M/M/1 model which still keeps the single queue but has $m$ services\n        acting on the queue. These services will be modelled by the amount of total worker threads in the system. With 2\n        \\mw{}s $m$ is set to double the value of worker threads (and not explicitly documented in the table).\n\n        In table \\ref{tab:mmm} the computed results for all combinations of worker threads with clients are presented\n        for the M/M/m model. Comparing the received numbers with measured data it becomes clear this model is still\n        insufficient to describe the real system's behaviour.\n\n        The following observations are made:\n\n        \\begin{enumerate}\n            \\item The response times in this model behave for low utilizations counter-intuitive where low utilization\n                  predicts for many workers a higher response time yet this trend not showing for high utilization. This\n                  is due to the fact that the workers amongst different configurations don't share the same service\n                  time. The service time for few workers is lower than for many workers (or as noted in the table many\n                  workers have fewer throughput per worker). It must be remembered that the parameter $\\mu$ comes from\n                  the real system and matches constraints on the real system. With the amount of threading that is close\n                  to the actual physical cores a better utilization is expected whereas for too much threading the\n                  system is mostly busy with scheduling overhead and other system maintenance. This reflects in higher\n                  throughput per thread. As the model numbers were obtained for the maximum throughput per configuration\n                  it is expected that model estimates for low utilization don't match but match much better for high\n                  amounts of utilization as can be inferred from the table. The model therefore ``adapts'' much better\n                  to the real system when they both converge in behaviour. It is of interesting note to see the\n                  predictions in many cases being below real system measurements. This also matches for the next\n                  parameter evaluated, the queue waiting time.\n            \\item This trend also follows for the queue waiting times and gives a much greater delta for estimated queue\n                  waiting times and response times. This is much more reasonable and begins to closer match the system\n                  behaviour as well for high utilization. For low degrees of utilization the models shows good degrees\n                  of approximation with the true system.\n            \\item The queue waiting times need to be evaluated with the constraints that the estimate is halved when\n                  compared to the real system as the model assumes one queue but the real system uses two. Even with\n                  this constraint the model varies too much to be able to make a statement of it agreeing with the real\n                  system. There are definitely overlaps but no definite pattern exists. As in the M/M/1 model this\n                  parameter is mostly inferred by the system utilization, the probability of queueing being an\n                  additional scaling factor.\n            \\item The probability of queueing goes up for more load (which is expected). The probability seem low\n                  compared to the actually observed queue-sizes for experiment \\ref{sec:4}, meaning queuing expectations\n                  should be converging earlier to 1 as queueing is definitely observed. Yet this would give a queue size\n                  estimation to the M/M/1 model, not what is reasonable.\n            \\item The probability of 0 jobs in the system is 0 for all experiments. This matches the expected reality.\n            \\item The elements in the system still correlate with the queue size and as has been discussed a reasonable\n                  statement cannot be made on the numbers obtained as for small workloads with high threading the number\n                  of expected jobs is too high.\n        \\end{enumerate}\n\n        Overall the model is better but not in the general case  as it may be parallel but still it uses a single queue\n        and the configuration is highly dependent on the service time given (it is fixed and doesn't align for low\n        system utilization inputs). The middleware uses multiple concurrent services (which adapt to a ceiling of\n        the worker thread configuration) but uses two, instead of one queue. Additionally this system merges the worker\n        threads and memcached into one virtual service, clearly not the actual system behaviour.\n\n        \\begin{table}\n            \\begin{adjustwidth}{-1cm}{}\n                \\footnotesize{\n                    \\begin{tabular}{lllrrrrrrrrrrrr}\n                        \\toprule\n                        & & & & & \\multicolumn{2}{c}{$\\mathbb{E}[n_q]$} & \\multicolumn{2}{c}{$\\mathbb{E}[w]$} & \\multicolumn{2}{c}{$\\mathbb{E}[r]$} & &  & & \\\\\n                        \\cmidrule(lr){6-7}\n                        \\cmidrule(lr){8-9}\n                        \\cmidrule(lr){10-11}\n                        Clients  & WT & $\\mu$  & $\\lambda$ & $\\rho$ & Est.   & Act.   & Est.  & Act.  & Est.  & Act.  & $\\mathbb{E}[n]$ & $\\varrho$ & $p_0$ & $U$  \\\\\n                        \\midrule\n                        6        & 8  & 421.93 & 2840.73   & 0.42   & 0.00   & 0.09   & 0.00  & 0.06  & 2.37  & 1.31  & 6.73            & 0.00      & 0.0   & 0.42 \\\\\n                                 & 16 & 272.39 & 2841.71   & 0.33   & 0.00   & 0.08   & 0.00  & 0.06  & 3.67  & 1.32  & 10.43           & 0.00      & 0.0   & 0.33 \\\\\n                                 & 32 & 162.27 & 2804.17   & 0.27   & 0.00   & 0.09   & 0.00  & 0.06  & 6.16  & 1.34  & 17.28           & 0.00      & 0.0   & 0.27 \\\\\n                                 & 64 & 90.49  & 2795.49   & 0.24   & 0.00   & 0.09   & 0.00  & 0.07  & 11.05 & 1.38  & 30.89           & 0.00      & 0.0   & 0.24 \\\\\n                        \\addlinespace\n                        12       & 8  & 421.93 & 4967.22   & 0.74   & 0.50   & 0.21   & 0.10  & 0.08  & 2.47  & 1.62  & 12.28           & 0.18      & 0.0   & 0.74 \\\\\n                                 & 16 & 272.39 & 4912.86   & 0.56   & 0.00   & 0.21   & 0.00  & 0.08  & 3.67  & 1.64  & 18.04           & 0.00      & 0.0   & 0.56 \\\\\n                                 & 32 & 162.27 & 4916.40   & 0.47   & 0.00   & 0.21   & 0.00  & 0.08  & 6.16  & 1.64  & 30.30           & 0.00      & 0.0   & 0.47 \\\\\n                                 & 64 & 90.49  & 4838.18   & 0.42   & 0.00   & 0.21   & 0.00  & 0.09  & 11.05 & 1.69  & 53.47           & 0.00      & 0.0   & 0.42 \\\\\n                        \\addlinespace\n                        24       & 8  & 421.93 & 5955.95   & 0.88   & 3.98   & 2.12   & 0.67  & 0.71  & 3.04  & 3.13  & 18.10           & 0.53      & 0.0   & 0.88 \\\\\n                                 & 16 & 272.39 & 6153.06   & 0.71   & 0.10   & 0.48   & 0.02  & 0.16  & 3.69  & 3.00  & 22.69           & 0.04      & 0.0   & 0.71 \\\\\n                                 & 32 & 162.27 & 6152.46   & 0.59   & 0.00   & 0.46   & 0.00  & 0.15  & 6.16  & 3.01  & 37.91           & 0.00      & 0.0   & 0.59 \\\\\n                                 & 64 & 90.49  & 6065.54   & 0.52   & 0.00   & 0.47   & 0.00  & 0.15  & 11.05 & 3.06  & 67.03           & 0.00      & 0.0   & 0.52 \\\\\n                        \\addlinespace\n                        48       & 8  & 421.93 & 6680.07   & 0.99   & 89.76  & 12.72  & 13.44 & 3.81  & 15.81 & 6.25  & 105.60          & 0.95      & 0.0   & 0.99 \\\\\n                                 & 16 & 272.39 & 8187.97   & 0.94   & 9.91   & 4.80   & 1.21  & 1.17  & 4.88  & 4.81  & 39.97           & 0.64      & 0.0   & 0.94 \\\\\n                                 & 32 & 162.27 & 8378.60   & 0.81   & 0.27   & 1.24   & 0.03  & 0.30  & 6.19  & 4.65  & 51.90           & 0.06      & 0.0   & 0.81 \\\\\n                                 & 64 & 90.49  & 8169.17   & 0.71   & 0.00   & 1.29   & 0.00  & 0.32  & 11.05 & 4.77  & 90.28           & 0.00      & 0.0   & 0.71 \\\\\n                        \\addlinespace\n                        96       & 8  & 421.93 & 6664.63   & 0.99   & 72.71  & 36.64  & 10.91 & 11.01 & 13.28 & 13.45 & 88.51           & 0.94      & 0.0   & 0.99 \\\\\n                                 & 16 & 272.39 & 8616.11   & 0.99   & 79.22  & 27.00  & 9.19  & 6.27  & 12.87 & 10.03 & 110.85          & 0.92      & 0.0   & 0.99 \\\\\n                                 & 32 & 162.27 & 10010.38  & 0.96   & 18.36  & 10.18  & 1.83  & 2.03  & 8.00  & 8.09  & 80.05           & 0.69      & 0.0   & 0.96 \\\\\n                                 & 64 & 90.49  & 9935.81   & 0.86   & 0.35   & 3.54   & 0.04  & 0.72  & 11.09 & 7.87  & 110.16          & 0.06      & 0.0   & 0.86 \\\\\n                        \\addlinespace\n                        192      & 8  & 421.93 & 6690.24   & 0.99   & 105.74 & 84.64  & 15.80 & 25.32 & 18.17 & 27.76 & 121.59          & 0.96      & 0.0   & 0.99 \\\\\n                                 & 16 & 272.39 & 8626.25   & 0.99   & 88.93  & 74.92  & 10.31 & 17.38 & 13.98 & 21.13 & 120.60          & 0.93      & 0.0   & 0.99 \\\\\n                                 & 32 & 162.27 & 10327.79  & 0.99   & 169.38 & 55.18  & 16.40 & 10.69 & 22.56 & 16.93 & 233.03          & 0.95      & 0.0   & 0.99 \\\\\n                                 & 64 & 90.49  & 11251.22  & 0.97   & 22.26  & 19.76  & 1.98  & 3.51  & 13.03 & 14.20 & 146.60          & 0.65      & 0.0   & 0.97 \\\\\n                        \\addlinespace\n                        288      & 8  & 421.93 & 6721.23   & 1.00   & 222.12 & 132.57 & 33.05 & 39.48 & 35.42 & 41.90 & 238.05          & 0.98      & 0.0   & 1.00 \\\\\n                                 & 16 & 272.39 & 8681.94   & 1.00   & 243.89 & 122.78 & 28.09 & 28.31 & 31.76 & 32.04 & 275.76          & 0.97      & 0.0   & 1.00 \\\\\n                                 & 32 & 162.27 & 10366.39  & 1.00   & 531.89 & 103.15 & 51.31 & 19.91 & 57.47 & 26.13 & 595.77          & 0.98      & 0.0   & 1.00 \\\\\n                                 & 64 & 90.49  & 11469.24  & 0.99   & 88.44  & 61.54  & 7.71  & 10.73 & 18.76 & 21.87 & 215.19          & 0.87      & 0.0   & 0.99 \\\\\n                        \\bottomrule\n                    \\end{tabular}\n                    \\caption{M/M/m calculations for given configurations of Experiment 4 using the formulae listed in\n                             the book, Box 31.2. Numbers are rounded to two decimal places for presentation purposes\n                             which for the case of $\\rho$ makes the system seem unstable yet the actual numbers are\n                             $< 1$.\\label{tab:mmm}}\n                }\n            \\end{adjustwidth}\n        \\end{table}\n\n        \\subsection{Network of Queues\\label{subsec:7_noc}}\n\n            In the following, two network of queue designs are constructed to try and model results obtained on\n            experiments \\ref{subsec:3_one-middleware} and \\ref{subsec:3_two-middlewares}. The designs include 3 queues\n            and 2 latency centers (which emulate the network where applicable).\n\n            A visualization of the network of queues for 2 \\mw{}s can be seen in figure \\ref{fig:noq_2mw} with the\n            difference to model 1 being the existence of only 1 \\mw{} instead of two for placement of components. With\n            two \\mw{}s the requests are split up between both in an even fashion such that both middlewares experience\n            only half the throughput.\\newline\n            As can be seen memcached is modelled with a queue, more specifically using an M/M/1 approach as this\n            reflects the experimental setup. Instances of memtier are assumed to be queue-less and their performance\n            being infinite. This matches with experimental setups where memtier was not the cause for slowdown (cf.\n            experiment \\ref{sec:2}). The middleware is modelled with 2 queues, an M/M/1 queue which emulates the\n            single network thread followed by an M/M/m queue which simulates the workers. The approach to model the\n            network thread with an M/M/1 queue follows from real system behaviour where packets queue up on a network\n            card if they are not processed quick enough. The M/M/m queue for the workers reflects the design of the\n            middleware in which a single queue is used amongst workers. The decision to leave out modelling the reply\n            stems from the fact that the correct pathway would involve the path back from memcached to each worker\n            thread that communicated with it and then have it reply back to memtier. With the design not allowing\n            bidirectional flows through service centers this cannot be correctly modelled.\n\n            \\begin{figure}\n                \\includegraphics[width=0.7\\linewidth]{graphics/network-of-queues_2-middlewares.png}\n                \\caption{Design of the network of queues. All rectangles define queues, circles delay centers. Circles\n                         with a ``G'' define delay centers which allow utilizations above 1 as they model the\n                         network.\\label{fig:noq_2mw}}\n            \\end{figure}\n\n            The software package \\tw{queueing} from \\emph{GNU Octave} is used to model the previously designed networks\n            using Mean-Value Analysis. The parameters for both networks are defined as follows:\n            \\begin{itemize}\n                \\item $n$: The number of requests in the system. This is equal to the amount of currently active\n                      clients.\n                \\item $S$: The average service time per actor. The actors are defined as follows for the network of\n                      queues:\n                      \\begin{itemize}\n                          \\item $S_{client}$: It is set to 0 as we assume \\cli{}s to never be the bottleneck.\n                          \\item $S_{network}$: The latency of the network. As a reasonable approach results from ping\n                                are taken and halved. This leads to unreasonably low throughput for few clients as has\n                                been inferred by trial and error and set to \\SI{0.3}{\\milli\\second}.\n                          \\item $S_{netthread}$: The service time of the network thread. This is inferred from the\n                                maximum throughput observed in SET requests for the configurations of one and two\n                                \\mw{}s. For the latter case this number is also halved as two instances exist and on\n                                average either has only experienced half the workload.\n                          \\item $S_{worker}$: The service time per worker. It is inferred for each worker thread and\n                                request type separately to model the actual system behaviour whereby worker threads have\n                                more sending to do for SET compared to GET requests. It is derived by taking the\n                                response time of the whole system and subtracting the queuing time and memcached\n                                communication time.\n                          \\item $S_{server}$: The service time for memcached. This is inferred from the maximum\n                                throughput per request type as GETs are network bound whereas SETs are CPU bound. For\n                                all analysis with SET this is $\\tfrac{1}{16335}$ (from experiment\n                                \\ref{subsec:2_one-server}) and for all analysis with GET this is $\\tfrac{1}{2940}$ (from\n                                experiment \\ref{subsec:3_one-middleware} as the throughput is slightly higher compared\n                                to experiment \\ref{subsec:2_one-server}).\n                      \\end{itemize}\n                \\item $V$: The visit ratios from one service center to the next. It is in general set to 1 but for 2\n                      \\mw{}s the ratio between the network delay center and each M/M/1 queue is halved to model the\n                      experimental parameters correctly.\n                \\item $m$: The number of identical servers for each node. This is only relevant for the M/M/m queues which\n                      model multiple concurrent worker threads. In contrast to the previous M/M/m model the number is\n                      set to actual amount of worker threads.\n            \\end{itemize}\n\n            We observe the results of the MVA in terms of throughput ($X$), response times ($R$), queue sizes ($Q$) and\n            system utilization ($U$).\n\n            \\begin{table}\n                \\footnotesize{%\n                    \\begin{tabular}{llllrrrrrr}\n                        \\toprule\n                        & & & & & & \\multicolumn{2}{c}{Worker Threads} & \\multicolumn{2}{c}{Memcached} \\\\\n                        \\cmidrule(lr){7-8}\n                        \\cmidrule(lr){9-10}\n                        \\# MW & Type & Parameter & $m$ & Delay Center & Net-Thread & Act.        & MVA  & Act.        & MVA    \\\\\n                        \\midrule\n                        1     & GET  & $U$       & 6   & 0.69         & 0.20       & \\textemdash & 0.04 & \\textemdash & 0.79   \\\\\n                              &      &           & 24  & 0.88         & 0.25       & \\textemdash & 0.05 & \\textemdash & 1.00   \\\\\n                              &      &           & 192 & 0.88         & 0.25       & \\textemdash & 0.05 & \\textemdash & 1.00   \\\\\n                        \\addlinespace\n                              &      & $R$       & 6   & 0.30         & 0.10       & 0.09        & 1.09 & 1.00        & 0.80   \\\\\n                              &      &           & 24  & 0.30         & 0.12       & 0.20        & 1.09 & 6.50        & 6.35   \\\\\n                              &      &           & 192 & 0.30         & 0.12       & 1.09        & 1.09 & 20.91       & 63.50  \\\\\n                        \\addlinespace\n                              &      & $Q$       & 6   & 0.69         & 0.24       & 0.19        & 2.52 & \\textemdash & 1.84   \\\\\n                              &      &           & 24  & 0.88         & 0.34       & 1.03        & 3.21 & \\textemdash & 18.68  \\\\\n                              &      &           & 192 & 0.88         & 0.34       & 124.11      & 3.21 & \\textemdash & 186.68 \\\\\n                        \\addlinespace\n                              &      & $X$       & 6   & \\multicolumn{6}{c}{MVA: 2311.40 / Measured: 2794.72} \\\\\n                              &      &           & 24  & \\multicolumn{6}{c}{MVA: 2940.00 / Measured: 2938.86} \\\\\n                              &      &           & 192 & \\multicolumn{6}{c}{MVA: 2940.00 / Measured: 2939.61} \\\\\n                        \\addlinespace\n                              & SET  & $U$       & 6   & 1.80         & 0.52       & \\textemdash & 0.02 & \\textemdash & 0.37   \\\\\n                              &      &           & 24  & 3.45         & 0.99       & \\textemdash & 0.03 & \\textemdash & 0.70   \\\\\n                              &      &           & 192 & 3.46         & 1.00       & \\textemdash & 0.03 & \\textemdash & 0.71   \\\\\n                        \\addlinespace\n                              &      & $R$       & 6   & 0.30         & 0.14       & 0.10        & 0.17 & 1.16        & 0.09   \\\\\n                              &      &           & 24  & 0.30         & 1.11       & 0.13        & 0.17 & 1.66        & 0.20   \\\\\n                              &      &           & 192 & 0.30         & 15.64      & 0.17        & 0.17 & 4.10        & 0.21   \\\\\n                        \\addlinespace\n                              &      & $Q$       & 6   & 1.80         & 0.86       & 0.17        & 1.04 & \\textemdash & 0.52   \\\\\n                              &      &           & 24  & 3.45         & 12.78      & 1.35        & 1.99 & \\textemdash & 2.32   \\\\\n                              &      &           & 192 & 3.46         & 180.67     & 43.02       & 2.00 & \\textemdash & 2.41   \\\\\n                        \\addlinespace\n                              &      & $X$       & 6   & \\multicolumn{6}{c}{MVA: 5985.93 / Measured: 2778.38} \\\\\n                              &      &           & 24  & \\multicolumn{6}{c}{MVA: 11511.69 / Measured: 7177.16} \\\\\n                              &      &           & 192 & \\multicolumn{6}{c}{MVA: 11545.00 / Measured: 11545.60} \\\\\n                        \\addlinespace\n                        2     & GET  & $U$       & 6   & 0.84         & 0.18       & \\textemdash & 0.06 & \\textemdash & 0.95   \\\\\n                              &      &           & 24  & 0.88         & 0.19       & \\textemdash & 0.06 & \\textemdash & 1.00   \\\\\n                              &      &           & 192 & 0.88         & 0.19       & \\textemdash & 0.06 & \\textemdash & 1.00   \\\\\n                        \\addlinespace\n                              &      & $R$       & 6   & 0.30         & 0.16       & 0.09        & 0.26 & 1.04        & 1.14   \\\\\n                              &      &           & 24  & 0.30         & 0.16       & 0.12        & 0.26 & 8.12        & 7.14   \\\\\n                              &      &           & 192 & 0.30         & 0.16       & 0.26        & 0.26 & 48.16       & 64.28  \\\\\n                        \\addlinespace\n                              &      & $Q$       & 6   & 0.84         & 0.22       & 0.08        & 0.36 & \\textemdash & 3.18   \\\\\n                              &      &           & 24  & 0.88         & 0.24       & 0.21        & 0.38 & \\textemdash & 21.01  \\\\\n                              &      &           & 192 & 0.88         & 0.24       & 30.14       & 0.38 & \\textemdash & 189.01 \\\\\n                        \\addlinespace\n                              &      & $X$       & 6   & \\multicolumn{6}{c}{MVA: 2784.95 / Measured: 2936.91} \\\\\n                              &      &           & 24  & \\multicolumn{6}{c}{MVA: 2940.00 / Measured: 2934.91} \\\\\n                              &      &           & 192 & \\multicolumn{6}{c}{MVA: 2940.00 / Measured: 2929.16} \\\\\n                        \\addlinespace\n                              & SET  & $U$       & 6   & 1.82         & 0.40       & \\textemdash & 0.00 & \\textemdash & 0.37   \\\\\n                              &      &           & 24  & 4.08         & 0.89       & \\textemdash & 0.01 & \\textemdash & 0.83   \\\\\n                              &      &           & 192 & 4.56         & 0.99       & \\textemdash & 0.01 & \\textemdash & 0.93   \\\\\n                        \\addlinespace\n                              &      & $R$       & 6   & 0.30         & 0.19       & 0.10        & 0.11 & 0.83        & 0.08   \\\\\n                              &      &           & 24  & 0.30         & 0.77       & 0.11        & 0.11 & 1.94        & 0.29   \\\\\n                              &      &           & 192 & 0.30         & 11.01      & 0.11        & 0.11 & 8.17        & 0.89   \\\\\n                        \\addlinespace\n                              &      & $Q$       & 6   & 1.82         & 0.58       & 0.09        & 0.33 & \\textemdash & 0.53   \\\\\n                              &      &           & 24  & 4.08         & 5.20       & 0.37        & 0.75 & \\textemdash & 3.93   \\\\\n                              &      &           & 192 & 4.57         & 83.84      & 23.08       & 0.84 & \\textemdash & 13.51  \\\\\n                        \\addlinespace\n                              &      & $X$       & 6   & \\multicolumn{6}{c}{MVA: 6081.54 / Measured: 3272.89} \\\\\n                              &      &           & 24  & \\multicolumn{6}{c}{MVA: 13609.05 / Measured: 8186.25} \\\\\n                              &      &           & 192 & \\multicolumn{6}{c}{MVA: 15218.43 / Measured: 15312.49} \\\\\n                        \\bottomrule\n                    \\end{tabular}\n                    \\caption{MVA analysis for one and two \\mw{}s at select clients. The intervals show increasingly\n                             saturated systems and as such are of interest in the presentation of the\n                             model. As the delay center behaves the same before or after the middleware only one\n                             center's results are listed. For the experiments with two \\mw{}s the average is\n                             reported.\\label{ref:tab_mva}}\n                }\n            \\end{table}\n\n            \\subsubsection{One \\mw{}\\label{subsubsec:7_noq_one-mw}}\n\n                For this analysis the following fixed parameters were chosen: $S_{network}$ =\n                \\SI{0.3}{\\milli\\second}, $S_{netthread}$ = $\\tfrac{1}{11546}$, $S_{worker\\_GET}$ =\n                \\SI{1.094205}{\\milli\\second}, $S_{worker\\_SET}$ = \\SI{0.172963}{\\milli\\second},\n                $m$ = 64.\n\n                The bottlenecks are expected to be memcached for GET requests and the Net-Thread for SET requests. For\n                GET requests it has already been determined that a single \\srv{} is bottlenecking the system and needs\n                no further proof. The utilizations expected align with expectations for memcached but the worker threads\n                are unrealistically low taxed. It looks as if they are ``sleeping'' for the most time. This would be\n                correct with the model but the real behaviour of worker threads waiting for replies is impossible to\n                model and as such cannot be included in the analysis. It is expected that worker threads are in general\n                expected to under-perform. The response times match general trends but for memcached response times the\n                numbers don't match for 192 clients. This is expected when including the queue sizes. The queue sizes\n                are incorrectly distributed. Memcached is supposedly having 186 requests in the M/M/1 queue for 196\n                clients, something that is a violation of the system design as each request sent expects a reply. With\n                the system being limited to 64 worker threads at most 64 requests can buffer on memcached in the actual\n                system at any time. This is another flaw of the model. Most requests are proven to be caught in the\n                work-queue because worker threads must wait for memcached replies. The throughput numbers are\n                unexpectedly low for six clients but quickly plateau towards the maximum throughput of memcached (which\n                reflects in maximal utilization).\\newline\n                SET requests indicate a high utilization of the Net-Thread with memcached increasing in utility for more\n                clients. This is a reflection on the model definition and as such only noteworthy to mention but cannot\n                be further elaborated on. As assumed, the utilization of worker threads is assumed too low. The response\n                times show a clear delay being caused by the Net-Thread but such an observation was not made in the\n                system. The model shows memcached replying much quicker than is the case, likely another issue of\n                assuming perfect scaling in the system (where more load doesn't introduce any overhead). The queues are\n                interesting in that the worker threads have virtually no queueing in the model. The Net-Thread is\n                modelled to be the point of queueing. This is a contradiction to previously gathered data where queuing\n                was observed for worker threads. Again the argument of threads ``sleeping'' in the model can be made\n                but actually worker-threads are busy for longer than just their service time (which is non-trivial to\n                model). The queue in the Net-Thread could be an indicator though that there is a large amount of work\n                incoming and can be the reason why the throughput isn't higher for the real system. Lastly the\n                throughput is predicted in all instances too high (where model limits are not reached). Again the\n                incorrect processing of requests by the model compared to the system are at fault.\n\n            \\subsubsection{Two \\mw{}s\\label{subsubsec:7_noq_two-mws}}\n\n                For this analysis the following fixed parameters were chosen: $S_{network}$ =\n                \\SI{0.3}{\\milli\\second}, $S_{netthread}$ = $\\tfrac{2}{15310}$, $S_{worker\\_GET}$ =\n                \\SI{0.256949}{\\milli\\second}, $S_{worker\\_SET}$ = \\SI{0.109886}{\\milli\\second}, $m$ = 64.\n\n                Again the bottlenecks are predicted to be memcached for GET requests and the Net-Thread for SET\n                requests. For GET requests the utilizations are reasonably predicted (excluding worker threads) with the\n                Net-Thread experiencing higher loads. The response times align much better for this model with memcached\n                actual and predicted values being close enough (for high loads still wrong results are calculated) and\n                the worker thread response time being stable. The queues are still incorrectly inferred by the model and\n                have been previously explained. It is noteworthy to mention the queue size predicted for memcached being\n                comparable to the single \\mw{} case. Lastly the throughput matches much closer which can be explained by\n                spreading the load over two \\mw{}s. This reflects in utilization values. The Net-Thread is less taxed\n                and the workers show on average more utilization.\\newline\n                For SET requests the utilization shows the Net-Thread still to be the major bottleneck but memcached\n                following close after. This is expected as both middlewares are able to achieve throughputs very close\n                to the maximum which can be handled by one \\srv{}. The utility of the workers is even lower than in the\n                single \\mw{} model. This is explained by the fact that each worker receives half the amount of work,\n                meaning they are ``sleeping'' even longer. The response times are still incorrectly predicted for SET\n                requests and the Net-Thread is expected to bottleneck the system. The only stable component for response\n                times is the response time of the workers which is comparable throughout. The queue sizes are again\n                incorrectly placed in the system with the Net-Threads queue filling up despite being able to handle the\n                expected amount of requests. Compared to the single \\mw{} case roughly half the elements are only\n                predicted. This matches with the model differences (1 queue vs 2 queues). The throughput is still\n                estimated incorrectly and stems from the aforementioned fact of worker threads processing data much\n                quicker than happens in reality where a feedback loop exists with memcached.\n\n                \\subsubsection{Conclusion\\label{subsubsec:7_noq_conclusion}}\n\n                Before drawing conclusions a note on response times predicted. For the case of GET requests these are\n                very close to the expected response time of the real system whereas the Net-Thread models the true\n                response time quite closely for SET requests. \n\n                To summarise, the network of queues models has shown improvements over M/M/1 and M/M/m models yet issues\n                still exist:\n                \\begin{enumerate}\n                    \\item It becomes increasingly complex to model queues correctly where feedback loops exist (such as\n                          worker threads waiting for memcached results or worker threads replying to memtier once a\n                          reply is received).\n                    \\item The model is only accurate if the resource given scale linearly. Usually hardware performance\n                          is not being able to be modelled linearly, especially not complete systems which are subject\n                          to a collection of unknowns.\n                \\end{enumerate}\n", "meta": {"hexsha": "c2a218d4da1710645ea8cff3bb720c1aa7932d58", "size": 43397, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/07_queueing-model.tex", "max_stars_repo_name": "mvaenskae/asl2018", "max_stars_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/07_queueing-model.tex", "max_issues_repo_name": "mvaenskae/asl2018", "max_issues_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/07_queueing-model.tex", "max_forks_repo_name": "mvaenskae/asl2018", "max_forks_repo_head_hexsha": "8d7d6b3fd1691483948cbbd0dd53ceb2c25e3f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.7484143763, "max_line_length": 165, "alphanum_fraction": 0.5151277738, "num_tokens": 12049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.41493311123821436}}
{"text": "\\section{Introduction}\n\\SecLabel{intro}\n\nA Feistel Network (FN) together with Substitution-Permutation Network (SPN) are the two main structures used to design a block cipher. Both are iterated structures in which a simple round function is iterated multiple times. The Feistel Network was invented by Horst Feistel who designed the Lucifer~\\cite{Lucifer} block cipher at IBM. Lucifer was a direct predecessor of the Data Encryption Standard (DES)~\\cite{DES} block cipher which has a 16-round Feistel Network as its structure.\n\nA classical Feistel Network operates on two $n$-bit branches of the same size. The round function works in the following way. A so-called Feistel function is applied to the right branch and the result is added to the left branch using the \\txor{} or the modular addition. Afterward, the branches are swapped. The swap in the last round is usually omitted. A 3-round Feistel Network is shown in \\FigRef{F3}. The Feistel function is not required to be bijective. In fact, a Feistel Network can be seen as a way to construct a pseudorandom \\emph{permutation} from several pseudorandom \\emph{functions}. In 1988, Luby and Rackoff~\\cite{LubyRackoff} proved adaptive chosen-plaintext security of a 3-round Feistel Network under the assumption of (pseudo)random Feistel functions. The proof states that any adversary making $q$ queries to the primitive cannot distinguish it from a random permutation with a probability higher than $q^2/2^n$. It follows that the security is guaranteed only as long as $q$ is much smaller than the birthday bound $2^{n/2}$.\n\n\\FigTex{F3.tex}\n\nA block cipher must have a relatively large block size, $2n \\ge 64$. In this case, it is impractical to generate fully random $n$-bit Feistel functions and store them during encryption. Usually, the Feistel function is chosen to have a simple and efficient structure and is public. However, a secret round key is injected before application of the Feistel function. This construction is called a Key-Alternating Feistel (KAF) cipher. It is much weaker than the ideal one and requires much more rounds in order to achieve strong security. For example, DES has 16 rounds and the recent block cipher Simon~\\cite{Simon} by the NSA has at least 32 rounds in its variants. An analysis of KAF ciphers was done by  Lampe~\\etal{}~\\cite{KeyFeistel1}, Dinur~\\etal{}~\\cite{KeyFeistel2} and more recently by Guo~\\etal{}~\\cite{KeyFeistel3}.\n\nFrom the viewpoint of structural cryptanalysis, it is still important to analyze Feistel Networks with secret round functions. This may have applications in white-box cryptography or S-Box reverse-engineering. Patarin~\\cite{Feistel5Patarin,Feistel5Patarin2} first described attacks on generic 5-round Feistel Network. In the seminal S-Box reverse-engineering paper~\\cite{LeoRE}, Biryukov and Perrin proposed a SAT-solver based heuristic algorithm which seems to be practical for branch sizes of up 7 bits and up to 7 rounds. Biryukov~\\etal{}~\\cite{LeoFeistel} described several cryptanalysis methods against generic Feistel Networks with up to 7 rounds, including integral and Yoyo cryptanalysis. More recently, Durak~\\etal{}~\\cite{FeistelDurak} described decomposition attacks against Feistel Networks with small branch domains based on optimized exhaustive search and the Meet-in-the-Middle technique.\n\nOften the Feistel function has a low algebraic degree for the efficiency reasons. For example, many FN-based ciphers (DES, Camellia) use one SPN round as a Feistel function. The degree of the Feistel function is then upper-bounded by the S-Box size minus one. The same degree bound applies for the inverses of such Feistel Functions. Todo~\\cite{division} proposed a novel method for finding integral characteristics in general structures, called division property. He evaluated FNs and SPNs based on a degree bound of components. Léo Perrin and I analyzed the algebraic degree of Feistel Networks in~\\cite{OurFeistel}. In addition, we showed how to cryptanalyze a Feistel Network composed with random affine encodings. Affine encodings are motivated by S-Box reverse-engineering and white-box applications, where such encodings can provide extra security at a low cost for the designer. These results form the plot of this chapter.\n\n\\subsection{Notation}\nIn this chapter, I will use the following definition of a Feistel Network. It includes a bound on the algebraic degree of the Feistel functions as a parameter since proposed attacks exploit low degree or algebraic degeneracy.\n\n\\begin{definition}[Feistel Network]\n\\Label{def:feistel}\n    $\\bij{r}{d}$ (resp. $\\nbij{r}{d}$) denotes the set of all permutations that can be expressed as an $r$-round Feistel Network with bijective (resp. unrestricted) Feistel functions $f_1,\\ldots,f_r\\colon \\field{n} \\to \\field{n}$ of an algebraic degree at most $d$:\n    \\begin{align*}\n        & \\bij{r}{d} \\eqdef \\pset{\\Swap \\circ R_{f_n}\\circ\\ldots\\circ R_{f_1} \\mid f_i\\colon \\field{n}\\to\\field{n}~\\text{bijective}}, \\\\\n        & \\nbij{r}{d} \\eqdef \\pset{\\Swap \\circ R_{f_n}\\circ\\ldots\\circ R_{f_1} \\mid f_i\\colon \\field{n}\\to\\field{n}}, \\\\\n        & \\text{where}\\\\\n        & R_f\\colon (\\field{n})^2 \\to (\\field{n})^2,~~ (a,b)\\mapsto(b, a\\oplus f(b)).\n    \\end{align*}\n\\end{definition}\n\nIn a few cases, the algebraic degree of the \\emph{inverse} of the Feistel function is considered. The upper bound is denoted by $\\dinv$.\n\n\n\\subsection{Contribution}\nOur work~\\cite{OurFeistel} has several contributions and I believe that it enriches the toolkit of structural cryptanalysis. I distinguish the following parts:\n\\begin{enumerate}\n    \\item We show an interesting link between the integral cryptanalysis and the LAT modulo 8. This fact does not seem to have direct applications but is interesting from a theoretical viewpoint. It might be useful for locating visual patterns in the LAT for the purpose of S-Box reverse-engineering.\n    \\item We define the High-Degree Indicator Matrix of a vectorial Boolean function. While it simply captures classic integral distinguishers, it has many useful properties and provides more insights into integral cryptanalysis.\n    \\item We study algebraic degree growth in Feistel Networks. As a result, we provide simple closed formulas that give rather good degree upper bounds. Though the algorithmic approach using the division property by Todo~\\cite{division} provides similar or slightly better results.\n    \\item We propose decomposition attacks on Feistel Networks masked with affine layers. Previously, a similar attack was only described for unmasked 5-round Feistel Networks in~\\cite{LeoFeistel}. We generalize it for more rounds based on the algebraic degeneracies proved in this work.\n\\end{enumerate}\n\nThe summary of structural attacks against Feistel Networks is given in \\TabRef{attacks1}, including attacks against Feistel Networks whitened with affine encodings.\n\n\\FigTex{attacks1.tex}\n\n\\subsection{Outline}\nThis chapter starts with the description of visual patterns in the LAT of random instances of 3- and 4-round Feistel Networks in~\\SecRef{hdim}. These patterns then are explained and linked to the algebraic degeneracies in these structures. The relevant algebraic structure is encoded in a new object called High-Degree Indicator Matrix. In~\\SecRef{hdim-feistel} the algebraic degeneracies are proved and generalized to a larger number of rounds depending on the algebraic degree of Feistel functions. This immediately yields integral distinguishers. In the following~\\SecRef{afa} these attacks are extended to Feistel Networks composed with secret affine encodings.\nFurther, I show lower degree algebraic degeneracies in Feistel Networks in~\\SecRef{impmono}. In~\\SecRef{monoattack} I describe how to exploit such weaknesses to mount a round function recovery attack. I discuss the results and conclude in~\\SecRef{conclusions}.\n\n\n\\subsection{Differences with~\\cite{OurFeistel}}\nThis chapter is a rather significantly reworked version of the paper~\\cite{OurFeistel} that we wrote together with Léo Perrin. Here I briefly describe the most significant modifications and additions that I have done in this chapter.\n\\begin{enumerate}\n    \\item I redefined and generalized the parametrization of the conditions on the integral distinguishers. I distinguish the case of bijective Feistel functions in a stricter way. Further, instead of using the parameter $\\theta(r,d)=d^{\\floor{r/2}-1} + d^{\\ceil{r/2}-1}$ from the original paper which comes from a very basic degree evaluation method, I use the parameters $\\thetabij{r}{d},\\thetanbij{r}{d}$ which correspond to exact degree bounds and are hard to evaluate but can be upper bounded using various methods. In this way, improving the upper bounds on the degrees would directly improve the results. In addition, I consider the effect of the degree of the inverse of the Feistel functions.\n    \n    \\item I describe a generalization of the LAT-ANF link to congruences with larger powers of 2. It is a simple corollary from the Poisson Summation formula, which I think is not very well-known or used often. It provides a clear relation between the ANF and the LAT of a Boolean function and gives an insight into the structure of the Walsh transform. \n    \n    \\item I describe a generalization of the HDIM-ANF link, an alternative expression for an arbitrary ANF coefficient. The HDIM expression yields a new method of proving the absence of particular monomials of degree $n-1$ in a permutation; the generalization yields analogous method for arbitrary monomials.\n    \n    \\item I provide a more rigorous and explicit analysis of the attacks on Feistel Networks masked with affine encodings. I distinguish the cases of linear and quadratic equation systems and analyze the conditions of success. Furthermore, I describe the re-randomization trick which allows attacking arbitrary affine encodings.\n    \n    \\item I describe the impossible monomial attack in a more concise and accurate way. Furthermore, I provide an algorithm in pseudocode. In addition, I propose a conjecture about the instances of Feistel Networks that can be attacked. I perform an experimental evaluation of the attack and the conjecture.\n\\end{enumerate}\n\n", "meta": {"hexsha": "543ca070755d522504024cb76291fd2d792b2fb0", "size": 10197, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis-source/9strFeistel/0intro.tex", "max_stars_repo_name": "hellman/thesis", "max_stars_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2019-05-16T19:55:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T15:36:12.000Z", "max_issues_repo_path": "thesis-source/9strFeistel/0intro.tex", "max_issues_repo_name": "hellman/thesis", "max_issues_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-09T11:26:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-09T11:26:45.000Z", "max_forks_repo_path": "thesis-source/9strFeistel/0intro.tex", "max_forks_repo_name": "hellman/thesis", "max_forks_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-05T19:40:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T19:40:16.000Z", "avg_line_length": 156.8769230769, "max_line_length": 1049, "alphanum_fraction": 0.7920957144, "num_tokens": 2450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303336, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4149331072811407}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{IV}\n\n\\def\\ntitle{Perfectoid Spaces}\n\\def\\nlecturer{T.\\ Csige}\n\n\\def\\nterm{Easter}\n\\def\\nyear{2020}\n\n\\input{header}\n\n\\newcommand{\\tilt}{\\flat} % tilting\n\\newcommand{\\perf}{\\mathrm{perf}}\n%\\DeclareMathOperator{\\perf}{perf} % perfection\n\\renewcommand{\\c}[1]{\\mathbf{#1}}\n\\newcommand{\\Mod}{{\\c{Mod}}}\n\\DeclareMathOperator{\\Tor}{Tor} % torsion\n\\DeclareMathOperator{\\Ext}{Ext} % extension\n\\newcommand{\\sh}[1]{\\mathcal{#1}} % sheaf\n\\DeclareMathOperator{\\Spa}{Spa}\n\\renewcommand*{\\O}{\\mathcal{O}}\n\n\n\\newtheorem*{construction}{Construction}\n\n\\iffalse\n\\renewcommand*{\\P}{\\mathbb{P}}\n\\newcommand{\\sh}[1]{\\mathcal{#1}} % sheaf\n\\renewcommand*{\\O}{\\mathcal{O}}\n\\let\\Sp\\Relax\n\\DeclareMathOperator{\\Sp}{Sp} % maximum spectrum\n\\DeclareMathOperator{\\Max}{Max}\n\\DeclareMathOperator{\\Spf}{Spf}\n\\DeclareMathOperator{\\Spa}{Spa}\n\\DeclareMathOperator{\\supp}{supp} % support of a valuation\n\\fi\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\section{Perfection and Tilting}\n\nLet \\(p\\) be a ring. Recall that a ring \\(R\\) of characteristic \\(p\\), is \\emph{perfect}\\index{perfect} if Frobenius \\(\\phi: R \\to R\\) is an isomorphism. We call \\(R\\) \\emph{semiperfect}\\index{semiperfect} if \\(\\phi\\) is surjective.\n\n\\begin{definition}[tilting]\\index{tilt!of ring}\n  Let \\(R\\) be a ring.\n  \\begin{itemize}\n  \\item If \\(R\\) has characteristic \\(p\\), set \\(R_\\perf = \\varinjlim_\\phi R\\) and \\(R^\\perf = \\varprojlim_\\phi R\\).\n  \\item (Fountaine) Set \\(R^\\tilt = (R/p)^\\perf\\). We endow \\(R^\\tilt\\) with the profinite topology (and \\(R/p\\) with the discrete topology).\n  \\end{itemize}\n\\end{definition}\n\n\\begin{remark}\n  Universal property of tilting: both \\(R_\\perf\\) and \\(R^\\perf\\) are perfect and the canonical map \\(R^\\perf \\to R\\) (resp.\\ \\(R \\to R_\\perf\\)) has the universal property for maps from perfect rings to \\(R\\) (resp.\\ from \\(R\\) into perfect rings). Moreover \\(R^{\\mathrm{perf}} \\to R\\) is surjective if and only if \\(R\\) is semiperfect.\n\\end{remark}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\F_p[t]_\\perf = \\F_p[t^{1/p^\\infty}], \\F_p[t]^\\perf = \\F_p\\).\n  \\item \\(\\F_p[t]^\\tilt = \\F_p\\).\n  \\item If \\(R\\) is perfect of characteristic \\(p\\), then for any \\(f \\in R\\) non-zero divisor, \\((R/f)^\\perf \\cong \\hat R\\), where \\(\\hat R\\) is the completion with respect to the \\((f)\\)-adic topology. This is left as an exercise. In particular, \\((\\F_p[t^{1/p^\\infty}]/(t))^\\perf \\cong \\widehat{\\F_p[t^{1/p^\\infty}]}\\), the perfect polynomial ring.\n  \\item \\((\\Z_p)^\\tilt \\cong \\F_p\\).\n  \\item \\((\\widehat{\\Z_p[p^{1/p^\\infty}]})^\\tilt \\cong \\widehat{\\F_p[t^{1/p^\\infty}]}\\). Note LHS before tilting is the completed direct limit of \\(\\Z_p[t]/(t^{p^n} - p)\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{ex}\n  Show that if \\(R \\to S\\) is a surjective ring homomorphism of characteristic \\(p\\) rings with nilpotent kernel then \\(R_\\perf \\cong S_\\perf\\), \\(R^\\perf \\cong S^\\perf\\). Slogan: tilting kills nilpotent extensions.\n\\end{ex}\n\nAn elementary but important lemma:\n\n\\begin{lemma}\n  Let \\(R\\) be a ring and \\(t \\in R\\) such that \\(p \\in (t)\\). Give \\(a, b \\in R\\) such that \\(a = b \\pmod t\\), then \\(a^{p^n} = b^{p^n} \\pmod{t^{n + 1}}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Induction on \\(n\\). Clear for \\(n = 0\\). Assume it is true for \\(n\\), then \\(a^{p^n} = b^{p^n} + t^{n + 1} \\cdot c\\). Raising to \\(p\\)th power,\n  \\[\n    a^{p^{n + 1}} = b^{p^{n + 1}} + p \\cdot t^{n + 1} \\cdot d + t^{(n + 1) p} \\cdot c^p.\n  \\]\n  Since \\(p \\in (t)\\), the claim follows.\n\\end{proof}\n\nCrucial lemma:\n\n\\begin{lemma}\n  Assume that \\(R\\) is \\(p\\)-adically complete. The map \\(R \\to R/p\\) induces an isomorphism of multiplicative monoids\n  \\[\n    \\varprojlim_\\phi R \\to \\varprojlim_\\phi R/p = R^\\tilt.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Injectivity: let \\((a_n), (b_n) \\in \\varprojlim_\\phi R\\) such that \\(a_n = b_n \\pmod p\\) for all \\(n\\). Then since \\(a_{n + k} = b_{n + k} \\pmod p\\), by the previous lemma \\(a_{n + k}^{p^k} = b_{n + k}^{p^k} \\pmod{p^{k + 1}}\\) for all \\(k\\). \\(R\\) is \\(p\\)-adically separated as it is complete so \\(a_n = b_n\\).\n\n  Surjectivity: let \\((\\overline a_n) \\in R^\\tilt\\). Choose lifts \\(a_n \\in R\\) of \\(\\overline a_n\\). Then \\(a_{n + k}^{p^k} = a_n \\pmod p\\) for all \\(n, k\\). Using the lemma again, \\((a_{n + k}^{p^k})_k\\) are Cauchy so by completeness it has a limit \\(b_n\\). By construction \\(b_{n + 1}^p = b_n\\) and \\(b_n\\)'s are lifts of \\(\\overline a_n\\).\n\\end{proof}\n\n\\begin{remark}\n  It is easy to see that \\(b_n\\)'s do not depend on the chosen lifts and it gives an explicit inverse to the map in the lemma. Composing this inverse with projection to the last component, we get the map\n  \\begin{align*}\n    \\sharp: R^\\tilt &\\to R \\\\\n    f &\\mapsto f^\\sharp\n  \\end{align*}\n  Its image is exactly those \\(f \\in R\\) which admit compatible system \\(\\{f^{1/p^\\infty}\\}\\). Such elements are called the \\emph{perfect elements} in this course.\n\\end{remark}\n\n\\begin{lemma}[tilting and valuation]\n  If a \\(p\\)-adically complete ring \\(R\\) is a domain (resp.\\ valuation ring), the same is true for \\(R^\\tilt\\). In fact, if \\(|\\cdot|: R \\to \\Gamma \\cup \\{0\\}\\) is the valuation on \\(R\\), then the composition\n  \\[\n    |\\cdot|^\\tilt: R^{\\tilt} \\xrightarrow{\\sharp} R \\xrightarrow{|\\cdot|} \\Gamma \\cup \\{0\\}\n  \\]\n  gives the valuation on \\(R^\\tilt\\). The rank of \\(|\\cdot|^\\tilt\\) is bounded above by the rank of \\(|\\cdot|\\).\n\\end{lemma}\n\n\\begin{proof}\n  Since \\(R^\\tilt \\cong \\varprojlim_\\phi R\\), if \\((a_n), (b_n) \\in R^\\tilt\\) are such that \\((a_n) \\cdot (b_n) = 0\\), then in particular \\(a_0 \\cdot b_0 = 0\\) so \\(a_0 = 0\\) or \\(b_0 = 0\\) as \\(R\\) is a domain. Then \\(a_i^{p^i} = a_0 = 0\\) so \\(a_i = 0\\). Thus \\(R^\\tilt\\) is a domain.\n\n  If \\(R\\) is a vaulation ring, its elements are totally ordered by divisibility and given \\((a_n), (b_n) \\in R^\\tilt\\), wlog \\(a_0 \\divides b_0\\). Then \\(a_n \\divides b_n\\) (since \\(\\frac{b_n}{a_n} \\in \\mathrm{Frac} R\\) must lie in \\(R\\), since \\(p\\)th root does). Thus \\(R^\\tilt\\) is a valuation ring. The rest follows from definition.\n\\end{proof}\n\n\\section{Perfectoid fields and their tilt}\n\n\\subsection{Perfectoid fields}\n\nWe construct, as a first step, non-archimedean fields with ``a lot of'' \\(p\\)-power roots and formulate almost purity in this case, which is already a deep theorem. We identify the Galois theory of \\(K\\) and \\(K^\\tilt\\).\n\n\\begin{definition}[perfectoid field]\\index{perfectoid field}\n  A \\emph{perfectoid field} is a non-archimedean complete field \\(K\\) of residue characteristic \\(p > 0\\) such that\n  \\begin{itemize}\n  \\item the value group \\(|K^\\times| \\subseteq \\R_{> 0}\\) is non-discrete,\n  \\item \\(K^\\circ/p\\) is semiperfect.\n  \\end{itemize}\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(K = \\widehat{\\Q_p(p^{1/p^\\infty})}\\). Then \\(|K^\\times| = \\Z[\\frac{1}{p}]\\). Note that colimit and completion of valuation ring is a valuation ring, hence \\(K^\\circ = \\widehat{\\Z_p[p^{1/p^\\infty}]}\\): we have a canonical injection \\(\\widehat{\\Z_p[p^{1/p^\\infty}]} \\embed K^\\circ\\). Both are valuation rings with the same fraction fields, hence equal. Then \\(K\\) is perfectoid.\n  \\item The same argument shows that \\(K = \\widehat{\\Q_p[\\mu_{p^\\infty}]}\\) is perfectoid.\n  \\item Any characteristic \\(p\\) field \\(K\\) is perfectoid if and only if \\(K\\) is perfect.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(K\\) be perfectoid.\n  \\begin{enumerate}\n  \\item The value group \\(|K^\\times|\\) is \\(p\\)-divisible.\n  \\item \\((K^{\\circ \\circ})^2 = K^{\\circ \\circ}\\). Moreover \\(K^{\\circ \\circ}\\) is a flat \\(K^\\circ\\)-module.\n  \\item \\(K^\\circ\\) is not noetherian.\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(x \\in K\\) be such that \\(|p| < |x| < 1\\) (these are called small elements). By perfectoidness, exists \\(y \\in K^\\circ\\) such that \\(x = y^p + p z\\). Then \\(|x| = |y^p| = |y|^p\\).\n\n    In general, since \\(|K^\\times|\\) is non-discrete, \\(|p|^\\Z \\subsetneq |K^\\times|\\) so exists \\(x \\in K\\), \\(|x| \\notin |p|^\\Z\\). Multiplying by a suitable power of \\(p\\) we may assume \\(|p| < |x| < 1\\). As \\(p\\) does not divide \\(x\\), by valuation property \\(p = xy\\) for some \\(y \\in K^\\circ\\). Then \\(y\\) is also small, therefore \\(|y|\\) is also \\(p\\)-divisible. Thus \\(|p|^\\Z\\) is divisible and we are done.\n  \\item Pick \\(f \\in K^{\\circ \\circ}\\). By perfectoidness \\(f = g^p + p h\\) where \\(g \\in K^{\\circ \\circ}, h \\in K^\\circ\\). Since \\(p = xy \\in (K^{\\circ \\circ})^2\\) in the previous part, \\((K^{\\circ \\circ})^2 = K^\\circ\\). Since \\(K^{\\circ \\circ}\\) is torsion-free and over a valuation ring, it is flat.\n  \\item \\(K^{\\circ \\circ}\\) is not finitely generated since it has elements with arbitrarily small valuation. Alternatively use Nakayama.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{remark}\n  The proof shows that \\(|K^\\times|\\) is generated by \\(|x|\\) such that \\(|p| < |x| < 1\\).\n\\end{remark}\n\n\\subsection{Tilting of perfectoid fields}\n\nWe are going to define the tilt of a perfectoid field. Fix a pseudo-uniformiser \\(\\pi \\in K^\\circ\\) such that \\(|p| \\leq |\\pi| < 1\\) (we can pick \\(p\\)). Consider\n\\[\n  \\begin{tikzcd}\n    \\varprojlim_\\phi K^{\\circ} \\ar[r] \\ar[d, \"\\cong\"] & K^\\circ \\ar[d] \\\\\n    K^{\\circ \\tilt} = \\varprojlim_\\phi K^\\circ/p \\ar[r] \\ar[d, \"\\cong\"] & K^\\circ/p \\ar[d] \\\\\n    \\varprojlim_\\phi K^\\circ/\\pi \\ar[r] & K^\\circ/\\pi\n  \\end{tikzcd}\n\\]\n\\(K^{\\circ \\tilt} \\to \\varprojlim_\\phi K^\\circ/\\pi\\) is an isomorphism since exists \\(n\\) such that \\(|\\pi|^n < |p|\\), so \\(K^\\circ/p \\to K^\\circ/\\pi\\) has nilpotent kernel, and hence \\((K^\\circ/p)^\\perf \\cong (K^\\circ/\\pi)^\\perf\\).\n\n\\begin{lemma}\n  There exists some \\(t \\in K^{\\circ \\tilt}\\) such that \\(|t^\\sharp| = |\\pi|\\). Moreover \\(t\\) maps to \\(0\\) in \\(K^\\circ/\\pi\\) and gives an isomorphism \\(K^{\\circ \\tilt}/t \\cong K^\\circ/\\pi\\).\n\\end{lemma}\n\n\\begin{proof}\n  By assumption \\((p) \\subseteq (\\pi)\\) so we have surjective maps \\(K^{\\circ \\tilt} \\to K^\\circ/p \\to K^\\circ/\\pi\\). By \\(p\\)-divisibility of \\(|K^\\times|\\), exists \\(f \\in K^\\circ\\) such that \\(|f|^p = |\\pi|\\). Thus \\(|f| > |\\pi|\\) and hence \\(\\overline f \\ne 0\\) in \\(K^\\circ/\\pi\\). Choose a lift \\(g \\in K^{\\circ \\tilt}\\) of \\(\\overline f\\). By the above diagram, \\(g^\\sharp = f \\pmod \\pi\\). By non-archimedean property \\(|g^\\sharp| = |f|\\). Let \\(t = g^p\\) and\n  \\[\n    |t^\\sharp| = |g^{\\sharp p}| = |\\pi|\n  \\]\n  by multiplicativity of \\(\\sharp\\).\n\n  \\(t\\) maps to \\(0\\) in \\(K^\\circ/\\pi\\) by construction and we have a surjection \\(K^{\\circ \\tilt}/t \\to K^\\circ/\\pi\\). It is an isomorphism: suppose \\(h \\in K^{\\circ \\tilt}\\) is such that \\(h\\) maps to \\(0\\) in \\(K^\\circ/\\pi\\). Since \\(|\\pi| = |t^\\sharp|\\), \\((\\pi) = (t^\\sharp)\\). \\(h^\\sharp\\) is also mapped to \\(0\\) by the commutative diagram so \\(h^\\sharp = a \\cdot t^\\sharp\\). Set \\(a_n = \\frac{(h^{1/p^n})^\\sharp}{(t^{1/p^n})^\\sharp} \\in K\\). Then \\(a_n^{p^n} = a\\) so \\(\\tilde a = (a_n) \\in \\varprojlim_\\phi K^\\circ\\). Then \\(h = \\tilde a \\cdot t\\) in \\(\\varprojlim_\\phi K^\\circ\\).\n\\end{proof}\n\n\\begin{corollary}\n  \\(K^{\\circ \\tilt}\\) is \\(t\\)-adically complete and the \\(t\\)-adic topology coincides with the inverse limit topology.\n\\end{corollary}\n\n\\begin{proof}\n  Exercise. Use \\(\\varprojlim_n K^{\\circ \\tilt}/t^n \\cong \\varprojlim_n K^{\\circ \\tilt}/t^{p^n}\\).\n\\end{proof}\n\n\\begin{proposition}\n  Fix an element \\(t\\) as in the previous lemma.\n  \\begin{enumerate}\n  \\item \\(K^{\\circ \\tilt}\\) is a valuation ring and \\(K^\\tilt = K^{\\circ \\tilt}[\\frac{1}{t}]\\) is a field (of characteristic \\(p\\)).\\index{tilt!of perfectoid field}\n  \\item The ideal \\((t^{1/p^\\infty})\\) is maximal and the Krull dimension of \\(K^{\\circ \\tilt}\\) is \\(1\\).\n  \\item The valuation topology on \\(K^{\\circ \\tilt}\\) coming from 1 coincides with the \\(t\\)-adic topology. In this topology \\(K^\\tilt\\) is a perfectoid field and \\(K^{\\tilt \\circ} = K^{\\circ \\tilt}\\).\n  \\item The value groups of \\(K\\) and \\(K^\\tilt\\) are identified, so are their residue fields.\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n  Observe that \\(a \\in K^{\\circ \\tilt}\\) is a unit if and only if \\(a^\\sharp\\) is a unit.\n  \\begin{enumerate}\n  \\item \\(K^{\\circ \\tilt}\\) is a valuation ring of rank 1 since the valuation is not trivial. It is a general fact that \\(K^{\\circ \\tilt}[\\frac{1}{t}]\\) produces the fraction field: \\(|t|^\\tilt = |t^\\sharp| = |\\pi|\\) so for any \\(h \\in K^{\\circ \\tilt}\\), exists \\(n\\) such that \\(|t^n| < |h|\\). Thus \\(\\frac{1}{h} = \\frac{z}{t^n}\\) if \\(t^n = h \\cdot z\\).\n  \\item It is a general fact that the Krull dimension of a valuation ring is the rank of valuation. Since \\(K^{\\circ \\tilt}/t \\cong K^\\circ/\\pi\\), the maximal ideal of \\(K^\\circ/\\pi\\) is its nilradical (since it is artinian) so the same is true for LHS. Certainly \\((t^{1/p^\\infty}) \\subseteq N(K^{\\circ \\tilt}/t)\\) and by construction \\(K^{\\circ \\tilt}/(t^{1/p^\\infty})\\) is perfect and hence reduced, so equality.\n  \\item Using that \\(|t|^\\tilt < 1\\), we see that \\(t\\)-adic topology is equivalent to the valuation topology. Since \\(K^{\\circ \\tilt}\\) is \\(t\\)-adically complete, \\(K^\\tilt \\) is non-archimedean. It is also perfect so is perfectoid.\n  \\item Easily \\(|K^{\\tilt \\times}| \\subseteq |K^\\times|\\). We've seen \\(|K^\\times|\\) is generated by \\(|x|\\) such that \\(|p| < |x| < 1\\). Using the previous lemma, all generators of \\(|K^\\times|\\) are in \\(|K^{\\tilt \\times}|\\) so equality.\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{proposition}[tilting continuous valuations]\n  For any continuous non-archimedean valuation \\(|\\cdot| : K \\to \\Gamma \\cup \\{0\\}\\) (of any rank), the function \\(|\\cdot|^\\tilt\\) is also a continuous valuation. This identifies the space of continuous valuations on \\(K\\) and \\(K^\\tilt\\).\n\\end{proposition}\n\n\\begin{proof}[Sketch proof]\n  It is clear that \\(|\\cdot|^\\tilt\\) is multiplicative and \\(|f|^\\tilt = 0\\) if and only if \\(f = 0\\). Check non-archimedean property: take \\((f_n), (g_n) \\in \\varprojlim_\\phi K^\\circ\\) so \\(f_0 = f^\\sharp, g_0 = g^\\sharp\\). Then\n  \\begin{align*}\n    |f + g|^\\tilt\n    &= |(f + g)^\\sharp| \\\\\n    &= |\\lim (f_n + g_n)^{p^n}| \\\\\n    &= \\lim |f_n + g_n|^{p^n} \\\\\n    &\\leq \\lim \\max(|f_n|^{p^n}, |g_n|^{p^n}) \\\\\n    &= \\max(|f^\\sharp|, |g^\\sharp|)\n  \\end{align*}\n\n  For continuity, note that a valuation \\(|\\cdot|\\) is continuous if and only if for any pseudo-uniformiser \\(f \\in K^{\\circ \\circ}\\), we have \\(|f|^n \\to 0\\). Since any pseudo-uniformiser can be tilted to a pseudo-uniformiser in \\(K^{\\circ \\tilt}\\), \\(|\\cdot|\\) is continuous implies \\(|\\cdot|^\\tilt\\) is continuous.\n\n  We can also use this characterisation to prove\n  \\begin{enumerate}\n  \\item \\(K^{\\circ \\circ} \\subseteq R\\), where \\(R\\) is the valuation ring of \\(|\\cdot|\\).\n  \\item \\(R \\subseteq K^\\circ\\).\n  \\end{enumerate}\n\n  Standard fact (Matsumura, Commmutative Ring Theory Theorem 16.1): let \\(R \\subseteq R' \\subseteq K\\) be valuation rings in a field, \\(\\mathfrak m_R, \\mathfrak m_{R'}\\) maximal ideals of \\(R\\) and \\(R'\\). Suppose \\(R \\ne R'\\). Then \\(\\mathfrak m_{R'} \\subseteq \\mathfrak m_R \\subseteq R\\) and \\(\\mathfrak m_{R'}\\) is a prime ideal of \\(R\\). Moreover \\(R' \\cong R_{\\mathfrak m_{R'}}\\). Hence if \\(R\\) has properties 1 and 2, \\(R \\to K^\\circ\\) is a localisation and \\(K^{\\circ \\circ}\\) lies in \\(\\Spec R\\). Thus \\(|f|^n \\to 0\\) for \\(f \\in K^{\\circ \\circ}\\).\n  \n  Passing to the quotient, there exists an bijection\n  \\[\n    \\{\\text{continuous valuations on } K\\} \\leftrightarrow \\{\\text{valuation rings in } K^\\circ/K^{\\circ \\circ}\\}\n  \\]\n  Similar for \\(K^\\tilt\\) and use the identification \\(K^\\circ/K^{\\circ \\circ} \\cong K^{\\tilt \\circ}/K^{\\tilt \\circ\\circ}\\), we are done.\n\\end{proof}\n\n\\begin{theorem}[almost purity in dimension \\(0\\)]\n  Let \\(L/K\\) be a finite extension and \\(K\\) be perfectoid. Then\n  \\begin{enumerate}\n  \\item \\(L\\) is perfectoid.\n  \\item the field extension \\(L^\\tilt/K^\\tilt\\) is finite of the same degree as \\(L/K\\).\n  \\item the association \\(L \\mapsto L^\\tilt\\) defines an equivalence of categories \\(K_{\\textup{fét}} \\simeq K^\\tilt_{\\textup{fét}}\\) of finite étale algebras.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{corollary}\n  \\(\\gal(\\overline K/K) \\cong \\gal(\\overline K^\\tilt/K^\\tilt)\\).\n\\end{corollary}\n\n\\begin{remark}\n  For \\(\\widehat{\\Q_p(\\mu_{p^\\infty})}\\), it is the famous Fontaine-Wintenberger theorem.\n\\end{remark}\n\n\\begin{remark}\n  It can be shown that if \\(K = \\overline K\\) then \\(\\overline{K^\\tilt} = K^\\tilt\\). See for example Prop.\\ 3.8 in Scholze, Perfectoid Space.\n\\end{remark}\n\n\\begin{eg}\n  This example show that the tilting functor \\(K \\mapsto K^\\tilt\\) is not fully faithful in general. Let \\(K = \\widehat{\\Q_p(\\mu_{p^\\infty})}\\) so \\(K^\\circ = \\widehat{\\Z_p[\\mu_{p^\\infty}]}\\). \\(K^\\circ\\) can be explicitly described as the \\(p\\)-adic completion of \\(\\Z_p[\\varepsilon^{1/p^\\infty}]/(1 + \\varepsilon^{1/p} + \\dots + \\varepsilon^{(p - 1)/p})\\) by taking a compatible system of \\(p\\)-power roots of unity \\(\\varepsilon_n \\in \\mu_{p^n}\\) and sending \\(\\varepsilon_n\\) to \\(\\varepsilon^{1/p^n}\\). Since \\(\\frac{x^p - 1}{x - 1} = (x - 1)^{p - 1} \\pmod p\\),\n  \\[\n    K^\\circ/p \\cong \\F_p[\\varepsilon^{1/p^\\infty}]/(\\varepsilon^{1/p} - 1)^{p - 1} \\cong \\F_p[t^{1/p^\\infty}]/t^{p - 1}\n  \\]\n  by substituting \\(t\\) for \\(\\varepsilon - 1\\). so \\(K^{\\circ \\tilt} \\cong \\widehat{\\F_p[t^{1/p^\\infty}]} \\cong (\\widehat{\\Z_p[p^{1/p^\\infty}]})^\\tilt\\). Thus \\(K^\\tilt \\cong (\\widehat{\\Q_p(p^{1/p^\\infty})})^\\tilt\\).\n\\end{eg}\n\n\\section{Almost ring theory}\n\nThe idea behind Faltings' theory is to develop commutative algebra notions whilst systematically ``ignoring'' some class of torsion modules. We follow Gabber \\& Ramero, Almost Ring Theory.\n\nThe basic setup for almost mathematics is as follow. Assume \\(R\\) is a commutative ring and \\(I \\subseteq R\\) an ideal such that \\(I^2 = I\\) and \\(I\\) is flat.\n\nThe cases of interest for us are\n\\begin{itemize}\n\\item for a perfectoid field \\(K\\), let \\(R = K^\\circ\\) and \\(I = K^{\\circ \\circ}\\). We have shown \\(I^2 = I\\) and \\(I\\) is flat. In fact we know that for any pseudo-uniformiser \\(t \\in K^{\\tilt \\circ}\\), \\(t^\\sharp\\) admits a compatible system of \\(p\\)-power roots and \\(I = ((t^\\sharp)^{1/p^\\infty})\\).\n\\item let \\(R\\) be a perfect ring of characteristic \\(p\\) and \\(I = (f^{1/p^\\infty})\\) for \\(f \\in R\\). It is straightfoward that \\(I^2 = I\\). If \\(f\\) is a non-zero divisor then \\(I\\) is flat.\n\\end{itemize}\n\n\\begin{definition}[almost zero module]\n  We say that \\(M \\in \\Mod_R\\) is \\emph{almost zero} if \\(IM = 0\\), i.e.\\ \\(M\\) is \\(I\\)-torsion. If \\(f \\in M\\) is such that \\(I \\cdot f = 0\\) then \\(f\\) is called an \\emph{almost zero element}.\n\\end{definition}\n\n\\begin{definition}[Serre subcategory]\n  Let \\(\\c{A}\\) be an abelain category. A \\emph{Serre subcategory} is a full subcategory \\(\\c B \\subseteq \\c A\\) such that\n  \\begin{enumerate}\n  \\item \\(\\c B\\) is an abelian subcategory, i.e.\\ clsoed under direct sumes, kernels and cokernels,\n  \\item \\(\\c B\\) is closed under extensions, i.e.\\ if\n    \\[\n      \\begin{tikzcd}\n        0 \\ar[r] & M \\ar[r] & N \\ar[r] & L \\ar[r] & 0\n      \\end{tikzcd}\n    \\]\n    is a short exact sequence and \\(M, L \\in \\c B\\) then \\(N \\in \\c B\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{construction}[quotient category]\n  Let \\(\\c A, \\c B\\) be as above. Then one can form a \\emph{quotient category} \\(\\c A/\\c B\\) with the following properties:\n  \\begin{enumerate}\n  \\item \\(\\c A/\\c B\\) is an abelian category and there exists a quotient functor \\(q: \\c A \\to \\c A/\\c B\\) which is exact and sends every object of \\(\\c B\\) to \\(0\\).\n  \\item given any abelian category \\(\\c C\\) and an exact functor \\(F: \\c A \\to \\c C\\) such that \\(F(B) = 0\\) for all \\(B \\in \\c B\\), \\(F\\) factors through \\(q\\).\n    \\[\n      \\begin{tikzcd}\n        \\c A \\ar[r, \"F\"] \\ar[d, \"q\"] & \\c C \\\\\n        \\c A/\\c B \\ar[ur, dashed]\n      \\end{tikzcd}\n    \\]\n  \\end{enumerate}\n\n  Explicitly, \\(\\mathrm{Obj}(\\c A/\\c B)\\) are the objects of \\(\\c A\\) and\n  \\[\n    \\Hom_{\\c A/\\c B}(X, Y) = \\varinjlim_{X' \\to X} \\Hom(X', Y)\n  \\]\n  where \\(X' \\to X\\) has kernel and cokernel in \\(\\c B\\).\n\\end{construction}\n\n\\begin{definition}[almost category]\\index{almost category}\n  The \\emph{almost category} \\(\\Mod_R^a\\) is the quotient of \\(\\Mod_R\\) by the Serre subcategory of \\(\\Mod_{R/I}\\), i.e.\\ the \\(I\\)-torsion modules.\n\\end{definition}\n\nNote that if\n\\[\n  \\begin{tikzcd}\n    0 \\ar[r] & M \\ar[r] & N \\ar[r] & L \\ar[r] & 0\n  \\end{tikzcd}\n\\]\nis a short exact sequence such that \\(M\\) and \\(L\\) are \\(I\\)-torsion then \\(M\\) is killed by \\(I^2 = I\\).\n\nWe have an exact functor \\((-)^a: \\Mod_R \\to \\Mod_R^a\\) called \\emph{almostification}\\index{almostification}. The objects of \\(\\Mod_R^a\\) are called \\emph{almost \\(R\\)-modules} or \\emph{\\(R^a\\)-modules}.\n\nBy construction\n\\[\n  \\Hom_{R^a}(M^a, N^a) = \\varinjlim_{M' \\to M} \\Hom_R(M', N)\n\\]\nwhere \\(M' \\to M\\) has almost zero kernel and cokernel, i.e.\\ \\(M' \\to M\\) is an almost isomorphism. In our case it is explicit: for any \n\nthe direct system has an initial object (?) \\(I \\otimes M \\to M\\), so\n\\[\n  \\Hom_{R^a}(M^a, N^a) = \\Hom_R(I \\otimes M, N)\n\\]\nwhich has a natural \\(R\\)-module structure.\n\n\\begin{remark}\n  It is straightforward to check that the tensor product on \\(\\Mod_R\\) descends to \\(\\Mod_R^a\\), i.e\\ \\(\\Mod_R^a\\) is an abelian tensor category with tensor product\n  \\[\n    M^a \\otimes_{R^a} N^a = (M \\otimes_R)^a\n  \\]\n  (it is enough to show that \\(M \\otimes_R N\\) is \\(I\\)-torsion if either \\(M\\) or \\(N\\) is \\(I\\)-torsion).\n\\end{remark}\n\n\\begin{remark}\n  It can be checked that there exists a right adjoint, the \\emph{internal Hom}\\index{internal hom}, to tensor product in \\(\\Mod_R^a\\). We denote it by \\(\\mathrm{alHom}(-, -)\\) and it is given by\n  \\[\n    \\mathrm{alHom}(X, Y) = \\Hom_{R^a}(M^a, N^a)^a\n  \\]\n  for \\(X = M^a, Y = N^a\\), with an isomorphism\n  \\[\n    \\Hom(X \\otimes Y, Z) \\cong \\Hom(X, \\mathrm{alHom}(Y, Z)).\n  \\]\n\\end{remark}\n\n\\begin{construction}[functors relating \\(\\Mod_R\\) and \\(\\Mod_R^a\\)]\n  Consider this motivating example of sheaves on topological spaces. If \\(X\\) is a topological space and \\(U \\subseteq X\\) open, then we have \\(j^*: \\c{Sh}(X) \\to \\c{Sh}(U)\\) (pullback). This functor is exact and has two adjoints \\(j_!, j_*\\) (extension by zero and pushforward). The functor \\(j_!\\) is exact and \\(j_*\\) is left exact.\n\n  Similar almostification \\((-)^a: \\Mod_R \\to \\Mod_R^a\\) admits adjoints\n  \\[\n    (-)_!, (-)_*: \\Mod_R^a \\to \\Mod_R.\n  \\]\n  It is enough to describe them on honest \\(R\\)-modules and check that they respect almost isomorphisms. They are given by\n  \\begin{align*}\n    M_! &= I \\otimes M \\\\\n    M_* &= \\Hom_R(I, M)\n  \\end{align*}\n  The adjunction can be checked by\n  \\[\n    \\Hom_{R^a}(M^a, N^a) = \\Hom_R(I \\otimes M, N) = \\Hom_R(M, \\Hom_R(I, N)).\n  \\]\n  Finally since \\(I\\) is flat, \\((-)_!\\) is flat.\n\\end{construction}\n\n\\begin{construction}(almost category in disguise)\n  Let \\(\\c A \\subseteq \\Mod_R\\) be the full subcategory of \\(R\\)-modules such that the multiplication map \\(I \\otimes M \\to M\\) is an isomorphism. Equivalently, as \\(I \\otimes I \\cong I^2 \\cong I\\), \\(\\c A\\) is the essential image of the functor \\(\\Mod_R \\to \\Mod_R, M \\mapsto I \\otimes M\\). This functor is exact since \\(I\\) is flat. Flatness also shows that \\(\\c A\\) is an abelian category. We prove that \\(\\c A\\) is a quotient of \\(\\Mod_R\\) and it gives an explicit realisation of \\(\\Mod_R^a\\).\n\n  Denote by \\(j^*: \\Mod_R \\to \\c A\\) the functor \\(- \\otimes I\\).\n\n  \\begin{proposition}\n    The functor \\(j^*: \\Mod_R \\to \\c A\\) provides an explicitsation of the quotient functor \\(q: \\Mod_R \\to \\Mod_R^a\\).\n  \\end{proposition}\n\n  \\begin{proof}\n    We must check that \\(j^*\\) satisfies the properties in the definition of a quotient category.\n    \\begin{itemize}\n    \\item Let \\(M\\) be an \\(I\\)-torsion module. Then since \\(M\\) is canonically an \\(R/I\\)-module, \\(I \\otimes_R M = I \\otimes_R (R/I \\otimes_R M) = 0\\) as \\(I/I^2 = 0\\).\n    \\item \\(j^*\\) is exact as \\(I\\) is flat.\n    \\item Universal property: if \\(F: \\c A \\to \\c B\\) is an exact funtor, \\(\\c B\\) is abelian and \\(F\\) sends \\(I\\)-torsion modules to \\(0\\), then \\(F\\) factors through \\(j^*\\): if \\(I \\otimes M \\to M\\) is the multiplication map then its kernel is \\(\\Tor_1^R(R/I, M)\\) and the cokernel is \\(R/I \\otimes_R M\\) (as \\(0 \\to I \\to R \\to R/I \\to 0\\) is a flat resolution of \\(R/I\\)). Both \\(\\Tor^R_1(R/I, M)\\) and \\(R/I \\otimes_R M\\) are \\(I\\)-torsion as\n      \\[\n        \\Tor_R^1(R/I, M) \\otimes_R I \\cong \\Tor_R^1(R/I \\otimes_R I, M) = 0.\n      \\]\n      Thus \\(F(I \\otimes M) \\cong F(M)\\) and \\(F \\compose j^*(M) \\cong F(M)\\), so \\(F\\) factors through \\(j^*\\).\n    \\end{itemize}\n  \\end{proof}\n\\end{construction}\n\n\\begin{remark}\n  We realised \\(\\Mod_R^a\\) as a full subcategory of \\(\\Mod_R\\). Then it is straightforward that \\(\\Mod_R^a\\) is an abelian tensor category and that\n  \\[\n    \\mathrm{alHom}(j^*(M), j^*(N)) = j^* \\Hom(M, N).\n  \\]\n\\end{remark}\n\n\\begin{definition}[almost finitely generated/presented]\\index{almost finitely generated}\\index{almost finitely presented}\n  An object \\(M^a \\in \\Mod_R^a\\) is \\emph{almost finitely generated} if for every \\(\\varepsilon \\in I\\), exists a finitely generated \\(R\\)-module \\(M_\\varepsilon\\) and a map \\(M_\\varepsilon \\to M\\) such that the cokernel is annihilated by \\(\\varepsilon\\). \\emph{Mutatis mutandis} define \\emph{almost finitely presented} modules.\n\n  If the number of generators can be bounded above independent of \\(\\varepsilon\\), we say that \\(M\\) is \\emph{uniformly almost finitely generated}.\n\\end{definition}\n\n\\begin{remark}\n  A priori the definition depends on the choice of the \\(R\\)-module \\(M\\) giving \\(M^a\\). However it is easy to check that it doesn't.\n\\end{remark}\n\n\\begin{definition}\n  Let \\(M \\in \\Mod_R\\) with image \\(M^a \\in \\Mod_R^a\\). Then\n  \\begin{itemize}\n  \\item we say \\(M\\) or \\(M^a\\) is \\emph{almost flat} if \\(M^a \\otimes -\\) is exact, or equivalently \\(\\Tor^R_i(M, N)\\) is almost zero for any \\(R\\)-module \\(N\\) and \\(i > 0\\).\n  \\item we say that \\(M\\) or \\(M^a\\) is \\emph{almost projective} if \\(\\mathrm{alHom}(M^a, -)\\) is exact, or equivalently \\(\\Ext^i_R(M, M)\\) is almost zero for any \\(R\\)-module \\(N\\) and \\(i > 0\\).\n  \\end{itemize}\n\\end{definition}\n\n\\begin{ex}\n  The bifunctor \\(\\Hom_{R^a}(M^a, N^a)\\) can be derived in either variable to convert a short exact sequence to a long exact sequence. In fact we get derivatives by formula\n  \\[\n    \\Ext_{R^a}^i(M^a, N^a) = \\Ext_R^i(I \\otimes_R M, N).\n  \\]\n  In particular, if \\(0 \\to M'^a \\to M^a \\to M''^a \\to 0\\) is a short exact sequence in \\(\\Mod_R^a\\), we have a long exact sequence\n  \\[\n    \\begin{tikzcd}\n      \\Ext_{R^a}^i(R^a, M'^a) \\ar[r] & \\Ext_{R^a}^i(R^a, M^a) \\ar[r] & \\Ext_{R^a}^i(R^a, M''^a) \\ar[dll, out=0, in=180, overlay] \\\\\n      \\Ext_{R^a}^{i + 1}(R^a, M'^a) \\ar[r] & \\Ext_{R^a}^{i + 1}(R^a, M^a) \\ar[r] & \\Ext_{R^a}^{i + 1} (R^a, M''^a) \\ar[dll, out=0, in=180, overlay] \\\\\n      \\cdots \n    \\end{tikzcd}\n  \\]\n  deriving the functor \\((-)_*\\) of almost elements.\n\\end{ex}\n\n\\begin{remark}\n  Note that almost projective modules are \\emph{not} projective objects in \\(\\Mod_R^a\\). Recall that an object \\(P\\) in some abelian category \\(\\c A\\) is projective if \\(\\Hom_{\\c A}(P, -)\\) is exact. We have just shown that \\(R^a\\) is not a projective object in \\(\\Mod_R^a\\), but it is certainly an almost projective module.\n\n  For example, for \\(K\\) perfectoid field, let \\(R = K^\\circ, I = K^{\\circ \\circ}\\) and \\(k\\) its residue field. Using the above exercise, we can show\n  \\[\n    \\Ext_{R^a}^i(R^a, R^a) \\cong \\Ext_R^2(k, R).\n  \\]\n  It is a standard fact that if \\(K\\) is not spherically complete (e.g.\\ \\(\\C_p\\)) then \\(\\Ext^2_R(k, R)\\) is non-zero.\n\\end{remark}\n\n\\begin{ex}\n  Consider \\(R = \\F_p[t^{1/p^\\infty}], I = (t^{1/p^\\infty})\\). Consider\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & R \\ar[r, \"t\\cdot\"] & R \\ar[r] & R/tR \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  Applying \\((-)^a\\) and the \\((-)_*\\), we get\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & R \\ar[r] & R \\ar[r] & (R/tR)_*\n    \\end{tikzcd}\n  \\]\n  which is not exact on the right because of elements such as \\(\\sum_{n > 0} t^{1- 1/p^n}\\).\n\\end{ex}\n\nBut if \\(K\\) is spherically complete, then higher derived functors of \\((-)_*\\) vanish.\n\n\\section{Almost purity in characteristic \\(p\\) and for perfectoid fields}\n\nLet \\(R\\) be a perfect \\(\\F_p\\)-algebra and for any non-zero divisor \\(t \\in R\\), let \\(I = (t^{1/p^\\infty})\\).\n\n\\begin{proposition}\n  Let \\(S \\to S'\\) be a map of perfect \\(R\\)-algebras and suppose that \\(S, S'\\) are integral over \\(R\\). Assume that \\(S[\\frac{1}{t}] \\to S'[\\frac{1}{t}]\\) is an isomorphism. Then \\(S \\to S'\\) is an almost isomorphism.\n\\end{proposition}\n\n\\begin{proof}\n  Let \\(s \\in S'\\). Let \\(M \\subseteq S'\\) be the \\(S\\)-module generated by \\(s\\). Any finitely generated \\(R\\)-module \\(M' \\subseteq S'\\) has the property that there exists \\(N \\in \\N\\) such that \\(t^N \\cdot M' \\subseteq S\\) since \\(S[\\frac{1}{t}] \\cong S'[\\frac{1}{t}]\\) and \\(S'\\) is integral over \\(R\\). In particular there exists \\(N \\in \\N\\) such that for any \\(n \\in \\N\\), \\(t^N \\cdot s^n \\in S\\). Taking \\(n = p^r\\) for \\(r \\in \\N\\) and extracting \\(p^r\\)-th roots, we see that \\(t^{N/p^r} \\cdot s \\in S\\) (\\(t^{N/p^r}\\) exists as \\(I^N = I = (t^{1/p^\\infty})\\)). Hence \\(s\\) almost belongs to \\(S\\). Similarly we can show almost injectivity.\n\\end{proof}\n\n\\begin{corollary}\n  There is an equivalence of categories\n  \\[\n    \\{\\text{perfect \\(R[\\frac{1}{t}]\\)-algberas}\\} \\longleftrightarrow\n    \\{\\text{perfect \\(R\\)-algebras integral over \\(R\\)}\\}/\\sim_{\\text{almost iso}}\n  \\]\n\\end{corollary}\n\n\\begin{definition}[finite étale algebra]\\index{finite étale algebra}\n  Let \\(R\\) be a commutative ring. An \\(R\\)-algebra \\(S\\) is called \\emph{finite étale} if\n  \\begin{enumerate}\n  \\item \\(S\\) is finitely generated projective over \\(R\\),\n  \\item \\(R \\to S\\) is unramified, which means any of the following equivalent conditions is satisfied:\n    \\begin{enumerate}\n    \\item the multiplication map \\(m: S \\otimes_R S \\to S\\) admits a section in \\(S \\otimes_R S\\)-modules;\n    \\item exists an idempotent \\(e \\in S \\otimes_R S\\) such that \\(e\\) generates the kernel of \\(m\\) (then \\((1 - e) S \\otimes_R S \\cong S\\) and \\((1 - e) \\ker m = 0\\));\n    \\item \\(\\ker m/(\\ker m)^2 = 0\\).\n    \\end{enumerate}\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{construction}\n  In general, if \\(R \\to S\\) is a ring map such that \\(S\\) is finitely generated projective, then we have a trace map \\(\\tr: S \\to R\\). If \\(S\\) is free of finite rank then \\(S \\cong R^n\\) and \\(\\tr(s)\\) is the trace of the matrix that corresponds to multiplication by \\(s\\). If \\(S\\) is finitely generated projective then it corresponds to a locally free sheaf \\(\\sh F\\) of rank \\(n\\) over \\(\\Spec R\\). There is an open cover \\(\\{U_i\\}\\) of \\(\\Spec(R)\\) such that \\(\\sh F|_{U_i} \\cong \\sh O_{U_i}^n\\), so we can define trace maps on \\(\\sh F(U_i) \\cong \\sh O_X^n(U_i)\\). Since \\(\\tr (M) = \\tr (C^{-1}MC)\\) for any matrix \\(M\\), the local data can be glued together to give a trace map \\(\\tr: S \\to R\\).\n\\end{construction}\n\nThe trace map \\(\\tr: S \\to R\\) induces a trace pairing\n\\begin{align*}\n  \\Tr: S \\times S &\\to R \\\\\n  (s_1, s_2) &\\mapsto \\tr (s_1 s_2)\n\\end{align*}\nIt is a standard fact that this symmetric bilinear map is nondegenerate if and only if \\(R \\to S\\) is finite étale (do it locally).\n\nUsing the idempotent \\(e'\\) from the definition, we see that in fact \\(S \\otimes_R S \\cong S \\times S'\\) (as rings) for some finite étale \\(R\\)-algebra \\(S'\\). We write \\(e' = \\sum a_i \\otimes b_i \\in S \\otimes_R S\\). Then we can explicitly realise \\(S\\) as a direct summand of \\(R^n\\) via \\(S \\xrightarrow{\\alpha} R^n \\xrightarrow{\\beta} S\\) where\n\\begin{align*}\n  \\alpha(f) &=\n              \\begin{psmallmatrix}\n                \\tr (f a_1) \\\\\n                \\vdots \\\\\n                \\tr (f a_n)\n              \\end{psmallmatrix}\n  \\\\\n  \\beta\n  \\begin{psmallmatrix}\n    r_1 \\\\\n    \\vdots \\\\\n    r_n\n  \\end{psmallmatrix}\n            &= \\sum r_i b_i\n\\end{align*}\nTo see that it works, we need that \\(\\beta \\compose \\alpha = \\id\\), i.e.\\ \\(\\sum \\tr(f a_i) \\cdot b_i = f\\) for \\(f \\in S\\). Use that \\(S \\otimes_R S \\cong S \\times S'\\) and that the trace maps is additive across products of finite étale algebras, we can show that if \\(i_2: S \\to S \\otimes_R S, s \\mapsto 1 \\otimes s\\) then \\(\\tr_{i_2} (e') = \\tr_{S/S}(1) = 1\\). By compatiblitiy of the trace map with base change of rings, we get that\n\\[\n  \\sum \\tr(a_i) \\cdot b_i = 1\n\\]\nso we get the statement for \\(e'\\). Then repeat the same argument by replacing \\(e'\\) with \\((f \\otimes 1) \\cdot e'\\).\n\n\\begin{definition}\n  A \\emph{monoid} \\((M, \\mu, i)\\) in a monoidal category \\((\\c C, \\otimes, I)\\) is an object \\(M \\in \\c C\\) with morphisms \\(\\mu: M \\otimes M \\to M\\), \\(i: I \\to M\\) called \\emph{multiplication} and \\emph{unit morphism} making the following diagrams commute\n  \\[\n    \\begin{tikzcd}\n      (M \\otimes M) \\otimes M \\ar[r] \\ar[d, \"\\mu \\otimes 1\"] & M \\otimes (M \\otimes M) \\ar[r, \"1 \\otimes \\mu\"] & M \\otimes M \\ar[d] \\\\\n      M \\otimes M \\ar[rr, \"\\mu\"] && M\n    \\end{tikzcd}\n  \\]\n  \\[\n    \\begin{tikzcd}\n      I \\otimes M \\ar[r] \\ar[dr, \"\\lambda\"'] & M \\otimes M \\ar[d, \"\\mu\"] & M \\otimes I \\ar[l] \\ar[dl, \"\\eta\"] \\\\\n      & M\n    \\end{tikzcd}\n  \\]\n  where \\(\\lambda\\) and \\(eta\\) are left and right identity maps.\n\\end{definition}\n\n\\begin{eg}\n  In this course we meet monoidal categories \\((\\Mod_R, \\otimes_R, R)\\) and \\((\\Mod_R^a, \\otimes, R^a)\\). A monoid in \\((R, \\otimes, R)\\) is just an \\(R\\)-algebra.\n\\end{eg}\n\nWe define \\emph{almost \\(R\\)-algebras}\\index{almost algebra} or \\(R^a\\)-algebras to be the monoid objects in \\(\\Mod_R^a\\).\n\nThe functor \\((-)^a\\) restricts to \\(\\c{Alg}_R \\to \\c{Alg}_{R^a}\\). Moreover if \\(A\\) is an \\(R^a\\)-algebra then \\((A_*)^a \\cong A\\), \\(A_*\\) being an honest \\(R\\)-algebra.\n\n\\begin{definition}\n  A map \\(A \\to B\\) of \\(R^a\\)-algebras is \\emph{almost finite étale} if\n  \\begin{enumerate}\n  \\item \\(B\\) is almost finite projective (i.e.\\ almost finitely generated and almost projective) over \\(A\\),\n  \\item (almost unramified) there exists an almost idempotent, i.e.\\ \\(e \\in (B \\otimes B)_*\\) such that \\(e^2 = e\\), \\(\\ker (\\mu)_* \\cdot e = 0\\), where \\(\\mu: B \\otimes B \\to B\\).\n  \\end{enumerate}\n  We write \\(A_{\\textup{afét}}\\) for the category of almost finite étale \\(A\\)-algebras.\n\\end{definition}\n\n\\begin{theorem}[almost purity in characteristic \\(p\\)]\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(S\\) is a perfect \\(R\\)-algebra (\\(R\\) is a perfect \\(\\F_p\\)-algebra) which is integral over \\(R\\) and \\(S[\\frac{1}{t}]\\) is finite étale over \\(R[\\frac{1}{t}]\\), then \\(S\\) is almost finite étale over \\(R\\).\n  \\item Inverting \\(t\\) induces an equivalence of categories between finite étale \\(R^a\\)-algebras and finite étale \\(R[\\frac{1}{t}]\\)-algebras.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\n  Reduce to the case \\(S\\) is \\(t\\)-torsion free: the ideal of \\(t\\)-power torsion elements in \\(S\\) is almost zero. Given \\(a \\in S\\) which is \\(t\\)-power torsion, exists \\(n \\in \\N\\) such that \\(t^n \\cdot a = 0\\). Thus \\(t^n \\cdot a^{p^k} = 0\\) so by perfectness \\(t^{n/p^k} \\cdot a = 0\\). Thus we may replace \\(S\\) by \\(S/\\{t-\\text{power torsion}\\}\\) since the kernel is almost zero.\n\n  Reduce to when \\(R\\) (resp.\\ \\(S\\)) are integrallly closed in \\(R[\\frac{1}{t}]\\) (resp.\\ \\(S[\\frac{1}{t}]\\)): let \\(R_{\\mathrm{int}}\\) be the integral closure of \\(R\\) in \\(R[\\frac{1}{t}]\\). The \\(R\\)-submodule \\(f^N \\cdot R \\subseteq R[\\frac{1}{t}]\\) for \\(f \\in R_{\\mathrm{int}}\\) is finitely generated. Thus exists \\(c \\in \\N\\) such that \\(t^c \\cdot f^N \\in R\\). In particular \\(t^c \\cdot f^{p^n} \\in R\\) so \\(t^{c/p^n} \\cdot f \\in R\\) for all \\(n\\). Thus \\(f\\) almost belongs to \\(R\\), i.e.\\ \\(R \\to R_{\\mathrm{int}}\\) is an almost isomorphism. Similarly for \\(S\\).\n\n  Almost unramifniteness: \\(R[\\frac{1}{t}] \\to S[\\frac{1}{t}]\\) is finitely étale so exists \\(e \\in (S \\otimes S)[\\frac{1}{t}] = S[\\frac{1}{t}] \\otimes S[\\frac{1}{t}]\\) with property 2. Thus \\(t^c \\cdot e \\in S \\otimes_R S\\) for some \\(c \\in \\N\\). As \\(e^{p^n} = e\\), \\(t^{c/p^n} \\cdot e \\in S \\otimes S\\) for all \\(n \\in \\N\\). Thus \\(e\\) almost belongs to \\(S \\otimes S\\), i.e.\\ \\(e \\in (S^a \\otimes S^a)_*\\). Thus \\(R \\to S\\) is almost unramified.\n\n  It remains to prove that \\(S\\) is almost finite projective over \\(R\\). Since \\(t^{1/p^n} \\cdot e \\in S \\otimes S\\), fix \\(n \\in N\\), \\(t^{1/p^n} \\cdot e = \\sum a_i \\otimes b_i\\). Now we use the decomposition\n  \\[\n    S[\\frac{1}{t}] \\xrightarrow{\\alpha} R[\\frac{1}{t}]^n \\xrightarrow{\\beta} S[\\frac{1}{t}]\n  \\]\n  and consider maps\n  \\[\n    S \\xrightarrow{\\alpha_0} R^n \\xrightarrow{\\beta_0} S\n  \\]\n  where\n  \\begin{align*}\n    \\alpha_0(f) &=\n                  \\begin{psmallmatrix}\n                    \\tr (f \\cdot a_i) \\\\\n                    \\vdots \\\\\n                    \\tr (f \\cdot a_n)\n                  \\end{psmallmatrix}\n    \\\\\n    \\beta_0\n    \\begin{psmallmatrix}\n      r_1 \\\\\n      \\vdots \\\\\n      r_n\n    \\end{psmallmatrix}\n    &= \\sum r_i \\cdot b_i\n  \\end{align*}\n  Since \\(R\\) is integrally closed these maps are well-defined. By (*) we have \\(\\beta_0 \\compose \\alpha_0 = t^{1/p^n}\\) (use \\(S\\) is \\(t\\)-torsion free). In particular, multiplication by \\(t^{1/p^n}\\) factors through a finite free \\(R\\)-module. This is true for all \\(n\\). Thus \\(S\\) is almost finite projective.\n\n  For 2, the functor \\(R_{\\textup{afét}} \\to R[\\frac{1}{t}]_{\\textup{fét}}, S \\mapsto (S^a)_*[\\frac{1}{t}]\\) is an equivalence of category:\n\n  essential surjectivity: follows from 1 since any integral extension of \\(R[\\frac{1}{t}]\\) is obtained by an integral extension \\(R \\to S\\) and then inverting \\(t\\). By 1 \\(R \\to S\\) is almost finite étale.\n\n  fully faithful: fix: fix \\(S \\in  R_{\\textup{afét}}\\). Claim \\(S \\cong T^a\\) for the integral losure \\(T\\) of \\(R\\) in \\(S_*[\\frac{1}{t}]\\). So the claim recovers \\(S\\) functorially from the map \\(S \\to S_*[\\frac{1}{t}]\\) as desired\n\\end{proof}\n\nalmost direct sum of a finite module.\n\n\\section{Integral perfectoid rings}\n\n\\begin{definition}[integral perfectoid ring]\\index{integral perfectoid ring}\n  Let \\(A\\) be a topological ring. We say that \\(A\\) is \\emph{integral perfectoid} if there exists a non-zero divisor \\(\\pi \\in A\\) such that\n  \\begin{enumerate}\n  \\item the topology on \\(A\\) is the \\(\\pi\\)-adic topology and \\(A\\) is complete with respect to \\(\\pi\\)-adic topology,\n  \\item \\(p \\in \\pi^p A\\),\n  \\item \\(\\phi: A/\\pi A \\to A/\\pi^pA\\) is an isomorphism. \n  \\end{enumerate}\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(K\\) is a perfectoid field, by semiperfectness \\(K^\\circ/\\pi \\to K^\\circ/\\pi^p\\) is surjective for some appropriate non-zero divisor \\(\\pi \\in K^\\circ\\). To show injectivity, let \\(z \\in K^\\circ\\) be such that \\(z^p \\in (\\pi^p)\\). Then \\(z^p/\\pi^p\\) is power bounded, therefore so is \\(z/\\pi\\) so \\(z = \\pi \\cdot a\\) for some \\(a \\in K^\\circ\\).\n  \\item If \\(A\\) is integral perfectoid then so is the algebra of ``perfectoid restricted power series''\n    \\[\n      A \\langle t_1^{1/p^\\infty}, \\dots, t_n^{1/p^\\infty} \\rangle,\n    \\]\n    the \\(\\pi\\)-adic completion of \\(A[t_1^{1/p^\\infty}, \\dots, t_n^{1/p^\\infty}]\\).\n  \\item Let \\(A\\) be integral perfectoid and \\(B\\) étale over \\(A\\). Then \\(B\\) is also integral perfectoid. This uses the fact that in characteristic \\(p\\), the \\emph{relative Frobenius} is an isomorphism for étale maps, i.e. (commutative diagram)\n    \\[\n      \\begin{tikzcd}\n      \\end{tikzcd}\n    \\]\n    and étale maps are closed under base change.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{ex}\n  If \\(A\\) is a complete topological ring of characteristic \\(p\\), then \\(A\\) is integral perfectoid if and only if \\(A\\) is perfect and the topology is the \\(\\pi\\)-adic topology for some non-zero divisor \\(\\pi \\in A\\).\n\\end{ex}\n\n\\begin{construction}[tilt of an integral perfectoid ring]\n  We have already defined \\(A^\\tilt\\) and we have showed that \\(\\varprojlim_\\phi A \\to A^\\tilt\\) is an isomorphism of multiplicative monoids and a homeomorphism. We also defined the sharp map \\(\\sharp: A^\\tilt \\to A\\). This is multiplicative but not additive in general. More specifically\n  \\[\n    (a + b)^\\sharp = \\lim_n ((a^{1/p^n})^\\sharp + (b^{1/p^n})^\\sharp)^{p^n}.\n  \\]\n  Note also that modulo \\(p\\), sharp is a ring homomorphism \\(A^\\tilt \\to A \\to A/pA\\).\n\\end{construction}\n\n\\begin{lemma}\n  The tilt \\(A^\\tilt\\) of an integral perfectoid ring is integral perfectoid.\n\\end{lemma}\n\n\\begin{proof}\n  We know that \\(A^\\tilt\\) is perfect of characteristic \\(p\\). We also know that \\(A^\\tilt\\) is complete with respect to the inverse limit topology. The only thing we need is a non-zero divisior \\(\\pi^\\tilt \\in A^\\tilt\\) such that the topology is given by the \\(\\pi^\\tilt\\)-adic topology.\n\n  Let \\(\\pi \\in A\\) give the topology on \\(A\\). Since \\(\\phi: A/\\pi \\to A/\\pi^p\\) is surjective, there exists some element \\(\\varprojlim_\\phi A/\\pi^pA\\) of the form \\((\\pi (\\pi^p), \\pi^{1/p} (\\pi^p), \\dots)\\). The very same proof that showed \\(\\varprojlim_\\phi A \\cong \\varprojlim_\\phi A/\\pi A\\) can also be used to show that \\(\\varprojlim_\\phi A \\cong \\varprojlim_\\phi A/\\pi^p A\\). Thus exists \\((a_0, a_1, \\dots)\\) such that \\(a_0 = \\pi \\pmod{\\pi^p}\\) etc. Therefore \\(a_0 = u \\in \\pi\\) for \\(u \\in 1 + \\pi^{p - 1}A \\subseteq A^\\times\\), where the inclusion follows from the fact that \\(A\\) is \\(\\pi\\)-adically complete. After multiplication by a uit, we may asume that \\(\\pi\\) admits \\(p\\)-power roots.\n\n  Take \\(\\pi^\\tilt = (\\overline \\pi, \\overline \\pi^{1/p}, \\dots) \\in A^\\tilt\\). Check that \\(\\pi^\\tilt\\) is a non-zero divisor: for any \\(n \\in \\N_{> 0}\\), we have an exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & \\pi^{1 - 1/p^n} A/\\pi A \\ar[r] & A/\\pi A \\ar[r, \"\\pi^{1/p^n}\"] & A/\\pi A \\ar[r, \"\\phi^n\"] & A/\\pi A \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  third last term: if \\(a \\in A\\) is such that \\(a^{p^n} \\in \\pi A\\) then \\(\\frac{a}{\\pi^{1/p^n}} \\in A[\\frac{1}{\\pi}]\\) satisfies \\((\\frac{a}{\\pi^{1/p^n}})^{p^n} \\in A\\). (By exactness?) \\(\\frac{a}{\\pi^{1/p^n}} \\in A\\).\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & \\pi^{1 - 1/p^n} A/\\pi A \\ar[r] & A/\\pi A \\ar[r, \"\\pi^{1/p^n}\"] & A/\\pi A \\ar[r, \"\\phi^n\"] & A/\\pi A \\ar[r] & 0 \\\\\n      0 \\ar[r] & \\pi^{1 - 1/p^{n + 1}} A/\\pi A \\ar[r] \\ar[u] & A/\\pi A \\ar[r, \"\\pi^{1/p^n}\"] \\ar[u, \"\\varphi\"] & A/\\pi A \\ar[r, \"\\phi^n\"] \\ar[u, \"\\varphi\"] & A/\\pi A \\ar[r] \\ar[u, \"\\id\"] & 0\n    \\end{tikzcd}\n  \\]\n  We have a compatible system of inverse systems. Since all connecting maps in the inverse systems are surjective or \\(0\\), by Mittag-Leffler condition \\(\\varprojlim\\) is exact, we get an exact sequence\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & A^\\tilt \\ar[r, \"\\pi^\\tilt\"] & A^\\tilt \\ar[r, \"\\cdot^\\sharp \\pmod p\"] & A/\\pi A \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  Hence \\(\\pi^\\tilt\\) is indeed a non-zero divisor and \\(A^\\tilt/\\pi^\\tilt A^\\tilt \\cong A/\\pi A\\).\n\n  Check that the topology on \\(A^\\tilt\\) is induced by \\(\\pi^\\tilt\\): \\(A^\\tilt \\cong \\varprojlim A/\\pi A\\) is a homeomorphism so a basis of open neighbourhoods of \\(0\\) is give by \\(\\ker \\mathrm{pr}_n: A^\\tilt \\to A/\\pi A\\). Now the composition\n  \\[\n    A^\\tilt \\xrightarrow{\\phi^n} A^\\tilt \\xrightarrow{\\mathrm{pr}_n} A/A\n  \\]\n  is \\(pr_0\\), then\n  \\[\n    \\ker \\mathrm{pr}_n = \\phi^n (\\ker \\mathrm{pr}_0) = \\phi^n (\\pi^\\tilt A^\\tilt ) = (\\pi^\\tilt)^{p^n} A\n  \\]\n\\end{proof}\n\n\\section{Fontaine's \\(\\Theta\\) map}\n\nWe introduce \\(\\Theta: W(A^\\tilt) \\to A\\) (\\(W(A^\\tilt)\\) also called \\(A_{\\mathrm{inf}}\\)) for integral perfectoid rings.\n\n\\begin{remark}\n  Reminder on Witt ring, reference: Local Fields, Serre. Let \\(R\\) be a commutative ring.\n  \\begin{itemize}\n  \\item \\(W(R) = R^\\N\\) as a set.\n  \\item Addition and multiplication are given by certain polynomials over \\(\\Z\\). For example\n    \\begin{align*}\n      (a_0, a_1, \\dots) + (b_0, b_1, \\dots) &= (a_0 + b_0, a_1 + b_1 - \\sum \\frac{1}{p} \\binom{p}{i} a_0^i b_0^{p - i}, \\dots, ) \\\\\n      +(a_0, a_1, \\dots) (b_0, b_1, \\dots) &= (a_0b_0, a_0^pb_1 + b_0^pa_1 + a_1b_1, \\dots)\n    \\end{align*}\n  \\item There is a natural ring homomorphism called ghost or phantom map \\(\\mathrm{gh}: W(R) \\to R^\\N\\), where\n    \\[\n      \\mathrm{gh}_n: (a_0, a_1, \\dots) \\mapsto \\sum_{i = 0}^n p^i a_i^{p^{n - i}}\n    \\]\n  \\item If \\(\\Q \\subseteq \\R\\), \\(\\mathrm{gh}\\) is an isomorphism and if \\(R\\) is \\(p\\)-torsion free, \\(\\mathrm{gh}\\) is injective.\n  \\item Given \\(a \\in R\\), its Teichmüller lift is\n    \\[\n      [a] = (a, 0, \\dots) \\in W(R)\n    \\]\n    and \\([-]: W(R) \\to R\\) is a multiplicative map (but not additive).\n  \\item If \\(\\F_p \\subseteq R\\) then \\(W(R)\\) is \\(p\\)-adically complete and for any \\(a_i \\in R\\), \\(\\sum [a_i] p^i = (a_0, a_1^p, a_2^{p^2}, \\dots)\\). In particular, if \\(R\\) is perfect, \\(f \\in W(R)\\) may be written uniquely as \\(\\sum [a_i] p^i\\) for some \\(a_i \\in R\\). The element \\(p\\) is a non-zero divisor and \\(W(R)/p \\cdot W(R) \\cong R, (a_0, \\dots) \\mapsto a_0\\). Hence \\(W(R)\\) is a strict \\(p\\)-ring.\n  \\end{itemize}\n\\end{remark}\n\n\\begin{theorem}[Fontaine]\n  Let \\(A\\) be an integral perfectoid ring.\n  \\begin{enumerate}\n  \\item There is a unique homomorphism \\(\\Theta: A_{\\mathrm{inf}} \\to A\\) satisfying \\(\\Theta([b]) = b^\\sharp\\)\n  \\item \\(\\Theta\\) is surjective and its kernel is generated by a non-zero divisor (usually denoted by \\(\\xi \\in W(A^\\tilt)\\).\n  \\item \\(\\chi \\in \\ker \\phi\\) is a generator if and only if \\((\\chi = (\\chi_0, \\chi_1, \\dots) \\in W(A^\\tilt)\\) is such that \\(\\chi_1 \\in (A\\)\n  \\end{enumerate}\n\\end{theorem}\n\nWe are going to require some results that we do not have time to prove during this course. Instead, go through the following exercises on your own.\n\n\\begin{ex}\n  Suppose that \\(R\\) is perfect of characteristic \\(p\\) and let \\(t \\in R\\) be a non-zero divisor and \\(q \\in W(R)\\) such that \\(q = p \\pmod{[t]}\\), then\n  \\begin{enumerate}\n  \\item \\([t] \\in W(R)\\) is a non-zero divisor.\n  \\item using that \\(p\\) is a non-zero divisor, show that \\(t\\) is a non-zero divisor in \\(R = W(R)/p \\cdot W(R)\\), \\(p\\) is a non-zero divisor in \\(W(R)/([t])\\).\n  \\item \\(q\\) is a non-zero divisor in \\(W(R)/[t]\\), \\([t]\\) is a non-zero divisor in \\(W(R)/q \\cdot W(R)\\).\n  \\end{enumerate}\n\n  Now assume that \\(R\\) is \\(t\\)-adically complete, prove that \\(W(R)\\) is \\([t]\\)-adically complete (by induction show that \\(W(R)/p^n \\cdot W(R)\\) is \\([t]\\)-adically complete and pass to inverse limit). In fact, it is even \\((p, [t])\\)-adically complete.\n\n  Finally show that \\(w\\) is a non-zero divisor in \\(W(R)\\). Show that \\(W(R)/q \\cdot W(R)\\) is \\([t]\\)-adically complete.\n\\end{ex}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Every element \\(b \\in W(A^\\tilt)\\) may be written uniquely as \\(b = \\sum_{i \\geq 0} [b_i] p^i\\). We define\n    \\begin{align*}\n      \\Theta: W(A^\\tilt) &\\mapsto A \\\\\n      \\sum [b_i] p^i &\\mapsto \\sum b_i^\\sharp \\cdot p^i\n    \\end{align*}\n    which makes sense as \\(A\\) is \\(p\\)-adically complete and is well-defined by uniqueness of power series expansion. Left to show it is a ring homomorphism. Note that it is enough to check that \\(\\Theta\\) is a ring homomorphism modulo \\(p^n\\) as \\(A\\) is \\(p\\)-adically separated. Fix \\(n\\) and consider the ghost map \\(\\mathrm{gh}_n\\). te that Cif \\(a_i = a_i' \\pmod p\\) then \\(p^i a_i^{p^{n - i}} = p^i \\cdot a_i'^{p^{n - i}} \\pmod{p^{n + 1}}\\). Consider \\(\\mathrm{gh}_n \\pmod{p^{n + 1}}\\). The values only depend on the coordinates modulo \\(p\\), i.e.\\ we have a commutative diagram\n    \\[\n      \\begin{tikzcd}\n        W(A) \\ar[r, \"\\mathrm{gh}_n\"] \\ar[r] & A \\ar[d] \\\\\n        W(A/pA) \\ar[r, \"\\mathrm{gh}_n\"] & A/p^{n + 1}A\n      \\end{tikzcd}\n    \\]\n  \\end{enumerate}\n  Consider\n  \\[\n    \\begin{tikzcd}\n      W(A^\\tilt) \\ar[r, \"W(\\phi^{-n})\"] & W(A^\\tilt) \\ar[r, \"W(\\cdot^\\sharp \\pmod p)\"] & W(A/pA) \\ar[r, \"\\overline{\\mathrm{gh}}_n\"] & A/p^{n + 1}A\n    \\end{tikzcd}\n  \\]\n  this map is exactly \\(\\Theta \\pmod{p^{n + 1}}\\) as\n  \\[\n    \\begin{tikzcd}\n      \\sum [b_i] p^i = (b_0, b_1, b_2^{p^2}, \\dots) \\ar[r] & (b_0^{p^{-n}}, b_1^{p^{1 - n}}, \\dots) \\ar[r] & ((b_0^{p^{-n}})^\\sharp, \\dots) \\ar[r] & \\sum_{i = 0}^n ({b_n^{p^{i - n}}}^\\sharp)^{p^{n - i}} \\cdot p^i = \\sum_{i = 0}^n b_i^\\sharp \\cdot p^i\n    \\end{tikzcd}\n  \\]\n  Since all the maps in the composition are ring homomorphisms, so is \\(\\Theta \\pmod{p^{n + 1}}\\).\n\\item Both \\(W(A^\\tilt)\\) and \\(A\\) are \\(p\\)-adically complete so to prove surjectivity it is enough to check it modulo \\(p\\). But since \\(\\cdot^\\sharp \\pmod p: A^\\tilt \\to A/pA\\) is surjective, \\(\\Theta\\) is surjective.\n\n  Now we construct a generator for \\(\\ker \\Theta\\). Let \\(\\pi \\in A\\) be a perfectoid pseudo-uniformiser (a pseudo-uniformiser whcih satisfies a, b, c, in Def 5. 1 (integral perfectoid ring) that admits \\(p\\)-power roots and \\(\\pi^\\tilt = (\\pi, \\pi^{1/p}, \\dots)\\). Since \\(p \\in \\pi^pA\\) and \\(\\Theta\\) is surjective, we may write \\(p = \\pi^p \\cdot \\Theta(z)\\) (note \\(\\Theta(\\pi^\\tilt) = \\pi\\)). Hence \\(\\xi = p + [\\pi^\\tilt] \\cdot z'\\), where \\(z' = -z\\), is a generator: \\(\\xi \\in \\ker \\Theta\\) and by exercise earlier, \\(\\xi\\) is a non-zero divisor of \\(W(A^\\tilt)\\) (\\(R = A^\\tilt, t = \\pi^\\tilt, q = \\xi\\)). \\(\\ker \\Theta = \\xi \\cdot W(A^\\tilt)\\): by exercise \\(W(A^\\tilt)\\) is \\([\\pi^\\tilt]\\)-adically complete and \\(A\\) is \\(\\Theta([\\pi^\\tilt]) = \\pi\\)-adically complete and \\(\\pi\\)-torsion free. We see that \\(W(A^\\tilt)/\\xi \\cdot W(A^\\tilt) \\to A\\) is an isomorphism if and only if it is an isomorphism modulo \\(([\\pi^\\tilt])\\), i.e.\\ \\(W(A^\\tilt)/(\\xi, [\\pi^\\tilt]) \\to A/\\pi A\\) is an isomorphism. But as \\(\\xi = p \\pmod{[\\pi^\\tilt]}\\), \\(A^\\tilt/\\pi^\\tilt A^\\tilt \\to A/\\pi A\\) must be an isomorphism (prove in lecture 6).\n\\item\n  \\[\n    \\xi\n    = (\\xi_0, \\xi_1, \\dots)\n    = p + [\\pi^\\tilt]^p \\cdot x = (0, 1, 0, \\dots) + (\\pi^{\\tilt p} x_0, \\pi^{\\tilt p^2} \\cdot x_1, \\dots)\n    = (\\pi^{\\tilt p} \\cdot x_0, 1 + \\pi^{\\tilt p^2} \\cdot x_1, \\dots)\n  \\]\n  \\(\\xi_1 \\in A^{\\tilt \\times}\\) (\\(\\pi^\\tilt\\)-adically complete), \\(\\xi_1 \\in \\pi^\\tilt A^\\tilt\\). \\(\\chi = (\\chi_0, \\chi_1, \\dots) \\in \\ker \\Theta\\) and write \\(\\chi = \\beta \\cdot \\xi\\).\n  \\[\n    \\chi = (\\beta_0, \\beta_1, \\dots) (\\xi_0, \\xi_1, \\dots) = (\\beta_0 \\xi_0, \\beta_1 \\xi_0^p + \\beta_0^p \\xi_1, \\dots)\n  \\]\n  \\(\\ker \\Theta = \\chi \\cdot A^\\tilt\\) if and only if \\(\\xi \\cdot W(A^\\tilt) = \\beta \\xi \\cdot W(A^\\tilt)\\) if and only if \\(\\beta \\in W(A^\\tilt)^\\times\\) (using \\(\\xi\\) is a non-zero divisor), if and only if \\(\\beta_0 \\in A^{\\tilt \\times}\\) (use \\(W(A^\\tilt)\\) is \\(p\\)-adically complete and \\(W(A^\\tilt)/p \\cdot W(A^\\tilt) = A^\\tilt\\)), if and only if \\(\\beta_0^p \\cdot \\xi_1 \\in A^{\\tilt \\times}\\), if and only if \\(\\beta_1 \\xi_0^p + \\beta_0^p \\xi \\in A^{\\tilt \\times}\\) (\\(A^\\tilt\\) is \\(\\pi^\\tilt\\)-adically complete and \\(\\xi_0 \\in \\pi^\\tilt A^\\tilt\\)), if and only if \\(\\chi_1 \\in A^{\\tilt \\times}\\).\n\\end{proof}\n\n\\section{Tilting correspondence for integral perfectoid rings}\n\n\\begin{definition}[perfectoid algebra]\\index{perfectoid algebra}\n  Given an integral perfectoid ring \\(A\\) and \\(B\\) an \\(A\\)-algebra, we equip \\(B\\) with the topology induced by the image of \\(\\pi\\), the perfectoid pseudo-uniformiser of \\(A\\).\n\n  We say that \\(B\\) is a \\emph{perfectoid \\(A\\)-algebra} if \\(B\\) is an integral perfectoid ring with respect to this topology.\n\\end{definition}\n\nNote that if \\(\\pi \\in A\\) is a perfectoid pseudo-uniformiser then its image in \\(B\\) is a pefectoid pseudo-uniformiser of \\(B\\).\n\n\\begin{theorem}[tilting correspondence]\n  Fix an integral perfect ring \\(A\\). Tilting gives an equivalence of categories\n  \\begin{align*}\n    \\{\\text{perfectoid \\(A\\)-algebras}\\} &\\longleftrightarrow \\{\\text{perfectoid \\(A^\\tilt\\)-algebras}\\} \\\\\n    B &\\mapsto B^\\tilt \\\\\n    C^\\sharp = W(C) \\otimes_{W(A^\\tilt), \\Theta} A &\\mapsfrom C\n  \\end{align*}\n  The \\(\\sharp\\) map is sometimes called untilt.\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(\\pi \\in A\\) be a perfectoid pseudo-uniformiser admitting \\(p\\)-power roots and let \\(\\pi^\\tilt = (\\pi, \\pi^{1/p}, \\dots) \\in A^\\tilt\\). Recall \\(\\xi = p + [\\pi^\\tilt]^p \\cdot x \\in \\ker \\Theta\\) generates \\(\\ker \\Theta\\).\n\n  Step 1: let \\(B\\) be a perfectoid \\(A\\)-algebra. We show \\((B^\\tilt)^\\sharp = B\\). We have a commutative diagram\n  \\[\n    \\begin{tikzcd}\n      W(A^\\tilt) \\ar[r, \"\\Theta_A\"] \\ar[d] & A \\ar[d] \\\\\n      W(B^\\tilt) \\ar[r, \"\\Theta_B\"] & B\n    \\end{tikzcd}\n  \\]\n  and hence \\(\\xi\\) lands in \\(\\ker \\Theta_B\\). Since \\(\\xi_1 \\in A^{\\tilt \\times}\\), its image is also a unit in \\(B^\\tilt\\). By Fontaine 3, image of \\(\\xi\\) generates \\(\\ker \\Theta_B\\). Thus the commutative diagram is a pushout. Thus \\(W(B^\\tilt) \\otimes A \\to B\\) is an isomorphism.\n\n  Step 2: if \\(C\\) is a perfectoid \\(A^\\tilt\\)-algebra, we show that \\(C^\\sharp\\) is a perfectoid \\(A\\)-algebra and \\((C^\\sharp)^\\tilt = C\\). Since \\(\\Theta_A\\) is surjective with kernel generated by \\(\\xi\\), \\(C^\\sharp = W(C) \\otimes A = W(C)/\\xi W(C)\\) as \\(A \\cong W(A^\\tilt)/ \\xi W(A^\\tilt)\\). By exercise (\\(R = C, t = \\pi^\\tilt, q = \\xi\\)), \\(C^\\sharp\\) is \\(\\pi\\)-adically complete and \\(\\pi\\) is a non-zero divisor. We need \\(\\phi: C^\\sharp/\\pi C^\\sharp \\to C^\\sharp/\\pi^p C^\\sharp\\) to be an isomorphism. But \\(C^\\sharp = W(C)/\\xi \\cdot W(C)\\) and \\(\\xi = p \\pmod{[\\pi^\\tilt]^p}\\) so we need \\(C/\\pi^\\tilt C \\to C/(\\pi^\\tilt)^p \\cdot C\\) to be an isomorphism. This follows from definition as \\(C\\) is integral perfectoid. Finally\n  \\[\n    (C^\\sharp)^\\tilt = \\varprojlim_\\phi C^\\sharp/pC^\\sharp = \\varprojlim_\\phi C/\\pi^\\tilt C = C^\\tilt = C.\n  \\]\n\\end{proof}\n\n\\section{Perfectoid Tate rings}\n\nRecall that a \\emph{Tate ring} is a Huber ring such that there exists a pseudo-uniformiser \\(\\pi\\) (i.e.\\ a topological nilpotent unit). Some facts:\n\\begin{enumerate}\n\\item if \\(R_0 \\subseteq R\\) is any subring of definition, then \\(R_0\\) is \\((\\pi^n)\\)-adic for some \\(n\\);\n\\item if \\(R_0\\) is any ring with non-zero divisor \\(\\pi \\in R_0\\) and \\(R = R_0[\\frac{1}{\\pi}]\\) equipped with the topology induced by \\(\\{\\pi^n \\cdot R_0\\}\\) as a basis of open neighbourhoods of \\(0\\), then \\(R\\) is a Tate ring with ring of definition \\(R_0\\) and ideal of definition \\(I = (\\pi)\\).\n\\end{enumerate}\n\nGiven an integral perfectoid ring \\(A\\), let \\(\\pi\\) be a perfectoid pseudo-uniformiser. Then \\(A[\\frac{1}{\\pi}]\\) is a Tate ring. It does not depend on the choice of \\(\\pi\\): if \\(\\pi'\\) is another perfectoid pseudo-uniformiser then by definition \\(\\pi\\) and \\(\\pi'\\) induce the same topology on \\(A\\). Hence they divide a power of each other and \\(A[\\frac{1}{\\pi}] = A[\\frac{1}{\\pi}]\\). We thus have a \\emph{generic fibre functor} from the category of integral perfectoid rings to Tate rings, mapping \\(A \\mapsto A[\\frac{1}{\\pi}]\\).\n\n\\begin{definition}[perfectoid Tate ring]\\index{perfectoid Tate ring}\n  A Tate ring \\(R\\) is called a \\emph{perfectoid Tate ring} if any of the following equivalent conditions is satisfied:\n  \\begin{enumerate}\n  \\item \\(R\\) has a subring of definition \\(R_0\\) which is integral perfectoid;\n  \\item \\(R\\) is in the image of the generic fibre functor;\n  \\item the subring \\(R^\\circ\\) is integral perfectoid;\n  \\item (Fontaine) \\(R\\) is uniform (i.e.\\ \\(R^\\circ\\) is bounded) and there exists a pseudo-uniformiser \\(\\pi \\in R\\) such that \\(p \\in \\pi^p R^\\circ\\) and \\(\\phi: R^\\circ/\\pi R^\\circ \\to R^\\circ/\\pi^p R^\\circ\\) is an isomorphism.\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{proposition}\n  Let \\(R\\) be a perfectoid Tate ring and \\(R_0 \\subseteq R\\) a subring of definition. Then \\(R_0\\) is integral perfectoid if and only if it is \\(p\\)-closed, i.e.\\ if \\(f \\in R\\) is such that \\(f^p \\in R_0\\) then \\(f \\in R_0\\). In particular every subring of integral elements \\(R^+ \\subseteq R\\) is integral perfectoid.\n\\end{proposition}\n\n\\begin{proof}[Proof of the equivalence of conditions in definition]\\leavevmode\n  \\begin{itemize}\n  \\item \\(4 \\implies 1\\): if \\(R\\) is uniform then \\(R^\\circ\\) is a ring of definition, \\(\\pi \\in R^\\circ\\) so by the above reminder \\(R^\\circ\\) is \\(\\pi\\)-adic. The other conditions hold directly.\n  \\item \\(1 \\implies 2\\): note that any perfectoid pseudo-uniformiser \\(\\pi \\in R_0\\) is a pseudo-uniformsier of \\(R\\), since \\(\\pi R_0\\) is open, so fixing some pseudo-uniformiser \\(\\varpi \\in R\\), it follows that \\(\\varpi^n \\in \\pi R\\). Thus \\(\\pi \\in R^\\times\\) so \\(R = R_0[\\frac{1}{\\pi}]\\).\n  \\item \\(2 \\implies 3\\): suppose that \\(R = A[\\frac{1}{\\pi}]\\) where \\(A\\) is integral perfectoid and \\(\\pi\\) is a perfectoid pseudo-uniformiser. Note \\(R^{\\circ \\circ} \\subseteq A\\) since if \\(f \\in R^{\\circ \\circ}\\) then \\(f^{p^n} \\in A\\) (?). Thus \\(f \\in A\\): For \\(n = 1\\), let \\(\\ell \\geq 0\\) be the smallest integer such that \\(\\pi^\\ell f \\in A\\). If \\(\\ell > 0\\) then \\(\\pi^{\\ell \\cdot p} \\cdot f^p \\in \\pi^{p \\cdot \\ell} A \\subseteq \\pi^p A\\) so \\(\\pi^\\ell \\cdot f \\in \\pi A\\) by condition 3 of definition 4.5.1. So \\(\\pi^{\\ell - 1} \\cdot f \\in A\\), absurd. In partcicular \\(\\pi R^\\circ \\subseteq A\\) so \\(R^\\circ\\) is uniform.\n  \\item \\(3 \\implies 4\\): since any subring of definition is bounded, \\(R\\) is uniform and any perfectoid pseudo-uniformiser \\(\\pi \\in R^\\circ\\) will give all the assumptions.\n  \\end{itemize}\n\\end{proof}\n\n\\begin{proof}\n  \\(\\impliedby\\): Let \\(R_0\\) be a \\(p\\)-closed subring of definition (e.g.\\ \\(R^\\circ)\\). By \\(p\\)-closedness \\(R^{\\circ \\circ} \\subseteq R_0\\), so \\(\\pi \\in R_0\\), so \\(R_0\\) is \\(\\pi\\)-adic. Every element is \\(p\\)th power modulo \\(\\pi\\): let \\(f \\in R_0\\). Then \\(\\pi \\cdot f \\in R^{\\circ \\circ}\\). Since \\(\\pi \\cdot f \\in R^\\circ\\), by condition 3 exists \\(y, z \\in R^\\circ\\) such that \\(\\pi \\cdot f = y^p + y^p + \\pi^p \\cdot z\\). We may assume that \\(\\pi\\) admits \\(p\\)-power roots. Then \\(f - \\pi^{p - 1} \\cdot z = (\\pi^{-1/p} \\cdot y)^p \\in R_0\\). Hence \\(\\pi^{-1/p} \\cdot y \\in R_0\\). Thus \\(f\\) is indeed a \\(p\\)th power modulo \\(\\pi\\). Note \\(p \\in (\\pi^{1/p})^pR^{\\circ}\\), \\(p \\in \\pi^p R^\\circ \\subseteq \\pi R^{\\circ \\circ}\\). By \\(p\\)-closedness \\(\\phi: R_0/\\pi^{1/p}R_0 \\to R_0/\\pi R_0\\) is injective.\n\n  \\(\\implies\\) is a consequence of 2.\n\\end{proof}\n\nRecall that if \\(R\\) is uniform then any subring of integral elements is a subring of definition (\\(R_0 \\subseteq R\\) is a subring of definition if and only if it is open and bounded).\n\n\\begin{corollary}\n  Let \\(R\\) be a perfectoid Tate. Then any subring of defition contains \\(R^{\\circ \\circ}\\) and the resulting functor \\(R_0 \\mapsto R_0/R^{\\circ \\circ}\\) defines a bijection\n  \\[\n    \\{\\text{integral perfectoid subring of definition of } R\\}\n    \\longleftrightarrow\n    \\{\\text{\\(p\\)-closed subring of } R^\\circ/R^{\\circ \\circ}\\}\n  \\]\n  which restricts to a bijection\n  \\[\n    \\{\\text{subring of integral elements } R^+ \\subseteq R\\}\n    \\longleftrightarrow\n    \\{\\text{integrally closed subring of } R^\\circ/R^{\\circ \\circ}\\}\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Use the previous proposition and the observation that if \\(R_0\\) is \\(p\\)-closed then \\(R^{\\circ \\circ} \\subseteq R_0\\).\n\\end{proof}\n\n\\begin{remark}\n  Using that \\(R\\) is integral perfectoid of characteristic \\(p\\) if and only if \\(R\\) is perfect and the topology is \\(\\pi\\)-adic for some pseudo-uniformiser, one can show that a characteristic \\(p\\) complete Tate ring is perfectoid if and only if it is perfect.\n\n  So the only non-trivial part is to show that \\(R\\) is uniform. Let \\(R_0 \\subseteq R\\) be a subring of definition, \\(\\pi \\in R_0\\) a pseudo-uniformiser. Set\n  \\[\n    R_N = \\phi^{-n}(R_0) = \\{f \\in R: f^{p^n} \\in R_0\\},\n  \\]\n  which is a subring as \\(\\ch R = p\\). Since \\(\\phi\\) is a continuous isomorphism, it is a homeomorphism by open mapping theorem (which holds for complete Tate rings). \\(\\phi(R_0)\\) is open so \\(\\pi^m R_0 \\subseteq \\phi(R_0)\\) for some \\(m \\geq 1\\). Apply \\(\\phi^{-n}\\), \\(\\pi^{m/p^n} R_n \\subseteq R_{n - 1}\\) for all \\(n\\). By induction \\(\\pi^{\\sum_{i = 1}^n m/p^i} R_n \\subseteq R_0\\). Thus \\(\\pi^m R_n \\subseteq R_0\\) as \\(m \\geq \\sum m/p^i\\). Given \\(f \\in R^\\circ\\), \\(\\{f^\\N\\}\\) is bounded if and only if \\(\\pi^{p^n} \\cdot f^\\N \\subseteq R_0\\) for some \\(n \\geq 0\\). In particular \\(\\pi^{p^n} f^{p^n} \\in R_0\\), i.e.\\ \\(\\pi \\cdot f \\in R_0\\). Thus \\(\\pi^{m + 1} R^\\circ \\subseteq R_0\\), i.e.\\ \\(R^\\circ\\) is bounded.\n\\end{remark}\n\n\\begin{lemma}\n  Let \\(B\\) be a perfect \\(A\\)-algebra where \\(A\\) is integral perfectoid. Then \\(A \\to B\\) is an almost isomorphism if and only if \\(A^\\tilt \\to B^\\tilt\\) is an isomorphism.\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(\\pi, \\pi^\\tilt\\) be as before, i.e.\\ \\(\\pi\\) a perfectoid pseudo-uniformiser that admits \\(p\\)-power roots and \\(\\pi^\\tilt = (\\pi, \\pi^{1/p}, \\dots)\\). Then \\(\\pi^\\tilt\\) is a pseudo-uniformiser for \\(A^\\tilt\\).\n  \\begin{itemize}\n  \\item \\(\\implies\\): Since \\(A\\) is \\(\\pi\\)-torsion free, \\(A \\to B\\) is injective. \\(\\pi^{1/p^n}B \\subseteq A\\) for all \\(n \\geq 0\\). By injectivity \\(A^\\tilt \\cong \\varprojlim_\\phi A \\to \\varprojlim_\\phi B \\cong B^\\tilt\\) is also injective. Moreover given \\(b^\\tilt \\in B^\\tilt\\), \\(b^\\tilt = (b_0, b_1, \\dots)\\) and \\((b_0 \\pi^{1/p^n}, b_1 \\pi^{1/p^n}, \\dots) \\in A^\\tilt\\). Thus \\(A^\\tilt \\to B^\\tilt\\) is almost surjective.\n  \\item \\(\\impliedby\\): \\(A^\\tilt \\to B^\\tilt\\) is an almost isomorphism if and only if \\(A^\\tilt/\\pi^\\tilt A^\\tilt \\to B^\\tilt/\\pi^\\tilt B^\\tilt\\) is an almost isomorphism. But we have showed \\(A^\\tilt/\\pi^\\tilt A^\\tilt \\cong A/\\pi A, B^\\tilt/\\pi^\\tilt B^\\tilt \\cong B/\\pi B\\). Thus \\(A \\to B\\) is an almost isomorphism.\n  \\end{itemize}\n\\end{proof}\n\n\\begin{lemma}\nLet \\(B\\) be a perfect \\(A\\)-algebra where \\(A\\) is integral perfectoid. Then \\(A \\to B\\) is an almost isomorphism if and only if \\(A[\\frac{1}{\\pi}] \\to B[\\frac{1}{\\pi}]\\) is an isomorphism, where \\(\\pi\\) is a perfectoid pseudouniformiser that admits \\(p\\)-power roots.\n\\end{lemma}\n\n\\begin{proof}\\leavevmode\n  \\begin{itemize}\n  \\item \\(\\implies\\): let \\(\\phi: A \\to B\\). \\(\\ker \\phi\\) and \\(\\coker \\phi\\) are killed by \\((\\pi^{1/p^\\infty})\\), in particular killed by \\(\\pi\\). Thus both \\(\\ker \\phi\\) and \\(\\coker \\phi\\) vanish after inverting \\(\\pi\\).\n  \\item \\(\\impliedby\\): Let \\(R = A[\\frac{1}{\\pi}] = B[\\frac{1}{\\pi}]\\). Then \\(A\\) and \\(B\\) are integral perfectoid subrings of definitions of \\(R\\). Thus \\(R^{\\circ \\circ} \\subseteq A, B\\). In particular \\(\\pi^{1/p^n}B \\subseteq A\\), so we have an almost surjection \\(A \\to B\\). Almost injection is automatic as \\(A\\) is \\(\\pi\\)-torsion free.\n  \\end{itemize}\n\\end{proof}\n\n\\section{Tilting perfectoid Tate rings}\n\n\\begin{definition}[tilt of a perfectoid Tate ring]\\index{tilt!perfectoid tate ring}\n  The \\emph{tilt} of a perfectoid Tate ring \\(R\\) is by definition \\(R^\\tilt = R_0^\\tilt[\\frac{1}{\\pi^\\tilt}]\\), the generic fibre of \\(R_0^\\tilt\\).\n\\end{definition}\n\nThis does not depend on the choice of either \\(R_0\\) or \\(\\pi\\): \\(R_0 \\subseteq R^\\circ\\) (\\(R^\\circ\\) is the colimit of all subrings of definition) and they have the same generic fibre. Thus by last lemma in the previous section \\(R_0 \\to R^\\circ\\) is an almost isomorphism. THus \\(R_0^\\tilt \\to R^{\\circ \\tilt}\\) is also an isomorphism, hence \\(R_0^\\tilt[\\frac{1}{\\pi^\\tilt}] \\cong R^{0\\tilt}[\\frac{1}{\\pi^\\tilt}]\\).\n\n\\begin{theorem}[tilting correspondence of lattice of subrings]\\index{tilting correspondence!lattice of subrings}\n  Let \\(R\\) be a perfectoid Tate ring. Then \\(R^{\\circ \\tilt} = R^{\\tilt \\circ}\\). Moreover tilting gives a bijection\n  \\[\n    \\{\\text{integral perfectoid subrings of definitions of } R\\}\n    \\longleftrightarrow\n    \\{\\text{integral perfectoid subrings of definitions of } R^\\tilt\\}\n  \\]\n  which restricts to a bijection\n  \\[\n    \\{\\text{subrings of integral elements of } R\\}\n    \\longleftrightarrow\n    \\{\\text{subrings of integral elements of } R^\\tilt\\}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  We show \\(R^{\\circ \\tilt} = R^{\\tilt \\circ}\\). \\(R^{\\circ \\tilt}\\) is a subring of definition of \\(R^\\tilt\\) so \\(R^{\\circ \\tilt} \\subseteq R^{\\tilt \\circ}\\), so \\(R^{\\tilt \\circ}\\) is a perfectoid \\(R^{\\circ \\tilt}\\)-algebra. Since passing to generic fibre gives an isomorphism \\(R^{\\circ \\tilt}[\\frac{1}{\\pi^\\tilt}] \\to R^{\\tilt \\circ}[\\frac{1}{\\pi^\\tilt}]\\). Thus \\(R^\\circ \\to B = (R^{\\tilt \\circ})^\\sharp\\) is an almost isomorphism. Thus \\(R^\\circ[\\frac{1}{\\pi}] \\to B[\\frac{1}{\\pi}]\\) is an ismophism, so \\(B\\) is a subring of definition. Thus by tilting correspondence \\(R^{\\circ \\tilt} = R^{\\tilt \\circ}\\).\n\n  The rest of the statement follows from corollary 8.8.3.\n\\end{proof}\n\n\\begin{theorem}[tilting correspondence for perfectoid Tate rings]\n  Let \\(R\\) be a perfectoid Tate ring. Then tilting defines an equivalence of categories\n  \\[\n    \\{\\text{perfectoid Tate algebras over } R\\}\n    \\to\n    \\{\\text{perfectoid Tate algebras over } R^\\tilt\\}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\n\\begin{theorem}[tilting in dimension \\(0\\)]\n  Let \\(K\\) be a perfectoid field. Then \\(K \\mapsto K^\\tilt\\) defines an equivalence\n  \\[\n    \\{\\text{perfectoids fields over } K\\}\n    \\longleftrightarrow\n    \\{\\text{perfectoid fields over } K^\\tilt\\}\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Claim that if \\(R\\) is a perfectoid \\(K\\)-algebra then \\(R\\) is a perfctoid field if and only if \\(R^\\tilt\\) is a perfectoid field.\n\n  \\begin{proof}\n    One direction is clear. For if, we know that \\(R\\) is a uniform Tate complete algebra over \\(K\\). Consider the spetral norm on \\(R\\)\n    \\[\n      \\norm x_R = \\inf \\{|t|^{-1}: t \\in K^\\times, tx \\in R^\\circ\\},\n    \\]\n    a priori only submultiplicative. Since \\(R\\) is a uniform complete Tate algebra, \\(\\norm \\cdot_R\\) defines the topology on \\(R\\), i.e.\\ a neighbourhood basis of \\(0\\) is given by the sets \\(\\norm \\cdot_R^{-1}((0, \\varepsilon))\\). We need to show \\(\\norm \\cdot_R\\) is multiplicative and \\(R\\) is a field.\n\n    For multiplicativity, let \\(x, y \\in R\\). After multiplying by elements in \\(K\\) we may assume \\(x, y \\in R^\\circ\\), but not in \\(\\pi^{1/p} \\cdot R^\\circ\\). But we can find \\(x^\\tilt, y^\\tilt \\in R^{\\tilt \\circ}\\) with \\(x - (x^\\tilt)^\\sharp, y - (y^\\tilt)^\\sharp \\in \\pi R^\\circ\\). Then \\(\\norm x_R = \\norm{x^\\tilt}_{R^\\tilt}, \\norm y_R = \\norm{y^\\tilt}_{R^\\tilt}\\) and \\(\\norm{xy}_R = \\norm{x^\\tilt y^\\tilt}_{R^\\tilt}\\).\n\n    To show \\(R\\) is a field, choose \\(x\\) such that \\(x \\in R^\\circ\\) but not in \\(\\pi R^\\circ\\) and take \\(x^\\tilt\\) as above. By multiplicativity of \\(\\norm \\cdot_R\\), \\(\\norm{1 - \\frac{x}{(x^\\tilt)^\\sharp}}_R < 1\\). Hence \\(\\frac{x}{(x^\\tilt)^\\sharp}\\) is invertible, so is \\(x\\).\n  \\end{proof}\n\\end{proof}\n\n\\section{Perfectoid spaces and tilting}\n\n\\begin{definition}[adic space]\\index{adic space}\n  We define the category \\(\\c U\\)\n  \n  objects: triples \\((X, \\sh O_X, (|\\cdot|_x)_{x \\in X})\\), where \\(X\\) is a topological space, \\(\\sh O_X\\) a sheaf of topological rings, \\((|\\cdot|_x)\\) an equivalence class of continuous valuations on \\(\\sh O_{X, x}\\) (Recall from Non-archimedean Geometry that this determines \\(\\sh O_X^+\\))\n\n  morphisms: \\(f: X \\to Y\\) of topoogically ringed spaces such that the following diagram commutes (up to equivalence) for all \\(x \\in X\\)\n  \\[\n    \\begin{tikzcd}\n      \\sh O_{Y, f(x)} \\ar[r] \\ar[d] & \\sh O_{X, x} \\ar[d] \\\\\n      \\Gamma_{f(x)} \\cup \\{0\\} \\ar[r] & \\Gamma_x \\cup \\{0\\}\n    \\end{tikzcd}\n  \\]\n\n  An \\emph{adic space} is an object in \\(\\c U\\) such that it has an open covering of \\((U_i, \\sh O_X|_{U_i}, (|\\cdot|_x)_{x \\in U_i}) \\cong \\Spa(A_i, A_i^+)\\) for some sheafy Huber pair \\((A_i, A_i^+)\\) called affinoid adic spaces.\n\n  Equivalently, one can define adic spaces as a topological space \\(X\\) equipped with a sheaf of topological rings and a subsheaf \\(\\sh O_X^+ \\subseteq \\sh O_X\\) such that for each \\(x \\in X\\), exists an open neighbourhood \\(x \\in U \\subseteq X\\), a sheafy Huber pair \\((R, R^+)\\) and an isomorphism \\((U, \\sh O_X|_U, \\sh O_X^+|_U) \\cong (\\Spa(R, R^+), \\sh O_{\\Spa(R, R^+)}, \\sh O^+_{\\Spa(R, R^+)})\\).\n\\end{definition}\n\n\\begin{definition}[perfectoid space]\\index{perfectoid space}\n  An adic space \\(X\\) is a \\emph{perfectoid space} if we can choose each \\(R\\) to be perfectoid.\n\\end{definition}\n\n\\begin{remark}\n  It is not clear that a perfectoid Tate ring induces a sheafy Huber pair. But we know that a Tate-Huber pair which is stably uniform is sheafy (Buzzard-Verberkmoes).\n\n  In characteristic \\(p\\) it is eay to see that perfectness is preserved under rational localisation. Then using Theorem 9.9.4, one can show that rational subsets are perfectoid Tate rings. By Fontaine's definition they are uniform so \\(R\\) is stably uniform.\n\\end{remark}\n\nFix a perfectoid Huber pair \\((R, R^+)\\), i.e.\\ \\(R\\) is perfectoid Tate. Equivalently, \\(R^+\\) is integral perfectoid as it is \\(p\\)-closed. Fix a perfectoid pseudo-uniformiser \\(\\pi \\in R\\) admitting \\(p\\)-power roots and let \\(\\pi^\\tilt = (\\pi, \\pi^{1/p}, \\dots) \\in R^\\tilt\\). Let by \\(X = \\Spa(R, R^+)\\), \\(X^\\tilt = \\Spa(R^\\tilt, R^{\\tilt +})\\). Define, as before, the tilting map \\(\\tilt: X \\to X^\\tilt\\) as follow: given a continuous valuation \\(|\\cdot|: R \\to \\Gamma \\cup \\{0\\}\\), we define\n\\begin{align*}\n  |\\cdot|^\\tilt: R^\\tilt &\\to \\Gamma \\cup \\{0\\} \\\\\n  f &\\mapsto |f^\\sharp|\n\\end{align*}\n\n\\begin{lemma}\n  The tilting map \\(\\tilt\\) is well-defined, i.e.\\ \\(|\\cdot|^\\tilt\\) is a continuous valuation. Moreover \\(\\tilt: X \\to X^\\tilt\\) is continuous.\n\\end{lemma}\n\n\\begin{proof}\n  We already proved the first statement in chapter 1. To show the tilting map is continuous, it is enough to check that the preimage of a rational subset \\(U \\subseteq X^\\tilt\\) is a rational subset. The following is a general argument: let \\(f_1, \\dots, f_n, g \\in R^\\tilt\\) induce \\(U = X(\\frac{f_1, \\dots, f_n}{g})\\) (so \\(f_1, \\dots, f_n\\) generate an open ideal in \\(R\\) (?)). We may assume that \\(f_1, \\dots, f_n, g \\in R^{+ \\tilt}\\) and \\(f_n = (\\pi^\\tilt)^N\\): by multiplying by a suitable power of \\(\\pi^\\tilt\\) we may assume \\(f_1, \\dots, f_n, g \\in R^{+ \\tilt}\\) (multiplication by a unit does not change \\(U\\)). Moreover for Tate-Huber pairs the only open ideal is \\(R\\). Hence \\(\\sum h_if_i = 1\\) for some \\(h_i \\in R^\\tilt\\). We may find \\(M > 0\\) such that \\((\\pi^\\tilt)^Mh_i \\in R^{+ \\circ}\\), then for any \\(x \\in X^\\tilt\\),\n  \\[\n    |\\pi^M|_x = |\\sum \\pi^M \\cdot h_if_i|_x \\leq \\max |\\pi^M \\cdot h_i|_x \\cdot |f_i|_x^\\tilt \\leq |g|_x\n  \\]\n  We may ``add'' \\(\\pi^M\\), i.e.\\ \\(f_1, \\dots, f_n, \\pi^M, g\\) induce the same rational subset \\(U\\).\n\n  Then the untilts \\(f_1^\\sharp, \\dots, f_n^\\sharp, g^\\sharp\\) define a rational subset \\(V \\subseteq X\\) (since \\(\\pi^N \\in (f_1, \\dots, f_n)\\) hence it is open) and by definition \\(\\tilt^{-1}(U) = X(\\frac{f_1^\\sharp, \\dots, f_n^\\sharp}{g^\\sharp})\\).\n\\end{proof}\n\n\\begin{theorem}[tilting correpondence for (analytic topology of) perfectoid space]\\index{tilting correspondence!perfectoid space}\n  The tilting map \\(\\tilt: X \\to X\\) is a homeomorphism which identifies rational subsets. Moreover if \\(V \\subseteq X, U \\subseteq X^\\tilt\\) are corresponding subsets then\n  \\begin{enumerate}\n  \\item \\(\\sh O_X(U)\\) is a perfectoid Tate algebra over \\(R\\);\n  \\item \\(\\sh O_{X^\\tilt}(U)\\) is a perfectoid Tate algebra over \\(R^\\tilt\\);\n  \\item there exists a unique continuous \\(R^\\tilt\\)-algebra homomorphism \\(\\sh O_X(U)^\\tilt \\to \\sh O_{X^\\tilt}(U)\\). It is an isomorphism. It restricts to an isomorphism of integral perfectoid \\(R^{+ \\tilt}\\)-algebras \\(\\sh O_X^+(U)^\\tilt \\to \\sh O_{X^\\tilt}^+(U)\\).\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proposition}\n  Let \\(A\\) be an integral perfectoid ring, \\(\\pi \\in A\\) a perfectoid pseudo-uniformiser admitting \\(p\\)-power roots, \\(\\pi^\\tilt = (\\pi, \\pi^{1/p}, \\dots)\\). Let \\(f_1, \\dots, f_n, g \\in A^\\tilt\\) where \\(f_n= (\\pi^\\tilt)^N\\). Let \\(C\\) be the \\(A^\\tilt\\)-subalgebra of \\(A^\\tilt[\\frac{1}{g}]\\) generated by \\(\\frac{f_1^{1/p^k}}{g^{1/p^K}}, \\dots, \\frac{f_n^{1/p^k}}{g^{1/p^k}}\\) for all \\(k \\geq 0\\). Similarly let \\(B\\) be the \\(A\\)-subalgebra of \\(A[\\frac{1}{g^\\tilt}]\\) generated by ... Then\n  \\begin{enumerate}\n  \\item ...\n  \\item Similarly the kernel of\n    \\begin{align*}\n      A[x^{1/p^\\infty}] &\\to B \\\\\n      x_i^{1/p^k} &\\mapsto \\frac{{f^{\\sharp}}}{...}\n    \\end{align*}\n    is generated by\n  \\item the \\(\\pi^\\tilt\\)-adic completion of \\(C\\) is an integral perfectoid \\(A^\\tilt\\)-algebra (then \\(\\widehat C^\\sharp\\) is an integral perfectoid \\(A\\)-algebra, hence \\(\\widehat C^\\sharp[\\frac{1}{\\pi}]\\) is perfectoid Tate);\n  \\item there is a unique continuous map of \\(R\\)-algebras \\(\\widehat B[\\frac{1}{\\pi}] \\to \\widehat C^\\sharp[\\frac{1}{\\pi}]\\) which is an isomorphism (\\(\\widehat B[\\frac{1}{\\pi}]\\) is perfectoid Tate). This restricts to an injective almost surjection \\(\\widehat B \\to \\widehat C^\\sharp\\);\n  \\item \\(\\widehat C^\\sharp\\) is integral over \\(\\widehat B\\);\n  \\item \\(\\widehat C\\) is integral over the subring \\(\\widehat{A^\\tilt[\\frac{f_i}{g}]}\\) and \\(\\coker(\\widehat{A^\\tilt[\\frac{f_i}{g}]} \\to \\widehat C)\\) is killed by a power of \\(\\pi^\\tilt\\).\n\n    Similarly \\(\\widehat B\\) is integral over its subring \\(\\widehat{A[\\frac{f_i^\\sharp}{g^\\sharp}]}\\) and \\(\\coker\\) is killed by a power of \\(\\pi\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n  We show 3 first. \\(C\\) is clearly perfect and \\(\\pi^\\tilt\\) is a non-zero divisor. Therefore \\(\\widehat C\\) with respect to the \\(\\pi^\\tilt\\)-adic topology is integral perfectoid.\n\n  1: let \\(J = (g^{1/p^k} \\cdot x_i^{1/p^k} - f_i^{1/p^k})_{k \\geq 0, i = 1, \\dots, k}\\). \\(J \\subseteq \\ker \\psi^\\tilt\\). Note that \\(\\phi\\) acts as an isomorphism on both \\(J\\) and \\(\\ker \\psi^\\tilt\\). Hence it is enough to prove that \\(\\ker \\psi^\\tilt /J\\) vanishes after inverting \\(\\pi^\\tilt\\), i.e.\\ \\(A^\\tilt[\\frac{1}{\\pi^\\tilt}][x^{1/p^\\infty}]/J \\to C[\\frac{1}{\\pi}]\\) is an isomorphism, i.e.\\ injective. Since \\(f_n = (\\pi^\\tilt)^N\\), \\(f_n\\) is invertible on LHS. Then \\(g\\) is also invertible on both sides \\(g \\cdot x_n - f_n\\). By rescaling the relations, we need\n  \\[\n    A^\\tilt[\\frac{1}{\\pi^\\tilt}, \\frac{1}{g}][x^{1/p^\\infty}]/(x_i^{1/p^k} - \\frac{f_i^{1/p^k}}{g^{1/p^k}}) \\to C[\\frac{1}{\\pi^\\tilt}, \\frac{1}{g}] = A^\\tilt[\\frac{1}{\\pi^\\tilt}, \\frac{1}{g}]\n  \\]\n  is injection. But this is now elementary that it is an isomorphism.\n\n  2 + 4: by 3 \\(\\widehat C^\\sharp\\) is integral perfectoid and \\((\\frac{f_i^{1/p^k}}{g^{1/p^k}})^\\sharp\\) satisfies\n  \\[\n    (g^\\sharp)^{1/p^k} \\cdot (\\frac{f_i^{1/p^k}}{g^{1/p^k}})^\\sharp\n    = ((g^\\sharp)^{1/p^k} \\cdot \\frac{f_i^{1/p^k}}{g^{1/p^k}})^\\sharp\n    = (f_i^\\sharp)^{1/p^k}\n  \\]\n  and \\(g^\\sharp\\) is an non-zero divisor (apply the above for \\(i = n\\)). So there is a unique map of \\(A\\)-algebras\n  \\begin{align*}\n    eB &\\to \\widehat C^\\sharp \\\\\n    \\frac{f_i^{\\sharp 1/p^k}}{g^{\\sharp 1/p^k}} &\\mapsto (\\frac{f_i^{1/p^k}}{g^{1/p^k}})^?\n  \\end{align*}\n  Taking \\(\\pi\\)-adic completion we get \\(\\hat e: \\widehat B \\to \\widehat C^\\sharp\\). Inverting \\(\\pi\\) gives \\(\\widehat B[\\frac{1}{\\pi}] \\to \\widehat C^\\sharp[\\frac{1}{\\pi}]\\)...\n  \\[\n    e \\compose \\psi: A[x^{1/p^\\infty}]/(g^{\\sharp 1/p^k} \\cdot x_i^{1/p^k} - f_i^{\\sharp 1/p^k}) \\to B \\to \\widehat C^\\sharp\n  \\]\n  Using\n  \\[\n    A^\\tilt/\\pi^\\tilt A^\\tilt \\cong A/\\pi A, \\widehat C/\\pi^\\tilt \\widehat C \\cong \\widehat C^\\sharp/\\pi \\widehat C^\\sharp,\n  \\]\n  we see \\(e \\compose \\psi \\pmod \\pi\\) is the same as \\(\\psi^\\tilt \\pmod{\\pi^\\tilt}\\). By 1 \\(\\psi^\\tilt \\pmod{\\pi^\\tilt}\\) is an almost isomorphism. Then \\(\\psi\\) is almost injective modulo \\(\\pi\\) and surjective. Hence \\(\\psi\\) is an almost injection, proving 2.\n\n  Since \\(e \\compose \\psi\\) is an almost isomorphism and \\(\\psi\\) is surjection, \\(e\\) is also an almost isomorphism modulo \\(\\pi\\). By induction \\(e\\) is an almost isomorphism modulo \\(\\pi^n\\) for all \\(n \\geq 1\\). Then by taking inverse limit \\(\\hat e\\) is an almost isomorphism. Inverting \\(\\pi\\), we get 4.\n\n  5: we don't know if \\(\\widehat B\\) is integral perfectoid, so let \\(B'\\) be its integral closure in \\(\\widehat C^\\sharp\\). Since \\(\\widehat C^\\sharp\\) is an open integral perfectoid subring of \\(\\widehat{B[\\frac{1}{\\pi}]}\\), \\(B'\\) is integral perfectoid (\\(p\\)-closedness). \\(B'\\) contains \\(\\frac{f_i^{\\sharp 1/p^k}}{g^{\\sharp 1/p^k}}\\), hence its tilt contains \\(\\frac{f_i^{1/p^k}}{g^{1/p^k}}\\). Thus \\(B^{'\\tilt} \\supseteq C\\). But \\(B^{' \\tilt} \\subseteq \\widehat C\\), so \\(\\widehat C = B^{' \\tilt}\\). Thus \\(\\widehat C^\\sharp = B'\\).\n\n  6: \\(A^\\tilt[\\frac{f_i}{g}] \\subseteq C\\). Since \\(f_n = (\\pi^\\tilt)^N\\), it is enough that \\(\\coker(\\widehat{A^\\tilt[\\frac{f_i}{g}]} \\to \\widehat C\\) is killed by \\(f_n^n\\). By\n  \\[\n    ...\n  \\]\n  for any \\(k_1, \\dots, k_n \\geq 0\\). Taking \\(\\pi^\\tilt\\)-adic completion, \\(\\widehat{A^\\tilt[\\frac{f_i}{g}]} \\subseteq \\widehat C\\) such that \\(\\widehat{A^\\tilt[\\frac{f_i}{g}]} \\supseteq (\\pi^\\tilt)^M \\widehat C\\). But \\(C\\) is clearly integral over \\(A^\\tilt[\\frac{f_i}{g}]\\), so if combine these two observations \\(\\widehat C\\) is integral over \\(\\widehat{A^\\tilt[\\frac{f_i}{g}]}\\). Do the same in the untilted case.\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(X, X^\\tilt\\) be as before. Let \\(U \\subseteq X^\\tilt\\) be a rational subset. Then \\(V = \\tilt^{-1}(U)\\) is a rational subset and all three assertions of theorem 20.2 are true.\n\\end{corollary}\n\n\\begin{proof}\n  We have already seen that \\(V\\) is a rational subset. Let \\(f_1, \\dots, f_n, g \\in R^{+ \\tilt}\\) with \\(f_n = (\\pi^\\tilt)^N\\) such that \\(U = X^\\tilt(\\frac{f_1, \\dots, f_n}{g})\\). Let \\(B, \\widehat B, C, \\hat C\\) be as in the previous proposition. Recall that for any Huber pair \\((S, S^+)\\) and elements \\(f_1, \\dots, f_n, g \\in R\\) such that \\((f_1, \\dots, f_n)\\) is an open ideal,\n  \\begin{align*}\n    R\\langle \\tfrac{f_1, \\dots, f_n}{g} \\rangle &= \\widehat{R[\\tfrac{f_1, \\dots, f_n}{g}]} \\\\\n    R\\langle \\tfrac{f_1, \\dots, f_n}{g} \\rangle^+ &= \\text{ completion of the integral closure of } R[\\tfrac{f_1, \\dots, f_n}{g}] \\subseteq R[\\tfrac{1}{g}]\n  \\end{align*}\n  then\n  \\[\n    \\Spa(S\\tfrac{f_1, \\dots, f_n}{g}, S\\tfrac{f_1, \\dots, f_n}{g}^+) = \\Spa(S, S^+)(\\tfrac{f_1, \\dots, f_n}{g}).\n  \\]\n  By part 6 of the previous proposition, \\(\\widehat C[\\frac{1}{\\pi^\\tilt}] = \\sh O_{X^\\tilt}(U), \\widehat B[\\frac{1}{\\pi}] = \\sh O_X(V)\\). Therefore part 3 and 4 shows \\(\\sh O_{X^\\tilt}(U), \\sh O_X(U)\\) are perfectoid Tate and exists a unique isomorphism \\(\\sh O_X(V) \\to \\sh O_{X^\\tilt}(U)^\\sharp\\). Then we have\n  \\[\n    \\sh O_X^+(V) = \\text{ completion of integral closure of } R^+(\\tfrac{f_i^\\sharp}{g^\\sharp}) \\subseteq \\sh O_X(V)[\\tfrac{1}{g^\\sharp}].\n  \\]\n  Observe \\(\\frac{1}{g^\\sharp} \\in \\sh O_{X^\\tilt}(U)^\\sharp = \\sh O_X(U)\\) as \\(f_n^\\sharp = \\pi^N\\) and \\(\\widehat C^\\sharp\\) contains \\(\\frac{f_n^\\sharp}{g^\\sharp}\\). Thus \\(\\sh O_X^+(V)\\) is the completion of the integral closure of \\(R^+[\\frac{f_i^\\sharp}{g^\\sharp}] \\subseteq \\sh O_X(U)^\\sharp = \\widehat C^\\sharp[\\frac{1}{\\pi}]\\), which as an exercise can be show to be\n  the integral closure of \\(\\widehat{R^+[\\frac{f_i^\\sharp}{g^\\sharp}]} \\subseteq \\sh O_{X^\\sharp}(U)^\\sharp\\),\n\n  same as integral closure of \\(\\widehat B \\subseteq \\widehat B[\\frac{1}{\\pi}]\\) by 6\n\n  same as integral closure of \\(\\widehat C \\subseteq \\widehat C^\\sharp[\\frac{1}{\\pi}]\\) by 5\n\n  same as the sharp of the integral closure of \\(\\widehat C \\subseteq \\widehat C[\\frac{1}{\\pi^\\tilt}]\\) (compatibility of tilting with integral closure\n\n  same as the sharp of the integral closure of \\(\\widehat{R^{+ \\tilt}[\\frac{f}{g}]} \\subseteq \\sh O_{X^\\tilt}(U)\\)\n\n  same as \\(\\sh O_{X^\\tilt}^+(U)^\\sharp\\)\n\\end{proof}\n\nThe second ingredient is a subtle approximation lemma which roughly says that we can approximate elements in \\(R\\) by perfect elements.\n\n\\begin{proposition}[approximation lemma]\n  Let \\(S\\) be a perfectoid Tate \\(R\\)-algebra. Let \\(f \\in R\\) and fix rational number \\(c \\geq 0\\) and real number \\(\\varepsilon > 0\\). Then exists \\(g_{c, \\varepsilon} \\in R^\\tilt\\) such that for any \\(x \\in \\Spa(R, R^\\circ)\\),\n  \\[\n    |f(x) - g_{c, \\varepsilon}^\\sharp(x)| \\leq |\\pi(x)|^{1 - \\varepsilon} \\cdot \\max(|f(x)|, |\\pi(x)|^c).\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  Omitted. See Scholze, Perfectoid Space\n\\end{proof}\n\n\\begin{corollary}\n  Any rational subset \\(V \\subseteq X\\) is of the form \\(\\tilt^{-1}(U)\\) where \\(U \\subseteq X^\\tilt\\) rational.\n\\end{corollary}\n\n\\begin{proof}\n  Pick \\(f_1, \\dots, f_n, g \\in R^+\\) with \\(f_n = \\pi^N\\) such that \\(V = X(\\frac{f_1, \\dots, f_n}{g})\\). Then \\(V = \\bigcap X(\\frac{f_i, \\pi^N}{g})\\) so suffice to show the result for \\(X(\\frac{f_i, \\pi^N}{g})\\). Applying the approximation lemma with \\(f = f_i, c = N, \\varepsilon \\in (0, 1)\\), get \\(a \\in R^\\tilt\\) such that\n  \\[\n    \\max(|f(x)|, |\\pi(x)|^N) = \\max(|a^\\sharp(x)|, |\\pi(x)|^N)\n  \\]\n  (use approximation lemma to show this equality for any \\(\\varepsilon < 1\\)). Use approximation lemma again with \\(f = g, c = N, \\varepsilon = 1\\). Exists \\(b \\in R^\\tilt\\) such that\n  \\[\n    |g(x) - b^\\sharp(x)| \\leq \\max (|g(x)|, |\\pi(x)|^N).\n  \\]\n\n  Now let \\(x \\in X(\\frac{f_i, \\pi^N}{g})\\). We show \\(x \\in X(\\frac{a^\\sharp, \\pi^N}{b^\\sharp})\\). As \\(|\\pi(x)^N| \\leq |g(x)|\\),\n  \\[\n    |g(x) - b^\\sharp(x)| < |g(x)|\n  \\]\n  so by strict triangle inequality \\(|b^\\sharp(x)| = |g(x)|\\), so \\(|\\pi(x)|^N \\leq |b^\\sharp(x)|\\). Also we have \\(|a^\\sharp(x)| \\leq |\\pi(x)|^N\\) or \\(|a^\\sharp(x)| = |f(x)|\\). The former implies\n  \\[\n    |a^\\sharp(x)| \\leq |\\pi(x)|^N \\leq |g(x)| = |b^\\sharp(x)|\n  \\]\n  and the latter implies\n  \\[\n    |a^\\sharp(x)| = |f(x)| \\leq |g(x)| = |b^\\sharp(x)|\n  \\]\n  so we do have \\(x \\in X(\\frac{a^\\sharp, \\pi^N}{b^\\sharp})\\). The converse is similar.\n\\end{proof}\n\n\\begin{proof}[Proof of tilting correspondence in general case]\n  We know that the elements of the basis for the topology are pullbacks from \\(X^\\tilt\\) so \\(\\tilt: X \\to X^\\tilt\\) is injective by general topology (\\(X\\) is \\(T_0\\)). Suffice to show surjectivity since then rational subsets are mapped to rational subsets, so continuity of the inverse follows.\n\n  Pick \\(x \\in X^\\tilt\\). We then have a map of Huber pairs \\((R^\\tilt, R^{+ \\tilt}) \\to (\\widehat{k(x)}, \\widehat{k(x)}^+)\\), where \\(\\widehat{k(x)}\\) is a perfectoid field.\n\n  (recall\n  \\begin{align*}\n    \\sh O_{X, x} &= \\varinjlim_{x \\in U} \\sh O_X(U) \\\\\n    \\sh O_{X, x}^+ &= \\varinjlim_{x \\in U} \\sh O_X^+(U)\n  \\end{align*}\n  Facts:\n  \\begin{enumerate}\n  \\item \\(\\sh O_{X, x}\\) is local, the valuation \\(|\\cdot|_x\\) extends to \\(\\sh O_{X, x}\\).\n  \\item \\(\\sh O_{X, x} = \\{f \\in \\sh O_{X, x}: |f(x)| \\leq 1\\}\\)\n  \\item \\(\\mathfrak m_{\\sh O_{X, x}}\\) is the support of \\(|\\cdot|_x\\) on \\(\\sh O_{X, x}\\).\n  \\item \\(\\sh O_{X, x}^+\\) is local with \\(\\mathfrak m_{\\sh O_{X, x}^+} = \\{f \\in \\sh O_{X, x}: |f(x)| < 1\\}\\).\n  \\item \\(\\sh O_{X, x} \\to k(x), \\sh O_{X, x}^+ \\to k(x)\\) and let \\(\\k(x)^+\\) be its image. Then \\(\\sh O_{X, x}^+ \\to k(x)^+\\) is an isomorphism after \\(\\pi\\)-adic completion.\n  \\end{enumerate}\n  )\n\n  \\(\\widehat{k(x)}\\) is a non-archimedean field with valuation \\(|\\cdot|_x\\) and with corresponding valuation ring \\(\\widehat{k(x)^+}\\). Therefore \\(\\widehat{k(x)}^+\\)  is the completion of the colimit of integral perfectoid \\(R\\)-algebras, so is indeed integral perfectoid. Thus \\(\\widehat{k(x)}\\) is perfect Tate, so a perfectoid field.\n\n  By tilting correspondence \\((\\widehat{k(x)}^\\sharp, \\widehat{k(x)}^{+ \\sharp})\\) is a perfect Huber pair such that \\(\\widehat{k(x)}^\\sharp\\) is a perfectoid field. Then it corresponds to a point \\(y \\in X\\) as we have \\((R, R^+) \\to (\\widehat{k(x)}^\\sharp, \\widehat{k(x)}^{+ \\sharp})\\), and by construction \\(\\tilt(y) = x\\).\n\\end{proof}\n\n\\section{Tilting étale topology and almost purity}\n\nMotivation: this allows us to study étale cohomology of objects over \\(\\Q_p\\) via étale cohomology in characteristic \\(p\\).\n\n\\begin{theorem}[almost purity]\n  Let \\(R\\) be a perfectoid Tate ring.\n  \\begin{enumerate}\n  \\item Let \\(S\\) be a finite étale \\(R\\)-algebra. Give \\(S\\) the canonical topology (see below). Then \\(S\\) is a perfectoid Tate \\(R\\)-algebra, \\(S^\\circ\\) is almost finite étale over \\(R^\\circ\\).\n  \\item Tilting \\(S \\mapsto S^\\tilt\\) induces an equivalence of categories \\(R_{\\textup{fét}} \\to R^\\tilt_{\\textup{fét}}\\).\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{remark}\n  If \\(R\\) is Tate and \\(S\\) is finite étale over \\(R\\), there is a unique way to give \\(S\\) a topology so that \\(S\\) is Tate and \\(R \\to S\\) is continuous. This is the \\emph{canonical topology} on \\(S\\)\\index{canonical topology}. Pick any subring of definition \\(R_0 \\subseteq R\\) and pseudo-uniformiser \\(\\pi \\in R\\). Then we pick ga finitely generated \\(R_0\\)-submodule \\(M \\subseteq S\\) such that \\(M[\\frac{1}{\\pi}] = S\\) and give \\(M\\) the unique linear topology induced by topology on \\(R_0\\). Then put the induced topology on \\(S\\).\n\\end{remark}\n\n\\begin{proof}\n  The outline of the strategy is\n  \\begin{enumerate}\n  \\item part 1 is easy in characteristic \\(p\\);\n  \\item hence we will obtain an untilting functor \\(\\sharp: R^\\tilt_{\\textup{fét}} \\to R^\\tilt_{\\textup{fét}}\\) and the theorem can be reformulated as this functor is essentially surjective;\n  \\item we prove the theorem for perfectoid fields;\n  \\item finally observe that the adic spectra \\(X\\) and \\(X^\\tilt\\) are locally given by perfectoid fields. We use \\(X \\cong X^\\tilt\\) to glue the results in the case of fields.\n  \\end{enumerate}\n\n  We begin with step A.\n\n  \\begin{lemma}\n    Let \\(T\\) be a finite étale \\(R^\\tilt\\)-algebra. Then \\(T\\) is a perfectoid Tate algebra over \\(R^\\tilt\\) and \\(T^\\circ\\) is almost finite étale over \\(R^{\\tilt \\circ}\\).\n  \\end{lemma}\n\n  \\begin{proof}\n    (note that we cannot just use the old result in characteristic \\(p\\) as we do not necessarily have integral ring extension) Note that since \\(R^\\tilt\\) is perfect and \\(R^\\tilt \\to T\\) is étale, \\(T\\) is perfect (see example lecture 6, 5.2). Thus since \\(T\\) is Tate with the canonical topology, \\(T\\) is perfect Tate. Therefore \\(T^\\circ\\) is an integral perfect \\(R^{\\tilt \\circ}\\)-algebra. We have showed in Theorem lecture 5 4.6(2) that inverting \\(\\pi^\\tilt\\) induces an equivalence \\(R^{\\tilt \\circ}_{\\textup{afét}} \\to R^\\tilt[\\frac{1}{\\pi^\\tilt}]_{\\textup{fét}}\\). Hence exists some almost finiteétale \\(R^{\\tilt \\circ}\\)-algebra \\(S\\) such that \\(R^{\\tilt \\circ}[\\frac{1}{\\pi^\\tilt}] \\to S[\\frac{1}{\\pi^\\tilt}]\\). But \\(S\\) is also integral perfect as it is a subring of integral elements in \\(S[\\frac{1}{\\pi^\\tilt}]\\). Then \\(S \\to T^\\circ\\) is an almost isomorphism. By lemma (lecture 9) 8.6 (almost isomorphism if and only if iso by inverting one element), so \\(T^\\circ\\) is almost finite étale.\n  \\end{proof}\n\n  \\begin{lemma}\n    Let \\(A\\) be an integral perfectoid ring and \\(\\pi\\) a perfectoid pseudo-uniformiser which admits \\(p\\)-power roots. Let \\(M\\) be an \\(A\\)-module that is \\(\\pi\\)-adically complete and \\(\\pi\\)-torsion free. Then if \\(M/\\pi M\\) is almost finitely generated (resp.\\ almost finitely presented) then \\(M\\) is almost finitely generated (resp.\\ almost finitely presented).\n  \\end{lemma}\n\n  \\begin{proof}\n    We prove the finitely generated case. Fix some \\(\\varepsilon \\in (0, 1) \\subseteq \\Z[\\frac{1}{p}]\\). Then exists \\(\\overline M_{\\varepsilon}\\) finitely generated such that \\(\\pi^\\varepsilon \\cdot M/\\pi M \\subseteq \\overline M_\\varepsilon\\). Let \\(M_\\varepsilon\\) be a finitely generated submodule of \\(M\\) which projects onto \\(\\overline M_\\varepsilon\\). Then for any \\(x \\in M\\) we can write\n    \\[\n      \\pi^\\varepsilon \\cdot x = \\pi z_0 + m_0\n    \\]\n    where \\(z_0 \\in M, m_0 \\in M_\\varepsilon\\). Then \\(\\pi z_0 = \\pi^{1 - \\varepsilon}(\\pi^\\varepsilon z_0)\\) and repeat to get\n    \\[\n      \\pi^\\varepsilon x = m_0 + \\pi^{1 - \\varepsilon} m_1 + (\\pi^{1 - \\varepsilon})^2 m_2 + \\cdots\n    \\]\n    As \\(M\\) is \\(\\pi\\)-adically complete, it is \\(\\pi^{1 - \\varepsilon}\\)-adically complete so \\(\\pi^\\varepsilon M \\subseteq M_\\varepsilon\\).\n  \\end{proof}\n\n  \\begin{lemma}\n    Let \\(A\\) and \\(\\pi\\) be as in the previous lemma. Let \\(B\\) be a \\(\\pi\\)-adically complete and \\(\\pi\\)-torsion freee \\(A\\)-algebra. Then TFAE\n    \\begin{enumerate}\n    \\item \\(B\\) is almost finite étale over \\(A\\);\n    \\item \\(B/\\pi B\\) is almost finite étale over \\(A/\\pi A\\).\n    \\end{enumerate}\n  \\end{lemma}\n\n  \\begin{proof}\n    \\(B\\) is almost finitely presented by the previous lemma so \\(2 \\implies 1\\).\n\n    Then the existence of idempotent follows from the lifting property of idempotent via nilpotent (complete) ideal.\n  \\end{proof}\n\n  \\begin{lemma}\n    \\(T^\\sharp\\) is finite étale over \\(R\\), \\(T^{\\sharp \\circ}\\) is  almost finite étale over \\(R^\\circ\\).\n  \\end{lemma}\n\n  \\begin{proof}\n    By lemma we know \\(R^{\\tilt \\circ} \\to T^\\circ\\) is almost finite étale. Thus \\(R^{\\tilt \\circ}/\\pi^\\tilt R^{\\tilt \\circ} \\to T^\\circ/\\pi^\\tilt R^{\\tilt \\circ}\\) finite étale. As \\(R^\\circ/\\pi R^\\circ \\cong R^{\\tilt \\circ}/\\pi^\\tilt R^{\\tilt \\circ}, T^\\circ/\\pi^\\tilt T^\\circ \\cong T^{\\sharp \\circ}/\\pi T^{\\sharp \\circ}\\), have \\(R^\\circ\\) ...\n\n    Use lemma 3 to show \\(R^\\circ \\to T^{\\sharp \\circ}\\) is almost finite étale.\n  \\end{proof}\n\n  In other words untilting defines a fully faithful functor whose image consists of perfectoid Tate algebra \\(S\\) such that \\(S^\\circ\\) is almost finite étale over \\(R^0\\). Thus almost purity is a matter of essential surjectivity of the untilting functor.\n\n  We now carry out step c, proving almost purity for perfectoid fields. Let \\(K\\) be a perfectoid field. \n  \\begin{enumerate}\n  \\item Any finite extension \\(L/K\\) is perfectoid.\n  \\item \\(L \\mapsto L^\\tilt\\) is a degree-preserving equivalence of categories between finite extensions of \\(K\\) and finite extensions of \\(K^\\tilt\\). It follows that \\(\\gal(\\overline K/K) \\cong \\gal(\\overline K^\\tilt/K)\\).\n  \\end{enumerate}\n\n  \\begin{proof}\n    We know \\(\\O_L\\) is \\(\\pi\\)-adically complete and \\(\\pi\\)-torsion free, so we need that every element in \\(\\O_L/p \\O_L\\) is a \\(p\\)th power. In characteristic \\(p\\), every finite extension of perfect fields is perfect so \\(L\\) is perfectoid and we know 2 since tilting doesnt do anything in characteristic \\(p\\).\n\n    In characteristic \\(0\\), we already know that tilting and untilting gives an equivalence of categories between perfectoid fields over \\(K\\) and \\(K^\\tilt\\). Left to prove it is degree preserving.\n\n    Let \\(M/K^\\tilt\\) be a finite extension. Claim that \\(\\O_M/\\pi^\\tilt \\O_M\\) is almost free over \\(\\O_{K^\\tilt}/\\pi^\\tilt \\O_{K^\\tilt}\\) of rank \\([M : K^\\tilt]\\).\n\n    \\begin{proof}\n      This is a special case of the proof of almost purity in characteristic \\(p\\).\n    \\end{proof}\n\n    Claim also that it is easy to check that if \\(A\\) is integral perfectoid, \\(\\pi\\) a perfectoid pseudo-uniformsier which admits \\(p\\)-power roots, then a \\(\\pi\\)-adically complete, \\(\\pi\\)-torsion free module \\(M\\) is almost free of rank \\(d\\) if and only if \\(M/\\pi M\\) is almost free of rank \\(d\\). (exercise)\n\n    Use this and the fact that \\(\\O^\\sharp_M/\\pi \\O_M^\\sharp \\cong \\O_M/\\pi^\\sharp \\O_M\\) to get that \\(\\O_M^\\sharp\\) is almost free of rank \\([M : K^\\tilt]\\) over \\(\\O_K\\). Thus \\(M/K\\) is a finite extension of degree \\([M : K^\\tilt]\\). Thus untilting is a fully functor whose images are finite extensions of \\(K\\) that are perfectoid.\n\n    Left to show it is essentially surjective. We quote\n\n    \\begin{lemma}[Krasner's lemma]\n      Let \\(F\\) be a field which is complete with respect to an absolute value \\(|\\cdot|: F \\to R_{\\geq 0}\\), \\(\\alpha, \\beta \\in F^{\\text{sep}}\\) and \\(\\alpha_1 = \\alpha, \\alpha_2, \\dots, \\alpha_d \\in F^{\\text{sep}}\\) be conjugates of \\(\\alpha\\). If \\(|\\alpha - \\beta| < |\\alpha - \\alpha_i|\\) for \\(i = 2, \\dots, d\\) then \\(\\alpha \\in F(\\beta)\\).\n    \\end{lemma}\n\n    and its corollary\n\n    \\begin{corollary}\n      Let \\(F\\) be a field complete with respect to \\(|\\cdot|: F \\to R_{\\geq 0}\\) and \\(F_0 \\subseteq F\\) a dense subfield. Then \\(F = F^{\\text{sep}}\\) if and only if \\(F_0 = F_0^{\\text{sep}}\\).\n    \\end{corollary}\n\n    Now let \\(Q\\) be the completion of an algebraic closure of \\(K^\\tilt\\). By the corollary, \\(Q\\) is algebraically closed (it is perfect and separably closed so algebraically closed as perfect implies every algebraic extension is separable). By previous lemma \\(Q^\\sharp\\) is algebraically closed over \\(K\\). Moreover for any finite subextension \\(K^\\tilt \\subseteq M \\subseteq Q\\), we have \\(K \\subseteq M^\\sharp \\subseteq Q^\\sharp\\). Now let \\(N = \\bigcup M^\\sharp \\subseteq Q^\\sharp\\) over all \\(M\\) finite, then \\(N\\) is an algebraic extension of \\(K\\) which is dense in \\(Q^\\sharp\\): on the level of rings of integers\n    \\[\n      \\O_N/\\pi = \\varinjlim_M \\O_{M^\\sharp}/\\pi = \\varinjlim_M \\O_M/\\pi^\\tilt = \\O_{Q^\\sharp}/\\pi^\\tilt.\n    \\]\n    Thus by the corollary \\(N\\) is algebraically closed. In particular for any finite extension \\(K \\subseteq L\\) we have \\(L \\subseteq N\\) so exists a finite extension \\(M/K^\\tilt\\) such that \\(L \\subseteq M^\\sharp\\). Replace \\(M\\) by its Galois closure, we have shown untilting from subextensions of \\(M/K^\\tilt\\) to subextensions of \\(M^\\sharp/K\\) is essentially surjective. But as untilting is degree-preserving and \\(\\gal(M^\\sharp/K) = \\gal(M/K^\\tilt)\\) as it is fully faithful, the two categories have the same cardinality. Then essential surjectivity follows.\n  \\end{proof}\n\n  Step d: we are going to be handwaving here. Recall two facts from commutative algebra\n  \\begin{enumerate}\n  \\item Let \\(A\\) be a ring that is Henselian along an ideal \\(t A\\), where \\(t \\in A\\) is a non-zero divisor (i.e.\\ Hensel's lemma holds modulo \\(t A\\), e.g.\\ if \\(A\\) is \\(t\\)-adically complete). Then \\(A[\\frac{1}{t}]_{\\textup{fét}} \\to \\widehat A[\\frac{1}{t}]\\) is an equivalence of categories.\n  \\item Let \\(\\varinjlim_i A_i\\) be a filteded colimit of rings. Then the 2-limit \\(\\varinjlim_i (A_i)_{\\textup{fét}} \\to (\\varinjlim A_i)_{\\textup{fét}}\\) (LHS is a filtered colimit of categories).\n  \\end{enumerate}\n\n  Recall \\(\\widehat{k^+(x)} \\cong \\widehat{\\sh O_{X, x}^+}, \\widehat{k(x)} \\cong \\widehat{\\sh O_{X, x}^+}[\\frac{1}{\\pi}]\\) for any \\(x \\in X = \\Spa(R, R^+)\\) and analogously for \\(X^\\tilt\\). Note also that \\(\\sh O_{X, x}^+\\) is Henselian along \\(\\pi \\sh O_{X, x}^+\\) since it is a filtered dolmit of \\(\\pi\\)-adically complete rings. Similarly \\(\\sh O_{X^{\\tilt, x^\\tilt}}^+\\) is Henselian along \\(\\pi^\\tilt\\). Then the two results above translate to\n  \\[\n    \\widehat{k(x)}_{\\textup{fét}} = \\widehat{\\sh O_{X, x}^+}[\\tfrac{1}{\\pi}]_{\\textup{fét}} \\cong_{\\text{(1)}} \\sh O_{X, x}^+[\\tfrac{1}{\\pi}]_{\\textup{fét}} \\cong_{\\text{(2)}}  \\varinjlim_{x \\in U \\subseteq X} \\sh O_X(U)_{\\textup{fét}}.\n  \\]\n  Thus any finite étale \\(\\widehat{k(x)}\\)-algebra spreads out to a finite étale \\(\\sh O_X(U)\\)-algebra for a sufficiently small \\(U\\). Moreover spreading out is unique, i.e.\\ another choice must agree on a smaller rational subset.\n\n  Consider the commutative diagram\n\n  Conclusion: given a finite \\(R\\)-algebra \\(S\\), the finite étale \\(\\widehat{k(x)}\\)-algebra \\(S \\otimes_R \\widehat{k(x)}\\) may be writeen as \\(T_x^\\sharp \\otimes_{\\sh O_X(U)} \\widehat{k(x)}\\) for some finite étale \\(\\sh O_X(U_x)^\\tilt\\)-algebra \\(T_x\\), where \\(U_x\\) is some sufficiently small rational subset containing \\(x\\). Since \\(\\sh O_X, \\sh O_{X^\\tilt}\\) are sheafs with vanishing higher cohomology (we did not prove this), one can glue \\(T_x\\) as we vary \\(x\\) to a finite étale \\(R^\\tilt\\)-algebra \\(T\\) such that \\(T^\\sharp \\cong S\\).\n\\end{proof}\n\n\\begin{remark}\n  Fact: for any perfectoid space \\(X\\), it is true that \\(X_{\\textup{ét}} \\cong X_{\\textup{ét}}^\\tilt\\).\n  \\begin{enumerate}\n  \\item Fibre products exist in the category of perfectoid spaces over \\(X\\).\n  \\item étale morphisms: \\(f: X \\to Y\\) is étale if locally around any point we have open neighbourhoods \\(U\\) and \\(V\\) for \\(x \\in X\\) and \\(f(x) \\in Y\\) such that\n    \\[\n      \\begin{tikzcd}\n        U \\ar[r, \"j\"] \\ar[dr, \"f|_U\"'] & W \\ar[d, \"p\"] \\\\\n        & V\n      \\end{tikzcd}\n    \\]\n    where \\(p\\) is finite étale.\n  \\end{enumerate}\n\\end{remark}\n\n\n\n\\printindex\n\\end{document}", "meta": {"hexsha": "4f9be09021bd4ae0b1533b85ced3173e302d00e3", "size": 95467, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "IV/perfectoid_spaces.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "IV/perfectoid_spaces.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "IV/perfectoid_spaces.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 68.780259366, "max_line_length": 1136, "alphanum_fraction": 0.6213141714, "num_tokens": 34399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4149330979499462}}
{"text": "% Standard Article Definition\n\\documentclass[]{article}\n\n% Page Formatting\n\\usepackage[margin=1in]{geometry}\n\\setlength\\parindent{0pt}\n\n% Graphics\n\\usepackage{graphicx}\n\n% Math Packages\n\\usepackage{physics}\n\\usepackage{amsmath, amsfonts, amssymb, amsthm}\n\\usepackage{mathtools}\n\n% Code Def\n\\usepackage{listings}\n\n% Section Heading Settings\n\\usepackage{enumitem}\n\\renewcommand{\\theenumi}{\\alph{enumi}}\n\\renewcommand*{\\thesection}{Problem \\arabic{section}}\n\\renewcommand*{\\thesubsection}{\\alph{subsection})}\n\\renewcommand*{\\thesubsubsection}{\\quad \\quad \\roman{subsubsection})}\n\n%Custom Commands\n\\newcommand{\\Rel}{\\mathcal{R}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\n\\newcommand{\\toI}{\\xrightarrow{\\textsf{\\tiny I}}}\n\\newcommand{\\toS}{\\xrightarrow{\\textsf{\\tiny S}}}\n\\newcommand{\\toB}{\\xrightarrow{\\textsf{\\tiny B}}}\n\n\\newcommand{\\divisible}{ \\ \\vdots \\ }\n\\newcommand{\\st}{\\ : \\ }\n\n\n% Theorem Definition\n\\newtheorem{definition}{Definition}\n\\newtheorem{assumption}{Assumption}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{proposition}{Proposition}\n\n\n%opening\n\n\\title{MATH 5301 Elementary Analysis - Homework 8}\n\n\\author{Jonas Wagner}\n\n\\date{2021, October 29\\textsuperscript{th}}\n\n\\begin{document}\n\n\\maketitle\n\n% Problem 1 ----------------------------------------------\n\\section{}\nShow that the norms $\\norm{\\cdot}_1$, $\\norm{\\cdot}_p$ for $p > 1$, and $\\norm{\\cdot}_\\infty$ are equivalent.\n\n\\begin{definition}\n    For $\\norm{\\cdot}_a, \\norm{\\cdot}_b$ on $S$, \n    $\\norm{\\cdot}_a$ is said to be \\emph{stronger} then $\\norm{\\cdot}_b$ if \n    \\[\n        \\forall \\{x_n\\} \\subset S \\st x_n \\xrightarrow[d_a]{} x \\implies x_n \\xrightarrow[d_b]{} x\n    \\]\n\\end{definition}\n\\begin{definition}\n    $\\norm{\\cdot}_a$ and $\\norm{\\cdot}_b$ are said to be \\emph{equivalent},  $\\norm{\\cdot}_a \\sim \\norm{\\cdot}_b$,\n    if $\\norm{\\cdot}_a$ is stronger then $\\norm{\\cdot}_b$ \n    and $\\norm{\\cdot}_b$ is stronger then $\\norm{\\cdot}_a$. \n    This means that\n    \\[\n        \\norm{\\cdot}_a \\sim \\norm{\\cdot}_b \n            \\iff \\exists{\\alpha,\\beta \\in \\R_{>0}} : \n            \\forall_{x\\in S} \\alpha \\norm{\\cdot}_b \\leq \\norm{\\cdot}_a \\leq \\beta \\norm{x}_b\n    \\]\n\\end{definition}\n\\begin{definition} The following norms are defined as\n    \\begin{enumerate}\n        \\item $\\norm{\\cdot}_1 := \\norm{x}_1 = \\sum_{i=1}^n \\abs{x_i} = \\abs{x_1} + \\abs{x_2} + \\dots + \\abs{x_n}$\n        \\item $\\norm{\\cdot}_2 := \\norm{x}_2 = \\qty(\\sum_{i=1}^n \\abs{x_i}^2)^{1/2} = \\qty(\\abs{x_1}^2 + \\abs{x_2}^2 + \\dots + \\abs{x_n}^2)^{1/2}$\n        \\item $\\norm{\\cdot}_p := \\norm{x}_p = \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p} =\\qty(\\abs{x_1}^p + \\abs{x_2}^p + \\dots + \\abs{x_n}^p)^{1/p}, \\ p > 1$\n        \\item $\\norm{\\cdot}_\\infty := \\norm{x}_\\infty = \\max_{i=1}^n \\abs{x_i} = \\max(\\abs{x_1}, \\abs{x_2}, \\dots, \\abs{x_n})$\n    \\end{enumerate}\n\\end{definition}\n\n\\newpage\n\\begin{theorem}\n    The norms $\\norm{\\cdot}_1, \\norm{\\cdot}_p,$ and $\\norm{\\cdot}_\\infty$ are equivalent.\n    \\begin{proof}\n        % 1-norm ~ p-norm\n        \\begin{lemma}\\label{lem:1-1toP}\n            $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p$\n            \\begin{proof}\n                $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p$ is true iff\n                \\begin{multline*}\n                    \\forall_{x} \\exists_{\\alpha,\\beta \\in \\R_+} :\\\\\n                    \\alpha \\norm{x}_p \n                        \\leq \\norm{x}_1 \n                        \\leq \\norm{x}_p\\\\\n                    \\alpha \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\n                        \\leq \\sum_{i=1}^n \\abs{x_i}\n                        \\leq \\beta \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\\\\\n                \\end{multline*}\n                From the Holder's inequality we have \n                \\begin{align*}\n                    \\norm{x}_1 = \\sum_{i=1}^n \\abs{x_i}\n                        &= \\sum_{i=1}^n \\abs{x_i} (1)\\\\\n                        &\\leq \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\n                            \\qty(\\sum_{i=1}^n \\abs{1}^{(1-p)})^{1/(1-p)}\\\\\n                        &\\leq n^{1/(1-p)} \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p} \n                \\end{align*}\n                So for $0 < \\alpha \\leq n^{1/(1-p)}$ and $\\beta \\geq n^{1/(1-p)}$,\n                \\begin{align*}\n                    &\\alpha \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\n                        &&\\leq \\sum_{i=1}^n \\abs{x_i}\n                        &&\\leq \\beta \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\\\\\n                    &\\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\n                        &&\\leq n^{1/(1-p)} \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p} \n                        &&\\leq n^{1/(1-p)} \\qty(\\sum_{i=1}^n \\abs{x_i}^p)^{1/p}\n                \\end{align*}\n                Therefore,\n                \\[\\norm{x}_p \\leq \\norm{x}_1 \\leq n^{\\frac{1}{1-p}} \\norm{x}_p\\]\n                which proves $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p$.\n            \\end{proof}\n        \\end{lemma}\n        % \\newpage\n        %1-norm ~ \\infty-norm\n        \\begin{lemma}\\label{lem:1-1toInfty}\n            $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$\n            \\begin{proof}\n                $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$ is true iff\n                \\begin{multline*} \n                    \\forall_{x} \\exists_{\\alpha,\\beta \\in \\R_+} :\\\\\n                    \\alpha \\norm{x}_\\infty \\leq \\norm{x}_1 \\leq \\beta \\norm{x}_\\infty\\\\\n                    \\alpha \\max_{i=1}^n \\abs{x_i} \\leq \\sum_{i=1}^n \\abs{x_i} \\leq \\beta \\max_{i=1}^n \\abs{x_i}\\\\\n                \\end{multline*}\n                Clearly, this is true for when $\\alpha \\in (0,1]$. Similarly, when $\\beta \\geq n$ then $\\sum_{i=1}^n \\max_{i=1}^n \\abs{x_i}$ and then clearly greater then the $\\norm{x}_1$; therefore $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$.\n            \\end{proof}\n        \\end{lemma}\n        From, Lemma \\ref{lem:1-1toP} and Lemma \\ref{lem:1-1toInfty}, it is clear that $\\forall_{p > 1}$:\n        \\[\n            \\norm{x}_\\infty \n            \\leq \\norm{x}_p \n            \\leq \\norm{x}_1 \n            \\leq n^{1/{1-p}} \\norm{x}_p \n            \\leq n \\norm{x}_\\infty\n        \\]\n        Therefore, $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p \\sim \\norm{\\cdot}_\\infty$ ($\\forall_{p > 1}$).\n    \\end{proof}\n\\end{theorem}\n\n% Problem 2\n\\newpage\n\\section{}\nLet $(S, \\norm{\\cdot})$ and $(S', \\norm{\\cdot}')$ to be two normed spaces. \nShow that the following norms on $S \\cross S'$ are equivalent.\n\\begin{enumerate}\n    \\item $\\norm{(x,y)}_1 = \\norm{x} + \\norm{y}'$\n    \\item $\\norm{(x,y)}_2 = \\sqrt{\\norm{x}^2 + (\\norm{y}')^2}$\n    \\item $\\norm{(x,y)}_p = \\qty(\\norm{x}^p + (\\norm{y}')^p)^{1/p}$\n    \\item $\\norm{(x,y)}_\\infty = \\max\\qty{\\norm{x} + \\norm{y}'}$\n\\end{enumerate}\n\n\\begin{theorem}\n    The norms $\\norm{\\cdot}_1,\\norm{\\cdot}_2,\\norm{\\cdot}_p,$ and $\\norm{\\cdot}_\\infty$ are all equivalent on $S \\cross S'$.\n    \\begin{proof}\n        % 1-norm ~ 2-norm\n        \\begin{lemma}\\label{lem:2-1to2}\n            $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_2$\n            \\begin{proof}\n                $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_2$ is true iff\n                \\begin{multline*}\n                    \\forall_{(x,y) \\in S \\cross S'} \\exists_{\\alpha,\\beta \\in \\R_+} :\\\\\n                    \\alpha \\norm{(x,y)}_2 \n                        \\leq \\norm{(x,y)}_1 \n                        \\leq \\beta \\norm{(x,y)}_2\\\\\n                    \\alpha (\\norm{x}^2 + (\\norm{y}')^2)^{1/2}\n                        \\leq \\norm{x} + \\norm{y}'\n                        \\leq \\beta (\\norm{x}^2 + (\\norm{y}')^2)^{1/2}\\\\\n                \\end{multline*}\n                First, the following demonstrates that $\\norm{(x,y)}_2 \\leq \\norm{(x,y)}_1$\n                \\begin{align*}\n                    \\norm{(x,y)}_1^2\n                        &= (\\norm{x} + \\norm{y}')^2\\\\\n                        &= \\norm{x}^2 + (\\norm{y}')^2 + \\norm{x}\\norm{y}'\\\\\n                        &\\leq \\norm{x}^2 + (\\norm{y}')^2 + (\\norm{x})^2 + (\\norm{y}')^2\\\\\n                        &= 2 \\norm{x}^2 + 2(\\norm{y}')^2\\\\\n                        &= 2 \\norm{(x,y)}_2^2\\\\\n                    \\frac{1}{2} \\norm{(x,y)}_1^2 \n                        &\\leq \\norm{(x,y)}_2^2\n                \\end{align*}\n                Therefore,\n                \\[\n                    \\frac{1}{\\sqrt{2}} \\norm{(x,y)}_2 \\leq \\norm{(x,y)}_1\n                \\]\n                and this is also true for any $p>2$ as well using an arbitrary number of power expansions.\n\n                Next, from the Cauchy Schwartz's inequality we have \n                \\begin{align*}\n                    \\norm{(x,y)}_1 \n                        &= \\norm{x} + \\norm{y}'\\\\\n                    &= \\qty(\\norm{x} (1) + \\norm{y}' (1))\\\\\n                    &\\leq \\qty(\\norm{x}^2 + (\\norm{y}')^2)^{\\frac{1}{2}} \\qty(1^2 + 1^2)^{1 - \\frac{1}{2}}\\\\\n                    &= \\qty(2)^\\frac{1}{2} \\qty(\\norm{x}^2 + (\\norm{y}')^2)^{\\frac{1}{2}}\\\\\n                    &= \\sqrt{2} \\sqrt{\\norm{x}^2 + (\\norm{y}')^2}\\\\\n                    \\norm{(x,y)}_1\n                        &\\leq \\sqrt{2} \\norm{(x,y)}_2\n                \\end{align*}\n                Therefore,\n                \\[\\frac{1}{\\sqrt{2}} \\norm{x}_2 \\leq \\norm{x}_1 \\leq \\sqrt{2} \\norm{x}_2\\]\n                which proves $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_2$.\n            \\end{proof}\n        \\end{lemma}\n        \\newpage\n        % 1-norm ~ p-norm\n        \\begin{lemma}\\label{lem:2-1toP}\n            $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p$\n            \\begin{proof}\n                $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_p$ is true iff\n                \\begin{multline*}\n                    \\forall_{(x,y) \\in S \\cross S'} \\exists_{\\alpha,\\beta \\in \\R_+} :\\\\\n                    \\alpha \\norm{(x,y)}_p \n                        \\leq \\norm{(x,y)}_1 \n                        \\leq \\beta \\norm{(x,y)}_p\\\\\n                    \\alpha \\qty(\\norm{x}^p + (\\norm{y}')^p)^{1/p}\n                        \\leq \\norm{x} + \\norm{y}'\n                        \\leq \\beta \\qty(\\norm{x}^p + (\\norm{y}')^p)^{1/p}\\\\\n                \\end{multline*}\n                From the Holder's inequality we have \n                \\begin{align*}\n                    \\norm{x}_1 = \\norm{x} + \\norm{y}'\\\\\n                        &= \\norm{x}(1) + \\norm{y}'(1)\\\\\n                        &\\leq \\qty(\\norm{x}^p + (\\norm{y}')^p)^{1/p} \\qty(\\sum_{i=1}^2 \\abs{1}^{(1-p)})^{\\frac{1}{1-p}}\\\\\n                        &= n^{\\frac{1}{1-p}} \\qty(\\norm{x}^p + (\\norm{y}')^p)^{1/p}\\\\\n                        &= n^{\\frac{1}{1-p}} \\norm{(x,y)}_p\n                \\end{align*}\n                Therefore,\n                \\[\n                    \\norm{(x,y)}_1 \\leq n^{\\frac{1}{1-p}} \\norm{(x,y)}_p\n                \\]\n                and, since $p > 1$, then the remainder of the arguments from Lemma \\ref{lem:2-1to2} can be applied here to any arbitrary $p > 1$ to prove the norm equivalence with 1, 2, and any $p$ norms.\n            \\end{proof}\n        \\end{lemma}\n        %1-norm ~ \\infty-norm\n        \\begin{lemma}\\label{lem:2-1toInfty}\n            $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$\n            \\begin{proof}\n                $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$ is true iff\n                \\begin{multline*} \n                    \\forall_{(x,y) \\in S \\cross S'} \\exists_{\\alpha,\\beta \\in \\R_+} :\\\\\n                    \\alpha \\norm{(x,y)}_\\infty \\leq \\norm{(x,y)}_1 \\leq \\beta \\norm{(x,y)}_\\infty\\\\\n                    \\alpha \\max\\qty{\\norm{x} + \\norm{y}'} \\leq \\norm{x} + \\norm{y}' \\leq \\beta \\max\\qty{\\norm{x} + \\norm{y}'}\\\\\n                \\end{multline*}\n                Clearly, this is true for when $\\alpha \\in (0,1]$. Similarly, when $\\beta \\geq 2$ then $\\max{\\norm{x},\\norm{y}'}$ and is clearly greater then the $\\norm{(x,y)}_1$; therefore $\\norm{\\cdot}_1 \\sim \\norm{\\cdot}_\\infty$.\n            \\end{proof}\n        \\end{lemma}\n    \\end{proof}\n\\end{theorem}\n\n% Problem 3\n\\newpage\n\\section{}\nLet $X$ be a vector space and $V$ be a normed space. \nThe function $f : X \\to V$ is called bounded if $\\exists M \\st \\forall_{x\\in X} \\implies \\norm{f(x)} < M$. \nConsider the set $\\mathcal{B}(X,V)$ of all bounded functions from $X \\to V$. \n\n%Part a\n\\subsection{}\nShow that $\\mathcal{B}(X,V)$ is a vector space.\n\n\\begin{definition}\\label{def:vec_space}\n    A \\emph{Vector space} over a field is the set $V$ along with two operations (vector addition and vector multiplication) satisfying the basic vector properties.\n    \\begin{enumerate}\n        \\item Associativity of vector addition\n        \\[\\vb{u} + (\\vb{v} + \\vb{w}) = (\\vb{u} + \\vb{v}) + \\vb{w}\\]\n        \\item Commutativity of vector addition\n        \\[\\vb{u} + \\vb{v} = \\vb{v} + \\vb{u}\\]\n        \\item Identity element of vector addition (zero vector)\n        \\[\\forall_{\\vb{v} \\in V} \\exists_{\\vb{0} \\in V} \\st \\vb{v} + \\vb{0} = v \\]\n        \\item Inverse elements of vector addition (additive inverse)\n        \\[\\forall_{\\vb{v} \\in V} \\exists_{-v \\in V} \\st \\vb{v} + (-\\vb{v}) = \\vb{0}\\]\n        \\item Compatibility of scalar and field multiplication\n        \\[a (b \\vb{v}) = (a b) \\vb{v}\\]\n        \\item Identity element of scalar multiplication (multiplicative identity)\n        \\[\\exists_{1 \\in F} \\vb{1} \\vb{v} = v\\]\n        \\item Distributivity of scalar multiplication with vector addition\n        \\[a (\\vb{u} + \\vb{v}) = a \\vb{u} + a \\vb{v}\\]\n        \\item Distributivity of scalar multiplication with field addition\n        \\[(a + b) \\vb{v} = a \\vb{v} + b \\vb{v}\\]\n    \\end{enumerate}\n\\end{definition}\n\n\\begin{definition}\n    $\\mathcal{B}(X,V)$ is the set of all functions $f : X \\to V$ that are bounded under the definition:\n    \\[\\exists_{M \\in V} \\st \\forall_{x\\in X} \\implies \\norm{f(x)} < M\\]\n\\end{definition}\n\n\\begin{theorem}\n    $\\mathcal{B}(X,V)$ is a vector space.\n    \\begin{proof}\n        It is known that $X$ is a vector space and $V$ is a normed vector space.\n        For all functions between $X$ and $V$ the normed space result implies many of the required vector space properties directly.\n        For instance, assuming standard function addition and multiplication methods, the mapped results of the new superimposed function will satisfy Associativity, Commutativity, Identity and inverse for addition, Compatibility and identity of multiplication.\n        The Distributivity properties require more justification as they do not clearly result from the results of a single function.\n        Fortunately, the boundedness of $\\mathcal{B}(X,V)$ provides that an upper bound exists for the output and so the complicated parts of accounting for weirder functions allows for a proof of distributivity based on the output and the induced addition and multiplication operations will satisfy all of the superposition properties.\n    \\end{proof}\n\\end{theorem}\n\n%Part b\n\\subsection{}\nShow that the function $\\norm{\\cdot}_\\infty : \\mathcal{B}(X,V) \\to \\R_{+} :$\n\\[\n    \\norm{f}_\\infty := \\sup_{x\\in X} \\norm{f(x)}\n\\]\ndefines a norm on $\\mathcal{B}(X,V)$.\n\n\\begin{definition}\n    A \\emph{norm} is a function $\\norm{\\cdot} : V \\to \\R_{+}$ satisfying\n    \\begin{enumerate}\n        \\item Non-negativity \n            \\[\\forall_{x\\in V} \\norm{x} \\geq 0 \\implies \\norm{x} = 0 \\iff x = 0\\]\n        \\item Homogeneity \n            \\[\\norm{\\lambda \\cdot x} = \\abs{\\lambda} \\norm{x}\\]\n        \\item Triangle inequality \n            \\[\\norm{x + y} \\leq \\norm{x} + \\norm{y}\\]\n    \\end{enumerate}\n\\end{definition}\n\n\\begin{theorem}\n    $\\norm{\\cdot}_\\infty$ is a norm on $\\mathcal{B}(X,V)$.\n    \\begin{proof}\n        Since $\\mathcal{B}(X,V)$ is a vector space, the important properties of a field and simple vector operations can be assumed.\n\n        First, by definition, the non-negativity is satisfied by the mapped results are within $\\R_+$.\n\n        Second, the original norm properties from the normed vector space $V$ can be applied to each of the $\\norm{f(x)}$ within the $\\sup_{x \\in X}$, resulting in the homogeneity required for a norm.\n\n        Third, The triangle inequality can also be easily seen with the following:\n        \\begin{align*}\n            \\norm{x + y} \n                &\\leq \\norm{x} + \\norm{y}\\\\\n            \\sup_{(x + y) \\in X} \\norm{f(x + y)}\n                &\\leq \\sup{x \\in X} \\norm{f(x)} + \\sup_{y \\in X} \\norm{f(y)}\\\\\n            \\sup_{x,y \\in X \\st x+y \\in X} \\norm{f(x + y)}\n                &\\leq \\sup_{x,y \\in X} \\norm{x} + \\norm{y}\n        \\end{align*}\n        which is clearly true considering the definition of the original normed space $V$.\n    \\end{proof}\n\\end{theorem}\n\n% Problem 4\n\\newpage\n\\section{}\nLet $A$ be a dense set in metric space $(S,d)$, let $(V,d_1)$ be a complete metric space, and $f : A \\to Y$ be a uniformly continuous function.\n\nNote: assuming that there was a typo and that $Y$ is also dense within $V$.\n\n%Part a\n\\subsection{Show that if $\\{x_n\\}$ is a Cauchy sequence in $A$ then $\\{f(x_n)\\}$ is a Cauchy sequence in $Y$.}\n\n\\begin{definition}\n    A set $A$ is \\emph{dense} within metric space $(S,d)$ if and only if $A = X$.\n\\end{definition}\n\n\\begin{definition}\\label{def:complete}\n    Metric space $(S,d)$ is called a \\emph{complete metric space} if every cauchy sequence $\\{a_n\\}\\subset S$ converges in $S$.\n    \\[\\forall_{\\{a_n\\} \\subset S \\st \\{a_n\\} \\ \\textnormal{cauchy} \\ \\implies \\exists_{a \\in S} \\st \\lim_{n\\to\\infty} a_n = a}\\]\n\\end{definition}\n\n\\begin{definition}\n    $\\{a_n\\}$ is said to be a \\emph{cauchy} sequence if\n    \\[\\{a_n\\} : \\forall_{\\epsilon>0} \\exists_{N} : \\forall_{n,m > N} \\implies d(a_n,a_m) < \\epsilon\\]\n\\end{definition}\n\n\\begin{definition}\n    A function $f : X \\to Y$ is said to be \\emph{uniformly continuous} if and only if\n    \\[\\forall_{\\epsilon>0} \\exists_{\\delta>0} \\forall_{x,x' \\in X} d_X(x,x') < \\delta \\implies d_Y(f(x), f(x')) < \\epsilon\\]\n\\end{definition}\n\n\\begin{theorem}\n    If $\\{x_n\\}$ is a Cauchy sequence in $A$ then $\\{f(x_n)\\}$ is a Cauchy sequence in $Y$.\n    \\begin{proof}\n        \\begin{align*}\n            \\{x_n\\} \\ \\text{cauchy} &\\implies \\{f(x_n)\\} \\ \\text{cauchy}\\\\\n            \\forall_{\\epsilon,\\delta>0} \\exists_{N(\\epsilon,\\delta) \\in \\N} : \\forall_{n,m > N} \\implies d(x_n,x_m) < \\epsilon)\n            &\\implies d_1(f(x_{n_1}),f(x_{n_1})) < \\epsilon_1)\n        \\end{align*}\n        By definition of the complete metric space $Y$, every cauchy sequence within $Y$ will converge to within $Y$, therefore every cauchy sequence that gets mapped from the dense $A$ to $Y$ via the uniformly continuos function $f$ will be guaranteed to be cauchy as well.\n        (this could also be written out in a more complicated way using quantifiers, but the words just explained it better)\n    \\end{proof}\n\\end{theorem}\n\n%Part b\n\\subsection{Show that there is only one continuous function $g : X \\to Y$ so that $g(x) = f(x)$ forall $x \\in A$.}\n\\begin{theorem}\n    There is only one continuous $g : X \\to Y$ so that $g(x) = f(x)$ forall $x \\in A$.\n    \\begin{proof}\n        This means that each continuous function from $X$ or $A$ to $Y$ only has one complimentary function that produces the same image as it in $Y$.\n        For $f$, the definition of uniformly continuous is\n        \\[\\forall_{\\epsilon>0} \\exists_{\\delta>0} \\forall_{x,x' \\in A} d(x,x') < \\delta \\implies d_1(f(x), f(x')) < \\epsilon\\]\n        Similarly, $g$ being continuous is defined by \n        \\[\\forall_{x \\in X} \\forall_{\\epsilon>0} \\exists_{\\delta > 0} \\forall_{x, x'\\in X} d(x,x') < \\delta \\implies d_1(g(x),g(x')) < \\epsilon\\]\n        There is only one possible mapping for each complete relation between each of the element $x \\in A$ to $f(x) \\in Y$, so since $A$ is dense in $X$, each element $x \\in X$ can be mapped from $X$ to the image in $Y$.\n        Although this is simple and the result clearly follows, the quantifiers can be used to demonstrate this as follows:\n        \\begin{multline*}\n            \\qty(\\forall_{\\epsilon>0} \\exists_{\\delta>0} \\forall_{x,x' \\in A} d(x,x') < \\delta \\implies d_1(f(x), f(x')) < \\epsilon) \\land \\\\\n            \\land \\qty(\\forall_{x \\in X} \\forall_{\\epsilon>0} \\exists_{\\delta > 0} \\forall_{x, x'\\in X} d(x,x') < \n            \\delta \\implies d_1(g(x),g(x')) < \\epsilon)\\\\\n            \\forall_{\\epsilon>0} \\exists_{\\delta>0} \\forall_{x,x' \\in A} d(x,x') < \\delta \\implies d_1(f(x), f(x')) < \\epsilon \\land \\exists_{\\epsilon_1(\\epsilon,x,x')} d_1(g(x),g(x'))) < \\epsilon_1\n        \\end{multline*}\n        And since we want $g(x) = f(x)$, it is clear that the exact same restrictions (for each element across all of $A$ and $X$) will be in place, which implies that only one function will be able to satisfy it.\n    \\end{proof}\n\\end{theorem}\n\n% Problem 5\n\\newpage\n\\section{}\nLet $(L, \\norm{\\cdot})$ be a Banach space. \nLet $L_0$ be a closed subspace of $L$. \nDefine the factor-space $L/L_0$ as $:L_1 := L/L_0 = \\qty{x + y \\st x \\in L, y \\in L_0}$. \nIn other works, $L_1$ consists of all subsets of $L$ obtained from $L_0$ by shifting all its elements by some element $x$. \n\n%Part a\n\\subsection{Show that $L_1$ is a vector space.}\n\\begin{theorem}\n    $L_1$ is a vector space.\n    \\begin{proof}\n        From the definition of a vector space, Definition \\ref{def:vec_space}, it is necessary for all vector spaces to have additive and multiplicative operations that satisfy the multiple properties of superposition.\n        Directly by definition of the of $L_1$, being composed of a Banach space and a closed subspace within it, it may be possible to directly claim that it is also Banach. Regardless, the definition of each element within $L_1$ as a summation of two elements within a Banach (and therefore vector) space, already demonstrates the additive properties. Similarly, the composition of $L_1$ as a linear combination of elements from $L$ (and $L_0$) that individually satisfy all of the vector space properties will imply that an induced (yet technically undefined in the problem statement) set of additive and multiplicative operations that obey superposition.\n    \\end{proof}\n\\end{theorem}\n\n%Part b\n\\subsection{}\nDefine the function $\\norm{\\cdot} : L_1 \\to \\R_{+}$ as $\\norm{x}_1 = \\inf_{x - y \\in L_0} \\norm{y}$. \nShow that this function defines a norm on the space $L_1$.\n\n\\begin{theorem}\n    $\\norm{x}_1$ is a norm on $L_1$.\n    \\begin{proof}\n        Since $L_1$ is a vector space, the important properties of a field and simple vector operations can be assumed.\n\n        First, by definition, the non-negativity is satisfied by the mapped results are within $\\R_+$.\n\n        Second, the original norm properties from $L$ apply to each  $\\norm{y}$ within the $\\inf_{x-y \\in L_0}$, resulting in the homogeneity required for a norm.\n\n        Third, The triangle inequality can also be easily seen with the following:\n        \\begin{align*}\n            \\norm{(a,b) + (x,y)} \n                &\\leq \\norm{(a,b)} + \\norm{(x,y)}\\\\\n            \\inf_{(a+x) - (b+y) \\in L_0} \\norm{b+y}\n                &\\leq \\inf_{a - b \\in L_0} \\norm{b} + \\inf_{x-y \\in L_0} \\norm{y}\\\\\n                &\\leq \\inf_{(a-b), (x-y) \\in L_0} \\norm{b + y}\n        \\end{align*}\n        which is clearly true considering the definition of the original banach space $L$.\n    \\end{proof}\n\\end{theorem}\n\n%Part c\n\\subsection{Show that $L_1$ is a Banach space.}\n\\begin{definition}\n    A complete, normed, space is called a \\emph{Banach space}.\n\\end{definition}\n\n\\begin{theorem}\n    $L_1$ is a Banach space.\n    \\begin{proof}\n        From the first two parts of this question, we know that $L_1$ is a vector space, and $(L_1, \\norm{x}_1)$ is a normed space.\n        The only remaining requirement is that of completeness, which by Definition \\ref{def:complete}, means\n        \\begin{align*}\n            \\forall\\{l_n\\} \\subset L_1 \\st \\{l_n\\} \\ \\textnormal{cauchy} \\ \\implies \\exists_{l \\in L_1} \\st \\lim_{n\\to\\infty} l_n = l\n        \\end{align*}\n        Since $L_1$ is composed of the complete collection of projections of the closed $L_0$ shifted by arbitrary values within $L$, both of which are complete (since they are Banach), so any possible cauchy sequences within $L_1$ will tend towards another element within $L_1$.\n    \\end{proof}\n\\end{theorem}\n\n\n\n\n% Problem 6\n\\newpage\n\\section{}\nLet $C([-1,1])$ be the space of all continuous real-valued functions $f(x)$ with $x \\in [-1,1]$. \nLet $\\norm{f}_\\infty := \\sup_{x \\in [-1,1]} \\abs{f(x)}$. \nFind the distance from point $p = x^{2021}$ to the space $P_{2020}$ of all polynomials of degree less than or equal to 2020.\n\n\\begin{definition}\n    The \\emph{distance} between a point and a set is defined by \n    \\[dist(x,A) := \\inf_{a \\in A} d(x,a) = \\inf_{a \\in A} \\norm{x - a}\\]\n\\end{definition}\n\nThe distance between point $p = x^{2021}$ and $P_{2020}$ is calculated as follows:\n\\begin{align*}\n    \\textnormal{dist}(p,P) \n        &= \\inf_{y \\in P_{2020}} d(p,y)\n            = \\inf_{y \\in P_{2020}} \\norm{p - y}\\\\\n        &= \\inf_{y \\in P_{2020}} \\sup_{x \\in [-1,1]} \\abs{p(x) - y(x)}\\\\\n        &= \\inf_{y \\in P_{2020}} \\sup_{x \\in [-1,1]} \\abs{x^{2021} - \\sum_{i=0}^{2020} a_i^{(y)} x^i}\n    \\intertext{Since the supremum has to bound the maximum value, it can be assumed that the suppremmum of an absolute value will only occur when $a_i^{(y)}<0$ and $x = \\max{x \\in [-1,1]} = 1$.}\n        &= \\inf_{y \\in P_{2020}} (1)^{2021} - \\sum_{i=0}^{2020} -\\abs{a_i^{(y)}} (1)^i\\\\\n        &= \\inf_{y \\in P_{2020}} 1 + \\sum_{i=0}^{2020} \\abs{a_i^{(y)}}\n\\end{align*}\nWe can then see that the largest lower bound would be when $a_i^{(y)} = 0, \\ \\forall_{i\\in [0,2020]}$.\n\nTherefore, \\[\\textnormal{dist}(p=x^{2021},P_{2020}) = 1\\]\n\n\\end{document}\n", "meta": {"hexsha": "533e7043af5948f5132aea3f753980631ff444eb", "size": 25335, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Homework/HW8/MATH5301-HW8.tex", "max_stars_repo_name": "jonaswagner2826/MATH5301", "max_stars_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-01T05:26:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-01T05:26:53.000Z", "max_issues_repo_path": "Homework/HW8/MATH5301-HW8.tex", "max_issues_repo_name": "jonaswagner2826/MATH5301", "max_issues_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Homework/HW8/MATH5301-HW8.tex", "max_forks_repo_name": "jonaswagner2826/MATH5301", "max_forks_repo_head_hexsha": "40de090ba1a936b406aa8d4c4383be2cf1418f29", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.1941747573, "max_line_length": 658, "alphanum_fraction": 0.5598579041, "num_tokens": 8394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.4149307637107711}}
{"text": "\\documentclass{article}\n\\title{Matlab and LaTeX integration}\n\\author{Ben Newhouse, Super Happy Dev House 32}\n\\begin{document}\n\\maketitle\n\\section{Abstract}\nI am lazy.  I do lots of problem sets.  I do lots of problem sets in LaTeX because I am to lazy to find real paper to write on.  I also use matlab because I am too lazy to find a calculator.  From one script I want to be able to do everything.  Screw MVC, I need what PHP is to HTML what I'm doing is to LaTeX.\nAs you can see here, $1 + 1=$\n<?ml\n1 + 1\n?>\nThe integral of\n\\begin{displaymath}\n<?ml\nsyms x;\nlatex(x^2 + log(x))\n?>\n\\end{displaymath}\nis\n\\begin{displaymath}\n<?ml\nlatex((int(x^2 + log(x),x)))\n?>\n\\end{displaymath}\n\\end{document}\n", "meta": {"hexsha": "5348ea676346ba8f2b449fde859c587e0f7b1a87", "size": 694, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "test.tex", "max_stars_repo_name": "newhouseb/MatTex", "max_stars_repo_head_hexsha": "04a1b3ebc6f1c077ac9bf0361389e762ac0e5e53", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-09T13:26:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-09T13:26:55.000Z", "max_issues_repo_path": "test.tex", "max_issues_repo_name": "newhouseb/MatTex", "max_issues_repo_head_hexsha": "04a1b3ebc6f1c077ac9bf0361389e762ac0e5e53", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test.tex", "max_forks_repo_name": "newhouseb/MatTex", "max_forks_repo_head_hexsha": "04a1b3ebc6f1c077ac9bf0361389e762ac0e5e53", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.6923076923, "max_line_length": 310, "alphanum_fraction": 0.7146974063, "num_tokens": 214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.41493076053481226}}
{"text": "\\documentclass[10pt]{article}\n\\usepackage{nameref}\n\\usepackage{cleveref}\n\\usepackage{palatino}\n\\usepackage[scaled=0.9]{beramono}\n\\usepackage[T1]{fontenc}\n\\usepackage[protrusion=true,expansion=true]{microtype}\n\\usepackage[draft=false]{hyperref}\n\\usepackage[left=4cm, right=4cm, top=2cm, bottom=1.8cm]{geometry}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{ulem}\n\\usepackage{attrib}\n\\begin{document}\n\n\\title{Experiments with an Abstract Machine}\n\\maketitle\n\n\\noindent The aim is to build an abstract machine which follows the semantics of OCaml, but which 1) can operate step-by-step 2) keeps around enough information to be able to recompute a source-code representation of the currently-executing portion of the program 3) and its place in the rest of the source code. In Leroy ``Functional Programming Languages: Part II: Abstract Machines'', a basic arithmetic example is provided, followed by an SECD machine (with tail-call elimintion), and then OCaml's actual bytecode, the Zinc Abstract Machine.\n\nThe arithmetic example is implemented like this. Here is the type for programs:\n\n\\begin{verbatim}\ntype op = Add | Sub | Mul | Div\n\ntype prog =\n  Int of int\n| Op of prog * op * prog\n\\end{verbatim}\n\nAnd here is the type for bytecode instructions:\n\n\\begin{verbatim}\ntype instr =\n  IConst of int\n| IOp of op\n\\end{verbatim}\n\nCompilation is very simple, consisting of just conversion to  Reverse Polish:\n\n\\begin{verbatim}\nlet rec compile = function\n  Int i -> [IConst i]\n| Op (a1, op, a2) -> compile a1 @ compile a2 @ [IOp op]\n\\end{verbatim}\n\nEvaluation is simple, too. The program is run instruction-by-instruction, keeping a stack on to which operands are placed. An operator takes two operands off the stack, and pushes its result. At the end, the answer is left on the stack and may be returned:\n\n\\begin{verbatim}\nlet calc_op a b = function\n  Add -> a + b | Sub -> a - b\n| Mul -> a * b | Div -> a / b\n\nlet rec run s = function\n  [] -> hd s\n| IConst i::r -> run (Int i::s) r\n| IOp op::r ->\n    match s with\n      Int n2::Int n1::s' ->\n        run (Int (calc_op n1 n2 op)::s') r\n\\end{verbatim}\n\nRunning step-by-step is then simple: just process one instruction of the bytecode as above, returning the remaining ones and the new state of the stack. Now, how can we reconstruct the program source code, given the current state of the program and the stack? Here is the uncompilation function. We take the remainder of the program and the current stack. When we find an IOp instruction, we take two things off the stack and build an Op node. This is the conversion back to infix.\n\n\\begin{verbatim}\nlet rec uncompile s = function\n  [] -> hd s\n| IConst i::r ->\n    uncompile (Int i::s) r\n| IOp op::r ->\n    match s with\n      a::b::s' -> uncompile (Op (b, op, a)::s') r\n\\end{verbatim}\n\n\nWe only print out steps where something important happens. For arithmetic, this means an op.\n\nHow do we highlight the current redex? It's easy because the first piece of work to be done is always at the top of the program, since the program is executed in linear order.\n\n\\section*{Example}\n\n\\begin{verbatim}\n$ ./arith -e \"1 + 2 * (3 + 4)\" -show-unimportant\n1 + 2 * (3 + 4)\n1 + 2 * (3 + 4)\n1 + 2 * (3 + 4)\n1 + 2 * (3 + 4)\n1 + 2 * (3 + 4)\n1 + 2 * 7\n1 + 14\n15\n\n$ ./arith -e \"1 + 2 * (3 + 4)\"\n1 + 2 * (3 + 4)\n1 + 2 * 7\n1 + 14\n15\n\n$ ./arith -e \"1 + 2 * (3 + 4)\" -debug\nIOp +; IOp *; IOp + || 4; 3; 2; 1\n1 + 2 * (3 + 4)\nIOp *; IOp + || 7; 2; 1\n1 + 2 * 7\nIOp + || 14; 1\n1 + 14\n15\n\\end{verbatim}\n\n\\section*{Speed}\nCalculating $1 + 2 * (3 + 4)$ one million times, this bytecode interpreter is 64x faster than our syntactic interpreter when not printing anything out, and 5x faster when printing out all the steps.\n\n\\section*{Next Steps}\n\nNote that, because each step reduces the size of the expression (and does not generate anything new), 2) and 3) in the first paragraph above are the same thing. Soon, they will not be, and we will need to find some way to keep enough information around.\n\n\n\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "ea6a2506edab11b359c7428776e1d9a8dadec579", "size": 4008, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/abstractmachine.tex", "max_stars_repo_name": "johnwhitington/ocamli", "max_stars_repo_head_hexsha": "28da5d87478a51583a6cb792bf3a8ee44b990e9f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 100, "max_stars_repo_stars_event_min_datetime": "2017-09-08T09:49:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T12:12:50.000Z", "max_issues_repo_path": "docs/abstractmachine.tex", "max_issues_repo_name": "johnwhitington/ocamli", "max_issues_repo_head_hexsha": "28da5d87478a51583a6cb792bf3a8ee44b990e9f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-01-31T15:47:28.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-01T11:54:44.000Z", "max_forks_repo_path": "docs/abstractmachine.tex", "max_forks_repo_name": "johnwhitington/ocamli", "max_forks_repo_head_hexsha": "28da5d87478a51583a6cb792bf3a8ee44b990e9f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4705882353, "max_line_length": 545, "alphanum_fraction": 0.6988522954, "num_tokens": 1203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.41493075278740227}}
{"text": "\\lab{Breadth-first Search}{Breadth-first Search}\n\\objective{\nShortest path problems are an important part of graph theory and network analysis.\nApplications include finding the fastest way to drive between two points on a map, network routing, genealogy, automated circuit layout, and a variety of other important problems.\nIn this lab we represent graphs as adjacency dictionaries, implement a shortest path algorithm based on a breadth-first search, and use the NetworkX package to solve a shortest path problem on a large network of movies and actors.}\n\n\\section*{Adjacency Dictionaries} % ===========================================\n\nComputers can represent mathematical graphs in various ways.\nGraphs with very specific structures are often stored with specialized data structures, such as binary search trees.\nMore general graphs without structural constraints are usually represented with an \\emph{adjacency matrix}, where each row and column of the matrix corresponds to a node in the graph, and the entries indicate connections between nodes.\nAdjacency matrices are usually implemented in a sparse matrix format since only the entries corresponding to node connections are nonzero.\n\nAnother common graph data structure is an \\emph{adjacency dictionary}, a dictionary with a key for each node in the graph.\nThe dictionary values are the set of nodes connected to the key node.\nAdjacency dictionaries automatically gain the advantages of a sparse matrix format since they only store information on the actual node connections (the nonzero entries of the adjacency matrix).\n% In Python, dictionaries are also much faster for lookup than matrices.\n\n\\begin{figure}[H] % simple graph, its adjacency matrix, and its adjacency dict.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.32\\textwidth}\n\\centering\n\\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n    % Nodes\n    \\node[normalcircle] (A) [] {A};\n    \\node[normalcircle] (B) [above of=A] {B};\n    \\node[normalcircle] (C) [right of=B] {C};\n    \\node[normalcircle] (D) [below of=C] {D};\n    % Edges\n    \\foreach \\a/\\b in {A/B,A/D,B/D,C/D} \\draw[thick,-,>=stealth'] (\\a) edge (\\b);\n\\end{tikzpicture}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n\\centering\n\\begin{align*}\n    \\begin{blockarray}{ccccccc}\n    & & \\small\\text{\\textcolor{gray}{A}} & \\small\\text{\\textcolor{gray}{B}} & \\small\\text{\\textcolor{gray}{C}} & \\small\\text{\\textcolor{gray}{D}} & \\\\\n    \\begin{block}{c[cccccc]}\n    \\small\\text{\\textcolor{gray}{A}} & & 0 & 1 & 0 & 1 & \\topstrut\\\\\n    \\small\\text{\\textcolor{gray}{B}} & & 1 & 0 & 0 & 1 & \\\\\n    \\small\\text{\\textcolor{gray}{C}} & & 0 & 0 & 0 & 1 & \\\\\n    \\small\\text{\\textcolor{gray}{D}} & & 1 & 1 & 1 & 0 & \\botstrut\\\\\n    \\end{block}\\end{blockarray}\n\\end{align*}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n\\centering\n\\begin{align*}\n\\{\\text{A}&:\\ \\{\\text{B},\\ \\text{D}\\},\\\\\n  \\text{B}&:\\ \\{\\text{A},\\ \\text{D}\\},\\\\\n  \\text{C}&:\\ \\{\\text{D}\\},\\\\\n  \\text{D}&:\\ \\{\\text{A},\\ \\text{B},\\ \\text{D}\\}\\}\n\\end{align*}\n\\end{subfigure}\n\\caption{A simple unweighted graph (left), its adjacency matrix (middle), and its adjacency dictionary (right).\nThe graph is undirected, so the adjacency matrix is symmetric.\nNote that the adjacency dictionary also encodes this behavior: since A and B are connected, B is in the set of values corresponding to the key A, and A is in the set of values corresponding to the key B.}\n% There are eight $1$'s in the matrix, corresponding to $8$ total values in the dictionary.}\n\\label{fig:bfs-simple-graph}\n\\end{figure}\n\n\\subsection*{Hash-based Data Structures} % ------------------------------------\n\nA Python \\li{set} is an unordered data type with no repeated elements.\nThe set class is implemented as a \\emph{hash table}, meaning it uses \\emph{hash values}---integers that uniquely identify an object---to organize its elements.\nRoughly speaking, in order to access, add, or remove an object \\li{x} to a set, Python computes the hash value of \\li{x}, and that value indicates where \\li{x} is (or should be) in memory. % (usually with the built-in \\li{hash()} function)\nIn other words, there is only one place in memory that \\li{x} could be; if it isn't in that place, it isn't in the set.\nThis implementation results in $O(1)$ lookup, insertion, and removal operations, an enormous improvement over the $O(n)$ search time for lists and the $O(\\log{n})$ search time for sorted structures like binary search trees.\nIt is also why set elements are unique.\n\n\\begin{table}[H]\n\\begin{tabular}{r|l}\n    Method & Description\\\\\n    \\hline\n    \\li{add()} & Add an element to the set. This has no effect if the element is already present. \\\\\n    \\li{remove()} & Remove an element from the set, raising\\\\\n    & a \\li{KeyError} if it is not a member of the set.\\\\\n    \\li{discard()} & Remove an element from the set without raising \\\\\n    & an exception if it is not a member of the set.\\\\\n    \\li{pop()} & Remove and return an arbitrary set element.\\\\\n    \\li{union()} & Return all elements that are in either set as a new set.\\\\\n    \\li{intersection()} & Return all elements that are in both sets as a new set.\\\\\n    \\li{update()} & Add all elements of another set in-place.\n\\end{tabular}\n\\caption{Basic methods of the \\li{set} class.}\n\\end{table}\n\n\\begin{lstlisting}\n# Initialize a set. Note that repeats are not added.\n>>> animals = {\"cow\", \"cat\", \"dog\", \"mouse\", \"cow\"}\n>>> print(animals)\n<<{'cow', 'dog', 'mouse', 'cat'}>>\n\n>>> animals.add(\"horse\")     # Add an object to the set.\n>>> \"horse\" in animals\n<<True>>\n>>> animals.remove(\"emu\")    # Attempt to delete an object from the set,\n<<KeyError: 'emu'>>              # resulting in an exception.\n>>> animals.pop()            # Delete and return a random object from the set.\n<<'mouse'>>\n>>> print(animals)\n<<{'cat', 'horse', 'dog', 'cow'}>>\n\n# Add all of the elements of another set to this one.\n>>> animals.update({\"dog\", \"velociraptor\"})\n>>> print(animals)\n<<{'velociraptor', 'cat', 'horse', 'dog', 'cow'}>>\n\n# Intersect this set with another one.\n>>> animals.intersection({\"cat\", \"cow\", \"cheetah\"})\n<<{'cat', 'cow'}>>\n\\end{lstlisting}\n\nSets are extremely fast, but they do not support indexing because the elements are unordered.\nA Python \\li{dict}, on the other hand, is a hash-based data structure that stores key-value pairs: the keys of a dictionary act like a set (unique and unordered, with $O(1)$ lookup), but each key corresponds to another object, called its value.\nThe keys index the dictionary and allow $O(1)$ lookup of the values.\n\n\\begin{table}[H]\n\\begin{tabular}{r|l}\n    Method & Description\\\\\n    \\hline\n    \\li{keys()} & Return a set-like iterator for the dictionary's keys.\\\\\n    \\li{values()} & Return a set-like iterator for the dictionary's values.\\\\\n    \\li{items()} & Return an iterator for the dictionary's key-value pairs.\\\\\n    \\li{pop()} & Remove a specified key and return the corresponding value,\\\\\n    & raising a \\li{KeyError} if the key is not a member of the dictionary.\\\\\n    \\li{update()} & Add or overwrite key-value pairs in-place with those from another dictionary.\n\\end{tabular}\n\\caption{Basic methods of the \\li{dict} class.}\n\\end{table}\n\n\\begin{lstlisting}\n# Initialize a dictionary.\n>>> grades = {\"business\": \"A\", \"math\": \"A+\", \"visual arts\": \"B\"}\n>>> grades[\"math\"]\n<<'A+'>>                            # The key \"math\" maps to the value \"A+\".\n\n# Add a \"science\" key with corresponding value \"A\".\n>>> grades[\"science\"] = \"A\"\n\n# Remove the \"business\" key.\n>>> grades.pop(\"business\")\n<<'A'>>\n>>> print(grades)\n<<{'math': 'A+', 'visual arts': 'B', 'science': 'A'}>>\n\n# Display the keys, values, and items.\n>>> list(grades.keys()), list(grades.values())\n<<(['math', 'visual arts', 'science'], ['A+', 'B', 'A'])>>\n>>> for key, value in grades.items():\n...   print(key, \"=>\", value)\n...\n<<math => A+\nvisual arts => B\nscience => A>>\n\n# Add key-value pairs from another dictionary.\n>>> grades.update({\"cooking\":\"A+\", \"math\": \"C\"})\n>>> print(grades)\n<<{'math': 'C', 'visual arts': 'B', 'science': 'A', 'cooking': 'A+'}>>\n\\end{lstlisting}\n\nDictionaries are ideal for storing values that need to be accessed often and for representing one-to-one or one-to-many relationships.\nThus, the \\li{dict} class is a natural choice for implementing adjacency dictionaries.\nFor example, the following code defines the adjacency dictionary for the graph in Figure \\ref{fig:bfs-simple-graph}.\nNote that the dictionary values are sets.\n\n\\begin{lstlisting}\n>>> adjacency = {'A': {'B', 'D'},\n                 'B': {'A', 'D'},\n                 'C': {'D'},\n                 'D': {'A', 'B', 'C'}}\n\n# The nodes of the graph are the dictionary keys.\n>>> set(adjacency.keys())\n<<{'B', 'D', 'A', 'C'}>>\n\n# The values are the nodes that the key node is adjacent to.\n>>> adjacency['A']\n<<{'B', 'D'}>>                  # A is adjacent to B and D.\n>>> 'C' in adjacency['B']\n<<False>>                       # B and C are not adjacent.\n>>> 'C' in adjacency['D']\n<<True>>                        # C and D are adjacent.\n\\end{lstlisting}\n\n\\begin{warn} % hashable objects only\nElements of a \\li{set} and keys of a \\li{dict} must be \\emph{hashable}.\nMutable objects---lists, sets and dictionaries---are not hashable, so they are not allowed as set elements or dictionary keys.\nThus, in order to represent a graph with an adjacency dictionary, each of the node labels should a string, a number, or some other hashable type.\n\\end{warn}\n\n\n\\begin{problem} % node, edge methods for Graph class (dictionary warm up).\n\\label{prob:bfs-graph-warmup}\nConsider the following \\li{Graph} class.\n\\begin{lstlisting}\nclass Graph:\n    \"\"\"A graph object, stored as an adjacency dictionary. Each node in the\n    graph is a key in the dictionary. The value of each key is a set of\n    the corresponding node's neighbors.\n\n    Attributes:\n        d (dict): the adjacency dictionary of the graph.\n    \"\"\"\n    def __init__(self, adjacency={}):\n        \"\"\"Store the adjacency dictionary as a class attribute\"\"\"\n        self.d = dict(adjacency)\n\n    def __str__(self):\n        \"\"\"String representation: a view of the adjacency dictionary.\"\"\"\n        return str(self.d)\n\\end{lstlisting}\nAdd the following methods to this class.\n\\begin{enumerate}\n\\item \\li{add_node()}: Add a node (with no initial edges) if it is not already present.\n\\\\ (Hint: use \\li{set()} to create an empty set.)\n\\item \\li{add_edge()}: Add an edge between two nodes. Add the nodes to the graph if they are not already present.\n\\item \\li{remove_node()}: Remove a node, including all edges adjacent to it.\nThis method should raise a \\li{KeyError} if the node is not in the graph.\n\\item \\li{remove_edge()}: Remove the edge between two nodes.\nThis method should raise a \\li{KeyError} if either node is not in the graph, or if there is no edge between the nodes.\n\\end{enumerate}\n\\end{problem}\n\n\\section*{Breadth-first Search} % =============================================\n\nMany common problems that arise in graph theory require finding the shortest path between two nodes in a graph.\nFor some highly structured graphs, such as binary search trees, this is a fairly straightforward problem (in the case of a tree, the shortest path is also the only path).\nFinding a path between nodes in a graph of arbitrary structure, however, requires a careful and methodical approach.\nThe two most common graph search algorithms are \\emph{depth-first search} (DFS) and \\emph{breadth-first search} (BFS).\nThe breadth-first strategy is almost always better at finding shortest paths than the depth-first strategy,\\footnote{See \\url{https://xkcd.com/761/}.} though a DFS can be useful for path problems in certain graphs.\n\nTo traverse a graph with a BFS, choose a node to start at, called the \\emph{source} node.\nFirst, visit each of the source node's neighbors.\nNext, visit each of the source node's neighbors' neighbors.\nThen visit each of their neighbors, continuing the process until all nodes have been visited.\nThis strategy explores all of the nodes closest to the source node before incrementally moving ``deeper'' (further from the source node) into the tree.\n\nThe implementation of a BFS requires the following data structures to keep track of which nodes have already been visited and the order in which to visit nodes in future steps.\n\\begin{itemize}\n    \\item A list $V$: The nodes that have been \\textbf{visited}, in visitation order.\n    \\item A \\textbf{queue} $Q$: The nodes to be visited, in the order that they were discovered.\n    Recall that a \\emph{queue} is a limited-access list where data is inserted to one end, but removed from the other (first-in, first-out).\n    \\item A set $M$: The nodes that have been visited, or that are \\textbf{marked} to be visited.\n    This is the union of the nodes in $V$ and $Q$.\n\\end{itemize}\nTo begin the search, add the source node to $Q$ and $M$.\nThen, until $Q$ is empty, repeat the following:\n\\begin{enumerate}\n    \\item Pop a node off of $Q$; call it the \\emph{current} node.\n    \\item ``Visit'' the current node by appending it to $V$.\n    \\item Add the neighbors of the current node that are not in $M$ to $Q$ and $M$.\n    \\label{step:bfs-add-to-queue}\n\\end{enumerate}\nThe ``that are not in $M$'' clause of step \\ref{step:bfs-add-to-queue} prevents nodes from being added to $Q$ more than once.\nNote that step \\ref{step:bfs-add-to-queue} could be replaced with ``Add the neighbors of the current node that are not in $V \\cup Q$ to $Q$.''\nHowever, lookup in $M$ (a set) is much faster than lookup in $V$ and $Q$ (arrays or linked lists), so including $M$ greatly speeds up the algorithm.\n\n\\begin{info}\nThe first-in, first-out (FIFO) structure of $Q$ enforces the ``breadth-first'' nature of the BFS: nodes that are marked first are visited first.\nUsing a a last-in, first-out (LIFO) stack for $Q$ changes the search to a DFS: the next node to visit is the one that was marked last.\n\\end{info}\n\n\\begin{figure}[H] % Example of a breadth-first search.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.6\\textwidth}\n    \\centering\n    \\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n    % Nodes\n    \\node[normalcircle] (A) [fill=red!20] {A};\n    \\node[normalcircle] (B) [above of=A] {B};\n    \\node[normalcircle] (C) [right of=B] {C};\n    \\node[normalcircle] (D) [below of=C] {D};\n    % Edges\n    \\foreach \\a/\\b in {A/B,A/D,B/D,C/D} \\draw[thick,-,>=stealth'] (\\a) edge (\\b);\n    \\end{tikzpicture}\n\\end{subfigure}\n%\n\\begin{subfigure}{.39\\textwidth}\n    \\Large\\begin{tabular}{r|l}\n    $V$ & \\textcolor{white}{A B C D} \\\\ \\hline\n    $Q$ & \\textcolor{red}{A} \\\\ \\hline\n    $M$ & A \\\\\n    \\end{tabular}\n\\end{subfigure}\n\\\\\\vspace{20px}\n\\begin{subfigure}{.6\\textwidth}\n    \\centering\n    \\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n    % Nodes\n    \\node[normalcircle] (A) [fill=blue!20] {A};\n    \\node[normalcircle] (B) [fill=red!20, above of=A] {B};\n    \\node[normalcircle] (C) [right of=B] {C};\n    \\node[normalcircle] (D) [fill=red!20, below of=C] {D};\n    % Edges\n    \\foreach \\a/\\b in {B/D,C/D} \\draw[thick,-,>=stealth'] (\\a) edge (\\b);\n    \\foreach \\a/\\b in {A/B,A/D} \\draw[red!80,thick,->,>=stealth',line width=1.5pt] (\\a) edge (\\b);\n    \\end{tikzpicture}\n\\end{subfigure}\n%\n\\begin{subfigure}{.39\\textwidth}\n    \\Large\\begin{tabular}{r|l}\n    $V$ & \\textcolor{blue}{A} \\textcolor{white}{B C D} \\\\ \\hline\n    $Q$ & \\textcolor{red}{B D} \\\\ \\hline\n    $M$ & A B D \\\\\n    \\end{tabular}\n\\end{subfigure}\n\\\\\\vspace{20px}\n\\begin{subfigure}{.6\\textwidth}\n    \\centering\n    \\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n    % Nodes\n    \\node[normalcircle] (A) [fill=blue!20] {A};\n    \\node[normalcircle] (B) [fill=blue!20, above of=A] {B};\n    \\node[normalcircle] (C) [right of=B] {C};\n    \\node[normalcircle] (D) [fill=red!20, below of=C] {D};\n    % Edges\n    \\foreach \\a/\\b in {A/B,A/D,B/D,C/D} \\draw[thick,-,>=stealth'] (\\a) edge (\\b);\n    \\end{tikzpicture}\n\\end{subfigure}\n%\n\\begin{subfigure}{.39\\textwidth}\n    \\Large\\begin{tabular}{r|l}\n    $V$ & \\textcolor{blue}{A B} \\textcolor{white}{C D}\\\\ \\hline\n    $Q$ & \\textcolor{red}{D} \\\\ \\hline\n    $M$ & A B D \\\\\n    \\end{tabular}\n\\end{subfigure}\n\\\\\\vspace{20px}\n\\begin{subfigure}{.6\\textwidth}\n    \\centering\n    \\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n    % Nodes\n    \\node[normalcircle] (A) [fill=blue!20] {A};\n    \\node[normalcircle] (B) [fill=blue!20, above of=A] {B};\n    \\node[normalcircle] (C) [fill=red!20, right of=B] {C};\n    \\node[normalcircle] (D) [fill=blue!20, below of=C] {D};\n    % Edges\n    \\foreach \\a/\\b in {A/B,A/D,B/D} \\draw[thick,-,>=stealth'] (\\a) edge (\\b);\n    \\draw[red!80,thick,->,>=stealth',line width=1.5pt] (D) edge (C);\n    \\end{tikzpicture}\n\\end{subfigure}\n%\n\\begin{subfigure}{.39\\textwidth}\n    \\Large\\begin{tabular}{r|l}\n    $V$ & \\textcolor{blue}{A B D} \\\\ \\hline\n    $Q$ & \\textcolor{red}{C} \\\\ \\hline\n    $M$ & A B D C \\\\\n    \\end{tabular}\n\\end{subfigure}\n\\caption{To start a BFS from node A to node C, put A in the visit queue $Q$ and mark it by adding it to the set $M$.\nPop A off the queue and ``visit'' it by adding A to the visited list $V$ and the neighboring nodes B and D to $Q$.\nThen visit B, but do not add anything to $Q$ because all of the neighbors of B are already marked.\nFinally, visit D, at which point the target node C is located because it is adjacent to D.\n}\n\\label{fig:bfs-example}\n\\end{figure}\n\n\\begin{problem} % BFS graph traversal.\n\\label{prob:bfs-traversal}\nWrite a method for the \\li{Graph} class that accepts a source node.\nTraverse the graph with a breadth-first search until all nodes have been visited.\nReturn the list of nodes in the order that they were visited.\nIf the source node is not in the graph, raise a \\li{KeyError}.\n\\\\(Hint: for $Q$, use a \\li{deque} from the \\li{collections} module, and make sure that nodes are added to one end but popped off of the other.)\n\\end{problem}\n\n\\subsection*{Shortest Paths via BFS} % ----------------------------------------\n\nConsider the problem of locating a path between two nodes with a BFS.\nThe nodes that are directly connected to the source node are all visited before any other nodes; more generally, the nodes that are $n$ nodes away from the source node are all visited before nodes that are $n+1$ or more nodes from the source point.\nTherefore, the search path taken to discover to the target with a BFS must be the shortest path from the source node to the target node.\n\nExamine again the graph in Figures \\ref{fig:bfs-simple-graph} and \\ref{fig:bfs-example}.\nThe shortest path from A to C starts at A, goes to D, and ends at C.\nDuring a BFS originating at A, D is placed on the visit queue because it is one of A's neighbors, and C is placed on the queue because it is one of D's neighbors.\nGiven that A was the node that visited D, and that D was the node that visited C, the shortest path from A to C can be constructed by stepping backward along the search path.\n\nTo implement this idea, initialize a dictionary before starting the BFS.\nWhen a node is marked and added to the visit queue, add a key-value pair mapping the \\textbf{visited} node to the \\textbf{visiting} node (for example, B $\\mapsto$ A means B was marked while visiting A).\nWhen the target node is found, step through the dictionary until arriving at the source node, recording each step.\n\n\\begin{figure}[H] % Example of a breadth-first search.\n\\centering\n\\begin{tikzpicture}[normalcircle/.style={draw,circle,minimum size=.75cm,fill=none,thick,node distance=1.5cm}]\n% Nodes\n\\node[normalcircle] (A) [fill=blue!20] {A};\n\\node[normalcircle] (B) [fill=blue!20, above of=A] {B};\n\\node[normalcircle] (C) [fill=blue!20, right of=B] {C};\n\\node[normalcircle] (D) [fill=blue!20, below of=C] {D};\n% Edges\n\\draw[thick,-,>=stealth'] (B) edge (D);\n\\foreach \\a/\\b in {C/D,D/A,B/A} \\draw[green!80,thick,->,>=stealth',line width=1.5pt] (\\a) edge (\\b);\n\\end{tikzpicture}\n\\caption{In the BFS from Figure \\ref{fig:bfs-example}, nodes B and D were marked while visiting node A, and node C was marked while visiting node D (this is same as reversing the red arrows in Figure \\ref{fig:bfs-example}).\nThus the ``visit path'' from C to A is $\\text{C}\\rightarrow\\text{D}\\rightarrow\\text{A}$, so the shortest path from A to C is $[$A, D, C$]$.}\n\\label{fig:bfs-shortest-path}\n\\end{figure}\n\n\\begin{problem}\nAdd a method to the \\li{Graph} class that accepts source and target nodes.\nBegin a BFS at the source node and proceed until the target is found.\nReturn a list containing the node values in the shortest path from the source to the target (including the endpoints).\nIf either of the input nodes are not in the graph, raise a \\li{KeyError}.\n\\label{prob:bfs-short-path1}\n\\end{problem}\n\n\\section*{Shortest Paths via NetworkX} % ======================================\n\n\\emph{NetworkX} is a Python package for creating, manipulating, and exploring graphs.\nIts \\li{Graph} object represents a graph with an adjacency dictionary, similar to the class from Problems \\ref{prob:bfs-graph-warmup}--\\ref{prob:bfs-short-path1}, and has many methods for interpreting information about the graph and its structure.\nAs before, the nodes must be hashable (a number, string, or another immutable object).\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{r|l}\n    Method & Description\\\\\n    \\hline\n    \\li{add_node()} & Add a single node to the graph.\\\\\n    \\li{add_nodes_from()} & Add a list of nodes to the graph.\\\\\n    \\li{add_edge()} & Add an edge between two nodes.\\\\\n    \\li{add_edges_from()} & Add a list of edges to the graph.\n\\end{tabular}\n\\caption{Methods of the \\li{nx.Graph} class for adding nodes and edges.}\n\\end{table}\n\n\\begin{lstlisting}\n>>> import networkx as nx\n\n# Initialize a NetworkX graph from an adjacency dictionary.\n>>> G = nx.Graph({'A': {'B', 'D'},\n                  'B': {'A', 'D'},\n                  'C': {'D'},\n                  'D': {'A', 'B', 'C'}})\n\n>>> print(G.nodes())            # Print the nodes.\n<<['A', 'B', 'C', 'D']>>\n>>> print(G.edges())            # Print the edges as tuples.\n<<[('A', 'D'), ('A', 'B'), ('B', 'D'), ('C', 'D')]>>\n\n>>> G.add_node('E')             # Add a new node.\n>>> G.add_edge('A', 'F')        # Add an edge, which also adds a new node 'F'.\n>>> G.add_edges_from([('A', 'C'), ('F', 'G')])  # Add several edges at once.\n\n>>> set(G['A'])                 # Get the set of nodes neighboring node 'A'.\n<<{'B', 'C', 'D', 'F'}>>\n\\end{lstlisting}\n\n\\subsection*{The Kevin Bacon Problem} % ---------------------------------------\n\nThe vintage parlor game \\href{http://oracleofbacon.org/help.php}{\\emph{Six Degrees of Kevin Bacon}} is played by naming an actor, then trying to find the shortest chain of actors that have worked with each other leading to Kevin Bacon.\nFor example, Samuel L. Jackson was in the film \\emph{Pulp Fiction (1994)} with Frank Whaley, who was in \\emph{JFK (1991)} with Kevin Bacon.\nIn other words, the goal of the game is to solve a shortest path problem on a graph that connects actors to the movies that they have been in.\n\n\\begin{problem} % MovieGraph.__init__()\nThe file \\texttt{movie\\_data.txt} contains IMDb data for about 137,000 movies.\nEach line of the file represents one movie: the title is listed first, then the cast members, with entries separated by a \\texttt{/} character.\nFor example, the line for \\emph{The Dark Knight (2008)} starts with\n\\begin{center}\n\\texttt{The Dark Knight (2008)/Christian Bale/Heath Ledger/Aaron Eckhart/...}\n\\end{center}\nAny \\li{/} characters in movie titles have been replaced with the vertical pipe character \\texttt{|} (for example, \\texttt{Frost|Nixon (2008)}).\n\nWrite a class whose constructor accepts the name of a file to read.\nInitialize a set for movie titles, a set for actor names, and an empty NetworkX \\li{Graph}, and store them as attributes.\nRead the file line by line, adding the title to the set of movies and the cast members to the set of actors.\nAdd an edge to the graph between the movie and each cast member.\n\\\\(Hint: Use the \\li{split()} method for strings to parse each line.)\n\nIt should take no more than 20 seconds to construct the entire graph.\nCheck that there are 137,018 movies and 930,717 actors.\nCompare parts of your graph to Figure \\ref{fig:bfs-network-subset}.\n\\label{prob:bfs-movie-network-init}\n\\end{problem}\n\n\\begin{figure}[H]\n\\centering\n\\begin{tikzpicture}\n% Set styles for Actor and Movie nodes\n\\tikzstyle{Actor}=[thick,circle,draw=purple,fill=purple!20!,font=\\sffamily\\footnotesize,align=center,minimum size=1.4cm]\n\\tikzstyle{Movie}=[thick,rectangle,draw=green!75!black,fill=green!20!,font=\\sffamily\\footnotesize,align=center,minimum height=1.35cm,minimum width=1.35cm]\n% Nodes\n\\foreach [count=\\i] \\x/\\y/\\t/\\n in {\n    0/1.25/Kevin\\\\Bacon/Actor,\n    5.9/-.75/Jim\\\\Cummings/Actor,\n    2/-3.25/Toby\\\\Jones/Actor,\n    -3.5/-2.5/Jennifer\\\\Lawrence/Actor,\n    -5.5/-.2/James\\\\McAvoy/Actor,\n    3.25/1/{Balto\\\\(1995)}/Movie,\n    4.75/-3/{Christopher\\\\Robin (2018)}/Movie,\n    1.25/-1/{Frost/Nixon\\\\(2008)}/Movie,\n    .-.75/-3/{The Hunger\\\\Games (2012)}/Movie,\n    -2.25/-.4/{X-Men: First\\\\Class (2011)}/Movie,\n    -5.9/-2.5/{X-Men:\\\\Apocalypse\\\\(2016)}/Movie,\n    -3.5/1.75/{Footloose\\\\(1984)}/Movie}\n  \\node[\\n] at (\\x,\\y) (v\\i) {\\t};\n% Edges\n\\foreach \\i/\\j in {1/6, 2/6, 2/7, 3/7, 1/8, 3/8, 3/9,\n                   4/9, 1/10, 4/10, 5/10,4/11,5/11,1/12}\n  \\draw[thick] (v\\i) edge (v\\j);\n\\end{tikzpicture}\n\\caption{A subset of the graph in \\texttt{movie\\_data.txt}.\nEach of these actors have a Bacon number of $1$ because they have all been in a movie with Kevin Bacon.\nEvery actor in \\emph{The Hunger Games} has a Bacon number of at most $2$ because of the paths through Jennifer Lawrence or Toby Jones.}\n\\label{fig:bfs-network-subset}\n\\end{figure}\n\n\\begin{info} % Note that the movie-actor graph is bipartite.\nThe movie/actor graph of Problem \\ref{prob:bfs-movie-network-init} and Figure \\ref{fig:bfs-network-subset} has an interesting property: actors are only directly connected to movies, and movies are only directly connected to actors.\nThis kind of graph is called \\emph{bipartite} because there are two types of nodes, and no node has an edge connecting it to another node of its type.\n\\end{info}\n\n\\begin{warn} % nx.draw() only works on small graphs.\nNetworkX \\li{Graph} objects can be visualized with \\li{nx.draw()} (followed by \\li{plt.show()}).\nHowever, this visualization tool is only effective on relatively small graphs.\nIn fact, graph visualization in general remains a challenging and ongoing area of research.\nBecause of the size of the dataset, \\textbf{do not} attempt to visualize the graph in Problem \\ref{prob:bfs-movie-network-init} with \\li{nx.draw()}.\n\\end{warn}\n\nThe Six Degrees of Kevin Bacon game poses an interesting question: can any actor be linked to Kevin Bacon, and if so, in how many steps?\nThe game hypothesizes, ``Yes, within $6$ steps'' (hence the title).\nMore precisely, let the \\emph{Bacon number} of an actor be the number of steps from that actor to Kevin Bacon, only counting actors.\nFor example, since Samuel L. Jackson was in a film with Frank Whaley, who was in a film with Kevin Bacon, Samuel L. Jackson has a Bacon number of $2$.\nActors who have been in a movie with Kevin Bacon have a Bacon number of $1$, and actors with no path to Kevin Bacon have a Bacon number of $\\infty$.\nThe game asserts that the largest Bacon number is $6$.\n\nNetworkX is equipped with a variety of graph analysis tools, including a few for computing paths between nodes (and, therefore, Bacon numbers).\nTo compute a shortest path between nodes $u$ and $v$, \\li{nx.shortest_path()} starts one BFS from $u$ and another from $v$, switching off between the two searches until they both discover a common node.\nThis approach is called a \\emph{bidirectional BFS} and is typically faster than a regular, one-sided BFS.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{r|l}\n    Function & Description\\\\\n    \\hline\n    \\li{has_path()} & Return \\li{True} if there is a path between two specified nodes.\\\\\n    \\li{shortest_path()} & Return \\textbf{one} shortest path between nodes.\\\\\n    \\li{shortest_path_length()} & Return the length of the shortest path between nodes.\\\\\n    \\li{all_shortest_paths()} & Yield \\textbf{all} shortest paths between nodes. \\\\\n    % \\li{average_shortest_path_length()} & Compute the average length of shortest paths from every node to every other node in the graph.\n\\end{tabular}\n\\caption{NetworkX functions for path problems. Each accepts a \\li{Graph}, then a pair of nodes.}\n\\end{table}\n\n\\begin{lstlisting}\n>>> G = nx.Graph({'A': {'B', 'D'},\n                  'B': {'A', 'D'},\n                  'C': {'D'},\n                  'D': {'A', 'B', 'C'}})\n\n# Compute the shortest path between 'A' and 'D'.\n>>> nx.has_path(G, 'A', 'C')\n<<True>>\n>>> nx.shortest_path(G, 'A', 'C')\n<<['A', 'D', 'C']>>\n>>> nx.shortest_path_length(G, 'A', 'C')\n2\n\n# Compute all possible shortest paths between two nodes.\n>>> G.add_edge('B', 'C')\n>>> list(nx.all_shortest_paths(G, 'A', 'C'))\n<<[['A', 'D', 'C'], ['A', 'B', 'C']]>>\n\n# When the second node is omitted from these functions, the shortest paths\n# from the given node to EVERY node are computed and returned as a dictionary.\n>>> nx.shortest_path(G, 'A')\n<<{'A': ['A'], 'D': ['A', 'D'], 'B': ['A', 'B'], 'C': ['A', 'D', 'C']}>>\n>>> nx.shortest_path_length(G, 'A')     # Path lengths are defined by the\n<<{'A': 0, 'D': 1, 'B': 1, 'C': 2}>>        #  number of edges, not nodes.\n\\end{lstlisting}\n\n\\begin{problem} % Individual shortest paths / Bacon numbers.\nWrite a method for your class from Problem \\ref{prob:bfs-movie-network-init} that accepts two actors' names.\nUse NetworkX to compute the shortest path between the actors and the degrees of separation between the two actors (if one of the actors is \\li{\"Kevin Bacon\"}, this is the Bacon number of the other actor).\nNote that this number is different than the number of entries in the actual shortest path list, since the movies are just intermediate steps between actors and are not counted when calculating the degress of separation.\n\\label{prob:bfs-actor-path}\n\\end{problem}\n\nThe idea of a Bacon number provides a few ways to analyze the connectivity of the Hollywood network.\nFor example, the distribution of all Bacon numbers describes how close Kevin Bacon is to actually knowing all of the actors in Hollywood\nSomeone with a lower average number---for instance, the average \\emph{Jackson number}, for Samuel L. Jackson---is, on average, ``more connected with Hollywood'' than Kevin Bacon.\nThe actor with the lowest average number is sometimes called \\emph{the center of the Hollywood universe}.\n\n\\begin{problem} % Average Bacon numbers.\n\\label{prob:bfs-average-bacon-number}\nWrite a method for your class from Problem \\ref{prob:bfs-movie-network-init} that accepts one actor's name.\nCalculate the shortest path lengths of every actor in the collection to the specified actor (not including movies).\nUse \\li{plt.hist()} to plot the distribution of path lengths and return the average path length.\n\\\\(Hint: Use a NetworkX function to compute all path lengths simultaneously; this is significantly faster than calling your method from Problem \\ref{prob:bfs-actor-path} repeatedly.\nAlso, use the keyword argument \\li{bins=[i-.5 for i in range(8)]} in \\li{plt.hist()} to get the histogram bins to correspond to integers nicely.)\n\\end{problem}\n\nAs an aside, the prolific \\href{https://en.wikipedia.org/wiki/Erd%C5%91s_number}{Paul Erd\\H{o}s} is the Kevin Bacon equivalent in the mathematical community.\nSomeone with an \\emph{Erd\\H{o}s number} of $2$ co-authored a paper with someone who co-authored a paper with Paul Erd\\H{o}s.\nHaving an Erd\\H{o}s number of $1$ or $2$ is considered quite an achievement (see \\url{https://xkcd.com/599/}).\n\n\\newpage\n\n\\section*{Additional Material} % ==============================================\n\n\\subsection*{Other Hash-based Structures} % -----------------------------------\n\nThe standard library has a few specialized alternatives to regular sets and dictionaries.\n\\begin{itemize}\n\\item \\li{frozenset}: an immutable version of the usual set class.\nFrozen sets cannot be altered after creation and therefore lack methods like \\li{add()}, \\li{pop()}, and \\li{remove()}, but they can be placed in other sets and used as dictionary keys.\n\n\\item \\li{collections.defaultdict}: a dictionary with default values.\nFor instance, \\li{defaultdict(set)} creates a dictionary that automatically uses an empty set as the value whenever a non-present key is used for indexing.\nSee \\href{https://docs.python.org/3/library/collections.html\\#defaultdict-examples}{\\texttt{https://docs.python.org/3/library/collections.html}} for examples.\n\n\\item \\li{collections.OrderedDict}: a dictionary that remembers insertion order.\nFor example, the \\li{popitem()} method returns the most recently added key-value pair.\n\\end{itemize}\n\n\\subsection*{Depth-first Search} % --------------------------------------------\n\nA \\emph{depth-first search} (DFS) takes the opposite approach of a BFS.\nInstead of checking all neighbors of a single node before moving on, it checks the first neighbor, then their first neighbor, then their first neighbor, and so on until reaching a leaf node.\nThe algorithm then backtracks to the previous node and checks its second neighbor.\nWhile a DFS is rarely useful for finding shortest paths, it is a common strategy for solving recursively structured problems, such as mazes or Sudoku puzzles.\n\nConsider adding a keyword argument to your method from Problem \\ref{prob:bfs-traversal} that specifies whether to use a BFS (the default) or a DFS.\nTo change from a BFS to a DFS, change the visit queue $Q$ to a stack.\nYou may be able to implement the change in a single line of code.\n\n\\subsection*{The Center of the Hollywood Universe} % --------------------------\n\nComputing the center of the universe in a graph amounts to solving Problem \\ref{prob:bfs-average-bacon-number} for every node in the graph.\nThis is computationally expensive, but since each average number is independent of the others, the problem is a good candidate for \\emph{parallel programming}, which divides the computational workload between multiple processes.\nEven with parallelism, however, computing the center of the Hollywood universe may require significant computational time and resources.\n\n\\subsection*{Shortest Paths on Weighted Graphs} % -----------------------------\n\nThe graphs presented in this lab are \\emph{unweighted}, meaning all edges have the same importance.\nA \\emph{weighted graph} assigns a weight to each edge, which can usually be thought of as the distance between the two adjacent nodes.\nThe shortest path problem becomes much more complicated on weighted graphs, and requires additions to the plain BFS.\nThe standard approach is \\emph{Dijkstra's algorithm}, which is implemented as \\li{nx.dijkstra_path()}.\nAnother approach, the \\emph{Bellman-Ford algorithm}, is implemented as \\li{nx.bellman_ford_path()}.\n", "meta": {"hexsha": "31747643ac21e2789581b936648ba11806eca30e", "size": 35135, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Volume2/BreadthFirstSearch/BreadthFirstSearch.tex", "max_stars_repo_name": "chrismmuir/Labs-1", "max_stars_repo_head_hexsha": "13c23611b90d73b0c2c7d275bce9808f829009f2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 190, "max_stars_repo_stars_event_min_datetime": "2015-07-17T01:57:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T19:16:19.000Z", "max_issues_repo_path": "Volume2/BreadthFirstSearch/BreadthFirstSearch.tex", "max_issues_repo_name": "chrismmuir/Labs-1", "max_issues_repo_head_hexsha": "13c23611b90d73b0c2c7d275bce9808f829009f2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 184, "max_issues_repo_issues_event_min_datetime": "2015-07-16T17:56:06.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-06T23:47:14.000Z", "max_forks_repo_path": "Volume2/BreadthFirstSearch/BreadthFirstSearch.tex", "max_forks_repo_name": "chrismmuir/Labs-1", "max_forks_repo_head_hexsha": "13c23611b90d73b0c2c7d275bce9808f829009f2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 76, "max_forks_repo_forks_event_min_datetime": "2015-08-06T02:53:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T11:08:57.000Z", "avg_line_length": 54.4728682171, "max_line_length": 248, "alphanum_fraction": 0.6941511314, "num_tokens": 9736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.41484790993231124}}
{"text": "\\chapter{Hypothesis Testing for Chapter \\ref{rnns-causal}} \\label{eval}\n\n\\citet{abadie2010synthetic} propose a randomization inference approach for calculating the exact distribution of placebo effects under the sharp null hypothesis of no effect. \\citet{cavallo2013catastrophic} extends the placebo-based testing approach to the case of multiple (placebo) treated units by constructing a distribution of \\emph{average} placebo effects under the null hypothesis. \\citet{firpo2018synthetic} derive the conditions under which the randomization inference approach is valid from a finite sample perspective and \\citet{hahn2017synthetic} analyze the approach from a repeated sampling perspective.\n\nRandomization $p$-values are obtained following these steps:\n\n\\begin{enumerate} \n\t\\item Estimate the observed test static $\\boldsymbol{\\hat{\\upphi}}$ from (\\ref{eq:pointwise}). Averaging over the time dimension results in a $\\text{T}_\\star$-length array of observed average treatment effects. \n\t\\item Calculate every possible average placebo treated effect $\\upmu$ by randomly sampling without replacement which $\\text{J}-1$ control units are assumed to be treated. There are $\\mathcal{Q} = \\sum\\limits_{\\text{g}=1}^{\\text{J}-1} {\\text{J} \\choose \\text{g}}$ possible average placebo effects.\\footnote{Since calculating $\\mathcal{Q}$ can be computationally burdensome for relatively high values of $J$, I artificially set $\\mathcal{Q} = 10,000$ in cases when $\\text{J} > 16$.} The result is a matrix of dimension $\\mathcal{Q} \\times \\text{T}_\\star$\n\t\\item Sum over the time dimension the number of $\\upmu$ that are greater than or equal to $\\boldsymbol{\\hat{\\upphi}}$.  \\label{counts}\n\\end{enumerate}\n\nEach element of the vector obtained from Step \\ref{counts} is divided by $\\mathcal{Q}$ to estimate a $\\text{T}_\\star$-length vector of exact two-sided $p$ values, $\\hat{p}$. \n\n\\subsection{Randomization confidence intervals}\n\nUnder the assumption that treatment has a constant additive effect $\\Delta$, I construct an interval estimate for $\\Delta$ by inverting the randomization test. Let $\\updelta_\\Delta$ be the test statistic calculated by subtracting all possible $\\upmu$ by $\\Delta$. I derive a two-sided randomization confidence interval by collecting all values of $\\updelta_\\Delta$ that yield $\\hat{p}$ values greater than or equal to significance level $\\upalpha=0.05$. I find the endpoints of the confidence interval by randomly sampling 500 values of $\\Delta$.", "meta": {"hexsha": "2265ed3a52d0836ff574ffb8bfe580b09e765e5a", "size": 2465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "a3-hypothesis.tex", "max_stars_repo_name": "jvpoulos/thesis", "max_stars_repo_head_hexsha": "15a691e8cb940ea427641155c7d69df3be152569", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "a3-hypothesis.tex", "max_issues_repo_name": "jvpoulos/thesis", "max_issues_repo_head_hexsha": "15a691e8cb940ea427641155c7d69df3be152569", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "a3-hypothesis.tex", "max_forks_repo_name": "jvpoulos/thesis", "max_forks_repo_head_hexsha": "15a691e8cb940ea427641155c7d69df3be152569", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 145.0, "max_line_length": 618, "alphanum_fraction": 0.7789046653, "num_tokens": 602, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.41483873972348256}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\DeclareRobustCommand{\\us}{\\rule{.2pt}{0pt}\\rule[-.8pt]{.4em}{.5pt}\\rule{.7pt}{0pt}}\n\\begin{document}\n\\begmath 19.6  Running Problems in Matrix Market Format With Codes in Chapter 4.7\n\n\\silentfootnote{$^\\copyright$ \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThese programs written in C will output either a Fortran code or a C\ncode which will solve sparse matrix problems entered in Matrix Market\nFormat, see \\url{http://math.nist.gov/MatrixMarket/}.\n\n\\subsection{Usage}\nEdit the two define's at the start of the code for your desired use,\nand compile the code.  Make up a file named mmjob which contains a\nlist of names for the matrix market files that you may have an\ninterest in running and that are stored on your machine.\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nmmgen [--Options] Path [name\\us 1] [name\\us 2] ...\\\\\n\\end{tabular}}\n\\end{center}\n\nOptions are a string of letters and numbers interpreted as follows.\n\\begin{description}\n\\item[[a] Process all lines in mmjob after processing the last\n  name\\us k.  If no names are given, start with the first name in mmjob.\n\\item[t] Save the transpose of the matrix, and solve $A^T \\mathbf{x} =\n  \\mathbf{b}$.\n\\item[b0--b9] Specify the number of right hand sides in $\\mathbf{b}$.\n  The defauls is b1.  In the case of 0, the matrix is factored, and\n  another call is made to solve the problem with a single right hand\n  side.\n\\item[c] Compute the reciprocal of the condition number.\n\\item[d] Compute the determinant.\n\\end{description}\n\n\\subsection{Examples and Remarks}\n\nThe file mmjob listed at the end of this document gives the output\nshown.\n\n\\subsection{Functional Description}\n\nNot applicable.\n\n\\subsection{Error Procedures and Restrictions}\n\\label{sec:errors}\nIn the case of input errors, an error message is printed.\n\n\\subsection{Supporting Information}\n\nThe source language is C.\n\nDesign and programming by Fred T. Krogh, Math \\`a la Carte, Inc.\nMarch 2006.\n\nThe random number generator from Chapter 3.1 is called by the drivers\ngenerated.\n\\begcode\n\\vspace {10pt}\n~\\\\\n\\normalsize\nThe File mmjob\\\\\n1138\\us bus\\\\\nCRY10000\\\\\nCURTIS54\\\\\nadd32\\\\\narc130\\\\\ncry2500\\\\\ne20r5000\\\\\nsmall1\\\\\n\n\\begin{verbatim}\n./mmgen -acd ./mmarket\n\n Problem      N  Seconds   RESERR     XERR      Unused     Used    RCOND     DET   x 10^?\n1138_bus   1138    0.016  1.87E-16  4.44E-16     36816     16895  3.98E-08  6.78450  2151\nCRY10000  10000    1.620  1.17E-15  6.31E-03   1675872   1554563  2.52E-28  6.30195 15523\nCURTIS54     54    0.000  1.46E-15  3.20E-14      2513      1930  1.15E-03 -1.78000    -8\n   add32   4960    0.292  6.21E-16  1.34E-14    738755    211828  2.23E-03  1.13981 -9892\n  arc130    130    0.004  4.27E-16  1.43E-09      7736     12327  8.83E-08  1.10261     3\n cry2500   2500    0.100  7.27E-16  1.19E-04     98883    240714  3.09E-24  8.65650  2445\ne20r5000   4241    1.828  8.14E-14  6.79E-10   2677775   2085209  2.95E-10 -1.24088  -671\n  small1     54    0.000  1.46E-15  3.20E-14      2513      1930  1.15E-03 -1.78000    -8\n\\end{verbatim}\n\n\\end{document}\n\n\n", "meta": {"hexsha": "db456ca9298632d7aa3ae22faeb03df7da85ee99", "size": 3144, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch19-06.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch19-06.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch19-06.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 33.4468085106, "max_line_length": 89, "alphanum_fraction": 0.701653944, "num_tokens": 1139, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.6548947425132314, "lm_q1q2_score": 0.41481705153653714}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage[utf8]{luainputenc}\n\\usepackage{aeguill}\n\\usepackage{setspace}\n\n\\tikzstyle{edge} = [fill,opacity=.5,fill opacity=.5,line cap=round, line join=round, line width=50pt]\n\\usetikzlibrary{graphs,graphdrawing}\n\\usegdlibrary{trees}\n\n\\pgfdeclarelayer{background}\n\\pgfsetlayers{background,main}\n\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{2 mars, 2015}\n\\maketitle\n\\section*{edge ideals}\nconsider $\\mathbb{R}$ and polynomials in $X$ with coefficients in $\\mathbb{R}$.\n\n\\subsection*{example}\n\\begin{align*}\n  x^2+1\\\\\n  x-2\\\\\n  \\pi\\\\\n  3x^3-5x+7\n\\end{align*}\n\nwe denote the set of all of these as $\\mathbb{R}[x]$.\n\nsome polynomials ``do fun things''\n\n\\begin{enumerate}\n\\item\nfactor\n\\begin{align*}\n  x^2-1&=(x+1)(x-1)\\\\\n  x^2-2x+1&=(x-1)^2\\\\\n  x^3-x^2+4x-4\\\\\n  etc\n\\end{align*}\nwe say all plynomials in $\\mathbb{R}[x]$ with  the property that $x-1$ divides it, this entire set is an ideal.\n\nthis is denoted $\\langle x-1\\rangle\\subseteq \\mathbb{R}[x]$ \n\nif we want all polynomials divisable by several things, then $\\langle x-1,x^2+1,x^4-2\\rangle$. This is ``or'' or union. the ``and'' or intersection would be formed by just multiplying the divisors.\n\nin general $\\langle f_1,\\dots,f_r\\rangle=\\{\\sum\\limits_{i=1}^r{p_if_i}|p_i\\in \\mathbb{R}[x]\\}$\n\nwe can do this in many variables like $\\mathbb{R}[x,y,z]$ or $\\mathbb{R}[x_1,\\dots,x_n]$ or even $\\mathbb{R}[x_1,\\dots]$\n\nall ideals have many invariants, eg, dimesnion, projective dimension, injective dimension, height, resolutions, betti numbers, etc.\n\n\\end{enumerate}\n\nlet $G$ be a graph and label the vertices $x_1,\\dots,x_n$. then create an ideal in $\\mathbb{R}[x_1,\\dots,x_n]$. $I=\\langle x_ix_j|x_j$\n\n\\subsubsection*{example}\n\\begin{tikzpicture}[main_node/.style={node distance=1cm,circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]\n  \\node[main_node] (1)  {1};\n  \\node[main_node] (2) [below left of=1] {1};\n\\end{tikzpicture}\nthese ideals create a dictionary between graph theory properties and algebraic properties\n\\end{document}\n", "meta": {"hexsha": "0639dbecb19cb4e1d01648c71c2518d50502238e", "size": 2194, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "graph/graph-notes-2015-03-02.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "graph/graph-notes-2015-03-02.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "graph/graph-notes-2015-03-02.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6486486486, "max_line_length": 197, "alphanum_fraction": 0.7164995442, "num_tokens": 778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.41481703847183193}}
{"text": "\\chapter{Metatheory and Type Preservation} \\label{ch:proofs}\n\n\\input{figures/takahashi.tex}\n\nIn this chapter, I elaborate on the proofs of the lemmas and theorems listed in \\cref{sec:syntactic-model},\nculminating in type preservation, which by \\cref{thm:overview:consistency} proves the consistency of \\lang.\nPrior to these proofs, I provide the required metatheoretical properties of both \\lang and \\CICE.\n\n\\section{Metatheory of \\lang}\n\n\\subsection{Basic properties}\n\nWe begin with three basic properties that all judgements satisfy:\n\\emph{weakening}\\index{weakening}, which allows environments to be extended;\n\\emph{replacement}\\index{replacement}, which allows replacing assumptions by subtypes;\nand \\emph{substitutivity}\\index{substitutivity}, which allows the substitution of an assumption by a well-typed term\nor a size variable by a size expression.\nBecause term environments have definitions in addition to assumptions,\nsubstitutivity can only apply to variables that aren't bound to a definition in the environment.\nA final property is the congruence of the reflexive, transitive closure of reduction,\nwhich extends congruence of reduction to its closure.\n\n\\begin{lemma}[Weakening] \\label{lem:weakening}\nLet $\\Phi$ be a size environment,\nlet $\\Gamma$ and $\\Gamma'$ be term environments\nwhere $\\Gamma'$ does not shadow any variables of $\\Gamma$,\nand suppose $\\wf{\\Phi}{\\Gamma, \\Gamma'}$.\n\\begin{enumerate}[noitemsep]\n  \\item \\label{item:weakening:red} If $\\red{\\Phi; \\Gamma}{e_1}{e_2}$ then $\\red{\\Phi; \\Gamma, \\Gamma'}{e_1}{e_2}$.\n  \\item \\label{item:weakening:red*} If $\\red*{\\Phi; \\Gamma}{e_1}{e_2}$ then $\\red*{\\Phi; \\Gamma, \\Gamma'}{e_1}{e_2}$.\n  \\item \\label{item:weakening:subtype} If $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}$ then $\\subtype{\\Phi; \\Gamma, \\Gamma'}{\\tau_1}{\\tau_2}$.\n  \\item If $\\type{\\Phi; \\Gamma}{e}{\\tau}$ then $\\type{\\Phi; \\Gamma, \\Gamma'}{e}{\\tau}$.\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof} \\hfill\n\\begin{enumerate}[noitemsep]\n  \\item By induction on the derivation of $\\red{\\Phi; \\Gamma}{e_1}{e_2}$.\n  \\item By induction on the derivation of $\\red*{\\Phi; \\Gamma}{e_1}{e_2}$,\n    using \\cref{item:weakening:red} in \\rref{red*-once}.\n  \\item Trivial by \\cref{item:weakening:red*} in \\rref{subtype-red}.\n  \\item By induction on the derivation of $\\type{\\Phi; \\Gamma}{e}{\\tau}$,\n    using \\cref{item:weakening:subtype} in \\rref{conv}. \\qedhere\n\\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}[Replacement by subtyping] \\label{lem:replacement-subtyping}\\index{subtyping}\nSuppose $\\subtype{\\Phi; \\Gamma_1}{\\sigma_1}{\\sigma_2}$ where\n$\\type{\\Phi; \\Gamma_1}{\\sigma_1}{U}$ and $\\type{\\Phi; \\Gamma_1}{\\sigma_2}{U}$\nfor some $U$.\n\\begin{enumerate}[noitemsep]\n  \\item \\label{item:replacement-subtyping:red}\n    If $\\red{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}{e_1}{e_2}$\n    then $\\red{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{e_1}{e_2}$.\n  \\item \\label{item:replacement-subtyping:red*}\n    If $\\red*{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}{e_1}{e_2}$\n    then $\\red*{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{e_1}{e_2}$.\n  \\item \\label{item:replacement-subtyping:subtyping}\n    If $\\subtype{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}{\\tau_1}{\\tau_2}$\n    then $\\subtype{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{\\tau_1}{\\tau_2}$.\n  \\item\n    \\begin{enumerate}[noitemsep]\n      \\item \\label{item:replacement-subtyping:typing} If $\\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}{e}{\\tau}$\n        then $\\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{e}{\\tau}$.\n      \\item \\label{item:replacement-subtyping:wf} If $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}$\n        then $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}$.\n    \\end{enumerate}\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  For \\crefrange{item:replacement-subtyping:red}{item:replacement-subtyping:subtyping},\n  the proof structure is similar to that of \\nameref{lem:weakening}.\n  \\begin{enumerate}[noitemsep] \\setcounter{enumi}{3}\n    \\item By mutual induction on the derivations of\n      $\\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}{e}{\\tau}$ and\n      $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\sigma_2}, \\Gamma_2}$.\n      % For \\rref{cons-ass}, if the variable is $x$ (\\ie if $\\Gamma_2 = \\mt$), use $\\type{\\Phi; \\Gamma_1}{\\sigma_1}{U}$.\n      For \\rref{var}, if the variable is $x$, apply \\rref{conv}:\n      \\begin{mathpar}\n      \\inferrule{\n        \\type{\\Phi; \\Gamma_1}{\\sigma_1}{U} \\\\\n        \\type{\\Phi; \\Gamma_1}{\\sigma_2}{U} \\\\\n        \\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{x}{\\sigma_1} \\\\\n        \\subtype{\\Phi; \\Gamma_1}{\\sigma_1}{\\sigma_2}\n      }{\n        \\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma_1}, \\Gamma_2}{x}{\\sigma_2}\n      }\n      \\end{mathpar}\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{corollary}\n\\nameref{lem:replacement-subtyping} also applies when the environment contains\n$\\define{x}{\\sigma_2}{e'}$ rather than $\\annot{x}{\\sigma_2}$\nby the exact same arguments.\n\\end{corollary}\n\n\\begin{lemma}[Substitutivity by terms] \\label{lem:substitutivity-terms}\\index{substitutivity}\nSuppose $\\type{\\Phi; \\Gamma_1}{e}{\\sigma}$.\n\\begin{enumerate}[noitemsep]\n  \\item If $\\red{\\Phi; \\Gamma_1, \\annot{x}{\\sigma}, \\Gamma_2}{e_1}{e_2}$\n    then $\\red{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e}}{\\subst{e_1}{x}{e}}{\\subst{e_2}{x}{e}}$\n  \\item If $\\red*{\\Phi; \\Gamma_1, \\annot{x}{\\sigma}, \\Gamma_2}{e_1}{e_2}$\n  then $\\red*{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e}}{\\subst{e_1}{x}{e}}{\\subst{e_2}{x}{e}}$\n  \\item If $\\subtype{\\Phi; \\Gamma_1, \\annot{x}{\\sigma}, \\Gamma_2}{\\tau_1}{\\tau_2}$\n    then $\\subtype{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e}}{\\subst{\\tau_1}{x}{e}}{\\subst{\\tau_2}{x}{e}}$\n  \\item \\label{item:substitutivity:typing-wf}\n    \\begin{enumerate}[noitemsep]\n      \\item \\label{item:substitutivity:typing} If $\\type{\\Phi; \\Gamma_1, \\annot{x}{\\sigma}, \\Gamma_2}{e'}{\\tau}$\n        then $\\type{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e}}{\\subst{e'}{x}{e}}{\\subst{\\tau}{x}{e}}$\n      \\item \\label{item:substitutivity:wf} If $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\sigma}, \\Gamma_2}$\n        then $\\wf{\\Phi}{\\Gamma_1, \\subst{\\Gamma_2}{x}{e}}$.\n    \\end{enumerate}\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\nThe proof structure is similar to that of \\nameref{lem:replacement-subtyping}.\nFor \\rref{var} of \\cref{item:substitutivity:typing}, if the variable is $x$,\napply \\nameref{lem:weakening} to $\\type{\\Gamma_1}{e}{\\sigma}$\nusing the extended environment from \\cref{item:substitutivity:wf}.\n\\end{proof}\n\n\\begin{corollary}\n\\nameref{lem:substitutivity-terms} also applies when the environment contains $\\define{x}{\\sigma}{e}$\nrather than $\\annot{x}{\\sigma}$ by the exact same arguments.\nNote that the term being substituted in must be the one defined as $x$.\n\\end{corollary}\n\n\\begin{lemma}[Substitutivity by unbounded sizes] \\label{lem:substitutivity-unbounded}\nSuppose $\\wf{\\Phi_1}{s}$.\n\\begin{enumerate}[noitemsep]\n  \\item \\label{item:substitutivity:unbounded:red}\n    If $\\red{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e_1}{e_2}$\n    then $\\red{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\subst{\\Gamma}{\\alpha}{s}}{\\subst{e_1}{\\alpha}{s}}{\\subst{e_2}{\\alpha}{s}}$.\n  \\item \\label{item:substitutivity:unbounded:red*}\n    If $\\red*{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e_1}{e_2}$\n    then $\\red*{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\subst{\\Gamma}{\\alpha}{s}}{\\subst{e_1}{\\alpha}{s}}{\\subst{e_2}{\\alpha}{s}}$.\n  \\item \\label{item:substitutivity:unbounded:subtyping}\n    If $\\subtype{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{\\tau_1}{\\tau_2}$\n    then $\\subtype{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\subst{\\Gamma}{\\alpha}{s}}{\\subst{\\tau_1}{\\alpha}{s}}{\\subst{\\tau_2}{\\alpha}{s}}$.\n  \\item \\label{item:substitutivity:unbounded:sizing}\n    \\begin{enumerate}[noitemsep]\n      \\item If $\\wf{\\Phi_1, \\alpha, \\Phi_2}{r}$\n        then $\\wf{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}}{\\subst{r}{\\alpha}{s}}$.\n      \\item If $\\wf{}{\\Phi_1, \\alpha, \\Phi_2}$\n        then $\\wf{}{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}}$.\n    \\end{enumerate}\n  \\item \\label{item:substitutivity:unbounded:subsizing}\n    If $\\subsize{\\Phi_1, \\alpha, \\Phi_2}{s_1}{s_2}$\n    then $\\subsize{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}}{\\subst{s_1}{\\alpha}{s}}{\\subst{s_2}{\\alpha}{s}}$.\n  \\item\n    \\begin{enumerate}[noitemsep]\n      \\item If $\\type{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e}{\\tau}$\n        then $\\type{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\subst{\\Gamma}{\\alpha}{s}}{\\subst{e}{\\alpha}{s}}{\\subst{\\tau}{\\alpha}{s}}$.\n      \\item If $\\wf{\\Phi_1, \\alpha, \\Phi_2}{\\Gamma}$ then $\\wf{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}}{\\subst{\\Gamma}{\\alpha}{s}}$\n    \\end{enumerate}\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\nFor \\crefrange{item:substitutivity:unbounded:red}{item:substitutivity:unbounded:subtyping},\nthe proof structure is similar to that of \\nameref{lem:substitutivity-terms}.\n\\begin{enumerate}[noitemsep] \\setcounter{enumi}{3}\n  \\item By mutual induction on the derivations of $\\wf{\\Phi_1, \\alpha, \\Phi_2}{r}$ and $\\wf{}{\\Phi_1, \\alpha, \\Phi_2}$.\n    If $r = \\alpha$ (\\ie $\\Phi_2 = \\mt$) and $\\alpha \\in \\Phi_1$, use $\\wf{\\Phi_1}{s}$.\n  \\item By induction on the derivation of $\\subsize{\\Phi_1, \\alpha, \\Phi_2}{s_1}{s_2}$,\n    using \\cref{item:substitutivity:unbounded:sizing}.\n  \\item By mutual induction on the derivations of $\\type{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e}{\\tau}$\n    and $\\wf{\\Phi_1, \\alpha, \\Phi_2}{\\Gamma}$,\n    using \\cref{item:substitutivity:unbounded:subtyping} in \\rref{conv},\n    \\cref{item:substitutivity:unbounded:sizing} in \\rref{sapp, forall<, slam<},\n    and \\cref{item:substitutivity:unbounded:subsizing} in \\rref{sapp<}.\n    \\qedhere\n\\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}[Substitutivity by bounded sizes] \\label{lem:substitutivity-bounded}\nSuppose $\\subsize{\\Phi_1}{\\sss{r}_1}{r_2}$.\n\\begin{enumerate}[noitemsep]\n  \\item \\label{item:substitutivity:bounded:red}\n    If $\\red{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2; \\Gamma}{e_1}{e_2}$ \\\\\n    then $\\red{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}; \\subst{\\Gamma}{\\alpha}{r_1}}{\\subst{e_1}{\\alpha}{r_1}}{\\subst{e_2}{\\alpha}{r_1}}$.\n  \\item \\label{item:substitutivity:bounded:red*}\n    If $\\red*{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2; \\Gamma}{e_1}{e_2}$ \\\\\n    then $\\red*{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}; \\subst{\\Gamma}{\\alpha}{r_1}}{\\subst{e_1}{\\alpha}{r_1}}{\\subst{e_2}{\\alpha}{r_1}}$.\n  \\item \\label{item:substitutivity:bounded:subtyping}\n    If $\\subtype{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2; \\Gamma}{\\tau_1}{\\tau_2}$ \\\\\n    then $\\subtype{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}; \\subst{\\Gamma}{\\alpha}{r_1}}{\\subst{\\tau_1}{\\alpha}{r_1}}{\\subst{\\tau_2}{\\alpha}{r_1}}$.\n  \\item \\label{item:substitutivity:bounded:sizing}\n    \\begin{enumerate}[noitemsep]\n      \\item If $\\wf{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2}{s}$\n        then $\\wf{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}}{\\subst{s}{\\alpha}{r_1}}$.\n      \\item If $\\wf{}{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2}$\n        then $\\wf{}{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}}$.\n    \\end{enumerate}\n  \\item \\label{item:substitutivity:bounded:subsizing}\n    If $\\subsize{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2}{s_1}{s_2}$\n    then $\\subsize{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}}{\\subst{s_1}{\\alpha}{r_1}}{\\subst{s_2}{\\alpha}{r_1}}$.\n  \\item\n    \\begin{enumerate}[noitemsep]\n      \\item If $\\type{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2; \\Gamma}{e}{\\tau}$ \\\\\n        then $\\type{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}; \\subst{\\Gamma}{\\alpha}{r_1}}{\\subst{e}{\\alpha}{r_1}}{\\subst{\\tau}{\\alpha}{r_1}}$.\n      \\item If $\\wf{\\Phi_1, \\bound{\\alpha}{r_2}, \\Phi_2}{\\Gamma}$ then $\\wf{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r_1}}{\\subst{\\Gamma}{\\alpha}{r_1}}$\n    \\end{enumerate}\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\nThe proof structure is similar to that of \\nameref{lem:substitutivity-unbounded}.\nFor \\cref{item:substitutivity:bounded:subsizing},\nif $\\alpha = r_1$ and $s_2 = r_2$ (\\ie $\\Phi_2 = \\mt$),\nuse $\\subsize{\\Phi_1}{\\sss{r}_1}{r_2}$.\n\\end{proof}\n\n\\begin{lemma}[Congruence of closure of reduction] \\label{lem:congruence}\nIf $\\red*{\\Phi'; \\Gamma'}{e_1}{e_2}$\nthen $\\red*{\\Phi; \\Gamma}{\\subst{e}{x}{e_1}}{\\subst{e}{x}{e_2}}$.\n\\end{lemma}\n\n\\begin{proof}\nEither $e_1 = e_2$, making the goal trivial by \\rref{red*-refl},\nor we can show by induction that $\\red*{\\Phi'; \\Gamma'}{e_1}{e_2}$\ncan be split into a finite number of reductions\n$\\Phi'; \\Gamma' \\vdash e_1 \\rhd e'_{1} \\rhd \\dots \\rhd e'_{n} \\rhd e_2$.\nBy \\rref{red-cong, red*-once}, we have\n$\\Phi; \\Gamma \\vdash \\subst{e}{x}{e_1} \\rhd^* \\subst{e}{x}{e'_{1}} \\rhd^* \\dots \\rhd^* \\subst{e}{x}{e'_{n}} \\rhd^* \\subst{e}{x}{e_2}$,\nwhich can then be chained together using \\rref{red*-trans}.\n\\end{proof}\n\nFrom here onwards, because it's used so often in uninteresting ways,\nI omit explicit references to uses of weakening.\n\n\\subsection{Confluence}\n\n\\emph{Confluence}\\index{confluence} states that if some term\nreduces to two different terms, those two terms must eventually\nreduce to some common term.\nThis property is used to prove transitivity of subtyping,\nwhich in turn is used in several proofs throughout.\nThe technique I use is to first show there is some judgement that satisfies the\n\\emph{Z property}\\index{Z property}~\\citep{Z, confluence} for reduction,\nso called for the Z shape formed by reduction and its closure.\nThis is illustrated by \\cref{fig:Z},\nwith the solid arrow representing reduction $\\rhd$ and\ndashed arrows representing its reflexive, transitive closure $\\rhd^*$.\nConfluence then follows from the Z property.\n\n\\begin{definition}[Z property] \\label{def:Z}\nThe judgement $\\develop{\\mt}{\\mt}{\\mt}$ is said to satisfy the Z property\nif $\\develop{\\Phi; \\Gamma}{e_i}{e'_i}$ for $i = 1, 2$\nand $\\red{\\Phi; \\Gamma}{e_1}{e_2}$\nimply that $\\red*{\\Phi; \\Gamma}{e_2}{e'_1}$\nand $\\red*{\\Phi; \\Gamma}{e'_1}{e'_2}$ hold.\n\\end{definition}\n\n\\begin{lemma} \\label{lem:confluence}\nIf there exists some judgement satisfying the Z property,\nthen given $\\red*{\\Phi; \\Gamma}{e}{e_1}$ and $\\red*{\\Phi; \\Gamma}{e}{e_2}$,\nthere exists some term $e'$ such that\n$\\red*{\\Phi; \\Gamma}{e_1}{e'}$ and $\\red*{\\Phi; \\Gamma}{e_2}{e'}$.\n\\end{lemma}\n\n\\vspace{-\\baselineskip}\n\\begin{figure}[h]\n\\centering\n\\begin{tikzcd}\n  e_1\n    \\arrow[r, rightarrow]\n    \\arrow[d, dotted, no head, \"\\blacktriangledown\" description]\n  & e_2\n    \\arrow[d, dotted, no head, \"\\blacktriangledown\" description]\n    \\arrow[dl, dashrightarrow] \\\\\n  e'_1\n    \\arrow[r, dashrightarrow]\n  & e'_2\n\\end{tikzcd}\n\\caption{Diagram illustrating the Z property.}\n\\label{fig:Z}\n\\end{figure}\n\nThe judgement I use to satisfy the Z property is an extension of the\n\\emph{complete development}\\index{complete development}\nused by~\\citet{Takahashi},\nwhich in short reduces all visible redexes from the inside out.\nThe inclusion of the size and term environments are crucial,\nsince $\\delta$-reduction depends on definitions in the environment\nand $\\mu$-reduction depends on subsizing.\n\\cref{fig:develop,app:cong:develop}\npresent the rules for complete development.\nThe first rule from left to right, top to bottom that applies is used,\nmaking complete development decidable and deterministic (up to subsizing)\ngiven the environments and an initial term.\n\n\\FigTakahashi{fig:develop}\n\nTo show that the mapping satisfies the Z property,\nwe first show that it satisfies some properties that will be useful later.\n\n\\begin{lemma} \\label{lem:develop-compos}\nIf $\\develop{\\Phi; \\Gamma_1, \\annot{x}{\\tau}, \\Gamma_2}{e_1}{e'_1}$ and\n$\\develop{\\Phi; \\Gamma_1}{e_2}{e'_2}$, then\n$\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}}{\\subst{e_1}{x}{e_2}}{\\subst{e'_1}{x}{e'_2}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the structure of $e_1$.\nThe cases not involving a redex are straightforward by the induction hypotheses,\nwhile the ones that do, namely those in \\cref{fig:develop},\nrequire some attention to substitution.\nI cover only the cases for a $\\delta$-redex and a $\\zeta$-redex,\nas these involve some subtleties with definitions in the environment,\nand the remaining redex cases are similar to the latter but without definitions.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $e_1 = y$ and $(\\define{y}{\\any}{e}) \\in \\Gamma_1, \\annot{x}{\\tau}, \\Gamma_2$. \\\\\n    We then have that $\\subst{e_1}{x}{e_2} = y$ and $e'_1 = e$.\n    If $y$ is in $\\Gamma_1$, then $x \\notin \\FV{e}$, so $\\subst{e}{x}{e_2} = e$,\n    and $\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}}{y}{e}$.\n    If $y$ is in $\\Gamma_2$, then $(\\define{y}{\\any}{\\subst{e}{x}{e_2}}) \\in \\subst{\\Gamma_2}{x}{e_2}$,\n    and $\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}}{y}{\\subst{e}{x}{e'_2}}$.\n  \\item $e_1 = \\letin{y}{\\tau}{e_3}{e_4}$. \\\\\n    Let $e'_3$, $e'_4$ be the complete developments of $e_3$ and $e_4$, respectively.\n    Suppose that $x \\neq y$.\n    By the induction hypotheses, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}}{\\subst{e_3}{x}{e_2}}{\\subst{e'_3}{x}{e'_2}}$ and\n      \\item $\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}, \\define{y}{\\subst{\\tau}{x}{e_2}}{\\subst{e_3}{x}{e_2}}}{\\subst{e_4}{x}{e_2}}{\\subst{e'_4}{x}{e'_2}}$.\n    \\end{itemize}\n    Then by complete development of $\\kw{let}$ expressions, we have\n    $\\develop{\\Phi; \\Gamma_1, \\subst{\\Gamma_2}{x}{e_2}}{\\letin{y}{\\subst{\\tau}{x}{e_2}}{\\subst{e_3}{x}{e_2}}{\\subst{e_4}{x}{e_2}}}{\\subst{(\\subst{e'_4}{x}{e'_2})}{y}{\\subst{e'_3}{x}{e'_2}}}$. \\\\\n    By the properties of substitution, we have that the right-hand side is\n    $\\subst{(\\subst{e'_4}{y}{e'_3})}{x}{e'_2}$,\n    giving us\n    $\\develop{\\Phi; \\Gamma}{\\subst{(\\letin{y}{\\tau}{e_3}{e_4})}{x}{e_2}}{\\subst{(\\subst{e'_4}{y}{e'_3})}{x}{e'_2}}$\n    as desired.\n    If $x = y$, then $e_2$ and $e'_2$ are never substituted into $e_4$ and $e'_4$, respectively,\n    simplifying the above argument. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{lemma} \\label{lem:develop-compos-size}\nIf $\\develop{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e}{e'}$ or\n$\\develop{\\Phi_1, \\bound{\\alpha}{r}, \\Phi_2; \\Gamma}{e}{e'}$ then\n$\\develop{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\Gamma}{\\subst{e}{\\alpha}{s}}{\\subst{e'}{\\alpha}{s}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy straightforward induction on the structure of $e$.\nIntuitively, since size expressions aren't terms and don't reduce,\nthe substitution leaves the structure of complete development untouched.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:develop-red*}\nIf $\\develop{\\Phi; \\Gamma}{e}{e'}$\nthen $\\red*{\\Phi; \\Gamma}{e}{e'}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\develop{\\Phi; \\Gamma}{e}{e'}$.\nAgain, the cases not involving a redex are straightforward by the induction hypotheses\nusing \\cref{lem:congruence},\nwhile the ones that do also use the reduction rule for the corresponding redex.\nThis time, I cover only the cases for a $\\delta$-redex and a $\\mu$-redex,\nwith the remaining redex cases similar to the latter.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $e = x$.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      (\\define{x}{\\tau}{e}) \\in \\Gamma \\\\\n      \\develop{\\Phi; \\Gamma}{e}{e'}\n    }{\n      \\develop{\\Phi; \\Gamma}{x}{e'}\n    }\n    \\end{mathpar}\n    By the induction hypothesis, we have $\\red*{\\Phi; \\Gamma}{e}{e'}$.\n    By $\\delta$-reduction, we have $\\red{\\Phi; \\Gamma}{x}{e}$.\n    Then by \\rref{red*-once, red*-trans}, we have $\\red*{\\Phi; \\Gamma}{x}{e'}$.\n  \\item $e = \\App{\\fix{f}{\\alpha}{\\tau}{e}}{s}$.\n    \\begin{mathpar}\n    \\inferrule{\n      \\subsize{\\Phi}{\\sss{r}}{s} \\\\\n      \\develop{\\Phi, \\alpha; \\Gamma}{\\tau}{\\tau'} \\\\\n      \\develop{\\Phi, \\alpha; \\Gamma, \\annot{f}{\\Funtype<{\\beta}{\\alpha}{\\subst{\\tau}{\\alpha}{\\beta}}}}{e}{e'}\n    }{\n      \\develop{\\Phi; \\Gamma}{\\App{\\fix{f}{\\alpha}{\\tau}{e}}{s}}{\\subst{e'}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\tau'}{e'})}{\\beta}}}}\n    }\n    \\end{mathpar}\n    By the induction hypotheses, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\red*{\\Phi, \\alpha; \\Gamma}{\\tau}{\\tau'}$ and\n      \\item $\\red*{\\Phi, \\alpha; \\Gamma, \\annot{f}{\\Funtype<{\\beta}{\\alpha}{\\subst{\\tau}{\\alpha}{\\beta}}}}{e}{e'}$.\n    \\end{itemize}\n    By \\cref{lem:congruence}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\red*{\\Phi; \\Gamma}{\\App{\\fix{f}{\\alpha}{\\tau}{e}}{s}}{\\App{\\fix{f}{\\alpha}{\\tau}{e'}}{s}}$ and\n      \\item $\\red*{\\Phi; \\Gamma}{\\App{\\fix{f}{\\alpha}{\\tau}{e'}}{s}}{\\App{\\fix{f}{\\alpha}{\\tau'}{e'}}{s}}$.\n    \\end{itemize}\n    Finally, by $\\mu$-reduction, we have\n    $\\red*{\\Phi; \\Gamma}{\\App{\\fix{f}{\\alpha}{\\tau'}{e'}}{s}}{\\subst{e'}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\tau'}{e'})}{\\beta}}}}$.\n    Then by \\rref{red*-trans}, we have\n    $\\red*{\\Phi; \\Gamma}{\\App{\\fix{f}{\\alpha}{\\tau}{e}}{s}}{\\subst{e'}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\tau'}{e'})}{\\beta}}}}$.\n    \\qedhere\n\\end{itemize}\n\\end{proof}\n\nNow we are ready to show that complete development satisfies the Z property.\n\n\\begin{lemma} \\label{lem:Z-property}\nIf $\\develop{\\Phi; \\Gamma}{e_i}{e'_1}$ for $i = 1, 2$\nand $\\red{\\Phi; \\Gamma}{e_1}{e_2}$\nthen $\\red*{\\Phi; \\Gamma}{e_2}{e'_1}$\nand $\\red*{\\Phi; \\Gamma}{e'_1}{e'_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\red{\\Phi; \\Gamma}{e_1}{e_2}$.\nFor the congruence cases of reduction,\nit could start and end with terms that aren't redexes.\nConsider bounded size quantification as an example.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\phantom{Never gonna give you up}\n  \\vspace{-2\\baselineskip}\n  \\begin{mathpar}\n  \\inferrule{\n    \\red{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\tau_1}{\\tau_2}\n  }{\n    \\red{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\tau_1}}{\\Funtype<{\\alpha}{s}{\\tau_2}}\n  }\n  \\end{mathpar}\n  By the induction hypotheses, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\tau_2}{\\tau'_1}$ and\n    \\item $\\red*{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\tau'_1}{\\tau'_2}$,\n  \\end{itemize}\n  where $\\tau'_1$ and $\\tau'_2$ are the corresponding complete developments.\n  Then quite straightforwardly, by \\cref{lem:congruence}, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\tau_2}}{\\Funtype<{\\alpha}{s}{\\tau'_1}}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\tau'_1}}{\\Funtype<{\\alpha}{s}{\\tau'_2}}$.\n  \\end{itemize}\n\\end{itemize}\nA congruence case could also start with a term that isn't a redex,\nbut end with a reducible term.\nIn this case, consider a size application that steps to an applied bounded size abstraction.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\phantom{Never gonna let you down}\n  \\vspace{-2\\baselineskip}\n  \\begin{mathpar}\n  \\inferrule{\n    \\red{\\Phi; \\Gamma}{e_1}{\\Fun<{\\alpha}{r}{e_2}}\n  }{\n    \\red{\\Phi; \\Gamma}{\\App{e_1}{s}}{\\App{(\\Fun<{\\alpha}{r}{e_2})}{s}}\n  }\n  \\end{mathpar}\n  By the induction hypotheses, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{\\Fun<{\\alpha}{r}{e_2}}{e'_1}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{e'_1}{\\Fun<{\\alpha}{r}{e'_2}}$,\n  \\end{itemize}\n  where $e'_1$ and $e'_2$ are the corresponding complete developments.\n  Again, quite straightforwardly, by \\cref{lem:congruence}, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{\\App{(\\Fun<{\\alpha}{r}{e_2})}{s}}{\\App{e'_1}{s}}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{\\App{e'_1}{s}}{\\App{(\\Fun<{\\alpha}{r}{e'_2})}{s}}$.\n  \\end{itemize}\n  Since $\\red{\\Phi; \\Gamma}{\\App{(\\Fun<{\\alpha}{r}{e'_2})}{s}}{\\subst{e'_2}{\\alpha}{s}}$,\n  using \\rref{red*-once, red*-trans}, we have\n  $\\red*{\\Phi; \\Gamma}{\\App{e'_1}{s}}{\\subst{e'_2}{\\alpha}{s}}$,\n  where the right-hand side is the complete development of $\\App{(\\Fun<{\\alpha}{r}{e_2})}{s}$.\n\\end{itemize}\nLastly, a congruence case could start and end with a redex,\nas is the case for $\\kw{let}$ expressions.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\phantom{Never gonna run around}\n  \\vspace{-2\\baselineskip}\n  \\begin{mathpar}\n  \\inferrule{\n    \\red{\\Phi; \\Gamma, \\define{x}{\\tau}{e_1}}{e_2}{e_3}\n  }{\n    \\red{\\Phi; \\Gamma}{\\letin{x}{\\tau}{e_1}{e_2}}{\\letin{x}{\\tau}{e_1}{e_3}}\n  }\n  \\end{mathpar}\n  By the induction hypotheses, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma, \\define{x}{\\tau}{e_1}}{e_3}{e'_2}$ and\n    \\item $\\red*{\\Phi; \\Gamma, \\define{x}{\\tau}{e_1}}{e'_2}{e'_3}$,\n  \\end{itemize}\n  where $e'_2$ and $e'_3$ are the corresponding complete developments.\n  By \\cref{lem:congruence}, we have\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{\\letin{x}{\\tau}{e_1}{e_3}}{\\letin{x}{\\tau}{e_1}{e'_2}}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{\\subst{e'_2}{x}{e'_1}}{\\subst{e'_3}{x}{e'_1}}$.\n  \\end{itemize}\n  By \\cref{lem:develop-red*}, we also have $\\red*{\\Phi; \\Gamma}{e_1}{e'_1}$,\n  where $e'_1$ is the corresponding complete development,\n  so applying \\cref{lem:congruence} again with $\\zeta$-reduction and chaining it all up,\n  we have $\\red*{\\Phi; \\Gamma}{\\letin{x}{\\tau}{e_1}{e_3}}{\\subst{e'_2}{x}{e'_1}}$.\n\\end{itemize}\nThe remaining cases for congruence of reduction not covered here are similar to the above,\nfalling into one of the three categories.\nMeanwhile, the reduction rules involving redexes except $\\delta$-reduction\nall involve some form of substitution,\nso I only cover $\\delta$-reduction and $\\beta$-reduction for functions,\nthe latter of which is representative of the remaining cases.\nNote that for situations involving substitution of a size expression rather than a term,\n\\cref{lem:develop-compos-size} is used in place of \\cref{lem:develop-compos}.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\red{\\Phi; \\Gamma}{x}{e}$ when $(\\define{x}{\\tau}{e}) \\in \\Gamma$. \\\\\n  Letting $e'$ be the complete development of $e$,\n  the goals are then\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{e}{e'}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{e'}{e'}$,\n  \\end{itemize}\n  which hold by \\cref{lem:develop-red*} and \\rref{red*-refl} respectively.\n  \\item $\\red{\\Phi; \\Gamma}{\\app{(\\fun{x}{\\tau}{e_1})}{e_2}}{\\subst{e_1}{x}{e_2}}$. \\\\\n  Let $e'_1$ and $e'_2$ be the complete development of $e_1$ and $e_2$ respectively.\n  By \\cref{lem:develop-compos}, we have\n  $\\develop{\\Phi; \\Gamma}{\\subst{e_1}{x}{e_2}}{\\subst{e'_1}{x}{e'_2}}$.\n  Then by \\cref{lem:develop-red*} and by \\rref{red*-refl}, we have our goals\n  \\begin{itemize}[noitemsep]\n    \\item $\\red*{\\Phi; \\Gamma}{\\subst{e_1}{x}{e_2}}{\\subst{e'_1}{x}{e'_2}}$ and\n    \\item $\\red*{\\Phi; \\Gamma}{\\subst{e'_1}{x}{e'_2}}{\\subst{e'_1}{x}{e'_2}}$. \\qedhere\n  \\end{itemize}\n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}[Confluence] \\label{thm:confluence}\nIf $\\red*{\\Phi; \\Gamma}{e}{e_1}$ and $\\red*{\\Phi; \\Gamma}{e}{e_2}$\nthen there is some term $e'$ such that\n$\\red*{\\Phi; \\Gamma}{e_1}{e'}$ and $\\red*{\\Phi; \\Gamma}{e_2}{e'}$.\n\\end{theorem}\n\n\\begin{proof}\nSince complete development satisfies the Z property by \\cref{lem:Z-property},\nconfluence holds by \\cref{lem:confluence}.\nSee \\citet[Theorem 3.10]{confluence} for a complete proof.\n\\end{proof}\n\n\\subsection{Inversion on typing}\n\n\\emph{Inversion principles}\\index{inversion} on typing\nallow for deducing from a typing judgement the necessary premises for a typing derivation,\nwith one principle for each syntactic form.\nIn the presence of subtyping, these principles are a little more complex,\nrelating the type derived from the premises to the desired type by a subtyping judgement.\nFor concision, I prove all inversion principles for a general typing rule\nrather than handling each rule explicitly.\n\nBefore we can prove these inversion principles,\nwe need transitivity of the subtyping judgement,\nwhich in turn requires both confluence and transitivity of $\\alpha$-cumulativity\\index{$\\alpha$-cumulativity},\nas well a few inversion principles for the closure of reduction.\n\n\\begin{lemma}[Inversion on closure of reduction (\\rref{pi})] \\label{lem:inversion-red}\nIf $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma_1}{\\tau_1}}{\\tau}$,\nthen $\\tau = \\funtype{x}{\\sigma_2}{\\tau_2}$,\nand we have $\\red*{\\Phi; \\Gamma}{\\sigma_1}{\\sigma_2}$\nand $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_1}{\\tau_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma_1}{\\tau_1}}{\\tau}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Cases}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{red*-refl}. Trivial by \\rref{red*-refl} on $\\sigma_1$ and $\\tau_1$.\n  \\item \\rref*{red*-once}. By case analysis on $\\red{\\Phi; \\Gamma}{\\funtype{x}{\\sigma_1}{\\tau_1}}{\\tau}$,\n    the only possible rule is a congruence rule.\n    Either $\\red{\\Phi; \\Gamma}{\\sigma_1}{\\sigma_2}$ and $\\tau_1 = \\tau_2$,\n    so that the goals hold by \\rref{red*-once, red*-refl} respectively,\n    or $\\sigma_1 = \\sigma_2$ and $\\red{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_1}{\\tau_2}$,\n    so that the goals hold by \\rref{red*-refl, red*-once} respectively.\n  \\item \\rref*{red*-trans}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma_1}{\\tau_1}}{\\tau'} \\\\\n      \\red*{\\Phi; \\Gamma}{\\tau'}{\\tau}\n    }{\n      \\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma_1}{\\tau_1}}{\\tau}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\tau' = \\funtype{x}{\\sigma_2}{\\tau_2}$,\n        $\\red*{\\Phi; \\Gamma}{\\sigma_1}{\\sigma_2}$, and\n        $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_1}{\\tau_2}$; and\n      \\item $\\tau = \\funtype{x}{\\sigma_3}{\\tau_3}$,\n        $\\red*{\\Phi; \\Gamma}{\\sigma_2}{\\sigma_3}$, and\n        $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_2}}{\\tau_2}{\\tau_3}$.\n    \\end{itemize}\n    By \\rref{red*-refl, acum-refl, subtype-red}, we have $\\subtype{\\Phi; \\Gamma}{\\sigma_1}{\\sigma_2}$.\n    Then by \\cref{lem:replacement-subtyping}, we have $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_2}{\\tau_3}$.\n    Finally, by \\rref{red*-trans} twice, we have\n    $\\red*{\\Phi; \\Gamma}{\\sigma_1}{\\sigma_3}$ and\n    $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_1}{\\tau_3}$. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{corollary}[Inversion on closure of reduction (\\rref{forall, forall<})]\nIf $\\red*{\\Phi; \\Gamma}{\\Funtype{\\alpha}{\\sigma}}{\\tau}$\nor $\\type{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\sigma}}{\\tau}$,\nthen $\\tau = \\Funtype{\\alpha}{\\sigma'}$ or $\\tau = \\Funtype<{\\alpha}{s}{\\sigma'}$,\nand $\\red*{\\Phi, \\alpha; \\Gamma}{\\sigma}{\\sigma'}$\nor $\\red*{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\sigma}{\\sigma'}$\nby the same argument as for \\nameref{lem:inversion-red},\nusing instead the congruence reduction rules for\n$\\Funtype{\\alpha}{\\sigma}$ or $\\Funtype<{\\alpha}{s}{\\sigma}$\nin the case of \\rref*{red*-once}.\n\\end{corollary}\n\n\\begin{lemma}[Transitivity of $\\alpha$-cumulativity] \\label{lem:transitivity-acum}\nIf $\\acum{e_1}{e_2}$ and $\\acum{e_2}{e_3}$ then $\\acum{e_1}{e_3}$.\n\\end{lemma}\n\n\\begin{proof}\nBy nested induction on the derivations of $\\acum{e_1}{e_2}$ and $\\acum{e_2}{e_3}$.\n\\begin{enumerate}[noitemsep, label=\\textbf{Cases}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{acum-refl} and $\\mathcal{R}$, $\\mathcal{R}$ and \\rref*{acum-refl}.\n    Trivial by the $\\mathcal{R}$ derivation.\n  \\item \\rref*{acum-prop} and \\rref*{acum-type}, \\rref*{acum-type} and \\rref*{acum-type}.\n    Trivial by \\rref*{acum-prop} or \\rref*{acum-type} respectively.\n  \\item \\rref*{acum-pi} and \\rref*{acum-pi}, \\rref*{acum-forall} and \\rref*{acum-forall}, \\rref*{acum-forall<} and \\rref*{acum-forall<}.\n    By \\rref*{acum-pi}, \\rref*{acum-forall}, or \\rref*{acum-forall<}, respectively,\n    using the induction hypothesis as premise. \\qedhere\n\\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}[Confluence up to $\\alpha$-cumulativity] \\label{lem:confluence-acum}\nSuppose we have the following:\n\\begin{itemize}[noitemsep]\n  \\item $\\acum{e_1}{e_2}$,\n  \\item $\\red*{\\Phi; \\Gamma}{e_1}{e'_1}$, and\n  \\item $\\red*{\\Phi; \\Gamma}{e_2}{e'_2}$.\n\\end{itemize}\nThen there are terms $e''_1, e''_2$ such that\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma}{e'_1}{e''_1}$,\n  \\item $\\red*{\\Phi; \\Gamma}{e'_2}{e''_2}$, and\n  \\item $\\acum{e''_1}{e''_2}$.\n\\end{itemize}\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\acum{e_1}{e_2}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{acum-refl}. By \\nameref{thm:confluence} and \\rref*{acum-refl}.\n  \\item[\\textbf{Cases}] \\rref*{acum-prop}, \\rref*{acum-type}.\n    Since $\\Prop$ and $\\Type{}$ don't reduce any further,\n    this is trivial by \\rref{acum-prop} or \\rref{acum-type} respectively with \\rref{red*-refl}.\n  \\item \\rref*{acum-pi}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\acum{\\tau_1}{\\tau_2}\n      }{\n        \\acum{\\funtype{x}{\\sigma}{\\tau_1}}{\\funtype{x}{\\sigma}{\\tau_2}}\n      }\n    \\end{mathpar}\n    By inversion on the closures of reduction, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma_1}$,\n      \\item $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_1}}{\\tau_1}{\\tau'_1}$,\n      \\item $\\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma_2}$, and\n      \\item $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma_2}}{\\tau_2}{\\tau'_2}$.\n    \\end{itemize}\n    By \\nameref{thm:confluence}, we have $\\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma'}$\n    for some $\\sigma'$.\n    By \\rref{red*-refl, acum-refl, subtype-red},\n    we have $\\subtype{\\Phi; \\Gamma}{\\sigma'}{\\sigma_i}$ for $i = 1, 2$.\n    Then by \\nameref{lem:replacement-subtyping},\n    we have $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma'}}{\\tau_i}{\\tau'_i}$\n    for $i = 1, 2$,\n    and we can apply the induction hypothesis to get\n    \\begin{itemize}[noitemsep]\n      \\item $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma'}}{\\tau'_1}{\\tau''_1}$,\n      \\item $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma'}}{\\tau'_2}{\\tau''_2}$, and\n      \\item $\\acum{\\tau''_1}{\\tau''_2}$.\n    \\end{itemize}\n    Finally, by \\nameref{lem:congruence}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\tau'_1}}{\\funtype{x}{\\sigma'}{\\tau''_1}}$, \n      \\item $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\tau'_2}}{\\funtype{x}{\\sigma'}{\\tau''_2}}$, and\n      \\item $\\acum{\\funtype{x}{\\sigma'}{\\tau''_1}}{\\funtype{x}{\\sigma'}{\\tau''_2}}$.\n    \\end{itemize}\n  \\item[\\textbf{Cases}] \\rref*{acum-forall}, \\rref*{acum-forall<}.\n    Similar to the case for \\rref*{acum-pi}. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{lemma}[Right confluence up to $\\alpha$-cumulativity] \\label{lem:confluence-acum-right}\nIf $\\acum{e_1}{e_2}$ and $\\red*{\\Phi; \\Gamma}{e_1}{e'_1}$ then there is some term $e'_2$ such that\n$\\red*{\\Phi; \\Gamma}{e_2}{e'_2}$ and $\\acum{e'_1}{e'_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\acum{e_1}{e_2}$.\n\\begin{enumerate}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{acum-refl}. Trivial by \\rref*{acum-refl} with the same reduction judgement.\n  \\item[\\textbf{Cases}] \\rref*{acum-prop}, \\rref*{acum-type}.\n    Since $\\Prop$ and $\\Type{}$ don't reduce any further,\n    trivial by \\rref*{acum-prop} or \\rref*{acum-type} respectively with \\cref{red*-refl}.\n  \\item \\rref*{acum-pi}. \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\acum{\\tau_1}{\\tau_2}\n      }{\n        \\acum{\\funtype{x}{\\sigma}{\\tau_1}}{\\funtype{x}{\\sigma}{\\tau_2}}\n      }\n    \\end{mathpar}\n    By inversion on the closure of reduction, we have\n    $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\tau_1}}{\\funtype{x}{\\sigma'}{\\tau'_1}}$.\n    where $\\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma'}$ and $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma'}}{\\tau_1}{\\tau'_1}$.\n    By the induction hypothesis, we can conclude that there is some term $\\tau'_2$ such that\n    $\\red*{\\Phi; \\Gamma, \\annot{x}{\\sigma'}}{\\tau_2}{\\tau'_2}$ and $\\acum{\\tau'_1}{\\tau'_2}$.\n    Then by \\nameref{lem:congruence} we conclude that $\\red*{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\tau_2}}{\\funtype{x}{\\sigma'}{\\tau'_2}}$,\n    and by \\rref{acum-pi} that $\\acum{\\funtype{x}{\\sigma'}{\\tau'_1}}{\\funtype{x}{\\sigma'}{\\tau'_2}}$.\n  \\item \\rref*{acum-forall}, \\rref*{acum-forall<}. Similar to the case for \\rref*{acum-pi}. \\qedhere\n\\end{enumerate}\n\\end{proof}\n\n\\begin{corollary}[Left confluence up to $\\alpha$-cumulativity] \\label{lem:confluence-acum-left}\nIf $\\acum{e_1}{e_2}$ and $\\red*{\\Phi; \\Gamma}{e_2}{e'_2}$ then there is some $e'_1$ such that\n$\\red*{\\Phi; \\Gamma}{e_1}{e'_1}$ and $\\acum{e'_1}{e'_2}$,\nusing the symmetric argument to \\cref{lem:confluence-acum-right}.\n\\end{corollary}\n\n\\begin{theorem}[Transitivity of subtyping] \\label{thm:transitivity-subtyping}\\index{subtyping}\nIf $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}$ and $\\subtype{\\Phi; \\Gamma}{\\tau_2}{\\tau_3}$\nthen $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_3}$.\n\\end{theorem}\n\n\\begin{proof}\nBy cases on the derivations of $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}$\nand $\\subtype{\\Phi; \\Gamma}{\\tau_2}{\\tau_3}$.\n\\begin{mathpar}\n\\inferrule{\n  \\acum{\\sigma_1}{\\sigma_{21}} \\\\\\\\\n  \\red*{\\Phi; \\Gamma}{\\tau_1}{\\sigma_1} \\\\\n  \\red*{\\Phi; \\Gamma}{\\tau_2}{\\sigma_{21}}\n}{\n  \\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}\n}\n\\and\n\\inferrule{\n  \\acum{\\sigma_{22}}{\\sigma_3} \\\\\\\\\n  \\red*{\\Phi; \\Gamma}{\\tau_2}{\\sigma_{22}} \\\\\n  \\red*{\\Phi; \\Gamma}{\\tau_3}{\\sigma_3}\n}{\n  \\subtype{\\Phi; \\Gamma}{\\tau_2}{\\tau_3}\n}\n\\end{mathpar}\nBy \\nameref{thm:confluence}, there is some term $\\tau'_2$ such that\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma}{\\sigma_{21}}{\\tau'_2}$ and\n  \\item $\\red*{\\Phi; \\Gamma}{\\sigma_{22}}{\\tau'_2}$.\n\\end{itemize}\nBy \\nameref{lem:confluence-acum-left} and \\nameref{lem:confluence-acum-right},\nthere are terms $\\tau'_1$ and $\\tau'_3$ such that\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma}{\\sigma_1}{\\tau'_1}$,\n  \\item $\\acum{\\tau'_1}{\\tau'_2}$; and\n  \\item $\\red*{\\Phi; \\Gamma}{\\sigma_3}{\\tau'_3}$,\n  \\item $\\acum{\\tau'_2}{\\tau'_3}$.\n\\end{itemize}\nBy \\rref{red*-trans} and \\nameref{lem:transitivity-acum}, we have\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma}{\\tau_1}{\\tau'_1}$,\n  \\item $\\red*{\\Phi; \\Gamma}{\\tau_3}{\\tau'_3}$, and\n  \\item $\\acum{\\tau'_1}{\\tau'_3}$.\n\\end{itemize}\nThen finally by \\rref{subtype-red}, we have $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_3}$.\n\\end{proof}\n\n\\begin{figure}[h]\n\\centering\n\\begin{tikzcd}\n\\tau_1\n  \\arrow[rr, dotted, no head, \"\\displaystyle\\preccurlyeq\" description]\n  % \\arrow[dd, dashrightarrow, bend right]\n  \\arrow[d, dashrightarrow]\n&&\\tau_2\n  \\arrow[rr, dotted, no head, \"\\displaystyle\\preccurlyeq\" description]\n  \\arrow[dl, dashrightarrow]\n  \\arrow[dr, dashrightarrow]\n&&\\tau_3\n  % \\arrow[dd, dashrightarrow, bend left]\n  \\arrow[d, dashrightarrow] \\\\\n\\sigma_1\n  \\arrow[r, dotted, no head, \"\\sqsubseteq\" description]\n  \\arrow[d, dashrightarrow]\n&\\sigma_{21}\n  \\arrow[dr, dashrightarrow]\n&&\\sigma_{22}\n  \\arrow[r, dotted, no head, \"\\sqsubseteq\" description]\n  \\arrow[dl, dashrightarrow]\n&\\sigma_3\n  \\arrow[d, dashrightarrow] \\\\\n\\tau'_1\n  \\arrow[rr, dotted, no head, \"\\sqsubseteq\" description]\n  % \\arrow[rrrr, dotted, no head, bend right, \"\\sqsubseteq\" description]\n&&\\tau'_2\n  \\arrow[rr, dotted, no head, \"\\sqsubseteq\" description]\n&&\\tau'_3\n\\end{tikzcd}\n\\caption{Diagram of proof of \\nameref{thm:transitivity-subtyping}.}\n\\label{fig:transitivity-subtyping}\n\\end{figure}\n\nA diagram representing the proof is shown in \\cref{fig:transitivity-subtyping},\nwhere again the dashed arrows represent closure of reduction $\\rhd^*$.\n\n\\begin{theorem}[Inversion on typing] \\label{thm:inversion}\nGiven a syntactic form $e$ and a typing rule $\\mathcal{R} \\neq \\text{\\upshape \\rref*{conv*}}$ for that form,\nif $\\mathcal{D}$ is a derivation ending in $\\type{\\Gamma}{e}{\\tau}$\nand $\\mathcal{J}_i$ are the judgement forms in the premises of $\\mathcal{R}$,\nthen there exist derivations $\\mathcal{D}_i$ ending in $\\mathcal{J}_i$\nsuch that $\\mathcal{R}$ builds a derivation ending in $\\type{\\Gamma}{e}{\\sigma}$,\nand $\\subtype{\\Gamma}{\\sigma}{\\tau}$ holds.\n\\end{theorem}\n\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Gamma}{e}{\\tau}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\mathcal{R}$. The premises of the derivation are the desired ones,\n    building a derivation ending in $\\type{\\Gamma}{e}{\\tau}$,\n    and $\\subtype{\\Gamma}{\\tau}{\\tau}$ holds by\n    \\rref{subtype-conv, acum-refl, red*-refl}.\n  \\item \\rref*{conv*}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\type{\\Gamma}{d}{\\sigma} \\\\\n      \\type{\\Gamma}{\\sigma}{U} \\\\\n      \\type{\\Gamma}{\\tau}{U} \\\\\n      \\subtype{\\Gamma}{\\sigma}{\\tau}\n    }{\n      \\type{\\Gamma}{e}{\\tau}\n    }\n    \\end{mathpar}\n    Induction hypothesis: there are derivations $\\mathcal{D}_i$ ending in $\\mathcal{J}_i$\n    such that $\\mathcal{R}$ builds a derivation ending in $\\type{\\Gamma}{e}{\\sigma'}$\n    and $\\subtype{\\Gamma}{\\sigma'}{\\sigma}$ holds. \\\\\n    The desired derivations are $\\mathcal{D}_i$, and $\\subtype{\\Gamma}{\\sigma'}{\\tau}$\n    holds by \\nameref{thm:transitivity-subtyping}. \\qedhere\n\\end{itemize}\n\\end{proof}\n\nWith inversion on typing judgements,\nwe can conclude that the natural premises hold up to subtyping\nwithout having to do case analysis on typing derivations and handle \\rref{conv} every single time.\nFor example, given $\\type{\\Phi; \\Gamma}{\\fun{x}{\\sigma}{e}}{\\tau}$,\nwe can conclude the following setting $\\mathcal{R} = \\rref*{lam}$:\n\\begin{itemize}[noitemsep]\n  \\item $\\type{\\Phi; \\Gamma}{\\sigma}{U}$,\n  \\item $\\type{\\Phi; \\Gamma, \\annot{x}{\\sigma}}{e}{\\sigma'}$, and\n  \\item $\\subtype{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\sigma'}}{\\tau}$.\n\\end{itemize}\nUses of inversion on typing will henceforth be referred to simply as inversion,\nwithout backreferences to the theorem statement.\n\n\\subsection{Replacement by reduction}\n\nSimilar to \\nameref{lem:replacement-subtyping}\\index{replacement},\nwhere a type annotation in the environment can be replaced by a subtype,\na definition in the environment can also be replaced by a reduct.\nIn contrast, the proof is more involved and requires \\nameref{thm:confluence}.\n\n\\begin{lemma} \\label{lem:replacement-reduction-1}\nIf $\\red{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e_2}{e'_2}$\nand $\\red*{\\Phi; \\Gamma_1}{e_1}{e'_1}$,\nthen there is some term $e''_2$\nsuch that $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{e_2}{e''_2}$\nand $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{e'_2}{e''_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of\n$\\red{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e_2}{e'_2}$.\nIn the case of $\\delta$-reduction where\n$\\red{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{x}{e_1}$,\nwe have\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{x}{e'_1}$ by $\\delta$-reduction and \\rref{red*-once}, and\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{e_1}{e'_1}$ by the second hypothesis.\n\\end{itemize}\nFor the case of \\rref*{red-cong},\nthe goal holds by the induction hypotheses and \\nameref{lem:congruence}.\nAll other cases are trivial, always reducing to the existing reduct.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:replacement-reduction-2}\nIf $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e_2}{e'_2}$\nand $\\red*{\\Phi; \\Gamma_1}{e_1}{e'_1}$,\nthen there is some term $e''_2$\nsuch that $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{e_2}{e''_2}$\nand $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e'_1}, \\Gamma_2}{e'_2}{e''_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of\n$\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e_2}{e'_2}$.\nThe \\rref*{red*-once} case holds by \\cref{lem:replacement-reduction-1} and\nthe \\rref*{red*-refl} case by \\rref{red*-refl}.\nThe \\rref*{red*-trans} case holds using \\nameref{thm:confluence}\non the two reducts from the middle term in the transitivity.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:replacement-reduction-3}\nIf $\\subtype{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{\\tau_1}{\\tau_2}$\nand $\\red*{\\Gamma_1}{e_1}{e_2}$\nthen $\\subtype{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau_1}{\\tau_2}$.\n\\end{lemma}\n\n\\begin{proof}\nBy cases on the derivation of\n$\\subtype{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{\\tau_1}{\\tau_2}$,\nthere being only one case.\n\\begin{mathpar}\n\\inferrule{\n  \\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{\\tau_1}{\\tau'_1} \\\\\n  \\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{\\tau_2}{\\tau'_2} \\\\\n  \\acum{\\tau'_1}{\\tau'_2}\n}{\n  \\subtype{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{\\tau_1}{\\tau_2}\n}\n\\end{mathpar}\nBy \\cref{lem:replacement-reduction-2}, there are two terms $\\tau''_1, \\tau''_2$ such that\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau_i}{\\tau''_i}$ and\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau'_i}{\\tau''_i}$\n\\end{itemize}\nfor $i = 1, 2$.\nBy \\nameref{lem:confluence-acum} on the latter, there are two terms $\\tau'''_1, \\tau'''_2$ such that\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau''_1}{\\tau'''_1}$,\n  \\item $\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau''_2}{\\tau'''_2}$, and\n  \\item $\\acum{\\tau'''_1}{\\tau'''_2}$.\n\\end{itemize}\nFinally, by \\rref{red*-trans}, we have\n$\\red*{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau_i}{\\tau'''_i}$\nfor $i = 1, 2$,\nand by \\rref{subtype-red} we have\n$\\subtype{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{\\tau_1}{\\tau_2}$.\n\\end{proof}\n\nA diagram representing the proof is shown in \\cref{fig:replacement-reduction-3},\nwhere again the dashed arrows represent closure of reduction $\\rhd^*$.\n\n\\begin{lemma}[Replacement by reduction] \\label{lem:replacement-reduction}\nIf $\\type{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e}{\\tau}$\nand $\\red*{\\Gamma_1}{e_1}{e_2}$\nthen $\\type{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_2}, \\Gamma_2}{e}{\\tau}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of\n$\\type{\\Phi; \\Gamma_1, \\define{x}{\\sigma}{e_1}, \\Gamma_2}{e}{\\tau}$,\nusing \\cref{lem:replacement-reduction-3}\nfor the case of \\rref*{conv}.\n\\end{proof}\n\n\\begin{figure}[h]\n\\centering\n\\begin{tikzcd}\n&\\tau_1\n  \\arrow[dl, dashrightarrow]\n  \\arrow[d, dashrightarrow]\n  \\arrow[r, dotted, no head, \"\\displaystyle\\preccurlyeq\" description]\n&\\tau_2\n  \\arrow[dr, dashrightarrow]\n  \\arrow[d, dashrightarrow] \\\\\n\\tau''_1\n  \\arrow[dr, dashrightarrow]\n&\\tau'_1\n  \\arrow[l, dashrightarrow]\n  \\arrow[r, dotted, no head, \"\\sqsubseteq\" description]\n&\\tau'_2\n  \\arrow[r, dashrightarrow]\n&\\tau''_2\n  \\arrow[dl, dashrightarrow] \\\\\n&\\tau'''_1\n  \\arrow[r, dotted, no head, \"\\sqsubseteq\" description]\n&\\tau'''_2\n\\end{tikzcd}\n\\caption{Diagram of proof of \\cref{lem:replacement-reduction-3}.}\n\\label{fig:replacement-reduction-3}\n\\end{figure}\n\n\\subsection{Regularity}\n\n\\emph{Regularity}\\index{regularity}\nstates that the types of typing judgements are themselves well-typed.\nProving this requires the substitutivity lemmas as well as a few inversion principles.\n\n\\begin{lemma} \\label{lem:wf-subsize}\nIf $\\subsize{\\Phi}{r}{s}$ then $\\wf{\\Phi}{r}$ and $\\wf{\\Phi}{s}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\subsize{\\Phi}{r}{s}$.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:typed-env}\nIf $\\wf{\\Phi}{\\Gamma}$ and $(\\annot{x}{\\tau}) \\in \\Gamma$\nthen $\\type{\\Phi; \\Gamma}{\\tau}{U}$ for some $U$.\n\\end{lemma}\n\\begin{proof}\nBy induction on the derivation of $\\wf{\\Phi}{\\Gamma}$.\nFor \\rref{cons-ass}, if the variable is $x$, the typing premise is the desired typing judgement.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:wf-env}\nIf $\\type{\\Phi; \\Gamma}{e}{\\tau}$ then $\\wf{\\Phi}{\\Gamma}$.\n\\end{lemma}\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Phi; \\Gamma}{e}{\\tau}$.\n\\end{proof}\n\n\\begin{lemma} \\label{lem:wf-env-size}\nIf $\\wf{\\Phi}{\\Gamma}$ then $\\wf{}{\\Phi}$.\n\\end{lemma}\n\\begin{proof}\nBy induction on the derivation of $\\wf{\\Phi}{\\Gamma}$.\n\\end{proof}\n\n\\begin{theorem}[Regularity] \\label{thm:regularity}\nIf $\\type{\\Phi; \\Gamma}{e}{\\tau}$ then $\\type{\\Phi; \\Gamma}{\\tau}{U}$.\n\\end{theorem}\n\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Phi; \\Gamma}{e}{\\tau}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{conv}. Trivial.\n  \\item \\rref*{var}. By \\cref{lem:typed-env}.\n  \\item[\\textbf{Cases}] \\rref*{univ}, \\rref*{pi}, \\rref*{forall}, \\rref*{forall<}, \\rref*{nat}, \\rref*{wft}.\n    By \\rref{univ}, using \\cref{lem:wf-env} when needed.\n  \\item[\\textbf{Cases}] \\rref*{lam}, \\rref*{slam}, \\rref*{slam<}.\n    By \\rref{pi, forall, forall<} respectively,\n    using the induction hypothesis as premise.\n  \\item[\\textbf{Cases}] \\rref*{zero}, \\rref*{succ}, \\rref*{sup}.\n    By \\rref{nat, nat, wft} respectively,\n    using \\cref{lem:wf-subsize} to get a size judgement from the subsizing premise.\n  \\item \\rref*{app}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\infer{\\Phi; \\Gamma}{e_1}{\\funtype{x}{\\sigma}{\\tau}} \\\\\n        \\check{\\Phi; \\Gamma}{e_2}{\\sigma}\n      }{\n        \\infer{\\Phi; \\Gamma}{\\app{e_1}{e_2}}{\\subst{\\tau}{x}{e_1}}\n      }\n    \\end{mathpar}\n    By the induction hypothesis, $\\funtype{x}{\\sigma}{\\tau}$ is well typed with some universe $U$.\n    By \\nameref{thm:inversion} on \\rref{pi},\n    we have that $\\type{\\Phi; \\Gamma, \\annot{x}{\\sigma}}{\\tau}{U'}$ for some $U'$.\n    By \\nameref{lem:substitutivity-terms}, we conclude that $\\type{\\Phi; \\Gamma}{\\subst{\\tau}{x}{e_1}}{U'}$.\n  \\item[\\textbf{Cases}] \\rref*{case-nat}, \\rref*{case-wft}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\type{\\Phi; \\Gamma}{e}{\\N{s}} \\\\\n        \\type{\\Phi; \\Gamma, \\annot{x}{\\N{s}}}{P}{U} \\\\\n        \\dots\n      }{\n        \\infer{\\Phi; \\Gamma}{\\match{e}{\\fun*{x}{P}}{\\any \\any}}{\\subst{P}{x}{e}}\n      }\n      \\and\n      \\inferrule{\n        \\type{\\Phi; \\Gamma}{e}{\\W{x}{\\sigma}{\\tau}{s}} \\\\\n        \\type{\\Phi; \\Gamma, \\annot{x}{\\W{x}{\\sigma}{\\tau}{s}}}{P}{U} \\\\\n        \\dots\n      }{\n        \\infer{\\Phi; \\Gamma}{\\match{e}{\\fun*{x}{P}}{\\any}}{\\subst{P}{x}{e}}\n      }\n    \\end{mathpar}\n    By \\nameref{lem:substitutivity-terms} of $e$ in $P$.\n  \\item[\\textbf{Cases}] \\rref*{sapp}, \\rref*{sapp<}.\n    By the same argument as for case \\rref*{app},\n    using instead inversion on \\rref{forall, forall<} respectively,\n    followed by \\nameref{lem:substitutivity-unbounded} and \\nameref{lem:substitutivity-bounded} respectively.\n  \\item \\rref*{fix}. By \\rref{forall} on the first premise. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Subject reduction}\n\nThe final metatheoretical property required is \\emph{subject reduction}\\index{subject reduction},\nwhich states that what a well-typed term reduces to is also well-typed with the same type.\nThe proof requires using the replacement lemmas.\n\n\\begin{lemma} \\label{lem:wf-defs}\nIf $\\wf{\\Phi}{\\Gamma}$ and $(\\define{x}{\\tau}{e}) \\in \\Gamma$ then $\\type{\\Gamma}{e}{\\tau}$.\n\\end{lemma}\n\\begin{proof}\nBy induction on the derivation of $\\wf{\\Phi}{\\Gamma}$,\nusing the typing premise of \\rref{cons-def} when the variable is $x$.\n\\end{proof}\n\n\\begin{lemma}[Subject reduction] \\label{lem:sr}\nIf $\\type{\\Phi; \\Gamma}{e}{\\tau}$ and $\\red{\\Phi; \\Gamma}{e}{e'}$ then $\\type{\\Phi; \\Gamma}{e'}{\\tau}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\red{\\Phi; \\Gamma}{e}{e'}$ and \\nameref{thm:inversion} of the right-hand term.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\textbf{for $\\delta$-reduction}. Follows by \\cref{lem:wf-env,lem:wf-defs}.\n  \\item \\textbf{for $\\beta$-reduction} (application of bounded sizes).\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{~}{\n      \\red{\\Phi; \\Gamma}{\\App{(\\Fun<{\\alpha}{r}{e})}{s}}{\\subst{e}{\\alpha}{s}}\n    }\n    \\end{mathpar}\n    By inversion on \\rref{sapp<}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\Fun<{\\alpha}{r}{e}}{\\Funtype<{\\alpha}{r}{\\sigma}}$,\n      \\item $\\subsize{\\Phi}{\\sss{s}}{r}$, and\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\sigma}{\\alpha}{s}}{\\tau}$.\n    \\end{itemize}\n    By inversion again on \\rref{slam}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\wf{\\Phi}{s}$,\n      \\item $\\type{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{e}{\\sigma'}$, and\n      \\item $\\subtype{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\sigma'}}{\\Funtype<{\\alpha}{s}{\\sigma}}$.\n    \\end{itemize}\n    By inversion on subtyping, $\\alpha$-cumulativity, and closure of reduction,\n    we also have $\\subtype{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\sigma'}{\\sigma}$.\n    % TODO: please don't make me explicitly list the inversion principles\n    By \\nameref{lem:substitutivity-bounded}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\sigma'}{\\alpha}{s}}{\\subst{\\sigma}{\\alpha}{s}}$ and\n      \\item $\\type{\\Phi; \\Gamma}{\\subst{e}{\\alpha}{s}}{\\subst{\\sigma'}{\\alpha}{s}}$.\n    \\end{itemize}\n    By \\nameref{thm:transitivity-subtyping} and \\nameref{thm:regularity}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\sigma'}{\\alpha}{s}}{\\tau}$,\n      \\item $\\type{\\Phi; \\Gamma}{\\subst{\\sigma'}{\\alpha}{s}}{U_1}$, and\n      \\item $\\type{\\Phi; \\Gamma}{\\tau}{U_2}$.\n    \\end{itemize}\n    By \\rref{conv}, both $\\subst{\\sigma'}{\\alpha}{s}$ and $\\tau$ have type $\\rules{U_1}{U_2}$.\n    Finally, by \\rref{conv} again, we have $\\type{\\Phi; \\Gamma}{\\subst{e}{\\alpha}{s}}{\\tau}$.\n  \\item \\rref*{red-cong}.\n    All of the cases for the congruence rules are similar to one another.\n    I cover only the case for reduction of the bound expression in a $\\kw{let}$ expression,\n    which requires careful handling of definitions in the environment.\n    \\begin{mathpar}\n    \\inferrule{\n      \\red{\\Phi; \\Gamma}{e_1}{e'_1}\n    }{\n      \\red{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\letin{x}{\\sigma}{e'_1}{e_2}}\n    }\n    \\end{mathpar}\n    By inversion on \\rref{let}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\sigma}{U}$,\n      \\item $\\type{\\Phi; \\Gamma}{e_1}{\\sigma}$, and\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e_1}}{e_2}{\\tau'}$, and\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e_1}}{\\tau}$.\n    \\end{itemize}\n    By the induction hypothesis, we have $\\type{\\Phi; \\Gamma}{e'_1}{\\sigma}$.\n    By \\nameref{lem:replacement-reduction},\n    we have $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e'_1}}{e_2}{\\tau'}$.\n    By \\rref{let}, we have $\\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e'_1}{e_2}}{\\subst{\\tau'}{x}{e'_1}}$.\n    By \\nameref{lem:congruence},\n    we have $\\red*{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e_1}}{\\subst{\\tau'}{x}{e'_1}}$.\n    Then by \\rref{red*-refl, acum-refl, subtype-red}, \\nameref{thm:transitivity-subtyping},\n    we have $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e'_1}}{\\tau}$.\n    Finally, by \\rref{conv}, we have $\\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e'_1}{e_2}}{\\tau}$.\n  \\item[\\textbf{Cases}] \\textbf{remaining}.\n    All similar to the case for $\\beta$-reduction for application of bounded sizes. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}[Subject reduction] \\label{thm:subject-reduction}\nIf $\\type{\\Phi; \\Gamma}{e}{\\tau}$ and $\\red*{\\Phi; \\Gamma}{e}{e'}$ then $\\type{\\Phi; \\Gamma}{e'}{\\tau}$.\n\\end{theorem}\n\n\\begin{proof}\nBy induction on the derivation of $\\red*{\\Phi; \\Gamma}{e}{e'}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{red*-once}. By \\cref{lem:sr}.\n  \\item \\rref*{red*-refl}. Trivial.\n  \\item \\rref*{red*-trans}. By the induction hypothesis on the first premise we have\n    $\\type{\\Phi; \\Gamma}{e_2}{\\tau}$;\n    by the induction hypothesis again on the second premise we have\n    $\\type{\\Phi; \\Gamma}{e_3}{\\tau}$. \\qedhere\n  \\iffalse\n  \\item \\rref*{red*-cong}. The various congruence cases are all similar to one another;\n    I cover only the case of \\rref*{let} as example.\n    \\begin{mathpar}\n      \\inferrule{\n        \\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma'} \\\\\n        \\red*{\\Phi; \\Gamma}{e_1}{e'_1} \\\\\n        \\red*{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{e_2}{e'_2}\n      }{\n        \\red*{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\letin{x}{\\sigma'}{e'_1}{e'_2}}\n      }\n    \\end{mathpar}\n    By \\nameref{thm:inversion} on \\rref{let}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\sigma}{U}$,\n      \\item $\\type{\\Phi; \\Gamma}{e_1}{\\sigma}$,\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e_1}}{e_2}{\\tau'}$, and\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e_1}}{\\tau}$.\n    \\end{itemize}\n    By \\rref{red*-refl, red*-cong, acum-refl, subtype-red} and\n    \\nameref{thm:transitivity-subtyping}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\subtype{\\Phi; \\Gamma}{\\sigma'}{\\sigma}$,\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e'_1}}{\\subst{\\tau'}{x}{e_1}}$, and\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e'_1}}{\\tau}$.\n    \\end{itemize}\n    Then by \\nameref{lem:replacement-subtyping} and by \\nameref{lem:replacement-reduction},\n    we have $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{e_2}{\\tau'}$.\n    The induction hypotheses then give\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\sigma'}{U}$,\n      \\item $\\type{\\Phi; \\Gamma}{e'_1}{\\sigma}$, and\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{e'_2}{\\tau'}$.\n    \\end{itemize}\n    By \\nameref{thm:regularity} and \\nameref{lem:substitutivity-terms}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\tau}{U_1}$,\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{\\tau'}{U_2}$, and\n      \\item $\\type{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e'_1}}{U_2}$.\n    \\end{itemize}\n    By \\rref{conv}, both $\\tau$ and $\\subst{\\tau'}{x}{e'_1}$ have type $\\rules{U_1}{U_2}$.\n    Finally, by \\rref{let} and by \\rref{conv} again,\n    we have $\\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma'}{e'_1}{e'_2}}{\\tau}$.\n  \\fi\n\\end{itemize}\n\\end{proof}\n\n\\section{Metatheory of \\CICE}\n\nFewer metatheoretical properties of \\CICE are required for the type preservation proof,\nnamely replacement\\index{replacement},\nsubstitutivity\\index{substitutivity},\nthe inversion principles\\index{inversion},\nand subject equivalence\\index{subject reduction}.\nI don't provide the proofs here, as the properties of CIC,\ntyped equivalence, and equality reflection are well established,\nand they're similar to the proofs for the analogous lemmas for \\lang.\n\n\\begin{lemma}[Replacement by subtyping] \\label{lem:replacement-subtyping*}\nSuppose $\\subtype{\\GammaT_1}{\\sigmaT_1}{\\sigmaT_2}$ where $\\type{\\GammaT_1}{\\sigmaT_1}{U}$ and $\\type{\\GammaT_1}{\\sigmaT_2}{U}$\nfor some $U$.\n\\begin{itemize}[noitemsep]\n  \\item If $\\type{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_2}, \\GammaT_2}{\\eT}{\\tauT}$ then $\\type{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_1}, \\GammaT_2}{\\eT}{\\tauT}$.\n  \\item If $\\subtype{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_2}, \\GammaT_2}{\\tauT_1}{\\tauT_2}$ then $\\subtype{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_1}, \\GammaT_2}{\\tauT_1}{\\tauT_2}$.\n  \\item If $\\defeq{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_2}, \\GammaT_2}{\\eT_1}{\\eT_2}{\\tauT}$ then $\\defeq{\\GammaT_1, \\annotT{\\xT}{\\sigmaT_1}, \\GammaT_2}{\\eT_1}{\\eT_2}{\\tauT}$.\n\\end{itemize}\nFurthermore, the above also applies when the environment contains $\\defineT{\\xT}{\\sigmaT_2}{\\eT}$\nrather than $\\annotT{\\xT}{\\sigmaT_2}$.\n\\end{lemma}\n\n\\begin{lemma}[Replacement by equivalence] \\label{lem:replacement-equivalence}\nSuppose $\\defeq{\\GammaT_1}{\\eT_1}{\\eT_2}{\\tauT'}$.\n\\begin{itemize}[noitemsep]\n  \\item If $\\type{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_1}, \\GammaT_2}{\\eT}{\\tauT}$ then $\\type{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_2}, \\GammaT_2}{\\eT}{\\tauT}$.\n  \\item If $\\subtype{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_1}, \\GammaT_2}{\\tauT_1}{\\tauT_2}$ then $\\subtype{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_2}, \\GammaT_2}{\\tauT_1}{\\tauT_2}$.\n  \\item If $\\defeq{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_1}, \\GammaT_2}{\\eT_3}{\\eT_4}{\\tauT}$ then $\\defeq{\\GammaT_1, \\defineT{\\xT}{\\sigmaT}{\\eT_2}, \\GammaT_2}{\\eT_3}{\\eT_4}{\\tauT}$.\n\\end{itemize}\n\\end{lemma}\n\n\\begin{lemma}[Substitutivity]\nSuppose $\\type{\\GammaT_1}{\\eT}{\\sigmaT}$.\n\\begin{itemize}[noitemsep]\n  \\item If $\\type{\\GammaT_1, \\annotT{\\xT}{\\sigmaT}, \\GammaT_2}{\\eT'}{\\tauT}$ then $\\type{\\GammaT_1, \\subst{\\GammaT_2}{\\xT}{\\eT}}{\\subst{\\eT'}{\\xT}{\\eT}}{\\subst{\\xT}{\\tauT}{\\eT}}$.\n  \\item If $\\subtype{\\GammaT_1, \\annotT{\\xT}{\\sigmaT}, \\GammaT_2}{\\tauT_1}{\\tauT_2}$ then $\\type{\\GammaT_1, \\subst{\\GammaT_2}{\\xT}{\\eT}}{\\subst{\\tauT_1}{\\xT}{\\eT}}{\\subst{\\tauT_2}{\\tauT}{\\eT}}$.\n  \\item If $\\defeq{\\GammaT_1, \\annotT{\\xT}{\\sigmaT}, \\GammaT_2}{\\eT_1}{\\eT_2}{\\tauT}$ then $\\defeq{\\GammaT_1, \\subst{\\GammaT_2}{\\xT}{\\eT}}{\\subst{\\eT_1}{\\xT}{\\eT}}{\\subst{\\eT_2}{\\tauT}{\\eT}}{\\subst{\\tauT}{\\xT}{\\eT}}$.\n\\end{itemize}\nFurthermore, the above also applies when the environment contains $\\defineT{\\xT}{\\sigmaT}{\\eT}$\nrather than $\\annotT{\\xT}{\\sigmaT}$.\n\\end{lemma}\n\n\\begin{theorem}[Inversion]\nGiven a syntactic form $\\eT$ and a typing rule $\\mathcal{R} \\neq \\text{\\upshape \\rref*{conv*}}$ for that form,\nif $\\mathcal{D}$ is a derivation ending in $\\type{\\GammaT}{\\eT}{\\tauT}$\nand $\\mathcal{J}_i$ are the judgement forms in the premises of $\\mathcal{R}$,\nthen there exist derivations $\\mathcal{D}_i$ ending in $\\mathcal{J}_i$\nsuch that $\\mathcal{R}$ builds a derivation ending in $\\type{\\GammaT}{\\eT}{\\sigmaT}$,\nand $\\subtype{\\GammaT}{\\sigmaT}{\\tauT}$ holds.\n\\end{theorem}\n\n\\iffalse\n\\begin{proof}\nBy induction on the derivation of $\\type{\\GammaT}{\\eT}{\\tauT}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\mathcal{R}$. The premises of the derivation are the desired ones,\n    building a derivation ending in $\\type{\\GammaT}{\\eT}{\\tauT}$,\n    and $\\subtype{\\GammaT}{\\tauT}{\\tauT}$ holds by well-typedness of $\\tauT$,\n    \\rref{equiv-refl}, and \\rref{subtype-conv}.\n  \\item \\rref*{conv*}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\type{\\GammaT}{\\eT}{\\sigmaT} \\\\\n      \\type{\\GammaT}{\\sigmaT}{\\UT} \\\\\n      \\type{\\GammaT}{\\tauT}{\\UT} \\\\\n      \\subtype{\\GammaT}{\\sigmaT}{\\tauT}\n    }{\n      \\type{\\GammaT}{\\eT}{\\tauT}\n    }\n    \\end{mathpar}\n    Induction hypothesis: there are derivations $\\mathcal{D}_i$ ending in $\\mathcal{J}_i$\n    such that $\\mathcal{R}$ builds a derivation ending in $\\type{\\GammaT}{\\eT}{\\sigmaT'}$\n    and $\\subtype{\\GammaT}{\\sigmaT'}{\\sigmaT}$ holds. \\\\\n    The desired derivations are $\\mathcal{D}_i$, and $\\subtype{\\GammaT}{\\sigmaT'}{\\tauT}$\n    holds by \\rref{subtype-trans}.\n\\end{itemize}\n\\end{proof}\n\\fi\n\n\\begin{theorem}[Subject equivalence] \\label{thm:subject-equivalence}\nIf $\\defeq{\\GammaT}{\\eT_1}{\\eT_2}{\\tauT}$\nthen $\\type{\\GammaT}{\\eT_1}{\\tauT}$ and $\\type{\\GammaT}{\\eT_2}{\\tauT}$.\n\\end{theorem}\n\nFor completeness I restate the consistency of \\CICE, again as a postulate.\n\n\\begin{postulate}[Consistency]\nThere exists no term $\\eT$ such that\n$\\type{\\mt}{\\eT}{\\funtypeT{\\PT}{\\PropT}{\\PT}}$.\n\\end{postulate}\n\n\\section{Proof of Type Preservation}\n\nAs was outlined in \\cref{sec:syntactic-model},\nthe proof of type preservation involves an additional five lemmas\ndemonstrating that the translation respects substitution, reduction,\n$\\alpha$-cumulativity, the closure of reduction, subtyping, and typing itself.\nThese lemmas require further sublemmas;\nthe subsequent subsections group the sublemmas with their lemma or theorem.\n\nMany of these lemmas use the translation of terms $e$ and term environments $\\Gamma$\nusing the shorthand $\\compile{e}$ and $\\compile{\\Gamma}$,\nomitting environment extensions for concision.\nIf not specified, the well-formedness of $\\Gamma$ and well-typedness of $e$\nneeded for the translations are derived when possible\n(\\eg $\\wf{\\Phi}{\\Gamma}$ and $\\type{\\Phi; \\Gamma}{\\tau}{U}$ from $\\type{\\Phi; \\Gamma}{e}{\\tau}$\nby \\cref{lem:wf-env} and \\nameref{thm:regularity}, respectively)\nand otherwise assumed as hypotheses.\n\n\\subsection{Compositionality}\n\nCompositionality\\index{compositionality} is the key to proving preservation of reduction in the next section,\nsince reduction rules are defined in terms of substitution.\nIn essence, we need to show that the translation commutes with substitution,\nso that translating a term with a substitution is the same as\ntranslating both terms and then applying the substitution.\nSince there are three different forms of substitution\n(substituting a term variable for a term,\na bounded size variable for a size,\nand an unbounded size variable for a size),\nwe need to handle each separately,\nand we end up with three individual compositionality lemmas.\n\n\\begin{sublemma} \\label{sublem:subsize-FV}\nIf $\\subsizeto{\\Phi}{s_1}{s_2}{\\eT}$ and $x$ is a term variable\nthen $\\xT \\notin \\FV{\\eT}$.\n\\end{sublemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\subsizeto{\\Phi}{s_1}{s_2}{\\eT}$.\nIntuitively, the only variables resulting from translating a size expression\nor a subsizing judgement are size variables $\\alphaT$ or fresh variables $\\alpha^*$,\nso they couldn't contain any translated term variables.\n\\end{proof}\n\n\\begin{lemma}[Term compositionality] \\label{lem:term-compositionality}\nIf $\\type{\\Phi; \\Gamma_1, \\annot{x}{\\tau'}, \\Gamma_2}{e}{\\tau}$\nand $\\type{\\Phi; \\Gamma_1}{e'}{\\tau'}$ then\n$\\subst{\\compile{e}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e}{x}{e'}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Phi; \\Gamma}{e}{\\tau}$,\nwhere $\\Gamma = \\Gamma_1, \\annot{x}{\\tau'}, \\Gamma_2$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{conv}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\dots \\\\\n      \\type{\\Phi; \\Gamma}{e}{\\sigma} \\\\\n      \\subtype{\\Phi; \\Gamma}{\\sigma}{\\tau} \\\\\n    }{\n      \\type{\\Phi; \\Gamma}{e}{\\tau}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $\\subst{\\compile{e}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e}{x}{e'}}$. \\\\\n    Trivial by the induction hypothesis.\n  \\item \\rref*{var}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\wf{\\Phi}{\\Gamma} \\\\\n      (\\annot{y}{\\tau}) \\in \\Gamma\n    }{\n      \\type{\\Phi; \\Gamma}{y}{\\tau}\n    }\n    \\end{mathpar}\n    If $x = y$, then $\\subst{\\xT}{\\xT}{\\compile{e'}} = \\compile{e'} = \\compile{\\subst{x}{x}{e'}}$. \\\\\n    If $x \\neq y$, then $\\subst{\\yT}{\\xT}{\\compile{e'}} = \\yT = \\compile{\\subst{y}{x}{e'}}$.\n  \\item[\\textbf{Cases}] \\rref*{univ}, \\rref*{nat}. Trivial.\n  \\item[\\textbf{Cases}] \\rref*{pi}, \\rref*{lam}, \\rref*{app}, \\rref*{let}, \\rref*{forall}, \\rref*{slam}, \\rref*{sapp}, \\rref*{forall<}, \\rref*{slam<}, \\rref*{wft}, \\rref*{case-nat}, \\rref*{case-wft}.\n    Straightforward by the induction hypotheses.\n    As example, I prove only the case for \\rref*{case-wft}.\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi; \\Gamma}{e}{\\W{y}{\\sigma}{\\tau}{s}} \\\\\n      z_1, z_2 \\notin \\FV{P} \\\\\n      \\infer{\\Phi; \\Gamma, \\annot{w}{\\W{y}{\\sigma}{\\tau}{s}}}{P}{U} \\\\\n      \\check{\\Phi, \\bound{\\alpha}{s}; \\Gamma, \\annot{z_1}{\\sigma}, \\annot{z_2}{\\arr*{\\subst{\\tau}{y}{z_1}}{\\W{y}{\\tau}{\\sigma}{\\alpha}}}}{e_s}{\\subst{P}{w}{\\sup{y}{\\sigma}{\\tau}{s}{\\alpha}{z_1}{z_2}}}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\match{e}{\\fun*{w}{P}}{(\\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow e_s)}}{\\subst{P}{w}{e}}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\subst{\\compile{e}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e}{x}{e'}}$,\n      \\item $\\subst{\\compile{P}}{\\xT}{\\compile{e'}} = \\compile{\\subst{P}{x}{e'}}$, and\n      \\item $\\subst{\\compile{e_s}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e_s}{x}{e'}}$.\n    \\end{itemize}\n    Suppose first that $x \\neq w$, $x \\neq z_1$, and $x \\neq z_2$.\n    Then we have\n    \\begin{align*}\n    &\\subst{\\compile{\\match{e}{\\fun*{w}{P}}{(\\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow e_s)}}}{\\xT}{\\compile{e'}} \\\\\n    &= \\subst{(\\matchT{\\compile{e}}{\\funT*{\\mt}{\\wT}{\\compile{P}}}{(\\app{\\supT}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2} \\RightarrowT \\compile{e_s})})}{\\xT}{\\compile{e'}} && \\textit{by translation} \\\\\n    &= \\matchT{\\subst{\\compile{e}}{\\xT}{\\compile{e'}}}{\\funT*{\\mt}{\\wT}{\\subst{\\compile{P}}{\\xT}{\\compile{e'}}}}{\\\\ & \\quad \\qquad \\app{\\supT}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2} \\RightarrowT \\subst{\\compile{e_s}}{\\xT}{\\compile{e'}}} && \\textit{by substitution} \\\\\n    &= \\matchT{\\compile{\\subst{e}{x}{e'}}}{\\funT*{\\mt}{\\wT}{\\compile{\\subst{P}{x}{e'}}}}{\\\\ & \\quad \\qquad \\app{\\supT}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2} \\RightarrowT \\compile{\\subst{e_s}{x}{e'}}} && \\textit{by IHs} \\\\\n    &= \\compile{\\match{\\subst{e}{x}{e'}}{\\fun*{w}{\\subst{P}{x}{e'}}}{(\\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow \\subst{e_s}{x}{e'})}} && \\textit{by translation} \\\\\n    &= \\compile{\\subst{\\match{e}{\\fun*{w}{P}}{(\\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow e_s)}}{x}{e'}} && \\textit{by substitution}.\n    \\end{align*}\n    If $x$ is any of the binders $w, z_1, z_2$,\n    then neither substitution of the subterms in \\lang nor in \\CICE would occur,\n    giving the exact same equality.\n  \\item[\\textbf{Cases}] \\rref*{sapp<}, \\rref*{zero}, \\rref*{succ}, \\rref*{sup}.\n    Similar to the above, but with an additional term generated from translating subsizing judgements to deal with.\n    I prove only the case for \\rref*{sapp<} as example.\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi; \\Gamma}{e}{\\Funtype<{\\alpha}{r}{\\tau}} \\\\\n      \\subsize{\\Phi}{\\sss{s}}{r}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\App{e}{s}}{\\subst{\\tau}{\\alpha}{s}}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $\\subst{\\compile{e}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e}{x}{e'}}$. \\\\\n    By the translation, we have $\\subsizeto{\\Phi}{\\sss{s}}{r}{\\eT''}$.\n    Then we have\n    \\begin{align*}\n    \\subst{\\compile{\\App{e}{s}}}{\\xT}{\\compile{e'}}\n    &= \\subst{(\\app{\\compile{e}}{\\compile{s}}{\\eT''})}{\\xT}{\\compile{e'}} && \\textit{by translation} \\\\\n    &= \\app{(\\subst{\\compile{e}}{\\xT}{\\compile{e'}})}{\\compile{s}}{(\\subst{\\eT''}{\\xT}{\\compile{e'}})} && \\textit{by substitution} \\\\\n    &= \\app{(\\subst{\\compile{e}}{\\xT}{\\compile{e'}})}{\\compile{s}}{\\eT''} && \\textit{by \\cref{sublem:subsize-FV}} \\\\\n    &= \\app{\\compile{\\subst{e}{x}{e'}}}{\\compile{s}}{\\eT''} && \\textit{by IH} \\\\\n    &= \\compile{\\App{\\subst{e}{x}{e'}}{s}} && \\textit{by translation} \\\\\n    &= \\compile{\\subst{\\App{e}{s}}{x}{e'}} && \\textit{by substitution},\n    \\end{align*}\n    noting that substitution of a term variable in the translation of a size expression\n    has no effect since they produce no term variables.\n  \\item \\rref*{fix}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\dots \\\\\n      \\infer{\\Phi, \\alpha; \\Gamma}{\\sigma}{U} \\\\\n      \\check{\\Phi, \\alpha; \\Gamma, \\annot{f}{\\Funtype<{\\beta}{\\alpha}{\\subst{\\sigma}{\\alpha}{\\beta}}}}{e}{\\sigma}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\fix{f}{\\alpha}{\\sigma}{e}}{\\Funtype{\\alpha}{\\sigma}}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\subst{\\compile{\\sigma}}{\\xT}{\\compile{e'}} = \\compile{\\subst{\\sigma}{x}{e'}}$ and\n      \\item $\\subst{\\compile{e}}{\\xT}{\\compile{e'}} = \\compile{\\subst{e}{x}{e'}}$.\n    \\end{itemize}\n    We then have\n    \\allowdisplaybreaks\n    \\begin{align*}\n    &\\subst{\\compile{\\fix{f}{\\alpha}{\\sigma}{e}}}{\\xT}{\\compile{e'}} \\\\\n    &= \\subst{(\\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}{\\compile{e}}})})}{\\xT}{e'} \\\\\n    & \\quad \\textit{by translation} \\\\\n    &= \\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\subst{\\compile{\\sigma}}{\\xT}{\\compile{e'}}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\xT, \\alphaT}{\\compile{e'}, \\betaT}}}}{\\subst{\\compile{e}}{\\xT}{\\compile{e'}}}})} \\\\\n    & \\quad \\textit{by substitution} \\\\\n    &= \\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\subst{\\sigma}{x}{e'}}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\subst{\\sigma}{x}{e'}}}{\\alphaT}{\\betaT}}}}{\\compile{\\subst{e}{x}{e'}}}})} \\\\\n    & \\quad \\textit{by IHs} \\\\\n    &= \\compile{\\fix{f}{\\alpha}{\\subst{\\sigma}{x}{e'}}{\\subst{e}{x}{e'}}} \\quad \\textit{by translation} \\\\\n    &= \\compile{\\subst{\\fix{f}{\\alpha}{\\sigma}{e}}{x}{e'}} \\quad \\textit{by substitution}.\n    \\end{align*}\n    Substitution of $x$ has no effect on $\\wfind$ since it's defined independently of the translation\n    and has no variables originating from the source expression. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\iffalse % this isn't used anywhere??\n\\begin{corollary}[Term environment compositionality]\nIf $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\tau}, \\Gamma_2}$ and $\\type{\\Phi; \\Gamma_1}{e}{\\tau}$\nthen $\\compile{\\Gamma_1}, \\subst{\\compile{\\Gamma_2}}{\\xT}{\\compile{e}} = \\compile{\\Gamma_1, \\subst{\\Gamma_2}{x}{e}}$\nby induction on $\\wf{\\Phi}{\\Gamma_1, \\annot{x}{\\tau}, \\Gamma_2}$\nusing \\nameref{lem:term-compositionality}.\n\\end{corollary}\n\\fi\n\nIn addition to compositionality when substituting terms,\nwe also need compositionality when substitution sizes.\nThis is not as simple when substituting bounded sizes into terms,\nsince a single substitution in the source\nwould correspond to two substitutions in the target,\nthe second being a term exhibiting boundedness,\nbut the proofs have the same structure.\n\n\\begin{sublemma}\\label{sublem:compos-size}\n$\\subst{\\compile{s}}{\\alphaT}{\\compile{r}} = \\compile{\\subst{s}{\\alpha}{r}}$.\n\\end{sublemma}\n\n\\begin{proof}\nBy induction on the structure of $s$.\n\\end{proof}\n\n\\begin{sublemma} \\label{sublem:compos-subsize-bounded}\nIf $\\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s}{r}{\\eT}$\nand $\\subsizeto{\\Phi_1}{\\sss{s}'}{r'}{\\eT'}$\nthen $\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s}{\\alpha}{s'}}{\\subst{r}{\\alpha}{s'}}{\\subst{\\eT}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}$.\n\\end{sublemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s}{r}{\\eT}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\subsize*{\\sss{\\beta}}{s}$.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule[]{\n      (\\bound{\\beta}{s}) \\in \\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2\n    }{\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{\\sss{\\beta}}{s}{\\betaT^*}\n    }\n    \\end{mathpar}\n    If $\\beta = \\alpha$, then $\\betaT^* = \\alphaT^*$ and $s = r'$, and the goal holds by\n    $\\subsizeto{\\Phi_1}{\\sss{s}'}{r'}{\\eT'}$.\n    If $\\beta \\neq \\alpha$ and $\\bound{\\beta}{s} \\in \\Phi_1$,\n    then $\\alpha \\notin \\FV{s}$ and $\\bound{\\beta}{s} \\in \\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}$,\n    so we have the following.\n    \\begin{mathpar}\n    \\inferrule{\n      \\bound{\\beta}{s} \\in \\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}\n    }{\n      \\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}}{\\sss{\\beta}}{s}{\\betaT^*}\n    }\n    \\end{mathpar}\n    Otherwise, if $\\bound{\\beta}{s} \\in \\Phi_2$,\n    then $\\bound{\\beta}{\\subst{s}{\\alpha}{r'}} \\in \\Phi_1, \\subst{\\Phi_2}{\\alpha}{r'}$,\n    and we have the following.\n    \\begin{mathpar}\n    \\inferrule[]{\n      (\\bound{\\beta}{\\subst{s}{\\alpha}{s'}}) \\in \\Phi_1, \\subst{\\Phi_2}{\\alpha}{r'}\n    }{\n      \\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{r'}}{\\sss{\\beta}}{\\subst{s}{\\alpha}{s'}}{\\betaT^*}\n    }\n    \\end{mathpar}\n  \\item[\\textbf{Cases}] $\\subsize*{\\circ}{s}$, $\\subsize*{s}{s}$, $\\subsize*{s}{\\sss{s}}$.\n    By \\cref{sublem:compos-size}, noting that the fresh variable $\\alphaT^*$\n    never appears in the translation of a size expression.\n  \\item $\\subsize*{\\sss{s}}{\\sss{r}}$.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s}{r}{\\eT}\n    }{\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{\\sss{s}}{\\sss{r}}{\\app{\\monoT}{\\compile{s}}{\\compile{r}}{\\eT}}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $$\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s}{\\alpha}{s'}}{\\subst{r}{\\alpha}{s'}}{\\subst{\\eT}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}.$$\n    By the same rule, we can derive\n    \\begin{align*}\n      &\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{\\sss{s}}{\\alpha}{s'}}{\\subst{\\sss{r}}{\\alpha}{s'}}\n      {\\\\ & \\qquad \\app{\\monoT}{\\compile{\\subst{s}{\\alpha}{s'}}}{\\compile{\\subst{r}{\\alpha}{s'}}}{(\\subst{\\eT}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}}.\n    \\end{align*}\n    By \\cref{sublem:compos-size}, again noting that $\\alphaT^*$ never appears in $\\compile{s}$ or $\\compile{r}$,\n    this becomes\n    \\begin{align*}\n      &\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{\\sss{s}}{\\alpha}{s'}}{\\subst{\\sss{r}}{\\alpha}{s'}}\n      {\\\\ & \\qquad \\app{\\monoT}{\\subst{\\compile{s}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}{\\subst{\\compile{r}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}{(\\subst{\\eT}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}}.\n    \\end{align*}\n    By substitution, the result of translation above is exactly $\\subst{(\\app{\\monoT}{\\compile{s}}{\\compile{r}}{\\eT})}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}$,\n    as desired.\n  \\item \\textbf{for transitivity}.\n    \\begin{mathpar}\n    \\inferrule{\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s_1}{s_2}{\\eT_{12}} \\\\\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s_2}{s_3}{\\eT_{23}}\n    }{\n      \\subsizeto{\\Phi_1, \\bound{\\alpha}{r'}, \\Phi_2}{s_1}{s_3}{\\app{\\transleq}{\\compile{s_1}}{\\compile{s_2}}{\\compile{s_3}}{\\eT_{12}}{\\eT_{23}}}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s_1}{\\alpha}{s'}}{\\subst{s_2}{\\alpha}{s'}}{\\subst{\\eT_{12}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}$ and\n      \\item $\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s_2}{\\alpha}{s'}}{\\subst{s_3}{\\alpha}{s'}}{\\subst{\\eT_{23}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}$.\n    \\end{itemize}\n    By the same rule, we can derive\n    \\begin{align*}\n    &\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s_1}{\\alpha}{s'}}{\\subst{s_3}{\\alpha}{s'}}\n    {\\\\ & \\qquad \\app{\\transleq}{\\compile{\\subst{s_1}{\\alpha}{s'}}}{\\compile{\\subst{s_2}{\\alpha}{s'}}}{\\compile{\\subst{s_3}{\\alpha}{s'}}}\n    {\\\\ & \\qquad \\phantom{\\app{\\transleq}{}} (\\subst{\\eT_{12}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}{(\\subst{\\eT_{23}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}}\n    \\end{align*}\n    By \\cref{sublem:compos-size}, again noting that $\\alphaT^*$ never appears in\n    $\\compile{s_1}$, $\\compile{s_2}$, or $\\compile{s_3}$, this becomes\n    \\begin{align*}\n    &\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s_1}{\\alpha}{s'}}{\\subst{s_3}{\\alpha}{s'}}\n    {\\\\ & \\qquad \\app{\\transleq}{\\subst{\\compile{s_1}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}{\\subst{\\compile{s_2}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}{\\subst{\\compile{s_3}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'}}\n    {\\\\ & \\qquad \\phantom{\\app{\\transleq}{}} (\\subst{\\eT_{12}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}{(\\subst{\\eT_{23}}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'})}}\n    \\end{align*}\n    By substitution, the result of translation above is exactly\n    $$\\subst{(\\app{\\transleq}{\\compile{s_1}}{\\compile{s_2}}{\\compile{s_3}}{\\eT_{12}}{\\eT_{23}})}{\\alphaT, \\alphaT^*}{\\compile{s'}, \\eT'},$$\n    as desired. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{sublemma} \\label{sublem:compos-subsize-unbounded}\nIf $\\subsizeto{\\Phi_1, \\alpha, \\Phi_2}{s}{r}{\\eT}$ and $\\wf{\\Phi_1}{s'}$ then\n$\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s'}}{\\subst{s}{\\alpha}{s'}}{\\subst{r}{\\alpha}{s'}}{\\subst{\\eT}{\\alphaT}{\\compile{s'}}}$.\n\\end{sublemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\subsizeto{\\Phi_1, \\alpha, \\Phi_2}{s}{r}{\\eT}$.\nThe proof structure follows that of \\cref{sublem:compos-subsize-bounded}.\n\\end{proof}\n\nJust as compositionality for subsizing is split into substitution of bounded and unbounded sizes,\nso is size compositionality with respect to terms.\nOf note is that the right-hand side only has a single substitution,\nwhile the left-hand side has two,\nsince the proof $\\eT'$ now needs to be handled explicitly.\n\n\\begin{lemma}[Size compositionality (bounded)] \\label{lem:compos-size-bounded}\nIf $\\type{\\Phi_1, \\bound{\\alpha}{r}, \\Phi_2; \\Gamma}{e}{\\tau}$\nand $\\subsizeto{\\Phi_1}{\\sss{s}}{r}{\\eT'}$ then\n$\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e}{\\alpha}{s}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Phi; \\Gamma}{e}{\\tau}$,\nwhere $\\Phi = \\Phi_1, \\bound{\\alpha}{r}, \\Phi_2$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{conv}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\dots \\\\\n        \\type{\\Phi; \\Gamma}{e}{\\sigma} \\\\\n        \\subtype{\\Phi; \\Gamma}{\\sigma}{\\tau}\n      }{\n        \\type{\\Phi; \\Gamma}{e}{\\tau}\n      }\n    \\end{mathpar}\n      Induction hypothesis: $\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e}{\\alpha}{s}}$.\n      Trivial by the induction hypothesis.\n  \\item[\\textbf{Cases}] \\rref*{var}, \\rref*{univ}. Trivial.\n  \\item[\\textbf{Cases}] \\rref*{pi}, \\rref*{lam}, \\rref*{app}, \\rref*{let}.\n    Straightforward by the induction hypotheses.\n    As example, I prove only the case for \\rref*{let}.\n    \\begin{mathpar}\n      \\inferrule{\n        \\type{\\Phi; \\Gamma}{\\sigma}{U} \\\\\n        \\type{\\Phi; \\Gamma}{e_1}{\\sigma} \\\\\n        \\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e_1}}{e_2}{\\tau} \\\\\n      }{\n        \\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\subst{\\tau}{x}{e_1}}\n      }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\subst{\\compile{\\sigma}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{\\sigma}{\\alpha}{s}}$,\n      \\item $\\subst{\\compile{e_1}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e_1}{\\alpha}{s}}$, and\n      \\item $\\subst{\\compile{e_2}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e_2}{\\alpha}{s}}$.\n    \\end{itemize}\n    Then we have\n    \\begin{align*}\n    &\\subst{\\compile{\\letin{x}{\\sigma}{e_1}{e_2}}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    &= \\subst{(\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}})}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    & \\quad \\textit{by translation} \\\\\n    &= \\letinT{\\xT}{\\subst{\\compile{\\sigma}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}{\\subst{\\compile{e_1}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}{\\subst{\\compile{e_2}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}} \\\\\n    & \\quad \\textit{by substitution} \\\\\n    &= \\letinT{\\xT}{\\compile{\\subst{\\sigma}{\\alpha}{s}}}{\\compile{\\subst{e_1}{\\alpha}{s}}}{\\compile{\\subst{e_2}{\\alpha}{s}}} \\\\\n    & \\quad \\textit{by IHs} \\\\\n    &= \\compile{\\letin{x}{\\subst{\\sigma}{\\alpha}{s}}{\\subst{e_1}{\\alpha}{s}}{\\subst{e_2}{\\alpha}{s}}} \\\\\n    & \\quad \\textit{by translation} \\\\\n    &= \\compile{\\subst{(\\letin{x}{\\sigma}{e_1}{e_2})}{\\alpha}{s}} \\\\\n    & \\quad \\textit{by substitution}.\n    \\end{align*}\n  \\item[\\textbf{Cases}] \\rref*{forall}, \\rref*{slam}, \\rref*{case-nat}, \\rref*{case-wft}.\n    Similar to the above, taking care to handle shadowing.\n    I prove only the case for \\rref*{forall} as example.\n    \\begin{mathpar}\n      \\inferrule{\n        \\type{\\Phi, \\beta; \\Gamma}{\\tau}{U}\n      }{\n        \\type{\\Phi; \\Gamma}{\\Funtype{\\beta}{\\tau}}{U}\n      }\n    \\end{mathpar}\n    Induction hypothesis: $\\subst{\\compile{\\tau}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{\\tau}{\\alpha}{s}}$. \\\\\n    Suppose first that $\\alpha \\neq \\beta$. Then we have\n    \\begin{align*}\n    \\subst{\\compile{\\Funtype{\\beta}{\\tau}}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}\n    &= \\subst{(\\funtypeT{\\betaT}{\\SizeT}{\\compile{\\tau}})}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}\n    && \\textit{by translation} \\\\\n    &= \\funtypeT{\\betaT}{\\SizeT}{\\subst{\\compile{\\tau}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}\n    && \\textit{by substitution} \\\\\n    &= \\funtypeT{\\betaT}{\\SizeT}{\\compile{\\subst{\\tau}{\\alpha}{s}}}\n    && \\textit{by IH} \\\\\n    &= \\compile{\\Funtype{\\beta}{\\subst{\\tau}{\\alpha}{s}}}\n    && \\textit{by translation} \\\\\n    &= \\compile{\\subst{(\\Funtype{\\beta}{\\tau})}{\\alpha}{s}}\n    && \\textit{by substitution}.\n    \\end{align*}\n    If $\\alpha = \\beta$, then the substitutions would never occur, making the goal hold trivially.\n  \\item[\\textbf{Cases}] \\rref*{sapp}, \\rref*{forall<}, \\rref*{slam<}, \\rref*{nat}, \\rref*{wft}.\n    Similar to the above, additionally using \\cref{sublem:compos-size} when substituting into size expressions.\n    I prove only the case for \\rref*{slam<} as example.\n    \\begin{mathpar}\n      \\inferrule{\n        \\wf{\\Phi}{r} \\\\\n        \\type{\\Phi, \\bound{\\beta}{r}; \\Gamma}{e}{\\tau}\n      }{\n        \\type{\\Phi; \\Gamma}{\\Fun<{\\beta}{r}{e}}{\\Funtype<{\\beta}{r}{\\tau}}\n      }      \n    \\end{mathpar}\n    Induction hypothesis: $\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e}{\\alpha}{s}}$. \\\\\n    Then we have\n    \\begin{align*}\n    &\\subst{\\compile{\\Fun<{\\beta}{r}{e}}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    &= \\subst{(\\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{r}}{\\compile{e}}})}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}\n    && \\textit{by translation} \\\\\n    &= \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\subst{\\compile{r}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}{\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}}\n    && \\textit{by substitution} \\\\\n    &= \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{\\subst{r}{\\alpha}{s}}}{\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}}\n    && \\textit{by \\cref{sublem:compos-size}, $\\alphaT^* \\notin \\compile{r}$} \\\\\n    &= \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{\\subst{r}{\\alpha}{s}}}{\\compile{\\subst{e}{s}{\\alpha}}}}\n    && \\textit{by IH} \\\\\n    &= \\compile{\\Fun<{\\beta}{\\subst{r}{\\alpha}{s}}{\\subst{e}{\\alpha}{s}}}\n    && \\textit{by translation} \\\\\n    &= \\compile{\\subst{(\\Fun<{\\beta}{r}{e})}{\\alpha}{s}}\n    && \\textit{by substitition}.\n    \\end{align*}\n  \\item[\\textbf{Cases}] \\rref*{sapp<}, \\rref*{zero}, \\rref*{succ}, \\rref*{sup}.\n    In these cases, there are additional terms generated rom translation subsizing judgements;\n    here is where we use \\cref{sublem:compos-subsize-bounded}.\n    I prove only the case of \\rref*{sapp<} as example.\n    \\begin{mathpar}\n      \\inferrule{\n        \\type{\\Phi; \\Gamma}{e}{\\Funtype<{\\beta}{r'}{\\tau}} \\\\\n        \\subsize{\\Phi}{\\sss{r}}{r'}\n      }{\n        \\type{\\Phi; \\Gamma}{\\App{e}{r}}{\\subst{\\tau}{\\beta}{r}}\n      }\n    \\end{mathpar}\n    Induction hypothesis: $\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} = \\compile{\\subst{e}{\\alpha}{s}}$. \\\\\n    By the translation, we have $\\subsizeto{\\Phi; \\Gamma}{\\sss{r}}{r'}{\\eT''}$.\n    On the left-hand, side we have\n    \\begin{align*}\n    &\\subst{\\compile{\\App{e}{r}}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    &= \\subst{(\\app{\\compile{e}}{\\compile{r}}{\\eT''})}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}\n    && \\textit{by translation} \\\\\n    &= \\app{(\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}{(\\subst{\\compile{r}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}{(\\subst{\\eT''}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}\n    && \\textit{by substitution} \\\\\n    &= \\app{(\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}{\\compile{\\subst{r}{\\alpha}{s}}}{(\\subst{\\eT''}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}\n    && \\textit{by \\cref{sublem:compos-size}, $\\alpha^* \\notin \\compile{r}$} \\\\\n    &= \\app{\\compile{\\subst{e}{\\alpha}{s}}}{\\compile{\\subst{r}{\\alpha}{s}}}{(\\subst{\\eT''}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}\n    && \\textit{by IH}.\n    \\end{align*}\n    Meanwhile, on the right-hand size,\n    noting that $\\subsizeto{\\Phi_1, \\subst{\\Phi_2}{\\alpha}{s}; \\Gamma}{\\subst{\\sss{r}}{\\alpha}{s}}{\\subst{r'}{\\alpha}{s}}{\\subst{\\eT''}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}$\n    by \\cref{sublem:compos-subsize-bounded}, we have\n\n    \\begin{align*}\n    &\\compile{\\subst{\\App{e}{r}}{\\alpha}{s}} \\\\\n    &= \\compile{\\App{\\subst{e}{\\alpha}{s}}{\\subst{r}{\\alpha}{s}}}\n    && \\textit{by substitution} \\\\\n    &= \\app{\\compile{\\subst{e}{\\alpha}{s}}}{\\compile{\\subst{r}{\\alpha}{s}}}{(\\subst{\\eT''}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'})}\n    && \\textit{by translation and \\nameref{lem:substitutivity-bounded}}.\n    \\end{align*}\n  \\item \\rref*{fix}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n      \\inferrule{\n        \\dots \\\\\n        \\infer{\\Phi, \\alpha; \\Gamma}{\\sigma}{U} \\\\\n        \\check{\\Phi, \\beta; \\Gamma, \\annot{f}{\\Funtype<{\\gamma}{\\beta}{\\subst{\\sigma}{\\beta}{\\gamma}}}}{e}{\\sigma}\n      }{\n        \\infer{\\Phi; \\Gamma}{\\fix{f}{\\beta}{\\sigma}{e}}{\\Funtype{\\beta}{\\sigma}}\n      }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\subst{\\compile{\\sigma}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}$ and\n      \\item $\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}$.\n    \\end{itemize}\n    Supposing that $\\alpha \\neq \\beta$, we then have\n    \\allowdisplaybreaks\n    \\begin{align*}\n    &\\subst{\\compile{\\fix{f}{\\beta}{\\sigma}{e}}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    &= \\subst{(\\app{\\wfind}{(\\funT{\\betaT}{\\SizeT}{\\compile{\\sigma}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\betaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\gammaT}{\\SizeT}{\\arrT*{\\gammaT \\szltT \\betaT}{\\subst{\\compile{\\sigma}}{\\betaT}{\\gammaT}}}}{\\compile{e}}})})}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'} \\\\\n    & \\quad \\textit{by translation} \\\\\n    &= \\app{\\wfind}{(\\funT{\\betaT}{\\SizeT}{\\subst{\\compile{\\sigma}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\betaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\gammaT}{\\SizeT}{\\arrT*{\\gammaT \\szltT \\betaT}{\\subst{\\compile{\\sigma}}{\\alphaT, \\alphaT^*, \\betaT}{\\compile{s}, \\eT', \\gammaT}}}}{\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}})} \\\\\n    & \\quad \\textit{by substitution} \\\\\n    &= \\app{\\wfind}{(\\funT{\\betaT}{\\SizeT}{\\compile{\\subst{\\sigma}{\\alpha}{s}}})}{ \\\\\n    & \\quad \\qquad (\\funT{\\betaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\gammaT}{\\SizeT}{\\arrT*{\\gammaT \\szltT \\betaT}{\\subst{\\compile{\\subst{\\sigma}{\\alpha}{s}}}{\\betaT}{\\compile{s}, \\eT', \\gammaT}}}}{\\compile{\\subst{e}{\\alpha}{s}}}})} \\\\\n    & \\quad \\textit{by IHs} \\\\\n    &= \\compile{\\fix{f}{\\alpha}{\\subst{\\sigma}{\\alpha}{s}}{\\subst{e}{\\alpha}{s}}} \\quad \\textit{by translation} \\\\\n    &= \\compile{\\subst{\\fix{f}{\\alpha}{\\sigma}{e}}{\\alpha}{s}} \\quad \\textit{by substitution}.\n    \\end{align*}\n\n    If $\\alpha = \\beta$, then the substitution for $\\alphaT$ would never occur;\n    since $\\beta$ is an unbound size variable,\n    neither $\\compile{\\sigma}$ nor $\\compile{e}$ would contain $\\betaT^*$,\n    so the substitution for $\\alphaT^*$ does nothing. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{lemma}[Size compositionality (unbounded)] \\label{lem:compos-size-unbounded}\nIf $\\type{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e}{\\tau}$\nand $\\wf{\\Phi_1}{s}$ then\n$\\subst{\\compile{e}}{\\alphaT}{\\compile{s}} = \\compile{\\subst{e}{\\alpha}{s}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\type{\\Phi_1, \\alpha, \\Phi_2; \\Gamma}{e}{\\tau}$.\nThe proof structure follows that of \\nameref{lem:compos-size-bounded},\nusing \\cref{sublem:compos-subsize-unbounded} in place of \\cref{sublem:compos-subsize-bounded}\nwhere the translation of subsizing is involved.\n\\end{proof}\n\n\\subsection{Preservation of reduction}\n\nWe're now ready to prove preservation of reduction,\nwhose proof uses the various compositionality lemmas\nwhenever substitution into a translated term is involved.\nOur task is to show that if one term reduces to another,\nthen their translations are equivalent.\nBecause \\CICE's equivalence judgement is typed,\nwe need typing information for the translated terms\nto satisfy its premises.\nNote however that we only need \\emph{some} typing information,\nand that $\\tauT$ isn't necessarily $\\compile{\\tau}$.\nTo show that it is would require type preservation itself,\nwhich in turn would make our proofs circular.\n\n\\begin{lemma}[Preservation of reduction] \\label{lem:pres-red}\nSuppose we have the following:\n\\begin{itemize}[noitemsep]\n  \\item $\\red{\\Phi; \\Gamma}{e}{e'}$,\n  \\item $\\type{\\Phi; \\Gamma}{e}{\\tau}$, and\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\tauT}$.\n\\end{itemize}\nThen $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{e'}}{\\tauT}$,\nwhere \\nameref{lem:sr} gives us $\\type{\\Phi; \\Gamma}{e'}{\\tau}$\nin order to translate $\\compile{e'}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\red{\\Phi; \\Gamma}{e}{e'}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\red{\\Phi; \\Gamma}{x}{e}$ when $(\\define{x}{\\tau}{e}) \\in \\Gamma$.\n    By the definition of $\\compile{\\Gamma}$, we have\n    $(\\defineT{\\xT}{\\compile{\\tau}}{\\compile{e}}) \\in \\compile{\\Gamma}$.\n    By inversion on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\xT}{\\tauT}$,\n    we have that $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau}}{\\tauT}$.\n    Then $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\xT}{\\compile{e}}{\\compile{\\tau}}$\n    holds by \\rref{equiv-delta, equiv-conv}.\n  \\item $\\red{\\Phi; \\Gamma}{\\app{(\\fun{x}{\\sigma}{e})}{e'}}{\\subst{e}{x}{e'}}$.\\\\\n    By inversion on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{e}})}{\\compile{e'}}}{\\tauT}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\xT}{\\compile{\\sigma}}{\\compile{e}}}{\\funtypeT{\\xT}{\\sigmaT'}{\\tauT'}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e'}}{\\sigmaT'}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\compile{e'}}}{\\tauT}$.\n    \\end{itemize}\n    By inversion once more on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\xT}{\\compile{\\sigma}}{\\compile{e}}}{\\funtypeT{\\xT}{\\sigmaT'}{\\tauT'}}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\compile{\\sigma}}}{\\compile{e}}{\\tauT''}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\tauT''}}{\\funtypeT{\\xT}{\\sigmaT'}{\\tauT'}}$.\n    \\end{itemize}\n    By inversion on $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\tauT''}}{\\funtypeT{\\xT}{\\sigmaT'}{\\tauT'}}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\sigmaT'}{\\UT}$ and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\tauT''}{\\tauT'}$.\n    \\end{itemize}\n    \\rref{conv*} gives us $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\compile{\\sigma}}}{\\compile{e}}{\\tauT'}$,\n    and \\rref{equiv-sym, subtype-conv} give us\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e'}}{\\compile{\\sigma}}$.\n    We can then use \\rref{equiv-beta, equiv-conv} to get\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{e}})}{\\compile{e'}}}{\\subst{\\compile{e}}{\\xT}{\\compile{e'}}}{\\tauT}.$$\n    Finally, by \\nameref{lem:term-compositionality}, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\app{(\\fun{x}{\\sigma}{e})}{e'}}}{\\compile{\\subst{e}{x}{e'}}}{\\tauT}$$\n  \\item $\\red{\\Phi; \\Gamma}{\\App{(\\Fun{\\alpha}{e})}{s}}{\\subst{e}{\\alpha}{s}}$.\\\\\n    By inversion on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{e}})}{\\compile{s}}}{\\tauT}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\alphaT}{\\SizeT}{\\compile{e}}}{\\funtypeT{\\alphaT}{\\SizeT}{\\tauT'}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{s}}{\\SizeT}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\alphaT}{\\compile{s}}}{\\tauT}$.\n    \\end{itemize}\n    By inversion once more on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\funtypeT{\\alphaT}{\\SizeT}{\\tauT'}}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\compile{e}}{\\tauT''}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\tauT''}}{\\funtype{\\alphaT}{\\SizeT}{\\tauT'}}$.\n    \\end{itemize}\n    By inversion on $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\tauT''}}{\\funtypeT{\\alphaT}{\\SizeT}{\\tauT'}}$,\n    we have $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\tauT''}{\\tauT'}$.\n    \\rref{conv*} then gives us $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\compile{e}}{\\tauT'}$.\n    We can then use \\rref{equiv-beta, equiv-conv} to get\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{e}})}{\\compile{s}}}{\\subst{\\compile{e}}{\\alphaT}{\\compile{s}}}{\\tauT}.$$\n    Finally, by \\nameref{lem:compos-size-unbounded}, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\App{(\\Fun{\\alpha}{e})}{s}}}{\\compile{\\subst{e}{\\alpha}{s}}}{\\tauT}$$\n  \\item $\\red{\\Phi; \\Gamma}{\\App{(\\Fun<{\\alpha}{r}{e})}{s}}{\\subst{e}{\\alpha}{s}}$.\\\\\n    Let $\\subsizeto{\\Phi}{\\sss{s}}{r}{\\eT'}$.\n    Then by inversion thrice on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\funT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{e}}})}{\\compile{s}}{\\eT'}}{\\tauT}$\n    and an application of \\rref{conv*}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\alphaT \\szltT \\compile{s}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}}{\\compile{e}}{\\tauT'}$, and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}{\\tauT}$.\n    \\end{itemize}\n    We can then use \\rref{equiv-beta} twice and \\rref{equiv-conv} to get\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\funT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{e}}})}{\\compile{s}}{\\eT'}}{\\subst{\\compile{e}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT'}}{\\tauT}.$$\n    Finally, by \\nameref{lem:compos-size-bounded}, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\App{(\\Fun<{\\alpha}{r}{e})}{s}}}{\\compile{\\subst{e}{\\alpha}{s}}}{\\tauT}$$\n  \\item $\\red{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e'}{e}}{\\subst{e}{x}{e'}}$.\\\\\n    By inversion on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e'}}{\\compile{e}}}{\\tauT}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e'}}{\\compile{\\sigma}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma}}{\\compile{e'}}}{\\compile{e}}{\\tauT'}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\eT'}}{\\tauT}$.\n    \\end{itemize}\n    We can then use \\rref{equiv-zeta, equiv-conv} to get\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e'}}{\\compile{e}}}{\\subst{\\compile{e}}{\\xT}{\\compile{e'}}}{\\tauT}.$$\n    Finally, by \\nameref{lem:term-compositionality}, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\letin{x}{\\sigma}{e'}{e}}}{\\compile{\\subst{x}{e}{e'}}}{\\tauT}.$$\n  \\item[\\textbf{Cases}] \\textbf{for $\\kw{case}$}.\n    \\setlength{\\jot}{-1.5pt}\n    Because the three reduction rules for case expressions on $\\zero*$, $\\succ*$, and $\\sup*$ are very similar,\n    I cover only $\\sup*$ as a representative case.\n    $$\\red{\\Phi; \\Gamma}{\n      \\begin{aligned}\n        &\\match{\\sup{x}{\\sigma}{\\tau}{r}{s}{e_1}{e_2}}{\\fun*{x}{P}}{\\\\\n        &\\quad \\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow e}\n      \\end{aligned}\n    }{\\subst{e}{\\alpha, z_1, z_2}{s, e_1, e_2}}$$\n    Let $\\subsizeto{\\Phi}{\\sss{s}}{r}{\\eT'}$.\n    Then by inversion multiple times on\n    $$\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\n      \\begin{aligned}\n        &\\matchT{\\app{\\supT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{r}}{\\compile{s}}{\\eT'}{\\compile{e_1}}{\\compile{e_2}}}{\\funT*{\\mt}{\\xT}{\\compile{P}}}{ \\\\\n        &\\quad \\app{\\supT}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2} \\RightarrowT \\compile{e}}\n      \\end{aligned}\n    }{\\tauT}$$\n    and a few applications of \\rref{conv*}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\UT}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{r}}{\\SizeT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{s}}{\\SizeT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\eT'}{\\compile{s} \\szltT \\compile{r}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{\\sigma}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_2}}{\\arrT*{\\app{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{e_1}}}{\\app{\\WT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{s}}}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\app{\\WT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{r}}}}{\\compile{P}}{\\UT'}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{r}}, \\annotT{\\zT_1}{\\compile{\\sigma}}, \\annotT{\\zT_2}{\\app{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\zT_1}}}{\\compile{e}}{\\subst{\\compile{P}}{\\xT}{\\app{\\supT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{r}}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2}}}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\compile{P}}{\\xT}{\\app{\\supT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{r}}{\\compile{s}}{\\eT'}{\\compile{e_1}}{\\compile{e_2}}}}{\\tauT}$\n    \\end{itemize}\n    We can then use \\rref{equiv-iota, equiv-conv} to get\n    \\begin{align*}\n    \\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\n      \\begin{aligned}\n        &\\matchT{\\app{\\supT}{\\compile{\\sigma}}{(\\funT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau}})}{\\compile{r}}{\\compile{s}}{\\eT'}{\\compile{e_1}}{\\compile{e_2}}}{\\funT*{\\mt}{\\xT}{\\compile{P}}}{ \\\\\n        &\\quad \\app{\\supT}{\\alphaT}{\\alphaT^*}{\\zT_1}{\\zT_2} \\RightarrowT \\compile{e}}\n      \\end{aligned}\n    }{\\\\ \\qquad \\subst{\\compile{e}}{\\alphaT, \\alphaT^*, \\zT_1, \\zT_2}{\\compile{s}, \\eT', \\compile{e_1}, \\compile{e_2}}}{\\tauT}.\n    \\end{align*}\n    Finally, by \\nameref{lem:compos-size-unbounded}, \\nameref{lem:compos-size-bounded},\n    and \\nameref{lem:term-compositionality} twice, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile*{\n      \\begin{aligned}\n        &\\match{\\sup{x}{\\sigma}{\\tau}{r}{s}{e_1}{e_2}}{\\fun*{x}{P}}{\\\\\n        &\\quad \\app{\\App{\\sup*}{\\alpha}}{z_1}{z_2} \\Rightarrow e}\n      \\end{aligned}\n    }}{\\compile{\\subst{e}{\\alpha, z_1, z_2}{s, e_1, e_2}}}{\\tauT}$$\n  \\item $\\red[]{\\Phi; \\Gamma}{\n      \\App{(\\fix{f}{\\alpha}{\\sigma}{e})}{s}\n    }{\n      \\subst{e}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\sigma}{e})}{\\beta}}}\n    }$.\\\\\n    By definition of the translation, we have\n    $$\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\n      \\begin{aligned}\n      & \\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\\\\n      & \\quad (\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}{\\compile{e}}})}{\\compile{s}}\n      \\end{aligned}\n    }{\\tauT},$$\n    where $\\wfind$ (and $\\wfacc$) are defined in \\cref{fig:defns}.\n    Because of the sheer volume of the terms involved in the translation, $\\wfind$, and $\\wfacc$,\n    I omit well-typedness premises when applying equivalence rules,\n    especially since all of these terms are known to be well typed.\n    Do note, however, that by repeated applications of inversion, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\compile{s}}}{\\tauT}$. \\\\[\\baselineskip]\n    Let $\\sigmaT$ be $\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}}$,\n    and let $\\eT$ be $\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}{\\compile{e}}}$.\n    Liberally using \\rref{equiv-trans}, for the left-hand side we then have\n    \\begin{align*}\n    \\compile{\\Phi}, \\compile{\\Gamma} &\\vdash \\app{\\wfind}{\\sigmaT}{\\eT}{\\compile{s}} \\\\\n    &\\equiv \\app{\\wfacc}{\\sigmaT}{\\eT}{\\compile{s}}{(\\app{\\accessible}{\\compile{s}})} \\\\\n      &\\phantom{\\equiv} \\textit{by $\\wfind$ and \\rref*{equiv-beta}} \\\\\n    &\\equiv \\app{(\\fixT{1}{\\wfacc*}{\\funtypeT{\\alphaT}{\\SizeT}{\\arrT*{\\app{\\AccT}{\\alphaT}}{\\app{\\sigmaT}{\\alphaT}}}}{ \\\\\n      &\\phantom{\\equiv} \\quad \\funT{\\alphaT}{\\any}{\\funT{\\access}{\\any}{\\app{\\eT}{\\alphaT}{(\\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\alphaT}{ \\\\\n      &\\phantom{\\equiv} \\qquad \\app{\\wfacc*}{\\betaT}{(\\matchT*{\\access}{(\\app{\\accT}{\\pT} \\Rightarrow \\app{\\pT}{\\betaT}{\\betaT^*})})}}})}}}})}{\\compile{s}}{(\\app{\\accessible}{\\compile{s}})} \\\\\n      &\\phantom{\\equiv} \\textit{by $\\wfacc$ and \\rref*{equiv-beta}} \\\\\n    &\\equiv \\subst{\\compile{e}}{\\alphaT, \\fT}{\\compile{s}, \\funT{\\betaT^*}{\\betaT \\szltT \\compile{s}}{ \\\\\n      &\\phantom{\\equiv} \\quad \\app{\\wfacc}{\\sigmaT}{\\eT}{\\beta}{(\\matchT*{\\app{\\accessible}{\\compile{s}}}{(\\app{\\accT}{\\pT} \\Rightarrow \\app{\\pT}{\\betaT}{\\betaT^*})})}}} \\\\\n      &\\phantom{\\equiv} \\textit{by \\rref*{equiv-mu}, \\rref*{equiv-beta}, and $\\wfacc$} \\\\\n    &: \\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\compile{s}}\n    \\end{align*}\n    Meanwhile, for the right-hand side we have\n    \\begin{align*}\n    &\\compile{\\subst{e}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\sigma}{e})}{\\beta}}}} \\\\\n    &= \\subst{\\compile{e}}{\\alphaT, \\fT}{\\compile{s}, \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{s}}{\\app{\\compile{\\fix{f}{\\alpha}{\\sigma}{e}}}{\\betaT}}}} \\\\\n      &\\phantom{=} \\textit{by \\nameref{lem:compos-size-unbounded} and \\nameref{lem:term-compositionality}} \\\\\n    &= \\subst{\\compile{e}}{\\alphaT, \\fT}{\\compile{s}, \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{s}}{\\app{\\wfind}{\\sigmaT}{\\eT}{\\betaT}}}} \\\\\n      &\\phantom{=} \\textit{by definition of translation of $\\kw{fix}$} \\\\\n    &= \\subst{\\compile{e}}{\\alphaT, \\fT}{\\compile{s}, \\funT{\\betaT}{\\SizeT}{\\funT{\\betaT^*}{\\betaT \\szltT \\compile{s}}{\\app{\\wfacc}{\\sigmaT}{\\eT}{\\betaT}{(\\app{\\accessible}{\\betaT})}}}} \\\\\n      &\\phantom{=} \\textit{by $\\wfind$}\n    \\end{align*}\n    The only difference between the left- and right-hand sides now\n    is the proof of $\\app{\\AccT}{\\betaT}$ for some $\\betaT \\szltT \\compile{s}$,\n    but we know that such proofs are propositionally equal to one another.\n    From inversion, we know that $\\compile{s}$ is well typed with type $\\SizeT$.\n    Then we can show that\n    \\begin{align*}\n    &\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\betaT}{\\SizeT}, \\annotT{\\betaT^*}{\\betaT \\szltT \\compile{s}}}{\\app{\\accIsProp}{\\betaT}{(\\matchT*{\\app{\\accessible}{\\compile{s}}}{(\\app{\\accT}{\\pT} \\Rightarrow \\app{\\pT}{\\betaT}{\\betaT^*})})}{(\\app{\\accessible}{\\betaT})}}{\\\\\n    &\\phantom{\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\betaT}{\\SizeT}, \\annotT{\\betaT^*}{\\betaT \\szltT \\compile{s}}}{}{}}\n    \\eq{\\matchT*{\\app{\\accessible}{\\compile{s}}}{(\\app{\\accT}{\\pT} \\Rightarrow \\app{\\pT}{\\betaT}{\\betaT^*})}}{\\app{\\AccT}{\\betaT}}{\\app{\\accessible}{\\betaT}}}.\n    \\end{align*}\n    By \\rref{equiv-reflect}, we have\n    \\begin{align*}\n    &\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\betaT}{\\SizeT}, \\annotT{\\betaT^*}{\\betaT \\szltT \\compile{s}}}{\\matchT*{\\app{\\accessible}{\\compile{s}}}{(\\app{\\accT}{\\pT} \\Rightarrow \\app{\\pT}{\\betaT}{\\betaT^*})}}{\\app{\\accessible}{\\betaT}}{\\app{\\AccT}{\\betaT}}.\n    \\end{align*}\n    Finally, by \\rref{equiv-cong}, we can equate the left- and right-hand sides,\n    and by \\rref{equiv-conv}, we obtain our goal.\n    \\begin{align*}\n    \\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\App{(\\fix{f}{\\alpha}{\\sigma}{e})}{s}}}{\\compile{\\subst{e}{\\alpha, f}{s, \\Fun<{\\beta}{s}{\\App{(\\fix{f}{\\alpha}{\\sigma}{e})}{\\beta}}}}}{\\tauT}\n    \\end{align*}\n  \\item \\rref*{red-cong}.\n    The various congruence cases are all similar to one another.\n    I cover only reduction of the bound expression in $\\kw{let}$ expressions as a representative case.\n    \\begin{mathpar}\n    \\inferrule{\n      \\red{\\Phi; \\Gamma}{e_1}{e'_1}\n    }{\n      \\red{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\letin{x}{\\sigma}{e'_1}{e_2}}\n    }\n    \\end{mathpar}\n    By inversion on $\\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\tau}$\n    and on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}}}{\\tauT}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\sigma}{U}$,\n      \\item $\\type{\\Phi; \\Gamma}{e_1}{\\sigma}$,\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e_1}}{e_2}{\\tau'}$,\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e_1}}{\\tau}$;\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{\\sigma}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}}{\\compile{e_2}}{\\tauT'}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\compile{e_1}}}{\\tauT}$.\n    \\end{itemize}\n    By the induction hypothesis, we have\n    $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{e'_1}}{\\compile{\\sigma}}$.\n    Meanwhile, by \\rref{equiv-refl}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{\\sigma}}{\\UT}$ and\n      \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}}{\\compile{e_2}}{{\\compile{e_2}}{\\tauT'}}$.\n    \\end{itemize}\n    Then by \\rref{equiv-cong}, we have\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e'_1}}{\\compile{e_2}}}{\\subst{\\tauT'}{\\xT}{\\compile{e_1}}}.$$\n    Finally, by \\rref{equiv-conv}, we obtain our goal.\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e'_1}}{\\compile{e_2}}}{\\tauT}$$\n    In general, the proof procedure is to invert on both typing derivations,\n    apply the induction hypothesis, construct the goal up to the type annotation via \\rref{equiv-cong},\n    and finally fix the type annotation using \\rref{equiv-conv}.\n    \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Preservation of closure of reduction}\n\nThe proof of preservation for reduction closed under reflexivity and transitivity is relatively straightforward,\nsince most of the work was done in the preservation proof for reduction itself.\nThis, too, requires well-typedness of the translated term as a premise to apply preservation of reduction.\n\n\\begin{lemma}[Preservation of reflexive, transitive closure of reduction] \\label{lem:pres-red*}\nSuppose we have the following:\n\\begin{itemize}[noitemsep]\n  \\item $\\red*{\\Phi; \\Gamma}{e}{e'}$,\n  \\item $\\type{\\Phi; \\Gamma}{e}{\\tau}$, and\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\tauT}$.\n\\end{itemize}\nThen $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{e'}}{\\tauT}$,\nwhere \\nameref{thm:subject-reduction} gives us $\\type{\\Phi; \\Gamma}{e'}{\\tau}$\nin order to translate $\\compile{e'}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\red*{\\Phi; \\Gamma}{e}{e'}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{red*-once}. By \\nameref{lem:pres-red}.\n  \\item \\rref*{red*-refl}. Trivial by \\rref{equiv-refl}.\n  \\item \\rref*{red*-trans}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\red*{\\Phi; \\Gamma}{e}{e'} \\\\\n      \\red*{\\Phi; \\Gamma}{e'}{e''} \\\\\n    }{\n      \\red*{\\Phi; \\Gamma}{e}{e''}\n    }\n    \\end{mathpar}\n    By the induction hypothesis on the first premise,\n    we have $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{e'}}{\\tauT}$.\n    By \\nameref{thm:subject-reduction} and \\nameref{thm:subject-equivalence}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{e'}{\\tau}$ and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e'}}{\\tauT}$.\n    \\end{itemize}\n    Then we can apply the induction hypothesis on the second premise to yield\n    $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e'}}{\\compile{e''}}{\\tauT}$.\n    Finally, by \\rref{equiv-trans}, we have\n    $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{e''}}{\\tauT}$. \\qedhere\n  \\iffalse\n  \\item \\rref*{red*-cong}.\n    The various congruence cases are all similar to one another;\n    I cover only \\rref{let} as a representative case.\n    \\begin{mathpar}\n    \\inferrule{\n      \\red*{\\Phi; \\Gamma}{\\sigma}{\\sigma'} \\\\\n      \\red*{\\Phi; \\Gamma}{e_1}{e'_1} \\\\\n      \\red*{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{e_2}{e'_2}\n    }{\n      \\red*{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\letin{x}{\\sigma'}{e'_1}{e'_2}}\n    }\n    \\end{mathpar}\n    By inversion on $\\type{\\Phi; \\Gamma}{\\letin{x}{\\sigma}{e_1}{e_2}}{\\tau}$\n    and on $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}}}{\\compile{\\tau}}$,\n    we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma}{\\sigma}{U}$,\n      \\item $\\type{\\Phi; \\Gamma}{e_1}{\\sigma}$,\n      \\item $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma}{e_1}}{e_2}{\\tau'}$,\n      \\item $\\subtype{\\Phi; \\Gamma}{\\subst{\\tau'}{x}{e_1}}{\\tau}$;\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{\\sigma}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}}{\\compile{e_2}}{\\tauT'}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\compile{e_1}}}{\\tauT}$.\n    \\end{itemize}\n    Applying the induction hypothesis to the first and second premises, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{\\sigma'}}{\\UT}$ and\n      \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{e'_1}}{\\compile{\\sigma}}$.\n    \\end{itemize}\n    By \\rref{red*-refl, acum-refl, subtype-red}, we have $\\subtype{\\Phi; \\Gamma}{\\sigma}{\\sigma'}$.\n    Then by \\nameref{lem:replacement-subtyping} and \\nameref{lem:replacement-reduction},\n    we have $\\type{\\Phi; \\Gamma, \\define{x}{\\sigma'}{e'_1}}{e_2}{\\tau'}$.\n    Similarly, by \\rref{subtype-conv}, we have $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{\\sigma'}}$,\n    and by \\nameref{lem:replacement-subtyping*} and \\nameref{lem:replacement-equivalence},\n    we have $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma'}}{\\compile{e'_1}}}{\\compile{e_2}}{\\tauT'}$.\n    This lets us to apply the induction hypothesis to the third premise,\n    yielding $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}, \\defineT{\\xT}{\\compile{\\sigma'}}{\\compile{e'_1}}}{\\compile{e_2}}{\\compile{e'_2}}{\\tauT'}$.\n    By \\rref{subtype-conv, equiv-conv, equiv-cong} and \\nameref{thm:transitivity-subtyping}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e_1}}{\\compile{\\sigma'}}$,\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\compile{e'_1}}}{\\subst{\\tauT'}{\\xT}{\\compile{e_1}}}$, and\n      \\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\subst{\\tauT'}{\\xT}{\\compile{e'_1}}}{\\tauT}$.\n    \\end{itemize}\n    Finally, by \\rref{equiv-cong, equiv-conv}, we have\n    $$\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\letinT{\\xT}{\\compile{\\sigma}}{\\compile{e_1}}{\\compile{e_2}}}{\\letinT{\\xT}{\\compile{\\sigma'}}{\\compile{e'_1}}{\\compile{e'_2}}}{\\tauT}.$$\n  \\fi\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Preservation of \\texorpdfstring{$\\alpha$}{alpha}-cumulativity}\n\nThis lemma is proven independently of compositionality and preservation of (closure of) reduction.\nLike preservation of reduction, the well-typedness of the translation of the $\\alpha$-cumulative\\index{$\\alpha$-cumulativity} terms\nis required to derive various equivalences,\nbut their types need not even be the same,\nsince the \\CICE subtyping judgement itself is untyped.\n\n\\begin{lemma}[Preservation of $\\alpha$-cumulativity] \\label{lem:pres-acum}\nSuppose we have the following:\n\\begin{itemize}[noitemsep]\n  \\item $\\acum{\\tau_1}{\\tau_2}$,\n  \\item $\\type{\\Phi; \\Gamma}{\\tau_1}{U_1}$,\n  \\item $\\type{\\Phi; \\Gamma}{\\tau_2}{U_2}$,\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\UT_1}$, and\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_2}}{\\UT_2}$.\n\\end{itemize}\nThen $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\compile{\\tau_2}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\acum{\\tau_1}{\\tau_2}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{acum-refl}.\n    Trivial by \\rref{equiv-refl, subtype-conv} using well-typedness of the translated term.\n  \\item[\\textbf{Cases}] \\rref*{acum-prop}, \\rref*{acum-type}.\n    Trivial by \\rref{subtype-prop} and \\rref{subtype-type}, respectively.\n  \\item \\rref{acum-pi}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\acum{\\tau_1}{\\tau_2}\n    }{\n      \\acum{\\funtype{x}{\\sigma}{\\tau_1}}{\\funtype{x}{\\sigma}{\\tau_2}}\n    }\n    \\end{mathpar}\n    By inversion on $\\type{\\Phi; \\Gamma}{\\funtype{x}{\\sigma}{\\tau_i}}{U_i}$ and on\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau_i}_{\\annot{x}{\\sigma}}}}{\\compile{U_i}}$\n    for $i = 1, 2$, omitting unneeded judgements, we have\n    \\begin{itemize}[noitemsep]\n      %\\item $\\type{\\Phi; \\Gamma}{\\sigma}{U'}$,\n      \\item $\\type{\\Phi; \\Gamma, \\annot{x}{\\sigma}}{\\tau_i}{U''_i}$,\n      %\\item $\\subtype{\\Phi; \\Gamma}{\\rules{U'}{U''_i}}{U'_i}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\UT'}$, and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\compile{\\sigma}}}{\\compile{\\tau_i}_{\\annot{x}{\\sigma}}}{\\UT''_i}$.\n      %\\item $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\rules{\\UT'}{\\UT''_i}}{\\UT_i}$.\n    \\end{itemize}\n    By the induction hypothesis on the premise using the above, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\compile{\\sigma}}}{\\compile{\\tau_1}_{\\annot{x}{\\sigma}}}{\\compile{\\tau_2}_{\\annot{x}{\\sigma}}}$.\n    By \\rref{equiv-refl}, we have $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{\\sigma}}{\\UT'}$.\n    Then by \\rref{subtype-pi}, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau_1}_{\\annot{x}{\\sigma}}}}{\\funtypeT{\\xT}{\\compile{\\sigma}}{\\compile{\\tau_2}_{\\annot{x}{\\sigma}}}}$.\n  \\item \\rref{acum-forall}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\acum{\\tau_1}{\\tau_2}\n    }{\n      \\acum{\\Funtype{\\alpha}{\\tau_1}}{\\Funtype{\\alpha}{\\tau_2}}\n    }\n    \\end{mathpar}\n    By inversion on $\\type{\\Phi; \\Gamma}{\\Funtype{\\alpha}{\\tau_i}}{U_i}$ and on\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\compile{\\tau_i}_{\\alpha}}}{\\UT_i}$\n    for $i = 1, 2$, omitting unneeded judgements, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi, \\alpha; \\Gamma}{\\tau_i}{U''_i}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\UT'}$, and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\compile{\\tau_i}_{\\alpha}}{\\UT''_i}$.\n    \\end{itemize}\n    By the induction hypothesis on the premise using the above, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\compile{\\tau_1}_{\\alpha}}{\\compile{\\tau_2}_{\\alpha}}$.\n    By \\rref{equiv-refl}, we have $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\SizeT}{\\UT'}$.\n    Then by \\rref{subtype-pi}, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\compile{\\tau_1}_{\\alpha}}}{\\funtypeT{\\alphaT}{\\SizeT}{\\compile{\\tau_2}_{\\alpha}}}$.\n  \\item \\rref{acum-forall<}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\acum{\\tau_1}{\\tau_2}\n    }{\n      \\acum{\\Funtype<{\\alpha}{s}{\\tau_1}}{\\Funtype<{\\alpha}{s}{\\tau_2}}\n    }\n    \\end{mathpar}\n    By inversion on $\\type{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\tau_i}}{U_i}$ and on\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\funtypeT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{\\tau_i}_{\\bound{\\alpha}{s}}}}}{\\UT_i}$\n    for $i = 1, 2$, omitting unneeded judgements, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\Phi; \\Gamma, \\bound{\\alpha}{s}}{\\tau_i}{U''_I}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\UT'}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\alphaT \\szltT \\compile{s}}{\\UT''}$, and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}}{\\compile{\\tau_i}_{\\bound{\\alpha}{s}}}{\\UT'''_i}$.\n    \\end{itemize}\n    By the induction hypothesis on the premise using the above, we have\n    $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}}{\\compile{\\tau_1}_{\\bound{\\alpha}{s}}}{\\compile{\\tau_2}_{\\bound{\\alpha}{s}}}$.\n    By \\rref{equiv-refl}, we have $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\SizeT}{\\SizeT}{\\UT'}$\n    and $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\alphaT}{\\SizeT}}{\\alphaT \\szltT \\compile{s}}{\\alphaT \\szltT \\compile{s}}{\\UT''}$.\n    Then by \\rref{subtype-pi} twice, we have\n    $$\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\funtypeT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{\\tau_1}_{\\bound{\\alpha}{s}}}}}{\\funtypeT{\\alphaT}{\\SizeT}{\\funtypeT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{\\tau_2}_{\\bound{\\alpha}{s}}}}}.$$\n    \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\subsection{Preservation of subtyping}\n\nMost of the heavy lifting in proving preservation of subtyping\\index{subtyping} is done by\npreservation of $\\alpha$-cumulativity and preservation of the closure of reduction.\n\n\\begin{lemma}[Preservation of subtyping] \\label{lem:pres-subtyping}\nSuppose we have the following:\n\\begin{itemize}[noitemsep]\n  \\item $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}$,\n  \\item $\\type{\\Phi; \\Gamma}{\\tau_1}{U}$,\n  \\item $\\type{\\Phi; \\Gamma}{\\tau_2}{U}$,\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\compile{U}}$, and\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_2}}{\\compile{U}}$.\n\\end{itemize}\nThen $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\compile{\\tau_2}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy cases on the derivation of $\\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}$,\nthere being only one case.\n\\begin{mathpar}\n\\inferrule{\n  \\red*{\\Phi; \\Gamma}{\\tau_1}{\\sigma_1} \\\\\n  \\red*{\\Phi; \\Gamma}{\\tau_2}{\\sigma_2} \\\\\n  \\acum{\\sigma_1}{\\sigma_2}\n}{\n  \\subtype{\\Phi; \\Gamma}{\\tau_1}{\\tau_2}\n}\n\\end{mathpar}\nBy \\rref{conv, conv*}, we have both $\\type{\\Phi; \\Gamma}{U}{\\axioms{U}}$\nand $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{U}}{\\compile{\\axioms{U}}}$.\nThen \\hyperref[lem:pres-red*]{Preservation of closure of reduction} on the first two premises yields\n\\begin{itemize}[noitemsep]\n  \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\compile{\\sigma_1}}{\\compile{U}}$ and\n  \\item $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_2}}{\\compile{\\sigma_2}}{\\compile{U}}$.\n\\end{itemize}\nBy \\nameref{thm:subject-reduction} and \\nameref{thm:subject-equivalence}, we have\n\\begin{itemize}[noitemsep]\n  \\item $\\type{\\Phi; \\Gamma}{\\sigma_1}{U}$,\n  \\item $\\type{\\Phi; \\Gamma}{\\sigma_2}{U}$,\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma_1}}{\\compile{U}}$, and\n  \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma_2}}{\\compile{U}}$.\n\\end{itemize}\nUsing the above and the final premise, by \\nameref{lem:pres-acum}, we have\n$\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma_1}}{\\compile{\\sigma_2}}$.\nThen by \\rref{equiv-sym, subtype-conv, subtype-trans}, we have\n$\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau_1}}{\\compile{\\tau_2}}$.\n\\end{proof}\n\n\\subsection{Type preservation}\n\nAt last we are able to prove type preservation\\index{type preservation},\nusing preservation of subtyping in the \\rref*{conv} case\nand preservation of sizes and subsizing,\nwhich are proven independently.\n\n\\begin{lemma}[Preservation of sizes] \\label{lem:pres-size}\n\\begin{enumerate}[noitemsep]\\hfill\n  \\item If $\\wf{}{\\Phi}$ then $\\wf{}{\\compile{\\Phi}}$; and\n  \\item If $\\wf{\\Phi}{s}$ then $\\type{\\compile{\\Phi}}{\\compile{s}}{\\SizeT}$.\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\nBy mutual induction on the derivations of $\\wf{}{\\Phi}$ and $\\wf{\\Phi}{s}$.\n\\begin{enumerate}[noitemsep]\n  \\item %\n    \\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n      \\item \\rref*{nil}. Trivial.\n      \\item \\rref*{cons-size}. By the induction hypothesis and \\rref{ind, cons*-ass}.\n      \\item \\rref*{cons-size<}. By the induction hypotheses and \\rref{ind, cons*-ass}.\n    \\end{itemize}\n  \\item %\n    \\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n      \\item $\\wf{\\Phi}{\\alpha}$. By the induction hypothesis and \\rref{var*}.\n      \\item $\\wf{\\Phi}{\\circ}$. By the induction hypothesis and well-typedness of $\\baseT$.\n      \\item $\\wf{\\Phi}{\\sss{s}}$. By the induction hypothesis and \\rref{constr}. \\qedhere\n    \\end{itemize}\n\\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}[Preservation of subsizing] \\label{lem:pres-subsize}\nIf $\\subsizeto{\\Phi}{r}{s}{\\eT}$ then $\\type{\\compile{\\Phi}}{\\eT}{\\compile{r} \\szleT \\compile{s}}$.\n\\end{lemma}\n\n\\begin{proof}\nBy induction on the derivation of $\\subsizeto{\\Phi}{r}{s}{\\eT}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item $\\subsizeto{\\Phi}{\\sss{\\alpha}}{s}{\\alphaT^*}$.\n    By definition of the translation,\n    $(\\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}) \\in \\compile{\\Phi}$,\n    so $\\type{\\compile{\\Phi}}{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}$ by\n    the induction hypothesis and \\rref{var*}.\n  \\item $\\subsizeto{\\Phi}{\\circ}{s}{\\app{\\baseleq}{\\compile{s}}}$.\n    By the induction hypothesis and well-typedness of $\\baseleq$.\n  \\item $\\subsizeto{\\Phi}{s}{s}{\\app{\\reflleq}{\\compile{s}}}$.\n    By the induction hypothesis and well-typedness of $\\reflleq$.\n  \\item $\\subsizeto{\\Phi}{s}{\\sss{s}}{\\app{\\sucleq}{\\compile{s}}}$.\n    By the induction hypothesis and well-typedness of $\\sucleq$.\n  \\item \\textbf{for monotonicity}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\subsizeto{\\Phi}{r}{s}{\\eT}\n    }{\n      \\subsizeto{\\Phi}{\\sss{r}}{\\sss{s}}{\\app{\\monoT}{\\compile{r}}{\\compile{s}}{\\eT}}\n    }\n    \\end{mathpar}\n    By the induction hypothesis,\n    $\\type{\\compile{\\Phi}}{\\eT}{\\compile{r} \\szleT \\compile{s}}$.\n    Then $\\type{\\compile{\\Phi}}{\\app{\\monoT}{\\compile{r}}{\\compile{s}}{\\eT}}{\\app{\\sucT}{\\compile{r}} \\szleT \\app{\\sucT}{\\compile{s}}}$\n    by \\rref{constr}.\n  \\item \\textbf{for transitivity}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\subsizeto{\\Phi}{s_1}{s_2}{\\eT_{12}} \\\\\n      \\subsizeto{\\Phi}{s_2}{s_3}{\\eT_{23}}\n    }{\n      \\subsizeto{\\Phi}{s_1}{s_3}{\\app{\\transleq}{\\compile{s_1}}{\\compile{s_2}}{\\compile{s_3}}{\\eT_{12}}{\\eT_{23}}}\n    }\n    \\end{mathpar}\n    By the induction hypotheses,\n    $\\type{\\compile{\\Phi}}{\\eT_{12}}{\\compile{s_1} \\szleT \\compile{s_2}}$ and\n    $\\type{\\compile{\\Phi}}{\\eT_{23}}{\\compile{s_2} \\szleT \\compile{s_3}}$.\n    Then $\\type{\\compile{\\Phi}}{\\app{\\transleq}{\\compile{s_1}}{\\compile{s_2}}{\\compile{s_3}}{\\eT_{12}}{\\eT_{23}}}{\\compile{s_1} \\szleT \\compile{s_3}}$\n    by well-typedness of $\\transleq$. \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{theorem}[Type preservation] \\label{thm:pres-typing} \\hfill\n\\begin{enumerate}[noitemsep]\n  \\item If $\\wf{\\Phi}{\\Gamma}$ then $\\wf{}{\\compile{\\Phi}, \\compile{\\Gamma}}$; and\n  \\item If $\\type{\\Phi; \\Gamma}{e}{\\tau}$ then $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{\\tau}}$.\n\\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\nBy mutual induction on the derivations of\n$\\wf{\\Phi}{\\Gamma}$ and $\\type{\\Phi; \\Gamma}{e}{\\tau}$.\n\\begin{itemize}[noitemsep, label=\\textbf{Case}, leftmargin=*, labelindent=\\parindent]\n  \\item \\rref*{nil}. Trivial by \\cref*{lem:wf-env-size} and \\nameref{lem:pres-size}.\n  \\item \\rref*{cons-ass}. By the induction hypotheses and \\rref{cons*-ass}.\n  \\item \\rref*{cons-def}. By the induction hypotheses and \\rref{cons*-def}.\n  \\item \\rref*{conv}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi; \\Gamma}{e}{\\sigma} \\\\\n      \\check{\\Phi; \\Gamma}{\\sigma}{U} \\\\\n      \\infer{\\Phi; \\Gamma}{\\tau}{U} \\\\\n      \\subtype{\\Phi; \\Gamma}{\\sigma}{\\tau}\n    }{\n      \\check{\\Phi; \\Gamma}{e}{\\tau}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{\\sigma}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{U}}$, and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\tau}}{\\compile{U}}$.\n    \\end{itemize}\n    By \\nameref{lem:pres-subtyping} on the last premise,\n    we have $\\subtype{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{\\tau}}$.\n    Then by \\rref{conv*}, we have $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\compile{\\tau}}$.\n  \\item \\rref*{var}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\wf{\\Phi}{\\Gamma} \\\\\n      (\\annot{x}{\\tau}) \\in \\Gamma\n      \\textit{ or }\n      (\\define{x}{\\tau}{e}) \\in \\Gamma\n    }{\n      \\infer{\\Phi; \\Gamma}{x}{\\tau}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $\\wf{}{\\compile{\\Phi}, \\compile{\\Gamma}}$. \\\\\n    By definition of the translation, we have\n    $(\\annotT{\\xT}{\\compile{\\tau}}) \\in \\compile{\\Gamma}$ or\n    $(\\defineT{\\xT}{\\compile{\\tau}}{\\compile{e}}) \\in \\compile{\\Gamma}$,\n    so by \\rref{var*}, we have\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\xT}{\\compile{\\tau}}$.\n  \\item[\\textbf{Cases}] \\rref*{univ}, \\rref*{pi}, \\rref*{lam}, \\rref*{app}, \\rref*{let}.\n    Straightforward by their induction hypotheses and \\rref{univ*, pi*, lam*, app*, let*}.\n  \\item \\rref{forall<}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\wf{\\Phi}{s} \\\\\n      \\type{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{\\tau}{U}\n    }{\n      \\type{\\Phi; \\Gamma}{\\Funtype<{\\alpha}{s}{\\tau}}{U}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $\\type{\\compile{\\Phi}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}, \\compile{\\Gamma}}{\\compile{\\tau}}{\\compile{U}}$. \\\\\n    By \\nameref{lem:pres-size}, we have $\\type{\\compile{\\Phi}}{\\compile{s}}{\\SizeT}$.\n    If $\\compile{U} = \\TypeT{\\iT}$ for some $\\iT \\geq 1$,\n    we have $\\type{\\compile{\\Phi}}{\\SizeT}{\\compile{U}}$\n    and $\\type{\\compile{\\Phi}, \\annotT{\\alphaT}{\\SizeT}}{\\alphaT \\szltT \\compile{s}}{\\compile{U}}$\n    by \\rref{ind, app*},\n    so we have $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funtypeT{\\alphaT}{\\SizeT}{\\funtypeT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}{\\compile{\\tau}}}}{\\compile{U}}$\n    by \\rref{pi*} twice.\n    If $U = \\Prop$, $\\SizeT$ and $\\alphaT \\szltT \\compile{s}$\n    can be typed as any $\\TypeT{\\iT}$ where $\\iT \\geq 1$,\n    and we still have the goal by \\rref{pi*}.\n  \\item \\rref{forall, slam, slam<}. Similar to the case for \\rref*{forall<}.\n  \\item \\rref{sapp<}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi; \\Gamma}{e}{\\Funtype<{\\alpha}{r}{\\tau}} \\\\\n      \\subsize{\\Phi}{\\sss{s}}{r}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\App{e}{s}}{\\subst{\\tau}{\\alpha}{s}}\n    }\n    \\end{mathpar}\n    Induction hypothesis: $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\funtypeT{\\alphaT}{\\SizeT}{\\funtypeT{\\alphaT^*}{\\alphaT \\szltT \\compile{r}}{\\compile{\\tau}}}}$. \\\\\n    Let $\\subsizeto{\\Phi}{\\sss{s}}{r}{\\eT}$.\n    By \\nameref{lem:pres-subsize}, we have $\\type{\\compile{\\Phi}}{\\eT}{\\compile{\\sss{s}} \\szltT \\compile{r}}$.\n    By \\cref{lem:wf-subsize} and \\nameref{lem:pres-size}, we have\n    $\\type{\\compile{\\Phi}}{\\compile{\\sss{s}}}{\\SizeT}$ and $\\type{\\compile{\\Phi}}{\\compile{r}}{\\SizeT}$.\n    Then by \\rref{app*} twice, we have\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{\\compile{e}}{\\compile{s}}{\\eT}}{\\subst{\\compile{\\tau}}{\\alphaT, \\alphaT^*}{\\compile{s}, \\eT}}$.\n    Finally, by \\nameref{lem:compos-size-bounded},\n    the type is equal to $\\compile{\\subst{\\tau}{\\alpha}{s}}$ as desired.\n  \\item[\\textbf{Cases}] \\rref{zero, succ, sup}. Similar to the case for \\rref*{sapp<}.\n  \\item[\\textbf{Cases}] \\rref{sapp, nat, wft}. Similar to the case for \\rref*{sapp<},\n    using only \\nameref{lem:pres-size} without \\nameref{lem:pres-subsize},\n    and \\nameref{lem:compos-size-unbounded} in place of \\nameref{lem:compos-size-bounded}.\n  \\item \\rref*{case-nat}.\n    \\setlength{\\jot}{-1.5pt}\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi; \\Gamma}{e}{\\N{s}} \\\\\n      \\infer{\\Phi; \\Gamma, \\annot{x}{\\N{s}}}{P}{U} \\\\\n      \\check{\\Phi, \\bound{\\alpha}{s}; \\Gamma}{e_z}{\\subst{P}{x}{\\zero{s}{\\alpha}}} \\\\\n      \\check{\\Phi, \\bound{\\beta}{s}; \\Gamma, \\annot{z}{\\N{\\beta}}}{e_s}{\\subst{P}{x}{\\succ{s}{\\beta}{z}}}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\match{e}{\\fun*{x}{P}}{(\\App{\\zero*}{\\alpha} \\Rightarrow e_z)(\\app{\\App{\\succ*}{\\beta}}{z} \\Rightarrow e_s)}}{\\subst{P}{x}{e}}\n    }\n    \\end{mathpar}\n    Induction hypotheses (using \\nameref{lem:term-compositionality} in the types of the last two):\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\compile{e}}{\\app{\\NatT}{\\compile{s}}}$,\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}, \\annotT{\\xT}{\\app{\\NatT}{\\compile{s}}}}{\\compile{P}}{\\compile{U}}$,\n      \\item $\\type{\\compile{\\Phi}, \\annotT{\\alphaT}{\\SizeT}, \\annotT{\\alphaT^*}{\\alphaT \\szltT \\compile{s}}, \\compile{\\Gamma}}{\\compile{e_z}}{\\subst{\\compile{P}}{\\xT}{\\app{\\zeroT}{\\compile{s}}{\\alphaT}{\\alphaT^*}}}$, and\n      \\item $\\type{\\compile{\\Phi}, \\annotT{\\betaT}{\\SizeT}, \\annotT{\\betaT^*}{\\betaT \\szltT \\compile{s}}, \\compile{\\Gamma}, \\annotT{\\zT}{\\app{\\NatT}{\\betaT}}}{\\compile{e_s}}{\\subst{\\compile{P}}{\\xT}{\\app{\\succT}{\\compile{s}}{\\betaT}{\\betaT^*}{\\zT}}}$.\n    \\end{itemize}\n    By \\rref{case} and \\nameref{lem:term-compositionality} once more, we have\n    $$\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\n      \\begin{aligned}\n      &\\matchT{\\compile{e}}{\\funT*{\\mt}{\\xT}{\\compile{P}}}{ \\\\\n      &\\quad \\app{\\zeroT}{\\alphaT}{\\alphaT^*} \\RightarrowT \\compile{e_z} \\\\\n      &\\quad \\app{\\succT}{\\betaT}{\\betaT^*}{\\zT} \\RightarrowT \\compile{e_s}}\n      \\end{aligned}\n    }{\\compile{\\subst{P}{x}{e}}}$$\n  \\item \\rref*{case-wft}. Similar to the case for \\rref*{case-nat}.\n  \\item \\rref*{fix}.\n    \\vspace{-\\baselineskip}\n    \\begin{mathpar}\n    \\inferrule{\n      \\infer{\\Phi, \\alpha; \\Gamma}{\\sigma}{U} \\\\\n      \\fresh{\\beta} \\\\\n      \\check{\\Phi, \\alpha; \\Gamma, \\annot{f}{\\Funtype<{\\beta}{\\alpha}{\\subst{\\sigma}{\\alpha}{\\beta}}}}{e}{\\sigma}\n    }{\n      \\infer{\\Phi; \\Gamma}{\\fix{\\fT}{\\alpha}{\\sigma}{e}}{\\Funtype{\\alpha}{\\sigma}}\n    }\n    \\end{mathpar}\n    Induction hypotheses:\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\annotT{\\alphaT}{\\SizeT}, \\compile{\\Gamma}}{\\compile{\\sigma}}{\\compile{U}}$ and\n      \\item $\\type{\\compile{\\Phi}, \\annotT{\\alphaT}{\\SizeT}, \\compile{\\Gamma}, \\annotT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}}{\\compile{e}}{\\compile{\\sigma}}$.\n    \\end{itemize}\n    By \\rref{ind, lam*}, we have\n    \\begin{itemize}[noitemsep]\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}}}{\\arrT*{\\SizeT}{\\compile{U}}}$ and\n      \\item $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}{\\compile{e}}}}{\\funtypeT{\\alphaT}{\\SizeT}{\\arrT*{(\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}})}{\\compile{\\sigma}}}}$.\n    \\end{itemize}\n    Let $\\eT$ be $\\funT{\\alphaT}{\\SizeT}{\\funT{\\fT}{\\funtypeT{\\betaT}{\\SizeT}{\\arrT*{\\betaT \\szltT \\alphaT}{\\subst{\\compile{\\sigma}}{\\alphaT}{\\betaT}}}}{\\compile{e}}}$.\n    By \\rref{app*} twice, we then have\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\eT}}{\\funtypeT{\\alphaT}{\\SizeT}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\alphaT}}}$.\n    By \\rref{equiv-beta, equiv-cong, subtype-conv}, we have\n    $\\defeq{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\alphaT}}{\\funtypeT{\\alphaT}{\\SizeT}{\\compile{\\sigma}}}{\\compile{U}}$.\n    Then finally, by \\rref{conv*}, we have\n    $\\type{\\compile{\\Phi}, \\compile{\\Gamma}}{\\app{\\wfind}{(\\funT{\\alphaT}{\\SizeT}{\\compile{\\sigma}})}{\\eT}}{\\funtypeT{\\alphaT}{\\SizeT}{\\compile{\\sigma}}}$.\n    \\qedhere\n\\end{itemize}\n\\end{proof}", "meta": {"hexsha": "d3ab364d59f4228a5c375b8900999b13f0d51a63", "size": 137208, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/proofs.tex", "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/proofs.tex", "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/proofs.tex", "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.8739884393, "max_line_length": 408, "alphanum_fraction": 0.6268293394, "num_tokens": 50523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.414817034471066}}
{"text": "\\documentclass[11pt, fleqn]{article}\n\n\\input{../../utils/header.tex}\n\n% \\crefname{figure}{Figure}{Figures}\n% \\crefname{section}{Section}{Sections}\n% \\crefname{table}{Table}{Tables}\n% \\crefname{lstlisting}{Listing}{Listings}\n\n\\setlength{\\parskip}{12pt} % Sets a blank line in between paragraphs\n\\setlength\\parindent{0pt} % Sets the indent for each paragraph to zero\n\n\\begin{document}\n\n\\title{Machine Learning (41204-01)\\\\HW \\#3}\n\\author{Will Clark $\\vert$ Matthew DeLio \\\\\n\\texttt{will.clark@chicagobooth.edu} $\\vert$ \\texttt{mdelio@chicagobooth.edu} \\\\\nUniversity of Chicago Booth School of Business}\n\\date{\\today}\n\\maketitle\n\n\\section{Data}\n\nFor this exercise, our data set contains the sale price and the observable characteristics for a sample of 20,000 used cars. We randomly sample it to break this data into three subsets: 50\\% of data will be our training set that will be used to train/tune our models ($n=10,031$); 25\\% will be our validation data set which we will use to evaluate model performance ($n=5,016$); and 25\\% will be our test set which we will use to evaluate out-of-sample performance of our best model ($n=5,016$).\n\nWe will build a series of models that can predict the selling price of a used car given its observable characteristics. The models and techniques we will use are: (1) regression trees, (2) bagging, (3) random forests, and (4) boosting trees.\n\n\\section{Regression Trees}\n\nWe begin by fitting a simple regression tree to the data. We use the \\texttt{rpart} package on the training data set discussed above. The \\texttt{rpart} method returns an object that includes a matrix of the optimal tree prunings. We use this matrix to find the tree complexity parameter that produces the lowest error and prune the tree to this level of complexity. The original tree and pruned tree for a small model (i.e. price on mileage) are depicted in \\cref{fig:tree_small,fig:tree_small_prune}, and it is clear that the pruned model has fewer end nodes than the original model.\n\nBecause the default options on \\texttt{rpart} choose a very simple tree, we lower the minimum split (i.e. smallest number of observations in a node in order for it to be split) from 20 to five, and we lower the complexity parameter from 1/100 to 5/10,000 (which effectively builds more splits into the tree). This produces a more complex model, but one that still does not perform well out-of-sample, especially in comparison to the other algorithms discussed below.\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[b]{0.49\\textwidth}\n \\caption{Small Regression Tree}\n \\includegraphics[width=\\textwidth]{tree_small.pdf}\n \\label{fig:tree_small}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.49\\textwidth}\n \\caption{Small Regression Tree (Pruned)}\n \\includegraphics[width=\\textwidth]{tree_small_prune.pdf}\n \\label{fig:tree_small_prune}\n  \\end{subfigure}\n \\caption{Comparison of Small Regression Tree Models}\n\\end{figure}\n\n\\section{Bagging}\n\nIn this section, we use an aggregate bootstrap technique to predict used car sales price. The basic algorithm is:\n\\begin{itemize}\n\\item For a given number of trials $T$:\n\\begin{itemize}\n\\item Select a bootstrap sample from the data and fit a large regression tree on this sample (in this case we take large to mean a tree that is not pruned);\n\\item Use the large tree to make a prediction for expected price;\n\\end{itemize}\n\\item Take an average of the predicted price across all trials.\n\\end{itemize}\n\nUltimately, as we will see, the bagging algorithm does not perform very well relative to the boosting tree, the random forest, and the LASSO regression. \n\n\\section{Random Forest}\n\nIn this section, we try to predict car price with a random forest algorithm. The main difference between the algorithm here and that in the prior section is that for each tree, instead of estimating based on the entire set of covariates, we estimate only on a subset $m$ of covariates. This makes the algorithm train more quickly and introduces another layer of randomness into our predictions. \n\nWe chose a value of $m=3$, which produced the best set of out-of-sample RMSE values. We also chose to stop the algorithm after 250 trees, as the predictive performance (measured by out-of-bag RMSE) fails to improve after this point (see \\cref{fig:rf_oob_mse}). In order to speed up performance even more, we can also divide our intended number of trees (250) by the number of processors available (eight, in this case). We then build each small forest on a separate processor, combine the eight forests at the end into one larger forest and use this final combined forest to predict car price.\n\nThe random forest algorithm ends up performing very well, nearly beating the best-in-class performance of the boosting tree.\n\n\\begin{figure}[!htb]\n  \\centering\n  \\caption{Out-of-Bag Mean Square Error by Number of Trees}\n  \\includegraphics[scale=.5]{rf_oob_mse.pdf}\n  \\label{fig:rf_oob_mse}\n\\end{figure}\n\n\\section{Boosting Trees}\n\nIn this section, we predict the car price using boosting trees.  As discussed in class, boosting trees are subtly different than the other algorithms discussed.  Just as in the random forest model, the end result is a forest of trees; however, the set of trees are fit on the residuals leftover from all previous passes through upstream shrunken trees.  There are three main parameters that we can choose when fitting such a forest:\n\\begin{itemize}\n\\item Crush factor ($\\lambda)$ - amount to truncate each tree;\n\\item  Interaction depth (d) - a maximum size (proxy for complexity) of each tree;\n\\item  \\# of trees (B) - the maximum number of trees in the forest.\n\\end{itemize}\n\nThe complexity in choosing these values is that, done properly, we would need to minimize our validation sample's RMSE by optimizing these three parameters simultaneously.  This quickly becomes a difficult convex optimization problem which is outside the scope of this assignment and course.  However, in the interest of choosing some reasonable values, we move forward by fixing two of the three values to some reasonable choice, sweeping the third, and iterating until we find something that approximates the ``best'' model available (or at least what looks like a local minima).\n\nFor the remainder of this section we confine ourselves to choosing optimal parameters for a ``large'' model consisting of all covariates.  First we set the nominal parameters to $\\lambda=0.11$, $d=16$, and $B=50$, then one of these values is swept to see its effect on the RMSE; \\cref{fig:gbm_shrink,fig:gbm_indepth,fig:gbm_ntree} shows the results of these sweeps (each averaged 100 times).  We note a large amount of sample noise, even with a relatively large averaging size, and therefore chose to employ a technique similar to the model selection rules present in the gamma lasso model.\n\nTo avoid over-fitting our data (which introduces variance), we first find the parameter choice that minimizes the validation RMSE and then calculate the variance it exhibits over all 100 runs.  Next we find the parameter choice that yields an RMSE 1-$\\sigma$ worse that this minimum.  In the figures, the minimum is shown as the dotted line in each of these figures with the solid line indicating the 1se rule.  In each case this chooses a simpler model that is less prone to overfitting, yet still yields exceptional RMSE performance.\n\nOur optimal choice of parameters was found after many iterations from an initial set to be the nominal ones used to produce \\cref{fig:gbm_shrink,fig:gbm_indepth,fig:gbm_ntree}.  Therefore, these parameters will be used to fit our final model.\n\nAs we will see in the final section, even though this algorithm is difficult to tune, it has the best RMSE performance.\n\n% boost.ntree = 50\n% boost.indepth = 16\n% boost.shrink = 0.11\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[b]{0.44\\textwidth}\n    \\caption{Crush Factor $\\lambda$}\n    \\includegraphics[width=\\textwidth]{gbm_shrink.pdf}\n    \\label{fig:gbm_shrink}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.44\\textwidth}\n    \\caption{Interaction Depth}\n    \\includegraphics[width=\\textwidth]{gbm_indepth.pdf}\n    \\label{fig:gbm_indepth}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.44\\textwidth}\n    \\caption{\\# number of Trees Paramter}\n    \\includegraphics[width=\\textwidth]{gbm_ntree.pdf}\n    \\label{fig:gbm_ntree}\n  \\end{subfigure}\n  \\caption{Optimal Tuning Parameters of Boosting Trees}\n\\end{figure}\n\n\\section{LASSO Regression}\nIn this section we use the linear regression to create a model we can compare to the trees we have been developing.  Do do this, we turn to the gamma-lasso regression.\n\nWe recognize pretty quickly that without adding interaction terms, the linear regression will perform terribly, so to make the comparison a little fairer, we add a single-layer of interactions (allowing each covariate to have an effect on another).  Also, because we found that the histogram of prices was not as ``normally'' distributed as we would have liked, we use a logarithm to transform it a bit.  Finally, we perform model selection using a 5-fold cv-gamma lasso with the ``1se'' selection criteria.  See \\cref{fig:lin_reg} for a plot of the lasso run; note that the right-most vertical line in the plot is the ``1se'' $\\lambda$.\n\nAs it turns out, this model actually holds its own quite well and is a strong contender in the top-3 spot (behind boosting trees and random forests).\n\n\\begin{figure}[!htb]\n  \\centering\n  \\caption{Trace of Gamma-Lasso Run for Linear Regressive Model}\n  \\includegraphics[scale=.5]{lin_reg_interaction.pdf}\n  \\label{fig:lin_reg}\n\\end{figure}\n\n\\section{Comparison and Out-of-Sample Test}\n\nIn \\cref{tab:rmse_comp}, we list the out-of-sample RMSE of each model for the validate data set. The models denoted by ``large'' are those trained on the entire set of covariates; those denoted by ``small'' are trained only on the mileage series.\n\nThe best performing model is the large boosting tree model, followed very closely by the large random forest model and the large LASSO regression model. All three models perform similarly, although we note that the boosting tree model was the most difficult to tune. In a production environment, deciding which model to employ would depend not only on RMSE performance but on computational expense. Because the three models mentioned above all perform so closely, we will look more closely at the out-of-sample RMSE produced by the test set (the unused 25\\% of our data-set) to make a final judgement.\n\nThe results of this out-of-sample test are shown in \\cref{tab:rmse_test}. Two things are clear. The first is that the \\textit{true} out-of-sample RMSE for all three models is very close to our expected out-of-sample RMSE (which was based on the validation data set). The second is that the order of performance of the models didn't change: the finely tuned boosting tree still narrowly out-performs the random forest in the true out-of-sample test. However, it is worth noting that the difference between the two models is almost imperceptible.  This suggests that at the margin, we can differentiate what is the ``best'' model by other factors like tractability and computational expense, and out-of-sample performance will not suffer much as a result.\n\n\\input{rmse_comp}\n\n\\input{rmse_test}\n\n\\end{document}\n\n% \\input{.tex}\n\n% \\begin{figure}\n%   \\centering\n%   \\begin{subfigure}[b]{0.49\\textwidth}\n%     \\caption{}\n%     \\includegraphics[width=\\textwidth]{.pdf}\n%     \\label{fig:}\n%   \\end{subfigure}\n%   \\hfill\n%   \\begin{subfigure}[b]{0.49\\textwidth}\n%     \\caption{}\n%     \\includegraphics[width=\\textwidth]{.pdf}\n%     \\label{fig:}\n%   \\end{subfigure}\n%   \\caption{}\n% \\end{figure}\n\n% \\begin{figure}[!htb]\n%   \\centering\n%   \\caption{}\n%   \\includegraphics[scale=.5]{.pdf}\n%   \\label{fig:}\n% \\end{figure}\n\n", "meta": {"hexsha": "2eca7097a4035c10a443015ce20d9d54ec54dc79", "size": 11790, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw3/writeup/hw3.tex", "max_stars_repo_name": "wclark3/machine-learning", "max_stars_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw3/writeup/hw3.tex", "max_issues_repo_name": "wclark3/machine-learning", "max_issues_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw3/writeup/hw3.tex", "max_forks_repo_name": "wclark3/machine-learning", "max_forks_repo_head_hexsha": "f4f09d6d1efa022d9c34647883e49ae8e2f1fe6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-02-23T00:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-18T13:16:58.000Z", "avg_line_length": 66.6101694915, "max_line_length": 753, "alphanum_fraction": 0.7682782019, "num_tokens": 2944, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.41481702540712667}}
{"text": "\\documentclass[a4paper, draft]{article}\n\\pagestyle{headings}\n\n\\title{Phase estimation, simulation and matrix inversion}\n\n\\usepackage{amsmath,amsthm, amsfonts,amscd, amssymb}\n\\usepackage{array}\n\\usepackage{caption}\n\\usepackage{url}\n\\usepackage[final]{graphicx}\n\n\n\n% Numbering\n\n%\\numberwithin{section}{chapter}\n%\\numberwithin{equation}{chapter}\n\n% Theorem environments\n\n%% \\theoremstyle{plain} %% This is the default\n\\newtheoremstyle{own}\n    {3pt}                    % Space above\n    {3pt}                    % Space below\n    {\\itshape}                   % Body font\n    {}                           % Indent amount\n    {\\scshape}                   % Theorem head font\n    {.}                          % Punctuation after theorem head\n    {.5em}                       % Space after theorem head\n    {}  % Theorem head spec (can be left empty, meaning ‘normal’)\n    \n\\theoremstyle{own}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem{ax}{Axiom}[section]\n\n%% \\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\n%% \\theoremstyle{remark}\n\\newtheorem{rem}{Remark}[section]\n\\newtheorem*{notation}{Notation}\n\\theoremstyle{remark}\n\\newtheorem*{example}{Example}\n\n% Fix alignments\n\n% \\setlength{\\parindent}{0.5cm}\n\n\n%  Math definitions\n\n% Fields\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\quat}{\\mathbb{H}}\n\n%Groups \n\\newcommand{\\Lo}{\\mathbf{O}(3,1)}\n\\newcommand{\\SL}{\\mathbf{SL}}\n\\newcommand{\\SU}{\\mathbf{SU}}\n\\newcommand{\\Spin}{\\mathbf{Spin}}\n\\newcommand{\\Pin}{\\mathbf{Pin}}\n\\newcommand{\\SO}{\\mathbf{SO}}\n\\newcommand{\\Poincare}{\\mathcal{P}}\n\\newcommand{\\Poincarecov}{\\widetilde{\\mathcal{P}}}\n\\newcommand{\\Poincareprop}{\\widetilde{\\mathcal{P}}_+^{\\uparrow}}\n\\newcommand{\\Aut}{\\mathrm{Aut}}\n\n% Rings\n\\newcommand{\\End}{\\mathrm{End}}\n\\newcommand{\\CCl}{\\mathbb{C}\\mathrm{l}}\n\\newcommand{\\Cl}{\\mathrm{Cl}}\n\\newcommand{\\Mat}{\\mathrm{Mat}}\n\n% Lie algebras\n\n\\newcommand{\\spin}{\\mathfrak{spin}}\n\\newcommand{\\so}{\\mathfrak{so}}\n\\newcommand{\\su}{\\mathfrak{su}}\n\\newcommand{\\slc}{\\mathfrak{sl}}\n\n%Three-vectors\n\\newcommand{\\xt}{\\mathbf{x}}\n\\newcommand{\\yt}{\\mathbf{y}}\n\\newcommand{\\pt}{\\mathbf{p}}\n\\newcommand{\\nt}{\\mathbf{n}}\n\\newcommand{\\sigmat}{\\mathbf{\\sigma}}\n\n% Vector spaces\n\\newcommand{\\Hil}{\\mathcal{H}}\n\n% Other\n\\newcommand{\\calE}{\\mathcal{E}}\n\\newcommand{\\calD}{\\mathcal{D}}\n\\newcommand{\\calF}{\\mathcal{F}}\n\\newcommand{\\calP}{\\mathcal{P}}\n\\newcommand{\\Fock}{\\mathcal{F}}\n\\newcommand{\\Op}{\\mathrm{Op}}\n\\newcommand{\\equalsoalpha}{\\stackrel{\\mathcal{O}(\\alpha)}{=}}\n\\newcommand\\smallO{\n  \\mathchoice\n    {{\\scriptstyle\\mathcal{O}}}% \\displaystyle\n    {{\\scriptstyle\\mathcal{O}}}% \\textstyle\n    {{\\scriptscriptstyle\\mathcal{O}}}% \\scriptstyle\n    {\\scalebox{.7}{$\\scriptscriptstyle\\mathcal{O}$}}%\\scriptscriptstyle\n  }\n\n\\DeclareMathOperator{\\per}{per}\n\\DeclareMathOperator{\\sign}{sgn}\n\n\\begin{document}\n\\maketitle\n\n\nEven though quantum algorithms have been an area of active and very intense research for more than twenty years, it is probably valid to say that most quantum algorithms can be considered as variations over a few central themes. One of these themes is the {\\bf quantum phase estimation}, a procedure introduced in the mid nineties of the last century, that is designed to discover eigenvalues and eigenstates of unitary operators. Since its first appearance in \\cite{Kitaev}, this procedure has not only been employed in some groundbreaking algorithms like quantum matrix inversion and quantum machine learning, but has also turned out to be related to existing algorithms like Shor's famous algorithm for factoring large integers. In these notes, we describe the quantum phase estimation algorithm and explore some of its applications.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Quantum phase estimation\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Quantum Phase estimation}\\label{sec:qpe}\n\nIn its simplest form, the {\\bf quantum phase estimation algorithm} is concerned with the following problem (\\cite{CleveEkert}). We are given a unitary operator $U$ acting on $n$ qubits, and suppose that $|\\psi \\rangle$ is an eigenvector of $U$. As $U$ is unitary, we know that the modulus of the eigenvalue is one, i.e. the eigenvalue is of the form $e^{i2\\pi \\Phi}$ with some $0 \\leq \\Phi < 1$. In other words, the eigenvalue is a pure phase factor. The objective of the algorithm is to estimate the phase, i.e. to find an approximation $\\Phi$. \n\nTo do this, we need to add $m$ additional qubits to our quantum register, where $m$ is a number chosen arbitrarily - we will see later that $m$ determines the precision of the result. We will write the combined states as tensor products\n$$\n|a \\rangle |b \\rangle\n$$\nwhere $|a \\rangle$ lives in the space spanned by the $m$ ancillary qubits and $|b \\rangle$ is the primary n-qubit quantum register. We then prepare the system in the state \n\\begin{align}\\label{eq:qpesuperposition}\n\\frac{1}{\\sqrt{2}^m} \\sum_{k = 0}^{2^m - 1} e^{2i\\pi k \\Phi} |k \\rangle |\\psi \\rangle = \\frac{1}{\\sqrt{2}^m} \\sum_{k = 0}^{2^m - 1}  |k \\rangle U^k |\\psi \\rangle\n\\end{align}\n\nBefore we proceed, let us see how this can be implemented as a quantum circuit. Consider the combination of gates  shown in figure \\ref{fig:QPECircuit}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/QPECircuit}\n\\caption[Quantum phase estimation circuit]{Quantum phase estimation circuit}\n\\label{fig:QPECircuit}\n\\end{figure}\n\nTo see why this gate produces the state that we need, let us first analyse the first (least significant) qubit of the ancillary register. Ignoring all other qubits for a moment, the state after applying the Hadamard gate will be\n$$\n\\frac{1}{\\sqrt{2}} \\big[ |0\\rangle |\\psi \\rangle + |1 \\rangle |\\psi \\rangle \\big] \n$$\nApplying the controlled-U operation and observing that the state $|\\psi \\rangle$ is an eigenstate for $U$, we find that the state after the controlled-U gate is\n$$\n\\frac{1}{\\sqrt{2}} \\big[ |0\\rangle |\\psi \\rangle + e^{2i\\pi \\Phi}|1 \\rangle |\\psi \\rangle \\big] \n$$\nDoing the same exercise for the second ancillary qubit yields \n$$\n\\frac{1}{\\sqrt{2}} \\big[ |0\\rangle |\\psi \\rangle + e^{2i\\pi 2^1 \\Phi}|1 \\rangle |\\psi \\rangle \\big] \n$$\nand so forth. Thus after applying the entire circuit, the overall state is\n$$\n\\frac{1}{\\sqrt{2}^m} \\prod_{j=0}^{m-1} (|0 \\rangle + e^{2i \\pi 2^j \\Phi} |1 \\rangle ) |\\psi \\rangle\n$$\nIf we multiply this out, every possible m-bit string will appear exactly one, and we obtain the state \\eqref{eq:qpesuperposition}. \n\nNow let us examine this superposition in a bit more detail. To do this, let us first consider the special case that the number $\\Phi$ is an exact multiple of $2^{-m}$, i.e.\n$$\n\\Phi = \\frac{t}{N}\n$$\nwhere $N = 2^{m}$. Then our state can be written as\n\\begin{align*}\n\\frac{1}{\\sqrt{N}} \\sum_{k = 0}^{N - 1} e^{2i\\pi \\frac{kt}{N}} |k \\rangle |\\psi \\rangle\n\\end{align*}\nBut this looks familiar - it is just the inverse quantum Fourier transform applied to the state $|t \\rangle |\\psi \\rangle$. This implies that we can recover the number $t$ and with it the phase by applying the Fourier transform to our superposition. In other words, for the special case that $\\Phi$ can be written exactly as a fraction with m bits, the following algorithm - the {\\bf quantum phase estimation algorithm} will work.\n\n\\begin{enumerate}\n\t\\item Start with the state  $|0 \\rangle |\\psi \\rangle$ where $|\\psi \\rangle$ is an aigenstate of $U$\n\t\\item Apply the circuit shown in figure \\ref{fig:QPECircuit} to build the state \\eqref{eq:qpesuperposition}\n\t\\item Apply an  quantum Fourier transform\n\t\\item Measure the first register and call the result $t$. \n\t\\item Return $e^{2\\pi i \\frac{t}{N}}$\n\\end{enumerate}\n\nThus, in this special case, the entire transformation - applying the circuit in figure \\ref{fig:QPECircuit} followed by the quantum Fourier transform - performs the mapping\n$$\n|0 \\rangle \\psi \\rangle \\mapsto | N \\Phi \\rangle |\\psi \\rangle\n$$\nand thus extracts the phase $\\Phi$.\n\nFortunately, it turns out that this is still approximately true if $\\Phi$ is not an exact multiple of $2^{-m}$. To see why this is the case, let us calculate, in the general case, the result of applying the inverse quantum Fourier transform to the state \\eqref{eq:qpesuperposition}. Recall that the  quantum Fourier transform acts as follows.\n\n$$\n|k \\rangle \\mapsto \\frac{1}{\\sqrt{N}} \\sum_{s=0}^{N-1} e^{2\\pi i \\frac{-sk}{N}} |s \\rangle\n$$\n\nTherefore, after applying the  quantum Fourier transform, our quantum registers will be in the following state\n\n$$\n\\frac{1}{2^m} \\sum_{s,k=0}^{N-1} e^{2\\pi i k(\\Phi - \\frac{s}{N})} |s \\rangle |\\psi \\rangle\n$$\n\nNow let $t$ the the closest m-bit approximation to the actual phase $\\Phi$. In other words, let us write\n$$\n\\Phi = \\frac{t}{N} + \\delta\n$$\nwith $|\\delta| < \\frac{1}{2N}$. By passing from $\\Phi$ to \n$1 - \\Phi$ if needed (which describes the same eigenvalue), we can also assume that $0 \\leq \\delta$. With that, we can write our state as\n\n$$\n\\frac{1}{2^m} \\sum_{s,k=0}^{N-1} e^{2\\pi i \\frac{k}{N}((t-s) + \\delta N)} |s \\rangle |\\psi \\rangle\n$$\n\nThe sum over $s$ can actually be considered as a sum over the group $\\Z / N\\Z$, as the arguments are periodic with period $N$. Now any element of this group can be obtained as the residue of $t - l$ with exactly one  $-\\frac{N}{2} \\leq l < \\frac{N}{2}$. Therefore our state can as well be written as\n\n$$\n  \\sum_{- \\frac{N}{2} \\leq l < \\frac{N}{2}} \\sum_{k=0}^{N-1} \\frac{1}{2^m} e^{2\\pi i \\frac{k}{N}(l + \\delta N)} | t - l \\, \\text{mod} N \\rangle |\\psi \\rangle\n=\n\\sum_{- \\frac{N}{2} \\leq l < \\frac{N}{2}} a_l | t - l \\, \\text{mod} N \\rangle |\\psi \\rangle\n$$\nwhere the coefficient $a_l$ is given by\n$$\na_l = \\sum_{k=0}^{N-1} \\frac{1}{2^m} e^{2\\pi i \\frac{k}{N}(l + \\delta N)}\n$$\nor, using the sum formula for a geometric series and the fact that the term $2\\pi i l$ drops out due to the periodicity\n$$\na_l = \\frac{1}{N} \\frac{1 - e^{2\\pi i \\delta N}}\n{1 - e^{2\\pi i (\\frac{l}{N} + \\delta) }}\n$$\nIntuitively, we expect that, as a function of $l$, this has a very sharp peak at $l = 0$, so that the probability to measure a value that differs significantly from $t$ is very low. In fact, one can show (see \\cite{CleveEkert} and appendix \\ref{app:successprobability}) that given some $\\epsilon >0 $ and some $\\Delta > 0$, we can always make sure that the probability to measure a value that deviates by more than $\\Delta$ from $t$ is less than $\\epsilon$ if we choose $m$ sufficiently large. In this sense, the number $m$ of ancillary qubits that we use is driving the precision of the algorithm.\n\nLet us visualize the behavior of the amplitudes $a_l$ for different values of $N$. We know (see appendix \\ref{app:estimates}) that we have the relation\n$$\n| 1- e^{i\\Phi}| = 2 \\sin \\frac{\\Phi}{2}\n$$\nwhich we can use to write\n$$\n|a_l|^2 = \\frac{1}{N^2} \\frac{\\sin^2 \\pi \\delta N}{\\sin^2 \\pi (\\frac{l}{N} + \\delta)}\n$$\nwhich is of course only valid if $\\delta \\neq 0$, as otherwise the sum formula for the geometric series that we have used does not apply. \n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/Amplitudes}\n\\caption[Amplitudes $a_l$ for different values of N]{Amplitudes $a_l$ for different values of N}\n\\label{fig:Amplitudes}\n\\end{figure}\n\nIn diagram \\ref{fig:Amplitudes}, we have plotted the amplitudes $a_l$ for different values of $N$ and $d=\\frac{1}{2N}$ (which is the worst case as the actual value of $\\Phi$ is exactly between two m-bit numbers in this case). The x-axis shows the absolute error that we make, i.e. $\\frac{|s-t|}{N}$. The y-axis shows the probability for this error. \n\nThe upper image shows $N=8$, corresponding to three ancillary qubits. We see a clear peak at $l=0$, but $l=-1$ has the same probability to be measured, and there is still some substantial amplitude at  $-0.2$. However, this changes quickly if we increase the number of ancillary qubits. The second diagram shows the results for the same choice $d = \\frac{1}{2N}$, but this time we are using eight qubits and therefore $N=256$. We see that the peak has become extremely sharp, and the probability to make an error of $-0.2$ is now virtually zero. Thus increasing the number of ancillary qubits leads very quickly to a high probability to obtain a very accurate result. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Finding eigenvectors\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Finding eigenvectors}\\label{sec:eigenvectors}\n\nIn the previous section, we have seen how the quantum phase estimation algorithm can be used to determine the eigenvalue of a given eigenstate $|\\psi \\rangle$. However, quite often we are not able to prepare the system in a pure eigenstate and are looking for a way to find both an eigenstate and the corresponding eigenvalue. It turns out that the QPE algorithm does that for us without any modifications.\n\nIn fact, let us now assume that we are given an arbitrary state $|\\psi \\rangle$. We do not know whether $|\\psi \\rangle$ is an eigenstate, but what we know by general linear algebra is that we can write $|\\psi \\rangle$ as a linear combination\n$$\n|\\psi \\rangle = \\sum_j c_j |\\psi_j \\rangle\n$$\nwhere each $|\\psi_j \\rangle$ is an normalized eigenstate with eigenvalue $e^{2\\pi i \\Phi_j}$, $c_j \\in \\R^+$ and the eigenvalues are all distinct. In particular, the $|\\psi_j \\rangle$ are orthonormal (but not necessarily a basis, as some eigenspaces might be degenerate). In fact, the $c_j |\\psi_j \\rangle$ are simply the non-zero projections of $|\\psi \\rangle$ onto the eigenstates of $U$.\n\nWhat happens to such a state when we apply the quantum phase estimation algorithm? Both the circuit shown in diagram \\ref{fig:QPECircuit} as well as the inverse quantum Fourier transform are of course linear operations. If $\\Phi_j$ is the phase corresponding to the eigenstate $|\\psi_j \\rangle$ and we again choose best approximations\n$$\n\\Phi_j = \\frac{t_j}{N} + \\delta_j\n$$\nthen, by linearity, we can write the state after applying the  Fourier transform as\n$$\n\\frac{1}{2^m} \\sum_j \\sum_{s=0}^{N-1} \n\\big[ \\sum_{k=0}^{N-1} c_j e^{2\\pi i \\frac{k}{N}((t_j-s) + \\delta N)}\\big] |s \\rangle |\\psi_j \\rangle\n$$\nor\n$$\n\\sum_j \\sum_{s=0}^{N-1} \nc_j a_{j,s} |s \\rangle |\\psi_j \\rangle\n$$\nwhere now\n$$\na_{j,s} = \\frac{1}{2^m}   \\sum_{k=0}^{N-1}  e^{2\\pi i \\frac{k}{N}((t_j-s) + \\delta N)}\n$$\nBut we already know that for sufficiently large $N$, the sum in this expression will have a very sharp peak around $s = t_j$. Thus, only those combinations of $j$ and $s$ for which $s \\approx t_j$ will have a substantial amplitude, and this amplitude will be close to $c_j$. \n\nIf we now measure the first register only, the system will end up in a state which is very close to one of the states $|t_j \\rangle |\\psi_j \\rangle$. Thus, after the measurement, the second register will aproximately be in one of the eigenstates $|\\psi_j \\rangle$, and the probability to obtain a specific $|\\psi_j \\rangle$ in this way is $|c_j|^2$. \n\n\nLet us now try to make this intuition a bit more precise. After applying the Fourier transform, our state is\n$$\n\\sum_j \\sum_{s=0}^{N-1} \nc_j a_{j,s} |s \\rangle |\\psi_j \\rangle\n$$\nThe amplitudes depend on the two degrees of freedom described by $s$ and $j$. Let us now choose some large values of $d$ and $N$ such that $\\frac{d}{N}$ is much smaller than the minimum distance between any two eigenvalues. If we now plot the possible combinations of $s$ and $j$ in a plane, we have a situation as shown in figure \\ref{fig:QPEigenstates}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/QPEigenstates}\n\\caption[Amplitudes on the (j,s)-lattice]{Amplitudes on the (j,s)-lattice}\n\\label{fig:QPEigenstates}\n\\end{figure}\n\nHere each horizontal line represents one different possible of $j$, i.e. one of the $|\\psi_j \\rangle$. The parentheses at each line mark the interval of size $2d$ around $\\Phi_j N$, i.e. \"good\" values of $s$ close to $\\Phi_j N$. The shaded areas are \"bad\" areas, i.e. values of $s$ outside this range.  \n\nFrom our previous consideration, we know that if we sum up the squares $|a_{s,j}|^2$ for a given value of $j$, i.e. along a horizontal line, and for the values of $s$ in the shaded areas, the result will be less at most $\\frac{1}{d}$. Let us now use this to find the probability that the measured value of $s$ has a distance of more than $d$ from one of the $\\Phi_j N$, i.e. would be in the shaded area on the x-axis of our diagram. The probability for measuring one such $s$ is obtained by adding up the probabilities along $j$ for each $s$ in the shaded area, i.e. the squared amplitudes for all combinations of $j$ and $s$ which are located in the vertical stripes labeled A - E.\n\nClearly, this is less than the sum over \\emph{all} amplitudes in the shaded area, i.e. bounded above by\n$$\n\\sum_{j, s \\, \\text{shaded}} |c_j|^2  |a_{s,j}|^2 \\leq \\sum_j |c_j|^2 \\frac{1}{d} = \\frac{1}{d}\n$$\nwhere we have assumed that our state is normed so that $\\sum_j |c_j|^2 = 1$. Therefore, we again obtain that the probability to obtain a \"bad\" outcome which is not close to one of the $\\Phi_j N$ is at most $\\frac{1}{d}$, which we can make again arbitrarily small by choosing large values of $d$ and $N$.\n\nNow suppose that we have measured and obtained a \"good\" value $s_0$, close to some $\\Phi_{j_0} N$. After the measurement, the state will be\n$$\n\\sum_j  \nc_j a_{j,s_0} |s_0 \\rangle |\\psi_j \\rangle\n$$\nWe see that there are contributions from values of $j$ other than $j_0$. But again, for all of those $j$, the index $(s_0, j)$ is in the shaded area. Therefore each individual squared amplitude is bounded from above by $|c_j|^2 \\frac{1}{d}$, and we can estimate\n$$\n\\sum_{j \\neq j_0} |c_j a_{j,s_0}|^2 \\leq \\sum_{j \\neq j_0} |c_j|^2 \\frac{1}{d} \\leq \\frac{1}{d} \\sum_j |c_j|^2 = \\frac{1}{d}\n$$\nThis implies that the contribution of the $|\\psi_j \\rangle$ for $j \\neq j_0$ is small for large $d$, and in this sense, the state is close to an eigenvector with eigenvalue $\\Phi_{j_0}$. \n\nThe upshot of this discussion is that the quantum phase estimation does not only allow us to find the \\emph{eigenvalue}, starting with an eigenstate, but can also put the system into an approximate \\emph{eigenstate} and at the same time tell us the corresponding eigenvalue. If the initial state $|\\psi \\rangle$ was already close to an eigenstate, i.e. if one of the $c_j$ dominates, we will most likely end up close to $|\\psi_j \\rangle$. If, on the other hand, the $c_j$ are in the same range, then we will pick one of the eigenstates $|\\psi_j \\rangle$ according to an almost uniform distribution. \n\nAs pointed out in \\cite{AbramsLloyd}, this fact can be used to find the energy eigenvalues and eigenstates of a Hamiltonian. The situation considered in this application is as follows. We are given a quantum system whose state space is finite dimensional and has been mapped in the Hilbert space of a quantum register. The time evolution of this system is described by a hermitian matrix $H$ called the {\\bf Hamiltonian}. We are interested in finding the eigenvectors and eigenvalues of $H$.\n\nGiven some time period $t$, the laws of quantum mechanics tell us that the unitary operator that describes how a state transforms in the time period $t$ is given as\n$$\nU(t) = e^{-\\frac{i}{\\hbar}Ht}\n$$\nNow if $\\lambda$ is an eigenvalue of $H$ with eigenstate $|\\psi \\rangle$, then of course $e^{i\\lambda t}$ is an eigenvalue of $U(t)$ with eigenstate $|\\psi \\rangle$ and vice versa. More precisely, given an eigenvalue of $U(t)$, we can reconstruct the corresponding eigenvalue of $H$ up to multiples of $\\frac{h}{t}$. \n\nThe idea is now to apply the quantum phase estimation algorithm to find the eigenvalues of $U$ which will also yield an eigenstate of the Hamiltonian. If we are working in a low energy regime, chances are that the overlap of the initial state with the ground state is bigger than that with any excited state, so that we have good reasons to hope that this procedure will give us the ground state of the Hamiltonian which is of particular interest.\n\nTo be able to efficiently apply the quantum phase estimation, we need a way to implement the unitary operations $U(t)^{2^j}$. Now the first observation we can make is that\n$$\nU(t)^{2^j} = U(2^j t)\n$$\nso that if we can implement $U(t)$ for arbitrary $t$ efficiently, we can also implement the needed powers efficiently. \n\nNow let us suppose that our Hamiltonian can be written as a sum of hermitian matrices each of which can be efficiently implemented, for instance because it only acts on a small subspace, i.e.\n$$\nH = \\sum_i H_i\n$$\nwith efficiently implementable $H_i$. Then the Trotter-formula gives us an approximation\n$$\ne^{-iHt} \\approx \\big[ \\prod e^{-iH_i \\frac{t}{n}} \\big]^n\n$$\nso that we can apply $U(t)$ approximately by applying each of the operators $e^{-iH\\frac{t}{n}}$ in turn and repeating this $n$ times, for some large value of $n$, see \\cite{Lloyd} for a more detailed analysis. This does in fact apply to a very large and rich class of Hamiltonians which are of practical interest. For these Hamiltonians, we can therefore implement the $U(t)$-operations and their powers efficiently and therefore carry out the quantum phase estimation algorithm even for a large number of qubits to obtain energy eigenstates. This algorithm is sometimes considered to be a form of {\\bf simulation} of the original system that will yield an energy eigenstate, because applying $U(t)$ simulates the time evolution of the original system. \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% QPE and Shor's algorithm\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{QPE and Shor's algorithm}\n\nIn this section, we will see that there is an intimate relation between the quantum phase estimation and Shor's algorithm for integer factorization, an observation which was first made in \\cite{Kitaev}.\n\nTo describe this relation, let us first recall the problem which is at the heart of Shor's factoring algorithm - finding the period. Specifically, suppose we are given a large integer $M$ and a number $a$ which is a unit in $\\Z/M\\Z$. We want to find the period $r$, i.e. the smallest number such that $a^r =1 \\mod M$. \n\nAs $a$ is a unit, multiplication by $a$ is a permutation of the elements of the group $\\Z / n\\Z$. Therefore, the linear operator $U$ defined by\n$$\nU |x \\rangle = |a x \\, \\text{mod} M \\rangle\n$$\nfor $0 \\leq x < M$ and trivially on all other members of the computational basis is a unitary operator (here we need a sufficiently large number of qubits to represent $M$).\n\nMoreover, one can also write down eigenvectors for this operator. In fact, for any integer $0 < k < r$, the state\n$$\n|\\psi_k \\rangle = \\sum_{s=0}^{r-1} e^{2\\pi i \\frac{sk}{r}} |a^s \\, \\text{mod} M \\rangle\n$$\nis an eigenvector. To see that this is true, let us apply $U$ to it. We have \n$$\nU  |\\psi_k \\rangle = \\sum_{s=0}^{r-1} e^{2\\pi i \\frac{sk}{r}}\n|a^{s+1} \\, \\text{mod} M\\rangle \n$$\nNow let us shift the summation index by one and handle the last term separately. We find that\n$$\nU  |\\psi_k \\rangle = \\sum_{s=1}^{r-1} e^{2\\pi i \\frac{(s-1)k}{r}}\n|a^s \\, \\text{mod} M\\rangle  + e^{2\\pi i \\frac{(r-1)k}{r}} |1 \\rangle\n$$\nBut this is the same as\n$$\nU  |\\psi_k \\rangle = e^{-2\\pi i \\frac{k}{r}} \\sum_{s=1}^{r-1} e^{2\\pi i \\frac{sk}{r}}\n|a^s \\, \\text{mod} M\\rangle  + e^{-2\\pi i \\frac{k}{r}} |1 \\rangle\n$$\nso that we eventually find that\n$$\nU  |\\psi_k \\rangle = e^{-2\\pi i \\frac{k}{r}} \\sum_{s=0}^{r-1} e^{2\\pi i \\frac{sk}{r}}\n|a^s \\, \\text{mod} M\\rangle   = e^{-2\\pi i \\frac{k}{r}} |\\psi_k \\rangle\n$$\nThis shows that $|\\psi_k \\rangle$ is an eigenstate of $U$ with eigenvalue $\\exp(-2\\pi i \\frac{k}{r})$. Now of course this raises hope. If we could use the phase estimation algorithm to estimate $\\frac{k}{r}$, we could again try to use continued fractions as in Shor's algorithm to find the period $r$. \n\nUnfortunately, it is not obvious how we could prepare the system in one of the states $|\\psi_k \\rangle$, given that we do not know $r$. But let us see what happens if we sum up all these states. We find that\n\\begin{align*}\n\\sum_{k=0}^{r-1} |\\psi_k \\rangle &= \\sum_{k=0}^{r-1} \\sum_{s=0}^{r-1} e^{2\\pi i \\frac{sk}{r}} |a^s \\, \\text{mod} M \\rangle \\\\\n&= \\sum_{s=0}^{r-1}  \\sum_{k=0}^{r-1} \\big[ e^{2\\pi i \\frac{s}{r}} \\big]^k  |a^s \\, \\text{mod} M \\rangle \n= \\sum_{s=0}^{r-1}  \\sum_{k=0}^{r-1} q_s^k  |a^s \\, \\text{mod} M \\rangle\n\\end{align*}\nwhere\n$$\nq_s^k =  e^{2\\pi i \\frac{s}{r}}\n$$\nSo again, we find that the sum is in fact a geometric series. If $s=0$, the series adds up to $r$. For all other values of $s$, however, we have that\n$$\n\\sum_{k=0}^{r-1} q_s^k = \\frac{1 - q_s^r}{1-q_s} = 0\n$$\nas $q_s^r = 1$. Therefore\n$$\n\\sum_{k=0}^{r-1} |\\psi_k \\rangle = r |1 \\rangle\n$$\n\nSo we have represented a state that we can easily prepare - the state $|1 \\rangle$ - as a superposition of eigenstates of our operator $U$. We have also seen that given such a superposition, the QPE algorithm will randomly select one of the eigenvalues when we perform the final measurement and leave the system in a state which is - at least approximately - in one of the eigenspaces. Specifically, the measurement will give us a value $s$ such that( with high probability)\n$$\n\\frac{s}{2^m} \\approx \\frac{k}{r}\n$$\nWe are now in exactly the same position as after performing the final measurement in Shor's factoring algorithm - we known $s$ and $m$ and need to determine $k$ and $r$. Thus, we can again use a continued fraction expansion to determine the unknown value of $r$ (at least if $k$ and $r$ are co-prime) and therefore the period.\n\nAt the first glance, it seems that we have found an alternative to Shor's algorithm for finding the period, given by the following sequence of processing steps.\n\n\\begin{enumerate}\n\t\\item Prepare the system in the state $|1 \\rangle$\n\t\\item Apply the circuit shown in figure \\ref{fig:QPECircuit} \n\t\\item Apply a quantum Fourier transform\n\t\\item Measure the first register and call the result $s$. \n\t\\item Perform a continued fraction expansion to determine the period $r$\n\\end{enumerate}\n\nHowever, it turns out - as observed in \\cite{Kitaev} and \\cite{CleveEkert} - that this is more or less identical to Shor's algorithm. In fact, let us look at the state after applying the circuit \\ref{fig:QPECircuit}. We know that the circuit will transform a state $|\\psi \\rangle$ into \n\n$$\n\\frac{1}{\\sqrt{2}^m} \\sum_{k = 0}^{2^m - 1}  |k \\rangle U^k |\\psi \\rangle\n$$\n\nLet us now apply this to the state $|1 \\rangle$ to understand the state of the system after the second step of the algorithm above. We obtain\n\n\\begin{align*}\n\\frac{1}{\\sqrt{N}} \\sum_{k = 0}^{N-1} |k \\rangle U^k |1 \\rangle &=\n\\frac{1}{\\sqrt{N}} \\frac{1}{r} \\sum_{k=0}^{N-1} |k \\rangle \\sum_{s=0}^{r-1} U^k |\\psi_s \\rangle \\\\\n&= \\frac{1}{\\sqrt{N}} \\frac{1}{r} \\sum_{k=0}^{N-1} |k \\rangle \\sum_{s=0}^{r-1} e^{-2\\pi i \\frac{sk}{r}} |\\psi_s \\rangle \\\\\n&= \\frac{1}{\\sqrt{N}} \\frac{1}{r} \\sum_{k=0}^{N-1} \\sum_{s=0}^{r-1} e^{-2\\pi i \\frac{sk}{r}} |k \\rangle \\sum_{t=0}^{r-1} e^{2\\pi i \\frac{ts}{r}} |a^t \\, \\text{mod} M \\rangle \\\\\n&= \\frac{1}{\\sqrt{N}} \\frac{1}{r}  \\sum_{k=0}^{N-1} \\sum_{t=0}^{r-1}    \\big[ \\sum_{s=0}^{r-1}  e^{-2\\pi i \\frac{s(t-k)}{r}} \\big] |k \\rangle |a^t \\, \\text{mod} M \\rangle\n\\end{align*} \n\nNow let us look at the inner sum in this expression. This is again a geometric series, depending on $t-k$. For $t=k \\mod r$, the series adds up to $r$, but for $t \\neq k \\mod r$, the series adds up to zero. Therefore all terms for which $a^t \\neq a^k$ disappear, and we are left with\n\n$$\n\\frac{1}{\\sqrt{N}} \\sum_{k = 0}^{N-1} |k \\rangle U^k |1 \\rangle \n= \n\\frac{1}{\\sqrt{N}} \\sum_{k=0}^{N-1} |k \\rangle |a^k \\, \\text{mod} M \\rangle\n$$\n\nBut this is exactly the state that Shor's algorithm produces right before applying the quantum Fourier transform. Even more, as observed in \\cite{CleveEkert}, the circuit in figure \\ref{fig:QPECircuit} is performing what is called modular exponentiation in Shor's algorithm. Thus we recognize that Shor's factoring algorithm has an interpretation as an instance of the quantum phase estimation algorithm.\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Matrix inversion\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Matrix inversion - the HHL algorithm}\n\n\nLet us now turn to another application of the quantum phase estimation to a problem which is at the heart of numerical linear algebra - inverting a matrix.\n\nMore specifically, let us assume that we are given a hermitian $N \\times N$ matrix $A$ (extensions of the algorithm exists for the non-hermitian case as well) which is invertible, and that we are given a vector $b \\in \\C^N$. We wish to find a vector $x \\in \\C^N$ such that\n$$\nAx = b\n$$ \nDoing this for all vectors of a base amounts to finding the columns of the inverse $A^{-1}$, i.e. solving this problem for arbitrary $b$ is essentially equivalent to finding the inverse of $A$. \n\nThis problem is classically very hard and scales at least linearly in $N$. Even though this does not sound too bad, it is a desaster for many applications as the dimension $N$ itself tends to grow exponentially with the size of the actual underlying problem.\n \nSuppose, for instance, we are given a linear partial differential equation on $\\R^d$. Solving this equation on, say, the unit cube, could be attempted by applying the \\emph{finite difference method}, i.e. by introducing a lattice, describing the function by its values on the lattice points and approximating the partial derivatives by finite differences, which turns the partial differential equation into a matrix equation. If $\\epsilon < 1$ denotes the step size in all dimensions, then the number of lattice points needed grows like $\\epsilon^{-d}$. Thus, the dimension of the underlying vector space grows exponentially with the number of variables $d$, which makes the calculations intractable on classical hardware for large values of $d$.\n\nIt appears natural to ask whether quantum computing can be applied to solve this problem. Late in 2008, A.W.~Harrow, A.~Hassidim and S.~Lloyd presented an algorithm (see \\cite{HHL2009}) that could be used for this purpose. To explain the algorithm, let us assume that the dimension $N$ is a power of two, i.e. $N = 2^m$ for some $m$ - this is not a real restriction, as we can always enlarge our vector space and the matrix $A$ if needed. Then we can represent the vector $b$ as a linear combination\n$$\n|b \\rangle = \\sum_{j=0}^{N-1} b_j |j \\rangle\n$$\nwhere $b_j$ are the coefficients of $b$. The matrix $A$ then defines a transformation on the Hilbert space that we again denote by $A$, and the purpose of the algorithm is to place the system in a state $|x \\rangle$ such that $A |x \\rangle = |b \\rangle$. We will call the quantum register in which this state is prepared the working register.\n\nThe basic idea of the algorithm is to reduce the problem to the case that the matrix $A$ is diagonal in the standard basis. Then, $A$ is acting by multiplication with the eigenvalues, and finding the solution is trivial - we just need to divide each component of $b$ by the respective eigenvalue. The reduction to this case is done using the quantum phase estimation.\n\nSpecifically, let us denote the eigenvalues of $A$ by $\\lambda_j$, where $j = 0, \\dots, N-1$ (i.e. we repeat each eigenvalue according to its multiplicity). After potentially rescaling the matrix $A$, we can also assume that all eigenvalues are between $0$ and $2 \\pi$. \n\nWe start by adding an additional register (called the \\emph{clock register} $C$, for a reason that we will explain in a second) with $k$ qubits in the initial state $|0 \\rangle$. We then pick a time $t_0 < 1$ and consider the operator\n$$\nU = e^{ i A t_0}\n$$\nThen the eigenvalues of $U$ will be $e^{i t_0 \\lambda_j }$, and as $\\lambda_j \\in (0, 2\\pi)$, we can also obtain $\\lambda_j$ from the eigenvalues of $U$ unambiguously.\n\nLet $|\\psi_j \\rangle$ denote an eigenvector of $A$ with eigenvalue $\\lambda_j$. Recall that approximately, i.e. up to a term that we treat as an error term, a quantum phase estimation for the operator $U$ amounts to the transformation\n\\begin{align}\\label{eq:qpetransformation}\n|0 \\rangle |\\psi_j \\rangle \\mapsto |\\tilde{\\lambda_j} \\rangle  |\\psi_j \\rangle\n\\end{align}\nwhere $\\tilde{\\lambda_j}$ is a $k$-bit approximation of \n$$\n\\tilde{\\lambda_j} = \\frac{2^k t_0}{2\\pi} \\lambda_j\n$$\n\nLet us now try to understand how the quantum phase estimation acts on the state $|b \\rangle$. As any state, this state can be written as a superposition of eigenvectors, i.e.\n$$\n|b \\rangle = \\sum_{j=0}^{N-1} \\beta_j |\\psi_j \\rangle\n$$\nfor some complex coefficients $\\beta_j$. Consequently, applying the quantum phase estimation procedure yields the state\n$$\n\\sum_{j=0}^{N-1} \\beta_j |\\tilde{\\lambda}_j \\rangle |\\psi_j \\rangle\n$$\n\nBefore we proceed to explain the remaining part of the algorithm, let us see what we want to do on an intuitive level. We want to divide the coefficient of $|\\psi_j \\rangle$ by $\\lambda_j$ and then \"forget\" the clock register, i.e. we would like to obtain the state\n$$\n\\sum_{j=0}^{N-1} \\frac{\\beta_j}{\\lambda_j}  |\\psi_j \\rangle\n$$\nThis state is in fact the solution $|x \\rangle$ we are looking for, as the matrix $A$ acts on $|\\psi_j \\rangle$ simply as multiplication by the eigenvalue $\\lambda_j$ and thus maps this state onto $|b \\rangle$!\n\nUnfortunately, the division by $\\lambda_j$ is not a unitary operation. But there is a unitary approximation to this operation which works as follows. We add another ancillary register $S$ with one qubit. On this register, we implement a conditional rotation, i.e. a unitary operator realizing the mapping\n$$\n|k \\rangle^C |0 \\rangle^S \\mapsto |k \\rangle^C \\big[  \\sqrt{1 - \\frac{C^2}{k^2}}  |0 \\rangle^S + \\frac{C}{k} |1 \\rangle^S   \\big] \n$$\nfor $k \\neq 0$ - here the upper index indicates the register in which a state is living, and $C$ is a constant that we need to choose. We refer to the appendix \\ref{app:conditionalrotations} or \\cite{Poisson} for details on how this sort of conditional rotations can be realized. After applying this transformation to our full state, we end up with\n$$\n\\sum_{j=0}^{N-1} \\beta_j |\\tilde{\\lambda}_j \\rangle |\\psi_j \\rangle \\big[  \\sqrt{1 - \\frac{C^2}{\\tilde{\\lambda}_j^2}}  |0 \\rangle^S + \\frac{C}{\\tilde{\\lambda}_j} |1 \\rangle^S   \\big] \n$$\nNow we revert the quantum phase estimation, i.e. apply its inverse to realize the inverse of the mapping rule \\eqref{eq:qpetransformation}. This will give us the state\n$$\n\\sum_{j=0}^{N-1} \\beta_j |0\\rangle |\\psi_j \\rangle \\big[  \\sqrt{1 - \\frac{C^2}{\\tilde{\\lambda}_j^2}}  |0 \\rangle^S + \\frac{C}{\\tilde{\\lambda}_j} |1 \\rangle^S   \\big] \n$$\nWe now ignore the clock register (which is again in state $|0 \\rangle$) and measure the ancillary register $S$. With a certain probability, this will yield the outcome $|1\\rangle$ in the register $S$ and therefore leave the working register in a state proportional to\n$$\n\\sum_{j=0}^{N-1} \\frac{\\beta_j}{\\tilde{\\lambda}_j}  |\\psi_j \\rangle     \n$$\nwhich is our solution $|x \\rangle$. \n\nIt is helpful to visualize the overall flow of the algorithm graphically, as in figure \\ref{fig:HHLOverview} (reproduced from \\cite{HHLPrimer}).\n\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/HHLOverview}\n\\caption[HHL Algorithm - an overview]{HHL Algorithm - an overview}\n\\label{fig:HHLOverview}\n\\end{figure}\n\n\nAfter this short overview, let us now try to understand some of the subleties and ramifications of this approach. First, let us discuss the value of the constant $C$ and the success probability. Clearly, for our conditional rotation to make sense, we need to choose $C$ such that $C < \\lambda_j$ for all $j$, i.e. $C$ can be at most the smallest eigenvalue. Without loss of generality, let us assume that the eigenvalues are sorted, so that $\\lambda_0$ is the smallest eigenvalue and $\\lambda_{N-1}$ is the largest. Then we could set $C = \\tilde{\\lambda}_0$. \n\nLet us now try to understand the success probability of the algorithm. For the sake of simplicity, let us assume that $|b \\rangle$ is normalized, so that $\\sum_j |\\beta_j|^2 = 1$. Immediately before the measurement, the state is a sum\n$$\n\\sum_{j=0}^{N-1} \\beta_j \\sqrt{1 - \\frac{C^2}{\\tilde{\\lambda}_j^2}} |\\psi_j \\rangle |0 \\rangle^S       \n+ \n\\sum_{j=0}^{N-1} \\beta_j \\frac{C}{\\tilde{\\lambda}_j} |\\psi_j  \\rangle\n |1 \\rangle^S    \n$$\n\nThe success probability is given by the probability to obtain 1 when measuring the register $S$, which we can estimate by\n$$\nP = \\sum_{j=0}^{N-1} |\\beta_j|^2 \\frac{C^2}{\\tilde{\\lambda}_j^2} = \\sum_{j=0}^{N-1} |\\beta_j|^2 \\big( \\frac{\\lambda_0}{\\lambda_j} \\big)^2 \\geq \\big( \\frac{\\lambda_0}{\\lambda_{N-1}} \\big)^2 = \\frac{1}{\\kappa^2}\n$$\nwhere the number $\\kappa$, defined as the ratio between the largest and the smallest eigenvalue, is called the {\\bf condition number} of the matrix $A$. \n\nThus for large values of the condition number $\\kappa$, the success probability can become very small, depending on the coefficients $\\beta_j$. Matrices with this property are called {\\bf ill-conditioned}. Intuitively, these matrices are close to being non-invertible, so that for certain vectors $b$, the inversion becomes numerically unstable. As a high condition number decreases the number of trial required to be successful, it increases the runtime by a factor $\\kappa^2$ (which, however, can be reduced to $\\kappa$ by applying Grover's amplitude amplification). In addition, as explained in \\cite{HHL2009}, the algorithm can be modified to handle also ill-conditioned matrices - this is done by using a three-dimensional Hilbert space for the ancillary register $S$ instead of a two-dimensional Hilbert space, where the third state in addition to our previous $|0 \\rangle$ and $|1 \\rangle$ represents \"limited success\". \n\nFurther improvements can be made by applying more refined versions of the phase estimation algorithm. To make contact with the terminology used in \\cite{HHL2009}, let us quickly recall how the first step of the phase estimation algorithm works. Here we apply powers of $U$ condition on the clock register, i.e. we apply the transformation\n$$\n|k \\rangle |\\psi \\rangle \\mapsto |k \\rangle U^k |\\psi \\rangle\n$$\nIf we spell this out using $A$ instead of $U$ and call the variable in the clock register $t$ instead of $k$, this becomes\n$$\n|t \\rangle |\\psi \\rangle \\mapsto |t \\rangle e^{iAt t_0} |\\psi \\rangle\n$$\nIn a physical interpretation, the operator $A$ would be the Hamiltonian of a physical system, and the operator $e^{iA\\tau}$ represents the time evolution over the time $\\tau$. Thus, the mapping above can be interpreted as simulating the evolution of the state $|\\psi \\rangle$ over different time periods $t \\cdot t_0$ for different values of $t$, given by the content of the clock register - this is the reason why this register is called the clock register, and is also what the authors mean in \\cite{HHL2009} when describing their algorithm as \"applying $e^{iAt}$ to $|b \\rangle$ for a superposition of different times $t$\".\n\nNow it turns out that instead of putting the clock register in the initial state $\\sum_t |t \\rangle$ before applying the controlled U-operation as we have done it, we could as well start with properly chosen initial states of the form\n$$\n|\\Phi_0 \\rangle = \\sum_{t=0}^{T-1} c_t |t \\rangle\n$$\nfor some coefficients $c_t$, where $T = 2^m$. The coefficients $c_t$ can then be chosen to sharpen the peak around the eigenvalues after applying the quantum Fourier transform even further and to therefore improve the precision of the algorithm, we refer to \\cite{HHL2009} or \\cite{HHLPrimer} for further details and the exact calculations.\n\nAnother critical point in the algorithm is the efficiency of applying the matrix $e^{iAt t_0}$, i.e. the \"simulation\" of the time evolution given by $A$. We need to be able to do this efficiently, which - as already discussed in the section on simulation - is not possible for arbitrary $A$. In \\cite{HHL2009}, it is assumed that the matrix $A$ is s-sparse (i.e. it has at most $s$ non-zero entries per row) and efficiently row computable, meaning that for each row, these entries can be efficiently computed in a time scaling at most linearly with $s$. Under these conditions, the overall runtime of the algorithm is\n$$\n\\tilde{O}(\\log(N)  \\frac{s^2 \\kappa^2}{\\epsilon})\n$$\nwhere $\\epsilon$ is the required precision. According to \\cite{HHLPrimer}, the best classical algorithm that is known to apply for this class of matrices has runtime\n$$\n\\tilde{O}(N s \\kappa \\log (\\frac{1}{\\epsilon}))\n$$\nThus assuming that $\\kappa$ and $s$ grow slowly with $N$, the quantum algorithm provides an exponential speedup.\n\nHowever, there is a caveat - we need to be able to prepare the input state $|b \\rangle$ efficiently and only obtain a quantum version $|x \\rangle$ of the result $x$. Measuring a component of $|x \\rangle$ will again destroy the state, so we cannot easily obtain the corresponding vector $x$ without repeating the procedure $O(N)$ times, destroying the speed advantage over classical algorithms. As pointed out in \\cite{HHL2009}, the algorithm unfolds its real power therefore in situations where we are not interested in $|x \\rangle$ itself, but in the expectation values of some hermitian operators, which we can measure and estimate with a low number of repetitions. If, for instance, the solution represents the solution of a physically motivated partial differential equation, this could give us access to expectation values of physical observables and thus yield insights that would be difficult to obtain using classical computation.\n\n\\appendix\n\n\\section{The quantum Fourier transform}\n\nIn this section, we briefly summarize the most important facts about the quantum Fourier transform. As the quantum Fourier transform is the quantum equivalent of the discrete Fourier transform, let us describe the discrete Fourier transform first.\n\nGiven an integer N, the discrete Fourier transform is usually defined to be a mapping from the space of complex sequences with N elements to itself. To simplify our notation a bit, we will denote the i-th element of a sequence of N complex numbers as $x[i]$ instead of $x_i$ and let the index i start at zero, so that such a sequence is given by the N complex numbers $x[0], x[1], \\dots, x[N-1]$. We combine these numbers into a vector $x \\in \\C^N$. \n\nGiven such a sequence x, the discrete Fourier transform of $x$ is defined to be the sequence X with elements\n\n$$\nX[k] = \\frac{1}{\\sqrt{N}} \\sum_{j=0}^{N-1} x_j e^{-\\frac{2\\pi i}{N} jk} = \\frac{1}{\\sqrt{N}} \\sum_{j=0}^{N-1} x_j \\eta^{-jk}\n$$\n\nwhere we denote by $\\eta = e^{\\frac{2\\pi i}{N}}$ the standard N-th root of unity. Mapping vectors to vectors, we can think of the Fourier transform as a mapping\n$$\n\\mathcal{F} \\colon \\C^N \\rightarrow \\C^N\n$$\nwhich is clearly linear and which can be shown to be in fact unitary. The formula for the inverse Fourier transform, is given by\n$$\nx[k] = \\frac{1}{\\sqrt{N}} \\sum_s X[s] \\eta^{sk}\n$$\n\n\nLet us now return to the world of quantum computers. Imagine that we have a quantum computer with n qubits. The states of this quantum computer are then described by rays in a Hilbert space with $N=2^n$ dimensions, namely the n-fold tensor product of the one-qubit Hilbert space. With respect to the usual standard basis labeled by the vectors $|x \\rangle $, with $x$ ranging from 0 to N-1, we can then consider any vector as a sequence, using the identification\n\n$$\nx = \\sum_k x[k] |x \\rangle\n$$\n\nTo this sequence, we can apply the Fourier transform. This will give us a unitary transformation $\\mathcal{F}$, described by\n\n$$\n\\mathcal{F}(\\sum_k x[k] |k \\rangle) = \\sum_k X[k] |k \\rangle \n= \\frac{1}{\\sqrt{N}} \\sum_{s,k} x[s] \\eta^{-sk} |k\\rangle \n$$\n\nAs any unitary transformation, this transformation can be realized by a quantum circuit. In fact, one can show (see \\cite{Shor96} and the references therein) that this can be done with a number of quantum gates that scales as O($n^2$). \n\n\\section{The success probability of the QPE algorithm}\\label{app:successprobability}\n\nIn this section, we will follow the treatment in \\cite{CleveEkert} and take a closer look at the amplitudes $a_l$ that we have used in section \\ref{sec:qpe}. Let us quickly recall the setup. We have defined an approximation\n$$\n\\Phi = \\frac{t}{N} + \\delta\n$$\nwith $0 \\leq t < N$ and $|\\delta| < \\frac{1}{2N}$. Let us now  ignore the special case $\\delta = 0$ that we have already considered). \n\n\nIt turns out that we have to distinguish between the case of a positive and a negative $\\delta$. Let us start with the {\\bf case $\\delta > 0$}. We have seen that with\n$$\na_l = \\frac{1}{N} \\frac{1 - e^{2\\pi i \\delta N}}\n{1 - e^{2\\pi i (\\frac{l}{N} + \\delta) }}\n$$\nthe state that our quantum registers have after applying the inverse Fourier transform in the QPE algorithm is\n$$\n\\sum_{- \\frac{N}{2} \\leq l < \\frac{N}{2}} a_l | t - l \\, \\text{mod} N \\rangle |\\psi \\rangle\n$$\nWe have good reasons to believe that this has a peak around $l = 0$. To qualify this peak, let us assume that we are given some integer $d$ with $2 \\leq d < \\frac{N}{2}$ and try to understand the probability that the algorithm will yield a value outside the band with width $\\frac{d}{N}$ around $\\Phi$. The situation is shown in figure \\ref{fig:DeviationFromPhi}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/DeviationFromPhi}\n\\caption[Approximation of $\\Phi$]{Approximation of $\\Phi$}\n\\label{fig:DeviationFromPhi}\n\\end{figure}\n\n\nAS $\\delta > 0$, the first \"bad\" values of $l$ that take us out of the error band of width $2d$ around $\\Phi$ are $l=3=d$ to the left and $l=-4=-(d+1)$ to the right. In other words, we are looking for an upper bound for the sum of the squares of all amplitudes $a_l$ with $l \\geq d$ or $l \\leq -(d+1)$, i.e. for the expression\n\\begin{align}\\label{eq:probI}\nP = \\sum_{l = - \\frac{N}{2}}^{-(d+1)} |a_l|^2 \n+ \n\\sum_{l=d}^{\\frac{N}{2}-1} |a_l|^2\n\\end{align}\n\nLet us first try to find an upper bound for each invididual $a_l$. To find an upper bound for $a_l$, we need to find a lower bound for the denominator. Now by assumption, we have\n$$\n- \\frac{N}{2} \\leq l \\leq \\frac{N}{2} - 1\n$$\ni.e.\n$$\n- \\frac{1}{2} \\leq \\frac{l}{N} \\leq \\frac{1}{2} - \\frac{1}{N}\n$$\nAt the same time, we know that $\\delta$ is less than $\\frac{1}{N}$ and not negative, so that\n$$\n- \\frac{1}{2} \\leq \\frac{l}{N} + \\delta \\leq \\frac{1}{2} \n$$\nWe can therefore apply the estimate in section \\ref{app:estimates} and find that\n$$\n| 1 - e^{2\\pi i (\\frac{l}{N} + \\delta) } | \\geq 2 \\frac{2\\pi  |\\frac{l}{N} + \\delta|}{\\pi} = 4 |\\frac{l}{N} + \\delta|\n$$\n\nNow let us see what this estimate implies in combination with equation \\eqref{eq:probI}. Let us first look at the second sum in equation \\eqref{eq:probI}. For the values of $l$ in the range that appear in that sum, we clearly have\n$$\n\\frac{l}{N} + \\delta \\geq \\frac{l}{N}\n$$\nand thus obtain\n$$\n\\sum_{l=d}^{\\frac{N}{2}-1} |a_l|^2 \\leq \\sum_{l=d}^{\\frac{N}{2}-1} \\frac{1}{N^2} \\big[ \\frac{2}{4 (\\frac{l}{N} + \\delta)} \\big]^2\n\\leq \\sum_{l=d}^{\\frac{N}{2}-1} \\frac{1}{N^2} \\frac{1}{4(\\frac{l}{N}^2)} = \\sum_{l=d}^{\\frac{N}{2}-1} \\frac{1}{4l^2}\n$$\n\nFor the first sum in \\eqref{eq:probI}, we can use a similar argument. Here, $l$ is negative. Thus\n$$\n| \\frac{l}{N} + \\delta  |  = - \\frac{l}{N} - \\delta  \\geq - \\frac{l}{N} - \\frac{1}{2N} =  \\frac{-l -\\frac{1}{2}}{N}\n$$\nBy passing from $-l$ to $l$ in the sum, we therefore obtain the estimate\n$$\n\\sum_{l=-\\frac{N}{2}}^{-(d+1)} |a_l|^2 \\leq \n\\sum_{l=d+1}^{\\frac{N}{2}} \\frac{1}{N^2} \n\\big[    \\frac{2}{4(\\frac{l - \\frac{1}{2}}{N})}   \\big]^2\n= \n\\sum_{l=d+1}^{\\frac{N}{2}} \\frac{1}{4(l - \\frac{1}{2})^2}\n$$\n\nNow let us put all this together. We find that the probability to obtain a measured value which deviates by at least $d$ from $t$ is bounded from above by\n$$\nP \\leq \\sum_{l=d+1}^{\\frac{N}{2}} \\frac{1}{(2l - 1)^2} \n+\n\\sum_{l=d}^{\\frac{N}{2}-1} \\frac{1}{(2l)^2} \n=\n\\sum_{x = 2d}^{N-1} \\frac{1}{x^2} =  \\sum_{x = 2d-1}^{N-2} \\frac{1}{(x+1)^2}\n$$\n\nNow, as illustrated in figure \\ref{fig:RiemannSum}, the step function which is equal to $(x+1)^{-2}$ on the interval from $x$ to $x+1$ is everywhere at most equal to $x^{-2}$. The sum as written is the integral of that step function, and therefore we can estimate the sum by the integral of $x^{-2}$ and obtain\n$$\nP \\leq \\int_{2d-1}^{N-2} \\frac{1}{x^2} dx \\leq \\int_{2d-1}^{\\infty} \\frac{1}{x^2} dx = \\frac{1}{2d-1} \\leq \\frac{1}{d}\n$$\n\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/RiemannSum}\n\\caption[Step function approximation]{Step function approximation}\n\\label{fig:RiemannSum}\n\\end{figure}\n\nThus, the probability to obtain a measured value outside of an interval with width $d$ around the best approximation $t$ drops with $d^{-1}$ if we make $d$ large. In might be irritating that this value does not depend on $N$, but in fact $d$ is just the relative error, not the absolute error which is $d$ divided by $N$. Thus we can make the error arbitrarily small by making $N$ large.\n\nIn fact, suppose we are given numbers $\\epsilon, \\Delta > 0$. Let us now choose $d$ sufficiently large such that \n$$\n\\frac{1}{d} \\leq \\epsilon\n$$\nand at the same time $N \\geq 4d$ so large that\n$$\n\\frac{d}{N} \\leq \\Delta\n$$\nIf we now let $s$ again denote the result of our measurement, we find that\n$$\nP (| \\frac{s}{N} - \\Phi | \\geq \\Delta)\n\\leq\nP (| \\frac{s}{N} - \\Phi  | \\geq \\frac{d}{N})\n \\leq \\frac{1}{d} \\leq \\epsilon\n$$\n\nIn other words, if we make $N$ sufficiently large, the probability that the value of $s / N$ - which we use an approximation for $\\Phi$ - deviates from the best possible m-bit approximation $t / N$ by more than a given threshold $\\Delta$ can be made arbitrarily small. Phrased differently, by choosing $N$ large, the peak of $a_l$ around $l = 0$ can be made arbitrarily sharp. \n\nLet us now complete our argument by considering the {\\bf case $\\delta < 0$}. In this case, it is useful to write the quantum state after applying the quantum Fourier transform slightly differently, namely as\n$$\n\\sum_{- \\frac{N}{2} < l \\leq \\frac{N}{2}} a_l | t + l \\, \\text{mod} N \\rangle |\\psi \\rangle\n$$\nThus we have now excluded $-\\frac{N}{2}$, but included $\\frac{N}{2}$. As these two numbers are equivalent module N, it is clear that this does not change the sum. With this choice of the range of $l$, we now have\n$$\n- \\frac{1}{2}  + \\frac{1}{N} \\leq  \\frac{l}{N} \\leq \\frac{1}{2}\n$$\nNow $\\delta$ is greater than $-\\frac{1}{N}$ and negative, so that\n$$\n- \\frac{1}{2} \\leq \\frac{l}{N} + \\delta \\leq \\frac{1}{2} \n$$\nNow we can again apply the estimate in section \\ref{app:estimates} and find that our previous estimate\n$$\n| 1 - e^{2\\pi i (\\frac{l}{N} + \\delta) } | \\geq 2 \\frac{2\\pi  |\\frac{l}{N} + \\delta|}{\\pi} = 4 |\\frac{l}{N} + \\delta|\n$$\nremains valid for the allowed values of $l$. \n\nLet us now again write down the probability for a deviation or more than  $d / N$. With the new convention for the range of $l$, this probability is now\n\\begin{align}\\label{eq:probII}\nP =  \\sum_{l = - \\frac{N}{2} + 1}^{-d} |a_l|^2 \n+ \n\\sum_{l=d+1}^{\\frac{N}{2}} |a_l|^2\n\\end{align}\nsee again figure \\ref{fig:DeviationFromPhi}. Now let us again look at each sum in turn. If $l < 0$, we can estimate\n$$\n|\\frac{l}{N} - \\delta | \\geq | \\frac{l}{N} + \\frac{1}{2N} |\n$$\nand obtain\n$$\n|a_l|^2 \\leq \\frac{1}{4(l+\\frac{1}{2})^2}\n$$\nFor the second sum, $l > 0$, and therefore (as $\\delta < 0$), \n$$\n|\\frac{l}{N} - \\delta | \\geq | \\frac{l}{N}|\n$$\nso that\n$$\n|a_l|^2 \\leq \\frac{1}{4l^2}\n$$\nIf we again replace $l$ by $-l$ in the first sum, we therefore find that\n$$\nP \\leq  \\sum_d^{l =  \\frac{N}{2} + 1}  \\frac{1}{4(l-\\frac{1}{2})^2}\n+ \n\\sum_{l=d+1}^{\\frac{N}{2}} \\frac{1}{4l^2}\n$$\nwhich can also be written as\n$$\nP \\leq  \\sum_d^{l =  \\frac{N}{2} + 1}  \\frac{1}{(2l-1)^2}\n+ \n\\sum_{l=d+1}^{\\frac{N}{2}} \\frac{1}{(2l)^2}\n$$\nThis sum is again the sum over $x^{-2}$ for all values from $2d-1$ up to $N+1$, except $2d$. As the missing value is positive, we can add it to the sum without making its value smaller and find that\n$$\nP \\leq \\sum_{x=2d-1}^{N+1} \\frac{1}{x^2} = \\sum_{x=2d-2}^{N} \\frac{1}{(x+1)^2} \\leq \\int_{2d-2}^\\infty \\frac{1}{x^2} dx = \\frac{1}{2d-2} \\leq \\frac{1}{d}\n$$\nas before.\n\n\n\n\t\n\\section{Estimates for points on the circle}\\label{app:estimates}\n\nHere we will take a closer look at the estimates for $1 - e^{i\\Phi}$ used before. First, let us try to find a bound from above. The absolute value $| 1 - e^{i\\Phi}|$ is the length of the straight line connecting the point 1 and the point $e^{i\\Phi}$, as shown in diagram \\ref{fig:LineSegments}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=1.0\\linewidth]{images/LineSegments}\n\\caption[Estimates on the unit circle]{}\n\\label{fig:LineSegments}\n\\end{figure}\n\nIntuitively, it is clear that this path is shorter than going around, i.e. that \n\n$$\n| 1 - e^{\\Phi} | \\leq |\\Phi|\n$$\n\nfor all angles $\\Phi$. Formally, this can be seen as follows. First, using the Euler identities, a short calculation shows that for all angles,\n\n$$\n|1 - e^{i\\Phi}|^2 = 2(1 - \\cos \\Phi)\n$$\n\nNow consider the two functions f and g given by $f(\\Phi) = 2(1 - \\cos \\Phi)$ and $g(\\Phi)  = \\Phi^2$. At the origin, both functions are zero. Their derivatives are both zero at the origin as well, and for their second derivatives, we have $f'' \\leq g''$ for all values. As furthermore both functions are symmetric around the origin, we can conclude that $f \\leq g$ everywhere. This proves our inequality.\n\nNext, let us try to apply a similar argument to prove our second inequality. First, we rewrite our expression for $|1 - e^{i\\Phi}|$ a bit. By the additional theorem for the cosine, we have\n\n$$\n1 - \\cos \\Phi = 2 \\sin^2 \\frac{\\Phi}{2}\n$$\nso that we obtain the simple expression\n$$\n| 1- e^{i\\Phi}| = 2 \\sin \\frac{\\Phi}{2}\n$$\nwhenever the right hand side is non-negative. To use this to derive a lower bound, we therefore need a lower bound for the sine. So let us now consider the function F given by\n\n$$\nF(x) = \\sin x - \\frac{2x}{\\pi}\n$$\n\nClearly, this function has zeros at $x = 0$ and $x = \\frac{\\pi}{2}$. We claim that it does not have any zeros between these two points. There are several ways to see this. One possible argument is that the function represents the difference between the function $\\cos $ and the straight line from the origin to the value of $\\cos$ at $\\frac{\\pi}{2}$. As the cosine is concave in this region, this line is always below the graph of the cosine and does not intersect it in any other points within this interval. Thus we have shown that for $x \\in [0,\\frac{\\pi}{2}]$, the inequality\n\n$$\n\\sin x \\geq \\frac{2x}{\\pi}\n$$\n\nholds. Consequently, we immediately find that for $\\Phi \\in [0,\\pi]$, we have the inequality\n\n$$\n| 1- e^{i\\Phi}| = 2 \\sin \\frac{\\Phi}{2}  \\geq 2 \\frac{\\Phi}{\\pi}\n$$\n\nUsing the symmetry of the right hand side with respect to reflexion at the origin, we therefore finally obtain that for all $\\Phi \\in [-\\pi, \\pi]$, we have the inequality\n\n$$\n| 1- e^{i\\Phi}|   \\geq 2 \\frac{|\\Phi|}{\\pi}\n$$\n\n\n\\section{Conditional rotations}\\label{app:conditionalrotations}\n\nIn this section, we will summarize a few basic facts about a procedure known as conditional rotation that appears in the HHL algorithm. \n\nIn its simplest version, the conditional rotation is rotating an ancillary qubit by an angle that is contained in a control register. More precisely, let \n$$\n\\sigma_Y = \\begin{pmatrix} 0 & -i \\\\ i & 0 \\end{pmatrix} = -iY\n$$\nbe the Pauli Y-matrix. Clearly $\\sigma_Y^2 = 1$, and therefore\n\\begin{align*}\ne^{i\\sigma_Y \\Phi} &= \\sum_{k=0}^\\infty \\frac{i^k \\Phi^k}{k!} \\sigma_Y^k \\\\\n&= \n\\sum_k (-1)^k \\frac{\\Phi^{2k}}{(2k)!} \\cdot 1 \n+ \ni \\sum_k (-1)^k \\frac{\\Phi^{2k+1}}{(2k+1)!} \\sigma_Y \\\\\n&= \\cos \\Phi \\cdot 1 + i \\sin \\Phi \\cdot \\sigma_Y \\\\\n&= \\begin{pmatrix} \\cos \\Phi & \\sin \\Phi \\\\ - \\sin \\Phi & \\cos \\Phi \\end{pmatrix}\n\\end{align*}\nConsequently, the unitary operation\n$$\nR(\\Phi) = e^{-i\\Phi \\sigma_Y} = \\begin{pmatrix} \\cos \\Phi & - \\sin \\Phi \\\\  \\sin \\Phi & \\cos \\Phi \\end{pmatrix}\n$$\nis the rotation by the angle $\\Phi$ in the counter-clockwise direction and maps $|0 \\rangle $ to\n$$\n\\cos \\Phi |0 \\rangle + \\sin \\Phi |1 \\rangle\n$$\n\nAfter these preliminaries, we can now define the {\\bf conditioned rotation} as follows. We are given a control register $C$ and a one-qubit register. The conditioned rotation is the unitary operation that is acting as\n$$\n|\\Phi \\rangle |0 \\rangle \\mapsto \\cos \\Phi  |\\Phi \\rangle   |0 \\rangle + \\sin \\Phi |\\Phi \\rangle |1 \\rangle \n$$\nIn other words, we rotate the one qubit-register by the angle contained in the working register.\n\nLet us now see how such a conditional rotation can be implemented as a quantum circuit. First, given a reference state $|a \\rangle$ of the computational basis and a unitary operator $U$ acting on some working register, we can always implement a conditional operation that acts as $U$ if a control register is in the state $|a \\rangle$ and trivially otherwise. In fact, using CNOT gates, we can first implement the operation\n$$\n|x \\rangle \\mapsto |x \\oplus a \\rangle\n$$\non the control register. This will put $|0 \\rangle$ into the control register if and only if $x = a$. We can then invert all qubits in the control register and use the result as the control register of a controlled U-operation on the working register to obtain the desired transformation.\n\nWith this primitive, we could now implement a conditional rotation as a sequence of rotations $R(\\Phi)$ where, as above, each $R(\\Phi)$ is applied if and only if the control register is in the state $|\\Phi \\rangle$. This approach is simple, but has a major drawback - we need one rotation circuit for each possible value of $\\Phi$ representable in the control register, and therefore the number of steps grows as $2^m$, where $m$ is the number of qubits in the control register. \n\nFortunately, there is a different approach. Let $\\Phi_k$ denote the k-th digit in the m-bit representation of $\\Phi$, i.e.\n$$\n\\Phi = \\sum_{k=0}^{2^m-1} \\Phi_k 2^k\n$$\nThen we can express the rotation by the angle $\\Phi$ as\n$$\nR(\\Phi) = e^{-i \\Phi \\sigma_Y} = \\prod_k \\big( e^{-i 2^k \\sigma_Y} \\big)^{\\Phi_k}\n$$\nIn other words, the entire rotation is a sequence of rotations around the angles $2^k$, applied only if the k-th bit of $\\Phi$ is set. We can therefore implement the conditional rotation as a sequence of m controlled rotations by angles $2^k$, controlled by the k-th qubit of the working register. The resulting circuit is shown on the left hand side of figure \\ref{fig:ConditionalRotation} (note the similarity with the exponentation step of the quantum phase estimation, which is in fact just a conditional application of $U^k$).\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/ConditionalRotation}\n\\caption[Conditional rotation]{Conditional rotation}\n\\label{fig:ConditionalRotation}\n\\end{figure}\n\nAs indicated on the right hand side of figure \\ref{fig:ConditionalRotation}, a conditional operation is often indicated by a solid box on the control register, with a slash indicating the number of qubits in the control register. \n\nNow we can take this even further. Suppose we are given a control register and a function $f$ which is classically efficiently computable. We known on general grounds (see for instance the discussion in chapter 6 of  \\cite{RieffelPolak}) that we can then efficiently construct a quantum circuit $U_f$ that acts as\n$$\n|x \\rangle |0 \\rangle \\mapsto |x \\rangle |f(x) \\rangle \n$$\nWe can now use the second register as the control register for a conditional rotation. This will give us a circuit that acts as\n$$\n|x \\rangle |0 \\rangle |0 \\rangle \\mapsto \\cos f(x) |x \\rangle |f(x) \\rangle \n|0 \\rangle + \\sin f(x) |x \\rangle |f(x) \\rangle |1 \\rangle \n$$\nThus we rotate the third register by the angle $f(x)$, there $x$ is the content of the first register, as graphically indicated in figure \\ref{fig:GeneralizedConditionalRotation}.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width=0.7\\linewidth]{images/GeneralizedConditionalRotation}\n\\caption[Conditional rotation by f(x)]{Conditional rotation by f(x)}\n\\label{fig:GeneralizedConditionalRotation}\n\\end{figure}\n\nThis is exactly what we do in the HHL algorithm. Here, our control register contains a state $|\\tilde{\\lambda}\\rangle$. We add one ancillary qubit and want to apply the transformation\n$$\n|\\tilde{\\lambda} \\rangle |0 \\rangle \\mapsto \n|\\tilde{\\lambda} \\rangle \n\\big[  \n\\sqrt{1-\\frac{C^2}{\\tilde{\\lambda}}^2} |0 \\rangle \n+\n\\frac{C}{\\tilde{\\lambda}} |1 \\rangle\n\\big]\n$$\nIf we set \n$$\nf(\\tilde{\\lambda}) = \\arcsin \\frac{C}{\\tilde{\\lambda}}\n$$\nthen this is exactly the situation as above, and we see that this transformation can be implemented as a conditional as shown in this section. Of course, this only works if $\\tilde{\\lambda}$ is between $0$ and $C$, but we can extend $f$ arbitrarily outside this range as our conditions on the matrix and the choice of $C$ make sure that the states to which we apply the transformation are restricted to the allowed range.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Bibliography\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{thebibliography}{9}\n\n\n\\bibitem{NC}\nM.A.~Nielsen, I.L.~Chaung, \\emph{Quantum Computation and Quantum Information},\nCambridge University Press, Cambridge, 2010\n\n\\bibitem{Shor96}\nP.~Shor, \\emph{Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer}, SIAM J.Sci.Statist.Comput. Vol. 26 Issue 5 (1997), pp 1484--1509, available as arXiv:quant-ph/9508027v2\n\n\n\\bibitem{CleveEkert}\nR.~Cleve, A.~Ekert, C.~Macchiavello, M.~Mosca, \\emph{Quantum Algorithms Revisited}, \tProceedings of the Royal Society of London, Series A, 454:339–354, 1998, also available as arXiv:quant-ph/9708016\n\n\\bibitem{Lloyd}\nS.~Lloyd, \\emph{Universal quantum computers},\nScience, New Series, Vol. 273, No. 5278 (Aug. 23, 1996), pp. 1073--1078\n\n\\bibitem{AbramsLloyd}\nD.S.~Abrams, S.~Lloyd, A quantum algorithm providing exponential speed increase for finding eigenvalues and eigenvectors, Phys. Rev. Lett.83 5162-- 5165, 1999, also available as arXiv:quant-ph/9807070\n\n\\bibitem{HW}\nG.H.~Hardy, E.M.~Wright, \\emph{An introduction to the theory of numbers}, Oxford University Press, Oxford, 1975\n\n\\bibitem{Kitaev}\nA.Yu.~Kitaev, \\emph{Quantum measurements and the Abelian Stabilizer Problem}, arXiv:quant-ph/9511026\n\t\n\\bibitem{HHL2009}\nA.W.~Harrow,A.~Hassidim,S.~Lloyd, \\emph{Quantum algorithm for linear systems of equations}, Phys. Rev. Lett. vol. 15, no. 103, pp. 150502 (2009) or arXiv:0811.3171 \n\n\\bibitem{HHLPrimer}\nD.~Dervovic,M.~Hebster,P.~Mountney, S.~Severini,N.~Usher,L.~Wossnig, \\emph{Quantum linear systems algorithms: a primer}, arXiv:1802.08227\n\n\\bibitem{Poisson}\nY.~Cao, A.~Papageorgiou, I.~Petras,J.~Traub, S.~Kais,\n\\emph{Quantum algorithm and circuit design solving the Poisson equation}, New J. Phys. 15 (2013) or arXiv:1207.2485 \n\n\\end{thebibliography}\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "422967fc522e8a427708c48555aea0ca8dd61478", "size": 62997, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "QPE/QPE.tex", "max_stars_repo_name": "christianb93/QuantumComputing", "max_stars_repo_head_hexsha": "c32a13813cd8c6e4ee3c6a2dde13b4554e899e2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2019-10-28T00:12:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-06T11:27:43.000Z", "max_issues_repo_path": "QPE/QPE.tex", "max_issues_repo_name": "christianb93/QuantumComputing", "max_issues_repo_head_hexsha": "c32a13813cd8c6e4ee3c6a2dde13b4554e899e2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "QPE/QPE.tex", "max_forks_repo_name": "christianb93/QuantumComputing", "max_forks_repo_head_hexsha": "c32a13813cd8c6e4ee3c6a2dde13b4554e899e2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-05-03T16:37:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-28T19:07:02.000Z", "avg_line_length": 62.6212723658, "max_line_length": 938, "alphanum_fraction": 0.704620855, "num_tokens": 19122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4147749269452417}}
{"text": "\\documentclass[a4paper]{amsproc}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage[hyphens]{url} \\urlstyle{same}\n\\usepackage{float}\n\\usepackage{multicol}\n\\usepackage{caption}\n\\usepackage{geometry}\n\\newgeometry{margin=1.5in, bottom=1in}\n\n%\\usepackage[dvips]{graphicx} %% Package for inserting illustrations/figures\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{prop}{Proposition}[section]\n\\newtheorem{lem}{Lemma}[section]\n\\newtheorem{cor}{Corollary}[section]\n\\theoremstyle{definition}\n\\newtheorem{exm}{Example}[section]\n\\newtheorem{dfn}{Definition}[section]\n\\theoremstyle{remark}\n\\newtheorem{rem}{Remark}[section]\n\\numberwithin{equation}{section}\n\\newtheorem{theorem}{Theorem}\n\n%% Please, do not change the following four lines:\n\\renewcommand{\\le}{\\leqslant}\\renewcommand{\\leq}{\\leqslant}\n\\renewcommand{\\ge}{\\geqslant}\\renewcommand{\\geq}{\\geqslant}\n\\renewcommand{\\setminus}{\\smallsetminus}\n%\\setlength{\\textwidth}{28cc} \\setlength{\\textheight}{42cc}\n\n\\title[From Markov Switching to Change Points, and Back]{From Markov Switching to Change Points, and Back}\n\n\\subjclass[2019]{}\n\\keywords{Markov Switching, Change Points, MCMC}\n\n\\author[Goolish]{\\bfseries Ethan Goolish}\n\\address{ \n\tDepartment of Statistical Science \\\\ \n\tCornell University   \\\\ \n\tIthaca\\\\\n\tNew York\\\\\n\t14853}\n\\email{efg36@cornell.edu}\n\n\n\\begin{document}\n\t\\vspace{18mm} \\setcounter{page}{1} \\thispagestyle{empty}\n\t\n\t\\\n\t\\maketitle\n%\t\\section*{Abstract}\n%\tEnter Abstract\n%\t\n%\t\\section{Introduction}\n%\tEnter Summary\n\t\n\t\\section{Markov Chain Time Series}\n\tLet $X$ be a Markov Chain with $k$ states: $S_1, ..., S_k$. It is known that we can associate with $X$ a $(k \\times k)$ transition matrix $P$ such that given $X_t = S_i$ (meaning chain $X$ is in state $i$ at time $t$), we have that $P_{ij}$ denotes the probability that $X_{t+1} = S_j$. However, if at time $t$, the state of $X_t$ is not directly observable, but rather $X_t$ emits some signal $y_t$ that probabilistically depends upon the (unobservable) state of $X_t$, we call $X$ a Hidden Markov Model. This is the case that will we will concern ourselves with first. In specific, we associate with each state $S_i$ a mean $\\mu_i$ along with a fixed variance $\\sigma^2$ so that if our chain is in state $S_i$ at time $t$, we can model our emitted signal as $y_t = \\mu_i + \\epsilon$, where $\\epsilon \\overset{i.i.d.}{\\sim} N(0, \\sigma^2)$. With this, we have our Markov Chain Time Series model: Begin in a state $S_1$. Using our above signal model, we obtain signal $y_1 = \\mu_1 + \\epsilon$. Then, we transition to a new state $S_j$ with probability $P_{1j}$. We obtain our next signal $y_2 = \\mu_j + \\epsilon$ before transitioning to our next state $S_{j'}$ with probability $P_{jj'}$, and so forth. Thus given a $(k \\times k)$ transition matrix $P$, a $(k \\times 1)$ vector of state means $S$, and a variation $\\sigma^2$, we can create a time series $Y = (y_1, y_2, ..., y_n)$ of length $n$. Our question is this: given a time series created in the above manner but with unknown parameters $P$ and $S$, can we recover our transition probabilities and means? \n\t\n\t\\section{Process}\n\tTo do so, we suggest the follow procedure. In the basic case, we will assume the number of states $k$ is known. Recall all we are given is a time series $Y = (y_1, ..., y_n)$ of length $n$ where each $y_i$ has associated with it some unknown state $S_j$, and is drawn probabilistically as $y_i = \\mu_j + \\epsilon$. For example, for if we took $k = 3$ and the following parameters:\n\t\\[\n\tS = \\begin{bmatrix} 5 & 0 & -5 \\end{bmatrix}\n\t\\qquad\n\t\\sigma^2 = 1\n\t\\qquad\n\tP = \\begin{pmatrix} \n\t0.95 & 0.02 & 0.03 \\\\\n\t0.01 & 0.95 & 0.04 \\\\\n\t0.03 & 0.03 & 0.94 \\\\\n\t\\end{pmatrix}\n\t\\]\n\twe could have the following series:\\\\\n    \\includegraphics[scale=0.4]{examplets.png}\\\\\n    Our suggested method takes advantage of the ECP change point package (TODO: cite). Within this package, we can use the $e\\_divisive$ call to divide a time series $Y$ into segments based on its change points. The method takes several parameters including $Y$, the time series in question, $k$, the number of estimated change points, $alpha$, the exponentiation for the distance matrix, and $min\\_size$, the minimum number of points allowed between change point estimations. For our method, we want to overpredict the number of change points to ensure all change points between one state $S_i$ and another state $S_j$ are found, and then merge the extraneous splits that separate two segments that should belong to the same state. Currently, we estimate $k$ by assuming the transition probabilities to be no lower than $0.75$, thus assuming the average time before transition to be approximately $1/(1 - 0.75) = 4$. Then we take $n/4$, where $n$ is the total length of $Y$, to be a rough approximation of the number of change points, and then add $n/100$ more in order to over-estimate $k$ appropriately. We also take $alpha$ to be $2$, and take $min\\_size$ to be the smallest allowed ($2$) to allowed for the finest granularity. With this set of parameters, we expect a call to $e\\_divisive$ to return segmentation similar to the following:\\\\\n    \\includegraphics[scale=0.4]{examplesplit.png}\\\\\n    Note for the most part that while the state transitions are marked by $e\\_divisive$, we have some excess segmentation, such as the third mark which incorrectly divides two segments from the same state $S_1$, the state corresponding to $\\mu_1 = 0$. Our next goal is to remove such incorrect splitting. To do this, begin by finding the mean $g_i$ of each guessed segment $G_i$ (which was returned by $e\\_divisive$). Then, sort the list of $G_i$ incrementally by their respective $g_i$. We can then run $e\\_divisive$ for a second time on our sorted $G_i$ to group our means into estimates for which state each segment guess was in. In other words, using $e\\_divisive$ on a sorted list of $g_i$ groups each $G_i$ into a guess for the segment label $\\hat{S_i}$. If the number of states $k$ is known, we can use $k - 1$ as the parameter for the number of change points in this second use of $e\\_divisive$. To continue the above example, here we plot the sorted means $g_i$, and then segment using the second $e\\_divisive$ call. The segments $G_i$ corresponding to points in the first segment will be estimated to be in state $\\hat{S_0}$, the segments corresponding to points in the second segment will be estimated to be in state $\\hat{S_1}$, and the segments corresponding to points in the third segment will be estimated to be in state $\\hat{S_2}$:\\\\\n    \\includegraphics[scale=0.4]{example2x.png}\\\\\n    After assigning each $G_i$ to the appropriate $\\hat{S_i}$, we then do the merging -- we can iterate through our original (unsorted) list of $G_i$, and if some $G_i$ and $G_{i+1}$ have the same assigned state label $\\hat{S_i}$, then we propose a new segment $G_i'$ such that $G_i'$ contains the points that used to be in $G_i$ and $G_{i+1}$. After doing this, we get this new estimation of the change points, which we can see is much more accurate:\\\\\n    \\includegraphics[scale=0.4]{examplefixedseg.png}\\\\\n    Now with our fixed segmentation, we estimate our transition probabilities $P_{i, j}$ as well as our state means $\\mu_i$. To do so, we first calculate the average stay time for each state label $\\hat{S_i}$. By this we mean we take each updated segment $G_i$ and observe its length. We groupby the segment labels $\\hat{S_i}$ and take the average to find the average time of stay for a given label $\\hat{S_i}$, call it $a_i$. Then note that\n    \\[\n    a_i = \\frac{1}{1 - P_{i, i}} \\iff P_{i, i} = \\frac{a_i - 1}{a_i}\n    \\] \n    and thus we can estimate our staying probabilities $P_{i, i}$. We can also estimate our off-diagonal probabilities $P_{i, j}$: We first count the number of times we transition from a state $i$ to every other state $j$ where $j \\neq i$, call it $c_{i, j}$. Then, we know that $P_{i, j}$ is proportional to the number of times we transition from $i$ to $j$ over the number of times we transition from $i$ to any other state $j'$. Since we know the sum across a row $\\sum_j P_{i, j} = 1$, we can say\n    \\[\n    P_{i, j} = \\frac{c_{i, j}(1 - P_{i, i})}{\\sum_j c_{i, j}}\n    \\]\n    Alternatively, we can take a prior $\\alpha_i$ so that $c'_{i, j} = c_{i, j} + \\alpha_i$. In this basic example we take $\\alpha_i = 0$, but other natural choices include $\\alpha_i = 1$, $\\alpha_i = 1/2$, or $\\alpha_i = 1/K$ (where $K$ is our number of states). In total, this gives us our full probability matrix $P$.\\\\ \n    \n    Then, to estimate $S = \\{\\mu_1, ...., \\mu_k\\}$, we simply groupby our updated segment labels $\\hat{S_i}$ and take the mean to find each $\\hat{\\mu_i}$. Doing the above on our example dataset above yields us:\n    \\[\n    \\hat{S} = \\begin{bmatrix} -5.04134908 & -0.03278774 & 4.91458622 \\end{bmatrix}\n    \\qquad\n    \\hat{P} = \\begin{pmatrix} \n    0.95384615 & 0.01538462 & 0.03076923 \\\\\n    0.01818182 & 0.93636364 & 0.04545455 \\\\\n    0.01298077 & 0.02163462 & 0.96538462 \\\\\n    \\end{pmatrix}\n    \\]\n\tyielding us an accurate recovering of our original parameters.\\\\\n    \n\\end{document}", "meta": {"hexsha": "f80111439cec2dcfd23098e266eb23ae761a7b02", "size": 9133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/Paper.tex", "max_stars_repo_name": "egoolish/mcts", "max_stars_repo_head_hexsha": "ff930dc2e0587d7c1fa2ff1868186f5fca61bd08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/Paper.tex", "max_issues_repo_name": "egoolish/mcts", "max_issues_repo_head_hexsha": "ff930dc2e0587d7c1fa2ff1868186f5fca61bd08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/Paper.tex", "max_forks_repo_name": "egoolish/mcts", "max_forks_repo_head_hexsha": "ff930dc2e0587d7c1fa2ff1868186f5fca61bd08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.8173076923, "max_line_length": 1563, "alphanum_fraction": 0.7176174313, "num_tokens": 2720, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.41477492694524165}}
{"text": "\n\n% ==============================================================================\n%\\chapter*{\\vspace{-1.0cm}Introduction}   \\addcontentsline{toc}{chapter}{Introduction} \\label{intro}\n\\chapter{Phonon Decoherence}   \\label{wigner}\n% ==============================================================================\n\n\n\\section{Introduction}\nThe Phonon Decoherence (PD) tool comprises methods, approaches and algorithms for particle simulation of quantum decoherence in the phase space. The theoretical foundation for the implemented algorithms is the Wigner description from the field of quantum mechanics.\n\nThe evolution of a system in the Wigner formalism is remarkably similar to the classical phase space description resulting in Boltzmann's equation. The distinctive difference is that where the Boltzmann description is restricted to using distribution functions, the quantum case also admits negative values -- hence using quasi distribution functions. This extension to negative values poses algorithmic difficulties in the general case.\n\nQuantum computational and communication ideas rely on the fundamental\nphysical notions of superposition, entanglement, and interference and thus to a coherent evolution.\n\nDecoherence, which destroys the unitary evolution of the coherent state is\nthe major showstopper of an effective practical realization of the above ideas. The\nsystem interacts with the environment so that system and environment states\nentangle into a common, usually macroscopic state. The system state is\nobtained after a trace on the additional variables, which rules out certain correlations.\nThe theory of decoherence addresses the manner in which some quantum\nsystems become classical due to such entanglement with the environment. The\nlatter in effect monitors certain observables in the system, destroying coherence\nbetween the states corresponding to their eigenvalues. Only preferred survive\nconsecutive 'measurements' by the environment. The\nrest of the states, which actually comprise a major part of the Hilbert space are\neliminated. Many of the features of 'classical' systems are actually induced in quantum\nsystems by their environment.\n\nThe PD tool provides tools for analysis of the evolution of an initially entangled\nelectron state which evolves in presence of semiconductor lattice vibrations - phonons.\nThe initial electron state is constructed by a superposition of two Gaussian wave packets\nand has a pronounced interference term comprised of alternating positive and negative\nvalues of the Wigner function. The simulations show how the phonons effectively\ndestroy the interference term. The initial coherence in wave vector distribution\nis pushed towards the equilibrium distribution. Phonons hinder\nthe natural spread of the density with time pushing towards a classical\nlocalization. The initially pure electron state evolves towards a state with an\nentirely different physical interpretation: it is a mixed state where the\nelectron can be with given probability in one of the two Gaussian packets.\nThe decoherence effect of the phonons causing transition\nfrom quantum to classical state is demonstrated by the purity of the\nstate, which decreases from it’s initial value of 1, with a speed depending\non the lattice temperature.\n\nThe PD tool is considered a free open source platform to provide the research community\nwith the actual implementations of published theoretical work in this field~\\cite{Schwaha_borovets_2011}.\nBased on the WIENS source code repository~\\cite{wiensonline}, PD tool extends the functionality\nwith respect to an increased degree of decoupling and provides potential users with access to the result data structures.\n\n\n\n\n\n% ==============================================================================\n% ==============================================================================\n\\section{Building Information} %\\addcontentsline{toc}{chapter}{Building Instructions} \\label{building}\n% ==============================================================================\n% ==============================================================================\n\n\\subsection{Dependencies}\n\nIn the following the dependencies of the PD simulator are presented.\n\n\\begin{itemize}\n  \\item C++11-Compiler (e.g. GCC~\\cite{gcc} Version $\\geq4.6$)\n  \\item Boost~\\cite{boost} Version $\\geq1.46$\n  \\item Lua~\\cite{lua} Version $5.1$\n\\end{itemize}\n\n\n\n% ==============================================================================\n\\section{Examples} \\label{wigner:examples}\n% ==============================================================================\nTo execute the generated simulation executable, two input files have to be utilized.\nIn the following, the provided example simulation setup is used to execute a simulation.\n\n\\begin{lstlisting}\n$> cd ViennaWD/build/phonon_decoherence/\n$> ./pdsim ../../phonon_decoherence/examples/parameters.lua\n            ../../phonon_decoherence/examples/config.lua\n\\end{lstlisting}\n\n%\\TIP{Keep the default parameters described in Section \\ref{boltzmann:sim}, tables \\ref{tab:mc2d}, \\ref{tab:matpar}, \\ref{tab:scatflag} and \\ref{tab:scatpar} when compiling an executable for running the examples. Alternatively all source files and the Makefile can be copied to the corresponding example folder and compiled there using \\texttt{make}.}\n\n%\\TIP{Currently, only one example is available, but additional one will be made\n%available in the future.}\n\nFig.~\\ref{fig:one} depicts exemplary simulation results using the visualization approach introduced in Appendix A.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\subfigure\n  {\n  \\includegraphics[width=0.5\\columnwidth]{figures/wiens_prop1.eps}\n  }\n  \\subfigure\n  {\n  \\includegraphics[width=0.5\\columnwidth]{figures/wiens_prop9.eps}\n  }\n  \\caption{\n    Phase space distribution functions computed by the PD simulator are shown.\n    In the classical case it can be interpreted directly\n    as probability to find a particle, the indefinite nature in the\n    quantum case, prohibits this direct interpretation, but still\n    provides correct derived quantities such as density and momentum\n    distribution. The evolution is shown at $100fs$ (\\textbf{top})\n    and at $1ps$ (\\textbf{bottom}).\n  }\n  \\label{fig:one}\n\\end{figure}\n\n\\clearpage\n\n% ==============================================================================\n% ==============================================================================\n\\section{Simulation Control} \\label{wigner:sim}\n% ==============================================================================\n% ==============================================================================\n\nThe simulations are controlled via the input configuration and parameter XML files.\nIn the following the individual variables are explained in detail.\n\n%\\subsection{Parameters}\n\n\n\n\\begin{table}[ht!]\n\\centering\n\\begin{tabular}{|l|p{4.5cm}|c|c|}\n\\hline\n\\textbf{Variable}   & \\textbf{Definition}   & \\textbf{Unit} & \\textbf{Default} \\\\\n\\hline\n%\\texttt{NI}  & FILLME & $m^{-3}$ & $1$ \\\\\n%\\hline\n\\texttt{TL}  & Lattice Temperature & $K$ & $300$ \\\\\n\\hline\n%\\texttt{Z}  &  FILLME  &  & $0.5e-12$ \\\\\n%\\hline\n\\texttt{effmass}  & Effective Mass Factor &  & $0.067$ \\\\\n\\hline\n\\texttt{alpha}  & Non-Parabolicity Factor & $1/eV$ & $0.61$ \\\\\n\\hline\n\\texttt{rho}  & Density & $kg/m^3$ &$5.36e3$ \\\\\n\\hline\n%\\texttt{us}  &  FILLME  & $m/s$ &$1./3. * ( 2. * 3.0e3  + 5.24e3 )$ \\\\\n%\\hline\n%\\texttt{DA}  &  FILLME  & $eV$ &$7.0$ \\\\\n%\\hline\n%\\texttt{energy\\_beta}  &  FILLME  & $J$ &$1$ \\\\\n%\\hline\n%\\texttt{DO}  & FILLME   & $J/m$ &$1$ \\\\\n%\\hline\n\\texttt{optical\\_phonon\\_energy}  &  Optical Phonon Energy  & $eV$ &$0.0343$ \\\\\n\\hline\n\\texttt{polar\\_optical\\_phonon\\_energy}  &  Polar Optical Phonon Energy  & $eV$ &$0.036$\\\\\n\\hline\n\\texttt{optical\\_permitivity}  &  Optical Permitivity  & & $10.92$ \\\\\n\\hline\n\\texttt{static\\_permitivity}  & Static Permitivity   & & $12.9$ \\\\\n\\hline\n\\texttt{free\\_flight\\_coeff}  &  Free Flight Coefficient  & $1/Hz$ & $1. / 2.6e13$ \\\\\n\\hline\n\\end{tabular}\n\\caption{The parameter variables are shown.}\n\\label{tab:paras}\n\\end{table}\n\n\n%\\subsection{Configuration}\n\n%\\clearpage\n\n\\begin{table}[ht!]\n\\centering\n\\begin{tabular}{|l|p{5cm}|c|c|}\n\\hline\n\\textbf{Variable}   & \\textbf{Definition}   & \\textbf{Unit} &\\textbf{Default} \\\\\n\\hline\n%\\texttt{L}  &  FILLME   & m & 800 * 1e-9 \\\\\n%\\hline\n%\\texttt{p\\_max}  &   FILLME  & 1/m & 6e-9 \\\\\n%\\hline\n\\texttt{x\\_count}  & Number of simulation domain points in x-direction &  & 400 \\\\\n\\hline\n\\texttt{y\\_count}  & Number of simulation domain points in y-direction &  & 3000 \\\\\n\\hline\n\\texttt{timestep}  & The time difference between two time steps &  s & 100.0e-15 \\\\\n\\hline\n\\texttt{max\\_iterations}  & Number of simulated time steps &  & 10 \\\\\n\\hline\n\\texttt{max\\_particle\\_count}  &  Number of generated particles for each point in the phase space   &  & 30 \\\\\n\\hline\n\\end{tabular}\n\\caption{The configuration variables are shown.}\n\\label{tab:configs}\n\\end{table}\n\n\\clearpage\n\n% ==============================================================================\n\\section{License}\n% ==============================================================================\n\nBoost Software License - Version 1.0 - August 17th, 2003\n\nPermission is hereby granted, free of charge, to any person or organization\nobtaining a copy of the software and accompanying documentation covered by\nthis license (the \"Software\") to use, reproduce, display, distribute,\nexecute, and transmit the Software, and to prepare derivative works of the\nSoftware, and to permit third-parties to whom the Software is furnished to\ndo so, all subject to the following:\n\nThe copyright notices in the Software and this entire statement, including\nthe above license grant, this restriction and the following disclaimer,\nmust be included in all copies of the Software, in whole or in part, and\nall derivative works of the Software, unless such copies or derivative\nworks are solely in the form of machine-executable object code generated by\na source language processor.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\nSHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\nFOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n", "meta": {"hexsha": "745a13fa1e1ab2a2aaf3f4630ca8848ee8200dd0", "size": 10472, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/manual/phonon_decoherence.tex", "max_stars_repo_name": "ViennaTools/ViennaEMC", "max_stars_repo_head_hexsha": "fbad17ca280b0ea97ccb9a9e8efb64a6f11dd9ee", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/manual/phonon_decoherence.tex", "max_issues_repo_name": "ViennaTools/ViennaEMC", "max_issues_repo_head_hexsha": "fbad17ca280b0ea97ccb9a9e8efb64a6f11dd9ee", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/manual/phonon_decoherence.tex", "max_forks_repo_name": "ViennaTools/ViennaEMC", "max_forks_repo_head_hexsha": "fbad17ca280b0ea97ccb9a9e8efb64a6f11dd9ee", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-18T19:55:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-18T19:55:18.000Z", "avg_line_length": 45.5304347826, "max_line_length": 437, "alphanum_fraction": 0.6810542399, "num_tokens": 2480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.41477491909766717}}
{"text": "\n\\documentclass[journal]{IEEEtran}\n\n\n\\usepackage [utf8] {inputenc}\n\\usepackage [english] {babel}\n\\usepackage [final] {microtype}\n\\usepackage {amssymb}\n\\usepackage {amsmath}\n\\usepackage {amsfonts}\n\\usepackage {graphicx}\n\\usepackage {dblfloatfix}\n\\usepackage {csquotes}\n\\usepackage {mathtools}\n\\usepackage {float}\n\\usepackage {hyperref}\n\\usepackage {listingsutf8}\n\\usepackage{chngcntr}\n\n\\renewcommand {\\a} {\\alpha}\n\\renewcommand {\\b} {\\beta}\n\\newcommand {\\g} {\\gamma}\n\\newcommand {\\G} {\\Gamma}\n\\newcommand {\\h} {\\eta}\n\\renewcommand {\\d} {\\delta}\n\\newcommand {\\e} {\\varepsilon}\n\\newcommand {\\f} {\\varphi}\n\\renewcommand {\\l} {\\lambda}\n\\newcommand {\\s} {\\sigma}\n\\renewcommand {\\i} {\\iota}\n\\renewcommand {\\th} {\\vartheta}\n\\newcommand {\\z} {\\zeta}\n\\renewcommand {\\O} {\\Omega}\n\\renewcommand {\\o} {\\omega}\n\\newcommand {\\D} {\\cdot}\n\\newcommand {\\Adj} {\\dagger}\n\\newcommand {\\Tr} {\\intercal}\n\n\\newcommand {\\m} [1] {\\( #1 \\)}\n\\newcommand {\\V} [1] {\\underline {#1}}\n\\newcommand {\\M} [1] {\\underline {\\underline {#1}}}\n\\newcommand {\\T} [1] {\\tilde {#1}}\n\\newcommand {\\RB} [1] {\\left( #1 \\right)}\n\\newcommand {\\SB} [1] {\\left[ #1 \\right]}\n\\newcommand {\\CB} [1] {\\left\\{ #1 \\right\\}}\n\\newcommand {\\DB} [1] {\\left[ \\! \\left[ #1 \\right] \\! \\right]}\n\\newcommand {\\Fl} [1] {\\left \\lfloor #1 \\right \\rfloor}\n\\newcommand {\\Cl} [1] {\\left \\lfloor #1 \\right \\rfloor}\n\\newcommand {\\Nm} [1] {\\left \\vert #1 \\right \\vert}\n\\newcommand {\\VNm} [1] {\\left \\Vert #1 \\right \\Vert}\n\\newcommand {\\R} [1] {\\sqrt {#1}}\n\\newcommand {\\Min} [1] {\\underset {#1} {\\mathrm {min}}\\;}\n\\newcommand {\\IP} [1] {\\left \\langle #1 \\right \\rangle}\n\\newcommand {\\Stack} [1] {\\startsubstack #1 \\stopsubstack}\n\\newcommand {\\Disp} [1] {\n   \\begin {align*}\n      #1\n   \\end {align*}\n}\n\n\n\\begin{document}\n\n\\title{Dantzig Selector Applied on mm-Wave MIMO Channel Estimation and and Error Analysis}\n\n\\author{Tzu-Yu Jeng \\\\\n        Hsuan-Jung Su%\n\\thanks{Hsuan-Jung Su is with the Department\nof Electrical Engineering, National Taiwan University.}\n\\thanks{Manuscript received April 1, 2020; revised April 1, 2021.}}\n\n\\markboth{IEEE Journal of whatever,~Vol.~0, No.~0, June~2020}%\n{Jeng and Su: Dantzig Selector Applied on mm-Wave MIMO Channel Estimation}\n\n\n\n\\maketitle\n\n\\begin{abstract}\nMultiple-input multiple-output communication systems in the millimeter-wave band are gradually being adopted.\nA larger antennae array makes channel estimation more difficult.\nMeanwhile, hybrid beamforming, which utilizes fewer RF chains, is applied too, so that new estimation methods have to be designed.\nThis can be seen as a compressive sensing problem, for which Orthogonal Matching Pursuit is usually used.\n\nWe consider a single user, hybrid structure with a uniform linear array with both precoders and combiners on each side.\nWe generate random beamforming matrices and use Dantzig Selector to estimate the channel in the space frequency domain.\nThen, we give a quantitative bound (which holds for high probability) on the expected error norm.\nTo reduce the complexity, we cast it as a linear program, and suggest the basis pursuit denoising form.\nNumerical results show that DS gives a superb regularization, especially when the sample is less sufficient and the noise level is higher.\nWe therefore propose that DS may be used, when the number of RF chains is more limited or when fewer stages of estimation are possible.\n\\end{abstract}\n\n\\begin{IEEEkeywords}\nchannel estimation, compressive sensing, sparsity, Dantzig Selector, regularization, restricted isometry\n\\end{IEEEkeywords}\n\n\\begin {figure*} [!b]\n\\centering\n\\includegraphics [width = \\textwidth] {system.png}\n\\caption {Schematic diagram of the hybrid beamforming system we consider.}\n\\end {figure*}\n\n\\section{Introduction}\n\n\\subsection {Background}\n\nMultiple-input multiple-output (MIMO) communication systems will be part of the 5G specification.\nWith a large number of antennae on both transmitter and receiver ends, MIMO is expected to provide a large signal gain.\nParallel and redundant transmission of data improves the error-correcting ability, and beamforming improves the signal level.\nThe millimeter wave (mm-wave) is adopted, since its smaller wavelength (and thus higher frequency) makes wider bands available.\nMoreover the antennae may be closer-spaced, allowing us to increase their number \\cite {RSM13}.\nHowever, because of a larger antennae array and of larger noise corruption in higher frequency, estimation of MIMO channel state information gives rise to higher complexity, and hence higher hardware overhead and power consumption.\nIndeed, RF chains are more expensive and power-consuming, so there is growing attention on hybrid beamforming, where there are not fewer RF chain than the antennae.\n\nIf we consider a slow varying MIMO channel for simplicity, in terms of a channel representation, to estimate the channel is to determine the parameters of the representation.\nIt amounts to invert a linear system whose dimension is the number of antennae, for which conventional training-based algorithms are not very effective.\nFortunately, physical evidence has suggested that mm-wave channel are poor in scattering \\cite {ALS14}, which reduces the number of paths, and compressive sensing techniques may be used.\nGenerally speaking, compressive sensing aims to reconstruct an underdetermined linear system, when the sparsity of solution guarantees successful recovery for most cases.\nIn our settings for hybrid beamforming structure, a way of generating the sensing matrix and pilot vectors in the estimation stage has to be devised and justified.\n\n\\subsection {Literature}\n\nCompressive sensing approaches can be divided into two categories, the convex programming approach and the greedy approach \\cite {RDD18}.\nWe will discuss one from each in more detail: Dantzig Selector and Orthogonal Matching Pursuit.\nFor the the convex programming approach, Dantzig Selector (DS) is one of the earlier method, and it recovers the sparse signal with expected error norm bounded with overwhelming probability, and near optimality \\cite {CaT07}.\nDS is an minimization problem on \\m {\\ell_1}-norm, with \\m {\\ell_\\infty}-constraint, which may be recast as a linear program, so that techniques from convex optimization may be used.\nFor our purpose in MIMO channel estimation, physical evidences suggest that mm-wave channels are sparse in the number of paths.\nBajwa et.\\ al.\\ \\cite {BHS10} used DS to estimate the time-dependent single-antenna channel response,\nand in the accompanying note \\cite {BHR08} they justified that \\m {X} has RIP for overwhelming probability.\nSome later results show that Least absolute shrinkage and selection operator (Lasso) and DS have similar behavior \\cite {AsR10}.\nLian, Liu and Lau applied Lasso on MIMO with an analog combiner \\cite {LLL17};\nDestino, Juntti, and Nagaraj used an adaptive Lasso \\cite {DJN15};\nVlachos, Alexandropoulos, and Thompson \\cite {VAT19} used Lasso on hybrid beamforming with an additional random spatial sampling device.\nThese formulations rely on joint optimization on the estimated channel and the sensing matrix, which can result in high complexity.\n\nOn the other hand, OMP has since been commonly used for channel estimation.\nAlkhateeb, Leus, and Heath Jr.\\ \\cite {ALH15} examined the trade-off between number of measurement and accuracy for an all-phase-shifter beamforming matrix based on nonuniform fixed set of angles.\nHu, Wang, and He \\cite {HWH13} applied OMP to estimate path delay of OFDM subcarriers.\nLee, Gil, and Lee \\cite {LGL16} considered a hybrid system, where the hybrid beamforming matrix serves as sensing matrix.\nGao, Dai, and Wang \\cite {GDW15} proposed a variant of OMP which there is the assumption of spatially common sparsity.\nFor the performance guarantee of OMP, Cai, Wang, and Xu \\cite {CWX10} gave a new bound on performance of OMP under assumption of low coherence of columns.\nCai and Wang \\cite {CaW11} extended the study to DS and other convex programs for sparse recovery, and Ben-Haim et.\\ al.\\ \\cite {BEE10} refined their bounds, concluding that OMP is better for low SNR scenario, and DS is better for high SNR.\n\n\\subsection {Contribution}\n\nDue to the constraint of hybrid structure, the designs which use fully digital beamforming cannot be directly applied, and the designs which use only analog beamforming might not be optimal.\nIndeed, if DS is shown to be optimal \\cite {CaT07}, then if we can overcome the problem of complexity among other difficulties, it may turn out to outperform greedy methods, and is even necessary for less ideal situations.\n\nIn this treatise, we consider a hybrid structure with a uniform linear array with both precoders and combiners on each side.\nWe shall generate random beamforming matrices, and use DS to estimate the channel in the space frequency domain.\nTo the best of our knowledge, the sensing matrix with i.i.d.\\ entries in both analog and digital stages has not been discussed on the literature.\nWe shall see that in our proposed method, the effective sensing matrix has RIP for high probability, which may serve as the sensing matrix for DS,\nfor which we give a quantitative bound, holding for high probability, on the expected error norm.\nNumerical results show that DS is superior to other methods for our problem.\nSince DS is more accurate, it can be used when the sample is less sufficient and the noise level is higher, where it might be the case that only DS can recover successfully.\nConsidering its higher complexity, we remark that it can be cast as a linear program, and the basis pursuit denoising form may be used.\n\nIt appears that, for a given number of sampling, DS recovers better than OMP, except perhaps in high noise scenario.\nMoreover, our setting is more general than Alkhateeb, Leus, and Heath Jr.\\ \\cite {ALH15} with only an analog combiner,\nand our random generation of sensing matrix is simpler than Lee, Gil, and Lee \\cite {LGL16},\nand we do not rely on additional assumptions on sparsity as in Gao, Dai, and Wang \\cite {GDW15}.\n\nOur work is also an improvement to Bajwa et.\\ al.\\ \\cite {BHS10}.\nFirst, while their method takes many time slices, for our case a few time slices suffice, since the channel is time independent.\nSecond, with the further constraint of hybrid beamforming, the channel matrix is downsampled, it is unclear whether their guarantee for successful signal recovery is still valid.\nThird, generating random sequences can lead to high complexity \\cite {LGL16}, and we instead use random beamforming matrices.\n\nIn addition, it seems that with the same threshold, DS recovers better than Lasso, except perhaps in low noise scenario.\nAgain, our proposed method is more general than Lian, Liu and Lau \\cite {LLL17} with only an analog combiner,\nand our sensing matrix is generated more simply than in Destino, Juntti, and Nagaraj \\cite {DJN15},\nand we do not require special devices as in Vlachos, Alexandropoulos, and Thompson \\cite {VAT19}.\nOverall, it is clear that DS leads to a relatively better regularization than OMP and Lasso.\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\n\\section{System model}\n\n\\subsection {Channel model}\n\nWe use an underline like \\m {\\V {v}} for vectors, two underlines like \\m {\\M {M}} for matrices.\nA dagger \\m {\\dagger} stands for Hermitian, and \\m {\\intercal} for transpose.\nA subscript with brackets like \\m {\\M {M} _{\\SB{1,2}}} is its corresponding entry.\n\nFor simplicity we suppose uniform linear arrays, for which the response would be,\n\\Disp {\n\\V {a} \\RB {\\psi', N}\n= \\frac {1} {\\R {N}} \\sum_{n_h=0}^{N-1} \\mathsf {e} ^{\\mathsf {i} n_h \\psi'} \\V {u} _{n_h}\n\\in \\mathbb {C} ^ {N} \n}\nAnd consider the virtual representation of the MIMO channel, \\cite {ALS14},\n\\Disp {\n\\M {H}\n=\\sum_{l=0} ^{L-1}\n\\a_l\n\\V {a} \\RB { 2\\pi \\frac {d_{\\mathrm {arr}}} {\\l _{\\mathrm {arr}}} \\sin \\f_l', N_{H,r}}\n\\V {a} \\RB { 2\\pi \\frac {d_{\\mathrm {arr}}} {\\l _{\\mathrm {arr}}} \\sin \\th_l', N_{H,t}}^\\dagger \n}\nThe physical meaning of \\m {\\f_l'} is the \\m {l}-th angle of incidence of departure electronic wave, and \\m {\\th_l'}, the \\m {l}-th angle of arrival wave, and \\m {d_{\\mathrm {arr}}} is the distance between two adjacent antennae.\n\n\\subsection {System model}\n\nWe consider hybrid beamforming at both the transmitter and receiver ends, as shown in Figure 2.\nEach end consists of both digital and analog precoders and combiners.\nIn the transmitter end, there are (seeing towards the receiver end), the digital precoder \\m {\\M {F} _B \\in \\mathbb {C} ^{N_B \\D N_B}} and the analog precoder \\m {\\M {F} _R \\in \\mathbb {C} ^{N_{H,t} \\D N_B}}.\nSimilarly, in the receiver end, there are (seeing towards the transmitter end) the digital combiner \\m {\\M {W} _B \\in \\mathbb {C} ^{N_B \\D N_B}} and the analog combiner \\m {\\M {W} _R \\in \\mathbb {C} ^{N_B \\D N_{H,r}}}.\nRecall that analog precoders may only have values of unity magnitude.\n\\Disp {\n\\Nm {\\RB {\\M {F} _R} _{\\SB {n_H, n_{R,t}}}}\n= &1, \\\\\n\\Nm {\\RB {\\M {W} _R} _{\\SB {n_{R,r}, n_H}}}\n= &1,\n}\nwhere we assume \\m {N_{H,t}, N_{H,r} \\gg N_B}.\n\nSince we restrict our discussion to a short interval of time, the noise term may be simply taken as a matrix \\m {\\M {Z} \\in \\mathbb {C} ^{N_B \\D N_B}} with each entry being i.i.d.\\ standard normal.\nLet us introduce the effective channel\n\\Disp {\n\\M {Y}\n:=\\M {W} _B \\M {W} _R \\RB {\\M {H} \\M {F} _R \\M {F} _B +\\M {Z}} \n}\nOur task then amounts to recovering \\m {\\M {H}}, and generating \\m {\\M {W} _R}, \\m {\\M {W} _B}, \\m {\\M {F} _R}, and \\m {\\M {F} _B}.\n\n\\subsection{Proposed method}\n\nLet vec stand for vectorization of matrices along each column, and \\m {\\otimes} for Kronecker product.\nThen it is more appealing to write\n\\Disp {\n\\V {h}\n:= &\\mathrm {vec} \\RB {\\M {H}} \\\\\n\\V {y}\n:= &\\mathrm {vec} \\RB {\\M {Y}} \\\\\n\\V {z}\n:= &\\mathrm {vec} \\RB {\\M {W} _B \\M {W} _R \\M {Z}} \\\\\n\\M {Q}\n:= &\\RB {\\M {F} _B^\\intercal \\M {F} _R^\\Tr} \\otimes \\RB {\\M {W} _B \\M {W} _R} \\\\\n}\nto formulate the problem as a linear system:\n\\Disp {\n\\V {y}\n=\\M {Q} \\V {h} +\\V {z} \n}\n\nAt this stage, it is not obvious that \\m {\\V {h}} must be sparse, so we apply discrete Fourier transform matrix \\m {\\M {K}} on both sides.\nIndeed, if we write\n\\Disp {\n\\M {G}\n=\\M {K}^\\dagger _r \\M {H} \\M {K} _t\n}\nthen\n\\Disp {\n\\M {Y}\n=\\M {W} _B \\M {W} _R \\M {K} _r \\D \\M {G} \\D \\M {K}^\\dagger _t \\M {F} _R \\M {F} _B\n+\\M {W} _B \\M {W} _R \\M {Z}\n}\nNow, set\n\\Disp {\n\\M {P}\n:= &\\RB {\\M {F} _B^\\intercal \\M {F} _R^\\intercal \\M {K}^\\ast _t} \\otimes \\RB {\\M {W} _B \\M {W} _R \\M {K} _r} \\\\\n\\V {g}\n:= &\\mathrm {vec} \\RB {\\M {G}}\n}\nAccordingly\n\\Disp {\n\\V {y}\n=\\M {P} \\V {g} +\\V {z} \n}\n\nIn short, our algorithm can be summarized more succinctly as below.\n\\begin {itemize}\n\\item Let \\m {\\g_{\\mathrm {DS}} \\geq 0} be given.\n\\item Input \\m {\\M {F} _B \\in \\mathbb {C} ^{N_R \\D N_B}},\n\\m {\\M {F} _R \\in \\mathbb {C} ^{N_{H,t} \\D N_R}},\n\\m {\\M {W} _R \\in \\mathbb {C} ^{N_R \\D N_{H,r}}},\n\\m {\\M {W} _B \\in \\mathbb {C} ^{N_B \\D N_R}},\nand \\m {\\M {Y} \\in \\mathbb {C} ^{N_B \\D N_B}}.\n\\item Find \\m {\\M {P} \\in \\mathbb {C} ^{N_B ^2 \\D N_{H,t} N_{H,r}}}, \\m {\\V {y} \\in \\mathbb {C} ^{N_B ^2}} as in above.\n\\item Compute the convex program\n\\Disp {\n\\hat {\\V {g}}\n\\leftarrow \\begin {cases}\n\\Min {\\V {g}' \\in \\mathbb {C} ^{N_{H,t} N_{H,r}}} & \\VNm {\\V {g}'} _1 \\\\\n\\mathrm {subject} \\; \\mathrm {to} \\quad & \\VNm {\\M {P}^\\dagger \\RB {\\V {y} -\\M {P} \\V {g}'}} _\\infty \\leq \\g_{\\mathrm {DS}} \\\\\n\\end {cases} \n}\n\\item Convert \\m {\\hat {\\V {g}}} back to the space domain, namely\n\\Disp {\n\\hat {\\M {G}}\n\\leftarrow \\mathrm {vec}^{-1} \\RB {\\hat {\\V {g}}} \n}\n\\item Recover the estimated \\m {\\hat {\\M {H}}}, as\n\\Disp {\n\\hat {\\M {H}}\n\\leftarrow \\M {K} _r \\hat {\\M {G}} \\M {K}^\\dagger _t\n}\n\\item Output \\m {\\hat {\\M {H}}}.\n\\end {itemize}\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\n\\section{Error Analysis}\n\nLet \\m {\\hat {\\V {g}}} be the Dantzig Selector, and let the sparsity level \\m {S} be fixed.\nSplit \\m {\\V {g}} into two parts: \\m {\\V {g} _{\\SB{\\mathcal {A}}}}, the largest-magnitude \\m {s} components of \\m {\\V {g}}, \\m {\\V {g} _{\\SB{\\mathcal {B}}}} the next \\m {s} largest-magnitude components of \\m {\\V {g}}, and \\m {\\V {g} _{\\SB{\\mathcal {C}}}} are the components complement to \\m {\\V {g} _{\\SB{\\mathcal {A}}}}.\nFor example, if \\m {\\V {g} =\\IP {-1,3,-4,2,8}}, and \\m {S=2}, then \\m {\\V {g} _{\\SB{\\mathcal {A}}} =\\IP {0,0,-4,0,8}}, \\m {\\V {g} _{\\SB{\\mathcal {B}}} =\\IP {0,3,0,2,0}}, and \\m {\\V {g} _{\\SB{\\mathcal {C}}} =\\IP {-1,3,0,2,0}}.\nIn this section, the subscripts \\m {\\mathcal {A}, \\mathcal {B}, \\mathcal {C}} will bear analogous meaning.\n\nWe hope that \\m {\\VNm {\\V {g} _{\\SB{\\mathcal {C}}}} _1} is small.\nIf so, we shall substitute the quantity into the expected square error of DS, thus generalizing to the almost-sparse case.\nRecall that \\m {\\M {G}} is just the vectorization of \\m {\\V {g}}, and is the function of \\m {\\V {a}}, so we seek to establish that \\m {\\V {a}} is almost sparse.\nWe define, similarly, \\m {\\V {a} _{\\SB{\\mathcal {A}}}} and \\m {\\V {a} _{\\SB{\\mathcal {C}}}}, with sparsity level \\m {s} different from \\m {S}.\nIf \\m {N} is large, we may forget for a moment that \\m {s} is an integer.\n\n\\subsection {Sparsity of channel}\n\nTo simplify expressions, define\n\\Disp {\n\\f_l\n= &2\\pi \\frac {d_{\\mathrm {arr}}} {\\l_{\\mathrm {arr}}} \\sin \\f_l'\n  \\; \\mathrm {mod}\\; \\RB {2\\pi} \\\\\n\\th_l\n= &2\\pi \\frac {d_{\\mathrm {arr}}} {\\l_{\\mathrm {arr}}} \\sin \\th_l'\n  \\; \\mathrm {mod}\\; \\RB {2\\pi}  \\\\\n\\V {b} \\RB {\\f}\n= &\\M {K}^\\Adj \\V {a} \\RB {\\f}\n}\n\n\\textbf {Proposition 1}\nLet \\m {\\f} be given.\nThen, for any random instance of \\m {\\f},\n\\Disp {\n\\VNm {\\V {b} \\RB {\\f} _{\\SB{\\mathcal {C}}}} _1\n\\leq \\frac {2} {\\pi} \\log N \n}\n\nTo show this, introduce\n\\Disp {\n\\psi \\RB {\\f, n_H}\n:=\\RB {\n   \\f \\; \\mathrm {mod}\\; \\frac {2\\pi} {N}\n   + \\RB {\\frac {2 n_H} {N} + 1} \\pi\n} \\;\n\\mathrm {mod}\\; \\RB {2\\pi}\n- \\pi \n}\nBy using suitable remainder terms to estimate the Maclaurin series,\n\\Disp {\n\\frac {\\Nm {\\sin \\RB {N \\psi'/2}}} {\\Nm {\\sin \\RB {\\psi' /2}}}\n\\leq &B \\RB {\\psi'}\n:= \\frac {48} {\\Nm {\\psi'^2 -24} \\Nm {\\psi'}}, \\\\\n}\nThen, a simple verification shows\n\\Disp {\n\\VNm {\\V {b} \\RB {\\f} _{\\SB{\\mathcal {C}}}} _1\n\\leq \\frac {1} {N}\n\\VNm {\n\\RB {\n   \\sum_{n_H' =0}^{N -1}\n      B \\RB {\\psi \\RB {\\f, n_H'}}\n      \\V {u} _{n_H'}\n} _{\\SB{\\mathcal {C}}}\n} _1\n}\nOr, if we carry out the integral and drop \\m {s},\n\\Disp {\n\\VNm {\\V {b} \\RB {\\f} _{\\SB{\\mathcal {C}}}} _1\n\\leq &\\frac {1} {N} \\D \\frac {N} {2\\pi} \\D 2 \\int_{\\pi s/N}^{\\pi} B \\RB {\\psi} ^2 d \\psi \\\\\n= &\\frac {48} {N \\pi^3}\n\\int _{s /N} ^1 \\frac {1} {\\RB {24/\\pi^2 -x^2} ^2 x^2} dx \\\\\n\\leq &\\frac {2} {\\pi} \\log N \n}\n\n\\textbf {Proposition 2}\nThe bound\n\\Disp {\n\\VNm {\\M {g} _{\\SB{\\mathcal {C}}}} _1\n\\leq \\frac {1} {3} L \\RB {\\log N_{H,t} + \\log N_{H,r}} ^2\n}\nholds for probability \\m {p}, with\n\\Disp {\n1 -p\n\\leq 2 \\exp \\RB {- \\frac {9L} {\\pi}} \n}\nThis is proved by using Proposition 1 with triangle inequality, and bound the sample mean by Hoeffding inequality.\n\n\n% % % % % % % % % % % % % % % %\n\n\\subsection {Generating beamforming matrices}\n\nTo investigate \\m {\\VNm {\\M {F} _B \\V {u}} _2} (respectively for \\m {\\M {W} _B}), for \\m {\\V {u}} is a unit vector, we need a large deviation result for i.i.d.\\ sum of chi-square random variables \\cite {LaM00}, as below.\n\n\\textbf {Proposition 3}\nIt holds that\n%\n\\Disp {\n\\Nm {\\VNm {\\M {F} _B \\V {u}} _2 ^2 - 1}\n\\geq \\d_s \n}\nfor probability \\m {p}, with\n\\Disp {\n1 -p\n\\leq 2 \\mathsf {e} ^{-N_R \\R {\\d_s} /4} \n}\n\nTo investigate \\m {\\VNm {\\M {F} _B \\V {u}} _2} (respectively for \\m {\\M {W} _B}), we apply a bound for the failure probability of a DFT submatrix with \\m {\\d_s} RIP, in Haviv and Regev, ``The restricted isometry property of subsampled Fourier matrices'' \\cite {KlM17}, and drop lower ordered terms as below,\n\n\\textbf {Proposition 4}\nSuppose\n\\Disp {\nN_R\n\\geq \\frac {s} {\\d_s^2} \\RB {\\log s}^2 \\log N_{H,t}\n}\nThen \\m {\\M {F}_R} (respectively \\m {\\M {W} _R}) has \\m {\\d_s} RIP for probability \\m {p}, with\n\\Disp {\n1 -p\n\\leq \\RB {\\frac {\\d_s} {N_{H,t} s}} ^{1/3} \n}\n\nSince both \\m {\\M {F}_B^\\Tr \\M {F}_R^\\Tr} and \\m {\\M {W}_B \\M {W}_R} are \\m {\\d_s} RIP, it does appear (if we ignore the sparsity constraint) that \\m {\\M {P}} has approximately \\m {2\\d_s} RIP.\nHowever, it remain to show that their Kronecker product still has RIP.\n\nNevertheless, notice that if angles \\m {\\th_l} (respectively \\m {\\f_l}) are exactly the multiples of \\m {2 \\pi / N_{H,t}} (respectively \\m {2 \\pi / N_{H,r}}), then for some \\m {S}-sparse \\m {\\V {d}'} and unitary \\m {\\M {U}},\n\\Disp {\n&\\VNm {\\M {W} _B \\M {W} _R \\M {H} \\M {F} _R \\M {F} _B} _2 \\notag \\\\\n= &\\VNm {\n   \\M {W} _B \\M {W} _R \\M {K} _r \\M {U} \\D\n   \\mathrm {diag} \\SB {\\mathrm {abs} \\SB {\\V {d}'}} \\D\n   \\M {U} ^\\dagger \\M {K} _t ^\\dagger \\M {F} _R \\M {F} _B} _2 \\notag \\\\\n= &\\VNm {\n   \\M {W} _B \\M {W} _R \\M {K} _r \\M {U}\n   \\R {\\mathrm {abs} \\SB {\\V {d}'}}} _2 \\D\n   \\VNm {\\M {F} _B ^\\dagger \\M {F} _R ^\\dagger \\M {K} _t \\M {U}\n   \\R {\\mathrm {abs} \\SB {\\V {d}'}}} _2 \\notag \\\\\n\\eqsim &\\VNm {\\M {G}} _2 \\RB {1 +2\\d_s} \n}\nThus, even we cannot make sure that \\m {\\M {P}} is \\m {\\d_s} RIP with respect to all possible \\m {\\V {g}}'s, at least \\m {\\M {P}} has RIP with respect to relevant values of \\m {\\V {g}} for which the channel is sparse.\n\n\n\n% % % % % % % % % % % % % % % %\n\n\\subsection {Bound for expected error norm}\n\nSet for short \\m {\\V {d} = \\hat {\\V {g}} - \\V {g}}.\nAnd for convenience, let \\m {N_h = N_{H,t} N_{H,r}}.\n%\nTo bound \\m {\\VNm {\\V {d}} _2}, we illustrate that \\m {\\V {g}} can be seen as sparse, and for that purpose we generously bound \\m {\\d_{S}} by \\m {1}.\nWe shall see below that it suffices to set\n\\Disp {\n\\g\n= \\R {2 \\log N_h} \n}\n\nThe propositions below are taken from \\cite {CaT07} and modified slightly according to our settings.\n\n\\textbf {Proposition 5}\n\\Disp {\n\\VNm {\\V {d} _{\\SB{\\mathcal {C}}}} _1\n\\leq \\VNm {\\V {d} _{\\SB{\\mathcal {A}}}} _1\n+\\VNm {\\V {g} _{\\SB{\\mathcal {C}}}} _1 \n}\n\n\\textbf {Proposition 6}\n\\Disp {\n\\VNm {\\M {P}^\\dagger \\M {P} \\V {d}} _\\infty\n\\leq 2 \\R {2 \\log N_h} \n}\nfor probability \\m {p}, with\n\\Disp {\n1 -p\n\\leq N_h^{-1}.\n}\n\n\\textbf {Proposition 7}\n\\Disp {\n\\VNm {\\V {d}} _2\n\\leq \\VNm {\\V {d} _{\\SB {\\mathcal {AB}}}} _2 + \\frac {1} {\\R {S}} \\VNm {\\V {d} _{\\SB{\\mathcal {C}}}} _1 \n}\n\n\\textbf {Proposition 8}\n\\Disp {\n\\VNm {\\V {d} _{\\SB{\\mathcal {AB}}}} _2\n\\leq \\frac {1} {1- \\R{2} \\d_{S}} \\VNm {P _{\\SB {\\mathcal {AB}}}^\\intercal P d} _2\n+ \\frac {\\R{3} \\d_{S}} {\\RB {1- \\R{2} \\d_{S}} \\R {S}} \\VNm {d_{\\SB{\\mathcal {C}}}} _1 \n}\n\nFinally, we shall show the proposed bound.\nFor simplicity, set \\m {S = Ls^2}, thus \\m {S =L \\log N_h}.\nAnd, for concreteness, suppose \\m {\\d_S \\leq 1/8}.\n\n\\textbf {Theorem 9}\nLet \\m {\\V {y}}, \\m {\\M {P}}, \\m {\\V {g}}, \\m {\\hat {\\V {g}}}, \\m {\\V {d}} be defined as above.\nThen it holds that\n\\Disp {\n\\VNm {\\V {d}} _2\n\\eqsim \\mathcal {O} \\RB {\\R {L} \\R {\\log N_h}^3} \n}\nfor probability \\m {p}, with\n\\Disp {\n1 -p\n\\eqsim \\mathcal {O} \\RB {\\mathsf {e} ^{-N_R \\R {\\d_s} /4}} \n}\n\nTo show this, by the definition of truncation, by \\m {\\ell_p} norm inequality, by Proposition 6,\n\\Disp {\n\\VNm {\\M {P} _{\\SB {\\mathcal {AB}}}^\\intercal \\M {P} \\V {d}} _2\n\\leq &\\VNm {\\M {P}^\\intercal \\M {P} \\V {d}} _2 \\\\\n\\leq &\\R {S} \\VNm {\\M {P}^\\intercal \\M {P} \\V {d}} _\\infty \\\\\n\\leq &2.83 \\R {L} \\log N_h\n}\nBy \\m {\\ell_p}-norm inequality, by the definition of truncation, by Proposition 8, and by above,\n\\Disp {\n\\VNm {\\V {d} _{\\SB{\\mathcal {A}}}} _1\n\\leq &\\R {S} \\VNm {\\V {d} _{\\SB{\\mathcal {A}}}} _2 \\\\\n\\leq &\\R {S} \\VNm {\\V {d} _{\\SB{\\mathcal {AB}}}} _2 \\\\\n\\leq &3.44 L \\R {\\log N_h}^3\n+0.262 \\VNm {\\V {d} _{\\SB{\\mathcal {C}}}} _1\n}\nThen, substituting this and Proposition 2 above into Proposition 5, we get\n\\Disp {\n\\VNm {\\V {d} _{\\SB{\\mathcal {C}}}} _1\n\\leq 5.12 L \\RB {\\log N_h}^2\n}\nNow Proposition 8 becomes\n\\Disp {\n\\VNm {\\V {d} _{\\SB{\\mathcal {AB}}}} _2\n\\leq 3.44 \\R {L} \\log N_h + 1.35 \\R {L} \\R {\\log N_h} ^3\n}\nFinally, by plugging \\m {\\VNm {\\V {d} _{\\SB{\\mathcal {AB}}}} _2} and \\m {\\VNm {\\V {d} _{\\SB{\\mathcal {C}}}} _1} into Proposition 7, we get\n\\Disp {\n\\VNm {\\V {d}} _2\n\\leq 4.79 \\R {L} \\R {\\log N_h}^3\n}\nTherefore, we set \\m {\\chi = \\R {L} \\R {\\log N_h}^3}, so that \\m {\\VNm {\\V {d}} _2 = \\mathcal {O} \\RB {\\chi}}, as claimed.\nThe failure probability is taken from Proposition 3.\n\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\n\\section{Simulation}\n\n\\subsection{Settings}\n\nFirst, complex numbers have to be recorded as the real and imaginary parts, to speed up calculation.\nLet \\m {\\mathcal {R}} denote the representation of complex vectors and matrices by real vectors and matrices.\nWith definitions \\m {\\tilde {\\V {y}} = \\mathcal {R} \\RB {\\V {y}}},\n\\m {\\tilde {\\V {g}} = \\mathcal {R} \\RB {\\V {g}}},\n\\m {\\tilde {\\M {P}} = \\mathcal {R} \\RB {\\M {P}}},\n\\m {\\tilde {\\V {z}} = \\mathcal {R} \\RB {\\V {z}}},\nwe have by construction\n\\Disp {\n\\V {\\tilde {y}}\n= \\M {\\tilde {P}} \\V {\\tilde {g}} +\\V {\\tilde {z}} \n}\n\nTo do convex optimization, we choose the Python library CVXPY.\nConsidering its high complexity, there are several possible methods.\nFirst of all, it is equivalent to a linear program.\nMoreover, we may apply DS more than once to better estimate the nonzero components:\nWe apply DS for the first time, and we extract largest components of the estimated vector, then apply Moore–Penrose inverse to get the returned solution, before scrambling back the resulting indices to the original ones.\nIn doing such successive estimation, it is possible to have more than one stage of extraction \\cite {CaT07}.\n\nAlternatively, in our investigation, we cast DS into a basis pursuit denoising form, for suitable \\m {\\l} \\cite {BoV04} as below.\n\\Disp {\n\\Hat {\\V {g}}\n\\leftarrow \\Min {\\V {g}' \\in \\mathbb {C} ^{N_{H,t} N_{H,r}}}\n\\RB {\\VNm {\\V {g}'} _1 + \\l \\VNm {\\M {P}^\\Adj \\RB {\\V {y} -\\M {P} \\V {g}'}} _\\infty}\n}\nHowever, there is no simple way to determine the value of \\m {\\l} in advance.\nWe have tried \\m {\\l = N_{H,t} N_{H,r} / \\g_{\\mathrm {DS}}} in the simulation.\n\nIn addition to DS, we shall simulate OMP for three different stop conditions, Lasso, and Moore Penrose pseudoinverse (marked as LS which stands for least square).\nEach data point for DS and Lasso is repeated for \\m {256} times, and taken arithmetic average.\nOther methods are repeated for more times: OMP for \\m {4 \\D 256} times, LS for \\m {12 \\D 256} times.\n\nLet \\m {1/\\s} be the SNR, which takes value starting with \\m {2^{-2}}, and being multiplied by powers of \\m {\\R {2}}, for \\m {6} values.\nWe take \\m {N_B} to be \\m {2, 4, 6}, respectively.\nThree series of plots are simulated.\nThe first series for \\m {N_{H,t} = 3 N_B} and \\m {N_{H,r} = 3 N_B}.\nThe second series for \\m {N_{H,t} = 3 N_B} and \\m {N_{H,r} = 4 N_B}.\nThe third series for \\m {N_{H,t} = 4 N_B} and \\m {N_{H,r} = 3 N_B}.\nUnfortunately, this is very far from achieving the ideal values for which our approximation is valid, and this may be part of the reason the result is not as successful as expected.\n\nOther parameters are fixed in these experiments.\nThe number of grid of quantization of phase shifters is \\m {16}.\nThe number of paths \\m {L = \\lfloor \\R {N_{H,t} N_{H,r}} / 2 \\rfloor}.\nThe ratio of the wavelength of carrier over the antenna spacing, \\m {\\l _{\\mathrm {ant}} / d _{\\mathrm {ant}} = 1 / 2}.\n\nDenote the threshold for DS to be \\m {\\g_{\\mathrm {DS}}}, and similar threshold of Lasso to be \\m {\\g_{\\mathrm {Lasso}}}.\nWe set \\m {\\g_{\\mathrm {DS}} = 2 \\log \\RB {N_{H,t} N_{H,r}}} as suggested in \\cite {CaT07}.\nFor sake of comparison, \\m {\\g_{\\mathrm {Lasso}} = \\g_{\\mathrm {DS}}}.\n\nFor OMP, we consult Cai and Wang \\cite {CaW11} for \\m {\\ell _2}-norm condition in their Theorem 7, and \\m {\\ell _\\infty}-norm condition in their Theorem 8.\nWe take \\m {\\h_{\\mathrm {OMP}} = \\R {2 \\log \\RB {N_{H,t} N_{H,r}}}} for \\m {\\infty}-norm condition, \\m {\\h_{\\mathrm {OMP}} = \\R {3 N_B}} for 2-norm condition.\n\nFor Lasso, \\m {\\l _{\\mathrm {Lasso}}} is also crucial to the performance, but cannot be obtained in advance.\nThus, for sake of comparison, we set the same threshold for Lasso and DS.\nIn view of the fact that \\m {\\VNm {g} _1 \\leq 2 N_{H,t} N_{H,r} \\VNm {g} _\\infty}, we tentatively set \\m {\\l _{\\mathrm {DS}} =  N_{H,t} N_{H,r} / \\g _{\\mathrm {DS}}} and \\m {\\l _{\\mathrm {Lasso}} =  1 / \\g _{\\mathrm {Lasso}}}.\nStill, there may be other values of \\m {\\g} (or \\m {\\l}) for which DS and Lasso are both better.\n\nFor performance metric, we also follow Lee, Gil, and Lee \\cite {LGL16} to use\n\\Disp {\n\\tilde {\\chi}\n=\\RB {\n   \\frac {\\log_2 {\\VNm {\\V {h} -\\hat {\\V {h}}} _2}}\n   {\\log_2 {\\VNm {\\V {h}}_2}}\n} _{\\mathsf {avg}}, \n}\nHowever, we remark that when \\m {\\VNm {\\V {h}}_2} is small, this can blow up.\nIndeed, since we did not consider a definite a channel model in this treatise, \\m {\\T {\\chi}} may not necessarily be proportional to the channel capacity.\n\n\\subsection {Result}\n\nIn the following, we plot for different values and ratios of \\m {N_B, N_{H,t}, N_{H,r}}.\nWe fix \\m {N_R = \\RB {3/2} N_B}, and with \\m {6} sets of observation.\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-small-more-tall-six-usual.png}\n\\caption {\\m {N_B = 2, N_{H,t} = 6, N_{H,r} = 8}, error.}\n\\end {figure}\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-small-more-wide-six-usual.png}\n\\caption {\\m {N_B = 2, N_{H,t} = 8, N_{H,r} = 6}, error.}\n\\end {figure}\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-medium-more-tall-six-usual.png}\n\\caption {\\m {N_B = 4, N_{H,t} = 12, N_{H,r} = 16}, error.}\n\\end {figure}\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-medium-more-wide-six-usual.png}\n\\caption {\\m {N_B = 4, N_{H,t} = 16, N_{H,r} = 12}, error.}\n\\end {figure}\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-big-more-tall-six-usual.png}\n\\caption {\\m {N_B = 6, N_{H,t} = 24, N_{H,r} = 18}, error.}\n\\end {figure}\n\n\\begin {figure} [H]\n\\includegraphics [width = 0.45 \\textwidth]\n{error-big-more-wide-six-usual.png}\n\\caption {\\m {N_B = 6, N_{H,t} = 18, N_{H,r} = 24}, error.}\n\\end {figure}\n\n\\subsection {Discussion}\n\nFrom the simulation, DS outperforms other methods in most of the datasets.\nWith low noise, \\m {\\tilde {\\chi} _{\\mathrm {DS}} \\approx \\tilde {\\chi} _{\\mathrm {OMP}} \\leq \\tilde {\\chi} _{\\mathrm {Lasso}} \\leq \\tilde {\\chi} _{\\mathrm {LS}}},\nalthough sometimes \\m {\\tilde {\\chi} _{\\mathrm {DS}} \\geq \\tilde {\\chi} _{\\mathrm {OMP}}}.\nWith high noise, \\m {\\tilde {\\chi} _{\\mathrm {DS}} \\approx \\tilde {\\chi} _{\\mathrm {Lasso}} \\leq \\tilde {\\chi} _{\\mathrm {OMP}} \\leq \\tilde {\\chi} _{\\mathrm {LS}}}.\nalthough sometimes \\m {\\tilde {\\chi} _{\\mathrm {DS}} \\geq \\tilde {\\chi} _{\\mathrm {Lasso}}}.\nLS is so much poorer that it is not a main contender.\nThese trends is true with different number of stages, and with the case \\m {N_B = N_R}.\nIn general, we can say that overall, DS gives a better regularization for both low noise and high noise scenario, and in most cases, DS is even better than both of them.\n\nDiffering thresholds does not to seem have much effect on OMP and DS.\nMeanwhile for Lasso, where a suitable threshold may improve the accuracy, but a excessively tight threshold may also result in a overfitting, and blowing up for high signal cases.\nIncreasing the number of stages obviously improves the estimation for all methods.\n\nUnfortunately, we report that CVXPY sometimes gives overflowing values, some of them as large as \\m {10^{11}}.\nThis probably indicates some typical-looking output may in fact be unreliable.\nTherefore we have discarded outputs larger than a given threshold, for instance \\m {10^4}, and simply return the answer to be a Moore–Penrose inverse.\n\n\\m {\\chi} is not shown in the figure, because the big O bound is much larger than \\m {\\tilde {\\chi}}.\nIt is possible that the nonsparsity of \\m {\\V {g}} undermines the analysis in chapter 3, despite our attempts to account for that effect.\nIt is curious to see whether for very large \\m {N_H}, whether \\m {\\tilde {\\chi}} and \\m {\\chi} will be asymptotically close.\n\n\\subsection {Complexity}\n\nWe discuss the complexity of DS, Lasso, and OMP.\nFor DS, suppose a linear program has an \\m {N} dimensional variable and \\m {M} inequality constraints, then its complexity is \\m {\\mathcal {O} \\RB {N^2 M}}, assuming the Dantzig simplex method is used \\cite {BoV04}.\nFor our case, that would be \\m {\\mathcal {O} \\RB {4 N_h ^2 \\D 8 N_h} = \\mathcal {O} \\RB {N_h ^3}}.\n\nAlternatively, suppose Newton method is used.\nHere, we have self-concordance for linear program \\cite {BoV04}.\nLet \\m {\\V {g} _0} denote the starting value of \\m {\\V {g}'}, and \\m {\\V {g} ^{\\star}} the the point of convergence.\nThen the number of Newton steps, which we take to be the complexity, is bounded by \\cite {BoV04}\n\\Disp {\nN_{\\mathrm {Newton}}\n\\propto \\RB {\\VNm {\\V {g}_0 -\\V {g} ^{\\star}}_1\n+ \\log_2 \\log_2 \\frac {1} {\\e}}\n}\n\nAssume that, at the start the iteration, the Moore–Penrose inverse is close to the initial value of \\m {\\V {g}_0}, namely\n%\n\\Disp {\n\\V {g}_0\n=\\V {g}_{\\mathrm {LS}}\n= \\RB {\\M {P} ^\\dagger \\M {P}} ^{-1} \\M {P} ^\\dagger \\V {y} \n}\nAnd suppose that, in view of restricted isometry, \\m {\\M {P}} has unity-normed, almost orthogonal columns, so that\n\\m {\\M {P} ^\\dagger \\M {P} \\approx I _{N_h}}\nMoreover, assume that \\m {\\V {g} ^\\star \\approx \\V {g}}.\nThen we simply have\n\\Disp {\nC_{\\mathrm {DS}}\n=\\mathcal {O} \\RB {N_h ^3} \n}\n\nFor OMP \\cite {TrG07}, \\m {C_{\\mathrm {OMP}} =\\mathcal {O} \\RB {L \\RB {\\log N_h} ^2}}.\n\nFor Lasso, it is equivalent to a quadratically constrained quadratic program, and there is not always a closed form for its complexity.\nHowever, Lasso and DS are equivalent in certain conditions \\cite {AsR10}, and we may suppose here they have the same complexity.\nAlternatively, an argument similar to the above one for DS is valid for Lasso.\nTherefore we take \\m {C_{\\mathrm {Lasso}} =\\mathcal {O} \\RB {N_h ^3}}.\n\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\n\\section{Conclusion}\n\nThe treatise aims to answer the problem of effective estimating a MIMO mm-wave channel by exploiting its sparsity.\nTo do so, we apply the Dantzig Selector (DS), by exploiting the sparsity in the spatial frequency domain, and justified the restricted isometry of the effective beamforming matrix.\nWe then prove quantitatively that the expected error norm is bounded for overwhelming probability.\nWe also suggest several ways of reducing the complexity without losing much performance.\nSimulation is done, and we see that DS indeed outperforms other methods in most datasets.\n\nSince we have RIP, a whole series of compressive sensing techniques become possible.\nBut moreover, we corroborate the prediction that DS gives better regularization, and it may extract more information than other methods do when the sampling rate is low.\nIn particular, when the sample is less abundant and the noise level is higher, sometimes only DS can recover successfully.\nTherefore, one may use DS for sake of higher precision, or with limited RF chains and fewer stages of estimation, for example, in the ultra reliable or low latency scenario.\n\n\\section*{Acknowledgment}\n\nThe authors would like to thank the heaven.\n\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\n\n\\begin{thebibliography}{30}\n\\bibitem{RSM13}\nT. S. Rappaport, S. Sun, R. Mayzus, H. Zhao, Y. Azar, K. Wang, G. N. Wong, J. K. Schulz, M. Samimi, and F. Gutierrez, “Millimeter wave mobile communications for 5g cellular: It will work!” \\textit {IEEE access}, vol. 1, pp. 335–349, 2013.\n\\bibitem{RDD18}\nM. Rani, S. B. Dhok, and R. Deshmukh, “A systematic review of compressive sensing: Concepts, implementations and applications,” \\textit {IEEE Access}, vol. 6, pp. 4875–4894, 2018.\n\\bibitem{CaT05}\nE. J. Candès and T. Tao, “Decoding by linear programming,” \\textit {IEEE Transactions on Information Theory}, vol. 51, no. 12, p. 4203, 2005.\n\\bibitem{CaT07}\nE. Candès and T. Tao, “The dantzig selector: Statistical estimation when p is much larger than n,” \\textit {The annals of Statistics}, vol. 35, no. 6, pp. 2313–2351, 2007.\n\\bibitem{BDD08}\n[6] R. Baraniuk, M. Davenport, R. DeVore, and M. Wakin, “A simple proof of the restricted isometry property for random matrices,” \\textit {Constructive Approximation}, vol. 28, no. 3, pp. 253–263, 2008.\n\\bibitem{BHS10}\nW. U. Bajwa, J. Haupt, A. M. Sayeed, and R. Nowak, “Compressed channel sensing: A new approach to estimating sparse multipath channels,” \\textit {Proceedings of the IEEE}, vol. 98, no. 6, pp. 1058–1076, 2010.\n\\bibitem{BHR08}\nW. U. Bajwa, J. Haupt, G. Raz, and R. Nowak, “Compressed channel sensing,” 2008 \\textit {42nd Annual Conference on Information Sciences and Systems}, pp. 5–10, 2008.\n\\bibitem{AsR10}\nM. S. Asif and J. Romberg, “On the lasso and dantzig selector equivalence,” 2010 \\textit {44th Annual Conference on Information Sciences and Systems} (CISS), pp. 1–6, 2010.\n\\bibitem{LLL17}\nL. Lian, A. Liu, and V. K. Lau, “Optimal-tuned weighted lasso for massive mimo channel estimation with limited rf chains,” \\textit {IEEE Global Communications Conference}, pp. 1–6, 2017.\n\\bibitem{DJN15}\nG. Destino, M. Juntti, and S. Nagaraj, “Leveraging sparsity into massive mimo channel estimation with the adaptive-lasso,” \\textit {IEEE Global Conference on Signal and Information Processing} (GlobalSIP), pp. 166–170, 2015.\n\\bibitem{VAT19}\nE. Vlachos, G. C. Alexandropoulos, and J. Thompson, “Wideband mimo channel estimation for hybrid beamforming millimeter wave systems via random spatial sampling,” \\textit {IEEE Journal of Selected Topics in Signal Processing}, vol. 13, no. 5, pp. 1136–1150, 2019.\n\\bibitem{TrG07}\nJ. A. Tropp and A. C. Gilbert, “Signal recovery from random measurements via orthogonal matching pursuit,” \\textit {IEEE Transactions on information theory}, vol. 53, no. 12, pp. 4655–4666, 2007.\n\\bibitem{ALH15}\nA. Alkhateeb, G. Leus, and R. W. Heath, “Compressed sensing based multi-user millimeter wave systems: How many measurements are needed?” 2015 \\textit {IEEE International Conference on Acoustics, Speech and Signal Processing} (ICASSP), pp. 2909–2913, 2015.\n\\bibitem{HWH13}\nD. Hu, X. Wang, and L. He, “A new sparse channel estimation and tracking method for time-varying ofdm systems,” \\textit {IEEE Transactions on Vehicular Technology}, vol. 62, no. 9, pp. 4648–4653, 2013.\n\\bibitem{LGL16}\nJ. Lee, G.-T. Gil, and Y. H. Lee, “Channel estimation via orthogonal matching pursuit for hybrid mimo systems in millimeter wave communications,” \\textit {IEEE Transactions on Communications}, vol. 64, no. 6, pp. 2370–2386, 2016.\n\\bibitem{GDW15}\nZ. Gao, L. Dai, Z. Wang, and S. Chen, “Spatially common sparsity based adaptive channel estimation and feedback for fdd massive mimo,” \\textit {IEEE Transactions on Signal Processing}, vol. 63, no. 23, pp. 6169–6183, 2015.\n\\bibitem{CWX10}\nT. T. Cai, L. Wang, and G. Xu, “Stable recovery of sparse signals and an oracle inequality,” \\textit {IEEE Transactions on Information Theory}, vol. 56, no. 7, pp. 3516–3522, 2010.\n\\bibitem{CaW11}\nT. T. Cai and L. Wang, “Orthogonal matching pursuit for sparse signal recovery with noise,” \\textit {IEEE Transactions on Information Theory}, 2011.\n\\bibitem{BEE10}\nZ. Ben-Haim, Y. C. Eldar, and M. Elad, “Coherence-based performance guarantees for estimating a sparse vector under random noise,” \\textit {IEEE Transactions on Signal Processing}, vol. 58, no. 10, pp. 5030–5043, 2010.\n\\bibitem{ALS14}\nM. R. Akdeniz, Y. Liu, M. K. Samimi, S. Sun, S. Rangan, T. S. Rappaport, and E. Erkip, “Millimeter wave channel modeling and cellular capacity evaluation,” \\textit {IEEE journal on selected areas in communications}, vol. 32, no. 6, pp. 1164–1179, 2014.\n\\bibitem{LaM00}\nB. Laurent and P. Massart, “Adaptive estimation of a quadratic functional by model selection,” \\textit {Annals of Statistics}, pp. 1302–1338, 2000.\n\\bibitem{KlM17}\nB. Klartag and E. Milman, \\textit {Geometric Aspects of Functional Analysis}. Springer, 2017.\n\\bibitem{BoV04}\nS. Boyd and L. Vandenberghe, \\textit {Convex optimization}. Cambridge U. press, 2004.\n\\bibitem{FrS07}\nM. P. Friedlander and M. A. Saunders, “Discussion: The dantzig selector: Statistical estimation when p is much larger than n,” \\textit {The Annals of Statistics}, vol. 35, no. 6, pp. 2385–2391, 2007.\n\n\\end{thebibliography}\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "77bc39068b32739b3a9aefd0aa4a600364051f60", "size": 40435, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "article/main.tex", "max_stars_repo_name": "violapterin/channel-estimation-via-dantzig-selector-paper", "max_stars_repo_head_hexsha": "a30f47c9951f7e47a3842a6f131f2bdd32fff5bf", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "article/main.tex", "max_issues_repo_name": "violapterin/channel-estimation-via-dantzig-selector-paper", "max_issues_repo_head_hexsha": "a30f47c9951f7e47a3842a6f131f2bdd32fff5bf", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "article/main.tex", "max_forks_repo_name": "violapterin/channel-estimation-via-dantzig-selector-paper", "max_forks_repo_head_hexsha": "a30f47c9951f7e47a3842a6f131f2bdd32fff5bf", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-14T00:56:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T00:56:32.000Z", "avg_line_length": 50.6704260652, "max_line_length": 321, "alphanum_fraction": 0.6700630642, "num_tokens": 13374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4146546313667571}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{tipa}\n\\date{February 24, 2018}\n\n\\begin{document}\n\\title{Finding Lane Lines, Part 1}\n\\author{Alexander Mont}\n\\maketitle\n\\section{Pipeline Overview}\n\nHere is a simple project for finding the lane lines on a road image. The pipeline consisted of the following steps:\n\n\\begin{enumerate}\n\\item First, we convert the image to grayscale. This is because the subsequent algorithms to be run on this, such as Canny edge detection, only work on grayscale images. Note that we do this by using the OpenCV function \\texttt{cv2.cvtColor(img, cv2.COLOR\\_RGB2GRAY}, which treats all of the three color channels (red, green, blue) equally.\n\\item Then, we apply Canny edge detection. Canny edge detection works by computing the \\emph{gradient} (difference between adjacent pixels) of the image, and highlights only the places where this gradient is highest - i.e., where there is an edge. Note that this effectively turns a segment of a lane line (a dotted line) into a quadrilateral, and turns a solid lane line into two edges.\n\\item The output of Canny edge detection is just a pixel bitmap showing which pixels are part of edges. Now we need to turn these pixels into lines. To do this we use the Hough transform, and algorithm which does the following:\n\\begin{enumerate}\n\\item Considers the ``space of possible lines'' defined by $\\theta$ (the angle of the line), and $\\rho$ (the shortest distance of the line from the origin) - this is referred to as the ``Hough space''.\n\\item Each highlighted point defines a curve in the Hough space representing the possible lines that contain that point.\n\\item Points in Hough space where lots of the above lines intersect represent lines in the original space (the more Hough curves intersect at that point in Hough space, the longer that line is)\n\\end{enumerate}\n\\item This process is likely to generate multiple lines for each lane line, so we must now combine these lines into just two lines - one on the left side and one on the right side. We do this as follows:\n\\begin{enumerate}\n\\item Divide up the lines into two categories: one with negative slope (on the left) and one with positive slope (on the right). The negative slope is on the left because the X axis goes from left to right, but the Y axis goes from the top dow.\n\\item In each of these categories, compute the \\emph{smallest} (absolute value of) slope, where slope here is defined as $\\frac{x}{y}$ - note that this is different from how slope is usually defined. We do it this way so that a nearly vertical line will not cause numerical issues due to the extremely high slope (and we expect nearly vertical lines to be more frequent than nearly horizontal lines(\n\\item On each side, we consider only Hough lines with a slope of no more than 0.2 away from this ``smallest slope''. The purpose of this is to filter out any lane lines other than the lines that bound the lane the car is in (a lane line multiple lanes over will have a higher slope)\n\\item We compute the average of the slopes of these lines to get the overall slope of the lane line, and then compute the intercept by fitting a line of the given slope through the endpoints of all the Hough lines.\n\\end{enumerate}\n\\item Then we draw the overall lane lines.\n\\end{enumerate}\n\nIt is also possible to use this algorithm to annotate the lane lines in a video by applying the above algorithm to each frame in the video. When I did this I noticed that the drawn lane lines jumped around a lot from frame to frame even though the actual lane lines do not appear to move that much. Thus I changed my algorithm in this case to compute the slope of each line in a given frame as (0.95 * slope of line from previous frame) + (0.05 * observed average slope of the Hough lines as described above). Thus this significantly dampens the frame-to-frame vibrations.\n\n\\section{Discussions and Improvements}\n\nHere are some of the shortcomings of this algorithm and ways it could be improved. I plan to implement these and other improvements in a future project.\n\n\\begin{enumerate}\n\\item The slopes of the Hough lines appear to change a lot from frame to frame spuriously. It is likely that this is because the edges obtained by the Canny edge detection are only one pixel wide (all the pixels in the \"middle\" of the lane line are thrown out) so a change in even a few of these pixels may significantly change the slope. A better approach may be to note that we don't really care about the \\emph{edges} of the lane line per se (the ``lane line'' is really a thin quadrilateral) what we care about is the overall lane line. Therefore, a better approach may be to not use Canny edge detection at all. A better approach may be to do the following:\n\\begin{enumerate}\n\\item Use thresholding to identify which pixels in the image are likely part of lane lines. for instance, any white or yellow pixels are likely part of lane lines. So the thresholding could be based on just the red and green color channels, since yellow has high red and green but low blue.\n\\item Use a flood fill or similar algorithm to segment these ``likely pixels'' into contiguous groups.\n\\item Try to identify which contiguous groups are lane lines on the road (as opposed to other objects such as white or yellow cars). Note that a lane line or lane line segment is expected to be long and thin. Thus, if one took all the $(x,y)$ coordinates of pixels in a lane line and did PCA on them, one would expect to see one very large principal component and one much smaller principal component. This pattern could be easily identified.\n\\item Once we have a contiguous group of pixels that represents a lane line, we can fit a line through it (e.g. using a least squares fit) to get the slope and intercept.\n\\end{enumerate}\n\\item The smoothing technique used between frames in the video works well for the test videos in this project where the car is moving roughly straight, but may not work well in a scenario where the car is changing lanes so the slope of the lane lines actually is changing significantly - it might be slow to catch up. A better solution here may be a Kalman filter which stores as its state both the current slope and a rate of change in slope. Thus if the car was e.g. changing lanes, where the lane line's slope is smoothly changing, the filter would pick up on this and track it.\n\\item The identifying of each lane line by a slope and intercept assumes that it is a straight line. This may not be true if the road is curving or if there is a hill in front of the car This is a major flaw because both of these situations are likely to require action by a self-driving car, so the car would want to know about it. A solution here may be to, after the lane line segments on the road have been identified as described above, to use some sort of clustering algorithm to find \"clusters\" of these line segments in Hough space, and assume that similar clusters represent the same lane lines. This would also mean that the algorithm wouldn't need to assume that there are two primary lane lines, one on each side - it could detect other things that look like lane lines.\n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "eca408eeb2555b59cd61eda69dc2f47ddefd5777", "size": 7177, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "carnd_p1_writeup.tex", "max_stars_repo_name": "alexander-mont/alexander-mont-sdc", "max_stars_repo_head_hexsha": "9673e2403e8386aae4380d9626c6edd7453e4bea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "carnd_p1_writeup.tex", "max_issues_repo_name": "alexander-mont/alexander-mont-sdc", "max_issues_repo_head_hexsha": "9673e2403e8386aae4380d9626c6edd7453e4bea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "carnd_p1_writeup.tex", "max_forks_repo_name": "alexander-mont/alexander-mont-sdc", "max_forks_repo_head_hexsha": "9673e2403e8386aae4380d9626c6edd7453e4bea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 140.7254901961, "max_line_length": 782, "alphanum_fraction": 0.7838929915, "num_tokens": 1592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.41465462714559304}}
{"text": "% !TEX root = ../main.tex\n\\newpage\n\\section{\\mywork Mean Field Reductions for Undirected Graphs} \\label{sec:MFRSUndirected}\nWe will now investigate the questions that were raised after deriving the \\MFR. How do we deal with the curse of dimensionality concerning the degree distribution? If the synchronisation dynamics of the network of Theta neurons in \\eqref{eq:thetaneuronnetwork} can be predicted by the Ott-Antonsen reductions \\eqref{eq:OttAntonsenMeanField}, then it can also be measured by the order parameter \\eqref{eq:orderparameter}. These systems describe the same quantity, but how can we show that?\n\n\n\\subsection{Directed graphs as permutations}\n%So how can we use the \\MFR efficiently when the network is a directed graph with an asymmetrical adjacency matrix? Let us investigate.\nSo how can we use the \\MFR when the network is a directed graph?\n\\begin{list}{$\\bullet$}{}  \n\\item Sampling $\\kinb$ and $\\koutb$ from a bivariate distribution requires us to find the marginal distribution of $P$ for $\\kinb$, sampling $\\kinbi$, and then sampling $\\koutbj$ from $P$ while keeping $\\kinbi$ fixed. This is a cumbersome process. And what relation would there be between $\\kinb$ and $\\koutb$?\n\\item However, if we assume that the marginal distributions for $\\kinb$ an $\\koutb$ are independent, there is a simplification to be found. We can even assume that the two marginal distributions are identical univariate distributions. \n\\item Hence, we can sample $\\kinb$ from a univariate distribution and find $\\koutb = \\permute ( \\kinb )$ so that the total number of links remains constant. This is an important trait, as we do not have to rely on the sheer size of the network to yield a constant number of links on average.\n\\end{list}\n\nThis hypothesis can be tested: we assume that $P(\\k) = P(\\kin) \\cdot P(\\kout)$ so that $P$ consists of two identical and independent distributions, given by the distributions presented in Chapter \\ref{sec:NetworkTopologies}. Then, we sample $\\kinb \\sim P(\\kin)$ and perform a permutation to find $\\koutb$. The surface given by $P(\\k)$ and the histogram of $\\k_j$ have been plotted in Figure \\ref{fig:2Ddistributions}. As we can see, the variates follow the distribution well. \n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[width = \\textwidth]{../Figures/Distributions/2D.pdf}\n\\caption{Bivariate distributions for different network topologies, using 10$^4$ number of samples. The surface given by $P(\\k)$ is well approximated by the histogram of variates sampled from a univariate distribution, used as the marginal distribution. $\\kmean =  2 \\times 10^3$ for all topologies, $p \\approx 0.2$ for the random network and $\\gamma = 4.3$ for the scale-free network.}\n\\label{fig:2Ddistributions}\n\\end{figure}\n%Hence, we can use univariate distributions in our simulations of the Ott-Antonsen Mean Field \\eqref{eq:OttAntonsenMeanField}.\nHowever, the problem remains the same: $\\K$ is too large to simulate the dynamics of the network. \n\nWhat we can do, is use $P(k)$ in the Ott-Antonsen reduction for a symmetric network, and observe how much the solution of the asymmetric network differs from the reduction of the symmetric network. This is an attainable goal.\n\n\\subsection{Building the adjacency matrix} \\label{sec:buildingA}\nIf we want to simulate the network of theta neurons we need to construct the adjacency matrix. We can find an exact solution for $A$ given the degree vectors in \\eqref{eq:definekinkoutfromP}. $A_{ij}$ represents a directed graph, but $A_{ij} \\neq A_{ji}$ is not a necessary condition. For the elements of $A_{ij}$ we need to find $N^2$ number of variables. We have the following constraints:\n\\begin{enumerate}\n\\item The column- and row-sums of $A_{ij}$ must be equal to $\\kinb$ and $\\koutb$, see (\\ref{eq:definekinkoutfromA}). 2$N$ constraints.\n\\item Self-coupling is mandatory: $A_{ii} = \\boldsymbol{1}$. $N$ constraints. \\cite{OttAntonsen2017}\n\\item The total number of links is constant: $\\sum_{i=1}^{N} \\kinbi \\equiv \\sum_{j=1}^{N} \\koutbj \\equiv \\sum_{i,j=1}^{N}A_{i j}$. 1 constraint.\n\\end{enumerate}\nThis means that there are $N^2 - (3N + 1)$ variables to find. Once a solution has been found, $A_{ij}$ can be switched with element $A_{ic}$ if $A_{ij} \\neq A_{ic}$ and $A_{rj}$ with $A_{rc}$, which yields another feasible solution. The solutions to this problem are thus bound by permutation symmetry. The number of switches one can make is high, and therefore we can simply try a stochastic approach to obtain $A$:\n\\begin{enumerate}\n\\item Choose a random row $i \\in [1,N]$. $A_{i,i} = 1$, so we need $m = \\kinbi - 1$ elements that are 1.\n\\item Perform $\\permute ( \\koutbj, j \\neq i)$ and therein find the indices $\\boldsymbol{\\ell}$ of the $m$ first largest elements. \n\\item Set $A_{il} = 1 \\: \\: \\forall \\: \\: l \\in \\permuteinv (\\boldsymbol{\\ell})$.\n\\end{enumerate}\nAlgorithms that find the largest value in a vector start from the first or the last element. The permutation in step 2 allows us to find different maxima every time by shuffling the row, which greatly reduces the event that constraint 1 does not hold. In practice, this stochastic method finds a solution for $A$ within 5 tries.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth]{../Figures/Adjacency_matrices.pdf}\n   \\caption{Adjacency matrices for different types of networks with $N$ = 500 and $\\kmean$ = 100. We can see how the fixed-degree network is quite homogeneous, while the random network shows some more clustering. The scale-free network has a low number of nodes with a very high degree, which is why we see vertical and horizontal stripes in the adjacency matrix.}\n   \\label{fig:adjacencymatrices}\n\\end{figure}\n\n\n\n\\subsection{Initial conditions: analytical versus numerical approaches} \\label{sec:initialconditions}\nAs our goal is to compare theory and simulations, we need to be able to start both at the exact same condition. This notion requires us to transform between the three number sets that our dynamics are described in: $\\theta \\in \\T^N$, $z \\in \\C^{M_{\\k}}$ and $Z, \\bar{Z} \\in \\C$. It is really only necessary to find a transformation that holds accurately for $t=0$, as the distribution of $\\theta$ and $z$ over their number set is unknown, but we assume they converge to that distribution when the systems are computed. \n\n%As the systems in \\cref{eq:orderparameter,eq:OttAntonsenMeanField,eq:MeanField} describe the same dynamics for fully connected networks, it is important to be able to transform initial conditions between systems. If we expect their behaviour to be the same, then we need to test that by starting from the same point in time. Hence we can test whether \\textsl{macroscopically} we can find the same equilibria, but we can also test \\textsl{microscopically} whether the systems arrive at those points at the same time. \n\n%The order parameter \\ref{eq:orderparameter} and the mean-field order parameter \\eqref{eq:OttAntonsenMeanField} describe the same dynamics for fully connected networks. Testing this hypothesis \n\n%  If the initial conditions of all systems are exactly the same, then we should find that they describe the exact same behaviour.\n% - macroscopically and microscopically - and this is the best way to test the \\MFR theory. \n\n%When transforming between $\\theta_i(t) \\leftrightarrow z(\\k,t) \\leftrightarrow Z(t)$ we go from $\\T^N \\leftrightarrow \\C^{M_\\k} \\leftrightarrow \\C$. If we have the same initial conditions, then all systems will predict the same behaviour. We will only map everything to $\\C$.\\\\\nAs we can optimally study the behaviour of $Z$ and $\\bar{Z}$ in the complex unit circle, the most important transformations are those that yield $\\theta$ and $z$ from $Z$ and $\\bar{Z}$ respectively. Hence, we can start our simulations anywhere in $\\C$, close to the limit cycle in Figure \\ref{fig:MFRCPW} for example. Our analysis will benefit from this advantage. \\\\\n\n%As we can study the behaviour of $Z$ and $\\bar{Z}$ in the complex unit circle, the most important relation we need to find is the transformation from $\\C$ to $\\T^{N}$ and from $\\C$ to $\\C^{M_{\\k}}$, which yield the phase angles $\\theta_i(0)$ and the degree dynamics $z(\\k,0)$ from $Z(0)$ and $\\bar{Z}(0)$ respectively. \\\\\n\n% The following maps can be used to transform the initial conditions, but as they do not give any qualitative information on the dynamics or distributions of the variables, they are not valid for transforming between dynamics. \\\\\n\nLet us start with the simplest transformation. Given an initial phase angle $\\theta_i(0)$ or initial degree dynamics $z(\\k, 0)$ we wish to find their resulting description in the complex unit circle. Mapping operations onto the order parameter is straightforward using \\eqref{eq:orderparameter} and \\eqref{eq:OttAntonsenMeanField}:\n\\begin{align}\n\\theta_i(0) \\xrightarrow{\\hspace*{8mm}} Z(0) &= \\frac{1}{N} \\sum_{j=1}^N e^{\\ic\\theta_j(0)} \\label{eq:thetatoZ}\\\\\nz(\\k,0) \\longrightarrow \\bar{Z}(0) &= \\frac{1}{N} \\sum_{\\k \\in \\K} P(\\k) z(\\k, 0)  \\label{eq:ztoZ}\n\\end{align}\nHere we can immediately see that information about the distribution of $\\theta$ and $z$ is lost when taking the (weighed) average. \n\nStarting from an initial synchronization $Z(0)$ and taking the inverse tranfsormation, we can make use of the fact that a set of identical values has an average equal to that value. This is simple for $\\theta_i(0)$: we can take all phase angles to be the same at $t = 0$. For $z(\\k,0)$ we have a weighed average which we need to invert, while making sure that the whole sums up to $N$ by multiplying with the total number of neurons $n(\\k)$ of degree $\\k$:\n\\begin{align}\nZ(0) \\xrightarrow{\\hspace*{8mm}} \\theta_i(0) &= -\\ic \\cdot \\log \\left( Z(0) \\right)  \\label{eq:Ztotheta} \\\\\nZ(0) \\longrightarrow z(\\k,0) &= \\frac{Z(0) \\cdot n(\\k)}{P(\\k)} \\label{eq:Ztoz}\n\\end{align}\nIt is necessary to include $n(\\k)$, as $P$ is only accurate in the limit that $N \\rightarrow \\infty$. This approach only alters the magnitude of $Z(0)$, so that $z(\\k,0)$ will be distributed on a line through $Z(0)$. Then, transforming between $\\theta_i$ and $z(\\k)$, we need to filter $\\theta_i$ per degree as there exist $n(\\k)$ number of nodes with $\\degree ( \\theta_i ) = \\k$:\n\\begin{alignat}{2}\nz(\\k,0) \\longrightarrow \\theta_i(0) &= -\\ic \\cdot \\log \\left( \\frac{z(\\k)\\cdot P(\\k)}{n(\\k)} \\right) \\qquad &&\\forall \\: \\theta \\in \\{ \\theta \\: | \\: \\degree(\\theta) = \\k \\}  \\label{eq:ztottheta}\\\\\n\\theta_i(0) \\longrightarrow z(\\k,0) &= \\sum_{\\k} e^{\\ic \\vartheta_{\\k}} \\qquad \\qquad &&\\forall \\: \\vartheta_{\\k} \\in \\{ \\vartheta_{\\k} = \\sum^{n(\\k)} \\theta \\: | \\: \\degree(\\theta) = \\k \\} \\label{eq:thetatoz}\n\\end{alignat}\n%We can see how $\\lim_{N \\rightarrow +\\infty} n(\\k) = P(\\k)$, which makes these maps exact for any network size. \n%The reason that these transformations can only hold for the initial state is because it is currently unknown what distributions $\\theta_i(t)$ and $z(\\k,t)$ should have. That information is lost when taking the (weighed) average in \\eqref{eq:orderparameter} and \\eqref{eq:MeanField}. \\\\\n\nThe relations derived here raise problems when $P(\\k)$ spans different orders of magnitude. \\eqref{eq:Ztoz} does not bound $z$ to its set, so it might occur that the distribution of $z$ has values outside of the complex unit circle. However, transforming back to $\\bar{Z}$ will always be correct. This problem does not occur for $\\theta$, as $\\T$ is a one-parameter group so that multiplication and division of elements in the group remain in the group. Let us look at the example in Figure \\ref{fig:mappings}, where we are trying to find $z(\\k, 0)$ so that $\\bar{Z}(0)$ is equal to the desired initial condition $Z(0) = $ -0.2 + $\\ic$0.8, using a scale-free topology. \\\\\n\n%The initial values of $z$ are not bound on $\\C$, so it might occur that the initial condition given through \\eqref{eq:ztoZ} is exact, but that the distribution of $z(\\k,t)$ leaves us with some out of the complex unit circle. Let us look at the example in Figure \\ref{fig:mappings}, where we are trying to find $z(\\k, 0)$ so that $\\bar{Z}(0)$ is equal to our desired initial condition $Z(0) = $ -0.2 + $\\ic$0.8. \\\\\n\n% Especially for scale-free networks, where there is a large difference between the smallest and largest degree, this offset is large\n \nWhen simply taking all $z(\\k, 0) = Z(0)$, there is a slight offset between $Z(0)$ and $\\bar{Z}(0)$. However, the dynamics are well-behaved and the end-state is almost a smooth curve. One can really interpret this curve as the attractive manifold of the Ott-Antonsen reduction. This method is an easy way of quickly coming up with an initial condition, without requiring any computation. In general, this yields quite a good approximation. \\\\\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth]{../Figures/PhaseSpace/Mappings.pdf}\n   \\caption{Simulation of 1000 neurons in a scale-free network. Example on the importance of accurate initial conditions. A scalefree network is used to show the outcome of different strategies of initialising the network. Left: the initial condition is not correct, but it yields very smooth dynamics. Middle: the initial condition is correct, but it does not yield smooth dynamics. Right: the initial condition is correct, and it also yields smooth dynamics.}\n   \\label{fig:mappings}\n\\end{figure}\n\nWhen using \\eqref{eq:ztoZ}, we can see that the initial conditions lie on a straight line through the origin indeed, and that $\\bar{Z}(0)$ is exactly equal to $Z(0)$. When a given $\\k$ yields a small $P(\\k)$, $z(\\k,0)$ will be scaled away from the origin. This means that the dynamics of nodes of that degree are not well represented. However, their contribution to $\\bar{Z}$ in \\eqref{eq:OttAntonsenMeanField} is small, so sometimes these effects cancel out and the dynamics are in fact quite smooth. However, we can see that in our example the dynamics are not represented well, resulting in large errors after conception and a more random end-state. We do expect these effects to cancel out after longer periods and for larger $N$, as the manifold is attractive and larger networks cancel out outliers, but our aim is to be as precise as possible from $t=0$. \\\\\n\nWhen trying to address the problems that are encountered here, we can try and find the distribution of $z(\\k,0)$ numerically. We can solve for the root of $f(z) = \\| Z(0) - \\bar{Z}(0) \\|$ (where $\\bar{Z}$ is computed from $z$) under the constraint that $| z | \\leq 1$, starting from an initial guess $\\hat{z}$ clustered around $Z(0)$. The resulting initial distribution is also quite clustered but as it is mostly a result of the constraint, we are more interested in the end-state, which shows a lot of improvements over the second method. The initial conditions are exact (up to $10^{-6}$) and the dynamics are smooth, which makes this method the most desirable. However, convergence can be very slow for scale-free networks, and the complexity of the system to solve scales with $\\sim N^2$ . It is therefore necessary to judge which of the three methods to use when performing a new simulation.\n\n\n\\subsection{Final conditions}\nGiven that the final condition of the system is such a particular smooth curve, we can try and understand what kind of distribution $z$ follows on that curve. In Figure \\ref{fig:FinalConditions} we have made different networks converge to a stable node in the \\PSR state until changes to the system were smaller than a tolerance. We can see that the final condition of $z$ is close to the final condition of $\\bar{Z}$. If we divide the length of the curve into equal parts, we can count how many $z$ can be found in each interval. The resulting distributions difficult to interpret, but we can see some traits of their respective degree distributions, though the likeness is not very high. \n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth]{../Figures/Distributions/FinalConditions.pdf}\n\\caption{Final conditions of $z$ for the \\PSR state, represented by 40 equally spaced indices and the resulting histogram. Both the random and scale-free network topologies show that the final conditions of $z$ are a smooth curve, and that points on that curve have a particular distribution over the length of the curve.}\n\\label{fig:FinalConditions}\n\\end{figure}\n\nFor other macroscopic states the distributions of $z$ across its final condition are quite similar as presented here. However, when the scale-free network has converged to the stable focus in the \\PSS state, the final condition is a highly convoluted spiral, which is difficult to interpret. What is important though, is that there is a definite structure to be found in the final condition as well.\n\n\n\\subsection{Commutativity of complex vectors} \nIt is important to notice that in \\eqref{eq:OttAntonsenSystemFull} and \\eqref{eq:OttAntonsenMeanField} and many other equations in this work, we compute an inner vector product, which is non-commutative for complex numbers:\n\\begin{align}\na \\cdot b = (b \\cdot a)^c \\qquad a, b \\in \\c^r\n\\end{align}\nThis is the result of the \\textsl{Conjugate} or \\textsl{Hermitian} symmetry of the inner product. This is especially important in the implementation, as one needs to be consistent with left- or right-hand products.\n\n\n\\subsection{Fixpoint iteration}\nIn \\cite{OttAntonsen2017} a fixpoint iteration is suggested to find attractive fixpoints of the system \\eqref{eq:OttAntonsenSystemFull}. If we set $\\frac{\\partial z(\\k, t)}{\\partial t} = 0$ we can solve the following system:\n\\begin{align}\n\\ic \\frac{(z(\\k, t)-1)^{2}}{2} &= \\frac{(z(\\k, t)+1)^{2}}{2} \\cdot I(\\k, t) \\nonumber \\\\\n\\ic \\left(\\frac{z(\\k, t)-1}{z(\\k, t)+1}\\right)^2 &= I(\\k, t) \\nonumber \\\\\n\\frac{z(\\k, t)-1}{z(\\k, t)+1} &\\equiv b(\\k,t) \\nonumber \\\\\nz(\\k, t) - 1 &= b(\\k,t) z(\\k, t) + b(\\k,t)  \\nonumber \\\\\nz(\\k, t) \\cdot (1 - b(\\k,t)) &= b(\\k,t)  + 1\\nonumber\n\\end{align}\nWe can then obtain the stable equilibria from:\n\\begin{align}\n\\ic b(\\k,t)^2 = I(\\k, t) \\hspace{10mm} z(\\k, t)_{\\pm} = \\frac{1 \\pm b(\\k,t)}{1 \\mp b(\\k,t)} \\label{eq:fixedpointiterations} \n\\end{align}\nwhere the signs are chosen so that $\\vert z(\\k, t) \\vert \\leq 1$. This works well, and in general this method converges fast.\n\n\n\\subsection{A Newton-Raphson iteration for all fixpoints}\nThe fixpoint iteration \\eqref{eq:fixedpointiterations} only gives us the stable equilibria of the \\MFR. We can obtain all equilibria and their stability through the Jacobian from a Newton-Raphson iteration, which has been described in \\ref{app:NewtonRaphson}. The Jacobian would be a $M_{\\k} \\times M_{\\k}$ matrix, as we have $M_{\\k}$ unique degrees in the network, and we need to take the derivate of one with respect to each other. However, finding the Jacobian is a challenge, as \\eqref{eq:OttAntonsenSystemFull} is non-holomorphic: $H_2(\\k,t)$ does not satisfy the Cauchy-Riemann equations. We can show this by separating $z$ into its real and imaginary part and expressing $H_2(\\k,t)$ as two real-valued functions $u$ and $v$:\n%For \\eqref{eq:OttAntonsenSystemFull}, we can compute the Jacobian for the diagonal and off-diagonal elements separately. But as $z(\\k,t)$ is a complex function, first we need to understand what the derivative of a complex function is. \n\\begin{align*}\nz(\\k,t) &= x(\\k,t) + \\ic y(\\k,t) \\qquad \\qquad x, y \\in \\R^{M_{\\k}}\\\\\nf\\left( z(\\k,t) \\right) &= u\\left(x(\\k, t), y(\\k, t) \\right) + \\ic v\\left(x(\\k, t), y(\\k, t) \\right)\\\\\n&= \\frac{\\kappa}{\\kmean} \\sum_{\\kacc} P\\left(\\kacc\\right) \\: a\\left(\\kacc \\rightarrow \\k\\right) \\left( 1 + \\frac{z(\\kacc, t)^2 + (z(\\kacc, t)^c )^2}{6} - \\frac{4}{3} \\Re(z(\\kacc, t)) \\right)\\\\\n&= \\frac{\\kappa}{\\kmean} \\sum_{\\kacc} P\\left(\\kacc\\right) \\: a\\left(\\kacc \\rightarrow \\k\\right) \\left( 1 + \\frac{x(\\kacc, t)^2}{3} - \\frac{4}{3} x(\\kacc, t) \\right)\n\\end{align*}\nThis leaves us with only $u$ defined as a real-valued function, so that the Cauchy-Riemann equations do not hold as $v$ is zero. Thus we cannot express the Jacobian as a matrix of complex numbers. \\\\\n\nInstead, we must think of $z$ as a vector of real and imaginary parts and express it as $z(\\k,t) = [ x(\\k,t), \\: y(\\k,t)]$. We can then interweave the two parts in the Jacobian, forming a $2 M_{\\k} \\times 2 M_{\\k}$ matrix of real values. For fixed-degree networks this is easy, and the approach yields the well-known $2 \\times 2 $ Jacobian, which has been used in Figure \\ref{fig:macroscopicstatesfixeddegree} to signify the stability of the equilibrium points and the magnitude and direction of the eigenvalues. \\\\\n\nHowever, for the typologies with more than one unique degree in the network, this approach did not yield promising results. If convergence occurs, the the equilibrium is found outside of the unit circle, which is unphysical. One issue might be that the initial condition used for the Newton-Raphson iteration is still not close enough to the true manifold. The resulting equilibria might be due to residuals from the Fourier series applied to $f(\\theta, \\eta | \\k, t)$ in \\eqref{eq:meanfieldorderparameter}. A deeper understanding of the manifold and initial conditions is necessary. \\\\\n\nOtherwise either the derivation of the Jacobian or the execution of the algorithm is flawed, though a mistake could not be found. For now, we will revert to the fixed point iteration method, \\eqref{eq:fixedpointiterations}, to find stable equilibria of the system.\n\n%\\textcolor{red}{QUESTION}: \\textsl{explain how the Jacobian can be found as a $2 M_{\\k} \\times 2 M_{\\k}$ matrix by using $z(\\k,t) = [ x(\\k,t), \\: y(\\k,t)]$ and interweaving the $x$ and $y$ dimension in the matrix, see \\cite{Cross2018}. This has been implemented but only stable results for the \\PSR state. Right now I still can only find attractive fixpoints. Should I continue on this?}\n\n\n\\subsection{Fixed-degree networks as a baseline}\nNow we have all the necessary tools to simulate networks of theta neurons: the adjacency matrix, and an understanding of the initial conditions. First, we will use a fixed-degree network, as this is the most simple instance of the different topologies. As all nodes have the same degree, the dynamics of a symmetric and asymmetric fixed-degree network ought to be identical. The results are shown in Figure \\ref{fig:InspectMeanFieldFixedDegree}.\n\nWe can easily recognise the three macroscopic states from Figure \\ref{fig:macroscopicstatesfixeddegree}. It is no wonder that the solutions for the equilibria are accurate, though results for the limit cycle are quite remarkable. There are small differences between $Z$ measured by the whole network and $\\bar{Z}$ predicted by the \\MFR, but these are most likely due to a finite network size and a finite integration step. The mean-field systems \\eqref{eq:OttAntonsenMeanField} and \\eqref{eq:MeanField} yield the exact same behaviour, as expected. This test benchmarks the lowest amount of error we can observe between simulation and theory, as for fixed-degree networks (\\ref{eq:OttAntonsenSystemFull}) consists of a single equation.\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth, trim={0 3mm 0 3mm},clip]{../Figures/InspectMeanFieldFixedDegree.pdf}\n\\caption{Comparison of the simulation of a fixed-degree network of Theta neurons and the Ott-Antonsen theory by the magnitude of the order parameter. We observe that the same three macroscopic states are found by the three descriptions of the mean-field.}\n\\label{fig:InspectMeanFieldFixedDegree}\n\\end{figure}\n\n\n\\subsection{Results for arbitrary network topologies} \\label{sec:resArbNetw}\nThe dynamics of random networks seem to be very similar to fixed-degree networks, when looking at the dynamics in the unit circle. Both networks have a unimodal and symmetric degree distribution, and this might be the cause for the likeness. We can see in Figure \\ref{fig:MFOARCPW_random} that the limit cycle is slightly larger, but no other differences can be observed. When looking at the dynamics over time the results in Figure \\ref{fig:InspectMeanFieldRandom} are also consistent, with a little more deviation between simulation and theory in the \\CPW state, but this can be expected for finite networks.\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARPSR_random.pdf}\n   \\caption{PSR state for $\\eta_0 = -0.9, \\sigma = 0.8$ and $\\kappa= -2$. The mean field settles onto a stable node.}\n   \\label{fig:MFOARPSR_random} \n\\end{subfigure} \\hfill\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARPSS_random.pdf}\n   \\caption{PSS state for $\\eta_0 = 0.5, \\sigma = 0.7$ and $\\kappa= 2$. The mean field settles onto a stable focus.}\n   \\label{fig:MFOARPSS_random}\n\\end{subfigure} \\hfill\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARCPW_random.pdf}\n   \\caption{CPW state for $\\eta_0 = 10.75, \\sigma = 0.5$ and $\\kappa= -9$. The mean field settles onto a stable limit cycle.}\n   \\label{fig:MFOARCPW_random}\n\\end{subfigure}\n   \\caption{Three macroscopic states observed in the \\MFR using a random network, inside the imaginary unit circle $|Z(t)| \\leqslant 1$. Green arrows mark the phase space vector field and green trails mark solution curves. The dotted line in the \\CPW state is the limit cycle of the fixed-degree networks, added for reference.}\n   \\label{fig:macroscopicstatesrandomnetworks}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth, trim={0 3mm 0 3mm},clip]{../Figures/InspectMeanFieldRandom.pdf}\n\\caption{Comparison of the simulation of a random network of Theta neurons and the Ott-Antonsen theory by the magnitude of the order parameter. }\n\\label{fig:InspectMeanFieldRandom}\n\\end{figure}\n\nFor scale-free networks, we can see that again the three macroscopic states continue to exist, Figure \\ref{fig:macroscopicstatesscalefreenetworks}. However, it seems like there is a fairly large discrepancy between symmetric and asymmetric networks, in Figure \\ref{fig:InspectMeanFieldScaleFree}. The stable node in the \\PSR state is found at different locations, and the limit cycle in the \\CPW state seems to be very different, but with a similar period. Indeed, if we look at the limit cycle to which the dynamics are attracted to in Figure \\ref{fig:InspectMeanFieldScaleFreePhaseSpace} we can indeed see two distinct cycles. \\\\\n\nThis means that due to its topology, the scale-free network cannot be represented by a symmetric variant. The degree distribution is asymmetric, and this likely causes the asymmetry observed here. Another observation is that now the fixed-point iteration finds the centre of the limit cycle as a stable equilibrium. The limit cycle has always been observed to be attractive, so a stable equilibrium within would require another unstable limit cycle around the equilibrium. We will regard this as an error.\n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARPSR_scalefree.pdf}\n   \\caption{PSR state for $\\eta_0 = -0.9, \\sigma = 0.8$ and $\\kappa= -2$. The mean field settles onto a stable node.}\n   \\label{fig:MFOARPSR_scalefree} \n\\end{subfigure} \\hfill\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARPSS_scalefree.pdf}\n   \\caption{PSS state for $\\eta_0 = 0.5, \\sigma = 0.7$ and $\\kappa= 2$. The mean field settles onto a stable focus.}\n   \\label{fig:MFOARPSS_scalefree}\n\\end{subfigure} \\hfill\n\\begin{subfigure}[b]{0.32\\linewidth}\n   \\centering\n  \\includegraphics[width=\\linewidth]{../Figures/PhaseSpace/MFOARCPW_scalefree.pdf}\n   \\caption{CPW state for $\\eta_0 = 10.75, \\sigma = 0.5$ and $\\kappa= -9$. The mean field settles onto a stable limit cycle.}\n   \\label{fig:MFOARCPW_scalefree}\n\\end{subfigure}\n   \\caption{Three macroscopic states observed in the \\MFR inside the imaginary unit circle $|Z(t)| \\leqslant 1$. Green arrows mark the phase space vector field and blue trails mark solution curves. Red points indicate equilibrium points, found by the fixed-point iteration. The dotted line in the \\CPW state is the limit cycle of the fixed-degree networks, added for reference}\n   \\label{fig:macroscopicstatesscalefreenetworks}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = \\textwidth, trim={0 3mm 0 3mm},clip]{../Figures/InspectMeanFieldScaleFree.pdf}\n\\caption{Comparison of the simulation of a scale-free network of Theta neurons and the Ott-Antonsen theory by the magnitude of the order parameter.}\n\\label{fig:InspectMeanFieldScaleFree}\n\\end{figure}\n\nThe results of these experiments point us in the right direction. Symmetric and asymmetric networks of the same family share many macroscopic properties, and networks with a symmetric degree distribution might share these properties with more detail. \n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width = 0.5\\textwidth]{../Figures/PhaseSpace/ScalefreeLimCycles.pdf}\n\\caption{Comparison of the limit cycles found by theory and simulation.}\n\\label{fig:InspectMeanFieldScaleFreePhaseSpace}\n\\end{figure}\n\n\n", "meta": {"hexsha": "4f4b372b8075ceb08e60e85c58f468d191d73b94", "size": 29131, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Writing/Mainmatter/OttAntonsen Directed Graphs.tex", "max_stars_repo_name": "simonaertssen/AdaptiveNeuronalNetworks", "max_stars_repo_head_hexsha": "506a4e8aba392330f8a6ecc6b229e2c8322b8e83", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Writing/Mainmatter/OttAntonsen Directed Graphs.tex", "max_issues_repo_name": "simonaertssen/AdaptiveNeuronalNetworks", "max_issues_repo_head_hexsha": "506a4e8aba392330f8a6ecc6b229e2c8322b8e83", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Writing/Mainmatter/OttAntonsen Directed Graphs.tex", "max_forks_repo_name": "simonaertssen/AdaptiveNeuronalNetworks", "max_forks_repo_head_hexsha": "506a4e8aba392330f8a6ecc6b229e2c8322b8e83", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 113.79296875, "max_line_length": 897, "alphanum_fraction": 0.7512615427, "num_tokens": 7953, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6297745935070808, "lm_q1q2_score": 0.414654605331854}}
{"text": "\\label{app:errors}\n\n\\subsection{Speedup Error Propagation} \\label{sec:app_numba}\n\nThe speedup offered by Numba JIT compilation in comparison to just using Numpy\nis calculated using,\n\n\\begin{equation}\n    \\text{Speedup} = \\frac{t_{\\text{numpy}}}{t_{\\text{JIT}}}\n\\end{equation}\n\nwhere $t_{\\text{JIT}}$ and $t_{\\text{numpy}}$ are the mean times taken to complete\na solve a given problem for each method respectively.\n\nThe error is then propagated using the standard formula \\cite{hughes2010measurements},\n\n\\begin{equation}\n    \\frac{\\sigma_{\\text{speedup}}}{\\text{Speedup}} = \\sqrt{\n        \\left ( \\frac{\\sigma_{\\text{JIT}}}{t_{\\text{JIT}}} \\right )^2 +\n        \\left ( \\frac{\\sigma_{\\text{numpy}}}{t_{\\text{numpy}}} \\right )^2\n    }\n\\end{equation}\n\nwhere $\\sigma_{\\text{JIT}}$ and $\\sigma_{\\text{numpy}}$ are the standard deviations\nfrom the runs for each problem size.\n", "meta": {"hexsha": "412126fdf4eadb45061687238685d3ccf89e28a5", "size": 869, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/appendix/errors.tex", "max_stars_repo_name": "skailasa/msc_thesis", "max_stars_repo_head_hexsha": "c9cad2703b6263e82fa32b025c8c3ab942367fd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/appendix/errors.tex", "max_issues_repo_name": "skailasa/msc_thesis", "max_issues_repo_head_hexsha": "c9cad2703b6263e82fa32b025c8c3ab942367fd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/appendix/errors.tex", "max_forks_repo_name": "skailasa/msc_thesis", "max_forks_repo_head_hexsha": "c9cad2703b6263e82fa32b025c8c3ab942367fd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.4230769231, "max_line_length": 86, "alphanum_fraction": 0.6973532796, "num_tokens": 274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.41465460533185394}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{siunitx} % Required for alignments\n\\begin{document}\n\t\\title{GST 108: Quantitative Reasoning}\n\n\t\\author{Ariyibi Joseph Iseoluwa}\n\\maketitle\n\\newpage\n\\tableofcontents\n\\newpage\n\\centering\n\\section{INTRODUCTION}\n    A logic gate is a building block of a digital circuit which is at the heart of any computer operation.\n    \n   \n   \\includegraphics[width=1\\linewidth]{logic}\n\n\t\\subsection{Logic Gates}\n\t\tLogic gates perform logical operations that take binary input (0s and 1s) and produce a single binary output. They are used in most electronic device including:\n\t\\begin{table}[h!]\n\t\t\\begin{center}\n\t\t\t\\caption{Logic Gates}\n\t\t\t\\label{tab:table1}\n\t\t\t\\begin{tabular}{l|c|c|}\n\t\t\t\t\\hline\n\t\t\t\tSmartphones\n\t\t\t\t&\n\t\t\t\tTablets\n\t\t\t\t&\n\t\t\t\tMemory Devices\n\t\t\t\t\\\\\n\t\t\t\t\\hline\n\t\t\t\t\\includegraphics[width=0.2\\linewidth]{iphone13}\n\t\t\t\t&\n\t\t\t\t\\includegraphics[width=0.25\\linewidth]{ipadmini}\n\t\t\t\t&\n\t\t\t\t\\includegraphics[width=0.2\\linewidth]{download}\n\t\t\t\t\\\\\n\t\t\t\t\\hline\n\t\t\t\\end{tabular}\n\t\t\\end{center}\n\t\\end{table}\n\\newpage\n\\section{Definition Of a Gate}\nA gate is a basic electronic circuit which operates on one or more signals to produce an output signal. \nLogic gates are digital circuits constructed from diodes, transistors, and resistors connected in such a way that the circuit output is the result of a basic logic operation (OR, AND, NOT) performed on the inputs. \\cite{okoacha2021logic}\n\\section{Types Of Logic Gates}\n\\textbf{Fundamental Gates include AND, OR, NOT gates}\n\n\\includegraphics[width=1\\linewidth]{gates.jpg}\n\\newpage\n\\subsection{AND Gate}\n\nThe expression C = A X B reads as “C equals A AND B“ \nThe multiplication sign (X) stands for the AND operation, same for ordinary multiplication of 1s and 0s.\nThe AND operation produces a true output (result of 1) only for the single case when all of the input variables are 1 and a false output (result of 0) where one or more inputs are 0.\n\n\\includegraphics[width=0.3\\linewidth]{and.jpg}\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\caption{AND TABLE}\n\t\t\\begin{tabular}{c|c|c|}\n\t\t\t\\textbf{A} & \\textbf{B} &  \\textbf{C= A x B} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{1} & \\textbf{1} \\\\\n\t\t\t\\textbf{1} & \\textbf{0} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{0} & \\textbf{0} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\\subsection{OR GATE}\nThe expression C = A + B reads as “C equals A OR B\". It is the inclusive “OR”\nThe Addition (+) sign stands for the OR operation.\nThe OR operation produces a true output (result of 1) when any of the input variable is 1 and a false output (result of 0) only when all the input variables are 0.\n\\includegraphics[width=0.6\\linewidth]{or.jpg}\n\\begin{table}\n\t\\begin{center}\n\t\t\\caption{OR TABLE}\n\t\t\\begin{tabular}{l|c|c|}\n\t\t\t\\textbf{A} & \\textbf{B} & \\textbf{C= A + B} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{1} & \\textbf{1} \\\\\n\t\t\t\\textbf{1} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} & \\textbf{1} \\\\\n\t\t\t\\textbf{0} & \\textbf{0} & \\textbf{0} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\\newpage\n\\subsection{NOT GATE}\nThe NOT gate is called a logical inverter.\nIt has only one input. It reverses the original input (A) to give an inverted output C.\nC = NOT A or C = $\\overline{A}$\n\\includegraphics[width=0.6\\linewidth]{not.jpg}\n\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\caption{NOT TABLE}\n\t\t\\begin{tabular}{c|c|}\n\t\t\t\\textbf{A} & \\textbf{C = $\\overline{A}$} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\\subsection{NOR GATE}\nThe NOR (NOT OR) gate circuit is an inverter OR gate\n\nC =  $\\overline{(A + B)}$\nReads as C = NOT of A or B\n \nThe NOR Gate gives a true output (result of 1) only when both inputs are false (0)\n\n\\includegraphics[width=0.6\\linewidth]{nor}\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\caption{NOR TABLE}\n\t\t\\begin{tabular}{l|c|c|c|}\n\t\t\t\\textbf{A} & \\textbf{B} & \\textbf{A+B} & \\textbf{C= (A+B)} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{1} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\\newpage\n\\subsection{NAND GATE}\nThe NAND (NOT AND) Gate is an inverted AND Gate\nC = ($\\overline{(A * B)}$) \nReads as C = NOT of A AND B\nThe NAND Gate gives a false output (result of 0) only when both inputs are true (1)\n\n\\includegraphics[width=0.7\\linewidth]{nand}\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\caption{NAND GATE}\n\t\t\\begin{tabular}{l|c|c|c|}\n\t\t\t\\textbf{A} & \\textbf{B} & \\textbf{A x B} & \\textbf{C= $\\overline{(A * B)}$} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{1} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\t\\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\nThe NAND Gate is a universal gate because it can be used to form any other kind of gate \n\\newpage\n\\subsection{XOR GATE}\nAn XOR (exclusive OR) gate acts in the same way as the exclusive OR logical connector. \nIt gives a true output (result of 1) if one, and only one, of the inputs to the gate is true (1), i.e either or but not both\n\n\\includegraphics[width=0.7\\linewidth]{xor}\n\\begin{table}[h!]\n \\begin{center}\n \t\\caption{XOR GATE}\n \t\\begin{tabular}{l|c|c|c|c|c|c|}\n \t\t\\textbf{A} & \\textbf{B} & \\textbf{$\\overline{A}$} & \\textbf{$\\overline{B}$} & \\textbf{$\\overline{A}$.B} & \\textbf{$\\overline{B}$.A} & \\textbf{$\\overline{A}$.B + $\\overline{B}$.A} \\\\\n \t\t\\hline\n \t\t\\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{0} \\\\\n \t\t\\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{1} \\\\\n \t\t\\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{0} & \\textbf{1} \\\\\n \t\t\\textbf{0} & \\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{0}\n \t\\end{tabular}\n \\end{center}\n\\end{table}\n\\newpage\n\\subsection{XNOR GATE}\nThe XNOR (exclusive - NOR) gate is a combination XOR gate followed by an inverter. It is represented by the $\\odot$\nIts gives a  true output (1), if the inputs are the same, and a false output (0) if the inputs are different. \n\nC = $\\overline{(A \\odot B)}$ =$\\overline{\\overline{A} .B + \\overline{B} .A}$\n\\includegraphics[width=0.7\\linewidth]{xnor}\n\\begin{table}[h!]\n\t\\begin{center}\n\t\t\\caption{XNOR GATE}\n\t\t\\begin{tabular}{l|c|c|c|c|c|c|c|}\n\t\t\t\\textbf{A} & \\textbf{B} & \\textbf{$\\overline{A}$} & $\\overline{B}$ & \\textbf{$\\overline{A}$ .B} & \\textbf{$\\overline{B}$ .A} & \\textbf{$\\overline{A}$ .B + $\\overline{B}$ .A} & \\textbf{$\\overline{\\overline{A} .B + \\overline{B} .A}$} \\\\\n\t\t\t\\hline\n\t\t\t\\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\t\\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{0} & \\textbf{1} & \\textbf{0} \\\\\n\t\t\t\\textbf{0} & \\textbf{0} & \\textbf{1} & \\textbf{1} & \\textbf{0} & \\textbf{0} & \\textbf{0} & \\textbf{1} \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\\end{table}\n\\newpage\n\\section{Summary}\n\\subsection{LOGIC GATES AND THEIR TRUTH TABLE}\n\\includegraphics[width=0.8\\linewidth]{truth table}\n\\subsection{Summary contd.}\nUsing different combination of logic gates, complex operations can be performed. \nWith the Universal logic gates - NAND and NOR, any other gate can be built.\n\nThere is no limit to the number of gates that can be arranged together in a single device.  \nHowever, in practice, there is a limit to the number of gates that can be packed into a given physical space. \nArrays of logic gates are found in digital integrated circuits.\nThe logic gates are abstract representations of real electronic circuits. \\cite{okoacha2021sum}\n\nIn computers, Logic gates are built using transistors combined with other electrical components like resistors and diodes. \nThese electrical components are wired together in order to transform a particular input to give a desired output.\n\\newpage\n\\section{QUIZ}\n\\begin{enumerate}\n\\item\tWhat is the output of an AND gate if the inputs are 1 and 0?\n\t\n\\item\tExplain the difference between the AND gate and the OR gate.\n\t\n\\item\tWhat is the output of a NOT gate if the inputs is 0?\n\t\n\\item\tWhich logic gate is this?\n\\begin{center}\n\t\\includegraphics[width=0.6\\linewidth]{xor2}\n\\end{center}\n\t\n\\item\tWhich gate is also known a logical converter?\n\t\n\\end{enumerate}\n\\newpage\n\\bibliography{gst}\n\\bibliographystyle{ieeetr}\n\\end{document}\n", "meta": {"hexsha": "e395524ccf191ef6f87fdcfffa8956a7bc7d534c", "size": 8604, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ARIYIBI iSEOLUWA COMMIT/student exercise 2.tex", "max_stars_repo_name": "ise2005best/iseoluwaCSC102", "max_stars_repo_head_hexsha": "4c2ac00d92146f0f84e4260160ff68700e13fd71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ARIYIBI iSEOLUWA COMMIT/student exercise 2.tex", "max_issues_repo_name": "ise2005best/iseoluwaCSC102", "max_issues_repo_head_hexsha": "4c2ac00d92146f0f84e4260160ff68700e13fd71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ARIYIBI iSEOLUWA COMMIT/student exercise 2.tex", "max_forks_repo_name": "ise2005best/iseoluwaCSC102", "max_forks_repo_head_hexsha": "4c2ac00d92146f0f84e4260160ff68700e13fd71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5720524017, "max_line_length": 237, "alphanum_fraction": 0.6691073919, "num_tokens": 3200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.4144783544913735}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 02/26/21\n\n\\section{G-homomorphisms}\n\\label{sec:g_homomorphisms}\n\nLet \\(K\\) be a field and \\(G\\) be a group. We are going to look at a structure of interest: we define \\(K\\)-linear representations of \\(G\\) as a \\(K\\)-vector space \\(V\\) equipped with a group homomorphism\n\\begin{align*}\n\t\\rho:G\\to GL(V)\\\\\n\tg\\mapsto [\\rho g:V\\to V]\n\\end{align*}\n\n\\begin{defn}[\\(G\\)-homomorphism]\n\tLet \\((V',\\rho')\\) and \\((V'',\\rho'')\\) be representations of \\(G\\) over \\(K\\). A \\textbf{\\(G\\)-homomorphism from \\((V',\\rho')\\) to \\(V'',\\rho'')\\)} is a \\(K\\) linear map \\(\\varphi:V'\\to V''\\) which intertwines with the action of \\(G\\) :\n\t\\begin{align*}\n\t\t\\varphi(\\rho'g(v')) = \\rho''g(\\varphi(v')) \\quad \\forall g \\in G, v' \\in V'\n\t\\end{align*}\n\tWe denote the collection of \\(G\\)-homomorphisms from \\((V', \\rho')\\) to \\((V'', \\rho'')\\) by \\( \\textrm{Hom}_G(V',V'')\\), and \\(\\textrm{End}_G(V') := \\textrm{Hom}_G(V',V')\\). Finally, a \\textbf{\\(G\\)-isomorphism} is an invertible \\(G\\)-homomorphism.\n\\end{defn}\n\nThis is really just a change in basis.\n\n\\begin{prop}\n\tIf \\(\\varphi \\in \\textrm{Hom}_G(V,W)\\), then \\(\\varphi^{-1} \\in \\textrm{Hom}_G(W,V)\\).\n\\end{prop}\n\\begin{prop} %Exercise 1 on HW 5\n\tTake \\(\\varphi \\in \\textrm{Hom}_G(V,W)\\). Then\n\t\\begin{enumerate}[(a).]\n\t\t\\item \\(\\textrm{Ker}\\varphi \\) is a subrepresentation of \\(V\\), and\n\t\t\\item \\(\\textrm{Im}\\varphi\\) is a subrepresentation of \\(W\\).\n\t\\end{enumerate}\n\\end{prop}\nFor the rest of the section, we take \\(K = \\C\\).\n\n\\begin{lemma}[Schur's Lemma]\n\tLet \\((V,\\rho)\\) be an irreducible representation of \\(G\\). If \\(\\varphi \\in \\textrm{End}_G(V)\\), then \\(\\varphi\\) is a scalar multiple of \\(\\textrm{Id}V\\) :\n\t\\begin{align*}\n\t\t\\exists \\lambda \\in \\C \\; s.t. \\; \\varphi(v) = \\lambda v \\quad \\forall v \\in V\n\t\\end{align*}\n\\end{lemma}\nThis result has many applications.\n\\begin{thm}\n\tAll nonzero complex irreducible representations of an abelian group \\(G\\) have degree 1.\n\\end{thm}\nUsing these tools, we now can complete a few problems.\n\n\\begin{hw}\n\tGiven a finite abelian group \\(G\\), describe its irreducible representations, up to equivalence. Illustrate this for the Klein-four group \\(G = C_2\\times C_2\\).\n\\end{hw}\nMoreover, one can apply Schur's lemma to complete the following problem:\n\\begin{hw}\n\tLet \\(V\\) and \\(W\\) be irreducible representations of \\(G\\), and take \\(\\varphi \\in \\textrm{Hom}_G(V,W)\\). Show that\n\t\\begin{enumerate}[(a).]\n\t\t\\item If \\(V \\not\\cong W\\), then \\(\\varphi\\) is the zero map.\n\t\t\\item If \\(V \\cong W\\) and \\(\\varphi\\neq 0\\), then \\(\\varphi\\) is a \\(G\\)-isomorphism.\n\t\\end{enumerate}\n\\end{hw} % Hint: hw5 exercise 1\n\n\\end{document}\n", "meta": {"hexsha": "82f86b0c5d0a139e3757a8830b315f5c424a52ef", "size": 3055, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture12 - GHomo_SchursLemma.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture12 - GHomo_SchursLemma.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture12 - GHomo_SchursLemma.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6753246753, "max_line_length": 250, "alphanum_fraction": 0.6559738134, "num_tokens": 1090, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.4144783517069334}}
{"text": "\\hypertarget{haskell}{%\n\\section{Haskell - Interpreter}\\label{haskell}}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\nTODO: Ich verstehe nicht ganz, was der Interpeter mit Haskell zu tun hat bzw. für was wir das gemacht haben.\n\\end{tcolorbox}\n\n\\hypertarget{abstract-operator}{%\n\\subsection{Abstract Operator}\\label{abstract-operator}}\n\nInstead of using expressions directly, one can replace them with\nabstract syntax. For instance instead of using arithmetic operators, one\ncan define a data type `ArithOperator'.\n\n\\begin{lstlisting}[language=Haskell]\ntype Ident = String\n\ndata ArithOperator\n= Times\n| Div\n| Mod\n| Plus\n| Minus\nderiving (Eq, Show)\n\ndata ArithExpr\n= LitAExpr Int\n| IdAExpr Ident\n| DyaAExpr ArithOperator ArithExpr ArithExpr\n\nevalAOpr :: ArithOperator -> (Value -> Value -> Value)\nevalAOpr Times = (*)\nevalAOpr Div = div\nevalAOpr Mod = mod\nevalAOpr Plus = (+)\nevalAOpr Minus = (-)\n\ntestExp1 = DyaAExpr Plus (LitAExpr 1) (DyaAExpr Times (LitAExpr 2) (LitAExpr 3))\n\\end{lstlisting}\n\n\\hypertarget{concrete-versus-abstract-syntax}{%\n\\subsubsection{Concrete Versus Abstract\nSyntax}\\label{concrete-versus-abstract-syntax}}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Concrete syntax is easier to read for humans\n\\item\n  Abstract syntax is easier to process for machines\n\\end{itemize}\n\n\\hypertarget{semantic-values}{%\n\\subsection{Semantic values}\\label{semantic-values}}\n\n\\begin{lstlisting}[language=Haskell]\ntype State = Ident -> Value\n\\end{lstlisting}\n\n\\begin{itemize}\n\\tightlist\n\\item\n  a state is modelled as a function mapping identifiers to values\n\\item\n  example: the function s0 mapping ``x'' to 5, ``y'' to 7, ``z'' to 9,\n  and everything else to 42 (or to an error)\n\\end{itemize}\n\n\\clearpage\n\\hypertarget{updates}{%\n\\subsubsection{updateS}\\label{updates}}\n\n\\begin{lstlisting}[language=Haskell]\nreadS :: State -> Ident -> Value\nreadS s ident = s ident\n\nupdateS :: State -> (Ident, Value) -> State\nupdateS s (ident, val) ident'\n| ident' == ident = val\n| otherwise = s ident'\n\\end{lstlisting}\n\nupdateS s0 (``y'', 17) yields the function s1 mapping ``x'' to 5, ``y''\nto 17, ``z'' to 9, and everything else to 42 (or to an error)\n\n\\clearpage", "meta": {"hexsha": "c21b6b5a25f429ec1986547695f9704684317dd8", "size": 2161, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TSM_AdvPrPa/Summary/11_Haskell_Interpreter.tex", "max_stars_repo_name": "nortismo/mse-documentations", "max_stars_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_stars_repo_licenses": ["Beerware"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TSM_AdvPrPa/Summary/11_Haskell_Interpreter.tex", "max_issues_repo_name": "nortismo/mse-documentations", "max_issues_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_issues_repo_licenses": ["Beerware"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TSM_AdvPrPa/Summary/11_Haskell_Interpreter.tex", "max_forks_repo_name": "nortismo/mse-documentations", "max_forks_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_forks_repo_licenses": ["Beerware"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-15T07:10:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-15T07:10:24.000Z", "avg_line_length": 25.1279069767, "max_line_length": 108, "alphanum_fraction": 0.7390097177, "num_tokens": 651, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4144459294417307}}
{"text": "% !TEX root=../presentation_1.tex\n\\section{Background}\n\n\\subsection{Basic Assumptions}\n\n\\begin{frame}\n\\frametitle{Basic Assumptions}\n\\begin{itemize}\n\\item Synchronous CONGEST model.\n\\begin{itemize}\n    \\item \\textbf{Synchronous} message-passing model.\n    \\item Every message is $O(\\log n)$ in length.\n\\end{itemize}\n\\item Every vertex $v$ knows its own \\textbf{unique} ID.\n\\item MST is \\textbf{unique}\n\\begin{itemize}\n    \\item We can always break the symmetry by encode the weights with fractions to be a function of node ID.\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\subsection{Summary of methods}\n\\begin{frame}\n\\frametitle{Summary of methods}\n\n\\begin{itemize}\n    \\item $n=|V|, m=|E|.$\n    \\item $D:$ Hop-diameter of the graph. $D=\\max_{u,v \\in V} dist(u, v)$.\n\\end{itemize}\n\\input{sections/table}\n\\end{frame}\n\n\\subsection{Pipeline-MST}\n\\begin{frame}\n\\frametitle{Pipeline-MST}\n\\begin{itemize}\n    \\item A distributed version of \\textbf{Kruskal's} algorithm.\n    \\item Build a BFS tree first, $O(D)$ rounds with $O(m)$ messages.\n    \\item Each node keeps a candidate set, initializes at neighbor edges.\n    \\item For each round\n    \\begin{itemize}\n        \\item Add the incoming edges to the set.\n        \\item Remove the \\textbf{heaviest} edge in any \\textbf{cycle} in the set.\n        \\item Send the \\textbf{lightest} candidate to its BFS parent.\n    \\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Pipeline-MST}\n\\begin{itemize}\n    \\item $O(D+n)$ rounds:\n    \\begin{itemize}\n        \\item $O(D)$ rounds to reach from the leaves to the root.\n        \\item $O(n)$ rounds to find the edges needed for an MST.\n    \\end{itemize}\n    \\item $O(m)$ messages to build BFS tree. Each node sends $O(n)$ edges.\n    \\item $O(D+n)$ rounds and $O(m + n^2)$ messages.\n\\end{itemize}\n\\begin{figure}\n\\includegraphics[width=0.4\\textwidth,trim={0cm 7cm 18cm 0},clip]{figures/pipeline1.pdf}\n\\end{figure}\n\\end{frame}\n\n\\subsection{GHS [GHS86]}\n\\begin{frame}\n\\frametitle{GHS Algorithm}\n\\begin{itemize}\n    \\item A distributed version of \\textbf{Boruvka's} algorithm: merging components.\n    \\item Each node starts as \\textbf{a tree} with height 0.\n    \\item At phase $i$, any component with size less than $2^i$ fuses into another.\n    \\item Minimum outgoing edge (MWOE) of each component for merging.\n    \\item Worst case $O(n)$ rounds: the component can grow to size $O(n)$.\n    \\item $\\log n$ phases, $O(n \\log n)$ rounds.\n\\end{itemize}\n\n\\begin{figure}\n\\includegraphics[width=0.4\\textwidth,trim={0cm 10cm 18cm 0},clip]{figures/boruv1.pdf}\n\\includegraphics[width=0.4\\textwidth,trim={0cm 10cm 18cm 0},clip]{figures/boruv2.pdf}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{GHS Algorithm}\n\\begin{itemize}\n    \\item Each edge can only be accepted or declined once $O(m)$.\n    \\item Every round, each node needs to send convergecast and broadcast once, $O(n \\log n)$.\n    and $O(m + n \\log n)$ messages.\n\\end{itemize}\n\\end{frame}\n\n\\subsection{Controlled-GHS [GKP98, KP98]}\n\\begin{frame}\n\\frametitle{Controlled-GHS Algorithm [GKP98, KP98]}\n\\begin{itemize}\n    \\item \\textbf{Pipeline-MST} reduces 1 component every round: \\textbf{slow}.\n    \\item \\textbf{GHS} reduces the number of components by half, but \\textbf{hard to merge giant components}.\n    \\item Why not combine the two algorithms?\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Controlled-GHS Algorithm [GKP98, KP98]}\n\\begin{itemize}\n    \\item Idea: \\textbf{maximal matching} can bound the component size.\n    \\item Fact: \\textbf{maximal matching} on rooted tree: $\\log^*(n)$ rounds.\n    \\item In the first part, use \\textbf{GHS} to reduce \\# components to $\\sqrt{n}$.\n    \\item In the second part, use \\textbf{Pipeline-MST} for $O(D + \\sqrt{n})$ rounds.\n\\end{itemize}\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.4\\textwidth,trim={0cm 5cm 12cm 0},clip]{figures/comptree.pdf}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Controlled-GHS Algorithm [GKP98, KP98]}\n\\begin{itemize}\n\\item $\\log \\sqrt{n}$ phases in the first part.\n\\item In each phase $i$, compute the maximal matching each component.\n\\item $O(2^i \\log^*n)$ rounds (messages need to traverse at node level).\n\\item $O(2^i)$ rounds to broadcast within the component.\n\\item First part: $\\sum_{i=0}^{\\log \\sqrt{n}} O(2^i \\log^* n) = O(\\sqrt{n}\\log^*n)$ rounds.\n\\end{itemize}\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.4\\textwidth,trim={0cm 5cm 12cm 0},clip]{figures/comptree.pdf}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Controlled-GHS Algorithm [GKP98, KP98]}\n\\begin{itemize}\n\\item Second part: Pipeline-MST, $O(D + \\sqrt{n})$ rounds.\n\\item $O(D + \\sqrt{n}\\log^* n)$ rounds in total - \\textbf{time-optimal}.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Controlled-GHS Algorithm [GKP98, KP98]}\n\\begin{itemize}\n\\item \\textbf{High} message complexity.\n\\item First part: $\\log \\sqrt n$ rounds. \n\\item $O(m + n \\log \\sqrt{n}) = O(m + n\\log n)$ messages.\n\\item Second part, $O(m)$ messages to build a BFS tree.\n\\item Each node sends $O(\\sqrt{n})$ edges. \n\\item Total message complexity: $O(m+n^{\\frac{3}{2}})$ - \\textbf{not optimal}.\n\\end{itemize}\n\\end{frame}", "meta": {"hexsha": "5bc076334f0dfa2149ff354bb434684ee61dd0c8", "size": 5119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/background.tex", "max_stars_repo_name": "renmengye/dist-mst-talk", "max_stars_repo_head_hexsha": "25f6a36c4cae5688fe7fa7965d4945e07f4b2909", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/background.tex", "max_issues_repo_name": "renmengye/dist-mst-talk", "max_issues_repo_head_hexsha": "25f6a36c4cae5688fe7fa7965d4945e07f4b2909", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/background.tex", "max_forks_repo_name": "renmengye/dist-mst-talk", "max_forks_repo_head_hexsha": "25f6a36c4cae5688fe7fa7965d4945e07f4b2909", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.355704698, "max_line_length": 109, "alphanum_fraction": 0.6985739402, "num_tokens": 1671, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4144459118544271}}
{"text": "% Define document class, aastex631, mnras and aa.\n\\documentclass[twocolumn]{aastex631}\n\n% Filler text\n\\usepackage{blindtext}\n\n% Begin!\n\\begin{document}\n\n% Title\n\\title{An open source scientific article}\n\n% Author list\n\\author[0000-0000-0000-0000]{First Author}\n\n% Abstract with filler text\n\\begin{abstract}\n    \\blindtext\n\\end{abstract}\n\n% Main body with filler text\n\\section{Introduction}\n\\[\nR_{\\mu\\nu}-\\frac{1}{2}g_{\\mu\\nu}R+\\Lambda g_{\\mu\\nu} = \\frac{8\\pi G}{c^4}T_{\\mu\\nu}\n\\]\n\n\\begin{figure}\n    \\begin{centering}\n        \\includegraphics[width=\\columnwidth]{figures/test.pdf}\n        \\caption{This is a test.}\n        \\label{fig:test}\n    \\end{centering}\n\\end{figure}\n\n\\Blindtext[4]\n\n\\[\nR_{\\mu\\nu}-\\frac{1}{2}g_{\\mu\\nu}R+\\Lambda g_{\\mu\\nu} = \\frac{8\\pi G}{c^4}T_{\\mu\\nu}\n\\]\n\n\\end{document}\n", "meta": {"hexsha": "0512aa6790952e6989256616532dcfe90a149528", "size": 795, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/ms.tex", "max_stars_repo_name": "Astro-Lee/mpPapers", "max_stars_repo_head_hexsha": "69cf4bc3d3668659841694b57e6c1188d9b15bf7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ms.tex", "max_issues_repo_name": "Astro-Lee/mpPapers", "max_issues_repo_head_hexsha": "69cf4bc3d3668659841694b57e6c1188d9b15bf7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ms.tex", "max_forks_repo_name": "Astro-Lee/mpPapers", "max_forks_repo_head_hexsha": "69cf4bc3d3668659841694b57e6c1188d9b15bf7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.9285714286, "max_line_length": 83, "alphanum_fraction": 0.6666666667, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228625116081, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.41444590767868406}}
{"text": "\\section{Audio Impedance Measurement}\n\\label{sect:ZMeas}\n%\nAudio Vector Network Analysis (AVNA) measurements break into two main types,  reflection and transmission.  This section covers the first case, reflection.  The major use of reflection measurements is to determine the impedance\nwhich creates the reflection, or, put another way, a quantity directly associated with impedance, such as inductance. This section covers AVNA impedance measurements. The next section covers transmission measurements.\n\nThe term \"Vector\" refers to the fact that we always measure both the amplitude and the relative phase of impedance.  This enables us to measure a combination of resistive and reactive components.\n%\n\\subsection{Description}\n\\label{subsect:ZDescr}\nBefore getting to the details of the measurements, we need to explore a few background items.\n\n\\subsection{Complex Impedance}Using the AVNA1 impedance \\q{T} terminals , the basic measurement quantity that is often displayed is impedance described by a resistance in series with a reactance. The reactance can be either a lossless inductance or a capacitance. Mathematically, this is represented as a complex number $\\vec{Z}$=R+jX where R is the series resistance and X is the series reactance, both in Ohms. The AVNA1 uses complex arithmetic notation for $\\vec{Z}$ which allows mathematically sound computation to be done on circuit models; the user can think of it as a way to keep the resistance separate from the reactance.\n\nIf the reactance is positive, the series component represents an inductor. Likewise, if the reactance is negative, the series component is a capacitor.  Note that this is only one of many representations. As an example, a series configuration can be converted to a parallel pair of components, neither being the same value as the series pair.  We will not attempt to cover all the possibilities here, but a few of them will be described below, as they appear in the display.\n\n\\subsection{Reference Resistance}Two different reference resistances can be used with the AVNA, 50 and 5,000 Ohms. The best value to use is generally the one that is in the range of the measured values. It is easy to pick 50 Ohms if the measured value is, say, 10 + j100. If the series reactance is much larger than the series resistance, we have a high-Q component that is not the easiest to measure with an AVNA. For that case we are probably going to uses the reference resistance that is closest to \\(X\\) since that determines the component value. If the user is trying to measure a resistance value, it is best to pick a reference resistance closest to the resistor value.\n\nA more elaborate procedure for finding the best reference resistance for a general impedance type is to first measure with 50 Ohms. Then find the geometric mean of the resistance and the reactance, that is \\(\\sqrt{R X}\\). Then remeasure with 5,000 Ohm reference. Choose the ratio of the geometric mean to the reference resistance (50 or 5,000) which is closest to 1.0.\n\nThe best reference resistance decision is calculated by ratio, not by subtraction. For instance 4,000 Ohms has a ratio with 50 Ohms of  \\( \\frac{4000}{50} = 80\\) whereas the ratio with 5,000 Ohms is \\( \\frac{5000}{4000} = 1.25\\). The latter is closer to 1.0 than the former.  Note that we put the larger value on top of the ratio for convenience in comparing the two results.\n%\n\\subsection{Instructions}\n\\label{subsect:ZInstr}\n\\textbf{Getting Started - }Here is a step-by-step description of a single frequency impedance measurement followed by a description of a swept impedance measurement. This will all be done directly from the touch screen. Everything covered here, and more, can be done via the USB-Serial link, as is described in the \"AVNA1 Serial Interface\" section.\n\nWhen the AVNA1 is powered up, you have a choice of four Audio Test Instruments along with Service and Calibration functions.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_000.pdf}\n\\caption{Audio Test Instrument Home  Screen.}\n\\label{AVNA_000-label}\n\\end{center}\n\\end{figure}\n%\nReferring to Figure \\ref{AVNA_000-label}, we are now at the main AVNA1 Audio Test Instrument home screen.  For our impedance measurements, we will select the menu item, \"\\textsf{AVNA}\" by touching that box at the bottom of the screen leading to the AVNA main screen.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_001.pdf}\n\\caption{AVNA Main  Screen.}\n\\label{AVNA_001-label}\n\\end{center}\n\\end{figure}\n%\nWe now have the choice  of single frequency or swept measurements as well as changing of the Reference Resistance described above. A last choice is the \"\\textsf{What?}\" function for exploring components without knowing much about them. To continue our impedance measurement, we select \"\\textsf{Set Ref R}\".\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_003.pdf}\n\\caption{AVNA reference resistor selection  Screen.}\n\\label{AVNA_003-label}\n\\end{center}\n\\end{figure}\n%\nThe current reference, as described above, is shown on the screen. It is also shown, during AVNA measurements, at the top of the screen in small type. Selecting the current value has no effect, and so in this example we choose the menu item, \"\\textsf{5k Ohms}\".\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_004.pdf}\n\\caption{AVNA reference resistor selection of 5000 (5K) Ohms.}\n\\label{AVNA_004-label}\n\\end{center}\n\\end{figure}\nAt this point we have changed the reference resistance and can return to the AVNA main screen, Figure \\ref{AVNA_001-label}, by tapping the menu item, \"\\textsf{Back}\".\n\n\\textbf{Measuring an Impedance - }As an example, suppose we put together a series combination of a 10 Ohm resistor and a 0.22 $\\mu$F capacitor and put this across the \\q{Z} terminals. To get started, we can measure this at a single frequency by tapping on the menu item, \"\\textsf{Single Freq}\". The frequency can be selected from a list of 13 ranging from 10 Hz to 40 kHz by using the menu items, \"\\textsf{Freq Down}\" and \"\\textsf{Freq Up}\".  For this sample measurement set the frequency to \"1000 Hz\".  Next, the menu item, \"\\textsf{Meas Z}\" is tapped to start a continuing series of impedance measurement, as shown next.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_006.pdf}\n\\caption{Impedance measurement of a series combination of 10 Ohms and a 0.22 $\\mu$F capacitor.}\n\\label{AVNA_006-label}\n\\end{center}\n\\end{figure}\nA couple of items to note:  First, this measurement repeats every second or so.\nThis is useful if you are measuring multiple components, or if you want to do mental averaging of the component values.\n\nNext, we see the series combination of  $\\vec{Z}$=11.07 -j700.7, which is the resistance and reactance. I measured the 10 Ohm resistor, without the capacitor and saw 9.81 Ohms with a 50 Ohm reference and 8.23 Ohms with a 5000 Ohm reference, so the 11.07 Ohm value which is probably a combination of the difficulty in measuring the resistor with 700 Ohms reactance in series as well as some loss in the capacitor.  The 9.81 Ohms is very close to the measured DC value. Then we see the translation of the reactance value to a capacity of 227.1 nF (or 0.2271 $\\mu$F).  Often this is the value we are looking for.\n\nThe Q value shown of 63.3 is the ratio of the reactance magnitude to the resistance value.  We are accustomed to measuring Q of inductors, and that would be shown here if the reactance were positive.  The Q of a capacitor has a physical meaning that parallels that of an inductor.\n\nLastly, the same screen shows the parallel RC values. At the one frequency where we measure the series connected components, we could have connected this parallel combination, and we would have measured the same quantities.\nFor more details on the series/parallel equivalence, see the original QEX article.\\footnote{\\textbf{\\texttt{http://www.janbob.com/electron/AVNA1/Larkin-QEX-2018-May-Jun.pdf}}, pg. 12} In particular, note that in general, both the resistance and reactance values will change between the series and parallel representations.\n\n\\textbf{Swept Impedance Measurements - }  We do not have a graphical presentation of frequency swept impedance data.  Instead we have a tabular listing. To do this measurement from the single frequency version, we tap on \"\\textsf{Back}\", bringing back the screen of Figure \\ref{AVNA_001-label}. At this point we could change the reference resistor to 50 Ohms, but not for this exercise. Instead, we tap on \"\\textsf{Sweep}\", bringing up the following screen.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_007.pdf}\n\\caption{Main Screen for swept measurements.}\n\\label{AVNA_007-label}\n\\end{center}\n\\end{figure}\nWe can change the 7 screen displayed frequencies shown in Figure \\ref{AVNA_009-label} with the two menu items at the bottom.  In all cases, the measurements are made at all 13 frequencies, but there is not room to display them all.  For now, we will leave the frequency settings at 50 to 5000 Hz.  We command the impedance measurement by tapping on, \"\\textsf{Meas Z}\".  Here is the display.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_009.pdf}\n\\caption{Swept impedance measurements.}\n\\label{AVNA_009-label}\n\\end{center}\n\\end{figure}\n%\nThe display shows the impedance for seven frequencies.\nThe menu items, \"\\textsf{Disp Frq Down}\" and \"\\textsf{Disp Frq Up}\" allow the displayed frequencies to be shifted down or up to cover the entire 10 to 40,000 Hz range.  The impedance is shown in  \\(R+jX\\) format. It can be seen that negative reactance values display with a minus sign in front of the value. Next in the display line is a translation of the  \\(jX\\) value to either a capacitance or inductor value. The units, in this case,  \"\\textsf{nF}\" change with component value.  In the right hand column is a rough measure of measurement quality. A single letter \\textsf{E, G, P} corresponds to (\\textsf{E})xcellent, (\\textsf{G})ood, or (\\textsf{P})oor. These indicate the difference between the impedance and the reference resistance.\nThe \\textsf{E}, \\textsf{G}, and \\textsf{P} designations should not be taken too literally, but if the letter shows \"\\textsf{P}\" or even \"\\textsf{G}\",  you might consider the values and whether to re-measure with the other reference resistance.\n\nGoing back to the AVNA main menu, there is a menu item, \"\\textsf{What?}\".  This is handy if the component type or value is unknown, or maybe a quick answer is wanted.  This starts with the following menu that describes what to do.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_012.pdf}\n\\caption{AVNA What? Screen.}\n\\label{AVNA_012-label}\n\\end{center}\n\\end{figure}\n%\nThe only option available is to omit measuring at 10, 20 and 50 Hz that speeds up the measurement. Otherwise, tapping on \"\\textsf{Search Value}\" produces the estimate:\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_013.pdf}\n\\caption{AVNA What? Screen after measuring.}\n\\label{AVNA_013-label}\n\\end{center}\n\\end{figure}\n%\nTwo different values are shown, corresponding to the two reference resistor values.  The \"\\textsf{What?}\" process chooses the frequency that gives an \"E\" for excellent measurement, if possible.  Often, this differs in frequency between the two reference resistor values.  For our 10 Ohm and 0.22 $\\mu$F series combination, we find the 50 Ohm reference measurement at 20,000 Hz and the 5000 Ohm measurement down at 200 Hz.  In either case, the capacitive value works out well, but measuring the 10 Ohm resistor in series with a 3492 Ohm reactance (at 200 Hz) is looking less successful with a 19.28 indicated \\(R\\) value.  It would be interesting to explore this further by measuring the two components individually with swept measurements. (We won't do that here to save the fun for others.)\n%\n\\subsection{Discussion}\n%\n\\textbf{Measurement Technique - } There are two commonly used methods of measuring impedance: the unbalanced Wheatstone bridge.\\footnote{The classic Wheatstone bridge,\\textbf{\\texttt{https://en.wikipedia.org/wiki/Wheatstone\\_bridge}}} \\footnote{The Wheatstone bridge in various AC/RF forms,\\textbf{\\texttt{http://g3ynh.info/zdocs/bridges/part\\_1.html}}}\n%\n and the series resistor method.   The latter method is used in the AVNA.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.75]{./images/AVNA_900.pdf}\n\\caption{Functional schematic of impedance measuring circuit.}\n\\label{AVNA_900-label}\n\\end{center}\n\\end{figure}\n%\nFigure \\ref{AVNA_900-label} shows the deceptively simple measurement circuit.  A software Direct Digital Synthesis (DDS) in the Teensy DSP creates a sine wave signal at a frequency between 10 and 40,000 Hz.  This is converted to an analog voltage by the left DAC on the Teensy Audio Adapter board which then goes to an audio amplifier producing the analog signal  $\\vec{V_R}$ seen on the diagram.\nThe overhead bar indicates that this is a complex voltage where we care about the phase of the sine wave as well as the amplitude.  \\vecr{$\\mathbf{V_R}$} is applied to the series combination of our reference resistor, $R_R$ and the unknown impedance, $\\vec{\\mathbf{Z_u}}$.  This results in a current through the pair  of \\(\\vec{\\mathbf{V_R}}  /  (R_R +   \\vec{\\mathbf{Z_u}})\\).  By measuring the complex voltage at the top of the unknown, $\\vec{\\mathbf{v_Z}}$ we can determine this current as\n\\begin{equation}\n \\vec{\\mathbf{i_u}}=\\vec{\\mathbf{V_R}}-\\vec{\\mathbf{V_Z}}/R_R\n\\end{equation}\n This in turn allows calculating the unknown impedance as\n\\begin{equation}\n\\vec{\\mathbf{Z_u}} =\\vec{\\mathbf{V_Z}}/\\vec{\\mathbf{i_u}}               =R_R \\times\\vec{\\mathbf{V_Z}}/\\vec{\\mathbf{V_R}}-\\vec{\\mathbf{V_Z}}\n\\end{equation}\nAs one would expect, this requires knowledge of the reference resistor value, but the absolute voltages are not used, but rather the ratio of absolute voltages.  This makes it important to have the two voltmeters, $\\vec{\\mathbf{V_R}}$ and $\\vec{\\mathbf{V_Z}}$ track in both amplitude and phase.  There is separate analog circuitry in the two voltmeter paths, so errors will occur.  These errors are removed by the calibration procedure where the two voltmeters are connected to the signal source and the ratio  of voltages and the difference in phase of the two is recorded. These are then applied as corrections at each impedance measurement.\n\n\\textbf{Measuring Amplitude and Phase - }The discussion of Measuring Technique, above, refers to the two voltmeters that are needed.  The  implementation of voltmeters is discussed in the QEX article referenced above, pages 8-9,\nand won't be repeated here.  The basic process is to generate a pair of software sine waves that are 90 degrees apart in phase but at the exact measurement frequency.  Each of these is multiplied (mixed) with the signal being measured and then low-pass filtered.  This produces the two complex voltages, needed for the impedance calculation.  All of the mixing and filtering occurs in the Teensy DSP.", "meta": {"hexsha": "5a6bf6d17b62d2538bf34ceee4f1fff9019928fa", "size": 15067, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "AVNA-UsersManual/c-AVNA-ZMeasure.tex", "max_stars_repo_name": "boblark/AVNA1UsersManual", "max_stars_repo_head_hexsha": "d6df2f2ec54cc431751da1d88f776a3aeb25b913", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "AVNA-UsersManual/c-AVNA-ZMeasure.tex", "max_issues_repo_name": "boblark/AVNA1UsersManual", "max_issues_repo_head_hexsha": "d6df2f2ec54cc431751da1d88f776a3aeb25b913", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AVNA-UsersManual/c-AVNA-ZMeasure.tex", "max_forks_repo_name": "boblark/AVNA1UsersManual", "max_forks_repo_head_hexsha": "d6df2f2ec54cc431751da1d88f776a3aeb25b913", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.8040540541, "max_line_length": 791, "alphanum_fraction": 0.7756686799, "num_tokens": 3832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4144459067943522}}
{"text": "\\chapter{Related Work}\n\\label{text:related}\nSocially-aware and safe navigation among human pedestrians poses a problem which is far from being solved and applicable to a wide range of real-world scenarios. One of the challenging factors of this field lies in the broad palette of building blocks that a possible solution may depend on, each being a challenging subproblem. In the following, some of the related subproblems tackled within project \\project are introduced.\n\n\\section{Pedestrian Prediction}\n\\label{text:related/prediction}\nThe problem of predicting human motions has been tackled by many different approaches. Some approaches try to model the human dynamics, including the dynamics of their interaction with their environment, or try to come up with a cost function that the human is trying to maximize (ontological methods). Other approaches model the pedestrian behavior merely by observing and (afterward) replicating it, without the use of inherent assumptions about the structure of the interaction or the human mindset itself (phenomenological methods).\n\n\\subsection{Ontological Approaches}\nAs described above, ontological approaches tackle the problem of predicting human movement by describing it as guided by an underlying \"physical\" model or some cost function. One popular example of a \"physics-based\" model, i.e., algorithms that model the pedestrian dynamics using first-order physical principles, is the social forces model \\cite{Helbing1995}. The Social Forces model is one of the most commonly used pedestrian predictions models in the field, due to its combined capabilities to accurately predict the behavior of human movement, its interpretability, and its small computational complexity. The model uses first-order mechanical principles for forecasting the human motions in accordance with several interaction forces, that describe the impacts the pedestrian is exposed to:\n\n\\begin{align}\n\\vec{F} &= \\underbrace{\\frac{1}{\\tau_{\\alpha}} (v^0_{\\alpha} \\vec{e}_{\\alpha} - \\vec{v}_{\\alpha})}_{F_{goal}} - \\underbrace{\\nabla_{\\vec{r}_{\\alpha \\beta}} V_{\\alpha \\beta}[b(\\vec{r}_{\\alpha \\beta})]}_{F_{interaction}} \n\\label{eq:social_forces} \\\\\n2b &= \\sqrt{(||\\vec{r}_{\\alpha \\beta}|| + ||\\vec{r}_{\\alpha \\beta} - v_{\\beta} \\dt \\vec{e}_{\\beta}||)^2 - (v_{\\beta} \\dt)^2}\n\\end{align}\n\nFor every pedestrian $\\alpha$, Social Forces describes an attractive force to reach an imaginary goal position with desired velocity $v^0_{\\alpha} \\vec{e}_{\\alpha}$, with $\\vec{e}_{\\alpha}$ being the unit direction vector pointing from the pedestrian's current to its goal position and $v^0_{\\alpha}$ being the desired speed, e.g.,\\ the maximal speed. The second force describes the repulsive forces the pedestrians exert among each other, modeled by the gradient of some potential field $V_{\\alpha \\beta} = V_{\\alpha \\beta}^0 \\exp(-b / \\sigma)$ in the direction pointing from pedestrian $\\alpha$ to pedestrian $\\beta$. Thereby, $b$ takes the relative speed and directions of the regarded pedestrian pair into account. While Social Forces is a mainly deterministic model, similar approaches use recursive Bayesian filtering to deal with uncertainty, such as \\cite{Schneider2013}\\cite{Rehder2015}\\cite{Guo2016}. Due to the small computational complexity and the high interpretability of these models, they tend to be very useful for large scale simulations but are prone to modeling errors in small scale predictions, as they widely hinge on a set of estimated parameters which is assigned individually to each pedestrian, might not grasp the exact dynamical model of the pedestrian and do not take into account knowledge about past interactions, which is likely to be important for the up-coming interactions.\n\\newline\nAnother way of explicitly formulating the humans' interaction with their environment is by deriving a cost function that the human maximizes during the interaction. While some works describe the cost function as a payoff of a cooperative or adversarial game and apply game theory to predict the behavior of the other agents as well as of the agent itself, such as \\cite{Bouzat2014}\\cite{Nikolaidis2017}, other works use \\ac{IRL} \\cite{Ng2000} to characterize the interaction as a value function assigned to each state-action-pair, such as \\cite{Fahad2018}\\cite{Fernando2019}\\cite{Saleh2018}, or as an expansion to probabilistic predictions using maximum entropy \\ac{IRL} \\cite{Ziebart2008}. Since IRL-based approaches rely on the Markovian property, they are not capable of including the interaction history while losing the property of interpretability by using a sufficiently complex reward function for modeling human interaction. Consequently, these approaches might work well under the constraints of limited data due to the possibility of encoding prior knowledge and the extrapolation capabilities of \\ac{IRL}-based approaches but lack behind phenomenological in the presence of many available data.\n\n\\subsection{Phenomenological Approaches}\nPhenomenological methods incorporate data-driven techniques to observe and imitate human behavior. As a consequence, they make merely minimal assumptions about the inherent interaction process, especially in comparison to most of the ontological methods discussed above. Therefore, the availability of a reasonably large set of observable data is the key to developing a well-performing prediction model. However, since increasingly many pedestrian datasets became available over recent years, such as \\cite{Pellegrini2009}\\cite{Rasouli2019}\\cite{Caesar2020}, phenomenological models became increasingly accurate for a wide range of scenarios. \n\\newline\nIn contrast to previously described methods, phenomenological approaches do not assume Markovian state transitions and are therefore capable of taking the state histories of each agent into account, a presumably crucial feature for a precise prediction over future states. \\ac{LSTM} modules \\cite{Hochreiter1997} have been developed to model temporal sequences and are thus perfectly suitable for the purpose of mining past human trajectories for predicting future states, as done in \\cite{Chen2019a}\\cite{Hug2018}\\cite{Zhang2019}\\cite{Jain2016} (similarly using GRUs \\cite{Liu2020}). However, the resulting deterministic trajectory output is not able to account for the uncertainty assigned to each prediction of future states, particularly due to the dynamic nature of human gait. To fully account for each possible future outcome, however, unimodal predictions would either miss some eventualities or be overly conservative estimates. \n\\newline\nGenerative models proved to be well applicable to solve this dilemma by producing general (including multi-modal) probability distribution over future pedestrian trajectories, learned from data. A \\ac{GAN} \\cite{Goodfellow2014}, a type of (deep) generative models, has been widely used in the field, as in \\cite{Gupta2018}\\cite{Kosaraju2019}\\cite{Ouyang2018} but is especially hard to train due to the internal conflict between generator and discriminator and generally output empirical distributions. Related to \\ac{GAN}s are \\ac{VAE}, a class of generative models that make use of a latent space. Conditional VAEs (CVAEs) have been recently used to predict distributions over pedestrian trajectories. CVAEs can learn the probability distribution of their latent space variables and map samples of these distribution to obtain a desired output distribution, allowing empirical as well as analytical distributions, and being easier to train in comparison to \\ac{GAN}s. Especially, this only allows to formulate the desired output distribution to be processable for online usage. Examples of works using (C)\\ac{VAE}s in the area of pedestrian prediction are \\cite{Ivanovic2018}\\cite{Salzmann2020}\\cite{Poibrenski2020}\\cite{Lee2017}.\n\n\\subsection{Trajectron}\nThe Trajectron++ model \\cite{Salzmann2020} by Salzmann et alt., an enhancement of the original Trajectron model \\cite{Ivanovic2018}\\footnote{For the sake of brevity in the following the Trajectron++ model will be addressed by the Trajectron model.}, is a generative, graph-structured, pedestrian prediction model based on a C\\ac{VAE}. By incorporating the state histories of various agents in the scene as well as their environment, it can efficiently predict a distribution over a full trajectory of future states, each being multi-modal and represented by a \\ac{GMM}. Especially, to the best of the authors' knowledge, the Trajectron model is the only model within the field of pedestrian prediction that is able to condition the prediction on a robot's planned trajectory.\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=\\imgwidth]{images/trajectron++.png}\n\\captionof{figure}{Spatiotemporal network architecture of Trajectron++ model \\cite{Salzmann2020}}\n\\label{img:trajectron_model}\n\\end{center}\n\\end{figure}\n\n\\begin{equation}\n\\max_{\\phi, \\theta, \\psi} \\sum_{i=1}^N \\mathbb{E}_{z \\sim q_{\\phi}(z | x_i, y_i)} [\\log p_\\psi (y_i | x_i, z)] - \\beta D_{KL} (q_{\\phi}(z | x_i, y_i) || p_{\\theta}(z | x_i)) + \\alpha I_q(\\boldsymbol{x}; z)\n\\label{eq:trajectron_loss}\n\\end{equation}\n\nFigure \\ref{img:trajectron_model} shows the architecture of the Trajectron model. Each agent in the scene is modeled as a node in a spatio-temporal graph, with assigned state history and properties shared by nodes of the same type, e.g.,\\ pedestrian or vehicle. Equation \\ref{eq:trajectron_loss} shows the loss function the model is being trained with. In the first step, the inputs, which are the state history of each node, including the robot, the environment obstacle map, as well as the planned robot trajectory (inputs $\\boldsymbol{x}$), are encoded to a 25 dimensional latent space $\\boldsymbol{z}$. The latent space representation is then sampled to generate the output distribution $\\boldsymbol{y}$, unrolled over the full prediction horizon. Formally, the model is described as estimating the conditional probability distribution $p(\\boldsymbol{y}|\\boldsymbol{x})$ by marginalizing over the latent variable $\\boldsymbol{z}$:\n\n\\begin{equation}\np(\\boldsymbol{y}|\\boldsymbol{x}) = \\sum_{\\boldsymbol{z}} p_{\\psi} (\\boldsymbol{y} | \\boldsymbol{x}, z) p_{\\theta}(z | \\boldsymbol{x})\n\\end{equation}\n\nThe optimization can be regarded as maximizing the $\\beta$-weighted evidence lower-bound of the conditional distribution $p(\\boldsymbol{y}|\\boldsymbol{x})$ \\cite{Ivanovic2018}. Although the model is able to deal with the agent's environment as well as several types of agents project, \\project focuses on the pedestrian type in a free-space environment, which is described in Section \\ref{text:approach/formulation} and its implications in Section \\ref{text:experiments/integration}.\n\n\\section{Safe Planning under Uncertainty}\n\\label{text:related/uncertainty}\nTrajectory optimization itself is a wide field with many different methodologies. Though the area can be roughly broken down into two categories, shooting and collocation \\cite{Kelly2017}.\\footnote{There are several other directions of separation possible such as the direct vs indirect methods, but I will focus on shooting vs collocation here. Further information about the taxonomy of trajectory optimization can be found in \\cite{Kelly2017}  and \\cite{Chai2020}.} Shooting optimizes for the control inputs and unrolls them using a simulation environment to compute objective and constraint. Thereby, the dynamics constraint $x = \\f(x, u)$ is intrinsically enforced. In comparison, collocation uses all controls and states as decision variables while constraining the system dynamics and tries to solve the \\ac{NLP} by approximating some function (e.g.\\ Lagrange polynomials in orthogonal collocation).\n\\newline\nWhile traditionally, the problem of trajectory optimization under uncertainty has been tackled by using fixed error bounds on all uncertainties in the system, which is also known as robust control \\cite{Bemporad1999}. Consequently, solutions obtained were largely sub-optimal due to widely overestimating the actual system uncertainties, or the optimization formulation became infeasible and thus impossible to solve. Subsequently, many different directions of research have evolved, such as formulating the problem as a \\ac{POMDP} and (online) \\ac{POMDP}-solvers to find feasible trajectories \\cite{Chen2016}, using Monte-Carlo planning \\cite{Janson2015} \\cite{Silver2010}, signal temporal logic \\cite{Sadigh2016}, (probabilistic) decision graphs \\cite{Koenig1994}, sampling-based methods, as well as constraint formulations that estimate and bound the risk (or chance) of collision \\cite{Ono2015}\\cite{Lew2019}\\cite{Chow2015a}\\cite{Chow2013}\\cite{Ono2012}\\cite{Ludersa}\\cite{Luders2011}\\cite{Otte2014} or reachability-based concepts for guaranteeing the impossibility of collision solely on the base of the dynamical properties and initial conditions of interacting agents \\cite{Leung2020}\\cite{Dhinakaran2017}\\cite{Margellos2009}\\cite{Chen2017b} \\cite{Althoff2009}\\cite{Althoff2010}. Since discussing all of these different techniques surely is out of the scope of this work, only three approaches, which are most relevant to this work, will be examined in the following:\n\n\\subsection{Sampling-based Path Planning}\nSampling-based path planning methods, such as RRT \\cite{LaValle1998}, have been shown to be an efficient solution for path planning in continuous-space, static environments, while often guaranteeing asymptotic optimality and feasibility of the derived solution, such as \\cite{Karaman2011}\\cite{Luders}. These algorithms are iteratively sampling random points from the configuration space, while retaining those in the free space (i.e., free from obstacles), storing them as milestones in a roadmap, and connecting those milestones, which can be connected completely in the free space. The algorithm repeats until either the goal state has been incorporated in the roadmap or the maximal computation time has exceeded. To account for dynamic and probabilistic obstacles, a temporal dimension has to be added to the search space, making the problem computationally challenging to solve in real-time. For addressing this issue, rapid replanning and repairing \\cite{Otte2014} are often used. To implicitly take into account system uncertainties, the occupancy cost can be augmented by risk level sets that assign a certain risk to each robot state, depending on the obstacle's state, e.g., its orientation and velocity, as shown in \\cite{Pierson2018}\\cite{Pierson2019}. However, despite the success of sampling-based methods in online path planning, they do not explicitly leverage future predictions of the environment and are therefore restricted to only (temporally) locally optimal solutions.\n\n\\subsection{Chance Constraints}\nChance constraints are a specific way of formulating a constraint under uncertainty, such that it holds for at least a pre-defined probability level $p$. With a general inequality constraint $g(x) \\leq 0$ it is:\n\n\\begin{equation}\nPr(g(x) \\leq 0) \\geq p\n\\label{eq:chance_constraint}\n\\end{equation}\n\nUsually, constraint \\ref{eq:chance_constraint} is reformulated as a set of deterministic constraints to be manageable for optimization. Therefore, several methods have been purposed: Sampling-based methods relying on the Bernstein approximation \\cite{Calafiore2005}, on scenario planning approach \\cite{Bemporad1999}, or Monte Carlo sampling \\cite{Hong2011}\\cite{Janson2015} as well as dynamic-programming based approaches for discrete space \\cite{Chow2013}\\cite{Ono2015} \\cite{Chow2015a}. While these methods work for general distributions but are usually too slow for an online optimization approach, shrinking the space of distributions can improve the performance, such as in \\cite{Chen2018}\\cite{Calafiore2006}\\cite{Carvalho2014}\\cite{Blackmore2009}\\cite{Blackmore2011}. Thereby, handling multi-modality of the risk distribution efficiently is a widely untouched ground, to the best of the authors' knowledge, which only has been solved for a specific scenario, such as in \\cite{Hu2018}. To conclude, solving a chance constraints program efficiently is quite hard to do, especially when dealing with general, such as multi-modal and non-convex risk distributions.\n\n\\subsection{Hamilton-Jacobi Reachability} \nReachability analysis deals with the problem of a two-person, zero-sum differential game. Specifically, it tries to solve the question how to react if there is another player that interferes with the fulfillment of the robot's objective by optimizing the joint system state, assuming that the counter-player always counters the robot's action optimally, i.e., assuming the worst case disturbance $\\d = \\beta[\\u]$ \\cite{Pavone2020}. Under these conditions, the optimal control strategy can be derived by maximizing: \\\\\n\n\\begin{equation}\nV(x(t), t) = \\min_{\\beta[\\u](\\cdot)} \\max_{\\u(\\cdot)} \\left[ \\int_t^0 l(\\x(\\tau), \\u(\\tau), \\boldsymbol{d}(\\tau)) \\, d\\tau + l_f(\\x(0)) \\right]\n\\label{eq:j_reachability}\n\\end{equation}\n\nwith $(\\x(\\tau), \\u(\\tau), \\d(\\tau))$ describing the joint system with dynamics $f(\\boldsymbol{x}, \\u, \\d)$. While solving the robot's optimal control strategy $\\u_{opt}$ in open-loop (also \\textit{forward} reachability) is computationally inexpensive but leads to overly conservative and hence un-realistic estimates, since the counter-player knows the entire policy $\\u_{opt}$ in advance and can re-act accordingly, \\ac{HJR} (also \\textit{backward} reachability) addresses the problem of maximizing Equation \\ref{eq:j_reachability} in closed-loop, i.e., by allowing the robot to adapt its control policy at each time-step. As proven in \\cite{Pavone2020}, this is equivalent to solving the Hamilton-Jacobi-Isaacs differential equation with boundary condition: \\\\\n\n\\begin{problem}{General \\ac{HJR} problem}\n\\begin{align}\n\\pd{V}{t} + \\max_{\\u}  \\min_{\\d} &\\left[l(\\x, \\u, \\d) + \\nabla V^T f(\\x, \\u, \\d) \\right] = 0 \\\\ \nV(\\x, 0) &= l_f(\\x) \\\\\n\\Rightarrow \\u_{opt} &= \\arg \\max_{\\u}  \\min_{\\d} \\nabla V^T f(\\x, \\u, \\d)\n\\label{eq:hjr_problem_u}\n\\end{align}\n\\label{eq:hjr_problem}\n\\end{problem}\n\nSolving Problem \\ref{eq:hjr_problem} has been examined for several scenarios and applications over the recent years, as in \\cite{Dhinakaran2017}\\cite{Margellos2009}\\cite{Chen2017b}, and has shown to be especially useful in the field of autonomous driving \\cite{Althoff2009}\\cite{Althoff2014}\\cite{Althoff2010}. In opposite to forward reachability, \\ac{HJR} finds the non-overly conservative avoidance maneuvers, \"stemming from its equivalence to an exhaustive search over the joint system dynamics\" while still being flexible with respect to the system dynamics, as depicted by \\cite{Leung2020}. To solve \\ref{eq:hjr_problem}, the value function $V(\\cdot)$ as well as its gradient are computed for every cell of a $n$-dimensional grid that discretizes the joint state $\\x(\\tau)$ and for some discrete time horizon (including $\\tau \\rightarrow \\infty$). \n\n\\section{Navigation in Human Crowds}\n\\label{text:related/crowd_navigation}\nNavigation in human crowds is especially important for vastly integrating autonomous ground vehicles in our daily life but poses a hard problem due to a priori unknown human intentions and hard to quantify objectives, e.g.,\\ the notion of socially-acceptable behavior. Existing work in this field can be roughly divided into two main directions, model- and learning-based approaches: \n\n\\subsection{Model-Based Approaches}\nTraditionally, the pedestrians are regarded as dynamic obstacles, with the collision avoidance algorithm being used for robot navigation \\cite{vandenBerg2011}\\cite{Fox1997}\\cite{Luo2018a}\\cite{Phillips2011}. \\ac{ORCA} \\cite{vandenBerg2011}, for example, guarantees a collision-free pre-defined time horizon, under the assumption of perfect knowledge about the state of each interacting agents as well as, more importantly, a shared, deterministic policy over all agents. Although these models have been advanced to relax some of the assumptions such as perfect perception \\cite{Hennes2012}, they still fail to capture a human-like behavior and, consequently, may lead to unsafe and socially unacceptable robot actions. To solve this issue, it is crucial to directly include the predicted impact of the robot's planned trajectories into the optimization itself. For this reason, the robot's motion has been incorporated in some of the (model-based) pedestrian prediction models discussed in Section \\ref{text:related/prediction}, e.g.,\\ the Social Forces model \\cite{Helbing1995}, usually by augmenting the model by robot-specific parameters while preserving the general concept of interaction \\cite{Ferrer2013}\\cite{Luo2018a}. Nonetheless, as discussed, these models usually are largely hinging on parameters, making them hard to tune and hence inaccurate in prediction and thus planning as a consequence of modeling errors. Additionally, model-based approaches are usually deterministic, regarding only one out of assumably many possible outcomes, and therefore might lead to un-safe behavior.\n\n\\subsection{Learning-based Approaches}\nLearning-based approaches try to replicate human behavior that has been learned from human demonstration in simulations or by accumulating features over possible trajectories of interacting agents while minimizing some interactive cost function (e.g.,\\ the separation distance) \\cite{Kim2016}\\cite{Kretzschmar2016}. While these models tend to plan trajectories that are more socially acceptable and natural, they are much larger in computational cost and very hard to train due to the dynamic and stochastic nature of human gait. Other approaches come up with a set of socially compliant rules, such as \"passing on the right\" and use deep reinforcement learning to apply them  \\cite{Knepper2012}\\cite{Chen2017}\\cite{Everett2018}. However, it can be doubted whether these methods can be generalized to unseen scenarios, how to certify a safe interaction, and whether these rules hold at all.\n\\newline\\newline\nWhile model-based approaches are computationally efficient and traceable but lack an accurate capturing of human behavior, learning-based methods do model the human motion more naturally and are therefore capable of planning socially-aware trajectories. However, they tend to be computationally expensive, are neither interpretable nor able to give any safety guarantees, which is crucial for secure human-robot interaction. Therefore, this works wants to combine both worlds, the predictive abilities of deep learned models with the safety guarantees of model-based safety guaranteeing methods, such as \\ac{HJR}, which was discussed above. To truly leverage the full \"knowledge\" of the prediction model, concepts of model-gradient informed concepts, which have been already shown to be successful in control theory \\cite{Chen2019}\\cite{Fan2020}, are thereby re-formulated for trajectory optimization. While most of the described approaches deal with deterministic and uni-modal predictions, due to the highly stochastic human motion, anticipatory and efficient, but safe interactions can only be derived when the system can reason about many possible future outcomes of the scenario so that multi-modality should be taken into account.\n\n% sequential-action control \\cite{Nishimura2020}\\cite{Nishimura2020a}", "meta": {"hexsha": "48418bf34e8460d5c6fe1feb2caecc35362e264b", "size": 23274, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/related_work.tex", "max_stars_repo_name": "simon-schaefer/mantrap", "max_stars_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-05-11T18:13:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:52:48.000Z", "max_issues_repo_path": "report/thesis/related_work.tex", "max_issues_repo_name": "StanfordASL/mantrap", "max_issues_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/related_work.tex", "max_forks_repo_name": "StanfordASL/mantrap", "max_forks_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-12-09T00:03:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T10:39:03.000Z", "avg_line_length": 219.5660377358, "max_line_length": 1594, "alphanum_fraction": 0.8013663315, "num_tokens": 5352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4144247476606547}}
{"text": "\\documentclass[10pt,portrait]{article}\r\n\\usepackage[portrait]{geometry}\r\n\\input{math_header}\r\n\r\n% Format inherited from <MA1101R Cheatsheet 17/18 Sem 1 Finals>\r\n% Original document is by Lee Yiyuan and Eugene Lim\r\n%\r\n% All the theorems are numbered according to <LINEAR ALGEBRA - Concepts and\r\n% Techniques on Euclidean Space>, ISBN 978-981-3152-88-5, Second Edition (2016)\r\n% -----------------------------------------------------------------------\r\n\r\n\\title{MA1101R Cheatsheet 19/20 Semester 1 Final}\r\n\r\n\\begin{document}\r\n\r\n\\begin{center}\r\n{\\large MA1101R Cheatsheet 19/20 Semester 1 Final}\\\\{by Howard Liu}\r\n\\end{center}\r\n\r\n\\footnotesize\r\n\r\n\\begin{multicols}{2}\r\n\\begin{justifying}\r\n\r\n\\setlength{\\premulticols}{1pt}\r\n\\setlength{\\postmulticols}{1pt}\r\n\\setlength{\\multicolsep}{1pt}\r\n\\setlength{\\columnsep}{2pt}\r\n\r\n\\section{Matrices}\r\n\r\n\\begin{namedthm*}{Theorem 1.2.7}\r\n\tIf \\textbf{augmented matrices} of two systems of linear equations are row equivalent, then the two systems have the same set of solutions. (\\(\\ast\\) Even for two homogeneous linear systems, we still need to say that \\(\\begin{pmatrix}[c|c]\\matr{A} & \\matr{0}\\end{pmatrix}\\) is row equivalent to \\(\\begin{pmatrix}[c|c]\\matr{B} & \\matr{0}\\end{pmatrix}\\), not that \\(\\matr{A}\\) is row equivalent to \\(\\matr{B}\\).)\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Example 1.4.10}\r\n\tSuppose augmented matrix \\(\\matr{R}\\) is in (R)REF:\r\n\t\\begin{enumerate}\r\n\t\t\\item LS has no solution \\\\\r\n\t\t    \\(\\Leftrightarrow\\) Last column of \\(\\matr{R}\\) is pivot.\r\n\t\t\\item LS has one unique solution \\\\\r\n\t\t    \\(\\Leftrightarrow\\) \\textbf{Only} last column of \\(\\matr{R}\\) is non-pivot.\r\n\t\t\\item LS has infinite number of solution \\\\\r\n\t\t    \\(\\Leftrightarrow\\) At least one column other than the last one is non-pivot \\\\\r\n\t\t    \\(\\Leftrightarrow\\) Number of variables $>$ Number of non-zero rows in \\(\\matr{R}\\) \\\\\r\n\t\t(\\(\\ast\\) \\# non-pivot columns in (R)REF \\(- 1 =\\) \\# unique solutions)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 6.1.8}\r\n\t\\(\\matr{A}\\) is invertible when:\r\n\t\\begin{enumerate}\r\n\t\t% T2.4.7\r\n\t\t\\item \\(\\exists \\matr{B}\\) s.t. \\(\\matr{AB} = \\matr{I} \\lor \\matr{BA} = \\matr{I}\\)\r\n\t\t\\item Refer to \\(\\textbf{Theorem 2.4.7.2}\\) below\r\n\t\t\\item \\(\\rref(\\matr{A}) = \\matr{I}\\)\r\n\t\t\\item \\(\\matr{A}\\) is a product of elementary matrices\r\n\t\t% T2.5.19\r\n\t\t\\item \\(\\det(\\matr{A}) \\ne 0\\)\r\n\t\t% T3.6.11\r\n\t\t\\item Rows of \\(\\matr{A}\\) is a basis of \\(\\mathbb{R}^n\\)\r\n\t\t\\item Columns of \\(\\matr{A}\\) is a basis of \\(\\mathbb{R}^n\\)\r\n\t\t% T6.1.8\r\n\t\t\\item 0 is not an eigenvalue of \\(\\matr{A}\\)\r\n\t\\end{enumerate} \r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 2.3.4 (Cancellation Laws for Matrices)}\r\n\tLet \\(\\matr{A}\\) be an invertible \\(m \\times m\\) matrix,\r\n\t\\begin{enumerate}[label=(\\alph*)]\r\n\t\t\\item If \\(\\matr{B}_1\\) and \\(\\matr{B}_2\\) are \\(m \\times n\\) matrices with \\(\\matr{AB_1} = \\matr{AB_2}\\), then \\(\\matr{B}_1 = \\matr{B}_2\\)\r\n\t\t\\item If \\(\\matr{C}_1\\) and \\(\\matr{C}_2\\) are \\(n \\times m\\) matrices with \\(\\matr{C_1A} = \\matr{C_2A}\\), then \\(\\matr{C}_1 = \\matr{C}_2\\)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\\begin{namedthm*}{Theorem 2.4.7.2 (generalised)}\r\n\tRelationship between singularity of \\(\\matr{A}\\) and the number of solutions of a linear system \\(\\matr{Ax} = \\matr{b}:\\)\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(\\matr{A}\\) is singular \\(\\Leftrightarrow \\matr{Ax} = \\matr{b}:\\) has $\\infty$ solutions (only case for homogeneous LS) or no solutions\r\n\t\t\\item \\(\\matr{A}\\) is invertible \\(\\Leftrightarrow \\matr{Ax} = \\matr{b}:\\) has one unique solution (trivial solution for homogeneous LS)\r\n\t\\end{enumerate} \r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 2.5.2}\r\n    Let \\(\\matr{A} = \\left(a_{ij}\\right)\\) be an \\(n \\times n\\) matrix. Let \\(\\matr{M}_{ij}\\) be an \\(\\nobreak{(n - 1)\\times (n - 1)}\\) matrix obtained from \\(\\matr{A}\\) by deleting the \\(i\\)th row and the \\(j\\)th column. Then the \\textit{determinant} of \\(\\matr{A}\\) is defined as\r\n    \\[\r\n        \\det(\\matr{A}) =\r\n            \\begin{cases}\r\n                a_{11} & \\text{if \\(n = 1\\)} \\\\\r\n                a_{11}A_{11} + \\cdots + a_{1n}A_{1n} & \\text{if \\(n > 1\\)}\r\n            \\end{cases}\r\n    \\]\r\n    where\r\n    \\[\r\n        A_{ij} = (-1)^{i + j} \\det\\left(\\matr{M_{ij}}\\right)\r\n    \\]\r\n    The number \\(A_{ij}\\) is called the \\((i, j)\\)\\textit{-cofactor} of \\(\\matr{A}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 2.5.8}\r\n    The determinant of a triangular matrix is equal to the product of its diagonal entries.\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 2.5.12 (added-on)}\r\n\tThe determinant of a square matrix is 0 when:\r\n\t\\begin{enumerate}\r\n\t\t\\item it has two identical rows, or\r\n\t\t\\item it has two identical columns\r\n\t\t\\item any row/column of its (R)REF is zero\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 2.5.15}\r\n    Let \\(\\matr{A}\\) be a square matrix. \\(k\\) is a non-zero constant.\r\n    \\begin{enumerate}\r\n    \t\\item \\(\\matr{A} \\xrightarrow{k\\vect{R}_i} \\matr{B} \\Rightarrow \\det(\\matr{B}) = k\\det(\\matr{A})\\)\r\n    \t\\item \\(\\matr{A} \\xrightarrow{\\vect{R}_i \\leftrightarrow \\vect{R}_j} \\matr{B} \\Rightarrow \\det(\\matr{B}) = -\\det(\\matr{A})\\)\r\n    \t\\item \\(\\matr{A} \\xrightarrow{\\vect{R}_i + k\\vect{R}_j} \\matr{B} \\Rightarrow \\det(\\matr{B}) = \\det(\\matr{A})\\)\r\n        \\item Let \\(\\matr{E}\\) be an elementary matrix of the same size as \\(\\matr{A}\\). Then \\(\\det(\\matr{EA}) = \\det(\\matr{E})\\det(\\matr{A})\\).\r\n    \\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 2.5.18}\r\n\tSince \\(\\det(\\matr{A}) = \\det(A^T)\\), theorem 2.5.15 holds if ``rows\" are changed to ``columns\".\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 2.5.22}\r\n\tLet \\(\\matr{A}\\) and \\(\\matr{B}\\) are two square matrices of order \\(n\\) and \\(c\\) is a scalar. Then\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(\\det(c\\matr{A}) = c^n\\det(\\matr{A})\\)\r\n\t\t\\item \\(\\det(\\matr{AB}) = \\det(\\matr{A})\\det(\\matr{B})\\)\r\n\t\t\\item if \\(\\matr{A}\\) is invertible, \\(\\det(\\matr{A}^-1) = \\frac{1}{\\det(\\matr{A})}\\)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 2.5.24}\r\n\tLet \\(\\matr{A}\\) be a square matrix of order \\(n\\). Then the \\textit{(classical) adjoint} of \\(\\matr{A}\\) is the \\(n \\times n\\) matrix\r\n\t\\[\r\n\t\\adj(\\matr{A}) = \\left(A_{ij}\\right)_{n \\times n}^T\r\n\t\\]\r\n\twhere \\(A_{ij}\\) is the \\((i, j)\\)-cofactor of \\(\\matr{A}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 2.5.27 (Cramer's Rule)}\r\n    Suppose \\(\\matr{A}\\vect{x} = \\vect{b}\\) is a linear system where \\(\\matr{A}\\) is an \\(n \\times n\\) matrix. Let \\(\\matr{A_i}\\) be the matrix obtained from \\(\\matr{A}\\) be replacing the \\(i\\)th column of \\(\\matr{A}\\) by \\(\\vect{b}\\). If \\(\\matr{A}\\) is invertible, then the system has only one solution\r\n    \\[\r\n        \\vect{x} = \\frac{1}{\\det(\\matr{A})}\\begin{pmatrix}\\det\\left(\\matr{A_1}\\right) \\\\ \\vdots \\\\ \\det\\left(\\matr{A_n}\\right) \\end{pmatrix}\r\n    \\]\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Notes 1}\r\n\t\\(\\matr{A}^{-1}\\) is able to be computed by:\r\n\t\\begin{enumerate}\r\n\t\t\\item Find \\(\\matr{B}\\) s.t. \\(\\matr{AB} = \\matr{I} \\lor \\matr{BA} = \\matr{I}\\)\r\n\t\t\\item Find using \\textbf{Theorem 2.5.25}: \\(\\matr{A}^{-1} = \\frac{1}{\\det(\\matr{A})}\\adj(\\matr{A})\\)\r\n\t\t\\item Find using: \\(\\begin{pmatrix}[c|c] \\matr{A} & \\matr{I}\\end{pmatrix} \\xrightarrow{GJE} \\begin{pmatrix}[c|c] \\matr{I} & \\matr{A}^{-1}\\end{pmatrix}\\)\r\n\t\\end{enumerate} \r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Notes 2}\r\n\t\\(\\det(\\matr{A})\\) is able to be computed by:\r\n\t\\begin{enumerate}\r\n\t\t\\item Using \\textbf{Theorem 2.5.2}\r\n\t\t\\item Using cross multiplication (for \\(2 \\times 2\\) and \\(3 \\times 3\\) matrices only)\r\n\t\t\\item Doing some ERO (e.g. GE, consider \\textbf{Thoerem 2.5.15}) and making it triangular  then using \\textbf{Theorem 2.5.8} or making it have properties in \\textbf{Theorem 2.5.12}\r\n\t\t\\item Using \\textbf{Theorem 2.5.22}\r\n\t\\end{enumerate} \r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Notes 3}\r\n\tSome random notes:\r\n\t\\begin{enumerate}\r\n\t\t\\item In \\(\\mathbb{R}^n\\) where \\(n \\ge 2\\), a set with 1 parameter is a line and that with 2 parameters is a space.\r\n\t\t\\item \\(\\matr{M}^2 + \\matr{M} = \\matr{I} \\Rightarrow \\matr{M}(\\matr{M} + \\textcolor{red}{\\matr{I}}) = \\matr{I}\\) (Don't put that \\(\\matr{I}\\) to be scalar 1!)\r\n\t\t\\item Two matrices have same RREF \\(\\Leftrightarrow\\) They are row equivalent\r\n\t\t\\item In exam, express a matrix in the form \\(\\matr{A} = (a_{ij})_{m \\times n}\\). \\textbf{DO NOT} use dots form\r\n\t\t\\item When using ERO \\(\\vect{R}_i = \\frac{1}{k}\\vect{R}_j\\), discuss whether \\(k\\) is 0 when necessary\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Notes 4}\r\n\tGenerally, for (square) matrices \\(\\matr{A}\\) and \\(\\matr{B}\\),\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(\\matr{AB} \\ne \\matr{BA}\\)\r\n\t\t\\item \\((\\matr{AB})^2 \\ne \\matr{A}^2\\matr{B}^2\\)\r\n\t\t\\item \\(\\matr{AB} = 0 \\nRightarrow \\matr{A} = 0 \\lor \\matr{B} = 0\\)\r\n\t\t\\item \\(\\matr{A}^2 = I \\nRightarrow \\matr{A} = \\pm \\matr{I}\\) (For example: 2 EMs of 2nd type ERO)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Notes 5}\r\n\tWhen expanding a row/column with cofactors of the other row/column, 0 will be yielded:\r\n\t\\[\r\n\t    \\sum_{m=1}^n a_{im}A_{jm} = \\sum_{m=1}^n a_{mi}A_{mj} = 0, \\text{ for some } i \\ne j\r\n\t\\]\r\n\\end{namedthm*}\r\n\r\n\\section{Euclidean Spaces}\r\n\r\n\\begin{namedthm*}{Discussion 3.2.5}\r\n\tGiven \\(S = \\{\\vect{v_1}, \\vect{v_2}, \\dots, \\vect{v_m}\\} \\subseteq \\mathbb{R}^n\\}\\), show \\(\\lspan(S) = \\mathbb{R}^n\\):\r\n\t\r\n\t\\medskip\r\n\t\\noindent\r\n\tConsider \\(\\vect{v_i} = \\left(v_{i1}, \\dots, v_{in}\\right)\\),\r\n\t\\[\r\n\t\\begin{pmatrix}\r\n\t\\vect{v_{11}} & \\dots & \\vect{v_{m1}}\\\\\r\n\t\\vdots & \\ddots & \\vdots\\\\\r\n\t\\vect{v_{1n}} & \\dots & \\vect{v_{mn}}\r\n\t\\end{pmatrix} \\xrightarrow{GE} \\matr{R}\r\n\t\\]\r\n\t\\(\\lspan(S) = \\mathbb{R}^n \\Leftrightarrow \\matr{R}\\) has no zero rows\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 3.2.7}\r\n\tIf \\(|S| < n\\), \\(\\lspan(S) \\ne \\mathbb{R}^n\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 3.2.10}\r\n\tLet \\(S_1 = \\{\\vect{u_1}, \\dots, \\vect{u_k}\\}\\) and \\(S_2 = \\{\\vect{v_1}, \\dots, \\vect{v_m}\\}\\) be subsets of \\(\\mathbb{R}^n\\). Then, \\(\\lspan(S_1) \\subseteq \\lspan(S_2) \\Leftrightarrow \\forall i=1, 2, \\dots, k\\), \\(u_i \\in \\lspan\\{\\vect{v_1}, \\dots, \\vect{v_m}\\}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 3.3.2}\r\n     Let \\(V\\) be a subset of \\(\\mathbb{R}^n\\). Then \\(V\\) is called a \\textit{subspace} of \\(\\mathbb{R}^n\\) if \\(V = \\lspan(S)\\) where \\(S = \\{\\vect{u_1}, \\dots, \\vect{u_k}\\}\\) for some vectors \\(\\vect{u_1}, \\dots, \\vect{u_k} \\in \\mathbb{R}^n \\).\r\n     \r\n     \\medskip\r\n     \\noindent\r\n     More precisely, \\(V\\) is called the \\textit{subspace spanned} by \\(S\\) (or the \\textit{subspace spanned} by \\( \\vect{u_1}, \\dots, \\vect{u_k} \\)). We also say that \\(S\\) \\textit{spans} (or \\(\\vect{u_1}, \\dots, \\vect{u_k}\\) \\textit{span}) the subspace \\(V\\).\r\n     \r\n     \\medskip\r\n     \\noindent\r\n     By contraposition, \\(V = \\lspan(S) \\Rightarrow \\vect{0} \\in V \\equiv \\vect{0} \\notin V \\Rightarrow V \\ne \\lspan(S)\\). (\\(\\ast\\) i.e., If \\(\\vect{0}\\) is not in \\(V\\), \\(V\\) is not a subspace of \\(\\mathbb{R}^n\\))\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 3.3.6}\r\n\tIf \\(V = \\{\\matr{x} | \\matr{Ax} = \\matr{0}\\}\\), \\(V\\) is a subspace of \\(\\mathbb{R}^n\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 3.3.8}\r\n    Let \\(V\\) be a non-empty subset of \\(\\mathbb{R}^n\\). Then \\(V\\) is a subspace of \\(\\mathbb{R}^n\\) if and only if \r\n    \\[\r\n        \\text{for all } \\vect{u}, \\vect{v} \\in V \\text{ and } c, d\\in \\mathbb{R},\\enspace c\\vect{u} + d\\vect{v} \\in V\r\n    \\]\r\n    (\\(\\ast\\) This checks whether V is \\textbf{closed} under addition and scalar multiplication)\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 3.4.2/4}\r\n\tConsider \\(\\vect{u_1}, \\vect{u_2}, ..., \\vect{u_k}\\) which are column vectors, set \\(S = {\\vect{u_1}, \\vect{u_2}, ..., \\vect{u_k}}\\) is \\textbf{Linear Indepedent} iff. any of:\r\n\t\\begin{enumerate}\r\n\t\t% T3.4.2\r\n\t\t\\item \\((\\vect{u_1} \\vect{u_2} ... \\vect{u_k})\\vect{x} = \\matr{0}\\) has only trivial solution.\r\n\t\t% T3.4.4\r\n\t\t\\item No vectors in \\(S\\) can be written as a linear combination of other vectors in \\(S\\).\r\n\t\t% From revision note of tutor\r\n\t\t\\item \\(S\\) is a subset of a \\textbf{Linear Independent} set.\r\n\t\\end{enumerate}\r\n\\end{namedthm*} \r\n\r\n\\begin{namedthm*}{Definition 3.5.4/Theorem 3.6.7}\r\n\tA set \\(S\\) is a basis of a vector space if:\r\n\t\\begin{enumerate}[label*=\\arabic*.]\r\n\t\t\\item \\(S \\subseteq V\\)\r\n\t\t\\item Any 2 of the 3 below:\r\n\t\t\\begin{enumerate}[label*=\\arabic*.]\r\n\t\t\t\\item \\(S\\) is Linear Independent\r\n\t\t\t\\item \\(S\\) spans \\(V\\)\r\n\t\t\t\\item \\(|S| = \\dim(V)\\)\r\n\t\t\\end{enumerate}\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 3.5.8}\r\n\tLet \\(S = {\\vect{u_1}, \\vect{u_2}, ..., \\vect{u_k}}\\) be a basis for a vector space \\(V\\) and \\(\\vect{v}\\) is a vector in \\(V\\). By T3.5.7, \\(\\vect{v}\\) is expressed uniquely as a LC:\r\n\t\\[\r\n\t    \\vect{v} = c_1\\vect{u_1} + c_2\\vect{u_2} + \\dots + c_k\\vect{u_k}\r\n\t\\]\r\n\tThen we shall have the \\textbf{coordinate vector} of \\(\\vect{v}\\) relative to the basis \\(S\\) : \\((\\vect{v})_S = (c_1, c_2, \\dots, c_k) \\in \\mathbb{R}^k\\) (assuming vectors in \\(S\\) are in fixed order).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 3.5.10/Theorem 3.5.11}\r\n\tLet \\(S\\) be a basis for a vector space \\(V\\),\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(\\forall \\vect{u}, \\vect{v} \\in V, \\vect{u} = \\vect{v} \\Leftrightarrow (\\vect{u})_S = (\\vect{v})_S\\)\r\n\t\t\\item Coordinate vectors are closed under scalar multiplication and addition\r\n\t\t\\item Let \\(\\vect{v_1}, \\vect{v_2}, \\dots, \\vect{v_r} \\in V\\), they are LI iff. \\((\\vect{v_1})_S, (\\vect{v_2})_S, \\dots, (\\vect{v_k})_S\\) are LI\r\n\t\t\\item \\(\\lspan {\\vect{v_1}, \\vect{v_2}, \\dots, \\vect{v_r}} = V \\Leftrightarrow \\lspan {(\\vect{v_1})_S, (\\vect{v_2})_S, \\dots, (\\vect{v_k})_S} = \\mathbb{R}^{|S|}\\)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 3.6.9}\r\n\tLet \\(U\\) be a subspace of \\(V\\), then \\(\\dim(U) \\le \\dim(V)\\). Furthermore, if \\(U \\ne V\\), then \\(\\dim(U) < \\dim(V)\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 3.7.3}\r\n\tLet \\(S = {\\vect{u_1}, \\vect{u_2}, ..., \\vect{u_k}}\\) and \\(T\\) be two bases for a vector space. The square matrix \\(\\matr{P} =\\begin{pmatrix}{[\\vect{u_1}]}_T & {[\\vect{u_2}]}_T & \\dots & {[\\vect{u_k}]}_T\\end{pmatrix}\\) is called the \\textbf{transition matrix} from \\(S\\) to \\(T\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Theorem 6}\r\n\tConsider \\(S\\) and \\(T\\) are two bases for vector space \\(V\\) and \\(\\matr{P}\\) is the transition matrix from \\(S\\) to \\(T\\). If \\(\\matr{A}\\) and \\(\\matr{B}\\) are matrices with elements of \\(S\\) and \\(T\\) respectively as columns, we have \\(\\matr{BP} = \\matr{A}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Mixed Theorem 7}\r\n\tERO preserves row space \\textbf{(T4.1.7)}, and we have:\r\n\t\\begin{itemize}\r\n\t\t\\item \\textbf{(R4.1.9)} \\(\\matr{R}\\) is RREF of \\(\\matr{A}\\). Non-empty rows in \\(\\matr{R}\\) forms the basis of row space of \\(\\matr{A}\\).\r\n\t\t\\item \\textbf{(T4.2.1)} Row space and column space of a matrix have the same dimension.\r\n\t\\end{itemize}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 4.2.5}\r\n\tRegarding rank(\\(\\matr{A}\\)):\r\n\t\\begin{enumerate}\r\n\t\t\\item For \\(m * n\\) matrix \\(\\matr{A}\\), \\(\\rank(\\matr{A}) \\le \\min{m, n}\\). If \\(\\rank(\\matr{A}) = \\min{m, n}\\), \\(\\matr{A}\\) is said to have \\textbf{full rank}.\r\n\t\t\\item A square matrix \\(\\matr{A}\\) have full rank iff. it is invertible.\r\n\t\t\\item \\(\\rank(\\matr{A}) = \\rank(\\matr{A^T})\\).\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 4.3.6}\r\n\tSuppose linear system \\(\\matr{A}\\vect{x} = \\vect{b}\\) has solution \\(\\vect{v}\\), then the solution set of this system is given by:\r\n\t\\[\r\n\t    M = \\{ \\vect{u} + \\vect{v} | \\vect{u} \\in \\text{nullspace\\((\\matr{A})\\)}\\}\r\n\t\\]\r\n\\end{namedthm*}\r\n\r\n\\section{Orthogonality}\r\n\r\n\\begin{namedthm*}{Definition 5.1.2.3/4}\r\n\tFor two vectors \\(\\vect{u}\\) and \\(\\vect{v}\\):\r\n\t\r\n\t\\(d(\\vect{u}, \\vect{v}) = \\norm{\\vect{u} - \\vect{v}}\\).\r\n\t\r\n\tAngle between \\(\\vect{u}\\) and \\(\\vect{v}\\) is:\r\n\t\\[\r\n\t    \\cos^{-1}(\\frac{\\vect{u}\\cdot\\vect{v}}{\\norm{\\vect{u}}\\norm{\\vect{v}}})\r\n\t\\]\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.2.4}\r\n\tIf \\(S\\) is an orthogonal set of non-zero vectors in a vector space, \\(S\\) is \\textbf{LI}.\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.2.8}\r\n\tConsider \\(S = \\{\\vect{u_1}, \\vect{u_2}, \\dots, \\vect{u_k}\\}\\) is a basis for a vector space \\(V\\), then for any vector \\(\\vect{w}\\) in \\(V\\):\r\n\t\\begin{enumerate}\r\n\t\t\\item If \\(S\\) is orthogonal, we have\r\n\t\t\\[\r\n\t\t    (\\vect{w})_S = (\\frac{\\vect{w}\\cdot\\vect{u_1}}{\\vect{u_1}\\cdot\\vect{u_1}}\\vect{u_1}, \\frac{\\vect{w}\\cdot\\vect{u_2}}{\\vect{u_2}\\cdot\\vect{u_2}}\\vect{u_2}, \\dots, \\frac{\\vect{w}\\cdot\\vect{u_k}}{\\vect{u_k}\\cdot\\vect{u_k}}\\vect{u_k})\r\n\t\t\\]\r\n\t\t\\item If \\(S\\) is orthonomal, we have\r\n\t\t\\[\r\n\t\t    (\\vect{w})_S = (\\vect{w}\\cdot\\vect{u_1}, \\vect{w}\\cdot\\vect{u_2}, \\dots, \\vect{w}\\cdot\\vect{u_k})\r\n\t\t\\]\r\n\t\\end{enumerate}\r\n    \\textbf{T5.2.15}: \\((\\vect{w})_S\\) is the projection of \\(\\vect{w}\\) onto \\(V\\) if \\(\\vect{w} \\in \\mathbb{R}^n \\land V\\) is a subspace of \\(\\mathbb{R}^n\\) (condition of \\(\\vect{w}\\) changed but same formula applies).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.2.19 (Gram-Schmidt Process)}\r\n\tLet {\\(\\vect{u_1}, \\vect{u_2}, \\dots, \\vect{u_k}\\)} be a basis for a vector space \\(V\\). Let\r\n\t\\begin{gather*}\r\n\t    \\vect{v_1} = \\vect{u_1},\\\\\r\n\t    \\vect{v_2} = \\vect{u_2} - \\frac{\\vect{u_2}\\cdot\\vect{v_1}}{\\vect{v_1}\\cdot\\vect{v_1}}\\vect{v_1},\\\\\r\n\t    \\vect{u_3} = \\vect{u_3} - \\frac{\\vect{u_3}\\cdot\\vect{v_1}}{\\vect{v_1}\\cdot\\vect{v_1}}\\vect{v_1} - \\frac{\\vect{u_3}\\cdot\\vect{v_2}}{\\vect{v_2}\\cdot\\vect{v_2}}\\vect{v_2},\\\\\r\n\t    \\vdots\r\n\t\\end{gather*}\r\n\tThen {\\(\\vect{v_1}, \\vect{v_2}, \\dots, \\vect{v_k}\\)} is an orthogonal basis for \\(V\\). Normalize all vectors in it then we have a orthonormal basis for \\(V\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 5.3.6}\r\n\tLet \\(\\matr{A}\\vect{x} = \\vect{b}\\) be a linear system where \\(\\matr{A}\\) is an \\(m * n\\) matrix. A vector \\(\\vect{u} \\in \\mathbb{R}^n\\) is called a \\textbf{least squares solution} to the linear system if \\(\\forall \\vect{u} \\in \\mathbb{R}^n, \\norm{\\vect{b} - \\matr{A}\\vect{u}} \\le \\norm{\\vect{b} - \\matr{A}\\vect{v}}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.3.8}\r\n\tContinuing \\textbf{D5.3.6}, let \\(\\vect{p}\\) be the projection of \\(\\vect{b}\\) onto the column space of \\(\\matr{A}\\). \\(\\vect{u}\\) is the least squares solution iff. \\(\\matr{A}\\vect{u} = \\vect{p}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.3.10}\r\n\tContinuing \\textbf{D5.3.6}, \\(\\vect{u}\\) is the least squares solution iff. \\(\\vect{u}\\) is a solution to \\(\\matr{A}^T\\matr{A}\\vect{x} = \\matr{A}^T\\vect{b}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{D5.4.3/R5.4.4/T5.4.6}\r\n\t\\(\\matr{A}\\) is a square matrix of order \\(n\\). The following are equivalent:\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(\\matr{A}\\) is orthogonal\r\n\t\t\\item \\(\\matr{A}^{-1} = \\matr{A}^T\\)\r\n\t\t\\item \\(\\matr{A}\\matr{A}^T = \\matr{A}^T\\matr{A} = \\matr{I}\\)\r\n\t\t\\item The rows of \\(\\matr{A}\\) form an \\textbf{orthonormal} basis for \\(\\mathbb{R}^n\\)\r\n\t\t\\item The columns of \\(\\matr{A}\\) form an \\textbf{orthonormal} basis for \\(\\mathbb{R}^n\\)\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 5.4.7}\r\n\tLet \\(S\\) and \\(T\\) be two \\textbf{orthonormal} bases for a vector space and let \\(\\matr{P}\\) be the transition matrix from \\(S\\) to \\(T\\). Then \\(\\matr{P}\\) is orthogonal and \\(\\matr{P}^T\\) is the transition matrix from \\(T\\) to \\(S\\).\r\n\\end{namedthm*}\r\n\r\n\\section{Diagonalization}\r\n\r\n\\begin{namedthm*}{Definition 6.1.3}\r\n\t\\(\\matr{A}\\) is a square matrix of order \\(n\\). \\(\\vect{u} \\in \\mathbb{R}^n\\) is an non-zero column vector that satisfies:\r\n\t\\[\r\n\t    \\matr{A}\\vect{u} = \\lambda \\vect{u}\r\n\t\\]\r\n\tfor some scalar \\(\\lambda\\). \\(\\lambda\\) is called an \\textbf{eigenvalue} of \\(\\matr{A}\\). \\(\\vect{u}\\) is said to be an \\textbf{eigenvector} of \\(\\matr{A}\\) \\textbf{associated} with the eigenvalue \\(\\lambda\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 6.1.9}\r\n\tIf \\(\\matr{A}\\) is triangular, the eigenvalues of \\(\\matr{A}\\) are the diagonal entries of \\(\\matr{A}\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Remark 6.2.5}\r\n\tSuppose the characteristic polynomial of the matrix \\(\\matr{A}\\) can be factorized as\r\n\t\\[\r\n\t    \\det(\\lambda\\matr{I} - \\matr{A}) = (\\lambda - \\lambda_1)^{r_1}(\\lambda - \\lambda_2)^{r_2}\\dots(\\lambda - \\lambda_k)^{r_k}\r\n\t\\]\r\n\twhere \\(\\lambda_1, \\lambda_2, \\dots, \\lambda_k\\) are distinct eigenvalues of \\(\\matr{A}\\). Then for each eigenvalue \\(\\lambda_i\\), \r\n\t\\[\r\n\t    \\dim(E_{\\lambda_i}) \\le r_i\r\n\t\\]\r\n\tFurthermore, \\(\\matr{A}\\) is diagonalizable iff. \\(\\forall 1 \\le i \\le k, \\dim(E_{\\lambda_i}) = r_i\\).\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Definition 6.3.2/T*.4}\r\n\tA square matrix \\(\\matr{A}\\) is said to be orthogonally diagonalizable iff. there exists an orthogonal matrix \\(\\matr{P}\\) such that \\(\\matr{P}^T\\matr{A}\\matr{P}\\) is diagonal.\r\n\t\r\n\tA square matrix is orthogonally diagonalizable iff. it is \\textbf{symmetric}.\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Algorithm 6.3.5}\r\n\tSimilar to the process for the normal matrix, orthogonal matrix \\(\\matr{P}\\) can be found by using vectors of \\(T\\) as \\textbf{its columns} where \\(T = T_{\\lambda_1} \\cup T_{\\lambda_2} \\cup \\dots \\cup T_{\\lambda_k}\\) and \\(T_{\\lambda_i}\\) is transformed from \\(S_{\\lambda_1}\\) using Gram-Schmidt Process.\r\n\\end{namedthm*}\r\n\r\n\\section{Linear Transformation}\r\n\r\n\\begin{namedthm*}{Theorem 7.1.4}\r\n\tLet \\(T\\) be a linear transformation, we have:\r\n\t\\begin{enumerate}\r\n\t\t\\item \\(T(\\vect{0}) = \\vect{0}\\)\r\n\t\t\\item \\(T\\) is closed under scalar multiplication and addition\r\n\t\\end{enumerate}\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Discussion 7.1.8}\r\n\tLet \\(T: \\mathbb{R}^n \\rightarrow \\mathbb{R}^m\\) be a linear transformation with the standard matrix \\(\\matr{A}\\). Let \\(\\{\\vect{e_1}, \\vect{e_2}, \\dots, \\vect{e_n}\\}\\) be the standard basis for \\(\\mathbb{R}^n\\). We then have:\r\n    \\[\r\n        \\matr{A} = \r\n        \\begin{pmatrix}\r\n        T(\\vect{e_1}) & T(\\vect{e_2}) & \\dots & T(\\vect{e_n})\r\n        \\end{pmatrix}\r\n    \\]\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{Theorem 7.2.4}\r\n\tContinuing \\textbf{D7.1.8}. We have:\r\n\t\\[\r\n\t    R(T) = \\lspan\\{T(\\vect{e_1}), T(\\vect{e_2}), \\dots, T(\\vect{e_n})\\} = \\text{the column space of }\\vect{A}\r\n\t\\]\r\n\twhich is a subspace of \\(\\mathbb{R}^m\\)\r\n\\end{namedthm*}\r\n\r\n\\begin{namedthm*}{D7.2.5/T7.2.9/D7.2.10/T7.2.12}\r\n\tContinuing \\textbf{T7.2.4}. We have:\r\n\t\\begin{itemize}\r\n\t\t\\item \\(\\rank(T) = \\dim(R(T)) = \\rank(\\matr{A})\\)\r\n\t\t\\item \\(\\nullity(T) = \\nullity(\\matr{A})\\)\r\n\t\t\\item \\(\\rank(T) + \\nullity(T) = n\\)\r\n\t\t\\item \\(\\ker(T) = \\text{the nullspace of }\\matr{A}\\)\r\n\t\\end{itemize}\r\n\\end{namedthm*}\r\n\\end{justifying}\r\n\\end{multicols}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "921ecc1291ba47b79b6cf6b4746b3940a832484f", "size": 22560, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "AY1920S1/LaTeX Source/MA1101R Final.tex", "max_stars_repo_name": "fsgmhoward/NUSCheatsheets", "max_stars_repo_head_hexsha": "b3be41a8caa52a7f860626fd9129b3280ab54bdf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-07-30T14:34:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-09T06:26:10.000Z", "max_issues_repo_path": "AY1920S1/LaTeX Source/MA1101R Final.tex", "max_issues_repo_name": "fsgmhoward/NUSCheatsheets", "max_issues_repo_head_hexsha": "b3be41a8caa52a7f860626fd9129b3280ab54bdf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AY1920S1/LaTeX Source/MA1101R Final.tex", "max_forks_repo_name": "fsgmhoward/NUSCheatsheets", "max_forks_repo_head_hexsha": "b3be41a8caa52a7f860626fd9129b3280ab54bdf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.6955602537, "max_line_length": 411, "alphanum_fraction": 0.6033244681, "num_tokens": 9127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.41442474394620027}}
{"text": "\n\\subsection{Correctness}\n\nAn algorithm is correct if it produces the expected output for each input.\n\n\\subsection{Partial and total correctness}\n\nAn algorithm is only partially correct if may not terminate. Otherwise it is totally correct.\n\n", "meta": {"hexsha": "f4d2fd37c658205a184609a2dfa6cbc155756011", "size": 242, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/computer/algorithms/03-01-correctness.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/computer/algorithms/03-01-correctness.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/computer/algorithms/03-01-correctness.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.2, "max_line_length": 93, "alphanum_fraction": 0.805785124, "num_tokens": 46, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.41442474394620016}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{fullpage}\n\\usepackage{url}\n\\usepackage{color}\n\\usepackage{amsmath, amssymb, bm}\n\\usepackage{ulem}\n\\usepackage{framed}\n\\usepackage{xcolor}\n\n\\textheight=8.85in\n\n\\pagestyle{myheadings}\n\n\\setlength{\\tabcolsep}{0in}\n\\begin{document}\n\n\\thispagestyle {empty}\n\n\\newcommand{\\lsp}[1]{\\large\\renewcommand{\\baselinestretch}{#1}\\normalsize}\n\\newcommand{\\hsp}{\\hspace{.2in}}\n\\newcommand{\\comment}[1]{}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}{Lemma}[section]\n\\newtheorem{cor}{Corollary}[section]\n\\newtheorem{prop}{Proposition}[section]\n\\newtheorem{problem}{Problem}[section]\n\n\\newcommand{\\R}{{\\rm\\hbox{I\\kern-.15em R}}}\n\\newcommand{\\IR}{{\\rm\\hbox{I\\kern-.15em R}}}\n\\newcommand{\\IN}{{\\rm\\hbox{I\\kern-.15em N}}}\n\\newcommand{\\IZ}{{\\sf\\hbox{Z\\kern-.40em Z}}}\n\\newcommand{\\IS}{{\\rm\\hbox{S\\kern-.45em S}}}\n\\newcommand{\\Real}{I\\!\\!R}\n\n\\newcommand{\\bPhi}{\\bm{\\Phi}}\n\\newcommand{\\bphi}{\\bm{\\phi}}\n\\newcommand{\\bt}{\\mathbf{t}}\n\\newcommand{\\bw}{\\mathbf{w}}\n\\newcommand{\\bx}{\\mathbf{x}}\n\\newcommand{\\by}{\\mathbf{y}}\n\\newcommand{\\bX}{\\mathbf{X}}\n\\newcommand{\\bmm}{\\mathbf{m}}\n\\newcommand{\\bS}{\\mathbf{S}}\n\\newcommand{\\bL}{\\mathbf{L}}\n\\newcommand{\\bM}{\\mathbf{M}}\n\n\\newcommand{\\linesep}{\\vspace{.2cm}\\hrule\\vspace{0.2cm}}\n\\newcommand{\\categorysep}{\\vspace{0.5cm}}\n\\newcommand{\\entrysep}{\\vspace{0cm}}\n\n\\newcommand{\\category}[1]{\\categorysep\n                  \\noindent {\\bf \\large #1}\n              \\linesep}\n\n\\pagestyle{empty}\n\n\\begin{center}\n{\\large \\textbf{CSE 847 (Spring 2021): Machine Learning--- Homework 2}} \\\\\n Instructor: Jiayu Zhou \\quad\n Due on Wednesday, Feb 24 11:59 PM Easter Time. \\\\\n All submissions should be uploaded to D2L.\n\\end{center}\n\n\\section{Linear Algebra II}\n\n\\begin{enumerate}\n\\item (20 points) Compute (by hand) the eigenvalues and the eigenvectors of the following matrix:\n$$A = \\begin{pmatrix} 2 & 1 & 0 \\\\ 1 & 2& 0\\\\ 0 & 0 & 1 \\end{pmatrix}.$$\nFor the eigenvalues:\n\\begin{center}\n      $\\det[A - \\lambda \\mathbf{I} ] = 0$\\\\\n      $\\det[\\begin{pmatrix} 2-\\lambda & 1 & 0 \\\\ 1 & 2-\\lambda& 0\\\\ 0 & 0 & 1-\\lambda \\end{pmatrix}] = 0$\\\\\n      $(2-\\lambda)[(2-\\lambda)(1-\\lambda) - 0*0] - 1*[1*(1-\\lambda) - 0*0] + 0*[1*0 - 0*(2-\\lambda)] = 0$\\\\\n      $(2-\\lambda)[(2-\\lambda)(1-\\lambda)] - (1-\\lambda) = 0$\\\\\n      $3 - 7\\lambda + 5\\lambda^2 - \\lambda^3 = 0$\\\\\n      $-(x-3)(x-1)(x-1) = 0$\\\\\n      $\\lambda = 3, \\lambda = 1$ , with multiplicity of 2\\\\\n\\end{center}\nFor the eigenvectors. First, $\\lambda = 3$.\n\\begin{center}\n      $\\begin{pmatrix} -1 & 1 & 0 \\\\ 1 & -1 & 0\\\\ 0 & 0 & -2 \\end{pmatrix}  \\begin{pmatrix} u_1  \\\\ u_2 \\\\ u_3 \\end{pmatrix}= \\begin{pmatrix} 0  \\\\ 0 \\\\ 0 \\end{pmatrix}$\\\\\n      $-u_1 + u_2 = 0, u_1-u_2 = 0, -2u_3 = 0$\\\\\n      $u_1 = u_2 = 1, u_3 = 0$\\\\\n      Eigenvector for $\\lambda = 3 = \\begin{pmatrix} 1  \\\\ 1 \\\\ 0 \\end{pmatrix}$\n\\end{center}\nSecond and third for $\\lambda = 1$.\n\\begin{center}\n      $\\begin{pmatrix} 1 & 1 & 0 \\\\ 1 & 1 & 0\\\\ 0 & 0 & 0 \\end{pmatrix}  \\begin{pmatrix} u_1  \\\\ u_2 \\\\ u_3 \\end{pmatrix}= \\begin{pmatrix} 0  \\\\ 0 \\\\ 0 \\end{pmatrix}$\\\\\n      $u_1 + u_2 = 0, u_1+u_2 = 0, u_3 = ?$\\\\\n      $u_1 = -u_2 and u_2 = u_2 , u_3 = u_3$\\\\\n      Eigenvectors for $\\lambda = 1$ is the set $\\{ u_2*\\begin{pmatrix} -1  \\\\ 1 \\\\ 0 \\end{pmatrix} + u_3 *\\begin{pmatrix} 0 \\\\ 0 \\\\ 1 \\end{pmatrix} \\}$\n\\end{center}\n\\item Given the three vectors $v_1 = (2, 0, -1), v_2 = (0, -1, 0)$ and $v_3 = (2, 0, 4)$ in $\\mathbb R^3$.\n\\begin{itemize}\n\\item (10 points) Show that they form an orthogonal set under the standard \n      Euclidean inner product for $\\mathbb R^3$ but not an orthonormal set. \\\\\n      A) This means that each vector in the set must be perpendicular to each other, \n      i.e. $v_i^Tv_j = 0$, but they are not normalized, i.e. $\\left\\lVert v_i \\right\\rVert  \\neq 0$.\n      \\begin{center}\n            $v_1^Tv_2 = \\begin{pmatrix} 2  \\\\ 0 \\\\ -1 \\end{pmatrix} \\begin{pmatrix} 0 , -1, 0 \\end{pmatrix} = 2*0 + 0*-1 + 0*-1 = 0$\n            $v_2^Tv_3 = \\begin{pmatrix} 0  \\\\ -1 \\\\ 0 \\end{pmatrix} \\begin{pmatrix} 2 , 0, 4 \\end{pmatrix} = 2*0 + 0*-1 + 0*4 = 0$\n            $v_3^Tv_1 = \\begin{pmatrix} 2  \\\\ 0 \\\\ 4 \\end{pmatrix} \\begin{pmatrix} 2 , 0, -1 \\end{pmatrix} = 2*2 + 0*0 + -1*4 = 0$\n            $\\left\\lVert v_1 \\right\\rVert = \\sqrt{2^2 + 0^2 + (-1)^2 } = \\sqrt{5}$\n      \\end{center} \n      So, because the different combinations of the vectors in the set are perpendicular, they are orthogonal. But\n      because at least one of the set has a length greater than 1, then the set doesn't form an orthonormal basis.\n\\item (10 points) Turn them into a set of vectors that will form an orthonormal set of \n      vectors under the standard Euclidean inner product for $\\mathbb R^3$. \\\\\n      A) This means we need to normalize each of the vectors.\n      \\begin{center}\n            $\\left\\lVert v_1 \\right\\rVert = \\sqrt{2^2 + 0^2 + (-1)^2 } = \\sqrt{5} \\Rightarrow v_1 = ( \\frac{2\\sqrt{5}}{5}, 0, \\frac{-\\sqrt{5}}{5})$\n            $\\left\\lVert v_2 \\right\\rVert = \\sqrt{0^2 + (-1)^2 + 0^2 } = 1$\n            $\\left\\lVert v_3 \\right\\rVert = \\sqrt{2^2 + 0^2 + 4^2 } = 2\\sqrt{5}\\Rightarrow v_3 = ( \\frac{\\sqrt{5}}{5}, 0, \\frac{2\\sqrt{5}}{5})$\n      \\end{center}\n\\end{itemize}\n\n\\item (10 points) Suppose that $A$ is an $n \\times m$ matrix with linearly independent columns.\n      Show that $A^T A$ is an invertible matrix. \\\\\n      A) $A^T A$ creates a new $m \\times m$ matrix. In order to be invertible, the created matrix must be \n      non-singular, which means that the matrix must be a square, full-rank matrix. Because $A$ has linearly independent columns,\n      if the created matrix is linearly independent, then it will be full-rank and non-singular, thus invertible. \n      However, this means that linear independence must be transferable through multiplication of two, linearly independent \n      matrices. To show this, consider $(A^TA)x = 0$. Matrix multiplication is associative, so $A^T(Ax) = 0$. Let $(Ax) = y$, and\n      $A^Ty = 0$. Because $A^T$ is a linearly independent matrix, $A^Ty = 0$ only has the trivial solution of $y = 0$. Substituting\n      that into $(Ax) = y$, then $(Ax) = 0$, and because $A$ is linearly independent, the only trivial solution is $x = 0$. \n      This means that the combination $A^TAx=0$ has only the trivial solution where $x = 0$, and so, the create matrix is linearly\n      independent, non-singular, and therefore, invertible.\n\n\n\\item (10 points) Suppose that $A$ is an $n \\times m$ matrix with linearly independent columns.\n      Let $\\bar x$ be a least squares solution to the system of equations $Ax = b$ (the solution of $\\min_x \\|Ax - b\\|_2^2$).\n      Show that $\\bar x$ is the \\textbf{unique} solution to the associated normal system \n      $A^T A \\bar x = A^T b$. \\\\\n      A) For this question, we know that $\\bar x$ is the least squares solution to the system of equations $Ax = b$. In order for \n      the least squares to be associated with the normal system, we need to show that the gradient of the least squares equation\n      results in the normal system, and then, we can show uniqueness through the fact that $A^TA$ is non-singular and invertible, \n      as discussed above. First, let's derive that normal system from the least squares equation:\n      \\begin{center}\n           $\\frac{1}{2}\\|Ax - b\\|_2^2$ \\\\\n           $\\frac{\\partial }{\\partial x_{j_0}} (\\sum_{j=1}^{n} A_{ij}x_j - b_i )^2$ Definition of least squares in element form for one element\\\\\n           $2A_{ij_0}(\\sum_{j=1}^{n} A_{ij}x_j - b_i )$ \\\\\n           $\\sum_{i=1}^{n}A_{ij_0}(\\sum_{j=1}^{n} A_{ij}x_j - b_i )$ Sum across all the elements for least squares \\\\\n           $A^T(Ax - b)$ Back to matrix notation \\\\\n           $A^TAx = A^Tb)$ Distribute and set equal \\\\\n      \\end{center}\n      So, the gradient of the least squares is the normal system, and so any value $\\bar x$ that solves the least\n      squares solves the normal system and vice versa. To ensure that the solution is unique, we must ask when \n      a solution is unique. We know this happens when $A^TA$ is non-singular, and so, because we know from the\n      previous problem that $A^TA$ is non-singular, we can say that this solution is unique.\n\n\\end{enumerate}\n\n\n\\section{Linear Regression I} \n\nQuestions in the textbook Pattern Recognition and Machine Learning:\n\\begin{enumerate}\n\\item (10 points) Page 174, Question 3.2 \\\\\nA) Let $w$ be some vector in the column space of $\\Phi$, and $w = \\Phi v$. Then, the projection $Pw$ is\n\\begin{center}\n      $Pw = \\Phi (\\Phi^T\\Phi)^{-1}\\Phi^T (\\Phi v)$\\\\\n      $\\Phi (\\Phi^T\\Phi)^{-1}(\\Phi^T \\Phi v)$\\\\\n      $\\Phi v = w$ Canceling like terms\n\\end{center}\nThis means that $\\Phi (\\Phi^T\\Phi)^{-1}\\Phi^T$ can take any vector an project it onto the column space of $\\Phi$.\nSimilarly, for least squares, the optimal position for the least squares equation is the projection closest to $t$.\nLet $t = t_\\Phi + t_{\\Phi \\perp}$ be the orthogonal decomposition with respect to space $\\mathbb{S}$. By definition,\nwe know that $t_\\Phi$ lies in the space $\\mathbb{S}$ and there is a coresponding vector $\\Phi y$ in $\\mathbb{S}$ where\n$\\Phi y = t_\\Phi$ (the projection). We can then say that $t - t_\\Phi = t - \\Phi y = x_{\\Phi \\perp}$ (subbing it into the first equation),\nwhich lies in the space $\\mathbb{S}^\\perp$. Note that the $Col(\\Phi)^perp = Nul(\\Phi^T)$, which means we can say that \n$0 = \\Phi^T(t - \\Phi y) \\Rightarrow \\Phi^T t - \\Phi^T \\Phi y$. Switching some things around, we can see that \n$y = (\\Phi^T \\Phi)^{-1}\\Phi^T t$, or the orthogonal projection of $t$.\n\n\\item (10 points) Page 175, Question 3.7\nFrom the hint, we know from Bayes' theorem that\n$$\np(\\bw | \\bt) \\propto p(\\bt | \\bw) p(\\bw)\n$$\nwhere the factors on the r.h.s are given by (3.10) and (3.48), respectively. \n\\begin{align*}\np(\\bt | \\mathbf X, \\bw, \\beta ) &= \\prod_{n=1}^N \\mathcal N (t_n | \\bw^T \\bphi(\\bx_n), \\beta^{-1} )  \\tag {3.10}\\\\\np(\\bw) &= \\mathcal N (\\bw| \\mathbf m_0, \\bS_0) \\tag {3.48}\n\\end{align*}\nthen plugin: \n\\begin{align*}\np(\\bw | \\bt) \n&\\propto \n{\\color{black}\\left[ \\prod_{n=1}^N \\mathcal N(t_n | \\bw^T \\bphi(\\bx_n), \\beta^{-1}) \\right]}\n{\\color{black}\\mathcal N (\\bw | \\mathbf m_0, \\bS_0)}\\\\\n&\\propto \n{\\color{black}\\exp\\left( -\\frac{\\beta}{2} (\\bt - \\bPhi \\bw)^T (\\bt - \\bPhi \\bw) \\right) }\n{\\color{black}\\exp\\left( -\\frac{1}{2}(\\bw - \\mathbf m_0)^T \\bS_0^{-1} (\\bw - \\mathbf m_0) \\right)}\n\\end{align*}\nAnd then, we can expand out the equations and combine like terms. \n\\begin{align*}\n{\\color{black}\\exp\\left( -\\frac{\\beta}{2} (\\bt^T - \\bPhi^T \\bw^T) (\\bt - \\bPhi \\bw) -\\frac{1}{2}(\\bw^T - \\mathbf m_0^T) \\bS_0^{-1} (\\bw - \\mathbf m_0) \\right)}\\\\\n{\\color{black}\\exp\\left( -\\frac{\\beta}{2} (\\bt^T \\bt - 2\\bt^T \\bPhi \\bw + \\bw^T \\bPhi^T \\bPhi \\bw) -\\frac{1}{2}(\\bS_0^{-1} \\bw^T \\bw - 2\\bS_0^{-1} \\mathbf m_0^T \\bw + \\bS_0^{-1} \\mathbf m_0^T \\mathbf m_0) \\right)}\\\\\n{\\color{black}\\exp\\left( -\\frac{1}{2} ( \\bw^T( \\bS_0^{-1} + \\beta \\bPhi^T \\bPhi)\\bw  - 2 \\bw( \\bS_0^{-1} \\mathbf m_0^T + \\beta \\bt^T \\bPhi ) + (\\beta \\bt^T \\bt + \\bS_0^{-1} \\mathbf m_0^T \\mathbf m_0) \\right)}\\\\\n\\end{align*}\nFinally, we have to complete the square. First, we start with the initial term, which turns out to be our $\\bS_N^{-1}$.\nThen, we need to select our new $\\bM_N$. There are some additional parameters $C$, but those can be ignored as we will have shown\nthat this is proportional to (3.49).\n\\begin{align*}\n\\bS_N^{-1} &= \\bS_0^{-1} + \\beta \\bPhi^T \\bPhi \\\\\n\\bM_N &= \\bS_N( \\bS_0^{-1} \\mathbf m_0 + \\beta \\bt \\bPhi^T )\\\\\n{\\color{black}\\exp\\left( -\\frac{1}{2} (w - \\bM_N)^T \\bS_N (w - \\bM_N) + C\\right)}\\\\\n\\end{align*}\nFrom this, you can see that the different equations are proportional.\n\n\\item (10 points) Page 175, Question 3.10\nWith the help of the hint, we can use (3.3), (3.8) and (3.49),\n\\begin{align*}\ny(\\bx, \\bw) &= \\bw^T \\bphi(\\bx) \\tag{3.3}\\\\\np(t|\\bx, \\bw, \\beta) &= \\mathcal N (t|y(\\bx, \\bw), \\beta^{-1}) \\tag{3.8}\\\\\np(\\bw | \\bt) &= \\mathcal N(\\bw | \\bmm_N, \\bS_N) \\tag{3.49}\n\\end{align*}\nwe can re-write (3.57) as\n\\begin{align*}\np(t|\\bx, \\bt, \\alpha, \\beta) \n&= \\int p(t| \\bx, \\bw, \\beta) p(\\bw | \\bt, \\alpha, \\beta) d \\bw\n= \\int \\mathcal N (t | \\bphi(\\bx)^T \\bw, \\beta^{-1}) \n\\mathcal N (\\bw | \\bmm_N, \\bS_N) d \\bw \n\\end{align*}\nFrom here, we can see that the first factor of the integrand in rewritten equation is equivalent to the more \ngeneric form described in (2.114):\n\\begin{align*}\n      p(\\mathbf y | \\bx) = \\mathcal N (\\by | \\mathbf A \\bx + \\mathbf b, \\mathbf L^{-1}) \\tag{2.114}\n\\end{align*}\nwhere $Ax+b = \\bw^T \\phi x$ and the precision matrix $\\mathbf L^{-1} = \\beta^{-1}$, or the inverse covariance matrix. \nWe can then also update the second factor with the more generic form of the distribution described in (2.113):\n\\begin{align*}\n      p(\\bx)             = \\mathcal N (\\bx | \\bm{\\mu}, \\bm \\Lambda^{-1}) \\tag{2.113}\\\\\n\\end{align*}\nwhere $\\mu = \\bmm_N$, or the mean of the distribution is equivalent to mean of the posterior and $\\Lambda^{-1} = \\bS_N$\nor the precision is equal to the covariance of the posterior. In form below:\n\\begin{align*}\n   \\int \\mathcal N (y | Ax+b, \\bL^{-1}) \n      \\mathcal N (x | \\mu, \\Lambda^{-1}) d \\bx    \n\\end{align*}\nPulling everything together, we can apply the Bayesian process described in 2.3.3 and the mean and covariance of \nthe distribution $p(y)$ (2.109 and 2.110) to create equivalent of (2.115).\n\\begin{align*}\n   \\int \\mathcal N (y | Ax+b, \\bL^{-1}) \n      \\mathcal N (x | \\mu, \\Lambda^{-1}) d \\bx = \\mathcal N (y | \\mathbb{E} [y], COV[y]) =\n      \\mathcal N (y | \\mathbf{A}\\mu + b, \\bL^{-1} + \\mathbf{A} \\Lambda^{-1} \\mathbf{A}^T)\n\\end{align*}\n\n\n\\item (10 points) Page 175, Question 3.11\nWe can show this by looking at functions, (3.59) and (3.54), after both are adjusted for the next iteration (Thanks hint!). \nThe two functions are below:\n\\begin{align*}\n      \\bS_{N+1}^{-1} &= \\bS_N^{-1} + \\beta \\bphi_{N+1} \\bphi_{N+1}^T. \\tag{3.54}\\\\\n      \\sigma_{N+1}^2 (\\bx) &= \\frac{1}{\\beta} + \\bphi(\\bx)^T \\bS_{N+1} \\bphi(\\bx) \\tag{3.59}\n\\end{align*}\nWe can then substitute (3.54) into (3.59) and simplify to show the relation between $\\sigma_{N+1}^2 (\\bx)$ and $\\sigma_{N}^2 (\\bx)$.\nAfter we substitute $\\bS_{N+1}^{-1}$, we can use (3.110) to help with the simplification. Finally, we distribute $\\bphi(\\bx)$\nto finish creating the relation.\n\\begin{align*}\n      \\sigma_{N+1}^2 (\\bx) = \\frac{1}{\\beta} + \\bphi(\\bx)^T \\bS_{N+1} \\bphi(\\bx)\\\\\n      \\frac{1}{\\beta} + \\bphi(\\bx)^T (\\bS_{N}^{-1} + \\beta \\bphi_{N+1}(\\bx) \\bphi_{N+1}(\\bx)^T)^{-1} \\bphi(\\bx)\\\\\n      \\frac{1}{\\beta} + \\bphi(\\bx)^T (\\bS_{N} - \\frac{(\\bS_{N} \\beta \\bphi_{N+1}(\\bx))(\\bphi_{N+1}(\\bx)^T \\bS_{N})}\n      {1+\\bphi_{N+1}(\\bx)^T\\bS_{N}\\beta \\bphi_{N+1}(\\bx)}) \\bphi(\\bx)\\\\\n      \\frac{1}{\\beta} + \\bphi(\\bx)^T \\bS_{N} \\bphi(\\bx) - \\bphi(\\bx) \\frac{(\\bS_{N} \\beta \\bphi_{N+1}(\\bx))(\\bphi_{N+1}(\\bx)^T \\bS_{N})}\n      {1+\\bphi_{N+1}(\\bx)^T\\bS_{N}\\beta \\bphi_{N+1}(\\bx)}\\\\\n      \\sigma_{N+1}^2 (\\bx) \\leq \\sigma_{N}^2 (\\bx) - \\bphi(\\bx) \\frac{(\\bS_{N} \\beta \\bphi_{N+1}(\\bx))(\\bphi_{N+1}(\\bx)^T \\bS_{N})}\n      {1+\\bphi_{N+1}(\\bx)^T\\bS_{N}\\beta \\bphi_{N+1}(\\bx)}\n\\end{align*}\nSo, because the next iteration reduces the current iteration, the next iteration will always be smaller than the current.\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "888daae7e626e1fb1addb8a9aacdcd2584fc588d", "size": 15180, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW2/CSE847-Homework2.tex", "max_stars_repo_name": "Sheepybloke2-0/CSE847_HW", "max_stars_repo_head_hexsha": "00d8a835d6dc08246e1d2751732486ba5a3c00f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW2/CSE847-Homework2.tex", "max_issues_repo_name": "Sheepybloke2-0/CSE847_HW", "max_issues_repo_head_hexsha": "00d8a835d6dc08246e1d2751732486ba5a3c00f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW2/CSE847-Homework2.tex", "max_forks_repo_name": "Sheepybloke2-0/CSE847_HW", "max_forks_repo_head_hexsha": "00d8a835d6dc08246e1d2751732486ba5a3c00f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.6043956044, "max_line_length": 215, "alphanum_fraction": 0.6192358366, "num_tokens": 5788, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4144247365172914}}
{"text": "%% LyX 2.2.3 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[12pt,english]{article}\n\\usepackage{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage[a4paper]{geometry}\n\\geometry{verbose,tmargin=1.5cm,bmargin=1.5cm,lmargin=1.5cm,rmargin=1.5cm,headheight=1.5cm,headsep=1.5cm,footskip=1.5cm}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\n\\makeatletter\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.\n%% Because html converters don't know tabularnewline\n\\providecommand{\\tabularnewline}{\\\\}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{lmodern}\n\\usepackage[T1]{fontenc}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\n\\title{EE6132: Deep Learning for Image Processing}\n\n\\author{\\textbf{Assignment 1: MNIST Classification using Multilayer Perceptron}}\n\n\\date{Adarsh B (MM14B001)}\n\n\\maketitle\n\\newpage{}\n\n\\tableofcontents{}\n\n\\newpage{}\n\n\\section{Overview}\n\nFollowing is a pictorial description of the Multilayer Perceptron\nmodel used for training and classifying on MNIST data:\n\\begin{center}\n\\includegraphics[width=16cm]{/home/adarsh/mlp}\n\\par\\end{center}\n\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \nMinibatch size & 64\\tabularnewline\n\\hline \nRegularization & l2\\tabularnewline\n\\hline \nRegularization parameter ($\\lambda$) & 0.005\\tabularnewline\n\\hline \nNo. of training iterations & 8000\\tabularnewline\n\\hline \nUpdate algorithm & SGD with Momentum acceleration\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\n\\rule[0.5ex]{0.9\\columnwidth}{1pt}\n\n\\bigskip{}\n\n\\section{Submissions}\n\n\\subsection{Backpropagation equations}\n\nFeedforwarding in the neural network takes place as follows (f can\nbe ReLU or sigmoid):\n\n\\begin{align*}\na_{i}^{1} & =x_{i}\\\\\nz_{i}^{2} & =(w_{ij}^{1}a_{j}^{1}+b_{i}^{1})\\\\\na_{i}^{2} & =f(z_{i}^{2})\\\\\nz_{i}^{3} & =(w_{ij}^{2}a_{j}^{2}+b_{i}^{2})\\\\\na_{i}^{3} & =f(z_{i}^{3})\\\\\nz_{i}^{4} & =(w_{ij}^{3}a_{j}^{3}+b_{i}^{3})\\\\\na_{i}^{4} & =f(z_{i}^{4})\\\\\nz_{i}^{5} & =w_{ij}^{4}a_{j}^{4}+b_{i}^{4}\\\\\na_{i}^{5} & =linear(z_{i}^{2})\\\\\n\\hat{y}_{i} & =softmax(a_{i}^{5})\n\\end{align*}\n\nFor taking momentum into account, we initialize $v^{i}$ and $u^{i}$\nas the velocity terms for $w^{i}$ and $b^{i}$ respectively. $\\text{\\ensuremath{\\delta}}^{i}$\nis the error derivative with respect to $a^{i}$. \\ensuremath{\\alpha}\nis the learning rate, $\\lambda$ is the regularization parameter,\nand \\ensuremath{\\mu} is the momentum parameter.\n\n\\bigskip{}\n\n\\noindent \\textbf{Final layer:}\n\n\\noindent Since we are using cross-entropy as the loss function, the\nderivative for cross entropy loss with respect to the final activation\ncan be evaluated as:\n\n\\begin{align*}\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}z_{i}^{5}} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}\\hat{y}_{i}}\\frac{\\text{\\ensuremath{\\partial}}\\hat{y}_{i}}{\\text{\\ensuremath{\\partial}}z_{i}^{5}}\\\\\n & =-\\frac{(y_{i}-\\hat{y_{i}})}{\\hat{y_{i}}(1-\\hat{y}_{i})}\\hat{y_{i}}(1-\\hat{y}_{i})\\\\\n & =\\boldsymbol{(\\hat{y_{i}}-y_{i})}\n\\end{align*}\n\n\\noindent \n\\begin{align*}\n\\text{\\ensuremath{\\delta}}_{i}^{5} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}z_{i}^{5}}\\\\\n & =(\\hat{y_{i}}-y_{i})\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{4}} & =\\text{\\ensuremath{\\delta}}_{i}^{5}\\frac{\\text{\\ensuremath{\\partial}}z_{i}^{5}}{\\text{\\ensuremath{\\partial}}w_{ij}^{4}}\\\\\n & =\\boldsymbol{(\\hat{y_{i}}-y_{i})a_{j}^{4}+\\lambda w_{ij}^{4}}\\\\\nv_{ij}^{4} & =\\text{\\ensuremath{\\mu}}v_{ij}^{4}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{4}}\\\\\nw_{ij}^{4} & =\\boldsymbol{w_{ij}^{4}+v_{ij}^{4}}\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{4}} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}z_{i}^{5}}\\frac{\\text{\\ensuremath{\\partial}}z_{i}^{5}}{\\text{\\ensuremath{\\partial}}b_{i}^{4}}\\\\\n & =\\boldsymbol{(\\hat{y_{i}}-y_{i})}\\\\\nu_{i}^{4} & =\\text{\\ensuremath{\\mu}}u_{ij}^{4}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{4}}\\\\\nb_{i}^{4} & =\\boldsymbol{b_{i}^{4}+u_{i}^{4}}\n\\end{align*}\n\n\\noindent \\textbf{Hidden layer 3:}\n\\begin{align*}\n\\text{\\ensuremath{\\delta}}_{i}^{4} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{4}}\\\\\n & =(\\text{\\ensuremath{\\delta}}_{j}^{5}w_{ji}^{4})f'(z_{i}^{4})\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{3}} & =\\text{\\ensuremath{\\delta}}_{i}^{4}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{4}}{\\text{\\ensuremath{\\partial}}w_{ij}^{3}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{5}w_{ji}^{4})f'(z_{i}^{4}))a_{j}^{3}+\\lambda w_{ij}^{3}}\\\\\nv_{ij}^{3} & =\\text{\\ensuremath{\\mu}}v_{ij}^{3}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{3}}\\\\\nw_{ij}^{3} & =\\boldsymbol{w_{ij}^{3}+v_{ij}^{3}}\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{4}} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{5}}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{5}}{\\text{\\ensuremath{\\partial}}b_{i}^{4}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{5}w_{ji}^{4})f'(z_{i}^{4}))}\\\\\nu_{i}^{3} & =\\text{\\ensuremath{\\mu}}u_{ij}^{3}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{3}}\\\\\nb_{i}^{3} & =\\boldsymbol{b_{i}^{3}+u_{i}^{3}}\n\\end{align*}\n\n\\noindent \\textbf{Hidden layer 2:}\n\\begin{align*}\n\\text{\\ensuremath{\\delta}}_{i}^{3} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{3}}\\\\\n & =(\\text{\\ensuremath{\\delta}}_{j}^{4}w_{ji}^{3})f'(z_{i}^{3})\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{2}} & =\\text{\\ensuremath{\\delta}}_{i}^{3}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{3}}{\\text{\\ensuremath{\\partial}}w_{ij}^{2}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{4}w_{ji}^{3})f'(z_{i}^{3}))a_{j}^{2}+\\lambda w_{ij}^{2}}\\\\\nv_{ij}^{2} & =\\text{\\ensuremath{\\mu}}v_{ij}^{2}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{2}}\\\\\nw_{ij}^{2} & =\\boldsymbol{w_{ij}^{2}+v_{ij}^{2}}\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{3}} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{4}}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{4}}{\\text{\\ensuremath{\\partial}}b_{i}^{3}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{4}w_{ji}^{3})f'(z_{i}^{3}))}\\\\\nu_{i}^{2} & =\\text{\\ensuremath{\\mu}}u_{ij}^{2}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{2}}\\\\\nb_{i}^{2} & =\\boldsymbol{b_{i}^{2}+u_{i}^{2}}\n\\end{align*}\n\\textbf{Hidden layer 1:}\n\\begin{align*}\n\\text{\\ensuremath{\\delta}}_{i}^{2} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{2}}\\\\\n & =(\\text{\\ensuremath{\\delta}}_{j}^{3}w_{ji}^{2})f'(z_{i}^{2})\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{1}} & =\\text{\\ensuremath{\\delta}}_{i}^{2}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{2}}{\\text{\\ensuremath{\\partial}}w_{ij}^{1}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{3}w_{ji}^{2})f'(z_{i}^{2}))a_{j}^{1}+\\lambda w_{ij}^{1}}\\\\\nv_{ij}^{1} & =\\text{\\ensuremath{\\mu}}v_{ij}^{1}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}w_{ij}^{1}}\\\\\nw_{ij}^{1} & =\\boldsymbol{w_{ij}^{1}+v_{ij}^{1}}\\\\\n\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{2}} & =\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}a_{i}^{3}}\\frac{\\text{\\ensuremath{\\partial}}a_{i}^{3}}{\\text{\\ensuremath{\\partial}}b_{i}^{2}}\\\\\n & =\\boldsymbol{((\\text{\\ensuremath{\\delta}}_{j}^{3}w_{ji}^{2})f'(z_{i}^{2}))}\\\\\nu_{i}^{1} & =\\text{\\ensuremath{\\mu}}u_{ij}^{1}-\\text{\\ensuremath{\\alpha}}\\frac{\\text{\\ensuremath{\\partial}}E}{\\text{\\ensuremath{\\partial}}b_{i}^{1}}\\\\\nb_{i}^{1} & =\\boldsymbol{b_{i}^{1}+u_{i}^{1}}\n\\end{align*}\n\n\\pagebreak{}\n\n\\subsection{Learning curve plots}\n\nFollowing is the plot of train and test loss vs iterations for a network\nwith Sigmoid activations:\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_test_loss_sigmoid_1e-2}\n\\par\\end{center}\n\nFollowing plots show the comparison of loss evolution between different\nlearning rates:\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_loss_sigmoid_lr_comparison}\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/test_loss_sigmoid_lr_comparison}\n\\par\\end{center}\n\nThe test accuracies for various cases is tabulated as shown. Clearly,\nit can be observed that convergence is faster in case of higher learning\nrates.\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{alpha} & \\textbf{Accuracy}\\tabularnewline\n\\hline \n\\hline \n1e-2 & 94.89\\%\\tabularnewline\n\\hline \n1e-3 & 90.49\\%\\tabularnewline\n\\hline \n1e-4 & 84.36\\%\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\n\\pagebreak{}\n\n\\subsection{Learning rate scheduling}\n\nLearning rate has been decayed by a factor of 0.85 for every 250 iterations.\nThe comparison between scheduled and unscheduled learning rates is\nturned in below:\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_loss_sigmoid_decay_comparison}\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/test_loss_sigmoid_decay_comparison}\n\\par\\end{center}\n\nThe accuracies obtained in both the cases are tabulated bwlow:\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \nExperiment & Accuracy\\tabularnewline\n\\hline \n\\hline \nConstant learning rate & 94.89\\%\\tabularnewline\n\\hline \nScheduled learning rate & 90.60\\%\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\nDespite having a lower accuracy in case of scheduled learning rate,\nthe convergence is smooth. With a high fixed learning rate, the system\ncan be thought of having too much \\textbf{kinetic energy} and the\nparameters oscillate around rapidly, unable to settle down into deeper,\nbut narrower parts of the loss function. This can be seen in the unsteady\ngreen line from the test loss plot. Sometimes, the loss function sometimes\ncan even get stagnated at a particular value. But with a decaying\nlearning rate, \\textbf{deeper} along with \\textbf{smoother convergence}\nover long iterations helps the network to learn better. \n\n\\subsection{Experimenting with ReLU activation function}\n\nFollowing is the plot of train and test loss vs iterations for a network\nwith ReLU activations:\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_test_loss_relu_1e-2}\n\\par\\end{center}\n\n\\pagebreak{}\n\nFollowing plots show the comparison of loss evolution between different\nlearning rates:\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_loss_relu_lr_comparison}\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/test_loss_relu_lr_comparison}\n\\par\\end{center}\n\nThe test accuracies for various cases is tabulated as shown. Again,\nit can be observed that convergence is faster in case of higher learning\nrates.\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{alpha} & \\textbf{Accuracy}\\tabularnewline\n\\hline \n\\hline \n1e-2 & 97.79\\%\\tabularnewline\n\\hline \n1e-3 & 96.87\\%\\tabularnewline\n\\hline \n1e-4 & 94.28\\%\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\n\\noindent \\textbf{Comparison between ReLU and Sigmoid:}\n\nFollowing plots depict the convergence comparison between ReLU and\nsigmoid activations for alpha=1e-2.\n\\begin{center}\n\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/train_sigmoid_relu_comparison}\\includegraphics[width=9cm]{/home/adarsh/PA1_MM14B001/outputs/test_sigmoid_relu_comparison}\n\\par\\end{center}\n\nClearly, ReLU converges faster as compared to sigmoid activation.\nTest accuracies are also higher for ReLU than sigmoid (97.79\\% for\nReLU and 94.89\\% for Sigmoid).\n\n\\subsection{Sample predictions}\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{Sigmoid} & \\textbf{ReLU}\\tabularnewline\n\\hline \n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_1} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_1}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_2} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_2}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_3} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_3}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_4} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_4}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_5} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_5}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_6} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_6}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_7} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_7}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_8} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_8}\\tabularnewline\n\\hline \n\\end{tabular}%\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{Sigmoid} & \\textbf{ReLU}\\tabularnewline\n\\hline \n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_9} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_9}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_10} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_10}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_11} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_11}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_12} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_12}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_13} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_13}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_14} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_14}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_15} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_15}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_16} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_16}\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\n\\begin{center}\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{Sigmoid} & \\textbf{ReLU}\\tabularnewline\n\\hline \n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_17} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_17}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_18} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_18}\\tabularnewline\n\\hline \n\\end{tabular}%\n\\begin{tabular}{|c|c|}\n\\hline \n\\textbf{Sigmoid} & \\textbf{ReLU}\\tabularnewline\n\\hline \n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_19} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_19}\\tabularnewline\n\\hline \n\\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/sigmoid/sample_20} & \\includegraphics[width=4cm]{/home/adarsh/PA1_MM14B001/outputs/relu/sample_20}\\tabularnewline\n\\hline \n\\end{tabular}\n\\par\\end{center}\n\\end{document}\n", "meta": {"hexsha": "1f7ecf2752a203f97185166b09e8299fbf601f30", "size": 16175, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PA1/report/report.tex", "max_stars_repo_name": "badarsh2/EE6132-Deep-Learning-For-Imaging-Assignments", "max_stars_repo_head_hexsha": "f2485bb2f0c17ebddd4acd176a8c6aa8ace6439a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-20T09:36:36.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-20T09:36:36.000Z", "max_issues_repo_path": "PA1/report/report.tex", "max_issues_repo_name": "badarsh2/EE6132-Deep-Learning-For-Imaging-Assignments", "max_issues_repo_head_hexsha": "f2485bb2f0c17ebddd4acd176a8c6aa8ace6439a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PA1/report/report.tex", "max_forks_repo_name": "badarsh2/EE6132-Deep-Learning-For-Imaging-Assignments", "max_forks_repo_head_hexsha": "f2485bb2f0c17ebddd4acd176a8c6aa8ace6439a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.3467048711, "max_line_length": 243, "alphanum_fraction": 0.7198763524, "num_tokens": 5895, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565327, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.4144130040344288}}
{"text": "\\documentclass{article} \n\n\\usepackage[UKenglish]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[all]{xy}\n\n\\usepackage{url}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\n\\usepackage{enumerate}\n\\usepackage{url}\n\\usepackage{algorithmic}\n\\usepackage{algorithm}\n\n\\include{macros}\n\n\\usepackage{natbib}\n\\setlength{\\bibsep}{1.75pt}\n\\usepackage{array}\n\n\\title{Cyclic factorization of complete graphs into spanning trees with an Euler trail}\n\\author{Alex Horn}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nA simple graph algorithm is presented which decomposes an $n$-complete graph of even order into edge-disjoint, isomorphic copies of a spanning tree whose edges form an Euler trail of length $n-1$. While more general methods of such spanning tree factorizations have been known, we emphasize here its simple algorithmic treatment with an efficient data structure.\n\\end{abstract}\n\n\\section{Introduction} \n\nThis document is written mainly for fun and it concerns a graph decomposition algorithm which computes the cyclic spanning tree factorization of complete graphs of even order. This algorithm could find application in ad hoc network designs in which link failures need to be restored quickly by creating a new isomorphic yet link-disjoint network structure.\n\nWe consider only simple and finite graphs. Let $G$ be such a graph. A \\define{decomposition} of $G$ is a set of pairwise edge-disjoint subgraphs $H_1, H_2, \\ldots H_k$ such that every edge of $G$ belongs to exactly one subgraph $H_i$ for $1 \\leq i \\leq k$. If every such subgraph is isomorphic to a graph $H$, then $G$ is said to have an \\define{$H$-decomposition}. An $H$-decomposition into $H_1, H_2, \\ldots H_k$ is called \\define{cyclic} if there exists an ordering $(x_1, x_2, \\ldots, x_n)$ of the vertices of $G$ together with graph isomorphisms $\\phi_i : H_1 \\to H_i$, for all $1 < i \\leq k$, such that $\\phi_i(x_j) = x_{(i+j) \\bmod n}$ for all $1 \\leq j \\leq n$. If $H$ has the same order as $G$ and none of the vertices in $H$ are isolated, then $H$ is a connected factor and the decomposition is called an \\define{$H$-factorization}. In particular, if $H$ is a spanning tree, we say that graph $G$ has a \\define{spanning tree factorization}. Figure~\\ref{fig:cyclic-decomposition} (p.~\\pageref{fig:cyclic-decomposition}) shows cyclic decompositions of the $6$-complete graph and $8$-complete graph which can be verified by ``rotating'' the subgraphs twice. Note that only the centre and most right decompositions are spanning tree factorizations.\n\n\\begin{figure}[t]\n\\center{\n\\begin{tabular}{m{3.2cm} m{3.2cm} m{3.2cm}}\n  \\[\\xymatrix@=0.2cm{\n            & \\bullet\\ar@{-}[dd] && \\bullet\\ar@{-}[ll]\\ar@{-}[ddll] &          \\\\\n    \\bullet &                    &&                                 & \\bullet  \\\\\n            & \\bullet\\ar@{-}[rr] && \\bullet\\ar@{-}[uu]              & \n  }\\]\n&\n  \\[\\xymatrix@=0.2cm{\n                         & \\bullet\\ar@{-}[ddrr] && \\bullet\\ar@{-}[ll] &          \\\\\n    \\bullet\\ar@{-}[urrr] &                      &&                    & \\bullet  \\\\\n                         & \\bullet\\ar@{-}[urrr] && \\bullet\\ar@{-}[ll] & \n  }\\]\n&\n  \\[\\xymatrix@=0.2cm{\n                         & \\bullet\\ar@{-}[dddrr] && \\bullet\\ar@{-}[ll] &                      \\\\\n    \\bullet\\ar@{-}[urrr] &                       &&                    & \\bullet\\ar@{-}[llll] \\\\\n    \\bullet              &                       &&                    & \\bullet\\ar@{-}[llll] \\\\\n                         & \\bullet\\ar@{-}[urrr]  && \\bullet\\ar@{-}[ll] & \n  }\\]\n\\end{tabular}\n}\n\\caption{Cyclic decomposition of $K_6$ into a subgraph whose edges form an Euler trail (left). Similarly, $K_6$ and $K_8$ have also a cyclic spanning tree factorization whose edges form an Euler trail (centre, right).}\n\\label{fig:cyclic-decomposition}\n\\end{figure}\n\nMany real-life applications such as network designs and combinatorial problems come in the disguise of complete graph decompositions. Graph theory studies their underlying properties. For example, when is the decomposition of a complete graph into cycles of length $m$ possible? Since the existence of such a decomposition requires the degree of every vertex to be even, the complete graph must be of odd degree. Otherwise, a $1$-factor can be removed from the $2n$-complete graph. Then, an $m$-cycle decomposition exists if and only if the length of the cycle, $m$, divides the number of edges in the graph~\\cite{A01},~\\cite{S02a}.\n\nIn contrast, no necessary and sufficient condition is known for a tree to admit a factorization of complete graphs~\\cite{K11}. Rather, most factorizations are subject to graph labeling techniques (see below). In general, a label is a function from the set of vertices into the set of natural numbers. Informally, these labels are chosen such that every edge appears in exactly one factor. In particular, Rosa-type labelings (see~\\cite{E09} for a recent survey) are being used for cyclic decompositions of complete graphs into spanning trees~\\cite{E97},~\\cite{F02},~\\cite{F04}.\n\nIn the sequel, we automate the labeling of the vertices in an Euler trail such that it admits a cyclic decomposition into spanning trees of a complete graph. In fact, cyclic spanning tree factorizations can be completely characterized in terms of their symmetrical structure~\\cite{E97},~\\cite{F04}. Before we can make this characterization precise, we must agree on the following definitions.\n\n\\begin{definition}\\label{def:labeling}\nDefine a \\define{labeling} of a graph $G$ with $m$ edges to be an injective function $\\lambda : V(G) \\to L$ where $L = \\{0, 1, \\ldots , 2m\\}$. The \\define{length} of an edge $(x,y) \\in E(G)$ is defined by $\\ell(x,y) \\deq min\\{|\\lambda(x)−\\lambda(y)|, 2m+1−|\\lambda(x)−\\lambda(y)|\\}$. If $\\{ \\ell(x,y) \\alt (x,y) \\in E(G) \\} = \\{1, 2, \\ldots, m\\}$, then $\\lambda$ is called a \\define{$\\rho$-labeling}; if the image of $\\lambda$ is moreover a subset of $\\{0, 1, \\ldots, m\\}$, then $\\lambda$ is a \\define{graceful labeling}. A graph which admits a graceful labeling is said to be \\define{graceful}.\n\\end{definition}\n\n\\begin{definition}\\label{def:symmetric-labeling}\nA connected graph $G$ is \\define{symmetric} if it has a bridge $(x,y)$ and there exists an automorphism $\\phi$ such that $\\phi(x) = y$ and $\\phi(y) = x$. The isomorphic connected components of $G−(x,y)$ are called \\define{banks} and denoted by $H$ and $H'$ respectively. A labeling of a symmetric graph $G$ with $2n−1$ edges and banks $H$ and $H'$ is \\define{$\\rho$-symmetric graceful} if $H$ has a $\\rho$-labeling and $\\lambda(\\phi(x)) = \\lambda(x) + n$ for each vertex $x \\in V(H)$. A labeling of a symmetric graph with $2n − 1$ edges is said to be \\define{symmetric graceful} if it is $\\rho$-symmetric graceful and the bank H is moreover graceful.\n\\end{definition}\n\n\\begin{theorem}[\\cite{E97},\\cite{F04}]\\label{theorem:cyclic-decomposition}\nLet $G$ be a symmetric graph with $2n − 1$ edges. Then, $K_{2n}$ has a cyclic $G$-decomposition if and only if G is $\\rho$-symmetric graceful.\n\\end{theorem}\n\nIn the next section, we present a polynomial time graph algorithm which constructs the symmetric graceful spanning tree of $K_{2n}$ with the additional constraint that this spanning tree must have an Euler trail. Clearly, the length of this Euler trail is bound to be odd ($2n-1$). Moreover, the spanning tree which contains the Euler trail is unique up to isomorphism.\n\n%\\begin{proposition}\\label{proposition:unique-spanning-tree}\n%Let $S$ be a spanning tree of $K_n$ for even $n$. If $S$ has an Euler trail, then $S$ is unique up to isomorphism.\n%\\begin{proof}\n%We prove the uniqueness of $S$ by induction on $n$. Clearly, the $2$-complete graph has a unique spanning tree. For the induction step, suppose $K_{n+2}$ has two spanning trees $S$ and $S'$ with an Euler trail. By Euler's Theorem, $S$ must have exactly two vertices of odd degree. Denote both these vertices by $a$ and $b$. Then, $a$ and $b$ must have degree one; for otherwise, the degree of every vertex in $S$ would be at least two forcing the existence of a cycle. An identical argument applies to $S'$. Thus, there exists an isomorphism between the odd degree vertices in $S$ and $S'$. By induction hypothesis, the subtrees induced by deleting both these vertices from $S$ and $S'$ are isomorphic.\n%\\end{proof}\n%\\end{proposition}\n\n\\section{Algorithm}\n \nGiven the $2n$-complete graph, we aim at finding the spanning tree $S$ with an Euler trail such that $K_{2n}$ has a cyclic $S$-decomposition. This spanning tree factorization is computed by Algorithm~\\ref{algorithm:spanning-tree} and Algorithm~\\ref{algorithm:spanning-tree-decomposition} (see p.~\\pageref{algorithm:spanning-tree-decomposition}). More precisely, Algorithm~\\ref{algorithm:spanning-tree} computes the symmetric labeling of the Euler trail such that a cyclic spanning tree factorization exists by theorem~\\eqref{theorem:cyclic-decomposition}. Then, Algorithm~\\ref{algorithm:spanning-tree-decomposition} creates the cyclic permutations of this Euler trail.\n\n\\begin{algorithm}\n\\caption{Finds the spanning tree $S$ with an Euler trail such that $K_{2n}$ has a cyclic $S$-decomposition. The Euler trail in $S$ is formed by the edges incident to the vertex labeled $k$ and vertex labeled $trails[k]$ where $0 \\leq k < 2n$. The trail can be traversed by starting at the vertex labeled $0$ and stops when $trail[k]=k$ for some  $0 \\leq k < 2n$.}\n\\label{algorithm:spanning-tree}\n\\begin{algorithmic}\n\\REQUIRE $N$ to be even and $N \\geq 2$\n\\REQUIRE $trail[k] = k$ for all $0 \\leq k < N$\n\n\\STATE $i \\leftarrow 0$\n\\STATE $j \\leftarrow N / 2 - 1$\n\\STATE $x \\leftarrow N - 1$\n\\STATE $y \\leftarrow N / 2$\n\\LOOP\n\\STATE $trail[i] \\leftarrow j$\n\\STATE $trail[x] \\leftarrow y$\n\\STATE $i \\leftarrow i + 1$\n\\STATE $y \\leftarrow y + 1$\n\\IF{$i = j$}\n\\STATE exit loop\n\\ENDIF\n\\STATE $trail[j] \\leftarrow i$\n\\STATE $trail[y] \\leftarrow x$\n\\STATE $j \\leftarrow j - 1$\n\\STATE $x \\leftarrow x - 1$\n\\IF{$i = j$}\n\\STATE exit loop\n\\ENDIF\n\\ENDLOOP\n\\IF{$N > 2$}\n\\STATE $trail[i] \\leftarrow y$\n\\ENDIF\n\\end{algorithmic}\n\\end{algorithm}\n\nThe following runtime complexity result is obvious:\n\n\\begin{proposition}\\label{proposition:spanning-tree-analysis}\nAlgorithm~\\ref{algorithm:spanning-tree} is $O(n)$ given the $2n$-complete graph.\n\\begin{proof}\nGiven $K_{2n}$, the loop iterates $n$ times plus a final constant operation.\n\\end{proof}\n\\end{proposition}\n\n\\begin{algorithm}\n\\caption{Computes the cyclic permutations of the symmetric spanning tree of $K_{2n}$ (see Algorithm~\\ref{algorithm:spanning-tree}). For each $0 \\leq s < n$, the tree traversal starts at the vertex labeled $trail[s][s]$ and stops when $trail[s][t]=t$ for some $0 \\leq t < 2n$.}\n\\label{algorithm:spanning-tree-decomposition}\n\\begin{algorithmic}\n\\REQUIRE $N$ to be even and $N \\geq 2$ \n\\REQUIRE $trail[s][k] = k$ for all $0 \\leq s < \\onehalf N$ and $0 \\leq k < N$\n\n\\STATE Store result of Algorithm~\\ref{algorithm:spanning-tree} into $trails[0]$\n\\FOR{$i = 1$ to $\\onehalf N - 1$}\n\\FOR{$j = 0$ to $N - 1$}\n\\STATE $v \\leftarrow (trails[i - 1][j] + 1) \\bmod N$\n\\STATE $trails[i][(j + 1) \\bmod N] \\leftarrow v$\n\\ENDFOR\n\\ENDFOR\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{proposition}\nAlgorithm~\\ref{algorithm:spanning-tree-decomposition} is $O(n^2)$ given the $2n$-complete graph.\n\\begin{proof}\nBy proposition~\\eqref{proposition:spanning-tree-analysis}, Algorithm~\\ref{algorithm:spanning-tree} is $O(n)$. Afterwards, the innermost loop executes $2n$ times. The outermost loop executes this loop $n - 1$ times counting a total of $2(n^2 - n)$ iterations. Therefore, Algorithm~\\ref{algorithm:spanning-tree-decomposition} is $O(n^2)$.\n\\end{proof}\n\\end{proposition}\n\n\\begin{figure}[b!]\n\\centering{\n\\begin{displaymath}\n  \\xymatrix{\n    *+[o][F]{0}\\ar@/^2.2pc/@{-}[rrrr]  &\n    *+[o][F]{1}\\ar@/^1pc/@{-}[rr]      &\n    *+[o][F]{2}\\ar@/^2.5pc/@{-}[rrrrr] &\n    *+[o][F]{3}\\ar@/_0.5pc/@{-}[l]     &\n    *+[o][F]{4}\\ar@/_1.5pc/@{-}[lll]   &\n    *+[o][F]{5}                        &\n    *+[o][F]{6}\\ar@/^1.5pc/@{-}[rrr]   &\n    *+[o][F]{7}\\ar@/^0.5pc/@{-}[r]     &\n    *+[o][F]{8}\\ar@/_1pc/@{-}[ll]      &\n    *+[o][F]{9}\\ar@/_2.2pc/@{-}[llll] \n  }\n\\end{displaymath}\n\n\\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|}\n\\hline\n$v$        & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\\\ \\hline\n$trail[v]$ & 4 & 3 & 7 & 2 & 1 & 5 & 9 & 8 & 6 & 5 \\\\ \\hline\n\\end{tabular}\n}\n\\caption{The diagrammatic and key-indexed array representation of the spanning tree with an Euler trail for the $10$-complete graph. This Euler trail is formed by joining the vertices labeled as $0,4,1,3,2,7,8,6,9,5$. More generally, notice that $trail[v]$ is the label of the vertex adjacent to the vertex labeled $v$. If $trail[v] = v$, then the end of the trail has been reached. According to definition~\\eqref{def:symmetric-labeling}, the spanning tree is symmetric because the subgraphs formed by the edges of the trail $0,4,1,3,2$ and $7,8,6,9,5$ are two isomorphic banks joined by the bridge between the vertices labeled $2$ and $7$. Since the first bank is graceful, we conclude that the entire spanning tree is symmetric graceful.}\n\\label{fig:spanning-tree}\n\\end{figure}\n\nBoth algorithms feature an efficient key-indexed array data structure which represents vertex labels and supports the traversal of the spanning trees.\n\n\\begin{example}\nFigure~\\ref{fig:spanning-tree} (p.~\\pageref{fig:spanning-tree}) illustrates the spanning tree labeling produced by Algorithm~\\ref{algorithm:spanning-tree} (p.~\\pageref{algorithm:spanning-tree}) of the $10$-complete graph. This labeling is symmetric graceful by definition~\\eqref{def:symmetric-labeling}. Therefore, by theorem~\\eqref{theorem:cyclic-decomposition}, the algorithm produced a cyclic spanning tree factorization of the $10$-complete graph. Algorithm~\\ref{algorithm:spanning-tree-decomposition}, in turn, creates the cyclic permutations of the trail to obtain the remaining four Euler trails of equal length which partition the edge set accordingly.\n\\end{example}\n\n\\section{Conclusion}\n\nIn summary, by relying on more recent graph theoretical results based on $\\rho$-labelings~\\cite{E97},~\\cite{F04}, a simple polynomial time graph algorithm was presented that constructs a spanning tree factorization of the $2n$-complete graph such that the spanning tree has an Euler trail.\n\n\\begin{figure}[t]\n\\centering{\n\\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|}\n\\hline\n$v$           & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\\\ \\hline\n$trail[1][v]$ & 6 & 5 & 4 & 8 & 3 & 2 & 6 & 0 & 9 & 7 \\\\ \\hline\n$trail[2][v]$ & 8 & 7 & 6 & 5 & 9 & 4 & 3 & 7 & 1 & 0 \\\\ \\hline\n$trail[3][v]$ & 1 & 9 & 8 & 7 & 6 & 0 & 5 & 4 & 8 & 2 \\\\ \\hline\n$trail[4][v]$ & 3 & 2 & 0 & 9 & 8 & 7 & 1 & 6 & 5 & 9 \\\\ \\hline\n\\end{tabular}\n}\n\\label{fig:spanning-tree-decomposition}\n\\caption{Given the trail from Figure~\\ref{fig:spanning-tree} (p.~\\pageref{fig:spanning-tree}), Algorithm~\\ref{algorithm:spanning-tree-decomposition} (p.~\\pageref{algorithm:spanning-tree-decomposition}) computes the remaining four trails of length nine by applying cyclic permutations.}\n\\end{figure}\n\n\\bibliographystyle{plain}\n\\bibliography{doc}\n\n\\end{document}\n", "meta": {"hexsha": "56a0d4f1fbf371c39e077c4d0f456cddf162a675", "size": 15095, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doc.tex", "max_stars_repo_name": "ahorn/spanning-tree-factorization", "max_stars_repo_head_hexsha": "2c336f81fae296c59370704e4222eeca1b57a906", "max_stars_repo_licenses": ["Apache-1.1"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-29T21:49:16.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-12T01:05:48.000Z", "max_issues_repo_path": "doc/doc.tex", "max_issues_repo_name": "ahorn/spanning-tree-factorization", "max_issues_repo_head_hexsha": "2c336f81fae296c59370704e4222eeca1b57a906", "max_issues_repo_licenses": ["Apache-1.1"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/doc.tex", "max_forks_repo_name": "ahorn/spanning-tree-factorization", "max_forks_repo_head_hexsha": "2c336f81fae296c59370704e4222eeca1b57a906", "max_forks_repo_licenses": ["Apache-1.1"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.6136363636, "max_line_length": 1254, "alphanum_fraction": 0.6918184829, "num_tokens": 4608, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.4144129932197772}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{geometry}\n\\geometry{letterpaper}\n\\usepackage{graphicx}\n\\usepackage{amssymb, amsmath}\n\\usepackage{epstopdf}\n\\usepackage{color}\n\\usepackage[table]{xcolor}\n\\usepackage{multirow}\n\n\\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}\n\n\\title{Efficient Implementation of Automatic Differentiation}\n\\author{Michael Betancourt}\n\\date{}\n\n\\begin{document}\n\n\\maketitle\n\nAutomatic differentiation (autodiff) is a tool for automating the chain rule when \ncomputing derivatives of complex, composite functions.  As one moves to higher \nderivatives the construction of autodiff becomes significantly more difficult and \nobfuscates computationally efficient implementations.\n\nIn this note I will take advantage of the \\textit{dual number} perspective of autodiff\nto simplify the construction and implementation of various higher-order derivations.\nAfter discussing the basics of dual numbers and how they can be used to derive\nautomatic differentiation, I'll review first, second, and third-order implementations.\n\n\\section*{Dual Numbers}\n\nDual numbers are an extension of the real numbers, $\\mathbb{R}$, given by the\naddition of a new element, $\\mathbf{a}$,%\n%\n\\footnote{In this note bold face will refer to the dual units while the regular\ntypeface will correspond to elements of $\\mathbb{R}$.  I will also reserve\nroman letters for real numbers and greek letters for dual numbers.}\n%\nwhich is nilpotent, $\\mathbf{a}^{2} = 0$. I will refer to this new element as a \\textit{dual unit}.\n\nThis extended space of dual numbers forms a two-dimensional associative algebra \nover the reals; in other words, the addition of the dual unit generates a two-dimensional\nspace, $\\mathbb{D}$, with elements\n%\n\\begin{equation*}\n\\xi = x + \\mathbf{a} \\, \\delta x; \\, \\xi \\in \\mathbb{D}, \\, x, \\delta x \\in \\mathbb{R}\n\\end{equation*}\n%\nequipped with addition and multiplication operations,\n%\n\\begin{align*}\n\\xi_{1} + \\xi_{2} &= \\left( x_{1} + \\mathbf{a} \\, \\delta x_{1} \\right) + \\left( x_{2} + \\mathbf{a} \\,  \\delta x_{2} \\right) \n\\\\\n&= \\left( x_{1} + x_{2} \\right) + \\mathbf{a} \\left( \\delta x_{1} + \\delta x_{2} \\right) \n\\\\\n\\xi_{1} \\cdot \\xi_{2} \n&= \\left( x_{1} + \\mathbf{a} \\, \\delta x_{1} \\right) \\cdot \\left( x_{2} + \\mathbf{a} \\, \\delta x_{2} \\right) \n\\\\\n&= x_{1} x_{2} + \\left( x_{1} \\delta x_{2} + \\delta x_{1} x_{2} \\right) \\mathbf{a} + \\delta x_{1} \\delta x_{2} \\, \\mathbf{a}^{2} \n\\\\\n&= x_{1} x_{2} + \\left( x_{1} \\delta x_{2} + \\delta x_{1} x_{2} \\right) \\mathbf{a}.\n\\end{align*}  \n\nNote that, because the dual unit is nilpotent, we cannot define an inverse to multiplication.  \nMathematically this means that the dual numbers form only a local ring; compare this to \nthe complex numbers on which we can define division and whose associative algebra is a field.\n\nDual numbers have many uses in mathematics and physics, but here we will focus on their\nrelationship to functions.  Any smooth function $f : \\mathbb{R} \\rightarrow \\mathbb{R}$ \ninduces a function on the dual numbers, $f : \\mathbb{D} \\rightarrow \\mathbb{D}$, \nvia a Taylor series around any purely real point, $\\xi_{0} = x_{0} + \\mathbf{a} \\, 0$,\n%\n\\begin{align*}\nf \\! \\left( \\xi \\right) \n&= \n\\sum_{n = 0}^{\\infty} \\frac{ \\left( \\xi - \\xi_{0} \\right)^{n} }{n!} \n\\frac{ \\partial^{n} f }{ \\partial \\xi^{n} } \\! \\left( \\xi = \\xi_{0} \\right) \n\\\\\n&= \n\\sum_{n = 0}^{\\infty} \\frac{ \\left( \\left( x - x_{0} \\right) + \\mathbf{a} \\, \\delta x \\right)^{n} }{n!} \n\\frac{ \\partial^{n} f }{ \\partial x^{n} } \\! \\left( x_{0} \\right)\n\\\\\n&= \n\\sum_{n = 0}^{\\infty} \\frac{ \\left( x - x_{0} \\right)^{n} }{n!} \n\\frac{ \\partial^{n} f }{ \\partial x^{n} } \\! \\left( x_{0} \\right)\n+ \\mathbf{a} \\, \\delta x \\sum_{n = 0}^{\\infty} \\frac{ \\left( x - x_{0} \\right)^{n - 1} }{\\left( n - 1 \\right)!} \n\\frac{ \\partial^{n} f }{ \\partial x^{n} } \\! \\left( x_{0} \\right) \n\\\\\n&= \nf \\! \\left( x \\right) \n+ \\mathbf{a} \\, \\delta x \\frac{ \\partial f }{ \\partial x } \\! \\left( x \\right).\n\\end{align*}\n%\nExtending a function to dual numbers requires not just the value of the function\nbut also its derivatives!  The second component of dual numbers formalizes\nthe intuitive concept of an ``infinitesimal'' in that any product of more than one\nwill vanish by construction.\n\nThe generalization to multivariate functions is straightforward: any function \n$f : \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$ is first decomposed into $m$\nfunctions $f_{i} : \\mathbb{R}^{n} \\rightarrow \\mathbb{R}$ which generalize\nto dual numbers as\n%\n\\begin{equation} \\label{dualFunction}\nf_{i} \\! \\left( \\xi_{j} \\right) = f_{i} \\! \\left( x_{j} \\right) \n+ \\mathbf{a} \\sum_{j = 1}^{n} \\delta x_{j} \\frac{ \\partial f_{i} \\! \\left( x_{j} \\right) }{ \\partial x_{j} }.\n\\end{equation}\n%\nNote that in the general case the extension does not require the full Jacobian, \n$ \\partial f_{i} \\! \\left( x_{j} \\right) \\! / \\partial x_{j}$, but rather its inner product with \n$\\delta x_{j}$.\n\nThe power of extending functions to dual numbers is the implicit incorporation of \nthe chain rule. A composition of the functions $f : \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$ \nand $g : \\mathbb{R}^{m} \\rightarrow \\mathbb{R}^{p}$, for example, becomes\n%\n\\begin{align*}\ng_{i} \\! \\left( f_{j} \\! \\left( \\xi_{k} \\right) \\right)\n&= \ng_{i} \\! \\left( f_{j} \\! \\left( x_{k} + \\mathbf{a} \\, \\delta x_{k} \\right) \\right)\n\\\\\n&=\ng_{i} \\! \\left( f_{j} \\! \\left( x_{k} \\right) \n+ \\mathbf{a} \\, \\sum_{k} \\delta x_{k} \\frac{ \\partial f_{j} }{ \\partial x_{k} } \\! \\left( x_{k} \\right) \\right)\n\\\\\n&=\ng_{i} \\! \\left( f_{j} \\! \\left( x_{k} \\right) \\right)\n+ \\mathbf{a} \\, \\sum_{k} \\delta x_{k} \n\\frac{ \\partial g_{i} }{ \\partial f_{j} }  \\! \\left( f_{j} \\! \\left( x_{k} \\right) \\right)\n\\frac{ \\partial f_{j} }{ \\partial x_{k} } \\! \\left( x_{k} \\right):\n\\end{align*}\n%\nthe second component is just $\\sum_{k} \\delta x_{k} \\partial g_{i} / \\partial x_{k} $ \nas would have been computed by the chain rule.  The real utility of dual numbers is \nthat they factor the chain rule into the purely differential operations (computing partial\nderivatives) and the purely algebraic operations (addition and multiplication), which \nallows for a straightforward algorithmic implementation.\n\n\\section*{First-Order Automatic Differentiation}\n\nAutomatic differentiation implements the propagation of dual numbers through a\ncomposite function and, consequently, the chain rule.  We begin by transforming\na composite function into an \\textit{expression graph}, where each node is given\nby a dual number intermediate to the calculation and edges denote the \ndependencies of the functions (Figure \\ref{fig:exprGraph}).\n\n\\begin{figure}\n\\setlength{\\unitlength}{0.1in} \n\\centering\n\\begin{picture}(50, 30)\n%\n%\\put(0, 0) { \\framebox(50, 30){} }\n%\\put(25, 0) { \\framebox(25, 30){} }\n%\\put(25, 0) { \\framebox(6.25, 30){} }\n%\\put(25, 0) { \\framebox(12.5, 30){} }\n%\\put(25, 0) { \\framebox(18.75, 30){} }\n%\n%\\put(25, 0) { \\framebox(3.125, 30){} }\n%\\put(25, 0) { \\framebox(9.375, 30){} }\n%\\put(25, 0) { \\framebox(15.625, 30){} }\n%\n\\put(12.5, 15) { \\makebox(0, 0) \n{$z \\! \\left( y_{1} \\! \\left( x_{1}, x_{2} \\right), y_{2} \\! \\left( x_{2}, x_{3} \\right) \\right)$} }\n%\n\\put(21.875, 15) { \\vector(1, 0){6.25} }\n%\n\\put(31.25, 7.5) { \\circle{4} }\n\\put(31.25, 7.5) { \\makebox(0, 0) {$ x_{1} $} }\n%\n\\put(37.5, 7.5) { \\circle{4} }\n\\put(37.5, 7.5) { \\makebox(0, 0) { $ x_{2} $ } }\n%\n\\put(43.75, 7.5) { \\circle{4} }\n\\put(43.75, 7.5) { \\makebox(0, 0) { $ x_{3} $ } }\n%\n\\put(31.25, 9.5) { \\vector(3, 4){2.75} }\n\\put(37.5, 9.5) { \\vector(-3, 4){2.75} }\n\\put(37.5, 9.5) { \\vector(3, 4){2.75} }\n\\put(43.75, 9.5) { \\vector(-3, 4){2.75} }\n%\n\\put(35, 15) {\\circle{4} } % Tweaked to the right\n\\put(34.375, 15) { \\makebox(0, 0) { $y_{1}$ } }\n%\n\\put(41.25, 15) {\\circle{4} } % Tweaked to the right\n\\put(40.625, 15) { \\makebox(0, 0) { $y_{2}$ } }\n%\n\\put(34.375, 17) { \\vector(3, 4){2.75} }\n\\put(40.625, 17) { \\vector(-3, 4){2.75} }\n%\n\\put(38, 22.5) {\\circle{4} } % Tweaked to the right\n\\put(37.5, 22.5) { \\makebox(0, 0) { $ z $ } }\n%\n\\end{picture} \n\\caption{\nComposite functions are isomorphic to directed acyclic graphs known as \nan \\textit{expression graph} or \\textit{expression tree}.  Here we the function\n$z \\! \\left( y_{1} \\! \\left( x_{1}, x_{2} \\right), y_{2} \\! \\left( x_{2}, x_{3} \\right) \\right)$\ngenerates a three level graph.\n}\n\\label{fig:exprGraph} \n\\end{figure}\n\nOnce the expression graph has been constructed the evaluation of the function\nreduces to propagating the values of the dual numbers along the edges.  The\ndirectionality of the messages at each node is not constrained, but in practice we \ntypically consider passing all messages \\textit{forward} with the evaluation and passing\nall messages \\textit{reverse} to the evaluation.\n\n\\subsection*{Forward Mode}\n\nNote that the second component of a dual number-valued function is really\na directional derivative, mapping the input vector $\\delta x_{j}$ to\n$\\sum_{k} \\delta x_{k} \\partial f_{j} / \\partial x_{k}$.  In other words,\nthe Jacobian is a map $J: \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$.\n\nIn forward mode autodiff we propagate $\\delta x_{j}$ defined at the inputs\nforward through the expression graph using the Jacobian map at each\nnode (Figure \\ref{fig:directions}).  Following the literature we will refer to the components of the dual\nnumbers as \\textit{values},\n%\n\\begin{equation*}\n\\mathcal{V} \\! \\left( \\xi \\right) \n= \\mathcal{V} \\! \\left( x + \\mathbf{a} \\, \\delta x \\right) \n= x,\n\\end{equation*}\n%\nand \\textit{tangents} or \\textit{perturbations},\n\\begin{equation*}\n\\mathcal{T} \\! \\left( \\xi \\right) \n= \\mathcal{T} \\! \\left( x + \\mathbf{a} \\, \\delta x \\right) \n= \\delta x,\n\\end{equation*}\n%\nrespectively.\n\n\\begin{figure}\n\\setlength{\\unitlength}{0.1in} \n\\centering\n\\begin{picture}(50, 30)\n%\n%\\put(0, 0) { \\framebox(50, 30){} }\n%\\put(0, 0) { \\framebox(12.5, 30){} }\n%\\put(0, 0) { \\framebox(25, 30){} }\n%\\put(0, 0) { \\framebox(37.5, 30){} }\n%\\put(0, 0) { \\framebox(50, 10){} }\n%\\put(0, 0) { \\framebox(50, 20){} }\n%\n% Forward Mode\n%\n\\put(12.5, 5) { \\makebox(0, 0) { Forward Mode } }\n%\n\\put(13, 10) {\\circle{4} } % Tweak to the right\n\\put(12.5, 10) { \\makebox(0, 0) { $ \\xi_{j} $ } }\n%\n\\put(12, 12) { \\vector(0, 1){6} }\n\\put(13, 12) { \\vector(0, 1){6} }\n%\n\\put(13, 20) {\\circle{4} } % Tweak to the right\n\\put(12.5, 20) { \\makebox(0, 0) { $ \\xi_{i} $ } }\n%\n\\put(6.75, 15) { \\makebox(0, 0) \n{ $ \\mathcal{V} \\! \\left( \\xi_{j} \\right) = x_{j} \\! \\left( x_{i} \\right)$ } }\n\\put(16.5, 16) { \\makebox(0, 0) \n{ $ \\mathcal{T} \\! \\left( \\xi_{i} \\right) =  $} }\n\\put(20, 14) { \\makebox(0, 0) \n{ $ \\sum_{i} \\frac{ \\partial x_{i} }{ \\partial x_{j} } \\mathcal{T} \\! \\left( \\xi_{j} \\right)  $ } }\n%\n% Reverse Mode\n%\n\\put(37.5, 5) { \\makebox(0, 0) { Reverse Mode } }\n%\n\\put(38, 10) {\\circle{4} } % Tweak to the right\n\\put(37.5, 10) { \\makebox(0, 0) { $ \\xi_{j} $ } }\n%\n\\put(37, 12) { \\vector(0, 1){6} }\n\\put(38, 18) { \\vector(0, -1){6} }\n%\n\\put(38, 20) {\\circle{4} } % Tweak to the right\n\\put(37.5, 20) { \\makebox(0, 0) { $ \\xi_{i} $ } }\n%\n\\put(31.75, 15) { \\makebox(0, 0) \n{ $ \\mathcal{V} \\! \\left( x_{j} \\right) = x_{j} \\! \\left( x_{i} \\right)$ } }\n\\put(41.5, 14) { \\makebox(0, 0) \n{ $ \\mathcal{A} \\! \\left( \\xi_{j} \\right) =  $} }\n\\put(45, 16) { \\makebox(0, 0) \n{ $ \\sum_{i} \\frac{ \\partial x_{i} }{ \\partial x_{j} } \\mathcal{A} \\! \\left( \\xi_{i} \\right)  $ } }\n%\n\\end{picture} \n\\caption{\nIn forward mode autodiff the Jacobian propagates directional derivatives, \n$\\mathcal{T} \\! \\left( \\xi \\right)$ forward in the same direction as the\nvalues, $\\mathcal{V} \\! \\left( \\xi \\right)$.  Reverse mode autodiff, on \nthe other hand, uses the adjoint Jacobian to propagate adjoint directional \nderivatives, $\\mathcal{A} \\! \\left( \\xi \\right)$, backwards against the \nvalues, $\\mathcal{V} \\! \\left( \\xi \\right)$.\n}\n\\label{fig:directions} \n\\end{figure}\n\nMessages accumulated at the output nodes yield the components of the directional\nderivative, $\\sum_{k} \\delta x_{k} \\partial f_{j} / \\partial x_{k}$.\n\n\\subsection*{Reverse Mode}\n\nIn reverse mode autodiff we consider not the Jacobian but rather its \\textit{adjoint},\n$J^{T} : \\mathbb{R}^{m} \\rightarrow \\mathbb{R}^{n}$, which maps the second\ncomponent of dual numbers at the outputs, denoted $\\mathrm{d} f_{i}$ to differentiate\nthem from their use in forward mode autodiff, to the adjoint directional derivative, \n$\\sum_{j} \\mathrm{d} f_{j} \\partial f_{j} / \\partial x_{k}$.  Using the adjoint Jacobian\nwe can propagate the $\\mathrm{d} f_{i}$ at the outputs backwards through the \nexpression graph until the input nodes yield the components of the transposed\ndirectional derivative (Figure \\ref{fig:directions}).\n\nWhen considering the action of the adjoint Jacobian the components of the dual\nnumbers as denoted \\textit{values},\n%\n\\begin{equation*}\n\\mathcal{V} \\! \\left( \\xi \\right) \n= \\mathcal{V} \\! \\left( x + \\mathbf{a} \\, \\mathrm{d} x \\right) \n= x,\n\\end{equation*}\n%\nand \\textit{adjoints} or \\textit{sensitivities},\n\\begin{equation*}\n\\mathcal{A} \\! \\left( \\xi \\right) \n= \\mathcal{A} \\! \\left( x + \\mathbf{a} \\, \\mathrm{d} x \\right) \n= \\mathrm{d} x,\n\\end{equation*}\n%\nrespectively.\n\n\\subsection*{Performance}\n\nThe relative performance of forward and reverse mode autodiff depends on\nthe sizes of $n$ and $m$ and the desired components of the Jacobian.  Note\nthat per evaluation forward mode will be faster than reverse mode as it requires\nonly one sweep compared to the two reverse mode requires (one forward sweep\nto build up the expression graph and one reverse sweep to compute the adjoint\ndirectional derivative).  Moreover the overhead for forward mode will be larger\nsince it does not require the full expression graph to be stored.\n\nConsider, for example, the many-to-one case where $m = 1$.  Here forward\nmode computes the scalar $\\sum_{k} \\delta x_{i} \\partial f / \\partial x_{i}$\nwhere as the reverse mode computes the full vector gradient \n$\\mathrm{d} f \\partial f / \\partial x_{i}$.  If the directional derivative is all\nthat is necessary then the forward mode calculation will be quicker given\nthe considerations above.  On the other hand, if the full vector gradient is required \nthen the small overhead from reverse mode will be dwarfed by the $m$ repetitions \nrequired to build the full gradient from directional derivatives in forward mode.\n\nIn general, computing the full Jacobian is faster with forward mode if $n \\ll m$ \nand faster with reverse mode if $n \\gg m$.\n\n\\section*{Higher-Order Automatic Differentiation}\n\nOne substantial advantage of dual numbers is that they dramatically ease the\nmanipulation of higher-order variants of the chain rule.  In order to go to \nhigher-order, however, we need to introduce nested dual numbers.\n\nFor example, let $\\mathbf{a}$ and $\\mathbf{b}$ be two distinct dual units.\nA first-order dual number,\n%\n\\begin{equation*}\n\\zeta_{i} = z_{i} + \\mathbf{a} \\, \\delta z_{i},\n\\end{equation*}\n%\nthen becomes a second-order dual number by replacing the \nreal-valued components with dual numbers in the direction of the second \ndual unit,\n%\n\\begin{alignat*}{3}\n\\zeta_{i} \n&=\n\\xi_{i} \n&&+ \\mathbf{a} \\, \\eta_{i}\n\\\\\n&=\n\\left( x_{i} + \\mathbf{b} \\, \\delta x_{i} \\right)\n&&+ \\mathbf{a} \\left( \\delta y_{i} + \\mathbf{b} \\, \\delta^{2} y_{i} \\right).\n\\end{alignat*}\n%\nI will refer to $x_{i}$ as the first value, $\\delta x_{i}$ as the first gradient, \n$\\delta y_{i}$ as the second value, and $\\delta^{2} y_{i}$\nas the second gradient.  Higher-order dual numbers follow recursively \nby replacing the real-valued components with additional dual numbers along \ndistinct dual units.\n\nHigher-order dual numbers are evaluated in the same manner of forward and \nreverse sweeps as the first order dual numbers, with the propagation rules\nfor each component generated by the dual algebra.  Forward and reverse\npropagations yield various directional derivatives as defined in Table \\ref{tab:directDerivs}.\n\n\\begin{table*}[t!]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{2}\n\t\\begin{tabular}{cccc}\n\t\\rowcolor[gray]{0.9} \\textbf{Value Type} & \\textbf{Order} \n\t& \\textbf{Formula} & \\textbf{Mode} \n\t\\\\\n\tScalar & First & \n\t$ \\displaystyle \\sum_{j} v_{j} \\, f_{i} \\! \\left( x_{j} \\right)$ & Forward\n\t\\\\\n\t\\rowcolor[gray]{0.9}\n\tVector & First & \n\t$ \\displaystyle  f_{i} \\! \\left( x_{j} \\right)$ & Reverse\n\t\\\\\n\tScalar & Second & \n\t$ \\displaystyle \\sum_{jk} v_{j} \\, u_{k} \\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} }$ \n\t& Forward\n\t\\\\\n\t\\rowcolor[gray]{0.9}\n\tVector & Second & \n\t$ \\displaystyle \\sum_{j} v_{j} \\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} }$  \n\t& Reverse\n\t\\\\\n\tScalar & Third & \n\t$ \\displaystyle \\sum_{jkl} v_{j} \\, u_{k} \\, w_{l} \n\t\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l}}$  \n\t& Forward\n\t\\\\\n\t\\rowcolor[gray]{0.9}\n\tVector & Third & \n\t$\\displaystyle \\sum_{jk} v_{j} \\, u_{k} \\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l}}$\n\t& Reverse\n\t\\\\\n\t\\end{tabular}\n\t\\caption{Automatic differentiation computes directional derivatives and\n\tgeneralizations thereof.  In general, forward mode calculations return\n\tscalars while reverse mode calculations return vectors.\n\t\\label{tab:directDerivs}}\n\\end{table*}\n\nHere we compute the propagation rules for second and third-order directional \nderivatives to complement the first-order rules derived above before considering \nhow to use these rules to compute popular differential objects such as the Hessian.\n\n\\subsection*{Second-Order}\n\nThe extension of a function $f: \\mathbb{R}^{n} \\rightarrow \\mathbb{R}^{m}$ to\na second-order dual number follows from the recursive application of the\nfirst-order extension: given the dual number\n%\n\\begin{alignat*}{3}\n\\zeta_{i} \n&=\n\\xi_{i} \n&&+ \\mathbf{a} \\, \\eta_{i}\n\\\\\n&=\n\\left( x_{i} + \\mathbf{b} \\, \\delta x_{i} \\right)\n&&+ \\mathbf{a} \\left( \\delta y_{i} + \\mathbf{b} \\, \\delta^{2} y_{i} \\right)\n\\end{alignat*}\n%\nwe have\n%\n\\begin{align*}\nf_{i} \\! \\left( \\zeta_{j} \\right)\n=&\nf_{i} \\! \\left( \\xi_{j} \\right) \n+ \\mathbf{a} \\sum_{j} \\eta_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( \\xi_{j} \\right) \n\\\\\n=&\nf_{i} \\! \\left( x_{j} + \\mathbf{b} \\, \\delta x_{j} \\right) \n+ \\mathbf{a} \\sum_{j} \\left( \\delta y_{j} + \\mathbf{b} \\, \\delta^{2} y_{j} \\right)\n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \n\\! \\left( x_{j} + \\mathbf{b} \\, \\delta x_{j} \\right) \n\\\\\n=&\nf_{i} \\! \\left( x_{j} \\right) \n+ \\mathbf{b} \\sum_{j} \\delta x_{j}  \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j} \\left( \\delta y_{j} + \\mathbf{b} \\, \\delta^{2} y_{j} \\right)\n\\left( \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right) + \n\\mathbf{b} \\, \\sum_{k} \\delta x_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( x_{j} \\right) \\right) \n\\\\\n=&\n\\quad\\quad\\quad \nf_{i} \\! \\left( x_{j} \\right) \n\\quad\\quad\\quad\\;\\;\\;\n+ \\mathbf{b} \\;\\;\\;\n\\sum_{j} \\delta x_{j}  \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\left( \n\\sum_{j} \\delta y_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right) \n+ \\mathbf{b} \\left(\n\\sum_{j} \\delta^{2} y_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)\n+ \\sum_{jk} \\delta x_{k} \\, \\delta y_{j}\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( x_{j} \\right)\n\\right)\n\\right)\n\\end{align*}\n%\nThese results are summarized in Table \\ref{tab:secondOrder}.\n\n\\begin{table*}[t!]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{2}\n\t\\begin{tabular}{ccc}\n\t\\rowcolor[gray]{0.9} \\textbf{Component} & \\textbf{Input} & \\textbf{Output} \\\\\n\tFirst Value & \n\t$x_{i}$ & \n\t$f_{i} \\! \\left( x_{j} \\right)$ \n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\tFirst Gradient & \n\t$\\delta x_{i}$ &\n\t$\\displaystyle \\sum_{j} \\delta x_{j}  \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)$\n\t\\\\\n\tSecond Value & \n\t$\\delta y_{i}$ & \n\t$\\displaystyle \\sum_{j} \\delta y_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)$\n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\tSecond Gradient & \n\t$\\delta^{2} y_{i}$ & \n\t$\\displaystyle \\sum_{j} \\delta^{2} y_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( x_{j} \\right)\n\t+ \\sum_{jk} \\delta x_{k} \\, \\delta y_{j}\n\t\\frac{ \\partial f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( x_{j} \\right)$\n\t\\\\\n\t\\end{tabular}\n\t\\caption{Recursively expanding an input function yields its action\n\ton a second-order dual number input.\n\t\\label{tab:secondOrder}}\n\\end{table*}\n\nIn forward mode we compute four different values at each node -- the function\nevaluation, a directional derivative along $\\delta x_{i}$, a directional derivative\nalong $\\delta y_{i}$, and the scalar-valued second-order directional derivative\n$ \\sum_{j} \\delta^{2} y_{j} \\, \\partial f_{i} / \\partial x_{j}\n+ \\sum_{jk} \\delta x_{k} \\, \\delta y_{j} \\, \\partial f_{i} / \\partial x_{j} \\partial x_{k}$.\n\nThe generalization of reverse mode requires some care because the second-order\nJacobian, $\\partial f_{i} / \\partial x_{j} \\partial x_{k}$, does not have a well-defined\ntranspose.  If we propagate the second-order values forward first, however,\nthen we can define the linear operator \n$\\delta y_{j} \\, \\partial f_{i} / \\partial x_{j} \\partial x_{k}$ which can be transposed.\nSecond-order reverse mode then consists of a forward sweep in which the\nfirst and second-order values are computed, and then reverse sweep in which\nthe first and second-order gradients are computed.  This yields the function\nevaluation, the full gradient, a directional derivative along $\\delta y_{j}$, and\nthe vector-valued second-order directional derivative \n$ \\sum_{j} \\mathrm{d}^{2} y_{j} \\, \\partial f_{i} / \\partial x_{j}\n+ \\sum_{jk} \\mathrm{d} x_{k} \\, \\delta y_{j} \\, \\partial f_{i} / \\partial x_{j} \\partial x_{k}$\n\n\\subsection*{Third-Order}\n\nContinuing to third-order follows in kind.  Given a third-order dual number,\n%\n\\begin{alignat*}{10}\n\\zeta_{i} \n&=\n&& \\xi_{i} && && &&\n&&+ \\mathbf{a} \\, \n&& \\eta_{i} && && &&\n\\\\\n&=\n( && \\sigma_{i} && + \\mathbf{b} && \\tau_{i} &&)\n&&+ \\mathbf{a} \\,\n( && \\upsilon_{i} && + \\mathbf{b} && \\nu_{i} && )\n\\\\\n&=\n(( && s_{i} + \\mathbf{c} \\, \\delta s_{i} )\n&& + \\mathbf{b} \\;\n( && \\delta t_{i} + \\mathbf{c} \\, \\delta^{2} t_{i}  ) &&)\n&&+ \\mathbf{a} \\;\n(( && \\delta u_{i} + \\mathbf{c} \\, \\delta^{2} u_{i} )\n&& + \\mathbf{b} \\;\n( && \\delta^{2} v_{i} + \\mathbf{c} \\, \\delta^{3} v_{i} ) &&)\n\\end{alignat*}\n%\nwe have\n%\n\\begin{align*}\nf_{i} \\! \\left( \\zeta_{j} \\right)\n%\n=&\nf_{i} \\! \\left( \\xi_{j} \\right) \n+ \\mathbf{a} \\sum_{j} \\eta_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( \\xi_{j} \\right) \n\\\\\n%\n=&\nf_{i} \\! \\left( \\sigma_{j} + \\mathbf{b} \\, \\tau_{j} \\right) \n+ \\mathbf{a} \\sum_{j} \\left( \\upsilon_{j} + \\mathbf{b} \\, \\nu_{j} \\right)\n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \n\\! \\left( \\sigma_{j} + \\mathbf{b} \\, \\tau_{j} \\right) \n\\\\\n%\n=&\nf_{i} \\! \\left( \\sigma_{j} \\right) + \\mathbf{b} \n\\sum_{j} \\tau_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \n\\! \\left( \\sigma_{j} \\right)\n+ \\mathbf{a} \\sum_{j} \\left( \\upsilon_{j} + \\mathbf{b} \\, \\nu_{j} \\right)\n\\left( \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( \\sigma_{j} \\right)\n+ \\mathbf{b} \\sum_{k} \\tau_{k}\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( \\sigma_{j} \\right) \\right) \n\\\\\n%\n=&\nf_{i} \\! \\left( \\sigma_{j} \\right) + \\mathbf{b} \n\\sum_{j} \\tau_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \n\\! \\left( \\sigma_{j} \\right)\n+ \\mathbf{a} \\sum_{j}\n\\upsilon_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( \\sigma_{j} \\right)\n\\\\\n& + \\mathbf{a} \\, \\mathbf{b} \\sum_{j}\n \\nu_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( \\sigma_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{b} \\, \\sum_{jk} \\upsilon_{j} \\tau_{k}\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( \\sigma_{j} \\right)\n\\\\\n%\n=&\nf_{i} \\! \\left( s_{j} + \\mathbf{c} \\, \\delta s_{j} \\right) + \\mathbf{b} \n\\sum_{j} \\left( \\delta t_{j} + \\mathbf{c} \\, \\delta^{2} t_{j} \\right) \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} + \\mathbf{c} \\, \\delta s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j}\n\\left( \\delta u_{j} + \\mathbf{c} \\, \\delta^{2} u_{j} \\right) \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} + \\mathbf{c} \\, \\delta s_{j} \\right)\n\\\\\n& + \\mathbf{a} \\, \\mathbf{b} \\sum_{j}\n\\left( \\delta^{2} v_{j} + \\mathbf{c} \\, \\delta^{3} v_{j} \\right) \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} + \\mathbf{c} \\, \\delta s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\, \\sum_{jk} \n\\left( \\delta u_{j} + \\mathbf{c} \\, \\delta^{2} u_{j} \\right) \n\\left( \\delta t_{k} + \\mathbf{c} \\, \\delta^{2} t_{k} \\right)\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} + \\mathbf{c} \\, \\delta s_{j} \\right)\n\\\\\n%\n=&\nf_{i} \\! \\left( s_{j} \\right) + \\mathbf{c} \\sum_{j} \\delta s_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{b}\n\\sum_{j} \\left( \\delta t_{j} + \\mathbf{c} \\, \\delta^{2} t_{j} \\right) \n\\left( \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+  \\mathbf{c} \\sum_{k} \\delta s_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j}\n\\left( \\delta u_{j} + \\mathbf{c} \\, \\delta^{2} u_{j} \\right) \n\\left( \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{c} \\sum_{k} \\delta s_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \\right)\n\\\\\n& + \\mathbf{a} \\, \\mathbf{b} \\sum_{j}\n\\left( \\delta^{2} v_{j} + \\mathbf{c} \\, \\delta^{3} v_{j} \\right) \n\\left( \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{c} \\sum_{k} \\delta s_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\, \\sum_{jk} \n\\left( \\delta u_{j} + \\mathbf{c} \\, \\delta^{2} u_{j} \\right) \n\\left( \\delta t_{k} + \\mathbf{c} \\, \\delta^{2} t_{k} \\right)\n\\\\\n& \\quad\\quad\\quad\\quad \\times \\left(\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \n+ \\mathbf{c} \\sum_{l} \\delta s_{l} \n\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right)\n\\right)\n\\\\\n%\n\\end{align*}\n\n\\begin{align*}\nf_{i} \\! \\left( \\zeta_{j} \\right)\n%\n=&\nf_{i} \\! \\left( s_{j} \\right) + \\mathbf{c} \\sum_{j} \\delta s_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{b} \\sum_{j} \\delta t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{2} t_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta t_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j} \\delta u_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{j} \\delta^{2} u_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta u_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\sum_{j} \\delta^{2} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{3} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta^{2} v_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\, \\sum_{jk} \n\\left( \\delta u_{j} \\delta t_{k}\n+ \\mathbf{c} \\left(\n\\delta u_{j} \\, \\delta^{2} t_{k} + \\delta^{2} u_{j} \\, \\delta t_{k} \n\\right) \\right)\n\\\\\n& \\quad\\quad\\quad\\quad \\times \\left(\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \n+ \\mathbf{c} \\sum_{l} \\delta s_{l} \n\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right)\n\\right)\n\\\\\n%\n=&\nf_{i} \\! \\left( s_{j} \\right) + \\mathbf{c} \\sum_{j} \\delta s_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{b} \\sum_{j} \\delta t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{2} t_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta t_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j} \\delta u_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{j} \\delta^{2} u_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta u_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\sum_{j} \\delta^{2} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{3} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta^{2} v_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \\, \\sum_{jk} \n\\delta u_{j} \\delta t_{k} \\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jk}\n\\left( \\delta u_{j} \\, \\delta^{2} t_{k} + \\delta^{2} u_{j} \\, \\delta t_{k}  \\right)\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \n\\\\\n&+\n\\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jkl}\n\\delta u_{j} \\delta t_{k} \\, \\delta s_{l} \n\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right)\n\\\\\n%\n\\end{align*}\n\n\\begin{align*}\nf_{i} \\! \\left( \\zeta_{j} \\right)\n%\n=&\nf_{i} \\! \\left( s_{j} \\right) + \\mathbf{c} \\sum_{j} \\delta s_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{b} \\sum_{j} \\delta t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{2} t_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{b} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta t_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\sum_{j} \\delta u_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{j} \\delta^{2} u_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\mathbf{a} \\, \\mathbf{c} \\sum_{jk} \\delta s_{k} \\, \\delta u_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n&+ \n\\mathbf{a} \\, \\mathbf{b} \n\\left( \n\\sum_{j} \\delta^{2} v_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\delta u_{j} \\delta t_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\right)\n\\\\\n&+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{j} \\delta^{3} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n\\\\\n&+ \\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jk}\n\\left( \n\\delta s_{k} \\, \\delta^{2} v_{j} + \\delta u_{j} \\, \\delta^{2} t_{k} + \\delta^{2} u_{j} \\, \\delta t_{k}  \\right)\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \n\\\\\n&+\n\\mathbf{a} \\, \\mathbf{b} \\, \\mathbf{c} \\sum_{jkl}\n\\delta u_{j} \\delta t_{k} \\, \\delta s_{l} \n\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right)\n\\\\\n%\n=& \\hspace{26mm} \nf_{i} \\! \\left( s_{j} \\right) \n\\hspace{9mm}\n+ \\mathbf{c} \n\\hspace{3mm}\n\\sum_{j} \\delta s_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\\\\n& \\hspace{8mm} + \n\\mathbf{b} \\left( \\sum_{j} \\delta t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\hspace{1mm}\n+ \\mathbf{c} \\left( \n\\sum_{j} \\delta^{2} t_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\sum_{jk} \\delta s_{k} \\, \\delta t_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \\right) \\right)\n\\\\\n&+ \n\\mathbf{a} \\Bigg( \n\\hspace{9mm}\n\\sum_{j} \\delta u_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n+ \\mathbf{c} \\left( \\sum_{j} \\delta^{2} u_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n+ \\sum_{jk} \\delta s_{k} \\, \\delta u_{j} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \\right)\n\\\\\n& \n\\hspace{8mm} \n+ \\mathbf{b} \\Bigg(\n\\hspace{0.5mm}\n\\sum_{j} \\delta^{2} v_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\\delta u_{j} \\delta t_{k} \n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)\n\\\\\n& \\hspace{34mm} \n+ \\mathbf{c} \\Bigg(\n\\sum_{j} \\delta^{3} v_{j} \n\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n\\\\\n& \\hspace{40mm} \n+ \\sum_{jk}\n\\left( \n\\delta s_{k} \\, \\delta^{2} v_{j} + \\delta u_{j} \\, \\delta^{2} t_{k} + \\delta^{2} u_{j} \\, \\delta t_{k}  \\right)\n\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) \n\\\\\n& \\hspace{40mm} +\n\\sum_{jkl}\n\\delta u_{j} \\delta t_{k} \\, \\delta s_{l} \n\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right) \n\\Bigg)\n\\Bigg)\n\\Bigg)\n\\\\\n%\n\\end{align*}\n%\nThese results are summarized in Table \\ref{tab:thirdOrder}.\n\n\\begin{table*}[t!]\n\t\\centering\n\t\\renewcommand{\\arraystretch}{2}\n\t\\begin{tabular}{ccc}\n\t\\rowcolor[gray]{0.9} \\textbf{Component} & \\textbf{Input} & \\textbf{Output} \\\\\n\tFirst Value & \n\t$s_{i}$ & \n\t$f_{i} \\! \\left( s_{j} \\right)$ \n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\tFirst Gradient & \n\t$\\delta s_{i}$ &\n\t$\\displaystyle \\sum_{j} \\delta s_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) $\n\t\\\\\n\tSecond Value & \n\t$\\delta t_{i}$ & \n\t$\\displaystyle \\sum_{j} \\delta t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)$\n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\tSecond Gradient & \n\t$\\delta^{2} t_{i}$ &\n\t$\\displaystyle \\sum_{j} \\delta^{2} t_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n\t+ \\sum_{jk} \\delta s_{k} \\, \\delta t_{j} \n\t\\frac{ \\partial f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)$\n\t\\\\\n\tThird Value & \n\t$\\delta u_{i}$ &\n\t$\\displaystyle \\sum_{j} \\delta u_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)$\n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\tThird Gradient & \n\t$\\delta^{2} u_{i}$ &\n\t$\\displaystyle \\sum_{j} \\delta^{2} u_{j} \n\t\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) \n\t+ \\sum_{jk} \\delta s_{k} \\, \\delta u_{j} \n\t\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)$\n\t\\\\\n\tFourth Value & \n\t$\\delta^{2} v_{i}$ & \n\t$\\displaystyle \\sum_{j} \\delta^{2} v_{j} \\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right)\n\t\\delta u_{j} \\delta t_{k} \n\t\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right)$\n\t\\\\\n\t\\rowcolor[gray]{0.9} \n       \\multirow{3}{*}{ \\vspace{-8mm} Fourth Gradient} & \n\t\\multirow{3}{*}{ \\vspace{-8mm} $\\delta^{3} v_{i}$} &\n\t$\\displaystyle \\sum_{j} \\delta^{3} v_{j} \n\t\\frac{ \\partial f_{i} }{ \\partial x_{j} } \\! \\left( s_{j} \\right) $ \n\t\\\\ \n\t& &\n\t$\\displaystyle + \\sum_{jk} \\left( \n\t\\delta s_{k} \\, \\delta^{2} v_{j} + \\delta u_{j} \\, \\delta^{2} t_{k} + \\delta^{2} u_{j} \\, \\delta t_{k}  \\right)\n\t\\frac{ \\partial^{2} f_{i} }{ \\partial x_{j} \\partial x_{k} } \\! \\left( s_{j} \\right) $ \n\t\\\\\n\t\\rowcolor[gray]{0.9} \n\t& &\n\t$ \\displaystyle+ \\sum_{jkl} \\delta u_{j} \\delta t_{k} \\, \\delta s_{l} \n\t\\frac{ \\partial^{3} f_{i} }{ \\partial x_{j} \\partial x_{k} \\partial_{l} } \\! \\left( s_{j} \\right) $\n\t\\\\\n\t\\end{tabular}\n\t\\caption{Recursively expanding an input function yields its action\n\ton a third-order dual number input.\n\t\\label{tab:thirdOrder}}\n\\end{table*}\n\nA forward sweep of third-order autodiff yields a wealth of information.  In addition\nto the function evaluation we have three different first-order scalar-valued directional \nderivatives, three different second-order scalar-valued directional derivatives,\nand a single third-order scalar-valued directional derivative.\n\nAs above, reverse mode requires a separation of values and gradients.  A\npreliminary forwards sweep first builds the expression graph and computes the\nfunction, three first-order scalar-valued directional derivatives, and a second-order\nscalar-valued directional derivative.  Given the values we can define adjoint\nJacobians and sweep backwards, generating the vector-valued gradient,\ntwo second-order vector-valued directional derivatives, and one third-order\nvector-valued directional derivative.\n\n\\subsection*{Higher-Order Techniques}\n\nLastly let's review some techniques for computing various differential objects that\nare common in statistical and optimization applications.  Here we focus on many-\nto-one functions, $f : \\mathbb{R}^{n} \\rightarrow 1$.\n\n\\begin{description}\n\t\n\t\\item[Directional Derivative] \\hfill \\\\\n\t\n\t\\begin{description}\n\t\t\\item[Form:] $\\displaystyle \\vec{v} \\cdot \\vec{g} = \\sum_{i} v_{i} \\frac{ \\partial f }{ \\partial x_{i} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\delta x_{i} = v_{i}$. \\\\\n\t\tCompute first-order forward sweep. \\\\\n\t\tReturn first gradient of output.\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( 1 \\right)$\n\t\t\\item[Adjuncts:] $ f $\n\t\\end{description}\n\n\t\\item[Gradient] \\hfill \\\\\n\t\\begin{description}\n\t\t\\item[Form:] $\\displaystyle \\vec{g} = \\frac{ \\partial f }{ \\partial x_{i} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\mathrm{d} f = 1$. \\\\\n\t\tCompute first-order reverse sweep. \\\\\n\t\tReturn first gradient of inputs.\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( 1 \\right)$\n\t\t\\item[Adjuncts:] $ f $\n\t\\end{description}\n\t\n\t\\item[Hessian Quadratic Form] \\hfill \\\\\n\t\\begin{description}\n\t\t\\item[Form:] \n\t\t$\\displaystyle \\vec{v\\,}^{T} H \\, \\vec{u} = \\sum_{ij} v_{i} u_{j} \\frac{ \\partial^{2} f }{ \\partial x_{i} \\partial x_{j} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\delta x_{i} = v_{i}, \\, \\delta y_{i} = u_{i}, \\delta^{2} y_{i} = 0$. \\\\\n\t\tCompute second-order forward sweep. \\\\\n\t\tReturn second gradient of output.\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( 1 \\right)$\n\t\t\\item[Adjuncts:] $ f, \\vec{v} \\cdot \\vec{g}, \\vec{u} \\cdot \\vec{g}$\n\t\\end{description}\n\t\n\t\\item[Hessian-Vector Product] \\hfill \\\\\n\t\\begin{description}\n\t\t\\item[Form:] $\\displaystyle H \\vec{v} = \\sum_{j} v_{j} \\frac{ \\partial^{2} f }{ \\partial x_{i} \\partial x_{j} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\mathrm{d} f = 1$. \\\\\n\t\tCompute first-order reverse sweep for first gradients. \\\\\n\t\tInitialize $\\delta y_{i} = v_{i}$. \\\\\n\t\tPropagate second values in a forward sweep. \\\\\n\t\tInitialize $\\mathrm{d}^{2} f = 0.$ \\\\\n\t\tCompute second-order reverse sweep. \\\\\n\t\tReturn second gradient of inputs.\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( 1 \\right)$\n\t\t\\item[Adjuncts:] $ f, \\vec{v} \\cdot \\vec{g}, \\vec{g}$\n\t\\end{description}\n\t\n\t\\item[Hessian] \\hfill \\\\\n\t\\begin{description}\n\t\t\\item[Form:] $\\displaystyle \\frac{ \\partial^{2} f }{ \\partial x_{i} \\partial x_{j} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\mathrm{d} f = 1$. \\\\\n\t\tCompute first-order reverse sweep for first gradients. \\\\\n\t\tFor each $j$ compute the $j$th row of the Hessian as:\n\t\t\\begin{itemize}\n\t\t\t\\setlength{\\itemsep}{0cm}\n\t\t\t\\setlength{\\parskip}{0cm}\n\t\t\t\\item[] Initialize $\\delta y_{i} = \\delta^{j}_{i}$.\n\t\t\t\\item[] Propagate second values in a forward sweep. \n\t\t\t\\item[] Initialize $\\mathrm{d}^{2} f = 0.$\n\t\t\t\\item[] Compute second-order reverse sweep.\n\t\t\t\\item[] Return second gradient of inputs\n\t\t\\end{itemize}\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( n \\right)$\n\t\t\\item[Adjuncts:] $ f, \\vec{g}$\n\t\\end{description}\n\t\n\t\\item[Gradient of the Trace of a Matrix Hessian Product] \\hfill \\\\\n\t\\begin{description}\n\t\t\\item[Form:] \n\t\t$\\displaystyle \\frac{\\partial}{\\partial x_{i} } \\mathrm{Tr} \\! \\left[ M \\cdot H \\right]\n\t\t= \\sum_{jk} M_{jk} \\frac{ \\partial^{3} f }{ \\partial x_{i}  \\partial x_{j}  \\partial x_{k} } $\n\t\t\\item[Algorithm:] \\hfill \\\\\n\t\tInitialize $\\mathrm{d} f = 1$. \\\\\n\t\tCompute first-order reverse sweep for first gradients. \\\\\n\t\tInitialize the trace gradient to zero.\n\t\tFor each $j$ increment the trace gradient with:\n\t\t\\begin{itemize}\n\t\t\t\\setlength{\\itemsep}{0cm}\n\t\t\t\\setlength{\\parskip}{0cm}\n\t\t\t\\item[] Initialize $\\delta t_{i} = \\delta^{j}_{i}$.\n\t\t\t\\item[] Propagate second values in a forward sweep. \n\t\t\t\\item[] Initialize $\\mathrm{d}^{2} f = 0$.\n\t\t\t\\item[] Compute second-order reverse sweep.\n\t\t\t\\item[] Initialize $\\delta u_{i} = M_{ji}, \\delta^{2} v_{i} = 0$.\n\t\t\t\\item[] Propagate third and fourth values in a  forward sweep.\n\t\t\t\\item[] Initialize $\\mathrm{d}^{3} f = 0$.\n\t\t\t\\item[] Compute third-order reverse sweep.\n\t\t\t\\item[] Return the fourth gradient of the inputs.\n\t\t\\end{itemize}\n\t\t\\item[Cost:] $\\mathcal{O} \\! \\left( n \\right)$\n\t\t\\item[Adjuncts:] $ f, \\vec{g}, H$\n\t\\end{description}\n\t\n\\end{description}\n\n\\end{document}\n", "meta": {"hexsha": "4561da3e40ccc35d2f12f7e537724c15539847d0", "size": 40883, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/autodiff.tex", "max_stars_repo_name": "stan-dev/nomad", "max_stars_repo_head_hexsha": "a21149ef9f4d53a198e6fdb06cfd0363d3df69e7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2015-12-11T20:06:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-15T18:59:58.000Z", "max_issues_repo_path": "doc/autodiff.tex", "max_issues_repo_name": "stan-dev/nomad", "max_issues_repo_head_hexsha": "a21149ef9f4d53a198e6fdb06cfd0363d3df69e7", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-12-15T08:12:01.000Z", "max_issues_repo_issues_event_max_datetime": "2016-07-17T01:36:56.000Z", "max_forks_repo_path": "doc/autodiff.tex", "max_forks_repo_name": "stan-dev/nomad", "max_forks_repo_head_hexsha": "a21149ef9f4d53a198e6fdb06cfd0363d3df69e7", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-10-13T17:40:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-08T19:17:51.000Z", "avg_line_length": 39.1224880383, "max_line_length": 159, "alphanum_fraction": 0.6157082406, "num_tokens": 16408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.41441299321977715}}
{"text": "\\clearpage\n\\newpage\n\n\n\\section{Results}\n\\paragraph{Statistical errors}  We used  coalescent simulations of neutral polymorphisms under spatial models of admixture to compare the statistical errors of the AQP and APLS estimates with those of the {\\tt tess3} algorithm. The ground truth for the $Q$-matrix (${\\bf Q}_0$)  was computed from the mathematical model for admixture proportions used to generate the data. For the $G$-matrix, the  ground truth matrix (${\\bf G}_0$) was computed from the empirical genotype frequencies in the two population samples before an admixture event.  The root mean squared errors (RMSE) for the ${\\bf Q}$ and ${\\bf G}$ estimates decreased as the sample size and the number of loci increased (Figure 1). For all algorithms, the statistical errors were generally small when the number of loci was greater than $10$k SNPs. Those results provided evidence that the three algorithms produced equivalent estimates of the matrices ${\\bf Q}_0$ and ${\\bf G}_0$. The results also provided a formal check that the APLS and {\\tt tess3} algorithms converged to the same estimates as those obtained after the application of  the AQP algorithm, which is guaranteed to converge mathematically.   \n\n\n\\paragraph{The benefit of including spatial information in algorithms}    Using  neutral coalescent simulations of spatial admixture, we compared the statistical estimates obtained from a spatial algorithm (APLS) and a non-spatial algorithm (sNMF, Frichot et al. 2014).  For various levels of ancestral population differentiation, estimates obtained from the spatial algorithm were more accurate than for those obtained using non-spatial approaches (Figure 2). For the larger samples, much finer population structure was detected with the spatial method than with the non-spatial algorithm (Figure 2). \n\nIn simulations of outlier loci, we used the area under the precision-recall curve (AUC) for quantifying the performances of tests based on the estimates of ancestry matrices, {\\bf Q} and {\\bf G}. In addition, we computed AUCs for $F_{\\rm ST}$-based neutrality tests using truly ancestral genotypes. As they represented the maximum reachable values, AUCs based on truly ancestral genotypes were always higher than those obtained for tests based on reconstructed matrices. For all values of the relative  selection intensity, AUCs were higher for spatial methods than for non-spatial methods (Figure 3, the relative selection intensity is the ratio of migration rates at neutral and adaptive loci). For high selection intensities, the performances of tests based on estimates of ancestry matrices were close to the optimal values reached  by tests based on true ancestral frequencies. These results provided evidence that including spatial information in ancestry estimation algorithms improves the detection of signatures of hard selective sweeps having occurred in unknown ancestral populations. \n\n\\paragraph{Runtime and convergence analyses} We subsampled a large SNP data set for {\\it A. thaliana} ecotypes  to compare the convergence properties and runtimes of the {\\tt tess3}, AQP, and APLS algorithms. In those experiments, we used $K = 6$ ancestral populations, and replicated 5 runs for each simulation. For $n = 100-600$ individuals ($L = 50$k SNPs), the APLS algorithm required more iterations (25 iterations)  than the AQP algorithm (20 iterations) to converge to its solution  (Figure 4). This was less than for {\\tt tess3} (30 iterations).  For $L = 10-200$k SNPs ($n = 150$ individuals), similar results were observed. For $50$k SNPs, the runtimes were significantly lower for the APLS algorithm than for the {\\tt tess3} and AQP algorithms. For $L = 50$k SNPs and $n = 600$ individuals, it took on average 0.956 min for the APLS and 100 min for the AQP algorithm to compute ancestry estimates. For {\\tt tess3}, the runtime was on average 66.3 min. For $L = 100$k SNPs and $n = 150$ individuals, it took on average 0.628 min (8.97 min) for the APLS (AQP) algorithm to compute ancestry estimates. For {\\tt tess3}, the runtime was on average 1.27 min.  For those values of $n$ and $L$, the APLS algorithm implementation ran about 2 to 100 times faster than the other algorithm implementations.\n \n \n\\paragraph{Application to European ecotypes of {\\it Arabidopsis  thaliana}} We used  the APLS algorithm to survey spatial population genetic structure and perform a genome scan for adaptive alleles in European ecotypes of the plant species {\\it A.  thaliana}. The cross validation criterion decreased rapidly from $K=1$ to $K=3$ clusters,  indicating  that  there were three main ancestral groups in Europe, corresponding to geographic regions in Western Europe, Eastern and Central Europe and Northern Scandinavia. For $K$ greater than four, the values of the cross validation criterion decreased in a slower way, indicating that subtle substructure resulting from complex historical isolation-by-distance  processes could also be detected (Figure 5). The spatial analysis provided an approximate range of  $\\sigma = 150$km for the spatial variogram (Figure 5). Figure 6 displays the $Q$-matrix estimate  interpolated on a geographic map of Europe for $K = 6$ ancestral groups. The estimated admixture coefficients provided clear evidence for the clustering of the ecotypes in spatially homogeneous genetic groups. \n\n\\paragraph{Targets of selection in {\\it A.  thaliana} genomes}  Tests based on the $F^Q_{\\rm ST}$  statistic were applied to the 241k SNP data set to reveal new targets of natural selection in the {\\it A. thaliana} genome. {\\it A. thaliana} occurs in a broad variety of habitats, and local adaptation to the environment is acknowledged to be important in shaping its genetic diversity through space~\\citep{Hancock2011, Fournier-Level2011}. \nThe APLS algorithm was run on the 1,095 European lines of {\\it A. thaliana} with $K=6$ ancestral populations and $\\sigma = 1.5$ for the range parameter. After controlling the FDR at the level $1\\%$, the program produced a list of 12,701 candidate SNPs, including linked loci and representing 3\\% of the total number of loci. \n The top 100 candidates included SNPs in the flowering-related genes SHORT VEGETATIVE PHASE (SVP), COP1-interacting protein 4.1 (CIP4.1) and FRIGIDA (FRI) ($p$-values $< 10^{-300}$). These genes were detected by previous scans for selection on this dataset~\\citep{Horton2012}.\n We performed a gene ontology enrichment analysis using AmiGO in order to evaluate which biological functions might be involved in local adaptation in Europe. \n We found a significant over-representation of genes involved in cellular processes (fold enrichment of 1.06, $p$-value equal to 0.0215 after Bonferonni correction).\n\n\n", "meta": {"hexsha": "59b82949e8ea8e939b4ac1909f6c34cecb727777", "size": 6717, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2Article/TESS3Article-master/Article/results.tex", "max_stars_repo_name": "cayek/Thesis", "max_stars_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2Article/TESS3Article-master/Article/results.tex", "max_issues_repo_name": "cayek/Thesis", "max_issues_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2Article/TESS3Article-master/Article/results.tex", "max_forks_repo_name": "cayek/Thesis", "max_forks_repo_head_hexsha": "14d7c3fd03aac0ee940e883e37114420aa614b41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 268.68, "max_line_length": 1305, "alphanum_fraction": 0.7881494715, "num_tokens": 1559, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4144129899735569}}
{"text": "\\documentclass[letterpaper,12pt,addpoints,answers]{exam}\n%\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\n\\usepackage[top=1in, bottom=1in, left=0.75in, right=0.75in]{geometry}\n\\usepackage{amsmath,amssymb,graphicx,xcolor,asymptote}\n\\usepackage[pdf]{graphviz}\n\\usepackage{float}\n\n\\newcommand{\\university}{SANTA MONICA COLLEGE}\n\\newcommand{\\faculty}{Department of Mathematics}\n\\newcommand{\\class}{Math 10}\n\\newcommand{\\examnum}{Final Exam}\n\\newcommand{\\content}{Discrete Structures}\n\\newcommand{\\examdate}{June 6-8, 2021}\n\\newcommand{\\timelimit}{12AM-11:59PM}\n\n\\newcommand{\\tf}{$\\quad\\quad T\\quad F$}\n\\newcommand{\\tft}{$\\quad\\quad \\boxed T\\quad F$}\n\\newcommand{\\tff}{$\\quad\\quad T\\quad \\boxed F$}\n\\newcommand{\\tfnt}{$\\quad\\quad \\boxed T\\quad F\\quad$neither}\n\\newcommand{\\tfnf}{$\\quad\\quad T\\quad \\boxed F\\quad$neither}\n\\newcommand{\\tfnn}{$\\quad\\quad T\\quad F\\quad \\boxed{\\text{ neither}}$}\n\\newcommand{\\tfn}{$\\quad\\quad T\\quad F\\quad$neither}\n\n\n\\pagestyle{headandfoot}\n\\firstpageheader{}{}{}\n\\firstpagefooter{}{Page \\thepage\\ of \\numpages}{}\n\\runningheader{\\class}{\\examnum}{\\examdate}\n\\runningheadrule\n\\runningfooter{}{Page \\thepage\\ of \\numpages}{}\n\n\\begin{document}\n\n\\title{\\Large \\textbf{\\university\\\\ \\faculty\\\\\n        \\bigskip\n        \\class -- \\examnum }}\n\\author{Instructor: Kevin Arlin}\n\\date{\\examdate}\n\\maketitle\n\\noindent \\rule{\\textwidth}{1pt}\n\nSubmit your work, typed, as a .pdf or .tex file on Canvas as usual.\n\nThis exam allows one sheet of handwritten notes. Handheld calculators are allowed.\n\\textcolor{red}{It is not open Internet.}  I take\nacademic honesty during COVID even more seriously than usual, and have been known to\nbe rather vindictive when I see solutions that were garnered online. Nobody wants that.\nDon't do it. I am generous with curves for honest students.\n\nShow your work. Partial credit will be given when earned. Explanations are\nrequired unless explicitly not requested.\n\n\n\\begin{center}\n    \\textbf{Distribution of Points}\\\\\n    \\medskip\n    \\multicolumngradetable{2}[questions]\n\\end{center}\n\n\\clearpage\n\n\\begin{questions}\n\n    \\question For any string $s\\in A^*$ where $A=\\{a,b,c,d,\\ldots,x,y,z\\},$ say another\n    string in $A^*$ \\emph{avoids $s$} if $s$ does not occur as a substring.\n    \\begin{parts}\n        \\part[4] Derive a recurrence relation for the number $a_n$ of strings in $A^*$ that avoid the string `ck', including initial conditions.\n        \\begin{solutionorlines}[2in]\n            $a_1 = 26$, and $a_2 = 26 * 25$\n            Let $c_k$ be the number of strings in $A^*$ that do \\textbf{not} end in \\textit{'c'} and avoid the string \\textit{'ck'}.\n            $c_k = a_{k-1} * 25$, removing \\textit{'c'}.\n            $a_n = 25 * c_{n-1} * 26$, avoiding \\textit{'k'} when ending with \\textit{'c'} and allowing any letter otherwise.\n            \\begin{equation}\n                a_n = 25 * (a_{n-2} * 25) * 26\n            \\end{equation}\n        \\end{solutionorlines}\n        \\part[3] By finding a closed form for $a_n,$ how many digits does $a_{50}$ have? You may use a programming language or WolframAlpha for this.\n        \\setlength\\answerlinelength{5in}\n        \\answerline[$19151123960735656846813146744436007044769689232586820865 * 10^{49}$]\n        \\part[4] Derive a recurrence relation for the number $b_n$ of strings that avoid the string `ack'.\n        \\begin{solutionorlines}[2in]\n            $b_1 = 26$, $b_2 = 26 * 26$, $b_3 = 26 * 26 * 25$\n            Let $c_k$ be the number of strings in $A^*$ that do \\textbf{not} end in \\textit{'ac'} and avoid the string \\textit{'ack'}.\n            $c_k = a_{k-2} * 26 * 25$, removing \\textit{'c'}.\n            $b_n = 25 * c_{n-1} * 26$, avoiding \\textit{'ak'} when ending with \\textit{'ac'} and allowing any letter otherwise.\n            $$b_n = 25 * (b_{n-3} * 26 * 25) + 26$$\n        \\end{solutionorlines}\n        \\part[3] Compute $b_5$ using inclusion-exclusion.\n        \\begin{solutionorlines}[2in]\n            \\paragraph{Excluded Strings:} \\textit{ack\\textbf{xx}}, \\textit{\\textbf{x}ack\\textbf{x}}, and \\textit{\\textbf{xx}ack}\n            $$n(excluded) = 3 * 26^2$$\n            $$b_5 = 26^5 - 3 * 26^2 = 11879348$$\n        \\end{solutionorlines}\n    \\end{parts}\n    \\question\n    \\begin{parts}\n        \\part[4] Explain which axioms of an equivalence relation fail for the relation\n        ''there is a driving route of length less than $0.25$ miles between $x$ and $y$'' on the set of all points in Santa Monica.\n        \\begin{solutionorlines}[3in]\n            The relation isn't transitive, as the route from point $A$ to point $B$, and the route from point $B$ to point $C$ can both be less than $0.25$ miles, that does not mean that the rounte $A \\to B$ is less than $0.25$ miles.\n        \\end{solutionorlines}\n        \\part[6] Give an example of an equivalence relation on the set $\\mathbb Z$ of integers under which all primes are equivalent, and such that the number of equivalence classes equals the total number of letters in your first and last name combined.\n        \\setlength\\answerlinelength{5in}\n        \\answerline[has the same number of factors modulo 17 as]\n        \\begin{solutionorlines}[1in]\n            Since all primes only have themselves and $1$ as factors, they all have $2$ factors.\n\n            Furthermore, since I added the modulo 17, there are only 17 equivalence classes, as it wraps back around to 0.\n        \\end{solutionorlines}\n    \\end{parts}\n\n    \\question[4] Give a natural example of a predicate $P$ of domain the set $H$ of all humans such that $\\forall x\\in H \\exists y \\in H (P(x,y))$ is true but $\\exists y\\in H\\forall x\\in H (P(x,y))$ is false.\n    \\setlength\\answerlinelength{5in}\n    \\answerline[$P$ is whether $x$ is a biological child of $y$]\n    \\begin{solutionorlines}\n        Since all humans $x$ have a parent (excluding the edge case of first human, as that begets the chicken-egg problem), but there is no human $y$ that is a child to ALL humans $x$, as humans typically have $2$ biological parents.\n    \\end{solutionorlines}\n\n    \\question[5] State and prove which natural numbers can be written in the form $6x+10y$ for some $x,y\\in \\mathbb N.$\n\n    \\begin{solutionorlines}[5in]\n        \\paragraph{Base case $16$:} $10 (1) + 6(1) = 16$\n        \\paragraph{Inductive Case:} Assume $a_{x,y}$ is can be written in the form $6x+10y$.\n        Then $a_{x,y+1}$ can also be written as $6x+10(y + 1)$, as $a_{x,y+1} = a_{x,y} + 10$.\n        \\paragraph{Inductive Case:} Assume $a_{x,y}$ is can be written in the form $6x+10y$.\n        Then $a_{x+1,y}$ can also be written as $6(x + 1)+10y$, as $a_{x+1,y} = a_{x,y} + 6$.\n\n        Therefore $16,22,26,28,32,34,36,\\dots$ can be written in the form $6x+10y$.\n\n        $a_1 = 16 + 6 = 22$\n        $a_2 = 16 + 10 = 26$\n        $a_3 = 16 + 6 + 6 = 28$\n\n        Since from these we can add $10$ any number of times, we get that all even numbers greater than 20 can be written in the form $6x+10y$.\n    \\end{solutionorlines}\n\n    \\question Consider the graph $G=K_{3,4}.$\n    \\begin{parts}\n        \\part[3] Does $G$ have an Euler circuit? (Why not, if not?)\n        \\begin{solutionorlines}[2in]\n            No, since there is no way to go from the last bottom node you have back to the start without going through a used top node.\n        \\end{solutionorlines}\n        \\part[3] Does $G$ have a Hamilton circuit? (Why not, if not?)\n        \\begin{solutionorlines}[2in]\n            No, since there is no euler circuit, it is impossible to get a Hamilton circuit.\n        \\end{solutionorlines}\n        \\part[4] Is $G$ planar? If so, explain how to draw it without any edges crossing (you may upload a drawing in this case.) If not, prove it is not.\n        \\begin{solutionorbox}[2in]\n            \\begin{figure}[H]\n                \\digraph{abc}{\n                    rankdir=TB;\n                    subgraph top {\n                            T1;\n                            T2;\n                            T3;\n                        }\n                    subgraph bottom {\n                            B1;\n                            B2;\n                            B3;\n                            B4;\n                        }\n                    T1 -> B1 [shape=none];\n                    T1 -> B2 [shape=none];\n                    T1 -> B3 [shape=none];\n                    T1 -> B4 [shape=none];\n                    T2 -> B1 [shape=none];\n                    T2 -> B2 [shape=none];\n                    T2 -> B3 [shape=none];\n                    T2 -> B4 [shape=none];\n                    T3 -> B1 [shape=none];\n                    T3 -> B2 [shape=none];\n                    T3 -> B3 [shape=none];\n                    T3 -> B4 [shape=none];\n                }\n            \\end{figure}\n        \\end{solutionorbox}\n        \\part[6] What are all the isomorphisms $\\varphi: G\\to G$?\n        \\begin{solutionorlines}[2in]\n            Since the top and bottom have no set order, there are $3! * 4! = 144$ ways to draw $G$.\n        \\end{solutionorlines}\n    \\end{parts}\n\n    \\question Let's do some landscaping.\n    \\begin{parts}\n        \\part[3] How many ways are there to choose six trees from a landscaper that sells orange, lemon, lime, and kumquat trees?\n        \\answerline[$4^6 = 4096$]\n        \\begin{solution}\n            Since there are $6$ trees to choose from $4$ variants.\n        \\end{solution}\n        \\part[4] Supposing I bought two orange, two lemon, and two lime trees, how many ways are there to distribute my trees among three identical bins for transport home?\n        \\answerline[$3 * 2 = 6$]\n        \\begin{solution}\n            Assuming we are distributing evenly.\n\n            Since there are $3$ possible cominations to distribute the two orange trees, and another $2$ possible cominations to distribute the two lime trees, and only one way to distribute the lemon trees (into the remaining spots).\n        \\end{solution}\n        \\part[7] Let $n$ be the number of ways to arrange my six trees along my driveway. There\n        are several possibilities for $n$ depending on how my trees are distributed among the\n        four species. What are all of these possibilities?\n        \\begin{solutionorlines}[2in]\n            $$\\sum_{o=0}^6 \\sum_{l=0}^{6-o} \\sum_{k=0}^{6-l-o} \\frac{6!}{o!l!k!(6-o-l-k)!}$$\n            Counting the number of orange, lime, and kumquat (and the rest are lemon), sum all the possibilities.\n        \\end{solutionorlines}\n    \\end{parts}\n\\end{questions}\n\\end{document}\n", "meta": {"hexsha": "2ebbb305d192f68a4cec368f272e98777b93446c", "size": 10415, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Tests/Final.tex", "max_stars_repo_name": "eschablowski/Math-10", "max_stars_repo_head_hexsha": "550ccc9222c29cb7f6bcd146b5b6b26808ce470f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tests/Final.tex", "max_issues_repo_name": "eschablowski/Math-10", "max_issues_repo_head_hexsha": "550ccc9222c29cb7f6bcd146b5b6b26808ce470f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tests/Final.tex", "max_forks_repo_name": "eschablowski/Math-10", "max_forks_repo_head_hexsha": "550ccc9222c29cb7f6bcd146b5b6b26808ce470f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5952380952, "max_line_length": 254, "alphanum_fraction": 0.615362458, "num_tokens": 3077, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.41433953706325344}}
{"text": "\\documentclass[bigger]{beamer}\n\n\\input{header-beam} % change to header-handout for handouts\n\n% ====================\n\\title[Lecture 8]{Logic I F13 Lecture 8}\n\\date{October 3, 2013}\n% ====================\n\n\\include{header}\n\n\\section{Review of Rules}\n\n\\subsec{$\\land$Intro}{\n\nIf $A$ and $B$ are both true, then $A \\land B$ is true\n\\bigskip\n\\setlength{\\fitchprfwidth}{1.2in}\n\\fitchctx{\n\\nline[$n.$]{A}\\\\\n\\nline[$m.$]{B}\\\\\n\\fpline[\\quad]{A \\land B}[\\landi{n}{m}]}\n\n}\n\n\\subsec{$\\land$Elim}{\n\nIf $A \\land B$ is true, then $A$ ($B$) is true\n\\bigskip\n\\begin{tabular}{@{}ll@{}}\n\\setlength{\\fitchprfwidth}{1in}\n\\fitchctx{\n\\nline[$n.$]{A \\land B}\\\\\n\\fpline[\\quad]{A}[\\lande{n}]}\n&\\setlength{\\fitchprfwidth}{1in}\n\\fitchctx{\n\\nline[$n.$]{A \\land B}\\\\\n\\fpline[\\quad]{B}[\\lande{n}]}\n\\end{tabular}\n}\n\n\\subsec{$\\lor$Intro}{\n\nIf $A$ ($B$) is true, then $A \\lor B$ is true\n\\bigskip\n\\begin{tabular}{@{}ll@{}}\n\\setlength{\\fitchprfwidth}{1in}\n\\fitchctx{\n\\nline[$n.$]{A}\\\\\n\\fpline[\\quad]{A \\lor B}[\\lori{n}]}\n&\\setlength{\\fitchprfwidth}{1in}\n\\fitchctx{\n\\nline[$n.$]{B}\\\\\n\\fpline[\\quad]{A \\lor B}[\\lori{n}]}\n\\end{tabular}\n}\n\n\\subsec{$\\lor$Elim}{\n\nFormal version of proof by cases\n\\bigskip\n\\bigskip\n\\setlength{\\fitchprfwidth}{1.2in}\n\\fitchctx{\n\\nline[$j.$]{A \\lor B}\\\\\n\\subproof{\\nline[$k.$]{A}}{\\dots\\\\ \\nline[$l.$]{C}}\n\\subproof{\\nline[$m.$]{B}}{\\dots\\\\ \\nline[$n.$]{C}}\n\\fpline[\\quad]{C}[\\lore{$j$}{$k$--$l$}{$m$--$n$}]}\n\n\n}\n\n\\subsec{Example}{\n\n\\fitchprf{\\pline[1.]{A \\lor (B \\land C)}}{\n\\subproof{\\pline[2.]{A}}{\\pline[3.]{A \\lor B}[\\lori{2}]}\n\\subproof{\\pline[4.]{B \\land C}}{\n\\pline[5.]{B}[\\lande{4}]\\\\\n\\pline[6.]{A \\lor B}[\\lori{5}]}\n\\pline[7.]{A \\lor B}[\\lore{1}{2--3}{4--6}]\n}}\n\n\n\\section{Indirect Proof}\n\n\n\\subsec{Indirect Proof}{\n\n\\begin{quote}\nTo prove that $A$ is true (false), you may proceed by pretending that\n$A$ is false (true), and showing that that's impossible.\n\\end{quote}\n\n\\bit\n\\item ``show that's impossible'': prove something known to be false,\n  e.g., proving a claim that is in conflict with the premises, or\n  outright contradictory\n\\item ``proof by contradiction'' = ``reductio (ad absurdum)'' =\n  indirect proof \\eit\n\n}\n\n\\subsec{Galileo on Falling Bodies}{ \n\nFrom Galileo Galilei's, \\textit{Discourses and Mathematical\n  Demonstrations Relating to Two New Sciences}, 1638.\n\\medskip\n\n\\emph{Simplicio.}  There can be no doubt but\n  that one and the same body moving in a single medium has a fixed\n  velocity which is determined by nature and which cannot be increased\n  except by the addition of momentum or diminished except by some\n  resistance which retards it.\n\\medskip\n\n\\emph{Salviati.}  If then we take two bodies whose natural speeds are\ndifferent, it is clear that on uniting the two, the more rapid one\nwill be partly retarded by the slower, and the slower will be somewhat\nhastened by the swifter. Do you not agree with me in this opinion?\n\\medskip \n\n\\emph{Simp.}  You are unquestionably right.}\n\\subsec{Galileo on Falling Bodies}{ \n \n\\emph{Salv.}  But if this is true, and if a large stone moves with a speed\nof, say, eight while a smaller moves with a speed of four, then when\nthey are united, the system will move with a speed less than eight;\nbut the two stones when tied together make a stone larger than that\nwhich before moved with a speed of eight.  Hence the heavier body\nmoves with less speed than the lighter; an effect which is contrary to\nyour supposition.  Thus you see how, from your assumption that the\nheavier body moves more rapidly than the lighter one, I infer that the\nheavier body moves more slowly.\n}\n\n\n\\subsec{Disjunctive Syllogism}{\n\n\\setlength{\\fitchprfwidth}{1.2in}\n\n\\begin{columns}\n\\begin{column}{3cm}\n\\fitchprf{\n\\nline{A \\lor B}\\\\\n\\nline{\\lnot A}}{\\nline{B}}\n\\end{column}\n\\begin{column}{7cm}\n\\bens\n\\item Suppose $\\sf B$\nwere not true.  \n\\item By premise 1, $\\sf A \\lor B$ is true. \n\\item Case 1.  $\\sf A$ is\ntrue. By premise 2, $\\sf \\lnot A$ is true, so we have a contradiction.\n\\item Case 2. $\\sf B$ is true. This contradicts the assumption that $\\sf B$ is false, so again we have a contradiction. \n\\item So by proof by\ncases, we have proved a contradiction from the assumption that $\\sf \nB$ is not true. \n\\item So $\\sf B$ must be true, by indirect proof. QED.\n\\een\n\\end{column}\n\\end{columns}\n}\n\n\n\\subsec{Rules for $\\lnot$}{\n\n\\setlength{\\fitchprfwidth}{.9in}\n\\fitchctx{\n\\subproof{\\nline[$k.$]{A}}{\\dots\\\\ \\nline[$l.$]{\\bot}}\n\\fpline[\\quad]{\\lnot A}[\\lnoti{$k$--$l$}]}\n\\fitchctx{\n\\subproof{\\nline[$k.$]{\\lnot A}}{\\dots\\\\ \\nline[$l.$]{\\bot}}\n\\fpline[\\quad]{A}[\\lnoti{$k$--$l$}]}\n\n\\bigskip\n\\fitchctx{\n\\nline[$k.$]{\\lnot\\lnot A}\\\\\n\\fpline[\\quad]{A}[\\lnote{k}]}\n\n}\n\n\\subsec{Rules for $\\bot$}{\n\n\\fitchctx{\n\\nline[$k.$]{A}\\\\\n\\nline[$l.$]{\\lnot A}\\\\\n\\fpline[\\quad]{\\bot}[\\lfalsei{k}{l}]}\n\\bigskip\n\\setlength{\\fitchprfwidth}{.9in}\n\\fitchctx{\n\\nline[$k.$]{\\bot}\\\\\n\\fpline[\\quad]{A}[\\lfalsee{k}]}\n\n}\n\n\\subsec{Disjunctive Syllogism}{\n\n\\setlength{\\fitchprfwidth}{1.2in}\n\n\\fitchprf{\n\\nline{A \\lor B}\\\\\n\\nline{\\lnot A}}{\\nline{B}}\n}\n\n\\subsec{De Morgan's Law}{\n\\setlength{\\fitchprfwidth}{1.2in}\n\n\\fitchprf{\n\\nline{A \\lor B}}{\\nline{\\lnot(\\lnot A \\land \\lnot B)}}\n}\n\n\\section{Proofs from Contradictory Premises}\n\n\\subsec{Proofs from Contradictory Premises}{\n\n\\begin{quote}\nAny argument with TT-contradictory premises is tautologically valid.\n\\end{quote}\n\n}\n\n\\subsec{Proofs from Contradictory Premises}{\n\n\\begin{columns}\n\\begin{column}{3cm}\n\\fitchprf{\n\\pline{Small(b)}\\\\\n\\pline{\\lnot Small(b)}}{\n\\pline{Tet(a)}}\n\\end{column}\n\\begin{column}{7cm}\n\\bens\n\\item Suppose, by way of contradiction, that $\\sf \\lnot Tet(a)$. \n\\item We are told (premise 1) that $\\sf\nSmall(b)$. \n\\item We are also told (premise 2) that $\\sf \\lnot\nSmall(b)$. \n\\item That's a contradiction. \n\\item So $Tet(a)$ by indirect proof. QED.\n\\een\n\\end{column}\n\\end{columns}\n}\n\n\\end{document}\n\n\\section{Proof Strategies}\n\n\\subsec{Strategy for Proving Conjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{}\n}{\n \\ellipsesline \\\\\n \\pline[2.]{} \\\\\n \\ellipsesline \\\\\n \\pline[3.]{} \\\\\n \\pline[4.]{P \\land Q}[\\hphantom{\\landi{2}{3}}]\n} \n  &\nIf we want to prove $\\sf P \\land Q$, we have to use $\\land$Intro.\n\\end{tabular}\n\n}\n\n\\subsec{Strategy for Proving Conjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n  \\fitchprf{\\pline[1.]{}}{\n    \\ellipsesline \\\\\n    \\pline[2.]{P} \\\\\n    \\ellipsesline \\\\\n    \\pline[3.]{Q} \\\\\n    \\pline[4.]{P \\land Q}[\\landi{2}{3}]\n  } \n  &\n  For $\\land$Intro, we need to prove $\\sf P$ first, then prove $\\sf Q$. For the last line,\n  we'll cite the lines where we proved $\\sf P$ and  $\\sf Q$, and use $\\land$Intro.\n\\end{tabular}\n}\n\n\n\n\\subsec{Strategy for Using Conjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{P \\land Q}\n}{\n \\pline{}[\\hphantom{\\lande{1}}] \\\\\n \\pline{} \\\\\n \\ellipsesline \\\\\n \\pline{R}\n} \n  &\nIf we want to use a sentence of the form $\\sf P \\land Q$ which is one\nof our premises, or a sentence we've already proved, use $\\land$Elim.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Using Conjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{P \\land Q}\n}{\n \\pline[2.]{P}[\\lande{1}]\\\\\n \\pline[3.]{Q}[\\lande{1}]\\\\\n \\ellipsesline \\\\\n \\pline{R}\n} \n& Use $\\land$Elim to ``split up'' $\\sf P \\land Q$, proving both $\\sf\nP$ and $\\sf Q$.  We'll probably need them further down in the proof.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Proving Disjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{}\n}{\n \\ellipsesline \\\\\n \\pline[2.]{} \\\\\n \\pline[3.]{P \\lor Q}[\\hphantom{\\lori{2}}]\n} \n  &\nWe want to prove $\\sf P \\lor Q$. We could do this using  $\\lor$Intro.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Proving Disjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline \\\\\n\\pline[2.]{P} \\\\\n\\pline[3.]{P \\lor Q}[\\lori{2}]\n} \n&\nFor $\\lor$Intro, we need to prove one of the disjuncts.\nWe'll try $\\sf P$ first. For the last line,\nwe'll cite the line where we proved $\\sf P$, and use $\\lor$Intro.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Proving Disjunctions}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline \\\\\n\\pline[2.]{Q} \\\\\n\\pline[3.]{P \\lor Q}[\\lori{2}]\n} \n&\nIf we can't prove $\\sf P$, we may have to backtrack and try to prove $\\sf Q$\ninstead.  Again, we'll cite the line where we proved $\\sf Q$, and use\n$\\lor$Intro.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Using Disjunctions}{\n\n\\setlength{\\fitchprfwidth}{.9in}\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{P \\lor Q}\n}{\n \\pline{}\\\\\n\\pline{} \\\\\n\\pline{}\\\\\n\\pline{} \\\\\n\\pline{} \\\\\n\\pline{} \\\\\n\\ellipsesline \\\\[.7em]\n  \\pline[6.]{R}[\\hphantom{\\lore{1}{2--3}{4--5}}]\n} \n  &\nSuppose we want to prove R, and we have $\\sf P \\lor Q$ as a premise,\nas the assumption of a subproof, or as something proved before.\nWe'll try to use it by applying $\\lor$Elim.\n\\end{tabular}\n\n}\n\n\\subsec{Strategy for Using Disjunctions}{\n\n\\setlength{\\fitchprfwidth}{.9in}\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{P \\lor Q} }{ \\subproof{\\pline[2.]{P}}{ \\ellipsesline \\\\\n\\pline[3.]{R}} \\subproof{\\pline[4.]{Q}}{ \\ellipsesline \\\\\n\\pline[5.]{R}} \\pline[6.]{R}[\\lore{1}{2--3}{4--5}] } \n& To prove $\\sf R$ using $\\lor$Elim from $\\sf P \\lor Q$, we'll have to\nlook for two subproofs: one in which we prove $\\sf R$ from $\\sf P$,\nanother where we prove $\\sf R$ from $\\sf Q$. Once we have both, we\ncan justify $\\sf R$ by using $\\lor$Elim, citing the line with $\\sf P\n\\lor Q$ and the two subproofs.\n\\end{tabular}\n}\n\n\\subsec{Strategy for Proving Negations}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{}\n}{\n \\pline{}\\\\\n\\pline{} \\\\\n\\pline{}\\\\\n\\ellipsesline \\\\[.7em]\n  \\pline[4.]{\\neg P}[\\hphantom{\\lnoti{2}}]\n} \n  &\nIf we want to prove $\\neg\\sf P$, we'll have to use  $\\neg$Intro.\n\\end{tabular}\n\n}\n\n\\subsec{Strategy for Proving Negations}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{P}}{\n\\ellipsesline \\\\\n\\pline[3.]{\\bot}}\n\\pline[4.]{\\neg P}[\\lnoti{2--3}]\n} \n& For $\\neg$Intro, we have to start a subproof with assumption $\\sf\nP$; the last line of the subproof has to be $\\bot$.  We'll cite the\nsubproof, and use $\\lnot$Intro.\n\\end{tabular}\n}\n\n\n\\subsec{Strategy for Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{}\n}{\n \\pline{}\\\\\n\\pline{} \\\\\n\\pline{}\\\\\n\\ellipsesline \\\\[.7em]\n  \\pline[4.]{P}[\\hphantom{\\lnoti{2}}]\n} \n& Sometimes, we want to prove a sentence $\\sf P$, but our other\nstrategies didn't get us far. This is often the case, e.g., when we\nwant to prove disjunctions but don't have any premises (for example:\n$\\sf A \\lor \\neg A$).  Then we can also use $\\neg$Intro.\n\\end{tabular}\n\n}\n\n\\subsec{Strategy for Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg P}}{\n\\ellipsesline \\\\\n\\pline[3.]{\\bot}}\n\\pline[4.]{P}[\\lnoti{2--3}]} \n&\nHere, we have to start a subproof with assumption $\\sf \\neg P$;\nthe last line of the subproof has to be $\\bot$.\nWe'll cite the subproof, and use $\\lnot$Intro.  In the subproof, we now\nhave an additional assumption (on line 2) to work with.\n\\end{tabular}\n\n}\n\n\\subsec{How to Find a Contradiction}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg P}}{\n\\pline{}\\\\\n\\ellipsesline \\\\\n\\pline[4.]{\\bot}}\n\\pline[5.]{P}[\\lnoti{2--3}]\n} \n&\nSuppose we used the indirect proof strategy, or we're in some other situation\nwhere we're looking for a proof of $\\bot$.  What's a good candidate?\n\\end{tabular}\n\n}\n\n\\subsec{How to Find a Contradiction}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg P}}{\n\\ellipsesline \\\\\n\\pline[3.]{P}\\\\\n\\pline[4.]{\\bot}[\\lfalsei{2}{3}]}\n\\pline[5.]{P}[\\lnoti{2--4}]\n} \n& One good candidate is $\\sf P$ itself!  This may look weird but\nremember that inside the subproof, we have an additional assumption\n$\\sf \\lnot P$ to work with.\n\\end{tabular}\n\n}\n\n\\subsec{How to Use a Negated Sentence}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\n   \\pline[1.]{\\neg P}\n}{\n \\pline{}\\\\\n\\pline{} \\\\\n\\pline{}\\\\\n\\ellipsesline \\\\[.7em]\n  \\pline[4.]{R}[\\hphantom{\\lnoti{2}}]\n} \n  &\nSuppose $\\sf\\neg P$ is one of your premises, or something else you've\nalready proved, and the sentence you're shooting for doesn't contain\n$\\sf \\neg P$. How are you going to make use of  $\\sf\\neg P$?\n\\end{tabular}\n\n}\n\n\\subsec{How to Use a Negated Sentence}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{\\neg P}}{\n\\subproof{\\pline[2.]{\\neg R}}{\n\\ellipsesline \\\\\n\\pline[3.]{P}\\\\\n\\pline[4.]{\\bot}[\\lfalsei{1}{3}]}\n\\pline[5.]{R}[\\lnoti{2--4}]\n} \n&\nThe only way to make use of $\\sf\\neg P$ in such a situation is as part\nof a contradiction. For instance, apply the indirect proof strategy,\nand then look for $\\sf P$ inside the subproof.\n\\end{tabular}\n\n}\n\n\\subsec{Summary}{\n\n\\bits\n\\item Trying to prove $\\sf P \\land Q$? Look for a proof of $\\sf P$,\n  then for a proof of $\\sf Q$ ($\\land$Intro).\n\\item Split up conjunctions ($\\land$Elim) whenever you can.\n\\item Next, use the disjunctions you have ($\\lor$Elim).\n\\item Trying to prove $\\sf\\neg P$? Look for a subproof of $\\bot$ from\n  $\\sf P$ ($\\neg$Intro).\n\\item Trying to prove $\\sf P \\lor Q$?  Look for a proof of $\\sf P$, if\n  that doesn't work, look for a proof of $\\sf Q$ ($\\lor$Intro). If\n  that doesn't work either, use indirect proof.  (Note: $\\lor$Intro\n  rarely works unless you're in a subproof.)\n\\item Apply the strategies at each step in the construction of your\n  proof. You may not be able to prove $\\sf P \\lor Q$ using $\\lor$Intro\n  at one point, but then you might find yourself in a subproof where\n  it is possible.\n\\eit\n}\n\n\\subsec{Summary}{\n\\bits\n\\item It's good to know where you're going: So use the strategies\n  based on $\\land$Intro, $\\lor$Elim, $\\neg$Intro before those based on\n  $\\land$Elim and $\\lor$Intro.\n\\item Picking a disjunct to prove for $\\lor$Intro or a candidate for a\n  contradiction doesn't always work. If it doesn't, you have to\n  backtrack and try something else.\n\\item If you're looking for a proof of $\\sf P$ and you're not getting\n  anywhere, make sure you're on the right track: is $\\sf P$ even a\n  tautological consequence of the premises and assumptions? If not,\n  you'll have to backtrack.\n\\end{itemize}\n\n}\n\n\\section{Examples}\n\n\\setlength{\\fitchprfwidth}{1.5in}\n\n\\subsec{An Example}{\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{(A \\land B) \\lor (A \\land C)}\n}{\n \\pline{}\\\\\n\\pline{} \\\\\n\\pline{}\\\\\n\\ellipsesline \\\\[.7em]\n  \\pline{A \\land (B \\lor C)}[\\hphantom{\\lore{1}{2--5}{6--9}}]\n} \n  &\nFirst, we use the disjunction on line 1, and set up the subproofs we\nneed for $\\lor$Elim.\n\\end{tabular}\n\n}\n\\subsec{An Example}{\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{(A \\land B) \\lor (A \\land C)}\n}{\n\\subproof{\\pline[2.]{A \\land B}}{\n\\ellipsesline \\\\\n  \\pline[6.]{A \\land (B \\lor C)}}\\\\[.5ex]\n\\subproof{\\pline[7.]{A \\land C}}{\n\\ellipsesline \\\\\n  \\pline[11.]{A \\land (B \\lor C)}}\n  \\pline{A \\land (B \\lor C)}[\\lore{1}{2--6}{7--11}]\n} \n  &\nIn the first subproof, we now set up the sub goals for proving line 6\nusing $\\land$Intro.\n\\end{tabular}\n\n}\n\\subsec{An Example}{\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{(A \\land B) \\lor (A \\land C)}\n}{\n\\subproof{\\pline[2.]{A \\land B}}{\n\\ellipsesline \\\\\n  \\pline[4.]{A}\\\\\n  \\pline[5.]{B \\lor C}\\\\\n  \\pline[6.]{A \\land (B \\lor C)}[\\landi{4}{5}]}\\\\[.5ex]\n\\subproof{\\pline[7.]{A \\land C}}{\n  \\ellipsesline \\\\\n  \\pline[11.]{A \\land (B \\lor C)}}\n\\pline{A \\land (B \\lor C)}[\\lore{1}{2--6}{7--11}]\n} \n  &\nWe immediately see that we get line 4 from 2 by $\\land$Elim; let's\napply the strategy for proving disjunctions to line 5: look for a\nproof of $\\sf B$.\n\\end{tabular}\n\n\n}\n\\subsec{An Example}{\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{(A \\land B) \\lor (A \\land C)}\n}{\n\\subproof{\\pline[2.]{A \\land B}}{\n  \\pline[3.]{B}\\\\\n  \\pline[4.]{A}[\\lande{2}]\\\\\n  \\pline[5.]{B \\lor C}[\\lori{3}]\\\\\n  \\pline[6.]{A \\land (B \\lor C)}[\\landi{4}{5}]}\\\\[.5ex]\n\\subproof{\\pline[7.]{A \\land C}}{\n\\ellipsesline \\\\\n  \\pline[11.]{A \\land (B \\lor C)}}\n  \\pline[12.]{A \\land (B \\lor C)}[\\lore{1}{2--6}{7--11}]\n} \n  &\nLike line 4 before, we get line 3 from 2 by $\\land$Elim. That's it for\nthe first subproof. The second subproof is exactly the same.\n\\end{tabular}\n\n}\n\\subsec{An Example}{\n\n\\begin{tabular}{@{}l@{}p{13em}}\n\\fitchprf{\n   \\pline[1.]{(A \\land B) \\lor (A \\land C)}\n}{\n\\subproof{\\pline[2.]{A \\land B}}{\n  \\pline[3.]{B}[\\lande{2}]\\\\\n  \\pline[4.]{A}[\\lande{2}]\\\\\n  \\pline[5.]{B \\lor C}[\\lori{3}]\\\\\n  \\pline[6.]{A \\land (B \\lor C)}[\\landi{4}{5}]}\\\\[.5ex]\n\\subproof{\\pline[7.]{A \\land C}}{\n  \\pline[8.]{C}[\\lande{7}]\\\\\n  \\pline[9.]{A}[\\lande{7}]\\\\\n  \\pline[10.]{B \\lor C}[\\lori{8}]\\\\\n  \\pline[11.]{A \\land (B \\lor C)}[\\landi{9}{10}]}\n  \\pline[12.]{A \\land (B \\lor C)}[\\lore{1}{2--6}{7--11}]\n} \n  &\n\\end{tabular}\n\n}\n\\subsec{Example Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg (P \\lor ~P)}}{\n\\ellipsesline\\\\\n\\pline[8.]{\\bot}[\\lfalsei{2}{7}]}\n\\pline[9.]{P \\lor \\neg P}[\\lnoti{2--8}]\n} \n&\nSuppose we want to prove $\\sf P \\lor \\neg P$.  A little reflection\nshows that this can only be done by indirect proof.  So we set up a subproof\nfor use with $\\neg$Intro.\n\\end{tabular}\n\n}\n\\subsec{Example Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg (P \\lor ~P)}}{\n\\ellipsesline\\\\\n\\pline[7.]{P \\lor \\neg P}[?]\\\\\n\\pline[8.]{\\bot}[\\lfalsei{2}{7}]}\n\\pline[9.]{P \\lor \\neg P}[\\lnoti{2--8}]\n} \n&\nOur first candidate for a contradiction is the assumption of the\nsubproof.  How should we get $\\sf P \\lor neg P$ inside that\nsubproof?\n\\end{tabular}\n\n}\n\\subsec{Example Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg (P \\lor ~P)}}{\n\\subproof{\\pline[3.]{P}}{\n\\ellipsesline\\\\\n\\pline[5.]{\\bot}[?]\n}\n\\pline[6.]{\\neg P}[\\lnoti{3--5}]\\\\\n\\pline[7.]{P \\lor \\neg P}[\\lori{6}]\\\\\n\\pline[8.]{\\bot}[\\lfalsei{2}{7}]}\n\\pline[9.]{P \\lor \\neg P}[\\lnoti{2--8}]\n} \n&\nInside the subproof, we \\emph{can} get $\\sf P \\lor \\neg P$ by\n$\\lor$Intro. So let's try to prove $\\sf \\neg P$; it's a negated\nsentence, so we'll use $\\neg$Intro.\n\\end{tabular}\n\n}\n\\subsec{Example Indirect Proof}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg (P \\lor ~P)}}{\n\\subproof{\\pline[3.]{P}}{\n\\pline[4.]{P \\lor \\neg P}[\\lori{3}]\\\\\n\\pline[5.]{\\bot}[\\lfalsei{2}{4}]\n}\n\\pline[6.]{\\neg P}[\\lnoti{3--5}]\\\\\n\\pline[7.]{P \\lor \\neg P}[\\lori{6}]\\\\\n\\pline[8.]{\\bot}[\\lfalsei{2}{7}]}\n\\pline[9.]{P \\lor \\neg P}[\\lnoti{2--8}]\n} \n&\nHere, the assumption of the subproof, $\\sf P$, is not\nreally a good candidate for a negation. But we can use the negated\nsentence on line 2 again, and it's easy to get in this situation.\n\\end{tabular}\n\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\ellipsesline\\\\\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\hphantom{\\lnoti{2--12}}]\n} \n  &\nHere, we're proving that $\\sf\\neg \\neg (P \\lor Q) \\lor \\neg P$ is a\ntautology---that's why there are no premises.  Since neither P nor\n$\\sf\\neg\\neg( P \\lor Q)$ is a tautology, we won't be able to\nprove either of these, so the strategy for proving the conclusion\nusing $\\lor$Intro won't work. We have to use indirect proof.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg \\neg (P \\lor Q) \\lor \\neg P)}}{\n\\ellipsesline\\\\\n\\pline[12.]{\\bot}[?]\n}\n\\pline[13.]{\\neg \\neg (P \\lor  Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nTo use $\\neg$Intro as the last step we need a subproof that proves\na contradiction from the negation of the goal sentence.  What's a \ngood candidate for sentences from which we get $\\bot$ using $\\bot$Intro?\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg (P \\lor Q) \\lor \\neg P)}}{\n\\ellipsesline\\\\\n\\pline[11.]{\\neg\\neg( P \\lor  Q) \\lor \\neg P}[?] \\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nThe only plausible candidate is the sentence $\\sf \\neg\\neg (P \\lor Q)\n\\lor \\neg P$ itself, since no other negated sentence is available.  So\nlet's try to prove that inside the subproof.  We'll get $\\bot$ by\n$\\bot$Intro from lines 2 and 11. So how do we get line 11?\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\ellipsesline\\\\\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[?] \\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}]\\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nLine 11 is a disjunction, so the strategy for $\\lor$Intro applies.  We\nhave two choices: try to prove $\\sf\\neg\\neg (P \\lor Q)$, or prove $\\sf \\neg P$.\nEither would work, but lets try to prove $\\sf \\neg\\neg (P \\lor Q)$.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\subproof{\\pline[3.]{\\neg(P \\lor Q)}}{\n\\ellipsesline\\\\\n\\pline[9.]{\\bot}[?]}\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[\\lnoti{3--9}]\\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}]\\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nSince $\\sf\\neg\\neg(P \\lor Q)$ starts with a $\\neg$, we'll apply the\nstrategy for proving negations: start a subproof with $\\sf\\neg(P \\lor\nQ)$ as the assumption, and try to prove $\\bot$.  We justify line 10\nusing $\\neg$Intro.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\subproof{\\pline[3.]{\\neg(P \\lor Q)}}{\n\\ellipsesline\\\\\n\\pline[8.]{P \\lor Q}[?]\\\\\n\\pline[9.]{\\bot}[\\lfalsei{3}{8}]}\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[\\lnoti{3--9}]\\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}]\\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nNow we need a candidate for a contradiction.  There are two negated\nlines in the avaliable assumptions. Let's pick line 3: try to prove\n$\\sf P \\lor Q$.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\subproof{\\pline[3.]{\\neg(P \\lor Q)}}{\n\\ellipsesline\\\\\n\\pline[7.]{P}[?]\\\\\n\\pline[8.]{P \\lor Q}[\\lori{7}]\\\\\n\\pline[9.]{\\bot}[\\lfalsei{3}{8}]}\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[\\lnoti{3--9}]\\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}] \\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nTo get $\\sf P \\lor Q$, we'll use $\\lor$Intro.  For this we have to\nprove one of the disjuncts, say, $\\sf P$.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\subproof{\\pline[3.]{\\neg(P \\lor Q)}}{\n\\subproof{\\pline[4.]{\\neg P}}{\n\\ellipsesline\\\\\n\\pline[6.]{\\bot}[?]\n}\n\\pline[7.]{P}[\\lnoti{4--6}]\\\\\n\\pline[8.]{P \\lor Q}[\\lori{7}]\\\\\n\\pline[9.]{\\bot}[\\lfalsei{3}{8}]\n}\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[\\lnoti{3--9}]\\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}]\\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n& $\\sf P$ is an atomic sentence, so no introduction rule can give us\n$\\sf P$.  We'll have to do indirect proof: start a subproof using $\\sf\n\\neg P$ a the assumption, and prove another contradiction.\n\\end{tabular}\n}\n\\subsec{Another Example}{\n\n\\begin{tabular}{@{}lp{13em}}\n\\fitchprf{\\pline[1.]{}}{\n\\subproof{\\pline[2.]{\\neg(\\neg\\neg( P \\lor Q) \\lor \\neg P)}}{\n\\subproof{\\pline[3.]{\\neg(P \\lor Q)}}{\n\\subproof{\\pline[4.]{\\neg P}}{\n\\pline[5.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{4}] \\\\\n\\pline[6.]{\\bot}[\\lfalsei{2}{5}]\n}\n\\pline[7.]{P}[\\lnoti{4--6}] \\\\\n\\pline[8.]{P \\lor Q}[\\lori{7}] \\\\\n\\pline[9.]{\\bot}[\\lfalsei{3}{8}]}\n\\pline[10.]{\\neg\\neg (P \\lor  Q)}[\\lnoti{3--9}]\\\\\n\\pline[11.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lori{10}]\\\\\n\\pline[12.]{\\bot}[\\lfalsei{2}{11}]\n}\n\\pline[13.]{\\neg \\neg (P \\lor Q) \\lor \\neg P}[\\lnoti{2--12}]\n} \n  &\nHow are we getting the contradiction now?  Note how since we have\n$\\sf\\neg P$ as an assumption, we can immediately get $\\sf\\neg\\neg(P\n\\lor Q) \\lor \\neg P$ by $\\lor$Intro.  Everything's now in place.\n\\end{tabular}\n}\n\n\\end{document}\n\n\n\\end{document}\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "4bb35cb3a9de953972d73d55f0e5fec77b09e2aa", "size": 24307, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "279-lec08.tex", "max_stars_repo_name": "rzach/phil279", "max_stars_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-09-23T13:42:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-21T10:48:55.000Z", "max_issues_repo_path": "279-lec08.tex", "max_issues_repo_name": "rzach/phil279", "max_issues_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "279-lec08.tex", "max_forks_repo_name": "rzach/phil279", "max_forks_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1886010363, "max_line_length": 120, "alphanum_fraction": 0.6303533961, "num_tokens": 9403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.41431510011633244}}
{"text": "\\documentclass[12pt,a4]{article}\n\n\\usepackage{xcolor}\n\n\n\\newcommand{\\handoutdate}{Friday, 2020-06-05}\n\\newcommand{\\firstduedate}{Thursday, 2020-06-12}\n\\newcommand{\\finalduedate}{Thursday, 2020-06-19}\n\n\n\\input{preamble}\n\n\n\n\n\\newcommand{\\rank}{\\textnormal{rank}}\n\\newcommand{\\y}{\\mathbf{y}}\n\\renewcommand{\\c}{\\mathbf{c}}\n\\newcommand{\\x}{\\mathbf{x}}\n\\newcommand{\\z}{\\mathbf{z}}\n\\renewcommand{\\u}{\\mathbf{u}}\n\\newcommand{\\V}{\\mathbf{v}}\n\n\\renewcommand{\\a}{\\mathbf{a}}\n\n\\renewcommand{\\b}{\\mathbf{b}} \n\\newcommand{\\zero}{\\mathbf{0}}\n\\newcommand{\\rpn}{\\mathbb{R}_{\\geq 0}}\n\\newcommand{\\sol}{\\textup{\\textrm{sol}}}\n\\newcommand{\\opt}{\\textup{\\textrm{opt}}}\n\\setcounter{section}{6}\n\n\n\\section{Farkas Lemma and LP Duality}\n\n\\subsection{Different Versions of Farkas Lemma}\n\nIn the following, let $A \\in \\R^{m \\times n}$ and $\\b \\in \\R^m$, and let \n$\\x = (x_1,\\dots,x_n)^T$ be a column vector of $n$ variables and \n$\\y = (y_1, \\dots,y_m)$ be a row vector of $m$ variables.\n\n\\begin{exercise}\n Show that the three versions of Farkas Lemma presented in class are all equivalent (I actually did not present\n the third version in class):\n \\begin{align}\n   ( \\neg \\exists \\x : \\, A \\x \\leq \\b ) \\, & \\Longleftrightarrow \n    ( \\exists \\y \\geq \\zero : \\, \\y^T A = \\zero, \\,     \\y^T \\b < 0 ) \\ . \\\\\n      ( \\neg \\exists \\x \\geq \\zero : \\, A \\x \\leq \\b ) \\, & \\Longleftrightarrow \n    ( \\exists \\y \\geq \\zero : \\, \\y^T A \\geq \\zero, \\,  \\y^T \\b < 0 ) \\ . \\\\\n   ( \\neg \\exists \\x \\geq \\zero : \\, A \\x = \\b ) \\, & \\Longleftrightarrow \n    ( \\exists \\y \\begingroup \\color{white} \\geq \\zero \\endgroup : \\, \\y^T A \\geq \\zero, \\,  \\y^T \\b < 0 ) \\ .\n \\end{align}\n  Note that the direction ``$\\Longleftarrow$'' is easy in each case. \n  We will show the ``$\\Longrightarrow$'' of (1) in class using a technique called {\\em Fourier-Motzkin Elimination}. \n  This exercise is actually not that hard. The hardest part is keeping track of what you \n  want to prove and what you can assume.\n\\end{exercise}\n\\begin{proof}\n\t\tFirst we prove (1) and (2) are equivalent. First consider (1) $\\implies$ (2). If $\\neg \\exists \\x \\ge  \\zero : A\\x \\le \\b$, \n\t\tnotice that $\\x \\ge \\zero $ iff $\\left( -I_{n} \\right) \\x \\le \\zero$ , we can construct a new maxtrix $A'$ \n\t\t\\[\n\t\tA' = \\begin{pmatrix} -I \\\\ A \\end{pmatrix} , \\b' = \\begin{pmatrix} \\zero\\\\ \\b \\end{pmatrix} \n\t\t.\\] \n\t\tsuch that our assumption turns into\n\t\t\\[\n\t\t\\neg \\exists \\x : A' \\x \\le \\b'\n\t\t.\\] \n\t\tAnd by (1), if follows that $\\exists \\y ' \\ge \\zero$ s.t. $(\\y ')^{\\top} A' = 0$ and  $(\\y ') ^{\\top} \\b ' < 0$.\n\t\tFor convenience, we wirte $\\y' = \\left( z_1,z_2\\ldots,z_n, \\y \\right) $ while $z_{i} \\ge 0$, therefore\n\t\t\\[\n\t\t-z_{i} + \\y ^{\\top} A_{i} = 0 \\implies \\y^{\\top} A_{i} = z_{i} \\ge  0\n\t\t.\\] \n\t\tWhich leads that $\\y^{\\top} A \\ge 0$.\n\t\tSimilarly $(\\y')^{\\top} \\b'= \\y ^{\\top} \\b  < 0 $, thus (2) is true. \n\t\t\n\t\tNext we prove (2) $\\implies$ (3). If $\\neg \\x \\ge 0, A\\x = \\b$, which is $A \\x \\le \\b$ plus $\\left( -A \\right) \\x \\le -\\b$,\n\t\tsimilarly we construct \n\t\t\\[\n\t\tA' = \\begin{pmatrix} A \\\\ -A \\end{pmatrix}, \\b' = \\begin{pmatrix} \\b \\\\ -\\b \\end{pmatrix}  \n\t\t.\\] \n\t\tBy (2), $\\exists \\y' = \\left( \\y_1, \\y_2 \\right) $ , such that \n\t\t\\[\n\t\t\\y_1 A - \\y_2 A \\ge 0, \\y_1\\b - \\y_2 \\b < 0\n\t\t.\\] \n\t\tChoose $\\y = \\y_1 - \\y_2$ we are done.\n\n\t\tNow we prove (2) $\\implies$ (1). \n\t\t\n\t\tWe know that $\\neg \\x \\ge 0, A\\left( \\x \\right) \\le \\b$.\n\t\tAnd it's also obvious that $\\neg \\exists \\x \\ge 0, A \\left( -\\x \\right) = \\left( -A \\right) \\x\\le \\b$, \n\t\twe can build a new matrix $A' = \\left( A, -A \\right) $, hence \n\t\t\\[\n\t\t\t\t\\neg \\x' = \\begin{pmatrix} \\x_1\\\\ \\x_2 \\end{pmatrix}  \\ge 0, \\left( A, -A \\right) \\begin{pmatrix} \\x_1 \\\\ \\x_2 \\end{pmatrix} \\le 2\\b\n\t\t.\\] \n\t\tBy (2) we have \n\t\t\\[\n\t\t\t\t\\exists \\y, \\y^{\\top} A \\ge 0, \\y ^{\\top} \\left( -A \\right) \\ge 0, \\y^{\\top} \\b < 0 \\implies \\y^{\\top} A = 0\n\t\t.\\] \n\t\tThus (2) $\\implies$ (1) is true.\n\n\t\tFinally we prove (3) $\\implies$ (2), if $\\neg \\exists \\x \\ge 0: A\\x \\le \\b$, similarly construct\n\t\t\\[\n\t\t\t\tA' = \\left( A, I \\right) \n\t\t.\\] \n\t\tWe know $\\neg \\exists \\x \\ge 0, A' \\x' = \\b$.\n\t\tThe result follows directly from (3).\n\\end{proof}\n\n\\subsection{A Linear Program for, well, for what?}\n\n\n\n\nLet $G = (V,E)$ be a directed graph, $s,t \\in V$,  and $c: E \\rightarrow \\mathbf{R}^+$ be a cost \nfunction. We want to find an $s-t$-flow $f$ of value $1$. Every edge $e$ generates cost $f(e) \\cdot c(e)$, and we want to minimize the overall cost. There are no capacity constraints.\nWe can easily write this as a linear program MCF (Minimum Cost Flow):\n\\begin{align*}\n  \\textrm{MCF}(G,s,t,c): \\qquad\n  \\begin{array}{ll}\n    \\textnormal{minimize} \\quad & \\multicolumn{1}{l}{\\sum_{e \\in E} c(e) f(e)} \\\\\n    \\\\\n    \\textnormal{subject to} \\quad & \\sum_{v \\in V} f(v,t)  = 1 \\\\\n\t\t\t\t\t        & \\sum_{u \\in V} f(u,v) - \\sum_{w \\in V} f(v,w)  = 0  \\quad \\forall\\ v \\in V  \\setminus \\{s,t\\}\\\\\n\t\t\t\t\t        \\\\\n     & f(e)  \\geq 0 \\ \\forall \\ e \\in E \n  \\end{array}\n\\end{align*}\nNote that we have $m$ variables, one variable $f(e)$ for each edge $e$.\nThe first constraint says that the value of the flow should be 1. The other constraints say that \nthe inflow at $v$ should equal the outflow.\n\n\\begin{exercise}\n   Let $d$ be the shortest path distance from $s$ to $t$ in the directed graph $G$, where distance\n   means sum of the $c(e)$ along the path. Show that $\\opt(MCF) = d$.\n   \\textbf{Hint.} Make sure you show both $\\leq$ and $\\geq$.\n\\end{exercise}\n\n\\begin{proof}\nTo prove $opt(MCF) \\le d$, we just need to prove that the shortest path is a solution to $MCF$.\n    We set $f(e) = 1$ along all edges in the shortest path, since there is only one path with flow $1$,\n    The constraints are obviously satisfied. So it is a solution of $MCF$, and its value is $1 * d = d$,\n    so $opt(MCF) \\le d$\n\n    To prove $opt(MCF) \\ge d$, we need to prove that all solutions of $MCF$ is not better than $d$.\n    We try to improve the value of all possible solutions to $d$.\n    \n    Suppose we have a solution with $x$ different $s-t$ path. Define $b(path)$ be the smallest flow in all\n    edges of $path$, $d(path)$ be the length of $path$. Let $sp$ be the shortest $s-t$ path. We do as follows, choose any path $p$ besides $sp$,\n    put $b(p)$ units of flow on $p$ to $sp$. Repeat it until there is only $1$ unit flowing through $sp$.\n\n    We need to show in each turn, $val(MCF)$ is not worse than previous and no constraints are broke. We fist prove \n    $val(MCF)$ is not worse. In each turn, $val(MCF)' = val(MCF) + d * b(p) - d(p) * b(p)$, $d \\le d(p)$, so $val(MCF)' \\le val(MCF)$.\n    As for the constraints, inflow of $t$ remains to be 1 since we just move $b(p)$ units between two different paths.\n    Flow constraints remains since we modify the flow in one path, which means we move inflow and outflow of a single \n    vertex at the same time. Since we only have $x$ different $s-t$ path, and the flow value on each path is finite,\n    the process terminates. So $val(MCF) \\ge d$\n\n    In all $val(MCF) = d$\n\\end{proof}\n\n\\begin{exercise}\n    Write down the dual of MCF. This will be a maximization problem. Don't use any matrix notation.\n\\end{exercise}\n\n\\begin{proof}\nWe introduce a dual coefficient $g_v, v \\in V$. The dual program is:\n    \\begin{itemize}\n        \\item Maximize $g_t$, subject to:\n        \\item $g_v - g_u \\le c(u, v), \\forall (u,v) \\in E$\n        \\item $g_v \\in \\mathbb{R}, v \\in V$\n    \\end{itemize}\n\\end{proof}\n\n\\begin{exercise}\n   Interpret the dual. Show that it is the LP formulation of a ``natural'' maximization problem on $G$.\n\\end{exercise}\n\n\\begin{proof}\nIf we set $g_s = 0$, then the $g_v$ can be thought as the cost of some $s-t$-path.\n    Since each edge $(u,v)$ must satisfy $g_v - g_u \\le c(u,v))$, we can not just choose the\n    maximal $s-t$-path as solution. Under this constraint, we can see that the solution\n    must at first be a \\textbf{safe} path, so the program is actually the shortest path problem.\n\\end{proof}\n\n\\begin{exercise}\n  Describe an optimal solution of the dual program.\n\\end{exercise}\n\n\\begin{proof}\n    The optimal solution is the shortest $s-t$-path $sp$, and for each vertex along the path, we must \n    set $g_v = g_u$ for $(u,v), u \\in sp, v \\notin sp$ accordingly to $g_v-g_u$ constraints.\n\\end{proof}\n   \n   \n   \n  \n\n\n\\end{document}\n", "meta": {"hexsha": "9d20dddf7862e40c9e90d0d80c01f0f35da16034", "size": 8240, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Week7/07-cs217-2020-homework-farkas.tex", "max_stars_repo_name": "yujie6/CS217-Notes", "max_stars_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Week7/07-cs217-2020-homework-farkas.tex", "max_issues_repo_name": "yujie6/CS217-Notes", "max_issues_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Week7/07-cs217-2020-homework-farkas.tex", "max_forks_repo_name": "yujie6/CS217-Notes", "max_forks_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2, "max_line_length": 183, "alphanum_fraction": 0.6139563107, "num_tokens": 3015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.546738151984614, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.414315097125686}}
{"text": "\\documentclass[]{article}\\usepackage[]{graphicx}\\usepackage[]{color}\n%% maxwidth is the original width if it is less than linewidth\n%% otherwise use linewidth (to make sure the graphics do not exceed the margin)\n\\makeatletter\n\\def\\maxwidth{ %\n  \\ifdim\\Gin@nat@width>\\linewidth\n    \\linewidth\n  \\else\n    \\Gin@nat@width\n  \\fi\n}\n\\makeatother\n\n\\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}\n\\newcommand{\\hlnum}[1]{\\textcolor[rgb]{0.686,0.059,0.569}{#1}}%\n\\newcommand{\\hlstr}[1]{\\textcolor[rgb]{0.192,0.494,0.8}{#1}}%\n\\newcommand{\\hlcom}[1]{\\textcolor[rgb]{0.678,0.584,0.686}{\\textit{#1}}}%\n\\newcommand{\\hlopt}[1]{\\textcolor[rgb]{0,0,0}{#1}}%\n\\newcommand{\\hlstd}[1]{\\textcolor[rgb]{0.345,0.345,0.345}{#1}}%\n\\newcommand{\\hlkwa}[1]{\\textcolor[rgb]{0.161,0.373,0.58}{\\textbf{#1}}}%\n\\newcommand{\\hlkwb}[1]{\\textcolor[rgb]{0.69,0.353,0.396}{#1}}%\n\\newcommand{\\hlkwc}[1]{\\textcolor[rgb]{0.333,0.667,0.333}{#1}}%\n\\newcommand{\\hlkwd}[1]{\\textcolor[rgb]{0.737,0.353,0.396}{\\textbf{#1}}}%\n\\let\\hlipl\\hlkwb\n\n\\usepackage{framed}\n\\makeatletter\n\\newenvironment{kframe}{%\n \\def\\at@end@of@kframe{}%\n \\ifinner\\ifhmode%\n  \\def\\at@end@of@kframe{\\end{minipage}}%\n  \\begin{minipage}{\\columnwidth}%\n \\fi\\fi%\n \\def\\FrameCommand##1{\\hskip\\@totalleftmargin \\hskip-\\fboxsep\n \\colorbox{shadecolor}{##1}\\hskip-\\fboxsep\n     % There is no \\\\@totalrightmargin, so:\n     \\hskip-\\linewidth \\hskip-\\@totalleftmargin \\hskip\\columnwidth}%\n \\MakeFramed {\\advance\\hsize-\\width\n   \\@totalleftmargin\\z@ \\linewidth\\hsize\n   \\@setminipage}}%\n {\\par\\unskip\\endMakeFramed%\n \\at@end@of@kframe}\n\\makeatother\n\n\\definecolor{shadecolor}{rgb}{.97, .97, .97}\n\\definecolor{messagecolor}{rgb}{0, 0, 0}\n\\definecolor{warningcolor}{rgb}{1, 0, 1}\n\\definecolor{errorcolor}{rgb}{1, 0, 0}\n\\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX\n\n\\usepackage{alltt}\n\n%\\usepackage[numbers]{natbib}\n\\usepackage[]{natbib}\n%\\bibliographystyle{plainnat}\n%\\bibliographystyle{unsrt}\n\\bibliographystyle{apa}\n%opening\n\\title{Project 1}\n\\author{Sahir}\n\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}\n\\begin{document}\n\n\n\\maketitle\n\\begin{abstract}\nthis is an abstract\n\\end{abstract}\n\n\n\\section{Linear Regression fit}\n\nThis is a demo for including R code in an knitr document. This model was given by~\\citep{breiman1996bagging}.\nAnd also by~\\citep{yang2017insurance}. He can also be referred to as~\\citep{breiman1999prediction}.\n\nThis is a demo for including R code in an knitr document. This model was given by~\\cite{breiman1996bagging}.\nAnd also by~\\cite{yang2017insurance}. He can also be referred to as~\\cite{breiman1999prediction}.\n\n\n\\begin{equation}\ny = \\beta_0 + \\beta_1 * X_1 + \\epsilon\n\\end{equation}\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\\begin{kframe}\n\\begin{verbatim}\n## \n## Call:\n## lm(formula = mpg ~ ., data = mtcars)\n## \n## Residuals:\n##     Min      1Q  Median      3Q     Max \n## -3.4506 -1.6044 -0.1196  1.2193  4.6271 \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)  \n## (Intercept) 12.30337   18.71788   0.657   0.5181  \n## cyl         -0.11144    1.04502  -0.107   0.9161  \n## disp         0.01334    0.01786   0.747   0.4635  \n## hp          -0.02148    0.02177  -0.987   0.3350  \n## drat         0.78711    1.63537   0.481   0.6353  \n## wt          -3.71530    1.89441  -1.961   0.0633 .\n## qsec         0.82104    0.73084   1.123   0.2739  \n## vs           0.31776    2.10451   0.151   0.8814  \n## am           2.52023    2.05665   1.225   0.2340  \n## gear         0.65541    1.49326   0.439   0.6652  \n## carb        -0.19942    0.82875  -0.241   0.8122  \n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## Residual standard error: 2.65 on 21 degrees of freedom\n## Multiple R-squared:  0.869,\tAdjusted R-squared:  0.8066 \n## F-statistic: 13.93 on 10 and 21 DF,  p-value: 3.793e-07\n\\end{verbatim}\n\\end{kframe}\n\\end{knitrout}\n\n\\newpage\n\n\\begin{kframe}\n\\begin{alltt}\n\\hlstd{texreg}\\hlopt{::}\\hlkwd{texreg}\\hlstd{(fit)}\n\\end{alltt}\n\\end{kframe}\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{l c }\n\\hline\n & Model 1 \\\\\n\\hline\n(Intercept) & $12.30$   \\\\\n            & $(18.72)$ \\\\\ncyl         & $-0.11$   \\\\\n            & $(1.05)$  \\\\\ndisp        & $0.01$    \\\\\n            & $(0.02)$  \\\\\nhp          & $-0.02$   \\\\\n            & $(0.02)$  \\\\\ndrat        & $0.79$    \\\\\n            & $(1.64)$  \\\\\nwt          & $-3.72$   \\\\\n            & $(1.89)$  \\\\\nqsec        & $0.82$    \\\\\n            & $(0.73)$  \\\\\nvs          & $0.32$    \\\\\n            & $(2.10)$  \\\\\nam          & $2.52$    \\\\\n            & $(2.06)$  \\\\\ngear        & $0.66$    \\\\\n            & $(1.49)$  \\\\\ncarb        & $-0.20$   \\\\\n            & $(0.83)$  \\\\\n\\hline\nR$^2$       & 0.87      \\\\\nAdj. R$^2$  & 0.81      \\\\\nNum. obs.   & 32        \\\\\nRMSE        & 2.65      \\\\\n\\hline\n\\multicolumn{2}{l}{\\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}\n\\end{tabular}\n\\caption{Statistical models}\n\\label{table:coefficients}\n\\end{center}\n\\end{table}\n\n\n\n\\bibliography{bibliography}\n\n\\end{document}\n", "meta": {"hexsha": "7a952904d23c68462dddf23e3fb3342ddd58fa66", "size": 5028, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "demos/001-basic-knitr-example/report/project1-report.tex", "max_stars_repo_name": "sahirbhatnagar/npu", "max_stars_repo_head_hexsha": "87c720bf5ecc0e27dd73bb4f8eff8f4af4558fb0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "demos/001-basic-knitr-example/report/project1-report.tex", "max_issues_repo_name": "sahirbhatnagar/npu", "max_issues_repo_head_hexsha": "87c720bf5ecc0e27dd73bb4f8eff8f4af4558fb0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "demos/001-basic-knitr-example/report/project1-report.tex", "max_forks_repo_name": "sahirbhatnagar/npu", "max_forks_repo_head_hexsha": "87c720bf5ecc0e27dd73bb4f8eff8f4af4558fb0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4035087719, "max_line_length": 109, "alphanum_fraction": 0.5912887828, "num_tokens": 2005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.41431509114439274}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{fullpage}\n\n\\pagestyle{empty}\n\n\\newcommand{\\ie}{{\\it i.e.}}%\n\\newcommand{\\reals}{{\\mbox{\\bf R}}}%\n\\newcommand{\\Span}{\\mathop{\\bf span}}%\n\\newcommand{\\diag}{\\mathop{\\bf diag}}%\n\n\\title{Subspaces that Minimize the Condition Number of a Matrix}\n\\author{Siddharth Joshi \\and Stephen Boyd\\thanks{The authors are with the department of\nElectrical Engineering at Stanford University. Email addresses: Siddharth\nJoshi: \\texttt{sidj@stanford.edu}, Stephen Boyd:\n\\texttt{boyd@stanford.edu}.}}\n\\date{}\n\n\\begin{document}\n\\hyphenation{non-singular}\n\\maketitle\n\\thispagestyle{empty}\n\n\n\\begin{abstract}\nWe define the condition number of a nonsingular matrix on a\nsubspace, and consider the problem of finding\na subspace of given dimension that minimizes the condition\nnumber of a given matrix.\nWe give a general solution to this problem, and show in particular\nthat when the given dimension is less than half the dimension\nof the matrix, a subspace can be found on which the condition\nnumber of the matrix is one.\n\\end{abstract}\n\n\n\\section{The problem} \n\nSuppose $A\\in \\reals^{n \\times n}$ and\n$\\mathcal V \\subseteq \\reals^n$ is a subspace with $\\dim \\mathcal\nV = k \\geq 1$. \nWe define the \\emph{maximum gain} (\\emph{minimum gain})\nof $A$ on $\\mathcal V$, as\n\\[\nG_\\mathrm{max} =\n\\sup_{x \\in \\mathcal V,~x \\neq 0} \\frac{\\|Ax\\|}{\\|x\\|}, \\qquad\nG_\\mathrm{min} =\n\\inf_{x \\in \\mathcal V,~x \\neq 0} \\frac{\\|Ax\\|}{\\|x\\|},\n\\]\nrespectively, where $\\|~\\|$ denotes the Euclidean norm.\nWhen $A$ is nonsingular, we define its \\emph{condition number\non the subspace $\\mathcal V$} as\n\\[\n\\kappa_{\\mathcal V}(A) = G_\\mathrm{max}/G_\\mathrm{min}.\n\\]\nThe condition number of $A$ on any\none-dimensional subspace is $1$, and its condition number\non $\\mathcal V=\\reals^n$ is the (usual) condition number of $A$,\nwhich we denote $\\kappa(A)$.\nThe condition number on any subspace is between $1$ and $\\kappa(A)$.\nIf $\\kappa_{\\mathcal V}(A)=1$, we say that $A$ is isotropic \non $\\mathcal V$,\nsince its gain $\\|Ax\\|/\\|x\\|$ is the same for any nonzero vector\n$x \\in \\mathcal V$.\n\nIn this note we address the following problem:\nGiven a nonsingular matrix $A \\in \\reals^{n \\times n}$, and \n$k \\in \\{1,\\ldots, n\\}$, find a subspace $\\mathcal V \\subseteq \\reals^n$\nof dimension $k$ which minimizes $\\kappa_{\\mathcal V}(A)$.\nThe number $\\kappa_{\\mathcal V}(A)$ is a measure of the\nanisotropy of the linear function induced by $A$, restricted\nto the subspace $\\mathcal V$, so\nour problem is to find a subspace of dimension $k$\non which $A$ is maximally isotropic. \n\nWe will show that the minimum possible condition number of $A$,\non a subspace of dimension $k$, is given by\n\\begin{equation}\n\\label{sol}\n\\inf_{\\mathcal V\\;:\\;\\mathrm{dim} \\mathcal V=k}\n\\kappa_{\\mathcal V} (A) =\n\\max \\left(\\frac{\\sigma_{n-k+1}}{\\sigma_k}, 1 \\right)  =\n\\left\\{ \\begin{array}{ll} \n1 & \\quad  k \\leq \\lceil n/2 \\rceil,\\\\\n\\sigma_{n-k+1} / \\sigma_k & \\quad  k > \\lceil n/2 \\rceil,\n\\end{array}\\right.\n\\end{equation}\nwhere $\\sigma_1 \\geq \\cdots \\geq \\sigma_n >0$\nare the singular values of $A$.  (The infimum is over all\nsubspaces of $\\reals^n$ of dimension $k$.)\nThis means, in particular, that for $k \\leq \\lceil n/2 \\rceil$,\nwe can find a subspace of dimension $k$ on which $A$ is isotropic.\n\nThere are many classical results that identify a subspace of a\ngiven dimension that minimizes or maximizes some quantity that\ndepends on the subspace and matrix.\nFor example, the Courant-Fischer theorem tells us that the\nminimum value of $G_\\mathrm{max}$, over all subspaces of\ndimension $k$, is $\\sigma_{n-k+1}$, and the\nmaximum value of $G_\\mathrm{min}$, over all subspaces of\ndimension $k$, is $\\sigma_{k}$. For these and similar results,\nsee, e.g., \\cite[\\S 4.2]{HoJ:85} or \\cite{Ber:05}.\nAlso, the idea of condition number of a matrix restricted to a\nparticular subspace can be seen in \\cite{ChanF:88}.\n\nWe can give a geometric application (or interpretation) of \nour problem.\nWe are given an ellipsoid $\\mathcal E = \\{ z \\;|\\; \\|Az \\|\\leq 1\\}$\nin $\\reals^n$, where $A \\in \\reals^{n \\times n}$ is nonsingular.\nOur goal is to find a $k$ dimensional subspace $\\mathcal V$\nso that the ellipsoid $\\mathcal V \\cap \\mathcal E$ is as spherical\nas possible, \\ie, has minimum eccentricity.\n(The eccentricity of $\\mathcal V \\cap \\mathcal E$ is defined as\nthe ratio of its maximum semi-axis length to its \nminimum semi-axis length, which is exactly $\\kappa_{\\mathcal V}(A)$.)\nThe solution is to choose $\\mathcal V$ that minimizes the condition\nnumber of $A$ on $\\mathcal V$.\nOur result~(\\ref{sol}) can be interpreted in this geometric setting.\nFor example, if $k< \\lceil n/2 \\rceil$, we can always find a subspace\nof dimension $k$ for which $\\mathcal V \\cap \\mathcal E$ is perfectly \nspherical, \\ie, a ball.\nAs a very simple special case, we see that for any ellipsoid in \n$\\reals^3$, there is a plane that intersects it in a ball.\nOur general result~(\\ref{sol}) can be considered a generalization of\nthis simple fact.\n\n\\section{The solution}\n\nSuppose $Q$ and $Z$ are $n \\times n$ orthogonal matrices,\n\\ie, $Q^TQ=Z^TZ=I$.  Then we have\n\\[\n\\kappa_{\\mathcal V} (QAZ) = \\kappa_{\\mathcal W} (A),\n\\]\nwhere $\\mathcal W = Z \\mathcal V = \\{ Zv \\;|\\; v \\in \\mathcal V \\}$.\nIt follows that\n\\[\n\\inf_{\\mathcal V\\;:\\; \\mathrm{dim} \\mathcal V =k}\n\\kappa_{\\mathcal V} (A) =\n\\inf_{\\mathcal V\\;:\\;\\mathrm{dim} \\mathcal V=k}\n\\kappa_{\\mathcal V} (QAZ),\n\\]\nsince the first orthogonal matrix $Q$ has no effect,\nand the second\northogonal matrix $Z$ simply changes the parametrization of \nsubspaces of dimension $k$.\n\nNow let $A=U \\Sigma V^T$ be a\nsingular value decomposition of $A$, \\ie,\n$U$ and $V$ are orthogonal, and\n$\\Sigma = \\diag (\\sigma_1, \\ldots, \\sigma_n)$.\nOur observation above, with $Q=U^T$, $Z=V$, shows that\n\\[\n\\inf_{\\mathcal V\\;:\\;\\mathrm{dim} \\mathcal V =k}\n\\kappa_{\\mathcal V} (A) =\n\\inf_{\\mathcal V\\;:\\;\\mathrm{dim} \\mathcal V =k}\n\\kappa_{\\mathcal V} (\\Sigma).\n\\]\nSo we can just as well solve the problem for the \ndiagonal matrix $\\Sigma$.  \n(To reconstruct a subspace of dimension $k$ on which $A$\nhas least condition number, we find a subspace of dimension\n$k$ for which $\\Sigma$ has least condition number, and multiply\nit by $V$.)\n\nNow our problem is to find a subspace $\\mathcal{V}$ of\ndimension $k$ which minimizes $\\kappa_\\mathcal{V}(\\Sigma)$.\nWe will show that \n\\begin{equation}\n\\label{sol2}\n\\inf_{\\mathcal V\\;:\\; \\mathrm{dim} \\mathcal V =k}\n\\kappa_{\\mathcal V} (\\Sigma) =\n\\max \\left(\\frac{\\sigma_{n-k+1}}{\\sigma_k}, 1 \\right)\n= \\left\\{ \\begin{array}{ll} \n1 & \\quad  k \\leq \\lceil n/2 \\rceil,\\\\\n\\sigma_{n-k+1} / \\sigma_k & \\quad  k > \\lceil n/2 \\rceil,\n\\end{array}\\right.\n\\end{equation}\n\nLet $\\{e_1, \\ldots, e_n\\}$ be the standard basis for $\\reals^n$,\n\\ie, for $i=1,\\ldots, n$, $e_{ij} = 0$ if $i \\neq j$ and $e_{ij}\n= 1$ otherwise.\n\nWe first give a simple result. \nSuppose $i<j$, and let $\\sigma$ satisfy\n$\\sigma_i \\geq \\sigma \\geq \\sigma_j$.\nThen there is a unit vector $z \\in \\Span \\{e_i,e_j\\}$ for\nwhich $\\|\\Sigma z\\|=\\sigma$.\nThis can be seen several ways. For example, we can rotate\na unit vector $z$ from $e_i$ towards $e_j$.  The norm $\\|\n\\Sigma z\\|$ varies continuously from $\\sigma_i$ to $\\sigma_j$,\nand therefore has the value $\\sigma$ at some rotation angle.\nWe can easily construct such a $z$.\nIf $\\sigma_i = \\sigma_j$, we can take $z = e_i$ or $z = e_j$.\nIf $\\sigma_i > \\sigma_j$, we can take\n\\[\nz =  \\frac{ (\\sigma^2 - \\sigma_j^2 )^{1/2} e_i +\n(\\sigma_i^2 - \\sigma^2 )^{1/2} e_j}\n{ ( \\sigma_i^2 - \\sigma_j^2 )^{1/2} }.\n\\]\nIt is easily verified that $\\|z\\| = 1$ and $\\| \\Sigma z\\| =\n\\sigma$.\n\n\\subsection{Case 1: $k \\leq \\lceil n/2 \\rceil$}\n\nTo establish~(\\ref{sol2}), we will construct a subspace $\\mathcal\nV^*$ of dimension $k$, with $\\kappa_{\\mathcal V^*}(\\Sigma)=1$.\nWe will construct an orthonormal basis\n$\\left\\lbrace z_0, z_1, \\ldots ,z_{k-1} \\right\\rbrace $\nfor $\\mathcal V^*$. \nWe start with $z_0=e_{\\lceil n/2 \\rceil }$.\nNote that $\\| \\Sigma z_0 \\| =\\sigma_{\\lceil n/2 \\rceil }$.\n\nNext, we choose a unit vector\n$z_1 \\in \\Span \\{ e_{\\left\\lceil n/2 \\right\\rceil -1}, e_{\\lceil\n(n+1)/2\\rceil +1} \\}$ that satisfies \n$\\|\\Sigma z_1 \\| = \\sigma_{\\lceil n/2 \\rceil }$.\nWe can do this using our simple result above,\nnoting that\n\\[\n\\sigma_{\\left\\lceil n/2 \\right\\rceil-1}\\geq \n\\sigma_{\\lceil n/2 \\rceil }\n\\geq \\sigma_{\\left\\lceil (n+1)/2 \\right\\rceil+1}.\n\\]\nWe note that $z_1 \\perp z_0$\nand $\\Sigma z_1 \\perp \\Sigma z_0$.\n\n\nWe continue the construction, taking $z_2$ as any unit vector\n\\[\nz_2 \\in \\Span \\{ e_{\\left\\lceil n/2 \\right\\rceil -2},e_{\\lceil\n(n+1)/2\\rceil +2}\\}\n\\]\nthat satisfies $\\| \\Sigma z_2\\|=\\sigma_{\\lceil n/2 \\rceil }$.\nThis continues, until we have unit vectors $z_0, \\ldots, z_{k-1}$.\nThese vectors are mutually orthogonal, since each one is in the span\nof two standard basis vectors, and these pairs of standard basis\nvectors are disjoint. Since $\\Sigma$ is a diagonal matrix,\nthe vectors $\\Sigma z_0, \\ldots, \\Sigma z_{k-1}$ are\nmutually orthogonal.\n\nWe now show that $\\kappa_{\\mathcal V^*}(\\Sigma) = 1$.\n\\iffalse \nLet $b$ be any nonzero vector in\n$\\mathcal V^*$, say, \n$b = \\beta_0 z_0 + \\cdots + \\beta_{k-1} z_{k-1}$.\nThe gain of $A$ in the direction $b$ is\n\\begin{eqnarray*}\n\\frac{\\|Ab\\|}{\\|b\\|} &=& \n\\left( \\frac{\\beta_0^2  \\|A z_0\\|^2 + \\cdots + \\beta_{k-1}^2 \\|A\nz_{k-1} \\|^2}\n{\\beta_0^2 \\|z_0\\|^2 + \\cdots + \\beta_{k-1}^2  \\|z_{k-1}\\|^2}\n\\right)^{1/2} \\\\\n&=& \n\\left( \\frac{\\beta_0^2 \\sigma_{\\lceil n/2 \\rceil }^2 + \\cdots +\n\\beta_{k-1}^2 \\sigma_{\\lceil n/2 \\rceil }^2}\n{\\beta_0^2+ \\cdots + \\beta_{k-1}^2 }\\right) ^{1/2}\\\\\n&=& \\sigma_{\\lceil n/2 \\rceil }.\n\\end{eqnarray*}\n\\fi\nFor any nonzero vector $b \\in \\mathcal V^*$, the gain of $\\Sigma$\nin the direction of $b$,  ${\\|\\Sigma b\\| / \\|b\\|} =\n\\sigma_{\\lceil n/2 \\rceil }$, because the gain of $\\Sigma$ in\nthe direction of any unit vector in the orthonormal basis\n$\\{z_0, \\ldots, z_{k-1} \\}$  of $\\mathcal V^*$ is $\\sigma_{\\lceil\nn/2 \\rceil}$.\nThus $G_\\mathrm{max} =G_\\mathrm{min} = \\sigma_{\\lceil\nn/2\\rceil}$, and therefore ${\\kappa_{\\mathcal V^*}}(\\Sigma) = 1$.\n\n\n\\subsection{Case II: $k > \\lceil n/2 \\rceil$}\nTo establish~(\\ref{sol2}), we first construct a subspace\n$\\mathcal V^*$ of dimension $k$, with\n$\\kappa_{\\mathcal V^*}(\\Sigma)$ $=\\sigma_{n-k+1} / \\sigma_k$, and\nthen show that for any subspace $\\mathcal V$ of dimension $k$,\n$\\kappa_{\\mathcal V}(\\Sigma) \\geq \\kappa_{\\mathcal V^*}(\\Sigma)$.\n\nWe will construct an orthonormal basis for $\\mathcal V^*$. \nWe start with the $2k-n$ vectors\n$\\{ e_{n-k+1}, e_{n-k}, \\ldots, e_{k-1}, e_{k} \\}$.\nWe will choose $n-k$ unit vectors, $z_1, \\ldots, z_{n-k}$,\nsuch that\n\\[\n\\{ z_1, \\ldots, z_{n-k}, e_{n-k+1},  \\ldots, e_{k-1},e_{k} \\}\n\\] \nforms an orthonormal basis for $\\mathcal V^*$. \nThe $n-k$ unit vectors $z_1, \\ldots, z_{n-k}$ will be chosen in\n$\\Span \\{ e_{1}, \\ldots, e_{n-k},\ne_{k+1}, \\ldots, e_{n} \\}$, and will therefore\nbe orthogonal to $\\{e_{n-k+1},  \\ldots, e_{k} \\}$.\n\nChoose a unit vector $z_1 \\in \\Span\\{e_1, e_n\\}$, satisfying\n$\\|\\Sigma z_1\\| = \\sigma_{k}$. We can do this using\nthe simple result given earlier, since\n$\\sigma_{1} \\geq \\sigma_{k} \\geq \\sigma_{n}$.\nWe note that $z_1 \\perp e_j$,\nand $\\Sigma z_1 \\perp  \\Sigma e_j$,  $j=n-k+1, \\ldots, k$.\n\nWe continue the construction, choosing a unit vector $z_2 \\in\n\\Span\\{e_2, e_{n-1}\\}$,\nsatisfying $\\| \\Sigma z_2\\| =\\sigma_{k}$.\nThis continues, until we have chosen a unit vector \n$z_{n-k}$ in $\\Span\\{e_{n-k}, e_{k+1}\\}$, satisfying\n$\\|\\Sigma z_{n-k}\\| =\\sigma_{k}$.\n\nThe vectors $z_1, \\ldots, z_{n-k}$ are mutually orthogonal, since each\none is in the span of two standard basis vectors, and these pairs\nof standard basis vectors are disjoint.\nAlso $z_i \\perp e_j$ for $i = 1,\\ldots, n-k$ and\n$j = n-k+1, \\ldots, k$, since each vector $z_i$ is in the\nspan of two standard basis vectors which are not in the set\n$\\{e_{n-k+1}, \\ldots, e_{k} \\}$.\nThus $\\{ z_1, \\ldots, z_{n-k}$, $e_{n-k+1}, e_{n-k}, \\ldots,\ne_{k-1},e_{k} \\}$ forms an orthonormal basis for $\\mathcal V^*$.\nSimilarly, since $\\Sigma$ is a diagonal matrix, the\nvectors $\\Sigma z_1, \\ldots, \\Sigma z_{n-k}, \\Sigma e_{n-k+1},\n\\ldots, \\Sigma e_{k}$ are mutually orthogonal.\n\n\nWe now show $\\kappa_{\\mathcal V^*}(\\Sigma) =\\sigma_{n-k+1} /\n\\sigma_k$.\nLet $b$ any nonzero vector in $\\mathcal V^*$, say, \n\\[\nb = \\beta_1 z_1 +\n\\cdots + \\beta_{n-k} z_{n-k} + \\beta_{n-k+1} e_{n-k+1} + \\cdots +\n\\beta_{k} e_{k}.\n\\]\nThe gain of $\\Sigma$ in the direction $b$ is\n\\begin{eqnarray*}\n\\frac{\\|\\Sigma b\\|}{\\|b\\|}&=&\n\\left( \\frac\n{\\sum_{i=1}^{n-k}  \\beta_i^2 \\|\\Sigma z_i\\|^2 +\n\\sum_{j=n-k+1}^{k} \\beta_j^2 \\|\\Sigma e_j\\|^2}\n{\\sum_{i=1}^{n-k} \\beta_i^2 \\|z_i\\|^2 +\n\\sum_{j=n-k+1}^{k} \\beta_j^2\\|e_j\\|^2}\n\\right) ^{1/2}\\\\\n&=&\n\\left( \\frac\n{\\sum_{i=1}^{n-k}  \\beta_i^2 \\sigma_k^2 +\n\\sum_{j=n-k+1}^{k} \\beta_j^2 \\sigma_j^2}\n{\\sum_{i=1}^{n} \\beta_i^2}\n\\right) ^{1/2},\n\\end{eqnarray*}\nand therefore\n$\\sigma_{n-k+1} \\geq \\|\\Sigma b\\|/\\|b\\| \\geq \\sigma_{k}$.\nFor $b = e_{n-k+1}$, $\\|\\Sigma b\\| / \\|b\\| = \\sigma_{n-k+1} $,\nso $G_\\mathrm{max} =  \\sigma_{n-k+1}$;\nfor $b = e_{k}$, we have $\\| \\Sigma b\\| / \\|b\\| = \\sigma_{k} $,\nso $G_\\mathrm{min} = \\sigma_{k}$.\nIt follows that $\\kappa_{\\mathcal V^*}(\\Sigma) \n= \\sigma_{n-k+1} / \\sigma_k$.\n\nNow we will show that for any subspace $\\mathcal V$ of dimension\n$k$, $\\kappa_{\\mathcal V} (\\Sigma)\\geq \\sigma_{n-k+1} /\n\\sigma_k$.\nBy the Courant-Fischer theorem, for any subspace\n$\\mathcal{V}$ of dimension $k$, $G_\\mathrm{max} \\geq\n\\sigma_{n-k+1}$ and $G_\\mathrm{min} \\leq \\sigma_{k}$.\nIt follows that\n$\\kappa_{\\mathcal V}(\\Sigma) =  G_\\mathrm{max}/{G_\\mathrm{min}}\n\\geq \\sigma_{n-k+1}/\\sigma_k$.\nThis establishes~(\\ref{sol2}), and therefore~(\\ref{sol}).\n\n\\bibliographystyle{plain}\n%\\bibliography{min_cond_sub}\n\\begin{thebibliography}{1}\n\n\\bibitem{Ber:05}\nD.~S. Bernstein.\n\\newblock {\\em Matrix Mathematics: {T}heory, facts, and formulas,\nwith\n  application to linear systems theory}.\n\\newblock Princeton University Press, 2005.\n\n\\bibitem{ChanF:88}\nT.~F. Chan and D.~E. Foulser.\n\\newblock Effectively well-conditioned linear systems.\n\\newblock {\\em SIAM Journal on Scientific and Statistical\nComputing},\n  9(6):963--968, November 1988.\n\n\\bibitem{HoJ:85}\nR.~A. Horn and C.~A. Johnson.\n\\newblock {\\em Matrix Analysis}.\n\\newblock Cambridge University Press, 1985.\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "ee6adfd1ced80fc728b6dce0fcb59f9141f5a37a", "size": 14249, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Journal/Volume1/Number1/author_source/JoshiBoyd/article/min_cond_sub.tex", "max_stars_repo_name": "rejecta/mathematica", "max_stars_repo_head_hexsha": "ed41246ae85e69cb3cc5b72b8c41eee42bd04925", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-06-16T15:53:24.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-14T20:01:43.000Z", "max_issues_repo_path": "Journal/Volume1/Number1/author_source/JoshiBoyd/article/min_cond_sub.tex", "max_issues_repo_name": "rejecta/mathematica", "max_issues_repo_head_hexsha": "ed41246ae85e69cb3cc5b72b8c41eee42bd04925", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Journal/Volume1/Number1/author_source/JoshiBoyd/article/min_cond_sub.tex", "max_forks_repo_name": "rejecta/mathematica", "max_forks_repo_head_hexsha": "ed41246ae85e69cb3cc5b72b8c41eee42bd04925", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7242268041, "max_line_length": 87, "alphanum_fraction": 0.6638360587, "num_tokens": 5296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.41430617621195037}}
{"text": "\\section{Topos} \\label{topos}\nIn this subsection we will examine the categorical interpretation of finite sets.\nIn particular, we will prove that discrete Kuratowski finite types form a\n\\(\\Pi\\)-pretopos.\nA lot of the work for this proof has been done already: we have already proven\nthat discrete Kuratowski finiteness is equivalent to cardinal finiteness\n(\\Cref{cardinal-kuratowski}), meaning that we can work with the latter\ndefinition which is much simpler to prove things about.\n\nThere are two reasons we're interested in the categorical and topos-theoretic\ninterpretation of finite sets: first, it's an important theoretical grounding\nfor finite sets, which allows us to understand them in the context of other\nset-like constructions.\nSecondly, and more practically, the language of a topos is (or in our case the\n\\(\\Pi\\)-pretopos) is a common standard framework for doing mathematics\ngenerally.\nThis makes it a good basis for an API for building QuickCheck-like generators,\nfor example.\n\\subsection{Categories in HoTT}\nAt first glance, HoTT seems like a perfect setting for category theory: the\nunivalence axiom identifies isomorphisms with equality, a useful tool for\ncategory theory missing from MLTT.\nWhile this initial impression is broadly true, the construction of categories in\nHoTT is unfortunately quite complex and involved.\n\nMuch of this subsection is simply a summary of parts of \\citet[section\n9]{hottbook}.\nThe formal proofs we provide are part translation of those proofs in that\nsection, part from \\citep{iversenFredefoxCat2018}\n\\citep{huProofrelevantCategoryTheory2020}, and part our own.\n\nFirst, we need to think about the type of objects and arrows.\nWe cannot, unfortunately, leave them unrestricted: because of the potential for\nhigher homotopy in HoTT types, we have\nto restrict the type of arrows to just the sets.\nThis notion: that of a category with all the usual laws such that arrows are a\nset, is called a \\emph{precategory}.\n\\begin{agdalisting}\n  \\ExecuteMetaDataInline[agda/Categories.tex]{precategory}\n\\end{agdalisting}\nWe will use long arrows to refer to morphisms within a category:\n\\begin{agdalisting*}\n  \\ExecuteMetaDataInline[agda/Categories.tex]{morph-arrow}\n\\end{agdalisting*}\n\nFrom here, we can define a notion of isomorphisms.\n\\begin{agdalisting}\n  \\ExecuteMetaDataInline[agda/Categories.tex]{isomorphism}\n\\end{agdalisting}\nIt's a condition on this type which separates the precategories from the\ncategories: if it satisfies a form of univalence, it the precategory is a full\ncategory.\n\\begin{agdalisting}\n  \\ExecuteMetaDataInline[agda/Categories.tex]{cat-univalence}\n\\end{agdalisting}\n\\subsection{The Category of Sets}\nNext we'll look at how to construct the category of sets (in the HoTT sense).\nMuch of this work comes directly from \\citet{rijkeSetsHomotopyType2015} and\n\\citet[section 10]{hottbook} (the latter of which is in fact an updated and\nslightly less detailed version of the former).\nIn particular, our treatment (and definition) of categories and topoi comes\ndirectly from those works.\nWe have provided in the formalisation a proof that sets in CuTT form a\n\\(\\Pi\\)-pretopos: this proof (in HoTT) is in fact the main result of\n\\citet{rijkeSetsHomotopyType2015}; our contribution is simply the formalisation.\n\nThe objects are represented by a \\(\\Sigma\\):\n\\begin{agdalisting*}\n  \\ExecuteMetaDataInline[agda/Snippets/Category.tex]{hset}\n\\end{agdalisting*}\nThis will be quite similar to our objects for finite sets.\n\nSince sets in HoTT don't form a topos, there are quite a few smaller lemmas we\nneed to prove to get as close as we can (a \\(\\Pi W\\)-pretopos): we won't include\nthem here, other than the closure proofs in the following subsection.\n\\subsection{Closure}\nThe two most involved proofs for showing that discrete Kuratowski sets form a\n\\(\\Pi\\)-pretopos are those proofs that show closure under \\(\\Pi\\) and\n\\(\\Sigma\\).\nWe will describe them here.\n\nIn \\cite[Theorem 4.21]{fruminFiniteSetsHomotopy2018}, Kuratowski finite types\nare proven to be closed under surjections, products, and sums.\nHere we prove closure under products and sums, but also functions, \\(\\Sigma\\),\nand \\(\\Pi\\) (and furthermore our closure proofs are given on all of the\nfiniteness predicates that they apply to).\n\\paragraph{Closure of the Ordered Predicates}\nFirst, we will show that split enumerability (and, by extension, manifest\nenumerability) are closed under \\(\\Pi\\) and \\(\\Sigma\\).\nThis is the first stepping stone on our way to prove that cardinal finiteness is\nclosed under the same.\n\nPractically speaking, these proofs also open up a wide number of other closure\nproofs to us.\nBy proving that dependent products and sums are finite, we get the non-dependent\ncases for free.\n\n\\begin{lemma} \\label{split-enum-sigma}\n  Split enumerability is closed under \\(\\Sigma\\).\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Cardinality/Finite/SplitEnumerable.tex]{split-enum-sigma}\n  \\end{agdalisting*}\n\\end{lemma}\n\\begin{proof}\n  Our task is to construct the two components of the output pair: the support\n  list, and the cover proof.\n  We'll start with the support list: this is constructed by taking the Cartesian\n  product of the input support lists.\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Cardinality/Finite/SplitEnumerable.tex]{sup-sigma}\n  \\end{agdalisting*}\n  We use do notation here because we're working the list monad: this applies the\n  latter function (\\(ys\\)) to every element of the list \\(xs\\), and concatenates\n  the results.\n\n  To show that this does indeed cover every element of the target type is a\n  little intricate, but not necessarily difficult.\n\\end{proof}\n\nNext we'll look at closure under \\(\\Pi\\).\nIn MLTT, this is of course not provable: since all of the finiteness predicates\nwe have seen so far imply decidable equality, and since we don't have any kind\nof decidable equality on functions in MLTT, we know that we won't be able to\nshow that any kind of function is finite; even one like \\(\\AgdaDatatype{Bool}\n\\rightarrow \\AgdaDatatype{Bool}\\).\n\nCuTT is not so restricted.\nSince we have things like function extensionality and transport, we can indeed\nprove the finiteness of function types.\nOur proof here makes use directly of the univalence axiom, and makes use\nfurthermore of all the previous closure proofs.\n\\begin{theorem} \\label{split-enum-pi}\n  Split enumerability is closed under dependent functions\n  (\\(\\Pi\\)-types).\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Cardinality/Finite/ManifestBishop.tex]{pi-clos}\n  \\end{agdalisting*}\n\\end{theorem}\n\\begin{proof}\n  Let \\(A\\) be a split enumerable type, and \\(U\\) be a type family from \\(A\\),\n  which is split enumerable over all points of \\(A\\).\n\n  As \\(A\\) is split enumerable, we know that it is also manifestly Bishop finite\n  (\\Cref{split-enum-to-manifest-bishop}), and consequently we know \\(A\n  \\simeq \\AgdaDatatype{Fin}\\;n\\), for some \\(n\\) (\\Cref{bishop-equiv}).\n  We can therefore replace all occurrences of \\(A\\) with \\(\\AgdaDatatype{Fin}\\;n\\),\n  changing our goal to:\n  \\begin{equation*}\n    \\frac{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;(\\AgdaDatatype{Fin}\\;n) \\; \\; \\; \\left((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;\\left( U\\;x \\right)\\right)\n    }{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\left((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow U\\;x\\right)\n    }\n  \\end{equation*}\n  \n  We then define the type of \\(n\\)-tuples over some type family.\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Data/Tuple/UniverseMonomorphic.tex]{tuple-def}\n  \\end{agdalisting*}\n  We can show that this type is equivalent to functions (proven in our formalisation):\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Data/Tuple/UniverseMonomorphic.tex]{tuple-iso}\n  \\end{agdalisting*}\n  And therefore we can simplify again our goal to the following:\n  \\begin{equation*}\n    \\frac{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;(\\AgdaDatatype{Fin}\\;n) \\; \\; \\; ((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\left( U\\;x \\right))\n    }{\n      \\AgdaFunction{\\ensuremath{\\mathcal{E}!}}\\;\\left(\\AgdaFunction{Tuple}\\;n\\;U\\right)\n    }\n  \\end{equation*}\n  \n  We can prove this goal by showing that \\(\\AgdaFunction{Tuple}\\;n\\;U\\) is split\n  enumerable: it is made up of finitely many products of points of \\(U\\), which\n  are themselves split enumerable, and \\agdatop, which is also split enumerable.\n  \\Cref{split-enum-sigma} shows us that the product of finitely many split\n  enumerable types is itself split enumerable, proving our goal.\n\\end{proof}\n\\paragraph{Closure on Cardinal Finiteness}\nSince we don't have a function of type \\(\\agdacal{C}\\;A \\rightarrow\n\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A\\), closure proofs on \\(\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\) do not transfer over to\n\\agdacal{C} trivially (unlike with \\(\\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\) and \\(\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\)).\nThe cases for \\agdabot, \\agdatop, and \\(\\AgdaDatatype{Bool}\\) are simple to adapt: we\ncan just propositionally truncate their Bishop finiteness proof.\n\nNon-dependent operators like \\AgdaFunction{\\(\\times\\)},\n\\AgdaFunction{\\(\\uplus\\)}, and \\(\\rightarrow\\) are also relatively\nstraightforward: since \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_\\rVert}}\\) forms a\nmonad, we can apply \\(n\\)-ary functions to values inside it, combining them\ntogether.\n\\begin{agdalisting*}\n  \\ExecuteMetaDataInline[agda/Cardinality/Finite/ManifestBishop.tex]{times-clos-sig}\n\\end{agdalisting*}\nInto a truncated context:\n\\begin{agdalisting*}\n  \\ExecuteMetaDataInline[agda/Cardinality/Finite/Cardinal.tex]{times-clos-impl}\n\\end{agdalisting*}\n\n\nUnfortunately, for the dependent type formers like \\(\\Sigma\\) and \\(\\Pi\\), the\nsame trick does not work.\nWe have closure proofs like:\n\\begin{equation*}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\; \\; \\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x))\n  }{\n    \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x)\n  }\n\\end{equation*}\nIf we apply the monadic truncation trick we can derive closure proofs like the\nfollowing:\n\\begin{equation*}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\; \\; \\; \\AgdaDatatype{\\ensuremath{\\lVert}}\\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x)) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }\n\\end{equation*}\nHowever our \\emph{desired} closure proof is the following:\n\\begin{equation*}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\; \\; \\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}})\n  }{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }\n\\end{equation*}\nThey don't match!\n\nThe solution would be to find a function of the following type:\n\\begin{equation*}\n  ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}) \\rightarrow\n  \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n\\end{equation*}\nHowever we might be disheartened at realising that this is a required goal: the\nabove equation is \\emph{extremely} similar to the axiom of choice!\n\\begin{definition}[Axiom of Choice] \\label{axiom-of-choice}\n  In HoTT, the axiom of choice is commonly defined as follows \\cite[lemma\n  3.8.2]{hottbook}.\n  For any set \\(A\\), and a type family \\(U\\) which is a set at all the points\n  of \\(A\\), the following function exists:\n  \\begin{equation*}\n    \\left( (x : A) \\rightarrow  \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\right) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation*}\n\\end{definition}\nLuckily the axiom of choice \\emph{does} hold for cardinally finite types,\nallowing us to prove the following:\n\\begin{lemma}\n  The axiom of choice holds for finite sets.\n  \\begin{equation*}\n    \\agdacal{C}\\;A \\rightarrow ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation*}\n\\end{lemma}\n\\begin{proof}\n  Let \\(A\\) be a cardinally finite type, \\(U\\) be a type family on \\(A\\), and\n  \\(f\\) be a dependent function of type \\(\\Pi(x : A) , \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\\).\n\n  First, since our goal is itself propositionally truncated, we have access to\n  values under truncations: put another way, in the context of proving our goal,\n  we can rely on the fact that \\(A\\) is manifestly Bishop finite.\n  Using the same technique as we did in \\Cref{split-enum-pi}, we can switch\n  from working with dependent functions from \\(A\\) to \\(n\\)-tuples, where \\(n\\)\n  is the cardinality of \\(A\\).\n  This changes our goal to the following:\n  \\begin{equation}\n    \\AgdaFunction{Tuple}\\;n\\;(\\AgdaDatatype{\\ensuremath{\\lVert\\_\\rVert}}\\;\\AgdaFunction{\\ensuremath{\\circ}}\\; U) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaFunction{Tuple}\\;n\\;U\\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation}\n  Since \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_ \\rVert}}\\) is closed under finite products, this function\n  exists (in fact, using the fact that \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_ \\rVert}}\\) forms a monad, we\n  can recognise this function as \\verb+sequenceA+ from the \\verb+Traversable+\n  class in Haskell).\n\\end{proof}\nThis lemma is a well-known folklore theorem.\n\nThis gets us all of the necessary closure proofs on \\agdacal{C}, and as a result\nwe know the following theorem.\n\\begin{theorem} \\label{kuratowski-topos}\n  Decidable Kuratowski finite sets form a \\(\\Pi\\)-pretopos.\n\\end{theorem}\n\\subsection{The Absence of the Subobject Classifier}\nIt's a little unsatisfying that our topos construction has so many caveats: we\nhave to prove a lot of small, uninteresting lemmas just to get to a\n\\(\\Pi\\)-pretopos, all because we can't prove the one or two larger, simple\nlemmas which would show that sets form a topos. \nSo what exactly are we missing?\n\nWell, one of the characteristic features of topos theory is that there are a\nwide variety of equivalent ways to show that something is a topos (a natural\nconsequence of their being a wide variety of things which qualify as toposes).\nFor the direction we have been going, though, the big missing feature is the\n\\emph{subobject classifier}.\n\nA subobject in this context refers to a subset.\nIn set theory, we can often describe a subset of some set \\(A\\) with the\nfollowing notation:\n\\begin{equation*}\n  \\left\\{ x \\;\\vert\\; x \\in A ; P(x) \\right\\}\n\\end{equation*}\nThis is the subset of elements in \\(A\\) which satisfy some predicate \\(P\\).\n\nType theoretically, the way to express the same would be\n\\(\\AgdaDatatype{\\(\\Sigma\\)}\\;A\\;P\\): if we wanted to describe the subset of \\Nat\nsmaller than 10 we would write\n\\mbox{\\(\\AgdaDatatype{\\(\\Sigma\\)[}\\;\\AgdaBound{n}\\;\\AgdaDatatype{:}\\;\\Nat\\;\\AgdaDatatype{]}\\;\\AgdaBound{n}\\;\\AgdaFunction{\\(<\\)}\\;\\AgdaNumber{10}\\)}.\nIn general, however, this type holds too many elements to properly classify the\nsubsets of the larger set: there may be more than one inhabitant of \\(P\\;x\\) for\nany given \\(x\\).\nFor \\emph{propositions}, however, (i.e. where \\(P\\) is a proposition),\n\\AgdaDatatype{\\(\\Sigma\\)} represents a perfectly valid encoding of subsets.\n\nThe subobject classifier is an object within the topos (which must be a\ncontraction) which classifies monomorphisms (injections).\nWe can actually show that the ``subset'' notion we just defined does in fact\nclassify monomorphisms in sets in HoTT (in fact directly through univalence),\nbut at this point we run into our one and only size problem in this paper.\nThe actual object corresponding to the subobject classifier is the following:\n\\begin{agdalisting*}\n  \\ExecuteMetaDataInline[agda/Snippets/Topos.tex]{prop-univ}\n\\end{agdalisting*}\nThe problem here, crucially, is that the universe level of this type is one\nhigher than the universe level of the types it bounds.\nIn other words, this is \\emph{not} an object in our \\(\\Pi\\)-pretopos of sets,\nwhere the types are all of universe level 0.\n\nRemember that the purpose of universe levels was to prevent Girard's paradox.\nHowever, there is an axiom which removes universe levels to a certain extent\nwhich does \\emph{not} imply the paradox: propositional resizing.\n\\begin{definition}[Propositional Resizing]\n  The axiom of propositional resizing states that the following two types, for\n  any universe level \\(u\\), are equivalent:\n  \\begin{agdalisting*}\n    \\ExecuteMetaDataInline[agda/Snippets/Topos.tex]{prop-resize}\n  \\end{agdalisting*}\n\\end{definition}\nIf propositional resizing holds, then we \\emph{can} in fact construct a\nsubobject classifier, for both sets and finite sets. \\todo{Mention lem?}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../paper\"\n%%% End:\n", "meta": {"hexsha": "51e1f57d6469dc798fe6f976dab65a719dbc15ee", "size": 17441, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/topos.tex", "max_stars_repo_name": "oisdk/masters-thesis", "max_stars_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "sections/topos.tex", "max_issues_repo_name": "oisdk/masters-thesis", "max_issues_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/topos.tex", "max_forks_repo_name": "oisdk/masters-thesis", "max_forks_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 51.146627566, "max_line_length": 273, "alphanum_fraction": 0.7438793647, "num_tokens": 5018, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.41426671996102454}}
{"text": "\\par\n\\section{Data Structure}\n\\label{section:SubMtx:dataStructure}\n\\par\n\\par\nThe {\\tt SubMtx} structure has the following fields.\n\\begin{itemize}\n\\item\n{\\tt int type} : type of entries.\n\\begin{itemize}\n\\item {\\tt SPOOLES\\_REAL} : double precision real entries.\n\\item {\\tt SPOOLES\\_COMPLEX} : double precision complex entries.\n\\end{itemize}\n\\item\n{\\tt int mode} : storage mode.\n\\begin{itemize}\n\\item {\\tt SUBMTX\\_DENSE\\_ROWS} : dense, storage by rows.\n\\item {\\tt SUBMTX\\_DENSE\\_COLUMNS} : dense, storage by columns.\n\\item {\\tt SUBMTX\\_SPARSE\\_ROWS} : sparse, storage by rows.\n\\item {\\tt SUBMTX\\_SPARSE\\_COLUMNS} : sparse, storage by columns.\n\\item {\\tt SUBMTX\\_SPARSE\\_TRIPLES} : sparse, storage by \n      $(i,j,a_{i,j})$ triples.\n\\item {\\tt SUBMTX\\_DENSE\\_SUBROWS} : sparse, storage by dense subrows.\n\\item {\\tt SUBMTX\\_DENSE\\_SUBCOLUMNS} : \n      sparse, storage by dense subcolumns.\n\\item {\\tt SUBMTX\\_DIAGONAL} : a diagonal matrix.\n\\item {\\tt SUBMTX\\_BLOCK\\_DIAGONAL\\_SYM} : a symmetric block\n      diagonal matrix with $1 \\times 1$ and $2 \\times 2$ blocks.\n\\item {\\tt SUBMTX\\_BLOCK\\_DIAGONAL\\_HERM} : a hermitian block\n      diagonal matrix with $1 \\times 1$ and $2 \\times 2$ blocks.\n\\end{itemize}\n\\item\n{\\tt int rowid} : object's row id, default value is {\\tt -1}.\n\\item\n{\\tt int colid} : object's column id, default value is {\\tt -1}.\n\\item\n{\\tt int nrow} : number of rows \n\\item\n{\\tt int ncol} : number of columns \n\\item\n{\\tt int nent} : number of stored matrix entries.\n\\item\n{\\tt DV wrkDV} : \nobject that manages the owned working storage.\n\\item\n{\\tt SubMtx *next} : \nlink to a next object in a singly linked list.\n\\end{itemize}\n\\par\nOne can query the type of the object using these simple macros.\n\\begin{itemize}\n\\item\n{\\tt SUBMTX\\_IS\\_REAL(mtx)} is {\\tt 1} if {\\tt mtx} \nhas real entries and {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_COMPLEX(mtx)} is {\\tt 1} if {\\tt mtx} \nhas complex entries and {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_DENSE\\_ROWS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas dense rows as its storage format, \nand {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_DENSE\\_COLUMNS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas dense columns as its storage format, \nand {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_SPARSE\\_ROWS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas sparse rows as its storage format, \nand {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_SPARSE\\_COLUMNS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas sparse columns as its storage format, \nand {\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_SPARSE\\_TRIPLES(mtx)} is {\\tt 1} if {\\tt mtx} \nhas sparse triples as its storage format, \n{\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_DENSE\\_SUBROWS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas dense subrows as its storage format, \n{\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_DENSE\\_SUBCOLUMNS(mtx)} is {\\tt 1} if {\\tt mtx} \nhas dense subcolumns as its storage format, \n{\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_DIAGONAL(mtx)} is {\\tt 1} if {\\tt mtx} is diagonal, \n{\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_BLOCK\\_DIAGONAL\\_SYM(mtx)} is {\\tt 1} if {\\tt mtx} \nis block diagonal and symmetric, \n{\\tt 0} otherwise.\n\\item\n{\\tt SUBMTX\\_IS\\_BLOCK\\_DIAGONAL\\_HERM(mtx)} is {\\tt 1} if {\\tt mtx} \nis block diagonal and hermitian, \n{\\tt 0} otherwise.\n\\end{itemize}\n", "meta": {"hexsha": "0176301fd0775f05cad56eaaa8c51454e82e2e14", "size": 3219, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/dataStructure.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/dataStructure.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/dataStructure.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 32.8469387755, "max_line_length": 70, "alphanum_fraction": 0.6952469711, "num_tokens": 1113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4142667122064194}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb, graphicx, float, hyperref, mathtools}\n\\usepackage[dvipsnames]{xcolor}\n%, amsmath, ,, nccmath, sectsty, }\n\n\\title{Computer Graphics - Notes}\n\\author{Matteo Alberici}\n\\date{January 2022}\n\n\\begin{document}\n\\maketitle\n\\newpage\n\\newpage\n\\tableofcontents\n\\newpage\n\n% ------------------------ %\n% Chapter 1 - Introduction\n% ------------------------ %\n\\section{Introduction}\n\\textbf{Computer graphics} deals with generating images with the aid of computers and has four main branches: \n\\begin{itemize}\n    \\item \\textbf{Rendering}: shading, raytracing, and photon mapping\n    \\item \\textbf{Geometry Processing and Modelling}: description and manipulation of surfaces\n    \\item \\textbf{Animation and Simulation}: physically \"correct\" behaviours reproduction\n    \\item \\textbf{Scientific Visualization}: graphical representation of data\n\\end{itemize}\nThree paradigms exist about computer graphics:\n\\begin{itemize}\n    \\item \\textbf{Raytracing}: represents complex scenes with photorealistic quality and \"real\" global effects, but it is expensive and targets offline applications\n    \\item \\textbf{Rasterization}: represent efficiently real time applications with \"fake\" global effects\n    \\item \\textbf{Image-based rendering}: creates novel views by combining images (Neural rending)\n\\end{itemize}\n\n\\newpage\n\n% ----------------------------- %\n% Chapter 2 - Raytracing Basics\n% ----------------------------- %\n\\section{Raytracing Basics}\n\\subsection{Ray Casting}\n\\textbf{Ray casting} determines the color of all pixels of an image: a \\textbf{ray} is traced from a \\textbf{camera} to a \\textbf{scene} passing through an \\textbf{image} full of pixels, copying the color of the intersected object on the correspondent pixel on the image.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=10cm]{Figure 1 - Ray Casting.png}\n    \\caption{Ray casting representation}\n\\end{figure}\n\\subsection{Whitted Ray Tracing}\nIn \\textbf{whitted ray tracing}, one \\textbf{primary ray} per pixel is traced, then for each of them:\n\\begin{enumerate}\n    \\item Find the intersection with the scene\n    \\item Consider generating \\textbf{secondary rays} recursively:\n        \\begin{itemize}\n            \\item Shadow rays\n            \\item Reflection rays\n            \\item Refraction rays\n        \\end{itemize}\n    \\item Color the pixel with the aggregated result \n\\end{enumerate}\nA ray terminates when it leaves the scene without hitting any object, when the maximal recursion depth is reached, or finally when the contribution to the final color is negligible.\n\\newpage\n\\subsection{Raytracing Computation}\n\\subsubsection{Camera and Image Definitions}\nThe camera is located at coordinates $(0,0,0)$ and creates an opening angle $\\alpha$.\nThe image is on a plane with $z = 1$ and has a resolution of $w\\cdot s \\times h\\cdot s$, where $s$ represents the dimensions of a pixel and is computed as follows:\n\\begin{center}\n    $ s = \\displaystyle\\frac{2 \\cdot tg(\\displaystyle\\frac{\\alpha}{2})}{w} $\n\\end{center}\nEach pixel has coordinates $p_{ij} = (x_{ij}, y_{ij}, z_{ij})$.\n\\subsubsection{Ray Computation}\nGiven the ray origin $o \\in \\mathbb{R}^3$, the distance $t$ between $o$ and the intersection, and the ray direction $d$, then a ray is defined as follows:\n\\begin{center}\n    $\\gamma(t) = o + t \\cdot d$,\n\\end{center}\n\n\\subsubsection{Per-Pixel Computation}\nLet's start by the top-left corner with coordinates $ (X, Y, 1) $, where $ X $ and $ Y $ are computed as follows:\n\\begin{center}\n    $ X = \\displaystyle\\frac{- w \\cdot s}{2} \\ \\ \\ \\ \\ \\ \\ Y = \\displaystyle\\frac{h \\cdot s}{2} $\n\\end{center}\nThe loop for computing the \\textbf{per-pixel direction} $ d $ is the following:\n\\begin{verbatim}\n    for i = 0 to w - 1\n        for j = 0 to h - 1\n            dx = X + i * s + 0.5 * s\n            dy = Y - j * s - 0.5 * s\n            dz = 1\n            d = d / ||d||\n\\end{verbatim}\n\\newpage\n\\subsubsection{Ray-Sphere Intersection}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 2 - Intersections.png}\n    \\caption{Intersection points on a sphere}\n\\end{figure}\nThe scene holds some objects such as a sphere with center $c$ and ray $r$. The ray intersects the sphere if there exists some $t$ such that:\n\\begin{center}\n    $||\\gamma(t) - c|| = r $\n\\end{center}\nThere exist two methods for computing the intersection points $t_1$ and $t_2$. \\\\ \nThe first method consists in computing points $t_1$ and $t_2$ as follows:\n\\begin{center}\n    $t_{1,2} = \\langle d,c\\rangle \\pm \\sqrt{\\langle d,c\\rangle^2 - ||c||^2 + r^2} $\n\\end{center}\nFurthermore, depending on their sign, we obtain a solution:\n\\begin{itemize}\n    \\item $ t_1, t_2 < 0 $: the sphere is located behind the ray\n    \\item $ t_1 \\ xor \\ t_2 < 0 $: the ray origin is inside the sphere, therefore there is only one point of intersection\n    \\item $ t_1, t_2 > 0 $: there exist two points of intersection\n\\end{itemize}\nThe second method consists in computing $D$ as follows:\n\\begin{center}\n    $ D = \\sqrt{||c||^2 - \\langle c,d\\rangle^2}$\n\\end{center}\nFurthermore, we can differ between three cases:\n\\begin{itemize}\n    \\item $ D < r $: there exist two solutions\n    \\item $ D = r $: there exists one solution\n    \\item $ D > r $: there exists no solution\n\\end{itemize}\nFinally, we can compute points $t_1$ and $t_2$ as follows:\n\\begin{center}\n    $t_{1,2} = \\langle c,d\\rangle \\pm \\sqrt{r^2 - D^2}$\n\\end{center}\n\n% --------------------------- %\n% Chapter 3 - Lighting Models\n% --------------------------- %\n\\section{Lighting Models}\nThere exists a set of rules for computing \\textbf{color values} of objects' surfaces which models the light sources and the surface itself.\n\\subsection{Illumination Factors}\nThe \\textbf{intensity} $I$ of a light source depends on many factors: the object's color and reflective properties, the light's position and intensity, the viewer's position, the \\textbf{normal} $n$ of the surface point $p$, and the distance from $p$ to the light.\n\\subsection{Phong Lighting Model}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=9cm]{Figure 3 - Phong Model.png}\n    \\caption{Phong model factors}\n\\end{figure}\n\\subsubsection{Diffuse Reflection}\n\\textbf{Diffuse reflection} simulates \\textbf{Lambertian surfaces} on which light only depends on the light direction $l$ and on the normal $n$ and is reflected evenly in all directions. These surfaces have a material-dependent reflection constant $\\rho_d \\leq 1$ and follow the \\textbf{Lambert's Cosine Law}, which states that the intensity $I_d$ coming from a diffuse reflection is proportional to the cosine of the angle between the normal $n$ and the direction $l$:\n\\begin{center}\n    $I_d = \\rho_d \\ \\cdot \\langle n,l\\rangle \\cdot \\ I$\n\\end{center}\nIf $\\langle n,l\\rangle \\ < 0$, then the light source is behind the surface and has an intensity $I = 0$.\n\\subsubsection{Ambient Illumination}\n\\textbf{Ambient illumination} simulates indirect lightning with multiple reflections between objects and is independent of the light source and the viewpoint. \\\\ Given a scene constant $I_a$ and a material-dependent reflection constant $\\rho_a \\leq 1$, the ambient term is computed as follows:\n\\begin{center}\n    $ \\rho_a \\cdot I_a $\n\\end{center}\n\\subsubsection{Specular Reflection}\n\\textbf{Specular reflection} simulates shiny surfaces on which light is reflected in exactly one reflection direction with maximum intensity.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=7cm]{Figure 4 - Specular Reflection.png}\n    \\caption{Specular reflection representation}\n\\end{figure}\n\\noindent\nThe \\textbf{reflection vector} $ r $ is computed as follows:\n\\begin{center}\n    $ r = 2 \\cdot n \\ \\cdot \\langle n,l\\rangle - \\ l $\n\\end{center}\nFinally, given a surface specular coefficient $\\rho_s$ and a \\textbf{shininess} $k \\geq 1$, the specular term $ I_s $ is computed as follows:\n\\begin{center}\n    $ I_s = \\rho_s \\ \\cdot \\langle v,r\\rangle^k \\cdot \\ I $\n\\end{center}\n\\subsubsection{Phong Lighting Model Computation}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 5 - Lighting Model.png}\n    \\caption{Phong lighting model representation}\n\\end{figure}\nThe \\textbf{Phong lightning model} consists of the superposition of diffuse reflection, ambient illumination, and specular reflection. \\\\\nGiven $n$ light sources and a self-emitting intensity $I_e$, the model is defined as follows:\n\\begin{center}\n    $ I = I_e + \\rho_a \\cdot I_a + \\displaystyle\\sum^n_{j=1}(\\rho_d \\ \\cdot \\langle n_j,l_j\\rangle + \\ \\rho_s \\ \\cdot \\langle v,r_j\\rangle^k) \\cdot I_j  $\n\\end{center}\n\\newpage\n\\subsubsection{Blinn-Phong Specular Reflection}\nIn order to simplify the computations for the Phong model, we can use the \\textbf{half vector} $ h $:\n\\begin{center}\n    $ h = \\displaystyle\\frac{1}{2} \\cdot (l + v) $\n\\end{center}\nWe can compute the specular term $I_s$ as follows:\n\\begin{center}\n    $ I_s = \\ p_s \\ \\cdot \\langle n,h\\rangle^{4k} \\cdot \\ I $ \n\\end{center}\n\\subsection{Light Sources}\nWe can distinguish between three types of light sources: point sources, directional sources, and spot sources.\n\\subsubsection{Point Light Sources}\n\\textbf{Point light sources} have an intensity $I$ and are specified by their position, from which they radiate evenly.\n\\subsubsection{Directional Light Sources}\n\\textbf{Directional light sources} consist of an infinite set of point sources and are specified by their direction.\n\\subsubsection{Spot Light Sources}\n\\textbf{Spot light sources} generate light cones and are specified by their position $p$, their direction $d$, and their opening angle $\\Theta_L$. The maximal intensity is found along direction $d$, otherwise it decreases as follows:\n\\begin{center}\n    $I'(\\Theta) = cos^k \\ \\Theta \\cdot I$\n\\end{center}\nIf $\\Theta > \\Theta_L$, then $I'(\\Theta) = 0$.\n\\subsection{Distance Attenuation}\nLight intensity \\textbf{attenuation} is proportional to $r^2$ and there exist two ways two compute it. The first one is the following:\n\\begin{center}\n    $att(r) = \\displaystyle\\frac{1}{max(r,r_{min})^2}$\n\\end{center}\nThe second one needs the extra parameters $a_1$, $a_2$, and $a_3$:\n\\begin{center}\n    $att(r) = \\displaystyle\\frac{1}{a_1 + a_2 \\cdot r + a_3 \\cdot r^2}$\n\\end{center}\n\\newpage\n\\noindent\nNow we can define the \\textbf{extended Phong model} as follows:\n\\begin{center}\n    $ I = I_e + \\rho_a \\cdot I_a + \\displaystyle\\sum^n_{j=1}(\\rho_d \\ \\cdot \\langle n_j,l_j\\rangle + \\ \\rho_s \\ \\cdot \\langle v,r_j\\rangle^k) \\cdot I_j  \\cdot att(d)$\n\\end{center}\nWhile computing lightning, all direction vectors must be normalized and we must handle cases in which cosines are negative.\n\\subsection{Bidirectional Reflectance Distribution Function}\n\\textbf{Bidirectional Reflectance Distribution Function} (\\textbf{BRDF})\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 6 - BRDF.png}\n    \\caption{Ray casting representation}\n\\end{figure}\n\n\\newpage\n\n% --------------------------- %\n% Chapter 4 - Light and Color\n% --------------------------- %\n\\section{Light and Color}\nLight consists of charged particles emitting electromagnetic radiations (EMs). Humans can only see some EMs depending on the \\textbf{wavelength} $ \\gamma [nm] $. The contribution of each $\\gamma$ is described using \\textbf{Spectral Power Distribution} (\\textbf{SPD}).\n\\subsection{Color Perception}\nEyes have two kinds of photoreceptor cells: \\textbf{rods}, which perceive light intensity, and \\textbf{cones}, which perceive colors. Cones can be distinguished in three types: $S$ for short wavelengths, $M$ for medium ones, and $L$ for long ones. Given a cone sensitivity $w$ and the incoming SPD $I$, the \\textbf{cone stimulus} is the following:\n\\begin{center}\n    $ \\int w(\\gamma) \\cdot I(\\gamma) \\ d\\gamma $\n\\end{center}\n\\subsection{Displays}\nDisplays stimulate cones using several sub-pixels. Given sub-pixels' intensities $R$, $G$, and $B$, and SPDs $\\bar{r}$, $\\bar{g}$, and $\\bar{b}$, the emitted light is computed as follows:\n\\begin{center}\n    $I(\\gamma) = R \\cdot \\bar{r}(\\gamma) + G \\cdot \\bar{g}(\\gamma) + B \\cdot \\bar{b}(\\gamma)$\n\\end{center}\n\\subsection{Gamma Correction}\nThe relation between \\textbf{display input} $I_{in}$ and \\textbf{intensity shown} $I_{out}$ is non-linear, thus we should apply \\textbf{inverse gamma correction} to the intensity $I$:\n\\begin{center}\n    $I_{in} = I^{\\frac{1}{\\gamma}} \\ \\ \\ \\ 1.8 \\leq \\gamma \\leq 2.4$\n\\end{center}\nWe assign more bits to dark regions to which we are more sensitive. In short:\n\\begin{enumerate}\n    \\item Compute intensities\n    \\item Apply \\textcolor{OliveGreen}{inverse gamma correction} for perceptual encoding\n    \\item Display applies \\textcolor{blue}{gamma}\n    \\item Get the \\textcolor{red}{desired intensities} on the screen\n\\end{enumerate}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=4cm]{Figure 7 - Gamma Correction.png}\n    \\caption{Ray casting representation}\n\\end{figure}\n\\subsection{Tone Mapping}\nDisplays show a range of intensities $ (I_{black}, I_{white}) $ expressed in \\textbf{luminance} ($cd/m^2$). Since it is impossible to reproduce the real luminance range on a screen, we can use simple \\textbf{tone mapping} followed by gamma correction with parameters $\\alpha$ and $\\beta$:\n\\begin{center}\n    $I_{in} = max((\\alpha \\cdot I^\\beta)^{\\frac{1}{\\gamma}}, 1.0)$ \n\\end{center}\nValues outside the range must be clamped.\n\n\\newpage\n\n% ------------------ %\n% Chapter 5 - Meshes\n% ------------------ %\n\\section{Meshes}\nComplex surfaces can be approximated using \\textbf{triangle meshes}.\n\\subsection{Anatomy of Triangle Meshes}\nTriangle meshes are composed of:\n\\begin{itemize}\n    \\item \\textbf{Vertices}: $ V = \\{v_1,v_2,...,v_n\\}, \\ v_i \\in \\mathbb{R}^3 $\n    \\item \\textbf{Edges}: $ E = \\{e_1,e_2,...,e_l\\}, \\ e_i = [v_{i1},v_{i2}] $\n    \\item \\textbf{Faces}: $F = \\{f_1,f_2,...,f_m\\}, \\ f_i = [v_{i1}, v_{i2}, v_{i3}] $\n\\end{itemize}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=5cm]{Figure 8 - Mesh.png}\n    \\caption{Triangle mesh representation}\n\\end{figure}\n\\subsection{Ray-Triangle Intersection}\nFirst, we define the ray-plane intersection, where $t$ is computed as follows:\n\\begin{center}\n    $t = \\displaystyle\\frac{\\langle p - o,N\\rangle}{\\langle d,N\\rangle}$\n\\end{center}\nA triangle is defined by three points $p_1$, $p_2$, and $p_3$. In order to compute the intersection, we must find a $t$ such that:\n\\begin{center}\n    $p = \\gamma(t)$ is coplanar with $p_1$, $p_2$, $p_3$\n\\end{center}\nIf $ t > 0 $ and $ p $ is inside the triangle, then we compute lighting at point $p$. \\\\\nThe normal vector $ n $ at $ p $ is computed as follows:\n\\begin{center}\n    $n = \\displaystyle\\frac{(p_2 - p_1) \\ \\times \\ (p_3 - p_1)}{||(p_2 - p_1) \\ \\times \\ (p_3 - p_1)||}$\n\\end{center}\n\\subsection{Barycentric Coordinates}\nGiven a triangle $[p_1, p_2, p_3]$ and a point $p$ inside:\n\\begin{enumerate}\n    \\item Compute the area $W$ of the triangle\n    \\item Compute the areas $w_1$, $w_2$, and $w_3$ formed by $p$ and the edges opposite $p_1$, $p_2$, and $p_3$\n    \\item Normalize the areas: $\\lambda_i(p) = \\displaystyle\\frac{w_i}{W}$\n\\end{enumerate}\nThe obtained values are the \\textbf{barycentric coordinates} of $p$ with respect to triangle $[p_1, p_2, p_3]$ and have two properties:\n\\begin{itemize}\n    \\item Partition of unity: $\\displaystyle\\sum^3_{i=1} \\lambda_i(p) \\ = 1$\n    \\item Non-negativity: $\\lambda_i(p) \\geq 0 \\ $ for $\\ p \\in [p_1,p_2,p_3]$\n\\end{itemize}\nIf $p$ is not in the triangle, then the second property does not hold.\n\\subsubsection{Computation in 2D}\n\\begin{enumerate}\n    \\item Define $p_i = (x_i,y_i)$ and $p = (x,y)$\n    \\item Compute the area of triangle $[p1, p2, p3]$ via $2D$ determinant:\n        \\begin{center}\n            $2W = (x_2 - x_1)\\cdot(y_3 - y_1) - (x_3 - x_1) \\cdot (y_2 - y_1)$\n        \\end{center}\n    \\item Compute similarly $w_1$, $w_2$, and $w_3$\n\\end{enumerate}\n\\subsection{Computation in 3D}\n\\begin{enumerate}\n    \\item Define $p_i = (x_i,y_i, z_i)$ and $p = (x,y,z)$\n    \\item Compute the area of triangle $[p1, p2, p3]$ via $3D$ cross-product:\n        \\begin{center}\n            $ n = (p_2 - p_1) \\times (p_3 - p_1) \\ \\ \\ \\ \\ 2W = ||n|| $\n        \\end{center}\n    \\item Compute $w_1$, $w_2$, and $w_3$:\n        \\begin{center}\n            $n_i = (p_{i + 1} - p) \\times (p_{i - 1} - p) \\ \\ \\ \\ \\ 2w_i = ||n_i|| \\cdot sign(\\langle n_i, n\\rangle)$\n        \\end{center}\n\\end{enumerate}\n\\subsection{Procedural Textures}\nIn \\textbf{procedural textures}, the color of an object depends on the coordinates of its surface point:\n\\begin{itemize}\n    \\item Sphere: reflection coefficients as function of the normal vector coordinates\n    \\item Triangle: reflection coefficients as function of the barycentric coordinates\n\\end{itemize}\nLet's define a function $f(u,v):\\mathbb{R}^2 \\rightarrow \\mathbb{R}^3$:\n\\begin{center}\n    $f(u,v) = (\\lfloor n \\cdot u \\rfloor + \\lfloor n \\cdot v \\rfloor) \\% 2$\n\\end{center}\nIn order to texture a triangle, we can use two of its barycentric coordinates:\n\\begin{center}\n    $f(u,v)=f(\\lambda(p_3),\\lambda(p_2))$\n\\end{center}\nIn order to texture a sphere, we need to transform the position $p=(x,y,z)$ to the spherical coordinates.\nFirst we compute the angles $\\theta$ and $\\phi$:\n\\begin{center}\n    $\\theta = arcsin(\\displaystyle\\frac{y}{r}) \\in [-\\displaystyle\\frac{\\pi}{2}, \\displaystyle\\frac{\\pi}{2}]$, \\ \\ \\ \\ \\ \\ $\\phi = arctan(\\displaystyle\\frac{z}{x}) \\in [-\\pi, \\pi] $\n\\end{center}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=7cm]{Figure 9 - Texturing.png}\n    \\caption{Sphere texturing representation}\n\\end{figure}\nThen we can compute the spherical coordinates $(u,v)$:\n\\begin{center}\n    $u=\\displaystyle\\frac{\\phi + \\pi}{2 \\cdot \\pi}$, \\ \\ \\ \\ \\ $v = \\displaystyle\\frac{\\theta + \\pi/2}{\\pi}$\n\\end{center}\n\n\\newpage\n\n% -------------------------- %\n% Chapter 6 - Transformation\n% -------------------------- %\n\\section{Transformation}\nObjects are described by $3D$ points: a sphere with center $c$ and radius $r$ is defined as follows:\n\\begin{center}\n    $r : S(c,r) = \\{p = (x,y,z) : ||p-c|| = r\\} $\n\\end{center}\n\\textbf{Translations} are described by a translation vector $t$:\n\\begin{center}\n    $t = (t_x, t_y, t_z) \\rightarrow p' = p + t$ \\\\\n    \\vspace{0.2cm}\n    Sphere $S(c, r) \\ \\rightarrow \\ S(c + t, r)$\n\\end{center}\n\\textbf{Rotations} are described by a transformation matrix $R$:\n\\begin{center}\n    $p' = Rp$ \\\\\n    \\vspace{0.2cm}\n    Axis $\\{c + \\lambda v : \\lambda \\in \\mathbb{R}\\} \\ \\rightarrow \\ \\{Rc + \\lambda \\cdot (Rv) : \\lambda \\in \\mathbb{R}\\}$\n\\end{center}\n\\subsection{Global and Local Coordinates}\nThere exist two ways to describe motions: using \\textbf{global coordinates}, meaning the camera ones, or using \\textbf{local coordinates}, meaning the object ones. From camera’s point of view, the object's coordinates change, while from the object's point of view, the ray origin coordinates change in the opposite direction. \\\\\nInitially, every object is born at the origin and the local coordinates are identical to the global ones, then objects are moved around: if an object is rotated by $R$ and translated by $T$, then from its perspective the world is translated by $-T$ and rotated by $-R$.\n\\subsection{Rotations}\nIn order to describe rotations, we must define an object center $c$ and a \\textbf{rotation axis}. In global coordinates, the rotation axis is defined as follows:\n\\begin{center}\n    $\\{c + \\lambda\\cdot (1,0,0):\\lambda\\in\\mathbb{R}\\}$\n\\end{center}\nIn local coordinates, we rotate the ray and its origin in the opposite direction with the following rotation axis:\n\\begin{center}\n    $\\{\\lambda\\cdot(1,0,0):\\lambda\\in\\mathbb{R}\\}$\n\\end{center}\n\\subsection{Homogeneous Coordinates}\nSince translations are described by additions and rotations by multiplications, we add a coordinate and work in $4$ dimensions. For any point $p$ and direction $d$:\n\\begin{center}\n    $p = (x,y,z) \\ \\ \\ \\rightarrow \\ \\ \\ p = (x,y,z,1)$ \\\\\n    $d = (x,y,z) \\ \\ \\ \\rightarrow \\ \\ \\ d = (x,y,z,0)$ \n\\end{center}\nThe new coordinates are called the \\textbf{homogeneous coordinates}. \\\\\nWe need to introduce some arithmetic meanings:\n\\begin{itemize}\n    \\item Position $+$ Displacement $=$ Position\n    \\item Position $-$ Position $=$ Displacement\n    \\item Displacement $+$ Displacement $=$ Displacement\n    \\item Position $+$ Position $=$ Position\n\\end{itemize}\n\n\\newpage\n\n% ------------------------------------------------- %\n% Chapter 7 - Shadows, Reflections, and Refractions\n% ------------------------------------------------- %\n\\section{Shadows, Reflection, and Refraction}\n\\subsection{Shadows}\n\\textbf{Shadows} are dark spots for which the light is occluded and consist of an \\textbf{umbra}, which is a complete shadow, and a \\textbf{penumbra}, which is a partial shadow. They convey information such as objects' relative positions, depth, and lights positions. \\\\\nAfter tracing the primary ray, we trace a \\textbf{shadow ray} from the intersection point towards the light source: if the intersection is closer than the light source, then the object is in shadow. \\\\\nThe Phong lighting model is extended by the \\textbf{shadow term} $s_j(p)$ which evaluates to $0$ if the shadow ray hits an object, otherwise evaluates to $1$\n\\begin{center}\n    $ I = I_e + \\rho_a \\cdot I_a + \\displaystyle\\sum^n_{j=1}(\\rho_d \\ \\cdot \\langle n_j,l_j\\rangle + \\ \\rho_s \\ \\cdot \\langle v,r_j\\rangle^k) \\cdot I_j \\cdot s_j(p)$\n\\end{center}\n\\subsection{Reflections}\n\\textbf{Reflection} occurs when a ray hits a point $p$ on a mirror surface.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=7cm]{Figure 10 - Reflection.png}\n    \\caption{Reflection representation}\n\\end{figure}\nThe procedure is the following:\n\\begin{enumerate}\n    \\item Compute the \\textbf{reflection ray} $r$ as follows:\n        \\begin{center}\n            $r = i - 2n \\ \\cdot \\langle n,i\\rangle$\n        \\end{center}\n    \\item Trace ray $r$ from $p$ towards the reflection direction\n    \\item Find the intersection point $q$ with the first object \n    \\item Compute the color at point $q$\n    \\item Reflect the color towards $p$\n\\end{enumerate}\nFor partial reflections, we use the constant $\\alpha_{reflect} \\in [0,1]$.\n\\subsection{Refractions}\n\\textbf{Refraction} occurs when light propagates through different materials. Given the speed of light in vacuum $c$ and the speed of light in the medium $v$, then the index of refraction $\\delta$ is computed as follows:\n\\begin{center}\n    $\\delta = \\displaystyle\\frac{c}{v}$\n\\end{center}\nThe \\textbf{Snell's law} is defined using the refraction indices $\\delta_1$ and $\\delta_2$ and the velocities in the medium $v_1$ and $v_2$:\n\\begin{center}\n    $\\delta_1 \\cdot sin \\ \\theta_1 = \\delta_2 \\cdot sin \\ \\theta_2 \\ \\rightarrow \\ \\displaystyle\\frac{sin \\ \\theta_1}{sin \\ \\theta_2} = \\displaystyle\\frac{\\delta_2}{\\delta_1}$\n\\end{center}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=9cm]{Figure 11 - Refraction Constraint.png}\n    \\caption{Refraction constraint}\n\\end{figure}\nAs in reflection, we compute a \\textbf{refraction ray} $r$ and evaluate the color of the point it intersects.\nThe refraction ray $r$ is computed as follows:\n\\begin{center}\n    $a = n \\cdot \\langle n,i\\rangle \\ \\ \\ \\ b = i - a \\ \\ \\ \\ \\beta = \\displaystyle\\frac{\\delta_1}{\\delta_2} \\ \\ \\ \\ \\alpha = \\sqrt{1 + (1 - \\beta^2) \\cdot \\displaystyle\\frac{||b||^2}{||a||^2}}$ \\\\\n    \\vspace{0.2cm}\n    $r = \\alpha \\cdot a + \\beta \\cdot b$\n\\end{center}\n\\subsection{Recursive Raytracing Algorithm}\nThe following is a recursive raytracing algorithm:\n\\begin{verbatim}\n    trace(origin o, direction d):\n        p = findFirstIntersection(o, d)\n        n = surfaceNormal(p)\n        s = reflectionDirection(p, n)\n        t = refractionDirection(p, n)\n        I_{direct} = phongLighting(p, n, d)\n        I_{reflect} = \\alpha_{reflect} \\cdot trace(p, s)\n        I_{refract} = \\alpha_{refract} \\cdot trace(p, t)\n        return (I_{direct} + I_{reflect} + I_{refract})\n\\end{verbatim}\nThe algorithm terminates when the ray leaves the scene, if the maximal recursion depth is reached, or if the intensity is smaller than some threshold.\n\\subsection{Fresnel Effect}\nDue to the \\textbf{Fresnel effect}, the amount of light that is reflected of refracted on a surface depends on the viewing angle. The Fresnel reflection ray $F_{reflection}$ is computed as follows:\n\\begin{center}\n    $F_{reflection} = \\displaystyle\\frac{1}{2} \\cdot \\big((\\displaystyle\\frac{\\delta_2 \\cdot cos\\Theta_1 - \\delta_1 \\cdot cos\\Theta_2}{\\delta_2 \\cdot cos\\Theta_1 + \\delta_1 \\cdot cos\\Theta_2})^2 + (\\displaystyle\\frac{\\delta_1 \\cdot cos\\Theta_1 - \\delta_2 \\cdot cos\\Theta_2}{\\delta_1 \\cdot cos\\Theta_1 + \\delta_2 \\cdot cos\\Theta_2})^2\\big)$\n\\end{center}\nThe Fresnel refraction ray $F_{refraction}$ is computed as follows:\n\\begin{center}\n    $F_{refraction} = 1 - F_{reflection}$\n\\end{center}\n\n\\newpage\n\n% ------------------------------- %\n% Chapter 8 - Advanced Raytracing\n% ------------------------------- %\n\\section{Advanced Raytracing}\nRaytracing is expensive since we generate at least one ray for each pixel and recursively more secondary rays for each intersection.\n\\subsection{Efficient Raytracing}\nEfficient raytracing uses space partitioning to reference singularly to each grid cell and to the objects contained in it.\n\\subsubsection{Bounding Volume Hierarchy}\nIn \\textbf{Bounding Volume Hierarchy} (\\textbf{BVH}), neighbouring objects are gathered through simple bouncing primitives, starting from the biggest primitives.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 12 - BVH.png}\n    \\caption{BVH representation}\n\\end{figure}\n\\subsubsection{Binary Space Partitioning}\nIn \\textbf{Binary Space Partitioning} (\\textbf{BSP}), the space is recursively divided with planes. It has a runtime of $O(logn)$, but the resulting space is hard to traverse.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 13 - BSP.png}\n    \\caption{BSP representation}\n\\end{figure}\n\\subsubsection{kd-Tree}\nIn \\textbf{kd-tree} partitioning, the space is recursively divided with axis aligned planes. It uses the following parametric ray equation:\n\\begin{center}\n    $ \\gamma(t) = 0 + t \\cdot d$,\n\\end{center}\nrecursively considering the active ray segment $[t_{min}, t_{max}]$. The following is a traversing algorithm that runs in $O(logn)$:\n\\begin{verbatim}\n    float recTraverse(node, t_min, t_max):\n        if (node.isLeaf):\n            intersectTrianglesInLeaf(node)\n            return t_closestHit\n        u = (node.s - o[node.a]) / d[node.a]\n        if (u <= t_min):\n            return recTraverse(node.b, t_min, t_max)\n        else if (u >= t_max):\n            return recTraverse(node.f, t_min, t_max)\n        else:\n            t_hit = recTraverse(node.f, t_min, u)\n            if (t_hit <= u):\n                return t_hit\n            return recTraverse(node.b, u, t_max)\n            \n    void traverse():x\n        (t_min, t_max) = clip(0, max)\n        recTraverse(kdRoot, t_min, t_max)\n\\end{verbatim}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 14 - kd.png}\n    \\caption{BSP representation}\n\\end{figure}\n\\newpage\n\\subsection{Antialiasing}\nWith \\textbf{antialiasing}, we perform super-sampling tracing $k \\times k$ rays per pixel and averaging the colors.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 15 - Antialiasing.png}\n    \\caption{Antialiasing effect}\n\\end{figure}\n\\noindent\nThere are two types of super-sampling: in the \\textbf{stochastic one}, many rays are traced to handle random distribution, while in the \\textbf{adaptive one}, we start with $5$ rays per pixel and, if the color difference is too big, we compute $4$ sub-pixels.\n\\subsection{Thin Lens Camera Model}\nIn \\textbf{thin lens camera model}, there are some additional inputs to the raytracer: the focal distance $f$, the aperture size $r$, and the number of samples $n$. \\\\\nThe following algorithm represents the model working:\n\\begin{verbatim}\n    color = 0\n    focal_point = f * d / d.z\n    for i = 0 to n:\n        offset = randDisk(r)    // random offset within aperture\n        new_o = o + (offset, 0)     // z component stays the same\n        new_d = normalize(focal_point - new_o)\n        color += traceRay(Ray(new_o, new_d))\n    color = color / n\n\\end{verbatim}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 16 - Model.png}\n    \\caption{Thin lens model representation}\n\\end{figure}\n\n\\newpage\n\n% ------------------------- %\n% Chapter 9 - Rasterization\n% ------------------------- %\n\\section{Rasterization}\n\\textbf{Rasterization} consists of coloring all visible pixels.\n\\subsection{Drawing Lines}\nSince trying to draw a line from point $p_1 \\in \\mathbb{R}^3$ to point $p_2 \\in \\mathbb{R}^3$ with raytracing would result in all rays missing the line, we must follow an inverse approach:\n\\begin{enumerate}\n    \\item Consider rays from $p_1$ and $p_2$ to the camera\n    \\item Compute the intersections with the image\n    \\item Obtain the screen coordinates $(x_1, y_1)$ and $(x_2, y_2)$ for $p_1$ and $p_2$\n    \\item Draw the line from $(x_1, y_1)$ to $(x_2, y_2)$\n\\end{enumerate}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 17 - Line.png}\n    \\caption{Drawing a line}\n\\end{figure}\nThe closest pixels to the “ideal” line must be colored. \\\\\nA line in $2D$ is defined as follows:\n\\begin{center}\n    $m = \\displaystyle\\frac{(y_2 - y_1)}{(x_2 - x_1)} \\ \\ \\ \\ d = y_1 - m \\cdot x_1 \\ \\ \\ \\     y = m \\cdot x + d $\n\\end{center}\nWithout loss of generalization:\n\\begin{itemize}\n    \\item $ 0 \\leq m \\leq 1$\n    \\item $x_1 < x_2$\n    \\item $0^\\circ \\leq$ line slop $\\leq 45^\\circ$\n\\end{itemize}\n\\newpage\n\\subsection{Midpoint Algorithm}\nWhile drawing a line, at each $x-$step there are two options for the $y-$coordinate: either it stays as it is or it increases by $1$.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=9cm]{Figure 18 - Midpoint.png}\n    \\caption{Midpoint algorithm}\n\\end{figure}\n\\noindent\nWe must determine where the \\textbf{midpoint} $M$ lies with respect to $Q$, which is the intersection of the ideal line and the vertical line at $x_i + 1$: if $M$ lies above $Q$, then we take pixel $P_0$, while if $M$ lies below $Q$, then we take pixel $P_1$. \\\\\nThe procedure to determine whether a point is above or below a line is the following:\n\\begin{enumerate}\n    \\item Compute $dx$ and $dy$ as follows:\n        \\begin{center}\n            $dx = x_2 - x_1$ \\ \\ \\ \\ $dy = y_2 - y_1$\n        \\end{center}\n    \\item Compute $F(x,y)$ as follows:\n        \\begin{center}\n            $F(x,y) = y \\cdot dx - x \\cdot dy + x_1 \\cdot dy - y_1 \\cdot dx$\n        \\end{center}\n    \\item Check the sign of $F(x,y)$:\n        \\begin{itemize}\n            \\item if $F(x,y) = 0$, then $(x,y)$ lies on the line \n            \\item if $F(x,y) > 0$, then $(x,y)$ lies above the line \n            \\item if $F(x,y) < 0$, then $(x,y)$ lies below the line \n        \\end{itemize}\n\\end{enumerate}\nThe midpoint decider $f$ is computed as follows:\n\\begin{center}\n    $f = F(x_i + 1, y_i + 0.5)$\n\\end{center}\nIf $f \\geq 0$, then we choose $P_0$, otherwise we choose $P_1$.\n\\newpage\nThe midpoint decider is computed incrementally:\n\\begin{center}\n    $F(M_0) = F(M) - 2 \\cdot dy$ \\\\\n    $F(M_1) = F(M) - 2 \\cdot dy + 2 \\cdot dx$ \\\\\n    Initial value: $F(M) = - 2 \\cdot dy + dx $\n\\end{center}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=5cm]{Figure 19 - Decider.png}\n    \\caption{Midpoint decider}\n\\end{figure}\nThe implementation of the midpoint algorithm is the following:\n\\begin{verbatim}\n    x = x1\n    y = y1\n    dx = x2 - x1\n    dy = y2 - y1\n    f = -2 * dy + dx\n    for i = 0 to dx:\n        setPixel(x,y)\n        x += 1\n        if (f < 0):\n            y += 1\n            f += 2 * dx\n        f -= 2 * dy\n\\end{verbatim}\nLines drawn with the algorithm appear aliased since we set only one pixel per column, thus we perform antialiasing by setting two pixels $P_0$ and $P_1$ per column. \\\\\nThe pixels intensities are proportional to the distance to the ideal line:\n\\begin{center}\n    $I_0 = \\displaystyle\\frac{F(P_1)}{F(P_1) - F(P_0)}$ \\\\\n    $I_1 = \\displaystyle\\frac{-F(P_0)}{F(P_1) - F(P_0)}$\n\\end{center}\nThe sum of the intensities is $1$.\n\\subsection{z-Buffer}\n\\subsection{Perspective Interpolation}\n\\subsection{Rasterization of Triangles}\nGiven a $3D$ triangle $[p_1, p_2, p_3]$ in global coordinates, we perform the following procedure:\n\\begin{enumerate}\n    \\item For each point $p_i$ compute the screen coordinates $s_i$:\n        \\begin{center}\n            $s_i = (x_i, y_i)$\n        \\end{center}\n    \\item Compute the reciprocal $z-$values $z_i$ as follows:\n        \\begin{center}\n            $z_i = \\displaystyle\\frac{1}{p_i^z}$\n        \\end{center}\n    \\item Found a bounding box defined as follows:\n        \\begin{center}\n            $x_{min} = min(x_1,x_2,x_3)$ \\\\\n            $y_{min} = min(y_1, y_2, y_3)$ \\\\\n            $x_{max} = max(x_1,x_2,x_3)$ \\\\\n            $y_{max} = max(y_1, y_2, y_3)$\n        \\end{center}\n    \\item Check for each pixel $s_i$ within the box if it is in the triangle as follows:\n        \\begin{enumerate}\n            \\item Compute the barycentric coordinates $\\lambda_1$, $\\lambda_2$, and $\\lambda_3$ of $s$\n            \\item Pixel $s$ is in the triangle if all the barycentric coordinates are non-negative\n        \\end{enumerate}\n\\end{enumerate}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 20 - Triangles.png}\n    \\caption{Rasterization of triangles}\n\\end{figure}\n\n\\newpage\n\n% ---------------------------------------- %\n% Chapter 10 - Graphics Pipeline and WebGL\n% ---------------------------------------- %\n\\section{Graphics Pipeline and WebGL}\nIn the \\textbf{graphics rendering pipeline}, everything runs in parallel according to the following procedure:\n\\begin{enumerate}\n    \\item \\textbf{Application}: determines the composition of the scene\n    \\item \\textbf{Geometry Processing}: puts the geometry in the common space, performs clipping and screen mapping, and computes per-vertex shading\n    \\item \\textbf{Rasterization}: performs primitive setup and traversal and generates fragments with interpolated per-vertex data\n    \\item \\textbf{Pixel processing}: colors each fragment and merge them into an image\n\\end{enumerate}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=6cm]{Figure 21 - Pipeline.png}\n    \\caption{Graphics rendering pipeline}\n\\end{figure}\nLet's have a closer look at the pipeline marking the fixed stages in \\textcolor{Orange}{orange}, which can be configured, and in \\textcolor{blue}{blue} the programmable stages, whose task must be specified:\n\\begin{enumerate}\n    \\item \\textcolor{Orange}{Vertex specification}: setting up geometry\n    \\item \\textcolor{blue}{Vertex shader}: performing transformations\n    \\item \\textcolor{Orange}{Vertex post-processing}: clipping and outputting geometry\n    \\item \\textcolor{Orange}{Primitive assembly}: creating geometry from vertices and face culling\n    \\item \\textcolor{Orange}{Rasterization}: creating fragments and interpolating data\n    \\item \\textcolor{blue}{Fragment shader}: shading\n    \\item \\textcolor{Orange}{Per-sample operations}: merging and depth test\n\\end{enumerate}\n\\subsection{Depth Test and Face Culling}\nThe \\textbf{depth test} is necessary to find which object occludes which other object. \\\\\n\\textbf{Face culling} prevents the rendering of the faces that are not visible to the viewer.\n\\newpage\n\\subsection{WebGL and GLSL}\nThe graphics pipeline in \\textbf{WebGL} performs the following procedure:\n\\begin{enumerate}\n    \\item Create a WebGL canvas\n    \\item Generate and send the geometry to \\textbf{Graphics Processing Unit} (\\textbf{GPU})\n    \\item Define vertex shaders (per-vertex operations)\n    \\item Define fragment shaders (per-pixel operations)\n    \\item Use the geometry and the shader program to draw the scene\n\\end{enumerate}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=9cm]{Figure 22 - Flow.png}\n    \\caption{Pipeline data flow}\n\\end{figure}\n\\subsection{Vertex Attributes}\nGeometric objects are stored as vertices, meaning collections of the following attributes in space: position, color, normal vector, and more. \\\\\nVertices data is stored in \\textbf{Vertex Buffer Objects} (\\textbf{VBOs}), which are arrays of concatenated elements of each vertex. Moreover, the \\textbf{Vertex Array Objects} (\\textbf{VAOs}) describe the state of attributes, which VBOs to use, and how to pull the data from it.\n\n\\newpage\n\n% ------------------------------------ %\n% Chapter 11 - Transformation Pipeline\n% ------------------------------------ %\n\\section{Transformation Pipeline}\nThe \\textbf{transformation pipeline} performs different types of transformations in order to convert the given coordinates.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=7cm]{Figure 23 - Transformations.png}\n    \\caption{Transformation pipeline steps}\n\\end{figure}\n\\subsection{Model Transformations}\n\\textbf{Model transformations} convert local \\textbf{model coordinates} (\\textbf{MC}) into global \\textbf{world coordinates} (\\textbf{WC}) through a multiplication in homogeneous coordinates with a \\textbf{model matrix} $M$.\n\\subsection{Viewing Transformations}\n\\textbf{Viewing transformations} convert global world coordinates into camera \\textbf{viewing coordinates} (\\textbf{VC}). Let $VPN$ the view plane normal and $VUP$ the view up vector, then we can define the following variables:\n\\begin{center}\n    $z' = \\displaystyle\\frac{VPN}{||VPN||} \\ \\ \\ \\ x' = \\displaystyle\\frac{VUP \\times z'}{||VUP \\times z'||} \\ \\ \\ \\ y' = z' \\times x' $\n\\end{center}\nSince we must express everything using the new coordinate system, we can transform the world such that the new coordinate system overlaps with the old one. Let $VP$ be the view point, then the \\textbf{view matrix} is defined as follows:\n\\begin{center}\n    $V = \\begin{pmatrix}\n        x'^T_x & x'^T_y & x'^T_z & -x'^TVP \\\\\\\\\n        y'^T_x & y'^T_y & y'^T_z & -y'^TVP \\\\\\\\\n        z'^T_x & z'^T_y & z'^T_z & -z'^TVP \\\\\\\\\n        0 & 0 & 0 & 1\n    \\end{pmatrix}$\n\\end{center}\n\\subsection{Projection Transformations}\n\\textbf{Projection transformations} convert viewing coordinates into \\textbf{normalized coordinates} (\\textbf{NC}) $[-1, 1]^3$. We need to specify the \\textbf{viewing frustum}, meaning the range in which objects are visible:\n\\begin{itemize}\n    \\item \\textbf{Near plane}: $z = -n$\n    \\item \\textbf{Far plane}: $z = -f$\n    \\item $0 < n < f$\n\\end{itemize}\nThese transformation can be divided in perspective and orthographic.\n\\subsubsection{Perspective Projections}\nIn \\textbf{perspective projections}, all rays go through the camera and the viewing frustum is mapped to a unit cube defined as follows:\n\\begin{center}\n    $[-1,1] \\times [-1,1] \\times [-1,1]$\n\\end{center}\nGiven a vertical opening angle $\\beta$ and an aspect ratio $\\gamma$, then we have the following relations:\n\\begin{center}\n    $\\displaystyle\\frac{n}{r} = cot(\\displaystyle\\frac{\\beta / 2}{\\gamma}) \\ \\ \\ \\ \\displaystyle\\frac{n}{t} = cot(\\displaystyle\\frac{\\beta}{2})$\n\\end{center}\nThe \\textbf{perspective matrix} is computed as follows:\n\\begin{center}\n    $P_{persp} =\n    \\begin{pmatrix}\n        \\displaystyle\\frac{n}{r} & & & \\\\\n        & \\displaystyle\\frac{n}{t} & & \\\\\n        & & -\\displaystyle\\frac{f + n}{f - n} & -\\displaystyle\\frac{2fn}{f - n} \\\\\n        & & -1 & 0\n    \\end{pmatrix}$\n\\end{center}\n\\subsubsection{Orthographic Projections}\nIn \\textbf{orthographic projections}, all rays are parallel to the viewing direction, thus the viewing frustum is an axis-aligned cuboid mapped to a unit cube as follows:\n\\begin{center}\n    $[-r, r] \\times [-t,t] \\times [-n,-f] \\ \\rightarrow \\ [-1,1]^3$\n\\end{center}\nThe \\textbf{orthographic matrix} is defined as follows:\n\\begin{center}\n    $P_{ortho} =\n    \\begin{pmatrix}\n        \\displaystyle\\frac{1}{r} & & & \\\\\n        & \\displaystyle\\frac{1}{t} & & \\\\\n        & & \\displaystyle\\frac{-2}{f - n} & -\\displaystyle\\frac{f + n}{f - n} \\\\\n        & & 0 & 1\n    \\end{pmatrix}$\n\\end{center}\n\\subsection{Window-to-Viewport Transformations}\n\\textbf{Window-to-Viewport transformations} convert normalized coordinates into \\textbf{screen coordinates} (\\textbf{SC}) by scaling and translating such that:\n\\begin{itemize}\n    \\item $x$ is mapped linearly: $[-1,1] \\rightarrow [0,w]$\n    \\item $y$ is mapped linearly: $[-1,1] \\rightarrow [0,h]$\n    \\item $z$ is mapped linearly: $[-1,1] \\rightarrow [0,1]$\n\\end{itemize}\n\\subsection{Transformations in Rasterization}\nMatrix transformations are per-vertex operations, meaning they should be implemented in a vertex shader:\n\\begin{center}\n    $v_{out} = PVMv_{in}$\n\\end{center}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=10cm]{Figure 24 - Matrices.png}\n    \\caption{Transformation matrices effects}\n\\end{figure}\n\n\\newpage\n\n% ------------------------------ %\n% Chapter 12 - Light Computation\n% ------------------------------ %\n\\section{Light Computation}\nInputs for light computation such as position, color, and normal vector are defined per vertex. The Phong reflectance model is defined as follows:\n\\begin{center}\n    $I = k_a \\cdot i_a + k_d(\\vec{L} \\cdot \\vec{N}) \\cdot i_d + k_s(\\vec{R} \\cdot \\vec{V})^s \\cdot i_s$, where\n\\end{center}\n\\begin{itemize}\n    \\item $\\vec{N}$: normal vector transformed with model and view matrices\n    \\item $\\vec{L}$: light vector transformed with a view matrix\n    \\item $\\vec{V}$: viewer position transformed with model and view matrices\n    \\item $\\vec{R}$: reflection direction computed in a fragment shader from $\\vec{L}$ and $\\vec{N}$\n\\end{itemize}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 25 - Reflectance.png}\n    \\caption{Phong reflectance model}\n\\end{figure}\n\\subsection{Shading and Illumination}\nIn \\textbf{Gouraud shading}, the color is computed per vertex and then interpolated; the Phong model is computed in a vertex shader. On the other side, in \\textbf{Phong shading}, all information for light computation is interpolated, then the color is computed per fragment; the Phong model is computed in a fragment shader. \\\\ \nThe most efficient method is the Phong shading since each fragment is shaded separately in a fragment shader.\n\n\\newpage\n\n% ---------------------------- %\n% Chapter 13 - Texture Mapping\n% ---------------------------- %\n\\section{Texture Mapping}\nIn order to implement \\textbf{texture mapping}, we augment simple geometry with extra information while shading.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=12cm]{Figure 26 - Texture.png}\n    \\caption{Texture mapping concept}\n\\end{figure}\nThe texture itself is an image composed of \\textbf{texels} and with a parameter space $\\Omega$. It obeys to the following procedural pattern:\n\\begin{center}\n    $M:(u,v) \\rightarrow color$\n\\end{center}\nGiven an object $S$, usually a triangle mesh, we find the correspondences between $S$ and the $2D$ plane through the following \\textbf{parameterization} $f$:\n\\begin{center}\n    $f : \\Omega \\leftrightarrow S$\n\\end{center}\nThe following example computes $f(u,v)$ for a sphere:\n\\begin{center}\n    $\\Omega = \\{(u,v)\\in [0,1]^2\\}$ \\\\\n    \\vspace{0.1cm}\n    $S = \\{(x,y,z) \\in \\mathbb{R}^3:x^2 + y^2 + z^2 = 1\\}$ \\\\\n    \\vspace{0.1cm}\n    $f(u,v) = (t \\cdot cos(2\\pi u), \\ t \\cdot sin(2\\pi v)$\n\\end{center}\n\\subsection{Texturing Triangles}\nGiven a triangle $[p_0, p_1, p_2]$ and a point $p_i \\in \\mathbb{R}^3$, we associate the following texture coordinates:\n\\begin{center}\n    $t_i =(u_i,v_i) \\in \\mathbb{R}^2$,\n\\end{center}\nthen we map the texture triangle $[t_0, t_1, t_2]$ linearly to the triangle. \\\\\nFirst, we interpolate $(u,v)$ from $uv$-coordinates of the vertices, then we fetch the corresponding texture value.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 27 - TT.png}\n    \\caption{Texturing a triangle}\n\\end{figure}\n\\subsection{Texture Access}\nIn order to texture the fragments $s$ in the screen space, we take the four closest texels through nearest neighbors interpolation and interpolate between them through \\textbf{bilinear filtering}.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=7cm]{Figure 28 - Access.png}\n    \\caption{Texture access}\n\\end{figure}\n\\subsection{Idea Behind Texture Mapping}\nWe read new \\textbf{diffuse colors} from the texture and then compute the Phong model using them. Moreover, textures supply high resolution \\textbf{displacement} information which is used to displace vertices along the normal direction.\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=8cm]{Figure 29 - Displacement.png}\n    \\caption{Displacement representation}\n\\end{figure}\n\n\\newpage\n\n% ------------------------------------- %\n% Chapter 14 - Shadows in Rasterization\n% ------------------------------------- %\n\\section{Shadows in Rasterization}\nSince the graphics pipeline only allows to do local computations, i.e. per-vertex and per-fragment, we need a sort of preprocessing.\n\\subsection{Shadows Preprocessing}\nFirst, we compute all the distances $z_i$ from points to a light source $L$ and store them in the z-buffer. While rendering, we test the current distance to $L$ with the stored smallest distance $z_{min}$. The z-buffer is thus used as a \\textbf{shadow map}, one per light source. \\\\\nIn per-fragment computation, we transform its coordinates into the local coordinates system of $L$. The fragment is in shadow if:\n\\begin{center}\n    $z > z_{min}(x,y)$\n\\end{center}\n\n\\newpage\n\n% ------------------------------------ %\n% Chapter 15 - Physics-based Animation\n% ------------------------------------ %\n\\section{Introduction to Physics-based Animation}\nObjects motions are computed using transformation matrices. In order to obtain an \\textbf{animation}, we must compute each frame's \\textbf{simulation state}, consisting of a \\textbf{position} $x(t)$ and a \\textbf{velocity} $v(t)$, as follows: \n\\begin{center}\n    $x(t)$ \\\\\n    $v(t) = \\dot{x}(t)$\n\\end{center}\n\\subsection{Simulation Step}\nAccording to Newton's first, no external forces are considered. Thus, given a time step $\\Delta t$, we have the following relations:\n\\begin{center}\n    $ v(t + \\Delta t) = v(t)$ \\\\\n    $ x(t + \\Delta t) = x(t) + \\Delta t \\cdot v(t) $\n\\end{center}\nMoreover, according to Newton's second law and given a force $F$, a mass $m$, and an acceleration $a$, we have the following relations:\n\\begin{center}\n    $ F(t) = m \\cdot a(t) \\ \\rightarrow \\ a(t) = F(t) / m $ \\\\\n    $a(t) = \\ddot{x}(t)$\n\\end{center}\n\\subsection{Particle Simulation}\nIn \\textbf{particle simulation}, we perform the following steps:\n\\begin{enumerate}\n    \\item Initialize position $x$, velocity $v$, and mass $m$ of each particle\n    \\item Set the time step $\\Delta t$\n    \\item Until simulation ends:\n        \\begin{enumerate}\n            \\item Compute the force $F$ acting on the particle\n            \\item For each particle:\n                \\begin{itemize}\n                    \\item Update the velocity: $v = v + \\Delta t \\cdot F / m$\n                    \\item Update the position: $x = x + \\Delta t \\cdot v$\n                \\end{itemize}\n        \\end{enumerate}\n\\end{enumerate}\n\\newpage\n\\subsection{Mass-Spring System}\nIn the \\textbf{mass-spring system}, we can model complex objects as particle systems connected with springs. The interaction with the environment is modeled by external forces. According to the \\textbf{Hooke's law}, a spring in its rest shape with its rest length $r$ does not exert force; otherwise, the force is proportional to the expansion. Defining the spring stiffness with $k$ and its expansion/compression as $x$, we have the following relation:\n\\begin{center}\n    $F = k \\cdot x$\n\\end{center}\nMoreover, defining the spring end points as $x_p$ and $x_q$ respectively, we obtain the following relation:\n\\begin{center}\n    $F_p = k \\cdot \\big(\\displaystyle\\frac{||x_q - x_p||}{r} - 1\\big) \\cdot \\displaystyle\\frac{x_q - x_p}{||x_q - x_p||}$\n\\end{center}\nWe perform the following steps:\n\\begin{enumerate}\n    \\item Initialize position $x$, velocity $v$, and mass $m$ of each particle\n    \\item Set the time step $\\Delta t$\n    \\item Define springs: $p, q, r, k$, where $q, p$ are the indices of vertices\n    \\item Until simulation ends:\n        \\begin{enumerate}\n            \\item Initiate the force $F$ acting on the particle\n            \\item For each spring:\n                \\begin{itemize}\n                    \\item Compute the forces exert by the spring on $p$ and $q$\n                    \\item Add the forces to $F_p$ and $F_q$\n                \\end{itemize}\n            \\item For each particle:\n                \\begin{itemize}\n                    \\item Update the velocity: $v = v + \\Delta t \\cdot F / m$\n                    \\item Update the position: $x = x + \\Delta t \\cdot v$\n                \\end{itemize}\n        \\end{enumerate}\n\\end{enumerate}\nIn case of static particles, the position should not be updated and the velocity should be zero. \\\\\nNow we can introduce the concept of \\textbf{damping}. Defining the damping coefficient as $d$, we have the following relation:\n\\begin{center}\n    $\\hat{F} = d \\cdot \\langle\\displaystyle\\frac{v_q - v_p}{r}, \\displaystyle\\frac{x_q - x_p}{||x_q - x_p||}\\rangle \\cdot \\displaystyle\\frac{x_q - x_p}{||x_q - x_p||}$\n\\end{center}\n\n\\newpage\n\n% ------------------------- %\n% Appendix A - Fundamentals\n% ------------------------- %\n\\section{Appendix A - CG Fundamentals}\n\n\\subsection{Trigonometry}\n\\subsubsection{Pythagorean Identity}\nFor any $ \\alpha \\in \\mathbb{R} $:\n\\begin{center}\n    $ sin^2\\alpha + cos^2\\alpha = 1 $\n\\end{center}\n\\subsubsection{Half-Angles}\nFor any $ \\alpha \\in \\mathbb{R} $:\n\\begin{center}\n    $ sin\\displaystyle\\frac{\\alpha}{2} = \\sqrt{\\displaystyle\\frac{1 - cos \\ \\alpha}{2}} $, \\ \\ \\ \\ \\ \n    $ cos\\displaystyle\\frac{\\alpha}{2} = \\sqrt{\\displaystyle\\frac{1 + cos \\ \\alpha}{2}} $, \\ \\ \\ \\ \\\n    $ tan\\displaystyle\\frac{\\alpha}{2} = \\displaystyle\\frac{sin \\ \\alpha}{1 + cos \\ \\alpha} $\n\\end{center}\n\n\\vspace{0.5cm}\n\n\\subsection{Linear Algebra}\n\\subsubsection{Vectors}\nIn vector spaces $\\mathbb{R}^n$ with coordinates $x_1, x_2, \\dots, x_n$:\n\\begin{center}\n    $ x = (x_1, x_2, \\dots, x_n)^T $\n\\end{center}\n\\subsubsection{Matrices}\nA matrix $A \\in \\mathbb{R}^{mxn}$ with $m$ rows and $n$ columns is an array of $m \\cdot n$ real numbers $a_{i,j}$, for $i = 1, \\dots, m$ and $j = 1, \\dots, n$:\n\\begin{center}\n    $\\begin{pmatrix}\n        a_{1,1} & a_{1,2} & \\dots & a_{1,n} \\\\\n        a_{2,1} & a_{2,2} & \\dots & a_{2,n} \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots \\\\\n        a_{m,1} & a_{m,2} & \\dots & a_{m,n} \\\\\n    \\end{pmatrix}$\n\\end{center}\n\\subsubsection{Determinant}\nIn a 2-by-2 matrix $A \\in \\mathbb{R}^{2x2}$ is:\n\\begin{center}\n    $ det A = det\n    \\begin{pmatrix}\n        a_{1,1} & a_{1,2} \\\\\n        a_{2,1} & a_{2,2} \n    \\end{pmatrix}\n    =\n    \\begin{vmatrix}\n        a_{1,1} & a_{1,2} \\\\\n        a_{2,1} & a_{2,2} \n    \\end{vmatrix}\n    = a_{1,1} \\cdot a_{2,2} - a_{1,2} \\cdot a_{2,1} $\n\\end{center}\n\\subsubsection{Normalization}\nThe norm of a vector $ x = (x_1, x_2, \\dots, x_n)^T \\in \\mathbb{R}^n $ is:\n\\begin{center}\n    $ ||x|| = \\sqrt{\\displaystyle\\sum^n_{i=1}x_i^2} = \\sqrt{x_1^2 + x_2^2 + \\dots + x_n^2} $ \\\\\n\\end{center}\nTo normalize a vector, we can compute:\n\\begin{center}\n    $ y = \\displaystyle\\frac{x}{||x||} \\rightarrow ||y|| = 1 $\n\\end{center}\n\\subsubsection{Dot Product}\nThe dot product of two vectors $ x = (x_1, x_2, \\dots, x_n)^T \\in \\mathbb{R}^n $ and $ y = (y_1, y_2, \\dots, y_n)^T \\in \\mathbb{R}^n $ is defined as:\n\\begin{center}\n    $ <x,y> = \\displaystyle\\sum^n_{i = 1}x_i \\cdot y_i = x_1 \\cdot y_1 + x_2 \\cdot y_2 + \\dots + x_n \\cdot y_n $ \\\\\n\\end{center}\nDenoting the angle between $ x $ and $ y $ by $ \\alpha $, we obtain:\n\\begin{center}\n    $ <x,y> = cos \\ \\alpha \\cdot ||x|| \\cdot ||y||$\n\\end{center}\n\\subsubsection{Cross Product}\nThe cross product of two vectors $x = (x_1, x_2, x_3)^T \\in \\mathbb{R}^3$ and $y = (y_1, y_2, y_3)^T \\in \\mathbb{R}^3$ is defined as:\n\\begin{center}\n    $ z = x \\times y = (z_1, z_2, z_3)^T $, $ z_1 =\n    \\begin{vmatrix}\n        x_2 & y_2 \\\\\n        x_3 & y_3\n    \\end{vmatrix}\n    $, $ z_2 = - \n    \\begin{vmatrix}\n        x_1 & y_1 \\\\\n        x_3 & y_3\n    \\end{vmatrix}\n    $ , $ z_3 = \n    \\begin{vmatrix}\n        x_1 & y_1 \\\\\n        x_2 & y_2\n    \\end{vmatrix}\n    $\n\\end{center}\nDenoting the angle between $ x $ and $ y $ by $ \\alpha $, we obtain:\n\\begin{center}\n    $ ||x \\times y|| = sin \\ \\alpha \\cdot ||x|| \\cdot ||y|| $   \n\\end{center}\n\n\\end{document}\n", "meta": {"hexsha": "759db61601ca5a0c2e438dd681e20eda27e3d3f2", "size": 52411, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Computer Graphics/cg_cheatsheet.tex", "max_stars_repo_name": "matteoalberici4/computer-science-cheatsheets", "max_stars_repo_head_hexsha": "5f2b9a6a4bd06f7a39dec198525b441a4f6a4399", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Computer Graphics/cg_cheatsheet.tex", "max_issues_repo_name": "matteoalberici4/computer-science-cheatsheets", "max_issues_repo_head_hexsha": "5f2b9a6a4bd06f7a39dec198525b441a4f6a4399", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Computer Graphics/cg_cheatsheet.tex", "max_forks_repo_name": "matteoalberici4/computer-science-cheatsheets", "max_forks_repo_head_hexsha": "5f2b9a6a4bd06f7a39dec198525b441a4f6a4399", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.5167724388, "max_line_length": 469, "alphanum_fraction": 0.6736181336, "num_tokens": 15477, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4142667122064194}}
{"text": "\\documentclass{tufte-handout}\n\\usepackage{amsmath}\n\n% Set up the images/graphics package\n\\usepackage{graphicx}\n\\setkeys{Gin}{width=\\linewidth,totalheight=\\textheight,keepaspectratio}\n\\graphicspath{{figures/}}\n\n\\title{Notes about the NGCC-PCC-DAC model}\n\n\\author{dthierry}\n\n% Make prettier tables.\n\\usepackage{booktabs}\n\n% The units package provides nice, non-stacked fractions and better spacing\n% for units.\n\\usepackage{units}\n\n% The fancyvrb package lets us customize the formatting of verbatim\n% environments.  We use a slightly smaller font.\n\\usepackage{fancyvrb}\n\\fvset{fontsize=\\normalsize}\n\n% Small sections of multiple columns\n\\usepackage{multicol}\n\\usepackage{amssymb}\n\n\n\n%%% Custom Commands\n%---------------------------------------------------------------------------\n% Concise referencing\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\\noindent abstract\n\\end{abstract}\n\n\n\n\\section{Introduction}\n%---------------------------------------------------------------------------\n\nLittle notes.\n\n\\section{Section 1: Disjunctive formulation}\n%---------------------------------------------------------------------------\n\n\\begin{equation}\n\t\\bigvee_{m \\in M}\n\t\\begin{pmatrix} \n    Y_m \\\\\n\t\t\\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) x_{m, i} = \\text{Pr} \\left(k\\right)\n\t\t\\\\ \n\t\t\\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) = 1 \\\\\n    0 \\leq \\lambda_{m,i} \\left(k \\right) \\leq 1 \\quad \\forall i \\\\\n    A_m w_{m}\\left(k\\right) = b_m\n\t\\end{pmatrix}, \\; k \\in {0,...,T},\n\\end{equation}\n\nVariables $\\text{Pr}\\left(k \\right)$, $\\lambda_{m,i} \\left(k \\right)$\n\nSuppose the vector of variables that are directly dependent on the load factor (e.g., fuel) can be calculated with a linear equation in the form $w \\left( k \\right)= A \\text{Load}\\left(k \\right) + b$. Then, if it is possible to calculate the coefficients of $A$ and $b$ for each operation mode $m \\in M$, the disjunctive constraint for the operating modes can be written as follows, \n\\begin{equation}\n\t\\bigvee_{m \\in M}\n\t\\begin{bmatrix} \n    Y_m \\left(k\\right)\\\\\n\t\t\\text{Load} \\left(k\\right) = \\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) \\nu_{m, i}\n\t\t\\\\ \n\t\t\\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) = 1 \\\\\n    0 \\leq \\lambda_{m,i} \\left(k \\right) \\leq 1 \\quad \\forall i \\\\\n    w_m = A_m \\text{Load} + b_m\n\t\\end{bmatrix}, \\; k \\in {0,...,T},\n\\end{equation}\nwhere $Y_m \\in \\left\\{\\text{True, False} \\right\\}$ is a boolean variable and it is assumed that $\\veebar_{m \\in M} Y_m \\left(k\\right)$\n\n\\subsection{Subsection 1: MILP form}\n\\begin{equation}\n\\begin{split}\n\\sum_{I_m} \\lambda_{m, i} \\left(k\\right) x_{m, i} &= \\overline{\\text{Pr}}_m \\left(k \\right) \\\\\n\\sum_{I_m} \\lambda_{m, i} \\left(k\\right) & = y_m \\left(k\\right) \\\\\n\\sum_{m \\in M} y_m \\left(k\\right) & = 1\n\\end{split}\n\\end{equation}\n\n\n\n\\begin{equation}\n\\begin{split}\n\tA_m \\nu_m \\left(k\\right) &= b_m \\\\\n\t\\nu_m \\left(k\\right) & = y_{m} \\left(k\\right)\n\\end{split}\n\\end{equation}\n\n\\subsection{Subsection 2: 2 $\\times$ 2 $\\times$ 1 of the GT-HRSG-ST train}\nSince we have two Gas Turbines (GT), 2 HRSG and 1 Steam Turbine (ST), in principle, it is possible to shutdown a GT-HRSG\nto reach half-ish the load. The only benefit of this is that we do can still use the same parameters. \nEven though this is a counter-intuitive way of modelling, we will offset the whole situation by having a single GT-HRSG active at all times.\n\nNew equation:\n\\begin{gather*}\n\\bigvee_{m \\in M}\n  \\begin{bmatrix} \n    Y_m \\left(k\\right)\\\\\n    \\text{Load} \\left(k\\right) = \\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) \\nu_{m, i}\n    \\\\ \n    \\sum_{i \\in I_m} \\lambda_{m,i} \\left(k \\right) = 1 \\\\\n    0 \\leq \\lambda_{m,i} \\left(k \\right) \\leq 1 \\quad i\\in I_m \\\\\n    w \\left(k \\right) = a_m \\; \\text{Load}\\left(k \\right) + b_m\n  \\end{bmatrix}, \\; k \\in {0,...,T}, \\\\\n\\Omega \\left(Y_m \\left( k\\right) \\right) = \\text{True} \\\\\n\\veebar_{m \\in M} Y_m \\left(k\\right) \\\\\nY_m \\left(k \\right) \\in \\left\\{\\text{True, False} \\right\\}, \\\\\n0 \\leq \\text{Load}\\left(k \\right) \\leq 100, \\; w\\left(k\\right) \\in \\mathbb{R}^{n},\\; k \\in {0,...,T}\n\\end{gather*}\n\n\n\\begin{gather*}\n\\bigvee_{m \\in M}\n  \\begin{bmatrix} \n    Y_{u,m} \\left(k\\right)\\\\\n    \\text{Load}_u \\left(k\\right) = \\sum_{i \\in I_m} \\lambda_{u,m,i} \\left(k \\right) \\nu_{u, m, i}\n    \\\\ \n    \\sum_{i \\in I_m} \\lambda_{u, m,i} \\left(k \\right) = 1 \\\\\n    0 \\leq \\lambda_{u, m,i} \\left(k \\right) \\leq 1 \\quad i\\in I_m \\\\\n    w_u \\left(k \\right) = a_m \\; \\text{Load}_u \\left(k \\right) + b_m\n  \\end{bmatrix}, \\\\\n \\qquad u \\in \\mathcal{U}, \\; k \\in {0,...,T}, \\\\\n\\Omega \\left(Y_{u,m} \\left( k\\right) \\right) = \\text{True} \\\\\n\\veebar_{m \\in M} Y_{u,m} \\left(k\\right) \\\\\nY_{u, m} \\left(k \\right) \\in \\left\\{\\text{True, False} \\right\\}, \\\\\n0 \\leq \\text{Load}_u \\left(k \\right) \\leq 100, \\; w_u \\left(k\\right) \\in \\mathbb{R}^{n},\\\\\nu \\in \\mathcal{U}, \\; k \\in {0,...,T}\n\\end{gather*}\n\n\n\n\\begin{gather*}\n\\text{Load}\\left(k\\right) = \\sum_{u \\in \\mathcal{U}} \\text{Load}_u\\left(k\\right) \\\\\n\\tilde{w} \\left(k \\right) = a \\; \\text{Load} \\left(k \\right) + b\n\\end{gather*}\n\n\\subsection{State-dependent transitions}\n\nWe encounter the following situation, if transition from mode $m$ to mode $m'$ occurs at time $k$, then transition from mode\n$m''$ to $m$ must occur within the time window $\\left[T^{L}_{m, m', m''}, T^{U}_{m, m', m''} \\right]$. In other words,\n\\begin{equation}\n    Z_{u,m,m'} \\left(k\\right) \\Rightarrow \\bigvee_{\\theta = T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''}} Z_{u, m'', m}\\left(k - \\theta\\right).\n\\end{equation}\nWhich can be reformulated as follows:\n\\[\n    \\neg Z_{u, m, m'} \\left(k \\right)\\vee \\bigvee_{\\theta = T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''}} Z_{u, m'', m}\\left(k - \\theta\\right).\n\\]\n\n\\[\n    1 - z_{u, m, m'}\\left(k\\right) + \\sum_{\\theta = T^{L}_{m, m', m''}-1}^{T^{U}_{m, m', m''}} z_{u, m'', m}\\left(k - \\theta\\right) \\geq 1\n\\]\n\\[\n    z_{u, m, m'}\\left(k\\right) \\leq \\sum_{\\theta = T^{L}_{m, m', m''}-1}^{T^{U}_{m, m', m''}} z_{u, m'', m}\\left(k - \\theta\\right)\n\\]\nI want to have the opposite situation, i.e., \n\\begin{equation}\n    \\neg z_{u,m,m'} \\left(k\\right) \\Leftarrow \\bigvee_{\\theta = T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''}} z_{u, m'', m}\\left(k-\\theta \\right).\n\\end{equation}\nThis constraint can be reformulated as follows:\n\\[\n    \\neg \\left[\\bigvee_{\\theta = T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''}} z_{u, m'', m}\\left(k-\\theta\\right) \\right] \\vee \\neg z_{u, m, m'}\\left(k\\right)\n\\]\n\\[\n    \\bigwedge_{\\theta = T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''}} \\left[ \\neg z_{u, m'', m}\\left(k- \\theta \\right) \\vee \\neg z_{u, m, m'}\\left(k\\right)\\right]\n\\]\nThis last expression is equivalent to the following inequalities:\n\\[\n    1-z_{u, m'', m} \\left( k - \\theta \\right) + 1-z_{u, m, m'} \\left( k \\right) \\geq 1, \\quad \\theta \\in \\{ T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''} \\}\n\\]    \n\\[\n    z_{u, m'', m} \\left( k - \\theta \\right) + z_{u, m, m'} \\left( k \\right)  \\leq 1, \\quad \\theta \\in \\{ T^{L}_{m, m', m''}-1, \\dots, T^{U}_{m, m', m''} \\}\n\\]    \n\\subsection{Minimum stay constraint}\n\\begin{equation}\n    \\bigvee_{\\theta = 0, \\dots, K_{u,m,m'}^{\\text{min}} -1} Z_{u, m, m'}\\left(k-\\theta \\right) \\Rightarrow Y_{u, m'} \\left( k \\right)\n\\end{equation}\n\\[\n    \\neg \\left[\\bigvee_{\\theta = 0, \\dots, K_{u,m,m'}^{\\text{min}} -1} Z_{u, m, m'}\\left(k-\\theta \\right) \\right] \\vee Y_{u, m'} \\left(k \\right)\n\\]\n\\[\n    \\bigwedge_{\\theta = 0, \\dots, K_{u,m,m'}^{\\text{min}} -1} \\left( \\neg Z_{u, m, m'}\\left(k-\\theta \\right) \\vee Y_{u, m'} \\left(k \\right)\n\\right)\n\\]\n\\[\n    1 - z_{u, m, m'}\\left(k-\\theta \\right) + y_{u, m'} \\left(k \\right)\\geq 1 \\quad \\theta \\in \\{ 0, \\dots, K_{u,m,m'}^{\\text{min}} -1\\}  \n\\]\n\\[\n    z_{u, m, m'}\\left(k-\\theta \\right) \\leq  y_{u, m'} \\left(k \\right) \\quad \\theta \\in \\{ 0, \\dots, K_{u,m,m'}^{\\text{min}} -1\\}  \n\\]\n\\[\n    y_{u, m'} \\left(k \\right) \\geq z_{u, m, m'}\\left(k-\\theta \\right) \n    \\quad \\theta \\in \\{ 0, \\dots, K_{u,m,m'}^{\\text{min}} -1\\}  \n\\]\nWhich is not exactly what I had in mind but anyways. \n\n\nHere is the opossite situation:\n\\begin{equation}\n    Y_{u, m'} \\left( k \\right) \\Rightarrow \\bigvee_{\\theta = 0, \\dots, K_{c,m,m'}^{\\text{min}} -1} z_{u, m, m'}\\left(k-\\theta \\right) \n\\end{equation}\n\n\\[\n    \\neg \n    Y_{u, m'} \\left( k \\right) \\vee  \\bigvee_{\\theta = 0, \\dots, K_{c,m,m'}^{\\text{min}} -1} z_{u, m, m'}\\left(k-\\theta \\right) \n\\]\n\\[\n    1- y_{u, m'} \\left( k \\right) +  \\sum_{\\theta = 0}^{K_{c,m,m'}^{\\text{min}} -1} z_{u, m, m'}\\left(k-\\theta \\right) \\geq 1\n\\]\n\\[\n    y_{u, m'} \\left( k \\right) \\leq  \\sum_{\\theta = 0}^{K_{c,m,m'}^{\\text{min}} -1} z_{u, m, m'}\\left(k-\\theta \\right)\n\\]\n\nFinally, the two sided statement. \n\n\\begin{equation}\n    Y_{u, m} \\left( k \\right) \\Leftrightarrow \n    \\bigvee_{\\theta=0, \\dots, K^{\\min}_{u, m, m'}-1} Z_{u, m, m'} \\left(k - \\theta \\right)\n\\end{equation}\n\n\\subsection{Switch variables variables}\n(Double Imp)\n\\[\nY_1 \\Leftrightarrow Y_2\n\\]\n\n\\[\n1-y_1 + y_2 \\geq 1\n\\]\n\\[\ny_1 \\leq y_2\n\\]\n\n\\[\ny_1 + 1 - y_2 \\geq 1\n\\]\n\n\\[\ny_1 \\geq y_2\n\\]\n\n(Actual constraint)\n\\[Y_{u, m} \\left( k \\right) = \\left\\{ \\text{True, False} \\right\\}\\]\n\\noindent $Y_{u, m} \\left( k \\right)=$True if mode $m$ is active at time $k$ for unit $u$  \n\n\\[\n    Z_{u, m, m'}\\left(k \\right) = \\left\\{\\text{True, False}\\right\\}\n\\]\n\n\\noindent $Z_{u, m, m'}\\left(k \\right)=$True if transition from $m$ to $m'$ occurs from time $k-1$ to $k$\n\n\\[\n    Y_{u, m} \\left( k \\right) = \\left\\{Z_{u, m', m}\\left(k\\right),\\dots  \\right\\}\n\\]\n\\[\n    Y_{u, m} \\left( k \\right) \\Leftrightarrow \\bigoplus_{m' \\in M} Z_{u, m', m}\\left(k\\right)\n\\]\n\n\\[\n    \\neg Y_{u, m} \\left( k \\right) \\vee \\bigoplus_{m' \\in M} Z_{u, m', m} \\left(k \\right)\n\\]\n\n\\[\n    Y_{1}\\left(k\\right) \\Leftrightarrow   Z_{0, 1} \\left( k \\right) \\oplus Z_{2, 1} \\left( k \\right)\n\\]\n\n\\[\n    Y_{0}\\left(k-1\\right) \\Leftrightarrow   Z_{0, 1} \\left( k \\right) \\oplus Z_{0, 2} \\left( k \\right)\n\\]\n\n\\[\n    \\begin{split}\n        Y_{0}\\left(k\\right) &\\Leftrightarrow   Z_{1, 0} \\left( k \\right) \\oplus Z_{2, 0} \\left( k \\right) \\\\\n        Y_{1}\\left(k\\right) &\\Leftrightarrow   Z_{0, 1} \\left( k \\right) \\oplus Z_{2, 1} \\left( k \\right) \\\\\n        Y_{2}\\left(k\\right) &\\Leftrightarrow   Z_{0, 2} \\left( k \\right) \\oplus Z_{1, 2} \\left( k \\right) \\\\\n    \\end{split}\n\\]\n\n\\[\n    \\begin{split}\n        Y_{0}\\left(k-1\\right) &\\Leftrightarrow   Z_{0, 1} \\left( k \\right) \\oplus Z_{0, 2} \\left( k \\right) \\\\\n        Y_{1}\\left(k-1\\right) &\\Leftrightarrow   Z_{1, 0} \\left( k \\right) \\oplus Z_{1, 2} \\left( k \\right) \\\\ \n        Y_{2}\\left(k-1\\right) &\\Leftrightarrow   Z_{2, 0} \\left( k \\right) \\oplus Z_{2, 1} \\left( k \\right) \\\\ \n    \\end{split}\n\\]\n\n\\[\n    y_{u,m}\\left(k\\right) = \\sum_{m' \\in M} z_{u, m', m} \\left( k \\right)\n\\]\n\n\n\\[\n    Y_{u, m} \\left( k-1 \\right) \\Leftrightarrow \\bigoplus_{m' \\in M} Z_{u, m, m'} \\left(k\\right)\n\\]\n\n\\[\n    Y_{u, m} \\left( k-1 \\right) = \\left\\{Z_{u, m, m'}\\left(k\\right), \\dots \\right\\}\n\\]\n\n\\[\n    y_{u,m}\\left(k-1 \\right) = \\sum_{m' \\in M} z_{u, m, m'} \\left( k \\right)\n\\]\n\n\\sectin{Sync times}\nI think there must be a separate set of constraints for this.\n\n\\begin{equation}\n    \\begin{pmatrix}\n        W_{\\text{cold}} \\\\\n        \n    \\end{pmatrix}\n    \\vee\n    \\begin{pmatrix}\n        W_{\\text{warm} \\\\\n    \\end{pmatrix}\n\\end{equation}\n\n%---------------------------------------------------------------------------\n\\end{document}\n", "meta": {"hexsha": "b0db0c1e6f0c0caa3161af6f0aa8bbb9a4856be5", "size": 11255, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/notes/notes.tex", "max_stars_repo_name": "dthierry/princetonDacLti", "max_stars_repo_head_hexsha": "135f1665d1ed09ef11af8559f14ff4665efbc723", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/notes/notes.tex", "max_issues_repo_name": "dthierry/princetonDacLti", "max_issues_repo_head_hexsha": "135f1665d1ed09ef11af8559f14ff4665efbc723", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/notes/notes.tex", "max_forks_repo_name": "dthierry/princetonDacLti", "max_forks_repo_head_hexsha": "135f1665d1ed09ef11af8559f14ff4665efbc723", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2097264438, "max_line_length": 383, "alphanum_fraction": 0.5682807641, "num_tokens": 4558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4142667122064194}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tikz, xcolor, array, graphicx}\n\\usetikzlibrary{arrows.meta}\n\\everymath{\\displaystyle}\n\n\\title{Polar Form of Conics}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\titlepage\n\\end{frame}\n\n\\section{Analyze the graphs of conic sections in polar form.}\n\n\\begin{frame}{Intro}\nGiven a fixed line $L$, a point $F$ not on $L$, and a positive number $e$, a \\alert{conic section} is the set of all points $P$ such that \\vspace{10pt}\n\\[\n\\frac{\\text{the distance from $P$ to $F$}}{\\text{the distance from $P$ to $L$}} = e\n\\]\n\\pause\n\\newline\\\\\n\nThe line $L$ is called the \\alert{directrix} of the conic section, the point $F$ is called a \\alert{focus} of the conic section, and the constant $e$ is called the \\alert{eccentricity} of the conic section.\n\\end{frame}\n\n\n\\begin{frame}{Eccentricity, Focus, and Directrix Line}\n    The conic section has eccentricity $e$, a focus $F$ at the origin and directrix line $x = -d$: \\newline\\\\\n\n\\begin{center}\n    \\begin{tikzpicture}\n    \\draw [->, >=stealth] (-3,0) -- (4,0) node [below, right] {$x$};\n    \\draw [->, >=stealth] (0,-1) -- (0,4) node [above, right] {$y$};\n    \\coordinate (P) at (50:3.5);\n    \\coordinate (O) at (0,0);\n    \\draw [fill=black] (P) circle (1pt) node [right] {$P(r, \\theta)$};\n    \\node at (O) [below right] {$O=F$};\n    \\draw [dashed] (O) -- (P) node [midway, above left] {$r$};\n    \\draw [<->, >=stealth, color=red] (-2.25,4) -- (-2.25,-0.5) node [below] {$x=-d$};\n    \\draw [<->, >=stealth, dashed, color=blue] (P) -- (0,2.68) node [midway, above] {$r\\cos\\theta$};\n    \\draw [<->, >=stealth, dashed, color=red] (-2.25,2.68) -- (0,2.68) node [midway, above] {$d$};\n    \\draw [->, >=stealth] (0:1) arc (0:50:1) node [midway, right] {$\\theta$}; \n    \\node at (-2.25,3.75) [red,left] {$L$};\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{General Equation}\nFrom which we get   \n\\[\ne = \\frac{\\text{the distance from $P$ to $F$}}{\\text{the distance from $P$ to $L$}} = \\frac{r}{d+r\\cos\\theta} = e\n\\]\n\\pause\nSo that $r = e(d + r\\cos\\theta)$, and solving for $r$ gives us  \n\\begin{align*}\n    \\onslide<3->{r &= ed +er\\cos\\theta} \\\\[8pt]\n    \\onslide<4->{r - er\\cos\\theta &= ed} \\\\[8pt]\n    \\onslide<5->{r(1-e\\cos\\theta) &= ed} \\\\[8pt]\n    \\onslide<6->{r &= \\frac{ed}{1-e\\cos\\theta}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\nExamine the graphs of each of the following for different values of $d$, but with $e = 1$.  \\newline\\\\\n(a) \\quad $r = \\frac{ed}{1+e\\cos\\theta}$    \\pause    \\quad $\\longrightarrow \\quad r = \\frac{d}{1+\\cos\\theta}$ \\newline\\\\ \\pause\n    \\begin{itemize}\n        \\item Parabola (opens left or right)  \\pause  \\newline\\\\\n        \\item Vertex at $\\left(\\frac{1}{2}d, 0\\right)$ \\pause \\newline\\\\\n        \\item $d > 0$ opens left    \\pause  \\newline\\\\\n        \\item $d < 0$ opens right   \\pause  \\newline\\\\\n        \\item $y$-intercepts at $\\left(0, \\pm d\\right)$\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $r = \\frac{ed}{1-e\\cos\\theta}$        \\pause    \\quad $\\longrightarrow \\quad r = \\frac{d}{1-\\cos\\theta}$ \\newline\\\\ \\pause\n    \\begin{itemize}\n        \\item Parabola (opens left or right)  \\pause  \\newline\\\\\n        \\item Vertex at $\\left(-\\frac{1}{2}d, 0\\right)$ \\pause \\newline\\\\\n        \\item $d > 0$ opens right    \\pause  \\newline\\\\\n        \\item $d < 0$ opens left   \\pause  \\newline\\\\\n        \\item $y$-intercepts at $\\left(0, \\pm d\\right)$\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $r = \\frac{ed}{1+e\\sin\\theta}$    \\pause    \\quad $\\longrightarrow \\quad r = \\frac{d}{1+\\sin\\theta}$ \\newline\\\\ \\pause\n    \\begin{itemize}\n        \\item Parabola (opens up or down)  \\pause  \\newline\\\\\n        \\item Vertex at $\\left(0, \\frac{1}{2}d\\right)$ \\pause \\newline\\\\\n        \\item $d > 0$ opens down    \\pause  \\newline\\\\\n        \\item $d < 0$ opens up   \\pause  \\newline\\\\\n        \\item $x$-intercepts at $\\left(\\pm d, 0\\right)$\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(d) \\quad   $r = \\frac{ed}{1-e\\sin\\theta}$  \\pause    \\quad $\\longrightarrow \\quad r = \\frac{d}{1-\\sin\\theta}$ \\newline\\\\ \\pause\n    \\begin{itemize}\n        \\item Parabola (opens up or down)  \\pause  \\newline\\\\\n        \\item Vertex at $\\left(0, -\\frac{1}{2}d\\right)$ \\pause \\newline\\\\\n        \\item $d > 0$ opens up    \\pause  \\newline\\\\\n        \\item $d < 0$ opens down   \\pause  \\newline\\\\\n        \\item $x$-intercepts at $\\left(\\pm d, 0\\right)$\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Follow-up to Example 1}\nNotice each of the previous graphs in Example 1 were parabolas. This is the case when $e = 1$. The directrix lines were either $x = \\pm d$ or $y = \\pm d$, and the focal diameter is $2d$.\n\\end{frame}\n\n\\begin{frame}{Example 2}\nExamine the graphs of each of the following for different values of $d$, but with $0 < e < 1$ and $e > 1$.  \\newline\\\\ \n(a) \\quad   $r = \\frac{ed}{1+e\\cos\\theta}$  \\newline\\\\  \\pause\nFor $0 < e < 1$:    \\pause  \\newline\\\\\n\nEllipse (wide)\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(a) \\quad   $r = \\frac{ed}{1+e\\cos\\theta}$  \\newline\\\\  \\pause\nFor $e > 1$:    \\pause  \\newline\\\\\n\nHyperbola (opening left and right)\n\\end{frame}\n\n\n\\begin{frame}{Example 2}\nExamine the graphs of each of the following for different values of $d$, but with $0 < e < 1$ and $e > 1$.  \\newline\\\\ \n(b) \\quad   $r = \\frac{ed}{1-e\\cos\\theta}$  \\newline\\\\  \\pause\nFor $0 < e < 1$:    \\pause  \\newline\\\\\n\nEllipse (wide)\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(b) \\quad   $r = \\frac{ed}{1-e\\cos\\theta}$  \\newline\\\\  \\pause\nFor $e > 1$:    \\pause  \\newline\\\\\n\nHyperbola (opening left and right)\n\\end{frame}\n\n\n\\begin{frame}{Example 2}\nExamine the graphs of each of the following for different values of $d$, but with $0 < e < 1$ and $e > 1$.  \\newline\\\\ \n(c) \\quad   $r = \\frac{ed}{1+e\\sin\\theta}$  \\newline\\\\  \\pause\nFor $0 < e < 1$:    \\pause  \\newline\\\\\nEllipse (tall)\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(c) \\quad   $r = \\frac{ed}{1+e\\sin\\theta}$  \\newline\\\\  \\pause\nFor $e > 1$:    \\pause  \\newline\\\\\n\nHyperbola (opening up and down)\n\\end{frame}\n\n\\begin{frame}{Example 2}\nExamine the graphs of each of the following for different values of $d$, but with $0 < e < 1$ and $e > 1$.  \\newline\\\\ \n(d) \\quad   $r = \\frac{ed}{1-e\\sin\\theta}$  \\newline\\\\  \\pause\nFor $0 < e < 1$:    \\pause  \\newline\\\\\n\nEllipse (tall)\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(d) \\quad   $r = \\frac{ed}{1-e\\sin\\theta}$  \\newline\\\\  \\pause\nFor $e > 1$:    \\pause  \\newline\\\\\n\nHyperbola (opening up and down)\n\\end{frame}\n\n\\begin{frame}{Properties From Example 2}\nIn the previous example, the graphs in which $0 < e < 1$ were ellipses. \\\\[18pt]  \\pause\n\nMajor axis length is $\\frac{2ed}{1-e^2}$ \\\\[18pt] \\pause\nMinor axis length is $\\frac{2ed}{\\sqrt{1-e^2}}$.   \n\\end{frame}\n\n\\begin{frame}{Properties From Example 2}\n\nIf $e > 1$, the graph is a hyperbola.   \\\\[18pt] \\pause\n\nTransverse axis length $\\frac{2ed}{e^2-1}$  \\\\[18pt]    \\pause\nConjugate axis length $\\frac{2ed}{\\sqrt{e^2-1}}$.\n\\end{frame}\n\n\\begin{frame}{Example 3}\nIdentify the conic for each.    \\newline\\\\\n(a) \\quad $r = \\frac{4}{1-\\sin\\theta}$  \\newline\\\\  \\pause\n$e = 1 \\longrightarrow$ Parabola (opens up).   \\newline\\\\  \\pause\nVertex: $(0, -2)$   \\newline\\\\  \\pause\nGoes through $(\\pm 4, 0)$\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(b) \\quad $r = \\frac{12}{3-\\cos\\theta}$ \\pause  \\quad $\\longrightarrow \\quad r = \\frac{4}{1-1/3\\cos\\theta}$   \\\\[18pt] \\pause\n$e = \\frac{1}{3} \\longrightarrow$ Ellipse (wide) \\\\[15pt] \\pause\n$\\frac{1}{3}d = 4 \\longrightarrow d = 12$   \\\\[15pt]  \\pause\nMajor axis length: $\\frac{2(1/3)(12)}{1-(1/3)^2} = 9$  \\\\[15pt]   \\pause\nMinor axis length: $\\frac{2(1/3)(12)}{\\sqrt{1-(1/3)^2}} = 6\\sqrt{3}$\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(c) \\quad $r = \\frac{6}{1+2\\sin\\theta}$ \\newline\\\\  \\pause\n$e = 2$: Hyperbola (opens up and down) \\newline\\\\ \\pause\n$2d = 6 \\longrightarrow d = 3$  \\newline\\\\  \\pause\nTransverse axis length: $\\frac{2(2)(3)}{2^2-1} = 4$ \\\\[15pt]    \\pause\nConjugate axis length: $\\frac{2(2)(3)}{\\sqrt{2^2-1}} = 4\\sqrt{3}$\n\\end{frame}\n\n\n\\begin{frame}{Polar Form of Rotated Conics}\nFor constants $\\ell > 0, \\, e \\geq 0, \\text{ and } \\phi,$ the graph of \n\\[\nr = \\frac{\\ell}{1-e\\cos(\\theta-\\phi)}\n\\]\nis a conic section with eccentricity $e$ and one focus at $(0,0)$.\n\\end{frame}\n\n\\begin{frame}{Polar Form of Rotated Conics}\n    If $e = 0$, the graph is a circle centered at $(0,0)$ with radius $\\ell$.\n\\end{frame}\n\n\\begin{frame}{Polar Form of Rotated Conics}\n    If $e \\neq 0$, the conic has a focus at $(0,0)$ and the directrix contains the point with polar coordinates $(-d,\\phi)$ where $d = \\frac{\\ell}{e}$.\n    \\begin{itemize}\n        \\item If $0 < e < 1$, graph is an ellipse with major axis length $\\frac{2ed}{1-e^2}$ and minor axis length $\\frac{2ed}{\\sqrt{1-e^2}}$. \\\\[15pt] \\pause\n        \\item If $e=1$, graph is a parabola with focal diameter $2d$.   \\\\[15pt]    \\pause\n        \\item If $e > 1$, graph is a hyperbola with transverse axis length $\\frac{2ed}{e^2-1}$ and conjugate axis length $\\frac{2ed}{\\sqrt{e^2-1}}$\n    \\end{itemize}\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "58db6b940fc16423bbbd1f4dda1923a49c3a2ed9", "size": 9300, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Polar_Form_of_Conics(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Polar_Form_of_Conics(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Polar_Form_of_Conics(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 37.0517928287, "max_line_length": 206, "alphanum_fraction": 0.6092473118, "num_tokens": 3470, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.41426670630391954}}
{"text": "\\chapter{Conclusion}\\label{cha:conclusion}\nThis chapter answers the research questions by summarizing the results and discussions.\nIt also gives a conclusive answer as to which algorithm one should use when implementing an optimal scanline algorithm.\n\n\\section{Research Questions}\nThe research questions presented in the introduction are reiterated and answered in the following paragraphs.\n\n\\begin{enumerate}\n\\item Which line voxelization algorithm performs best for the optimal scanline? \n\\end{enumerate}\nFor all models and voxel grid resolution, the floating-point version, RLV, performed better.\nILV performed anywhere between 20-250\\% worse compared to RLV.\nBresenham performed anywhere between 20-500\\% worse compared to RLV.\nInterestingly, ILV performed better than Bresenham in every case but two.\nAlthough, the difference was not as dramatic as between RLV and ILV, except for a few outliers which performed way worse.\n\nThe reason for the big difference between the floating-point and integer versions was due to the complexity of finding the scanline endpoints.\nFor RLV, it was simply a case of increasing the length of the scanline direction and performing a reverse projection of the direction to the triangle's edges.\nFor ILV and Bresenham, finding the endpoints required iterating through the edge voxelizations and performing a boundary test based on the previous scanline and the current voxel.\n\nThe reason for ILV being faster than Bresenham had less to do with Bresenham being worse in general.\nIt had more to do with Bresenham not being able to step the line voxelization by one voxel each iteration.\nThis in turn required extra overhead to overcome.\n\n\\begin{enumerate}\n\\setcounter{enumi}{1}\n\\item How great is the approximation error of the integer versions of the optimal scanline?\n\\end{enumerate}\nThe error for the integer versions of the optimal scanline was determined to be around 20-25\\%.\nThis was based on the Jaccard distance between RLV and ILV/Bresenham.\nOne outlier of the data was the dragon model, with 871414 triangles, where the error started at around 9\\% for a voxel grid resolution of 128.\nIt however gradually grew as the resolution increased.\nThe reason was likely due to the triangles of the model being mostly within a single or a few voxels.\nMaking it less likely to cause an error.\n\nThere also turned out to be a minor error ($\\sim$5\\%) between ILV and Bresenham, even though they both used the same underlying algorithm.\nThis was caused due to cases where the scanline passes through multiple voxels, such that the choice of voxel was ambiguous.\nAn example of this was shown in \\figref{fig:ilv-bresen-error}.\n\n\\section{Choice of Algorithm}\nFrom the results given there is only one obvious choice as to which algorithm one should use.\nThis is of course the floating-point version using RLV.\nThe algorithm had the best performance in terms of runtime.\nIt is also closer to the ground truth, as it only voxelizes voxels touching the triangle.\nDue to approximation errors, this is not the case for the integer versions.\nGiven those results, there should be no reason not to choose RLV.\n", "meta": {"hexsha": "4f26fd343d8e44e413aa16ed18b4a245790d5b40", "size": 3127, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/Latex/conclusion.tex", "max_stars_repo_name": "Thraix/MasterThesis", "max_stars_repo_head_hexsha": "4e4cb94b2a4ee261b2b9974aa4b20f6643eb6595", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-16T10:54:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-16T10:54:38.000Z", "max_issues_repo_path": "Thesis/Latex/conclusion.tex", "max_issues_repo_name": "Thraix/MasterThesis", "max_issues_repo_head_hexsha": "4e4cb94b2a4ee261b2b9974aa4b20f6643eb6595", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/Latex/conclusion.tex", "max_forks_repo_name": "Thraix/MasterThesis", "max_forks_repo_head_hexsha": "4e4cb94b2a4ee261b2b9974aa4b20f6643eb6595", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.5319148936, "max_line_length": 179, "alphanum_fraction": 0.8078030061, "num_tokens": 679, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318194686362, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4142667024266171}}
{"text": "\\documentclass{article}%\n\n\\usepackage{amsmath,amssymb,amsfonts,epsfig,amsfonts}\n\\usepackage{cite}\n\\usepackage{graphicx}\n\\usepackage{subfigure}\n\\usepackage{mathrsfs}\n\\usepackage{extarrows}  %\n\\usepackage{hyperref}\n\\usepackage{comment}  %\n\\usepackage{pgfplots} %\n\\makeatletter\n\n\\baselineskip=40pt\n\\textheight 22.5truecm\n\\topmargin -0.5125truein\n\\textwidth 15.74truecm\n\\oddsidemargin -0.06truein\n\\evensidemargin -0.06truein\n\\parskip=0.1in\n\\renewcommand{\\baselinestretch}{1.2}   %\n\n\\title{ \\bf Are local-mins Rare?\n \\footnote{This is an informal note. }\n} \\vskip 1cm\n\\author{ Thomas Jefferson\n}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n\nAnalyze nonconvex optimization from topology. \n\n\\end{abstract}\n\n\\thispagestyle{empty}\n\n\n\n\n\\section{Test Section}\n\n\n\n\n\\iffalse \n This is commented by iffalse command, not comment.\n Not easy to be eliminated by this cleaning file. \n \\fi \n\nThis is a percent \\%.  Should stay here after running the cleaning file. \n\nWe add a figure for testing. \n\n\\includegraphics{images/im1_included.png}\n\nIf the code is correct, then the following figure should not appear in the cleaned tex file (\nif the code is wrong in the sense that it only removes $\\%$ but not the commands\nafter it, then the non-included figure would appear in the cleaned tex  file).\n\n\nWe can also check inputting other Latex Files.\nThis is a file in a sub-folder ``figures'', and we are supposed to see\none figure, but not two figures. \n\n\\input{figures/figure_included.tex}\n\n\n\n\\section{Model}\n\nThis part is a test that the standard math formulas will not be affected after\nrunning the cleaning file. \n\nDefinition (LSC property): $\\forall \\bar{\\alpha} \\in G, \\bar{x} \\in L_f(\\bar{\\alpha}) \\triangleq \\{ x: f(x) \\leq \\bar{\\alpha} \\}$,\nand $\\forall$ sequence $\\{ \\alpha_i \\} \\rightarrow \\bar{\\alpha}$, we have \n$$\n\\exists x^i \\in L_f(\\alpha_i), \\text{s.t. } \\{ x^i\\} \\rightarrow \\bar{x}. \n$$\n\nDefinition (GC property): For any two points $ f(\\tilde{x}) < f(\\bar{x}) $, there exists a sequence $ \\{x^i\\} \\in C$ converging to $ \\bar{x} $\nsuch that \n\\begin{equation}\nf(x^i)\\leq \\frac{1}{i} f(\\tilde{x}) + (1 - \\frac{1}{i})f(\\bar{x}). \n\\end{equation} \n\n\n \\vspace{0.3cm}\n\n{\\footnotesize\n\\bibliography{refs}\n}\n\n\n\\end{document}\n\n\n\n", "meta": {"hexsha": "96e4d20e4d36fbeaeffab6c60ecad3fbf8f0ee1a", "size": 2225, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex_test_arXiv/main.tex", "max_stars_repo_name": "ruoyus/arxiv-latex-cleaner", "max_stars_repo_head_hexsha": "98511861b42d6f58f8fa75a82858c1019fa61f5a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex_test_arXiv/main.tex", "max_issues_repo_name": "ruoyus/arxiv-latex-cleaner", "max_issues_repo_head_hexsha": "98511861b42d6f58f8fa75a82858c1019fa61f5a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex_test_arXiv/main.tex", "max_forks_repo_name": "ruoyus/arxiv-latex-cleaner", "max_forks_repo_head_hexsha": "98511861b42d6f58f8fa75a82858c1019fa61f5a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.8137254902, "max_line_length": 142, "alphanum_fraction": 0.7150561798, "num_tokens": 705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6224593452091672, "lm_q1q2_score": 0.41419102069280794}}
{"text": "\\documentclass{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\n\\title{hello-\\LaTeX}\n\\author{valorad }\n\\date{January 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Introduction}\n% This section is very important\nWelcome to this \\textbf{presentation}. In this section, we will see how a program called \\textit{superValleyStation} is boomed within \\emph{0.1} seconds.\n\n\\section{Entertainment}\n\n\\subsection{TV}\n\n\\subsubsection{Talk-shows}\n\n% \\paragraph is like a heading\n\n\\paragraph{\nDo various kinds of entertainment bring about happiness?\n}\n\n\\ldots Y/n\n\n\\subparagraph{Why?}\n\n\n\n\n\n\\section{Mathtime}\n\n\\begin{equation}\n    y_0 = x^{ \\frac{3} {4} }\n\\end{equation}\n\n\\begin{equation}\n   \\frac {x^2 + a} {2x}\n\\end{equation}\n\n\\begin{equation}\n   \\sqrt[8]{x^3 + B}\n\\end{equation}\n\nAn inline version of equation is surrounded by double dollar signs like $+\\infty$\n\n\n\n\\section{FigureTime}\n\nSome figures will show here.\n\nFirst, you will see a random cat in Figure \\ref{fig:randomKit}.\n\nAn ancient research on cat predatory actions reveals that cats generally have high tendency on attacking rodents such as mice \\cite{reis1973predatory}.\n\nA recent study on the behavior of jungle cats also indicates that the cats are cats \\cite{MARINATH2019112651}.\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{images/kittenrandom.jpg}\n    \\caption{Random Kitten}\n    \\label{fig:randomKit}\n\\end{figure}\n\n\n\\section{Table time}\n\n% Generate your table at https://www.tablesgenerator.com/latex_tables#\n\nThis section shows some tables.\n\nFirst, some rubbish courses are shown in Table \\ref{table:trashCourses}\n\n\\begin{table}[ht]\n\\centering\n\\caption{Trash courses}\n\\label{table:trashCourses}\n\\begin{tabular}{|c|l|l|}\n\\hline\nCourse               & \\multicolumn{1}{c|}{Difficulty} & \\multicolumn{1}{c|}{Drop rate} \\\\ \\hline\nLisa's cooking class & 60                              & 50                             \\\\ \\hline\nBoxing class         & 90                              & 0                              \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\n\n\n\\bibliographystyle{plain}\n\\bibliography{ref.bib}\n\n\\end{document}", "meta": {"hexsha": "063aa4a72b2429236032ab41f0e6f7e47e828dad", "size": 2164, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "longyiszh/hello-latex", "max_stars_repo_head_hexsha": "ae397ad13d0e3db5bbfae170b89e5e313c94fcd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "longyiszh/hello-latex", "max_issues_repo_head_hexsha": "ae397ad13d0e3db5bbfae170b89e5e313c94fcd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "longyiszh/hello-latex", "max_forks_repo_head_hexsha": "ae397ad13d0e3db5bbfae170b89e5e313c94fcd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.4150943396, "max_line_length": 153, "alphanum_fraction": 0.6908502773, "num_tokens": 612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4141910165626846}}
{"text": "\\section{Two body problem}\nThe problem of motion of bodies relative to each other has long been studied. However it's only until recently that researchers have been able to use the full power of computers to research on these problems. In this project we will  leverage on the research that has been done on n-body problems specifically the two-body problems. The two body problem is able to be solved exactly reproducing the Kepler laws.\nJohannes Kepler 1571 to 1630 was able to formulate laws that described the data gathered by Tycho Brahe. These laws were largely empirical. Isaac newton who came after him was able to formulate the laws that  govern motion. Joseph lagrange was able to make these equations more detailed. For this project we will focus on the two body problem. The two body problem states that given two bodies with velocities and masses at a given time,t, seperated by a distance, r, find consecutive values for the v and r henceforth.\n", "meta": {"hexsha": "099ff56cbf33ecebf9a7fb42f57661d5c5c8eb1f", "size": 959, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/chapter02.tex", "max_stars_repo_name": "Sylvance/two-body-problem-simulation", "max_stars_repo_head_hexsha": "b40f0018960891ae59fd2eb970a94427b9319e67", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-13T14:29:54.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-13T14:29:54.000Z", "max_issues_repo_path": "thesis/chapters/chapter02.tex", "max_issues_repo_name": "Sylvance/two-body-problem-simulation", "max_issues_repo_head_hexsha": "b40f0018960891ae59fd2eb970a94427b9319e67", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapters/chapter02.tex", "max_forks_repo_name": "Sylvance/two-body-problem-simulation", "max_forks_repo_head_hexsha": "b40f0018960891ae59fd2eb970a94427b9319e67", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-03-20T07:18:27.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-18T17:53:48.000Z", "avg_line_length": 239.75, "max_line_length": 519, "alphanum_fraction": 0.8070907195, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.4141910155023174}}
{"text": "\\index{reference cells}\n\nThe following five reference cells are covered by the UFC specification:\nthe reference \\emph{interval},\nthe reference \\emph{triangle},\nthe reference \\emph{quadrilateral},\nthe reference \\emph{tetrahedron} and\nthe reference \\emph{hexahedron} (see Table~\\ref{tab:ufc_reference_cells}).\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|l|c|c|c|}\n      \\hline\n      Reference cell & Dimension & \\#Vertices & \\#Facets \\\\\n      \\hline\n      \\hline\n      The reference interval      & 1 & 2 & 2 \\\\\n      \\hline\n      The reference triangle      & 2 & 3 & 3 \\\\\n      \\hline\n      The reference quadrilateral & 2 & 4 & 4 \\\\\n      \\hline\n      The reference tetrahedron   & 3 & 4 & 4 \\\\\n      \\hline\n      The reference hexahedron    & 3 & 8 & 6 \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Reference cells covered by the UFC specification.}\n    \\label{tab:ufc_reference_cells}\n  \\end{center}\n\\end{table}\n\nThe UFC specification assumes that each cell in a finite element mesh\nis always isomorphic to one of the reference cells.\n\n\\section{The reference interval}\n\\index{interval}\n\nThe reference interval is shown in Figure~\\ref{fig:interval} and is\ndefined by its two vertices with coordinates as specified in\nTable~\\ref{tab:interval,vertices}.\n\n\\begin{figure}\n  \\begin{center}\n    \\psfrag{0}{$0$}\n    \\psfrag{1}{$1$}\n    \\includegraphics[width=10cm]{eps/interval.eps}\n    \\caption{The reference interval.}\n    \\label{fig:interval}\n  \\end{center}\n\\end{figure}\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_0$ & $x = 0$ \\\\\n      \\hline\n      $v_1$ & $x = 1$ \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Vertex coordinates of the reference interval.}\n    \\label{tab:interval,vertices}\n  \\end{center}\n\\end{table}\n\n\\section{The reference triangle}\n\\index{triangle}\n\nThe reference triangle is shown in Figure~\\ref{fig:triangle} and is\ndefined by its three vertices with coordinates as specified in\nTable~\\ref{tab:triangle,vertices}.\n\n\\begin{figure}\n  \\begin{center}\n    \\psfrag{v0}{$(0, 0)$}\n    \\psfrag{v1}{$(1, 0)$}\n    \\psfrag{v2}{$(0, 1)$}\n    \\includegraphics[width=8cm]{eps/triangle.eps}\n    \\caption{The reference triangle.}\n    \\label{fig:triangle}\n  \\end{center}\n\\end{figure}\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_0$ & $x = (0, 0)$ \\\\\n      \\hline\n      $v_1$ & $x = (1, 0)$ \\\\\n      \\hline\n      $v_2$ & $x = (0, 1)$ \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Vertex coordinates of the reference triangle.}\n    \\label{tab:triangle,vertices}\n  \\end{center}\n\\end{table}\n\n\\section{The reference quadrilateral}\n\\index{quadrilateral}\n\nThe reference quadrilateral is shown in Figure~\\ref{fig:quadrilateral}\nand is defined by its four vertices with coordinates as specified in\nTable~\\ref{tab:quadrilateral,vertices}.\n\n\\begin{figure}\n  \\begin{center}\n    \\psfrag{v0}{$(0, 0)$}\n    \\psfrag{v1}{$(1, 0)$}\n    \\psfrag{v2}{$(1, 1)$}\n    \\psfrag{v3}{$(0, 1)$}\n    \\includegraphics[width=8cm]{eps/quadrilateral.eps}\n    \\caption{The reference quadrilateral.}\n    \\label{fig:quadrilateral}\n  \\end{center}\n\\end{figure}\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_0$ & $x = (0, 0)$ \\\\\n      \\hline\n      $v_1$ & $x = (1, 0)$ \\\\\n      \\hline\n      $v_2$ & $x = (1, 1)$ \\\\\n      \\hline\n      $v_3$ & $x = (0, 1)$ \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Vertex coordinates of the reference quadrilateral.}\n    \\label{tab:quadrilateral,vertices}\n  \\end{center}\n\\end{table}\n\n\\section{The reference tetrahedron}\n\\index{tetrahedron}\n\nThe reference tetrahedron is shown in Figure~\\ref{fig:tetrahedron} and\nis defined by its four vertices with coordinates as specified in\nTable~\\ref{tab:tetrahedron,vertices}.\n\n\\begin{figure}\n  \\begin{center}\n    \\psfrag{v0}{$(0, 0, 0)$}\n    \\psfrag{v1}{$(1, 0, 0)$}\n    \\psfrag{v2}{$(0, 1, 0)$}\n    \\psfrag{v3}{$(0, 0, 1)$}\n    \\includegraphics[width=6cm]{eps/tetrahedron.eps}\n    \\caption{The reference tetrahedron.}\n    \\label{fig:tetrahedron}\n  \\end{center}\n\\end{figure}\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_0$ & $x = (0, 0, 0)$ \\\\\n      \\hline\n      $v_1$ & $x = (1, 0, 0)$ \\\\\n      \\hline\n      $v_2$ & $x = (0, 1, 0)$ \\\\\n      \\hline\n      $v_3$ & $x = (0, 0, 1)$ \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Vertex coordinates of the reference tetrahedron.}\n    \\label{tab:tetrahedron,vertices}\n  \\end{center}\n\\end{table}\n\n\\section{The reference hexahedron}\n\\index{hexahedron}\n\nThe reference hexahedron is shown in Figure~\\ref{fig:hexahedron} and\nis defined by its eight vertices with coordinates as specified in\nTable~\\ref{tab:hexahedron,vertices}.\n\n\\begin{figure}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\psfrag{v0}{$(0, 0, 0)$}\n    \\psfrag{v1}{$(1, 0, 0)$}\n    \\psfrag{v2}{$(1, 1, 0)$}\n    \\psfrag{v3}{$(0, 1, 0)$}\n    \\psfrag{v4}{$(0, 0, 1)$}\n    \\psfrag{v5}{$(1, 0, 1)$}\n    \\psfrag{v6}{$(1, 1, 1)$}\n    \\psfrag{v7}{$(0, 1, 1)$}\n    \\includegraphics[width=9cm]{eps/hexahedron.eps}\n    \\caption{The reference hexahedron.}\n    \\label{fig:hexahedron}\n  \\end{center}\n\\end{figure}\n\n\\begin{table}\n\\linespread{1.2}\\selectfont\n  \\begin{center}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_0$ & $x = (0, 0, 0)$ \\\\\n      \\hline\n      $v_1$ & $x = (1, 0, 0)$ \\\\\n      \\hline\n      $v_2$ & $x = (1, 1, 0)$ \\\\\n      \\hline\n      $v_3$ & $x = (0, 1, 0)$ \\\\\n      \\hline\n    \\end{tabular}\n    \\begin{tabular}{|c|c|}\n      \\hline\n      Vertex & Coordinate \\\\\n      \\hline\n      \\hline\n      $v_4$ & $x = (0, 0, 1)$ \\\\\n      \\hline\n      $v_5$ & $x = (1, 0, 1)$ \\\\\n      \\hline\n      $v_6$ & $x = (1, 1, 1)$ \\\\\n      \\hline\n      $v_7$ & $x = (0, 1, 1)$ \\\\\n      \\hline\n    \\end{tabular}\n    \\caption{Vertex coordinates of the reference hexahedron.}\n    \\label{tab:hexahedron,vertices}\n  \\end{center}\n\\end{table}\n", "meta": {"hexsha": "d02441567175197af13bc7e6e70fe8b5024808bf", "size": 6243, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/ufc-2.0.5/doc/manual/chapters/referencecells_common.tex", "max_stars_repo_name": "szmurlor/fiver", "max_stars_repo_head_hexsha": "083251420eb934d860c99dcf1eb07ae5b8ba7e8c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ufc-2.0.5/doc/manual/chapters/referencecells_common.tex", "max_issues_repo_name": "szmurlor/fiver", "max_issues_repo_head_hexsha": "083251420eb934d860c99dcf1eb07ae5b8ba7e8c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ufc-2.0.5/doc/manual/chapters/referencecells_common.tex", "max_forks_repo_name": "szmurlor/fiver", "max_forks_repo_head_hexsha": "083251420eb934d860c99dcf1eb07ae5b8ba7e8c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8725099602, "max_line_length": 74, "alphanum_fraction": 0.5985904213, "num_tokens": 2285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.4141910061817034}}
{"text": "\\documentclass[11pt, oneside]{book}\n\\input{latex-classnotes-preamble.tex}\n\n% Main Body\n\\title{Frequently Used Theorems}\n\\author{Johnson Ng}\n\n\\begin{document}\n\\hypersetup{pageanchor=false}\n\\maketitle\n\\hypersetup{pageanchor=true}\n\\tableofcontents\n\n\\chapter*{List of Definitions}\n\\theoremlisttype{all}\n\\listtheorems{defn}\n\n\\chapter*{List of Theorems}\n\\theoremlisttype{allname}\n\\listtheorems{axiom,lemma,thm,crly,propo}\n\n\\chapter*{Foreword}\n  \\label{chapter:foreword}\n\nThis booklet contains some of the frequently used theorems that I simply cannot remember and always have to waste time searching for the theorem. Proofs may or may not be included depending on how I find them relevant. Note that these theorems are introduced based on the curriculum of my varsity.\n\nFor anyone that wishes to grab this pdf for yourself, feel free to do so.\n\n% chapter foreword (end)\n\n\\chapter{General}\n  \\label{chapter:general}\n\n\n\n% chapter general (end)\n\n\\chapter{Calculus/Analysis}\n  \\label{chapter:calculus/Analysis}\n\n\\begin{thm}[Mean Value Theorem]\\label{thm:mean_value_theorem}\n   \\begin{gather*}\n     \\forall a, b \\in \\mathbb{R} \\\\\n     f: [a, b] \\to \\mathbb{R} \\text{ differentiable in } (a, b) \\implies \\\\\n     \\exists c \\in (a, b) \\quad f'(c) = \\frac{f(b) - f(a)}{b - a} \n   \\end{gather*}\n\\end{thm}\n\n% chapter calculus/Analysis (end)\n\n\\end{document}", "meta": {"hexsha": "1247b764cd75f3990a453d50529edf806bc6d25d", "size": 1339, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Others/fut.tex", "max_stars_repo_name": "japorized/TeX_notes", "max_stars_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-09-28T21:23:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-21T01:41:27.000Z", "max_issues_repo_path": "Others/fut.tex", "max_issues_repo_name": "japorized/TeX_notes", "max_issues_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-29T17:58:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-29T17:58:51.000Z", "max_forks_repo_path": "Others/fut.tex", "max_forks_repo_name": "japorized/TeX_notes", "max_forks_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-09-27T20:55:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-27T20:55:58.000Z", "avg_line_length": 26.2549019608, "max_line_length": 297, "alphanum_fraction": 0.7341299477, "num_tokens": 414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7853085909370422, "lm_q1q2_score": 0.4141061959530277}}
{"text": "% Data Mining HS 2017; Ondrej Skopek, Lukas Jendele\n% This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.\n%\n% Adapted from:\n%\n% 0. Lecutre slides; https://las.inf.ethz.ch/teaching/dm-f17\n% 1. Taivo Pungas; https://github.com/taivop/eth-dm\n% 2. Vincent Ulitzsch, et al.; https://github.com/viniul/Data-Mining-Cheat-Sheet-ETHZ\n%    Copyright for template: \\copyright\\ 2014 Winston Chang\n%    \\href{http://www.stdout.org/~winston/latex/}{http://www.stdout.org/$\\sim$winston/latex/}\n%    Cheat Sheet By Vincent Ulitzsch and Mario Gersbach\n\n\\documentclass[11pt,landscape]{article}\n%\\usepackage{times}\n\\usepackage[scaled]{helvet}\n\\usepackage{multicol}\n\\usepackage{xcolor}\n\\usepackage{calc}\n\\usepackage{ifthen}\n\\usepackage[landscape]{geometry}\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{enumitem}\n\\usepackage{algorithmicx}\n\\usepackage[noend]{algpseudocode}\n\\setlist{nolistsep}\n\\usepackage{titlesec}\n\\ifthenelse{\\lengthtest { \\paperwidth = 11in}}\n    { \\geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }\n    {\\ifthenelse{ \\lengthtest{ \\paperwidth = 297mm}}\n        {\\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }\n        {\\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }\n    }\n\n\n\\algnewcommand\\algorithmicforeach{\\textbf{for each}}\n\\algdef{S}[FOR]{ForEach}[1]{\\algorithmicforeach\\ #1\\ \\algorithmicdo}\n\n% Turn off header and footer\n\\pagestyle{empty}\n\\titlespacing{\\section}{0pt}{\\parskip}{-\\parskip}\n\n\\definecolor{sectionColor}{HTML}{EE0000}\n\\definecolor{subsectionColor}{HTML}{FF7F00}\n\\definecolor{subsubsectionColor}{HTML}{EE6600}\n\n% Redefine section commands to use less space\n\\makeatletter\n\\renewcommand{\\section}{\\@startsection{section}{1}{0mm}%\n                                {-1ex plus -.5ex minus -.2ex}%\n                                {0.5ex plus .2ex}%x\n                                {\\color{sectionColor}\\normalfont\\normalsize\\bfseries}}\n\\renewcommand{\\subsection}{\\@startsection{subsection}{2}{0mm}%\n                                {-1ex plus -.5ex minus -.2ex}%\n                                {0.5ex plus .2ex}%\n                                {\\color{subsectionColor}\\normalfont\\normalsize\\bfseries}}\n\\renewcommand{\\subsubsection}{\\@startsection{subsubsection}{3}{0mm}%\n                                {-1ex plus -.5ex minus -.2ex}%\n                                {1ex plus .2ex}%\n                                {\\color{subsubsectionColor}\\normalfont\\small\\bfseries}}\n\\makeatother\n\n% Define BibTeX command\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\n\n% Don't print section numbers\n\\setcounter{secnumdepth}{0}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{0pt plus 0.5ex}\n\n\\setlength{\\abovedisplayskip}{0pt}\n\\setlength{\\belowdisplayskip}{0pt}\n\\setlength{\\abovedisplayshortskip}{0pt}\n\\setlength{\\belowdisplayshortskip}{0pt}\n\n% -----------------------------------------------------------------------\n\n\\begin{document}\n\n\\raggedright\n\\footnotesize\n\\begin{multicols}{3}\n\n% multicol parameters\n% These lengths are set only within the two main columns\n%\\setlength{\\columnseprule}{0.25pt}\n\\setlength{\\premulticols}{1pt}\n\\setlength{\\postmulticols}{1pt}\n\\setlength{\\multicolsep}{0pt}\n\\setlength{\\columnsep}{0.5pt}\n\n\\section{General Remarks}\n\\begin{tabular}{ l c  }\n$\\mathrm{d}(x, y) = ||x - y||$, & $\\mathrm{dist}(x, y) = 1 - \\mathrm{sim}(x, y)$\\\\\n$l_2$-euclidean distance & $\\sqrt{\\sum_{i=1}^d (x_i-y_i)^2}$ \\\\\n$l_1$-manhatten distance & $\\sum_{i=1}^d \\left|x_i-y_i\\right|$\\\\\n$l_p$-distance & $(\\sum_{i=1}^d |x_i-y_i|^p)^{1/p}$ \\\\\n$l_\\infty$-distance & $\\max_i | x_i - y_i| $ \\\\\nMahalanobis norm & $||w||^2_G = ||Gw||^2_2$ \\\\\nCosine-Similarity & $\\cos \\frac{x^T y}{||x||_2 ||y||_2}$ \\\\\nJaccard-Distance & $1-\\text{sim}(A,B) = 1 - \\frac{|A \\cap B|}{|A \\cup B|}$\n\\end{tabular}\n\n\\subsection{Function Properties}\n\\begin{description}\n    \\item[Concave function] $f(a + s) - f(a) \\geq f(b + s) - f(b)~\\forall a \\leq b, s > 0$\n    \\item[Convex functions] A function $f: S \\rightarrow \\mathbb{R}$, $S \\subseteq \\mathbb{R}^d$,\n        is called convex if $\\forall x,x' \\in S, \\lambda \\in [0,1]$ it holds that\n    $\\lambda f(x) + (1 - \\lambda) f(x') \\geq f(\\lambda x + (1 - \\lambda) x')$\n    \\item[H-strongly convex]\n    $f(x') \\geq f(x) + \\nabla f(x)^T (x'-x) + \\frac{H}{2} ||x' -x||^2, H > 0$\\\\\n    1-D: $f$ is H-sc $\\Leftarrow f''(x) \\geq H, \\forall x$.\\\\\n    $d$-D: $f$ is H-sc $\\Leftarrow$ $\\lambda_{\\min}(\\nabla^2 f(x)) \\geq H, \\forall x$.\n\\item[Subgradients] Given a convex not necessarily differentiable function $f$, a subgradient $\\mathbf{g_x} \\in \\nabla f(x)$ is the slope of a linear lower bound of $f$, tight at $x$, that is\n    $\\forall x' \\in S \\colon f(x') \\geq f(x) + \\mathbf{g_x}^T(x' - x)$\n\\end{description}\n\n\\section{Locality Sensitive Hashing}\n    \\begin{description}\n        \\item[Near-duplicate detection] $ \\{ (x,y) \\in X \\times X : x \\neq y, \\text{d}(x,y) \\leq \\epsilon \\}$\n        \\item[$(r,\\epsilon)$-neighbour search]\n        Find all points with distance $\\leq r$ and no points with distance $> (1+ \\epsilon)r$ from query q.\n        Pick $(r,(1+\\epsilon) \\cdot r,p,q)$-sensitive family and boost.\n        \\item[Min-hashing] $h(C) = h_{\\pi}(C) = \\min_{i : C(i) = 1} \\pi(i)$\n            \\subitem $\\pi(i) = h_{a, b}(i) = ((a \\cdot i + b) \\mod p) \\mod N)$,\n        $p \\text{ prime (fixed) } > N$, $N$ number of documents\n        $(d_1, d_2, 1-d_1, 1-d_2)$-sensitive with Jaccard sim.\n            \\hrule\n            \\begin{algorithmic}[1]\n\\For {each column $c$}\n    \\For {each row $r$}\n        \\If {$c$ has 1 in row $r$}\n            \\For {each hash fn $h_i$}\n                \\State $M_{i,c} \\gets \\min\\{h_i(r), M_{i,c}\\}$\n            \\EndFor\n        \\EndIf\n    \\EndFor\n\\EndFor\n\\end{algorithmic}\n        \\item[Band-hashing] Signature matrix into $b$ bands of $r$ hash fns,\n            per-column into $b$ hash tables. If any h-table has a collision,\n            report candidate pair. $s^r$ prob of col on band $j$: $P(\\text{col in } \\geq 1 \\text{ band}) = 1-(1-s^r)^b$\n        \\item[$(d1,d2,p1,p2)$-sensitivity] Assume $d_1<d_2$, $p_1>p_2$.\n                $\\forall x,y \\in S: d(x,y) \\leq d_1 \\Rightarrow Pr[h(x)=h(y)] \\geq p_1$\\\\\n                $\\forall x,y \\in S: d(x,y) \\geq d_2 \\Rightarrow Pr[h(x)=h(y)] \\leq p_2$\n        \\item[r-way AND] $h(x)=h(y) \\iff \\forall i : h_i(x)=h_i(y)$\n            $(d_1,d_2,p_1^r,p_2^r)$ -- big r, more FN\n        \\item[b-way OR] $h(x)=h(y) \\iff \\exists i : h_i(x)=h_i(y)$\n            $(d_1,d_2,1-(1-p_1)^b,1-(1-p_2)^b)$ -- big b, more FP\n        \\item[AND-OR cascade] $(d_1,d_2,1-(1-p_1^r)^b,1-(1-p_2^r)^b)$\n        \\item[OR-AND cascade] $(d_1,d_2,(1-(1-p_1)^b)^r,(1-(1-p_2)^b)^r)$\n    \\end{description}\n\\subsection{Hash Functions}\n\\begin{description}\n    \\item[Euclidean distance] $h_{w,b}(x) =  \\lfloor (\\frac{w^Tx-b}{a}) \\rfloor$\nwhere $w \\leftarrow \\frac{w}{||w||_2}$, $w \\sim \\mathcal{N}(0,I)$, $w_i \\sim \\mathcal{N}(0,1)$, $b \\sim Unif([0,a])$, yields $(a/2,2a,1/2,1/3)$-sensitive\n    \\item[Cosine distance] $\\mathcal{H} = \\{ h(v) = \\text{sgn}(w^Tv) \\}$ where\n        $w \\sim \\text{Unif} \\{ x \\in \\mathbb{R}^n : ||x||_2 = 1 \\}$\n        $Pr(h_u(x) = h_v(y)) = 1 - \\Theta_{x, y}/\\pi$\n        $(\\Theta_1, \\Theta_2, 1-\\Theta_1 / \\pi, 1-\\Theta_2 / \\pi)$-sensitive\n\\end{description}\n\n\\section{Support Vector Machines}\n\\begin{description}\n    %\\item[Linear Classifier] $y = \\text{sign} \\left ( w^T x +b \\right )$. Train classifier $\\sim$ find $w$.\n    %Want: $y_i w^T x_i > 0~\\forall i$ for linearly separable data.\n    \\item[SVM] SVM = Max margin linear classifier\n    $\\min_{w, \\xi \\geq 0} \\frac{1}{2} w^T w + C \\sum_{i=1}^{n} \\xi_i \\text{ s. t. } y_i w^T x_i \\geq 1 - \\xi_i~\\forall i$\n    Support vectors (SV) are all data points on the margin and data points with non-zero slack\n        \\item[Regularized hinge loss formulation] $C = 1/\\lambda$\n            $\\min_w \\lambda w^T w + C \\sum_{i} \\max(0,1-y_i w^T x_i)$\n        \\item[Norm-constrained hinge loss minimization]\n            $ \\min_w \\sum_{i} \\max(0,1-y_iw^Tx_i)$ s.t. $||w||_2 \\leq \\frac{1}{\\sqrt{\\lambda}}$\n        \\item[Strongly convex formulation]\n            $ \\min_w \\frac{1}{T} \\sum_{t=1}^{T} \\left ( \\frac{\\lambda}{2} ||w||_2^2 + \\max(0,1-y_t w^T x_t) \\right )$\\\\ s.t. $ ||w||_2 \\leq \\frac{1}{\\sqrt{\\lambda}}$\\\\\n            $\\text{Proj}_S^{(2)}(w) = w \\cdot \\min\\left(1, \\frac{1/\\sqrt{\\lambda}}{||w||}\\right)$\\\\\n            $\\text{Proj}_S^{(\\infty)}(w) = \\min\\left((1/\\sqrt{\\lambda}, \\ldots, 1/\\sqrt{\\lambda})^T, w\\right) \\cdot \\text{sgn}(w)$\n    \\end{description}\n    \\textbf{Small $C$, Big $\\lambda$:} Greater margin, more misclassification\n\n\\subsection{Kernels}\n\\begin{description}\n    \\item[Dual SVM Formulation]\n    $\\max_{\\alpha} \\sum_{i=1}^{n} \\alpha_i - \\frac{1}{2} \\sum_{i,j} \\alpha_i \\alpha_j y_i y_j x_i^T x_j$\\\\ s.t. $ 0 \\leq \\alpha_i \\leq C$\\\\\n    $\\Rightarrow$ optimal w: $ w^{\\ast} = \\sum_{i} \\alpha_i^{\\ast} y_i x_i = \\sum_{i \\in \\text{SV}} \\alpha_i^{\\ast} y_i x_i $\n\\item[Kernel trick] Substitute inner product $x_{i}^T x_{j}$ in dual formulation and in classification function with $k(x_{i}, x_{j}) = \\phi(x_{i})^T \\phi(x_{j})$, where $\\phi(\\cdot): \\mathbb{R}^d \\to \\mathbb{R}^{>d}$\n    \\item[Kernel functions] A kernel is function $k: X \\times X \\rightarrow \\mathbb{R}$:\n        \\begin{enumerate}\n            \\item Symmetry: $\\forall x,x' \\in X : k(x,x') = k(x',x)$\n            \\item PSD: $\\forall n \\in \\mathbb{N}$, any set $S = \\{x_1,..,x_n\\} \\subseteq X$, the Gram matrix is PSD.\n        \\end{enumerate}\n    \\end{description}\n\n\\subsubsection{Random Features (Inverse Kernel Trick)}\n% $$x \\in \\mathbb{R}^d \\overset{\\text{kernel trick}}{\\rightarrow} \\Phi(x) \\in \\mathbb{R}^D \\overset{\\text{Inverse Kernel Trick}}{\\rightarrow} z(x) \\in \\mathbb{R}^m$$ where $d << D$,$m<<D$,$m>d$.\n\\begin{description}\n    \\item[Shift-invariant kernel] $k(x,y) = k'(x-y)$. Then the kernel has Fourier transform, such that:\n    $$ k(x-y) = \\int_{\\mathbb{R}^d} p(w) \\cdot e^{i w^T (x-y)} dw $$\n    where $p(w)$ is the Fourier transformation, i.e. we map $k(s)$ to another function $p(w)$.\n    \\item[Random fourier features (prerequisites)] Interpret kernel as expectation\n    $ k(x-y) = $\n    $$\\int_{\\mathbb{R}^d} p(w) \\cdot \\underbrace{e^{i w^T (x-y)}}_{g(w)} dw = \\mathbb{E}_{w,b} \\left [ z_{w,b} (x) z_{w,b} (y) \\right ]$$\n    where $z_{w,b}(x) = \\sqrt{2} \\cos \\left (w^T x +b \\right )$,\\\\\n    $b \\sim U([0,2 \\pi])$, $w \\sim p(w)$\n\n\\item[Random fourier features] \\textbf{(kernel approximation)}\\\\\n    \\begin{enumerate}\n        \\item $w_i \\sim p, b_i \\sim U([0, 2\\pi])$ for $i = 1, \\ldots, m;$ iid\n        \\item $z(x) = [z_{w_1,b_1}(x),...,z_{w_m,b_m}(x)]/\\sqrt{m}$\n        \\item $z(x)^T z(y) = \\frac{1}{m} \\sum_{i=1}^{m} z_{w_i,b_i} (x) \\cdot     z_{w_i,b_i} (y)$\n        \\item If $m \\rightarrow \\infty$, then (almost surely) $z(x)^T z(y)     \\rightarrow  \\mathbb{E}_{w,b} ( z_{w,b}(x) \\cdot z_{w,b} (y) ) = k(x-y)$\n    \\end{enumerate}\n\\end{description}\n\n\\section{Online Convex Programming}\n\\begin{description}[leftmargin=*]\n    \\item[Regret] $R_T = (\\sum_{t=1}^{T} f_t(w_t)) - \\min_{w \\in S} \\sum_{t=1}^{T} f_t(w)$\n    \\item[No-regret] $\\lim_{T \\rightarrow \\infty}\\frac{R_T}{T} \\rightarrow 0$\n    \\item[Online convex programming (OCP)] \n        If $y_t w_t^Tx_t < 1:$\n        $w_{t+1} = \\text{Proj}_S( w_t - \\eta_t \\nabla f_t(w_t))$\\\\\n        $\\text{Proj}_S(w) = \\text{arg}\\min_{w' \\in S} ||w' - w ||_2 = \\min \\left(w, \\frac{w}{\\lambda||w||_2}\\right)$\n    \\item[Regret for OCP] $$ \\frac{R_T}{T} \\leq \\frac{1}{\\sqrt{T}} [||w_0 - w^*||_2^2 + ||\\nabla f||_2^2] $$ where $||\\nabla f||_2^2 = \\sup_{w \\in S, t \\in \\{1,\\dots,T\\}} ||\\nabla f(w)||_2^2 $\n    \\item[Parallel stochastic gradient descent]\n    \\begin{enumerate}\n        \\item Split data into $k$ subsets, $k =$ number of machines, want $k = O(1/\\lambda)$\n        \\item Each machine produces $w_i$ on its subset\n        \\item After T iterations, compute $w = \\frac{1}{k} \\sum_{i = 1}^k w_i$\n    \\end{enumerate}\n    \\item[PEGASOS] Online SVM: H-sc. lossfn. Minibatch + reg\n\\end{description}\n\n\\section{Active Learning}\n\\begin{description}\n    \\item[Uncertainty sampling] Repeat until all labels inferred:\n    \\begin{enumerate}\n        \\item Assign uncertainty score $U_t(x)$ to each unlabeled data point:\n        $U_t(x) = U \\left ( x | x_{1:t-1},y_{1:t-1} \\right )$\n        \\item Greedily pick the most uncertain point and request label\n        $x_t = \\text{arg } \\max_x U_t(x)$ and retrain classifier\n    \\end{enumerate}\n    \\item For SVM: $U_t(x) = \\frac{1}{|w_{t-1}^T x|}$\n    \\item Cost to pick $m$ labels: $m \\cdot n \\cdot d + m \\cdot C(m)$\\\\\n        $n =$ number of data points, $d =$ dimensions,\\\\\n        $C(m) =$ cost to train classifier\n\n    \\item[Hashing a hyperplane query] Draw $u,v \\sim \\mathcal{N}(0,I)$. Then resulting two-bit hash is:\n    $$ h_{u,v}(a,b) = \\left [ \\text{ sign }(u^T a),\\text{ sign }(v^T b) \\right ]$$\n    Define the hash family:\n    $$\n    h_{\\mathcal{H}}(z) = \\begin{cases}\n        h_{u,v} (z,z) & \\text{if $z$ is a database point vector} \\\\\n        h_{u,v} (z,-z) & \\text{if $z$ is a query hyperplane vector}\n    \\end{cases}$$\n    \\item[Version space] Set of all classifiers consistent with the data:\n        $V(D) = \\{w : \\forall (x,y) \\in D : \\text{ sign}(w^T x) = y \\}$\n    \\item[Relevant version space] $\\hat{V}(D;U)$ describes all possible labelings $h$ of all unlabeled data $U$ that are still possible under some model $w$, or,\n    \\begin{align*}\n        \\hat{V}(D;U) &= \\{h: U \\rightarrow  \\{+1,-1\\}  : \\exists w  \\in V(D)\\\\\n        &\\forall x \\in U : \\text{sign}(w^T x) = h(x) \\}\n    \\end{align*}\n\\item[Generalized Binary Search] (GBS)\\\\\n    \\begin{algorithmic}[1]\n        \\State {Start with $D = \\emptyset$}\n        \\While {$|\\hat{V}(D;U)| > 1$}\n            \\ForEach {unlabeled example x in $U$}\n                \\State {$ v^+(x) = |\\hat{V}(D \\cup \\{(x,+)\\}; U)|$}\n                \\State {$ v^-(x) = |\\hat{V}(D \\cup \\{(x,-)\\}; U)|$}\n                \\State \\Comment number of labelings left if $x$ is $-$/$+$\n            \\EndFor\n            \\State {Pick $x^{\\ast} = \\text{arg}\\min_{x} \\max(v^-(x),v^+(x))$}\n            \\State $D = D \\cup \\{x^\\ast\\}$\n        \\EndWhile\n    \\end{algorithmic}\n\\item[Decision rules] for GBS SVM, $m \\sim$ margin $\\sim \\frac{1}{||w||}$\\\\\n    \\begin{description}\n        \\item[Max-min margin] $\\max_x \\min \\left( m^+(x),m^-(x) \\right)$\n        \\item[Ratio margin] $\\max_x \\min \\left (\\frac{m^+(x)}{m^-(x)},\\frac{m^-(x)}{m^+(x)} \\right)$\n    \\end{description}\n\\end{description}\n\n\\section{Clustering}\n\\subsection{K-Means}\n\\begin{description}\n    \\item[Cost Function] $L(\\mu) = L(\\mu_1,....,\\mu_k) =$\\vspace{-0.5em}\n        $$\\vspace{-0.5em}\\sum_{i=1}^N \\underbrace{\\min_{j \\in \\{1,\\dots,k\\}} ||x_i- \\mu_j ||_2^2}_{d(\\mu, x_{i})}$$\n    \\item[Objective] $\\mu^*  = \\text{arg } \\min_{\\mu} L(\\mu)$\n    \\item[Algorithm] Until convergence:\\\\\n        \\begin{algorithmic}[1]\n        \\State {Assign each point $x_{i}$ to closest center\n            $$z_i \\leftarrow \\text{arg } \\min_{j \\in \\{1,\\dots,l\\}} ||x_{i} - \\mu_{j}^{(t-1)}||_2^2$$}\n        \\State {Update center as mean of assigned data points\n            $$\\mu_j^{(t)} \\leftarrow \\frac{1}{n_j} \\sum_{i: z_i = j} x_i$$}\n    \\end{algorithmic}\n\n    \\item[Online k-means algorithm]\n        $$\\frac{\\textbf{d} \\text{d}(\\mu, x_t)}{\\textbf{d} \\mu_j} =\n        \\begin{cases}\n            0 & \\text{if }  j \\notin \\text{arg} \\min_i ||\\mu_i-x_t||^2 \\\\\n            2(u_j-x_t) & \\text{else}\n        \\end{cases}$$\n    \\begin{enumerate}[leftmargin=*]\n         \\item Initialize centers randomly\n         \\item For $t=1:N$\n            \\begin{itemize}\n                \\item Find $c = \\text{arg } \\min ||\\mu_j - x_t ||_2$\n                \\item $\\mu_c = \\mu_c + \\eta_t (x_t - \\mu_c)$\n            \\end{itemize}\n        \\item For convergence:\n        $ \\sum_t \\eta_t = \\infty$ and $\\sum_t \\eta_t^2 < \\infty$, e.g. $\\eta_t = \\frac{c}{t}$.\n     \\end{enumerate}\n\\end{description}\n\n\\subsection{Coresets}\n\\begin{description}\n    \\item[Idea] Replace many points by one weighted point\n    $ L_k(u;C) = \\sum_{(w,x) \\in C} w \\cdot \\min_j || u_j - x ||_2^2$\n    \\item[$(k,\\epsilon)$-coreset] $C$ is called a $(k,\\epsilon)$-coreset for $D$, if for all $\\mu$:\n    $(1-\\epsilon) L_k(\\mu;D) \\leq L_k(\\mu;C) \\leq (1+\\epsilon) L_k(\\mu;D)$\n\\item[Operations]\\textbf{Merge}: union of two $(k,\\epsilon)$-csets is a $(k, \\epsilon)$-cset\\\\\n    \\textbf{Compress}: $(k,\\delta)$-cset of a $(k, \\epsilon)$-cset of $D$ is a $(k, \\epsilon + \\delta + \\epsilon\\delta)$-cset of $D$\n\\item[Construction]\n    \\textbf{$D^2$-sampling}: iteratively build $B = \\emptyset$ by sampling $\\propto \\frac{\\text{d}(x, B)^2}{\\sum_{x' \\in X} \\text{d}(x', B)^2}$\\\\\n    \\textbf{Importance sampling}: $\\propto \\frac{\\alpha \\text{d}(x, B)^2}{c_\\Phi} + \\frac{2\\alpha\\sum_{x' \\in B_x} \\text{d}(x', B)^2}{|B_x|c_\\Phi} + \\frac{4|X|}{|B_x|}$\n        where $c_\\Phi = \\frac{1}{|X|}\\sum_{x \\in X}\\text{d}(x, B)^2$\\\\\n        $B_x = $ pts in $X$ that belong to same cluster as $x$\n\\end{description}\n\n\\section{Bandits}\n\\begin{description}\n    \\item[Regret] $R_T = \\sum_{t=1}^T (\\mu^* - \\mu_{i_t})$, $i_t$ chosen arm at time $t$\n    \\item[$\\epsilon$-greedy] The algorithm goes as follows:\n    \\begin{enumerate}\n        \\item Set $\\epsilon_t = \\mathcal{O}(\\frac{1}{t})$\n        \\item With probability $\\epsilon_t$: explore by picking uniformly at random\n        \\item With probability $1 - \\epsilon_t$: exploit by picking arm with highest empirical mean\n    \\end{enumerate}\n    Regret: $R_T = \\mathcal{O}(k \\log(T))$\n\\end{description}\n\\subsection{UCB1 \\& LinUCB}\n\\begin{description}\n    \\item[Hoeffding's inequality] $\\Pr(|\\mu - \\frac{1}{m} \\sum_{t=1}^m X_t | \\geq b) \\leq 2 \\cdot \\exp(-2b^2m)$\n    \\item[Confidence bound] Want: Hoeffding $\\leq \\delta$\n        $\\Rightarrow b = \\sqrt{\\frac{1}{2m}\\ln\\frac{2}{\\delta}}$\n    \\item[UCB/Mean update]\n    $UCB(i) = \\hat{\\mu_i}+ \\sqrt{\\frac{2 \\ln t}{\\eta_i}}$\n        $j = \\text{arg}\\max_i UCB(i)$\\\\\n    $\\hat{\\mu_j} = \\hat{\\mu_j} + \\frac{1}{\\eta_j} (y_t - \\hat{u}_j)$\n    \\item[Contextual bandits] Reward is now $y_t = f(x_t,z_t) + \\epsilon_t$ with $z_t$ user features. For us: $f(x_i,z_t) = w^T_{x_i}z_t$\n    \\item[LinUCB (disjoint)] Ridge regression on $z_t$:\n        $\\hat{w}_i = (D_i^TD_i + I)^{-1}D_i^Ty_i$.\\\\\n        $|\\hat{w}_i^Tz_t - w_i^Tz_t| \\leq \\alpha \\sqrt{z_t^T(D_i^TD_i)^{-1}z_t}$ with\n        probability $1-\\delta$ if $\\alpha = 1 + \\sqrt{\\log(2/\\delta)/2}$\\\\\n        $R_T/T = O(d \\cdot d' \\cdot \\text{poly}\\log T / \\sqrt{T})$\n    \\item[Hybrid model] Reward is now $y_t = w^T_{x_t} z_t + \\beta^T \\phi(x_t,z_t) + \\epsilon_t$\n    \\item[Rejection sampling] First obtain data log through pure exploration, and then reiterate:\n    \\begin{enumerate}\n        \\item Get event $(x_t^{(1)},..,x_t^{(k)},z_t,a_t,y_t)$ from log\n        \\item Use algorithm that is testing to pick $a_t'$:\n        \\begin{itemize}\n            \\item If $a_t'  = a_t$\n            $\\Rightarrow$ Feed back reward $y_t$\n            \\item Else ignore log line\n        \\end{itemize}\n        \\item Stop when T rewards have been fed back\n    \\end{enumerate}\n\\end{description}\n\n\\subsection{Submodular Functions}\n\\begin{description}\n    \\item[Submodularity] A function $F: 2^V \\mapsto \\mathbb{R}$ is called submodular iff for all $A \\subseteq B, s \\notin B$:\n        $$F(A \\cup \\{s\\}) - F(A) \\geq F(B \\cup \\{s\\}) - F(B)$$\n    \\item[Monotonic] if $S \\subseteq T \\Rightarrow F(S) \\leq F(T)$\n    \\item[Union-intersection def.] Same preconditions as above: $$F(A) - F(A\\cap B) \\geq F(A\\cup B) - F(B)$$\n    \\item[Closure properties] $F, F_i$ submodular on $V$; $S, W \\subseteq V$\n    \\begin{description}\n        \\item[Linear] \\textbf{Combinations}\\\\ $F'(S) = \\sum_{i} \\lambda_i F_i(S)$, $\\lambda_i \\geq 0$\n        \\item[Restriction] $F'(S) = F(S \\cap W)$\n        \\item[Conditiong] $F'(S) = F(S \\cup W)$\n        \\item[Reflection] $F'(S) = F(V \\setminus S)$\n        \\item[Monotonic truncation] $F$ also monotonic, $F'(S) = \\min(c, F(S)), c \\in \\mathbb{R}$\n    \\end{description}\n    \\item[Min/Max] For $F_{1,2}(A)$, $\\max \\{F_1(A),F_2(A) \\}$ or $\\min \\{F_1(A),F_2(A) \\}$ \\textbf{not} submodular in general.\n    \\item[Concavity]\n    $F(A) = g(|A|)$ where $g: \\mathbb{N} \\mapsto \\mathbb{R}$, then $F$ submodular iff $g$ concave.\n\\item[Lazy Greedy] Optimizing submodular \\textbf{monotonic} functions: $\\Delta(s|A_i) \\geq \\Delta(s|A_{i+1})$.\n    \\begin{algorithmic}[1]\n    \\State {$A_0 = \\emptyset$.\n        Keep ordered list of marginal benefits $\\Delta_s$ from previous iterations $j < i$, for all $s \\in \\mathcal{S}$, set of articles}\n        \\For {$i = 1 \\ldots k:$}\n            \\State $s$ is the article for which $\\Delta_s$ is at the top\n            \\State {Update: $\\Delta_s = F(A_{i-1} \\cup \\{s\\}) - F(A_{i-1})$}\n            \\If {$\\Delta_s$ is not top element anymore}\n            \\State{re-sort the list, goto 3}\n            \\EndIf\n            \\State {$A_i = A_{i-1} \\cup \\{s\\}$}\n        \\EndFor\n\\end{algorithmic}\n\\end{description}\n\n\\end{multicols}\n\\end{document}\n", "meta": {"hexsha": "8ad9477ebfa7fabee1c7d6a2bb3d012ad57fe778", "size": 20956, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cheatsheet.tex", "max_stars_repo_name": "oskopek/dm-cheatsheet", "max_stars_repo_head_hexsha": "9fcc5864bf2d22c4f540664363baee0cd3e20d36", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-03-04T23:50:15.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-19T15:16:13.000Z", "max_issues_repo_path": "cheatsheet/cheatsheet.tex", "max_issues_repo_name": "oskopek/dm", "max_issues_repo_head_hexsha": "a895a97b52052d04f7451ca3dba4205d02d18fc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cheatsheet/cheatsheet.tex", "max_forks_repo_name": "oskopek/dm", "max_forks_repo_head_hexsha": "a895a97b52052d04f7451ca3dba4205d02d18fc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.6157635468, "max_line_length": 217, "alphanum_fraction": 0.5800248139, "num_tokens": 7850, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7853085758631158, "lm_q1q2_score": 0.41410618800429727}}
{"text": "% ~~~ [ Control Flow Analysis ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\subsubsection{Control Flow Analysis}\n\\label{sec:lit_review_control_flow_analysis}\n\nThe control flow analysis stage is responsible for analysing the control flow (i.e. flow of execution) of source programs to recover their high-level control flow structures. The control flow of a given function is determined by its branching instructions and may be expressed as a control flow graph (CFG), which is a connected graph with a single entry node (the function entry point) and zero or more exit nodes (the function return statements). A key insight provided by C. Cifuentes and S. Moll is that high-level control flow primitives (such as 1-way conditionals and pre-test loops) may be expressed using graph representations~\\cite{reverse_comp, decomp_of_llvm}, as illustrated in figure~\\ref{fig:graph_representations}. The problem of recovering high-level control flow primitives from CFGs may therefore be reformulated as the problem of identifying subgraphs (i.e. the graph representation of a high-level control flow primitive) in graphs (i.e. the CFG of a function) without considering node names. This problem is commonly referred to as \\textit{subgraph isomorphism search}, the general problem of which is NP-hard~\\cite{subgraph_isomorphism_algorithms}. However, the problem which is required to be solved by the control flow analysis stage may be simplified by exploiting known properties of CFGs (e.g. connected graph with a single entry node).\n\n\\begin{figure}[htbp]\n\t\\centering\n\t% if\n\t\\begin{subfigure}[ht]{0.23\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.45\\textwidth}\n\t\t\t\\lstinputlisting[language=go, style=go, breaklines=false, numbers=none]{inc/primitives/if.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.42\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/if.png}\n\t\t\\end{subfigure}\n\t\t\\caption{1-way conditional; entry: \\texttt{A}, exit: \\texttt{C}.}\n\t\t\\label{fig:if_graph_representation}\n\t\\end{subfigure}\n\t\\qquad\n\t% if_else\n\t\\begin{subfigure}[ht]{0.28\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.45\\textwidth}\n\t\t\t\\lstinputlisting[language=go, style=go, breaklines=false, numbers=none]{inc/primitives/if_else.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.50\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/if_else.png}\n\t\t\\end{subfigure}\n\t\t\\caption{2-way conditional; entry: \\texttt{A}, exit: \\texttt{D}.}\n\t\t\\label{fig:if_else_graph_representation}\n\t\\end{subfigure}\n\t\\qquad\n\t% if_return\n\t\\begin{subfigure}[ht]{0.30\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.45\\textwidth}\n\t\t\t\\lstinputlisting[language=go, style=go, breaklines=false, numbers=none]{inc/primitives/if_return.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.50\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/if_return.png}\n\t\t\\end{subfigure}\n\t\t\\caption{1-way condition with return statement in body; entry: \\texttt{A}, exit: \\texttt{C}.}\n\t\t\\label{fig:if_return_graph_representation}\n\t\\end{subfigure}\n\t\\qquad\n\t% pre_loop\n\t\\begin{subfigure}[ht]{0.32\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.45\\textwidth}\n\t\t\t\\lstinputlisting[language=C, style=go, breaklines=false, numbers=none]{inc/primitives/pre_loop.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.50\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/pre_loop.png}\n\t\t\\end{subfigure}\n\t\t\\caption{pre-test loop; entry: \\texttt{A}, exit: \\texttt{C}.}\n\t\t\\label{fig:pre_loop_graph_representation}\n\t\\end{subfigure}\n\t\\qquad\n\t% post_loop\n\t\\begin{subfigure}[ht]{0.30\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.50\\textwidth}\n\t\t\t\\lstinputlisting[language=C, style=go, breaklines=false, numbers=none]{inc/primitives/post_loop.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.35\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/post_loop.png}\n\t\t\\end{subfigure}\n\t\t\\caption{post-test loop; entry: \\texttt{A}, exit: \\texttt{B}.}\n\t\t\\label{fig:post_loop_graph_representation}\n\t\\end{subfigure}\n\t\\qquad\n\t% seq\n\t\\begin{subfigure}[ht]{0.24\\textwidth}\n\t\t\\centering\n\t\t\\begin{subfigure}[ht]{0.20\\textwidth}\n\t\t\t\\lstinputlisting[language=C, style=go, breaklines=false, numbers=none]{inc/primitives/seq.c}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}[ht]{0.35\\textwidth}\n\t\t\t\\includegraphics[width=\\textwidth]{inc/primitives/seq.png}\n\t\t\\end{subfigure}\n\t\t\\caption{consecutive statements; entry: \\texttt{A}, exit: \\texttt{B}.}\n\t\t\\label{fig:seq_graph_representation}\n\t\\end{subfigure}\n\t\\caption{The pseudo-code and graph representation of various high-level control flow primitives with denoted entry and exit nodes.}\n\t\\label{fig:graph_representations}\n\\end{figure}\n\nWhen the subgraph isomorphism of a high-level control flow primitive has been identified in the CFG of a function, it may be replaced by a single node that inherits the predecessors of the subgraph entry node and the successors of the subgraph exit node; as illustrated in figure~\\ref{fig:subgraph_merge}. By recording the node names of the identified subgraphs and the name of their corresponding high-level control flow primitives, the high-level control flow structure of a CFG may be recovered by successively identifying subgraph isomorphisms and replacing them with single nodes until the entire CFG has been reduced into a single node; as demonstrated by the step-by-step simplification of a CFG in appendix~\\ref{app:control_flow_analysis_example}. Should the control flow analysis fail to reduce a CFG into a single node, the CFG is considered irreducible with regards to the supported high-level control flow primitives (see figure~\\ref{fig:graph_representations}). To structure arbitrary irreducible graphs, S. Moll applied node splitting (which translates irreducible graphs into reducible graphs by duplicating nodes) to produce functionally equivalent target programs~\\cite{decomp_of_llvm}. In contrast, C. Cifuentes focused on preserving the structural semantics of the source program (which may be required in forensics investigations), and therefore used \\texttt{goto}-statements in these cases to produce unstructured target programs.\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\begin{subfigure}[ht]{0.15\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{inc/2_lit_review/cfg_pre_merge.png}\n\t\\end{subfigure}\n\t\\qquad\n\t\\begin{subfigure}[ht]{0.15\\textwidth}\n\t\t\\includegraphics[width=\\textwidth]{inc/2_lit_review/cfg_post_merge.png}\n\t\\end{subfigure}\n\t\\caption{The left side illustrates the CFG of a function in which the graph representation of a 1-way conditional (see figure~\\ref{fig:if_graph_representation}) has been identified, and the right side illustrates the same CFG after the subgraph has been replaced with a single node (i.e. \\texttt{if0}) that inherits the predecessors of the subgraph entry node (i.e. \\texttt{3}) and the successors of the subgraph exit node (i.e. \\texttt{list0}).}\n\t\\label{fig:subgraph_merge}\n\\end{figure}\n", "meta": {"hexsha": "b7ed36fbed1b608b8b6828349c971182b67c55e6", "size": 6880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/compositional_decompilation/sections/2_literature_review/2_decompilation_phases/3_control_flow_analysis.tex", "max_stars_repo_name": "decomp/doc", "max_stars_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-05-27T10:16:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-16T08:14:04.000Z", "max_issues_repo_path": "report/compositional_decompilation/sections/2_literature_review/2_decompilation_phases/3_control_flow_analysis.tex", "max_issues_repo_name": "decomp/doc", "max_issues_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 48, "max_issues_repo_issues_event_min_datetime": "2019-01-30T19:08:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-29T19:17:53.000Z", "max_forks_repo_path": "report/compositional_decompilation/sections/2_literature_review/2_decompilation_phases/3_control_flow_analysis.tex", "max_forks_repo_name": "decomp/doc", "max_forks_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-25T21:15:26.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-09T07:36:14.000Z", "avg_line_length": 65.5238095238, "max_line_length": 1451, "alphanum_fraction": 0.7699127907, "num_tokens": 1945, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.41406365596689865}}
{"text": "%!TEX root = ../notes.tex\n\\section{April 18, 2022}\n\\subsection{Midterm 2 Review}\n\\begin{itemize}\n    \\item Apologies for poor communication.\n    \\item Feedback is welcome---will send out form.\n\\end{itemize}\n\\emph{Average:} 28/40.\n\n``A-level work'' would equate to doing around 3 problems, \\\\\n``B-level work'' would equate to doing around 2 problems, and \\\\\n``C-level work'' would equate to doing around 1 problem.\n\n\n\\begin{problem}\n\\emph{About 3/4 solved.}\n\n\\ul{Idea}: exploit something special about $n$ being a Carmichael number. That is that $a^{N-1}\\equiv 1\\pmod{N}$. We can do something inspired by the Miller-Rabin test. We then have\n\\[\\left( a^{\\frac{N-1}{2}}\\equiv 1\\pmod{N} \\right)\\]\nIf $a^{\\frac{N-1}{2}}\\equiv 1$, then we decrement the exponent by a factor of two. We then check\n\\[\\left( a^{\\frac{N-1}{4}}\\equiv 1\\pmod{N} \\right)\\]\nand so on. Eventually, we'll find a nontrivial square root of $1$. This produces a factorization, since\n\\begin{align*}\n    x^2        & \\equiv 1\\pmod{n} \\\\\n    (x-1)(x+1) & \\equiv 0\\pmod{n}\n\\end{align*}\nso $\\gcd(x\\pm 1, n)$ likely allows us to recover a factor of $N$. We run through this multiple times with different values of $a$.\n\\end{problem}\n\n\\begin{problem}\n\\emph{Hardest problem, 1/2 solved.}\n\n\\ul{Idea}: Implement some reasonably general-purpose factorization method:\n\\begin{enumerate}\n    \\item Lenstra's Elliptic Curve Factorization.\n    \\item Quadratic Sieve.\n    \\item Pollard $\\rho$ method.\n\\end{enumerate}\n\nThings that would not work:\n\\begin{enumerate}\n    \\item Trial division.\n    \\item Pollard $p-1$.\n\\end{enumerate}\n\nThe factorization was $15\\times 35$ digits, which gives a relatively equal runtime for Elliptic Curve and Quadratic Sieve.\n\\end{problem}\n\n\\begin{problem}\n\\emph{About 2/3 solved (generally speaking, lost 3 points on it).}\n\n\\ul{Idea}: solve DLP. Babystep-Giantstep, as in class, yields 7/10 due to excessive memory usage. 4 people solved this problem in a way that didn't use a shit-ton of RAM, with 3 distinct solutions.\n\n\\emph{How to solve DLP without using tons of RAM:}\n\\begin{enumerate}\n    \\item Babystep-Giantstep with fewer babysteps ($B$ babysteps). We need $B + \\frac{N}{B}$ time to solve this, which is minimized if $B\\equiv N^{0.5}$. We take a smaller $B\\equiv N^{0.3}$ or something, and our time would be $N^{0.7}$, still within the bounds.\n    \\item Index calculus. Time/Memory are asymptotically small compared to Babystep-Giantstep.\n    \\item Pollard $\\rho$ method \\emph{(discussion of which is in textbook)}. Gives runtime of $N^{0.5}$ with minimal memory usage.\n\\end{enumerate}\n\n\\end{problem}\n\n\\begin{problem}\n\\emph{This was a fairly easy problem.}\n\\end{problem}\n", "meta": {"hexsha": "adc076025c25810b204a9c1b2b8cbae2e43b8171", "size": 2658, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-04-18.tex", "max_stars_repo_name": "jchen/math1580-notes", "max_stars_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-14T15:03:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T15:03:38.000Z", "max_issues_repo_path": "lectures/2022-04-18.tex", "max_issues_repo_name": "jchen/math1580-notes", "max_issues_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-04-18.tex", "max_forks_repo_name": "jchen/math1580-notes", "max_forks_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2727272727, "max_line_length": 261, "alphanum_fraction": 0.7088036117, "num_tokens": 828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.41406365596689865}}
{"text": "\n\\subsection{Symplectic Tensors}\n\n\\exercisehead{22.1}\n\n{\\scriptsize{\\url{http://math.stackexchange.com/questions/342267/non-degenerate-bilinear-forms-and-invertible-matrices}}} (shout out to Branimir Cacic for the answer)  gave me a hint at how to approach this exercise, even though the original question was for symmetric bilinear forms.  \n\nLet $\\lbrace e_1 \\dots e_n \\rbrace$ be (some) basis of $V$ \\\\\nLet $\\lbrace f^1 \\dots f^n \\rbrace$ be dual basis of $V$ s.t. $f^i(e_j)=\\delta^i_{ \\,\\, j}$\n\nNow\n\\[\n\\begin{aligned}\n  & \\widehat{\\omega}(e_i) = (\\widehat{\\omega}(e_i))_jf^j \\\\\n  & \\widehat{\\omega}(e_i)e_j = (\\widehat{\\omega}(e_i))_j = i_{e_i}\\omega(e_j) = \\omega(e_i,e_j) \\equiv \\omega_{ij}\n\\end{aligned}\n\\]\nso $\\omega_{ij} = (\\widehat{\\omega}(e_i))_j$ (i.e. matrix $\\omega_{ij}$ is precisely $(\\widehat{\\omega}(e_i))_j$.  \n\nIf $\\omega_{ij}$ nonsingular, i.e. $\\exists \\, \\omega^{-1}_{ki}$ s.t. $\\omega^{-1}_{ki} \\omega_{ij} = \\omega_{ki}\\omega^{-1}_{kj} = \\delta_{kj}$ (by def.)\n\nIf $\\widehat{\\omega}$ invertible, $\\widehat{\\omega}^{-1} \\widehat{\\omega}(v) = v$\n\\[\n\\begin{gathered}\n  \\widehat{\\omega}^{-1}\\widehat{\\omega}(e_i) = \\widehat{\\omega}^{-1}(\\widehat{\\omega}(e_i))_j f^j = (\\widehat{\\omega}(e_i))_j \\widehat{\\omega}^{-1}(f^j) = (\\widehat{\\omega}(e_i))_j(\\widehat{\\omega}^{-1}(f^j))^k e_k = e_i \\\\\n\\Longrightarrow (\\widehat{\\omega}(e_i))_j(\\widehat{\\omega}^{-1}(f^j))^k = \\delta_i^{ \\, \\, k}\n\\end{gathered}\n\\]\nSo if $\\omega_{ij}$ nonsingular, $(\\widehat{\\omega}^{-1}(f^j))^k$ exists and $(\\widehat{\\omega}(f^j))^k = \\omega^{-1}_{jk}$ \\\\\n\\phantom{So } if $\\widehat{\\omega}$ invertible, $\\omega^{-1}_{jk}$ exists and is given by $\\omega^{-1}_{jk} = (\\widehat{\\omega}(f^j))^k$\n\n\nSo the (a) $\\Longleftrightarrow$(c) part of the exercise is done.  \n\nShow (a) $\\Longleftrightarrow$(b) and we're done.\n\nIf $\\widehat{\\omega}:V\\to V^*$ linear isomorphism,  \n\\[\n\\text{ker}\\widehat{\\omega}=0\n\\]\n\nSuppose $\\nexists \\, w \\in V$ s.t. $\\omega(v,w)\\neq 0$ (proof by contradiction strategy) \\\\\nThen $\\forall \\, w \\in V$, $\\omega(v,w) =0$  \\\\\n$\\omega(v,w) = 0 = \\widehat{\\omega}(v)(w) \\quad \\, \\forall \\, w \\in V$.  \\\\\nThen $v=0$.  Contradiction.  \n\n(b) $\\Longrightarrow $ (a): if $\\forall \\, v \\neq 0$, $\\exists \\, w \\in V$ s.t. $\\omega(v,w) \\neq 0$ \\\\\nthen if $\\forall \\, w \\in V$, $\\omega(v,w) =0$, then $v=0$ \\\\\n$\\omega(v,w) = \\widehat{\\omega}(v)(w) = 0$ implies $v=0$, $\\forall \\, w \\in V$.  \\\\\nThen $\\text{ker}\\widehat{\\omega}=0$.  So $\\widehat{\\omega}$ linear isomorphism.  So $\\omega$ nondegenerate.  \n\n\\exercisehead{22.4} There was a proof of this in Konstantin Athanassopoulos, \\textbf{Notes on Symplectic Geometry}, Iraklion, 2013\n\\url{http://www.math.uoc.gr/~athanako/symplectic.pdf}\n\nRecall that \\\\\n$S^{\\perp} = \\lbrace v \\in V | \\omega(v,w) =0 \\quad \\, \\forall \\, w \\in S \\rbrace$ \\\\\n$(S^{\\perp})^{\\perp} = \\lbrace u \\in V | \\omega(u,v)=0 \\quad \\, \\forall \\, v \\in S^{\\perp}\\rbrace$\n\nLet $s\\in S$.  $\\omega(s,v)=0 \\quad \\, \\forall \\, v \\in S^{\\perp}$, by def. of $S^{\\perp}$ \\\\\n$\\begin{aligned} & \\quad \\\\\n  & s\\in (S^{\\perp})^{\\perp} \\\\ \n  \\Longrightarrow & S \\subseteq (S^{\\perp})^{\\perp} \\end{aligned}$\n\nThen $\\text{dim}S \\leq \\text{dim}(S^{\\perp})^{\\perp}$ with equality iff $S= (S^{\\perp})^{\\perp}$\n\nNow by Lemma 22.3, \\\\\n$\\text{dim}S + \\text{dim}S^{\\perp} = \\text{dim}V$, $\\forall \\, $ linear subspace $S\\subseteq V$ \\\\\n$\\text{dim}S^{\\perp} + \\text{dim}(S^{\\perp})^{\\perp} = \\text{dim}V = \\text{dim}S + \\text{dim}S^{\\perp} \\Longrightarrow \\text{dim}S = \\text{dim}(S^{\\perp})^{\\perp}$ \\\\\n \n$\\text{dim}S \\leq \\text{dim} (S^{\\perp})^{\\perp}$ with equality iff $S= (S^{\\perp})^{\\perp}$\n\n\n\n\n\\subsection{Symplectic Structures on Manifolds}\n\n\\exercisehead{22.10} $F:N\\to M$ smooth immersion.  Recall definition: $F_*$ injective.  Recall Appendix B, Exercise B.22 (EY: 20150512 This exercise is \\textbf{very useful}; I can't emphasize that enough).  $F_*$ injective so $\\text{rank}F_* = \\text{dim}N$. (implying $\\text{ker}F_*=0$).  \n\nRecall that $F$ isotropic if \\\\\n\n$(F_*)_p(T_pN) \\subseteq T_{F(p)}M$ isotropic, i.e. \n\n\\[\n(F_*)_p(T_pN) \\subseteq ((F_*)_p(T_pN))^{\\perp}\n\\]\n\nConsider $X,Y \\in T_pN$, with $X,Y$ nonzero.  Then, as $F_*$ injective, $Z,W \\in ((F_*)_p(T_pN))$ nonzero, for $\\begin{aligned}\n& \\quad \\\\\n  & Z = (F_*)_pX \\\\\n  & W = (F_*)_pY \\end{aligned}$\n\nSuppose $\\omega(Z,W)=0$, $\\forall \\, W \\in (F_*)_p(T_pN)$.  $Z \\in ((F_*)_p(T_pN))^{\\perp}$.  \n\n\\[\n\\omega(Z,W) = \\omega((F_*)_pX, (F_*)_pY) = (F^*)_p\\omega(X,Y)=0\n\\]\n\nIf $F$ isotropic, then this is the case $\\forall \\, Z \\in ((F_*)_p(T_pN)) \\subseteq ((F_*)_p(T_pN))^{\\perp}$.  \n\nThen since $(F^*)_p\\omega(X,Y)=0$ \\, $\\forall \\, p \\in N$, $\\forall \\, X,Y \\in T_pN$, then $F^*\\omega=0$.  \n\nIf $F$ symplectic, $(F_*)_p(T_pN) \\cap ((F_*)_p(T_pN))^{\\perp}=0$\n\nLikewise, for the reverse.  \n\nIf $F$ symplectic, \n\n\\[\n(F_*)_p(T_pN) \\cap ((F_*)_p(T_pN))^{\\perp}=0\n\\]\nFor $ X,Y \\in T_pN$, suppose\n\n\\[\nF_p^*\\omega(X,Y) = \\omega((F_*)_pX, (F_*)_pY) =0 \n\\]\n\nThis implies $(F_*)_pX \\in (F_*)_p(T_pN) \\cap ((F_*)_p(T_pN))^{\\perp}$\n\nThen \n\nsince $F_*$ immersion, $X,Y=0$.  So $F^*\\omega$ is nondegenerate and so is a symplectic form.  \n\n\n\\subsubsection{the Canonical Symplectic Form on the Cotangent Bundle}\n\n\\begin{quote}\nThe most important symplectic manifolds are total spaces of cotangent bundles, which carry canonical symplectic structures that we now define.\n\\end{quote}\n\n\n\\subsection{The Darboux Theorem}\n\n\\subsection{Hamiltonian Vector Fields}\n\n\\textbf{Hamiltonian vector field} of $f$\n\\[\nX_f = \\widehat{\\omega}^{-1}(df)\n\\]\n\nHamiltonian vector field of $f$ in Darboux coordinates:\n\\begin{equation}\n  X_f = \\sum_{i=1}^n \\left( \\frac{ \\partial f}{ \\partial y^i} \\frac{ \\partial }{ \\partial x^i } - \\frac{ \\partial f}{ \\partial x^i} \\frac{\\partial}{ \\partial y^i} \\right)\n\\end{equation}\n(22.9)\n\n\n\nsmooth $X \\in \\mathfrak{X}(M)$ \\textbf{symplectic} if $\\omega$ invariant under flow of $X$, i.e. $\\mathcal{L}_X \\omega =0$\n\n\n\\subsubsection{Poisson Brackets}\n\n$f \\in C^{\\infty}(M)$ \\textbf{conserved quantity} if $f$ constant on every integral curve of $X_H$.  \n\nsmooth $V \\in \\mathfrak{X}(M)$ \\textbf{infinitesimal symmetry} of $(M,\\omega,H)$ if $\\omega,H$ invariant under flow of $V$, i.e. EY (20150521) \n\\[\n\\begin{aligned}\n  & \\mathcal{L}_V \\omega = 0\n  & \\mathcal{L}_V H = 0\n\\end{aligned}\n\\]\n\n\\begin{proposition}[22.21]\nLet $(M,\\omega,H)$ Hamiltonian system\n\\begin{enumerate}\n\\item[(a)] $f \\in C^{\\infty}(M)$ conserved quantity iff $\\lbrace f,H\\brace =0$\n\\item[(b)] infinitesimal symmetries of $(M, \\omega,H)$ are precisely symplectic fields $V$ s.t. $VH=0$ \n\\item[(c)] if $\\theta$ flow of infinitesimal symmetry and $\\gamma$ trajectory of system\n\\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\nThis is the solution to Problem 22-18.  \n\n\\begin{enumerate}\n\\item[(a)] if $f\\in C^{\\infty}(M)$ conserved quantity, by def. $f$ constant on every integral curve of $X_H$\n\\[\n\\lbrace f,H\\rbrace = \\frac{ \\partial f}{ \\partial x^i} \\frac{ \\partial H}{ \\partial y^i} - \\frac{ \\partial f}{ \\partial y^i} \\frac{ \\partial H}{ \\partial x^i} = X_H f = 0 \n\\]\nfor \n\\[\nX_H = \\frac{ \\partial H}{ \\partial y^i} \\frac{ \\partial }{ \\partial x^i} - \\frac{ \\partial H}{ \\partial x^i} \\frac{ \\partial }{ \\partial y^i} \n\\] \nlikewise, if $\\lbrace f,H \\rbrace =0$, then $X_Hf =0$, $X_Hf = \\mathcal{L}_{X_H} f= 0 $, so $f$ constant on flow of $X_H$\n\\item[(b)] Recall smooth $V \\in \\mathfrak{X}(M)$ infinitesimal symmetry of $(M,\\omega,H)$ if $\\omega, H$ invariant under flow of $V$, i.e. \n\\[\n\\begin{aligned}\n  & \\mathcal{L}_V \\omega =0 \n  &  \\mathcal{L}_VH = 0 \n\\end{aligned}\n\\]\nsmooth $V\\in \\mathfrak{X}(M)$ symplectic if $\\omega$ invariant under flow of $V$, i.e. $\\mathcal{L}_V\\omega =0$\n\\[\n\\mathcal{L}_VH = VH = 0\n\\]\n\\item[(c)] EY : 20150521 I'm not sure how to go about this because what is a trajectory?\n\n$\\gamma: I \\to M$\n\n$\\theta$ flow of an infinitesimal symmetry, so (collecting facts)\n\n\\[\n\\begin{aligned}\n  & \\mathcal{L}_{\\dot{\\theta}}\\omega = di_{\\dot{\\theta}}\\omega + i_{\\dot{\\theta}}d\\omega = di_{\\dot{\\theta}}\\omega \\quad \\, (\\omega \\text{ closed so } i_{\\dot{\\theta}}d\\omega) \\\\ \n  & \\dot{\\theta}H = 0 \n\\end{aligned}\n\\]\n\nNow $\\theta_s \\circ \\gamma : I \\to M$\n\n\\[\n\\frac{d}{dt}(\\theta_s \\circ \\gamma)(t) = (D\\theta_s)(\\gamma(t)) \\dot{\\gamma}(t) = V_{s,\\gamma(t)} \\dot{\\gamma}(t)\n\\]\n\\end{enumerate}\n\\end{proof}\n\n\\problemhead{22.1} \n\n\\begin{proof}\n\\begin{enumerate}\n  \\item[(a)] If $S$ symplectic, $S \\cap S^{\\perp} = 0$.  $S=(S^{\\perp})^{\\perp}$ so $(S^{\\perp})^{\\perp} \\cap S^{\\perp} =0$.  $S^{\\perp}$ symplectic.  \\\\\nIf $S^{\\perp}$ symplectic, $S^{\\perp} \\cap (S^{\\perp})^{\\perp} = 0$.  $S=(S^{\\perp})^{\\perp}$ so $(S^{\\perp})^{\\perp} =S \\cap S^{\\perp} =0$.  $S$ symplectic.  \\\\\n  \\item[(b)] Suppose for $s\\in S\\cap S^{\\perp}$, $s\\neq 0$.  Then as $s\\in S^{\\perp}$, $\\omega(s,w)=0 \\, \\forall \\, \\, w \\in S^{\\perp}$. \n\nThen $\\omega(s,s)=0$.  But $\\omega$ nondegenerate so $s=0$.  Contradiction.  \n\nSuppose $S$ symplectic.  For $\\left. \\omega \\right|_S(s,t) = \\omega(s,t)=0$, for some $s \\in S$, $\\forall \\, t \\in S$, then $S\\cap S^{\\perp}=0$ implies that $s,t=0$.  Then $\\left. \\omega \\right|_S$ nondegenerate.  \n\n\n  \\item[(c)] If $S$ isotropic, $S\\subseteq S^{\\perp}$ so that $\\omega(s,t)=0$ \\, $\\forall \\, t \\in S$ (def. of $S^{\\perp}$).  $\\left. \\omega \\right|_S =0$ as $\\omega(s,t)=0$, \\, $\\forall \\, s,t \\in S$.  \n\nIf $\\left. \\omega \\right|_S =0$, then $\\forall \\, s,t \\in S$, $\\omega(s,t)=0 \\, \\, \\forall \\, t\\in S$.  By def. of $S^{\\perp}$, $S\\subseteq S^{\\perp}$.  \n  \\item[(d)] if $S$ coisotropic, $S\\supseteq S^{\\perp}$.  $S^{\\perp} \\subseteq S=(S^{\\perp})^{\\perp}$.  Then $S^{\\perp}$ isotropic.  \n\nIf $S^{\\perp}$ isotropic, $S^{\\perp} \\subseteq (S^{\\perp})^{\\perp} = S$, so $S$ coisotropic.  \n  \\item[(e)] If $S$ Lagrangian, $\\forall \\, s \\in S$, $s\\in S^{\\perp}$, so that $\\omega(s,t) = 0$ \\, $\\forall \\, t \\in S$.  Then $\\left. \\omega \\right|_S =0$, (i.e. identically $0$).  \\\\\n\n$\\text{dim}S + \\text{dim}S^{\\perp} = 2\\text{dim}S = \\text{dim}V $ by Lemma 22.3, so $\\text{dim}S = \\frac{1}{2} \\text{dim}V$.  \n\nIf $\\text{dim}S = \\frac{1}{2} \\text{dim}V$, $\\text{dim}S^{\\perp} = \\frac{1}{2} \\text{dim}V = \\text{dim}S$.  $\\left. \\omega \\right|_S =0$, so $S$ isotropic, i.e. $S\\subseteq S^{\\perp}$.  $\\text{dim}S \\leq \\text{dim}S^{\\perp}$, with equality iff $S=S^{\\perp}$.  \n\\end{enumerate}\n\\end{proof}\n\n\n\n\\problemhead{22.-17} Given Hamiltonian system $(T^*Q, \\omega,E)$.  \n\nRecall that \n\\[\n\\begin{aligned}\n  q(t) & = (q_1^1(t),q_1^2(t), q_1^3(t) \\dots q^1_n(t),q_n^2(t),q_n^3(t))=0 \\\\\n  & = (q^1(t) \\dots q^{3n}(t))\n\\end{aligned}\n\\]\n\nNow $p(t) = (p_1^1,p_1^2,p_1^3\\dots p_n^1,p_n^2,p_n^3)$ and \\\\\n$p_i(t)=M_{ij}\\dot{q}^j(t)$ with \n\n$M_{ij}$ $3n \\times 3n$ diagonal matrix $(m_1,m_1,m_1,m_2,m_2,m_2 \\dots m_n, m_n, m_n)$\n\nNow $E \\in C^{\\infty}(T^*Q)$ where \n\\[\nE(q,p) = V(q) + K(p) = V(q) + \\frac{1}{2} M^{ij}p_i p_j\n\\]\n\n\\begin{enumerate}\n\\item[(a)] Let $\\mathbf{u} = (u^1,u^2,u^3)$ \n\n\\[\n\\begin{aligned}\n  & P : T^*Q \\to \\mathbb{R} \\\\ \n  & \\begin{aligned} P(q,p) & = \\mathbf{u}\\cdot \\mathbf{p}_1 + \\mathbf{u}\\cdot \\mathbf{p}_2 \\\\ \n      & = u^1p_1^1 + u^2p_1^2 + u^3 p_1^3 +u^1p_2^1 + u^2 p_2^2 + u^3 p_2^3 \\end{aligned}\n\\end{aligned}\n\\]\n\n Recall Prop. 22.21, Let $(M,\\omega, H)$ Hamiltonian system\n\\begin{enumerate}\n\\item[(a)] $f \\in C^{\\infty}(M)$ conserved quantity iff $\\lbrace f, H\\rbrace =0$\n\\end{enumerate}\n\nNow in Darboux coordinates,\n\\[\n\\lbrace f, g \\rbrace = \\sum_{i=1}^n \\frac{ \\partial f}{ \\partial x^i} \\frac{ \\partial g}{ \\partial y^i } - \\frac{ \\partial f}{ \\partial y^i } \\frac{ \\partial g}{ \\partial x^i}\n\\]\n(22.16)\n\nFor \n\\[\nE = V(|\\mathbf{q}_2 - \\mathbf{q}_1|) + \\frac{1}{2} M^{ij}p_ip_j\n\\]\n\nnote that \n\n\\[\n\\begin{aligned}\n  & V(| \\mathbf{q}_2 - \\mathbf{q}_1|) = V(r) \\text{ with } \\\\ \n  & r = \\sqrt{ (q_2^1 - q_1^1)^2 + \\dots + (q_2^3 - q_1^3)^2 } \\\\ \n  & \\frac{ \\partial V}{ \\partial q_i^j} = \\frac{ \\partial V}{ \\partial r} \\frac{1}{2} \\frac{1}{r}(2)(q_2^j - q_1^j)(-1)^i = \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} (q_2^j-q_1^j)(-1)^i\n\\end{aligned}\n\\]\n\n\n\nthen\n\\[\n\\begin{aligned}\n  & \\frac{ \\partial E}{ \\partial p_i^j} = \\frac{p_i^j}{m_i} \\\\ \n  & \\frac{ \\partial E}{ \\partial q_i^j} = \\frac{ \\partial V}{ \\partial r} \\frac{1}{r}(-1)^i (q_2^j-q_1^j)\n\\end{aligned}\n\\]\nwith $r = |\\mathbf{q}_2 - \\mathbf{q}_1| = \\sqrt{ (q_2^1- q_1^1)^2 + \\dots + (q_2^3- q_1^3)^2 }$\n\n\\[\nP = \\mathbf{u}\\cdot (\\mathbf{p}_1 + \\mathbf{p}_2) = u^i p^i_1 + u^i p_2^i\n\\]\n\\[\n\\begin{aligned}\n\\frac{ \\partial P}{ \\partial p_i^j} = u^j  \\\\ \n \\frac{ \\partial P}{ \\partial q }=  0\n\\end{aligned}\n\\]\n\n\\[\n\\lbrace P,E \\rbrace =0 - u^j \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} (-1)^i(q_2^j-q_1^j) = -\\mathbf{u}\\cdot(\\mathbf{q}_2-\\mathbf{q}_1) \\frac{ \\partial V}{ \\partial r} \\frac{1}{r}(-1) + -\\mathbf{u}\\cdot (\\mathbf{q}_2-\\mathbf{q}_1) \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} = 0 \n\\]\n\n\\item[(b)] \n\\[\nL(q,p) = q_1^1 p_1^2 - q_1^2 p_1^1 + q_2^1p_2^2 - q_2^2 p_2^1 \n\\]\n\\[\n\\begin{aligned}\n  & \\frac{ \\partial L}{ \\partial q_i^j } = p_i^k \\epsilon^{jk} \\\\ \n  & \\frac{ \\partial L}{ \\partial p_i^k } = q_i^j \\epsilon^{jk}\n\\end{aligned}\n\\]\n\n\n\\[\n\\begin{gathered}\n  \\lbrace L, E \\rbrace = p_i^k \\epsilon^{jk} \\frac{p_i^j}{m_i} - q_i^k \\epsilon^{kj} \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} (-1)^i (q_2^j - q_1^j) = \\frac{ p_i^2 p_i^1}{m_i} - \\frac{ p_i^1 p_i^2}{m_i} -  q_i^k \\epsilon^{kj} \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} (-1)^i (q^j_2 - q^j_1) = \\\\\n  = 0 - \\frac{ \\partial V}{ \\partial r} \\frac{1}{r} ( -q_1^2(q_2^1- q_1^1 )(-1) + q_1^1 (q_2^2 - q_1^2)(-1) - q_2^2 (q_2^1 - q_1^1) + q_2^1 (q_2^2 - q_1^2) ) = 0 \n\\end{gathered}\n\\]\n\n\n\n\\end{enumerate}\n\n\n\\problemhead{22-18}\n\n\\begin{enumerate}\n\\item[(a)] if $f\\in C^{\\infty}(M)$ conserved quantity, by def. $f$ constant on every integral curve of $X_H$\n\\[\n\\lbrace f,H\\rbrace = \\frac{ \\partial f}{ \\partial x^i} \\frac{ \\partial H}{ \\partial y^i} - \\frac{ \\partial f}{ \\partial y^i} \\frac{ \\partial H}{ \\partial x^i} = X_H f = 0 \n\\]\nfor \n\\[\nX_H = \\frac{ \\partial H}{ \\partial y^i} \\frac{ \\partial }{ \\partial x^i} - \\frac{ \\partial H}{ \\partial x^i} \\frac{ \\partial }{ \\partial y^i} \n\\] \nlikewise, if $\\lbrace f,H \\rbrace =0$, then $X_Hf =0$, $X_Hf = \\mathcal{L}_{X_H} f= 0 $, so $f$ constant on flow of $X_H$\n\\item[(b)] Recall smooth $V \\in \\mathfrak{X}(M)$ infinitesimal symmetry of $(M,\\omega,H)$ if $\\omega, H$ invariant under flow of $V$, i.e. \n\\[\n\\begin{aligned}\n  & \\mathcal{L}_V \\omega =0 \n  &  \\mathcal{L}_VH = 0 \n\\end{aligned}\n\\]\nsmooth $V\\in \\mathfrak{X}(M)$ symplectic if $\\omega$ invariant under flow of $V$, i.e. $\\mathcal{L}_V\\omega =0$\n\\[\n\\mathcal{L}_VH = VH = 0\n\\]\n\\item[(c)] EY : 20150521 I'm not sure how to go about this because what is a trajectory?\n\n$\\gamma: I \\to M$\n\n$\\theta$ flow of an infinitesimal symmetry, so (collecting facts)\n\n\\[\n\\begin{aligned}\n  & \\mathcal{L}_{\\dot{\\theta}}\\omega = di_{\\dot{\\theta}}\\omega + i_{\\dot{\\theta}}d\\omega = di_{\\dot{\\theta}}\\omega \\quad \\, (\\omega \\text{ closed so } i_{\\dot{\\theta}}d\\omega) \\\\ \n  & \\dot{\\theta}H = 0 \n\\end{aligned}\n\\]\n\nNow $\\theta_s \\circ \\gamma : I \\to M$\n\n\\[\n\\frac{d}{dt}(\\theta_s \\circ \\gamma)(t) = (D\\theta_s)(\\gamma(t)) \\dot{\\gamma}(t) = V_{s,\\gamma(t)} \\dot{\\gamma}(t)\n\\]\n\\end{enumerate}\n\n\n\n\n", "meta": {"hexsha": "a2941b79aa8a3fd242723aadcc3c33eadfa42033", "size": 15078, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LeeJM/22SymplecticManifolds.tex", "max_stars_repo_name": "wacfeldwang333/mathphysics", "max_stars_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2017-01-10T14:24:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:19:23.000Z", "max_issues_repo_path": "LeeJM/22SymplecticManifolds.tex", "max_issues_repo_name": "wacfeldwang333/mathphysics", "max_issues_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2017-09-29T09:29:53.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T03:12:29.000Z", "max_forks_repo_path": "LeeJM/22SymplecticManifolds.tex", "max_forks_repo_name": "wacfeldwang333/mathphysics", "max_forks_repo_head_hexsha": "59eb794dfa46e2b80e43df0440bb8ec3c472d973", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 25, "max_forks_repo_forks_event_min_datetime": "2018-01-21T05:33:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T20:15:13.000Z", "avg_line_length": 37.8844221106, "max_line_length": 300, "alphanum_fraction": 0.5931821196, "num_tokens": 6339, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.41404849661205345}}
{"text": "\\documentclass[a4paper,12pt]{extarticle}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\n\\renewcommand\\familydefault{\\sfdefault}\n\\usepackage{tgheros}\n\\usepackage[defaultmono]{droidmono}\n\n\\usepackage{amsmath,amssymb,amsthm,textcomp}\n\\usepackage{enumerate}\n\\usepackage{multicol}\n\\usepackage{tikz}\n\n\\usepackage{geometry}\n\\geometry{left=25mm,right=25mm,%\nbindingoffset=0mm, top=20mm,bottom=20mm}\n\n\n\\linespread{1.3}\n\n\\newcommand{\\linia}{\\rule{\\linewidth}{0.5pt}}\n\n% custom theorems if needed\n\\newtheoremstyle{mytheor}\n    {1ex}{1ex}{\\normalfont}{0pt}{\\scshape}{.}{1ex}\n    {{\\thmname{#1 }}{\\thmnumber{#2}}{\\thmnote{ (#3)}}}\n\n\\theoremstyle{mytheor}\n\\newtheorem{defi}{Definition}\n\n% my own titles\n\\makeatletter\n\\renewcommand{\\maketitle}{\n\\begin{center}\n\\vspace{2ex}\n{\\huge \\textsc{\\@title}}\n\\vspace{1ex}\n\\\\\n\\linia\\\\\n\\@author \\hfill \\@date\n\\vspace{4ex}\n\\end{center}\n}\n\\makeatother\n%%%\n\n% custom footers and headers\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\lhead{}\n\\chead{}\n\\rhead{}\n\\lfoot{Intro to Kalman Filter}\n\\cfoot{}\n\\rfoot{Page \\thepage}\n\\renewcommand{\\headrulewidth}{0pt}\n\\renewcommand{\\footrulewidth}{0pt}\n%\n\n% code listing settings\n\\usepackage{listings}\n\\lstset{\n    language=Python,\n    basicstyle=\\ttfamily\\small,\n    aboveskip={1.0\\baselineskip},\n    belowskip={1.0\\baselineskip},\n    columns=fixed,\n    extendedchars=true,\n    breaklines=true,\n    tabsize=4,\n    prebreak=\\raisebox{0ex}[0ex][0ex]{\\ensuremath{\\hookleftarrow}},\n    frame=lines,\n    showtabs=false,\n    showspaces=false,\n    showstringspaces=false,\n    keywordstyle=\\color[rgb]{0.627,0.126,0.941},\n    commentstyle=\\color[rgb]{0.133,0.545,0.133},\n    stringstyle=\\color[rgb]{01,0,0},\n    numbers=left,\n    numberstyle=\\small,\n    stepnumber=1,\n    numbersep=10pt,\n    captionpos=t,\n    mathescape=true,\n    escapeinside={\\%*}{*)}\n}\n\n%%%----------%%%----------%%%----------%%%----------%%%\n\n\\begin{document}\n\n\\title{ Extended Kalman Filter }\n\n\\author{ Dhruv Patel }\n\n\\maketitle\n\n\\section*{ Why Extended Filter is required ? }\n\nIf we already have Kalman Filter, first question in mind would be why do we require another alternative to that ... ?\n\nWell, in real life, the assumptions of \\emph{linear state transitions} and linear measurements with added \\emph{Gaussian noise} are only found on the rarest of occasions. Let's see what I mean by that using an example.\n\" A robot that moves with constant translational and rotational velocity typically moves on a circular trajectory, which cannot be described by linear next state transitions. This fact, along with the assumption of unimodal beliefs, renders the simple Kalman Filter adequate enough for most trivial robotics problems. This Extended Kalman Filter (EKF) overcomes one of these assumptions : the linearity assumption. Here, the assumption is that the next state probability and the measurement probabilities are governed by nonlinear functions $g$ and $h$, respectively :\n\n\\begin{equation}\nx_{t} = g(u_{t}, \\: x_{t-1}) + \\varepsilon_{t}\n\\end{equation}\n\\begin{equation}\nz_{t} = h(x_{t}) + \\delta_{t}\n\\end{equation}\n\nThis model strictly generalizes the linear Gaussian model underlying Kalman filters, postulated in Equations $1$ and $2$. The function $g$ replaces the matrices $A_{t}$ and $B_{t}$ in previous filter type, while $h$ replaces the matrix $C_{t}$. \\textbf{Unfortunately, with arbitrary functions $g$ and $h$, the belief is no longer a Gaussian}. In fact, performing the belief update exactly is usually impossible for non-linear functions $g$ and $h$, in the sense that the Bayes filter does not possess a closed-form solution.\n\\newline\n\\newline\n\\textbf{So how come this EKF performs better than Kalman Filter?}\n\nThe extended Kalman filter (EKF) calculates an approximation to the true belief. Particularly, the belief $bel(x_{t})$ at time $t$ is represented by a mean $\\mu_{t}$ and a covariance $\\Sigma_{t}$. Thus, the EKF inherits from the Kalman filter the basic belief representation, but it differs in that this belief is only approximate, not exact as was the case in Kalman filters.\n\n\\vfill\n% Pseudo Code - Extended Kalman Filter\n\\section*{The EKF Algorithm}\n\nThe algorithm, in many ways, is similar to the KF.\n\n\\begin{lstlisting}\nAlgorithm Kalman Filter($\\mu_{t-1}, \\Sigma_{t-1}, u_t, z_t$):\n\t# Prediction Step : ref. as Motion Model\n\t$\\overline{\\mu}_t =  g(u_{t}, \\mu_{t-1})$\n\t$\\overline{\\Sigma}_t = G_t * \\Sigma_{t-1} * G_t^T  +  R_t$\n\t# Update Step : ref. as Measurement Model\n\t$K_t = \\overline{\\Sigma}_t * H_t^T * (H_t * \\overline{\\Sigma}_t * H_t^T  +  Q_t)^{-1}$\n\t$\\mu_t = \\overline{\\mu}_t + K_t * (z_t - h({\\mu}_t))$\n\t$\\Sigma_t = ( I - K_t * H_t ) * \\overline{\\Sigma}_t$\n\treturn $\\mu_t , \\Sigma_t$\n\t\n\\end{lstlisting}\n\n\\begin{table}[h!]\n   \\begin{center}\n    \\caption{Comparison - Kalman Filter vs EKF}\n    \\label{tab:table1}\n    \n    \\begin{tabular}{l|c|r} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between\n      \n      \\textbf{} & \\textbf{Kalman Filter} & \\textbf{EKF}\\\\\n      \\hline\n      state prediction (line 2) & $A_t * \\mu_{t-1} + B_t * u_t$ & $g(u_t, \\mu_{t-1})$\\\\\n      measurement prediction (line 5) & $C_t * \\overline{\\mu}_t$ & $h(\\overline{\\mu}_t)$\\\\\n    \n    \\end{tabular}\n    \\end{center}    \n\\end{table}\n\nIn summary, the linear predictions in Kalman filters are replaced by their nonlinear generalizations in EKF. Also, EKF uses Jacobians $G_t$ and $H_t$ instead of the corresponding linear system matrices $A_t$, $B_t$ and $C_t$ in Kalman counterpart. The Jacobian $G_t$ corresponds to the matrices $A_t$ and $B_t$, while the Jacobian $H_t$ corresponds to $C_t$. \n\n\nThe Kalman Filter represents beliefs by the moments parameterization : At time $t$, the belief $bel(x_t)$is represented by the mean $\\mu_t$ and the covariance $\\Sigma_t$. The input of the Kalman filter is the belief at time $t-1$, represented by $\\mu_{t-1}$ and $\\Sigma_{t-1}$. To update these parameters, Kalman filters require the control $u_t$ and the measurement $z_t$. The output is the belief at time $t$, represented by $\\mu_t$ and $\\Sigma_t$. This predicted belief $\\mu_t$ and $\\Sigma_t$ is calculated representing the belief $\\overline{bel}(x_t)$ one time step later, but before incorporating the measurement $z_t$. This belief is obtained by incorporating the control $u_t$. The update of the covariance considers the fact that states depend on previous states through the linear matrix $A_t$. This matrix is multiplied twice into the covariance, since the covariance is a quadratic matrix.\n\n\\vfill\n\\section*{Considerations}\n\nThe EKF has become just about the most popular tool for state estimation in robotics. Its strength is its simplicity and in its efficiency. \n\nThe reason for the computational efficiency is the fact that it (EKF) represents the belief by a multivariate Gaussian distribution. A Gaussian is a unimodal distribution, which can be thought of as a single guess, illustrated as an uncertainty ellipse. In many practical situations, Gaussians are robust estimators. EKF has been applied with great success to a number of state estimation problems that violate the underlying assumptions.\n\n\n\\textbf{An important limitation} : It approximates state transitions and measurements using Linear Taylor expansions. In most of the robotics problems, these functions are nonlinear. The goodness of this approximation depends on two main factors. First, it depends on the degree of nonlinearity of the functions that are being approximated. If these functions are approximately linear, the EKF approximation may generally be a good one, and EKF may approximates the posterior belief with sufficient accuracy. However, sometimes, the functions are not only nonlinear, but are also multi-modal, in which case the linearization may be a poor approximation. The goodness of the linearization also depends on the degree of uncertainty. The less certain the robot, the wider its Gaussian belief, and the more it is affected by nonlinearities in the state transition and measurement functions. In practice, when applying EKF, it is therefore important to keep the uncertainty of the state estimate small.\n\n\\textbf{Note} : Taylor series expansion is only one way to linearize. Two other approaches have often been found to yield superior results. One is the \\emph{unscented Kalman filter}, which probes the function to be linearized at selected points and calculates a linearized approximation based on the outcomes of these probes. Another is known as moments matching, in which the linearization is calculated in a way that preserves the true mean and the true covariance of the posterior distribution (which is not the case for EKF). Both techniques are relatively recent but appear to be superior to the EKF linearization. \n\n\n\\section*{ A brief explanation about the variables }\n\nThe state transition probability $ p( x_t | u_t, x_{t-1} ) $ must be a linear function in its arguments with added Gaussian noise. This is expressed by the following equation : \n\\begin{equation} \\label{eq1}\nx_t =  A_t * x_{t-1}  +  B_t * u_t  +  \\varepsilon_t\n\\end{equation}\nHere, $x_t$ and $x_{t-1}$ are state vectors, and $u_t$ is the control vector at time $t$. These vectors are column vectors. They are of the form\n\\begin{equation}\nx_t = \\left( \\begin{array}{c} x_{1,t} \\\\ x_{2,t} \\\\ . \\\\ . \\\\  x_{n,t} \\end{array} \\right)\n\\mbox{~and~}\nu_t = \\left( \\begin{array}{c} u_{1,t} \\\\ u_{t,2} \\\\ . \\\\ . \\\\ u_{m,t} \\end{array} \\right)\n\\end{equation}\n$A_t$ and $B_t$ are matrices. $A_t$ is a square matrix of size $ n \\times n $, where $n$ is the dimension of the state vector $x_t$. $B_t$ is of size $ n \\times m$, with $m$ being the dimension of the control vector $u_t$. By multiplying the state and control vector with the matrices $A_t$ and $B_t$, respectively, the state transition function becomes \\emph{linear} in its arguments. Thus, Kalman Filters assume linear system dynamics.\n\nThe random variable $\\varepsilon_t$ in (1) is a Gaussian random vector that models the uncertainty introduced by the state transition. It is of the same dimension as the state vector. It has zero mean, and its covariance will be denoted by $R_t$. A state transition probability of the form (1) is called a \\emph{linear Gaussian}, to reflect the fact that it is linear in its arguments with additive Gaussian noise. \n\nThe measurement probability $ p(z_t | x_t ) $ must also be \\emph{linear} in its arguments, with added Gaussian noise :\n\\begin{equation}\nz_t = C_t * x_t + \\delta_t\n\\end{equation}\nHere, $C_t$ is a matrix of size $k \\times n$, where $k$ is the dimension of the measurement vector $z_t$. The vector $\\delta_t$ describes the measurement noise. The distribution of $\\delta_t$ is a multivariate Gaussian with zero mean and covariance $Q_t$.\n\n\n\\vfill\n\n\\section*{ Given Problem }\n\nHere, we have been given a simple target tracking problem in one-dimensional space. The state contains three components : position (one-dimensional), velocity and acceleration and it can be expressed as below.\n\\begin{equation}\nx = \\left( \\begin{array}{c} x_k \\\\ \\dot{x}_k \\\\ \\ddot{x}_k \\end{array} \\right)\n\\end{equation}\nwhere, $x_k$ is the position, $\\dot{x}_k$ is the velocity and $\\ddot{x}_k$ is the acceleration at time '$k$'. $T$ is the size of sample time step.\n\nThe process equation for target motion is given by the following kinematic equation:\n\\begin{equation}\n\\left[ \\begin{array}{c} x_k \\\\ \\dot{x}_k \\\\ \\ddot{x}_k \\end{array} \\right] = \n\\left[ \\begin{array}{ccc} 1 & T & \\frac1{2}T^2 \\\\ 0 & 1 & T \\\\ 0 & 0 & 1  \\end{array} \\right] * \\left[ \\begin{array}{c} x_{k-1} \\\\ \\dot{x}{k-1} \\\\ \\ddot{x}{k-1} \\end{array} \\right] + \\upsilon_{k-1}\n\\end{equation}\nand \n\\begin{equation}\n\\upsilon_{k-1} \\sim N(0, Q)\n\\end{equation}\nwhere,\n$ Q = \\sigma^2 * \\left[ \\begin{array}{ccc} \\frac{T^4}{4} & \\frac{T^3}{2} & \\frac{T^2}{2} \\\\ \\frac{T^3}{2} & 2T^3 & T^2 \\\\ \\frac{T^2}{2} & T^2 & T^2  \\end{array} \\right] $, $\\sigma$ represents intensity of Gaussian noise.\n\nTargets are usually tracked with the help of sensors such as radars or lidars which provide the position of the target. Hence, the measurement equation can be written as:\n\\begin{equation}\ny_k = \n\\left[ \\begin{array}{ccc} 1 & 0 & 0 \\end{array} \\right] * \\left[ \\begin{array}{c} x_k \\\\ \\dot{x}_k \\\\ \\ddot{x}_k \\end{array} \\right] + \\omega\n\\end{equation}\nwhere, $y_k$ is the measurement and $\\omega \\sim N(0, R) $ is the measurement noise. \n\n\\hfill\n\nFor the given problem, obtain the estimate of its state over a period of $ 20 ~sec $. Assume time step $ T = 0.1 ~sec $. \n\n\n\n\n\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "815bed784101965f75174f19972fab3d2b5b670a", "size": 12551, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/Kalman_Filter.tex", "max_stars_repo_name": "loggerd/extended-kalman-filter", "max_stars_repo_head_hexsha": "e18282f5e28a500793fc83b27a9646414ccf978e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX/Kalman_Filter.tex", "max_issues_repo_name": "loggerd/extended-kalman-filter", "max_issues_repo_head_hexsha": "e18282f5e28a500793fc83b27a9646414ccf978e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX/Kalman_Filter.tex", "max_forks_repo_name": "loggerd/extended-kalman-filter", "max_forks_repo_head_hexsha": "e18282f5e28a500793fc83b27a9646414ccf978e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.8636363636, "max_line_length": 997, "alphanum_fraction": 0.7252011792, "num_tokens": 3580, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4140484931784742}}
{"text": "\\RequirePackage[l2tabu, orthodox]{nag} % This gives you warnings if you use obsolete LaTeX commands.\n\\documentclass[12pt,reqno]{amsart}\n\\usepackage{fullpage,amssymb,amsbsy,url,enumerate,color,comment,colonequals,graphicx,ifthen,mathrsfs,stmaryrd,bm}\n\\usepackage[all]{xy}\n\\usepackage[ruled, linesnumbered]{algorithm2e}\n\n% Color!\n\\usepackage[dvipsnames,xcdraw,hyperref]{xcolor}\n\\definecolor{darkgreen}{rgb}{0,0.5,0}\n\\newcommand{\\green}[1]{{\\color{darkgreen} #1}}\n\\newcommand{\\blue}[1]{{\\color{blue} #1}}\n\\newcommand{\\red}[1]{{\\color{red} #1}}\n\\newcommand{\\magenta}[1]{{\\color{magenta} #1}}\n\\newcommand{\\violet}[1]{{\\color{violet} #1}}\n\n\\newcommand{\\defi}[1]{\\textsf{\\color{blue} #1}} % for defined terms\n\n% Characters\n\\newcommand{\\Aff}{\\mathbb{A}}\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\F}{\\mathbb{F}}\n\\newcommand{\\G}{\\mathbb{G}}\n\\newcommand{\\bbH}{\\mathbb{H}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\PP}{\\mathbb{P}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Sphere}{\\mathbb{S}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\Qbar}{{\\overline{\\Q}}}\n\\newcommand{\\Zhat}{{\\widehat{\\Z}}}\n\\newcommand{\\Zbar}{{\\overline{\\Z}}}\n\\newcommand{\\kbar}{{\\overline{k}}}\n\\newcommand{\\Kbar}{{\\overline{K}}}\n\\newcommand{\\Fbar}{{\\overline{\\F}}}\n\n\\newcommand{\\boldmu}{\\bm{\\mu}}\n\\newcommand{\\boldalpha}{\\bm{\\alpha}}\n\n\\newcommand{\\ii}{\\mathbf{i}}\n\\newcommand{\\jj}{\\mathbf{j}}\n\\newcommand{\\kk}{\\mathbf{k}}\n\n\\newcommand{\\pp}{\\mathfrak{p}}\n\\newcommand{\\mm}{\\mathfrak{m}}\n\n% mathcal characters\n\\newcommand{\\calA}{\\mathcal{A}}\n\\newcommand{\\calB}{\\mathcal{B}}\n\\newcommand{\\calC}{\\mathcal{C}}\n\\newcommand{\\calD}{\\mathcal{D}}\n\\newcommand{\\calE}{\\mathcal{E}}\n\\newcommand{\\calF}{\\mathcal{F}}\n\\newcommand{\\calG}{\\mathcal{G}}\n\\newcommand{\\calH}{\\mathcal{H}}\n\\newcommand{\\calI}{\\mathcal{I}}\n\\newcommand{\\calJ}{\\mathcal{J}}\n\\newcommand{\\calK}{\\mathcal{K}}\n\\newcommand{\\calL}{\\mathcal{L}}\n\\newcommand{\\calM}{\\mathcal{M}}\n\\newcommand{\\calN}{\\mathcal{N}}\n\\newcommand{\\calO}{\\mathcal{O}}\n\\newcommand{\\calP}{\\mathcal{P}}\n\\newcommand{\\calQ}{\\mathcal{Q}}\n\\newcommand{\\calR}{\\mathcal{R}}\n\\newcommand{\\calS}{\\mathcal{S}}\n\\newcommand{\\calT}{\\mathcal{T}}\n\\newcommand{\\calU}{\\mathcal{U}}\n\\newcommand{\\calV}{\\mathcal{V}}\n\\newcommand{\\calW}{\\mathcal{W}}\n\\newcommand{\\calX}{\\mathcal{X}}\n\\newcommand{\\calY}{\\mathcal{Y}}\n\\newcommand{\\calZ}{\\mathcal{Z}}\n\n\\newcommand{\\CC}{\\mathscr{C}}\n\\newcommand{\\FF}{\\mathscr{F}}\n\\newcommand{\\GG}{\\mathscr{G}}\n\\newcommand{\\scriptH}{\\mathscr{H}}\n\\newcommand{\\II}{\\mathscr{I}}\n\\newcommand{\\JJ}{\\mathscr{J}}\n\\newcommand{\\KK}{\\mathscr{K}}\n\\newcommand{\\LL}{\\mathscr{L}}\n\\newcommand{\\OO}{\\mathscr{O}}\n\\newcommand{\\XX}{\\mathscr{X}}\n\\newcommand{\\ZZ}{\\mathscr{Z}}\n\n% various math expressions that shouldn't be italicized \n\\DeclareMathOperator{\\cis}{cis}\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\Var}{Var}\n\\DeclareMathOperator{\\Cov}{Cov}\n\\DeclareMathOperator*{\\lcm}{lcm}\n\\DeclareMathOperator{\\ord}{ord}\n\\DeclareMathOperator{\\Ker}{Ker}\n\\DeclareMathOperator{\\Bin}{Bin}\n\\DeclareMathOperator{\\res}{res}\n\\DeclareMathOperator{\\rad}{rad}\n\\DeclareMathOperator{\\Spec}{Spec}\n\n\\newcommand{\\Cech}{\\v{C}ech}\n\\newcommand{\\del}{\\partial}\n\\newcommand{\\directsum}{\\oplus} % binary direct sum\n\\newcommand{\\Directsum}{\\bigoplus} % direct sum of a collection\n\\newcommand{\\injects}{\\hookrightarrow}\n\\newcommand{\\intersect}{\\cap} % binary intersection\n\\newcommand{\\Intersection}{\\bigcap} % intersection of a collection\n\\newcommand{\\isom}{\\simeq}\n\\newcommand{\\HH}{{\\operatorname{H}}}\n\\newcommand{\\HHcech}{{\\check{\\HH}}}\n\\newcommand{\\HHat}{{\\hat{\\HH}}}\n\\newcommand{\\notdiv}{\\nmid}\n\\newcommand{\\surjects}{\\twoheadrightarrow}\n\\newcommand{\\tensor}{\\otimes} % binary tensor product\n\\newcommand{\\Tensor}{\\bigotimes} % tensor product of a collection\n\\newcommand{\\To}{\\longrightarrow}\n\\newcommand{\\union}{\\cup} % binary union\n\\newcommand{\\Union}{\\bigcup} % union of a collection\n\n%Mau's\n\\newcommand{\\ra}[1][]{\\xrightarrow{#1}}\n\\newcommand{\\f}[2]{\\frac{#1}{#2}}\n\\DeclareMathOperator{\\id}{id}\n\\newcommand{\\be}{\\mathbf{e}}\n\\newcommand{\\bd}{\\mathbf{d}}\n\\newcommand{\\eps}{\\varepsilon}\n\\DeclareMathOperator{\\Stab}{Stab}\n\\DeclareMathOperator{\\Span}{Span}\n\\DeclareMathOperator{\\im}{im}\n\\DeclareMathOperator{\\sgn}{sgn}\n\n%%% \\numberwithin{equation}{section}\n%%% \\newtheorem{theorem}[equation]{Theorem} \n%%% etc.\n\n% We use one numbering for all theorems, lemmas, etc.\n% Use \\newtheorem{theorem}{Theorem}[section] to number by section, so that the first theorem in Section 3 would be Theorem 3.1.\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{proposition}[theorem]{Proposition}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{question}[theorem]{Question}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\n\\theoremstyle{remark}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{examples}[theorem]{Examples}\n\\newtheorem{remark}[theorem]{Remark}\n\\newtheorem{remarks}[theorem]{Remarks}\n\n\\newenvironment{problem}\n\t{\n\t\t\\bigskip\n\t\t\\noindent\n\t\t{\\large\\textbf{Problem.}}\n\t\t\\newline\n\t}\n\t{\n\t\t\\bigskip\n\t}\n\n\\newenvironment{solution}[1]\n\t{\n\t\t\\bigskip\n\t\t\\noindent\n\t\t{\\large\\textbf{Solution to #1.}}\n\t\t\\newline\n\t}\n\t{\n\t\t\\ensuremath{\\blacksquare} \\bigskip\n\t}\n\n\\usepackage{microtype}  % This adjusts spacing between words so as to improve the probability of having line breaks in good places.\n\n\\usepackage[\n%\tdraft,\n%\tcolorlinks,\n%\tpagebackref,\n%\tpdfauthor={Authors go here}, % not necessary to enter this\n%\tpdftitle={Paper title}, % not necessary to enter this\n]{hyperref} % This allows you to put hyperlinks in your document.\n\n% \\begin{center}\n%    \\includegraphics[width=0.5\\textwidth]{Filename}\n% \\end{center}\n\\usepackage[utf8]{inputenc}\n\n\\title{Tetrahedra UROP Project 2}\n\\author{Mauricio Barba da Costa}\n\\date{September 2020}\n\n\\begin{document}\n\n\\maketitle\n\\section{Introduction}\nA tetrahedron is a polyhedron with 4 faces. Suppose $T$ is a tetrahedron with angles\n$\\alpha_{12},\\alpha_{13},\\alpha_{14},\\alpha_{23},\\alpha_{24},\\alpha_{34}$. \nMy team and I were curious about tetrahedra whose angles, when viewed as elements of \n$\\R/2\\pi\\Q$, span a 5-dimensional $\\Q$ vector space. In particular, we wanted to know\nif one such tetrahedra could have Dehn invariant zero. Showing that no such tetrahedron\nwith this property have Dehn invariant zero would have serious ramifications. For instance, Debrunner showed\nthat if a polyhedron $P$ tiles 3D space then it must have Dehn invariant zero.\n\\section{The Problem}\nGiven a tetrahedron $T$, enumerate the vertices 1,2,3,4. Denote $e_{ij}$\nas the edge between vertices $i$ and $j$ and $\\theta_{ij}$ as the dihedral\nangle of $e_{ij}$. One convention that I follow throughout this paper\nis listing edges and angles using the ordering $12,13,14,23,24,34$.\nSuppose we're given dihedral angles $\\theta_{12},...,\\theta_{34}\\in \\R/\\Q\\pi$ \nthat span a 5-dimensional $\\Q$-vector space. \nFor a tetrahedron with such angle to have Dehn invariant 0, the edge \nlengths $e_{12},...,e_{34}$ must be proportional to a tuple of positive\nintegers such that $\\sum_{i<j} e_{ij}\\theta_{ij}=0 \\mod{\\Q\\pi}$. Let $z_{ij}=e^{i\\theta_{ij}}$.\nLet $w_{ij}=e^{i(2\\theta_{ij})}$. Then $2\\cos\\theta_{ij}=z_{ij}+z_{ij}^{-1}$\nand $2\\cos2\\theta_{ij}=w_{ij}+w_{ij}^{-1}$. By Theorem 1 of Wirth-Dreiding,\n$\\cos\\theta_{ij}=\\frac{D_{ij}}{\\sqrt{D_{ijk}D_{ijl}}}\\in \\sqrt{\\Q}$\nand consequently $\\cos2\\theta_{ij}=2\\cos^2\\theta_{ij}-1\\in \\Q$. Then $w_{ij}$\nsatisfies the polynomial relation $w_{ij}^2-c_{ij} w_{ij}+1=0$ where\n$c_{ij}=2\\cos2\\theta_{ij}$.\n\\section{Numerical Approach}\nThe code I developed as part of this project is distributed across 3 branches of my forked\nrepository of Abdelatiff Chentouf Anas' original work. It includes my p-adic approach\nto resolving the problem, my numerical approach, and some functions that were generally essential for\nmaking computations with tetrahedra. \n\nSuppose $\\sum_{i<j} e_{ij}\\theta_{ij}=0\\mod{\\Q\\pi}$. Then $\\sum e_{ij}\\theta_{ij}=q\\pi$\nfor some $q\\in \\Q$ so $\\sum_{i<j} e_{ij}\\theta_{ij} i=iq\\pi$. Then $\\prod z_{ij}^{e_{ij}}$ is a root\nof unity in a field obtained by adjoining square roots to $\\Q$. Now,\n$Gal(\\Q(\\zeta_n/\\Q)=(\\Z/n\\Z)^\\times$ so $\\zeta_n\\in \\Q(\\sqrt{\\Q})$\nif and only if $(\\Z/n\\Z)^\\times$ \nis an elementary 2-group. This forces $(\\Z/n\\Z)^\\times=\\prod_{p|n}(\\Z/p^{e_p}\\Z)^\\times$\nwhere $e_2\\leq 3,e_3\\leq 1$ and $e_p=0$ for all other primes $p$. Thus,\n$n|24$. Thus, $(\\prod_{j=1}^6 w_{ij}^{e_{ij}})^{24}=1$. For a tetrahedra $T$, we can \ncalculate $W=\\prod_{j=1}^6 w_{ij}^{e_{ij}})^{24}$ with a computer and see if it falls\nwithin some $\\epsilon$ of 1. To identify a counterexample, I iterated over randomly generated\nsextuples, checked if they determined a tetrahedron according to Lemma 4 of Wirth-Dreiding.\nI had some setbacks when I undertook this approach. For a while, I was applying the conditions\nfor Lemma 4 of Wirth-Dreiding into my computer incorrectly. When I did realize that I was\ndoing it wrong, I had to end my AWS EC2 instance because my free plan was running out.\nIt might be worth further exploring this approach.\n\\section{p-adic Approach}\nIf we think about p-adics now, if $\\sum_{i<j}e_{ij}\\theta_{ij}=0\\mod{\\Q\\pi}$ then $\\sum e_{ij}v_p(w_{ij})=0$\nfor every prime $p$. Now, $c_{ij}\\in \\Q$ so \ncomputing $v_p(c_{ij})$ is easy. Calculating, $v_p(w_{ij})$\nis more difficult to calculate since it's in a field extension of $\\Q$.\nWe can use the following tool:\n$$\nv_p(w_{ij})=\\begin{cases}\n  0&v(c_{ij})\\geq 0\\\\\n  \\pm v(c_{ij})&v(c_{ij})<0\n\\end{cases}\n$$\nIf $v_p(w_ij)<0$, whether $v_p(w_{ij})=+v(c_{ij})$ or $v_p(w_{ij})=-v(c_{ij})$ we can't know.\n\\section{My algorithm}\nMy algorithm exploits the p-adic approach to the problem to find tetrahedra\nwhose angles span a 5-dimensional $\\Q$-vector space and have Dehn invariant zero. \nIt does this by randomly generating sextuples, checking if they determine a \ntetrahedra (using Lemma 4 of Wirth-Dreiding). If it is a tetrahedron, then it calcualtes the denominator\nof $c_{ij}$ when it is expressed in simplest terms. Recall that\n$$\nc_{ij}=2\\cos2\\theta_j=4\\cos^2\\theta_j-2=\\frac{4D_{ij}^2-2D_{ijk}D_{ijl}}{D_{ijk}D_{ijl}}\n$$\nNow, the denominator can be expressed as \n$$\nL_{ij}=\\frac{D_{ijk}D_{ijl}}{\\gcd(D_{ijk}D_{ijl},4D_{ij}^2-2D_{ijk}D_{ijl})}=\n\\frac{D_{ijk}D_{ijl}}{\\gcd(D_{ijk}D_{ijl},4D_{ij}^2)}\n$$\nThen, it gets the prime factors of all these. Then, it\nfinds the valuations of all of these with respect to all the primes. We\ncan arrange these $L$s into a list $[L_{12},L_{13},L_{14},L_{23},L_{24},L_{34}]$.\nTaking the valuation with respect to $p$ of these yields\n$$\nv_p(L_{ij})=\\begin{cases}\n  0&v_p(c_{ij})\\geq 0\\\\\n  \\pm v_p(c_{ij})&v_p(c_{ij})<0\n\\end{cases}\n$$\nIf $\\sum_{i<j}\\pm e_{ij}v_p(L_{ij})=0$ for some combination of pluses and minuses,\nthis is a necessity for the condition to hold. It is not a sufficiency since we don't know\nwhich combination of pluses and minuses is right. Here is how I checked if \n$\\sum_{i<j}\\pm e_{ij}v_p(L_{ij})=0$ computationally:\n\nFor every prime $p$\n\\begin{enumerate}\n  \\item Identify all $L_{ij}$ such that $v_p(L_{ij})>0$. Suppose there are $m$ such \n  $L_{ij}$s. Insert these valuatioins into an $1\\times m$ matrix $VL$. \n  \\item Create an $2^m\\times m$ matrix $M$ where the elements in the $i$th row\n  are the digits of the $i$th integer (starting from 0) when expressed in base 2.\n  \\item Perform an elementwise multiplication $M\\star VL$ then the matrix\n  multiplication $(M\\star VL)\\times E$ where\n  $$\n  E=\\begin{pmatrix}\n    e_{12}\\\\e_{13}\\\\e_{14}\\\\e_{23}\\\\e_{24}\\\\e_{34}\n  \\end{pmatrix}\n  $$\n  \\item Use np.any($(M\\star VL)\\times E==0$) to see if any combination\n  of pluses and minuses yielded the correct result.\n\\end{enumerate}\nNot unless np.any($(M\\star VL)\\times E==0$) for all primes is the tetrahedron a candidate\nfor having Dehn invariant zero. This seems to never happen.\n\\section{Some Observations and Analysis}\nI have a \\href{https://github.com/mauriciobarba/AC-18.Tetra/tree/main}{GitHub Repo}\nwhere the code for this project is stored. In here is also a file that's the result\nof running the p-adic analysis of my code. Here is an example output:\\\\\n\n\\begin{verbatim}\n[39, 82, 56, 47, 56, 90]\n[2314830, 4265533440, 36952226532, 384102810, 3407333959107, 796296384]\n193 [0, 0, 0, 1, 1, 1]\n2 [1, 13, 2, 1, 0, 6]\n3 [1, 3, 2, 7, 6, 2]\n5 [1, 1, 0, 1, 0, 0]\n7 [1, 1, 0, 1, 0, 0]\n73 [1, 0, 1, 0, 1, 0]\n13 [0, 0, 2, 1, 3, 1]\n19 [0, 1, 1, 0, 0, 1]\n151 [1, 0, 1, 0, 1, 0]\n29 [0, 1, 1, 0, 0, 1]\nprimes passed: {3}\n\\end{verbatim}\nThis is how you interpret the results:\n\\begin{enumerate}\n  \\item On the first line is randomly generated sextuple of integers that denote the edges of a tetrahedron\n  in the order that we've been using $(e_{12},e_{13},e_{14},e_{23},e_{24},e_{34})$.\n  \\item In the second line is the list $[L_{12},L_{13},L_{14},L_{23},L_{24},e_{34}]$.\n  \\item In the lines below that, the number in the first column is a prime that divides\n  some $L_{ij}$. \n  \\item The primes that ``passed\" are those such that there exists a combination \n  of pluses and minuses such that $\\sum_{i<j}\\pm e_{ij}v_p(L_{ij})=0$. \n\\end{enumerate}\n\nThe Erdos-Kac Theorem states that the probability distribution of \n$$\n\\frac{\\omega(n)-\\log\\log n}{\\sqrt{\\log\\log n}}\n$$\nwhere $\\omega(n)$ is the number of distinct\nprime factors of $n$\nis the standard normal distribution. With this, we can calculate the average\nnumber of distinct prime factors of a number with 9 digits to be 3\nwith standard deviation approximately 1.6 (need to cite\nand check if 1.6 is right). $L_{ij}$\nis usually around 9 digits and has more than 3 distinct prime factors.\nFor instance, from looking at the table above, \n$$\n384102810=193\\times 2\\times 3^7\\times 5\\times 7\\times 13\n$$\nHowever, the primes that comprise 384102810 tend to be smaller and have a \ngreater power. \nBy contrast 1,000,000,003=$23\\times 307\\times 141623$. This suggests that the \nprime factorizations of the $L_{ij}$s is somewhat anomalous. Further exploring why\nthis is might bear some fruit. \n\nThe most common valuation list is [1,1,0,1,0,0]\nor some tetrahedral rotation of it. Also, you never get [2,0,0,0,0,0,2] or any\ntetrahedral rotation of this.\nWhich valuation lists are possible? I looked at valuation lists mod 2. I found that only a \nfew valuation lists are possible mod 2. They are\n$$\n  [1,1,0,0,1,1]\n$$\n$$\n  [1,1,0,1,0,0]\n$$\n$$\n  [0,0,0,0,0,0]\n$$\nMaybe we can prove the claim\nby showing that for every tetrahedron, there exists a prime $p$ that \nyields a valuation list [1,1,0,1,0,0] (or some tetrahedral rotation of it). Note that it's not possible that \n$\\pm e_{12}\\pm e_{13}\\pm e_{23}=0$ otherwise this would lead to a degenerate tetrahedron because\none of the faces violates the triangle inequality.\n\nIn general, my findings support the conjecture that there are no tetrahedra whose angles\nspan a 5-dimensional $\\Q$ vector space. The output of my code showed that seldom does\na prime pass. \n\\end{document}", "meta": {"hexsha": "755d63f55ce51fe871d2181b59759d4cac732d9a", "size": 14901, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX/main.tex", "max_stars_repo_name": "mercush/AC-18.Tetra", "max_stars_repo_head_hexsha": "3c22a4ddc6c9a847b8def579f2e824a8137e3642", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TeX/main.tex", "max_issues_repo_name": "mercush/AC-18.Tetra", "max_issues_repo_head_hexsha": "3c22a4ddc6c9a847b8def579f2e824a8137e3642", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX/main.tex", "max_forks_repo_name": "mercush/AC-18.Tetra", "max_forks_repo_head_hexsha": "3c22a4ddc6c9a847b8def579f2e824a8137e3642", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.525198939, "max_line_length": 131, "alphanum_fraction": 0.7122340782, "num_tokens": 5176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813031051514762, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.41402278383763924}}
{"text": "\\documentclass[fontsize=9pt, parskip=half, notitlepage, fleqn]{scrartcl}\n\n\\usepackage[UKenglish]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage{amssymb, amsmath, amsfonts, amsthm, empheq}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{xspace}\n\\usepackage{siunitx}\n\\usepackage[margin=3cm]{geometry}\n\\usepackage{natbib}\n\n\\frenchspacing\n\n% So equation numbers are not coloured\n\\makeatletter\n\\renewcommand\\tagform@[1]{%\n   \\maketag@@@{\\normalcolor\\ignorespaces(#1)\\unskip\\@@italiccorr}}\n\\makeatother\n\n\\newcommand{\\bkcol}[1]{\\textcolor{MidnightBlue}{#1\\xspace}}\n\\newcommand{\\hun}{\\textsc{Hun15}\\xspace}\n\\newcommand{\\book}{\\bkcol{\\textsc{Book}}\\xspace}\n\\newcommand{\\empymod}{\\texttt{empymod}\\xspace}\n\\newcommand{\\tmtemod}{\\texttt{tmtemod.py}\\xspace}\n\\newcommand{\\mr}[1]{\\mathrm{#1}}\n\n\\begin{document}\n\\setlength{\\jot}{10pt}  % Increase spacing between equations\n\n\\section*{Adjust Hunziker et al. (2015) for TM/TE-split}\n\n{\\ttfamily \\small Version 1.0, \\today\n\n\\hun refers to \\cite{GEO.15.Hunziker}, \\book refers to the derivation of\n\\cite{CUP.17.Ziolkowski}.}\n\nThe modeller \\empymod returns the total field, hence not distinguishing between\nTM and TE mode, and even less between up- and down-going fields. The reason\nbehind this is simple: The derivation of \\hun, on which \\empymod is based,\nreturns the total field. Internally it also calculates TM and TE modes, and\nsums these up. However, the separation into TM and TE mode introduces a\nsingularity at $\\kappa = 0$. It has no contribution in the space-frequency\ndomain to the total fields, but it introduces non-physical events in each mode\nwith opposite sign (so they cancel each other out in the total field). In\norder to obtain the correct TM and TE contributions one has to remove these\nnon-physical parts.\n\nTo remove the non-physical part we use the file \\tmtemod in this\ndirectory. This routine is basically a heavily simplified version of \\empymod\nwith the following limitations:\n\\begin{itemize}\n  \\item x-directed electric sources and electric receivers;\n  \\item only frequency domain;\n  \\item direct field is always calculated in the wavenumber-domain;\n  \\item the Fast Hankel transform is used with a 201\\,pt filter;\n  \\item source and receivers have to be in the same layer;\n  \\item the model must have more than one layer (there is only direct field\n    contribution anyway for a fullspace); and\n  \\item electric permittivity and magnetic permeability are isotropic.\n\\end{itemize}\n\nSo \\tmtemod returns the signal separated into TM$^{++}$, TM$^{+-}$, TM$^{-+}$,\nTM$^{--}$, TE$^{++}$, TE$^{+-}$, TE$^{-+}$, and TE$^{--}$ as well as the direct\nfield TM and TE contributions. The first superscript denotes the direction in\nwhich the field diffuses towards the receiver and the second superscript\ndenotes the direction in which the field diffuses away from the source. For\nboth the plus-sign indicates the field diffuses in the downward direction and\nthe minus-sign indicates the field diffuses in the upward direction. The\nroutine uses \\empymod wherever possible, see the corresponding functions in\n\\empymod for more explanation and documentation regarding input parameters.\n\nWe start with equation (105) in \\hun:\n%\n\\begin{align}\n  \\hat{G}^{ee}_{xx}(\\boldsymbol{x}, \\boldsymbol{x'}, \\omega)& =\n  \\hat{G}^{ee;i}_{xx;s}(\\boldsymbol{x}-\\boldsymbol{x'}, \\omega)\n  + \\frac{1}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\left(\\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s}-\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\\right)\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa \\nonumber\\\\\n  %\n  &\\quad - \\frac{\\cos(2\\phi)}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\left(\\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s} +\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\\right)\n  J_2(\\kappa r)\\kappa\\,\\mr{d}\\kappa \\ .\n\\end{align}\n%\n\nIgnoring the incident field, and using $J_2 = \\frac{2}{\\kappa r}J_1 - J_0$ to\navoid $J_2$-integrals, we get\n%\n\\begin{align}\n  \\hat{G}^{ee}_{xx}(\\boldsymbol{x}, \\boldsymbol{x'}, \\omega)& =\n  \\frac{1}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\left(\\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s}-\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\\right)\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa \\nonumber\\\\\n  %\n  &\\quad + \\frac{\\cos(2\\phi)}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\left(\\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s} +\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\\right)\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa \\nonumber\\\\\n  %\n  &\\quad - \\frac{\\cos(2\\phi)}{4\\pi r}\\int^\\infty_{\\kappa=0}\n  \\left(\\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s} +\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\\right)\n  J_1(\\kappa r)\\,\\mr{d}\\kappa \\ .\n\\end{align}\n%\n\nFrom this the TM- and TE-parts follow as\n%\n\\begin{align}\n  \\mr{TE}& = \\frac{\\cos(2\\phi)-1}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa \n   - \\frac{\\cos(2\\phi)}{4\\pi r}\\int^\\infty_{\\kappa=0}\n  \\frac{\\zeta_s \\tilde{g}^{te}_{zz;s}}{\\bar{\\Gamma}_s}\n  J_1(\\kappa r)\\,\\mr{d}\\kappa \\ , \\\\\n  %\n  \\mr{TM}& = \\frac{\\cos(2\\phi)+1}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s}\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa\n  - \\frac{\\cos(2\\phi)}{4\\pi r}\\int^\\infty_{\\kappa=0}\n  \\frac{\\Gamma_s \\tilde{g}^{tm}_{hh;s}}{\\eta_s}\n  J_1(\\kappa r)\\,\\mr{d}\\kappa \\ .\n\\end{align}\n%\n\nEquations (108) and (109) in \\hun yield the required parameters\n$\\tilde{g}^{tm}_{hh;s}$ and $\\tilde{g}^{te}_{zz;s}$,\n%\n\\begin{align}\n  \\tilde{g}^{tm}_{hh;s}& = P^{u-}_s W^u_s + P^{d-}_s W^d_s \\ , \\\\\n  \\tilde{g}^{te}_{zz;s}& = \\bar{P}^{u+}_s \\bar{W}^u_s +\n                           \\bar{P}^{d+}_s \\bar{W}^d_s \\ .\n\\end{align}\n%\n\nThe parameters $P^{u\\pm}_s$ and $P^{d\\pm}_s$ are given in equations (81) and\n(82), $\\bar{P}^{u\\pm}_s$ and $\\bar{P}^{d\\pm}_s$ in equations (A-8) and (A-9);\n$W^u_s$ and $W^d_s$ in equation (74). This yields\n%\n\\begin{align}\n  \\tilde{g}^{te}_{zz;s} &=\n  %\n  \\frac{\\bar{R}_s^+}{\\bar{M}_s}\\left\\{\\exp[-\\bar{\\Gamma}_s(z_s-z+d^+)] +\n    \\bar{R}_s^-\\exp[-\\bar{\\Gamma}_s(z_s-z+d_s+d^-)]\\right\\} \\nonumber \\\\\n  %\n  &\\quad +\n    \\frac{\\bar{R}_s^-}{\\bar{M}_s}\\left\\{\\exp[-\\bar{\\Gamma}_s(z-z_{s-1}+d^-)]+\n    \\bar{R}_s^+\\exp[-\\bar{\\Gamma}_s(z-z_{s-1}+d_s+d^+)]\\right\\}\\nonumber \\ ,\\\\\n  %\n  &=\\frac{\\bar{R}_s^+}{\\bar{M}_s}\\left\\{\\exp[-\\bar{\\Gamma}_s(2z_s-z-z')] +\n    \\bar{R}_s^-\\exp[-\\bar{\\Gamma}_s(z'-z+2d_s)]\\right\\} \\nonumber \\\\\n  %\n  &\\quad +\n  \\frac{\\bar{R}_s^-}{\\bar{M}_s}\\left\\{\\exp[-\\bar{\\Gamma}_s(z+z'-2z_{s-1})]+\n  \\bar{R}_s^+\\exp[-\\bar{\\Gamma}_s(z-z'+2d_s)]\\right\\}\\ ,\n  %\n\\end{align}\n%\nwhere $d^\\pm$ is taken from the text below equation (67). There are four terms\nin the right-hand side, two in the first line and two in the second line. The\nfirst term in the first line is the integrand of TE$^{+-}$, the second term in\nthe first line corresponds to TE$^{++}$, the first term in the second line is\nTE$^{-+}$, and the second term in the second line is TE$^{--}$.\n\nIf we look at TE$^{+-}$, we have\n%\n\\begin{equation}\n  \\tilde{g}^{te+-}_{zz;s} =\n  \\frac{\\bar{R}_s^+}{\\bar{M}_s}\\exp[-\\bar{\\Gamma}_s(2z_s-z-z')] \\ ,\n  %\n\\end{equation}\n%\nand therefore\n%\n\\begin{align}\n  \\mr{TE}^{+-}& = \\frac{\\cos(2\\phi)-1}{8\\pi}\\int^\\infty_{\\kappa=0}\n  \\frac{\\zeta_s \\bar{R}_s^+}{\\bar{\\Gamma}_s\\bar{M}_s}\n  \\exp[-\\bar{\\Gamma}_s(2z_s-z-z')]\n  J_0(\\kappa r)\\kappa\\,\\mr{d}\\kappa \\nonumber \\\\\n  &\\quad - \\frac{\\cos(2\\phi)}{4\\pi r}\\int^\\infty_{\\kappa=0}\n  \\frac{\\zeta_s \\bar{R}_s^+}{\\bar{\\Gamma}_s\\bar{M}_s}\n  \\exp[-\\bar{\\Gamma}_s(2z_s-z-z')]\n  J_1(\\kappa r)\\,\\mr{d}\\kappa \\ .\n  \\label{eq:hunte}\n\\end{align}\n%\n\nWe can compare this to equation (4.165) in \\book, with $\\hat{I}^e_x=1$ and\nslightly re-arranging it to look more alike, we get\n%\n\\bkcol{\n\\begin{align}\n  \\hat{E}^{+-}_{xx;H} &= \\frac{y^2}{4\\pi r^2}\n  \\int^\\infty_{\\kappa=0} \\frac{\\zeta_1}{\\Gamma_1} \n  \\frac{R^-_{H;1}}{M_{H;1}}\n  \\exp(-\\Gamma_1 h^{+-})J_0(\\kappa r)\\kappa\\rm{d}\\kappa \\nonumber \\\\\n  %\n  &\\quad + \\frac{x^2-y^2}{4\\pi r^3}\n  \\int^\\infty_{\\kappa=0} \\frac{\\zeta_1}{\\Gamma_1} \n  \\left(\\frac{R^-_{H;1}}{M_{H;1}} -\n  \\frac{R^-_{H;1}(\\kappa=0)}{M_{H;1}(\\kappa=0)}\\right)\n  \\exp(-\\Gamma_1 h^{+-})J_1(\\kappa r)\\rm{d}\\kappa \\nonumber \\\\\n  %\n  &\\quad - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^-_{H;1}(\\kappa=0)}{M_{H;1}(\\kappa=0)}\n  \\exp(-\\gamma_1 R^{+-}) \\ .\n  \\label{eq:bookte}\n\\end{align}\n}\n\nThe equation is marked in \\bkcol{blue} to make it clear that the symbols and\nparameters in \\hun and in \\book are not exactly the same.\n\nThe difference between equations \\ref{eq:hunte} and \\ref{eq:bookte} is that the\nfirst one contains non-physical contributions. These have opposite signs in\nTM$^{+-}$ and TE$^{+-}$, and therefore cancel each other out. But if we want to\nknow the specific contributions from TM and TE we have to remove them. The\nnon-physical contributions only affect the $J_1$-integrals, and only for\n$\\kappa = 0$.\n\nThe following lists for all 8 cases the term that has to be removed, in the\nnotation of \\book (for the notation as in \\hun see the implementation in\n\\tmtemod):\n%\n\\bkcol{\n\\begin{align}\n  TE^{++} &= + \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{\\exp(-\\gamma_1 |h^-|) }{M_{H;1}(\\kappa=0)} \\ ,\n  \\label{eq:1}\\\\\n  %\n  TE^{-+} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^+_{H;1}(\\kappa=0)\\exp(-\\gamma_1 h^{-+}) }{M_{H;1}(\\kappa=0)}\\ , \n  \\label{eq:2}\\\\\n  %\n  TE^{+-} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^-_{H;1}(\\kappa=0)\\exp(-\\gamma_1 h^{+-}) }{M_{H;1}(\\kappa=0)}\\ , \n  \\label{eq:3}\\\\\n  %\n  TE^{--} &= + \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^+_{H;1}(\\kappa=0)R^-_{H;1}(\\kappa=0)\\exp(-\\gamma_1 h^{--}) }\n  {M_{H;1}(\\kappa=0)}\\ , \n  \\label{eq:4}\\\\\n  %\n  %\n  TM^{++} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{\\exp(-\\gamma_1 |h^-|) }{M_{V;1}(\\kappa=0)}\\ , \n  \\label{eq:5}\\\\\n  %\n  TM^{-+} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^+_{V;1}(\\kappa=0)\\exp(-\\gamma_1 h^{-+}) }{M_{V;1}(\\kappa=0)}\\ , \n  \\label{eq:6}\\\\\n  %\n  TM^{+-} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^-_{V;1}(\\kappa=0)\\exp(-\\gamma_1 h^{+-}) }{M_{V;1}(\\kappa=0)}\\ , \n  \\label{eq:7}\\\\\n  %\n  TM^{--} &= - \\frac{\\zeta_1 (x^2-y^2)}{4\\pi\\gamma_1 r^4}\n  \\frac{R^+_{V;1}(\\kappa=0)R^-_{V;1}(\\kappa=0)\\exp(-\\gamma_1 h^{--}) }\n  {M_{V;1}(\\kappa=0)} \\ .\n  \\label{eq:8}\n\\end{align}\n}\n\nNote that in equations \\ref{eq:1} and \\ref{eq:4} the correction terms have\nopposite sign as those in equations \\ref{eq:5} and \\ref{eq:8} because at\n$\\kappa=0$ the TM and TE mode correction terms are equal. Also note that in\nequations \\ref{eq:2} and \\ref{eq:3} the correction terms have the same sign as\nthose in equations \\ref{eq:6} and \\ref{eq:7} because at $\\kappa=0$ the TM and\nTE mode reflection responses in those terms are equal but with opposite sign:\n\\bkcol{$R^\\pm_{V;1}(\\kappa=0) = -R^\\pm_{V;1}(\\kappa=0)$}. \n\n\\hun uses $\\phi$, whereas \\book uses $x$, $y$, for which we can use\n%\n\\begin{equation}\n  \\cos(2\\phi) = -\\frac{x^2-y^2}{r^2} \\ .\n  \\label{eq:phixy}\n\\end{equation}\n\n\n% REFERENCES\n\\bibliographystyle{seg}\n\\begin{thebibliography}{}\n\\itemsep0pt\n\n\\bibitem[Hunziker et~al., 2015]{GEO.15.Hunziker}\nHunziker, J., J. Thorbecke, and E. Slob, 2015, The electromagnetic response in\n  a layered vertical transverse isotropic medium: A new look at an old problem:\n  Geophysics, {\\bf 80}, F1--F18, doi: 10.1190/geo2013-0411.1.\n\n\\bibitem[Ziolkowski and Slob, 2017]{CUP.17.Ziolkowski}\nZiolkowski, A. and E. Slob, 2017, CSEM book (TODO, add citation once the book\n  is out): Cambridge University Press.  ISBN: ??????.\n\n\\end{thebibliography}\n\n\\end{document}\n\n", "meta": {"hexsha": "c100cd59722bf972292f0a1749e4d742ba05deae", "size": 11502, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/LaTeX/tmtemod.tex", "max_stars_repo_name": "ruboerner/empymod", "max_stars_repo_head_hexsha": "03d769f25cbc60bc34af7b38922bd48d6bf31c92", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 31, "max_stars_repo_stars_event_min_datetime": "2017-06-07T00:47:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-02T13:45:29.000Z", "max_issues_repo_path": "docs/LaTeX/tmtemod.tex", "max_issues_repo_name": "agrayver/empymod", "max_issues_repo_head_hexsha": "6c5f158b6093f8dcc1dec63057e6d3fd523fdbee", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 97, "max_issues_repo_issues_event_min_datetime": "2017-06-05T08:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-30T15:25:07.000Z", "max_forks_repo_path": "docs/LaTeX/tmtemod.tex", "max_forks_repo_name": "empymod/empyscripts", "max_forks_repo_head_hexsha": "b542f86ce4a48f43d2ddaeabbc08af2a5815fe95", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2017-11-05T13:24:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-25T19:25:18.000Z", "avg_line_length": 37.8355263158, "max_line_length": 79, "alphanum_fraction": 0.6395409494, "num_tokens": 4624, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4140227770558918}}
{"text": "\\documentclass{beamer}\n\\usetheme{CambridgeUS}\n\\title[Process]{The Koopman operator identification algorithm}\n\\subtitle{So far}\n\\institute[Polimi]{Politecnico di Milano}\n\\author{Sergio Vanegas}\n\\date{\\today}\n\n\\usepackage{listings}\n\\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode/mcode}\n\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\usepackage{siunitx}\n\n\n\\begin{document}\n\n\\begin{frame}[plain,noframenumbering]\n    \\maketitle\n\\end{frame}\n\n\\begin{frame}{Table of Contents}\n    \\tableofcontents\n\\end{frame}\n    \n\n\n\\section{Pre-requisites}\n\n\\begin{frame}[fragile]{The forced Van Der Pol oscillator}\n    \\begin{equation}\n        \\begin{cases}\n            \\dot{x}_1 = 2*x_2 \\\\\n            \\dot{x}_2 = -0.8*x_1 + 2*x_2 + 10*x_1^2*x_2 + u\n        \\end{cases}\n    \\end{equation}\n\n    \\begin{lstlisting}[language=Matlab]\nfunction dxdt = VanDerPol(t,x,u_t,u)\n    % Interpolation just for the sake of indexing\n    u = interp1(u_t,u,t);\n\n    dxdt = [2*x(2);\n            -0.8*x(1)+2*x(2)-10*(x(1)^2)*x(2) + u];\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}{Data generation - Parameters}\n    \\begin{itemize}\n        \\item $T_s = \\SI{1}{\\milli \\second}$\n        \\item $T = \\SI{20}{\\second}$\n        \\item $N_\\text{Sim} = \\num{100}$\n        \\item $\\textbf{u}$: random Gaussian signal with the same sampling rate and length as the simulation\n        \\item $\\sigma = 1$: std deviation of the Gaussian noise\n        \\item $\\mu$: average of the Gaussian noise (randomly selected per trajectory)\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Data generation - Noise as input}\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\nData_Source = \"~/Documents/Thesis/VanDerPol_Unsteady_Input/\";\nts = 1e-3;\nT = 20;\nN_Sim = 40;\n\nu_t = 0:ts:T;\nsigma = 1; % 0 for constant input\nmu = 0;\n\nsystem(\"mkdir -p \"+Data_Source);\ndelete(Data_Source+\"Data_*.mat\");\n\nparfor f=1:N_Sim\n    mu = randn(1); % 0 for zero-mean noise\n    u = sigma^2*randn(size(u_t)) + mu;\n    z0 = 4*rand(2,1) - 2;\n    [~,z] = ode113(@(t,z) VanDerPol(t,z,u_t,u), u_t, z0);\n    \n    z = z';\n    L = length(z)-1;\n    parsave(sprintf(Data_Source+'Data_%i.mat',f),L,z,u,T,ts);\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Polynomial observables}\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\nfunction [g,n] = Poly_Obs(z,P,Nx,Nu)\n    % Number of monomials with degree lesser than P\n    n = factorial(Nx+P)/(factorial(Nx)*factorial(P));\n    g = ones(n+Nu,size(z,2));\n\n    exponents = zeros(n,Nx);\n    current = zeros(1,Nx);\n\n    [exponents,~] = Recursive_Monomial(1,1,exponents,current,P);\n\n    for i=1:n\n        for j=1:Nx\n            g(i,:) = g(i,:).*(z(j,:).^exponents(i,j));\n        end\n    end\n    \n    % Inputs returned as additional observables\n    g(n+1:end,:) = z(Nx+1:end,:);\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Recursive exponent generation}\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\nfunction [exponents,i] = Recursive_Monomial(i,j,exponents,current,P)\n    while sum(current) <= P\n        % Decide wether or not to register the exponent combination only on the deepest level of recursion\n        if j==size(exponents,2)\n            exponents(i,:) = current;\n            i = i+1;\n        else\n            [exponents,i] = Recursive_Monomial(i,j+1,exponents,current,P);\n        end\n\n        % Reset exponent count\n        current(j) = current(j)+1;\n    end\n    current(j) = 0;\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\n\\section{First step: data observables}\n\n\\begin{frame}[fragile]{Data reading \\& Polynomial degree selection}\n    Up to fourth order polynomials used for the presentation (lower order more stable but just as inaccurate).\n\n    \\begin{lstlisting}[language=Matlab, basicstyle=\\tiny]\ndata = dir(Data_Source+\"Data_*.mat\");\nload(Data_Source+data(1).name);\n\nK = 0;\nfor f=1:length(data)\n    load(Data_Source+data(f).name,\"L\");\n    K = K+L;\nend\n\nP = 12;\n[g_t,n] = Poly_Obs(z,P);\n\nPx = zeros(n,K);\nPy = Px;\nZ = zeros(size(z,1),K);\nU = zeros(size(u,1),K);\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Data concatenation}\n    \\begin{lstlisting}[language=Matlab]\nPx(:,1:L) = g_t(:,1:end-1);\nPy(:,1:L) = g_t(:,2:end);\nZ(:,1:L) = z(:,2:end);\nU(:,1:L) = u(:,1:end-1);\n\nidx = L;\nfor f=2:length(data)\n    load(Data_Source+data(f).name);\n    [g_t,~] = Poly_Obs(z,P);\n\n    Px(:,idx+1:idx+L) = g_t(:,1:end-1);\n    Py(:,idx+1:idx+L) = g_t(:,2:end);\n    Z(:,idx+1:idx+L) = z(:,2:end);\n    U(:,idx+1:idx+L) = u(:,1:end-1);\n\n    idx = idx+L;\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\n\\section{Second step: operator matrix}\n\n\\begin{frame}{Matrix calculation - Notation}\n    \\begin{itemize}\n        \\item $\\mathbf{u}\\left[k\\right]$: input vector at sample $k \\in \\left\\{1,\\dots,K+1\\right\\}$.\n        \\item $\\left(\\mathbf{x}\\left[k\\right],\\mathbf{y}\\left[k\\right]\\right)$: state pairs such that, for a generic causal DT system $\\mathbf{x}\\left[k+1\\right] = \\mathbf{T}(\\mathbf{x}\\left[k\\right] , \\mathbf{u}\\left[k\\right])$, $\\mathbf{y}\\left[k\\right] = \\mathbf{T}(\\mathbf{x}\\left[k\\right], \\mathbf{u}\\left[k\\right])$. States are of dimension $N_x$, and the input is of dimension $N_u$.\n        \\item $P_N$: Projection over the N-Dimensional truncated space of observables, where $\\tilde{N} = \\frac{\\left(N_x + P\\right)!}{N_x! P!}$ and $N = \\tilde{N} + N_u$.\n        \\item $p_j$: Monomial observing the original states, with $j \\in {1,\\dots,\\tilde{N}}$.\n        \\item $\\mathbf{P_x},\\mathbf{P_y},\\mathbf{Z}$: State data collections of the form\n            \\begin{align*}\n                \\mathbf{P_x} &= \n                \\begin{pmatrix}\n                    \\mathbf{p}\\left(\\mathbf{x}\\left[1\\right]\\right)   &\n                    \\cdots  &\n                    \\mathbf{p}\\left(\\mathbf{x}\\left[K\\right]\\right)\n                \\end{pmatrix}\n                \\\\\n                \\mathbf{P_y} &= \n                \\begin{pmatrix}\n                    \\mathbf{p}\\left(\\mathbf{y}\\left[1\\right]\\right)   &\n                    \\cdots  &\n                    \\mathbf{p}\\left(\\mathbf{y}\\left[K\\right]\\right)\n                \\end{pmatrix}\n                \\\\\n                \\mathbf{Z} &= \n                \\begin{pmatrix}\n                    \\mathbf{x}\\left[1\\right]    &\n                    \\cdots  &\n                    \\mathbf{x}\\left[K\\right]\n                \\end{pmatrix}\n            \\end{align*}\n        \\item $\\mathbf{U}$: Input data collection of the form $\\begin{pmatrix} \\mathbf{u}\\left[1\\right] & \\cdots & \\mathbf{x}\\left[K\\right] \\end{pmatrix}$.\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Matrix calculation - I}\n\n    We denote the associated Koopman operator with sampling time $T_s$ by $\\mathcal{K}^{T_s}$, derived from the solution to the following minimization problem:\n\n    \\begin{align}\n        P_N & g = \\text{arg min}_{\\tilde{g} \\in \\text{span}\\left\\{p_1 , \\dots , p_N , u_1 , \\dots , u_m\\right\\}} \\sum_{k=1}^K \\left|\\tilde{g}\\left(\\mathbf{x}_k\\right) - g\\left(\\mathbf{x}_k\\right)\\right|^2 \\\\\n        &\\implies P_N g =\n        \\begin{pmatrix}\n            g\\left(\\mathbf{x}_1\\right) &\n            \\cdots &\n            g\\left(\\mathbf{x}_K\\right)\n        \\end{pmatrix}\n        \\begin{pmatrix}\n            \\mathbf{P}_x \\\\\n            \\mathbf{U}\n        \\end{pmatrix}^\\dagger\n        \\begin{pmatrix}\n            \\mathbf{p} \\\\\n            \\mathbf{u}\n        \\end{pmatrix}\\\\\n        & \\implies P_N \\left(\\mathcal{K}^{T_s} p_j\\right) = \\mathbf{p}^T \\mathbf{P_x}^\\dagger\n        \\begin{pmatrix}\n            \\mathcal{K}^{T_s} p_j\\left(\\mathbf{x}_1\\right) \\\\\n            \\vdots \\\\\n            \\mathcal{K}^{T_s} p_j\\left(\\mathbf{x}_K\\right)\n        \\end{pmatrix}\n        \\approx\n        \\begin{pmatrix}\n            p_j\\left(\\mathbf{y}_1\\right) \\\\\n            \\vdots \\\\\n            p_j\\left(\\mathbf{y}_K\\right)\n        \\end{pmatrix}\n        \\begin{pmatrix}\n            \\mathbf{P}_x \\\\\n            \\mathbf{U}\n        \\end{pmatrix}^\\dagger\n        \\begin{pmatrix}\n            \\mathbf{p} \\\\\n            \\mathbf{u}\n        \\end{pmatrix}\n    \\end{align}\n\\end{frame}\n\n\\begin{frame}[fragile]{Matrix calculation - II}\n    We get each row of the truncation (and, by consequence, the whole matrix) as below, where $A$ and $B$ follow the notation from a classical State Space representation:\n\n    \\begin{equation} \\label{eq:Matrix_Operator}\n        \\overline{\\mathcal{K}}_{N,j} \\approx \\mathbf{P}_{y,j} \\begin{pmatrix}\n            \\mathbf{P}_x \\\\\n            \\mathbf{U}\n        \\end{pmatrix}^\\dagger \\implies \\overline{\\mathcal{K}}_N = \n        \\begin{bmatrix}\n            A & B\n        \\end{bmatrix}\n        \\approx \\mathbf{P}_y\n        \\begin{pmatrix}\n            \\mathbf{P}_x \\\\\n            \\mathbf{U}\n        \\end{pmatrix}^\\dagger\n    \\end{equation}\n    \n    We implement Equation~\\ref{eq:Matrix_Operator} as follows:\n\n    \\begin{lstlisting}\n[A,B] = Koopman(Px,Py,U);\n% Generic way to recover original states\nC = Unobserver(Px,Z);\n% Recovery of original states independent from input\nD = zeros(size(Z,1),size(U,1));\nsave(sprintf(Data_Source+'Operator_P_%i.mat',P), ...\n    \"A\",\"B\",\"C\",\"D\",\"ts\");\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Matrix calculation - III}\n    The function \\texttt{Koopman} called above is defined as follows:\n\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\nfunction [A,B] = Koopman(X,Y,U)\n% Following \"Practical Considerations\" from Korda-Mezic\nG = [X;U]*[X;U]';\nV = Y*[X;U]';\nA = zeros(size(Y,1),size(X,1));\nB = zeros(size(Y,1),size(U,1));\n\n%     Matricial division segmented because of memory limits\n%     M0 = V/G;\n%     A = M0(:,1:size(X,1));\n%     B = M0(:,size(X,1)+1:end);\n\nfor i=1:size(Y,1)\n    m0 = V(i,:)/G;\n    A(i,:) = m0(1:size(X,1));\n    B(i,:) = m0(size(X,1)+1:end);\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Spectral analysis - Code}\n    Originally done for DMD purposes, but it keeps being useful for stability analysis.\n\n    \\begin{lstlisting}[language=Matlab]\nLambda = eig(A);\nfigure(1);\nscatter(real(Lambda),imag(Lambda));\nhold on;\nrectangle('Position', [-1 -1 2 2], 'Curvature', 1);\nhold off;\n    \\end{lstlisting}\n\\end{frame}\n\n\n\\section{Third step: trajectory prediction}\n\n\\begin{frame}[fragile]{Training data - Visualization}\n    \\begin{lstlisting}[language=Matlab]\nload(Data_Source+data(1).name);\nL = length(0:ts:T);\n\nmarkerDecay = 0.001;\nfigure(2);\nscatter(z(1,:),z(2,:),36*exp(-markerDecay*(0:L-1)));\nhold on;\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Training data - Trajectory prediction}\n    \\begin{lstlisting}[language=Matlab]\ng_p = zeros(size(g_t,1),L);\n[g_p(:,1),~] = Poly_Obs(z(:,1),P);\n\nfor i=1:L-1\n    g_p(:,i+1) = A*g_p(:,i) + B*u(:,i);\nend\n\nz_p = C*g_p;\n\nscatter(z_p(1,:),z_p(2,:),36*exp(-markerDecay*(0:L-1)));\nlegend(\"Original Data\",\"Trajectory Prediction\");\nhold off;\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{New signal - Data generation}\n    \\begin{lstlisting}[language=matlab]\nT = 20;\n\nz0 = 4*rand(2,1) - 2;\nsigma = randn(1);\nu_t = 0:ts:T;\nu = sigma * cos(u_t);\n\n[t,z] = ode113(@(t,z) VanDerPol(t,z,u_t,u), u_t, z0);\nz = z';\nL = length(0:ts:T);\n\nmarkerDecay = 0.001;\nfigure(1);\nscatter(z(1,:),z(2,:),36*exp(-markerDecay*(0:L-1)));\nhold on;\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{New signal - Trajectory prediction}\n    \\begin{lstlisting}\ng_p = zeros(size(g_t,1),L);\n[g_p(:,1),~] = Poly_Obs(z(:,1),P);\n\nfor i=1:L-1\n    g_p(:,i+1) = A*g_p(:,i) + B*u(:,i);\nend\n\nz_p = C*g_p;\n\nscatter(z_p(1,:),z_p(2,:),36*exp(-markerDecay*(0:L-1)));\nlegend(\"New Simulation\",\"Trajectory Prediction\");\nhold off;\n    \\end{lstlisting}\n\\end{frame}\n\n\n\\section{Alternative Observables}\n\n\\begin{frame}[fragile]{Thin-Plate Spline-Radial functions I}\n    Instead of using polynomials, we can use $\\psi_j \\left(\\mathbf{x}\\right) = \\left|\\left|\\mathbf{x}-\\mathbf{x}_j\\right|\\right|^2 \\log{\\left(\\left|\\left|\\mathbf{x}-\\mathbf{x}_j\\right|\\right|\\right)}$ as basis function, where $\\mathbf{x}_j$ is a bounded random vector of the same dimension as the original states. Since this collection of reference vectors has to be constant once it has been selected, we implement the observables as follows:\n\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\nfunction [g,n] = Spline_Radial_Obs(z,X0)\n    L = size(z,2);\n    n = size(X0,1);\n    N = size(X0,2);\n    \n    % Preservation of original states\n    g = [z;zeros(N,L)];\n\n    for i=1:N\n        x0 = X0(:,i);\n        g(i+n,:) = vecnorm(z-x0).^2 .* log(vecnorm(z-x0));\n    end\n\n    n=n+N;\nend\n    \\end{lstlisting}\n\\end{frame}\n\n\\begin{frame}[fragile]{Thin-Plate Spline-Radial functions II}\n    The following modifications to the code had to be made in order to accommodate the new observables:\n\n    \\begin{lstlisting}[language=Matlab,basicstyle=\\tiny]\n% P = 12;\n% [g_t,n] = Poly_Obs(z,P);\nM = 100;\nX0 = 2*rand(size(z,1),M)-1;\n[g_t,n] = Spline_Radial_Obs(z,X0);\n...\n    %     [g_t,~] = Poly_Obs(z,P);\n    [g_t,~] = Spline_Radial_Obs(z,X0);\n...\n% save(sprintf(Data_Source+'Operator_P_%i.mat',P), ...\n%     \"A\",\"B\",\"C\",\"D\",\"ts\");\nsave(sprintf(Data_Source+'Operator_M_%i.mat',M), ...\n    \"A\",\"B\",\"C\",\"D\",\"ts\",\"X0\");\n...\n% [g_p(:,1),~] = Poly_Obs(z(:,1),P);\n[g_p(:,1),~] = Spline_Radial_Obs(z(:,1),X0);\n    \\end{lstlisting}\n\\end{frame}\n\n\n\\section{Results}\n\n\\begin{frame}{Spectral analysis - Results}\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Eigen_Poly.png}\n            \\caption{Polynomial observables (P=13) - Operator eigenvalues}\n            \\label{fig:eigen_poly}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Eigen_Radial.png}\n            \\caption{Radial observables (M=100) - Operator eigenvalues}\n            \\label{fig:eigen_radial}\n        \\end{subfigure}\n        \\caption{Operator eigenvalues (highest calculated order) - Observable to observable}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Noisy input prediction - Results}\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Training_Poly.png}\n            \\caption{Polynomial observables (P=13) - Predicted trajectory}\n            \\label{fig:training_poly}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Training_Radial.png}\n            \\caption{Radial observables (M=100) - Predicted trajectory}\n            \\label{fig:training_radial}\n        \\end{subfigure}\n        \\caption{Reference and predicted trajectories (highest calculated order) - Training data}\n    \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Deterministic - Results}\n    \\begin{figure}\n        \\centering\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Verification_Poly.png}\n            \\caption{Polynomial observables - Predicted trajectories}\n            \\label{fig:verification_poly}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.45\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{Verification_Radial.png}\n            \\caption{Radial observables}\n            \\label{fig:verification_radial}\n        \\end{subfigure}\n        \\caption{Reference and predicted trajectories - Predicted trajectories}\n    \\end{figure}\n\\end{frame}\n\n\n\\section{Conclusions}\n\n\\begin{frame}{Conclusions}\n    \\begin{itemize}\n        \\item Lower sampling periods have shown to yield a better prediction horizon, since in practice it is bounded by the variations in shape between different trajectories getting wider throughout physical time.\n        \\item A classical optimization approach was implemented as part of the development process; nevertheless, it did not produce different results from the pseudo-inverse approach and instead was not able to keep up with the increase in dimension of the observable space. As a consequence, it was removed.\n        \\item Spline-radial functions yielded an overall better prediction horizon than the polynomial observables, which opens the question of wether or not better observable structures should be researched.\n        \\item Finally, higher-degree observables yielded better approximations of the original system, but required a higher than theoretical data library in order to converge when applying the pseudo-inverse.\n    \\end{itemize}\n\\end{frame}\n\n\\end{document}", "meta": {"hexsha": "9108db8897ebe635ba0e88b5c9364a3ff99da0f6", "size": 16446, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis_Progress/main.tex", "max_stars_repo_name": "sergiovaneg/LaTex_Documents", "max_stars_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis_Progress/main.tex", "max_issues_repo_name": "sergiovaneg/LaTex_Documents", "max_issues_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis_Progress/main.tex", "max_forks_repo_name": "sergiovaneg/LaTex_Documents", "max_forks_repo_head_hexsha": "22daa8196b611089e6753e600c39922c55522d9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-21T14:26:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-21T14:26:02.000Z", "avg_line_length": 31.6269230769, "max_line_length": 443, "alphanum_fraction": 0.6132798249, "num_tokens": 5141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.4140227735051709}}
{"text": "\\section{Implementation}\n\n\\citet{Nakajima2009} developed and published a software that was used for their calculations using SV with leverage~\\citep{nakajima2009code}.\nHowever, that software was written in the proprietary Ox language, which is only freely available with limited features for academic and teaching purposes~\\citep{doornik2009object}.\nThus, apart from investigating the behaviour of leverage, this master thesis also partly aims at providing a freely available solution for fitting SV with leverage.\nThis section provides details and tests about our implementation, which will be published under the GNU GPLv3 License~\\citep{gplv3}.\nIn the meantime, the software is available upon request from the author.\n\n\\subsection{Software framework}\n\nThe software is written mainly in R, and some parts are in C++ via the package Rcpp for the sake of efficiency~\\citep{rlanguage,rcpp2011,iso2016iec}.\nThere are two parts to the software: an R package that provides a function that runs the algorithm detailed in Section~\\ref{sec:estimlev}, and a set of individual R scripts that apply that function on data, evaluate results and create plots.\nOther packages used for the model are numDeriv, Matrix, testthat, mvtnorm and MCMCpack.\nFor data manipulation and visualisation the tidyverse is used~\\citep{rmcmcpack,rtestthat,rmatrix,rnumderiv,rmvtnorm,rtidyverse}.\n\n\\subsection{Simulation}\\label{sec:simulation}\n\nThe main task of the software is to estimate leverage, thus tests were centred around different simulated values of $\\rho$.\nThe seven setups that are detailed here all had the same settings except for the simulated value of $\\rho$:\n\\begin{description}\n\t\\item[``True'', simulated values]\n\t\\begin{align*}\n\t\\phi &= 0.95, \\\\\n\t\\sigma^2 &= 0.01, \\\\\n\t\\mu &= -9, \\\\\n\tT &= 1000,\n\t\\end{align*}\n\t\\begin{equation*}\n\t\\rho\\in[-0.9,-0.6,-0.3,0,0.3,0.6,0.9].\n\t\\end{equation*}\n\t\\item[Prior distributions]\n\t\\begin{align*}\n\t\\frac{\\phi+1}2 &\\sim\\text{Beta}(20,1.5), \\\\\n\t\\sigma^2 &\\sim\\text{InverseGamma}(2.25,\\text{rate}=0.0625), \\\\\n\t\\rho &\\sim\\mathcal{U}(-1,1), \\\\\n\t\\mu &\\sim\\mathcal{N}(-9,1), \\\\\n\th_1\\mid\\phi,\\sigma,\\mu &\\sim\\mathcal{N}(\\mu,\\sigma^2/(1-\\phi^2)).\n\t\\end{align*}\n\\end{description}\nThe simulated true values used here are similar to the ones found in the literature~\\citep{Omori2007,Kastner2014}.\nVariance is usually highly persistent and has a mean about $\\exp(-9/2)\\approx 1\\%$, these are encoded both in the simulated value and the prior.\nThe chosen prior for $\\sigma^2$ has mean 0.05 and standard deviation 0.1, so the prior is not too far from the simulated value.\nThe latent vector is initialised by $h_1$, and its prior is chosen to be the stationary distribution of the AR(1) process that models $\\bm h$.\nFinally, we check a wide range of $\\rho$ values, and $\\rho$'s prior is intended to be non-informative.\n\nThe simulation was based on model~\\eqref{form:orig_model}.\nAll the parameters and $h_1$ need to be initialised, and a realisation of the two white-noise processes has to be generated.\nFinally, after substituting the parameters and the errors into the model, $\\bm h$ and $\\bm y$ are acquired.\n\nFigure~\\ref{fig:simdata} illustrates the simulated dataset, the price process and the latent volatility process, with three chosen values of $\\rho$.\nIt also demonstrates how the different correlation signs affect the directly observable relationship.\nHigh values of $\\rho$ make the price process and the volatility do mirrored changes, while low values imply parallel movements.\n\nFigure~\\ref{fig:volatility} presents how the posterior variance fits the simulated variance.\nIn general, comovement of the posterior median with the simulated values is observed, and stronger correlation seemingly brings better fit.\nThat result is not surprising since, intuitively, there is less information in the directly measured return series about the variance when correlation is low.\n\nThere are three distributions corresponding to each parameter in the current estimation method: the prior, the approximate posterior and the corrected posterior.\nFigure~\\ref{fig:rhodensities} shows these and the simulated value for $\\rho$.\nFor low absolute values, the correction outlined in Section~\\ref{sec:reweight} has quite low impact, the difference is invisible on the plot, but it is larger for more extreme $\\rho$.\nAlthough the ``true'' value is in the 5\\%-95\\% credible interval in each case, the posterior is closer to the simulated value for negative $\\rho$.\n\n\\begin{figure}\n\t\\thisfloatpagestyle{empty}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{simulations/data-plot.pdf}\n\t\\caption[Simulated price process and standard deviation]{Simulated price process scaled to 0.03 and its return's standard deviation.\n\t\tTop: with high negative correlation, the price process and the volatility move to the opposite direction.\n\t\tMiddle: with no correlation, there is no visible pattern.\n\t\tBottom: with high positive correlation, the price process and the volatility move together.}\n\t\\label{fig:simdata}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{simulations/variance-plot.pdf}\n\t\\caption{Simulated values and posterior quantiles of the variance process.}\n\t\\label{fig:volatility}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{simulations/rho-densities.pdf}\n\t\\caption[Prior, approximate and true posteriors, and simulated $\\rho$]{Prior, approximate and corrected posterior distributions, and the simulated value for $\\rho$.}\n\t\\label{fig:rhodensities}\n\\end{figure}\n", "meta": {"hexsha": "4661c817fbfcc117a17143511c2cbb8e1c8527b8", "size": 5521, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/sections/implementation.tex", "max_stars_repo_name": "hdarjus/master-thesis", "max_stars_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-23T12:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-23T12:51:22.000Z", "max_issues_repo_path": "thesis/sections/implementation.tex", "max_issues_repo_name": "hdarjus/master-thesis-WU", "max_issues_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/sections/implementation.tex", "max_forks_repo_name": "hdarjus/master-thesis-WU", "max_forks_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-12T00:39:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-12T00:39:19.000Z", "avg_line_length": 63.4597701149, "max_line_length": 241, "alphanum_fraction": 0.7761275131, "num_tokens": 1412, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.41402276995444975}}
{"text": "\\documentclass[11pt, twocolumn]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage[a4paper, total={7in, 9in}]{geometry}\n\n\n\\title{Probability Cheatsheet}\n\\author{Yahya~Almardeny\\\\almardeny@gmail.com}\n\\date{June 2019}\n\n\\begin{document}\n\\begin{titlepage}\n\\maketitle\n\\end{titlepage}\n\n\\section{Overview}\nProbability provides measures for reasoning the likelihood that an event will occur in an experiment.\n\\section{Terminology}\n\\begin{enumerate}\n\\item \\textbf{Experiment}: Procedure that yields one of the possible outcomes. E.g. Tossing a coin.\n\\item \\textbf{Sample Space S}: A set of all possible outcomes of an experiment. E.g. S = \\{Head, Tail\\} when tossing a fair coin.\n\\item \\textbf{Event E}: Set of outcomes of an experiment. Note that if the Event contains only one outcome, it is then called an elementary event. E.g. The event that coin is Head.\n\\end{enumerate}\n\\section{Random Variable R.V}\nA variable that its possible values are the outcomes of an experiment. It has two types:\n\\begin{enumerate}\n\\item \\textbf{Discrete R.V}: Take one countable number of distinct values. E.g 1, 2, 3, 4\n\\item \\textbf{Continuous R.V}: Take infinite number of possible values (usually measurements). E.g. all interval values in the range [1 - 2].\n\\end{enumerate}\n\n\\section{Probability of Events}\n\\begin{enumerate}\n\\item \\textbf{Marginal probability}: Simply $P(A)$ which means \"unconditional probability\". And for each outcome $s$, it should satisfy: $ 0 \\leq P(s) \\leq 1$ and $\\Sigma P(s_i) = 1$.\n\\item \\textbf{Addition Rule}: $P(A \\cup B) = P(A) + P(B) - P(A \\cap B)$ where $\\cup$ means OR, $\\cap$ means AND.\n\\item \\textbf{Joint (Compound) Probability Rule}:\n\t\\begin{enumerate}\n\t\\item Independent Events: $P(A \\cap B) = P(A) \\times P(B)$.\n\t\\item Dependent Events: $P(A \\cap B) = P(A) \\times P(B | A)$. where $P(B | A)$ read: Probability of B given A had happened.\n\t\\end{enumerate}\n\\item \\textbf{Conditional Probability}: $P(A | B) = \\frac{P(A \\cap B)}{P(B)}$\n\\item \\textbf{Bayes Theorem}: $P(A | B) = \\frac{P(B | A) \\times P(A)}{P(B)}$. It gives the probability of A based on prior knowledge of B.\n\\end{enumerate}\n\n\\section{Probability Distributions}\n\\begin{enumerate}\n\\item \\textbf{Probability Mass Function (PMF)}: Gives the probability a \\textit{discrete} R.V $X$ takes on the value $x$: $P( X = x)$.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=0.7\\linewidth]{figs/PMF.png}\n\\end{figure}\n\\item \\textbf{Probability Density Function (PDF)}: Gives the probability a \\textit{continuous} R.V $X$ takes on the value $x$: $P( X = x)$ which means how dense the probability of $X$ near $x$, and it will be the definite Integrals between two points.\n\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=0.6\\linewidth]{figs/PDF.png}\n\\end{figure}\n\\item \\textbf{Cumulative Density Function (CDF)}: Gives the probability a R.V $X$ is less than or equals the value $x$: $P( X \\leq x)$. It is  cumulative because it adds the probabilities up to $x$.\n\t\\begin{enumerate}\n\t\\item For Discrete R.V: It is the summation of previous probabilities $\\Sigma p(x_i)$.\n\t\\item For Continuous R.V: It is the integral $\\int_{-\\infty}^{x} p(x) dx$\n\t\\end{enumerate}\n\\end{enumerate}\n\n\\section{Expected Value of R.V}\nIntuitively, it is the long-run average value of repetitions of the same experiment it represents (i.e. what outcome to expect on long run)\n\\begin{enumerate}\n\\item \\textbf{For a Discrete R.V}: It is the average of R.V values based on their associated probabilities $E(X) = \\Sigma (x_i \\times p(x_i))$.\n\\item \\textbf{For a Continuous R.V}: $E(X) = \\int_{-\\infty}^{\\infty} x f(x) dx$ where $f(x)$ is probability density function.\n\\end{enumerate}\n\n\\section{Combining Random Variables}\nIf we have two independent random variables $X$ and $Y$, we can add or subtract to get the total or the difference of their means (expected values) and variances:\n$T = X \\pm Y \\Rightarrow \\mu_T = \\mu_X \\pm \\mu_Y  ~~ and ~~ \\sigma_T^2 = \\sigma_X^2 \\pm \\sigma_Y^2$.\n\n\\section{The Law of Large Numbers}\nLet $X$ be R.V of a population where its expected value (i.e Mean) is $E(X)$. Let $\\overline{X_n} = \\frac{x_1 + x_2 + ... x_n}{n}$ be the mean of $n$ samples $\\in X$. As $n \\to \\infty$ : $\\overline{X_n} \\to E(X)$. Which means as we do more experiments, the outcomes become closer and closer to the outcomes of the probability theory.\n\n\\section{Statistical Distributions}\\footnote{Included because it is related directly to probability}\n\\begin{enumerate}\n\\item \\textbf{Binomial Distribution}: How many success in finite number of trials:\n\t\\begin{itemize}\n\t\\item Made up of \\textit{independent} trials.\n\t\\item Each trial has one of two \\textit{discrete} outcomes (success or failure).\n\t\\item \\textit{Fixed} number of trials\n\t\\item Probability of success in each trial is \\textit{constant}.\n\t\\item E.g. X = number of heads after 10 flips of a coin.\t\n\t\\item \\textit{10\\% Rule}: We assume independence if the sample $\\leq$ 10\\% of the population.\n\t\\item PMF: $P(X = x) = (_{n}^{k}) p^x (1 - p)^{n-x}$ which means the probability of $k$ successes in $n$ trials.\n\t\\item $E(X) = \\mu_X = n . p$ where $p$ is the probability of success per trial.\n\t\\item $\\sigma_X = \\sqrt{var(X)} = \\sqrt{n . p (1 - p)}$.\n\t\\item The more trials we do, the more Binomial becomes Normal distribution.\n\t\\end{itemize} \n\n\\item \\textbf{Bernoulli Distribution}: Simply a Binomial Distribution with just \\textit{one} trial. \n\\item \\textbf{Geometric Distribution}: How many trials until success?. It is similar to Binomial dist. but here we do not have fixed number of trials because we do not know ahead how many trials until we get the desired outcome:\n\t\\begin{itemize}\n\t\\item PMF: $P(X = x) = (1 - p)^{k - 1} p$.\n\t\\item $E(X) = \\mu_X = \\frac{1}{p}$.\n\t\\item $\\sigma_X = \\sqrt{var(X)} = \\sqrt{\\frac{1 - p}{p^2}}$.\n\t\\end{itemize} \n\n\\item \\textbf{Hypergeometric Distribution}: It is a \\textit{discrete} probability distribution that describes the probability of $k$ successes in $n$ draws, \\textit{without} replacement, from a finite population of size $N$ that contains exactly $K$ objects. In contrast, the binomial distribution describes the probability of $k$ successes in $n$ draws \\textit{with} replacement. \n\t\n\\item \\textbf{Poisson Distribution}: It is a \\textit{discrete} probability distribution that predicts \\textit{rare} events that are independent of one another and occur with a known constant rate $\\lambda$. It is usually used instead of Binomial dist. if the number of trials is very high (fixed interval of time) and the probability (occurrence) of each is relatively low:\n\t\\begin{itemize}\n\t\\item PMF: $P\\left( x \\right) = \\frac{{\\lambda ^x }}{{x!}} e^{ - \\lambda } $.\n\t\\item Mean is $E(X) = \\lambda$. and Variance is $\\lambda$.\n\t\\end{itemize} \n\n\\item \\textbf{Normal Distribution (a.k.a Gaussian)}: It is a \\textit{continuous} probability distribution that has the notation  $X \\sim \\mathcal{N}(\\mu,\\,\\sigma^{2})$. It is symmetric and has a bell shape where most of the values are near to the mean and follows the 68–95–99.7 rule (a.k.a empirical rule). This rule states that 68.27\\%, 95.45\\% and 99.73\\% of the values lie within one, two and three standard deviations of the mean, respectively:\n\t\\begin{itemize}\n\t\\item PDF: $P(x) = \\frac{1}{{\\sigma \\sqrt {2\\pi } }}e^{{{ - \\left( {x - \\mu } \\right)^2 } \\mathord{\\left/ {\\vphantom {{ - \\left( {x - \\mu } \\right)^2 } {2\\sigma ^2 }}} \\right. \\kern-\\nulldelimiterspace} {2\\sigma ^2 }}}$.\n\t\\item Mean is $E(X) = \\mu_X$. and Variance is $\\sigma_X^2$.\n\t\\end{itemize} \n\t\n\\item \\textbf{Log-Normal Distribution}: It is a \\textit{continuous} probability distribution of a random variable whose \\textit{logarithm is normally distributed}.Because the values in a log-normal distribution are positive, they create a right-skewed curve which is important in determining which distribution is appropriate to use in investment decision-making.  One of the most common applications of log-normal distributions is in the analysis of stock prices. A log-normal distribution can be translated to a normal distribution and vice versa using associated logarithmic calculations.\n\t\n\\item \\textbf{Uniform Distribution}: It is a probability distribution that has \\textit{constant} probability. \n\t\\begin{enumerate}\n\t\\item \\textit{Discrete Uniform Dist.}:  It takes one of a finite $n$ possible values:\n\t\t\\begin{itemize}\n\t\t\\item PMF: $P(X = x) = \\frac{1}{n}$\n\t\t\\item $E(X) = \\mu_X = \\frac{(a + b)}{2}$\n\t\t\\item $\\sigma_X^2 =\\frac{(b - a + 1)^2 ~ - 1 }{12}$\n\t\t\\end{itemize} \n\n\t\\item \\textit{Continuous Uniform Dist.}: It takes values within a specified range $a$ to $b$:\n\t\t\\begin{itemize}\n\t\t\\item PDF:\n\t\t\\begin{align*}\n\t\t\tP(X = x) = \\begin{cases}  \\frac{1}{b-a}~ if ~ x \\in [a , b]\\\\ 0 ~ otherwise \\end{cases}\n\t\t\\end{align*}\n\t\t\\item $E(X) = \\mu_X = \\frac{1}{2} (a+b)$\n\t\t\\item $\\sigma_X^2 =\\frac{1}{12} (b - a)^2 $\n\t\t\\end{itemize} \n\n\t\\end{enumerate}\n\n\\item \\textbf{Gamma Distribution}: It is a family of a \\textit{continuous}, \\textit{positive-only}, \\textit{unimodal} distributions that encode the time required for $alpha$ events to occur in a Poisson process with mean arrival time of $beta$. These distributions are useful in real-life where something has a natural minimum of $0$. For example, it is commonly used in finance, for elapsed times, or during Poisson processes. In other words, it is a generalization of both the exponential and chi-squared distributions.\n\t\t\n\\item \\textbf{Exponential Distribution}: Special case of Gamma Distribution. It is a \\textit{continuous} analogue of the geometric distribution and often used to model the time elapsed between events. Formally, it is the probability distribution of the time between events in a process where events occur continuously and independently at a \\textit{constant} average rate (i.e. Poisson process):\n\t\t\\begin{itemize}\n\t\t\\item PDF: $P(X = x) = {\\lambda e}^{-\\lambda x}$\n\t\t\\item $E(X) = \\mu_X = \\lambda^{-1} = \\beta$\n\t\t\\item $\\sigma_X^2 =\\lambda^{-2} = \\beta^2$\n\t\t\\end{itemize} \n\n\\item \\textbf{Chi-Square Distribution}:  It is a special case of the Gamma distribution. It is a \\textit{continuous} distribution of a sum of the squares of $k$ independent standard normal deviates (where $k$ is known as degree of freedom).  A standard normal deviate is a \\textit{random sample} from the standard normal distribution.\n\t\t\\begin{itemize}\n\t\t\\item PDF: $P(X = x) = {\\frac{1}{2^{\\frac{k}{2}}\\Gamma(\t\\frac{K}{2})}}^{x^{\\frac{k}{2}-1}~e^{\\frac{-x}{2}}}$ where $\\Gamma$ is the gamma function\n\t\t\\item $E(X) = \\mu_X = k$\n\t\t\\item $\\sigma_X^2 = 2k$\n\t\t\\end{itemize} \n\t\n\\item \\textbf{Student's t-Distribution}:  It is a probability distribution used to estimate population parameters when the sample size is small and standard deviation is unknown. It is mainly used by applying Student's t-test for assessing the statistical significance of the difference between two sample means, and in linear regression analysis. \n\t\t\\begin{itemize}\n\t\t\\item PDF: $$ \\frac{\\Gamma (\\frac{\\nu+1}{2})}{\\sqrt{\\nu \\pi} \\Gamma (\\frac{\\nu}{2})} (1 + \\frac{x^2}{\\nu})^{-\\frac{\\nu+1}{2}}\n$$ where $\\nu$ is the number of degrees of freedom and $\\Gamma$ is the gamma function.\n\t\t\\item $E(X) = \\mu_X = \t0 ~ for ~ \\nu > 1,$ otherwise undefined.\n\t\t\\item $\\sigma_X^2 = \\frac{\\nu }{\\nu -2} ~for~ \\nu >2, ~\\infty ~for~ 1 < \\nu \\le 2,$ otherwise undefined.\n\t\t\\end{itemize} \n\\end{enumerate}\n\n\\end{document}\n\n\n\n\n\n\n", "meta": {"hexsha": "05b85cae6aac6e9be863cbf2e2017edaab1101dd", "size": 11350, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Probability/Beginner_Probability_Cheatsheet_Based_On_Khan_Academy_Vids/Probability_Cheatsheet.tex", "max_stars_repo_name": "datablazor/Data_Science_Machine_Learning_and_AI_Cheat_Sheets", "max_stars_repo_head_hexsha": "b6e047a10e182387584094d1aec2ce2556733a45", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-15T21:40:09.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-31T11:54:32.000Z", "max_issues_repo_path": "kaggle/Probability/Beginner_Probability_Cheatsheet_Based_On_Khan_Academy_Vids/Probability_Cheatsheet.tex", "max_issues_repo_name": "caroheymes/Cheat_Sheets", "max_issues_repo_head_hexsha": "5def52a06bfec30520bd87300795604eee0f5223", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "kaggle/Probability/Beginner_Probability_Cheatsheet_Based_On_Khan_Academy_Vids/Probability_Cheatsheet.tex", "max_forks_repo_name": "caroheymes/Cheat_Sheets", "max_forks_repo_head_hexsha": "5def52a06bfec30520bd87300795604eee0f5223", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.988372093, "max_line_length": 591, "alphanum_fraction": 0.7083700441, "num_tokens": 3459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.4140227664037287}}
{"text": "\\documentclass[10pt,letterpaper]{article}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{outlines}\n\\usepackage{amsmath}\n\\usepackage{tikz}\n\\usepackage{hyperref}\n\\usepackage{enumitem}\n\\usepackage{cancel}\n\\usepackage{subcaption}\n\\DeclareCaptionOptionNoValue{centering}{\\centering} % Make sure everything is centered in subs\n\\captionsetup[sub]{centering}\n\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\usepackage{multirow}\n\\usepackage{cancel}\n\\usepackage{float}\n\n\\usepackage{parskip}\n\n\\usepackage{slantsc,lmodern}\n\n\\usepackage{pgfplotstable,booktabs}\n\\usepackage{framed}\n\\definecolor{shadecolor}{rgb}{0.9,0.9,0.9}\n\n\\usepackage{gensymb}\n\n\\usepackage{paralist}\n\n\\usepackage[paper=a4paper,margin=1in]{geometry}\n\n\\usepackage{etoolbox}\n\n\\newcommand{\\volume}{{\\ooalign{\\hfil$V$\\hfil\\cr\\kern0.08em--\\hfil\\cr}}}\n\n\\makeatletter\n\\g@addto@macro\\@floatboxreset\\centering\n\\makeatother\n\n\\author{Thaddeus Hughes \\\\ hughes.thad@gmail.com \\\\ thaddeus-maximus.github.io}\n\\date{\\today}\n\\title{Documentation and Validation of EveryCalc's Trajectory Tool}\n\n\n\n\\begin{document}\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\tHurling projectiles is something we humans really like doing. We've become exceedingly efficient at it. We make sport of it. We can guess at a trajectory pretty easily- but nailing it down, and tweaking it with an engineering mindset is harder. Lots of tools already exist to do this but I want to roll my own so I can add all the physics I want, along with the swept area of a projectile, and stacking the tolerance.\n\t\\end{abstract}\n\t\n\\section{Basic Projectile Motion}\n\tConsider a ball of mass $m$, in a vacuum. It has only the force of gravity acting on it. That is to say,\n\n\t\\begin{align}\n\t\t\\Sigma F_x &= m \\frac{d v_x}{d t} = 0 \\\\\n\t\t\\Sigma F_y &= m \\frac{d v_y}{d t} = - m g\n\t\\end{align}\n\n\tTo figure out the path, we'd also need to know the initial conidtions. Let's also say that the ball was launched at an angle $\\theta$ from the horizontal at an initial velocity of $\\bar{v}_0$, so that the x- and y- velocities would be\n\t\\begin{align}\n\t\tv_x(0) &= \\bar{v}_0 \\ cos(\\theta) \\\\\n\t\tv_y(0) &= \\bar{v}_0 \\ sin(\\theta) .\n\t\\end{align}\n\n\tWe'll start from a height of $y_0$ and at $x=-x_0$ from our target.\n\n\t\\begin{align}\n\t\tx(0) = -x_0 \\\\\n\t\ty(0) = -y_0 \n\t\\end{align}\n\n\tThis is enough to get us a very simple simulation for projectile motion:\n\n\t\\begin{align}\n\t\t\\frac{d v_x}{d t} &= 0 \\\\\n\t\t\\frac{d v_y}{d t} &= - g \\\\\n\t\t\\frac{d x}{d t} &= v_x \\\\\n\t\t\\frac{d y}{d t} &= v_y \\\\\n\t\tv_x(0) &= \\bar{v}_0 \\ cos(\\theta) \\\\\n\t\tv_y(0) &= \\bar{v}_0 \\ sin(\\theta) \\\\\n\t\tx(0) &= -x_0 \\\\\n\t\ty(0) &= y_0 \\\\\n\t\t\\text{terminate when } x &\\geq 0\n\t\\end{align}\n\n\\section{Swept Path with Parallel Curves}\n\tIt's also worth knowing the swept zone that the target travels, since the object of firing a projectile may not be to hit a target per se, but to make it \\textit{through} a target. This may seem like a trivial task at first blush; just add on the radius of the ball to the y-direction, but then one realizes the projetile may not be striking the target dead-on. Creating an offset path, or \\href{https://en.wikipedia.org/wiki/Parallel_curve}{parallel curve} is necessary. The upper swept path ($x_u$, $y_u$) of a ball of radius $r$ can be determined as\n\n\t\\begin{align}\n\t\tx_u = x + r (\\hat{x} \\cdot \\hat{N}) \\\\\n\t\ty_u = y + r (\\hat{y} \\cdot \\hat{N})\n\t\\end{align}\n\n\tWhere $\\hat{x}$, $\\hat{y}$, $\\hat{N}$, $\\hat{T}$ are unit vectors in the x-, y-, normal, and tangent directions.\n\n\t\\begin{align}\n\t\t\\text{let } \\bar{v} &= \\sqrt{v_x^2 + v_y^2} \\\\\n\t\t\\hat{x} \\cdot \\hat{N} &= - v_x / \\bar{v} \\\\\n\t\t\\hat{x} \\cdot \\hat{T} &= + v_y / \\bar{v} \\\\\n\t\t\\hat{y} \\cdot \\hat{N} &= + v_x / \\bar{v} \\\\\n\t\t\\hat{y} \\cdot \\hat{T} &= + v_y / \\bar{v}\n\t\\end{align}\n\n\tThe lower path would be found by reversing the direction of $r$, yielding\n\t\n\t\\begin{align}\n\t\tx_l &= x - r (\\hat{x} \\cdot \\hat{N}) \\\\\n\t\ty_l &= y - r (\\hat{y} \\cdot \\hat{N}) .\n\t\\end{align}\n\n\\section{Aerodynamic Effects}\n\tThere are multiple aerodynamic forces that can act on a ball.\n\n\t\\begin{align}\n\t\tF_{drag}   &= \\frac{1}{2}   \\ C_{drag} \\ \\rho \\ A \\ \\bar{v}^2 \\\\\n\t\tF_{lift}   &= \\frac{1}{2}   \\ C_{lift} \\ \\rho \\ A \\ \\bar{v}^2 \\\\\n\t\tF_{magnus} &= \\frac{\\pi}{3} \\ C_{magnus} \\ \\rho \\ A \\ \\bar{v} \\ \\omega_{\\text{+ccw}}\n\t\\end{align}\t\n\n\tThe lift and drag forces are standard equations, but the magnus force equation is derived from \\href{https://www.grc.nasa.gov/WWW/K-12/airplane/beach.html}{\\underline{this NASA page}}. There are undoubtedly better models out there, but this is what I have currently.\n\n\tIn vector form the conservation of momentum could be written as\n\n\t\\begin{align}\n\t\tm \\frac{d \\vec{v}}{d t} = - F_{drag} \\hat{T} + F_{lift} \\hat{N} + F_{magnus} \\hat{N} - m g \\hat{y}\n\t\\end{align}\n\n\tThis changes the model, when projected out into the x- and y- components to\n\n\t\\begin{align}\n\t\t\\frac{d v_x}{d t} &= \\frac{- F_{drag} (\\hat{x} \\cdot \\hat{T}) + F_{lift} (\\hat{x} \\cdot \\hat{N}) + F_{magnus} (\\hat{x} \\cdot \\hat{N})}{m}\\\\\n\t\t\\frac{d v_y}{d t} &= \\frac{ - F_{drag} (\\hat{y} \\cdot \\hat{T}) + F_{lift} (\\hat{y} \\cdot \\hat{N}) + F_{magnus} (\\hat{y} \\cdot \\hat{N})}{m} - g \\\\\n\t\t\\frac{d x}{d t} &= v_x \\\\\n\t\t\\frac{d y}{d t} &= v_y \\\\\n\t\tv_x(0) &= \\bar{v}_0 \\ cos(\\theta) \\\\\n\t\tv_y(0) &= \\bar{v}_0 \\ sin(\\theta) \\\\\n\t\tx(0) &= -x_0 \\\\\n\t\ty(0) &= y_0 \\\\\n\t\t\\text{terminate when } x &\\geq 0 .\n\t\\end{align}\n\n\\section{Tolerance Stacking}\n\tTo determine accuracy, multiple iterations of the simulation can be ran with different permutations of input variables.\n\n\\section{Reverse Computation}\n\tA \\href{https://en.wikipedia.org/wiki/Bisection_method}{\\underline{bisection algorithm}} is used to solve for the appropriate distance/angle/velocity required to propel the projectile into the target. This has benefits over analytical solutions in that it can be used in conjunction with aerodynamic effects.\n\n\\section{Validation Against Other Tools}\n\n\tI'll compare results to \\href{https://www.chiefdelphi.com/t/amb-design-spreadsheet-v5/383857}{\\underline{AMB's Design Spreadsheet}}.\n\n\t\\newpage\n\t\\subsection*{Case A: Metric units, no aero}\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.8\\textwidth]{validation/trajectory_AMB_A.png}\n\t\\end{figure}\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.65\\textwidth]{validation/trajectory_EC_A.png}\n\t\\end{figure}\n\n\tLook only at the \"Forward\" portions of AMB's sheet. Effectively the same result.\n\n\t\\newpage\n\t\\subsection*{Case B: English units, drag included}\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.8\\textwidth]{validation/trajectory_AMB_B.png}\n\t\\end{figure}\n\n\t\\begin{figure}[H]\n\t\t\\includegraphics[width=0.65\\textwidth]{validation/trajectory_EC_B.png}\n\t\\end{figure}\n\n\tLook only at the \"Forward\" portions of AMB's sheet. Effectively the same result.\n\t\n\\end{document}", "meta": {"hexsha": "214b79bb6f6f2ff091a02eea95d7b524c3b58dbf", "size": 6770, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/trajectories.tex", "max_stars_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_stars_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-04-27T03:38:12.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T22:52:39.000Z", "max_issues_repo_path": "docs/trajectories.tex", "max_issues_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_issues_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 50, "max_issues_repo_issues_event_min_datetime": "2020-03-22T15:43:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-10T01:40:08.000Z", "max_forks_repo_path": "docs/trajectories.tex", "max_forks_repo_name": "Thaddeus-Maximus/swissarmyengineer", "max_forks_repo_head_hexsha": "3b2a289bc91ce5013b02149681a118d511e7610a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7934782609, "max_line_length": 553, "alphanum_fraction": 0.6847858198, "num_tokens": 2293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.41402276317270237}}
{"text": "\n\\chapter{First principle methods}\n\n\nIn this section we present our proposed methods for causal inference in the \nbivariate setting: The twin test and the residual method. We will introduce each method, \nprovide a detailed algorithmic description and end by giving a proof of correctness. \n\n\n\\section{The twin test}\n\nLet us recall the setup: \nsuppose we are given samples $\\mathcal{D} = \\{x_i, y_i\\}_{i \\in [n]}$ from an ANM $X \\rightarrow Y$, which has the form\n\n\\[\n    \\begin{cases} \n        & Y = f(X) + Z \\\\\n        & X \\bigCI Z,\\quad X \\thicksim P_X,\\quad Z \\thicksim P_{Z}  \n     \\end{cases}  \n\\]\n\nThe main strategy of of the ANM methods has been to estimate $f$, and then to compute the estimated\nresidual $\\hat{\\mathbf{e}} = \\hat{f}(\\mathbf{x}) - \\mathbf{y}$; the final step is to test the independence between $\\hat{\\mathbf{e}}$ and $\\mathbf{x}$. This exploits \nthe assumption that $X \\bigCI Z$. In practice we often have that the noise is \\textit{independent} between each sample\ni.e. we produce a sequence $Y_1, ..., Y_n$, where $Z_i \\bigCI Z_j$ $\\forall i \\neq j$; for example when we are \ntaking measurements, the additive noise of our devices tends to be independent between each sample.\n\nBy directly exploiting the i.i.d noise assumption, we will circumvent the need for an independence test. The \nidea is to to partition the data ---  for simplicity you can think about splitting it around the median; we \nthen estimate the residuals for each partition, and we then test if the i.i.d noise assumption holds by comparing\nthe residuals of each partition. We can apply this procedure to both directions and then we will call the \ndirection causal if its residuals are more similar. \n\nWe explain this idea in more detail by following an example: we are given samples \n$\\mathcal{D} = \\{x_i, y_i\\}_{i \\in [n]}$ from an ANM $X \\rightarrow Y$; \nWe first visualize the data $\\{x_i, y_i\\}_{i \\in [n]}$, by plotting\nX to Y, and vice versa (see Figure \\ref{fig:algo_data}). \n\n\\begin{figure}[H]\n    \\captionsetup[subfigure]{labelformat=empty}\n    \\centering\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_direct.png} }}%\n    % \\quad\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_reverse.png} }}%\n\n    \\caption{300 samples of data $X$, $Y$. With \\textbf{ANM}: \\\\\n    $f(x) = \\tanh(x) + 2\\sin(2x) + x^3$}\n    $X \\thicksim \\mathcal{U}_{[-a, a]}$ and $Z \\thicksim \\mathcal{N}(0, \\sigma^2)$\n    \\label{fig:algo_data}\n\\end{figure}\n\n\n\nFor simplicity assume $X \\thicksim \\mathcal{U}_{[-a, a]}$ (i.e. $X$ is uniformly disributed), then we can split \nthe data in two\\footnote{ The question of how to split the data is important, and we will address this problem in \nmore detail later, but for now, given the assumptions, splitting it in half is not such a bad idea; another \nquestion one might ask is the following: how many intervals? We will clarify all this later.}\n, say $D_1$ and $D_2$, where we place all samples with $x_i < 0$ into $D_1$, and the rest into \n$D_2$. To be more precise, $\\mathcal{D}_1 = \\{(x_i, y_i) : x_i < 0\\}$ and $\\mathcal{D}_2 = \\mathcal{D} \n\\backslash \\mathcal{D}_1$. We also do the same procedure for the reverse set up, i.e. we reverse the roles of x and y\n, $\\mathcal{\\tilde{D}} = \\{y_i, x_i\\}_{i \\in [n]}$ and by the same procedure we obtain $\\mathcal{\\tilde{D}}_1$\nand $\\mathcal{\\tilde{D}}_2$. We can visualize this partition bellow in Figure \\ref{fig:colo_code}.\n \n\\begin{figure}[H]\n    \\captionsetup[subfigure]{labelformat=empty}\n    \\centering\n    \\subfloat[Partitions $D_1$ and $D_2$]{{\\includegraphics[width=6.5cm]{algo_part.png} }}%\n    % \\quad\n    \\subfloat[Partitions $\\mathcal{\\tilde{D}}_1$ and $\\mathcal{\\tilde{D}}_2$]{{\\includegraphics[width=6.5cm]{algo_part_reverse.png} }}%\n    \\caption{ We highlight each partition in a different color. On the left we have $D_1$ and $D_2$; and on \n    the right we have $\\mathcal{\\tilde{D}}_1$ and $\\mathcal{\\tilde{D}}_2$ }\n    \\label{fig:colo_code}\n\\end{figure}\n\nIf we estimate a fit $\\hat{f}_1$ for $\\mathcal{D}_1$ and similarly $\\hat{f}_2$ for $\\mathcal{D}_2$, then we can \ncompute residuals for each sets, say $\\hat{e}_1$ for $\\mathcal{D}_1$  and $\\hat{e}_2$ for $\\mathcal{D}_2$.\nSince the noise is ---  not only independent from $X$ but also ---  i.i.d, it follows that $\\hat{e}_1$ and $\\hat{e}_2$\nfollow the same distribution ---  assuming a perfect fit $f$. We can visualize this by looking at the \nhistograms from the residuals.\n\n\\begin{figure}[H]\n    \\captionsetup[subfigure]{labelformat=empty}\n    \\centering\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_fit_direct.png} }}%\n    % \\quad\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_fit_reverse.png} }}%\n    % \\caption{Samples from two different sources, $X$ and $Y$, how can we tell if \n    % they come from the same distribution?}\n    \\\\\n\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_res_direct.png} }}%\n    % \\quad\n    \\subfloat{{\\includegraphics[width=6.5cm]{algo_res_reverse.png} }}%\n\n    \\caption{  We show the the estimated fits $\\hat{f}$ for each partition in black. Below each \n    partition we plot the histograms of the residuals ---  in the same color. }\n    \\label{fig:algo_fit}\n\\end{figure}\n\nNote that for the reverse model, the noise in $\\mathcal{\\tilde{D}}_1$ appears to be very different from \nthat of $\\mathcal{\\tilde{D}}_2$; this is not a coincidence ---  intuitively, it seems very unlikely that \nregressing in the other direction will also result in independence noise. Further, as we briefly \nmentioned in the early chapters, as \\cite{hoyer2009nonlinear} show, it is unlikely that for a non-linear $f$\nwe might not have identifiability. \n\nOne simple idea is then to quantify these observations; from $\\mathcal{D}_1$ and $\\mathcal{D}_2$ we \ncompute $\\hat{e}_1$, $\\hat{e}_2$, and so we can define as a score for these sets:\n\n$$\n     \\mathcal{C}(\\mathcal{D}_1, \\mathcal{D}_2) = \\norm{p_1 - p_2}_1\n$$\n\nWhere $p_1$ is the empirical distribution of $\\hat{e}_1$, and similarly for $p_2$ and $\\hat{e}_2$. We \ncan then apply the score function to $\\mathcal{\\tilde{D}}_1$ and $\\mathcal{\\tilde{D}}_2$ and \ninfer causality as follows:\n\n\\[ \n     \\begin{cases} \n        & X \\rightarrow Y \\quad  \\mathcal{C}(\\mathcal{D}_1, \\mathcal{D}_2) \n        \\leq \\mathcal{C}(\\mathcal{\\tilde{D}}_1, \\mathcal{\\tilde{D}}_2) \\\\\n        & Y \\rightarrow X \\quad \\text{otherwise}\n     \\end{cases}\n\\]\n\nIn the above example, we get that $\\mathcal{C}(\\mathcal{D}_1, \\mathcal{D}_2) = 0.138$ and that\n$\\mathcal{C}(\\mathcal{\\tilde{D}}_1, \\mathcal{\\tilde{D}}_2) = 0.480$ where use bins of size $5$ \nfor discretization; We are able to predict the causal direction with high confidence.\n\nAssuming the regressions are \\textbf{suitable}, then as $n \\rightarrow \\infty$ we know that both \n$p_1$ and $p_2$ will converge to the same $p_Z$ and so $\\mathcal{C}(\\mathcal{D}_1, \\mathcal{D}_2) \\rightarrow 0$.\nOn the other hand, it is unlikely that the residuals of $\\mathcal{\\tilde{D}}_1$ and $\\mathcal{\\tilde{D}}_2$ \nfollow the same distribution (due to the non-linearlities introduced by f) and \nso we can be pretty confident that asymptotically the procedure will correct. In fact, assuming that \\textbf{ANM}\n$X \\rightarrow Y$ is identifiable will be enough to show that this procedure is consistent.\n\nIn essence the algorithm consists of the parts:\n\n\\begin{enumerate}\n    \\item Partition the data\n    \\item Estimate regressions and residuals for each partition\n    \\item Compute scores between partition\n\\end{enumerate}\n\nWe note that the algorithm is a general framework as we are free to choose the partition, regression method\nand score function. As in the ANM methods, one can either form a train/test split to learn the regression, or\ninstead recycle the data. The algorithmic description can be found in Algorithm \\ref{alg:twin_test}.\n\nWe will next describe in more detail the core parts of the algorithm.\n\n\\subsection{Partition}\n\nSay that we partition\n$\\mathcal{D}$ into disjoint sets $\\mathcal{D}_1, ..., \\mathcal{D}_k$; then partition \npartitions need to satisfy two requirements:\n\n\\begin{enumerate}\n    \\item The partitions need to be \\textbf{dense}: \n    $|\\mathcal{D}_i| \\geq \\rho |\\mathcal{D}|, \\quad \\forall i \\in [k]$, for some $\\rho \\in (0, 1)$.\n    % \\item By disjoint partitions we mean that\n    % $$\n    % \\mathcal{D} = \\bigcup_i \\mathcal{D}_i \\quad \\text{and} \\quad\n    % \\mathcal{D}_i \\cap \\mathcal{D}_j = \\emptyset \\quad \\forall i \\neq j\n    % $$\n    \\item We need to be able to order the partitions, say $\\mathcal{D}_1, ..., \\mathcal{D}_k$, such that\n    if $i < j$ then\\footnote{The $*$ is to indicate a dummy variable, as we do not care for the value of $y$.}: \n    $$\n    \\operatorname{max} \\{ x : (x, *) \\in \\mathcal{D}_i \\} \\leq \n    \\operatorname{min} \\{ x : (x, *) \\in \\mathcal{D}_j \\}\n    $$\n\\end{enumerate}\n\nThe first condition ---  that of dense partitions ---  is to avoid getting trivial large deviations between residuals \nin the subsets; the second reason is that if they are dense, then we can give asymptotic guarantees about each subset.\nThe second condition simply ensure that we are not mixing data and that it is coherent to make regression\nin each subset. \n\nIf we use K-means (perhaps the most popular clustering algorithm), then condition 2 are met. The only \ndoubt is in regards to condition 1. K-means starts by randomly initializing two or n centers (depending \non the number of clusters that we want), and the updates the centers that they locally \nminimizes within-cluster variances. If our data is infinite support, and we re-run K-means if there is some cluster\n$i$ s.t. $|\\mathcal{D}_i| < \\rho |\\mathcal{D}|$; then if we have enough data and for some $\\rho$ we can be quite \ncertain that the algorithm will eventually terminate. \n\nIn practice this has always been the case; we conjecture that the following statement or a slight variant holds true: \ngiven $n$ samples $ \\mathcal{D} = x_1, ..., x_n$ from some random variable $X$ \nthat is \"well behaved\"\\footnote{By well behaved we mean that the data should have enough spread, if it is too\nconcentrated then partitioning will be hard.}, by running k-means once we get two partitions, \n$\\mathcal{D}_1$ and $\\mathcal{D}_2$; we can\nrestart k-means $r$  times with a different initialization to obtain $\\mathcal{D}_1(1), ...\\mathcal{D}_1(r)$ and \n$\\mathcal{D}_2(1), ...\\mathcal{D}_2(r)$. Let $s_j = \\operatorname{min} \\left(\\mathcal{D}_1(j), \\mathcal{D}_2(j)\\right)$\n\nthen there is some $\\rho > 0$ s.t.\n\n$$\n    \\Prob \\left( \\operatorname{max}_j s_j \\geq \\rho n \\right) \\rightarrow 1\n$$\n\nas $n \\rightarrow \\infty$, with $r = \\log(n)$. \n\nThe last question is, \"How many clusters do we want?\". Obviously for the small data regime we must be content \nwith only two clusters; but what if we have a lot of data? Experimentally we observed that if we \nwe choose the number of partition as an increasing function w.r.t. sample size, then we can get better performance.\n\nOne crucial aspect is that the benchmark is in the 1-D setting, where clustering is of reasonable difficulty; \nin higher dimensions clustering is a much harder problem. \n\n\n\\subsection{Regression}\n\nA benefit of partitioning the is that we are also partitioning the function we are trying to estimate; in \nparticular one would expect that the regression will be easier, e.g. a low order polynomial might be enough.\n\nFor regression we try two different methods:\n\n\\begin{enumerate}\n    \\item Polynomial regression: We perform model selection based on the BIC\\footnote{\n    The BIC score is defined as follows: $\\mathrm{BIC} =k\\ln(n)-2\\ln({\\widehat{L}})$; where $\\widehat{L}$\n    is the the maximized value of the likelihood function of the model, $n$ the number of samples and \n    $k$ the number of parameters in model. In essence it is a score that \n    trades off model fit with model complexity. } score. We pick the model with the \n    best BIC score with degree at most 6. \n    \\item Neural networks: We perform regression with a one layer 100 neuron network with ReLu activation\n    function, and trained on Adam.\n\\end{enumerate}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=.45\\textwidth]{partition_smooth.png}\n    \\caption{An example of how partitioning the data may make the regression task easier.}\n\\end{figure}\n\n\n\\subsection{Score functions}\n\nWe have seen in previous chapters various ways to measure the distances between two distributions say \n$p_1$ and $p_2$, via some score function $d(p_1, p_2)$; for example $d$ could be the \nMMD metric, or the $l_1$ distance.\n\nNow instead we have a set of distributions, say $P_k = \\{p_1, ..., p_k\\}$, and we wish to see how homogenous\\footnote{\n    By homogenous set we simply mean one in which its elements resemble each other, which is precisely what we will try to measure. \n}\n$P_k$ is compared to some other set $\\tilde{P}_j$ ---  recall that we wish to see in which of the two, \n the distributions are more likely to be the same, i.e. we are testing the i.i.d assumption. \n\nThere are several simple ways to go about this:\n\n$$\n    C(P_k) = \\operatorname{max}_{i, j} d(p_i, p_j)\n$$\n\nAnother option is to take an average of the pairwise score:\n\n$$\n    C(P_k) = \\frac{1}{\\binom{k}{2}} \\sum_{i < j} d(p_i, p_j)\n$$\n\nor even \n\n$$\n    C(P_k) = \\frac{1}{\\binom{k}{2}} \\sum_{i < j} d(p_i, p_\\mu)\n    , \\quad p_\\mu = \\frac{1}{k} \\sum_i p_i\n$$\n\n\nThus if $C(P_k) < C(\\tilde{P}_j)$, we can say that the distributions in $P_k$ are\nmore homogenous; e.g. they more likely stem from the same noise distribution. \n\nWe have tested all of the above and find that the first method ---  using the maximum score between pairs ---\ngives the best performance.\n\n\n\n\n\\subsection{Proof of consistency}\n\nWe show consistency for a simple set up of the twin test ---  but we note that generalizing it to the more \ngeneral case should follow with little effort from our proof. We leave it as an exercise for the reader. \n\n\nThe setup was the linear \\textbf{ANM}:\n\n\\[ \\begin{cases} \n    & Y = f(X) + Z  \\\\\n    & X \\bigCI Z,\\; X \\thicksim p_x,\\; Z \\thicksim p_{Z}  \n \\end{cases}\n\\]\n\nIn practice we are given samples $\\mathcal{D} = \\{x_i, y_i\\}_{i \\in [n]}$ from an ANM $X \\rightarrow Y$; next \nthe algorithm will proceed to split the data into sets $\\mathcal{D}_1$ and $\\mathcal{D}_2$. It then proceeds \nto compute residuals and to compute some scores between them.\n\nTo simplify the proof, we will \\textbf{skip the partition procedure} and assume that\nwe are directly given $\\mathcal{D}_1$ and $\\mathcal{D}_2$, each with \n$n$ samples (Note that, if $p_x$ is uniform, then having these sets be of equal size would happen exponentially \nfast; indeed, in general, we will have dense partitions as $n$ becomes arbitrarily large). \n\nNext, we will assume that on each interval, the data is linear with slope $a_1$ and $a_2$ resp. \n\n\\begin{figure}[!h]\n    \\centering\n    \\begin{tikzpicture}\n        \\draw[thin, dashed] (1.5, -0.5) --  (1.5, 2.6) node[above] {};\n        \\path (0.75, -0.8) -- (0.75, -0.6) node[above] {$\\mathcal{D}_1$};\n        \\path (2.25, -0.8) -- (2.25, -0.6) node[above] {$\\mathcal{D}_2$};\n        \\draw[->] (-1, 0) -- (4.2, 0) node[right] {$x$};\n        \\draw[->] (0, -1) -- (0, 3) node[above] {$y$};\n        \\draw[scale=1, domain=0:1.5, smooth, variable=\\x, blue] plot ({\\x}, {0.5*\\x});\n        \\draw[scale=1, domain=1.5:3, smooth, variable=\\y, red]  plot ({\\y}, {1*\\y - 0.75});\n        \\draw[decoration={brace,mirror,raise=5pt},decorate] (0.1, -.5) -- node[below=8pt] {$\\mathcal{D}$} (2.9, -.5) ;\n      \\end{tikzpicture}\n      \\caption{Slopes $a_1$ and $a_2$ in blue and red respectively.}\n\\end{figure}\n\nThus our problem can be seen as getting data from two different \\textbf{ANM}, both with identical noise, but with \na different scaling of $X$:\n\n$\\mathcal{D}_1$ is sampled from \n\n\\[ \\begin{cases} \n    & Y_1 = a_1 X_1 + Z  \\\\\n    & X_1 \\bigCI Z,\\; X_1 \\thicksim p_{X_1},\\; Z \\thicksim p_{Z}  \n \\end{cases}\n\\]\n\nand $\\mathcal{D}_2$ is sampled from \n\n\\[ \\begin{cases} \n    & Y_2 = a_2 X_2 + Z  \\\\\n    & X_2 \\bigCI Z,\\; X_2 \\thicksim p_{X_2},\\; Z \\thicksim p_{Z}  \n \\end{cases}\n\\]\n\n\nWe call this scenario the \\textbf{simplified Twin Test scenario}. \n\nWe next describe the steps of the algorithm after partitioning:\n\nWe first split $\\mathcal{D}_1$ in two sets of equal size $\\mathcal{D}_{1}^{train}$ and \n$\\mathcal{D}_{1}^{test}$. We first use $\\mathcal{D}_{1}^{train}$ to estimate $a_1$, say $\\hat{a}_1$ via \nregression. Then, using $\\mathcal{D}_{1}^{test}$, we estimate the residual:\n\n$$\n    \\hat{Z}_1 = Y_1 - \\hat{a}_1 X\n$$\n\nWe then discretize $\\hat{Z}_1$ and form a distribution say $\\hat{p}_1$; we can do the same thing for \n$\\mathcal{D}_2$, and by doing the same procedure obtain $\\hat{p}_2$.\n\nWe discretize both with a fixed step size, say $s$; as we will see, the only requirement is that we fix \nthe size beforehand.\n\nWe use the $l_1$ distance as our score:\n\n$$\n    \\hat{C}_{X \\rightarrow Y} = \\norm{\\hat{p}_1 - \\hat{p}_2}_1\n$$\n\nAs we have seen, $\\hat{C}_{Y \\rightarrow X} > 0$ holds in general except in very particular situations. So, \nto prove that our algorithm is consistent, we need to show that:\n\n$$\n    \\hat{C}_{X \\rightarrow Y} \\rightarrow 0 \\qquad \\text{as }  \\qquad n \\rightarrow \\infty \\qquad \\text{in probability}\n$$\n\nThis is precisely what we will show:\n\n\\begin{theorem}\n    The \\textbf{simplified Twin Test scenario} is consistent, i.e. \n\n$$\n    \\hat{C}_{X \\rightarrow Y} \\rightarrow 0 \\qquad \\text{as }  \\qquad n \\rightarrow \\infty \\qquad \\text{in probability}\n$$\n\nAssuming that the noise distribution satisfies the conditions of lemma \\ref{lemma:conv_bound}.\n\n\\end{theorem}\n\nThe assumption about the noise distribution holds for most distributions, for example uniform, \nexponential, ...\n\nThe idea of the proof is to observe the following:\n\nIf we have enough data, i.e. when $n$ is large enough then assuming the regression is \n\\textbf{suitable}, we can choose any $\\alpha$ such that (for the linear regression, one can show that \nthe events below happen in probability), \n\n$$\n    \\abs{a_1 - \\hat{a}_1} \\leq \\alpha \\qquad \\text{and} \\qquad \\abs{a_2 - \\hat{a}_2} \\leq \\alpha\n$$\n\nThis means that \n\n$$\n    \\hat{Z}_1 = Z + (a_1 - \\hat{a}_1)X \\quad \\implies \\quad Z - \\alpha X \\leq \\hat{Z}_1 \\leq Z + \\alpha X \n$$\n\nand similarly\n\n$$\n    \\hat{Z}_2 = Z + (a_2 - \\hat{a}_2)X \\quad \\implies \\quad Z - \\alpha X \\leq \\hat{Z}_2 \\leq Z + \\alpha X \n$$\n\nNote that $\\hat{Z}_1 \\thicksim P_{Z + \\Delta_1 X}$ and $\\hat{Z}_2 \\thicksim P_{Z + \\Delta_2 X}$ , where for \nbrevity we denote $\\Delta_1 = a_1 - \\hat{a}_1$ and $\\Delta_2 = a_2 - \\hat{a}_2$. We can visualize the distance\nbetween these distributions as follows: (see\\footnote{Note that the illustration does not follow the actual\ngeometry of the space, we draw it solely to gain intuition about the problem.} figure \\ref{fig:dist})\n\n\\begin{figure}[!h]\n    \\centering\n    \\begin{tikzpicture}[scale=2]\n        \\draw[thick] (0,0) circle (1);\n        \\draw[semithick, fill=black] (0,0) circle (0.02) node[left] {$P_Z$};\n        \\draw[thick, <->] (0, .05) -- node[right] {$R(\\alpha)$} (0, .95);\n        \\draw[semithick, fill=black] (0,1) circle (0.02) node[above] {$P_{Z + \\alpha X}$};\n        % p_1 and p_2\n        \\draw[semithick, fill=black] (.5, -.5) circle (0.02) node[above, color=red] {$P_{Z + \\Delta_2 X}$};;\n        \\draw[semithick, fill=black] (-.58, .114) circle (0.02) node[above, color=blue] {$P_{Z + \\Delta_1 X}$};;\n      \\end{tikzpicture}\n      \\caption{The $l_1$ \"ball\" around $P_Z$, for brevity we denote \n      $\\Delta_1 = a_1 - \\hat{a}_1$ and $\\Delta_2 = a_2 - \\hat{a}_2$}\n      \\label{fig:dist}\n\\end{figure}\n\nThe idea is then the following, given some $\\epsilon > 0$, we want to show that asymptotically\n\n$$\n    \\norm{\\hat{p}_1 - \\hat{p}_2}_1 > \\epsilon\n$$\n\ncannot happen. The game plan will be to find a bound on the $R(\\alpha)$; once we have one, we are done, we \nwill simply pick an $\\alpha$ s.t. $R(\\alpha) < \\epsilon$, where $R(\\alpha) = \\norm{P_{Z}- P_{\\alpha X + Z}}_{1}$\n. Recall that $\\alpha$ is the error in of our $\\hat{a}$\nestimate, which we can get arbitrarily small with enough samples. \n\nWe begin by proving lemmas to find bounds for the radius $R(\\alpha)$.\n\n\\begin{lemma} \n    \n    Given $\\alpha > 0$, random variables $Z$ and $X$, with $X \\bigCI Z$, \n$X \\thicksim P_X$, $Z \\thicksim P_Z$, such that\\footnote{\n    we remark that this \n    condition holds for most distributions such as the uniform, exponential and Gaussian.} there is \n    some $g$ s.t. \n    $ \\forall \\theta \\in (-\\sqrt{\\alpha}, \\sqrt{\\alpha}), \\; \\left| P_{Z}^{\\prime}(t - \\theta) \\right| \\leq g(t) \\; \\forall t$\n    and $\\int \\left| g(t) \\right| d t < L$, for some $L > 0$.\n then\n\n$$\n\\norm{P_{Z}- P_{\\alpha X + Z}}_{1} \\leq \\sqrt{\\alpha} L + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)\n$$\n\nWhere $P_{\\alpha X + Z}$ is the distribution of the sum: $\\alpha X + Z \\thicksim  P_{\\alpha X + Z}$.\n\n\\label{lemma:conv_bound}\n\\end{lemma}\n\n \n\n\\begin{proof}\n    ~\n\nFirst note that $\\alpha X \\thicksim \\frac{1}{\\alpha}P_{X} \\left( \\frac{\\tau}{\\alpha} \\right)$ by applying the \nchange of variable rule. Let $P_{\\alpha X + Z}$ be the distribution of the sum: $\\alpha X + Z \\thicksim  P_{\\alpha X + Z}$.\n\nNext, since $X \\bigCI Z$, we may write $P_{\\alpha X + Z}$ as a convolution:\n\n$$\n    P_{\\alpha X + Z} (t) = \\int P_{Z}(t-x) \\frac{1}{\\alpha}P_{X} \\left( \\frac{x}{\\alpha} \\right) d x =\n     \\int P_{Z}(t-\\alpha x) P_{X}(x) d x\n$$\n\nLet $T^{\\alpha X} P_Z(t) := P_{Z}(t-\\alpha x)$ (we use the notation introduced by Lagrange for the shift operator).\n\nHence we may write (with $P_X$ as the underlying measure):\n\n$$\n    P_{\\alpha X + Z} (t) = \\E\\left(P_{Z}(t-\\alpha X ) \\right)\n$$\n\n\nWe proceed as follows:\n\n$$\n\\begin{aligned}\n\\norm{P_{Z}- P_{\\alpha X + Z}}_{1} &=\\int\\abs{ P_{Z}(t)-\\E\\left(P_{Z}(t-\\alpha X ) \\right)} d t \\\\\n&\\leq \\int \\E \\abs{ P_{Z}(t)-P_{Z}(t-\\alpha X )} d t \\\\\n&=\\E \\int\\abs{ P_{Z}(t)-P_{Z}(t-\\alpha X ) } d t \\\\\n&= \\E \\left( \\norm{P_{Z}- T^{\\alpha X} P_Z }_{1} \\, | \\, \\abs{X} \\leq \\frac{1}{\\sqrt{\\alpha}} \\right) \n\\Prob\\left( \\abs{X} \\leq \\frac{1}{\\sqrt{\\alpha}} \\right) + \\E \\left( \\norm{P_{Z}- T^{\\alpha X} P_Z }_{1} \\, | \\, \\abs{X} > \\frac{1}{\\sqrt{\\alpha}} \\right) \n\\Prob\\left( \\abs{X} > \\frac{1}{\\sqrt{\\alpha}} \\right) \\\\\n&\\leq \\E \\left( \\norm{P_{Z}- T^{\\alpha X} P_Z }_{1} \\, | \\, \\abs{X} \\leq \\frac{1}{\\sqrt{\\alpha}} \\right) \n + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right) \\\\ \n&\\leq \\operatorname{max}_{\\eta \\in (-\\sqrt{\\alpha}, \\sqrt{\\alpha})} \\int\\abs{ P_{Z}(t)-P_{Z}(t-\\eta ) } d t + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right) \\\\\n&\\leq \\operatorname{max}_{\\eta \\in (-\\sqrt{\\alpha}, \\sqrt{\\alpha})} \\int \\abs{ \\eta g(t) } d t  + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)\\\\\n% &\\leq \\int\\abs{ P_{Z}(t)- \\left( P_{Z}(t) + \\sum_{n \\geq 1} \\left( \\alpha C^* \\right)^n P_{Z}(t)^{(n)} \\right) } d t  + 2 P(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}})\\\\\n% &\\leq \\alpha C^* L + 2 P(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}})\\\\\n&\\leq \\sqrt{\\alpha} \\int \\abs{ g (t)} dt + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)\\\\\n&\\leq \\sqrt{\\alpha} L + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)\n\\end{aligned}\n$$\n\nThe first equality follows by the aforementioned observation. The first inequality follows from the triangle \ninequality; \nthe equality that comes after is due to Fubini's theorem, we can swap the expectation (which is also an \nintegration) since all measures are measurable. We next use the law of total probability by splitting \nthe expectation w.r.t $\\frac{1}{\\sqrt{\\alpha}}$.\n\nThe next upper bounds follows by noting that\n$\\norm{p - q}_1 \\leq 2$ for any distributions $p$ and $q$. Next observe that \n$\\E \\left( \\norm{P_{Z}- T^{\\alpha X} P_Z }_{1} \\, | \\, \\abs{X} \\leq \\frac{1}{\\sqrt{\\alpha}} \\right)$ is the average $l_1$ distance\nbetween $\\norm{P_{Z}}$ and random shifts of itself. Hence we can bound this by the maximum shift.\n\nSince $\\eta \\approx 0$, and since \n$  \\eta \\in (-\\sqrt{\\alpha}, \\sqrt{\\alpha}) \\implies  \\left| P_{Z}^{\\prime}(t - \\eta) \\right| \\leq g(t) \\; \\forall t$\n, using Taylor's theorem we obtain that: \n\n$$\n    \\abs{P_{Z}(t- \\eta ) - P_{Z}(t) }  \\leq \\eta g(t)\n$$\n\nThe rest follows from the assumption that $\\int g(t) dt \\leq L$.\n\n% % Using taylor expansions we obtain \n\n% % $$\n% %     P_{Z}(t-\\alpha C^* ) = P_{Z}(t) + \\sum_{n \\geq 1} \\left( \\alpha C^* \\right)^n P_{Z}(t)^{(n)}\n% % $$\n\n% % then  we upper bound what we get after as follows\n\n% % \\begin{align*}\n% %     \\int \\left| \\sum_{n \\geq 1} \\left( \\alpha C^* \\right)^n P_{Z}(t)^{(n)} \\right|\n% %     &\\leq L \\sum_{n \\geq 1} \\left( \\alpha C^* \\right)^n \\\\\n% %     &\\leq L \\frac{\\alpha C^*}{1 - \\alpha C^*} \\\\\n% %     &\\approx \\alpha C^* L\n% % \\end{align*}\n\n% % We will later pick $\\alpha \\ll 1$, and so it follows from $\\frac{x}{1 - x} \\approx x$ for small $x$. \n\n% Finally, since are free to pick $k$, we choose it large enough s.t. $2P(\\abs{ X} > k) \\leq \\delta$, we then let \n% $C = C^* L$ and we are done.\n\n% Note that as $k$ increases so does $C^*$, since we are growing the space to optimise for $C^*$; this is \n% where the dependence between $\\delta$ and $C$ comes from. \n\n\\end{proof}\n\nSo we have found a bound on the $l_1$ distance between two continuous distributions; however in our\napplication, these will be quantized versions of these distributions. The following lemma tells us \nthat this is not a problem, the $l_1$ distance between the quantized version cannot be bigger than \nthat of their continuous counter parts. The only requirement is that we fix the quantization scheme\nbeforehand and use the same one for both.\n\n\\begin{lemma}\n    Let $P$ and $Q$ be two continuous distributions, then let $P^*$, $Q^*$ resp. be discretized versions.\n    Then\n\n    $$\n        \\norm{P^* - Q^*}_1 \\leq \\norm{P - Q}_1 \n    $$\n    \\label{lemma:quantisation}\n\\end{lemma}\n\n\\begin{proof}\n    ~\n    We first quantize $\\R$ in bins of length $w$, say $I_i = [wi, w(i + 1))$, note \n    $\\bigcup_{i \\in \\Z} I_i = \\R$.\n\n    Given continuous distributions $P$ and $Q$, we form their quantized counter parts as\n    follows:\n\n    $$\n        P^*(k) := \\sum _{i \\in \\Z} \\; \\int_{I_i} P(t) dt \\; \\Ind_{k  = i}\n        , \\quad   Q^*(k) := \\sum _{i \\in \\Z} \\; \\int_{I_i} Q(t) dt \\; \\Ind_{k  = i}\n    $$\n\n    We then conclude as follows by a applying the triangle inequality twice:\n\n    \\begin{align*}\n        \\norm{P^* - Q^*}_1^2 &= \\sum _{k \\in \\Z} \\; \\left| P^*(k) - Q^*(k)\\right|  \\\\\n        &\\leq \\sum _{k \\in \\Z} \\sum _{i \\in \\Z} \\; \\left| \\int_{I_i} \\left(P(t) - Q(t)\\right) dt \\right|  \\; \\Ind_{k  = i} \\\\\n        &\\leq \\sum _{k \\in \\Z} \\sum _{i \\in \\Z} \\;  \\int_{I_i} \\left|P(t) - Q(t)\\right| dt  \\; \\Ind_{k  = i} \\\\\n        &= \\sum _{i \\in \\Z} \\;  \\int_{I_i} \\left|P(t) - Q(t)\\right| dt  \\; \\sum _{k \\in \\Z} \\Ind_{k  = i} \\\\\n        &= \\sum _{i \\in \\Z} \\;  \\int_{I_i} \\left|P(t) - Q(t)\\right| dt \\\\\n        &= \\int_{\\R} \\left|P(t) - Q(t)\\right| dt \\\\\n        &= \\norm{P - Q}_1^2\n    \\end{align*}\n\n\\end{proof}\n\nWe can now conclude by proving consistency, recall that we want to show that:\n\n$$\n    P \\left(\\norm{\\hat{p}_1 - \\hat{p}_2}_1 > \\epsilon \\right) \\rightarrow 0\n$$\n\n\\begin{proof}\n\n\\begin{align*}\n        \\Prob\\left( \\norm{ \\hat{p}_1 - \\hat{p}_2 }_1 \\geq \\epsilon \\right) &\\leq \n        \\Prob\\left( \\norm{ \\hat{p}_1 -  P^*_Z}_1 + \\norm{ \\hat{p}_2 -  P^*_Z}_1 \\geq \\epsilon \\right) \\\\\n        &\\leq \\Prob\\left( \\norm{ \\hat{p}_1 -  P^*_Z}_1 + \\norm{ \\hat{p}_2 -  P^*_Z}_1 \\geq \\epsilon \n        \\; | \\; \\abs{a_1 - \\hat{a}_1} \\leq \\alpha \\; \\text{,} \\; \\abs{a_2 - \\hat{a}_2} \\leq \\alpha \\right) \\\\\n                        &\\qquad + \\Prob\\left( \\abs{a_1 - \\hat{a}_1} > \\alpha \\; \\text{or} \\; \\abs{a_2 - \\hat{a}_2} > \\alpha  \\right) \n\\end{align*}\n\nWhere $P^*_Z$ is the quantized version of $P_Z$.\n\nThe first inequality follows by the triangle inequality, and the second one by using the law of total probability.\n\nObserve that \n\n$$\n\\Prob\\left( \\abs{a_1 - \\hat{a}_1} > \\alpha \\; \\text{or} \\; \\abs{a_2 - \\hat{a}_2} > \\alpha  \\right)  =\n\\Prob\\left( \\abs{a_1 - \\hat{a}_1} > \\alpha \\right) + P \\left( \\abs{a_2 - \\hat{a}_2} > \\alpha  \\right) \n$$\n\nBoth of which go to zero for any $\\alpha > 0$ assuming that our regression is \\textit{suitable}.\n\n\nIt remains to bound \n\n\\begin{equation}\n    \\Prob\\left( \\norm{ \\hat{p}_1 -  P^*_Z}_1 + \\norm{ \\hat{p}_2 -  P^*_Z}_1 \\geq \\epsilon \n        \\; | \\; \\abs{a_1 - \\hat{a}_1} \\leq \\alpha \\; \\text{,} \\; \\abs{a_2 - \\hat{a}_2} \\leq \\alpha \\right)\n\\end{equation}\n\nNote that $\\hat{p}_1 \\rightarrow P^*_{Z + \\Delta_1 X}$ as $n \\rightarrow \\infty$; where \n$P^*_{Z + \\Delta_1 X}$ is the discretized distribution of $P_{Z + \\Delta_1 X}$; recall that \nwe form $\\hat{p}_1$ by creating a discretized histogram from the residuals. \n\nThen, by combining lemma \\ref{lemma:conv_bound} and \\ref{lemma:quantisation} we have that:\n\nFor any $\\alpha$, there is some $L > 0$ s.t.\n$$\n    \\norm{P^*_{Z} - P^*_{Z + \\Delta_1 X}}_1 \\leq \\sqrt{\\alpha} L + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)\n$$\n\n\n\nThus if we are given some $\\epsilon > 0$, pick\\footnote{We can do this since $\\sqrt{\\alpha}$ is increasing \nin $\\alpha$ and $\\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right)$ is decreasing in $\\alpha$.} \nsome $\\alpha$ such that\n\n$$\n    \\sqrt{\\alpha} L + 2 \\Prob \\left(\\abs{ X} > \\frac{1}{\\sqrt{\\alpha}} \\right) < \\frac{\\epsilon}{2}\n$$\n\nBy applying the same idea to $\\hat{p}_2$, we get that as $n \\rightarrow \\infty$\n\n$$\n   \\norm{\\hat{p}_1 -  P^*_Z}_1 + \\norm{ \\hat{p}_2 -  P^*_Z}_1 < \\frac{\\epsilon}{2} + \\frac{\\epsilon}{2} = \\epsilon\n$$\n\nAnd so as $n \\rightarrow \\infty$\n\n$$\n    \\Prob\\left( \\norm{ \\hat{p}_1 -  P^*_Z}_1 + \\norm{ \\hat{p}_2 -  P^*_Z}_1 \\geq \\epsilon \n        \\; | \\; \\abs{a_1 - \\hat{a}_1} \\leq \\alpha \\; \\text{,} \\; \\abs{a_2 - \\hat{a}_2} \\leq \\alpha \\right)\n        \\rightarrow 0 \n$$\n\n\n\\end{proof}\n\n\n\\subsection{Algorithm}\n\n\n\\begin{algorithm}[H]\n\n    \\caption{\\textbf{Twin Test (TT)}: General procedure to decide whether $P_{X, Y}$ satisfies and ANM $X \\rightarrow Y$\n        or $Y \\rightarrow X$}\n  \n    \\textbf{Input}:\n\n    \\begin{enumerate}\n        \\item I.i.d samples $\\mathcal{D} = \\{ (x_i, y_i )\\}_{i \\in [N]}$ of $X$ and $Y$\n        \\item Partition procedure\n        \\item Regression method\n        \\item Score estimator $\\hat{C}: R^{* \\times *} \\rightarrow \\R$, where E is a set of vectors. \n    \\end{enumerate}\n    \n    \\textbf{Output}: $\\hat{C}_{X \\rightarrow Y}$, $\\hat{C}_{Y \\rightarrow X}$, dir\n\n    \\begin{enumerate}\n\n        \\item $\\tilde{\\mathcal{D}} := \\{ ( y_i, x_i )\\}_{i \\in [N]}$\n\n        \\item \\textbf{Partition} the data into subsets\\footnote{The subsets are disjoint and their union equals the data}:\n        \\begin{itemize}\n            \\item[--] $\\{ \\mathcal{D}_i \\}_{i \\in [k]} \\quad \\text{s.t.} \\quad \\mathcal{D}_i \\subset \\mathcal{D}, \n            \\forall i \\in [k]$\n            \\item[--] $\\{ \\tilde{\\mathcal{D}}_i \\}_{i \\in [j]} \\quad \\text{s.t.} \\quad \\tilde{\\mathcal{D}}_i \n            \\subset \\tilde{\\mathcal{D}}, \\forall i \\in [j]$\n            \\item[--] Where integers $j, k > 1$ are determined by the partition procedure.\n        \\end{itemize}\n\n        \\item \\textbf{Estimate regressions} and residuals for each subset\n        \n        for $i \\in [k]:$\n\n        \\begin{itemize}\n            \\item[--] Let $\\mathbf{x}$, $\\mathbf{y}$ be the vectors formed from $\\mathcal{D}_i$\n            \\item[--] $\\hat{f}_Y$ of the regression function $x \\mapsto \\E(Y | X=x)$\n            \\item[--] $ \\mathbf{\\hat{e}_{Y}}(i) := \\mathbf{y} - \\hat{f}_Y(\\mathbf{x})$\n        \\end{itemize}\n\n        end for\n\n        $\\mathbf{E_Y} := \\{ \\mathbf{\\hat{e}_{Y}}(i) \\}_{i \\in [k]} $\n\n        for $i \\in [j]:$\n\n        \\begin{itemize}\n            \\item[--] Let $\\mathbf{x}$, $\\mathbf{y}$ be the vectors formed from $\\tilde{\\mathcal{D}}_i$\n            \\item[--] $\\hat{f}_X$ of the regression function $y \\mapsto \\E(X | Y=y)$\n            \\item[--] $ \\mathbf{\\hat{e}_{X}}(i) := \\mathbf{x} - \\hat{f}_X(\\mathbf{y})$\n        \\end{itemize}\n\n        end for\n\n        $\\mathbf{E_X} := \\{ \\mathbf{\\hat{e}_{X}}(i) \\}_{i \\in [j]} $\n\n        \\item \\textbf{Compute scores} to measure the difference between the residuals\n        \\begin{itemize}\n            \\item[--] $\\hat{C}_{X \\rightarrow Y}: = \\hat{C}( \\mathbf{E_Y} )$ \n            \\item[--] $\\hat{C}_{Y \\rightarrow X}: = \\hat{C}( \\mathbf{E_X} )$\n        \\end{itemize}        \n\n        \\item Output $\\hat{C}_{X \\rightarrow Y}$, $\\hat{C}_{Y \\rightarrow X}$, and\n        \n        \\[ \n        \\text{dir} :=  \n         \\begin{cases} \n            & X \\rightarrow Y \\quad \\text{if} \\; \\hat{C}_{X \\rightarrow Y} \\leq \\hat{C}_{Y \\rightarrow X}\\\\\n            & Y \\rightarrow X \\quad \\text{otherwise}\n         \\end{cases}\n        \\]\n        \n    \\end{enumerate}\n\n  \\label{alg:twin_test}\n  \\end{algorithm}\n\n\\newpage\n\\section{The residual method}\n\nWhen given an ANM $X \\rightarrow Y $, the traditional method based on ANM is to regress $X$ on \n$Y$ and then vice versa in order to see which residual is more independent from it's input. A\nvery basic --- but restrictive --- idea is to assume knowledge about the additive noise, $P_Z$. \nIn some sense this idea was the precursor to the twin test, where we check if the noise is consistent\nin the different intervals of the data. Instead here, since we assume knowledge about $P_Z$, we \nwill test and see which residual is more likely to be drawn from the actual noise distribution $P_Z$.\n\nThis is however quite a strong assumption, so it is more of a theoretical curiosity. \n\nWe start again we typical setup:\nsuppose we are given samples $\\mathcal{D} = \\{x_i, y_i\\}_{i \\in [n]}$ from an ANM $X \\rightarrow Y$, which has the form\n\n\\[\n    \\begin{cases} \n        & Y = f(X) + Z \\\\\n        & X \\bigCI Z,\\quad X \\thicksim P_X,\\quad Z \\thicksim P_{Z}  \n     \\end{cases}  \n\\]\n\nIn addition, we will know $P_{Z}$, in some cases it is not such an unreasonable assumption; for example, \na lot of thermal noise in measurements is usually very well modeled by a Gaussian. Another example \nis when a real value x from a sensor, is discretized with a uniform quantizer, the error is \nlikely to be uniformly distributed. (\\cite{uniformCond})\n\nFor the ANM methods, the first step was to \n\n1. Regress $\\mathbf{x}$ on $\\mathbf{y}$, to find an estimate say $\\hat{f}_Y$\n\n2. Estimate residual via $\\mathbf{\\hat{e}}_Y = \\hat{f}_Y(\\mathbf{x}) - \\mathbf{y}$\n\nThe next step was to then compute the same thing for the reverse model, that is, swapping the \nroles of $\\mathbf{x}$ and $\\mathbf{y}$. We would then compute some score of independence \nbetween the residual and their respective inputs ($\\mathbf{x}$ for the direct model And\n $\\mathbf{y}$ for the reverse). \n\n Since we have knowledge of $P_Z$ we can avoid this last step all together, and instead simply \n compute a score to see how close $\\mathbf{\\hat{e}}_Y$ is to $P_Z$. \n\n One simple idea is the following:\n\n 1. $\\mathbf{b} :=$ histogram of $\\mathbf{\\hat{e}}_Y$\n\n 2. $P^*_Z :=$  discretized distribution of $P_Z$\n\n For both we pick the same discretization size, say $m$. \n\n Our score is then \n $\n     \\hat{C}_{X \\rightarrow Y} := d\\left(\\mathbf{b}, P^*_Z \\right)\n $\n Where $d$ is some statistical distance, such as an f-divergence. We compute the score for reverse model \n by swapping the roles of $\\mathbf{x}$ and $\\mathbf{y}$.\n\n\n\\subsection{Proof of consistency: A tale of two bounds}\n\nThe setup was the linear \\textbf{ANM}:\n\n\\[ \\begin{cases} \n    & Y = aX + Z  \\\\\n    & X \\bigCI Z,\\; X \\thicksim P_X,\\; Z \\thicksim P_{Z}  \n \\end{cases}\n\\]\n\nGiven data $\\mathcal{D} = \\{x_i, y_i\\}_{i \\in [n]}$ from this ANM, we \nestimate $\\hat{f}_Y$ by regressing $X$ on $Y$ and \n$\\hat{f}_X$ for the reverse model. We then compute the residuals (as always we can \neither recycle data or perform a test/train partition). \n\n\\begin{align}\n    &  \\hat{\\mathbf{e}}_Y = \\mathbf{y} - \\hat{f}_Y(\\mathbf{x})\\\\\n    &  \\hat{\\mathbf{e}}_X = \\mathbf{x} - \\hat{f}_X(\\mathbf{y})\n\\end{align}\n\nWe note that for the ease of analysis, it would first be wise to use some fraction \nof the data to first estimate the regression, and then use the remaining for the test.\n\nThe idea is the very simple, test which of the residuals $\\hat{\\mathbf{e}}_Y$ or \n$\\hat{\\mathbf{e}}_X$ is more likely to be distributed according to $P_Z$.\nTo ease computation in the bounds we will assume $P_Z$ to be the uniform\ndistribution, but we remark that the analysis will hold in general. \n\nTo do so we first discretize\\footnote{We do so in a naive manner by splitting\nit uniformly into $m$ bins.} $P_{Z}$ into $m$ bins, call this discrete distribution\n$Q$. We apply the same discretization to obtain $\\mathbf{b} = (b_1, ..., b_m)$ from $\\hat{\\mathbf{e}}_Y$\nand $\\tilde{\\mathbf{b}} = (\\tilde{b}_1, ..., \\tilde{b}_m)$ from $\\hat{\\mathbf{e}}_X$.\n\nWe then decide the causal direction as follows\n\n\\[ \\begin{cases} \n    & X \\rightarrow Y \\quad \\text{if} \\quad C \\leq W  \\\\\n    & Y \\rightarrow X \\quad \\text{if} \\quad C > W  \n \\end{cases}\n\\]\n\nWhere \n\n$$\n    C = \\norm{\\mathbf{b} - \\mathbf{u}}_{1} \n$$\n$$\n    W = \\norm{\\tilde{\\mathbf{b}} - \\mathbf{u}}_{1}\n$$\n\n\ns.t. $\\mathbf{u} = (\\frac{1}{m}, ..., \\frac{1}{m})$.\n\nGiven our assumption about the \\textbf{ANM}, the probability to output the correct causal direction is:\n\n$$\n   P_{\\text{correct}} = \\mathbb{P}\\left(C \\leq W\\right) \n$$\n\nWe will assume that we have perfect regression estimates to simplify the proof; as we have seen in the \nprevious chapter, with a little bit of work we can incorporate the error terms of the regression in \nthe probability of correctness. \n\nWe next upper bound this quantity in order to show consistency\n\n\\begin{align}\n    \\Prob\\left(C \\leq W\\right) &\\geq \\Prob\\left( \\underset{\\tau \\in \\mathbb{Q}}{\\bigcup} C \\leq \\tau \\cap W > \\tau \\right) \\\\\n    &\\geq \\Prob\\left(C \\leq \\tau \\cap W > \\tau \\right) \\\\\n    &\\geq \\Prob\\left(C \\leq \\tau \\right) - \\Prob\\left(W \\leq \\tau \\right)\n\\end{align}\n\nThe first inequality is due to the fact that we are only taking the union in the rationals\\footnote{We note that\nwe can only take unions over countable sets; recall also that the rationals are dense in the irrationals, so the\ninequality is very close to equality (and in practice and among friends it would be).}. The second inequality is done by \nlooking at the probability of a fixed $\\tau$; and the final one follows by:\n\n$$\n    1 \\geq \\Prob\\left( C \\leq \\tau \\cup W > \\tau \\right) = \n    \\Prob\\left( C \\leq \\tau \\right) + \\Prob\\left( W > \\tau \\right) - \\Prob\\left( C \\leq \\tau \\cap W > \\tau \\right)\n$$\n\nWe will next find appropriate bounds for $\\Prob\\left( C \\leq \\tau \\right)$ and $\\Prob\\left(W \\leq \\tau \\right)$.\n\n\nWe will first lower bound $\\Prob\\left( C \\leq \\tau \\right)$ by upper bounding the complement event.\n\n\\begin{align}\n    \\Prob\\left( C \\geq \\tau \\right) &= \\Prob\\left( \\sum_{i = 1}^{m} \\abs{b_i - \\frac{1}{m}} \\geq \\tau \\right)  \\\\\n    &\\leq \\Prob\\left( m \\operatorname{max}_{i} \\abs{b_i - \\frac{1}{m}} \\geq \\tau \\right)  \\\\\n    &= \\Prob\\left( \\bigcup_{i} \\; \\abs{b_i - \\frac{1}{m}} \\geq \\frac{\\tau}{m} \\right)  \\\\\n    &\\leq m \\; \\Prob\\left( \\abs{b_0 - \\frac{1}{m}} \\geq \\frac{\\tau}{m} \\right) \\\\\n    &\\leq m2\\exp \\left( -2n \\frac{\\tau^2}{m^2} \\right)\n\\end{align}\n\nThe second to last inequality follows by the union bound and by noting that all $b_i$s are the same since they\nare discretized empirical distribution coming from a uniform source. For the final inequality we use Hoeffding's\ninequality.\n\n\nRecall that what is left to bound is the following quantity, $\\Prob\\left(W \\leq \\tau \\right)$; \nfor this we first define the following set of probability distributions:\n\n$$\n    \\Gamma_\\tau = \\{ \\pi \\in  \\Delta_m : \\norm{\\pi - U}_{L_1} \\leq \\tau \\}\n$$\n\nWhere the $\\Delta_m$ is the $m$ dimensional simplex and $U$ the uniform vector as before.\n\nObserve that: \n\n$$\n    \\{ W \\leq \\tau \\} = \\{ \\tilde{\\mathbf{b}} \\in \\Gamma_\\tau \\}\n$$\n\nIn essence, we are asking: \"what is the chance that the realization of $\\tilde{\\mathbf{b}}$ --- which is the \nempirical distribution of some distribution $Q$ --- lies inside some set of distributions $\\Gamma_\\tau$.\n\nWe note that bounding this kind of event is exactly what Sanov's theorem\\footnote{See the section on Information Theory and statistics in \n\\cite{cover1999elements}} gives us, an important\nresult from large deviation theory that also exploits concentration of measure.\n\n\n\nLet $\\mathbf{x} = (x_1, ..., x_n)$ be a sequence of $n$ each drawn independently from \na finite universe $U$ with $|U| = m$. Denote by $P_\\mathbf{x}$ the empirical distribution --- \nor type --- for a given sequence $\\mathbf{x}$. Let $Q^{n}$ be the product distribution $n$\nindependent samples of $Q$. \n\n\\begin{theorem}[Sanov’s theorem]\\label{sanov}\n\n    Let $\\Pi$ be a convex set of distributions on $U,$ and $m=|U| .$ Let\n\n    \\[\n        P^{*}=\\operatorname{argmin}_{P \\in \\Pi} D(P \\| Q)\n    \\]\n    \n    Then\n    \\[\n        \\underset{Q^{n}}{\\Prob}\\left(P_{\\mathbf{x}} \\in \\Pi\\right) \\leq(n+1)^{m} 2^{-nD\\left(P^{*} \\| Q\\right)}\n    \\]\n    \n\\end{theorem}\n\nApplying the above theorem, and noting that $\\Gamma_\\tau$ takes the place of $\\Pi$, $\\tilde{\\mathbf{b}}$ that of $P_{\\mathbf{x}}$\nand the discretized distribution $\\hat{e}_X = X - \\hat{f}_X(Y)$ that of $Q$ we get:\n\n\\begin{equation}\n    \\Prob\\left(W \\leq \\tau \\right) = \\Prob\\left( \\tilde{\\mathbf{b}} \\in \\Gamma_\\tau \\right) \n    \\leq (n+1)^{m} 2^{-nD\\left( \\tau \\right)}\n\\end{equation}\n\nWhere $D\\left( \\tau \\right) := D\\left(P^{*} \\| Q\\right)$, we make the $\\tau$ relation explicit to \nkeep in mind that the minimization is constrained to the set $\\Gamma_\\tau$ which depends on $\\tau$.\n\nWe remark that the only place of concern is if $D\\left(P^{*} \\| Q\\right) = 0$; assuming however that $Q \\neq U$, then \nthere will be some $\\tau$ s.t. $Q \\notin \\Gamma_\\tau$ and thus $D\\left(P^{*} \\| Q\\right) \\neq 0$.\n\nWe can now conclude by putting everything together; recall that we had shown that we could bound the success probability \nas follows:\n\n\n\n\\begin{align}\n    \\Prob\\left(C \\leq W\\right) &\\geq \\Prob\\left(C \\leq \\tau \\right) - \\Prob\\left(W \\leq \\tau \\right) \\\\\n    &\\geq 1 - 2m\\exp \\left( -2n \\frac{\\tau^2}{m^2} \\right) - (n+1)^{m} 2^{-nD\\left( \\tau \\right)}\n\\end{align}\n\nThis, if we fix $m$, and if there exists some $\\tau$ s.t. $D\\left( \\tau \\right) > 0$ then we get consistency\nby letting $n \\rightarrow \\infty$.\n\nWe note that to get the best bound we may maximizes the right hand side w.r.t. $\\tau$.\n\n\\subsection{Algorithm}\n\n\\begin{algorithm}[H]\n\n    \\caption{\\textbf{Residual method}: Method to decide whether $P_{X, Y}$ satisfies and ANM $X \\rightarrow Y$\n        or $Y \\rightarrow X$ , for an ANM given that the additive noise $P_Z$ is known.}\n  \n    \\textbf{Input}:\n\n    \\begin{enumerate}\n        \\item I.i.d samples $\\mathcal{D} = \\{ (x_i, y_i )\\}_{i \\in [N]}$ of $X$ and $Y$\n        \\item Noise distribution $P_Z$\n        \\item Regression method\n        \\item Score estimator $\\hat{C}: R^{m \\times m} \\rightarrow \\R$\n    \\end{enumerate}\n    \n    \\textbf{Output}: $\\hat{C}_{X \\rightarrow Y}$, $\\hat{C}_{Y \\rightarrow X}$, dir\n\n    \\begin{enumerate}\n\n        \\item \\textbf{Estimate regressions} \n        \n        \\begin{itemize}\n            \\item[--] $\\hat{f}_Y$ of the regression function $x \\mapsto \\E(Y | X=x)$\n            \\item[--] $\\hat{f}_X$ of the regression function $y \\mapsto \\E(X | Y=y)$\n        \\end{itemize}\n\n        \\item \\textbf{Estimate residuals} \n        \n        \\begin{itemize}\n            \\item[--] $ \\mathbf{\\hat{e}_{Y}} := \\mathbf{y} - \\hat{f}_Y(\\mathbf{x})$\n            \\item[--] $ \\mathbf{\\hat{e}_{X}} := \\mathbf{x} - \\hat{f}_X(\\mathbf{y})$\n        \\end{itemize}\n\n\n        \\item \\textbf{Discrete distribution} \n       \n        \\begin{itemize}\n            \\item[--] $P^*_Z :=$ discretized distribution of $P_Z$\n            \\item[--] $b :=$ histogram of $ \\mathbf{\\hat{e}_{Y}}$\n            \\item[--] $\\tilde{b} :=$ histogram of $ \\mathbf{\\hat{e}_{X}}$\n        \\end{itemize}\n\n        \\item \\textbf{Compute scores} to measure the difference between the residuals\n        \\begin{itemize}\n            \\item[--] $\\hat{C}_{X \\rightarrow Y}: = \\hat{C}( b, P^*_Z  )$ \n            \\item[--] $\\hat{C}_{Y \\rightarrow X}: = \\hat{C}( \\tilde{b}, P^*_Z  )$\n        \\end{itemize}        \n\n        \\item Output $\\hat{C}_{X \\rightarrow Y}$, $\\hat{C}_{Y \\rightarrow X}$, and\n        \n        \\[ \n        \\text{dir} :=  \n         \\begin{cases} \n            & X \\rightarrow Y \\quad \\text{if} \\; \\hat{C}_{X \\rightarrow Y} \\leq \\hat{C}_{Y \\rightarrow X}\\\\\n            & Y \\rightarrow X \\quad \\text{otherwise}\n         \\end{cases}\n        \\]\n        \n    \\end{enumerate}\n\n  \\label{alg:residual}\n  \\end{algorithm}", "meta": {"hexsha": "19a85059c7e45d5b54233c17112fdbda7d238d93", "size": 44426, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main/ch4_proposed.tex", "max_stars_repo_name": "Nacho114/EPFL_thesis_template", "max_stars_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main/ch4_proposed.tex", "max_issues_repo_name": "Nacho114/EPFL_thesis_template", "max_issues_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main/ch4_proposed.tex", "max_forks_repo_name": "Nacho114/EPFL_thesis_template", "max_forks_repo_head_hexsha": "e92f8b0b2d14d0a514dce0fc4a83a358481a4d20", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8408871745, "max_line_length": 169, "alphanum_fraction": 0.6409985144, "num_tokens": 14793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371502, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.41402276317270226}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[left=0.7in,right=0.7in,top=1in,bottom=0.7in]{geometry}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\n\\usepackage[sc]{mathpazo}\n\\newcommand{\\bN}{\\mathbb{N}}\n\\newcommand{\\bR}{\\mathbb{R}}\n\\newcommand{\\bC}{\\mathbb{C}}\n\\newcommand{\\bZ}{\\mathbb{Z}}\n\\newcommand{\\bQ}{\\mathbb{Q}}\n\n\\newcommand{\\A}{\\alpha}\n\n\\newcommand{\\e}{\\epsilon}\n\\newcommand{\\D}{\\delta}\n\n\\newcommand{\\liminfty}[1]{\\lim_{ #1 \\to \\infty}}\n\\newcommand{\\Hom}{\\mathrm{Hom}}\t\n\\newcommand{\\twom}[4]{\\[\\left[ \\begin{array}{cc} #1&#2\\\\#3&#4\\end{array}\\right]\\]}\n\\newcommand{\\diff}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\diffn}[3]{\\frac{\\partial^{#1} #2}{\\partial #3^{#1}}}\n\\newcommand{\\diffs}[2]{\\diffn{2}{#1}{#2}}\n\\newcommand{\\diffm}[3]{\\frac{\\partial^2 #1}{\\partial #2 \\partial #3}}\n\\newcommand{\\del}{\\nabla}\n\\newcommand{\\norm}[1]{\\left\\Vert #1 \\right\\Vert}\n\\newcommand{\\crossproductA}[6]{\\begin{vmatrix}\n\\vec i & \\vec j & \\vec k \\\\\n#1 & #2 & #3 \\\\\n#4 & #5 & #6 \\\\\n\\end{vmatrix}}\n\\newcommand{\\crossproductB}[6]{\\begin{vmatrix}\n#2 & #3 \\\\\n#5 & #6 \\\\\n\\end{vmatrix} \\vec i\n- \\begin{vmatrix}\n#1 & #3 \\\\\n#4 & #6 \\\\\n\\end{vmatrix} \\vec j\n+ \\begin{vmatrix}\n#1 & #2 \\\\\n#4 & #5 \\\\\n\\end{vmatrix} \\vec k\n}\n\n\\newcommand{\\cA}{\\mathcal{A}}\n\\newcommand{\\cB}{\\mathcal{B}}\n\\newcommand{\\cD}{\\mathcal{D}}\n\\newcommand{\\cP}{\\mathcal{P}}\n\\newcommand{\\cQ}{\\mathcal{Q}}\n\\newcommand{\\cR}{\\mathcal{R}}\n\n\\newcommand{\\colcup}[2]{\\bigcup_{#1 \\in #2} #1}\n\\newcommand{\\colcap}[2]{\\bigcap_{#1 \\in #2} #1}\n\n\\newcommand{\\colcalcup}[1]{\\colcup{#1}{\\mathcal{#1}}}\n\\newcommand{\\colcalcap}[1]{\\colcap{#1}{\\mathcal{#1}}}\n\n\\DeclareMathOperator{\\im}{Im}\n\n\\DeclareMathOperator{\\E}{\\mathbb{E}}\n\\DeclareMathOperator{\\Cov}{\\mathrm{Cov}}\n\\DeclareMathOperator{\\Var}{\\mathrm{Var}}\n\n\\newcommand{\\citebf}[1]{\\textbf{Citations: }#1}\n\\newcommand{\\alone}{\\citebf{I worked independently}}\n\\newcommand{\\lauren}{\\citebf{I worked on this problem with Lauren Pusey-Nazzaro}}\n\n\\usepackage{enumitem}\n\n\\title{Homework 12}\n\\author{Aidan Kelley}\n\\begin{document}\n\n\\section{Introduction}\n\nIn this project we propose a method for detecting sensor anomalies in time-series data based on the difference between the predicted and actual output of a sensor. We use a linear regression model to predict the output of a sensor based on the outputs of sensors on other channels. We additionally validate our model on fault-free data to determine how well our model correlates with actual sensor output. Then, we can run our model in real time and can detect sensor anomalies when the correlation between the actual and expected sensor data is far from the expected correlation.\n\n\\section{Assumptions}\n\nWe treat the data as if it were a point cloud, meaning that at each time step, $t$, the values of all channels at time $t$ as a vector are a point. We treat all points as if they are independent and are drawn from the same distribution.\n\n\\section{Problem Setting}\n\nSay that we have $n$ channels, $c_1, \\ldots, c_n$, and that $C_i(t)$ is the value of all channels but $i$ at a given time $t$.\n\nFor each channel $c_i$ we have a map $f_i: \\bR^{n - 1} \\to \\bR$ that, given the state of other channels at a given point in time, predicts the value of channel $i$. For each $f_i$, we also have the metric $\\rho_i$, where\n\n$$\\rho_i = \\frac{\\Cov_t(f_i(C_i(t)), c_i(t))}{\\sqrt{\\Var_t(f_i(C_i(t)))\\Var_t(c_i(t))}},$$\n\nwhich is the Pearson correlation coefficient between the predicted channel, given by $f_i(C_i(t))$ for a singe point in time, and the actual channel $c_i$. Note that $|\\rho_i|$ may not be large for some channels, meaning that our function $f_i$ does a poor job fitting this channel. However, our model in detecting anomalies will account for the fact that many fits may be imperfect.\n\nThen, we will use our model and some additional statistics to check for anomalies in real-time. At a high level, our model will calculate the correlation between how our model predicts what the sample will be versus what the sample actually is. For a window of length $k$, meaning entries from $t_0-k+1, \\ldots t_0$, where $t_0$ is the current time, we will find $r_i$, the test statistic, given by\n\n$$r_i = \\frac{\\Cov_{t_0 - k < t \\le t_0}(f_i(C_i(t)), c_i(t))}{\\sqrt{\\Var_{t_0 - k < t \\le t_0}(f_i(C_i(t)))\\Var_{t_0 - k < t \\le t_0}(c_i(t))}},$$\n\nWe will show how to calculate this test statistic efficiently (in $\\Theta(1)$ time amortized per window) and will show how to reject a sample as an anomaly using probabilistic methods.\n\nFor the rest of the discussion, we will fix some $t_0$ and some $k$. For notation purposes, let $X_j = f_i(C_i(t_0 - k + j))$ and $Y_j = c_i(t_0 - k + j)$ for $1 \\le j \\le k$, meaning that $X_j$ and $Y_j$ are the $j$th entries of the predicted and actual samples of the time series. Then, let $A$ and $B$ be the normalized version of $X$ and $Y$, meaning that\n\n$$A_i = \\frac{X_i - \\bar X}{\\sigma_X},\n~~~~~~~~~~~~~\nB_i = \\frac{X_i - \\bar Y}{\\sigma_Y},$$\n\nsuch that\n\n$$\\E[A] = \\E[B] = 0,\n~~~~~~~~~~~~~\n\\Var(A) = \\Var(B) = 1.$$\n\nIt is important to note that this normalization is really just a \"trick\" to simplify the calculations. We additionally note that it does not matter whether we use the sample variance (multiplied by $\\frac{k}{k - 1}$ or not as long as we are consistent and also use the sample covariance, as both result multiplying the top and bottom of the expression for $r_i$ by the same value. Now, with $A$ and $B$, we have that the expression for $r_i$ is\n\n$$r_i = \\frac{\\Cov(A, B)}{\\Var(A)\\Var(B)},$$\n\nbut since the $\\Var(A) = \\Var(B) = 1$, this is just\n\n$$r_i = \\Cov(A, B).$$\n\nThen, by the definition of the covariance and since we know the values of $A$ and $B$ this is just\n\n$$r_i = \\Cov(A, B) = \\E[AB] = \\frac{1}{k} \\sum_{i = 1}^k A_i B_i,$$\n\nwhich, interestingly, is the cosine-distance if we treat these as scalars (an aside: since $\\Var[A] = \\Var[B] = 1$, this says $\\frac{1}{k} \\norm{A}_2^2 = \\frac{1}{k} \\norm{B}_2^2 = 1$, meaning that $\\norm{A}_2 = \\norm{B}_2 = \\sqrt{k}$, so the cosine distance $\\frac{A \\cdot B}{\\norm{A}_2 \\norm{B}_2}$ is $\\sum_{i = 1}^k A_i B_i / \\sqrt{k * k} = \\frac{1}{k} \\sum_{i = 1}^k A_i B_i = r_i.$).\n\n\\section{Training $f_i$}\n\nEach $f_i$ is a linear model that takes in every channel but $c_i$ and predicts the value of $c_i$. If $z_i$ is the input that does not include the $i$th channel, we have that $f_i(z_i) = w_i \\cdot z_i + b_i$, where $w_i$ is a vector of weights and $b_i$ is a single bias. The model is trained using \\texttt{linear\\_model} from \\texttt{scikit-learn}.\n\n\\section{Detecting Anomalies}\n\nNow, we want to run a statistical test to determine if the window ending at $t_0$ represents an anomaly. Then, we use the two hypotheses:\n\n$$H_0: \\mu_{r_i} = \\rho_i,\n~~~~~~~~~~~\nH_a: \\mu_{r_i} \\ne \\rho_i.$$\n\nThe null hypothesis, $H_0$, represents that the correlation between this window of the data is the same as the correlation that we would expect. This then represents that the data is as expected and that there is no anomaly. $H_a$ represents some sort of anomaly in the window. Our goal will then be to calculate the probability $p$ that this window has correlation $r_i$ given that $H_0$ is true, and if $p$ is \"low enough\", meaning $p < \\alpha$ for an $\\alpha$ we will define later, then we can say with confidence that there is an anomaly.\n\nThen, to calculate this probability, we want to know the distribution of $r_i$. We can think of $A_i$ and $B_i$ themselves as being random variables, so $A_i B_i$ is a random variable, and by our assumptions these are independent and identically distributed. Then, since $r_i$ is a sum of independent indentically distributed random variables, the Central Limit Theorem applies, which says that in the limit (as $k \\to \\infty$), that $r_i$ is normally distributed. This gives us a good approximation for the distribution of $r_i$. Then, since we assume that $\\mu = \\rho$, the only parameter we need estimate is the standard deviation of $r_i$. We have that this is\n\n$$\\Var(r_i) = \\Var(\\frac{1}{k} \\sum_{i = 1}^k A_i B_i) = \\frac{1}{k^2} \\sum_{i =1}^k \\Var(A_i B_i),$$\n\nby linearity, but since $A_i B_i$ are all identically distributed, their variances are the same, so we can write this as\n\n$$ = \\frac{1}{k} \\Var(AB) = \\E((AB - r_i)^2) = \\frac{1}{k}\\left(\\E((AB)^2) - r_i^2\\right),$$\n\nby a well-know formula for variance. To calculate $\\E((AB)^2)$, we just do\n\n$$\\E((AB)^2) = \\frac{1}{k} \\sum_{i=1}^k (A_i B_i)^2.$$\n\nAdditionally, to get the sample variance, we multiply by $\\frac{k}{k-1}$, so the full formula for $S^2_{r_i}$ is\n\n$$\\Var(r_i) = \\frac{1}{k-1}\\left(\\frac{1}{k}\\sum_{i=1}^k (A_i B_i)^2 - r_i^2\\right).$$\n\nThen, this means that\n\n$$\\frac{r_i - \\rho}{\\sqrt{S^2_{r_i}}}$$\n\nis distributed approximately normally, which means that given some other standard normal random variable $N$ that the probability of drawing $r_i$ randomly under the assumption that $\\mu_{r_i} = \\rho$ is\n\n$$p \\approx P\\left(|N| \\ge \\left|\\frac{r_i - \\rho}{\\sqrt{S^2_{r_i}}}\\right|\\right)\n= 2P\\left(N \\le -\\left|\\frac{r_i - \\rho}{\\sqrt{S^2_{r_i}}}\\right|\\right),$$\n\nwhich we can calculate using existing normal CDF functions.\n\n\\section{Finding $r_i$ efficiently}\n\nWe can see from above that we can calculate $r_i$ in $\\Theta(k)$ time, where $k$ is the the size of the window, which isn't bad. However, if we want the anomaly detection system to work in real-time, we want to calculate $r_i$ faster than this. We will show a method for calculating $r_i$ in amortized $\\Theta(1)$ time and using $\\Theta(k)$ memory, assuming that we are calculating $r_i$ for every window of size $k$.\n\nThe method works by using two different queues that store the last $k$ values and additionally by maintaining a number of different accumulators that store some value that changes as we move from left to right. Each queue stores the last $k$ values of $X_i$ and $Y_i$. We have to spend $\\Theta(k)$ time initially populating each of the queues but when we move from the window ending at $t_0$ to the one ending at $t_0 + 1$, we extract the oldest element from each of the queues, say $X_0$ and $Y_0$, and replace it with the newest element, say $X_k$ and $Y_k$. Then, we use the old values to subtract off the accumulators and the new values to add to them to keep accurate. We'll denote $\\sum(Z)$ to be the accumulator $\\sum_{i = 1}^k Z_i$. For example, $\\sum(X) = \\sum_{i = 1}^k X_i$. We maintain the following accumulators:\n\n$$\\sum(X), \\sum(Y), \\sum(X^2), \\sum(Y^2), \\sum(XY), \\sum((XY)^2), \\sum(X^2 Y), \\sum(XY^2).$$\n\nFor calculating $r_i$, we have\n\n$$r_i = \\Cov(A, B) = \\Cov \\left( \\frac{X - \\bar X}{\\sigma_X}, \\frac{Y - \\bar Y}{\\sigma_Y}\\right)$$\n\n$$= \\frac{1}{\\sigma_X \\sigma_Y} \\Cov(X - \\bar X, Y - \\bar Y)$$\n$$ = \\frac{1}{\\sigma_X \\sigma_Y} (\\E[XY] - \\bar X \\bar Y).$$\n\nWe will write down how to calculate all of the variables in this expression in terms of our accumulators.\n\n$$\\sigma_X = \\sqrt{\\E[(X - \\E[X]^2)]}\n= \\sqrt{\\E[X^2] - \\E[X]^2}\n= \\sqrt{\\frac{1}{k} \\sum_{i = 1}^k X^2 - \\left(\\frac{1}{k} \\sum_{i=1}^k X \\right)^2}$$\n$$= \\frac{1}{k} \\sqrt{k\\sum(X^2) - \\sum(X)^2}\n$$\n$$\\sigma_Y = \\sqrt{\\E[(Y - \\E[Y]^2)]}\n= \\sqrt{\\E[Y^2] - \\E[Y]^2}\n= \\sqrt{\\frac{1}{k} \\sum_{i = 1}^k Y^2 - \\left(\\frac{1}{n} \\sum_{i=1}^k Y \\right)^2}$$\n$$= \\frac{1}{k} \\sqrt{\\sum(Y^2) - k\\sum(Y)^2}\n$$\n \n$$\\E[XY] = \\frac{1}{k} \\sum_{k = 1}^k X Y = \\frac{1}{k} \\sum(XY)$$\n$$\\bar X = \\E[X] = \\frac{1}{k} \\sum_{i = 1}^k X = \\frac{1}{k} \\sum(X)$$\n$$\\bar Y = \\E[Y] = \\frac{1}{k} \\sum_{i = 1}^k Y = \\frac{1}{k} \\sum(Y)$$\n\nNow, we will show how to calculate $\\Var(r).$ We know from above that this is\n$$\\Var(r) = \\frac{1}{k}\\left(\\E((AB)^2) - r^2\\right),$$\nso since we know $r$ (we just calculated it) we only need to find $\\E((AB)^2)$. Inserting the definitions for $A$ and $B$ this is\n\n$$\\E((AB)^2) = \\E\\left(\\left(\\frac{X - \\bar X}{\\sigma_X} \\cdot \\frac{Y - \\bar Y}{\\sigma_Y} \\right)^2 \\right)$$\n$$ = \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\E\\left((X - \\bar X)^2(Y - \\bar Y)^2 \\right)$$\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\E\\left((X^2 - 2X\\bar X + \\bar X^2)(Y^2 - 2Y\\bar Y + \\bar Y^2) \\right)$$\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\E\\left(X^2(Y^2 - 2Y\\bar Y + \\bar Y^2) - 2X\\bar X(Y^2 - 2Y\\bar Y + \\bar Y^2) + \\bar X^2(Y^2 - 2Y\\bar Y + \\bar Y^2) \\right)$$\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\E\\left(X^2Y^2 - 2X^2Y\\bar Y + X^2\\bar Y^2 - 2X\\bar X Y^2 + 4X\\bar XY\\bar Y  - 2X\\bar X \\bar Y^2 + \\bar X^2Y^2 - 2\\bar X^2Y\\bar Y + \\bar X^2\\bar Y^2) \\right)$$\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\left(\\E(X^2Y^2) - 2\\E(X^2Y)\\bar Y + \\E(X^2)\\bar Y^2 - 2\\E(XY^2)\\bar X\\right.$$ \n$$\\left. + 4\\E(XY) \\bar X\\bar Y  - 2\\E(X) \\bar X \\bar Y^2 + \\bar X^2 \\E(Y^2) - 2\\E(Y)\\bar X^2\\bar Y + \\bar X^2\\bar Y^2 \\right).$$\n\nThen, noting that $\\E[X] = \\bar X$ and $\\E[Y] = \\bar Y$, we can simply this further and some terms cancel out, getting\n\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\left(\\E(X^2Y^2) - 2\\bar Y \\E(X^2Y)+ \\bar Y^2\\E(X^2) - 2\\bar X\\E(XY^2) \\right.$$ \n$$\\left. + 4\\bar X\\bar Y \\E(XY) - 2\\bar X^2 \\bar Y^2 + \\bar X^2 \\E(Y^2) - 2\\bar X^2 \\bar Y^2 + \\bar X^2 \\bar Y^2 \\right).$$\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\left(\\E(X^2Y^2)  + \\bar X^2 \\E(Y^2) + \\bar Y^2\\E(X^2) - 2\\bar X\\E(XY^2) - 2\\bar Y \\E(X^2Y)  - 3 \\bar X^2 \\bar Y^2 + 4\\bar X\\bar Y \\E(XY)\\right).$$\n\nHowever, this can actually be further simplified. We can write it as\n\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\left(\\E(X^2Y^2)  + \\bar X^2 (\\E(Y^2) - \\bar Y^2) + \\bar Y^2( \\E(X^2) - \\bar X^2) - 2\\bar X\\E(XY^2) - 2\\bar Y \\E(X^2Y)  - \\bar X^2 \\bar Y^2 + 4\\bar X\\bar Y \\E(XY)\\right),$$\n\nwhich we can write as\n\n$$= \\frac{1}{\\sigma_X^2 \\sigma_Y^2}\\left(\\E(X^2Y^2)  + \\bar X^2 \\sigma_Y^2 + \\bar Y^2 \\sigma_X^2 - 2\\bar X\\E(XY^2) - 2\\bar Y \\E(X^2Y)  - \\bar X^2 \\bar Y^2 + 4\\bar X\\bar Y \\E(XY)\\right),$$\n\n\nThen, we have already described how to find $\\sigma_X, \\sigma_Y, \\bar X, \\bar Y,$ and $\\E[XY]$. in the previous calculation of $r_i$. We will show how to find the other variables in terms of the accumulators below:\n\n$$\\E[X^2Y^2] = \\E[(XY^2) = \\frac{1}{k} \\sum{i=1}^k (X_iY_i)^2 = \\frac{1}{k}\\sum((XY)^2)$$\n$$\\E[Y^2] = \\frac{1}{k} \\sum_{i = 1}^k Y_i^2 = \\frac{1}{k} \\sum(Y^2)$$\n$$\\E[X^2] = \\frac{1}{k} \\sum_{i = 1}^k X_i^2 = \\frac{1}{k} \\sum(X^2)$$\n$$\\E[XY^2] = \\frac{1}{k} \\sum_{i = 1}^k X_iY_i^2 = \\frac{1}{k} \\sum(XY^2)$$\n$$\\E[X^2Y] = \\frac{1}{k} \\sum_{i = 1}^k X_i^2Y_i = \\frac{1}{k} \\sum(X^2Y)$$\n\n\\section{Choosing $\\alpha$}\n\nWhen we run our statistical test, we will reject $H_0$ if $p < \\alpha$, meaning that we detect an anomaly. However, since we will our anomaly detection algorithm will be running many times, if we set $\\alpha = 0.05$, if the algorithm run 100 times and there are no malfunctioning sensors, we will still report on average 5 anomalies. Then, we see that we need to make $\\alpha$ much lower. We will set $\\alpha$ such that, given every sensor is working (meaning $H_0$ is true) the probability that there will be no reported anomalies is $\\alpha_0$. Then, if the probability of a single test reporting an anomaly is $\\alpha$, the probability it does not report one is $1 - \\alpha$, so the probability that given $N$ tests we return no anomalies is $(1 - \\alpha)^N$. Then, the probability of at least one anomaly being reported is $1 - (1- \\alpha)^N$, so we want to have $1 - (1 - \\alpha)^N < \\alpha_0$, so\n$$1 - \\alpha_0 < (1 - \\alpha)^N$$\n$$\\sqrt[n]{1 - \\alpha_0} < 1 - \\alpha$$\n$$\\alpha < 1 - \\sqrt[n]{1 - \\alpha_0}.$$\n\nThen, for example, if we want $\\alpha_0 = 0.05$, so if we have $N = 200,000$ tests and want $\\alpha_0 = 0.05$, then $\\alpha = 2.564 \\times 10^{-7}$.\n\\clearpage\n\\section{Evaluating the Approximation}\n\nHere we will experimentally evaluate how well the approximation of assuming $r_i$ is normally distributed works. With $10,000$ trials in each test, we randomly generated $k$ data points of standard normal $X$ and $Y$s which have correlation coefficient $\\rho$, and used $X$ as the predicted sample and $Y$ as the actual sample. We ran the test in each trial and calculated a $p$-value. The distributions of the $p$-values in the cases we tested are shown below.\n\n\\includegraphics[width=0.33\\linewidth]{rho01k50.png}\n\\includegraphics[width=0.33\\linewidth]{rho05k50.png}\n\\includegraphics[width=0.33\\linewidth]{rho09k50.png}\n\n\\includegraphics[width=0.33\\linewidth]{rho1k500.png}\n\\includegraphics[width=0.33\\linewidth]{rho05k500.png}\n\\includegraphics[width=0.33\\linewidth]{rho09k500.png}\n\nIf the approximation worked well, we would expect that $p$-values would be uniformly distributed. We see that this is the case for $\\rho = 0.1$. Unfortunately, for high $\\rho$, we see that the approximation breaks down. We see that in cases where the two series are highly correlated that the chance of a low $p$-value is very low. However, while this isn't optimal, it also isn't terrible as it just means that the false-positive rate of detecting anomalies will be lower.\n\n\\section{Improvements}\n\nThere are several things that could be improved for our model.\n\n\\subsection{Detecting out-of-range failures}\n\nSince our model is based on the shape of the data itself, it can detect subtle in-range failures but will not work well for out of range failures that do not otherwise have some anomalous shape.\n\n\\subsection{Changing how we compute $p$-values}\n\nWe can see from the graphs in the previous section that the test does not give a uniform distribution of $p$-values as we would hope. In his paper, \"A note on the distribution of the product of zero mean correlated normal random variables\", Gaunt describes a way that $r_i$ should be distributed if we assume $X$ and $Y$ are normal (this is another assumption, but it may be a better one than assuming $r_i$ is normal). We tried to implement this model initially, but gave up after running into issues with the numerical integration.\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "ab85417e5868822884a8883b4f392ca1c147cf0e", "size": 17751, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/hackmath.tex", "max_stars_repo_name": "devYaoYH/hackillinois_2020", "max_stars_repo_head_hexsha": "36fdcd2e4848d2b7f513ee729dc124dbdbeb3125", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentation/hackmath.tex", "max_issues_repo_name": "devYaoYH/hackillinois_2020", "max_issues_repo_head_hexsha": "36fdcd2e4848d2b7f513ee729dc124dbdbeb3125", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/hackmath.tex", "max_forks_repo_name": "devYaoYH/hackillinois_2020", "max_forks_repo_head_hexsha": "36fdcd2e4848d2b7f513ee729dc124dbdbeb3125", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.5836177474, "max_line_length": 902, "alphanum_fraction": 0.6715114641, "num_tokens": 6190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.41402276285300765}}
{"text": "\\chapter{Localization}\n\nIn a few previous chapters, we have covered the steps to obtain a position of\nan object in 2D images. In this chapter, we will take a closer look at\nobtaining a position of an object in the world coordinates by combining\ninformation from multiple cameras.\n\nAt this point we have computed not only intristic matrices of the cameras but\nalso the rotation matrix and the translation vector (from mono camera\ncalibration and stereo calibration). Our goal is to get a position of the\nobject in world coordinates from tuple of coordinates from the images taken by\ncameras.\n\n\\section{Projection matrices}\nProjection matrices provide us way to transform world coordinates to image\ncoordinates. Our first step is to find out projection matrices for both cameras\nand then we will use them for solving triangulation problem.\n\nWe define projection matrix as transformation matrix P, where stands: $x = P\n\\dot X$, where $X$ denote a vector of size 4$\\times$1 -- homogenous world coordinates\nof the object and $x$ denotes homogenous object coordinates in the image plane\nof the camera -- a vector 3$\\times$1.\n\n\\subsection{World coordinate system}\nWe define our world coordinate system as orthogonal, with the origin in the\ncenter of projection of the first (usually left) camera. The positive part\nz-axis is pointing in front of the camera and below the camera is positive\ny-axe and to the right is positive x-axe. Layout and coordinate system may be\nseen on image \\ref{fig:coordinate-system}.\n\n\\begin{figure}\n\\centering\n\\includegraphics{img/camera-positions}\n\\caption{Cameras layout and coordinate system}\n\\label{fig:coordinate-system}\n\\end{figure}\n\n\\subsection{Computing projection matrices}\nAfter defining our coordinate systems we can compute projection matrices for\nboth cameras. We use projection matrix decomposition to get projection matrix\nfrom calibration results.\n\nProjection matrix can be decomposed as $P = K[R|T]$, where $K$ is intristic\ncamera matrix and $[R|T]$ is extrinstic matrix. $R$ is a rotation matrix and\n$T$ translation vector. We use this decomposition to compute our projection\nmatrices.\n\n\\emph{First camera}\nSince we settted the origin of the world coordinate system in the first camera,\nthe camera has no rotation nor translation to the coordinate system. Therefore\nwe compute a projection matrix as:\n\n\\[\n P_1 = K_1 \\cdot \\begin{pmatrix}\n\tI_3 & | & 0_3  \n\\end{pmatrix}\n\\]\n\nWhere $K_1$ denotes first camera instrictic parameters matrix, $I_3$ identity\nmatrix 3$\\times$3 and $0_3$ zero vector. Only intristic parameters matrix take\neffect on given coordinates, computing from world coordinates coordinates in\nimage plane of the camera.\n\n\\emph{Second camera}\nFor the second camera projection matrix stereo calibration results will be\nused. We know the rotation matrix and translation vector between the cameras,\nbeing able to get coordinates of the second camera relatively to the first one.\n\nWe now use this information in construction of projection matrix. $P_2 = K_2\n\\dot [R | T]$, where $K_2$ is second camera intristic parameters matrix, $R$\nrotation matrix and $T$ translation vector.\n\nMore about the decomposition itself could be found in an article by\n\\citet{computervisionblog}.\n\n\\todo[inline]{V programme aktualne nerobim s distortion coeffs, pretoze uz aj bez toho su rozumne vysledky}\n\n\\section{Triangulation}\nNow when we know the projection matrices we can formalize our problem as\n\\begin{equation}\nx_1 = P_1X, x_2 = P_2X \\label{projection-statements}\n\\end{equation}\nwith the goal to find $X$. Since errors may occure during\nmeasurement of $x_1$, $x_2$ and calibration. In further steps we consider that\ncalibration results are provided with high accurancy compared to measurement of\n$x_1$ and $x_2$ (that is the reason to have longer calibration with more images\nat once).\n\n\\subsection{Simple linear triangulation}\nWe are going to shortly describe how is triangulation working under the hood.\n\nThe results of cross product of vector itself is zero vector. We can write\nequation \\ref{projection-statements} as crossproduct $x \\times (PX) = 0$. We\ndenote point $x = (x, y, w)$, where $w = 1$ since these coordinates are\nhomogenous -- in other words up to scale factor $w$.\n\nWe can then rewrite $x \\times (PX) = 0$ in following way:\n\n$$ w(p^{3T}X) - x(p^{2T}X) = 0 $$\n$$ y(p^{3T}X) - w(p^{1T}X) = 0 $$\n$$ x(p^{2T}X) - y(p^{1T}X) = 0 $$\n\nWhere $p^{iT}$ denotes ith row of $P$. Since $w = 1$ we can equally write:\n\n$$ x(p^{3T}X) - (p^{1T}X) = 0 $$\n$$ y(p^{3T}X) - (p^{2T}X) = 0 $$\n$$ x(p^{2T}X) - y(p^{1T}X) = 0 $$\n\nThese equations are linear in the components of X. Only two equations are\nlinear independent, since the third one could be obtained as the sum $y$\ntimes the first row and $-x$ times the second row.\n\nTherefore an equation of form $AX = 0$ can then be composed using two points $x_1 = (x, y, 1)$ and $x = (m, n, 1)$:\n\n\\[\nA = \\begin{pmatrix}\nx(p_1^{3T}X) - (p_1^{1T}X) \\\\\ny(p_1^{3T}X) - (p_1^{2T}X) \\\\\nm(p_2^{3T}X) - (p_2^{1T}X) \\\\\nn(p_2^{3T}X) - (p_2^{2T}X) \\\\\n\\end{pmatrix}\n\\]\n\nFor each image two equations were included, giving a total of four equations in\nfour homogeneous unknowns.\n\nWithout an error during measurements a point $X$ satisfying $AX = 0$ would\nexist. However, due to the errors it might not exists. As the next step Homogenous\nmethod (DLT) is used to find the solution. More about the method could be found\nin \\citet*{multiple-view-geometry}.\n\n\\section{Implementation note}\nFor the triangulation we used OpenCV function triangulatePoints($P_1$, $P_2$,\n$x_1$, $x_2$), which is based on simple triangulation method with use of DLT\nmethod for solving equations.\n", "meta": {"hexsha": "f744e16d33c0f0c3dd5c88fcb3fe8ad837333206", "size": 5636, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text/sk/localization.tex", "max_stars_repo_name": "JankaSvK/thesis", "max_stars_repo_head_hexsha": "c440ab8242b058f580fdf9d5a1d00708a1696561", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-29T14:13:47.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-29T14:13:47.000Z", "max_issues_repo_path": "text/sk/localization.tex", "max_issues_repo_name": "JankaSvK/thesis", "max_issues_repo_head_hexsha": "c440ab8242b058f580fdf9d5a1d00708a1696561", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-04-24T18:30:00.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-11T23:25:07.000Z", "max_forks_repo_path": "text/sk/localization.tex", "max_forks_repo_name": "JankaSvK/thesis", "max_forks_repo_head_hexsha": "c440ab8242b058f580fdf9d5a1d00708a1696561", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4411764706, "max_line_length": 115, "alphanum_fraction": 0.7539034776, "num_tokens": 1540, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.4140227560712604}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{III}\n\n\\def\\ntitle{Lie Algebras and Their Representations}\n\\def\\nlecturer{I.\\ Grojnowski}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2019}\n\n\\input{header}\n\n\\DeclareMathOperator{\\Mat}{Mat}\n\\newcommand*{\\Lie}[1]{\\mathfrak{#1}} % Lie groups\n\\renewcommand*{\\P}{\\mathbb{P}}\n\\newcommand{\\ad}{\\mathrm{ad}} % adjoint\n\\let\\ch\\relax\n\\DeclareMathOperator{\\ch}{ch} % character\n\\DeclareMathOperator{\\cha}{ch} % characteristic\n%\\newcommand*{\\gg}{\\Lie{g}}\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\section{Introduction \\& Motivation}\n\nThe objects of interest in this course are\n\\begin{align*}\n  \\SL_n &= \\{A \\in \\Mat_n: \\det A = 1\\} \\\\\n  \\SO_n &= \\{A \\in \\SL_n: AA^T = I\\} \\\\\n  \\Sp_{2n} &= \\cdots\n\\end{align*}\nand five more examples. First of all they are algebraic groups.\n\nWe have \\(\\SU_2 \\subseteq \\SL_2\\). Note that \\(\\SU_2\\) is homeomorphic to \\(S^3\\) and so is compact. In fact it is maximal compact and every maximal compact subgroup of \\(\\SL_2\\) is conjugate to \\(\\SU_2\\).\n\nWe will look at the tangent space of the group at the identity, which is just a finite-dimensional vector space.\n\n\\begin{definition}\n  A \\emph{linear algebraic group} is a subgroup of \\(\\Mat_n\\) which is defined by polynomial equations in the matrix coefficients.\n\\end{definition}\n\nFor example \\(\\SL_n\\) and \\(\\SO_n\\) are linear algebraic groups. \\(\\GL_n\\) is also an example as we have embedding\n\\begin{align*}\n  \\GL_n &\\to \\Mat_{n + 1} \\\\\n  A &\\to\n      \\begin{pmatrix}\n        A & \\\\\n        & \\lambda\n      \\end{pmatrix}\n\\end{align*}\nwhere the image is given by \\(\\det A \\cdot \\lambda = 1\\).\n\n\\begin{eg}\n  Let \\(G = \\SL_2\\) and let\n  \\[\n    g =\n    \\begin{pmatrix}\n      1 & \\\\\n      & 1\n    \\end{pmatrix}\n    + \\varepsilon\n    \\begin{pmatrix}\n      a & b \\\\\n      c & d\n    \\end{pmatrix}\n    + \\cdots\n  \\]\n  so\n  \\[\n    \\det g = 1 + \\varepsilon(a + d) + \\text{higher terms}\n  \\]\n  so \\(\\det g = 1\\) if and only if \\(a + d = 0\\) if we pretend to be physicists for a second. Now introduce the dual numbers\n  \\[\n    E = \\C[\\varepsilon]/(\\varepsilon^2) = \\{a + b \\varepsilon: a, b \\in \\C\\}.\n  \\]\n  If \\(G\\) is an algebraic group then we define\n  \\[\n    G(E) = \\{A \\in \\Mat_n(E): A \\text{ satisfies the defining equations of } G\\}.\n  \\]\n  Then\n  \\[\n    \\SL_2(E) = \\{\n    \\begin{pmatrix}\n      \\alpha & \\beta \\\\\n      \\gamma & \\delta\n    \\end{pmatrix}\n    : \\alpha, \\beta, \\gamma, \\delta \\in E, \\alpha \\delta - \\beta \\gamma = 1\\}\n  \\]\n  Now the map \\(E \\to \\C, \\varepsilon \\mapsto 0\\) defines a map \\(\\pi: G(E) \\to G\\). We define the \\emph{Lie algebra}\\index{Lie algebra} of \\(G\\) to be\n  \\[\n    \\Lie g \\cong \\pi^{-1}(I) \\cong \\{X \\in \\Mat_n(\\C): I + \\varepsilon X \\in G(E)\\}.\n  \\]\n  In particular,\n  \\[\n    \\SL_2 = \\{\n    \\begin{pmatrix}\n      a & b \\\\\n      c & d\n    \\end{pmatrix}\n    \\in \\Mat_2(\\C): a + d = 0\\}.\n  \\]\n\\end{eg}\n\n\\begin{ex}\n  Show that \\(G(E) = TG\\) is the tangent bundle of \\(G\\) and \\(\\Lie g\\) is the tangent space at \\(1\\), \\(I + X \\varepsilon\\) is the germ of a curve through \\(1 \\in G\\).\n\\end{ex}\n\n\\begin{eg}\n  Let \\(G = \\GL_n\\). Then\n  \\begin{align*}\n    G(E) &= \\{\\tilde A \\in \\Mat_n(E): \\tilde A^{-1} \\text{ exists}\\} \\\\\n         &= \\{A + B \\varepsilon: A, B \\in \\Mat_n(\\C), A^{-1} \\text{ exists}\\}\n  \\end{align*}\n  where the second equality is because\n  \\[\n    (A + B \\varepsilon) (A^{-1} - A^{-1}B A^{-1} \\varepsilon) = I.\n  \\]\n  So there is no condition on \\(B\\) so \\(\\Lie{gl}_n = \\Mat_n(\\C)\\). Another explantion for this result is that \\(\\det\\) does not vanish in a neighbourhood of the identity matrix so we get all matrices in the Lie algebra.\n\\end{eg}\n\n\\begin{ex}\n  Let \\(G = \\SL_n\\). Show that\n  \\[\n    \\det (I + \\varepsilon X) = 1 + \\varepsilon \\tr X\n  \\]\n  and hence\n  \\[\n    \\Lie{sl}_n = \\{X \\in \\Mat_n(\\C): \\tr X = 0\\}.\n  \\]\n\\end{ex}\n\n\\begin{eg}\n  Let\n  \\[\n    G = \\OO_n = \\{A \\in \\Mat_n: AA^T = I\\}.\n  \\]\n  Then\n  \\begin{align*}\n    \\Lie g &= \\{X \\in \\Mat_n(\\C): (I + \\varepsilon X)(I + \\varepsilon X)^T = I\\} \\\\\n                &= \\{X \\in \\Mat_n(\\C): X + X^T = 0\\}\n  \\end{align*}\n  Note \\(\\tr X^T = \\tr X\\) so \\(\\tr X = \\tr X^T = 0\\). Thus \\(\\SO_n\\) has the same Lie algebra. In other words, by just looking into the Lie algebras we cannot distinguish the groups \\(\\OO_n\\) and \\(\\SO_n\\). This is because \\(\\OO_n\\) has two connected component, and the component of the identity is \\(\\SO_n\\). Of course the tangent space at the identity doesn't tell us anything in the other component. Thus this undesirable situation can be remedied by restricting to connected Lie groups.\n\\end{eg}\n\nWhat structure does \\(\\Lie g\\) have that it inherits from \\(G\\)? It is not a (multiplicative) group as\n\\[\n  (I + A \\varepsilon) (I + B \\varepsilon) = I + \\varepsilon (A + B)\n\\]\nhas nothing to do with multiplication. Instead, we can consider the commutator\n\\begin{align*}\n  G \\times G &\\to G \\\\\n  (P, Q) &\\mapsto PQP^{-1}Q^{-1}\n\\end{align*}\nThis sends \\((I, I) \\mapsto I\\) so by differentiating at the origin we get a map \\(\\Lie g \\times \\Lie g \\to \\Lie g\\). Actually, we want a bilinear map \\(\\Lie g \\times \\Lie g \\to \\Lie g\\), so differentiate in each variable separately: fix \\(P\\) and differentiate \\(f_P: Q \\mapsto PQP^{-1}Q^{-1}\\) to get \\(df_P: \\Lie g \\to \\Lie g\\). Then we differentiate it as a function of \\(P\\).\n\nExplicitly, write\n\\begin{align*}\n  P &= I + \\varepsilon A \\\\\n  Q &= I + \\delta B\n\\end{align*}\nwhere \\(\\varepsilon^2 = \\delta^2 = 0, \\varepsilon \\delta = \\delta \\varepsilon \\neq 0\\). Then\n\\[\n  PQP^{-1}Q^{-1} = I + (AB - BA) \\varepsilon\\delta\n\\]\nso the map constructed out of the commutators is\n\\begin{align*}\n  \\Lie g \\times \\Lie g &\\to \\Lie g \\\\\n  (A, B) &\\mapsto AB - BA\n\\end{align*}\nThis is called the \\emph{Lie bracket} of \\(A\\) and \\(B\\).\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show by differentiation that\n    \\[\n      (PQP^{-1}Q^{-1})^{-1} = QPQ^{-1}P^{-1}\n    \\]\n    implies that\n    \\[\n      [B, A] = -[A, B]\n    \\]\n    so the Lie bracket is anti-symmetric.\n  \\item Show associativity of multiplication implies that\n    \\[\n      [[X, Y], Z] + [[Y, Z], X] + [[Z, X], Y] = 0.\n    \\]\n    This is the \\emph{Jacobi identity}.\n\n    Also show this is true from the definition \\([A, B] = AB - BA \\in \\Mat_n\\).\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{definition}[Lie algebra]\\index{Lie algebra}\n  Let \\(k\\) be a field, \\(\\cha k \\neq 2\\). A \\emph{Lie algebra} \\(\\Lie g\\) is a \\(k\\)-vector space equipped with a bilinear map \\([\\cdot, \\cdot]: \\Lie g \\times \\Lie g \\to \\Lie g\\) that\n  \\begin{enumerate}\n  \\item is anti-symmetric: \\([X, Y] = - [Y, X]\\),\n  \\item satisfies the Jacobi identity\n    \\[\n      [[X, Y], Z] + [[Y, Z], X] + [[Z, X], Y] = 0.\n    \\]\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\Lie{gl}_n = \\Mat_n\\) with \\([A, B] = AB - BA\\). More generally, if \\(V\\) is a vector space, write \\(\\Lie{gl}(V) = \\End(V)\\).\n  \\item \\(\\Lie{so}_n = \\{A \\in \\Lie{gl}_n: A + A^T = 0\\}\\).\n  \\item \\(\\Lie{sl}_n = \\{A \\in \\Lie{gl}_n: \\tr A = 0\\}\\).\n  \\item \\(\\Lie{sp}_{2n} = \\{A \\in \\Lie{gl}_{2n}: JA^TJ^{-1} + A = 0\\}\\) where\n    \\[\n      J =\n      \\begin{psmallmatrix}\n        & & & & & 1 \\\\\n        & & & & 1 \\\\\n        & & & \\cdots \\\\\n        & -1 \\\\\n        -1\n      \\end{psmallmatrix}\n    \\]\n  \\item \\(\\Lie{b}_n = \\{\n    \\begin{psmallmatrix}\n      * & \\cdots & * \\\\\n      & \\ddots & * \\\\\n      0 & & *\n    \\end{psmallmatrix}\n    \\}\n    \\) of upper triangular matrices.\n  \\item \\(\\Lie u_n\\) of strictly upper triangular matrices.\n  \\item If \\(V\\) is any vector space, let \\([\\cdot, \\cdot]: V \\times V \\to V\\) be the zero map. This is a Lie algebra, called \\emph{abelian Lie algebra}.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show \\(\\Lie{gl}_n\\) is a Lie algebra.\n  \\item Show examples 2 - 7 are sub-Lie algebras of \\(\\Lie{gl}_n\\).\n  \\item Find algebraic groups whose Lie algebras are the examples above.\n  \\item Show \\(\\{\n    \\begin{psmallmatrix}\n      * & * \\\\\n      * & 0\n    \\end{psmallmatrix}\n    \\} \\subseteq \\Lie{gl}_2\\) is not a Lie algebra.\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{eg}\n  Any \\(1\\)-dim Lie algebra is abelian by anti-symmetry.\n\\end{eg}\n\n\\begin{ex}\n  Classify all Lie algebras of dimension \\(3\\).\n\\end{ex}\n\n\\begin{definition}[representation]\\index{representation}\n  A \\emph{representation} of a Lie algebra \\(\\Lie g\\) on a vector space \\(V\\) is a Lie algebra homomorphism \\(\\Lie g \\to \\Lie{gl}(V)\\). We say \\(\\Lie g\\) acts on \\(V\\).\n\\end{definition}\n\nWe have the silly example of trivial representation: \\(\\Lie g\\) acts on \\(V = k\\) by \\(x \\mapsto 0\\).\n\nLess trivially, for any \\(x \\in \\Lie g\\), define\n\\begin{align*}\n  \\ad x: \\Lie g &\\to \\Lie g \\\\\n  y &\\mapsto [x, y]\n\\end{align*}\n\n\\begin{lemma}\n  \\(\\ad: \\Lie g \\to \\End(\\Lie g)\\) is a representation of \\(\\Lie g\\), i.e.\\ \\(\\Lie g\\) acts on it self. This is called the \\emph{adjoint representation}\\index{adjoint representation}.\n\\end{lemma}\n\n\\begin{proof}\n  Must show\n  \\[\n    \\ad [x, y] = \\ad x \\ad y - \\ad y \\ad x.\n  \\]\n  If \\(z \\in \\Lie g\\) then\n  \\begin{align*}\n    (\\ad [x, y])(z) &= [[x, y], z] \\\\\n    \\text{RHS}(z) &= [x, [y, z]] - [y, [x, z]] = -[[y, z], x] - [[z, x], y]\n  \\end{align*}\n  and they are equal by Jacobi.\n\\end{proof}\n\n\\begin{definition}[center]\\index{center}\n  The \\emph{center} of \\(\\Lie g\\) is\n  \\[\n    \\{x \\in \\Lie g: [x, y] = 0 \\text{ for all } y \\in \\Lie g\\} = \\ker (\\ad: \\Lie g \\to \\Lie{gl}(\\Lie g)),\n  \\]\n  which is an abelian Lie algebra.\n\\end{definition}\n\nIn particular, the center of \\(\\Lie g\\) is \\(0\\) if and only if \\(\\ad\\) is an embedding. Question: does every finite-dimensional Lie algebra \\(\\Lie g\\) have a faithful finite-dimensional representation? In other words, does \\(\\Lie g \\embed \\Lie{gl}(V)\\) for some \\(V\\)?\n\nNote: every affine algebraic group has a faithful representation.\n\n\\begin{theorem}[Ado]\n  Any finite-dimensional Lie algebra \\(\\Lie g\\) over \\(k\\) has a faithful finite-dimensional rep, i.e.\\ \\(\\Lie g \\embed \\Lie{gl}_n\\) for some \\(.\\)\n\\end{theorem}\n\n\\begin{eg}\n  Let \\(\\Lie g = \\Lie{sl}_2\\) with basis\n  \\[\n    e =\n    \\begin{pmatrix}\n      0 & 1 \\\\\n      0 & 0\n    \\end{pmatrix},\n    f =\n    \\begin{pmatrix}\n      0 & 0 \\\\\n      1 & 0\n    \\end{pmatrix},\n    h =\n    \\begin{pmatrix}\n      1 & 0 \\\\\n      0 & -1\n    \\end{pmatrix}\n  \\]\n  so we have\n  \\[\n    [e, f] = h,\n    [h, e] = 2e,\n    [h, f] = -2f\n  \\]\n  so a representation of \\(\\Lie{sl}_2\\) is a triple of matrices \\(E, F, H \\in \\Mat_n\\) with these relations. How can we find such? The answer, at this moment, is to find reps of the algebraic group \\(\\SL_2\\) and differentiating. Later we will find them just by using linear algebra.\n\\end{eg}\n\n\\begin{definition}[algebraic representation]\\index{algebraic representation}\n  If \\(G\\) is an algebraic group. An \\emph{algebraic representation} of \\(G\\) on a vector space \\(V\\) is a homomorphism \\(G \\to \\GL(V)\\) defined by polynomial equations in the matrix coefficients.\n\\end{definition}\n\nLet \\(\\rho: G \\to \\GL(V)\\) be an algebraic rep. We have \\(\\rho(I) = I\\). Consider the map \\(G(E) \\to \\GL(V)(E)\\). We get\n\\[\n  \\rho(I + A\\varepsilon) = I + \\varepsilon d\\rho(A)\n\\]\nfor some function \\(d\\rho(A)\\) of \\(A\\).\n\n\\begin{ex}\n  \\(d \\rho\\) is the derivative of \\(\\rho\\) at identity.\n\\end{ex}\n\n\\begin{ex}\n  \\(\\rho: G \\to \\GL(V)\\) implies that \\(d\\rho: \\Lie g \\to \\Lie{gl}(V)\\) is a Lie algebra homomorphism, so \\(V\\) is a representation of \\(\\Lie g\\).\n\\end{ex}\n\nLet \\(G = \\SL_2\\) and let \\(L(n)\\) be homogeneous polynomials in \\(x, y\\) of degree \\(n\\), with basis \\(x^n, x^{n - 1}y, \\cdots, y^n\\), so has dimension \\(n + 1\\). \\(\\GL_2\\) acts on \\(L(n)\\) by change of coordinates: if \\(g =\n\\begin{pmatrix}\n  a & b \\\\\n  c & d\n\\end{pmatrix}\n\\), \\(f \\in L(n)\\) then\n\\[\n  (\\rho_n(g)f)(x, y) = f(ax + cy, bx + dy).\n\\]\nCheck that\n\\begin{enumerate}\n\\item \\(\\rho_0\\) is the trivial rep.\n\\item \\(\\rho_1\\) is the usual \\(2\\)-dim rep.\n\\item\n  \\[\n    \\rho_2\n    \\begin{pmatrix}\n      a & b \\\\\n      c & d\n    \\end{pmatrix}\n    =\n    \\begin{pmatrix}\n      a^2 & ab & b^2 \\\\\n      2ac & ad + bc & 2bd \\\\\n      c^2 & cd & d^2\n    \\end{pmatrix}\n  \\]\n\\end{enumerate}\nDifferentiate and we get an action of \\(\\Lie{sl}_2\\) on \\(L(n)\\). Explicitly,\n\\[\n  \\rho(I + \\varepsilon e) x^iy^j\n  = x^i (y + \\varepsilon x)^j\n  = x^iy^j + \\varepsilon jx^{i + 1} y^{j - 1}\n\\]\nand hence\n\\[\n  d\\rho(e) x^iy^j = jx^{i + 1} y^{j - 1}.\n\\]\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item The Lie algebra acts by\n    \\begin{align*}\n      e \\cdot (x^iy^j) &= jx^{i + 1} y^{j - 1} \\\\\n      f \\cdot (x^iy^j) &= ix^{i - 1} y^{j + 1} \\\\\n      h \\cdot (x^iy^j) &= (i - j) x^iy^j\n    \\end{align*}\n  \\item Check directly this gives a rep of \\(\\Lie{sl}_2\\).\n  \\item Show \\(L(2)\\) is isomorphic to the adjoint rep.\n  \\item Show that\n    \\[\n      e = x \\frac{\\partial  }{\\partial y}, f = y \\frac{\\partial  }{\\partial x}, h = x \\frac{\\partial  }{\\partial x} - y \\frac{\\partial  }{\\partial y}\n    \\]\n    defines an (infinite-dimensional) rep of \\(\\Lie{sl}_2\\) on \\(k[x, y]\\). Some implication: this can be defined for all characteristics, and the differential operator is suggesting that reps of Lie groups might have something to do with calculus.\n  \\item Show if \\(\\cha k = 0\\) then \\(L(n)\\) is irreducible as an \\(\\Lie{sl}_2\\), hence \\(\\SL_2\\)-module.\n  \\end{enumerate}\n\\end{ex}\n\nThe map \\(\\rho \\mapsto d \\rho\\) defines a functor from the category of a linear algebraic group \\(G\\) to the category of Lie algebra reps of \\(\\Lie g\\). However, this is not as nice a map as you might hope.\n\n\\begin{eg}\n  Let \\(G = \\C^\\times\\) so \\(\\Lie g = \\C\\) is the abelian Lie algebra. A rep of \\(\\Lie g\\) on a vector space \\(V\\) is the same as an element \\(A \\in \\End(V)\\). A submodule \\(W \\subseteq V\\) is a subspace \\(W\\) such that \\(gW \\subseteq W\\), i.e.\\ \\(A \\cdot W \\subseteq W\\), so the same as an \\(A\\)-subspace of \\(V\\). Check that \\(A\\) and \\(A'\\) in \\(\\End(V)\\) determine isomorphic reps of \\(\\Lie g\\) if and only if \\(A, A'\\) are conjugate. Hence isomorphism classes of reps of \\(\\Lie g = \\C\\) is in bijection with conjugacy classes of matrices, and hence is determined by its Jordan normal form.\n\n  In addition, any \\(A \\in \\End(V)\\) has an eigenvector as \\(V\\) is a vector space over \\(\\C\\). Thus the only irreducible rep of \\(\\Lie g\\) are the 1-dim ones.\n\n  A rep is isomorphic to a direct sum of irred reps if and only if \\(A\\) is diagonalisable. For example if \\(A =\n  \\begin{psmallmatrix}\n    0 & 1 \\\\\n    & 0 & 1 \\\\\n    & & & \\ddots \\\\\n    & & & & 1 \\\\\n    & & & & 0\n  \\end{psmallmatrix}\n  \\) then the associated rep is \\emph{indecomposable}, i.e.\\ it does not split into a direct sum, as the only \\(A\\)-subspaces are \\(\\langle e_1, \\rangle, \\langle e_1, e_2 \\rangle, \\cdots, \\langle e_1, \\dots, e_n \\rangle\\).\n\n  Now in constrast consider reps of \\(G = \\C^\\times\\). It is a theorem that the irred algebraic reps of \\(\\C^\\times\\) are the 1-dim reps where \\(z \\in \\C^\\times\\) acts on \\(\\C\\) by \\(z \\cdot v = z^n v\\) for \\(n \\in \\Z\\). In other words they are given by \\(G \\to \\GL_1, z \\mapsto z^n\\). Moreover, any finite-dimensional rep of \\(G\\) is a direct sum of irreducible (this is similar to the proof that the only irred reps of the compact group \\(S^1\\) are given by \\(z \\mapsto z^n\\), once we set up the theory of algebraic groups).\n\\end{eg}\n\n\\begin{ex}\n  Show \\(\\rho \\mapsto d\\rho\\) sends \\(z \\mapsto z^n\\) to the algebraic rep \\(n \\in \\C\\).\n\\end{ex}\n\nThe rep of Lie algebra \\(\\C\\) is continuous while that of the algebraic group \\(\\C^\\times\\) is discrete. This has something to do with \\(S^1\\) and its topology. Later we'll see that the functor \\(d\\) gives an equivalence of category when restricted to simply connected Lie groups.\n\n\\begin{note}\n  Notice \\(\\Lie g\\) is also the Lie algebra of the additive group \\((\\C, +)\\), whose algebraic reps resemble the reps of \\(\\Lie g\\).\n\\end{note}\n\nLess distressingly, if \\(Z \\subseteq G\\) is a finite central subgroup then \\(T_1(G/Z) = T_1G\\) so the Lie algebras of \\(G\\) and \\(G/Z\\) agree.\n\n\\begin{ex}\n  Let \\(G_n = \\C^* \\ltimes \\C\\) where \\(\\C^*\\) acts on \\(\\C\\) by \\(t \\cdot \\lambda = t^n \\lambda\\) so\n  \\[\n    (t, \\lambda) (t', \\lambda') = (tt', t'^n \\lambda + \\lambda').\n  \\]\n  Show that \\(G_n \\cong G_m\\) if and only if \\(n = \\pm m\\), but\n  \\[\n    \\operatorname{Lie} G_n = \\operatorname{Lie} G_m = \\C x + \\C y\n  \\]\n  where \\([x, y] = y\\), so the functor is not faithful.\n\\end{ex}\nAs a side note, the functor is not surjective either.\n\n\\section{Representations of \\(\\Lie{sl}_2\\)}\n\nRecall that \\(\\Lie{sl}_2\\) has basis\n\\[\n  e =\n  \\begin{pmatrix}\n    0 & 1 \\\\\n    0 & 0\n  \\end{pmatrix}\n  , f =\n  \\begin{pmatrix}\n    0 & 0 \\\\\n    1 & 0\n  \\end{pmatrix}\n  , h =\n  \\begin{pmatrix}\n    1 & 0 \\\\\n    0 & -1\n  \\end{pmatrix}\n\\]\nso we have\n\\[\n  [e, f] = h, [h, e] = 2e, [h, f] = -2f\n\\]\n \nWe would like to prove\n\\begin{theorem}\\leavevmode\n  \\begin{enumerate}\n  \\item For each \\(n \\geq 0\\) there is a unique irreducible rep of \\(\\Lie{sl}_2\\) of dimension \\(n + 1\\).\n  \\item Every finite-dimensional rep of \\(\\Lie{sl}_2\\) is a direct sum of irred reps.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{definition}[weight space]\\index{weight space}\n  Let \\(V\\) be a rep of \\(\\Lie{sl}_2\\). If \\(\\lambda \\in \\C\\), the \\emph{\\(\\lambda\\)-weight space} of \\(V\\) is\n  \\[\n    V_\\lambda = \\{v \\in V: h v = \\lambda v\\},\n  \\]\n  the eigenspace of \\(h\\).\n\\end{definition}\n\n\\begin{eg}\n  \\(L(n)_\\lambda = \\C x^i y^j\\) if \\(i - j = \\lambda\\).\n\\end{eg}\n\nLet \\(v \\in V_\\lambda\\) and we have\n\\[\n  h \\cdot ev = (he - eh + eh) v = ([h, e] + eh) v = 2ev + e \\lambda v = (\\lambda + 2) ev\n\\]\nso if \\(v \\in V_\\lambda\\) then \\(ev \\in V_{\\lambda + 2}\\), if and only if \\(ev \\neq 0\\). Similarly \\(fv \\in V_{\\lambda - 2}\\). Thus \\(f\\) and \\(e\\) shifts between a string of spaces \\(V_{\\lambda + 2}, V_\\lambda, V_{\\lambda - 2}, \\dots\\)\n\\[\n  \\begin{tikzcd}\n    \\cdots \\ar[r,  shift left] & V_{\\lambda - 2} \\ar[l, shift left] \\ar[r, \"e\", shift left] & V_\\lambda \\ar[l, \"f\", shift left] \\ar[r, \"e\", shift left] & V_{\\lambda + 2} \\ar[l, \"f\", shift left] \\ar[r, shift left] & \\cdots \\ar[l, shift left]\n  \\end{tikzcd}\n\\]\n\nIf \\(v \\in V_\\lambda \\cap \\ker e\\), that is \\(ev = 0, hv = \\lambda v\\) we say \\(v\\) is a \\emph{highest weight vector with highest weight \\(\\lambda\\)}.\n\n\\begin{lemma}\n  Let \\(V\\) be a rep of \\(\\Lie{sl}_2\\), \\(v \\in V_\\lambda\\) a highest weight vector of weight \\(\\lambda\\) then \\(W = \\langle v, fv, f^2v, \\cdots \\rangle\\) is an \\(\\Lie{sl}_2\\)-invariant subspace, that is a subrep of \\(V.\\)\n\\end{lemma}\n\n\\begin{proof}\n  We must show the image of \\(W\\) under \\(f, h, e\\) are contained in \\(W\\). \\(fW \\subseteq W\\) by construction. As \\(v \\in V_\\lambda\\), we see that \\(f^kv \\in V_{\\lambda - 2k}\\) and so \\(hW \\subseteq W\\). Finally \\(ev = 0 \\in W\\) and\n  \\begin{align*}\n    e \\cdot fv &= (ef - fe + fe) v = hv = \\lambda v \\in W \\\\\n    e \\cdot f^2 v &= ([e, f] + fe) fv = (\\lambda - 2) fv + f\\cdot \\lambda v = (2\\lambda - 2) fv \\in W \\\\\n    e \\cdot f^3 v &= ([e, f] + fe) f^2 = (\\lambda - 4) f^2v + f(2\\lambda - 2) fv = (3\\lambda - 6)f^2 v \\in W\n  \\end{align*}\n  and so on. It is an exercise to show by induction\n  \\[\n    e\\cdot f^n v = n (\\lambda - n + 1) f^{n - 1} v.\n  \\]\n\\end{proof}\n\nWe have a surprising result:\n\\begin{lemma}\n  Let \\(V\\) be a finite-dimensional \\(\\C\\)-space and a rep of \\(\\Lie{sl}_2\\) and \\(v \\in V\\) a highest weight vector with highest weight \\(\\lambda\\) then \\(\\lambda \\in \\{0, 1, \\dots \\} = \\Z_{\\geq 0}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Note that all \\(f^k v\\) lie in different eigenspaces for \\(h\\) so if non-zero they are linearly independent. But \\(V\\) is finite dimensional so exists \\(k\\) such that \\(f^k v \\neq 0, f^{k + 1} v = 0\\). The exercise shows\n  \\[\n    0 = ef^{k + 1}v = (k + 1)( \\lambda - k)f^k v\n  \\]\n  so \\(k + 1 \\neq 0\\) so \\(\\lambda = k\\).\n\\end{proof}\n\n\\begin{lemma}\n  If \\(V\\) is a finite-dimensional rep of \\(\\Lie{sl}_2\\) then it has a highest weight vector.\n\\end{lemma}\n\n\\begin{proof}\n  As \\(V\\) is a \\(\\C\\)-space \\(h\\) has an eigenvector. Apply \\(e\\) to it get \\(v, ev, e^2v, \\dots\\) which are eigenvectors with different eigenvectors so if nonzero are linearly independent so exists \\(k\\) such that \\(e^kv = 0\\), so \\(e^kv\\) is a highest weight eigenvector.\n\\end{proof}\n\n\\begin{corollary}\n  Let \\(k = \\C\\). If \\(V\\) is an irreducible finite dimensional representation of \\(\\Lie{sl}_2\\) then \\(\\dim V = n + 1\\) and \\(V\\) has basis \\(v_0, v_1, \\dots, v_n\\) with\n  \\begin{align*}\n    hv_i &= (n - 2i) v_i \\\\\n    fv_i &= v_{i + 1} \\\\\n    ev_i &= i (n - i + 1) v_{i - 1}\n  \\end{align*}\n  In particular there is a unique irreducible representation of dimension \\(n + 1\\), which is isomorphic to \\(L(n)\\).\n\\end{corollary}\n\n(Picture of string)\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Find the explicit relation between this basis and the \\(x^ay^b\\) basis earlier, where \\(a + b = n\\).\n  \\item Recall \\(\\C[x, y] = \\bigoplus_{n \\geq 0} L(n)\\) as a representation of \\(\\Lie{sl}_2\\) where \\(e, h, f\\) acts as differential operators. Show that the same operators give a rep of \\(\\Lie{sl}_2\\) on \\(x^\\lambda y^\\mu \\C[x/y, y/x]\\) for all \\(\\lambda, \\mu \\in \\C\\). Determine the submodules of this rep.\n  \\end{enumerate}\n\\end{ex}\n\nNow we show that all reps can be written as direct sum of the irreducible ones. This is one of the more difficult theorem but will lead us towards the general result later. We will show strings of different lengths don't interact, then strings of the same lengths do not interact.\n\n\\begin{definition}\n  Let \\(V\\) be a rep of \\(\\Lie{sl}_2\\). Define \\(\\Omega \\in \\End(V)\\) by\n  \\[\n    \\Omega = ef + fe + \\frac{1}{2}h^2,\n  \\]\n  the \\emph{Casimir} of \\(\\Lie{sl}_2\\).\n\\end{definition}\n\n\\begin{lemma}\n  \\(\\Omega\\) is central, that is \\(e\\Omega = \\Omega e, f \\Omega = \\Omega f, h \\Omega = \\Omega h\\).\n\\end{lemma}\n\n\\begin{proof}\n  We will later show a slick proof. For now this is left as an exercise. For example\n  \\begin{align*}\n    e \\Omega\n    &= e (ef +fe + \\frac{1}{2} h^2) \\\\\n    &= e(ef - fe) + 2efe \\\\\n    &+ \\frac{1}{2} (eh - he) h + \\frac{1}{2} heh \\\\\n    &= 2efe + \\frac{1}{2} heh \\\\\n    &= \\cdots \\\\\n    &= \\Omega e\n  \\end{align*}\n\\end{proof}\n\n\\begin{corollary}\n  If \\(V\\) is an irreducible rep of \\(\\Lie{sl}_2\\), then \\(\\Omega\\) acts on \\(V\\) by a scalar.\n\\end{corollary}\n\n\\begin{proof}\n  Similar to Schur's lemma.\n\\end{proof}\n\n\\begin{lemma}\n  \\(\\Omega\\) acts on \\(L(n)\\) as multiplication by \\(\\frac{1}{2} n^2 + n\\).\n\\end{lemma}\n\n\\begin{proof}\n  We can choose any nonzero element and use the above corollary. Alternatively we can do it by hand. Let \\(v\\) be the highest weight vector of \\(L(n)\\) so \\(ev = 0, hv = nv\\). Then\n  \\[\n    \\Omega = (ef - fe) + 2fe + \\frac{1}{2} h^2 = (\\frac{1}{2} h^2 + h) + 2fe\n  \\]\n  so\n  \\begin{align*}\n    \\Omega v &= (\\frac{1}{2} n^2 + n) v \\\\\n    \\Omega (f^k v) &= f^k \\Omega v = (\\frac{1}{2} n^2 + n) f^k v\n  \\end{align*}\n\\end{proof}\n\nThis immediately implies ``strings of different lengths don't interact'', which we shall make sense of now.\n\nLet \\(V\\) be a finite dimensional rep of \\(\\Lie{sl}_2\\). Let\n\\[\n  V^\\lambda = \\{v \\in V: (\\Omega - \\lambda)^{\\dim V} v = 0\\}\n\\]\nbe the generalised eigenspace for \\(\\Omega\\) with eigenvalue \\(\\lambda\\). By linear algebra, \\(V = \\bigoplus_\\lambda V^\\lambda\\). Claim that each \\(V^\\lambda\\) is a subrep, i.e.\\ preserved by \\(\\Lie{sl}_2\\), so this is a direct sum decomposition of \\(V\\) as reps of \\(\\Lie{sl}_2\\).\n\n\\begin{proof}\n  Let \\(x \\in \\Lie{sl}_2, v \\in V^\\lambda\\). Then\n  \\[\n    (\\Omega - \\lambda)^{\\dim V} xv = x(\\Omega - \\lambda)^{\\dim V} v = 0\n  \\]\n  as \\(\\Omega\\) is central so \\(xv \\in V^\\lambda\\).\n\\end{proof}\n\nClaim that if \\(V^\\lambda \\neq 0\\) then \\(\\lambda = \\frac{1}{2} n^2 + n\\) for a unique \\(n \\in \\Z_{\\geq 0}\\), and ``\\(V^\\lambda\\) is glued together from copies of \\(L(n)\\)''. Formally, ``gluing'' refers to the following:\n\n\\begin{definition}[composition series]\\index{composition series}\n  Let \\(W\\) be a finite dimensional representation of \\(\\Lie g\\). A \\emph{composition series} for \\(W\\) is a sequence of submodules\n  \\[\n    0 = W_0 \\subseteq W_1 \\subseteq W_2 \\subseteq \\cdots \\subseteq W_r = W\n  \\]\n  such that each \\(W_i/W_{i - 1}\\) is a non-zero irreducible module.\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\Lie g = \\C, W = \\C^r\\) where \\(1 \\in \\Lie g\\) acts as \\(\n    \\begin{psmallmatrix}\n    0 & 1 \\\\\n    & 0 & 1 \\\\\n    & & & \\ddots \\\\\n    & & & & 1 \\\\\n    & & & & 0\n  \\end{psmallmatrix}\n  \\). Then there is a unique composition series for \\(W\\), namely\n  \\[\n    0 \\subseteq \\langle e_1 \\rangle \\subseteq \\langle e_1, e_2 \\rangle \\subseteq \\cdots \\subseteq \\langle e_1, \\dots, e_r \\rangle.\n  \\]\n\\item Let \\(\\Lie g = \\C, W = \\C^r\\) and \\(1 \\in \\Lie g\\) acts as \\(0\\). Then any chain of subspaces\n  \\[\n    W_0 \\subseteq W_1 \\subseteq \\cdots \\subseteq W_r\n  \\]\n  with \\(\\dim W_i = i\\) is a composition series.\n  \\end{enumerate}\n\\end{eg}\n\nThe intuition is that by choosing a suitable basis, we can put each element of \\(\\Lie g\\) into \\emph{block triangular form}, with the diagonal blocks \\(A_i\\) the action on the subquotient \\(W_i/W_{i - 1}\\), which we require to be irreducible.\n\\[\n  \\begin{pmatrix}\n    A_1 & & & * \\\\\n    & A_2 \\\\\n    & & \\ddots \\\\\n    0 & & & A_r\n  \\end{pmatrix}\n\\]\n\n\\begin{lemma}\n  Composition series always exist.\n\\end{lemma}\n\n\\begin{proof}\n  Induct on \\(\\dim W\\). Take an irreducible subrep of \\(W\\) (why does it always exist?), call it \\(W_1\\). Then \\(W/W_1\\) has smaller dimension than \\(W\\) so has a composition series. Take the preimage of this in \\(W\\) and stick \\(W_1\\) in the front.\n\\end{proof}\n\n\\begin{remark}\n  The subquotients \\(W_i/W_{i - 1}\\) are unique (up to reordering). This requires proof in general, but will follow for Lie algebras from what we show in a bit.\n\\end{remark}\n\nNow we can rephrase the claim as follow: if \\(V^\\lambda \\neq 0\\) then \\(\\lambda = \\frac{1}{2} n^2 + n\\) for a unique \\(n \\in \\Z_{\\geq 0}\\), and \\(V^\\lambda\\) has a composition series where all of the subquotients \\(W_i/W_{i - 1}\\) are isomorphic to \\(L(n)\\). This proves the slogan ``strings of different lengths don't interact''.\n\n\\begin{proof}\n  First observe that if \\(n \\neq m\\) then \\(\\Omega\\) acts on \\(L(n)\\) and \\(L(m)\\) by different numbers, as \\(n \\mapsto \\frac{1}{2} n^2 + n\\) is an increasing function for \\(n \\geq -1\\). Thus if \\(V^\\lambda \\neq 0\\), let \\(L(n)\\) be an irreducible submodule of \\(V^\\lambda\\). As \\(\\Omega\\) acts on \\(L(n)\\) by \\(\\frac{1}{2} n^2 + n\\), we have \\(\\lambda = \\frac{1}{2}n^2 + n\\), and then \\(\\Omega\\) acts on \\(V^\\lambda/L(n)\\) with generalised eigenvalue \\(\\lambda = \\frac{1}{2} n^2 + n\\), and for the same reason all composition factors of \\(V^\\lambda\\) must be \\(L(n)\\) for this \\(n\\).\n\\end{proof}\n\nNow we have \\(V = \\bigoplus_{n \\geq 0} V^{\\frac{1}{2}n^2 + n}\\) where each \\(V^{\\frac{1}{2}n^2 + n}\\) has all composition factors \\(L(n)\\). We now show strings of the same lengths don't interact.\n\n\\begin{lemma}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(hf^k = f^k (h - 2k)\\) for all \\(k \\geq 0\\).\n  \\item \\(ef^{k + 1} = f^{k + 1} e + (k + 1) f^k (h - k)\\) for all \\(k \\geq 0\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\nIf \\(W' \\subseteq W\\) and \\(h\\) preserves \\(W'\\) then the set of generalised eigenvalues of \\(h\\) on \\(W\\) is the union on that of \\(h\\) on \\(W'\\) and \\(W/W'\\). As a result, \\(h\\) acts on \\(V^\\lambda\\) with generalised eigenvalues in \\(\\{-n, -n + 2, \\dots, n - 2, n\\}\\). Also the only generalised eigenvalue of \\(h\\) on \\(\\ker (e: V^\\lambda \\to V^\\lambda)\\) is \\(n\\), that is \\((h - n)^{\\dim V^\\lambda} \\cdot x = 0\\) for all \\(x \\in V^\\lambda \\cap \\ker e\\).\n\n\\begin{proposition}\n  \\(h\\) acts diagonally on \\(\\ker (e: V^\\lambda \\to V^\\lambda)\\), that is it acts by multiplication by \\(n\\). Thus\n  \\[\n    \\ker (e: V^\\lambda \\to V^\\lambda) = (V^\\lambda)_n = \\{x \\in V^\\lambda: hx = nx\\}.\n  \\]\n\\end{proposition}\n\n\\begin{proof}\n  If \\(hx = nx\\) then \\(ex \\in (V^\\lambda)_{n + 2} = 0\\) so \\(x \\in \\ker e\\). Conversely let \\(x \\in \\ker e\\). We know \\((h - n)^{\\dim V^\\lambda} x = 0\\). By exercises\n  \\[\n    (h - n + 2k)^{\\dim V^\\lambda} f^kx = f^k (h - n)^{\\dim V^\\lambda} x = 0\n  \\]\n  so \\(f^n x\\) is in the generalised eigenspace of \\(h\\) with eigenvalue \\(n - 2k\\). Claim that on the other hand, for any \\(0 \\neq y \\in \\ker e\\), \\(f^n y \\neq 0\\).\n  \\begin{proof}\n    Let \\(0 = W_0 \\subseteq W_1 \\subseteq \\cdots \\subseteq W_r = V^\\lambda\\) be a composition series of \\(V^\\lambda\\) such that \\(W_i/W_{i - 1} \\cong L(n)\\) for all \\(i\\). Then exists \\(i\\) such that \\(y \\in W_i, y \\neq W_{i - 1}\\). Then \\(\\overline y = y + W_{i - 1} \\in W_i/W_{i - 1} \\cong L(n)\\). Then \\(\\overline y\\) is a highest weight vector of \\(L(n)\\), so \\(f^n(\\overline y) \\neq 0 \\in W_i/W_{i - 1}\\) so \\(f^n y \\neq 0 \\in W_i \\subseteq V^\\lambda\\).\n  \\end{proof}\n  \n  Now \\(f^{n + 1}x\\) belongs to the generalised eigenspace of \\(h\\) with eigenvalue \\(-n - 2\\), which must be \\(0\\) by the observation above. Thus \\(0 = ef^{n + 1}x\\). By exercise this equals to\n  \\[\n    0 = ef^{n + 1}x = (n + 1)f^n (h - n)x + \\underbrace{f^{n + 1} ex}_{= 0}\n  \\]\n  so \\((n + 1) f^n (h - n)x = 0\\). As \\(e(h - n)x = (h - n - 2)ex = 0\\), we have \\((h - n) x \\in \\ker e\\) so if \\((h - n)x \\neq 0\\) then \\(f^n (h - n)x \\neq 0\\). As we are over \\(\\C\\), \\(n + 1 \\neq 0\\) and we just showed \\(y \\ne o, y \\in \\ker e\\) but \\(f^ny \\neq 0\\), impossible. Thus \\((h - x)x = 0\\) so \\(hx = nx\\).\n\\end{proof}\n\nTo show complete reducibility, do the following exercise:\n\n\\begin{ex}\n  Take a basis \\(w_1, \\dots, w_k\\) of \\(\\ker e\\) and consider the string generated by each \\(w_i\\), that is \\(w_i, fw_i, \\dots, f^n w_i\\). Show that these give a basis of \\(V^\\lambda\\), each such string is a subrep isomorphic to \\(L(n)\\) and this gives a direct sum decomposition. In particular \\(h\\) acts diagonally on all of \\(V\\) for \\(V\\) a finite-dimensional rep.\n\\end{ex}\n\n\\begin{ex}\n  Show all of this is false in characteristic \\(p\\). More precisely, show the irreducible reps of \\(\\Lie{sl}_2\\) over \\(\\overline F_p\\) are \\emph{not} parameterised by \\(n \\in \\Z_{\\geq 0}\\). Find a rep of \\(\\Lie{sl}_2(\\overline F_p)\\) which does not decompose as a direct sum.\n\\end{ex}\n\n\\subsection{Consequences}\n\n\\begin{definition}[tensor product]\\index{tensor product}\n  Let \\(V\\) and \\(W\\) be \\(\\Lie g\\)-reps. Then the \\emph{tensor product} of \\(V\\) and \\(W\\) is a rep via the map\n  \\begin{align*}\n    \\Lie g &\\to \\End(V \\otimes W) = \\End(V) \\otimes \\End(W) \\\\\n    x &\\mapsto x \\otimes 1 + 1 \\otimes x\n  \\end{align*}\n\\end{definition}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show the above map is a homomorphism of Lie algebras.\n  \\item Suppose \\(G\\) acts on \\(V\\) and \\(W\\). Show it acts on \\(V \\otimes W\\) by \\(g \\mapsto g \\otimes g\\) and the above action is obtained by differentiating this action.\n  \\end{enumerate}\n\\end{ex}\n\nTake \\(\\Lie g = \\Lie{sl}_2\\). Then by complete reducibility we know \\(L(n) \\otimes L(m) \\cong \\bigoplus_{a \\geq 0} m_a L(a)\\) for some \\(m_a\\)'s.\n\n\\begin{ex}\n  Find the highest weight vectors in \\(L(1) \\otimes L(n)\\) and \\(L(2) \\otimes L(n)\\) and hence decompose these.\n\\end{ex}\n\nTo start, let \\(v_a\\) be a highest weight vector in \\(L(a)\\). Claim that \\(v_n \\otimes v_m\\) is a highest weight vector in \\(L(n) \\otimes L(m)\\):\n\\begin{align*}\n  h(v_n \\otimes v_m &= (hv_n) \\otimes v_m + v_n \\otimes (hv_m) = (n + m) (v_n \\otimes v_m) \\\\\n  e(v_n \\otimes v_m) &= (ev_n) \\otimes v_m + v_n \\otimes (ev_m) = 0\n\\end{align*}\nso \\(L(n) \\otimes L(m) = L(n + m) \\oplus \\text{ other stuff}\\).\n\n\\begin{definition}[character]\\index{character}\n  Let \\(V\\) be a finite-dimensional rep of \\(\\Lie{sl}_2\\). Define the \\emph{character} of \\(V\\) to be\n  \\[\n    \\ch V = \\sum_{n \\in \\Z} \\dim V_n \\cdot z^n \\in \\N[z, z^{-1}].\n  \\]\n\\end{definition}\n\nIt has the following properties:\n\\begin{enumerate}\n\\item \\(\\ch V|_{z = 1} = \\dim V\\). This is a consequence of the fact that \\(h\\) is diagonalisable with integer eigenvalues.\n\\item \\(\\ch L(n) = z^n + z^{n - 2} + \\dots + z^{2 - n} + z^{-n} = \\frac{z^{n + 1} - z^{-{n + 1}}}{z - z^{-1}}\\).\n\\item \\(\\ch V = \\ch W\\) if and only if \\(V \\cong W\\) as \\(\\Lie{sl}_2\\) reps.\n  \\begin{proof}\n    Notice that\n    \\begin{align*}\n      \\ch L(0) &= 1 \\\\\n      \\ch L(1) &= z + z^{-1} \\\\\n      \\ch L(2) &= z^2 + 1 + z^{-1} \\\\\n               &\\cdots\n    \\end{align*}\n    form a basis of \\(\\Z[z, z^{-1}]^{S_2}\\), the space of symmetric Laurent polynomials with integer coefficients. Now by complete reducibility if \\(V \\cong \\bigoplus _{a\\geq 0} n_a L(a), W \\cong \\bigoplus_{a \\geq 0} m_a L(a)\\) then \\(V \\cong W\\) if and only if \\(n_a = m_a\\) for all \\(a \\geq 0\\). As \\(\\{\\ch L(n): n \\geq 0\\}\\) is a basis of \\(\\Z[z, z^{-1}]^{S_2}\\), \\(\\ch V = \\sum m_a \\ch L(n)\\) determines \\(V\\).\n  \\end{proof}\n\\item \\(\\ch (V \\otimes W) = \\ch V \\cdot \\ch W\\). This follows from the exercise: show that \\(V_n \\otimes W_m \\subseteq (V \\otimes W)_{n + m}\\) and hence \\((V \\otimes W)_p = \\bigoplus_{n + m = p} V_n \\otimes W_m\\). This is exactly how we multiply polynomials.\n\\end{enumerate}\n\n\\begin{eg}\n  \\begin{align*}\n    \\ch (L(1) \\otimes L(3))\n    &= \\ch L(1) \\cdot \\ch L(3) \\\\\n    &= (z + z^{-1})(z^3 + z + z^{-1} + z^{-3}) \\\\\n    &= (z^4 + z^2 + 1 + z^{-2} + z^{-4}) + (z^2 + 1 + z^{-2})\n  \\end{align*}\n  so complete reducibility and the fact that \\(\\ch L(n)\\) form a basis immediately tell us that \\(L(3) \\otimes L(1) = L(4) \\otimes L(2)\\), which is a lot easier than finding highest weight vectors in the tensor product!\n\\end{eg}\n\n\\begin{corollary}[Clebsch-Gordon]\\index{Clebsch-Gordon}\n  \\[\n    L(n) \\otimes L(m) = \\bigoplus_{\\substack{k = |n - m| \\\\ k = n - m \\pmod 2}}^{n + m} L(k).\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Induction. Also pictorially,\n\\end{proof}\n\nPurpose of this course: \\(\\Lie{sl}_n, \\Lie{so}_n, \\Lie{sp}_{2n}\\) etc are simple Lie algebras and the category of their \\(\\C\\)-representations are semisimple, and are parameterised by positive cones in the lattice \\(\\Z_{\\geq 0}^\\ell\\). Also we can write down their characters parameterised by the lattice. Finally, we are going to draw more pictures like above.\n\n\\section{Structure and Classification of simple Lie algebras}\n\nLet's do some warm up exercises in linear algebras. Let \\(k\\) be a field.\n\n\\begin{definition}[simple Lie algebra]\\index{simple}\n  Let \\(\\Lie g\\) be a Lie algebra over \\(k\\). \\(\\Lie g\\) is \\emph{simple} if \\(\\dim \\Lie g > 1\\) and the only ideals of \\(\\Lie g\\) are \\(0\\) and \\(\\Lie g\\).\n\\end{definition}\n\n1 dimensional Lie algebras are excluded because they are abelian and as we have seen, their representations do not form a discrete family so they tend to break results we are going to state for nonabelian simple algebras.\n\nIn order to describe simple Lie algebras, we will need some Lie algebras which are very far from simple.\n\n\\begin{definition}[derived subalgebra]\\index{derived subalgebra}\n  The \\emph{derived subalgebra} of \\(\\Lie g\\), denoted \\([\\Lie g, \\Lie g]\\), is the linear span of \\([x, y]\\) for \\(x, y \\in \\Lie g\\).\n\\end{definition}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show \\([\\Lie g, \\Lie g]\\) is an ideal.\n  \\item Show \\(\\Lie g/[\\Lie g, \\Lie g]\\) is abelian.\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{definition}[central/derived series]\\index{central series}\\index{derived series}\n  The \\emph{central series} for \\(\\Lie g\\) is the sequence of subalgebras\n  \\[\n    \\Lie g \\supseteq [\\Lie g, \\Lie g] \\supseteq [[\\Lie g, \\Lie g], \\Lie g] \\supseteq \\cdots\n  \\]\n  or more formally,\n  \\[\n    \\Lie g^0 = \\Lie g, \\quad \\Lie g^n = [\\Lie g^{n - 1}, \\Lie g] \\text{ for } n \\geq 1.\n  \\]\n\n  The \\emph{derived series} for \\(\\Lie g\\) is the sequence\n   \\[\n    \\Lie g \\supseteq [\\Lie g, \\Lie g] \\supseteq [[\\Lie g, \\Lie g], [\\Lie g, \\Lie g]] \\supseteq \\cdots\n  \\]\n  or more formally\n  \\[\n    \\Lie g^{(0)} = \\Lie g, \\quad \\Lie g^{(n)} = [\\Lie g^{(n - 1)}, \\Lie g^{(n - 1)}] \\text{ for } n \\geq 1.\n  \\]\n\\end{definition}\n\nNote that \\(\\Lie g^{(n)} \\subseteq \\Lie g^n\\).\n\n\\begin{definition}[nilpotent/solvable Lie algebra]\\index{nilpotent}\\index{solvable}\n  \\(\\Lie g\\) is \\emph{nilpotent} if \\(\\Lie g^n = 0\\) for some \\(n > 0\\), that is if the central series terminates.\n\n  \\(\\Lie g\\) is \\emph{solvable} if \\(\\Lie g^{(n)} = 0\\) for some \\(n > 0\\), that is if the derived series terminates.\n\\end{definition}\n\nNote that \\(\\Lie g\\) nilpotent implies \\(\\Lie g\\) solvable.\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\Lie u\\) of strictly upper triangular matrices is nilpotent.\n  \\item \\(\\Lie b\\) of upper triangular matrices is solvable.\n  \\item The two dimensional Lie algebra with basis \\(x, y\\) and \\([x, y] = y\\) is solvable but not nilpotent.\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{ex}\n  Compute the central and derived series for \\(\\Lie u, \\Lie b\\) and show they are nilpotent and solvable repsectively.\n\n  Compute the centre of these Lie algebras.\n\\end{ex}\n\n\\begin{eg}\n  Let \\(W\\) be a symplectic vector space, that is \\(W\\) is a \\(k\\)-vector space with a non-degenerated alternating form \\(\\langle \\cdot, \\cdot \\rangle: W \\times W \\to k\\). For example \\(L\\) be a finite dimensional vector space and let \\(W = L \\oplus L^*\\) with symplectic form\n  \\[\n    \\langle L, L \\rangle = \\langle L^*, L^* \\rangle = 0, \\langle v^*, w\\rangle = - \\langle w, v^* \\rangle = v^*(w).\n  \\]\n  \\(L\\) is a maximal Lagrangian space and by basic linear algebra all examples are of this form. \n\n  Define the \\emph{Heisenberg Lie algebra}\\index{Heisenberg Lie algebra} \\(H_W = W \\oplus k.c\\) with Lie brackets\n  \\begin{align*}\n    [w, w'] &= \\langle w, w' \\rangle . c \\\\\n    [c, w] &= 0\n  \\end{align*}\n\\end{eg}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show \\(H_W\\) is a Lie algebra.\n  \\item Show \\(H_W\\) is nilpotent. Do we have to do any extra work?\n  \\end{enumerate}\n\\end{ex}\n\nDifferentiating the Heisenberg group\n\nThis is the most important nilpotent Lie algebra that arises in nature For example take \\(k = \\C, L = \\C\\). \\(H_W\\) has basis \\(p, q, c\\) with \\([p, q] = c, [c, *] = 0\\).\n\n\\begin{ex}\n  Show \\(\\C[x]\\) is a rep of \\(H_W\\) where \\(q\\) acts by multiplication by \\(x\\), \\(p = \\frac{\\partial  }{\\partial x}\\) and \\(c\\) is identity.\n\\end{ex}\n\nFor a general vector space \\(L\\) with basis \\(v_1, \\dots, v_n\\) and \\(L^*\\) with dual basis \\(v_1^*, \\dots, v_n^*\\). Then \\(H_W\\) acts \\(\\C[x_1, \\dots, x_n]\\) with \\(v_i^* \\mapsto \\frac{\\partial }{\\partial x_i}, v_i \\mapsto x_i, c \\mapsto 1\\).\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Subalgebras and quotient Lie algebras of a solvable Lie algebra are solvable.\n  \\item Subalgebras and quotient Lie algebras of a nilpotent Lie algebra are nilpotent.\n  \\item Let \\(\\Lie g\\) be a Lie algebra and \\(\\Lie h \\subseteq \\Lie g\\) an ideal. Then \\(\\Lie g\\) is solvable if and only if \\(\\Lie h\\) and \\(\\Lie g/\\Lie h\\) are solvable. In particular solvable Lie algebras are built out of one-dimensional abelian Lie algebras, i.e.\\ there is a refinement of the derived series such that all subquotients are one-dimensional (and hence abelian).\n  \\item \\(\\Lie g\\) is nilpotent if and only if centre of \\(\\Lie g\\) is non-zero and the quotient of \\(\\Lie g\\) by its centre is nilpotent.\n    \n    For only if, indeed if \\(\\Lie g\\) is nilpotent we have central series\n    \\[\n      \\Lie g \\supsetneq \\Lie g^1 \\supsetneq \\cdots \\supsetneq \\Lie g^n = 0\n    \\]\n    and since \\(\\Lie g^n = [\\Lie g^{n - 1}, \\Lie g] = 0\\) so must have \\(\\Lie g^{n - 1}\\) contained in the centre of \\(\\Lie g\\).\n  \\item \\(\\Lie g\\) is nilpotent if and only if \\(\\ad (\\Lie g) \\subseteq \\Lie{gl}(\\Lie g)\\) is a nilpotent Lie algebra. This is immediate from 4 as we have a short exact sequence of Lie algebras\n    \\[\n      \\begin{tikzcd}\n        0 \\ar[r] & \\text{centre of } \\Lie g \\ar[r] & \\Lie g \\ar[r] & \\ad(\\Lie g) \\ar[r] & 0\n      \\end{tikzcd}\n    \\]\n  \\end{enumerate}\n\\end{ex}\n\nWe will use but not prove\n\n\\begin{theorem}[Lie]\\index{Lie's theorem}\n  Let \\(k = \\overline k\\) and \\(\\cha k = 0\\). Let \\(\\Lie g\\) be a solvable Lie algebra over \\(k\\) and \\(\\Lie g \\subseteq \\Lie{gl}(V)\\) for some \\(V\\). Then there exists a basis \\(v_1, \\dots, v_n\\) of \\(V\\) with respect to which all element of \\(\\Lie g\\) are upper triangular, i.e.\\ \\(\\Lie g \\subseteq \\Lie b\\).\n\\end{theorem}\nNote that \\(\\Lie g \\subseteq \\Lie{gl}(V)\\) is automatic by Ado.\n\nEquivalently, there exists a linear function \\(\\lambda: \\Lie g \\to k\\) and an element \\(v \\in V\\) such that \\(xv = \\lambda(x) v\\) for all \\(x \\in \\Lie g\\), that is \\(\\Lie g\\) has a one dimensional subrep. In particular the only irreducible finite dimensional reps of \\(\\Lie g\\) are one dimensional.\n\n\\begin{ex}\n  Show these two formulations are equivalent.\n\\end{ex}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show the theorem is false if \\(k \\neq \\overline k\\).\n  \\item Show the theorem is false if \\(\\cha k = p > 0\\). Hint: consider the 3 dimensional Heisenberg Lie algebra \\(H\\) and show that \\(k[x]/(x^p)\\) is an irreducible rep of \\(H\\) of dimension larger than \\(1\\).\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{corollary}\n  If \\(\\cha k = 0\\) and \\(\\Lie g\\) is solvable then \\([\\Lie g, \\Lie g]\\) is nilpotent.\n\\end{corollary}\n\n\\begin{proof}\n  It is an exercise to show that \\(\\Lie b\\) solvable over \\(k\\) if and only if \\(\\Lie b \\otimes_k \\overline k\\) is solvable over \\(\\overline k\\), and similarly for nilpotents (?), so we may assume \\(k = \\overline k\\). Now apply Lie's theorem to the adjoint rep \\(\\Lie g \\to \\End \\Lie g\\) so there exists a basis where \\(\\ad \\Lie g\\) are upper triangular. Then \\([\\ad \\Lie g, \\ad \\Lie g]\\) is strictly upper triangular. As \\(\\ad: \\Lie g \\to \\Lie{gl}(\\Lie g)\\) is a rep, \\([\\ad \\Lie g, \\ad \\Lie g] = \\ad [\\Lie g, \\Lie g]\\) so \\(\\ad [\\Lie g, \\Lie g]\\) is nilpotent, hence \\([\\Lie g, \\Lie g]\\) is nilpotent since a Lie algebra \\(\\Lie h\\) is nilpotent if and only if \\(\\ad \\Lie h\\) is nilpotent. (?)\n\\end{proof}\n\n\\begin{ex}\n  Show this is false in characteristic \\(p\\).\n\\end{ex}\n\n\\begin{theorem}[Engel]\\index{Engel's theorem}\n  \\(\\Lie g\\) is nilpotent if and only if for all \\(x \\in \\Lie g\\), \\(\\ad(x)\\) is nilpotent. Equivalently, if \\(V\\) is a finite dimensional rep of a Lie algebra \\(\\Lie g\\) and for all \\(x \\in \\Lie g\\), \\(x\\) acts on \\(V\\) as a nilpotent operator, then there exists \\(v \\in V\\) such that \\(xv = 0\\) for all \\(x \\in \\Lie g\\). In otherwords, \\(V\\) has a 1 dimensional subrep which is the trivial rep. Equivalently, there exists a basis of \\(V\\) if \\(\\Lie g \\subseteq \\Lie{gl}(V)\\) with respect to which all matrices in \\(\\Lie g\\) are strictly upper triangular.\n\\end{theorem}\n\n\\begin{ex}\n  Show these are all equivalent.\n\\end{ex}\n\nEngel says \\(V\\) is built out of trivial reps. That is \\(V\\) has a composition series whose subquotients are trivial reps.\n\nWarning: Engel says is \\(\\Lie g\\) consists of nilpotent matrices then \\(\\Lie g\\) is a nilpotent Lie algebra. The converse is \\emph{false}, for example the abelian Lie algebra of scalar matrices. The correct converse is: \\(\\Lie g\\) is nilpotent then \\(\\Lie g/\\text{center}\\) (which is isomorphic to \\(\\ad \\Lie g\\)) consists of nilpotent matrices.\n\n\\begin{definition}[invariant symmetric bilinear form]\\index{invariant symmetric bilinear form}\n  A symmetric bilinear form \\((\\cdot, \\cdot): \\Lie g \\times \\Lie g \\to k\\) is \\emph{invariant} if \\(([x, y], z) = (x, [y, z])\\) for all \\(x, y, z \\in \\Lie g\\).\n\\end{definition}\n\n\\begin{ex}\n  Show if \\(G\\) is an algebraic group actions on a vector space \\(V\\) and \\((gx, gy) = (x, y)\\) for all \\(g \\in G, x, y \\in V\\) then this defines an invariant form on \\(V\\).\n\\end{ex}\n\n\\begin{ex}\n  If \\(\\mathfrak a \\subseteq \\Lie g\\) is an ideal and \\((\\cdot, \\cdot)\\) is an invariant symmetric bilinear form then \\(\\mathfrak a^\\perp\\) is an ideal.\n\\end{ex}\n\n\\begin{definition}[trace form]\\index{trace form}\n  If \\(\\rho: \\Lie g \\to \\Lie{gl}(V)\\) is a rep, define the \\emph{trace form} of \\(V\\) to be\n  \\[\n    (x, y)_V = \\tr (\\rho(x) \\rho(y)).\n  \\]\n\\end{definition}\n\n\\begin{ex}\n  Show \\((\\cdot, \\cdot)_V\\) is an invariant symmetric bilinear form.\n\\end{ex}\n\n\\begin{definition}[Killing form]\\index{Killing form}\n  The \\emph{Killing form} of a Lie algebra \\(\\Lie g\\) is the trace form of the adjoint rep, i.e.\n  \\[\n    (x, y)_{\\ad} = \\tr (\\ad x \\ad y).\n  \\]\n\\end{definition}\n\nThe third theorem that we are not going to prove:\n\n\\begin{theorem}[Cartan's criteria]\\index{Cartan's criteria}\n  Suppose \\(\\cha k = 0\\) and \\(\\Lie g \\subseteq \\Lie{gl}(V)\\). Then \\(\\Lie g\\) is solvable if and only if for all \\(x \\in \\Lie g, y \\in [\\Lie g, \\Lie g]\\), the trace form \\((x, y)_V = 0\\). That is \\([\\Lie g, \\Lie g] \\subseteq \\Lie g^\\perp\\).\n\\end{theorem}\n\n\\begin{ex}\n  Show only if is immediate from Lie's theorem. Idea: if \\(\\Lie g\\) is solvable then we have a basis with \\(x\\) upper triangular and \\(y\\) strictly upper triangular, so \\(xy\\) has \\(0\\) entries on the diagonals and so has trace \\(0\\).\n\\end{ex}\n\n\\begin{corollary}\n  If \\(\\cha k = 0\\) then \\(\\Lie g\\) is solvable if and only if \\((\\Lie g, [\\Lie g, \\Lie g])_{\\ad} = 0\\).\n\\end{corollary}\n\n\\begin{proof}\n  If \\(\\Lie g\\) is solvable then Lie's theorem says that \\((\\Lie g, [\\Lie g, \\Lie g])_{\\ad} = 0\\). Conversely Cartan says \\(\\ad \\Lie g = \\Lie g/\\text{centre}\\) is solvable so \\(\\Lie g\\) is solvable.\n\\end{proof}\n\n\\begin{ex}\n  Show now every invariant symmetric bilinear form on \\(\\Lie g\\) is a trace form. More precisely, let \\(\\Lie g = \\tilde H\\) where \\(\\tilde H\\) has basis \\(c, p, q, d\\) with\n  \\[\n    [c, \\tilde H] = 0, [p, q] = c, [d, p] = p, [d, q] = -q.\n  \\]\n  \\begin{enumerate}\n  \\item Show \\(\\tilde H\\) is solvable.\n  \\item Construct a non-degenerate invariant form on \\(\\tilde H\\).\n  \\item Why couldn't we just write use \\(H\\)?\n  \\item Extend the rep of \\(H\\) on \\(k[x]\\) to a rep of \\(\\tilde H\\).\n  \\end{enumerate}\n\\end{ex}\n\nNow we can use the theorems.\n\n\\begin{definition}[semisimplicity]\\index{semisimplicity}\n  \\(\\Lie g\\) is \\emph{semisimple} if is a sum of simple (non-abelian) Lie algebras.\n\\end{definition}\n\n\\begin{definition}[radical]\\index{radical}\n  The \\emph{radical} of \\(\\Lie g\\), \\(R(\\Lie g)\\), is the maximal solvable ideal in \\(\\Lie g\\).\n\\end{definition}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show the sum of solvable ideals in \\(\\Lie g\\) is solvable and hence \\(R(\\Lie g)\\) is just the sum of all solvable ideals in \\(\\Lie g\\).\n  \\item Show \\(R(\\Lie g/R(\\Lie g)) = 0\\).\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{theorem}\n  \\label{thm:semisimplicity criteria}\n  Suppose \\(\\cha k = 0\\). Then TFAE:\n  \\begin{enumerate}\n  \\item \\(\\Lie g\\) is semisimple.\n  \\item \\(R(\\Lie g) = 0\\).\n  \\item Killing criterion: the Killing form is non-degenerate.\n  \\end{enumerate}\n  Moreover if \\(\\Lie g\\) is semisimple then every derivation \\(D: \\Lie g \\to \\Lie g\\) is inner.\n\\end{theorem}\nThe converse of the last statement is \\emph{false}.\n\n\\begin{definition}[derivation]\\index{derivation}\n  A \\emph{derivation} is a linear map \\(D: \\Lie g \\to \\Lie g\\) such that\n  \\[\n    D[x, y] = [Dx, y] + [x, Dy].\n  \\]\n\\end{definition}\n\n\\begin{eg}\n  If \\(x \\in \\Lie g\\) then \\(\\ad x\\) is a derivation. Derivations of this form are called \\emph{inner}\\index{derivation!inner}.\n\\end{eg}\n\nMore generally if \\(V\\) is a rep of \\(\\Lie g\\) then \\(D: \\Lie g \\to V\\) is a derivation if\n\\[\n  D[x, y] = x Dy - y Dx\n\\]\nand if \\(v \\in V\\), \\(x \\mapsto xv\\) is a derivation. Such a derivation is called inner. We define \\(H^1(\\Lie g, V)\\) to be the quotient \\(\\operatorname{Der}(\\Lie g, V)\\) by the inner derivations. Thus the theorem says that \\(\\Lie g\\) is semisimple implies that \\(H^1(\\Lie g, \\Lie g) = 0\\), but the converse is false. This is the subject of Lie algebra cohomology.\n\n\\begin{remark}\n  If \\(\\Lie g\\) is a Lie algebra over \\(k\\) where \\(\\cha k = 0\\) then consider the SES\n  \\[\n    \\begin{tikzcd}\n      0 \\ar[r] & R(\\Lie g) \\ar[r] & \\Lie g \\ar[r] & \\Lie g/R(\\Lie g) \\ar[r] & 0\n    \\end{tikzcd}\n  \\]\n  The theorem says that \\(\\Lie g/R(\\Lie g)\\) is semisimple as its radical is \\(0\\). We are going to classify all the semisimple Lie algebras. As \\(R(\\Lie g)\\) is solvable, this makes the theory particularly nice.\n\\end{remark}\n\nIt's helpful to mention that\n\n\\begin{theorem}[Levi]\n  The above exact sequence splits, that is there exists a subalgebra \\(\\Lie h \\subseteq \\Lie g\\) with \\(\\Lie h \\to \\Lie g/R(\\Lie g)\\). This subalgebra is not canonical, i.e.\\ not an ideal, but his does say semidirect product.\n\\end{theorem}\n\n\\begin{ex}\n  Show Levi's theorem fails in characteristic \\(p\\). Let \\(\\Lie g = \\Lie{sl}_p(\\overline F_p)\\). Show \\(R(\\Lie g) = \\overline F_p \\cdot I\\) but there is no complement to \\(R(\\Lie g)\\) which is a subalgebra.\n\\end{ex}\n\n\\begin{proof}[Proof of \\Cref{thm:semisimplicity criteria}]\n  Claim \\(\\R(Lie g) = 0\\) if and only if \\(\\Lie g\\) has non-zero abelian ideals.\n  \\begin{proof}\n    Only if is easy as an abelian ideal is solvable. For if, the derived series of \\(R(\\Lie g)\\) is (defines?) a sequence of ideals of \\(\\Lie g\\) and the last term is abelian.\n  \\end{proof}\n\n  \\(3 \\implies 2\\): we show that if \\(\\Lie a \\subseteq \\Lie g\\) is an abelian ideal then \\(\\Lie a \\subseteq \\Lie g^\\perp\\) where the perp is with respect to the Killing form.\n  \\begin{proof}\n    Take a vector space complement \\(\\Lie h\\) to \\(\\Lie a\\) in \\(\\Lie g\\) so \\(\\Lie g = \\Lie a \\oplus \\Lie h\\). If \\(x \\in \\Lie g\\) then \\(\\ad x\\) is block upper triangular and if \\(a \\in \\Lie a\\) then as \\([\\Lie a, \\Lie a] = 0\\) so \\(\\ad a\\) ia block strictly upper triangular so \\((a, x)_\\ad = \\tr \\ad_a \\ad_x = 0\\).\n  \\end{proof}\n\n  \\(2 \\implies 3\\): let \\(\\Lie r \\subseteq \\Lie g^\\perp\\) be an ideal of \\(\\Lie g\\) (for example \\(\\Lie r = \\Lie g^\\perp\\) and  suppose \\(\\Lie r \\neq 0\\). Then \\(R(\\Lie g) = 0\\) implies that centre of \\(\\Lie g\\) is zero (?) so \\(\\Lie r \\subseteq \\Lie{gl}(\\Lie g)\\) as \\(\\ad: \\Lie g \\to \\Lie{gl}(\\Lie g)\\) is injection and as \\(Lie r \\subseteq \\Lie g^\\perp\\), \\((x, y)_\\ad = 0\\) for all \\(x, y \\in \\Lie g\\). In particular for all \\(y \\in [\\Lie r, \\Lie r]\\), so Carton's criteria implies that \\(\\Lie r\\) is solvable, contradiction. Thus \\(R(\\Lie g) = 0\\).\n\n  \\begin{ex}\n    Show \\(R(\\Lie g) \\supseteq \\Lie g^\\perp \\supseteq [R(\\Lie g), R(\\Lie g)]\\) in general for \\(\\cha k = 0\\).\n  \\end{ex}\n\n  \\(2, 3 \\implies 1\\): Assume the Killing form is nondegenerate and let \\(\\Lie s \\subseteq \\Lie g\\) be a minimal non-zero ideal. Observe that \\((\\cdot, \\cdot)_\\ad|_{\\Lie s}\\) is either non-degenerate or \\(0\\): the kernel is \\(\\{x \\in \\Lie s: (x, s)_\\ad = 0\\} = \\Lie s \\cap \\Lie s^\\perp\\) which is an intersection of ideals, and we assumed \\(\\Lie s \\neq 0\\) is minimal. But if it is zero then by Cartan \\(\\Lie s\\) is solvable so \\(R(\\Lie g) \\neq 0\\), contradiction. Thus \\((\\cdot, \\cdot)_\\ad|_{\\Lie s}\\) is non-degenerate and hence we get a direct sum decomposition \\(\\Lie g = \\Lie s \\oplus \\Lie s^\\perp\\). Note \\(\\Lie s\\) is not abelian as \\(R(\\Lie g) = 0\\) and \\(\\Lie s\\) is minimal implies \\(\\Lie s\\) is simple. Moreover \\(R(\\Lie g) = 0\\) implies \\(R(\\Lie s^\\perp) = 0\\) (exercise) and we can conclude by induction on \\(\\dim \\Lie g\\) as \\(\\Lie s^\\perp\\) is a Lie algebra of smaller dimension with \\(R(\\Lie s^\\perp) = 0\\).\n\n  \\(1 \\implies 2\\): exercise: show that if \\(\\Lie g\\) is semisimple then \\(\\Lie g\\) is a direct sum of minimal ideals in a unique way. In particular show if \\(\\Lie g = \\bigoplus_{i = 1}^r \\Lie s_i\\) where \\(\\Lie s_i\\)'s are minimal ideals of \\(\\Lie g\\) and if \\(\\Lie b\\) is a minimal ideal of \\(\\Lie g\\), show \\(\\Lie b = \\Lie s_i\\) for some \\(i\\) (hint: consider \\(\\Lie b \\cap \\Lie s_i\\) for all \\(i\\)). Derive as a corollary \\(1 \\implies 2\\).\n\n  Finally let \\(D: \\Lie g \\to \\Lie g\\) be a derivation with \\(\\Lie g\\) semisimple. Consider the linear map\n  \\begin{align*}\n    \\ell: \\Lie g &\\to k \\\\\n    x &\\mapsto \\tr (d \\ad x: \\Lie g \\to \\Lie g)\n  \\end{align*}\n  As \\((\\cdot, \\cdot)_\\ad\\) is non-degenerate, exists \\(y \\in \\Lie g\\) such that \\(\\ell(x) = (y, x)_\\ad\\) for all \\(x \\in \\Lie g\\). Would like to show \\(E = D - \\ad y = 0\\): enough to show \\((Ex, z)_\\ad = 0\\) for all \\(x, z \\in \\Lie g\\). But\n  \\[\n    \\ad(Ex) = E \\ad x - \\ad x E = [E, \\ad x]\n  \\]\n  as\n  \\[\n    \\ad(Ex)(z) = [Ex, z] = E[x, z] - [x, Ez]\n  \\]\n  since \\(E\\) is a derivation. Hence\n  \\begin{align*}\n    (Ex, z)_\\ad\n    &= \\tr(\\ad(Ex) \\ad(z)) \\\\\n    &= \\tr([E, \\ad x], \\ad z) \\\\\n    &= \\tr(E, [\\ad x, \\ad z]) \\\\\n    &= \\tr(E, \\ad[x, z]) \\\\\n    &= (E, [x, z])_\\ad\n  \\end{align*}\n  But by the definition of \\(E\\), \\((E, a)_\\ad = 0\\) for all \\(a \\in \\Lie g\\), proving the result.\n\\end{proof}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(\\Lie n\\) is a nilpotent Lie algebra then there exists a non-inner derivation \\(D: \\Lie n \\to \\Lie n\\).\n  \\item Let \\(\\Lie g = \\langle x, y\\rangle, [x, y] = y\\). Show this has only inner derivations (so this doesn't characterise semisimple Lie algebras).\n  \\end{enumerate}\n\\end{ex}\n\n\\section{Structure theory of semisimple Lie algebras}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\Lie g\\) be a simple Lie algebra with two nondegenerate symmetric bilinear forms \\((\\cdot, \\cdot)_1, (\\cdot, \\cdot)_2\\). SHow exists \\(\\lambda \\in k^*\\) such that \\((\\cdot, \\cdot)_1 = \\lambda (\\cdot, \\cdot)_2\\) (\\(\\cha k = 0, k = \\overline k\\)).\n  \\item Let \\(\\Lie g = \\Lie{sl}_n(\\C)\\). Then there are two such forms: the Killing form and \\((A, B) \\mapsto \\tr AB\\). Find \\(\\lambda\\).\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{definition}[torus]\\index{torus}\\index{maixmal torus}\n  Let \\(\\Lie g\\) be a Lie algebra. A \\emph{torus} \\(\\Lie t \\subseteq \\Lie g\\) is an abelian subalgebra such that for all \\(t \\in \\Lie t\\), \\(\\ad t: \\Lie g \\to \\Lie g\\) is a diagonalisable linear map. A \\emph{maximal torus} is a torus not contained in any strictly bigger torus.\n\\end{definition}\n\n\\begin{eg}\n  Let \\(G\\) be an algebraic group, \\(T = (\\C^*)^r \\subseteq G\\) a subgroup. Then \\(\\mathrm{Lie}(T)\\) is a torus in \\(\\mathrm{Lie}(G)\\).\n\\end{eg}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(\\Lie g = \\Lie{gl}_n\\) then \\(\\Lie t\\) of diagonal matrices in \\(\\Lie g\\) is a maximal torus. Show the same for \\(\\Lie{sl}_n\\).\n  \\item Show \\(\n    \\begin{psmallmatrix}\n      0 & * \\\\\n      0 & 0\n    \\end{psmallmatrix}\n    \\subseteq \\Lie{sl}_2\\) is not a torus.\n  \\end{enumerate}\n\\end{ex}\n\nIf \\(V\\) is a vector space, \\(t_1, \\dots, t_r: V \\to V\\) are pairwise commuting linear maps, \\(\\lambda_1, \\dots, \\lambda_r \\in \\C^r\\). Define\n\\[\n  V_{(\\lambda_1, \\dots, \\lambda_r)} = \\{v \\in V: t_i v = \\lambda_i v \\text{ for all } i\\},\n\\]\nthe simultaneous eigenspace.\n\n\\begin{lemma}\n  If each \\(t_i\\) is diagonalisable then \\(V = \\bigoplus_{\\lambda \\in \\C^r} V_\\lambda\\).\n\\end{lemma}\n\n\\begin{proof}\n  Induction on \\(R\\). If \\(r = 1\\) this is the assumption \\(t_1\\) is diagonalisable. For \\(r > 1\\), induction gives\n  \\[\n    V = \\bigoplus_{(\\lambda_1, \\dots, \\lambda_{r - 1}) \\in \\C^{r - 1}} V_{(\\lambda_1, \\dots, \\lambda_{r - 1})}\n  \\]\n  and now \\(t_r\\) commutes with each of \\(t_1, \\dots, t_{r - 1}\\) so preserves this eigenspace decomposition, so decomposes each \\(V_{(\\lambda_1, \\dots, \\lambda_{r - 1})}\\) into eigenspaces for \\(t_r\\).\n\\end{proof}\n\nRecap: let \\(\\Lie t\\) be an abelian Lie algebra with basis \\(t_1, \\dots, t_n\\), \\(k = \\overline k\\). Then\n\\begin{enumerate}\n\\item a rep \\(V\\) of \\(\\Lie t\\) is irreducible if and only if \\(\\dim V = 1\\), exists \\(\\lambda \\in \\Lie t^* = \\Hom(\\Lie t, k)\\), \\(t v = \\lambda(t) v\\). \\(\\lambda_i = \\lambda(t_i)\\) is the eigenvalue of \\(t_i\\).\n\\item \\(V\\) is a direct sum of irreducible reps if and only if each \\(t_i\\) is diagonalisable.\n\\end{enumerate}\n\nDefine \\(\\Lie t \\subseteq \\Lie g\\) to be the maximal torus. If \\(V\\) is a rep of \\(\\Lie t^*\\). Write \\(V_\\lambda\\) for the \\(\\lambda\\)-weight space of \\(V\\).\n\n\\begin{corollary}\n  \\(\\Lie g = \\Lie g + \\bigoplus_{\\lambda \\in \\Lie t^*} \\Lie g_\\lambda\\)\n\\end{corollary}\n\n\\begin{definition}\n  We define the roots of \\(\\Lie g\\) to be \\(R = \\{\\lambda \\in \\Lie t^*: \\Lie g_\\lambda \\neq 0\\}\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(\\Lie g = \\Lie{sl}_n\\), \\(\\Lie t\\) the diagonal matrices, i.e.\\ the trace \\(0\\) diagonal matrices. Let \\(t\\) be the diagonal matrix with diagonal entries \\(t_1, \\dots, t_n\\), \\(E_{ij}\\) with \\(1\\) at \\(ij\\)th entry and \\(0\\) elsewhere (matrix units). Then \\([t, E_{ij}] = (t_i - t_j) E_{ij}\\). Define linear maps \\(\\varepsilon_i: \\Lie t \\to k, ... \\mapsto t_i\\). Then \\(\\varepsilon_i\\) span \\(\\Lie t^*\\). Also as \\(\\Lie t \\subseteq k^n\\), we have \\((k^n)^* \\surj \\Lie t^*\\). \\((k^n)^*\\) has basis \\(\\varepsilon_i\\), so this is quotient by \\(\\varepsilon_1 + \\dots + \\varepsilon_n = 0\\).\n\n  Also \\(\\Lie g_0 = \\Lie t, \\Lie g_{\\varepsilon_i - \\varepsilon_j} = k \\cdot E_{ij}\\) and so \\(\\Lie{sl}_n\\) has root space decomposition\n  \\[\n    \\Lie{sl}_n = \\Lie t \\oplus \\bigoplus_{i \\neq j} \\Lie g_{\\varepsilon_i - \\varepsilon_j}.\n  \\]\n\\end{eg}\n\n\\begin{ex}\n  Essential exercise. Suppose \\(k = \\overline k, \\cha k \\neq 2\\) (can take \\(k = \\C\\)). Compute the root space decomposition for \\(\\Lie g = \\Lie{sl}_n, \\Lie{so}_{2n + 1}, \\Lie{so}_{2n}, \\Lie{sp}_{2n}\\) with \\(\\Lie t\\) the diagonal matrices in \\(\\Lie g\\). Note we use the bilinear form defining \\(\\Lie{so}_n\\) to be \\(\\Lie{so}_n = \\{A: JA + A^TJ = 0\\}\\) where \\(J\\) is the antidiagonal matrix with entries \\(1\\). Check that \\(\\Lie t\\) is indeed a maximal torus.\n\n  Subexercise: show this \\(\\Lie{so}_n\\) is the same as \\(\\{A + A^T = 0\\}\\) by showing all nondegenerate orthogonal forms are equivalent.\n\\end{ex}\n\n\\begin{proposition}\n  \\(\\Lie{sl}_n \\C\\) is a simple Lie algebra.\n\\end{proposition}\n\n\\begin{proof}\n  Suppose \\(\\Lie r \\subseteq \\Lie{sl}_n \\C = \\Lie t \\oplus \\bigoplus_{\\alpha \\in R} \\Lie g_\\alpha\\) is a nonzero ideal. We must show \\(\\Lie r = \\Lie g\\). Choose \\(r \\neq 0, r \\in \\Lie r\\) such that \\(\\Lie r = \\Lie t + \\sum_\\alpha e_\\alpha\\) with \\(e_\\alpha \\in \\Lie g_\\alpha\\) with the minimal number of non-zero terms. First suppose \\(\\Lie t \\neq 0\\). Choose \\(\\alpha \\in \\Lie t\\) such that \\(\\alpha(t_0) neq 0\\) for all \\(\\alpha \\in R\\), that is choosing a diagonal matrix with disinct eigenvalues. Consider \\([t_0, r] \\in \\Lie r\\), \\([t_0, r] = \\sum \\alpha(t_0) e_\\alpha\\). If nonzero this has fewer terms than \\(r\\), absurd. Thus \\(e_\\alpha = 0\\) for all \\(\\alpha \\in R\\), i.e.\\ \\(r = t \\in \\Lie t\\). But \\(t \\neq 0\\) so exists \\(\\alpha \\in R\\) with \\(\\alpha(t) \\neq 0\\). (as \\(\\alpha(t) = 0\\) for all \\(\\alpha = \\varepsilon_i - \\varepsilon_j\\) is saying \\(t\\) is \\(\\lambda I\\), but \\(\\tr \\lambda I = n\\lambda \\neq 0\\). Phrase in another way: \\(R\\) spans \\(\\Lie t^*\\))\n\n  Thus \\([t, e_\\alpha] = \\alpha(t) e_\\alpha \\neq 0 \\in \\Lie r\\) so \\(e_\\alpha \\in \\Lie r\\). But \\(\\alpha = \\varepsilon_i - \\varepsilon_j\\) for some \\(i \\neq j\\), so this says \\(E_{ij} \\in \\Lie r\\). But \\([E_{ij}, E_{jk}] = E_{ik}\\) if \\(k \\neq i\\) and \\([E_{si}, E_{ij}] = E_{sj}\\) if \\(s \\neq j\\). Hence \\(E_{ab} \\in \\Lie r\\) for all \\(a \\neq b\\). Finally\n  \\[\n    [E_{i, i + 1}, E_{i + 1, i}] = E_{ii} - E_{i + 1, i + 1} \\in \\Lie r\n  \\]\n  so we've just seen a basis for \\(\\Lie{sl}_n\\) is in \\(\\Lie r\\).\n\n  Finally if \\(r = t + \\sum e_\\alpha\\) and \\(t = 0\\). If there is one term in this expression, i.e.\\ \\(r = c E_{ij}\\) for some \\(c \\neq 0\\), we are done as above. Otherwise\n  \\[\n    r = e_\\alpha + e_\\beta + \\sum_{\\gamma \\in R\\setminus\\{\\alpha, \\beta\\}} e_\\alpha\n  \\]\n  for some \\(\\alpha \\neq \\beta\\). Choose \\(t_0 \\in \\Lie t\\) such that \\(\\alpha(t_0) \\neq \\beta(t_0)\\). Then some linear combination of \\([t_0, r]\\) and \\(r\\) is nonzero with fewer terms, absurd.\n\n  Key ingedient: \\([E_{ij}, E_{jk}] = \\dots\\) Combinatorial.\n\\end{proof}\n\n\\begin{proposition}\n  Let \\(\\Lie g\\) be a semisimple Lie algebra over \\(\\C\\). Then\n  \\begin{enumerate}\n  \\item non-zero maximal tori \\(\\Lie t\\) exist.\n  \\item \\(\\Lie t = \\Lie g_0 = \\{x \\in \\Lie g: [t, x] = 0 \\text{ for all } t \\in \\Lie t\\}\\), that is, such \\(\\Lie t\\) are maximal abelian.\n  \\item Will state more precisely later: any two such \\(\\Lie t\\) are conjugate by an element of algebraic group \\(G\\) of automorphisms of \\(\\Lie g\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\n  Omitted, for lack of time.\n\\end{proof}\n\nHence \\(\\Lie g = \\Lie g \\oplus \\bigoplus_{\\alpha \\in R} \\Lie g_\\alpha\\), as we have seen by hand for the classical Lie algebras \\(\\Lie{sl}_n, \\Lie{so}_n, \\Lie{so}_{2n}\\).\n\n\\begin{theorem}[structure theorem for semisimple Lie algebras, part 1]\n  Let \\(\\Lie g\\) be a semisimple Lie algebra over \\(\\C\\), \\(\\Lie g = \\Lie t \\oplus \\bigoplus_{\\alpha \\in R} \\Lie g_\\alpha\\). Then\n  \\begin{enumerate}\n  \\item the roots span \\(\\Lie t^*\\).\n  \\item \\(\\dim \\Lie g_\\alpha = 1\\) for all \\(\\alpha \\in R\\).\n  \\item If \\(\\alpha, \\beta \\in R\\) and \\(\\alpha, \\beta \\in R\\) then \\([\\Lie g_\\alpha, \\Lie g_\\beta] = \\Lie g_{\\alpha + \\beta}\\). If \\(\\alpha + \\beta \\notin R\\) and \\(\\alpha \\ne -\\beta\\) then \\([\\Lie g_\\alpha, \\Lie g_\\beta] = 0\\).\n  \\item \\([\\Lie g_\\alpha, \\Lie g_{-\\alpha}] \\subseteq \\Lie t\\) is one-dimensional and \\(\\Lie g_\\alpha + [\\Lie g_\\alpha, \\Lie g_{-\\alpha}] + \\Lie g_{-\\alpha}\\) is a Lie subalgebra of \\(\\Lie g\\), isomorphic to \\(\\Lie{sl}_2\\). In particular if \\(\\alpha \\in R\\) then \\(-\\alpha \\in R\\).\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{ex}\n  Check this for classical Lie algebras.\n\\end{ex}\n\n\\begin{proof}\n  Suppose not. Then there exists \\(t \\in \\Lie t^*\\) such that \\(\\alpha(t) = 0\\) for all \\(\\alpha \\in R\\). But then if \\(x \\in \\Lie g_\\alpha\\), \\([t, x] = \\alpha(t) x = 0\\) so \\([t, \\Lie g] = 0\\), i.e.\\ \\(t\\) is in the centre of \\(\\Lie g\\). But \\(\\Lie g\\) is semisimple so has no nontrivial abelian ideals.\n\n  We now prove a sequence of results which implies most of them. If \\(\\lambda, \\mu \\in \\Lie t^*\\) then \\([\\Lie g_\\lambda, \\Lie g_\\mu] \\subseteq \\Lie g_{\\lambda + \\mu}\\).\n\n  \\begin{proof}\n    If \\(x \\in \\Lie g_\\lambda, y \\in \\Lie g_\\mu, t \\in \\Lie t\\) then\n    \\begin{align*}\n      [t, [x, y]] &= [[t, x], y] + [x, [t, y]] \\\\\n                  &= \\lambda(t) [x, y] + \\mu(t) [x, y] \\\\\n                  &= (\\lambda + \\mu) (t) [x, y]\n    \\end{align*}\n    Hence if \\(\\alpha, \\beta \\in R\\) but \\(\\alpha + \\beta \\neq 0\\) and \\(\\alpha + \\beta \\notin R\\) (so \\(\\Lie g_{\\alpha + \\beta} = 0\\)) then \\([\\Lie g_\\alpha, \\Lie g_\\beta] = 0\\) and if \\(\\alpha + \\beta \\in R\\) then \\([\\Lie g_\\alpha, \\Lie g_\\beta] \\subseteq \\Lie g_{\\alpha + \\beta}\\). If \\(\\alpha + \\beta = 0\\) then \\([\\Lie g_\\alpha, \\Lie g_\\beta] \\subseteq \\Lie t\\). Note we will not show \\([\\Lie g_\\alpha, \\Lie g_\\beta] = \\Lie g_{\\alpha + \\beta}\\) for a while.\n\n  \\end{proof}\n  Secondly claim \\((g_\\lambda, g_\\mu)_\\ad = 0\\) if \\(\\lambda + \\mu \\neq 0\\) and \\((\\cdot, \\cdot)_\\ad|_{g_\\lambda + g_{-\\lambda}}\\) is nondegenerate.\n\n  \\begin{proof}\n    Let \\(x \\in g_\\lambda, y \\in g_\\mu\\). To show this is \\(0\\), it is enough to show \\(\\ad x \\ad y\\) is nilpotent (?). But\n    \\[\n      (\\ad x \\ad y)^N g_\\alpha \\subseteq g_{\\alpha + N(\\lambda + \\mu)}\n    \\]\n    by the previous part. So if \\(\\lambda + \\mu \\neq 0\\) then as \\(g\\) is finite dimensional, \\(g_{\\alpha + N(\\lambda + \\mu)} = 0\\) for \\(N >> 0\\), showing \\((x, y)_\\ad = 0\\).\n\n    On the other hand, the Killing form is nondegenerate and \\(g = \\bigoplus_\\lambda (g_\\lambda + g_{-\\lambda})\\) is an orthogonal decomposition by what we just showed, so \\((\\cdot, \\cdot)_\\ad|_{g_\\lambda + g_{-\\lambda}}\\) is nondegenerate.\n  \\end{proof}\n\n  In particular take \\(\\lambda = 0\\). Get \\((\\cdot, \\cdot)_\\ad|_{\\Lie t}\\) is non-degenerate. Hence we get an isomorphism \\(v: \\Lie t \\to \\Lie t^*\\) by \\(v(t)(t') = (t, t')_\\ad\\). Moreover this defines a symmetric bilinear form on \\(\\Lie t^*\\) by \\((v(t), v(t')) = (t, t')_\\ad\\) (make \\(v\\) an isometry).\n\n  Claim if \\(\\alpha \\in R\\) then \\(-\\alpha \\in R\\): \\((g_\\alpha, g_\\alpha)_\\ad = 0\\) as \\(\\alpha \\neq 0\\) implies \\(2\\alpha \\neq 0\\). But \\((\\cdot, \\cdot)_\\ad|_{g_\\alpha + g_{-\\alpha}}\\) is non-degenerate (in particular so Killing form gives an isomorphism \\(g_\\alpha \\cong g_{-\\alpha}^*\\)).\n\n  Let \\(x \\in g_\\alpha, y \\in g_{-\\alpha}\\). Claim \\([x, y] = (x, y)_\\ad v^{-1}(\\alpha)\\).\n\n  \\begin{proof}\n    \\begin{align*}\n      (t, [x, y])_\\ad\n      &= ([t, x], y)_\\ad \\\\\n      &= \\alpha(t) (x, y)_\\ad\n    \\end{align*}\n  \\end{proof}\n\n  Pick \\(e_\\alpha \\in g_\\alpha, e_\\alpha \\ne 0\\) and \\(e_{-\\alpha} \\in g_{-\\alpha}\\) such that \\((e_\\alpha, e_{\\alpha})_\\ad \\ne 0\\). and consider \\(M_:a = \\langle e_\\alpha, e_{-\\alpha}, v^{-1}(\\alpha) \\rangle\\). This is a 3 dimensional Lie algebra as\n  \\[\n    [v^{-1}(\\alpha), e_\\alpha] = \\alpha(v^{-1}(\\alpha)) e_\\alpha = (\\alpha, \\alpha) e_\\alpha\n  \\]\n  and similarly \\([v^{-1}(\\alpha), e_{-\\alpha}] = -(\\alpha, \\alpha) e_\\alpha\\). So if \\((\\alpha, \\alpha) \\neq 0\\) then define \\(h_\\alpha = \\frac{2}{(\\alpha, \\alpha)} v^{-1}(\\alpha)\\) and rescale \\(e_{-\\alpha}\\) so that \\((e_\\alpha, e_{-\\alpha})_\\ad = \\frac{2}{(\\alpha, \\alpha)}\\). It is an exercise to show that \\(M_\\alpha \\to \\Lie{sl}_2, e_\\alpha, h, e_{-\\alpha} \\mapsto e, h, f\\).\n\n  Now we show if \\(\\alpha \\in R\\) then \\((\\alpha, \\alpha) \\neq 0\\). Suppose otherwise, then \\([M_\\alpha, M_\\alpha] = \\C v^{-1}(\\alpha)\\) (or did we merely prove containment?), i.e.\\ \\(M_\\alpha\\) is a solvable Lie algebra. Hence by Lie's theorem, \\(\\ad[M_\\alpha, M_\\alpha]\\) acts as nilpotent operators on \\(\\Lie g\\), i.e.\\ \\(\\ad v^{-1}(\\alpha)\\) is nilpotent. But \\(v^{-1}(\\alpha) \\in \\Lie t\\) and hence diagonalisable. Together this implies \\(\\nu^{-1}(\\alpha) = 0\\). But \\(\\alpha \\in R\\) means \\(\\alpha \\neq 0\\), contradiction.\n\n  Claim \\(\\dim \\Lie g_{-\\alpha} = 1\\) for all \\(\\alpha \\in R\\).\n\n  \\begin{proof}\n    Fix \\(\\alpha\\). Pick \\(\\Lie m_\\alpha \\subseteq \\Lie g\\) so \\(\\Lie m_\\alpha \\cong \\Lie{sl}_2\\). If \\(\\dim \\Lie g_{-\\alpha} > 1\\) then the map \\(g_{-\\alpha} \\to \\C \\nu^{-1}(\\alpha), x \\mapsto \\ad e_\\alpha \\cdot x\\) has a non-zero kernel. So exists \\(v \\in g_{-\\alpha}\\) such that\n    \\begin{align*}\n      \\ad(e_\\alpha) v &= 0 \\\\\n      \\ad(h_\\alpha) v &= -\\alpha(h_\\alpha) . v = -2v\n    \\end{align*}\n    Claim \\(v\\) is a highest weight vector for \\(\\Lie{sl}_2\\) with negative highest weight. Hence the \\(\\Lie{sl}_2\\)-submodule of \\(\\Lie g\\) generated by \\(v\\) is infinite dimensional, conradiction.\n  \\end{proof}\n\\end{proof}\n\nGuaranteed question on exam: explain everything about each classical Lie algebra.\n\n\\begin{theorem}[structure theorem, part II]\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\frac{2(\\alpha, \\beta)}{(\\alpha, \\alpha)} \\in \\Z\\) for all \\(\\alpha, \\beta \\in R\\).\n  \\item If \\(\\alpha \\in R\\) and \\(k \\alpha \\in R\\) then \\(k = \\pm 1\\).\n  \\item \\(\\bigoplus_{k \\in \\Z} \\Lie g_{\\beta + k \\alpha}\\). This is an irreducible module for \\((\\Lie{sl}_2)_\\alpha = \\Lie m_\\alpha\\). In particular\n    \\[\n      \\{k\\alpha + \\beta: k \\in \\Z, k \\alpha + \\beta \\in \\R \\cup \\{0\\}\\}\n    \\]\n    is of the form \\(\\beta - p \\alpha, \\beta - (p - 1) \\alpha, \\dots, \\beta + (p - 1)\\alpha, \\beta + q \\alpha\\) where \\(p - q = \\frac{2(\\alpha, \\beta)}{(\\alpha, \\alpha)}\\). This is called the \\emph{\\(\\alpha\\) string through \\(\\beta\\)}.\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(q = \\max \\{k \\in \\Z: p + k \\alpha \\in R\\}\\) and let \\(v \\in \\Lie g_{\\beta + q \\alpha} \\setminus \\{0\\}\\). Then \\(\\ad e_\\alpha v \\in \\Lie g_{\\beta + (q + 1)\\alpha} = 0\\) and\n    \\[\n      \\ad h_\\alpha . v = (\\beta + q\\alpha) (h_\\alpha) . v = \\left( \\frac{2(\\beta, \\alpha)}{(\\alpha, \\alpha)} + 2q \\right) \\cdot v\n    \\]\n    Hence is a highest weight vector for \\(\\Lie{sl}_2\\) with weight ... and this is a non-negative integer as \\(\\Lie g\\) is finite dimensional.\n  \\item\n  \\item Structure of \\(\\Lie{sl}_2\\)-modules implies that \\((\\ad e_{\\alpha})^r v \\neq 0\\) for \\(0 \\leq r \\leq N\\) where \\(N = \\frac{2(\\beta, \\alpha)}{(\\alpha, \\alpha)} + 2q\\) and \\((\\ad e_{-\\alpha})^{N + 1}v = 0\\). Hence\n  \\[\n    \\{\\beta + (q - k) \\alpha: 0 \\leq k \\leq N\\}\n  \\]\n  are all in \\(R \\cup \\{0\\}\\) (in particular, non-zero eigenspaces). We need to show no other roots of the form \\(\\beta + k\\alpha\\). Repeat same construction from bottom up: \\(p = \\max \\{k: \\beta - k\\alpha \\in R \\cup \\{0\\}\\}\\), \\(w \\in \\Lie g_{\\beta - p \\alpha} \\setminus \\{0\\}\\) implies \\(\\ad e_{-\\alpha} w = 0\\).\n  ... diagram and the strings coincide.\n  \\end{enumerate}\n  For 2, apply 1 to \\(\\{\\alpha, \\beta\\} = \\{\\alpha, k\\alpha\\}\\) to get\n  \\[\n    \\frac{2(\\alpha, k\\alpha)}{k \\alpha, k \\alpha} = \\frac{2}{k} \\in \\Z, \\frac{2(k\\alpha, \\alpha)}{\\alpha, \\alpha)} = 2k \\in \\Z.\n  \\]\n  Take \\(\\alpha = \\beta\\) in 2 (?) as \\((sl_2)_\\alpha = g_\\alpha + [g_\\alpha, g_\\alpha] + g_{-\\alpha}\\) is an irreducible \\((sl_2)_\\alpha\\)-module, 2 says it is a string though \\(\\alpha\\) so \\(g_{2\\alpha} = 0 = g_{-2\\alpha}\\).\n\n  Finally if \\(\\alpha, \\beta, \\alpha + \\beta \\in R\\), we need to show \\([g_\\alpha, g_\\beta] = g_{\\alpha + \\beta}\\). But \\(\\bigoplus_{k \\in \\Z} g_{\\beta + k \\alpha}\\) is an irreducible \\(sl_2\\)-module, so \\(ad e_k: g_{\\beta + k\\alpha} \\to g_{\\beta + (k + 1)\\alpha}\\) is an iso if \\(k < q\\). But \\(q \\geq 1\\) so in particular \\(\\ad e_\\alpha: g_\\beta \\to g_{\\beta + \\alpha}\\) is an iso.\n\\end{proof}\n\nThe statement of 3 is messsy. Here is a much cleaner consequence.\n\nGiven \\(\\alpha \\in t^*\\), define ``reflection''\n\\begin{align*}\n  s_\\alpha: t^* &\\to t^* \\\\\n  v &\\mapsto v -\\frac{2 (\\alpha, v)}{(\\alpha, \\alpha)} \\alpha\n\\end{align*}\nClaim that 3 implies \\(s_\\alpha \\beta \\in R\\) if \\(\\alpha, \\beta \\in R\\).\n\n\\begin{proof}\n  Let \\(r = \\frac{2(\\alpha, \\beta)}{(\\alpha, \\alpha)}\\). If \\(r \\geq 0\\) then \\(p = q + r \\geq r\\). If \\(r \\leq 0\\) then \\(q = p - r \\geq -r\\). In either case \\(\\beta - r \\alpha\\) is the \\(\\alpha\\)-string through \\(\\beta\\). Exercise: show drawing is accurate (reflection sends \\(\\beta\\) to \\(s_\\alpha \\beta\\).\n\\end{proof}\n\n\\begin{proposition}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(\\alpha, \\beta \\in R\\) then \\((\\alpha, \\beta) \\in \\Q\\).\n  \\item If we pick a basis \\(\\beta_1, \\dots \\beta_r\\) of \\(t^*\\) with each \\(\\beta_i \\in R\\) then any \\(\\beta \\in R\\) is of the form \\(\\sum q_i \\beta_i\\) with \\(q_i \\in \\Q\\), that is the \\(\\Q\\)-span of \\(R\\) has dimension equal to \\(\\dim_\\C t\\).\n  \\item \\((\\cdot, \\cdot)\\) is positive definite on \\(\\Q R\\).\n  \\end{enumerate}\n\\end{proposition}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item As \\(\\frac{2(\\alpha, \\beta)}{(\\alpha, \\alpha)} \\in \\Z\\) it is enough to show \\((\\beta, \\beta) \\in \\Q\\) for all \\(\\beta \\in R\\). Let \\(t, t' \\in t\\), then\n    \\[\n      (t, t')_\\ad = \\tr(\\ad t \\ad t': g \\to g) = \\sum_{\\alpha \\in R} \\alpha(t) \\alpha(t')\n    \\]\n    by weight space decomposition. So if \\(\\lambda, \\beta \\in t^*\\) then\n    \\begin{align*}\n      (\\lambda, \\mu) &= (\\nu^{-1}(\\lambda), \\nu^{-1}(\\mu)) \\\\\n                     &= \\sum_{\\alpha \\in R} \\alpha(\\nu^{-1}(\\lambda)) \\alpha (\\nu^{-1}(\\mu)) \\\\\n      &= \\sum_{\\alpha \\in R} (\\lambda, \\alpha)(\\mu, \\alpha)\n    \\end{align*}\n    In particular \\((\\beta, \\beta) = \\sum_{\\alpha \\in R} (\\beta, \\alpha)^2\\). Multiply by \\(\\frac{4}{(\\beta, \\beta)^2}\\), get\n    \\[\n      \\frac{4}{(\\beta, \\beta)} = \\sum_{\\alpha \\in R} \\left( \\frac{2(\\alpha, \\beta)}{(\\beta, \\beta)} \\right)^2 \\in \\Z.\n    \\]\n  \\item Let \\(B\\) be the grand matrix of \\((\\cdot, \\cdot)\\) on \\(t^*\\) with respect to basis \\(\\beta_i\\), meaning \\(B = [(\\beta_i, \\beta_j)]_{ij}\\). It is an exercise to check \\((\\cdot, \\cdot)\\) is nondegenerate implies \\(\\det B \\neq 0\\). Let \\(\\beta = \\sum c_i \\beta_i \\in R\\) so \\((\\beta, \\beta_i) = \\sum_j c_j (\\beta_j, \\beta_i)\\), that is\n    \\[\n      \\begin{pmatrix}\n        (\\beta, \\beta_1) \\\\\n        \\vdots \\\\\n        (\\beta, \\beta_r)\n      \\end{pmatrix}\n      = B\n      \\begin{pmatrix}\n        c_1 \\\\\n        \\vdots \\\\\n        c_r\n      \\end{pmatrix}\n    \\]\n    and as \\(\\det B \\neq 0\\) we can invert this. Then \\(c_i \\in \\Q\\).\n  \\item Let \\(\\lambda = \\sum c_i \\beta_i\\) with \\(c_i \\in \\Q\\), so \\((\\lambda, \\alpha) \\in \\Q\\) for all \\(\\alpha \\in R\\). But \\((\\lambda, \\lambda) = \\sum_{\\alpha \\in R}(\\lambda, \\alpha)^2 \\geq 0\\) and \\((\\lambda, \\lambda) = 0\\) implies \\((\\lambda, \\alpha) = 0\\) for all \\(\\alpha \\in R\\). But \\(R\\) spans \\(t^*\\) and \\((\\cdot, \\cdot)\\) is nondegenerate so \\(\\lambda = 0\\).\n  \\end{enumerate}\n\\end{proof}\n\n\\section{Root systems}\n\nLet \\(V\\) be a vector space over \\(\\R\\), let \\((\\cdot, \\cdot): V \\times V \\to \\R\\) be an inner product, i.e.\\ a positive definite symmetric bilinear form. If \\(\\alpha \\in V, \\alpha \\neq 0\\) let \\(\\alpha^\\vee = \\frac{2\\alpha}{(\\alpha, \\alpha)}\\) so \\((\\alpha, \\alpha^\\vee) = 2\\). Define\n\\begin{align*}\n  s_\\alpha: V &\\to V \\\\\n  v &\\mapsto v - (v, \\alpha^\\vee) \\alpha\n\\end{align*}\n\n\\begin{lemma}\n  \\(s_\\alpha\\) is the reflection in the hyperplane orthogonal to \\(\\alpha\\). In particular \\(s_\\alpha \\alpha = -\\alpha\\) and all other eigenvectors of \\(s_\\alpha\\) have eigenvalue \\(1\\). Moreover\n  \\[\n    s_\\alpha^2 = 1, \\quad (s_\\alpha + 1)(s_\\alpha - 1) = 0\n  \\]\n  and \\(s_\\alpha \\in O(V, (\\cdot, \\cdot))\\), the orthogonal group of \\(V\\) with respect to \\((\\cdot, \\cdot)\\), which is in particular an algebraic group.\n\\end{lemma}\n\n\\begin{proof}\n  \\(V = \\R\\alpha \\oplus \\alpha^\\perp\\) and if \\(v \\in \\alpha^\\perp\\) then \\(s_\\alpha v = v\\).\n\\end{proof}\n\n\\begin{definition}[root system]\\index{root system}\n  A \\emph{root system} \\(R\\) in \\(V\\) is a finite set \\(R \\subseteq V\\) such that\n  \\begin{enumerate}\n  \\item \\(0 \\notin R, \\R R = V\\),\n  \\item for all \\(\\alpha, \\beta \\in R\\), \\((\\alpha, \\beta^\\vee) \\in \\Z\\),\n  \\item for all \\(\\alpha \\in R\\), \\(s_\\alpha R \\subseteq R\\). In particular \\(s_\\alpha \\alpha = -\\alpha \\in R\\).\n  \\end{enumerate}\n  Moreover \\(R\\) is \\emph{reduced} if in addition \\(\\alpha, k \\alpha \\in R\\) implies \\(k = \\pm 1\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(g\\) be a semisimple Lie algebra over \\(\\C\\). Then it has weight space decomposition \\(g = t \\oplus \\bigoplus_{\\alpha \\in R} g_\\alpha\\). Then \\(R\\) is a root system.\n\\end{eg}\n\n\\begin{definition}[Weyl group]\\index{Weyl group}\n  Let \\(W\\) be the group generated by the reflection \\(s_\\alpha\\) for \\(\\alpha \\in R\\). This is the \\emph{Weyl group of \\(R\\)}.\n\\end{definition}\n\nClaim that \\(W\\) is finite.\n\n\\begin{proof}\n  \\(W\\) acts on \\(R\\) by permutations and as \\(\\R R = V\\), this action is faithful (?), so \\(W \\subseteq \\operatorname{Sym}(R)\\) so finite.\n\\end{proof}\n\n\\begin{definition}\n  The \\emph{rank} of \\(R\\) is the dimension of \\(V\\).\n\\end{definition}\n\n\\begin{definition}\n  An isomorphism of root systems between \\((V, R)\\) and \\((V', R')\\) is a linear bijection \\(\\phi: V \\to V'\\) such that \\(\\phi(R) = R'\\).\n\\end{definition}\nNote that we do not require this to be an isometry.\n\n\\begin{ex}\n  If \\((R, V), (R', V')\\) are two root systems then so is \\((R \\amalg R', V \\oplus V')\\).\n\\end{ex}\n\nA root system not isomorphic to a direct sum is called \\emph{irreducible}.\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Rank 1: take \\(V = \\R, (x, y) = xy, R = \\{\\alpha, - \\alpha\\}\\) with \\(\\alpha \\in R, \\alpha \\neq 0\\). \\(W = \\Z/2\\). Exercise: this is the only rank \\(1\\) root system.\n  \\item rank 2\n    \\begin{enumerate}\n    \\item \\(V = \\R^2\\) with usual inner product is a root system. This is called \\(A_1 \\times A_1\\) and is not irreducible. \\(W = \\Z/2 \\times \\Z/2\\).\n    \\item \\((\\alpha, \\beta) = -1, \\alpha = \\alpha^\\vee, \\beta = \\beta^\\vee\\) . \\(W = S_3\\). This is the root system for \\(sl_3\\). This is \\(A_2\\).\n    \\item \\(B_2\\). \\(W = D_8\\).\n    \\item \\(\\alpha = e_1, \\beta = e_2 - e_1, (\\alpha, \\alpha) = 1, (\\beta, \\beta) = 1\\). This is \\(G_2\\).\n    \\end{enumerate}\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{ex}\\leavevmode\n  \\begin{enumerate}\n  \\item Show these are root systems.\n  \\item Show they are all the rank 2 root systems.\n  \\item Show \\(A_2, B_2, G_2\\) are irreducible.\n  \\end{enumerate}\n\\end{ex}\n\n\\begin{ex}\n  If \\((R, V)\\) is a root system then so is \\((R^\\vee, V)\\) where \\(R^\\vee = \\{\\alpha^\\vee: \\alpha \\in R\\}\\).\n\\end{ex}\n\n\\begin{definition}[simply laced]\\index{simply laced}\n  \\(R\\) is simply laced if all the roots have the samle length.\n\\end{definition}\n\n\\begin{ex}\n  If \\(R\\) is a simply laced root system then \\(R\\) is isomorphic to a root system with \\((\\alpha, \\alpha) = 2\\) for all \\(\\alpha \\in R\\).\n\\end{ex}\n\n\\begin{definition}[lattice]\\index{lattice}\\index{root}\n  A \\emph{lattice} \\(L\\) is a finitely generated free abelian group (i.e. isomoprhic to \\(\\Z^\\ell\\) for some \\(\\ell\\)) equipped with a form \\((\\cdot, \\cdot): L \\otimes L \\to \\Z\\) such that the induced form \\((\\cdot, \\cdot): L_\\R \\times L_\\R \\to \\R\\) is a positive definite symmetric bilinear form, where \\(L_\\R = L \\otimes_\\Z \\R \\cong \\R^\\ell\\).\n\n  A \\emph{root} of \\(L\\) is a vector \\(\\alpha \\in L\\) with \\((\\alpha, \\alpha) = 2\\). We denote the set of roots of \\(L\\) by \\(R_L\\).\n\\end{definition}\n\n\\begin{ex}\n  If \\(\\alpha \\in R_L\\) then \\(s_\\alpha(L) \\subseteq L\\).\n\\end{ex}\n\n\\begin{lemma}\n  \\(R_L\\) is a simply laced root system in \\(\\R R_L\\).\n\\end{lemma}\n\n\\begin{proof}\n  Obvious except finiteness of \\(R_L\\). But \\(R_L\\) is the intersection of a compact set (the sphere \\(\\{\\alpha \\in \\R L: (\\alpha, \\alpha) = 2\\}\\)) and a discrete set (\\(L\\)), so finite.\n\\end{proof}\n\n\\begin{definition}\n  \\(L\\) is \\emph{generated by roots} if \\(\\Z R_L = L\\).\n\\end{definition}\n\nNote if so, \\(L\\) is an ``even lattice'', i.e.\\ \\((\\ell, \\ell) \\in 2\\Z\\) for all \\(\\ell \\in L\\).\n\n\\begin{eg}\n  \\(L = \\Z \\alpha\\) with \\((\\alpha, \\alpha) = 2\\). If \\(\\lambda = 2\\) then \\(R_L = \\{\\pm \\alpha\\}\\) and \\(L = \\Z R_L\\). If \\(\\frac{k^2\\lambda}{2} \\neq 1\\) for all \\(k \\in \\Z\\) then \\(R_L = \\emptyset\\).\n\\end{eg}\n\nWe will now meet all simply laced lattices generated by roots.\n\\begin{enumerate}\n\\item \\(A_n\\) Consider \\(\\Z^{n + 1} = \\bigoplus_{i = 1}^{n + 1} \\Z e_i\\), \\((e_i, e_j) = \\delta_{ij}\\). This is the square lattice. Define\n  \\[\n    L = \\{\\ell \\in \\Z^{n + 1}: (\\ell, e_1 + \\dots + e_{n + 1}) = 0\\}\n    = \\{\\sum a_i e_i: \\sum a_i = 0\\} \\cong \\Z^n\n  \\]\n  then \\(R_L = \\{e_i - e_j: i \\neq j, \\# R_L = n(n + 1), \\Z R_L = L\\). If \\(\\alpha = e_i - e_j\\) then \\(s_\\alpha\\) waps \\(i\\)th and \\(j\\)th coordinate, i.e.\n  \\[\n    s_\\alpha(x_1e_1 + \\dots + x_{n + 1} e_{n + 1}) = x_1e_1 + \\dots + x_je_i + \\dots + x_ie_j + \\dots + x_{n + 1} e_{n + 1}\n  \\]\n  so \\(W = \\langle s_{e_i - e_j}: i \\neq j\\rangle \\cong S_{n + 1}\\).\n\n  \\((R_L, L)\\) is the root system of \\(\\Lie{sl}_{n + 1}\\).\n\n  \\begin{ex}\\leavevmode\n    \\begin{enumerate}\n    \\item Check all these statement, especially the one about root of \\(\\Lie{sl}_{n + 1}\\).\n    \\item Draw \\(L\\) and \\(R_L\\) for \\(n = 1, 2\\). Check \\(A_2, A_2\\) are as produced earlier.\n    \\end{enumerate}\n  \\end{ex}\n\\item \\(D_n\\). Consider the square lattice \\(\\Z^n\\) and define\n  \\begin{align*}\n    R_L &= \\{\\pm e_i \\pm e_j: i \\neq j\\} \\\\\n    L &= \\Z R_L = \\{\\sum a_i e_i: \\sum a_i \\text{ even}\\}\n  \\end{align*}\n  and \\(s_{e_i - e_j}\\) as before, and \\(s_{e_i + e_j}\\) flips signs of \\(i\\)th and \\(j\\)th coordinate. \\(\\# R_L = 2n(n + 1)\\). Then \\(W = (\\Z/2)^{n - 1} \\rtimes S_n\\).\n\n  \\begin{ex}\\leavevmode\n    \\begin{enumerate}\n    \\item Check all the claims.\n    \\item Show \\(D_n\\) is irreducible if \\(n \\geq 3\\).\n    \\item \\(D_3 \\cong A_3, D_2 \\cong A_1 \\times A_1\\).\n    \\item Roots of \\(\\Lie{so}_{2n}\\) are of type \\(D_n\\).\n    \\end{enumerate}\n  \\end{ex}\n\\item \\(E_8\\). Let\n  \\[\n    \\Gamma_n = \\{(k_1, \\dots, k_n): \\sum k_i \\in 2\\Z \\text{ and either } k_i \\in \\Z \\text{ or } k_i \\in \\Z + \\frac{1}{1} \\text{ for all } i\\}\n  \\]\n  with the usual inner product of \\(\\R^n\\). Consider \\(\\alpha = (\\frac{1}{2}, \\dots, \\frac{1}{2})\\). Note \\((\\alpha, \\alpha) = \\frac{n}{4}\\) so if \\(\\alpha \\in \\Gamma_n\\) and \\(\\Gamma_n\\) is an even lattice then \\(8 \\divides n\\).\n\n  \\begin{ex}\\leavevmode\n    \\begin{enumerate}\n    \\item Show \\(\\Gamma_{8n}\\) is an even lattice.\n    \\item If \\(n >1\\), roots of \\(\\Gamma_{8n}\\) are a root system of type \\(D_n\\).\n    \\item Show the roots of \\(\\Gamma_8\\) are \\(\\{\\pm e_i \\pm e_j: i \\neq j\\} \\cup \\{\\frac{1}{2}(\\pm e_i  \\pm \\dots \\pm e_8): \\text{ even number of minus signs}\\}\\). Roots of \\(\\Gamma_8\\) are called \\emph{root system of type \\(E_8\\)}. \\(\\# R_{E_8} = \\binom{8}{2} \\cdot 4 + 128 = 240\\), so by classification of semisimple Lie algebras the associated Lie algebra has dimension \\(248\\).\n    \\item Can you compute \\(\\# W_{E_8}\\)? The answer is \\(2^{14} \\cdot 3^5 \\cdot 5^2 \\cdot 7\\).\n    \\end{enumerate}\n  \\end{ex}\n\\end{enumerate}\n\n\\begin{ex}\n  If \\(R\\) is a root system, \\(\\alpha \\in R\\) then \\(\\alpha^\\perp \\cap R \\) is a root system.\n\\end{ex}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\printindex\n\\end{document}\n", "meta": {"hexsha": "ae343f951cbab04494fa224ed78ce0d2671edaa2", "size": 79663, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "III/lie_algebras_and_their_representations.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "III/lie_algebras_and_their_representations.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "III/lie_algebras_and_their_representations.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 48.6343101343, "max_line_length": 972, "alphanum_fraction": 0.6000025106, "num_tokens": 29075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040617, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.41389003112399364}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n\\newcommand{\\Gr}{\\opname{Gr}}\n\n\n\\title{Math 217 -- Geometry and Physics -- Lec13}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{31}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{More stuff}\n\nHirzebruch theorem, arguably most important in subject:\n\\begin{eqn}\n\\Omega^*_\\Q = \\Q[\\CP^2, \\CP^4, \\dots]\n\\end{eqn}\nand\n\\begin{eqn}\nL(\\CP^{2n}) = 1 = \\opname{sgn} M.\n\\end{eqn}\nThis implies that \n\\begin{eqn}\nL(M) = \\opname{sgn} M\n\\end{eqn}\nwhich is zero unless $M$ is $4k$-dimensional. Recall that for\n\\begin{eqn}\nQ(x) = \\frac{x/2}{\\sinh (x/2)},\n\\end{eqn}\nwe have\n\\begin{eqn}\nf(x) = 2 \\sinh (x/2)\n\\end{eqn}\nand\n\\begin{eqn}\nf'(x)^2 = 1 + \\frac{1}{4} f(x)^2, \\qquad g'(y) = (1 + \\frac{1}{4} y)^{-1/2}.\n\\end{eqn}\nWe find that \n\\begin{eqn}\n\\varphi(\\CP^n) = \\hat{A} (\\CP^n) = \n\\begin{cases}\n0 & \\text{$n$ odd} \\\\\n-1/8 & \\text{$n$ even}.\n\\end{cases}\n\\end{eqn}\nNote that $CP^{2k}$ is not a spin manifold. \n\nA hot topic for the last 20 or so years has been the following\n\\begin{example}\nSuppose $f(x)$ has derivative of the form\n\\begin{eqn}\nf'(x)^2 = 1 - 2 \\delta f^2 + \\epsilon f^4,\n\\end{eqn}\ni.e. \n\\begin{eqn}\ny^2 = 1 - 2 \\delta x^2 + \\epsilon x^4\n\\end{eqn}\nwhich is an elliptic curve. Then $Q(x) = x / f(x)$ is an elliptic genus. For example if $\\delta = 1$, $\\epsilon = 0$ [error, $\\delta$ does not match up], then we have\n\\begin{eqn}\nf'(x) = 1 - f^2\n\\end{eqn}\nso that $f(x) = \\tanh x$. If $\\epsilon = 0$, $\\delta = -1/8$, then we have\n\\begin{eqn}\nf'(x) = 1 + \\frac{1}{4} f^2,\n\\end{eqn}\nso that $f(x) = 2 \\sinh (x/2)$. As an exercise, find the elliptic genus $\\varphi_\\text{ell}(\\CP^n)$. \n\\end{example}\n\nThis implies that we have elliptic cohomology. Given $\\Omega_U^*$ we have a universal group loaw (Quiller). Given genus\n\\begin{eqn}\n\\varphi : \\Omega_U^* (p+) \\rightarrow R\n\\end{eqn}\nwhere $R$ is the coefficient ring of a cohomology. Then\n\\begin{eqn}\nH^* (M, R) \\cong \\Omega^*_U (M) \\oplus_{\\Omega^*_U (p+)} R.\n\\end{eqn}\n\nWe can consider analogous geometric constructions\n\\begin{itemize}\n\\item Cohomology --- singular cycles, $H^*_\\text{dR}$ differential forms.\n\\item $K$-theory --- Bundles\n\\item Cobordism manifolds --- [?]\n\\item ? Elliptic cohomology --- \n\\begin{eqn}\nEll^*(M) = \\Omega_U^* (M) \\oplus_{\\omega^*_U} R \\qquad \\implies \\qquad R = \\Z [\\frac{1}{2}, \\epsilon, \\delta]\n\\end{eqn}\nwhere \n\\begin{eqn}\n\\varphi(M^{2k}) = \\int_M \\prod_{j=1}^n Q(x_j).\n\\end{eqn}\n\\end{itemize}\n\n\n\\section{Elliptic operators}\n\n\\begin{definition}\nConsider two complex vector bundles $E,F \\rightarrow M$ on a smooth closed orientable manifold $M$. Given smooth sections $\\Gamma(E), \\Gamma(F)$ a map\n\\begin{eqn}\nD : \\Gamma(E) \\rightarrow \\Gamma(F)\n\\end{eqn}\nis called a differential operator on $U \\subseteq M$ iff $D$ can be written\n\\begin{eqn}\nDf = g.\n\\end{eqn}\nIf we write $f = (f_1, \\dots, f_m)^\\top$ and $g = (g_1, \\dots, g_n)^\\top$ then we can write $D$ as a matrix\n\\begin{eqn}\nD_{ij} = \\sum_I a^I_{ij} \\pd[I]{}{x}, \\qquad I = (i_1, \\dots, i_n).\n\\end{eqn}\n\\end{definition}\n\n\\begin{definition}\nWe define the order $p$ of $D$ as the highest degree of the derivatives in $D$, and the symbol $\\sigma(D)$ of $D$ is a function\n\\begin{eqn}\n\\sigma(D) = \\sigma^{(p)} (D) : \\pi^* E \\rightarrow \\pi^* F\n\\end{eqn}\ndefined by\n\\begin{eqn}\n\\sigma(D) (x,v) e = D \\left( \\frac{i^p}{p!} ((h - h(x))^p f) \\right) (x)\n\\end{eqn}\nwhere $e = f(x)$ and $f \\in \\Gamma(E)$. \n\\end{definition}\n\n\\begin{example}\nConsider $M = \\R^k / L$ where $L \\subset \\R^k$ (a lattice of rank $k$). Given \n\\begin{eqn}\nE = F = \\C \\times M \\qquad \\implies \\Gamma(E) = \\Gamma(F) = C^\\infty (M),\n\\end{eqn}\nwe have\n\\begin{eqn}\nD = \\Delta = \\sum_{i=1}^k \\pd[2]{}{x_i}.\n\\end{eqn}\nThen given\n\\begin{eqn}\nv = \\sum_{i=1}^k v_i \\dif{x_i} \\in T_x^* M,\n\\end{eqn}\nwe have\n\\begin{eqn}\n\\sigma(D) = \\sigma^{(2)} (x,v) = -\\sum_{i=1}^k v_i^2.\n\\end{eqn}\n\\end{example}\n\n\\begin{definition}\n$D$ is called elliptic iff $\\sigma(D)$ is an isomorphism for all $v \\neq 0$.\n\\end{definition}\n\nOne can show that if $D$ is elliptic then \n\\begin{eqn}\n\\ker D \\subseteq \\Gamma(E), \\qquad \\opname{coker} D = \\Gamma(F) / \\Im D.\n\\end{eqn}\nare finite dimensional spaces.\n\n\\begin{definition}\nThe index $\\opname{Ind} D$ of $D$ is defined by\n\\begin{eqn}\n\\opname{Ind} D = \\dim_\\C \\ker D - \\dim \\opname{coker} D.\n\\end{eqn}\n\\end{definition}\n\nSo if $D$ is elliptic then $\\sigma(D)$ defines an element \n\\begin{eqn}\n\\eta_D = (\\pi^* E, \\pi^* F, \\sigma(D)) \\in K(T^* M, T^* M - \\set{0}).\n\\end{eqn}\n\n\\begin{remark}\n\\begin{eqn}\nK(T^* M, T^* M - \\set{0}) \\cong K(M).\n\\end{eqn}\nGiven \n\\begin{eqn}\nf : M \\rightarrow p+\n\\end{eqn}\nso\n\\begin{eqn}\n\\begin{matrix}\nf_! & : & K(M) & \\rightarrow & K(p+) \\cong \\Z \\\\\n& & \\eta_D & \\mapsto & f_! \\eta_D.\n\\end{matrix}\n\\end{eqn}\nAtiyah-Singer showed\n\\begin{eqn}\n\\opname{Ind} D = \\opname{ch} f_! \\eta_D = \\int_M (\\text{char. classes})\n\\end{eqn}\nthe last equality by topological RR. \n\\end{remark}\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "63056dedf960c99da6d13157cbfd0291b73a089a", "size": 5162, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geometry/lec13.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "geometry/lec13.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geometry/lec13.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9396984925, "max_line_length": 166, "alphanum_fraction": 0.6344440139, "num_tokens": 2078, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.4138900258037189}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{bssn-eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.62.044034 equation (10)}\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'bssn-eqtns-10.json'\n   cdblib.create (jsonfile)\n\n   # --------------------------------------------------------------------------\n\n   DphiDt  := \\partial_{t}{\\phi}.                # cdb(eq10.00,DphiDt)\n   DphiDt  := -(1/6) N trK.                      # cdb(eq10.01,DphiDt)\n\n   canonicalise (DphiDt)                         # cdb(eq10.02,DphiDt)  # no change\n                                                 # cdb(eq10.99,DphiDt)  # no change\n\n   cdblib.put ('DphiDt',DphiDt,jsonfile)\n\\end{cadabra}\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb{eq10.00} = \\Cdb*{eq10.02}\\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "aed2d683ddb2c796d65ed4269abdcb9368277573", "size": 797, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "bssn/cadabra/bssn-eqtns-10.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-numerical", "max_stars_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-25T11:36:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T11:36:06.000Z", "max_issues_repo_path": "bssn/cadabra/bssn-eqtns-10.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-numerical", "max_issues_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bssn/cadabra/bssn-eqtns-10.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-numerical", "max_forks_repo_head_hexsha": "9e32c201272e9a41e7535475fe381e450b99b058", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7096774194, "max_line_length": 83, "alphanum_fraction": 0.5056461731, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.41389002233737104}}
{"text": "\\subsection{The course of the signal accumulation}\n\nA Raman spectrum is usually acquired as a consecutive series of spectra,\nfurther called \\emph{frames}, taken at the same experimental conditions and\nwith the constant accumulation time.\nThis approach has many reasons.\nAmongst the most important is that measurement of Raman spectra requires highly\nsensitive detectors which means that detector saturation can be easily reached\nwith a stronger signal.\n\nSecondly, such sensitive detectors are susceptible to cosmic ray artifacts,\nwhich can significantly damage the spectra, see\n\\cref{subsec:spike_removal}.\nIt is easier to subtract the cosmic ray signal in the series of spectra taken\nwith the same measurement condition than from a single spectrum because the\nsubsequent spectra should be almost identical, and the average of the\nsurrounding spectra can replace the spectral regions with cosmic ray signal.\n\nFurthermore, other temporal effects can affect the spectra, like slight\ntemperature variations, mechanical movements etc.\n\nRRS is also affected by photodecomposition and an increasing presence of\nphotoproducts which can directly or indirectly influence the measured spectra.\nThe direct presence of a signal of photoproducts in the detected spectra is\nusually negligible because Raman scattering of the photoproducts is not usually\nresonantly enhanced.\nHowever, indirect effects through chemical interactions of photo products with\nthe system under investigation are always possible.\n\nSo, measurement of more frames with a shorter accumulation time would be\nfavored for better monitoring of all these processes during the accumulation of\nthe spectrum.\n\nHowever, there are also opposite effects that support longer measurements.\nThe most dominant is the ratio between the signal from the sample and noise.\nThe noise in the spectra can have many origins, but dominant are those\nconnected with acquiring the signal on the CCD detector.\nThe first one is low-frequency (almost constant) background which is usually\nused in SNR calculation.\nBest results with the most linear response to the intensity of the gathered\nlight are achieved with a signal in the range $\\approx 10 -- 80\\,\\%$ of the\nmaximal signal limit.\nThe second component is high-frequency noise which lowers the quality of the\nspectra, reliability of the band position detection, or can even hide some\nspectral features completely.\n\nWe tried to estimate some guiding principles about a balance between a number\nof frames and an accumulation time.\nWe measured the background spectrum of deionized water with high laser power\n(100\\,mW), which meant short accumulation times (5\\,s) taken in 100 frames.\nAll these frames were then averaged to obtain one high quality Raman spectrum\nof water $I_\\text{water}(\\wn)$ as a reference.\nThen we measured the same water with 1\\,mW excitation in 30 frames with 20\\,s\naccumulation time and 10 frames with 60\\,s accumulation time which are\nparameters of our typical RRS measurement. We summed all the frames to obtain a\nsingle Raman spectrum $I_{20}(\\wn)$ and $I_{60}(\\wn)$, so both of them\nrepresented 10 min total accumulation.\n\nWe decided to assess the SNR to estimate the quality of the measured spectra.\nThe noise height was estimated by a fit of the high-quality water spectrum\n$I_\\text{water}(\\wn)$ plus constant background, which resulted in the model\nintensity function\n\\begin{equation}\n\tI_\\text{model}(\\wn) = a_0 I_\\text{water}(\\wn) + a_1.\n\t\\label{\\eqnlabel{accum_length:sn_model}}\n\\end{equation}\nAn example fit can be seen in\n\\figref{accum_length:sn_ratio}.\n\n\\begin{figure}\n\t\\centering\n\t\\input{results_and_discussion/assets/sn_ratio/sn_ratio}\n\t\\caption[%\n\t\tSignal-to-noise ratio calculation from a fit of the high-quality spectrum\n\t\tand constant background addition.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tSignal-to-noise ratio calculation from a fit of the high-quality spectrum\n\t\t\tand constant background addition.%\n\t\t}\n\t\tThe original \\emph{spectrum} (here, we are using the spectrum $I_{20}(\\wn)$\n\t\twith 20\\,s accumulation time) was modeled by \\emph{model}\n\t\t\\eqnref{accum_length:sn_model}.\n\t\tThe spectra on the image were then normalized to the \\emph{constant} $a_1$.\n\t}\n\t\\label{\\figlabel{accum_length:sn_ratio}}\n\\end{figure}\n\nThe low-frequency SNR was then estimated as\n\\begin{equation*}\n\tSNR_\\text{low} = \\frac{I_\\text{model}(1637)}{a_1},\n\\end{equation*}\nwhich leads to\n\\begin{align*}\n\tSNR_{\\text{low},20} &= 1.3841 \\pm 0.0004, \\\\\n\tSNR_{\\text{low},60} &= 2.6112 \\pm 0.0026,\n\\end{align*}\n\nWe also estimated the high-frequency noise.\nWe subtracted the constant $a_1$ from the measured spectra and normalized them\nto the maximum of the $I_\\text{model}(1637\\,\\text{cm}^{-1})$ to compare the\nnoise size to the size of this band.\nWe then calculated spectrum $I_\\text{SG}$ smoothed by Savitzky-Golay filter\n\\parencite{Savitzky1964},\nsee\n\\figref{accum_length:sn_ratio_sg}.\n\n\\begin{figure}\n\t\\centering\n\t\\input{results_and_discussion/assets/sn_ratio/sn_ratio_sg}\n\t\\caption[%\n\t\tSignal-to-noise ratio calculation using standard deviation from the\n\t  spectrum smoothed by the Savitzky-Golay filter.\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tSignal-to-noise ratio calculation using standard deviation from the\n\t\t\tspectrum smoothed by the Savitzky-Golay filter.\n\t\t}\n\t\tThe spectrum is normalized to the water band at 1637\\,\\icm{}.\n\t\tThe figure shows the original \\emph{spectrum} and the spectrum smoothed by\n\t\tthe Savitzky-Golay filter (\\emph{SG filter}).\n\t}\n\t\\label{\\figlabel{accum_length:sn_ratio_sg}}\n\\end{figure}\n\nFinally, we estimated the high-frequency $SNR_\\text{high}$ from the standard\ndeviation $\\sigma$ of the original spectrum from the smoothed spectrum\nnormalized to the intensity of the water band at 1637\\,\\icm{} (which means that\nthe normalized intensity maximum at 1637\\,\\icm{} is equal to 1),\n\\begin{equation*}\n\tSNR_\\text{high} = \\frac{1}{\\sigma},\n\\end{equation*}\n\\begin{align*}\n\tSNR_{\\text{high},20} &= 240, \\\\\n\tSNR_{\\text{high},60} &= 297.\n\\end{align*}\n\nIt can be seen that longer single-frame accumulation times give better quality\nspectra in these experimental conditions.\nThe difference is larger in the low-frequency SNR even though the\nhigh-frequency SNR difference is also significant.\nRegarding the disadvantages of the\nlonger accumulation discussed at the beginning of this section and the speed of\nthe sample degradation with lifetimes in the range of minutes, we decided that\nthe optimal accumulation time is 60\\,s.\n", "meta": {"hexsha": "bc03b7eab0cd919111402e721abef4f66c95b52a", "size": 6420, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/results_and_discussion/length_of_accumulation.tex", "max_stars_repo_name": "lumik/phd_thesis", "max_stars_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/results_and_discussion/length_of_accumulation.tex", "max_issues_repo_name": "lumik/phd_thesis", "max_issues_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 41, "max_issues_repo_issues_event_min_datetime": "2019-08-13T12:27:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T03:00:58.000Z", "max_forks_repo_path": "src/results_and_discussion/length_of_accumulation.tex", "max_forks_repo_name": "lumik/phd_thesis", "max_forks_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9726027397, "max_line_length": 79, "alphanum_fraction": 0.7855140187, "num_tokens": 1603, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.41389002171939554}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\n\\section{Z Notation Introduction}\n\nThe following subsections provide a high level overview of select properties of Z Notation based on\n\"The Z Notation: A Reference Manual\" by J. M. Spivey. A copy\nof this reference manual can be found at dave/docs/z/Z-notation reference manual.pdf.\nIn many cases, definitions will be pulled directly from the reference manual and when this occurs,\nthe relevant page number(s) will be included. For a proper introduction with tutorial examples, see\nchapter 1, \"Tutorial Introduction\" from pages 1 to 23. For the $LaTeX$ symbols used to write Z,\nsee the reference document found at dave/docs/z/zed-csp-documentation.pdf.\n\n\\subsection{Decorations}\nThe following decorations are used throughout this document and are taken directly from the reference manual.\nFor a complete summary of the Syntax of Z, see chapter 6, Syntax Summary, starting on page 142.\n\\begin{argue}\n  ' & indicates final state of an operation \\\\\n  ? & indicates input to an operation \\\\\n  ! & indicates output of an operation \\\\\n  \\Delta & indicates the schema results in a change to the state space \\\\\n  \\Xi & indicates the schema does not result in a change to the state space \\\\\n  \\pipe & indicates output of the left schema is input to the right schema\n\\end{argue}\n\n\\subsection{Types}\nObjects have a type which characterizes them and distinguish them from other kinds of objects.\n\\begin{itemize}\n\\item Basic types are sets of objects which have no internal structure of interest meaning the concrete definition of the members is not relevant, only their shared type.\n\\item Free types are used to describe (potentially nested and/or recursive) sets of objects. In the most simple case, a free type can be an enumeration of constants.\n\\end{itemize}\nWithin the xAPI Formal Specification, both of these types are used to describe the\n\\href{https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#inversefunctional}{Inverse Functional Identifier}\nproperty.\n\\begin{itemize}\n\\item Introduction of the basic types $MBOX$, $MBOX\\_SHA1SUM$, $OPENID$ and $ACCOUNT$\n  allows the specification to talk about these constraints within the xAPI\n  specification without defining their exact structure\n\\item The free type $IFI$ is defined as one of the above basic types meaning an object\n  of type $IFI$ is of type $MBOX$ or $MBOX\\_SHA1SUM$ or $OPENID$ or $ACCOUNT$.\n\\end{itemize}\nTypes can be composed together to form composite types and thus complex objects.\n\\begin{zed}\n  [MBOX, MBOX\\_SHA1SUM, OPENID, ACCOUNT]\n  \\also\n  IFI ::= MBOX \\,|\\, MBOX\\_SHA1SUM \\,|\\, OPENID \\,|\\, ACCOUNT\n\\end{zed}\nWithin the xAPI Formal Specification, $IFI$ is used within the definition\nof an $agent$ as presented in the schema $Agent$.\n\n\\begin{schema}{Agent}\n  agent : AGENT \\\\\n  objectType : OBJECTTYPE \\\\\n  name : \\finset_1 \\#1 \\\\\n  ifi : IFI\n  \\where\n  objectType = Agent \\\\\n  agent = \\{ifi\\} \\cup \\power \\{name, objectType\\}\n\\end{schema}\nSee section 2.2, pages 28 to 34, and chapter 3, pages 42 to 85, for more information about Schemas and the Z Language.\n\n\\subsection{Sets}\nA collection of elements that all share a type. A set is characterized solely by which objects are members and which are not.\nBoth the order and repetition of objects are ignored. Sets are written in one of two ways:\n\\begin{itemize}\n\\item listing their elements\n\\item by a property which is characteristic of the elements of the set.\n\\end{itemize}\nsuch that the following law from page 55 holds for some object y\n$$y \\in \\{x_{1},...,x_{n}\\} \\iff y = x_{1} \\lor ... \\lor y = x_{n}$$\n\n\\subsection{Ordered Pairs}\nTwo objects $(x, y)$ where $x$ is paired with $y$. An n-tuple is\nthe pairing of n objects together such that equality between two n-tuple pairs\nis given by the law from page 55\n$$(x_{1},...,x_{n}) = (y_{1},...,y_{n}) \\iff x_{1} = y_{1} \\land ... \\land x_{n} = y_{n}$$\nWhen ordered pairs are used with respect to application (as seen on page 60)\n$$f x \\implies f(x) \\iff (x,y) \\in f$$\nwhich states that $f(x)$ is defined if and only if there is a unique value $y$ which result from $f x$\nAdditionally, application associates to the left\n$$f x y \\implies (f x) y \\implies (f(x), y)$$\nmeaning $f(x)$ results in a function which is then applied to $y$.\n\n\\subsection{Sequences}\nA collection of elements where their ordering matters such that\n$$\\langle a_{1},...,a_{n} \\rangle \\implies \\{1 \\mapsto a_{1}, ..., n \\mapsto a_{n}\\}$$\nas seen on page 115. Additionally, $\\iseq$ is used to describe a sequence whose members are distinct.\n\n\\subsection{Bags}\nA collection of elements where the number of times an element appears in the collection is meaningful.\n$$\\lbag a_{1},...,a_{n} \\rbag \\implies \\{a_{1} \\mapsto k_{1},...,k_{n} \\mapsto k_{n}\\}$$\nAs described on page 124, each element $a_{i}$ appears $k_{i}$ times in the list $a_{1},...,a_{n}$\nsuch that the number of occurrences of $a_{i}$ within bag $A$ is returned by\n$$count ~A ~a_{i} \\ \\equiv A ~\\# ~a_{i}$$\n\n\\subsection{Maps}\nThis document introduces a named subcategory of sets, $map$ of the free type $KV$,\nwhich are akin to sequences and bags. To enumerate the members of a $map$, $\\ldata ... \\rdata$ is used\nbut should not be confused with $d_{i}\\ldata E_{i}[T]\\rdata$ within a Free Type definition. The\ndistinction between the two usages is context dependent but in general, if $\\ldata ... \\rdata$\nis used outside of a constructor declaration within a Free Type definition,\nit should be assumed to represent a $map$.\n$$KV ::= base ~| ~associate\\ldata KV \\cross X \\cross Y \\rdata$$\nwhere\n\\begin{argue}\n  base & is a constant which is the empty $KV \\implies \\ldata \\rdata$ \\\\\n  associate & is a constructor and is inferred to be an injection\n\\end{argue}\nThe full enumeration of all properties, constraints and functions\nspecific to a $map$ with type $KV$ will be defined elsewhere but\n$associate$ can be understood to (in the most basic case) operate as follows.\n$$associate(base, x_{i}, y_{i}) = \\ldata (x_{i}, y_{i}) \\rdata \\implies \\ldata x_{i} \\mapsto y_{i} \\rdata$$\nThe enumeration of a $map$ was chosen to be $\\ldata ... \\rdata$ as a $map$ is a collection of injections\nsuch that if $M$ is the result of $associate(base, x_{i}, y_{i})$ from above then\n$$atKey(M, x_{i}) = y_{i} \\iff x_{i} \\mapsto y_{i} ~\\land (x_{i}, y_{i}) \\in M$$\n\n\\subsection{Select Operations and Symbols}\nThe follow are defined in Chapter 4 (The Mathematical Tool-kit) within the reference manual\nand are used extensively throughout this document. In many cases, the functions listed here\nwill serve as Operations in the context of Primitives and Algorithms.\n\n\\subsubsection{Functions}\n\\begin{argue}\n  \\pfun & relate each x $\\in$ X to at most one y $\\in$ Y, page 105 \\\\\n  \\fun & relate each x $\\in$ X to exactly one y $\\in$ Y, page 105 \\\\\n  \\pinj & map different elements of x to different y, page 105 \\\\\n  \\inj & $\\pinj$ that are also $\\fun$, page 105 \\\\\n  \\psurj & $X \\pfun Y$ where whole of Y is the range, page 105 \\\\\n  \\surj & $X \\pfun Y$ whole of X as domain and whole of Y as range, page 105 \\\\\n  \\bij & map x $\\in$ X one-to-one with y $\\in$ Y, page 105\n\\end{argue}\n\\begin{zed}\n  X \\pfun Y == \\{~f : X \\rel Y ~| ~(\\forall x : X; y1, y2 : Y @ \\\\\n  \\t5 (x \\mapsto y_{1} \\in f \\ \\land \\ (x \\mapsto y_{2}) \\in f \\implies y_{1} = y_{2}))\\} \\\\\n  X \\fun Y == \\{~f : X \\pfun Y ~| ~\\dom f = X\\} \\\\\n  X \\pinj Y == \\{~f : X \\pfun Y ~| ~(\\forall x_{1}, x_{2} : \\dom f @ f(x_{1}) = f(x_{2}) \\implies x_{1} = x_{2})\\} \\\\\n  X \\inj Y == (X \\pinj Y) \\cap (X \\fun Y) \\\\\n  X \\psurj Y == \\{~f : X \\pinj Y ~| ~\\ran f = Y\\} \\\\\n  X \\surj Y == (X \\psurj Y) \\cap (X \\fun Y) \\\\\n  X \\bij Y == (X \\surj Y) \\cap (X \\inj Y)\n\\end{zed}\n\n\\subsubsection{Ordered Pairs, Maplet and Composition of Relations}\n\\begin{argue}\n  first & returns the first element of an ordered pair, page 93 \\\\\n  second & returns the second element of an ordered pair, page 93 \\\\\n  \\mapsto & maplet is a graphic way of expressing an ordered pair, page 95 \\\\\n  \\dom & set of all x $\\in$ X related to at least one y $\\in$ Y by R, page 96 \\\\\n  \\ran & set of all y $\\in$ Y related to at least one x $\\in$ X by R, page 96 \\\\\n  \\comp & The composition of two relationships, page 97 \\\\\n  \\circ & The backward composition of two relationships, page 97\n\\end{argue}\n\n\\begin{gendef}[X,Y]\n  first: X \\cross Y \\fun X \\\\\n  second: X \\cross Y \\fun Y\n  \\where\n  \\forall x: X; y: Y @ \\\\\n  \\t1 first(x,y) = x \\ \\land \\\\\n  \\t1 second(x,y) = y\n\\end{gendef}\n\n\\begin{gendef}[X,Y]\n  \\_\\mapsto\\_: X \\cross Y \\fun X \\cross Y\n  \\where\n  \\forall x:X; y:Y @ \\\\\n  x \\mapsto y = (x, y)\n\\end{gendef}\n\n\\begin{gendef}[X,Y]\n  \\dom : (X \\rel Y) \\fun \\power X \\\\\n  \\ran : (X \\rel Y) \\fun \\power Y\n  \\where\n  \\forall R : X \\rel Y @ \\\\\n  \\t1 \\dom R = \\{~x : X; ~y : Y ~| ~x \\underline{R} y @ x\\} ~\\land \\\\\n  \\t1 \\ran R = \\{~x : X; ~y : Y ~| ~x \\underline{R} y @ y\\}\n\\end{gendef}\n\n\\begin{gendef}[X,Y,Z]\n  \\_\\comp\\_: (X \\rel Y) \\cross (Y \\rel Z) \\fun (X \\rel Z) \\\\\n  \\_\\circ\\_: (Y \\rel X) \\cross (X \\rel Y) \\fun (X \\rel X)\n  \\where\n  \\forall ~Q : X \\rel Y; R : Y \\rel Z @ \\\\\n  \\t1 Q \\comp R = R \\circ Q = \\{~x : X; y : Y; z : Z | \\\\\n  \\t5  x ~\\underline{Q} ~y \\ \\land \\ y ~\\underline{R} ~z @ x \\mapsto z\\}\n\\end{gendef}\n\n\\subsubsection{Numeric}\n\n\\begin{argue}\n  succ & the next natural number, page 109\\\\\n  .. & set of integers within a range, page 109 \\\\\n  \\# & number of members of a set, page 111 \\\\\n  \\min & smallest number in a set of numbers, page 113 \\\\\n  \\max & largest number in a set of numbers, page 113\n\\end{argue}\n\n\\begin{axdef}\n  succ : \\nat \\fun \\nat \\\\\n  \\_~..~\\_ : \\num \\cross \\num \\fun \\power \\num\n  \\where\n  \\forall n : \\nat @ succ(n) = n + 1 \\\\\n  forall a,b : \\num @ \\\\\n  \\t2 a~..~b = \\{~k : \\num ~| ~a \\leq k \\leq b\\}\n\\end{axdef}\n\n\\begin{gendef}[X]\n  \\# : \\finset X \\fun \\nat\n  \\where\n  \\forall S : \\finset X @ \\\\\n  \\t1 \\#S = (\\mu ~n : \\nat ~| ~(\\exists f : 1~..~n \\inj X @ \\ran f = S))\n\\end{gendef}\n\n\\begin{axdef}\n  \\min : \\power_1 \\num \\pfun \\num \\\\\n  \\max : \\power_1 \\num \\pfun \\num\n  \\where\n  \\min = \\{~S : \\power_1 \\num; m : \\num ~| \\\\\n  \\t2 m \\in S ~\\land ~(\\forall n : S @ m \\leq n) @ S \\mapsto m\\} \\\\\n  \\max = \\{~S : \\power_1 \\num; m : \\num ~| \\\\\n  \\t2 m \\in S ~\\land ~(\\forall n : S @ m \\geq n) @ S \\mapsto m\\}\n\\end{axdef}\n\n\\subsubsection{Sequences}\n\\begin{argue}\n  \\cat & concatenation of two sequences, page 116 \\\\\n  rev & reverse a sequence, page 116 \\\\\n  head & first element of a sequence, page 117 \\\\\n  last & last element of a sequence, page 117 \\\\\n  tail & all elements of a sequence except for the first, page 117 \\\\\n  front & all elements of a sequence except for the last, page 117 \\\\\n  \\extract & sub seq based on provided indices, order maintained, page 118\\\\\n  \\filter & sub seq based on provided condition, order maintained, page 118 \\\\\n  squash & compacts a fn of positive integers into a sequence, page 118 \\\\\n  \\dcat & flatten seq of seqs into single seq, page 121 \\\\\n  \\disjoint & pairs of sets in family have empty intersection, page 122 \\\\\n  \\partition & union of all pairs of sets = the family set, page 122\n\\end{argue}\n\n\\begin{gendef}[X]\n  \\_~\\cat~\\_ : \\seq X \\cross \\seq X \\fun \\seq X \\\\\n  rev : \\seq X \\fun \\seq X\n  \\where\n  \\forall s, t : \\seq X @ \\\\\n  \\t1 s \\cat t = s \\cup \\{~n : \\dom t @ n + \\# s \\mapsto t(n)\\} \\\\\n  \\forall s : \\seq X @ \\\\\n  \\t1 rev s = (\\lambda ~n : \\dom s @ s(\\#s - n + 1))\n\\end{gendef}\n\n\\begin{gendef}[X]\n  head, last : \\seq_1 X \\fun X \\\\\n  tail, front : \\seq_1 X \\fun \\seq X\n  \\where\n  \\forall s : \\seq_1 X @ \\\\\n  \\t1 head ~s = s(1) ~\\land \\\\\n  \\t1 last ~s = s(\\#s) ~\\land \\\\\n  \\t1 tail ~s = (\\lambda ~n : 1 ~..~\\#s - 1 @ s(n + 1)) ~\\land \\\\\n  \\t1 front ~s = (1~..~\\#s - 1) \\dres s\n\\end{gendef}\n\n\\begin{gendef}[X]\n  \\_~\\extract~\\_ : \\power \\nat_1 \\cross \\seq X \\fun \\seq X \\\\\n  \\_~\\filter~\\_ : \\seq X \\cross \\power X \\fun \\seq X \\\\\n  squash : (\\nat_1 \\pfun X) \\fun \\seq X\n  \\where\n  \\forall U : \\power \\nat_1; s : \\seq X @ \\\\\n  \\t1 U \\extract s = squash(U \\dres s) \\\\\n  \\forall s : \\seq X; V : \\power X @ \\\\\n  \\t1 s \\filter V = squash(s \\rres V) \\\\\n  \\forall f : \\nat_1 \\pfun X @ \\\\\n  \\t1 squash f = f ~ \\circ ~(\\mu ~p : 1~..~\\# f \\bij \\dom f ~| ~p \\circ succ \\circ p \\inv \\subseteq (\\_ ~< ~\\_))\n\\end{gendef}\n\n\\begin{gendef}[X]\n  \\dcat : \\seq(\\seq X) \\fun \\seq X\n  \\where\n  \\dcat \\langle \\rangle = \\langle  \\rangle \\\\\n  \\forall s : \\seq X @ \\dcat \\langle s \\rangle = s \\\\\n  \\forall q,r : \\seq(\\seq X) @ \\\\\n  \\t1 \\dcat (q \\cat r) = (\\dcat q) \\cat (\\dcat r)\n\\end{gendef}\n\n\\begin{gendef}[I,X]\n  \\disjoint ~\\_ : \\power (I \\pfun \\power X) \\\\\n  ~\\_ ~\\partition ~\\_ : (I \\pfun \\power X) \\rel \\power X\n  \\where\n  \\forall S : I \\pfun \\power X; T : \\power X @ \\\\\n  \\t1 (\\disjoint S \\iff \\\\\n  \\t2 (\\forall i,j : \\dom S ~| ~i \\not= j @ S(i) \\cap S(j) = \\emptyset))~ \\land \\\\\n  \\t1 (S \\partition T \\iff \\\\\n  \\t2 \\disjoint S ~ \\land ~ \\bigcup \\{~i : \\dom S @ S(i)\\} = T)\n\\end{gendef}\n\n\\subsubsection{Bags}\n\n\\begin{argue}\n  count, \\# & the number of times something appears in a bag, page 124 \\\\\n  \\otimes & scaling across a bag, page 124 \\\\\n  \\uplus & union of two bags, sum of occurrences, page 126 \\\\\n  \\uminus & bag difference, subtract occurrences or zero if negative, page 126 \\\\\n  items & conversion from $\\seq$ to $\\bag$, page 127\n\\end{argue}\n\n\\begin{gendef}[X]\n  count : \\bag X \\bij (X \\fun \\nat) \\\\\n  \\_ ~ \\# ~ \\_ : \\bag X \\cross X \\fun \\nat \\\\\n  \\_ ~ \\otimes ~\\_ : \\nat \\cross \\bag X \\fun \\bag X\n  \\where\n  \\forall B : \\bag X @ \\\\\n  \\t1 count B = (\\lambda x : X @ 0) \\oplus B \\\\\n  \\forall x : X; B : \\bag x @ \\\\\n  \\t1 B ~\\# ~x = count ~B ~x \\\\\n  \\forall n : \\nat ; B : \\bag X; x : X @ \\\\\n  \\t1 (n \\otimes B) ~\\# ~x = n * (B ~\\# ~x)\n\\end{gendef}\n\n\\begin{gendef}[X]\n  \\_ ~\\uplus ~\\_ ~, ~\\_ ~ \\uminus ~\\_ : \\bag X \\cross \\bag X \\fun \\bag X\n  \\where\n  \\forall B ~, ~C : \\bag X; x : X @ \\\\\n  \\t1 (B ~ \\uplus ~C) ~\\# ~x = B ~ \\# ~ x + C ~ \\# x ~ \\land \\\\\n  \\t1 (B ~ \\uminus ~C) ~\\# ~ x = \\max \\{B ~\\# x ~- ~C ~\\# ~x, 0\\}\n\\end{gendef}\n\n\\begin{gendef}[X]\n  items : \\seq X \\fun \\bag X\n  \\where\n  \\forall s : \\seq X; x : X @ \\\\\n  \\t1 (items ~s) ~\\# ~x = \\#\\{~i : \\dom s ~| ~s(i) = x\\}\n\\end{gendef}\n\n\\end{document}\n", "meta": {"hexsha": "55b0a018bc408bebb4dab99d283e60c62af3552b", "size": 14039, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/z/introduction.tex", "max_stars_repo_name": "yetanalytics/dave", "max_stars_repo_head_hexsha": "7a71c2017889862b2fb567edc8196b4382d01beb", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2018-08-17T00:38:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-09T02:32:37.000Z", "max_issues_repo_path": "docs/z/introduction.tex", "max_issues_repo_name": "adlnet/dave", "max_issues_repo_head_hexsha": "9339713fac747118e462e4fc7e1ecd54e5d916e3", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 95, "max_issues_repo_issues_event_min_datetime": "2018-08-31T18:57:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-15T16:40:01.000Z", "max_forks_repo_path": "docs/z/introduction.tex", "max_forks_repo_name": "yetanalytics/dave", "max_forks_repo_head_hexsha": "7a71c2017889862b2fb567edc8196b4382d01beb", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-09-28T06:48:47.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-31T16:20:47.000Z", "avg_line_length": 42.0329341317, "max_line_length": 170, "alphanum_fraction": 0.6350879692, "num_tokens": 4834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.41389001763507205}}
{"text": "\\section{Sybil Resilience}\n  One of our aims is to mitigate Sybil attacks \\cite{sybilattack} whilst maintaining decentralized autonomy \\cite{dionyziz}.\n  We begin by extending the definition of indirect trust.\n  \\subimport{common/definitions/}{indirecttrustmultiplayer.tex}\n  \\noindent We now extend the Trust Flow theorem to many players.\n  \\subimport{common/theorems/}{multiplayertrustflowtheorem.tex}\n  \\subimport{common/proofs/}{multiplayertrustflowproof.tex}\n  \\noindent We now define several useful notions to tackle the problem of Sybil attacks. Let Eve be a possible attacker.\n  \\subimport{common/definitions/}{corrupted.tex}\n  \\subimport{common/definitions/}{sybil.tex}\n  \\subimport{common/definitions/}{collusion.tex}\n  \\subimport{common/figures/}{collusion.tikz}\n  From a game theoretic point of view, players $\\mathcal{V} \\setminus (\\mathcal{B} \\cup \\mathcal{C})$ perceive the collusion\n  as independent players with a distinct strategy each, whereas in reality they are all subject to a single strategy dictated\n  by Eve.\n  \\subimport{fc17/theorems/}{sybilrestheorem.tex}\n  \\subimport{fc17/proofsketches/}{sybilresproofsketch.tex}\n  We have proven that controlling $|\\mathcal{C}|$ is irrelevant for Eve, thus Sybil attacks are meaningless. Note that\n  the theorem does not reassure against deception attacks. Specifically, a malicious player can create several identities, use\n  them legitimately to inspire others to deposit direct trust to these identities and then switch to the evil strategy, thus\n  defrauding everyone that trusted the fabricated identities. These identities correspond to the corrupted set of players and\n  not to the Sybil set because they have direct incoming trust from outside the collusion.\n\n  In conclusion, we have delivered on our promise of a Sybil-resilient decentralized financial trust system with invariant\n  risk for purchases.\n\n", "meta": {"hexsha": "9b7afeb6a52e2184f3769faebf23e06a74159410", "size": 1879, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fc17/sybil_resilience.tex", "max_stars_repo_name": "dionyziz/DecentralizedTrust", "max_stars_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2017-03-15T14:33:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T14:07:45.000Z", "max_issues_repo_path": "fc17/sybil_resilience.tex", "max_issues_repo_name": "dionyziz/DecentralizedTrust", "max_issues_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-03-07T12:25:26.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-31T14:42:20.000Z", "max_forks_repo_path": "fc17/sybil_resilience.tex", "max_forks_repo_name": "dionyziz/DecentralizedTrust", "max_forks_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-07T10:49:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-28T06:32:33.000Z", "avg_line_length": 69.5925925926, "max_line_length": 126, "alphanum_fraction": 0.7967003725, "num_tokens": 452, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.41389000946642496}}
{"text": "\\section{Machine learning techniques}\\label{sec:machine-learning-techniques}\nIn modern cyber security, there exist many different threats that potentially expose the system to being compromised.\nMany of them are very sophisticated, some are pretty difficult to distinguish from legitimate operations.\nNowadays, there is a trend to use machine learning approaches to meet the high demands for the quality and reliability of security systems.\n\nAs stated by Tony Thomas et al. --- \"Machine learning (\\gls{ml}) may be defined as the ability of machines to learn without being explicitly programmed.\nUsing mathematical techniques across cyberdata, \\gls{ml} algorithms can build models of behaviors and use those models as a basis for making predictions on newly input data\"~\\cite{thomas2020machine}.\nThis behavior of machine learning techniques is very convenient, especially when the domain of the problem and the borders between the data cannot be explicitly expressed by the written program.\nMachine learning models can learn from their own mistakes and then recognize or even predict the future attacks~\\cite{thomas2020machine}.\n\nIn scope of sequential data with natural timespan interpretation such us mouse actions, the recursive neural networks are natural choice.\nAs stated by Chong et al. --- \"Given the sequential nature of mouse movement data, a recurrent neural network (\\gls{rnn}), commonly employed for time series structure data, would be an intuitive choice for tackling this problem\"~\\cite{Main}.\nHowever, if the data can be represented as a bit map or a picture, the convolutional neural networks become possible to use.\nDue to the size of picture representation in a computer world, it is pretty expensive in the meaning of computational cost to use plain artificial neural networks because the number of weights in such a network becomes tremendous.\nConvolutional neural networks address this issue and make the computation significantly faster and efficient.\n\nKeiron O'Shea et. al in \\cite{cnn-description} define an architecture of \\gls{cnn}'s as a connected network of three types layers: convolutional layer, pooling layer and fully-connected layer.\nThe convolutional layer is combined out of filters that represent features of the images that the given filter should recognize.\nThese filters are then used on the different regions of images from the dataset by performing convolution.\nThe output reflects the found matches between the image that is recognized and the one described by the filter.\nPooling is a technique used to decrease the size of the image by grouping pixels and returning the representative value for this group.\nAs an example, the max-pooling bases on returning the pixel with the highest value in the group.\nThe fully-connected layer is a layer that builds plain artificial neural networks and it is built out of the neurons that are connected to the neurones from the previous layer, but they are not connected inside the current layer.\nThomas et. al add to these layers so-called rectified linear unit layer (\\gls{relu}) and define its responsibility as \"changing the negative pixel values in the image to zero, which gives us another stack of images with no negative values\"~\\cite{thomas2020machine}.\nThis layer is called an activation function because it activates the next layer only if the value of the pixel is positive.\n\nThe problem that this work raises can be specified as a binary problem because there exist only two possible categories for the data --- user's and bot actions.\nIn such situations, the measure of quality and correctness of the solution is commonly defined by a confusion matrix.\nThis matrix defines the performance of the model and consists of several measures: true positives, true negatives, false positives and false negatives.\nTrue positives (\\gls{tp}) are defined as the number of samples that the model assign to the positive category and the assignment is correct.\nThe opposite to them are false positives (\\gls{fp}), which can be described as faulty categorized to the positive category.\nThe true negatives (\\gls{tn}) and false negatives (\\gls{fn}) are analogous, but the assigned category is negative.\n\nBasing on the described measures, one can define relative measures --- false rejection rate (\\gls{frr}) and false acceptance rate (\\gls{far}).\nThese are defined as follows:\n\n\\begin{samepage}\n\\begin{equation}\n    FRR = \\frac{FN}{FN + TP}\\label{eq:frr}\n\\end{equation}\n\\begin{equation}\n    FAR = \\frac{FP}{FP + TN}\\label{eq:far}\n\\end{equation}\n\\end{samepage}\n\nThe values of \\gls{frr} and \\gls{far} are often expressed as a percentage value and the smaller their values, the better the performance of the model.\nIn authorization related problems such as raised in this work, there is a desire to have those values as low as possible because low \\gls{far} defines the good security level of the system --- the lower it is, the less unauthorized users have access to the system, and accordingly \\gls{frr} has an impact on authorization rejections of legitimate users.\n\nIn the presented solution, the authors use a transfer learning technique.\nAs stated in the \"A survey of transfer learning\" by Weiss et al. --- \"In certain scenarios, obtaining training data that matches the feature space and predicted data distribution characteristics of the test data can be difficult and expensive.\nTherefore, there is a need to create a high-performance learner for a target domain trained from a related source domain.\nThis is the motivation for transfer learning.\nTransfer learning is used to improve a learner from one domain by transferring information from a related domain\"~\\cite{transfer-learning-def}.\nThis approach provides several conveniences, such as computational time and cost reduction.\nThe pretrained network does not require such a long time as in the case of training from scratch which also translates into the cost of calculations and in the end does not require a large computational grant.\nThe main advantage of such an approach is the reduction of the required amount of representative data.\nIn cases where the data gathering is difficult or the collected dataset is small, transfer learning seems to be a technique that is worth considering.\nAs a transfer learning model, the authors chose the InceptionV3\\upperref{itm:inceptionV3} architecture from Tensorflow Hub\\upperref{itm:tensorflow-hub}, which originally was trained on ImageNet\\upperref{itm:image-net} dataset.\nBasing on several benchmarks, it was considered that the described architecture fits well to the raised problem and the performance is great at the same time.\nThe architecture is build out of convolutional layers, average and max pooling, dropouts, concatenation layers and fully-connected layers.\nDescription of the InceptionV3 architecture is out of the scope of this work.\n\nIn order to perform the learning process of the model, the main dataset should be divided into two subsets --- training and test datasets.\nThe network basing on the output of the loss function is able to improve its predictions and make progress in classification.\nIn the case of the supervised learning, where the network learns from the given examples, there is also a requirement for the assignment of the labels that are considered as descriptive ones for the input sample.\nWhen the gathered data consist of several categories, among which there is a dominant class in the meaning of volume of samples, such dataset is considered as an imbalanced one.\nThis issue has a negative impact on the learning process and should be resolved in order to improve the performance of the model.\n", "meta": {"hexsha": "ce0985ae9dcfe5278e6ae9d28f6d26e0156111f9", "size": 7622, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/theory/machine-learning-theory.tex", "max_stars_repo_name": "Mouse-BB-Team/Thesis", "max_stars_repo_head_hexsha": "24fe0f9dca4fa0b18137fdebd976feef9997d895", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chapters/theory/machine-learning-theory.tex", "max_issues_repo_name": "Mouse-BB-Team/Thesis", "max_issues_repo_head_hexsha": "24fe0f9dca4fa0b18137fdebd976feef9997d895", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapters/theory/machine-learning-theory.tex", "max_forks_repo_name": "Mouse-BB-Team/Thesis", "max_forks_repo_head_hexsha": "24fe0f9dca4fa0b18137fdebd976feef9997d895", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 112.0882352941, "max_line_length": 353, "alphanum_fraction": 0.807662031, "num_tokens": 1531, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4137927058186993}}
{"text": "\\documentclass[a4paper,man,natbib]{apa6}\n\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\n% Common Packages - Delete Unused Ones %\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\n\n\\usepackage[cache=false]{minted}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\graphicspath{ {./images/} }\n% End Packages %\n\n\\title{Exercise Assignment 5}\n\\shorttitle{ES5}\n\\author{Brandon Hosley}\n\\date{2018 09 25}\n\\affiliation{Mike Davis}\n\n%\\abstract{}\n\n\\begin{document}\n\\maketitle\n\\singlespacing\n\\subsection{25a}\n\\emph{Assuming nine-bit two's complement representation, convert each of the following decimal numbers to binary, show the effect of the ASL operation on it, and\n\tthen convert the result back to decimal. Repeat with the ASR operation:} \\\\\n94 \\\\\nBIN $\\rightarrow$ 0 0101 1110 \\\\\nASL $\\rightarrow$ 0 1011 1100 \\\\\nDEC $\\rightarrow$ 188 \\\\\nASR $\\rightarrow$ 0 0101 1110 $\\rightarrow$ 94 \\\\\n\\subsection{25c}\n\\emph{Assuming nine-bit two's complement representation, convert each of the following decimal numbers to binary, show the effect of the ASL operation on it, and\n\tthen convert the result back to decimal. Repeat with the ASR operation:} \\\\\n-62 \\\\\nBIN $\\rightarrow$ 1 1100 0010 \\\\\nASL $\\rightarrow$ 1 1000 0100 \\\\\nDEC $\\rightarrow$ -124\nASR $\\rightarrow$ 0 1100 0010$_{2}$ $\\rightarrow$ 194$_{10}$\n\\subsection{26a}\n\\emph{Write the RTL specification for an arithmetic shift right on a six-bit cell.} \\\\\n$c\\rightarrow r\\langle 0\\rangle ,r \\langle 0...5\\rangle\\rightarrow r\\langle 1...6\\rangle ,r\\langle 6\\rangle\\rightarrow C$ \\\\\n\\subsection{26b}\n\\emph{Write the RTL specification for an arithmetic shift left on a 16-bit cell.} \\\\\n$C\\leftarrow r\\langle 0\\rangle ,r \\langle 0...15\\rangle\\leftarrow rlangle 1...16\\rangle ,r\\langle 6\\rangle\\leftarrow c$\n\\subsection{28a}\n\\emph{C = 1, ROL 0 0110 1101} \\\\\nC=0, 0 1101 1011 \\\\\n\\subsection{28b}\n\\emph{C = 0, ROL 0 0110 1101} \\\\\nC=0, 0 1101 1010 \\\\\n\\subsection{35b}\n\\emph{Assuming nine-bit two's complement binary representation, convert the following numbers from hexadecimal to decimal. Remember to check the sign bit: 0F5} \\\\\n0F5$_{16}$ $\\rightarrow$ 0 1111 0101$_{2}$ $\\rightarrow$ 245$_{10}$\n\\subsection{35c}\n\\emph{Assuming nine-bit two's complement binary representation, convert the following numbers from hexadecimal to decimal. Remember to check the sign bit: 100} \\\\\n100$_{16}$ $\\rightarrow$ 1 0000 0000$_{2}$ $\\rightarrow$ -255$_{10}$\n\\subsection{53b}\n\\emph{For IEEE 754 single precision floating point, write the hexadecimal representation for the following decimal values: -1.0} \\\\\n-1.0$_{10}$ $\\rightarrow$ 1 0111 1111 000 0000 0000 0000 0000 0000$_{2}$ $\\rightarrow$ BF800000$_{16}$\n\\subsection{53c}\n\\emph{For IEEE 754 single precision floating point, write the hexadecimal representation for the following decimal values: -0.0} \\\\\n-0.0$_{10}$ $\\rightarrow$ 1 0000 0000 000 0000 0000 0000 0000 0000$_{2}$ $\\rightarrow$ 80000000$_{16}$\n\n\\nocite{warford10}\n\\bibliographystyle{apacite}\n\\bibliography{CS} %link to relevant .bib file\n\n\\end{document}\n", "meta": {"hexsha": "204b4fa4ab203d80d9294a2b279a04f996b8a2b8", "size": 2999, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2018-Spr Computer Architecture/ES5/bhosl2ES5.tex", "max_stars_repo_name": "bhosley/Schoolwork", "max_stars_repo_head_hexsha": "7c4eb909d2e6c65cd93b1c7fa744a183cebfc952", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2018-Spr Computer Architecture/ES5/bhosl2ES5.tex", "max_issues_repo_name": "bhosley/Schoolwork", "max_issues_repo_head_hexsha": "7c4eb909d2e6c65cd93b1c7fa744a183cebfc952", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2018-Spr Computer Architecture/ES5/bhosl2ES5.tex", "max_forks_repo_name": "bhosley/Schoolwork", "max_forks_repo_head_hexsha": "7c4eb909d2e6c65cd93b1c7fa744a183cebfc952", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.527027027, "max_line_length": 162, "alphanum_fraction": 0.7402467489, "num_tokens": 967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7310585786300048, "lm_q1q2_score": 0.41379270581869926}}
{"text": "% !TeX root = RJwrapper.tex\n\\title{Connecting R with D3 for dynamic graphics, to explore multivariate data\nwith tours}\n\\author{by Michael Kipp, Ursula Laa, Dianne Cook}\n\n\\maketitle\n\n\\abstract{%\nThe tourr package in R has several algorithms and displays for showing\nmultivariate data as a sequence of low-dimensional projections. It can\ndisplay as a movie but has no capacity for interaction, such as stop/go,\nchange tour type, drop/add variables. The tourrGui package provides\nthese sorts of controls, but the interface is programmed with the dated\nRGtk2 package. This work explores using custom messages to pass data\nfrom R to D3 for viewing, using the Shiny framework. This is an approach\nthat can be generally used for creating all sorts of interactive\ngraphics.\\\\\n}\n\n\n\\hypertarget{introduction}{%\n\\subsection{Introduction}\\label{introduction}}\n\nDid you know you can run \\emph{any javascript you like} in a Shiny\napplication and you can pass \\emph{whatever you want including JSON}\nback and forth? This massively widens the scope of what you can do with\nShiny, and generating a tour of multivariate data with this approach is\na really good example of what is possible.\n\nThe tour algorithm (Cook et al. \\protect\\hyperlink{ref-gt_pp}{1995},\n\\protect\\hyperlink{ref-gt_pp_mc}{2007}) is a way of systematically\ngenerating and displaying projections of high-dimensional spaces in\norder for the viewer to examine the multivariate distribution of data.\nIt can do this either randomly, or by picking projections judged\ninteresting according to some criterion or index function. The tourr\npackage (Wickham et al. \\protect\\hyperlink{ref-tourr}{2011}) provides\nthe computing and display in R (R Core Team\n\\protect\\hyperlink{ref-R}{2018}; Ihaka and Gentleman\n\\protect\\hyperlink{ref-ihaka:1996}{1996}) to make several types of\ntours: grand, guided, little and local. The projection dimension can be\nchosen between one and the number of variables in the data. The display,\nthough, has no capacity for interaction. The viewer can watch the tour\nlike a movie, but not pause it and restart, or change tour type, or\nnumber of variables.\n\nThese interactive controls were provided with the tourrGui package\n(Huang, Cook, and Wickham \\protect\\hyperlink{ref-tourrGui}{2012}), with\nwas programmed with the RGtk2 package (Lawrence and Temple Lang\n\\protect\\hyperlink{ref-RGtk2}{2010}). This is not the toolkit of choice\ntoday, and has been superceded with primarily web-capable tools, like\nShiny (Chang et al. \\protect\\hyperlink{ref-shiny}{2017}). To display\ndynamic graphics though, is not straight-forward. This paper explains\nhow to use D3 (Bostock, Ogievetsky, and Heer\n\\protect\\hyperlink{ref-D3}{2011}) as the display engine in a Shiny\ngraphical user interface (GUI), using custom message passing between\nserver and client.\n\n\\hypertarget{creating-a-tour-with-the-tourr-package}{%\n\\subsection{Creating a tour, with the tourr\npackage}\\label{creating-a-tour-with-the-tourr-package}}\n\nThe \\pkg{tourr} package (Wickham et al.\n\\protect\\hyperlink{ref-tourr}{2011}) is an R implementation of the tour\nalgorithms discussed in Cook et al.\n(\\protect\\hyperlink{ref-gt_pp_mc}{2007}). It includes methods for\ngeodesic interpolation and basis generation, as well as an\nimplementation of the simulated annealing algorithm to optimise\nprojection pursuit indices for the guided tour. The tour can be\ndisplayed directly in the R graphics device, for example, the code below\ngenerates a 1D density tour. Figure \\ref{tour} shows snapshots.\n\n\\begin{Schunk}\n\\begin{Sinput}\nlibrary(tourr)\n# quartz() # to display on a Mac; X11() # For windows; The Rstudio graphics\n# device is not advised\nanimate_dist(flea[, 1:6], center = TRUE)\n\\end{Sinput}\n\\end{Schunk}\n\n\\begin{figure}[ht]\n\\centerline{\\includegraphics[width=5cm]{figures/tour1.png}\\includegraphics[width=5cm]{figures/tour2.png}\\includegraphics[width=5cm]{figures/tour3.png}}\n\\caption{Three projections from a 1D tour of 6D data, displayed as a density. Full video can be seen at https://vimeo.com/255466661.}\n\\label{tour}\n\\end{figure}\n\nA tour path is a smooth sequence of projection matrices, \\(p\\times d\\),\nthat when combined with a matrix of n data points, \\(n\\times p\\), and a\nrendering method, produces a steady stream of \\(d\\)-dimensional views of\nthe data. Each tour is initialised with the \\texttt{new\\_tour()} method,\nwhich instantiates a tour object and takes as arguments the data \\(X\\),\nthe tour method, e.g. \\texttt{guided\\_tour()}, and the starting basis.\nOnce initialised, a new target plane is chosen, and a series of steps\nalong a geodesic path from starting to target plane are generated by\ninterpolation.\n\nThis requires a series of calls to the tour object producing the series\nof projections. The steps are discrete, of size given by\n\\(\\omega/\\Delta\\), where \\(\\omega\\) denotes the angular velocity of the\ngeodesic interpolation, and \\(\\Delta\\) is a parameter denoting frames\nper second, reflecting the rendering speed of the device in use. The\n\\(\\Delta\\) parameter can be thought of as the frames per second, while\n\\(\\omega\\) affects the speed at which the tour moves through the\nprojection space. For our purposes, \\(\\Delta\\), \\texttt{fps} in the\ncode, is set at 25, while the \\(\\omega\\) can be adjusted by the user.\n\n\\hypertarget{connecting-the-tour-projections-to-d3-display-using-sendcustommessage}{%\n\\subsection{\\texorpdfstring{Connecting the tour projections to D3\ndisplay using\n\\texttt{sendCustomMessage}}{Connecting the tour projections to D3 display using sendCustomMessage}}\\label{connecting-the-tour-projections-to-d3-display-using-sendcustommessage}}\n\nD3.js (Data-Driven Documents) (Bostock, Ogievetsky, and Heer\n\\protect\\hyperlink{ref-D3}{2011}) is a JavaScript library for\nmanipulating documents based on data. The advantages of D3 are similar\nto those provided by Shiny: namely, an industry standard with rich array\nof powerful, easy to use methods and widgets that can be displayed on a\nwide variety of devices, with a large user base. D3 works on data\nobjects in the JavaScript Object Notation (JSON) format, which are then\nparsed and used to display customisable data visualisations.\n\nThe new implementation of the tour interface uses D3 to render each\nprojection step returned by R, focusing on 2D projections as a test\ncase. It does this by drawing and re-drawing a scatterplot with dots (or\ncircles in D3 language) and providing SVG objects for the web browser to\nrender. Figure \\ref{tourrD3} shows the new GUI.\n\n\\begin{figure*}[ht]\n\\centerline{\\includegraphics[width=15cm]{figures/TourrD3.png}}\n\\caption{Shiny GUI for the tour, with D3 as the display engine. GUI provides controls to select tour type, change speed, restart, and select variables to include.}\n\\label{tourrD3}\n\\end{figure*}\n\nThere are two functions provided by the Shiny framework to transport\ndata between R and JavaScript: \\texttt{session\\$sendCustomMessage()} in\nR, and the corresponding \\texttt{Shiny.addCustomMessageHandler()} in\nJavaScript. Whenever the former is executed in R, the latter function\nwill execute a code block in JS. There are many examples of such\nfunctions being used to pass arbitrary data from an R app to a JS\nfront-end, few examples exist of this basic functionality to update a D3\nanimation in real-time.\n\nTo set up the interface for the app, we need to load the relevant\nscripts into the Shiny app and assign a section for the resulting plots.\nThis is done when setting up the user interface. We import D3 and our\nplotting code via the \\texttt{tags\\$script} (for web links) and\n\\texttt{includeScript} (for reading from a full path). We use\n\\texttt{tags\\$div} to assign an id for the output section that can be\naccessed in the D3 code.\n\n\\begin{verbatim}\ntags$script(src = \"https://d3js.org/d3.v4.min.js\"),\nincludeScript(system.file(\"js/d3anim.js\", package = \"tourrGUID3\")),\ntags$div(id = \"d3_output\")\n\\end{verbatim}\n\nOn the D3 side we can access the id defined in Shiny, and for example\nassign it to a scalable vector graphics (svg) object to be filled in D3\nand rendered onto the Shiny app.\n\n\\begin{verbatim}\nvar svg = d3.select(\"#d3_output\")\n    .append(\"svg\")\n    .attr(\"width\", w)\n    .attr(\"height\", h);\n\\end{verbatim}\n\nThe data format expected by D3 is in JSON format, which combines two\nbasic programming paradigms: a collection of name/value pairs, and an\nordered list of values. R's preferred data formats include data frames,\nvectors and matrices. Every time a new projection has been calculated\nwith the tour path, the resulting matrix needs to be converted to JSON\nand sent to D3. Using a named list we can send multiple JSON datasets to\nD3, e.g.~to draw both the data points (stored in dataframe d) and the\nprojection axes (stored in dataframe a). Converting dataframes will pass\nthe column names to JSON. The code to send the D3 data looks like this:\n\n\\begin{verbatim}\nsession$sendCustomMessage(type = \"data\", message = list(d = toJSON(d), a = toJSON(a)))\n\\end{verbatim}\n\nThis code is from the observe environment from the \\texttt{server.R}\nfile. It converts the matrix of projected data points to JSON format,\nand sends it to JavaScript with the id data. The list entries of the\n``message'' can parsed in D3 by its \\texttt{data()} method, e.g.\n\\texttt{data(message.d)} to access the projected data points, and we can\naccess each column through the column names assigned in the original\ndataframe, and loop over all rows for rendering. All of the code\nrequired to render the scatterplots and legends, along with colours, is\nJavaScript code in the file \\texttt{d3anim.js}. In particular, the data\nfrom R is handled with the following code:\n\n\\begin{verbatim}\nShiny.addCustomMessageHandler(\"data\",\n    function(message) {\n        /* D3 scatterplot is drawn and re-drawn using the\n            data sent from the server. */\n}\n\\end{verbatim}\n\nEvery time the message is sent (25 times per second), the code-block is\nrun.\n\n\\hypertarget{getting-projections}{%\n\\subsection{Getting projections}\\label{getting-projections}}\n\nThe \\texttt{observeEvent} Shiny method defines a code block to be run\nwhenever some input value changes. The following code snippet restarts a\ntour using a random basis:\n\n\\begin{verbatim}\nobserveEvent(input$restart_random,\n  {\n    p <- length(input$variables)\n    b <- matrix(runif(2*p), p, 2)\n    rv$tour <- \n      new_tour(as.matrix(rv$d[input$variables]),\n              choose_tour(input$type, \n              input$guidedIndex,\n              c(rv$class[[1]])), b)\n})\n\\end{verbatim}\n\nThe projections are calculated using the tour object in an\n\\texttt{observe()} environment, which re-executes the code whenever it\nis invalidated. The invalidation is either by a change in reactive value\ninside the code block, or we can schedule a re-execution by explicitly\ninvalidating the observer after a selected interval using\n\\texttt{invalidateLater()}. The projections are calculated using the\nfollowing code block:\n\n\\begin{Schunk}\n\\begin{Sinput}\nobserve({\n    if (length(rv$mat[1, ]) < 3) {\n      session$sendCustomMessage(type = \"debug\",\n      message = \"Error: Need >2 variables.\")\n    }\n    aps <- rv$aps\n    tour <- rv$tour\n    step <- rv$tour(aps / fps)\n    invalidateLater(1000 / fps)\n    j <- center(rv$mat %*% step$proj)\n    j <- cbind(j, class = rv$class)\n    colnames(j) <- NULL\n    session$sendCustomMessage(type = \"data\",\n         message = list(d = toJSON(data.frame(pL=rv$pLabel[,1], x=j[,2], \n                                              y=j[,1], c=j[,3])),\n                        a = toJSON(data.frame(n=rv$vars, y=step$proj[,1], \n                                              x=step$proj[,2]))))\n})\n\\end{Sinput}\n\\end{Schunk}\n\n\\hypertarget{try-it}{%\n\\subsection{Try it}\\label{try-it}}\n\nYou can try the app yourself using this code:\n\n\\begin{Schunk}\n\\begin{Sinput}\ndevtools::install_github(\"uschiLaa/tourrGUID3\")\nlibrary(tourrGUID3)\nlaunchApp(system.file(\"extdata\", \"geozoo.csv\", package = \"tourrGUID3\"))\n\\end{Sinput}\n\\end{Schunk}\n\n\\hypertarget{troubleshooting}{%\n\\subsection{Troubleshooting}\\label{troubleshooting}}\n\nFixing bugs in the JavaScript code can be cumbersome, as R and Shiny\nwill not report any errors. Tracing JavaScript errors can be done when\nusing the JavaScript console in the web browser. For example, in Google\nChrome the console can be accessed via the ``Developer Tools'' option\nfound under ``Moore Tools'' in the control menu. Typical errors that we\nencountered were version dependent syntax in D3, e.g.~for axis\ndefinitions or scaling.\n\n\\hypertarget{pros-and-cons}{%\n\\subsection{Pros and cons}\\label{pros-and-cons}}\n\nThe D3 canvas makes for smooth drawing and re-drawing of the data\nprojections. Adding a GUI around the display is straightforward with the\nShiny package, e.g.~control elements such as stop/go, increase/decrease\nspeed, change tour type, add/remove variables from the mix.\n\nThe main disadvantage is that the speed is inconsistent, as server and\nclient play tag to keep up with each other, and the display cannot\nhandle many observations. Noticeable slow down was oberved with 2000\npoints, the main reason being the rendering time required for the large\nnumber of SVG circle elements. The situation can be improved when using\na single HTML5 canvas element to draw the scatter points, significantly\nreducing the rendering time.\n\nAnother disadvantage is that the displays needs to be coded anew. D3\nprovides mostly primitives, and example code, to make scatterplots, and\ncontours, but the data displays all need to be coded again.\n\n\\hypertarget{summary}{%\n\\subsection{Summary}\\label{summary}}\n\nThe custom message tools from Shiny provide a way to share a tour path\nwith the D3 renderer, and embed it in a Shiny GUI providing controls\nsuch as stop/go, increase/decrease speed, change tour type, add/remove\nvariables. However, the approach doesn't provide the smooth motion that\nis needed for easy display of projections, and is slow for large numbers\nof observations.\n\n\\hypertarget{code}{%\n\\subsection{Code}\\label{code}}\n\nThe code is available at \\url{https://github.com/uschiLaa/tourrGUID3},\nand the source material for this paper is available at\n\\url{https://github.com/dicook/paper-tourrd3}.\n\n\\hypertarget{acknowledgements}{%\n\\subsection{Acknowledgements}\\label{acknowledgements}}\n\nThanks to Yihui Xie for pointing out the custom message tools.\n\n\\hypertarget{references}{%\n\\subsection{References}\\label{references}}\n\n\\hypertarget{refs}{}\n\\leavevmode\\hypertarget{ref-D3}{}%\nBostock, Michael, Vadim Ogievetsky, and Jeffrey Heer. 2011. ``D3:\nData-Driven Documents.'' \\emph{IEEE Transactions on Visualization and\nComputer Graphics} 17 (12): 2301--9.\n\\url{http://vis.stanford.edu/papers/d3}.\n\n\\leavevmode\\hypertarget{ref-shiny}{}%\nChang, Winston, Joe Cheng, JJ Allaire, Yihui Xie, and Jonathan\nMcPherson. 2017. \\emph{Shiny: Web Application Framework for R}.\n\\url{https://CRAN.R-project.org/package=shiny}.\n\n\\leavevmode\\hypertarget{ref-gt_pp}{}%\nCook, Dianne, Andreas Buja, Javier Cabrera, and Catherine Hurley. 1995.\n``Grand Tour and Projection Pursuit.'' \\emph{Journal of Computational\nand Graphical Statistics} 4 (4): 155--72.\n\n\\leavevmode\\hypertarget{ref-gt_pp_mc}{}%\nCook, Dianne, Andreas Buja, Eun-Kyung Lee, and Hadley Wickham. 2007.\n``Grand Tours, Projection Pursuit Guided Tours and Manual Controls.''\n\n\\leavevmode\\hypertarget{ref-tourrGui}{}%\nHuang, Bei, Dianne Cook, and Hadley Wickham. 2012. ``TourrGui: A\ngWidgets Gui for the Tour to Explore High-Dimensional Data Using\nLow-Dimensional Projections.'' \\emph{Journal of Statistical Software} 49\n(6): 1--12.\n\n\\leavevmode\\hypertarget{ref-ihaka:1996}{}%\nIhaka, Ross, and Robert Gentleman. 1996. ``R: A Language for Data\nAnalysis and Graphics.'' \\emph{Journal of Computational and Graphical\nStatistics} 5 (3): 299--314.\n\n\\leavevmode\\hypertarget{ref-RGtk2}{}%\nLawrence, Michael, and Duncan Temple Lang. 2010. ``RGtk2: A Graphical\nUser Interface Toolkit for R.'' \\emph{Journal of Statistical Software}\n37 (8): 1--52. \\url{http://www.jstatsoft.org/v37/i08/}.\n\n\\leavevmode\\hypertarget{ref-R}{}%\nR Core Team. 2018. \\emph{R: A Language and Environment for Statistical\nComputing}. Vienna, Austria: R Foundation for Statistical Computing.\n\\url{http://www.R-project.org/}.\n\n\\leavevmode\\hypertarget{ref-tourr}{}%\nWickham, Hadley, Dianne Cook, Heike Hofmann, and Andreas Buja. 2011.\n``Tourr: An R Package for Exploring Multivariate Data with\nProjections.'' \\emph{Journal of Statistical Software} 40 (2): 1--18.\n\n\\bibliography{references.bib}\n\n\\address{%\nMichael Kipp\\\\\nMonash University\\\\\nDepartment of Econometrics and Business Statistics\\\\\n}\n\\href{mailto:mkipp271@gmail.com}{\\nolinkurl{mkipp271@gmail.com}}\n\n\\address{%\nUrsula Laa\\\\\nMonash University\\\\\nSchool of Physics and Astronomy\\\\\n}\n\\href{mailto:ursula.laa@monash.edu}{\\nolinkurl{ursula.laa@monash.edu}}\n\n\\address{%\nDianne Cook\\\\\nMonash University\\\\\nDepartment of Econometrics and Business Statistics\\\\\n}\n\\href{mailto:dicook@monash.edu}{\\nolinkurl{dicook@monash.edu}}\n\n", "meta": {"hexsha": "06fa6a57bb1e45fbaadfa981687f2dbc40de9b9c", "size": 16886, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper-tourrd3.tex", "max_stars_repo_name": "dicook/paper-tourrd3", "max_stars_repo_head_hexsha": "8695f4d396f83280655aee467ce41b98b63199c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-02-22T14:30:35.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-22T14:30:35.000Z", "max_issues_repo_path": "paper-tourrd3.tex", "max_issues_repo_name": "dicook/paper-tourrd3", "max_issues_repo_head_hexsha": "8695f4d396f83280655aee467ce41b98b63199c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-01T02:30:05.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-01T02:30:05.000Z", "max_forks_repo_path": "paper-tourrd3.tex", "max_forks_repo_name": "dicook/paper-tourrd3", "max_forks_repo_head_hexsha": "8695f4d396f83280655aee467ce41b98b63199c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.9669211196, "max_line_length": 177, "alphanum_fraction": 0.7613407557, "num_tokens": 4447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.41379268848183237}}
{"text": "\\documentclass[10pt]{report}\n\n\\usepackage{enumerate} % for enumerate counter\n\\usepackage{subcaption} % for subfigures\n\\usepackage{amsthm} % for QED\n\\usepackage{mathtools} % for delimiter\n\n\\usepackage{listings} % for code\n\\lstset{ \n\tlanguage=R,\n\tbasicstyle=\\footnotesize\\ttfamily,\n\tnumbers=none,\n\tstepnumber=1,\n\tnumbersep=8pt,\n\tshowspaces=false,\n\tshowstringspaces=false,\n\tshowtabs=false,\n\tframe=single,\n\ttabsize=2,\n\tcaptionpos=t,\n\tbreaklines=true,\n\tbreakatwhitespace=false\n} \n\n\\usepackage{float} % for figure [H]\n\\usepackage{booktabs} % for tabular\n\\usepackage{caption} % for \\caption*\n\\usepackage[export]{adjustbox} % for valign=t\n\\usepackage{array} % for column type m\n\\usepackage{verbatim}\n\\usepackage{graphicx}\n%\\graphicspath{ {imgs/} }\n\\usepackage{fancyhdr}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\n%%%%%%Pagination\n\\setlength{\\topmargin}{-.3 in}\n\\setlength{\\oddsidemargin}{0in}\n\\setlength{\\evensidemargin}{0in}\n\\setlength{\\textheight}{9.in}\n\\setlength{\\textwidth}{6.5in}\n\n%Cover\n\\newcommand{\\hwTitle}{Homework \\#4}\n\\newcommand{\\hwCourse}{Applied Statistics}\n\\newcommand{\\hmClassInstructor}{Professor Lulu Kang}\n\n\\title{\n\t\\vspace{2in}\n\t\\textmd{\\textbf{\\hwCourse\\\\\\hwTitle}}\\\\\n\t\\vspace{0.3in}\\large{\\textit{\\hmClassInstructor}}\n\t\\vspace{3in}\n}\n\\author{\\textbf{Zhihao Ai}}\n\\date{}\n\n%Header\n\\pagestyle{fancy}\n\\fancyhead[L]{Zhihao Ai}\n\\fancyhead[C]{Math 484}\n\\fancyhead[R]{Homework 4}\n%%%%%%\n\n%Global settings\n%\\everymath{\\displaystyle}\n\\setlength\\parindent{0pt}\n\n%Custom commands\n\\newcommand{\\ds}{\\displaystyle}\n\\newcommand{\\ts}{\\textstyle}\n\n\\newcolumntype{N}{>$ c <$}\n\\newcolumntype{M}[1]{>{\\centering\\arraybackslash $}m{#1}<{$}}\n\n\\newcommand{\\abs}[1] {\\left| #1 \\right|}\n\n\\DeclarePairedDelimiter\\autoparen{(}{)}\n\\newcommand{\\pa}[1]{\\autoparen*{#1}}\n\n\\newcommand{\\var} {\\text{var}}\n\n\\newcommand{\\m}[1] {\\mathbf{#1}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Problem 1}\n(Ex. 7.19) Refer to \\textbf{Commercial properties}  Problem 6.18.\n\\begin{enumerate}[a.]\n\t\\item \n\tTransform the variables by means of the correlation transformation (7.44) and fit the standardized regression model (7.45).\n\t\n\tBy solving $\\m{b} = \\m{r}^{-1}_{XX} \\m{r}^{}_{YX}$, we have\n\t\\[\n\t\\m{b} = [-0.5478526, 0.4236468, 0.04846136, 0.5027571]'\n\t\\]\n\tSo the standardized regression model is $Y^*_i = -0.5478526 X^*_{i1} + 0.4236468 X^*_{i2} + 0.04846136 X^*_{i3} + 0.5027571 X^*_{i4}$.\n\t\n\t\\item \n\tInterpret the standardized regression coefficient $b^*_2$.\n\t\n\tWith other predictor variables fixed, the rental rates ($Y$) will increase by 0.4236468 standard deviations if operating expenses and taxes ($X_2$) increase by 1 standard deviation.\n\t\n\t\\item \n\tTransform the estimated standardized regression coefficients by means of (7.53) back to the ones for the fitted regression model in the original variables. Verify that they are the same as the ones obtained in Problem 6.18c.\n\t\n\tEmploying the relations\n\t\\begin{align*}\n\t\tb_k &= \\pa{\\frac{s_Y}{s_k}} b^*_k \\quad (k=1,\\dots,p-1)\\\\\n\t\tb_0 &= \\bar{Y} - b_1 \\bar{X}_1 - \\dots - b_{p-1} \\bar{X}_{p-1}\n\t\\end{align*}\n\tWe have\n\t\\[\n\t\\m{b} = [1.220059\\mathrm{e}+01, -1.420336\\mathrm{e}-01, 2.820165\\mathrm{e}-01, 6.193435\\mathrm{e}-01, 7.924302\\mathrm{e}-06]'\n\t\\]\n\twhich is the same as the one ontained in Problem 6.18c.\n\\end{enumerate}\n\n\\section*{Problem 2}\n(Ex. 7.24) Refer to \\textbf{Brand preference}  Problem 6.5.\n\\begin{enumerate}[a.]\n\t\\item \n\tFit first-order simple linear regression model (2.1) for relating brand liking ($Y$) to moisture content ($X_1$). State the fitted regression function.\n\t\n\tFitting the model for relating $Y$ to $X_1$, we have\n\t\\lstinputlisting{p2/24a.txt}\n\tSo the fitted regression function is $\\hat{Y} = 50.775 + 4.425 x_1$.\n\t\n\t\\item \n\tCompare the estimated regression coefficient for moisture content obtained in part (a) with the corresponding coefficient obtained in Problem 6.5b. What do you find?\n\t\n\tThe fitted regression function in Problem 6.5b is $\\hat{Y} = 37.65 + 4.425 x_1 + 4.375 x_2$. The $b_1$ coefficients are the same.\n\t\n\t\\item \n\tDoes $SSR(X_1)$ equal $SSR(X_1|X_2)$ here? If not, is the difference substantial?\n\t\n\tYes, they both equal 1566.45.\n\t\n\t\\item \n\tRefer to the correlation matrix obtained in Problem 6.5a. What bearing does this have on your findings in parts (b) and (c)?\n\t\n\tThe correlation between $X_1$ and $X_2$ is 0, meaning the two predictor variables are uncorrelated. When they are uncorrelated, the effects ascribed to them by a first-order regression model are the same no matter which other of the variables are included in the model, so the corresponding coefficients in parts (b) are the same. Likewise, the marginal contribution of one variable in reducing the error sum of squares when the other variable is in the model is the same as when it is in the model alone, hence $SSR(X_1) = SSR(X_1|X_2)$.\n\t\n\\end{enumerate}\n\n\\section*{Problem 3}\n(Ex. 8.24) \\textbf{Assessed valuations}\n\\begin{enumerate}[a.]\n\t\\item \n\tPlot the sample data for the two populations as a symbolic scatter plot. Does the regression relation appear to be the same for the two populations?\n\t\n\tBelow is the symbolic scatter plot:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=.5\\linewidth]{p3/24a.png}\n\t\\end{figure}\n\tThe regression relation does not appear to be the same.\n\t\n\t\\item \n\tTest for identity of the regression functions for dwellings on corner lots and dwellings in the other locations; control the risk of Type I error at .05. State the alternatives, decision rule, and conclusion.\n\t\n\tThe tentative model is given by\n\t\\[\n\tY_i = \\beta_0 + \\beta_1 X_{i1} + \\beta_2 X_{i2} + \\beta_3 X_{i1}X_{i2} + \\epsilon_i\n\t\\]\n\twhere\n\t\\begin{align*}\n\t\tX_{i1} &= \\text{assessed valuation}\\\\\n\t\tX_{i2} &=\n\t\t\\begin{cases}\n\t\t0 & \\text{if on non-corner lots}\\\\\n\t\t1 & \\text{if on corner lots}\n\t\t\\end{cases}\n\t\\end{align*}\n\tThe alternatives are\n\t\\begin{align*}\n\t\tH_0: &\\ \\beta_2 = \\beta_3 = 0\\\\\n\t\tH_a: &\\ \\text{not both $\\beta_2 = 0$ and $\\beta_3 = 0$}\n\t\\end{align*}\n\tThe test statistic is:\n\t\\[\n\tF^* = \\frac{MSR(X_2, X_1 X_2 | X_1)}{MSE} = \\frac{SSR(X_2 | X_1) + SSR(X_1 X_2 | X_1, X_2)}{2} \\div MSE\n\t\\]\n\tThe decision rule is\n\t\\begin{align*}\n\t\\text{If } F^* \\le F(0.95; 2, 60) = 3.150411, \\text{ conclude } H_0\\\\\n\t\\text{If } F^* > F(0.95; 2, 60) = 3.150411, \\text{ conclude } H_a\n\t\\end{align*}\n\t\\lstinputlisting{p3/24b.txt}\n\tUsing the results above, $F^* = (453.1+113.0)/2/15.2 = 18.62171 > 3.150411$. So we conclude $H_a$, that the regression functions for the two dwellings locations are not identical.\n\t\n\t\\item \n\tPlot the estimated regression functions for the two populations and describe the nature of the differences between them.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=.5\\linewidth]{p3/24c.png}\n\t\\end{figure}\n\tThe response functions are:\n\t\\begin{align*}\n\t\tE(Y) &= \\beta_0 + \\beta_1 X_1 + \\beta_2(0) + \\beta_3(0) = \\beta_0 + \\beta_1 X_1 \\quad \\text{non-corner lots}\\\\\n\t\tE(Y) &= \\beta_0 + \\beta_1 X_1 + \\beta_2(1) + \\beta_3(X_1) = (\\beta_0 + \\beta_2) + (\\beta_1 + \\beta_3) X_1 \\quad \\text{corner lots}\n\t\\end{align*}\n\t$\\beta_2$ here indicated how much greater is the $Y$ intercept of the response function for the class coded 1 than that for the class coded 0. $\\beta_3$ indicates how much smaller is the slope of the response function for the class coded 1 than that for the class coded 0. The nature of the differences is the effect of the class and the interaction of $X_1$ and $X_2$ on the regression.\n\\end{enumerate}\n\n\\end{document}\n\n", "meta": {"hexsha": "69e65304fadcf1ee97aae5209f3c6e5c5e54f301", "size": 7408, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW4/Math-484-HW4.tex", "max_stars_repo_name": "ZhihaoAi/MATH-484-Assignments", "max_stars_repo_head_hexsha": "9817add32fbcb46b58849ec923aa73a47daa9584", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW4/Math-484-HW4.tex", "max_issues_repo_name": "ZhihaoAi/MATH-484-Assignments", "max_issues_repo_head_hexsha": "9817add32fbcb46b58849ec923aa73a47daa9584", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW4/Math-484-HW4.tex", "max_forks_repo_name": "ZhihaoAi/MATH-484-Assignments", "max_forks_repo_head_hexsha": "9817add32fbcb46b58849ec923aa73a47daa9584", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2761904762, "max_line_length": 539, "alphanum_fraction": 0.7089632829, "num_tokens": 2539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7905303211371898, "lm_q1q2_score": 0.4137796565343722}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{amsmath,amsfonts,amssymb}\n\\textheight=22cm \\topmargin=-1cm\n\n%%%%%Structure of Thms. etc.%%%%%%%%%%%%%%%\n\\newtheorem{thm}{Theorem}\n\\newtheorem{con}{Conjecture}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}{Proposition}\n\\newtheorem{cor}{Corollary}\n\\newtheorem{defn}{Definition}\n\\newtheorem{ex}{Example}\n\\newtheorem{exo}{Exercice}\n\\newtheorem{porism}{Porism}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newcommand\\la{\\lambda}\n\\newcommand{\\spf}{\\noindent{\\bf Second proof: \\/}}\n\\newcommand{\\fpf}{\\noindent{\\bf First proof: \\/}}\n\\newcommand{\\pr}{{\\bf Proof: \\/}}\n\\newcommand{\\remark}{\\noindent{\\bf Remark: \\/}}\n%\\newcommand{\\eg}{\\noindent{\\bf For example: \\/}}\n\\def\\qed{\\nobreak\\quad\\raise -2pt\\hbox{\\vrule\\vbox to 10pt{\\hrule width 6pt\n\\vfill\\hrule}\\vrule}\\par\\vspace{2ex}}\n\\def\\qel{\\nobreak\\quad\\raise -2pt\\hbox{\\vrule\\vbox to 10pt{\\hrule width 6pt\n\\vfill\\hrule}\\vrule}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\n\\begin{center}\n{\\Large\\bf Applications of Waring's formula to some identities of\nChebyshev polynomials}\n\\end{center}\n\n\\vskip 2mm \\centerline{ Jiang Zeng$^{1,2}$ and Jin Zhou$^2$}\n\n\\begin{center} \\small $^1$ Institut Girard Desargues,\nUniversit\\'e Claude Bernard (Lyon I)\\\\\n69622 Villeurbanne Cedex, France \\\\\n{\\tt zeng@igd.univ-lyon1.fr}\\\\\nand\\\\\n$^2$ Center for Combinatorics, LPMC,\nNankai University\\\\\n Tianjin 300071, People's Republic of China\\\\\n{\\tt jinjinzhou@hotmail.com} \\\\\n\\vspace{10pt}\n\\small AMS Math Subject Classification Numbers: 11B39, 33C05, 05E05\\\\\n\\end{center}\n\n \\noindent\n\\textbf{Abstract.} Some identities of Chebyshev polynomials are\ndeduced from Waring's formula on symmetric functions. In\nparticular, these formulae generalize some recent results of\nGrabner and Prodinger.\n\\section{Introduction}\n\nGiven a set of variables $X=\\{x_1,x_2,\\ldots\\}$, the $k$th ($k\\geq\n0$) \\emph{elementary symmetric polynomial} $e_{k}(X)$ is defined\nby $e_0(X)=1$,\n$$\ne_k(X)=\\sum_{i_1<\\ldots<i_k}x_{i_1}\\ldots x_{i_k},\\quad\n\\text{for}\\quad k\\geqslant 1,\n$$\n and  the $k$th  ($k\\geq\n0$)\\emph{power sum symmetric polynomial} $p_{k}(X)$ is defined by\n$p_0(X)=1$,\n$$\np_k(X)=\\sum_ix_i^k,\\quad \\text{for}\\quad k\\geqslant 1.\n$$\nLet $\\la=1^{m_1}2^{m_2}\\ldots $ be a partition of $n$, i.e., $m_1\n1+m_2 2+\\ldots +m_n n=n$, where $m_i\\geq 0$ for $i=1,2,\\ldots n$.\nSet $l(\\la)=m_1+m_2+\\ldots +m_n$. According to the\n\\emph{fundamental theorem of symmetric polynomials}, any symmetric\npolynomial can be written uniquely as a polynomial of elementary\nsymmetric polynomials $e_i(X)$ ($i\\geq 0$). In particular, for the\npower sum $p_k(x)$, the corresponding formula  is usually\nattributed to Waring~\\cite{CLY,Mac} and reads as follows:\n\\begin{equation}\\label{war}\np_k(X)=\\sum_{\\la}(-1)^{k-l(\\lambda)}\\frac{k(l(\\lambda)-1)!}\n{\\prod_{i}{m_{i}!}}e_{1}(X)^{m_1}e_{2}(X)^{m_2}\\ldots,\n\\end{equation}\nwhere the sum is over all the partitions\n$\\la=1^{m_1}2^{m_2}\\ldots$ of $k$.\n\nIn a recent paper~\\cite{GP} Grabner and Prodinger proved some\nidentities about Chebyshev polynomials using generating functions,\nthe aim of this paper is to show that Waring's formula provides\na natural generalization of such kind of identities.\n\nLet $U_n$ and $V_n$ be two\nsequences defined by the following recurrence relations:\n\\begin{align}\nU_n&=pU_{n-1}-U_{n-2},&U_0=0, U_1=1,\\\\\nV_n&=pV_{n-1}-V_{n-2},&V_0=2, V_1=p.\n\\end{align}\nHence $U_n$ and $V_n$ are rescaled versions of the first and\nsecond kind of Chebyshev polynomials ${\\cal U}_n(x)$ and ${\\cal\nT}_n(x)$, respectively:\n$$\n{\\cal U}_n(x)=U_{n+1}(2x),\\quad {\\cal T}_n(x)=\\frac{1}{2}T_n(x).\n$$\n\\begin{thm} For integers\n$m,n\\geq 0$, let $W_n=aU_n+bV_n$ and  $\\Omega=a^2+4b^2-b^2p^2$. Then the following identity holds\n\\begin{equation}\\label{eq:wm}\nW_n^{2k}+W_{n+m}^{2k}=\\sum_{r=0}^{k}\\theta_{k,r}(m)\\Omega^{k-r}W_n^rW_{n+m}^r,\n\\end{equation}\nwhere\n$$\n\\theta_{k,r}(m)=\\sum_{0\\leqslant 2j\\leqslant\nk}(-1)^j\\frac{k(k-j-1)!}{j!(k-r)!(r-2j)!}V_m^{r-2j}U_m^{2k-2r}.\n$$\n\\end{thm}\nNote that  the identities of Grabner and Prodinger~\\cite{GP} correspond to the $m=1$\nand implicitly $m=2$ cases of Theorem~1 (cf. Section~3).\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Proof of Theorem~1}\nWe first check the $k=1$ case of (\\ref{eq:wm}):\n\\begin{equation}\\label{fund}\nW_n^2+W_{n+m}^2=V_mW_nW_{n+m}+U_m^2\\Omega.\n\\end{equation}\nSet $\\alpha=(p+\\sqrt{p^2-4})/2$ and $\\beta=(p-\\sqrt{p^2-4})/2$\nthen it is easy to see that\n$$\nU_n=\\frac{\\alpha^{n}-\\beta^{n}}{\\alpha-\\beta},\\quad\nV_{n}=\\alpha^n+\\beta^n,\n$$\nit follows that\n\\[\nW_n=aU_n+bV_n=A\\alpha^n+B\\beta^n,\n\\]\nwhere $A=b+a/(\\alpha-\\beta)$ and $B=b-a/(\\alpha-\\beta)$. Therefore\n\\begin{align*}\nV_mW_nW_{n+m}+U_m^2\\Omega\n&=(\\alpha^m+\\beta^m)(A\\alpha^n+B\\beta^n)(A\\alpha^{n+m}+B\\beta^{n+m})\\\\\n&+\\left(\\frac{\\alpha^m-\\beta^m}{\\alpha-\\beta}\\right)^2(a^2+4b^2-b^2p^2),\n\\end{align*}\n which is readily seen to be equal to $W_n^2+W_{n+m}^2$.\n\nNext we  take the alphabet $X=\\{W_n^2, W_{n+m}^2\\}$, then the left-hand\nside of (\\ref{eq:wm}) is the power sum $p_k(X)$. On the other\nhand, since\n$$\ne_1(X)=W_n^2+W_{n+m}^2,\\quad  e_2(X)=W_n^2W_{n+m}^2,\\quad e_i(X)=0\n\\quad \\textrm{if} \\quad i\\geqslant3,\n$$\nthe summation at the right-hand side of (\\ref{war}) reduces to the\npartitions $\\la=(1^{k-2j}\\,2^j)$, with  $j\\geq 0$. Now, using\n(\\ref{fund}) Waring's formula~(\\ref{war}) infers that\n\\begin{align*}\nW_n^{2k}&+W_{n+m}^{2k} \\\\\n &=\\sum_{0\\leqslant2 j\\leqslant\nk}(-1)^{j} \\frac{k(k-j-1)!}{j!(k-2j)!}\n(V_mW_nW_{n+m}+U_m^2\\Omega)^{k-2j}(W_n^2W_{n+m}^2)^{j}\\\\\n&=\\sum_{0\\leqslant2j\\leqslant k}\\sum_{i=0}^{k-2j}(-1)^j\n\\frac{k(k-j-1)!}{j!i!(k-2j-i)!}V_m^{k-2j-i}\nU_m^{2i}\\Omega^{i}(W_{n}W_{n+m})^{k-i}\n\\end{align*}\nSetting $k-i=r$ and exchanging the order of summations yields\n(\\ref{eq:wm}). \\qed\n\n\n\\section{Some special cases}\nWhen $m=1$ or 2, as $U_1=1$, $V_1=p$ and $U_2=p$, $V_2=p^2-2$ the\ncoefficient $\\theta_{k,r}(r)$ of Theorem~1 is much simpler.\n\\begin{cor} We have\n\\begin{eqnarray}\n\\theta_{k,r}(1)&=&\\sum_{0\\leqslant2j\\leqslant\nr}(-1)^j\\frac{k(k-1-j)!}{(k-r)!j!(r-2j)!}p^{r-2j},\\label{coeff1}\\\\\n\\theta_{k,r}(2) &=&\\sum_{0\\leqslant2j\\leqslant\nk}(-1)^j\\frac{k(k-j-1)!}{j!(k-r)!(r-2j)!}\n(p^2-2)^{r-2j}p^{2k-2r}.\\label{coeff2}\n\\end{eqnarray}\n\\end{cor}\n\nWe notice  that (\\ref{coeff1}) is exactly the formula given by Grabner and Prodinger~\\cite{GP}\nfor $\\theta_{k,r}(1)$, while for $\\theta_{k,r}(2)$  they\ngive a more involved formula than  (\\ref{coeff2})  as follows:\n\\begin{cor}[Grabner and Prodinger~\\cite{GP}] There holds\n\\begin{equation}\\label{coeffGP}\n\\theta_{k,r}(2) =\\sum_{0\\leqslant\\lambda\\leqslant\nk}(-1)^{\\lambda}p^{2k-2\\lambda}\n\\frac{k(k-\\lfloor\\frac{\\lambda}{2}\\rfloor-1)!\n2^{\\lceil\\frac{\\lambda}{2}\\rceil}}{(k-r)!\\lambda!(r-\\lambda)!}\n\\prod_{i=0}^{\\lfloor\\frac{\\lambda}{2}\\rfloor-1}\n(2k-2\\lceil\\frac{\\lambda}{2}\\rceil-1-2i).\n\\end{equation}\n\\end{cor}\nIn order to identify (\\ref{coeff2}) and (\\ref{coeffGP}), we need\nthe following identity.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{lem}\\label{key} We have\n\\begin{eqnarray}\\label{fa}\n&&\\sum_{i=0}^{j/2}(-1)^{i}\\frac{(k-i-1)!2^{j-2i}}{(j-2i)!i!}\\nonumber\\\\\n&&\\hspace{1cm}= \\frac{(k-\\lfloor{j/2}\\rfloor-1)!}{j!}2^{\\lceil\nj/2\\rceil} \\prod_{i=0}^{\\lfloor j/2\\rfloor-1}(2k-2\\lceil\nj/2\\rceil-1-2i).\n\\end{eqnarray}\n\\end{lem}\n\\begin{pr} For $n\\geq 0$ let $(a)_n=a(a+1)\\ldots (a+n-1)$, then\nthe Chu-Vandermonde formula~\\cite[p.212]{GKP} reads:\n\\begin{equation}\\label{cv}\n{}_2F_1( -n,a; c; 1):=\\sum_{k\\geqslant0}\\frac{(-n)_k(a)_k}{(c)_k\nk!}=\\frac{(c-a)_n}{(c)_n}.\n\\end{equation}\nNote that $n!=(1)_n$, so using the simple transformation formulae:\n$$\n(a)_{2n}=\\left(\\frac{a}{2}\\right)_n\\left(\\frac{a+1}{2}\\right)_{n}2^{2n},\\quad\n(a)_{2n+1}=\\left(\\frac{a}{2}\\right)_{n+1}\n\\left(\\frac{a+1}{2}\\right)_{n}2^{2n+1},\n$$\nand\n$$\n(a)_{N-n}=\\frac{(a)_N}{(a+N-n)_n}=(-1)^n\\frac{(a)_N}{(-a-N+1)_n},\n$$\n we can rewrite the left-hand side of identity~(\\ref{fa}) as follows:\n \\begin{eqnarray*}\n  \\begin{cases}\n    \\frac{(k-1)!}{(\\frac{1}{2})_m(1)_m}\n    \\,{}_2F_1(-m, -m+\\frac{1}{2};-k+1; 1)& \\text{if $j=2m$}, \\\\\n    \\\\\n    \\frac{(k-1)!}{{(\\frac{1}{2})}_{m+1}(1)_m}\n    \\,{}_2F_1(-m, -m-\\frac{1}{2};-k+1; 1)& \\text{if $j=2m+1$},\n  \\end{cases}\n\\end{eqnarray*}\nwhich is clearly equal to the right-hand side of (\\ref{fa}) in\nview of (\\ref{cv}). \\qed\n\\end{pr}\n\nNow, expanding  the right-hand side of (\\ref{coeff2}) by binomial\nformula yields\n$$\n\\sum_{0\\leqslant2j\\leqslant k}(-1)^j\\frac{k(k-j-1)!}\n{j!(k-r)!(r-2j)!}\\sum_{i=0}^{r-2j}{r-2j\\choose i}\np^{2i}(-2)^{r-2j-i}p^{2k-2r}.\n$$\nWriting  $\\la=r-i$, so $\\la\\leq r\\leq k$, and exchanging the order\nof summations, the above quantity becomes\n$$\n\\sum_{0\\leqslant \\la\\leqslant k} (-1)^{\\la} p^{2k-2\\la\n}\\frac{k}{(k-r)!(r-\\la)!}\\sum_{0\\leqslant j\\leqslant\nk/2}(-1)^j\\frac{(k-j-1)!2^{\\la-2j}}{(\\la-2j)!j!},\n$$\nwhich yields (\\ref{coeffGP}) by applying Lemma~\\ref{key}.\n\n\\begin{thebibliography}{99}\n\\bibitem{CLY} William Y. C. Chen, Ko-Wei Lih, and  Yeong-Nan Yeh:\n\\emph{Cyclic Tableaux and Symmetric Functions}, Studies in Applied\nMath., 94 (1995), 327-339.\n\\bibitem{GKP} Ronald L. Graham, Donald E. Knuth and Oren Patashnik:\n\\emph{Concrete Mathematics}, Addion-Wesley Pubilshing Co. 1989.\n\\bibitem{GP} Peter J. Grabner and Helmut Prodinger:\n\\emph{Some identities for Chebyshev polynomials}, Portugalia\nMathematicae 59 (2002), 311-314.\n\\bibitem{Mac} P. A. MacMahon:\n\\emph{Combinatory analysis}, Chelsea Publishing Co. New York,\n1960.\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "c5d12583478d9a0aa31f15cf562416a847edb989", "size": 9443, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "benchmark/src/test-data/0501/math0501216/math0501216.tex", "max_stars_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_stars_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-23T19:07:01.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-23T19:07:01.000Z", "max_issues_repo_path": "benchmark/src/test-data/0501/math0501216/math0501216.tex", "max_issues_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_issues_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/src/test-data/0501/math0501216/math0501216.tex", "max_forks_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_forks_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3192307692, "max_line_length": 97, "alphanum_fraction": 0.6452398602, "num_tokens": 3938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.41371320333655853}}
{"text": "\\documentclass[a4paper, 12pt]{article}\n\\usepackage{preamble}\n\n\\begin{document}\n\n\\title{NOTES ON SOMETHING}\n\\author{AUTHOR}\n\\maketitle{}\n\n\\section{A section}\n\\blindtext[1]{}\n\n\\subsection{A subsection}\n\\blindtext[1]{}\n\nCiting Equation~\\ref{eq:sum}.\n\n\\begin{equation}\n\\label{eq:sum}\n    a + b = c\n\\end{equation}\n\n\\section{Another section}\n\\blindtext[2]{}\n\n\\begin{table}[hbt!]\n  \\centering\n  \\renewcommand{\\arraystretch}{1.1}\n  \\caption{Table caption}\n  \\begin{tabular}{p{0.3\\linewidth}c{0.12\\linewidth}c{0.12\\linewidth}}\n   \\toprule\n   \\textbf{Column 1} & \\textbf{Column 2} & \\textbf{Column 3} \\\\\n   \\midrule\n   Description 1 & 0.1 & 1.0 \\\\\n   Description 2 & 0.2 & 2.0 \\\\\n  \\bottomrule\n  \\end{tabular}\\label{tab:table}\n  \\renewcommand{\\arraystretch}{1}\n\\end{table}\n\n\\begin{algorithm}[hbt!]\n\\caption{$\\textrm{AlgorithmTitle}(q, P)$}\n\\textit{Input.} Algorithm input. \\\\\n\\textit{Output.} Algorithm output.\n\\begin{algorithmic}[1]\n  \\State{Draw a horizontal line $l_{0r}$ from $q$ to its left}\\label{linea}\n    \\State{Move from infinity to $q$, following $l_{0r}$, and count the number\n    $N$ of intersections of $l_{0r}$ with $P$}\n    \\If{$N$ is odd}\n        \\State{$q$ is inside $P$}\n    \\Else{}\n        \\State{$q$ is outside $P$}\n    \\EndIf{}\n    \\For{all edges $e_{ab}$ of $P$, where $a$ is the lower and $b$ is the upper\n      point}\n      \\If{$a_{y} < q_{y}$ \\textbf{and} $b_{y} > q_{y}$ \\textbf{and}\n      Equation~\\ref{eq:sum} is satisfied}\\label{lineb}\n        \\State{$N = N + 1$}\n      \\EndIf{}\n    \\EndFor{}\n\\end{algorithmic}\\label{alg:example}\n\\end{algorithm}\n\nCiting lines~\\ref{linea} and~\\ref{lineb} of Algorithm~\\ref{alg:example}.\n\nIt is possible to include snippets from real code, like in Listing~\\ref{list:snippet}.\n\n\\begin{listing}[hbf!]\n  \\caption{Code snippet}\n  \\label{list:snippet}\n  \\inputminted{cpp}{./snippets/hello.cpp}\n\\end{listing}\n\nExplanation of code using highlighted syntax.\n\n\\code{cpp}{double x, y;}{declaration without initialization}\n\\code{cpp}{double x = 1.5;}{declaration with initialization}\n\\code{cpp}{double x(1.5);}{declaration with initialization}\n\\code{cpp}{const double x = 1.5;}{initializes a constant}\n\n\\begin{definition}{Lines intersections.}\n\\begin{enumerate}\n  \\item The lower point of $l_{ab}$ lies below $q$.\n  \\item The upper point of $l_{ab}$ lies above $q$.\n  \\item $q$ lies to the right from the line $\\overrightarrow{l}_{ab}$, that\n      goes from $a$ to $b$.\n\\end{enumerate}\n\\end{definition}\n\n\\begin{problem}{Point inclusion in a polygon}\nGiven a point $q$ and a polygon $P$, determine if $q$ is inside or outside $P$.\n\\end{problem}\n\n\\end{document}\n\n", "meta": {"hexsha": "4193d8d4c22d34d94a9daacf59cf6ad59e912139", "size": 2602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex-notes/notes.tex", "max_stars_repo_name": "lbteixeira/code-starters", "max_stars_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-13T12:21:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-13T12:21:06.000Z", "max_issues_repo_path": "latex-notes/notes.tex", "max_issues_repo_name": "lbteixeira/code-starters", "max_issues_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex-notes/notes.tex", "max_forks_repo_name": "lbteixeira/code-starters", "max_forks_repo_head_hexsha": "a2805511064e43c2f79e659dfa7da0910110680c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1041666667, "max_line_length": 86, "alphanum_fraction": 0.6675634128, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.41371231850541934}}
{"text": "\\section{Structural Synthesis}\n\\label{sec:struct}\n\nThe structural synthesis stage of our algorithm consists of two parts.\nFirst, we guess at an initial filter structure based on a preliminary analysis of the input/output audio examples.\nIn the second stage, which occurs during the synthesis loop, we iteratively pick new structures to try during metrical synthesis.\nFor this second stage we have implemented a greedy algorithm to pick the best structure out of the possible next choices.\n\n\\subsection{Initial Structure Construction}\n\\label{sec:initStruct}\nIn order to find an initial structure for our synthesized filter, we use an adaption of room impulse response measurement.\nWhen measuring the impulse response of a room, we can reconstruct the band-pass filter exactly by playing a sound in the room, recording the sound, then examining the differences.\nIn DSP-PBE, we do not want to allow infinitely many bandpass filters, as the synthesized program should be relatively small and human-readable, in the same way as code would be readable if it had been manually written.\nThus, we mimic the room impulse response measurement technique using only the available \\dspnode in our grammar.\n\nIn the grammar listed in Fig.~\\ref{fig:grammar}, we have two filters which are similar to the bandpass filters used in measuring room impulse response - a low-pass filter, $LFP \\ [0,20k]\\ [0,1]$, and a high-pass filter $HPF\\ [0,20k]\\ [0,1]$.\nIn order to quickly discover approximate values for each \\dspnode, we run an analysis of the frequencies present in the input example that have decreased in amplitude in the output example.\nTo describe the analysis, we write a formula that show how to find an initial threshold value for a lowpass filter in our synthesized code.\nWe use $t$ to represents the threshold of the lowpass filter, \\texttt{spectrogram} to represent a function that runs a FFT on a sound sample and returns a list of peaks, $f_i$ to represent a frequency, and \\texttt{amp()} to represent a function to retrieve the amplitude of the frequency. \n%\n\\begin{align*}\n&\\text{Given input audio }i\\text{ and output audio }o\\text{, find }t\\text{ such that} \\\\\n&\\forall f_1 \\in  \\texttt{spectrogram(i)}.\\ \\forall f_2 \\in \\texttt{spectrogram(o)}. \\\\\n&(f_1 > t \\land  f_2 > t \\land f_1 == f_2) \\implies \\texttt{amp}(f_1) > \\texttt{amp}(f_2)\n\\end{align*}\n\n\nSimilarly, we can build a formula to describe how to calculate an initial value for a high-pass.\nHere we look for the lowest frequency where amplitude has decreased in the output audio - this is then a starting point for the threshold of a high pass filter.\n%\n\\begin{align*}\n&\\text{Given input audio }i\\text{ and output audio }o\\text{, find }t\\text{ such that} \\\\\n&\\forall f_1 \\in \\texttt{spectrogram(i)}.\\ \\forall f_2 \\in \\texttt{spectrogram(o)}. \\\\\n&(f_1 < t \\land f_2 < t \\land f_1 == f_2) \\implies \\texttt{amp(}f_1\\texttt{)} > \\texttt{amp(} f_2 \\texttt{)} \n\\end{align*}\n\n\n\\subsection{Structural Synthesis}\n\n\\begin{figure}\n\\begin{align*}\n\tLPF \\ 10000 \\ 0.5 \\arrComp HPF \\ 100 \\ 0.5 & \\\\\n\t\\ldots & \\arrComp PitchShift \\ 0.1 \\ 0.1 \\\\\n\t\\ldots & \\parallelCompose PitchShift \\ 0.1 \\ 0.1 \\\\\n\t\\ldots & \\arrComp Reverb \\ 0.1 \\ 0 \\ 0.1 \\\\\n\t\\ldots & \\parallelCompose Reverb \\ 0.1 \\ 0 \\ 0.1 \\\\\n\t\\ldots & \\arrComp WhiteNoise \\ 0.1 \\\\\n\t\\ldots & \\parallelCompose WhiteNoise \\ 0.1\n\\end{align*}\n\\caption{New structural candidates are generated based on all compositions of unused \\dspnode}\n\\label{fig:generation}\n\\end{figure}\n\nDuring each loop of our synthesis procedure, we attempt to build a new structure based on the results of our previous attempts.\nWe compare several different variations on the current structure (Fig.~\\ref{fig:generation}).\nVariations are generated by composing all \\dspnode that are not present in the current structure with sequential and parallel composition onto the existing filter program returned from our metrical synthesis (cf. Sec.~\\ref{sec:opt}).\nWe keep the parameters for the existing \\dspnode, but for the new \\dspnode we initialize the parameters to small values.\nUsing small values (instead of zeroes) ensures that the filter has an observable effect on the sound.\nWe score each of these filter programs, $f$, by the distance, $\\distFxn(f(i), o)$, from their output to the output example file.\nWe then select the candidate filter program with the best score.\nWe continue this process until we either exceed our maximum allowed structural attempts or have reached a program whose output is close enough to the desired output.\n", "meta": {"hexsha": "411c4ca0b640217d9f316f6d04c8ed00c58938ec", "size": 4507, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/ISMIR2019/secs/struct.tex", "max_stars_repo_name": "Yale-OMI/DSP-PBE", "max_stars_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-03T02:36:39.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-03T02:36:39.000Z", "max_issues_repo_path": "papers/ISMIR2019/secs/struct.tex", "max_issues_repo_name": "Yale-OMI/DSP-PBE", "max_issues_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2018-11-16T21:50:44.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-16T18:57:19.000Z", "max_forks_repo_path": "papers/ISMIR2019/secs/struct.tex", "max_forks_repo_name": "Yale-OMI/DSP-PBE", "max_forks_repo_head_hexsha": "073f366e8096004adeec5d2cde1cf3546c4690f5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.6935483871, "max_line_length": 289, "alphanum_fraction": 0.7599289993, "num_tokens": 1169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.413712307502374}}
{"text": "\\breakpagebeforenextheadingtrue\n\\section{Implementation and Numerical Results}\n\\label{sec:73results}\n\n\\minitoc[0mm]{69mm}{8}\n\n\\parbox{1em}{}\n\\vspace{-3em}\n\n\n\n\\disableornamentsfornextheadingtrue\n\\subsection{Implementation}\n\\label{sec:731implementation}\n\n\\paragraph{Parameters, implementation, and geometry}\n\nDetails about implementational aspects of the model can be found in\n\\multicite{Sprenger15Continuum,Roehrle16Two,Valentin18Gradient},\nfor instance, values for the material parameters.\n%\nThe constitutive law has been implemented in the CMISS software package\n(an interactive computer program for Continuum Mechanics,\nImage analysis, Signal processing and System identification%\n\\footnote{%\n  \\url{https://www.cmiss.org/}%\n}).\nThe emerging PDEs are discretized using quadratic finite element basis\nfunctions and the resulting linearized system is solved with CMISS.\n%\nThe geometry of the human upper limb model is based on\nthe Visible Human Male's dataset \\cite{Spitzer96Visible}.\nAgain, we refer to \\multicite{Sprenger15Continuum,Roehrle16Two} for details\nabout the geometry.\n\n\n\n\\subsection{Reference and Sparse Grid Solution}\n\\label{sec:732solutionTypes}\n\n\\paragraph{Reference solution}\n\nSince the model is only two-dimensional, we can compute a reference solution\non a full grid.\nTo this end, we evaluate the exerted muscle forces $\\forceT$ and $\\forceB$ on\nthe full grid\n\\begin{equation}\n  \\{\\ang{10}, \\ang{11}, \\dotsc, \\ang{150}\\} \\times \\{0, 0.1, \\dotsc, 1\\}\n  \\ni (\\elbang, \\actX),\\quad\n  X \\in \\{\\mathrm{T}, \\mathrm{B}\\}.\n\\end{equation}\nThe resulting \\num{1551} grid points\nare interpolated with bicubic full grid splines%\n\\footnote{%\n  Computed with the Geometric Tools Engine \\cite{Schneider03Geometric},\n  see \\url{https://www.geometrictools.com/}.%\n}\nto obtain \\term{reference solutions}\n$\\forceTref, \\forceBref\\colon\n\\clint{\\ang{10}, \\ang{150}} \\times \\clint{0, 1} \\to \\real$,\nwhich are shown in \\cref{fig:biomech2ReferenceForce}.\nDue to the high resolution of the full grid,\nwe may assume that the reference solutions are accurate enough\nto ensure $\\forceTref \\approx \\forceT$ and $\\forceBref \\approx \\forceB$.\nWe refer to the resulting equilibrium elbow angle\nwith $\\equielbangref{\\forceL}$.\nIt is displayed in\n\\cref{fig:biomech2ReferenceEquilibriumAngle}\nfor the loads of $\\forceL = \\SI{22}{\\newton}$,\n$\\SI{-60}{\\newton}$, and $\\SI{180}{\\newton}$.\n\n\\begin{figure}\n  \\includegraphics{biomech2ReferenceForce_1}%\n  \\;\\;%\n  \\includegraphics{biomech2ReferenceForce_2}%\n  \\hfill%\n  \\rlap{\\raisebox{53mm}{\\;$\\forceXref$ [\\si{\\kilo\\newton}]}}%\n  \\includegraphics{biomech2ReferenceForce_3}%\n  \\caption[Reference triceps and biceps forces]{%\n    Reference triceps and biceps forces $\\forceXref$\n    ($X \\in \\{\\mathrm{T}, \\mathrm{B}\\}$).%\n  }%\n  \\label{fig:biomech2ReferenceForce}%\n\\end{figure}\n\n\\begin{figure}\n  \\includegraphics{biomech2ReferenceEquilibriumAngle_4}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{22}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ReferenceEquilibriumAngle_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{-60}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ReferenceEquilibriumAngle_2}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{180}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ReferenceEquilibriumAngle_3}%\n  }%\n  \\caption[Reference equilibrium elbow angle]{%\n    Reference equilibrium elbow angle $\\equielbangref{\\forceL}$\n    for different loads $\\forceL$.\n    The empty areas correspond to activation pairs\n    at which $\\equielbangref{\\forceL}$ is not well-defined\n    (see \\cref{eq:equilibriumAngle}).%\n  }%\n  \\label{fig:biomech2ReferenceEquilibriumAngle}%\n\\end{figure}\n\n\\paragraph{Sparse grid solution}\n\nAdditionally, we evaluate $\\forceT$ and $\\forceB$ at the $\\ngp = 49$\ngrid points\n\\begin{equation}\n  \\{(\\elbang^{(k,\\mathrm{unif})}, \\actX^{(k,\\mathrm{unif})}) \\mid\n  k = 1, \\dotsc, \\ngp\\}\n  \\subset \\clint{\\ang{10}, \\ang{150}} \\times \\clint{0, 1},\\quad\n  X \\in \\{\\mathrm{T}, \\mathrm{B}\\},\n\\end{equation}\nof the uniform regular sparse grid $\\interiorregsgset{n}{d}$ of\nlevel $n = 5$ in $d = 2$ dimensions\nwithout boundary points (to reduce the number of samples)\nand at the sparse Clenshaw--Curtis grid\n\\begin{equation}\n  \\{(\\elbang^{(k,\\cc)}, \\actX^{(k,\\cc)}) \\mid\n  k = 1, \\dotsc, \\ngp\\}\n  \\subset \\clint{\\ang{10}, \\ang{150}} \\times \\clint{0, 1},\\quad\n  X \\in \\{\\mathrm{T}, \\mathrm{B}\\},\n\\end{equation}\nof the same size and level.%\n\\footnote{%\n  The domain $\\clint{\\ang{10}, \\ang{150}} \\times \\clint{0, 1}$\n  is assumed to be implicitly normalized to the unit square\n  $\\clint{\\*0, \\*1}$.%\n}\nThese values are interpolated using three\ndifferent hierarchical B-spline bases of degree $p = 1$, $3$, and $5$:\nmodified hierarchical uniform B-splines\n$\\bspl[\\modified]{\\*l,\\*i}{p}$\n(see \\cref{sec:313modification}),\nmodified hierarchical Clenshaw--Curtis B-splines\n$\\bspl[\\cc,\\modified]{\\*l,\\*i}{p}$\n(see \\cref{sec:314nonUniform}), and\nmodified hierarchical uniform not-a-knot B-splines\n$\\bspl[\\nak,\\modified]{\\*l,\\*i}{p}$\n(see \\cref{sec:323modifiedNAKBSplines}).\nThe implementation was done using the sparse grid toolbox\n\\sgpp{} \\cite{Pflueger10Spatially}.%\n\\footnote{%\n  \\url{http://sgpp.sparsegrids.org/}%\n}\nThe corresponding interpolants and resulting quantities\nare denoted with the superscripts\n``$\\sparse,\\!p$'', ``$\\sparse,\\!p,\\!\\cc$'', or ``$\\sparse,\\!p,\\!\\nak$'',\nrespectively.\nA superscript of ``$\\sparse$'' without any further specification\nmeans one of the three hierarchical B-spline bases in general.\nNote that the equilibrium elbow angle is \\emph{not} interpolated\n(neither in the full grid nor in the sparse grid case),\nbut rather obtained by inserting the interpolated muscle forces\ninto \\eqref{eq:totalMomentSurrogate} and \\eqref{eq:equilibriumAngleSurrogate}.\n\n\n\n\\subsection{Errors of Muscle Forces and Equilibrium Angle}\n\\label{sec:733errors}\n\n\\paragraph{Quality of reference interpolants}\n\nBefore we turn to the sparse grid interpolants,\nwe assess the quality of the reference interpolants on the full grid.\nFor this purpose, we evaluate the full grid interpolants\n$\\forceTintp, \\forceBintp$\nat the sparse grid points $(\\elbang^{(k)}, \\actX^{(k)})$\n(which are not a subset of the full grid points!)\nand compare the resulting values with the known exact values\n$\\forceT(\\elbang^{(k)}, \\actT^{(k)})$ and\n$\\forceB(\\elbang^{(k)}, \\actB^{(k)})$\nof the muscle forces $\\forceT, \\forceB$.\nWe also incorporate the known values at the sparse\nClenshaw--Curtis grid points.\nIn particular, let $G$ be the union of\n$\\{(\\elbang^{(k,\\mathrm{unif})}, \\actX^{(k,\\mathrm{unif})}) \\mid\nk = 1, \\dotsc, \\ngp\\}$ and\n$\\{(\\elbang^{(k,\\cc)}, \\actX^{(k,\\cc)}) \\mid k = 1, \\dotsc, \\ngp\\}$.\nWe then approximate the relative $\\Ltwo$ interpolation error\nof the reference interpolants by\n\\begin{equation}\n  \\frac{\\normLtwo{\\forceX - \\forceXref}}{\\normLtwo{\\forceX}}\n  \\approx\n  \\frac{\n    \\setsize{G}^{-1/2}\n    \\norm[2]{\n      (\\forceX(\\elbang, \\actX) - \\forceXref(\\elbang, \\actX))_\n      {(\\elbang, \\actX) \\in G}\n    }\n  }{\n    \\setsize{G}^{-1/2}\n    \\norm[2]{(\\forceX(\\elbang, \\actX))_{(\\elbang, \\actX) \\in G}}\n  },\\quad\n  X \\in \\{\\mathrm{T}, \\mathrm{B}\\},\n\\end{equation}\nwhere $\\norm[2]{\\cdot}$ is the Euclidean norm.%\n\\footnote{%\n  We have $\\setsize{G} = 2\\ngp - 1$, since sparse grids of\n  uniform and Clenshaw--Curtis type only\n  share the center point $(\\elbang, \\actX) = (\\ang{80}, 0.5)$,\n  if there are no boundary points.%\n}\nAfter inserting the known values $\\forceX(\\elbang, \\actX)$ and\n$\\forceXref(\\elbang, \\actX)$ ($(\\elbang, \\actX) \\in G$)\non the right-hand side, %\\rhs\nwe obtain\n\\begin{equation}\n  \\frac{\\normLtwo{\\forceT - \\forceTref}}{\\normLtwo{\\forceT}}\n  \\approx \\SI{2.19}{\\permille},\\qquad\n  \\frac{\\normLtwo{\\forceB - \\forceBref}}{\\normLtwo{\\forceB}}\n  \\approx \\SI{2.06}{\\permille}.\n\\end{equation}\nThese errors are very small, which justifies our assumption of\n$\\forceTref \\approx \\forceT$ and $\\forceBref \\approx \\forceB$.\n\n\\paragraph{Error of sparse grid muscle forces}\n\n\\Cref{tbl:biomech2ErrorL2_1} contains the relative $\\Ltwo$\ninterpolation errors\n$\\normLtwo{\\forceXref - \\forceXintp}/\\normLtwo{\\forceXref}$\n($X \\in \\{\\mathrm{T}, \\mathrm{B}\\}$) of the sparse grid interpolants\nfor all hierarchical bases and degrees $p = 1, 3, 5$.\nAll reported errors are relatively small\ndue to the smoothness of the original functions\n(cf.\\ $\\forceXref$ in \\cref{fig:biomech2ReferenceForce}).\nAll in all, the modified Clenshaw--Curtis B-splines perform best,\nachieving relative $\\Ltwo$ errors of below \\SI{3.6}{\\permille}\nin the cubic case.\nSurprisingly, the not-a-knot B-splines are the worst choice in our\ncomparison.\nTheir corresponding errors exceed \\SI{1}{\\percent} for the triceps\nand $p > 1$.\nThe possible reasons are two-fold:\nFirst, there might be slight noise in the given muscle force data,\nwhich is visible in \\cref{fig:biomech2ReferenceForce},\nas there seems to be a kink in $\\forceBref$ at $\\elbang \\approx \\ang{25}$.\nSecond, the employed regular sparse grids might be too coarse\nas the higher convergence order of not-a-knot B-splines\nonly pays off in the asymptotic range (see \\cref{sec:541interpolation}).\nThe same observations hold for the degree $p$,\nfor which $p = 3$ seems to be the best choice,\nas the errors increase again for $p = 5$.\n\n\\begin{table}\n  \\newcommand*{\\bi}{$\\bspl[\\modified]{l,i}{p}$}\n  \\newcommand*{\\bii}{$\\bspl[\\cc,\\modified]{l,i}{p}$}\n  \\newcommand*{\\biii}{$\\bspl[\\nak,\\modified]{l,i}{p}$}\n  \\subcaptionbox{%\n    $\\normLtwo{\\forceXref - \\forceXintp}/\\normLtwo{\\forceXref}$\n    [\\si{\\permille}] given as triceps/biceps pairs\n    ($X \\in \\{\\mathrm{T}, \\mathrm{B}\\}$).%\n    \\label{tbl:biomech2ErrorL2_1}%\n  }[85.2mm]{%\n    \\setnumberoftableheaderrows{1}%\n    \\begin{tabular}{%\n      >{\\kern\\tabcolsep}=l<{\\kern2mm}%\n      +c<{\\kern-1mm}+c<{\\kern-1mm}+c<{\\kern\\tabcolsep}%\n    }\n      \\toprulec\n      \\headerrow\n      $p$&   $1$&                  $3$&                  $5$\\\\\n      \\midrulec\n      \\bi&   $3.60,7.12$&          $3.05,7.00$&          $\\mathbf{2.98},7.90$\\\\\n      \\bii&  $\\mathbf{3.28},4.35$& $3.31,\\mathbf{3.56}$& $3.35,3.64$\\\\\n      \\biii& $3.60,7.12$&          $3.09,10.0$&          $7.13,24.6$\\\\\n      \\bottomrulec\n    \\end{tabular}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\normLtwo{\\equielbangref{\\forceL} - \\equielbangintp{\\forceL}}/\n    \\normLtwo{\\equielbangref{\\forceL}}$\n    [\\si{\\permille}] for $\\forceL = \\SI{22}{\\newton}$.%\n    \\label{tbl:biomech2ErrorL2_2}%\n  }[59mm]{%\n    \\setnumberoftableheaderrows{1}%\n    \\begin{tabular}{%\n      >{\\kern\\tabcolsep}=l<{\\kern2mm}%\n      +c<{\\kern-1mm}+c<{\\kern-1mm}+c<{\\kern\\tabcolsep}%\n    }\n      \\toprulec\n      \\headerrow\n      $p$&   $1$&    $3$&             $5$\\\\\n      \\midrulec\n      \\bi&   $4.15$& $3.74$&          $3.72$\\\\\n      \\bii&  $3.42$& $\\mathbf{2.83}$& $2.86$\\\\\n      \\biii& $4.15$& $4.06$&          $8.28$\\\\\n      \\bottomrulec\n    \\end{tabular}%\n  }%\n  \\caption[Relative $L^2$ errors of forces and equilibrium elbow angle]{%\n    Relative $\\Ltwo$ errors of triceps/biceps force \\emph{(left)} and\n    equilibrium elbow angle \\emph{(right)}\n    for different hierarchical bases $\\basis{\\*l,\\*i}$ and\n    B-spline degrees $p$.\n    Highlighted entries are the best among those with\n    the same hierarchical basis or the same degree\n    (similar to Nash equilibria).%\n  }%\n  \\label{tbl:biomech2ErrorL2}%\n\\end{table}\n\n\\vspace{\\fill}\n\n\\Cref{fig:biomech2ErrorForce} shows the pointwise absolute error\n$\\abs{\\forceXref(\\elbang, \\actX) - \\forceXintp(\\elbang, \\actX)}$\nfor the modified B-splines $\\bspl[\\modified]{l,i}{p}$ and\n$\\bspl[\\cc,\\modified]{l,i}{p}$\non uniform and Clenshaw--Curtis grids in the cubic case $p = 3$.\nNote that in contrast to usual interpolation settings,\nthe absolute errors $\\abs{\\forceXref - \\forceXintp}$\nshown in \\cref{fig:biomech2ErrorForce} do not vanish at the\nsparse grid points $(\\elbang^{(k)}, \\actX^{(k)})$\n($X \\in \\{\\mathrm{T}, \\mathrm{B}\\}$, $k = 1, \\dotsc, \\ngp$),\nsince $\\forceXintp$ does not interpolate $\\forceXref$\nat these points.%\n\\footnote{%\n  It would have been possible to construct $\\forceXintp$\n  as a sparse grid interpolant of $\\forceXref$.\n  However, building a spline surrogate ($\\forceXintp$)\n  of another spline surrogate ($\\forceXref$) would skew the results.%\n}\nAs it is typical for (modified) sparse grid interpolants,\nthe error is the largest near the boundary of the domain.\nHowever, the Clenshaw--Curtis points help to decrease the error\ndue to the higher density of grid points near the boundary.\nIn the Clenshaw--Curtis case, the maximal errors are\n\\begin{equation}\n  \\normLinfty{\\forceTref - \\forceTintp[p,\\cc]}\n  \\approx \\SI{10.6}{\\newton},\\qquad\n  \\normLinfty{\\forceBref - \\forceBintp[p,\\cc]}\n  \\approx \\SI{9.51}{\\newton},\n\\end{equation}\nwhere $\\normLinfty{\\forceXref - \\forceXintp[p,\\cc]}\n\\ceq \\max_{(\\elbang, \\actX)}\n\\abs{\\forceXref(\\elbang, \\actX) - \\forceXintp[p,\\cc](\\elbang, \\actX)}$\n(since the functions are continuous).\nIf we restrict the domain to\n$\\clint{\\ang{31}, \\ang{129}} \\times \\clint{0.15, 0.85}$\nby omitting \\SI{15}{\\percent} on each side of the original domain,\nthen the maximal absolute errors drop to only\n\\SI{6.73}{\\newton} (triceps) and \\SI{0.967}{\\newton} (biceps),\nwhich is small compared to maximal possible forces of\naround \\SI{1}{\\kilo\\newton}.\n\n\\begin{figure}\n  \\includegraphics{biomech2ErrorForce_7}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    $\\abs{\\forceXref - \\forceXintp[p]}$ for\n    $X = \\mathrm{T}$ \\emph{(left)} and\n    $X = \\mathrm{B}$ \\emph{(right).}%\n  }[74mm]{%\n    \\includegraphics{biomech2ErrorForce_1}%\n    \\hfill%\n    \\includegraphics{biomech2ErrorForce_2}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\abs{\\forceXref - \\forceXintp[p,\\cc]}$ for\n    $X = \\mathrm{T}$ \\emph{(left)} and\n    $X = \\mathrm{B}$ \\emph{(right).}%\n  }[74mm]{%\n    \\includegraphics{biomech2ErrorForce_3}%\n    \\hfill%\n    \\includegraphics{biomech2ErrorForce_4}%\n  }%\n  \\caption[Absolute error of muscle forces]{%\n    Absolute error of muscle forces $\\forceT, \\forceB$ for\n    modified cubic B-splines ($p = 3$)\n    on sparse grids of uniform type \\emph{(left two plots)} and\n    of Clenshaw--Curtis type \\emph{(right two plots)}\n    together with the points of the sparse grid \\emph{(dots).}%\n  }%\n  \\label{fig:biomech2ErrorForce}%\n\\end{figure}\n\n\\pagebreak\n\n\\paragraph{Error of the equilibrium elbow angle}\n\nThe relative $\\Ltwo$ errors\n$\\normLtwo{\\equielbangref{\\forceL} - \\equielbangintp{\\forceL}}/\n\\normLtwo{\\equielbangref{\\forceL}}$\nof the equilibrium elbow angle function are shown in\n\\cref{tbl:biomech2ErrorL2_1} for the load of\n$\\forceL = \\SI{22}{\\newton}$.\nModified cubic Clenshaw--Curtis B-splines achieve the best results.\nTherefore, we use this type of hierarchical basis\nfor the remainder of this chapter.\nPointwise plots of the absolute error\n$\\abs{\\equielbangref{\\forceL} - \\equielbangintp[p,\\cc]{\\forceL}}$\nare presented in \\cref{fig:biomech2ErrorEquilibriumAngle}.\nAgain, the maximal error is comparatively small:\nFor $\\forceL = \\SI{22}{\\newton}$, it is only \\ang{0.886}.\nIf we restrict the domain to $\\clint{0.15, 0.85}^2$,\nthen this maximal error drops to \\ang{0.103} (or \\ang{;6.18;}),\nas the areas near the boundary of $\\clint{\\*0, \\*1}$\ncontribute the most to the error.\n\n\\begin{figure}\n  \\includegraphics{biomech2ErrorEquilibriumAngle_5}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{22}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ErrorEquilibriumAngle_1}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{-60}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ErrorEquilibriumAngle_2}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\forceL = \\SI{180}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ErrorEquilibriumAngle_3}%\n  }%\n  \\caption[Absolute error of the equilibrium elbow angle]{%\n    Absolute error\n    $\\abs{\\equielbangref{\\forceL} - \\equielbangintp[p,\\cc]{\\forceL}}$\n    of the equilibrium elbow angle for\n    modified hierarchical cubic Clenshaw--Curtis B-splines ($p = 3$)\n    for different loads $\\forceL$.\n    In the empty areas, at least one of\n    $\\equielbangref{\\forceL}$ and $\\equielbangintp[p,\\cc]{\\forceL}$\n    is not well-defined (see \\cref{eq:equilibriumAngle}).%\n  }%\n  \\label{fig:biomech2ErrorEquilibriumAngle}%\n\\end{figure}\n\n\n\n\\subsection{Test Scenario}\n\\label{sec:734scenario}\n\n\\paragraph{Definition of the test scenario}\n\nIn the following, we want to assess the performance\nof the sparse grid interpolants for the optimization problems\n\\ref{item:biomech2MinSum} and \\ref{item:biomech2MinDist}.\nFor this goal, we create a test scenario \\cite{Valentin18Gradient}\nthat simulates a pseudo-dynamic sequence of motions\nby varying the load force and/or the target elbow angle\nin discrete time steps $t$ as seen in \\cref{fig:biomech2ScenarioA_1}.\nThe test scenario is as follows:\n%\n\\begin{figure}\n  \\includegraphics{biomech2ScenarioA_5}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    Load $\\forceL$ and target elbow angle $\\tarelbang$.%\n    \\label{fig:biomech2ScenarioA_1}%\n  }[73.3mm]{%\n    \\hspace*{4.5mm}%\n    \\includegraphics{biomech2ScenarioA_1}%\n    \\hspace*{2.4mm}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    Optimal activation parameters $\\actT$ and $\\actB$.%\n    \\label{fig:biomech2ScenarioA_2}%\n  }[73.3mm]{%\n    \\hspace*{0.0mm}%\n    \\includegraphics{biomech2ScenarioA_2}%\n    \\hspace*{9.8mm}%\n  }%\n  \\\\[1mm]%\n  \\subcaptionbox{%\n    Deviation $\\abs{\\equielbang{\\forceL} - \\tarelbang}$\n    of attained elbow angle to target and\n    deviation \\smash{$|\\momentref|$} of the moment from equilibrium.%\n    \\label{fig:biomech2ScenarioA_3}%\n  }[73.3mm]{%\n    \\includegraphics{biomech2ScenarioA_3}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    Number of evaluations of $\\equielbang{\\forceL}$\n    and number of Newton iterations per evaluation\n    of $\\equielbang{\\forceL}$.%\n    \\label{fig:biomech2ScenarioA_4}%\n  }[73.3mm]{%\n    \\includegraphics{biomech2ScenarioA_4}%\n  }%\n  \\caption[Settings and results of the test scenario]{%\n    Setting (a) of the test scenario and corresponding results (b, c, d).%\n  }%\n  \\label{fig:biomech2ScenarioA}%\n\\end{figure}\n%\n\\begin{enumerate}\n  \\item\n  Find a feasible initial solution for problem \\ref{item:biomech2MinSum}\n  with $\\forceL(t_0) \\ceq \\SI{22}{\\newton}$ and\n  $\\tarelbang(t_0) \\ceq \\ang{75}$.\n  \n  \\item\n  Apply \\ref{item:biomech2MinSum} with $\\forceL(t_1) \\ceq \\SI{22}{\\newton}$ and\n  $\\tarelbang(t_1) \\ceq \\ang{75}$.\n  \n  \\item\n  Apply \\ref{item:biomech2MinDist} with $\\forceL(t_2) \\ceq \\SI{22}{\\newton}$ and\n  $\\tarelbang(t_2) \\ceq \\ang{60}$ (changed target angle).\n  \n  \\item\n  Apply \\ref{item:biomech2MinDist} with $\\forceL(t_3) \\ceq \\SI{30}{\\newton}$ and\n  $\\tarelbang(t_3) \\ceq \\ang{60}$ (changed load).\n  \n  \\item\n  Apply \\ref{item:biomech2MinDist} with $\\forceL(t_4) \\ceq \\SI{40}{\\newton}$ and\n  $\\tarelbang(t_4) \\ceq \\ang{50}$ (changed load and target angle).\n\\end{enumerate}\n%\nFor each of the steps 2 to 5, the activation levels $\\actT, \\actB$ obtained\nin the previous step (i.e., either the feasible initial solution\nof step 1 or the optimal solution of steps 2 to 4) are used\nas the input of the optimization problem\n\\ref{item:biomech2MinSum} or \\ref{item:biomech2MinDist}.\nThe feasible initial solution in step 1 is determined as explained\nin \\cref{sec:513gradientBasedConstrained}.\n\n\\paragraph{Solutions of problem \\ref{item:biomech2MinSum}}\n\nWe note that independently of $\\forceL$ and $\\tarelbang$,\nevery solution $(\\actT, \\actB)$ of problem \\ref{item:biomech2MinSum} will be\non the boundary part of the domain $\\clint{\\*0, \\*1}$,\non which at least one activation parameter vanishes, i.e.,\n\\begin{equation}\n  \\{(\\actT, \\actB) \\in \\clint{\\*0, \\*1} \\mid\n  (\\actT = 0) \\lor (\\actB = 0)\\}.\n\\end{equation}\nThe reason is that the two muscles triceps and biceps are antagonistic\n(see \\cref{sec:711models}), meaning that they work against each other.\nIf both $\\actT > 0$ and $\\actB > 0$, then the body will waste energy,\nas the same target elbow angle can be attained by reducing both\n$\\actT$ and $\\actB$ simultaneously, thus requiring less energy.\nA visual example for this is \\cref{fig:biomech2ReferenceEquilibriumAngle},\nwhere the contour lines generally go from the bottom left\n(small $\\actT, \\actB$) to the top right (large $\\actT, \\actB$).\nThis issue may be prevented by either\nmore complicated musculoskeletal models with more\nthan two muscles or different optimization problems\nsuch as problem \\ref{item:biomech2MinDist},\nwhere the objective function differs.\n\n\\paragraph{Plots of optimization results}\n\n\\Cref{fig:biomech2ScenarioA_2,fig:biomech2ScenarioA_3,fig:biomech2ScenarioA_4}\nshow the results of the test scenario using the muscle forces\n$\\forceXintp[p,\\cc]$ obtained by interpolating with\nmodified hierarchical cubic Clenshaw--Curtis B-splines (solid lines, $p = 3$).\nAs comparison, we repeat the solution process\nwith the forces obtained by interpolating with the\ncorresponding hierarchical piecewise linear basis (dashed lines, $p = 1$) and\nwith the reference forces $\\forceXref$ (dotted lines).\nFor the piecewise linear basis,\nwe use exactly the same method as for the cubic case\n(Newton method for $\\equielbangintp{\\forceL}$,\nAugmented Lagrangian with adaptive gradient descent for the\nsolution of problems \\ref{item:biomech2MinSum} and \\ref{item:biomech2MinDist}),\nalthough the derivatives of the muscle forces are discontinuous.\nFor the reference forces, we use the fact that the reference surrogates\nare full grid spline interpolants, which can be explicitly differentiated.\nWithout the full grid interpolants,\nwe would have to approximate the derivatives with finite differences.\n\n\\vspace*{\\fill}\n\\pagebreak\n\n\\paragraph{Equilibrium elbow angle}\n\nIn \\cref{fig:biomech2ScenarioA_2}, we see that the activation levels\nof all three methods are more or less the same.\nHowever, \\cref{fig:biomech2ScenarioA_3} reveals that even these small\ndifferences lead to deviations of the resulting equilibrium elbow angle\nto the target angle that differ by up to two orders of magnitude.\nThe two green lines with filled markers at the bottom of\n\\cref{fig:biomech2ScenarioA_3} show the error of\nthe equilibrium elbow angle $\\equielbangintp{\\forceL}$\nusing sparse grid interpolation to the desired target angle $\\tarelbang$.\nUnsurprisingly, this error is very small as\nit is minimized by the optimizer as part of the constraint.\nThe true error, which is obtained by\nusing the reference equilibrium elbow angle $\\equielbangref{\\forceL}$,\nis in general much larger\n(top two green lines in \\cref{fig:biomech2ScenarioA_3}\nwith hollow markers).\nWe see that the cubic B-splines decrease the error\nby up to two orders of magnitude compared to the\npiecewise linear basis.\nThere are two reasons for this:\nFirst, the error of $\\equielbang{\\forceL}$ is generally smaller\nwhen using higher-order B-splines as we have seen above.\nSecond, higher-order B-splines are continuously differentiable,\nwhich makes them suitable for gradient-based optimization.\nIn contrast, the surrogates obtained by piecewise linear interpolation\nhave kinks, which may complicate finding optimal points\nin the augmented Lagrangian and Newton methods.\n\n\\paragraph{Number of evaluations and Newton iterations}\n\nThis is supported by \\cref{fig:biomech2ScenarioA_4},\nwhich shows the number of evaluations of $\\equielbang{\\forceL}$\nduring the optimization and the average number of Newton iterations\nper evaluation.\nWhile the number of total evaluations is similar for all three methods,\nthe number of required Newton iterations to achieve convergence\nis in general around \\SI{50}{\\percent} larger for the piecewise linear\nbasis functions.\n\n\n\n\\subsection{Spatial Adaptivity}\n\\label{sec:735adaptivity}\n\n\\paragraph{Generation of a spatially adaptive sparse grid}\n\nAs mentioned in \\cite{Valentin18Gradient}, spatial adaptivity\nmay be employed to reduce the number of necessary muscle force samples\neven further,\nespecially for more complicated musculoskeletal systems with\nmore parameters.\nTo verify this statement, we remove all grid points\n$(\\elbang^{(k,\\cc)}, \\actX^{(k,\\cc)})$\nfrom the regular sparse Clenshaw--Curtis grid that satisfy\n\\begin{equation}\n  \\frac{\n    \\abs{\\alpha_\\mathrm{T}^{(k,p,\\cc)}}\n  }{\n    \\max_{k'} \\abs{\\alpha_\\mathrm{T}^{(k',p,\\cc)}}\n  } < \\SI{1}{\\percent}\n  \\quad\\text{and}\\quad\n  \\frac{\n    \\abs{\\alpha_\\mathrm{B}^{(k,p,\\cc)}}\n  }{\n    \\max_{k'} \\abs{\\alpha_\\mathrm{B}^{(k',p,\\cc)}}\n  } < \\SI{1}{\\percent},\n\\end{equation}\nwhere $\\alpha_X^{(k,p,\\cc)}$ ($X \\in \\{\\mathrm{T}, \\mathrm{B}\\}$)\nis the hierarchical surplus of the basis function $\\bspl[\\cc,\\modified]{k}{p}$\ncorresponding to $(\\elbang^{(k,\\cc)}, \\actX^{(k,\\cc)})$.\nFor higher-dimensional models,\none would of course not sample muscle data on a regular sparse grid\nand then coarsen the data by removing points,\nbut rather use an a posteriori adaptivity criterion to\ndecide which grid points to refine iteratively.\n\n\\paragraph{Comparison with the regular case}\n\nFor the cubic case $p = 3$,\nthe resulting force interpolants $\\forceXintp[p,\\cc,\\mathrm{adap}]$ together\nwith the spatially adaptive sparse grid\n(which has been coarsened from 49 to 28 points) and\nequilibrium elbow angle $\\equielbangintp[p,\\cc,\\mathrm{adap}]{\\forceL}$\nfor $\\forceL = \\SI{22}{\\newton}$ are shown in\n\\cref{fig:biomech2SpatiallyAdaptive}.\nThe sparse grid is almost dimensionally adaptive,\nas $\\forceXref$ seems to be almost linear in the $\\actX$ direction\nfor both $X = \\mathrm{T}$ and $X = \\mathrm{B}$.\nThe errors increase slightly:\nThe relative $\\Ltwo$ force errors for $(\\mathrm{T}, \\mathrm{B})$ increase\nfrom $(\\SI{3.31}{\\permille}, \\SI{3.56}{\\permille})$\nto $(\\SI{3.36}{\\permille}, \\SI{4.43}{\\permille})$,\nand the absolute $\\Linfty$ errors increase\nfrom $(\\SI{10.6}{\\newton}, \\SI{9.51}{\\newton})$\nto $(\\SI{12.3}{\\newton}, \\SI{9.57}{\\newton})$.\nIn addition, the relative $\\Ltwo$ and absolute $\\Linfty$ errors\nfor $\\equielbang{\\forceL}$ increase\nfrom \\SI{2.83}{\\permille} and \\ang{0.886}\nto \\SI{4.12}{\\permille} and \\ang{1.09}, respectively.\nWhile all these errors are somewhat larger than for the regular sparse grid,\nthey are still at an acceptable level,\nbut the number of necessary muscle force evaluations is halved compared\nto the regular case.\nAdditionally, the solution of the test scenario doesn't change significantly\ndue to the similar errors of $\\forceX$ and $\\equielbang{\\forceL}$.\n\n\\begin{figure}\n  \\hspace*{2mm}%\n  \\raisebox{0.2mm}{\\includegraphics{biomech2ErrorForce_8}}%\n  \\hspace*{12mm}%\n  \\includegraphics{biomech2ErrorEquilibriumAngle_6}%\n  \\\\[2mm]%\n  \\subcaptionbox{%\n    $\\abs{\\forceTref - \\forceTintp[p,\\cc,\\mathrm{adap}]}$%\n  }[49mm]{%\n    \\raisebox{1.02mm}{\\includegraphics{biomech2ErrorForce_5}}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\abs{\\forceBref - \\forceBintp[p,\\cc,\\mathrm{adap}]}$%\n  }[49mm]{%\n    \\raisebox{1.02mm}{\\includegraphics{biomech2ErrorForce_6}}%\n  }%\n  \\hfill%\n  \\subcaptionbox{%\n    $\\abs{\n      \\equielbangref{\\forceL} - \\equielbangintp[p,\\cc,\\mathrm{adap}]{\\forceL}\n    }$\n    for $\\forceL = \\SI{22}{\\newton}$%\n  }[49mm]{%\n    \\includegraphics{biomech2ErrorEquilibriumAngle_4}%\n  }%\n  \\caption[%\n    Errors of muscle forces and equilibrium angle\n    for the spatially adaptive case%\n  ]{%\n    Errors of muscle forces and equilibrium elbow angle\n    for the spatially adaptive case\n    (modified hierarchical cubic Clenshaw--Curtis B-splines,\n    i.e., $p = 3$) together with the points of the\n    spatially adaptive sparse grid \\emph{(dots).}%\n  }%\n  \\label{fig:biomech2SpatiallyAdaptive}%\n\\end{figure}\n", "meta": {"hexsha": "cc2554438b4e531a8f9b862d11beb5505805e5b9", "size": 27334, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/document/73results.tex", "max_stars_repo_name": "valentjn/thesis", "max_stars_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-01-15T19:50:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T20:16:10.000Z", "max_issues_repo_path": "tex/document/73results.tex", "max_issues_repo_name": "valentjn/thesis", "max_issues_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/document/73results.tex", "max_forks_repo_name": "valentjn/thesis", "max_forks_repo_head_hexsha": "65a0eb7d5f7488aac93882959e81ac6b115a9ea8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.3415300546, "max_line_length": 80, "alphanum_fraction": 0.7078729787, "num_tokens": 8873, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389325, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.41371230750237387}}
{"text": "\\section{Quantum Phases of Gapped Hamiltonians}\nRevision.\nThere are two definitions of phase.\n\nThe first one is this:\n$H_1$, $H_2$ are in the same quantum ($T=0$) phase of matter\nif and only if\nwe have a continuous parameter $\\lambda$ and a path connecting them such that\n$H(\\lambda)$ stays open.\n\nThe second definition is the traditional thermodynamics definition.\n$H_1$ and $H_2$ are in the same phase if and only if\nthere is a path $H(\\lambda)$ such that\n\\begin{align}\n    \\lim_{N\\to\\infty} \\frac{E(\\lambda)}{N}\n\\end{align}\nis smooth.\n\nThe third definition is this:\n$H_1$ and $H_2$ are the same phase if and only if\nthere is a path $H(\\lambda)$\nwith ground states $\\ket{\\psi_i(\\lambda)}$\nsuch that the ground state expectation value\n${\\langle\\mathcal{O}\\rangle}_{\\lambda}$\nis a smooth function of $\\lambda$ for every local operator $\\mathcal{O}$.\n\nSome remarks:\n\\begin{itemize}\n    \\item We will use (1)\n    \\item (2) is the usual thermodynamic definition in terms of free energy\n        density.\n    \\item (2) and (3) apply for gapless systems.\n\\end{itemize}\n\nThere is a conjecture.\n\\begin{conjecture}\n    If $H(\\lambda)$ remains gapped,\n    then ${\\langle\\mathcal{O}\\rangle}_{\\lambda}$\n    is a smooth function of $\\lambda$.\n\\end{conjecture}\nThis implies that if two phases are the same according to (1)\nthen they are also different according to (3).\n\n\\section{Constant Depth Circuits}\nYou can have two states in the same phase\nbut they might not be related by a constant depth local circuit.\n\nWe have a bunch of local gates that act on our qubits.\nLocal quantum circuit is a circuit where each layer has gates with finite\nsupport locally.\nIt is a composition of these layers.\nConstant depth means that the number of layers is less than a constant as the\nsize goes to infinity.\n\nLet $U$ be a constant depth local unitary circuit.\nIf $\\ket{\\psi}$ is the ground state of some Hamiltonian $H$,\nthen $U\\ket{\\psi}$ is in the same phase.\n\nHowever, it is not true that if I have two states $\\ket{\\psi_1}$ and\n$\\ket{\\psi_2}$ \nthen $\\ket{\\psi_1} = U\\ket{\\psi_2}$.\n\nAn example of this is the following.\nSuppose $\\ket{\\psi_1}$ is a product state.\nThe correlations must be exactly zero beyond a certain range,\nbecause it cannot create correlations beyond a certain distance $\\xi$ in space\nthat has to do with the gates and range.\n\nIf you have one state which is a trivial phase of matter\nbut correlations have exponentially decaying tails,\nyou cannot go to one with $U$.\n\nYou can fix this by allowing the notaries have tails,\nbut then it's tricky\nand I've never seen anyone made this work.\nIt's not that useful.\nIf only useful to show two states are in the same state.\n\nIf you allow logarithmic depth,\nyou can connect states that are in different phases\nand that's too much.\n\nOne hope would be to give up the fact you want it to be exactly\n$\\ket{\\psi_1} = U\\ket{\\psi_2}$\nand make it constant error instead.\n\nIn particular,\nif you have a gapped ground state $\\ket{\\psi_1}$\nand this unitary circuit $U$,\nthen there should be an adiabatic path between the Hamiltonians,\nand you should be able to construct that unitary path\ngiven this circuit.\n\nOne more point is that you can add symmetry to the problem.\nIf you assume the problem has symmetry,\nthen you must make sure that whole path respects the symmetry.\nFor example,\nquantum hall phases have paths that are sometimes incompatible with\ntime-reversal symmetry.\n\nWhen you add symmetry,\nyou end up splitting into many phases that cannot be connected by\nsymmetry-respecting paths.\n\n\\section{Topology in Gapped Ground States}\nNow let's connect this to the mathematical structure of TQFT.\n\nHere is some gapped phase of matter,\nbut where is the topology?\n\nThe properties robust to arbitrary perturbations.\n\nUniversal properties that distinguish different phases are usually characterised\nby TQFTs.\nOn the one hand,\nI can think of gapped quantum phases of matter.\nThe idea is that as far as we know, although there's no proof,\nthese are in one-to-one correspondence with deformation classes of TQFTs.\n\nThis statement as I said it is not quite right,\ndepending on how you define TQFT.\nWe believe this is true in $1+1$ and $2+1$ spacetime dimensions,\nbut in higher dimensions,\nyou could have more complicated things happening.\n\nTopological liquids are interesting.\nThere is the space of all gapped phases of matter.\nThen inside this space,\nthere are topological liquids\nwhich have one-to-one correspondence with deformation classes of TQFTs.\nWhereas gapped phases for $D\\ge 3 + 1$,\nwe're not really sure,\nbut we thin they are in one-to-one correspondence with\ndeformation classes of TQFTs with \\emph{defect networks}.\n\nThe mathematical structure TQFT has a log of topology.\nThey essentially classify gapped phases of matter with some caveats.\nTQFTs may come with continuous parameters.\nYou have to be really careful what these objects are.\n\n\\begin{question}\n    What are deformation classes?\n\\end{question}\nA TQFT $\\mathcal{T}_\\lambda$ can be split up into spaces and points.\nYou could have some theory $\\mathcal{T}^1_\\lambda$ for some continuous parameter\n$\\lambda$,\nyou could have another one $\\mathcal{T}^2_\\lambda$\nand then you have some which are just points $\\mathcal{T}^3_\\lambda$, etc.\n\nThat there are TQFTs without lattice descriptions,\nsome TQFTs do not have an exact lattice description.\nEvery TQFT useful for gapped phases of matter\ncan arise from some microscopic description on a lattice.\nIt might not be exactly solvable.\n\nThe rough intuition is that if you want to define TQFTs,\nyou want to make sure all quantities that come up are\ntopological invariants.\nIf you use triangulation of the space you're describing,\nit should be independent of the triangulation.\nSome gapped phases of matter require you to specify some microscopic geometry,\nand you can't avoid it.\n\nThere's nothing outside of topological liquids outside of 1 and 2 spatial\ndimensions,\nbut in 3 dimensions it's weird and clever.\n\n\\section{Topological Quantum Field Theory Basics}\nI want to give you the plain vanilla version.\nThe discussion is abstract and mathematical,\nbut it's worth doing before moving into examples.\n\nI want to tell you some basics of TQFTs.\nI want to talk about ``plain'' TQFT,\nbut there are additives like oriented and unitary.\nI will tell you the plain TQFT and then soup it up.\n\nTQFT is this really amazing and intricate math structure that \\emph{emerges} out\nof some messy quantum many-body system with an energy gap.\nIt's not obvious why it should emerge from a gapped quantum many-body system.\n\nTo me, it's an absolutely amazing and profound thing.\nYou can have something so mathematically rich just emerge from some quantum\nmany-body system.\nWhat I'm going to discuss are the \\emph{Atiyah's axioms}.\nAtiyah is one of the foremost mathematicians of the century\nwho died recently.\nWhen discussing with Witten,\nAtiyah saw what Witten was doing and axiomised it.\nSo it listed some axioms TQFTs should satisfy.\nSo it is an axiomatic framework that describes TQFTs.\nOne interesting aspect is that it is a way of defining a restricted class of\nQFTs in a rigorous fashion.\nIn QFT, you have problems with lattice discretisation and perturbation theory.\nBut TQFT can be mathematically rigorously defined and used in physics,\nso it's beautiful common ground.\n\nThese Atiyah axioms are related to some other axioms proposed at around the same\ntime, including those by Segal,\nwho was trying to define 2D \\emph{conformal field theory} axioms,\nwhich has a lot more structure that TQFTs.\n\nThese are useful for eventually giving a rigorous definition of quantum field\ntheory.\nA few months ago there was an article in Quanta magazine about the mathematical\nproblem of defining QFT.\\@\nHow do you define a QFT,\nno one really knows.\nTQFT might be useful.\n\n\\begin{question}\n    What's the problem with QFT?\\@\n\\end{question}\nWe know how to rigorously define free field theory.\nWe know how to rigorously define perturbation theory of free field theory.\nThere was this whole program of axiomatic quantum field theory in the late 20th\ncentury that never became useful and cannot capture what we know.\nWe can't understand 2D CFT from the ideas that we had.\nYou need a whole new set of tools,\nlike operators algebras, a complicated story.\nYou can rigorously define some aspects of simple QFTs\nbut people are after something more broad\nthat can explain all the things we know about all the QFTs we know.\n\nI'm not going to say anything mathematically complicated.\nFeel free to say if you don't understand some mathematical terminology,\ndon't be shy.\n\nThere's an abstract definition of plain vanilla TQFT.\n\\begin{definition}\n    A $(d+1)$-dimensional TQFT is is a symmetric monoidal functor\n    between two categories $\\mathcal{F}: \\mathrm{Cob}_{d + 1}\\to \\mathrm{Vec}$.\n\\end{definition}\n\n$\\Cob_{d + 1}$ is a tensor category of $(d + 1)$-dimensional cobordisms.\n\nA \\emph{category} is a mathematical structure that consists of objects\nand \\emph{morphisms} between objects.\nAt a naive level,\nit's a set of objects and arrows between objects called morphisms.\nAnd this is a 1-category.\nIn our case,\nobjects of $\\Cob_{d + 1}$ are $d$-dimensional closed manifolds\nand a morphism between two objects,\nwhich are $d$-dimensional manifolds,\nsay from $\\Sigma_1^d\\to\\Sigma_2^d$,\nis a $(d+1)$-dimensional manifold $M^{d+1}$\nsuch that its boundaries are $\\Sigma_1^d$ and $\\Sigma_2^d$,\ni.e.\n$\\partial M^{d + 1} = \\Sigma_1^d\\sqcup \\bar{\\Sigma}_2^d$.\n\nLet's do an example $\\Sigma_2 = S^1$, which is a circle\nand we have a cobordism to $\\Sigma_1 = S^1\\sqcup S^1$.\nA morphism looks like this\n[picture of pair of pants]\nThe manifold $M^{d+1}$ is called a (co)-bordism\nfrom $\\Sigma_1^d$ to $\\Sigma_2^d$.\nBord means boundary in French.\nThe point is that if you hae two manifolds,\nand if you can go from one another in a highr-dimensional manifold,\nthen that's a bordism, sometimes called a co-bordism.\n\n\\begin{question}\n    So there's nothing differnt betwen cobordism and bodirsm?\n\\end{question}\nTwo words for the same hting,\nbut in some cnotexts,\nthey'll call maps from this into $U(1)$ as a cobordism.\nMahtematicians do yuse oth interchangably.\n\n\\begin{question}\n    Can you go other that such that clause?\n    What is $\\sqcup$?\n\\end{question}\nObjects of this category are $d$-dimensiona closed manifiolds.\nA morphism is a way to gor from one objcet toa nother.\nA cobordism is a $d+1$-dimeisional manifold with boundaries that are the\nobjects.\nIt's disjoint union.\n\n\\begin{question}\n    Category of sets, category of topological sets.\n    Weird notation?\n\\end{question}\nObjects of Vec are vector spaces and the morphisms are maps betwene vector\nspaces, so it is a bit weird.\n\n\\begin{question}\n    Are there some topological properties?\n\\end{question}\nIf two manifolds are bordred with each other,\nit just means they're boundaries of some higher-dimesional manifold,\nbut that's about it.\n\n\\begin{question}\n    Are two manifolds always connected by a $(d+1)$-dimensional manifolds?\n\\end{question}\nNo, there's a cobordism group notion,\ngroup by equivalence classes based on whether there is a cobordism betwen them.\n\nEvery 2D manifold is related to every 2D manifold,\nso that's trivial,\nbut it's not true in higher-dimensional space.\n\n\\begin{question}\n    What are the points in between?\n\\end{question}\nA morphism here is this higher dimensional manifold.\n\nFor every object, there may or may not be a morphism between them.\n\nIt's more than a map.\nThe TQFT gives a map, but $\\mathrm{Cob}_{d+1}$ is the whole manifold.\n\n\n\\begin{question}\n    What is a tensor category?\n\\end{question}\nI'll come back to that.\n\n\\begin{question}\n    What is they're not circles but spheres?\n    What does that look like?\n\\end{question}\nYou want me to draw in 4D?\\@\n\nYou have $\\Sigma_1^2 = S^2 \\sqcup S^2$ and\n$\\Sigma_2^2=S^2$.\nThen the bordism is\n$M^3 = B^3\\sqcup (S^2\\times I)$\nand the boundary is\n$\\partial M^3 = S^2 \\sqcup (S^2 \\times S^2)$\n\n\\begin{question}\n    Does the cobordism have to be connected?\n\\end{question}\nNo, it doesn't have to connected.\nThere are many possible morphisms between objects.\n\n\\begin{question}\n    Can you give an example of what these objects are physically?\n\\end{question}\nTo some extent I can,\nbut it's related to why a miracle TQFT emerges out of a system.\nII haven't gotten there yet.\nI can define stuff on all kinds of spacetime manifolds.\nI'm going to define stuff for eveyr $(d+1)$-dimensional spacetime manifodls.\nBut Condensed matter systmes don't have spacetime,\nonly time and space the system lives on.\nIt's hard to give examples which use all this technology irght now.\nBut a simple example is this.\nActually, hold that question until I get further.\nLet me define a few things about it and then I'll try to address your question.\n\n\nThe next thing is the tensor category.\nTensor means there's a notion of a tensor product here.\nThere is a tensor product betwene objects\n$\\Sigma_1\\otimes\\Sigma_2$.\nI need to give a meaning for tensor product,\nwhich I say is just the disjoint union.\n$\\Sigma_1 \\otimes \\Sigma_2 := \\Sigma_1 \\sqcup \\Sigma_2$.\nNow I need to define $\\mathrm{Vec}$, which is a tensor category.\nObjects are finite-dimensional vector spaces of $\\mathbb{C}$.\nMorphisms are linear maps between vector spaces.\n\nIn our case,\nbecause we're doing \\emph{unitary} TQFT,\nwe want these linear maps to be unitary maps.\nActually, no unitary for now, we'll add it later.\nThe tensor aspect should be obvious.\nThe tensor product is just the tensor product of vector spaces.\n\nA functor is just a map between categories.\nFor every object on the left side,\nI have an object on the right side.\nAnd for every morphism on the left I have on on the right.\nMonoidal means it respects the tensor product on the left and right side.\nSymmetric means it applies the same on each side.\n\nWhat the TQFT is telling is is that\nfor every closed $d$-manifold $\\Sigma_d$,\nwe have a finite-dimensional vector space $V(\\Sigma^d)$.\nFor every $M^{d+1}$ cobordism between\n$\\Sigma_1^d$ and $\\Sigma_2^d$,\nwe have an unitary linear map\n$Z(M^{d+1}):V(\\Sigma_1^d)\\to V(\\Sigma_2^d)$.\n\nThis is the outline of the more abstract definitoin.\nNow I'm going to be more specific about exactly what data the axioms satisfy.\nIt's all hidden in this very abstract construction of a symmetric monoidal\nuniatry functor between two categories.\n\n\n\n\\begin{question}\n    You can only have unitary vector spaces of the same size?\n\\end{question}\nActually, it should be a linear map,\nonly unitary if they are the same dimension.\nThat's why you want the manifold to be closed.\n\n\\begin{question}\n    Is this always defined for two objects?\n\\end{question}\nThe tensor product $\\Sigma_1\\otimes\\Sigma_2$ defines for me a single object.\nThen if I have another one\n$\\Sigma_1\\sqcup\\Sigma_2$.\n[pair of pants picture]\n\nAgain, let me emphasize,\nit's totally not obvious why something like this should come out of a quantum\nmany-body system.\nI have linear maps associated with every $(d+1)$-dimensional bordisms.\nWhy should this structure arise?\nIt's not obvious.\n\n\\begin{question}\n    $V(\\Sigma^d)$\n\\end{question}\nEvery manifold is associated with a vector space.\nYou can think of $\\Sigma^d$ as an argument.\nFor every $\\Sigma^d$ you have a different vector space.\n\n\\begin{question}\n    Does the dimension of the vector space have something to do with the\n    dimension of the manifold?\n\\end{question}\nNo.\n\n\\begin{question}\n    What is monoidal and symmetric?\n\\end{question}\nI can write it down.\n\nMonoidal means that\n$\\mathcal{F}(\\Sigma_1^d\\otimes \\Sigma_2^d)\n\\simeq\nV(\\Sigma_1^d)\\otimes V(\\Sigma_2^d)$.\nHere $\\simeq$ means isomorphic.\n\nSymmetric means that\n$\\mathcal{F}(\\Sigma_1^d\\otimes\\Sigma_2^d)\\simeq\n\\matcal{F}(\\Sigma_2^d\\otimes\\Sigma_1^2)$.\n\n\n\\subsection{Defining data}\nLet's define what's the data.\n$V(\\Sigma^d)$ is a finite-dimensional vector space.\nThere is a path integral or partition function $Z(M^{d+1})$.\nWhen $M^{d+1}$ is closed,\nthen $Z(M^{d+1})\\in\\mathbb{C}$.\nWhen $M^{d+1}$ has boundary, then\n$Z(M^{d+1})\\in V(\\partial M^{d=1})$.\n\nThis is an alternative way of thinking about it.\nWhen $M^{d+1}$ is closed, you have a point,\nbut when it has a boundary, you have a state.\n\n\\begin{question}\n    If I have a 5D TQFT,\n    can we define a state on $\\mathbb{CP}^2$.\n\\end{question}\nNo path integral will define this.\nBut you still have a vector space.\n\n\\section{Atiyah's Axioms}\nYou could think of this as the data of a TQFT\nand these are the axioms.\n\n\\begin{axiom}\n    All manifolds have orientation.\n\\end{axiom}\n\n\\begin{axiom}\n    $Z$ and $V$ are \\emph{functorial} with respect to orientation-preserving\n    diffeomorphisms of $M^{d+1}$ and $\\Sigma^d$.\n\\end{axiom}\nLet me try to explain what this means.\n\n$M^{d+1}$ had two boundaries,\nand $Z(M^{d+1})$ was thought of as a map.\n\nActually, we're out of time,\nI'll tell you what this axiom means next time.\n\n\\begin{question}\n    What does $V$ mean physically?\n\\end{question}\n$V$ is the ground state degeneracy on that manifold.\n", "meta": {"hexsha": "2158467cfaf574b4e6ea16ef4ec1db4bddeaabb6", "size": 16929, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phys733/lecture3.tex", "max_stars_repo_name": "ehua7365/umdphysnotes", "max_stars_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-11T12:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-11T12:53:46.000Z", "max_issues_repo_path": "phys733/lecture3.tex", "max_issues_repo_name": "ehua7365/umdphysnotes", "max_issues_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phys733/lecture3.tex", "max_forks_repo_name": "ehua7365/umdphysnotes", "max_forks_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4786150713, "max_line_length": 80, "alphanum_fraction": 0.7588162325, "num_tokens": 4520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4137120343908656}}
{"text": "\\section{The WORG Method}\n\\label{method}\n\nIn order to describe the WORG method, first it is is useful to define\nnotation for demand curves and their parameterization.  Call $t$ the time\n[years] up to some maximal time horizon $T$ (e.g. 50 years) over which time\nthe demand curve is known.  Then call $f(t)$ the demand curve in the natural\nunits of the facility type (such as [GWe] for reactors).\n$f(t)$ may be any function that is desired, including non-differential\nfunctions. Moreover, $f(t)$ need not return a simple scalar.  In a\nmulti-objective case, this function would return a vector of independent\nobjective values.\nFor example, though, the demand curve for a 1\\% growth rate\nstarting at 90 [GWe] has the following form:\n\\begin{equation}\n\\label{f-1}\nf(t) = 90\\times 1.01^t\n\\end{equation}\nAdditionally, call $\\Theta$ the deployment schedule for the facilities that\nmay be constructed to meet the demand.\n$\\Theta$ is a sequence of $P$ parameters, indexed by $p$, as seen in\nEquation \\ref{Theta}.\n\\begin{equation}\n\\label{Theta}\n\\Theta = \\left\\{\\theta_1, \\theta_2, \\ldots, \\theta_P\\right\\}\n\\end{equation}\nEach $\\theta_p$ represents that number of facilities to deploy on its\ntime step. In simple cases where there is only one type of facility\nto deploy $P == T$.  However, when the deployment schedules of multiple\nfacility types are needed to meet the same demand curve, $P > T$.  The usual\nexample for $P > T$ is for transition scenarios which necessarily require\nmultiple kinds of reactors.\n\nNow denote $M$ as the sequence for the minimum number of facilities deployable\nfor each deployment parameter. Also, call $N$ the sequence of the maximum number\nof facilities deployable. The deployment parameters are thus each defined\non the range $\\theta_p \\in [M_p, N_p]$. Furthermore, because only whole\nnumbers of facilities may be deployed $\\theta_p \\in \\N$.  It is also typical,\nbut not required, for $M = \\mathbf{0}$. Zero is also the lower bound\nfor all possible $\\theta_p$ as facilities may not be forcibly retired via the\ndeployment schedule.\n\nFrom here, call $g(t, \\Theta)$ the production as a function of time for a\ngiven deployment schedule. This has the same units as the demand curve.\nThus for power demand and reactor deployments, $g$ is in units of [GWe]. The\noptimization problem can now be posed as an attempt to find a $\\Theta$\nthat minimizes the difference between $f$ and $g$.\n\n\\input{dtw}\n\\input{gp}\n\\input{algo}\n", "meta": {"hexsha": "ba478fda060eab8bd0d8b26001504a5761ed93d2", "size": 2435, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "method.tex", "max_stars_repo_name": "scopatz/fc-deploy-opt", "max_stars_repo_head_hexsha": "dfc3a93f1eb8981317a4f332bc76bd6f4bedd6b7", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-02-01T16:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-05T11:58:31.000Z", "max_issues_repo_path": "method.tex", "max_issues_repo_name": "scopatz/fc-deploy-opt", "max_issues_repo_head_hexsha": "dfc3a93f1eb8981317a4f332bc76bd6f4bedd6b7", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "method.tex", "max_forks_repo_name": "scopatz/fc-deploy-opt", "max_forks_repo_head_hexsha": "dfc3a93f1eb8981317a4f332bc76bd6f4bedd6b7", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.8269230769, "max_line_length": 80, "alphanum_fraction": 0.7572895277, "num_tokens": 637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.41371203439086557}}
{"text": "\\documentclass[11pt]{amsart}\n\\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}                   % ... or a4paper or a5paper or ... \n%\\geometry{landscape}                % Activate for for rotated page geometry\n%\\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n\\usepackage{epstopdf}\n\\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}\n\n\\title{Brief Article}\n\\author{The Author}\n%\\date{}                                           % Activate to display a given date or no date\n\n\\begin{document}\n%\\maketitle\n%\\section{}\n%\\subsection{}\nLet $(X, \\eta)$ and $(Y, \\rho)$ be two Polish spaces.\n$C(X, Y)$ is the set of all continuous mappings $f: X\\mapsto Y$.\nFor $f, g\\in C(X, Y)$, we define\n$$d (f, g) = \\sup_{x\\in X} \\rho(f(x),  g(x)).$$\n\\begin{enumerate}\n\\item\nProve that $(C(X, Y), d)$ is a Polish space.\n\\item If $K \\subset Y$ are compact, is $C(X, K)$ compact in $C(X, Y)$?\n\\iffalse\n\\item Let $F \\subset C(X, K)$ be a equicontinuous. This means, $\\forall \\epsilon >0$, there $\\exists \\delta>0$, such that\n\\begin{itemize}\n\\item\nif $\\eta(x, y) < \\delta$ and $f\\in F$, then $\\rho(f(x), f(y))<\\epsilon$.\n\\end{itemize}\nIs $F$ compact in $C(X, Y)$?\n\\fi\n\\end{enumerate}\n\n\n\\end{document}  ", "meta": {"hexsha": "f7c8a8984d59e62c0b6f2a9840a4c3fcee6dd65f", "size": 1387, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/200611jj.tex", "max_stars_repo_name": "songqsh/foo1", "max_stars_repo_head_hexsha": "536bf44cc4fb43a3ac0f2a64695f619ac7526651", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-14T03:04:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-14T03:04:24.000Z", "max_issues_repo_path": "doc/200611jj.tex", "max_issues_repo_name": "songqsh/foo1", "max_issues_repo_head_hexsha": "536bf44cc4fb43a3ac0f2a64695f619ac7526651", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-07-01T20:35:39.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-04T22:07:50.000Z", "max_forks_repo_path": "doc/200611jj.tex", "max_forks_repo_name": "songqsh/foo1", "max_forks_repo_head_hexsha": "536bf44cc4fb43a3ac0f2a64695f619ac7526651", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-08-25T00:50:05.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-25T20:06:32.000Z", "avg_line_length": 36.5, "max_line_length": 121, "alphanum_fraction": 0.6279740447, "num_tokens": 443, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.41354308060811795}}
{"text": "\\subsection{Reiterate self-energy requirements}\n\n\\begin{frame}\n  \\frametitle{Reiterate self-energy requirements}\n  \\tikzset{block/.style={\n          shape=rectangle,draw,minimum size=.8cm},\n      dd/.style={densely dotted},\n      block dd/.style={block,dd},\n  }\n  \\def\\bsize{.8cm}\n\n  \\begin{block}{Rules for using self-energies}\n\n    Coupling a \\emph{bulk} electrode to a device requires(!) coupling region to behave\n    \\emph{bulk} as well. \n\n    \\vspace{4pt}\n\n    \\begin{center}\n      \\begin{tikzpicture}\n\n        \\foreach \\x in {0,1,2,3,4,5,6,7,8} {\n            \\def\\tmpcol{black}\n            \\ifnum\\x>2\n            \\def\\tmpcol{red!70!black}\n            \\fi\n            \\ifnum\\x>3\n            \\def\\tmpcol{green!70!black}\n            \\fi\n            \\ifnum\\x>4\n            \\def\\tmpcol{red!70!black}\n            \\fi\n            \\ifnum\\x>5\n            \\def\\tmpcol{black}\n            \\fi\n            \\node[block,gray] at ({(\\x-0.5)*\\bsize},3*\\bsize) {};\n\n            \\expandafter\\fill\\expandafter[\\tmpcol] ({(\\x-0.75)*\\bsize},3*\\bsize)\n            circle (3pt);\n            \\expandafter\\fill\\expandafter[\\tmpcol] ({(\\x-0.25)*\\bsize},3*\\bsize)\n            circle (3pt);\n\n        }\n    \n        \\node[block dd] at (-1.5*\\bsize,0.5*\\bsize) {$\\SE_{-}$};\n        \\foreach \\x in {0,1,2,3,4,5,6,7,8} {\n            \\ifnum\\x<3\n            \\def\\tmpnum{0}\n            \\fi\n            \\ifnum\\x>2\n            \\pgfmathparse{int(\\x-2)}\n            \\edef\\tmpnum{\\pgfmathresult}\n            \\fi\n            \\ifnum\\x>5\n            \\pgfmathparse{int(4)}\n            \\edef\\tmpnum{\\pgfmathresult}\n            \\fi\n            \\node[block] (A\\x) at ({(\\x-0.5)*\\bsize},0.5*\\bsize) {$\\HH_\\tmpnum$};\n            \\ifnum\\x>0\n            \\pgfmathparse{int(\\x-1)}\n            \\edef\\xp{\\pgfmathresult}\n            \\ifnum\\x>6\n            \\pgfmathparse{int(5)}\n            \\edef\\tmpnum{\\pgfmathresult}\n            \\fi\n            \\draw[->,dd] (A\\xp) to[out=75,in=105] node[above] {$\\VV_\\tmpnum$} (A\\x);\n            \\draw[<-,dd] (A\\xp) to[out=-75,in=-105] node[below] {$\\VV^\\dagger_\\tmpnum$} (A\\x);\n            \\fi\n        }\n        \\node[block dd] at (8.5*\\bsize,0.5*\\bsize) {$\\SE_{+}$};\n      \\end{tikzpicture}\n\n    \\end{center}\n\n    \\vspace{-12pt}\n\n    \\begin{itemize}\n      \\item<+-> Remember that $\\SE_{-/+}$ is a correction to the Hamiltonian (i.e. \n      $\\HH' = \\HH + \\SE$)\n\n      \\item \\emph{Extremely} important in TranSiesta, electrostatics are long-range!\n    \\end{itemize}\n  \\end{block}\n\n  % \\begin{block}<2->{Use symmetries whenever you can}\n\n  %   \\begin{itemize}\n  %     \\item If you have transverse periodic electrodes you should apply Bloch's theorem\n  %     using the flag \\texttt{Bloch}\n  %   \\end{itemize}\n    \n  % \\end{block}\n\n\\end{frame}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"talk\"\n%%% End:\n", "meta": {"hexsha": "3fb7ad3a4fdd7612cee4b2e46f2f9e8207bbb40f", "size": 2797, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ts-tbt-sisl-tutorial-master/presentations/03/reiterate.tex", "max_stars_repo_name": "rwiuff/QuantumTransport", "max_stars_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-25T14:05:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-25T14:05:45.000Z", "max_issues_repo_path": "ts-tbt-sisl-tutorial-master/presentations/03/reiterate.tex", "max_issues_repo_name": "rwiuff/QuantumTransport", "max_issues_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-31T03:17:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-31T03:17:38.000Z", "max_forks_repo_path": "ts-tbt-sisl-tutorial-master/presentations/03/reiterate.tex", "max_forks_repo_name": "rwiuff/QuantumTransport", "max_forks_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-27T10:27:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-17T10:18:18.000Z", "avg_line_length": 27.6930693069, "max_line_length": 94, "alphanum_fraction": 0.5098319628, "num_tokens": 957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.41354306304366023}}
{"text": "\n\\twocolumn\n\n\\chapter*{Appendix}\n\nThe table below contains an initial segment of the fine spectrum for each of the classes in this survey. The classes are ordered in lexicographically decreasing order of their fine spectrum sequence and, if available, the sequence is followed by a link to the \\url{oeis.org} entry for this sequence.\n\n{\\small\n%\\begin{multicols}{2}\n\\begin{tabular}{|l|l|l|}\\hline\nName& Fine spectrum& \\href{oeis.org}{OEIS}\\\\\\hline\n\\hyperlink{PoMag}{PoMag}& 1, 16, 4051 &No\\\\\n\\hyperlink{PoImpA}{PoImpA}& 1, 16, 3981 &No\\\\\n\\hyperlink{PoSgrp}{PoSgrp}& 1, 11, 173, 4753, 198838,...&No\\\\\n\\hyperlink{Mag}{Mag}& 1, 10, 3330, 178981952,...&\\href{http://oeis.org/A001329}{A001329}\\\\\n\\hyperlink{Srng}{Srng}& 1, 10, 132, 2341 &No\\\\\n\\hyperlink{CPoSgrp}{CPoSgrp}& 1, 7, 83, 1468, 37248,... &No\\\\\n\\hyperlink{MedMag}{MedMag}& 1, 7, 75, 3969 &No\\\\\n\\hyperlink{IdPoSgrp}{IdPoSgrp}& 1, 7, 69, 1035 &No\\\\\n\\hyperlink{MMag}{MMag}& 1, 6, 280&\\\\\n\\hyperlink{JImpA}{JImpA}& 1, 6, 245&\\\\\n\\hyperlink{MImpA}{MImpA}& 1, 6, 220&\\\\\n\\hyperlink{JMag}{JMag}& 1, 6, 220&\\\\\n\\hyperlink{ToMag}{ToMag}& 1, 6, 175&\\\\\n\\hyperlink{ToImpA}{ToImpA}& 1, 6, 175&\\\\\n\\hyperlink{MultLat}{MultLat}& 1, 6, 175&\\\\\n\\hyperlink{DLMag}{DLMag}& 1, 6, 175&\\\\\n\\hyperlink{DLImpA}{DLImpA}& 1, 6, 175&\\\\\n\\hyperlink{LMag}{LMag}& 1, 6, 175&\\\\\n\\hyperlink{LImpA}{LImpA}& 1, 6, 175&\\\\\n\\hyperlink{DivPos}{DivPos}& 1, 6, 123 &\\\\\n\\hyperlink{LrPoMag}{LrPoMag}& 1, 6, 110&\\\\\n\\hyperlink{MSgrp}{MSgrp}& 1, 6, 70, 1437 &No\\\\\n\\hyperlink{JSgrp}{JSgrp}& 1, 6, 61, 866 &No\\\\\n\\hyperlink{CDivPos}{CDivPos}& 1, 6, 55, 1434 &No\\\\\n\\hyperlink{DLSgrp}{DLSgrp}& 1, 6, 44, 479 &No\\\\\n\\hyperlink{LSgrp}{LSgrp}& 1, 6, 44, 479 &No\\\\\n\\hyperlink{ToSgrp}{ToSgrp}& 1, 6, 44, 386 &\\href{http://oeis.org/A084965}{A084965}\\\\\n\\hyperlink{PoUn}{PoUn}& 1, 6, 43, 452 &No\\\\\n\\hyperlink{PoNUn}{PoNUn}& 1, 6, 39, 386, 5203 &No\\\\\n\\hyperlink{BMag}{BMag}& 1, 6, 0, 1176, 0, 0, 0 &No\\\\\n\\hyperlink{BImpA}{BImpA}& 1, 6, 0, 1176, 0, 0, 0 &No\\\\\n\\hyperlink{BSgrp}{BSgrp}& 1, 6, 0, 93, 0, 0, 0 &No\\\\\n\\hyperlink{LrPoSgrp}{LrPoSgrp}& 1, 5, 28, 273, 3788 &No\\\\\n\\hyperlink{Sgrp}{Sgrp}& 1, 5, 24, 188, 1915, 28634,...&\\href{http://oeis.org/A027851}{A027851}\\\\\n\\hyperlink{DivJslat}{DivJslat}& 1, 4, 281 &No\\\\\n\\hyperlink{DivMslat}{DivMslat}& 1, 4, 216 &\\\\\n\\hyperlink{DivLat}{DivLat}& 1, 4, 216&\\\\\n\\hyperlink{ToDivLat}{ToDivLat}& 1, 4, 216&\\\\\n\\hyperlink{DDivLat}{DDivLat}& 1, 4, 216&\\\\\n\\hyperlink{CnjMag}{CnjMag}& 1, 4, 215&\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{CMag}{CMag}& 1, 4, 129, 43968, 254429900,... &\\href{http://oeis.org/A001425}{A001425}\\\\\n\\hyperlink{CDivJslat}{CDivJslat}& 1, 4, 79, 7545 &No\\\\\n\\hyperlink{CDivMslat}{CDivMslat}& 1, 4, 64, 6208 &No\\\\\n\\hyperlink{CDivLat}{CDivLat}& 1, 4, 64, 6208 &No\\\\\n\\hyperlink{PoMon}{PoMon}& 1, 4, 37, 549 &No\\\\\n\\hyperlink{CMSgrp}{CMSgrp}& 1, 4, 32, 432 &\\href{http://oeis.org/A009668}{??}\\\\\n\\hyperlink{CJSgrp}{CJSgrp}& 1, 4, 29, 289 &No\\\\\n\\hyperlink{IdMSgrp}{IdMSgrp}& 1, 4, 28, 308, 4694 &No\\\\\n\\hyperlink{CPoMon}{CPoMon}& 1, 4, 27, 301, 4887 &No\\\\\n\\hyperlink{IdJSgrp}{IdJSgrp}& 1, 4, 23, 166, 1379 &No\\\\\n\\hyperlink{Srng$_0$}{Srng$_0$}& 1, 4, 22, 283 &No\\\\\n\\hyperlink{Srng$_1$}{Srng$_1$}& 1, 4, 22, 169, 1819 &No\\\\\n\\hyperlink{CDLSgrp}{CDLSgrp}& 1, 4, 20, 149, 1106 &No\\\\\n\\hyperlink{CLSgrp}{CLSgrp}& 1, 4, 20, 149, 1427 &No\\\\\n\\hyperlink{CToSgrp}{CToSgrp}& 1, 4, 20, 114, 710, 4726,... &\\href{http://oeis.org/A346414}{A346414}\\\\\n\\hyperlink{IdLSgrp}{IdLSgrp}& 1, 4, 17, 100, 674 &No\\\\\n\\hyperlink{DIdLSgrp}{DIdLSgrp}& 1, 4, 17, 100, 576 &No\\\\\n\\hyperlink{IdToSgrp}{IdToSgrp}& 1, 4, 17, 82, 422 &\\href{http://oeis.org/A181517}{??}\\\\\n\\hyperlink{RPoUn}{RPoUn}& 1, 4, 16, 87, 562 &No\\\\\n\\hyperlink{GalPos}{GalPos}& 1, 4, 15, 83, 539 &No\\\\\n\\hyperlink{InPoMag}{InPoMag}& 1, 4, 12, 77, 498 &No\\\\\n\\hyperlink{CyInPoMag}{CyInPoMag}& 1, 4, 12, 76, 481 &No\\\\\n\\hyperlink{CInPoMag}{CInPoMag}& 1, 4, 12, 69, 354, 3632 &No\\\\\n\\hyperlink{InPoSgrp}{InPoSgrp}& 1, 4, 10, 50, 210, 1721 &No\\\\\n\\hyperlink{CyInPoSgrp}{CyInPoSgrp}& 1, 4, 10, 50, 196, 1397 &No\\\\\n\\hyperlink{CInPoSgrp}{CInPoSgrp}& 1, 4, 10, 50, 194, 1356 &No\\\\\n\\hyperlink{BCSgrp}{BCSgrp}& 1, 4, 0, 35, 0, 0, 0, 1237, 0 &No\\\\\n\\hyperlink{BIdSgrp}{BIdSgrp}& 1, 4, 0, 18, 0, 0, 0, 88, 0, 0 &No\\\\\n\\hyperlink{LrMMag}{LrMMag}& 1, 3, 52, 4827 &No\\\\\n\\hyperlink{LrJMag}{LrJMag}& 1, 3, 52, 4827 &No\\\\\n\\hyperlink{LrLMag}{LrLMag}& 1, 3, 50, 4441 &No\\\\\n\\hyperlink{DLrLMag}{DLrLMag}& 1, 3, 50, 4441 &No\\\\\n\\hyperlink{LrToMag}{LrToMag}& 1, 3, 50, 4116 &\\href{http://oeis.org/A071094}{??}\\\\\n\\hyperlink{RtQgrp}{RtQgrp}& 1, 3, 44, 14022 &\\href{http://oeis.org/A193623}{??}\\\\\n\\hyperlink{RPoMag}{RPoMag}& 1, 3, 28, 1200 &No\\\\\n\\hyperlink{IdPoMon}{IdPoMon}& 1, 3, 23, 238, 3356 &No\\\\\n\\hyperlink{CDDivLat}{CDDivLat}& 1, 3, 20, 364 &\\href{http://oeis.org/A003150}{??}\\\\\n\\hyperlink{CToDivLat}{CToDivLat}& 1, 3, 20, 294 &No\\\\\n\\hyperlink{LrMSgrp}{LrMSgrp}& 1, 3, 19, 199, 2946 &No\\\\\n\\hyperlink{LrJSgrp}{LrJSgrp}& 1, 3, 19, 192 &No\\\\\n\\hyperlink{CIdPoSgrp}{CIdPoSgrp}& 1, 3, 19, 171, 2069 &No\\\\\n\\hyperlink{LrLSgrp}{LrLSgrp}& 1, 3, 18, 183, 2500 &No\\\\\n\\hyperlink{DLrLSgrp}{DLrLSgrp}& 1, 3, 18, 183, 1968 &No\\\\\n\\hyperlink{LrToSgrp}{LrToSgrp}& 1, 3, 18, 144, 1370 &No\\\\\n\\hyperlink{MUn}{MUn}& 1, 3, 17, 138, 1555 &No\\\\\n\\hyperlink{QtMag}{QtMag}& 1, 3, 16, 218 &\\href{http://oeis.org/A000273}{??}\\\\\n\\hyperlink{CRPoMag}{CRPoMag}& 1, 3, 16, 180, 4761 &No\\\\\n\\hyperlink{RPoSgrp}{RPoSgrp}& 1, 3, 16, 154, 2100 &No\\\\\n\\hyperlink{JUn}{JUn}& 1, 3, 16, 104, 822 &No\\\\\n\\hyperlink{MNUn}{MNUn}& 1, 3, 15, 113, 1167 &No\\\\\n\\hyperlink{JNUn}{JNUn}& 1, 3, 15, 113, 1167 &No\\\\\n\\hyperlink{CIdPoMon}{CIdPoMon}& 1, 3, 13, 86, 759 &No\\\\\n\\hyperlink{CRPoSgrp}{CRPoSgrp}& 1, 3, 12, 76, 670 &No\\\\\n\\hyperlink{IdLrPoSgrp}{IdLrPoSgrp}& 1, 3, 12, 71, 524 &No\\\\\n\\hyperlink{CSgrp}{CSgrp}& 1, 3, 12, 58, 325, 2143, 17291,... &\\href{http://oeis.org/A001426}{A001426}\\\\\n\\hyperlink{pPos}{pPos}& 1, 3, 11, 47, 243 &No\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{LNUn}{LNUn}& 1, 3, 10, 56, 457 &No\\\\\n\\hyperlink{DLNUn}{DLNUn}& 1, 3, 10, 56, 276 &No\\\\\n\\hyperlink{LUn}{LUn}& 1, 3, 10, 50, 313 &No\\\\\n\\hyperlink{DLUn}{DLUn}& 1, 3, 10, 50, 226 &No\\\\\n\\hyperlink{Bnd}{Bnd}& 1, 3, 10, 46, 251, 1682, 13213 &\\href{http://oeis.org/A058112}{A058112}\\\\\n\\hyperlink{ToNUn}{ToNUn}& 1, 3, 10, 35, 126, 462 &\\\\\n\\hyperlink{ToUn}{ToUn}& 1, 3, 10, 35, 126, 462 &\\\\\n\\hyperlink{RegSgrp}{RegSgrp}& 1, 3, 9, 42, 206, 1352, 10168,... &\\href{http://oeis.org/A001427}{A001427}\\\\\n\\hyperlink{NBnd}{NBnd}& 1, 3, 8, 30, 114, 536 &No\\\\\n\\hyperlink{InPoMon}{InPoMon}& 1, 3, 5, 20, 39, 179, 500 &No\\\\\n\\hyperlink{CyInPoMon}{CyInPoMon}& 1, 3, 5, 20, 39, 176, 493 &No\\\\\n\\hyperlink{CInPoMon}{CInPoMon}& 1, 3, 5, 20, 39, 174, 488 &No\\\\\n\\hyperlink{InPos}{InPos}& 1, 3, 5, 16, 30, 108 &No\\\\\n\\hyperlink{NRng}{NRng}& 1, 3, 5, 35, 10, 99, 24, 3856,...&\\href{http://oeis.org/A305858}{A305858}\\\\\n\\hyperlink{BDivLat}{BDivLat}& 1, 3, 0, 325 &No\\\\\n\\hyperlink{BLrMag}{BLrMag}& 1, 3, 0, 325, 0, 0, 0 &No\\\\\n\\hyperlink{BCDivLat}{BCDivLat}& 1, 3, 0, 70, 0, 0, 0 &No\\\\\n\\hyperlink{BLrSgrp}{BLrSgrp}& 1, 3, 0, 39, 0 &No\\\\\n\\hyperlink{BUn}{BUn}& 1, 3, 0, 15, 0, 0, 0, 147, 0 &No\\\\\n\\hyperlink{BNUn}{BNUn}& 1, 3, 0, 15, 0, 0, 0, 147, 0 &No\\\\\n\\hyperlink{Shell}{Shell}& 1, 2, 243 &\\\\\n\\hyperlink{RMMag}{RMMag}& 1, 2, 20, 1116 &No\\\\\n\\hyperlink{RJMag}{RJMag}& 1, 2, 20, 1116 &No\\\\\n\\hyperlink{RLMag}{RLMag}& 1, 2, 20, 1116 &No\\\\\n\\hyperlink{DRLMag}{DRLMag}& 1, 2, 20, 1116 &No\\\\\n\\hyperlink{RToMag}{RToMag}& 1, 2, 20, 980 &\\href{http://oeis.org/A008793}{??}\\\\\n\\hyperlink{MMon}{MMon}& 1, 2, 14, 168, 3488 &No\\\\\n\\hyperlink{RMSgrp}{RMSgrp}& 1, 2, 12, 129, 1852 &No\\\\\n\\hyperlink{RJSgrp}{RJSgrp}& 1, 2, 12, 129, 1852 &No\\\\\n\\hyperlink{RLSgrp}{RLSgrp}& 1, 2, 12, 129, 1852 &No\\\\\n\\hyperlink{IdSrng$_0$}{IdSrng$_0$}& 1, 2, 12, 129, 1852 &No\\\\\n\\hyperlink{DRLSgrp}{DRLSgrp}& 1, 2, 12, 129, 1437 &No\\\\\n\\hyperlink{RToSgrp}{RToSgrp}& 1, 2, 12, 101, 1003 &No\\\\\n\\hyperlink{Sgrp$_0$}{Sgrp$_0$}& 1, 2, 12, 90, 960 &No\\\\\n\\hyperlink{JMon}{JMon}& 1, 2, 11, 73, 703 &No\\\\\n\\hyperlink{CRMMag}{CRMMag}& 1, 2, 10, 148, 4398 &No\\\\\n\\hyperlink{CRJMag}{CRJMag}& 1, 2, 10, 148, 4398 &No\\\\\n\\hyperlink{CRLMag}{CRLMag}& 1, 2, 10, 148, 4398 &No\\\\\n\\hyperlink{CDRLMag}{CDRLMag}& 1, 2, 10, 148, 3554 &No\\\\\n\\hyperlink{CRToMag}{CRToMag}& 1, 2, 10, 112, 2772 &\\href{http://oeis.org/A049505}{??}\\\\\n\\hyperlink{CMMon}{CMMon}& 1, 2, 10, 92, 1322 &No\\\\\n\\hyperlink{IdMMon}{IdMMon}& 1, 2, 10, 81, 950 &No\\\\\n\\hyperlink{FL}{FL}& 1, 2, 9, 79, 737 &No\\\\\n\\hyperlink{FL$_e$}{FL$_e$}& 1, 2, 9, 63, 492 &No\\\\\n\\hyperlink{CJMon}{CJMon}& 1, 2, 9, 55, 437 &No\\\\\n\\hyperlink{GalJslat}{GalJslat}& 1, 2, 9, 52, 361, 2947 &No\\\\\n\\hyperlink{CRMSgrp}{CRMSgrp}& 1, 2, 8, 57, 550 &No\\\\\n\\hyperlink{CRJSgrp}{CRJSgrp}& 1, 2, 8, 57, 550 &No\\\\\n\\hyperlink{CRLSgrp}{CRLSgrp}& 1, 2, 8, 57, 550 &No\\\\\n\\hyperlink{CRSlSgrp}{CRSlSgrp}& 1, 2, 8, 57, 392 &No\\\\\n\\hyperlink{CDRLSgrp}{CDRLSgrp}& 1, 2, 8, 57, 392 &No\\\\\n\\hyperlink{CIdMSgrp}{CIdMSgrp}& 1, 2, 8, 53, 498 &No\\\\\n\\hyperlink{IdLrMSgrp}{IdLrMSgrp}& 1, 2, 8, 46, 345, 3180 &No\\\\\n\\hyperlink{LMon}{LMon}& 1, 2, 8, 45, 347 &No\\\\\n\\hyperlink{IdLrJSgrp}{IdLrJSgrp}& 1, 2, 8, 45, 304 &No\\\\\n\\hyperlink{DLMon}{DLMon}& 1, 2, 8, 45, 279 &No\\\\\n\\hyperlink{CRToSgrp}{CRToSgrp}& 1, 2, 8, 41, 241 &No\\\\\n\\hyperlink{ToMon}{ToMon}& 1, 2, 8, 34, 184, 1218,... &\\href{http://oeis.org/A346413}{A346413}\\\\\n\\hyperlink{IdLrLSgrp}{IdLrLSgrp}& 1, 2, 7, 40, 273 &No\\\\\n\\hyperlink{DIdLrLSgrp}{DIdLrLSgrp}& 1, 2, 7, 40, 213 &No\\\\\n\\hyperlink{Mon}{Mon}& 1, 2, 7, 35, 228, 2237, 31559 &\\href{http://oeis.org/A058129}{A058129}\\\\\n\\hyperlink{CIdJSgrp}{CIdJSgrp}& 1, 2, 7, 33, 185 &\\\\\n\\hyperlink{IdLrToSgrp}{IdLrToSgrp}& 1, 2, 7, 30, 144, 740 &No\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{IdJMon}{IdJMon}& 1, 2, 7, 29, 136 &\\href{http://oeis.org/A307389}{??}\\\\\n\\hyperlink{OrdA}{OrdA}& 1, 2, 7, 36, 251 &No\\\\\n\\hyperlink{Srng$_{01}$}{Srng$_{01}$}& 1, 2, 6, 40, 295, 3246 &No\\\\\n\\hyperlink{FL$_c$}{FL$_c$}& 1, 2, 6, 39, 279 &No\\\\\n\\hyperlink{LrPoMon}{LrPoMon}& 1, 2, 6, 32, 234, 2493 &No\\\\\n\\hyperlink{CIdMMon}{CIdMMon}& 1, 2, 6, 31, 228, 2205 &No\\\\\n\\hyperlink{CLMon}{CLMon}& 1, 2, 6, 31, 199 &No\\\\\n\\hyperlink{FL$_{ec}$}{FL$_{ec}$}& 1, 2, 6, 31, 199 &No\\\\\n\\hyperlink{CDLMon}{CDLMon}& 1, 2, 6, 31, 149 &No\\\\\n\\hyperlink{GalMslat}{GalMslat}& 1, 2, 6, 30, 184, 1373 &No\\\\\n\\hyperlink{GalLat}{GalLat}& 1, 2, 6, 30, 184 &No\\\\\n\\hyperlink{DGalLat}{DGalLat}& 1, 2, 6, 30, 126 &No\\\\\n\\hyperlink{IdLMon}{IdLMon}& 1, 2, 6, 22, 93, 439 &No\\\\\n\\hyperlink{CToMon}{CToMon}& 1, 2, 6, 22, 92, 426 &\\\\\n\\hyperlink{DIdLMon}{DIdLMon}& 1, 2, 6, 22, 75, 274 &No\\\\\n\\hyperlink{GalToLat}{GalToLat}& 1, 2, 6, 20, 70, 252, 924 &\\\\\n\\hyperlink{IdToMon}{IdToMon}& 1, 2, 6, 16, 44, 120 &\\\\\n\\hyperlink{InLMag}{InLMag}& 1, 2, 5, 42, 342 &No\\\\\n\\hyperlink{CyInLMag}{CyInLMag}& 1, 2, 5, 42, 328 &No\\\\\n\\hyperlink{DInLMag}{DInLMag}& 1, 2, 5, 42, 164 &No\\\\\n\\hyperlink{CyDInLMag}{CyDInLMag}& 1, 2, 5, 42, 156 &No\\\\\n\\hyperlink{CInLMag}{CInLMag}& 1, 2, 5, 38, 238, 2722 &No\\\\\n\\hyperlink{CDInLMag}{CDInLMag}& 1, 2, 5, 38, 90, 858 &No\\\\\n\\hyperlink{InLSgrp}{InLSgrp}& 1, 2, 5, 29, 146, 1308 &No\\\\\n\\hyperlink{CyInLSgrp}{CyInLSgrp}& 1, 2, 5, 29, 132, 1018 &No\\\\\n\\hyperlink{CInLSgrp}{CInLSgrp}& 1, 2, 5, 29, 130, 984 &No\\\\\n\\hyperlink{DInLSgrp}{DInLSgrp}& 1, 2, 5, 29, 63, 454 &No\\\\\n\\hyperlink{CyDInLSgrp}{CyDInLSgrp}& 1, 2, 5, 29, 55, 353 &No\\\\\n\\hyperlink{CDInLSgrp}{CDInLSgrp}& 1, 2, 5, 29, 53, 330 &No\\\\\n\\hyperlink{CInSlSgrp}{CInSlSgrp}& 1, 2, 5, 29, 53, 330 &No\\\\\n\\hyperlink{RPoMon}{RPoMon}& 1, 2, 5, 28, 186 &No\\\\\n\\hyperlink{CRPoMon}{CRPoMon}& 1, 2, 5, 24, 131, 1001 &No\\\\\n\\hyperlink{InToMag}{InToMag}& 1, 2, 5, 22, 142 &No\\\\\n\\hyperlink{CyInToMag}{CyInToMag}& 1, 2, 5, 22, 138 &\\href{http://oeis.org/A001437}{??}\\\\\n\\hyperlink{BCI}{BCI}& 1, 2, 5, 22, 118, 974 &No\\\\\n\\hyperlink{CIdLSgrp}{CIdLSgrp}& 1, 2, 5, 19, 86, 462 &No\\\\\n\\hyperlink{CMon}{CMon}& 1, 2, 5, 19, 78, 421, 2637 &\\href{http://oeis.org/A058131}{A058131}\\\\\n\\hyperlink{CDIdLSgrp}{CDIdLSgrp}& 1, 2, 5, 19, 68 &No\\\\\n\\hyperlink{CInToMag}{CInToMag}& 1, 2, 5, 18, 72, 384 &No\\\\\n\\hyperlink{CIdJMon}{CIdJMon}& 1, 2, 5, 17, 66, 288 &No\\\\\n\\hyperlink{Pos}{Pos}& 1, 2, 5, 16, 63, 318, 2045, 16999,... &\\href{http://oeis.org/A000112}{A000112}\\\\\n\\hyperlink{pMslat}{pMslat}& 1, 2, 5, 16, 60, 262, 1315 &No\\\\\n\\hyperlink{pJslat}{pJslat}& 1, 2, 5, 16, 60, 262, 1315 &No\\\\\n\\hyperlink{InvSgrp}{InvSgrp}& 1, 2, 5, 16, 52, 208, 911, 4637,... &\\href{http://oeis.org/A001428}{A001428}\\\\\n\\hyperlink{CInvSgrp}{CInvSgrp}& 1, 2, 5, 16, 51, 201,...&\\href{http://oeis.org/A234843}{A234843}\\\\\n\\hyperlink{InToSgrp}{InToSgrp}& 1, 2, 5, 14, 43, 147, 578 &\\href{http://oeis.org/A137555}{??}\\\\\n\\hyperlink{CIdToSgrp}{CIdToSgrp}& 1, 2, 5, 14, 42, 132 &\\\\\n\\hyperlink{CyInToSgrp}{CyInToSgrp}& 1, 2, 5, 14, 39, 119 &No\\\\\n\\hyperlink{CInToSgrp}{CInToSgrp}& 1, 2, 5, 14, 37, 107 &No\\\\\n\\hyperlink{CIdLMon}{CIdLMon}& 1, 2, 4, 12, 41, 159 &No\\\\\n\\hyperlink{CDIdLMon}{CDIdLMon}& 1, 2, 4, 12, 31, 90, 241 &No\\\\\n\\hyperlink{CIdToMon}{CIdToMon}& 1, 2, 4, 8, 16, 32, 64 &\\\\\n\\hyperlink{pLat}{pLat}& 1, 2, 3, 7, 21, 75, 315 &No\\\\\n\\hyperlink{pDLat}{pDLat}& 1, 2, 3, 7, 13, 27, 50 &No\\\\\n\\hyperlink{pToLat}{pToLat}& 1, 2, 3, 4, 5, 6,... &\\href{http://oeis.org/A000027}{A000027}\\\\\n\\hyperlink{DivRng}{DivRng}& 1, 2, 3, 3, 5, 0, 7, 4 &No\\\\\n\\hyperlink{Rng}{Rng}& 1, 2, 2, 11, 2, 4 &\\href{http://oeis.org/A027623}{A027623}\\\\\n\\hyperlink{CRng}{CRng}& 1, 2, 2, 9, 2, 4 &\\href{http://oeis.org/A037289}{A037289}\\\\\n\\hyperlink{LtCanSgrp}{LtCanSgrp}& 1, 2, 2, 4, 2, 5, 2, 9 &No\\\\\n\\hyperlink{RecBnd}{RecBnd}& 1, 2, 2, 3, 2, 4, 2, 4, 3, 4 &\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{Sfld}{Sfld}& 1, 2, 1, 1, 1, 0 &\\\\\n\\hyperlink{BRMag}{BRMag}& 1, 2, 0, 136, 0 &No\\\\\n\\hyperlink{BCRMag}{BCRMag}& 1, 2, 0, 36, 0, 0 &No\\\\\n\\hyperlink{BRSgrp}{BRSgrp}& 1, 2, 0, 28, 0, 0 &No\\\\\n\\hyperlink{BInMag}{BInMag}& 1, 2, 0, 20, 0 &No\\\\\n\\hyperlink{BCyInMag}{BCyInMag}& 1, 2, 0, 20, 0 &No\\\\\n\\hyperlink{BCInMag}{BCInMag}& 1, 2, 0, 20, 0 &No\\\\\n\\hyperlink{BCRSgrp}{BCRSgrp}& 1, 2, 0, 16, 0, 0 &\\\\\n\\hyperlink{BInSgrp}{BInSgrp}& 1, 2, 0, 15, 0, 0 &No\\\\\n\\hyperlink{BCyInSgrp}{BCyInSgrp}& 1, 2, 0, 15, 0, 0 &No\\\\\n\\hyperlink{BCInSgrp}{BCInSgrp}& 1, 2, 0, 15, 0, 0 &No\\\\\n\\hyperlink{BMon}{BMon}& 1, 2, 0, 11, 0, 0, 0, 383 &No\\\\\n\\hyperlink{BRUn}{BRUn}& 1, 2, 0, 10, 0, 0, 0, 104 &No\\\\\n\\hyperlink{BIdLrSgrp}{BIdLrSgrp}& 1, 2, 0, 10, 0, 0 &No\\\\\n\\hyperlink{BGalLat}{BGalLat}& 1, 2, 0, 10, 0, 0 &No\\\\\n\\hyperlink{BCMon}{BCMon}& 1, 2, 0, 9, 0, 0, 0 &No\\\\\n\\hyperlink{BIdMon}{BIdMon}& 1, 2, 0, 6, 0, 0, 0, 24 &No\\\\\n\\hyperlink{BCIdSgrp}{BCIdSgrp}& 1, 2, 0, 5, 0, 0, 0, 13 &No\\\\\n\\hyperlink{BCIdMon}{BCIdMon}& 1, 2, 0, 4, 0, 0, 0, 9 &No\\\\\n\\hyperlink{pBA}{pBA}& 1, 2, 0, 3, 0, 0, 0, 1, 0, 0 &\\\\\n\\hyperlink{Qgrp}{Qgrp}& 1, 1, 5, 35, 1411,... &\\href{http://oeis.org/A057991}{A057991}\\\\\n\\hyperlink{MouQgrp}{MouQgrp}& 1, 1, 5, 29, 1351 &No\\\\\n\\hyperlink{LrMMon}{LrMMon}& 1, 1, 4, 24, 195, 2146 &No\\\\\n\\hyperlink{IdRMSgrp}{IdRMSgrp}& 1, 1, 4, 24, 169, 1404 &No\\\\\n\\hyperlink{IdRJSgrp}{IdRJSgrp}& 1, 1, 4, 24, 169, 1404 &No\\\\\n\\hyperlink{IdRPoSgrp}{IdRPoSgrp}& 1, 1, 4, 24, 169 &No\\\\\n\\hyperlink{IdRLSgrp}{IdRLSgrp}& 1, 1, 4, 24, 169 &No\\\\\n\\hyperlink{DIdRLSgrp}{DIdRLSgrp}& 1, 1, 4, 24, 124 &No\\\\\n\\hyperlink{LrLMon}{LrLMon}& 1, 1, 4, 23, 169, 1635 &No\\\\\n\\hyperlink{LrJMon}{LrJMon}& 1, 1, 4, 23, 169, 1635 &No\\\\\n\\hyperlink{DLrLMon}{DLrLMon}& 1, 1, 4, 23, 130, 976 &No\\\\\n\\hyperlink{LrToMon}{LrToMon}& 1, 1, 4, 17, 92, 609 &No\\\\\n\\hyperlink{IdRToSgrp}{IdRToSgrp}& 1, 1, 4, 17, 82 &No\\\\\n\\hyperlink{RL}{RL}& 1, 1, 3, 20, 149, 1488, 18554,... &No??\\\\\n\\hyperlink{IdSrng$_{01}$}{IdSrng$_{01}$}& 1, 1, 3, 20, 149, 1488, 18554,... &No\\\\\n\\hyperlink{bRL}{bRL}& 1, 1, 3, 20, 149, 1488 &No\\\\\n\\hyperlink{RMMon}{RMMon}& 1, 1, 3, 20, 149, 1488 &No\\\\\n\\hyperlink{RJMon}{RJMon}& 1, 1, 3, 20, 149, 1488 &No\\\\\n\\hyperlink{KA}{KA}& 1, 1, 3, 20, 149, 1488 &No\\\\\n\\hyperlink{KLat}{KLat}& 1, 1, 3, 16, 149, 1488 &No\\\\\n\\hyperlink{ActLat}{ActLat}& 1, 1, 3, 16, 149, 1488 &No\\\\\n\\hyperlink{DRL}{DRL}& 1, 1, 3, 20, 115, 899, 7782,... &No\\\\\n\\hyperlink{CRL}{CRL}& 1, 1, 3, 16, 100, 794, 7493,... &No\\\\\n\\hyperlink{CRMMon}{CRMMon}& 1, 1, 3, 16, 100, 794 &No\\\\\n\\hyperlink{CRJMon}{CRJMon}& 1, 1, 3, 16, 100, 794 &No\\\\\n\\hyperlink{CDRL}{CDRL}& 1, 1, 3, 16, 70, 399 &No\\\\\n\\hyperlink{RToMon}{RToMon}& 1, 1, 3, 15, 84, 575 &No\\\\\n\\hyperlink{BCKJslat}{BCKJslat}& 1, 1, 3, 14, 87, 745 &No\\\\\n\\hyperlink{IdLrPoMon}{IdLrPoMon}& 1, 1, 3, 12, 59, 350 &No\\\\\n\\hyperlink{IdLrMMon}{IdLrMMon}& 1, 1, 3, 12, 59, 348, 2372 &No\\\\\n\\hyperlink{CRSlMon}{CRSlMon}& 1, 1, 3, 12, 47, 220 &No\\\\\n\\hyperlink{IdLrJMon}{IdLrJMon}& 1, 1, 3, 11, 46, 215, 1114 &No\\\\\n\\hyperlink{IdLrLMon}{IdLrLMon}& 1, 1, 3, 11, 46, 215 &No\\\\\n\\hyperlink{CRToMon}{CRToMon}& 1, 1, 3, 11, 46, 213 &\\\\\n\\hyperlink{DIdLrLMon}{DIdLrLMon}& 1, 1, 3, 11, 37, 134 &No\\\\\n\\hyperlink{IdLrToMon}{IdLrToMon}& 1, 1, 3, 8, 22, 60, 164 &\\href{http://oeis.org/A155020}{??}\\\\\n\\hyperlink{Qnd}{Qnd}& 1, 1, 3, 7, 22, 73, 298, 1581,... &\\href{http://oeis.org/A181769}{A181769}\\\\\n\\hyperlink{IPoMon}{IPoMon}& 1, 1, 2, 11, 102, 1609 &No\\\\\n\\hyperlink{IMMon}{IMMon}& 1, 1, 2, 11, 102, 1569 &No\\\\\n\\hyperlink{CIPoMon}{CIPoMon}& 1, 1, 2, 9, 60, 590 &No\\\\\n\\hyperlink{CIMMon}{CIMMon}& 1, 1, 2, 9, 60, 572 &No\\\\\n\\hyperlink{Polrim}{Polrim}& 1, 1, 2, 9, 51, 409 &No\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{ILrMMon}{ILrMMon}& 1, 1, 2, 9, 51, 408 &No\\\\\n\\hyperlink{Porim}{Porim}& 1, 1, 2, 9, 49, 365 &No\\\\\n\\hyperlink{IRJMon}{IRJMon}& 1, 1, 2, 9, 49, 364, 3335 &No\\\\\n\\hyperlink{IRMMon}{IRMMon}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{IJMon}{IJMon}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{IRL}{IRL}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{ILrJMon}{ILrJMon}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{ILrLMon}{ILrLMon}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{ILMon}{ILMon}& 1, 1, 2, 9, 49, 364 &No\\\\\n\\hyperlink{DIRL}{DIRL}& 1, 1, 2, 9, 49, 359 &No\\\\\n\\hyperlink{DILrLMon}{DILrLMon}& 1, 1, 2, 9, 49, 359 &No\\\\\n\\hyperlink{DILMon}{DILMon}& 1, 1, 2, 9, 49, 359 &No\\\\\n\\hyperlink{InFL}{InFL}& 1, 1, 2, 9, 21, 101, 284, 1464 &No\\\\\n\\hyperlink{CyInFL}{CyInFL}& 1, 1, 2, 9, 21, 101, 279, 1433 &No\\\\\n\\hyperlink{CInFL}{CInFL}& 1, 1, 2, 9, 21, 100, 276, 1392 &No\\\\\n\\hyperlink{DInFL}{DInFL}& 1, 1, 2, 9, 8, 43, 49 &No\\\\\n\\hyperlink{CyDInFL}{CyDInFL}& 1, 1, 2, 9, 8, 43, 48 &No\\\\\n\\hyperlink{CDInFL}{CDInFL}& 1, 1, 2, 9, 8, 42, 46 &No\\\\\n\\hyperlink{IToMon}{IToMon}& 1, 1, 2, 8, 44, 308, 2641,... &\\href{http://oeis.org/A253950}{A253950}\\\\\n\\hyperlink{IRToMon}{IRToMon}& 1, 1, 2, 8, 44, 308 &\\\\\n\\hyperlink{ILrToMon}{ILrToMon}& 1, 1, 2, 8, 44, 308 &\\\\\n\\hyperlink{BCKMslat}{BCKMslat}& 1, 1, 2, 8, 38, 265 &No\\\\\n\\hyperlink{CIdRPoSgrp}{CIdRPoSgrp}& 1, 1, 2, 8, 36, 203 &No\\\\\n\\hyperlink{CIdRMSgrp}{CIdRMSgrp}& 1, 1, 2, 8, 36, 202 &No\\\\\n\\hyperlink{CIdRJSgrp}{CIdRJSgrp}& 1, 1, 2, 8, 36, 202 &No\\\\\n\\hyperlink{CIdRLSgrp}{CIdRLSgrp}& 1, 1, 2, 8, 36, 202 &No\\\\\n\\hyperlink{IdRPoMon}{IdRPoMon}& 1, 1, 2, 8, 32, 148 &No\\\\\n\\hyperlink{IdRJMon}{IdRJMon}& 1, 1, 2, 8, 32, 147, 759 &No \\\\\n\\hyperlink{IdRMMon}{IdRMMon}& 1, 1, 2, 8, 32, 147 &No\\\\\n\\hyperlink{IdRL}{IdRL}& 1, 1, 2, 8, 32, 147 &No\\\\\n\\hyperlink{DIdRL}{DIdRL}& 1, 1, 2, 8, 27, 96 &No\\\\\n\\hyperlink{CIdRSlSgrp}{CIdRSlSgrp}& 1, 1, 2, 8, 25, 97 &No\\\\\n\\hyperlink{CDIdRLSgrp}{CDIdRLSgrp}& 1, 1, 2, 8, 25, 97 &No\\\\\n\\hyperlink{RtHp}{RtHp}& 1, 1, 2, 8, 24, 91 &No\\\\\n\\hyperlink{Dtoid}{Dtoid}& 1, 1, 2, 7, 61 &No\\\\\n\\hyperlink{CIRMMon}{CIRMMon}& 1, 1, 2, 7, 26, 129, 723 &No\\\\\n\\hyperlink{CIRL}{CIRL}& 1, 1, 2, 7, 26, 129, 723 &No\\\\\n\\hyperlink{CIRJMon}{CIRJMon}& 1, 1, 2, 7, 26, 129, 723 &No\\\\\n\\hyperlink{FL$_{ew}$}{FL$_{ew}$}& 1, 1, 2, 7, 26, 129, 723 &No\\\\\n\\hyperlink{FL$_w$}{FL$_w$}& 1, 1, 2, 7, 26, 129, 723 &No\\\\\n\\hyperlink{Pocrim}{Pocrim}& 1, 1, 2, 7, 26, 129 &No\\\\\n\\hyperlink{CIJMon}{CIJMon}& 1, 1, 2, 7, 26, 129 &No\\\\\n\\hyperlink{CILMon}{CILMon}& 1, 1, 2, 7, 26, 129 &No\\\\\n\\hyperlink{BCKLat}{BCKLat}& 1, 1, 2, 7, 26, 129 &No\\\\\n\\hyperlink{CDIRL}{CDIRL}& 1, 1, 2, 7, 26, 124, 645 &No\\\\\n\\hyperlink{CDILMon}{CDILMon}& 1, 1, 2, 7, 26, 124, 645 &No\\\\\n\\hyperlink{CIRSlMon}{CIRSlMon}& 1, 1, 2, 7, 23, 99, 464 &No\\\\\n\\hyperlink{CIToMon}{CIToMon}& 1, 1, 2, 6, 22, 94, 451 &\\href{http://oeis.org/A030453}{A030453}\\\\\n\\hyperlink{CIRToMon}{CIRToMon}& 1, 1, 2, 6, 22, 94, 451 &Same as above??\\\\\n\\hyperlink{CIdRPoMon}{CIdRPoMon}& 1, 1, 2, 6, 20, 78 &\\\\\n\\hyperlink{CIdRJMon}{CIdRJMon}& 1, 1, 2, 6, 20, 77, 333 &No\\\\\n\\hyperlink{CIdRMMon}{CIdRMMon}& 1, 1, 2, 6, 20, 77 &\\\\\n\\hyperlink{CIdRL}{CIdRL}& 1, 1, 2, 6, 20, 77 &\\\\\n\\hyperlink{IdRToMon}{IdRToMon}& 1, 1, 2, 6, 16, 44, 120 &No\\\\\n\\hyperlink{CDIdRL}{CDIdRL}& 1, 1, 2, 6, 15, 44, 115 &No\\\\\n\\hyperlink{Mslat}{Mslat}& 1, 1, 2, 5, 15, 53, 222, 1078,... &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{Jslat}{Jslat}& 1, 1, 2, 5, 15, 53, 222, 1078,... &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{ubJslat}{ubJslat}& 1, 1, 2, 5, 15, 53, 222, 1078,... &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{CIdRToSgrp}{CIdRToSgrp}& 1, 1, 2, 5, 14, 42 &\\\\\n\\hyperlink{GBL}{GBL}& 1, 1, 2, 5, 10, 23, 49, 111 &No\\\\\n\\hyperlink{BLA}{BLA}& 1, 1, 2, 5, 10, 23, 49, 111 &No\\\\\n\\hyperlink{Hp}{Hp}& 1, 1, 2, 5, 10, 23, 49 &No\\\\\n\\hyperlink{CIdRSlMon}{CIdRSlMon}& 1, 1, 2, 5, 9, 20, 38 &No\\\\\n\\hyperlink{CInSlMon}{CInSlMon}& 1, 1, 2, 5, 8, 20, 36, 90 &No\\\\\n\\hyperlink{InToMon}{InToMon}& 1, 1, 2, 4, 8, 17, 38 &\\href{http://oeis.org/A229202}{??}\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{CyInToMon}{CyInToMon}& 1, 1, 2, 4, 8, 17, 38, 91 &\\\\\n\\hyperlink{CInToMon}{CInToMon}& 1, 1, 2, 4, 8, 17, 36, 81 &No\\\\\n\\hyperlink{CIdRToMon}{CIdRToMon}& 1, 1, 2, 4, 8, 16, 32 &\\\\\n\\hyperlink{sqMV}{sqMV}& 1, 1, 2, 2, 5, 5, 8 &\\\\\n\\hyperlink{qMV}{qMV}& 1, 1, 1, 9, 9, 467 &No\\\\\n\\hyperlink{Rng$_1$}{Rng$_1$}& 1, 1, 1, 4, 1, 1, 1, 11, 4, 1 &\\href{http://oeis.org/A037291}{A037291}\\\\\n\\hyperlink{CRng$_1$}{CRng$_1$}& 1, 1, 1, 4, 1, 1, 1, 10, 4, 1 &\\href{http://oeis.org/A127707}{A127707}\\\\\n\\hyperlink{HilA}{HilA}& 1, 1, 1, 3, 8, 27, 113 &No\\\\\n\\hyperlink{InLat}{InLat}& 1, 1, 1, 3, 5, 14, 27 &No\\\\\n\\hyperlink{InPorim}{InPorim}& 1, 1, 1, 3, 3, 13, 17, 84 &No\\\\\n\\hyperlink{IInFL}{IInFL}& 1, 1, 1, 3, 3, 12, 17, 78 &No\\\\\n\\hyperlink{CyInPorim}{CyInPorim}& 1, 1, 1, 3, 3, 12, 15, 79 &No\\\\\n\\hyperlink{CyIInFL}{CyIInFL}& 1, 1, 1, 3, 3, 12, 15, 75 &No\\\\\n\\hyperlink{InPocrim}{InPocrim}& 1, 1, 1, 3, 3, 12, 15, 73, 116 &No\\\\\n\\hyperlink{CIInFL}{CIInFL}& 1, 1, 1, 3, 3, 12, 15, 70, 112 &No\\\\\n\\hyperlink{DIInFL}{DIInFL}& 1, 1, 1, 3, 3, 12, 13, 66 &No\\\\\n\\hyperlink{CyDIInFL}{CyDIInFL}& 1, 1, 1, 3, 3, 12, 12, 65 &No\\\\\n\\hyperlink{CDIInFL}{CDIInFL}& 1, 1, 1, 3, 3, 12, 12, 60, 73 &No\\\\\n\\hyperlink{MZrd}{MZrd}& 1, 1, 1, 3, 3, 8, 12, 35 &No\\\\\n\\hyperlink{IMTL}{IMTL}& 1, 1, 1, 3, 3, 8, 12, 35 &No\\\\\n\\hyperlink{DInLat}{DInLat}& 1, 1, 1, 3, 1, 4, 3, 11 &No\\\\\n\\hyperlink{DmA}{DmA}& 1, 1, 1, 3, 1, 4, 2, 9, 5, 14 &No\\\\\n\\hyperlink{Lp}{Lp}& 1, 1, 1, 2, 6, 109, 23746,... &\\href{http://oeis.org/A057771}{A057771}\\\\\n\\hyperlink{Lat}{Lat}& 1, 1, 1, 2, 5, 15, 53, 222, 1078,... &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{lbJslat}{lbJslat}& 1, 1, 1, 2, 5, 15, 53 &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{bLat}{bLat}& 1, 1, 1, 2, 5, 15, 53 &\\href{http://oeis.org/A006966}{A006966}\\\\\n\\hyperlink{MsdLat}{MsdLat}& 1, 1, 1, 2, 4, 9, 23, 65, 197, 636 &No\\\\\n\\hyperlink{JsdLat}{JsdLat}& 1, 1, 1, 2, 4, 9, 23, 65, 197, 636 &No\\\\\n\\hyperlink{SdLat}{SdLat}& 1, 1, 1, 2, 4, 9, 22, 60, 174, 534 &\\href{http://oeis.org/A292790}{A292790}\\\\\n\\hyperlink{ModLat}{ModLat}& 1, 1, 1, 2, 4, 8, 16, 34, 72, 157 &\\href{http://oeis.org/A006981}{A006981}\\\\\n\\hyperlink{AdLat}{AdLat}& 1, 1, 1, 2, 4 &\\\\\n\\hyperlink{IInToMon}{IInToMon}& 1, 1, 1, 2, 3, 7, 12, 35 &\\\\\n\\hyperlink{CyIInToMon}{CyIInToMon}& 1, 1, 1, 2, 3, 7, 12, 35 &\\\\\n\\hyperlink{IMTLChn}{IMTLChn}& 1, 1, 1, 2, 3, 7, 12, 31, 59 &\\href{http://oeis.org/A034786}{A034786}\\\\\n\\hyperlink{HA}{HA}& 1, 1, 1, 2, 3, 5, 8, 15, 26, 47 &\\href{http://oeis.org/A006982}{A006982}\\\\\n\\hyperlink{DLat}{DLat}& 1, 1, 1, 2, 3, 5, 8, 15, 26, 47 &\\href{http://oeis.org/A006982}{A006982}\\\\\n\\hyperlink{BrSlat}{BrSlat}& 1, 1, 1, 2, 3, 5, 8, 15, 26, 47 &\\href{http://oeis.org/A006982}{A006982}\\\\\n\\hyperlink{BrA}{BrA}& 1, 1, 1, 2, 3, 5, 8, 15, 26, 47 &\\href{http://oeis.org/A006982}{A006982}\\\\\n\\hyperlink{bDLat}{bDLat}& 1, 1, 1, 2, 3, 5, 8, 15, 26, 47 &\\href{http://oeis.org/A006982}{A006982}\\\\\n\\hyperlink{StAlg}{StAlg}& 1, 1, 1, 2, 2, 4, 5, 10, 16, 28 &No\\\\\n\\hyperlink{CIdInFL}{CIdInFL}& 1, 1, 1, 2, 2, 4, 4, 9, 10, 21 &No\\\\\n\\hyperlink{KLA}{KLA}& 1, 1, 1, 2, 1, 3, 2, 6, 4, 10 &No\\\\\n\\hyperlink{PoGrp}{PoGrp}& 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1 &\\href{http://oeis.org/A000001}{A000001}\\\\\n\\hyperlink{Grp}{Grp}& 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1 &\\href{http://oeis.org/A000001}{A000001}\\\\\n\\hyperlink{CanSgrp}{CanSgrp}& 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1 &\\href{http://oeis.org/A000001}{A000001}\\\\\n\\hyperlink{psMV}{psMV}& 1, 1, 1, 2, 1, 2, 1, 3, 2, 2 &\\\\\n\\hyperlink{GödA}{GödA}& 1, 1, 1, 2, 1, 2, 1, 3, 1, 2 &\\\\\n\\hyperlink{MV}{MV}& 1, 1, 1, 2, 1, 2, 1, 3 &\\\\\n\\hyperlink{CanMon}{CanMon}& 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1 &\\href{http://oeis.org/A000001}{A000001}\\\\\n\\hyperlink{AbPoGrp}{AbPoGrp}& 1, 1, 1, 2, 1, 1, 1, 3, 2, 1 &\\href{http://oeis.org/A000688}{A000688}\\\\\n\\hyperlink{AbGrp}{AbGrp}& 1, 1, 1, 2, 1, 1, 1, 3, 2, 1 &\\href{http://oeis.org/A000688}{A000688}\\\\\n\\hyperlink{CanCSgrp}{CanCSgrp}& 1, 1, 1, 2, 1, 1, 1 &\\href{http://oeis.org/A000688}{A000688}\\\\\n\\hyperlink{CanCMon}{CanCMon}& 1, 1, 1, 2, 1, 1, 1 &\\href{http://oeis.org/A000688}{A000688}\\\\\n\\hyperlink{InToLat}{InToLat}& 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 &\\\\\n\\hyperlink{ToLat}{ToLat}& 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 &\\href{http://oeis.org/A000012}{A000012}\\\\\n\\hyperlink{Set}{Set}& 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 &\\href{http://oeis.org/A000012}{A000012}\\\\\n\\hyperlink{UFDom}{UFDom}& 1, 1, 1, 1, 1, 0 &\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{PIDom}{PIDom}& 1, 1, 1, 1, 1, 0 &\\\\\n\\hyperlink{IntDom}{IntDom}& 1, 1, 1, 1, 1, 0 &\\\\\n\\hyperlink{EucDom}{EucDom}& 1, 1, 1, 1, 1, 0 &\\\\\n\\hyperlink{NRng$_1$}{NRng$_1$}& 1, 1, 1, 6, 1, 1, 1, 53, 11, 1 &No\\\\\n\\hyperlink{MouLp}{MouLp}& 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1 &\\\\\n\\hyperlink{LRng}{LRng}& 1, 1, 1, 2, 3, 5, 8 &\\\\\n\\hyperlink{BIdRSgrp}{BIdRSgrp}& 1, 1, 0, 7, 0, 0, 0, 26 &No\\\\\n\\hyperlink{BLrMon}{BLrMon}& 1, 1, 0, 6, 0, 0, 0, 90 &\\href{http://oeis.org/A305324}{??}\\\\\n\\hyperlink{BSlat}{BSlat}& 1, 1, 0, 5, 0, 0, 0 &\\\\\n\\hyperlink{BInFL}{BInFL}& 1, 1, 0, 5, 0, 0, 0, 25 &No\\\\\n\\hyperlink{BCyInFL}{BCyInFL}& 1, 1, 0, 5, 0, 0, 0 &(Stopped)\\\\\n\\hyperlink{BCInFL}{BCInFL}& 1, 1, 0, 5, 0, 0, 0&\\\\\n\\hyperlink{BRL}{BRL}& 1, 1, 0, 5, 0, 0&\\\\\n\\hyperlink{BCRL}{BCRL}& 1, 1, 0, 5, 0&\\\\\n\\hyperlink{RA}{RA}& 1, 1, 0, 3, 0, 0&\\\\\n\\hyperlink{BIdLrMon}{BIdLrMon}& 1, 1, 0, 3, 0, 0&\\\\\n\\hyperlink{BCIdRSgrp}{BCIdRSgrp}& 1, 1, 0, 3, 0, 0&\\\\\n\\hyperlink{IRA}{IRA}& 1, 1, 0, 2, 0, 0, 0, 10, 102, 4412&\\\\\n\\hyperlink{BInLat}{BInLat}& 1, 1, 0, 2, 0, 0&\\\\\n\\hyperlink{BIdRL}{BIdRL}& 1, 1, 0, 2, 0, 0&\\\\\n\\hyperlink{BCIdRL}{BCIdRL}& 1, 1, 0, 2, 0, 0&\\\\\n\\hyperlink{CplmLat}{CplmLat}& 1, 1, 0, 1, 2&\\\\\n\\hyperlink{CdMLat}{CdMLat}& 1, 1, 0, 1, 1&\\\\\n\\hyperlink{OLat}{OLat}& 1, 1, 0, 1, 0, 2, 0, 5, 0, 15&\\\\\n\\hyperlink{OMLat}{OMLat}& 1, 1, 0, 1, 0, 1, 0, 2&\\\\\n\\hyperlink{BA}{BA}& 1, 1, 0, 1, 0, 0, 0, 1, 0, 1&\\\\\n\\hyperlink{BCIInFL}{BCIInFL}& 1, 1, 0, 1, 0, 0, 0, 1, 0&\\\\\n\\hyperlink{BIInFL}{BIInFL}& 1, 1, 0, 1, 0, 0, 0, 1&\\\\\n\\hyperlink{BGrp}{BGrp}& 1, 1, 0, 1, 0, 0, 0, 1&\\\\\n\\hyperlink{BCyIInFL}{BCyIInFL}& 1, 1, 0, 1, 0, 0, 0, 1&\\\\\n\\hyperlink{GBA}{GBA}& 1, 1, 0, 1, 0, 0&\\\\\n\\hyperlink{BIRL}{BIRL}& 1, 1, 0, 1, 0, 0&\\\\\n\\hyperlink{BCIRL}{BCIRL}& 1, 1, 0, 1, 0, 0&\\\\\n\\hyperlink{BCIMon}{BCIMon}& 1, 1, 0, 1, 0, 0&\\\\\n\\hyperlink{BIMon}{BIMon}& 1, 1, 0, 1, 0&\\\\\n\\hyperlink{BILrMon}{BILrMon}& 1, 1, 0, 1, 0&\\\\\n\\hyperlink{Bilat}{Bilat}& 1, 0, 0, 1, 3, 32, 284&\\\\\n\\hyperlink{RepLGrp}{RepLGrp}& 1, 0, 0, 0, 0, 0&\\\\\n\\hyperlink{AbLGrp}{AbLGrp}& 1, 0, 0, 0, 0, 0&\\\\\n\\hyperlink{LGrp}{LGrp}& 1, 0, 0, 0, 0, 0&\\\\\n\\hyperlink{TrivA}{TrivA}& 1, 0, 0&\\\\\n\\hyperlink{ToGrp}{ToGrp}& 1, 0, 0&\\\\\n\\hyperlink{CanRL}{CanRL}& 1, 0, 0&\\\\\n\\hyperlink{AbToGrp}{AbToGrp}& 1, 0, 0&\\\\\n\\hyperlink{Fld}{Fld}& 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1 &\\href{https://oeis.org/A069513}{A069513}\\\\\n\\hyperlink{pcDLat}{pcDLat}& &\\\\\n\\hyperlink{pGrp}{pGrp}& &\\\\\n\\hyperlink{WaHp}{WaHp}& &\\\\\n\\hyperlink{Unar}{Unar}& &\\\\\n\\hyperlink{ToRng}{ToRng}& &\\\\\n\\hyperlink{ToFld}{ToFld}& &\\\\\n\\hyperlink{TA}{TA}& &\\\\\n\\hyperlink{SkLat}{SkLat}& &\\\\\n\\hyperlink{SeqA}{SeqA}& &\\\\\n\\hyperlink{RegRng}{RegRng}& &\\\\\n\\hyperlink{RMod}{RMod}& &\\\\\n\\hyperlink{OreDom}{OreDom}& &\\\\\n\\hyperlink{OckA}{OckA}& &\\\\\n\\hyperlink{NlGrp}{NlGrp}& &\\\\\n\\hyperlink{Neofld}{Neofld}& &\\\\\n\\hyperlink{NdLat}{NdLat}& &\\\\\n\\hyperlink{NaA}{NaA}& &\\\\\n\\end{tabular}\n\n\\begin{tabular}{|l|l|l|}\n\\hyperlink{NVLGrp}{NVLGrp}& &\\\\\n\\hyperlink{NFld}{NFld}& &\\\\\n\\hyperlink{NA}{NA}& &\\\\\n\\hyperlink{Mset}{Mset}& &\\\\\n\\hyperlink{MonA}{MonA}& &\\\\\n\\hyperlink{MTLA}{MTLA}& &\\\\\n\\hyperlink{ModOLat}{ModOLat}& &\\\\\n\\hyperlink{MALLA}{MALLA}& &\\\\\n\\hyperlink{MA}{MA}& &\\\\\n\\hyperlink{LieA}{LieA}& &\\\\\n\\hyperlink{LNeofld}{LNeofld}& &\\\\\n\\hyperlink{LLA}{LLA}& &\\\\\n\\hyperlink{LA$_n$}{LA$_n$}& &\\\\\n\\hyperlink{JorA}{JorA}& &\\\\\n\\hyperlink{ImpLat}{ImpLat}& &\\\\\n\\hyperlink{ILLA}{ILLA}& &\\\\\n\\hyperlink{Gset}{Gset}& &\\\\\n\\hyperlink{GMV}{GMV}& &\\\\\n\\hyperlink{FVec}{FVec}& &\\\\\n\\hyperlink{FRng}{FRng}& &\\\\\n\\hyperlink{DunnMon}{DunnMon}& &\\\\\n\\hyperlink{DpAlg}{DpAlg}& &\\\\\n\\hyperlink{DdpAlg}{DdpAlg}& &\\\\\n\\hyperlink{DblStAlg}{DblStAlg}& &\\\\\n\\hyperlink{DmMon}{DmMon}& &\\\\\n\\hyperlink{DDblpAlg}{DDblpAlg}& &\\\\\n\\hyperlink{CliffSgrp}{CliffSgrp}& &\\\\\n\\hyperlink{CToRng}{CToRng}& &\\\\\n\\hyperlink{CRegRng}{CRegRng}& &\\\\\n\\hyperlink{CA$_2$}{CA$_2$}& &\\\\\n\\hyperlink{CLRng}{CLRng}& &\\\\\n\\hyperlink{BoolLat}{BoolLat}& &\\\\\n\\hyperlink{BilinA}{BilinA}& &\\\\\n\\hyperlink{BRMod}{BRMod}& &\\\\\n\\hyperlink{BCK}{BCK}& &\\\\\n\\hyperlink{AbpGrp}{AbpGrp}& &\\\\\n\\hyperlink{AAlg}{AAlg}& \\\\\\hline\n\\end{tabular}\n%\\end{multicols}\n}\n\n\\onecolumn\n", "meta": {"hexsha": "2cd216c4a6e0da02b40049ab2940ab2d867b8d69", "size": 29465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX files/SoPoAappendix.tex", "max_stars_repo_name": "jipsen/Survey-of-po-algebras", "max_stars_repo_head_hexsha": "63c8d09372400904d1c09cbf77b28c9d65e8926b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX files/SoPoAappendix.tex", "max_issues_repo_name": "jipsen/Survey-of-po-algebras", "max_issues_repo_head_hexsha": "63c8d09372400904d1c09cbf77b28c9d65e8926b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LaTeX files/SoPoAappendix.tex", "max_forks_repo_name": "jipsen/Survey-of-po-algebras", "max_forks_repo_head_hexsha": "63c8d09372400904d1c09cbf77b28c9d65e8926b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.2633517495, "max_line_length": 299, "alphanum_fraction": 0.6052604785, "num_tokens": 17212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.41325932684134725}}
{"text": "\\documentclass{article}\n\\newsavebox{\\oldepsilon}\n\\savebox{\\oldepsilon}{\\ensuremath{\\epsilon}}\n\\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit\n\\renewcommand*{\\epsilon}{\\usebox{\\oldepsilon}}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx} % For .eps inclusion\n%\\usepackage{indentfirst} % Controls indentation\n\\usepackage[compact]{titlesec} % For regulating spacing before section titles\n\\usepackage{adjustbox} % For vertically-aligned side-by-side minipages\n\\usepackage{array, amsmath,  mhchem}\n\\usepackage{hyper ref}\n\\usepackage{courier, subcaption}\n\\usepackage{multirow, color}\n\\usepackage[autolinebreaks,framed,numbered]{mcode}\n\n\\usepackage{float}\n\\restylefloat{table}\n\n\\pagenumbering{gobble} \n\\setlength\\parindent{0 cm}\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{document}\n\\large\n\n\\section*{Problem 1}\n\nUltimately we would like to calculate the rate of product formation, which from the law of mass action is given by:\n\n\\[ \\frac{d\\left[ P \\right]}{dt} = k_2 \\left[ C_2 \\right] - k_{-2} \\left[ P \\right] \\left[ E \\right] \\]\n\nAssume that $[C_2]$ is at steady state:\n\n\\[ 0 = \\frac{d \\left[ C_2 \\right]}{dt} =  k_r \\left[ C_1 \\right] + k_{-2} \\left[ P \\right] \\left[ E \\right] - k_2 \\left[ C_2 \\right] = k_r \\left[ C_1 \\right]  -  \\frac{d\\left[ P \\right]}{dt}   \\implies  \\frac{d\\left[ P \\right]}{dt}  = k_r \\left[ C_1 \\right] \\]\n\nAssume that $[C_1]$ is also at steady state:\n\n\\[ 0 = \\frac{d \\left[ C_1 \\right]}{dt} =  k_1 \\left[ S \\right] \\left[ E \\right] -\\left(  k_{-1} + k_r \\right)  \\left[ C_1 \\right] \\implies \\left[ C_1 \\right]  = \\frac{k_1 \\left[ S \\right] \\left[ E \\right]}{k_{-1} + k_r} \\]\n\nGiven this expression and the above result:\n\n\\begin{eqnarray}\n \\frac{d\\left[ P \\right]}{dt}  = \\frac{k_1 k_r \\left[ S \\right] \\left[ E \\right]}{k_{-1} + k_r} \\label{eqn:prob1a} \n \\end{eqnarray}\n\nThe desired rate law expression is equivalent to this statement, but does not contain the variable $[E]$, suggesting we must substitute an equivalent expression for $[E]$. Noting that the enzyme moiety is conserved, we can see that:\n\n\\begin{eqnarray*}\n\\left[ E_{\\textrm{tot}} \\right]  & = &  \\left[ E\\right]  + \\left[ C_1 \\right] + \\left[ C_2 \\right]\\\\\n \\left[ E\\right] & = & \\left[ E_{\\textrm{tot}} \\right] - \\left[ C_1 \\right] - \\left[ C_2 \\right]\\\\\n & = & \\left[ E_{\\textrm{tot}} \\right] - \\frac{k_1}{k_{-1} + k_r} \\left[ S \\right] \\left[ E \\right] - \\left[ C_2 \\right]\n\\end{eqnarray*}\n\nTo simplify further, we must find an expression for $[C_2]$. The statement that the product readily rebinds free enzyme suggests that it may be appropriate to assume a rapid equilibrium assumption for the right-most reversible reaction:\n\n\\begin{eqnarray*}\nk_2 \\left[ C_2 \\right] & = & k_{-2} \\left[ P \\right] \\left[ E \\right]\\\\\n\\left[ C_2 \\right] & = & \\frac{k_{-2} }{k_2} \\left[ P \\right] \\left[ E \\right]\n\\end{eqnarray*}\n\nwhere we have again defined $K_p$ for convenience. Plugging this expression for $[C_2]$ into our expression for $[E]$ derived from moiety conservation and rearranging, we get:\n\n\\begin{eqnarray*}\n \\left[ E\\right] & = & \\left[ E_{\\textrm{tot}} \\right] - \\frac{k_1}{k_{-1} + k_r} \\left[ S \\right] \\left[ E \\right] - K_p \\left[ P \\right] \\left[ E \\right]\\\\\n \\left(1 + \\frac{k_1 \\left[ S \\right]}{k_{-1} + k_r} + \\frac{k_{-2} }{k_2}  \\left[ P \\right] \\right) \\left[ E \\right]   & = & \\left[ E_{\\textrm{tot}} \\right]\\\\\n  \\left(\\frac{k_{-1}+k_r}{k_1} + \\left[ S \\right]+ \\frac{k_{-2} \\left(k_{-1}+k_r \\right)}{k_1k_2}  \\left[ P \\right] \\right) \\left[ E \\right]   & = & \\frac{k_{-1}+k_r}{k_1} \\left[ E_{\\textrm{tot}} \\right]\\\\\n   \\left( K_m + \\left[ S \\right] + \\frac{K_m}{K_p} \\left[ P \\right] \\right) \\left[ E \\right] & = & K_m \\left[ E_{\\textrm{tot}} \\right]\\\\\n \\left[ E \\right] & = & \\frac{K_m \\left[ E_{\\textrm{tot}} \\right]}{\\left[ S \\right] + K_m \\left(1 + \\frac{\\left[ P \\right]}{K_p} \\right)}\n\\end{eqnarray*}\n\nwhere we have defined $K_m$ and $K_p$ for convenience. This expression for $[E]$ can be plugged into equation \\ref{eqn:prob1a} to get:\n\n\\begin{eqnarray*}\n \\frac{d\\left[ P \\right]}{dt}  & = & \\frac{k_r \\left[ S \\right]}{K_m} \\left( \\frac{K_m \\left[ E_{\\textrm{tot}} \\right]}{\\left[ S \\right] + K_m \\left(1 + \\frac{\\left[ P \\right]}{K_p}  \\right)} \\right)  = \\frac{V_{\\textrm{max}} \\left[ S \\right]}{\\left[ S \\right] + K_m \\left(1 + \\frac{\\left[ P \\right]}{K_p} \\right)}\n \\end{eqnarray*}\n \n \\section*{Problem 2}\n\nWe illustrate two approaches: the first uses rapid equilibrium assumptions for binding, and the second uses quasi-steady-state assumptions as the problem statement hints.\n\n\\subsection*{Rapid equilibrium assumptions}\n\nEnzyme moiety conservation gives the expression:\n\n\\[ \\left[ E_{\\textrm{tot}} \\right] = \\left[ E \\right] + \\left[ ES \\right] + \\left[ EI \\right] + \\left[ ESI \\right] \\]\n\nTo simplify this, we will assume that all substrate and inhibitor binding events are in rapid equilibrium:\n\n\\begin{eqnarray*}\nk_1 \\left[ E \\right] \\left[ S \\right] = k_{-1} \\left[ ES \\right] & \\implies & \\left[ E \\right]  = \\frac{k_{-1} \\left[ ES \\right]}{k_1 \\left[ S \\right]}\\\\\nk_3 \\left[ E \\right] \\left[ I \\right] = k_{-3} \\left[ EI \\right] & \\implies & \\left[ EI \\right]  = \\frac{k_3 \\left[ I \\right]}{k_{-3}} \\left( \\frac{k_{-1} \\left[ ES \\right]}{k_1 \\left[ S \\right]} \\right) = \\frac{k_{-1}k_3 \\left[ I \\right] \\left[ ES \\right]}{k_{-3}k_1 \\left[ S \\right]}\\\\\nk_3 \\left[ ES \\right] \\left[ I \\right] = k_{-3} \\left[ ESI \\right] & \\implies & \\left[ ESI \\right] = \\frac{k_3 \\left[ ES \\right] \\left[ I \\right]}{k_{-3}}\n\\end{eqnarray*}\n\nPlugging these equations into the moiety conservation statement allows us to find an expression for [ES]:\n\n\\begin{eqnarray*}\n\\left[ E_{\\textrm{tot}} \\right] & = & \\left( \\frac{k_{-1}}{k_1 \\left[ S \\right]} + 1 + \\frac{k_{-1}k_3 \\left[ I \\right]}{k_1 k_{-3} \\left[ S \\right]} + \\frac{k_3 \\left[ I \\right]}{k_{-3}}  \\right) \\left[ ES \\right]\\\\\n& = & \\left( 1 + \\frac{k_3 \\left[ I \\right]}{k_{-3}} \\right)\\left( 1 + \\frac{k_{-1}}{k_{1}\\left[ S \\right]} \\right) \\left[ ES \\right]\\\\\n\\left[ ES \\right] & = & \\frac{\\left[ E_{\\textrm{tot}} \\right]}{\\left( 1 + \\frac{k_3 \\left[ I \\right]}{k_{-3}} \\right)\\left( 1 + \\frac{k_{-1}}{k_{1}\\left[ S \\right]} \\right)} = \\frac{\\left[ E_{\\textrm{tot}} \\right] \\left[ S \\right]}{\\left( 1 + \\frac{\\left[ I \\right]}{K_i} \\right)\\left( \\left[ S \\right] + K_m\\right)}\n\\end{eqnarray*}\n\nNotice that the definition of $K_m$ here is a bit unexpected: this is due to our use of rapid equilibrium rather than steady-state assumptions. Plugging this into the equation for rate of product formation, we get:\n\\begin{eqnarray*}\n\\frac{d \\left[ P \\right]}{dt} = k_2 \\left[ ES \\right] = \\left( \\frac{k_2 \\left[ E_{\\textrm{tot}} \\right]}{1 + \\frac{\\left[ I \\right]}{K_i}} \\right) \\frac{\\left[S\\right]}{\\left[ S \\right] + K_m} = \\left( \\frac{V_{\\textrm{max}}}{1 + \\frac{\\left[ I \\right]}{K_i}} \\right) \\frac{\\left[S\\right]}{\\left[ S \\right] + K_m}\n\\end{eqnarray*}\n\n\\subsection*{Quasi-steady-state assumptions}\n\nThe quasi-steady-state assumptions give three expressions:\n\n\\begin{eqnarray*}\n\\frac{d\\left[ EI \\right]}{dt} & = & k_{3} \\left[ E\\right] \\left[ I\\right]  + k_{-1} \\left[ ESI \\right] - \\left( k_1 \\left[ S \\right] + k_{-3} \\right) \\left[ EI \\right] = 0 \\\\\n\\frac{d\\left[ ES \\right]}{dt} & = & k_{1} \\left[ E\\right] \\left[ S \\right]  + k_{-3} \\left[ ESI \\right] - \\left( k_3 \\left[ I \\right] + k_{-1} + k_2 \\right) \\left[ ES \\right] = 0\\\\\n\\frac{d\\left[ ESI \\right]}{dt} & = & k_{1} \\left[ EI \\right] \\left[ S \\right]  + k_{3} \\left[ ES \\right] \\left[ I \\right] - \\left( k_{-3} + k_{-1} \\right) \\left[ ESI \\right] = 0 \\\\\n\\end{eqnarray*}\n\n\nWe can eliminate [E] from these expressions using moiety conservation, i.e.\n\n\\[ \\left[ E \\right] = \\left[ E_{\\textrm{tot}} \\right] - \\left[ ES \\right] - \\left[ EI \\right] - \\left[ ESI \\right] \\]\n\nPlugging in and rearranging, we get:\n\n\\begin{eqnarray*}\n\\frac{d\\left[ EI \\right]}{dt} & = & k_{3} \\left[ E_{\\textrm{tot}} \\right] \\left[ I\\right]  - k_{3} \\left[ I\\right]  \\left[ ES \\right]  + \\left(k_{-1} - k_3 \\left[ I \\right] \\right) \\left[ ESI \\right] - \\left( k_1 \\left[ S \\right] + k_{-3} + k_3 \\left[ I \\right] \\right) \\left[ EI \\right] = 0 \\\\\n\\frac{d\\left[ ES \\right]}{dt} & = & k_{1} \\left[ E_{\\textrm{tot}} \\right] \\left[ S \\right]  - k_{1} \\left[ S \\right] \\left[ EI \\right]  + \\left( k_{-3} - k_1 \\left[S\\right] \\right) \\left[ ESI \\right] - \\left( k_3 \\left[ I \\right] + k_{-1} + k_2 + k_1 \\left[S\\right] \\right) \\left[ ES \\right] = 0\\\\\n\\frac{d\\left[ ESI \\right]}{dt} & = & k_{1} \\left[ EI \\right] \\left[ S \\right]  + k_{3} \\left[ ES \\right] \\left[ I \\right] - \\left( k_{-3} + k_{-1} \\right) \\left[ ESI \\right] = 0 \\\\\n\\end{eqnarray*}\n\nThe third quasi-steady-state assumption gives us that:\n\n\\[ \\left[ ESI \\right] = \\frac{k_{1}}{k_{-3} + k_{-1}} \\left[ EI \\right] \\left[ S \\right]  + \\frac{k_{3}}{k_{-3} + k_{-1}} \\left[ ES \\right] \\left[ I \\right] \\]\n\nPlugging this in to the remaining two expressions, we get:\n\n\\begin{eqnarray*}\n\\frac{d\\left[ EI \\right]}{dt} & = & k_{3} \\left[ E_{\\textrm{tot}} \\right] \\left[ I\\right]  - k_{3} \\left[ I\\right]  \\left( \\frac{k_{-3} + k_3 \\left[ I \\right]}{k_{-3} + k_{-1} } \\right) \\left[ ES \\right]  - \\left( k_1 \\left[ S \\right] \\left( \\frac{k_{-3} + k_3 \\left[ I \\right]}{k_{-3} + k_{-1} } \\right) + k_{-3} + k_3 \\left[ I \\right] \\right) \\left[ EI \\right] = 0 \\\\\n\\frac{d\\left[ ES \\right]}{dt} & = & k_{1} \\left[ E_{\\textrm{tot}} \\right] \\left[ S \\right] \n- k_{1} \\left[ S \\right]  \\left( \\frac{k_{-1} + k_1 \\left[ S \\right]}{k_{-3} + k_{-1} } \\right) \\left[ EI \\right] - \\left( k_3 \\left[ I \\right] \\left( \\frac{k_{-1} + k_1 \\left[ S \\right]}{k_{-3} + k_{-1} } \\right) + k_{-1} + k_2 + k_1 \\left[S\\right] \\right) \\left[ ES \\right] = 0\n\\end{eqnarray*}\n\nWe can solve the first equation to find an expression for [EI], then plug this into the second equation and solve to find [ES]:\n\n\\begin{eqnarray*}\n\\left[ ES \\right] & = & \\frac{}{k_3 \\left[ I \\right] \\left( \\frac{k_{-1} + k_1 \\left[ S \\right]}{k_{-3} + k_{-1} } \\right) + k_{-1} + k_2 + k_1 \\left[S\\right]}\n\n\\end{eqnarray*}\n\n\n\\begin{lstlisting}\nfunction []  = mutualrepression()\n    % Pick some parameter values for plotting\n    global k n\n    k = 0.5; n=3;\n    \n    [x, y] = meshgrid(0:0.05:1.5, 0:0.05:1.5);\n    dx = k ./(k+y.^n) - x;\n    dy = k ./(k+x.^n) - y;\n    r = (dx.^2 + dy.^2).^0.5;\n    dx = dx ./ r;\n    dy = dy ./ r;\n    \n    quiver(x,y,dx,dy); hold on;\n    xlabel('[X]')\n    ylabel('[Y]')\n    axis([0,1.5,0,1.5])\n    [t, c] = ode45(@updater, [0 50], [0.7, 0.8]);\n    plot(c(:,1),c(:,2),'-r', 'LineWidth', 3)\n    plot(0.7, 0.8, 'or');\n    [t, c] = ode45(@updater, [0 50], [0.6,0.5]);\n    plot(c(:,1),c(:,2),'-g', 'LineWidth', 3);\n    plot(0.6, 0.5, 'og');\n    [t, c] = ode45(@updater, [0 50], [1.4,0.2]);\n    plot(c(:,1),c(:,2),'-b', 'LineWidth', 3);\n    plot(1.4, 0.2, 'ob');\n    [t, c] = ode45(@updater, [0 50], [0.3,1.2]);\n    plot(c(:,1),c(:,2),'-k', 'LineWidth', 3);\n    plot(0.3, 1.2, 'ok');\n    [t, c] = ode45(@updater, [0 50], [0.3,0.3]);\n    plot(c(:,1),c(:,2),'-m', 'LineWidth', 3);\n    plot(0.3, 0.3, 'om');\n      \nend\n\nfunction dc = updater(t, c)\n    x = c(1);\n    y = c(2);\n    global k n\n    dx = k/(k+y^n) - x;\n    dy = k/(k+x^n) - y;\n    dc = [dx; dy];\nend\n\\end{lstlisting}\n\n\n\\end{document}", "meta": {"hexsha": "2bcf66f58d3531aaf2cbecf80de9d7177bad2ad1", "size": 11154, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problem set keys/ps2/tex/ps2 answer key.tex", "max_stars_repo_name": "mewahl/intro-systems-biology", "max_stars_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-01-20T17:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-31T17:23:09.000Z", "max_issues_repo_path": "problem set keys/ps2/tex/ps2 answer key.tex", "max_issues_repo_name": "mewahl/intro-systems-biology", "max_issues_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problem set keys/ps2/tex/ps2 answer key.tex", "max_forks_repo_name": "mewahl/intro-systems-biology", "max_forks_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-01-20T17:43:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T14:42:10.000Z", "avg_line_length": 56.6192893401, "max_line_length": 369, "alphanum_fraction": 0.6038192577, "num_tokens": 4573, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7401743563075447, "lm_q1q2_score": 0.41325932364131196}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 18.2  Sorting Data of Arbitrary Structure in Memory\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nSort data having an organization or structure not supported by one of the\nsubprograms in Chapter~18.1, for example, data having more than one key to\ndetermine the sorted order. The subprogram INSORT in Chapter~18.3 has\nsimilar functionality to GSORTP and is more efficient if the data are\ninitially partly ordered, or the ordering criterion is expensive.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype}\n\n\\begin{description}\n\n\\item[INTEGER] \\ {\\bf N, IP}($\\geq |\\text{N}|$){\\bf , COMPAR}\n\n\\item[EXTERNAL] \\ {\\bf COMPAR}\n\n\\end{description}\n\nAssign values to N and data elements indexed by~1 through N. Require\nN $\\geq $ 1.\n$$\n\\fbox{\\bf CALL GSORTP (COMPAR, N, IP)}\n$$\nFollowing the call to GSORTP the contents of IP(1) through IP(N) are such\nthat the $\\text{J}^{th}$ element of the sorted sequence is the IP(J$)^{th}$ element\nof the original sequence.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\n\\item[COMPAR] \\ [in] An INTEGER FUNCTION subprogram that defines the relative\norder of elements of the data. COMPAR is invoked as COMPAR(I, J), and is\nexpected to return $-$1 (or any negative integer) if the $\\text{I}^{th}$\nelement of the original data is to precede the $\\text{J}^{th}$ element in\nthe sorted sequence, +1 (or any positive integer)\nif the $\\text{I}^{th}$ element is to follow the $\\text{J}^{th}$ element,\nand zero if the order is immaterial. GSORTP does not have access to the\ndata. It is the caller's responsibility to make the data known to COMPAR.\nSince COMPAR is a dummy procedure, it may have any name. Its name must\nappear in an EXTERNAL statement in the calling program unit.\n\n\\item[N] \\ [in] $|$N$|$ is the number of elements to sort, and the upper\n bound of subscripts to use to access IP.  If N $>$ 0 then IP(I) is\n initialized to I, for $1 \\leq I \\leq N$.  Actual arguments for COMPAR\n are always elements of IP.\n\n\\item[IP()] \\ [out] An array to contain the definition of the sorted\nsequence. IP(1:N) are set so the $\\text{J}^{th}$ element of the sorted sequence\nis the IP(J$)^{th}$ element of the original sequence.\n\\end{description}\n\n\\subsection{Examples and Remarks}\n\nProgram DRGSORTP illustrates the use of GSORTP to sort 1000 randomly\ngenerated real numbers. The output should consist of the single line\n\n\\hspace{.2in}GSORTP succeeded\n\n\\subparagraph{Stability}\n\nA sorting method is said to be $stable$ if the original relative order of\nequal elements is preserved. This subroutine uses the quicksort algorithm,\nwhich is not inherently stable. To impose stability, return COMPAR =\nI $-$ J if the $\\text{I}^{th}$ and $\\text{J}^{th}$ elements are equal.\n\n\\subsection{Functional Description}\n\nSee Section~18.1.D.\n\n\\subsection{Error Procedures and Restrictions}\n\nSee Section~18.1.E.\n\n\\subsection{Supporting Information}\n\nThe source language for these subroutines is ANSI Fortran 77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.2in} {\\bf Required Files}\\vspace{2pt}\\\\\nGSORTP & \\hspace{.35in} GSORTP\\\\\\end{tabular}\n\nDesigned and coded by W. V. Snyder, JPL~1988.\n\n\n\\begcodenp\n\\medskip\\\n\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRGSORTP}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{gsortp}}\n\\end{document}\n", "meta": {"hexsha": "b89c0719c6c30867e0e4b1e1699234832eb9faf3", "size": 3523, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch18-02.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch18-02.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch18-02.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 33.5523809524, "max_line_length": 98, "alphanum_fraction": 0.7451036049, "num_tokens": 1010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7401743505760727, "lm_q1q2_score": 0.41325932044127645}}
{"text": "\\documentclass[a4paper]{article}\r\n\\usepackage{graphicx}\r\n\\usepackage{fullpage}\r\n\\usepackage{graphicx} % for pdf, bitmapped graphics files\r\n\\usepackage{amsmath} % assumes amsmath package installed\r\n\\usepackage{amssymb}  % assumes amsmath package installed\\ref\r\n\\usepackage{psfrag}\r\n\\usepackage{algorithmic}\r\n\\usepackage{algorithm}\r\n\\usepackage{color}\r\n\\usepackage{xcolor}\r\n\\usepackage{listings}\r\n\\begin{document}\r\n\r\n\\lstset{\r\nlanguage=C++,\r\ncaptionpos=b,\r\ntabsize=2,\r\nkeywordstyle=\\color{blue},\r\ncommentstyle=\\color{green},\r\nstringstyle=\\color{red},\r\nbreaklines=true,\r\nshowstringspaces=false,\r\nframe=shadowbox,\r\nrulesepcolor=\\color{gray},\r\nbasicstyle=\\footnotesize%\r\n}\r\n\r\n\r\n\\newcommand{\\gopt}{g\\ensuremath{^2}o}\r\n\\newcommand{\\defeq}{\\stackrel{\\text{def.}}{=}}\r\n\\newcommand{\\gcomment}[1]{\\textcolor{red}{\\textbf{Giorgio:}~\\emph{#1}}}\r\n\\newcommand{\\rcomment}[1]{\\textcolor{red}{\\textbf{Rainer:}~\\emph{#1}}}\r\n\r\n\\def\\secref#1{Section~\\ref{#1}}\r\n\\def\\figref#1{Figure~\\ref{#1}}\r\n\\def\\tabref#1{Table~\\ref{#1}}\r\n\\def\\eqref#1{Eq.~\\ref{#1}}\r\n\r\n\\newcommand{\\Dom}{\\mathtt{Dom}}\r\n\\newcommand{\\bZero}{\\mathbf{0}}\r\n\\newcommand{\\bb}{\\mathbf{b}}\r\n\\newcommand{\\bc}{\\mathbf{c}}\r\n\\newcommand{\\bh}{\\mathbf{h}}\r\n\\newcommand{\\bH}{\\mathbf{H}}\r\n\\newcommand{\\bA}{\\mathbf{A}}\r\n\\newcommand{\\bM}{\\mathbf{M}}\r\n\\newcommand{\\bF}{\\mathbf{F}}\r\n\\newcommand{\\bG}{\\mathbf{G}}\r\n\\newcommand{\\bI}{\\mathbf{I}}\r\n\\newcommand{\\bB}{\\mathbf{B}}\r\n\\newcommand{\\bR}{\\mathbf{R}}\r\n\\newcommand{\\bp}{\\mathbf{p}}\r\n\\newcommand{\\bq}{\\mathbf{q}}\r\n\\newcommand{\\bqTilde}{\\mathbf{\\tilde q}}\r\n\\newcommand{\\ec}{\\mathbf{e}}\r\n\\newcommand{\\be}{\\mathbf{e}}\r\n\\newcommand{\\br}{\\mathbf{r}}\r\n\\newcommand{\\bx}{\\mathbf{x}}\r\n\\newcommand\\bbx{\\breve{\\bx}}\r\n\\newcommand{\\bu}{\\mathbf{u}}\r\n\\newcommand{\\bz}{\\mathbf{z}}\r\n\\newcommand{\\bt}{\\mathbf{t}}\r\n\\newcommand{\\bDeltax}{\\mathbf{\\Delta x}}\r\n\\newcommand{\\bDeltaAlpha}{\\mathbf{\\Delta \\alpha}}\r\n\\newcommand{\\bDeltaAlphaTilde}{\\mathbf{\\Delta\\tilde\\alpha}}\r\n\\newcommand{\\bTDeltax}{\\mathbf{\\Delta \\tilde x}}\r\n\\newcommand{\\bDelta}{\\mathbf{\\Delta}}\r\n\\newcommand{\\balpha}{\\mathbf{\\alpha}}\r\n\\newcommand{\\bOmega}{\\mathbf{\\Omega}}\r\n\\newcommand{\\bSigma}{\\mathbf{\\Sigma}}\r\n\\newcommand{\\bJ}{\\mathbf{J}}\r\n\\newcommand{\\diff}{\\partial}\r\n\\def\\argmax{\\mathop{\\rm argmax}}\r\n\\def\\argmin{\\mathop{\\rm argmin}}\r\n\r\n\\newcommand{\\Rstar}{{\\cal R} }\r\n\\newcommand{\\Rx}{R}\r\n\\newcommand{\\tx}{t}\r\n\r\n\\newcommand{\\angleOf}{\\mathbf{angleOf}}\r\n\\newcommand{\\axisOf}{\\mathbf{axisOf}}\r\n\\newcommand{\\slerp}{\\mathbf{slerp}}\r\n\r\n\\title{\\gopt: A general Framework for (Hyper) Graph Optimization}\r\n\\author{Giorgio Grisetti, Rainer K\\\"ummerle, Hauke Strasdat, Kurt Konolige\\\\\r\n\temail: \\texttt{\\{grisetti,kuemmerl\\}@informatik.uni-freiburg.de}\\\\\r\n        \\texttt{strasdat@gmail.com konolige@willowgarage.com}\r\n}\r\n\\maketitle\r\n\r\nIn this document we describe a C++ framework for performing the\r\noptimization of nonlinear least squares problems that can be embedded\r\nas a graph or in a hyper-graph. A hyper-graph is an extension of a\r\ngraph where an edge can connect multiple nodes and not only two.\r\nSeveral problems in robotics and in computer vision require to find\r\nthe optimum of an error function with respect of a set of parameters.\r\nExamples include, popular applications like SLAM and Bundle\r\nadjustment.\r\n\r\nIn the literature, many approaches have been proposed to address this\r\nclass of problems. The naive implementation of standard methods, like\r\nLevenberg-Marquardt or Gauss-Newton can lead to acceptable results for\r\nmost applications, when the correct parameterization is\r\nchosen. However, to achieve the maximum performances substantial\r\nefforts might be required.\r\n\r\n\\gopt\\ stands for General (Hyper) Graph Optimization. The purposes of\r\nthis framework are the following:\r\n\\begin{itemize}\r\n\\item To provide an easy-to-extend and easy-to-use general library for \r\n  graph optimization that can be easily applied to different problems,\r\n\\item To provide people who want to understand SLAM or BA with an\r\n  easy-to-read implementation that focuses on the relevant details of\r\n  the problem specification.\r\n\\item Achieve state-of-the-art performances, \r\n  while being as general as possible.\r\n\\end{itemize}\r\n\r\nIn the remainder of this document we will first characterize the\r\n(hyper) graph-embeddable problems, and we will give an introduction to\r\ntheir solution via the popular Levenberg-Marquardt or Gauss-Newton\r\nalgorithms implemented in this library.  Subsequently, we will\r\ndescribe the high-level behavior of the library, and the basic\r\nstructures.  Finally, we will introduce how to implement 2D SLAM as a\r\nsimple example.\\\\\r\n\\vspace{.5cm}\\\\\r\n\\textbf{This document is not a replacement for the\r\n  in-line documentation.  Instead, it is a digest to help the\r\n  user/reader to read/browse and extend the code.}\r\n\r\n  \\vspace{.5cm}\r\n\\noindent Please cite this when using \\gopt:\\\\\r\nR. K\\\"ummerle, G. Grisetti, H. Strasdat, K. Konolige, and W. Burgard.\r\ng2o: A General Framework for Graph Optimization. \r\nIn Proc. of the IEEE Int. Conf. on Robotics and Automation (ICRA). Shanghai, China, May 2011. \r\n\r\n\\section{(Hyper)Graph-Embeddable Optimization Problems}\r\nA least squares minimization problem can be described by the following equation:\r\n\\begin{eqnarray}\r\n\\bF(\\bx)&=& \\sum_{k \\in\\mathcal{C}}\r\n\\underbrace{\\be_k(\\bx_k, \\bz_{k})^T \\bOmega_{k} \\be_k(\\bx_k, \\bz_{k})}_{\\bF_{k}}\r\n\\label{eq:sumOfFactors}\\\\\r\n\\bx^*&=&\\argmin_{\\bx} \\bF(\\bx).\r\n\\label{eq:toMinimize}\r\n\\end{eqnarray}\r\nHere\r\n\\begin{itemize}\r\n  \\item  $\\bx=(\\bx_1^T,\\;\\ldots\\;,\\bx_n^T)^T$ is a vector of\r\n    parameters, where each $\\bx_i$ represents a generic parameter block.\r\n  \\item $\\bx_k=(\\bx_{k_1}^T,\\;\\ldots\\;,\\bx_{k_q}^T)^T \\subset\r\n    (\\bx_1^T,\\;\\ldots\\;,\\bx_n^T)^T$ is the subset of the parameters\r\n    involved in the $k^\\mathrm{th}$ constraint.  \r\n  \\item $\\bz_{k}$ and $\\bOmega_{k}$ represent \r\n    respectively the mean and the information matrix of a constraint\r\n    relating the parameters in $\\bx_k$.\r\n  \\item $\\be_k(\\bx_k \\bz_{k})$ is a vector error function\r\n    that measures how well the parameter blocks in $\\bx_k$ satisfy the\r\n    constraint $\\bz_{k}$. It is $\\bZero$ when $\\bx_k$ and $\\bx_j$\r\n    perfectly match the constraint.  As an example, if one has a\r\n    measurement function $\\hat \\bz_k = \\bh_k(\\bx_k)$ that generates a\r\n    synthetic measurement $\\hat \\bz_k$ given an actual configuration\r\n    of the nodes in $\\bx_k$.  A straightforward error function would\r\n    then be $\\be(\\bx_k, \\bz_{k}) = \\bh_k(\\bx_k) - \\bz_k$.\r\n\\end{itemize}\r\nFor simplicity of notation, in the rest of this paper we will encode\r\nthe measurement in the indices of the error function:\r\n\\begin{equation}\r\n\\be_k(\\bx_k, \\bz_{k}) \\; \\defeq \\; \\be_{k}(\\bx_k) \\; \\defeq \\; \\be_{k}(\\bx).\r\n\\end{equation}\r\nNote that each parameter block and each error\r\nfunction can span over a different space.  A problem in this form can\r\nbe effectively represented by a directed hyper-graph. A node $i$ of\r\nthe graph represents the parameter block $\\bx_i \\in \\bx_k$ and an\r\nhyper-edge among the nodes $\\bx_{i} \\in \\bx_k $ represents a\r\nconstraint involving all nodes in $\\bx_k$. In case the hyper edges\r\nhave size 2, the hyper-graph becomes an ordinary graph.\r\nFigure~\\ref{fig:graph-example} shows an\r\nexample of mapping between a hyper-graph and an objective function.\r\n\r\n\\begin{figure}\r\n\\centering\r\n\\psfrag{p0}{$\\bp_0$}\r\n\\psfrag{p1}{$\\bp_1$}\r\n\\psfrag{p2}{$\\bp_2$}\r\n\\psfrag{pi}{$\\bp_i$}\r\n\\psfrag{pj}{$\\bp_j$}\r\n\\psfrag{pim1}{$\\bp_{i-1}$}\r\n\\psfrag{z2i}{$\\bz_{2i}$}\r\n\\psfrag{K}{$\\mathbf{K}$}\r\n\\psfrag{zij}{$\\bz_{ij}$}\r\n\\psfrag{u0}{$\\bu_{0}$}\r\n\\psfrag{u1}{$\\bu_{1}$}\r\n\\psfrag{ui1}{$\\bu_{i-1}$}\r\n\\includegraphics{pics/hgraph.eps}\r\n\\caption{This example illustrates how to represent an objective\r\n  function by a hyper-graph. Here we illustrate a portion of a small\r\n  SLAM problem~\\cite{konolige10iros}. In this example we assume that\r\n  where the measurement functions are governed by some unknown\r\n  calibration parameters $\\mathbf{K}$. The robot poses are represented\r\n  by the variables $\\bp_{1:n}$. These variables are connected by\r\n  constraints $\\bz_{ij}$ depicted by the square boxes. The constraints\r\n  arise, for instance, by matching nearby laser scans \\emph{in the\r\n    laser reference frame}. The relation between a laser match and a\r\n  robot pose, however, depends on the position of the sensor on the\r\n  robot, which is modeled by the calibration parameters\r\n  $\\mathbf{K}$. Conversely, subsequent robot poses are connected by\r\n  binary constraints $\\bu_{k}$ arising from odometry\r\n  measurements. These measurements are made in the frame of the robot\r\n  mobile base.}\r\n\\label{fig:graph-example}\r\n\\end{figure}\r\n\r\n\\section{Least Squares Optimization}\r\nIf a good initial guess $\\breve{\\bx}$ of the parameters is known, a\r\nnumerical solution of \\eqref{eq:toMinimize} can be obtained by using\r\nthe popular Gauss-Newton or Levenberg-Marquardt\r\nalgorithms~\\cite[\\S15.5]{Press92Book}.  The idea is to approximate the\r\nerror function by its first order Taylor expansion around the current\r\ninitial guess $\\breve{\\bx}$\r\n\\begin{eqnarray}\r\n\\be_{k}(\\breve{\\bx}_k + \\bDeltax_k) &=& \\be_{k}(\\breve{\\bx} + \\bDeltax)\\\\\r\n&\\simeq& \\ec_{k} + \\bJ_{k} \\bDeltax.\r\n\\label{eq:taylor}\r\n\\end{eqnarray}\r\nHere $\\bJ_{k}$ is the Jacobian of $\\be_{k}(\\bx)$ computed in\r\n$\\breve{\\bx}$ and $\\ec_{k} \\defeq \\be_{k}(\\breve{\\bx})$.\r\nSubstituting \\eqref{eq:taylor} in the error terms $\\bF_{k}$ of\r\n\\eqref{eq:sumOfFactors}, we obtain\r\n\r\n\\vspace{-3.5mm}\r\n{\\small\r\n\\begin{eqnarray}\r\n\\lefteqn{\\bF_{k}(\\breve{\\bx} + \\bDeltax) }\\\\\r\n&=&  \\be_{k}(\\breve{\\bx} + \\bDeltax)^T \\bOmega_{k} \\be_{k}(\\breve{\\bx} + \\bDeltax)  \\\\\r\n\\label{eq:errorQuad1}\r\n             &\\simeq& \\left(\\ec_{k} + \\bJ_{k} \\bDeltax \\right)^T \\bOmega_{k} \\left(\\ec_{k} + \\bJ_{k} \\bDeltax \\right)  \\\\\r\n\\label{eq:errorQuad2}\r\n             &=& \\underbrace{\\ec_{k}^T \\bOmega_{k}\\ec_{k}}_{\\mathrm{c}_{k}} + 2 \\underbrace{\\ec_{k}^T \\bOmega_{k} \\bJ_{k}}_{\\bb_{k}} \\bDeltax +\r\n \\bDeltax^T \\underbrace{\\bJ_{k}^T \\bOmega_{k}\\bJ_{k}}_{\\bH_{k}} \\bDeltax \\\\\r\n             &=&\\mathrm{c}_{k} + 2 \\bb_{k} \\bDeltax + \\bDeltax^T \\bH_{k} \\bDeltax\r\n\\label{eq:errorQuad}\r\n\\end{eqnarray}\r\n} \r\nWith this local approximation, we can rewrite the function\r\n$\\bF(\\bx)$ given in \\eqref{eq:sumOfFactors} as\r\n\r\n\\vspace{-3.5mm}\r\n{\\small\r\n\\begin{eqnarray}\r\n\\bF(\\breve{\\bx} + \\bDeltax) &=& \\sum_{k \\in\\mathcal{C}} \\bF_{k}(\\breve{\\bx} + \\bDeltax) \r\n\\label{eq:optNetwork0}\\\\\r\n                      &\\simeq& \\sum_{k \\in\\mathcal{C}} \\mathrm{c}_{k} + 2 \\bb_{k} \\bDeltax + \\bDeltax^T \\bH_{k} \\bDeltax\r\n\\label{eq:optNetwork1}\\\\\r\n                      &=&\\mathrm{c} + 2 \\bb^T \\bDeltax + \\bDeltax^T \\bH \\bDeltax. \r\n\\label{eq:optNetwork2}\r\n\\end{eqnarray}\r\n} The quadratic form in \\eqref{eq:optNetwork2} is obtained from\r\n\\eqref{eq:optNetwork1} by setting $\\mathrm{c}=\\sum \\mathrm{c}_{k}$,\r\n$\\bb=\\sum \\bb_{k}$ and $\\bH=\\sum \\bH_{k}$. It can be minimized in\r\n$\\bDeltax$ by solving the linear system\r\n\\begin{eqnarray}\r\n       \\bH\\,\\bDeltax^* &=& - \\bb. \r\n\\label{eq:oneLinearIteration}\r\n\\end{eqnarray}\r\nThe matrix $\\bH$ is the information matrix of the system and is sparse\r\nby construction, having non-zeros only between blocks connected by a\r\nconstraint.  Its number of non-zero blocks is twice the number of\r\nconstrains plus the number of nodes. This allows to solve\r\n\\eqref{eq:oneLinearIteration} with efficient approaches like sparse\r\nCholesky factorization or Preconditioned Conjugate Gradients (PCG). An\r\nhighly efficient implementation of sparse Cholesky factorization can\r\nbe found in publicly available packages like CSparse~\\cite{csparse} or\r\nCHOLMOD~\\cite{cholmod}.  The linearized solution is then obtained by\r\nadding to the initial guess the computed increments\r\n\\begin{eqnarray}\r\n  \\bx^*&=&\\breve{\\bx}+\\bDeltax^*.\r\n\\label{eq:linearPropagation}\r\n\\end{eqnarray}\r\nThe popular Gauss-Newton algorithm iterates the linearization in\r\n\\eqref{eq:optNetwork2}, the solution in \\eqref{eq:oneLinearIteration}\r\nand the update step in \\eqref{eq:linearPropagation}. In every\r\niteration, the previous solution is used as linearization point and as\r\ninitial guess.\r\n\r\nThe Levenberg-Marquardt (LM) algorithm is a nonlinear variant to Gauss-Newton that introduces \r\na damping factor and backup actions to control the convergence.\r\nInstead of solving directly Eq.~\\ref{eq:oneLinearIteration}\r\nLM solves a damped version of it\r\n\\begin{eqnarray}\r\n       (\\bH +\\lambda \\bI)\\,\\bDeltax^* &=& - \\bb. \r\n\\label{eq:oneLinearIterationLevenberg}\r\n\\end{eqnarray}\r\nHere $\\lambda$ is a damping factor: the larger $\\lambda$ is the\r\nsmaller are the $\\bDeltax$. This is useful to control the step size in\r\ncase of non-linear surfaces.  The idea behind the LM algorithm is to\r\ndynamically control the damping factor.  At each iteration the error\r\nof the new configuration is monitored.  If the new error is lower than\r\nthe previous one, lambda is decreased for the next iteration.\r\nOtherwise, the solution is reverted and lambda is increased.\r\nFor a more detailed explanation of the LM algorithm implemented in our package\r\nwe refer to~\\cite{lourakis2009toms}.\r\n\r\nThe procedures described above are a general approach to multivariate\r\nfunction minimization. The general approach, however, assumes that the\r\nspace of parameters $\\bx$ is Euclidean, which is not valid for several\r\nproblems like SLAM or bundle adjustment. This may lead to sub-optimal\r\nsolutions. In the remainder of this section we discuss first the\r\ngeneral solution when the space of the parameters is Euclidean, and\r\nsubsequently we extend this solution to more general non-Euclidean\r\nspaces.\r\n\r\n\\section{Considerations about the Structure of the Linearized System}\r\nAccording to \\eqref{eq:optNetwork2}, the matrix $\\bH$ and the vector\r\n$\\bb$ are obtained by summing up a set of matrices and vectors, one\r\nfor every constraint.  If we set $\\bb_{k}=\\bJ_{k}^T \\bOmega_{k}\r\n\\ec_{k}$ and $\\bH_{k}= \\bJ_{k}^T \\bOmega_{k}\\bJ_{k}$ we can\r\nrewrite $\\bH$ and $\\bb$ as\r\n\\begin{eqnarray}\r\n  \\bb&=&\\sum_{k \\in\\mathcal{C}} \\bb_{ij}\\\\ \r\n  \\bH&=&\\sum_{k \\in\\mathcal{C}} \\bH_{ij}. \\label{eq:addendTerm}\r\n\\end{eqnarray}\r\nEvery constraint will contribute to the system with an addend\r\nterm. The \\emph{structure} of this addend depends on the Jacobian of\r\nthe error function.  Since the error function of a constraint depends\r\nonly on the values of the nodes $\\bx_i \\in \\bx_k$, the Jacobian in\r\n\\eqref{eq:taylor} has the following form:\r\n\\begin{eqnarray}\r\n\\bJ_{k} &=& \\left(\\bZero \\cdots \\bZero \\; \\bJ_{k_1} \\; \\cdots \\; \\bJ_{k_i} \\;\\cdots \\bZero\\; \\cdots\\;  \\bJ_{k_q} \\bZero \\cdots \\bZero \\right).\r\n\\label{eq:jacExpanded}\r\n\\end{eqnarray}\r\nHere $\\bJ_{k_i}= \\frac{\\partial \\be(\\bx_k)}{\\partial \\bx_{k_i}}$ are the\r\nderivatives of the error function with respect to the nodes connected\r\nby the $k^\\mathrm{th}$ hyper-edge, with respect to the parameter block\r\n$\\bx_{k_i} \\in \\bx_k$.\r\n\r\nFrom \\eqref{eq:errorQuad2} we obtain the following structure for the block matrix $\\bH_{ij}$:\r\n\\begin{eqnarray}\r\n\\bH_{k}&=&\\left(\r\n\\begin{array}{cccccccc}\r\n\\ddots & & & & & & &\\\\\r\n& \\bJ_{k_1}^T \\bOmega_{k} \\bJ_{k_1} & \\cdots & \\bJ_{k_1}^T \\bOmega_{k} \\bJ_{k_i} & \\cdots & \\bJ_{k_1}^T \\bOmega_{k} \\bJ_{k_q} &\\\\\r\n& \\vdots & & \\vdots & & \\vdots & \\\\\r\n& \\bJ_{k_i}^T \\bOmega_{k} \\bJ_{k_1} & \\cdots & \\bJ_{k_i}^T \\bOmega_{k} \\bB_{k_i} & \\cdots & \\bJ_{k_i}^T \\bOmega_{k} \\bJ_{k_q} & \\\\\r\n& \\vdots & & \\vdots & & \\vdots & \\\\\r\n& \\bJ_{k_q}^T \\bOmega_{k} \\bJ_{k_1} & \\cdots & \\bJ_{k_q}^T \\bOmega_{k} \\bB_{k_i} & \\cdots & \\bJ_{k_q}^T \\bOmega_{k} \\bJ_{k_q} & \\\\\r\n& &&&&&& \\ddots \\\\\r\n\\end{array}\r\n\\right) \\\\\r\n\\bb_{k}&=&\\left(\r\n\\begin{array}{c}\r\n\\vdots\\\\\r\n\\bJ_{k_1} \\bOmega_{k} \\ec_{k}\\\\\r\n\\vdots\\\\\r\n\\bJ_{k_i}^T \\bOmega_{k} \\ec_{k}\\\\\r\n\\vdots\\\\\r\n\\bJ_{k_q}^T \\bOmega_{k} \\ec_{k}\\\\\r\n\\vdots\\\\\r\n\\end{array}\r\n\\right) \r\n\\end{eqnarray}\r\nFor simplicity of notation we omitted the zero blocks.  The reader\r\nmight notice that the block structure of the matrix $\\bH$ is the\r\nadjacency matrix of the hyper graph.  Additionally the Hessian $\\bH$\r\nis a symmetric matrix, since all the $\\bH_k$ are symmetric. A single\r\nhyper-edge connecting $q$ vertices will introduce $q^2$ non zero\r\nblocks in the Hessian, in correspondence of each pair $\\left<\r\n\\bx_{k_i}, \\bx_{k_j} \\right>$, of nodes connected.\r\n\r\n\r\n\\section{Least Squares on Manifold}\r\n\\label{sec:manifold}\r\n\r\nTo deal with parameter blocks that span over a non-Euclidean spaces,\r\nit is common to apply the error minimization on a manifold.  A\r\nmanifold is a mathematical space that is not necessarily Euclidean on\r\na global scale, but can be seen as Euclidean on a local\r\nscale~\\cite{Lee2003SmoothManifolds}.\r\n\r\nFor example, in the context of SLAM problem, each parameter block\r\n$\\bx_i$ consists of a translation vector $\\bt_i$ and a rotational\r\ncomponent $\\balpha_i$. The translation~$\\bt_i$ clearly forms a Euclidean\r\nspace. In contrast to that, the rotational components~$\\balpha_i$ span\r\nover the non-Euclidean 2D or 3D rotation group $SO(2)$ or $SO(3)$.  To\r\navoid singularities, these spaces are usually described in an\r\nover-parameterized way, e.g., by rotation matrices or quaternions.\r\nDirectly applying \\eqref{eq:linearPropagation} to these\r\nover-parameterized representations breaks the constraints induced by the\r\nover-parameterization. The over-parameterization results in additional\r\ndegrees of freedom and thus introduces errors in the solution.  To\r\novercome this problem, one can use a minimal representation for the\r\nrotation (like Euler angles in 3D). This, however, is then subject to\r\nsingularities.\r\n\r\nAn alternative idea is to consider the underlying space as a manifold\r\nand to define an operator $\\boxplus$ that maps a local variation\r\n$\\bDeltax$ in the Euclidean space to a variation on the manifold,\r\n$\\bDeltax\\mapsto\\bx\\boxplus\\bDeltax$.  We refer the reader to\r\n\\cite[\\S1.3]{hertzberg08diplom} for more mathematical details. With\r\nthis operator, a new error function can be defined as\r\n\\begin{eqnarray}\r\n\\breve \\be_{k}(\\bTDeltax_k) &\\defeq&\r\n  \\be_{k}(\\bbx_k \\boxplus \\bTDeltax_k) \\\\\r\n  &=& \\be_{k}(\\bbx \\boxplus \\bTDeltax) \\label{eq:manifoldTaylor0}\r\n  \\simeq \\breve \\be_{k} + \\tilde \\bJ_{k} \\bTDeltax,\r\n\\label{eq:manifoldTaylor}\r\n\\end{eqnarray}\r\nwhere $\\bbx$ spans over the original over-parameterized space, for\r\ninstance quaternions. The term $\\bTDeltax$ is a small increment around\r\nthe original position $\\bbx$ and is expressed in a minimal\r\nrepresentation. A common choice for $SO(3)$ is to use the vector part\r\nof the unit quaternion.\r\n%\r\nIn more detail, one can represent the increments $\\bTDeltax$ as 6D vectors\r\n$\\bTDeltax^T = ( {\\bDelta\\tilde\\bt}^T \\, {\\bqTilde}^T)$,\r\nwhere $\\bDelta \\tilde \\bt$ denotes the translation and $\\bqTilde^T\r\n= ( \\Delta q_x \\, \\Delta q_y \\, \\Delta q_z)^T$ is the\r\nvector part of the unit quaternion representing the 3D rotation.  Conversely, $\\bbx^T=(\r\n\\breve \\bt^T \\, \\breve \\bq^T)$ uses a quaternion $\\breve \\bq$ to\r\nencode the rotational part.  Thus, the operator $\\boxplus$ can be\r\nexpressed by first converting $\\bDelta \\tilde \\bq$ to a full quaternion $\\bDelta\r\n\\bq$ and then applying the transformation $\\bDelta \\bx ^T = ( \\bDelta\r\n\\bt^T \\, \\bDelta \\bq^T)$ to $\\bbx$.  In the equations\r\ndescribing the error minimization, these operations can nicely be\r\nencapsulated by the $\\boxplus$ operator.  The Jacobian $\\tilde\r\n\\bJ_{k}$ can be expressed by\r\n\\begin{eqnarray}\r\n\\tilde \\bJ_{k} &=& \\left. \\frac{\\partial \\be_{k}(\\breve{\\bx} \\boxplus \\bTDeltax)} {\\partial \\bTDeltax} \\right|_{\\bTDeltax=\\bZero}.\r\n\\label{eq:manifoldJacobian}\r\n\\end{eqnarray}\r\nSince in the previous equation $\\breve{\\be}$ depends only on $\\bTDeltax_{k_i} \\in \\bTDeltax_{k}$ we can further expand it as follows:\r\n\\begin{eqnarray}\r\n\\tilde \\bJ_{k} &=& \r\n\\left. \r\n\\frac{\\partial \\be_{k}(\\breve{\\bx} \\boxplus \\bTDeltax)} {\\partial \\bTDeltax} \\right|_{\\bTDeltax=\\bZero}\\\\\r\n&=& \\left(\\bZero \\cdots \\bZero \\; \\tilde \\bJ_{k_1} \\; \\cdots \\; \\tilde \\bJ_{k_i} \\;\\cdots \\bZero\\; \\cdots\\;  \\tilde \\bJ_{k_q} \\bZero \\cdots \\bZero \\right).\r\n\\label{eq:manifoldJacobianSparse}\r\n\\end{eqnarray}\r\nWith a straightforward extension of notation, we set\r\n\\begin{equation}\r\n\\tilde \\bJ_{k_i} = \\left. \\frac{ \\partial \\be_{k}(\\breve{\\bx} \\boxplus \\bTDeltax)}{\\partial \\bTDeltax_{k_i}} \\right|_{\\bTDeltax=\\bZero}\r\n\\end{equation}\r\n\r\n%% Using the rule on the partial derivatives and exploiting the fact\r\n%% that the Jacobian is evaluated in $\\bTDeltax=\\bZero$, the non-zero\r\n%% blocks become:\r\n%% \\begin{eqnarray}\r\n%% \\frac{\\partial \\be_{k}(\\breve{\\bx_k} \\boxplus \\bTDeltax_k)} {\\partial \\bTDeltax_i} &=& \r\n%% \\underbrace{\\frac{\\partial \\be_{k}(\\breve{\\bx})} {\\partial \\breve{\\bx}_i}}_{\\bJ_{k_i}} \r\n%% \\cdot\r\n%% \\left.\r\n%% \\underbrace{\r\n%% \\frac{\\breve{\\bx}_{k_i} \\boxplus \\bTDeltax_{k_i}} {\\partial \\bTDeltax_{k_i}}\r\n%% }_{\\bM_{k_i}}\r\n%% \\right|_{\\bTDeltax=\\bZero}\r\n%% \\label{eq:manifoldJacobianBlocks}\r\n%% \\end{eqnarray}\r\n%% Accordingly, one can easily derive from the a Jacobian \\emph{not} defined on a manifold\r\n%% of Eq.~\\ref{eq:jacExpanded} a Jacobian on a manifold just by multiplying its non-zero blocks\r\n%% by the derivative of the $\\boxplus$ operator computed in $\\breve{\\bx_i}$ and $\\breve{\\bx_j}$.\r\n%% Let the Jacobians of $\\boxplus$ be denoted by $\\bM_{k_i}$. By using the notation in \r\n%% Eq.~\\ref{eq:jacExpanded} we can rewrite Eq.~\\ref{eq:manifoldJacobian} as\r\n%% \\begin{eqnarray}\r\n%% \\tilde \\bJ_{ij} &=& \r\n%% \\left(\\bZero \\cdots \\bZero \\; \\bJ_{k_1} \\bM_{k_1} \\; \\cdots \\; \\bJ_{k_i} \\bM_{k_i} \\;\\cdots \\bZero\\; \\cdots\\; \\bJ_{k_q}\\bM_{k_q} \\bZero \\cdots \\bZero \\right).\r\n%% \\label{eq:jacManExpanded}\r\n%% \\end{eqnarray}\r\n\r\nWith a straightforward extension of the notation, we can insert\r\n\\eqref{eq:manifoldTaylor} in \\eqref{eq:errorQuad1} and\r\n\\eqref{eq:optNetwork0}. This leads to the following increments:\r\n\\begin{eqnarray}\r\n       \\tilde \\bH \\, \\bTDeltax^* &=& - \\tilde \\bb .\r\n\\label{eq:oneLinearManifoldIteration}\r\n\\end{eqnarray}\r\nSince the increments $\\bTDeltax^*$ are computed in the local Euclidean\r\nsurroundings of the initial guess $\\breve{\\bx}$, they need to be\r\nre-mapped into the original redundant space by the $\\boxplus$\r\noperator. Accordingly, the update rule of \\eqref{eq:linearPropagation}\r\nbecomes\r\n\\begin{eqnarray}\r\n  \\bx^*& =& \\breve{\\bx} \\boxplus \\bTDeltax^*.\r\n\\label{eq:manifoldPropagation}\r\n\\end{eqnarray}\r\nIn summary, formalizing the minimization problem on a manifold consists\r\nof first computing a set of increments in a local Euclidean\r\napproximation around the initial guess by\r\n\\eqref{eq:oneLinearManifoldIteration}, and second accumulating the\r\nincrements in the global non-Euclidean space by\r\n\\eqref{eq:manifoldPropagation}.  Note that the linear system computed on\r\na manifold representation has the same structure like the linear system\r\ncomputed on an Euclidean space.  One can easily derive a manifold\r\nversion of a graph minimization from a non-manifold version, only by\r\ndefining an $\\boxplus$ operator and its Jacobian $\\tilde \\bJ_{k_{i}}$\r\nw.r.t.  the corresponding parameter block.  In \\gopt{} we provide tools\r\nfor numerically computing the Jacobians on the manifold space.  This\r\nrequires the user to implement the error function and the $\\boxplus$\r\noperator only. As a design choice, we do not address the non-manifold\r\ncase since it is already contained in the manifold one.  However, to\r\nachieve the maximum performances and accuracy we recommend the user to\r\nimplement analytic Jacobians, once the system is functioning with the\r\nnumeric ones.\r\n\r\n\\section{Robust Least Squares\\label{sec:robust_kernel}}\r\nOptionally, the least squares optimization can be robustified.\r\nNote, that the error terms in Eq.~\\ref{eq:sumOfFactors}  have the following form:\r\n\\begin{eqnarray}\r\n\\bF_k = \\be_k^T\\Omega_k \\be_k = \\rho_2\\left(\\sqrt{\\be_k^T\\Omega_k \\be_k}\\right) \\quad \\text{with} \\quad \\rho_2(x):=x^2.\r\n\\end{eqnarray}\r\nThus, the error vector $\\be_k$ has quadratic influence on $\\bF$, \r\nso that a single potential outlier would have major negative impact.\r\nIn order be more outlier robust, the quadratic error function $\\rho_2$\r\ncan be replaced by a more robust cost function which weighs large errors less. \r\nIn \\gopt, the Huber cost function $\\rho_H$ can be used\r\n\\begin{eqnarray}\r\n\\rho_H(x) := \\begin{cases}\r\n                 x^2         & \\text{if } |x|<b\\\\\r\n                  2b |x| - b^2          & \\text{else},\r\n   \\end{cases}\r\n\\end{eqnarray}\r\nwhich is quadratic for small $|x|$ but linear for large $|x|$. Compared to other,\r\neven more robust cost functions, the Huber kernel has to advantage that it is\r\nstill convex and thus does not introduce new local minima in $\\bF$~\\cite[pp.616]{Hartley:Zisserman:Book2004}.\r\nIn practice, we do not need to modify Eq.~$\\ref{eq:sumOfFactors}$. Instead, the following scheme \r\nis applied. First the  error $\\be_k$ is computed as usual. Then, $\\be_k$ is replaced by \r\na weighted version $w_k\\be_k$ such that \r\n\\begin{eqnarray}\r\n(w_k\\be_k)^T\\Omega_k (w_k\\be_k) = \\rho_H\\left(\\sqrt{\\be_k^T\\Omega_k \\be_k}\\right).\r\n\\end{eqnarray}\r\nHere, the weights $w_k$ are calculated as follows\r\n\\begin{eqnarray}\r\nw_k = \\frac{\\sqrt{\\rho_H\\left(||\\be_k||_\\Omega \\right)}}{||\\be_k||_\\Omega } \\quad \\text{with} \\quad ||\\be_k||_\\Omega := \\sqrt{\\be_k^T\\Omega_k \\be_k}.\r\n\\end{eqnarray}\r\nIn \\gopt, the user has fine-grained control and can enable/disable the robust cost function for each edge individually (see Section~\\ref{sec:error}).\r\n\r\n\r\n\r\n\r\n\\section{Library Overview}\r\nFrom the above sections it should be clear that a graph-optimization problem is entirely defined by:\r\n\\begin{itemize}\r\n\\item The types of the vertices in the graph (that are the parameters blocks $\\{\\bx_i\\}$. \r\n  For each of those one has to specify:\r\n  \\begin{itemize}\r\n    \\item the domain $\\Dom(\\bx_i)$ of the internal parameterization, \r\n    \\item the domain $\\Dom(\\bDeltax_i)$ of the increments $\\bDeltax_i$,\r\n    \\item $\\boxplus: \\Dom(\\bx_i) \\times \\Dom(\\bDeltax_i) \\rightarrow \\Dom(\\bx_i)$ that \r\n      applies the increment $\\bDeltax_i$ to the previous solution $\\bx_i$.\r\n  \\end{itemize}\r\n\\item the error function for every type of hyper-edge\r\n  $\\be_{k}:\\Dom(\\bDeltax_{k_1}) \\times \\Dom(\\bDeltax_{k_2}) \\times \\dots \\times\r\n  \\Dom(\\bDeltax_{k_q}) \\rightarrow \\Dom(\\bz_{k})$ that should be zero when\r\n  the perturbated estimate $\\bx_{k} \\boxplus \\bDeltax_{k}$ perfectly satisfies the constraint $\\bz_{k}$.\r\n\\end{itemize}\r\nBy default the Jacobians are computed numerically by our\r\nframework. However to achieve the maximum performances in a specific\r\nimplementation one can specify the Jacobian of the error functions and\r\nof the manifold operators.\r\n\r\nIn the reminder we will shortly discuss some basic concepts to use and\r\nextend \\gopt.  This documentation is by no means complete, but it is\r\nintended to help you browsing the automatically generated\r\ndocumentation. To better visualize the interplay of the components of\r\n\\gopt{} we refer to the class diagram of Figure~\\ref{fig:classes}.\r\n\\begin{figure}\r\n\\centering\r\n\\includegraphics[width=0.7\\columnwidth]{pics/classes.eps}\r\n\\caption{Class diagram of \\gopt{}.}\r\n%% TODO update by adding OptimizationAlgorithm\r\n\\label{fig:classes}\r\n\\end{figure}\r\n\r\n\\subsection {Representation of an Optimization Problem}\r\n\\label{sec:representation}\r\nAll in all our system utilizes a generic hyper-graph structure to\r\nrepresent a problem instance (defined in \\verb+hyper_graph.h+).  This\r\ngeneric hyper graph is specialized to represent an optimization\r\nproblem by the class \\verb+OptimizableGraph+, defined in\r\n\\verb+optimizable_graph.h+.  Within the \\verb+OptimizableGraph+ the\r\ninner classes \\verb+OptimizableGraph::Vertex+ and\r\n\\verb+OptimizableGraph::Edge+ are used to represent generic hyper\r\nedges and hyper vertices.  Whereas the specific implementation might\r\nbe done by directly extending these classes, we provided a template\r\nspecialization that implements automatically most of the methods that\r\nare mandatory for the system to work.\r\n\r\nThese classes are \\verb+BaseVertex+ and \\verb+BaseUnaryEdge+,\r\n\\verb+BaseBinaryEdge+ and \\verb+BaseMultiEdge+. \r\n\\begin{description}\r\n\\item \\verb+BaseVertex+ templatizes the dimension of a parameter block\r\n  $\\bx_i$ and of the corresponding manifold $\\bDeltax_i$, thus it can \r\n  use blocks of memory whose layout is known at compile-time (means\r\n  efficiency). Furthermore, it implements some mapping operators to\r\n  store the Hessian and the parameter blocks of the linearized\r\n  problem, and a stack of previous values that can be used to\r\n  save/restore parts of the graph.  The method \\verb+oplusImpl(double* v)+\r\n  that applies the perturbation $\\bDeltax_i$ represented by \\verb+v+,\r\n  to the member variable \\verb+_estimate+ should be implemented. This\r\n  is the $\\boxplus$ operator. Additionally,\r\n  \\verb+setToOriginImpl()+ that should set the internal state of the vertex\r\n  to $\\bZero$ has to specified.\r\n\r\n\\item \\verb+BaseUnaryEdge+ is a template class to model a unary\r\n  hyper-edge, which can be used to represent a prior. It offers for\r\n  free the calculation of the Jacobians, via an implementation of the\r\n  \\verb+linearizeOplus+ method. It requires to specify the types of\r\n  the (single) vertex $\\bx_i$, and type and dimension of the error \r\n  $\\be(\\bx_k)$ as template parameters.  The function\r\n  \\verb+computeError+ that stores the result of the error $\\be(\\bx_k)$ in the\r\n  member \\verb+Eigen::Matrix _error+ should be implemented.\r\n\r\n\\item \\verb+BaseBinaryEdge+ is a template class that models a binary\r\n  constraint, namely an error function in the form $\\be_k(\\bx_{k_1},\r\n  \\bx_{k_2})$. It offers the same facilities of \\verb+BaseUnaryEdge+, and it\r\n  requires to specify the following template parameters: the type of the nodes\r\n  $\\bx_{k_1}$ and $\\bx_{k_2}$  and the  type and the dimension of the measurement. \r\n  Again, it implements the numeric Jacobians via\r\n  a default implementation of the \\verb+linearizeOplus+ method.\r\n  Again, the \\verb+computeError+ should be implemented in a derived class.\r\n\r\n\\item \\verb+BaseMultiEdge+ is a template class that models a\r\n  multi-vertex constraint in the form of $\\be_k(\\bx_{k_1}, \\bx_{k_2},\r\n  \\ldots, \\bx_{k_q})$. It offers the same facilities of the types\r\n  above, and it requires to specify only the type and dimension of the\r\n  measurement as template parameters. The specialized class should\r\n  take care of resizing the connected vertices to the correct size\r\n  $q$.  This class relies on a dynamic memory, since too many\r\n  parameters are unknown, and if you need of an efficient\r\n  implementation for a specific problem you can program it yourself.\r\n  Numeric Jacobian comes for free, but you should implement the\r\n  \\verb+computeError+ in a derived class, as usual\r\n\\end{description}\r\n\r\nIn short, all you need to do to define a new problem instance is to\r\nderive a set of classes from those above listed, one for each type of\r\nparameter block and one for each type of (hyper)edge. Always try to\r\nderive from the class which does the most work for you.  If you want to\r\nhave a look at a simple example look at \\verb+vertex_se2+ and\r\n\\verb+edge_se2+. Those two types define a simple 2D graph SLAM\r\nproblem, like the one described in many SLAM papers.\r\n\r\n\\begin{lstlisting}[float,label=lst:inittypes,caption=Registering types\r\n  by a constructor from a library]\r\n#include \"g2o/core/factory.h\"\r\n\r\nnamespace g2o {\r\n  G2O_REGISTER_TYPE_GROUP(slam2d);\r\n\r\n  G2O_REGISTER_TYPE(VERTEX_SE2, VertexSE2);\r\n  G2O_REGISTER_TYPE(VERTEX_XY, VertexPointXY);\r\n\r\n  // ...\r\n}\r\n\\end{lstlisting}\r\n\r\nOf course, for every type you construct you should define also the\r\n\\verb+read+ and \\verb+write+ functions to read and write your data to a\r\nstream.  Finally, once you define a new type, to enable the loading and\r\nthe saving of the new type you should ``register'' it to a factory.\r\nThis is easily done by assigning a string tag to a new type, via the\r\n\\verb+registerType+ function. This should be called once before\r\nall files are loaded.\r\n\r\nTo this end, \\gopt{} provides an easy macro to carry out the registration of the\r\nclass to the factory.  See Listing~\\ref{lst:inittypes} for an example,\r\nthe full example can be found in \\verb+types_slam2d.cpp+.  The first\r\nparameter given to the macro \\verb+G2O_REGISTER_TYPE+ specifies the tag\r\nunder which a certain vertex / edge is known. \\gopt\\ will use this\r\ninformation while loading files and for saving the current graph into a\r\nfile. In the example given in Listing~\\ref{lst:inittypes} we register\r\nthe tags \\verb+VERTEX_SE2+ and \\verb+EDGE_SE2+ with the classes\r\n\\verb+VertexSE2+ and \\verb+EdgeSE2+, respectively.\r\n\r\nFurthermore, the macro \\verb+G2O_REGISTER_TYPE_GROUP+ allows to declare\r\na type group. This is necessary if we use the factory to construct the\r\ntypes and we have to enforce that our code is linked to a specific type\r\ngroup. Otherwise the linker may drop our library, since we do not\r\nexplicitly use any symbol provided by the library containing our type.\r\nDeclaring the usage of a specific type library and hence enforcing the\r\nlinking is done by the macro called \\verb+G2O_USE_TYPE_GROUP+.\r\n\r\n\\subsection{Construction and Representation of the Linearized Problem}\r\nThe construction and the solution can be separated into individual\r\nsteps which are iterated.\r\n\\begin{itemize}\r\n  \\item Initialization of the optimization (only before the first\r\n    iteration).\r\n  \\item Computing the error vector for each constraint.\r\n  \\item Linearize each constraint.\r\n  \\item Build the linear system.\r\n  \\item Updating the Levenberg-Marquardt damping factor.\r\n\\end{itemize}\r\n\r\nWithin the following sections we will describe the steps.\r\n\r\n\\subsubsection{Initialization}\r\nThe class \\verb+SparseOptimizer+ offers several methods to initialize\r\nthe underlying data structure. The methods\r\n\\verb+initializeOptimization()+ either takes a subset of vertices or a\r\nsubset of edges which will be considered for the next optimization runs.\r\nAdditionally, all vertices and edges can be considered for optimization.\r\nWe refer to the vertices and edges currently considered as \\emph{active}\r\nvertices and edges, respectively.\r\n\r\nWithin the initialization procedure, the optimizer assigns a temporary\r\nindex to each active vertex. This temporary index corresponds to the\r\nblock column / row of the vertex in the Hessian. Some of the vertices\r\nmight need to be kept fixed during the optimization, to resolve\r\narbitrary degrees of freedom (gauge freedom). This can be done by\r\nsetting the \\verb+_fixed+ attribute of a vertex.\r\n\r\n\\subsubsection{Compute error\\label{sec:error}}\r\nThe \\verb+computeActiveErrors()+ function takes the current estimate of\r\nthe active vertices and for each active edge calls\r\n\\verb+computeError()+ for computing the current error vector. Using\r\nthe base edge classes described in Section~\\ref{sec:representation} \r\nthe error should be cached in the member variable \\verb+_error+.\r\n\r\n If \\verb+robustKernel()+ is set to true for a particular active edge,\r\n\\verb+robustifyError()+ is called and \\verb+_error+ is robustified \r\nas described in Section~\\ref{sec:robust_kernel}.\r\n\r\n\\subsubsection{Linearizing the system}\r\nEach active edge is linearized by calling its\r\n\\verb+linearizeOplus()+ function. Again the Jacobians can be cached by\r\nmember variables provided by the templatized base classes described in \r\nSection~\\ref{sec:representation}. If the \\verb+linearizeOplus()+\r\nfunction is not re-implemented the Jacobian will be computed\r\nnumerically as follows:\r\n\\begin{eqnarray}\r\n  \\tilde \\bJ_k^{\\bullet l} = \\frac{1}{2\\delta} \\left(\r\n  \\be_k (\\bx_k \\boxplus \\delta\\mathbf{1}_l)\r\n  -\r\n  \\be_k (\\bx_k \\boxplus -\\delta\\mathbf{1}_l)\r\n  \\right),\r\n  \\label{eqn:jacobiannumeric}\r\n\\end{eqnarray}\r\nwhere $\\delta > 0$ is a small constant ($10^{-9}$ in our\r\nimplementation) and $\\mathbf{1}_l$ is the unit vector along dimension\r\n$l$. Note that we only store and calculate the non-zero entries of\r\n$\\tilde \\bJ_k$ that have not been fixed during the initialization.\r\n\r\n\\subsubsection{Building the system}\r\nFor each active edge the addend term for Eq.~\\ref{eq:addendTerm} is\r\ncomputed by multiplying the corresponding blocks of the Jacobians and\r\nthe information matrix of the edge. The addend term is calculated in\r\neach edge by calling \\verb+constructQuadraticForm()+.\r\n\r\n\\subsubsection{Updating Levenberg-Marquardt}\r\nAs illustrated in \\eqref{eq:oneLinearIterationLevenberg} the\r\nLevenberg-Marquardt algorithm requires updates to the linear system.\r\nHowever, only the elements along the main diagonal need to be modified.\r\nTo this end, the methods \\verb+updateLevenbergSystem(double lambda)+ and\r\n\\verb+recoverSystem(double lambda)+ of the \\verb+Solver+ class apply the\r\nmodifications by respectively adding or subtracting $\\lambda$ along the\r\nmain diagonal of $\\bH$.\r\n\r\n\\subsection{Solvers}\r\nA central component of these least-squares approaches is the solution\r\nof the linear system $\\tilde \\bH \\, \\bTDeltax^* = - \\tilde \\bb$. To\r\nthis end there are several approaches available, some of them exploit\r\nthe known structure of certain problems and perform intermediate\r\nreductions of the system, like by applying the Schur complement to a\r\nsubset of variables.  In \\gopt{} we do not select any particular solver,\r\nbut we rely on external libraries.  To this end, we decouple these\r\n\\emph{structural} operations (like the Schur complement)\r\nfrom the solution of the linear system.\r\n\r\nThe construction of the linear problem from the Jacobian matrices and the error vectors\r\nin the hyper-graph elements are controlled by a so-called \\verb+Solver+ class.\r\nTo use a specific factorization of the system, the user has to extend the\r\n\\verb+Solver+ class, and to implement the virtual functions. \r\nNamely a solver should be able to extract from an\r\nhyper-graph the linear system, and to return a solution.  This is\r\ndone in several steps: at the beginning of the optimization the\r\nfunction \\verb+initializeStructure+ is called, to allocate the\r\nnecessary memory that will be overwritten in the subsequent\r\noperations. This is possible since the structure of the system does\r\nnot change between iterations. Then the user should provide means to\r\naccess to the increment vector $\\bTDeltax$ and $\\tilde \\bb$, via the\r\nfunctions \\verb+b()+ and \\verb+x()+. To support Levenberg-Marquardt\r\none should also implement a function to perturb the Hessian with the\r\n$\\lambda \\bI$ term. This function is called\r\n\\verb+setLambda(double lambda)+ and needs to be implemented by the\r\nspecific solver.\r\n\r\nWe provide a templatized implementation of the solver class, the\r\n\\verb+BlockSolver<>+ that stores the linear system in a\r\n\\verb+SparseBlockMatrix<>+ class. The \\verb+BlockSolver<>+ implements\r\nalso the Schur complement, and relies on another abstract class, the\r\n\\verb+LinearSolver+ to solve the system.\r\nAn implementation of the linear solver does the actual work\r\nof solving the (reduced) linear system, and has to implement a few methods.\r\nIn this release of \\gopt{} we provide linear solvers that use respectively\r\npreconditioned gradient descent, CSparse, and CHOLMOD.\r\n\r\n\r\n\\subsection{Actions}\r\nTo the extent of \\gopt{}, the entities stored in a hyper-graph have a\r\npure mathematical meaning. They either represent variables to be\r\noptimized (vertices), or they encode optimization constraints.\r\nHowever, in general these variables are usually related to more\r\n``concrete'' objects, like laser scans, robot poses, camera parameters\r\nand so on.  Some variable type may support only a subset of feasible\r\noperations.  For instance it is possible to ``draw'' a robot pose, but\r\nit is not possible to ``draw'' the calibration parameters.  More in\r\ngeneral we cannot know a priori the kind of operations that will be\r\nsupported by the user types of \\gopt.  However, we want to design a set\r\nof tools and of functions that rely on certain operations. These include,\r\nfor instance viewers, or functions to save/load the graph in a specific format.\r\n\r\nA possibility to do this would be to ``overload'' the base classes of\r\nthe hyper-graph elements (vertices and edges) with many virtual\r\nfunctions, one for each of the functionality we want to support.  This\r\nis of course not elegant, because we would need to patch the base\r\nclasses with the new function every time something new is added.\r\nAnother possibility would be to make use of the multiple inheritance\r\nof C++, and to define an abstract ``drawable'' object, on which the\r\nviewer operates.  This solution is a bit better, however we cannot\r\nhave more than one ``drawing'' function for each object.\r\n\r\nThe solution used in \\gopt{} consists in creating a library of\r\nfunction objects that operate on the elements (vertices or edges) of\r\nthe graph.  One of these function objects is identified by a function\r\nname and by a type on which it operates.  These function objects can\r\nbe registered into an action library.  Once these objects are loaded\r\nin the action library it is possible to call them on a graph.  These\r\nfunctionalities are defined in \\verb+hyper_graph_action.h+.  It is\r\ncommon to register and create the actions when defining the types for\r\nthe edges and the vertices.  You can see many examples in\r\n\\verb+types_*/*.h+.\r\n\r\n\\section{\\gopt\\ Tools}\r\n\\gopt\\ comes with two tools which allow to process data stored in\r\nfiles. The data can be loaded from a file and stored again after\r\nprocessing. In the following we will give a brief introduction to these\r\ntools, namely a command line interface and a graphical user interface.\r\n\r\n\\subsection{\\gopt\\ Command Line Interface}\r\n\r\n\\verb+g2o+ is the command line interface included in \\gopt. It\r\nallows to optimize graphs stored in files and save the result back to a\r\nfile. This allows a fast prototyping of optimization problems, as it is\r\nonly required to implement the new types or solvers. The \\gopt\\\r\ndistribution includes a data folder which comprises some data files on\r\nwhich \\verb+g2o+ can be applied.\r\n\r\n\\subsection{\\gopt\\ Viewer}\r\n\r\n\\begin{figure}\r\n  \\centering\r\n  \\includegraphics[width=0.7\\columnwidth]{pics/viewer}\r\n  \\caption{Graphical interface to \\gopt. The GUI allows to select\r\n  different suitable optimizers and perform the optimization.}\r\n  \\label{fig:viewer}\r\n\\end{figure}\r\n\r\nThe Graphical User Interface depicted in Figure~\\ref{fig:viewer} allows\r\nto visualize the optimization problem. Additionally, the various\r\nparameters of the algorithms can be controlled.\r\n\r\n\\subsection{\\gopt{} incremental}\r\n\r\n\\gopt{} includes an experimental binary for performing optimization in\r\nan incremental fashion, i.e., optimizing after inserting one or several\r\nnodes along with their measurements. In this case, \\gopt{} performs\r\nranke updates on the Hessian matrix to update the linear system. Please\r\nsee the \\verb+README+ in the \\verb+g2o_incremental+ sub-folder for\r\nadditional information.\r\n\r\nExample for the Manhattan3500 dataset:\r\n\\begin{verbatim}\r\ng2o_incremental -i manhattanOlson3500.g2o\r\n\\end{verbatim}\r\n\r\n\\subsection{Plug-in Architecture}\r\n\r\n\\begin{lstlisting}[float,label=lst:initsolvers,caption=Registering\r\n  solvers by a constructor from a library]\r\nclass PCGSolverCreator : public AbstractOptimizationAlgorithmCreator\r\n{\r\n  public:\r\n    PCGSolverCreator(const OptimizationAlgorithmProperty& p) : AbstractOptimizationAlgorithmCreator(p) {}\r\n    virtual OptimizationAlgorithm* construct()\r\n    {\r\n      // create the optimization algorithm\r\n      // see g2o/solver_pcg/solver_pcg.cpp for the details\r\n    }\r\n};\r\n\r\nG2O_REGISTER_OPTIMIZATION_LIBRARY(pcg);\r\n\r\nG2O_REGISTER_OPTIMIZATION_ALGORITHM(gn_pcg, new PCGSolverCreator(OptimizationAlgorithmProperty(\"gn_pcg\", \"Gauss-Newton: PCG solver using block-Jacobi pre-conditioner (variable blocksize)\", \"PCG\", false, Eigen::Dynamic, Eigen::Dynamic)));\r\n\r\nG2O_REGISTER_OPTIMIZATION_ALGORITHM(gn_pcg3_2, new PCGSolverCreator(OptimizationAlgorithmProperty(\"gn_pcg3_2\", \"Gauss-Newton: PCG solver using block-Jacobi pre-conditioner (fixed blocksize)\", \"PCG\", true, 3, 2)));\r\n\r\n//...\r\n\\end{lstlisting}\r\n\r\nBoth tools support the loading of types and optimization algorithms at\r\nrun-time from dynamic libraries. This is realized as follows. The tools\r\nload from the libs folder all libraries matching ``*\\_types\\_*'' and\r\n``*\\_solver\\_*'' to register types and optimization algorithms,\r\nrespectively. We assume that by loading the libraries the types and the\r\nalgorithms register via their respective constructors to the system.\r\nListing~\\ref{lst:inittypes} shows how to register types to the system\r\nand Listing~\\ref{lst:initsolvers} is an example, which shows how to\r\nregister an optimization algorithm via the plug-in architecture.\r\n\r\nFor loading dynamic library containing types or optimization algorithms, we support two\r\ndifferent methods:\r\n\\begin{itemize}\r\n  \\item The tools recognize the command line switch \\verb+-typeslib+\r\n    and \\verb+-solverlib+ to load a specific library.\r\n  \\item You may specify the environment variables \\verb+G2O_TYPES_DIR+\r\n    and \\verb+G2O_SOLVER_DIR+ which are scanned at start and libraries\r\n    matching ``*\\_types\\_*'' and ``*\\_solver\\_*'' are automatically\r\n    loaded.\r\n\\end{itemize}\r\n\r\n\\section{2D SLAM: An Example}\r\nSLAM is a well known problem in robotics and this acronym stands for\r\n``Simultaneous Localization And Mapping''. The problem can be stated\r\nas follows: given a moving robot equipped with some sensors, we want\r\nto estimate both the map and the pose of the robot in the environment\r\nfrom the sensor measurements. Usually, the sensors can be classified\r\nin exteroceptive or proprioceptive.  An exteroceptive sensor is a\r\ndevice that measures quantities relative to the environment where the\r\nrobot moves.  Examples of these sensors can be cameras that acquire an\r\nimage of the world at a particular location, laser scanners that\r\nmeasure a set of distances around the robot or accelerometers in\r\npresence of gravity that measure the gravity vector or GPS that derive\r\na pose estimate by observing the constellation of known satellites.\r\nIn contrast, proprioceptive sensors measure the change of the robot's\r\nstate (the position), relative to the previous robot position. Example\r\ninclude odometers, that measure the relative movement of the robot\r\nbetween two time steps or gyroscopes. In traditional approaches to\r\nSLAM, like EKF these two sensors play a substantially different role\r\nin the system.  The proprioceptive measurements are used to evolve a\r\nset of state variables, while the exteroceptive measurements are used\r\nto correct these estimates, by feeding back the measurement errors.\r\nThis is not the case of smoothing methods (like the ones that can be\r\nimplemented with \\gopt{}), where all measurements are treated in a\r\nsubstantially similar manner.\r\n\r\nA complete solution to SLAM is typically rather complex and involves\r\nprocessing raw sensor data and determining correspondences between\r\npreviously seen parts of the environment and actual measurements (data\r\nassociation). Describing a complete solution to the problem is out of\r\nthe scope of this document.  However, in the reminder we will present a\r\nsimplified but meaningful version of the problem that contains all the relevant elements\r\nand that is well suited to be implemented with \\gopt.\r\n\r\nThe scenario is a robot moving on a plane. The robot is equipped\r\nwith an odometry sensor that is able to measure the relative movement\r\nof the robot between two time frames and of a ``landmark'' sensor\r\nthat is able to measure the position of some environment landmarks\r\nnearby the robot \\emph{in the robot reference frame}. One could\r\nimplement this landmark detector, for instance, by extracting corners\r\nfrom a laser scan or by detecting the position of relevant features\r\nfrom a stereo image pair. A simplification that we make in this\r\nsection is that the landmarks are uniquely identifiable. In other\r\nwords whenever the robot sees a landmark, it can tell if it is a new\r\none or if it has already seen it and when.\r\n\r\nClearly both odometers and landmark sensors are affected by noise.  In\r\nprinciple, if the odometry would not be affected by noise one could\r\nreconstruct the trajectory of the robot simply by chaining the\r\nodometry measurements. However, this is not the case and integrating\r\nthe odometry leads to an increasing positioning error that becomes\r\nevident when the robot reenters a known region. In a similar way,\r\nif the robot would have unlimited perception range, it could acquire\r\nall the map in one shot and the position could be retrieved by simple\r\ngeometric constructions. Again this is not the case and the robot\r\nperceives the position of the landmarks that are located within a\r\nmaximum range. These measurements are affected by a noise, that\r\nusually increases with the distance of a landmark from the robot.\r\n\r\nIn the remainder of this section we will walk through all essential\r\nsteps that are required to characterize a problem within \\gopt{}.\r\nThese are:\r\n\\begin{itemize}\r\n\\item identification of the state variables $\\bx_i$ and of their domain,\r\n\\item characterization of the constraints and identification of the graph structure,\r\n\\item choice of the parameterization for the increments $\\bTDeltax_i$, and definition of the\r\n$\\boxplus$ operator.\r\n\\item construction of the error functions $e_k(\\bx_k)$.\r\n\\end{itemize}\r\n\r\n\\subsection{Identification of the State Variables}\r\nFigure~\\ref{fig:slam} illustrates a fragment of a SLAM graph.  The\r\nrobot positions are denoted by the nodes $\\bx^\\mathrm{s}_t$, while the\r\nlandmarks are denoted by the nodes $\\bx^\\mathrm{l}_i$. We assume that\r\nour landmark sensor is able to detect only the 2D pose of a landmark,\r\nbut not its orientation.  In other words the landmarks ``live'' in\r\n$\\Re^2$.  Conversely, the robot poses are parameterized by the robot\r\nlocation $(x,y)$ on the plane and its orientation $\\theta$, thus they\r\nbelong to the group of 2D transformations $SE(2)$.  More\r\nformally, the nodes of a 2D SLAM graph are of two types\r\n\\begin{itemize}\r\n\\item Robot positions $\\bx^\\mathrm{s}_t = ( x^\\mathrm{s}_t  \\; y^\\mathrm{s}_t \\; \\theta^\\mathrm{s}_t)^T \\in SE(2)$\r\n\\item Landmark positions $\\bx^\\mathrm{l}_i = ( x^\\mathrm{l}_i  \\; y^\\mathrm{l}_i )^T \\in \\Re^2$\r\n\\end{itemize}\r\n\r\n\\begin{figure}\r\n\\psfrag{p1}{$\\bx^\\mathrm{s}_1$}\r\n\\psfrag{p2}{$\\bx^\\mathrm{s}_2$}\r\n\\psfrag{pt1}{$\\bx^\\mathrm{s}_{t-1}$}\r\n\\psfrag{pt}{$\\bx^\\mathrm{s}_{t}$}\r\n\\psfrag{L1}{$\\bx^\\mathrm{l}_1$}\r\n\\psfrag{L2}{$\\bx^\\mathrm{l}_2$}\r\n\\psfrag{Li1}{$\\bx^\\mathrm{l}_{i-1}$}\r\n\\psfrag{Li}{$\\bx^\\mathrm{l}_{i}$}\r\n\\psfrag{u12}{$\\bz^\\mathrm{s}_{1,2}$}\r\n\\psfrag{utt1}{$\\bz^\\mathrm{s}_{t-1,t}$}\r\n\\psfrag{l11}{$\\bz^\\mathrm{l}_{1,1}$}\r\n\\psfrag{l12}{$\\bz^\\mathrm{l}_{1,2}$}\r\n\\psfrag{lit}{$\\bz^\\mathrm{l}_{t,i}$}\r\n\\psfrag{l1i}{$\\bz^\\mathrm{l}_{1,i}$}\r\n\\psfrag{lti1}{$\\bz^\\mathrm{l}_{t,i-1}$}\r\n\\psfrag{lt1i}{$\\bz^\\mathrm{l}_{t-1,i-1}$}\r\n\\centering\r\n\\includegraphics[width=0.8\\columnwidth]{pics/slam.eps}\r\n\\caption{Graphical representation of a SLAM process. The vertices of\r\n  the graph, depicted with circular nodes, denote either robot poses\r\n  $\\bx^\\mathrm{s}_*$ or landmarks $\\bx^\\mathrm{l}_*$. The measurement\r\n  of a landmark from a robot pose is captured by a constraints\r\n  $\\bz^{\\mathrm{l}}_*$ and odometry measurements connecting subsequent\r\nrobot poses are modeled by the constraints $\\bz^\\mathrm{s}_*$.}\r\n\\label{fig:slam}\r\n\\end{figure}\r\n\r\n\\subsection{Modeling of the Constraints}\r\nTwo subsequent robot positions $\\bx^\\mathrm{s}_t$ and\r\n$\\bx^\\mathrm{s}_{t+1}$ are related by an odometry measurement, that\r\nrepresent the relative motion that brings the robot from\r\n$\\bx^\\mathrm{s}_t$ to $\\bx^\\mathrm{s}_{t+1}$ \\emph{measured} by the\r\nodometry. This measurement will be typically slightly different from\r\nthe \\emph{real} transformation between the two pose because of the\r\nnoise affecting the sensors.  Being an odometry measurement, an\r\nEuclidean transformation, it is also a member of $SE(2)$ group.\r\nAssuming the noise affecting the measurement being white and Gaussian,\r\nit can be modeled by an $3 \\times 3$ symmetric positive definite\r\ninformation matrix.  In real applications the entries of this matrix\r\ndepend on the motion of the robot.  i.e., the bigger the movement is\r\nthe larger the uncertainty will be.\r\nThus an odometry edge between the nodes $\\bx^\\mathrm{s}_t$ and\r\n$\\bx^\\mathrm{s}_{t+1}$ consists of these two entities:\r\n\\begin{itemize}\r\n\\item $\\bz^\\mathrm{s}_{t,t+1} \\in SE(2)$ that represents the motion\r\n  between the nodes and\r\n\\item $\\bOmega^\\mathrm{s}_{t,t+1} \\in \\Re^{3 \\times 3}$ that represents the\r\n  inverse covariance of the measurement, and thus is symmetric and\r\n  positive definite.\r\n\\end{itemize}\r\n\r\nIf the robot senses a landmark $\\bx^\\mathrm{l}_i$ from the location\r\n$\\bx^\\mathrm{s}_t$, the corresponding measurement will be modeled by\r\nan edge going from the robot pose to the landmark. A measurement about\r\nthe landmark consists in a point in the $x$-$y$ plane, perceived in the\r\nrobot frame. Thus a landmark measurement lives in $\\Re^2$ as the\r\nlandmarks do. Again, under white Gaussian noise assumption, the\r\nnoise can be modeled by its inverse covariance. Accordingly, an edge between\r\na robot pose and a landmark is parametrized in this way:\r\n\\begin{itemize}\r\n\\item $\\bz^\\mathrm{l}_{t,i} \\in \\Re^2$ that represents position of the landmark\r\n  in the frame expressed by $\\bx^\\mathrm{s}_t$ and\r\n\\item $\\bOmega^\\mathrm{l}_{t,i} \\in \\Re^{2 \\times 2}$ that represents the inverse\r\n  covariance of the measurement and is SPD.\r\n\\end{itemize}\r\n\r\n\\subsection{Choice of the Parameterization for the Increments}\r\nSo far, we defined most of the elements necessary to implement a 2D\r\nSLAM algorithm with \\gopt{}.  Namely we characterized the domains of\r\nthe variables and the domains of the measurements.  What remains to do\r\nis to define the error functions for the two kinds of edges in our\r\nsystem and to determine a (possibly smart) parameterization for the\r\nincrements.\r\n\r\n\r\nThe landmark positions are parameterized in $\\Re^2$, which is already\r\nan Euclidean space. Thus the increments $\\bTDeltax^\\mathrm{l}_i$ can live in the same space and the\r\n $\\boxplus$ operator can be safely chosen as the vector sum:\r\n\\begin{eqnarray}\r\n  \\bx^\\mathrm{l}_i \\boxplus \\bTDeltax^\\mathrm{l}_i   & \\doteq & \\bx^\\mathrm{l}_i + \\bTDeltax^\\mathrm{l}_i\r\n\\end{eqnarray}\r\n\r\nThe poses, conversely, live in the non-Euclidean space $SE(2)$.\r\nThis space admits many parameterizations. Examples include:\r\nrotation matrix $\\bR(\\theta)$ and translation vector $(x \\; y)^T$ or\r\nangle $\\theta$ and translation vector $(x \\; y)^T$.\r\n\r\nAs a parameterization for the increments, we choose a minimal one,\r\nthat is translation vector and angle. Having chosen this\r\nparameterization, we need to define the $\\boxplus$ operator between a\r\npose and a pose increment.  One possible choice would be to treat the\r\nthree scalar parameters $x$, $y$ and $\\theta$ of a pose as if they\r\nwere a vector, and define the $\\boxplus$ as the vector sum.  There are\r\nmany reasons why this is a poor choice. One of them is that the angles\r\nare not Euclidean, and one would need to re-normalize them after every\r\naddition.\r\n\r\nA better choice is to define the $\\boxplus$ between a pose and a pose\r\nincrement as the motion composition operator. Namely, given a robot\r\npose $\\bx^{s}_t = (x\\; y\\; \\theta)^T$ and an increment $\\bTDeltax^{s}_t\r\n= (\\Delta x\\; \\Delta y\\; \\Delta \\theta)^T$, where $\\Delta x$ is the\r\nlongitudinal displacement (i.e. in direction of the heading of the robot),\r\n$\\Delta y$ the lateral displacement and $\\Delta \\theta$ the rotational\r\nchange, the operator can be defined as follows:\r\n\\begin{eqnarray}\r\n    \\bx^\\mathrm{s}_t \\boxplus \\bTDeltax^\\mathrm{s}_t   & \\doteq & \r\n    \\left( \r\n    \\begin{array}{c}\r\n      x + \\Delta x \\cos \\theta - \\Delta y \\sin \\theta \\\\\r\n      y + \\Delta x \\sin \\theta + \\Delta y \\cos \\theta \\\\\r\n      \\mathrm{normAngle}(\\theta + \\Delta \\theta)\r\n    \\end{array}\r\n    \\right)\\\\\r\n    = \\bx^\\mathrm{s}_t \\oplus \\bTDeltax^\\mathrm{s}_t.\r\n\\end{eqnarray}\r\n\r\nIn  the previous equation we introduced the motion composition operator $\\oplus$\r\nSimilarly to $\\oplus$ there is the $\\ominus$ operator that performs the opposite operation\r\nand is defined as follows:\r\n\\begin{eqnarray}\r\n    \\bx^\\mathrm{s}_a \\ominus \\bx^\\mathrm{s}_b   & \\doteq & \r\n    \\left( \r\n    \\begin{array}{c}\r\n        (x_a - x_b)  \\cos \\theta_b + (y_a - y_b) \\sin \\theta_b \\\\\r\n      - (x_a - x_b)  \\sin \\theta_b + (y_a - y_b) \\cos \\theta_b \\\\\r\n      \\mathrm{normAngle}(\\theta_b - \\theta_a)\r\n    \\end{array}\r\n    \\right)\r\n\\end{eqnarray}\r\n\r\n\\subsection{Design of the Error Functions}\r\nThe last step in formalizing the problem is to design error functions\r\n$\\be(\\bx_k)$ that are ``reasonable''. A common way to do this to define a\r\nso-called \\emph{measurement} function $\\bh_k(\\bx_k)$ that ``predicts''\r\na measurement $\\hat \\bz_k$, given the knowledge of the vertices in the\r\nset $\\bx_k$. Defining this function is usually rather easy, and can be\r\ndone by directly implementing the error model. Subsequently, the error\r\nvector can be computed as the vector difference between the prediction\r\n$\\hat \\bz_k$ and the real measurement.  This is a general approach to\r\nconstruct error functions and it works when the space of the errors is\r\nlocally Euclidean around the origin of the measurement. If this is not\r\nthe case one might want to replace the vector difference with some\r\nother operator which is more ``regular''.\r\n\r\nWe will now construct the error functions for the edges connecting a\r\nrobot pose $\\bx^\\mathrm{s}_t$ and a landmark $\\bx^\\mathrm{l}_i$.  The\r\nfirst step is to construct a measurement prediction\r\n$\\bh^\\mathrm{l}_{t,i}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{l}_i)$ that computes\r\na ``virtual measurement''. This virtual measurement is the position of\r\nthe landmark $\\bx^\\mathrm{l}_i$, seen from the robot position\r\n$\\bx^\\mathrm{s}_t$. The equation for $\\bh^\\mathrm{l}_{t,i}(\\cdot)$ is the\r\nfollowing:\r\n\\begin{eqnarray}\r\n    \\bh^\\mathrm{l}_{t,i}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{l}_i)   & \\doteq &\r\n    \\left(\r\n    \\begin{array}{c}\r\n        (x^\\mathrm{s}_t - x_i)  \\cos \\theta^\\mathrm{s}_t + (y^\\mathrm{s}_t - y_i) \\sin \\theta^\\mathrm{s}_t \\\\\r\n      - (x^\\mathrm{s}_t - x_i)  \\sin \\theta^\\mathrm{s}_t + (y^\\mathrm{s}_t - y_i) \\cos \\theta^\\mathrm{s}_t\r\n    \\end{array}\r\n    \\right)\r\n\\end{eqnarray}\r\nwhich converts the position of the landmark into the coordinate system of\r\nthe robot.\r\n\r\nSince the landmarks live in an Euclidean space, it is reasonable to\r\ncompute the error function as the normal vector difference.  This\r\nleads to the following definition for the error functions of the\r\nlandmarks.\r\n\\begin{eqnarray}\r\n    \\be^\\mathrm{l}_{t,i}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{l}_i)   & \\doteq & \\bz_{t,i} - \\bh^\\mathrm{l}_{t,i}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{l}_i).\r\n    \\label{eq:landmarkError}\r\n\\end{eqnarray}\r\n\r\nIn a similar way, we can define the error functions of an odometry\r\nedge connecting two robot poses $\\bx^\\mathrm{s}_t$ and\r\n$\\bx^\\mathrm{s}_{t+1}$. As stated before, an odometry measurement lives in $SE(2)$.\r\nBy using the $\\oplus$ operator we can write a synthetic measurement function:\r\n\\begin{eqnarray}\r\n    \\bh^\\mathrm{s}_{t,t+1}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{s}_{t+1})   & \\doteq & \\bx^\\mathrm{s}_{t+1} \\ominus \\bx^\\mathrm{s}_{t}.\r\n\\end{eqnarray}\r\nIn short this function returns the motion that brings the robot from\r\n$\\bx^\\mathrm{s}_t$ to $\\bx^\\mathrm{s}_{t+1}$, that is the ``ideal''\r\nodometry.  Once again the error can be obtained as a difference\r\nbetween the measurement and the prediction. However, since our measurements\r\ndo not live in an Euclidean space we can use $\\ominus$ instead of the vector difference.\r\n\r\n\\begin{eqnarray}\r\n    \\be^\\mathrm{s}_{t,t+1}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{s}_{t+1})   & \\doteq & \\bz_{t,t+1} \\ominus \\bh^\\mathrm{s}_{t,t+1}(\\bx^\\mathrm{s}_t, \\bx^\\mathrm{s}_{t+1}).\r\n    \\label{eq:odometryError}\r\n\\end{eqnarray}\r\n\r\n\\subsection{Putting things together}\r\nHere we summarize the relevant parts of the previous problem definition,\r\nand we get ready for the implementation.\\\\[.3em]\r\n{\\small\r\n\\begin{tabular}{|c|c|c|c|c|c|}\r\n\\hline\r\n\\textbf{Variable} & \\textbf{Symbol}  & \\textbf{Domain} & \\textbf{Dimension} & \\textbf{Parameterization of }$\\bDeltax$   & $\\boxplus$ \\textbf{operator} \\\\\r\n\\hline\r\nRobot    pose     & $\\bx^\\mathrm{s}_t$ & $SE(2)$         & 3                  & $(\\Delta x \\; \\Delta y \\; \\Delta\\theta)$  & $\\bx^\\mathrm{s}_t \\oplus \\bDeltax^\\mathrm{s}_t$ \\\\\r\n\\hline\r\nLandmark pose     & $\\bx^\\mathrm{l}_i$ & $\\Re^2$         & 2                  & $(\\Delta x \\; \\Delta y )$                 & $\\bx^\\mathrm{l}_i + \\bDeltax^\\mathrm{l}_i$\\\\\r\n\\hline\r\n\\end{tabular}\\\\[.3em]\r\n\\begin{tabular}{|c|c|c|c|c|c|}\r\n\\hline\r\n\\textbf{Measurement} & \\textbf{Symbol}         & \\textbf{Domain} & \\textbf{Dimension} & \\textbf{Set $\\bx_k$ of variables involved}             & \\textbf{error function}\\\\\r\n\\hline\r\nOdometry             & = $\\bz^\\mathrm{s}_{t,t+1}$ & $SE(2)$         & 3                  & $\\left\\{ \\bx^\\mathrm{s}_t, \\bx^\\mathrm{s}_{t+1} \\right\\}$ & Eq.~\\ref{eq:odometryError} \\\\\r\n\\hline\r\nLandmark             & = $\\bz^\\mathrm{l}_{t,i}$   & $\\Re^2$         & 2                  & $\\left\\{ \\bx^\\mathrm{s}_t, \\bx^\\mathrm{l}_{i} \\right\\}$  & Eq.~\\ref{eq:landmarkError} \\\\\r\n\\hline\r\n\\end{tabular}}\\\\[.3em]\r\n\r\nThe first thing we are going to do is to implement a class that\r\nrepresents elements of the $SE(2)$ group. We represent these elements\r\ninternally by using the rotation matrix and the translation vector\r\nrepresentation, via the types defined in \\verb+Eigen::Geometry+.  Thus\r\nwe define an \\verb+operator*(...)+ that implements the motion composition\r\noperator $\\oplus$, and an \\verb+inverse()+ function that returns the inverse of\r\na transformation. For convenience we also implement an\r\n\\verb+operator*+ that transforms 2D points. To convert the elements\r\nfrom and to a minimal representation that utilizes an \\verb+Eigen::Vector3d+\r\nwe define the methods \\verb+fromVector(...)+ and \\verb+toVector(...)+.\r\nThe constructor initializes this class as a point in the origin\r\noriented at 0 degrees.  Note that having a separate class for a group\r\nis not mandatory in \\gopt, but makes the code much more readable and\r\nreusable. The corresponding C++ class is reported in\r\nListing~\\ref{lst:se2}.\r\n\\begin{lstlisting}[float,label=lst:se2,caption=\\text{Helper class to represent $SE(2)$}.]\r\nclass SE2 {\r\n  public:\r\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW\r\n    SE2():_R(0),_t(0,0){}\r\n\r\n    SE2(double x, double y, double theta):_R(theta),_t(x,y){}\r\n\r\n    SE2 operator * (const SE2& tr2) const{\r\n      SE2 result(*this);\r\n      result._t += _R*tr2._t;\r\n      result._R.angle()+= tr2._R.angle();\r\n      result._R.angle()=normalize_theta(result._R.angle());\r\n      return result;\r\n    }\r\n\r\n    Vector2d operator * (const Vector2d& v2) const{\r\n      Vector2d result(*this);\r\n      result._t = _t + _R*tr2._t;\r\n      return result;\r\n    }\r\n\r\n    SE2 inverse() const{\r\n      SE2 ret;\r\n      ret._R=_R.inverse();\r\n      ret._R.angle()=normalize_theta(ret._R.angle());\r\n      ret._t=ret._R*(_t*-1.);\r\n      return ret;\r\n    }\r\n\r\n    void fromVector (const Vector3d& v){\r\n      *this=SE2(v[0], v[1], v[2]);\r\n    }\r\n\r\n    Vector3d toVector() const {\r\n      Vector3d ret;\r\n      for (int i=0; i<3; i++){\r\n        ret(i)=(*this)[i];\r\n      }\r\n      return ret;\r\n    }\r\n\r\n  protected:\r\n    Rotation2Dd _R;\r\n    Vector2d _t;\r\n};\r\n\\end{lstlisting}\r\n\r\nOnce we defined our nice $SE(2)$ group we are ready to implement the\r\nvertices.  To this end we extend the \\verb+BaseVertex<>+ class, and we\r\nderive the classes \\verb+VertexSE2+ to represent a robot pose and\r\n\\verb+VertexPointXY+ to represent a point landmark in the plane.\r\nThe class definition for robot pose vertices is reported in\r\nListing~\\ref{lst:vertexse2}.\r\nThe pose-vertex extends a template specialization of\r\n\\verb+BaseVertex<>+.  We should say to \\gopt{} that the internal type\r\nhas dimension 3 and that the estimate is of type \\verb+SE2+. This\r\nmeans that the member \\verb+_estimate+ of a \\verb+VertexSE2+ is of\r\ntype \\verb+SE2+.  Then all we need to do is to redefine the methods\r\n\\verb+setToOriginImpl()+ that resets the estimate to a known\r\nconfiguration, and the method \\verb+\\oplusImpl(double*)+.  The method\r\nshould apply an increment, expressed in the increment parameterization\r\n(that is a vector $(\\Delta x \\; \\Delta y \\; \\Delta \\theta )^t$ to the\r\ncurrent estimate.  To do this, we first convert the vector passed as\r\nargument into an \\verb+SE(2)+, then we multiply this increment at the\r\nright of the previous estimate.  After that we should implement the\r\nread and write functions to a stream, but this is straight-forward and\r\nyou can look it up yourself in the code.\r\n\r\n\\begin{lstlisting}[float,label=lst:vertexse2,caption=Vertex representing\r\n  a 2D robot pose]\r\nclass VertexSE2 : public BaseVertex<3, SE2>\r\n{\r\n  public:\r\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW\r\n    VertexSE2();\r\n\r\n    virtual void setToOriginImpl() {\r\n      _estimate=SE2();\r\n    }\r\n\r\n    virtual void oplusImpl(double* update)\r\n    {\r\n      SE2 up(update[0], update[1], update[2]);\r\n      _estimate = _estimate * up;\r\n    }\r\n\r\n    virtual bool read(std::istream& is);\r\n    virtual bool write(std::ostream& os) const;\r\n\r\n};\r\n\\end{lstlisting}\r\nThe next step is to implement a vertex to describe a landmark\r\nposition.  Since the landmarks are parameterized in $\\Re^2$, we do not\r\nneed to define any group for that, and we use directly the vector\r\nclasses defined in Eigen. This class is reported in Listing~\\ref{lst:vertexxy}.\r\n\r\n\\begin{lstlisting}[float,label=lst:vertexxy,caption=Vertex representing\r\n  a 2D landmark]\r\nclass VertexPointXY : public BaseVertex<2, Eigen::Vector2d>\r\n{\r\n  public:\r\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW\r\n      VertexPointXY();\r\n\r\n    virtual void setToOriginImpl() {\r\n      _estimate.setZero();\r\n    }\r\n\r\n    virtual void oplusImpl(double* update)\r\n    {\r\n      _estimate[0] += update[0];\r\n      _estimate[1] += update[1];\r\n    }\r\n\r\n    virtual bool read(std::istream& is);\r\n    virtual bool write(std::ostream& os) const;\r\n};\r\n\\end{lstlisting}\r\n\r\nNow we are done with the vertices. We should go for the edges.  Since\r\nboth edges are binary edges we, extend the class\r\n\\verb+BaseBinaryEdge<>+.\r\nTo represent an odometry edge (see Listing~\\ref{lst:edgese2}) that\r\nconnects two \\verb+VertexSE2+, we need to extend \r\n\\verb+BaseBinaryEdge<>+,  specialized with the types of the\r\nconnected vertices (the order matters), where the measurement itself\r\nis represented by an \\verb+SE2+ that has dimension 3. The second\r\ntemplate parameter is the one used for the member variable\r\n\\verb+_measurement+.  The second step is to construct an error\r\nfunction, by redefining the \\verb+computeError()+ method.  The\r\n\\verb+computeError()+ should put the error vector in a member variable\r\n\\verb+error+ that has type \\verb+Eigen::Vector<double,3>+. Here the 3\r\ncomes from the template parameter that specifies the dimension.\r\nAgain, the read and write functions can be looked up in the code.\r\nNow we are done with this edge. The Jacobians are computed numerically\r\nby \\gopt{}.  However, if you want to speed up the execution of your\r\ncode after everything works, you are warmly invited to redefine the\r\n\\verb+linearizeOplus+ method.\r\n\r\n\\begin{lstlisting}[float,label=lst:edgese2,caption=\\text{Edge connecting two\r\n  robot poses, for example, the odometry of the robot.}]\r\nclass EdgeSE2 : public BaseBinaryEdge<3, SE2, VertexSE2, VertexSE2>\r\n{\r\n  public:\r\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW\r\n      EdgeSE2();\r\n\r\n    void computeError()\r\n    {\r\n      const VertexSE2* v1 = static_cast<const VertexSE2*>(_vertices[0]);\r\n      const VertexSE2* v2 = static_cast<const VertexSE2*>(_vertices[1]);\r\n      SE2 delta = _measurement.inverse() * (v1->estimate().inverse()*v2->estimate());\r\n      _error = delta.toVector();\r\n    }\r\n    virtual bool read(std::istream& is);\r\n    virtual bool write(std::ostream& os) const;\r\n};\r\n\\end{lstlisting}\r\n\r\nThe last thing that remains to do is to define a class to represent a\r\nlandmark measurement.  This is shown in Listing~\\ref{lst:edgese2xy}.\r\nAgain, we extend a specialization of \\verb+BaseBinaryEdge<>+, and we\r\ntell the system that it connects a \\verb+VertexSE2+ with a\r\n\\verb+VertexPointXY+, that the measurement is represented by an\r\n\\verb+Eigen::Vector2d+ that has dimension 2.\r\n\r\n\\begin{lstlisting}[float,label=lst:edgese2xy,caption=Edge connecting a\r\n  robot poses and a landmark.]\r\nclass EdgeSE2PointXY : public BaseBinaryEdge<2, Eigen::Vector2d, VertexSE2, VertexPointXY>\r\n{\r\n  public:\r\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW\r\n      EdgeSE2PointXY();\r\n\r\n    void computeError()\r\n    {\r\n      const VertexSE2* v1 = static_cast<const VertexSE2*>(_vertices[0]);\r\n      const VertexPointXY* l2 = static_cast<const VertexPointXY*>(_vertices[1]);\r\n      _error = (v1->estimate().inverse() * l2->estimate()) - _measurement;\r\n    }\r\n\r\n    virtual bool read(std::istream& is);\r\n    virtual bool write(std::ostream& os) const;\r\n\r\n};\r\n\\end{lstlisting}\r\nThe final step we should do to make our system operational, is to\r\nregister the types to let \\gopt{} know that there are new types ready.\r\nHowever, if you intend to manually construct your graph without doing\r\nany i/o operation on disk, this step is not even necessary. Have fun!\r\n\r\nYou may find the full code of this 2D SLAM example in the folder\r\n\\texttt{examples/tutorials\\_slam2d}.\r\n\r\n{\\small\r\n\\bibliographystyle{unsrt}\r\n\\bibliography{robots}}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "ad133875dad5ab8b8e0d7073e7421a122443e366", "size": 69085, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slambook2/3rdparty/g2o/doc/g2o.tex", "max_stars_repo_name": "zhh2005757/slambook2_in_Docker", "max_stars_repo_head_hexsha": "f0e71327d196cdad3b3c10d96eacdf95240d528b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-10-14T07:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T09:20:33.000Z", "max_issues_repo_path": "slambook2/3rdparty/g2o/doc/g2o.tex", "max_issues_repo_name": "zhh2005757/slambook2_in_Docker", "max_issues_repo_head_hexsha": "f0e71327d196cdad3b3c10d96eacdf95240d528b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slambook2/3rdparty/g2o/doc/g2o.tex", "max_forks_repo_name": "zhh2005757/slambook2_in_Docker", "max_forks_repo_head_hexsha": "f0e71327d196cdad3b3c10d96eacdf95240d528b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-21T06:12:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T15:52:28.000Z", "avg_line_length": 48.1428571429, "max_line_length": 238, "alphanum_fraction": 0.7254396758, "num_tokens": 19452, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953797290153, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4131540556161965}}
{"text": "%!TEX root = forallxsol.tex\n%\\part{First-order logic}\n%\\label{ch.FOL}\n%\\addtocontents{toc}{\\protect\\mbox{}\\protect\\hrulefill\\par}\n\n\\setcounter{chapter}{21}\n\\chapter{Sentences with one quantifier}\\label{s:MoreMonadic}\\setcounter{ProbPart}{0}\n\\problempart\n\\label{pr.BarbaraEtc}\nHere are the syllogistic figures identified by Aristotle and his successors, along with their medieval names:\n\\begin{ebullet}\n\t\\item \\textbf{Barbara.} All G are F. All H are G. So:  All H are F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif Fx)$}\n\t\\item \\textbf{Celarent.} No G are F. All H are G. So: No H are F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Ferio.} No G are F. Some H is G. So: Some H is not F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\exists x (Hx \\eand  Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Darii.} All G are H. Some H is G. So: Some H is F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\exists x (Hx \\eand  Gx) \\therefore \\exists x (Hx \\eand  Fx)$}\n\t\\item \\textbf{Camestres.} All F are G. No H are G. So: No H are F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\forall x (Hx \\eif \\enot Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Cesare.} No F are G. All H are G. So: No H are F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Baroko.} All F are G. Some H is not G. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\exists x (Hx \\eand \\enot Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Festino.} No F are G. Some H are G. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\exists x (Hx \\eand Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Datisi.} All G are F. Some G is H. So: Some H is F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\exists x (Gx \\eand Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Disamis.} Some G is F. All G are H. So: Some H is F.\n\t\\item[] \\myanswer{$\\exists x (Gx \\eand Fx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Ferison.} No G are F. Some G is H. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\exists x (Gx \\eand Hx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Bokardo.} Some G is not F. All G are H. So:  Some H is not F.\n\t\\item[] \\myanswer{$\\exists x (Gx \\eand \\enot Fx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Camenes.} All F are G. No G are H So: No H is F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\forall x (Gx \\eif \\enot Hx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Dimaris.} Some F is G. All G are H. So: Some H is F.\n\t\\item[] \\myanswer{$\\exists x (Fx \\eand Gx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Fresison.} No F are G. Some G is H. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\exists x (Gx \\eand Hx) \\therefore \\exists (Hx \\eand \\enot Fx)$}\n\\end{ebullet}\nSymbolize each argument in FOL.\n\n\\\n\\problempart\n\\label{pr.FOLvegetarians}\nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Kx] \\gap{x} knows the combination to the safe\n\\item[Sx] \\gap{x} is a spy\n\\item[Vx] \\gap{x} is a vegetarian\n%\\item[Txy] \\gap{x} trusts \\gap{y}.\n\\item[h] Hofthor\n\\item[i] Ingmar\n\\end{ekey}\nsymbolize the following sentences in FOL:\n\\begin{earg}\n\\item Neither Hofthor nor Ingmar is a vegetarian.\n\\item[] \\myanswer{$\\enot Vh \\eand \\enot Vi$}\n\\item No spy knows the combination to the safe.\n\\item[] \\myanswer{$\\forall x (Sx \\eif \\enot Kx)$}\n\\item No one knows the combination to the safe unless Ingmar does.\n\\item[] \\myanswer{$\\forall x \\enot Kx \\eor Ki$}\n\\item Hofthor is a spy, but no vegetarian is a spy.\n\\item[] \\myanswer{$Sh \\eand \\forall x(Vx \\eif \\enot Sx)$}\n%\\item Hofthor trusts a vegetarian.\n%\\item Everyone who trusts Ingmar trusts a vegetarian.\n%\\item Everyone who trusts Ingmar trusts someone who trusts a vegetarian.\n%\\item Only Ingmar knows the combination to the safe.\n%\\item Ingmar trusts Hofthor, but no one else.\n%\\item The person who knows the combination to the safe is a vegetarian.\n%\\item The person who knows the combination to the safe is not a spy.\n\\end{earg}\n\n\\solutions\n\\problempart\\label{pr.FOLalligators}\nUsing this symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[Ax] \\gap{x} is an alligator.\n\\item[Mx] \\gap{x} is a monkey.\n\\item[Rx] \\gap{x} is a reptile.\n\\item[Zx] \\gap{x} lives at the zoo.\n\\item[a] Amos\n\\item[b] Bouncer\n\\item[c] Cleo\n\\end{ekey}\nsymbolize each of the following sentences in FOL:\n\\begin{earg}\n\\item Amos, Bouncer, and Cleo all live at the zoo. \n\\item[] \\myanswer{$Za \\eand Zb \\eand Zc$}\n\\item Bouncer is a reptile, but not an alligator. \n\\item[] \\myanswer{$Rb \\eand \\enot Ab$}\n%\\item If Cleo loves Bouncer, then Bouncer is a monkey. \n%\\item If both Bouncer and Cleo are alligators, then Amos loves them both.\n\\item Some reptile lives at the zoo. \n\\item[] \\myanswer{$\\exists x (Rx \\eand Zx)$}\n\\item Every alligator is a reptile. \n\\item[] \\myanswer{$\\forall x(Ax \\eif Rx)$}\n\\item Any animal that lives at the zoo is either a monkey or an alligator. \n\\item[] \\myanswer{$\\forall x(Zx \\eif (Mx \\eor Ax))$}\n\\item There are reptiles which are not alligators.\n\\item[] \\myanswer{$\\exists x (Rx \\eand \\enot Ax)$}\n%\\item Cleo loves a reptile.\n%\\item Bouncer loves all the monkeys that live at the zoo.\n%\\item All the monkeys that Amos loves love him back.\n\\item If any animal is an reptile, then Amos is.\n\\item[] \\myanswer{$\\exists x Rx \\eif Ra$}\n\\item If any animal is an alligator, then it is a reptile.\n\\item[] \\myanswer{$\\forall x(Ax \\eif Rx)$}\n%\\item Every monkey that Cleo loves is also loved by Amos.\n%\\item There is a monkey that loves Bouncer, but sadly Bouncer does not reciprocate this love.\n\\end{earg}\n\n\\problempart\n\\label{pr.FOLarguments}\nFor each argument, write a symbolization key and symbolize the argument in FOL.\n\\begin{earg}\n\\item Willard is a logician. All logicians wear funny hats. So Willard wears a funny hat\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Lx] \\gap{x} is a logician\n\\item[Hx] \\gap{x} wears a funny hat\n\\item[i] Willard\n\\end{ekey}\n$Li, \\forall x (Lx \\eif Hx) \\therefore Hi$}\n\\item Nothing on my desk escapes my attention. There is a computer on my desk. As such, there is a computer that does not escape my attention.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] physical things\n\\item[Dx] \\gap{x} is on my desk\n\\item[Ex] \\gap{x} escapes my attention\n\\item[Cx] \\gap{x} is a computer\n\\end{ekey}\n$\\forall x (Dx \\eif \\enot Ex), \\exists x(Dx \\eand Cx) \\therefore \\exists x (Cx \\eand \\enot Ex)$}\n\\item All my dreams are black and white. Old TV shows are in black and white. Therefore, some of my dreams are old TV shows.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] episodes (psychological and televised)\n\\item[Dx] \\gap{x} is one of my dreams\n\\item[Bx] \\gap{x} is in black and white\n\\item[Ox] \\gap{x} is an old TV show\n\\end{ekey}\n$\\forall x (Dx \\eif Bx), \\forall x (Ox \\eif Bx) \\therefore \\exists x (Dx \\eand Ox)$. \\\\Comment: generic statements are tricky to deal with. Does the second sentence mean that \\emph{all} old TV shows are in black and white; or that most of them are; or that most of the things which are in black and white are old TV shows? I have gone with the former, but it is not clear that FOL deals with these well.}\n\\item Neither Holmes nor Watson has been to Australia. A person could see a kangaroo only if they had been to Australia or to a zoo. Although Watson has not seen a kangaroo, Holmes has. Therefore, Holmes has been to a zoo.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Ax] \\gap{x} has been to Australia\n\\item[Kx] \\gap{x} has seen a kangaroo\n\\item[Zx] \\gap{x} has been to a zoo\n\\item[h] Holmes\n\\item[a] Watson\n\\end{ekey}\n$\\enot Ah \\eand \\enot Aa, \\forall x(Kx \\eif (Ax \\eor Zx)), \\enot Ka \\eand Kh \\therefore Zh$}\n\\item No one expects the Spanish Inquisition. No one knows the troubles I've seen. Therefore, anyone who expects the Spanish Inquisition knows the troubles I've seen.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Sx] \\gap{x} expects the Spanish Inquisition\n\\item[Tx] \\gap{x} knows the troubles I've seen\n\\item[h] Holmes\n\\item[a] Watson\n\\end{ekey}\n$\\forall x\\enot Sx, \\forall x \\enot Tx \\therefore \\forall x (Sx \\eif Tx)$}\n\\item All babies are illogical. Nobody who is illogical can manage a crocodile. Berthold is a baby. Therefore, Berthold is unable to manage a crocodile.\n\\myanswer{\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Bx] \\gap{x} is a baby\n\\item[Ix] \\gap{x} is illogical\n\\item[Cx] \\gap{x} can manage a crocodile\n\\item[b] Berthold\n\\end{ekey}\n$\\forall x (Bx \\eif Ix), \\forall x (Ix \\eif \\enot Cx), Bb \\therefore \\enot Cb$}\n\\end{earg}\n\n\\chapter{Multiple generality}\\setcounter{ProbPart}{0}\n\\problempart\nUsing this symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[Ax] \\gap{x} is an alligator\n\\item[Mx] \\gap{x} is a monkey\n\\item[Rx] \\gap{x} is a reptile\n\\item[Zx] \\gap{x} lives at the zoo\n\\item[Lxy] \\gap{x} loves \\gap{y}\n\\item[a] Amos\n\\item[b] Bouncer\n\\item[c] Cleo\n\\end{ekey}\nsymbolize each of the following sentences in FOL:\n\\begin{earg}\n\\item If Cleo loves Bouncer, then Bouncer is a monkey. \n\\item[] \\myanswer{$Lcb \\eif Mb$}\n\\item If both Bouncer and Cleo are alligators, then Amos loves them both.\n\\item[] \\myanswer{$(Ab \\eand Ac) \\eif (Lab \\eand Lac)$}\n%\\item Some reptile lives at the zoo. \n%\\item Every alligator is a reptile. \n%\\item Any animal that lives at the zoo is either a monkey or an alligator. \n%\\item There are reptiles which are not alligators.\n\\item Cleo loves a reptile.\n\\item[] \\myanswer{$\\exists x(Rx \\eand Lcx)$\\\\Comment: this English expression is ambiguous; in some contexts, it can be read as a generic, along the lines of `Cleo loves reptiles'. (Compare `I do love a good pint'.) }\n\\item Bouncer loves all the monkeys that live at the zoo.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Zx) \\eif Lbx)$}\\item All the monkeys that Amos loves love him back.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Lax) \\eif Lxa)$}\n%\\item If any animal is an reptile, then Amos is.\n%\\item If any animal is an alligator, then it is a reptile.\n\\item Every monkey that Cleo loves is also loved by Amos.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Lcx) \\eif Lax)$}\n\\item There is a monkey that loves Bouncer, but sadly Bouncer does not reciprocate this love.\n\\item[] \\myanswer{$\\exists x (Mx \\eand Lxb \\eand \\enot Lbx)$}\n\\end{earg}\n\n\\problempart \nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[Dx] \\gap{x} is a dog\n\\item[Sx] \\gap{x} likes samurai movies\n\\item[Lxy] \\gap{x} is larger than \\gap{y}\n\\item[r] Rave\n\\item[h] Shane\n\\item[d] Daisy\n\\end{ekey}\nsymbolize the following sentences in FOL:\n\\begin{earg}\n\\item Rave is a dog who likes samurai movies.\n\\item[] \\myanswer{$Dr \\eand Sr$}\n\\item Rave, Shane, and Daisy are all dogs.\n\\item[] \\myanswer{$Dr \\eand Dh \\eand D\\emph{d}$}\n\\item Shane is larger than Rave, and Daisy is larger than Shane.\n\\item[] \\myanswer{$Lhr \\eand L\\emph{d}h$}\n\\item All dogs like samurai movies.\n\\item[] \\myanswer{$\\forall x(Dx \\eif Sx)$}\n\\item Only dogs like samurai movies.\n\\item[] \\myanswer{$\\forall x(Sx \\eif Dx)$\\\\\nComment: the FOL sentence just written does not require that anyone likes samurai movies. The English sentence might suggest that at least some dogs \\emph{do} like samurai movies?}\n\\item There is a dog that is larger than Shane.\n\\item[] \\myanswer{$\\exists x (Dx \\eand Lxh)$}\n\\item If there is a dog larger than Daisy, then there is a dog larger than Shane.\n\\item[] \\myanswer{$\\exists x (Dx \\eand Lx\\emph{d}) \\eif \\exists x(Dx \\eand Lxh)$}\n\\item No animal that likes samurai movies is larger than Shane.\n\\item[] \\myanswer{$\\forall x (Sx \\eif \\enot Lxh)$}\n\\item No dog is larger than Daisy.\n\\item[] \\myanswer{$\\forall x (Dx \\eif \\enot Lx\\emph{d})$}\n\\item Any animal that dislikes samurai movies is larger than Rave.\n\\item[] \\myanswer{$\\forall x (\\enot Sx \\eif Lxr)$\\\\\nComment: this is very poor, though! For `dislikes' does not mean the same as `does not like'.}\n\\item There is an animal that is between Rave and Shane in size.\n\\item[] \\myanswer{$\\exists x((Lbx \\eand Lxh) \\eor (Lhx \\eand Lxr))$}\n\\item There is no dog that is between Rave and Shane in size.\n\\item[] \\myanswer{$\\forall x \\bigl(Dx \\eif \\enot\\bigl[(Lbx \\eand Lxh) \\eor (Lhx \\eand Lxr)\\bigr]\\bigr)$}\n\\item No dog is larger than itself.\n\\item[] \\myanswer{$\\forall x(Dx \\eif \\enot Lxx)$}\n\\item Every dog is larger than some dog.\n\\item[] \\myanswer{$\\forall x (Dx \\eif \\exists y(Dy \\eand Lxy))$\\\\\nComment: the English sentence is potentially ambiguous here. I have resolved the ambiguity by assuming it should be paraphrased by `for every dog, there is a dog smaller than it'.}\n\\item There is an animal that is smaller than every dog.\n\\item[] \\myanswer{$\\exists x \\forall y(Dy \\eif Lyx)$}\n\\item If there is an animal that is larger than any dog, then that animal does not like samurai movies.\n\\item[] \\myanswer{$\\forall x (\\forall y (Dy \\eif Lxy) \\eif \\enot Sx)$\\\\\nComment: I have assumed that `larger than any dog' here means `larger than every dog'.}\n\\end{earg}\n\n\\problempart\n\\label{pr.QLcandies}\nUsing the symbolization key given, translate each English-language sentence into FOL.\n\\begin{ekey}\n\\item[\\text{domain}] candies\n\\item[Cx] \\gap{x} has chocolate in it.\n\\item[Mx] \\gap{x} has marzipan in it.\n\\item[Sx] \\gap{x} has sugar in it.\n\\item[Tx] Boris has tried \\gap{x}.\n\\item[Bxy] \\gap{x} is better than \\gap{y}.\n\\end{ekey}\n\\begin{earg}\n\\item Boris has never tried any candy.\n\\item Marzipan is always made with sugar.\n\\item Some candy is sugar-free.\n\\item The very best candy is chocolate.\n\\item No candy is better than itself.\n\\item Boris has never tried sugar-free chocolate.\n\\item Boris has tried marzipan and chocolate, but never together.\n%\\item Boris has tried nothing that is better than sugar-free marzipan.\n\\item Any candy with chocolate is better than any candy without it.\n\\item Any candy with chocolate and marzipan is better than any candy that lacks both.\n\\end{earg}\n\n\\problempart\nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] people and dishes at a potluck\n\\item[Rx] \\gap{x} has run out.\n\\item[Tx] \\gap{x} is on the table.\n\\item[Fx] \\gap{x} is food.\n\\item[Px] \\gap{x} is a person.\n\\item[Lxy] \\gap{x} likes \\gap{y}.\n\\item[e] Eli\n\\item[f] Francesca\n\\item[g] the guacamole\n\\end{ekey}\nsymbolize the following English sentences in FOL:\n\\begin{earg}\n\\item All the food is on the table.\n\\item[] \\myanswer{$\\forall x(Fx \\eif Tx)$}\n\\item If the guacamole has not run out, then it is on the table.\n\\item[] \\myanswer{$\\enot Rg \\eif Tg$}\n\\item Everyone likes the guacamole.\n\\item[] \\myanswer{$\\forall x (Px \\eif Lxg)$}\n\\item If anyone likes the guacamole, then Eli does.\n\\item[] \\myanswer{$\\exists x (Px \\eand Lxg) \\eif Leg$}\\item Francesca only likes the dishes that have run out.\n\\item[] \\myanswer{$\\forall x \\bigl[(L\\emph{f}x \\eand Fx) \\eif Rx\\bigr]$}\n\\item Francesca likes no one, and no one likes Francesca.\n\\item[] \\myanswer{$\\forall x\\bigl[Px \\eif (\\enot L\\emph{f}x \\eand \\enot Lx\\emph{f})\\bigr]$}\n\\item Eli likes anyone who likes the guacamole.\n\\item[] \\myanswer{$\\forall x ((Px \\eand Lxg) \\eif Lex)$}\n\\item Eli likes anyone who likes the people that he likes.\n\\item[] \\myanswer{$\\forall x \\bigl[\\bigl(Px \\eand \\forall y[(Py \\eand Ley) \\eif Lxy]\\bigr) \\eif Lex\\bigr]$}\n\\item If there is a person on the table already, then all of the food must have run out.\n\\item[] \\myanswer{$\\exists x(Px \\eand Tx) \\eif \\forall x(Fx \\eif Rx)$}\n\\end{earg}\n\n\\solutions\n\\problempart\n\\label{pr.FOLballet}\nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Dx] \\gap{x} dances ballet.\n\\item[Fx] \\gap{x} is female.\n\\item[Mx] \\gap{x} is male.\n\\item[Cxy] \\gap{x} is a child of \\gap{y}.\n\\item[Sxy] \\gap{x} is a sibling of \\gap{y}.\n\\item[e] Elmer\n\\item[j] Jane\n\\item[p] Patrick\n\\end{ekey}\nsymbolize the following sentences in FOL:\n\\begin{earg}\n\\item All of Patrick's children are ballet dancers.\n\\item[] \\myanswer{$\\forall x(Cxp \\eif Dx)$}\n\\item Jane is Patrick's daughter.\n\\item[] \\myanswer{$Cjp \\eand Fj$}\n\\item Patrick has a daughter.\n\\item[] \\myanswer{$\\exists x(Cxp \\eand Fx)$}\n\\item Jane is an only child.\n\\item[] \\myanswer{$\\enot \\exists x Sxj$}\n\\item All of Patrick's sons dance ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[(Cxp \\eand Mx) \\eif Dx\\bigr]$}\n\\item Patrick has no sons.\n\\item[] \\myanswer{$\\enot \\exists x(Cxp \\eand Mx)$}\n\\item Jane is Elmer's niece.\n\\item[] \\myanswer{$\\exists x(Sxe \\eand Cjx \\eand Fj)$}\n\\item Patrick is Elmer's brother.\n\\item[] \\myanswer{$Spe \\eand Mp$}\n\\item Patrick's brothers have no children.\n\\item[] \\myanswer{$\\forall x\\bigl[(Spx \\eand Mx) \\eif \\enot \\exists y Cyx\\bigr]$}\n\\item Jane is an aunt.\n\\item[] \\myanswer{$Fj \\eand \\exists x(Sxj \\eand \\exists y Cyx)$}\n\\item Everyone who dances ballet has a brother who also dances ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[Dx \\eif \\exists y(My \\eand Syx \\eand Dy)\\bigr]$}\n\\item Every woman who dances ballet is the child of someone who dances ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[(Fx \\eand Dx) \\eif \\exists y(Cxy \\eand Dy)\\bigr]$}\n\\end{earg}\n\n\n\\chapter{Identity}\\label{sec.identity}\\setcounter{ProbPart}{0}\n%\\problempart\n%\\label{pr.FOLcandies}\n%Using the following symbolization key:\n%\\begin{ekey}\n%\\item[\\text{domain}] candies\n%\\item[Cx] \\gap{x} has chocolate in it.\n%\\item[Mx] \\gap{x} has marzipan in it.\n%\\item[Sx] \\gap{x} has sugar in it.\n%\\item[Tx] Boris has tried \\gap{x}.\n%\\item[Bxy] \\gap{x} is better than \\gap{y}.\n%\\end{ekey}\n%symbolize the following English sentences in FOL:\\\\\n%\\myanswer{Comment: these are deliberately tricky. What follows is the \\emph{best} we can offer in FOL, for each of these sentences. Some are not great.}\n%\\begin{earg}\n%\\item Boris has never tried any candy.\n%\\item[] \\myanswer{$\\forall x(Cx \\eif \\enot Tx)$}\n%\\item Marzipan is always made with sugar.\n%\\item[] \\myanswer{$\\forall x(Mx \\eif Sx)$}\n%\\item Some candy is sugar-free.\n%\\item[] \\myanswer{$\\exists x \\enot Sx$}\n%\\item The very best candy is chocolate.\n%\\item[] \\myanswer{Simply can't be done! The best we can offer is as in answer to 8.}\n%\\item No candy is better than itself.\n%\\item[] \\myanswer{$\\forall x \\enot Bxx$}\n%\\item Boris has never tried sugar-free chocolate.\n%\\item[] \\myanswer{$\\forall x((Cx \\eand Sx) \\eif \\enot Tx)$}\n%\\item Boris has tried marzipan and chocolate, but never together.\n%\\item[] \\myanswer{$\\exists x(Mx \\eand Tx) \\eand \\exists x(Cx \\eand Tx) \\eand \\forall x ((Mx \\eand Cx) \\eif \\enot Tx)$}\n%%\\item Boris has tried nothing that is better than sugar-free marzipan.\n%\\item Any candy with chocolate is better than any candy without it.\n%\\item[] \\myanswer{$\\forall x(Cx \\eif \\forall (\\enot Cy \\eif Bxy))$}\n%\\item Any candy with chocolate and marzipan is better than any candy that lacks both.\n%\\item[] \\myanswer{$\\forall x\\bigl[(Cx \\eand Mx)\\eif \\forall \\bigl((\\enot Cy \\eand \\enot My) \\eif Bxy\\bigr)\\bigr]$}\n%\\end{earg}\n\n\\problempart Explain why:\n\t\\begin{ebullet}\n\t\t\\item   `$\\exists x \\forall y(Ay \\eiff x= y)$' is a good symbolization of `there is exactly one apple'.\n\t\t\\item[] \\myanswer{We might naturally read this in English thus: \n\t\t\\begin{ebullet}\n\t\t\t\\item There is something, x, such that, if you choose any object at all, if you chose an apple then you chose x itself, and if you chose x itself then you chose an apple. \n\t\t\\end{ebullet}\n\t\tThe x in question must therefore be the one and only thing which is an apple.}\n\t\t\\item `$\\exists x \\exists y \\bigl[\\enot x = y \\eand \\forall z(Az \\eiff (x= z \\eor y = z)\\bigr]$' is a good symbolization of `there are exactly two apples'.\n\t\t\\item[] \\myanswer{Similarly to the above, we might naturally read this in English thus: \n\t\t\\begin{ebullet}\n\t\t\t\\item There are two distinct things, x and y, such that if you choose any object at all, if you chose an apple then you either chose x or y, and if you chose either x or y then you chose an apple. \n\t\t\\end{ebullet}\n\t\tThe x and y in question must therefore be the only things which are apples, and since they are distinct, there are two of them.}\n\t\\end{ebullet}\t\t\n\n\n\n\\chapter{Definite descriptions}\\setcounter{ProbPart}{0}\n\\problempart\nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[Kx] \\gap{x} knows the combination to the safe.\n\\item[Sx] \\gap{x} is a spy.\n\\item[Vx] \\gap{x} is a vegetarian.\n\\item[Txy] \\gap{x} trusts \\gap{y}.\n\\item[h] Hofthor\n\\item[i] Ingmar\n\\end{ekey}\nsymbolize the following sentences in FOL:\n\\begin{earg}\n\\item Hofthor trusts a vegetarian.\n\\item[] \\myanswer{$\\exists x(Vx \\eand Thx)$}\n\\item Everyone who trusts Ingmar trusts a vegetarian.\n\\item[] \\myanswer{$\\forall x\\bigl[Txi \\eif \\exists y(Txy \\eand Vy)\\bigr]$}\n\\item Everyone who trusts Ingmar trusts someone who trusts a vegetarian.\n\\item[] \\myanswer{$\\forall x\\bigl[Txi \\eif \\exists y\\bigr(Txy \\eand \\exists z(Tyz \\eand Vz)\\bigr)\\bigr]$}\n\\item Only Ingmar knows the combination to the safe.\n\\item[] \\myanswer{$\\forall x(Ki \\eif x = i)$\\\\Comment: does the English claim entail that Ingmar \\emph{does} know the combination to the safe? If so, then we should formalise this with a `$\\eiff$'.}\n\\item Ingmar trusts Hofthor, but no one else.\n\\item[] \\myanswer{$\\forall x(Tix \\eiff x = h)$}\n\\item The person who knows the combination to the safe is a vegetarian.\n\\item[] \\myanswer{$\\exists x\\bigl[Kx \\eand \\forall y(Ky \\eif x = y) \\eand Vx\\bigr]$}\n\\item The person who knows the combination to the safe is not a spy.\n\\item[] \\myanswer{$\\exists x\\bigl[Kx \\eand \\forall y(Ky \\eif x = y) \\eand \\enot Sx\\bigr]$\\\\\nComment: the scope of negation is potentially ambiguous here; I have read it as \\emph{inner} negation.}\n\\end{earg}\n\n\n\\solutions\n\\problempart\n\\label{pr.FOLcards}\nUsing the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] cards in a standard deck\n\\item[Bx] \\gap{x} is black.\n\\item[Cx] \\gap{x} is a club.\n\\item[Dx] \\gap{x} is a deuce.\n\\item[Jx] \\gap{x} is a jack.\n\\item[Mx] \\gap{x} is a man with an axe.\n\\item[Ox] \\gap{x} is one-eyed.\n\\item[Wx] \\gap{x} is wild.\n\\end{ekey}\nsymbolize each sentence in FOL:\n\\begin{earg}\n\\item All clubs are black cards.\n\\item[] \\myanswer{$\\forall x (Cx \\eif Bx)$}\n\\item There are no wild cards.\n\\item[] \\myanswer{$\\enot \\exists x Wx$}\n\\item There are at least two clubs.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Cx \\eand Cy)$}\n\\item There is more than one one-eyed jack.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Jx \\eand Ox  \\eand Jy \\eand Oy)$}\n\\item There are at most two one-eyed jacks.\n\\item[] \\myanswer{$\\forall x \\forall y \\forall z\\bigl[(Jx \\eand Ox \\eand Jy \\eand Oy \\eand Jz \\eand Oz) \\eif (x = y \\eor x = z \\eor y = z)\\bigr]$}\n\\item There are two black jacks.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Bx \\eand Jx \\eand By \\eand Jy)$\\\\\nComment: I am reading this as `there are \\emph{at least} two\\ldots'. If the suggestion was that there are \\emph{exactly} two, then a different FOL sentence would be required, namely:\\\\\n$\\exists x \\exists y \\bigl(\\enot x = y \\eand Bx \\eand Jx \\eand By \\eand Jy \\eand \\forall z[(Bz \\eand Jz) \\eif (x = z \\eor y = z)]\\bigr)$}\n\\item There are four deuces.\n\\item[] \\myanswer{$\\exists w \\exists x \\exists y \\exists z(\\enot w = x \\eand \\enot w = y \\eand \\enot w = z \\eand \\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Dw \\eand Dx \\eand Dy \\eand Dz)$\\\\\nComment: I am reading this as `there are \\emph{at least} four\\ldots'. If the suggestion is that there are \\emph{exactly} four, then we should offer instead:\\\\\n$\\exists w \\exists x \\exists y \\exists z\\bigl(\\enot w = x \\eand \\enot w = y \\eand \\enot w = z \\eand \\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Dw \\eand Dx \\eand Dy \\eand Dz \\eand \\forall v[Dv \\eif (v = w \\eor v = x \\eor v = y \\eor v =z)]\\bigr)$}\n\\item The deuce of clubs is a black card.\n\\item[] \\myanswer{$\\exists x \\bigl[Dx \\eand Cx \\eand \\forall y\\bigl((Dy \\eand Cy) \\eif x = y\\bigr) \\eand Bx\\bigr]$}\n\\item One-eyed jacks and the man with the axe are wild.\n\\item[] \\myanswer{$\\forall x \\bigl[(Jx \\eand Ox) \\eif Wx\\bigr] \\eand \\exists x\\bigl[Mx \\eand \\forall y(My \\eif x = y) \\eand Wx\\bigr]$}\n\\item If the deuce of clubs is wild, then there is exactly one wild card.\n\\item[] \\myanswer{$\\exists x \\bigl(Dx \\eand Cx \\eand \\forall y \\bigl[(Dy \\eand Cy) \\eif x= y\\bigr] \\eand Wx\\bigr) \\eif \\exists x \\bigl(Wx \\eand \\forall y(Wy \\eif x = y)\\bigr)$\\\\\nComment: if there is not exactly one deuce of clubs, then the above sentence is true. Maybe that's the wrong verdict. Perhaps the sentence should definitely be taken to imply that there is one and only one deuce of clubs, and then express a conditional about wildness. If so, then we might symbolize it thus:\n\\\\$\\exists x \\bigl(Dx \\eand Cx \\eand \\forall y \\bigl[(Dy \\eand Cy) \\eif x = y\\bigr] \\eand \\bigl[Wx \\eif \\forall y (Wy \\eif x = y)\\bigr]\\bigl)$}\n\\item The man with the axe is not a jack.\n\\item[] \\myanswer{$\\exists x \\bigl[Mx \\eand \\forall y(My \\eif x = y) \\eand \\enot Jx\\bigr]$}\n\\item The deuce of clubs is not the man with the axe.\n\\item[] \\myanswer{$\\exists x \\exists y\\bigl(Dx \\eand Cx \\eand \\forall z[(Dz \\eand Cz) \\eif x = z] \\eand My \\eand \\forall z(Mz \\eif y = x) \\eand \\enot x = y\\bigr)$}\n\n\\end{earg}\n\n\\\n\n\\problempart Using the following symbolization key:\n\\begin{ekey}\n\\item[\\text{domain}] animals in the world\n\\item[Bx] \\gap{x} is in Farmer Brown's field.\n\\item[Hx] \\gap{x} is a horse.\n\\item[Px] \\gap{x} is a Pegasus.\n\\item[Wx] \\gap{x} has wings.\n\\end{ekey}\nsymbolize the following sentences in FOL:\n\\begin{earg}\n\\item There are at least three horses in the world.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z (\\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Hx \\eand Hy \\eand Hz)$}\n\\item There are at least three animals in the world.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z (\\enot x = y \\eand \\enot x = z \\eand \\enot y = z)$}\n\\item There is more than one horse in Farmer Brown's field.\n\\item[] \\myanswer{$\\exists x \\exists y (\\enot x = y \\eand Hx \\eand Hy \\eand Bx \\eand By)$}\n\\item There are three horses in Farmer Brown's field.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z(\\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Hx \\eand Hy \\eand Hz \\eand Bx \\eand By \\eand Bz)$\\\\Comment: I have read this as `there are \\emph{at least} three\\ldots'. If the suggestion was that there are \\emph{exactly} three, then a different FOL sentence would be required.}\n\\item There is a single winged creature in Farmer Brown's field; any other creatures in the field must be wingless.\n\\item[] \\myanswer{$\\exists x\\bigl[Wx \\eand Bx \\eand \\forall y\\bigl((Wy \\eand By) \\eif x = y)\\bigr]$}\n\\item The Pegasus is a winged horse.\n\\item[] \\myanswer{$\\exists x \\bigl[Px \\eand \\forall y(Py \\eif x = y) \\eand Wx \\eand Hx\\bigr]$}\n\\item The animal in Farmer Brown's field is not a horse.\n\\item[] \\myanswer{$\\exists x \\bigl[ Bx \\eand \\forall y (By \\eif x = y) \\eand \\enot Hx\\bigr]$\\\\Comment: the scope of negation might be ambiguous here; I have read it as \\emph{inner} negation.}\n\\item The horse in Farmer Brown's field does not have wings.\n\\item[] \\myanswer{$\\exists x \\bigl[Hx \\eand Bx \\eand \\forall y \\bigl((Hy \\eand By) \\eif x = y\\bigr) \\eand \\enot Wx\\bigr]$\\\\Comment: the scope of negation might be ambiguous here; I have read it as \\emph{inner} negation.}\n\n\\end{earg}\n\n\\problempart\nIn this chapter, we symbolized `Nick is the traitor' by `$\\exists x (Tx \\eand \\forall y(Ty \\eif x = y) \\eand x = n)$'. Two equally good symbolizations would be:\n\t\\begin{ebullet}\n\t\t\\item $Tn \\eand \\forall y(Ty \\eif n = y)$\n\t\t\\item[] \\myanswer{This sentence requires that Nick is a traitor, and that Nick alone is a traitor. Otherwise put, there is one and only one traitor, namely, Nick. Otherwise put: Nick is the traitor.}\n\t\t\\item $\\forall y(Ty \\eiff y = n)$\n\t\t\\item[] \\myanswer{This sentence can be understood thus: Take anything you like; now, if you chose a traitor, you chose Nick, and if you chose Nick, you chose a traitor. So there is one and only one traitor, namely, Nick, as required.}\n\t\\end{ebullet}\nExplain why these would be equally good symbolizations.\n\n\\chapter{Sentences of FOL}\\setcounter{ProbPart}{0}\n\\problempart\n\\label{pr.freeFOL}\nIdentify which variables are bound and which are free.\n\\myanswer{We underline the bound variables, and overline the free variables.}\n\\begin{earg}\n\\item $\\exists x L\\underline{x}\\overline{y} \\eand \\forall y L\\underline{y}\\overline{x}$\n\\item $\\forall x A\\underline{x} \\eand B\\overline{x}$\n\\item $\\forall x (A\\underline{x} \\eand B\\underline{x}) \\eand \\forall y(C\\overline{x} \\eand D\\underline{y})$\n\\item $\\forall x\\exists y[R\\underline{xy} \\eif (J\\overline{z} \\eand K\\underline{x})] \\eor R\\overline{yx}$\n\\item $\\forall x_1(M\\overline{x_2} \\eiff L\\overline{x_2}\\underline{x_1}) \\eand \\exists x_2 L\\overline{x_3}\\underline{x_2}$\n\\end{earg}\n", "meta": {"hexsha": "64c6a35480a11ba230e3c5a782008bb3651a6f61", "size": 28915, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "solutions/forallx-sol-fol.tex", "max_stars_repo_name": "peasantcore/forallx-yyc", "max_stars_repo_head_hexsha": "7023818f0871d1d4712fd84032b920c73292cc53", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "solutions/forallx-sol-fol.tex", "max_issues_repo_name": "peasantcore/forallx-yyc", "max_issues_repo_head_hexsha": "7023818f0871d1d4712fd84032b920c73292cc53", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "solutions/forallx-sol-fol.tex", "max_forks_repo_name": "peasantcore/forallx-yyc", "max_forks_repo_head_hexsha": "7023818f0871d1d4712fd84032b920c73292cc53", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.8189964158, "max_line_length": 404, "alphanum_fraction": 0.6993256095, "num_tokens": 10083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953797290153, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.4131540451042859}}
{"text": "\\documentclass[bigger]{beamer}\n\n\\input{header-beam} % change to header-handout for handouts\n\n% ====================\n\\title[Lecture 16]{Logic I F13 Lecture 16}\n\\date{November 5, 2013}\n% ====================\n\n\\input{header}\n\n\\setlength{\\fitchprfwidth}{5em}\n\n\\section{Ambiguity}\n\n\\subsec{Types of Ambiguity}{\n\n\\bit\n\\item Lexical ambiguity: same word, different meaning\n\\item Structural ambiguity: different ways to read a phrase/sentence\n\\item \\emph{Scope ambiguity}: which connective or quantifier is in the\n  scope of which other connective or quantifier\\\\[2ex]\n\na is left of b and large or left of c\n\\begin{align*}\n\\sf LeftOf(a, b) & \\sf{} \\land (Large(a) \\lor RightOf(a, c)) \\\\\n\\sf (LeftOf(a, b) & \\sf{} \\land Large(a)) \\lor RightOf(a, c)\n\\end{align*}\n\\eit\n\n}\n\n\\subsec{``Anything''}{\n\n\\bit\n\\item Anything {\\color{blue}left of a cube} is large\\pauses\n\\[\\sf\n\\uncovers{3-}{\\forall x(}{\\color{blue}\\exists y(Cube(y) \\land LeftOf(x, y))} \\uncovers{3-}{{}\\to Large(x))}\n\\]\\pauses\n\\item {\\color{red}No cube is} left of anything large \\pauses\n\\[\\sf\n{\\color{red}\\forall x(Cube(x) \\to \\lnot} \\uncovers{5-}{\\exists y(Large(y) \\land LeftOf(x, y))}{\\color{red})}\n\\]\\pauses\n\\item {\\color{red}No cube is} left of everything large \\pauses\n\\[\\sf\n{\\color{red}\\forall x(Cube(x) \\to \\lnot} \\forall y(Large(y) \\to LeftOf(x, y)){\\color{red})}\n\\]\n\\eit\n\n}\n\n\\subsec{Negation and the Quantifiers}{\n\n\\bit\n\\item ``All cubes are not large''\n\\bit\n\\item Denial of ``all cubes are large''\\\\\n(``Are all cubes large? No, all cubes are not large'')\\pauses\n\\begin{align*}\n\\sf\\lnot\\forall x(Cube(x) & \\sf{} \\to Large(x)) \\\\\n\\sf\\exists x(Cube(x) & \\sf{} \\land\\lnot Large(x)) \n\\end{align*}\n\\item All cubes are: not large, i.e.,\\\\\nNo cubes are large\\pauses\n\\begin{align*}\n\\sf\\forall x(Cube(x) & \\sf{} \\to \\lnot Large(x)) \\\\\n\\sf\\lnot\\exists x(Cube(x) & \\sf{}\\land Large(x)) \n\\end{align*}\n\\eit\n\\eit\n}\n\n\\subsec{Multiple Quantifiers and Ambiguity}{\n\n\\bit\n\\item ``All cubes adjoin a tetrahedron''\n\\bit\n\\item ``A tetrahedron'' in the scope of ``all cubes'', i.e.,\\\\\n``For every cube, there is a tetrahedron it adjoins''\\pauses\n\\[\n\\sf\\forall x(Cube(x) \\to \\exists y(Tet(y) \\land Adjoins(x, y))\n\\]\n\\item ``All cubes'' in scope of ``a tetrahedron'', i.e.,\\\\\n``There is a tetrahedron which every cube adjoins''\\pauses\n\\[\n\\sf\\exists y(Tet(y) \\land \\forall x(Cube(x) \\to Adjoins(x, y))\n\\]\n\\eit\\eit\n}\n\n\n\\section{Anaphora and Uniqueness}\n\n\\subsec{Anaphora (Donkey Sentences)}{\n\n``Every farmer who owns a donkey is happy''\n\n\\bits\n\\item Step by step translation: ``All As are Bs''\n\\item x is a farmer who owns a donkey \\dots\\[\\sf\nFarmer(x) \\land \\exists y(Donkey(y) \\land Owns(x, y))\n\\] \n\\item {\\color{blue}Every} farmer who owns a donkey {\\color{blue}is happy}\n\\[\\sf\n{\\color{blue}\\forall x(}(Farmer(x) \\land \\exists y(Donkey(y) \\land Owns(x, y))) {\\color{blue}\\to Happy(x))}\n\\]\n\\eit\n\n}\n\n\\subsec{Anaphora (Donkey Sentences)}{\n\n``Every farmer who owns a donkey beats it''\n\n\\bits\n\\item Step by step translation: ``All As are Bs''\n\\item x is a farmer who owns a donkey \\dots\\[\\sf\nFarmer(x) \\land \\exists y(Donkey(y) \\land Owns(x, y))\n\\] \n\\item {\\color{blue}Every} farmer who owns a donkey {\\color{blue}beats it}\n\\[\\sf\n{\\color{blue}\\forall x(}(Farmer(x) \\land \\exists y(Donkey(y) \\land Owns(x, y))) {\\color{blue}\\to Beats(x, {\\color{red}y}))}\n\\]\n\\eit\n\n}\n\n\\subsec{Anaphora (Donkey Sentences)}{\n\n``Every farmer who owns a donkey beats it''\\pauses\n\n\\bits\n\\item When is it false that every farmer who owns a donkey beats it? \\pauses \nIf there's a farmer who owns a donkey but doesn't beat it. Deny that! \\pauses\n\\[\\sf\n\\lnot\\exists x(Farmer(x) \\land \\exists y(Donkey(y) \\land Owns(x, y) \\land \\lnot Beats(x, y)))\n\\]\n\\item For every farmer and every donkey: if the farmer owns the\n  donkey, the farmer beats the donkey\n\\[\\sf\n\\forall x\\forall y((Farmer(x) \\land Donkey(y)) \\to (Owns(x, y) \\to Beats(x, y)))\n\\]\n\\item Every farmer beats every donkey they own\n\\[\\sf\n\\forall x(Farmer(x) \\to \\forall y((Donkey(y) \\land Owns(x, y)) \\to Beats(x, y)))\n\\]\n\\eit\n\n}\n\n\\subsec{Uniqueness}{\n\n\\bit\n\\item There is at least one cube.\n\\[\n\\sf\\exists x\\, Cube(x)\\]\n\\item There is exactly one cube.\n\\bit\n\\item<2-> There's at least one cube, and\n\\item<3-> There are no others\n\\begin{align*}\n\\uncover<2->{\\sf\\exists x\\, (Cube(x)} & \\uncover<4->{\\sf\\land \\lnot \\exists y\\, (y \\neq x \\land Cube(y)))}\\\\\n\\uncover<3->{\\sf\\exists x\\,(Cube(x)} & \\uncover<5->{\\sf\\land \\forall y(Cube(y) \\to x = y))}\n\\end{align*}\n\\eit\n\\eit\n}\n\n\\section{Rules for $\\forall$}\n\n\\subsec{Rules for Fitch}{\n\n\\bit\n\\item Need rules for $\\forall$ and $\\exists$ for formal proofs\n\\item Formal proofs now more important, because no alternative (truth-table method)\n\\item Intro and Elim rules should be\n\\bit\n\\item simple\n\\item elegant (not involve other connectives or quantifiers)\n\\item yield only valid arguments\n\\eit \n\\eit\n\n}\n\n\\subsec{Candidates for Rules}{\n\\setlength{\\fitchprfwidth}{6em}\n\n\\bit\n\\item Only simple sentence close to $\\sf \\forall x\\, A(x)$ is $\\sf A(c)$\n\\item Gives simple, elegant $\\forall$Elim rule:\n\n\\fitchctx{\n\\nline[$k.$]{\\forall x\\, A(x)}\\\\\n\\fpline{\\quad A(c)}[\\lalle{}]\n}\n\\item Problem: corresponding ``intro rule'' isn't valid:\n\\fitchctx{\n\\nline[$k.$]{A(c)}\\\\\n\\fpline{\\quad\\forall x\\,A(x)}[\\emph{doesn't follow!}]\n}\n\\eit\n\n}\n\n\\subsec{Names for Arbitrary Objects}{\n\n\\bit\n\\item Diagnosis: the c in A(c) is a name for a \\emph{specific object}\nWe need a name for an \\emph{arbitrary, unspecified object}\n\\item If A(c) is true for whatever c could name, then A(x) is satisfied by \\emph{every} object \n\\item In fact, this is what we do when we give proofs of general claims, e.g.,\n\n\\setlength{\\fitchargwidth}{15em}\n\\fitcharg{\\tline{All cubes adjoin a}\\\\\n\\tline{Only small things adjoin a}}{\n\\tline{All cubes are small}}\n\n\\pauses\nProof: Let Carl be any cube.  Since all cubes adjoin a, Carl adjoins\na. Since only small things adjoin a, Carl is small. But ``Carl''\nstands for \\emph{any} cube. So all cubes are small.\n  \\eit\n\n}\n\n\\subsec{Arbitrary Objects in Fitch}{\n\n\\bit \n\\item Every special constant with stands for an arbitrary object is\n  introduced only pro tem\n\\item In particular, they never appear in the premises or conclusion of an argument\n\\item In Fitch, this is enforced by requiring that special constants only appear in subproofs\n\\item To indicate that a constant names an arbitrary object, it is put in a box at the beginning of this subproof\n\\eit\n\n}\n\n\\subsec{General Conditional Proof}{\n\\setlength{\\fitchctxwidth}{11em}\n\n\\fitchctx{\n\\boxedsubproof[$m$.]{c}{A(c)}{\\ellipsesline \\\\ \\nline[$n.$]{B(c)}}\n\\fpline{\\quad \\forall x(A(x) \\to B(x))}[\\lalli{$m$--$n$}]}\n\n\\bit\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Universal Generalization}{\n\\setlength{\\fitchprfwidth}{11em}\n\n\\fitchctx{\n\\boxedsubproof[$m$.]{c}{}{\\ellipsesline \\\\ \\nline[$n.$]{A(c)}}\n\\fpline{\\quad \\forall x\\,A(x)}[\\lalli{$m$--$n$}]}\n\\bit\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Example}{\n\n\\setlength{\\fitchargwidth}{15em}\n\\fitcharg{\\tline{All cubes adjoin a}\\\\\n\\tline{Only small things adjoin a}}{\n\\tline{All cubes are small}}\n\n\\bigskip\n\n\\fitchprf{\\pline{\\forall x\\, (Cube(x) \\to Adjoins(x, a))}\\\\\n\\pline{\\forall x(Adjoins(x, a) \\to Small(x))}}{\n\\pline{\\forall x(Cube(x) \\to Small(x))}}\n\n}\n\n\\subsec{Example}{\n\n\\setlength{\\fitchprfwidth}{15em}\n\n\\fitchprf{\\pline[1.]{\\forall x\\, (Cube(x) \\to Adjoins(x, a))}\\\\\n\\pline[2.]{\\forall x(Adjoins(x, a) \\to Small(x))}}{\n\\boxedsubproof[3.]{c}{Cube(c)}{\\pline[4.]{Cube(c) \\to Adjoins(c, a)}[\\lalle{1}] \\\\\n\\pline[5.]{Adjoins(c, a)}[\\life{3}{4}]\\\\\n\\pline[6.]{Adjoins(c, a) \\to Small(c)}[\\lalle{2}] \\\\\n\\pline[7.]{Small(c)}[\\life{5}{6}]}\n\\pline[8.]{\\forall x(Cube(x) \\to Small(x))}[\\lalli{3--7}]}\n\n}\n\n\\section{Rules for $\\exists$}\n\n\\subsec{Intro Rule for $\\exists$}{\n\\setlength{\\fitchprfwidth}{7em}\n\\bit\n\\item If we know of a specific object that it satisfies A(x), we know that at least one object satisfies A(x)\n\\item So this rule is valid:\n\n\\fitchctx{\\pline[$m.$]{A(c)}\\\\\n\\fpline{\\quad \\exists x\\, A(x)}[\\lexii{$m$}]}\n\\item Problem: corresponding ``elim rule'' isn't valid:\n\\fitchctx{\n\\nline{\\exists x\\, A(x)}\\\\\n\\fpline{\\quad A(c)}[\\emph{doesn't follow!}]\n}\n\n\n\\eit\n\n}\n\n\\subsec{Arbitrary Objects Again}{\n\n\\bit\n\\item If we know that $\\sf\\exists x\\, A(x)$ is true, we know that \\emph{some} object(s) satisfy A(x), but not which ones\n\\item To use this information, we have to introduce a temporary name that stands for any one of the objects that satisfy A(x)\n\\item This is what we'd do if we reason informally from existential information, e.g.,\n\n\\setlength{\\fitchprfwidth}{15em}\n\\fitchprf{\\tline{There are small cubes}\\\\\n\\tline{Anything small adjoins a}}{\n\\tline{Some cubes adjoin a}}\n\n\\pauses\nProof: We know there are small cubes. Let Cate be an arbitrary one of them.  So\nCate is small. Since all small things adjoins a, Cate adjoins a. Since\nCate is a cube adjoining a, some cubes adjoin a.\n\\eit \n\n}\n\n\\subsec{Existential Instantiation}{\n\\setlength{\\fitchprfwidth}{7em}\n\n\\bit\n\\item If we know that some object satisfies A(x), we assume for the time being that c is one of them (i.e., assume A(c)), and we can prove that some claim B fololows from this assumption, then B follows already from $\\sf\\exists x\\, A(x)$.\n\\item Rule for existential elimination:\n\\bigskip\n\n\\fitchctx{\n\\pline[$k$.]{\\exists x\\, A(x)}\\\\\n\\boxedsubproof[$m$.]{c}{A(c)}{\\ellipsesline \\\\ \\nline[$n.$]{B}}\n\\fpline{\\quad B}[\\lexie{k}{$m$--$n$}]}\n\\item c is special: c must not appear anywhere outside the subproof\n\\eit\n}\n\n\\subsec{Example}{\n\n\\setlength{\\fitchprfwidth}{15em}\n\\fitchprf{\\tline{There are small cubes}\\\\\n\\tline{Anything small adjoins a}}{\n\\tline{Some cubes adjoin a}}\n\n\\bigskip\n\n\\fitchprf{\\pline{\\exists x(Small(x) \\land Cube(x))}\\\\\n\\pline{\\forall x(Small(x) \\to Adjoins(x, a))}}{\n\\pline{\\exists x(Cube(x) \\land Adjoins(x, a)}}\n}\n\n\\subsec{Example}{\n\n\\setlength{\\fitchprfwidth}{15em}\n\\fitchprf{\\pline[1.]{\\exists x(Small(x) \\land Cube(x))}\\\\\n\\pline[2.]{\\forall x(Small(x) \\to Adjoins(x, a))}}{\n\\boxedsubproof[3.]{c}{Small(c) \\land Cube(c)}{\n\\pline[4.]{Small(c)}[\\lande{3}] \\\\\n\\pline[5.]{Small(c) \\to Adjoins(c, a)}[\\lalle{2}] \\\\\n\\pline[6.]{Adjoins(c, a)}[\\life{4}{5}]\\\\\n\\pline[7.]{Cube(c)}[\\lande{3}] \\\\\n\\pline[8.]{Cube(c) \\land Adjoins(c, a)}[\\landi{6}{7}]\\\\\n\\pline[9.]{\\exists x(Cube(x) \\land Adjoins(x, a)}[\\lexii{8}]\n}\n\\pline[10.]{\\exists x(Cube(x) \\land Adjoins(x, a)}[\\lexie{1}{3--9}]\n}\n\n}\n\\end{document} \n\n\n\n\n", "meta": {"hexsha": "9208d5e3d80ade2576d0967927512e246d1ba999", "size": 10380, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "279-lec16.tex", "max_stars_repo_name": "rzach/phil279", "max_stars_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-09-23T13:42:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-21T10:48:55.000Z", "max_issues_repo_path": "279-lec16.tex", "max_issues_repo_name": "rzach/phil279", "max_issues_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "279-lec16.tex", "max_forks_repo_name": "rzach/phil279", "max_forks_repo_head_hexsha": "722ec82ae7a4593d40c72083d830c4e3e4864dc0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.03125, "max_line_length": 238, "alphanum_fraction": 0.6715799615, "num_tokens": 3621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.4131540382036995}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Wednesday\\\\ 2020-8-19, \\\\ compiled \\\\ \\today}\n\nUnder our assumptions the electric field can be written as \n%\n\\begin{align}\n\\vec{E} = E_0 \\sin \\omega_0 t \\vec{\\epsilon}\n\\,,\n\\end{align}\n%\nwhere \\(\\vec{\\epsilon}\\) is a unit vector which is perpendicular to the propagation direction: \\(\\vec{\\epsilon} \\cdot \\vec{k} = 0\\); while \\(E_0 \\) is the amplitude of the electric field and \\(\\omega_0\\) is its frequency. \n\nThe equations of motion of the charge read \n%\n\\begin{align}\nm \\ddot{\\vec{r}} = e \\vec{E} = e E_0 \\sin \\omega_0 t \\vec{\\epsilon}\n\\,,\n\\end{align}\n%\nwhich  we can also express through the dipole moment \\(\\vec{d} = e \\vec{r}\\): the equation for its evolution will then read \n%\n\\begin{align}\n\\ddot{\\vec{d}} = \\frac{e^2}{m} E_0 \\sin \\omega_0 t \\vec{\\epsilon }\n\\,.\n\\end{align}\n\nIf we integrate in \\(\\dd{t}\\) two times we find \n%\n\\begin{align}\n\\vec{d} (t) = - \\frac{e^2 E_0 }{m \\omega_0^2} \\sin \\omega_0 t \\vec{\\epsilon}\n\\,,\n\\end{align}\n%\nso the response to the impinging EM wave is an oscillation of the dipole, with a frequency \\(\\omega_0\\) equal to that of the EM wave and an amplitude equal to \n%\n\\begin{align}\nd_0 = \\frac{e^2 E_0 }{m \\omega_0^2}\n\\,.\n\\end{align}\n\nThe electron is accelerating, so it will radiate: the power emitted per unit solid angle will be \n%\n\\begin{align}\n\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\Omega }} = \\frac{1}{c^3} \\frac{ \\ddot{d}^2}{4 \\pi } \\sin^2 \\Theta \n= \\frac{1}{4 \\pi c^3} \\frac{e^{4}}{m^2} E_0^2 \\sin^2 \\omega_0 t \\sin^2 \\Theta \n\\,,\n\\end{align}\n%\nwhere \\(\\Theta \\) is the angle between the direction of propagation of the wave and the direction of observation. \nThis oscillates in time; we can compute the average over an oscillation: this means that we substitute the square sine with a factor \\(1/2\\): \n%\n\\begin{align}\n\\expval{\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\Omega }}} = \n\\frac{e^{4} E_0^2 \\sin^2 \\Theta }{8 \\pi c^3 m^2}\n\\,.\n\\end{align}\n\nIntegrating over the solid angle to get the average power amounts to multiplying by \\(4 \\pi \\) times \\(2/3\\), because of the solid angle in the sphere and because of the integral of \\(\\sin^2 \\Theta\\). \nThis yields \n%\n\\begin{align}\n\\expval{\\dv{w}{t}} = \\frac{e^{4} E_0^2}{3 m^2 c^3}\n\\,.\n\\end{align}\n\nNow, let us compute the flux of energy which is carried away by the incident EM wave: \n%\n\\begin{align}\nS = \\frac{ \\dd{w}}{ \\dd{A} \\dd{t}} \n= \\frac{c}{4 \\pi } E_r^2 \n= \\frac{c}{4 \\pi R^2} E_0^2 \\sin^2 \\omega_0t \n\\,,\n\\end{align}\n%\nthen the power per unit solid angle is \n%\n\\begin{align}\n\\frac{ \\dd{w}}{ \\dd{\\Omega } \\dd{t}} = \\frac{c}{4 \\pi } E_0^2 \\sin^2 \\omega_0 t \n\\,,\n\\end{align}\n%\nwhose average as before is \n%\n\\begin{align}\n\\expval{ \\frac{ \\dd{w}}{ \\dd{\\Omega } \\dd{t}}} = \\frac{c E_0^2}{8 \\pi }\n\\,.\n\\end{align}\n\n\\todo[inline]{Except this, dimensionally, is a power per unit \\emph{area}!}\n\nNow, let us define the \\textbf{differential scattering cross section} as \n%\n\\begin{align}\n\\dv{\\sigma }{\\Omega } = \n\\frac{\n    \\expval{\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\Omega }}}_{\\text{emitted}}\n    }{\n    \\expval{\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\Omega }}}_{\\text{incoming}}\n}\n\\,,\n\\end{align}\n%\n\\todo[inline]{is this not dimensionally inconsistent? the differential scattering cross section should have the dimensions of an area / steradian\\dots Maybe the incoming power should be considered per unit \\emph{area}, since it is a plane wave whose source is at infinity?\n\nThis seems indeed to be the case, see \\cite[eq.\\ 3.36]{rybickiRadiativeProcessesAstrophysics1979}}\nand if we compute this for our case we will have \n%\n\\begin{align}\n\\dv{\\sigma }{\\Omega } = \\frac{e^{4}E_0^2 \\sin^2 \\Theta }{8 \\pi c^3 m^2}\n\\frac{8 \\pi }{c E_0^2} \n= \\frac{e^{4}}{c^{4} m^2} \\sin^2 \\Theta \n\\,.\n\\end{align}\n\nThis expression can also be written through the classical electron radius: \n%\n\\begin{align}\nr_0 = \\frac{e^2}{mc^2} \\approx \\SI{2.82e-13}{cm}\n\\,,\n\\end{align}\n%\nwhose expression is found by equating the rest energy of the electron \\(m c^2\\) with its electromagnetic self-energy \\(e^2 / r_0 \\). \nThen, the scattering cross section can be expressed as \n%\n\\begin{align}\n\\dv{\\sigma }{\\Omega } = r_0^2 \\sin^2 \\Theta \n\\,.\n\\end{align}\n\nThe total cross section is found from the integral of this over all the solid angle: \n%\n\\begin{align}\n\\sigma_T = \\int \\dv{\\sigma }{\\Omega } \\dd{\\Omega } = r_0^2 \\underbrace{\\int (1 - \\mu^2) \\dd{\\mu } \\times 2 \\pi }_{= 8 \\pi /3} = \\frac{8 \\pi }{3} r_0^2\n\\,.\n\\end{align}\n\nThis is the \\textbf{Thomson cross section} of the electron \\(\\sigma_{T} \\approx \\SI{0.665e-24}{cm^2}\\). \n\nNow, for some observations. This cross section does not change depending on the frequency of the incoming wave: it is ``color blind''.\nThis formula for the scattering is not always valid, but in its regime of validity (which will be discussed later) we expect no frequency dependence. \n\nMoreover, this scattering is \\textbf{conservative} or coherent: the frequency of the scattered radiation is the same as the frequency of the incoming radiation.\n\nIt also is \\textbf{not isotropic} because of the factor \\(\\sin^2 \\Theta \\). This scattering ``prefers'' for the light to go along the same direction it came from, and the probability density for it goes to zero for  \\(\\Theta = \\pi /2\\), meaning for a scattered photon orthogonal to the direction of propagation. \nAlso, there is forward-backward symmetry, which will be useful to simplify certain calculations.\nThe degree of anisotropy is also rather mild, it varies slowly over the solid angle, so in certain situations it will be alright to approximate Thomson scattering as isotropic.\nThis is the closest we can get to completely isotropic and coherent scattering. \n\nWe can apply this reasoning to any other particle, it does not need to be an electron: for example, let us apply it to a proton. \nTheir square charge is the same --- the sign does not matter. The only different is the mass, which appears with a power \\(m^{-2}\\) in the cross section and in the differential cross section. \n\nSo, their ratio will be \n%\n\\begin{align}\n\\frac{\\sigma_{p}}{\\sigma_{e}} = \\qty( \\frac{m_e}{m_p})^2 \\approx \\num{3e-7}\n\\,.\n\\end{align}\n\nThis is important in astrophysical applications: if we have a plasma with protons and electron we can almost completely ignore the protons. \n\nOur assumptions have been to treat the electromagnetic field classically, and to assume the electron moves nonrelativistically. \nThe first of these holds as long as the energy of the individual photons is small: \\(h \\nu \\ll m_e c^2\\). If this is the case, the \\textbf{recoil} of the electron due to the scattering with the single photon is negligible. \nSince \\(m_e c^2 \\approx \\SI{511}{keV}\\), we are asking that \\(h \\nu \\ll \\SI{511}{keV}\\). \nA rough boundary for when this works is given by considering \\(h \\nu \\approx \\SI{50}{keV}\\), a tenth of the electron rest energy. \nThis puts us in the medium X-rays. \n\nWe also assumed that the electron started out at rest, while in practically all situations charges are moving around, if nothing else because of thermal motion. \nIf we are considering a plasma, it must be hot for the gas to stay ionized. \n\nIn the electron's rest frame our description works, however in order to be in that frame we must perform a Lorentz boost, apply Thomson scattering, and boost back: in this way we can describe how the energy of the photon changes.\n\nIn astrophysical settings, radiation is generally either completely unpolarized or partially polarized. Therefore, it is interesting to compute the cross section for unpolarized radiation.\n\nUnpolarized radiation can be described as the superposition of two orthogonal polarized waves. One of them will have an angle \\(\\Theta \\) between the polarization vector \\(\\vec{\\epsilon}_1 \\) and the observation direction \\(\\vec{n}\\), let us suppose that \\(\\vec{\\epsilon}_1 \\), \\(\\vec{k}\\) and \\(\\vec{n}\\) are coplanar. \nThis can be done, since all we are doing is choosing a convenient basis for the plane orthogonal to the propagation direction.\n\nIf this is the case, then if \\(\\vec{\\epsilon}_2 \\perp \\vec{\\epsilon}_1\\) we must have \\(\\Theta = \\pi / 2\\) for the second wave. This means that we have the two cross sections \n%\n\\begin{align}\n\\eval{\\dv{\\sigma }{\\Omega }}_{1} = r_0^2 \\sin^2 \\Theta \n\\qquad \\text{and} \\qquad\n\\eval{\\dv{\\sigma }{\\Omega }}_{2} = r_0^2 \\sin^2 \\frac{\\pi}{2} = r_0^2\n\\,.\n\\end{align}\n\nThe total differential cross section will be given by their average: \n%\n\\begin{align}\n\\dv{\\sigma }{\\Omega } = r_0^2 \\frac{1 + \\sin^2 \\Theta }{2} = r_0^2 \\frac{1 + \\cos^2 \\theta }{2}\n\\,,\n\\end{align}\n%\nwhere we define \\(\\theta = \\pi /2 - \\Theta \\), the angle between the propagation direction \\(\\vec{k}\\) and the observation direction \\(\\vec{n}\\). \n\nThe total unpolarized cross section is the same as the one we had for polarized light:\n%\n\\begin{align}\n\\sigma _{\\text{unpol}} = \\int \\dv{\\sigma }{\\Omega } \\dd{\\Omega } \n= \\frac{2 \\pi r_0^2}{2} \\int_{-1}^{1} (1 + \\mu^2) \\dd{\\mu }\n=\\frac{8 \\pi }{3} r_0^2 = \\sigma_{T}\n\\,.\n\\end{align}\n\nSo, for the total cross section of Thomson scattering polarization does not matter, while it does change the differential cross section. \n\n\\subsubsection{The Eddington limit}\n\nThe total momentum flux of the radiation field is given by \n%\n\\begin{align}\nP = \\int_{0}^{\\infty } \\dd{\\nu } \\int_{4 \\pi } \\dd{\\Omega } \\cos^2 \\theta I_\\nu \n\\,.\n\\end{align}\n\nSuppose we have a differential area \\(\\dd{A}\\), and suppose that photons only cross it in the direction of its normal \\(\\vec{n}\\). \nIf this is the case, then we have \n%\n\\begin{align}\nP = \\int_0^{\\infty } \\dd{\\nu } I_\\nu  = \\frac{F}{c}\n\\,,\n\\end{align}\n%\nsince then the angular distribution function is a delta on \\(\\theta = 0 \\) on the unit sphere. \n\nSuppose then we have a particle at the center of the area element \\(\\dd{A}\\), and that we want to calculate the force upon it. It will be the pressure times the cross section: \n%\n\\begin{align}\n\\mathscr{F} = \\frac{F}{c} \\sigma = P \\sigma \n\\,.\n\\end{align}\n\nNow, let us consider a source which emits photons only radially, such as a star with perfect spherical symmetry. \nThe flux at any radius \\(r\\) will be \\(F = L / 4 \\pi r^2\\), where \\(L\\) is the luminosity (power) of the source. \nThe photons will only move radially. \n\nThen, the force onto a test particle will be \n%\n\\begin{align}\n\\mathscr{F} = \\frac{L \\sigma }{c 4 \\pi r^2}\n\\,.\n\\end{align}\n\nThe source will have a mass \\(M\\), and it will attract the particles gravitationally.\n\nNow, a typical composition for the material outside a star is a plasma, made up of dissociated hydrogen: protons and electrons.\nAs we have seen, the cross section of the electrons for Thomson scattering will be much larger than that of the protons, while the gravitational force will be much larger on the protons since they are more massive. \n\nIf we consider a single electron-proton pair which is bound by electrostatic forces (although not in a bound \\emph{state}, since we still have a plasma), then we can calculate the equilibrium point for the forces on the pair. \nWe can then equate the radiative force on the electron to the gravitational force on the proton, since the other two forces are negligible in comparison. This yields: \n%\n\\begin{align}\n\\frac{L \\sigma_{T}}{c 4 \\pi r^2} &= \\frac{G M m_p}{r^2}  \\\\\nL &= \\frac{4 \\pi G M m_p c}{\\sigma_{T}} = L _{\\text{Edd}}\n\\,,\n\\end{align}\n%\nthe \\textbf{Eddington luminosity} corresponding to a mass \\(M\\). \nIn comparison to the Sun, this is roughly \n%\n\\begin{align}\nL _{\\text{Edd}} \\approx \\num{3e5} L_{\\odot} \\frac{M}{M_{\\odot}}\n\\,.\n\\end{align}\n\nThis means that the Sun is well below the Eddington limit. \nThis is not a general limit, since it only applies if we have spherical symmetry; if this is broken the ``limit'' can be violated. \nAlso, we can define analogous limits for different kinds of processes, which will have different cross sections. \n\n\\end{document}\n", "meta": {"hexsha": "44c70e5d315bffd84aafd87e5c0fd8ac25556aa7", "size": 11784, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/radiative_processes/apr01.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/radiative_processes/apr01.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/radiative_processes/apr01.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 43.3235294118, "max_line_length": 320, "alphanum_fraction": 0.7009504413, "num_tokens": 3629, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41315029525336}}
{"text": "% Questions about the Fission Matrix initiated by Prof. Holloway's paper.\n\n\\documentclass[12pt]{article}\n\\usepackage[margin=1in]{geometry}\n\n\\title{Questions Regarding Fission Matrix ideas}\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\n\\begin{enumerate}\n    \\item Why do we need $PGPq = kq$ when we already have $Gq = kq$?  What is the difference?  What about $T$, how does he play into all this?\n     \n    I think the need for this is to map $G$ to the Monte Carlo space from ``reality'' space.  So when Holloway writes $P:Q\\rightarrow T$, this means that we take a particle in ``reality'' space and map it into a ``binned'' Monte Carlo space or some other space that the computer can understand and manipulate.  \\\\[2in]\n\n    \\item Is the $T$ in \n    \\begin{equation}\n        \\left(T\\psi = \\frac{1}{k}F\\psi\\right)\n    \\end{equation}\n    the same as in $P:Q\\rightarrow T$?\n\n\\end{enumerate}\n\\subsection{The fission matrix}\n\\begin{enumerate}\n    \\item What is $\\{p_n\\}$?  How are $p_n$ related to $P$?\n\n    I think $p_n$'s are the basis functions (e.g., histograms, Legendre, etc.).  The expansion coefficients are the $x_n$'s.  Using $x$'s and $p$'s we can write any $q$ as $q = \\sum_n x_np_n$.\\\\[1in]\n\n    \\item What is the difference between $p_n$ and $p_n^{\\dagger}$?  Why do we need a \\emph{biorthonormal} basis instead of a simple orthonormal basis?\n\n    \\item How can I calculate $p_n$, $p_n^{\\dagger}$, and $x_n$?  They all seem to depend on each other.  \n\n    If $p_n$ is one of the expansion functions, then $x_n$ is calculated during the Markov Chain.  If this is the case then we know $p_n$ and $x_n$, but how to we find $p_n^{\\dagger}$?\n\\end{enumerate}\n\n\\section{Working with A}\nNo specific questions here, but I don't fully understand how one might generate the matrix $\\mathbf{A}$ using FET modes. \n\\section{General Questions}\n\\begin{enumerate}\n    \\item Why is this different from a typical Monte Carlo kcode calculation? \\\\[1in]\n\n    \\item Can I really do just a simple dot product of $q$'s?\n\n    If I understand correctly, the elements of $q$ are the expansion coefficients.  When I perform the inner product $\\left\\langle q_n, q_m\\right\\rangle$ is this really just a simple dot product?\n\\end{enumerate}\n\\end{document}\n\n", "meta": {"hexsha": "251ad3768b4dfac1f354ee4650c3c512079afde4", "size": 2241, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "misc/FissionMatrixQuestions.tex", "max_stars_repo_name": "jlconlin/PhDThesis", "max_stars_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "misc/FissionMatrixQuestions.tex", "max_issues_repo_name": "jlconlin/PhDThesis", "max_issues_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "misc/FissionMatrixQuestions.tex", "max_forks_repo_name": "jlconlin/PhDThesis", "max_forks_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6875, "max_line_length": 318, "alphanum_fraction": 0.7041499331, "num_tokens": 661, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41315029525336}}
{"text": "\\subsection{Transactions}\n\n\\subsubsection{Definitions}\n\nIn Bitcoin, there are some transactions.\nIn each transaction, there are multiple inputs and outputs.\nEach input is named TXFieldWithId.\nThe input of one transaction is the output of another transaction.\nFirsts outputs are generated from coinbase transaction (created by the miner).\nEach block has just one of this transaction.\n\n\\agda{Transactions}{VectorOutput}\n\nVector output is the vector of outputs transactions.\nIt is a non-empty vector, because it already starts with one element \\emph{fstStart}\nor it is an union from one transaction with another vector.\nIn its representation, it is possible to know in what time it was created (time is the position of\nthey in all transactions),\nwhat is his size (quantity of outputs fields)\nand the total amount spent in this transaction,\n\n\\emph{elStart} is a proof that the position of TXFieldWithId is the last one,\nbecause its position in the vector is the same as the last position (size) of the vector.\nIt is used after to specify which input is in the transaction.\n\n\\agda{Transactions}{TXSigned}\n\nA signed transaction is composed of a non-empty list of inputs and outputs.\nFor each input, there is a signature that confirms that he accepted every output in the list of outputs.\nAnd in the transaction, there is proof ($in \\geq out$) that the total amount of money\nin all inputs is bigger than the total amount of outputs.\nThe remainder will be used by the miner.\n\n\\subsubsection{Raw Transaction}\n\nRaw transactions are transactions without any explicit dependent type.\nHere the definition of \\emph{raw signed transaction}:\n\n\\agda{RawTransactions}{rawtxsigned}\n\n\\emph{Raw signed transactions} are a record with \\emph{inputs}, \\emph{outputs}\nand the signature of \\emph{inputs} and \\emph{outputs}.\n\nThe definition of some important types:\n\n\\agda{Crypto}{cryptoTypes}\n\nThe definition of \\emph{Raw Input}:\n\n\\agda{RawTransactions}{rawinput}\n\nIn each input, it is necessary to know the time, the position of it in the transaction,\nthe amount spent, its message, the signature, and its public key.\nThe signature is the signature of the message.\nAnd the message is usually related to the amount spent in each output.\n\nThe definition of \\emph{raw transaction}:\n\n\\agda{RawTransactions}{rawTransaction}\n\nIt is all inputs and all outputs.\n\nThe definition of \\emph{Raw TX}:\n\n\\agda{RawTransactions}{rawTX}\n\nThe definition of \\emph{raw transaction coinbase}:\n\n\\agda{RawTransactions}{rawCoinbase}\n\nThe definition of \\emph{raw Vector Output}: \n\n\\agda{RawTransactions}{rawVecOut}\n\nIt has the time, its size, the total amount, the \\emph{vector output}\nand proof that this vector is the same as the list of outputs of this type.\n\nThe definition of the record that every input transaction is signed in a given time:\n\n\\agda{RawTransactions}{txsigall}\n\nIt has the size of vector output, the sublist of all inputs, the total amount,\nthe \\emph{vector output} and a proof that all sublists of inputs are signed.\n\n$rawTXSigned \\to TXSigAll$ returns a signed transaction of all inputs in a given time\nif \\emph{rawTXSigned} has valid signatures for all these inputs:\n\n\\agda{RawTransactions}{rawtxSigToTxsigAll}\n\nIt has to validate first that the \\emph{list of outputs} is a valid \\emph{Vector Output}.\nSecond, it validates if the signature of the inputs are valid with the\n\\emph{raw signed transaction}.\nIn the last case, it validates if the time of the \\emph{vector output} is equal\nof the time of this transaction.\nIf all conditions match, it returns a proven signed transaction.\nIf not, it returns nothing.\n\n\\hyperref[rawToTX]{This function} transforms a \\emph{raw transaction} into a \\emph{signed transaction}:\n\n\\plabel{rawToTX}\n\\agda{RawTransactions}{txrawToTxsig}\n\nThe function $vecOut \\equiv ListAmount$ returns a proof that the \\emph{vector output} is equal\nto the total amount of the \\emph{list of transactions}.\nIt is impossible that the \\emph{vector output} is equal to an empty list.\nIn case that the list has just one element, it just has to return \\emph{refl}.\nThe another case, it is done recursively.\n\nThe proof that the amount of input transaction is greater than the amount of output\nis just a rewrite from the previous proof ($vecOut≡ListAmount outputs vecOut out≡vec$).\n\nThe function \\emph{sameMessage} returns a proof that the message of \\emph{raw transaction}\nis the same as the message of the \\emph{vector output}.\nIn case that \\emph{vector output} has just size one or two, it is a trivial case.\nThe other cases are doing it recursively.\n\n\\emph{sigPub} is another function that returns a proof that an input message is signed.\nIt validates it with its public key.\n\nThe last function returns a proof that every input was signed.\nIt is done in a recursive way using the function \\emph{sigPub}.\n\nThis is the function that transforms a list of transactions into a possible \\emph{vector output}:\n\n\\agda{RawTransactions}{listTXFieldtoVecOut}\n\nThe list has to be at least with a size one.\nBecause the \\emph{vector output} can not be empty.\nTo add one element into the vector, it has to verify if the time is equal to the first time.\nAnother verification is that the informed position in the vector is right.\nIf all validations are right, it returns the vector output.\nIf it is not, it returns nothing.\n\nThe definition of the function that transform a \\emph{raw transaction} into a\n\\emph{raw signed transaction}:\n\n\\agda{RawTransactions}{rawtoTXSigned}\n\nThe first validation that the function does is verifying that the outputs are not empty.\nAnother validation is verifying if the amount spent on inputs is greater than the amount of the outputs.\nThe function \\emph{Signed?}, defined in the crypto library, validates if the\nmessage was signed with the input.\nAfter, it validates if all inputs are signed.\nIf all validations are right, it returns the \\emph{raw transaction signed}.\nIf it is not, it returns nothing.\n", "meta": {"hexsha": "7c430a2f7fa669c1a6c54c21c1181e9f8aaf1761", "size": 5904, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/transactions.tex", "max_stars_repo_name": "guilhermehas/crypto-agda", "max_stars_repo_head_hexsha": "ac91e00abca9a26678d0cbc1bedecf8abef6b703", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-02-13T16:56:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T19:27:12.000Z", "max_issues_repo_path": "docs/transactions.tex", "max_issues_repo_name": "guilhermehas/cripto-agda", "max_issues_repo_head_hexsha": "ac91e00abca9a26678d0cbc1bedecf8abef6b703", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-11-01T11:36:06.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-03T14:31:16.000Z", "max_forks_repo_path": "docs/transactions.tex", "max_forks_repo_name": "guilhermehas/cripto-agda", "max_forks_repo_head_hexsha": "ac91e00abca9a26678d0cbc1bedecf8abef6b703", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.4383561644, "max_line_length": 104, "alphanum_fraction": 0.7860772358, "num_tokens": 1407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.41315029525336}}
{"text": "\\documentclass[12pt, letterpaper]{article}\n\\usepackage{abstract}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{braket}\n\\usepackage[hang,small,bf]{caption}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx}\n\\usepackage[utf8]{inputenc}\n\\usepackage{tikz}\n\\usetikzlibrary{\nbackgrounds,\nshadows.blur,\nfit,\ndecorations.pathreplacing,\nshapes}\n\\usepackage[frame,line,arrow,matrix,tips]{xy}\t% all that is usually necessary\n\n\\renewcommand{\\abstractname}{}    % clear the title\n\\renewcommand{\\absnamepos}{empty} % originally center\n\n% qasm2circ definitions\n\\def\\w{\\ar@{-}[l]}\n\\def\\A#1{\\save []=\"#1\" \\restore}\n\\def\\op#1{*+[F]{\\rule[-0.2ex]{0ex}{2.1ex}#1}}\t% operator in box\n\\def\\b{*={\\bullet}}\n\\def\\o{*={\\oplus}}\n\\def\\m#1{\\left[\\matrix{#1}\\right]}\t\t% matrix shortcut\n\\def\\z{*+[]{\\rule[-0.2ex]{0ex}{2.1ex}~|0\\>}}\t% re-init to |0>\n\\def\\discard{*[]{\\rule[-0.2ex]{0.75pt}{2.1ex}~}}\t% vertical ``|''\n\\def\\n{*-{}\\w}\n\\def\\>{\\rangle}\n\\def\\<{\\langle}\n\\def\\ua{\\uparrow}\n\\def\\q#1{*+{\\rule[-0.2ex]{0ex}{2.1ex}|#1\\>}}\n\\def\\qv#1#2{*+{\\rule[-0.2ex]{0ex}{2.1ex}|#1\\>=|#2\\>}}\n\n\\title{CS 269Q Lecture 4 \\\\ \\large Programming a quantum algorithm with pyQuil\\vspace{-1ex}}\n\\author{Peter Karalekas \\\\ \\small peter@rigetti.com}\n\\date{\\normalsize April 11, 2019\\vspace{-3ex}}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n\\noindent\nWe build out our quantum computing toolbox so that we can implement our very first quantum algorithm. We begin by working through a couple foundational concepts—the wavefunction, classical logic, and quantum parallelism—and then conclude with a walkthrough of the protocol for Deutsch's algorithm. Alongside these notes, there is a Jupyter notebook that uses Rigetti Computing's open-source software development kit, called Forest, to step through the algorithm and inspect the wavefunction.\n\\end{abstract}\n\n\\section{The wavefunction and quantum circuits}\n\nWe represent the state of our qubit using the ``ket\" $\\ket{\\psi}$, which is a superposition of the states $\\ket{0}$ and $\\ket{1}$ that form a\nbasis for a two-dimensional complex vector space ($\\mathbb{C}^2$). We additionally have a normalization condition on our complex amplitudes $\\alpha$ and $\\beta$ such that their magnitudes squared must sum to 1.\n\n\\begin{equation}\n\\ket{\\psi} = \\alpha \\ket{0} + \\beta \\ket{1} \\hspace{1 cm} |\\alpha|^2 + |\\beta|^2 = 1\n\\end{equation}\n\n\\subsection{1Q states}\n\nFor our quantum virtual machine (QVM), each qubit begins in the $|\\psi\\rangle = |0\\rangle$ state. We then apply quantum gates to evolve the state of the QVM, and each gate $U$ must be unitary, meaning that $U^{\\dag}U = I$. We can use an $X$ gate to flip between $|0\\rangle$ and $|1\\rangle$.\n\n\\begin{equation}\nX|0\\rangle = |1\\rangle \\hspace{1 cm} X|1\\rangle = |0\\rangle \\vspace{3 mm}\n\\end{equation}\n\n\\noindent\nIn addition to swapping between the 1Q computational basis states, we can use quantum gates to create superposition states. Here we create the 1Q superposition states $|+\\rangle$ amd $|-\\rangle$ using the $H$ (Hadamard) gate.\\vspace{2 mm}\n\n\\begin{equation}\nH|0\\rangle = \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}} = |+\\rangle \\hspace{1 cm} H|1\\rangle = \\dfrac{|0\\rangle - |1\\rangle}{\\sqrt{2}} = |-\\rangle\n\\end{equation}\n\n\\subsection{2Q states}\n\nFor two-qubit states, we can create ``product states\" of computational basis states, which just look like two-bit bitstrings. Here we create the 2Q computational basis state $|10\\rangle$.\n\n\\begin{equation}\n(X \\otimes I)|00\\rangle = |10\\rangle \\vspace{3 mm}\n\\end{equation}\n\n\\noindent\nWe can also create product states of superposition states. Here we create the 2Q superposition state $|+,+\\rangle$ using two Hadamard gates.\\vspace{2 mm}\n\n\\begin{equation}\n(H \\otimes H)|00\\rangle = \\left( \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}}\\right) \\otimes \\left( \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}}\\right) = |+,+\\rangle \\vspace{4 mm}\n\\end{equation}\n\n\\noindent\nIn addition to product states, we can create entangled states, which we can no longer factor into the tensor product of two individual qubit states. Here we create the Bell state $|\\Phi^+\\rangle$.\n\n\\vspace{2 mm}\n\\begin{equation}\n\\text{CNOT}_{0,1}(I \\otimes H)|00\\rangle = \\text{CNOT}_{0,1}|0\\rangle \\otimes \\left( \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}}\\right) = \\dfrac{|00\\rangle + |11\\rangle}{\\sqrt{2}} = |\\Phi^+\\rangle\n\\end{equation}\n\n\\section{Classical logic and function evaluation}\n\nIn Computer Science, we learn about Boolean logic gates like \\texttt{NOT},\n\\texttt{AND}, \\texttt{OR}, and \\texttt{XOR}. In quantum computing, we can implement these classical logic gates, but we must do so in a way that respects the unitarity requirements of quantum logic gates.\n\n\\subsection{Boolean functions of 1-bit domain}\n\\vspace{2 mm}\n\n\\begin{equation}\nx \\in \\{0,1\\} \\hspace{1cm} f(x) \\rightarrow \\{0,1\\} \\vspace{2 mm}\n\\end{equation}\n\n\\noindent\nOne-bit boolean functions represent the simplest classical logic we can implement on a quantum computer. There are four possible one-bit functions $f(x)$, and we will work through all of them.\n\n\\subsubsection{Balanced functions}\n\\vspace{2 mm}\n$$\\text{Balanced-}I : (0 \\rightarrow 0,  1 \\rightarrow 1)\n\\hspace{1 cm}\n\\text{Balanced-}X : (0 \\rightarrow 1,  1 \\rightarrow 0) \\vspace{2 mm}$$\n\n\\noindent\nFor the balanced 1-bit functions, it’s pretty easy to come up with a quantum circuit that works. If we use just an $I$ gate for Balanced-$I$ and just an $X$ gate for Balanced-$X$, we can produce a quantum circuit $U_f$ that maps $|x\\rangle \\rightarrow |f(x)\\rangle$. Knowing the gate and and output, we can reproduce the input, which means our circuit satisfies our reversibility requirements. Below, we have the quantum circuit for Balanced-$I$ on the left, and Balanced-$X$ on the right.\n\n% the 1-qubit balanced circuits\n\\def\\gAxA{\\op{X}\\w\\A{gAxA}}\n\\def\\bA{ \\q{x}}\n\\begin{equation}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\gAxA &\\n &\\n &\\n &\\n\n}\n\\end{equation}\n\n\\subsubsection{Constant functions}\n\\vspace{2 mm}\n$$\\text{Constant-}0 : (0 \\rightarrow 0,  1 \\rightarrow 0)\n\\hspace{1 cm}\n\\text{Constant-}1 : (0 \\rightarrow 1,  1 \\rightarrow 1) \\vspace{2 mm}$$\n\n\\noindent\nComing up with the circuit for the constant functions seems less trivial. We can write down a matrix $M_f$ that maps the 0 state to the 0 state and the 1 state to the 0 state.\\vspace{1 mm}\n\n\\begin{equation}\nM_f = \\left(\\begin{matrix}\n    1 & 1 \\\\\n    0 & 0\n\\end{matrix}\\right) \\vspace{3 mm}\n\\end{equation}\n\n\\noindent\nHowever, this matrix has some problems. It is not invertible (determinant 0) and it is not length preserving (superposition state changes length), and therefore it is not unitary. We can also see that it is not reversible simply from the truth table—knowing the output and the gate isn’t enough to get back to the input.\\vspace{1 mm}\n\n\\begin{equation}\n\\text{det}(M_f) = \\text{det}\\left(\\begin{matrix}\n    1 & 1 \\\\\n    0 & 0\n\\end{matrix}\\right) = 1\\cdot0 - 1\\cdot0 = 0\n\\end{equation}\n\\vspace{3 mm}\n\\begin{equation}\nM_f|\\psi\\rangle = \\left(\\begin{matrix}\n    1 & 1 \\\\\n    0 & 0\n\\end{matrix}\\right)\n\\left(\\begin{matrix}\n    0.6 \\\\\n    0.8\n\\end{matrix}\\right) =\n\\left(\\begin{matrix}\n    1.4 \\\\\n    0.0\n\\end{matrix}\\right)\n\\end{equation}\n\n\\subsubsection{Ancilla qubits}\n\nIn order to write this function as a quantum circuit, we need to introduce a new concept—the ancilla qubit. An ancilla qubit is an additional qubit used in a computation that we know the initial state of. Using an ancilla, we can produce a quantum circuit $U_f$ that maps $|0, x\\rangle \\rightarrow |f(x), x\\rangle$. Now, we can come up with a unitary matrix (albeit a trivial one) that allows us to evaluate constant functions. For the Constant-$0$, we just simply do nothing to the ancilla, and its state encodes $f(x)$. And for the Constant-$1$, all we have to do is flip the ancilla with an $X$ gate, and we get $f(x)$ for all $x$. Below, we have the Balanced-$I$ (top left), Balanced-$X$ (bottom left), Constant-$0$ (top right), and Constant-$1$ (bottom right) functions implemented as quantum circuits with one ancilla qubit. We will continue to use this ordering for sections 2.3 and 2.4.\n\n\\begin{equation}\n|0, x\\rangle \\rightarrow |f(x), x\\rangle\n\\end{equation}\n\n% ancilla qubit circuits\n\\def\\gAxB{\\op{X}\\w\\A{gAxB}}\n\\def\\gBxA{\\b\\w\\A{gBxA}}\n\\def\\gBxB{\\o\\w\\A{gBxB}}\n\\def\\bA{ \\q{x}}\n\\def\\bB{ \\q{0}}\n$$\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxA &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxB &\\n &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n}$$\n$$\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\gBxA &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\gAxB &\\gBxB &\\n &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\gAxB &\\n &\\n &\\n &\\n\n}$$\n\n\\subsection{The Quantum \\texttt{XOR} gate}\n\nThe Boolean function \\texttt{XOR} (for ``exclusive or\") takes in two bits $x$ and $y$ and returns 1 if and only if the values of the bits are different from one another. Otherwise, it returns 0. The operation is written as $x \\oplus y$, and although it is a two-bit function, we can implement it as a quantum circuit without an ancilla, by simply using the \\textrm{CNOT} gate.\n\n\\begin{equation}\n\\textrm{CNOT}_{0,1}|y, x\\rangle = |y \\oplus x, x\\rangle\n\\end{equation}\n\n% xor circuit\n\\def\\gAxA{\\b\\w\\A{gAxA}}\n\\def\\gAxB{\\o\\w\\A{gAxB}}\n\\def\\bA{ \\q{x}}\n\\def\\bB{ \\q{0}}\n$$\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\gAxA &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\gAxB &\\n &\\n &\\n\n\\ar@{-}\"gAxB\";\"gAxA\"\n}$$\n\n\\subsection{Deutsch Oracle}\n\nIn Deutsch's algorithm, we are given something called an oracle (referred to as $U_f$), which maps $|y, x\\rangle \\rightarrow |y \\oplus f(x), x\\rangle$, and the goal is to determine a global property of the function $f(x)$ with as few queries to the oracle as possible. We can combine the two concepts above (one-bit function evaluation with ancillas, and the \\texttt{XOR} gate), to produce the four implementations of the Deutsch Oracle with one ancilla qubit.\n\n\\begin{equation}\nU_f : |y, 0, x\\rangle \\rightarrow |y \\oplus f(x), 0, x\\rangle\n\\end{equation}\n\n% deutsch oracle circuit\n\\def\\gAxB{\\op{X}\\w\\A{gAxB}}\n\\def\\gBxA{\\b\\w\\A{gBxA}}\n\\def\\gBxB{\\o\\w\\A{gBxB}}\n\\def\\gCxB{\\b\\w\\A{gCxB}}\n\\def\\gCxC{\\o\\w\\A{gCxC}}\n\\def\\gDxA{\\b\\w\\A{gDxA}}\n\\def\\gDxB{\\o\\w\\A{gDxB}}\n\\def\\gExB{\\op{X}\\w\\A{gExB}}\n\\def\\bA{ \\q{x}}\n\\def\\bB{ \\q{0}}\n\\def\\bC{ \\q{y}}\n$$\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxA &\\n &\\gDxA &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxB &\\gCxB &\\gDxB &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bC &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\gCxC &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n\\ar@{-}\"gCxC\";\"gCxB\"\n\\ar@{-}\"gDxB\";\"gDxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n & \\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\gCxB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bC &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\gCxC &\\n &\\n &\\n &\\n &\\n &\\n & \\n &\\n &\\n &\\n\n\\ar@{-}\"gCxC\";\"gCxB\"\n}$$\n$$\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\gBxA &\\n &\\gDxA &\\n &\\n\n\\\\  \\bB &\\gAxB &\\gBxB &\\gCxB &\\gDxB &\\gExB &\\n\n\\\\  \\bC &\\n &\\n &\\gCxC &\\n &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n\\ar@{-}\"gCxC\";\"gCxB\"\n\\ar@{-}\"gDxB\";\"gDxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\gAxB &\\n &\\n &\\n &\\gCxB &\\n &\\n &\\n &\\gAxB &\\n\n\\\\  \\bC &\\n &\\n &\\n &\\n &\\gCxC &\\n &\\n &\\n &\\n &\\n\n\\ar@{-}\"gCxC\";\"gCxB\"\n}$$\n\n\\subsection{Optimized Deutsch Oracle}\n\nFor pedagogical reasons, it is nice to separate out the three steps in the Deutsch Oracle—evaluate $f(x)$, calculate $y \\oplus f(x)$, and then return the ancilla to $|0\\rangle$. But, in practice we always want to implement our circuits in as few gates as possible (this is especially important when running on a real, noisy quantum computer!). Below, we show how we can rewrite each of the four Deutsch Oracle implementations (which we call $U_f$) without the need for an ancilla qubit.\n\n\\vspace{20 mm}\n\\begin{equation}\nU_f : |y, x\\rangle \\rightarrow |y \\oplus f(x), x\\rangle\n\\end{equation}\n\n% optimized deutsch oracle circuits\n\\def\\gAxA{\\op{X}\\w\\A{gAxA}}\n\\def\\gBxA{\\b\\w\\A{gBxA}}\n\\def\\gBxB{\\o\\w\\A{gBxB}}\n\\def\\gCxA{\\op{X}\\w\\A{gCxA}}\n\\def\\bA{ \\q{x}}\n\\def\\bB{ \\q{y}}\n$$\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\gBxB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n}$$\n$$\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\gAxA &\\gBxA &\\gCxA &\\n\n\\\\  \\bB &\\n &\\gBxB &\\n &\\n\n\\ar@{-}\"gBxB\";\"gBxA\"\n}\\hspace{1 cm}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\n &\\n &\\n &\\gAxA &\\n &\\n &\\n &\\n &\\n &\\n\n}$$\n\n\\section{Quantum parallelism}\n\nIn the previous section, we showed that we could implement classical logic using quantum circuits. However, when using a computational basis state ($|0\\rangle$ or $|1\\rangle$), we don't do anything more interesting than a classical computer can do. If we instead feed a superposition state into one of these circuits, we can effectively evaluate a function $f(x)$ on multiple values of $x$ at once!\n\n\\begin{equation}\nU_f : |0,+\\rangle \\rightarrow \\dfrac{|f(0), 0\\rangle + |f(1), 1\\rangle}{\\sqrt{2}}\n\\end{equation}\n\\vspace{1 mm}\n\n\\begin{equation}\nU_f : |0,-\\rangle \\rightarrow \\dfrac{|f(0), 0\\rangle - |f(1), 1\\rangle}{\\sqrt{2}}\n\\end{equation}\n\\vspace{1 mm}\n\n\\noindent\nIt is important to note, that although this quantum parallelism concept is interesting, we are unable to learn about both $f(0)$ and $f(1)$ when the states above are in that form. This is due to the fact that we can only extract one classical bit of information from a quantum computer (of 1 qubit) when we measure it. But, as we will find in Deutsch's algorithm below, we can cleverly take advantage of quantum parallelism to do things that a classical computer cannot, even with the constraint that measurement yields only one classical bit.\n\n\\subsection{Test with Balanced-$I$}\n\nTo verify, we run the Balanced-$I$ circuit for an input that is in a superposition state.\n\n\\vspace{2 mm}\n\\begin{equation}\n\\text{CNOT}_{0,1}|0,+\\rangle = \\dfrac{\\text{CNOT}_{0,1}|00\\rangle + \\text{CNOT}_{0,1}|01\\rangle}{\\sqrt{2}} = \\dfrac{|00\\rangle + |11\\rangle}{\\sqrt{2}} = |\\Phi^+\\rangle\n\\end{equation}\n\\vspace{1 mm}\n\n\\begin{equation}\n\\text{CNOT}_{0,1}|0,-\\rangle = \\dfrac{\\text{CNOT}_{0,1}|00\\rangle - \\text{CNOT}_{0,1}|01\\rangle}{\\sqrt{2}} = \\dfrac{|00\\rangle - |11\\rangle}{\\sqrt{2}} = |\\Phi^-\\rangle\n\\end{equation}\n\\vspace{2 mm}\n\n\\noindent\nIn both of our output states, we can see that if we take the state of qubit 0 in each ket to be $x$, the state of qubit 1 in the corresponding ket is equal to $f(x)$ (as $f(x) = x$ for Balanced-$I$).\n\n\\section{Deutsch's algorithm}\n\n\\noindent\n\\textbf{Goal}: Determine if function $f(x)$ is \\textit{constant} ($f(0) = f(1)$) or \\textit{balanced} ($f(0) \\neq f(1)$).\n\n\\vspace{1 mm}\n{\n% utulity text box for figuring out width of things\n\\newbox{\\sbox}\n% empty space of width determined by the text argument\n\\def\\gspace#1{*+{\\rule[-0.2ex]{0ex}{2.1ex}%\n\t\\setbox\\sbox=\\hbox{$#1$}%\n\t\\hspace*{\\wd\\sbox}\n\t\\hspace*{\\wd\\sbox}\n\t\\hspace*{\\wd\\sbox}}}\n% n-qubit operation #1=box label, #2=number of qubits (eg d=2 qubits, ddd=4)\n\\def\\gnqubit#1#2{\\gspace{#1}\n\t\t \\save [].[#2]!C=\"qq\"*[F]\\frm{}\\restore\n\t\t \\save \"qq\"*[]{#1} \\restore}\n\n% deutsch's algorithm circuit\n\\def\\gAxA{\\op{H}\\w\\A{gAxA}}\n\\def\\gAxB{\\op{H}\\w\\A{gAxB}}\n\\def\\gBxA{\\gnqubit{U_{f}}{d}\\w\\A{gBxA}}\n\\def\\gBxB{\\gspace{U_{f}}\\w\\A{gBxB}}\n\\def\\gCxA{\\op{H}\\w\\A{gCxA}}\n\\def\\gCxB{\\op{H}\\w\\A{gCxB}}\n\\def\\bA{ \\q{0}}\n\\def\\bB{ \\q{1}}\n\\begin{equation}\n\\begin{split}\n\\xymatrix@R=5pt@C=10pt{\n    \\bA &\\n &\\n &\\gAxA &\\n &\\n &\\gBxA &\\n &\\n &\\gCxA &\\n &\\n &\\n\n\\\\  \\bB &\\n &\\n &\\gAxB &\\n &\\n &\\gBxB &\\n &\\n &\\gCxB &\\n &\\n &\\n\n}\n\\end{split}\n\\end{equation}\n}\n\n\\vspace{2 mm}\n\n\\noindent\nAs part of the algorithm, we are given a Deutsch Oracle and are unaware of which one-bit Boolean function $f(x)$ it implements. We show that we can do this with only one query to the Deutsch Oracle, which is impossible on a classical computer, which would require two queries to the Deutsch Oracle to determine this global property of $f(x)$.\n\n\\subsection{Initial state}\n\nWe begin our algorithm in the computational basis state $|10\\rangle$. The fact that the states for qubit 0 and qubit 1 are different proves to be important.\n\n\\begin{equation}\n|\\psi_0\\rangle = |10\\rangle\n\\end{equation}\n\n\\subsection{Prepare superpositions}\n\nWe cannot do anything interesting with computational basis states, so to take advantage of quantum parallelism we put our qubits in superposition states.\\vspace{1 mm}\n\n\\begin{equation}\n|\\psi_1\\rangle = (H \\otimes H)|\\psi_0\\rangle = (H \\otimes H)|10\\rangle = \\left( \\dfrac{|0\\rangle - |1\\rangle}{\\sqrt{2}}\\right) \\otimes \\left( \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}}\\right) = |-,+\\rangle \\vspace{1 mm}\n\\end{equation}\n\n\\subsection{Apply the Deutsch Oracle}\n\nWe learned earlier that the action of the Deutsch Oracle on input state $|y,x\\rangle$ is $U_f|y, x\\rangle \\rightarrow |y \\oplus f(x), x\\rangle$. So, what happens if we apply the Deutsch Oracle to the input state $|-,x\\rangle$?\n\n\\begin{equation}\n\\begin{split}\nU_f|-, x\\rangle\n&= \\dfrac{U_f|0, x\\rangle - U_f|1, x\\rangle}{\\sqrt{2}} \\\\\n\\vspace{1 mm}\\\\\n&= \\dfrac{|0 \\oplus f(x), x\\rangle - |1 \\oplus f(x), x\\rangle}{\\sqrt{2}} \\\\\n\\vspace{1 mm}\\\\\n&= \\begin{cases}\n    \\dfrac{|0, x\\rangle - |1, x\\rangle}{\\sqrt{2}}  = (+1)|-,x\\rangle \\text{ \\hspace{5 mm} if } f(x) = 0;\\\\\n    \\vspace{1 mm}\\\\\n    \\dfrac{|1, x\\rangle - |0, x\\rangle}{\\sqrt{2}}  = (-1)|-,x\\rangle \\text{ \\hspace{5 mm} if } f(x) = 1.\n\\end{cases}\n\\end{split}\n\\end{equation}\n\\vspace{1 mm}\n\n\\noindent\nThese two branches can be unified, as we see in the following equation.\n\n\\begin{equation}\nU_f|-, x\\rangle = (-1)^{f(x)}|-, x\\rangle\n\\vspace{3 mm}\n\\end{equation}\n\n\\noindent\nThus, we get a negative sign if $f(x) = 1$, and the state is unchanged if $f(x) = 0$. However, something interesting happens when we apply $U_f$ to the state $|-,+\\rangle$, which is $|\\psi_1\\rangle$.\n\n\\begin{equation}\n\\begin{split}\n|\\psi_2\\rangle = U_f|\\psi_1\\rangle\n&= U_f|-, +\\rangle \\\\\n\\vspace{1 mm}\\\\\n&= \\dfrac{U_f|-, 0\\rangle + U_f|-, 1\\rangle}{\\sqrt{2}} \\\\\n\\vspace{1 mm}\\\\\n&= \\dfrac{(-1)^{f(0)}|-, 0\\rangle + (-1)^{f(1)}|-, 1\\rangle}{\\sqrt{2}} \\\\\n\\vspace{1 mm}\\\\\n&= |-\\rangle \\otimes \\left( \\dfrac{(-1)^{f(0)}|0\\rangle + (-1)^{f(1)}|1\\rangle}{\\sqrt{2}}\\right) \\\\\n\\vspace{1 mm}\\\\\n&= \\begin{cases}\n   \\pm |-\\rangle \\otimes \\left( \\dfrac{|0\\rangle + |1\\rangle}{\\sqrt{2}}\\right) = \\pm |-,+\\rangle \\text{ \\hspace{5 mm} if constant;} \\\\\n   \\vspace{1 mm}\\\\\n   \\pm |-\\rangle \\otimes \\left( \\dfrac{|0\\rangle - |1\\rangle}{\\sqrt{2}}\\right) = \\pm |-,-\\rangle \\text{ \\hspace{5 mm} if balanced.}\n\\end{cases}\n\\end{split}\n\\end{equation}\n\\vspace{1 mm}\n\n\\noindent\nIf $f(x)$ is balanced, this has the effect of changing the relative phase between the $|0\\rangle$ and $|1\\rangle$ components of qubit 0's state, which flips it from $|+\\rangle$ to $|-\\rangle$. This is interesting, because the action of our oracle on the computational basis state $|y,x\\rangle$ is to change the state of qubit 1 and leave qubit 0 alone. But, when our qubits are in superposition states, the balanced oracle actually changes the state of qubit 0 (which is the control qubit in the oracle), and leaves alone the state of qubit 1 (which is the target qubit in the oracle).\n\n\\subsection{Return to 2Q computational basis states}\n\nWe know that the outcome of the previous step is to produce one of two superposition product states, $|-, +\\rangle$ or $|-, -\\rangle$. However, our goal is to query the Deutsch Oracle as few times as possible, and so although we can see that these states are different, we cannot distinguish them with a single measurement (as we only get a 0 or a 1). Therefore, we use the Hadamard gate to return to 2Q computational basis states that can be distinguished in one measurement.\n\n\\begin{equation}\n|\\psi_3\\rangle = (H \\otimes H)|\\psi_2\\rangle =\n\\begin{cases}\n   \\pm (H \\otimes H)|-, +\\rangle = \\pm |10\\rangle \\text{ \\hspace{5 mm} if constant;}\\\\\n   \\\\\n   \\pm (H \\otimes H)|-, -\\rangle = \\pm |11\\rangle \\text{ \\hspace{5 mm} if balanced.}\n\\end{cases}\n\\end{equation}\n\\vspace{1 mm}\n\n\\noindent\nThus, we are in two distinct 2Q computational basis states, dependent on the nature of $f(x)$. We could then measure the state of qubit 0 one time, and we would immediately know the answer to whether $f(x)$ is constant or balanced.\n\n\\subsection{Conclusions}\n\nSo, we were able to learn about a \\textit{global property} of the function $f(x)$ in just one query to the Deutsch Oracle, which is impossible on a classical computer. Although the problem statement for Deutsch's algorithm is a bit contrived, if you can suspend your judgment, you can imagine that we could take some of the non-classical concepts of this algorithm and apply them to a more complex scenario to actually produce an interesting quantum speedup. And, later in the course, you will do exactly this!\n\n\\end{document}\n", "meta": {"hexsha": "9771b076aa65808ceb822fbe2a3ccb20258ee4e6", "size": 21405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture4.tex", "max_stars_repo_name": "chrisyeh96/stanford-cs269q", "max_stars_repo_head_hexsha": "0919afdb5800f9fd4875b102133b02e3efe0eee7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-08-16T06:02:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T21:47:55.000Z", "max_issues_repo_path": "Lecture4.tex", "max_issues_repo_name": "chrisyeh96/stanford-cs269q", "max_issues_repo_head_hexsha": "0919afdb5800f9fd4875b102133b02e3efe0eee7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-04-15T06:17:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-16T06:51:33.000Z", "max_forks_repo_path": "Lecture4.tex", "max_forks_repo_name": "chrisyeh96/stanford-cs269q", "max_forks_repo_head_hexsha": "0919afdb5800f9fd4875b102133b02e3efe0eee7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-04-18T05:42:59.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-07T21:33:25.000Z", "avg_line_length": 44.3167701863, "max_line_length": 894, "alphanum_fraction": 0.6623686055, "num_tokens": 8098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331606115021, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4131146396050233}}
{"text": "\\documentclass[../main.tex]{subfiles}\n\n\\begin{document}\n\\section{Bipolar Transistors}\n\n\\ex{2.1}\n\tWe assume a forward voltage for the LED of 1.5\\V. Then for $I_{LED}$ we have\n\t\\[I_{LED} = \\frac{V_R}{R} = \\frac{3.3\\V - 1.5\\V}{330\\Ohm} \\approx \\sol{5.5\\m\\A}\\]\n\tTo estimate the $\\beta_{min}$ we need the current entering the base\n\t\\[I_B = \\frac{3.3\\V - 0.6\\V}{10\\k\\Ohm} = 0.27\\m\\A \\]\n\tThus\n\t\\[\\beta_{min} \\geq \\frac{I_{LED}}{I_B} = \\sol{20}\\]\n\t\n\\ex{2.2}\n\t\n\t\\tans{NOTE: According to the errata $0.63$ should be replaced by $0.76$ and $63\\u\\sec$ by $76\\u\\sec$.}\n\t\\\\\\\\\n\tStarting from the hint that the capacitor charges from $-4.4\\V$ towards $+5\\V$, we would result to a total $9.4\\V$ for a full charge. However, the $V_{BE}$ of $Q_2$ is clipping the charging process at only $5\\V$ of the total (from $-4.4\\V$ to $0.6\\V$). Thus, the capacitor will be $53\\%$ charged at the end. \\\\Solving the voltage equation for a charging capacitor gives us\n\t\\[V_C(t) = V_f * (1 - e^{-\\frac{t}{R C}})\\]\n\tset $V_C(t_1) = 0.53 * V_f$\n\t\\[0.53 = 1 - e^{-\\frac{t_1}{R_3 C_1}}\\]\n\t\\[\\Rightarrow\\]\n\t\\[t_1 = - R_3 C_1*ln(0.47) \\approx \\sol{0.76 * R_3 C_1}\\]\n\t\n\\ex{2.3}\n\t\n\tThe output voltage is reduced due to the $R_4 - R_5$ voltage divider\n\t\\[V_\\out = \\frac{R_5}{R_4 + R_5} * (V_{CC} - 0.6\\V) \\approx \\sol{4.18\\V}\\]\n\tTo estimate the minimum $\\beta_3$, we need first to find the maximum (worst-case) collector current for which $Q_3$ should still be in saturation. For this we can assume a $0\\V$ drop across C and $Q_3$ while the current travels through the parallel connected resistors $R_2||R_3$.\n\t\\[I_{C_3,max} = \\frac{V_{CC}}{R_2||R_3} = 5.5\\m\\A\\]\n\t\\[\\Rightarrow \\beta_{3,min} = \\frac{I_{C_3,max}}{I_{B_3}} = \\frac{5.5\\m\\A}{\\frac{(4.18\\V - 0.6\\V)} {20\\k\\Ohm}} \\approx \\sol{31}\\]\n\t\n\\ex{2.4}\n\t\n\tBy using KCL and the fact that the transistor is in the active region we get\n\t\\[i_E = i_C + i_B = (\\beta + 1) * i_B = (\\beta + 1) \\frac{v_B}{Z_{source}}\\]\n\tFor small signals $Z_\\out = \\frac{v_E}{i_E} = \\frac{v_B}{i_E}$. Thus:\n\t\\[ \\sol{Z_\\out = \\frac{v_B}{(\\beta + 1)\\frac{v_B}{Z_{source}}} = \\frac{Z_{source}}{\\beta +1}}\\qquad q.e.d.\\]\n\tNote: In practice one will often see $Z_\\out \\approx \\frac{Z_{source}}{\\beta}$. When $\\beta \\approx 100$ the \"$+ 1$\" part is often being ignored to simplify calculations.\n\n\\ex{2.5}\n\t\n\t\\begin{schematic}{fig:2.5.1}{Follower driven by voltage divider}\n\t\t(0,-1) node[ground](GND1){}\n\t\t(GND1) to[R=$R_2$] (0,2)\n\t\tto[R=$R_1$] (0,4)\n\t\t(0,4) node[vcc] {$+15\\V$}\n\t\t\n\t\t(3,2) node[npn] (Q1) {Q}\n\t\t(0,2) to[short] (Q1.B)\n\t\t(3,2) node[npn] (Q1) {Q}\n\t\t(3,4) node[vcc] {$+15\\V$}\n\t\t(3,4) to[short] (Q1.C)\n\t\t(3,-1) node[ground](GND2){}\n\t\t(Q1.E) to[R=$R_E$] (GND2)\n\t\t(Q1.E) to[short, -o] ++(2,0) node[right]{$+5\\V$}\n\t\t(Q1.B) node[above]{$5.6\\V$}\n\t\\end{schematic}\n\t\n\tWe can simplify the voltage divider with it equivalent Th\\'evenin voltage source depicted in Figure~\\ref{fig:2.5.2} below.\n\t\n\t\\begin{schematic}{fig:2.5.2}{Follower driven by equivalent Th\\'evenin source}\n\t\t(0,-1) node[ground](GND1){}\n\t\t(GND1) to[V, l=$V_\\Th$, a={$+5.6\\V$}, invert] (0,2) \n       \n\t\t(3,2) node[npn] (Q1) {Q}\n\t\t(0,2) to[R=$R_\\Th$] (Q1.B)\n\t\t(3,4) node[vcc] {$+15\\V$}\n\t\t(3,4) to[short] (Q1.C)\n\t\t(3,-1) node[ground](GND2){}\n\t\t(Q1.E) to[R=$R_E$] (GND2)\n\t\t(Q1.E) to[short, -o] ++(2,0) node[right]{$+5\\V$}\n\t\\end{schematic}\n\t\n\tWith $R_\\Th = R_1||R_2$ which is also our $R_{source}$. The output impedance of our circuit then is  \n\t\\[R_\\out=\\frac{R_\\Th}{\\beta + 1} \\approx \\frac{R_\\Th}{100} = \\frac{R_1||R_2}{100}\\qquad(\\text{assuming}~\\beta \\approx 100)\\]\n\t \n\tWe also know that the following condition needs to be true in order to achieve the wished $5.6\\V$ at the base: \n\t\\[\\frac{R_2}{R_1 + R_2} = \\frac{5.6\\V}{15\\V} \\Rightarrow R_2 \\approx 0.6 * R_1\\]\n\t\n\tNow let's observe the equivalent circuit \\emph{with} load.\n\t\n\t\\begin{schematic}{fig:2.5.3}{Equivalent voltage source of emitter follower with load}\n\t\t(3,-2) node[ground](GND1){}\n\t\t(0,0) node[left]{$+5\\V$}\n\t\tto[R=$R_\\out$, o-] (3,0)\n\t\tto[short, -o] (4,0) node[right]{$V\\out$}\n\t\t(3,0) to[R=$R_L$] (GND1)\n\t\\end{schematic}\n\t\n\tOur goal is to have a maximum voltage drop of 5\\% with maximum load:\n\t\n\t\\[V_\\out = \\frac{R_L}{R_\\out + R_L} * 5\\V \\geq 0.95 * 5\\V\\]\n\t$\\Rightarrow$\n\t\\[R_\\out \\leq \\frac{R_L}{19} \\leq \\frac{\\frac{4.75\\V}{25\\m\\A}}{19} = 10\\Ohm\\]\n\t$\\Rightarrow$\n\t\\[\\frac{R_\\Th}{100} \\leq 10\\Ohm\\]\n\t$\\Rightarrow$\n\t\\[\\frac{R_1||R_2}{100} \\leq 10\\Ohm\\]\n\t$\\Rightarrow$\n\t\\[R_1 \\leq 2.7\\k\\Ohm~\\text{and}~R_2 \\leq 1.62\\k\\Ohm\\]\n\t\n\tWe choose the following values for $R_1$ and $R_2$:\n\t\\[\\sol{R_1 = 2.7\\k\\Ohm}~\\text{and}~\\sol{R_2 = 1.6\\k\\Ohm}\\]\n\t\n\tNOTE 1: We could have picked more conservative (smaller) values for the resistors. However, this would increase the idle power consumption.\\\\\\\\\n\tNOTE 2: We could also define a value for $R_E$ i.e. to limit the quiescent current, but this is out of the scope of this exercise. Basically we see now $R_E$ as our load or put differently, our total load is $R_E||Z_{whatever-the-user-wants}$.\n\t\n\\end{document}\n", "meta": {"hexsha": "93d5db46701268312ce75f744923e1be67047248", "size": 4960, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/2_Bipolar_Transistors.tex", "max_stars_repo_name": "stelioskat/the-art-of-electronics-3-solutions", "max_stars_repo_head_hexsha": "1c86d43f05dfb612cb928671d89e4c8b1f845423", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-12-14T13:52:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-08T04:35:11.000Z", "max_issues_repo_path": "chapters/2_Bipolar_Transistors.tex", "max_issues_repo_name": "stelioskat/the-art-of-electronics-3-solutions", "max_issues_repo_head_hexsha": "1c86d43f05dfb612cb928671d89e4c8b1f845423", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-12-14T20:13:42.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-15T20:00:01.000Z", "max_forks_repo_path": "chapters/2_Bipolar_Transistors.tex", "max_forks_repo_name": "stelioskat/the-art-of-electronics-3-solutions", "max_forks_repo_head_hexsha": "1c86d43f05dfb612cb928671d89e4c8b1f845423", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.0909090909, "max_line_length": 373, "alphanum_fraction": 0.6223790323, "num_tokens": 2121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4131146372360204}}
{"text": "% Prelim, Appendix C\n% by Rachel Slaybaugh\n\n\\chapter{Reflecting Boundaries}\n\\label{sec:AppendixC}\n\nAlgorithm \\ref{algo:RQI+MGkrylov} in Chapter~\\ref{sec:Chp3} works for problems with vacuum boundary conditions. However, with reflecting boundary conditions some modifications must be made to the calculation of the Rayleigh quotient. To compute the correct RQ the reflected boundary terms must be excluded when computing the dot products, but their contribution to the real moments must be included properly. It was not possible to do this using the solvers in Denovo when this work was begun. How Denovo handles reflecting boundary conditions and what was done to fix this problem are detailed here. The information in this section is derived from conversations with Tom Evans \\cite{Evans2011a} and a paper by Warsa et.\\ al.\\ \\cite{Warsa2004}.\n\nDenovo stores the boundary condition information between the flux moments in the solution vector. For the following discussion let the moments for group $g$ be held in $\\phi_{g}$, which is of length $f_{g} = t \\times c \\times u$ (these sizes are defined in Chapter \\ref{sec:Chp1}). Let the reflected angular flux for that group be $\\psi_{r,g}$, which is of length $m = n \\times c_{r} \\times u$ where $c_{r}$ is the number of cells on the reflecting boundaries. For each group the solution vector and associated source are of length $f_{g} + m$ and look like\n%\n\\begin{alignat}{2}\n \\Phi_{g} = \\begin{pmatrix} \\phi_{g} & \\psi_{r,g} \\end{pmatrix}^{T} \\:, \\qquad Q = \\begin{pmatrix} q & 0 \\end{pmatrix}^{T} \\:.\n\\label{eq:reflFlux}\n\\end{alignat}\n%\nTo exclude the boundary terms when computing the dot products in the RQ, $\\Phi_{g}$ is simply truncated to only include $\\phi_{g}$. \n\nUnderstanding the next issue is aided by considering what the operator form of the transport equation for one group looks like with reflecting boundary conditions. First recall the transport equation for group $g$ that \\emph{does not} include reflecting boundaries, where group indices are excluded for notational brevity:\n%\n\\begin{align}\n  \\mathbf{L} \\psi &= \\mathbf{MS}\\phi + q\n  \\label{eq:transport} \\\\\n  \\bigl(\\ve{I} - \\ve{DL}^{-1}\\ve{MS} \\bigr) \\phi &= \\ve{DL}^{-1}q \\:.\n  \\label{eq:transportMoments}\n\\end{align}\n\nTo include reflecting boundaries, the operators are expanded in the appropriate dimensions from $f_{g}$ to $f_{g} + m$ to act on $\\Phi$. The reflecting operators will be denoted by a tilde. The transport operator is split into volume (traditional) and reflected components: $\\tilde{\\ve{L}} = \\ve{L}_{v} + \\ve{L}_{r}$. The other terms become:\n%\n\\begin{alignat}{4}\n  \\ve{\\tilde{I}} = \\begin{pmatrix} \\ve{I} & 0 \\\\ 0 & \\ve{I}_{r} \\end{pmatrix} \\:, \\nonumber\n \\qquad\n \\ve{\\tilde{D}} = \\begin{pmatrix} \\ve{D} & 0 \\\\ 0 & \\ve{I}_{r} \\end{pmatrix} \\:, \\nonumber\n \\qquad\n \\ve{\\tilde{M}} = \\begin{pmatrix} \\ve{M} & 0 \\\\ 0 & \\ve{I}_{r} \\end{pmatrix} \\:, \\nonumber\n \\qquad\n \\ve{\\tilde{S}} = \\begin{pmatrix} \\ve{S} & 0 \\\\ 0 & \\ve{I}_{r} \\end{pmatrix} \\:. \\nonumber\n\\end{alignat}\n%\nThe operators in Equation \\eqref{eq:transportMoments} can now be replaced by the reflecting operators, and then doing a transport solve will converge both the moments and reflected terms at once. \n\nWhen computing the Rayleigh quotient, however, the operator is applied but a full solve is not done. With Denovo's standard implementation this does not converge $\\psi_{r}$ and therefore those terms do not contribute to the solution properly. \n\nTo address this the reflecting boundaries must be converged first by solving each group separately while excluding within-group scattering. Explicitly multiplying the reflecting matrices illustrates what is happening here. The inverse of the reflecting transport operator is\n%\n\\begin{alignat}{3}\n \\ve{\\tilde{L}}^{-1} = \\begin{pmatrix} \\ve{I} \\\\ \\ve{P}^{T} \\end{pmatrix}\n \\begin{pmatrix} \\ve{L}_{v}^{-1} & -\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\end{pmatrix}\n =\n \\begin{pmatrix} \\ve{L}_{v}^{-1} & -\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\\\\n                   \\ve{P}^{T}\\ve{L}_{v}^{-1} & -\\ \\ve{P}^{T}\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\end{pmatrix}  \\:,\n\\label{eq:reflInverse}\n\\end{alignat} \n%\nwhere $\\ve{P}$ is a projection operator that projects $\\psi_{r} \\to \\psi$. The multiplication makes the system:\n%\n\\begin{equation}\n  \\Bigg[ \\begin{pmatrix} \\ve{I} & 0 \\\\ 0 & \\ve{I}_{r} \\end{pmatrix} - \n  \\begin{pmatrix} \\ve{DL}_{v}^{-1}\\ve{MS} & -\\ve{DL}_{v}^{-1}\\ve{L}_{r}\\ve{P} \\\\\n                      \\ve{P}^{T}\\ve{L}_{v}^{-1}\\ve{MS} & - \\ve{P}^{T}\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\end{pmatrix} \\Bigg]\n  \\begin{pmatrix} \\phi \\\\ \\psi_{r} \\end{pmatrix}\n  =\n  \\begin{pmatrix} \\ve{DL}_{v}^{-1} & -\\ve{DL}_{v}^{-1}\\ve{L}_{r}\\ve{P} \\\\\n                     \\ve{P}^{T}\\ve{L}_{v}^{-1} & - \\ve{P}^{T}\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\end{pmatrix}\n  \\begin{pmatrix} q \\\\ 0 \\end{pmatrix} \\:.\n\\label{eq:explicitBlocks}\n\\end{equation}\n% \n\nNow there are two equations with two unknowns that can be examined for similarities.\n\\begin{align}\n  \\phi - \\ve{DL}_{v}^{-1}\\ve{MS}\\phi + \\ve{DL}_{v}^{-1}\\ve{L}_{r}\\ve{P} \\psi_{r} &= \\ve{DL}_{v}^{-1} q \n\\label{eq:momentTE} \\\\\n  \\psi_{r} - \\ve{P}^{T}\\ve{L}_{v}^{-1}\\ve{MS} \\phi + \\ve{P}^{T}\\ve{L}_{v}^{-1} \\ve{L}_{r} \\ve{P} \\psi_{r} &= 0 \n\\label{eq:reflTE}\n\\end{align}\nComparing the reflecting case to the standard case, $\\ve{P}^{T}$ replaces $\\ve{D}$ and $-\\ve{L}_{r}\\ve{P}$ acts like $\\ve{MS}$. Equation \\eqref{eq:reflTE} can be rearranged and solved for $\\psi_{r}$. In Denovo this amounts to solving each group separately to converge the reflecting flux where the group source is $\\ve{P}^{T}\\ve{L}_{v}^{-1}\\ve{MS} \\phi$. The reflecting boundaries will then contribute properly when solving Equation \\eqref{eq:momentTE} where the effective source becomes $q - \\ve{DL}_{v}^{-1}\\ve{L}_{r}\\ve{P} \\psi_{r}$.  \n\nIn practice, the process to apply $\\ve{A}$ in Denovo when calculating the Rayleigh quotient is:\n%\n\\begin{alignat}{2}\n  \\ve{\\tilde{L}} z = v \\:, \\qquad y = \\ve{\\tilde{D}}z \\:.\n\\label{eq:calcRQ}\n\\end{alignat}\n%\nNow Equation \\eqref{eq:calcRQ} looks just like Equation \\eqref{eq:transport} where the within-group scattering source is set to zero ($\\ve{S} = 0$) and $v = q$. \n\nAn alternative way to express the same idea using the traditional operators with the $\\ve{L}_{v}$ and $\\ve{L}_{r}$ terms can be informative as well. This is presented in source iteration notation, where the reflecting boundaries are lagged. This is exactly the same idea as above, though iteration indices were excluded.\n\\begin{align}\n  \\psi^{l+1} &= \\ve{L}_{v}^{-1} \\bigl( \\ve{MS} \\phi^{l} - \\ve{L}_{r} \\ve{P} \\psi_{r}^{l} \\bigr) + \\ve{D}q \n\\label{eq:laggedSI} \\\\\n  \\phi^{l+1} &= \\ve{D}\\psi^{l+1} \\:.\n\\end{align}\n\nA new solver was written that solves each group separately to converge the reflecting boundaries. This solver is used to compute the Rayleigh quotient when there are reflecting boundaries. This has worked well, but has not yet been implemented for multisets because each group must be solved separately. \n\n\n", "meta": {"hexsha": "f990c670a3c24b4615e6ac8e8173ebcd4f0a5470", "size": 6967, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reflecting.tex", "max_stars_repo_name": "rachelslaybaugh/RNS_Thesis", "max_stars_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-01-07T09:06:04.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-16T17:13:56.000Z", "max_issues_repo_path": "reflecting.tex", "max_issues_repo_name": "rachelslaybaugh/RNS_Thesis", "max_issues_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reflecting.tex", "max_forks_repo_name": "rachelslaybaugh/RNS_Thesis", "max_forks_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-24T17:15:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-24T17:15:21.000Z", "avg_line_length": 71.824742268, "max_line_length": 744, "alphanum_fraction": 0.6819290943, "num_tokens": 2294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.41311463723602027}}
{"text": "\\section{Numerical Illustrations}\n\n\\subsection{Examples from \\citep{huang1995software}}\n\n\\subsubsection{Example A}\n\\begin{itemize}\n  \\item Mean Time Between Failures (MTBF): $12 \\times 30 \\times 24$ hours\n  \\item failure repair time:  30 minutes\n  \\item base longevity interval:  $7 \\times 24$ hours\n  \\item rejuvenation time: 20 minutes\n  \\item average cost of unscheduled downtime: \\$1700 / hour\n  \\item average cost of scheduled downtime: \\$40 / hour  \n\\end{itemize}\n\n\\begin{table}[h]\n\\begin{tabular}{ | l || c | c | c | }\n  \\hline\n   \\multicolumn{4}{|c|}{For $12 \\times 30 \\times 24 $ hours } \\\\\n  \\hline                       \n    & no rejuvenation & once every 3 weeks & once every two weeks \\\\\n   \\hline     \n  Hours of Down Time  & 0.49 & 5.965 & 8.727 \\\\\n  \\hline    \n  \\$Cost of Down Time & 490  & 554 & 586 \\\\\n  \\hline \n\\end{tabular}\n  \\caption{Huang etc's estimation for Example A}\n\\end{table}  \n  \n\n\n\\subsubsection{Example B}\n\\begin{itemize}\n  \\item Mean Time Between Failures (MTBF): $3 \\times 30 \\times 24$ hours\n  \\item failure repair time:  30 minutes\n  \\item base longevity interval:  $3 \\times 24$ hours\n  \\item rejuvenation time: 10 minutes\n  \\item average cost of unscheduled downtime: \\$5000 / hour\n  \\item average cost of scheduled downtime: \\$5 / hour  \n\\end{itemize}\n\n\\begin{table}[h]\n\\begin{tabular}{ | l || c | c | c | }\n  \\hline\n   \\multicolumn{4}{|c|}{For $12 \\times 30 \\times 24 $ hours } \\\\\n  \\hline                       \n    & no rejuvenation & once every 2 weeks & once a week \\\\\n   \\hline     \n  Hours of Down Time  & 1.94 & 5.70 & 9.52 \\\\\n  \\hline    \n  \\$Cost of Down Time & 9675.25  & 7672.43 & 5643.31 \\\\\n  \\hline  \n\\end{tabular}\n  \\caption{Huang etc's estimation for Example B}\n\\end{table}  \n  \n\n\\begin{figure}[h]\n     \\begin{center}\n     \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/accumulated_cost_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/accumulated_cost_month.png}\n        }\\\\\n        \\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/accumulated_cost_day.png}\n        }\n\t\\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/accumulated_downtime_month.png}\n        }\\\\ \n        \n        \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/availability_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/availability_month.png}\n        }\\\\\n        \\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/availability_day.png}\n        }\n\t\\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/availability_month.png}\n        }\\\\ \n        \n             \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/acc_rej_time_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995B2/acc_rej_time_month.png}\n        }\\\\\n        \\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/acc_rej_time_day.png}\n        }\n\t\\subfigure[]{            \n\\includegraphics[scale=0.18]{./plot/Huang1995B3/acc_rej_time_month.png}\n        }\\\\\n\n    \\end{center}\n     \\caption{Example B}\n   \\label{throughput}\n\\end{figure}\n\n\\subsubsection{Example C}\n\\begin{itemize}\n  \\item Mean Time Between Failures (MTBF): $3 \\times 30 \\times 24$ hours\n  \\item failure repair time:  $2$ hours\n  \\item base longevity interval (BLI):  $10 \\times 24$ hours\n  \\item rejuvenation time: 10 minutes\n  \\item average cost of unscheduled downtime: \\$5000 / hour\n  \\item average cost of scheduled downtime: \\$5 / hour  \n\\end{itemize}\n\n\\begin{table}[h]\n\\begin{tabular}{ | l || c | c | c | }\n  \\hline\n   \\multicolumn{4}{|c|}{For $12 \\times 30 \\times 24 $ hours } \\\\\n  \\hline                       \n    & no rejuvenation & once every 2 weeks & once a week \\\\\n   \\hline     \n  Hours of Down Time  & 7019 & 6.83 & 6.36 \\\\\n  \\hline    \n  \\$Cost of Down Time & 3.6K  & 2.48K & 1.11K \\\\\n  \\hline  \n\\end{tabular}\n  \\caption{Huang etc's estimation for Example C}\n\\end{table}  \n  \n\n\\begin{figure}[h]\n     \\begin{center}\n     \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/accumulated_cost_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/accumulated_cost_month.png}\n        }\\\\\n%        \\subfigure[]{            \n%\\includegraphics[scale=0.18]{./plot/Huang1995C3/accumulated_cost_day.png}\n%        }\n%\t\\subfigure[]{            \n%\\includegraphics[scale=0.18]{./plot/Huang1995C3/accumulated_downtime_month.png}\n%        }\\\\ \n        \n        \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/availability_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/availability_month.png}\n        }\\\\\n%        \\subfigure[]{            \n% \\includegraphics[scale=0.18]{./plot/Huang1995C3/availability_day.png}\n%        }\n%\t\\subfigure[]{            \n% \\includegraphics[scale=0.18]{./plot/Huang1995C3/availability_month.png}\n%        }\\\\ \n        \n             \\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/acc_rej_time_day.png}\n        }\n\\subfigure[]{\n\\includegraphics[scale=0.18]{./plot/Huang1995C2/acc_rej_time_month.png}\n        }\\\\\n%        \\subfigure[]{            \n%\\includegraphics[scale=0.18]{./plot/Huang1995C3/acc_rej_time_day.png}\n%        }\n%\t\\subfigure[]{            \n%\\includegraphics[scale=0.18]{./plot/Huang1995C3/acc_rej_time_month.png}\n%        }\\\\   \n    \\end{center}\n     \\caption{Example C}\n\\end{figure}\n\n\n\\subsubsection{Simulation Results}\n\n\\begin{itemize}\n  \\item 4 experiments for each example: two different rejuvenation schedules, \ntwo simulated longevity (1 year and 20 years)\n  \\item basic time unit: 10 minutes\n  \\item failure distribution: uniform distributio, $U(BLI, 2\\times MTBF-BLI)$\n\\end{itemize}\n\n\n\n\n\n\\subsubsection{Observations}\n\n\n\\begin{itemize}\n  \\item In each of the above examples, it takes more than 1.5 years to reach steady-state (see availability graph).\n  the property of a reliable system 1.5 years from now is less valuable as the its property now.\n  \\item The cost for the first year is lower than the expected annual cost\n  \\item For a reliable system, the main cost is the rejuvenation cost.\n\\end{itemize}\n\n\n\n\\subsection{Examples from Dohi}\n\nUse the same parameter used in the paper, assume weibull distribution as in the paper\n\n\n", "meta": {"hexsha": "b92b54ed318380460016208b69f8de2c7ed18f5f", "size": 6281, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "s1024484/Paper/Rejuvenation/example.tex", "max_stars_repo_name": "Jiansen/TAkka", "max_stars_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-09-11T14:35:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T06:36:09.000Z", "max_issues_repo_path": "s1024484/Paper/Rejuvenation/example.tex", "max_issues_repo_name": "Jiansen/TAkka", "max_issues_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "s1024484/Paper/Rejuvenation/example.tex", "max_forks_repo_name": "Jiansen/TAkka", "max_forks_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6390243902, "max_line_length": 115, "alphanum_fraction": 0.6424136284, "num_tokens": 1948, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177488, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.41311463486701683}}
{"text": "% Created 2015-11-10 Tue 15:09\n\\documentclass{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{fixltx2e}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{float}\n\\usepackage{wrapfig}\n\\usepackage{soul}\n\\usepackage{textcomp}\n\\usepackage{marvosym}\n\\usepackage{wasysym}\n\\usepackage{latexsym}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\tolerance=1000\n\\usepackage{khpreamble}\n\\providecommand{\\alert}[1]{\\textbf{#1}}\n\n\\title{Computerized control - Homework 6}\n\\author{Kjartan Halvorsen}\n\\date{Due 2015-11-20}\n\\hypersetup{\n  pdfkeywords={},\n  pdfsubject={},\n  pdfcreator={Emacs Org-mode version 7.9.3f}}\n\n\\begin{document}\n\n\\maketitle\n\n\n\n\\section{Controller design by state feedback}\n\\label{sec-1}\n\n  Sampling the DC-motor with transfer function and state-space representation\n  \\[ G(s) = \\frac{1}{s(s+1)} \\]\n   \\begin{align*}\n   \\dot{x} &= \\bbm 0 & 1\\\\0 & -1\\ebm x + \\bbm 0\\\\1\\ebm \\\\\n   y &= \\bbm 1 & 0\\ebm x\n   \\end{align*}\n   gives the discrete-time state-space model\n   \\begin{align*}\n   x(k+1) &= \\Phi x(k) + \\Gamma u(k) = \\bbm \\mexp{-h} & 1-\\mexp{-h}\\\\ 0 & 1\\ebm x(k) + \\bbm \\mexp{-h}+h-1\\\\ h \\ebm \\\\\n   y(k) &= Cx(k) = \\bbm 1 & 0 \\ebm x(k).\n   \\end{align*}\n\\subsection{Determine the pulse-transfer function}\n\\label{sec-1-1}\n\n   Show that the corresponding pulse-transfer operator is given by\n  \\begin{equation}\n  \\begin{split}\n   H(q) &= \\frac{B(q)}{A(q)} = \\frac{(q-1)(\\mexp{-h}+h-1) + h(1-\\mexp{-h})}{(q-1)(q-\\mexp{-h})}.\n  \\end{split}\n  \\label{eq:Gd}\n  \\end{equation}\n\\subsection{Reachability and observability}\n\\label{sec-1-2}\n\n   Show that the discrete-time system is both reachable and observable.\n\\subsection{Design the feedback control}\n\\label{sec-1-3}\n\n   Choose a suitable sampling period $h$ and determine $L$ and $m_0$ in the state feedback\n   \\[ u(k) = -Lx(k) + m_0u_c(k) \\]\n   such that the closed loop system has poles in \\(0.5\\pm i0.5,\\) and so that the closed-loop system has static gain equal to 1.\n\\subsection{Implement the model}\n\\label{sec-1-4}\n\n   Implement the model in Simulink or in Matlab. Simulate a step-response and attach to your report. Verify that the sampling period is reasonable based on the step-response: Determine the rising time and compare it to the sampling period you chose. \n\n\\end{document}\n", "meta": {"hexsha": "3c910de30f107359fc4ae5c856d132f36a9b4cdf", "size": 2266, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homework/historical/hw6-fall15.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "homework/historical/hw6-fall15.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "homework/historical/hw6-fall15.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 30.2133333333, "max_line_length": 250, "alphanum_fraction": 0.6902030009, "num_tokens": 791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4131146334518973}}
{"text": "\\begin{document}\n\t\\chapter{Conclusions}\n\t\n\tIn this work we presented an analysis of various aspects of a newborn Bitcoin micro-payment system known as Lightning Network. We collected data from the testnet environment for a month and showed the trends in terms of size of the network, number of edges, average degree and diameter on a daily basis and on a monthly basis, evidencing a small variation over a 24h period with respect to a 31 days period. We focused on the centrality aspect of some nodes that showed a high betweenness centrality score throughout the daily and the monthly observation period, evidencing the implications on having such a high centrality degree on this particular network. Then an inherent hierarchical structure of the network has been showed through the analysis of the k-vertex components iterated over the maximal subgraph found for each step, and the process was repeated for each snapshot of the network putting in evidence the size of each vertex component. Then we investigated the features of the nodes belonging to the most connected component by computing the intersection with a list of nodes sorted by their betweenness centrality score, discovering that each highest k-connected component is mostly composed by central nodes, suggesting that there is a strong backbone that either would help in future to form a hierarchical structure similar to the one observed in ISPs infrastructures, or will cause the network.\n\t\n\tBased on the information gathered so far, we wanted to find out which was the best random graph model able to capture the essential structure of the network. We first observed that the network degree distribution was governed by a power-law, then we guessed the $\\gamma$ value, that is the exponent of such power-law, via curve fitting over many instances of the network, computing the mean value among these fits. We finally discovered, by comparing the real information with the one gathered on the newly created model, that the random graph that was best suited to represent the Lightning Network was the Chung-Lu model, which is a model for scale-free network. Then we provided a formalization of the network behavior based on the Time Varying Graph framework by defining a directed TVG that can model the presence of an edge along the lifespan of a system; we also introduced the notion of payment channel modeled as two opposed directed edges that connects two nodes of the network and defined the conditions under which a payment is doable in both the best and worst case scenario (cooperative and uncooperative nodes).\n\t\n\t\\section{Future works and directions}\n\t\n\tBitcoin is a fairly new technology and the literature is still scarce; this determined an initial difficult approach to the topic since most of the documentation has to be found in old forums or in developers mailing-list. In addition, the Lightning Network was publicly released on November 2017 on the testnet environment and for this reason the scientific literature by the time was literally non-existent except for a proposal of a Lightning Network routing scheme known as Flare \\cite{Prihodko2016}. For this reason, a survey over this technology would indeed help other researchers to get to know to the main features of this scalability solution and better orientate between the main issues.\n\t\n\tWhen we started working on this protocol there were no tools that offered network stats, thus part of this work is dedicated to trends analysis. As the network kept growing, more and more tools were developed for the user base, as well as network trackers which displayed some basic characteristic of the network, but they all lack of important network characterization metrics: thus, one direction could be further develop and ease the visualization of the metrics, like the one presented on this work, to give users more information about the network they are investing in. Furthermore, the data presented until now only applies to the testnet environment due to hardware limit, so it would be interesting to see some of the analysis presented above repeated on the main network data, in particular those about the generation of an equivalent model.\n\t\n\tThe network route discovery protocol relies by now on the fact that each node in the graph knows the topology of the network; as the network grows it would be rather impractical for nodes to store all the information of an ever-evolving graph, thus a discussion over a Lightning Network hierarchical infrastructure has to be made, and the considerations about the k-vertex components we made so far could be used as a starting ground for future works. On the other hand, having so many central nodes belonging to the same connected component may led to the formation of payment cartels were some users would be served with much more priority by central nodes with respect to others, thus decreasing the overall fairness when it comes to transaction processing.\n\t\n\tLastly, the Lightning Network so far has seen a low adoption by the users because setting up a new node is a task that requires a strong technical background, thus the network is still small in size with respect to the scalability goals that it has anticipated. With an equivalent model in mind and a formal model that describes the basic operations of the system, it would be useful to test the Lightning Network against a wider scenario, where millions of nodes are capable to process transactions and/or to fail them. Also, since the autopilot function appears to be designed around the BA-model, it would be interesting to test the network against other random graph models and see which one would fit better for the system purpose.\n\t\n\\end{document}", "meta": {"hexsha": "e4a2637229b44efb8bf26d8a69f81ff7cc4960bc", "size": 5706, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "conclusion/conclusion.tex", "max_stars_repo_name": "randomBEAR/master_thesis", "max_stars_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "conclusion/conclusion.tex", "max_issues_repo_name": "randomBEAR/master_thesis", "max_issues_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "conclusion/conclusion.tex", "max_forks_repo_name": "randomBEAR/master_thesis", "max_forks_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 317.0, "max_line_length": 1415, "alphanum_fraction": 0.8161584297, "num_tokens": 1084, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.41311462966777435}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Template for a LaTex article in English.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass{article}\n\n% AMS packages:\n\\usepackage{amsmath, amsthm, amsfonts}\n\n% Theorems\n%-----------------------------------------------------------------\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\theoremstyle{definition}\n\\newtheorem{defn}[thm]{Definition}\n\\theoremstyle{remark}\n\\newtheorem{rem}[thm]{Remark}\n\n% Shortcuts.\n% One can define new commands to shorten frequently used\n% constructions. As an example, this defines the R and Z used\n% for the real and integer numbers.\n%-----------------------------------------------------------------\n\\def\\RR{\\mathbb{R}}\n\\def\\ZZ{\\mathbb{Z}}\n\n% Similarly, one can define commands that take arguments. In this\n% example we define a command for the absolute value.\n% -----------------------------------------------------------------\n\\newcommand{\\abs}[1]{\\left\\vert#1\\right\\vert}\n\n% Operators\n% New operators must defined as such to have them typeset\n% correctly. As an example we define the Jacobian:\n% -----------------------------------------------------------------\n\\DeclareMathOperator{\\Jac}{Jac}\n\n%-----------------------------------------------------------------\n\\title{Implementing Jarzynski Equality in Python}\n\\author{Lingbo Tang\\\\\n  \\small Dept. Computing Science\\\\\n  \\small University of Alberta\\\\\n  \\small Canada\n}\n\n\\begin{document}\n\\maketitle\n\n\\abstract{Jarsynski Equality is a neat equality that reveals that the system Free Energy could be calculated even when the system is not in equilibrium state.}\n\n\\section{Introduction}\n\nIn general, the Jarzynski Equality could look like this:\n\n\\begin{equation}\\label{eq:general}\n  \\Delta F = F(\\lambda_{t}) - F(\\lambda_{0}) <= < W >\n\\end{equation}\n\nand the integration form looks like:\n\n\\begin{equation}\\label{eq:integration}\n  W_{0\\rightarrow t} = \\int_{0}^{t} dt^{'} \\frac{\\partial \\lambda_t^{'}}{\\partial t^{'}} [\\frac{\\partial \\tilde{H} (r, p; \\lambda)}{\\partial \\lambda} ]_{(r,p; \\lambda)} = (r_{t^{'}}, p_{t^{'}} ; \\lambda_{t^{'}})\n\\end{equation}\n\nOne can refer to equations like this: see equation (\\ref{eq:general}). One can also\nrefer to sections in the same way: see section \\ref{sec:nothing}. Or\nto the bibliography like this: \\cite{Cd94}.\n\n\\subsection{Subsection}\\label{sec:nothing}\n\nMore text.\n\n\\subsubsection{Subsubsection}\\label{sec:nothing2}\n\nMore text.\n\n% Bibliography\n%-----------------------------------------------------------------\n\\begin{thebibliography}{99}\n\n\\bibitem{Cd94} Author, \\emph{Title}, Journal/Editor, (year)\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "0b9c4f2130bda5b5cd3732c17063c60ccc380dd5", "size": 2774, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "article.tex", "max_stars_repo_name": "LingboTang/LearningFiles", "max_stars_repo_head_hexsha": "efe3174dd7700d1f39851d9d813929425b4e473f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "article.tex", "max_issues_repo_name": "LingboTang/LearningFiles", "max_issues_repo_head_hexsha": "efe3174dd7700d1f39851d9d813929425b4e473f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "article.tex", "max_forks_repo_name": "LingboTang/LearningFiles", "max_forks_repo_head_hexsha": "efe3174dd7700d1f39851d9d813929425b4e473f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8222222222, "max_line_length": 211, "alphanum_fraction": 0.5836337419, "num_tokens": 687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.4130692420367494}}
{"text": "%% Digital Systems\n%% Digital System Models\n\\def\\FileDate{98/11/18}\n\\def\\FileVersion{1.0}\n% ----------------------------------------------------------------\n% Notes pages *********************************************************\n% ----------------------------------------------------------------\n\n\\section*{Digital System Models}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9sA}\n\\heading{Digital system models}\n\\input{chunk1}\n\\end{slide}\n\\fi\n\\input{chunk1}\n\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9sB} \\heading{Difference equation}\n\\input{chunk2}\n\\end{slide}\n\\fi\n\\input{chunk2}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9sC} \\heading{Difference equation in terms of the delay operator}\n\\input{chunk3}\n\\end{slide}\n\\fi\n\\input{chunk3}\n\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9sD} \\heading{$z$-transform of difference equation}\n\\input{chunk4}\n\\end{slide}\n\\fi\n\\input{chunk4}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s1} \\heading{$z$ Transfer Function}\n\\input{chunk5.tex}\n\\end{slide}\n\\fi\n\\input{chunk5.tex}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s2} \\heading{$z$ Transfer Function (2)}\n\\input{chunk6}\n\\end{slide}\n\\fi\n\\input{chunk6}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s3} \\heading{$z$ Transfer Function (3)}\n\\input{chunk7}\n\\end{slide}\n\\fi\n\\input{chunk7}\n\n\\ifslidesonly\n\\begin{slide}\\heading{Other forms of digital transfer function}\n\\input{chunk8}\n\\end{slide}\n\\fi\n\\input{chunk8}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s4} \\heading{Canonical Forms}\n\\input{chunk9}\n\\end{slide}\n\\fi\n\\input{chunk9}\n\n\\ifslidesonly\n\\begin{slide}\n\\heading{End of Pre-Class Presentation}\nThis concludes the pre-class presentation.\n\nIn the class we will\nlook at system response and compute the impulse and step responses of\nand example system.\n\\end{slide}\n\\fi\n\n%% Digital Systems\n%% Digital System Response\n\n\\section*{Digital System Response}\n\nAs in the case of a continuous system, the response of a digital\nsignal comprises the sum of a free response and a forced response.\nThe free response is dependent on the initial conditions of a\ndigital system states, and as these are taken as zero here the\nfree response is also zero and will not be considered further.\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s5} \\heading{Digital System Response}\n\\input{chunk10}\n\\end{slide}\n\\fi\n\\input{chunk10}\n\nThe inverse transform needed to determine the digital system\nresponse is obtained using the inverse z transform methods, e.g.\npolynomial division and partial fraction expansion, discussed in a\nprevious lecture.\n\n\\subsection*{Response to Singularity Signals}\n\nThe elemental singularity signals in a digital system response\ninclude the digital impulse signal and the digital step input.\n\n\\subsubsection*{Impulse response}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s6} \\heading{Impulse signal}\n\\input{chunk11}\n\\end{slide}\n\\fi\n\\input{chunk11}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s7} \\heading{Example 1: Impulse Response}\nCalculate the impulse response of the digital system with transfer function\n  \\[ H(z) = \\frac{4z^2 - 16}{z^2 - 0.25}\\]\n\\end{slide}\n\\fi\nConsider the system\n\\[ H(z) = \\frac{4z^2 - 16}{z^2 - 0.25}\\]\nThe impulse response will be\n\\[ Y(z) = H(z)\\times 1 = \\frac{4z^2 - 16}{z^2 - 0.25}\\]\nWe shall determine this response using the partial fraction\nexpansion.\n\\begin{eqnarray*}\nY(z) &=& \\frac{4 - 16z^{-2}}{1 - 0.25 z^{-2}}\\\\\n     &=& \\frac{4(4 - 16z^{-2})}{4 - z^{-2}}\\\\\n     &=& \\frac{4(2 - 4z^{-1})(2 + 4z^{-1})}{(2 - z^{-1})(2 + z^{-1})}\n\\end{eqnarray*}\nAssuming a partial fraction expansion of the form \\[Y(z) =\n\\frac{A}{2 - z^{-1}} + \\frac{B}{2 + z^{-1}} + C \\]  we have\n\\begin{eqnarray*}\n \\frac{4(2 - 4z^{-1})(2 + 4z^{-1})}{(2 - z^{-1})(2 + z^{-1})}\n     &=& \\frac{A(2 + z^{-1}) + B(2 - z^{-1}) + C(2 - z^{-1})(2 + z^{-1})}{(2 - z^{-1})(2 + z^{-1})}\\\\\n     16 - 64z^{-2} &=& 2A + Az^{-1} + 2B - Bz^{-1} + 4C - Cz^{-2}\n \\end{eqnarray*}\nGathering terms and equating coefficients\n\\begin{eqnarray}\n16 &=& 2A +2B + 4C\\\\ 0 &=& A - B\\\\ -64 &=& -C\n\\end{eqnarray}\nHence\n\\begin{eqnarray}\nC &=& 64\\\\ A &=& B\\\\ 16 &=& 4A + 256\\\\ A &=& B = -60\n\\end{eqnarray}\nThus\n\\begin{eqnarray*}\n    Y(z) &=& 64 -\\frac{60}{2-z^{-1}}-\\frac{60}{2+z^{-1}}\\\\\n    &=& 64 -\\frac{30}{1-1/2 z^{-1}}-\\frac{30}{1+1/2 z^{-1}}\\\\\n     y_k& =& \\left\\{64\\delta_k - 30\\left(\\frac{1}{2}\\right)^k - 30\n\\left(-\\frac{1}{2}\\right)^k\\right\\}\\\\\n &=& \\left\\{4,\\ 0,\\ -15,\\ 0,\\ -3.75,\\ 0,\\ -0.9375,\\ \\ldots\n \\right\\}\n\\end{eqnarray*}\n\n\\subsubsection*{Step response}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s8} \\heading{Step signal}\n\\input{chunk12}\n\\end{slide}\n\\fi\n\\input{chunk12}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s9} \\heading{$z$-transform of step signal}\n\\input{chunk13}\n\\end{slide}\n\\fi\n\\input{chunk13}\n\n\\ifslidesonly\n\\begin{slide}\\label{slide:l9s10} \\heading{Example 2: Step Response}\nCalculate the step response of the digital system with transfer function\n  \\[ H(z) = \\frac{4z^2 - 16}{z^2 - 0.25}\\]\n\\end{slide}\n\\fi\n\nThe step response of the example system is\n\\[ Y(z) = H(z)\\times \\frac{z}{z-1} = \\frac{z(4z^2 - 16)}{(z-1)(z^2 - 0.25)}\\]\nWe shall determine this response using the partial fraction\nexpansion.\n\\begin{eqnarray*}\nY(z) &=& \\frac{4z^3 - 16z}{z^3 - z^2 - 0.25z + 0.25}\\\\\n &=& \\frac{4 - 16z^{-2}}{1 - z^{-1} - 0.25z^{-2} + 0.25z^{-3}}\\\\\n\\end{eqnarray*}\nEarlier we showed that the result of the partial\nfraction expansion was\n\\[\\frac{30}{1-1/2 z^{-1}} - \\frac{10}{1+1/2z^{-1}} -\n\\frac{16}{1-z^{-1}}\\] and the corresponding sequence is\n\\[y_k = \\left\\{30(1/2)^k -10(-1/2)^k -16\\epsilon_k\\right\\}.\\]\n\n\n%----------------------------------------------------------------\n% The end of notes\n% ----------------------------------------------------------------\n\\endinput\n\n% Local Variables:\n% TeX-master: \"lecture02\"\n% End:\n", "meta": {"hexsha": "ef97679799fee2196ce02eb9e5882ad567eac3cf", "size": 5692, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DigitalSystems/Lecture11/notes.tex", "max_stars_repo_name": "cpjobling/EGLM03-Resources", "max_stars_repo_head_hexsha": "70e5fd7b3e519cc3f327f348631b800d361bbb27", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DigitalSystems/Lecture11/notes.tex", "max_issues_repo_name": "cpjobling/EGLM03-Resources", "max_issues_repo_head_hexsha": "70e5fd7b3e519cc3f327f348631b800d361bbb27", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DigitalSystems/Lecture11/notes.tex", "max_forks_repo_name": "cpjobling/EGLM03-Resources", "max_forks_repo_head_hexsha": "70e5fd7b3e519cc3f327f348631b800d361bbb27", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7230046948, "max_line_length": 101, "alphanum_fraction": 0.6328179902, "num_tokens": 1971, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.41306923822008434}}
{"text": "\n\\chapter{Winding Surface Optimization with Adjoint \\texttt{REGCOIL}}\n\\label{ch:adjoint}\n\nIn this section we describe winding surface optimization using the adjoint \\texttt{REGCOIL} method. \n\n\\section{Overview}\n\nIf an adjoint equation is solved in \\texttt{REGCOIL}, (\\parlink{sensitivity\\_option} $> 1$), then analytic derivatives of $\\chi^2_B$, $\\norm{\\bm{K}}_2$, or $K_{\\max}$ are computed with respect to the Fourier coefficients defining the winding surface using the adjoint method. These derivatives are used for a gradient-based optimization method to find a winding surface which minimizes a user-defined objective function. The target plasma surface is held fixed during the optimization. The user has the option of holding a target function fixed during the optimization (such as $\\chi^2_B$, $\\norm{\\bm{K}}_2$, or $K_{\\max}$) to fix the regularization parameter $\\lambda$. There are also options to impose constraints, such as on the minimum coil-plasma distance. The \\texttt{NESCIN} convention is used, and the result of the optimization is a \\texttt{NESCIN} file with the optimal winding surface Fourier coefficients. \n\n\\section{Optimization scripts}\nAdditional parameters must be included in the \\texttt{REGCOIL} input file outside the \\texttt{regcoil\\_nml} Fortran namelist. The parameters in this namelist are read by either the \\texttt{scipy\\_optimize} or \\texttt{nlopt\\_optimize} python scripts, found in the \\texttt{windingSurfaceOptimization} directory. These scripts are called with the \\texttt{REGCOIL} input file as an argument. The \\texttt{REGCOIL} input file in addition to any geometry files (\\texttt{nescin\\_filename}, \\texttt{efit\\_filename}, \\texttt{bnorm\\_filename}, \\texttt{shape\\_filename\\_plasma}) must be located in the directory from which these scripts are called. \n\nThe \\texttt{nlopt} package must be installed in order to call \\texttt{nlopt\\_optimize}. See the \\href{https://nlopt.readthedocs.io/en/latest/#download-and-installation}{nlopt documentation} for installation instructions. In general \\texttt{nlopt\\_optimize} should be used if one wants to perform constrained optimization. Once \\texttt{nlopt} is installed, ensure that your \\texttt{\\$PYTHONPATH} includes the directory containing \\texttt{libnlopt.so}. The directory where this is located is specified by \\texttt{libdir} in the file \\texttt{libnlopt.la}. At this time \\texttt{nlopt\\_optimize} has been used with \\texttt{nlopt} 2.4.2. The \\texttt{scipy\\_optimze} script utilizes the \\texttt{scipy.optimize} package. Details on installation of \\texttt{scipy} can be found \\href{https://scipy.org/install.html}{here}. The parameters relevant to each of these scripts are detailed below. \n\nEach time that \\texttt{REGCOIL} is called from one of the scripts, an \\texttt{eval\\_} directory will be created. The script will print the objective function and constraint functions diagnostics with each evaluation to standard output. The \\texttt{compareRegcoilSurface} script (found in \\texttt{regcoil/coilOptimizationTools}) can be called on two \\texttt{REGCOIL} output files to compare the winding surfaces at 2 evaluations.\n\\begin{verbatim}\ncompareRegcoilSurface eval_0/regcoil_out.w7x.nc eval_10/regcoil_out.w7x.nc\n\\end{verbatim}\nSeveral example input files can be found in the \\texttt{adjointRegcoilExamples} directory.\n\nWhile \\texttt{nlopt\\_optimize} and \\texttt{scipy\\_optimize} are serial optimizers, the gradient computation in \\texttt{REGCOIL} is performed in parallel with OpenMP. Multithreading is controlled with the \\texttt{OMP\\_NUM\\_THREADS} environment variable.\n\nTo run \\texttt{scipy\\_optimize} or \\texttt{nlopt\\_optimize} from any directory, add the \\\\ \\texttt{regcoil/coilOptimizationTools} directory to your \\texttt{\\$PATH} and to your \\texttt{\\$PYTHONPATH}, and add the \\texttt{regcoil} directory to your \\texttt{\\$PATH}.\n\n\\section{Required \\texttt{\\&regcoil\\_nml} namelist parameters}\nThe following items in the \\texttt{\\&regcoil} namelist should be used when running adjoint \\texttt{REGCOIL}. \n\\begin{itemize}\n\\item \\parlink{geometry\\_option\\_coil} = 3 or 4 \n    \\begin{itemize}\n    \\item A \\parlink{nescin\\_filename} must be specified. It is assumed that the $m=0$ mode only includes $n\\geq0$ modes. \n    \\end{itemize}\n\\item \\parlink{sensitivity\\_option} $>1$ denotes an adjoint solve must be performed. If $\\chi^2_B$, $\\norm{\\bm{K}}_2$ or $K_{\\text{max}}$ are included in the objective function, \\parlink{sensitivity\\_option} should be $>2$. If finite difference derivatives are used by setting \\parlink{grad\\_option} = 1 or if $\\chi^2_B$, $\\norm{\\bm{K}}_2$ or $K_{\\text{max}}$ are not included in the objective function, \\parlink{sensitivity\\_option} can be set to 1. \n\\item \\parlink{nmax\\_sensitivity} should be set to the largest value of $n$ that should be varied in the \\texttt{NESCIN} file. This matters if \\parlink{sensitivity\\_option} $>1$.\n\\item \\parlink{nmax\\_sensitivity} should be set to the largest value of $m$ that should be varied in the \\texttt{NESCIN} file. This matters if \\parlink{sensitivity\\_option} $>1$.\n\\item \\parlink{sensitivity\\_symmetry\\_option} should be set to reflect the symmetry desired in the optimized winding surface. \n\\item If the coil-plasma distance is to be included in the objective function or constraints, then \\parlink{coil\\_plasma\\_dist\\_lse\\_p} should be set to the desired value for the log-sum-exponent approximation. A value in the range $10^{2}$ - $10^4$ is typically sufficient. At very large values the function has very steep gradients, while at small values it does not approximate the minimum function well. \n\\item If the gradients of $\\chi^2_B$, $\\norm{\\bm{K}}_2$ or $K_{\\text{max}}$  are to be computed at fixed target function (specified by \\parlink{target\\_option}) (rather than at fixed $\\lambda$), \\parlink{fixed\\_norm\\_sensitivity\\_option} should be $>1$. The following parameters matter when \\parlink{fixed\\_norm\\_sensitivity\\_option} $>1$. \n\t\\begin{itemize}\n\t\\item \\parlink{target\\_option} must be \\texttt{\"max\\_K\\_lse\"}, \\texttt{\"lp\\_norm\\_K\"}, or \\texttt{\"chi2\\_B\"}\n\t\\item \\parlink{target\\_option\\_p} is a parameter in the norm defined by \\parlink{target\\_option}\n\t\\end{itemize}\n\\end{itemize}\n\n\\section{Coil-winding Surface Optimization Parameters}\n\n\\myhrule\n\nThe parameters related to winding surface optimization are defined in the input file outside the \\texttt{regcoil\\_nml} namelist. \n\n\\myhrule\n\n\\section{Winding Surface Optimization}\n\nThe following objective function is used when \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is called.\n\\begin{multline}\nf = \\texttt{scale\\_factor} \\Bigg( -\\alpha_V V_{\\text{coil}} + \\alpha_S S_p - \\alpha_D d_{\\text{min}} + \\alpha_B \\chi^2_B + \\alpha_K \\norm{\\bm{K}}_2 \\\\ + \\alpha_{D,\\tanh} \\left(1 + \\tanh\\left( \\left( d_{\\min}-\\texttt{d\\_min\\_target} \\right)/\\texttt{alpha\\_D\\_tanh\\_scale} \\right) \\right) \\Bigg)\n\\end{multline}\nHere $S_p$ is the spectral width,\n\\begin{gather}\nS_p = \\sum_{m,n} m^p \\left( \\left(r_{mn}^c\\right)^2 + \\left(z_{mn}^s\\right)^2 \\right),\n\\label{spectral_width}\n\\end{gather}\n$d_{\\text{min}}$ is the minimum coil-plasma distance,\n\\begin{gather}\nd_{\\text{min}} = \\min \\left( \\sqrt{ \\left(\\bm{r}_{\\text{coil}} - \\bm{r}_{\\text{plasma}} \\right)^2 } \\right),\n\\end{gather}\nand $\\norm{\\bm{K}}_2$ is the root-mean-squared current density,\n\\begin{gather}\n\\norm{\\bm{K}}_2 = \\sqrt{\\chi^2_K/A_{\\text{coil}}}.\n\\end{gather}\nThe coefficients in $f$ are defined by the user. \n\n\\myhrule\n\n\\param{alphaV}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for $V_{\\text{coil}}$ in the objective function.}\n\n\\myhrule\n\n\\param{alphaS}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for $S_p$ in the objective function.}\n\n\\myhrule\n\n\\param{alphaD}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for $d_{\\text{min}}$ in the objective function.}\n\n\\myhrule\n\n\\param{alphaB}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for $\\chi^2_B$ in the objective function.}\n\n\\myhrule\n\n\\param{alphaK}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for $\\norm{\\bm{K}}_2$ in the objective function.}\n\n\\myhrule\n\n\\param{alphaD\\_tanh}\n{float}\n{0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for the $\\tanh$ function in the objective function, which acts as a `wall` in parameter space when $d_{\\min}$ reaches \\parlink{d\\_min\\_target}. The scaling is set by \\parlink{alphaD\\_tanh\\_scale}.}\n\n\\myhrule\n\n\\param{alphaD\\_tanh\\_scale}\n{float}\n{1.0}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called and \\parlink{alphaD\\_tanh\\_scale} is non-zero.}\n{Sets the scale length for the $\\tanh$ function in the objective function. When this value is large, the gradients are less sharp.}\n\n\\myhrule\n\n\\param{d\\_min\\_target}\n{float}\n{0.1}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called and \\parlink{alphaD\\_tanh\\_scale} is non-zero.}\n{Sets the location of the `wall' in parameter space due to the $\\tanh$ function.}\n\n\\myhrule\n\n\\param{scaleFactor}\n{float}\n{1}\n{When \\texttt{nlopt\\_optimize} or \\texttt{scipy\\_optimize} is being called.}\n{Scaling factor for objective function.}\n\n\\myhrule\n\n\\subsection{Scipy Optimize}\n\nThe following parameters are read if \\texttt{scipy\\_optimize} is being called. \n\n\\param{scipy\\_optimize\\_method}\n{string}\n{CG}\n{When \\texttt{scipy\\_optimize} is being called.}\n{The method used by \\texttt{scipy\\_optimize}. The following gradient-based methods are available: CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, and trust-ncp. See the \\\\\n\\href{https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html}{scipy.optimize.minimize} documentation for more information.}\n\n\\myhrule\n\n\\param{grad\\_option}\n{integer}\n{1}\n{When \\texttt{scipy\\_optimize} is being called.}\n{When \\parlink{grad\\_option} $ == 1$, the gradients computed by REGCOIL are used by \\\\ \\texttt{scipy.optimize.minimize}. If \\parlink{grad\\_option} $ == 0$, a gradient function handle is not passed to \\texttt{scipy.optimize}, and finite differencing is used.}\n\n\\myhrule\n\n\\param {maxiter}\n{integer}\n{1000}\n{When \\texttt{scipy\\_optimize} is being called.}\n{Maximum number of iteration to be taken by \\texttt{scipy.optimize.minimize}.}\n\n\\myhrule\n\n\\param{norm}\n{integer}\n{2}\n{When \\texttt{scipy\\_optimize} is being called.}\n{Order of norm of the gradient used by \\texttt{scipy.optimize.minimize} to determine successful termination.}\n\n\\myhrule\n\n\\param{gtol}\n{float}\n{$10^{-5}$}\n{When \\texttt{scipy\\_optimize} is being called.}\n{Tolerance for gradient norm required for termination.}\n\n\\myhrule\n\n\\param{nmax}\n{integer}\n{none}\n{When \\texttt{scipy\\_optimize} is being called.}\n{Maximum $n$ for Fourier modes of coil winding surface parameterization in \\parlink{nescin\\_filename}.}\n\n\\myhrule\n\n\\param{mmax}\n{integer}\n{none}\n{When \\texttt{scipy\\_optimize} is being called.}\n{Maximum $m$ for Fourier modes of coil winding surface parameterization in \\parlink{nescin\\_filename}.}\n\n\\myhrule\n\n\\param{nmax}\n{integer}\n{none}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{Maximum $n$ value for winding surface Fourier modes in \\texttt{nescin\\_filename}.}\n\n\\myhrule\n\n\\param{mmax}\n{integer}\n{none}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{Maximum $m$ value for winding surface Fourier modes in \\texttt{nescin\\_filename}.}\n\n\\subsection{NLOPT Optimize}\n\nThe following parameters are read if \\texttt{nlopt\\_optimize} is being called. \n\n\\param{constraint\\_min}\n{integer}\n{0}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{\\texttt{constraint\\_min} = 0: No constraint on a minimum coil-plasma distance is enforced. \\\\\n \\texttt{constraint\\_min} = 1: Minimum coil-plasma distance is constrained to be $\\leq$ \\texttt{d\\_min}. }\n \n\\myhrule\n\n\\param{d\\_min}\n{float}\n{0.2}\n{When \\texttt{nlopt\\_optimize} is being called and \\texttt{contraint\\_min} = 1.}\n{Minimum coil-plasma allowed for optimized winding surface.}\n \n \\myhrule\n \n\\param{constraint\\_max\\_K}\n{integer}\n{0}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{\\texttt{constraint\\_max\\_K} = 0: No constraint on $\\max K$. \\\\\n \\texttt{constraint\\_max\\_K} = 1: Maximum current density is constraint to be $\\leq$ \\texttt{max\\_K}}\n \n\\myhrule\n\n\\param{max\\_K}\n{float}\n{7.1e6}\n{When \\texttt{nlopt\\_optimize} is being called and \\texttt{contraint\\_max\\_K} = 1.}\n{Maximum current density allowed during winding surface optimization. }\n\n\\myhrule\n\n\\param{constraint\\_rms\\_K}\n{integer}\n{0}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{\\texttt{constraint\\_rms\\_K} = 0: No constraint on $\\norm{K}_2$. \\\\\n \\texttt{constraint\\_rms\\_K} = 1: Maximum current density is constraint to be $\\leq$ \\texttt{rms\\_K}}\n \n\\myhrule\n\n\\param{rms\\_K}\n{float}\n{2.36e6}\n{When \\texttt{nlopt\\_optimize} is being called and \\texttt{contraint\\_rms\\_K} = 1.}\n{Maximum current density allowed during winding surface optimization. }\n\n\\myhrule\n\n\\param{nlopt\\_method}\n{string}\n{none}\n{When \\texttt{nlopt\\_optimize} is being called. }\n{Algorithm used for gradient based winding surface optimization. The following options are supported.\n\\begin{itemize}\n\\item \\texttt{nlopt.G\\_MLSL\\_LDS}\n\\item \\texttt{nlopt.LD\\_LBFGS}\n\\item \\texttt{nlopt.LD\\_MMA}\n\\item \\texttt{nlopt.LD\\_SLSQP} \n\\item \\texttt{nlopt.LD\\_CCSAQ}\n\\item \\texttt{nlopt.LD\\_TNEWTON\\_PRECOND\\_RESTART}\n\\item \\texttt{nlopt.LD\\_VAR1}\n\\end{itemize}\n}\n\n\\myhrule\n\n\\param{omega\\_min}\n{float}\n{-7}\n{When \\texttt{nlopt\\_optimize} is being called. }\n{Minimum value for $r_{mn}^c$ or $z_{mn}^s$ allowed for winding surface optimization.}\n\n\\myhrule\n\n\\param{omega\\_max}\n{float}\n{7}\n{When \\texttt{nlopt\\_optimize} is being called. }\n{Maximum value for $r_{mn}^c$ or $z_{mn}^s$ allowed for winding surface optimization.}\n\n\\myhrule\n\n\\param{constraint\\_tol}\n{float}\n{1e-6}\n{When \\texttt{nlopt\\_optimize} is being called and \\texttt{constraint\\_min} =1 or \\texttt{constraint\\_max\\_K} = 1 or \\texttt{constraint\\_rms\\_K}.}\n{Tolerance allowed for constraint equation to be satisfied.}\n\n\\myhrule\n\n\\param{ftol\\_rel}\n{float}\n{1e-6}\n{When \\texttt{nlopt\\_optimize} is being called.}\n{Optimization will stop when the relative change in the objective function $f$ is less than \\texttt{ftol\\_rel} in successive steps.}\n\n\\myhrule\n\n\\section{General considerations and tips}\n\\begin{itemize}\n\\item The results of the optimization vary widely with the input parameters. It is suggested that a user perform low-resolution optimizations with varying parameters (such as $\\alpha_B$, $\\alpha_S$, $\\alpha_{\\max{K}}$, and $\\alpha_V$). To begin, one can run the optimization for a few evaluations to ensure that it is descending in the desired direction. \n\\item If \\parlink{general\\_option} = 4 or 5 (a $\\lambda$ search is performed for a target function), it is not always possible to obtain a solution for $\\lambda$ if the current density is too low or high. In this case, the optimization scripts adjust the \\parlink{target\\_current\\_density} and will print a message to standard output. If you see that the \\parlink{target\\_current\\_density} is readjusted several times, it is probably a good idea to begin the optimization with a different \\parlink{target\\_current\\_density} . \n\\item The SLSQP and CCSAQ algorithms in \\texttt{nlopt} can be sensitive to the selection of \\parlink{omega\\_min} and \\parlink{omega\\_max}, as these set the initial step size for the optimization. If the winding surface wanders to far from the initial surface, these should be adjusted. \n\\end{itemize}\n", "meta": {"hexsha": "e8d7fd0b34c7511654def346da8a6229a3e8e984", "size": 15595, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manual/adjoint.tex", "max_stars_repo_name": "landreman/regcoil", "max_stars_repo_head_hexsha": "99f9abf8b0b0c6ec7bb6e7975dbee5e438808162", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-05-26T14:08:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T10:22:26.000Z", "max_issues_repo_path": "manual/adjoint.tex", "max_issues_repo_name": "landreman/regcoil", "max_issues_repo_head_hexsha": "99f9abf8b0b0c6ec7bb6e7975dbee5e438808162", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-02-17T07:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-30T20:34:25.000Z", "max_forks_repo_path": "manual/adjoint.tex", "max_forks_repo_name": "landreman/regcoil", "max_forks_repo_head_hexsha": "99f9abf8b0b0c6ec7bb6e7975dbee5e438808162", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2016-12-13T18:15:05.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-07T20:58:01.000Z", "avg_line_length": 46.6916167665, "max_line_length": 918, "alphanum_fraction": 0.7552420648, "num_tokens": 4636, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038302, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.4130692382200843}}
{"text": "\\subsection{Tuning Rules According to Ziegler-Nichols (Oscillation Method)}\n\nThis method relies on a plant that can potentially become unstable. That is to\nsay,  the  plant  must be of higher order such  that  the  phase  crosses  the\n\\SI{180}{\\degree} threshold at some point. If this is the case, then the plant\ncan be  placed  in a closed loop with a single gain element (P-Controller) and\nthe gain can be  increased  until  the  system's  output  begins to oscillate.\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=\\imagewidth]{images/osc_method.png}\n\\end{figure}\n\nThe gain at which this occurs  is  $K_{p,crit}$  and  the  period  at which it\noscillates is $\\tau_{crit}$.\n\nThe full procedure of the Ziegler-Nichols method is:\n\n\\begin{enumerate}\n    \\item Use a pure P controller and set a small gain $K_{P}$.\n    \\item Increasing the gain $K_{P}$ until an undamped oscillation occurs.\n    \\item Indentify the critical gain $K_{p,crit}$ and the critical period $\\tau_{crit}$\n    \\item According to table \\ref{tab:ziegler_nichols} specifying the controllers parameter.\n\\end{enumerate}\n\n\\begin{center}\n    \\begin{threeparttable}\n        \\begin{tabular}{cccc}\n            \\toprule\n            Type & $K_{P}$                   &  $T_{i}$                   &  $T_{d}$ \\\\\n            \\midrule\n            P    &  $0.5  \\cdot K_{P,crit}$  &  -                         &  -                         \\\\\n            PI   &  $0.45 \\cdot K_{P,crit}$  &  $0.85 \\cdot \\tau_{crit}$  &  -                         \\\\\n            PID  &  $0.6  \\cdot K_{P,crit}$  &  $0.5 \\cdot \\tau_{crit}$   &  $0.12 \\cdot \\tau_{crit}$  \\\\\n            \\bottomrule\n        \\end{tabular}\n        \\caption{Table with controller parameters, according to the Ziegler-Nichols method (good disturbance rejection).}\n        \\label{tab:ziegler_nichols}\n    \\end{threeparttable}\n\\end{center}\n\nThe advantage of the Ziegler-Nichols method is  that it is simple to apply and\nbecause of that also easy to understand. On the  other  hand  it is very risky\nbecause the control loop must be operated close to instability.  Dependong  on\nthe  plant  being  measured  this  can  be  very dangerous and very expensive.\n\nA  disadvantage  is  the  need  for  the  plant to  be  potentially  unstable.\nTheoretically not all plants can be made to oscillate in a closed  loop with a\nP-controller. The  practical  significance  of  this  method  is thus limited.\n\n", "meta": {"hexsha": "034ffbe57596b9b134950182de1ada6de8d7b649", "size": 2421, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "versuche/rtGL/labor2/sections/theory/ziegler_nichols.tex", "max_stars_repo_name": "TheComet93/laborjournal", "max_stars_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_stars_repo_licenses": ["WTFPL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "versuche/rtGL/labor2/sections/theory/ziegler_nichols.tex", "max_issues_repo_name": "TheComet93/laborjournal", "max_issues_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_issues_repo_licenses": ["WTFPL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "versuche/rtGL/labor2/sections/theory/ziegler_nichols.tex", "max_forks_repo_name": "TheComet93/laborjournal", "max_forks_repo_head_hexsha": "5b83c35ec2580a22106d755f466dc6371d7444ee", "max_forks_repo_licenses": ["WTFPL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.4705882353, "max_line_length": 121, "alphanum_fraction": 0.6476662536, "num_tokens": 682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.4130194214963232}}
{"text": "We present three benchmakrs in the poster:\n\n\\subsection{Standard Poisson systems}\n\n    \\subsubsection{Description}\n    This benchmark provides a reference to users whose CFD codes solve standard Poisson systems.\n    For this purpose, we measured only the run time of solving the system, that is, the calls to\n    \\lstinline[language=C++, basicstyle=\\ttfamily]|KSPSolve| and\n    \\lstinline[language=C++, basicstyle=\\ttfamily]|solve(x, rhs)|.\n    The  function \\lstinline[language=C++, basicstyle=\\ttfamily]|solve(x, rhs)|\n    covers MPI communications and data conversion and transfer,\n    so timing the call to this\n    function gives a performance indication of our wrapper, rather than only \n    of the solution behavior on GPUs.\n\n    The benchmarks use conjugate-gradient solvers on both CPUs and GPUs.\n    The preconditioner for the CPU solver is Hypre BoomerAMG \n    (through PETSc's interface),\n    whereas the preconditioner of the GPU solver is classical algebraic multigrid -- \n    described as a GPU implementation of Hypre BoomerAMG in the AmgX\n    manual\\cite[see][p.130]{amgx-manual}.\n\n    \\subsubsection{Results}\n    With 25M unknowns,\n    four\\footnotemark[2] NVIDIA K20s can compete with about 100\\footnotemark[3] \n    CPU cores in 2D problems;\n    in 3D, eight K20s can compete with about 256 CPUs.\n    For 2D problems with 100M unknowns and 3D problems with 50M unknowns,\n    32 K20s can compete with about 400 CPU cores.\n\n\\subsection{Flying snake simulations -- an application of PetIBM}\n\n    \\subsubsection{Description}\n    This benchmark intends to show how multi-GPU computing can accelerate a real\n    PETSc-based CFD code through an actual application.\n    The CFD code we chose is PetIBM\\cite{petibm-repo}, \n    and the application is simulating the flow around a flying-snake's cross-section\\cite{Krishnan-2013-ID33}.\n\n    PetIBM, our group's PETSc-based CFD code, offers a Navier-Stokes solver based on \n    the formulation of Taira and Colonius\\cite{Taira-2007-ID69}, in which a modified \n    Poisson system is solved at each time step.\n    Solving this modified Poisson system takes over 90\\% of run rime on CPUs.\n    We only applied multi-GPU linear solvers on this part, while keeping all other\n    calculations on CPUs.\n\n    We attempt a fair comparison using the same nodes of the cluster, with\n    the GPU runs exploiting two available NVIDIA K20s on each node\n    (each node has 12 physical CPU cores).\n    We also ran the benchmark on a workstation, having 6 physical \n    CPU cores and up to two NVIDIA K40c GPUs.\n\n    We obtain the best run times on the GPU cases with conjugate-gradient solvers and \n    aggregation multigrid preconditioners.\n    For the CPU cases, we used stabilized biconjugate-gradient solvers and GAMG \n    preconditioners, given that (to the best of our knowledge) there is no \n    counterpart implementation of aggregation multigrid in PETSc,\n    and the combination of stabilized biconjugate-gradient and GAMG gave \n    the best result in this case.\n\n    \\subsubsection{Results}\n    The overall speed-up provided by only one GPU node is \n    competitive with about 20 nodes of a CPU cluster. \n    On a workstation, one K40c GPU can compete with about 16 nodes of a CPU cluster.\n\n\\subsection{Amazon EC2}\n\n    \\subsubsection{Description}\n    The previous benchmark shows that enabling multi-GPU computing in a CFD code can\n    size down the clusters required for running simulations.\n    This comes with a cost saving to research based on CFD simulations.\n    We experimented with the same flying-snake simulations on Amazon EC2 to give \n    an example of the cost savings.\n    We compared the simulation executed on an 8-node CPU cluster (c4.8xlarge)\n    versus a single GPU node (g2.8xlarge). \n\n    \\subsubsection{Results}\n    The result indicates a 3.1x speed-up and a 16x cost saving on Amazon EC2\n    when exploiting the GPU nodes.\n\n\\footnotetext[2]{\n    The number of GPUs presented in the text is the minimum number of GPUs needed \n    due to limited memory on a single GPU.\n}\n\n\\footnotetext[3]{\n    The comparable numbers of CPU cores are estimated based on \n    good scaling shown in the benchmarks (see figures on the poster).\n    This is a conservative estimate for our purposes (i.e., favors the CPU case).\n}\n", "meta": {"hexsha": "0f9310eff5092cf7bc3862afc489928c6d45a2be", "size": 4282, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SC2016/abstract/secIII_benchmarks.tex", "max_stars_repo_name": "barbagroup/conferences", "max_stars_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-01T03:23:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T03:23:03.000Z", "max_issues_repo_path": "SC2016/abstract/secIII_benchmarks.tex", "max_issues_repo_name": "barbagroup/conferences", "max_issues_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-05-20T09:32:36.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-20T09:32:36.000Z", "max_forks_repo_path": "SC2016/abstract/secIII_benchmarks.tex", "max_forks_repo_name": "barbagroup/conferences", "max_forks_repo_head_hexsha": "5fc1bda55348242043054000dd5a20366410897e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-12-13T07:09:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-01T03:23:13.000Z", "avg_line_length": 47.5777777778, "max_line_length": 110, "alphanum_fraction": 0.7475478748, "num_tokens": 1046, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.538983220687684, "lm_q1q2_score": 0.4130194157429692}}
{"text": "\\documentclass[a4paper]{article}\n\n\\input{temp}\n\n\\begin{document}\n\n\\title{Revision Questions}\n\\date{Easter 2016}\n\n\\maketitle\n\n\\newpage\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Introduction}\nThere are many tripos questions which are far more than enough for anyone who is keen to practice. These questions are, however, usually targeted at the fundamental ideas, and can be used as a check list when you think you have finished revision on a course.\n\n\\newpage\n\n\\section{Groups}\n\n\\newpage\n\n\\section{Vector Calculus}\n\n\\subsection{Problem 1}\nExplain what is meant by saying that $f$ is a \\emph{scalar field}.\\\\\nLet $f$ be a scalar field, $\\mathbf{a}$ be a point in the space where $f$ is defined. Show that the direction in which $f$ is increasing at the greatest rate is the direction of $\\nabla f$ at that point.\\\\\nLet a surface $S$ be defined by $f=c$ where $c$ is a constant, and let $\\mathbf{b}$ be a point on the surface. Show that $\\nabla f$ at $\\mathbf{b}$ is normal to the surface.\n\n\\subsection{Problem 2}\nDeduce the relationship between the basis vectors $\\mathbf{e}_r,\\mathbf{e}_\\varphi,\\mathbf{e}_\\theta$ of the spherical polar coordinate system and $\\mathbf{e}_x,\\mathbf{e}_y,\\mathbf{e}_z$ of the Cartesian coordinate system.\\\\\nLet $S$ be a surface of sphere of radius $a$. Show that the scalar area element is given by\n\\begin{equation*}\n\\begin{aligned}\ndS = a^2 \\sin\\theta d\\theta d\\varphi.\n\\end{aligned}\n\\end{equation*}\n\n\\subsection{Problem 3}\nState what is the \\emph{curl} of a vector field $\\mathbf{F}$ in 3 dimensions.\\\\\nState Green's theorem.\\\\\nState Stoke's theorem.\\\\\nProve that Green's theorem and Stoke's theorem are equivalent.\n\n\\subsection{Problem 4}\nLet $\\mathbf{F}$ be a vector field in $\\R^3$. Show that the following three statements are equivalent to each other:\\\\\ni) $\\mathbf{F}=\\nabla f$ for some scalar field $f$;\\\\\nii) $\\int_C \\mathbf{F}\\cdot d\\mathbf{r}$ is independent of $C$ for fixed endpoints and orientation;\\\\\niii) $\\nabla\\times\\mathbf{F}=0$.\n\n\\subsection{Problem 5}\nLet $C$ be a curve in $\\R^n$. State what is meant by a \\emph{parameterisation} of it.\\\\\nExplain why\n\\begin{equation*}\n\\begin{aligned}\n\\mathbf{r}:[0,4\\pi) \\to \\R^2\n\\end{aligned}\n\\end{equation*}\nwith\n\\begin{equation*}\n\\begin{aligned}\n\\theta \\to \\left(\\cos\\theta,\\sin\\theta\\right)\n\\end{aligned}\n\\end{equation*}\nis \\emph{not} a parameterisation of the unit circle centred at the origin.\\\\\nState what is the \\emph{arclength} of $C$.\\\\\nShow that the arclength of $C$ is not changed under different parameterisations.\n\n\\subsection{Problem 6}\nLet $f$ be a scalar field and $\\mathbf{F}$ be a vector field in $\\R^3$.\\\\\nConsider $f\\left(\\mathbf{r}\\left(u,v,w\\right)\\right)$ in an orthogonal curvilinear coordinate system. Show that \n\\begin{equation*}\n\\begin{aligned}\n\\nabla f = \\frac{1}{h_u} \\frac{\\partial f}{\\partial u} \\mathbf{e}_u + \\frac{1}{h_v} \\frac{\\partial f}{\\partial v} \\mathbf{e}_v + \\frac{1}{h_w} \\frac{\\partial f}{\\partial w} \\mathbf{e}_w\n\\end{aligned}\n\\end{equation*}\nwhere $h_u, h_v, h_w$ satisfy\n\\begin{equation*}\n\\begin{aligned}\n\\frac{\\partial \\mathbf{r}}{\\partial u} = h_u \\mathbf{e}_u, \\frac{\\partial \\mathbf{r}}{\\partial v} = h_v \\mathbf{e}_v, \\frac{\\partial \\mathbf{r}}{\\partial w} = h_w \\mathbf{e}_w.\n\\end{aligned}\n\\end{equation*}\n(non-examinable?)\\\\\nDeduce the formula of $\\nabla f$, $\\nabla \\cdot \\mathbf{F}$, $\\nabla \\times \\mathbf{F}$ in cylindrical polar coordinates.\\\\\nDeduce the formula of $\\nabla f$, $\\nabla \\cdot \\mathbf{F}$, $\\nabla \\times \\mathbf{F}$ in spherical polar coordinates.\n\n\\subsection{Problem 7}\nState Gauss' Law of gravitation.\\\\\nAssuming mass is distributed with spherical symmetry, deduce Newton's law of gravitation for point masses from Gauss' Law of gravitation.\\\\\nDeduce that\n\\begin{equation*}\n\\begin{aligned}\n\\nabla\\cdot \\mathbf{g} = -4\\pi G \\rho.\n\\end{aligned}\n\\end{equation*}\nDeduce that\n\\begin{equation*}\n\\begin{aligned}\n\\nabla^2 \\mathbf{F} = \\nabla\\left(\\nabla\\cdot\\mathbf{F}\\right) - \\nabla \\times \\left(\\nabla\\times\\mathbf{F}\\right).\n\\end{aligned}\n\\end{equation*}\nHence a gravitational potential $\\varphi$ can be chosen such that\n\\begin{equation*}\n\\begin{aligned}\n\\nabla^2 \\varphi = 4\\pi G\\rho\n\\end{aligned}\n\\end{equation*}\nwith $-\\nabla \\varphi = \\mathbf{g}$.\n\n\\subsection{Problem 8}\nDescribe what is a \\emph{Dirichlet condition} and what is a \\emph{Neumann condition}.\\\\\nState and prove the Uniqueness theorem.\\\\\nProve Green's First and Second identities:\n\\begin{equation*}\n\\begin{aligned}\n\\int_S \\left(u\\nabla v\\right) \\cdot dS = \\int_V \\left(\\nabla u\\right) \\cdot\\left(\\nabla v\\right) dV + \\int_V u\\nabla^2 v dV,\\\\\n\\int_S \\left(u\\nabla v - v\\nabla u\\right) \\cdot d\\mathbf{S} = \\int_V \\left(u\\nabla^2 v - v\\nabla^2 u \\right) dV.\n\\end{aligned}\n\\end{equation*}\n\n\\subsection{Problem 9}\nExplain what is a \\emph{harmonic function}.\\\\\nState and prove the mean value property for harmonic functions.\\\\\nIf $\\varphi$ is a harmonic function in a region $V$, show that it can't take a minimum or maximum at an interior point of $V$.\n\n\\subsection{Problem 10}\nState the Maxwell's equations.\\\\\nShow that\n\\begin{equation*}\n\\begin{aligned}\n\\frac{\\partial \\rho}{\\partial t}+ \\nabla \\cdot \\mathbf{j} = 0.\n\\end{aligned}\n\\end{equation*}\n\n\\subsection{Problem 11}\nExplain what is a \\emph{tensor}. Explain what is the \\emph{rank} of a tensor.\\\\\nState the \\emph{tensor transformation rule}.\\\\\nLet $\\mathbf{u},\\mathbf{v},...,\\mathbf{w}$ be n vectors. Explain why\n\\begin{equation*}\n\\begin{aligned}\nT_{ij...k} = u_i v_j ... w_k\n\\end{aligned}\n\\end{equation*}\nis a rank $n$ tensor.\n\nIn the following problems, the tensors are \nby default Cartesian tensors.\n\n\\subsection{Problem 12}\nDefine the \\emph{tensor product}, and show that the tensor product of two tensors is still a tensor.\\\\\nExplain what is meant by saying that a tensor is \\emph{antisymmetric} in some two indices.\n\n\\subsection{Problem 13}\nShow that a rank $n$ tensor is equivalent to a multilinear map from $n$ vectors to $\\R$.\n\n\\subsection{Problem 14}\nState and prove the quotient rule of tensors. Prove that its converse is also true.\n\n\\subsection{Problem 15}\nExplain what is a \\emph{tensor field}.\\\\\nLet $T_{ij...k}$ be a rank $n$ tensor. Show that\n\\begin{equation*}\n\\begin{aligned}\n\\frac{\\partial}{\\partial x_p} T_{ij...k}\n\\end{aligned}\n\\end{equation*}\nis a rank $n+1$ tensor.\n\n\\subsection{Problem 16}\nState and prove the divergence theorem for tensors.\n\n\\newpage\n\n\\section{Differential Equation}\n\n\\newpage\n\n\\section{Probability}\n\n\\newpage\n\n\\section{Vectors and Matrices}\n\n\\newpage\n\n\\section{Analysis}\n\n\\newpage\n\n\\section{Numbers and Sets}\n\n\\newpage\n\n\\section{Dynamics and Relativity}\n\n\\subsection{Problem 1}\nDefine \\emph{central force}.\\\\\nState the formula of \\emph{angular momentum}. Prove that it is conserved by a central force.\n\n\\subsection{Problem 2}\nDefine \\emph{gravitational potential energy} and \\emph{gravitational potential}.\\\\\nFor a planet with radius $R$ and mass $M$, find its escape velocity.\n\n\\subsection{Problem 3}\nState the formula for the force experienced by a particle with charge $q$ and velocity $\\mathbf{v}$ in an electric field $\\mathbf{E}$ and magnetic field $\\mathbf{B}$.\\\\\nShow that, for time independent electric field and magnetic field, the energy\n\\begin{equation*}\n\\begin{aligned}\nE=\\frac{1}{2}m|\\mathbf{v}|^2 + q \\phi_e\n\\end{aligned}\n\\end{equation*}\nis conserved.\n\n\\subsection{Problem 4}\n\n\n\n\n\\newpage\n\n\\end{document}", "meta": {"hexsha": "70d29a642a06efd7ec3ccd0badd3d903e7162630", "size": 7339, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/revision_2016.tex", "max_stars_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_stars_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T17:34:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T17:34:25.000Z", "max_issues_repo_path": "Notes/revision_2016.tex", "max_issues_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_issues_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/revision_2016.tex", "max_forks_repo_name": "raoxiaojia/raoxiaojia.github.io", "max_forks_repo_head_hexsha": "d20c23a64794b500f2e0356fd01017ee31830fa2", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6177777778, "max_line_length": 258, "alphanum_fraction": 0.7246218831, "num_tokens": 2376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7718434978390746, "lm_q1q2_score": 0.4130122428393562}}
{"text": "\\documentclass[11 pt]{scrartcl}\n\\usepackage[header, margin, koma]{tyler}\n\n\\newcommand{\\hwtitle}{Discussion 1B Recap}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\fancyhead[l]{\\hwtitle{}}\n\\fancyhead[r]{Tyler Zhu}\n\\cfoot{\\thepage}\n\n\\begin{document} \n\\title{\\Large \\hwtitle{}}\n\\author{\\large Tyler Zhu}\n\\date{\\large September 4, 2020}\n\n\\maketitle \n\n\\section{Induction}\n\nInduction is typically most helpful when we try to prove statements of the form: $(\\forall n\\in \\NN), P(n)$ is true. This happens in three steps:\n\\itemnum\n    \\ii \\styl{Base Case}: Prove that $P(0)$ is true.\n    \\ii \\styl{Induction Hypothesis}: Assume that for any $k \\geq 0$, $P(k)$ is true. \n    \\ii \\styl{Inductive Step}: Prove that $P(k+1)$ is true, showing that $P(k) \\implies P(k+1)$. \n\\itemend\n\nWhen writing induction proofs for homework or for exams, be sure to state these three steps clearly for maximal points. \n\nInduction used like this is typically referred to as \\emph{weak} induction, in contrast with \\emph{strong} induction, where in the IH we instead make the assumption that for all $0\\leq k' \\leq k$, $P(k')$ is true.  \n\nLet me reinforce the relationship between weak and strong induction. If we have a statement $P(n)$ for integer $n \\geq 0$, then weak induction proves $P(0)$ and $P(k) \\implies P(k+1)$. So in this framework, if a statement $P(5)$ is true, it must have been proved through the connection $P(0) \\implies P(1) \\implies P(2) \\implies \\dots \\implies P(5)$, meaning that if $P(5)$ is true, $P(k')$ is true for $0\\leq k' \\leq 4$.\n\nBut that's precisely what strong induction is! To prove $P(k+1)$, we assume that $P(k')$ is true for $0 \\leq k' \\leq k$. Hence, strong and weak induction are the same, aside from their assumptions. So you don't need to worry about whether you should use strong or weak induction and just worry about what base assumptions you need in order to prove $P(k+1)$. \n\n\\section{Tips}\n\\itemnum\n    \\ii To show the IS, take $k+1$ case, break it down to the $k$ case, apply the induction hypothesis, and re-extend to the $k+1$ case. In other words, start with the statement of $P(k+1)$ and manipulate until you can apply the induction hypothesis of $P(k)$, then show that $P(k+1)$ follows. This is the standard way to use induction, and is more useful than you'd expect.  \n    \\ii For purely algebraic proofs, you can feel free to manipulate from the LHS to the RHS or vice versa, but do not modify both sides at the same time. This works because algebra is symmetric. \n    \\ii If you need more room for bounds or arguing in the IS, consider \\emph{strengthening the hypothesis}, i.e. make a claim which is more specific which implies your statement. It's counterintuitive that we would try to instead prove a harder statement, but the extra assumptions often help in induction. \n\\itemend\n\n\\end{document}\n", "meta": {"hexsha": "6d4799627edda4aff8d9dc0b98cf6b78f9ed3d3d", "size": 2810, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CS70/recap1a/recap1b.tex", "max_stars_repo_name": "cbugwadia32/course-notes", "max_stars_repo_head_hexsha": "cc269a2606bab22a5c9b8f1af23f360fa291c583", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2021-07-20T19:22:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T01:19:16.000Z", "max_issues_repo_path": "CS70/recap1a/recap1b.tex", "max_issues_repo_name": "cbugwadia32/course-notes", "max_issues_repo_head_hexsha": "cc269a2606bab22a5c9b8f1af23f360fa291c583", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CS70/recap1a/recap1b.tex", "max_forks_repo_name": "cbugwadia32/course-notes", "max_forks_repo_head_hexsha": "cc269a2606bab22a5c9b8f1af23f360fa291c583", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-13T08:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T17:21:17.000Z", "avg_line_length": 63.8636363636, "max_line_length": 421, "alphanum_fraction": 0.7252669039, "num_tokens": 810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.4130122400310408}}
{"text": "\\documentclass{article}\n\n\\usepackage{algpseudocode}\n\\usepackage{booktabs}\n\\usepackage{caption}\n\\usepackage{enumitem}\n\\usepackage{fontspec}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\usepackage{microtype}\n\\usepackage{sectsty}\n\\usepackage[table,xcdraw]{xcolor}\n\n\\allsectionsfont{\\sffamily}\n\\captionsetup{font=small,labelfont={bf,sf},margin=1.5em}\n\n\\title{Balanced Binary Search Trees}\n\\author{Florian Kretlow}\n\n\\begin{document}\n\n\\section{Red-Black-Tree}\n\n\\subsection{Introduction and general properties}\nA red-black-tree is a self-balancing binary search tree. In addition to the invariants\nof the latter, the former garantees that the tree remains roughly balanced even when it\nreceives input sequences that constitute pathological cases for normal binary search\ntrees (sorted input).\n\nEvery node in a red-black-tree is assigned one of two colors (traditionally red and\nblack). The following invariants hold after each insertion into, or deletion from a\nred-black-tree.\n\n\\begin{enumerate}[label=(\\arabic*)]\n\\item The root node of the tree is black. Every other node is either red or black.\n\\item If a node is red, it doesn't have a red child.\n\\item All paths from the root to a leaf go through the same number of black nodes.\n\\end{enumerate}\n\nIf \\(b\\) is the number of black nodes on every path from the root to a leaf, then the\nshortest possible path from the root to a leaf (which contains no red nodes) has a\nlength of \\(b\\), and the longest possible path (where black and red nodes alternate) has\na length of \\(2b\\).  Thus the invariants ensure that the lengths of any two paths from\nthe root to a leaf (i.e. the depths of any two leaf nodes) differ by at most a factor of\n2.\n\n\\[\n\\forall \\text{ leaf nodes } l_{i}, l_{j} \\in T : \\text{depth}(l_i) \\leq 2 \\cdot\n\\text{depth}(l_j)\n\\]\n\nThe balance is weaker than in an AVL tree (where the difference between the heights of\nthe left and right sub-trees of any sub-tree is at most 1). Consequently, operations on\na red-black-tree require fewer tree rotations, so they’re faster. Both red-black-trees\nand AVL trees get, insert, and delete elements in logarithmic time (\\(\\Theta(\\log n)\\)).\n\n\\subsection{Groups of Nodes}\nLet a \\emph{group} of nodes in a red-black-tree denote \\emph{any black node together\nwith all its direct red child nodes.} Every node in a red-black-tree belongs to exactly\none group: Every black node is the ‘head’ of its own group. Every red node belongs\nto the group of its black parent. Using the fact that every group contains exactly one\nblack node, we can rephrase invariant 3 as follows:\n\n\\begin{enumerate}[label=(\\arabic*)]\n\\setcounter{enumi}{2}\n\\item All paths from the root to a leaf go through the same number of groups.\n\\end{enumerate}\n\nThe \\emph{weight} of a group \\(g\\) is the number of nodes it contains, obviously \\(1\n\\leq \\text{weight}(g) \\leq 3\\). If \\(\\text{weight}(g) = 1\\), \\(g\\) is said to be\n\\emph{empty:} it doesn't contain any red child nodes.  If \\(\\text{weight}(g) = 3\\),\n\\(g\\) is said to be \\emph{full:} it contains two red child nodes and it's not possible\nto add another node to the group.  If \\(\\text{weight}(g) = 2\\), it's possible to rotate\n\\(g\\) in such a way that the former red child becomes the black root of the group, and\nthe former black root becomes a red child on the opposite site; this rotation does not\naffect any other group than \\(g\\).\n\n\\begin{figure}\n\\begin{centering}\n    \\includegraphics[scale=2]{img/groups.pdf}\n    \\caption{Possible groups in a red-black-tree. The direct ancestor of the head of a\n    group can be both red and black. Every direct descendant below a group is black.}\n\\end{centering}\n\\end{figure}\n\n\\subsection{Insertion}\nInsertion into a normal binary search tree is straightforward. You start at the root,\nand then you always go left if the new value is less than the current value, or you go\nright if it is greater. When you've nowhere left to go (i.e. you'd need to go left but\nthere's no left child, or the other way around) you simply add the value at that\nposition.\n\nIn order to preserve the invariants, inserting a node into a red-black-tree must not add\na new group to the tree (except at the very root where the addition affects all paths\nequally).  Therefore insertion is not possible if the direct parent of the to-be-added\nnode is part of a full group. The solution is to reduce the weight of that group: If \\(\n\\text{weight}(g) \\leq 2\\), it is possible to add a node to \\(g\\).\n\n\\begin{small}\n\\begin{verbatim}\nprocedure decrease-weight(n):\n    p := parent of n\n    pp := grandparent of n\n    l, r := children of n\n\n    // assume that n is black and l, r are red\n\n    case 1: n is the root of the tree\n        recolor:\n            l, r: black\n\n    case 2: p is black\n        recolor:\n            n: red\n            l, r: black\n\n    case 3: p is red\n        case 3.1: pp has 1 red child (p)\n            case 3.1a: pp->p->n is right-right or left-left\n                right-right: rotate-left(pp)\n                left-left: rotate-right(pp)\n                recolor:\n                    pp: red\n                    p: black\n                    n: red\n                    l, r: black\n            case 3.1b: pp->p->n is right-left or left-right\n                right-left:\n                    rotate-right(p)\n                    rotate-left(pp)\n                left-right:\n                    rotate-left(p)\n                    rotate-right(pp)\n                recolor:\n                    pp: red\n                    l, r: black\n\n        case 3.2: pp has 2 red children\n            decrease-weight(pp)\n            decrease-weight(n) // try again\n\nprocedure insert(n, v):\n    p := parent of n\n\n    if v == n.value:\n        return\n    else if v < n.value and n has a left child:\n        insert(n.left, v)\n        return\n    else if v > n.value and n has a right child:\n        insert(n.right, v)\n        return\n\n    case 1: n is black\n        if v < n.value:\n            n.left = new node(v, red)\n            n.left.parent = n\n        else:\n            n.right = new node(v, red)\n            n.right.parent = n\n\n    case 2: n is red\n        case 2.1: weight(p) = 2\n            decrease-weight(p)\n            // now n can be anywhere, go again:\n            insert(n, v)\n\n        case 2.2: weight(p) = 1\n            case 2.2.1: v < n.value and n = p.left\n                rotate-right(p)\n                n.left = new node(v, red)\n            case 2.2.2: v > n.value and n = p.right\n                rotate-left(p)\n                n.right = new node(v, red)\n            case 2.2.3: v < n.value and n = p.right\n                p.left = new node(v, red)\n                swap(p, p.left)\n            case 2.2.4: v > n.value and n = p.left\n                p.right = new node(v, red)\n                swap(p, p.right)\n\\end{verbatim}\n\\end{small}\n\n\\subsection{Deletion}\n\nDeletion is only possible if the group we delete from is not empty. Likewise, deleting a\nnode from the tree must not remove a group entirely (again, except at the root).\n\n\\begin{small}\n\\begin{verbatim}\nprocedure increase-weight(n):\n    p := parent of n\n    s := sibling of n\n\n    // case 1: ancestor group is not empty\n    if p is red or weight(p) >= 2:\n        if p is black:\n            if n == p.right:\n                rotate-right(p); s = p.left\n            else:\n                rotate-left(p); s = p.right\n\n        // case 1.1: s is empty\n        if weight(s) == 1:\n            recolor:\n                p: black\n                n, s: red\n\n        // case 1.2: s is not empty\n        else:\n            // make sure s has an outer child\n            if s == p.left and s.left is black:\n                rotate-left(s); s = p.left\n            else if s == p.right and s.right is black:\n                rotate-right(s); s = p.right\n\n            if n == p.right:\n                rotate-right(p)\n            else:\n                rotate-left(p)\n\n            recolor:\n                p: black\n                n, s: red\n                outer child of s: black\n\n    // case 2: ancestor group is empty\n    else:\n        // case 2.1: s is empty\n        if weight(s) == 1:\n            if p is root:\n                recolor:\n                    n, s: red\n            else:\n                increase-weight(p)\n                increase-weight(n)\n\n        // case 2.2: s is not empty\n        else:\n            // make sure s has an outer child\n            if s == p.left and s.left is black:\n                rotate-left(s); s = p.left\n            else if s == p.right and s.right is black:\n                rotate-right(s); s = p.right\n\n            if n == p.right:\n                rotate-right(p)\n            else:\n                rotate-left(p)\n\n            recolor:\n                n: red\n                outer child of s: black\n\n\nprocedure delete(n, v):\n    while v != n.value:\n        if v < n.value:\n            n = n.left\n        else if v > n.value:\n            n = n.right\n        if n == nil: return // not found\n\n    if n is not in a leaf position:\n        successor := n.right\n        while successor has a left child:\n            successor = successor.left\n        swap(n, successor)\n        // now n is where successor was, in a leaf position\n\n    if n is black and not the root and weight(n) == 1:\n        increase-weight(n)\n\n    if n is black:\n        if n has a left child:\n            rotate-right(n)\n        else:\n            rotate-left(n)\n\n    remove n from the tree\n\n\\end{verbatim}\n\\end{small}\n\n\\end{document}\n", "meta": {"hexsha": "3776f617ab7fd0f1d9b9117b4a7075878cd3684e", "size": 9416, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/red_black_tree.tex", "max_stars_repo_name": "fkretlow/libdsa", "max_stars_repo_head_hexsha": "2b1666f830098976cb153025e71fb0715da6a261", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/red_black_tree.tex", "max_issues_repo_name": "fkretlow/libdsa", "max_issues_repo_head_hexsha": "2b1666f830098976cb153025e71fb0715da6a261", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/red_black_tree.tex", "max_forks_repo_name": "fkretlow/libdsa", "max_forks_repo_head_hexsha": "2b1666f830098976cb153025e71fb0715da6a261", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9230769231, "max_line_length": 88, "alphanum_fraction": 0.5962192014, "num_tokens": 2433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4129556409982311}}
{"text": "\\documentclass[aspectratio=169]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage{hyperref}\n\\usepackage{amsmath,amsfonts,amsthm,bm}\n\\usepackage{color}\n\\usepackage{minted}\n\\usepackage{graphicx} % Allows including images\n\\usepackage{booktabs} % Allows the use of \\toprule, \\midrule and \\bottomrule in tables\n\\usepackage{tikz}\n\\usepackage[version=3]{mhchem}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=1.16} \n\\setminted{fontsize=\\scriptsize}\n\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=red,\n    filecolor=magenta,      \n    urlcolor=red,\n}\n\n\\DeclareMathOperator*{\\argmax}{argmax}\n\\DeclareMathOperator*{\\argmin}{argmin}\n\\let \\vec \\mathbf\n\n\\mode<presentation> {\n    \\usetheme{CambridgeUS}\n    \\setbeamertemplate{footline}[page number]\n    \\setbeamertemplate{navigation symbols}{}\n}\n\n\n\\title[Linear Methods]{Linear Methods}\n\n\\author{Shyue Ping Ong}\n\\institute[UCSD]{University of California, San Diego\\\\\n\\medskip\n}\n\\date{NANO281}\n\n\\begin{document}\n\n\n\\begin{frame}\n    \\titlepage % Print the title page as the first slide\n\\end{frame}\n\n\n\\begin{frame}{Overview}\n    \\tableofcontents\n\\end{frame}\n\n\n\\section{Preliminaries}\n\n\\begin{frame}{Preliminaries}\n    \\begin{itemize}\n        \\item We will go very deep into linear models.\n        \\item Most of you probably have seen linear models in some form, but we will start from scratch to further illustrate key concepts such as bias and variance.\n        \\item We will then discuss techniques such as regularization and transformation of inputs in the context of linear methods.\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Notation}\n    \\begin{itemize}\n        \\item Capital letters, e.g., $X$ denote variables.\n        \\item Lower-case letters e.g., $x$, denote observations.\n        \\item Dummy index $j$ to denotes different variables, e.g., $X_j$\n        \\item Dummy index $i$ to denotes different observations, e.g., $x_i$\n        \\item Bolded variables are vector/matrices, e.g., $\\vec{y}$, $\\vec{X}$\n    \\end{itemize}\n\\end{frame}\n\n\\section{Linear regression}\n\n\\begin{frame}{Linear Regression}\n    \\Huge{\\centerline{Linear Regression}}\n\\end{frame} \n\n\\begin{frame}{Simplest possible model between target and feature}\n    \\begin{equation*}\n        Y=f(X_1,X_2,...,X_p)= \\beta_0 + \\sum_{j=1}^p \\beta_j X_j\n    \\end{equation*}\n    $X_j$ can be:\n    \\begin{itemize}\n        \\item Quantitative inputs\n        \\item Transformations of quantitative inputs, e.g., log, exp, powers, etc.\n        Basis expansions, e.g., $X_2 = X_1^2$, $X_3 = X_1^3$\n        \\item Interactions between variables\n        \\item Encoding of levels of inputs\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Supervised learning}\n    \\begin{itemize}\n        \\item Given a set of paired observations $\\{x_{ij}, y_i\\}$, what are the model parameters (in this case, the coefficients $\\beta_j$) that are ``optimal''?\n        \\item ``Optimal'' is typically defined as minimization of some \\textbf{loss function} (also known as \\textbf{cost function}) that measures the error of the model.\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Least squares regression}\n    Consider the simple case of\n    \\begin{equation*}\n        Y = \\beta_0 + \\beta_1 X_1\n    \\end{equation*}\n    In least squares regression, the loss function is defined as the sum squared error given the $N$ observations:\n    \\begin{eqnarray*}\n        L(Y, \\hat{f}(X)) & = & \\sum_{i=1}^N (y_i - f(x_i))^2 \\\\\n        & = & \\sum_{i=1}^N (y_i - \\beta_0 - \\beta_1 x_{i1})^2\n    \\end{eqnarray*}\n    \\end{frame}\n\n    \\begin{frame}{What are the optimal parameters $\\beta_0$ and $\\beta_1$?}\n    \\begin{eqnarray*}\n        \\frac{\\partial L}{\\partial\\beta_0} & = & \\sum_{i=1}^N 2 (y_i - \\beta_0 - \\beta_1 x_{i1})(-1) = 0\\\\\n        \\implies & & \\sum_{i=1}^N y_i = N \\beta_0 + \\sum_{i=1}^N \\beta_1 x_{i1} \\\\\n        \\implies & & \\beta_0 = \\bar{y} - \\beta_1 \\bar{x_{1}} \\\\\n        \\frac{\\partial L}{\\partial\\beta_1} & = & \\sum_{i=1}^N 2 (y_i - \\beta_0 - \\beta_1 x_{i1}) (-x_{i1}) = 0\\\\\n        \\implies & & \\beta_1 = \\frac{\\sum_{i=1}^N x_{i1} y_i - N \\bar{x_1}\\bar{y}}{\\sum_{i=1}^N x_{i1}^2 - N \\bar{x_1}^2}\\\\\n    \\end{eqnarray*}\n    \\end{frame}\n\n    \\begin{frame}{Reformulating the general multiple linear regression as a vector equation…}\n    Considering $N$ observations of\n    \\begin{equation*}\n        y_i = \\beta_0 + \\beta_1 x_{i1} + + \\beta_2 x_{i2} + ... + \\beta_p x_{ip}\n    \\end{equation*}\n    Let\n    \\begin{equation*}\n        \\vec{y} = \\begin{pmatrix}y_1\\\\y_2\\\\...\\\\y_n\\end{pmatrix}, \\bm{\\beta} = \\begin{pmatrix}\\beta_0\\\\\\beta_1\\\\...\\\\\\beta_p\\end{pmatrix}, \\vec{X} = \\begin{pmatrix}1 & x_{11} & x_{12} & ... & x_{1p}\\\\\n        1 & x_{21} & x_{22} & ... & x_{2p}\\\\\n        \\vdots & & & & \\\\\n        1 & x_{N1} & x_{N2} & ... & x_{Np}\\end{pmatrix}, \n    \\end{equation*}\n    So, \n    \\begin{equation*}\n        \\vec{y} = \\vec{X}\\bm{\\beta} \n    \\end{equation*}\n    Note that $\\vec{y}$ is a $N \\times 1$ vector,\n    $\\bm{\\beta}$ is a $(p+1) \\times 1$ vector, and $\\vec{X}$ is a  $N \\times (p+1)$ matrix.\n\\end{frame}\n\n\n\\begin{frame}{Reformulating the general multiple linear regression as a vector equation…}\n    \\begin{equation*}\n        L = RSS = (\\vec{y} - \\vec{X}\\bm{\\beta})^T(\\vec{y} - \\vec{X}\\bm{\\beta})\n    \\end{equation*}\n    Assuming (for the moment) that $\\vec{X}$ has full column rank, and hence $\\vec{X}^T\\vec{X}$ is positive definite, It can be shown using the same principles that the following unique solution for $\\bm{\\beta}$ is:\n    \\begin{eqnarray*}\n        \\hat{\\bm{\\beta}} &=& (\\vec{X}^T \\vec{X})^{-1} \\vec{X}^T \\vec{y} \\\\\n        \\hat{\\vec{y}} & = & \\vec{X} \\hat{\\bm{\\beta}} = \\vec{X}(\\vec{X}^T \\vec{X})^{-1} \\vec{X}^T \\vec{y} \n    \\end{eqnarray*}\n\\end{frame}\n\n\n\\begin{frame}{Graphic representation of MLR with two dependent variables}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=0.3\\textwidth]{figures/fig3-1.pdf}\n        \\includegraphics[width=0.3\\textwidth]{figures/fig3-2.pdf}\n        \\caption{MLR minimizes sum square of residuals. The projection $\\vec{\\hat{y}}$ represents the vector of the least squares predictions onto the hyperplane spanned by the input vectors $\\vec{x_1}$ and $\\vec{x_2}$. \\cite{hastieElementsStatisticalLearning2016}.}\n    \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}{Validity of least squares criterion}\n    \\begin{itemize}\n        \\item Observations are independently drawn at random.\n        \\item Variance of $\\vec{y}$ is constant given by $\\sigma^2$.\n    \\begin{equation*}\n        \\mathrm{var}(\\hat{\\bm{\\beta}}) = (\\vec{X}^T \\vec{X})^{-1} \\sigma^2\n    \\end{equation*}\n    \\item and $\\sigma$ is estimated using:\n    \\begin{equation*}\n        \\sigma^2 = \\frac{1}{N-p-1}\\sum_{i=1}^N (y_i - \\hat{y_i})^2\n    \\end{equation*}\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Example materials data}\n    \\begin{columns}\n    \\begin{column}{0.6\\textwidth}\n        \\begin{itemize}\n            \\item Target: Bulk modulus of elements (from Materials Project)\n            \\item Candidate features:\n            \\begin{itemize}\n                \\item Melting point (MP)\n                \\item Boiling point (MP)\n                \\item Atomic number (Z)\n                \\item Electronegativity ($\\chi$)\n                \\item Atomic radius ($r$)\n            \\end{itemize}\n            \\item Question: Why these features?\n            \\item We will add some transformations of these inputs as well, i.e., the square and square root of the electronegativity and atomic radius.\n    \\end{itemize}\n    \\end{column}\n    \\begin{column}{0.3\\textwidth}\n        \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figures/elementdata.png}\n    \\end{figure}\n    \\end{column}\n\\end{columns}\n\\end{frame} \n\n\n\\begin{frame}[fragile]{Using pandas for easy data manipulation}\n    \\inputminted{python}{example_pandas_data_manipulation.py}\n\\end{frame} \n\n\n\\begin{frame}[fragile]{MLR in scikit-learn}\n\\inputminted{python}{example_sklearn_mlr.py}\n\\begin{itemize}\n    \\item Note that x should contain the features only - there is no need to add a 1 column for the intercept. By default, the parameter fit\\_intercept in sklearn.linear\\_model.LinearRegression is True. You can set it to False to do a MLR without intercept.\n    \\item Documentation: \\href{https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html}{link}.\n\\end{itemize}\n\n\\end{frame} \n\n\n\n\n\\begin{frame}{Hypothesis Testing for Coefficients}\n    \\begin{itemize}\n        \\item To derive insights into a model, we often want to know which of the input parameters are the most relevant to the target.\n        \\item Under assumptions of the errors in $y$ follow a Gaussian distribution $N(0, \\sigma^2)$, the errors in $\\hat{\\bm{\\beta}}$ also have a Gaussian distribution $N(\\beta, (\\vec{X}^T \\vec{X})^{-1} \\sigma^2)$\n        \\item Hypothesis testing can be carried out for whether a particular $\\beta_j$ is 0 using the following test statistic:\n        \\begin{equation*}\n        t_j = \\frac{\\hat{\\bm{\\beta_j}}}{\\sigma\\sqrt{v_j}}\n        \\end{equation*}\n        where $v_j$ is the $j$th diagonal element of $(\\vec{X}^T \\vec{X})^{-1}$. $t_j$ has a $t$ distribution with $N-p-1$ degrees of freedom (dof).\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Hypothesis Testing for Groups of Coefficients}\n    \\begin{itemize}\n        \\item More often, we want to test groups of coefficient for significance. E.g., to the $k$ levels of a categorical variable.\n        \\item We will use the following $F$ statistic:\n        \\begin{equation*}\n        F = \\frac{(\\mathrm{RSS}_0 - \\mathrm{RSS}_1)/(p_1-p_0)}{\\mathrm{RSS}_1/(N-p_1-1)}\n        \\end{equation*}\n        where $\\mathrm{RSS}_0$ is the RSS of the larger model with $p_0 + 1$ parameters and $\\mathrm{RSS}_1$ is the RSS of the smaller model with $p_1 + 1$ parameters with $p_0 - p_1$ parameters set to zero. The $F$ statistic has a distribution of $F_{p_1-p_0,N-p_1-1}$.\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Gauss-Markov Theorem}\n    \\begin{itemize}\n        \\item Consider the estimator $\\hat{\\theta}$ for a variable $\\theta$.\n        \\begin{eqnarray*}\n            \\mathrm{MSE} & = & E(\\hat{\\theta} - \\theta)^2 \\\\\n            & = & \\mathrm{var}(\\hat{\\theta}) + [E(\\hat{\\theta}) - \\theta]^2\n        \\end{eqnarray*}\n        \\item The MSE can be broken down into the variance of the estimate itself and the square of the bias.\n        \\begin{block}{Gauss-Markov Theorem}\n        The least squares estimator has the smallest variance among all linear \\textit{unbiased} estimators.\n        \\end{block}\n        \\item However, there can be estimators that are biased with smaller MSE.\n    \\end{itemize}\n\\end{frame}\n\n\n\n\\section{Model selection}\n\n\\begin{frame}{Model selection}\n    \\Huge{\\centerline{Model selection}}\n\\end{frame} \n\n\n\\begin{frame}{Model performance}\n    \\begin{itemize}\n        \\item We will take a brief digression into model assessment and selection before continuing on to other linear methods.\n        \\item Model performance is related to its performance on \\textit{independent test data}, i.e., one cannot simply report a model's performance on training data alone.\n        \\item Note that this section is deliberately limited to high level concepts that are needed to continue further in exploration of linear methods. A more detailed discussion will be performed in later lectures.\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Typical measures of model performance}\n    \\begin{itemize}\n        \\item Mean squared error (MSE):\n            \\begin{equation*}\n                L(Y, \\hat{f}(X)) = \\frac{1}{N}\\sum_{i=1}^N (y_i - f(x_i))^2\n            \\end{equation*}\n        \\item Mean absolute error (MAE):\n            \\begin{equation*}\n                L(Y, \\hat{f}(X)) = \\frac{1}{N}\\sum_{i=1}^N \\left| y_i - f(x_i) \\right|\n            \\end{equation*}\n        \\item Test error: $L$ over independent test set.\n        \\item Training error: $L$ over training set.\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Training and test errors with model complexity}\n    \\begin{itemize}\n        \\item Model complexity increases as the number of parameters increases (e.g., number of independent variables in MLR). \n        \\item Training errors \\textbf{always} decrease with increasing model complexity.\n        \\item However, test errors do not have a monotonic relationship with model complexity. Test errors are high when model complexity is too low (underfitting) or too high (overfitting).\n    \\end{itemize}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=0.35\\textwidth]{figures/fig7-1.pdf}\n    \\end{figure}\n\\end{frame}\n\n\n\\begin{frame}{Training, validation and test data}\n    \\begin{itemize}\n        \\item Model selection: estimating the performance of different models in order to choose the best one.\n        \\item Model assessment: having chosen a final model, estimating its prediction error (generalization error) on new data.\n        \\item Ideal data-rich situation: Divide data into three parts:\n        \\begin{itemize}\n            \\item Training set: For training the model.\n            \\item Validation set: For estimating prediction error to select the model.\n            \\item Test set: For assessing the generalization error of the final model.\n        \\end{itemize}\n        \\item Typical training:validation:test split is 50:25:25 or 80:10:10, or in very data-poor situations, maybe even 90:5:5.\n        \\item Note that at no point in the model fitting process should the test set be ``seen''.\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{$K$-fold cross validation (CV)}\n    \\begin{itemize}\n        \\item Simplest and most widely used approach for model validation.\n        \\item Data set is split into $K$ buckets (usually by random).\n        \\item Typical values of $K$ is 5 or 10. $K = N$ is known as ``leave-one-out'' CV.\n        \\begin{table}\n        \\begin{tabular}{|p{1.7cm}|p{1.7cm}|p{1.7cm}|p{1.7cm}|p{1.7cm}|}\n            \\hline\n            \\Large{Train} & \\Large{Train} & \\textcolor{red}{\\Large{Validate}} & \\Large{Train} & \\Large{Train}\\\\\n            \\hline\n        \\end{tabular}\n        \\end{table}\n        \\item CV score is computed on the validate data set after training on the train data:\n        \\begin{equation*}\n                CV(\\hat{f}^{-k(i)},\\alpha) = \\frac{1}{N_{k(i)}}\\sum_{i=1}^{N_{k(i)}} L(y_i, \\hat{f}^{-k(i)}(x_i,\\alpha))\n        \\end{equation*}\n        \\item assuming the $k^{th}$ data bucket has $N_{k(i)}$ data points and $\\hat{f}^{-k(i)}$ refers to the model fitted with the $k^{th}$ data left out ($N-N_{k(i)}$ data in fitting).\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[fragile]{CV in scikit-learn}\n\\inputminted{python}{example_sklearn_cv.py}\n\\begin{itemize}\n    \\item Note that we have customized the KFold object passed to the cross\\_validate method. The reason is that our element data is non-random by default. So we want to perform shuffling prior to doing the splits.\n    \\item Documentation: \\href{https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_validate.html?highlight=cross_validate#sklearn.model_selection.cross_validate}{link}.\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Characteristics of the example materials dataset}\n    \\begin{itemize}\n        \\item Before proceeding further, let us try to tease out some aspects of the dataset.\n        \\item Quite clearly, there are correlations between some sets of variables.\n        \\item In other words, the input features are \\textbf{non-orthonormal} with each other.\n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=0.35\\textwidth]{figures/pairplot-materialsdata.png}\n            \\includegraphics[width=0.45\\textwidth]{figures/paircorrelations-materialsdata.png}\n        \\end{figure}\n    \\end{itemize}\n\\end{frame}\n\n\n\\section{Beyond least squares}\n\n\n\\begin{frame}{Beyond least squares}\n    \\Huge{\\centerline{Beyond least squares}}\n\\end{frame} \n\n\\begin{frame}{Model selection}\n    \\begin{itemize}\n        \\item Often, we want to improve on the least squares model.\n        \\begin{itemize}\n            \\item To improve prediction accuracy by sacrificing some bias for reduced variance.\n            \\item To improve interpretability by reducing number of features or descriptors.\n        \\end{itemize}\n        \\item Three main approaches:\n        \\begin{enumerate}\n            \\item Subset selection\n            \\item Shrinkage methods\n            \\item Dimension reduction\n        \\end{enumerate}\n    \\end{itemize}\n\\end{frame}\n\n\n\\subsection{Subset selection}\n\n\\begin{frame}{Subset selection}\n    Best subset selection\n    \\begin{itemize}\n        \\item Brute force approach.\n        \\item From $p$ parameters, find the subset of $k$ parameters that results in the smallest RSS.\n        \\item Combinatorially expensive for large $p$ and large $k$.\n        \\item Note that the best subset for a larger $k$ does not necessarily include the best subset for a smaller $k$.\n    \\end{itemize}\n    Forward- or backward-stepwise selection\n    \\begin{itemize}\n        \\item Forward: Start with intercept, and iteratively add feature that most improves the fit.\n        \\item Backward: Start with full model, and sequentially deletes the feature with least impact on the fit.\n    \\end{itemize}\n\\end{frame} \n\n\n\\subsection{Shrinkage}\n\n\\begin{frame}{Shrinkage methods}\n    \\begin{itemize}\n        \\item Subset methods is discrete, i.e., retains/discards variables, and tends to exhibit high variance.\n        \\item Shrinkage methods are more continuous and do not suffer as much from high variability.\n        \\item Basic concept: instead of finding the parameters that minimizes the RSS only, we add a penalty term that penalizes more complex models, e.g., models with larger coefficients or larger number of coefficients. This ``shrinks'' the coefficients, in some cases, to 0.\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Ridge regression ($L_2$ regularization)}\n    \\begin{equation*}\n        \\hat{\\beta^{ridge}} = \\argmin_\\beta \\left \\{ \\sum_{i=1}^N (y_i - \\beta_0 - \\sum_{j=1}^p \\beta_j x_j)^2 + \\lambda \\sum_{j=1}^p \\beta_j^2 \\right \\}\n    \\end{equation*}\n    \\begin{itemize}\n        \\item $\\lambda \\geq 0$ is the shrinkage parameter. The larger the $\\lambda$, the greater the shrinkage.\n        \\item Also equivalent to:\n        \\begin{eqnarray*}\n        \\hat{\\beta^{ridge}} = \\argmin_\\beta \\sum_{i=1}^N (y_i - \\beta_0 - \\sum_{j=1}^p \\beta_j x_j)^2\\\\\n        \\mathrm{subject~to} \\sum_{j=1}^p \\beta_j^2 \\leq t\n        \\end{eqnarray*}\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Ridge regression - Key details}\n    \\begin{itemize}\n        \\item Intercept ($\\beta_0$) is not part of penalty term.\n        \\item Inputs should be scaled prior to performing ridge regression, typically by centering to the mean and scaling to unit variance:\n        \\begin{equation*}\n            z_j = \\frac{x_j - \\mu_{x_j}}{s_{x_j}}\n        \\end{equation*}\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{LASSO ($L_1$ regularization)}\n    \\begin{equation*}\n        \\hat{\\beta^{LASSO}} = \\argmin_\\beta \\left \\{ \\sum_{i=1}^N (y_i - \\beta_0 - \\sum_{j=1}^p \\beta_j x_j)^2 + \\lambda \\sum_{j=1}^p |\\beta_j| \\right \\}\n    \\end{equation*}\n    \\begin{itemize}\n        \\item Least Absolute Shrinkage and Selection Operator\n        \\item $\\lambda \\geq 0$ is the shrinkage parameter. The larger the $\\lambda$, the greater the shrinkage.\n        \\item Also equivalent to:\n        \\begin{eqnarray*}\n        \\hat{\\beta^{LASSO}} = \\argmin_\\beta \\sum_{i=1}^N (y_i - \\beta_0 - \\sum_{j=1}^p \\beta_j x_j)^2\\\\\n        \\mathrm{subject~to} \\sum_{j=1}^p |\\beta_j| \\leq t\n        \\end{eqnarray*}\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{LASSO regression - Key details}\n    \\begin{itemize}\n        \\item Intercept ($\\beta_0$) is not part of penalty term.\n        \\item Inputs should be scaled prior to performing lasso regression, just as in ridge regression.\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Subset vs ridge vs LASSO}\n    \\begin{itemize}\n        \\item Consider a set of orthonormal features.\n        \\begin{itemize}\n            \\item Ridge: proportional shrinkage. No coefficients are set to zero.\n            \\item LASSO: ``soft'' thresholding. Translates coefficients by a factor, truncating at zero.\n            \\item Best-subset: ``hard'' thresholding. Drops all coefficients below a certain threshold.\n        \\end{itemize}\n    \\end{itemize}\n    \\begin{figure}\n    \\begin{tikzpicture}[scale=0.35]\n\t\\begin{axis}[title=Best subset, grid=major]\n\t\\addplot[color=black, dashed] coordinates {\n\t\t(-9,-9)\n\t\t(9,9)\n\t};\n\t\\addplot[color=red] coordinates {\n\t\t(-9,-9)\n\t\t(-3,-3)\n\t\t(-3,0)\n\t\t(3,0)\n\t\t(3,3)\n\t\t(9,9)\n\t};\n\t\\end{axis}\n\t\\end{tikzpicture}\n    \\begin{tikzpicture}[scale=0.35]\n\t\\begin{axis}[title=Ridge, grid=major]\n\t\\addplot[color=black, dashed] coordinates {\n\t\t(-9,-9)\n\t\t(9,9)\n\t};\n\t\\addplot[color=red] coordinates {\n\t\t(-9,-7)\n\t\t(9,7)\n\t};\n\t\\end{axis}\n    \\end{tikzpicture}\n    \\begin{tikzpicture}[scale=0.35]\n\t\\begin{axis}[title=LASSO, grid=major]\n\t\\addplot[color=black, dashed] coordinates {\n\t\t(-9,-9)\n\t\t(9,9)\n\t};\n\t\\addplot[color=red] coordinates {\n\t\t(-9,-7)\n\t\t(-2,0)\n\t\t(2,0)\n\t\t(9,7)\n\t};\n\t\\end{axis}\n    \\end{tikzpicture}\n        \\includegraphics[width=0.35\\textwidth]{figures/fig3-14.pdf}\n    \\end{figure}\n\\end{frame} \n\n\n\\begin{frame}{Other variants of shrinkage methods}\n    \\begin{itemize}\n        \\item Elastic net penalty:\n        \\begin{eqnarray*}\n            \\lambda \\left( \\alpha \\sum_{j=1}^p \\beta_j^2+ (1-\\alpha) \\sum_{j=1}^p |\\beta_j| \\right)\n        \\end{eqnarray*}\n        \\item Least angle regression\n    \\end{itemize}\n\\end{frame}\n\n\n\\subsection{Derived input directions}\n\n\\begin{frame}{Derived input directions}\n    \\begin{itemize}\n        \\item General concept: transforms input $\\vec{X}$ into a smaller subset of $\\vec{z_m}$ and regress on $\\vec{z_m}$\n        \\item Principal component regression:\n        \\begin{itemize}\n            \\item Transform non-orthonormal features into orthonormal directions using Principal Component Analysis (PCA).\n            \\item Choose $M$ directions that have the highest eigenvalues (explains the most variance) and discards the rest.\n            \\item Will revisit at a later lecture.\n        \\end{itemize}\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Partial Least Squares (PLS)}\n    \\begin{itemize}\n        \\item Algorithm:\n        \\begin{enumerate}\n            \\item Compute $\\phi_{1j} = <\\vec{x_j}, \\vec{y}>$ for each $j$.\n            \\item First transformed direction $\\vec{z_1} = \\sum_j \\phi_{1j} \\vec{x_j}$, i.e., each direction is weighted by strength of effect on $\\vec{y}$.\n            \\item Regress $\\vec{y}$ on $\\vec{z_1}$ to obtain $\\theta_1$, orthogonalize $\\vec{x_1}, ... \\vec{x_p}$ wrt $\\vec{z_1}$ via $x_j' = x_j - \\frac{<\\vec{z_1}, \\vec{x_j}>}{<\\vec{z_1}, \\vec{z_1}>}\\vec{z_1}$.\n            \\item Repeat until $M \\leq p$ coefficients are obtained.\n        \\end{enumerate}\n        \\item Finds directions with high variance and high correlation with response.\n    \\end{itemize}\n\\end{frame} \n\n\n\\section{Extending linear methods}\n\n\\begin{frame}{Preliminaries}\n    \\begin{itemize}\n        \\item It is highly unlikely that the true function $f(X)$ is linear in $X$.\n        \\item In some cases, linearity is a reasonable assumption, e.g., a first order Taylor series expansion:\n        \\begin{equation*}\n            f(x) = f(a) + f'(a) (x-a) + f''(a) \\frac{(x-a)^2}{2!} + f'''(a) \\frac{(x-a)^3}{3!} + ...\n        \\end{equation*}\n        \\item Examples where this is used in materials science - linear elasticity (Hooke's law), etc.\n        \\item More frequently, we perform a transformation of inputs to create a linear basis expansion.\n    \\end{itemize}\n\\end{frame}\n\n\n\\section{Transformation of inputs}\n\n\\begin{frame}{General concept}\n    \\begin{itemize}\n        \\item Express:\n        \\begin{equation*}\n            f(X) = \\sum_{m=1}^M \\beta_m h_m(X)\n        \\end{equation*}\n        where $h_m$ is the $m^{th}$ transformation of $X$.\n        \\item This is known as a linear basis expansion in $X$.\n        \\item The key lies in choice of the basis functions $h_m$.\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Examples of basis expansions}\n    \\begin{itemize}\n        \\item $h_m(X) = X_j^2, h_m(X) = X_i X_j$\n        \\begin{itemize}\n            \\item Polynomial expansion to higher-order Taylor series terms.\n            \\item No. of terms increases exponentially with degree of polynomial. For $p$ variables, we have $O(p^2)$ square and cross-product terms in a quadratic model. For a degree $d$ polynomial, we have $O(p^d)$.\n        \\end{itemize}\n        \\item $h_m(X) = log(X_j), sqrt(X_j), exp(i X_j)$: non-linear transformations in $X$.\n        \\item $h_m(X) = I(L_m \\leq X_k < U_m)$: Piece-wise division of regions of $X$. E.g., cubic splines.\n        \\item $h_m(X) = RBF(||X-X_m||)$: radial basis function, e.g., Gaussian. \n        \\item Typically, basis functions are used simply to allow a more flexible representation of the data. The basis functions can span a very large (sometimes infinite) set, from which a selection has to be made:\n        \\begin{itemize}\n            \\item Restriction - Truncate the choice of basis functions using some criteria.\n            \\item Selection - Choose basis functions that contribute significantly to the fit.\n            \\item Regularization - Use the whole and/or very large subset and apply regularization techniques (e.g., ridge or LASSO) to restrict coefficients.\n        \\end{itemize}\n    \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Linearization from physical laws}\n    \\begin{itemize}\n        \\item Arrhenius law:\n        \\begin{equation*}\n            r = A \\exp(-\\frac{E_a}{RT}) \\longrightarrow log(r) = log(A) - \\frac{E_a}{RT}\n        \\end{equation*}\n        \\item Ising model:\n        \\begin{equation*}\n            H(\\sigma) = - \\sum_{<i, j>} J_{ij}\\sigma_i \\sigma_j - \\mu \\sum_j h_j \\sigma_j\n        \\end{equation*}\n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=0.3\\textwidth]{figures/ising.png}\n        \\end{figure}\n    \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{Compressive sensing for cluster expansions}\n    \\begin{itemize}\n        \\item Cluster expansion of energy on lattice points:\n        \\begin{equation*}\n            H(\\sigma) = E_0 + \\sum_f J_f \\prod_f(\\sigma)\n        \\end{equation*}\n        \\item $\\sigma$ is the vector representing occupation of lattice sites, $\\prod_f$ are the cluster basis functions, $J_f$ are effective cluster interactions (ECIs).\n        \\item Compressive sensing: essentially a LASSO to solve for ECIs.\\cite{nelsonCompressiveSensingParadigm2013}\n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=0.3\\textwidth]{figures/numberofclusters.png}\n            \\includegraphics[width=0.3\\textwidth]{figures/ecifit.pdf}\n        \\end{figure}\n    \\end{itemize}\n\\end{frame} \n\n\\section{Piece-wise polynomials}\n\n\\begin{frame}{Piecewise polynomials}\n    \\begin{equation*}\n        h_1(X) = I(X < \\xi_1), h_2(X) = I(\\xi_1 \\leq X < \\xi_2), h_3(X) = I(X \\geq \\xi_2)\n    \\end{equation*}\n    \\begin{columns}\n    \\column{0.3\\textwidth}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figures/piecewisefits.pdf}\n    \\end{figure}\n    \\column{0.7\\textwidth}\n    Parameters:\n    \\begin{itemize}\n        \\item No. of knots\n        \\item Order of polynomial\n        \\item Continuity at knots (value, first derivative, second derivative, etc.). For a polynomial of order $N$, we usually want all derivatives $< N$ to be continuous. \n    \\end{itemize}\n    \\end{columns}\n\\end{frame} \n\n\n\\begin{frame}{Cubic splines}\n    \\begin{columns}\n    \\column{0.5\\textwidth}\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=0.7\\textwidth]{figures/piecewisecubic.pdf}\n    \\end{figure}\n    \\column{0.5\\textwidth}\n    \\begin{itemize}\n        \\item Probably the most commonly used.\n        \\item Continuous 1st and 2nd derivatives.\n        \\item Natural cubic spline: polynomial is linear beyond boundaries.\n        \\item Smoothing spline: Use  regularization to control complexity:\n        \\begin{eqnarray*}\n            RSS(f, \\lambda) = \\sum_{i=1}^N \\{y_i - f(x_i)\\} ^ 2 \\\\\n            + \\lambda \\int \\{f''(t)\\}^2 dt\n        \\end{eqnarray*}\n    \\end{itemize}\n    \\end{columns}\n\\end{frame}\n\n\n\\begin{frame}{Examples of cubic spline fitting}\n    \\begin{itemize}\n        \\item Spline-based Modified Embedded Atom Method (MEAM)\n        \\begin{eqnarray*}\n            E = \\sum_{i <j} \\phi(r_{ij}) + \\sum_i U(n_i), \\\\\n            n_i = \\sum_j \\rho(r_{ij}) + \\sum_{i < k, j,k!=i} f(r_{ij}) f(r_{ik})g[cos(\\theta_{jik})]\n        \\end{eqnarray*}\n        where $\\phi$, $U$, $\\rho$, $f$ and $g$ can be approximated by cubic splines. \n        \\begin{figure}\n            \\centering\n            \\includegraphics[width=0.3\\textwidth]{figures/meam-phi.png}\n            \\includegraphics[width=0.3\\textwidth]{figures/meam-u.png}\n\n        \\end{figure}\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}[fragile]{Demo: Cubic spline fitting in scipy}\n    \\inputminted{python}{example_sklearn_spline.py}\n\\end{frame} \n\n\n\\section{Gaussian basis functions}\n\n\n\\begin{frame}{Gaussian basis functions}\n    \\begin{equation*}\n        h_m(x) = \\exp(-k(x - x_m) ^ 2)\n    \\end{equation*}\n    \\begin{itemize}\n        \\item Gaussian functions centered at $x_m$.\n        \\item Other similar types of functions include Lorentzian ($h_m(x) = \\frac{1}{1 + kx^2}$), Gaussian-Lorentzian, Voigtian, Pearson type IV, and beta profiles.\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Example: Rietveld refinement}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.45\\textwidth]{figures/rietveld.pdf}\n    \\caption{Neutron powder diffraction diagram of \\ce{CaUO4}}\n\\end{figure}\n    \\begin{itemize}\n        \\item Least squares fitting of theoretical line profile to match a measured diffraction pattern (e.g., X-ray, neutron).\\cite{rietveldProfileRefinementMethod1969}\n    \\end{itemize}\n\\end{frame} \n\n\n\\begin{frame}{Example: Rietveld refinement, contd.}\n    \\begin{itemize}\n        \\item Peak shape function:\n        \\begin{equation*}\n            PSF(\\theta) = \\Omega(\\theta) \\otimes \\Lambda(\\theta) \\otimes \\Psi(\\theta) + b(\\theta)\n        \\end{equation*}\n        \\item $\\Omega$: Instrument broadening, $\\Lambda$: Wavelength dispersion, $\\Psi$: Specimen function.\n        \\item For single phase, minimize:\n        \\begin{equation*}\n            \\Phi = \\sum_{i=1}^N w_i \\left ( Y_i^{obs} - \\left ( b_i + K \\sum_{j=1}^m I_jy_j(x_j)\\right )\\right )^2\n        \\end{equation*}\n        \\item where $y_j(x_j)$ is typically a pseudo-Voigt (mix of Gaussian and Lorentizan function) function.\n        \\item Note that the background ($b_i$) holds no useful structural information and should be minimized in experiments.\n    \\end{itemize}\n\\end{frame} \n\n\n\n\\section{Wavelet and Fourier basis functions}\n\n\n\\begin{frame}\n\\frametitle{Wavelet smoothing}\n\\begin{columns}\n\\column{0.4\\textwidth}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/wavelets.pdf}\n\\end{figure}\n\\column{0.6\\textwidth}\n    \\begin{itemize}\n        \\item Complete orthonormal basis\n        \\item Shrink and select toward \\textbf{sparse} representation.\n        \\item Able to represent both time and frequency localization efficiently (Fourier basis can only do frequency localization).\n    \\end{itemize}\n\\end{columns}\n\\end{frame} \n\n\n\\begin{frame}{Example: NMR Spectroscopy}\n\\begin{columns}\n\\column{0.4\\textwidth}\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.45\\textwidth]{figures/nmrwavelet.pdf}\n    \\caption{Subtraction of a large spectral line: (top) the original spectrum of polyethylene, (bottom) reconstructed spectrum after removal of \\ce{CH2} peak.\\cite{baracheContinuousWaveletTransform1997}}\n\\end{figure}\n\\column{0.6\\textwidth}\n    Applications:\n    \\begin{itemize}\n        \\item Suppression of large unwanted spectral line (left).\n        \\item Rephasing spectrum perturbed by time-dependent magnetic field.\n        \\item Noise filtering\n        \\item Detecting phases in a mixture\n    \\end{itemize}\n\\end{columns}\n\\end{frame} \n\n\\begin{frame}{Example: Fourier transform for analysis of extended X-ray absorption fine structure (EXAFS)}\n    \n    \\begin{columns}\n    \\column{0.2\\textwidth}\n    \\begin{figure}\n        \\centering\n    \\includegraphics[width=\\textwidth]{figures/EXAFS-1.png}\n    \\includegraphics[width=\\textwidth]{figures/EXAFS-2.png}\n    \\includegraphics[width=\\textwidth]{figures/EXAFS-3.png}\n    \\end{figure}\n    \\column{0.77\\textwidth}\n    \\begin{itemize}\n        \\item (a) The extended edge (orange part) contains information of atom chemical environment.\n        \\item (b) Subtract the background, convert energy to k-space unit, and multiply the normalized intensity by $k^2$\n        \\item (c) Fourier transform $k$-space information to real space and obtain the first shell bond length. \n    \\end{itemize}\n    \\end{columns}\n\\end{frame} \n\n\n\\begin{frame}[allowframebreaks]{Bibliography}\n    \\bibliographystyle{unsrt}\n    \\bibliography{refs}\n\\end{frame}\n\n\n\\begin{frame}\n    \\Huge{\\centerline{The End}}\n\\end{frame}\n\n\\end{document}\n\n", "meta": {"hexsha": "1a5acdd683da26415467287fa5f6cd7dfa62fc07", "size": 32957, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/slides_tex/03-Linear_Methods.tex", "max_stars_repo_name": "materialsvirtuallab/nano281", "max_stars_repo_head_hexsha": "d527c5049aab3da99237cbff0cc749640b2c9c06", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 38, "max_stars_repo_stars_event_min_datetime": "2019-12-23T13:14:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T23:59:33.000Z", "max_issues_repo_path": "lectures/slides_tex/03-Linear_Methods.tex", "max_issues_repo_name": "materialsvirtuallab/nano281", "max_issues_repo_head_hexsha": "d527c5049aab3da99237cbff0cc749640b2c9c06", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/slides_tex/03-Linear_Methods.tex", "max_forks_repo_name": "materialsvirtuallab/nano281", "max_forks_repo_head_hexsha": "d527c5049aab3da99237cbff0cc749640b2c9c06", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-02-10T20:43:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T13:45:36.000Z", "avg_line_length": 39.2345238095, "max_line_length": 277, "alphanum_fraction": 0.6503929363, "num_tokens": 9819, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4129556380277094}}
{"text": "\\chapter{Conclusion}\\label{cha:conclusion}\n\nIn this thesis, the graph convolutional neural network presented in Gasse et al. (2019) \\cite{gasse2019exact} was iteratively ablated. The ablations resulted in five models, among which two were graph convolutional neural networks and three were pure multi-layer perceptrons. The \\gls{GCNN} models used the bipartite graph nature of the constraint-variable relationship, while the \\gls{MLP}s only used the features of the candidate variables. The models were trained, tested, and evaluated on generated \\gls{MILP} problems from the problem classes combinatorial auctions and set covering. All resulting models were tested for accuracy on predicting the optimal branching variable according to the strong branching algorithm. The efficiency of the \\gls{ML}-enhanced solvers were evaluated by running the models on both a \\gls{GPU} and \\gls{CPU}. These experiments were chosen in order to gain insight into the model and help future researchers make informed choices on \\gls{ML} model selection. \n\n% Ecole\nThe experiments were implemented in the new framework \\textit{\\gls{Ecole}} \\cite{prouvost2020ecole}. The framework provides an interface for the \\gls{BnB} solver \\gls{SCIP}, inspired by \\textit{OpenAI Gym} \\cite{brockman2016openai}.  \nThis thesis is the first article to use \\gls{Ecole} except for the introductory papers by Provoust et al. (2020) \\cite{prouvost2020ecole} and Cappart et al. (2021) \\cite{cappart2021combinatorial}. The framework was evaluated to be useful, especially as it is improved upon in the future.\n\n% accuracy ...\nThe accuracy of the models consistently decreased as layers were removed from the original model. There was a significant loss of accuracy after removing the graph convolutional component as well as after removing all hidden layers of the model. Both problem sets showed the same tendency, though the degradation of accuracy was more dramatic for the set covering problems, where there is a larger number of constraints.  \n%The iterative ablations showed a consistent decrease in accuracy for both problem classes. The notable decreases in accuracy occurred after removing the graph convolutional modules (resulting in a pure Multi-Layer Perceptron) and after all of the hidden layers of the model were removed, resulting in a linear model. A larger loss of accuracy was found for the set covering problems than the combinatorial auction problems after the removal of the graph convolutions. This is assumed to be because of the higher number of constraints in the set covering problems compared to the combinatorial auction problems. \n\n% efficiency ...\nThe computation time per variable decision also decreased with the ablations. Significant reductions in time per node were found after removing the graph convolutions and after removing all hidden layers. When the \\gls{SCIP} solver was run on test problems by performing the variable selection with the learned models, all models showed competitive efficiency with a selection of classical branching algorithms. When the models were run on the \\gls{CPU}, the more complex models suffered a large loss of efficiency. This particularly affected the models containing graph convolutions. Results were also indicative of the problem formulation being relevant for the viability of running \\gls{GCNN} models on the \\gls{CPU}. \n%All ablations resulted in decreased computation time per variable branching decision. All models were competitive with the classical branching strategies (Full Strong branching, Pseudo-cost branching, Reliability Pseudo-cost branching) when run on the \\gls{GPU}. On the \\gls{CPU}, there was a significant decrease in performance for the models containing graph convolutions. This performance reduction was greater for the set covering problems, indicating that the number of constraints might exacerbate problems with running graph convolutional models on restricted hardware. Reducing the number of hidden layers did not impact the computation time per node in particular, and is therefore not considered a viable alternative for reducing the computation time.    \n\n% Implications ...\nThe main implications of the results are the importance of considering the hardware the \\gls{ML} enhanced solver will be deployed on, as well as the problem types the models are tested on. The relation between the running times of the different models on both hardware implied non-trivial relations, which urges caution for future attempts at developing \\gls{ML} models for this purpose. The results in this thesis as well as the project \\textit{Multi-Layer Perceptrons for Branching in Mixed-Integer Linear Programming} (2020) and the article by Gupta et al. (2020) \\cite{gupta2020hybrid} stipulate a shift toward less computationally complex models with richer input features (observation functions). These models will be more universally applicable and predictable on the various hardware that will run \\gls{BnB} algorithms. In addition, the most recent attempt at learning to branch by Zarpellon et al. (2020) \\cite{zarpellon2020parameterizing} is consistent with this observation by training models that generalize across problem classes.\n\n% Future work ...\nFuture work should take into account the implications of this thesis in terms of both hardware and problem class. The analysis of how problem formulations can be detrimental to model performance is also highly relevant and should be taken into consideration when presenting data-driven methods with the implication of universally useful. Following the trend of the last few years, models pre-trained with imitation learning and improved with reinforcement learning can provide further advances in the field of \\gls{ML} enhanced \\gls{BnB}. These models will yield insights into the greater topic of machine-created algorithms, and may revolutionize how the hardest computational problems are solved in the future.  \n\n%\\begin{chapquote}{Thomas Aquinas, \\textit{Summa Theologica}}\n%``Quod potest compleri per pauciora principia, non fit per plura.\\footnote{It is superfluous %to suppose that what can be accounted for by a few principles has been produced by many.}''\n%\\end{chapquote}\n\n% Diskusjonskapittel\n% Rød tråd: Accuracy vs. efficiency", "meta": {"hexsha": "150f603961a48568d1da1f5618a967d6cb8eac08", "size": 6252, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/16-conclusion.tex", "max_stars_repo_name": "Sandbergo/master-thesis", "max_stars_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-25T10:42:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-25T10:42:49.000Z", "max_issues_repo_path": "tex/16-conclusion.tex", "max_issues_repo_name": "Sandbergo/master-thesis", "max_issues_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/16-conclusion.tex", "max_forks_repo_name": "Sandbergo/master-thesis", "max_forks_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 223.2857142857, "max_line_length": 1043, "alphanum_fraction": 0.8142994242, "num_tokens": 1325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4129556307858804}}
{"text": "\\chapter{Conclusion and Outlook}\n\\label{chap:conclusion}\n\n\\section{Conclusion}\n\n    In this thesis, existing procedures have been combined, such that a new penalizing metric is computed for provided graphs.\n    This new metric compensates the popularity of routes' edges in the graph, because these higher popularities causes to overload a graph's underlying network, when many routes are computed.\n    This is achieved with the help of an existing procedure from~\\cite{barth:alternative_multicriteria_routes}, that interpretes optimum paths found by Dijkstra in the underlying cost-space.\n    With help of this procedure, several alternative routes for a provided pair of source and destination are enumerated.\n    Because of the new metric, the number of found alternative routes is increased significantly while a user-provided tolerance (with respect to travel-time) holds.\n\n    Advantages of the presented process to create the new metric is the intuitive idea behind it.\n    While other approaches for finding alternative routes lack in performance, parameter-tuning, complexity or diversity of found alternative routes, the method in this thesis can be summarized in two iterations.\n    The first iteration updates the graph's new metric by favoring popular routes.\n    The second and last iteration considers this preference negatively and updates the graph's new metric, respectively trying to avoid these popular routes.\n    In the end, the average of both updates results in a penalizing metric, that can be used in existing routing-algorithms for graphs of multidimensional metrics.\n    The new metric leads to more spreaded routes, as shown in this thesis with street-networks from OpenStreetMap.\n\n\\section{Future work}\n\n    Remaining issues with the procedure are mainly performance-related, although preprocessing-methods as contraction-hierarchies are already used to speed the route-queries significantly up.\n\n    One performance-improvement would bring a better choice of sources and destinations for the user-provided set of \\glspl{stpair}.\n    Yet, sources and destinations are chosen \\gls{uar}\\ from the graph's vertices.\n    This requires a high number of \\glspl{stpair} to actually overload the graph.\n    Heuristics, as one described in~\\cite{bakillah:population_from_osm} to approximate the population based on OpenStreetMap-data, may help to weight the vertices in a more realistic way, which is usually less \\gls{uar}\\ when thinking of rush-hour-scenarios.\n\n    One slighter performance-improvement might be the flattening of shortcuts, that are created by the contraction-hierarchies, right after all found routes are collected, not right after a route is found.\n    Another improvement refers the implemented graph-parser, that assumes, that drivers are okay with choosing even dirt tracks for their paths, leading to more edges in the graph.\n    As the tolerance for travel-time holds, this shouldn't affect the spread a lot, but the routing-algorithms (especially the contraction-hierarchies) are much affected by the number of edges.\n    Further, the contraction-hierarchies contracts just almost all vertices, which takes much less time than actually creating the new metric.\n    A higher contraction-rate to reduce the creation-time might improve the total runtime here.\n\n    Although the results from the shown experiments are satisfying, only one metric is created.\n    Maybe, the results would be even better with several artificial penalization-metrics being created, since the averaging-approach behaves accordingly to this idea.\n    In addition, once a graph is balanced, the graph's balancing-progress is more or less fixed.\n    Here, it would be more practical to have the graph being balanced right after each \\gls{stpair} is processed.\n    Despite the metric-update, that relies on the mean over all workloads, a remaining issue would be the adaption of contraction-hierarchies.\n    This could be done by a replacement-strategy, where the last contracted graph is used for answering incoming queries and a copy of it is further balanced in the meanwhile.\n    At some point, the contracted graph, that is answering incoming queries, is replaced by the new graph, after this is contracted.\n    This would fit better for use-cases in the real world, especially with large capacities, as Google can provide.\n    Google additionally has enough user-queries to produce valid workloads.\n\n    Another aspect is the influence of crossroads on travel-time.\n    The tolerance holds for travel-time, which is based solely on speed-limits and distances, not on behaviour or circumstances at crossroads.\n    Here, the hop-distance would be important, too.\n    On the other hand, the idea behind all of this is the reduction of occuring traffic-jams.\n    Probably, circumstances at crossroads might be the better option than standing in a traffic-jam.", "meta": {"hexsha": "59d4e16c8f828042154a070ff84ab737ecdad9f9", "size": 4880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "core/src/content/conclusion_and_outlook.tex", "max_stars_repo_name": "dominicparga/master-thesis", "max_stars_repo_head_hexsha": "0215902fc26180df102deaed03fbf3a8b2d03801", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-04T23:53:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-11T16:28:31.000Z", "max_issues_repo_path": "core/src/content/conclusion_and_outlook.tex", "max_issues_repo_name": "dominicparga/master-thesis", "max_issues_repo_head_hexsha": "0215902fc26180df102deaed03fbf3a8b2d03801", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/src/content/conclusion_and_outlook.tex", "max_forks_repo_name": "dominicparga/master-thesis", "max_forks_repo_head_hexsha": "0215902fc26180df102deaed03fbf3a8b2d03801", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 101.6666666667, "max_line_length": 258, "alphanum_fraction": 0.7952868852, "num_tokens": 982, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4129556271649657}}
{"text": "\\documentclass{article}%\n\\usepackage[T1]{fontenc}%\n\\usepackage[utf8]{inputenc}%\n\\usepackage{lmodern}%\n\\usepackage{textcomp}%\n\\usepackage{lastpage}%\n\\usepackage{amsmath}%\n%\n\\title{2019 AIME II Problems}%\n\\author{MAA}%\n\\date{\\today}%\n%\n\\begin{document}%\n\\normalsize%\n\\maketitle%\n\\section{Problems}%\n\\label{sec:Problems}%\n\\begin{enumerate}%\n\\item%\nTwo different points, $C$ and $D$, lie on the same side of line $AB$ so that $\\triangle ABC$ and $\\triangle BAD$ are congruent with $AB = 9$, $BC=AD=10$, and $CA=DB=17$. The intersection of these two triangular regions has area $\\frac mn$, where $m$ and $n$ are relatively prime positive integers. Find $m+n$.\n%\n\\item%\nLily pads $1,2,3,\\ldots$ lie in a row on a pond. A frog makes a sequence of jumps starting on pad $1$. From any pad $k$ the frog jumps to either pad $k+1$ or pad $k+2$ chosen randomly with probability $\\frac{1}{2}$ and independently of other jumps. The probability that the frog visits pad $7$ is $\\frac{p}{q}$, where $p$ and $q$ are relatively prime positive integers. Find $p+q$.\n%\n\\item%\nFind the number of $7$-tuples of positive integers $(a,b,c,d,e,f,g)$ that satisfy the following systems of equations:\n\\begin{align*} abc&=70,\\\\ cde&=71,\\\\ efg&=72. \\end{align*}\n%\n\\item%\nA standard six-sided fair die is rolled four times. The probability that the product of all four numbers rolled is a perfect square is $\\frac{m}{n}$, where $m$ and $n$ are relatively prime positive integers. Find $m+n$.\n%\n\\item%\nFour ambassadors and one advisor for each of them are to be seated at a round table with $12$ chairs numbered in order $1$ to $12$. Each ambassador must sit in an even-numbered chair. Each advisor must sit in a chair adjacent to his or her ambassador. There are $N$ ways for the $8$ people to be seated at the table under these conditions. Find the remainder when $N$ is divided by $1000$.\n%\n\\item%\nIn a Martian civilization, all logarithms whose bases are not specified as assumed to be base $b$, for some fixed $b\\ge2$. A Martian student writes down\n\\[3\\log(\\sqrt{x}\\log x)=56\\]\n\\[\\log_{\\log x}(x)=54\\]\nand finds that this system of equations has a single real number solution $x>1$. Find $b$.\n%\n\\item%\nTriangle $ABC$ has side lengths $AB=120,BC=220$, and $AC=180$. Lines $\\ell_A,\\ell_B$, and $\\ell_C$ are drawn parallel to $\\overline{BC},\\overline{AC}$, and $\\overline{AB}$, respectively, such that the intersections of $\\ell_A,\\ell_B$, and $\\ell_C$ with the interior of $\\triangle ABC$ are segments of lengths $55,45$, and $15$, respectively. Find the perimeter of the triangle whose sides lie on lines $\\ell_A,\\ell_B$, and $\\ell_C$.\n%\n\\item%\nThe polynomial $f(z)=az^{2018}+bz^{2017}+cz^{2016}$ has real coefficients not exceeding $2019$, and $f\\left(\\frac{1+\\sqrt{3}i}{2}\\right)=2015+2019\\sqrt{3}i$. Find the remainder when $f(1)$ is divided by $1000$.\n%\n\\item%\nCall a positive integer $n$ $k$-pretty if $n$ has exactly $k$ positive divisors and $n$ is divisible by $k$. For example, $18$ is $6$-pretty. Let $S$ be the sum of positive integers less than $2019$ that are $20$-pretty. Find $\\frac{S}{20}$.\n%\n\\item%\nThere is a unique angle $\\theta$ between $0^{\\circ}$ and $90^{\\circ}$ such that for nonnegative integers $n$, the value of $\\tan{\\left(2^{n}\\theta\\right)}$ is positive when $n$ is a multiple of $3$, and negative otherwise. The degree measure of $\\theta$ is $\\frac{p}{q}$, where $p$ and $q$ are relatively prime integers. Find $p+q$.\n%\n\\item%\nTriangle $ABC$ has side lengths $AB=7, BC=8,$ and $CA=9.$ Circle $\\omega_1$ passes through $B$ and is tangent to line $AC$ at $A.$ Circle $\\omega_2$ passes through $C$ and is tangent to line $AB$ at $A.$ Let $K$ be the intersection of circles $\\omega_1$ and $\\omega_2$ not equal to $A.$ Then $AK=\\frac mn,$ where $m$ and $n$ are relatively prime positive integers. Find $m+n.$\n%\n\\item%\nFor $n \\ge 1$ call a finite sequence $(a_1, a_2 \\ldots a_n)$ of positive integers progressive if $a_i < a_{i+1}$ and $a_i$ divides $a_{i+1}$ for all $1 \\le i \\le n-1$. Find the number of progressive sequences such that the sum of the terms in the sequence is equal to $360$.\n%\n\\item%\nRegular octagon $A_1A_2A_3A_4A_5A_6A_7A_8$ is inscribed in a circle of area $1.$ Point $P$ lies inside the circle so that the region bounded by $\\overline{PA_1},\\overline{PA_2},$ and the minor arc $\\widehat{A_1A_2}$ of the circle has area $\\frac{1}{7},$ while the region bounded by $\\overline{PA_3},\\overline{PA_4},$ and the minor arc $\\widehat{A_3A_4}$ of the circle has area $\\frac{1}{9}.$ There is a positive integer $n$ such that the area of the region bounded by $\\overline{PA_6},\\overline{PA_7},$ and the minor arc $\\widehat{A_6A_7}$ of the circle is equal to $\\frac{1}{8}-\\frac{\\sqrt2}{n}.$ Find $n.$\n%\n\\item%\nFind the sum of all positive integers $n$ such that, given an unlimited supply of stamps of denominations $5,n,$ and $n+1$ cents, $91$ cents is the greatest postage that cannot be formed.\n%\n\\item%\nIn acute triangle $ABC$ points $P$ and $Q$ are the feet of the perpendiculars from $C$ to $\\overline{AB}$ and from $B$ to $\\overline{AC}$, respectively. Line $PQ$ intersects the circumcircle of $\\triangle ABC$ in two distinct points, $X$ and $Y$. Suppose $XP=10$, $PQ=25$, and $QY=15$. The value of $AB\\cdot AC$ can be written in the form $m\\sqrt n$ where $m$ and $n$ are positive integers, and $n$ is not divisible by the square of any prime. Find $m+n$.\n%\n\\end{enumerate}\n\n%\n\\end{document}", "meta": {"hexsha": "9eb8e935fa70a09974a0f1b0fba41d77d602d011", "size": 5405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "output/2019_AIME_II.tex", "max_stars_repo_name": "chen-siyuan/amc-worksheet", "max_stars_repo_head_hexsha": "d9fb3bfe5ffa57295795cb830a4584a1baa344ef", "max_stars_repo_licenses": ["zlib-acknowledgement"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-06-13T20:59:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T23:09:26.000Z", "max_issues_repo_path": "output/2019_AIME_II.tex", "max_issues_repo_name": "chen-siyuan/amc-worksheet", "max_issues_repo_head_hexsha": "d9fb3bfe5ffa57295795cb830a4584a1baa344ef", "max_issues_repo_licenses": ["zlib-acknowledgement"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2020-06-13T00:38:03.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-17T03:32:10.000Z", "max_forks_repo_path": "output/2019_AIME_II.tex", "max_forks_repo_name": "chen-siyuan/awg", "max_forks_repo_head_hexsha": "d9fb3bfe5ffa57295795cb830a4584a1baa344ef", "max_forks_repo_licenses": ["zlib-acknowledgement"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.1267605634, "max_line_length": 607, "alphanum_fraction": 0.7043478261, "num_tokens": 1709, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7606506635289835, "lm_q1q2_score": 0.41292931655068854}}
{"text": "\\documentclass[fleqn, final]{../styles/unmphythesis}\n\\usepackage{../styles/qxd}\n\\renewcommand{\\thechapter}{6}\n%\\newcommand{\\thechapter}{1}\n\n\\makeindex\n\\begin{document}\n\n%<*twocolorprotocol>\n\n\\chapter{Canceling the tensor light shift with two-color probes}\\label{chap:twocolor}\n\nFollowing Chapter~\\ref{chap:quantumdynamicsrepresentation}, the light-atom interaction Hamiltonian with one atom can be written as\n\\begin{align}\n\\hat{h}_\\eff &= -\\hat{\\mathbf{E}}^{(-)}(\\br')\\cdot\\hat{\\tensor{\\mathbf{\\alpha}}}\\cdot\\hat{\\mathbf{E}}^{(+)}(\\br')\\nn\\\\\n&= -\\frac{2\\pi\\hbar\\omega}{v_g}\\left[\\mathbf{u}_H^*\\cdot\\hat{\\tensor{\\mathbf{\\alpha}}}\\cdot \\mathbf{u}_H\\hat{a}_H^\\dagger\\hat{a}_H\\right.\n+ \\mathbf{u}_H^*\\cdot\\hat{\\tensor{\\mathbf{\\alpha}}}\\cdot \\mathbf{u}_V\\hat{a}_H^\\dagger\\hat{a}_V\\nn\\\\\n&\\quad\\quad + \\mathbf{u}_V^*\\cdot\\hat{\\tensor{\\mathbf{\\alpha}}}\\cdot \\mathbf{u}_H\\hat{a}_V^\\dagger\\hat{a}_H \n\\left. + \\mathbf{u}_V^*\\cdot\\hat{\\tensor{\\mathbf{\\alpha}}}\\cdot \\mathbf{u}_V\\hat{a}_V^\\dagger\\hat{a}_V\\right]\\\\\n&= \\hbar\\left[(\\hat{\\chi}_{HH}+\\hat{\\chi}_{VV})\\hat{S}_0 + (\\hat{\\chi}_{HH}-\\hat{\\chi}_{VV})\\hat{S}_1 \\right.\\nn\\\\\n&\\quad \\quad\\left. + (\\hat{\\chi}_{HV}+\\hat{\\chi}_{VH})\\hat{S}_2 + i(\\hat{\\chi}_{HV}-\\hat{\\chi}_{VH})\\hat{S}_3 \\right]\\\\\n%\\hbar \\left[\\left(\\chi_{RR\\uparrow} + \\chi_{RR\\downarrow} +\\chi_{LL\\uparrow}+\\chi_{LL\\downarrow} \\right)\\hat{F}_0\\hat{S}_0 \\right.\\nonumber\\\\\n%&\\quad+\\left(\\chi_{RR\\uparrow} + \\chi_{RR\\downarrow} -\\chi_{LL\\uparrow}-\\chi_{LL\\downarrow} \\right)\\hat{F}_0\\hat{S}_3\\nonumber\\\\\n%&\\quad+\\left(\\chi_{RR\\uparrow} + \\chi_{LL\\uparrow} -\\chi_{RR\\downarrow}-\\chi_{LL\\downarrow} \\right)\\hat{F}_3\\hat{S}_0\\nonumber\\\\\n%&\\quad+\\left(\\chi_{RR\\uparrow} - \\chi_{RR\\downarrow} +\\chi_{LL\\downarrow}-\\chi_{LL\\uparrow} \\right)\\hat{F}_3\\hat{S}_3\\nonumber\\\\\n%&\\quad+i\\left(\\chi_{LR\\uparrow} - \\chi_{RL\\uparrow} +\\chi_{RL\\downarrow}-\\chi_{RL\\downarrow} \\right)\\hat{F}_0\\hat{S}_1\\nonumber\\\\\n%&\\quad+\\left(\\chi_{RL\\uparrow} + \\chi_{LR\\uparrow} +\\chi_{RL\\downarrow}+\\chi_{LR\\downarrow} \\right)\\hat{F}_0\\hat{S}_2\\nonumber\\\\\n%&\\quad+i\\left(\\chi_{LR\\uparrow} - \\chi_{RL\\uparrow} +\\chi_{RL\\downarrow}-\\chi_{LR\\downarrow} \\right)\\hat{F}_3\\hat{S}_1\\nonumber\\\\\n%&\\quad+\\left.\\left(\\chi_{LR\\uparrow} + \\chi_{RL\\uparrow} -\\chi_{LR\\downarrow}-\\chi_{RL\\downarrow} \\right)\\hat{F}_3\\hat{S}_2 \\right]\\\\\n&=\\hbar\\sum_{i=0}^3 \\hat{\\chi}_{i}\\hat{S}_i\\\\\n&=\\hbar\\sum_{i,j=0} \\chi_{ij}\\hat{f}_i\\hat{S}_j,\n\\end{align}\nwhere $ \\hat{S}_i $ are the Stokes vector operators of the light indicating its polarization, and the mode-atom coupling operator\n\\begin{align}\n\\hat{\\chi}_{pp'} \n&=-\\frac{2\\pi \\omega}{v_g}\\mathbf{u}_{p}^*(r'\\!_\\perp,\\phi')\\cdot \\hat{\\tensor{\\alpha}}\\cdot \\mathbf{u}_{p'}(r'\\!_\\perp,\\phi')\\\\\n&= \\sum_{f'} \\frac{n_g\\sigma_0}{4}\\frac{\\Gamma_{f'}}{\\Delta_{ff'}+i\\Gamma_{f'}/2}\\cdot \\left\\{ C_{j'ff'}^{(0)}\\mathbf{u}_p^*(r'\\!_\\perp)\\cdot \\mathbf{u}_{p'}(r'\\!_\\perp)\\hat{\\mathbbm{1}}\\right.\\nn\\\\\n&\\quad\\quad +iC_{j'ff'}^{(1)}\\left(\\mathbf{u}_p^*(r'\\!_\\perp)\\times\\mathbf{u}_{p'}(r'\\!_\\perp) \\right)\\cdot \\hat{\\mathbf{f}} \\nonumber\\\\\n&\\quad\\quad\\left. + C_{j'ff'}^{(2)}\\sum_{i,j}\\left[u^*_{p,i}u_{p',j}(\\frac{\\hat{f}_i\\hat{f}_j+\\hat{f}_j\\hat{f}_i}{2}-\\frac{\\delta_{ij}}{3}\\hat{\\mathbf{f}}\\cdot\\hat{\\mathbf{f}}) \\right]\\right\\}\n%&\\left.+C_{jj'ff'}^{(2)}\\left[\\mathbf{u}_p^*(r'\\!_\\perp)\\cdot \\mathbf{u}_{p'}(r'\\!_\\perp)\\left(\\frac{f(f+1)}{6}-\\frac{m^2}{2} \\right)+\\mathbf{u}_p^*(r'\\!_\\perp)\\cdot (\\hat{e}^*_{\\tilde{z}}\\hat{e}_{\\tilde{z}})\\cdot \\mathbf{u}_{p'}(r'\\!_\\perp)\\left(\\frac{3m^2}{2}-\\frac{f(f+1)}{2} \\right) \\right] \\right\\}\n\\label{eq:chippp}\n\\end{align}\nwith the horizontally(H)- and vertically(V)-linearly polarized guided modes, $ \\mathbf{u}_p(r'\\!_\\perp) $, at the atom position $ \\br'=(r'\\!_\\perp,\\phi',z') $. \n$ \\chi_{ij}=\\tr[\\hat{f}_i\\hat{\\chi}_j]/(2f+1) $ is the coupling strength between spin operator $ \\hat{f}_i $ and Stokes operator $ \\hat{S}_j $. \nFor example, $ \\chi_{33} $ is the coupling strength between $ \\hat{f}_z $ and $ \\hat{S}_3 $.\nThe fundamental guided modes of an optical nanofiber has been defined in the appendix of our previous paper~\\cite{Qi2016}. \nIn general, for a cylindrical waveguide, the H- and V-modes are the guided modes adiabatically transferred from a corresponding linearly polarized input light from one end of the waveguide, where H- and V-directions are orthogonal to each other in the transverse plane.\nThe coupling operator or Eq.\\eqref{eq:chippp} includes three terms corresponding to scalar, vector and tensor interactions between atoms and the probe light which are proportional to $ C_{j'ff'}^{(K)} $ with $ K=0,\\,1,\\,2 $, respectively.\n\n\\qxd{Generalize the above to the two-color case. Some words on finding the correct frequencies.}\n\nWe also ignore the tensor coupling strength related to $ C_{jj'ff'}^{(2)} $ terms in Eq.\\eqref{eq:chippp} as the tensor interaction strength ($ \\sim 1/\\Delta^2 $) is relatively small compared to the vector interaction strength ($ \\sim 1/\\Delta $)~\\cite{Deutsch2010a}. \nFor a nanofiber geometry, the Faraday interaction coupling strength is independent of the azimuthal position of the atoms and can be simplified as\n\\begin{align}\n\\chi_{33} &= -\\sum_{f'}n_g\\sigma_0\\frac{\\Gamma_0}{\\Delta_{ff'}+i\\Gamma_0/2}C_{jj'ff'}^{(1)}u_{r\\!_\\perp}(r'\\!_\\perp)u_\\phi(r'\\!_\\perp)\\\\\n&=\\frac{\\sigma_0}{A_F}\\frac{\\Gamma_0}{\\Delta_F},\n\\end{align}\nwhere the effective Faraday interaction mode area $ A_F=1/2n_g|u_{r\\!_\\perp}(r'\\!_\\perp)u_\\phi(r\\!_\\perp)| $, and the effective detuning $ \\Delta_F=\\sum_{f'}\\frac{-C_{j'ff'}^{(1)}}{\\Delta_{ff'}} $.\nThe measurement strength is now defined as\n\\begin{align}\n\\kappa\\equiv|\\chi_{33}|^2\\dot{N}_L=\\frac{\\sigma_0A_{in}}{A_F^2}\\gamma_s,\n\\end{align}\nwhere the characteristic photon scattering rate $ \\gamma_s\\equiv \\frac{\\Gamma_0\\Omega^2}{4\\Delta_F}=\\frac{\\sigma_0}{A_{in}}\\frac{\\Gamma_0^2}{4\\Delta_F^2}\\dot{N}_L $ and the effective mode area $ A_{in}=1/n_g|u_{\\mathrm{in}}(\\br'\\!_\\perp)|^2 $.\nNow we can define the OD per atom for the Faraday interaction using SCS by\n\\begin{align}\n\\frac{\\mathrm{OD}}{N_A} \\equiv \\frac{\\kappa}{\\gamma_s}=\\frac{\\sigma_0A_{in}}{A_F^2}.\n\\end{align}\n\n\\qxd{Again, generalize to two-color case.}\n\\section{A two-color spin squeezing protocol to cancel the tensor light shift}\nAs illustrated in Enrique Montano's PhD dissertation work, the tensor light shift due to the external field can be canceled in a free-space spin squeezing setup, we will generalize this idea to the nanophotonic waveguide case.\n\nFrom Eq.~\\eqref{eq:Heff_Faraday_C02}, the state-dependent tensor light shift (the term proportional to $ \\hat{f}_x^2 $) is proportional to \n\\begin{align}\n\\delta E_T &= \\sum_{j',f'} \\frac{\\Gamma_{j'f'}^x\\Omega^2}{\\Delta_{fj'f'}^2+(\\Gamma_{j'f'}^x)^2/4}C_{j'ff'}^{(2)}\\\\\n&\\approx \\sum_{j'f'}\\frac{\\Gamma_{j'f'}^x\\Omega^2}{\\Delta_{fj'f'}^2}C_{j'ff'}^{(2)} = \\sum_{j'f'}\\frac{\\sigma_0}{\\Ain}\\left(\\frac{\\Gamma_{j'f'}^x}{\\Delta_{fj'f'}} \\right)^2 \\dot{N}_L C_{j'ff'}^{(2)}\n\\end{align}\nTo cancel the tensor light shift, we want to find the two frequencies of the probes so that $ \\delta E_T=0 $.\n\n\\qxd{To be continue...}\n\n\n\\section{Spin dynamics with two-color probes}\n\nTo study the spin squeezing dynamics, we employ a first-principles stochastic master equation for the collective state of $N_A$ atoms,\n\\begin{align}\\label{eq:totaldrhodt_twocolor}\n\\mathrm{d}\\hat{\\rho}= \\left.\\mathrm{d}\\hat{\\rho}\\right|_{QND}+\\left.\\mathrm{d}\\hat{\\rho}\\right|_{op}.\n\\end{align}\nThe first term on the right-hand side of Eq.\\eqref{eq:totaldrhodt_twocolor} governs the spin dynamics arising from QND measurement~\\cite{Jacobs2006,Baragiola2014},\n\\begin{align}\n\\left.\\mathrm{d}\\hat{\\rho}\\right|_{QND} &= \\sqrt{\\frac{\\kappa_1}{4}}\\mathcal{H}\\left[\\hat{\\rho} \\right]\\mathrm{d}W_1 + \\sqrt{\\frac{\\kappa_2}{4}}\\mathcal{H}\\left[\\hat{\\rho} \\right]\\mathrm{d}W_2 + \\frac{\\kappa_1+\\kappa_2}{4}\\mathcal{L}\\left[ \\hat{\\rho}\\right]\\mathrm{d}t, \n\\end{align}\nwhere  $\\kappa_1$ and $ \\kappa_2 $ are the measurement strengths defined in Eq.~\\eqref{eq:kappa} for the two probes in different frequencies, respectively; $\\mathrm{d}W_1$ and $ \\mathrm{d}W_2 $ are independent stochastic Weiner intervals for the two probes. The conditional dynamics are generated by superoperators that depend on the {\\em collective} spin\n\\begin{subequations}\n\\begin{align}\n\\mathcal{H}\\left[ \\hat{\\rho}\\right] &= \\hat{F}_z \\hat{\\rho} + \\hat{\\rho}\\hat{F}_z -2\\expect{\\hat{F}_z}\\hat{\\rho}, \\\\\n\\mathcal{L}\\left[ \\hat{\\rho} \\right] &= \\hat{F}_z \\hat{\\rho}\\hat{F}_z -\\frac{1}{2}\\left(\\hat{\\rho}\\hat{F}_z^2+\\hat{F}_z^2\\hat{\\rho} \\right)=\\frac{1}{2}\\left[\\hat{F}_z,\\left[\\hat{\\rho},\\hat{F}_z \\right] \\right].\n\\end{align}\n\\end{subequations}\nThe second term governs decoherence arising from optical pumping, which acts {\\em locally} on each atom$,\\mathrm{d}\\hat{\\rho}|_{op}=\\sum_n^{N_A} \\mathcal{D}^{(n)}\\left[ \\hat{\\rho}\\right] \\mathrm{d}t$, where \n\\begin{equation}\n\\mathcal{D}^{(n)}\\left[ \\hat{\\rho}\\right] = -\\frac{i}{\\hbar}\\left(\\hat{H}^{(n)}_{\\rm eff}\\hat{\\rho} - \\hat{\\rho} \\hat{H}^{(n)\\dag}_{\\rm eff}\\right) + \\gamma_{op} \\sum_q \\hat{W}^{(n)}_q \\hat{\\rho}\\hat{W}^{(n)\\dag}_q.\n\\label{op_superator}\n\\end{equation}\nHere $\\hat{H}^{(n)}_{\\rm eff}$ is the effective nonHermitian Hamiltonian describing the local light shift and absorption by the $i^{th}$ atom and $\\hat{W}^{(n)}_q$ is the jump operator corresponding to optical pumping through spontaneous emission of a photon of polarization $q$~\\cite{Deutsch2010a} (see Appendix~\\ref{chap:opticalpumpingwithmodifiedrates} \\qxd{Need to double check if all modified decay rates are correctly included.}).   \nThe rate of decoherence is characterized by the total optical pumping rate, $\\gamma_{op}=\\gamma_{op,1}+\\gamma_{op,2}$, of the two probes.  Note, the optical pumping superoperator, Eq.\\eqref{op_superator},  is not trace preserving when restricted to a given ground-state hyperfine manifold $f$.  In this case, optical pumping of atoms to the other hyperfine manifold in the ground-electronic state is treated as loss.  If the atoms are placed at the optimal position, the local field is linearly polarized.  In that case the vector light shift vanishes, and for detunings large compared to the excited-state hyperfine splitting, the rank-2 tensor light shift is negligible over the time scales of interest.  In that case the light shift is dominated by the scalar component, which has no effect on the spin dynamics.  In that case $\\hat{H}_{\\rm eff} = -i\\hbar \\gamma_{op}/2 1$.\n\n\n%</twocolorprotocol>\n\n\\appendix\n\n%<*opticalpumpingwithmodifiedrates>\n\\chapter{Optical pumping considering the modified emission rates}\\label{chap:opticalpumpingwithmodifiedrates}\nIn this part, we derive the motion of equations for the optical pumping dynamics with one-color probe. To make our notation simple, we implicit include the excited state fine structure quantum number $ j' $ for the one-color probe case. Once the quantum transition rates of individual colors of the probes have been calculated, the total dynamics due to the two-color probes should be determined by the sums of the transition rates associated with the two probes.\n\nThe collective spin dynamics in the QND measurement and spin squeezing process is described by the stochastic master equation defined in Eq.~\\eqref{eq:totaldrhodt}. The optical pumping dynamics of the $ j $-th atom are governed by \n\\begin{align}\n\\left.\\dt{\\hat{\\rho}^{(j)}}\\right|_{op} &= \\mathcal{D}[\\hat{\\rho}^{(j)}]=-\\frac{i}{\\hbar}\\left\\{\\hat{H}_{\\rm eff}^{(j)},\\hat{\\rho}^{(j)} \\right\\}_+ + \\gamma_s\\sum_{q}\\hat{W}_q(\\br'_j)\\hat{\\rho}^{(j)}\\hat{W}_q^\\dagger(\\br'_j) %\\\\\n%&=-\\gamma_s\\frac{1}{2}\\sum_{a,b}\\gamma_{ba}\\ket{b}\\bra{a}+\n%\\!\\!\\!\\!\\!\\!\\sum_{q,q',q'',a,b,c,d,f',f'',m',m''}\\!\\!\\!\\!\\!\\! \\gamma_sw_{dcq}^{f''m''q''}\\left(w_{abq}^{f'm'q'}\\right)^*\\ket{d}\\bra{c}\\hat{\\rho}^{(i)}\\ket{b}\\bra{a}.\n\\end{align} \nWe have defined a characteristic photon scattering rate, $\\gamma_s \\equiv \\frac{\\Gamma_0\\Omega^2}{4\\Delta_{F}^2}= \\frac{\\sigma_0}{A_{\\rm in}}\\frac{\\Gamma_0^2}{4 \\Delta_{F}^2} \\dot{N}_L $ with an effective detuning $ \\Delta_F $ defined by $ \\frac{1}{\\Delta_F}=\\sum_{f'}\\frac{C_{ff'}^{(1)}}{\\Delta_{ff'}} $ and $ \\Delta_{ff'}=\\omega-\\omega_{ff'} $.\nWe have also defined Rabi frequency $ \\Omega=2\\bra{j}|d|\\ket{j'}\\mathcal{E}^{(+)}_{\\rm in}/\\hbar $ with reduced optical dipole matrix element $\\bra{j}|d|\\ket{j'}$ and field amplitude $ \\mathcal{E}^{(+)}_{\\rm in}=|\\mathbf{E}_{\\rm in}^{(+)}(\\br')| $.\nThe total rate of photon scattering by an atom from the $\\ket{a}\\equiv \\ket{f,f_x=a}$ to $ \\ket{b}\\equiv\\ket{f,f_x=b} $ hyperfine ground state in the $x$-basis is\n\t\\begin{equation}\\label{Eq::gammaf}\n\t\t\\gamma_{ba}=- \\frac{2}{\\hbar} {\\rm Im} \\big[ \\bra{f,b} \\hat{h}_{\\rm eff}\\ket{f,a} \\big] ,\n\t\\end{equation}\nThe effective nonHermitian light-shift Hamiltonian for one atom (labeled with superscript $ (j) $ for the $ j $th atom) is given by\n\\begin{align}\n\\hat{H}_{\\rm eff}^{(i)} \\equiv \\hat{h}_{\\rm eff}&= - \\hat{\\mathbf{E}}^{(-)}_{\\rm in}(\\mathbf{r}' ; t ) \\cdot \\poltens \\cdot \\hat{\\mathbf{E}}^{(+)}_{\\rm in}(\\mathbf{r}' ;t ),\n\\end{align}\nwhere the polarizability operator $  \\poltens=\\sum_{f',q}\\hat{\\tensor{\\mathbf{A}}}(f,f',q)$ with elements of $ \\hat{\\tensor{\\mathbf{A}}} $ given by\n\\begin{align} \\label{Eq::PolarizabilityIrrep}\n\t\t\\hat{A}_{ij}(f,f',q)&\\equiv -\\frac{\\sigma_0}{8\\pi k_0\\gamma_s}\\frac{\\Gamma_{f'\\!\\!,\\, i}^q}{\\Delta_{ff'}^q+i\\Gamma_{f'\\!\\!,\\, i}^q/2}\\hat{e}_i^*\\cdot\\hat{\\mathbf{D}}_{ff'}\\hat{\\mathbf{D}}_{f'f}^\\dagger \\cdot \\hat{e}_j \\\\\n\t\t&=  -\\frac{\\sigma_0}{8\\pi k_0\\gamma_s}\\frac{\\Gamma_{f'\\!\\!,\\, i}^q}{\\Delta_{ff'}^q\\!+\\! i\\Gamma_{f'\\!\\!,\\, i}^q/2}\\left\\{ C_{ff'}^{(0)} \\delta_{i,j}\\hat{\\mathbbm{1}}\\!+\\! iC_{ff'}^{(1)}\\epsilon_{ijk}\\hat{f}_k \\!+\\! C_{ff'}^{(2)} \\Big[ \\smallfrac{1}{2} ( \\hat{f}_i\\hat{f}_j \\!+\\!\\hat{f}_j\\hat{f}_i )\\!-\\!\\smallfrac{1}{3} \\hat{\\mathbf{f}}\\!\\cdot\\!\\hat{\\mathbf{f}} \\delta_{i,j} \\Big]\\right\\}, \n\\end{align}\nwhere $\\hat{\\mathbf{f}}$ is the atomic spin operator in hyperfine multiplet $f$, and $ \\epsilon_{ijk} $ is the Levi-Civita symbol. \nDefinitions of the interaction coefficients $ C_{ff'}^{(n)} $ can be found in Ref.~\\cite{Qi2016}, which correspond to scalar, vector and tensor atom-light interactions for $ n=0,1,2 $, respectively.\n\nGiven the geometry of the Faraday spin squeezing protocol for optical nanofiber and square waveguides discussed in this paper, the local electric field at the atom positions is linearly polarized. \nBy denoting the local field's polarization direction as the $ x$-direction and the propagation direction of the guided light as the $ z $-direction, the effective atom-light interaction Hamiltonian in a static reference frame can be written as \n\\begin{align}\n\\hat{h}_{\\rm eff} &= -\\frac{i\\hbar}{2}\\sum_{f'} \\gamma'_s \\left[C_{ff'}^{(0)}\\hat{\\mathbbm{1}}+C_{ff'}^{(2)}(\\hat{f}_{x}^2-\\frac{\\hat{\\mathbf{f}}^2}{3} ) \\right],\\label{eq:Heff_Faraday_C02}\n\\end{align}\nwhere the intrinsic photon scattering rate $ \\gamma'_s\\equiv \\frac{\\Gamma_{f'}^x\\Omega^2}{4(\\Delta_{ff'}^2+\\left(\\Gamma_{f'}^x\\right)^2/4 )}$ and in the far-detuning regime, $\\gamma'_s \\approx \\frac{\\Gamma_{f'}^x\\Omega^2}{4\\Delta_{\\rm eff}^2}=\\frac{\\sigma_0}{\\Ain}\\left(\\frac{\\Gamma_{f'}^x}{2\\Delta_{\\rm eff}} \\right)^2\\dot{N}_L $. Note here the vector interaction term vanishes given a linearly polarized light; we have ignored the energy shift, which is valid when the detuning is much larger than the hyperfine level splitting.\nIn our simulations of spin squeezing in this paper, we have used the decay rate $ \\Gamma_{f',q} $ to indicate the decay rates from the hyperfine $ f' $ manifold sublevels of excited states with a photon emission polarized along the $ \\mathbf{e}_q $ direction; the effective detuning is also an averaged detuning from the fine structure excited level $ j' $ to the ground fine structure manifold $ j $ with resonant frequency $ \\omega_D $ of $ D_1 $ line transitions--that is $ \\Delta_{\\rm eff}=\\omega -\\omega_D $ with probe frequency at $ \\omega $ in vacuum given a far-detuned $ \\sim 1 $nm of detuning from the $ D_1 $ line transition of $ ^{133}Cs $ atoms. \nCompared to the normal characteristic photon scattering rate $ \\gamma_s $, we can see they are defined in different scales.\nIn general, they are related given a transition between ground hyperfine structure level $ f $ and excited hyperfine structure level $ f' $ by \n\\begin{align}\n\\gamma'_s(f')=\\gamma_s \\frac{\\Delta_F^2}{\\Delta_{ff'}^2},\n\\end{align}\nand hence $ \\frac{\\sqrt{\\Gamma_{f'}^x}\\Omega/2}{\\Delta_{ff'}\\pm i\\Gamma_{f'}^x/2}\\approx \\frac{\\sqrt{\\Gamma_{f'}^x}\\Omega/2}{\\Delta_{ff'}}=\\sqrt{\\gamma_s}\\frac{\\Delta_F}{\\Delta_{ff'}} $ in the far-detuning regime.\n\nWe define the Lindblad jump operators of optical pumping among ground states by~\\cite{Deutsch2010a}\n\t\\begin{align}\\label{Eq::Wq_Faraday}\n\t\t\\hat{W}_q &= \\frac{1}{\\sqrt{\\gamma_s}}\\sum_{f'}\\frac{\\sqrt{\\Gamma_{f'}^q}\\Omega/2}{\\Delta_{f'f}^q+i\\Gamma_{f'}^q/2}\\mathbf{e}_q^*\\cdot(\\hat{\\mathbf{D}}_{ff'}  \\hat{\\mathbf{D}}^\\dagger_{f'f} )\\cdot\\mathbf{e}_{\\rm in} \\\\\n\t\t&= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'k}\\! \\frac{\\sqrt{\\Gamma_{f'}^q}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^q/2} \\left[\\delta_{qx}C_{ff'}^{(0)}\\hat{\\mathbbm{1}} + iC_{ff'}^{(1)}\\epsilon_{qxk}\\hat{f}_k  \\phantom{\\dfrac{\\hat{f}}{f}}\\right. \\nn\\\\\n\t\t&\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad \\left. + C_{ff'}^{(2)} \\left(\\frac{\\hat{f}_q\\!\\hat{f}_{x}\\!+\\!\\hat{f}_{x}\\!\\hat{f}_q }{2} \\!-\\! \\frac{\\delta_{qx}}{3}\\hat{\\mathbf{f}}^2 \\right) \\right].\n%\t\t&=\\sum_{f',m',q',a,b} w_{baq }^{f'm'q'}\\ket{b}\\bra{a}.\n\t\\end{align}\nEach jump operator $\\hat{W}_q$ is associated with absorption of the probe photon polarized along $ \\mathbf{e}_{\\rm in} $ followed by spontaneous emission of a photon with polarization $ \\mathbf{e}_q $, where $q= \\{0,\\pm 1\\}$ labels spherical basis elements for $\\pi$ and $ \\sigma_\\pm$ transitions. \n%Here the dimensionless raising operator $ \\mathbf{e}_q\\cdot\\hat{\\mathbf{D}}_{f'f}^\\dagger= \\sum_{m',m} o_{jf}^{j'f'} C_{f',m'}^{f,m;1, q}\\ket{f',m'}\\bra{f,m} $,\n%where $ C_{f',m'}^{f,m;1, q}=0 $ unless $ m'=m+q $ with $ C_{f',m+q}^{f,m;1, q}=\\Braket{f',m+q}{f,m;1,q}$ being the Clebsch-Gordan coefficients, and\n%\\begin{equation}\n%\\big| o_{jf}^{j'f'} \\big|^2=(2j'+1)(2f+2) \\bigg\\{\n%\\begin{array}{ccc}\n%f' & 7/2 & j' \\\\\n% j & 1 & f\n% \\end{array}\n% \\bigg\\}\n%\\end{equation}\n%are the relative oscillator strengths determined by the relevant Wigner 6-$J$ symbol.\n%In our protocols, we assume the probe light is so far-detuned from any of the atomic resonances that the tilting of the hyperfine structure levels due to an external magnetic field becomes irrelevant and we can set $ \\Delta_{ff'}^q=\\Delta_{ff'} $ and $ \\Delta_{ff'}\\gg \\Gamma_f'^q $ for arbitrary $ f' $ and $ q $.\n\nTherefore, in the static $ \\left\\{x,y,z \\right\\} $ basis, we have\n\\begin{align}\n\\hat{W}_{x} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^x}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^x/2} \\left[C_{ff'}^{(0)}\\hat{\\mathbbm{1}} + C_{ff'}^{(2)}\\left(\\hat{f}_{x}^2-\\frac{1}{3}\\hat{\\mathbf{f}}^2 \\right) \\right]\\\\\n\\hat{W}_{y} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^y}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^y/2} \\left(-iC_{ff'}^{(1)}\\hat{f}_z + C_{ff'}^{(2)}\\frac{\\hat{f}_{x}\\hat{f}_{y}+\\hat{f}_{y}\\hat{f}_{x}}{2} \\right)\\\\\n\\hat{W}_{z} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^z}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^z/2} \\left(iC_{ff'}^{(1)}\\hat{f}_{y} + C_{ff'}^{(2)}\\frac{\\hat{f}_z\\hat{f}_{x}+\\hat{f}_{x}\\hat{f}_z}{2}  \\right).\n\\end{align}\n\n\nThe optical pumping dynamics of the $ j $-th atom are governed by \n\\begin{align}\n\\left.\\dt{\\hat{\\rho}^{(j)}}\\right|_{op} &= \\gamma_s\\mathcal{D}[\\hat{\\rho}^{(j)}]=-\\frac{i\\gamma_s}{\\hbar}\\left\\{\\hat{h}^{\\rm eff}_{\\rm eff},\\hat{\\rho}^{(j)} \\right\\}_+ + \\gamma_s\\sum_{q}\\hat{W}_q(\\br'_j)\\hat{\\rho}^{(j)}\\hat{W}_q^\\dagger(\\br'_j)\\\\\n\\\\\n&=-\\gamma_s\\frac{1}{2}\\sum_{a,b}\\gamma_{ba}\\ket{b}\\bra{a} \\nn\\\\\n&\\quad\\quad + \\!\\!\\!\\!\\!\\!\\sum_{q,q',q'',a,b,c,d,f',f'',m',m''}\\!\\!\\!\\!\\!\\! \\gamma_sw_{dcq}^{f''m''q''}\\left(w_{abq}^{f'm'q'}\\right)^*\\ket{d}\\bra{c}\\hat{\\rho}^{(i)}\\ket{b}\\bra{a}\n\\end{align}\nEqs.~\\eqref{Eq::gammaf} and~\\eqref{Eq::Wq_Faraday} yield,\n\\begin{subequations}\n\t\\begin{align}\n\t\t\\gamma_{ba} \n\t\t&=\\frac{n_g\\dot{N}_L}{\\gamma_s}  \\sum_{f',q} \\sigma (\\Delta_{ff'} ) \\mathbf{u}^*_\\inp(\\br'_\\perp)\\cdot \\bra{b} \\hat{\\tensor{\\mbf{A}}}(f,f') \\ket{a}  \\cdot \\mathbf{u}_\\inp(\\br'_\\perp)\\\\\n\t\t&\\approx  \\sum_{f',m'} \\frac{\\Delta_{F}^2}{\\Delta_{ff'}^2}\\sum_{q,q'} \\big| o_{jf}^{j'f'} \\big|^2C_{f',b+q'}^{f,b;1, q'}C_{f',a+q}^{f,a;1, q} \\mathbf{e}_{q'}^* \\cdot (\\mathbf{e}_{\\rm in}\\mathbf{e}_{\\rm in}^* )\\cdot \\mathbf{e}_q,\n\t\\end{align}\n\\end{subequations}\n\t\\begin{align}\n\t\tw_{baq}^{f'm'q'}\n\t\t&\\approx  \\frac{\\Delta_{F}}{\\Delta_{ff'}+i\\Gamma_{f'}^q/2} \\big| o_{jf}^{j'f'}  \\big|^2 C_{f'm'}^{f,b;1 q}C_{f',m'}^{f,a;1,q'} (\\mathbf{e}_{q'}^* \\cdot \\mathbf{e}_{\\rm in}),\n\t\\end{align}\nwhere $ \\sigma (\\Delta_{ff'} )  = \\sigma_0 \\Gamma_0^2/4\\Delta^2_{f' f}$ is the the scattering cross section at the probe detuning in free space. \n\nNow, we consider a static magnetic field is applied to the atoms to fix the quantization axis to the $ \\mathbf{e}_{z} $ direction pointing along the waveguide axis.\nWe assume the magnetic field is so strong that the Larmor processing is much faster than the atomic decay and atom-photon interaction processes and the transverse components of the atomic angular momentum operators will be averaged out in the process of spin squeezing dynamics.\nIn theory, this leads us to transfer the master equations of the collective spin dynamics to the rotating frame determined by the fast-rotating transform operator\n\\begin{align}\n\\hat{U}_B(t) &= e^{-i\\Omega_Bt\\hat{f}_z},\n\\end{align}\nwhere $ \\Omega_B $ is the Larmor processing frequency of the external magnetic field.\nIn the rotating frame, a quantum operator $ \\hat{A} $ is transfered into $ \\hat{A}' $ through $ \\hat{A}\\rightarrow \\hat{A}'=\\expect{\\hat{U}_B^\\dagger\\hat{A}\\hat{U}_B }_T $, where the notation $ \\expect{\\cdot}_T=\\frac{1}{T}\\int\\cdot dt $ is the time average of observables in a period $ T $.\nThe density operator preserves its form in the rotating frame.\nWe can solve the transformed master equations by employing the Baker-Campbell-Hausdorff formula that $ e^{\\lambda\\hat{A}}\\hat{B}e^{-\\lambda\\hat{A}}=\\sum_{n=0}^\\infty\\frac{\\lambda^n}{n!}\\hat{C}_n $, where $ \\hat{C}_0=\\hat{B} $ and $ \\hat{C}_n=\\left[\\hat{A},\\hat{C}_{n-1} \\right] $ for $ n>1 $, and the commutators of atomic angular momentum operators, $ \\left[\\hat{f}_m, \\hat{f}_n\\right]=i\\sum_p\\epsilon_{mnp}\\hat{f}_p $.\nThe following static-rotating frame transformation relationships can be proved easily:\n\\begin{subequations}\\label{eq:rotationtransf}\n\t\\begin{align}\n\t\\hat{U}_B^\\dagger\\hat{f}_{x}\\hat{U}_B&=\\cos(\\Omega_Bt)\\hat{f}_x-\\sin(\\Omega_Bt)\\hat{f}_y,\\\\\n\t\\hat{U}_B^\\dagger\\hat{f}_{y}\\hat{U}_B &= \\sin(\\Omega_Bt)\\hat{f}_x+ \\cos(\\Omega_Bt)\\hat{f}_y, \\\\ \\hat{U}_B^\\dagger\\hat{f}_{z}\\hat{U}_B &=\\hat{f}_z,\\quad \\hat{U}_B^\\dagger\\hat{\\mathbbm{1}}\\hat{U}_B =\\hat{\\mathbbm{1}}.\n\t\\end{align}\n\\end{subequations}\nIn the rotating frame, operators with a transverse atomic angular momentum will be averaged to vanish. For example,\n\\begin{subequations}\\label{eq:rotationtransf_f}\n\t\\begin{align}\n\t\\hat{f}_{x}&=\\hat{f}_{y} \\rightarrow 0, \\quad \\hat{f}_{z}\\rightarrow\\hat{f}_z, \\quad \\hat{f}_{z}^ 2\\rightarrow\\hat{f}_z^2,\\\\\n\t\\hat{f}^2_{x} &= \\hat{f}^ 2_{y} \\rightarrow \\frac{1}{2}(\\hat{\\mathbf{f}}^2-\\hat{f}_z^2),\\\\\n\t\\hat{f}_{x}\\hat{f}_{y} &\\rightarrow\\frac{1}{2}\\hat{f}_z,\\quad \\hat{f}_{y}\\hat{f}_{x}\\rightarrow -\\frac{1}{2}\\hat{f}_z,\\quad \\hat{f}_{i=x,y}\\hat{f}_{z}\\rightarrow 0.\n\t\\end{align}\n\\end{subequations}\n\n\n\nUsing the transformation relationships defined in Eqs.\\eqref{eq:rotationtransf}, the loss Hamiltonian in the rotating frame becomes\n\\begin{subequations}\\label{eq:rotationtransf_hloss}\n\\begin{align}\n\\hat{h}_{\\rm eff} =-\\frac{i\\hbar}{2} \\sum_{f'}\\gamma'_s \\left[C_{ff'}^{(0)}\\hat{\\mathbbm{1}} + \\frac{C_{ff'}^{(2)}}{6}(\\hat{\\mathbf{f}}^2-3\\hat{f}_z^2 ) \\right],\n\\end{align}\n\\end{subequations}\nwhere $ z $-direction is the waveguide axis direction, and $ \\hat{\\mathbf{f}}^2=\\hat{\\mathbf{f}}\\cdot\\hat{\\mathbf{f}} $.\n\n\nBy using the transformation relationships of Eqs.\\eqref{eq:rotationtransf}, the jump operators become \n\\begin{subequations}\\label{eq:rotationtransf_Wxyz}\n\\begin{align}\n\\hat{W}_{x} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^x}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}/2} \\left[C_{ff'}^{(0)}\\hat{\\mathbbm{1}} + \\frac{C_{ff'}^{(2)}}{6}\\left(\\hat{\\mathbf{f}}^2-3\\hat{f}_{z}^2 \\right) \\right]\\\\\n\\hat{W}_{y} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} -\\frac{i\\sqrt{\\Gamma_{f'}^y}\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^y/2} C_{ff'}^{(1)}\\hat{f}_z  \\\\\n\\hat{W}_{z} &= 0.\n\\end{align}\n\\end{subequations}\n\nBy using the fact that \n\\begin{subequations}\n\\begin{align}\n\\hat{\\mathbf{f}}^2 &=f(f+1)\\hat{\\mathbbm{1}}\\\\\n\\hat{f}_z &=\\sum_{m=1}^{2f+1}(f-m+1)\\hat{\\sigma}_{mm}\\\\\n\\hat{f}_z^2 &= \\sum_{m=1}^{2f+1}(f-m+1)^2\\hat{\\sigma}_{mm}\n\\end{align}\n\\end{subequations}\nin the rotating frame, both $ \\hat{h}_{\\rm eff} $ and $ \\hat{W}_{q} $ become diagonal, and Eqs.\\eqref{eq:rotationtransf_hloss} and~\\eqref{eq:rotationtransf_Wxyz} can be simplified as\n\\begin{subequations}\n\\begin{align}\n\\hat{h}_{\\rm eff} &= -\\frac{i\\hbar}{2} \\sum_{f'} \\gamma'_s(f') \\sum_{m=-f}^f\\left[C_{ff'}^{(0)} + \\frac{C_{ff'}^{(2) }}{6}(f(f+1)-3m^2) \\right]\\hat{\\sigma}_{mm}\\\\\n\\hat{W}_{x} &= \\frac{1}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^x }\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^x/2 } \\sum_{m=-f}^f\\left[C_{ff'}^{(0)} + \\frac{C_{ff'}^{(2) }}{6}(f(f+1)-3m^2) \\right]\\hat{\\sigma}_{mm}\\\\\n\\hat{W}_{y} &= -\\frac{i}{\\sqrt{\\gamma_s}}\\!\\sum_{f'} \\frac{\\sqrt{\\Gamma_{f'}^y }\\Omega/2}{\\Delta_{ff'}+i\\Gamma_{f'}^y/2 } \\sum_{m=-f}^f C_{f'ff'}^{(1)}m\\hat{\\sigma}_{mm}\\\\\n\\hat{W}_z &=0.\n\\end{align}\n\\end{subequations}\nAfter some algebra, one can obtain the optical pumping master equation in the rotating frame as\n\\begin{align}\n\\left. \\dt{\\hat{\\rho}}\\right|_{\\rm op} \n&= - \\sum_{f'} \\gamma'_s(f') \\left[\\left(C_{ff'}^{(0)}+\\frac{f(f+1)}{12}C_{ff'}^{(2)} \\right)\\hat{\\rho}-\\frac{C_{ff'}^{(2)}}{4}(\\hat{f}_z^2\\hat{\\rho}+\\hat{\\rho}\\hat{f}_z^2) \\right]\\nn\\\\\n&\\quad+\\sum_{f',f''} \\frac{\\sqrt{\\Gamma_{f'}\\Gamma_{f''} }\\Omega^2/4 }{\\Delta_{ff'}\\Delta_{ff''}+\\Gamma_{f'}\\Gamma_{f''}/4+i(\\Delta_{ff''}\\Gamma_{f'}-\\Delta_{ff'}\\Gamma_{f''} ) }\\nn\\\\\n&\\quad\\cdot\\left\\{C_{ff'}^{(0)}C_{ff''}^{(0)}\\hat{\\rho}+ C_{ff'}^{(0)}C_{ff''}^{(2)}\\frac{\\hat{\\rho}}{6}(\\fo^2-3\\hat{f}_z^2) + C_{ff''}^{(0)}C_{ff'}^{(2)}(\\fo^2-3\\hat{f}_z^2)\\frac{\\hat{\\rho}}{6} \\right.\\nn\\\\\n&\\quad\\quad + \\frac{1}{2}C_{ff'}^{(1)}C_{ff''}^{(1)}(\\hat{f}_x\\hat{\\rho}\\hat{f}_x+\\hat{f}_y\\hat{\\rho}\\hat{f}_y+2\\hat{f}_z\\hat{\\rho}\\hat{f}_z )\\nn\\\\\n&\\quad\\quad -\\frac{1}{4}C_{ff'}^{(1)}C_{ff''}^{(2)}(\\fx\\rhoo\\fx-\\fy\\rhoo\\fy-2i\\fx\\rhoo\\fz\\fy+2i\\fy\\rhoo\\fx\\fz )\\nn\\\\\n&\\quad\\quad +\\frac{1}{4}C_{ff''}^{(1)}C_{ff'}^{(2)}(\\fx\\rhoo\\fx-\\fy\\rhoo\\fy-2i\\fz\\fy\\rhoo\\fx+2i\\fx\\fz\\rhoo\\fy ) \\nn\\\\\n&\\quad +C_{ff'}^{(2)}C_{ff''}^{(2)}\\left[\\frac{1}{4}f^2(f \\!+\\! 1)^2\\rhoo \\!-\\! \\frac{f(f \\!+\\! 1)}{6}(\\fo^2 \\!-\\! \\fz^2)\\rhoo \\!-\\! \\frac{f(f \\!+\\! 1)}{6}\\rhoo(\\fo^2 \\!-\\! \\fz^2) \\right.\\nn\\\\\n&\\quad\\quad\\quad+\\frac{1}{2}\\fx^2\\rhoo\\fx^2+\\frac{1}{2}\\fy^2\\rhoo\\fy^2+\\frac{1}{4}(i\\fz+2\\fy\\fx)\\rhoo(i\\fz+2\\fy\\fx)\\nn\\\\\n&\\quad\\quad\\quad +\\frac{1}{8}(i\\fy+2\\fx\\fz)\\rhoo(i\\fy+2\\fx\\fz)\\nn\\\\\n&\\quad \\quad\\quad \\left.\\left. +\\frac{1}{8}(i\\fx+2\\fz\\fy)\\rhoo(i\\fx+2\\fz\\fy) \\right]\\right\\}.\n\\end{align}\nAs a sanity check, we consider a far-detuning regime where the detuning on hyperfine sublevels is indistinguishable so that we can denote $ f''=f' $ and ignore all tensor polarizability terms where $ C_{ff'}^{(2)} $ presents, and the optical pumping part of the master equation above becomes\n\\begin{align}\n\\left.\\dt{\\rhoo}\\right|_{\\rm op} &= \\gamma'_s  \\left[C_{fj'}^{(0)}(C_{fj'}^{(0)}-1)\\rhoo+\\frac{1}{2}(C_{fj'}^{(1)})^2(\\fx\\rhoo\\fx+\\fy\\rhoo\\fy+2\\fz\\rhoo\\fz ) \\right]\\\\\n&= -\\frac{2\\gamma'_s}{9}+\\frac{\\gamma'_s}{18f^2}(\\fx\\rhoo\\fx+\\fy\\rhoo\\fy+2\\fz\\rhoo\\fz )\n\\end{align}\nfor the far-detuned $ D_1 $- and $ D_2 $-line transitions of cesium atoms,\nwhich is a well-known result in previous studies~\\cite{Deutsch2010a,Baragiola2014}.\nAbove, we have defined $ C_{fj'}^{(0)}=\\sum_{f'}C^{(0)}_{ff'}=1/3  $ for $ j'=1/2 $ or $ 2/3 $ for $ j'=3/2 $; $ C^{(1)}_{fj'}=\\sum_{f'}C^{(1)}_{ff'}=\\pm g_f/3 $ for $ j'=1/2 $ and $ j'=3/2 $, respectively, and $ g_f=1/f $ for our case. \n\n\n%</opticalpumpingwithmodifiedrates>\n\n%\\bibliography{Nanofiber}\n%\\bibliographystyle{amsplain}\n\\bibliographystyle{../styles/abbrv-alpha-letters-links}\n%\\bibliographystyle{unsrt}\n% \\nocite{*}\n\\bibliography{../refs/Archive,../chap5/Nanofiber}\n\n\\printindex\n\n\\end{document}          \n", "meta": {"hexsha": "1d6ba25347ff961e91d3d1c88c989754f7319b2d", "size": 28577, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap6/twocolor.tex", "max_stars_repo_name": "i2000s/PhD_Thesis", "max_stars_repo_head_hexsha": "a9bc6bc4213896c70c90cbb3d9b533782d428761", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-03-26T01:58:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-27T19:11:43.000Z", "max_issues_repo_path": "chap6/twocolor.tex", "max_issues_repo_name": "i2000s/PhD_Thesis", "max_issues_repo_head_hexsha": "a9bc6bc4213896c70c90cbb3d9b533782d428761", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-07-18T01:47:21.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-18T01:47:21.000Z", "max_forks_repo_path": "chap6/twocolor.tex", "max_forks_repo_name": "i2000s/PhD_Thesis", "max_forks_repo_head_hexsha": "a9bc6bc4213896c70c90cbb3d9b533782d428761", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-07-17T21:55:09.000Z", "max_forks_repo_forks_event_max_datetime": "2018-07-17T21:55:09.000Z", "avg_line_length": 94.0032894737, "max_line_length": 876, "alphanum_fraction": 0.6629107324, "num_tokens": 11146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.5078118642792044, "lm_q1q2_score": 0.41278366808273476}}
{"text": "\\section{Object Reconstruction}\n\\subsection{Tracks}\n\nBuilding a track, which represents the three dimensional path of the a charge particle, begins with forming hits in both the SMT and CFT tracking detectors. An SMT hit cluster is formed when a group of adjacent silicon strips register enough charge generated from an ionizing charged particle traversing the detector. The presence of the magnetic field in the SMT causes the electron-hole pairs to drift at an angle, known as the Lorentz angle. This drift angle is corrected for when determining the center of the silicon strip. The center of the hit cluster is formed by the charge weighted average of the centers of each silicon strip. The fine granularity of the SMT silicon strips allows an $x$-$y$-$z$ coordinate measurement for each hit in the detector. The axial resolution of an SMT hit is $10~\\mu m$ and the $z$ coordinate resolution is $35~\\mu m$. A hit in the CFT is formed when the two fibers in each layer register scintillation light indicating the presence of the charge particle traversing the fibers. The $x$-$y$ position of the hit can be measured because each fiber layers is rotated by $3^{\\circ}$~with respect to the beam axis. The $z$ hit position is inferred from the $x$-$y$ coordinate measurement and the fibers which produced the signal. \nThe axial resolution of a CFT hit is $100~\\mu m$ and the $z$ coordinate resolution $2$~cm.\n\nA track formed by pattern recognition software that takes SMT and CFT hit clusters as input to form a path in three dimensions, which represents the path of the charged particle. Because the tracking detectors are immersed in a $2$T magnetic field, the paths of the charged particles with be a three-dimensional helix as opposed to a straight line in absence of the magnetic field. The goal of the track finding algorithms is to combine SMT and CFT hits into possible track candidates and determine the parameters which fully define the track helix. There are two track finding algorithms employed in the $\\dzero$~event reconstruction software. The first algorithm uses a histogramming technique to find finds and the second algorithm uses a road method technique. These two techniques are described in more detail below. A global track reconstruction algorithm combines the output of the two algorithms to create a final set of reconstructed tracks.\n\n\\subsubsection{Histogramming Tracking Finding Method (HTF)}\n\\label{htf}\nThe histogramming method works by taking a list of hits in the SMT and CFT and transforming their coordinates transverse coordinates (x,y) into the ($\\rho$,$\\phi$) plane, where $\\rho$ is the track curvature and $\\phi$ is the azimuthal angle. The conversion to the new unit is done by a Hough transformation. Hits resulting from the same charged particle and thus the same track parameters will form a peak in this plane. The height of the peak will be $n(n-1)/2$, where $n$~is the number hits. This new histogram then goes through a cleaning procedure, called a 2D Kalman filter, which for the first time includes material related affects such as multiple scattering and energy loss. The Kalman filter has several tunable parameters such as the maximum $\\chi^{2}$ of the track fit and the minimum number is SMT and CFT hits. The result of the filter is to have at most one $r$-$\\phi$ hit in each layer and modified track parameters. The $z$~coordinate information is included by creating a new histogram in $(r,z)$ and performing a Hough transformation to the $(z_{0},C)$ plane, where $z_{0}$ is the position of the track along the origin and $C$ is the track inclination defined as $C = \\frac{dr}{dz}$. Finally, the tracks are extrapolated either inward toward the SMT if the track finding began in the CFT or outward toward the CFT if the track finding began in the inner SMT detector. The histogramming method has advantages over titional road finding algorithms because it does not need to compute all possible combinations of tracks, which grows exponentially with increasing luminosity. The method is also well suited to detectors without distinct layers such as the SMT detector.\n\n\n\\subsubsection{Alternative Algorithm Tracking (AA)}\n\\label{aa}\nThe alternative algorithm tracking method works by building a seed track in one layer and building a track by incrementally including more layers of the SMT and CFT detectors. The algorithm begins by taking SMT clusters in the innermost layers and adding additional layers if the axial angle between the next point and the beam spot is less than a certain tunable value. Additional layers are included if the previous condition is true and also if the resulting ius of curvature of the track hypothesis is greater than $30$~cm, which indicates the track must have $p_{T}>180$~MeV. The new track must also have a track fit $\\chi^{2}<16$. All possible combinations that meet these requirements are kept in the tracking algorithm for later filtering. The algorithm also allows for missing hits in the SMT or CFT by re-defining the track if a hit in one of the outer layers is consistent with a previously defined track. The number of such missing hits is a tunable parameter in the algorithm. AA tracking also allows for so-called CFT-only tracks built from seeds in the CFT detector that have less than 3 hits in the SMT detector. Allowing tracks to be built in this manner dramatically increases the overall efficiency of the algorithm. The final step in the algorithm is to remove overlapping tracks by selecting the track with the lowest $\\chi^{2}$.\n\n\n\\subsection{Primary Interaction Vertex}\n\\label{pvreco}\nThe primary hard scatter interaction vertex is very important to locate in to allow discrimination of physics objects resulting from the $\\ppbar$~collision and objects created from noise in the detector or other low energy inelastic $\\ppbar$~collisions. The primary vertex is defined as the three-dimensional position of the hard-scatter interaction. These vertices are found using the adaptive primary vertex algorithm. The algorithm begins by attempting to assign all tracks with $p_{T}>0.5$~GeV and at least two SMT hits to a vertex where the track paths intersect. The result of this first pass fit to the primary vertex is a $\\chi^{2}$ for each track. The algorithm then attempts a second path fit to the primary vertex except this time each track receives a weight, shown in Eq.~\\ref{pvweight}, that is contains to the $\\chi^{2}$ of the previous fit.\n\n\\begin{equation}\n\\label{pvweight}\nw_{i} = \\frac{1}{1+e^{(\\chi^{2}_{i} - \\chi^{2}_{\\rm{cutoff}})/2T}}\n\\end{equation}\n\nThe parameters $\\chi^{2}_{\\rm{cutoff}}$ and T are input parameters to the algorithm and have similar interpretations to the chemical potential and temperature in Fermi statistics. If the weight of the track is less than $10^{-6}$ the track is not included in the next round of fitting. This procedure is repeated until the difference of weights from the previous iteration for each track is less than $10^{-4}$.\n\nThe adaptive vertexing algorithm produces a list of possible vertices of which one might be the hard scatter vertex. To determine the hard scatter vertex a minimum bias~\\footnote{A minimum bias vertex is a vertex from an inelastic $\\ppbar$~collision.} vertex probability is calculated. The probability, shown in Fig~\\ref{minbias} peaks at zero for the hard-scatter vertex and is uniform for inelastic $\\ppbar$~collision vertices. The vertex used as hard-scatter vertex in an event is the one that has the lowest minimum bias probability. Finally, the vertex resolution of the algorithm for events with no heavy flavor production is 9.3 $\\mu$m and 12.8 $\\mu$m for events with heavy flavor.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.45\\textwidth]{eps/Reco/MBP_PV.eps}\n\\includegraphics[width=0.45\\textwidth]{eps/Reco/MBP_MB.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption[minbias]{Minimum bias probability for the hard-scatter vertex (left) and inelastic $\\ppbar$ vertices (right).}\n\\label{minbias}\n\\end{figure}\n\n\n\\subsection{Electrons}\nElectrons are characterized by narrow electromagnetic showers produced in the electromagnetic calorimeter. Electrons are first identified by searching for a cluster of EM calorimeter towers with energies above a given threshold value. Once a tower is found above threshold the electron candidate is defined as the towers surrounded the highest $E_{T}$ tower in a cone of ius 0.4. Since electrons are light they will deposit almost all of their energy in the first few layers of the electromagnetic calorimeter. Once the electron candidate is found it is required to have at least $90\\%$ of it's energy deposited in this region. The shape of the electromagnetic shower induced by the depleted uranium should also be consistent with an electron or photon. The shower shape is fit to the expected shower shape determined from simulation and the resulting $\\chi^{2}$ must be less than 50. To remove photons, which will produce similar deposits of energy and shower shapes, the electromagnetic cluster is required to be matched to a track found by the global track reconstruction algorithm. The matched track is then required to have $p_{T}>5$~GeV. To ensure that the electron is well measured it is also required to be narrow and isolated from other electromagnetic clusters. The isolation, defined in Eq.~\\ref{fiso}, is required to be less than 0.15\n\n\\begin{equation}\n\\label{fiso}\n\\rm{f_{iso}} = \\frac{E_{tot}(\\Delta R <  0.4) - E_{EM}(\\Delta R <  0.2)}{E_{EM}(\\Delta R <  0.2)}\n\\end{equation}\n\nFinally to ensure high quality electrons, likelihood discriminant is created using seven variables that will separate electrons from W/Z boson decays from jets with large electromagnetic fractions (fake electrons). Electrons with a likelihood discriminant greater than 0.85 are considered true electrons from a W/Z decay.\n\n\\subsection{Muons}\n\\label{muonreco}\nMuon are reconstructed by requiring hits in the layers of the muon system from both the scintillators and the wire chambers. Muons are required to register at least two wire hits and at least one scintillator hit in the A layer. If this condition is met, the muon is required to have at least two wire hits in the B and C layers as well as at least one scintillator hit in this region. By requiring hits in all three layers it is possible to construct a local momentum measurement due to the curvature induced by the toroid magnet; however, typically the resolution of this measurement is quite poor. To improve the resolution, the local muon track is required to be matched to a track found by the global track reconstruction algorithm. The track is required to be $\\Delta R<0.5$~from the local muon track. To remove muons produced by cosmic rays the muon is required to arrive at the three muon layers less than $10$~ns after the bunch crossing. To further reduce the cosmic ray background the muon track is required to originate from the primary vertex. The ensure this requirement the muon track must have a transverse distance of closest approach (DCA) less than 0.2 cm if there are no SMT hits and less than 0.02 cm if there is at least one SMT hit for the track. The track is also required to be within 1 cm of the primary vertex in the $z$ direction. The final background contamination to remove are muons from heavy flavor decays (e.g. $B \\rightarrow \\mu\\nu_{\\mu} D$). These muons tend to be embedded inside or nearby a jet since they are decay product of the boosted mesons that makeup the jet. To remove this background muons are required to be isolated ($\\Delta R(\\mu,\\rm{jet}) > 0.5$)~from nearby jets. Also, a muon track isolation variable, defined in Eq.~\\ref{trackiso}, is required to be less than 0.2. \n\n\\begin{equation}\n\\label{trackiso}\n\\frac{1}{p_{T}(\\mu)} \\times \\sum_{\\rm{tracks \\neq muon~ \\Delta R < 0.5 }}p_{T}(\\rm{track})\n\\end{equation}\n\nA similar variable for calorimeter tower energies, shown in Eq.~\\ref{caliso}, is also required to be less than 0.2.\n\n\\begin{equation}\n\\label{caliso}\n\\frac{1}{p_{T}(\\mu)} \\times \\sum_{\\rm{cal~tower~0.1 < \\Delta R < 0.4 }}E_{T}(\\rm{cal~tower})\n\\end{equation}\n\nMuons that satisfy all of these criteria are considered true muons from a W/Z decay.\n\n\n\\subsection{Jets}\n\\label{jetreco}\nA jet is the result of an strong interaction particle, such as a quark or gluon, that hadronizes producing a collection of collimated hadrons traveling in the same direction as the origination parton~\\footnote{A parton is a fundamental particle such as a quark or a gluon that is a constituent of a hadron.}. The Run II improved legacy cone algorithm~\\cite{Blazey:2000qt} is used to reconstruct jets in the $\\dzero$~calorimeter. This algorithm starts with calorimeter towers with transverse energies~\\footnote{The transverse energy is the energy of the calorimeter tower weighted by the sine of the polar angle $\\theta$ of the tower. $E_{T} = E \\times \\sin(\\theta)$.} greater than $0.5$~GeV and uses them as seeds around which the jet is built. If there is greater than $1$~GeV is total transverse energy in a cone ius if $0.5$ in $y-\\phi$~space~\\footnote{$y$~is the rapidity of the jet.}, then the collection of towers is considered a jet. The center of the jet is defined by the $E_{T}$ weighted midpoint of each calorimeter tower. If the cone axis of the jet is different from the previous iteration, a new jet is formed and the total $E_{T}$ is again calculated. This process is repeated until a stable jet is found. The result of this process is a list of stable jets with well-defined transverse energy $E_{T}$, rapidity $y$, and, azimuthal angle $\\phi$. The final step of the jet finding algorithm is to remove overlapping (duplicate) jets and either split large jets or merge nearby jets. Two overlapping jets are merged if they contain more than half of each others energy in their own jets. If the overlapping jets are not merged, then they are split into two distinct jets whose total $E_{T}$ and cone axis are then recomputed.\n\nCone jets have several advantages both experimentally and theoretically. Since the jets are defined by rapidity and $\\phi$, they are invariant under boosts along the longitudinal direction (beam axis). This is important because the longitudinal boost of the event will typically be large with resepect to the $\\ppbar$~rest frame. The other advantage of cone jets is they are infrared safe meaning that one can calculate jet properties in the low energy regime of a theory without incurring singularities.\n\nOnce the final list of jets has been created, the final step is to impose a set of quality criteria that will help remove fake jets created out of calorimeter noise and remove electromagnetic particles such as electrons and photons. To remove jets created by electromagnetic particles a jet is require to have between 5 and 95$\\%$ of it's energy deposited in the hadronic calorimeter because electrons and photons tend to deposit almost all of their energy in the electromagnetic calorimeter. Also, a jet is required to be isolated ($\\Delta R>0.5$) from all electromagnetic clusters in the detector. To remove fake jets created by calorimeter noise, the jet is required to have at least 60$\\%$ of it's energy deposited in the fine hadronic calorimeter since this detector gives significantly better energy measurements compared to the coarse hadronic calorimeter. To remove jets created by a single noisy tower all jets are required to have at least two or more calorimeter cells containing at least $90\\%$ if the jet energy. Also, the ratio of the most energetic tower to the second most energetic tower must be less than 10. \n\n\\subsection{Missing $E_{T}$}\nMissing transverse energy, $\\met$, is a useful quantity to calculate because it is highly correlated with the energy an undetected neutrino carries away from the events. The missing energy is only calculated in the transverse plane (x-y) because there is no net momentum in this plane since the collision only occurs along the beam axis. The total missing energy of the event can not be calculated however because of the unknown boost along the longitudinal direction from the hard scatter process.  The $\\met$~is formed by summing all calorimeter cells in the electromagnetic and fine hadronic calorimeters and then balanced so there is no net transverse momentum in the event. The $\\met$ is further corrected for high $p_{T}$ leptons in the event. The total $\\met$ is defined in Eq.~\\ref{met}.\n\n\\begin{equation}\n\\label{met}\n\\left[~\\sum_{\\rm{cells}} E_{T}~\\right]+ p_{T}(\\ell) + \\rm{ME}_{T} = 0\n\\end{equation}\n\n\\subsection{$B$-Jets}\n\\label{bidreco}\nEvents with heavy flavor jets (jets formed from initial $b$ or $c$ quarks) are important to measure because many fundamental particles, such as the top quark, will decay into a $b$ quark leaving it as one of the few signatures of it's existence. Jets formed from $b$ quarks are unique from other jets produced from light quarks because the $B$~meson (a combination of a $b$ quark and a light quark) has a much longer lifetime than lighter mesons. The result of this long lifetime is a displaced decay vertex from the primary interaction vertex. The typical decay length, which is the distance from the decay vertex from the primary vertex, is $\\sim$few mm. The goal of the $B$-jet finding algorithm is to use this information and more to identify heavy flavor jets from ordinary light flavor jets.\n\nThe $B$-jet selection algorithm at $\\dzero$~uses a neural network (NN) to separate events with heavy flavor (B,D mesons) from light flavor events. The neural network is trained on seven variables that show discrimination between heavy and light flavor events. The seven variables are shown in Table~\\ref{nnvars}. The neural network takes as input good quality jets and the tracks which point towards those jets. All jets must have at least two associated tracks with $p_{T}>1$~GeV. Jets that fail these criteria are considered light jets. The network was trained with $Z\\rightarrow b\\bar{b}$ and direct QCD $b\\bar{b}$ production as heavy flavor signal-like events and $Z\\rightarrow q\\bar{q}$ and QCD $q\\bar{q}$ production as light flavor background-like events. The output of the neural network is new probabilistic variable which peaks at 1 for jets with heavy flavor and 0 for light flavor jets. A jet is considered a $B$-jet if the NN value is greater than 0.775. For this choice of NN cut, the average $b$-tagging efficiency for central jets is $47\\%$ and a light jet mis-tag rate of $0.47\\%$.\n\n\\begin{table}[!h!tbp]\n\\begin{center}\n\\begin{tabular}{c|c}\n\\multicolumn{2}{c}\n{\\underline{Variables Used in $B$-jet Neural Network}} \\\\\nRank\t&\tVariable Description\t\\\\\n\\hline\n1\t\t&\tDecay length significance ($\\frac{L_{T}}{\\delta L_{T}}$) of the displaced vertex\t\\\\\n2\t\t&\tWeighed combination of the input tracks' impact parameter significance ($\\frac{IP}{\\delta IP}$)\t\\\\\n3\t\t&\tProbability that the jet originates from the primary interaction vertex\t\\\\\n4\t\t&\t$\\chi^{2}$/N$_{dof}$ of the displaced vertex fit\t\\\\\n5\t\t&\tNumber of tracks used to reconstruct the displaced vertex\t\\\\\n6\t\t&\tMass of the tracks used to reconstruct the displaced vertex\t\\\\\n7\t\t&\tNumber of displaced vertices found inside the input jets\t\t\\\\\n\\end{tabular}\n\\vspace{-0.1 in}\n\\caption[nnvars]{Variables used in the neural networks training. The variables are listed in order of relative importance as determined in the training.}\n\\label{nnvars}\n\\end{center}\n\\end{table} ", "meta": {"hexsha": "5d94fd099272535923180c0931174f7a48c4a601", "size": 19405, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reconstruction.tex", "max_stars_repo_name": "tgadf/thesis", "max_stars_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reconstruction.tex", "max_issues_repo_name": "tgadf/thesis", "max_issues_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reconstruction.tex", "max_forks_repo_name": "tgadf/thesis", "max_forks_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 171.7256637168, "max_line_length": 1819, "alphanum_fraction": 0.7824272095, "num_tokens": 4590, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.41274083085489865}}
{"text": "\\subsection{Memory Resistor}\n\nIn 2008, a group of researchers from HP labs published a paper entitled \\textit{``The missing memristor found''} \\cite{hp_memristor_found}. What, then, is a memristor, and how did we know it was missing? A memristor (short for memory resistor) is a resistor with memory whose resistance depends on the past flows of current passed through the circuit. The resistance of a memristor is increased by current travelling through it in one direction, and decreased by current travelling through it in the other direction. A memristor is a passive circuit which remembers its resistance even when inactive and without power for long periods of time. These properties make memristors interesting candidates for non-volatile storage and memory units, as they retain their state when unpowered, and specifically as they enable storage of continuous ranges of values (i.e. low \\textit{through} high resistance) in contrast to discrete binary values (i.e. 0 \\textit{or} 1) \\cite{memristors_a_new_frontier}.\n\nBack in 1971, Leon Chua, often referred to as the father of non-linear circuit theory, laid the mathematical foundation detailing the relations between the four fundamental circuit elements. Interestingly, at that time only three fundamental circuit elements had physical counterparts, namely resistors, capacitors and inductors. The fourth fundamental circuit element, the memristor, was only conceptualized in theory by Chua for the sake of symmetry (see figure \\ref{fig:circuit_elements}). As outlined in Chua's seminal paper \\textit{``Memristor-the missing circuit element''} \\cite{chua_memristor}, the current-$I$ voltage-$V$ curve of a memristor has a unique shape, an IV-fingerprint if you will, in the form of a pinched hysteresis loop (see figure \\ref{fig:pinched_hysteresis}). A hysteresis loop indicates that a system has an internal state (i.e. memory) which affects the output of the system and which depends on past inputs to the system \\cite{memristor_hayes}. As famously state by Chua, \\textit{``If it's pinched it's a memristor''} indicates that the hysteresis loop of a memristor passes through the origin.\n\n\\begin{figure}[htbp]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.5\\textwidth]{inc/circuit_elements.png}\n\t\t\\caption{Fundamental circuit elements.\\protect\\footnotemark}\n\t\t\\label{fig:circuit_elements}\n\t\\end{center}\n\\end{figure}\n\\footnotetext{Original image (CC BY-SA): \\url{https://en.wikipedia.org/wiki/File:Two-terminal_non-linear_circuit_elements.svg}}\n\n\\begin{figure}[htbp]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.5\\textwidth]{inc/pinched_hysteresis.png}\n\t\t\\caption{IV-curve of a memristor circuit, arrow indicates time.\\protect\\footnotemark}\n\t\t\\label{fig:pinched_hysteresis}\n\t\\end{center}\n\\end{figure}\n\\footnotetext{Original image (© Brian Hayes): \\url{https://www.americanscientist.org/libraries/documents/201128120228377-2011-03CompScienceHayes.pdf}}\n\nEver since 2008, there has been an exponential increase in research related to memristors, where the number of search results for ``memristor'' on Google Scholar has doubled every 18-24 months \\cite{memristors_a_new_frontier}. Why are so many researchers attracted to this new field of research? To answer this question, lets first evaluate the suitability of using current computer architectures in highly adaptive systems, such as brain-like learning systems with neural and synaptic placticity (i.e. adaptivity).\n\nMachine learning research has managed to achieve some truly remarkable milestones in recent years (e.g. AlphaGo beating the human world champion in Go \\cite{alphago}), both reaching and surpassing human potential on a number of tasks for which the brain is tailored towards, such as face recognition \\cite{facenet}, classification, and abnormality detection. Given this resent development, it may be tempting to imagine that it is only a matter of time until these machines achieve general problem solving skills through highly adaptive learning, which is fundamental for general artificial intelligence.\n\nHowever, the very nature of adaptivity introduces a significant challenge for today's computer architectures as it is inherently dependent on mutable states to reflect changes in the environment. To model these changes in state, data has to be shuffled back and forth between the processor and memory. The separation of processing and memory access is the underlying cause of two significant problems with current computer architectures. Firstly, it restricts the potential for parallel computation \\cite{net_doing_all_the_work} and introduces a set of complex workarounds (e.g. mutual exclusion, cache line invalidation). Secondly, and perhaps more importantly, a substantial amount of energy is required just to shuffle data back and forth between the processor and memory \\cite{ahah}.\n\nThere exist a huge discrepancy between the energy requirements of adaptive learning systems implemented in nature by biological brains and those implemented in silicon by machine learning algorithms running on von-Neumann computers. The difference in energy efficiency for adaptive learning tasks is estimated to be around 9 orders of magnitude. To put this into perspective, the brain would be able to travel around the entire earth on the same amount of energy that current computers would require to travel one and a half inches \\cite{memristors_a_new_frontier}. This is one compelling reason why researchers are interested in understanding the inner workings of the brain, so that fundamental principles for energy efficient adaptive learning may be derived and modelled.\n\n%Current computer architectures are designed around major bottlenecks, huge amounts of data has to be shuffled back and forth to perform computations. Reaching its limits; transistors now so small that they only allow a single electron to pass through (similar in size to the ion channels). At this scale, problems arise when transistors may allow electrons to pass through, when they shouldn't and wise versa; which leads to unpredictable behaviour (small bursts of ones when should be be all zero, and wise versa.)\n\n\n% NOTE:\n% * Discripancy\n%    - Discripancy between computers and biology in terms of energy efficiency when used for highly adaptive systems, such as a synaptic network.\n% * Root cause\n%    - the adaptive power problem, von-Neumann bottleneck.\n% * Why are they interesting?\n\n% ref: Tim Molter HiPeac Prague 2016 Memristor Keynote\n%\n% Denser memory, faster read and write, lower energy use, non-volatile, and may represent continuous (i.e. not 0 and 1).\n\n% ref: Tim Molter HiPeac Prague 2016 Memristor Keynote\n%\n% 1 billion fold discrepancy between current machine learning platforms and biological brains.\n%\n% We can operate on very low voltages because of the read and write phases that constantly repair relevant state.\n\n% === [ Subsections ] ==========================================================\n\n\\input{sections/2_models_of_associative_memory/3_memory_resistor/1_artificial_synapses}\n", "meta": {"hexsha": "0570354adb6d3d1256603e387de4f29121ec275e", "size": 7012, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/2_models_of_associative_memory/3_memory_resistor.tex", "max_stars_repo_name": "mewmew/associative_memories", "max_stars_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-30T12:08:22.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-30T12:08:22.000Z", "max_issues_repo_path": "report/sections/2_models_of_associative_memory/3_memory_resistor.tex", "max_issues_repo_name": "mewmew/associative_memory", "max_issues_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-04-04T00:06:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-02T13:32:52.000Z", "max_forks_repo_path": "report/sections/2_models_of_associative_memory/3_memory_resistor.tex", "max_forks_repo_name": "mewmew/associative_memory", "max_forks_repo_head_hexsha": "d0c50cf3efbcab9369f5a030125752253539d9e0", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 125.2142857143, "max_line_length": 1124, "alphanum_fraction": 0.8006274957, "num_tokens": 1554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477015, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.41271371055515876}}
{"text": "\\documentclass{article}\r\n\\usepackage[utf8]{inputenc}\r\n\\usepackage{lmodern}\r\n\\usepackage{microtype}\r\n\r\n\\usepackage{amsmath}\r\n\\usepackage{amsthm}\r\n\\usepackage{amssymb}\r\n\\usepackage{amsfonts}\r\n\\usepackage{mathtools}\r\n\\usepackage{commath}\r\n\\usepackage{mathrsfs}\r\n\r\n\\usepackage[backend=biber, style=alphabetic]{biblatex}\r\n\\addbibresource{documentation.bib}\r\n\r\n\\usepackage{graphicx}\r\n\r\n\\usepackage{hyperref}\r\n\\usepackage[noabbrev]{cleveref}\r\n\\usepackage{tabularx}\r\n\\usepackage{threeparttable}\r\n\\usepackage{enumitem}\r\n\r\n\\usepackage{siunitx}\r\n\r\n\\usepackage{listings}\r\n\\lstset{language=Matlab}\r\n\r\n\\usepackage{keystroke}\r\n\r\n\\usepackage{algorithm}\r\n\\usepackage{algpseudocode}\r\n\r\n\\newcommand{\\C}{\\mathbb{C}}\r\n\\newcommand{\\R}{\\mathbb{R}}\r\n\\newcommand{\\N}{\\mathbb{N}}\r\n\\newcommand{\\scrS}{\\mathscr{S}}\r\n\\newcommand{\\scrH}{\\mathscr{H}}\r\n\\newcommand{\\SD}{\\mathsf{SD}}\r\n\\DeclareMathOperator{\\FP}{FP}\r\n\\DeclarePairedDelimiter{\\inp}{\\langle}{\\rangle}\r\n\r\n% russian integral\r\n\\usepackage{scalerel}\r\n\\DeclareMathOperator*{\\rint}{\\scalerel*{\\rotatebox{17}{$\\!\\int\\!$}}{\\int}}\r\n\r\n\\newcommand{\\df}{\\textit}\r\n\r\n\\theoremstyle{definition}\r\n\\newtheorem{ex}{Example}\r\n\r\n\\title{Documentation}\r\n\\author{Alex Elzenaar}\r\n\\date{\\today}\r\n\r\n\\begin{document}\r\n  \\maketitle\r\n\r\n  \\tableofcontents\r\n\r\n  \\section{Overview}\r\n  The purpose of this MATLAB software package is to generate putatively optimal\r\n  spherical $(t,t)$-designs \\autocite{waldron2018}.\r\n\r\n  The package itself will only work on newer versions of MATLAB (it has been tested\r\n  on R2018b and above); it depends on the following packages beyond those that are\r\n  part of the `standard' MATLAB release:-\r\n  \\begin{itemize}\r\n    \\item Statistics and Machine Learning Toolbox\r\n  \\end{itemize}\r\n\r\n  In addition, should the user wish to use the \\texttt{generate.py} Python script to create\r\n  a nice index for their generated designs, they will require:\r\n  \\begin{itemize}\r\n    \\item The MATLAB Engine API for Python\\footnote{This is included by default with MATLAB but must be specifically installed. Documentation may be found at the\r\n          following URL: \\url{https://au.mathworks.com/help/matlab/matlab-engine-for-python.html}}\r\n  \\end{itemize}\r\n\r\n  \\section{Software usage}\r\n  In this section, we describe how the user can use the algorithm implementation to generate\r\n  putatively optimal spherical designs.\r\n\r\n  MATLAB files are located in the \\texttt{matlab/} subdirectory; all the scripts and procedures\r\n  are implemented in MATLAB unless otherwise stated.\r\n\r\n  \\subsection{The \\textproc{tightframe} method}\r\n  The main method available is \\textproc{tightframe}; this method takes the parameters\r\n  listed in \\cref{tab:tightframe_params} and produces the tuple of return values listed\r\n  in \\cref{tab:tightframe_returns}. Broadly speaking, the purpose of this method is to\r\n  produce a putatively optimal spherical $(t,t)$-design of $ n $ vectors in $ \\C^d $; the\r\n  three parameters here ($ d $, $ n $, and $ t $) are the most likely ones to be changed.\r\n  The fourth parameter, $ k $ (the number of iterations) is also one that most users might\r\n  wish to manipulate. The final parameters listed in the table allow the caller\r\n  to modify and fine-tune specific parts of the algorithm, and will be described in a later section.\r\n\r\n  \\begin{ex}\\label{ex:dnt_2_4_2}\r\n    The following command computes a putatively optimal $ (2,2)$-design consisting of four vectors in $ \\C^2 $:-\r\n    \\begin{lstlisting}\r\n[result, errors, totalBadness] =...\r\n  tightframe(2, 4, 2, 5000, 100, 10, 5000, 1, 1);\r\n    \\end{lstlisting}\r\n  \\end{ex}\r\n\r\n  The errors obtained over time may be plotted by MATLAB using the following commands:\r\n  \\begin{lstlisting}\r\nt = 1:length(errors);\r\nplot(t,errors);\r\nhold on;\r\nset(gca, 'YScale', 'log');\r\n  \\end{lstlisting}\r\n  An example plot corresponding to \\cref{ex:dnt_2_4_2} is included as \\cref{fig:example_error_plot}.\r\n  The plot produced should resemble an exponential decay curve, because as the number of iterations increases\r\n  the step size of the algorithm towards the variety of designs decreases proportionally.\r\n\r\n  The only return value of \\textproc{tightframe} which is obscure to understand is $ totalBadness $; when\r\n  this value is large compared to the total number of iterations, it means that the algorithm had trouble\r\n  finding a design (in the sense that it took many tries to get a single step closer to the variety of\r\n  designs). We shall make this more precise in a later section.\r\n\r\n  \\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=0.8\\textwidth]{example_error_plot}\r\n    \\caption{The error plot of a run with low badness.\\label{fig:example_error_plot}}\r\n  \\end{figure}\r\n\r\n  \\begin{ex}\r\n    \\Cref{fig:example_error_plot_2} shows a error plot of an example with extremely high badness (0.913); and\r\n    \\cref{fig:example_error_plot_3} shows an example with medium badness (0.706).\\footnote{Badness numbers will\r\n    usually be quoted as proportions:- $ totalBadness/k $ where $ k $ is the number of iterations completed.}\r\n\r\n    Note that in general a high badness corresponds to two characteristics of the error curve:\r\n    \\begin{itemize}\r\n      \\item A very long, shallow tail (i.e. for large $ x$-ordinates on the graph, $ \\od{y}{x} \\approx 0 $). This\r\n            is particularly noticable in \\cref{fig:example_error_plot_2}.\r\n      \\item A very `blocky' curve shape consisting of stretches of zero gradient interspersed with periods of\r\n            extreme decline. This can be seen in \\cref{fig:example_error_plot_3}.\r\n    \\end{itemize}\r\n    The shallow tail corresponds to the fact that the algorithm decreases its step size according to the total\r\n    badness (we shall discuss this in detail in a later section); the blockiness occurs because if it is `hard'\r\n    for the algorithm to find a better candidate for the design then the error will remain constant over long\r\n    stretches.\r\n\r\n    Both of the graphs in this example were generated with $ (d,n,t) = (3,5,3) $, and it\r\n    is known that there is no such design (see, e.g. the list given in \\autocite[\\S 6.16]{waldron2018});\r\n    this explains why the asymptote of the error graph is non-zero (in this case, it\r\n    appears to be $ \\approx 26 $).\r\n  \\end{ex}\r\n\r\n  \\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=0.8\\textwidth]{example_error_plot_2}\r\n    \\caption{The error plot of a run with high badness.\\label{fig:example_error_plot_2}}\r\n  \\end{figure}\r\n\r\n  \\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=0.8\\textwidth]{example_error_plot_3}\r\n    \\caption{The error plot of a run with medium badness.\\label{fig:example_error_plot_3}}\r\n  \\end{figure}\r\n\r\n  \\begin{table}\r\n    \\begin{threeparttable}\r\n    \\begin{tabularx}{\\linewidth}{r|X|l}\r\n      \\textbf{Parameter} & \\textbf{Description} & \\textbf{Sane value}\\\\\\hline\r\n      $d$ & Dimension of the space to embed the design into.\\\\\r\n      $n$ & Number of vectors in the design.\\\\\r\n      $t$ & Parameter of the $ (t,t)$-design.\\\\\r\n      $k$ & Number of iterations of the algorithm to run before returning.\\\\\r\n      $s$ & Number of inital seed matrices to check. & \\num{1e6}\\\\\r\n      $b$ & Number of attempts at walking down the line of the gradient before falling back to looking at a ball. & \\num{10}\\\\\r\n      $ap$ & Number of times to run alternating projection on each iteration. & \\num{10}\\thinspace\\tnote{a}\\\\\r\n      $errorMultiplier$ & Scale factor for the walking distance at each iteration. & $1\\times 10^{-4}$\\thinspace\\tnote{b}\\\\\r\n      $fd$ & MATLAB file descriptor for progress output. & 1\\thinspace\\tnote{c}\r\n    \\end{tabularx}\r\n    \\begin{tablenotes}\\footnotesize\r\n      \\item[a] According to \\autocite[\\S7.2.7]{tropp2004}, increasing $ ap $ beyond around \\num{5000} does not significantly\r\n               change the results obtained. However, note that in that thesis the projection algorithm itself is the convergence\r\n               procedure (as opposed to the current project, in which a separate convergence step is performed). Thus we only\r\n               need to run the projection a small number of times (and in fact larger numbers here will cause the Gram matrix\r\n               to drift away from the line of descent towards a low value of $ \\FP $).\r\n      \\item[b] If $ n $ is large, $ errorMultiplier $ should be made very small. For $ n \\leq 4 $,\r\n               $ errorMultiplier \\approx \\num{1e0} $ is OK; then decrease by powers of 10 from there. If\r\n               the number is too large, it is more likely that the algorithm will go too far past the\r\n               variety of $ (t,t)$-designs. If in doubt, set this small (especially if the badness proportion\r\n               ends up high on test runs) and increase $ k $.\r\n      \\item[c] Set to `1' for console output; for file output set to \\texttt{fopen('<filename>', 'w')}.\r\n    \\end{tablenotes}\r\n    \\end{threeparttable}\r\n    \\caption{Parameters for the \\textproc{tightframe} method.\\label{tab:tightframe_params}}\r\n  \\end{table}\r\n\r\n  \\begin{table}\r\n    \\begin{threeparttable}\r\n    \\begin{tabularx}{\\linewidth}{r|X}\r\n      \\textbf{Return value} & \\textbf{Description} \\\\\\hline\r\n      $result$ & A $ d \\times n $ matrix consisting of $ n $ column vectors in $ \\C^d $ which is putatively optimal\r\n                 according to the error function.\\\\\r\n      $errors$ & A $ k \\times 1 $ matrix where the $ i$th value is the minimum error of the best design found by\r\n                 iteration $ i $.\\\\\r\n      $totalBadness$ & The total number of times that the algorithm failed to improve the estimate by walking\r\n                       down the gradient. A more `efficient' run minimises $ totalBadness/k $ (where $ k $ is the\r\n                       number of iterations).\r\n    \\end{tabularx}\r\n    \\end{threeparttable}\r\n    \\caption{Return values for the \\textproc{tightframe} method.\\label{tab:tightframe_returns}}\r\n  \\end{table}\r\n\r\n  \\subsection{The \\texttt{runtf} script}\r\n  The \\textproc{tightframe} method is useful if the user wants to script the algorithm (e.g. try to run it for\r\n  lots of values of $ n $ to find the minimal $ n $ such that a $ (t,t)$--design in $ \\C^d $ exists). However,\r\n  if the user does not need this power they will probably want to use the wrapper script in \\texttt{runtf.m}.\r\n\r\n  In order to change the design parameters (the same as those listed in \\cref{tab:tightframe_params}, the user\r\n  should change the first few lines of \\texttt{runtf.m}; then the script (when run) will produce the following:\r\n  \\begin{itemize}\r\n    \\item The console output from \\textproc{tightframe} in the console verbatim.\r\n    \\item A printout (to the default number of decimal places) of the returned $ d \\times n $ matrix $ result $.\r\n    \\item A printout of the final error of that design (i.e. $ \\FP_{\\C^d,n,t}(result) $).\r\n    \\item A printout of the overall badness proportion $ totalBadness/k $.\r\n    \\item The parameters used for the generation of the design, together with the $ result $ matrix, the $ totalBadness $, and the list of $ errors $\r\n          in the file \\verb|tf_run_YYYY-MM-DD-HH-MM-SS.mat| (in the current directory).\r\n    \\item A plot of the best error over time (displayed on screen as a MATLAB figure).\r\n  \\end{itemize}\r\n\r\n  \\subsection{The \\textproc{compute3Products} method}\r\n  This method takes a single argument --- a $ d \\times n $ matrix $ A $ --- and computes the set of all $ n^3 $ 3--products of the vectors of $ A $,\r\n  sorted according to the MATLAB \\textproc{sort} method.\r\n\r\n  \\subsection{The \\texttt{generate.py} script}\r\n  The purpose of this script, located in the top-level directory, is to take a directory of \\texttt{.mat} files generated\r\n  by the \\texttt{runtf} method and produce a folder containing a nice HTML index of the generated designs.\r\n\r\n  The script takes one required argument --- the directory in which to look for the \\texttt{.mat} files. If the \\texttt{-R}\r\n  flag is specified, then the script will search recursively; otherwise it will search only the directory given and no subdirectories.\r\n  For each \\texttt{.mat} file it finds, the script will check whether it contains a variable called \\texttt{result}. If it does,\r\n  then it is copied to the output directory (default is \\texttt{html/}, but this may be changed using the \\texttt{-o} flag). An\r\n  \\texttt{index.html} file is also generated in the output directory containing a list of all the found designs, along with some\r\n  parameters ($d$, $n$, $t$, and $k $ from \\cref{tab:tightframe_params}, along with the error of the design found).\r\n\r\n  If the flag \\texttt{-e} is set, the script will attempt to connect to a running MATLAB instance; otherwise it will try to start\r\n  MATLAB itself. If connection to an existing MATLAB instance is needed, the user should note that some user interaction is required:\r\n  a command needs to be run in the MATLAB console and then the \\Enter key needs to be pressed to make the script continue. The command\r\n  needs only be run once for a given MATLAB instance, and to avoid the prompt one can give the flag twice (\\texttt{-ee}).\r\n\r\n  The up-to-date usage information for the script may be viewed by running \\texttt{python generate.py -h}.\r\n\r\n  \\section{Mathematical background}\r\n  Let $ \\scrH $ be a finite-dimensional Hilbert space of dimension $ d $ (so, as a vector space,\r\n  $ \\scrH \\simeq K^d $ for some field $ K $), and let $ \\scrS_\\scrH(n) $ be the set of finite\r\n  sequences of $ n $ elements of $ V $ with unit norm:\r\n  \\begin{displaymath}\r\n    \\scrS_\\scrH(n) := \\{ (v_i)_{i = 1}^n : \\forall_i (v_i \\in V \\text{ and } \\norm{v_i} = 1) \\}.\r\n  \\end{displaymath}\r\n\r\n  Suppose $ S $ is the unit sphere in $ \\scrH $, let $ \\sigma $ be a normalised measure\r\n  on $ S $, and suppose we have picked an orthonormal basis $ (w_i)_{i = 1}^d $ on $ \\scrH $.\r\n  Let $ \\pi $ be the projection map from $ \\scrH $ onto the subspace spanned by $ w_1 $,\r\n  and for each $ t \\in \\N $ define the \\df{bound weighting} $ c_t(\\scrH) $ to be the (real) quantity\r\n  \\begin{displaymath}\r\n    c_t(\\scrH) = \\left(\\rint_S \\norm{\\pi v}^{2t} \\dif{\\sigma(v)}\\right)^{-1}.\r\n  \\end{displaymath}\r\n  (Remark: the quantity $ c_t(\\scrH) $ is independent of the choice of basis.)\r\n\r\n  Finally, define the functions $ \\FP_{\\scrH,n,t} : \\scrS_\\scrH(n) \\to \\R $ by the rule\r\n  \\begin{equation}\\label{eqn:fp}\r\n    \\FP_{\\scrH,n,t} : (v_i)_{i = 1}^n \\mapsto\r\n          c_t(\\scrH) \\sum_{i = 1}^n \\sum_{j = 1}^n \\abs{\\inp{v_i, v_j}}^{2t}\r\n            - n^2.\r\n  \\end{equation}\r\n  The value of $ \\FP $ for a given design is called the \\textit{error} of that design.\r\n\r\n  Define the set $ \\SD_\\scrH(n,t) := \\FP_{\\scrH,n,t}^{-1}(0) $; the elements of this set\r\n  are called \\df{spherical $ (t,t)$-designs} of order $ n $, embedded in $ \\scrH $. (These\r\n  designs obviously also depend on $ \\sigma $, the spherical measure --- but usually this\r\n  comes naturally with $ \\scrH $.)\r\n\r\n  If $ \\scrH = \\R^d $ or $ \\scrH = \\C^d $ (with the usual inner product and with $ \\sigma $\r\n  the normalised surface area measure of the sphere) then one can precalculate the following\r\n  values \\autocite[122]{waldron2018}:-\r\n  \\begin{displaymath}\r\n    c_t(\\R^d) = \\frac{d(d+2)\\cdots(d+ 2(t-1))}{1\\cdot3\\cdot5\\cdots(2t-1)},\r\n    \\qquad\r\n    c_t(\\C^d) = \\binom{d+t-1}{t}.\r\n  \\end{displaymath}\r\n\r\n  The data of a design may be summarised by a $ d \\times n $ matrix $ V $ whose columns form\r\n  the $ n $ column vectors of the design with respect to the basis $ (w_i) $. A frequently\r\n  more useful representation, however, is the $ n \\times n $ \\df{Gram matrix} of the design:\r\n  \\begin{displaymath}\r\n    \\Gamma((v_i)_{i=1}^d) = [V^* V] = [\\inp{v_j,v_i}_{i,j}].\r\n  \\end{displaymath}\r\n\r\n  It can be shown that the Gram matrix $ \\Gamma $ has the following properties:\r\n  \\begin{enumerate}[label=(G\\arabic*)]\\label{pg:gram_properties}\r\n    \\item $ \\Gamma $ is Hermitian;\r\n    \\item $ \\Gamma $ has unit diagonal;\r\n    \\item $ \\Gamma $ is positive definite;\r\n    \\item $ \\Gamma $ has rank $ d $;\r\n    \\item $ \\Gamma $ has trace $ n $.\r\n  \\end{enumerate}\r\n  Note that (1) and (2) are conditions on the \\emph{entries} of $ \\Gamma $, while (3), (4), and (5) are conditions\r\n  on the \\emph{spectrum} of $ \\Gamma $.\r\n\r\n  We may also find the gradient of $ \\FP_{\\scrH,n,t} $ with respect to the entries of the Gram\r\n  matrix: we may rewrite $ \\FP $ in terms of $ \\Gamma $ as\r\n  \\begin{displaymath}\r\n    \\FP_(\\scrH,n,t) : \\Gamma \\mapsto c_t(\\scrH) \\sum_{i = 1}^n \\sum_{j = 1}^n \\abs{\\Gamma_{j,i}}^{2t} - n^2\r\n  \\end{displaymath}\r\n  and taking the partial derivatives of this, we obtain\r\n  \\begin{displaymath}\r\n    \\pd{\\FP}{\\Gamma_{i,j}} = t\\thinspace c_t(\\scrH)\\thinspace \\abs{\\Gamma_{i,j}}^{2(t-1)} \\thinspace \\overline{\\Gamma_{i,j}};\r\n  \\end{displaymath}\r\n  thus to decrease the frame potential we must perturb the Gram matrix in the direction $ -\\nabla \\FP $\r\n  where $ (\\nabla \\FP)_{i,j} = \\pd{\\FP}{\\Gamma_{i,j}} $.\r\n\r\n  \\section{Algorithms implemented}\r\n  In this section we will give pseudocode for the operations that are implemented by this\r\n  package, along with explaining various design choices and limitations of the approach.\r\n\r\n  \\subsection{The high-level method}\r\n  The high-level method is implemented in \\textproc{tightframe}, listed in \\cref{alg:high_level}.\r\n  The algorithm as described here does not take the $ fd $ parameter listed in \\cref{tab:tightframe_params},\r\n  as this is only used to print status updates.\r\n\r\n  We begin by choosing a good starting Gram matrix (line \\ref{line:seed}). We generate $ s $ different matrices\r\n  with the properties (G1)--(G5) (the `seed' matrices), and pick the one which minimises the potential function\r\n  to begin the iteration with.\r\n\r\n  The actual iteration begins on line \\ref{line:tf_iter}; the variable $ badCount $ holds the number of iterations\r\n  since the current best matrix $ A $ was found, and if $ badCount < b $ we attempt to walk down the gradient\r\n  a small random amount. The mean distance to walk, $ \\frac{error \\times errorMultiplier}{totalBadness + 1} $,\r\n  is proportional to $ error $ (so when we are `close' the distance we walk decreases), and inversely proportional\r\n  to $ totalBadness $ (so if we keep failing to find a good choice the step size decreases).\r\n\r\n  If $ badCount $ exceeds the parameter $ b $, we stop trying to walk down the gradient and instead we pick\r\n  random matrices from the `ball' $ B $ around $ A $ of mean distance $ error\\times errorMultiplier$. The idea here\r\n  is that if the badCount is high then we keep trying and failing to walk along the line of steepest descent\r\n  towards the variety of $ (t,t)$--designs, and so the path of steepest descent must be twisting sharply away\r\n  from the path it has been taking (\\cref{fig:badness_illustration}). The amount we try to walk along the path\r\n  of steepest descent keeps decreasing as the badness (i.e. failure rate) increases, but if the path is very\r\n  twisty then this permanently makes the walk distance tiny and so the convergence rate will become very slow.\r\n  Instead, if the $badCount$ becomes large, we instead look at the ball $ B $ (dotted blue) of (relatively) large radius, in\r\n  the hope that we will hit upon the path of steepest descent again after it has rounded the corner, we will tend\r\n  to skip part of the path and rejoin it on a straighter section (the dotted arrow on the figure) without having to\r\n  drop our rate of walking too far. This can be seen in the console output: long runs of \\texttt{*** Better found, ...} tend to\r\n  accompany very small decreases of the error, while occasional blocks of \\texttt{Nothing better}  tend to be followed by a sharp decrease\r\n  in the error. In order to take advantage of this, a healthy \\texttt{badnessProportion} should be around 0.7.\r\n\r\n  \\begin{figure}\r\n    \\centering\r\n    \\includegraphics[width=0.8\\textwidth]{badness_illustration}\r\n    \\caption{An intuitive depiction of the way counting `badness' allows the algorithm to skip twists in the path of steepest descent.\\label{fig:badness_illustration}}\r\n  \\end{figure}\r\n\r\n\r\n  In either case we have picked a new random candidate for Gram matrix near $ A $; we call it $ A_\\mathrm{new} $.\r\n  Since the randomisation process does not guarantee that $ A_\\mathrm{new} $ is Hermitian, we project it onto\r\n  the space of Hermitian matrices (line \\ref{line:make_hermitian}); then we attempt to project it onto the space\r\n  of matrices satisfying the properties (G1)--(G5). This is done by the method \\textproc{alternatingProjection}\r\n  described below; \\textproc{tightframe} passes into this method the parameter $ ap $ to modify the accuracy\r\n  of the alternating projection algorithm, as well as the matrix $ A_\\mathrm{new} $ and the desired rank $ d $.\r\n\r\n  Finally, we compute the error of the resulting matrix; if it is lower than the current best we set the $ badCount $\r\n  back to zero; otherwise we increase both $ totalBadness $ and $ badCount $.\r\n\r\n  When the loop is done, we are left with a Gram matrix $ A $ satisfying (G1)--(G5). The final diagonalisation process\r\n  undoes the map $ V \\mapsto \\Gamma = V*V $ which produces the Gram matrix from the initial vectors. The resulting\r\n  $ n \\times n $ matrix will have $ n - d $ zero rows (by consideration of the rank of $ A $) and so we project down\r\n  to $ \\C^d $ in the natural way to produce the final matrix $ result $ which is returned.\r\n\r\n  \\begin{algorithm}\r\n    \\caption{The high-level method}\\label{alg:high_level}\r\n    \\begin{algorithmic}[1]\r\n      \\Procedure{tightframe}{$d,n,t,k,s,b,ap,errorMultiplier$}\r\n        \\State Find a good starting matrix $ A $ which satisfies properties (G1)--(G5) by checking $ s $ different\r\n               matrices, $ A_1,...,A_s $ and calculating $\\FP_{\\C^d,n,t}(A_i)$ for each. \\label{line:seed}\r\n        \\State $ error \\gets \\FP_{\\C^d,n,t}(A) $\r\n        \\State $ errors \\gets [] $\r\n        \\State $ badCount \\gets 0 $\r\n        \\State $ totalBadness \\gets 0 $\r\n        \\State $ h \\gets 1 $\r\n        \\While{$ h \\leq k $} \\label{line:tf_iter}\r\n          \\State Append $ error $ to $ errors $.\r\n          \\If{$badCount < b $}\r\n            \\State $ \\delta \\gets $ a random positive value near $ \\frac{error \\times errorMultiplier}{totalBadness + 1} $\r\n            \\State $ A_{\\mathrm{new}} \\gets A - \\delta \\nabla\\FP_{\\C^d,n,t}(A) $\r\n          \\Else\r\n            \\State $ \\Delta \\gets $ an $ n \\times n $ matrix of random values near $ (error \\times errorMultiplier) $\r\n            \\State $ A_{\\mathrm{new}} \\gets A + \\Delta $\r\n          \\EndIf\r\n          \\State $ A_{\\mathrm{new}} \\gets \\frac{A_{\\mathrm{new}} + A_{\\mathrm{new}}^*}{2} $\\label{line:make_hermitian}\r\n          \\State Project $ A_{\\mathrm{new}} $ onto the space of matrices satisfying (G1)-(G5).\r\n          \\State $ error_\\mathrm{new} \\gets \\FP_{\\C^d,n,t}(A_{\\mathrm{new}}) $\r\n\r\n          \\If{$error_\\mathrm{new} < error$}\r\n            \\State $ A \\gets A_\\mathrm{new} $\r\n            \\State $ error \\gets error_\\mathrm{new} $\r\n            \\State $ badCount \\gets 0 $\r\n          \\Else\r\n            \\State $ badCount \\gets badCount + 1 $\r\n            \\State $ totalBadness \\gets totalBadness + 1 $\r\n          \\EndIf\r\n        \\EndWhile\r\n\r\n        \\State $ U \\gets $ the $ n \\times n $ matrix of eigenvectors of $ A $\r\n        \\State $ D \\gets $ the diagonal matrix of corresponding eigenvalues\r\n        \\State $ result \\gets D^{1/2}U $\r\n        \\State Delete the zero rows of $ result $, producing a $ d \\times n $ matrix (by rank of $ A $).\r\n        \\State Return $ (result, errors, totalBadness) $.\r\n      \\EndProcedure\r\n    \\end{algorithmic}\r\n  \\end{algorithm}\r\n\r\n  \\section{Further work to be done}\r\n  \\begin{itemize}\r\n    \\item Allow users to pass in an error function to be minimised.\r\n    \\item Add support for real designs.\r\n    \\item Save all generated designs in a database.\r\n    \\item Implement an algorithm to partition generated designs into unitary equivalence classes.\r\n  \\end{itemize}\r\n\r\n  \\printbibliography\r\n\\end{document}\r\n", "meta": {"hexsha": "525a46c5e640f28e566c9111aeb09c2f82046bad", "size": 23908, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/documentation.tex", "max_stars_repo_name": "aelzenaar/tightframes", "max_stars_repo_head_hexsha": "1176ab1f3a12ea958d919f1a67eda62a9693376b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/documentation.tex", "max_issues_repo_name": "aelzenaar/tightframes", "max_issues_repo_head_hexsha": "1176ab1f3a12ea958d919f1a67eda62a9693376b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-02-05T01:18:22.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-17T09:05:35.000Z", "max_forks_repo_path": "doc/documentation.tex", "max_forks_repo_name": "aelzenaar/tightframes", "max_forks_repo_head_hexsha": "1176ab1f3a12ea958d919f1a67eda62a9693376b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.2541176471, "max_line_length": 168, "alphanum_fraction": 0.6845825665, "num_tokens": 6657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.41271370180321976}}
{"text": "\\subsection{BRKGA implementation}\n\n\\subsubsection{Chromosome structure}\n\nSince in this problem all the nurses are equal in terms of schedule, to exploit the diversification of the chromosoem we have chosen between two approaches. The firsts is to assign each gene of the chromosome in order to each hour of the schedule (chromosome length $hours$). This ways we can sort the hours of the schedule and assign nurses to hours in that order. The other choice is instead to define an excess of working nurses for each hours, that is, to increase the demand of each hour randomly by the chromosome. We choose the second approach as it appears to diversify more in the initial tests that we have performed (around 20\\% of different fitness between individuals in each breed versus only around 5\\% for the first approach).\n\n\n\\begin{algorithm}[H]\n\\KwIn{chromosome, hours, demand, nNurses}\n%\\Parameter{Some parameter}\n\\KwOut{demand}    \n\n\\SetKwData{Left}{left}\n\\SetKwData{This}{this}\n\\SetKwData{Up}{up}\n\\SetKwFunction{Union}{Union}\n\\SetKwFunction{FindCompress}{FindCompress}\n\ni = 0 \\\\\n\\ForEach{$gene$ $\\in$ $chromosome$}{\n\n\t\\If{$gene < 0.2$}{\n\t\t$new\\_hourly\\_demand = ceil(demand_{i} \\cdot 0.8 \\cdot nNurses)  $ \\\\\n\t\t$demand_{i} = new\\_hourly\\_demand$ \\\\\n\t}\n\t$ i += 1$\\\\\n\n}\n\n$\\textbf{return}$ demand\n\\caption{BRKGA Decoding algorithm}\\label{brkga.decoding}\n\\end{algorithm}\n\n\n\\subsubsection{Decoder}\n\n\n\\begin{algorithm}[H]\n\\KwIn{population, nNurses, hours, demand, constraints}\n%\\Parameter{Some parameter}\n\\KwOut{population}    \n\n\\SetKwData{Left}{left}\n\\SetKwData{This}{this}\n\\SetKwData{Up}{up}\n\\SetKwFunction{Union}{Union}\n\\SetKwFunction{FindCompress}{FindCompress}\n\n\\ForEach{$individual$ $\\in$ $population$}{\nnew\\_demand $\\leftarrow decoding(individual, hours, demand, nNurses, constraints)$ \\\\\npopulation $\\leftarrow assignNurses(solution, nNurses, hours, new\\_demand)$ \\\\\n}\n$\\textbf{return}$ population\n\\caption{BRKGA Decoder algorithm}\\label{BRKGA.decoder.mainLoop}\n\\end{algorithm}\n\nAs illustrated in $Algorithm$ \\ref{BRKGA.decoder.mainLoop}, the decoder simply decodes each individual chromosome with $Algorithm$ \\ref{brkga.decoding}, and calls $assignNurses$ to assign the nurses according to the newly computed $new\\_demand$. Each solution is stored in the population with its corresponding fitness already computed in the $assignNurses$ function ($Algorithm$ \\ref{BRKGA.assignNurses}).\n\n\\begin{algorithm}[H]\n\\KwIn{solution, nNurses, hours, new\\_demand, constraints}\n%\\Parameter{Some parameter}\n\\KwOut{solution}    \n\n\\SetKwData{Left}{left}\n\\SetKwData{This}{this}\n\\SetKwData{Up}{up}\n\\SetKwFunction{Union}{Union}\n\\SetKwFunction{FindCompress}{FindCompress}\n\n\n\\ForEach{$h \\in hours$}{\n\t$mustWorkList, canWorkList = computeCandidateAssignments(solution, h, constraints)$\\\\\n\t\\ForEach{$n \\in mustWorkList$}{\n\t\t$ assignWorkingHour(solution, n, h)$\\\\\n\t\t$ demand_{h} \\leftarrow updateRemainingDemand(solution,h)$\\\\\n\t}\n\t\\ForEach{$n \\in canWorkList$}{\n\t\t\\If{$demand_{h} > 0$}{\n\t\t\t$ assignWorkingHour(solution, n, h)$\\\\\n\t\t\t$ demand_{h} \\leftarrow updateRemainingDemand(solution,h)$\\\\\n\t\t}\n\t}\n}\n\n\\If{$Feasible(solution)$}{\n\t$solution(fitness) \\leftarrow computeFitness(solution)$ \\\\\n}\n\\Else{\n\t$solution(fitness) \\leftarrow \\infty $\n}\n\n$\\textbf{return}$ solution\n\\caption{assignNurses}\\label{BRKGA.assignNurses}\n\\end{algorithm}\n\n\nAs shown in $Algorithm$ \\ref{BRKGA.assignNurses}, this algorithm assigns nurses to the schedule according to the demand and the constraints. For each possible hour in the schedule, in order, the algorithm selects the nurses that should work at this specific hour according to the constraints, and the nurses that could work at this specific hour according to the constraints (line 2). The function $computeCandidateAssignments$ walks through all the nurses, assigning the current hour and verifying if the nurse schedule is valid according to the constraints. From that \"canWorkList\", it walks through all the nurses from that list, removing the assignment in the specific hour and verifying if the schedule would be valid or not. That way it creates the second \"mustWorkList\" with nurses that must work to have valid schedules, removing them from the first list in order to have two disjoint sets. Once the two lists are set, it first assigns all the nurses that must work to have a valid schedule (lines 3 to 5). Each time, the remaining demand is updated (line 5). Then it walks throught the list of nurses that can work and assign the hour if and only if the remaining demand in that specific hour is positive (line 8). The final solution is then updated with its fitness, which is the same as the cost or number of nurses that work any hour during the schedule. If the solution is not feasible, that means that the demand is not fulfilled in each hour, then the fitness is set to be infinite or big enough.\n\n", "meta": {"hexsha": "dbcc6add13d92b09920f858d87765192f207d799", "size": 4825, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/tex/Metaheuristics-brkga.tex", "max_stars_repo_name": "presmerats/Nurse-Scheduling-LP-and-Heuristics", "max_stars_repo_head_hexsha": "0b4796d082908f6644bd28ad4bfad9552879ea75", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-10T02:38:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-10T02:38:12.000Z", "max_issues_repo_path": "Documentation/tex/Metaheuristics-brkga.tex", "max_issues_repo_name": "presmerats/Nurse-Scheduling-LP-and-Heuristics", "max_issues_repo_head_hexsha": "0b4796d082908f6644bd28ad4bfad9552879ea75", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/tex/Metaheuristics-brkga.tex", "max_forks_repo_name": "presmerats/Nurse-Scheduling-LP-and-Heuristics", "max_forks_repo_head_hexsha": "0b4796d082908f6644bd28ad4bfad9552879ea75", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-10T02:38:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-10T02:38:13.000Z", "avg_line_length": 48.7373737374, "max_line_length": 1511, "alphanum_fraction": 0.7641450777, "num_tokens": 1274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.4127136974272502}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{amsmath,amsfonts,amssymb,algorithm,algpseudocode}\n\\usepackage{graphicx,tikz,setspace}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage[mathscr]{euscript}\n\\usepackage[top=1in, left=1.5in, right=1.5in, bottom=1in]{geometry}\n\n\\newcommand{\\pd}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\setstretch{1.5}\n\n\\title{Practicum in Artificial Intelligence:\\\\ Optical Character Recognition via Neural Networks}\n\\date{December 12, 2012}\n\\author{Bryan Cuccioli (\\texttt{blc72@cornell.edu}), Mathematics \\& Computer Science, 2014\\\\\n\\and\nRenato Amez (\\texttt{ra374@cornell.edu}), Electrical \\& Computer Engineering, 2014}\n\n\\usetikzlibrary{calc,positioning,arrows,chains,decorations.pathreplacing,matrix}\n\n\\tikzset{\n>=stealth',\n  punktchain/.style={\n    rectangle, \n    rounded corners, \n    fill=black!5,\n    draw=black, very thick,\n    text width=9em, \n    minimum height=3em, \n    text centered, \n    on chain},\n  line/.style={draw, thick, <-},\n  element/.style={tape, text centered, on chain},\n  every join/.style={->, thick,shorten >=1pt},\n  decoration={brace},\n  tuborg/.style={decorate},\n  tubnode/.style={midway, right=2pt},\n}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\\pagebreak\n\n\\section{Abstract}\n\n\\emph{\nWe propose to design and train a feed-forward, multilayer neural network with back-propagation to perform optical character recognition. We give a formal definition of the problem of optical character recognition, and then exhibit the design and topology of such a neural network. We present experimental results relating several construction parameters, such as number of hidden layers, response threshold, and learning rate, independently to the output of our neural network.\n}\n\n\\section{Introduction}\nOptical character recognition (OCR) is an important problem in computer vision, with applications ranging from efficiently scanning books to recognizing cheques in an ATM. We aim to give a simple solution to the problem of OCR via training a neural network. In particular, we approximately model the human brain as a weighted directed graph and use training samples to tune the weights, enabling the network to compute the character corresponding to the representation in an image. This gives a relatively simple version of a general purpose \\emph{linear classifier}, more sophisticated versions of which are used in industry to perform OCR.\n\nWe exhibit the design and structure of such a network, and experimentally determine parameters of its construction that give optimal results.\n\n\\subsection{Formal Description}\n\nWe will now give a more precise definition of the problem of optical character recognition. Each image in our input set is of size $N\\times N$, consisting of pixel values in $\\{0,\\dots,M\\}$, and represents a digit between 0 and 9. That is, each image is a vector in the $N\\times N$-dimensional vector space $\\mathscr{V}$ taken over the Galois field $\\mathbf{F}=\\mathrm{GF}(M+1)$. We aim to construct a function\n\\begin{equation}\\varphi:\\mathscr{V}\\xrightarrow{\\ \\ \\ } \\{0,1,\\dots,9\\}\\end{equation}\nthat assigns to each image $v\\in\\mathscr{V}$ an output $n\\in \\{0,1,\\dots,9\\}$, such that the output corresponds to the digit represented in the image.\n\n\\section{Method}\n\nOur method for solving this problem is to create a multi-layer feed-forward neural network trained with back-propagation. A \\emph{neural network} is a directed weighted graph $G=(V,E)$ such that the set of \\emph{neurons} $V$ is partitioned into a set of \\emph{layers} $\\{L_1,\\dots,L_n\\}$, with $n\\geq 2$. The layer $L_1$ is called the \\emph{input layer}, and $L_n$ the \\emph{output layer}; the remaining layers are \\emph{hidden layers}, and all have the same cardinality. For each $i=1,\\dots,n-1$, we form the edge set between layers\n\\[E_i=\\{(u,v) : u\\in L_i\\mathrm{\\ and\\ } v\\in L_{i+1}\\}\\]\nso that our neural network has edges\n\\begin{equation}E=\\bigcup_{i=1}^{n-1} E_i.\\end{equation}\nWe also add to each layer a \\emph{bias node}, and create an edge from this node to every neuron in the layer.\n\nFor example, Figure \\ref{nn} shows a simple neural network with two hidden layers, each containing five neurons, an input layer containing four neurons, and an output layer containing three neurons, with no bias node.\n\n\\def\\layersep{2.5cm}\n\n\\vspace{1cm}\n\\begin{figure}[h]\n\\centering\n\\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\\layersep]\n    \\tikzstyle{every pin edge}=[<-,shorten <=1pt]\n    \\tikzstyle{neuron}=[circle,fill=black,minimum size=6pt,inner sep=0pt]\n    \\tikzstyle{input neuron}=[neuron];\n    \\tikzstyle{output neuron}=[neuron];\n    \\tikzstyle{hidden neuron}=[neuron];\n    \\tikzstyle{annot} = [text width=4em, text centered]\n\n    % Draw the input layer nodes\n    \\foreach \\name / \\y in {1,...,4}\n        \\node[input neuron, pin=left:Input \\#\\y] (I-\\name) at (0,-\\y) {};\n\n    % Draw the hidden layer nodes\n    \\foreach \\name / \\y in {1,...,5}\n        \\path[yshift=.5cm]\n            node[hidden neuron] (H1-\\name) at (\\layersep,-\\y cm) {};\n    \\foreach \\name / \\y in {1,...,5}\n        \\path[yshift=.5cm]\n            node[hidden neuron] (H2-\\name) at (5cm,-\\y cm) {};\n\n    % Draw the output layer nodes\n    \\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H2-2] (O1) {};\n    \\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H2-3] (O2) {};\n    \\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H2-4] (O3) {};\n\n    % Connect every node in the input layer with every node in the\n    % hidden layer.\n    \\foreach \\source in {1,...,4}\n        \\foreach \\dest in {1,...,5}\n            \\path (I-\\source) edge (H1-\\dest);\n\n    % Connect every node between the hidden layers\n    \\foreach \\source in {1,...,5}\n        \\foreach \\dest in {1,...,5}\n            \\path (H1-\\source) edge (H2-\\dest);\n\n    % Connect every node in the hidden layer with the output layer\n    \\foreach \\dest in {1,...,3}\n        \\foreach \\source in {1,...,5}\n            \\path (H2-\\source) edge (O\\dest);\n\n    % Annotate the layers\n    \\node[annot,above of=H1-1, node distance=1cm] (hl) {Hidden layer};\n    \\node[annot,above of=H2-1, node distance=1cm] (hl2) {Hidden layer};\n    \\node[annot,left of=hl] {Input layer};\n    \\node[annot,right of=hl2] {Output layer};\n\\end{tikzpicture}\n\\caption{Topology of a simple neural network} \\label{nn}\n\\end{figure}\n\\vspace{1cm}\n\nWe begin by initializing each edge weight to a random value in the interval $[-10,10]$. We then \\emph{feed forward} each input in the neural network to compute the output. This is done by computing for each neuron the weighted sum of its inputs, and then passing to the \\emph{sigmoid function} $\\sigma:\\mathbb{R}\\xrightarrow{\\ \\ \\ \\ } \\mathbb{R}_{\\geq 0}$ given by\n\\begin{equation}\\sigma(x) = \\frac{1}{1+e^{-x/a}},\\end{equation}\nwhere $a$ is the \\emph{activation threshold}. The function $\\sigma$ approximates an activation threshold to the perceptron, and has the advantage of being differentiable, which is necessary for the back-propagation step.\n\nFor each $i=2,\\dots,n$ in sequence, we compute for each neuron $j$\n\\begin{equation}b_j = \\sum_{k=1}^m w_{k,j} a_k, \\mathrm{\\ \\ \\ } a_j=\\sigma(b_j),\\end{equation}\nwhere $m$ is the number of neurons in each hidden layer, $w_{k,j}$ is the weight of the edge $(k,j)$, and the $a_k$ are initialized in the input layer to the values of the inputs. This is exhibited fully in Algorithm 1.\n\n\\begin{algorithm}\n\\caption{Feed forward}\n\\begin{algorithmic}[1]\n\\Function{FeedForward}{input $(x_1,x_2,\\dots,x_r)$}\n\\For{node $i$ in the input layer}\n  \\State $a_i \\gets x_i$\n\\EndFor\n\\For{$\\ell=2,...,n$}\n  \\For{node $j$ in layer $\\ell$}\n    \\State $b_j\\gets \\sum_i w_{i,j} a_i$\n    \\State $a_j \\gets \\sigma(b_j)$\n  \\EndFor\n\\EndFor\n\\State \\Return set of neurons in $L_n$\n\\EndFunction\n\\end{algorithmic}\n\\end{algorithm}\n\nTo facilitate learning in the neural network, it is necessary to update the edge weights after computing the output based on whether the output was correct. The process by which this is accomplished is called \\emph{back-propagation}. At a high level, the idea behind the back-propagation algorithm is that we can update the weights in the edges of $E_{n-1}$ in order to minimize the \\emph{loss}, a heuristic designed to measure the distance between the output and the desired output. This gives the desired activation values for the neurons of layer $L_{n-1}$, so we update the weights of edges in $E_{n-2}$ similarly, and recurse until the input layer is reached. \n\nWe will derive and analyze a method for computing the updated weights. Suppose that $\\mathbf{a}=(a_1,\\dots,a_s)$ is the input vector, and $\\mathbf{y}=(y_1,\\dots,y_r)$ is the desired output. Let $f$ be the function that implements the neural network, i.e. the function that takes in the input vector and weight vector $\\mathbf{w}$ consisting of all of the weights in the network, and returns the output layer $f(\\mathbf{a},\\mathbf{w})$. Define the ``loss function'' $\\mathscr{L}$ as\n\\begin{align}\\mathscr{L}(\\mathbf{a})&=\\sum_{i=1}^r (y_i - f(a_i,\\mathbf{w}))^2\\notag\\\\\n&=\\sum_{i=1}^r \\mathscr{L}_i(\\mathbf{a}).\\end{align}\n\nWe implement back-propagation as a form of hill-climbing search, following the gradient of the loss function in order to arrive at a local minimum. We begin by defining for each node $j$ in the output layer\n\\begin{equation}\\Delta_j = \\sigma'(b_j) \\cdot (y_j-a_j).\\end{equation}\nThen observe that at the output layer, we can compute the gradient of $\\mathscr{L}_k$ as\n\\begin{align}\\pd{\\mathscr{L}_k}{w_{j,k}} &= -2(y_k-a_k)\\pd{a_k}{w_{j,k}}\\notag\\\\\n&=-2(y_k-a_k)\\pd{\\sigma(b_k)}{w_{j,k}}\\notag\\\\\n&=-2(y_k-a_k)\\sigma'(b_k)\\pd{b_k}{w_{j,k}}\\notag\\\\\n&=-2(y_k-a_k)\\sigma'(b_k)\\pd{}{w_{j,k}} \\left(\\sum_{j} w_{j,k} a_j\\right)\\notag\\\\\n&=-2(y_k-a_k)\\sigma'(b_k)a_j\\notag\\\\&=-a_j \\Delta_k.\\end{align}\nThe gradients with respect to the weights in layers upstream from the output layer can now be computed. For each $i=n-1,\\dots,1$, we define for each neuron $j\\in L_i$,\n\\begin{equation}\\Delta_j = \\sigma'(a_j) \\sum_{k\\in L_{i+1}} w_{j,k} \\Delta_k,\\end{equation}\nso that\n\\begin{align}\\pd{\\mathscr{L}_k}{w_{i,j}} &= -2(y_k-a_k)\\pd{a_k}{w_{i,j}}\\notag\\\\\n&=-2(y_k-a_k)\\pd{\\sigma(b_k)}{w_{i,j}}\\notag\\\\\n&=-2(y_k-a_k)\\sigma'(b_k)\\pd{b_k}{w_{i,j}}\\notag\\\\\n&=-2\\Delta_k \\pd{}{w_{i,j}} \\left(\\sum_j w_{j,k} a_j\\right)\\notag\\\\\n&=-2\\Delta_k w_{j,k} \\pd{a_j}{w_{i,j}}\\notag\\\\\n&=-2\\Delta_k w_{j,k} \\sigma'(b_j) \\pd{b_j}{w_{i,j}}\\notag\\\\\n&=-2\\Delta_k w_{j,k} \\sigma'(b_j) \\pd{}{w_{i,j}}\\left(\\sum_i w_{i,j} a_i\\right)\\notag\\\\\n&=-2\\Delta_k w_{j,k} \\sigma'(b_j) a_i\\notag\\\\\n&=-a_i \\Delta_j.\\end{align}\nHence it remains to update each edge weight by adding the gradient of the loss function at that weight, multiplied by some pre-defined \\emph{learning rate} $\\lambda$. The full back-propagation algorithm is shown in Algorithm 2.\n\n\\begin{algorithm}\n\\caption{Back-propagate}\n\\begin{algorithmic}[1]\n\\Function{BackPropagate}{output $\\mathbf{a}$, correct output $\\mathbf{y}$}\n\\For{node $j$ in the output layer}\n  \\State $\\Delta_j \\gets \\sigma'(b_j)\\cdot (y_j-a_j)$\n\\EndFor\n\\For{$\\ell=n-1,\\dots,1$}\n  \\For{node $i$ in layer $\\ell$}\n    \\State $\\Delta_i\\gets \\sigma'(b_i) \\sum_{j\\in L_{\\ell+1}} w_{i,j}\\Delta_j$\n  \\EndFor\n\\EndFor\n\\For{weight $w_{i,j}$ in network}\n  \\State $w_{i,j}\\gets w_{i,j} + \\lambda\\times a_i\\times \\Delta_j$\n\\EndFor\n\\EndFunction\n\\end{algorithmic}\n\\end{algorithm}\n\nAt the top level, we use $t$ training examples per digit, computing the output through the neural network in each and then back-propagating in turn to update the weights. Each image is first resized from $28\\times 28$ to $6\\times 6$, and is then converted from grayscale to black and white using Otsu thresholding. This serves to reduce the dimensionality of the input, so that the input set can be fit more accurately to the weights. We construct a neural network with $6\\times 6$ neurons in the input layer, each corresponding to a pixel in the image, and 10 neurons in the output layer, each corresponding to a possible output $0,1,\\dots,9$, with activation values $a_i$ representing the network's confidence that $i$ is the correct output.\n\nWe then execute the training algorithm shown in Algorithm 3.\n\n\\begin{algorithm}\n\\caption{Train}\n\\begin{algorithmic}[1]\n\\Function{Train}{training set $S$}\n\\For{weight $w_{i,j}$ in $\\mathbf{w}$}\n  \\State $w_{i,j} \\gets \\mathrm{\\ small\\ random\\ value}$\n\\EndFor\n\\For{image $s\\in S$}\n  \\State $s\\gets \\mathrm{resize}(s)$\n  \\State $f(\\mathbf{s},\\mathbf{w})\\gets \\mathrm{FeedForward}(\\mathbf{s})$\n  \\State BackPropagate($f(\\mathbf{s},\\mathbf{w})$, desired output)\n\\EndFor\n\\EndFunction\n\\end{algorithmic}\n\\end{algorithm}\n\nThe \\emph{success} of the neural network is measured by running the above algorithm on some distinct set of $T$ images without the BackPropagate stage and counting for how many images the correct value was output.\n\n\\section{System Architecture}\n\nThe implementation of the system is divided among four main classes. Although an approach not based on object-oriented programming using only a three-dimensional array to store weights and activation values is possible, the structure of a neural network and modularization of the project lend themselves well to a class-based approach.\n\n\\begin{enumerate}\n\\item \\texttt{ImageData}: This class is responsible for reading in images from the data set, resizing them, and thresholding them from grayscale to black and white. Image processing is done via the OpenCV \\footnote{\\url{http://opencv.org}} library.\n\n\\item \\texttt{Neuron}: This class represents a single neuron in the network. Each neuron stores its activation value and the weights of its incoming edges. It handles the logic for randomly assigning values to these weights upon initialization as well as for computing the linear combination of its inputs.\n\n\\item \\texttt{Layer}: This class represents a layer of the neural network. It stores an array of neurons belonging to this layer, and handles the logic for initializing each neuron.\n\n\\item \\texttt{NeuralNet}: This class represents the neural network at the top level. It handles the logic for initializing each layer and implements the FeedForward and BackPropagate algorithms.\n\\end{enumerate}\n\n\\vspace{.5cm}\n\\begin{figure}[h]\n\\centering\n\\begin{tabular}{ccc}\n\\begin{tikzpicture}\n  [node distance=.8cm, start chain=going above,]\n  \\node[punktchain, join] (neuron) {\\texttt{Neuron}};\n  \\node[punktchain, join] (layer) {\\texttt{Layer}};\n  \\node[punktchain, join] (neuralnet) {\\texttt{NeuralNet}};\n\\end{tikzpicture}\n& \\hspace{.75cm} &\n\\begin{tikzpicture}\n  [node distance=.8cm, start chain=going above,]\n  \\node[punktchain] (imagedata) {\\texttt{ImageData}};\n\\end{tikzpicture}\n\\end{tabular}\n\\caption{Class structure} \\label{classes}\n\\end{figure}\n\\vspace{.5cm}\n\nTraining and testing is done using Google's MNIST database \\footnote{\\url{http://yann.lecun.com/exdb/mnist/}}. As part of pre-processing, a simple C\\# script\\footnote{\\url{https://gist.github.com/4056614}} was used to convert the glob of pixel values to 10,000 JPEG images suitable for processing. \n\n\\section{Experimental Evaluation}\n\n\\subsection{Methodology}\n\nThe interface to the program supports specifying several variables that we test in relation to the success of the network, including\n\n\\begin{itemize}\n\\item $t$: the number of training samples per digit;\n\\item $\\ell$: the number of hidden layers in the network;\n\\item $h$: the number of neurons per hidden layer;\n\\item $b$: the weight of the bias;\n\\item $\\lambda$: the learning rate of the network, as defined above;\n\\item $r$: the response threshold for the sigmoid function.\n\\end{itemize}\nWe vary each of these parameters independently over several discrete values, holding fixed the size of the test sample set $T=100$. Training and test data samples are taken from the MNIST database, a collection of 10,000 handwritten digits. Recognizing digits simplifies the problem of learning optical character recognition without loss of generality; it can easiy be extended to learning to recognize all handwritten characters.\n\n\\subsection{Results}\n\nThe hypothesis established before beginning the experimental trials was that increasing every one of the above parameters separately would increase the success rate of the neural network roughly linearly. Experimental trials show that each of the parameters affects the output in this way between some lower and upper bound.\n\nWe found that the learning rate $\\lambda$ is one such parameters which increases the success up to some upper bound. We fix $\\ell=1$, $h=45$, $t=800$, $r=55$, and $b=60$. With $\\lambda=1$, we get $\\mu=10.3\\% \\pm 1.1\\%$. With $\\lambda=10$, we get $\\mu=27.0\\% \\pm 1.3\\%$. With $\\lambda=40$, we get $\\mu=34.4\\% \\pm 1.4\\%$. However, with $\\lambda=50$, we get $\\mu=27.2\\% \\pm 1.2\\%$, and the results similarly decrease from there, indicating that the optimal value for $\\lambda$ is approximately 40.\n\nWe found that having one hidden layer is optimal for our neural network. With $\\lambda=40$ and the other parameters fixed as above, we find that with $\\ell=0$, we get $\\mu=12.3\\% \\pm 1.3\\%$. With $\\ell=1$, we get $\\mu=34.4\\% \\pm 1.4\\%$, as above. With $\\ell=2$, we get $\\mu=23.8\\% \\pm 1.6\\%$, and with $\\ell=3$, we get $\\mu=12.7\\% \\pm 0.8\\%$. This makes intuitive sense: having too few nodes available should make it hard for the network to generalize to the entire dataset, while having too many subjects the network to \\emph{overfitting}.\n\nBy the same reasoning, we intuit that there will be some middle value for $h$ that is optimal. Experimental results confirm this: with $h=25$ we get $\\mu=15.7\\% \\pm 0.7\\%$; with $h=45$ we get $\\mu=30.4\\% \\pm 1.2\\%$; with $h=55$, we get $\\mu=35.1\\% \\pm 1.4\\%$, and the outputs stay approximately constant up through at least $h=100$ (fixing the optimal values above for the other parameters).\n\nWe found that the response threshold $r$ greatly influences the success of the neural network. Fix the other parameters as above, with $h=45$. With $r=25$, we get $\\mu=15.2\\% \\pm 2.2\\%$; with $r=35$, we get $\\mu=23.8\\%\\pm 2.0\\%$; with $r=55$ we get $\\mu=31.8\\% \\pm 1.6\\%$; with $r=65$ however we get $\\mu=20.0\\% \\pm 1.9\\%$. Intuitively, it makes sense that having a value for $r$ that is slightly too large or too low can drastically affect the outcome, as it skews the already steep slope of the sigmoid curve.\n\nThe bias element also has a weak effect on the outcome. Having a bias $b=0$ gives an output $\\mu=27.6\\% \\pm 1.6\\%$; having a bias $b=20$ gives an output $\\mu=28\\%\\pm 1.4\\%$; we see that optimally the bias $b=60$ gives an output of $\\mu=32.1\\% \\pm 2.0\\%$; however, having a bias $b=70$ causes the output to drop to $\\mu=21.3\\% \\pm 1.7\\%$.\n\nFinally, we observe that the number of training examples $t$ used has a strong effect on the success of the network, with diminishing returns. Fixing the other parameters with the above-determined values, with $t=200$ gives output $\\mu=17.1\\% \\pm 1.8\\%$; using $t=400$ gives output $\\mu=29.2\\%\\pm 1.9\\%$; with $t=600$ we have $\\mu=31.2\\%\\pm 2.3\\%$; with $t=900$ we have output $\\mu=29.8\\% \\pm 2.2\\%$, approximately the same result as with $t=600$. It is expected that the success of the neural network should level off as $t\\to\\infty$, since many of the training examples are very similar and eventually the weights are changing by very small amounts.\n\n\\section{Future Work}\n\nThe major shortcoming with using a neural network is that it does not achieve a high rate of recognition. While recognition rates in the neighborhood of 35\\% indicate that the model is at least somewhat successful, it is unable to adapt the weights to the resolution required for 90\\% or greater recognition. It appears that the neural network model is not general or adaptable enough to perform OCR effectively.\n\nThere are a number of methods from computer vision that can be used to increase the efficacy of OCR. For example, many commercial OCR solutions use feature detection mechanisms such as computing the Laplacian of a Gaussian convolved with the image and then compare local features using e.g. scale-invariant feature transform (SIFT) to measure similarity between images$^3$. These methods could be incorporated into future versions of the project.\n\nThe neural network can also be adapted to a more robust detection mechanism. In particular, one could train a network to recognize for each $i\\in \\{0,\\dots,9\\}$ whether an input simply represents $i$ or not, and then apply all 10 neural networks to determine the digit in the image.\n\n\\section{Conclusion}\n\nBy constructing a multilayer feed-forward neural network and training it using back-propagation, we are able to implement a simple classifier that recognizes handwritten digits with a non-trivial success rate of approximately 35\\%. Via experimentation, we determined that our neural network optimally has one hidden layer containing $h=45$ neurons, uses approximately $t=600$ training examples per digit, has a response threshold of $r=55$, a bias of $b=60$, and a learning rate of $\\lambda=40$. These results make intuitive sense, as they achieve an optimal balance between under- and over-fitting the data.\n\nWhile the neural network alone was able to achieve a success rate indicating that it is learning, it was not able to achieve a practically-applicable success rate alone. We posit that a neural network in combination with feature detection and extraction algorithms will perform significantly better.\n\n\\section{References}\n\n\\begin{enumerate}\n\\item \\emph{``OpenCV''}. Visited December 12, 2012. $<$\\url{http://opencv.org}$>$.\n\n\\item Cortes, LeCun. \\emph{``The MNIST Database of Handwritten Digits''}.\\\\\nVisited December 12, 2012. $<$\\url{http://yann.lecun.com/exdb/mnist/}$>$.\n\n\\item Szeliski, Richard. \\emph{Computer Vision: Algorithms and Applications.}\\\\ New York: SpringerLink, 2011.\n\n\\end{enumerate}\n\n\\section{Appendix: Code Tree}\n\n\\begin{itemize}\n\\item \\texttt{main.cpp}: The main driver program, implements the top-level algorithm.\n\n\\item \\texttt{Neuron.h}: Defines the \\texttt{Neuron} class, contains logic for initializing a neuron and computing its activation.\n\n\\item \\texttt{Layer.h}: Defines the \\texttt{Layer} class, contains logic for initializing a layer of neurons.\n\n\\item \\texttt{NeuralNet.h}: Defines an interface for the variables and methods of the \\texttt{NeuralNet} class.\n\n\\item \\texttt{NeuralNet.cpp}: Implements forward-feeding and back-propagation for the \\texttt{NeuralNet} class.\n\n\\item \\texttt{ImageData.h}: Defines an interface for the \\texttt{ImageData} class, which handles processing of JPEG images into suitable pixel arrays.\n\n\\item \\texttt{ImageData.cpp}: Implements the methods of the \\texttt{ImageData} class.\n\n\\item \\texttt{Makefile}: Build system used for compiling the project.\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "2dc1856f3e1698e907546ff441a27ab83640cfab", "size": 22709, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/final.tex", "max_stars_repo_name": "stepany4/neural-ocr", "max_stars_repo_head_hexsha": "3d669fbdcdf5bfc9908f0824678071b240795768", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "papers/final.tex", "max_issues_repo_name": "stepany4/neural-ocr", "max_issues_repo_head_hexsha": "3d669fbdcdf5bfc9908f0824678071b240795768", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/final.tex", "max_forks_repo_name": "stepany4/neural-ocr", "max_forks_repo_head_hexsha": "3d669fbdcdf5bfc9908f0824678071b240795768", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.3857566766, "max_line_length": 743, "alphanum_fraction": 0.7308556079, "num_tokens": 6536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.6406358548398982, "lm_q1q2_score": 0.41271369305128064}}
{"text": "\\documentclass[11pt]{article}\n\n\\pagestyle{empty}                         %%%% No page Numbering\n \n% Mathews packages....\n\\usepackage{amsbsy,amsmath,amssymb,psfig} \n\\usepackage{times,mathpi,mathptm} \n\\usepackage{graphicx,psfrag,rotating,subfigure} \n\n\\begin{document}\t\n\\section{Calculation of the sparsity pattern for Mixed formulation}\n\t\nIn the mesh migration problem, it is useful to use a first order\nelement-element adjancy matrix when a mixed formulation is being used\nby the solver. To see why, consider\nFigure~\\ref{fig:mixedgraph}. Normally the yellow elements define the\nmesh overlap, or halo, between two domains. In the case of a mixed\nformulation, some field values are stored and solved on a more sparce\nmatrix pattern. For the mixed formulation considered here, all\nelements adjacent to yellow elements, are also required on the\nneighbouring domain. The elements of interest are coloured blue in\nFigure~\\ref{mixedgrapg}. \n\nDefine $\\pmb{E}$ as the element-element adjancy matrix over all the\ndomains where\n\\begin{displaymath}\nE_{ij} = \\left\\{ \\begin{array}{ll}\n1 & \\textrm{if element $i$ shares nodes with element $j$ and $i \\ne j$,}\\\\\n0 & \\textrm{otherwise}\n\\end{array} \\right.\n\\end{displaymath}\n\n\\begin{figure}[h]\\label{fig:mixedgraph}\n\\centering\n\\includegraphics[width=80mm]{images/mixed}\n\\caption{Yellow indicates elements in the halo between two domains\ndivided by the dashed line. The blue elements indicates the additional\nelements that need to be communicated to the neighbouring domains in\nthe mixed formulation}\n\\end{figure} \n\nNext we define $\\pmb{D}_s$ is the element distribution across the domains\n\\begin{displaymath}\nD_{s_i} = \\left\\{ \\begin{array}{ll}\n1 & \\textrm{if element $i$ has nodes assigned to domain $s$,}\\\\\n0 & \\textrm{otherwise}\n\\end{array} \\right.\n\\end{displaymath}\nThus, the yellow halo elements between domains $s$ and $r$ can be\ndefined by $pmb{H}_{sr} = \\pmb{D}_s \\otimes \\pmb{D}_r$. \n\nFinally, let us define $\\pmb{B}_{sr}$ as the non-halo elements in\ndomain $s$, which have to be sent with some specific field values to\ndomain $r$;\n\\begin{equation}\nB_{sr_i} = S( (H_{sr_i}\\pmb{E}_i ).D_s )\n\\end{equation}\n\nwhere the function $S$ is defined by\n\\begin{displaymath}\nS(x) = \\left\\{ \\begin{array}{ll}\n1 & \\textrm{for $x \\ne 0$,}\\\\\n0 & \\textrm{otherwise}\n\\end{array} \\right.\n\\end{displaymath}\n\n\\end{document} \n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "57aeb17ec26a81597db7abd0ebf4833aa9d1baa2", "size": 2353, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "libadaptivity/load_balance/doc/mixed.tex", "max_stars_repo_name": "luh1202/DynEarthSol", "max_stars_repo_head_hexsha": "60a46924fc9b7cac72f66554c78930c50f3817d0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2019-09-25T08:10:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-20T07:47:05.000Z", "max_issues_repo_path": "libadaptivity/load_balance/doc/mixed.tex", "max_issues_repo_name": "luh1202/DynEarthSol", "max_issues_repo_head_hexsha": "60a46924fc9b7cac72f66554c78930c50f3817d0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-11-25T17:35:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T09:58:45.000Z", "max_forks_repo_path": "libadaptivity/load_balance/doc/mixed.tex", "max_forks_repo_name": "luh1202/DynEarthSol", "max_forks_repo_head_hexsha": "60a46924fc9b7cac72f66554c78930c50f3817d0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2019-09-27T02:15:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-05T15:38:52.000Z", "avg_line_length": 30.9605263158, "max_line_length": 74, "alphanum_fraction": 0.7365065873, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.41271188122389924}}
{"text": "\\documentclass[11pt]{article}\n\\newcommand\\tab[1][1cm]{\\hspace*{#1}}\n\\usepackage{graphicx}\n\\graphicspath{ {C:/Users/yedkk/Desktop/CS465/hw4} }\n\\begin{document}\n\\section{Homework 4}\nName: Kangdong Yuan\n\t\n\\subsection{problem1}\na).I did not work in a group.\n\\\\b).I did not consult without anyone my group members\n\\\\c).I did not consult any non-class materials.\n\n\\subsection{problem2}\nFirst we need to count the number of vertices $|V|$ in this graph G. We count the number of edge in this graph by dfs or bfs. if the count of edges exceed $|V|-1$, return yes. If there are only $|V|-1$ edges in graph G, we return no.  \\\\\nThe time to count vertices is $|V|$, and the time to count $|V|$ edges is $O(|V|)$. So, the time complexity of this algorithm is $2|V|=O(|V|)$ \n\n\\subsection{problem3}\na). the minimum spanning tree will not change\\\\\n\\\\the reason behind it: if graph has n vertices, then any spanning tree of G has $n-1$ edges. We define the cost of each spanning tree are $x_1,x_2,x_3,...x_j$. If each edge's weight decrease by 1, the cost of every spanning tree will decrease  by a constant $n-1$. So, the new cost of each spanning tree are $x_1-(n-1),x_2-(n-1),x_3-(n-1),...x_j-(n-1)$. Thus, the order of cost of spanning trees will not change, so the mst will still be the mst in new graph after weight changing.   \\\\\n\\\\\nb).but the shortest path may change\\\\\nfor example, this is the original graph, the shortest path from vertex 1 to vertex 2 is edge(1,2)\\\\\n\\includegraphics[scale=0.2]{og1}\\\\\nThis is the new graph that all edge weights minus 1, the shortest path from vertex 1 to vertex 2 is edge (1,3), (3,2)\\\\\n\\includegraphics[scale=0.2]{ng1}\\\\\nso the shortest path may change after edge weights changed\\\\\n\\subsection{problem4}\nwe prove by the contradiction.\\\\\nSuppose this claim not hold, which is $T\\cap U \\notin T_H$. Then there is an edge $e\\in T \\cap H$ across some cut $(S|V-S)$ of H such that another edge across the cut, where the weight $e'$ is less. However, H is a subgraph of G, so $e'$ is lighter edge than e across the cut $(S|V-S)$ of G. This new edge $e$ should replace the edge in minimum spanning tree in G because it provide less cost, contradicting that T is an MST.\n\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "57c32fe368048d5f6909dd5a66cbb0b8e8a256b0", "size": 2216, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "8. Shortest path and MST/hw8.tex", "max_stars_repo_name": "yedkk/algorithm-design", "max_stars_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-06-01T02:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T02:39:45.000Z", "max_issues_repo_path": "8. Shortest path and MST/hw8.tex", "max_issues_repo_name": "yedkk/algorithm-design", "max_issues_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "8. Shortest path and MST/hw8.tex", "max_forks_repo_name": "yedkk/algorithm-design", "max_forks_repo_head_hexsha": "433b70e8302ec91b74542e9144dd93fdb5b0f8d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.8205128205, "max_line_length": 487, "alphanum_fraction": 0.7170577617, "num_tokens": 668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4127118772778703}}
{"text": "%\n% @author   Shmish  \"shmish90@gmail.com\"\n% @legal    MIT     \"(c) Christopher Schmitt\"\n%\n\n\n\\documentclass{article}\n\n\n%\n% Document Imports\n%\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{color}\n\\usepackage{tikz}\n\n\n\n%\n% Document Configuation\n%\n\n\\newcommand{\\hwAuthor}{Christopher Schmitt}\n\\newcommand{\\hwSubject}{Math 218}\n\\newcommand{\\hwSection}{Section 81}\n\\newcommand{\\hwSemester}{Summer 2019}\n\\newcommand{\\hwAssignment}{Assignment 4}\n\n\n%\n% Document Enviornments\n%\n\n\\setlength{\\headheight}{65pt}\n\\pagestyle{fancy}\n\\lhead{\\hwAuthor}\n\\rhead{\n  \\hwSubject \\\\\n  \\hwSection \\\\\n  \\hwSemester \\\\\n  \\hwAssignment\n}\n\n\\newenvironment{problem}[1]{\n  \\nobreak\\section*{Problem #1}\n}{}\n\n\n%\n% Document Start\n%\n\n\\begin{document}\n  \\begin{problem}{1}\n    Let $\\preceq$ be the relation on the set $A = \\{2, 3, 5, 8, 25, 30, 300\\}$ defined by:\n    \\begin{center}\n      $a \\preceq b$ iff $a$ is a divisor of $b$\n    \\end{center}\n    $\\preceq$ is a partial order on $A$ (you do not need to prove this).  Answer each of the following.\n\n    \\begin{flushleft}\n      \\textbf{(a)} Draw the hasse diagram for this partially ordered set.\n    \\end{flushleft}\n\n    \\begin{center}\n      \\begin{tikzpicture}[scale=1.5]\n        \\node (300) at (1, 0) {$300$};\n        \\node (8) at (0, -1) {$8$};\n        \\node (30) at (1, -1) {$30$};\n        \\node (25) at (2, -1) {$25$};\n        \\node (2) at (0, -2) {$2$};\n        \\node (3) at (1, -2) {$3$};\n        \\node (5) at (2, -2) {$5$};\n        \\draw (30) -- (300) -- (25) -- (5) -- (30) -- (3) -- (30) -- (2) -- (8);\n      \\end{tikzpicture}\n    \\end{center}\n\n    \\begin{enumerate}\n      \\item[\\textbf{(b)}] What are the maximal elements for this poset? $\\{8, 300\\}$\n      \\item[\\textbf{(c)}] What are the maximum elements for this poset? None\n      \\item[\\textbf{(d)}] What are the minimal elements for this poset? $\\{2, 3, 5\\}$\n      \\item[\\textbf{(e)}] What are the minimum elements for this poset? None\n      \\item[\\textbf{(f)}] Find $2 \\vee 3$. $30$\n      \\item[\\textbf{(g)}] Find $8 \\vee 25$. Does not exist\n      \\item[\\textbf{(h)}] Find $8 \\wedge 300$. $2$ \n      \\item[\\textbf{(i)}] Find $8 \\wedge 25$. Does not exist \n    \\end{enumerate}\n  \\end{problem}\n\n  \\begin{problem}{2}\n    Prove that the function $f : Q \\rightarrow Q$ defined by $f(x) = 3x + 7$ is injective.\n    \\begin{proof}\n      Let $a, b \\in Q$, Suppose $f(a) = f(b)$\n      \\begin{equation*}\n        \\begin{split}\n          3(a) + 7 & = 3(b) + 7\\\\\n          3(a) & = 3(b)\\\\\n          a & = b\\\\\n        \\end{split}\n      \\end{equation*}\n    \\end{proof}\n  \\end{problem}\n\n  \\begin{problem}{3}\n    Prove that the function $f : R \\rightarrow R$ defined by $f(x) = x^{2} - 3x + 5$ is not injective.\n    \\begin{proof}\n      \\begin{equation*}\n        f(0) = f(3)\n      \\end{equation*}\n    \\end{proof}\n  \\end{problem}\n\n  \\begin{problem}{4}\n    Prove that the function $f : Z \\times Z \\rightarrow Z$ defined by $f(n, m) = 3n - 2m - 1$ is onto.\n    \\begin{proof}\n      Let $k \\in Z$\n      \\begin{equation*}\n        \\begin{split}\n          f(n, m) & = 3(n) - 2(m) - 1\\\\\n          f(2, 2) & = 3(2) - 2(2) - 1 = 1\\\\\n          f(2k, 2k) & = 3(2k) - 2(2k) - 1\\\\\n          f(2k, 2k) & = k(1) = k\n        \\end{split}\n      \\end{equation*}\n    \\end{proof}\n  \\end{problem}\n\n  \\begin{problem}{5}\n    Prove that the function $f : Z \\rightarrow Z$ defined by $f(n) = 3n + 2$ is not onto.\n    \\begin{proof}\n      \\begin{equation*}\n        \\begin{split}\n          1 & \\in Z\\\\\n          1 & = 3n + 2\\\\\n          -1 & = 3n\\\\\n          \\frac{-1}{3} & = n\\\\\n          \\frac{-1}{3} & \\notin Z\n        \\end{split}\n      \\end{equation*}\n      So $f : Z \\rightarrow Z$ cannot produce the value $1$, and therefore cannot be onto.\n    \\end{proof}\n  \\end{problem}\n\n  \\begin{problem}{6}\n    Let $f : R \\setminus \\{4\\} \\rightarrow R$ be the function defined by $f(x) = \\frac{2x + 7}{x - 4}$\n    \\begin{flushleft}\n      \\textbf{(a)} Prove that this function is injective.\n    \\end{flushleft}\n    \\begin{proof}\n      Let $a, b \\in R \\setminus \\{4\\}$ Suppose $f(a) = f(b)$\n      \\begin{equation*}\n        \\begin{split}\n          \\frac{2(a) + 7}{a - 4} & = \\frac{2(b) + 7}{b - 4}\\\\\n          (2(a) + 7)(b - 4) & = (2(b) + 7)(a - 4)\\\\\n          2ab - 8a + 7b - 28 & = 2ab - 8b + 7a - 28\\\\\n          -8a + 7b & = -8b + 7a\\\\\n          15b & = 15a\\\\\n          b & = a\\\\\n        \\end{split}\n      \\end{equation*}\n    \\end{proof}\n\n    \\begin{flushleft}\n      \\textbf{(b)} This function is not onto. Determine which element should be removed from the codomain to make it onto. Prove that $f$ is onto when this element is removed from the codomain, and find the inverse $f^{-1}$.\n    \\end{flushleft}\n\n    \\begin{center}\n      $f : R \\setminus \\{4\\} \\rightarrow R \\setminus \\{2\\}$\n    \\end{center}\n\n    \\begin{proof}\n      Let $r \\in R \\setminus \\{2\\}$\n      \\begin{equation*}\n        \\begin{split}\n          r & = \\frac{2x + 7}{x - 4}\\\\\n          r(x - 4) & = 2x + 7\\\\\n          rx - 4r & = 2x + 7\\\\\n          rx - 4r - 2x + 8 & = 15\\\\\n          (r - 2)(x - 4) & = 15\\\\\n          x - 4 & = \\frac{15}{r - 2}\\\\\n          x & = \\frac{15}{r - 2} + 4\\\\\n          x & = \\frac{15 + 4(r - 2)}{r - 2}\\\\\n          x & = \\frac{7 + 4r}{r - 2}\\\\\n          f(\\frac{7 + 4r}{r - 2}) & = r \\text{, where $r \\neq 2$}\n        \\end{split}\n      \\end{equation*}\n    \\end{proof}\n\n    \\begin{center}\n      $f^{-1} : R \\setminus \\{2\\} \\rightarrow R \\setminus \\{4\\}$\\\\\n    \\end{center}\n\n    \\begin{center}\n      $f^{-1}(x) = \\frac{7 + 4r}{r - 2}$\n    \\end{center}\n  \\end{problem}\n\\end{document}\n", "meta": {"hexsha": "eaa9601ea6e10a01824318723a698895e6190f95", "size": 5603, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Assignment_004.tex", "max_stars_repo_name": "shmishtopher/MATH-218", "max_stars_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Assignment_004.tex", "max_issues_repo_name": "shmishtopher/MATH-218", "max_issues_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Assignment_004.tex", "max_forks_repo_name": "shmishtopher/MATH-218", "max_forks_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4656862745, "max_line_length": 224, "alphanum_fraction": 0.5157951098, "num_tokens": 2150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765155565327, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4127047609049681}}
{"text": "% !TEX root = ../main.tex\n\n\\section{Context}\n\\begin{frame}{\\insertsec}\n  \\begin{itemize}\n    \\item Work based on predicting Princess Margaret Cancer Center Dataset's patients survival\n    \\item Nowadays Machine Learning is widely used\n    \\item Medical images can be obtained using MRI, PET or CT scans but are underused\n    \\item Different methods have appeared to analyze these data for image classification,\n    object detection, segmentation... usually using deep learning.\n    \\item Hand-crafted radiomic features can be extracted from medical images\n  \\end{itemize}\n\\end{frame}\n\n\\subsection{Survival Analysis}\n\\begin{frame}{\\insertsubsec}\n  Survival analysis models usually have:\n  \\begin{itemize}\n    \\item Baseline data \\( x \\)\n    \\item Event \\( E \\in \\{0, 1\\} \\)\n    \\item Time \\( T \\)\n    \\item Censoring\n  \\end{itemize}\n  \n  \\begin{block}{Survival function}\n    \\[\n      S(t) = \\Pr(T \\ge t)\n    \\]\n  \\end{block}\n\n  \\begin{block}{Hazard function}\n  \\[\n    \\lambda(t) = \\lim_{\\Delta t \\rightarrow 0}\n    \\frac{\\Pr(t \\le T < t + \\Delta t | T \\ge t)}{\\Delta t}\n  \\]\n  \\end{block}\n\n  \\begin{block}{Cox Proportional Hazards model}\n    \\[\n      \\lambda(t | \\bm{x}) = \\exp(\\bm{x}\\bm{\\beta}) \\cdot \\lambda_0 (t)\n    \\]\n  \\end{block}\n\\end{frame}\n\n\\begin{frame}\n\n  Casting the survival problem as a ranking is a way of dealing with censored data.\n  Conditions:\n  \\begin{itemize}\n    \\item Both of them are uncensored (\\( \\bm{E}_i = \\bm{E}_j = 1\\))\n    \\item The uncensored time of one is smaller than the censored survival time of the other\n    (\\( \\bm{T}_i < \\bm{T}_j | \\bm{E}_i = 1; \\bm{E}_j = 0 \\))\n  \\end{itemize}\n\n  \\begin{columns}\n    \\begin{column}{.5\\textwidth}\n      \\begin{figure}\n        \\centering\n        \\scalebox{.8}{\\input{drawings/graph_no_censored.tikz.tex}}\n        \\caption{Uncensored data}\n      \\end{figure}\n    \\end{column}\n    \\begin{column}{.5\\textwidth}\n      \\begin{figure}\n        \\centering\n        \\scalebox{.8}{\\input{drawings/graph_censored.tikz.tex}}\n        \\caption{Censored data}\n      \\end{figure}\n    \\end{column}\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{block}{Good prediction}\n    \\[\n      T_i > T_j \\land \\hat{T}_i > \\hat{T}_j\n    \\]\n  \\end{block}\n\n  \\begin{block}{Bad prediction}\n    \\[\n      T_i > T_j \\land \\hat{T}_i < \\hat{T}_j\n    \\]\n  \\end{block}\n\n  \\begin{block}{Concordance Index}\n    \\[\n      CI = \\frac{\\text{Good predictions}}{\\text{Total predictions}} \\in [0, 1]\n    \\]\n  \\end{block}\n\\end{frame}\n\n\\subsection{Dataset}\n\\begin{frame}{\\insertsubsec}\n  \\begin{itemize}\n    \\item Dataset with 671 patients diagnosed of Oropharyngeal Squamous Cell Carcinoma\n    \\item CT scan of \\( 512 \\times 512 \\) with 100-200 slices\n    \\item Tumour annotated in provided mask\n    \\item Clinical information compressed of:\n    \\begin{itemize}\n      \\item Subject characteristics\n      \\item Tumour characteristics\n      \\item Treatment data\n      \\item Outcome data\n    \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\begin{subfigure}[t]{.32\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{images/IMG0138_example.png}\n      \\caption{Original image}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}[t]{.32\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{images/IMG0138_MASS_example.png}\n      \\caption{Image mask}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}[t]{.32\\textwidth}\n      \\centering\n      \\includegraphics[width=\\textwidth]{images/IMG0138_merge_example.png}\n      \\caption{Mask applied to original}\n    \\end{subfigure}\n  \n    \\caption[Images from the dataset]{\n      Example of images from the dataset\n    }\n  \\end{figure}\n\\end{frame}\n\n\\subsection{Neural Networks}\n\\begin{frame}{\\insertsubsec}\n  \\begin{figure}\n    \\centering\n    \\input{drawings/neural_network.tikz.tex}\n    \\caption[Neural network graph]{\n      Neural Network graph drawing. \n    }\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{block}{Hidden Layers}\n    \\begin{equation*}\n      \\begin{aligned}\n        z_i^{[l]} &= \\sum_{j = 1}^{n^{[l]}} w_{ij}^{[l]} \\cdot a_j^{[l - 1]} + w_{i0}^{[l]} \\\\\n        a_i^{[l]} &= g^{[l]}(z_i^{[l]})\n      \\end{aligned}\n      \\quad\n      \\xrightarrow{\\text{becomes}}\n      \\quad\n      \\begin{aligned}\n        \\bm{z}^{[l]} &= \\bm{W}^{[l]} \\cdot \\bm{a}^{[l - 1]} + \\bm{b}^{[l]} \\\\\n        \\bm{a}^{[l]} &= g^{[l]}(\\bm{z}^{[l]})\n      \\end{aligned}\n    \\end{equation*}\n  \n  \\end{block}\n  \\begin{figure}\n    \\centering\n    \\input{drawings/activation_functions.tikz.tex}\n  \n    \\caption[Activation functions]{\n      Activation functions\n    }\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{block}{Output layers}\n    \\[\n      g_k^{[L]}(\\bm{a}^{[L - 1]}) = \\frac{e^{a_k^{[L - 1]}}}{\\sum_{i = 1}^K e^{a_i^{[L - 1]}}}\n    \\]\n  \\end{block}\n  \n  \\begin{block}{Cost function}\n    \\begin{align*}\n      \\hat{\\bm{y}} &:= g^{[L]}(\\bm{a^{[L - 1]}}) \\\\\n      C(\\bm{y}, \\hat{\\bm{y}}) &:= \\frac{1}{N} \\sum_{i = 1}^N (y_i - \\hat{y}_i)^2\n    \\end{align*}\n  \\end{block}\n\\end{frame}\n\n\\subsection{Convolutional Neural Networks}\n\n\\begin{frame}{\\insertsubsec}\n  \\centering\n  \\begin{figure}\n    \\hspace{-7cm}\n    \\adjustbox{max width=1.35\\pagewidth}{\\input{drawings/convolution_operation.tikz.tex}}\n\n    \\caption{Convolution operation}\n  \\end{figure}\n\n  \\begin{block}{Output size}\n    \\begin{align*}\n      n_{\\text{next}} = \\left\\lfloor\\frac{n_{\\text{prev}} + p - f}{s}\\right\\rfloor + 1\n    \\end{align*}\n  \\end{block} \n\\end{frame}\n\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\scalebox{.7}{\\input{drawings/convolutional_layer.tikz.tex}}\n    \\caption{Convolutional layer}\n  \\end{figure}\n\n  \\begin{align*}\n    \\bm{z}^{[l]} &= \\bm{W}^{[l]} \\cdot \\bm{a}^{[l - 1]} + \\bm{b}^{[l - 1]} \\\\\n    &\\downarrow \\text{becomes} \\\\\n    \\bm{\\mathsf{Z}}^{[l]} &= \\bm{\\mathsf{A}}^{[l - 1]} * \\bm{\\mathsf{W}}^{[l]} + \n    \\bm{\\mathsf{B}}^{[l - 1]}\n  \\end{align*}\n\\end{frame}\n", "meta": {"hexsha": "a6bb7c2590cc6d12d47108c93fa81fcd58f86321", "size": 5894, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LATEX/final_presentation/sections/01_context.tex", "max_stars_repo_name": "jmigual/FIB-TFG", "max_stars_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-02T15:17:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-02T15:17:51.000Z", "max_issues_repo_path": "LATEX/final_presentation/sections/01_context.tex", "max_issues_repo_name": "jmigual/FIB-TFG", "max_issues_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LATEX/final_presentation/sections/01_context.tex", "max_forks_repo_name": "jmigual/FIB-TFG", "max_forks_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-10-23T08:11:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-23T08:11:28.000Z", "avg_line_length": 26.6696832579, "max_line_length": 94, "alphanum_fraction": 0.6062097048, "num_tokens": 2028, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.41270474686468256}}
{"text": "\\input{docs/preamble}\n\\title{Optical Pumping}\n\\author{Max Bigras and David Frawley}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nWe performed optical pumping to trap $^{85}$Rb and  $^{87}$Rb atoms. We measured the strength of an applied magnetic field and the intensity of light passing through the Rb vapor. We determined the Lande g-factor, $g_{\\mathrm{f}}$, for each of the isotopes and were able to determine the ratio $g^{\\mathrm{exp}}_{87}$/$g^{\\mathrm{exp}}_{85}$ = $1.5 \\pm 0.1$ which agrees with the accepted value $g_{87}$/$g_{85}$ = 1.5. We also observed our applied magnetic field cancel the Earth's magnetic field.\n\\end{abstract}\n\n\\section{Introduction}\nOptical pumping is an important experimental technique that takes precise advantage of quantum selection rules to trap and manipulate atoms. We used a technique developed in the 1950s by Alfred Kastler who later won the Nobel Prize in 1966 \\cite{wiki}. By careful constructing a magnetic field from pairs of Helmholtz coils, one can adjust the Zeeman energy gap and pump atoms into a trapped state. Once trapped the atoms can be manipulated in interesting and precise ways to measure quantities like the size of the Zeeman energy gap, the atom's g-factors, or the strength of an external magnetic field.\n\n\n\\section{Theory}\n\\subsection{Zeeman splitting}\nWhen an atomic system is placed in a magnetic field it's energy levels undergo Zeeman splitting. Our atomic system consists of the two stable isotopes $^{85}$Rb and  $^{87}$Rb. A schematic for $^{85}$Rb can be seen in Figure \\ref{energy_levels}. In the Rb atoms there are three magnetic moments caused by orbiting electrons, electron spin, and nuclear spin. Taking into account these moments the equation for the energy gap between adjacent levels is\n\n\\begin{equation}\nE_{\\mathrm{Zeeman}}= g_{\\mathrm{f}} \\mu_{\\mathrm{B}} B\n\\label{zeeman}\n\\end{equation}\nwhere $g_{\\mathrm{f}}$ is the Lande g-factor, $\\mu_{\\mathrm{B}}$ is the Bohr magneton, and $B$ is the strength of the total magnetic field felt by the atom.\n\\begin{figure}[H]\n  \\includegraphics[totalheight=0.65\\textwidth]{figs/energy_levels}\n  \\caption{Structure of the $^{85}$Rb isotope (not to scale) image from \\cite{manual}}\n  \\label{energy_levels}\n\\end{figure}\n\n\\subsection{Optical pumping}\n\nA visual description for optical pumping can be seen in Figure \\ref{pumping}. Initially all the atomic states are equally populated. At this point an atom in one of the lower states can absorb  a photon and excite, following the selection rule $\\Delta m_{\\mathrm{F}} = +1$. To de-excite the atom emits a photon and follows the selection rule $\\Delta m_{\\mathrm{F}} = -1, 0, +1$. So there is some probability that $\\Delta m_{\\mathrm{F}}$ will be 0 or $+1$ on the way down, causing a net ``ratcheting up'' of the atoms. Now when the Rb atom falls into the $m_{\\mathrm{F}} = 3$ state it can no longer excite while following the selection rules, so it is trapped. Interestingly once all the atoms are trapped they can no longer absorb photons and become transparent, shown in  Figure \\ref{pumping}g.\n\\begin{figure}[H]\n  \\includegraphics{figs/pumping}\n  \\caption{Optical pumping of Rb atoms with 795 nm light}\n  \\label{pumping}\n\\end{figure}\n\nA visual description for de-pumping and zero-fielding can be seen in Figure \\ref{rfing}. Now, all the Rb atoms have been trapped. What could cause a Rb atom to   absorb a photon again? There are two ways, the first is place the atoms in a zero-field situation so there is no more Zeeman splitting and they can absorb photons as usual. The second is de-pump the atoms into a lower state, now they can obey the selection rules and absorb photons.\n\nHow is a zero field situation created? Even if there is no magnetic field created in the lab Zeeman splitting will  occur because of the presence of the Earth's magnetic field. If one adjusts the magnetic field in a precise way the Earth's magnetic field can be canceled, thus creating a zero-field situation, shown in Figure \\ref{rfing}b. \n\nHow are atoms de-pumped? If the magnetic field is increased further then the Zeeman gap is also increased. What if the atoms are exposed to a second set of photons at the same time? The energy of these photons is\n\\begin{equation}\nE = hf\n\\end{equation}\nIf the Zeeman energy gap is matched with the energy of the second set of photons then stimulated emission will occur, de-pumping a Rb atom so it is again able to absorb the higher energy exciting photons while obeying the selection rules, Figure \\ref{rfing}d-\\ref{rfing}e.\n\\begin{figure}[H]\n  \\includegraphics{figs/rfing}\n  \\caption{Zero-fielding and De-pumping Rb atoms with RF photons}\n  \\label{rfing}\n\\end{figure}\n\n\\section{Apparatus}\nA schematic for our apparatus can be seen in Figure \\ref{schematic}. We generate 795 nm light from a Rubidium lamp. The light is then manipulated and filtered so we get 795 nm circularly polarized light which is used to pump Rb atoms. After the light passes through the chamber we measured it's intensity with a detector.\n\nOptical pumping and manipulation depend on a carefully controlled magnetic field. We generated the vertical and horizontal components of the lab's magnetic field with a pair of Helmholtz coils. Now we have trapped atoms, to de-pump them we require a second set of lower energy photons. We used Helmholtz coils to generate radio frequency photons shown in red, Figure \\ref{schematic}g.\n\n% magnetic field vs current\n\\begin{figure}[H]\n  \\includegraphics[totalheight=0.5\\textwidth]{figs/apparatus}\n  \\caption{Experimental setup. \\newline\na) Rubidium lamp \\newline\nb) lens, $f$ = 50 mm \\newline\nc) Interference filter \\newline\nd) Polarizer \\newline\ne) Quarter wave plate \\newline\nf) 795 nm right circularly polarized light \\newline\ng) Helmholtz coils, with rubidium chamber \\newline\nh) lens, $f$ = 50 mm \\newline\ni) Amplified photo-detector}\n  \\label{schematic}\n\\end{figure}\n\n\n\\section{Analysis}\nWhat kind of behavior will a system of trapped atoms that is suddenly freed exhibit? It will absorb light, which is to say go from transparent to not transparent. We can measure and detect when this happens because the intensity of the light passing through the chamber will suddenly decrease. By sweeping through an increasing range of magnetic fields we can see when the magnetic field is just right to cause: a cancellation of Earth's magnetic field, stimulated emission of  $^{87}$Rb and stimulated emission of $^{85}$Rb, shown in Figure \\ref{depumping}. What will happen if the radio frequency is increased? Now the Zeeman energy gap must be larger for stimulated emission to occur so we would see the two humps slide to the right.\n% MATLAB by itself EPS\n\\begin{figure}[H]\n  \\includegraphics[totalheight=0.6\\textwidth]{figs/depumping_final}\n  \\caption{Drop in light intensity caused by canceling Earth's magnetic field and de-pumping $^{85}$Rb and $^{87}$Rb}\n  \\label{depumping}\n\\end{figure}\n\nBecause we can measure the current through the Helmholtz coils and we know the required physical parameters of the coils we can measure the magnetic field. Because we know the energy of the RF photons we can measure the Zeeman energy gap. A plot and fit of the energy gap vs. magnetic field can be seen in Figures \\ref{rb85line} and \\ref{rb87line}. We determined the slope of the line and by applying Equation \\ref{zeeman} we determined the Lande g-factors. Our results can be seen in Table \\ref{result}. Taking the ratio we obtain $g^{\\mathrm{exp}}_{87}$/$g^{\\mathrm{exp}}_{85}$ = $1.5 \\pm 0.1$ which agrees with the accepted value $g_{87}$/$g_{85}$ = 1.5, shown in Table \\ref{result2}.\n% MATLAB by itself EPS\n\\begin{figure}[H]\n  \\includegraphics[totalheight=0.6\\textwidth]{figs/rb85}\n  \\caption{Determining the slope of  $\\Delta E$ vs. $B$  for  $^{85}$Rb}\n  \\label{rb85line}\n\\end{figure}\n\n% MATLAB by itself EPS\n\\begin{figure}[H]\n  \\includegraphics[totalheight=0.6\\textwidth]{figs/rb87}\n  \\caption{Determining the slope of $\\Delta E$ vs. $B$  for  $^{87}$Rb}\n  \\label{rb87line}\n\\end{figure}\n\n\\begin{table}[H]\n\\caption{Experimental g-factors }\n\\begin{tabular}{c@{\\hskip 1cm} c}\n\\hline\\noalign{\\smallskip}\nIsotope & $g_{\\mathrm{f}_{\\mathrm{exp}}}$ \\\\\n\\hline\\noalign{\\smallskip}\n$^{85}$Rb & $0.34 \\pm 0.02$\\\\\n$^{87}$Rb & $0.52 \\pm 0.03$\\\\\n\\hline\\noalign{\\smallskip}\n\\end{tabular}\n\\label{result}\n\\end{table}\n\n\\begin{table}[H]\n\\caption{Experimental and Accepted g-factor ratio from \\cite{mit} }\n\\begin{tabular}{c@{\\hskip 1cm} c@{\\hskip 1cm} c}\n\\hline\\noalign{\\smallskip}\nQuantity & Experimental Value & Accepted Value \\\\\n\\hline\\noalign{\\smallskip}\n$g_{87}$/$g_{85}$ & $1.5 \\pm 0.1$ & 1.5 \\\\\n\\hline\\noalign{\\smallskip}\n\\end{tabular}\n\\label{result2}\n\\end{table}\n\n\\section{Conclusion}\nWe performed optical pumping to trap $^{85}$Rb and  $^{87}$Rb atoms. We measured the strength of an applied magnetic field and the intensity of light passing through the Rb vapor. We determined the Lande g-factors for each of the isotopes which agree with accepted values. We also observed our applied magnetic field cancel the Earth's magnetic field.\n\n\n\n\\begin{thebibliography}{99}\n\n\\bibitem{manual} Physics Dept., ``Optical Pumping'', Quantum Lab,\n  California Polytechnic University, (2013).\n\n\\bibitem{wiki} ``Optical pumping'', Wikipedia: The Free Encyclopedia. Wikimedia Foundation, Inc., 05 December 2013. Web. wikipedia.org/wiki/Opticalpumping.\n\n\n\\bibitem{mit} A. Speranza, ``Optical Pumping of Rubidium Vapor'', MIT Physics Dept.,MIT University, (2013).\n\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "d53c8e709ae2befa1964e8d63331e65a72544211", "size": 9483, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "optical_pumping_report/lab_report.tex", "max_stars_repo_name": "mbigras/physics_projects", "max_stars_repo_head_hexsha": "7dd29707b3ac8adea7ed8b63786245e34097345e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-12-05T23:34:30.000Z", "max_stars_repo_stars_event_max_datetime": "2016-12-11T19:45:07.000Z", "max_issues_repo_path": "optical_pumping_report/lab_report.tex", "max_issues_repo_name": "mbigras/physics_projects", "max_issues_repo_head_hexsha": "7dd29707b3ac8adea7ed8b63786245e34097345e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "optical_pumping_report/lab_report.tex", "max_forks_repo_name": "mbigras/physics_projects", "max_forks_repo_head_hexsha": "7dd29707b3ac8adea7ed8b63786245e34097345e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.9520547945, "max_line_length": 795, "alphanum_fraction": 0.7590424971, "num_tokens": 2574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.4127047435944696}}
{"text": "\\subsection{\\acrshort{nrpa} playout}%\n\\label{sub:nrpa_playout}\n\nA \\gls{nrpa} playout is used to generate and evaluate a sequence of actions.\nSo a sequence \\(S={a1, a2, a3, \\dots}\\) is a list of actions that lead from the root state to a terminal one.\nTo \\(S\\), we can attach a score equal to the sum of rewards obtained by applying it to the root state.\nAs the problem is not stochastic, therefore, \\(S\\) can be apply any number of time and will always give the same resuls.\n\nThe algorithm in charge of the rollout is given in algorithm~\\ref{alg:nrpa_playout}.\nThe algorithm first initialize the sequence it's going to create (line 2).\nThen if it reaches a terminal state, it returns the sequence alongside the score obtained.\nOtherwise, it repeats the following.\nIt sums the exponential of the weights attached to each legal actions for the current state (line 8-10).\nThen it samples a move among the legal ones according to the exponential of the weight divided by the sum it just computed.\nThis basically means that, a move attached to a big weight will more likely be picked.\nIt then plays the chosen action and update the sequence by adding the move at the end.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\begin{minipage}{.7\\linewidth}\n        \\subimport{../../../algorithms/nrpa/}{playout.tex}\n    \\end{minipage}\n\\end{figure}\n\n\n\n\n", "meta": {"hexsha": "d56983ec38a75c4bb70961a59b9aafd937132e7c", "size": 1334, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/report/src/sections/nrpa/subs/playout.tex", "max_stars_repo_name": "XanX3601/stochastic_mcts_optimization", "max_stars_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "documents/report/src/sections/nrpa/subs/playout.tex", "max_issues_repo_name": "XanX3601/stochastic_mcts_optimization", "max_issues_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/report/src/sections/nrpa/subs/playout.tex", "max_forks_repo_name": "XanX3601/stochastic_mcts_optimization", "max_forks_repo_head_hexsha": "743ef3df090427750fee55fd69d7646a88d5946a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.6428571429, "max_line_length": 123, "alphanum_fraction": 0.7533733133, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.41266740478193914}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage[english]{babel}\n\\usepackage{a4}\n\\usepackage{latexsym}\n\\usepackage[\n\tcolorlinks,\n\tpdftitle={Towers of Hanoi in Lambda Calculus},\n\tpdfsubject={Towers of Hanoi in Lambda Calculus},\n\tpdfauthor={Martijn Vermaat}\n]{hyperref}\n\n\\title{Towers of Hanoi in Lambda Calculus}\n\\author{\n\tMartijn Vermaat\\footnote{E-mail: mvermaat@cs.vu.nl, homepage: http://www.cs.vu.nl/\\~{}mvermaat/}\n}\n\\date{29th February 2004}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nIn this document we will see how a solution to the Towers of Hanoi problem can be constructed in pure, untyped Lambda Calculus.\n\\end{abstract}\n\n\\tableofcontents\n\n\\section{The problem of the Towers of Hanoi}\n\nThe problem definition below is taken from Wikipedia\\footnote{Tower of Hanoi, http://en.wikipedia.org/wiki/Tower\\_{}of\\_{}Hanoi}.\n\n\\begin{quote}\nThe Tower of Hanoi (also called Towers of Hanoi) is a mathematical game or puzzle. It consists of three pegs, and a number of discs of different sizes which can slot onto any peg. The puzzle starts with the discs neatly stacked in order of size on one peg, smallest at the top, thus making a conical shape.\n\nThe object of the game is to move the entire stack to another peg, obeying the following rules:\n\\begin{itemize}\n\\item\nonly one disc may be moved at a time\n\\item\na disc can only be placed onto a larger disc (it doesn't have to be the adjacent size, though: the smallest disc may sit directly on the largest disc) \n\\end{itemize}\n\\end{quote}\n\nThis problem is often used in programming courses to illustrate the use of recursion. Solutions have been programmed in allmost every language known to human kind. Having taken a introductory course on Lambda Calculus, I searched for a solution for the Towers of Hanoi problem in Lambda Calculus. Much to my suprise, I wasn't able to find one.\n\n\n\\section{A solution in untyped Lambda Calculus}\n\n\n\\subsection{The simple solution in Haskell}\n\nThe solution is basically a translation to Lambda Calculus of the following obvious solution in Haskell:\n\n\\begin{verbatim}\nhanoi (0, _, _, _)         = []\nhanoi (n, from, to, using) = hanoi(n-1, from, using, to) ++\n                               (from, to) :\n                               hanoi(n-1, using, to, from)\n\\end{verbatim}\n\nThat is, to move \\verb|n| discs from \\verb|from| to \\verb|to| (using \\verb|using|), all we have to do is move \\verb|n-1| discs to \\verb|using|, then move the last disc to \\verb|to|, and finaly move the \\verb|n-1| discs from \\verb|using| to \\verb|to|. The trivial case here is moving 0 discs--just don't do anything (return the empty list of pairs). Calling \\verb|hanoi| as follows will return a list of pairs, where each pair denotes a move:\n\n\\begin{verbatim}\n> hanoi (3, 1, 3, 2)\n[(1,3),(1,2),(3,2),(1,3),(2,1),(2,3),(1,3)]\n\\end{verbatim}\n\nIn Lambda Calculus, we can try to do the same thing, using notations for pairs, lists, and natural numbers. Because we are talking about untyped Lambda Calculus, the result will be complicated to read (but nevertheless it can well be a correct solution).\n\n\n\\subsection{Translating to Lambda Calculus}\n\nTo denote numbers, we will use the common notation known as Church Numerals. The most important part of the translation is what we can do in Haskelly with simple pattern matching: to distinguish in the number 0 and all numbers above.\n\nBy realising what happend if we apply two arguments on a Church Numeral, we find the following body for our Hanoi function:\n\n\\begin{displaymath}\n\\lambda n.n \\quad (\\lambda x.A) \\quad B\n\\end{displaymath}\n\nwhere $A$ is some Lambda term not containing $x$ and $B$ an arbitrary Lambda term. This function expects one argument, a Church numeral, and will reduce to $A$ on applications on numbers greater than zero, and $B$ on application on zero.\n\nNow, moving on, we can fill in the $B$ part. The resulting term for zero has to be the empty list. We do have to make sure though, to discard the three arguments $from$, $to$, and $using$. So, using $empty$ as the empty list constructor, we have our new Hanoi function:\n\n\\begin{displaymath}\n\\lambda n.n \\quad (\\lambda x.A) \\quad (\\lambda f \\; t \\; u.empty)\n\\end{displaymath}\n\nThe $A$ part is a bit more complicated, but can nevertheless be translated from the Haskell solution fairly straightforward by making use of some predefined functions:\n\n\\begin{displaymath}\n\\begin{array}{ll}\n\\lambda f \\; t \\; u\\;. \\quad append & (hanoi\\;(pre\\;n)\\;f\\;u\\;t) \\\\\n& (cons \\; (pair\\;f\\;t) \\; (hanoi\\;(pre\\;n)\\;u\\;t\\;f))\n\\end{array}\n\\end{displaymath}\n\nwhere:\n\n\\begin{itemize}\n\\item $append$ is the append operator for lists\n\\item $pre$ is the predecessor function\n\\item $cons$ is the list constructor function\n\\item $pair$ is the pairing constructor function\n\\item $hanoi$ is a recursive call to the Hanoi function itself\n\\end{itemize}\n\nCombining these results, we then have a complete Hanoi function:\n\n\\begin{displaymath}\n\\begin{array}{llll}\nhanoi \\to & \\lambda n.n & ( \\lambda f \\; t \\; u\\;. \\; append & (hanoi\\;(pre\\;n)\\;f\\;u\\;t) \\\\\n& & & (cons \\; (pair\\;f\\;t) \\; (hanoi\\;(pre\\;n)\\;u\\;t\\;f)) ) \\\\\n& & (\\lambda f \\; t \\; u.empty) &\n\\end{array}\n\\end{displaymath}\n\n\n\\subsubsection{Recursion in Lambda Calculus}\n\nThe problem is that we now have a definition in terms of it self. We say we now how $hanoi$ goed, but only if we know $hanoi$. We can transform this recursive definition in a non-recursive one using a little trick and the fixed-point combinator $Y$\\footnote{For a short explanation of the fixed-point combinator, see for example http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?fixed+point+combinator on FOLDOC}.\n\nWe can rewrite the term we just had to the following (taking the $hanoi$ references outside the term):\n\n\\begin{displaymath}\n\\begin{array}{llll}\nhanoi \\to & (\\lambda h \\; n.n & ( \\lambda f \\; t \\; u\\;. \\; append & (h\\;(pre\\;n)\\;f\\;u\\;t) \\\\\n& & & (cons \\; (pair\\;f\\;t) \\; (h\\;(pre\\;n)\\;u\\;t\\;f)) ) \\\\\n& & (\\lambda f \\; t \\; u.empty)) & \\\\\n& hanoi & &\n\\end{array}\n\\end{displaymath}\n\nThe resulting definition is still recursive, but if we look closely, we can see that $hanoi$ seems to be a fixed-point of the function consisting of the complex inner term (everything between the two $hanoi$'s).\n\nThat observation makes it possible to write $hanoi$ using the fixed-point combinator $Y$, as follows:\n\n\\begin{displaymath}\n\\begin{array}{llll}\nhanoi \\to & Y \\quad \\lambda h \\; n.n & ( \\lambda f \\; t \\; u\\;. \\; append & (h\\;(pre\\;n)\\;f\\;u\\;t) \\\\\n& & & (cons \\; (pair\\;f\\;t) \\; (h\\;(pre\\;n)\\;u\\;t\\;f)) ) \\\\\n& & (\\lambda f \\; t \\; u.empty) &\n\\end{array}\n\\end{displaymath}\n\nAnd there we have our final definition of a solution for the Towers of Hanoi problem in untyped Lambda Calculus. Please don't try to prove its correctness by reducing\n\n\\begin{displaymath}\nhanoi \\; 4 \\; left \\; right \\; middle\n\\end{displaymath}\n\nby hand. Let's instead just assume it's correct enough.\n\n\n\\appendix\n\n\\section{Function definitions}\n\nBelow are the definitions of the functions used in the construction of our solution. These definitions are widely used and are certainly not `invented' by me. Because there we have smart people for.\n\n\\subsection*{General combinators}\n\n\\begin{displaymath}\n\\begin{array}{rll}\nI & \\to & \\lambda x.x \\\\\nY & \\to & \\lambda f. \\; (\\lambda x.f(x \\; x)) \\; (\\lambda x.f(x \\; x))\n\\end{array}\n\\end{displaymath}\n\n\\subsection*{Church numerals}\n\n\\begin{displaymath}\n\\begin{array}{rll}\nzero & \\to & \\lambda s \\; z.z \\\\\nsuc & \\to & \\lambda x \\; s \\; z.s \\; (x \\; s \\; z) \\\\\npre & \\to & \\lambda c.c \\; (\\lambda z. \\; (z \\; I (suc \\; z))) \\; (\\lambda a. \\; (\\lambda x.zero))\n\\end{array}\n\\end{displaymath}\n\n\\subsection*{Pairing constructor}\n\n\\begin{displaymath}\n\\begin{array}{rll}\npair & \\to & \\lambda l \\; r \\; z.z \\; l \\; r\n\\end{array}\n\\end{displaymath}\n\n\\subsection*{Lists}\n\n\\begin{displaymath}\n\\begin{array}{rll}\nempty & \\to & \\lambda x \\; y.y \\\\\ncons & \\to & \\lambda h \\; t \\; z.z \\; h \\; t \\\\\nappend & \\to & Y \\quad (\\lambda a \\; l \\; r.l \\; (\\lambda h \\; t \\; z.cons \\; h \\; (a \\; t \\; r)) \\; r)\n\\end{array}\n\\end{displaymath}\n\n\n\\end{document}\n", "meta": {"hexsha": "0ebd2899b42a4906891c0f69c6f350857b3604e1", "size": 8031, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hanoi/hanoi.tex", "max_stars_repo_name": "martijnvermaat/documents", "max_stars_repo_head_hexsha": "42483b7c4bf94ed708e2893c3ea961d025a10b5e", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-28T14:38:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-28T14:38:06.000Z", "max_issues_repo_path": "hanoi/hanoi.tex", "max_issues_repo_name": "martijnvermaat/documents", "max_issues_repo_head_hexsha": "42483b7c4bf94ed708e2893c3ea961d025a10b5e", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hanoi/hanoi.tex", "max_forks_repo_name": "martijnvermaat/documents", "max_forks_repo_head_hexsha": "42483b7c4bf94ed708e2893c3ea961d025a10b5e", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3567839196, "max_line_length": 441, "alphanum_fraction": 0.6977960403, "num_tokens": 2403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.41266740478193903}}
{"text": "\n\\chapter{IDL Routines}\n\\label{ch_idl}\n%\\chapterhead{IDL Routines}\n\\markright{IDL Routines}\n\n\\section{Introduction}\nA set of routines has been developed in IDL. Starting IDL using\nthe script program {\\em mre} allows the user to get the multiresolution\nenvironment, and all routines\ndescribed in the following can be called. An online help facility \nis also available by\ninvoking the {\\em mrh} program under IDL.\n\n\\section{IDL Tools}\n\\subsection{del\\_pattern}\n\\label{pat}\nSuppress a pattern in an image. A pattern is considered as a peak in \nFourier space. So it can be iteratively eliminated.\n{\\bf\n\\begin{center}\n     USAGE: output = del\\_pattern(Image, n\\_iter=n\\_iter, pattern=pattern, disp=disp, NSigma=NSigma, NbrScale=NbrScale)\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em Image} is an IDL 2D array.\n\\item {\\em n\\_iter} is the number of iterations. Default is 3.\n\\item if {\\em disp} set, then results are displayed during the iterations.\n\\item {\\em output} is an IDL 2D array. It contains the input image, without\nthe pattern.\n\\item {\\em pattern} is an IDL 2D array. It is equal to the difference between\n{\\em Image} and {\\em output}.\n\\item {\\em NSigma} is a real value (default is 3.0).\n\\item {\\em NbrScale} is the number of scales used in the wavelet transform.\n\\end{itemize}\n\n\n\\subsection{block\\_trans}\nThis routine separates the image into blocks of size {\\em BlockSize} \n$\\times$ {\\em BlockSize}\nand computes inside each block the mean and the variance. The \nvariance versus mean plot gives information about the type of noise in\nthe data.\n \n{\\bf\n\\begin{center}\n     USAGE: block\\_trans, Image, TabVar=TabVar, TabMean=TabMean,  Plot=Plot, BlockSize=BlockSize\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em Image} is an IDL 2D array.\n\\item {\\em TabVar} is an output keyword and is the array of variances.\n\\item {\\em TabMean} is an output keyword and is the array of means.\n\\item {\\em Plot} is an input keyword. If set, the curve variance versus\nmean is plotted.\n\\item {\\em BlockSize} is the size of the blocks. Default is 8.\n\\end{itemize}\n\n\\subsection{delete}\nSuppress a file in working directory.\n{\\bf\n\\begin{center}\n     USAGE: delete, filename\n\\end{center}}\n\n\\subsection{im\\_smooth}\nSmooth an image, taking into account the border.\n{\\bf\n\\begin{center}\n     USAGE:  im\\_smooth, Im\\_in, Im\\_out, method=method, Step\\_Trou=Step\\_Trou, Border=Border, WinSize=WinSize\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em Im\\_in} is the input 2D IDL array.\n\\item {\\em Im\\_out} is the output 2D IDL smoothed array.\n\\item {\\em method}: keyword specifying the method for smoothing. \nAvailable methods are ``linear'', ``bspline'', or ``median''. Default is \n``median''.\n\\item {\\em Step\\_Trou}: $2^{Step\\_Trou}$ is the  distance between \ntwo adjacent \npixels (default is 0).\n\\item {\\em Border} defines the way  the borders of the image must be managed.\nAvailable methods are: ``cont'' ($Im_{in}(-i,-j) = Im_{in}(0,0)$), ``mirror''  \n($Im_{in}(-i,-j) = Im_{in}(i,j)$), ``zero'' ($Im_{in}(-i,-j) = 0$), ``nobord'' (the\nborders of the image are not \nsmoothed).\n\\item {\\em WinSize} is the window size (only used if method = \n``median''). Default is 3.\n\\end{itemize}\n\n\\subsection{Tikhonov}\n Deconvolve  an image using Tikhonov regularization.\n This program does not shift the maximum of the PSF to the center. \n The minimized functional is:\n\\begin{eqnarray}\n  J(O) = \\parallel I - P*O  \\parallel + \\alpha  \\parallel H*O  \\parallel\n \\end{eqnarray}\nwhere $O$ is the unknown object, $P$ the point spread function (PSF), $I$\nthe data and $H$ a high pass filter (the Laplacian).\n{\\bf\n\\begin{center}\n  USAGE: Result = TIKHONOV(Imag, Psf, residu=residu, niter=niter, \n                         CvgParam=CvgParam, RegulParam=RegulParam, \n                         NoRegul=NoRegul)\n \\end{center}}\n where\n\\begin{itemize}\n\\item {\\em Imag} is an input 2D IDL  array, i.e.\\ the image to deconvolve.\n\\item {\\em Psf}  is an input 2D IDL  array, i.e.\\ point spread function.\n\\item {\\em niter} is the input number of iterations. Default is 10.\n\\item {\\em CvgParam} is the convergence parameter. Default is 0.1.\n\\item {\\em RegulParam} is the regularization parameter (i.e.\\ $\\alpha$).\n\\item {\\em NoRegul} if set, no regularization is performed.\n\\item {\\em Residu} is an output 2D IDL array containing the residual: \nresidual = Imag -- Psf*Result.\n\\end{itemize}\n \nIf the keyword NoRegul is set, then no regularization is done, \nand the algorithm becomes a simple one step gradient method.\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item Result = TIKHONOV(Imag, Psf) \\\\\nDeconvolve an image with all default options.\n\\item  Result = TIKHONOV(Imag, Psf) \\\\\n Same example, but impose the number of iterations to be 30.\n\\item   Result = TIKHONOV (Imag, Psf, niter=30) \\\\\n Deconvolution by the one step gradient method, without \n any regularization, with 30 iterations.\n\\item  Result = TIKHONOV (Imag, Psf, niter=30, /NoRegul)  \n\\end{itemize}\n  \n\\section{Noise Related Routines}\n\\subsection{poisson\\_image}\nCreate an image with Poisson-distributed values around the mean values\nIMAGE, using Knuth's ``Algorithm Q\"  (D.E. Knuth, The Art of\nComputer Programming, Volume 2, ``Seminumerical Algorithms\", \nAddison-Wesley, 1969, p.\\ 117). This routine has been written by James Hamill\n(Siemens Medical Systems, 2501 N. Barrington Rd., Hoffman Estates, IL  \n60195-7372), and has been inserted in the \\proj package.\n{\\bf\n\\begin{center}\n     USAGE: output = poisson\\_image ( image[, seed] )\n\\end{center}}\nwhere {\\em image} is a  numeric array (byte, integer, long, or float) of arbitrary dimensionality.  \nThis is the array of values around which values in the\nresult will be Poisson-distributed. {\\em seed} is a  longword seed for the random number generator.  If this is not\nsupplied, the value --123456789L is used for generating the first random\nvalue. \n\n\\subsection{poisson\\_to\\_gauss}\nTransforms the data with Poisson noise into a new set of data\n with Gaussian noise using the generalized Anscombe transform.\n\\begin{eqnarray}\nT(x) = \\frac{2}{gain} \\sqrt{gain*x + \\frac{3}{8}*gain^2 + \\sigma^2 - gain * mean}\n\\end{eqnarray}\nwhere\n\\begin{itemize}\n\\item {\\em gain} = gain of the CCD\n\\item $\\sigma$ = standard deviation of the readout noise\n\\item {\\em mean} = mean of the read out noise\n\\end{itemize}\nFor pure Poisson noise, {\\em gain}=1, {\\em mean}=0, and $\\sigma$=0.\nIf the {\\em inv} keyword is set, then the inverse transform is applied:\n\\begin{eqnarray}\n T(x) = \\frac{x^2}{4.} * \\textrm{\\em gain} - \\frac{\\frac{3}{8}*\\textrm{\\em gain}^2 + \\sigma^2 - gain * mean}{gain}\n\\end{eqnarray}\n\n{\\bf\n\\begin{center}\n     USAGE: output = poisson\\_to\\_gauss (Data, poisson=poisson, inv=inv)\n\\end{center}}\n\\begin{itemize}\n\\item {\\em Data}: IDL array: data\n\\item {\\em poisson}: float array (poisson(0) = gain, poisson(1)= $\\sigma$, and\npoisson(2) = mean). By default, poisson=[1.,0.,0.].\n\\item {\\em inv}: If set, the inverse transform is applied.\n\\end{itemize}\n\n\\subsection{sigma\\_clip}\nReturns the noise standard deviation obtained by k-sigma.  \n{\\bf\n\\begin{center}\n     USAGE: output = sigma\\_clip(Data, sigma\\_clip=sigma\\_clip, mean=mean)\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em output}: standard deviation estimated by k-sigma clipping.\n\\item {\\em Data}: IDL array (input data).\n\\item {\\em sigma\\_clip}: number of iterations.  Default value is 3.\n\\item {\\em mean}: If mean is set, the mean of the data (taking into \naccount outliers) is returned.\n\\end{itemize}\n\n\\subsection{get\\_noise}\nFind the standard deviation of white Gaussian noise in the data.\n{\\bf\n\\begin{center}\n     USAGE: SigmaNoise = get\\_noise(Data, Niter=Niter)\n\\end{center}}\n{\\em Data} is an IDL array (1D, 2D, or 3D), and ({\\em Niter}) is a keyword\nwhich fixes the number of iterations used by the sigma clipping. Default\nvalue is 3.\n\n\\section{Display}\n\\subsection{tvlut}\nDisplay an image with a zoom factor, and the LUT is displayed\nThe zoom factor is calculated automatically in order to visualize\nthe image in a window of size 320 $\\times$ 320 (for an image 32 $\\times$ \n32, the\nzoom factor is 320/32 = 10). An offset is automatically calculated\n(or is set by keywords) in order to center the image in the IDL window. \n{\\bf\n\\begin{center}\n     USAGE: tvlut, Data, Depx=Depx, Depy=Depy\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em Data}: 2D IDL array (input data) to visualize.\n\\item {\\em Depx}: offset in x (default is 50).\n\\item {\\em Depy}: offset in y (default is 80).\n\\end{itemize}\n\n\\subsection{xdisp}\nXDISP is a widget program for image analysis. Several operations\ncan be carried out by using the mouse and pressing buttons:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item QUIT: quit the application\n\\item LOAD: load a FITS image. \n\\item LUT: modify the LUT.\n\\item PROFILE: examine rows or columns.\n\\item CURSOR: examine pixel values. If the image format is FITS and if\nthe header contains astrometric position, then the pixel\nposition in the sky is given (right ascension and declination).\n\\item HISTO: plot the histogram.\n\\item CONTOURS: Contours of the image (isophotes).\n\\item 3D VISU: three-dimensional representation of the image.\n\\item INFO: print the min, max, mean, sigma of the image.\n\\item FFT: compute the Fourier transform and display either the power \nspectrum, the phase, the real part or the imaginary part.\n\\item PAN: make a zoom. Zoom factors are 2,4,8,1/2,1/4,1/8\n\\end{itemize}\n{\\bf\n\\begin{center}\n     USAGE: xdisp, Data [, FitsHeader]\n\\end{center}}\n{\\em Data} is a two-dimensional IDL array, and {\\em FitsHeader} (string array)\nis an optional parameter for astrometric information (in FITS format).\n\n\\subsection{x3d}\nX3D is a widget program for cube analysis. Several operations\ncan be carried out by using the mouse and buttons:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item  QUIT: quit the application\n\\item Temporal Cut: A temporal cut is displayed.\n\\item Horizontal Cut: A horizontal cut is displayed.\n\\item Vertical Cut: A vertical cut is displayed.\n\\item Frame Number: When the user enters a value V followed by carriage return\nthe image Cube(*,*,V) is displayed.\n\\item Window Size: Define the number of elements plotted.\n\\item Slider Frame Number: When the user moves the slider, \nthe corresponding frame is displayed.\n\\end{itemize}\n\n{\\bf\n\\begin{center}\n     USAGE: x3d, Data, from=from, to=to\n\\end{center}}\n{\\em Data} is an IDL 3D array. The keywords {\\em from} and {\\em to} allow\nthe user \nto define a subcube, which can analysed separately with x3d.\n\\subsubsection*{Example:}\n\\begin{verbatim}\nIDL> HELP,MY_CUBE \n       MY_CUBE         INT       = Array(32, 32, 100)\nIDL>  X3D, my_cube,from=[0,21,50],to=[20,49,99] \n\\end{verbatim}\n\n\\subsection{xdump}\nSave the selected window in a Postscript file. The file\nname is ``idl.ps''. \n{\\bf\n\\begin{center}\n     USAGE: xdump, FILENAME=filename, WIN=win, LANDSCAPE=landscape, \n              SCALE=scale, TITLE=title, GIF=gif\n\\end{center}}\nwhere keywords are\n\\begin{itemize}\n\\item {\\em filename}: filename of output Postscript file (default is ``idl.ps\")\n\\item {\\em win}: identifier of IDL window (default is active window)\n\\item {\\em landscape}: set landscape orientation\n\\item {\\em title}: add the title at the upper left corner of window\n\\item {\\em scale}: specify a scale to be applied to the entire graph\n\\item {\\em gif}: store the data in GIF format instead of PS format.\n Default title in this case ``idl.gif\".\n\\end{itemize}\n \n \n\n\\section{Multiresolution Routines (1D)}\n\\subsection{mr1d\\_atrou}\nComputes a multiresolution transform of a 1D Signal by the\n\\`a trous algorithm.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_atrou, Signal, WaveTrans, Nscale, mirror=mirror, linear=linear\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input one-dimensional IDL array.\n\\item {\\em WaveTrans}: output two-dimensional array (wavelet transform).\n\\item {\\em Nscale}: number of scales (input parameter).\n\\item {\\em mirror}: if set, then mirroring is used at the border. \n\\item {\\em linear}: if set, then a linear wavelet function is used.\nIf not set, then a B-spline wavelet function is used.\n\\end{itemize}\n \n\\subsection{mr1d\\_pavemed}\nComputes a multiresolution transform of a 1D Signal by the\nmultiresolution median algorithm.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_pavemed, Signal, MedTrans, Nscale, cont=cont\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input one-dimensional IDL array.\n\\item {\\em MedTrans}: output two-dimensional array (multiresolution transform).\n\\item {\\em Nscale}: number of scales (input parameter).\n\\item {\\em cont}: if set, consider the data as constant beyond\nthe borders. \n\\end{itemize}\n \n\\subsection{mr1d\\_minmax}\nComputes a multiresolution transform of a 1D Signal by the\nmin-max algorithm.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_minmax, Signal, MinMaxTrans, Nscale\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input one-dimensional IDL array.\n\\item {\\em MinMaxTrans}: output two-dimensional array \n(multiresolution transform).\n\\item {\\em Nscale}: number of scales (input parameter).\n\\end{itemize}\n\n\\subsection{mr1d\\_pyrmed}\nComputes a multiresolution transform of a 1D Signal by the\npyramidal median algorithm.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_pyrmed, Signal, MedTrans, Nscale, TabNp=TabNp, interp=interp, cont=cont\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input one-dimensional IDL array.\n\\item {\\em MedTrans}: output two-dimensional array (multiresolution transform).\n\\item {\\em Nscale}: number of scales (input parameter).\n\\item {\\em TabNp}: Number of pixels at each scale of the multiresolution\ntransform (MedTrans(0:TabNp(j)-1) are the multiresolution coefficients\nof the scale j).\n\\item {\\em interp}: if set, each scale is interpolated to the size of the \ninput signal.\n\\item {\\em cont}: if set, consider the data as constant outside\nthe borders. \n\\end{itemize}\n \n\\subsection{mr1d\\_paverec}\nReconstruct a signal from its multiresolution transform (\\`a trous algorithm\nor multiresolution median transform).\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_paverec, MR\\_Trans, Rec\\_Signal, Adjoint=Adjoint, \nmirror=mirror, nosmooth=nosmooth\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em MR\\_Trans}: input two-dimensional \nIDL array (multiresolution transform).\n\\item {\\em Rec\\_Signal}: output one-dimensional \nIDL array. This is the reconstructed signal.\n\\item {\\em Adjoint}: if set, the adjoint operator is used for the \nreconstruction.\n\\item {\\em nosmooth}: if set, the last scale is not used.\n\\item {\\em interp}:  if set, and if adjoint is set, \nthen mirroring is used beyond the borders.\n\\end{itemize}\n\n\\subsection{mr1d\\_pyrrec}\nReconstruct a signal from its pyramidal multiresolution transform.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_pyrrec, MR\\_Trans, Rec\\_Signal\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em MR\\_Trans}: input two-dimensional IDL array (multiresolution transform).\n\\item {\\em Rec\\_Signal}: output one-dimensional IDL array. This \nis the reconstructed signal.\n\\end{itemize}\n \n\\subsection{mr1d\\_pyrinterp}\nInterpolate each scale of a 1D pyramidal multiresolution transform to the size\nof the original signal.\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_pyrinterp, MR\\_Trans\n\\end{center}}\nwhere {\\em MR\\_Trans} is a pyramidal multiresolution transform.\n\n\n\\subsection{mr1d\\_tabcoef}\nReturn the pre-computed table for noise behavior in the multiresolution \ntransform.\n{\\bf\n\\begin{center}\n     USAGE: output =  mr1d\\_tabcoef(TypeTransform)\n\\end{center}}\nwhere {\\em TypeTransform} is the type of multiresolution transform. Available\ntypes are ``atrou\", ``pyrmed\" or ``pavemed\". The output is a float array which\ngives the standard deviation of the noise at each scale, when we apply\na multiresolution transform to a signal following a Gaussian distribution \nwith a standard deviation equal to 1. \n \n\\subsection{mr1d\\_trans}\nOne-dimensional wavelet transform. 19 transforms are available\n (see \\ref{sect_mr1dtrans}), which are grouped in 5 classes:\n\\bi\n\\item Class 1: no decimation (transform 1 to 7 and 11 to 14).\n\\item Class 2: pyramidal transform (transform 8 to 10).\n\\item Class 3: orthogonal transform (15 and 16).\n\\item Class 4: Wavelet packets (17 and 18).\n\\item Class 5: Wavelet packets from the \\`a trous algorithm  (19).\n\\ei\nDepending on the class, the transform does not contain the\nsame number of pixels, and the data representation differs.\n{\\bf\n\\begin{center}\n     USAGE: MR1D\\_Trans, Signal, Result, OPT=OPT, BAND=BAND, NODEL=NODEL \n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input one-dimensional IDL array.\n\\item {\\em Result}: output IDL structure.\n\\item {\\em Opt}: string which contains the different options \n(see the {\\em mr1d\\_trans} C++  program).\n\\item {\\em Band}: if set, a tag per band is created in the output structure.\n\\item {\\em Nodel}: if set, the two created file are not deleted: \\\\\nxx\\_result.fits: wavelet coefficients file  \\\\\nxx\\_info.fits: information about the transform\n\\end{itemize}\n{\\em Result} is IDL structure which contains the wavelet transform.\nThe structure contains the following tags:\n{\\small\n\\bi\n\\item N\\_BAND: float; number of bands in the transfrom    \n\\item INFO: 2D float array (Array[2, NbrBand+3])\n\\begin{verbatim}\n                       info[0,0] = transform number\n                       info[1,0] = number of scales\n                       info[0,1] = transform class number (5 classes)\n                       info[1,1] = number of bands\n                                 it is not equal to the number of scales\n                                 for wavelet packets transform.\n                       info[0,2] = number of pixels\n                       info[1,2] = lifting scheme type\n                       info[0,3] = type of filter\n                       info[1,3] = type of normalization\n                       for i=4 to Number_of_bands + 3  \n                       info[0,i] = number of pixels in the band i\n                       info[1,i] = position number of the pixel of the band\n\t\t       If a user filter file is given (i.e. -T 6,filename), \n                       with a filename of $L$ characters, $L$ lines are added \n                       to the array:\n                       info[1,Number_of_bands + 4] = number of characters of \n                                                    the filter file name\n                        for i=Number_of_bands+4 to  Number_of_bands+4+L-1\n                             info[0,i] = ascii number of the ith character.\n\\end{verbatim}\nIf a user filter file is given (i.e. -T 6,filename), with a filename \nof $L$ characters, $L$ lines are added to the array:\n\\begin{verbatim}\n        info[1,Number_of_bands + 4] = number of characters of the filter file name\n        for i=Number_of_bands+4 to  Number_of_bands+4+L-1\n\tinfo[0,i] = ascii number of the ith character.\n\\end{verbatim}\n\\item FROM: 1D array (NbrBand); position of the first pixel \n\\item TO: 1D array (NbrBand); position of the last pixel\n\\item COEF: 1D or 2D FLOAT array; wavelet coefficients\n     for non-redundant transform (15,16,17), it is a 1D array \\\\\n     for other transform, it is 2D array \\\\\n     class 1 and 5: coeff[*,i] = band i (i in [0..NbrBand-1]) \\\\\n     class 2: coeff[0:to[i],i] = band i \\\\\n     class 3 and 4: coeff[from[i]:to[i]] = band i \\\\\n\\item Bandi: if BAND keyword is set, the array coef is also split \ninto bands:\n\\begin{verbatim}\n            BAND1   : band 1  \n            BAND2   : band 2  \n                      ...\n            BANDi   : band i  \n\\end{verbatim}\n\\ei\n}\n\n\\subsection{mr1d\\_recons}\nReconstruct a one-dimensional signal from its wavelet transform.   \n{\\bf\n\\begin{center}\n     USAGE:  MR1D\\_RECONS, WT\\_Struct, result\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em WT\\_Struct}: input  IDL structure (obtained using IDL MR1D\\_TRANS program)..\n\\item {\\em Result}: output one-dimensional IDL array.\n\\end{itemize}\n\n\\subsection{mr1d\\_filter}\nFilter a 1D signal:\n\\begin{center}\n     USAGE: mr1d\\_filter, Signal, Result, Opt=Opt\n\\end{center}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: input  one-dimensional IDL array.\n\\item {\\em Result}: output one-dimensional IDL array (filtered signal).\n\\item {\\em Opt}:  string which contains the different options \n(see the {\\em mr1d\\_filter} C++  program).\n\\end{itemize}\n\n\\section{Spectral Analysis}\n\n\\subsection{mr1d\\_continuum}\nEstimate the continuum of a 1D signal.\n{\\bf\n\\begin{center}\n     USAGE: output = mr1d\\_continuum(Signal, Nscale,Sigma=Sigma,median=median,mirror=mirror)\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: 1D IDL array. Input spectrum.\n\\item {\\em Output}: 1D IDL array. Estimated continuum.\n\\item {\\em Nscale}: number of scales.\n\\item {\\em median}: if set  use multiresolution median transform\n\\item {\\em mirror}: if set, use mirroring at borders.\n\\item {\\em niter}: number of iterations. Default is 5.\n\\item {\\em Sigma}: noise estimation (output keyword).\n\\end{itemize}\n\n\\subsection{mr1d\\_optical\\_depth}\nEstimate the optical depth of a spectrum.\n{\\bf\n\\begin{center}\n     USAGE: output = mr1d\\_optical\\_depth(Signal, Nscale, Sigma=Sigma)\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em Signal}: 1D IDL array. Input spectrum.\n\\item {\\em Output}: 1D IDL array. Estimated optical depth.\n\\item {\\em Nscale}: number of scales.\n\\item {\\em Sigma}: noise estimation (output keyword).\n\\end{itemize}\n\n\\subsection{mr1d\\_detect}\n{\\bf\n\\begin{center}\n     USAGE: mr1d\\_detect, Signal, result, OPT=OPT, print=print, tabobj=tabobj, \n    NbrObj=NbrObj, nodel=nodel, tabw=tabw\n\\end{center}}\nwhere\n\\begin{itemize}\n\\item {\\em Signal}: input signal.\n\\item {\\em result}: output signal (sum of all detected objects).\n\\item {\\em OPT}: string which contains the different options \n(see the {\\em mr1d\\_detect} C++  program).\n\\item {\\em print}: if set, information about each detected object is printed.\n\\item {\\em tabobj}: IDL structure which contains the information about \nthe objects. For each object, we have\n\\begin{itemize}\n\\item NumObj: Object number \n\\item Pos: Position in the signal (in wavelength units). \n\\item Sigma: standard deviation of the band (in wavelength units).\n\\item Fwhm:  Full-width at half-maximum (in wavelength units).\n\\item PosPix: Position in the signal (in pixel units).\n\\item SigmaPix: standard deviation of the band (in pixel units).\n\\item Flux:  integrated flux of the band.\n\\end{itemize}\n\\item {\\em NbrObj}: number of detected objects\n\\item {\\em nodel}: if set, the created files \n(by the {\\em mr1d\\_detect} C++ program)\nare not deleted.\n\\item {\\em tabw}:  wavelength array\n\\end{itemize}\n\n\n\n\\section{Multiresolution Routines (2D)}\n\n\\subsection{mr\\_transform}\nComputes a multiresolution transform of an image. If the\nkeyword {\\em MR\\_File\\_Name} is set, a file is created\nwhich contains the multiresolution transform. A multiresolution file\nhas a ``.mr\" extension, and if the parameter file name does not \nspecify this, then\nthe extension is added to the file name. Result is stored in the {\\em \nDataTransf}. \nDepending on the options, DataTransf can be a cube, an\nimage, or an IDL structure. This routine calls \nthe C++ executable {mr\\_transform}. \nThe keyword ``OPT\" allows to pass to the executable all\noptions described in section~\\ref{sect_trans}.\n\n{\\bf\n\\begin{center}\n  USAGE: mr\\_transform, Data, DataTransf, MR\\_File\\_Name=MR\\_File\\_Name, OPT=Opt\n\\end{center}}\n\\subsubsection*{Examples:}\n\\begin{itemize}\n\\item mr\\_transform, I, Output, MR\\_File\\_Name='result.mr' \\\\\nCompute the multiresolution of the image {\\em I} with default options\n(i.e.\\ \\`a trous algorithm with 4 scales). The result is stored in \nthe file ``result.mr\".\n\\item mr\\_transform, I, Output, MR\\_File\\_Name='result\\_pyr\\_med', \nOPT='-t 10 -n 5' \\\\\nCompute the multiresolution of {\\em I}  by using the pyramidal median \nalgorithm with 5 scales. The result is stored in the file\n``result\\_pyr\\_med.mr\".\n\\end{itemize}\n\n\\subsection{xmr\\_transform}\nComputes a multiresolution transform of an image. Parameters are\nchosen through a widget interface. Creates a file which contains\nthe multiresolution transform of the image. The transform is made\nby calling the routine mr\\_transform. If there is an image parameter\nthe user doesn't need to load an image with the interface.  \n{\\bf\n\\begin{center}\n   USAGE: xmr\\_transform, TransfData, input=input\n\\end{center}}\n{\\em TransfData} is the output transform, and {\\em input} is the input\nimage. \n\n\n\\subsection{mr\\_info}\nCalculate statistical information about the wavelet transform\nof an image. This routine calls \nthe C++ executable {mr\\_info}. \nThe keyword ``OPT\" allows to pass to the executable all\noptions described in section~\\ref{sect_trans}.\nThe output is the 2D IDL array $T(*,0:4)$ with the following\nsyntax:\n\\begin{itemize}\n\\item  T(j,0) = standard deviation of the jth band\n\\item T(j,1) = skewness of the jth band\n\\item T(j,2) = kurtosis of the jth band\n\\item T(j,3) = minimum of the jth band\n\\item T(j,4) = maximum of the jth band\n\\end{itemize}\n\n{\\bf\n\\begin{center}\n  USAGE: mr\\_info, Data, TabStat, OPT=Opt, nodel=nodel, NameRes=NameRes\n\\end{center}}\n\\subsubsection*{Example:}\n\\begin{itemize}\n\\item mr\\_info, I, Stat \\\\\nCompute the multiresolution of the image {\\em I} with default options\n(i.e.\\ \\`a trous algorithm with 4 scales) and calculate statistical\ninformation about each band.\n\\end{itemize}\n\n\n\\subsection{mr\\_extract}\nExtract a scale from a multiresolution transform. This routine \ncalls the C++ executable {mr\\_extract}. The keyword ``OPT\" \nallows \nall options described in \nsection~\\ref{sect_extr}\nto be passed to the executable.\n{\\bf\n\\begin{center}\n   USAGE: mr\\_extract, Multiresolution\\_File\\_Name, ScaleImage, OPT=Opt\n\\end{center}}\nwhere {\\em Multiresolution\\_File\\_Name} is a string which contain the \nname of multiresolution file (``.mr\"), and {\\em ScaleImage} is the output\nimage (IDL 2D array).\n\n\\subsection{mr\\_read}\nRead a multiresolution file (extension ``.mr\"). If the multiresolution\ntransform is a cube, the output is a three-dimensional array. \nIf it is an image the output is a two-dimensional IDL array.\nIf it is a pyramidal transform or a half-pyramidal transform, \nwe have 3 different outputs:\n\\begin{enumerate}\n\\item an image containing several subimages (flag raw set)\n\\item a cube of interpolated or rebinned images (flag interpol set)\n\\item a structure containing several subimages  (default)\n\\end{enumerate}\n{\\bf\n\\begin{center}\n     USAGE: output = mr\\_read(filename, interpol=interpol, raw=raw, debug=debug)\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em filename}: string which contains the file name of \nthe multiresolution transform (extension ``.mr\").\n\\item {\\em interpol}: integer (for pyramidal transform only) \\\\\n0: the output will not be interpolated \\\\\n1: the output will be rebinned \\\\\n2: the output will be interpolated \\\\\n\\item {\\em raw}: if set the output overwrites the \ninput FITS file (for pyramidal transform only).\n\\item {\\em debug}: if set, the routine is verbose\n\\end{itemize}\n\n\\subsection{mr\\_compare}\nComparison between a reference image and an image or a sequence of images.\nThe comparison is carried out on the multiresolution scales.\nIf {\\em Ima\\_Or\\_Cube} is a cube,  \nthe processing is repeated on each image of the\ncube (*,*,i).\nFor each image {ima\\_i} of the cube {\\em Ima\\_Or\\_Cube} \n\\begin{itemize}\n\\item  we compute the wavelet transform {\\em WaveRef} of {\\em ImaRef}\n\\item  we compute the wavelet transform {\\em WaveIma} of {\\em  ima\\_i}\n\\item  we calculate the  correlation at each scale s: \\\\\nif TabCorrel[s,i] = 1 then WaveRef[*,*,s] = WaveIma[*,*,s] are identical \\\\\nelse TabCorrel[s,i] is less than 1, and some differences exist.\n\\item  we calculate the  RMS at each scale:    \\\\\n  TabRMS[s,i] = sigma( WaveRef[*,*,s] - WaveIma[*,*,s]])\n\\item  we calculate the normalized SNR at each scale (in dB): \\\\\n  TabSNR[s,i] = 10 alog10 ( mean(WaveRef[*,*,s]\\^2) \\/ TabRMS[s,i]\\^2)\n\\end{itemize}\nThis routine  calls the C++ \nexecutable {mr\\_transform} described in section~\\ref{sect_trans}.\n\n{\\bf\n\\begin{center}\n     USAGE:  mr\\_compare, ImaRef, Ima\\_Or\\_Cube, TabCorrel, TabRMS, TabSNR, Nscale=Nscale, plot=plot, title=title\n\\end{center}}\nwhere \n\\begin{itemize}\n\\item {\\em ImaRef}: IDL 2D array. Reference image.\n\\item {\\em Ima\\_Or\\_Cube}:  IDL 2D or 3D array.  Image or sequence of images \nto be compared.\n\\item {\\em Nscale}: number of scales for the comparison\n\\item {\\em plot}: if set, then plot the results\n\\item {\\em title}:  is set, add the title to the plots\n\\item {\\em TabCorrel}:  1D or 2D IDL array: output correlation table\n\\item {\\em TabRMS}:  1D or 2D IDL array: output RMS table\n\\item {\\em TabSNR}:  1D or 2D IDL array: output SNR table (in dB)\n\\end{itemize}\n\\subsubsection*{Example}\nmr\\_compare, imaref, ima1, tc, tr, ts, /plot, title='Comparison ImaRef-Ima1'\\\\\nComparison of the images {\\em imaref} and {\\em ima1}.\n\n\n\\subsection{mr\\_background}\nEstimate the background of an image. \n{\\bf\n\\begin{center}\n     USAGE:  output=mr\\_background(Image, nscale=nscale, border=border)\n\\end{center}}\nIf {\\rm border} is set, the background is estimated from the border of\nthe image. If not, the pyramidal median transform is used with {\\em nscale}\nscales (default is 3) by calling the C++ executable {mr\\_background} described in section~\\ref{sect_bgr}.\n\n\n\\subsection{mr\\_filter}\nFilter  an image by using a multiresolution transform. \nThis routine is calling the C++ executable {mr\\_filter}. The keyword \n``OPT\" allows \nall options described in section~\\ref{sect_filter}\nto be passed to the executable.\n\n{\\bf\n\\begin{center}\n     USAGE: mr\\_filter, Data, FilterData, opt=opt\n\\end{center}}\n{\\em Data} is an image (2D IDL array), and {\\em FilterData} is the result\nof the filtering.\n\n\\subsection{im\\_deconv}\nDeconvolve an image by standard methods. This routine calls \nthe C++ executable {im\\_deconv}. The keyword ``OPT\" \nallows \nall options described in section~\\ref{sect_deconv} to be passed \nto the executable.\n\n{\\bf\n\\begin{center}\n     USAGE: im\\_deconv, Data, PSF, DeconvData, opt=opt\n\\end{center}}\n\\subsubsection*{Examples:} \n\\begin{itemize}\n\\item im\\_deconv, Imag, Psf, Result \\\\\ndeconvolve an image with all default options (gradient method).\n\\item  im\\_deconv, Imag, Psf, Result, OPT='-i 30 -e 0' \\\\\nsame example, but impose the number of iterations to be 30.\n\\item  im\\_deconv, Imag, Psf, Result, OPT='-d 4 -i 30' \\\\\ndeconvolution by the one step gradient method, without \nany regularization, with 30 iterations.\n\\end{itemize}\n\n\n\\subsection{mr\\_deconv}\nDeconvolve an image by using the multiresolution support. This routine calls \nthe C++ executable {mr\\_deconv}. The keyword ``OPT\" \nallows \nall options described in section~\\ref{sect_deconv} to be passed \nto the executable.\n\n{\\bf\n\\begin{center}\n     USAGE: mr\\_deconv, Data, PSF, DeconvData, opt=opt\n\\end{center}}\n\\subsubsection*{Examples:} \n\\begin{itemize}\n\\item mr\\_deconv, Imag, Psf, Result \\\\\ndeconvolve an image with all default options (Richardson-Lucy method + \nregularization in  wavelet space by using the \\`a trous \nalgorithm, etc.).\n\\item  mr\\_deconv, Imag, Psf, Result, OPT='-i 30 -e 0'  \\\\\nsame example, but impose the number of iterations to be 30.\n\\item  mr\\_deconv, Imag, Psf, Result, OPT='-d 2 -i 30' \\\\\ndeconvolution by the one step gradient method, without \nany regularization, with 30 iterations.\n\\end{itemize}\n\n\\subsection{mr\\_detect}\nDetect the sources in  an image by using a multiresolution transform. \nThis routine calls the C++ executable {mr\\_detect}. The keyword ``OPT\" \nallows all options described in section~\\ref{sect_detect}\nto be passed to the executable. \n\n{\\bf\n\\begin{center}\n     USAGE: mr\\_detect, imag, result, OPT=OPT, print=print, tabobj=tabobj, \n    NbrObj=NbrObj, nodel=nodel, RMS=RMS\n\\end{center}}\nwhere\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item {\\em imag}: input image.\n\\item {\\em result}: output image (sum of all detected objects).\n\\item {\\em OPT}: option keyword.\n\\item {\\em print}: if set, information about each detected object is printed.\n\\item {\\em tabobj}: IDL structure which contains the information about \nthe objects. For each object, we have\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item ScaleObj: scale where the object is detected.\n\\item NumObj: object number \n\\item PosX: X coordinate in the image.\n\\item PosY: Y coordinate in the image.\n\\item SigmaX: standard deviation on first main axis of the object.\n\\item SigmaY: standard deviation on second main axis of the object.\n\\item Angle: angle between the main axis and x-axis.\n\\item ValPixMax: value of the maximum of the object.\n\\item Flux: integrated flux of the object.\n\\item Magnitude: magnitude of the object.\n\\item ErrorFlux: flux error.\n\\item SNR\\_ValMaxCoef: signal to noise ratio of the maximum of the wavelet\ncoefficient.\n\\item SNR\\_Obj: signal to noise ratio of the object.\n\\item PosCoefMaxX: X coordinate  of the maximum wavelet coefficient\n\\item PosCoefMaxY: Y coordinate  of the maximum wavelet coefficient\n\\end{itemize}\n\\item {\\em NbrObj}: number of detected objects\n\\item {\\em nodel}: if set, the files created (by the program mr\\_detect)\nare not deleted.\n\\item {\\em RMS}: RMS image related to the input image.\n\\end{itemize}\n\\subsubsection*{Examples:} \nmr\\_detect, imag, result, tabobj=tabobj, NbrObj=NbrObj \\\\\ndetects all sources with default options in the image {\\em imag}. \\\\\nprint, NbrObj \\\\\nprint the number of objects. \\\\\nprint, tabobj(0).PosX, tabobj(0).PosY \\\\\nprint the coordinates of the first object. \\\\\n\n\\subsection{xlive}\nXLIVE is a widget program for large image analysis. The large image\nhas to be compressed  by mr\\_comp or mr\\_lcomp before being \nanalyzed. Then the XLIVE data format is the MRC format.\nWhen an MRC file is read, an image at very low resolution is displayed\nand the user can improve the resolution of the image, or of a part\nthe image, using the RESOLUP button. When RESOLUP is called,\nXLIVE reads from the MRC file the  wavelet coefficient needed for improving\nthe resolution. \nIf the large image has been compressed by block (-C option), only  \nthe blocks needed are decompressed, and the image in memory has always\na size compatible with the window size.\nThe Dat parameter (if given) contains the last displayed image.\nIf it is not given, the user can however get it using the global\nvariable XIMA.\n\nSeveral operations can be carried out by using the mouse and pressing buttons:\n\\begin{itemize}\n\\baselineskip=0.4truecm\n\\item QUIT: quit the application.\n\\item LOAD: load a FITS image. \n\\item LUT: modify the LUT.\n\\item PROFILE: examine rows or columns.\n\\item CURSOR: examine pixel values. If the image format is FITS and if\nthe header contains astrometric position, then the pixel\nposition in the sky is given (right ascension and declination).\n\\item HISTO: plot the histogram.\n\\item CONTOURS: contours of the image (isophotes).\n\\item 3D VISU: three-dimensional representation of the image.\n\\item INFO: print the min, max, mean, sigma of the image.\n\\item FFT: compute the Fourier transform and display either the power \nspectrum, the phase, the real part or the imaginary part.\n\\item PAN: make a zoom. Zoom factors are 2,4,8,1/2,1/4,1/8\n\\item RESOLUP: Improve the image resolution. If the new image size is\ngreater than the window size, the user must click in the area\nhe/she wishes to see, and only this part of the image will be \ndecompressed.\n\\item RESOLDOWN: decrease the resolution.\n\\item RESOL: goto a given resolution.\\end{itemize}\n{\\bf\n\\begin{center}\n     USAGE: xlive, [Dat,], FILEName=FileName, WindowSize=WindowSize \n\\end{center}}\n{\\em Dat} is an output two-dimensional IDL array, \nand {\\em FileName} (string array)\nis an optional parameter containing the MRC filename to be read.  \n\n", "meta": {"hexsha": "9801013ef6818757db9ab32a48f031db3bafb6f9", "size": 35397, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr1/ch5_idl.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr1/ch5_idl.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr1/ch5_idl.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9796137339, "max_line_length": 119, "alphanum_fraction": 0.7241009125, "num_tokens": 10157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.41257486965710694}}
{"text": "\n\\section{Introduction}\n\nThis model adds equations for a rigid body and constraints\nto attach rigid bodies to other things.  The treatment is taken\nfrom Chapter 12 of Zienkiewicz and Taylor~\\cite{ZienTayl00b}.\n\nThe nodal variables are displacements in the $x$ and $y$ directions\nand rotation about the $z$ axis.\n\n\n\\subsection{Interface}\n\n\\nwfilename{model-rigid.nw}\\nwbegincode{1}\\sublabel{NWmodE-modD-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modD-1}}}\\moddef{model-rigid.h~{\\nwtagstyle{}\\subpageref{NWmodE-modD-1}}}\\endmoddef\n#ifndef MODEL_RIGID_H\n#define MODEL_RIGID_H\n\n#include \"modelmgr.h\"\n\nvoid model_rigid_register(model_mgr_t model_mgr);\n\n#endif /* MODEL_RIGID_H */\n\\nwnotused{model-rigid.h}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\n\\subsection{Rigid body equations}\n\n% Equations of motion for the rigid body\n\nThe equations of motion for a rigid body with center of mass $R$\nare the balance of linear and angular momentum:\n\\begin{eqnarray*}\n  (m      r_{,t})_{,t} =   p_{,t} & = & \\sum f_a \\\\\n  (J \\omega_{,t})_{,t} = \\pi_{,t} & = & \\sum (x_a - r) \\times f_a\n\\end{eqnarray*}\nSince we are working in two dimensions, $J$ is a scalar value\nand not a 3-by-3 tensor, which makes life a little simpler.\n\n\n\\subsection{Rigid-flexible coupling}\n\n% Lagrange multipliers\n\nIn general, our rigid bodies will be coupled to flexural elements\n(beams).  We add the coupling by writing a set of constraint\nequations that relate the rigid body displacements to the\ndisplacements of attached nodes, and enforcing those constraints\nvia Lagrange multipliers.  For the moment, let $x$ be the vector\nof unknowns for the flexible part, and $y$ be the vector of\nunknowns for the rigid part.  Then we have two energy functionals\n$I_1(x)$ and $I_2(y)$, and a coupling equation $C(x,y) = 0$.\nAccording to Lagrange multipliers, to minimize $I_1 + I_2$\nsubject to the constraints, we should minimize\n\\[\n  I(x, y, \\lambda) = I_1(x) + I_2(y) + \\lambda^T C(x,y)\n\\]\n\nAfter we take variations of everything in sight, we end up with\nthe augmented residual equations\n\\[\n  \\begin{pmatrix}\n    R_1(x) + \\frac{\\partial C}{\\partial x}^T \\lambda \\\\\n    R_2(y) + \\frac{\\partial C}{\\partial y}^T \\lambda \\\\\n    C(x, y)\n  \\end{pmatrix} = 0\n\\]\nThe tangent matrix is\n\\[\n  \\begin{pmatrix}\n       K_1 &      0 & C_{,x}^T \\\\\n         0 &    K_2 & C_{,y}^T \\\\\n    C_{,x} & C_{,y} &        0\n  \\end{pmatrix}\n\\]\n\nNote that the Lagrange multiplier variables $\\lambda$ are purely\nlocal, and could be eliminated on an element-by-element basis.\nRight now, we leave them explicit in the system.\n\nLet $u_1, u_2$ and $\\theta$ be the displacement and rotation\nnodal degrees of freedom for a beam node which is to be connected \nto a rigid body.  The rigid body is described by the current position\nof its center of mass ($r_1, r_2$) and the rotation matrix $Q(\\omega)$\n(rotation of $\\omega$ in the plane).\nIf $R$ and $X$ are the reference positions for the rigid body\ncenter of mass and the attached node, then\n\\[\n  C = \n  \\begin{pmatrix}\n    (r + Q(\\omega) (X-R)) - x \\\\\n    \\omega - \\theta\n  \\end{pmatrix} = 0\n\\]\nThere is one problem with these constraints -- the ``rotational''\nparameter $\\theta$ for the beam theory actually represents a\nlinearization, while $Q(\\omega)$ is an honest rotation.  For\nthe moment, I cross my fingers and hope that the angles remain small\nenough that replacing $\\theta - \\omega = O(\\omega^2)$ with\n$\\theta - \\omega = 0$ will not be too terrible.\n\n\n\n\\section{Implementation}\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NWmodE-modD.2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modD.2-1}}}\\moddef{model-rigid.c~{\\nwtagstyle{}\\subpageref{NWmodE-modD.2-1}}}\\endmoddef\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <math.h>\n#include <assert.h>\n\n#include \"model-rigid.h\"\n#include \"affine.h\"\n#include \"mesh.h\"\n#include \"vars.h\"\n#include \"assemble.h\"\n#include \"netdraw.h\"\n#include \"netout.h\"\n\n\\LA{}types~{\\nwtagstyle{}\\subpageref{NWmodE-typ5-1}}\\RA{}\n\\LA{}model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}\\RA{}\n\\LA{}registration function~{\\nwtagstyle{}\\subpageref{NWmodE-regL-1}}\\RA{}\n\\nwnotused{model-rigid.c}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NWmodE-regL-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-regL-1}}}\\moddef{registration function~{\\nwtagstyle{}\\subpageref{NWmodE-regL-1}}}\\endmoddef\nvoid model_rigid_register(model_mgr_t model_mgr)\n\\{\n    model_element_t model;\n\n    \\LA{}register models~{\\nwtagstyle{}\\subpageref{NWmodE-regF-1}}\\RA{}\n\\}\n\\nwused{\\\\{NWmodE-modD.2-1}}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\n\\subsection{Rigid body model}\n\nThe user will eventually have to supply a mass and an inertia tensor,\nbut at the moment we just leave placeholders.  Note that the ``user''\nhere could well be a subnet or other higher-level abstraction.\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NWmodE-typ5-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-typ5-1}}}\\moddef{types~{\\nwtagstyle{}\\subpageref{NWmodE-typ5-1}}}\\endmoddef\ntypedef struct rigid_t \\{\n    element_t element;\n    int node;\n    int vars[3];\n    double m;\n    double J;\n\\} rigid_t;\n\n\\nwalsodefined{\\\\{NWmodE-typ5-2}}\\nwused{\\\\{NWmodE-modD.2-1}}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NWmodE-modF-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\endmoddef\nstatic element_t* rigid_init(mesh_t mesh, const char* model,\n                        model_element_t* modelfunc)\n\\{\n    rigid_t* self = (rigid_t*) \n        mempool_cget(mesh_pool(mesh), sizeof(*self));\n\n    self->element.data = self;\n    self->element.model = modelfunc;\n\n    if (mesh_num_param_nodes(mesh) != 1)\n        mesh_error(mesh, \"Incorrect number of nodes for rigid\");\n    self->node = mesh_param_node(mesh, 0);\n\n    return &(self->element);\n\\}\n\n\\nwalsodefined{\\\\{NWmodE-modF-2}\\\\{NWmodE-modF-3}\\\\{NWmodE-modF-4}\\\\{NWmodE-modF-5}\\\\{NWmodE-modF-6}\\\\{NWmodE-modF-7}\\\\{NWmodE-modF-8}\\\\{NWmodE-modF-9}}\\nwused{\\\\{NWmodE-modD.2-1}}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\nI am not sure whether giving the rigid body variables the same names\nas the corresponding beam nodal variables is such a good idea.  But\nI will do it anyway, at least for the moment.\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NWmodE-modF-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-2}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void rigid_vars(void* pself, vars_mgr_t vars)\n\\{\n    rigid_t* self = (rigid_t*) pself;\n\n    self->vars[0] = vars_node(vars, self->node, \"x\");\n    self->vars[1] = vars_node(vars, self->node, \"y\");\n    self->vars[2] = vars_node(vars, self->node, \"rz\");\n\\}\n\n\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\nOnce dynamics are ready, we'll have to make appropriate additions. %'\nUntil then, we just need an output function.\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NWmodE-modF-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-3}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void rigid_output(void* pself, netout_t* netout)\n\\{\n    rigid_t* self = (rigid_t*) pself;\n\n    netout_string        (netout, \"model\",     \"rigid\");\n    netout_int           (netout, \"node\",      self->node);\n    netout_int_matrix    (netout, \"vars\",      self->vars, 1, 3);\n\\}\n\n\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NWmodE-regF-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-regF-1}}}\\moddef{register models~{\\nwtagstyle{}\\subpageref{NWmodE-regF-1}}}\\endmoddef\nmemset(&model, 0, sizeof(model));\nmodel.init    = rigid_init;\nmodel.vars    = rigid_vars;\nmodel.output  = rigid_output;\nmodel_mgr_add_element(model_mgr, \"rigid\", &model);\n\n\\nwalsodefined{\\\\{NWmodE-regF-2}}\\nwused{\\\\{NWmodE-regL-1}}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\n\n\\subsection{Coupling model}\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NWmodE-typ5-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-typ5-2}}}\\moddef{types~{\\nwtagstyle{}\\subpageref{NWmodE-typ5-1}}}\\plusendmoddef\ntypedef struct constraint_t \\{\n    element_t element;\n    int node[2];\n    int vars[9];\n    double relpos[3];\n\\} constraint_t;\n\n\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NWmodE-modF-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-4}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic element_t* constraint_init(mesh_t mesh, const char* model,\n                                  model_element_t* modelfunc)\n\\{\n    constraint_t* self = (constraint_t*) \n        mempool_cget(mesh_pool(mesh), sizeof(*self));\n\n    self->element.data = self;\n    self->element.model = modelfunc;\n\n    if (mesh_num_param_nodes(mesh) != 2)\n        mesh_error(mesh, \"Incorrect number of nodes for rigid constraint\");\n    self->node[0] = mesh_param_node(mesh, 0);\n    self->node[1] = mesh_param_node(mesh, 1);\n\n    return &(self->element);\n\\}\n\n\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NWmodE-modF-5}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-5}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void constraint_set_position(void* pself, mesh_t mesh)\n\\{\n    constraint_t* self = (constraint_t*) pself;\n    double* x1 = mesh_node(mesh, self->node[0])->x;\n    double* x2 = mesh_node(mesh, self->node[1])->x;\n\n    self->relpos[0] = x2[0] - x1[0];\n    self->relpos[1] = x2[1] - x1[1];\n    self->relpos[2] = x2[2] - x1[2];\n\\}\n\n\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NWmodE-modF-6}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-6}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void constraint_vars(void* pself, vars_mgr_t vars)\n\\{\n    constraint_t* self = (constraint_t*) pself;\n\n    self->vars[0] = vars_node(vars, self->node[0], \"x\");\n    self->vars[1] = vars_node(vars, self->node[0], \"y\");\n    self->vars[2] = vars_node(vars, self->node[0], \"rz\");\n\n    self->vars[3] = vars_node(vars, self->node[1], \"x\");\n    self->vars[4] = vars_node(vars, self->node[1], \"y\");\n    self->vars[5] = vars_node(vars, self->node[1], \"rz\");\n\n    /* Multiplier variables */\n    self->vars[6] = vars_branch(vars, \"lx\" );\n    self->vars[7] = vars_branch(vars, \"ly\" );\n    self->vars[8] = vars_branch(vars, \"lrz\");\n\\}\n\n\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\nRecall that the constraint equations are\n\\[\n  C = \n  \\begin{pmatrix}\n    (r + Q(\\omega) (X-R)) - x \\\\\n    \\omega - \\theta\n  \\end{pmatrix} = 0\n\\]\nand the corresponding tangent matrix (in block form) is\n\\[\n  \\frac{\\partial C}{\\partial (r, \\omega, x, \\theta)} =\n    \\begin{pmatrix}\n      -I & \\frac{\\partial Q}{\\partial \\omega} (X-R) & -I &  0 \\\\\n       0 & 1                                        &  0 & -1\n    \\end{pmatrix}\n\\]\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NWmodE-**pk-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pk-1}}}\\moddef{contribute $\\partial C / \\partial (x, \\theta)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pk-1}}}\\endmoddef\nKij(7,4) = Kij(4,7) = -1;\nKij(8,5) = Kij(5,8) = -1;\nKij(9,6) = Kij(6,9) = -1;\n\\nwused{\\\\{NWmodE-modF-8}}\\nwendcode{}\\nwbegindocs{26}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{27}\\sublabel{NWmodE-**pu-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pu-1}}}\\moddef{contribute $\\partial C^T \\lambda / \\partial (x, \\theta)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pu-1}}}\\endmoddef\nRi(4) = -xi(7);\nRi(5) = -xi(8);\nRi(6) = -xi(9);\n\\nwused{\\\\{NWmodE-modF-7}}\\nwendcode{}\\nwbegindocs{28}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{29}\\sublabel{NWmodE-**pk.2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pk.2-1}}}\\moddef{contribute $\\partial C / \\partial (r, \\omega)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pk.2-1}}}\\endmoddef\nKij(7,1) = Kij(1,7) =  1;\nKij(8,2) = Kij(2,8) =  1;\n\nKij(7,3) = Kij(3,7) = \\LA{}$(\\partial Q(X-R) / \\partial \\omega)_1$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd-1}}\\RA{};\nKij(8,3) = Kij(3,8) = \\LA{}$(\\partial Q(X-R) / \\partial \\omega)_2$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd.2-1}}\\RA{};\nKij(9,3) = Kij(3,9) =  1;\n\n\\nwused{\\\\{NWmodE-modF-8}}\\nwendcode{}\\nwbegindocs{30}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{31}\\sublabel{NWmodE-**pu.2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pu.2-1}}}\\moddef{contribute $\\partial C^T \\lambda / \\partial (r, \\omega)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pu.2-1}}}\\endmoddef\nRi(1) = xi(7);\nRi(2) = xi(8);\nRi(3) = \\LA{}$(\\partial Q(X-R) / \\partial \\omega)_1$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd-1}}\\RA{} * xi(7) +\n        \\LA{}$(\\partial Q(X-R) / \\partial \\omega)_1$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd-1}}\\RA{} * xi(8) + \n        xi(9);\n\\nwused{\\\\{NWmodE-modF-7}}\\nwendcode{}\\nwbegindocs{32}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{33}\\sublabel{NWmodE-conK-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-conK-1}}}\\moddef{contribute $C(x, y)$~{\\nwtagstyle{}\\subpageref{NWmodE-conK-1}}}\\endmoddef\nRi(7) = xi(1) - xi(4) + (\\LA{}$(Q(X-R))_1$~{\\nwtagstyle{}\\subpageref{NWmodE-$(QC-1}}\\RA{} - relpos[0]);\nRi(8) = xi(2) - xi(5) + (\\LA{}$(Q(X-R))_2$~{\\nwtagstyle{}\\subpageref{NWmodE-$(QC.2-1}}\\RA{} - relpos[1]);\nRi(9) = xi(3) - xi(6);\n\\nwused{\\\\{NWmodE-modF-7}}\\nwendcode{}\\nwbegindocs{34}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{35}\\sublabel{NWmodE-$(QC-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-$(QC-1}}}\\moddef{$(Q(X-R))_1$~{\\nwtagstyle{}\\subpageref{NWmodE-$(QC-1}}}\\endmoddef\n( c * relpos[0]  +  -s * relpos[1])\n\\nwused{\\\\{NWmodE-conK-1}}\\nwendcode{}\\nwbegindocs{36}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{37}\\sublabel{NWmodE-$(QC.2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-$(QC.2-1}}}\\moddef{$(Q(X-R))_2$~{\\nwtagstyle{}\\subpageref{NWmodE-$(QC.2-1}}}\\endmoddef\n( s * relpos[0]  +   c * relpos[1])\n\\nwused{\\\\{NWmodE-conK-1}}\\nwendcode{}\\nwbegindocs{38}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{39}\\sublabel{NWmodE-**pd-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pd-1}}}\\moddef{$(\\partial Q(X-R) / \\partial \\omega)_1$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd-1}}}\\endmoddef\n(-s * relpos[0]  +  -c * relpos[1])\n\\nwused{\\\\{NWmodE-**pk.2-1}\\\\{NWmodE-**pu.2-1}}\\nwendcode{}\\nwbegindocs{40}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{41}\\sublabel{NWmodE-**pd.2-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-**pd.2-1}}}\\moddef{$(\\partial Q(X-R) / \\partial \\omega)_2$~{\\nwtagstyle{}\\subpageref{NWmodE-**pd.2-1}}}\\endmoddef\n( c * relpos[0]  +  -s * relpos[1])\n\\nwused{\\\\{NWmodE-**pk.2-1}}\\nwendcode{}\\nwbegindocs{42}\\nwdocspar\n\n\n\\nwenddocs{}\\nwbegincode{43}\\sublabel{NWmodE-defc-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-defc-1}}}\\moddef{define locals for residual computation~{\\nwtagstyle{}\\subpageref{NWmodE-defc-1}}}\\endmoddef\n#define xi(i) xlocal[(i)-1]\ndouble xlocal[9];\n\ndouble* relpos = self->relpos;\ndouble  c, s;\n\nassemble_matrix_add(x, self->vars, 9, xlocal);\nc = cos(xi(6));\ns = sin(xi(6));\n\\nwused{\\\\{NWmodE-modF-7}\\\\{NWmodE-modF-8}}\\nwendcode{}\\nwbegindocs{44}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{45}\\sublabel{NWmodE-modF-7}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-7}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void constraint_R(void* pself, assemble_matrix_t *R, \n                         assemble_matrix_t* x,\n                         assemble_matrix_t* v,\n                         assemble_matrix_t* a)\n\\{\n    constraint_t* self = (constraint_t*) pself;\n\n    #define Ri(i) Rlocal[(i)-1]\n    double Rlocal[9];\n\n    \\LA{}define locals for residual computation~{\\nwtagstyle{}\\subpageref{NWmodE-defc-1}}\\RA{}\n    memset(Rlocal, 0, sizeof(Rlocal));\n\n    \\LA{}contribute $\\partial C^T \\lambda / \\partial (x, \\theta)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pu-1}}\\RA{}\n    \\LA{}contribute $\\partial C^T \\lambda / \\partial (r, \\omega)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pu.2-1}}\\RA{}\n    \\LA{}contribute $C(x, y)$~{\\nwtagstyle{}\\subpageref{NWmodE-conK-1}}\\RA{}\n\n    #undef xi\n    #undef Ri\n\n    assemble_matrix_add(R, self->vars, 9, Rlocal);\n\\}\n\n\\nwendcode{}\\nwbegindocs{46}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{47}\\sublabel{NWmodE-modF-8}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-8}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void constraint_dR(void* pself, assemble_matrix_t* dR, \n                          double cx, assemble_matrix_t* x,\n                          double cv, assemble_matrix_t* v,\n                          double ca, assemble_matrix_t* a)\n\\{\n    constraint_t* self = (constraint_t*) pself;\n\n    #define Kij(i,j) Klocal[(i) + (j)*9 - 10]\n    double Klocal[81];\n\n    \\LA{}define locals for residual computation~{\\nwtagstyle{}\\subpageref{NWmodE-defc-1}}\\RA{}\n    memset(Klocal, 0, sizeof(Klocal));\n\n    \\LA{}contribute $\\partial C / \\partial (x, \\theta)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pk-1}}\\RA{}\n    \\LA{}contribute $\\partial C / \\partial (r, \\omega)$~{\\nwtagstyle{}\\subpageref{NWmodE-**pk.2-1}}\\RA{}\n\n    #undef xi\n    #undef Kij\n\n    assemble_matrix_add(dR, self->vars, 9, Klocal);\n\\}\n\n\\nwendcode{}\\nwbegindocs{48}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{49}\\sublabel{NWmodE-modF-9}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-modF-9}}}\\moddef{model functions~{\\nwtagstyle{}\\subpageref{NWmodE-modF-1}}}\\plusendmoddef\nstatic void constraint_output(void* pself, netout_t* netout)\n\\{\n    constraint_t* self = (constraint_t*) pself;\n\n    netout_string        (netout, \"model\",     \"constraint\");\n    netout_int_matrix    (netout, \"node\",      self->node, 1, 2);\n    netout_int_matrix    (netout, \"vars\",      self->vars, 1, 9);\n\\}\n\n\\nwendcode{}\\nwbegindocs{50}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{51}\\sublabel{NWmodE-regF-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NWmodE-regF-2}}}\\moddef{register models~{\\nwtagstyle{}\\subpageref{NWmodE-regF-1}}}\\plusendmoddef\nmemset(&model, 0, sizeof(model));\nmodel.init         = constraint_init;\nmodel.set_position = constraint_set_position;\nmodel.vars         = constraint_vars;\nmodel.R            = constraint_R;\nmodel.dR           = constraint_dR;\nmodel.output       = constraint_output;\nmodel_mgr_add_element(model_mgr, \"constraint\", &model);\n\n\\nwendcode{}\n\n\\nwixlogsorted{c}{{$(Q(X-R))_1$}{NWmodE-$(QC-1}{\\nwixu{NWmodE-conK-1}\\nwixd{NWmodE-$(QC-1}}}%\n\\nwixlogsorted{c}{{$(Q(X-R))_2$}{NWmodE-$(QC.2-1}{\\nwixu{NWmodE-conK-1}\\nwixd{NWmodE-$(QC.2-1}}}%\n\\nwixlogsorted{c}{{contribute $C(x, y)$}{NWmodE-conK-1}{\\nwixd{NWmodE-conK-1}\\nwixu{NWmodE-modF-7}}}%\n\\nwixlogsorted{c}{{contribute $\\partial C / \\partial (r, \\omega)$}{NWmodE-**pk.2-1}{\\nwixd{NWmodE-**pk.2-1}\\nwixu{NWmodE-modF-8}}}%\n\\nwixlogsorted{c}{{contribute $\\partial C / \\partial (x, \\theta)$}{NWmodE-**pk-1}{\\nwixd{NWmodE-**pk-1}\\nwixu{NWmodE-modF-8}}}%\n\\nwixlogsorted{c}{{contribute $\\partial C^T \\lambda / \\partial (r, \\omega)$}{NWmodE-**pu.2-1}{\\nwixd{NWmodE-**pu.2-1}\\nwixu{NWmodE-modF-7}}}%\n\\nwixlogsorted{c}{{contribute $\\partial C^T \\lambda / \\partial (x, \\theta)$}{NWmodE-**pu-1}{\\nwixd{NWmodE-**pu-1}\\nwixu{NWmodE-modF-7}}}%\n\\nwixlogsorted{c}{{define locals for residual computation}{NWmodE-defc-1}{\\nwixd{NWmodE-defc-1}\\nwixu{NWmodE-modF-7}\\nwixu{NWmodE-modF-8}}}%\n\\nwixlogsorted{c}{{model functions}{NWmodE-modF-1}{\\nwixu{NWmodE-modD.2-1}\\nwixd{NWmodE-modF-1}\\nwixd{NWmodE-modF-2}\\nwixd{NWmodE-modF-3}\\nwixd{NWmodE-modF-4}\\nwixd{NWmodE-modF-5}\\nwixd{NWmodE-modF-6}\\nwixd{NWmodE-modF-7}\\nwixd{NWmodE-modF-8}\\nwixd{NWmodE-modF-9}}}%\n\\nwixlogsorted{c}{{model-rigid.c}{NWmodE-modD.2-1}{\\nwixd{NWmodE-modD.2-1}}}%\n\\nwixlogsorted{c}{{model-rigid.h}{NWmodE-modD-1}{\\nwixd{NWmodE-modD-1}}}%\n\\nwixlogsorted{c}{{$(\\partial Q(X-R) / \\partial \\omega)_1$}{NWmodE-**pd-1}{\\nwixu{NWmodE-**pk.2-1}\\nwixu{NWmodE-**pu.2-1}\\nwixd{NWmodE-**pd-1}}}%\n\\nwixlogsorted{c}{{$(\\partial Q(X-R) / \\partial \\omega)_2$}{NWmodE-**pd.2-1}{\\nwixu{NWmodE-**pk.2-1}\\nwixd{NWmodE-**pd.2-1}}}%\n\\nwixlogsorted{c}{{register models}{NWmodE-regF-1}{\\nwixu{NWmodE-regL-1}\\nwixd{NWmodE-regF-1}\\nwixd{NWmodE-regF-2}}}%\n\\nwixlogsorted{c}{{registration function}{NWmodE-regL-1}{\\nwixu{NWmodE-modD.2-1}\\nwixd{NWmodE-regL-1}}}%\n\\nwixlogsorted{c}{{types}{NWmodE-typ5-1}{\\nwixu{NWmodE-modD.2-1}\\nwixd{NWmodE-typ5-1}\\nwixd{NWmodE-typ5-2}}}%\n\\nwbegindocs{52}\\nwdocspar\n\\nwenddocs{}\n", "meta": {"hexsha": "57255705a88f559b585f3f705a3747f4459b0d10", "size": 20017, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sugar30/src/tex/model-rigid.tex", "max_stars_repo_name": "davidgarmire/sugar", "max_stars_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sugar30/src/tex/model-rigid.tex", "max_issues_repo_name": "davidgarmire/sugar", "max_issues_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sugar30/src/tex/model-rigid.tex", "max_forks_repo_name": "davidgarmire/sugar", "max_forks_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.09030837, "max_line_length": 266, "alphanum_fraction": 0.679622321, "num_tokens": 7513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.41257486559091594}}
{"text": "\\documentclass[../PHYS306Notes.tex]{subfiles}\n\n\\begin{document}\n\\section{Lecture 10}\n\\subsection{Lecture Notes - Intro to Coupled Oscillators}\n\\subsubsection{Analysis with Newtonian Mechanics}\n\\begin{center}\n    \\includegraphics[scale=0.5]{Lecture-10/w10-img1.png}\n\\end{center}\nA system of two coupled harmonic oscillators has spring constants $k$ (left spring), $k_{12}$ (middle spring) and $k$ (right spring). The displacements of the blocks are measured from equilibrium. The forces on the blocks are therefore given by:\n\\[F_1 = -kx_1 - k_{12}(x_1 - x_2)\\]\n\\[F_2 = -kx_2 - k_{12}(x_2 - x_1)\\]\nThe Lagrangian formulation gives the same result; see worksheet!\n\\end{document}", "meta": {"hexsha": "618671f4cd7a7dcd7c2ff3c59e913c457852f5df", "size": 675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-10/Lecture-Notes-10.tex", "max_stars_repo_name": "RioWeil/PHYS306-notes", "max_stars_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture-10/Lecture-Notes-10.tex", "max_issues_repo_name": "RioWeil/PHYS306-notes", "max_issues_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture-10/Lecture-Notes-10.tex", "max_forks_repo_name": "RioWeil/PHYS306-notes", "max_forks_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.2142857143, "max_line_length": 245, "alphanum_fraction": 0.7481481481, "num_tokens": 205, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341024983754, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4125748561346864}}
{"text": "\\documentclass[12pt, a4paper]\n{article}\n\n\\usepackage[margin=2cm]{geometry}\n\\usepackage{svg}\n\\setsvg{inkscape=inkscape -z -D,svgpath=images/}\n\\usepackage{float}\n\\usepackage{amsmath}\n\\usepackage{todonotes}\n\\usepackage{xspace}\n\\usepackage{booktabs}\n\\usepackage[]{algorithm2e}\n\n\n\\title{Pybricks motor control algorithms}\n\\author{The Pybricks authors}\n\n% Generic macros\n\\providecommand{\\lr}[1]{\\left(#1\\right)}\n\\providecommand{\\sub}[1]{_{\\text{#1}}}\n\\renewcommand{\\sup}[1]{^{\\text{#1}}}\n\n% omega symbols\n\\providecommand{\\w}{\\omega}\n\\providecommand{\\wt}{\\w^*}\n\\providecommand{\\wref}{\\w\\sub{ref}}\n\\providecommand{\\wmax}{\\w\\sub{max}}\n\n% theta symbols\n\\renewcommand{\\th}{\\theta}\n\\providecommand{\\thref}{\\th\\sub{ref}}\n\n% alpha symbols\n\\renewcommand{\\a}{\\alpha}\n\n% math\n\\providecommand{\\minab}[2]{\\min\\,\\lr{{#1},\\,\\,{#2}}}\n\\providecommand{\\abs}[1]{\\left|#1\\right|}\n\\providecommand{\\inlineadd}{\\,\\,+\\!\\!=\\,\\,}\n\\providecommand{\\inlinesubtract}{\\,\\,-\\!\\!=\\,\\,}\n\n%\n%\n% Begin Document\n%\n%\n\\begin{document}\n\\maketitle\n\n\\tableofcontents\n\\pagebreak\n\n\\section{Control system overview}\n\n\\begin{figure}[H]\n    \\centering\n    \\fontsize{8}{10}\\selectfont\n    \\includesvg[inkscapelatex=false,width=1\\textwidth]{control}\n    \\caption{\n        Control system overview.\n        \\label{fig:controloverview}}\n\\end{figure}\n\n\n\\section{Reference trajectories}\n\nWhen the user gives a motor command, we compute the reference trajectories for\nthe motor angle ($\\thref$) and angular velocity ($\\wref$) as a function of\ntime ($t$). These trajectories describe the ideal motion that would be followed\nif the motor is not subject to external loads or disturbances.\n\n\\subsection{Trajectory definition}\n\nFor a typical maneuver, the reference trajectories for $\\thref$ and $\\wref$\nare shown in Figure \\ref{fig:plots}. Initially, when the user executes the\ncommand at time $t_0$, the motor has a given initial angle $\\th_0$ and a given\ninitial angular velocity $\\w_0$. The motor accelerates with a magnitude\n$\\abs{\\a_0}$ until it reaches the user-specified target angular velocity $\\wt$\nat time $t_1$. The target speed is maintained until it begins decelerating at\ntime $t_2$, in order to stop precisely at $t_3$. During this maneuver, at the\ncorresponding times, the motor angle reference traverses from $\\th_0$ through\n$\\th_3$.\n\nThe reference trajectories $\\thref(t)$ and $\\wref(t)$ are uniquely specified by\nthe time instants $t_0$, $t_1$, $t_2$, $t_3$, the angles $\\th_0$, $\\th_1$,\n$\\th_2$, $\\th_3$, the initial velocity $\\w_0$, the target velocity $\\wt$, the\nfinal velocity $\\w_3$, the acceleration $\\a_0$ and deceleration $\\a_2$.\n\nDepending on which command is executed, we are given a subset of these\nparameters and we have to compute the dependent variables.\n\n\n\\begin{figure}[H]\n    \\centering\n    \\includesvg[width=0.9\\textwidth]{trajectory}\n    \\caption{\n        Reference velocity (top) and reference angle (bottom).\n        \\label{fig:plots}}\n\\end{figure}\n\n\nIf these parameters are known, the trajectories $\\wref(t)$ and $\\thref(t)$ are\ngiven by\n%\n\\begin{align}\n    \\label{eq:wref}\n    \\wref(t)&=\n    \\begin{cases}\n    \\w_0 & \\text{if} \\quad t = t_0\\\\ \n    \\w_0 + \\a_0(t-t_0) & \\text{if} \\quad t < t_1\\\\\n    \\w_1=\\w_2=\\wt  & \\text{if} \\quad t_1 \\leq t \\leq t_2\\\\\n    \\w_2 + \\a_2(t-t_2) & \\text{if}\\quad t_2 < t < t_3\\\\\n    \\w_3 & \\text{if} \\quad t = t_3\n    \\end{cases}\\\\[1em]\n    \\label{eq:thref}\n    \\thref(t)&=\n    \\begin{cases}\n        \\th_0 & \\text{if} \\quad t = t_0\\\\\n        \\th_0 + \\w_0(t-t_0) + \\dfrac{1}{2}\\a_0(t-t_0)^2 &\n            \\text{if} \\quad t_0 < t \\leq t_1\\\\\n        \\th_1 + \\w_1(t-t_1)  & \\text{if} \\quad t_1 < t \\leq t_2\\\\\n        \\th_2 +\\w_2(t-t_2)+\\dfrac{1}{2}\\a_2(t-t_2)^2 &\n            \\text{if}\\quad t_2 < t < t_3\\\\\n        \\th_3 & \\text{if} \\quad t = t_3\n    \\end{cases}\n\\end{align}\n\nSome parameters are known because they are measured or because they are\nspecified by the user, while others are to be computed from the known\nparameters. Which of the parameters are known depends on the user-specified\nmaneuver.\n\nIf the user specifies to rotate the motor for a certain duration with\n\\texttt{run\\_time(speed, duration)}, the final time $t_3=t_0+t\\sub{duration}$\nis known but we must compute the corresponding angle $\\th_3$. If instead the\nfinal angle $\\th_3$ is specified by the user command, we have to compute the\nfinal time $t_3$. This applies to \\texttt{run\\_target(speed, target)}, where\n$\\th_3=\\th\\sub{target}$. The following two sections provide the formulas to\ncompute the unknown parameters for both cases.\n\n\n\\begin{table}[H]\n    \\centering\n    \\caption{Overview of known and computed trajectory parameters}\n    \\label{tab:parameters}\n    \\begin{tabular}{@{}lllll@{}}\n    \\toprule\n                & Known    & Obtained from & Computed & Method \\\\\n                &          & user command  &          &        \\\\ \\midrule\n    Time-based  &\n        $t_0$, $\\th_0$, $\\w_0$ &\n        $\\abs{\\a_0}$, $\\abs{\\a_2}$, $\\wt$, $t_3$, $\\w_3$ &\n        $\\a_0$, $\\a_2$, $t_1$, $t_2$, $\\th_1$, $\\th_2$, $\\boldsymbol{\\th_3}$\n        & Section \\ref{sec:timebasedref}\\\\\n    Angle-based &\n        $t_0$, $\\th_0$, $\\w_0$ &\n        $\\abs{\\a_0}$, $\\abs{\\a_2}$, $\\wt$, $\\th_3$, $\\w_3$ &\n        $\\a_0$, $\\a_2$, $t_1$, $t_2$, $\\boldsymbol{t_3}$, $\\th_1$, $\\th_2$ &\n        Section \\ref{sec:anglebasedref}  \\\\\n        \\bottomrule\n    \\end{tabular}\n\\end{table}\n\nFor a typical single command, the final speed is always zero ($\\w_3 = 0$), in\nwhich case $\\th(t) \\equiv \\th_3$ for $t > t_3$. We will also allow the user to\nspecify $\\w_3 = \\wt$. This can be used to blend subsequent commands together\nwithout stopping.\n\n\n\\subsection{Calculating trajectory parameters given time target}\n\\label{sec:timebasedref}\nThis section derives the parameters in Table \\ref{tab:parameters} for a\ntime-based maneuver. Without loss of generality, we will assume that the\ntarget angular velocity is nonnegative:\n%\n\\begin{align}\n    \\label{eq:t:forwardmaneuver}\n    \\wt \\geq 0, \\quad \\w_3 \\in \\{0, \\wt\\}\n\\end{align}\n%\nIf it is not, we can mirror the inputs along the $\\w=0$ line, perform the\nfollowing computations, and mirror back the final result. This is discussed\nin Section \\ref{sec:t:reversing}.\n\nIn a time-based maneuver, we are only concerned with angular velocity control,\nwhile the final angle is arbitrary. In principle, this means we are only\nconcerned with tracking $\\wref(t)$ as shown in the top graph of\nFigure \\ref{fig:plots}. However, that graph depicts only one possible angular\nvelocity trajectory, for a particular set of parameters.\nFigure \\ref{fig:time} captures four possible types of angular velocity\nreference trajectories, which differ in initial speed compared to the\ntarget speed and final speed.\n\n\\begin{figure}[H]\n    \\centering\n    \\includesvg[width=0.8\\textwidth]{timebased}\n    \\caption{\n        Time-based motions with a duration of $t_3-t_0$ for various initial\n        conditions, with a stationary endpoint (left), or a nonzero final speed\n        (right). The trajectory is determined by the initial speed $\\w_0$,\n        which may be equal to or greater than the target $\\wt$ (blue),\n        or lower than the target (green). It could also be so low or high that\n        it will not be able to reach the target speed before completion\n        (orange and red).\\label{fig:time}}\n\\end{figure}\n\nBecause we allow only positive duration arguments, we have $t_3-t_0 > 0$ by\ndefinition. In order to ensure that the motor is able to reach $\\w_3$ at time\n$t_3$, the initial angular velocity must be bound by the gray area in Figure\n\\ref{fig:time}. The slope magnitude of the upper boundary equals the magnitude\nof the acceleration $\\abs{\\a_0}$ or deceleration $\\abs{\\a_2}$, whichever is\nlarger. The lower boundary slope corresponds to the acceleration magnitude\n$\\abs{\\a_0}$. We also limit the target speed such that it is able to\ndecelerate to the final speed with the given deceleration $\\a_2$. This gives\nthe constraints\n%\n\\begin{align}\n    -\\abs{\\a_0} \\lr{t_3-t_0} &\\leq \\w_0 \\leq \\max \\{\\abs{\\a_0}, \\abs{\\a_2}\\} \\lr{t_3-t_0} + \\w_3\\label{eq:t:timeboundary1}\\\\[1em]\n    0 &\\leq \\wt \\leq \\abs{\\a_2} \\lr{t_3-t_0} + \\w_3\\nonumber\n\\end{align}\n%\nIn all cases, the trajectory decelerates between $t_2$ and $t_3$, so that\n$\\a_2  = - \\abs{\\a_2} < 0$. The initial acceleration between $t_0$ and $t_1$\ndepends on the initial speed $\\w_0$ with respect to the \\mbox{target $\\wt$},\nwhich gives\n%\n\\begin{align}\n    \\label{eq:t:accel0}\n    \\a_0 &= \n        \\begin{cases}\n        \\phantom{-}\\abs{\\a_0} & \\text{if} \\quad \\w_0 < \\wt\\\\ \n        -\\abs{\\a_0} &  \\text{otherwise}\n        \\end{cases}\n\\end{align}\n%\nThe case of equality is handled intrinsically within the\nsecond case by ensuring that $\\a_0$ is never used if $\\w_0 = \\wt$.\n\n\n\\subsubsection{Standard case}\n\\label{sec:t:standard}\nThe first step is to accelerate or decelerate to reach the target speed $\\wt$.\nSolving for the intersection time $t_1$ gives:\n%\n\\begin{align}\n    \\label{eq:t:t1mt0:standard}\n    \\lr{t_1 - t_0}\\sub{standard} &= \\dfrac{\\wt-\\w_0}{\\a_0}\n\\end{align}\n%\nSimilarly, the time $t_2$ at which we start decelerating becomes defined by:\n%\n\\begin{align}\n    \\label{eq:t:t3mt2:standard}\n    \\lr{t_3 - t_2}\\sub{standard} &= \\dfrac{\\w_3-\\wt}{\\a_2}\\\\[1em]\n    \\label{eq:t:t2mt1:standard}\n    \\lr{t_2 - t_1}\\sub{standard} &=\n        (t_3-t_0) - \\lr{t_1 - t_0}\\sub{standard} - \\lr{t_3 - t_2}\\sub{standard}\n\\end{align}\n%\nSince the target speed is reached the constant speed value is simply\n\\begin{align}\n    \\lr{\\w_1}\\sub{standard} &= \\wt\n\\end{align}\n%\nThe result is valid if and only if $\\lr{t_2 - t_1}\\sub{standard}\\geq 0$.\nOtherwise, we resort to the cut-short case covered below.\n\n\\subsubsection{Cut short case}\n\\label{sec:t:cutshort}\nIf the initial velocity is too low or if the maneuver is too short to be able\nto reach the target velocity, it accelerates until it must begin to\ndecelerate, as shown by the first segment of the red line in Figure\n\\ref{fig:time}. Solving for the intersection time $t_1$\ngives:\n%\n\\begin{align}\n    \\label{eq:t:t1mt0:cutshort}\n    \\lr{t_1 - t_0}\\sub{cut short} &=\n        \\dfrac{\\w_3-\\w_0 - \\a_2(t_3-t_0)}{\\a_0-\\a_2}\n\\end{align}\n%\nThis result also applies if the initial acceleration is negative (orange line).\nZero division would occur if $\\a_2 = \\a_0$. Since $\\a_2 < 0$, this is a concern\nonly when $\\a_0 < 0$. However, this never happens since $\\a_2 = \\a_0 < 0$\nimplies that the standard case in Section \\ref{sec:t:standard} has a valid\nsolution.\n\nSimilarly, the time when we start decelerating ($t_2$) becomes defined by:\n%\n\\begin{align}\n    \\label{eq:t:t3mt2:cutshort}\n    \\lr{t_3 - t_2}\\sub{cut short} &= (t_3 - t_0) - (t_1 - t_0)\\sub{cut short}\n    \\\\[1em]\n    \\label{eq:t:t2mt1:cutshort}\n    \\lr{t_2 - t_1}\\sub{cut short} &= 0\n\\end{align}\n%\nWhen cut short, the target speed $\\wt$ is not reached but it peaks out at\n%\n\\begin{align}\n    \\lr{\\w_1}\\sub{cut short} &= \\w_0 + \\a_0(t_1 - t_0)\\sub{cut short}\n\\end{align}\n\n\\subsubsection{Cut short case with $\\w_3 = \\w_1$ and $\\a_0 > 0$}\n\\label{sec:t:cutshortw3}\n\nIf $\\w_3 = \\wt$ and $\\a_0 > 0$, there is only the increasing\nramp for the whole duration of the maneuver, indicated by the\nred line in the right graph of Figure \\ref{fig:time}, giving:\n%\n\\begin{align}\n    \\w_1 = \\w_3 := \\w_0 + \\a_0(t_3 - t_0)\n\\end{align}\n%\nand accordingly $t_3=t_2=t_1$.\n\n\n\n\n\\subsubsection{Reversing and unreversing the final and target speed}\n\n\\label{sec:t:reversing}\nThe aforementioned derivation assumes $\\wt \\geq \\w_3 \\geq 0$\n\\eqref{eq:t:forwardmaneuver} to reduce the number of (similar) cases that must\nbe accounted for. This section shows how to transform a given time based\nmaneuver to match this assumption, calculate the trajectory, and map the final\nresult back to obtain the originally requested command.\n\n\\begin{itemize}\n    \\item Cap $\\w_0$ and $\\wt$ using \\eqref{eq:t:timeboundary1}.\n    \\item Let the boolean $a := \\wt < 0$.\n    \\item If $a$, then invert all speeds: $\\w_0 := -\\w_0$, $\\wt := -\\wt$,\n        $\\w_3 := -\\w_3$.\n    \\item Calculate time and speed intersections using Sections \\ref{sec:t:standard}--\n    \\ref{sec:t:cutshortw3}.\n    \\item If $a$, then invert the results as shown in Section \\ref{sec:invert}.\n\\end{itemize}\n\n\n\\subsubsection{Intermediate angles (all cases)}\n\nHaving derived expressions to evaluate $t_1$, $t_2$, and $\\w_1$, the remaining\nparameters of Table \\ref{tab:parameters} to compute are the angles\n$\\th_1$, $\\th_2$, and $\\th_3$, which can be derived by integrating the\nangular velocity reference signal \\eqref{eq:thref}:\n% %\n\\begin{align}\n    \\label{eq:t:anglepar1}\n    \\th_1  &= \\th_0  + \\w_0(t_1-t_0)+\\dfrac{1}{2}\\a_0(t_1-t_0)^2\\\\\n    \\label{eq:t:anglepar2}\n    \\th_2&=\\th_1+ \\w_1(t_2-t_1)\\\\\n    \\label{eq:t:anglepar3}\n    \\th_3  &=\\th_2+ \\w_2(t_3-t_2)+\\dfrac{1}{2}\\a_2(t_3-t_2)^2    \n\\end{align}\n%\n\n\\subsection{Calculating trajectory parameters given angle target}\n\\label{sec:anglebasedref}\nThis section derives the parameters in Table \\ref{tab:parameters} for an\nangle-based maneuver. For simplicity of the derivation will assume that\nthe target angle  is greater than the initial angle. This\nmeans that the motor must move forward to reach its goal:\n%\n\\begin{align}\n    \\label{eq:a:forwardmaneuver}\n    \\th_3 &> \\th_0\\\\\n    \\wt &> 0\n\\end{align}\n%\nIf it is not, we can mirror the inputs along the $\\th_3$ line, perform the\nfollowing computations, and mirror back the final result. This is discussed\nin Section \\ref{sec:a:reversing}.\n\nIn an angle-based maneuver, the end time $t_3$ is arbitrary, so the trajectory\nis best analyzed in a ($\\th$, $\\w$) phase plot. This is shown in Figure\n\\ref{fig:positions} for various initial conditions indicated with blue dots.\nTo reduce the complexity of quadratic solutions on the microcontroller, we\nrestrict the final velocity to be either $\\w_3=0$ or $\\w_3=\\w_2=\\w_1$, implying\neither deceleration to zero or no deceleration at all. Possible end states are\nindicated with orange dots. In all cases $\\a_2 < 0$.\n\n\n\\begin{figure}[H]\n    \\centering\n    \\includesvg[width=1\\textwidth]{angbased}\n    \\caption{\n        Phase portrait of trajectory from different types of initial conditions\n        indicated with blue dots:\n        (a) nonnegative initial speed with a\n        sufficient distance from target to have a constant speed phase.\n        (b) Same as (a), except with negative initial speed.\n        (c) nonnegative initial speed without a constant speed phase because\n        the target is too close.\n        (d) Same as (c), except with negative initial speed.\n        \\label{fig:positions}}\n\\end{figure}\n\n\nThe typical trajectory is similar to case (a) and (c): The motor starts\nwith a nonnegative velocity, accelerates, optionally runs through a constant\nspeed phase, and then decelerates to standstill at the target.\nIf the initial speed is negative ($\\w_0 < 0$) as in initial conditions (b)\nand (d), the motor slows down and goes backwards in the process. Once the\nvelocity passes through zero, the remaining trajectory is just like case (a)\nand (c). For all trajectory types, it is convenient to define the common\nzero-speed angle $\\th_f$ as indicated\nwith green dots in Figure~\\ref{fig:positions}:\n%\n\\begin{align}\n    \\th_f = \\th_0 - \\dfrac{1}{2 \\a_0}\\w_0^2\n\\end{align}\n\nBecause we allow only positive speeds we have $\\th_3-\\th_0 > 0$ by\ndefinition. In order to ensure that the motor is able to reach $\\w_3$ at time\n$t_3$, the initial angular velocity must be bound by the gray area in Figure\n\\ref{fig:positions}. The upper boundary corresponds to the maximum speed\nwe can be at initially and still decelerate to the target angle on time.\n\nIn particular, we restrict the initial speed to the value from which we can\ndecelerate with either $\\abs{\\a_0}$ or $\\abs{\\a_2}$, whichever is larger.\nThere is no need for a negative lower bound. To see this, consider cases (b)\nand (d) in Figure~\\ref{fig:positions}: a negative initial speed makes it move\nfarther from the target angle, eliminating the risk of overshooting it. This\ngives the constraint:\n%\n\\begin{align}\n    \\w_0 \\leq \\sqrt{\\w_3^2 + 2 \\max\\{ \\abs{\\a_0}, \\abs{\\a_2}\\}\\lr{\\th_3-\\th_0}}\n\\end{align}\n%\nLikewise, we bind the strictly positive target speed to a value from which we\ncan still decelerate to the final speed with the given deceleration\n$\\abs{\\a_2}$:\n%\n\\begin{align}\n    0 < \\wt \\leq \\sqrt{\\w_3^2 + 2\\abs{\\a_2}\\lr{\\th_3-\\th_0}}\n\\end{align}\n%\n\nIn all cases, the trajectory decelerates between $t_2$ and $t_3$, so that\n$\\a_2  = - \\abs{\\a_2} < 0$. The initial acceleration between $t_0$ and $t_1$\ndepends on the initial speed $\\w_0$ with respect to the \\mbox{target $\\wt$},\nwhich gives\n%\n\\begin{align}\n    \\label{eq:a:accel0}\n    \\a_0 &= \n        \\begin{cases}\n        \\phantom{-}\\abs{\\a_0} & \\text{if} \\quad \\w_0 < \\wt\\\\ \n        -\\abs{\\a_0} &  \\text{otherwise}\n        \\end{cases}\n\\end{align}\n%\nThe case of equality is handled intrinsically within the\nsecond case by ensuring that $\\a_0$ is never used if $\\w_0 = \\wt$.\n\n\n\n\\subsubsection{Standard case with $\\w_3 \\in \\{0, \\wt\\}$}\n\\label{sec:a:standard}\nIn the standard maneuver, it accelerates or decelerates\nuntil it reaches the target speed $\\w_1$, as shown for cases (a), (b), (c),\n(d), and (e) in Figure \\ref{fig:positions}. \nSolving for the intersection with $\\wt$ gives:\n%\n\\begin{align}\n    \\label{eq:a:t1mt0:standard}\n    \\lr{\\th_1}\\sub{standard} &= \\th_f  + \\dfrac{1}{2\\a_0}(\\wt)^2\\\\[1em]\n    \\lr{\\th_2}\\sub{standard} &= \\th_3  + \\dfrac{1}{2\\a_2}\\lr{(\\wt)^2 - \\w_3^2}\n\\end{align}\n%\n%\nSince the target speed is reached the constant speed value is simply\n\\begin{align}\n    \\lr{\\w_1}\\sub{standard} &= \\wt\n\\end{align}\n%\nThe standard case is valid if and only if:\n\\begin{align}\n    \\label{eq:a:t1mt0:standardvalidity}\n    \\lr{\\th_1}\\sub{standard} &< \\lr{\\th_2}\\sub{standard}\n\\end{align}\n%\nOtherwise, we have to evaluate the cut-short case.\n%\n\n\\subsubsection{Cut short case with $\\w_3 = 0$}\n\\label{sec:a:cutshortw3is0}\nIf initial velocity is too low or if the\nmaneuver is too short to be able to reach the target velocity, it accelerates\nuntil it must begin to decelerate, as in cases (c) and (d) in\nFigure \\ref{fig:positions}.\nSolving for the intersection angle $\\th_1=\\th_2$ for $\\w_1=\\w_2$ gives:\n%\n\\begin{align}\n    \\label{eq:a:cutshort}\n    \\lr{\\th_1}\\sub{cut short} &= \\lr{\\th_2}\\sub{cut short}\\\\[1em]\n    \\dfrac{1}{2\\a_0}\\w_1^2 + \\th_f  &= \\th_3 + \\dfrac{1}{2\\a_2} \\w_1^2 \n\\end{align}\n%\nwhich can be solved for $\\w_1$ as:\n%\n\\begin{align}\n    \\label{eq:a:cutshortsolve}\n    \\w_1^2 = 2 \\dfrac{\\a_0\\a_2}{\\a_2-\\a_0}\\lr{\\th_3 - \\th_f}\n\\end{align}\n%\nfrom which $\\th_1=\\th_2$ follow via \\eqref{eq:a:cutshort}.\n%\nWhen cut short, the target speed $\\wt$ is not reached but the\npeak $\\w_1 \\geq 0$ can be obtained as the square root\nof \\eqref{eq:a:cutshortsolve}.\n%\n\\subsubsection{Cut short case with $\\w_3 = \\w_1$ and $\\a_0 > 0$}\n\\label{sec:a:cutshortw3isw1}\n\nIf $\\a_0 > 0$ and there is no deceleration phase but we still can't reach the\ntarget speed, we have $\\w_3=\\w_1 < \\wt$ with $\\th_1=\\th_2=\\th_3$:\n%\n\\begin{align}\n    \\label{eq:a:cutshortw1}\n    \\w_1^2  &= 2\\a_0\\lr{\\th_3 - \\th_f}\n\\end{align}\n\n\\subsubsection{Reversing and unreversing the final and target speed}\n\\label{sec:a:reversing}\nThe aforementioned derivation assumes $\\th_3 > \\th_0$ and so $\\wt > 0$ to\nreduce the number of (similar) cases that must be accounted for. This section\nshows how to transform a given angle based maneuver to match this assumption,\ncalculate the trajectory, and map the final result back to obtain the\noriginally requested command.\n\n\\begin{itemize}\n    \\item Let the boolean $a := \\th_3 < \\th_0$.\n    \\item If $a$, then invert targets as:\n          $\\th_3 := 2 \\th_0 - \\th_3$, $\\wt := -\\wt$, $\\w_0 := -\\w_0$,\n          $\\w_3 := -\\w_3$.\n    \\item Calculate angle and speed intersections using\n          Sections \\ref{sec:a:standard}--\\ref{sec:a:cutshortw3isw1}.\n    \\item If $a$, then reverse results using Section \\ref{sec:invert}.\n\\end{itemize}\n\n\n\\subsubsection{Intermediate times (all cases)}\n\nHaving derived expressions to evaluate $\\th_1$, $\\th_2$, and $\\w_1$, the\nremaining parameters of Table \\ref{tab:parameters} to compute are the times\n$t_1$, $t_2$, and $t_3$:\n%\n\\begin{align}\n    t_1 - t_0 &= \\dfrac{\\w_1-\\w_0}{\\a_0}\\\\[1em]\n    t_2 - t_1 &= \\dfrac{\\th_2-\\th_1}{\\w_1}\\\\[1em]\n    t_3 - t_2 &= \\dfrac{\\w_3-\\w_1}{\\a_2}\n\\end{align}\n\n\\subsection{Making a stationary trajectory}\n\\label{sec:stationary}\nFor a stationary hold trajectory, we have:\n%\n\\begin{align}\n    t_3 = t_2 = t_1 = t_0 \\\\[1em]\n    \\th_3 = \\th_2 = \\th_1 = \\th_0 \\\\[1em]\n    \\w_1 = \\w_0 = 0 \\\\[1em]\n    \\a_0 = \\a_2 = 0\n\\end{align}\n\n\n\\subsection{Reversing a trajectory}\n\\label{sec:invert}\nIn Sections \\ref{sec:timebasedref} and \\ref{sec:anglebasedref} several\nassumptions were made to ensure that the calculated trajectory is always\nforwards with $\\wt > 0$. If the original target speed was negative, the\nnewly computed maneuver can be reversed as follows:\n%\n\\begin{align}\n    \\th_1 &:= 2 \\th_0 - \\th_1\\\\[1em]\n    \\th_2 &:= 2 \\th_0 - \\th_2\\\\[1em]\n    \\th_3 &:= 2 \\th_0 - \\th_3\\\\[1em]\n    \\w_0 &:= -\\w_0\\\\[1em]\n    \\w_1 &:= -\\w_1\\\\[1em]\n    \\a_0 &:= -\\a_0\\\\[1em]\n    \\a_2 &:= -\\a_2\n\\end{align}\n\n\\subsection{Stretching trajectories for synchronization}\n\nIn some applications, two or more separate trajectories are executed in\nparallel to synchronize their movements. Typically, each trajectory has its own\ntarget angle $\\th_3$. To make them run in parallel, we slow down the shorter\nmaneuvers such that they take as long as the longest maneuver. For this\nanalysis, let the trajectory with superscript $0$ take the longest, so that\n%\n\\begin{align}\n    t^0_3 - t^0_0 \\geq t^i_3 - t^i_0  \\quad \\forall \\quad i\n\\end{align}\n\nFor synchronization we require that for all other trajectories $i$ we have:\n%\n\\begin{align}\n    t^i_1 &= t^0_1=t_1\\\\[1em]\n    t^i_2 &= t^0_2=t_2\\\\[1em]\n    t^i_3 &= t^0_3=t_3\n\\end{align}\n%\nEach trajectory still has to reach its own target $\\th^i_3$.\nUsing (\\ref{eq:t:anglepar1}--\\ref{eq:t:anglepar3}) this gives the constraint:\n%\n\\begin{align}\n    \\label{eq:stretchconstraint1}\n    \\th^i_3 - \\th^i_0  &=  \\w^i_0(t_1-t_0)+\\dfrac{1}{2}\\a^i_0(t_1-t_0)^2+\n        \\w^i_1(t_2-t_1)+ \\w^i_1(t_3-t_2)+\\dfrac{1}{2}\\a^i_2(t_3-t_2)^2    \n\\end{align}\n%\nLikewise, each trajectory has to reach its top speed $\\w^i_1$ and its final\nspeed $\\w^i_3$ in the same time spans as the longest maneuver, which gives the\ntwo additional constraints:\n%\n\\begin{align}\n    \\label{eq:stretchconstraint2}\n    \\a^i_0 &= \\dfrac{\\w^i_1-\\w_0^i}{t_1 - t_0}\\\\[1em]\n    \\label{eq:stretchconstraint3}\n    \\a_2^i &= \\dfrac{\\w_3^i-\\w_1^i}{t_3 - t_2}\n\\end{align}\n%\nWith three constraints we can solve for the three unknowns $\\a^i_0$, $\\a^i_1$.\nand $\\w^i_1$. To do so, solve for $\\w^i_1$ by substituting\n\\eqref{eq:stretchconstraint2}, \\eqref{eq:stretchconstraint3} into\n\\eqref{eq:stretchconstraint1}:\n%\n\\begin{align}\n    \\label{eq:stretchconstraintsolved}\n    \\w^i_1 = \\dfrac{2\\lr{\\th_3^i-\\th_0^i}-\\w_0^i\\lr{t_1-t_0} -\n    \\w_3^i\\lr{t_3-t_2}}{t_3-t_0 + t_2 - t_1}\n\\end{align}\n%\nSince $t_2 - t_1 \\geq 0$, zero division is avoided if $t_3 - t_0 > 0$. If $t_3\n- t_0 = 0$, then we have a stationary trajectory as per Section\n\\ref{sec:stationary}. If $\\w_3^i$ was nonzero, it needs to be lowered\ntoo as $\\w_3^i := \\w_1^i$.\n\nOnce $\\w^i_1$ is known, $\\a^i_0$, $\\a^i_1$ follow directly from\n\\eqref{eq:stretchconstraint2}, \\eqref{eq:stretchconstraint3}. Zero division is\navoided because $\\a^i_0$ is undefined (not used) when $t_1 = t_0$ and $\\a^i_2$\nis undefined (not used) when $t_3 = t_2$. The intermediate angles $\\th_1^i$\nand $\\th_2^i$ can be obtained from\n(\\ref{eq:t:anglepar1}--\\ref{eq:t:anglepar2}).\n\n\\end{document}\n", "meta": {"hexsha": "6f2ec413f08a9ecd63db129007fe027cb7dc91da", "size": 23566, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/pbio/doc/control/control.tex", "max_stars_repo_name": "Novakasa/pybricks-micropython", "max_stars_repo_head_hexsha": "4cb036fdcdcf1240576efae772375a6b37e8a7ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/pbio/doc/control/control.tex", "max_issues_repo_name": "Novakasa/pybricks-micropython", "max_issues_repo_head_hexsha": "4cb036fdcdcf1240576efae772375a6b37e8a7ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/pbio/doc/control/control.tex", "max_forks_repo_name": "Novakasa/pybricks-micropython", "max_forks_repo_head_hexsha": "4cb036fdcdcf1240576efae772375a6b37e8a7ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3672839506, "max_line_length": 129, "alphanum_fraction": 0.6834846813, "num_tokens": 7942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665855647394, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4124712441929314}}
{"text": "%\\documentclass[12pt,onecolumn]{report}\n%\\usepackage{amssymb, amsmath, amsthm,graphicx,\n%paralist,algpseudocode,algorithm,cancel,url,color}\n%\\usepackage[margin=1in]{geometry}\n\n\\documentclass[11pt]{article}\n%\\usepackage{amsmath, amssymb, amsthm, fullpage, algorithm,\n%  algorithmic, hyperref}\n\n\\newcommand\\numberthis{\\addtocounter{equation}{1}\\tag{\\theequation}}\n\n\n\\input{arxiv_style}\n\\input{macros}\n\\input{ayush}\n\n\\bibliographystyle{alpha}\n\n\n%\\usepackage{sectsty}\n%\\usepackage{fancyvrb}\n%\\usepackage{mathrsfs}\n%\\usepackage{multirow}\n%\\usepackage{hhline}\n%\\usepackage{booktabs}\n%\\usepackage[table]{xcolor}\n%\\usepackage{tikz}\n%\\usepackage{amssymb}\n%\\usepackage{amsmath}\n%\\usepackage{dsfont}\n%\\usepackage{enumitem}\n%\\usepackage{amsmath}\n%\\usepackage{amsfonts}\n%\\usepackage{mathtools}\n%\\theoremstyle{definition}\n%\n%\\newtheorem{definition}{Definition}[section]\n%\\newtheorem{theorem}{Theorem}[section]\n%\\newtheorem{lemma}[theorem]{Lemma}\n%\\newtheorem{corollary}{Corollary}[theorem]\n\n\\title{Concentration Inequalities II: Bernstein, Freedman, Martingale Methods  and Applications}\n\\author{Presenter: Seth Strimas-Mackey \\\\ Scribe: Leo Huang}\n\\date{1st March 2019}\n\n\\begin{document}\n\n\\maketitle\n\n\\subsubsection*{Topics Covered}\n\\begin{itemize}\n  \\item Sub-Gaussian/Sub-Exponential Random Variables\n  \\item Bernstein's Inequality (3 types)\n  \\item Johnson-Lindenstrauss (JL) Lemma\n\\end{itemize}\n\n\\section{Sub-Gaussian Random Variables}\n\\begin{definition}[Sub-Gaussian Random Variable]\nA random variable $X$, with $\\mathbb{E}[X]=0$, is Sub-Gaussian with variance proxy $\\sigma^2$, i.e., $X \\sim \\text{subG}(\\sigma^2)$ if $$\\mathbb{E}e^{sX}\\le e^{s^2\\sigma^2/2}~~\\forall s\\in \\mathbb{R}$$.\n\\end{definition}\n\n\\begin{theorem}[Sub-Gaussian Hoeffding]\nLet $X_1, ...X_n\\sim \\text{subG}(\\sigma^2)$ be independent, with $\\mathbb{E}[X]=0$. Then\n\\[P(\\frac{1}{n}\\sum_{i=1}^nX_i\\ge t)\\le e^{-nt^2/2\\sigma^2}\\]\nIn the bounded Case: $|X_i|\\le k, \\sigma^2 \\leq k^2$\n\\end{theorem}\n\\begin{proof}\nLet $\\overline(X) = \\frac{1}{n}\\sum_{i=1}^n X_i$. Then, \n\\begin{align*}\n    P(\\overline{X}>t) &\\le e^{-st}\\mathbb{E}[e^{s}\\overline{X}]\n    \\\\ & = e^{-st}(\\mathbb{E}[e^{sX_i}/n])^n \n    \\\\&\\le e^{-st}(e^{s^2\\sigma^2/2n^2})^n \\\\& = e^{-st+s^2\\sigma^2/2n} \n\\end{align*}\nSetting $s = \\frac{nt}{\\sigma^2}$ minimizes the exponent, so that we have \n\\[P(\\overline{X}>t)\\le e^{-\\frac{nt^2}{2\\sigma^2}}\\]\n\\end{proof}\n\nAs an example, one can observe that for $n=1$, $P(X\\ge t)\\le e^{-t^2/2\\sigma^2}$. Sub-Gaussian random variables have Gaussian like tails.\n\n\\section{Sub-exponential Random Variables} \nThis class of random variables is similar to sub-Gaussian random variables, but have heavier exponential tails. \n\n\\paragraph{Example}\nConsider Laplace(1), with $f_X(x)=\\frac{1}{2}e^{-|x|}$ for $x \\in \\mathbb{R}$. Then, $P(|x|\\ge t)=e^{-t}$, and clearly, $X$ is not subG($\\sigma^2$) for any $\\sigma$. \n\nBut for small s, i.e., $|s| < \\frac{1}{2}$, $\\mathbb{E}[e^{sX}]=\\frac{1}{1-s^2} \\leq e^{2s^2}$, which is bounded by a sub-Gaussian moment generating function. Thus, the random variable behaves like sub-gaussian for small $s$, but not as $s$ gets larger. It turns out that this is more general.\n\n\\begin{lemma} $\\mathbb{E}[X]=0, \\mathbb{P}(|x|>t)\\le 2e^{-t/\\lambda}, \\lambda>0\\implies \\mathbb{E}[|x|^k]\\le 2 \\lambda^k k!$ and $ \\mathbb{E}[e^{sX}]\\le e^{2s^2\\lambda^2}$.\n\\end{lemma}\n\nThis lemma is used to prove bound on all moments of $X$. The\nfirst step is to write $\\mathbb{E}[|X|^k]=\\int_{0}^\\infty P(|x|^k>t)\\,dt$. The second step is to Taylor expand and use the bound on $\\mathbb{E}[|X|^k]$. \n\nThis motivates an equivalent definition using moment generating functions.\n\n\n\n\\begin{definition}(Sub-Exponential Random Variables)\nA random variable $X$, with $\\mathbb{E}[X]=0$, is Sub-Exponential with parameter $\\lambda$, i.e., $X \\in \\text{subE}(\\lambda)$,  if $\\mathbb{E}[e^{sX}]\\le e^{s^2\\lambda^2/2},~~\\forall ~|s|\\le \\frac{1}{\\lambda}$.\n\\end{definition}\n\n\\section{Bernstein's Inequality}\n\\subsection{Bernstein's Inequality I}\n\\begin{theorem}\nLet $X_1, ...X_n\\sim \\text{subE}(\\lambda)$ be independent random variables with $\\mathbb{E}[X]=0$. Then, \n\\[P(\\frac{1}{n}\\sum_{i=1}^n X_i>t)\\le \\exp\\left(-\\frac{n}{2}\\left(\\frac{t^2}{\\lambda^2}\\wedge \\frac{t}{\\lambda}\\right)\\right)\\]\n\\end{theorem}\n\n\\begin{proof}\n\\begin{align*}\nP\\left(\\frac{1}{n}\\sum_{i=1}^n X_i>t\\right)\\le e^{-snt}\\prod_{i=1}^n \\mathbb{E}[e^{sX_i}]\\le e^{-snt}e^{ns^2\\lambda^2/2}=\\exp(-snt+ns^2\\lambda^2/2)=\\exp\\prn*{-\\frac{n}{2} \\prn*{\\frac{t^2}{\\lambda^2}\\wedge \\frac{t}{\\lambda}}}\n\\end{align*}\nIf, $\\abs*{t} \\leq \\lambda^2$, optimizer $s$, otherwise set $S = \\frac{1}{\\lambda}$.\n\n%Optimize, $s=\\frac{t}{}$ if $|t|\\le 1, s=1$, else $s=t\\wedge 1$.\n\\end{proof}\n\n%Normalize by $\\frac{1}{\\sqrt{n}}$. Then \n%\\[P(\\frac{1}{\\sqrt{n}}\\sum_{i=1}^n X_i > t ) \\le \\begin{cases}e^{-t^2/2\\lambda^2} & |t|<\\lambda \\sqrt{n}\\\\ e^{-t\\sqrt{n}/2\\lambda} & |t|\\ge \\lambda \\sqrt{n}\\end{cases}\n%\\]\n\n\\begin{lemma} \\label{lem: subgaussian_to_subexponential}\n Let $X\\sim \\text{subG}(\\sigma^2)$. Consider $Z=X^2-\\mathbb{E}[X^2]$. Then $Z\\sim \\text{subE}[16\\sigma^2]$. \n\\end{lemma}\n \\begin{proof}{(informal)}\n \\begin{align*}\nP(|x|>t) &\\le 2e^{-ct^2}\\\\\n\\intertext{implies,} P(X^2>t) &\\le 2e^{-ct^2} \\\\ \n\\intertext{implies,}\nP(X^2>t) &\\le 2e^{-ct}.\n\\end{align*}\n\\end{proof}\n\nFor bounded RV, we can get stronger version of Bernstein's Inequality, with smooth transition from regime to regime.\n\n\\subsection{Bernstein's Inequality II}\n\\textbf{Theorem}\nConsider $X_1, ..., X_n$ with $\\mathbb{E}[X_i]=0, \\mathbb{E}[X_i^2]=\\sigma^2$ and $|X_i|\\le K$. Then \n\\[P\\left(\\frac{1}{n}\\sum_{i=1}^n X_i>t\\right)\\le \\exp\\left(\\frac{-nt^2/2}{\\sigma^2+Kt/3}\\right)\\]\n\n\n\\begin{proof}\nUsing the standard Chernoff method, \n\\begin{align}\nP\\left(\\frac{1}{n}\\sum_{i=1}^n X_i>t\\right) &\\le \\frac{\\mathbb{E} \\left[ e^{ s \\frac{\\sum_{i=1}^n X_i}{n}} \\right]}{e^{st}} \\notag \\\\\n&= e^{-st} \\prod_{i=1}^n \\mathbb{E} \\left[e^{s \\frac{X_i}{n} } \\right] \\label{eq:bernstein_at_chernoff}\n\\end{align}\nNote that if $|s|<\\frac{3n}{k}$, then $|s \\frac{X_i}{n}|\\le 3$, and thus using lemma \\ref{lem:bernstein_algebraic}\n\\begin{align*}\n\\mathbb{E}[e^{s\\frac{X_i}{n}}]&\\le 1+ \\frac{s}{n}\\mathbb{E}[X_i]+\\mathbb{E}\\left[ \\frac{\\frac{s^2X^2_i}{2n^2}}{1-\\frac{|s||X_i|}{3n}}\\right] \\\\\n\t\t\t\t\t   &\\le 1 + \\mathbb{E}\\left[\\frac{\\frac{s^2X^2_i}{2n^2}}{1-\\frac{|s|K}{3n}}\\right]  \\\\\n\t\t\t\t\t   &\\leq 1 + \\frac{\\frac{s^2\\sigma^2}{2n^2}}{1-\\frac{|s|K}{3n}} \\\\\n\t\t\t\t\t   &\\leq \\exp\\left(\\frac{\\frac{s^2\\sigma^2}{2n^2}}{1-\\frac{|s|K}{3n}}\\right)  \\numberthis \\label{eq:mgf_bound}\n\t\t\t\t\t   %&\\le \\exp\\left(\\frac{s^2\\sigma^2/2}{1-|s|K/3}\\right)\n\\end{align*}\n\nUsing this back in Equation \\ref{eq:bernstein_at_chernoff}, we get:\n\\begin{align*}\nP\\left(\\frac{1}{n}\\sum_{i=1}^n X_i>t\\right) &\\le \\exp\\left(  \\frac{\\frac{s^2\\sigma^2}{2n}}{1-\\frac{|s|K}{3n}} - st \\right)\n\\intertext{Choosing $s=\\frac{nt}{\\sigma^2+tK/3}$}\n&\\leq \\exp\\left(\\frac{-nt^2}{2(\\sigma^2 + \\frac{tK}{3})}\\right)\n\\end{align*}\n\\end{proof}\n\n\\paragraph{Comparison to Hoeffding's inequality for Bounded Random variables}\nFor the same failure probability $\\delta$, Bernstein's inequality allows with probability at-least $1 - \\delta$, \n\\begin{align*}\n\t\\frac{\\sum_{i=1}^n X_i}{n} \\leq \\mathbb{E} [X] + O \\left( \\frac{\\sigma}{\\sqrt{n}} + \\frac{K}{n} \\right)\n\\end{align*}\n\nwhereas, Hoeffding's inequality gives us\n\\begin{align*}\n\t\\frac{\\sum_{i=1}^n X_i}{n} \\leq \\mathbb{E} [X] + O \\left( \\frac{K}{\\sqrt{n}} \\right).\n\\end{align*}\n\nThus, for random variables for which $\\sigma << K$, Bernstein gives a tigher rate.\n\\begin{lemma} \\label{lem:bernstein_algebraic} For all $z \\in [-3, 3] $, \n\\[e^z\\le 1+z+\\frac{z^2/2}{1-|z|/3}\\] \\end{lemma}\n\\begin{proof} Proof by picture. Compare the two graphs.\n\\end{proof}\n\n\\subsubsection{An Application: Johnson Lindenstrauss Lemma}\nFor any two vectors $a, a' \\in \\bbR^p$, define the distance to be $\\nrm*{a - a'}_2^2$. The Johnson Lindenstrauss (JL) lemma deals with the following question.\n\n\\paragraph{Question}  Given a finite set of $n$ points, $A=\\{a_1, ...a_n\\}\\subset \\mathbb{R}^D$, with $D$ large. Can one find a $d < D$ such that there exists a linear mapping $f: \\bbR^D \\mapsto \\bbR^d$ that preserves distance upto an error $\\epsilon$, i.e., $f$ is an $\\epsilon-$isometry on $A\\subset \\mathbb{R}^D$, or,  \n$$(1-\\epsilon)\\|a-a'\\|^2\\le \\|f(a)-f(a')\\|^2 \\le (1+\\epsilon)\\|a-a'\\|^2 ~~ \\forall a, a'\\in A$$\n\nWe first show that such a mapping exists using the probabilistic method. Consider a random matrix $X \\in \\bbR^{d \\times D}$ such that for all $i\\in\\{1, ...d\\}, j\\in \\{1, ...D\\}$,  $X_{ij}$ is an independent random variable with $\\En \\brk*{X_{ij}}=0$ and $var(X_{ij})=1$ (for example normal gaussians).  Define the function $f: \\bbR^D \\mapsto \\bbR^d$ as $f(a) \\ldef{} \\frac{1}{\\sqrt{d}}Xa$, or for any $k \\in [d]$,  $f_k(a) = \\sum_{j=1}^d X_{ij} a_j$. Thus, we have:\n \n\n\\begin{align*}\\mathbb{E}[f_k^2(a)] &= \\frac{1}{d}\\sum_{j=1}^D a_j^2 \\mathbb{E}[X_{ij}^2] = \\|a\\|^2 \\\\\n\\mathbb{E}[\\|f(a)\\|^2] &= \\frac{1}{d} \\mathbb{E}\\sum_{k=1}^d f_k^2(a) = \\|a\\|^2\n\\end{align*}\n\nThis shows that $\\|\\alpha\\|^2$ is preserved by $f$ in expectation. The following theorem gives a condition on $d$ such that this also holds in high probability.\n\n\\begin{theorem}[JL lemma]\nLet $A\\subset \\mathbb{R}^D$ such that  $|A|=n$. Consider a matrix $X: \\bbR^D \\mapsto \\bbR^d$ such that for all $i \\in [d], j \\in [D], ~~ X_{ij} \\in  \\text{subG}(\\sigma^2)$ and is sampled independently. Then for any $\\epsilon, \\delta\\in(0, 1)$, if $d\\ge 100 \\frac{\\sigma^4}{\\epsilon^{2}}\\log(n/\\sqrt{\\delta})$, then with probability at-least $1 - \\delta$, the linear map defined by $f(a) \\ldef{} \\frac{1}{\\sqrt{d}} Xa$ is an $\\epsilon-$isometry on $A$, or more specifically, \n$$(1-\\epsilon)\\|a-a'\\|^2\\le \\|f(a)-f(a')\\|^2 \\le (1+\\epsilon)\\|a-a'\\|^2 ~~ \\forall a, a'\\in A$$\n\\end{theorem}\n\nBefore we provide a proof for the JL lemma, observe that the projection dimension $d$ is independent of the dimension $D$ of our feature vectors. \n\\begin{proof}\nDefine $T=\\{\\frac{a-a'}{\\|a-a'\\|}: a, a'\\in A, a\\ne a' \\}$. We first state the following fact, which is quite easy to prove, \n\n\\begin{fact}\n$f$ is a linear $\\epsilon-$isometry of A iff \\[\\left|\\|f(\\alpha)\\|^2-1\\right|\\le \\epsilon \\ \\ \\forall \\alpha\\in T\\]\n\\end{fact}\n\nWe will thus show that with probabilty at-least $1 - \\delta $, $\\left|\\|f(\\alpha)\\|^2-1\\right|\\le \\epsilon \\ \\ \\forall \\alpha\\in T$. Note that $|T|\\le {{n}\\choose{2}}\\le \\frac{n^2}{2}$, and $\\En \\brk*{f(\\alpha)} = 1$ $\\forall \\alpha \\in T$. First observe that $f_{i}(\\alpha)$ is $\\sigma^2$ sub-gaussian. \n\n\\begin{align*}\n\\mathbb{E}[e^{sf_i(\\alpha)}] &= \\mathbb{E}\\exp\\left(s\\sum_{j=1}^D \\alpha_j X_{ij}\\right) \\\\& = \\prod_{j=1}^D \\exp(s\\alpha_jX_{ij})\\\\&\\le \\exp(\\frac{s^2\\sigma^2}{2}  \\sum_{j=1}^D \\alpha_j^2 /\\|\\alpha\\|^2) \\\\ & = e^{s^2\\sigma^2/2}\n\\end{align*}\n\nUsing \\pref{lem: subgaussian_to_subexponential}, this implies that $f^2_i(\\alpha)\\sim \\text{subE}(16\\sigma^2)$. Thus, applying Bernstein's inequality, with $\\En \\brk*{f_i(\\alpha)} = 1 $  and taking a union bound over all $\\alpha \\in T$, \n\n\n\n Using the Bernstein's inequality in the regime $|t|\\le 16\\sigma^2$, \n \n \\begin{align*}\n P(\\sup_{\\alpha\\in T}\\left|\\sum_{i=1}^d  \\frac{f_i^2(\\alpha)}{d} -1\\right|\\ge \\epsilon)\\le 2 \\times \\frac{n^2}{2} \\exp(\\frac{-dt^2}{2 \\times16^2\\sigma^4}),\n\\intertext{Setting $t = \\sqrt{\\frac{512\\sigma^4\\log(n^2/\\delta)}{d}} ~~(\\leq 16 \\sigma^2)$, we get, }\nP\\left(\\sup_{\\alpha\\in T}\\left|\\|f(\\alpha)\\|^2-1\\right|\\ge \\sqrt{\\frac{512\\sigma^4\\log(n^2/d)}{d}} \\right )\\ge \\delta.\n \\end{align*}\nThus, our choice of $d$ suffices for  $\\epsilon$-isometry. \n\\end{proof}\n\n\\subsection{Berstein's Inequality III: Martingales}\n\n\\begin{theorem}[Freedman's Inequality]\nLet $X_1, ..., X_n$ be a bounded martingale difference sequence, i.e.,  $\\mathbb{E}[X_i|X_{i-1}]=0$ and  $|X_i|\\le K$. Define the martingale $S_i = \\sum_{j=1}^i X_i$. Additionally, define $\\En_{i-1}[S_1]$ to be the expectation w.r.t. $X_i$ while the random variables $X_1, \\ldots, X_i$ are fixed. Similarly, define $V_n = \\sum_{i=1}^n \\En_{i-1} \\brk*{X_i^2} $.Then, \n$$ P\\prn*{S_n>t \\text{ and } V_n\\le \\sigma^2} \\le \\exp\\left(\\frac{-t^2/2}{\\sigma^2+Kt/3}\\right) $$\n\\end{theorem}\n\n$E_{i-1}[S_i] = E_{i-1}[X_i]+S_{i-1}=S_{i-1}$. Let $V_n = \\sum_{i=1}^n \\mathbb{E}[X_i^2]$. Then \n\n\n\\begin{proof}(informal)\nPreviously, we saw $\\mathbb{E}[e^{\\lambda X_i}]\\le \\exp(\\mathbb{E}[X_i^2\\psi(\\lambda)])$, $\\psi(s) = \\frac{\\lambda^2/2}{1-|\\lambda|K/3}$ (see \\pref{eq:mgf_bound}). Repeat argument using $\\mathbb{E}_{i-1}$ instead of $\\mathbb{E}$ to show that $\\mathbb{E}_{i-1}e^{\\lambda X_i}\\le \\exp(\\mathbb{E}_{i-1}X_i^2\\psi(\\lambda))$. Then \n\n\\begin{align*}\n    P(S_n\\ge t, V_n\\le \\sigma^2) &= \\mathbb{E}1(e^{\\lambda S_n}\\ge e^{\\lambda t})1(V_n\\le \\sigma^2) \\\\& \\le e^{-\\lambda t}\\mathbb{E}[e^{\\lambda S_n}1(V_n\\le \\sigma^2)] \\\\&= e^{-\\lambda t}\\mathbb{E}[e^{\\lambda S_n-V_n\\psi(\\lambda)}e^{V_n\\psi(\\lambda)}1(V_n\\le \\sigma^2)] \\\\ &\\le e^{-\\lambda t+\\sigma^2 \\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_n-V_n\\psi(\\lambda)}1(V_n\\le \\sigma^2)]\n    \\\\&\\le e^{-\\lambda t+\\sigma^2 \\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_n -V_n\\psi(\\lambda)}] \n    \\\\&= e^{-\\lambda t +\\sigma^2\\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_{n-1}-V_{n-1}\\psi(\\lambda)-\\mathbb{E}_{n-1}[X_n]^2\\psi(\\lambda)}\\times e^{\\lambda X_n}]\\\\&= e^{-\\lambda t +\\sigma^2\\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_{n-1}-V_{n-1}\\psi(\\lambda)-\\mathbb{E}_{n-1}[X_n]^2\\psi(\\lambda)}\\times \\mathbb{E}_{n-1}[e^{\\lambda X_n}]]  \\\\& =\n    [e^{-\\lambda t +\\sigma^2 \\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_{n-1}-V_{n-1}\\psi(\\lambda)-\\mathbb{E}_{n-1}[X_n^2]\\psi(\\lambda)}\\times e^{\\mathbb{E}_{n-1}[X_n^2]\\psi(\\lambda)}]\n    \\\\& = e^{-\\lambda t+\\sigma^2 \\psi(\\lambda)}\\mathbb{E}[e^{\\lambda S_{n-1}-V_{n-1}\\psi(\\lambda)}]\\le ...\\le e^{-\\lambda t +\\sigma^2\\psi(\\lambda)} \n\\end{align*}\nOptimizing over $\\lambda$ gives the required tail bound.\n\\end{proof}\n\n\\nocite{*}\n{\\small\n\\bibliography{refs}\n}\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "5e1ccfb627990044456fa52c8947a1eaefe30913", "size": 13883, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "scribes/scribe_2/Meeting2_1_March.tex", "max_stars_repo_name": "sekhari/Concentration_Inequalities", "max_stars_repo_head_hexsha": "7f0625adbfc4ec841964f06969d73b8b8a671276", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "scribes/scribe_2/Meeting2_1_March.tex", "max_issues_repo_name": "sekhari/Concentration_Inequalities", "max_issues_repo_head_hexsha": "7f0625adbfc4ec841964f06969d73b8b8a671276", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scribes/scribe_2/Meeting2_1_March.tex", "max_forks_repo_name": "sekhari/Concentration_Inequalities", "max_forks_repo_head_hexsha": "7f0625adbfc4ec841964f06969d73b8b8a671276", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.9885496183, "max_line_length": 474, "alphanum_fraction": 0.6430166391, "num_tokens": 5572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073802837478, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.4124529449329196}}
{"text": "\\documentclass[../searching.tex]{subfiles}\n\\begin{document}\n% \\paragraph{refers} \n% \\url{https://tp-iiita.quora.com/The-Two-Pointer-Algorithm}\n\n\nThere are actually 50/900 problems on LeetCode are tagged as two pointers. Two pointer search algorithm are normally used to refer to searching that use two pointer in one for/while loop over the given data structure. Therefore, this part of algorithm gives linear performance as of $O(n)$. While, it does not refer to situation such as searching a pair of items in an array that sums up to a given target value, then two nested for loops are needed to search all the possible pairs. There are different ways to put these two pointers:\n\\begin{enumerate}\n    \\item Equi-directional:  Both start from the beginning: we have \\textbf{slow-faster pointer}, \\textbf{sliding window algorithm}.\n    \\item Opposite-directional: One at the start and the other at the end, they move close to each other and meet in the middle, (-> <-).\n\\end{enumerate}\nIn order to use two pointers, most times the data structure needs to be ordered in some way, and decrease the time complexity from $O(n^2)$ or $O(n^3)$ of two/three nested for/while loops to $O(n)$ of just one loop with two pointers and search each item just one time. In some cases, the time complexity is highly dependable on the data and the criteria we set. \n\nAs shown in Fig.~\\ref{fig:two pointer}, the pointer $i$ and $j$ can decide: a pair or a subarray (with all elements starts from i and end at j). We can either do search related with a pair or a subarray. For the case of subarray, the algorithm is called sliding window algorithm. As we can see, two pointers and sliding window algorithm can be used to solve K sum (Section~\\ref{}), most of the subarray (Section~\\ref{}), and string pattern match problems (Section~\\ref{}). \n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.9\\columnwidth]{fig/two_pointers.png}\n    \\caption{Two pointer Example}\n    \\label{fig:two pointer}\n\\end{figure}\n\nTwo pointer algorithm is less of a talk and more of problem attached. We will explain this type of algorithm in virtue of both the leetcode problems and definition of algorihtms. \n% \\subsection{Two Pointers Techniques}\nTo understand two pointers techniques, better to use examples, here we use two examples: use slow-faster pointer to find the median and Floyd's fast-slow pointer algorithm for loop detection in an array/linked list and two pointers to get two sum. \n\n\\subsection{Slow-fast Pointer} \n\\paragraph{Find middle node of linked list} The simpest example of slow-fast pointer application is to get the middle node of a given linked list. (LeetCode problem: 876. Middle of the Linked List)\n\\begin{lstlisting}[numbers=none]\nExample 1 (odd length):\n\nInput: [1,2,3,4,5]\nOutput: Node 3 from this list (Serialization: [3,4,5])\n\nExample 2 (even length):\n\nInput: [1,2,3,4,5,6]\nOutput: Node 4 from this list (Serialization: [4,5,6])\n\\end{lstlisting}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width = 0.8\\columnwidth]{fig/middle node of a given linked list.png}\n    \\caption{Slow-fast pointer to find middle}\n    \\label{fig:slow-faster}\n\\end{figure}\nWe place two pointers simultaneously at the head node, each one moves at different paces, the slow pointer moves one step and the fast moves two steps instead. When the fast pointer reached the end, the slow pointer will stop at the middle. For the loop, we only need to check on the faster pointer, make sure fast pointer and fast.next is not None, so that we can successfuly visit the fast.next.next. When the length is odd, fast pointer will point at the end node, because fast.next is None, when its even, fast pointer will point at None node, it terimates because fast is None. \n\\begin{lstlisting}[language=Python]\ndef middleNode(self, head):\n    slow, fast = head, head\n    while fast and fast.next:        \n        fast = fast.next.next\n        slow = slow.next     \n    return slow\n\\end{lstlisting}\n\n\\paragraph{Floyd's Cycle Detection (Floyd's Tortoise and Hare)} Given a linked list which has a cycle, as shown in Fig.~\\ref{fig:floyd_cycle}. To check the existence of the cycle is quite simple. We do exactly the same as traveling by the slow and fast pointer above, each at one and two steps. (LeetCode Problem: 141. Linked List Cycle). The  code is pretty much the same with the only difference been that after we change the fast and slow pointer, we check if they are the same node. If true, a cycle is detected, else not. \n\\begin{lstlisting}[language=Python]\ndef hasCycle(self, head):\n    slow = fast = head\n    while fast and fast.next:\n        slow = slow.next\n        fast = fast.next.next\n        if slow == fast:\n            return True\n    return False\n\\end{lstlisting}\n\nIn order to know the starting node of the cycle. Here, we set the distance of the starting node of the cycle from the head is $x$, and $y$ is the distance from the start node to the slow and fast pointer's node, and $z$ is the remaining distance from the meeting point to the start node. \n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{fig/TQoyH.png}\n    \\caption{Floyd's Cycle finding Algorithm}\n    \\label{fig:floyd_cycle}\n\\end{figure}\n\nNow, let's try to device the algorithm. Both slow and fast pointer starts at position 0, the node index they travel each step is: [0,1,2,3,...,k] and [0,2,4,6,...,2k] for slow and fast pointer respectively. Therefore, the total distance traveled by the slow pointer is half of the distance travelled by the fat pointer. From the above figure, we have the distance travelled by slow pointer to be $d_s = x+y$, and for the fast pointer $d_f = x+y+z+y = x+2y+z$. With the relation $2*d_s = d_f$. We will eventually get $x = z$. Therefore, by moving slow pointer to the start of the linked list after the meeting point, and making both slow and fast pointer to move one node at a time, they will meet at the starting node of the cycle. (LeetCode problem: 142. Linked List Cycle II (medium)).\n\\begin{lstlisting}[language=Python]\ndef detectCycle(self, head):\n    slow = fast = head\n    bCycle = False\n    while fast and fast.next:\n        slow = slow.next\n        fast = fast.next.next\n        if slow == fast: # a cycle is found\n            bCycle = True\n            break\n    \n    if not bCycle:\n        return None\n    # reset the slow pointer to find the starting node       \n    slow = head\n    while fast and slow != fast:\n        slow = slow.next\n        fast = fast.next\n    return slow\n\\end{lstlisting}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.6\\columnwidth]{fig/circularlinkedlist.png}\n    \\caption{One example to remove cycle}\n    \\label{fig:cycle_remove}\n\\end{figure}\nIn order to remove the cycle as shown in Fig.~\\ref{fig:cycle_remove}, the starting node is when slow and fast intersect, the last fast node before they meet. For the example, we need to set -4 node's next node to None. Therefore, we modify the above code to stop at the last fast node instead:\n\\begin{lstlisting}[language=Python]\n    # reset the slow pointer to find the starting node       \n    slow = head\n    while fast and slow.next != fast.next:\n        slow = slow.next\n        fast = fast.next\n    fast.next = None\n\\end{lstlisting}\n\n\n\\subsection{Opposite-directional Two pointer}\nTwo pointer is usually used for searching a pair in the array. There are cases the data is organized in a way that we can search all the result space by placing two pointers each at the start and rear of the array and move them to each other and eventually meet and terminate the search process. The search target should help us decide which pointer to move at that step.  This way, each item in the array is guaranteed to be visited at most one time by one of the two pointers, thus making the time complexity to be $O(n)$. Binary search used the technique of two pointers too, the left and right pointer together decides the current searching space, but it erase of half searching space at each step instead.\n\n\\paragraph{Two Sum - Input array is sorted} Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.  (LeetCode problem: 167. Two Sum II - Input array is sorted (easy).)\n\\begin{lstlisting}[numbers=none]\nInput: numbers = [2,7,11,15], target = 9\nOutput: [1,2]\nExplanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2.\n\\end{lstlisting}\n\nDue to the fact that the array is sorted which means in the array [s,s1 ..., e1, e], the sum of any two integer is in range of [s+s1, e1+e]. By placing two pointers each start from s and e, we started the search space from the middle of the possible range. [s+s1, s+e, e1+e].  Compare the target $t$ with the sum of the two pointers $v_1$ and $v_2$:\n\\begin{enumerate}\n    \\item  $t == v_1 + v_2$: found\n    \\item  $v_1+v_2 < t$: we need to move to the right side of the space, then we increase $v_1$ to get larger value.\n    \\item $v_1+v_2 > t$: we need to move to the left side of the space, then we decrease $v_2$ to get smaller value.\n\\end{enumerate}\n\\begin{lstlisting}[language=Python]\ndef twoSum(self, numbers, target):\n    #use two pointers\n    n = len(numbers)\n    i, j  = 0, n-1\n    while i < j:\n        temp = numbers[i] + numbers[j]\n        if temp == target:\n            return [i+1, j+1]\n        elif temp < target:\n            i += 1\n        else:\n            j -= 1\n    return []\n\\end{lstlisting}\n% T1: If you see in the problem that you can do comparison and it is always one type of satisfactory element is in ahead of the other, this could be resolved by two pointers (slower and faster). Note: when the while loop stops, is there operations you need?\n\n% Two pointers or three pointers are the most possible. \\textit{Two pointers or three pointers is a superset of the sliding window algorithm, prefix sum too.} It can lower the complexity by one power level of n. \n\n%%%%%%%%%%%%%%%%%%%%%%Sliding Window Algorithm%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Sliding Window Algorithm}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{fig/sliding1.png}\n    \\caption{Sliding Window Algorithm}\n    \\label{fig:slide_window}\n\\end{figure}\nGiven an array, imagine that we have a fixed size window as shown in Fig.~\\ref{fig:slide_window}, and we can slide it forward each time. If we are asked to compute the sum of each window, the bruteforce solution would be $O(kn)$ where k is the window size and n is the array size by using two nested for loops, one to set the starting point, and the other to compute the sum. A sliding window algorithm applied here used the property that the sum of the current window ($S_c$) can be computed from the last winodow ($S_l$) knowling the items that just slided out and moved in as $a_o$ and $a_i$. Then $S_c = S_l-a_o+a_i$. Not necessarily using sum, we generalize it as state, if we can compute $S_c$ from $S_l$, $a_o$ and $a_i$ in O(1), a function $S_c = f(S_l, a_o, a_i)$ then we name this \\textbf{sliding window property}. Therefore the time complexity will be decreased to $O(n)$. \n\\begin{lstlisting}[language=Python]\ndef fixedSlideWindow(A, k):\n    n = len(A)\n    if k >= n:\n        return sum(A)\n    # compute the first window\n    acc = sum(A[:k])\n    ans = acc\n    # slide the window\n    for i in range(n-k): # i is the start point of the window\n        j = i + k # j is the end point of the window\n        acc = acc - A[i] + A[j]\n        ans = max(ans, acc)\n    return ans\n\\end{lstlisting}\n\n\\paragraph{When to use sliding window} It is important to know when we can use sliding window algorithm, we summarize three important standards:\n\\begin{enumerate}\n    \\item It is a subarray/substring problem.\n    \\item \\textbf{sliding window property:}T he requirement of the sliding window satisfy the sliding window property.\n    \\item \\textbf{Completeness:} by moving the left and right pointer of the sliding window in a way that we can cover all the search space. Sliding window algorithm is about optimization problem, and by moving the left and right pointer we can search the whole searching space. \\textbf{Therefore, to testify that if applying the sliding window can cover the whole search space and guarentee the completeness decide if the method works.}\n\\end{enumerate}\n\nFor example, 644. Maximum Average Subarray II (hard) does not satisfy the completeness. Because the average of subarray does not follow a certain order that we can decided how to move the window. \n\n\\paragraph{Flexible Sliding Window Algorithm} Another form of sliding window where the window size is flexble, and it can be used to solve a lot of real problems related to subarray or substring that is conditioned on some pattern. Compared with the fixed size window, we can first fix the left pointer, and push the right pointer to enlarge the window in order to find a subarray satisfy a condition. Once the condition is met, we save the optimal result and shrink the window by moving the left pointer in a way that we can set up a new starting pointer to the window (shrink the window). At any point in time only one of these pointers move and the other one remains fixed.\n\n\n\\paragraph{Sliding Window Algorithm with Sum} In this part, we list two examples that we use flexible sliding window algorithms to solve subarray problem with sum condition. \n\nGiven an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum >= s. If there isn't one, return 0 instead. (LeetCode Problem: 209. Minimum Size Subarray Sum (medium)). \n\\begin{lstlisting}[numbers=none]\nExample: \n\nInput: s = 7, nums = [2,3,1,2,4,3]\nOutput: 2\nExplanation: the subarray [4,3] has the minimal length under the problem constraint.\n\\end{lstlisting}\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.5\\columnwidth]{fig/prefixsum.png}\n    \\caption{The array and the prefix sum}\n    \\label{fig:prefix_sum_array}\n\\end{figure}\nAs we have shown in Fig.~\\ref{fig:prefix_sum_array}, the prefix sum is the subarray starts with the first item in the array, we know that the sum of the subarray is monotonically increasing as the size of the subarray increase. Therefore, we place a 'window' with left and right as i and j at the first item first. The steps are as follows:\n\\begin{enumerate}\n    \\item Get the optimal subarray starts from current i, 0: Then we first move the j pointer to include enough items that sum[0:j+1]>=s, this is the process of getting the optimial subarray that starts with 0. And assume j stops at $e_0$\n    \\item Get the optimal subarray ends with current j, $e_0$: we shrink the window size by moving the i pointer forward so that we can get the optimal subarray that ends with current j and the optimal subarray starts from $s_0$. \n    \\item Now, we find the optimal solution for subproblem [0:i,0:j](the start point in range [0, i] and end point in range [0,j]. Starts from next i and j, and repeat step 1 and 2.\n\\end{enumerate}\n\nThe above process is a standard flexible window size algorithm, and it is a complete search which searched all the possible result space. Both j and i pointer moves at most n, it makes the total operations to be at most 2n, which we get time complexity as $O(n)$. \n\\begin{lstlisting}[language=Python]\ndef minSubArrayLen(self, s, nums):\n    ans = float('inf')\n    n = len(nums)\n    i = j = 0\n    acc = 0 # acc is the state\n    while j < n:\n        acc += nums[j]# increase the window size\n        while acc >= s:# shrink the window to get the optimal result\n            ans = min(ans, j-i+1)\n            acc -= nums[i]\n            i += 1\n        j +=1\n    return ans if ans != float('inf') else 0\n\\end{lstlisting}\n\\begin{bclogo}[couleur = blue!30, arrondi=0.1,logo=\\bccrayon,ombre=true]{What happens if there exists negative number in the array? } Sliding window algorithm will not work any more, because the sum of the subarray is no longer monotonically increase as the size increase. Instead (1) we can use prefix sum and organize them in order, and use binary search to find all posible start index.  (2) use monotone stack (see  LeetCode probelm: 325. Maximum Size Subarray Sum Equals k, 325. Maximum Size Subarray Sum Equals k (hard)))\n\\end{bclogo}\n\nMore similar problems:\n\\begin{enumerate}\n    \\item 674. Longest Continuous Increasing Subsequence (easy)\n\\end{enumerate}\n\n\\paragraph{Sliding Window Algorithm with Substring} For substring problems, to be able to use sldiing window, s[i,j] should be gained from s[i,j-1] and s[i-1,j-1] should be gained from s[i,j-1]. Given a string, find the length of the longest substring without repeating characters. (LeetCode Problem: 3. Longest Substring Without Repeating Characters (medium))\n\\begin{lstlisting}[numbers=none]\nExample 1:\n\nInput: \"abcabcbb\"\nOutput: 3 \nExplanation: The answer is \"abc\", with the length of 3. \n\nExample 2:\n\nInput: \"bbbbb\"\nOutput: 1\nExplanation: The answer is \"b\", with the length of 1.\n\\end{lstlisting}\n\nFirst, we know it is a substring problem. Second, it askes to find substring that only has unique chars, we can use hashmap to record the chars in current window, and this satisfy the sliding window property. When the current window violates the condition ( a repeating char), we shrink the window in a way to get rid of this char in the current window by moving the i pointer one step after this char. \n\\begin{lstlisting}[language=Python]\ndef lengthOfLongestSubstring(self, s):\n    if not s:\n        return 0\n    n = len(s)\n    state = set()\n    i = j = 0\n    ans = -float('inf')\n    while j < n:\n        if s[j] not in state:\n            state.add(s[j])\n            ans = max(ans, j-i)\n        else:\n            # shrink the window: get this char out of the window\n            while s[i] != s[j]: # find the char\n                state.remove(s[i])\n                i += 1\n            # skip this char\n            i += 1\n        j += 1\n    return ans if ans != -float('inf') else 0\n\\end{lstlisting}\n\nNow, let us see another example with string ang given a pattern to match. Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). (LeetCode Problem: 76. Minimum Window Substring (hard))\n\\begin{lstlisting}[numbers=none]\nExample:\n\nInput: S = \"ADOBECODEBANC\", T = \"ABC\"\nOutput: \"BANC\"\n\\end{lstlisting}\n\nIn this problem, the desirable window is one that has all characters from T. The solution is pretty intuitive. We keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest window till now. The only difference compared with the above problem is the definition of desirable: we need to compare the state of current window with the required state in T. They can be handled as a hashmap with character as key and frequency of characters as value. \n\\begin{lstlisting}[language=Python]\ndef minWindow(self, s, t):\n    dict_t = Counter(t)\n    state = Counter()\n    required = len(dict_t)\n\n    # left and right pointer\n    i, j = 0, 0\n\n    formed = 0\n    ans = float(\"inf\"), None # min len, and start pos\n\n    while j < len(s):\n        char = s[j]\n        # record current state\n        if char in dict_t:\n            state[char] += 1\n            if state[char] == dict_t[char]:\n                formed += 1\n\n        # Try and contract the window till the point where it ceases to be 'desirable'.\n        # bPrint = False\n        while i<=j and formed == required:\n            # if not bPrint:\n            #     print('found:', s[i:j+1], i, j)\n            #     bPrint = True\n            char = s[i]\n            if j-i+1 < ans[0]:\n                ans = j - i + 1, i\n            # change the state\n            if char in dict_t:\n                state[char] -= 1\n                if state[char] == dict_t[char]-1:\n                    formed -= 1\n\n            # Move the left pointer ahead,\n            i += 1    \n        \n        # Keep expanding the window \n        j += 1  \n        # if bPrint:\n        #     print('move to:', s[i:j+1], i, j)\n    return \"\" if ans[0] == float(\"inf\") else s[ans[1] : ans[1] + ans[0]]\n\\end{lstlisting}\n\nThe process would be:\n\\begin{lstlisting}[numbers=none]\nfound: ADOBEC 0 5\nmove to: DOBECO 1 6\nfound: DOBECODEBA 1 10\nmove to: ODEBAN 6 11\nfound: ODEBANC 6 12\nmove to: ANC 10 13\n\\end{lstlisting}\n\\paragraph{Three Pointers and Sliding  Window Algorithm}\nSometimes, by manipulating two pointers are not enough for us to get the final solution. \n\\begin{examples}\n\\item \\textbf{930. Binary Subarrays With Sum.} In an array A of 0s and 1s, how many non-empty subarrays have sum S?\n\\begin{lstlisting}[numbers=none]\nExample 1:\n\nInput: A = [1,0,1,0,1], S = 2\nOutput: 4\nExplanation: \nThe 4 subarrays are bolded below:\n[1,0,1,0,1]\n[1,0,1,0,1]\n[1,0,1,0,1]\n[1,0,1,0,1]\n\\end{lstlisting}\n\\textit{Note: A.length <= 30000, 0 <= S <= A.length, A[i] is either 0 or 1.}\n\nFor example in the following problem, if we want to use two pointers to solve the problem, we would find we miss the case; like in the example $1, 0, 1, 0, 1$, when $j = 5$, $i = 1$, the sum is $2$, but the algorithm would miss the case of $i = 2$, which has the same sum value.\n \nTo solve this problem, we keep another index $i_hi$, in addition to the moving rule of $i$, it also moves if the sum is satisfied and that value is $0$. This is actually a Three pointer algorithm, it is also a mutant sliding window algorithm. \n\\begin{lstlisting}[language=Python]\nclass Solution:\n    def numSubarraysWithSum(self, A, S):\n        i_lo, i_hi, j = 0, 0, 0 #i_lo <= j\n        sum_window = 0\n        ans = 0\n        while j < len(A):\n\n            sum_window += A[j]\n                                     \n            while i_lo < j and sum_window > S:\n                sum_window -= A[i_lo]\n                i_lo += 1\n            # up till here, it is standard sliding window\n            \n            # now set the extra pointer at the same location of the i_lo\n            i_hi = i_lo\n            while i_hi < j and sum_window == S and not A[i_hi]:\n                i_hi += 1\n            if sum_window == S:\n                ans += i_hi - i_lo + 1\n                            \n            j += 1 #increase the pointer at last so that we do not need to check if j<len again\n\n        return ans\n\\end{lstlisting}\n\\end{examples}\n\n\\paragraph{Summary} Sliding Window is a powerful tool for solving certain subarray/substring related problems. The normal situations where we use sliding window is summarized:\n\\begin{itemize}\n    \\item Subarray: for an array with numerical value, it requires all positive/negative values so that the prefix sum/product has monotonicity. \n    \\item Substring: for an array with char as value, it requires the state of each subarray does not related to the order of the characters (anagram-like state) so that we can have the sliding window property.\n\\end{itemize}\n\nThe steps of using sliding windows:\n\\begin{enumerate}\n    \\item Initialize the left and right pointer;\n    \\item Handle the right pointer and record the state of the current window;\n    \\item While the window is in the state of desirable: record the optimal solution, move the left pointer and record the state (change or stay unchanged).\n    \\item Up till here, the state is not desirable.  Move the right pointer in order to find a desirable window;\n\\end{enumerate}\n\\subsection{LeetCode Problems}\n\\paragraph{Sliding Window}\n\\begin{examples}\n\\item 76. Minimum Window Substring\n\\item 438. Find All Anagrams in a String\n\\item 30. Substring with Concatenation of All Words\n\\item 159. Longest Substring with At Most Two Distinct Characters\n\\item 567. Permutation in String\n\\item 340. Longest Substring with At Most K Distinct Characters\n\\item 424. Longest Repeating Character Replacement\n\\end{examples}\n\\end{document}", "meta": {"hexsha": "5d2e51df5de5fd06dd8b02f73f2e752f5742ed44", "size": 23945, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Easy-Book/chapters/mastering/learning/search/sliding_window.tex", "max_stars_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_stars_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Easy-Book/chapters/mastering/learning/search/sliding_window.tex", "max_issues_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_issues_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Easy-Book/chapters/mastering/learning/search/sliding_window.tex", "max_forks_repo_name": "stungkit/Algorithms-and-Coding-Interviews", "max_forks_repo_head_hexsha": "131199fea0b082d92c0f272a495c7a56a3242b71", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.8329238329, "max_line_length": 884, "alphanum_fraction": 0.7039465442, "num_tokens": 6220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.4124529338850014}}
{"text": "\\section{Modelling and plotting parametric responses}\n\nIn addition to analysing the data in the above \"categorical\" design, we now illustrate an alternative \"parametric\" design in which repetition is viewed as a continuum. In this case, the response to each presentation of famous and non-famous faces is modulated by the time interval (lag) since the previous presentation of that face (for first presentations, this lag is infinite). \n\n\\subsection{Specification and estimation}\n\nFinally, consider the effects of the interval between first and second presentations of famous and non-famous faces. For this purpose, an alternative statistical model needs to be estimated, with four trial types. (1) First and second presentation of a non-famous face (N1 and N2 collapsed). (2) First and second presentation of a famous face (F1 and F2 collapsed). (3) Errors in judging non-famous faces. (4) Errors in judging famous faces. These are modelled with the canonical hrf alone, with two parametric (exponential) modulations added for second presentations of non-famous and famous faces. See the README.txt for details of design specification.\n\n\\subsection{Inference and plotting}\n\nAfter completion of model estimation, press `Results' and select the SPM.mat file. When the Contrast Manager appears, define an F-contrast `Effect of Lag (on canonical N+F)' (name) and `0 1 0 1', and a t-contrast `Canonical: Faces $>$ Baseline' (name) and `1 0 1 0'. Select the F-contrast, specify `mask with other contrasts' (yes), select `Canonical: Faces $>$ Baseline', specify `uncorrected mask p-value' (accept default), `nature of mask (inclusive), `title for comparison' (accept default), `corrected height threshold' (no), and `corrected p-value' (accept default). When the MIP appears, press `Volume'.\n\nThe table displays all clusters where the exponential change in activation between first and second presentations for famous OR non-famous faces for the canonical hrf is significantly different from zero AND the canonical hrf for the first two conditions is significantly larger than zero (baseline). We can now plot these parametric effects at particular voxels.\n\nTo plot these parametric effects, select the R fusiform region (45 -60 -18, similar to the region identified in the previous categorical analysis for repetition effects), and press 'plot'. Select 'Plots of parametric responses' and select 'F' (or 'N').  Note that the 'attrib' option does not allow adjustment of the scale of the Z-axis; therefore, to change the scale for all axes, type e.g. 'figure (1), axis ([0 30 0 100 0 1])' in the Matlab window.\n\nNote that these repetition effects are transient (decrease with increasing intervals between first and second presentations), especially for famous faces.\n", "meta": {"hexsha": "66a230a3b84d06e6d4bac4ef48adebcdbdb4131a", "size": 2761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "spm8/man/faces/parametric.tex", "max_stars_repo_name": "Hexans/spm_linux", "max_stars_repo_head_hexsha": "0d817a8478de736cd91946efa2a71c8dae7ec08a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2015-03-26T21:29:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:18:42.000Z", "max_issues_repo_path": "software/spm12/man/faces/parametric.tex", "max_issues_repo_name": "wiktorolszowy/diffusion_fMRI", "max_issues_repo_head_hexsha": "2028515a244fcec88c072d4a66b97bbc57dc15c0", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-09-27T20:50:48.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-24T20:06:01.000Z", "max_forks_repo_path": "software/spm12/man/faces/parametric.tex", "max_forks_repo_name": "wiktorolszowy/diffusion_fMRI", "max_forks_repo_head_hexsha": "2028515a244fcec88c072d4a66b97bbc57dc15c0", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-26T21:30:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T06:47:37.000Z", "avg_line_length": 153.3888888889, "max_line_length": 655, "alphanum_fraction": 0.7844983702, "num_tokens": 616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4124360754243705}}
{"text": "\\documentclass{beamer}\n\\usepackage{appendixnumberbeamer}\n\n\\mode<presentation>{\\usetheme[subsectionpage=progressbar,block=fill,numbering=none]{metropolis}}\n\n\\usepackage[sfdefault]{FiraSans} %% option 'sfdefault' activates Fira Sans as the default text font\n\\usepackage[english]{babel} \n% \\usepackage[utf8]{inputenc}\n\n\\usepackage{graphicx} % Allows including images\n\\usepackage{caption}\n\\usepackage{booktabs} % Allows the use of \\toprule, \\midrule and \\bottomrule in tables\n\\usepackage{multicol} \n\n% Math packages\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{amssymb}\n\\usepackage{mathpartir}\n\n% Lean \n\\usepackage[outputdir=build]{minted}\n\\setminted{encoding=utf-8}\n\\usepackage{fontspec}\n\\setmainfont{FreeSerif}\n\\setmonofont{FreeMono}\n\\setminted[Lean]{\nmathescape=true,\nlinenos=true,\nbreaklines=true,\nnumbersep=5pt,\nfontsize=\\small,\nframe=lines,\nframesep=2mm\n}\n\n% Coloured boxes\n\\usepackage{tcolorbox}\n\\colorlet{alert}{mLightBrown}\n\\newtcolorbox{alertbox}\n{standard jigsaw, opacityback=0,colframe=alert}\n\\newtcolorbox{tbox}\n{standard jigsaw, opacityback=0,opacityframe=0}\n\n\\title{Continued Fractions in Lean} % the title on the title page\n\\subtitle{A Newbie's Adventure}\n\n\\author{Kevin Kappelmann} % Your name\n\\institute[VU Amsterdam]{Vrije Universiteit Amsterdam}\n\\date{June 14, 2019} % Date, can be changed to a custom date\n\n\\begin{document}\n\n\\maketitle\n\n%------------------------------------------------\n\\section{Let's Go on an Adventure}\n\\begin{frame}{Choose a Weapon}\n\\pause\n\\only<2>{\\begin{figure}\\includegraphics[height=0.6\\textheight]{img/choose_prover.png}\\end{figure}}\n\\only<3->{\\begin{figure}\\includegraphics[height=0.6\\textheight]{img/choose_prover2.png}\\end{figure}}\n\\visible<4>{\n\\centerline{\\dots perhaps because I am interning at VU Amsterdam}\n}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}{The Adventurer's Skill Set}\n\\pause\n\\begin{itemize}[<+->]\n\\item Some experience using Isabelle\n\\item First project with a dependent type theorem prover\n\\item Basic maths and functional programming knowledge\n\\end{itemize}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}\n\\begin{figure}\n    \\includegraphics[height=0.8\\textheight]{img/salt_shaker.png}\n\\end{figure}\n\\end{frame}\n%------------------------------------------------\n\\section{Definitions}\n\\begin{frame}{Generalized Continued Fractions}\nA generalized continued fraction is\\dots\n\\pause\n\\begin{equation*}\nb + \\cfrac{a_0}{b_0 + \\cfrac{a_1}{b_1 + \\cfrac{a_2}{b_2 + \\cfrac{a_3}{b_3 + \\ddots\\,}}}}\n\\end{equation*}\n\\pause\n\\begin{itemize}[<+->]\n\\item $b$ is called the \\emph{integer part}\n\\item each $a_i$ is a \\emph{partial numerator}\n\\item each $b_i$ is a \\emph{partial denominator}\n\\end{itemize}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}{Generalized Continued Fractions of $\\pi$}\n\\begin{columns}\n\\column{0.49\\textwidth}\n\\visible<2->{\n    \\only<1-2>{\\centerline{\\alert{Continued fraction}}}\n    \\only<3->{\\centerline{Continued fraction}}\n}\n\\begin{equation*}\n\\resizebox{1\\hsize}{!}{$\n\\pi=3+\\cfrac{1}{7+\\cfrac{1}{15+\\cfrac{1}{1+\\cfrac{1}{292+\\cfrac{1}{1+\\ddots}}}}}\n$}\n\\end{equation*}\n\\column{0.49\\textwidth}\n\\vspace{5.3mm}\n\\visible<3->{\n\\visible<4->{\n    \\centerline{\\alert{Generalized continued fraction}}\n}\n\\begin{equation*}\n\\resizebox{1\\hsize}{!}{$\n\\pi=3+\\cfrac{1^2}{6+\\cfrac{3^2}{6+\\cfrac{5^2}{6+\\cfrac{7^2}{6+\\cfrac{9^2}{6+\\ddots}}}}}\n$}\n}\n\\end{equation*}\n\\end{columns}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Generalized Continued Fractions in Lean}\n\\begin{columns}\n\\column{0.30\\textwidth}\n\\begin{equation*}\n\\resizebox{1\\hsize}{!}{$\nb + \\cfrac{a_0}{b_0 + \\cfrac{a_1}{b_1 + \\cfrac{a_2}{b_2 + \\cfrac{a_3}{b_3 + \\ddots\\,}}}}$\n}\n\\end{equation*}\n\\pause\n\\column{0.65\\textwidth}\n\\begin{onlyenv}<4->\n    \\begin{minted}[fontsize=\\tiny,linenos=false]{Lean}\n    /- Fix a type -/\n    variable (α : Type*)\n\n    /-- A gcf_pair consists of a partial numerator a and partial denominator b -/\n    structure gcf_pair := (a : α) (b : α)\n    \\end{minted}   \n\\end{onlyenv}\n\\end{columns}\n\\begin{onlyenv}<1-2>\n\\begin{visibleenv}<2>\n\\begin{minted}{Lean}\n/- Fix a type -/\nvariable (α : Type*)\n\\end{minted}\n\\end{visibleenv}\n\\end{onlyenv}\n\\begin{onlyenv}<3>\n    \\begin{minted}{Lean}\n    /- Fix a type -/\n    variable (α : Type*)\n\n    /-- A gcf_pair consists of a partial numerator a and partial denominator b -/\n    structure gcf_pair := (a : α) (b : α)\n    \\end{minted}   \n\\end{onlyenv}\n\\begin{onlyenv}<4>\n\\begin{minted}[linenos=false]{Lean}\n-- Once a sequence hits none, it stays none\ndef seq := {f : ℕ → option α // ∀ {n}, f n = none → f (n + 1) = none}\n\\end{minted}\n\\end{onlyenv}\n\\begin{onlyenv}<5>\n\\begin{minted}[linenos=false]{Lean}\ndef seq := {f : ℕ → option α // ∀ {n}, f n = none → f (n + 1) = none}\n/-- A generalized continued fraction consists of a leading head term (the \"integer part\") and a sequence of partial partial numerators $a_n$ and partial denominators $b_n$ -/\nstructure gcf := (head : α) (seq : seq (gcf_pair α))\n\\end{minted}\n\\end{onlyenv}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Evaluate Generalized Continued Fractions}\n\\begin{onlyenv}<1>\n\\begin{minted}[fontsize=\\small]{Lean}\ndef convergents (g : gcf α) (n : ℕ) : α :=\ng.head + if n = 0 then 0 else aux n g.seq\n\\end{minted}\n\\end{onlyenv}\n\\begin{onlyenv}<2>\n\\begin{minted}[fontsize=\\small]{Lean}\ndef aux : ℕ → seq (gcf_pair α) → α\n| 0 s := match s.head with\n  | none := 0\n  | some ⟨a, b⟩ := a / b\n  end\n| (n + 1) s := match s.head with\n  | none := 0\n  | some ⟨a, b⟩ := a / (b + aux n s.tail)\n  end\n\ndef convergents (g : gcf α) (n : ℕ) : α :=\ng.head + if n = 0 then 0 else aux n g.seq\n\\end{minted}\n\\end{onlyenv}\n\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Continued Fractions}\n\\begin{equation*}\n\\resizebox{0.4\\hsize}{!}{$\nb + \\cfrac{1}{b_0 + \\cfrac{1}{b_1 + \\cfrac{1}{b_2 + \\cfrac{1}{b_3 + \\ddots\\,}}}}$\n}\n\\end{equation*}\n\\pause\n\\vspace{-5mm}\n\\begin{visibleenv}<2->\n\\begin{minted}{Lean}\n/-- A continued fraction is a gcf whose partial numerators are equal to 1. -/\ndef cf := {g : gcf α // ∀ (n : ℕ) (a : α), (partial_numerators g).nth n = some a → a = 1}\n\\end{minted}\n\\end{visibleenv}\n\\visible<3-4>{\\centerline{First impression: \\visible<4>{\\alert{Pretty Sweet!}}}}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Fun with Subtypes}\nSo, since \\emph{cf} is a subtype of \\emph{gcf}, we can do\n\\begin{onlyenv}<1-4>\n\\begin{minted}{Lean}\ndef convergents (g : gcf α) (n : ℕ) : α := ...\n\nvariable (c : cf α)\n#check convergents c 0\n\\end{minted}\n\\visible<2->{\n    \\only<1-2>{\\textcolor{red}{\\centerline{\\Large{NOPE!}}}}\n    \\only<3-4>{\\begin{center}{\\includegraphics[height=0.4\\textheight]{img/subtype_error.png}}\\end{center}}\n    \\visible<4>{\\centerline{\\alert{Oh, I see -- I need to cast!}}}\n}\n\\end{onlyenv}\n\\begin{onlyenv}<5->\n\\begin{minted}{Lean}\ndef convergents (g : gcf α) (n : ℕ) : α := ...\n\nvariable (c : cf α)\n#check convergents (c : gcf α) 0\n\\end{minted}\n\\visible<6->{\n    \\only<5-6>{\\textcolor{red}{\\centerline{\\Large{NOPE!}}}}\n    \\only<7->{\\begin{center}{\\includegraphics[height=0.3\\textheight]{img/subtype_error2.png}}\\end{center}}\n    \\visible<8->{\\centerline{\\alert{\\dots alright, let's go on Zulip \\includegraphics[height=0.04\\textheight]{img/zulip.png}}}}\n}\n\\end{onlyenv}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}{Please Help Me}\n    \\center A few minutes and messages from \\href{http://wwwf.imperial.ac.uk/~buzzard/}{\\emph{Kevin Buzzard}} later\\dots\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{The ``Solution''}\nWe first need to define the casting\n\\pause\n\\begin{minted}{Lean}\ninstance cf_to_gcf : has_coe (cf β) (gcf β)\n:= by {unfold cf, apply_instance}\n\n/- Best practice: create a lemma for your cast -/\n@[simp, elim_cast]\nlemma coe_cf (c : cf β) : (↑c : gcf β) = c.val\n:= by refl\n\\end{minted}\n\\begin{visibleenv}<3->\n\\begin{onlyenv}<1-3>\n\\alert{Now this works:}\n\\begin{minted}{Lean}\nvariable (c : cf α)\n#check convergents (c : gcf α) 0\n\\end{minted}\n\\end{onlyenv}\n\\begin{onlyenv}<4->\n\\textcolor{red}{This, however, still does not work:}\n\\begin{minted}{Lean}\nvariable (c : cf α)\n#check convergents c 0\n\\end{minted}\n\\end{onlyenv}\n\\end{visibleenv}\n\\end{frame}\n%------------------------------------------------\n\\section{Proofs}\n%------------------------------------------------\n\\begin{frame}[fragile]{The Proof Is Trivial}\n\\begin{minted}{Lean}\nlemma floor_rat_eq_num_div_denom (n d : ℤ) :\n  ⌊rat.mk n d⌋ = n / d\n\\end{minted}\n\n\\vspace{10mm}\n\\only<2>{\\centerline{Wait, let's do some examples first\\dots}}\n\\only<3>{\\centerline{\\alert{Alright, I am sold!}}}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Proving\\dots\\ Please Wait}\n\\only<1>{\\begin{figure}{\\includegraphics[height=0.5\\textheight]{img/clock.png}}\\end{figure}}\n\\only<2>{\n\\begin{figure}{\\includegraphics[height=0.5\\textheight]{img/melting_clock.png}}\\end{figure}\n\n\\vspace{5mm}\n\\centerline{\\alert{Something seems wrong}}\n}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{Now It Is Trivial}\n\\begin{minted}{Lean}\nlemma floor_rat_eq_num_div_denom (n : ℤ) (d : ℕ) :\n  ⌊rat.mk n d⌋ = n / d\n\\end{minted}\n\\vspace{5mm}\n\\centerline{That's better!}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[fragile]{A Short Note About Tactics}\n\\centerline{\\emph{<Show two short examples in VS Code>}}\n\\end{frame}\n%------------------------------------------------\n\\section{Results}\n\\begin{frame}[fragile]{Collected Treasures}\n\\only<1>{\\begin{figure}\\includegraphics[height=0.6\\textheight]{img/chest.png}\\end{figure}}\n\\begin{onlyenv}<2>\nDefinition of (generalized) continued fractions and their evaluation\n\\begin{minted}{Lean}\nstructure gcf := (head : α) (seq : seq (gcf_pair α))\ndef cf := {g : gcf α // ∀ (n : ℕ) (a : α), (partial_numerators g).nth n = some a → a = 1}\ndef convergents (g : gcf α) (n : ℕ) : α := ...\n\\end{minted}\n\\end{onlyenv}\n\\begin{onlyenv}<3-4>\nComputable continued fractions for discrete linear ordered floor fields \n\\begin{minted}{Lean}\ndef get_cf [discrete_linear_ordered_field α] [floor_ring α] (v : α) : cf α := ...\n\\end{minted}\n\\visible<4>{\\centerline{Also works for $\\mathbb{R}$ -- just not computable\\dots}}\n\\end{onlyenv}\n\\begin{onlyenv}<5-7>\nTermination proof for archimedian fields\n\\begin{minted}{Lean}\ntheorem termination_iff_rat [archimedean α] (v : α) :\n  Terminates (get_gcf v) ↔ ∃ (q : ℚ), v = (q : α)\n\\end{minted}\n\\visible<6-7>{Including a theorem a mathematician would never prove:}\n\\begin{visibleenv}<7>\n\\begin{minted}{Lean}\ntheorem translate_rat_get_cf {q : ℚ}\n(v_eq_q : v = q) :\n  ((get_gcf q : gcf ℚ) : gcf α) = get_gcf v :=\n\\end{minted}\n\\end{visibleenv}\n\\end{onlyenv}\n\\begin{onlyenv}<8>\nFinite correctness of the computation\n\\begin{minted}{Lean}\ntheorem get_gcf_finite_correctness\n(terminates: Terminates (get_gcf v)) :\n  ∃ (n : ℕ), v = convergents (get_gcf v) n\n\\end{minted}\n\\end{onlyenv}\n\\begin{onlyenv}<9-10>\nSome interesting inequalities, and finally:\n\\begin{minted}{Lean}\ntheorem epsilon_convergence : ∀ (ε > (0 : α)),\n  ∃ (N : ℕ), ∀ (n ≥ N),\n  |v - convergents (get_gcf v) n| < ε :=\n\\end{minted}\n\n\\vspace{5mm}\n\\visible<10>{\\centerline{But sadly no library for sequence limits in Lean :(}}\n\\end{onlyenv}\n\\end{frame}\n%------------------------------------------------\n\\section{End of the Story}\n%------------------------------------------------\n\\begin{frame}{Lessons Learnt}\n\\pause\n\\begin{itemize}[<+->]\n\\item Lean's type system is very expressive and great for definitions\\dots\n\\begin{itemize}\n\\item \\dots if one knows the gotchas.\n\\end{itemize}\n\\item Support on Zulip is fantastic.\n\\item Existing tactics help a LOT\\dots\n\\begin{itemize}\n\\item \\dots but no integration of automated theorem provers yet.\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}{We Need You!}\n\\Large\n\\centerline{\\alert{Help us making interactive theorem proving}}\n\n\\centerline{\\alert{an even better place!}}\n\n\\end{frame}\n%------------------------------------------------\n\\begin{frame}[standout]\n\\normalsize{Formalisation can be found at \\url{github.com/kappelmann/lean-continued-fractions}}\n\\pause\n\\center\n% \\Large{Thanks for your attention! Any questions?}\n\\begin{equation*}\nThanks + \\cfrac{1}{for + \\cfrac{1}{your + \\cfrac{1}{attention!}}}\n\\end{equation*}\n\n\\vspace{10mm}\n\n\\pause\n\\Large{\\alert{Any questions?}}\n\\end{frame}\n%----------------------------------------------------------------------------------------\n%\\begin{frame}[allowframebreaks]{References}\n  %\\bibliography{../paper/sources.bib}\n  %\\bibliographystyle{abbrv}\n%\\end{frame}\n\n\\begin{frame}[allowframebreaks]{Image Sources}\n\\begin{itemize}\n\\item Salt shaker: Modified from \\url{bit.ly/2K8Jw8s}\n\\item Link 1: \\url{bit.ly/2wMGOwE}\n\\item Link 2: \\url{bit.ly/2RaypfX}\n\\item Link 3: \\url{bit.ly/2MNGUPt}\n\\item Clock: \\url{bit.ly/2HOc9GC}\n\\item Melting clock: \\url{bit.ly/2MKWknv}\n\\end{itemize}\n\\end{frame}\n\n\\end{document} \n", "meta": {"hexsha": "f6168942233c18c3d8c0eb93420c9d6045e680fb", "size": 13054, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation_lean_continued_fractions.tex", "max_stars_repo_name": "kappelmann/presentation_lean_continued_fractions", "max_stars_repo_head_hexsha": "e8fdf1578af78ca68e971ef3a86d3b71d70cfd3c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentation_lean_continued_fractions.tex", "max_issues_repo_name": "kappelmann/presentation_lean_continued_fractions", "max_issues_repo_head_hexsha": "e8fdf1578af78ca68e971ef3a86d3b71d70cfd3c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation_lean_continued_fractions.tex", "max_forks_repo_name": "kappelmann/presentation_lean_continued_fractions", "max_forks_repo_head_hexsha": "e8fdf1578af78ca68e971ef3a86d3b71d70cfd3c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3581395349, "max_line_length": 174, "alphanum_fraction": 0.6355140187, "num_tokens": 4308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.41243607511560515}}
{"text": "\n\\begin{document}\n\n\\chapter*{Notation}\n\n\\begin{table}[h!]\n\n    \\centering\n\n    \\begin{tabular}{l|l}\n    \\hline\n    Notation                                              & Description                                                                          \\\\ \\hline\n    $a$                                                 & A dynamic obstacle                                                                   \\\\\n    $A$                                                 & Set of dynamic obstacles                                                             \\\\\n    $P_a(\\cdot)$                              & Cost distribution for a single dynamic obstacle, $a$                               \\\\\n    $P(\\cdot)$                                 & Cost distribution for a set of dynamic obstacles                                     \\\\\n    $\\mathcal{N}(\\cdot)$            & Three dimensional normal distribution                                                \\\\\n    $\\dot{\\zeta}(\\cdot)$   & Velocity function for a dynamic obstacle                                             \\\\\n    $\\zeta(\\cdot)$                    & Predicted trajectory of a dynamic obstacle                                           \\\\\n    $\\tilde{\\zeta}(\\cdot)$ & Observed trajectory for a dynamic obstacle                                           \\\\\n    $C(\\cdot)$                                 & Dynamic edge cost for the probabilistic roadmap excluding revisiting penalty         \\\\\n    $TC(\\cdot)$                                & Dynamic edge cost for the probabilistic roadmap including revisiting penalty         \\\\\n    $I$                                                 & Initial configuration of a dynamic obstacle                                          \\\\\n    $\\epsilon$                                 & Amount of noise injected into a dynamic obstacle's trajectory                        \\\\\n    $\\xi$                                      & Last configuration used for trajectory prediction                                    \\\\\n    $T$                                                 & Last time used for trajectory prediction                                             \\\\\n    $\\alpha$                                   & Multiplicative weight for the variance in $\\mathcal{N}(\\cdot)$ \\\\\n    $\\beta$                                    & Additive weight for the variance in $\\mathcal{N}(\\cdot)$       \\\\\n    $\\gamma$                                   & Exponential constant used for weighting basis functions in $P$                     \\\\\n    $\\psi$                                     & Multiplicative weight for the cost distribution in $TC$                            \\\\\n    $\\omega$                                   & Multiplicative weight for revisiting a node in $TC$                                \\\\\n    \\end{tabular}\n\\end{table}\n\n\\end{document}\n", "meta": {"hexsha": "c96223f0879293c03e1b8265cb9be372b512c97f", "size": 2838, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/notation.tex", "max_stars_repo_name": "wallarelvo/DodgerReport", "max_stars_repo_head_hexsha": "a44515d384bfb3d7f61be715c1a5d04d116b1b85", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-03-17T23:02:36.000Z", "max_stars_repo_stars_event_max_datetime": "2015-03-17T23:02:36.000Z", "max_issues_repo_path": "chapters/notation.tex", "max_issues_repo_name": "wallarelvo/DodgerReport", "max_issues_repo_head_hexsha": "a44515d384bfb3d7f61be715c1a5d04d116b1b85", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/notation.tex", "max_forks_repo_name": "wallarelvo/DodgerReport", "max_forks_repo_head_hexsha": "a44515d384bfb3d7f61be715c1a5d04d116b1b85", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.8333333333, "max_line_length": 154, "alphanum_fraction": 0.3587033122, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4124360708737255}}
{"text": "%% Copyright (C) 2011, Gostai S.A.S.\n%%\n%% This software is provided \"as is\" without warranty of any kind,\n%% either expressed or implied, including but not limited to the\n%% implied warranties of fitness for a particular purpose.\n%%\n%% See the LICENSE file for more information.\n\n\\section{Matrix}\n\n\\subsection{Prototypes}\n\\begin{refObjects}\n\\item[Object]\n\\end{refObjects}\n\n\\subsection{Construction}\n\\label{sec:specs:matrix:ctor}\n\nThe \\lstinline|init| function is overloaded, and its behavior depends on the\nnumber of arguments and their types.\n\nWhen there is a single argument, it can either be a List, or another Matrix.\n\nIf it's a List of ``Vectors and/or Lists of Floats'', then they must have\nthe same sizes and constitute the rows.\n\n\\begin{urbiscript}\nvar listList     = Matrix.new([           [0, 1],             [0, 1] ]);\n[00071383] Matrix([\n[:]  [0, 1],\n[:]  [0, 1]])\nvar listVector   = Matrix.new([           [0, 1],  Vector.new([0, 1])])|;\nvar vectorList   = Matrix.new([Vector.new([0, 1]),            [0, 1] ])|;\nvar vectorVector = Matrix.new([Vector.new([0, 1]), Vector.new([0, 1])])|;\n\nassert\n{\n  listList == listVector;\n  listList == vectorList;\n  listList == vectorVector;\n};\nMatrix.new([           [0],            [1, 2]]);\n[00000030:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new([Vector.new([0]),           [1, 2]]);\n[00000056:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new([           [0], Vector.new([1, 2])]);\n[00000071:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new([Vector.new([0]), Vector.new([1, 2])]);\n[00052403:error] !!! new: expecting rows of size 1, got size 2 for row 2\n\\end{urbiscript}\n\nIf it's a Matrix, then there is a deep-copy: they are not aliases.\n\n\\begin{urbiscript}\nvar m1 = Matrix.new([[1, 1], [1, 1]])|;\nvar m2 = Matrix.new(m1)|;\nm2[0, 0] = 0|;\nassert\n{\n  m1 == Matrix.new([[1, 1], [1, 1]]);\n  m2 == Matrix.new([[0, 1], [1, 1]]);\n};\n\\end{urbiscript}\n\nWhen given two Float arguments, they must be the two integers, defining the\nsize of the null Matrix.\n\\begin{urbiscript}\nMatrix.new(2, 3);\n[00051329] Matrix([\n[:]  [0, 0, 0],\n[:]  [0, 0, 0]])\n\\end{urbiscript}\n\nIn other cases, the arguments are expected to be Lists of Floats and/or\nVectors.\n\n\\begin{urbiassert}\nMatrix.new([1, 2])                   == Matrix.new([[1, 2]]);\nMatrix.new([1, 2],           [3, 4]) == Matrix.new([[1, 2], [3, 4]]);\nMatrix.new([1, 2], Vector.new(3, 4)) == Matrix.new([[1, 2], [3, 4]]);\n\\end{urbiassert}\n\nThese rows must have equal sizes.\n\n\\begin{urbiscript}\n// Lists and Lists.\nMatrix.new([0], [1, 2]);\n[00000160:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new([0, 1], [2]);\n[00000169:error] !!! new: expecting rows of size 2, got size 1 for row 2\n\n// Lists and Vectors.\nMatrix.new([0], Vector.new(1, 2));\n[00000178:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new(Vector.new(0, 1), [2]);\n[00000186:error] !!! new: expecting rows of size 2, got size 1 for row 2\n\n// Vectors and Vectors.\nMatrix.new(Vector.new(0), Vector.new(1, 2));\n[00000195:error] !!! new: expecting rows of size 1, got size 2 for row 2\nMatrix.new(Vector.new(0, 1), Vector.new(2));\n[00000204:error] !!! new: expecting rows of size 2, got size 1 for row 2\n\\end{urbiscript}\n\n\n\\subsection{Slots}\n\n\\begin{urbiscriptapi}\n\\item['*'](<that>)%\n  If \\that is a Matrix, matrix product between \\this and \\that.\n\\begin{urbiassert}\nMatrix.new([1, 2]) * Matrix.new([10], [20])\n  == Matrix.new([50]);\nMatrix.new([3, 4]) * Matrix.new([10], [20])\n  == Matrix.new([110]);\nMatrix.new([1, 2], [3, 4]) * Matrix.new([10], [20])\n  == Matrix.new([50], [110]);\n\\end{urbiassert}\n\nThe sizes must be compatible ($\\texttt{\\this.size.second} =\n\\texttt{\\that.size.first}$).\n\\begin{urbiscript}\nMatrix.new([1, 2]) * Matrix.new([3, 4]);\n[00081168:error] !!! *: incompatible sizes: 1x2, 1x2\n\\end{urbiscript}\n\n  If \\that is a Float, the scalar product.\n\\begin{urbiassert}\nMatrix.new([1, 2], [3, 4]) * 3 == Matrix.new([3, 6], [9, 12]);\n\\end{urbiassert}\n\n\n\\item['*='](<that>)%\n  In place (\\autoref{sec:lang:op:ass}) product (\\refSlot{'*'}).  The same\n  constraints apply.\n\\begin{urbiassert}\nvar lhs1 = Matrix.new([1, 2], [3, 4]);\nvar lhs2 = Matrix.new(lhs1);\nvar rhs = Matrix.new([10], [20]);\nvar res = lhs1 * rhs;\n\n(lhs1.'*='(rhs)) === lhs1;  lhs1 == res;\n(lhs2  *=  rhs ) === lhs2;  lhs2 == res;\n\nrhs *= rhs;\n[00272182:error] !!! *=: incompatible sizes: 2x1, 2x1\n\\end{urbiassert}\n\n\\begin{urbiassert}\nvar v = Matrix.new([1, 2], [3, 4]);\nvar res = v * 3;\n(v *= 3) === v; v == res;\n\\end{urbiassert}\n\n\n\\item['+'](<that>)%\n  The sum of \\this and \\that.  Their sizes must be equal.\n\\begin{urbiassert}\nMatrix.new([1, 2]) + Matrix.new([10, 20])\n  == Matrix.new([11, 22]);\n\nMatrix.new([1, 2], [3, 4]) + Matrix.new([10, 20], [30, 40])\n  == Matrix.new([11, 22], [33, 44]);\n\nMatrix.new([1, 2]) + Matrix.new([10, 20], [30, 40]);\n[00002056:error] !!! +: incompatible sizes: 1x2, 2x2\n\\end{urbiassert}\n\n  If \\that is a Float, the scalar addition.\n\\begin{urbiassert}\nMatrix.new([1, 2], [3, 4]) + 3 == Matrix.new([4, 5], [6, 7]);\n\\end{urbiassert}\n\n\n\\item['+='](<that>)%\n  In place (\\autoref{sec:lang:op:ass}) sum (\\refSlot{'+'}).  The same\n  constraints apply.\n\\begin{urbiassert}\nvar lhs1 = Matrix.new([ 1 , 2], [ 3,  4]);\nvar lhs2 = Matrix.new(lhs1);\nvar rhs = Matrix.new([10, 20], [30, 40]);\nvar res = lhs1 + rhs;\n\n(lhs1.'+='(rhs)) === lhs1;  lhs1 == res;\n(lhs2  +=  rhs ) === lhs2;  lhs2 == res;\n\nlhs1 += Matrix.new([1, 2]);\n[00338194:error] !!! +=: incompatible sizes: 2x2, 1x2\n\\end{urbiassert}\n\n\\begin{urbiassert}\nvar v = Matrix.new([3, 6], [9, 12]);\nvar res = v + 3;\n(v += 3) === v; v == res;\n\\end{urbiassert}\n\n\n\\item['-'](<that>)%\n  The difference of \\this and \\that.  Their sizes must be equal.\n\\begin{urbiassert}\nMatrix.new([1, 2]) - Matrix.new([10, 20])\n  == Matrix.new([-9, -18]);\n\nMatrix.new([1, 2], [3, 4]) - Matrix.new([10, 20], [30, 40])\n  == Matrix.new([-9, -18], [-27, -36]);\n\nMatrix.new([1, 2]) - Matrix.new([10, 20], [30, 40]);\n[00002056:error] !!! -: incompatible sizes: 1x2, 2x2\n\\end{urbiassert}\n\n  If \\that is a Float, the scalar difference.\n\\begin{urbiassert}\nMatrix.new([1, 2], [3, 4]) - 3 == Matrix.new([-2, -1], [0, 1]);\n\\end{urbiassert}\n\n\n\\item['-='](<that>)%\n  In place (\\autoref{sec:lang:op:ass}) difference (\\refSlot{'-'}).  The same\n  constraints apply.\n\\begin{urbiassert}\nvar lhs1 = Matrix.new([ 1 , 2], [ 3,  4]);\nvar lhs2 = Matrix.new(lhs1);\nvar rhs = Matrix.new([10, 20], [30, 40]);\nvar res = lhs1 - rhs;\n\n(lhs1.'-='(rhs)) === lhs1;  lhs1 == res;\n(lhs2  -=  rhs ) === lhs2;  lhs2 == res;\n\nlhs1 -= Matrix.new([1, 2]) ;\n[00362383:error] !!! -=: incompatible sizes: 2x2, 1x2\n\\end{urbiassert}\n\n\\begin{urbiassert}\nvar v = Matrix.new([3, 6], [9, 12]);\nvar res = v - 3;\n(v -= 3) === v; v == res;\n\\end{urbiassert}\n\n\n\\item['/'](<that>)%\n  Same as \\lstinline|this * that.inverse|.  \\that must be invertible.\n\\begin{urbiassert}\nvar lhs = Matrix.new([20, 0], [0, 200]);\nvar rhs = Matrix.new([10, 0], [0, 100]);\nvar res = Matrix.new([ 2, 0], [0,   2]);\n\nlhs / rhs == res;\n(lhs / rhs) * rhs == lhs;\nrhs * (lhs / rhs) == lhs;\n\nlhs / Matrix.createZeros(2, 2);\n[00160168:error] !!! /: non-invertible matrix: <<0, 0>, <0, 0>>\n\\end{urbiassert}\n\n  If \\that is a Float, the scalar division.\n\\begin{urbiassert}\nMatrix.new([3, 6], [9, 12]) / 3 == Matrix.new([1, 2], [3, 4]);\n\\end{urbiassert}\n\n\n\\item['/='](<that>)%\n  In place (\\autoref{sec:lang:op:ass}) division (\\refSlot{'/'}).  The same\n  constraints apply.\n\\begin{urbiassert}\nvar lhs1 = Matrix.new([20, 0], [0, 200]);\nvar lhs2 = Matrix.new(lhs1);\nvar rhs = Matrix.new([10, 0], [0, 100]);\nvar res = Matrix.new([ 2, 0], [0,   2]);\n\n(lhs1.'/='(rhs)) === lhs1;  lhs1 == res;\n(lhs2  /=  rhs ) === lhs2;  lhs2 == res;\n\nlhs1 /= Matrix.createZeros(2, 2);\n[00207285:error] !!! /=: non-invertible matrix: <<0, 0>, <0, 0>>\n\\end{urbiassert}\n\n\\begin{urbiassert}\nvar v = Matrix.new([3, 6], [9, 12]);\nvar res = v / 3;\n(v /= 3) === v; v == res;\n\\end{urbiassert}\n\n\n\\item['=='](<that>)%\n  Whether \\this and \\that have the same dimensions and members.\n\\begin{urbiscript}\ndo (Matrix)\n{\n  assert\n  {\n      new([[1], [2], [3]]) == new([[1], [2], [3]]);\n    !(new([[1], [2], [3]]) == new([[1], [2]]));\n    !(new([[1], [2], [3]]) == new([[3], [2], [1]]));\n  };\n}|;\n\\end{urbiscript}\n\n\n\\item|'[]'|(<row>, <col>)%\n  The element at \\lstinline|\\var{row}, \\var{col}|.  The index \\var{row} must\n  verify $0 \\le \\textrm{\\var{row}} < \\texttt{\\this.size.first}$, or\n  $-\\texttt{\\this.size.first} \\le \\texttt{\\var{row}} < 0$, in which case it\n  is equivalent to using index $\\textrm{\\var{row}} +\n  \\texttt{\\this.size.first}$: it counts ``backward''.  Similarly for\n  \\var{col}.\n\\begin{urbiscript}\nvar m = Matrix.new([1, 2, 3], [10, 20, 30])|;\nassert\n{\n  m[0, 0] == 1;   m[0, -3] == 1;\n  m[0, 1] == 2;   m[0, -2] == 2;\n  m[0, 2] == 3;   m[0, -1] == 3;\n\n  m[1, 2] == 30;  m[-1, -1] == 30;\n};\n\nm[2, 0];\n[00127812:error] !!! []: invalid row: 2\n\nm[-3, 0];\n[00127824:error] !!! []: invalid row: -3\n\nm[0, 3];\n[00127836:error] !!! []: invalid column: 3\n\nm[0, -4];\n[00127850:error] !!! []: invalid column: -4\n\\end{urbiscript}\n\\begin{urbicomment}\n  removeSlots(\"m\");\n\\end{urbicomment}\n\n\n\\item|'[]='|(<row>, <col>, <val>)%\n  Set the element at \\lstinline|\\var{row}, \\var{col}| to \\var{val}, and\n  return \\var{val}.  The index \\var{row} must verify $0 \\le\n  \\textrm{\\var{row}} < \\texttt{\\this.size.first}$, or\n  $-\\texttt{\\this.size.first} \\le \\texttt{\\var{row}} < 0$, in which case it\n  is equivalent to using index $\\textrm{\\var{row}} +\n  \\texttt{\\this.size.first}$: it counts ``backward''.  Similarly for\n  \\var{col}.\n\\begin{urbiscript}\nvar m = Matrix.new([1, 2], [10, 20])|;\nassert\n{\n  (m[0, 0]  = -1) == -1;   m[0, 0] == -1;\n  (m[-1, -1] = -2) == -2;  m[1, 1] == -2;\n};\n\nm[2, 0] = -1;\n[00127812:error] !!! []=: invalid row: 2\n\nm[-3, 0] = -1;\n[00127824:error] !!! []=: invalid row: -3\n\nm[0, 2] = -1;\n[00127836:error] !!! []=: invalid column: 2\n\nm[0, -3] = -1;\n[00127850:error] !!! []=: invalid column: -3\n\\end{urbiscript}\n\\begin{urbicomment}\n  removeSlots(\"m\");\n\\end{urbicomment}\n\n\n\\item[appendRow](<vector>)%\n  Append \\var{vector} to \\this and return \\this.\n\\begin{urbiassert}\nvar m2x1 = Matrix.new([0], [1]);\nm2x1.appendRow(Vector.new(2)) === m2x1;\nm2x1 == Matrix.new([0], [1], [2]);\n\nvar m2x2 = Matrix.new([0, 1], [10, 11]);\nm2x2.appendRow(Vector.new(20, 21)) == m2x2;\nm2x2 == Matrix.new([0, 1], [10, 11], [20, 21]);\n\\end{urbiassert}\n\n  Sizes must match.\n\\begin{urbiscript}\nMatrix.new([0], [1]).appendRow(Vector.new(10, 11));\n[00017936:error] !!! appendRow: incompatible sizes: 2x1, 2\n\nMatrix.new([0, 1]).appendRow(Vector.new(10));\n[00050922:error] !!! appendRow: incompatible sizes: 1x2, 1\n\\end{urbiscript}\n\n\n\\item[asMatrix]%\n  \\this.\n\\begin{urbiassert}\nMatrix.asMatrix() === Matrix;\nvar m = Matrix.new([1], [2]);\nm.asMatrix() === m;\n\\end{urbiassert}\n\n\n\\item[asPrintable]%\n  A String that denotes \\this.\n\\begin{urbiassert}\nMatrix                    .asPrintable() == \"Matrix([])\";\nMatrix.new([1, 2], [3, 4]).asPrintable() == \"Matrix([[1, 2], [3, 4]])\";\n\\end{urbiassert}\n\n\n\\item[asString]%\n  A String that denotes \\this.\n\\begin{urbiassert}\nMatrix                    .asString() == \"<>\";\nMatrix.new([1, 2], [3, 4]).asString() == \"<<1, 2>, <3, 4>>\";\n\\end{urbiassert}\n\n\n\\item[asTopLevelPrintable]%\n  A String that denotes \\this.\n\\begin{urbiassert}\nMatrix                    .asTopLevelPrintable()\n  == \"Matrix([])\";\nMatrix.new([1, 2], [3, 4]).asTopLevelPrintable()\n == \"Matrix([\\n  [1, 2],\\n  [3, 4]])\";\n\\end{urbiassert}\n\n\n\\item[column](<i>)%\n  The \\var{i}th column as a Vector.  See also \\refSlot{row}.\n\\begin{urbiassert}\nvar m = Matrix.new([1, 2, 3], [4, 5, 6]);\nm.column(0) == Vector.new(1, 4);  m.column(-3) == m.column(0);\nm.column(1) == Vector.new(2, 5);  m.column(-2) == m.column(1);\nm.column(2) == Vector.new(3, 6);  m.column(-1) == m.column(2);\n\nm.column(3);\n[00000232:error] !!! column: invalid column: 3\n\\end{urbiassert}\n\n\n\\item[createIdentity](<size>)%\n  The unit Matrix of dimensions \\var{size}.\n\\begin{urbiassert}\nMatrix.createIdentity(0) == Matrix;\nMatrix.createIdentity(3) == Matrix.new([1, 0, 0], [0, 1, 0], [0, 0, 1]);\n\nMatrix.createIdentity(-2);\n[00000328:error] !!! createIdentity: argument 1: expected non-negative integer: -2\n\\end{urbiassert}\n\n\n\\item[createOnes](<row>, <col>)%\n  Same as \\lstinline|createScalar(\\var{row}, \\var{col}, 1)|.\n\\begin{urbiassert}\nMatrix.createOnes(0, 0) == Matrix;\nMatrix.createOnes(2, 3) == Matrix.new([1, 1, 1], [1, 1, 1]);\n\nMatrix.createOnes(-2, 2);\n[00000328:error] !!! createOnes: argument 1: expected non-negative integer: -2\n\\end{urbiassert}\n\n\n\\item[createScalars](<row>, <col>, <scalar>)%\n  A Matrix of size \\lstinline|\\var{row} * \\var{col}| filled with\n  \\var{scalar}.\n\\begin{urbiassert}\nMatrix.createScalars(0, 0, 99) == Matrix;\nMatrix.createScalars(2, 3, 99) == Matrix.new([99, 99, 99], [99, 99, 99]);\n\nMatrix.createScalars(-2, 2, 99);\n[00000328:error] !!! createScalars: argument 1: expected non-negative integer: -2\n\\end{urbiassert}\n\n\n\\item[createZeros](<row>, <col>)%\n  Same as \\lstinline|createScalar(\\var{row}, \\var{col}, 0)|.\n\\begin{urbiassert}\nMatrix.createZeros(0, 0) == Matrix;\nMatrix.createZeros(2, 3) == Matrix.new([0, 0, 0], [0, 0, 0]);\n\nMatrix.createZeros(-2, 2);\n[00000328:error] !!! createZeros: argument 1: expected non-negative integer: -2\n\\end{urbiassert}\n\n\n\\item[distanceMatrix](<that>)%\n  Considering that \\this and \\that are collections of Vectors that denote\n  positions in an Euclidean space, produce a Matrix whose value at\n  \\lstinline|(\\var{i}, \\var{j})| is the distance between points\n  \\lstinline|this[\\var{i}]| and \\lstinline|\\var{that}[\\var{j}]|.\n\\begin{urbiassert}\n// Left-hand side matrix.\nvar l0 = Vector.new([0, 0]);  var l1 = Vector.new([2, 1]);\nvar lhs = Matrix.new([l0, l1]);\n// Right-hand side matrix.\nvar r0 = Vector.new([0, 1]);  var r1 = Vector.new([2, 0]);\nvar rhs = Matrix.new([r0, r1]);\n\nlhs.distanceMatrix(rhs)\n  == Matrix.new([l0.distance(r0), l0.distance(r1)],\n                [l1.distance(r0), l1.distance(r1)]);\n\\end{urbiassert}\n\n\n\\item[init]%\n  See \\autoref{sec:specs:matrix:ctor}.\n\n\n\\item[inverse]%\n  The inverse of \\this if it exists, raise an error otherwise.\n\\begin{urbiassert}\nvar m = Matrix.new(\n  [1, 3, 1],\n  [1, 1, 2],\n  [2, 3, 4]);\n\nm * m.inverse() == Matrix.createIdentity(3);\nm.inverse() * m == Matrix.createIdentity(3);\n\nm.inverse() == Matrix.new(\n  [ 2,  9, -5],\n  [ 0, -2,  1],\n  [-1, -3,  2]);\n\nMatrix.createZeros(2, 2).inverse();\n[00000534:error] !!! inverse: non-invertible matrix: <<0, 0>, <0, 0>>\n\\end{urbiassert}\n\n\n\\item[resize](<row>, <col>)%\n  Change the dimensions of \\this, using 0 for new members.  Return \\this.\n\\begin{urbiscript}\n// Check that <<1, 2><3, 4>> is equal to the Matrix composed of rows,\n// when resized to the dimensions of rows.\nfunction resized(var rows[])\n{\n  var m = Matrix.new([1, 2], [3, 4]);\n  var res = Matrix.new(rows);\n  // Resize returns this...\n  m.resize(res.size.first, res.size.second) === m;\n  // ...and does resize.\n  m == res;\n}|;\nassert\n{\n  // Fewer rows/cols.\n  resized([1], [3]);\n  resized([1, 2]);\n  resized([1]);\n  resized([]);\n\n  // As many rows and cols.\n  resized([1, 2], [3, 4]);\n\n  // More rows/cols.\n  resized([1, 2, 0], [3, 4, 0]);\n  resized([1, 2], [3, 4], [0, 0]);\n  resized([1, 2, 0], [3, 4, 0], [0, 0, 0]);\n\n  // More rows, less cols, and conversely.\n  resized([1], [3], [0]);\n  resized([1, 2, 0]);\n};\n\\end{urbiscript}\n\n\n\\item[row](<i>)%\n  The \\var{i}th row as a Vector.  See also \\refSlot{column}.\n\\begin{urbiassert}\nvar m = Matrix.new([1, 2, 3], [4, 5, 6]);\nm.row(0) == Vector.new(1, 2, 3);  m.row(-2) == m.row(0);\nm.row(1) == Vector.new(4, 5, 6);  m.row(-1) == m.row(1);\n\nm.row(2);\n[00195645:error] !!! row: invalid row: 2\n\\end{urbiassert}\n\n\n\\item[rowAdd](<vector>)%\n  A Matrix whose rows (vectors) are the sum of each row of \\this with\n  \\var{vector}.\n\\begin{urbiscript}\ndo (Matrix)\n{\n  assert\n  {\n    rowAdd(Vector) == Matrix;\n    new([[1, 2]]).rowAdd(Vector.new(10))     == new([[11, 12]]);\n    new([1], [2]).rowAdd(Vector.new(10, 20)) == new([11], [22]);\n    new([1, 2], [3, 4]).rowAdd(Vector.new(10, 20)) == new([11, 12], [23, 24]);\n  }\n}|;\n\\end{urbiscript}\n\n  The dimensions must be compatible:\n  \\lstinline|size.first == \\var{vector}.size|.\n\\begin{urbiscript}\nMatrix.new([1], [2]).rowAdd(Vector.new(10));\n[00000415:error] !!! rowAdd: incompatible sizes: 2x1, 1\n\nMatrix.new([1, 2]).rowAdd(Vector.new(10, 20));\n[00000425:error] !!! rowAdd: incompatible sizes: 1x2, 2\n\\end{urbiscript}\n\n\n\\item[rowDiv](<vector>)%\n  A Matrix whose rows (vectors) are the member-wise division of each row of\n  \\this with \\var{vector}.\n\\begin{urbiscript}\ndo (Matrix)\n{\n  assert\n  {\n    rowDiv(Vector) == Matrix;\n    new([[10, 20]]).rowDiv(Vector.new(10))     == new([[1, 2]]);\n    new([10], [20]).rowDiv(Vector.new(10, 20)) == new([1], [1]);\n    new([10, 30], [20, 40]).rowDiv(Vector.new(10, 20)) == new([1, 3], [1, 2]);\n  }\n}|;\n\\end{urbiscript}\n\n  The dimensions must be compatible:\n  \\lstinline|size.first == \\var{vector}.size|.\n\\begin{urbiscript}\nMatrix.new([1], [2]).rowDiv(Vector.new(10));\n[00000415:error] !!! rowDiv: incompatible sizes: 2x1, 1\n\nMatrix.new([1, 2]).rowDiv(Vector.new(10, 20));\n[00000425:error] !!! rowDiv: incompatible sizes: 1x2, 2\n\\end{urbiscript}\n\n\n\\item[rowMul](<vector>)%\n  A Matrix whose rows (vectors) are the member-wise product of each row of\n  \\this with \\var{vector}.\n\\begin{urbiscript}\ndo (Matrix)\n{\n  assert\n  {\n    rowMul(Vector) == Matrix;\n    new([[10, 20]]).rowMul(Vector.new(10))     == new([[100, 200]]);\n    new([10], [20]).rowMul(Vector.new(10, 20)) == new([100], [400]);\n    new([1, 2], [3, 4]).rowMul(Vector.new(10, 20)) == new([10, 20], [60, 80]);\n  }\n}|;\n\\end{urbiscript}\n\n  The dimensions must be compatible:\n  \\lstinline|size.first == \\var{vector}.size|.\n\\begin{urbiscript}\nMatrix.new([1], [2]).rowMul(Vector.new(10));\n[00000415:error] !!! rowMul: incompatible sizes: 2x1, 1\n\nMatrix.new([1, 2]).rowMul(Vector.new(10, 20));\n[00000425:error] !!! rowMul: incompatible sizes: 1x2, 2\n\\end{urbiscript}\n\n\n\\item[rowNorm]%\n  A Vector whose values are the (Euclidean) norms of the rows of \\this.\n\\begin{urbiassert}\nvar m = Matrix.new([1, 2], [3, 3]);\nm.rowNorm()[ 0] == m.row( 0).norm();\nm.rowNorm()[-1] == m.row(-1).norm();\n\\end{urbiassert}\n\n\n\\item[rowSub](<vector>)%\n  A Matrix whose rows (vectors) are the difference of each row of \\this with\n  \\var{vector}.\n\\begin{urbiscript}\ndo (Matrix)\n{\n  assert\n  {\n    rowSub(Vector) == Matrix;\n    new([[10, 20]])    .rowSub(Vector.new(1))      == new([[9, 19]]);\n    new([11], [22])    .rowSub(Vector.new(10, 20)) == new([1], [2]);\n    new([1, 2], [3, 4]).rowSub(Vector.new(1, 2))   == new([0, 1], [1, 2]);\n  }\n}|;\n\\end{urbiscript}\n\n  The dimensions must be compatible:\n  \\lstinline|size.first == \\var{vector}.size|.\n\\begin{urbiscript}\nMatrix.new([1], [2]).rowSub(Vector.new(10));\n[00000415:error] !!! rowSub: incompatible sizes: 2x1, 1\n\nMatrix.new([1, 2]).rowSub(Vector.new(10, 20));\n[00000425:error] !!! rowSub: incompatible sizes: 1x2, 2\n\\end{urbiscript}\n\n\n\\item[set](<vectors>)%\n  Change \\this to be equal to the Matrix defined by the list of vectors\n  given as argument, and return \\this.\n\\begin{urbiassert}\nvar m = Matrix.new([]);\n\nvar m1 = Matrix.new([0, 1], [0, 1]);\n    m  ===    m.set([[0, 1], [0, 1]]);\n    m  == m1;\n\nvar m2 = Matrix.new([2, 3]);\n    m  ===    m.set([[2, 3]]);\n    m  == m2;\n\\end{urbiassert}\n\n\n\\item[setRow](<index>, <vector>)%\n  Set the \\var{index}th row of \\this to \\var{vector} and return \\this.\n\\begin{urbiassert}\nvar m2x1 = Matrix.new([0], [1]);\nm2x1.setRow(0, Vector.new(2)) === m2x1;\nm2x1 == Matrix.new([2], [1]);\n\nvar m2x2 = Matrix.new([0, 1], [10, 11]);\nm2x2.setRow(0, Vector.new(20, 21)) == m2x2;\nm2x2 == Matrix.new([20, 21], [10, 11]);\n\\end{urbiassert}\n\n  Sizes and index must match.\n\\begin{urbiscript}\nMatrix.new([0], [1]).setRow(0, Vector.new(10, 11));\n[00017936:error] !!! setRow: incompatible sizes: 2x1, 2\n\nMatrix.new([0, 1]).setRow(0, Vector.new(10));\n[00050922:error] !!! setRow: incompatible sizes: 1x2, 1\n\nMatrix.new([0], [1]).setRow(2, Vector.new(10));\n[00017936:error] !!! setRow: invalid row: 2\n\\end{urbiscript}\n\n\n\\item[size](<arg>)%\n  The dimensions of the \\this, as a Pair of Floats.\n\\begin{urbiassert}\nMatrix.size == Pair.new(0, 0);\nMatrix.new([1, 2], [3, 4], [5, 6]).size == Pair.new(3, 2);\nMatrix.new([1, 2, 3], [4, 5, 6])  .size == Pair.new(2, 3);\n\\end{urbiassert}\n\n\n\\item[transpose](<arg>)%\n  The transposed of \\this.\n\\begin{urbiassert}\nMatrix                    .transpose() == Matrix;\nMatrix.new([1])           .transpose() == Matrix.new([1]);\nMatrix.new([1], [2])      .transpose() == Matrix.new([1, 2]);\nMatrix.new([1, 2], [3, 4]).transpose() == Matrix.new([1, 3], [2, 4]);\n\\end{urbiassert}\n\n\n\\item[type]%\n  The String \\lstinline|Matrix|.\n\\begin{urbiassert}\nMatrix.type         == \"Matrix\";\nMatrix.new([]).type == \"Matrix\";\n\\end{urbiassert}\n\\end{urbiscriptapi}\n\n%%% Local Variables:\n%%% coding: utf-8\n%%% mode: latex\n%%% TeX-master: \"../urbi-sdk\"\n%%% ispell-dictionary: \"american\"\n%%% ispell-personal-dictionary: \"../urbi.dict\"\n%%% fill-column: 76\n%%% End:\n", "meta": {"hexsha": "cdb127e0e541acf05a69a7834337e1c7a030cb26", "size": 21065, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/specs/matrix.tex", "max_stars_repo_name": "jcbaillie/urbi", "max_stars_repo_head_hexsha": "fb17359b2838cdf8d3c0858abb141e167a9d4bdb", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2016-05-10T05:50:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-05T22:16:13.000Z", "max_issues_repo_path": "doc/specs/matrix.tex", "max_issues_repo_name": "jcbaillie/urbi", "max_issues_repo_head_hexsha": "fb17359b2838cdf8d3c0858abb141e167a9d4bdb", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2016-09-05T10:08:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-13T10:51:07.000Z", "max_forks_repo_path": "doc/specs/matrix.tex", "max_forks_repo_name": "jcbaillie/urbi", "max_forks_repo_head_hexsha": "fb17359b2838cdf8d3c0858abb141e167a9d4bdb", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 15, "max_forks_repo_forks_event_min_datetime": "2015-01-28T20:27:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-28T19:26:08.000Z", "avg_line_length": 27.4283854167, "max_line_length": 82, "alphanum_fraction": 0.600854498, "num_tokens": 7773, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4124360708737255}}
{"text": "\\chapter{Sensors}\n\\label{chapter:Sensors}\n\nIn this chapter will is briefly explained several notations used along the report and\nimportant definitions that help the reader to walk through the work. Many parts of the text presented here are extracted from \\cite{thesis_BT} where full description is available and user should refer to it, if necessary. \nThe notation system of leading superscripts and subscripts is used to denote\nrelative frames orientation or general physical quantities (vectors, points).\nFor frames orientations, leading subscript refers to the frame being represented\nwith respect to the frame in leading superscript. For example let R be a\nrotation matrix. Using the notations stated before, ${}^a_bR$ describes\norientation of frame $b$ with respect to frame $a$. For physical quantities, a\nvector is represented in the frame defined by is leading superscript,\n${}^av$ and in similar way points follow the same rule,\n${}^aP=[{}^ax,{}^ay,{}^az]$.\n\n\n\\section{Definition of frames} \\label{section:frames}\n\nThe frames cited are \\gls{ECEF}, \\gls{WGS84},\n\\gls{ENU} and body frame. The \\gls{ECEF}, \\gls{WGS84} are just auxiliary frames\nused to define the \\gls{ENU} frame which will be considered the world frame.\n\n\n\\subsection{ECEF and ENU Frame}\n\n\\gls{ECEF} coordinate system defines a referential axis where the origin is\ndefined as the center of Earth, X axis is defined through the intersection of\nthe plan defined by zero latitude line (Equator) and plan defined by zero\nlongitude line (prime meridian). The X-axis orientation is considered positive\nfrom center towards the point defined by zero latitude and zero longitude. Z axis\nis defined by line intersecting origin and both Poles, being positive towards\nNorth Pole. Y axis is perpendicular to the plan defined by X and Z axis and it\npositive direction is defined by right hand rule.\n\n\\begin{figure}[!htb]\n\t\\centering\n\t\\includegraphics[width=0.3\\linewidth]{figures/EarthTangentialPlane.png}\n\t\\caption[ECEF frame and Local ENU frame.]{ECEF frame and Local ENU frame (\\href{https://en.wikipedia.org/wiki/File:EarthTangentialPlane.png}{source:wikipedia})}. \n\t\\label{fig:ecef_enu} \n\\end{figure}\n\n\\gls{ENU} coordinate system is a local coordinate system where the origin is\nlocated at a user defined point in \\gls{ECEF} coordinate system, with Y axis pointing\ntowards North Pole and X axis pointing towards East. The plan defined by X and Y\naxis is tangent to the \\gls{WGS84} frame on the origin of ENU. Z axis express\nthe altitude from defined local plane (see figure \\ref{fig:ecef_enu}). The\n\\gls{ENU} frame is considered in this work as the reference frame and will be\ndenoted with superscript or subscript $w$.\n\nGiven a point of reference in \\gls{ECEF} frame, it is necessary to find the\ncorresponding latitude and longitude of reference point ($X_r,Y_r,Z_r$). To do\nit is necessary to use the parameters of \\gls{WGS84} presented in the table\n\\ref{tab:wgs84_parameters}\n\n\\begin{table}[!htb]\n\t\\centering\n\t\\begin{tabular}{lll}\n\t\t\\toprule\n\t\t\\multicolumn{3}{c}{\\textbf{WGS 84 Defining Parameters}\\cite{wgs84_params}}\\\\\n\t\t\\midrule\n\t\t\\textbf{Parameter}        & \\textbf{Notation} & \\textbf{Value} \\\\\n\t\t\\midrule\n\t\tSemi-major axis           & $a$   & 6 378 137.0 m   \\\\\n\t\tReciprocal of flattening  & $1/f$ & 298.257 223 563 \\\\\n\t\tSemi-minor axis \t\t  & $b$   & 6 356 752.3142 m\\\\\n\t\tFirst eccentricity squared& $e^2$ & 6.694 379 990 14x10\\textsuperscript{-3}\\\\\n\t\tSecond eccentricity squared &${e'}^2$ &  6.739 496 742 28x10\\textsuperscript{-3}\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\caption[WGS84 parameters necessary to transform ECEF coordinates into ENU]{WGS84 parameters necessary to transform ECEF coordinates into ENU}\n\t\\label{tab:wgs84_parameters}\n\\end{table}\n\nUsing set of equations \\eqref{eq:ecef_enu_auxiliary} to estimate the latitude\n($\\lambda_r$) and longitude ($\\varphi_r$) for the reference coordinate point.\nThe final transformation results in applying \\eqref{eq:ecef_enu} to\n\\gls{ECEF} physical quantities \\cite{ecef_enu}.\n\n\\begin{subequations}\n\t\\label{eq:ecef_enu_auxiliary}\n\t\\begin{equation}\n\tp = \\sqrt{{X_r}^2 + {Y_r}^2}\n\t\\end{equation}\n\t\\begin{equation}\n\t\\theta = \\arctan\\bigg(Z_r\\frac{a}{pb}\\bigg)\n\t\\end{equation}\n\t\\begin{equation}\n\t\\lambda_r = \\arctantwo(Y_r,X_r)\n\t\\end{equation}\n\t\\begin{equation}\n\t\\varphi_r = \\arctan\\bigg(\\frac{Z_r + e^2b\\sin^3(\\theta)}{p-{e'}^2a\\cos^3(\\theta)}\\bigg)\n\t\\end{equation}\n\\end{subequations}\n\n\\begin{equation}\n\\begin{bmatrix}\nX\\\\\nY\\\\\nZ\n\\end{bmatrix}_{ENU} =\n\\begin{bmatrix}\n-\\sin(\\lambda_r)   \t\t\t\t& \\cos(\\varphi_r) \t\t\t\t  & 0               \\\\\n-\\sin(\\varphi_r)\\cos(\\lambda_r) & -\\sin(\\varphi_r)\\sin(\\lambda_r) & \\cos(\\varphi_r) \\\\\n\\cos(\\varphi_r)\\cos(\\lambda_r)  & \\cos(\\varphi_r)\\sin(\\lambda_r)  & \\sin(\\varphi_r)  \n\\end{bmatrix}\n\\begin{bmatrix}\nX-X_r\\\\\nY-Y_r\\\\\nZ-Z_r\n\\end{bmatrix}_{ECEF}\n\\label{eq:ecef_enu}\n\\end{equation}\n\n\\subsection{Body frame, \\textit{b}}\\label{subsection:body_frame}\n\nEach sensor present in the razor board is aligned to match the sensor axes\nprinted in the board as seen in figure \\ref{fig:razor9dof}. For simplicity, the\nrazor sensor is placed as possible near the middle point of the bisector\nsegment between the two wheel axes in such a away that YY axis as marked in the\nfigure \\ref{fig:razor9dof} is pointing towards the front of vehicle, XX axis is\npointing to the right side of the car and ZZ axis is pointing to the top. This\nway, if the Euler angles describing the orientation of body frame related to\nworld frame are all equal to zero, it means the axes in each frame are\ncoincident apart from an offset in origin.\nRotation angles are considered positive following the right hand rule in each axis.\nThe origin of body frame is equal to intersection of rear wheel axis with the bisector defined above.\n\n\\section{Euler angles and Rotation Matrix} \\label{section:euler_matrix_def}\n\n\\begin{figure}[hb]\n\t\\centering\n\t\\subcaptionbox{3D view of axes frames example\\label{subcap:3D_view_axis_example}}{\n\t\t\\tdplotsetmaincoords{45}{70}\n\t\t\\begin{tikzpicture}[scale=3, tdplot_main_coords]\n\t\t\n\t\t%draw a grid in the x-y plane\n\t\t\\foreach \\xgrid in {-1,-0.9,...,1.1}\n\t\t\\foreach \\ygrid in {-1,-0.9,...,1.1}\n\t\t{\n\t\t\t\\draw[very thin,gray!30] (\\xgrid,-1) -- (\\xgrid,1);\n\t\t\t\\draw[very thin,gray!30] (-1,\\ygrid) -- (1,\\ygrid);\n\t\t}\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% Extend axis backwards\n\t\t%---------------------------------------------------------------------------------\n\t\t\\draw[dashed] (0,0,0) -- ( -1, 0, 0);\n\t\t\\draw[dashed] (0,0,0) -- (  0, -1, 0);\n\t\t%\\draw[dashed] (0,0,0) -- ( 0, 0, -1);\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% Plot new frame axis\n\t\t%---------------------------------------------------------------------------------\n\t\t\\draw[->, bluemat] (0,0,0) -- ( 0.5000,  0.5000, 0.7071) node[anchor=south]{${}^bx$};\n\t\t\\draw[->, redmat](0,0,0) -- (-0.8536,  0.1464, 0.5000) node[anchor=south]{${}^by$};\n\t\t\\draw[->, yellowmat]  (0,0,0) -- ( 0.1464, -0.8536, 0.5000) node[anchor=south]{${}^bz$};\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for XX axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, bluemat] (0.5000, 0, 0) -- ( 0.5000, 0.5000, 0) node[pos=0.5, anchor=north]{\\small $r_{xy}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, bluemat] ( 0, 0.5000, 0) -- ( 0.5000, 0.5000, 0) node[pos=0.5, rotate=-60, anchor=north]{\\small $r_{xx}$};\n\t\t% dashed lines z\n\t\t\\draw[dashed, bluemat] ( 0.5000, 0.5000, 0) -- ( 0.5000,  0.5000, 0.7071) node[pos=0.5, rotate=90, anchor=north]{\\small $r_{xz}$};\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for YY axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, redmat] (-0.8536, 0, 0) -- (-0.8536, 0.1464, 0) node[pos=0.5,anchor=north]{\\small $r_{yy}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, redmat] (0, 0.1464, 0) -- (-0.8536, 0.1464, 0) node[pos=0.5, rotate=-60, anchor=south]{\\small $r_{yx}$};\n\t\t% dashed lines z\n\t\t\\draw[dashed, redmat] (-0.8536, 0.1464, 0) -- (-0.8536,  0.1464, 0.5000) node[pos=0.5,rotate=90,anchor=south]{\\small $r_{yz}$};\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for ZZ axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, yellowmat] (0, -0.8536, 0) -- ( 0.1464, -0.8536, 0) node[pos=0.5,anchor=east]{\\small $r_{zx}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, yellowmat] (0.1464, 0, 0) -- ( 0.1464, -0.8536, 0) node[pos=0.5,anchor=north]{\\small $r_{zy}$};\n\t\t% dashed lines z\n\t\t\\draw[dashed, yellowmat] ( 0.1464, -0.8536, 0) -- ( 0.1464, -0.8536, 0.5000) node[pos=0.5,rotate=90,anchor=north]{\\small $r_{zz}$};\n\t\t\n\t\t% Draw main coordinate system\n\t\t\\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{${}^ax$};\n\t\t\\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{${}^ay$};\n\t\t\\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{${}^az$};\n\t\t\n\t\t\\end{tikzpicture}}\n\t\\hfill\n\t\\subcaptionbox{XY plane of axes frame example\\label{subcap:axis_example_xy_plane}}{\n\t\t\\tdplotsetmaincoords{0}{0}\n\t\t\\begin{tikzpicture}[scale=3, tdplot_main_coords]\n\t\t\n\t\t%draw a grid in the x-y plane\n\t\t\\foreach \\xgrid in {-1,-0.9,...,1.1}\n\t\t\\foreach \\ygrid in {-1,-0.9,...,1.1}\n\t\t{\n\t\t\t\\draw[very thin,gray!30] (\\xgrid,-1) -- (\\xgrid,1);\n\t\t\t\\draw[very thin,gray!30] (-1,\\ygrid) -- (1,\\ygrid);\n\t\t}\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% Extend axis backwards\n\t\t%---------------------------------------------------------------------------------\n\t\t\\draw[dashed] (0,0,0) -- ( -1, 0, 0);\n\t\t\\draw[dashed] (0,0,0) -- (  0, -1, 0);\n\t\t%\\draw[dashed] (0,0,0) -- ( 0, 0, -1);\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% Plot new frame axis\n\t\t%---------------------------------------------------------------------------------\n\t\t\\draw[->, bluemat] (0,0,0) -- ( 0.5000,  0.5000, 0.7071) node[anchor=south]{${}^bx$};\n\t\t\\draw[->, redmat](0,0,0) -- (-0.8536,  0.1464, 0.5000) node[anchor=south]{${}^by$};\n\t\t\\draw[->, yellowmat]  (0,0,0) -- ( 0.1464, -0.8536, 0.5000) node[anchor=west]{${}^bz$};\n\t\t\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for XX axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, bluemat] (0.5000, 0, 0) -- ( 0.5000, 0.5000, 0) node[pos=0.5, anchor=west]{\\small $r_{xy}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, bluemat] ( 0, 0.5000, 0) -- ( 0.5000, 0.5000, 0) node[pos=0.5, anchor=south]{\\small $r_{xx}$};\n\t\t% dashed lines z\n\t\t%\\draw[dashed, bluemat] ( 0.5000, 0.5000, 0) -- ( 0.5000,  0.5000, 0.7071) node[pos=0.5, rotate=90, anchor=north]{\\small $r_{xz}$};\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for YY axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, redmat] (-0.8536, 0, 0) -- (-0.8536, 0.1464, 0) node[pos=0.5,anchor=east]{\\small $r_{yy}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, redmat] (0, 0.1464, 0) -- (-0.8536, 0.1464, 0) node[pos=0.5, anchor=south]{\\small $r_{yx}$};\n\t\t% dashed lines z\n\t\t%\\draw[dashed, redmat] (-0.8536, 0.1464, 0) -- (-0.8536,  0.1464, 0.5000) node[pos=0.5,rotate=90,anchor=south]{\\small $r_{yz}$};\n\t\t%---------------------------------------------------------------------------------\n\t\t% guides for ZZ axis\n\t\t%---------------------------------------------------------------------------------\n\t\t% dashed lines x\n\t\t\\draw[dashed, yellowmat] (0, -0.8536, 0) -- ( 0.1464, -0.8536, 0) node[pos=0.5,anchor=north]{\\small $r_{zx}$};\n\t\t% dashed lines y\n\t\t\\draw[dashed, yellowmat] (0.1464, 0, 0) -- ( 0.1464, -0.8536, 0) node[pos=0.5,anchor=west]{\\small $r_{zy}$};\n\t\t% dashed lines z\n\t\t%\\draw[dashed, yellowmat] ( 0.1464, -0.8536, 0) -- ( 0.1464, -0.8536, 0.5000) node[pos=0.5,rotate=90,anchor=north]{\\small $r_{zz}$};\n\t\t\n\t\t% Draw main coordinate system\n\t\t\\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{${}^ax$};\n\t\t\\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{${}^ay$};\n\t\t%\\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{${}^az$};\n\t\t\n\t\t\\end{tikzpicture}\n\t\t\n\t}\n\t\\caption[Two frames axes example]{Two frames axes example}\n\t\\label{fig:frame_axis_example}\n\\end{figure}\n\n\nThe rotation matrix is a tool used to describe transformation of coordinates\nfrom one frame to another and this also describe orientation of one frame\nrelative to another frame. The convention used in this work is represented by \\eqref{eq:rotation_matrix} and maps quantities described in frame $b$ to\nframe $a$. Comparing the structure of \\eqref{eq:rotation_matrix} with\nfigure \\ref{fig:frame_axis_example} it is seen that columns of ${}^a_bR$\nrepresent each unity vector defining all axes of frame $b$.\n\n\n\n\\begin{equation}\n{}^a_bR=\\begin{bmatrix}\n{}^ar_{xx} & {}^ar_{yx} & {}^ar_{zx}\\\\\n{}^ar_{xy} & {}^ar_{yy} & {}^ar_{zy}\\\\\n{}^ar_{xz} & {}^ar_{yz} & {}^ar_{zz}\n\\end{bmatrix}\n\\label{eq:rotation_matrix}\n\\end{equation}\n\nRotation matrices belong to the orthonormal group and one important property\nis that ${}^a_bR{}^a_bR^T=I$ meaning ${}^a_bR^T = {}^a_bR^{-1}$. Also\n${}^a_bR^T$ is equal to ${}^b_aR$\n\\cite{Sequeira2016}\\cite{wiki_rotationtheorem}.\n\n\nEuler angles are another form to describe orientation of one frame relative to\nanother by defining three angles. The Euler angles convention adopted in this\nwork is the Tait–Bryan \\gls{intrinsic} rotation sequence Z-Y-X, meaning\nreferential $a$ axes, represented in figure \\ref{fig:frame_axis_example}, can be\nmapped into referential $b$ by performing sequential rotations, first along ZZ\naxis by an angle $\\psi$, second along the resulting YY axis by an angle $\\theta$\nand final rotation along the resulting XX axis by an angle $\\phi$. In figure\n\\ref{fig:frame_axis_example_euler} is represented the sequence necessary to\nrotate frame $a$ into frame $b$ with the respective Euler angles to achieve the\nsame orientation as expressed in figure \\ref{fig:frame_axis_example}. It is also\nrepresented the intermediary axes resulting from each sequential rotation and it\npositive direction. Each individual rotation is expressed by is own rotation\nmatrix using the respective Euler angle associated and the final orientation is\nthe result of successive matrices multiplications as shown in equation\n\\ref{eq:rotMat_composition} where the intermediary axes sequence is denoted as\nexpressed in the figure \\ref{fig:frame_axis_example_euler}.\n\n\\begin{equation}\n\\begin{aligned}\n{}^b_aR&={}^b_2R_x(\\phi){}^2_1R_y(\\theta){}^1_aR_z(\\psi)\\\\\n&=\\begin{bmatrix}\n\\cos(\\psi)\\cos(\\theta) \t\t\t\t\t\t\t\t  & \\sin(\\psi)\\cos(\\theta) \t\t\t\t\t\t\t\t  & -\\sin(\\theta)         \\\\\n\\cos(\\psi)\\sin(\\theta)\\sin(\\phi)-\\sin(\\psi)\\cos(\\phi) & \\cos(\\psi)\\cos(\\phi)+\\sin(\\psi)\\sin(\\theta)\\sin(\\phi) & \\cos(\\theta)\\sin(\\phi)\\\\\n\\sin(\\psi)sin(\\phi)+\\cos(\\psi)\\sin(\\theta)\\cos(\\phi)  & \\sin(\\psi)\\sin(\\theta)\\cos(\\phi)-\\cos(\\psi)\\sin(\\phi) & \\cos(\\theta)\\cos(\\phi)\n\\end{bmatrix}\n%\t\t\t\t  \\begin{bmatrix} % the usual transpose\n%\t\t\t\t  \\cos(\\psi)\\cos(\\theta) & \\cos(\\psi)\\sin(\\theta)\\sin(\\phi)-\\sin(\\psi)\\cos(\\phi) & \\sin(\\psi)sin(\\phi)+\\cos(\\psi)\\sin(\\theta)\\sin(\\phi)\\\\\n%\t\t\t\t  \\sin(\\psi)\\cos(\\theta) & \\cos(\\psi)\\cos(\\phi)+\\sin(\\psi)\\sin(\\theta)\\sin(\\phi) & \\sin(\\psi)\\sin(\\theta)\\cos(\\phi)-\\cos(\\psi)\\sin(\\phi)\\\\\n%\t\t\t\t  -\\sin(\\theta)\t\t   & \\cos(\\theta)\\sin(\\phi)\t\t\t\t\t\t\t\t   & \\cos(\\theta)\\cos(\\phi)\n%\t\t\t\t  \\end{bmatrix}\n\\end{aligned}\n\\label{eq:rotMat_composition}\n\\end{equation}\n\n\\begin{figure}[!hbt]\n\t\\centering\n\t% Set the plot display orientation\n\t% Syntax: \\tdplotsetdisplay{\\theta_d}{\\phi_d}\n\t\\tdplotsetmaincoords{75}{120}\n\t\n\t\\pgfmathsetmacro{\\zRot}{45}\n\t\\pgfmathsetmacro{\\yRot}{-45}\n\t\\pgfmathsetmacro{\\xRot}{45}\n\t%%%%%% Change the rotation matrix in order to use Tait-Bryan angles\n\t\\tdseteulerxyz\n\t%%%%%%%%%%%%% Z-Y-X\n\t\\begin{tikzpicture}[scale=4,tdplot_main_coords]\n\t\\foreach \\xgrid in {-1,-0.9,...,1.1}\n\t\\foreach \\ygrid in {-1,-0.9,...,1.1}\n\t{\n\t\t\\draw[very thin,gray!30] (\\xgrid,-1) -- (\\xgrid,1);\n\t\t\\draw[very thin,gray!30] (-1,\\ygrid) -- (1,\\ygrid);\n\t}\n\t\n\t%---------------------------------------------------------------------------------\n\t% Extend axis backwards\n\t%---------------------------------------------------------------------------------\n\t\\draw[dashed] (0,0,0) -- ( -1, 0, 0);\n\t\\draw[dashed] (0,0,0) -- (  0, -1, 0);\n\t%\\draw[dashed] (0,0,0) -- ( 0, 0, -1);\n\t% Set origin of main (body) coordinate system\n\t\\coordinate (O) at (0,0,0);\n\t\n\t% Draw main coordinate system\n\t\\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{\\tiny ${}^ax$};\n\t\\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{\\tiny ${}^ay$};\n\t\\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{\\tiny ${}^az$};\n\t\n\t%Draws arc representing the rotated angle.\n\t\\tdplotdrawarc[thick,tdplot_main_coords,->, color=black]{(0,0,0)}{0.5}{0}{\\zRot}{anchor=north,color=black}{\\tiny $\\psi$}\n\t%Draws circle representing the rotated planes. Each of these should be \"pointed\" by two arrows.\n\t\\tdplotdrawarc[dashed,tdplot_main_coords,->, color=black]{(0,0,1)}{0.1}{0}{359}{}{}\n\t\n\t\n\t\n\t% First intrinsic rotation\n\t\\tdplotsetrotatedcoords{\\zRot}{0}{0}\n\t\\draw[thick,tdplot_rotated_coords,->, yellowmat] (0,0,0) -- (0.9,0,0) node[anchor=west]{\\tiny ${}^1x$};\n\t\\draw[thick,tdplot_rotated_coords,->, yellowmat] (0,0,0) -- (0,0.9,0) node[anchor=west]{\\tiny ${}^1y$};\n\t\\draw[thick,tdplot_rotated_coords,->, yellowmat] (0,0,0) -- (0,0,0.9) node[anchor=north west]{\\tiny ${}^1z$};\n\t\n\t% make xy plane in vertical to mark angle\n\t\\tdplotsetrotatedcoords{\\zRot}{0}{90}\n\t\\tdplotdrawarc[thick,tdplot_rotated_coords,->,color=yellowmat]{(0,0,0)}{0.5}{0}{-\\yRot}{anchor=west,color=yellowmat}{$\\theta$}\n\t\\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=yellowmat]{(0,0,-0.9)}{0.1}{0}{-359}{}{}\n\t%\t% auxiliary axis to confirm correct plan\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (1,0,0) node[anchor=north east]{${}^tx$};\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,1,0) node[anchor=north west]{${}^ty$};\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,1) node[anchor=south]{${}^tz$};\n\t\n\t% second intrinsic rotation\n\t\\tdplotsetrotatedcoords{\\zRot}{\\yRot}{0}\n\t\\draw[thick,tdplot_rotated_coords,->, redmat] (0,0,0) -- (0.8,0,0) node[anchor=west]{\\tiny ${}^2x$};\n\t\\draw[thick,tdplot_rotated_coords,->, redmat] (0,0,0) -- (0,0.8,0) node[anchor=north]{\\tiny ${}^2y$};\n\t\\draw[thick,tdplot_rotated_coords,->, redmat] (0,0,0) -- (0,0,0.8) node[anchor=south]{\\tiny ${}^2z$};\n\t\n\t% make xy plan in vertical to mark angle b\n\t\\tdplotsetrotatedcoords{90+\\zRot}{0}{\\xRot}\n\t\\tdplotdrawarc[thick,tdplot_rotated_coords,->,color=redmat]{(0,0,0)}{0.5}{0}{\\xRot}{anchor=west,color=redmat}{$\\phi$}\n\t\\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=redmat]{(0,0,0.8)}{0.1}{0}{359}{}{}\n\t%\t% auxiliary axis to confirm correct plan\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (1,0,0) node[anchor=north east]{${}^tx$};\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,1,0) node[anchor=north west]{${}^ty$};\n\t%\t\\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,1) node[anchor=south]{${}^tz$};\n\t\n\t% second intrinsic rotation\n\t\\tdplotsetrotatedcoords{\\zRot}{\\yRot}{\\xRot}\n\t\\draw[thick,tdplot_rotated_coords,->, bluemat] (0,0,0) -- (1,0,0) node[anchor=west]{\\tiny ${}^bx$};\n\t\\draw[thick,tdplot_rotated_coords,->, bluemat] (0,0,0) -- (0,1,0) node[anchor=west]{\\tiny ${}^by$};\n\t\\draw[thick,tdplot_rotated_coords,->, bluemat] (0,0,0) -- (0,0,1) node[anchor=south]{\\tiny ${}^bz$};\n\t\n\t\\end{tikzpicture}\n\t\\caption[Two frames axes example - Euler angles]{Two frames axes example - Euler angles. In this case, the angles are $\\psi=45^o, \\theta=-45^o, \\phi=45^o$}\n\t\\label{fig:frame_axis_example_euler}\n\\end{figure}\n\n\\section{Quaternion} \\label{section:quaternion}\n\nDuring the work an \\gls{AHRS} algorithm based on \\cite{Madgwick2010_report} and derived in \\cite{thesis_BT} is implemented  and it uses quaternions. Basic definitions for understanding the filter terminology  are explained in this section following the same notation as present by \\cite{thesis_BT} in case the user as no notion of quaternions at all.\n\nQuaternion is a complex number in four dimension that can be used, similar to rotation matrices and Euler angles, to represent orientation of frames with respect to others. The Euler rotation theorem and the Rodriguez formula are the basis for quaternion representation of rotations but will not be discussed. The theorem states it is possible to describe an orientation of frame relative to other by performing a rotation of $\\alpha$ along an axis $r$ that is defined by the points that remain static relative to the original frame. \\cite{quaternions} quickly resumes the main idea about quaternions, why they can be used to express orientations and relation between them and Euler and Rodriguez formulations. \n\nA quaternion can be represented by \\eqref{eq:quaternion_definition} where $q_1$ is the norm of it, $q_2, q_3$ and $q_4$ are complex coordinates with \\textit{i, j, k} being the axis versors. If a quaternion is normalized, it is denoted with a circumflex accent as shown in \\eqref{eq:quaternion_normalized}.\n\n\\begin{equation}\n\\centering\n\\begin{aligned}\nq &=q_1+q_2i+q_3j+q_4k\\\\\nq &= [q_1\\, q_2\\, q_3\\, q_4]\n\\end{aligned}\n\\label{eq:quaternion_definition}\n\\end{equation}\n\n\\begin{equation}\n\\centering\n\\hat{q} \\implies \\|q\\|=1\n\\label{eq:quaternion_normalized}\n\\end{equation}\n\nUsing the same notation as stated before, ${}^w_bq$ represent the orientation of body frame with respect to world frame. With \\eqref{eq:quaternion_definition} in mind, the following list of properties/operations are summarized in this \\hyperref[list:quaternion_operations]{list}:\n\n\\begin{description}[]\n\t\\label{list:quaternion_operations}\n\t\\item [Identities] All quaternions multiplications must obey to the following set of properties described in equation \\ref{eq:quaternion_identities}.\n\t\\begin{subequations}\n\t\t\\label{eq:quaternion_identities}\n\t\t\\begin{equation}\n\t\ti^2=j^2 = k^2 = ijk = -1\n\t\t\\end{equation}\n\t\t\\begin{equation}\n\t\tij =-ji=k\n\t\t\\end{equation}\n\t\t\\begin{equation}\n\t\tjk =-kj=i\n\t\t\\end{equation}\n\t\t\\begin{equation}\n\t\tki =-ik= j\n\t\t\\end{equation}\n\t\\end{subequations}\n\t\\item [Quaternion multiplication] The quaternions multiplication, denoted by $\\otimes$, is defined by the Hamilton product as in equation \\ref{eq:quaternion_product}\n\t\\begin{equation}\n\t\\begin{aligned}\n\ta \\otimes b &= [a_1\\, a_2\\, a_3\\, a_4] \\otimes [b_1\\, b_2\\, b_3\\, b_4]\\\\\n\t&= \\begin{bmatrix}\n\ta_1b_1 -a_2b_2 -a_3b_3 -a_4b_4\\\\\n\ta_1b_2 +a_2b_1 +a_3b_4 -a_4b_3\\\\\n\ta_1b_3 -a_2b_4 +a_3b_1 +a_4b_2\\\\\n\ta_1b_4 +a_2b_3 -a_3b_2 +a_4b_1\n\t\n\t\\end{bmatrix}^T\n\t\\end{aligned}\n\t\\label{eq:quaternion_product} \n\t\\end{equation}\n\t\\item [Quaternion conjugate] The quaternion conjugate describes the inverse rotation and is defined as equation \\ref{eq:quaternion_conjugate}.\n\t\\begin{equation}\n\t{}^w_bq^* = {}^b_wq = [q_1\\, -q_2\\, -q_3\\, -q_4]\n\t\\label{eq:quaternion_conjugate} \n\t\\end{equation}\n\t\\item [Vector rotation] Let's define the following quaternion representation of the same vector but in each referential by using is \\gls{pure quaternion} as ${}^wv = [0\\,{}^wx\\,{}^wy\\,{}^wz]$ and ${}^bv = [0\\,{}^bx\\,{}^by\\,{}^bz]$. The rotation of vector $v$ from one frame to other, using a quaternion, is performed by equation \\ref{eq:quaternion_rotation}.\n\t\\begin{equation}\n\t{}^bv = {}^w_b\\hat{q} \\otimes {}^wv \\otimes {}^w_b\\hat{q}^*\n\t\\label{eq:quaternion_rotation}\n\t\\end{equation}\n\t\n\t\\item [Composed rotations] The composition of rotations can be described in quaternions as the product between quaternions. For example the sequence ${}^a_b\\hat{q} \\rightarrow {}^b_c\\hat{q}$ is equal to ${}^a_c\\hat{q}$ and is defined as equation \\ref{eq:quaternion_composed_rotation}.\n\t\\begin{equation}\n\t{}^a_c\\hat{q} = {}^b_c\\hat{q} \\otimes {}^a_b\\hat{q}\n\t\\label{eq:quaternion_composed_rotation}\n\t\\end{equation}\n\\end{description}\n\n%-------------------------------------------------------------------------------\n% Novatel part\n%-------------------------------------------------------------------------------\n\\section{Novatel OEM4-G2L FlexPak} \\label{section:novatel} \n\n\\begin{figure}[!hb]\n\t\\centering\n\t\\subcaptionbox{Novatel OEM4-G2L FlexPak receiver.\\label{subcap:novatel_receiver}}{\\includegraphics[width=0.4\\linewidth]{figures/novatel_flexpak.png}}\n\t\\subcaptionbox{Novatel GPS-701-GG antenna\\label{subcap:novatel_antenna}}{\\includegraphics[width=0.4\\linewidth]{figures/Novatel_701-GGL.png}}\n\t\\caption[Novatel GNSS devices used]{Novatel GNSS devices used (\\href{https://www.novatel.com}{source:NovAtel})}\n\t\\label{fig:novatel_devices}\n\\end{figure}\n\nEach  Novatel GPS sensor is composed with Novatel OEM4-G2L FlexPak receiver and\nNovatel high performance GPS-701-GG antenna. The Novatel OEM4-G2L FlexPak\nreceiver provides position and velocity estimations using GPS broadcasted\nsatellites radio signals. It has two communications ports that can be configured\nindependently. Additional to common GPS protocols, it has support for custom\nNovatel protocols (which will be used) providing the best possible estimation\nthe receiver can do making it as simple as possible from the point of view of\nuser. The receiver can handle both L1 and L2 signals provided by satellites\n\\cite{NovAtel2005_volume1}, however, antenna module only can handle L1 frequency\nsignal (1575.42MHz)\\cite{NovAtel2013_antenna}. Power supply to FlexPak enclosure\nshould range from 6 to 18 volts DC with typical consumption of 5W. Without\ndifferential GPS methods, the Novatel receiver can achieve up to 1.8 meters\nprecision \\gls{CEP} with single point operation. Output logs data rate is up to\n20Hz in binary mode and 10Hz in ASCII format.\n\nSince the receivers used are industrial grade, no particular effort is made to modeling any error source or trying to improve the solution given by it. However is important to have minimal knowledge the limitations of those types of receivers. It is trusted that the reported position and velocity information is the best the sensor could possibly estimate.\n\nThe developed library interface full documentation is present in the attach appendix \\ref{appendix:novatel}, however is advised to use the online version for granting the most recent \\href{https://novatel-oem4-python.readthedocs.io/en/latest/}{updated documentation}.\n\n\\subsection{GNSS main errors}\\label{subsection:GNSS_main_errors}\n\nThe main cause of \\gls{GNSS} calculations errors are presented in table \\ref{tab:gnss_error_source}.\nWhile some can't be controlled by user (satellite clocks, orbit clocks), others can be mitigated using differential GNSS techniques, multi-frequency (currently civilians have access to more than one), satellite based augmentations system and multi-constellation or using modeling the error source. Multipath is probably the most user dependent but in some situations hard to avoid for example in streets surround with high buildings general denoted as urban canyons.\n\n\n\\begin{table}[!htb]\n\t\\centering\n\t\\begin{tabular}{lc}\n\t\t\\toprule\n\t\t\\textbf{Source}\t\t& \\textbf{Value (up to)}\\\\\n\t\t\\midrule\n\t\tSatellite clocks\t& $\\pm2$m\\\\\n\t\tOrbit Errors\t\t& $\\pm2.5$m\\\\\n\t\tInospheric Delays\t& $\\pm5$m\\\\\n\t\tTropospheric Delays & $\\pm0.5$m\\\\\n\t\tReceiver Noise\t\t& $\\pm0.3$m\\\\\n\t\tMultipath\t\t\t& $\\pm1$m\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\caption[Main source of errors in calculations using GNSS]{Main source of errors in calculations using GNSS \\cite{NovatelIntroGNSS}}\n\t\\label{tab:gnss_error_source}\n\\end{table}\n\\vfill\n\n%-------------------------------------------------------------------------------\n% Razor related stuff\n%-------------------------------------------------------------------------------\n\\section{Sparkfun Razor IMU 9DOF} \\label{section:sparkfun}\n\n\\begin{figure}[!htb]\n\t\\centering\n\t\\includegraphics[width=0.5\\linewidth]{figures/10125-04b.jpg}\n\t\\caption[Razor 9DOF IMU.]{Razor 9DOF IMU.}\n\t\\label{fig:razor9dof}\n\\end{figure}\n\nRazor IMU \\glsdisp{9DOF}{9DOF} is an electronics board, developed by\n\\href{http://www.sparkfun.com/}{Sparkfun Electronics}, which includes an\naccelerometer, a gyroscope and a magnetometer, each one with three axis of\nsensibility. Since this board is based on the\n\\href{https://www.arduino.cc/}{Arduino project}, the chip sensors are\ninterconnected by an Atmel\\textsuperscript{\\textregistered} ATmega328p \\gls{MCU}\nwhich allows the configuration of sensors, handles the readings and processing\nof their respective outputs. \n\n\n%-------------------------------------------------------------------------------\n% ADXL345 part\n%-------------------------------------------------------------------------------\n\\subsection{ADXL345 Digital Accelerometer} \\label{subsection:adxl345}\n\n\nThe ADXL345 is a \\gls{MEMS} sensor with three axis accelerometer made by\n\\href{http://http://www.analog.com/en/index.html}{Analog Devices} . It has an\nadjustable acceleration scale range value up to $\\pm16g$. It is possible to\nmeasure both dynamic accelerations resulting from motion and shock or measure\nstatic accelerations such as gravity, which allows this device to be used as a\ntilt sensor also. Acceleration deflects the a proof mass attached to one differential capacitor plate and unbalances it, resulting in a sensor output whose amplitude is\nproportional to acceleration \\cite{adxl345_datasheet}.Conversion of outputs is made through 10 to 13 bit \\gls{ADC} according to selected\nrange to maintain the same scale of 4mg/LSB. \n\n\n\\subsubsection{Accelerometer sensor model}\\label{subsubsection:adxl345model}\n\nThe output of accelerometer is proportional to the sum of acceleration in each\naxis. However the accelerometer is not capable of distinguish if the\nacceleration is caused by a true acceleration produced by motion or produced by\na static force, generally gravity force. As so, equation \\eqref{eq:accel_model}\ndescribes the general output of accelerometer \\cite{Vectornav_calibration}\nwhere, ${}^bA_{ext}$ is the sum of real external acceleration due to\nlinear or rotational dynamics in the body frame, ${}^b_wR$ is the rotation\nmatrix mapping quantities in world frame into sensor frame, ${}^wg $\nrepresents the fictitious acceleration due to gravity in the world frame, ${}^bA_{0}$ is an offset and\n$\\delta A_{\\epsilon}$ describes addictive gaussian noise.\nIdeally, $G$ should be equal to identity matrix but in fact it represents the\nproduct of two matrices, one describing the cross-axis influence and the other\na scale factor for each axis \\cite{Vectornav_calibration}.\n\n\\begin{equation}\n{}^bA_{s}=G[{}^bA_{ext} + {}^b_wR\\,{}^wg\\,] + {}^bA_{0} + \\delta A_{\\epsilon}\n\\label{eq:accel_model}\n\\end{equation}\n\n\\subsubsection{Accelerometer calibration}\\label{subsubsection:adxl345calibration}\n\nThe suggested calibration method by the manufacturer \\cite{adxl345AN1077}\nassumes that cross-axis influence is small enough and can be neglected, this\nway, $G$ should only be represented by a diagonal matrix with the scale factors\nfor each axis. However, if more precision for the application is needed,\ncalibration using the ellipsoid fitting approach should be made\n\\cite{Pylvanainen2008}.\n\nFor this application it will be used the suggested calibration by manufacturer\nresulting in exposing the sensor to six position combination while resting. This\nmeans the ${}^bA_{ext}$ will be zero and accelerometer will be only\ninfluenced by the gravity force, 1g.\n\n\\begin{figure}[!hbt]\n\t\\begin{minipage}{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{figures/adxl_calibration.png}\n\t\t\\caption[ADXL345 calibration poses and expected output.]{ADXL345 calibration\n\t\t\tposes and expected output \\cite{adxl345AN1077}.} \n\t\t\\label{fig:adxl_calibration}\n\t\\end{minipage}\n\t\\hfill\n\t\\begin{minipage}{0.49\\textwidth}\n\t\t\\renewcommand{\\arraystretch}{1.2} % more space between rows\n\t\t\\centering\n\t\t\\begin{tabular}{cc}\n\t\t\t\\toprule\n\t\t\t\\textbf{Gains and offset [LSB]} & \\textbf{Razor }\\\\\n\t\t\t\\midrule\n\t\t\tZ gain   &  253.66  \\\\\n\t\t\tZ offset & -3.47    \\\\\n\t\t\tY gain\t & 266.27    \\\\\n\t\t\tY offset & -3.18     \\\\\n\t\t\tX gain   & 266.04   \\\\\n\t\t\tX offset & 13.83\t\\\\\n\t\t\t\\bottomrule\n\t\t\\end{tabular}\n\t\t\\captionof{table}{Summary of values extracted and calculated for each axis of accelerometer in both sensors}\n\t\t\\label{tab:adxl_summary}\n\t\\end{minipage}\n\\end{figure}\n\nAligning one axis at a time with gravity vector, as seen in figure\n\\ref{fig:adxl_calibration}, the mean value of several samples is calculated.\nUsing these means for each axis and the known acceleration\nvalues(\\ensuremath{\\pm}1g), it is calculated the slope and offset of the\nrespective line passing through the two points. Calculated values (see table \\ref{tab:adxl_summary}) will be stored\nin the internal \\glsdisp{EEPROM}{EEPROM} memory of \\gls{MCU} to be loaded at\nboot time of each razor. The conversion between LSB and g unities is given by\nthe relation $254LSB/g$ or $3.9mg/LSB$ \\cite{adxl345_datasheet}\n\n%-------------------------------------------------------------------------------\n% ITG3200 part\n%-------------------------------------------------------------------------------\n\\subsection{ITG3200 Digital Gyroscope} \\label{subsection:itg3200}\n\nThe ITG-3200 is a microelectronic mechanical integrated circuit chip with three\naxis independent gyroscopes, built by\n\\href{http://www.invensense.com/}{Invensense} able of measuring angular\nvelocities up to $\\pm2000\\degree/s$. When the gyroscopes are rotated about any\nof the sensor axes, the Coriolis effect causes a deflection that is  detected by\na capacitive pick-off circuit proportional to angular velocity. The measured signal is filtered and converted using internal \\gls{ADC}. The scale factor that allow to convert the\noutput values to angular velocities in degrees per second is, according to its\ndatasheet \\cite{itg3200_datasheet}, factory calibrated and equal to\n$14.375LSB/\\degree.s^{-1}$.\n\n\\subsubsection{Gyroscope sensor model} \\label{subsubsection:itg3200model}\n\n\nFor a given axis, the gyroscope output is proportional the angular velocity\nsensed of that axis and is given by equation \\eqref{eq:gyro_model} where\n${}^b\\omega_{s}$ represents the vector output of the sensor in body\nframe at instant $t$, ${}^b\\omega_{real}$ is the real angular velocity\nvector applied to sensor in body frame, ${}^b\\omega_{0}$ is the bias\nvector term and $\\delta\\omega_{\\epsilon}$ addictive gaussian noise.\nSince the sensor is described in \\cite{itg3200_datasheet} as factory calibrated,\n$G$ which represent a scaled factor correction, is expected to be equal to\nidentity matrix. Note that the equation model \\eqref{eq:gyro_model} is in fact a\nsimplified version of a more accurate model described in\n\\cite{Vectornav_calibration}. As stated in \\cite{Vectornav_calibration}\ncross-axis misalignment and linear acceleration sensitivity are expected to be\nsmall for the application purpose so they are considered irrelevant.\n\nIn general, the offset value depends on the temperature value inside chip. Once\ninternal stability is reached, offset values tends to be constant \\cite{Woodman2007}. Electrical\ntemperature stability can be achieved after a few minutes of operation. At the\nbeginning of initialization of Razor, several samples are acquired internally in\nthe microprocessor and  mean value is calculated for each axis, defining this\nway the offset constant for each axis.\n\n\n\\begin{equation}\n{}^b\\omega_{s}=G\\,{}^b\\omega_{real} + {}^b\\omega_{0} + \\delta\\omega_{\\epsilon}\n\\label{eq:gyro_model}\n\\end{equation}\n\n%-------------------------------------------------------------------------------\n% HMC5843 part\n%-------------------------------------------------------------------------------\n\\subsection{HMC5843 Digital compass} \\label{subsection:hmc5843} \n\nThe HCM5843 sensor is a digital compass chip designed by\n\\href{https://www.honeywell.com}{Honeywell}, designed for low field magnetic\nsensing. This sensor uses anisotropic magnetic resistor technology, making it\nimmune to vibration noises, and the use of Wheatstone bridge makes it more\nrobust to noise. A material with anisotropic magnetic resistor properties\nchanges its resistance according to absolute value and direction of magnetic\nfield. \n\n\\subsubsection{Magnetometer model}\n\nThe magnetometer sensor model follows a similar structure as two previous\nsensors and is given by equation \\eqref{eq:mag_model}. The ${}^bH_{s}$ is\nthe value sensed by the sensor in body frame. $C$ is a matrix resulting from\nthe multiplication of matrices containing influence of cross-axis, gain scale\nfactor and soft-iron interference \\cite{magAN4246}. ${}^wh_e$ represent\nthe geomagnetic vector of Earth, ${}^bh_{offset}$ is an offset vector which\ndescribes the influence of zero-field offset and the ferromagnetic masses fixed\nrelative to body frame usually denoted as hard-iron. $\\delta h_{\\epsilon}$ \nrepresents gaussian additive noise.\n\n\\begin{equation}\n{}^bH_{s}=C\\,{}^b_wR{}^wh_e\\, + {}^bh_{offset} + \\delta h_{\\epsilon}\n\\label{eq:mag_model}\n\\end{equation}\n\n\n\\subsubsection{Geomagnetic field}\\label{subsubsection: geomagnetic_field}\n\nThe geomagnetic field can be described as 3D vector in each point as seen in\n\\cite{ipma_geomagnetism}. As previous defined, ${}^wh_e$ represent the\ngeomagnetic vector of Earth. Let us define now, ${}^wh_0$ as the\nhorizontal projection of ${}^wh_e$. The angle between ${}^wh_0$ and\n${}^wh_e$ is denominated as inclination, $I$. As stated in\n\\cite{ipma_geomagnetism}, the horizontal projection of the geomagnetic vector\npoints to the magnetic north which may not be aligned with the north axis of\nreference frame, ${}^wY$. This defines the magnetic declination angle, $D$, as the\nangle between horizontal projection and the ${}^wY$ axis.\n\nFor Lisbon, the magnetic declination angle, in January 2017, defined in the reference\nframe is equal to 2.48\\degree, inclination angle is equal to 52.77\\degree and\nthe ${}^wh_e$ is equal to $[-1121.5, 26479.8, -34884.7]^T$ nanoteslas\n\\cite{noaa}\n\n\n\n\n\\subsubsection{Hard and soft-iron compensation}\n\nThe compensation for hard and soft-iron effects can be done using a geometric\napproach as described by \\cite{magAN4246} \\cite{Caruso2000}\n\\cite{Vasconcelos2011}. If the geomagnetic vector is known and sensor perfect\ncalibrated, free of any type ambient distortion, points collected are expected\nto belong a surface of an origin centered sphere with radius equal to the\nmagnitude of geomagnetic field ${}^wh_e$. Distortions, cross-axis\ninfluence, scale-factor inequalities between axis, causes the expected sphere to\nbe deformed into a ellipsoid. Collecting points in 3D space by performing\nrotations of the sensor frame, allow us to fit the data to an ellipsoid surface\nand after determinate the matrix $C$ and offset vector ${}^bh_{offset}$.\n\nHowever since the body frame is a vehicle, it is not physically possible to\ncollect points based in rotations of YY and XX axis. Only ZZ axis rotations are\navailable and the data instead of belonging to an ellipsoid surfaces, will\nbelong to an ellipse in Z-plane as a result from that plan cutting the ellipsoid\nin some undetermined z coordinate. Because of restriction stated before it will\nbe considered that the influence in ZZ axis is zero and the scale\nfactor is equal to one. Offset in ZZ axis will also be considered zero. In \\cite{thesis_BT} is shown that this assumption is not relevant. \\eqref{eq:mag_model} will be rearranged to equation \\eqref{eq:mag_model1}\nform.\n\n\\begin{equation}\n\\begin{aligned}\n{}^bH_{s}&=C\\,{}^b_wR{}^wh_e\\, + {}^bh_{offset} + \\delta h_{\\epsilon}\\\\\n{}^b_wR{}^wh_e &=C^{-1}[{}^bH_{s}-{}^bh_{offset} - \\delta h_{\\epsilon}] \\\\\n\\end{aligned}\n\\label{eq:mag_model1}\n\\end{equation}\n\nWithout loss of generality, $C^{-1}\\delta h_{\\epsilon}$ will result\nalso in a gaussian vector so it will be rewritten as $\\delta\nh_{\\epsilon}$. Equation \\eqref{eq:mag_model1} can take now be arranged into \\eqref{eq:mag_model2} where ${}^bH_{c}$ is the corrected value\nafter calibration process.\n\n\\begin{equation}\n\\begin{aligned}\n{}^b_wR(t){}^wh_e &=C^{-1}[{}^bH_{s}-{}^bh_{offset} - \\delta h_{\\epsilon}] \\\\\n{}^bH_{c} &= C^{-1}[{}^bH_{s}-{}^bh_{offset}] + \\delta h_{\\epsilon}\n\\end{aligned}\n\\label{eq:mag_model2}\n\\end{equation}\n\nThe matrix $C^{-1}$ and ${}^bh_{offset}$ is obtained as described by\n\\cite{Caruso2000} using the\n\\textit{ellipse\\_fit}\\footnote{\\href{https://www.mathworks.com/matlabcentral/fileexchange/22423-ellipse-fit}{https://www.mathworks.com/matlabcentral/fileexchange/22423-ellipse-fit}}. The function \\textit{ellipse\\_fit} returns the least square estimate that best fits the data collected from sensor and the parameters that define the estimated ellipse as described in \\hyperref[list:ellipsfit_out]{this list}:\n\n\\begin{itemize}[noitemsep]\n\t\\label{list:ellipsfit_out}  \n\t\\item \\textbf{semi-major} - The length of major semi axis of ellipse. \n\t\\item \\textbf{semi-minor} - The length of minor semi axis of ellipse. \n\t\\item $\\bm{x_0}$ - The offset in the XX axis of ellipse.\n\t\\item $\\bm{y_0}$ - The offset in the YY axis of ellipse.\n\t\\item $\\bm{\\alpha}$ - Rotation angle between semi-major axis and XX axis in reference frame.\n\\end{itemize}\n\n\\begin{figure}[!htb]\n\t\\centering\n\t\\includegraphics[width=0.7\\linewidth]{figures/mag_calibration_steps.png}\n\t\\caption[Calibration steps of ellipse data]{Simulation of the calibration steps applied to hypothetical ellipse data.}\n\t\\label{fig:mag_cal_steps_fig}\n\\end{figure}\n\nTake note the fact that since is not physically possible to perform rotations in\n3D space, the calibration will only be reflect the XX and YY axis. Using the\nvalues returned, the calibration process consists in the following sequential\nsteps:\n\n\\circled{1} Remove offset by using equation \\eqref{eq:mag_cal_step1} with ${}^bh_{offset} = [{}^bx_0, {}^by_0, 0]^T$\n\n\\begin{equation}\n{}^bH_{s}={}^bH_{s}-{}^bh_{offset}\n\\label{eq:mag_cal_step1}\n\\end{equation}\n\n\\circled{2} Align semi-major axis of ellipse with the XX axis of reference frame using a rotation of $-\\alpha$ by using equation \\eqref{eq:mag_cal_step2}\n\n\\begin{equation}\n\\begin{aligned}\n{}^bH_{s}&=R_{cal}\\,{}^bH_{s}\\Leftrightarrow\\\\\n\\Leftrightarrow{}^bH_{s}&=\\begin{bmatrix}\n\\cos(\\alpha) & -\\sin(\\alpha) & 0\\\\\n\\sin(\\alpha) & \\cos(\\alpha)  & 0\\\\\n0\t\t\t & 0\t\t\t & 1\n\\end{bmatrix}{}^bH_{s}\n\\end{aligned}\n\\label{eq:mag_cal_step2}\n\\end{equation}\n\n\\circled{3} Apply a scaling matrix $S$ to make semi-major axis the same length as semi-minor axis using \\eqref{eq:mag_cal_step3}\n\n\\begin{equation}\n\\begin{aligned}\n{}^bH_{s}&=S\\,{}^bH_{s}\\Leftrightarrow\\\\\n\\Leftrightarrow{}^bH_{s}&=\\begin{bmatrix}\n\\frac{semi-minor}{semi-major} & 0 & 0\\\\\n0 & 1 & 0\\\\\n0 & 0 & 1\n\\end{bmatrix}{}^bH_{s}\n\\end{aligned}\n\\label{eq:mag_cal_step3}\n\\end{equation}\n\n\\circled{4} Restore the initial rotation $\\alpha$ to the scaled data using the transpose of $R_{cal}$ as seen in \\eqref{eq:mag_cal_step4}\n\n\\begin{equation}\n\\begin{aligned}\n{}^bH_{s}&=R^T_{cal}\\,{}^bH_{s}\\Leftrightarrow\\\\\n\\Leftrightarrow{}^bH_{s}&=\\begin{bmatrix}\n\\cos(\\alpha) & \\sin(\\alpha) & 0\\\\\n-\\sin(\\alpha) & \\cos(\\alpha)  & 0\\\\\n0\t\t\t & 0\t\t\t & 1\n\\end{bmatrix}{}^bH_{s}\n\\end{aligned}\n\\label{eq:mag_cal_step4}\n\\end{equation}\n\nThe ${}^bH_{s}$ resulting from step four is in fact the expected\ncorrected reading of sensor, ${}^bH_{c}$. In figure\n\\ref{fig:mag_cal_steps_fig} visually represented the steps applied to a\nhypothetical ellipse. Resuming, all sequential steps in one equation results in\n\\eqref{eq:mag_cal_resume}.\n\n\\begin{equation}\n{}^bH_{c}=R_{cal}\\,S\\,R^T_{cal}[{}^bH_{s}-{}^bh_{offset}]\n\\label{eq:mag_cal_resume}\n\\end{equation}\n\nComparing the structure of \\eqref{eq:mag_cal_resume} with \\eqref{eq:mag_model2} this implies that $C^{-1}$ is equal to $R_{cal}\\,S\\,R^T_{cal}$. \n\n%The results of calibration are presented for one of the devices in figure\n%\\ref{fig:mag_cal_din0} and the obtained are expressed in the table\n%\\ref{tab:mag_cal_results}. The trajectory used is not important as long as it is\n%able perform one or more rotation of the vehicle in the horizontal plan. In\n%figure \\ref{subcap:mag_cal_comparison} is shown the results before and after\n%calibration for the estimation of Euler $\\psi$ angle. It is also present the\n%estimation of the same angle using the the one of the gps unities as a reference\n%for the comparison.\n%\n%\\begin{figure}[!htp]\n%\t\\centering\n%\t\\subcaptionbox{Trajectory used for calibration.\\label{subcap:mag_cal_din0_gps}}{\\includegraphics[width=0.32\\linewidth]{Figures/mag_calibration_steps_din0_gps.pdf}}\n%\t\\hfill\n%\t\\subcaptionbox{Magnetometer calibration \\label{subcap:mag_cal_din0}}{\\includegraphics[width=0.32\\linewidth]{Figures/mag_calibration_steps_din0.pdf}}\n%\t\\hfill\n%\t\\subcaptionbox{$\\psi$ angle estimation before and after calibration of magnetometers\\label{subcap:mag_cal_comparison}}{\\includegraphics[width=0.32\\linewidth]{Figures/mag_calibration_compare.pdf}}\n%\t\\caption{Magnetometer calibration steps applied to real data}\n%\t\\label{fig:mag_cal_din0}\n%\\end{figure}\n%\n%\n%\\begin{table}[!hbt]\n%\t\\centering\n%\t\\begin{tabular}{ccc}\n%\t\t\\toprule\n%\t\t{} & \\textbf{Razor 1} \\\\\n%\t\t\\midrule\n%\t\t${}^bh_{offset}\\quad[nT]$ &[-2.5828\\, -2.1703]\\textsuperscript{T}x10\\textsuperscript{4} \\\\\n%\t\t\\addlinespace[5pt]\n%\t\t$\\alpha\\quad [deg]$ & 107.5238 \\\\\n%\t\t\\addlinespace[5pt]\n%\t\t$\\frac{semi-minor}{semi-major}$ & 0.9567\\\\\n%\t\t\\addlinespace[5pt]\n%\t\t$R_{cal}$ & $\\begin{bmatrix}\n%\t\t-0.3011 & -0.9536 & 0 \\\\\n%\t\t+0.9536 & -0.3011 & 0 \\\\\n%\t\t0\t\t &  0\t   & 1 \\end{bmatrix}$ \\\\\n%\t\t\\addlinespace[5pt]\n%\t\t$C^{-1} $ &$\\begin{bmatrix}\n%\t\t+0.9961& +0.0124 & 0\\\\\n%\t\t+0.0124& +0.9606 & 0\\\\\n%\t\t0     & 0      & 1\n%\t\t\\end{bmatrix} $\t\t \\\\\n%\t\t\\addlinespace[5pt]\n%\t\t\\bottomrule\n%\t\\end{tabular}\n%\t\\caption{Magnetometers calibration results.}\n%\t\\label{tab:mag_cal_results}\n%\\end{table}\n\n", "meta": {"hexsha": "c97c1233873d104f699bbf69a50ed2ea0ea6debb", "size": 45704, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report_05Sensors.tex", "max_stars_repo_name": "brtiberio/VIENA_Documentation_Latex", "max_stars_repo_head_hexsha": "56355afaea096b8a5c141a5ee1b173a3eb17f421", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report_05Sensors.tex", "max_issues_repo_name": "brtiberio/VIENA_Documentation_Latex", "max_issues_repo_head_hexsha": "56355afaea096b8a5c141a5ee1b173a3eb17f421", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report_05Sensors.tex", "max_forks_repo_name": "brtiberio/VIENA_Documentation_Latex", "max_forks_repo_head_hexsha": "56355afaea096b8a5c141a5ee1b173a3eb17f421", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.7323177367, "max_line_length": 711, "alphanum_fraction": 0.6810782426, "num_tokens": 14389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070808, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.4124360575305561}}
{"text": "% !TEX root = ../../../proposal.tex\n\n\\section{Factoring Group Orders of Non-Safe Primes}\n\\label{sec:ecm}\n\nAcross all scans, we collected 41,847 unique groups with non-safe primes.\nTo measure the extent to which each group would facilitate a small subgroup\nattack in a vulnerable implementation, we attempted to factor $(p-1)/2$. We\nused the GMP-ECM~\\cite{gmp-ecm-zimmerman-2012} implementation of the elliptic curve method for\ninteger factorization on a local cluster with 288 cores over a several-week\nperiod to opportunistically find small factors of the group order for each of\nthe primes.\n\n\\ECMBreakableGroups\n\n\\ECMRFCFiveFiveOneFourGroups\n\nGiven a group with prime $p$ and a generator $g$, we can check whether the\ngenerator generates the entire group or generates a subgroup by testing whether\n$g^{q_i} \\equiv 1 \\bmod p$ for each factor $q_i$ of $(p-1)/2$.  When $g^{q_i}\n\\equiv 1 \\bmod p$, then if $q_i$ is prime, we know that $q_i$ is the exact\norder of the subgroup generated by $g$; otherwise $q_i$ is a multiple of the\norder of the subgroup. We show the distribution of group order for groups using\nnon-safe primes in Table~\\ref{tab:ecm-distribution}.  We were able to\ncompletely factor $p-1$ for 4,701 primes.  For the remaining primes, we\ndid not obtain enough factors of $(p-1)/2$ to determine the group order. \n\n%We show the number of groups for which the difference in size of $\\lg(p)$ and\n%$\\lg(q_i)$ is at least 8 bits, since these subgroups are more likely to have\n%been intentionally generated \\todo{come up with better reason for why this is\n%interesting}. \n\nOf the groups where we were able to deduce the exact subgroup orders, several\nthousand had a generator for a subgroup that was either 8, 32, or 64 bits\nshorter than the prime itself.  Most of these were generated by the Xlight FTP\nserver, a closed-source implementation supporting SFTP.  It is not clear\nwhether this behavior is intentional or a bug in an implementation intending to\ngenerate safe primes.  Primes of this form would lead to a more limited\nsubgroup confinement or key recovery attack.\n\nGiven the factorization of $(p-1)/2$, and a limit for the amount of online and\noffline work an attacker is willing to invest, we can estimate the\nvulnerability of a given group to a hypothetical small subgroup key recovery\nattack. For each subgroup of order $q_i$, where $q_i$ is less than the online\nwork limit, we can learn $q_i$ bits of the secret key via an online brute-force\nattack over all elements of the subgroup. To recover the remaining bits of the\nsecret key, an attacker could use the Pollard lambda algorithm, which runs in\ntime proportional to the square root of the remaining search space. If this\nruntime is less than the offline work limit, we can recover the entire secret\nkey. We give work estimates for the primes we were able to factor and the\nnumber of hosts that would be affected by such a hypothetical attack in\nTable~\\ref{tab:ecm-breakable}.\n\nThe DSA groups introduced in RFC 5114~\\cite{rfc5114} are of particular\ninterest. We were able to completely factor $(p-1)/2$ for both Group 22 and\nGroup 24, and found several factors for Group 23. We give these factorizations\nin Table~\\ref{tab:group-order-factorization}.\nIn Table~\\ref{tab:ecm-rfc5114}, we show the amount of online and offline work\nrequired to recover a secret exponent for each of the RFC 5114 groups. In\nparticular, an exponent of the recommended size used with Group 23 is fully\nrecoverable via a small subgroup attack with 33 bits of online work and 47 bits\nof offline work.\n\n\\ECMDistributionTable\n\n\\GroupOrderFactorization\n", "meta": {"hexsha": "9ba9bf4223244f41fa021bc80f161ace36d220f0", "size": 3598, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/subgroup/paper/ecm.tex", "max_stars_repo_name": "dadrian/dissertation", "max_stars_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "papers/subgroup/paper/ecm.tex", "max_issues_repo_name": "dadrian/dissertation", "max_issues_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "papers/subgroup/paper/ecm.tex", "max_forks_repo_name": "dadrian/dissertation", "max_forks_repo_head_hexsha": "5607114fb4340c5b6e944c73ed6019006d3ebec9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.7014925373, "max_line_length": 94, "alphanum_fraction": 0.780155642, "num_tokens": 918, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4122511242052927}}
{"text": "The general idea behind this approach is simple: There exists one network which takes the futures' term structure as input and outputs a prediction of spread prices. If not specified otherwise the prices of the next business day are predicted. This is quite similar to figure~\\ref{fig:longspread} where the green data points are the input and the blue data points -- but now for the next day! -- the output. Ideally one just has to find optimal hyperparameters.\n\nThe first part of this section will be about getting familiar with the data itself. This includes a general description as well as the handling of problematic data points.\nThereafter the network architecture as well as the tunable hyperparameters will be introduced more formally.\nAt last the the results of this approach are presented in a detailed manner.\n\n\\section{Data description and data handling}\n\\label{sec:aao-data-handling}\n\nPrimarily, the available data are the prices of VIX futures since they were first issued in 2004. Supplementary there is data about the VIX itself as well as additional information about the futures: their symbol and their precise date of expiration. All of these are sampled on a daily interval. There is also minutely data available which will not be used unless explicitly mentioned.\n\n\\subsection{Input data (term structure)}\n\\label{sec:aao-input-data}\n\nThe set of term structure data includes 3,304 samples in total from March 26th, 2004 to May 5th, 2017. Each term structure consists of three up to eight legs. The legs symbolize the months when the respective future expires. The specific date of expiration is always a workday in the middle of this month. For an example term structure see table~\\ref{tab:single-termstructure} and for a graphical overview over the whole data set see figure~\\ref{fig:termstructures}. Notice how similar the legs look to each other and to the VIX from figure~\\ref{fig:vix}. To make the curvature between the term structures' legs more explicit their difference is calculated and used as network input.\n\n\\begin{table}\n\t\\centering\n\t\\caption[Single term structure with expiration dates (February 29th, 2012)]{A single term structure with expiration dates (February 29th, 2012) and corresponding long prices. The eight values are the futures' current prices for the next eight months. The expiration row shows the date the respective future expires. After expiration one can not invest in this future anymore.}\n\t\\begin{tabular}{lllllllll}\n\t\\toprule\n\t{} &      M1 &      M2 &      M3 &      M4 &      M5 &      M6 &      M7 &      M8 \\\\\n\t\\midrule\n\tValue      &   21.00 &   23.99 &   25.60 &   26.50 &   27.75 &   28.40 &   29.05 &   29.25 \\\\\n\tExpiration &  Mar 21 &  Apr 18 &  May 16 &  Jun 20 &  Jul 18 &  Aug 22 &  Sep 19 &  Oct 17 \\\\\n    \\midrule\t\n    Long Price &         &    1.38 &    0.71 &   -0.35 &    0.60 &    0.00 &    0.45 &         \\\\\n\t\\bottomrule\n\t\\end{tabular}\n \t\\label{tab:single-termstructure}\n\\end{table}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{termstructures}\n\t\\caption[Complete data set of term structures]{%\n\t\tComplete data set of term structures. Each term structure consists of at most eight legs (M1 to M8) where M1 is closest to expiration (blue). For most of the data -- except in times of crisis -- the legs with later expiration (green) have a higher price. Furthermore the general shape of the data is very similar between legs as well as similar to the VIX itself (see figure~\\ref{fig:vix}).}\n\t\\label{fig:termstructures}\n\\end{figure}\n\nOne problem for this task is missing data. If there are values for all eight months of a term structure like in table~\\ref{tab:single-termstructure} this is a \\emph{complete} sample. Consequently, when there are values missing it is an \\emph{incomplete} sample. As seen in figure~\\ref{fig:some-nice-graphics} there are especially many incomplete samples in earlier years. Because trading of futures just started it was not as established as of now. Futures are issued per month. But even though this happens regulary for each consecutive month since 2012 this was not always the case before. However, this regularity is necessary for a complete term structure. Removing all incomplete samples would shrink the dataset by $35\\%$. \nBy removing all samples before October 23th, 2006 only samples with up to two missing legs are left. This shrinks the data set by just $20\\%$ resulting in 2,656 remaining samples. The remaining incomplete samples need to be handled by the network itself.\n\n\\begin{figure}\n\t\t\\centering\n\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{number_of_samples}\n\t\t\\caption{Number of samples by year}\n\t\t\\label{fig:missing-values}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\\includegraphics[width=0.95\\linewidth]{missing_values}\n\t\t\\caption{Distribution of missing values}\n\t\t\\label{fig:weekdays}\n\t\\end{subfigure}\n\t\\caption[Number of samples by year and distribution of missing values]{%\n\t\tWhile a whole term structure consists of eight legs there is often less data available, especially in earlier years. Even though there are less samples from 2004 to 2006 there is a larger number of \\emph{incomplete} term structures, often missing up to five legs.}\n\t\\label{fig:some-nice-graphics}\n\\end{figure}\n\n\\subsection{Target data (long spread prices)}\n\\label{sec:aao-target-data}\n\nFor training a network one needs inputs as well as corresponding targets. While the term structure data set holds the necessary inputs, it is easy to calculate the target by applying \\eqref{eq:long-spread} thus getting the long spread prices (see table~\\ref{tab:single-termstructure}).\\footnote{%\n\tBecause of \\eqref{eq:spread-correlation} it is sufficient to either calculate long spreads \\emph{or} short spreads.}\nFor a complete term structure we get a complete set of spread prices consisting of six values.\nObviously the targets are the spread prices of the next term. Otherwise the network will not learn to make a prediction but an approximation of the applied formula. Because the term structure is the calculatory basis of the spread prices, they suffer from the same problem of missing data. Furthermore one has to exercise caution when expiration is close, so prediction is not made for already expired values.\n\n\\subsection{Seasonality}\n\\label{sec:seasonality}\n\nAs the original problem is finding inefficiencies in the term structure the network needs to be able to predict some recurring patterns. Therefore one might need some additional prior introducing seasonality. Some options are:\n\n\\newpage\n\n\\begin{itemize}\n\t\\item The day of the month (1st to 31st)\n\t\\item The month itself (Jan to Dec)\n\t\\item The days until expiration of the term structure's first leg (0 to 34; see figure~\\ref{fig:daystoexpiration})\n\\end{itemize}\n\nThe latter one -- the days until expiration -- has a nice property that is hopefully\\footnote{%\nUnderstanding what exactly a network actually learns is very difficult. One can not simply assume the same behavior as for humans. Most of the time one can only \\emph{hope} the own choices were correct.}\nadvantageous in this context: \nThere exist a total order. The former two are categorical by nature, e.g. without knowing about the year, January is \\emph{not smaller} than February. But it is certainly possible to count down the days until expiration. Therefore it is appropriate to model these as a simple natural number at the network's input. For the alternatives is might have been necessary to use more verbose representations like a one-hot vector.\\footnote{%\n\tA \\emph{one-hot vector} is a binary vector with the same length as there are classes. All entries are $0$, except one which holds the value $1$. The position of this $1$ denotes the corresponding class.}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{days_to_expiration}\n\t\\caption[Distribution of days to expiration for the termstructures' first leg]{%\n\t\tDistribution of days to expiration for the term structures' first leg.}\n\t\\label{fig:daystoexpiration}\n\\end{figure}\n\n\\begin{table}\n\t\\centering\n\t\\caption[Descriptive statistics for futures and spread prices]{Common descriptive statistics for futures, their legs' difference and spread prices.}\n\t\\begin{tabular}{lrrrrrrr}\n\t\t\\toprule\n\t\t{} &  Mean &  Std. &    Min. &   25\\% &   50\\% &   75\\% &  Max. \\\\\n\t\t\\midrule\n\t\tFutures & 22.38 & 6.91 &  10.24 & 17.55 & 20.70 & 25.70 & 67.90 \\\\\n\t\tDifference & 0.38 & 1.00 & 21.10 & 0.07 & 0.40 & 0.75 & 5.45 \\\\\n\t\tSpread prices  &  0.11 & 0.74 & -13.68 & -0.10 &  0.13 &  0.36 &  4.90 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\label{tab:descriptive-stats}\n\\end{table}\n\n\\subsection{Normalization}\n\nLooking at the most common descriptive statistics for input and target data in table~\\ref{tab:descriptive-stats} -- especially the quantiles -- the spread prices are usually smaller than the futures by two orders of magnitude. And even for the differences of the futures' legs there are some outliers. This will not necessarily pose a problem but nevertheless \\emph{optional} normalization is introduced by:\n\n\\begin{equation}\n\tX' = \\frac{X - \\bar{X}}{X_{max} - X_{min}} \\quad \\text{where $\\bar{X}$ is the mean.}\n\\end{equation}\n\nHence, the resulting values of $X'$ will be in range $[0,1]$.\n\nWhen explicitly mentioned am alternative formula for normalization is used, leading to zero mean and unit variance:\n\n\\begin{equation}\n\t\\label{eq:normalization2}\n\tX'' = \\frac{X - \\bar{X}}{Std(X)} = \\frac{X - \\bar{X}}{\\sqrt{Var(X)}}\n\\end{equation}\n\n\\subsection{Validation and test set}\n\\label{sec:aao-validation-and-test-set}\n\nFor validating the performance of deep networks the most widespread approach is to use one part of the data for tuning the hyperparameters introduced in section~\\ref{sec:hyperparameters} (the \\emph{validation set}) and one part for evaluating the final model (the \\emph{test set}). In this work $15\\%$ of the data will be used for validation and test set each. \n\nLooking at figure~\\ref{fig:termstructures} it becomes evident that there is a temporal connection between areas of low and high price: If you look at some sample with low priced futures there is a high probability that samples next to this one also have a low price and vice versa. Therefore choosing completely random samples for validation and testing will result in datasets highly similar to the training set. But choosing one large connected chunk will result in hyperparameters fitted only to this timeframe. Choosing a tradeoff, test and validation set will be chosen by taking two chunks of data from different locations of the original data each, as shown in figure~\\ref{fig:validation-and-test-set}.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{images/validation-and-test-set}\n\t\\caption[Splitting whole dataset into training, validation and test set]{Splitting the whole dataset into training, validation and test set. The top figure shows the futures' prices for the next eight months (M1 to M8) of expiration forming the term structure. The bottom figure shows the corresponding spread prices. While the green area shows the data used for validation the red area is used for testing. The remaining data is used for training.}\n\t\\label{fig:validation-and-test-set}\n\\end{figure}\n\n\n\\section{Network architecture}\n\\label{sec:aao-network-architecture}\n\nA feedforward neural network is one oft the simplest architectures used in deep learning. First, there will be some definitions describing the network as well as some intuitions about training of neural networks. Thereafter the hyperparameters for tailoring the network to the problem are introduced. To prevent clueless searching over all of these some defaults are adopted. Finally, as already mentioned, the network needs to handle missing data. Some simple approach introducing an additional layer at the networks' output is introduced.\n\n\\subsection{Definitions}\n\nThe feedforward neural network can formally be described as a sequence of matrix-vector multiplications. Let $L$ be the number of hidden layers where $l \\in \\{1,\\dots,L\\}$ is the hidden layer's index. For a layer $l$ there is an input vector $\\mathbf{z}^{(l)}$, an output vector $\\mathbf{y}^{(l)}$ as well as a weight matrix $W^{(l)}$ and a bias vector $\\mathbf{b}^{(l)}$. The input layer be $\\mathbf{x} = \\mathbf{y}^{(0)}$ and the output $\\mathbf{t} = \\mathbf{y}^{(L+1)}$. Furthermore there is an activation function $f^{(l)}$. At the output $f^{(L+1)}$ is typically the identity function.\n\nInference is done by the following operations for $l \\in \\{1,\\dots,L+1\\}$:\n\n\\begin{align}\n\t\\label{eq:layer-input}\n\t\\mathbf{z}^{(l)} &= W^{(l)\\top} \\mathbf{y}^{(l-1)} + \\mathbf{b}^{(l)} \\\\\n\t\\label{eq:layer-output}\n\t\\mathbf{y}^{(l)} &= f^{(l)}(\\mathbf{z}^{(l)})\n\\end{align}\n\nEach hidden layer can have an arbitrary width greater zero. A layer's width is the length of the vector $\\mathbf{y}^{(l)}$. In this work each hidden layer has the same width. Let this be the network's width $K$. Accordingly, the number of hidden layers $L$ is the network's depth.\n\nFor training -- this corresponds to optimizing $W$ and $\\mathbf{b}$ -- the \\emph{back-propagation} algorithm along with an optimization method like \\emph{stochastic gradient descent} is used. Therefore a scalar loss function $J(\\mathbf{t}, \\mathbf{\\hat{t}})$ is introduced, comparing the output of the network $\\mathbf{t}$ to the target $\\mathbf{\\hat{t}}$. By iteratively computing the gradient with respect to the parameters $W$ and $\\mathbf{b}$ for $J$ as well as for the activation functions $f^{(l)}$ backwards through the network one can optimize each layer's parameters. For further details see \\cite{Rumelhart-1986a} and \\cite[p.\\,204ff.]{Goodfellow-et-al-2016}.\n\n\\subsection{Hyperparameters}\n\\label{sec:hyperparameters}\n\nThese definitions result in a number of tunable hyperparameters, potentially affecting the network's performance:\n\\begin{itemize}\n\t\\item Activation functions $f^{(l)}$\n\t\\item Loss function $J$\n\t\\item Optimization method (and corresponding hyperparameters)\n\t\\item Weight initializations (choosing initial values for $W^{(l)}$)\n\t\\item Network depth $L$\n\t\\item Network width $K$\n\\end{itemize}\n\nWhile for some of these it is relatively easy to find some good values or there is some reasonable default, others are highly dependent on the problem and the data. For these, one has to extensively search for optimal values while constantly validating the performance. \n\n\\paragraph{Activation functions.}\n(also called hidden units when used together with their input from \\eqref{eq:layer-input}) \\\\\nOne can read in \\cite[p.\\,191]{Goodfellow-et-al-2016}:\n\\begin{quote}\n\t``The design of hidden units is an extremely active area of research and does not yet have many definitive guiding theoretical principles.''\n\\end{quote}\n\n\\begin{wrapfigure}[8]{r}{0.3\\textwidth}\n\t\\vspace{-1em}\n\t\\fbox{%\n\t\t\\begin{minipage}{0.3\\textwidth}\\centering\n\t\t\t\\includegraphics[width=\\textwidth]{images/rectifier}\n\t\t\t\\vspace{-20pt}\n\t\t\t\\caption[Rectifier function]{%\n\t\t\t\tRectifier \\\\ function $f(z)=\\max(0,z)$}\n\t\t\t\\label{fig:rectifier}\n\t\\end{minipage}}\n\\end{wrapfigure}\n\nAlthough directly followed by:\n\\begin{quote}\n\t``Rectified linear units are an excellent default choice of hidden unit.''\n\\end{quote}\n\nA \\emph{rectified linear unit} (ReLU) uses the activation function $f(z)=\\max(0,z)$ (also called \\emph{rectifier}, see figure~\\ref{fig:rectifier}) meaning for $z \\leq 0$ it always outputs zero. This offers some nice and simple properties especially regarding its derivative.\\footnote{%\n\tThe derivative is 0 across half its domain and 1 in the other. Furthermore the second derivative is 0 almost everywhere eliminating second-order effects.}\nUsing this function should ensure reasonable performance.\n\nAn alternative might be using \\emph{scaled exponential linear units} (SELUs) as activations thus building a \\emph{self-normalizing neural network}.\\cite{DBLP:journals/corr/KlambauerUMH17} This is a very recent approach aiming for mapping the mean and variance from each layer to the next one. They explicitly try to solve some shortcoming of feedforward neural networks, often showing effective regularization properties. The SELU activation function is given by:\n\n\\begin{equation}\n\t\\label{eq:selu}\n\tf(z) = \\lambda\n\t\\begin{cases}\n\tz & \\text{if } z > 0 \\\\\n\t\\alpha e^z - \\alpha & \\text{if } z \\leq 0\n\t\\end{cases}\n\\end{equation}\n\nThe corresponding paper suggests using $\\alpha = 1.6733$ and $\\lambda = 1.0507$ implying zero mean and unit variance. These are most effective if the training data has zero mean and unit variance, too, which can be accomplished by normalization using equation~\\eqref{eq:normalization2}.\n\n\\paragraph{Loss function.}\nThis can be chosen quite conservatively, too. To penalize larger derivations from the target value proportionally more the \\emph{mean squared error} (MSE) is used:\n\\begin{equation}\n\t\\label{eq:mse}\n\tJ(\\mathbf{t}, \\mathbf{\\hat{t}}) =\n\t\\frac{1}{n} \\sum_{i=1}^{n}(t_i - \\hat{t}_i)^2 \\quad\n\t\\text{where } n \\text{ is the length of vector } \\mathbf{t}.\n\\end{equation}\n\n\\paragraph{Optimization method.}\nMost of the time \\emph{stochastic gradient descent} (SGD) or some extension is chosen. The general idea is to use the gradient $\\nabla_{\\theta}J(\\theta)$ of a function $J$ with parameters $\\theta$ to find the direction (in parameter space) with the steepest descent. By updating the parameters iteratively with small steps\\footnote{%\n\tTypically some value $\\tau < 1$ is chosen like $0.01$ or $0.001$.}\nof size $\\alpha$ one is guaranteed to find a local minimum:\n\n\\begin{equation}\n\t\\theta^{(i+1)} = \\theta^{(i)} - \\alpha \\nabla_{\\theta}J(\\theta^{(i)})\n\\end{equation}\n\nThis formula describes the general gradient descent algorithm. As for the stochastic part, one takes a specific number of samples from the dataset -- called the \\emph{batch size} -- and updates the parameters after evaluating just this sample. In deep learning SGD is applied with respect to weights $W$ and bias $\\mathbf{b}$ for loss and activation functions. Because of the non-convex structure of neural networks finding a local minimum (instead of a global one) is acceptable. In practice this works reasonably well.\n\nIn this work primary the \\emph{Adam}\\footnote{``\\dots the name Adam is derived from adaptive moment estimation.''} algorithm is used.\\cite{DBLP:journals/corr/KingmaB14} It shows faster convergence, in general as well as for some specific tests on the current problem. New hyperparameters $\\beta_1$ and $\\beta_2$ are introduced for estimating the first and second moments of the gradients respectively. \\\\ The following hyperparameter settings are used: $\\alpha=0.001$, $\\beta_1 = 0.9$, $\\beta_2=0.999$ (the latter two following the original paper's recommendations) and batch size of 32.\n\n\\paragraph{Weight initializations.}\nFor the presented iterative optimization methods the weights $W^{(l)}$ need to be initialized in some way. As mentioned above the optimization of a neural network is a non-convex problem. Therefore the local minimum found depends on these initializations. There are two properties which are especially important when choosing an initialization strategy.\n\nFirst and foremost the initialization needs to break symmetry between units:\n\n\\begin{quote}\n\t``If two hidden units with the same activation function are connected to the same inputs, then these units must have different initial parameters. If they have the same initial\n\tparameters, then a deterministic learning algorithm applied to a deterministic cost\n\tand model will constantly update both of these units in the same way.''\\cite[p.\\,301]{Goodfellow-et-al-2016}\n\\end{quote}\n\nSince one generally wants for each unit to learn some different aspects of the given task this is the most important role of initialization. \n\nSecondly, since SGD is used for optimization, the weights are updated with a certain step size. A small step size indicates the assumption that the values after optimization are close to the initial values. Taking both of these properties into account, using a common probability distribution seems to be an obvious solution. This work uses the following uniform distribution suggested by \\cite{pmlr-v9-glorot10a}:\n\n\\begin{equation}\n\t\\label{eq:glorot-initialization}\n\tW_{ij} \\sim U\\left[ -\\frac{1}{\\sqrt{k}}, \\frac{1}{\\sqrt{k}} \\right]\n\t\\quad \\text{where $k$ is the width of the previous layer.} \n\\end{equation}\n\n\n\\paragraph{Network depth and network width.}\nIntuitively the network width increases the amount of information the network can ``remember''. The weight matrices are larger and therefore hold more values. Whereas the network depth increases the network's ability to learn underlying abstractions. A naive solution might be to chose width \\emph{and} depth as large as possible. Unfortunately, this approach has serious drawbacks:\n\n\\begin{enumerate}\n\t\\item One gets a powerful model which easily leads to overfitting\\footnote{%\n\t\tThis is a general problem in machine learning not limited to neural networks.}.\n\tThe network will not learn to solve the problem but just echo its training. For samples outside the training set the performance will degrade drastically. This can distort the results in such a dramatic manner that some practitioners like \\cite[p.\\,23: When not to Backtest a Strategy]{Chan-2013} refuse to look at such models completely. One can fight overfitting by carefully choosing an out-of-sample validation set and using different kinds of regularization.\n\t\n\t\\item As shortly explained above, the backpropagation algorithm uses the gradients for updating the weights backwards throughout the network. This may lead to the \\emph{vanishing gradient problem} where the layers near the outputs are updated much faster than the layers near the inputs. Even though (very) deep networks were quite successful one some tasks during the recent years\\footnote{%\n\t\tThe ResNet architecture is very popular in image recognition. With a depth of 152 layers it even won 1st place on the Large Scale Visual Recognition Challenge (ILSVRC) 2015 classification task.\\cite{DBLP:journals/corr/HeZRS15}}\n\tthere is still no general solution for this problem, especially for feedforward networks.\n\t\n\t\\item One may wish to force the network to learn abstractions and therefore require a certain depth. But a large depth in combination with a large width will not lead to the desired results because the network will likely use its many parameters to just ``remember'', ignoring the possibilities for abstraction coming with the additional hidden layers and therefore rendering them useless.\n\\end{enumerate}\n\nThere are some recent insights that imply using a powerful model with many parameters generally works well in deep learning.\\cite{DBLP:journals/corr/ZhangBHRV16} But ultimately it comes down to the actual performance on the problem at hand. Therefore depth and width of the network will be considered tunable hyperparameters, too, that need to be evaluated empirically.\n\n\\subsection{Handling missing values at network level}\n\nUp to now was a description of a standard feedforward architecture. In section~\\ref{sec:aao-data-handling} the problem of missing data for inputs as well as outputs was described. These need to be handled partly by the network. At the inputs one can just set the missing values to zero. By looking at \\emph{dropout regularization} one can see why this works. Here, the general idea is to randomly remove units during training to prevent them from co-adapting too much making each individual unit more robust eventually. This is implemented by adjusting the layers' input \\ref{eq:layer-input} the following way: \\cite{JMLR:v15:srivastava14a}\n\n\\begin{align}\n\t\\mathbf{z}^{(l)} &= W^{(l)\\top} \\mathbf{\\tilde{y}}^{(l-1)} + \\mathbf{b}^{(l)} \\\\\n\t\\text{where} \\quad\n\t\\mathbf{\\tilde{y}}^{(l)} &= \\underset{\\text{entrywise product}}{\\mathbf{r}^{(l)} \\circ \\mathbf{y}^{(l)}}\n\\end{align}\n\nThe values of vector $\\mathbf{r}^{(l)}$ are from a Bernoulli distribution meaning $\\mathbf{r}^{(l)} \\in \\{0, 1\\}^k$.\n\nTherefore by setting the inputs $\\mathbf{y}^{(0)}$ not randomly but deterministically to zero -- in case they were missing in the first place -- the respective input nodes are effectively removed. It is important to note that this will not work for SELU activations because these do not settle at zero. Setting the inputs to $\\lim_{z \\to -\\infty} f(z) = -\\lambda \\alpha$ might be a slightly better fit but is not really removing the corresponding input nodes.\n\nFor partly handling the outputs, missing values were set to zero and a conditional mask layer was added to the end of the network. The mask layer uses days to expiration as additional input: If this value is zero, the output for the spread price is set to zero, too. Both output and target would be zero resulting in $J(0, 0) = 0$. Because one does not know beforehand about the availability of the next term's data there is no way to handle the output in general.\n\nThe resulting architecture is illustrated in figure~\\ref{fig:architecture1}.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{architecture1}\n\t\\caption[Network architecture with hidden layer width $K=5$]{%\n\t\tNetwork architecture with hidden layer width $K=5$. The mask layer just masks the first output in case there are zero days to expiration.}\n\t\\label{fig:architecture1}\n\\end{figure}\n\n\\section{Evaluation}\n\nTraining a neural network to estimate a real valued vector comes down to a regression problem. This section is mainly about evaluating this chapter's approach for different configurations of hyperparameters.\n\n\\subsection{Network width, depth and normalization}\n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex1-loss-basic}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex1-val-basic}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\\\\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex1-loss-normal}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex1-val-normal}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\caption[Resulting loss depending on width, depth and normalization]{The resulting loss depending on width, depth and normalization of training data. (a) Training loss without normalization; (b) Validation loss without normalization; (c) Training loss with normalization; (d) Validation loss with normalization.}\n\t\\label{fig:approach1-ex1}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{approach1-ex1-progression}\n\t\\caption[Progression of training loss for networks with $L=1$ and $K=24$]{Progression of training loss for networks with $L=1$ and $K=24$. Mean and standard derivation (std.) over ten identical networks trained separately.}\n\t\\label{fig:approach1-ex1-progression}\n\\end{figure}\n\nFor evaluating depth $L$ and width $K$ of the network as well as the influence of normalization a number of models different in these hyperparameters were trained. While the choice for normalization is a binary one, $L \\in \\{1,3,\\dots,9\\}$ and $K \\in \\{9,12,\\dots,24\\}$ were used. The training happened for 1,000 epochs\\footnote{%\n\tOne epoch specifies the number of iterations during SGD until the network as seen each sample exactly one time. For 1,000 epochs the network has seen each sample 1,000 times, subsequently.}\nand for each combination ten models are trained to get information about mean and variance. A total of $2 \\cdot 5 \\cdot 6 \\cdot 10 = 600$ models were trained.\n\nFor evaluating the results, for each model the epoch with the minimum loss was selected. Afterwards the mean over all models with identical hyperparameters was taken forming the figures in~\\ref{fig:approach1-ex1}. There are three observations:\n\n\\begin{enumerate}\n\t\\item As expected, the training loss decreases for more powerful models with larger depth and width. In contrast, the structure of the validation loss looks different. This is an example of overfitting where the network is not fitted to the problem but the training data only.\n\t\\item Just looking at the validation loss, the performance obviously worsens with increasing depth. Only increasing the width seems to have an influence on decreasing the loss. These are similar results to \\cite{Niaki-2013}.\n\t\\item There is no obvious advantage to using normalized data. Looking at figure~\\ref{fig:approach1-ex1-progression}, the network in general converges faster using normalized data but also shows higher variance. The differences are neglectable, therefore normalization is not pursued further.\n\\end{enumerate}\n\n\n\\subsection{Regularization techniques}\n\n\\begin{quote}\n\t``Many strategies\tused in machine learning are explicitly designed to reduce the test error, possibly at the expense of increased training error. These strategies are known collectively as regularization.''\\cite[p.\\,228]{Goodfellow-et-al-2016}\n\\end{quote}\n\nRegularization is especially important in deep learning, where it is hard to visualize and understand what exactly was learned by the network. There is a large number of regularization techniques available, some of them exclusive for neural networks. Even a simple strategy like ``stopping the training when the validation error increases'' (\\emph{early stopping}) is already some kind of regularization. This section mainly focuses on comparing three approaches: The widespread \\emph{dropout regularization}, \\emph{self-normalizing neural networks} (using SELUs as activation functions) and an attempt on \\emph{data augmentation}, using minutely data for training.\\footnote{%\n\tData augmentation: Creating similar -- but not identical -- data from existing one, increasing the variance and hence making the network more robust. Even though the data was not newly generated the general idea is similar. By using some minute's futures as input, targeting the spread prices of the same minute at the next term, the network would learn a similar mapping. The number of samples increases by factor 1,440.}\n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex3-val-minutely}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.49\\linewidth}\n\t\t\\includegraphics[width=\\linewidth]{approach1-ex3-val-selu}\n\t\t\\caption{}\n\t\\end{subfigure}\n\t\\caption[Validation loss for models trained with regularization techniques]{Validation loss for models trained with (a) minutely data and (b) SELU activations.}\n\t\\label{fig:approach1-ex3}\n\\end{figure}\n\nFor evaluating the effectiveness of regularization the range of width $K$ and especially depth $L$ to search over was widened, except for minutely data. Using $L \\in \\{1,4,\\dots,91\\}$ and $K \\in \\{3,6,\\dots,33\\}$ a total of $30 \\cdot 30 = 900$ models were trained. The large raise of the maximum depth was done in hope of finding a network with better abstraction capabilities, since the former experiments favored shallow networks. There was only one training run per model configuration, therefore neglecting statistical soundness. \n\nFor minutely data $L \\in \\{1, 4, \\dots, 28\\}$ and $K \\in \\{3,6,\\dots,30\\}$ were chosen. Further increasing the depth would have been computationally expensive. Because of similar reasons the batch size was set to 1024, also reducing the noise at each weight update. For each such configurations ten models were trained.\n\nLooking at the results in figure~\\ref{fig:approach1-ex3}, their implications do not seem much different from the former experiments. Again, for each model the epoch with minimum loss was selected:\n\n\\begin{enumerate}\n\t\\item For dropout, the smallest loss was around $0.2$, much higher than all other models. Hence using dropout seems out of question. It neither allows for deeper networks nor does it result in an acceptable loss, regardless of configuration.\n\t\\item Building self-normalizing neural networks with SELUs seems promising. But comparison with figure~\\ref{fig:approach1-ex1} shows not much difference, concluding that in this case simple width is more important than some additional regularizations.\n\t\\item Again, a small depth in connection with a large width seems to be the preferred configuration. \n\\end{enumerate}\n\n\\subsection{Additional inputs}\n\nRemembering section~\\ref{sec:seasonality}, there were some additional inputs which might hold important information. Adding these inputs to the existing models might decrease the loss under the conditions that these features indeed are useful and that the model is able to learn their underlying pattern. \n\nTherefore two inputs are added: The corresponding day of month and the month itself, represented as simple natural numbers where January $\\mapsto 1$, \\dots, December $\\mapsto 12$. Increasing the depth hurt performance in previous experiments, therefore depth $L = 1$ is chosen while width is set to $K \\in \\{20,23,\\dots,50\\}$. For each configuration ten models were trained, resulting in a total of $11 \\cdot 10 = 110$ models. Furthermore, there were some training runs with normalized values but since the performance was always much worse these will not be evaluated further.\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=0.9\\linewidth]{approach1-ex4-val-basic}\n\t\\caption[Validation loss using additional inputs with respect to width]{Validation loss for models with additional input. The x-axis shows the networks' width. Ten models were trained, shown by the thin lines. The thick blue line is the mean and the light blue area the standard derivation in either direction.}\n\t\\label{fig:approach1-ex4}\n\\end{figure}\n\n\\newpage\n\nThe results are shown in figure~\\ref{fig:approach1-ex4}. While mean and standard derivation seem reasonable, the loss itself only gains significance by comparing it to the other experiments. This is done in the following section.\n\n\\subsection{Comparison}\n\\label{sec:aao-comparison}\n\nThere are four models used for comparison, corresponding to the experiments described above:\n\n\\begin{enumerate}\n\t\\item Basic network as presented in section~\\ref{sec:aao-network-architecture} (Basic)\n\t\\item Network using dropout regularization (Dropout)\n\t\\item Self-normalizing network using SELUs (SNN)\n\t\\item Basic network trained with minutely data (Minutely)\n\t\\item Network with additional inputs for days and month (AddIn)\n\\end{enumerate}\n\nAll these networks have a depth $L=1$ and width $K=30$. Using a greater width might lead to marginally better performance. The training data is not normalized. Furthermore the learning rate is reduced by $\\sqrt{0.1}$ up to two times if there is no improvement on the validation loss for 20 epochs. If there is still no improvement afterwards the training is stopped (\\emph{early stopping}). As a baseline a naive prediction is used: It just assumes the futures' prices did not change for the next day, calculating spread prices and error from these.\n\nBy looking at table~\\ref{tab:aao-comparison} -- especially the last column using the test dataset not used for network optimization -- the results are quite devastating. The error on most models is worse than for naive prediction. Only the self-normalizing network and the network trained with minutely data beat this by a negligible difference. Furthermore the training error is unusually high, often above the validation MSE. Even though the training data seems to have higher fluctuations -- likely because of the financial crisis in 2008 -- one could expect the networks to fit more to this dataset. Therefore this chapter's approach failed to deliver useful predictions.\n\n\\begin{table}\n\t\\centering\n\t\\caption[Comparison of the results obtained by the first approach]{Comparison of the results obtained by the first approach. Smaller error (MSE) indicated better performance. Because training and validation set were used for optimization the test MSE is most meaningful.}\n\t\\begin{tabular}{llrrr}\n\t\t\\toprule\n\t\t{} & Epoch &  Training MSE &  Validation MSE &  \\textbf{Test MSE} \\\\\n\t\t\\midrule\n\t\tNaive    &       &        0.2099 &          0.0985 &    0.1318 \\\\\n\t\tBasic    &   307 &        0.1386 &          0.1013 &    0.1563 \\\\\n\t\tDropout  &   174 &        0.1895 &          0.2426 &    0.2984 \\\\\n\t\tSNN      &   242 &        0.1425 &          0.1077 &    \\textbf{0.1259} \\\\\n\t\tMinutely &    70 &        0.2252 &          \\textbf{0.0896} &    0.1294 \\\\\n\t\tAddIn    &   268 &        \\textbf{0.1297} &          0.0997 &    0.1321 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\label{tab:aao-comparison}\n\\end{table}", "meta": {"hexsha": "23b1087ca10e3ebed2f00f49d0471feaef42878a", "size": 36472, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/experiments1.tex", "max_stars_repo_name": "leyhline/vix-term-structure", "max_stars_repo_head_hexsha": "b00ad5025bc68280a21e58cecbf5944aee03da97", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-08-17T10:54:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-07T16:02:33.000Z", "max_issues_repo_path": "thesis/chapters/experiments1.tex", "max_issues_repo_name": "leyhline/vix-term-structure", "max_issues_repo_head_hexsha": "b00ad5025bc68280a21e58cecbf5944aee03da97", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapters/experiments1.tex", "max_forks_repo_name": "leyhline/vix-term-structure", "max_forks_repo_head_hexsha": "b00ad5025bc68280a21e58cecbf5944aee03da97", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-02-22T00:46:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-15T19:29:43.000Z", "avg_line_length": 82.5158371041, "max_line_length": 729, "alphanum_fraction": 0.7678767274, "num_tokens": 9010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4122511116152033}}
{"text": "\\documentclass{scrartcl}\n\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{siunitx}\n\n\\title{Higher-order finite elements for embedded simulation}\n\\subtitle{Errata}\n\\date{October 2021}\n\\author{Andreas Longva, RWTH Aachen University}\n\n\\begin{document}\n\\maketitle\n\nThis document details some errors discovered in our source code after the publication of our paper.\n\nThe code used to produce most of the results for our paper is available at the following URL:\n\n\\begin{center}\n\\url{https://github.com/InteractiveComputerGraphics/higher_order_embedded_fem}\n\\end{center}\n\n\\section*{Material parameters}\nWhile rewriting and transfering some code to a new project, we discovered that our utility function for converting material parameters from Young's modulus and Poisson's ratio to corresponding Lamé parameters was off by a factor 4.\n\nIn short, when converting to the Lamé parameters $\\lambda$ and $\\mu$, our code used an incorrect formula for computing $\\lambda$, whereas the formula used for $\\mu$ was correct. The formulas we had implemented were:\n\\begin{align*}\n\\mu = \\frac{E}{2 (1 + \\nu)}, \\qquad\n\\lambda^\\text{bad} = \\frac{1}{2} \\cdot \\frac{\\mu \\nu}{1 - 2 \\nu}. \\\\\n\\end{align*}\nThe correct formula for $\\lambda$ is\n\\begin{align*}\n\\lambda = 2 \\cdot \\frac{\\mu \\nu}{1 - 2 \\nu} = 4 \\lambda^\\text{bad}.\n\\end{align*}\n\nAs a result, the parameters we give in the paper are not the \\emph{true} parameters that were used for the simulation. With the incorrect formulas we can compute the Lamé parameters that were used for the simulation, and use the \\emph{correct} conversion formulas the other way to compute corresponding \\emph{effective} values for the Young's modulus and Poisson's ratio that would lead to the same Lamé parameters, and therefore the same simulation results. We obtain:\n\\begin{align*}\n\\nu^\\text{eff} = \\frac{\\nu^\\text{paper}}{4 - 6 \\, \\nu^\\text{paper}},\n\\qquad\nE^\\text{eff} = E^\\text{paper} \\frac{1 + \\nu^\\text{eff}}{1 + \\nu^\\text{paper}}.\n\\end{align*}\n\nThe following table gives the original material parameters (as presented in the paper) and the corresponding effective values (up to 4 significant digits) for the experiments in which these material parameters were provided.\n\n\\begin{center}\n\\begin{tabular}{l | c | c}\n\\textbf{Experiment} & \\textbf{Paper parameters} & \\textbf{Effective parameters} \\\\\n\\hline\nQuadrature verification (Section 5.4)\n&\n\\begin{tabular}{l}\n$E = \\SI{3e6}{\\pascal}$ \\\\ $\\nu = 0.4$\n\\end{tabular}\n& \\begin{tabular}{l}\n$E = \\SI{2.679e6}{\\pascal}$ \\\\ $\\nu = 0.25$\n\\end{tabular}\n\\\\\n\\hline\nTwisting cylinder (Section 6.2)\n&\n\\begin{tabular}{l}\n$E = \\SI{5e6}{\\pascal}$ \\\\ $\\nu = 0.48$\n\\end{tabular}\n& \\begin{tabular}{l}\n$E = \\SI{4.826e6}{\\pascal}$ \\\\ $\\nu = 0.4286$\n\\end{tabular}\n\\\\\n\\hline\nArmadillo slingshot (Section 6.5)\n&\n\\begin{tabular}{l}\n$E = \\SI{5e5}{\\pascal}$ \\\\ $\\nu = 0.4$\n\\end{tabular}\n& \\begin{tabular}{l}\n$E = \\SI{4.464e5}{\\pascal}$ \\\\ $\\nu = 0.25$\n\\end{tabular}\n\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nWe see that the resulting effective parameters are (unfortunately) noticably different from the intended parameters. However, these parameter choices were more or less arbitrary to begin with, so it seems fair to say that it does not significantly change any of the conclusions made in the paper.\n\n\n\n\\section*{Twisting cylinder boundary conditions}\n\nThe twisting cylinder (Section 6.2) is reported in the paper to be 16 meters long. Recently, upon reviewing the code, we realized that the Dirichlet boundary conditions at the end were enforced for nodes with $y$-coordinate $|y| \\geq 6.99$ instead of $|y| \\geq 7.99$. Therefore the motion of the last meter on each side of the cylinder is prescribed. The experiment therefore effectively simulates a 14 meter long cylinder as opposed to the 16 meters described.\n\n\n\\section*{}\n\\end{document}", "meta": {"hexsha": "e476b4dc0b8cf7b230dc0e77adffdda529f61214", "size": 3795, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "errata/tex/errata.tex", "max_stars_repo_name": "InteractiveComputerGraphics/higher_order_embedded_fem", "max_stars_repo_head_hexsha": "868fbc25f93cae32aa3caaa41a60987d4192cf1b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-10-19T17:11:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-26T10:20:53.000Z", "max_issues_repo_path": "errata/tex/errata.tex", "max_issues_repo_name": "InteractiveComputerGraphics/higher_order_embedded_fem", "max_issues_repo_head_hexsha": "868fbc25f93cae32aa3caaa41a60987d4192cf1b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "errata/tex/errata.tex", "max_forks_repo_name": "InteractiveComputerGraphics/higher_order_embedded_fem", "max_forks_repo_head_hexsha": "868fbc25f93cae32aa3caaa41a60987d4192cf1b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-10-20T16:13:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T01:50:35.000Z", "avg_line_length": 41.25, "max_line_length": 469, "alphanum_fraction": 0.734914361, "num_tokens": 1110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.4122511066249925}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 16.2  Character-based Graphics --- Single Print Line\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nThis subroutine constructs a character string that may be printed as part of a\nsingle line image by the user's program to give a graphical representation of\ndata.  It is intended primarily for use as a supplement to ordinary tabular\noutput of data as an aid in spotting trends, wild points, etc.\n\n\\subsection{Usage}\n\n\\subsubsection{Program Prototype, Single precision}\n\n\\begin{description}\n\n\\item[INTEGER] \\ {\\bf NCHAR}\n\n\\item[REAL] \\  {\\bf Y, Y1, Y2}\n\n\\item[LOGICAL] \\ {\\bf RESET}\n\n\\item[CHARACTER*{\\rm 1}] \\ {\\bf SYMBOL}\n\n\\item[CHARACTER*$n$] \\ {\\bf IMAGE} \\ $[n \\geq $ NCHAR]\n\n\\end{description}\n\nAssign values to Y, SYMBOL, NCHAR, Y1, Y2, and RESET.\n\n\\begin{center}\n\\fbox{\\begin{tabular}{@{\\bf }c}\nCALL SPRPL (Y, SYMBOL, IMAGE,\\\\\nNCHAR, Y1, Y2, RESET)\\\\\n\\end{tabular}}\n\\end{center}\n\nOn return the string, IMAGE, contains the character SYMBOL positioned as a\nfunction of the value of Y.  The user's program may then print IMAGE as part\nof a line containing Y and possibly other information.\n\n\\subsubsection{Argument Definitions}\n\n\\begin{description}\n\\item[Y] \\ [in]  Data value to be plotted.  Y should be between Y1 and Y2;\notherwise see Section E, Error Procedures.\n\\item[SYMBOL] \\ [in]  A single character to be used as a plot symbol.  The character can\nbe specified literally in the call statement, as for example:\nCALL SPRPL (Y, $^\\prime $*$^\\prime $, ...)\n\\item[IMAGE] \\ [inout]  Character string in which a plot image is constructed.\n\\item[NCHAR] \\ [in]  Number of character positions in IMAGE to be used in constructing\nthe plot image.  Require NCHAR $\\geq  2.$\n\\item[Y1,Y2] \\ [in]  Numbers that bracket the range of values of Y to be plotted in\nIMAGE.  Either Y1 $\\leq $ Y2 or Y1 $\\geq $ Y2 is acceptable.\n\\item[RESET] \\ [in]  Flag to reset the line image.  If RESET\\ = .TRUE., the subroutine\nwill:\n\n\\begin{itemize}\n\\item[1.] Store NCHAR blank characters into IMAGE, and then store the character '0' in\nthe zero value position if zero is contained in the interval [$ymin$, $ymax$].  See\nSection D.\n\n\\vspace{3pt}% Need to get decent column break\n\n\\item[2.] Store the character specified by SYMBOL in the Y value position.\n\n\\end{itemize}\nIf RESET = .FALSE., the subroutine will only execute Step~2 above.\n\n\\end{description}\n\n\\subsubsection{Modifications for Double Precision}\n\nFor double-precision usage change the REAL type statement to DOUBLE PRECISION,\nand change the subroutine name from SPRPL to DPRPL.\n\n\\subsection{Examples and Remarks}\n\nPrint a set of ($x$, $y$)-data.  On the right side of the page print a\n``strip chart\" plot of the data with $x$ increasing downward and $y$\nincreasing to the right.  See DRSPRPL and ODSPRPL for code and output\nillustrating this example.\n\n\\subsection{Functional Description}\n\n\\begin{itemize}\n\\item[1.] The subroutine will compute $ymin = \\min$(Y1, Y2) and $ymax\n= \\max$(Y1, Y2).  Then, if $ymin = ymax$ these numbers will be\nreplaced by $ymin = 0.9 \\times ymin$ and $ymax = 1.1 \\times ymax$\nif $ymin \\neq 0.$, or by $ymin = -1$, and $ymax = +1$, if $ymin = 0$.\n\n\\item[2.] If zero is not in the interval [$ymin$, $ymax$], then the\nscaling will be such that $ymin$ corresponds to the center of the\nleftmost character position and $ymax$ corresponds to the center of\nthe rightmost character position.  If zero is in the interval\n[$ymin$, $ymax$], and does not correspond to the first or last\ncharacter position in IMAGE(), then scaling will be adjusted so the\nvalue zero corresponds to the center of a character position.  This\nadjustment guarantees that values located symmetrically with respect\nto zero will be plotted in character positions symmetrically located\nwith respect to the zero character position.\n\\end{itemize}\n\n\\subsection{Error Procedures and Restrictions}\n\nA Y value outside the stated data range, [Y1, Y2], (plus a small tolerance)\nwill not be plotted, but the message 'OUT' is placed in either the left or\nright end of IMAGE() as appropriate.  This message will be suppressed if\nNCHAR $< 6.$\n\\enlargethispage*{40pt}\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77.\n\nBased on 1969 code by C.L. Lawson, JPL.  Adapted for MATH77 by C.L. Lawson and\nS. Chiu, JPL, 1983.  At MATH77 Release~2.2, Nov.~1988, introduced DPRPL, and changed the\nname of the previous PRPL to SPRPL.  Programs that were using PRPL should be\nchanged to use the name SPRPL.\n\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.2in} {\\bf Required Files}\\vspace{2pt} \\\\\nDPRPL & \\hspace{.35in} DPRPL\\rule[-5pt]{0pt}{8pt}\\\\\nSPRPL & \\hspace{.35in} SPRPL\\\\\\end{tabular}\n\n\\begcode\n\n\\medskip\\\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSPRPL}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sprpl}}\n\n\\vspace{20pt}\\centerline{\\bf \\large ODSPRPL}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sprpl}}\n\\end{document}\n", "meta": {"hexsha": "eceaab9a4e6ea2d43f755fb94918e4a9f86818fb", "size": 5151, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch16-02.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch16-02.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch16-02.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 35.7708333333, "max_line_length": 98, "alphanum_fraction": 0.7365560085, "num_tokens": 1515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.41225110242829616}}
{"text": "%!TEX root =  ../main.tex\n\n\\subsection{First Discontinuities}\n\n\\objective{Find informal limits at holes and non-holes.}\n\nIn this section, we will explore the informal definition of a \\textbf{limit}.  Have you ever had anyone\nsneer at you over a lost opportunity and say, ``Should of, would of, could of?''  (It probably\nsounded like ``shoulda, woulda, coulda.'')  The idea is that everyone can see a hypothetical \nin hindsight, though that does not avail you anything now.  Hypotheticals are situations describing\nwhat was likely, or intended, or desired.  In mathematics, we often encounter functions\nwhich appear \\textit{as though} there is an expected value, only to have that spot not\neven be part of the domain.\n\n\\personfeature[0in]{\\chapdir/pics/Dedekind.jpg}{Richard Dedekind}{1831-1916}{was one of the greatest mathematicians of the nineteenth-century, as well as one of the most important contributors to algebra and number theory of all time. Any comprehensive history of mathematics will mention him for his investigation of the notions of algebraic number, field, ring, group, module, lattice, etc., and especially, for the invention of his theory of ideals.  He contributed greatly to the idea of continuity, which makes limits possible. \\href{https://en.wikipedia.org/wiki/Richard_Dedekind}{Wikipedia}}\n\n\nLimits are like a hypothetical situation in math.  Suppose your friend bought a ticket for a vacation,\nand said they wanted to get away.  Then you didn't see this friend for a long time, and when you\nfinally saw them you asked, ``Did you ever go on vacation?  Where were you going to go?''  \nYou know they  were going somewhere, but from your perspective, it has yet to be determined if\nhe or she actual went and where your friend was even headed.  Notice how your second question\ndoesn't even depend on whether they went anywhere or not: it is about a hypothetical.  \n\nMany functions give an indeterminate answer at certain gaps in their domain.  It is obvious\nwhere they were ``headed'', but direct evaluation at that value of the independent variable is\nnot helpful.\n\n\n\n\\begin{derivation}{Indeterminate Form}\n\\index{indeterminate form}\nFor a given function $f(x)$, if $f(c)=\\frac{0}{0}$, then the point $c$ represent a \\textbf{hole} \nin the domain of $f$.\n\\end{derivation}\n\n\n\\subsection{Algebra Techniques}\nFrom the perspective of algebra, there are four techniques for constructing \nprecise replacements for many functions, replacements which are everywhere else the same,\nbut lack the particular hole.\n\n\\subsubsection{Cancelling}\nConsider the function $f(x) = \\frac{x^2-4}{x-2}$.    Enter it in your calculator and try \\Touche[style=function,principal={ZOOM},]\n\\Touche[style=number, principal=6].  How can it be just a line?  Why isn't it more complicated than that?  \nWell, it is.  Try plugging in 2.  That is, what is $f(2)$?  $\\frac{2^2-4}{2-2} = \\frac{0}{0}$.\n\n\n\\begin{derivation}{Factor Removal}\nWhen $f(c)=\\frac{0}{0}$ and the removal of a common factor in the numerator and denominator yields a real number $d$,\nthen $(c,d)$ represents the location of a hole in $f(x)$.\n\\end{derivation}\n\n\nReturning to our equation, $x^2-4$ in the numerator factors by the \nDifference of Squares to $(x-2)(x+2)$.  This is means\nwe can write $f(x)=\\frac{(x-2)(x+2)}{x-2}$.  It is \\emph{not} true that \n$\\frac{x-2}{x+2} = x+2$: they differ in their domains.\nHowever, $x+2$ is an \\textbf{analytic continuation} of $\\frac{x^2-4}{x-2}$, \nmeaning is is everywhere the same as the\noriginal but has an \\textit{even larger} domain.  We may use $x+2$ to answer the \nquestion what $f(x)$ would output at $x=2$, were it to exist there.\n\n\\subsubsection{Expanding}\nSome functions obscure the factor that could be cancelled with further arithmetic.  For example, it is not obvious\nwhat $g(x)=\\frac{(x+3)^3-27}{x}$ will be at $x=0$.\\footnote{If you are especially keen, \nyou might notice that this is factorable as the difference of cubes in the numerator, \nbut we will pretend no one saw that for just a minute!}  Sometimes a small\npiece of arithmetic allows us to proceed as in the previous section.  In this case $(x+3)^3=x^3+9x^2+27x+27$.\n\n\n\\begin{align*}\n\\frac{(x^3+9x^2+27x+27)-27}{x} &=\\\\\n\\frac{x(x^2+9x+27)}{x} & \\approx x^2+9x+27\\\\\n& \\rightarrow (0)^2+9(0)+27 \\\\\n&\\rightarrow 27\\\\\n\\end{align*}\n\n\n\\subsubsection{Complex Fractions}\n\\emph{Not to be confused with fractions involving complex numbers!}\n\nBesides simple arithmetic, complex fractions can obfuscate the cancelling \nneeded to simplify the presence\nof a hole.  $\\cfrac{2-x}{\\frac{1}{x}-\\frac{1}{2}}$ is indeterminate at $x=2$.  \nHowever, if we simplify this fraction until it has a simple (non-fraction) numerator and \ndenominator, the indeterminate form will evaporate.\n\n\n\\begin{align*}\n\\cfrac{2-x}{\\frac{2}{2}\\cdot\\frac{1}{x}-\\frac{1}{2}\\cdot\\frac{x}{x}} &= \\cfrac{2-x}{\\frac{2-x}{2x}} \\\\\n&\\approx \\cfrac{2x(2-x)}{2-x} \\\\\n&\\approx 2x\\\\\n&\\rightarrow 2(2) = 4\n\\end{align*}\n\n\n\n\\begin{derivation}{Additional Factor}\nWhen $f(c)=\\frac{0}{0}$ and the multiplication by a common factor in the numerator and denominator yields a real number $d$,\nthen $(c,d)$ represents the location of a hole in $f(x)$.\n\\end{derivation}\n\n\n\n\\subsubsection{Conjugates}\nWhat to multiply by can be difficult to decipher.  It often appears as though \nwe might wish to square individual terms  in the numerator or denominator.  \nFor instance, the function $h(x) = \\cfrac{\\sqrt{x+1}-1}{x}$ is $\\frac{0}{0}$ at $x=0$.\nClearly, it would be ideal to square only the upper-left corner of the fraction, \nin order to remove the square root.  The\nsecret is to recognize the numerator is of the form $a-b$, where \n$a=\\sqrt{x+1}$ and $b=1$.  Any binomial multiplied\nby its conjugate yields the difference of squares (i.e. $(a+b)(a-b)=a^2-b^2$).  \nIn this case, we must multiply top and bottom by $\\sqrt{x+1}+1$.\n\n\n\\begin{align*}\n\\cfrac{\\sqrt{x+1}-1}{x} \\cdot \\cfrac{\\sqrt{x+1}+1}{\\sqrt{x+1}+1} &\\approx \\cfrac{(x+1)-1}{x(\\sqrt{x+1}+1)}\\\\\n&\\approx \\cfrac{1}{\\sqrt{x+1}+1}\\\\\n&\\rightarrow \\cfrac{1}{\\sqrt{0+1}+1} = \\frac{1}{2}\n\\end{align*}\n\n\\subsubsection{Direct Substitution}\nSome time, there might seem to be a hole, but none exists.  In that case, we can simply plug\nthe input into the equation and get a result.\n\n\\inlinefig{\\chapdir/pics/Continuidad_de_funciones_02.png}{Removable discontinuities are typically hole in the graph, places where there is no value to the function, but the expected value is straightforward to calculate.}\n\n", "meta": {"hexsha": "a13240a7d21b02c9722d1bfc9beedba09af731e6", "size": 6462, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch02/0201.tex", "max_stars_repo_name": "aquatiki/AnalysisTextbook", "max_stars_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-10-08T15:05:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-07T12:32:53.000Z", "max_issues_repo_path": "ch02/0201.tex", "max_issues_repo_name": "aquatiki/AnalysisTextbook", "max_issues_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch02/0201.tex", "max_forks_repo_name": "aquatiki/AnalysisTextbook", "max_forks_repo_head_hexsha": "011c16427ada1b1e3df8e66c02566a5d5ac8abcf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.7076923077, "max_line_length": 598, "alphanum_fraction": 0.7308882699, "num_tokens": 1883, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.41224209019163727}}
{"text": "\\section{Quantum Mechanics}\n\nThis section goes well beyond what is necessary for the PGRE.\nFocus mainly on energy levels and probability as these are common themes on all the practice tests.\nPerturbation theory is usually just one question but is typically straightforward.\nSinglet and triplet spin states come up from time to time as well.\nAgain, any of this (and more) could be on the exam, but it would be unusual for some of the more advanced material to be there.\\\\*\n\n\\subsection{The Schr\\\"odinger Equation}\n\n\\subsubsection{Time-Dependent}\n\\(i\\hbar\\dot{\\Psi}=H\\Psi\\)\\\\*\nSolution: \\(\\Psi(\\mathbf{r},t)=\\Psi(\\mathbf{r},0)e^{-iHt/\\hbar}\\)\n\n\\subsubsection{Time-Independent}\n\\(H\\psi_n=E_n\\psi_n\\)\\\\*\nSolution: \\(\\displaystyle\\Psi(\\mathbf{r},t)=\\sum_{n=1}^{m}c_n\\psi_n(\\mathbf{r},0)e^{-iE_nt/\\hbar}\\) (\\(m\\) can go to \\(\\infty\\))\\\\\\\\*\nThese eigenfunctions (\\(\\psi_n\\)) are called stationary states.\nEvery expectation value is constant in time. (i.e. \\(\\langle\\hat{p}\\rangle=0\\) because \\(\\langle \\hat{x}\\rangle=\\mathrm{const.}\\))\n\n\\subsubsection{Boundary Conditions}\n\\(\\Psi\\) and \\(\\nabla\\Psi\\) are both continuous.\\\\*\nIf \\(V(\\mathbf{r}_0)\\to\\pm\\infty\\) then only \\(\\Psi\\) is continuous at \\(\\mathbf{r}_0\\).\n\n\\subsubsection{Normalization}\n\\(\\int_{-\\infty}^{\\infty}|\\Psi(\\mathbf{r},t)|^2\\,\\mathrm{d}\\mathbf{r}=1\\)\n\n\\subsection{General Information}\n\n\\subsubsection{de Broglie Wavelength}\nFor any particle: \\(\\displaystyle\\lambda=\\frac{h}{p}\\to p=\\hbar k\\)\n\n\\subsubsection{Energy of a Photon}\n\\(E=h\\nu=\\frac{hc}{\\lambda}\\)\n\n\\subsubsection{Operators}\nAny operator can be decomposed into Hermitian and anti-Hermitian parts:\\\\*\n\\(\\displaystyle \\Omega=\\frac{\\Omega+\\Omega^{\\dag}}{2}+\\frac{\\Omega-\\Omega^{\\dag}}{2}\\)\\\\\\\\*\nIn the \\(x\\) basis:\n\\begin{itemize}\n\\item \\(\\hat{x}=x\\)\n\\item \\(\\hat{p}=-i\\hbar\\frac{\\partial}{\\partial x}\\)\n\\end{itemize}\n\\(\\hat{L}_z=-i\\hbar\\frac{\\partial}{\\partial\\phi}\\)\\\\\\\\*\nIn the \\(p\\) basis:\n\\begin{itemize}\n\\item \\(\\hat{x}=i\\hbar\\frac{\\partial}{\\partial p}\\)\n\\item \\(\\hat{p}=p\\)\n\\end{itemize}\n\n\\subsubsection{Change of Basis}\n\\(x\\) basis: \\(\\displaystyle\\Psi(x,t)=\\frac{1}{\\sqrt{2\\pi\\hbar}}\\int_{-\\infty}^{\\infty}e^{ipx/\\hbar}\\Phi(p,t)\\,\\mathrm{d}p\\)\\\\\\\\*\n\\(p\\) basis: \\(\\displaystyle\\Phi(p,t)=\\frac{1}{\\sqrt{2\\pi\\hbar}}\\int_{-\\infty}^{\\infty}e^{-ipx/\\hbar}\\Psi(x,t)\\,\\mathrm{d}x\\)\n\n\\subsubsection{Commutation Relations}\n\\([A,B]=AB-BA\\)\\\\*\n\\([A,B]_+=AB+BA\\)\\\\*\n\\([AB,C]=A[B,C]+[A,C]B\\)\\\\\\\\*\n\\([\\hat{x},\\hat{p}]=i\\hbar\\)\\\\*\n\\(\\displaystyle [f(\\hat{x}),\\hat{p}]=i\\hbar\\frac{\\mathrm{d}f}{\\mathrm{d}x}\\)\\\\*\n\\([\\hat{L}_i,\\hat{L}_j]=\\epsilon_{ijk}i\\hbar\\hat{L}_k\\)\\\\*\n\\([\\hat{L}^2,\\hat{L}_i]=0\\)\\\\*\n\\([H,\\hat{L}_i]=[H,\\hat{L}^2]=0\\)\n\n\\subsubsection{Uncertainty Principle}\nStandard Deviation: \\(\\sigma_A=\\sqrt{\\langle A^2\\rangle-\\langle A\\rangle^2}\\)\\\\\\\\*\n\\(\\sigma_A\\sigma_B \\geq \\frac{1}{2}|\\langle[A,B]\\rangle|\\)\\\\\\\\*\nCommon uncertainties:\\\\*\n\\(\\sigma_x\\sigma_p\\geq\\frac{\\hbar}{2}\\)\\\\*\n\\(\\sigma_E\\sigma_t\\geq\\frac{\\hbar}{2}\\)\\\\*\n\\(\\sigma_{L_x}\\sigma_{L_y}\\geq\\frac{\\hbar}{2}|\\langle L_z\\rangle|\\)\n\n\\subsubsection{Ehrenfest's Theorem}\n\\(\\displaystyle \\frac{\\mathrm{d}}{\\mathrm{d}t}\\langle\\hat{Q}\\rangle=\\frac{i}{\\hbar}\\langle[H,\\hat{Q}]\\rangle+\\left<\\frac{\\partial \\hat{Q}}{\\partial t}\\right>\\)\\\\\\\\*\nUses:\\\\*\n\\(\\displaystyle \\frac{\\mathrm{d}}{\\mathrm{d}t}\\langle\\mathbf{p}\\rangle=\\langle-\\nabla V\\rangle\\)\\\\*\n\\(\\displaystyle \\frac{\\mathrm{d}}{\\mathrm{d}t}\\langle\\mathbf{L}\\rangle=\\langle\\mathbf{r}\\times(-\\nabla V)\\rangle\\)\n\\newpage\n\\subsubsection{Probability}\nProbability Density: \\(\\int_{-\\infty}^{\\infty} P(\\mathbf{r})\\,\\mathrm{d}\\mathbf{r}=\\int_{-\\infty}^{\\infty} |\\Psi(\\mathbf{r})|^2\\,\\mathrm{d}\\mathbf{r}\\)\\\\*\nMost Probable Value of \\(r\\): set \\(\\frac{\\mathrm{d}}{\\mathrm{d}r}|\\psi(r)|^2r^2=0\\), then solve for \\(r\\) (the \\(r^2\\) comes from \\(\\mathrm{d}\\mathbf{r} = r^2\\sin(\\theta)\\mathrm{d}r\\mathrm{d}\\theta\\mathrm{d}\\phi\\))\\\\\\\\*\nProbability Current: \\(\\displaystyle J(x,t)=\\frac{i\\hbar}{2m}\\left(\\psi\\frac{\\partial\\psi^*}{\\partial x}-\\psi^*\\frac{\\partial\\psi}{\\partial x}\\right)\\)\\\\*\nProbability of finding a particle in the range \\(a<x<b\\) at time \\(t\\): \\(\\displaystyle\\frac{\\mathrm{d}P_{ab}}{\\mathrm{d}t}=J(a,t)-J(b,t)\\)\\\\\\\\*\n\\(\\displaystyle\\langle H\\rangle=\\sum_{n=1}^{m}|c_n|^2E_n\\)\\\\*\n(same \\(c_n\\) as in \\(\\displaystyle\\sum_{n=1}^{m}c_n\\psi_n(\\mathbf{r},0)e^{-iE_nt/\\hbar}\\))\\\\*\n\\(|c_n|^2\\) tells you the probability that a measurement of the energy would yield the value \\(E_n\\).\\\\*\n\\(\\displaystyle\\sum_{n=1}^{m}|c_n|^2=1\\)\n\n\\subsection{Common Solved Problems}\nBe sure to study how each of these solutions look like when they are plotted (especially the first two).\nSpecifically, focus on how many ``nodes'' each eigenfunction has and where they are located.\nWhen an infinite barrier is introduced to a potential only eigenfunctions with a ``node'' at that barrier survive (think ``wave on a string'').\n\n\\subsubsection{Infinite Square Well}\nPotential: \\[V(x) = \\left\\{\n\\begin{array}{l l}\n  0 & \\quad \\mbox{\\(0<x<a\\)}\\\\\n  \\infty & \\quad \\mbox{otherwise}\\\\ \\end{array} \\right. \\]\nEigenfunctions: \\(\\psi_n(x)=\\sqrt{\\frac{2}{a}}\\sin(k_nx)\\) where \\(k_n=\\frac{n\\pi}{a}\\), \\(n=1,2,3,\\ldots\\)\\\\*\nEnergy Levels: \\(\\displaystyle E_n=\\frac{\\hbar^2k_n^2}{2m}=\\frac{\\hbar^2\\pi^2}{2ma^2}n^2\\)\n\n\\subsubsection{Harmonic Oscillator}\nPotential: \\(V(x)=\\frac{1}{2}m\\omega^2x^2\\)\\\\*\nEigenfunctions: \\(\\psi_n(x)=\\frac{1}{\\sqrt{n!}}(a_+)^n\\psi_0\\) where \\(a_+\\) is the raising operator and\\\\*\n\\(\\displaystyle\\psi_0(x)=\\left(\\frac{m\\omega}{\\pi\\hbar}\\right)^{1/4}e^{-\\frac{m\\omega}{2\\hbar}x^2}\\)\\\\*\nEnergy Levels: \\(\\displaystyle\\hbar\\omega\\left(n+\\frac{1}{2}\\right)\\),  \\(n=0,1,2,\\ldots\\)\\\\\\\\*\nRaising and Lowering Operators: \\(a_{\\pm}=\\frac{1}{\\sqrt{2\\hbar m\\omega}}(\\pm ip+m\\omega x)\\)\\\\*\n\\([a_-,a_+]=1\\)\\\\*\n\\(H=\\hbar\\omega\\left(a_-a_+-\\frac{1}{2}\\right)=\\hbar\\omega\\left(a_+a_-+\\frac{1}{2}\\right)\\)\\\\*\n\\(a_+\\psi_n=\\sqrt{n+1}\\psi_{n+1}\\)\\\\*\n\\(a_-\\psi_n=\\sqrt{n}\\psi_{n-1}\\)\\\\*\n\\(a_-a_+\\psi_n=(n+1)\\psi_{n}\\)\\\\*\n\\(a_+a_-\\psi_n=n\\psi_{n}\\)\\\\*\nof course, \\(a_-\\psi_0=0\\) and \\(a_+\\psi_{n_{highest}}=0\\)\n\n\\subsubsection{Free Particle}\nPotential: \\(V(x)=0\\)\\\\*\n\\(v_{classical}=v_{group}=2v_{phase}\\)\\\\\\\\*\n\\(\\displaystyle\\Psi(x,t)=\\frac{1}{\\sqrt{2\\pi}}\\int_{-\\infty}^{\\infty}\\phi(k)e^{i(kx-\\frac{\\hbar k^2}{2m}t)}\\,\\mathrm{d}k\\)\\\\*\nwhere \\(\\displaystyle\\phi(k)=\\frac{1}{\\sqrt{2\\pi}}\\int_{-\\infty}^{\\infty}\\Psi(x,0)e^{-ikx}\\,\\mathrm{d}x\\)\n\n\\subsubsection{Delta-Function Potential}\nPotential: \\(V(x)=-\\alpha\\delta(x)\\)\\\\*\nEigenfunction: \\(\\displaystyle\\psi(x)=\\frac{\\sqrt{m\\alpha}}{\\hbar}e^{-m\\alpha|x|/\\hbar^2}\\)\\\\*\nOnly One Bound State Energy: \\(\\displaystyle E_0=-\\frac{m\\alpha^2}{2\\hbar^2}\\)\\\\\\\\*\nReflection \\& Transmission Coefficients:\\\\\\\\*\n\\(R+T=1\\)\\\\\\\\*\n\\(\\displaystyle R=\\frac{1}{1+(E/|E_0|)}\\)\\\\*\n\\(\\displaystyle T=\\frac{1}{1+(|E_0|/E)}\\)\n\n\\subsubsection{Finite Square Well}\nPotential: \\[V(x) = \\left\\{\n\\begin{array}{l l}\n  -V_0 & \\quad \\mbox{\\(-a<x<a\\)}\\\\\n  0 & \\quad \\mbox{otherwise}\\\\ \\end{array} \\right. \\]\nWith a wide, deep well the energies approach those of an infinite square well.\\\\*\n\\(\\displaystyle E_n+V_0=\\frac{\\hbar^2k_n^2}{2m}\\)\\\\\\\\*\nWith a shallow, narrow well there will always be at least one bound state no matter how weak the well is.\n\\newpage\n\\subsubsection{Hydrogen Atom}\nPotential: \\(\\displaystyle V(r)=-\\frac{e^2}{4\\pi\\epsilon_0}\\frac{1}{r}\\)\\\\*\nThe eigenfunctions (\\(\\psi_{nlm_l}(r,\\theta,\\phi)\\)) are complicated and involve Laguerre polynomials and the spherical harmonics.\nHowever, the ground state of the hydrogen atom is easy to remember.\\\\*\n\\(\\displaystyle\\psi_{100}(r)=\\frac{1}{\\sqrt{\\pi a^3}}e^{-r/a}\\) where \\(a\\) is the Bohr radius (\\(a\\approx .53\\mathrm{\\text{\\AA}}\\))\\\\*\nEnergy Levels: \\(\\displaystyle E_n=-\\frac{E_1}{n^2}\\) where \\(E_1\\approx 13.6\\mathrm{eV}\\)\\\\*\nIt is important to know that \\(E_1\\propto m_eZ_1^2Z_2^2\\) where \\(m_e\\) is the mass of the orbiting body (electron), \\(Z_1\\) is the charge of the orbiting body (in units of electron charge), and \\(Z_2\\) is the charge of the central body (nucleus).\\\\\\\\*\nETS frequently makes you alter the energy level formula for positronium and helium.\nJust replace \\(m_e\\) in \\(E_1\\) with the reduced mass \\(\\mu=\\frac{m_e}{2}\\) for positronium.\nFor helium, just remember \\(Z_2\\to 2\\).\n\n\\subsection{Angular Momentum}\nOrbital: \\(\\mathbf{L}\\times\\mathbf{L}=i\\hbar\\mathbf{L}\\) (or \\([\\hat{L}_i,\\hat{L}_j]=\\epsilon_{ijk}i\\hbar\\hat{L}_k\\))\\\\*\nThis means that one cannot have a completely determined angular momentum \\emph{vector} just as one cannot completely determine both position and momentum.\\\\\\\\*\nSpin: \\(\\mathbf{S}=\\frac{\\hbar}{2}\\vec{\\sigma}\\)\\\\\\\\*\nPauli matrices: \\(\\sigma_x= \\left[\\!\n  \\begin{array}{ c c }\n     0 & 1 \\\\\n     1 & 0\n  \\end{array} \\!\\right]\n\\),\n\\(\\sigma_y= \\left[\\!\n  \\begin{array}{ c c }\n     0 & -i \\\\\n     i & 0\n  \\end{array} \\!\\right]\n\\),\n\\(\\sigma_z= \\left[\\!\n  \\begin{array}{ c c }\n     1 & 0 \\\\\n     0 & -1\n  \\end{array} \\!\\right]\n\\)\\\\\\\\*\nIt is convenient to express spin in terms of up/down vectors:\\\\*\nUp: \\(|\\!\\uparrow\\rangle=\\left[\\!\\begin{array}{c}1 \\\\ 0 \\end{array}\\!\\right]\\)\\\\*\nDown: \\(|\\!\\downarrow\\rangle=\\left[\\!\\begin{array}{c}0 \\\\ 1 \\end{array}\\!\\right]\\)\\\\*\n\\(\\mathbf{S}\\times\\mathbf{S}=i\\hbar\\mathbf{S}\\)\\\\\\\\*\nTotal: \\(\\mathbf{J}=\\mathbf{L}+\\mathbf{S}\\)\\\\*\n\\(\\mathbf{J}\\times\\mathbf{J}=i\\hbar\\mathbf{J}\\)\n\n\\subsubsection{Raising and Lowering Operators}\n\\(\\hat{L}_\\pm=\\hat{L}_x\\pm i\\hat{L}_y\\)\\\\*\n\\([\\hat{L}_z,\\hat{L}_\\pm]=\\pm\\hbar\\hat{L}_\\pm\\)\n\n\\subsubsection{Eigenvalues}\n\\(\\hat{L}^2|lm_l\\rangle=l(l+1)\\hbar^2|lm_l\\rangle\\), \\(l=0,1,2,\\ldots,n\\)\\\\*\n\\(\\hat{L}_z|lm_l\\rangle=m_l\\hbar|lm_l\\rangle\\), \\(m_l=-l,-l+1,\\ldots,0,\\ldots,l-1,l\\)\\\\*\n\\(\\hat{L}_\\pm|lm_l\\rangle=A_l^{m_l}\\hbar^2|l(m_l\\pm 1)\\rangle\\)\\\\\\\\*\n\\(\\hat{S}^2|sm_s\\rangle=s(s+1)\\hbar^2|sm_s\\rangle\\), \\(s=0,1,2,\\ldots\\)\\\\*\n\\(\\hat{S}_z|sm_s\\rangle=m_s\\hbar|sm_s\\rangle\\), \\(m_s=-s,-s+1,\\ldots,0,\\ldots,s-1,s\\)\n\n\\subsubsection{Addition of Angular Momentum}\n\\(s=1\\) (triplet states):\\\\*\n\\(|11\\rangle =\\) \\( \\uparrow\\uparrow\\)\\\\*\n\\(|10\\rangle =\\) \\(\\frac{1}{\\sqrt{2}}(\\uparrow\\downarrow+\\downarrow\\uparrow)\\)\\\\*\n\\(|1(-1)\\rangle =\\) \\(\\downarrow\\downarrow\\)\\\\\\\\*\n\\(s=0\\), \\(m_s=0\\) (singlet state):\\\\*\n\\(|00\\rangle =\\) \\(\\frac{1}{\\sqrt{2}}(\\uparrow\\downarrow-\\downarrow\\uparrow)\\)\n\n\\subsection{Time-Independent Perturbation Theory}\n\\(H=H_0+\\lambda\\Delta H\\) where \\(H_0\\) is a solvable Hamiltonian with basis functions \\(|n^{(0)}\\rangle\\)\\\\*\n\\(E_n=E_n^{(0)}+\\lambda E_n^{(1)}+\\ldots\\)\\\\*\n\\(|n\\rangle=|n^{(0)}\\rangle+\\lambda |n^{(1)}\\rangle+\\ldots\\)\n\n\\subsubsection{First-Order Energy Correction}\n\\(E_n^{(1)}=\\langle n^{(0)}|\\Delta H|n^{(0)}\\rangle\\)\n\n\\subsubsection{First-Order Eigenfunction Correction}\n\\(\\displaystyle |n^{(1)}\\rangle=\\sum_{k\\neq n}\\frac{\\langle k^{(0)}|\\Delta H|n^{(0)}\\rangle}{E_n^{(0)}-E_k^{(0)}}|k^{(0)}\\rangle\\)\\\\*\nThe key point of this equation is \\(\\langle k^{(0)}|\\Delta H|n^{(0)}\\rangle\\), which determines what new eigenfunctions will be zero (typically using even/odd symmetry arguments).\n", "meta": {"hexsha": "5af7c028e069b606d2dc81f0b82ba7a608fe6709", "size": 10912, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/quantum_mech.tex", "max_stars_repo_name": "jhetherly/Physics_GRE_Review", "max_stars_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-11T13:33:29.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-11T13:33:29.000Z", "max_issues_repo_path": "src/quantum_mech.tex", "max_issues_repo_name": "jhetherly/Physics_GRE_Review", "max_issues_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/quantum_mech.tex", "max_forks_repo_name": "jhetherly/Physics_GRE_Review", "max_forks_repo_head_hexsha": "3edbd342c1d1bf39502b4c6838828501e145e408", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.9619047619, "max_line_length": 252, "alphanum_fraction": 0.6435117302, "num_tokens": 4209, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.41224207981978217}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, sfmath, tikz, xcolor, pgfplots, array}\n\\pgfplotsset{compat = 1.16}\n\\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}\n\n\\title{Parabolas}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Table of Contents}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\maketitle\n\\end{frame}\n\n\\section{Find the vertex, focus, and directrix for a parabola in standard form.}\n\n\\begin{frame}{Intro}\nIf we look at the graph of the quadratic function $f(x) = ax^2 + bx + c$, we obtain what is known as a \\emph{parabola}.    \\newline\\\\    \\pause\n\nA \\alert{parabola} is the set of all points in the plane that are the same distance from the focus and the directrix line.\n\\end{frame}\n\n\\begin{frame}{}\n\\begin{center}\n\\begin{tikzpicture}\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -4,\n    xmax = 12,\n    ymin = 0,\n    ymax = 10,\n    xtick = \\empty,\n    ytick = \\empty]\n    \\addplot [color=blue, <->, samples=200, domain=-0.5:6.5, line width = 1.5] {2 + 0.5*(x-3)^2} node[right]{\\color{blue}{\\textbf{Parabola}}};\n    \\addplot [mark = *] (3, 3) node[above]{Focus};\n    \\addplot [dashed, <->, samples=200, domain = -3:8] {1} node[right]{Directrix};\n    \\addplot [mark = *] (3, 2);\n    \\draw [<-] (3.25,2) -- (6,2.5) node[right]{Vertex};\n    \\draw [color=red] (3,1) rectangle (2.5,1.5);\n    \\draw [color=red, dashed] (3,3) -- (3,2) -- (3,1);\n    \\end{axis}\n\\end{tikzpicture}\n\\end{center}\n\\pause\n\nThe \\alert{focal length} is the distance between the focus and vertex (or directrix and vertex) and is $|p|$.\n\\end{frame}\n\n\\begin{frame}{Equations}\n    \\begin{center}\n    \\setlength{\\extrarowheight}{5pt}\n    \\begin{tabular}{c|c|c}\n    &   \\textbf{Opens Up or Down}   &   \\onslide<2->{\\textbf{Opens Left or Right}}    \\\\  \\hline\n    &   $(x-h)^2 = 4p(y-k)$  &   \\onslide<2->{$(y-k)^2 = 4p(x-h)$}  \\\\[5pt]  \\hline\n    Vertex  &   $(h,k)$ &   \\onslide<2->{$(h,k)$} \\\\[5pt]  \\hline\n    Focus Point   &   $(h, k+p)$    &   \\onslide<2->{$(h+p, k)$}  \\\\[5pt] \\hline\n    Directrix   &   $y = k-p$   &   \\onslide<2->{$x = h-p$}   \\\\\n    \\end{tabular}\n\\end{center}\n\\vspace{11pt}\n\\onslide<3->{\n\\emph{Note}: Sometimes the equations are written as \n\\[y = \\frac{1}{4p}(x-h)^2 + k \\text{ and } x = \\frac{1}{4p}(y-k)^2 + h\\].}\n\\end{frame}\n\n\\begin{frame}{Finding Vertex Without Technology}\n    For $y = ax^2 + bx + c$  \\\\[8pt] \\pause\n    \\begin{enumerate}\n        \\item $x$-coordinate: $-\\frac{b}{2a}$   \\\\[8pt]   \\pause\n        \\item $y$-coordinate: Evaluate at $x$-coordinate \\\\[18pt] \\pause\n    \\end{enumerate}\n    \n    For $x = ay^2 + by + c$ \\\\[8pt] \\pause\n    \\begin{enumerate}\n        \\item $y$-coordinate: $-\\frac{b}{2a}$   \\\\[8pt] \\pause\n        \\item $x$-coordinate: Evaluate at $y$-coordinate\n    \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{Example 1}\nFind the vertex, focus, and directrix line for $(x+1)^2 = -8(y-3)$. \\pause\nGraph the parabola: \\newline\\\\\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}[scale=0.4]\n    \\draw [color=gray, dashed] (-8,-5) grid (6,6);\n    \\draw [<->, >=stealth] (-8.5,0) -- (6.5,0);\n    \\draw [<->, >=stealth] (0,-5.5) -- (0,6.5);\n    \\foreach \\x in {-8,-7,...,6}\n    \\draw (\\x, 0.2) -- (\\x,-0.2);\n    \\foreach \\y in {-5,-4,...,6}\n    \\draw (0.2,\\y) -- (-0.2,\\y);\n    \\draw [<->, >=stealth, domain=-8:6, color=red, line width = 1.25] plot (\\x, {-0.125*(\\x+1)*(\\x+1)+3});\n    \\onslide<3->{\\draw[color=red, fill=red] (-1,3) circle (4pt);}\n    \\onslide<8->{\\draw[color=blue, fill=blue] (-1,1) circle (4pt);}\n    \\onslide<10->{\\draw[color=violet, <->, >=stealth, line width=1.25, dashed] (-8,5) -- (6,5);}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<4->{Vertex: $(-1,3)$} \\\\[8pt]\n\\onslide<5->{$4p = |-8|$} \\\\[8pt]\n\\onslide<6->{$p = 2$} \\\\[8pt]\n\\onslide<7->{Focus: $(-1, 3-2)$} \\\\[8pt]\n\\onslide<8->{Focus: $(-1,1)$} \\\\[8pt]\n\\onslide<9->{Directrix: $y = 3 + 2$} \\\\[8pt]\n\\onslide<10->{Directrix: $y = 5$} \n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 2}\nFind the vertex, focus, and directrix for $(y-2)^2 = 12(x+1)$.  \\newline\\\\\n\\pause\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.5]\n    \\draw [dashed, gray] (-4,-3) grid (4.5,7.5);\n      \\draw[<->, >=stealth] (-4.5,0) -- (4.5,0) node[right] {$x$};\n      \\draw[<->, >=stealth] (0,-3) -- (0,7.5) node[above] {$y$};\n      \\foreach \\x in {-4,-3,-2,...,4}\n      \\draw (\\x, 0.1) -- (\\x, -0.1);\n      \\foreach \\y in {-3,-2,...,7}\n      \\draw (0.1,\\y) -- (-0.1,\\y);\n      \\draw[<->, >=stealth, line width = 1.25, domain=-3:7,smooth,variable=\\y,red]  plot ({0.0833*\\y*\\y - 0.333*\\y - 0.667},\\y);\n      \\draw [color=red, fill=red] (-1,2) circle (4pt);\n      \\onslide<6->{\\draw[color=blue, fill=blue] (2,2) circle (4pt);}\n      \\onslide<7->{\\draw[<->,>=stealth, line width = 1.25, dashed, color=violet] (-4,-3.5) -- (-4,7.5);}\n    \\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.6cm}\n\\begin{minipage}{0.48\\textwidth}\n\\onslide<3->{Vertex: $(-2,1)$} \\\\[10pt]\n\\onslide<4->{$4p = 12$} \\\\[10pt]\n\\onslide<5->{$p = 3$} \\\\[10pt]\n\\onslide<6->{Focus: $(-1+3, 2) \\rightarrow (2,2)$} \\\\[10pt]\n\\onslide<7->{Directrix: $x = -1-3$} \\\\[10pt]\n\\onslide<8->{$x = -4$} \\\\\n\\end{minipage}\n\\end{frame}\n\n\\section{Find the equation of the standard form of a parabola.}\n\n\\begin{frame}{Latus Rectum and Focal Diameter}\nThe \\alert{latus rectum} of a parabola is a line segment through the focus point that is parallel to the directrix line.   \\newline\\\\\n\\pause\nThe \\alert{focal diameter} is the length of the latus rectum, and is $\\mid 4p \\mid$.  \\newline\\\\\n\\pause\n\\begin{center}\n    \\begin{tikzpicture}[scale=0.8]\n    \\begin{axis}[\n    axis lines = middle,\n    xmin = -4,\n    xmax = 12,\n    ymin = 0,\n    ymax = 10,\n    xtick = \\empty,\n    ytick = \\empty]\n    \\addplot [color=blue, <->, samples=200, domain=-0.5:6.5, line width = 1.5] {1 + 0.5*(x-3)^2};\n    \\addplot [mark = *] (3, 3);\n    \\addplot [dashed, domain=1:5, line width = 1.25] {3} node [midway, above, yshift=0.2cm] {L.R.};\n    \\draw [decoration = {brace}, decorate] (1,3.2) -- (5,3.2);\n    \\end{axis}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 3}\nFind the standard form of the parabola with focus $(2, 1)$ and directrix $y = -4$.   \\newline\\\\\n\\begin{minipage}{0.6\\textwidth}\n\\begin{tikzpicture}[scale=0.4]\n\\draw [gray, dashed] (-5,-5) grid (7,5);\n\\draw [<->, >=stealth] (-5.5,0) -- (7.5,0) node [right] {$x$};\n\\draw [<->, >=stealth] (0,-5.5) -- (0,5.5) node [right] {$y$};\n\\foreach \\x in {-5,-4,...,7}\n\\draw (\\x, 0.1) -- (\\x, -0.1);\n\\foreach \\y in {-5,-4,...,5}\n\\draw (0.1,\\y) -- (-0.1,\\y);\n\\draw [<->, >=stealth, color=blue, line width = 1.25] (-5,-4) -- (7,-4);\n\\draw [color=red, fill=red] (2,1) circle (4pt);\n\\onslide<2->{\\draw [color=blue, fill=blue] (2,-4) circle (4pt);}\n\\onslide<8->{\\draw [<->, >=stealth, domain = -3:7, line width = 1.25] plot (\\x, {0.1*(\\x-2)*(\\x-2)-1.5});}\n\\onslide<3->{\\draw [fill=black] (2,-1.5) circle (4pt);}\n\\end{tikzpicture}\n\\end{minipage}\n\\begin{minipage}{0.35\\textwidth}\n\\onslide<4->{Vertex: $(2,-1.5)$}    \\\\[11pt]\n\\onslide<5->{$p = 2.5$} \\\\[11pt]\n\\onslide<6->{$4p = 10$} \\\\[11pt]\n\\onslide<7->{$(x-2)^2 = 10(y+1.5)$} \\\\\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Converting Equations}\nTo convert parabolas in $y = ax^2 + bx + c$ form to standard form, do the following:  \\newline\\\\  \\pause\n\\begin{enumerate}\n    \\item Find the coordinates of the vertex. This will give you $h$ and $k$.    \\pause  \\\\[11pt]\n    \\item Use the relationship that $4p = \\frac{1}{a}$.\n\\end{enumerate}    \n\\end{frame}\n\n\\begin{frame}{Example 4a}\nFind the vertex, focus, and directrix of the following. \\newline\\\\\n(a) \\quad $y^2 + 4y + 8x = 4$   \\newline\\\\  \\pause\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.4]\n    \\draw [dashed, gray] (-2,-7) grid (3,3);\n      \\draw[<->, >=stealth] (-2.5,0) -- (3.5,0) node[right] {$x$};\n      \\draw[<->, >=stealth] (0,-7.5) -- (0,3.5) node[above] {$y$};\n      \\foreach \\x in {-2,-1,...,3}\n      \\draw (\\x, 0.2) -- (\\x, -0.2);\n      \\foreach \\y in {-7,-6,...,3}\n      \\draw (0.2,\\y) -- (-0.2,\\y);\n      \\draw[<->, >=stealth, line width = 1.25, domain=-7:3,smooth,variable=\\y,red]  plot ({-0.125*(\\y*\\y + 4*\\y - 4)},\\y);\n      \\onslide<4->{\\draw[color=red,fill=red] (1,-2) circle (4pt);}\n      \\onslide<8->{\\draw[color=blue,fill=blue] (-1,-2) circle (4pt);}\n      \\onslide<10->{\\draw[color=violet, line width=1.25, dashed, <->, >=stealth] (3,-7) -- (3,3);}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{0.25cm}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<3->{Vertex: $(1,-2)$} \\\\[10pt]\n\\onslide<5->{$4p = |8|$} \\\\[10pt]\n\\onslide<6->{$p = 2$} \\\\[10pt]\n\\onslide<7->{Focus: $(1-2, -2)$} \\\\[10pt]\n\\onslide<8->{Focus: $(-1,-2)$} \\\\[10pt]\n\\onslide<9->{Directrix: $x = 1 + 2$} \\\\[10pt]\n\\onslide<10->{Directrix: $x = 3$}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Example 4b}\n(b) \\quad $x^2 - 2x + 5y = 1$   \\newline\\\\  \\pause\n\\begin{minipage}{0.4\\textwidth}\n\\begin{tikzpicture}[scale=0.6]\n    \\draw[dashed, gray] (-3,-4) grid (5,2);\n    \\draw[<->,>=stealth] (-3.5,0)--(5.5,0) node [right] {$x$};\n    \\draw[<->,>=stealth] (0,-4.5)--(0,2.5) node [above] {$y$};\n    \\draw[<->,>=stealth,color=red,line width=1.25,domain=-3:5] plot (\\x, {-0.2*(\\x-1)*(\\x-1)+0.4});\n    \\onslide<4->{\\draw[color=red,fill=red] (1,0.4) circle (4pt);}\n    \\onslide<8->{\\draw[color=blue,fill=blue] (1,-0.85) circle (4pt);}\n    \\onslide<10->{\\draw[color=violet,<->,>=stealth,dashed,<->,>=stealth,line width = 1.25] (-3,1.65) -- (5,1.65);}\n\\end{tikzpicture}\n\\end{minipage}\n\\hspace{1.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<3->{Vertex: $\\left(1,\\frac{2}{5}\\right)$} \\\\[8pt]\n\\onslide<5->{$4p = |5|$} \\\\[8pt]\n\\onslide<6->{$p = 5/4$} \\\\[8pt]\n\\onslide<7->{Focus: $\\left(1, \\frac{2}{5}-\\frac{5}{4}\\right)$} \\\\[8pt]\n\\onslide<8->{Focus: $\\left(1, -\\frac{17}{20}\\right)$} \\\\[8pt]\n\\onslide<9->{Directrix: $y = \\frac{2}{5} + \\frac{5}{4}$} \\\\[8pt]\n\\onslide<10->{Directrix: $y = \\frac{33}{20}$} \\\\\n\\end{minipage}\n\\end{frame}\n\n\\section{Applications of Parabolas}\n\n\\begin{frame}{Paraboloid}\n    If we rotate a parabola around its axis of symmetry, we obtain a 3-D model of a parabola called a \\alert{paraboloid}, or a \\alert{paraboloid of revolution}.    \\newline\\\\  \\pause\n    \n    The nature of paraboloids allows signals to be sent to or from the focus in a directed manner.\n\\end{frame}\n\n\\begin{frame}{Example 5}\n    A satellite dish is to be constructed in the shape of a paraboloid of revolution. If the receiver placed at the focus is located 2 ft above the vertex of the dish, and the dish is to be 12 feet wide, how deep will the dish be?    \n\\end{frame}\n\n\\begin{frame}{Example 5}\n    If we place the vertex at the origin and open the graph upward, \\onslide<2->{we get the equation $x^2 = 8y$}    \\newline\n    \\begin{minipage}{0.5\\textwidth}\n        \\begin{tikzpicture}[scale=0.45]\n            \\draw[dashed, gray] (-7,0) grid (7,6);\n            \\draw[<->,>=stealth] (-7.5,0) -- (7.5,0) node [right] {$x$};\n            \\draw[->,>=stealth] (0,0) -- (0,6) node [above] {$y$};\n            \\draw[<->,>=stealth,color=red,domain=-7:7,line width=1.25] plot ({\\x, 0.125*\\x*\\x});\n            \\draw[color=blue,fill=blue] (0,2) circle (4pt);\n            \\onslide<3->{\\draw[|<->|,>=stealth,color=violet] (0,5) -- (6,5) node [midway, above] {6 ft};}\n            \\onslide<5->{\\draw[color=red,fill=red] (6,4.5) circle (4pt) node [right] {$(6,y)$};}\n        \\end{tikzpicture}\n    \\end{minipage}\n    \\hspace{1cm}\n    \\begin{minipage}{0.3\\textwidth}\n    \\begin{align*}\n        \\onslide<4->{x^2 &= 8y} \\\\[10pt]\n        \\onslide<6->{6^2 &= 8y} \\\\[10pt]\n        \\onslide<7->{36 &= 8y} \\\\[10pt]\n        \\onslide<8->{y &= \\frac{36}{8}} \\\\[10pt]\n        \\onslide<9->{y &= \\frac{9}{2}} \\\\\n    \\end{align*}\n    \\end{minipage}\n\\end{frame}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "e509678c612c96cd8d07dd99a95645bf84b43d57", "size": 11868, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Parabolas(BEAMER).tex", "max_stars_repo_name": "BryanBain/Trig_BEAMER", "max_stars_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Parabolas(BEAMER).tex", "max_issues_repo_name": "BryanBain/Trig_BEAMER", "max_issues_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Parabolas(BEAMER).tex", "max_forks_repo_name": "BryanBain/Trig_BEAMER", "max_forks_repo_head_hexsha": "3639d0202fc691738d26f922d9e84f0a0d62b42a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:06.000Z", "avg_line_length": 38.4077669903, "max_line_length": 234, "alphanum_fraction": 0.5726322885, "num_tokens": 4892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.41222801680848375}}
{"text": "%!TEX root = ./egpaper_for_review.tex\n%\n\\section{Introduction}\nCorrelation clustering~\\cite{Bansal-2002}, also known as the multicut problem~\\cite{chopra_1993_mp} \nis a basic primitive in computer vision~\\cite{andres_2011_iccv,kroeger_2012_eccv,yarkony_2012_eccv,alush_2013_simbad} and data mining~\\cite{Arasu-2009,Sadikov-2010,Chen-2012,Chierichetti-2014}.\nSee Sec.~\\ref{sec:problem_formulation} for its formal definition of clustering the nodes of a graph.\n \nIts merit is, firstly, that it accommodates both positive (attractive) \\emph{and} negative (repulsive) edge weights.\nThis allows doing justice to evidence in the data that two nodes or pixels do not wish or do wish to end up in the same cluster or segment, respectively.\nSecondly, it does not require a specification of the number of clusters beforehand.\n\n\nIn signed social networks, where positive and negative edges encode friend and foe relationships, respectively,\ncorrelation clustering is a natural way to detect communities~\\cite{Chen-2012,Chierichetti-2014}.\nCorrelation clustering can also be used to cluster query refinements in web search~\\cite{Sadikov-2010}.\nBecause social and web-related networks are often huge, heuristic methods, \\eg the PIVOT-algorithm~\\cite{Ailon-2008},\nare popular~\\cite{Chierichetti-2014}.\n\nIn computer vision applications, unsupervised image segmentation algorithms often start with an over-segmentation\ninto superpixels (superregions), which are then clustered into ``perceptually meaningful''\nregions by correlation clustering.\nSuch an approach has been shown to yield\nstate-of-the-art results on the Berkeley Segmentation Database\n\\cite{andres_2011_iccv,Kim-2011,yarkony_2012_eccv,alush_2013_simbad}.\n\nWhile it has a clear mathematical formulation and nice properties,\ncorrelation clustering suffers from NP-hardness. \n%\nConsequently, partition problems on large scale data, \\eg\nhuge volume images in computational neuroscience~\\cite{kroeger_2012_eccv}\nor social networks~\\cite{Leskovec-2010}, \nare not tractable because reasonable solutions cannot be computed in acceptable time.\n\n% Importantly, this allows doing justice to evidence in the data that two nodes or pixels do \\emph{not} wish to end up in the same cluster or segment. This is in contrast to the submodular potentials so popularized by the graph cut algorithm, which only allow two nodes to be attracted to each other, or at most be agnostic about membership in the same cluster. Secondly, the algorithm does not require a specification of the number of clusters. This is in contrast to methods such as normalized cut \\cite{} that can only accommodate attractive interactions and hence need the number of clusters to be specified. \n\n% \\paragraph{Contribution.} The evident usefulness of correlation clustering and its clean and compact formulation in terms of an optimization problem, together with its unfortunate NP-hardness, are an invitation to develop fast approximate solvers. The basic idea of the move making algorithm proposed here is to maintain, at all times, a best current partitioning; and to iteratively improve it (as we show, monotonously) by considering diverse and cheaply generated proposal partitionings. Any two nodes that are in one cluster in both the current and the proposal partitioning are contracted. Edges to contracted nodes are equally combined and reweighted, and the correlation clustering problem is then solved on this reduced graph. We offer a polyhedral characterization of this strategy, and evaluate it in conjunction with two versatile proposal generators.   We conduct experiments on a broad range of data sets ranging from 2D and 3D segmentation problems to clustering in signed social networks. The results suggest that this simple move making algorithm is the fastest technique known today, reaching close to globally optimal solutions in a tenth or a hundredth of the time required by the most efficient exact solvers. \n\\vspace{0.1cm}\n\\noindent \\textbf{Contribution.}\nIn this work we present novel approaches that are designed for large scale correlation clustering problems.\nFirst, we define a novel energy based agglomerative clustering algorithm that monotonically increases the energy.\nWith this at hand we show how to improve the anytime performance of Cut, Clue \\& Cut~\\cite{beier_2014_cvpr}.\n%\nSecond, we improve the anytime performance of polyhedral multicut methods~\\cite{kappes_2013_arxiv} by more efficient separation procedures.\n%\nThird, we introduce cluster-fusion moves, which extend the original fusion moves~\\cite{Lempitsky-2010} \nused in supervised segmentation to the unsupervised case and give a polyhedral interpretation of this algorithm.\nFinally, we propose two versatile proposal generators, and evaluate the proposed methods on existing and new benchmark problems.\nExperiments show that we can improve the computation time by one to two magnitudes without worsening the segmentation \nquality significantly.\n \n\\vspace{0.1cm}\n\\noindent \\textbf{Related Work.}\nA natural approach is to solve the integer linear program (ILP) directly~\\ref{eq:edgeproblem}. \nTo this end, efficient separation procedures have been found~\\cite{kappes_2011_emmcvpr,kappes_2013_arxiv} that allow to iteratively augment the set of constraints until a valid partitioning is found. \nAlternatively, it is possible to relax the integrality constraints of the ILP formulation~\\cite{kappes_2013_arxiv}. \nSuch an outer relaxation can be iteratively tightened. However, intermediate solutions are fractional and therefore rounding is required to obtain a valid partitioning.\nFor the latter approach column generating methods exist, which work best on planar graphs~\\cite{yarkony_2012_eccv}. %or almost planar \\cite{yarkony-andres-2013} graphs. \n\nAnother line of work uses move making algorithms \nto optimize correlation clustering~\\cite{Kernighan-1970,bagon_2011_arxiv,beier_2014_cvpr}.\nStarting with an initial segmentation, auxiliary max-cut problems are (approximately) solved,\nsuch that the segmentation is strictly improved.\nAs shown in~\\cite{beier_2014_cvpr} only Cut, Glue \\& Cut (CGC)\ncan deal with large scale problems, but can also suffer from very large auxiliary problems.\n\nOutside computer vision, greedy methods~\\cite{Soon-2001,Ng-2002,Gionis-2007,Elsner-2008,Ailon-2008} have been suggested for correlation clustering problems, see \\cite{Elsner-2009} for an overview.\nThe PIVOT Algorithm~\\cite{Ailon-2008} iterates over all nodes in random order.\nIf the node is not assigned it constructs a cluster containing the node and all its \nunassigned positively linked neighbors.  \n%\nA widely used post-processing method is  Best One Element Move (BOEM)~\\cite{Gionis-2007}, which iteratively reassigns nodes to clusters.\n\nFor energy minimization problems fusion moves have become increasingly popular~\\cite{Lempitsky-2010,kappes_2014_ws}.\nFor many large scale computer vision applications fusion moves lead to good approximations\nwith state of the art anytime performance~\\cite{kappes_2014_ws}.\nDue to the ambiguity of a node-labeling, classical fusion moves~\\cite{Lempitsky-2010} cannot be applied directly for correlation clustering.\nWe will show how to overcome this problem in Sec.~\\ref{sec:cc_fm}.\n\n\n\\vspace{0.1cm}\n\\noindent \\textbf{Outline:} \nIn Sec.~\\ref{sec:problem_formulation} we give a \ndetailed problem definition and introduce \nthe correlation clustering objective.\nNext we give a description of energy based hierarchical clustering in Sec.~\\ref{sec:ehc} and\nour proposed correlation clustering fusion moves in Sec.~\\ref{sec:cc_fm}.\nWe evaluate the proposed methods in Sec.~\\ref{sec:exp} and conclude in Sec.~\\ref{sec:future} and \\ref{sec:conclusion}.\n\n%-------------------------------------------------------------------------\n\n\\input{inputs/fig_notation.tex}\n\\section{Notation and Problem Formulation}\\label{sec:problem_formulation}\nLet $G=(V,E, w)$ be a weighted graph of nodes $V$ and edges $E$.\n%\nThe function $w : E \\rightarrow \\mathbb{R}$ assigns a weight to each edge.\nWe will use $w_e$ as a shorthand for $w(e)$.\nA positive weight expresses the desire that two adjacent nodes should\nbe merged, whereas a negative weight indicates\nthat these nodes should be separated into two distinct regions.\n%\n%A \\emph{subgraph} $G_A = \\{A, E_A, w\\}$ consists\n%of nodes $A \\subseteq V$ and edges $E_A := E\\cap (A\\times A)$.\n%\n%\\input{inputs/fig_notation.tex}\nA segmentation of the graph $G$ can be either given by a\nnode labeling $l \\in \\mathbb{N}^{|V|}$\nor an edge labeling $y \\in\\{0,1\\}^{|E|}$, \\cf Fig.~\\ref{fig:notation}.\nAn edge labeling is only consistent if it does not violate any cycle constraint~\\cite{chopra_1993_mp}.\nWe denote the set of all consistent edge labelings by $P(G)\\subset\\{0,1\\}^{|E|}$.\nThe convex hull of this set is known as the \\emph{multicut polytope} $MC(G) = \\textrm{conv}(P(G))$.\n%\nBy $l(y)$ we denote some node labeling for a segmentation given by $y$.\n\nGiven a weighted graph $G=(V,E,w)$ we consider the problem of segmenting $G$ such that the costs\nof the edges between distinct segments is minimized. This can be formulated in the node domain\nby assigning each node $i$ a label $l_i \\in \\mathbb{N}$\n\\begin{align}\n  l^* &= \\argmin_{l \\in \\mathbb{N}^{|V|}} \\sum_{ (i,j) \\in E } w_{ij} \\cdot [l_{i} \\neq l_{j}], \\label{eq:nodeproblem}\n\\end{align} \nor in the edge domain, by labeling each edge $e$ as cut $y_e=1$ or uncut $y_e=0$ \n\\begin{align}\n  y^* &= \\argmin_{y \\in P(G)} \\sum_{ (i,j) \\in E } w_{ij} \\cdot y_{ij} \\label{eq:edgeproblem}.%\\\\ \n\\end{align}\nAs shown in~\\cite{kappes_2013_arxiv}  both problems are equivalent, but formulation \\ref{eq:nodeproblem}\nsuffers from ambiguities in the representation, \\cf Fig.~\\ref{fig:notation}. \n\n%\\input{inputs/fig_notation.tex}\n", "meta": {"hexsha": "1caa9a21b747e3a46660ee63c7e7d2db805deb77", "size": 9720, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/introduction-new.tex", "max_stars_repo_name": "DerThorsten/boring_spaghetti", "max_stars_repo_head_hexsha": "0cacb5cf66d5ebd09f060fda87efcdb7e9c487f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/introduction-new.tex", "max_issues_repo_name": "DerThorsten/boring_spaghetti", "max_issues_repo_head_hexsha": "0cacb5cf66d5ebd09f060fda87efcdb7e9c487f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/introduction-new.tex", "max_forks_repo_name": "DerThorsten/boring_spaghetti", "max_forks_repo_head_hexsha": "0cacb5cf66d5ebd09f060fda87efcdb7e9c487f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.9375, "max_line_length": 1232, "alphanum_fraction": 0.787037037, "num_tokens": 2464, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318194686359, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.41222800124482967}}
{"text": "\\documentclass[12pt,letterpaper]{article}\n\\author{Brian B. Maranville}\n\\title{Polarization correction for neutron reflectometry with transmission spin filters}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1.0in]{geometry}\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{mathtools}\n\\begin{document}\n\\maketitle\n\n\\section{Adaptation from source}\nAdaptation of polarization efficiency corrections from \n``Neutron scattering studies of magnetic thin films and multilayers''\n\nC.F. Majkrzak (1996). Physica B 221, 342-356\n\n\\url{http://dx.doi.org/10.1016/0921-4526(95)00948-5}\n\\subsection{flipper efficiency}\nFor any neutron-polarizing optical system, a spin-filter is chosen which selects a particular spin\nstate which we will call the dominant state.\n\nThe transmitted intensity of the dominant spin state through the polarizing optics (at the sample)\nis proportional to $(1 + F)$ when the front flipper is off and $(1 - F(1 - 2f))$ when the flipper is on; \nthe transmitted intensity of the other (leakage) spin state is $(1 - F)$ for flipper off and $(1 + F(1 - 2f))$\nfor flipper on, where $F, f$ are the efficiencies of the polarizer device and the flipper, respectively.\n$F$ and $f$ are defined such that $0 \\leq F \\leq 1$ and $0 \\leq f \\leq 1$, so that in the above\nequations, for a perfect polarized and flipper the transmission would be 1 for the dominant spin state\nwith the flipper off, with 0 leakage, and vice-versa with the flipper off.  The same set of equations holds\nfor the transmission through the spin-analyzer optics after the beam interacts with the sample: the analyzer\nefficiency and rear flipper efficiency will be written as $R, r$.\n\nIn the reference above, the math is defined for a supermirror polarizer and analyzer in the reflection geometry.\nThis corresponds to a dominant transmitted neutron spin state of $(+)$ when a flipper is \noff and $(-)$ when a flipper is on.\n\n\\subsection{spin-filter geometry: transmit or reflect}\nTo apply the equations in Table 2 of that reference to a system in which the supermirrors are\noperated in a transmission geometry, we have to reverse the sign of all the spin-dependent cross-sections described,\n(all the subscripts on the $\\sigma$) while keeping the relationship of transmission efficiencies to the flipper state\n(off vs. on) the same, e.g.\n\\begin{equation}\n\\begin{array}{rll}\n\tI^{\\textrm{off off}}_\\textrm{reflect} / \\beta =& {} & \\sigma_{++} (1 + F)(1 + R) \\\\\n\t {} & + & \\sigma_{-+} (1 - F)(1 + R) \\\\\n\t {} & + & \\sigma_{--} (1 - F)(1 - R) \\\\\n\t {} & + & \\sigma_{+-} (1 + F)(1 - R) \\\\\n\t {} & {} & {} \\\\\n\t I^{\\textrm{off on}}_\\textrm{reflect} / \\beta =& {} & \\sigma_{++} (1 + F)[1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{-+} (1 - F)[1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{--} (1 - F)[1 - R(1-2r)] \\\\\n\t {} & + & \\sigma_{+-} (1 + F)[1 - R(1-2r)] \\\\\n\\end{array}\n\\end{equation}\nfor a reflection polarizer/analyzer in the reference becomes\n\\begin{equation}\n\\begin{array}{rll}\n\tI^{\\textrm{off off}}_\\textrm{transmit} / \\beta =& {} & \\sigma_{--} (1 + F)(1 + R) \\\\\n\t {} & + & \\sigma_{+-} (1 - F)(1 + R) \\\\\n\t {} & + & \\sigma_{++} (1 - F)(1 - R) \\\\\n\t {} & + & \\sigma_{-+} (1 + F)(1 - R) \\\\\n\t {} & {} & {} \\\\\n\t I^{\\textrm{off on}}_\\textrm{transmit} / \\beta =& {} & \\sigma_{--} (1 + F)[1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{+-} (1 - F)[1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{++} (1 - F)[1 - R(1-2r)] \\\\\n\t {} & + & \\sigma_{-+} (1 + F)[1 - R(1-2r)] \\\\\n\\end{array}\n\\end{equation}\nand similarly for the other two flipper states...\n\\begin{equation}\n\\begin{array}{rll}\n\tI^{\\textrm{on off}}_\\textrm{transmit} / \\beta =& {} & \\sigma_{--} [1 + F(1-2f)](1 + R) \\\\\n\t {} & + & \\sigma_{+-} [1 - F(1-2f)](1 + R) \\\\\n\t {} & + & \\sigma_{++} [1 - F(1-2f)](1 - R) \\\\\n\t {} & + & \\sigma_{-+} [1 + F(1-2f)](1 - R) \\\\\n\t {} & {} & {} \\\\\n\t I^{\\textrm{on on}}_\\textrm{transmit} / \\beta =& {} & \\sigma_{--} [1 + F(1-2f)][1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{+-} [1 - F(1-2f)][1 + R(1-2r)] \\\\\n\t {} & + & \\sigma_{++} [1 - F(1-2f)][1 - R(1-2r)] \\\\\n\t {} & + & \\sigma_{-+} [1 + F(1-2f)][1 - R(1-2r)] \\\\\n\\end{array}\n\\end{equation}\nFor a transmitting polarizer/analyzer, we will identify the measured cross-sections as \n\\begin{equation}\n\t\\mathbf{I} = \n\t\\begin{pmatrix}\n\t\tI^{++} \\\\\n\t\tI^{-+} \\\\\n\t\tI^{+-} \\\\\n\t\tI^{--} \n\t\\end{pmatrix}\n\t= \n\t\\begin{pmatrix}\n\t\tI^\\textrm{on on} \\\\\n\t\tI^\\textrm{off on} \\\\\n\t\tI^\\textrm{on off} \\\\\n\t\tI^\\textrm{off off} \n\t\\end{pmatrix}_\\textrm{transmit}\n\\end{equation}\n\n\\subsection{matrix for transmission spin-filters}\nThen re-arranging the cross-sections from the reference into \n$\\{(++), (+-), (-+), (--)\\}$ (our preferred order) \nwe can write the equations as a matrix:\n\\begin{equation}\n\\begin{array}{c}\n\t A \\cdot \\boldsymbol{\\sigma} = \\mathbf{I} \\\\[1em]\n\n  A = \n  \\begin{pmatrix*}[l]\n\t(1-Fx)(1-Ry) &\\!\\!\\! (1-Fx)(1+Ry) &\\!\\!\\! (1+Fx)(1-Ry) &\\!\\!\\! (1+Fx)(1+Ry) \\\\\n\t(1-Fx)(1-R) &\\!\\!\\! (1-Fx)(1+R) &\\!\\!\\! (1+Fx)(1-R) &\\!\\!\\! (1+Fx)(1+R) \\\\\n\t(1-F)(1-Ry) &\\!\\!\\! (1-F)(1+Ry) &\\!\\!\\! (1+F)(1-Ry) &\\!\\!\\! (1+F)(1+Ry) \\\\\n\t(1-F)(1-R) &\\!\\!\\! (1-F)(1+R) &\\!\\!\\! (1+F)(1-R) &\\!\\!\\! (1+F)(1+R) \n  \\end{pmatrix*}\n\\end{array}\n\\end{equation}\nwhere $x = (1 - 2f), y = (1-2r)$.  From here, we can invert $A$ to get back the intrinsic\nscattering cross-sections $\\boldsymbol{\\sigma}$ by\n\\begin{equation}\n\t\\boldsymbol{\\sigma} = A^{-1} \\cdot \\mathbf{I}\n\\end{equation}\n\n\\subsection{reduced matrices}\nAt times, when measuring some assumptions are made about the samples in question which can\nsimplify the equations and reduce the measurement time\n\\subsubsection{spin-flip cross-sections equal, nonzero}\n\nIn this case, $\\sigma_\\textrm{SF} \\equiv \\sigma_{+-} = \\sigma_{-+}$ and there are only three\nunknowns to solve for.  We can then measure just one spin-flip (SF) cross-section and solve for\nthe reflectivity $\\boldsymbol{\\sigma}$\n\\begin{equation}\n\\begin{array}{c}\n\tA^{+-} \\cdot \n\t\\begin{pmatrix}\n\t \t\\sigma_{++} \\\\\n\t \t\\sigma_\\textrm{SF} \\\\\n\t \t\\sigma_{--} \n\t \\end{pmatrix}\t \n\t = \n\t \\begin{pmatrix}\n\t\tI^{++} \\\\\n\t\tI^{+-} \\\\\n\t\tI^{--} \n\t\\end{pmatrix}  \\\\[2em]\n\n  A^{+-} = \n  \\begin{pmatrix*}[l]\n\t(1-Fx)(1-Ry) &\\!\\!\\! [(1-Fx)(1+Ry) + (1+Fx)(1-Ry)] &\\!\\!\\! (1+Fx)(1+Ry) \\\\\n\t(1-Fx)(1-R) &\\!\\!\\! [(1-Fx)(1+R) + (1+Fx)(1-R)] &\\!\\!\\! (1+Fx)(1+R) \\\\\n\t(1-F)(1-R) &\\!\\!\\! [(1-F)(1+R) + (1+F)(1-R)] &\\!\\!\\! (1+F)(1+R) \n  \\end{pmatrix*}\n\\end{array}\n\\end{equation}\nor similarly\n\\begin{equation}\n\\begin{array}{c}\n\tA^{-+} \\cdot \n\t\\begin{pmatrix}\n\t \t\\sigma_{++} \\\\\n\t \t\\sigma_\\textrm{SF} \\\\\n\t \t\\sigma_{--} \n\t \\end{pmatrix}\t \n\t = \n\t \\begin{pmatrix}\n\t\tI^{++} \\\\\n\t\tI^{-+} \\\\\n\t\tI^{--} \n\t\\end{pmatrix}  \\\\[2em]\n\n  A^{-+} = \n  \\begin{pmatrix*}[l]\n\t(1-Fx)(1-Ry) &\\!\\!\\! [(1-Fx)(1+Ry) + (1+Fx)(1-Ry)] &\\!\\!\\! (1+Fx)(1+Ry) \\\\\n\t(1-F)(1-Ry) &\\!\\!\\! [(1-F)(1+Ry) + (1+F)(1-Ry)] &\\!\\!\\! (1+F)(1+Ry) \\\\\n\t(1-F)(1-R) &\\!\\!\\! [(1-F)(1+R) + (1+F)(1-R)] &\\!\\!\\! (1+F)(1+R) \n  \\end{pmatrix*}\n\\end{array}\n\\end{equation}\n\n\\subsubsection{spin-flip cross-sections zero}\n\nIf the spin-flip cross-sections are expected to be vanishingly small \n(which occurs when the in-plane magnetization is strictly parallel or antiparallel to\nthe field quantization axis) then a further simplification is possible:\n\\begin{equation}\n\\begin{array}{c}\n\tA^\\textrm{NSF} \\cdot \n\t\\begin{pmatrix}\n\t \t\\sigma_{++} \\\\\n\t \t\\sigma_{--} \n\t \\end{pmatrix}\t \n\t = \n\t \\begin{pmatrix}\n\t\tI^{++} \\\\\n\t\tI^{--} \n\t\\end{pmatrix}  \\\\[2em]\n\n  A^\\textrm{NSF} = \n  \\begin{pmatrix*}[l]\n\t(1-Fx)(1-Ry) &\\!\\!\\!  (1+Fx)(1+Ry) \\\\\n\t(1-F)(1-R) &\\!\\!\\! (1+F)(1+R) \n  \\end{pmatrix*}\n\\end{array}\n\\end{equation}\n\n\\subsection{Calibration}\nIn order to do the polarization correction as described, one has to first determine the parameters\n$F,R,f,r$.  These are done exactly as described in the reference; the only thing to note is the \nidentification of the measured cross-sections for transmission spin-filters:  \n\\begin{equation}\nI^{--} \\equiv I^\\textrm{off off}_\\textrm{NS,transmit} = \\alpha[FR + 1]\n\\end{equation}\n\\begin{equation}\nI^{+-} \\equiv I^\\textrm{on off}_\\textrm{NS,transmit} = \\alpha[FR(1-2f) + 1]\n\\end{equation}\n\\begin{equation}\nI^{-+} \\equiv I^\\textrm{off on}_\\textrm{NS,transmit} = \\alpha[FR(1-2r) + 1]\n\\end{equation}\n\n\\end{document}", "meta": {"hexsha": "9d534e4e20f2df963fcd24d33d5a36a12c5952e8", "size": 8094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/polcor.tex", "max_stars_repo_name": "SayaTakeuchi1010/_combine", "max_stars_repo_head_hexsha": "31d511e07068603274db017212cfbfd228ab7d23", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-09-28T14:05:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-15T21:53:28.000Z", "max_issues_repo_path": "doc/polcor.tex", "max_issues_repo_name": "SayaTakeuchi1010/_combine", "max_issues_repo_head_hexsha": "31d511e07068603274db017212cfbfd228ab7d23", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 80, "max_issues_repo_issues_event_min_datetime": "2018-04-26T15:00:41.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T15:32:53.000Z", "max_forks_repo_path": "doc/polcor.tex", "max_forks_repo_name": "SayaTakeuchi1010/_combine", "max_forks_repo_head_hexsha": "31d511e07068603274db017212cfbfd228ab7d23", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2018-04-20T18:30:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T15:38:41.000Z", "avg_line_length": 36.4594594595, "max_line_length": 117, "alphanum_fraction": 0.6008154188, "num_tokens": 3133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4121550209435672}}
{"text": "\\documentclass{article}\n\\newsavebox{\\oldepsilon}\n\\savebox{\\oldepsilon}{\\ensuremath{\\epsilon}}\n\\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit\n\\renewcommand*{\\epsilon}{\\usebox{\\oldepsilon}}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx} % For .eps inclusion\n%\\usepackage{indentfirst} % Controls indentation\n\\usepackage[compact]{titlesec} % For regulating spacing before section titles\n\\usepackage{adjustbox} % For vertically-aligned side-by-side minipages\n\\usepackage{array, amsmath,  mhchem}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{courier, subcaption}\n\\usepackage{multirow, enumerate}\n\\usepackage[autolinebreaks,framed,numbered]{mcode}\n\\usepackage{float}\n\\restylefloat{table}\n\n\\pagenumbering{gobble} \n\\setlength\\parindent{0 cm}\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{document}\n\\large\n\nMCB 135 Problem Set 9 \\hfill Due Wedesday, April 22, 2015 at 2:30 PM\n\n\\section*{Problem 1: Bicoid gradient scaling (40 points)}\n\nThe generic reaction-diffusion equation for a system with one component and one spatial dimension is\\footnote{$\\nabla^2$ is the Laplace operator. In one dimension, it is simply the second spatial derivative, $\\partial_{xx}$. On the Cartesian plane, it is the sum of the two spatial derivatives, $\\partial_{xx} + \\partial_{yy}$.}:\n\\[ \\frac{\\partial}{\\partial t} c(x,t) = f\\left[ c(x,t) \\right] + D \\nabla^2  c(x,t) \\]\nWhen simulating such systems, we consider only a finite number of points on a one-dimensional grid.\n\\begin{enumerate}[a)]\n\\item Show, using the definition of the derivative, that the Laplacian term can be approximated on a grid with spacing $h$:\n\\[  \\nabla^2 c(x,t) \\approx  \\frac{c(x-h,t) + c(x+h,t) - 2 \\, c(x,t)}{h^2} \\]\n\\end{enumerate}\nWe will model Bicoid reaction and diffusion in one dimension (representing the A-P axis of the embryo). Since Bicoid diffuses through the cytoplasm, it should not be able to ``exit\" the embryo at either end: the boundaries of our grid must therefore be reflective. Unfortunately, the MATLAB function which implements the discrete Laplacian, \\mcode{del2()}, does not handle these boundary conditions.\n\\begin{enumerate}[a)]\n\\setcounter{enumi}{1}\n\\item Write a function to estimate the discrete Laplacian on a grid with reflective boundaries at either end. The Turing pattern example script in the Lecture 29 notes, which implements the discrete Laplacian on a torus, may be a helpful starting point.\n\\item Suppose that the Bicoid protein gradient is established over the course of two hours in a 500 $\\mu$m embryo according to the reaction-diffusion equation:\n\\[  \\frac{\\partial}{\\partial t} c(x,t) =  \\alpha \\, \\delta_k(x) - \\beta \\, c(x,t) + D \\frac{\\partial^2}{\\partial x^2}  c(x,t) \\]\nwhere $\\delta_k(x)$ is the Kronecker delta distribution, $\\alpha$ = 10 nM/s is the translation rate, $\\beta$ = 1/1800 s$^{-1}$ is the degradation rate, and $D$ = 0.3 $\\mu$m$^2$/s is the diffusion rate. Show that the final Bicoid gradient is approximately exponential by simulating the system using  Euler's method and your subroutine from part (b). Assume that no Bicoid protein is present initially and use a step size\\footnote{If you do use a different grid spacing, ensure that Bicoid is still synthesized in a 5 $\\mu$m region.} of $h$=5 $\\mu$m.\n\\item Repeat for an embryo twice as long, and for a third embryo half as long as the original, maintaining the same step size and synthesis rate. Plot the Bicoid concentration profiles vs. fractional body length on the same axes. Does the concentration profile scale?\n\\item Implement a gradient scaling mechanism of your choice and demonstrate an improvement by creating a plot similar to part (c) for comparison.\n\\end{enumerate}\n\n%\\section*{Problem 1: Reaction-diffusion in two dimensions (20 points)}\n%\n%The generic reaction-diffusion equation for a system with one component on the Cartesian plane is:\n%\\[ \\frac{\\partial}{\\partial t} c(x,y,t) = g\\left[ c(x,y,t) \\right] + D \\left[ \\frac{\\partial^2}{\\partial x^2} +  \\frac{\\partial^2}{\\partial y^2} \\right] c(x,y,t) = g(c) + D \\nabla^2 c(x,y,t) \\]\n%where $\\nabla^2$ represents the \\textit{Laplace operator}. When simulating such systems, we consider only a finite number of points on a two-dimensional grid.\n%\\begin{enumerate}[a)]\n%\\item Show, using the definition of the derivative, that the Laplacian term can be approximated on a grid with spacing $h$:\n%\\[ D \\nabla^2 c(x,y,t) \\approx  \\frac{c(x-h,y,t) + c(x+h,y,t) +  c(x,y-h,t) +  c(x,y+h,t) - 4 c(x,y,t)}{h^2} \\]\n%\\end{enumerate}\n%Bicoid protein primarily diffuses through the yolkless cytoplasm near the surface of the fruit fly embryo: a region shaped like a thin ovoid shell. We will approximate this region by a cylindrical shell using a rectangular grid with appropriate boundary properties. The MATLAB function \\mcode{del2()} implements the discrete Laplacian but unfortunately will not tolerate these creative boundary conditions. \n%\\begin{enumerate}[a)]\n%\\setcounter{enumi}{1}\n%\\item Write a function to estimate the discrete Laplacian on a grid with reflective boundaries at the left and right. Arrange for continuity under diffusion between the top and bottom row of the grid\\footnote{In other words, particles which would diffuse off the left side of the grid instead bounce back to the right, and particles which diffuse off the top row of the grid appear in the bottom row, etc. The Turing pattern example script on the course website, which implements the discrete Laplacian on a torus, may be a helpful starting point.}.\n%\\item \n%\\end{enumerate}\n\n\\section*{Problem 2: Growing snake (60 points)}\n\nAnother Turing pattern mechanism proposed by Gierer and Meinhardt (1972) follows:\n\\[ \\frac{\\partial A}{\\partial t} = \\frac{\\alpha \\, A^2}{B} - \\beta \\, A + \\epsilon \\, D \\,  \\nabla^2 A \\hspace{ 2 cm}  \\frac{\\partial B}{\\partial t} = \\gamma \\, A^2  - \\delta \\, B + D \\nabla^2 B\\]\nwhere all constants are positive. \n\\begin{enumerate}[a)]\n\\item Show that the spatially-homogeneous solution for this system is:\n\\[ (A^*, B^*) = \\left( \\frac{\\alpha \\delta}{\\beta \\gamma}, \\frac{\\alpha^2 \\delta}{\\beta^2 \\gamma} \\right) \\]\n\\item Show that for Turing patterns to arise, the following two conditions must hold:\n\\[ \\delta > \\beta \\hspace{2 cm} \\textrm{ and } \\hspace{2 cm} \\left( \\beta + \\delta \\, \\epsilon \\right)^2  > 8 \\, \\beta \\, \\delta \\, \\epsilon \\]\n\\end{enumerate}\nConsider the specific case where $\\alpha=\\beta =\\gamma = 1$, $\\delta = 1.1$, $\\epsilon = 0.12$, and $D=15$. You will use Euler's method to simulate this system on a two-dimensional grid representing the skin of a snake. The left and right boundaries of the grid (the ``head\" and ``tail\") should be reflective under diffusion, while the top and bottom should wrap around. You may wish to modify the example Turing pattern script on the course website for this purpose.\n\\begin{enumerate}[a)]\n\\setcounter{enumi}{3}\n\\item Simulate this system on a grid with dimensions 5 units x 10 units (a ``baby snake\"). Use a step size of one unit; choose the time step and duration appropriately to allow the system to reach its steady-state pattern. Include an image of your results. How many stripes does this snake have?\n\\item The snake grows up. Repeat the simulation on a grid with dimensions 10 units by 100 units. How many stripes does the snake have now? Include an image of the results.\n\\item The snake lives large. Repeat on a grid with dimensions 100 units by 100 units. Include an image of the results.\n\\item Determine which modes are unstable for organisms with the following lengths (i) $L=\\sqrt{5^2 + 10^2}$, (ii) $L=\\sqrt{10^2 + 100^2}$, and (iii) $L=\\sqrt{100^2 + 100^2}$. How are these values reflected in the images you produced in (d-f)? Hint: see Iglesias section 3.3.2 and Figure 3.9 for a worked example.\n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "d2af4c71cdd849089d5b7d13b265527e1c3c3f00", "size": 7768, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problem sets/ps9/mcb 135 problem set 9.tex", "max_stars_repo_name": "mewahl/intro-systems-biology", "max_stars_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-01-20T17:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-31T17:23:09.000Z", "max_issues_repo_path": "problem sets/ps9/mcb 135 problem set 9.tex", "max_issues_repo_name": "mewahl/intro-systems-biology", "max_issues_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problem sets/ps9/mcb 135 problem set 9.tex", "max_forks_repo_name": "mewahl/intro-systems-biology", "max_forks_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-01-20T17:43:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T14:42:10.000Z", "avg_line_length": 93.5903614458, "max_line_length": 550, "alphanum_fraction": 0.7427909372, "num_tokens": 2163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.4121550209435672}}
{"text": "\\chapter{Introduction}\n%\\addcontentsline{toc}{chapter}{Introduction}\n \\section{A few words to set the scene}\nIn real life, it is not uncommon to have at one's disposal data about a phenomenon occurring through time. It may be as simple as daily rainfall data in a city for the past two years, or it could be the weekly opening prices of a stock for the past decade. \\\\[4 pt]\nMost of the time, people would like to use the data at their disposal to make predictions to answer questions, from the prosaic ones such as 'Will it rain tomorrow ?' to more consequential ones such as 'Will I make a profit if I cling to my shares today and sell them only tomorrow ?'. Of course, those are only vaguely worded questions : it is impossible to answer them satisfactorily without knowing the context, the objectives etc. behind them. \\\\[4 pt]\nYet, what these questions have in common is that they focus on the normal 'behaviour' that is to be expected in the future. Depending on the specific issue that is considered, the 'average behaviour' may not be the most interesting thing. For instance, suppose that a government wants to build a network of dams\\footnote{As was done in The Netherlands beginning in the fifties}. The dams are meant to protect the country from future floods for the next one hundred years, therefore the question that needs to be answered is one of 'worst case event' : \"Over the next century, how severe may be the worst flood ?\". \\\\[4 pt]\nExtreme events are the kind of events we will be interested in this master thesis project. Although Extreme Value Theory has applications in many fields\\footnote{including climate science, seismology, insurance etc.}, we will here apply it more specifically to financial data.\n\n\\section{Formalising the settings}\nLet $(X_n)_{n \\ge 0}$ be a sequence of independent identically distributed random variables with common cumulative distribution function $F_X$. The sequence of maxima is defined by $M_0$=$X_0$ and $\\forall n \\ge 1$, $M_n = \\max_{0 \\le i \\le n}(X_i)$. We would like to determine the limiting distribution of the sequence $(M_n)_{n \\ge 0}$.\\footnote{If we can determine the limiting distribution of the maxima from the data, then we will have a means to make predictions on the occurrence of future extreme events.} This is a matter that will keep us busy quite a long time but the first thing to do is to re-formulate it. \\\\ [4 pt]\nIndeed, let us do a quick and simple computation :\\\\\n\\begin{equation}\n\\begin{aligned}\n\tF_n(t) &= \\Pr(\\{M_n \\le t\\}) \\\\\n              &= \\Pr(\\{\\max_{0 \\le i \\le n}(X_i) \\le t\\}) \\\\\n              &= \\Pr(\\{X_1 \\le t\\} \\cap \\cdots \\cap \\{X_n \\le t\\}) \\\\\n              &= (F_X(t))^n\n\\end{aligned}\n\\end{equation}\nHere we see that little information will be drawn from this result by taking the limit $n \\longrightarrow +\\infty$. The limiting distribution will be degenerate. Indeed, let us consider the upper end-point of $F_X$\\footnote{that is the smallest z such that $F_X(z)$ be equal to one. For the Normal distribution, z will be +$\\infty$, by contrast for a continuous Uniform Distribution $U([a,b])$ it will be b. The definition, properly speaking, of the upper end-point of $F_X$ is the following : $z^{+} = \\inf\\{z : F_X(z) \\ge 1\\}$.}, $z^{+}$. Then,\n\\begin{equation}\n\\begin{aligned}\n\\forall z < z^{+} \\lim_{z\\to\\infty} F_n(z) &= 0 \\\\\n\\forall z \\ge z^{+} \\lim_{z\\to\\infty} F_n(z) &= 1 \\\\\n\\end{aligned}\n\\end{equation}\n\\\\[4 pt]\nIt turns out we cannot use the limiting distribution directly. A common approach\\footnote{adopted by the mathematicians that laid the grounds of Extreme Value Theory.} is to consider a sequence of the maxima, standardized this time (i.e. centred and rescaled).\\\\[4 pt] \nWe will thus consider in all what follows the sequence defined by $(M^{*}_n)_{n \\ge 0}$ = $(\\frac{M_n - b_n}{a_n})_{n \\ge 0}$ where $(a_n)_{n \\ge 0}$ and $(b_n)_{n \\ge 0}$ are a sequence of real numbers and positive real numbers respectively. Finding a result on whether such a sequence admits a limiting distributions, and the conditions under which the result holds, will be one of our goals.\n\\paragraph{The two fundamental problems of extreme value theory} More specifically, assuming that there exists a non-degenerate distribution $G$, what may G be ? That is the \\textit{\\textbf{extremal limit problem}}. Additionally, what conditions do we have to impose on the common distribution of the random variables making up the sample, $F_X$, for the sequence $(M^{*}_n)_{n \\ge 0}$ to converge to a non-degenerate distribution function G ? That is the \\textit{\\textbf{domain of attraction problem}}.\n\n\n\n", "meta": {"hexsha": "8e40c677954f5efcb11828c015659872ea68be3a", "size": 4600, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/main/ch1_introduction.tex", "max_stars_repo_name": "CillianMH/pdmExtremeValueTheory", "max_stars_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/main/ch1_introduction.tex", "max_issues_repo_name": "CillianMH/pdmExtremeValueTheory", "max_issues_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/main/ch1_introduction.tex", "max_forks_repo_name": "CillianMH/pdmExtremeValueTheory", "max_forks_repo_head_hexsha": "f7a7504c2eca0c6be665bcfc3d98dfee6c02de41", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 135.2941176471, "max_line_length": 630, "alphanum_fraction": 0.7384782609, "num_tokens": 1195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.41215501736939797}}
{"text": "% !TeX root = ../main.tex\n% Add the above to each chapter to make compiling the PDF easier in some editors.\n\n\\chapter{Online Algorithms}\\label{chapter:online_algorithms}\n\nIn this chapter, we discuss the online algorithms we implemented in our work. Similar to the previous chapter on offline algorithms, we begin our discussion in \\cref{section:online_algorithms:ud} with algorithms for the uni-dimensional setting. As was discussed in \\cref{chapter:theory}, these algorithms give strong guarantees yielding a constant competitive ratio. Next in \\cref{section:online_algorithms:md}, we extend our discussion to the multi-dimensional setting. Here, the guarantees are not as strong. We thus begin in \\cref{section:online_algorithms:md:lazy_budgeting} by considering lazy budgeting algorithms for smoothed convex optimization problems with particular cost functions. As mentioned previously in \\cref{chapter:theory}, while there are algorithms with sublinear regret (gradient descent), there cannot be any algorithm achieving a dimension-independent constant competitive ratio unless the class of allowed cost functions is restricted~\\cite{Chen2018}. In \\cref{section:online_algorithms:md:descent_methods}, we thus discuss gradient methods that perform well with regard to either the competitive ratio or regret with a restricted class of cost functions. Still, sublinear regret and a constant competitive ratio cannot be achieved simultaneously, even for linear cost functions~\\cite{Andrew2015}. We, therefore, end this chapter in \\cref{section:online_algorithms:md:predictions} with a discussion of algorithms that use predictions to circumvent this fundamental limitation. \\Cref{appendix:taxonomy} includes an overview of all discussed online algorithms.\n\nThroughout this chapter, we denote by $\\tau \\in [T]$ the current time slot. In contrast to offline algorithms that know the hitting costs $f_t$ for all $t \\in [T]$, an online algorithm only knows the hitting costs $f_t$ up to $\\tau$, i.e. $t \\in [\\tau]$.\n\n\\section{Uni-Dimensional}\\label{section:online_algorithms:ud}\n\n\\subsection{Lazy Capacity Provisioning}\\label{section:online_algorithms:ud:lazy_capacity_provisioning}\n\n\\subsubsection{Fractional Algorithm}\n\nWe begin by returning to the notion of capacity provisioning that we introduced in \\cref{section:offline_algorithms:ud:capacity_provisioning}, yielding a backward-recurrent algorithm finding an optimal schedule for SSCO. This algorithm computed bounds $X_{\\tau}^L$ and $X_{\\tau}^U$ on the optimal solution, which only depend on the schedule up to time slot $\\tau$. However, the optimal offline algorithm stayed within these bounds moving backward in time which is impossible for an online algorithm. \\citeauthor{Lin2011}~\\cite{Lin2011} present a similar algorithm moving forward in time called \\emph{lazy capacity provisioning}. We compute the schedule $X_{\\tau}$ during time slot $\\tau$ by setting $X_{\\tau} = X_{\\tau-1}$ unless this violates the bounds in which case we make the smallest possible change: \\begin{align*}\n    X_{\\tau} = \\begin{cases} \n        0 & \\tau \\leq 0 \\\\\n        (X_{\\tau-1})_{X_{\\tau,\\tau}^L}^{X_{\\tau,\\tau}^U} & \\tau \\geq 1\n    \\end{cases}\n\\end{align*} where $(X_{\\tau-1})_{X_{\\tau,\\tau}^L}^{X_{\\tau,\\tau}^U}$ is the projection of $X_{\\tau-1}$ onto $[X_{\\tau,\\tau}^L, X_{\\tau,\\tau}^U]$~\\cite{Lin2011}. \\Cref{fig:backward_recurrent_capacity_provisioing_vs_lazy_capacity_provisioning} shows how this update rule differs from \\nameref{alg:brcp}. The resulting algorithm is described in \\cref{alg:ud:lcp}. Similar to the offline algorithm, we can use algorithms for convex optimization to compute the upper and lower bounds. Hence, we obtain a complexity of $\\mathcal{O}(\\tau C O_{\\epsilon}^{\\tau})$ for $\\epsilon$-optimal upper and lower bounds. This complexity is worrying as it depends on $\\tau$, which may grow very large. However, \\citeauthor{Lin2011}~\\cite{Lin2011} prove the following lemma, which implies that it suffices to compute the lower and upper bounds using only the history since the last time slot where both bounds were either decreased or increased.\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/brcp_vs_lcp}\n    \\caption{Backward-Recurrent Capacity Provisioning vs. Lazy Capacity Provisioning. LCP stays within the bounds ``lazily'' moving forwards in time. The optimal solution stays within the bounds moving backwards in time.}\n    \\label{fig:backward_recurrent_capacity_provisioing_vs_lazy_capacity_provisioning}\n\\end{figure}\n\n\\begin{lemma}\n\\cite{Lin2011} If there exists an index $t \\in [1, \\tau-1]$ such that $X_{\\tau,t+1}^U < X_{\\tau,t}^U$ or $X_{\\tau,t+1}^L > X_{\\tau,t}^L$, then $(\\hat{X}_{\\tau,1},\\dots,\\hat{X}_{\\tau,t}) := (X_{\\tau,1}^L,\\dots,X_{\\tau,t}^L) = (X_{\\tau,1}^U,\\dots,X_{\\tau,t}^U)$, and no matter what the future arrival is, solving the optimization in $[1,\\tau']$ for $\\tau' > \\tau$ is equivalent to solving two optimizations: one over $[1,t]$ with initial condition $X_0$ and final condition $\\hat{X}_{\\tau,t}$ and the second over $[t+1,\\tau']$ with initial condition $\\hat{X}_{\\tau,t}$.\n\\end{lemma}\n\nWhile not changing the worst-case complexity, this significantly improves the practical complexity in the application of right-sizing data centers as diurnal load patterns typically ensure that less than a day needs to be considered~\\cite{Lin2011}. We denote by $X_{\\tau}^{L,(t,x_0)}$ and $X_{\\tau}^{U,(t,x_0)}$ the bounds resulting from optimizations beginning at time slot $t$ with initial condition $x_0$. \\citeauthor{Lin2011}~\\cite{Lin2011} showed that lazy capacity provisioning is $3$-competitive and also proved that this result is tight.\n\n\\begin{algorithm}\n    \\caption{Lazy Capacity Provisioning~\\cite{Lin2011}}\\label{alg:ud:lcp}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    $t_0 \\gets 0$\\;\n    $x_0 \\gets 0$\\;\n    \\For{$t \\gets \\tau-1$ \\KwTo $2$}{\n        \\If{$X_{t,t}^U < X_{t,t-1}^U \\lor X_{t,t}^L > X_{t,t-1}^L$}{\n            $t_0 \\gets t$\\;\n            $x_0 \\gets X_{t,t-1}^U$\\;\n            \\KwBreak\n        }\n    }\n    find $X_{\\tau,\\tau}^{L,(t_0,x_0)}$ using the optimization described by \\cref{eq:ud:brcp:lower}\\;\n    find $X_{\\tau,\\tau}^{U,(t_0,x_0)}$ using the optimization described by \\cref{eq:ud:brcp:upper}\\;\n    \\Return $(X_{\\tau-1})_{X_{\\tau,\\tau}^{L,(t_0,x_0)}}^{X_{\\tau,\\tau}^{U,(t_0,x_0)}}$\\;\n\\end{algorithm}\n\n\\subsubsection{Integral Algorithm}\n\n\\citeauthor{Albers2018}~\\cite{Albers2018} applied lazy capacity provisioning to the integral variant Int-SSCO using their graph-based offline algorithm discussed in \\cref{section:offline_algorithms:ud:graph_based} to compute the integral lower and upper bounds. It is apparent that this immediately yields a deterministic online algorithm for Int-SSCO. \\citeauthor{Albers2018}~\\cite{Albers2018} showed that similar to lazy capacity provisioning, their algorithm is $3$-competitive. Due to the changed method of determining the bounds, its runtime is $\\mathcal{O}(\\tau^2 C \\log_2 m)$. Note that it is impossible to cache the intermediate results of the dynamic program (see \\cref{alg:ud:optimal_graph_search}) as the binary search over possible configurations considers different vertices depending on the obtained schedule, which changes over time. Thus, for large $\\tau$, it may be beneficial to use caching instead of binary search resulting in a worst-case runtime of $\\mathcal{O}(\\tau C m)$. By using the same method of shortening the used history that was proposed by \\citeauthor{Lin2011}~\\cite{Lin2011}, we can reduce this time complexity drastically in practice (for large $\\tau$). Thus, the adopted algorithm is still described by \\cref{alg:ud:lcp}. We simply need to slightly modify the graph-based algorithm computing optimal offline solutions to allow for initial conditions other than $0$.\n\n\\subsection{Memoryless Algorithm}\\label{section:online_algorithms:ud:memoryless}\n\n\\citeauthor{Bansal2015}~\\cite{Bansal2015} showed that for SSCO, a competitive ratio of $3$ can also be attained by a memoryless algorithm. In a memoryless online algorithm for smoothed convex optimization, the configuration $X_{\\tau}$ only depends on the preceding configuration $X_{\\tau-1}$ and the current hitting cost $f_{\\tau}$. This generally allows for a more space and time-efficient algorithm, which is important when choosing a small time slot length $\\delta$ to be more responsive to changes in load.\n\nThe algorithm proposed by \\citeauthor{Bansal2015}~\\cite{Bansal2015} works as follows. Let $\\hat{x}$ be the minimizer of $f_{\\tau}(x)$, i.e. $\\hat{x} = \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$. The algorithm moves into the direction of the minimizer until it either reaches $\\hat{x}$, or it reaches a configuration $x$ where its switching cost equals twice the hitting cost of $x$. \\Cref{fig:memoryless_algorithm} gives an example of a step of the algorithm. We observe that this is equivalent to the following convex optimization: \\begin{align}\\label{eq:ud:memoryless}\\begin{aligned}\n    &\\min_{x \\in \\mathcal{X}} &&f_{\\tau}(x) \\\\\n    &\\text{subject to}        &&\\beta |x - X_{\\tau-1}| \\leq \\frac{f_{\\tau}(x)}{2}.\n\\end{aligned}\\end{align} Originally, \\citeauthor{Bansal2015}~\\cite{Bansal2015} proposed this algorithm for a restricted variant of uni-dimensional SSCO where the decision space is unbounded, i.e., $\\mathcal{X} = \\mathbb{R}$, and the switching costs are given by the $\\ell_1$ norm. In particular, they choose $\\beta = 1$. First, it is easy to see that we can adapt the algorithm for a bounded decision space by bounding the feasible region of the optimization problem in \\cref{eq:ud:memoryless}. Second, we observe that $\\beta$ can simply be interpreted as the weight that we associate with smoothing (i.e., minimizing movement) instead of minimizing hitting costs. This is shown by the following equation, which is obtained by dividing the cost of \\cref{eq:simplified_smoothed_convex_optimization} by $\\beta$: \\begin{align}\\label{eq:simplified_smoothed_convex_optimization:without_beta}\n    \\sum_{t=1}^T \\frac{1}{\\beta} f_t(X_t) + \\sum_{k=1}^d (X_{t,k} - X_{t-1,k})^+.\n\\end{align} The cost associated with this equation is the cost of \\cref{eq:simplified_smoothed_convex_optimization} linearly scaled by $1 / \\beta$. Especially, this argument shows the following lemma.\n\n\\begin{lemma}\\label{lemma:switching_cost_absolute_vs_positive_movement}\nA schedule is optimal with respect to \\cref{eq:simplified_smoothed_convex_optimization:without_beta} if and only if it is optimal with respect to \\cref{eq:simplified_smoothed_convex_optimization}.\n\\end{lemma}\n\nTherefore, without loss of optimality, we can incorporate the weight of the switching cost $\\beta$ into the hitting costs. Further, note that in their model, \\citeauthor{Bansal2015}~\\cite{Bansal2015} consider the absolute movement, i.e. $|X_{t,k} - X_{t-1,k}|$, rather than only positive movements, i.e. $(X_{t,k} - X_{t-1,k})^+$. However, with \\cref{lemma:switching_cost_l1_norm_vs_pos_movement} in \\cref{chapter:theory}, we have shown that these switching costs only differ by a constant factor (namely $1/2$).\n\nThe resulting algorithm is simply given by determining $\\hat{x}$ based on the convex optimization in \\cref{eq:ud:memoryless}, see \\cref{alg:ud:memoryless}. Thus, the time (and space) complexity of this memoryless algorithm is $\\mathcal{O}(C O_{\\epsilon}^1)$ for finding $\\epsilon$-optimal solutions.\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/memoryless}\n    \\caption{The memoryless algorithm moves towards the minimizer of the hitting cost, balancing hitting and movement costs.}\n    \\label{fig:memoryless_algorithm}\n\\end{figure}\n\n\\begin{algorithm}\n    \\caption{Memoryless algorithm~\\cite{Bansal2015}}\\label{alg:ud:memoryless}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    \\Return $\\hat{x}$ such that that $\\hat{x}$ is the result of the optimization in \\cref{eq:ud:memoryless}\\;\n\\end{algorithm}\n\n\\subsection{Probabilistic Algorithm}\\label{section:online_algorithms:ud:probabilistic}\n\nNext, we discuss a $2$-competitive algorithm developed by \\citeauthor{Bansal2015}~\\cite{Bansal2015}, which works by maintaining a probability distribution over configurations. Using this probability distribution, they describe a randomized algorithm which they subsequently translate into a deterministic algorithm. We discuss how to gather a randomized and then a deterministic algorithm from a probability distribution. Then, we describe how \\citeauthor{Bansal2015}~\\cite{Bansal2015} determine the probability distribution and how it can be computed in practice.\n\n\\subsubsection{From Probability Distribution to Deterministic Algorithm}\n\nLet's suppose we have given a probability distribution $p$ over configurations $x \\in \\mathcal{X}$. A randomized algorithm is then described by initially picking a number $\\gamma \\in [0,1]$ uniformly at random and then maintaining the invariant that at time $\\tau$ the chosen configuration $x_{\\tau}$ has the property that the probability mass to the left of $x_{\\tau}$ with respect to $p$ is exactly $\\gamma$~\\cite{Bansal2015}. Crucially, this approach only works in the fractional setting. Also, note that $\\gamma$ is chosen only once prior to running the algorithm. This describes how we obtain a randomized algorithm from a probability distribution over configurations.\n\nNext, \\citeauthor{Bansal2015}~\\cite{Bansal2015} show the following theorem, which describes how we can obtain a deterministic algorithm from a randomized algorithm. \\begin{theorem}\n   ~\\cite{Bansal2015} For the problem of (fractional) online convex optimization, if there exists a $\\rho$-competitive randomized algorithm $\\mathcal{R}$ then there exists a $\\rho$-competitive deterministic algorithm $\\mathcal{D}$.\n\\end{theorem}\n\\begin{proof}\n\\citeauthor{Bansal2015}~\\cite{Bansal2015} prove this theorem using Jensen's inequality. In the setting of a probability space, \\emph{Jensen's inequality}\\index{Jensen's inequality} claims that given a convex function $\\varphi$ and a random variable $X$ we have \\begin{align}\n    E(\\varphi(X)) \\geq \\varphi(E X)\n\\end{align} provided both expectations exist, i.e. $E |X|$ and $E |\\varphi(X)| < \\infty$~\\cite{Durrett2010}.\n\nLet $X_{\\tau}$ be a random variable denoting the configuration of the randomized algorithm $\\mathcal{R}$ at time $\\tau$. Then, the deterministic algorithm $\\mathcal{D}$ of \\citeauthor{Bansal2015}~\\cite{Bansal2015} sets their configuration to $x_{\\tau} = E X_{\\tau}$. The cost of $\\mathcal{D}$ is thus given by $f_{\\tau}(x_{\\tau}) + (x_{\\tau} - x_{\\tau-1})^+$ and the cost of $\\mathcal{R}$ is given by $E(f_{\\tau}(X_{\\tau})) + E((X_{\\tau} - X_{\\tau-1})^+)$. We observe that both $f_{\\tau}$ and $(\\cdot)^+$ are convex functions, implying that the cost of $\\mathcal{R}$ is at least $f_{\\tau}(E X_{\\tau}) + (E X_{\\tau} - E X_{\\tau-1})^+$ which equals the cost of $\\mathcal{D}$. Summing over all $t$ completes the proof.\n\\end{proof}\n\nHence, we have seen that a deterministic algorithm can be obtained from a randomized algorithm by, in each time slot, choosing the expected configuration of the randomized algorithm.\n\n\\subsubsection{Assumptions}\n\nIn the description of their algorithm, \\citeauthor{Bansal2015}~\\cite{Bansal2015} consider a restricted variant of uni-dimensional SSCO. Similar to their memoryless algorithm, which we discussed in \\cref{section:online_algorithms:ud:memoryless}, they consider an unbounded decision space, i.e., $\\mathcal{X} = \\mathbb{R}$, and the $\\ell_1$ norm as switching costs. Further, for their description of this probabilistic algorithm, they assume that the minimizer $\\hat{x}$ of $f_{\\tau}$ is unique and bounded and that the hitting costs $f_{\\tau}$ are continuous and smooth, i.e., are infinitely many times continuously differentiable. In particular, they assume the first-order and second-order derivatives of $f_{\\tau}$ are well-defined and continuous. In \\cref{section:theory:beyond_convexity}, we discussed the assumption of differentiability and how it relates to our data center model.\n\nOur implementation generalizes their algorithm to instances of SSCO with a bounded decision space $\\mathcal{X}$, variable switching costs $\\beta$, and piecewise linear functions. The second assumption, namely that the minimizer of the hitting cost is bounded, is natural in a data center setting as revenue loss increases for small configurations, whereas energy costs increase for large configurations.\n\nIn summary, the final algorithm is $2$-competitive for arbitrary instances of uni-dimensional SSCO with the restriction that hitting costs must either be piecewise linear or smooth.\n\n\\subsubsection{The Probability Distribution}\n\nFor any time $\\tau$, the algorithm maintains a probability distribution $p_{\\tau}$ over configurations $x \\in \\mathcal{X}$. So $\\int_a^b p_{\\tau}(x) \\,dx$ represents the probability that $X_{\\tau} \\in [a,b]$ for any two $a, b \\in \\mathcal{X}$. At each time step $\\tau$ we first find the minimizer of $f_{\\tau}$, $\\hat{x} = \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$. Then, we find a point $x_r \\geq \\hat{x}$ such that \\begin{align}\\label{eq:ud:probabilistic:right}\n    \\frac{1}{2} \\int_{\\hat{x}}^{x_r} \\diff[2]{f_{\\tau}}{y}(y) \\,dy = \\beta \\int_{x_r}^{\\infty} p_{\\tau-1}(y) \\,dy\n\\end{align} and a point $x_l \\leq \\hat{x}$ such that \\begin{align}\\label{eq:ud:probabilistic:left}\n    \\frac{1}{2} \\int_{x_l}^{\\hat{x}} \\diff[2]{f_{\\tau}}{y}(y) \\,dy = \\beta \\int_{-\\infty}^{x_l} p_{\\tau-1}(y) \\,dy.\n\\end{align} Note that we use \\cref{lemma:switching_cost_absolute_vs_positive_movement} to linearly scale the hitting cost $f_{\\tau}$ by $1 / \\beta$ to allow for $\\beta \\neq 1$. We then simply moved the constant factor outside of the derivative and integral. The probability distribution is updated as follows: \\begin{align}\\label{eq:ud:probabilistic:update}\n    p_{\\tau}(x) = \\begin{cases}\n        p_{\\tau-1}(x) + \\frac{1}{2 \\beta} \\diff[2]{f_{\\tau}}{x}(x) & x \\in [x_l,x_r] \\\\\n        0 & \\text{otherwise}\n    \\end{cases}\n\\end{align} where $p_0$ is a discrete distribution concentrating all probability mass in the point $0$. Note that \\citeauthor{Bansal2015}~\\cite{Bansal2015} do not assume any particular initial distribution, yet in our original problem statement we assumed $X_0 = \\mathbf{0}$. The continuous extension of this distribution can be approximated as $p_0 \\sim \\text{Unif}(0, \\epsilon)$ for a suitably small $\\epsilon > 0$. In our implementation we choose $\\epsilon = 10^{-5}$.\n\n\\subsubsection{The Algorithm}\n\nTo begin with, recall that the algorithm developed by \\citeauthor{Bansal2015}~\\cite{Bansal2015} operates on an unbounded decision space. To translate the algorithm to a setting with a bounded decision space, it is easy to see that we need to ensure that the underlying probability distribution does not assign positive probability to $x \\not\\in \\mathcal{X}$. This can be achieved by introducing the additional restrictions $0 \\leq x_l$ and $x_r \\leq m$ which requires the assumption $\\hat{x} \\in [0,m]$. This is not a restriction as we simply define $\\hat{x}$ as the minimizer of the hitting cost $f_{\\tau}$ with respect to the decision space $\\mathcal{X}$.\n\nWe use a convex optimization (as described in \\cref{section:offline_algorithms:convex_optimization}) to find the minimizer of the hitting cost $\\hat{x}$. To determine $x_l$ and $x_r$, we use Brent's method with suitably defined functions and intervals to find a root. We will define these intervals and functions and describe how they can be computed in the following. Before beginning their description, note that we can only use a bracketed root finding method as we assumed that our decision space is bounded. If the decision space was not bounded, $x_l$ could be determined using a search for a local optimum minimizing $x$ starting from $\\hat{x}$ under the equality constraint given in \\cref{eq:ud:probabilistic:left}. This works because the equality constraint reduces the dimensionality of the optimization to $0$, resulting in a single feasible point. The analogous approach can be used to determine $x_r$.\n\nWe begin by describing how $x_r$ can be determined by a local search for a root. First, note that $x_r \\in [\\hat{x},m]$. Next, we restate \\cref{eq:ud:probabilistic:right} as a function of $x_r$: \\begin{align*}\n    && \\frac{1}{2} \\int_{\\hat{x}}^{x_r} \\diff[2]{f_{\\tau}}{y}(y) \\,dy =&\\ \\beta \\int_{x_r}^{\\infty} p_{\\tau-1}(y) \\,dy \\\\\n    \\iff&& \\left(\\diff{f_{\\tau}}{x}(x_r) - \\diff{f_{\\tau}}{x}(\\hat{x})\\right) =&\\ 2 \\beta \\int_{x_r}^{\\infty} p_{\\tau-1}(y) \\,dy \\\\\n    \\iff&& g(x_r) := \\diff{f_{\\tau}}{x}(x_r) - 2 \\beta \\int_{x_r}^{\\infty} p_{\\tau-1}(y) \\,dy =&\\ 0.\n\\end{align*} Here, we used the fundamental theorem of calculus and that the first order derivative of $f_{\\tau}$ at $\\hat{x}$ is $0$ as $\\hat{x}$ is the minimizer of $f_{\\tau}$. We observe that $g(\\hat{x}) \\leq 0$ and $g(m) \\geq 0$. As $g$ is continuous, we know that we can be sure to find a root $x_r$ of $g$ on the interval $[\\hat{x},m]$.\n\nWe take the analogous approach to determine $x_l \\in [0,\\hat{x}]$. Using \\cref{eq:ud:probabilistic:left}, we obtain: \\begin{align*}\n    && \\frac{1}{2} \\int_{x_l}^{\\hat{x}} \\diff[2]{f_{\\tau}}{y}(y) \\,dy =&\\ \\beta \\int_{-\\infty}^{x_l} p_{\\tau-1}(y) \\,dy \\\\\n    \\iff&& \\left(\\diff{f_{\\tau}}{x}(\\hat{x}) - \\diff{f_{\\tau}}{x}(x_l)\\right) =&\\ 2 \\beta \\int_{-\\infty}^{x_l} p_{\\tau-1}(y) \\,dy \\\\\n    \\iff&& h(x_l) := 2 \\beta \\int_{-\\infty}^{x_l} p_{\\tau-1}(y) \\,dy - \\diff{f_{\\tau}}{x}(x_l) =&\\ 0.\n\\end{align*} Again, we observe that $h(0) \\leq 0$, $h(\\hat{x}) \\geq 0$, and $h$ is continuous, implying that we can be sure to find a root $x_l$ of $h$ on the interval $[0,\\hat{x}]$. \\Cref{fig:probabilistic_algorithm} illustrates the choice of $x_l$ and $x_r$.\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/probabilistic}\n    \\caption{Visualization of the choice of $x_l$ and $x_r$ of the probabilistic algorithm.}\n    \\label{fig:probabilistic_algorithm}\n\\end{figure}\n\n\\paragraph{Root Finding} The previous arguments show that a bracketed root finding method can be used to find $x_l$ and $x_r$. We use \\emph{Brent's method}\\index{Brent's method} for root finding. Brent's method combines the bisection method with higher-order methods to guarantee convergence to the root, yet at a higher rate than if only bisection were used~\\cite{Press2007}. \\citeauthor{Press2007}~\\cite{Press2007} ``recommend it as the method of choice for general one-dimensional\nroot finding where a function’s values only (and not its derivative or functional form)\nare available''. We denote the convergence rate of approximating the root with tolerance $\\epsilon$ by $\\mathcal{O}(R_{\\epsilon})$.\n\n\\paragraph{Numerical Differentiation} We use the \\emph{five-point stencil}\\index{five-point stencil} \\begin{align*}\n    \\diff{f_{\\tau}}{x}(x) \\approx \\frac{-f_{\\tau}(x - 2h) + 8 f_{\\tau}(x + h) - 8 f_{\\tau}(x - h) + f_{\\tau}(x - 2h)}{12h}\n\\end{align*} to find a finite difference approximation of order $\\mathcal{O}(h)$ of the first order derivative of $f_{\\tau}$ at configurations $x \\in \\mathcal{X}$~\\cite{Sauer2011}. To match the accuracy of our convex optimizations we set $h := \\epsilon / 10$. To approximate the second order derivative of $f_{\\tau}$ at a configuration $x \\in \\mathcal{X}$ we use \\begin{align*}\n    \\diff[2]{f_{\\tau}}{x}(x) \\approx \\frac{-f_{\\tau}(x + 2h) + 16 f_{\\tau}(x+h) - 30 f_{\\tau}(x) + 16 f_{\\tau}(x-h) - f_{\\tau}(x - 2h)}{12 h^2}\n\\end{align*} which yields an approximation of order $\\mathcal{O}(h^4)$~\\cite{Sauer2011}. Thus, we set $h := (\\epsilon / 10)^{-1/4}$. We are thus able to compute these approximations in $\\mathcal{O}(C)$ time.\n\nNext, we describe how the constraints from \\cref{eq:ud:probabilistic:right} and \\cref{eq:ud:probabilistic:left} can be computed numerically.\n\n\\paragraph{Numerical Integration} In our implementation, we need to compute both finite and semi-infinite integrals over the probability distribution $p$.\n\nWe use the \\emph{Tanh-sinh quadrature}\\index{Tanh-sinh quadrature} (also known as the double exponential method) to compute finite integrals. \\citeauthor{Bailey2005}~\\cite{Bailey2005} describe the convergence and error of this method in more detail. They conclude that ``overall, the tanh-sinh scheme appears to be the best\nfor integrands of the type most often encountered in experimental math research'' and highlight that it has ``excellent accuracy and runtime performance''~\\cite{Bailey2005}.\n\nWe use the \\emph{Gauss-Laguerre quadrature}\\index{Gauss-Laguerre quadrature} for semi-infinite integrals, which approximates values of integrals of the kind \\begin{align}\\label{eq:gauss_laguerre}\n    \\int_0^{\\infty} e^{-x} f(x) \\,dx\n\\end{align}~\\cite{Weisstein}. It is easy to see that we can eliminate the weights by multiplying the integrand $g$ with $e^x$. Let $\\text{GL}(g)$ denote the approximation of \\cref{eq:gauss_laguerre} obtained by the Gauss-Laguerre quadrature. We are then able to compute any right-open integral over the interval $[{a,\\infty})$ with integrand $p$ by setting $g(x) := p(a+x)$ and any left-open integral over the interval $({-\\infty,b}]$ with integrand $p$ by setting $g(x) := p(b-x)$.\n\nCrucially, for numeric stability in both integration schemes, we need that the integrands are continuous. It is easy to see that, in general, this is not the case for our probability distribution $p$. We describe in the following paragraph how integrals can be suitably discretized to allow for stable numeric results. Moreover, as the integration schemes are not universal, probability distributions exist for which the used quadratures cannot find the integral. In such a case, one would have to resort to another integration scheme. We denote the convergence rate of approximating the integral with tolerance $\\epsilon$ by $\\mathcal{O}(I_{\\epsilon})$.\n\n\\paragraph{Piecewise Linear Hitting Costs} We have already discharged the assumptions that $\\beta = 1$ and that the decision space is unbounded. It remains to extend this algorithm to allow for piecewise linear hitting costs.\n\nIn our description of the adaption to piecewise linear hitting costs $f_{\\tau}$, we refer to the non-continuous or non-smooth points of $f_{\\tau}$ as \\emph{breakpoints}\\index{breakpoint}. For a piecewise linear function, we can discretize the integral into a summation, replace the first-order derivative at a breakpoint by the difference of consecutive points, and replace the second-order derivative at a point by the difference in slopes of consecutive points~\\cite{Bansal2015}. Let $B_{f_{\\tau}}$ denote the set of breakpoints of $f_{\\tau}$. Further, we denote by $x_{\\tau,l}$ and $x_{\\tau,r}$ the values of $x_l$ and $x_r$ at time $\\tau$, respectively. It is easy to see that the set of breakpoints of $p_{\\tau}$ is then given by \\begin{align*}\n    B_{p_{\\tau}} := \\{0, m\\} \\cup \\left(B_{f_1} \\cup \\{x_{1,l}, x_{1,r}\\}\\right) \\cup \\dots \\cup \\left(B_{f_{\\tau}} \\cup \\{x_{\\tau,l}, x_{\\tau,r}\\}\\right).\n\\end{align*}\n\nLet $B_{p_{\\tau}}^I := B_{p_{\\tau}} \\cap I$. The integral of $p_{\\tau}$ over $I \\subseteq \\mathbb{R} \\cup \\{-\\infty, \\infty\\}$ can then be computed using the quadrature methods described previously by integrating piecewise: \\begin{align*}\n    \\int_I p_{\\tau}(y) \\,dy = \\int_{\\min I}^{\\min B_{p_{\\tau}}^I} p_{\\tau}(y) \\,dy + \\int_{\\max B_{p_{\\tau}}^I}^{\\max I} p_{\\tau}(y) \\,dy + \\sum_{(i, j) \\in \\text{sort}(B_{p_{\\tau}}^I)} \\int_i^j p_{\\tau}(y) \\,dy\n\\end{align*} where $\\text{sort}(A)$ denotes the pairs of consecutive elements of some set $A \\subset \\mathbb{R}$ in ascending order. We can continue to use finite difference approximations for the first-order and second-order derivatives.\n\n\\paragraph{} Note that the computation of $p_{\\tau}$ requires $\\mathcal{O}(\\tau)$ many approximations of the second-order derivative of $f_{t}$. Therefore, any evaluation of $p_{\\tau}$ requires $\\mathcal{O}(\\tau C)$ time and we are thus able to compute the $\\epsilon$-optimal integral in $\\mathcal{O}(\\tau C I_{\\epsilon} |B_{p_{\\tau}}|) = \\mathcal{O}(\\tau^2 C I_{\\epsilon} |B_{f_0}|)$ time, assuming $B_{f_{\\tau}}$ add a constant number of new breakpoints in each time step and with $B_{f_0}$ denoting the number of breakpoints that is shared between multiple $f_{\\tau}$. Overall, the described convex optimizations can be solved $\\epsilon$-optimally in $\\mathcal{O}(\\tau^2 C I_{\\epsilon} |B_{f_0}| R_{\\epsilon} O_{\\epsilon}^1)$ time. This is also the time complexity of the algorithm. This shows that, similarly to lazy capacity provisioning, the computational complexity grows polynomially with time. However, unlike lazy capacity provisioning, we cannot regularly reset the history, rendering this algorithm computationally inefficient for short time slot lengths. The algorithm is described in \\cref{alg:ud:probabilistic}.\n\n\\begin{algorithm}\n    \\caption{Probabilistic algorithm~\\cite{Bansal2015}}\\label{alg:ud:probabilistic}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    $\\hat{x} \\gets \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$\\;\n    find $x_r$ using the optimization described by \\cref{eq:ud:probabilistic:right} subject to $x \\in \\mathcal{X}$\\;\n    find $x_l$ using the optimization described by \\cref{eq:ud:probabilistic:left} subject to $x \\in \\mathcal{X}$\\;\n    set $p_{\\tau}$ based on the update rule in \\cref{eq:ud:probabilistic:update}\\;\n    \\Return $\\int_{x_l}^{x_r} y \\cdot p_{\\tau}(y) \\,dy$\\;\n\\end{algorithm}\n\nUpdating the probability distribution $p$ can be done in constant time as this does not require any function evaluations. As discussed in the beginning of this subsection, given a uniformly picked $\\gamma \\in [0,1]$, the randomized algorithm chooses $X_{\\tau}$ (randomly) such that $\\int_{-\\infty}^{X_{\\tau}} p_{\\tau}(y) \\,dy = \\gamma$. In other words, $P_{\\tau}(X_{\\tau}) \\sim \\text{Unif}(0,1)$ where $P_{\\tau}$ is the cumulative distribution function of $p_{\\tau}$. By the universality of the uniform, $X_{\\tau}$ is $P_{\\tau}$-distributed, i.e. $X_{\\tau} \\sim P_{\\tau}$. Hence, $E X_{\\tau} = \\int_{x_l}^{x_r} y \\cdot p_{\\tau}(y) \\,dy$ computes the configuration for time slot $\\tau$ as $p_{\\tau}(y) = 0$ for $y \\not\\in [x_l, x_r]$. We then return $E X_{\\tau}$. Similarly to the previously discussed integrals, this integral can be computed $\\epsilon$-optimally in $\\mathcal{O}(\\tau^2 C I_{\\epsilon} |B_{f_0}|)$ time, not affecting the asymptotic time complexity of the algorithm.\n\n\\subsection{Randomly Biased Greedy Algorithm}\\label{section:online_algorithms:ud:rbg}\n\nWe have seen many constant-competitive online algorithms for uni-dimensional smoothed convex optimization. However, we have not yet paid much attention to minimizing regret. This is also partially because sublinear regret can be achieved easily using online gradient descent. As this approach generalizes to the multi-dimensional setting, we discuss this approach in \\cref{section:online_algorithms:md:descent_methods}, where we look more generally at descent methods.\n\nStill, one important question regarding the uni-dimensional setting remains, namely, whether there is an algorithmic framework that achieves both a constant-competitive ratio and sublinear regret. While it is impossible to achieve both simultaneously, it is possible to develop an algorithmic framework that balances both performance metrics.\n\nIn their paper, where the incompatibility between the competitive ratio and regret was first introduced, \\citeauthor{Andrew2015}~\\cite{Andrew2015} already proposed an algorithmic framework for SCO balancing the two notions in the uni-dimensional setting. Their approach is to scale the norm used to penalize movement in the decision space with a parameter $\\theta \\geq 1$. If $\\theta = 1$, i.e., the algorithm solves the original problem, their algorithm is $2$-competitive and has linear regret. In contrast, for $\\theta > 1$, movement in the decision space is penalized more. This allows reducing the regret to an arbitrary amount (which still depends linearly on $T$) while maintaining a constant competitive ratio~\\cite{Andrew2015}.\n\nNote that while regret is understood as introduced in \\cref{section:theory:performance_metrics}, the competitive ratio is understood with respect to the modified problem with lookahead $1$. In general, with \\emph{lookahead}\\index{lookahead} $i$, the environment plays actions $i$ steps before the agent follows suit. In other words, a step at time $i$ is evaluated using the cost function from time $t-i$, and the initial step $X_i$ is $\\mathbf{0}$. For lookahead $i$, we consider the modified overall cost \\begin{align*}\n    \\sum_{t=1}^T f_t(X_{t+i}) + \\norm{X_{t+i} - X_{t+i-1}}.\n\\end{align*} Note that in this definition we assume that $f_t$ is known after $X_t$ is played, whereas in our original definition of SOCO we assumed that $f_t$ is known before $X_t$ is played. Hence, for $i=1$, this modified problem is equivalent to SOCO and similar to metrical task systems where, in both cases, the environment plays first. In contrast, with online convex optimization, the agent plays first, resulting in a lookahead of $i=0$~\\cite{Andrew2015}. Note that online convex optimization is the more restricted setting as the agent has less knowledge than in metrical task systems, implying that given an algorithm for lookahead $i$, the corresponding algorithm for lookahead $0$ is as competitive. Given an algorithm with lookahead $i$, the corresponding algorithm with lookahead $0$ is obtained simply by shifting determined configurations $i$ time slots into the past.\n\n\\citeauthor{Bansal2015}~\\cite{Bansal2015} mention in their paper that the claims on this algorithm were withdrawn, however, \\citeauthor{Andrew2015}~\\cite{Andrew2015} clarified their proof, showing it is correct as stated in the original paper~\\cite{Wierman}.\n\nThe algorithm of \\citeauthor{Andrew2015}~\\cite{Andrew2015} is initialized with a random parameter $r$ which is uniformly sampled from $({-1,1})$, i.e. $r \\sim \\text{Unif}(-1, 1)$. They define the work function \\begin{align}\\label{eq:randomly_biased_greedy:work_function}\n    w_{\\tau}(x) = \\min_{y \\in \\mathcal{X}} w_{\\tau-1}(y) + f_{\\tau}(y) + \\theta \\norm{x - y}\n\\end{align} where $w_0(x) = \\theta \\norm{x}$. During each time slot $\\tau$ the algorithm moves to the configuration $x$ minimizing $w_{\\tau-1}(x) + r \\theta \\norm{x}$. The resulting algorithm is described in \\cref{alg:ud:rbg}.\n\n\\begin{algorithm}\n    \\caption{Randomly Biased Greedy~\\cite{Andrew2015}}\\label{alg:ud:rbg}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SCO}} = (\\tau \\in \\mathbb{N}, \\mathcal{X} \\subset \\mathbb{R}, \\norm{\\cdot}, (f_1, \\dots, f_{\\tau}) \\in (\\mathcal{X} \\to \\mathbb{R}_{\\geq 0})^{\\tau}), \\theta \\geq 1, r \\sim \\text{Unif}(-1,1)$}\n    $x \\gets \\argmin_{x \\in \\mathcal{X}} w_{\\tau-1}(x) + r \\theta \\norm{x}$\\;\n    set $w_{\\tau}$ as described in \\cref{eq:randomly_biased_greedy:work_function}\\;\n    \\Return $x$\\;\n\\end{algorithm}\n\nObserve that as expected, the algorithm returns $X_1 = \\mathbf{0}$ for the initial step.\n\n\\citeauthor{Andrew2015}~\\cite{Andrew2015} show that given a $\\theta \\geq 1$ their algorithm attains the $\\alpha$-unfair competitive ratio $(1+\\theta) / \\min \\{\\theta, \\alpha\\}$ and regret $\\mathcal{O}(\\max \\{T / \\theta, \\theta\\})$. Hence, for $\\alpha = 1$ and $\\theta = 1$ the algorithm is $2$-competitive. For any $\\alpha > 0$, the optimal $\\alpha$-unfair competitive ratio is $1 + 1 / \\alpha$ and obtained by setting $\\theta = \\alpha$. In contrast, $\\theta = 1 / \\epsilon$ for some $\\epsilon > 0$ yields the minimal regret $\\mathcal{O}(\\epsilon T)$~\\cite{Andrew2015}. In general, when $T$ is known in advance, \\citeauthor{Andrew2015}~\\cite{Andrew2015} show that for $\\theta \\in \\mathcal{O}(\\sqrt{T})$, their algorithm achieves a $\\mathcal{O}(\\sqrt{T})$ $\\alpha$-unfair competitive ratio and $\\mathcal{O}(\\sqrt{T})$-regret.\n\nIt is easy to see that the work function itself is convex as it can be interpreted as the inf-projection of the convex function $f(x,y) = w_{\\tau-1}(y) + f_{\\tau}(y) + \\theta \\norm{x - y}$. This fact is shown in proposition 2.22 of~\\cite{Burke2015}. The evaluation of $w_{\\tau}$ requires $\\mathcal{O}(\\tau)$ recursive evaluations of the work function each of which uses a convex optimization and evaluates the hitting costs. Thus, an $\\epsilon$-optimal evaluation of $w_{\\tau}$ can be obtained in $\\mathcal{O}(C (O_{\\epsilon}^1)^{\\tau})$ time. Hence, the overall time complexity of the algorithm is in $\\mathcal{O}(C (O_{\\epsilon}^1)^{\\tau+1})$. We improve the practical runtime by memoizing the work function.\n\n\\subsection{Randomized Integral Relaxation}\n\n\\citeauthor{Albers2018}~\\cite{Albers2018} use the probabilistic algorithm described in \\cref{section:online_algorithms:ud:probabilistic} in their randomized algorithm for Int-SSCO achieving the optimal competitive ratio $2$ against an oblivious adversary. Although they used the probabilistic algorithm in their paper, their proof generalizes to any $2$-competitive fractional algorithm, so, in particular, the randomly biased greedy algorithm can be used as well. Roughly, the algorithm works by solving the relaxed problem using the probabilistic algorithm of \\citeauthor{Bansal2015}~\\cite{Bansal2015} and then randomly rounding the resulting fractional schedule.\n\nLet $\\bar{\\mathcal{I}} = (T, m, \\beta, \\bar{F})$ with $\\bar{F} = (\\bar{f}_1, \\dots, \\bar{f}_T)$ be the fractional relaxation of the instance $\\mathcal{I} = (T, m, \\beta, F)$ of Int-SSCO and let $\\bar{\\mathcal{X}} = [0,m]$ denote the decision space of $\\bar{\\mathcal{I}}$. \\citeauthor{Albers2018}~\\cite{Albers2018} define the relaxed operating costs $\\bar{f}_{\\tau} : \\bar{\\mathcal{X}} \\to \\mathbb{R}_{\\geq 0}$ as the linear interpolation of the integral operating costs $f_{\\tau}$: \\begin{align*}\n    \\bar{f}_{\\tau} := \\begin{cases}\n        f_{\\tau}(x) & x \\in [m]_0 \\\\\n        (\\lceil x \\rceil - x) f_{\\tau}(\\lfloor x \\rfloor) + (x - \\lfloor x \\rfloor) f_{\\tau}(\\lceil x \\rceil) & \\text{otherwise}.\n    \\end{cases}\n\\end{align*} Note that $\\bar{f_{\\tau}}$ are continuous and piecewise linear with the set of breakpoints $[m]_0$. Hence, we are able to use \\cref{alg:ud:probabilistic} to obtain the configuration $\\bar{X}_{\\tau} \\in \\bar{\\mathcal{X}}$ at time $\\tau$ for the relaxed problem instance  $\\bar{\\mathcal{I}}$. Further, let $\\text{frac}(x) = x - \\lfloor x \\rfloor$ be the fractional part of $x$ and let $\\bar{X}'_{\\tau-1} = (\\bar{X}_{\\tau-1})_{\\lfloor\\bar{X}_{\\tau}\\rfloor}^{\\lceil\\bar{X}_{\\tau}\\rceil}$ be the projection of the preceding relaxed configuration onto the discrete interval of the current relaxed configuration.\n\nThe randomized algorithm distinguishes between time slots where the configuration is increased and time slots where the configuration is decreased. In the first case, i.e. $\\bar{X}_{\\tau-1} \\leq \\bar{X}_{\\tau}$, if $X_{\\tau-1} = \\lceil\\bar{X}_{\\tau}\\rceil$  the configuration remains unchanged. Otherwise, $X_{\\tau}$ is set to $\\lceil\\bar{X}_{\\tau}\\rceil$ with probability \\begin{align*}\n    p_{\\tau}^{\\uparrow} := \\frac{\\bar{X}_{\\tau} - \\bar{X}'_{\\tau-1}}{1 - \\text{frac}(\\bar{X}'_{\\tau-1})}\n\\end{align*} and to $\\lfloor\\bar{X}_{\\tau}\\rfloor$ with probability $1 - p_{\\tau}^{\\uparrow}$. Conversely, if $\\bar{X}_{\\tau-1} > \\bar{X}_{\\tau}$, the configuration remains unchanged if $X_{\\tau-1} = \\lfloor\\bar{X}_{\\tau}\\rfloor$, and otherwise with probability \\begin{align*}\n    p_{\\tau}^{\\downarrow} := \\frac{\\bar{X}'_{\\tau-1} - \\bar{X}_{\\tau}}{\\text{frac}(\\bar{X}'_{\\tau-1})}\n\\end{align*} the configuration is set to $\\lfloor\\bar{X}_{\\tau}\\rfloor$ and with probability $p_{\\tau}^{\\downarrow}$ the configuration is set to $\\lceil\\bar{X}_{\\tau}\\rceil$. The resulting algorithm is shown in \\cref{alg:ud:randomized}.\n\n\\begin{algorithm}\n    \\caption{Randomized integral relaxation~\\cite{Albers2018}}\\label{alg:ud:randomized}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{Int-SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{N}_0 \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    $\\bar{X}_{\\tau} \\gets \\text{\\cref{alg:ud:probabilistic}}(\\bar{\\mathcal{I}}_{\\text{Int-SSCO}})$\\;\n    \\eIf{$\\bar{X}_{\\tau-1} \\leq \\bar{X}_{\\tau}$}{\n        \\eIf{$X_{\\tau-1} = \\lceil\\bar{X}_{\\tau}\\rceil$}{\n            \\Return $\\lceil\\bar{X}_{\\tau}\\rceil$\\;\n        }{\n            $\\gamma \\sim \\text{Unif}(0,1)$\\;\n            \\eIf{$\\gamma \\leq p_{\\tau}^{\\uparrow}$}{\n                \\Return $\\lceil\\bar{X}_{\\tau}\\rceil$\\;\n            }{\n                \\Return $\\lfloor\\bar{X}_{\\tau}\\rfloor$\\;\n            }\n        }\n    }{\n        \\eIf{$X_{\\tau-1} = \\lfloor\\bar{X}_{\\tau}\\rfloor$}{\n            \\Return $\\lfloor\\bar{X}_{\\tau}\\rfloor$\\;\n        }{\n            $\\gamma \\sim \\text{Unif}(0,1)$\\;\n            \\eIf{$\\gamma \\leq p_{\\tau}^{\\downarrow}$}{\n                \\Return $\\lfloor\\bar{X}_{\\tau}\\rfloor$\\;\n            }{\n                \\Return $\\lceil\\bar{X}_{\\tau}\\rceil$\\;\n            }\n        }\n    }\n\\end{algorithm}\n\nWe use the universality of the uniform to simulate Bernoulli-distributed random variables with parameters $p_{\\tau}^{\\uparrow}$ and $p_{\\tau}^{\\downarrow}$, respectively. Any pseudo-random number generator can be used to produce the uniformly distributed $\\gamma$. It is easy to see that the time complexity is given by the time complexity of \\cref{alg:ud:probabilistic}, i.e., $\\mathcal{O}(\\tau^2 m C I_{\\epsilon} R_{\\epsilon} O_{\\epsilon}^1)$ with $|B_{f_0}| \\in \\mathcal{O}(m)$, or the complexity of \\cref{alg:ud:rbg}, i.e., $\\mathcal{O}(C (O_{\\epsilon}^1)^{\\tau+1})$ depending on which algorithm is used for the relaxed problem.\n\n\\section{Multi-Dimensional}\\label{section:online_algorithms:md}\n\n\\subsection{Lazy Budgeting}\\label{section:online_algorithms:md:lazy_budgeting}\n\nTo begin with our discussion of the multi-dimensional setting, we examine two algorithms developed by \\citeauthor{Albers2021}~\\cite{Albers2021} for a restricted class of convex cost functions. Their first algorithm is $2d$-competitive for SLO, i.e., load and time-independent costs, and their second algorithm is $(2d+1)$-competitive for SBLO. Note that we only defined SBLO and SLO for the integral case. As no online algorithm for SLO can attain a competitive ratio smaller than $2d$, their first algorithm is optimal, and their second algorithm is nearly optimal~\\cite{Albers2021, Albers2021_2}.\n\nThe idea behind both algorithms is to calculate optimal schedules up to the current time slot. Depending on this schedule, the algorithm decides if a server is powered up. To perform the smoothing, the algorithm remembers how long a server was idling and powers this server down if the idle duration surpasses a threshold. \\citeauthor{Albers2021}~\\cite{Albers2021} do not name their algorithms, yet, within this work, we refer to them as \\emph{lazy budgeting methods}\\index{lazy budgeting}.\n\n\\subsubsection{Lazy Budgeting for Smoothed Load Optimization}\n\nLet $\\mathcal{I} = (d, \\tau, m, \\beta, \\Lambda, c)$ be an instance of SLO. \\citeauthor{Albers2021}~\\cite{Albers2021} focus on a setting without inefficient server types. A server type $k$ is called \\emph{inefficient} if there exists another server type $k'$ where both the operating cost and the switching cost is lower, i.e. $c_k \\geq c_{k'}$ and $\\beta_k \\geq \\beta_{k'}$. In practice, this is not a restriction as a server of an inefficient server type is only ever powered up if all more efficient servers are already active as there is no trade-off between operating and switching costs. Furthermore, typically servers with a lower operating cost also have a higher switching cost. In addition, \\citeauthor{Albers2021} assume that there are no duplicated server types, i.e., server types with equal operating and switching costs.\n\nWe assume that the server types are sorted in descending order by their operating costs, i.e. $c_1 > \\dots > c_d$. As we excluded inefficient server types, switching costs are in ascending order, $\\beta_1 < \\dots < \\beta_d$.\n\nThe algorithm of \\citeauthor{Albers2021}~\\cite{Albers2021} separates a problem instance into $m := \\sum_{k=1}^d m_k$ lanes. Recall that with SLO, we assume that each active server can handle a single job during each time slot. The algorithm uses that at time slot $t$ there is a job in line $j$ if and only if $j \\leq \\lambda_{t}$. Thus, all servers represented by lines $j > \\lambda_{t}$ are either inactive or idling.\n\nLet $y_{t,j}$ denote the server type that handles the $j$-th lane during time slot $t$ given some underlying schedule $X$. We say $y_{t,j} = 0$ if there is no active server in lane $j$ during time slot $t$, which is only the case if $j > \\lambda_{t}$ as we can assume that $\\lambda_{t} \\leq m$ holds for all time slots $t \\in [T]$. \\citeauthor{Albers2021}~\\cite{Albers2021} give the following formal definition: \\begin{align*}\n    y_{t,j} := \\begin{cases}\n        \\max \\{k \\in [d] \\mid \\sum_{k' = k}^d X_{t,k'} \\geq j\\} & k \\in \\left[\\sum_{k=1}^d X_{t,k}\\right] \\\\\n        0 & \\text{otherwise}.\n    \\end{cases}\n\\end{align*} By this definition, we prefer to use servers of the server type with the lowest operating cost (and largest switching cost). In other words, the server types handling each lane $y_{t,1}, \\dots, y_{t,m}$ are sorted in descending order, i.e. $y_{t,j} \\geq y_{t,j'}$ for $j < j'$. We denote by $\\hat{y}_{t,j}^{\\tau}$ the server type in lane $j$ during time slot $t$ induced by some optimal schedule $\\hat{X}^{\\tau}$ up to time $\\tau$ and by $\\widetilde{y}_{t,j}$ the server type in lane $j$ during time slot $t$ as assigned by the algorithm.\n\nThe algorithm begins by finding an optimal schedule $\\hat{X}^{\\tau}$ up to time slot $\\tau$. This schedule is chosen such that the server type in a lane of $\\hat{X}^{\\tau}$ is never reduced compared to the previously used optimal schedule $\\hat{X}^{\\tau-1}$, i.e. $\\hat{y}_{t,j}^{\\tau} \\geq \\hat{y}_{t,j}^{\\tau-1}$ for all time slots $t \\in [\\tau]$ and lanes $j \\in [m]$. Moreover, we assume that $\\hat{X}^{\\tau}$ is a schedule that powers up servers as late as possible and powers down servers as early as possible. This is necessary in case $c_k = 0$ for some server type $k \\in [d]$. We observe that these properties are fulfilled by all optimal schedules that \\cref{alg:md:optimal_graph_search} obtains. We cache the results of the optimal graph-based algorithm such that in every iteration of the online algorithm, only one dynamic update needs to be performed. The asymptotic time complexity of this dynamic update is thus given as $\\mathcal{O}(|\\mathcal{M}| C d)$ where $|\\mathcal{M}| \\in \\mathcal{O}(\\prod_{k=1}^d m_k)$.\n\nNow, the algorithm ensures that no server type is used for lane $j \\in [m]$ that is smaller than the server type used by $\\hat{X}^{\\tau}$, i.e. $\\widetilde{y}_{\\tau,j} \\geq \\hat{y}_{\\tau,j}^{\\tau}$. If $\\widetilde{y}_{\\tau-1,j} < \\hat{y}_{\\tau,j}^{\\tau}$, a server of type $\\widetilde{y}_{\\tau-1,j}$ is powered down and a server of type $\\hat{y}_{\\tau,j}^{\\tau}$ is powered up. A server of type $k$ that is not replaced by a greater server type remains active for $\\bar{t}_k := \\lfloor \\beta_k / c_k \\rfloor$ time slots~\\cite{Albers2021}. If $\\hat{X}^{\\tau}$ uses a smaller server type $k' \\leq k$ in the meantime, then the server of type $k$ will run for at least $\\bar{t}_{k'}$ further time slots.\n\nThe algorithm computes $\\widetilde{y}_{\\tau,j}$ directly. The corresponding number of active servers of type $k$ of the underlying schedule $\\widetilde{X}$ can be obtained by $\\widetilde{X}_{\\tau,j} = |\\{j \\in [m] \\mid \\widetilde{y}_{\\tau,j} = k\\}|$. The resulting algorithm is shown in \\cref{alg:md:lazy_budgeting:det_slo}. Here, $h_j$ denotes the time until the server handling line $j \\in [m]$ is powered down.\n\n\\begin{algorithm}\n    \\caption{Lazy Budgeting for SLO~\\cite{Albers2021}}\\label{alg:md:lazy_budgeting:det_slo}\n    \\KwIn{$\\mathcal{I}_{\\text{SLO}} = (d \\in \\mathbb{N}, \\tau \\in \\mathbb{N}, m \\in \\mathbb{N}^d, \\beta \\in \\mathbb{R}_{>0}^d, \\Lambda \\in \\mathbb{N}_0^{\\tau}, c \\in \\mathbb{R}_{\\geq 0}^d)$}\n    Update the previously found optimal schedule $\\hat{X}^{\\tau-1}$ to $\\hat{X}^{\\tau}$ such that $\\hat{y}_{t,j}^{\\tau} \\geq \\hat{y}_{t,j}^{\\tau-1}$ for all  $j \\in [m]$\\;\n    \\For{$j \\gets 1$ \\KwTo $m$}{\n        \\eIf{$\\widetilde{y}_{\\tau-1,j} < \\hat{y}_{\\tau,j}^{\\tau}$ \\KwOr $t \\geq h_j$}{\n            $\\widetilde{y}_{\\tau,j} \\gets \\hat{y}_{\\tau,j}^{\\tau}$\\;\n            $h_j \\gets \\tau + \\bar{t}_{\\hat{y}_{\\tau,j}^{\\tau}}$\\;\n        }{\n            $\\widetilde{y}_{\\tau,j} \\gets \\widetilde{y}_{\\tau-1,j}$\\;\n            $h_j \\gets \\max \\{h_j, \\tau + \\bar{t}_{\\hat{y}_{\\tau,j}^{\\tau}}\\}$ where $\\bar{t}_0 = 0$\\;\n        }\n    }\n    \\ForEach{$k \\in [d]$}{\n        $X_{\\tau,k} \\gets |\\{j \\in [m] \\mid \\widetilde{y}_{\\tau,j} = k\\}|$\\;\n    }\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\n\\begin{function}\n\t\\caption{BuildLanes($x, d, m$)}\\label{proc:md:lazy_budgeting:build_lanes}\n\t$y \\gets \\mathbf{0}$\\;\n\t\\For{$j \\gets 1$ \\KwTo $m$}{\n\t    \\If{$j \\leq \\sum_{k=1}^d x_k$}{\n\t        \\For{$k \\gets 1$ \\KwTo $d$}{\n        \t    \\If{$\\sum_{k'=k}^d x_{k'} \\geq j$}{\n        \t        $y_j \\gets k$\\;\n        \t    }\n        \t}\n\t    }\n\t}\n    \\Return $y$\\;\n\\end{function}\n\nSchedules can be converted to lanes in $\\mathcal{O}(m d^2)$ time as described by \\ref{proc:md:lazy_budgeting:build_lanes} and lanes can be converted back to schedules in $\\mathcal{O}(m)$ time by iterating over all lanes. Hence, the overall asymptotic time complexity of the algorithm is described by adding the time required to find the optimal schedule, i.e., $\\mathcal{O}(m d^2 + C d \\prod_{k=1}^d m_k)$.\n\n\\subsubsection{Randomized Lazy Budgeting for Smoothed Load Optimization}\n\n\\citeauthor{Albers2021}~\\cite{Albers2021} describe how the competitive ratio of the previously described \\cref{alg:md:lazy_budgeting:det_slo} can be improved to $\\frac{e}{e-1}d \\approx 1.582d$ against an oblivious adversary by randomizing the running time of a server. Before execution, the randomized algorithm chooses $\\gamma \\in [0,1]$ according to the probability density function \\begin{align*}\n    f_{\\gamma}(x) = \\begin{cases}\n        e^x / (e-1) & x \\in [0,1] \\\\\n        0 & \\text{otherwise}.\n    \\end{cases}\n\\end{align*} Then, the running time of a server of type $k \\in [d]$, $\\bar{t}_k$, is set to $\\lfloor \\gamma \\cdot \\beta_k / c_k \\rfloor$.\n\nTo sample $\\gamma$ we first seek to find the cumulative distribution function $F_{\\gamma}$. For $x \\in [0,1]$ we have \\begin{align*}\n    F_{\\gamma}(x) &= \\int_0^x f_{\\gamma}(t) \\,dt \\\\\n                  &= \\frac{1}{e-1} \\int_0^x e^t \\,dt \\\\\n                  &= \\frac{1}{e-1} (e^x - 1).\n\\end{align*} By the universality of the uniform, realizations of $F_{\\gamma}$ can be simulated given $U \\sim \\text{Unif}(0,1)$ as $F_{\\gamma}^{-1}(U) \\sim F_{\\gamma}$. It is now easy to see that $F_{\\gamma}^{-1}(x) = \\ln (x (e - 1) + 1)$.\n\nThis completes the description of the implementation of the randomized variant of lazy budgeting for SLO. The asymptotic time complexity is given by the time complexity of \\cref{alg:md:lazy_budgeting:det_slo}.\n\n\\subsubsection{Lazy Budgeting for Smoothed Balanced-Load Optimization}\n\nIn a subsequent paper, \\citeauthor{Albers2021_2}~\\cite{Albers2021_2} modified their lazy budgeting method to SBLO, allowing for more complex cost functions. The method remains similar: First, an optimal schedule is found which ends at the current time slot. Then, the algorithm ensures for each server type that the number of active servers is at least as large as the number of active servers in the optimal schedule. Lastly, to make the algorithm competitive, if the accumulated idle operating cost of a server of type $k$, $g_{t,k}(0)$ exceeds the switching cost $\\beta_k$, a server of type $k$ is powered down.\n\nFirst, \\citeauthor{Albers2021_2}~\\cite{Albers2021_2} developed a $(2d+1)$-competitive online algorithm for a setting where the operating costs are time-independent. This allows to determine the runtime of a server in advance as both $g_{t,k}(0)$ and $\\beta_k$ are known. Then, they extend their algorithm to a setting that allows for time-dependent operating costs where their algorithm attains a competitive ratio of $2d+1+\\epsilon$ for any $\\epsilon > 0$.\n\n\\paragraph{Time-Independent Operating Costs}\n\nAgain, we denote by $\\hat{X}^{\\tau}$ the optimal schedule with information up to time slot $\\tau$ and by $X$ the schedule obtained by the algorithm. If the optimal schedule has more active servers of some type $k \\in [d]$ than the schedule obtained by the algorithm, i.e. $\\hat{X}_{\\tau,k}^{\\tau} > X_{\\tau-1,k}$, $(\\hat{X}_{\\tau,k}^{\\tau} - X_{\\tau-1,k})^+$ servers of type $k$ are powered up. After being active for $\\bar{t}_k := \\lfloor \\beta_k / g_k(0) \\rfloor$ time slots, a server of type $k$ is powered down again. The resulting algorithm is shown in \\cref{alg:md:lazy_budgeting:sblo_a}. Here, $h_{t,k}$ denotes the number of servers of type $k$ that were powered up at time $t$. We assume that $h_{t,k}$ is initialized with $0$ for all $t \\in \\mathbb{Z}$ and $k \\in [d]$.\n\n\\begin{algorithm}\n    \\caption{Lazy Budgeting for SBLO (for time-independent operating costs)~\\cite{Albers2021_2}}\\label{alg:md:lazy_budgeting:sblo_a}\n    \\KwIn{$\\mathcal{I}_{\\text{SBLO}} = (d \\in \\mathbb{N}, \\tau \\in \\mathbb{N}, m \\in \\mathbb{N}^d, \\beta \\in \\mathbb{R}_{>0}^d, \\Lambda \\in \\mathbb{N}_0, G \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0}^d)^d)$}\n    Update $\\hat{X}^{\\tau-1}$ to $\\hat{X}^{\\tau}$\\;\n    \\For{$k \\gets 1$ \\KwTo $d$}{\n        $X_{\\tau,k} \\gets X_{\\tau-1,k} - h_{\\tau - \\bar{t}_k, k}$\\;\n        \\If{$X_{\\tau,k} < \\hat{X}_{\\tau,k}^{\\tau}$}{\n            $X_{\\tau,k} \\gets \\hat{X}_{\\tau,k}^{\\tau}$\\;\n            $h_{t,k} \\gets \\hat{X}_{\\tau,k}^{\\tau} - X_{\\tau,k}$\\;\n        }\n    }\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\nSimilar to our implementation of Lazy Budgeting for SLO (\\cref{alg:md:lazy_budgeting:det_slo}), we cache intermediate results of the algorithm computing the optimal schedule up to time slot $\\tau$ (\\cref{alg:md:optimal_graph_search}). It is therefore enough to perform a single dynamic update to obtain $\\hat{X}^{\\tau}$ which is possible in $\\mathcal{O}(|\\mathcal{M}| C d)$ time where $|\\mathcal{M}| \\in \\mathcal{O}(\\prod_{k=1}^d m_k)$. It is easy to see that this is also the time complexity of \\cref{alg:md:lazy_budgeting:sblo_a}.\n\n\\paragraph{Time-Dependent Operating Costs}\n\nNext, \\citeauthor{Albers2021_2}~\\cite{Albers2021_2} extend \\cref{alg:md:lazy_budgeting:sblo_a} to an algorithm which supports time-dependent operating costs and achieves a competitive ratio of $2d + 1 + c(\\mathcal{I})$ where $c(\\mathcal{I}) := \\sum_{k=1}^d \\max_{t \\in [T]} \\frac{g_{t,k}(0)}{\\beta_k}$. Now, the idle operating cost $g_{t,k}(0)$ is not constant over time anymore. Since at time $\\tau$ we only know the operating costs up to time $\\tau$, we cannot pre-determine the number of time slots that a server of type $k$ is active until powered down, yet at the time slot when a server is powered down we know all relevant cost functions. \\citeauthor{Albers2021_2}~\\cite{Albers2021_2} formally define the maximal number of time slots such that the sum of the idle operating costs beginning from the next time slot, $\\tau+1$, is smaller than or equal to the switching cost as \\begin{align*}\n    \\bar{t}_{t,k} := \\max \\left\\{\\bar{t} \\in [T - t] \\mid \\sum_{t' = t+1}^{t+\\bar{t}} g_{t,k}(0) \\leq \\beta_k\\right\\}\n\\end{align*} In contrast to \\cref{alg:md:lazy_budgeting:sblo_a} where servers of type $k$ that were powered up at time $\\tau$ were active for $\\bar{t}_{\\tau,k}$ time slots, they are now active for $\\bar{t}_{\\tau,k} + 1$ time slots.\n\nLet $W_{\\tau,k}$ denote the set of all time slots $t$ such that servers of type $k$ that were powered up at time $t$ are powered down during time slot $\\tau$, i.e., $t + \\bar{t}_{t,k} + 1 = \\tau$. Again, we denote by $h_{t,k}$ the number of servers of type $k$ that were powered up at time $t$. Using the same powering-up policy as \\cref{alg:md:lazy_budgeting:sblo_a}, the updated algorithm is described in \\cref{alg:md:lazy_budgeting:sblo_b}.\n\n\\begin{algorithm}\n    \\caption{Lazy Budgeting for SBLO (for time-dependent operating costs)~\\cite{Albers2021_2}}\\label{alg:md:lazy_budgeting:sblo_b}\n    \\KwIn{$\\mathcal{I}_{\\text{SBLO}} = (d \\in \\mathbb{N}, \\tau \\in \\mathbb{N}, m \\in \\mathbb{N}^d, \\beta \\in \\mathbb{R}_{>0}^d, \\Lambda \\in \\mathbb{N}_0^{\\tau}, G \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0}^d)^{d^{\\tau}})$}\n    Calculate $\\hat{X}^{\\tau}$\\;\n    \\For{$k \\gets 1$ \\KwTo $d$}{\n        $W_{\\tau,k} \\gets \\left\\{t \\in [\\tau-1] \\mid \\sum_{t'=t+1}^{\\tau-1} g_{t',k}(0) \\leq \\beta_k < \\sum_{t'=t+1}^{\\tau} g_{t',k}(0)\\right\\}$\\;\n        $X_{\\tau,k} \\gets X_{\\tau-1,k} - \\sum_{t \\in W_{\\tau,k}} h_{t, k}$\\;\n        \\If{$X_{\\tau,k} < \\hat{X}_{\\tau,k}^{\\tau}$}{\n            $X_{\\tau,k} \\gets \\hat{X}_{\\tau,k}^{\\tau}$\\;\n            $h_{t,k} \\gets \\hat{X}_{\\tau,k}^{\\tau} - X_{\\tau,k}$\\;\n        }\n    }\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\n$W_{\\tau,k}$ can be computed in $\\mathcal{O}(\\tau^2 C)$ time. Thus, the overall time complexity of the algorithm is $\\mathcal{O}(\\tau^2 |\\mathcal{M}| C d)$.\n\n\\paragraph{Reducing the Competitive Ratio}\n\nWe now describe how \\citeauthor{Albers2021_2}~\\cite{Albers2021_2} improve the competitive ratio of their algorithm to $2d + 1 + \\epsilon$ for any $\\epsilon > 0$. The idea is to consider a modified problem instance $\\widetilde{\\mathcal{I}} = (d, \\widetilde{\\tau}, m, \\beta, \\widetilde{\\Lambda}, \\widetilde{G})$ which divides each time slot $t$ of the original problem instance $\\mathcal{I}$ into $\\widetilde{n}_t$ sub time slots, allowing for up to $\\widetilde{n}_t$ intermediate state changes. Our goal is to choose $\\widetilde{\\mathcal{I}}$ such that $c(\\widetilde{\\mathcal{I}})$ becomes arbitrarily small.\n\nIn our description, we refer to time slots of $\\mathcal{I}$ by $t$ and to sub time slots of $\\widetilde{\\mathcal{I}}$ by $u$. The total number of sub time slots is given by $\\widetilde{\\tau} := \\sum_{t=1}^{\\tau} \\widetilde{n}_t$. We denote by $U(t) = [u+1 : u+\\widetilde{n}_t] = \\{u+1, u+2, \\dots, u+\\widetilde{n}_t\\} \\subseteq [\\widetilde{\\tau}]$ with $u = \\sum_{t'=1}^{t-1} \\widetilde{n}_t$ the set of sub time slots corresponding to time slot $t$. In contrast, let $U^{-1}(u)$ be the time slot $t \\in [\\tau]$ such that $u \\in U(t)$.\n\nThe operating cost $g_{t,k}(l)$ of a server of type $k$ during time slot $t$ under load $l$ is divided equally among all sub time slots $\\widetilde{n}_t$, i.e. $\\widetilde{g}_{u,k}(l) := g_{U^{-1}(u),k}(l) / \\widetilde{n}_{U^{-1}(u)}$. The job volume does not change, so $\\widetilde{\\lambda}_u := \\lambda_{U^{-1}(u)}$.\n\n\\citeauthor{Albers2021_2}~\\cite{Albers2021_2} show that for \\begin{align*}\n    \\widetilde{n}_t = \\left\\lceil\\frac{d}{\\epsilon} \\cdot \\max_{k \\in [d]} \\frac{g_{t,k}(0)}{\\beta_k}\\right\\rceil\n\\end{align*} the cost of the resulting schedule is at most $2d + 1 + \\epsilon$ times larger than the cost of an optimal solution. For $\\epsilon \\to 0$, the competitive ratio converges to $2d + 1$.\n\nLet $\\widetilde{X}$ be the schedule obtained by \\cref{alg:md:lazy_budgeting:sblo_b} for $\\widetilde{\\mathcal{I}}$. Then, the schedule $X$ for the original problem instance $\\mathcal{I}$ can be obtained by setting $X_{\\tau} = \\widetilde{X}_{\\mu(\\tau)}$ where $\\mu(\\tau) = \\argmin_{u \\in U(\\tau)} \\widetilde{f}_{u}(\\widetilde{X}_u)$ is the configuration that minimizes the operating cost during $U(t)$~\\cite{Albers2021_2}.\n\nThe resulting algorithm is shown in \\cref{alg:md:lazy_budgeting:sblo_c}. First, the modified problem instance $\\widetilde{\\mathcal{I}}$ is created, and the next $\\widetilde{n}_{\\tau}$ time steps are simulated using \\cref{alg:md:lazy_budgeting:sblo_b}. Then, the resulting schedule $X$ is constructed from $\\widetilde{X}$.\n\n\\begin{algorithm}\n    \\caption{Lazy Budgeting for SBLO~\\cite{Albers2021_2}}\\label{alg:md:lazy_budgeting:sblo_c}\n    \\KwIn{$\\mathcal{I}_{\\text{SBLO}} = (d \\in \\mathbb{N}, \\tau \\in \\mathbb{N}, m \\in \\mathbb{N}^d, \\beta \\in \\mathbb{R}_{>0}^d, \\Lambda \\in \\mathbb{N}_0^{\\tau}, G \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0}^d)^{d^{\\tau}})$}\n    $\\widetilde{n}_{\\tau} \\gets \\left\\lceil d / \\epsilon \\cdot \\max_{k \\in [d]} g_{\\tau,k}(0) / \\beta_k\\right\\rceil$\\;\n    Extend the modified problem instance $\\widetilde{\\mathcal{I}}$ by $\\widetilde{n}_{\\tau}$ additional time slots\\;\n    Update $\\widetilde{X}$ by executing the next $\\widetilde{n}_{\\tau}$ time slots in \\cref{alg:md:lazy_budgeting:sblo_b}\\;\n    $X_{\\tau} \\gets \\widetilde{X}_{\\mu(\\tau)}$ with $\\mu(\\tau) = \\argmin_{u \\in U(\\tau)} \\widetilde{f}_u(\\widetilde{X}_u)$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\nThe number of sub time slots $\\widetilde{n}_t$ can be determined in $\\mathcal{O}(C d)$ time. Creating the modified problem instance takes $\\mathcal{O}(\\widetilde{n}_{\\tau})$ time. Simulating \\cref{alg:md:lazy_budgeting:sblo_b} for $\\widetilde{n}_{\\tau}$ sub time slots takes $\\mathcal{O}(\\widetilde{n}_{\\tau} \\widetilde{\\tau}^2 |\\mathcal{M}| C d)$ time. The obtained schedule can be constructed in $\\mathcal{O}(\\widetilde{n}_{\\tau} C)$ time. Hence, the overall asymptotic time complexity of \\cref{alg:md:lazy_budgeting:sblo_c} is given by $\\mathcal{O}(\\widetilde{n}_{\\tau} \\widetilde{\\tau}^2 |\\mathcal{M}| C d)$, which is inversely proportional to $\\epsilon^3$.\n\n\\subsection{Descent Methods}\\label{section:online_algorithms:md:descent_methods}\n\nWhen we seek fractional solutions, and the cost functions are differentiable, a promising method is to descent towards the minimizer of the current cost function. This is an approach that is commonly used in online convex optimization, yielding algorithms with sublinear regret~\\cite{Andrew2015}. As mentioned in \\cref{section:online_algorithms:ud:rbg} on the Randomly Biased Greedy algorithm, movement costs are not considered in the online convex optimization setting, and the agent picks a point in the decision space before the cost function is revealed. A commonly used algorithm that achieves no-regret in the setting of online convex optimization is \\emph{online gradient descent} (OGD).\n\n\\subsubsection{Online Gradient Descent}\n\nOnline gradient descent works by selecting an arbitrary initial point $X_1 \\in \\mathcal{X}$ and then choosing, at time $\\tau > 1$, $X_{\\tau} = \\Pi_{\\mathcal{X}}(X_{\\tau-1} - \\eta_{\\tau-1} \\nabla f_{\\tau-1}(X_{\\tau-1}))$ where $\\eta_t$ are the learning rates and $\\Pi_{\\mathcal{X}}(x)$ is the euclidean projection of $x$ onto $\\mathcal{X}$~\\cite{Andrew2015}. The algorithm is described in \\cref{alg:md:ogd}. Similar to RBG, OGD operates with lookahead $1$. In the multi-dimensional setting, the \\emph{euclidean projection}\\index{euclidean projection} of a point $x \\in \\mathbb{R}^d$ onto a convex set $K$ is given as $\\Pi_{K}(x) = \\argmin_{y \\in K} \\norm{y - x}_2$.\n\n\\begin{algorithm}\n    \\caption{Online Gradient Descent~\\cite{Andrew2015}}\\label{alg:md:ogd}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SCO}} = (\\tau \\in \\mathbb{N}, \\mathcal{X} \\subset \\mathbb{R}^d, \\norm{\\cdot}, (f_1, \\dots, f_{\\tau}) \\in (\\mathcal{X} \\to \\mathbb{R}_{\\geq 0})^{\\tau}), \\eta > 0$}\n    $X_{\\tau} \\gets \\Pi_{\\mathcal{X}}(X_{\\tau-1} - \\eta \\nabla f_{\\tau-1}(X_{\\tau-1}))$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\nWith appropriate learning rates OGD achieves no-regret for online convex otpimization. For example, OGD obtains $\\mathcal{O}(\\sqrt{T})$-regret for $\\eta_t \\in \\Theta(1 / \\sqrt{t})$~\\cite{Andrew2015}. \\citeauthor{Andrew2015}~\\cite{Andrew2015} showed that an OGD algorithm with $\\mathcal{O}(\\rho_2(T))$-regret in the online convex optimization setting, and $\\sum_{t=1}^T \\eta_t \\in \\mathcal{O}(\\rho_1(T))$, achieves $\\mathcal{O}(\\rho_1(T) + \\rho_2(T))$-regret in the online smoothed convex otpimization setting. In particular, for learning rates $\\eta_t \\in \\Theta(1 / \\sqrt{t})$, OGD obtains $\\mathcal{O}(\\sqrt{T})$-regret when movement costs are considered and the agent picks a point after the hitting costs were revealed~\\cite{Andrew2015}.\n\nUsing finite difference methods, $\\nabla f_{\\tau-1}(X_{\\tau-1})$ can be computed in $\\mathcal{O}(d C)$ time. The euclidean projection can be computed $\\epsilon$-optimally in $\\mathcal{O}(O_{\\epsilon}^d)$ time. Thus, the overall asymptotic time complexity of OGD is $\\mathcal{O}(d C O_{\\epsilon}^d)$.\n\n\\subsubsection{Online Mirror Descent}\\label{section:online_algorithms:md:descent_methods:omd}\n\nThus, concerning regret, where algorithms seek to minimize the hitting cost immediately, the smoothing property of SCO does not require the development of new algorithms. In contrast, competitive algorithms need to wait before moving to the minimizer of the hitting cost until the movement costs are amortized. In other words, in each step, a competitive algorithm has to decide how far to move into the direction of the minimizer to balance hitting cost and movement cost. Crucially, where to move depends on the geometry of the cost function. As is shown in \\cref{fig:level_sets_of_the_hitting_costs}, rather than moving towards the minimizer directly, it is advantageous to move to a projection onto some sub-level set of the cost function. This approach minimizes the movement costs that are required to reach a point with the same hitting cost. This approach can balance hitting costs and movement costs and is discussed in \\cref{section:online_algorithms:md:descent_methods:obd}, where we introduce the online balanced descent framework.\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/level_sets}\n    \\caption{Level sets of $f_{\\tau}$ in two dimensions. The blue arrows show projections of $X_{\\tau-1}$ onto some level set. The red line visualizes the projection of $X_{\\tau-1}$ onto all level sets $\\{x \\in \\mathbb{R}^2 \\mid f_{\\tau}(x) = l\\}$ for $l \\in [\\hat{x}, f_{\\tau}(X_{\\tau-1})]$. The step in the direction of the minimizer of $f_{\\tau}$ is shown in black. Note that it is not optimal to move directly in the direction of the minimizer as there likely exists a closer point on the same level set. Online balanced descent picks a point on the red line.}\n    \\label{fig:level_sets_of_the_hitting_costs}\n\\end{figure}\n\nThe mirror descent framework is an extension of gradient descent, allowing to adapt to the underlying ``geometry'' of a problem~\\cite{Gupta2020}. The original gradient descent algorithm uses Euclidean geometry. This is shown by a slightly modified form of its update rule: \\begin{align*}\n    X_{\\tau} = \\argmin_{x \\in \\mathcal{X}} \\eta_{\\tau-1} \\langle\\nabla f_{\\tau-1}(X_{\\tau-1}), x\\rangle + \\frac{1}{2} \\norm{x - X_{\\tau-1}}_2^2.\n\\end{align*} Observe that OGD uses the squared Euclidean distance as a regularizer (i.e., a function ensuring that we remain close to the point $X_{\\tau-1}$) which can be replaced by another distance to obtain different algorithms~\\cite{Gupta2020}.\n\n\\paragraph{Proximal Point View} The Bregman divergence is a commonly used class of distance functions. Given a strictly convex \\emph{distance-generating function}\\index{distance-generating function} $h$, the Bregman divergence measures the deviation of $h$ from its linear approximation.\n\n\\begin{definition}\\index{Bregman divergence}\n\\cite{Chen2018} The Bregman divergence from a point $x$ to a point $y$ with respect to a strictly convex function $h$ is given as \\begin{align*}\n    D_h(x,y) = h(x) - h(y) - \\langle\\nabla h(y), x - y\\rangle.\n\\end{align*}\n\\end{definition}\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/bregman_divergence}\n    \\caption{Bregman Divergence $D_h(x,y)$ for a function $h : \\mathbb{R} \\to \\mathbb{R}$ \\cite{Chen2018}. The Bregman divergence measures how much a function differs at $x$ from its linear approximation at $y$.}\n    \\label{fig:bregman_divergence}\n\\end{figure}\n\nThe definition of the Bregman divergence of a univariate function $h$ is visualized in \\cref{fig:bregman_divergence}.\n\nThe modified variant of OGD, which uses a Bregman divergence as a regularizer, is known as \\emph{online mirror descent}\\index{mirror descent} (OMD) or online proximal gradient descent. Note that OMD is parametrized by $h$, which is used to describe the underlying geometry of the problem~\\cite{Chen2018}.\n\nFor the function $h(x) = \\frac{1}{2} \\norm{x}_2^2$ from $\\mathbb{R}^d$ to $\\mathbb{R}$ (the \\emph{squared $\\ell_2$ norm}\\index{squared $\\ell_2$ norm}), the Bregman divergence is the Euclidean distance, i.e. $D_h(x,y) = \\frac{1}{2} \\norm{x-y}_2^2$~\\cite{Chen2018}. Hence, OMD reduces to OGD if it is parametrized with the provided definition of $h$, i.e., a Euclidean geometry is used.\n\n\\paragraph{Mirror Map View} The proximal point view yields just one perspective of mirror descent. Another perspective that is used frequently is the perspective of mirror maps.\n\nRecall that in OGD, starting from some point $X_{\\tau-1}$, we moved into the direction of the gradient of $f$. However, note that $\\nabla f_{\\tau-1}(X_{\\tau-1})$ belongs to the dual space\\footnote{The \\emph{dual space}\\index{dual space} of a vector space $V$ over some field $\\mathbb{F}$ is the set of all linear maps from vectors in $V$ to scalars in $\\mathbb{F}$ (which are called \\emph{linear functionals}\\index{linear functionals})~\\cite{Wadsley2015}} of $\\mathbb{R}^d$. In the Euclidean space, this is not a problem as the dual space of the Euclidean space is the Euclidean space itself~\\cite{Gupta2020}. However, when working with normed spaces that are not self-dual, this is problematic.\n\nInstead of adding elements from the dual space to elements from the primal space, mirror descent maps points from the primal space to the dual space, performs the gradient step in the dual space, and then maps the resulting point back to the primal space.\n\n\\begin{figure}\n    \\centering\n    \\input{thesis/figures/mirror_descent}\n    \\caption{Visualization of a step of Mirror Descent. The previous point $X_{\\tau-1}$ is first mapped to the dual space, $\\theta_{\\tau-1}$. Then, a step is taken into the direction of the gradient, $\\theta_{\\tau}$, and the resulting point is mapped back to the primal space. Finally, the resulting point $X'_{\\tau}$ is projected back onto the feasible region $K$, resulting in the next point $X_{\\tau}$ \\cite{Gupta2020}.}\n    \\label{fig:mirror_descent}\n\\end{figure}\n\n\\begin{definition}\\index{mirror map}\n\\cite{Gupta2020} Given a norm $\\norm{\\cdot}$ and a differentiable and $\\alpha$-strongly convex function $h : \\mathbb{R}^d \\to \\mathbb{R}$, the associated mirror map is $\\nabla h : \\mathbb{R}^d \\to \\mathbb{R}^d$ and the inverse mirror map is $(\\nabla h)^{-1} : \\mathbb{R}^d \\to \\mathbb{R}^d$.\n\\end{definition}\n\nFor $h(x) = \\frac{1}{2} \\norm{x}_2^2$ the mirror map and its inverse are the identity map~\\cite{Gupta2020}. A complete description of the mirror descent framework is given in \\cref{alg:md:omd}. Note that the choice of the mirror map is central as it describes the dual space (also called mirror image) where the gradient step is taken. \\Cref{fig:mirror_descent} visualizes a step of mirror descent.\n\n\\begin{algorithm}\n    \\caption{Online Mirror Descent~\\cite{Gupta2020}}\\label{alg:md:omd}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\tau \\in \\mathbb{N}, K \\subset \\mathbb{R}^d, \\norm{\\cdot}, h \\in \\mathbb{R}^d \\to \\mathbb{R}$}\n    map to the dual space $\\theta_{\\tau-1} \\gets \\nabla h (X_{\\tau-1})$\\;\n    take a gradient step in the dual space $\\theta_{\\tau} \\gets \\theta_{\\tau-1} - \\eta_{\\tau-1} \\nabla f_{\\tau-1}(X_{\\tau-1})$\\;\n    map back to the primal space $X'_{\\tau} \\gets (\\nabla h)^{-1}(\\theta_{\\tau})$\\;\n    project $X'_{\\tau}$ onto a point $X_{\\tau} \\in K$ using the Bregman projection $X_{\\tau} \\gets \\Pi_K^h(X'_{\\tau})$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\n\\begin{definition}\\index{Bregman projection}\n\\cite{Gupta2020} The Bregman projection of a point $x$ onto a convex set $K \\subseteq \\mathbb{R}^d$ given the distance-generating function $h$ is \\begin{align*}\n    \\Pi_K^h(x) = \\argmin_{y \\in K} D_h(y,x).\n\\end{align*}\n\\end{definition}\n\nNote that when $h$ is the squared $\\ell_2$ norm, the Bregman projection is equivalent to the Euclidean projection. Using finite difference methods, the Bregman projection can be computed similarly to the Euclidean projection, $\\epsilon$-optimally in $\\mathcal{O}(O_{\\epsilon}^d)$ time, assuming the runtime of $h$ is constant.\n\nNext, we describe how the ideas from mirror descent are adapted for the smoothed online convex optimization setting, where agents operate with lookahead $1$ and movement costs need to be considered.\n\n\\subsubsection{Online Balanced Descent}\\label{section:online_algorithms:md:descent_methods:obd}\n\nThe online balanced descent (OBD) algorithms that were developed by \\citeauthor{Chen2018}~\\cite{Chen2018} are a special case of online mirror descent (OMD) with lookahead $1$. In practice, to achieve the one-step lookahead, OBD moves to a point $X_{\\tau}$ on a level set of $f_{\\tau}(\\cdot)$ such that the step is normal to the contour line of $f_{\\tau-1}$. In contrast, OMD steps into a direction that is normal to the contour line of $f_{\\tau-1}(X_{\\tau-1})$. In other words, OMD takes a step with respect to its starting point on some level set, whereas OBD takes a step with respect to its destination on some level set. \\Cref{fig:comparison_of_an_update_of_omd_and_obd} shows how these updates compare.\n\n\\begin{figure}\n    \\begin{subfigure}[b]{\\textwidth}\n    \\centering\n    \\input{thesis/figures/level_sets_omd}\n    \\caption{Update of OMD. The contour lines represent level sets of $f_{\\tau-1}$.}\n    \\end{subfigure}\n    \\par\\bigskip\n    \\begin{subfigure}[b]{\\textwidth}\n    \\centering\n    \\input{thesis/figures/level_sets_obd}\n    \\caption{Update of OBD. The contour lines represent level sets of $f_{\\tau}$.}\n    \\end{subfigure}\n    \\caption{Comparison of an update of OMD and OBD in two dimensions assuming the distance-generating function $h(x) = \\frac{1}{2} \\norm{x}_2^2$. OMD (red) takes a step in a direction normal to the contour line of $f_{\\tau-1}$ at $X_{\\tau-1}$. OBD (blue) takes a step in a direction normal to the contour line of $f_{\\tau}$ at $X_{\\tau}$ \\cite{Chen2018}. The step in the direction of the minimizer of $f_{\\tau}$ is shown in black. Note that it is not optimal to move in the direction of the minimizer to a point on some level set as there likely exists a closer point on the same level set.}\n    \\label{fig:comparison_of_an_update_of_omd_and_obd}\n\\end{figure}\n\nThe algorithmic framework for OBD can roughly be divided into two parts. First, the projection of the previous point onto some level set of the cost function.  Second, the strategies to choose the specific level set and geometry to balance hitting costs and movement costs. The algorithm for (1) is also called the \\emph{meta} algorithm as it is parametrized with a concrete level set and geometry (i.e., mirror map).\n\n\\subsubsection{Meta Algorithm}\n\nSimilar to OMD, the meta algorithm of OBD chooses the next point $X_{\\tau}$ in the dual space. However, whereas OMD takes an arbitrary step into the direction of the gradient, OBD takes the shortest step onto some sub-level set $K_l = \\{x \\in \\mathcal{X} \\mid f_{\\tau}(x) \\leq l\\}$ of the revealed hitting cost $f_{\\tau}$. In other words, we seek to find the Bregman projection of $X_{\\tau-1}$ onto the sub-level set $K_l$. The first-order condition of the corresponding optimization in the dual space implies that \\begin{align}\\label{eq:pbd:first_order_condition}\n    \\nabla h(X_{\\tau}) = \\nabla h(X_{\\tau-1}) - \\eta_{\\tau} \\nabla f_{\\tau}(X_{\\tau})\n\\end{align} must be satisfied by $X_{\\tau}$ where $\\eta_{\\tau}$ is the optimal slack of the inequality constraint $f_{\\tau}(x) \\leq l$~\\cite{Chen2018}. Note that this corresponds to a variant of OMD with lookahead $1$.\n\nOBD requires $h$ to be $\\alpha$-strongly convex and $\\beta$-Lipschitz smooth in the norm $\\norm{\\cdot}$ that is used to obtain the movement costs. The meta algorithm is described in \\cref{alg:md:obd}.\n\n\\begin{algorithm}\n    \\caption{Online Balanced Descent (meta algorithm)~\\cite{Chen2018}}\\label{alg:md:obd}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SCO}} = (\\tau \\in \\mathbb{N}, \\mathcal{X} \\subset \\mathbb{R}^d, \\norm{\\cdot}, (f_1, \\dots, f_{\\tau}) \\in (\\mathcal{X} \\to \\mathbb{R}_{\\geq 0})^{\\tau}), l \\geq 0, \\text{distance-generating function } h$}\n    $X_{\\tau} \\gets \\Pi_{K_l}^h(X_{\\tau-1})$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\nAs an example, we consider the Euclidean space with the $\\ell_2$ norm. In this setting $h(x) = \\frac{1}{2} \\norm{x}_2^2$ is 1-strongly convex and 1-Lipschitz smooth~\\cite{Chen2018}. As the corresponding mirror map, $\\nabla h$ is the identity map, the first-order condition \\cref{eq:pbd:first_order_condition} reduces to \\begin{align*}\n    X_{\\tau} = X_{\\tau-1} - \\eta_{\\tau} \\nabla f_{\\tau}(X_{\\tau})\n\\end{align*} corresponding to OGD with lookahead $1$.\n\nWe can generally choose $h$ to either perform well for the competitive ratio or regret. In their initial paper, \\citeauthor{Chen2018}~\\cite{Chen2018} propose two algorithms that balance hitting and movement costs in the primal and dual space and perform well concerning the competitive ratio and regret, respectively.\n\n\\subsubsection{Primal Algorithm}\n\n\\emph{Primal online balanced descent} (P-OBD) balances hitting and movement costs in the primal space. Let $\\hat{x} = \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$ and $x(l) = \\text{Meta-OBD}(\\mathcal{I}, l, h) = \\Pi_{K_l}^h(X_{\\tau-1})$. Given some $\\beta > 0$, the balance parameter $l$ is chosen such that a balance condition $g(l) = \\norm{x(l) - X_{\\tau-1}} \\leq \\beta l$ is satisfied. More formally, $l$ is chosen such that either $x(l) = \\hat{x}$ and $g(l) < \\beta l$ or $g(l) = \\beta l$ hold~\\cite{Chen2018}.\n\n\\citeauthor{Chen2018}~\\cite{Chen2018} show that the balance function $g(l)$ is continuous in $l$. We observe that $l$ is lower bounded by $f_{\\tau}(\\hat{x})$. As we assume that $\\hat{x}$ is unique, $x(l) = \\hat{x}$ iff $l = f_{\\tau}(\\hat{x})$ and the first condition is fulfilled if and only if $g(f_{\\tau}(\\hat{x})) < \\beta f_{\\tau}(\\hat{x})$. If the first condition is not satisfied, we can efficiently determine an $l$ fulfilling the second condition using a bracketed root finding method on $g(l) - \\beta l$ within the interval $[f_{\\tau}(\\hat{x}), \\gamma]$. Here, it suffices to choose $\\gamma$ ``large enough'' to ensure that $g(\\gamma) \\leq \\beta \\gamma$. Observe that for $\\gamma = f_{\\tau}(X_{\\tau-1})$, this is trivially satisfied, as $x(\\gamma) = X_{\\tau-1}$ and as such $g(\\gamma) = 0$. The algorithm is described in \\cref{alg:md:pobd}.\n\n\\begin{algorithm}\n    \\caption{Primal Online Balanced Descent~\\cite{Chen2018}}\\label{alg:md:pobd}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SCO}} = (\\tau \\in \\mathbb{N}, \\mathcal{X} \\subset \\mathbb{R}^d, \\norm{\\cdot}, (f_1, \\dots, f_{\\tau}) \\in (\\mathcal{X} \\to \\mathbb{R}_{\\geq 0})^{\\tau}), \\beta > 0, \\text{distance-generating function } h$}\n    $\\hat{x} = \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$\\;\n    \\If{$g(\\hat{x}) \\leq \\beta f_{\\tau}(\\hat{x})$}{\n        \\Return $\\hat{x}$\\;\n    }\n    $l \\gets $ root of $g(l') - \\beta l'$ for $l' \\in [f_{\\tau}(\\hat{x}), f_{\\tau}(X_{\\tau-1})]$\\;\n    \\Return $\\text{Meta-OBD}(\\mathcal{I}, l, h)$\\;\n\\end{algorithm}\n\nThe balancing is chosen such that the movement cost is upper bounded by the constant $\\beta$ times the hitting cost~\\cite{Chen2018}.\n\n\\citeauthor{Chen2018}~\\cite{Chen2018} show that P-OBD attains a competitive ratio of at most $3 + \\mathcal{O}(1 / \\alpha)$ for some $\\beta > 0$, $\\alpha$-locally polyhedral cost functions, and the $\\ell_2$ norm as movement cost. They also show that local polyhedrality is useful when other norms like the $l_{\\infty}$ norm are used. Note that the algorithm is memoryless and, therefore, nearly optimal, as \\citeauthor{Bansal2015}~\\cite{Bansal2015} showed in the uni-dimensional setting that no memoryless algorithm can attain a better competitive ratio than $3$ (which also holds for locally polyhedral cost functions)~\\cite{Chen2018}. When used with the $\\ell_1$ norm, which is relevant in the application of right-sizing data centers, P-OBD attains a competitive ratio of $\\mathcal{O}(\\sqrt{d})$ if $\\alpha$ is fixed~\\cite{Chen2018}. The memoryless algorithm (\\cref{alg:ud:memoryless}) of \\citeauthor{Bansal2015}~\\cite{Bansal2015} can be seen as a special case of P-OBD for $d = 1$ and $\\beta = \\frac{1}{2}$~\\cite{Chen2018}.\n\nThe minimizer can be found $\\epsilon$-optimally in $\\mathcal{O}(C O_{\\epsilon}^d)$ time. Assuming the runtime of $h$ is constant, the balance parameter $l$ can be determined $\\epsilon$-optimally in $\\mathcal{O}(O_{\\epsilon}^d R_{\\epsilon})$ time. Overall, P-OBD runs in $\\mathcal{O}(C O_{\\epsilon}^d + O_{\\epsilon}^d R_{\\epsilon})$ time.\n\n\\subsubsection{Dual Algorithm}\n\n\\citeauthor{Chen2018}~\\cite{Chen2018} also developed an algorithm called \\emph{dual online balanced descent} (D-OBD), which balances the movement cost in the dual space with the gradient of the hitting cost (which is also in the dual space). Before describing the algorithm, we must first describe how the movement cost can be represented in the dual space. We thus introduce the notion of a \\emph{dual norm}.\n\n\\begin{definition}\\index{dual norm}\n\\cite{Gupta2020} Given some norm $\\norm{\\cdot}$ on $\\mathbb{R}^d$, its dual norm $\\norm{\\cdot}_*$ is defined as \\begin{align*}\n    \\norm{y}_* = \\sup_{x \\in \\mathbb{R}^d} \\{\\langle x, y \\rangle \\mid \\norm{x} \\leq 1\\}.\n\\end{align*}\n\\end{definition}\n\nThe $\\ell_2$ norm is self-dual~\\cite{Gupta2020}. In general, the dual norm for a concrete point $y \\in \\mathbb{R}^d$ can be computed with the following convex optimization: \\begin{align*}\n    &\\max_{x \\in \\mathbb{R}^d} &&\\langle x, y \\rangle \\\\\n    &\\text{subject to}         &&\\norm{x} \\leq 1.\n\\end{align*}\n\nReturning to the description of D-OBD, for some fixed learning rate $\\eta$, $l$ is now chosen such that \\begin{align*}\n    \\norm{\\nabla h(x(l)) - \\nabla h(X_{\\tau-1})}_* = \\eta \\norm{\\nabla f_{\\tau}(x(l))}_*\n\\end{align*} holds. Let $g_1(l) = \\norm{\\nabla h(x(l)) - \\nabla h(X_{\\tau-1})}_*$ and $g_2(l) = \\norm{\\nabla f_{\\tau}(x(l))}_*$. Again, \\citeauthor{Chen2018}~\\cite{Chen2018} show that the balance function $\\frac{g_1(l)}{g_2(l)}$ is continuous in $l$ under the assumption that $h$ and $f_{\\tau}$ are continuously differentiable on $\\mathcal{X}$. Similar to our analysis of P-OBD, we observe  that $l$ is lower bounded by $f_{\\tau}(\\hat{x})$. We can determine $l$ using a bracketed root finding method on $g_1(l) - \\eta g_2(l)$ within the interval $[f_{\\tau}(\\hat{x}), \\gamma]$. We observe that for $l = f_{\\tau}(\\hat{x})$, $g_1(l) \\geq \\eta g_2(l) = 0$. Therefore, we need to choose $\\gamma$ such that $g_1(l) \\leq \\eta g_2(l)$ is satisfied. Similar to our argument for P-OBD, it suffices to choose $\\gamma = f_{\\tau}(X_{\\tau-1})$, resulting in $x(\\gamma) = X_{\\tau-1}$, and implying $g_1(\\gamma) = 0$. The resulting algorithm is described in \\cref{alg:md:dobd}.\n\n\\begin{algorithm}\n    \\caption{Dual Online Balanced Descent~\\cite{Chen2018}}\\label{alg:md:dobd}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SCO}} = (\\tau \\in \\mathbb{N}, \\mathcal{X} \\subset \\mathbb{R}^d, \\norm{\\cdot}, (f_1, \\dots, f_{\\tau}) \\in (\\mathcal{X} \\to \\mathbb{R}_{\\geq 0})^{\\tau}), \\eta > 0, \\text{distance-generating function } h$}\n    $\\hat{x} = \\argmin_{x \\in \\mathcal{X}} f_{\\tau}(x)$\\;\n    $l \\gets $ root of $g_1(l') - \\eta g_2(l')$ for $l' \\in [f_{\\tau}(\\hat{x}), f_{\\tau}(X_{\\tau-1})]$\\;\n    \\Return $\\text{Meta-OBD}(\\mathcal{I}, l, h)$\\;\n\\end{algorithm}\n\n\\citeauthor{Chen2018}~\\cite{Chen2018} show that the $L$-constrained dynamic regret of D-OBD is upper bounded by $\\frac{G L}{\\eta} + \\frac{T \\eta}{2 \\alpha}$ where $h$ is $\\alpha$-strongly convex in $\\norm{\\cdot}$, $\\norm{\\nabla h(x)}_*$ is upper bounded by $G$, and $\\nabla h(0) = 0$. When $G$, $L$, and $T$ are known, $\\eta$ can be chosen optimally as $\\eta = \\sqrt{\\frac{2 G L \\alpha}{T}}$, resulting in an $L$-constrained dynamic regret that is upper bounded by $\\sqrt{\\frac{2 G L T}{\\alpha}}$~\\cite{Chen2018}. Further, in this setting, D-OBD achieves static regret $\\mathcal{O}(\\sqrt{T})$~\\cite{Chen2018}.\n\nAn evaluation of the dual norm can be computed $\\epsilon$-optimally in $\\mathcal{O}(O_{\\epsilon}^d)$ time. Thus, assuming the runtime of $h$ is constant, $l$ can be found in $\\mathcal{O}((O_{\\epsilon}^d)^2 R_{\\epsilon})$ time. Overall, the asymptotic time complexity of D-OBD is given as $\\mathcal{O}(C O_{\\epsilon}^d + (O_{\\epsilon}^d)^2 R_{\\epsilon})$.\n\n\\subsubsection{Greedy and Regularized Algorithms}\n\nLater, \\citeauthor{Goel2019}~\\cite{Goel2019} proposed two additional algorithms using the OBD framework, \\emph{greedy online balanced descent} (G-OBD) and \\emph{regularized online balanced descent} (R-OBD). Both algorithms yield strong guarantees for the competitive ratio in the setting of squared $\\ell_2$ norm movement costs and $\\alpha$-strongly convex hitting costs where the optimal competitive ratio is $\\mathcal{O}(1 / \\sqrt{\\alpha})$ as $\\alpha$ approaches zero. G-OBD achieves this competitive ratio for quasiconvex\\footnote{A function is quasiconvex iff it has a unique global minimum.} hitting costs that are $\\alpha$-strongly convex around their minimizer and squared $\\ell_2$ norm movement costs. R-OBD achieves this competitive ratio for $\\alpha$-strongly convex hitting costs and arbitrary Bregman divergences as movement costs.\n\nBoth algorithms take an additional step of size $\\mathcal{O}(\\sqrt{\\alpha})$ towards the minimizer of the hitting cost. G-OBD works by first taking a regular P-OBD step to some level set of the hitting cost. Then, it takes an additional step towards the minimizer of the hitting cost with a step size based on the convexity parameter $\\alpha$. In contrast, R-OBD picks the next point by minimizing a weighted sum of hitting and movement costs. It uses an additional regularization term that encourages the algorithm to pick a point closer to the minimizer of the hitting cost~\\cite{Goel2019}. We do not discuss G-OBD and R-OBD in more detail, as their theoretical guarantees do not cover the application of right-sizing data centers, but we provide implementations of them.\n\n\\section{Predicting}\\label{section:online_algorithms:md:predictions}\n\nIn practice, we can attempt to use predicted hitting costs to improve the performance of online algorithms. Predicting future incoming loads to a high degree of accuracy in the data-center setting is often possible. Using predicted hitting costs and their uncertainty distributions, online algorithms can make more informed decisions in practice. In this section, we begin by discussing prediction windows. Then, we describe approaches for time-series predictions and end with discussing algorithms that use such predictions.\n\n\\subsection{Prediction Window}\n\nA natural model to allow incorporating predictions is the use of a finite prediction window $w$. A prediction window bridges the gap between offline and online algorithms. Whereas an online algorithm only knows the hitting costs $f_t$ for $t \\in [\\tau]$ and an offline algorithm knows the hitting costs $f_t$ for all $t \\in [T]$, an online algorithm with \\emph{prediction window}\\index{prediction window} of length $w$ knows all hitting costs $f_t$ up to $\\tau + w$, i.e. $t \\in [\\tau + w]$. In other words, the prediction window $w$ represents the number of upcoming time slots at which the algorithm is assumed to have perfect knowledge of the future.\n\n\\subsubsection{Lazy Capacity Provisioning with Prediction Window}\n\n\\citeauthor{Lin2011}~\\cite{Lin2011} extend their algorithm lazy capacity provisioning, which we discussed in \\cref{section:online_algorithms:ud:lazy_capacity_provisioning} to support the prediction window by changing the update rule to \\begin{align*}\n    X_{\\tau} = \\begin{cases} \n        0 & \\tau \\leq 0 \\\\\n        (X_{\\tau-1})_{X_{\\tau+w,\\tau}^L}^{X_{\\tau+w,\\tau}^U} & \\tau \\geq 1\n    \\end{cases}\n\\end{align*}\n\nThe optimal schedules now need to obtained for $\\tau + w$ rather than $\\tau$ time slots. Thus, the time complexity changes to $\\mathcal{O}((\\tau + w) C O_{\\epsilon}^{\\tau + w})$ and $\\mathcal{O}((\\tau + w)^2 C \\log_2 m)$ in the fractional and integral case, respectively.\n\nThe assumption of perfect knowledge of the future is sure to be violated when an online algorithm is used in practice. Still, \\citeauthor{Lin2011}~\\cite{Lin2011} show that lazy capacity provisioning with a prediction window is robust to this assumption in practice. \\citeauthor{Lin2011}~\\cite{Lin2011} and \\citeauthor{Albers2018}~\\cite{Albers2018} showed that using a finite prediction window does not improve the worst-case performance of the online algorithm for the fractional and integral case, respectively. In other words, the competitive ratio of lazy capacity provisioning is $3$ regardless of whether it uses a finite prediction window. In practice, however, \\citeauthor{Lin2011}~\\cite{Lin2011} show that a prediction window significantly improves the algorithm's performance.\n\nThere are two main drawbacks to using a finite prediction window. First, predictions windows are finite and typically constrained to a short period as they are assumed to be perfect. In contrast, predictions can be made for much longer time horizons, albeit with decreasing accuracy. Second, it completely disregards any knowledge or assumptions of the certainty and noise of the predictions by assuming the predictions to be perfect.\n\n\\subsection{Making Predictions}\\label{section:online_algorithms:md:predictions:making_predictions}\n\nThere exist multiple paradigms for making time-series predictions. Due to much recent engagement in the field of deep learning generally and time-series predictions specifically, multiple approaches perform well in practical settings. Most algorithms separately tune parameters of individual models for short-term and long-term trends as well as seasonality~\\cite{Taylor2017, Hosseini2021}.\n\nA fundamental difference between models is Bayesianness, i.e., whether they use an underlying uncertainty distribution within the model. Facebook's Prophet algorithm is Bayesian, whereas LinkedIn's Greykite algorithm is not~\\cite{Taylor2017, Hosseini2021}.\n\nFor Bayesian models, online algorithms can use the uncertainty distribution to consider outliers appropriately. For non-Bayesian models, additive white Gaussian noise can be added to the prediction to achieve a similar effect. In general, many strategies can be used to obtain a single representative prediction of the underlying distribution. In our experiments, we use the mean prediction to ensure appropriate consideration of outliers. The median or 90th percentile predictions are alternatives that are more robust to outliers.\n\nNote that, in principle, predictions can be made arbitrarily far into the future. However, at some point, they become too uncertain to be valuable. For example, infeasible load profiles may be assigned a positive probability, which would result an infinite cost if we use the mean to obtain a representative prediction, even if all servers are active. Thus, we also use a prediction window, which needs to be set appropriately to account for the uncertainty distribution of the predicted loads.\n\n\\subsection{Receding Horizon Control}\n\n\\emph{Receding horizon control}\\index{receding horizon control} (RHC) (or \\emph{model predictive control}) is a methodology for making decisions based on predictions of the future that is commonly used to control data centers~\\cite{Lin2012}. In RHC, an agent predicts their action up to some fixed point in time, referred to as the prediction window. Based on this prediction, the agent adjusts their action for the current time slot. In the next time slot, this process repeats~\\cite{Zak2017}.\n\n\\citeauthor{Lin2012}~\\cite{Lin2012} previously investigated the performance of RHC in the context of right-sizing data centers. RHC works by solving a convex optimization from time $\\tau$ to time $\\tau + w$ starting from the initial configuration $X_{\\tau-1}$. We set $X_0 = \\mathbf{0}$. Similar to our analysis of capacity provisioning in \\cref{section:offline_algorithms:ud:capacity_provisioning}, we describe by $X^{\\tau}(X_{\\tau-1}) \\in \\mathcal{X}^{w+1}$ the optimal schedule for times $\\tau$ through $\\tau+w$. This schedule is obtained by minimizing \\begin{align}\\label{eq:rhc}\n    \\sum_{t=\\tau}^{\\tau+w} f_t(X_t) + \\norm{X_t - X_{t-1}}\n\\end{align} over configurations $X_{\\tau}, \\dots, X_{\\tau+w} \\in \\mathcal{X}$. This optimization has $\\mathcal{O}(d w)$ dimensions and thus can be computed $\\epsilon$-optimally in $\\mathcal{O}(C O_{\\epsilon}^{dw})$ time. Now, RHC simply picks the first predicted action. RHC is described in \\cref{alg:predictions:rhc}.\n\n\\begin{algorithm}\n    \\caption{Receding Horizon Control~\\cite{Lin2012}}\\label{alg:predictions:rhc}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    $X_{\\tau} = X_{\\tau}^{\\tau}(X_{\\tau-1})$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\n\\citeauthor{Lin2012}~\\cite{Lin2012} prove the competitive ratio of RHC in the application of right-sizing data centers. They show that in the uni-dimensional setting, RHC attains a competitive ratio of $1 + \\mathcal{O}(1/w)$ which is strictly better than the optimal competitive ratio (for deterministic algorithms without predictions) of $2$ and $3$ for memoryless algorithms for $w > 1$ and $w > \\frac{1}{2}$, respectively. However, in a multi-dimensional setting, RHC is $(1 + \\max_{k \\in [d]} \\beta_k / e_k(0))$-competitive where we defined $\\beta_k$ as the switching cost of a server of type $k$ and $e_k(0)$ as the average energy cost of an idling server of type $k$. Importantly, this competitive ratio does not depend on the size of the prediction window $w$.\n\n\\subsection{Averaging Fixed Horizon Control}\n\nIn their paper, \\citeauthor{Lin2012}~\\cite{Lin2012} present another algorithm, \\emph{averaging fixed horizon control} (AFHC), which attains a competitive ratio of $1 + \\max_{k \\in [d]} \\frac{\\beta_k}{(w+1) e_k(0)}$. In particular, AFHC is $(1 + \\mathcal{O}(1/w))$-competitive. However, \\citeauthor{Lin2012}~\\cite{Lin2012} find that in many realistic settings, RHC performs better than AFHC.\n\nAt time $\\tau$, AFHC works by performing $w + 1$ individual RHC steps starting from $t_0 = \\tau-w$ up to $t_0 = \\tau$ and averaging the results. Each individual step is also referred to as an iteration of \\emph{fixed horizon control} (FHC).\n\nWe describe the sub-iterations of AFHC using $k \\in [w+1]$. We set $t_0 = \\tau+k-(w+1)$, ensuring that $t_0 \\in [\\tau-w,\\tau]$. We denote by $X^{t_0}(X_{t_0-1}^{(k)})$ the optimal schedule for times $t_0$ through $t_0+w$ which is obtained analogously to \\cref{eq:rhc}. We also set $X_t = \\mathbf{0}$ and $X_t^{(k)} = \\mathbf{0}$ for all $t \\leq 0$ and $k \\in [w+1]$. AFHC is described in \\cref{alg:predictions:afhc}.\n\n\\begin{algorithm}\n    \\caption{Averaging Fixed Horizon Control~\\cite{Lin2012}}\\label{alg:predictions:afhc}\n    \\SetKwInOut{Input}{Input}\n    \\Input{$\\mathcal{I}_{\\text{SSCO}} = (\\tau \\in \\mathbb{N}, m \\in \\mathbb{N}, \\beta \\in \\mathbb{R}_{>0}, (f_1, \\dots, f_{\\tau}) \\in (\\mathbb{R}_{\\geq 0} \\to \\mathbb{R}_{\\geq 0})^{\\tau})$}\n    \\ForEach{$k \\in [w+1]$}{\n        $t_0 \\gets \\tau+k-(w+1)$\\;\n        $X^{(k)} \\gets X^{t_0}(X_{t_0-1}^{(k)})$\\;\n    }\n    $X_{\\tau} = \\frac{1}{w+1} \\sum_{k=1}^{w+1} X_{\\tau}^{(k)}$\\;\n    \\Return $X_{\\tau}$\\;\n\\end{algorithm}\n\nIntuitively, AFHC can be interpreted as performing $w+1$ FHC-steps in parallel, where each FHC-step starts from a different $t_0 \\in [\\tau-w,\\tau]$, and then averaging all configurations for time $\\tau$. Note that RHC is equivalent to the last FHC-step with initial time $t_0 = \\tau$, i.e., $k = w+1$. The asymptotic time complexity of AFHC is given as $\\mathcal{O}(w C O_{\\epsilon}^{dw})$.\n\n\\citeauthor{Chen2015}~\\cite{Chen2015} show that AFHC achieves sublinear regret and a constant competitive ratio using a prediction window of constant length. \\citeauthor{Badiei2015}~\\cite{Badiei2015} introduce a class of ``forward-looking'' algorithms that can consider cost functions within some prediction window but are only allowed to use a constant limited number of past cost functions. They show that among these algorithms, AFHC achieves optimal regret.\n\nIn~\\cite{Chen2016}, \\citeauthor{Chen2016} generalize RHC and AFHC to a class of algorithms called \\emph{committed horizon control} (CHC), which consist of $v \\in [w+1]$ sub-iterations of FHC. Note that RHC corresponds to CHC with parameter $v = 1$, whereas AFHC corresponds to CHC with parameter $v = w+1$. They investigate how $v$ can be chosen optimally based on the noise distribution of predictions.\n\n\\citeauthor{Lin2019}~\\cite{Lin2019} extend AFHC to a new algorithm called \\emph{synchronized fixed horizon control} (SFHC), which is $(1 + \\mathcal{O}(1/w))$-competitive for both convex and non-convex cost functions. \\citeauthor{Li2018}~\\cite{Li2018} propose two new gradient-based online algorithms, \\emph{receding horizon gradient descent} (RHGD) and \\emph{receding horizon accelerated gradient} (RHAG), and show that the dynamic regret of RHAG is near-optimal when compared to a class of online algorithms that includes CHC.\n\n", "meta": {"hexsha": "5d2a87acd12628db89ed20441e47fb706e71ee40", "size": 97553, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/05_online_algorithms.tex", "max_stars_repo_name": "jonhue/bachelors-thesis", "max_stars_repo_head_hexsha": "17f760c5b1394a364a2fca1108e7a997201460aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chapters/05_online_algorithms.tex", "max_issues_repo_name": "jonhue/bachelors-thesis", "max_issues_repo_head_hexsha": "17f760c5b1394a364a2fca1108e7a997201460aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-09-08T11:45:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-05T07:47:11.000Z", "max_forks_repo_path": "thesis/chapters/05_online_algorithms.tex", "max_forks_repo_name": "jonhue/bachelors-thesis", "max_forks_repo_head_hexsha": "17f760c5b1394a364a2fca1108e7a997201460aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-14T12:01:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-14T12:01:49.000Z", "avg_line_length": 133.6342465753, "max_line_length": 1584, "alphanum_fraction": 0.7196395805, "num_tokens": 29539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4121550173693979}}
{"text": "\\documentclass[international_finance_p2.tex]{subfiles}\n\n\\begin{document}\n\\setbeamercovered{transparent}\n\\section{International Parities}\n\n\\subsection{Interest Parity. Interest Rates and Inflation}\n\\begin{frame}{Interest Parity}{Interest Rates and Inflation}\n\\begin{itemize}[<+->]\n\\item\nInterest rate parity is a no-arbitrage condition on the market under which investors will be indifferent to interest rates available on bank deposits in two different currencies. \n\\item\nNo-arbitrage condition exists when the market prices do not allow for profitable arbitrage. \n\\item\nThis condition does not always hold and this create potential opportunities for riskless profits from arbitrage deals. \n\\item\nTwo assumptions central to interest rate parity are capital mobility and perfect substitutability of domestic and foreign assets.\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Two forms of interest rate parities}\n\\begin{itemize}[<+->]\n\\item\nuncovered interest rate parity (UIRP) exists when exposure to foreign exchange risk  is uninhibited;\n\\item\ncovered interest rate parity (CIRP) exists when a forward contract has been used to cover  exchange rate risk\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Uncovered interest rate parity (UIRP)}\n\\begin{align}\n1+i_{USD}=\\frac{E_t S_{t+k}}{S_t}(1+i_{EUR}),\n\\end{align}\nwhere\n$E_t S_{t+k}$ is the expected future spot exchange rate at time $t + k$;\n\n$k$ is the number of periods into the future from time $t$;\n\n$S_t$ is the current spot exchange rate at time $t$;\n\n$i_{USD},\\quad i_{EUR}$  are the interest rates in the domestic and foreign currencies, for example USD and EUR respectively.\n\nThe dollar return on dollar deposits, $1+i_{USD}$, is shown to be equal to the dollar return on euro deposits, $\\frac{E_t S_{t+k}}{S_t}(1+i_{EUR})$.\n\\end{frame}\n\n\\begin{frame}{Covered interest rate parity (CIRP)}\n\\begin{align}\n1+i_{USD}&=\\frac{F_t}{S_t}(1+i_{EUR}) \\quad \\nonumber or\\\\\ni_{USD}-i_{EUR}&=\\frac{F_t-S_t}{S_t}\n\\end{align}\n\nwhere\n\n$F_t$ is the forward exchange rate at time $t$;\n\nThe dollar return on dollar deposits, $1+i_{USD}$, is shown to be equal to the dollar return on euro deposits, $\\frac{F_t}{S_t}(1+i_{EUR})$.\n\nCovered interest arbitrage is an arbitrage trading strategy whereby an investor capitalizes on the interest rate differential between two countries by using a forward contract to cover exchange rate risk.\n\n\\end{frame}\n\\subsection{The relation between Exchange Rates, Interest Rates, and Inflation}\n\\begin{frame}{The relation between Exchange Rates, Interest Rates, and Inflation}\n\\begin{itemize}[<+->]\n\\item\nThe nominal interest rate is the rate actually observed in the market. \n\\item\nThe real rate is a concept that measures the return after adjusting for inflation.\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{The Fisher effect}\n\\begin{align}\ni_{USD}&=r_{USD}+p^{USD}\\\\\ni_{EUR}&=r_{EUR}+p^{EUR}\n\\end{align}\n\nwhere \n\n$i$ is the nominal interest rate;\n\n$r$ is the real interest rate;\n\n$p^{USD}$ is the expected rate of inflation (in this case in US dollars or EUR).\n\\end{frame}\n\n\\begin{frame}{Real interest rate parity (RIRP)}\n\\begin{align}\nUIRP:\\Delta E_t S_{t+k}&=E_t S_{t+k}-S_t\\nonumber \\\\\n&=i_{USD}-i_{EUR},\\\\\nE_t S_{t+k}&= \\Delta E_t (p_{t+k}^{USD} ) - \\Delta E_t (p_{t+k}^{EUR} ),\n\\end{align}\n\nwhere\n\n$p_{t+k}^{USD}, \\quad p_{t+k}^{EUR}$ represent expected rate of inflation for both currencies respectively (dollar and Euro in this example).\n\nIf the above conditions hold, then they can be combined and rearranged as the following:\n\\begin{align}\nRIRP:i_{USD} - \\Delta E_t (p_{t+k}^{USD})=i_{EUR}- \\Delta E_t (p_{t+k}^{EUR} ),\n\\end{align}\n\\end{frame}\n\\begin{frame}{The link between interest rates, inflation, and exchange rates}\n\\begin{align}\nRIRP:i_{USD}-i_{EUR}&=p_{t+k}^{USD}-p_{t+k}^{EUR}\\nonumber\\\\\n&=\\frac{F_t-S_t}{S_t}.\n\\end{align}\nThe interest differential is equal to expected rates of inflation differential and is also equal to the forward premium.\n\nThe parity condition suggests that real interest rates will equalize between countries and that capital mobility will result in capital flows that eliminate opportunities for arbitrage.\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "a9c352e8c0a5b3981da41f9ff6aa7f632fbbdf8c", "size": 4133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "if/tex/2/interestparity.tex", "max_stars_repo_name": "aabor/textbooks", "max_stars_repo_head_hexsha": "8a6f8ea8cdadc3c9e934c3162a9faea74259adec", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "if/tex/2/interestparity.tex", "max_issues_repo_name": "aabor/textbooks", "max_issues_repo_head_hexsha": "8a6f8ea8cdadc3c9e934c3162a9faea74259adec", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "if/tex/2/interestparity.tex", "max_forks_repo_name": "aabor/textbooks", "max_forks_repo_head_hexsha": "8a6f8ea8cdadc3c9e934c3162a9faea74259adec", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2685185185, "max_line_length": 204, "alphanum_fraction": 0.7490926688, "num_tokens": 1151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.41215500350937234}}
{"text": "% !TEX root = RadCal_User_Guide.tex\n\n\\typeout{new file: Introduction_Chapter.tex}\n\n\\chapter{Introduction}\n\nThermal radiation fire plays a preponderant role in most fires as it is responsible for fire spread and fire growth due to thermal feedback from the hot upper layer in a compartment fire or the hot plume in an open pool fire, or controls the mass loss rate in large scale pool fire.\nIn all the aforementioned cases, it is crucial to accurately determinate the radiative heat transfer. The use of the Wien's displacement law quantifies the wavelength of the maximum radiative energy emitted by a blackbody. This law is expressed\nby\n\\begin{equation}\\label{eq:Wien}\n \\rm \\lambda_m T = 2897 \\, \\mu m.K\n\\end{equation}\nwith $\\rm \\lambda_m$ being the wavelength in units of m, corresponding to the peak intensity of blackbody emittance; T represents the temperature in units of Kelvin of the blackbody. Equation \\ref{eq:Wien} says that in typical fire configurations, where the temperature ranges from 300~K to about 2500~K, the peak emittance wavelength varies from 10 $\\rm \\mu m$ to 1.1 $\\rm \\mu m$: almost all the radiative exchanges happen in the near to mid infrared range. Most of the components involved in fire are present in gas phase. The infrared spectrum of the gases is very discontinuous, with few narrow spectral areas that participate to radiative exchange. The rest of the spectrum is practically transparent. The participation propensity varies with the amount of the species present and the local temperature.\n\nThese intrinsics aspects of the radiative exchange between medium with important gradients of temperature, species amount, and non-homogeneity in species render this problem quite complex and some level of sophistication is needed in its treatment. The radiative properties of a gas species are dictated by quantum mechanics and are related to the composition and the structure of the component considered. The discrete nature of the energy levels (mostly vibrational and rotational modes) for a given molecule generate its infrared ``fingerprint''. While a thorough consideration of all the energy levels would give an exact assessment of the radiative exchange -- this is often referred to as line-by-line calculation in the literature -- this operating mode is still too computationally expensive for engineering applications and is only used for simple configurations. Moreover, the lack of data for both elevated temperatures and for most hydrocarbon species further restricts its applicability to fire scenarios. The development of narrow-band models constitutes a compromise between accuracy and efficiency. Narrow-band models divide the spectrum of interest into small spectral segments of uniform spectral properties and use statical representations of the energy levels over these segments. Narrow band models are computationally fast and accurate. In particular, they do not require detailed knowledge of all the active energy levels in a given molecule. They are easier to implement and use than Line-by-Line techniques.\n\nRadCal was previously developed by Grosshandler \\cite{Grosshandler1993} to predict radiative heat transfer from gases at elevated temperature using narrow-band models. RadCal is a computer program, originally written in FORTRAN 77, that computes the directional spectral intensity from a non-isothermal, non-uniform mixture of gases and soot, by spectrally solving the radiative transfer equation. In addition, RadCal returns the Planck mean absorption coefficient, an effective absorption coefficient, and other integrated quantities. Details about the different models used and the quantities printed by RadCal are provided in Chapter \\ref{chap:SNB}.\n\nThe first version of RadCal was developed to predict the enhancement in radiation caused by the addition of pulverized coal to a 60 kW methanol-fired furnace~\\cite{Grosshandler1976}. This first version considered the contributions of CO, $\\rm CO_2$, $\\rm H_2O$, and soot. Validation of first version of RadCal was documented in 1979 and can be found in Ref.~\\cite{Grosshandler1979}. Predictions from RadCal for $\\rm CO_2$, CO, and $\\rm H_2O$ in individual or in mixtures were compared against published data. Good agreement was found except for some data. As Grosshandler states in Ref.~\\cite{Grosshandler1993}:\n\\textit{``...The spectrum between 1.25 and 12.5 $\\mu$m was satisfactorily reproduced, although some of the data at particular wavelengths differed from the prediction by as much as 17\\%. Considerable disagreement occurred between the integrated emittance of $\\rm CO_2$ as predicted from RADCAL and that computed from the charts of Hottel \\cite{Hottel1954}. No one source for this disagreement was identified, but it was thought to be a combination of the difficulty in obtaining high accuracy spectral measurements under the full range of conditions investigated, the uncertainty associated with extrapolating total transmittance results beyond the measured temperature and pressure-pathlengths, and the approximations associated with the narrow-band models.''}\n\nMethane was added to RadCal in 1985 \\cite{Grosshandler1985}, along with an extension to 200 $\\rm \\mu m$ of the considered spectrum. The added methane data originates mostly from experiments performed by Brosmer \\textit{et al.} \\cite{Brosmer1985} and Lee \\textit{et al.} \\cite{Lee1964}. At this time, the code structure was updated and a new input file was created.\n\nThis report, a second edition of NIST Special Publication 1402, presents the latest enhancements brought to RadCal and aims to provide an exhaustive list of the mathematical and physical models used in RadCal, which was missing from the first edition. Chapter~\\ref{chap:SNB} presents the fundamental mathematical models used in radiative heat transfer and presents the different narrow-band models used in RadCal. Chapter~\\ref{chap:old_species} recalls the characteristics of the species that were present in the 1993 version of RadCal: $\\rm H_2O$, $\\rm CO_2$, CO, $\\rm CH_4$, and soot. Additional hydrocarbons have been implemented into RadCal and the code has been rewritten, for its most part, into Fortran 2008. FTIR transmission measurements at the National Institute of Standards and Technology (NIST) were undertaken to provide highly resolved spectral absorption coefficients in the mid-IR and NIR as a function of temperature for many fuel species~\\cite{Wakatsuki2005a,Wakatsuki2008,Yilmaz2008}. These measurements were performed over a range of temperatures from 300~K up to 1000~K for several fuel species, including paraffins (methane, ethane, propane, and n-heptane), olefins (ethylene and propylene), and other fuel-related species (methanol, toluene, and methyl-methacrylate). The uniform set of conditions and spectral resolution of these measurements have provided a set of data for developing calculation methodologies for absorption coefficients of these species in flame environments. New species and their associated narrow-band parameters are described in Chapter~\\ref{chap:new_species}. The syntax of the input file was modified to make good use of native Fortran namelist that offers a more flexible way to input data. Chapter~\\ref{chap::using_RADCAL} describes the new input file syntax, and how to compile and use RadCal. The code was modified following a modular approach and was translated into Fortran 2008 to benefit from recent advances in Fortran standard. The list of RadCal functions and subroutines is detailed in Chapter~\\ref{chap:Code}.  The code has also been modified to account for any type of fuel mixture. Verification of the new species spectral data has been performed and results from these tests are reported in Chapter~\\ref{sec:verification}. Finally, Chapter~\\ref{chap::validation_tests} compares the new version of RadCal with the 1993 one for the various validation tests presented in the first edition of this report. This chapter also presents predicted quantities from an experimentally characterized small methanol pool fire.\n\n\n\nInclude here New RadCal features in a list:\n\n\\begin{itemize}\n \\item New species spectral data between 700 and 4000~$\\rm cm^{-1}$ and for temperature ranging from about 300~K to about 1000~K.\n \\item New species data for: Ethylene, Ethane, Propylene, Propane, n-Heptane, Toluene, Methanol, Methane, MMA\n \\item Code rewritten in Fortran 2008\n \\item Code made modular\n \\item More convenient input file\n \\item Possibility to calculate the spectrum for any mixture of gas\n \\item Updated and enhanced user guide\n\\end{itemize}\n", "meta": {"hexsha": "22ecb63e6173898a33328127994bdb63bf26419e", "size": 8561, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/Introduction_Chapter.tex", "max_stars_repo_name": "mcgratta/radcal", "max_stars_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_stars_repo_licenses": ["Linux-OpenIB"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documentation/Introduction_Chapter.tex", "max_issues_repo_name": "mcgratta/radcal", "max_issues_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_issues_repo_licenses": ["Linux-OpenIB"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/Introduction_Chapter.tex", "max_forks_repo_name": "mcgratta/radcal", "max_forks_repo_head_hexsha": "83cb42ec8f43f243fe3b0b7640f62071b8482129", "max_forks_repo_licenses": ["Linux-OpenIB"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 219.5128205128, "max_line_length": 2579, "alphanum_fraction": 0.8120546665, "num_tokens": 1857, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4120647175871202}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage{epsfig,latexsym,amsmath,amssymb,epic,eepic,psfrag,subfigure,float,euscript,array}\n\\usepackage[latin1]{inputenc}\n\\usepackage{standalone}\n\\usepackage{tikz,pgf,pgfplots}\n\n\\newenvironment{exercise}[1][Uppgift]{\\begin{trivlist} \\item[\\hskip\n    \\labelsep {\\stepcounter{exerctr}\\bfseries #1\n      \\arabic{exerctr}}]}{\\end{trivlist}\\vspace{10mm}}\n\n\\newcounter{exerctr}\n\\newcounter{abcctr}[exerctr]\n\n\\newcommand{\\abc}{\\noindent\\vspace{1mm}\\\\ {\\bf\n    \\stepcounter{abcctr}(\\alph{abcctr})\\ }}\n\\newcommand{\\bbm}{\\begin{bmatrix}}\n\\newcommand{\\ebm}{\\end{bmatrix}}\n\\newcommand{\\point}[1]{\\hfill {\\bf (#1p)}\\\\ \\vspace{-5mm}}\n\\newcommand{\\ctrb}{\\EuScript{S}}\n\\newcommand{\\Lap}{\\mathcal{L}}\n\\newcommand{\\obsv}{\\EuScript{O}}\n\\newcommand{\\realdel}[1]{\\text{Re}\\left\\{#1\\right\\}}\n\\newcommand{\\imagdel}{\\text{Im}}\n\\newcommand{\\bC}{\\mathbb{C}}\n\\newcommand{\\bR}{\\mathbb{R}}\n\\newcommand{\\bmpv}{\\begin{minipage}[t]}\n\\newcommand{\\bmps}{\\begin{minipage}[t]{45mm}}\n\\newcommand{\\bmpm}{\\begin{minipage}[t]{90mm}}\n\\newcommand{\\bmpl}{\\begin{minipage}[t]{140mm}}\n\\newcommand{\\emp}{\\end{minipage}}\n\\newcommand*{\\zethree}{\\big(z - \\mexp{-3h}\\big)}\n\\newcommand*{\\mexp}[1]{\\ensuremath{\\mathrm{e}^{#1}}}\n\n\\newcommand*\\circled[1]{\\tikz[baseline=(char.base)]{\n            \\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}\n\n\\addtolength{\\topmargin}{-1cm}\n\\textheight 23.5cm\n%\\oddsidemargin 0.61cm\n%\\evensidemargin 0.61cm\n\n\n\\def\\OctaveG{tf([0.5 1], [1 0 -1])}\n\n\\title{Computerized control partial exam 1 from fall semester 2016, modified}\n\\author{Kjartan Halvorsen}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\begin{description}\n\\item[Time] September 13 17:30\n\\item[Place] 4101\n\\item[Permitted aids] The single colored page with your own notes, table of Laplace transforms, calculator\n\\end{description}\n\nAll answers should be readable and well motivated (if nothing else is written). Solutions/motivations should be written on the provided spaces in this exam. Use the last page if more space is needed.\n\n\\begin{center}\n{\\Large Good luck!} \\\\\n\\end{center}\n\n\\begin{tabular}{|l|l|}\n\\hline\n\\multicolumn{2}{|l|}{\\bmpl\nMatricula and name\n\\vspace*{18mm}\n\\emp}\\\\\n\\hline\n\n\\end{tabular}\n\n\\clearpage\n\n%-----------------------------------------------------------------\n\\subsection*{The system}\nThe dynamic model of a ship with input $u$ being the rudder angle and the output $y$ being the heading (see figure \\ref{fig:tanker}) can be described as a continuous-time second order system with a pole in the origin\n\\[ G(s) = \\frac{K}{s(s + a)}. \\]\nFor fully loaded, large tankers this dynamics is often unstable, meaning that $a<0$.  \n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=0.8\\linewidth]{tanker}\n\\caption{Heading of a ship controlled by rudder input.}\n\\label{fig:tanker}\n\\end{center}\n\\end{figure}\n\nConsider for this exam the normalized continuous-time model of the tanker\n\\[ G(s) = \\frac{1}{s(s - 1)}. \\]\n\n\\clearpage\n\\subsection*{Problem 1 (50p)}\n\nThe system is sampled with sampling interval $h$ using step-invariant (zero-order hold) sampling. \\textbf{Circle the correct pulse-transfer function below, and show your calculations}\n\\begin{enumerate}\n \\item \\( H(z) = \\frac{(1-\\mexp{h} -h)z - \\big((1-h)\\mexp{h}-1\\big)}{(z-1)(z-\\mexp{h})}\\)\n \\item \\( H(z) = \\frac{(-1+\\mexp{h} -h)z - \\big((1-h)\\mexp{h}-1\\big)}{(z-1)(z-\\mexp{2h})}\\)\n \\item \\( H(z) = \\frac{(-1+\\mexp{h} -h)z - \\big((1-h)\\mexp{h}-1\\big)}{(z-1)(z-\\mexp{h})}\\)\n \\end{enumerate}\n\n\\noindent\n\\fbox{\n\\bmpl\n{\\bf Derivation:}\\\\\n\\vspace*{150mm}\n\\emp}\n\n\\clearpage\n\\subsection*{Problem 2 (20p)}\nAssume that the sampling period is $h=0.2$. In figure \\ref{fig:complex-plane} draw the poles (crosses) and zero (circle) for both the continuous-time transfer function $G(s)$ and the  discretized pulse-transfer function $H(z)$ you determined in Problem 1.\n   \\begin{figure}[h]\n   \\begin{center}\n   \\includegraphics[]{complex-plane}\n   \\caption{Problem 2: Plot the poles of the continuous-time system (on the left) and the poles and zero of the discrete-time system (on the right). Indicate (with arrows and/or colors) corresponding pairs of continuous-time and discrete-time poles.}\n   \\label{fig:complex-plane}\n   \\end{center}\n   \\end{figure}\n\n\\noindent\n\\fbox{\n\\bmpl\n{\\bf Calculations:}\\\\\n\\vspace*{90mm}\n\\emp}\n\n\\clearpage\n\n\\subsection*{Problem 3 (40p)}\nAssume, now, that the plant \\(H(z) = \\frac{1}{z-0.9}\\) is controlled by feedback from the control error, as illustrated in figure~\\ref{fig:feedback}, using the controller\n\\[ F(z) = K\\frac{z}{z-1}. \\]\n\n\\begin{figure}\n\\begin{center}\n     \\begin{tikzpicture}[scale = 0.8, node distance=25mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]\n     \n     \\node[coordinate] (refinput) {};\n     \\node[sumnode, right of=refinput, node distance=20mm] (sumerr) {\\tiny $\\sum$};\n     \\node[block, right of=sumerr] (controller) {$K\\frac{z}{z-1}$};\n     %\\node[above of=controller, node distance=6mm] {controller};\n     \\node[block, right of=controller, node distance=35mm] (plant) {$\\frac{1}{z-0.9}$};\n     \\node[sumnode, right of=plant, node distance=24mm] (sum) {\\tiny $\\sum$};\n     %\\node[above of=tank, node distance=6mm] {motor};\n     \\node[coordinate, right of=sum, node distance=20mm] (output) {};\n     \\node[coordinate, above of=sum, node distance=12mm] (disturbance) {};\n\n     \\draw[->] (refinput) -- node[above, pos=0.3] {$u_c(k)$} (sumerr);\n     \\draw[->] (sumerr) -- node[above] {$e(k)$} (controller);\n     \\draw[->] (controller) -- node[above] {$u(k)$} (plant);\n     \\draw[->] (plant) -- (sum);\n     \\draw[->] (sum) -- node [coordinate] (measure)  {} node [above, near end] {$y(k)$} (output);\n     \\draw[->] (disturbance) -- node[right, pos=0.2] {$d(k)$} (sum);\n     \\draw[->] (measure) -- ++(0,-14mm) -| node[right, pos=0.95] {$-$} (sumerr);\n     \\end{tikzpicture}\n     \\caption{Feedback control from the error signal.}\n     \\label{fig:feedback}\n   \\end{center}\n \\end{figure}\n \n\\subsubsection*{(a) 20p}\n\nFigure~\\ref{fig:rlocus} shows the root locus for the closed-loop poles with respect to the gain $K$. In figure~\\ref{fig:step}, four different step plots are shown for four different values of $K$. Identify (and circle) the corresponding step plot for each value of $K$ in the table below.\n\n\\begin{center}\n\\begin{tabular}{cl}\n\\(K\\) & Step plot\\\\\\hline\n0.002 & A\\hspace*{2mm} B\\hspace*{2mm} C\\hspace*{2mm} D\\\\\n1.0 & A\\hspace*{2mm}  B\\hspace*{2mm}  C\\hspace*{2mm} D\\\\\n3.0 & A\\hspace*{2mm} B\\hspace*{2mm}  C\\hspace*{2mm} D\\\\\n4.0 & A\\hspace*{2mm} B\\hspace*{2mm}  C\\hspace*{2mm} D\\\\ \\hline\n\\end{tabular}\n\\end{center}\n\n\\begin{figure}[bp]\n\\begin{center}\n\\begin{tikzpicture}\n    \\node[anchor=south west,inner sep=0] at (0,0) {\\includegraphics[width=0.5\\linewidth]{p2_rlocus_rlocus-crop}};\n    \\node[coordinate, pin={[pin distance=20mm] 80:{$K=0.003$}}] at (7.17,3.47) {};\n    \\node[coordinate, pin={[pin distance=20mm] 115:{$K=3.8$}}] at (3.77,3.47) {};\n\\end{tikzpicture} \n\n\\caption{Root locus wrt the gain $K$.}\n\\label{fig:rlocus}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tp]\n\\begin{center}\n\\begin{tabular}{cc}\nA & B\\\\\n\\includegraphics[width=0.4\\linewidth]{step-plot-3-crop}\n&\\includegraphics[width=0.4\\linewidth]{step-plot-1-crop}\\\\\nC & D\\\\\n\\includegraphics[width=0.4\\linewidth]{step-plot-5-crop}\n&\\includegraphics[width=0.4\\linewidth]{step-plot-2-crop}\n\n\\end{tabular}\n\\caption{Step responses for different values of $K$.}\n\\label{fig:step}\n\\end{center}\n\\end{figure}\n\n\\clearpage\n\\subsubsection*{(b) 20p}\n\nDetermine the gain $K$ so that the closed loop system has poles with realpart equal to $0.7$.\n\n\n\\noindent\n\\fbox{\n\\bmpl\n{\\bf Solution:}\\\\\n\\vspace*{150mm}\n\\emp}\n\n\\cleardoublepage\n\n\\noindent\n{\\bf If necessary,} you can continue your solutions on this page. Mark clearly which problem the solution corresponds to.\n\n\n%\\end{document}\n\n%*****************************************************************\n%*****************************************************************\n\\newpage\n\\setcounter{page}{1}\n\n\\section*{Solutions}\n\\subsection*{Problem 1}\n   First calculate the step-response of the continous-time system\n   \\[Y(s) = G(s)\\frac{1}{s} = \\frac{1}{s^2(s-1)} = \\frac{1}{s-1} - \\frac{1}{s} - \\frac{1}{s^2}.\\]\n   The inverse Laplace-transform gives\n   \\[ y(t) = \\mexp{t} - 1 - t\\]\n   Sampling this function gives\n   \\[ y(kh) = \\mexp{kh} -1 - kh\\]\n   which has the Z-transform\n   \\[Y(z) = \\frac{z}{z - \\mexp{h}} - \\frac{z}{z-1} - \\frac{hz}{(z-1)^2}\\]\n   Dividing the z-transform of the system response to that of the input (the step) gives\n   \\begin{align*}\n   H(z) &= \\frac{Y(z)}{U(z)} = \\frac{z-1}{z}Y(z) = \\frac{z-1}{z-\\mexp{h}} - 1 - \\frac{h}{z-1}\\\\\n        &= \\frac{(z-1)^2 - (z-1)(z-\\mexp{h}) - h(z-\\mexp{h})}{(z-1)(z-\\mexp{h})}\\\\\n\t&= \\frac{(z-1)(z-1 -z + \\mexp{h}) - hz + h\\mexp{h}}{(z-1)(z-\\mexp{h})}\\\\\n        &= \\frac{ (\\mexp{h} - 1 -h)z - (\\mexp{h}-1-h\\mexp{h})}{(z-1)(z-\\mexp{h})}\\\\\n        &= \\frac{ (\\mexp{h} - 1 -h)z - \\big( (1-h)\\mexp{h}-1\\big)}{(z-1)(z-\\mexp{h})}\\\\\n   \\end{align*}\n\n   The correct pulse transfer function is the third.\n\n\\subsection*{Problem 2}\nThe discrete-time poles are in $z=1$ and $z=\\mexp{0.2} \\approx 1.22$. The zero is  in \n\\[ z = - \\frac{(1-h)\\mexp{0.2} - 1}{\\mexp{0.2} - 1 -h} \\approx -1.07. \\]\n\\begin{center}\n\\includegraphics[width=0.8\\linewidth]{complex-plane-facit}\n\\end{center}\n \n\\subsection*{Problem 3}\n\n\\subsubsection*{(a)}\n\nThe root locus starts with two poles at $1$ and $0.9$. For small values of $K$ we will have poles that are slow and completely damped. The only such response is \\textbf{B}. As $K$ increases we will have closed-loop poles that follows the unit circle a bit inside it. The poles will have little damping and will increase in speed with $K$. Finally, one pole move outside the unit circle, and the system becomes unstable. It is easy to see the response that is slow (B) and unstable (C). It is a bit difficult to read off the difference in osciallation period between the other two responses. In summary, we get\n\n\\begin{center}\n\\begin{tabular}{cl}\n\\(K\\) & Step plot\\\\\\hline\n0.002 & A\\hspace*{2mm} \\circled{B}\\hspace*{2mm} C\\hspace*{2mm} D\\\\\n1.0 & A\\hspace*{2mm}  B\\hspace*{2mm}  C\\hspace*{2mm} \\circled{D}\\\\\n3.0 & \\circled{A}\\hspace*{2mm} B\\hspace*{2mm}  C\\hspace*{2mm} D\\\\\n4.0 & A\\hspace*{2mm} B\\hspace*{2mm}  \\circled{C}\\hspace*{2mm} D\\\\ \\hline\n\\end{tabular}\n\\end{center}\n\n\\subsubsection*{(b)}\n\nThe closed-loop system from command signal to the output is\n\\[ H_c(z) = \\frac{K \\frac{z}{z-1}\\frac{1}{z-0.9}}{1 + K \\frac{z}{z-1}\\frac{1}{z-0.9}} = \\frac{Kz}{(z-1)(z-0.9) + Kz}. \\]\nThe characteristic equation is \n\\[ (z-1)(z-0.9) + Kz = z^2 - (1.9-K)z + 0.9 = 0 \\]\nwith solution\n\\[ z = \\frac{1.9-K}{2} \\pm \\frac{1}{2}\\sqrt{(1.9-K)^2 - 5.6}. \\]\nWe know from the root locus that for a value of  $K$ that gives poles with real part $0.7$, then the poles are complex-conjugated and so the expression under the root sign must be negative. The real part is given by the first term in the solution to the quadratic equation. We get\n\\[ \\frac{1.9-K}{2} = 0.7 \\quad \\Rightarrow \\quad K = 1.9-1.4 = 0.5 \\]\n\n\\end{document}\n", "meta": {"hexsha": "a5c36378487db7ad3437b45689dcd300822b10d4", "size": 11028, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/partial-exam-1/MR2007-partial-1-dummy-vt17.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "exams/partial-exam-1/MR2007-partial-1-dummy-vt17.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "exams/partial-exam-1/MR2007-partial-1-dummy-vt17.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 38.5594405594, "max_line_length": 609, "alphanum_fraction": 0.6523394995, "num_tokens": 3979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704796847396, "lm_q2_score": 0.743167997235783, "lm_q1q2_score": 0.41206471591367183}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n%\\makeindex\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on \n\n\\subsection{Free Homotopy of Curves}\n\\label{sub:free_homotopy_of_curves}\n\nIn order to state Cauchy's theorem in complete generality, we need to construct a notion of homotopy for curves.\n\n\\begin{defn}[Free Homotopy]\n\tA \\textbf{free homotopy} of closed curves in \\(\\Omega \\) is a continuous map \\(\\gamma(\\tau,t)\\) from \\([0,1]\\times [t_0,t_1]\\) to \\(\\Omega \\) such that\n\\begin{align*}\n\t\\gamma(\\tau,t_0) = \\gamma(\\tau,t_1)\n\\end{align*}\nfor every \\(\\tau\\in [0,1]\\). We can denote \\(\\gamma_\\tau(t) := \\gamma(\\tau,t)\\).\\\\\n\nWe say \\(\\gamma_0,\\gamma_1\\) are \\textbf{homotopic} if there exists a free homotopy with \\(\\gamma(0,t) = \\gamma_0\\) and \\(\\gamma(1,t) = \\gamma_1\\).\n\\end{defn}\nOf course, if \\(\\Omega \\) is convex, then any two curves are automatically freely homotopic.\n\n\n% \\printindex\n\\end{document}\n", "meta": {"hexsha": "924e67f39ccdfaa827ef8ed4b9e150d28a6e2a74", "size": 1273, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Complex Analysis/Notes/source/CurveHomotopy.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Complex Analysis/Notes/source/CurveHomotopy.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Complex Analysis/Notes/source/CurveHomotopy.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3095238095, "max_line_length": 152, "alphanum_fraction": 0.7085624509, "num_tokens": 415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.412020074760097}}
{"text": "\\graphicspath{{Pics/}}\n\n\n\\newpage\\section{Centers of inside and outside}\n\n\n\\impden{Incenter and Co.}{ \n    Let $\\triangle ABC$ be an ordinary triangle, $I$ is\n    its incenter, $D, E, F$ are the touch points of the incenter with $BC, CA,\n    AB$ and $ D', E', F' $ are the reflections of $D, E, F$ wrt $ I $. \n    Let the $ I_a, I_b, I_c $ excircles touch $BC, CA, AB$ at $D_1, E_1,\n    F_1$.\\\\\n\n    Let $M_a, M_b, M_c$ be the midpoints of the smaller arcs $BC, CA, AB$, and\n    $M_A, M_B, M_C$ be the midpoints of the major arcs $BC, CA, AB$. $ M $ are\n    the midpoint of $ BC $.  Let $ A' $ be the antipode of $ A $ wrt $ \\odot\n    ABC $.\\\\\n\n    Let $(I_a)$ touch $BC, CA, AB$ at $D_A, E_A, F_A$. So, $D_A \\equiv D_1$.\\\\\n\n    Call $ EF $, `$ A $-tangent line', and $ DE, DF $ similarly. And call $\n    E_AF_A $ `$ A_A $-tangent line.\\\\\n\n    \\figdf{.8}{incenter_main}{All the primary points related to the incenter\n    and the excenters}\n}\n\n\\newpage\n\n\\begin{minipage}{.59\\linewidth} \n    \\lem{Antipode and Incenter}{\n        $ A'I, \\odot ABC, \\odot AEIF $ are concurrent at $ Y_A $. And $ Y_A,\n        D, M_a $ are collinear.\n    }\n\n    \\lem{}{\n        $ DD_H \\perp EF $, then $ D_H, I, A' $ are collinear.\n    }\n\n    \\lem{}{\n        \\[\\frac{FD_H}{D_HE} = \\frac{BD}{DC}\\] \n    }\n\n    \\vspace{2em}\n\n    \\lem{Arc Midpoint as Centers}{\n        \\[M_AE_1 = M_AF_1\\quad M_BF_1 = M_BD_1\\quad M_CD_1 = M_CE_1\\]\n    Moreover, $I, O$ are the orthocenter and the circumcenter of $\\triangle\n    I_aI_bI_c$\n    }\n\n    \\vspace{4em}\n\n    \\lem{Incircle Touchpoint and Cevian}{\n        Let a cevian be $ AX $ and let $ I_1, I_2 $ be the incirlces of $\n        \\triangle ABX, \\triangle ACX $. Then $ D, I_1, I_2, X $ are concyclic.\n        And the other common tangent of $ \\odot I_1 $ and $ \\odot I_2 $ goes\n        through $ D $.\n    } \n\n\\end{minipage}\\hfill% \n\\begin{minipage}{.39\\linewidth}\n    \\figdf{.9}{antipode_incenter}{\\autoref{lemma:Antipode and Incenter}}\n\n    \\figdf{.9}{excenter_touchpoint_bigarc-midpoints}{\\autoref{lemma:Arc Midpoint\n    as Centers}}\n    \\figdf{.9}{incircle_touchpoint_and_cevian}{\\autoref{lemma:Incircle Touchpoint\n    and Cevian}} \n\\end{minipage}\n\n\\newpage\n\n\\begin{minipage}{.5\\linewidth} \n    \\lem{Apollonius Circle and Incenter, ISL 2002 G7}{\n        Let $ \\omega_a $ be the circle that goes through $ B, C $ and is\n        tangent to $ (I) $ at $ X $. \\hl{Then $ XD', EF, BC $ are concurrent and $\n        X, D, I_a $ are collinear.} The same properties is held if the roles of\n        incenter and excenter are swapped.  \n        \\begin{itemize}[left=0pt, itemsep=0pt]\n            \\item The circle $ BXC $ is tangent to $ (I) $ \n            \\item $ X $ lies on the Apollonius Circle of $ (B, C; D, G) $.\n            \\item $ XD $ bisects $ \\angle BXC $.  \n        \\end{itemize} \n    } \n\n    \\lem{Line parallel to BC through I}{\n        Let $E, F$ be the intersection of the $B, C$ angle bisectors with $AC,\n        AB$. Then the tangent to $\\odot ABC$ at $A$, $EF$ and the line through\n        $I$ parallel to $BC$ are concurrent.\n    }\n    \\lem{Midline Concurrency with Incircle Touchpoints}{\n        $AI$, $ B, B_A $-tangent lines and $ C $-mid-line are concurrent. And,\n        if the concurrency point is $ X $, then $ CS\\perp AI $\n    }\n    \\theo{}{Paul Yui Theorem}{\n        $ B $-tangent line, $ C_A $-tangent line, and $ AH $ are concurrent.\n    }\n\n    \\lem{Concurrent Lines in Incenter}{\n        Let $ AD \\cap (I) = G, AD' \\cap (I) = H $. Let the line through $ D' $\n        parallel to $ BC $ meet $ AB, AC $ at $ B', C' $. Then $ AM,\\ EF,\\\n        GH,\\ DD',\\ BC',\\ CB' $ are concurrent.\n    }\\label{lemma:concurrent_lines_in_incenter}\n\\end{minipage}\\hfill% \n\\begin{minipage}{.48\\linewidth}\n    \\figdf{.9}{InExLemma3}{\\autoref{lemma:Apollonius Circle and Incenter, ISL 2002 G7}}\n\n    \\figdf{.9}{BC_parallel_through_I}{\\autoref{lemma:Line parallel to BC\n    through I}}\n\n    \\figdf{.8}{InExLemma4}{\n        \\autoref{lemma:Midline Concurrency with Incircle Touchpoints} \\&\n        \\autoref{theorem:Paul Yui Theorem}\n    } \n\\end{minipage}\n\n\\figdf{.5}{concurrent_lines_in_incenter}{\n    \\autoref{lemma:Concurrent Lines in Incenter} \n    The lines are concurrent.\n} \n\n\n\\begin{minipage}{.5\\linewidth}\n    \\lem{Insimilicenter}{\n        The \\emph{insimilicenter} is the positive homothety center of the\n        circumcircle and the incircle. It is also the \\emph{isogonal conjugate of\n        the Nagel Point} wrt $\\triangle ABC$.\n    }\n\n    \\begin{solution}\n        Let $T$ be the $A$-mixtilinear touchpoint. If $AT\\cap \\left(I\\right)\n        =A'$, then if we can show that $A'B'$ arc has angle $\\angle C$, where\n        $A'B'\\parallel AB$, we are done.\n    \\end{solution}\n\\end{minipage}\\hfill%\n\\begin{minipage}{.49\\linewidth}\n    \\figdf{.9}{insimilicenter}{}\n\\end{minipage}\n\n\\prob{}\n{Application of Aollonius Circle and Incenter Lemma}{}{\n    Let triangle $ABC$, incircle $(I)$, the $A$-excircle $(I_a)$ touches\n    $BC$ at $M$. $IM$ intersects $(I_a)$ at the second point $X$. Similarly,\n    we get $Y$, $Z$. Prove that $AX$, $BY$, $CZ$ are concurrent.\\\\\n\n    \\href{http://artofproblemsolving.com/community/c6h1595900p9909100}{Extension,\n    by buratinogigle}: Triangle $ABC$ and $XYZ$ are homothetic with center $I$ is\n    incenter of $ABC.$ Excircles touches $BC,$ $CA,$ $AB$ at $D,$ $E,$ $F.$ $XD,$\n    $YE,$ $FZ$ meets excircles again at $U,$ $V,$ $W.$ Prove that $AU,$ $BV,$ $CW$\n    are concurrent.\n}\n\n\n\\newpage\n\n\\den{Isodynamic Points}{\n    Let $ ABC $ be a triangle, and let the angle bisectors\n    of $ \\angle A $ meet $ BC $ at $ X, Y $. Call $ \\omega_a $ the\n    circumcircle of $ \\triangle AXY $. Define $ \\omega_b, \\omega_c $\n    similarly. The first and second isodynamic points are the points where the\n    three circles $ \\omega_a, \\omega_b, \\omega_c $ meet. I.e. these two points\n    are the intersections of the three Apollonius circles. These two points\n    satisfy the following relations: \n    \\begin{enumerate} \n        \\item $PA\\sin A = PB\\sin B = PC\\sin C$ \n        \\item They are the isogonal congugates of the\n            Fermat Points, and they lie on the `Brocard Axis' \n    \\end{enumerate}\n    \\figdf{.6}{Isodynamic_Points}{} \n}\n\n\\theo{https://en.wikipedia.org/wiki/Isodynamic_point}{Pedal Triangles of\n    Isodynamic Points}{\n    Prove that the pedal triangles of the isodynamic points are\n    equilateral triangles. Also, Inverting around the Isodynamic Points trasnform\n    $\\triangle ABC $ into an equilateral triangle.\n}\n\n\\prob{https://artofproblemsolving.com/community/c6h1568534p9617561}{China TST\n    2018 T1P3}{EM}{\n    Circle $\\omega$ is tangent to sides $AB$,$AC$ of triangle $ABC$\n    at $D$,$E$ respectively, such that $D\\neq B$, $E\\neq C$ and $BD+CE<BC$.\n    $F$,$G$ lies on $BC$ such that $BF=BD$, $CG=CE$. Let $DG$ and $EF$ meet at\n    $K$. $L$ lies on minor arc $DE$ of $\\omega$, such that the tangent of $L$ to\n    $\\omega$ is parallel to $BC$. Prove that the incenter of $\\triangle ABC$ lies\n    on $KL$.\n}\n\n\\solu{\n    Using \\autoref{lemma:Collinearity with antipode and center}, in the\n    touch triangle of $\\omega$.\n}\n\n\n\\prob{}\n{}{E}{\n    Given a triangle $A B C$ with circumcircle $\\Gamma$. Points $E$ and $F$\n    are the foot of angle bisectors of $B$ and $C, I$ is incenter and $K$ is\n    the intersection of $A I$ and $E F$. Suppose that $N$ be the midpoint of\n    arc $B A C$. Circle $\\Gamma$ intersects the $A$ -median and circumcircle\n    of $A E F$ for the second time at $X$ and $S$. Let $S^{\\prime}$ be the\n    reflection of $S$ across $A I$ and $J'$ be the second intersection of\n    circumcircle of $A S^{\\prime} K$ and $A X$. Prove that quadrilateral $T J'\n    I X$ is cyclic.\n}\n\n\\begin{solution}[Reim and lemmas]\n    Since $NI\\cap \\odot ABC=T$, the mixtilinear touchpoint, if we can show\n    that $AT||IJ'$, we will be done.  Instead of working with $S'$ and $J'$,\n    we reflect them back and work with $S, J$. Then we need to prove that\n    $IJ||AD'$ where $D'$ is the reflection of $D$ over $I$.\n\n    \\figdf{.7}{mixti_symmedian}{}\n\n    From \\autoref{lemma:Line parallel to BC through I} we know that the $A$\n    symmedian, $EF$, $IM$ are concurrent at a point $P$. We prove that $P\n    \\equiv J$. For that we need to show that $P$ lies on $\\odot AKS$.\\\\\n\n    If $\\odot AKP\\cap AB, AC = U, V$, it is sufficient to prove that \n    \\[\\frac{UF}{FB} = \\frac{VE}{EC}\\] \n    \n    We have:\n    \\begin{align*}\n        \\frac{UF}{KU} = \\frac{\\sin FAP}{\\sin KFA} &\\quad\\frac{VE}{KV} =\n        \\frac{\\sin EAP}{\\sin KEA}\\\\[1em]\n        \\therefore \\frac{UF}{VE} &=\\frac{\\sin FAP}{\\sin EAP} \\frac{\\sin KEA}{\\sin KFA}\n        =\\frac{\\sin CAM}{\\sin BAM}\\frac{AF}{AE}\\\\[1em]\n        &=\\frac{BA}{CA}\\frac{AF}{AE}=\\frac{BA}{AE}\\frac{AF}{CA}\n        =\\frac{BC}{EC}\\frac{CF}{BC}\\\\[1em]\n        &=\\frac{BF}{EC}\n    \\end{align*}\n\\end{solution}\n\n\\begin{minipage}{.55\\linewidth}\n    \\prob{https://artofproblemsolving.com/community/c6t45786f6h1618685}{Vietnamese\n        TST 2018 P6.a}{M}{\n        Triangle $ABC$ circumscribed $(O)$ has $A$-excircle\n        $(I_a)$ that touches $AB,\\ BC,\\ AC$ at $F,\\ D,\\ E$, resp. $M$ is the\n        midpoint of $BC$. Circle with diameter $MI_a$ cuts $DE,\\ DF$ at $K,\\ H$.\n        Prove that $(BDK),\\ (CDH)$ have an intersecting point on $(I_a)$.\n    }\n\n    \\vspace{2em}\n\n    \\prob{}\n    {After Inverting Around D}{}{\n        $MD$ is a line, $ I_a $ is an arbitrary point such that $ DI_a\\perp\n        MD$. $l$ is the perpendicular bisector of $ DI_a $. $ F, E $ are\n        arbitrary points on $ l $. $ B=I_aF\\cap MD, C=I_aE\\cap MD\\, H=FD\\cap\n        MI_a, K=DE\\cap MI_a $. Then $ BK, CH, l $ are concurrent.\n    }\n\n    \\begin{solution}\n        It is straightforward using Puppus's Theorem on lines $ BDC $\n        and $ HI_aK $.\n    \\end{solution}\n\\end{minipage}\\hfill%\n\\begin{minipage}{.4\\linewidth}\n    \\figdf{}{Vietnamese_TST_2018_P6_a_problem}{} \n    \\figdf{}{Vietnamese_TST_2018_P6_a_inv}{After inverting around $ D $}\n\\end{minipage}\n\n\n\n\\begin{solution}[Synthetic: Length Chase] \n    \\sollem{\n        Let $ G, H, B', C' $ be\n        defined the same way in Lemma 3.2. Prove that $ F $ lies on the radical\n        axis of $ \\odot D'GI, D'C'H $. By extension prove that $ B $ lies on the\n        radical axis of $ \\odot D'B'I, D'C'H $\n    }\\label{problem:vietTST2018P6.a}\n\n    \\figdf{.7}{Vietnamese_TST_2018_P6_a_modified}{\\hrf{problem:vietTST2018P6.a}{Vietnamese\n    TST 2018 P6.a}}\n\n    We prove the first part, and the second part follows using spiral\n    similarity.\n\n    Suppose $ K\\in FD\\cap \\odot KDI $. Due to spiral similarity on $ \\odot\n    KDI, \\odot (I) $, we have $ \\triangle GFK \\sim \\triangle GD'I $. Which\n    implies: \\[\\frac{FK}{GF}=\\frac{ID}{GD'} \\implies FK = ID\\frac{GF}{GD'}\\]\n    Now, if $ KDCE $ is to be cyclic, we need to have $ \\triangle HFK \\sim\n    \\triangle HDC $. So we need, \n\n    \\[\\frac{FK}{HF}=\\frac{DC}{HD}\\implies FK=DC\\frac{HF}{HD}\\] \n    Combining two equations: \n    \\[\\frac{GF}{GD'}\\cdot \\frac{ID}{DC}=\\frac{HF}{HD}\\]\n\n    Now, using Ptolemy's theorem in $ \\square FDEH $, we have, \n\n    \\begin{align*}\n        FD\\cdot EH + DE\\cdot FH &= DH\\cdot EF\\\\ \n        EH \\cdot \\frac{FD}{FH} + DE &= EF \\cdot\\frac{DH}{FH}\\\\ \n        2\\ \\frac{DE}{EF} &= \\frac{DH}{FH} \n    \\end{align*} \n\n    Similarly from $ \\square FGED' $ we get, \\[2\\ \\frac{D'E}{EF} =\n    \\frac{GD'}{FG}\\] Combining these two equations gives us the desired result.  \n\\end{solution}\n\n\n\\begin{minipage}{.45\\linewidth}\n    \\gene{https://artofproblemsolving.com/community/c374081h1619335}{Vietnamese\n        TST 2018 P6.a Generalization}{\n        Let $ABC$ be a triangle. The points $D,$\n        $E,$ $F$ are on the lines $BC,$ $CA,$ $AB$ respectively. The circles $(AEF),$\n        $(CFD),$ $(CDE)$ have a common point $P.$ A circle $(K)$ passes through $P,$\n        $D$ meet $DE,$ $DF$ again at $Q,$ $R$ respectively. Prove that the circles\n        $(DBQ),$ $(DCR)$ and $(DEF)$ are coaxial.\n    } \n\n    \\begin{solution}[Inversion] \n        Invert around $ D $, and use Pappu's Theorem as in\\\\\n        \\autoref{problem:Vietnamese TST 2018 P6.a}.  \n    \\end{solution} \n\\end{minipage}\\hfill%\n\\begin{minipage}{.52\\linewidth}\n    \\figdf{}{Vietnamese_TST_2018_P6_a_gene}{\\hrf{VNTST2018P6a_Gene}{Vietnamese TST\n    2018 P6.a Generalization}} \n\\end{minipage}\n\n\\rem{\n    The synthetic solution of \\autoref{problem:Vietnamese TST 2018 P6.a}\n    can't be reproduced here maybe because here we don't have $ A, P, D $\n    collinear, and we can't have harmonic quadrilaterals either.\n}\n\n\n\n\n\\theo{https://en.wikipedia.org/wiki/Poncelet's_closure_theorem}{Poncelet's\n    Porism}{\n    Poncelet's porism (sometimes referred to as Poncelet's closure\n    theorem) states that whenever a polygon is inscribed in one conic section and\n    circumscribes another one, the polygon must be part of an infinite family of\n    polygons that are all inscribed in and circumscribe the same two conics.\n}\n\n\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1181536p5720184}{IMO 2013\n    P3}{M}{\n    Let the excircle of triangle $ABC$ opposite the vertex $A$ be tangent\n    to the side $BC$ at the point $A_1$. Define the points $B_1$ on $CA$ and $C_1$\n    on $AB$ analogously, using the excircles opposite $B$ and $C$, respectively.\n    Suppose that the circumcentre of triangle $A_1B_1C_1$ lies on the circumcircle\n    of triangle $ABC$. Prove that triangle $ABC$ is right-angled.\n}\n\n\\solu{\n    Straightforward use of \\autoref{lemma:excenter_touchpoint_bigarc-midpoints}\n}\n\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c74453h1225408_some_geometric_problems}{buratinogigle's\n    proposed probs for Arab Saudi team 2015}{E}{\n    Let $ABC$ be acute triangle with\n    $AB < AC$ inscribed circle $(O)$. Bisector of $\\angle BAC$ cuts $(O)$ again at\n    $D$. $E$ is reflection of $B$ through $AD$. $DE$ cuts $BC$ at $F$. Let $(K)$\n    be circumcircle of triangle $BEF$. $BD, EA$ cut $(K)$ again at $M, N$, reps.\n    Prove that $\\angle BMN = \\angle KFM$.\t\n}\n\n\\fig{.5}{SATST2015proposed_by_bura/derakynay1134-8}{}\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h54506p340041}{USAMO 1999\n    P6}{E}{\n    Let $ABCD$ be an isosceles trapezoid with $AB \\parallel CD$. The\n    inscribed circle $\\omega$ of triangle $BCD$ meets $CD$ at $E$. Let $F$ be a\n    point on the (internal) angle bisector of $\\angle DAC$ such that $EF \\perp\n    CD$. Let the circumscribed circle of triangle $ACF$ meet line $CD$ at $C$ and\n    $G$. Prove that the triangle $AFG$ is isosceles.\n}\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1619730p10134424}{Serbia\n    2018 P1}{E}{\n    Let $\\triangle ABC$ be a triangle with incenter $I$. Points $P$\n    and $Q$ are chosen on segments $BI$ and $CI$ such that $2\\angle  PAQ=\\angle\n    BAC$. If $D$ is the touch point of incircle and side $BC$ prove that $\\angle\n    PDQ=90$.\n}\n\n\\solu{Straightforward Trig application.}\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1628676p10217476}{Iran TST\n    T2P5}{E}{\n    Let $\\omega$ be the circumcircle of isosceles triangle $ABC$\n    ($AB=AC$). Points $P$ and $Q$ lie on $\\omega$ and $BC$ respectively such that\n    $AP=AQ$ .$AP$ and $BC$ intersect at $R$. Prove that the tangents from $B$ and\n    $C$ to the incircle of $\\triangle AQR$ (different from $BC$) are concurrent on\n    $\\omega$.\n}\n\n\n\n\n\\prob{}{}{M}{\n    Let a point $ P $ inside of $ \\triangle ABC $ be such that the\n    following condition is satisfied \\[\\frac{AP+BP}{AB} = \\frac{BP+CP}{BC} =\n    \\frac{CP+AP}{CA}\\]\tLines $ AP, BP, CP $ intesect the circumcirle again at $\n    A', B', C' $. Prove that $ ABC $ and $ A', B', C' $ have the same incircle.\n}\n\n\\solu{\n    After finiding the point $ P $, we get a lot of ideas.\n    \\figdf{.8}{itti_same_incircle}{two lines are parallel}\t\n}\n\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1623012p10163453}{Iran TST\n    2018 P3}{EM}{\n    In triangle $ABC$ let $M$ be the midpoint of $BC$. Let $\\omega$\n    be a circle inside of $ABC$ and is tangent to $AB,AC$ at $E,F$, respectively.\n    The tangents from $M$ to $\\omega$ meet $\\omega$ at $P,Q$ such that $P$ and $B$\n    lie on the same side of $AM$. Let $X \\equiv PM \\cap BF $ and $Y \\equiv QM \\cap\n    CE $. If $2PM=BC$ prove that $XY$ is tangent to $\\omega$.\n}\n\n\\solu{Work backwards}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1623417p10167655}{Iran TST\n    2018 P4}{E}{\n    Let $ABC$ be a triangle ($\\angle A\\neq 90^\\circ$). $BE,CF$ are the\n    altitudes of the triangle. The bisector of $\\angle A$ intersects $EF,BC$ at\n    $M,N$. Let $P$ be a point such that $MP\\perp EF$ and $NP\\perp BC$. Prove that\n    $AP$ passes through the midpoint of $BC$.\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1662902p10561154}{APMO 2018\n    P1}{E}{\n    Let $H$ be the orthocenter of the triangle $ABC$. Let $M$ and $N$ be\n    the midpoints of the sides $AB$ and $AC$, respectively. Assume that $H$ lies\n    inside the quadrilateral $BMNC$ and that the circumcircles of triangles $BMH$\n    and $CNH$ are tangent to each other. The line through $H$ parallel to $BC$\n    intersects the circumcircles of the triangles $BMH$ and $CNH$ in the points\n    $K$ and $L$, respectively. Let $F$ be the intersection point of $MK$ and $NL$\n    and let $J$ be the incenter of triangle $MHN$. Prove that $F J = F A$.\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h155710p875026}{ISL 2006\n    G6}{E}{\n    Circles $ w_{1}$ and $ w_{2}$ with centres $ O_{1}$ and $ O_{2}$ are\n    externally tangent at point $ D$ and internally tangent to a circle $ w$ at\n    points $ E$ and $ F$ respectively. Line $ t$ is the common tangent of $ w_{1}$\n    and $ w_{2}$ at $ D$. Let $ AB$ be the diameter of $ w$ perpendicular to $ t$,\n    so that $ A, E, O_{1}$ are on the same side of $ t$. Prove that lines $\n    AO_{1}$, $ BO_{2}$, $ EF$ and $ t$ are concurrent.\n}\n\n\\solu{\\hrf{lemma:concurrent_lines_in_incenter}{This}}\n\n\n\n\n\\lem{Tangential Quadrilateral Incenters}{\n    Let $ ABCD $ be a tangential\n    quatrilateral. Let $ I_1, I_2 $ be the incenters of $ \\triangle ABD, \\triangle\n    BCD $. Then $ (I_1), (I_2) $ is tangent to $ BD $ at the same point.\n    \\fig{.5}{tangential_quad_incenters}{}\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h21758p140322}{Four\n    Incenters in a Tangential Quadrilateral}{E}{\n    Let $ABCD$ be a quadrilateral.\n    Denote by $X$ the point of intersection of the lines $AC$ and $BD$. Let\n    $I_{1}$, $I_{2}$, $I_{3}$, $I_{4}$ be the centers of the incircles of the\n    triangles $XAB$, $XBC$, $XCD$, $XDA$, respectively. Prove that the\n    quadrilateral $I_{1}I_{2}I_{3}I_{4}$ has a circumscribed circle if and only if\n    the quadrilateral $ABCD$ has an inscribed circle.\n}\n\n\\solu{\n    There is a lot going on in this figure, firstly, the $ J_1, J_2 $ and $\n    M $, then $ K $, then $ \\angle I_4ME = \\angle I_3ME $. Connecting them\n    with the \\hyperref[Incircle Touchpoint and Cevian]{lemma}.\n\n    \\figdf{1}{tangential_quad_four_incenters}{}\n}\t\n\n\n\n\\prob{}{Geodip}{E}{\n    Let $ G $ be the centeroid. Dilate $ \\odot I $ from $ G $\n    with constant $ -2 $ to get $ I'$. Then $ I' $ is tangent to the circumcircle.\n    \\figdf{.5}{nice_prob_by_geodip}{} \n}\n\n\n\n\\theo{http://mathworld.wolfram.com/FuhrmannCircle.html}{Fuhrmann Circle}{\n    Let $ X', Y', Z' $ be the midpoints of the arcs not containing $ A, B, C $ of $\n    \\odot ABC $. Let $ X, Y, Z $ be the reflections of these points on the\n    sides. Then $ \\odot XYZ $ is called the \\textbf{Fuhrmann Circle}. The\n    orthocenter $ H $ and the nagel point $N$ lies on this circle, and $ HN $\n    is a diameter of this circle.\n\n    Furthermore, $ AH, BH, CH $ cut the circle for the second time at a\n    distance $ 2r $ from the vertices.\n\n    \\figdf{1}{fuhrmann_circle}{Fuhrmann Circle}\n}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h213443p1178421}{Iran TST\n    2008 P12}{E}{\n    In the acute-angled triangle $ ABC$, $ D$ is the intersection of\n    the altitude passing through $ A$ with $ BC$ and $ I_a$ is the excenter of the\n    triangle with respect to $ A$. $ K$ is a point on the extension of $ AB$ from\n    $ B$, for which $ \\angle AKI_a=90^\\circ+\\frac 34\\angle C$. $ I_aK$ intersects\n    the extension of $ AD$ at $ L$. Prove that $ DI_a$ bisects the angle $ \\angle\n    AI_aB$ iff $ AL=2R$. ($ R$ is the circumradius of $ ABC$)\n}\n\n\\solu{}\n\n\\lem{Polars in Incircle}{\n    In the acute angled triangle $ABC$, $I$ is the incenter and $DEF$ is the\n    touch triangle. Let $EF$ meet $\\odot ABC$ at $P, Q$ such that $E$ lies \n    inside $F, Q$. If $QD$ meets $\\odot ABC$ for the second time at $U$, prove\n    that $AU$ is the polar line of $P$ wrt $\\left(I\\right)$.\n} \n\n\\proof{[Projective]\n    We have:\n    \\begin{align*}\n        \\left(B, C; D, EF\\cap BC\\right) &= Q\\left(B, C; P, U\\right) \\\\\n                                        &= A(E, F; P, U)\\\\\n                                        &= -1\n    \\end{align*}\n\n    Which means $\\left(P, AU\\cap EF; E, F\\right)$ is harmonic.\n    \\figdf{.5}{ISL2019G6_lem}{}\n}\n\n\\prob{}{ISL 2019 G6}{HM}{\n    In the acute angled triangle $ABC$, $I$ is the incenter and $DEF$ is the\n    touch triangle. Let $EF$ meet $\\odot ABC$ at $P, Q$ such that $E$ lies\n    inside $F, Q$. Prove that \\[\\angle APD + \\angle AQD = \\angle PIQ\\]\n}\n\n\\begin{solution}\n    Since $PI \\cap AU$ at $X$ from \\autoref{lemma:Polars in Incircle}, we have\n    $AFPX$ is cyclic. And so\n    \\[\\angle FAX = \\angle FIX\\] \n    \\figdf{.5}{ISL2019G6}{}\n    After some more angle chasing, we reach our goal.\n\\end{solution}\n\n\n\n\\newpage\n\\subsection{Feurbach Point}\n\n\\den{Feurbach Point}{\n    The point where the nine point circle touches the incircle is called the\n    \\emph{Feurbach Point}.\n}\n\n\\thmbox{}\n{It Exists!}{\n    The nine point circle touches the incircle and the excircles.\n}\n\n\\begin{prooof}[Inversion]\n    Let $D, D'$ be the incircle and the $A$-excircle touchpoints with $BC$.\n    Let $M, N, P$ be the midpoints of $BC, CA, AB$ resp. Also let $B'C'$ be\n    the reflection of $BC$ on $AI$. Now let $N', P'$ be the intersection\n    points of $MN, MP$ with $B'C'$. \\\\\n\n    We invert around $M$ with radius $MD = \\frac{b-c}{2}$. We prove that the\n    image of $\\odot MNP$ after the inversion is $B'C'$. And since $(I)$ and\n    $(I_a)$ are orthogonal to $(M)$, we will be done. \n    \\figdf{.8}{feurbach_inversion}{}\n    Wlog, assume that $b \\ge c$.\n    \\[\\begin{aligned}\n        B'N &= AB' - AN = c - \\frac{b}{2} &\\quad NN' &= B'N \\cdot\\frac{AC'}{AB'}\\\\[.5em]\n        MN' &= MN - NN' &\\quad &= \\frac{2c-b}{2}\\cdot \\frac{b}{2}\\\\[1em]\n        MN'\\cdot MN &= \\frac{c}{2}\\left(\\frac{c}{2} -\n        \\frac{b}{c}\\cdot\\frac{2c-b}{2}\\right) &= \\frac{b-c}{2}^2\n    \\end{aligned}\\]\n    Which concludes the proof.\n\\end{prooof}\n\n\\thmbox{}\n{Construction of Feurbach Point}{\n    Let $D$ be the incenter touch point with $BC$. Let $M, L$ be the midpoints\n    of $BC$ and $AI$. Let $D_1, D'$ be the reflections of $D$ over $I$ and\n    $M$. Let $K, P$ be the refecltions of $D_1, D$ over $L$ and $AI$. Let $Q$\n    be the intersection of $AD_1$ with the incircle.\\\\\n\n    Then $D_1K$ and $MP$ meet at $F$ on the incircle, which is the Feurbach\n    Point of $\\triangle ABC$. \n}\n\n\\figdf{.7}{feurbach_construction}{}\n\n\\begin{prooof}\n    It is easy to see that the tangents at $P$ and $M$ to the incircle and the\n    nine point circle are parallel. So if we let $F = MP\\cap \\left(I\\right)$,\n    then we have $F$ is the Feurbach point. \\\\\n\n    And since $MQ$ is tangent to $(I)$, we also have $\\left(F, P; D,\n    Q\\right)=-1$. But notice that\n    \\[\\begin{aligned}\n        D_1(A, I; L, P) &= D_1(K, P; Q, I)\\\\\n                        &=-1\n    \\end{aligned}\\]\n    So $D_1K$ passes through $F$.\n\\end{prooof}\n\n\n\n\\newpage\n\\subsection{Assorted Diagrams}\n\n\\figdf{.7}{circles_with_arc_midpoints}{The smaller circles touches the side\nand the circumcircle}\n\n", "meta": {"hexsha": "5d8ccdd4ee2613f2676b0e4fb6bbc71d10b58e9c", "size": 23759, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geo/sec3_in-ex-circle.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "geo/sec3_in-ex-circle.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geo/sec3_in-ex-circle.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 36.6086286595, "max_line_length": 103, "alphanum_fraction": 0.6279725578, "num_tokens": 8015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.412020074760097}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[english]{babel}\n\\usepackage[left=3.5cm,top=2cm,right=3.5cm,bottom=2cm]{geometry}\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{amsopn}\n\\usepackage{amsthm}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{cleveref}\n\\usepackage{fancyvrb}\n\\usepackage{tikz}\n\\usepackage[justification=centering]{caption}\n% \\patchcmd{\\thebibliography}{\\chapter*}{\\section*}{}{}\n\\usepackage[super]{nth}\n\\usepackage{textcomp}\n\\usepackage{enumitem}\n\\usepackage{doi}\n\\usepackage{mathrsfs}\n\\usepackage{siunitx}\n\\setlist{nosep}\n% \\usepackage[justification=justified,singlelinecheck=false]{caption}\n\\usepackage{subcaption}\n\n\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{prop}[thm]{Property}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{cor}{Corollary}[thm]\n\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n% \\newtheorem{axi}{Axiom}[chapter]\n\\newtheorem{eqn}[thm]{Equation}\n\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\n\n\\setcounter{secnumdepth}{3}\n\\setcounter{tocdepth}{1}\n% \\renewcommand\\thesection{\\arabic{section}}\n\n\\newcommand{\\R}{\\ensuremath{\\mathbb{R}}}\n\\newcommand{\\Rb}{\\ensuremath{\\overline{\\mathbb{R}}}}\n\\newcommand{\\N}{\\ensuremath{\\mathbb{N}}}\n\\newcommand{\\Q}{\\ensuremath{\\mathbb{Q}}}\n\\newcommand{\\Z}{\\ensuremath{\\mathbb{Z}}}\n\\newcommand{\\C}{\\ensuremath{\\mathbb{C}}}\n\\newcommand{\\U}{\\ensuremath{\\mathbb{U}}}\n\\newcommand{\\F}{\\ensuremath{\\mathbb{F}}}\n\\newcommand{\\K}{\\ensuremath{\\mathbb{K}}}\n\\newcommand{\\TODO}{\\textbf{TODO}}\n\n\n\\newcommand\\eqdef{\\stackrel{\\mathclap{\\mbox{\\tiny def}}}{=}}\n\n\n\\sisetup{inter-unit-product=\\ensuremath{{}\\cdot{}}}\n\n\\newcommand{\\ket}[1]{|#1\\rangle}\n\\newcommand{\\bra}[1]{\\langle#1|}\n\\newcommand{\\braket}[2]{\\langle#1|#2\\rangle}\n\n\\newcommand{\\dd}{\\mathrm{d}}\n\\newcommand{\\der}[2]{\\frac{\\dd{#1}}{\\dd{#2}}}\n\\newcommand{\\dern}[3]{\\frac{\\dd^{#3} #1}{\\dd{#2}^{#3}}}\n\\newcommand{\\dpar}[2]{\\frac{\\partial{#1}}{\\partial{#2}}}\n\\newcommand{\\dparn}[3]{\\frac{\\partial^{#3} {#1}}{\\partial{#2}^{#3}}}\n\n\\renewcommand{\\geq}{\\geqslant}\n\\renewcommand{\\leq}{\\leqslant}\n\n\\newcommand{\\mat}[1]{\\begin{pmatrix}#1\\end{pmatrix}}\n\\newcommand{\\bs}{\\boldsymbol}\n\n\\DeclareMathOperator{\\cov}{cov}\n\\DeclareMathOperator{\\Tr}{Tr}\n\\DeclareMathOperator{\\argmax}{arg\\,max}\n\\DeclareMathOperator{\\argmin}{arg\\,min}\n\\DeclareMathOperator{\\rk}{rk}\n\\DeclareMathOperator{\\Span}{Span}\n\\DeclareMathOperator{\\dom}{dom}\n\n\n\\newcommand{\\class}[1]{{\\mathscr{C}^{#1}}}\n\n\\newcommand{\\trnorm}[1]{\\frac{#1}{\\Tr\\left({#1}\\right)}}\n\\newcommand{\\pr}{_{||}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\ml}{_{M\\!L}}\n\n\n\\newcommand{\\maxim}[3]{\\begin{cases}\n    \\mathbf{maximize}\\,\\quad #1& \\mathbf{on}\\; #2\\\\\n    \\mathbf{subject\\;to}\\quad #3\n  \\end{cases}}\n\\newcommand{\\maximf}[2]{\\begin{cases}\n    \\mathbf{maximize}\\,\\quad #1& \\mathbf{on}\\; #2\n  \\end{cases}}\n\\newcommand{\\maxima}[3]{\\begin{cases}\n    \\mathbf{maximize}\\,\\quad #1& \\mathbf{on}\\; #2\\\\\n    \\mathbf{subject\\;to}\\quad \\begin{aligned}[t]#3\\end{aligned}\n  \\end{cases}}\n\n\\newcommand{\\minim}[3]{\\begin{cases}\n    \\mathbf{minimize}\\;\\,\\quad #1& \\mathbf{on}\\; #2\\\\\n    \\mathbf{subject\\;to}\\quad #3\n  \\end{cases}}\n\\newcommand{\\minimf}[2]{\\begin{cases}\n    \\mathbf{minimize}\\,\\quad #1& \\mathbf{on}\\; #2\n  \\end{cases}}\n\\newcommand{\\minima}[3]{\\begin{cases}\n    \\mathbf{minimize}\\;\\,\\quad #1& \\mathbf{on}\\; #2\\\\\n    \\mathbf{subject\\;to}\\quad \\begin{aligned}[t]#3\\end{aligned}\n  \\end{cases}}\n\n\\newcommand{\\gap}{\\hspace{0.5cm}}\n\\newcommand{\\twoline}{\\vphantom{\\frac\\int\\int}}\n\n\\graphicspath{{../img/}}\n\n\\title{Error estimation in maximum-likelihood reconstruction for quantum state tomography}\n\\author{Thibaut Pérami, Igor Dotsenko, Pierre Rouchon}\n\n\\makeatletter\n\\hypersetup{\n  pdftitle = {\\@title},\n  pdfauthor = {\\@author},\n  pdfsubject = {Quantum state tomography}\n}\n\\makeatother\n\n\\begin{document}\n\n\\maketitle\n\n\\newcommand{\\fset}{\\ensuremath{\\mathop{\\text{\\textquotesingle}}}}\n\n\n\n\n\\section*{Abstract}\n\nThe maximum likelihood estimator is often used in to reconstruct state in the\ncontext of quantum state tomography. The formulas used by physicist are based on\nasymptotic development of multi-dimensional Laplace integrals. The results\nobtained in previous work allow to provably retrieve the value and first-order\nerror estimation of the evaluation of any quantum observable on the\nreconstructed quantum state. Those results hold even when on the boundaries of\nthe integration domain. However in the context of Quantum Thermodynamics,\nphysicists need to evaluate non linear function of the quantum observable. In\nparticular Von-Neumann entropy whose first order derivative goes to infinity on\nthe edge of the domains. In this paper we prove again expansion of those\nintegral with minimal hypothesis. We also prove variation of such expansion that\nare applicable to the Von-Neuman Entropy. In addition we have some informal proposition\nabout how to handle the case where the information obtained on the quantum state\nis incomplete.\n\n\n\\section{Introduction}\n\n\\TODO\n\n\\subsection{Previous Work}\n\nPrevious results.\n\n\\subsection{Goal}\n\n\\section{Generic Laplace expansion of integrals}\n\nIn this section we generalize the problem to generic expansion in $\\R^n$. Doing\nit in $\\R^n$ is sufficient for it to be usable in any differential variety like\n$\\mathcal{D}$. Thanks to a trick we'll see in \\cref{sec:app} (from \\cite{SPRAL17}), we only need to\ncare about boundaries of dimension one less that the main dimension. The\ngeneralized integral we study is:\n\n\\[\\int_{z \\in U} g(z)e^{N\\!f(z)} \\dd z\\]\n\nwhere $f$ is concave and when $N$ goes to infinity. Intuitively, the result\nexpansion will use only value around the maximum of $f$\nWe do not prove all the possible case of this expansion, but only the ones that\nare useful in the quantum setting.\n\n\\subsection{In the interior}\n\nWe start by abstracting $f$ even mode with $f(z) = - \\frac {\\|z\\|^2}2$ and start\nthe asymptotic expansion. $U$ always represent an open set of $\\R^n$.\n\n\\begin{thm}\\label{thm:asy1}\n  Let $g : U \\to \\R$ be a function of class $\\class 1$ on $U$ a neighborhood of 0. If $g(0)\n  \\neq 0$, we have, as $N \\to \\infty$:\n  \\[\\int_{z \\in U} g(z)e^{-\\frac N2\\|z\\|^2} \\dd z = g(0){\\left(\\frac\n        {2\\pi}{N}\\right)}^{\\frac n 2} +\n    O\\left({N^{-\\frac n 2 -1}}\\right)\\]\n\\end{thm}\n\n\\begin{proof}\n  We can decompose $g$ in $g(z) = g(0) + h(z)$ with $h(z) = O(\\|z\\|)$ as $g$ is\n  $\\class{1}$ in 0, thus:\n  \\[\\int_{z \\in U} g(z)e^{-\\frac N2\\|z\\|^2} \\dd z = g(0)\\int_{z \\in U} e^{-\\frac\n      N2\\|z\\|^2} \\dd z + \\int_{z \\in U} h(z)e^{-\\frac N2\\|z\\|^2} \\dd z.\\]\n  Furthermore,\n  \\begin{align*}\n    \\left |\\int_{z \\in U} h(z)e^{-\\frac N2\\|z\\|^2} \\dd z\\right|\n    &\\leq C \\int_{z \\in U} \\|z\\|e^{-\\frac N2\\|z\\|^2} \\dd z\\\\\n    &\\leq C \\int_{z \\in \\R^n} \\|z\\|e^{-\\frac N2\\|z\\|^2} \\dd z\\\\\n    &\\leq CA_n \\int_{r \\in \\R_+} r^{n+1}e^{-\\frac N2 r^2} \\dd r\\\\\n    &\\leq CA_n \\int_{r \\in \\R_+} r^{n+1}e^{-\\frac N2 r^2} \\dd r\\\\\n    &\\leq CA_n \\int_{r \\in \\R_+} r^{n+1}e^{-\\frac N2 r^2} \\dd r\\\\\n    &\\leq CA_n \\left ( \\frac2N\\right)^{\\frac n2+1}\\int_{s \\in \\R_+} s^{n+1}e^{-s^2} \\dd s\n    & {\\textstyle\\left (s = \\sqrt{\\frac N2} r\\right)} \\\\\n    &\\leq O\\left({N^{-\\frac n 2 -1}}\\right)\n  \\end{align*}\n\n  where $C$ is the constant such that $|h(z)| \\leq C \\|z\\|$, $A_n$ is the surface\n  of the hypersphere of $\\R^n$.\n\n  Additionally, up to exponentially small terms ($O(e^{N\\delta})$ for a given $\\delta$), we have:\n  \\[g(0)\\int_{z \\in U} e^{-\\frac\n      N2\\|z\\|^2} \\dd z \\approx g(0)\\int_{z \\in \\R^n} e^{-\\frac\n      N2\\|z\\|^2} \\dd z = g(0) {\\left(\\frac\n        {2\\pi}{N}\\right)}^{\\frac n 2}\\]\n\n  By adding both equations, we get the theorem.\n\\end{proof}\n\n\\\n\n\nHowever when $g(0) = 0$, the previous theorem does not give anymore the first\norder term but just a bound on the integral which may not be very useful in\ncertain cases. We'll thus look in more details at the case $g(0) = 0$. We'll\nassume additionally that $\\nabla g = 0$, because that is what happens for our\ncases that require that theorem.\n\n\n\\begin{thm}\\label{thm:asy2}\n  Let $g : U \\to \\R$ be a function of class $\\class 3$ on $U$ a neighborhood of 0. If $g(0) = 0$\n  and $\\nabla g(0) = 0$, we have, as $N \\to \\infty$:\n  \\[\\int_{z \\in U} g(z)e^{-\\frac N2\\|z\\|^2} \\dd z = \\frac{\\Tr(\\nabla^2 g(0))}{2N} {\\left(\\frac\n        {2\\pi}{N}\\right)}^{\\frac n 2} +\n    O\\left({N^{-\\frac n 2 -2}}\\right).\\]\n\\end{thm}\n\n\\begin{proof}\n  $g$ can be written $g(z) = \\frac12\\bra z \\nabla^2 g(0) \\ket z + O(\\|z\\|^3)$ because it\n  is $\\class 3$. The integral on the $O(\\|z\\|^3)$ part gives $O\\left({N^{-\\frac\n        n 2 -2}}\\right)$ with exactly the same method as in\n  the precedent proof (replace $\\|z\\|$ by $\\|z\\|^3$ and $r^{n+1}$ by $r^{n+3}$.\n\n  We can then use prove a little lemma to get the result:\n\n  \\begin{lem}\\label{lem:gausssymtr}\n    Let $S$ be an real symmetric matrix of dimension $n$, we have:\n    \\[\\int_{z \\in \\R^n} \\bra z S \\ket z e^{-\\frac N 2 \\|z\\|^2} \\dd z =\n      \\frac{\\Tr(S)}N {\\left(\\frac\n          {2\\pi}{N}\\right)}^{\\frac n 2} \\]\n  \\end{lem}\n  \\begin{proof}[Lemma proof] If we take the spectral decomposition of $S$ and split the\n    coordinate along $S$ eigenvectors, the result comes after some calculus.\n  \\end{proof}\n\n  The application of the lemma with $S = \\nabla^2 g(0)$ and the previous\n  asymptotic bound added give the theorem.\n\\end{proof}\n\n\\\n\nIt is now time to replace the $-\\|z\\|^2$ by a generic concave function and to do\nthe actual change of variables.\n\n\\begin{thm}\\label{thm:asymid}\n  Let $U$ be an open set containing $0$. Let $f : U \\to \\R$ be a $\\class 4$ function.\n  Let $g : U \\to \\R$ be a $\\class 1$ function.\n  Assume that $f$ has a unique global non critical maximum in $0$\n  ($\\nabla f = 0$ and $\\nabla^2 f < 0$). We have at $N \\to \\infty$:\n  \\[\\int_{z \\in U} g(z)e^{Nf(z)} \\dd z = g(0)\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    \\frac {e^{Nf(0)}}{\\sqrt{\\left|\\det \\nabla^2 f(0)\\right|}}\n    + O(e^{Nf(0)} N^{-\\frac n 2 -1})\\]\n\n  Additionally, If $g(0) = 0$ and $\\nabla g(0) = 0$, and $f \\in \\class 6$ and $g\n  \\in \\class 3$, we have:\n\n  \\[\\int_{z \\in U} g(z)e^{N f(z)} \\dd z =\n    \\frac{\\Tr\\left(-\\nabla^2 g(0) {\\left(\\nabla^2 f(0)\\right)}^{-1}\\right)}{2N}\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    \\frac {e^{Nf(0)}}{\\sqrt{\\left|\\det \\nabla^2 f(0)\\right|}}\n    + O\\left(e^{Nf(0)}{N^{-\\frac n 2 -2}}\\right)\\]\n\\end{thm}\n\n\\begin{proof}\n  First we assume $f(0) = 0$ without loss of generality (it suffice to divide\n  everything by $e^{Nf(0)}$). The Morse lemma (\\ref{lem:morse}) tells us that\n  there is a  neighborhood $V$ of 0 and\n  a diffeomorphism $\\psi : V \\to V'$ with $\\psi(0) = 0$ such that\n  \\[f(z) = - \\frac12 \\|\\psi(z)\\|^2 \\gap \\text{and}\\gap \\nabla \\psi(0) =\n    \\sqrt{-\\nabla^2 f}.\\]\n\n  Because the hessian of $f$ is negative definite in 0 and the maximum is unique,\n  all values of $f$ outside of $V$ are below a\n  constant $-\\delta$. So all the part of the integral outside of $V$ are\n  $O(e^{-N\\delta})$ and thus negligible. We can now study the integral only on\n  $V$. We can then make a change of variable on $\\psi$:\n\n  \\[\\int_{z \\in V} g(z)e^{Nf(z)} = \\int_{z \\in V'}\n    g(\\psi^{-1}(z))e^{-\\frac N2\\|z\\|^2} J(z) \\dd z\\]\n\n  with $J(z) = |\\det{\\nabla \\psi^{-1}}|$. We can then set $g_0(z) =\n  g(\\psi^{-1}(z))J(z)$, and look at the two cases:\n  \\begin{itemize}\n  \\item As $f \\in \\class 4$, we have $\\psi \\in \\class 2$ (and thus also\n    $\\psi^{-1}$) and finally $J \\in \\class 1$, but $g$ is also in $\\class 1$, so\n    $g_0$ is in $\\class 1$. We can then apply \\cref{thm:asy1} and get the result\n    we want with:\n    \\[g_0(0) = g(\\psi^{-1}(0))J(0) = g(0)\\frac 1 {\\det {\\nabla \\psi(0)}} =\n      \\frac {g(0)}{\\sqrt{\\left|\\det \\nabla^2 f\\right|}}\n    \\]\n\n\n  \\item As $f \\in \\class 6$, we have $\\psi \\in \\class 4$ (and thus also\n    $\\psi^{-1}$) and finally $J \\in \\class 3$, but $g$ is also in $\\class 3$, so\n    $g_0$ is in $\\class 3$. We can then apply \\cref{thm:asy2} and get the result\n    we want with:\n    \\[\\nabla g_0^t = \\nabla g^t \\nabla \\psi\\inv \\times J + g \\circ \\psi\\inv\n      \\times \\nabla J\\]\n    but as $g(0) = 0$, we have $g(\\psi^{-1}(0)) = 0$ and furthermore $\\nabla\n    g(0) = 0$ so $\\nabla (g \\circ \\psi^{-1})(0) = 0$. Finally, the only remaining term is:\n    \\begin{align*}\n      \\nabla^2 g_0(0))\n      &= \\nabla^2 (g \\circ \\psi\\inv) \\times J(0)\\\\\n      &= {(\\nabla \\psi^{-1}(0))}^t\\nabla^2 g(0) {(\\nabla \\psi^{-1}(0))} \\times\n        \\frac {1}{\\sqrt{\\left|\\det \\nabla^2 f\\right|}}\n    \\end{align*}\n    If we put that to the trace, we get the result we wanted.\n  \\end{itemize}\n\\end{proof}\n\n\n\\subsection{On the boundaries}\n\nAs said earlier we can content ourselves with working on an hyperplane boundary.\nSo we'll take $U$ as subset of $\\R_+ \\times \\R^n$ and work from there.\n\n\\begin{rem}\n  All theorems work with $n = 0$ i.e on $\\R_+$ alone. It suffice to note that the\n  Lebesgue measure of the point in dimension 0 is 1 and all the proofs will work directly.\n\\end{rem}\n\n\\begin{thm}\\label{thm:asyp1}\n  Let U be an open bounded set of $\\R_+ \\times \\R^n$ where $(0,0) \\in U$. The $\\R_+$\n  coordinate will be $x$ and the $\\R^n$ coordinate will be $z$. Let $g : U \\to\n  \\R$ be a $\\class 1$ function. The derivatives against the edge i.e on $x$ when\n  $x=0$ are\n  taken as one-sided derivatives. We have as $N \\to \\infty$:\n\n  \\[\\int_{(x,z) \\in U} x^m g(x,z)e^{-N(x + \\frac 12 \\|z\\|^2)} \\,\\dd x\\, \\dd z =\n    g(0,0)\\,m! {(2\\pi)}^{\\frac n 2} N^{-\\frac n 2 - m - 1} + O(N^{-\\frac n 2 - m - 2})\\]\n\\end{thm}\n\n\\begin{proof} We can restrict ourselves to a\n  rectangular set $U' = [0,\\eta) \\times U_z \\subset U$ with the usual argument:\n  the value inside\n  the integral on $U \\setminus U'$ is $O(e^{-N\\delta}$ and $U$ is\n  bounded so the integral on $U \\setminus U'$ is exponentially negligible. We\n  further restrict $U'$ such that $g$ and $g'$ are bounded on $U'$ (by taking the\n  interior of a compact neighborhood included in $U$).\n\n  Here we decompose $g$ in $g(x,z) = h(z) + x g_1(x,z)$ with $h(z) = g(0,z)$ (\\cref{lem:dec}). As\n  $g_1$ is bounded on $U'$, we have:\n  \\begin{align*}\n    \\int_{(x,z) \\in U'} x^{m+1}g_1(x,z)e^{-N(x + \\frac 12 \\|z\\|^2)} \\,\\dd x\\, \\dd z\n    &\\leq\n      \\|g_1\\|_\\infty\\int_{(x,z) \\in U'} x^{m+1}e^{-N(x + \\frac 12 \\|z\\|^2)} \\,\\dd x\\, \\dd z\\\\\n    &=O(N^{-\\frac n 2 - m - 2})\n  \\end{align*}\n  This is because we can split the integral on $x$ and $z$ and then do an\n  appropriate change of variable to get $N$ out of both resulting integrals.\n  On the other hand, thanks to \\cref{thm:asy1} and the relation between the $\\Gamma$\n  function and the factorial, we have:\n  \\begin{align*}\n    \\int_{(x,z) \\in U'} x^{m}h(z)e^{-N(x + \\frac 12 \\|z\\|^2)} \\,\\dd x\\, \\dd z\n    &= \\int_0^\\eta x^{m}e^{-Nx} \\,\\dd x \\times\n      \\int_{z \\in U_z} h(z)e^{-\\frac N2 \\|z\\|^2} \\, \\dd z\\\\\n    &= m! N^{-m-1} \\times( h(0){\\left(\\frac\n      {2\\pi}{N}\\right)}^{\\frac n 2} +\n      O\\left({N^{-\\frac n 2 -1}}\\right))\n  \\end{align*}\n\n  We get the theorem by adding both equations.\n\\end{proof}\n\n\\\n\n\\begin{thm}\\label{thm:asyp2}\n  If we add to the previous theorem the hypothesis that $g(0) = 0$, $\\nabla g(0) =\n  0$ and $g$ is $\\class 2$ and in particular $\\class 3$ on the\n  variable $z$ (i.e.\\ for any $x$, $z \\mapsto g(x,z) \\in \\class 3$), we have:\n  \\[\\int_{(x,z) \\in U} x^m g(x,z)e^{-N(x + \\frac 12 \\|z\\|^2)} \\,\\dd x\\, \\dd z\n    = \\frac{m!\\Tr\\left(\\dparn g z 2\\right)}{2N^{m+2}}\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    + O\\left({N^{-\\frac n 2 -m -3}}\\right)\\]\n\n  Where $\\dparn g z 2$ is the partial hessian on $z$.\n\\end{thm}\n\n\\begin{proof}\n  We use the same $U'$ as in last proof (same shape and boundedness on $g$, $g'$\n  and $g''$).\n  By applying \\cref{lem:dec} twice, we get\n  \\[g(x,z) = h(z) + x^2g_2(x,z)\\]\n  For that same reason as in previous proof, The integral on $x^2g_2$ is\n  $O(N^{-\\frac n2 - m - 3})$. We can then, like the previous proof, split the\n  integral on $h(z)$ and use \\cref{thm:asy2} to get the result.\n\\end{proof}\n\nLike in the previous section we now need to take care about a generic function\n$f$ in the exponential. We can't use the \\cref{thm:asymid} because it assumes a\nnull gradient for $f$ but here $\\dpar f x$ could be negative. In practice we\nonly care about the case where is indeed negative, otherwise we can adapt \\cref{thm:asymid}.\n\n\\begin{thm}\\label{thm:asypmid}\n  Let U be an open set of $\\R_+ \\times \\R^n$ where $(0,0) \\in U$. The $\\R_+$\n  coordinate will be $x$ and the $\\R^n$ coordinate will be $z$. Let $f:U \\to \\R$\n  be a function of class $\\class 4$ and $g : U \\to\n  \\R$ be a function of class $\\class 1$. The derivative against the edge i.e on $x$ are\n  taken as one-sided derivative. Assume that $f$ has a global non-critical\n  maximum in $0$ so that $\\dpar f z(0) = 0$ and $\\dparn f z 2(0) < 0$. Furthermore, we\n  assume that $\\dpar f x(0) < 0$. We have as $N \\to \\infty$:\n  \\begin{multline*}\n    \\int_{(x,z) \\in U} x^m g(x,z)e^{Nf(x)} \\,\\dd x\\, \\dd z =\\\\\n    \\frac{g(0,0)\\,m! {(2\\pi)}^{\\frac n 2}}{N^{\\frac n 2 + m + 1}} \\times\n    \\frac{e^{Nf(0,0)}}\n    {\\sqrt{\\left|\\det \\dparn f z 2\\right|} \\left(-\\dpar f x\\right)^{m+1}}\n    + O(e^{Nf(0,0)}N^{-\\frac n 2 - m - 2})\n  \\end{multline*}\n\n  Additionally, if $g(0) = 0$, $\\nabla g(0) = 0$, $g$ is $\\class 2$ and in\n  particular $g$ is $\\class 3$ on\n  variable $z$ and $f$ is $\\class 6$, We have as $N \\to \\infty$:\n  \\begin{multline*}\n    \\int_{(x,z) \\in U}\n     x^m g(x,z)e^{Nf(x)} \\,\\dd x\\, \\dd z =\\\\\n     \\frac{m!\\Tr\\left(\\dparn g z 2 \\left( \\dparn f z 2 \\right)\\inv\\right)}{2N^{m+2}}\n    \\times\n    \\frac{{\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}e^{Nf(0,0)}}\n    {\\sqrt{\\left|\\det \\dparn f z 2\\right|} \\left(-\\dpar f x\\right)^{m+1}}\n    + O\\left(e^{Nf(0,0)}{N^{-\\frac n 2 -m -3}}\\right)\n  \\end{multline*}\n\\end{thm}\n\n\\begin{proof}\n  We start by supposing $f(0,0) = 0$ by dividing everything by $e^{Nf(0,0)}$.\n\n  We now do a change a variable to bring back $f$ to be $-x -\\frac12\\|z\\|^2$ like in\n  the proof of \\cref{thm:asymid}.\n  To that change of variable we decompose $f$ in $f(x,z) = h(z) + xf_1(x,z)$\n  with $h(z) = f(0,z)$. The change of variable $\\tilde x = xf_1(x,z)$ and\n  $\\tilde z = \\psi(z)$ where $\\psi$ is the Morse lemma (\\ref{lem:morse}) decomposition of $h$ will\n  give the right result. Doing the actual variable change and computing the\n  Jacobian is left to the reader.\n  The regularity analysis is the same as in \\cref{thm:asymid}\n\n  \\TODO{} Maybe we should actually do it.\n\\end{proof}\n\n\n\n\n\\section{Application to quantum state tomography}\n\\label{sec:app}\n\n\\TODO{} $\\rho\\ml$ and $\\ell$ must be already introduced in the introduction\n\nHere we can finally apply all those asymptotic theorems to our case. I first recall the\nnotations. For $h : \\mathcal{D} \\to \\R$, we define\n\\begin{equation}\nI_h(N) = \\int_{\\rho\\in\\mathcal{D}} h(\\rho) e^{N\\ell(\\rho)} P_0(\\rho) \\dd \\rho\n\\end{equation}\nwhere $P_0$ is the prior probability distribution on density matrices.\nSo that we have its expectation\n\\begin{equation}\nE_h(N) = \\frac{I_h(N)}{I_1(N)}.\n\\end{equation}\n\nIts variance is the expectation of:\n\\begin{equation}\nh_V = {\\left(h - \\lim_{N \\to \\infty} E_h(N)\\right)}^2\n\\end{equation}\n\nWe make some technical assumptions such as:\n\\begin{itemize}\n\\item $P_0(\\rho\\ml) > 0$: If our estimator has a null-probability, the prior\n  distribution doesn't make much sense.\n\\item $P_0$ is of class $\\class 3$: This is necessary for the various asymptotic\n  developments. As $P_0$ is often the uniform distribution, this is not a strong requirement.\n\\item $\\mathcal{D} = \\mathcal{D}(\\C^d)$: We use simple $d$-dimensional density matrices.\n\\end{itemize}\n\n\\\n\nLet's start with the main technical lemma and the change of variable to use the\ntheorems of previous section:\n\n\\begin{lem}\\label{lem:asymain}\n  For any $h$ of class $\\class 1$ on $\\mathcal{D}$, we have:\n  \\[E_h(N) = h(\\rho\\ml) + O\\left(\\frac 1N\\right)\\]\n  and for any $h$  of class $\\class 2$ such that $h(\\rho\\ml) = 0$, $\\nabla\n  h(\\rho\\ml) = 0$, and such that,\n  if we name $z$ the variable on the space tangent to the boundary of\n  $\\mathcal{D}$\n  in $\\rho\\ml$, $g$ is of class $\\class 3$ in $z$, we have:\n  \\[E_h(N) = \\frac{\\displaystyle \\Tr \\left( - \\dparn h z 2 (\\rho\\ml)  \\left( \\dparn \\ell z\n        2(\\rho\\ml)\\right)\\inv\\right)}{2N} + O\\left(\\frac 1 {N^2}\\right)\\]\n\\end{lem}\n\n\\begin{proof}[Proof if $\\rho\\ml$ has full rank]\n  In this case, $\\mathcal{D}$ is a neighborhood of $\\rho\\ml$ in the hyperplane of\n  Hermitian matrices of trace 1.\n  This hyperplane is itself an euclidean real vector space isometric to $\\R^n$\n  for a given $n$. $\\ell$ is\n  smooth so it is $\\class 4$, and it has a global unique (by convexity)\n  non-critical (by strong convexity) maximum in $\\rho\\ml$. As both $h$ and $P_0$\n  are of class $\\class1$, we can just do a translation to apply\n  \\cref{thm:asymid}. We have then:\n  \\[I_h(N) = h(\\rho\\ml)P_0(\\rho\\ml)\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    \\frac {e^{N\\ell(\\rho\\ml)}}{\\sqrt{\\left|\\det \\nabla^2 f(\\rho\\ml)\\right|}}\n    + O(e^{N\\ell(\\rho\\ml)} N^{-\\frac n 2 -1})\\]\n  and\n  \\[I_1(N) = P_0(\\rho\\ml)\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    \\frac {e^{N\\ell(\\rho\\ml)}}{\\sqrt{\\left|\\det \\nabla^2 f(\\rho\\ml)\\right|}}\n    + O(e^{N\\ell(\\rho\\ml)} N^{-\\frac n 2 -1})\\]\n  Everything then simplifies in the result we wanted:\n  \\[E_h(N) = \\frac{I_h(N)}{I_1(N)} = h(\\rho\\ml) + O\\left(\\frac 1N\\right)\\]\n\n  In second case $h(\\rho\\ml) = 0$, $z$ just span the full space and so represent\n  the same variable as $\\rho$. Therefore $h$ is just plainly $\\class 3$, we can\n  thus just apply the second part of \\cref{thm:asymid}, and get:\n  \\[I_h(N) =\n    \\frac{\\Tr\\left(-\\nabla^2 h(\\rho\\ml) {\\left(\\nabla^2 \\ell(\\rho\\ml)\\right)}^{-1}\\right)}{2N}\n    {\\left(\\frac {2\\pi}{N}\\right)}^{\\frac n 2}\n    \\frac {e^{N\\ell(\\rho\\ml)}}{\\sqrt{\\left|\\det \\nabla^2 f(\\rho\\ml)\\right|}}\n    + O\\left(e^{Nf(0)}{N^{-\\frac n 2 -2}}\\right)\\]\n  And finally:\n\n  \\[E_h(N) = \\frac{I_h(N)}{I_1(N)} =\n    \\frac{\\Tr\\left(-\\nabla^2 h(\\rho\\ml) {\\left(\\nabla^2\n            \\ell(\\rho\\ml)\\right)}^{-1}\\right)}{2N}\n    + O\\left(\\frac 1{N^2}\\right)\\]\n\n\n\n\n\n\n\n  % This proof comes straight from~\\cite{SPRAL17}. The only thing added would be\n  % to check all the regularity conditions which I have only done informally on paper yet.\n  % I'll try to do that by Monday night.\n\\end{proof}\n\nBefore starting the proof where $\\rho\\ml$ has partial rank i.e. on the boundary of\n$\\mathcal{D}$, we need to characterize a bit the solution. Indeed in the full\nrank case, $\\rho\\ml$ is the only matrix such that $\\nabla \\ell (\\rho\\ml) = 0$.\nThis is no longer true on the boundary. The full characterization is:\n\n\\begin{prop}\\label{prop:caracKKT}\n  $\\rho\\ml$ is an optimal solution if and only if there\n  exists $\\eta \\geq 0$ and $\\lambda$ such that\n  \\[\\braket \\eta {\\rho\\ml} = 0 \\quad \\text{and} \\quad \\nabla \\ell + \\eta =\n    \\lambda I\\]\n\\end{prop}\n\n\\begin{proof}\n  \\TODO{} Adapt chapter 4 of report to do by directly assuming\n  Karush–Kuhn–Tucker conditions instead of proving them again.\n\\end{proof}\n\nWe can now start the longest and most\ncomplex proof of this paper. This proof is more subtle because in\n\\cref{thm:asypmid}, the edge\ndimension $x$ is of only one dimension but here, we may miss several\ndimensions.\nWe thus need to mount a change of variable that reduces several\ndimension to one. This change of variable came form~\\cite{SPRAL17}.\n\n\n\n\\begin{proof}[Proof of \\cref{lem:asymain} if $\\rho\\ml$ has partial rank\n  and $\\nabla \\ell \\neq \\lambda I$]\n\n  \\\n\n  Before starting let's just define $h_0(\\rho) = h(\\rho)P_0(\\rho)$.\n\n  First let $r$ be the rank of $\\rho\\ml$. Then let's suppose that $\\rho\\ml$ is\n  diagonal by rotating everything along a unitary $U$ such that $\\rho\\ml = U\n  DU^\\dagger$. $D$ will then be $\\mathrm{diag}(0,\\ldots,0,p_1,\\ldots,p_r)$.\n  We'll define $\\Delta$ by:\n  \\[ D = \\mat{0 & 0\\\\0&\\Delta}\\]\n\n  We can then\n  pose the following change of variable:\n  \\begin{equation}\n  \\Psi(\\xi,\\zeta,\\omega) = \\exp\\mat{0 &\\omega\\\\-\\omega^\\dagger&0}\n    \\mat{\\xi&0\\\\0&\\Delta + \\zeta - \\Tr \\xi \\frac{I}r} \\exp\\mat{0 &-\\omega\\\\\\omega^\\dagger&0}\n  \\end{equation}\n\n  Where $\\xi \\in \\mathcal{O}(\\C^{d-r})$, $\\omega \\in \\mathcal{M}_{(d-r),r}$ and\n  $\\zeta \\in \\mathcal{O}(\\C^r)$ but with $\\Tr \\zeta = 0$. First, let's show that\n  it is a diffeomorphism. We have:\n  \\begin{equation}\n    \\nabla \\Psi(D) \\cdot (\\delta\\xi,\\delta\\zeta, \\delta\\omega) =\n    \\mat{\\delta\\xi& \\delta\\omega\\,\\Delta\\\\ \\Delta\\, \\delta\\omega & \\delta\\zeta -\n      \\Tr(\\delta\\xi)\\frac Ir}\n  \\end{equation}\n  This is bijective in 0 ($\\Delta$ is invertible), so by local inversion theorem\n  $\\Psi : U \\to V$ is a diffeomorphism on $U$ a neighborhood of $D$. By the\n  same argument as usual, we can focus our study of the various integral to only\n  $U' = U \\cap \\mathcal{D}$ and even to $U'' = \\mathring U'$ because $U'\n  \\setminus U''$ is of null measure. We can thus apply the change of variable\n  \\newcommand{\\vars}{(\\xi,\\zeta,\\omega)}\n  \\newcommand{\\dvars}{\\dd \\xi\\, \\dd \\zeta\\, \\dd \\omega\\,}\n  \\newcommand{\\pvars}{\\Psi(\\xi,\\zeta,\\omega)}\n  \\begin{equation}\\label{eqn:uglyint}\n    \\int_{\\rho \\in U''} h_0(\\rho)e^{N\\ell(\\rho)}\\dd \\rho =\n    \\int_{\\vars \\in V''} h_0(\\pvars)e^{N\\ell(\\pvars)}J\\vars \\dvars\n  \\end{equation}\n  Where $J(\\vars)$ is the determinant of the Jacobian of $\\Psi$ and $V'' = \\Psi(U'')$.\n\n  In fact we can characterize what the edge of $\\mathcal{D}$ is in the\n  $\\vars$-space:\n  \\[\\rho = \\pvars > 0 \\iff \\xi >0\\]\n\n  So we would like $\\xi$ to be our $x$ variable and $(\\zeta,\\omega)$ to be our\n  $z$ variable. On one hand the second part is easy: let's name $z$ the variable\n  $z = (\\zeta,\\omega)$. One the other hand the first part is not that easy\n  because $\\xi$ is multidimensional (except if $r = n-1$).\n\n  Luckily If we write $\\xi = x \\sigma$ with $\\sigma \\in \\mathcal{D}(\\C^{d-r})$,\n  we'll have $\\xi > 0 \\iff x > 0$ and we are brought back to a single one sided\n  variable. If we name $\\Phi(x,\\sigma) = x \\sigma$ our function, it is a\n  diffeomorphism on the whole $\\R_{>0} \\times \\mathcal{D}(\\C^{d-r})$ to the positive\n  definite Hermitian matrices of size $r$. Furthermore it's Jacobian can easily\n  be computed and it is $x^r$.\n\n  There just one problem before doing a new change\n  of variable: In order to do a proper change of variable, we'll\n  need to split $\\xi$ from $z$, Thus we'll build a rectangle\n  neighborhood $V'''$ of\n  $(0,0,0)$ that separates $\\xi$ on one side and $z$ on the other,\n  such that $V''' = V'''_\\xi \\times V'''_z$.\n  We'll also use $W''' = \\Phi\\inv(V'''_\\xi)$ We'll thus have:\n  \\newcommand{\\ppvars}{\\Psi(\\Phi(x,\\sigma),z)}\n  \\newcommand{\\pvvars}{(\\Phi(x,\\sigma),z)}\n  \\newcommand{\\pdvars}{\\dd x\\, \\dd \\sigma\\, \\dd z}\n  \\begin{multline}\n    \\int_{\\rho \\in U'''} h_0(\\rho)e^{N\\ell(\\rho)}\\dd \\rho =\\\\\n    \\int_{(x,\\sigma) \\in W'''}\\int_{z \\in V'''_z} x^m h_0(\\ppvars)e^{N\\ell(\\ppvars)}J\\pvvars\n    \\,\\pdvars\n  \\end{multline}\n\n  Where $m = \\dim \\mathcal{D}(\\C^{d-r}) = (d-r)^2 -1$.\n  If we split again $W'''$ in a rectangular sub-neighborhood of $0$, namely $W''''_x \\times\n  W''''_\\sigma$, we have:\n\n  \\begin{multline}\n    \\int_{\\rho \\in U''''} x^m h_0(\\rho)e^{N\\ell(\\rho)}\\dd \\rho =\\\\\n    \\int_{\\sigma \\in W''''_\\sigma}\\left(  \\int_{(x,z) \\in W''''_x \\times V'''_z}\n      h_0(\\ppvars)e^{N\\ell(\\ppvars)}J\\pvvars \\,\\dd x \\, \\dd z\n    \\right) \\dd \\sigma\n  \\end{multline}\n\n  We now want to apply \\cref{thm:asypmid} on the integral inside the\n  parenthesis. Let's check all the hypothesis. $U = \\overline{W''''_x \\times\n    V'''_z}$ is a neighborhood of $(0,0)$ in $\\R_+ \\times \\R^n$.\n  $\\ell, \\Psi, \\Phi$ are smooth so\n  $f(x,z) = \\ell(\\ppvars)$ will be $\\class 4$. Being a non-critical global maximum\n  is conserved when pre-composing with any differentiable function so $(0,0)$ is global maximum\n  of $f$ on $U$.\n\n  We now only need to prove about $f$ that $\\dpar f x < 0$:\n  \\[\\dpar f x \\times \\delta x = \\nabla \\ell \\cdot \\mat{\\delta x\\, \\sigma & 0\\\\0 &-\n      \\delta x I} \\]\n\n  According to \\cref{prop:caracKKT} If $\\nabla f \\neq \\lambda I$, we have $\\eta\n  \\neq 0$ with $\\eta \\geq 0$ such that $\\Tr(\\eta D) = 0$ and $\\nabla f + \\eta =\n  \\lambda I$, Thus we have:\n  \\begin{equation}\\label{eqn:etanu}\n  \\eta = \\mat{\\nu&0\\\\0&0}\n  \\end{equation}\n\n  with $\\nu \\geq 0$ and $\\nu \\neq 0$. Therefore:\n  \\[\\dpar f x = - \\Tr(\\eta\\sigma) <0.\\]\n  Additionally, $h$ and $P_0$ are $\\class 1$, and $J$ is smooth so $g(x,z) =\n  h_0(\\ppvars)J\\pvvars$ is of class $\\class 1$. We can then\n  apply~\\cref{thm:asypmid}, and when $h(\\rho\\ml) \\neq 0$ we have:\n\n  \\begin{equation}\\label{eqn:IhNp}\n    I_h(N) =\n    \\frac{h(\\rho\\ml)P_0(\\rho\\ml)J(0,0)\\,m! {(2\\pi)}^{\\frac n 2}}{N^{\\frac n 2 + m + 1}} \\times\n    \\int_{\\sigma \\in W_\\sigma''''}\\frac{e^{N\\ell(\\rho\\ml)}}\n    {\\sqrt{\\left|\\det \\dparn f z 2\\right|} \\left(-\\dpar f x\\right)^{m+1}} \\dd \\sigma\n    + O\\left(\\frac{e^{Nf(0,0)}}{N^{\\frac n 2 + m + 2}}\\right)\n  \\end{equation}\n\n  We can then simplify everything and get the result we want.\n\n  \\\n\n  In the case $h(\\rho\\ml) = 0$. We can easily check that the various regularity conditions\n  are directly mapped on the similar conditions on $g$. Because $\\dpar h z = 0$\n  by hypothesis, we have:\n  \\[\\dparn g z 2(0,0) = J(0,0)P_0(\\rho\\ml) \\dparn h z 2 (\\rho\\ml)\\]\n\n  Therefore when we apply \\cref{thm:asypmid} and simplify by \\cref{eqn:IhNp},\n  we get the second result we wanted.\n\\end{proof}\n\n\n\\\n\n\\\n\nThe corner case where the $\\rho\\ml$ is on the edge of $\\mathcal{D}$ but the\ngradient toward the exterior is 0 is not done in this report like in the original\npaper~\\cite{SPRAL17}. The probability that such an event happens is really low\n(if it is not 0) in particular if we take into account the numerical errors of\nthe implementation. However it can still probably be done by splitting again the\n$x$ and $z$ variable but keeping $x$ as a quadratic variable in the function in\nthe exponential.\n\n\n\n\n\\begin{thm}\\label{thm:asymain}\n  For any $h : \\mathcal{D} \\to \\R$ of class $\\class 1$,\n  we have its expectation:\n  \\[E_h(N) = h(\\rho\\ml) + O\\left(\\frac 1N\\right)\\]\n  Additionally, if it is of class $\\class 3$ in the inside and along the edges\n  and $\\class 2$ otherwise with $\\dparn h x 2 =\n  o(\\frac 1 x)$ when leaving the edge where $x$ is a scalar variable not\n  tangent to the\n  edge, we'll have the variance:\n  \\[V_h(N) = E_{h_V}(N) = \\frac{\\Tr(\\nabla h\\pr \\mathbb H\\inv(\\nabla h\\pr))}N +O(\\frac 1 {N^2})\\]\n  where:\n\\begin{itemize}\n\\item $\\mathcal{D}_r$ is the submanifold of $\\mathcal{D}$ of matrices with rank $r$\n\\item $P\\ml$ is the orthogonal projector on the range of $\\rho$.\n\\item $A\\pr$ is\n  the orthogonal projection on the tangent space to $\\mathcal{D}_{\\rk \\rho}$ in\n  $\\rho$:\n  \\[A\\pr = A - \\frac{\\Tr(AP\\ml)}{\\Tr(P\\ml)}P\\ml - (I-P\\ml)A(I-P\\ml)\\]\n\\item $\\mathbb H$ is the hessian of $\\ell_{|\\mathcal{D}_{\\rk \\rho}}$ in $\\rho$:\n  \\[\\mathbb{H}(A) = \\sum_i \\frac{\\Tr(A{E_i}\\pr)}{\\Tr^2(\\rho\\ml E_i)} {E_i}\\pr +\n    (\\lambda I - \\nabla \\ell(\\rho\\ml))A\\rho\\ml^+ +\n    \\rho\\ml^+A(\\lambda I - \\nabla \\ell(\\rho\\ml))\\]\n  Where $\\rho^+$ is the Moore-Penrose pseudo inverse.\n\\end{itemize}\n\n\\end{thm}\n\n\\begin{proof}\n  The expectation proof is just a direct application of \\cref{lem:asymain}. For\n  the variance, it's a bit more tricky. First, let's check the regularity\n  conditions. We want to apply \\cref{lem:asymain} on $h_V = {\\big(h - h(\\rho\\ml)\\big)}^2$.\n  On the inside $h$ is of class $\\class 3$, so we have\n\n  \\begin{equation}\\label{eqn:hvder}\n  \\nabla h_V = 2 (h - h(\\rho\\ml)) \\nabla h \\gap \\text{and}\\gap \\nabla^2 h_V =\n    2(h-h(\\rho\\ml)) \\nabla^2 h\n    + 2 \\ket {\\nabla h} \\bra {\\nabla h}\n\\end{equation}\n\n  And we find out, that if $\\rho\\ml$ is on the edge,\n  $\\nabla^2 h_V$ can be prolonged to the edge because $\\nabla^2 h$\n  will be dominated by $(h - h(\\rho\\ml))$. If we are inside, we have a $\\class 3$\n  neighborhood, so we don't care. Furthermore, we have that $\\nabla h_V = 0$.\n  Therefore, we can apply \\cref{lem:asymain} and get:\n\n  \\[V_h(N) = E_{h_V}(N) =\n    \\frac{\\displaystyle \\Tr \\left( - \\dparn {h_V} z 2 (\\rho\\ml)\n        \\left( \\dparn \\ell z 2(\\rho\\ml)\\right)\\inv\\right)}\n    {2N}\n    + O\\left(\\frac 1 {N^2}\\right)\\]\n\n  As seen in \\cref{eqn:hvder}, $\\dparn {h_v} z 2 = 2 \\ket {\\dpar h z} \\bra{\\dpar h z^t}$. We\n  just have some equalities to show:\n\n  \\begin{itemize}\n  \\item $\\dpar h z = \\nabla h\\pr$: If we take an hermitian matrix $A$ written as\n    \\[A = \\mat{A_0& A_{0,r}\\\\A_{0,r}^\\dagger & A_r}\\]\n    one can check that we have\n    \\[ A\\pr = \\mat{0&A_{0,r}\\\\A_{0,r}^\\dagger & A_r - \\Tr(A_r)\\frac Ir}\\]\n\n    which is exactly the tangent space to $\\mathcal{D}_{\\rk \\rho\\ml}$ at $\\rho\\ml$. Furthermore\n    that tangent space is exactly spanned by $z$.\n\n    \\item $\\bra X {\\left (\\dparn \\ell z 2\\right)}^{-1}\n      \\ket X = \\Tr(X\\times \\mathbb H\\inv\\!(X))$: Computing the link between the\n      original hessian at $\\rho\\ml$ truncated to the tangent space and $\\dparn\n      \\ell z 2$ is a bit more complicated because the $z$ variable has a curve. We\n      use again explicitly the change of variable of the previous proof. If\n      we write $\\ell(z) = \\ell(\\Psi(z))$, we have\n      \\[ \\dparn \\ell z 2 = \\bra{ \\nabla \\ell} \\nabla^2 \\Psi + \\nabla \\Psi\n        \\nabla^2 \\ell \\nabla \\Psi\\]\n\n      In this formula, $\\nabla^2 \\Psi$ is a not a matrix but a 3 dimensional\n      tensor with two input sides and one output side. The $\\bra{\\nabla \\ell}$\n      applies on the output side.\n\n      Since $\\nabla \\Psi \\ket X = \\ket {X\\pr}$ the second term is simply\n      \\[\\nabla \\Psi^t\n        \\nabla^2 \\ell \\nabla \\Psi = \\sum_i\n        \\frac{\\ket{{E_i}\\pr}\\bra{{E_i}\\pr}} {\\Tr^2(\\rho\\ml E_i)} \\]\n\n      On the other hand, with some calculus, one\n      can prove that\n      \\[ \\nabla^2\\Psi(\\delta z, \\delta z) = \\mat{2\\delta \\omega\\, \\Delta\\, \\delta\n          \\omega & ? \\\\ ? & ?}.\\]\n      We use again the notations of \\cref{eqn:etanu} and\n      \\cref{prop:caracKKT}. We know that $\\bra {\\lambda I} \\nabla^2 \\Psi = 0$\n      because $\\mathcal{Y}$ in the set of matrices of trace one. So the only\n      remaining part is:\n      \\[\\bra {\\nabla \\ell} \\nabla^2\\Psi(\\delta z, \\delta z) = -2\\Tr(\\nu \\delta\n        \\omega \\Delta \\delta \\omega). \\]\n\n      If we write $\\delta \\Psi = \\nabla \\Psi \\delta z$, we have:\n      \\begin{align*}\n        \\Tr(\\delta\\Psi (\\lambda I - \\nabla \\ell(\\rho\\ml))\\delta\\Psi\\rho\\ml^+ +\n        \\delta\\Psi \\rho\\ml^+\\delta\\Psi(\\lambda I - \\nabla \\ell(\\rho\\ml)))\n        &= - \\Tr(\\delta\\Psi \\eta\\delta\\Psi\\rho\\ml^+ +\n          \\delta\\Psi \\rho\\ml^+\\delta\\Psi\\eta)\\\\\n        &= -2\\Tr(\\nu \\delta\n        \\omega \\Delta \\delta \\omega)\n      \\end{align*}\n\n      In the end,\n      \\[\\bra X \\dparn \\ell z 2 \\ket X = \\bra X \\mathbb H(X) = \\Tr(X \\mathbb H(X))\\]\n      so they are just two version of the same operator.\n  \\end{itemize}\n\n\\end{proof}\n\n\nIf we remove the $N$ factor and replace $N\\ell$ by just $\\ell$, the $N$\ndenominator will enter $\\mathbb H$ and we will have the results that were announced at\nthe beginning of the section.\n\n\\section{Relaxation for Von-Neumann entropy and related functions}\n\\label{sec:regentropy}\n\n\\TODO{} Read again this section and clean it up, maybe expand the proof. I did\nin a rush last time.\n\n\\\n\nIf we look at the previous regularity constraints, the entropy does not satisfy\nthem: it is not $\\class 1$ on the edge, and its variance is not $\\class 2$ on\nthe edge. However, we can get similar but a bit inferior results by defining\nintermediate regularity classes:\n\n\\begin{defn}\n  We say that a function $f : \\R \\to \\R$ is of class $\\class \\beta$ in $0$ if\n  for $k = \\lfloor \\beta \\rfloor$, the function is $\\class k$ on a neighborhood\n  of $0$ and we can write:\n  \\[f^{(k)} = f^{(k)}(0) + o(x^{\\beta-k})\\]\n\\end{defn}\n\n\\begin{rem}\n  $f$ is of class $\\class \\beta$ if and only if $f' \\in \\class{\\beta-1}$.\n\\end{rem}\n\n\\begin{rem}\nThis definition extends trivially to multivariate functions, So I'll use the\nnotation for those functions\n\\end{rem}\n\n\\begin{prop}\n  If $f \\in \\class \\beta$ and $\\lfloor k \\rfloor = \\beta$, we have\n  \\[f(x) = f(0) + xf'(0) + \\cdots + \\frac{x^{(k)}}{k!}f^{(k)}(0) + o(x^\\beta)\\]\n\\end{prop}\n\n\\begin{proof}\n  If we call $g(x) = f(x) - \\left(f(0) + xf'(0) + \\cdots +\n    \\frac{x^{(k)}}{k!}f^{(k)}(0)\\right)$, then $g^{(i)}(0) = 0$ for any $i \\leq\n  k$, and $g^{(k)}(x) = o(x^{\\beta - k})$. By successive integration's we get\n  $g^{(i)}(x) = o(x^{\\beta-i})$ and thus $g(x) = o(x^\\beta)$.\n\\end{proof}\n\n\\begin{thm}\n  For any $h : \\mathcal{D} \\to \\R$ of class $\\class \\varepsilon$ with $0 <\n  \\varepsilon < 1$, we have its expectation:\n  \\[E_h(N) = h (\\rho\\ml) + O\\left(\\frac 1 {N^\\varepsilon}\\right)\\]\n\\end{thm}\n\n\\begin{proof}\n  It suffice to go over all the proofs and replace $\\class 1$ by $\\class\n  \\varepsilon$ everywhere, and all the proofs can be adapted: when we\n  decompose $g$ in $g(z) = g(0) + h(z)$ with $O(\\|z\\|)$ in \\cref{thm:asy1}, We\n  just replace it by $h(z) = O(\\|z\\|^\\varepsilon)$. In all the proof the change\n  of class propagates well (The product of a $\\class 1$ function and $\\class \\varepsilon$\n  function is $\\class \\varepsilon$. The same is true for composition $g \\circ f$\n  if $g$ is $\\class \\varepsilon$ and $f$ is in $\\class 1$).\n\n  In \\cref{thm:asyp1}, we also decompose $g(x,z)$ in $h(0,z) + xg_1(x,z)$. In\n  the $\\class \\varepsilon$, we can do $g(x,z) = h(0,z) + x^\\varepsilon g_1(x,z)$\n  and the rest of the proof will give what we want.\n\\end{proof}\n\n\\begin{thm}\\label{thm:asyvarS}\n  Let's take $h : \\mathcal{D} \\to \\R$ that is $\\class 3$ on the interior of\n  $\\mathcal{D}$ and  on the tangent spaces to the edges. Furthermore we ask that\n  $h$ is $\\class\\varepsilon$ on the edge for $0 < \\varepsilon < 1$ and that it satisfies\n  $\\dpar h x = o(\\frac1{x^{\\delta}})$ with $0 < \\delta < \\varepsilon$,\n  for any scalar variable $x$ not tangent to the edge, the variance will be:\n  \\[V_h(N) = E_{h_V}(N) = \\frac{\\Tr(\\nabla h\\pr \\mathbb H\\inv(\\nabla h\\pr))}N\n    +O(\\frac 1 {N^{1 + \\varepsilon - \\delta}})\\]\n\\end{thm}\n\n\\begin{proof}\n  Let's study the regularity of $h_V = {(h - h(\\rho\\ml))}^2$. On the interior of\n  $\\mathcal{D}$ we have:\n  \\[\\nabla h_V = 2(h-h(\\rho\\ml))\\nabla h\\]\n\n  First on any vector variable $z$ tangent to the edge of $\\mathcal{D}$, this formula\n  will be true on the edge with partial gradient on $z$. On any variable $x$ not\n  tangent to the edge, we'll have $\\dpar {h_v} x = 2\n  o(x^\\varepsilon)o(\\frac1x^{\\delta}) = o(x^{\\varepsilon - \\delta})$. From\n  $\\varepsilon > \\delta$, we deduce that\n  $\\dpar {h_V} x(\\rho\\ml)$ exists and is $0$, so $h_V$ can be prolonged in a\n  $\\class 1$ function on the edge. In fact is prolonged in a $\\class {1 +\n    \\varepsilon - \\delta}$ function.\n\n  Now, if we look at \\cref{lem:asymain}, it only manipulates derivative on $z$,\n  so its proof works. If we go further back, all theorem require both $\\class 3$\n  in the interior and when tangent to the edge, and $\\class 2$ otherwise. That\n  $\\class 2$ can be replaced everywhere by $\\class {1 + \\varepsilon - \\delta}$\n  with the same kind of proof modification as in the previous theorem.\n\\end{proof}\n\n\\begin{prop}\nThe con-Newman entropy is of class $\\class \\varepsilon$ for any\n$\\varepsilon < 1$ on the edge of $\\mathcal{D}$, and smooth on the interior.\n\\end{prop}\n\n\\begin{proof}\n  $x^\\varepsilon \\ln(x) \\xrightarrow[x\\to0]{} 0$, for any $0< \\varepsilon$\n\\end{proof}\n\n\\begin{cor}\n  The expectation of the entropy $S$ is\n  \\[E_S(N) = S(\\rho\\ml) + O(N^{-\\varepsilon})\\]\n\\end{cor}\n\n\\begin{rem}\nIt is likely that as $\\varepsilon \\to 1$, the hidden constant\nof the $O$ will explode.\n\\end{rem}\n\n\\begin{prop}\n  The entropy satisfy the hypothesis of \\cref{thm:asyvarS} for any $\\varepsilon\n  < 1$ and any $\\delta < \\varepsilon$. Therefore for any $1 < \\beta < 2$, we have\n  \\[V_S(N) = \\frac{\\Tr(\\nabla S\\pr \\mathbb H\\inv(\\nabla S\\pr))}N\n    +O\\left(\\frac 1 {N^\\beta}\\right)\\]\n\\end{prop}\n\n\n\nI haven't tried them all, but I think all the other entropy-related values like\nmutual-information will also have similar regularity characteristics and thus will\nhave the same result on the asymptotic expectation and variance.\n\n\\section{Remark on error-propagation}\n\nNow I have the operator $\\mathbb H$, and I want to compute the standard\ndeviation on various functions that are mixture of classical observable\nevaluations and entropy-related functions. For my function $h: \\mathcal{D} \\to\n\\R$, I know from previous chapter that its standard deviation is:\n\n\\begin{equation}\\label{eqn:stddev}\n  \\sqrt{\\Tr(\\nabla h\\pr\\mathbb H\\inv \\nabla h\\pr)}\n\\end{equation}\n\nThe problem is that the functions I want to evaluate are complex and span\nmultiple files of source code. I would like a method to propagate the error\nestimation through all the layers of the code, following the way functions are\ncomputed. In order to do that, let's look at a more generic way of propagating\nerrors.\n\nSuppose we have a random variable $X \\in \\R^n$ and its covariance matrix $V_X$.\nSuppose we take a function $f : \\R^n \\to \\R^m$ such that $P(X \\in \\dom f) = 1$.\nWe would like to know the covariance matrix of $f(X)$.\nIf $X$ has a probability distribution centered on its expectation $X_0$, such as\na normal law, we can make a first order approximation and assume that $f$ on the\ndomain where $X$ varies looks like $f(X_0) + \\nabla f \\cdot (X-X_0)$. In such a\nsituation one can prove that:\n\\begin{equation}\\label{eqn:propag}\n  V_{f(X)} = \\nabla f^t V_X \\nabla f = \\bra {\\nabla f} V_x \\ket {\\nabla f}.\n\\end{equation}\n\n\nThis really looks like the \\cref{eqn:stddev}. In fact if we linearize our\nHermitian matrices $\\nabla h$\nand thus think of $\\mathbb H$ as an element of\n$\\mathcal{L}(\\mathcal{O}(\\mathcal{H}))$, we can write:\n\\[V_h = \\bra {\\nabla h\\pr} \\mathbb H^{-1} \\ket{\\nabla h\\pr}\\]\nFurthermore the projecting operator $\\pr$ is linear and thus can be put in a\nmatrix form such that\n\\[V_h = \\bra{\\nabla h}P^t\\mathbb H^{-1}P \\ket{\\nabla h}.\\]\nIn fact we have $P^t \\mathbb H\\inv P = \\mathbb H$ but I don't need it so I\nwon't prove it. What is important is that $V_\\rho = P^t \\mathbb H\\inv P$ looks\nlike the covariance matrix of $\\rho$ around $\\rho\\ml$ and thus I proved in the last chapter\nthat the first order error propagation gives the right asymptotic variance of\nany function.\n\nTherefore, in the code, I compute $V_\\rho$ from the results of the\nreconstruction and then when a function is applied on a variable, I compute its\ncovariance matrix with \\cref{eqn:propag}. In the end when a function has a\nsingle dimension output, the variance matrix is a simple variance real that I can put\nthrough a square root to get the standard deviation on that value.\n\n\n\\section{Proposition for partial information problem}\\label{sec:fixspan}\n\n\\subsection{Centering function}\n\nAs explained in \\cref{ssec:uniq}, when the $E_i$ do not span the whole space of\npositive hermitian matrices, the solution to the max-likelihood problem is not\nunique. We need to decide a way to pick one. The simplest way to do that is to\nchoose a centering function $c : \\mathcal{D} \\to \\R$ such that, the higher $c$\nis, the more ``centered'', the density matrix is. This function must satisfy\nsome properties to make sense\n\n\\begin{defn}\n  A function $c : \\mathcal{D}(\\mathcal{H}) \\to \\R$ is a \\emph{centering function} if:\n\n  \\begin{enumerate}\n  \\item It is concave, so that being between other matrices is always better.\n  \\item $\\displaystyle \\argmax_{\\rho \\in \\mathcal{D}} c = \\frac I{\\dim\n      \\mathcal{H}}$.\n  \\item $c$ must be unitary invariant: $c(U\\rho U^\\dagger) = c(\\rho)$ for $U \\in \\mathcal{U}(\\mathcal{H})$\n  \\item In dimension $2$, the density matrix is inside the Bloch sphere which is\n    linearly isomorphic to $\\mathcal{D}$. Any vector space cutting this space\n    gives either a disc or a segment that has an obvious center. $c$ must give\n    that center.\n  \\end{enumerate}\n\\end{defn}\n\nAll these constraints are qualitative constraints that ensure that $c$ makes sense\nas a centering function. If a function does not satisfy those conditions, it is\nnot a good centering function. But satisfying them does not guaranty that the function\nmake sense from the physical point of view. The logarithm of the determinant and\nthe von-Neuman entropy are good candidates. I plot heatmaps of them on random\nplanes to see how good they are in \\cref{fig:heat}. However, I don't think\nthere is a perfect centering function waiting to be found, but I obviously can't\nprove that.\n\nI didn't use any of its results directly in the report, but~\\cite{Bhatia07} was\nvery useful for analysing the structure of the density matrix space in my quest\nfor the perfect centering function\n\n\\subsubsection{Log-Determinant}\n\nThe log-determinant is good choice of strictly concave function. It seems to\nreally keep the matrices geometrically centered. And on some special case, for\nexample if it happens to be quadratic on the vector space studied, It will give\nthe exact center (It the determinant is quadratic on a slice of $\\mathcal{D}$,\nthat slice will be an ellipsoid which has an exact center). The reasons to use\nthe log determinant instead of the determinant are twofold: It is strictly\nconcave on $\\mathcal{D}$, and it will more likely fit on a machine floating\npoint number on the edges of $\\mathcal{D}$.\n\nI haven't time to prove formally that the log-determinant satisfy all centering\nfunction properties, but none of those should be hard to do.\n\\subsubsection{Von Neumann Entropy}\n\nThe Von-Neumann entropy is also a good choice of centering function from a probabilistic\npoint of view. Maximizing the entropy means maximizing the incertitude, which\nmakes sense when we are moving on direction on which we have zero information.\n\nThe entropy also satisfies the four conditions and thus is a centering function.\n\n\\begin{figure}\n  \\centering\n  \\begin{subfigure}[t]{0.49\\textwidth}\n\n    \\includegraphics[width=0.99\\textwidth]{det2.png}\n    \\includegraphics[width=0.99\\textwidth]{ent2.png}\n    \\caption{dimension 2}\n\n  \\end{subfigure}\n  \\begin{subfigure}[t]{0.49\\textwidth}\n    \\includegraphics[width=0.99\\textwidth]{det3b.png}\n    \\includegraphics[width=0.99\\textwidth]{ent3b.png}\n    \\caption{dimension 3}\n  \\end{subfigure}\n  \\begin{subfigure}[t]{0.49\\textwidth}\n    \\includegraphics[width=0.99\\textwidth]{det4.png}\n    \\includegraphics[width=0.99\\textwidth]{ent4.png}\n\n    \\caption{dimension 4}\n  \\end{subfigure}\n  \\begin{subfigure}[t]{0.49\\textwidth}\n    \\includegraphics[width=0.99\\textwidth]{det5.png}\n    \\includegraphics[width=0.99\\textwidth]{ent5.png}\n    \\caption{dimension 5}\n  \\end{subfigure}\n\n\\caption{In order to compare $\\log \\circ \\det$ and $S$, I plotted them on random affine planes\nslicing $\\mathcal{D}$. I pick a random density matrix $A$ and two random orthonormal null\ntrace matrices $H_1$ and $H_2$. I then plot $\\log \\circ \\det$ and $S$ in the\nplane $A + x H_1 + y H_2$. In each case $\\log\\circ \\det$ is on top and the\nentropy is below. The colorless area is outside of $\\mathcal{D}$}\n\\label{fig:heat}\n\\end{figure}\n\n\\subsubsection{In practice}\n\nThat part of my work wasn't directly useful for Luis project, because his effect\nmatrices only span the populations of Fock base and thus the centering simply\nconsists in putting $0$ in each correlation, which I think achieve perfect centering\nwhatever the centering function is.\n\n\\subsection{Two objective optimisation}\n\nIn order to use the centering function, what we want to do is that, after\noptimizing $\\ell$ and landing on $M = \\argmax_{\\rho \\in \\mathcal{D}} \\ell(\\rho)$, we\ncan optimize the centering function on $M$ and get the most centered matrix that\nmaximize $\\ell$.\n\nOne way of doing it is to do exactly what I just said: Find a $\\rho_{int}$ in\n$M$ with a first optimization (projected gradient ascent will find one).\nThen we could optimize $c$ on $M$.\nHowever I have no idea how to project a vector on $M$: The projection method\ndescribed in \\cref{ssec:proj} only works on the whole $\\mathcal{D}$ because\n$\\mathcal{D}$ is unitary invariant which is generally not the case of $M$.\n\nAn other way of doing that is by using a kind of barrier method with $c$. By optimizing $\\ell +\n\\varepsilon c$ and reducing progressively $\\varepsilon$, we'll the right\n$\\rho\\ml = \\argmax_{\\rho \\in M} c$.\n\n\\begin{prop}\n  If I name $\\rho_\\varepsilon$ the solution of:\n  \\[\\maximf{\\ell + \\varepsilon c}{\\rho \\in \\mathcal{D}}\\]\n\n  Then, if $c$ is strictly concave, and uniformly continuous we'll have:\n\n  \\[ \\rho_\\varepsilon \\xrightarrow[\\varepsilon \\to 0]{} \\rho\\ml = \\argmax_{\\rho \\in M} c\\]\n\\end{prop}\n\n\\begin{proof}\n  Let's define $\\ell\\ml = \\ell(\\rho\\ml)$.\n  $\\ell$ is strictly concave on all the dimension on which there is an $E_i$\n  i.e all the dimension orthogonal to $M$. That means that if\n  $\\ell(\\rho_\\varepsilon) \\to \\ell\\ml$, then $d(\\rho_\\varepsilon,M) \\to 0$.\n\n  Then lets prove that $\\ell(\\rho_\\varepsilon) \\to \\ell\\ml$. We now that\n  $\\ell\\ml > \\ell(\\rho_\\varepsilon)$, but we also know that\n  $\\ell(\\rho_\\varepsilon) + \\varepsilon c(\\rho_\\varepsilon) \\geq \\ell\\ml +\n  \\varepsilon c(\\rho\\ml)$. Therefore:\n  \\[\\ell\\ml - \\ell(\\rho_\\varepsilon) < \\varepsilon (g(\\rho_\\varepsilon) - g(\\rho\\ml))\\]\n  But $c$ is strictly concave so it has an upper bound. So when $\\varepsilon \\to\n  0$, we have $\\ell\\ml - \\ell(\\rho_\\varepsilon) \\to 0$ and thus\n  $d(\\rho_\\varepsilon,M)\\to 0$.\n\n  Let's name $\\rho_{p\\varepsilon}$ the projection of $\\rho_\\varepsilon$ on $M$.\n  As $\\rho_{p\\varepsilon} \\in M$, we have $g(\\rho_{p\\varepsilon}) < c(\\rho\\ml)$.\n\n  By uniform continuity, $d(g(\\rho_{p\\varepsilon}),c(\\rho_\\varepsilon)) \\to 0$\n  and $g(\\rho\\ml)$ is between them so $c(\\rho_{p\\varepsilon}) \\to c(\\rho\\ml)$.\n  But as $c$ is strictly concave, this must mean that $\\rho_{p\\varepsilon} \\to\n  \\rho\\ml$.\n\n  On the other hand we had $d(\\rho_\\varepsilon,M) =\n  d(\\rho_\\varepsilon,\\rho_{p\\varepsilon}) \\to 0$, so in the end we have\n  $\\rho_\\varepsilon \\to \\rho\\ml$.\n\\end{proof}\n\nThis proof works perfectly with the entropy but not with the $\\log \\circ \\det$\nas it isn't uniformly continuous. Furthermore, the projected gradient method won't\nwork directly with the entropy because when projecting on the edge, the gradient of the\nentropy will be infinite. I think both of this problems have solutions, for\nexample when we are on the edge, only output the tangent gradient for the\nentropy. However, the internship is finished, so I won't have the time to check\nit properly.\n\n\n\nCentering functions.\n\n\n\\section{Conclusion}\n\n\\TODO Write it\n\n\\bibliographystyle{plain}\n\n\\bibliography{article}\n\n\n\\newpage\\appendix\n\n{\\huge Appendix}\n\n\\vspace{1cm}\n\n\\section{Morse lemma}\n\n\\begin{lem}\\label{lem:dec}\n  Let $f : U \\subset \\R^n \\to \\R^m$, be $\\class{n}$ with $U$ a neighborhood of 0.\n  Suppose that $f(0) = 0$. Then we have $g : U \\to \\mathcal{L}(\\R^n,\\R^m)$ of\n  class $\\class {n-1}$ such\n  that:\n  \\[f(x) = g(x) x\\]\n  and with $g(0) = \\nabla f(0)$\n\\end{lem}\n\n\\begin{proof}\n  $g(x) = \\int_0^1 \\nabla f(tx) \\dd t$\n\\end{proof}\n\n\\begin{lem}\\label{lem:dec2}\n  Let $f : U \\subset \\R^n \\to \\R$, be $\\class{n}$ with $U$ a neighborhood of 0.\n  Suppose that $f(0) = 0$ and $\\nabla f(0) = 0$.\n  Then we have $h : U \\to \\mathcal{S}(\\R^n)$ of class\n  $\\class {n-2}$ such\n  that $h(0) = \\nabla^2 f(0)$ and:\n  \\[f(x) = \\bra x h(x) \\ket x\\]\n\\end{lem}\n\n\\begin{proof}\n  We apply \\cref{lem:dec} on $f$ to get $g$, that we see as a gradient $g :U \\to\n  \\R^n$. Then we apply it again on $g$ to get $h_0$, then we take the symmetric part:\n  \\[h = \\frac{h_0 + h_0^t}2\\]\n\n  We also have: $h_0(0) = \\nabla g(0) = \\nabla^2 f(0) = h(0)$\n\\end{proof}\n\n\n\\begin{lem}[Morse lemma]\\label{lem:morse}\n  Let $f : U \\subset \\R^n \\to \\R$, be $\\class{n}$ with $U $ a neighborhood of 0.\n  Suppose that $f(0) = 0$, $\\nabla f(0) = 0$ and $\\nabla^2 f > 0$.\n  Then we have a neighborhood $V$ of 0 and $\\psi : V \\to \\R^n$ of class\n  $\\class{n-2}$, a such that on $V$:\n  \\[f(x) = \\|\\psi(x)\\|^2\\]\n\n  If $n \\geq 3$, we can have $\\psi$ a diffeomorphism with $\\nabla \\psi(0) = \\sqrt{\\nabla^2 f(0)}$\n\\end{lem}\n\n\\begin{proof}\n  We take $h$ as in \\cref{lem:dec2}. As $h$ is continuous, we can take $V$ such\n  that $h > 0$ on $V$ ($h(0) = \\nabla^2 f > 0$).\n\n  We can then define $\\psi(x) = \\sqrt{h(x)} x$. With the square root being the\n  $\\class{\\infty}$ square root on the positive definite matrices.\n  If $n \\geq 3$, then $h$ is $\\class 1$, thus we have: $\\nabla \\psi(0) =\n  \\sqrt{h(0)} = \\sqrt{\\nabla^2 f(0)}$. As $\\nabla^2\n  f(0) > 0$, we have $\\nabla \\psi(0)$ invertible, so by local inversion theorem,\n  we can reduce the size of $V$ to make $\\psi$ a diffeomorphism on $V$.\n\n\\end{proof}\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "b13eb276f16d078c8c7f052ed4f8fc51f2769574", "size": 52261, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "article/article.tex", "max_stars_repo_name": "CuiCui66/Report-LKB-2019", "max_stars_repo_head_hexsha": "25bc002fcd88bde9d21369a423bda4765ac5a1d0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "article/article.tex", "max_issues_repo_name": "CuiCui66/Report-LKB-2019", "max_issues_repo_head_hexsha": "25bc002fcd88bde9d21369a423bda4765ac5a1d0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "article/article.tex", "max_forks_repo_name": "CuiCui66/Report-LKB-2019", "max_forks_repo_head_hexsha": "25bc002fcd88bde9d21369a423bda4765ac5a1d0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8608287725, "max_line_length": 106, "alphanum_fraction": 0.6489160177, "num_tokens": 18824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.41202007060879553}}
{"text": "\\documentclass[thesis]{poster_style}\n\\usepackage{graphicx}\n\\usepackage{natbib}\n\\usepackage{booktabs}\n\\usepackage{subfig}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{url}\n\\usepackage{tikz}\n\\usetikzlibrary{quotes,arrows.meta}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb}\n\\usepackage{caption}\n\\usepackage{float}\n\\graphicspath{{Images/}} \n\\usepackage{tocbibind}\n\\usepackage{tabularx}\n\\usepackage{amsmath}\n\\usepackage{appendix}\n\\usepackage{hyperref}\n\\usepackage{blindtext}\n\\usepackage{url}\n\\usepackage{xcolor}\n\\usepackage{sectsty}\n\n\\sectionfont{\\color{bordercolor}}\n\\subsectionfont{\\color{bordercolor}}\n\n%% Author of the thesis.\n\\author{Conor Casey}\n\n%% The year of your thesis poster's creation.\n\\posteryear{2019}\n\n%% Thesis Title.\n\\title{AMSIMP: An Open Source Implementation to Simulating \\\\ Tropospheric and Stratospheric Dynamics \\\\ on a Synpotic Scale}\n\n%% Teacher name.\n\\advisor{Ms. Abbott}\n\n%% School name.\n\\reader{Pobalscoil Inbhear Scéine}\n\n\\pagestyle{fancy}\n\n\\begin{document}\n\n\\begin{poster}\n\n\\section{Introduction}\nThis \\textbf{project hypothesises} that it is \\textbf{possible to create} an\n\\textbf{open-source implementation} to \\textbf{simulating tropospheric} and\n\\textbf{stratospheric dynamics} on a \\textbf{synoptic scale}, that \\textbf{such software}\nis \\textbf{consistent and reliable}, and that the software \\textbf{consists of high-quality source code}.\n\n\\section{Parameterisation of Simulation}\nWithin the software, the \\textbf{globe} is \\textbf{divided into cells}. You can imagine\nthis as \\textbf{cutting} the \\textbf{atmosphere} up into \\textbf{cuboids} of air of \\textbf{equal volume}.\nIt then \\textbf{solves} the relevant \\textbf{equation} at the \\textbf{middle} of the\n\\textbf{cell}. After which point, this value is \\textbf{used as} an\n\\textbf{approximation} for the \\textbf{entire cell}. \n\n\\hfill\n\n\\begin{center}\n    \\begin{tikzpicture}[every edge quotes/.append style={auto, text=black}]\n        \\pgfmathsetmacro{\\cubex}{10}\n        \\pgfmathsetmacro{\\cubey}{5}\n        \\pgfmathsetmacro{\\cubez}{7.5}\n        \\draw [draw=black, every edge/.append style={draw=black, densely dashed, opacity=.5}]\n        (0,0,0) coordinate (o) -- ++(-\\cubex,0,0) coordinate (a) -- ++(0,-\\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\\cubez)  -- ++(\\cubex,0,0) coordinate (c) -- cycle\n        (o) -- ++(0,0,-\\cubez) coordinate (d) -- ++(0,-\\cubey,0) coordinate (e) edge (g) -- (c) -- cycle\n        (o) -- (a) -- ++(0,0,-\\cubez) coordinate (f) edge (g) -- (d) -- cycle;\n        \\path [every edge/.append style={draw=black, |-|}]\n        (b) +(0,-25pt) coordinate (b1) edge [\"$\\Delta \\lambda$\"'] (b1 -| c)\n        (b) +(-25pt,0) coordinate (b2) edge [\"$\\Delta z$\"] (b2 |- a)\n        (c) +(17.5pt,-17.5pt) coordinate (c2) edge [\"$\\Delta \\phi$\"'] ([xshift=17.5pt,yshift=-17.5pt]e);\n    \\end{tikzpicture}\n\\end{center}\n\nThe \\textbf{key equations} utilised within the software are represented\n\\textbf{in discretized form} below:\n\n\\begin{equation}\n    u_g = -\\frac{1}{\\rho f} \\frac{\\Delta p_y}{2 \\Delta y}\n    \\label{u}\n\\end{equation}\n\n\\begin{equation}\n    v_g = \\frac{1}{\\rho f} \\frac{\\Delta p_x}{2 \\Delta x}\n    \\label{v}\n\\end{equation}\n\n\\begin{equation}\n    T^{n + 1}_{x, y, z} = T^{n - 1}_{x, y, z} + u \\frac{\\Delta t}{\\Delta x} (\\Delta T_{x})\n    + v \\frac{\\Delta t}{\\Delta y} (\\Delta T_{y})\n    \\label{temp}\n\\end{equation}\n\n\\begin{equation}\n    W^{n + 1}_{x, y, z} = W^{n - 1}_{x, y, z} + u \\frac{\\Delta t}{\\Delta x} (\\Delta W_{x})\n    + v \\frac{\\Delta t}{\\Delta y} (\\Delta W_{y})\n    \\label{pwv}\n\\end{equation}\n\n\\begin{equation}\n    \\rho^{n + 1}_{x, y, z} = \\rho^{n - 1}_{x, y, z} - u \\frac{\\Delta t}{\\Delta x} (\\Delta \\rho_{x})\n    - v \\frac{\\Delta t}{\\Delta y} (\\Delta \\rho_{y})\n    \\label{mass_continuity}\n\\end{equation}\n\n\\begin{equation}\n    p = \\rho R T\n    \\label{state_eq}\n\\end{equation}\n\n\\section{Contour Plot}\n\n\\begin{center}\n    \\begin{figure}\n        \\includegraphics[width=.65\\linewidth]{pressure.png}\n        \\caption{An Example Atmospheric Pressure Contour Plot}\n    \\end{figure}\n\\end{center}\n\n\\section{Open Source Software}\n\\textbf{Open Source Software} is software with \\textbf{source code}\nthat \\textbf{anyone} can inspect, \\textbf{modify}, and enhance. \\textbf{Programmers with access}\nto the source code can \\textbf{improve} that \\textbf{program} by\n\\textbf{adding features} to it, or by \\textbf{fixing bugs}. If an \\textbf{atmospheric dynamics simulator} \nbecame \\textbf{available} to the \\textbf{open source community}, it could\n\\textbf{lead to} a \\textbf{low cost}, and \\textbf{high quality simulator} ultimately being\nproduced. If such an event occurs, it could, \\textbf{theoretically},\nvastly \\textbf{enhance} existing \\textbf{numerical weather prediction software}.\n\n\\section{Benchmarking Method}%\n\nTo prove the hypothesis, it was determined that a series of appropriate\nbenchmarks would be carried out in the areas of performance, accuracy,\nand code quality.\n\n\\begin{itemize}\n\\item The \\textbf{performance benchmark} would \\textbf{demonstrate whether} \nor not the \\textbf{software} has \\textbf{consistent and reliable performance}.\n\\item The \\textbf{accuracy benchmark} would \\textbf{highlight whether} or not\nthe \\textbf{forecasts produced} by the software has a \\textbf{reasonable level of accuracy}.\n\\item The \\textbf{code quality benchmark} would \\textbf{indicate whether} or not the \\textbf{source code} \nof the software was \\textbf{of high quality}.\n\\end{itemize}\n\n\\section{Results}%\n\n\\begin{center}\n\\begin{tabular}{|c|c|c|c|} \n \\hline\n Forecast Day & $\\bar{x}$ & $\\sigma$ & $\\frac{\\sigma}{\\bar{x}}$ \\\\\n \\hline\n 1 & 48.71941 & 1.6192 & 0.03324 \\\\\n \\hline\n 2 & 82.05565 & 3.14003 & 0.03827 \\\\\n \\hline\n 3 & 122.0275 & 6.96494 & 0.05708 \\\\\n \\hline\n 4 & 164.84392 & 6.02163 & 0.03653 \\\\\n \\hline\n 5 & 209.37133 & 7.62972 & 0.03644 \\\\\n \\hline\n\\end{tabular}\\par\n\\end{center}\n\nIn regards to the performance benchmark, the time it took to generate a five-day forecast was measured. The\n\\textbf{statistical analysis} of the results \\textbf{found} that the \\textbf{mean coefficient of variation} \n($\\frac{\\sigma}{\\bar{x}}$) was approximately, \\textbf{0.04}.\n\n\\begin{center}\n    \\begin{figure}\n        \\includegraphics[width=.5\\linewidth]{mape_graph.png}\n        \\includegraphics[width=.36\\linewidth]{code_coverage.png}\n        \\caption{Results of Accuracy (L) and Code Quality (R) Benchmarks}\n    \\end{figure}\n\\end{center}\n\nIn regards to the accuracy benchmark, it showed that a \\textbf{four-day forecast}\nproduced software had a \\textbf{mean absolute percentage error}\nof approximately \\textbf{1.56\\%}.\n\nIn regards to the code quality benchmark, it indicated\nthat the software had a \\textbf{code coverage} of approximately \\textbf{98\\%}.\n\n\\section{Conclusions}\nThe results of the \\textbf{performance benchmark demonstrated} that there was a \\textbf{low variation} \nin \\textbf{execution time}, proving that the \\textbf{performance of the software}\nwas \\textbf{consistent and reliable}. The results of the \\textbf{accuracy benchmark indicated}\nthat the \\textbf{forecast produced} by the software is \\textbf{accurate}, which further proves its consistency and reliability. This \\textbf{code quality benchmark signified}\nthat the \\textbf{software has} a \\textbf{lower chance} of \\textbf{containing undetected bugs}, ultimately\n\\textbf{demonstrating} that the \\textbf{quality of} the \\textbf{source code is high}.\n\n\\end{poster}\n\n\\end{document}\n\n \n", "meta": {"hexsha": "2deef359b2ac38bd0b51d26dd735cbb6f7325b2d", "size": 7399, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "btyste/2020/poster/main.tex", "max_stars_repo_name": "amsimp/papers", "max_stars_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-05-15T10:06:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-15T10:06:17.000Z", "max_issues_repo_path": "btyste/2020/poster/main.tex", "max_issues_repo_name": "amsimp/papers", "max_issues_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "btyste/2020/poster/main.tex", "max_forks_repo_name": "amsimp/papers", "max_forks_repo_head_hexsha": "a212b3f65140f0292d51055be324a7c1b084e121", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4482758621, "max_line_length": 185, "alphanum_fraction": 0.7042843628, "num_tokens": 2383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4117833346024631}}
{"text": "\\chapter{Tableaux for Propositional Logic}\n\n\\section{Proof Systems}\n\n\\begin{enumerate}[\\thesection.1]\n\n\t\t\\item Remember from the introduction (1.1.9) that the point of a proof system is to formulate syntactic \\emph{inference rules} that allow us to derive the conclusion from the premises in all (and only) the valid inferences. There are, in fact, several different \\emph{kinds} of proof systems in the literature and we begin this chapter with an overview of the most important ones. What all of these proof systems have in common is that they avoid reference to semantic concepts, like valuations or consequence.\n\t\t\n\t\t\\emph{I don't expect you to become fluent in all of the different proof systems covered below. The point is that you should see what they look like and (roughly) how they work.}\n\t\t\n\t\t\\item \\emph{Hilbert systems} are, essentially, a model of step-by-step axiomatic reasoning in mathematics. A Hilbert system is defined by giving a set of \\emph{axioms} (i.e. valid formulas) and a set of \\emph{inference rules} (i.e. rules that allow you to infer valid formulas from valid formulas). As an example, here are axioms and rules for a Hilbert system for classical propositional logic:\t\t\n\t\t \\begin{description}\n\n\t\t\t\t\t\t\\item[Hilbert$_1$] $\\phi\\to (\\psi\\to \\phi)$\n\n\t\t\t\t\t\t\\item[Hilbert$_2$] $(\\phi\\to (\\psi\\to \\chi))\\to((\\phi\\to \\psi)\\to (\\phi\\to \\chi))$\n\n\t\t\t\t\t\t\\item[Hilbert$_3$] $(\\neg \\phi\\to \\neg \\psi)\\to (\\psi\\to\\phi)$\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\item[Modus Ponens.] From $\\phi$ and $(\\phi\\to\\psi)$ infer $\\psi$.\n\t\t\t\t\t\t\n\t\t\t\t\t\t\\item[Definitions.] From $(\\phi\\land\\psi)$ infer $\\neg(\\phi\\to\\neg\\psi)$ and vice versa; from $(\\phi\\lor\\psi)$ infer  $(\\neg\\phi\\to\\psi)$ and vice versa; and from $(\\phi\\leftrightarrow\\psi)$ infer $((\\phi\\to\\psi)\\land(\\psi\\to\\phi))$ and vice versa.\n\n\t\t\\end{description}\n\tA \\emph{proof} in the Hilbert system is a sequence of formulas such that each formulas is either an axiom (in our case, an instance of \\textbf{Hilbert}$_\\text{1--3}$) or inferred from some formulas earlier in the proof via an inference rule (in our case, \\textbf{Modus Ponens}  or \\textbf{Definitions}). We write $\\vdash_H\\phi$ to say that there is a proof in the Hilbert system that ends with $\\phi$. It can be shown (though we won't do that here) that the Hilbert calculus is sound and complete:\n\t \\[\\vdash_H\\phi\\text{ iff }\\vDash\\phi.\\]\n\t That is, a formula is derivable in our Hilbert system iff it is valid. Using the idea of Theorem 5.2.16, we can use the Hilbert system to show that an inference is valid: we know that $\\phi_1, \\mathellipsis,\\phi_n\\vDash \\psi$ iff $\\vDash \\phi_1\\land \\mathellipsis\\land \\phi_n\\to\\psi$, which by soundness and completeness of our Hilbert system is equivalent to $\\vdash_H \\phi_1\\land \\mathellipsis\\land \\phi_n\\to\\psi$\n\t \n\t \\item But proving things in Hilbert systems is \\emph{hard}. Hilbert systems are very economical, they only have a few axioms and rules---that's it. Our system, for example, has just 3 axioms and 2 rules. This makes reasoning \\emph{about} our system very efficient. But it makes reasoning \\emph{with} the system had. To see how hard, here I give a derivation of $p\\to p$ in our Hilbert system:\n\t\\begin{enumerate}[1.] \n\n\t\\item $((p \\to ((p \\to p) \\to p)) \\to ((p \\to (p \\to p)) \\to (p \\to p)))$ \n\n\t\\item[] \\ \\hfill (Axiom 2. with $\\phi=p, \\psi=(p\\to p),$ and $\\chi=p$)\n\n\t\\item $(p \\to ((p \\to p) \\to p))$ \\hfill (Axiom 1. with $\\phi=p$ and $\\psi=(p\\to p)$)\n\n\t\\item $((p \\to (p \\to p)) \\to (p \\to p))$ \\hfill (From 1. and 2. by MP.)\n\n\t\\item $(p \\to (p \\to p))$ \\hfill (Axiom 1. with $\\phi=p$ and $\\psi=p$.)\n\n\t\\item $(p \\to p)$\\hfill (From 3. and 4. by MP.)\n\n\\end{enumerate}\nThis is how you would show that $p\\vDash p$ using a Hilbert system. Would you have managed to find the proof yourself?\n\t\n\t\n\t\\item The next kind of proof system, we'll discuss are \\emph{sequent calculi} or \\emph{Gentzen systems}. A \\emph{sequent} is an expression of the form $\\Gamma\\Rightarrow\\Delta$, where $\\Gamma$ and $\\Delta$ are sets of formulas. Intuitively, we read a sequent $\\phi_1,\\mathellipsis,\\phi_n\\Rightarrow\\psi_1,\\mathellipsis, \\psi_m$ as the claim that $\\phi_1\\land\\mathellipsis\\land\\phi_n\\vDash\\psi_1\\lor\\mathellipsis\\lor\\psi_m$; that is, sequents are claims about consequence. The point is that we can derive consequence claims from other consequence claims (as we did in the previous chapter). In the Gentzen calculus for propositional logic, there is only one axiom (i.e. consequence claims held to be true no matter what): \\[\\phi\\Rightarrow\\phi\\tag{Identity}\\] The remaining ingredients are several \\emph{rules}, which allow us to infer consequence claims from each other. These rules fall into two classes \\emph{structural rules}, which don't involve the connectives, and \\emph{logical rules}, a pair of two for each connective. \n\nHere are the structural rules:\n\t\\begin{center}\n\t\t\\begin{tabular}{c c c}\n\t\t\t\\infer[Weak L]{\\Gamma\\cup\\{\\phi\\}\\Rightarrow \\Delta}{\\Gamma\\Rightarrow\\Delta} & \\infer[Weak R]{\\Gamma\\Rightarrow \\Delta\\cup\\{\\phi\\}}{\\Gamma\\Rightarrow\\Delta}\\\\[2ex]\n\t\t\t\n\t\t\t\\infer[Cut]{\\Gamma\\cup\\Gamma'\\Rightarrow\\Delta,\\Delta'}{\\Gamma\\Rightarrow \\{\\phi\\}\\cup \\Delta & \\{\\phi\\}\\cup\\Gamma'\\Rightarrow\\Delta'}\n\t\t\\end{tabular}\n\t\\end{center}\n\nAnd here are the rules for the connectives:\n\n\\begin{center}\n\t\t\t\\begin{tabular}{c c c }\n\t\t\t\n\t\t\t\t\\infer[\\neg L]{\\Gamma\\cup\\{\\neg\\phi\\}\\Rightarrow\\Delta}{\\Gamma\\Rightarrow\\Delta\\cup\\{\\phi\\}} & \\infer[\\neg R]{\\Gamma\\Rightarrow\\Delta\\cup\\{\\neg\\phi\\}}{\\Gamma\\cup\\{\\phi\\}\\Rightarrow\\Delta} \\\\[2ex]\n\t\t\t\n\t\t\t\t\\infer[\\land L]{\\Gamma\\cup\\{\\phi\\land \\psi\\}\\Rightarrow \\Delta}{\\Gamma\\cup\\{\\phi,\\psi\\}\\Rightarrow \\Delta} & \\infer[\\land R]{\\Gamma\\cup\\Gamma'\\Rightarrow \\{\\phi\\land \\psi\\}\\cup\\Delta\\cup\\Delta'}{\\Gamma\\Rightarrow \\{\\phi\\}\\cup\\Delta & \\Gamma'\\Rightarrow \\{\\psi\\}\\cup\\Delta'}\\\\[2ex]\n\t\t\t\t\n\t\t\t\t \\infer[\\lor L]{\\Gamma\\cup\\Gamma'\\cup \\{\\phi\\lor \\psi\\}\\Rightarrow\\Delta\\cup\\Delta'}{\\Gamma\\cup \\{\\phi\\}\\Rightarrow\\Delta & \\Gamma'\\cup\\{\\psi\\}\\Rightarrow \\Delta'} & \\infer[\\lor R]{\\Gamma\\Rightarrow \\Delta\\cup\\{\\phi\\lor \\psi\\}}{\\Gamma\\Rightarrow \\Delta\\cup\\{\\phi,\\psi\\}}\\\\[2ex]\n\t\t\t\t \n\t\t\t\t \\infer[\\to L]{\\Gamma\\cup\\Gamma'\\cup\\{\\phi\\to\\psi\\}\\Rightarrow\\Delta\\cup\\Delta'}{\\Gamma\\Rightarrow \\{\\phi\\}\\cup\\Delta' & \\Gamma'\\cup\\{\\psi\\}\\Rightarrow \\Delta'} & \\infer[\\to R]{\\Gamma\\Rightarrow \\{\\phi\\to\\psi\\}\\cup\\Delta}{\\Gamma\\cup\\{\\phi\\}\\Rightarrow\\{\\psi\\}\\cup\\Delta}\n\t\t\t\t\n\t\t\t\\end{tabular}\n\t\t\t\\end{center}\nIt is possible to give rules $\\leftrightarrow L$ and $\\leftrightarrow R$ as well, but they are complicated. Typically, in sequent calculus, $\\phi\\leftrightarrow\\psi$ is considered \\emph{defined} as $(\\phi\\to\\psi)\\land(\\psi\\to\\phi)$. A proof in a Gentzen system is an upwards down tree whose leaves are all axioms and whose branches are constructed according to the rules. We write $\\Gamma\\vdash_G\\Delta$ to say that there is a proof with $\\Gamma\\Rightarrow\\Delta$ as its root. It is possible to show (in fact, it's not that difficult) that \\[\\Gamma\\vdash_G\\phi\\text{ iff }\\Gamma\\vDash\\phi\\]\n\n\t\\item Gentzen calculi have some very nice properties from a theoretical perspective. This is why you will likely encounter them in courses that focus on proof theory. But they are a bit hard to wrap your head around since they are very ``meta:'' you infer claims about consequence from claims about consequence. Here is an example of a Gentzen proof that $\\neg(p\\lor q)\\vDash \\neg p\\land \\neg q$:\n\n\t\\begin{center}\n\t\t\\begin{tabular}{c}\n\t\t\\infer[\\land R]{\\neg(p\\lor q)\\Rightarrow \\neg p\\land \\neg q}{\\infer[\\neg R]{\\neg(p\\lor q)\\Rightarrow \\neg p}{\\infer[\\neg L]{\\neg (p\\lor q),p\\Rightarrow \\emptyset}{\\infer[\\lor R]{p\\Rightarrow p\\lor q}{\\infer[Weak R]{p\\Rightarrow p,q}{p\\Rightarrow p}}}} & \\infer[\\neg R]{\\neg(p\\lor q)\\Rightarrow \\neg q}{\\infer[\\neg L]{\\neg (p\\lor q),q\\Rightarrow \\emptyset}{\\infer[\\lor R]{q\\Rightarrow p\\lor q}{\\infer[Weak R]{q\\Rightarrow p,q}{q\\Rightarrow q}}}}}\n\t\t\\end{tabular}\n\t\\end{center}\n\tIt is actually quite easy to find sequent proofs, even though they are difficult to understand properly. Here, however, we shall not go more into the depth of sequent calculi.\n\t\n\t\\item The third kind of proof system you should have seen is what's called a \\emph{natural deduction} system. Natural deduction systems are characterized by having \\emph{no} axioms, only rules that allow you to infer formulas from each other. The idea of natural deduction is to model the kind of informal reasoning we naturally do in mathematical proofs. The main aspect is the idea of \\emph{assumptions}. In a natural deduction proof, you may assume any formula at any point during the proof. But you may only proceed via the inference rules. Some of these rules \\emph{cancel} previous assumptions, which is done by writing $[\\phantom{\\phi}]$ around the assumption. Here are the natural deduction rules for propositional logic:\n\t\t\\begin{center}\n\n\t\t\t\\begin{tabular}{c c c}\n\t\t\t\t\n\t\t\t\t\\infer[EFQ]{\\psi}{\\phi & \\neg \\phi} & & \\infer[Biv]{\\psi}{\\infer*{\\psi}{[\\phi]} & \\infer*{\\psi}{[\\neg\\phi]}}\\\\[2ex]\\\\[2ex]\n\t\t\t\t\n\t\t\t\t\\infer[\\land I]{\\phi\\land \\psi}{\\phi & \\psi} & \\infer[\\land E_1]{\\phi}{\\phi\\land \\psi} & \\infer[\\land E_2]{\\psi}{\\phi\\land \\psi}\\\\[2ex]\n\t\t\t\t\n\t\t\t\t\\infer[\\lor I_1]{\\phi\\lor\\psi}{\\phi} & \\infer[\\lor I_2]{\\phi\\lor\\psi}{\\psi} & \\infer[\\lor E]{\\theta}{\\phi\\lor\\psi & \\infer*{\\theta}{[\\phi]} & \\infer*{\\theta}{[\\psi]}}\\\\[2ex]\n\n\t\t\t\t\\infer[\\to I]{\\phi\\to \\psi}{\\infer*{\\psi}{[\\phi]}} & & \\infer[\\to E]{\\psi}{\\phi\\to\\psi & \\phi}\n\n\t\t\t\\end{tabular}\n\t\t\t\n\t\t\t\\end{center}\n\tSimilar to sequent calculi, there are two kinds of rules: \\emph{introduction} and \\emph{elimination rules}, i.e. rules that allow you to infer a statement with a connective and rules that allow you to infer something from a statement with a connective. \n\t\n\tA natural deduction proof is an upside down tree (like a sequent calculus proof) of formulas whose branches are constructed according to the rules. We write $\\Gamma\\vdash_N\\phi$ to say that there exists a natural deduction proof whose root is $\\phi$ and the formulas at the leaves that don't have $[\\phantom{\\phi}]$ written around them are all in $\\Gamma$. It's a bit more tricky, but possible to show that \\[\\Gamma\\vdash_N\\phi\\text{ iff }\\Gamma\\vDash\\psi\\]\n\t\n\t\\item Here's an example of a natural deduction proof:\n\t\\begin{center}\n\t\t\t\\begin{tabular}{c}\n\t\t\t\t\\infer[\\lor E, 1]{q}{p\\lor q & [q] &\\infer[EFQ]{q}{[p] & \\neg q}}\n\t\t\t\\end{tabular}\n\t\t\\end{center}\t\n\tThis proof shows that $p\\lor q,\\neg q\\vdash_N p$.\n\n\t\\item In this course, we will not cover Hilbert calculi, Gentzen calculi, or natural deduction in detail. If you take a liking to one of these systems, you can check out the references at the end of this chapter. In this course, we'll make use of \\emph{analytic tableaux}, which double as a proof system and decision procedure for propositional logic. In the following sections, we will motivate and develop this proof system in some more detail.\n\n\t\\end{enumerate}\n\t\n\n\\section{Satisfiability and Consequence}\n\n\t\\begin{enumerate}[\\thesection.1]\n\n\t\t\\item Just like the method of truth-tables we discussed in the previous chapter, the method of analytic tableaux has a theoretical foundation in an important theorem. In this section, we shall state and prove this theorem.\n\t\t\n\t\t\\item  But first, we need to introduce a new theoretical concept, the concept of \\emph{satisfiability}. A set of formulas $\\Gamma\\subseteq\\mathcal{L}$ is said to be satisfiable iff there exists a valuation $v$ such that $\\llbracket\\phi\\rrbracket_v=1$ for all $\\phi\\in\\Gamma$. In words, a set of formulas is satisfiable iff there exists a valuation that makes all the members of the set true. \n\t\t\n\t\t\\item Let's consider some examples of satisfiable sets (where we assume, again, that $\\mathcal{P}=\\{p,q,r\\}$):\n\t\t\n\t\t\t\\begin{enumerate}[(a)]\n\t\t\t\n\t\t\t\t\\item The whole set $\\mathcal{P}=\\{p,q,r\\}$ is satisfiable since $v(p)=1, v(q)=1, v(r)=1$ is a valuation that makes all the members of $\\mathcal{P}$ true.\n\t\t\t\t\n\t\t\t\t\\item Any subset $X\\subseteq \\mathcal{P}$ is satisfiable since $v(p)=1$ iff $p\\in X$ defines a valuation $v$ that makes all the members of $X$ true.\n\t\t\t\t\n\t\t\t\t\\item The empty set $\\emptyset$ is satisfiable since \\emph{every} valuation makes all the members of $\\emptyset$ true (again, ask yourself: can there be a valuation that doesn't make some member of $\\emptyset$ true?). \n\t\t\t\t\n\t\t\t\t\\item We can even more generally note that any subset of a satisfiable set is satisfiable:\n\t\t\t\t\n\t\t\t\t\\begin{proposition}. Let $\\Gamma,\\Delta\\subseteq\\mathcal{L}$ be sets of formulas. If $\\Gamma$ is satisfiable and $\\Delta\\subseteq \\Gamma$, then $\\Delta$ is satisfiable.\n\t\t\t\t\\end{proposition}\n\t\t\t\t\n\t\t\t\t\\begin{proof}\n\t\t\t\tLet $\\Gamma,\\Delta\\subseteq\\mathcal{L}$ be sets of formulas such that $\\Gamma$ is satisfiable and $\\Delta\\subseteq \\Gamma$. That $\\Gamma$ is satisfiable means, by definition, that there exists a valuation $v$ such that $\\llbracket\\phi\\rrbracket_v=1$ for all $\\phi\\in\\Gamma$. We need to show that  that there exists a valuation $v'$ such that $\\llbracket\\psi\\rrbracket_{v'}=1$ for all $\\psi\\in\\Delta$. But we can simply let $v'$ be $v$. For let $\\psi$ be an arbitrary element of $\\Delta$. Since $\\Delta\\subseteq\\Gamma$, we have that $\\psi\\in\\Gamma$. And we have that $\\llbracket\\phi\\rrbracket_v=1$ for all $\\phi\\in\\Gamma$, and so $\\llbracket\\psi\\rrbracket_v=1$. Hence $\\llbracket\\psi\\rrbracket_{v}=1$ for all $\\psi\\in\\Delta$, as desired.\n\t\t\t\t\\end{proof} \n\t\t\t\t\n\t\t\t\t\\item The set $\\{p\\lor\\neg p\\}$ is satisfiable since (as we proved in 5.2.11) $p\\lor\\neg p$ is true under \\emph{every} valuation.\n\t\t\t\t\n\t\t\t\t\\item The set $\\{p\\to q, \\neg q\\}$ is satisfiable since $v(p)=0,v(q)=0,$ and $v(r)$ arbitrary defines a valuation that makes both $p\\to q$ and $\\neg q$ true.\t\t\t\t\n\t\t\t\n\t\t\t\\end{enumerate}\n\t\t\t\n\t\t\\item So, what does it mean for a set of formulas to be \\emph{un}satisfiable? Well, it follows immediately from the definition that a set $\\Gamma$ of formulas is unsatisfiable iff there exists no valuation $v$ such that $\\llbracket\\phi\\rrbracket_v=1$ for all $\\phi\\in\\Gamma$; in words, a set of formulas is unsatisfiable iff there is no valuation that makes all the members of the set true or, equivalently, iff every valuation makes some member false. So, intuitively, unsatisfiability is a kind of inconsistency: a set of formulas is unsatisfiable iff its members can't all be made true by a valuation.\n\t\t\n\t\t\\item Let's consider some examples of \\emph{un}satisfiable sets (assuming, again, that $\\mathcal{P}=\\{p,q,r,\\}$):\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\t\\item Any set $\\{\\phi, \\neg \\phi\\}$ for $\\phi\\in\\mathcal{L}$ is unsatisfiable. This immediately follows from the fact noted in 5.1.10 that for each valuation $v$ and formula $\\phi\\in\\mathcal{L}$, we have that either $\\llbracket\\phi\\rrbracket_v=1$ or $\\llbracket\\phi\\rrbracket_v=0$ (and never both); that is $\\llbracket\\cdot\\rrbracket_v$ is a \\emph{function} from $\\mathcal{L}$ to $\\{0,1\\}$. But if both $\\llbracket\\phi\\rrbracket_v=1$ and $\\llbracket\\neg \\phi\\rrbracket_v=1$, it would follow that $\\llbracket\\phi\\rrbracket_v=1$ and $\\llbracket\\phi\\rrbracket_v=0$, since $\\llbracket\\neg\\phi\\rrbracket_v=1-\\llbracket\\phi\\rrbracket_v$. It follows, for example, more concretely that $\\{p,\\neg p\\}$ is unsatisfiable. \n\t\n\t\t\t\\item A more general consequence of the previous observation is that the set $\\mathcal{L}$ of \\emph{all} formulas is unsatisfiable. To see this, simply observe that $\\phi,\\neg\\phi\\in\\mathcal{L}$ and so if $\\mathcal{L}$ would be satisfiable (i.e. all its members would be made true by some valuation), then $\\llbracket\\phi\\rrbracket_v=1$ and $\\llbracket\\neg \\phi\\rrbracket_v=1$, which we've just seen is impossible.\n\t\t\t\n\t\t\t\\item The point generalizes even more:\n\t\t\t\n\t\t\t\\begin{proposition}\n\t\t\tLet $\\Gamma,\\Delta\\subseteq\\mathcal{L}$ be sets of formulas. If $\\Gamma$ is unsatisfiable and $\\Gamma\\subseteq \\Delta$, then $\\Delta$ is unsatisfiable.\n\t\t\t\\end{proposition}\n\t\t\t\\begin{proof}\n\t\t\tWe prove this by contradiction. So, let $\\Gamma,\\Delta\\subseteq\\mathcal{L}$ be sets of formulas, $\\Gamma$ unsatisfiable, $\\Gamma\\subseteq \\Delta$, and suppose, for contradiction, that $\\Delta$ is satisfiable. This would mean that there exists a valuation $v$ such that $\\llbracket\\phi\\rrbracket_v=1$ for all $\\phi\\in\\Delta$. But then, since $\\Gamma\\subseteq\\Delta$, it would follow that for all $\\psi\\in\\Gamma$, $\\llbracket\\psi\\rrbracket_v=1$, which means that $\\Gamma$ would be satisfiable. Contradiction! Hence $\\Delta$ is unsatisfiable, as desired.\n\t\t\\end{proof}\n\t\t\n\t\t\n\t\t  \\item Finally, let's consider a less abstract/more concrete example:\n\t\t\tthe set\n\t\t\t$\\{p\\lor q, \\neg p, \\neg q\\}$\n\t\t\tis unsatisfiable.\n\t\t\tTo see this,\n\t\t\tsuppose that $v$ is a valuation with\n\t\t\t$\\llbracket p\\lor q\\rrbracket_v=1$,\n\t\t\t$\\llbracket\\neg p\\rrbracket_v=1$,\n\t\t\tand $\\llbracket\\neg q\\rrbracket_v=1$.\n\t\t\tSince $\\llbracket\\neg\\phi\\rrbracket_v=1-\\llbracket\\phi\\rrbracket_v$,\n\t\t\twe get immediately that  $\\llbracket p\\rrbracket_v=0$ and $\\llbracket q\\rrbracket_v=0$.\n\t\t\tBut since\n\t\t\t$\\llbracket p\\lor q\\rrbracket_v=max(\\llbracket p\\rrbracket_v, \\llbracket q\\rrbracket_v)$\n\t\t\tand  $\\llbracket p\\lor q\\rrbracket_v=1$,\n\t\t\tthat either\n\t\t\t$\\llbracket p\\rrbracket_v=1$\n\t\t\tand $\\llbracket q\\rrbracket_v=1$\n\t\t\t(otherwise, how could $max(\\llbracket p\\rrbracket_v, \\llbracket q\\rrbracket_v)=1$?)\n\t\t\t---but either case leads to a contradiction.\n\t\t\tHence, we cant have that\n\t\t\t$\\llbracket p\\lor q\\rrbracket_v=1$,\n\t\t\t$\\llbracket\\neg p\\rrbracket_v=1$,\n\t\t\tand $\\llbracket\\neg q\\rrbracket_v=1$ for any $v$; that is,\n\t\t\t$\\{p\\lor q, \\neg p, \\neg q\\}$\n\t\t\tis unsatisfiable.\n\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\\item The reason why we talk about satisfiability is that the method of analytic tableaux is a method for satisfiability checking: it's an algorithm that allows us to determine, purely syntactically, whether a set of formulas in propositional logic is satisfiable. ``But what does this have to do with proof theory?'' you may ask. And rightly so---we haven't connected the questions of satisfiability and validity yet. This is what we're doing in the following theorem:\n\t\t\t\n\t\t\t\\begin{theorem}[I Can't Get No Satisfaction]\n\t\t\tLet $\\Gamma\\subseteq\\mathcal{L}$ be a set of formulas and $\\phi\\in\\mathcal{L}$ a formula. Then, the following are equivalent:\n\t\t\t\\begin{enumerate}[1.]\n\t\t\t\n\t\t\t\t\\item $\\Gamma\\vDash\\phi$\n\t\t\t\t\n\t\t\t\t\\item $\\Gamma\\cup\\{\\neg\\phi\\}$ is unsatisfiable\n\t\t\t\n\t\t\t\\end{enumerate}\n\t\t\t\\end{theorem} \n\t\t\t\\begin{proof}\n\t\t\tWe need to show two things: $1.\\Rightarrow 2.$ and $2. \\Rightarrow 1.$ We do so in turn:\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item ($1.\\Rightarrow 2.$) We proceed by conditional proof. So suppose that ($\\ast$) $\\Gamma\\vDash \\phi$, i.e. for all $v$, if $\\llbracket \\psi\\rrbracket_v=1$, for all $\\psi\\in\\Gamma$, then $\\llbracket\\phi\\rrbracket_v=1$. We proceed by indirect proof to show that $\\Gamma\\cup\\{\\neg \\phi\\}$ is unsatisfiable. So suppose that $\\Gamma\\cup\\{\\neg \\phi\\}$ \\emph{is} satisfiable, i.e. there is a valuation $v$ such that $\\llbracket\\psi\\rrbracket_v=1$ for all $\\psi\\in\\Gamma\\cup\\{\\neg \\phi\\}$. Then $\\llbracket\\psi\\rrbracket_v=1$, for all $\\psi\\in\\Gamma$, since $\\Gamma\\subseteq \\Gamma\\cup\\{\\neg \\phi\\}$. And so by ($\\ast$), we know that $\\llbracket\\phi\\rrbracket_v=1$. But also $\\{\\neg\\phi\\}\\subseteq \\Gamma\\cup\\{\\neg \\phi\\}$, so $\\llbracket\\neg\\phi\\rrbracket_v=1-\\llbracket\\phi\\rrbracket=1$, which means that $\\llbracket\\phi\\rrbracket_v=0$. Contradiction. So we can conclude that $\\Gamma\\cup\\{\\neg \\phi\\}$ is unsatisfiable, given our assumption that $\\Gamma\\vDash \\phi$. So by conditional proof, we get that if $\\Gamma\\vDash\\phi$, then $\\Gamma\\cup\\{\\neg\\phi\\}$ is unsatisfiable.\n\t\t\t\t\n\t\t\t\t\\item ($2.\\Rightarrow 1.$) Suppose (for conditional proof) that $\\Gamma\\cup\\{\\neg\\phi\\}$ is unsatisfiable, i.e. there exists no valuation $v$ such that $\\llbracket \\psi\\rrbracket_v=1$ for all $\\psi\\in \\Gamma\\cup\\{\\neg\\phi\\}$. We want to show that $\\Gamma\\vDash\\phi$ and do so indirectly. So, suppose that $\\Gamma\\nvDash\\phi$; that is, suppose that there exists a valuation $v$ such that $\\llbracket \\psi\\rrbracket_v=1$ for all $\\psi\\in \\Gamma$ and $\\llbracket \\phi\\rrbracket_v=0$. But then, since $\\llbracket\\neg\\phi\\rrbracket_v=1-\\llbracket\\phi\\rrbracket$, it follows that $\\llbracket\\neg\\phi\\rrbracket_v=1$. And this just means that $\\llbracket \\psi\\rrbracket_v=1$ for all $\\psi\\in \\Gamma\\cup\\{\\neg\\phi\\}$---in contradiction to  $\\Gamma\\cup\\{\\neg\\phi\\}$ being unsatisfiable. Hence $\\Gamma\\vDash\\phi$, as desired.\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\\end{proof}\n\t\t\n\t\\item A good way of understanding this theorem is by looking at an example. Remember from 6.2.5.d that $\\{p\\lor q, \\neg p, \\neg q\\}$ is unsatisfiable. Note that the proof of this can equally be read as a proof of $p\\lor q,\\neg p\\vDash\\neg q$. Just compare it to 5.2.3.iv!\n\t\t\n\t\\item The point of the previous theorem is that we can reduce the question of the validity of arguments to the satisfiability of a set of formulas: by the previous theorem, an inference is valid iff the set of premises together with the negation of the conclusion is unsatisfiable. In the following section, we will make use of this idea to develop the method of analytic tableaux as a proof theory for propositional logic.\n\t\t\n\t\\end{enumerate}\n\n\\section{Analytic Tableaux}\n\t\t\t\n\t\\begin{enumerate}[\\thesection.1]\n\n\t\t\\item The method of analytic tableaux is an algorithm for determining whether a (finite) set of formulas is satisfiable. In this way, via Theorem 6.2.6, analytic tableaux allow us to determine whether a given inference is valid---we get another decision procedure for propositional logic. What makes the method of tableaux proof theoretic is that it proceeds step-by-step and purely syntactically: no mention of semantic concepts (like truth) is made in the formulation of the procedure. This is in stark contrast to the method of truth-tables, which makes \\emph{explicit} reference to truth. We will now describe \\emph{how} the method works and in the next chapter prove \\emph{that} it does.\n\t\t\n\t\t\\item The aim of our algorithm is to determine whether a given, finite set of formulas is satisfiable. So, as input, we get a set $\\Gamma$ of formulas. We will check the satisfiability of $\\Gamma$ by constructing a \\emph{tree} (yet another use of trees) according to the following recipe:\n\t\t\n\t\t\\begin{enumerate}[1.]\n\t\t\n\t\t\t\\item We begin by writing down the members of $\\Gamma$ as the \\emph{initial list}. This list forms the root of our tableau.\n\t\t\t\n\t\t\t\\item[] \\emph{Examples}.\n\t\t\t\n\t\t\t\\begin{itemize}\n\n\t\t\t\t\\item $\\Gamma=\\{p\\lor q, \\neg p, \\neg q\\}$\n\n\t\t\t\t\\item[] Initial List: \n\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t\t{\n\t\t\t\t\t\tline numbering=false,\n\t\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\t\tsingle branches=true,\n\t\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t\t}\n\t\t\t\t\t\t[p\\lor q, grouped [\\neg p, grouped [\\neg q, grouped] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t\n\t\t\t\t\\item $\\Gamma=\\{p\\land q, \\neg p\\lor q, \\neg (q\\land \\neg \\neg r)\\}$\n\n\t\t\t\t\t\\item[] Initial List:\n\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[p\\land q, grouped [ \\neg p\\lor q, grouped [\\neg (q\\land \\neg \\neg r), grouped ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t\n\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\\item Next, we repeatedly apply the following rules: \n\t\t\t\t\t\n\t\t\t\t\t\\vspace{2ex}\n\t\t\t\t\n\t\t\t\t\t\\begin{center}\n\t\t\t\t\t\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\neg\\neg \\phi [\\phi ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\phi\\land\\psi [\\phi [\\psi ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\neg (\\phi\\land\\psi) [\\neg \\phi ] [\\neg \\psi ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\phi\\lor\\psi [\\phi ] [\\psi ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\neg(\\phi\\lor\\psi) [\\neg\\phi [\\neg\\psi ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\n\t\t\t\t\t\\vspace{2ex}\n\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\neg (\\phi\\to\\psi) [\\phi [\\neg \\psi ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\phi\\to\\psi [\\neg \\phi ] [\\psi ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\phi\\leftrightarrow \\psi [\\phi [\\psi] ] [\\neg \\phi [\\neg \\psi] ] ]]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t%\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[\\neg(\\phi\\leftrightarrow \\psi) [\\phi [\\neg \\psi] ] [\\neg \\phi [ \\psi] ] ]]\n\t\t\t\t\t\\end{prooftree}\n\n\t\t\t\t\\end{center}\n\t\t\tWe read these rules as follows:\n\t\t\t\n\t\t\t\t\\begin{itemize}\n\t\t\n\t\t\t\\item If there's a node with a formula to which no rule has been applied yet, then we apply the rule by extending every branch that goes through the node as shown by the rule.\\footnote{Order doesn't matter.}\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\t\n\t\t\t If all the rules that can be applied have been applied, then we say that the tableau is \\emph{complete}.\n\t\t\n\t\t\n\t\t\t\\item[] \\emph{Examples (Cont'd)}. The initial lists that we gave as examples above can be extended to complete tableaux as follows:\n\t\t\t\n\t\t\t\t\\begin{center}\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 2cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[p\\lor q, grouped [\\neg p, grouped [\\neg q, \t\t\t\t\tgrouped [p] [q] ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\t\n\t\t\t\t\t\\begin{prooftree}\n\t\t\t\t\t{\n\t\t\t\t\tline numbering=false,\n\t\t\t\t\tline no sep= 1cm,\n\t\t\t\t\tfor tree={s sep'=5mm},\n\t\t\t\t\tsingle branches=true,\n\t\t\t\t\tclose with=\\xmark\n\t\t\t\t\t}\n\t\t\t\t\t[p\\land q, grouped [ \\neg p\\lor q, grouped [\\neg (q\\land \\neg\\neg r), grouped [p [q [\\neg p [\\neg q] [\\neg\\neg\\neg r [\\neg r] ] ] [q [\\neg q] [\\neg\\neg\\neg r [\\neg r] ] ] ] ] ] ] ]\n\t\t\t\t\t\\end{prooftree}\n\t\t\t\t\\end{center}\n\t\t\t\t\n\t\t\t\\item Once we've completed our tableau, we check on every branch $B$ whether there is a $p\\in\\mathcal{P}$ such that $p\\in B$ and $\\neg p\\in B$.\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\n\t\t\t\\item if yes, then we say that $B$ is \\emph{closed}, and mark it by writing an {\\xmark} under it;\n\t\t\t\n\t\t\t\\item if no, then we say that $B$ is \\emph{open}. \n\t\t\n\t\t\\end{itemize}\n\t\t\n\t\t\t\\item[] \\emph{Examples (Cont'd).} In our examples, we get the following results:\n\t\t\t\n\t\t\t\\begin{center}\n\\begin{prooftree}\n{\nline numbering=false,\nline no sep= 2cm,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\lor q, grouped [\\neg p, grouped [\\neg q, grouped [p, close] [q, close] ] ] ]\n\\end{prooftree}\n\n{\\begin{prooftree}\n{\nline numbering=false,\nline no sep= 1cm,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\land q, grouped [ \\neg p\\lor q, grouped [\\neg (q\\land \\neg\\neg r), grouped [p [q [\\neg p [\\neg q, close] [\\neg\\neg\\neg r [\\neg r, close] ] ] [q [\\neg q, close] [\\neg\\neg\\neg r [\\neg r ] ] ] ] ] ] ] ]\n\\end{prooftree}}\n\\end{center}\n\n\t\t\n\t\t\t\\item We now check our tableau whether there an open branch in the tree (i.e. a branch without an {\\xmark} underneath):\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\n\t\t\t\t\\item If yes, the tableau is called \\emph{open} and the set is satisfiable.\n\t\t\t\t\n\t\t\t\t\\item If no, the tableau is called \\emph{closed} and the set is unsatisfiable.\n\t\t\t\n\t\t\t\\end{itemize}\n\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\t\\item Lets talk about the idea behind the algorithm for a moment. The idea is that the rules allow us to test, step-by-step, what would need to be the case for the formulas in the tree to be true. A rule creates new branches if there's more than one possibility for the formula to be true. The idea can be given in the following two principles:\n\t\t\n\t\t\\begin{description}\n\t\t\t\n\t\t\t\t\\item[Down Preservation.] If the formula $\\phi$ at the parent node of a rule is true under a valuation $v$, i.e. $\\llbracket \\phi\\rrbracket_v=1$, then at least one formula $\\psi$ on a newly generated child node is true under $v$, i.e. $\\llbracket \\psi\\rrbracket_v=1$.\n\t\t\t\t\n\t\t\t\t\\item[Up Preservation.] If a formula $\\psi$ at a newly generated child node is true under $v$, $\\llbracket \\psi\\rrbracket_v=1$, then the formula $\\phi$ at the parent node is true, i.e. $\\llbracket \\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\end{description}\n\t\tFollowing this idea, we ultimately create a tree in which each branch corresponds (intuitively) to a possible valuation making all its members true. More formally, the idea is that each complete branch $B$ corresponds to a valuation $v_B$, such that $\\llbracket\\phi\\rrbracket_{v_B}=1$ whenever $\\phi\\in B$. Note, however, that in contrast to the method of truth-tables, we don't use the recursive definition of truth in the formulation of our method. The method is purely syntactic.\n\t\t\n\t\t%Insert examples\n\t\t\n\t\t\\item And what's the deal with the {\\xmark}'s? Well, a branch $B$ can only correspond to a \\emph{real} valuation if there is no $p\\in\\mathcal{P}$ such that $p,\\neg p\\in B$. This is so, because $v$ needs to be a \\emph{function} and if it would make both $p$ and $\\neg p$ true, i.e. if $\\llbracket p\\rrbracket_v=1$ and $\\llbracket \\neg p\\rrbracket_v=1-\\llbracket p\\rrbracket_v=1$, we'd need to have $v(p)=1$ and $v(p)=0$, which is impossible. Hence a branch $B$ with some $p,\\neg p\\in B$ doesn't correspond to a real possibility and can thus be eliminated. \n\t\t\n\t\tIf in this way, we eliminate all the possible evaluations, we have shown that there is no valuation that makes all the members of the formulas in the initial list true. Note that the initial list is the only node that is on every branch of the tree---it is the root. Well, strictly speaking we will need to prove this; and we will, in the next chapter.\n\t\t\n\t\t\\item But for now, let's focus on the pragmatics. We will now first discuss how to get a valuation from an open branch that makes the formulas on the branch---and thus the initial list---true. If $B$ is an open branch of a complete tableau, then we define its associated interpretation $v_B:\\mathcal{P}\\to\\{0,1\\}$ by setting:\\[v_B(p):=\\begin{cases} 1 &\\text{if }p\\in B\\\\0&\\text{if }p\\notin B\\end{cases}\\]\t\n\t\tNote that since we assume that $B$ is open, $v_B$ is indeed a function! (Why?) In fact, if $B$ is open and $\\neg p\\in B$, then $p\\notin B$, and hence $v_B(p)=0$---and so $\\llbracket \\neg p\\rrbracket_{v_B}=1-\\llbracket p\\rrbracket_{v_B}=1$. In fact, as we will show in the next chapter, we will get as a theorem that every formula of an open branch is true under the associated interpretation:\n\t\t\n\t\t\\begin{theorem}[To be proven later]\n\t\tLet $B$ be an open branch of a complete tableau and $v_B$ it's associated valuation. Then for all $\\phi\\in B$, we have that $\\llbracket\\phi\\rrbracket_{v_B}=1$.\n\t\t\\end{theorem}\n\t\t\n\t\t\\item \\emph{Example}. Let's consider our example of an open tableau from the description of the tableau method:\n\t\t\n\t\t\\begin{center}\n{\\small\\begin{prooftree}\n{\nline numbering=false,\nline no sep= 2cm,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\land q, grouped [ \\neg p\\lor q, grouped [\\neg (q\\land \\neg\\neg r), grouped [p [q [\\neg p [\\neg q, close] [\\neg\\neg\\neg r [\\neg r, close] ] ] [q [\\neg q, close] [\\neg\\neg\\neg r [\\neg r ] ] ] ] ] ] ] ]\n\\end{prooftree}}\n\\end{center}\n\n\tIn this case, the associated interpretation of the only open branch $B$ (the right-most one) is given by $v_B(p)=1, v_B(q)=1, v_B(r)=0$.\n\t\t\n\t\t\\item Note that since the initial list, the members of our set $\\Gamma$, are on every branch of tableau (they're on the root, after all), it follows that if there's an open branch, then the initial list is on it. So, by the Theorem stated (but not proven!) in 6.3.5, we have that $v_B$ makes all the members of $\\Gamma$ true. We will use this now to define a proof method using analytic tableaux.\n\t\t\n\t\t\\item Using the idea that $\\Gamma\\vDash \\phi$ iff $\\Gamma\\cup\\{\\neg\\phi\\}$ is unsatisfiable (by Theorem 6.2.6), we define $\\Gamma\\vdash_T \\varphi$ as meaning that the complete tableau for $\\Gamma\\cup\\{\\neg\\varphi\\}$ is closed (i.e. not open). As a notational convention, we usually leave out the $_T$ and just write $\\Gamma\\vdash\\varphi$. So, to be perfectly explicit, the idea is that if the tableau for $\\Gamma\\cup\\{\\neg\\phi\\}$ is closed, then there is no valuation that makes all its members true, the set is unsatisfiable; but that just means that $\\Gamma\\vDash\\phi$. If, instead, the tableau for $\\Gamma\\cup\\{\\neg\\varphi\\}$ is open, then there is such a valuation, which shows that $\\Gamma\\nvDash\\phi$. So, in the tableau method, our step-by-step syntactic procedure, our proof, is the construction of the tableau. And, as it turns out, we cannot only use this method to derive the conclusion from the premises in all (and only) the valid inferences; in fact, we can also show that all invalid inferences in fact are invalid---and we get a countermodel to show this for free, on top. \n\t\t\n\t\t\\item Note that in order to prove that a formula is a logical truth, we need to show that it follows from the empty set. Remember: $\\vDash\\phi$ means that $\\emptyset\\vDash\\phi$. Using the method of tableaux, this means that we need to check if the set $\\{\\neg\\phi\\}$ is satisfiable. If it is, then there is a valuation in which $\\neg\\phi$ is true, so $\\phi$ false, and so $\\phi$ is not a logical truth; if $\\{\\neg\\phi\\}$ is not satisfiable, then $\\neg\\phi$ is always false, so $\\phi$ always true, and so $\\phi$ a logical truth.\n\t\t\n\t\t\\item Let's consider a bunch of examples:\n\t\t\n\t\t\t\\begin{enumerate}[(a)]\n\t\t\t\n\t\t\t\t\\item \\emph{De Morgan 1}\n\t\t\t\t\n\t\t\t\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\neg p\\lor \\neg q\\vdash \\neg (p\\land q)},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg p\\lor \\neg q, grouped [\\neg \\neg (p\\land q), grouped [p\\land q [\\neg p [p [q, close] ]] [\\neg q [p [q, close] ]]] ] ]\n\\end{prooftree}\\qquad \\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\neg (p\\land q)\\vdash \\neg p\\lor \\neg q},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg (p\\land q), grouped [\\neg(\\neg p\\lor \\neg q), grouped [\\neg\\neg p [\\neg\\neg q [\\neg p [p [q, close ] ] ] [\\neg q [p [q, close]] ]] ]]]\n\\end{prooftree}\n\\end{center}\n\n\t\t\t\\item \\emph{De Morgan 2}\n\n\t\t\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\neg p\\land \\neg q\\vdash \\neg (p\\lor q)},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg p\\land \\neg q, grouped [\\neg \\neg (p\\lor q), grouped [p\\lor q [ p [\\neg p [\\neg q, close]]] [q [\\neg p [\\neg q, close] ]]] ] ]\n\\end{prooftree}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\neg (p\\lor q)\\vdash \\neg p\\land \\neg q},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg (p\\lor q), grouped [\\neg(\\neg p\\land \\neg q), grouped [\\neg p [\\neg q [\\neg \\neg p [p, close]] [\\neg \\neg q [q, close]] ]] ]]\n\\end{prooftree}\n\\end{center}\n\n\t\t\t\n\t\t\t\\item \\emph{Law of Excluded Middle}\n\t\t\t\n\t\t\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\vdash p\\lor \\neg p},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg(p\\lor \\neg p) [\\neg p [\\neg\\neg p [p, close]] ] ]\n\\end{prooftree}\n\\end{center}\n\t\t\t\n\n\t\t\t\\item \\emph{Definition of the Conditional}\n\t\t\t\n\t\t\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={\\vdash (\\neg p\\lor q)\\leftrightarrow (p\\to q)},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[\\neg((\\neg p\\lor q)\\leftrightarrow (p\\to q)) [(\\neg p\\lor q) [\\neg  (p\\to q) [p [\\neg q [\\neg p, close] [q, close]] ]  ]] [\\neg(\\neg p\\lor q) [(p\\to q) [\\neg\\neg p [\\neg q [\\neg p [p, close ] ] [q [p, close ] ] ]] ] ] ]\n\\end{prooftree}\n\\end{center}\n\n\t\\item \\emph{Transitivitiy}\n\t\n\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={(p\\to q), (q\\to r)\\vdash (p\\to r)},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\to q, grouped [q\\to r, grouped [\\neg (p\\to r), grouped [p [\\neg r [\\neg p [\\neg q, close] [r, close] ] [q [\\neg q, close] [r, close]] ] ]] ] ]\n\\end{prooftree}\n\\end{center}\n\n\t\\item \\emph{Distributivity}\n\t\n\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={(p\\lor q)\\land r\\vdash (p\\land r)\\lor (q\\land r)},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[(p\\lor q)\\land r, grouped [\\neg((p\\land r)\\lor (q\\land r)), grouped [p\\lor q [r [\\neg (p\\land r) [\\neg (q\\land r) [p [\\neg p [\\neg q,close] [\\neg r, close]] [\\neg r [\\neg q,close] [\\neg r, close]]] [q [\\neg p [\\neg q,close] [\\neg r, close]] [\\neg r [\\neg q,close] [\\neg r, close]]]]]]]]]\n\\end{prooftree}\n\\end{center}\t\t\n\t\t\n\t\\end{enumerate}\t\n\t\t\n\t\\item Note that by Definition 6.3.8, we have that $\\Gamma\\nvdash\\phi$ iff the tableau for $\\Gamma\\cup\\{\\neg\\phi\\}$ is open. In that case, we get a countermodel showing that $\\Gamma\\nvDash \\phi$ for free. Here are a couple of examples:\n\t\n\t\\begin{enumerate}[(a)]\n\t\n\t\t\\item \\emph{Fallacy Affirming the Consequent}\n\t\t\n\t\t\n\t\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={p\\to q, q\\nvdash p},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\to q, grouped [q, grouped [\\neg p, grouped [\\neg p] [q]]]]\n\\end{prooftree}\n\n\\vspace{2ex}\n\\emph{Countermodel}: $v_B(q)=1, v_B(p)=0$.\n\\end{center}\n\n\t\\item \\emph{Fallacy of Affirming the Disjunct}\n\t\n\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={p\\lor q, p\\nvdash \\neg q},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[p\\lor q, grouped [p, grouped [\\neg\\neg q, grouped [q [p] [q]] ]]]\n\\end{prooftree}\n\n\\vspace{2ex}\n\\emph{Countermodel}: $v_B(p)=1, v_B(q)=1$.\n\\end{center}\n\n\t\\item \\emph{Messed Up Distributivity}\n\t\n\t\\begin{center}\n\\begin{prooftree}\n{\nproof statement format={centered},\nto prove={(p\\lor r)\\land (q\\lor r)\\nvdash (p\\lor q)\\land r},\nline numbering=false,\nfor tree={s sep'=5mm},\nsingle branches=true,\nclose with=\\xmark\n}\n[(p\\lor r)\\land (q\\lor r), grouped [\\neg((p\\lor q)\\land r), grouped  [p\\lor r [q\\lor r [\\neg(p\\lor q) [\\neg p [\\neg q [p [q,close] [r, close]] [r[q,close] [r]]]]] [\\neg r [p [q] [r, close ]] [r [q,close] [r, close]]]] ] ]] ]\n\\end{prooftree}\n\n\\vspace{2ex}\n\\emph{Countermodel} (left most branch): $v_B(p)=0, v_B(q)=0, v_B(r)=1$\n\\end{center}\n\t\t\n\t\n\t\\end{enumerate}\n\t\n\t\\item Let's conclude with one remark. Note that, officially, we're only allowed to close branches once we've completed the entire tree. In practice, however, it's often possible to stop early---as soon as we find a formula $\\phi$ and its negation $\\neg\\phi$ on a branch, we know that we'll also eventually find a $p$ and $\\neg p$ on the branch. So we can ``close early.'' In practice, this will be fine but for now, I'd like you to stick to the official rules. It's a bit like with official notation and conventional notation. The official rules (don't close early) are there to ensure that no mistakes are made. Once we're more comfortable doing tableau---when we do them for first-order logic---you'll be allowed to ``close early.''\n\t\n\t\\end{enumerate}\t\t\n\t\t\t\t\t\n\\section{Core Ideas}\n\n\\begin{itemize}\n\n\t\\item There are several different \\emph{kinds} of proof systems: Hilbert calculi, sequent calculi, natural deduction, and analytic tableaux. In this course, we use analytic tableaux. \n\t\n\t\\item A set of formulas is satisfiable iff there is a valuation that makes all of its members true.\n\t\n\t\\item An inference is valid iff the set of the premises and the negation of the conclusion is unsatisfiable.\n\t\n\t\\item The method of analytic tableaux is an algorithm for checking whether a set of formulas is satisfiable: if the tableau for a set is open, then the set is satisfiable.\n\t\n\t\\item We define a proof system using analytic tableaux by defining derivability as the tableau for the set of premises plus negation of conclusion being closed.\n\t\n\t\\item We can read-off a countermodel from an open branch of an open tableau.\n\n\\end{itemize}\n\n\\section{Self Study Questions}\n\n\t\\begin{enumerate}[\\thesection.1]\n\t\n\t\t\t\\item Consider a set $\\Gamma$. Which of the following implies that $\\Gamma$ is satisfiable?\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\n\t\t\t\\item For all valuations $v$, there is a formula $\\phi\\in\\Gamma$, such that $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For all valuations $v$ and all formulas $\\phi\\in\\Gamma$, we have $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For some valuation $v$ there is a formula $\\phi\\in\\Gamma$ such that $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For some valuation $v$ and all formulas $\\phi\\in\\Gamma$, we have $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For all $\\phi\\in\\Gamma$ there exists a valuation $v$ with $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For all $\\phi\\in\\Gamma$ and valuations $v$, we have $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item For some $\\phi\\in\\Gamma$ there exists a valuation $v$ with $\\llbracket\\phi\\rrbracket_v=1$.\n\n\t\t\t\\item For some $\\phi\\in\\Gamma$ we have for all valuations $v$ that $\\llbracket\\phi\\rrbracket_v=1$.\n\n\t\t\\end{enumerate}\n\t\n\t\t\\item Consider a set $\\Gamma$. Which of the following implies that $\\Gamma$ is unsatisfiable?\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\t\\item For each formula $\\phi\\in\\Gamma$, there is a valuation $v$ with $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\n\t\t\t\\item For each formula $\\phi\\in\\Gamma$ and valuation $v$, we have $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\n\t\t\t\\item There is a formula $\\phi\\in\\Gamma$ such that for all valuations $v$, we have $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\n\t\t\t\\item There is a formula $\\phi\\in\\Gamma$ and valuation $v$, such that $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\t\t\t\n\t\t\t\\item For each valuation $v$, there is a formula $\\phi\\in\\Gamma$ with $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\n\t\t\t\\item For all valuations $v$ and formulas $\\phi\\in\\Gamma$, we have $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\\item There is a valuation $v$ such that for all formulas $\\phi\\in\\Gamma$, we have $\\llbracket\\phi\\rrbracket_v=0$.\n\t\t\t\n\t\t\t\\item There is no valuation $v$ such that for all formulas $\\phi\\in\\Gamma$, we have $\\llbracket\\phi\\rrbracket_v=1$.\n\t\t\t\n\t\t\t\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\t\\item Consider a complete tableau. Which of the following entails that the tableau is open.\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\t\\item For no sentence letter $p\\in\\mathcal{P}$ is it the case that for all branches $B$ we have $p,\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item For no sentence letter $p\\in\\mathcal{P}$ do we have a branch $B$ with $p,\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item For some sentence letter $p\\in\\mathcal{P}$ do we have a branch $B$ with either $p\\notin B$ or $\\neg p\\notin B$.\n\t\t\t\n\t\t\t\\item For some sentence letter $p\\in\\mathcal{P}$ we have that for all branches $B$, either $p\\notin B$ or $\\neg p\\notin B$.\n\t\t\t\n\t\t\t\\item For all branches $B$ there is a sentence letter $p\\in \\mathcal{P}$ such that either $p\\notin B$ or $\\neg p\\notin B$.\n\t\t\t\n\t\t\t\\item For all branches $B$ and all sentence letters $p\\in \\mathcal{P}$ we have that either $p\\notin B$ or $\\neg p\\notin B$.\t\n\t\t\t\t\t\t\t\t\n\t\t\\end{enumerate}\n\n\t\t\\item Consider a complete tableau. Which of the following entails that the tableau is closed.\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\t\\item There is a sentence letter $p\\in\\mathcal{P}$ and branch $B$, such that $p,\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item There is a sentence letter $p\\in\\mathcal{P}$, such that for all branches $B$, we have $p,\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item There is a sentence letter $p\\in\\mathcal{P}$, such that for all branches $B$, either $p\\in B$ or $\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item For each branch $B$ there is a $p\\in\\mathcal{P}$ such that either $p\\in B$ or $\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item For each branch $B$ there is a $p\\in\\mathcal{P}$ such that $p\\in B$ and $\\neg p\\in B$.\n\t\t\t\n\t\t\t\\item For each branch $B$ and all $p\\in\\mathcal{P}$ we have that $p\\in B$ and $\\neg p\\in B$.\n\t\t\t\t\t\t\t\t\n\t\t\\end{enumerate}\n\n\n\t\\end{enumerate}\n\n\\section{Exercises}\n\n\n\t\\begin{enumerate}[\\thesection.1]\n\t\n\t\t\\item {$[\\nosym]$} Describe the content of Theorem 6.2.6 in your  words (without symbols).\n\t\t\n\t\t\\item Prove that the following sets are unsatisfiable \\emph{without using analytic tableau}!\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\t\t\n\t\t\n\t\t\t\\item $[h]$ $\\{\\neg (p\\to q), \\neg (q\\to p)\\}$\n\t\t\t\n\t\t\t\\item $\\{\\neg (p\\lor \\neg p)\\}$\n\t\t\t\n\t\t\t\\item $[h]$ $\\{\\neg p, \\neg p\\to p\\}$\n\t\t\t\n\t\t\t\\item $\\{\\neg p, (p\\to q)\\to p\\}$\n\t\t\n\t\t\n\t\t\\end{enumerate}\n\t\t\n\t\t\\item Let $\\Gamma=\\{\\phi_1, \\mathellipsis,\\phi_n\\}$ be a finite set of formulas. Prove that $\\Gamma$ is unsatisfiable iff $\\vDash \\neg (\\phi_1\\land\\mathellipsis\\land\\phi_n)$ is a logical truth.\n\t\n\t\t\\item Check the following claims using analytic tableau:\n\t\t\n\t\t\\begin{enumerate}[(a)]\n\n\t\t\t\\item $[h]$ $p\\to q, r\\to q\\vdash (p\\lor r)\\to q$\n\n\t\t\t\\item $[h]$ $p\\to (q\\land r), \\neg r\\vdash \\neg p$\n\n\t\t\t\\item $[h]$ $((p\\to q)\\to q)\\to q$\n\n\t\t\t\\item $[h]$ $((p\\to q)\\land (\\neg p\\to q))\\to \\neg p$\n\n\\item $p\\leftrightarrow (q\\leftrightarrow r)\\vdash (p\\leftrightarrow q)\\leftrightarrow r$\n\n\\item $\\neg(p\\to q)\\land \\neg(p\\to r)\\vdash \\neg q\\lor \\neg r$\n\n\\item $p\\land (\\neg r\\lor s), \\neg (q\\to s)\\vdash r$\n\n\\item $\\vdash (p\\to (q\\to r))\\to (q\\to (p\\to r))$\n\n\\item $\\neg(p\\land \\neg q)\\lor r, p\\to (r\\leftrightarrow s)\\vdash p\\leftrightarrow q$\n\n\\item $p\\leftrightarrow \\neg\\neg q, \\neg q\\to (r\\land \\neg s), s\\to (p\\lor q)\\vdash (s\\land q)\\to p$\n\n\\end{enumerate} \n\n\t\t\\item Let $\\phi$ be a formula. Determine how long the tableau for $\\{\\neg\\phi\\}$ can \\emph{at most} (measured in terms of longest branch) based on $\\phi$'s complexity $c(\\phi)$.\n\n\t\t\\item \\emph{Highly optional}: Prove in the Hilbert calculus that:\n\t\t\n\t\t\\begin{enumerate}\n\t\t\n\t\t\t\\item $\\vdash (\\neg p\\to p)\\to p$\n\t\t\t\n\t\t\t\\item $\\vdash (((p\\to q)\\to p)\\to p)$\n\t\t\n\t\t\\end{enumerate}\n\n\t\\end{enumerate}\n\n\\section{Further Readings}\n\nThe system of natural deduction finds many applications in logic. You can read more about it in:\n\n\\begin{itemize}\n\t\n\t\t\\item \\emph{Natural Deduction}: Section 2.4 of Dalen, Dirk van. 2013. \\emph{Logic and Structure}. 5$^\\text{th}$ edition. London, UK: Springer.\n\t\t\t\n\t\\end{itemize}\n\n\n\\vfill\n\n\\hfill \\rotatebox[origin=c]{180}{\n\\fbox{\n\\begin{minipage}{0.5\\linewidth}\n\n\\subsection*{Self Study Solutions}\n\n\\begin{enumerate}\n\n\t\\item[6.5.1] (b), (d), (f)\n\n\t\\item[6.5.2] (c), (e), (h)\n\t\n\t\\item[6.5.3] (b), (f)\n\t\t\n\t\\item[6.5.4] (b), (e), (f)\n\n\\end{enumerate}\n\n\n\\end{minipage}}}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../../logic.tex\"\n%%% End:\n", "meta": {"hexsha": "e200dcc4efc39c311ee35d2bd87a074049fea1ae", "size": 47224, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/notes/tex/mainmatter/prop-tableaux.tex", "max_stars_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_stars_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/notes/tex/mainmatter/prop-tableaux.tex", "max_issues_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_issues_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/notes/tex/mainmatter/prop-tableaux.tex", "max_forks_repo_name": "crcaret/KI1V13001-Inleiding-Logica", "max_forks_repo_head_hexsha": "6c7966886cde1c5a3622dadab3c9c903a7ac4ff7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2747014115, "max_line_length": 1091, "alphanum_fraction": 0.6799720481, "num_tokens": 15045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.4117833318936356}}
{"text": "\\chapter{Markov Decision Processes}\n\\label{chapter2}\n\\usetikzlibrary{matrix}\n\n\\vspace{0.5cm}\n\n\\noindent Reinforcement learning refers to both a learning problem and a subfield of machine learning. A typical reinforcement learning setting is depicted in figure~\\ref{fig:rlsetting} and, as you can see it, shows a controller and a system continuously connected with each other where the controller receives the state of the system and the reward of the previous iteration and outputs a new action to send to the system. In response to this action, the system makes a transition and this cycle is repeated indefinitely. The main goal of reinforcement learning is to actually learn the problem and manage to control the system in order to maximize the reward. Problems with these characteristics are defined as Markov Decision Processes (MDPs) and the purpose of this chapter is to introduce MDPs as they describe the environment for reinforcement learning.\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.6\\textwidth]{./pictures/rlsetting.eps}\n    \\caption{A typical reinforcement learning setting}\n    \\label{fig:rlsetting}\n\\end{figure}\n\n\\section{Problem Definition}\n\nA Markov Decision Process is defined as a tuple, a triple, a 4-elements tuple or sometimes as a 5-elements tuple, depending on the specifications. In any case, here are the most important elements that define a MDP:\n\\begin{itemize}\n    \\item A \\textbf{state space} $\\mathcal{S}$ which is a countable non-empty set of states $\\mathcal{s}$;\n    \\item An \\textbf{action space}  $\\mathcal{A}$ which defines a countable non-empty set of actions $\\mathnormal{a}$, or $\\mathnormal{a(s)}$ if the set of actions is function of the state where we are in;\n    \\item A \\textbf{transition probability distribution} or \\textbf{transition model} $\\mathcal{P}$ that defines the probability of moving from state $\\mathnormal{s}$ to $\\mathnormal{s'}$ following action $\\mathnormal{a}$. This probability is defined as $\\mathbb{P}(s_{t+1} = \\mathnormal{s'} \\vert s_t = \\mathnormal{s}, a_t = \\mathnormal{a})$;\n    \\item An \\textbf{immediate reward function} $\\mathcal{R}$ which gives the reward received when $\\mathnormal{a}$ is chosen in state $\\mathnormal{s}$ and can be written as $\\mathcal{R}(\\mathnormal{s})$ or $\\mathcal{R}(\\mathnormal{s, a})$ or $\\mathcal{R}(\\mathnormal{s, a, s'})$;\n    \\item and a \\textbf{discount factor} $\\mathcal{\\gamma}$ that will be described later.\n\\end{itemize}\n\nFirst of all, why are MDPs called Markov Decision Processes? Now that we have the definition, we can explain it. MDPs are a tool for modeling sequential decision-making problems where a decision maker interacts with a system in a sequential way~\\cite{RLAlgs}. With this definition, we already explained the \\textit{decision} and the \\textit{process} part of the name; but why \\textit{markovian}?\n\nWell, the \\textbf{Markovian property} is a property stating that the conditional probability of the future depends only on the present state and not on past states or, in other words, that the current state where whatever person, computer, system you are trying to model is, is sufficient to decide on future actions and spaces without having to look backwards in time. We can see this in the definition of the transition probability distribution where the conditional probability of $\\mathnormal{s_{t+1}}$ is conditioned only by $\\mathnormal{s_t}$ and not by $\\mathnormal{s_{t-1}}$.\n\n\\section{An example}\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.6\\textwidth]{./pictures/frozenlake.eps}\n    \\caption{Frozen Lake. An example of a MDP game~\\cite{DeepRLCourse}}\n    \\label{fig:frozenlake}\n\\end{figure}\n\nMDPs can be better explained with the game of Frozen Lake depicted in figure~\\ref{fig:frozenlake}. The game's story is that a guy was playing frisbee but with a wrong shot his frisbee got stuck in the middle of a frozen lake and it has to be retrieved. The ice is very slippery and so every time a step is made, you have some probability of ending up in a different place. The grid system shows the starting cell, the final cell and some holes where you shouldn't end up.\n\nIn this game, the state is the complete grid system with the place where you are marked. There are $4 \\times 4$ possible states (all possible cells in the grid) although some of them will be bad states, meaning that if you reach one of those states you \"lose\". \\\\\nThe possible actions are obviously 4, as the possible directions you are able to follow, i.e. LEFT, RIGHT, UP, DOWN. \\\\\nThe model instead describes the rules of the game or better, describes what will happen if you do something in a particular place. In this case, since the ice is slippery, when you choose to follow an action you will have $0.5$ probability of going in the correct direction and $0.5$ probability of ending up in a wrong one. \\\\\nFor example, given that you are in the top left starting corner, your possible actions are going DOWN or RIGHT. Let us say that you choose DOWN, mathematically you will get formally:\n\\begin{align*}\n    \\mathbb{P}(s_{t+1} = DOWN \\ \\vert \\ s_t = START, \\ a_t = DOWN) &= 0.5 \\\\\n    \\mathbb{P}(s_{t+1} = RIGHT \\ \\vert \\ s_t = START, \\ a_t = DOWN) &= 0.5 \\\\\n    \\mathbb{P}(s_{t+1} = UP \\ \\vert \\ s_t = START, \\ a_t = DOWN) &= 0 \\\\\n    \\mathbb{P}(s_{t+1} = LEFT \\ \\vert \\ s_t = START, \\ a_t = DOWN) &= 0\n\\end{align*}\nusing the notation of $s_{t+1}$ equal to DOWN (RIGHT, UP, LEFT respectively) meaning \"the space you would end up into, having moved down (right, up, left respectively) of one cell\". \\\\\nWe still have to define the reward in the game. Since the goal is a very good cell, the reward of reaching that state would be $+1$ and since all the other cells are just a path to the good cell, they would give reward $0$.\n\nNow that we have seen all the definitions in a game example, the understanding should have become clearer.\n\n\\section{The reward function}\n\nWe still have to give a closer look to the reward. \\\\\nThe reward is a function that maps the space and the action to a real number that can be translated into the \\textit{goodness} of your action and can be mathematically written as:\n\\begin{equation}\n    \\mathnormal{r(s,a, s')} = \\mathbb{E}[\\mathcal{R}_{t+1} \\ \\vert \\ S_t = s, A_t = a, S_{t+1} = s']\n\\end{equation}\nsince it gives the expected immediate reward.\n\\newline\n\\newline\nThe \\textbf{return} is the total discounted sum of the rewards from time step $t$:\n\\begin{equation}\n    \\mathcal{R}_{t+1} + \\gamma\\mathcal{R}_{t+2} + \\gamma^{2}\\mathcal{R}_{t+3} + \\dots = \\sum^{\\infty}_{k=0}\\gamma^k \\mathcal{R}_{t+k+1}\n\\end{equation}\nWhere the discount $\\gamma \\in [0,1]$ is the present value of future rewards. Thus, if $\\gamma < 1$ then rewards far in the future worth exponentially less than rewards received in the first stages. \\\\\nIf $\\gamma < 1$ then the MDP is defined as \\textit{discounted} MDP instead if $\\gamma = 1$ the MDP is \\textit{undiscounted}.\n\nWe have to explain better the reward function. If $\\gamma = 1$ and for every step the reward is positive, then actually the sum from $0$ to $\\infty$ is equal to $\\infty$. If this is the case, then there is no real gain in changing state since the return at an infinite time step in the future is infinite so it doesn't matter to move now or later. This is the \\textit{existential dilemma of immortality} that says: if I have infinite time in the future and I know that moving now or later (making an action) will bring me to infinite reward, why should I move now? \\\\\nThis is why the discounted reward is important. It treats rewards nearest to the current time step more with respect to the ones further in the future. The discounted summation has a boundary, in opposition to the undiscounted one: in fact, if we define as $\\mathcal{R}_{max}$ the maximum reward for one single step, and hypothetically we say that every step is rewarded with this amount of reward, still the discounted return is bounded by:\n\\begin{equation}\n    \\sum^{\\infty}_{k=0}\\gamma^k \\mathcal{R}_{max} = \\frac{\\mathcal{R}_{max}}{1 - \\gamma}\n\\end{equation}\nthat is actually a geometrical series and so it can be easily computed. As we can see, if $\\gamma$ is close to $0$, the higher boundary is near $\\mathcal{R}_{max}$ and when $\\gamma$ is near to $1$, the higher boundary becomes bigger and bigger until, for $\\gamma = 1$, the result degenerates to $\\infty$.\n\nThe goal of the system, or decision-maker, is to choose a behavior that maximizes the expected return.\n\n\\section{Policy}\nThe Markov Decision Process as depicted above describes a problem. Given a problem, we always need to find a solution; and a solution for a Markov Decision Process is called a \\textbf{policy} $\\mathcal{\\pi}$. But, \\textit{what is a policy?} A policy is a sort of \"brain\" for the decision maker that tells how to choose actions. There are two kinds of policies:\n\\begin{itemize}\n    \\item \\textbf{deterministic policies} where the action is just a function of the state:\n    \\begin{equation}\n        a = \\pi(s)\n    \\end{equation}\n    \\item \\textbf{stochastic policies} where the action is a conditional distribution given a state:\n    \\begin{equation}\n        a \\sim \\pi(a \\ \\vert \\ s)\n    \\end{equation}\n\\end{itemize}\n\nAn \\textbf{optimal policy} is the one the maximizes the long term return.\n\nWe'll go more in depth in policies in the next chapter.\n\n\\section{Summary}\nA Markov Decision process has two main functions, the reward function $\\mathcal{R}$ and the transition model function $\\mathcal{P}$. This last one suggests the actions to do at each state in order to reach another state while the first one gives rewards after every step to suggest if you are going well or not.\n\nWhen we have those two functions that is, we can predict which reward will be received and which will be the next state for any state-action pair, the MDP can be solved through Dynamic Programming techniques and the optimal policy can be found. \\\\\nIf those two functions can't be computed or are not available, other approaches must be taken and reinforcement learning is the best approach.", "meta": {"hexsha": "d3cbd5f32caf2fc04b9ba27088be96c94f368ee3", "size": 10060, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/chapter2.tex", "max_stars_repo_name": "DistributedSystemsGroup/tensorpong", "max_stars_repo_head_hexsha": "736ded637c5b6dac8b105ef3bc25cace052b50ba", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/chapter2.tex", "max_issues_repo_name": "DistributedSystemsGroup/tensorpong", "max_issues_repo_head_hexsha": "736ded637c5b6dac8b105ef3bc25cace052b50ba", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/chapter2.tex", "max_forks_repo_name": "DistributedSystemsGroup/tensorpong", "max_forks_repo_head_hexsha": "736ded637c5b6dac8b105ef3bc25cace052b50ba", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.6699029126, "max_line_length": 859, "alphanum_fraction": 0.7479125249, "num_tokens": 2600, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.41178332820285585}}
{"text": "\\subsection{Runtime}\n\\label{subsec:appendix-experiments-robustness}\n\nWe briefly discuss runtime on the \\SBD, \\SUNRGBD and \\Fash datasets allowing to get\nmore insights on how the algorithms scale with respect to image size and the\nnumber of generated superpixels.\n\nWe find that the runtime of most algorithms scales roughly linear in the input size, while the\nnumber of generated superpixels has little influence. We first remember that\nthe average image size of the \\SBD, \\SUNRGBD and \\Fash datasets is: $314 \\times 242 = 75988$,\n$660 \\times 488 = 322080$ and $400 \\times 600 = 240000$. For $\\K \\approx 400$, \\W\nruns in roughly $1.9\\text{ms}$ and $7.9\\text{ms}$ on the \\SBD and \\SUNRGBD datasets, respectively.\nAs the input size for the \\SUNRGBD dataset is roughly $4.24$ times larger compared to the\n\\SBD dataset, this results in roughly linear scaling of runtime with respect to the input size.\nSimilar reasoning can be applied to most of the remaining algorithms, especially\nfast algorithms such as \\CW, \\PF, \\preSLIC, \\MSS or \\SLIC. Except for \\RW, \\QS and \\SEAW\nwe also notice that the number of generated superpixels does not influence runtime significantly.\nOverall, the results confirm the claim of many authors that algorithms scale\nlinear in the input size, while the number of generated superpixels has little influence.\n", "meta": {"hexsha": "ac733c3e3a530c30d4981877836fe6ef219dc800", "size": 1332, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/appendix/experiments-runtime.tex", "max_stars_repo_name": "davidstutz/cviu2018-superpixels", "max_stars_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/appendix/experiments-runtime.tex", "max_issues_repo_name": "davidstutz/cviu2018-superpixels", "max_issues_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/appendix/experiments-runtime.tex", "max_forks_repo_name": "davidstutz/cviu2018-superpixels", "max_forks_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.6, "max_line_length": 98, "alphanum_fraction": 0.7807807808, "num_tokens": 343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804478040617, "lm_q2_score": 0.6654105454764746, "lm_q1q2_score": 0.41174303530347794}}
{"text": "\\documentclass{article}\n\\newsavebox{\\oldepsilon}\n\\savebox{\\oldepsilon}{\\ensuremath{\\epsilon}}\n\\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit\n\\renewcommand*{\\epsilon}{\\usebox{\\oldepsilon}}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{graphicx} % For .eps inclusion\n%\\usepackage{indentfirst} % Controls indentation\n\\usepackage[compact]{titlesec} % For regulating spacing before section titles\n\\usepackage{adjustbox} % For vertically-aligned side-by-side minipages\n\\usepackage{array, amsmath,  mhchem}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{courier, subcaption}\n\\usepackage{multirow, enumerate}\n\\usepackage[autolinebreaks,framed,numbered]{mcode}\n\\usepackage{float}\n\\restylefloat{table}\n\n\\pagenumbering{gobble} \n\\setlength\\parindent{0 cm}\n\\renewcommand{\\arraystretch}{1.2}\n\\begin{document}\n\\large\n\nMCB 135 Problem Set 8 \\hfill Due Friday, April 10, 2015 at 2:30 PM\n\n\\section*{Problem 1: Fluorescence Recovery After Photobleaching (40 points)}\n\nA protein's localization can be used to regulate its activity. Fluorescence Recovery After Photobleaching (FRAP) is one method to investigate whether a protein is diffusing freely or physically confined. The coding sequence of a fluorescent protein is appended to the open reading frame of the protein of interest. A small region of a cell expressing this construct is then photobleached so that all proteins in that region permanently lose fluorescence. Diffusion of nearby fluorescent proteins into the region gradually restores fluorescence. This problem will guide you through a calculation of the expected spatiotemporal profile of fluorescence recovery for diffusion in one dimension, which can be compared to experimental data to estimate the protein's diffusion coefficient.\n\\begin{enumerate}[a)]\n\\item Consider the initial concentration profile:\n\\[ c(x,t=0) = \\left\\{\n     \\begin{array}{lr}\n       0 & : x < 0\\\\\n       a & : x \\geq 0\n     \\end{array}\n   \\right. \\]\nUsing the fact that the ``impulse response function\" for 1-D diffusion from a point source is $h(x,t)=e^{-x^2/4Dt}/\\sqrt{4\\pi D t}$, show via convolution that:\n\\[ c(x,t) = \\frac{a}{2} \\left[ 1 + \\textrm{erf} \\left( \\frac{x}{\\sqrt{4Dt}} \\right)\\right], \\hspace{3 cm} \\textrm{ where }\\textrm{erf} \\left( z \\right) \\triangleq \\frac{2}{\\sqrt{\\pi}} \\int_0^z e^{-u^2} \\, du \\]\n{\\color{red}\nThe profile for $t>0$ is given by the convolution of the initial concentration profile with the impulse response function/Green's function:\n\\begin{eqnarray*}\nc(x,t) & = & \\int_{-\\infty}^{\\infty} c(s,0) h(x - s,t) \\, ds\\\\\n& = & a \\int_{0}^{\\infty} h(x-s,t) \\, ds = \\frac{a}{\\sqrt{4\\pi D t}} \\int_0^{\\infty} e^{-\\frac{(x-s)^2}{4Dt}} \\, ds  \\\\\n\\end{eqnarray*}\nTo simplify, we define:\n\\[ u = \\frac{x-s}{\\sqrt{4Dt}} \\hspace{3 cm} du = - \\frac{ds}{\\sqrt{4Dt}} \\]\nAs $s \\to 0$, $u \\to x/\\sqrt{4Dt}$; as $s \\to \\infty$, $u \\to -\\infty$. With this substitution, we have:\n\\begin{eqnarray*}\nc(x,t) & = & \\frac{-a}{\\sqrt{\\pi}} \\int_{x/\\sqrt{4Dt}}^{-\\infty} e^{-u^2} \\, du  = \\frac{a}{\\sqrt{\\pi}} \\int_{-\\infty}^{x/\\sqrt{4Dt}} e^{-u^2} \\, du \\\\\n& = & \\frac{a}{\\sqrt{\\pi}} \\left[\\int_{-\\infty}^{0} e^{-u^2} \\, du +  \\int_{0}^{x/\\sqrt{4Dt}} e^{-u^2} \\, du \\right]\\\\\n& = & \\frac{a}{\\sqrt{\\pi}} \\left[\\frac{\\sqrt{\\pi}}{2} +  \\frac{\\sqrt{\\pi}}{2} \\textrm{ erf} \\left( \\frac{x}{\\sqrt{4Dt}} \\right) \\right]\\\\\n& = & \\frac{a}{2} \\left[1 +  \\textrm{ erf} \\left( \\frac{x}{\\sqrt{4Dt}} \\right) \\right]\\\\\n\\end{eqnarray*}\n}\n\\item A region along the axis of a rod-shaped cell is photobleached so that the initial concentration profile is:\n\\[ c(x,t=0) = \\left\\{\n     \\begin{array}{lr}\n       0 & : -L < x < L\\\\\n       a & : \\textrm{otherwise}\n     \\end{array}\n   \\right. \\]\nFind an expression for $c(x,t)$ in terms of the error function erf(). (Hint:  this can be done without taking any more integrals.)\\\\\n\n{\\color{red}\nNotice that we can solve the following related initial value problems by shifting and making a symmetry argument:\n\\begin{eqnarray*}\nc_1(x,t=0) = \\left\\{\n     \\begin{array}{lr}\n       0 & : x < L\\\\\n       a & : \\textrm{otherwise}\n     \\end{array}\n   \\right. & \\implies & c_1(x,t) = \\frac{a}{2} \\left[ 1 + \\textrm{erf} \\left( \\frac{x- L}{\\sqrt{4Dt}} \\right) \\right]\\\\\n   c_2(x,t=0) = \\left\\{\n     \\begin{array}{lr}\n       0 & : x > -L\\\\\n       a & : \\textrm{otherwise}\n     \\end{array}\n   \\right. & \\implies & c_2(x,t) = \\frac{a}{2} \\left[ 1 - \\textrm{erf} \\left( \\frac{x+L}{\\sqrt{4Dt}} \\right) \\right]\\\\\n   \\end{eqnarray*}\nThe solution to our initial value problem is just the sum of these two solutions:\n\\[ c(x,t) = c_1(x,t) + c_2(x,t) = \\frac{a}{2} \\left[ 2 + \\textrm{erf} \\left( \\frac{x-L}{\\sqrt{4Dt}} \\right)  - \\textrm{erf} \\left( \\frac{x+L}{\\sqrt{4Dt}} \\right) \\right] \\]\n}\n\n\\item Plot $c(x,t)$ from part (b) for $x\\in[-20,20]$ at $t=0.01, 1,$ and $100$. Use the parameter values $D=1$, $a=1$, and $L=5$.\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{problem1c.pdf}\n\\end{center}\n\n\\begin{lstlisting}\nfunction [] = problem1c()\n    D = 1;\n    a = 1;\n    L = 5;\n    x = -20:0.1:20;\n    \n    t = 0.01;\n    y = (a/2) * (2 + erf((x-L)/(4*D*t)^0.5) - erf((x+L)/(4*D*t)^0.5));\n    plot(x,y,'-k'); hold on;\n    \n    t = 1;\n    y = (a/2) * (2 + erf((x-L)/(4*D*t)^0.5) - erf((x+L)/(4*D*t)^0.5));\n    plot(x,y,'-r'); \n    \n    t = 100;\n    y = (a/2) * (2 + erf((x-L)/(4*D*t)^0.5) - erf((x+L)/(4*D*t)^0.5));\n    plot(x,y,'-b');\n    \n    legend('t=0.01','t=1','t=100','Location','SouthEast')\n    set(gca,'FontSize',16)\n    xlabel('Position')\n    ylabel('Concentration')\n    \nend\n\\end{lstlisting}\n\n\\item Outline how you would estimate $D$ if given a single fluorescence profile collected $\\tau$ seconds after photobleaching. You may assume that photobleaching is perfectly efficient, and that $L$ and $x$ are known.\\\\\n\n{\\color{red}\nMultiple answers are acceptable. One approach would be:\n\\begin{enumerate}[i)]\n\\item Estimate the parameter $a$ as the fluorescence at a distance far from the site of photobleaching\n\\item Calculate the expected fluorescence profile at each measured point for a range of values of $D$ using the formula\n\\item Compute the sum of squared error $\\sum (\\textrm{ Expected } - \\textrm{ Observed })^2$ for each of these values of $D$, and\n\\item Choose the value of $D$ with the smallest sum of squared error (or repeat steps 2-4 with an improved range of values for $D$)\n\\end{enumerate}\n}\n\n\\end{enumerate}\n\n\\section*{Problem 2: Epidemic (60 points)}\nA disease spreads through a population of $N$ persons: $x$ of them are infected, and the remainder, $s=N-x$, are susceptible. When the infection subsides, a person becomes susceptible again (no immunity is conferred). Infection and recovery are modeled by two events:\n\\[ \\ce{X + S ->[k_1] X + X} \\hspace{3 cm} \\ce{X ->[k_2] S}  \\]\n\n\\begin{enumerate}[a)]\n\\item What is the analog of the system size $\\Omega$ in this model?\\\\\n{\\color{red}\n$N$, the population size, is the analog of $\\Omega$ for this system.\n}\n\n\\item What is the stoichiometry matrix for these events?\\\\\n{\\color{red}\nMaintaining the order of events given above,\n\\[ S = \\begin{pmatrix} 1 & -1 \\end{pmatrix} \\]\n}\n\n\\item What are the two event propensities $\\Omega r_i(x, \\Omega)$?\n{\\color{red}\n\\begin{eqnarray*} P_1 & = & N r_1(x,N) = N k_1 \\left( \\frac{x}{N} \\right)\\left( \\frac{N - x}{N} \\right) = \\frac{k_1 x(N-x)}{N}\\\\\nP_2 & = & N r_2(x,N) = N k_2 \\left( \\frac{x}{N} \\right) = k_2 x\n\\end{eqnarray*}\n}\n\n\n\\item Using your answers to (a)-(c), find expressions for the first and second jump moments, $\\mu(x,t)$ and $\\sigma^2(x,t)$.\n{\\color{red}\n\\begin{eqnarray*} \\mu(x,t) & = & \\sum_{k=1}^2 s_k P_k = \\frac{k_1 x(N-x)}{N} - k_2 x\\\\\n\\sigma^2(x,t) & = & \\sum_{k=1}^2 s_k s_k^T P_k = \\frac{k_1 x(N-x)}{N} + k_2 x\n\\end{eqnarray*}\n}\n\n\\item Write down an expression for $dx$ in Langevin notation.\n{\\color{red}\n\\[ dx = \\mu(x,t) \\, dt + \\sigma(x,t) \\, dW_t = \\left[ \\frac{k_1 x(N-x)}{N} - k_2 x \\right] \\, dt + dW_t \\sqrt{\\frac{k_1 x(N-x)}{N} + k_2 x} \\]\n}\n\n\\item Simulate the system using the Euler-Maruyama method with parameters $N=1000$, $k_1 = 0.2$, and $k_2 = 0.1$ and with step size $\\Delta t = 0.1$ and $t \\in [0,1000]$. Include a plot with three sample trajectories with initial values $x(0)=100,500,$ and $900$.\n{\\color{red}\nWe first rewrite to clarify that the step size for the simulation will be found using:\n\\[ \\Delta x =  \\left[ \\frac{k_1 x(N-x)}{N} - k_2 x \\right] \\, \\Delta t + \\eta \\, \\sqrt{\\Delta t} \\sqrt{\\frac{k_1 x(N-x)}{N} + k_2 x} \\]\nwhere $\\eta \\sim \\mathcal{N}(0,1)$.\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{problem2f.pdf}\n\\end{center}\n}\n\\begin{lstlisting}\nfunction [] = problem2f()\n    k1 = 0.2;\n    k2 = 0.1;\n    N = 1000;\n    \n    delta_t = 0.1;\n    t = 0:delta_t:1000;\n    x0= [100 500 900];\n    for i=1:3\n        x = zeros(1,length(t)); x(1) = x0(i);\n        for j=2:length(t)\n            x(j) = x(j-1) + ((k1/N)*x(j-1)*(N - x(j-1)) - k2*x(j-1))*delta_t + ...\n                ((k1/N)*x(j-1)*(N - x(j-1)) + k2*x(j-1))^0.5 *(delta_t^0.5)*normrnd(0,1);\n            if x(j) > N\n                x(j) = N;\n            elseif x(j) < 0\n                x(j) = 0;\n            end\n        end\n        plot(t,x,'LineWidth',2); hold on;\n    end\n \n    xlabel('Time')\n    ylabel('x')\n    set(gca,'FontSize',16)\n    \nend\n\\end{lstlisting}\n\n\\item Use Wright's formula to find an expression proportional to the stationary probability distribution of states, $P(x)$. Do not calculate the normalization constant. Hint: to save headaches later, don't omit the absolute value notation when taking integrals of the form  $\\int \\frac{dx}{x} = \\ln |x|+C$.\n\n{\\color{red}\nAccording to Wright's formula,\n\\begin{eqnarray*}\nP(x,t) & \\propto &  \\frac{1}{\\sigma^2} \\exp \\left( \\int \\frac{\\mu}{\\sigma^2} \\, dx  \\right) = \\frac{1}{ \\frac{k_1 x(N-x)}{N} + k_2 x} \\exp \\left( \\int \\frac{ \\frac{k_1 x(N-x)}{N} - k_2 x}{ \\frac{k_1 x(N-x)}{N} + k_2 x} \\, dx  \\right)\\\\\n& = & \\frac{N}{ k_1 x(N-x) + k_2 N x}    \\exp \\left( \\int \\frac{ k_1 (N-x) - k_2 N}{ k_1 (N-x) + k_2 N} \\, dx  \\right)\\\\\n& = & \\frac{N}{ k_1 x(N-x) + k_2 N x}    \\exp \\left( \\int 1 - \\frac{ 2 k_2 N}{ k_1 (N-x) + k_2 N} \\, dx  \\right)\\\\\n& = & \\frac{N}{ k_1 x(N-x) + k_2 N x}    \\exp \\left( x + 2 k_2 N \\int  \\frac{ 1}{ k_1 x - (k_1 + k_2) N} \\, dx  \\right)\\\\\n& = & \\frac{Ne^x}{ k_1 x(N-x) + k_2 N x}    \\exp \\left( \\frac{ 2 k_2 N}{k_1} \\ln \\left| k_1 x - (k_1 + k_2) N \\right|   \\right)\\\\\n& = & \\frac{Ne^x}{ k_1 x(N-x) + k_2 N x} \\left| k_1 x - (k_1 + k_2) N \\right|^{ \\frac{ 2 k_2 N}{k_1} }\\\\\n \\end{eqnarray*}\nNote that the quantity inside of the absolute value sign is guaranteed to be negative.\n}\n\n\\item In the real world, what would happen if $x$ chances to reach zero? How does this reflect what will happen if you attempt to normalize your expression for $P(x)$ over $x \\in [0, N] \\cap \\mathbb{Z}$?\\\\\n{\\color{red}\nIf $x$ reaches zero, no people will be infected and the disease will be eliminated (unless it has a natural reservoir). Notice that the expression of $P(x,t)$ goes to infinity as $x \\to 0$: this indicates that the normalized probability distribution is $P(x,t)=\\delta(x)$, i.e., the stationary probability distribution is $x=0$.\n}\n\\end{enumerate}\nAs you saw in part f, this system has a different, ``pseudo-stable\" behavior that is apparent on intermediate timescales. We can investigate it by normalizing $P(x)$ over all $x \\neq 0$.\n\\begin{enumerate}[a)]\n\\setcounter{enumi}{8}\n\\item Numerically calculate $P^*(x)$, the ``pseudo-stationary probability distribution,\" by normalizing $P(x)$ with the parameter values given above for $x \\in [1, N] \\cap \\mathbb{Z}$.  Hint: to minimize rounding errors, calculate $\\ln P(x)$ for each value of $x$, subtract the minimum value in this array from all values in the array, then exponentiate and normalize.\\\\\n\\begin{lstlisting}\n    lnp = zeros(1,N);\n    for x=1:N\n        lnp(x) = -1 * log(1/((k1/N)*x*(N - x) + k2*x)) + x + ...\n            (2*k2*N/k1) * log(abs(k1*x - (k1+k2)*N));\n    end\n    lnp = lnp - min(lnp);\n    p = exp(lnp);\n    p = p ./ sum(p);\n\\end{lstlisting}\n\\item Calculate the mean $m$ and standard deviation $s$ of $P^*(x)$.\n\\begin{lstlisting}\n    p_mean = 0;\n    p_variance = 0;\n    for x=1:N\n       p_mean = p_mean + x*p(x);\n       p_variance = p_variance + (x^2)*p(x);\n    end\n    p_variance = p_variance - p_mean^2;\n    p_std_dev = p_variance^0.5;\n\\end{lstlisting}\n\\item Add lines to your plot from part (f) to mark $x=m-2s$ and $x=m+2s$. Do your simulated trajectories tend to remain within these bounds after reaching the pseudo-stationary distribution?\\\\\n{\\color{red} The trajectories tend to remain within two standard deviations of the mean on this timescale. }\n\\begin{center}\n\\includegraphics[width=0.5\\textwidth]{problem2j.pdf}\n\\end{center}\n\\begin{lstlisting}\n    plot([0, t(end)],[p_mean - 2 * p_std_dev, p_mean - 2 * p_std_dev],'k')\n    plot([0, t(end)],[p_mean + 2 * p_std_dev, p_mean + 2 * p_std_dev],'k')\n\\end{lstlisting}\n\n\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "8070735627c5a0296a1c71680e3a5c2547b8bbef", "size": 12859, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "problem set keys/ps8/tex/problem set 8 answer key.tex", "max_stars_repo_name": "mewahl/intro-systems-biology", "max_stars_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-01-20T17:43:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-31T17:23:09.000Z", "max_issues_repo_path": "problem set keys/ps8/tex/problem set 8 answer key.tex", "max_issues_repo_name": "mewahl/intro-systems-biology", "max_issues_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problem set keys/ps8/tex/problem set 8 answer key.tex", "max_forks_repo_name": "mewahl/intro-systems-biology", "max_forks_repo_head_hexsha": "95ad58ec50ef79d084e71f4380fbfbf5e1603836", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-01-20T17:43:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T14:42:10.000Z", "avg_line_length": 48.8935361217, "max_line_length": 782, "alphanum_fraction": 0.6341861731, "num_tokens": 4575, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.41174302069756474}}
{"text": "\\documentclass[a4paper]{article}  \r\n\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{mathrsfs}\r\n\\usepackage[toc,page]{appendix}\r\n\\usepackage[pdftex]{graphicx}\r\n\\usepackage{geometry}\r\n\\usepackage[utf8]{inputenc}\r\n\\usepackage{tabularx}\r\n\\usepackage{color}\r\n\\usepackage{natbib}\r\n\\usepackage{epstopdf}\r\n\\usepackage{caption}\r\n\\usepackage{subcaption}\r\n\\usepackage{cancel}\r\n\\usepackage{pdfpages}\r\n\r\n\\bibliographystyle{plainnat}\r\n\\newcommand{\\HRule}{\\rule{\\linewidth}{1mm}}\r\n\\newcommand{\\myparagraph}[1]{\\paragraph{#1}\\mbox{}\\\\}\r\n\r\n\\title{\\textsc{Design description of the model}}\r\n\\date{\\today}\r\n\r\n\\begin{document}\r\n\r\n\\begin{titlepage}\r\n\t\\centering\r\n\t{\\scshape\\LARGE Design description of the model \\par}\r\n\t\\vspace{1cm}\r\n\t{\\scshape\\Large Rev 0.1.0 \\par}\r\n\t\\vspace{2cm}\r\n\t\\vfill\r\n\r\n% Bottom of the page\r\n\t{\\large \\today\\par}\r\n\\end{titlepage}\r\n\r\n\\thispagestyle{empty}\r\n\\newpage\r\n\r\n\\setcounter{tocdepth}{3}\r\n\\tableofcontents\r\n\\setcounter{secnumdepth}{3}\r\n\\newpage\r\n\r\n\\section{Vessel model}\r\n\r\n\\begin{equation}\r\n\\label{eq:vessel_model}\r\n\\begin{aligned}\r\n\t\\boldsymbol{\\dot{\\eta}} &= \\boldsymbol{R} (\\psi) \\boldsymbol{\\nu} \\\\\r\n\t(\\boldsymbol{M}_{RB} + \\boldsymbol{M}_A) \\boldsymbol{\\dot{\\nu}} + \\boldsymbol{D} \\boldsymbol{\\nu} |\\boldsymbol{\\nu}| &= \\boldsymbol{\\tau}_{thr} + \\boldsymbol{\\tau}_{wind} + \\boldsymbol{\\tau}_{current} + \\boldsymbol{\\tau}_{ext}\r\n\\end{aligned}\r\n\\end{equation}\r\n\\\\\r\n\\\\\r\nThe matrix $\\boldsymbol{M}_{RB}$ can be defined as\r\n\\begin{equation}\r\n\\label{eq:MRB_matrix}\r\n\\begin{aligned}\r\n\t\\boldsymbol{M}_{RB} &=\r\n\t\t\\left[ \\begin{array}{ccc}\r\n\t\t\tm &  0 & 0 \\\\\r\n\t\t\t0 &  m & 0 \\\\\r\n\t\t\t0 &  0 &  I_z \r\n\t\t\\end{array} \\right],\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nwhere $m$ is the displacement, i.e. the mass of the displaced fluid, or the mass of the vessel, and $I_z$ is the moment of inertia about the $z_b$-axis. The elements that are not on\r\nthe diagonal of the matrix are ignored.\r\n\\\\\r\n\\\\\r\nThe added-mass matrix, $\\boldsymbol{M}_A$, is calculated in the origin of the coordinate system, CO. This matrix can be written as\r\n\r\n\\begin{equation}\r\n\\label{eq:MA_matrix}\r\n\\begin{aligned}\r\n\t\\boldsymbol{M}_A &=\r\n\t\t\\left[ \\begin{array}{ccc}\r\n\t\t\t-X_{\\dot{u}} &  0 & 0 \\\\\r\n\t\t\t0 &  -Y_{\\dot{v}} & 0 \\\\\r\n\t\t\t0 & 0 &  -N_{\\dot{r}} \r\n\t\t\\end{array} \\right],\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nin SNAME notation. $X_{\\dot{u}}$ is added mass in surge, $Y_{\\dot{v}}$ is added mass in sway og $N_{\\dot{r}}$ is added mass ini yaw. The elements that are not on\r\nthe diagonal of the matrix are ignored.\r\n\\\\\r\n\\\\\r\nThe matrix $\\boldsymbol{D}$ can, in SNAME notation, be written as\r\n\r\n\\begin{equation}\r\n\\label{eq:D_matrise}\r\n\\begin{aligned}\r\n\t\\boldsymbol{D} &=\r\n\t\t\\left[ \\begin{array}{ccc}\r\n\t\t\t-X_u &  0 & 0 \\\\\r\n\t\t\t0 &  -Y_v & 0 \\\\\r\n\t\t\t0 & 0 &  -N_r \r\n\t\t\\end{array} \\right],\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nwhere $X_u$ is drag in surge, $Y_v$ is drag in sway and $N_r$ is drag in yaw. The elements that are not on the diagonal of the matrix are ignored.\r\n\\\\\r\n\\\\\r\n$\\boldsymbol{\\tau}_{thr} = [\\tau_{thr,X}, \\tau_{thr,Y}, \\tau_{thr,N}]^{\\top}$ are forces from thrusters in surge, sway and yaw. \r\n$\\boldsymbol{\\tau}_{wind} = [\\tau_{wind,X}, \\tau_{wind,Y}, \\tau_{wind,N}]^{\\top}$ and $\\boldsymbol{\\tau}_{ext} =\r\n [\\tau_{ext,X}, \\tau_{ext,Y}, \\tau_{ext,N}]^{\\top}$ are wind forces and external forces (pipe, winch, etc.) that affects the vessel.\r\n\\\\\r\n\\\\\r\nRotation from vessel coordinates (BODY) to Earth coordinates (NED) can be done with a rotation matrix, $\\boldsymbol{R}(\\psi)$. For three degrees of freedom, this can be written as\r\n\r\n\\begin{equation}\r\n\\label{eq:rotation_matrix}\r\n\\begin{aligned}\r\n\t\\boldsymbol{R}(\\psi) &=\r\n\t\t\\left[ \\begin{array}{ccc}\r\n\t\t\t\\cos(\\psi) &  -\\sin(\\psi) & 0 \\\\\r\n\t\t\t\\sin(\\psi) &  \\cos(\\psi) & 0 \\\\\r\n\t\t\t0 & 0 &  1 \r\n\t\t\\end{array} \\right],\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nwhere $\\psi$ is the heading of the vessel. $\\boldsymbol{\\eta} = [N, E, \\psi]^{\\top}$ is the position in North, East and heading. $\\boldsymbol{\\nu} = [u, v, r]^{\\top}$ \r\nis velocity in surge, sway and yaw.\r\n\r\n\r\n\\section{Thruster model}\r\n\r\nThe force that a single thruster can use can be written as\r\n\r\n\\begin{equation}\r\n\tT = K_T \\rho D^4 n^2,\r\n\\end{equation}\r\n%\r\nwhere $T$ is the thruster force, $\\rho$ is the density of water, $D$ is the diameter of the propeller and $n$ is the rpm of the propeller. $K_T$ is an empirical value that is\r\ndependent on water speed into the propeller and the pitch angle of the propeller. A simplified version can be written as\r\n\r\n\\begin{equation}\r\n\tK_T = K \\cdot \\theta^\\alpha,\r\n\\end{equation}\r\n%\r\nwhere $K$ is a constant, $\\theta$ is pitch angle normalized to 0 $\\rightarrow$ 1 (0\\% $\\rightarrow$ 100\\%) and $\\alpha$ is a constant. Because $K$, $\\rho$ og $D$ are constants\r\nthey can be merged together into one constant. $n$ can also be normalized such that it's between $0$ and $1$: $n_n = K_n \\cdot n$. The final expression for $T$ is then\r\n\r\n\\begin{equation}\r\n\\begin{aligned}\r\n\tT &= K_T \\rho D^4 n^2 \\\\\r\n\t   &= K \\theta^\\alpha D^4 (K_n n_n)^2 \\\\\r\n\t   &= K \\theta^\\alpha D^4 K_n^2 n_n^2 \\\\\r\n\t   &= T_{K} \\cdot \\theta^\\alpha n_n^2,\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nwhere $T_{K} = K D^4 K_n^2$.\r\n%\r\nThis model is suitable for bollard pull condition, i.e. zero water speed through the propeller other than the self-induced speed.\r\n\r\n\\section{Wind model}\r\n\r\n$\\boldsymbol{\\tau}_{wind}$  are wind forces that influence the vessel. The forces can be written as:\r\n\r\n\\begin{equation}\r\n\\label{eq:vindkrefter}\r\n\\begin{aligned}\r\n\t\\boldsymbol{\\tau}_{wind} &=\r\n\t\t\\left[ \\begin{array}{ccc}\r\n\t\t\tq \\cdot C_X \\cdot  A_f \\\\\r\n\t\t\tq  \\cdot C_Y \\cdot A_l \\\\\r\n\t\t\tq  \\cdot C_N \\cdot A_f \\cdot Loa\r\n\t\t\\end{array} \\right],\r\n\\end{aligned}\r\n\\end{equation}\r\n%\r\nwhere $C_X$, $C_Y$ og $C_N$ are wind coefficients (drag coefficients) in surge, sway og yaw, $A_f$ is projected frontal area and $A_l$ is projected lateral area.\r\n$q = \\frac{1}{2} \\cdot \\rho_{air} \\cdot V_{w,r}^2$, where $\\rho_{air}$ is the density of air and $V_r$ is relative wind velocity.\r\n$C_X$, $C_Y$ og $C_N$ are typically found with emprical methods such as Blendermann. These are functions of relative wind velocity.\r\n\r\n\\section{Current model}\r\n\r\n\\end{document}", "meta": {"hexsha": "851b77b4ed07bea433913a437432f8dced35e204", "size": 6118, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/design/model.tex", "max_stars_repo_name": "mika-s/ship-simulator", "max_stars_repo_head_hexsha": "9e4522c29f4bc5709625657477ccf92beb823191", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/design/model.tex", "max_issues_repo_name": "mika-s/ship-simulator", "max_issues_repo_head_hexsha": "9e4522c29f4bc5709625657477ccf92beb823191", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/design/model.tex", "max_forks_repo_name": "mika-s/ship-simulator", "max_forks_repo_head_hexsha": "9e4522c29f4bc5709625657477ccf92beb823191", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7165775401, "max_line_length": 228, "alphanum_fraction": 0.6583850932, "num_tokens": 2045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.41174302069756474}}
{"text": "\\documentclass[twoside]{MATH77}\n\\usepackage{multicol}\n\\usepackage[fleqn,reqno,centertags]{amsmath}\n\\begin{document}\n\\begmath 3.1 Uniform Random Numbers\n\n\\silentfootnote{$^\\copyright$1997 Calif. Inst. of Technology, \\thisyear \\ Math \\`a la Carte, Inc.}\n\n\\subsection{Purpose}\n\nGenerate pseudorandom numbers from the uniform distribution. Capabilities\nare also provided for optionally setting and fetching the ``seed\" of the\ngenerator.\n\n\\subsection{Usage}\n\n\\subsubsection{Generating uniform pseudorandom numbers}\n\nThree subprograms are provided for generation of single precision uniform\nrandom numbers:\n\n\\begin{description}\n\\item[X = SRANU()]  \\ Returns one random number in [0,~1].\n\n\\item[call SRANUA(XTAB, N)]  \\ Returns an array of N random numbers in\n[0,~1].\n\n\\item[call SRANUS(XTAB, N, A, B)]  \\ Returns an array of N numbers scaled\nas A + B $\\times $ U where U is random in [0,~1].\n\\end{description}\n\nCorresponding double precision subprograms are also provided.\n\n\\paragraph{Program Prototype, A Single Random Number, Single Precision}\n\n\\begin{description}\n\\item[REAL]  \\ {\\bf SRANU, X}\n\\end{description}\n$$\n\\fbox{{\\bf X = SRANU()}}\n$$\n\\subparagraph{Argument Definitions}\n\n\\begin{description}\n\\item[SRANU]  \\ [out] The function returns a pseudorandom number from the\nuniform distribution on [0.0,~1.0].\n\\end{description}\n\n\\paragraph{Program Prototype, An Array of Random Numbers, Single Precision}\n\n\\begin{description}\n\\item[INTEGER]  \\  N\n\n\\item[REAL]  \\ {\\bf XTAB}($\\geq $N)\n\\end{description}\n\nAssign a value to N.\n$$\n\\fbox{{\\bf CALL SRANUA(XTAB, N)}}\n$$\nComputed values will be returned in XTAB().\n\n\\subparagraph{Argument Definitions}\n\n\\begin{description}\n\\item[XTAB()]  \\ [out] Array into which the subroutine will store N\npseudorandom samples from the uniform distribution on [0.0,~1.0].\n\n\\item[N]  \\ [in] Number of pseudorandom numbers requested. The subroutine\nreturns immediately if N $\\leq 0.$\n\\end{description}\n\n\\paragraph{Program Prototype, An Array of Scaled Random Numbers, Single\nPrecision}\n\n\\begin{description}\n\\item[INTEGER]  \\ {\\bf N}\n\n\\item[REAL]  \\ {\\bf XTAB}($\\geq $N){\\bf , A, B}\n\\end{description}\n\nAssign values to N, A, and B.\n$$\n\\fbox{{\\bf CALL SRANUS(XTAB, N, A, B)}}\n$$\nComputed values will be returned in XTAB().\n\n\\subparagraph{Argument Definitions}\n\n\\begin{description}\n\\item[XTAB()]  \\ [out] Array into which the subroutine will store N numbers\ncomputed as A + B $\\times $ U, where for each number, U is a pseudorandom\nsample from a uniform distribution on [0.0,~1.0].\n\n\\item[N]  \\ [in] Number of pseudorandom numbers requested. The subroutine\nreturns immediately if N $\\leq 0.$\n\n\\item[A, B] \\ [in] Numbers defining the linear transformation (A + B\n  $\\times$ U) to be applied to the random numbers.\n\\end{description}\n\n\\subsubsection{Modifications for Double Precision}\n\nFor double precision usage change the REAL type statements above to DOUBLE\nPRECISION and change the initial ``S\" of the function and subroutine names\nto ``D.\" Note particularly that if the function name, DRANU, is used it must\nbe typed DOUBLE PRECISION either explicitly or via an IMPLICIT statement.\n\n\\subsubsection{Operations relating to the seed}\n\nThe handling of the seed is modeled on the function RANDOM\\_SEED which is a\nnew intrinsic function introduced in Fortran~90. Random number generation\ndoes not require any initialization calls by the user, but initialization\ncapabilities are provided in case they are wanted.\n\nThe seed for random number generation is a set of KSIZE numbers of type\nINTEGER. The value of KSIZE depends on the algorithm and implementation used\nfor generating uniform random numbers.\n\\begin{description}\n\\item[call RANSIZ(KSIZE)] \\ Returns the value of KSIZE for the current library\nimplementation.\n\n\\item[call RAN1] \\ Sets the seed to its default initial value.\n\n\\item[call RANPUT(KSEED)] \\ Sets the seed to the array of KSIZE values given in\nKSEED().\n\n\\item[call RANGET(KSEED)] \\ Fetches the current seed into the array KSEED().\n\\end{description}\n\nBesides resetting the seed, RAN1 and RANGET set values in common that have\nthe effect of reinitializing all of the pseudorandom number generators of\nChapters~3.1, 3.2 and~3.3.\n\nIf one needs to produce the same sequence of pseudorandom numbers more than\nonce within the same run, a suggested approach is to initialize the package\nat each point in the computation where the sequence is to be started or\nrestarted. One could either use RAN1 to initialize the package to its\nstandard starting seed or use RANPUT to initialize the package to a seed\nselected by the user.\n\nThe seed returned by RANGET may be the seed associated with the next uniform\nnumber that will be returned by the package, but generally this will not be\nthe case. Due to buffering within the package this seed may be associated\nwith a uniform number that will be returned some tens of requests later.\n\nA potential use for the RANGET function would be to assure a different set\nof random numbers on a subsequent run. Thus one could use RANGET at the end\nof a run and write to a file the seed value returned by RANGET. Then on a\nsubsequent run one could read this seed from the file and use RANPUT to\ninitialize the package to this seed value. This would assure a new sequence\nof numbers.\n\n\\paragraph{Program Prototype, Get the value of KSIZE}\n\n\\begin{description}\n\\item[INTEGER]  \\ {\\bf KSIZE}\n\\end{description}\n$$\n\\fbox{{\\bf CALL RANSIZ(KSIZE)}}\n$$\nA value will be returned in KSIZE.\n\n\\subparagraph{Argument Definitions}\n\n\\begin{description}\n\\item[KSIZE]  \\ [out] The subroutine sets KSIZE to the number of integers\nneeded to constitute a seed for the current library implementation of a\nrandom number generation algorithm. The user should use this information to\nverify that the dimension of the array KSEED() is adequate before calling\nRANPUT or RANGET. The preferred algorithm in the MATH77 library has KSIZE =\n2. If this is replaced by a different algorithm KSIZE could change.\n\\end{description}\n\n\\paragraph{Program Prototype, Set seed to default value}\\vspace{-10pt}\n$$\n\\fbox{{\\bf CALL RAN1}}\n$$\n\\subparagraph{Argument Definitions}\n\nThis subroutine has no arguments. It causes the seed stored in the random\nnumber generation code to be reset to its default initial value. It also\nsets values in common that have the effect of reinitializing all of the\npseudorandom number generators of Chapters~3.1, 3.2, and~3.3.\n\n\\paragraph{Program Prototype, Set the seed}\n\n{\\bf INTEGER} {\\bf KSEED}($\\geq $KSIZE)\n\nAssign values to KSEED().\n$$\n\\fbox{{\\bf CALL RANPUT(KSEED)}}\n$$\n\\subparagraph{Argument Definitions}\n\n\\begin{description}\n\\item[KSEED()] \\ [in] Array of KSIZE integers to be used to set a new seed value. Any\ninteger values are acceptable. If the given values do not conform to\ninternal requirements the subroutine will derive usable values from the\ngiven values.\n\\end{description}\n\nIn the preferred MATH77 implementation the internal integer sequence\nconsists of numbers in the range from~1 to~68719476502. For example, to set\nthe seed to the value 10987654321 one should set KSEED(1) = 109876 and\nKSEED(2) = 54321. In general RANPUT will compute KSEED(1$) \\times 10^5 +\n\\text{KSEED}(2)$ using either single precision or double precision\narithmetic, depending on the ``mode\"\ndescribed in Section D, and then alter the result, if necessary, to obtain a\nseed in the range from~1 to~68719476502.\n\nThis subroutine also sets values in common that have the effect of\nreinitializing all of the pseudorandom number generators of Chapters~3.1,\n3.2, and~3.3.\n\n\\paragraph{Program Prototype, Get the seed}\n\n{\\bf INTEGER} {\\bf KSEED}($\\geq $KSIZE)\n$$\n\\fbox{{\\bf CALL RANGET(KSEED)}}\n$$\nValues will be returned in KSEED(). See the discussion at the beginning of\nSection B.2 for information on the applicability of this subprogram.\n\n\\subparagraph{Argument Definitions}\n\nKSEED() [out] Array into which the subroutine will store the KSIZE integers\nconstituting the current seed.\n\n\\subsection{Examples and Remarks}\n\nDRSRANU demonstrates the use of SRANU to compute uniform random numbers and\nuses SSTAT1 and SSTAT2 to compute and print statistics and a histogram based\non a sample of~10000 numbers delivered by SRANU.\n\nThe uniform distribution on [0,~1] has mean 0.5 and standard deviation $%\n\\sqrt{1/12} \\approx 0.288675.$\n\nThe smallest number that can be produced by SRANU, DRANU, SRANUA, or DRANUA\nis approximately $0.15 \\times 10^{-10}$. The largest value that can be\nproduced is approximately $1.0 - 0.15 \\times 10^{-10}$. The single precision\nsubprograms SRANU and SRANUA will return this largest value as exactly 1.0\non many computer systems.\n\nDRDRAN provides a critical test of the correct performance of the\ncore integer sequence generator on whatever host system it is run.\nThe seed values are set to cause the generation of the largest and\nsmallest numbers possible in the underlying integer sequence. This\nprogram is expected to generate exactly the same values in the column\nheaded ``Integer sequence\" on all compiler/computer systems. DRDRAN\nalso calls RN2 to show the value of MODE (described below in Section\nD) being used on the host system. See the output listing, ODDRAN, for\nresults.\n\nTo compute random numbers, uniform in [C, D], one can use the statement\n\n\\hspace{.2in}X =C + (D $-$ C) * SRANU()\n\nor to put N such numbers into an array XTAB() one can write\n\n\\hspace{.2in}call SRANUS(XTAB, N, C, D $-$ C)\n\nTo compute random INTEGER's in the range from I1 through I2, (I1 $<$ I2),\nwith equal probability, one can write\n\\begin{tabbing}\n\\hspace{.2in}\\=FAC = real(I2 $-$ I1 + 1)\\\\\n\\>K = min(I2, I1 + int(FAC * SRANU() ) )\n\\end{tabbing}\nThe min function is used in the above statement because SRANU will, with\nvery low probability, return the exact value~1.0.\n\nIf one needs to compute many random numbers and execution time is critical,\none should note that one call to SRANUA with a sizeable value of N will take\nless execution time than N references to SRANU. For even greater efficiency\none could write the random number generation in line, since it only requires\na few declarations and a few executable statements. When and if Fortran~90\ncompilers come into widespread usage it will probably be more efficient to\nuse the new intrinsic subroutine RANDOM\\_NUMBER, although this subroutine is\nnot specified to generate the same sequence on different computers.\n\n\\subsection{Functional Description}\n\n\\subsubsection{The core algorithm for generation of uniform pseudorandom\nnumbers}\n\nA sequence of integer values, $k_i$, is generated by the equation\n\\begin{equation}\n\\label{O1}k_i = ak_{i-1}\\text{ mod }\\ m\n\\end{equation}\nThe rational number, $k_i/m$, is returned as a pseudorandom number from the\nuniform distribution on [0,~1].\n\nWhen $m$ is prime and $a$ is a primitive root of $m$, this integer\nsequence has period $m-1$, attaining all integer values in the range [1,\n$m-1]$.  According to \\cite{Knuth:1981:ACP}, this sequence will have good\nequidistribution properties, at least in dimensions up to $d$, if the\nnumbers $\\nu _i$ and $\\mu _i$, $i = 2$, ..., $d$, that are functions of\n$m$ and $a$, are not exceptionally small.  Finding satisfactory values of\n$\\nu _i$ and $\\mu _i$ is simplified by having $m$ large and $a$ not too\nsmall.  The size of $m$ and $a$ is limited however by the requirement of\ncomputing Eq.\\,(1) exactly at a reasonable cost.\n\nWe have determined a pair of integers $m$ and $a$ that satisfy all these\nrequirements.  The values of $\\nu _i$ and $\\mu _i$, $i = 2$, ..., 6,\nattained are excellent compared with any of the 30 $(m, a)$ pairs listed\nin Table~1, pp.~102--103 of \\cite{Knuth:1981:ACP}, which includes pairs\nused in a number of widely distributed random number generation\nsubprograms.  We use the values $$ \\text{MDIV} = m = 6\\_87194\\_76503 =\n2^{36} - 233 $$ and $$ \\text{AFAC} = a = 612\\_662 \\approx 0.58 \\times\n2^{20} $$ The number $m-1$ is the product of three primes, $p(i)$, listed\nhere with other relevant number-theoretic values.\n\n\\begin{tabular}{rrrr}\n$i$ & $p(i)$ & $q(i) = (m-1)/p(i)$ & $a^{q(i)}$ mod $m$\\\\\n1 & 2 & 3\\_43597\\_38251 & $m-1$\\\\\n2 & 43801 & 15\\_68902 & 2\\_49653\\_21011\\\\\n3 & 784451 & 87602 & 1\\_44431\\_31136\n\\end{tabular}\n\nThe fact that values in the last column above are not~1 verifies that $a$ is a\nprimitive root of $m.$\n\nThe values of $\\mu _i$ and log~base~2 of $\\nu _i$ are\n\n\\begin{tabular}{r@{\\ }c@{\\ }r@{\\ \\ }r@{\\ \\ }r@{\\ \\ }r@{\\ \\ }r}\n$(Log_2 \\nu _i,\\ i=2,6)$ & = & 18.00, & 12.00, & 8.60, & 7.30, & 6.00\\\\\n$(\\mu _i$, $i=2,6)$ &      = &  3.00, &  3.05, & 3.39, & 4.55, & 6.01\n\\end{tabular}\n\nThese values may be compared with Table~1, pp.~102--103,\n\\cite{Knuth:1981:ACP}, that lists the same measures for a number of other\nrandom number generators.\n\nThis package contains both a short and a long algorithm to implement Eq.\\,(1).\nLet XCUR be the program variable containing the current value of $k_i$ of\nEq.\\,(1). The short algorithm for advancing XCUR is\n\n\\hspace{.2in}XCUR = mod(AFAC * XCUR, MDIV).\n\nThe long algorithm, using ideas from \\cite{Wichmann:1982:AEP}, is\n\n\\begin{tabbing}\n\\hspace{.2in}\\=Q = aint(XCUR/B)\\\\\n\\>R = XCUR $-$ Q * B\\\\\n\\>XCUR = AFAC * R $-$ C * Q\\\\\n\\>do while(XCUR .lt. 0.0)\\\\\n\\>\\ \\ \\ \\ XCUR = XCUR + MDIV\\\\\n\\>end do\n\\end{tabbing}\n\nwhere B and C are constants related to MDIV and AFAC by MDIV = B $\\times $\nAFAC + C. We use B = 112165 and C = 243273. The average number of executions\nof the statement XCUR = XCUR + MDIV is 1.09 and the maximum number of\nexecutions is~3.\n\nThe largest number that must be handled in the short algorithm is the\nproduct of AFAC with the maximum value of XCUR, $i.e., 612\\_662 \\times\n6\\_87194\\_76502 = 42\\_10181\\_19126\\_68324 \\approx 0.58 \\times 2^{56}$. Thus,\nthe short algorithm requires arithmetic exact to at least 56~bits.\n\nThe largest number that must be handled in the long algorithm is the product\nof C with the maximum value of aint(XCUR/B), $i.e., 243273 \\times 612664 \\approx\n0.14904 \\times 10^{12} \\approx 0.54 \\times 2^{38}$. Thus the long algorithm requires\narithmetic exact to at least 38~bits.\n\nTo accommodate different compiler/computer systems this program unit\ncontains code for~3 different ways of computing the new XCUR from the old\nXCUR, each producing the same sequence of values. Initially we have MODE $=\n1 $. When MODE $= 1$ the code does tests to see which of the three\nimplementation methods will be used, and sets MODE $= 2$, 3, or~4 to\nindicate the choice.\n\nMode~2 will be used in machines such as the Cray that have at least a 38~bit\nsignificand in single precision arithmetic. XCUR will be advanced using the long algorithm\nin single precision arithmetic.\n\nMode~3 will be used on machines that don't meet the Mode~2 test, but can\nmaintain at least 56~bits exactly in computing mod(AFAC $\\times $ XCUR,\nMDIV) in double precision arithmetic. This includes VAX, UNISYS, IBM~30xx, and some IEEE\nmachines that have clever compilers that keep an extended precision\nrepresentation of the product AFAC $\\times $ XCUR within the math processor\nfor use in the division by MDIV. XCUR will be advanced using the short\nalgorithm in double precision arithmetic.\n\nMode~4 will be used on machines that don't meet the Mode~2 or~3 tests, but\nhave at least a 38~bit significand in double precision arithmetic. This includes IEEE\nmachines that have not-so-clever compilers. XCUR is advanced using the long\nalgorithm in double precision arithmetic.\n\nIf a user wishes to know which mode has been selected, the statement\n$$\n\\fbox{{\\bf CALL RN2( MODE )}}\n$$\ncan be used after at least one access has been made to one of the random\nnumber generators or to RANPUT or RANGET. This call will set the integer\nvariable MODE to the mode value of~2, 3, or~4 that the package is using.\n\n\\subsubsection{Remarks on alternative algorithms}\n\nFrom \\cite{Learmonth:1973:STS} and \\cite{Learmonth:1976:ETM} it appears\nthat a multiplicative congruential generator of the form of Eq.\\,(1) using\nthe values MDIV $= 2147483647 = (2^{31}) - 1$ and AFAC $= 16807 = 7^5\n\\approx 0.513 \\times 2^{15}$ has been widely used, and is quite\nsatisfactory.  However, the associated values of $\\mu _i$ and $\\nu _i$ are\nsmaller than those associated with the MDIV and AFAC we are using.  With\nthese values, XCUR would take all integer values in [1,\\ MDIV $-$ 1].  The\nmaximum value of the product, AFAC $\\times $ XCUR would be approximately\n$0.361 \\times 10^{14} \\approx 0.51 \\times 2^{46}$, so at least 46-bit\narithmetic would be needed.\n\nThe method of \\cite{Wichmann:1982:AEP} is interesting in that it\nillustrates techniques for getting a very long period generator\n$(0.36\\times 10^{14} \\approx 0.51 \\times 2^{46})$ using relatively\nlow-precision arithmetic.  This method uses at least three integer mod\noperations, three integer multiplications, three floating divisions, two\nfloating additions, and a floating mod; there does not appear to be any\ntheoretical measure of the quality of the sequence, such as the $\\mu _i$\nand $\\nu _i$ described in \\cite{Knuth:1981:ACP}.\n\n\\subsubsection{Organization of the package}\n\nThe basic uniform pseudorandom number generation algorithm for the MATH77\nlibrary is contained in the program unit RANPK2 that returns an array of N\nnumbers when called at any one of the entry points, SRANUA, SRANUS, DRANUA,\nor DRANUS. A single sequence of pseudorandom integers is managed within this\nprogram unit. Calling any of these four entry points will cause updating of\nthis single pseudorandom integer sequence. The other random number\nsubprograms in Chapters~3.2 and~3.3 depend on uniform pseudorandom numbers\nobtained by calling SRANUA or DRANUA.\n\nThe function SRANU is a separate program unit. SRANU references common\nblocks that contain a REAL buffer array of length~97, and an index into the\narray. If the value of the index indicates the buffer contains unused random\nnumbers, SRANU simply decrements the index and returns the next number from\nthe buffer. If the index indicates the buffer is empty, SRANU calls SRANUA\nto fill the buffer with uniform random numbers and then reinitializes the\nindex and returns one random number.\n\nThe common blocks are also referenced and used in this way by other random\nnumber subprograms needing single-precision uniform random numbers: SRANE,\nSRANG, SRANR, and IRANP.\n\nThe double-precision subprograms, DRANU, DRANE, DRANG, and DRANR share\nreference to a different common block that is used similarly to buffer an\narray of double-precision uniform pseudorandom numbers.\n\nRAN1 and RANPUT are entries in a program unit RANPK1. When either of these\nentries is called, the pointers in common will be set to indicate the empty\nstate and a call will be made to the appropriate one of two private entry\npoints in program unit RANPK2 to make the requested change in the seed.\n\nRANSIZ and RANGET are entries in RANPK2 that simply return stored values, a\nconstant in the case of RANSIZ, and a variable integer array in the case of\nRANGET.\n\n\\subsubsection{Accuracy tests}\n\nWe have run tests of equidistribution in~1, 2, and~3 dimensions, as well\nas the run test and gap test described in \\cite{Knuth:1981:ACP}.  Results\nwere satisfactory.  The main basis for confidence in this algorithm is the\nnumber-theoretic properties of the pair $(m,a)$ described above.\n\nValues returned as double-precision random numbers will have random bits\nthroughout the word, however the quality of randomness should not be\nexpected to be as good in a low-order segment of the word as in a high-order\npart.\n\n\\bibliography{math77}\n\\bibliographystyle{math77}\n\n\\subsection{Error Procedures and Restrictions}\n\nIf the argument N in SRANUA, SRANUS, DRANUA, or DRANUS is nonpositive the\nsubroutine will return immediately and make no reference to the array XTAB().\n\nWhen using RANPUT or RANGET, the user must assure that the array, KSEED(),\nhas an adequate dimension. Violation of this condition will have\nunpredictable effects. The user can call RANSIZ to determine the required\ndimension.\n\nIf none of the three modes of computation (See MODE $= 2$, 3, or~4 in\nSection~D.) succeeds, the program unit RANPK2 will write an error message\ndirectly to the system output unit and stop. This is unlikely, as it would\nonly happen if the host system cannot at least do exact 38-bit arithmetic in\ndouble precision.\n\n\\subsection{Supporting Information}\n\nThe source language is ANSI Fortran~77.\n\n\\begin{tabular}{@{\\bf}l@{\\hspace{5pt}}l}\n\\bf Entry & \\hspace{.35in} {\\bf Required Files}\\vspace{2pt} \\\\\nDRANU & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nDRANU, ERFIN, ERMSG, RANPK1, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nDRANUA & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nDRANUS & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nRAN1 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK1, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nRANGET & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nRANPUT & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK1, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nRANSIZ & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nRN2 & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nSRANU & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK1, RANPK2, SRANU\\rule[-5pt]{0pt}{8pt}}\\\\\nSRANUA & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2\\rule[-5pt]{0pt}{8pt}}\\\\\nSRANUS & \\parbox[t]{2.7in}{\\hyphenpenalty10000 \\raggedright\nERFIN, ERMSG, RANPK2}\\\\\\end{tabular}\n\nDesigned by C. L. Lawson and F. T. Krogh, JPL, April~1987. Programmed by C.\nL. Lawson and S. Y. Chiu, JPL, April, 1987. November~1991: Lawson redesigned\nRANPK2 to have MODES~2, 3, and~4 for better portability. Also reorganized\nand renamed common blocks.\n\n\n\\begcodenp\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRSRANU}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{sranu}}\n\\newpage\n\\vspace{30pt}\\centerline{\\bf \\large ODSRANU}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{sranu}}\n\n\n\\newpage\n\\enlargethispage*{30pt}\n\\lstset{language=[77]Fortran,showstringspaces=false}\n\\lstset{xleftmargin=.8in}\n\n\\centerline{\\bf \\large DRDRAN}\\vspace{10pt}\n\\lstinputlisting{\\codeloc{dran}}\n\\newpage\n\\vspace{30pt}\\centerline{\\bf \\large ODDRAN}\\vspace{10pt}\n\\lstset{language={}}\n\\lstinputlisting{\\outputloc{dran}}\n\n\\end{document}\n", "meta": {"hexsha": "4f804021f089874b85a3ffbc56712b7adeed8846", "size": 22434, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doctex/ch03-01.tex", "max_stars_repo_name": "jacobwilliams/math77", "max_stars_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2016-01-04T03:17:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T19:17:42.000Z", "max_issues_repo_path": "doc/doctex/ch03-01.tex", "max_issues_repo_name": "jacobwilliams/math77", "max_issues_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-01-17T02:48:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T16:04:58.000Z", "max_forks_repo_path": "doc/doctex/ch03-01.tex", "max_forks_repo_name": "jacobwilliams/math77", "max_forks_repo_head_hexsha": "b562d09e191e99eba8a5bedfec45acf7461203b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-01-07T09:26:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-25T05:32:54.000Z", "avg_line_length": 41.012797075, "max_line_length": 98, "alphanum_fraction": 0.7554604618, "num_tokens": 6508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4116988877478428}}
{"text": "%\\setcounter{page}{900}\n\n\\chapter{Applications of Definite Integrals I: General Arguments\n\\label{AppsDefIntegrals}}\n\nHere we look at many further quantities which give rise to \nantidifferentiation.  \n\n\n\n\nMost modern calculus textbooks contain numerous excellent examples\nof applications of definite integrals.  Indeed, most examples\nwhich are likely to be seen in further studies of the physical\nsciences can trace back to calculus textbook-type problems.\n\nHere we will make an attempt to accomplish the presentations\nof the usual topics, and others.  We will also \ndo the following:\n\n\\begin{enumerate}\n\\item Re-introduce the notion of infinitesimals into the\nphysical analysis of these problems.  This was a traditional\napproach which has fallen out of favor.  While we will refer\nback to the Riemann sums for each case, that will be more\nfor a ``spot-check'' of the reasoning behind the infinitesimals,\nand perhaps some proofs.  However, the first introduction to \nmost topics will be through infinitesimals.  Besides, they\nmake for prettier pictures!\n\nStudents are unlikely to be inspired by the Riemann sum proofs,\nwhich are often used to show that the quantity represented\nby the integral has the integrand as derivative.  The proofs\nare technical, and leave a student to believe he would never\ncome up with it himself.  The differentials ``cut to the chase,''\nand can be proved later after guessed, rather than derived from \nRiemann sums.\n\n\\item Finite Riemann sums used for numerical approximations of\nthe quantities involved.  This contains all the intuition\n(short of the proofs) contained in the most textbook developments\nof these integrals.\n\n\\item Explanations of why some guesses for the infinitesimals\nwill not work.\n\n\\item Explanation of how to tell---by sight---if a particular\ndifferential is correct, and whether the Riemann sum form\nwill actually converge to the desired quantity as the partition\nis refined.\n\\end{enumerate}\n\n\n\n\n\n%Recall that we already gave one argument for two situations where\n%a given quantity can be represented by a definite integral:\n%\\begin{align}\n%   s\\left(t_f\\right)-s\\left(t_0\\right)\n%        &=\\int_{t_0}^{t_f}a(t)\\,dt,\\label{S(T_F)-S(T_O)ForDefIntI}\\\\\n%   v\\left(t_0\\right)-v\\left(t_0\\right)\n%        &=\\int_{t_0}^{t_f}a(t)\\,dt.\\label{V(T_F)-V(T_O)ForDefIntI}\n%\\end{align}\n%This was just the working definition\n%of the definite integral, \n%\\begin{equation}\\int_a^bf(x)\\,dx=F(b)-F(a),\\label{FundTheoremAsWorkingDef}\n%\\end{equation} \n%assuming $f(x)$ is continuous on $[a,b]$ and $F'(x)=f(x)$ on $[a,b]$.\n%As a matter of fact, (\\ref{FundTheoremAsWorkingDef}) is not the actual\n%definition of the definite integral $\\int_a^bf(x)\\,dx$.  Indeed,\n%the definition is more complicated.  However, it is quite useful.\n\n\n\\section{Riemann Sums and Approximations of Cumulative Quantities}\n\nSuppose we had some data on the velocity of an object, and\nwe wish to approximate its net displacement over a time interval.\nSuppose the data we have is the following:\n\n%\\begin{tabular}{m{.4in}|m{.3in}|m{.3in}|m{.3in}|m{.3in}|m{.3in}|%\n%m{.3in}|m{.3in}|m{.3in}|m{.3in}|m{.3in}|}\n%\\cg $t=$&\\cg0&\\cg1&\\cg2&\\cg2.5&\\cg3&\\cg4&\\cg6&\\cg7&\\cg8.5&\\cg10%\\\\\n%\\cg $v=$&\\cg10.9&\\cg9.6&\\cg8.9&\\cg8.775&\\cg8.8&\\cg9.3&\\cg12.1&\\cg14.4\n%               &\\cg18.975&\\cg24.9\n%\\end{tabular}\n\n\n\\section{Other Complications}\nConsider cases where the function is only piecewise continuous,\nand try to recover a continuous antiderivative.\nConsider, perhaps, some cases from electricity and magenetism\nregarding fields or potentials across interfaces.\n\nConsider two ``antiderivatives'' of \n$$f(x)=\\left\\{\\begin{aligned}1,\\qquad&x>0,\\\\\n                           -1,\\qquad x<0.\\end{aligned}\\right.\n$$\nOne is continuous, the other not.\n\nCan always recover a continuous antiderivative from a piecewise continuous\nfunction, so long as we don't have vertical asymptotes, for instance.\n", "meta": {"hexsha": "94b859275ab656e82a28667dac7ce9522f5490f0", "size": 3880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "michael.dougherty/chapter08.tex", "max_stars_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_stars_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "michael.dougherty/chapter08.tex", "max_issues_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_issues_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "michael.dougherty/chapter08.tex", "max_forks_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_forks_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6699029126, "max_line_length": 75, "alphanum_fraction": 0.7466494845, "num_tokens": 1107, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.41169888389457354}}
{"text": "\\section{KFAC: Block-diagonal inverse approx, $\\breve{F}^{-1} \\approx \\tilde{F}^{-1}$}\n\\frame{\\tableofcontents[currentsection, hideothersubsections]}\n\n\\begin{frame}\n\\frametitle{KFAC: Block-diagonal inverse approx, $\\breve{F}^{-1} \\approx \\tilde{F}^{-1}$}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.275]{kfac_08}\n\\end{figure}\nNOTE: this is equivalent to approximating Fisher itself as block-diagonal\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{KFAC: Block-diagonal inverse approx, $\\breve{F}^{-1} \\approx \\tilde{F}^{-1}$}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.275]{kfac_09}\n\\end{figure}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{KFAC: Block-diagonal inverse approx, $\\breve{F}^{-1} \\approx \\tilde{F}^{-1}$}\n{\\footnotesize\nLeft to right: \\\\\n$\\tilde{F}^{-1}$, its approximations $\\breve{F}^{-1}$ (top) and $\\hat{F}^{-1}$ (bottom), their absolute difference\n}\n\\begin{figure}\n    \\centering\n    \\includegraphics[scale=0.225]{kfac_12}\n\\end{figure}\n\\end{frame}\n\n% \\begin{frame}\n% \\frametitle{KFAC: Block-diagonal inverse approx, $\\breve{F}^{-1} \\approx \\tilde{F}^{-1}$}\n% Left to right: \\\\\n% $\\tilde{F}$, its approximations $\\breve{F}$ (top) and $\\hat{F}$ (bottom), their absolute difference\n\n% \\begin{figure}\n%     \\centering\n%     \\includegraphics[scale=0.175]{kfac_10}\n% \\end{figure}\n\n% \\begin{itemize}\n%     \\item the off-tridiagonal blocks of the bottom right matrix, while being very close to zero, are\n%     actually NON-zero (hard to see from the plot)\n%     % \\item the plot is of the absolute values of the entries\n% \\end{itemize}\n% \\end{frame}\n", "meta": {"hexsha": "5dca4fa4703fdc2db24705be53acb74f105313a7", "size": 1577, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "talk/tor/kfac-20180824/kfac2.tex", "max_stars_repo_name": "tttor/robot-foundation", "max_stars_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "talk/tor/kfac-20180824/kfac2.tex", "max_issues_repo_name": "tttor/robot-foundation", "max_issues_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "talk/tor/kfac-20180824/kfac2.tex", "max_forks_repo_name": "tttor/robot-foundation", "max_forks_repo_head_hexsha": "779b0d9583fe0f4c582f03b808dd2b7027088493", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1836734694, "max_line_length": 114, "alphanum_fraction": 0.6823081801, "num_tokens": 534, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.41169887793679893}}
{"text": "\\title{Self Organizing Systems Exercise 1}\n\\author{\n        Alexander Dobler 01631858\\\\\n        Thomas Kaufmann 01129115 \n}\n\\date{\\today}\n\n\\documentclass[12pt]{article}\n\n\\usepackage{hyperref}\n\\usepackage{booktabs}\n\\usepackage{graphics}\n\\usepackage{multirow}\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{mwe}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction \\& Problem Description}\nFor exercise 1 of self-organizing systems we chose the task \\textit{Sequence alignment for Genetic Data (DNA Lattice) Anonymization} in which we should solve the DNA lattice anonymization described in \\cite{mainpaper} with two metaheuristic techniques from the lecture.\nThe task is to find a pairing of DNA sequences, such that the sum of distances between two DNA sequences of a pair over all pairs is as small as possible.\n\nMore specifically we are given a set of $n$ sequences described by strings which can have different length.\nIn a first step we have to align these sequences, such that all sequences have the same length.\nThis is done by introducing \\textit{gap}-characters to increase the length of sequences.\nIn general this process is called multiple sequence alignment (MSA) and we do not describe how this is done here, but rather use a library as a black-box tool for this step.\nNow, that every sequence has the same length, we can compute the distance between two sequences as described in \\cite{mainpaper}.\nThe last and main step is to combine this set of sequences into pairs, such that the sum of distances of two sequences of a pair summed up over all pairs is minimal.\nObviously this is just an application of minimal weighted matching in a complete graph, where a graph is represented by $G=(V,E)$ as follows.\nThe set $V$ of nodes are described by the sequences and the set $E$ of edges is $V\\times V$.\nFor an edge $e=\\{u,v\\}$ its weight $w(e)$ is just the distance between the sequences $u$ and $v$. \nWe denote by $M \\subset E$ a complete matching on a graph $G$, s.t. $2 \\times |M| = |V|$, and by $c(M)$ the corresponding weight of the matching.\n\nIn the next sections we describe our solution approaches and main results.\n\n\\section{Test Data \\& Preprocessing}\n\\label{sec:test-data}\nAs base set of data we chose DNA sequences from \\url{https://www.kaggle.com/neelvasani/humandnadata} which consists of over 4000 human DNA sequences.\nIn a next step we created multiple instances of different size by selecting 10-300 random samples of these sequences.\nTest-case sizes are always even, such that we do not have to bother about the leftover single sequence.\nFor each of these instances we performed some preprocessing with the python module \\textit{Bio.SeqIO} from the package \\textit{Bio} (\\url{https://biopython.org/wiki/SeqIO}) and as suggested in ~\\cite{mainpaper} compute multiple sequence alignments with the MSA-toolkit \\emph{ClustalW}~\\cite{clustalw}. \nIn the last step we compute the cost-matrix between pairs of sequences as described in \\cite{mainpaper}.\nAll of the algorithms described in the next section only use the cost-matrix to compute a pairing.\nAlthough we chose instances of sizes comparable to the work of Bradley~\\cite{mainpaper}, as shown below, instances turned out being relatively easy to solve where even the relatively simple construction heuristic obtains high quality solutions in little to no execution time. We then further investigated this behavior in more depth and found that a specially structured cost matrix due to the tree-based alignment procedure in \\emph{ClustalW} often leads to edge-costs of $0$ between specific pairs in the graph, inherently favouring the nature of the DNALA construction heuristic. \n\nThese test-cases can be found in the project under the folder \\textit{data}:\nSequence alignments for each test-case are stored in the files \\textit{human\\_data\\_XX.fasta} where \\textit{XX} denotes the size of the test-case.\nSimilarly \\textit{human\\_data\\_XX.cm} stores the cost-matrices in \\textit{pickle}-format (\\url{https://docs.python.org/3/library/pickle.html}).\n\n\\section{DNALA \\& Exact Method}\nWe provide two preliminary methods to solve this problem which are used to benchmark the metaheuristik techniques:\n\\begin{itemize}\n    \\item An implementation of the DNALA algorithm as described in \\cite{mainpaper} can be found in the \\textit{algorithms} directory.\n    We did implement the described randomness, but do not use multiple runs of the algorithm, but instead only run the algorithm for a testset once to determine its capability.\n\n    \\item As DNALA is only a heuristic and is not guaranteed to find an optimal solution we furthermore use a maximum weighted matching implementation provided by the package \\textit{networkx} (\\url{https://networkx.org/documentation/stable//index.html}) to compute an exact solution used for optimality gaps in benchmarking.\n\\end{itemize}\n\n\\section{Genetic Algorithm}\nThe first metaheuristic technique with which we solve the problem is a genetic algorithm.\nFor this we use the \\textit{deap}-package for python (\\url{https://deap.readthedocs.io/en/master/}) which provides a framework for creating genetic algorithms.\nThe well-know genetic algorithm compononents are implemented as follows:\n\\begin{itemize}\n    \\item \\textbf{Solution representation}: A solution consists of $\\frac{n}{2}$ pairs such that each node (sequence) appears in exactly one pair.\n    \\item \\textbf{Fitness}: The fitness is just the sum of distances between pairs of points. \n    This in fact also represents the value of the corresponding weighted matching.\n    \\item \\textbf{Crossover}: Given a pair of individuals $M_i$ and $M_j$, we derive a successor individual $M_{i'}$ with the following procedure:\n    \\begin{enumerate}\n    \t\\item Select a subset $M'_i \\subset M_i$ of matchings from individual $M_i$, where each edge $e \\in M_i$ is selected with a probability of $0.5$. \n    \t\\item We then try to identify matchings $e \\in M_j$ composed of edges not contained in $M'_i$, which are entirely preserved for the offspring $M_{i'}$.\n    \t\\item Finally, we identify the remaining unmatched vertices and pair them randomly. \n    \\end{enumerate}\n    It is worth to notice that different variations of this approach were tested, considering orders of matchings in the solution representation as well as alternative strategies to pair remaining vertices, but no significant improved was obtained. \n    \\item \\textbf{Mutation}: Given an individual $M$, selects a random pair $e=\\{u,v\\}$, $e'=\\{u',v'\\} \\in M$ of matchings based on a given mutation probability and constructs an offspring $M'$ by performing 1) an arbitrary or 2) the best two-opt in the subgraph induced by vertices $V=\\{u,v,u',v'\\}$. Experiments showed slight advantages for the intensifying mutation approach (i.e. the best two-opt neighbour) at only a negligible increase in computational cost. \n\\end{itemize}\nFurthermore we used a tournament selection strategy with tournament size of $k=3$ and have the option to select different population sizes and mutation rates for running the algorithm.\n\n\\section{Ant Colony Optimization}\nAt first we did not know how to solve the problem with ant colony optimization.\nBut then we realized that a weighted matching in a complete graph is just a tour visiting every vertice, where every second edge will have weight 0.\nThis was really convenient, as ant colony optimization is well-known to perform well on the TSP-problem.\nFurthermore there are a lot of implementations available, which provide ACO-methods to solve the TSP-problem.\nFor our purposes it was enough to alter the implementation provided by the \\textit{pants}-package (\\url{https://pypi.org/project/ACO-Pants/}) in a way, such that we could solve the minimum weighted matching problem.\n\nOur alteration can be described as follows.\nWhen solving the TSP-problem every ant starts at a specific node and tries to find a best tour.\nThis means that at a specific point of the algorithm each ant has currently visited an acyclic path.\nNow this path has either even or odd length.\nThis means when an ant can chose its next edge there are two different strategies:\n\\begin{itemize}\n    \\item If the path until now has even length, then choose the usual strategy to select the next node to visit (pheromones in ACO with $\\alpha$- and $\\beta$-values).\n    \\item If the path until now has odd length, then go to any not yet visited node.\n    This resembles the fact that every other edge of the tour will have weight 0.\n\\end{itemize}\nOf course we also have to alter the cost of a tour, in particular that every other edge has weight 0, to guide the algorithm to an optimal solution.\n\nOne might think that this construction of an algorithm to solve the minimum weighted matching problem is pretty superficial, but we will see that its performance is not too bad.\n\n\\section{Local Search}\nWhile population based metaheuristics are usually great to identify high quality solution components in widely distributed solution spaces, they tend to end up in suboptimal regions, where simple intensification procedures like local search heuristics can significantly improve the solution quality. To this end, it is so common that population based metaheuristics are combined with local search procedures that for genetic algorithms the term \\emph{memetic algorithm} has been established in the literature. In this work, we used a relatively simple two-opt neighbourhood structure with a constant time neighbour evaluation scheme and a first-improvement step function to improve populations of both the ACO as well as the GA. \n\n\\section{Results \\& Conclusion}\nTo evaluate the described approaches, experiments with a set of $12$ differently sized instances were run for different kinds of algorithm configurations. \nWe used the optimality gap as a scale invariant performance measure describing the relative distance to the global optimum. \nAs for particularly large instances, some configurations did converge towards the global optimum.\nAll experiments were run with a wallclock time of $300 s$ and $5$ repetitions each for statistical stability. Execution times do not include preparation time of cost matrices, since they have been precomputed and stored for reuse. All experiments were run on a Windows 10 machine with AMD Ryzen 3700X CPU in single-threaded mode. \n\n\\subsection{Comparison of GA, ACO and DNALA}\n\nTable~\\ref{tab:main} compares both the GA as well as the ACO to the DNALA baseline, where we show the median values, for the optimality gap, the execution time as well as the iteration where the best solution was obtained. \n\nMain observations:\n\\begin{itemize}\n\t\\item Purely population-based metaheuristic approaches work quite well for moderate sized instances, but solution quality declines significantly with increasing instance sizes. While for smaller instances, some instances could even be solved to optimality, for large instances the gap increases even above $100\\%$ optimality gap. \n\t\\item Both approaches show the same behaviour with respect to the overall number of iterations conducted in the given period, where in smaller instances optimal solutions are obtained relatively fast and as the instance size increases, also the number of iterations until premature termination due to optimality increases. At some point, however, instances become more difficult and more expensive in terms of computational cost, such that the iteration count then steadily decreases, which in turn also affects solution quality. \n\t\\item It can be observed that our GA does not suffer from premature convergence as the iteration where the best solution was obtained tends to be close to the overall iteration count. This suggests that more iterations could still improve the solution quality. \n\t\\item Local search generally improves quality significantly, allowing to solve even larger instances almost to optimality. However, iteration count drops to a level suggesting our GA being basically just a \\emph{fancy} random restart procedure. \n\t\\item The effectiveness of two-opt local search\tbacks up our observation of the biased instance generation procedure with \\textit{ClustalW} mentioned in Section~\\ref{sec:test-data}, since this simple neighborhood is able to identify the respective pairs of minimal cost easily. Furthermore, DNALA + LS seems to be quite good combtination \n\\end{itemize}\n\n\\begin{table}\n\\centering\n\\resizebox{\\columnwidth}{!}{%\n\\begin{tabular}{llr|rrrrr|rrrrr}\n\\toprule\n   &     &          & \\multicolumn{5}{|c|}{Without Local Search} & \\multicolumn{5}{|c}{With Local Search} \\\\\n   &     &  Optimum &  Fitness &    Gap &   Time &  $I_{opt}$ &  $I_{total}$ &  Fitness &   Gap &   Time &  $I_{opt}$ &  $I_{total}$ \\\\\nALG & n &          &          &        &        &            &          &       &        &            \\\\\n\\midrule\nGA & 10  &     1994 &     1994 &   0.00 &   0.00 &          1 &                  1 &     1994 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 20  &    11758 &    11758 &   0.00 &   0.00 &         13 &                 13 &    11758 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 30  &    19032 &    19032 &   0.00 &   2.00 &         33 &                 33 &    19032 &  0.00 &   1.00 &          0 &                  0 \\\\\n   & 40  &    20892 &    20892 &   0.00 &   5.00 &         54 &                 54 &    20892 &  0.00 &   3.00 &          0 &                  0 \\\\\n   & 50  &    34198 &    34198 &   0.00 &  18.00 &        124 &                124 &    34198 &  0.00 &   3.00 &          0 &                  0 \\\\\n   & 60  &    42382 &    44060 &   3.96 & 300.00 &        141 &               1795 &    42382 &  0.00 &  10.00 &          1 &                  1 \\\\\n   & 70  &    47234 &    47498 &   0.56 & 300.00 &        221 &               1744 &    47234 &  0.00 &  15.00 &          1 &                  1 \\\\\n   & 80  &    53538 &    53538 &   0.00 &  62.00 &        291 &                347 &    53538 &  0.00 &  23.00 &          2 &                  2 \\\\\n   & 90  &    69731 &    70489 &   1.09 & 300.00 &        477 &               1322 &    69731 &  0.00 &  36.00 &          2 &                  2 \\\\\n   & 100 &    83495 &    90825 &   8.78 & 300.00 &        314 &                314 &    83495 &  0.00 &  56.00 &          3 &                  3 \\\\\n   & 150 &   104772 &   164686 &  57.19 & 300.00 &        141 &                141 &   104772 &  0.00 & 183.00 &          6 &                  6 \\\\\n   & 200 &   130178 &   285042 & 118.96 & 300.00 &        142 &                142 &   133848 &  2.82 & 300.00 &          7 &                  7 \\\\\n   \\midrule\nACO & 10  &     1994 &     1994 &   0.00 &   0.00 &          0 &                  0 &     1994 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 20  &    11758 &    11758 &   0.00 &   0.00 &          0 &                  0 &    11758 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 30  &    19032 &    19032 &   0.00 &   0.00 &          1 &                  1 &    19032 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 40  &    20892 &    20892 &   0.00 &   8.00 &         89 &                 89 &    20892 &  0.00 &   0.00 &          0 &                  0 \\\\\n   & 50  &    34198 &    34280 &   0.24 & 300.00 &       1380 &               1856 &    34198 &  0.00 &   1.00 &          0 &                  0 \\\\\n   & 60  &    42382 &    45370 &   7.05 & 300.00 &        326 &               1358 &    42382 &  0.00 &   1.00 &          0 &                  0 \\\\\n   & 70  &    47234 &    50798 &   7.55 & 300.00 &        361 &               1271 &    47234 &  0.00 &   2.00 &          0 &                  0 \\\\\n   & 80  &    53538 &    60098 &  12.25 & 300.00 &        684 &                775 &    53538 &  0.00 &   3.00 &          0 &                  0 \\\\\n   & 90  &    69731 &    83165 &  19.27 & 300.00 &        500 &                598 &    69731 &  0.00 &   5.00 &          0 &                  0 \\\\\n   & 100 &    83495 &   107569 &  28.83 & 300.00 &        428 &                512 &    83495 &  0.00 &  22.00 &          4 &                  4 \\\\\n   & 150 &   104772 &   157702 &  50.52 & 300.00 &         57 &                194 &   108990 &  4.03 & 300.00 &         18 &                 32 \\\\\n   & 200 &   130178 &   218002 &  67.46 & 300.00 &         49 &                125 &   171176 & 31.49 & 300.00 &         20 &                 24 \\\\\n   \\midrule\nDNALA & 10  &     1994 &     1994 &   0.00 &   0.00 &          - &                  - &     1994 &  0.00 &   0.00 &          - &                  - \\\\\n   & 20  &    11758 &    11758 &   0.00 &   0.00 &          - &                  - &    11758 &  0.00 &   0.00 &          - &                  - \\\\\n   & 30  &    19032 &    19032 &   0.00 &   0.00 &          - &                  - &    19032 &  0.00 &   0.00 &          - &                  - \\\\\n   & 40  &    20892 &    22066 &   5.62 &   0.00 &          - &                  - &    21164 &  1.30 &   0.00 &          - &                  - \\\\\n   & 50  &    34198 &    35336 &   3.33 &   0.00 &          - &                  - &    34198 &  0.00 &   0.00 &          - &                  - \\\\\n   & 60  &    42382 &    44666 &   5.39 &   0.00 &          - &                  - &    42890 &  1.20 &   0.00 &          - &                  - \\\\\n   & 70  &    47234 &    47252 &   0.04 &   0.00 &          - &                  - &    47244 &  0.02 &   0.00 &          - &                  - \\\\\n   & 80  &    53538 &    55448 &   3.57 &   0.00 &          - &                  - &    53538 &  0.00 &   0.00 &          - &                  - \\\\\n   & 90  &    69731 &    71779 &   2.94 &   0.00 &          - &                  - &    69747 &  0.02 &   0.00 &          - &                  - \\\\\n   & 100 &    83495 &    86513 &   3.61 &   0.00 &          - &                  - &    85293 &  2.15 &   0.00 &          - &                  - \\\\\n   & 150 &   104772 &   105824 &   1.00 &   0.00 &          - &                  - &   104940 &  0.16 &   0.00 &          - &                  - \\\\\n   & 200 &   130178 &   134640 &   3.43 &   0.00 &          - &                  - &   130194 &  0.01 &   0.00 &          - &                  - \\\\\n\n\\bottomrule\n\\end{tabular}%\n}\n\\caption{Comparison of GA and ACO against the DNALA baseline in $12$ different instances.}\\label{tab:main}\n\\end{table}\n\n\n\\subsection{Comparison of GA Mutation Operators}\nThe previous section showed that our GA is not subject to premature convergence. However, the effectiveness of the two-opt neighbourhood structure and the fact that improvements occur frequently in the last iterations, we suspected that our GA was actually a multi-solution, random-neighbour local search. To this end, we compared the random two-opt move mutation operator against the best two-opt move one. Table~\\ref{tab:mutation-operator} compares median values for fitness, optimality gap, execution time and iteration characteristics for both types for moderate and large instance types. \n\nMain observations:\n\\begin{itemize}\n\t\\item The randomized approach general performs quite similarly, however, tends to require more iterations for comparable solution qualities (e.g. $n=70$)\n\t\\item For smaller instances, the locally-improving moves seem to be slightly advantageous in terms of convergence pace. \n\t\\item As the instance size increases, the effect of small locally-improving moves seem to vanish and both quality as well as iteration characteristics seem to align. \n\\end{itemize}\n\n\\begin{table}\n\\centering\n\\resizebox{\\columnwidth}{!}{%\n\\begin{tabular}{llr|rrrrr}\n\\toprule\n      &     &   Optimum &   Fitness &    Gap &   Time &   $I_{opt}$ &  $I_{total}$  \\\\\ntype & n &           &           &        &        &            &                    \\\\\n\\midrule\nRandom & 70  &  47234.00 &  47371.00 &   0.29 & 300.00 &     278.50 &            2203.50 \\\\\n      & 80  &  53538.00 &  55116.00 &   2.95 & 300.00 &     564.00 &            1650.00 \\\\\n      & 90  &  69731.00 &  70490.00 &   1.09 & 300.00 &     599.00 &            1012.00 \\\\\n      & 100 &  83495.00 &  94405.00 &  13.07 & 300.00 &     501.00 &             629.50 \\\\\n      & 150 & 104772.00 & 180576.00 &  72.35 & 300.00 &     149.00 &             149.00 \\\\\n      & 200 & 130178.00 & 280278.00 & 115.30 & 300.00 &     142.50 &             142.50 \\\\\n         \\midrule\nBest  & 70  &  47234.00 &  47366.00 &   0.28 & 221.00 &     320.00 &            1523.50 \\\\\n      & 80  &  53538.00 &  53538.00 &   0.00 &  88.00 &     295.50 &             364.50 \\\\\n      & 90  &  69731.00 &  71061.00 &   1.91 & 300.00 &     486.00 &            1492.50 \\\\\n      & 100 &  83495.00 &  89561.00 &   7.27 & 300.00 &     401.50 &            1002.50 \\\\\n      & 150 & 104772.00 & 192572.00 &  83.80 & 300.00 &     135.50 &             135.50 \\\\\n      & 200 & 130178.00 & 279480.00 & 114.69 & 300.00 &     143.50 &             143.50 \\\\\n\\bottomrule\n\n\\end{tabular}%\n}\n\\caption{Comparison of the random and best two-opt move in the GA mutation operator.}\\label{tab:mutation-operator}\n\\end{table}\n\n\n\\subsection{Population Size}\nAs the name might suggest, population size is obviously a crucial parameter in population-based metaheuristics. On the one hand, an increased population size allows vaster search diversity and allows to cover more areas in the solution space at once, obviously increasing likelihood to identifying new promising regions. \nOn the other hand, metaheuristics usually require lots of iterations to continuously improve the solution quality, which obviously is a major limiting factor for large population sizes. \nIn Figure~\\ref{fig:population} we compare the impact of different population sizes on the optimality gap over time in single executions on two different instances (usually a time bucket average would be more appropriate for statistical stability, but we assumed this was beyond the scope if this exercise).\n\nMain observations:\n\\begin{itemize}\n\t\\item Too large population sizes inherently lead to increased computational costs, thus slowing down individual iterations, as can be observed in Figure~\\ref{fig:population-b}\n\t\\item The increased population sizes, however, increase search diversity, thus may improve solution quality (compare again Figure~\\ref{fig:population-b}). Of course this depends on the structure of the solution space, e.g. big-valley vs. widely distrusted.\n\t\\item Independent of the population size, it can be observed that the GA tends to perform small steps towards improving solutions until convergence towards an (local or global) optimum sets in, while the ACO seems to require large periods to obtain improving solutions. This could be either an indicator for a suboptimal model or some hyper-parameter issue. In a more elaborated study, we would use for instance the R-package irace for proper parameter tuning. \n\\end{itemize}\n\n  \\begin{figure*}\n        \\centering\n        \\begin{subfigure}[b]{0.475\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{figures/ga_50_population_comparison.pdf}\n            \\caption%\n            {{\\small }}    \n            \\label{fig:population-a}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.475\\textwidth}  \n            \\centering \n            \\includegraphics[width=\\textwidth]{figures/ga_100_population_comparison.pdf}\n            \\caption%\n            {{\\small }}     \n            \\label{fig:population-b}\n        \\end{subfigure}\n        \\vskip\\baselineskip\n        \\begin{subfigure}[b]{0.475\\textwidth}   \n            \\centering \n            \\includegraphics[width=\\textwidth]{figures/aco_50_population_comparison.pdf}\n            \\caption%\n            {{\\small }}      \n            \\label{fig:population-c}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.475\\textwidth}   \n            \\centering \n            \\includegraphics[width=\\textwidth]{figures/aco_100_population_comparison.pdf}\n            \\caption%\n            {{\\small }}    \n            \\label{fig:population-d}\n        \\end{subfigure}\n        \\caption\n        {\\small Optimality gap over time for different population sizes on instances with $n=50$ and $n=100$ vertices. } \n        \\label{fig:population}\n    \\end{figure*}\n\n\n\\subsection{Hyper-parameters}\nIn addition to some manual tweaking of hyper-parameters, we performed a very limited comparison of selected hyper-parameters of both the GA and the ACO. \nThe default mutation rate corresponds to $2/|V|$, multiplied by a tunable parameter $r \\in \\{1,4,8\\}$. The integer values for alpha and beta define the relative importance of pheromones and distances respectively. \n\nMain observations:\n\\begin{itemize}\n\t\\item We can clearly see that with too high mutation rate ($r=8$) the genetic algorithm does not converge to the optimum, whereas for $r=1$ and $r=4$ the performance is similar.\n\t\\item For ACO alpha=1 and beta=4 or beta=8 clearly outperforms all other parameter choices, suggesting the importance of distance information rather than pheromones again likely due to specially structured instances.\n\\end{itemize}\n\n \\begin{figure*}\n        \\centering\n        \\begin{subfigure}[b]{0.475\\textwidth}\n            \\centering\n            \\includegraphics[width=\\textwidth]{figures/ga_50_mutation_rate_comparison.pdf}\n            \\caption%\n            {{\\small }}    \n            \\label{fig:mean and std of net14}\n        \\end{subfigure}\n        \\hfill\n        \\begin{subfigure}[b]{0.475\\textwidth}  \n            \\centering \n            \\includegraphics[width=\\textwidth]{figures/aco_50_alpha_beta_ratio_comparison.pdf}\n            \\caption%\n            {{\\small }}     \n            \\label{fig:mean and std of net24}\n        \\end{subfigure}\n        \\caption\n        {\\small Optimality gap over time for different parameters with $n=50$ vertices. } \n        \\label{fig:mean and std of nets}\n    \\end{figure*}\n\n\\section{Conclusion}\nWe have seen two metaheuristic techniques to solve the minimum weighted matching problem, namely ACO and genetic algorithms.\nBoth approaches performed similarly and converged to optimal solutions in appropriate times even for larger instances.\n\n\\bibliographystyle{abbrv}\n\\bibliography{main}\n\n\n\\end{document}\n  ", "meta": {"hexsha": "e827a5d2dd27f69ecd0b099de14f6d41dd74d5c9", "size": 26119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ex1/report/report.tex", "max_stars_repo_name": "tkauf15k/sos2020", "max_stars_repo_head_hexsha": "b75188097d095e4acaca32290ba4f49fa8cb6c0e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ex1/report/report.tex", "max_issues_repo_name": "tkauf15k/sos2020", "max_issues_repo_head_hexsha": "b75188097d095e4acaca32290ba4f49fa8cb6c0e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ex1/report/report.tex", "max_forks_repo_name": "tkauf15k/sos2020", "max_forks_repo_head_hexsha": "b75188097d095e4acaca32290ba4f49fa8cb6c0e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.5275080906, "max_line_length": 729, "alphanum_fraction": 0.6359355259, "num_tokens": 7112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.41169887197902383}}
{"text": "\\documentclass[t]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tikz, bm, tkz-euclide,pgfplots}\n\\pgfplotsset{compat = 1.16}\n\\usetkzobj{all}\n\n\\title{Equations and Inequalities}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame} \n\\maketitle\n\\end{frame}\n\n\\section{Solve linear equations and check solutions.}\n\n\\begin{frame}{Solving Equations}\nWhen solving an equation, our goal is to get the variable, usually $x$, alone on one side of the equal sign.\t\\newline\\\\\t\\pause\n\nTo do this, we use \\alert{reverse order of operations}:\t\\newline\\\\\t\\pause\n\\begin{enumerate}\n\t\\item<+-> Undo any addition or subtraction. \n\t\\item<+-> Undo any multiplication or division.\n\t\\item<+-> Undo any exponents.\n\t\\item<+-> Get rid of parentheses.\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{Checking Your Answer}\nYou can make sure your answer is correct by {\\color{blue}\\textbf{plugging it in}} to the original problem and seeing if the left side and right side are equal.\n\\end{frame}\n\n\\begin{frame}{Example 1}\nSolve each of the following. Round to 2 decimal places.\t\\newline\\\\\n(a) \\quad $3x + 4 = 16$\n\\begin{align*}\n\\onslide<2->{3x+4 &= 16 &} \\\\[6pt]\n\\onslide<3->{3x &= 12 &\\text{subtract 4}} \\\\[6pt]\n\\onslide<4->{x &= 4 &\\text{divide by 3}}\n\\end{align*}\n\\onslide<5->{Check $x = 4$:}\n\\begin{align*}\n\\onslide<6->{3(4) + 4 &= 16?} \\\\\n\\onslide<7->{16 &= 16}\n\\end{align*}\n\\onslide<8->{\\[x=4\\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $-2x-9=17-x$ \n\\begin{align*}\n\\onslide<2->{-2x-9&=17-x &} \\\\[6pt]\n\\onslide<3->{-1x - 9 &= 17 &\\text{add $x$}} \\\\[6pt]\n\\onslide<4->{-1x &= 26 &\\text{add 9}}\t\\\\[6pt]\n\\onslide<5->{x &= -26 &\\text{divide by $-1$}}\n\\end{align*}\n\\onslide<6->{Check $x = -26$:}\n\\begin{align*}\n\\onslide<7->{-2(-26)-9 &= 17 - (-26)?} \\\\[6pt]\n\\onslide<8->{43 &= 43}\n\\end{align*}\n\\onslide<9->{\\[x=-26\\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $\\frac{1}{2}x + 3 = \\frac{2}{5}x$\n\\begin{align*}\n\\onslide<2->{\\frac{1}{2}x + 3 &= \\frac{2}{5}x &} \\\\[8pt]\n\\onslide<3->{3 &= -\\frac{1}{10}x &\\text{subtract $\\frac{1}{2}x$}} \\\\[8pt]\n\\onslide<4->{-30 &= x &\\text{divide by $-\\frac{1}{10}$}}\n\\end{align*}\n\\onslide<5->{Check $x=-30$:}\n\\begin{align*}\n\\onslide<6->{\\frac{1}{2}(-30)+3 &= \\frac{2}{5}(-30)?} \\\\[8pt]\n\\onslide<7->{-12 &= -12}\n\\end{align*}\n\\onslide<8->{\\[x = -30\\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(d) \\quad $2.1x - 7 = 23.83$\n\\begin{align*}\n\\onslide<2->{2.1x - 7 &= 23.83 &} \\\\[6pt]\n\\onslide<3->{2.1x &= 30.83 &\\text{add 7}} \\\\[6pt]\n\\onslide<4->{x &\\approx 14.68 &\\text{divide by 2.1}}\n\\end{align*}\n\\onslide<5->{Check $x \\approx 14.68$:}\n\\begin{align*}\n\\onslide<6->{2.1(14.68) - 7 &\\approx 23.83?} \\\\[6pt]\n\\onslide<7->{23.828 &\\approx 23.83}\n\\end{align*}\n\\onslide<8->{\\[x \\approx 23.83\\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(e) \\quad $2(x-10) = 4(x-5)-2x$\n\\begin{align*}\n\\onslide<2->{2(x-10) &= 4(x-5)-2x &} \\\\[6pt]\n\\onslide<3->{2x-20 &= 4x-20 - 2x &\\text{distribute}} \\\\[6pt]\n\\onslide<4->{2x-20 &= 2x-20 &\\text{combine like terms on the right}} \\\\[6pt]\n\\onslide<5->{-20 &= -20 &\\text{subtract $2x$ from both sides}}\n\\end{align*}\n\\onslide<6->{True statement, so $x = \\text{all real numbers, or }\\mathbb{R}$}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(f) \\quad $3(x+4)+3x = 2(3x+5)-2$\n\\begin{align*}\n\\onslide<2->{3(x+4)+3x &= 2(3x+5)-2 &} \\\\[6pt]\n\\onslide<3->{3x+12+3x &= 6x+10-2 &\\text{distribute}} \\\\[6pt]\n\\onslide<4->{6x+12 &= 6x+8 &\\text{combine like terms}} \\\\[6pt]\n\\onslide<5->{12 &= 8 &\\text{subtract $6x$ from both sides}}\n\\end{align*}\n\\onslide<6->{False statement, so $x = \\text{No solution, or } \\varnothing$}\n\\end{frame}\n\n\\begin{frame}{Visual Way to Check Answers}\nAnother useful way to help check your answers is to graph the left side of the equation, as well as the right side. \\newline\\\\\t\\pause\n\nThe solution is the $x$-coordinate of their \\alert{intersection point}.\t\\newline\\\\\t\\pause\n\nFor ``no solution'' answers, the graphs will \\textbf{never intersect}. \\newline\\\\\t\\pause\n\nFor ``all real numbers'' answers, the graphs will be \\textbf{one in the same}.\n\\end{frame}\n\n\\begin{frame}{Visual Way to Check Answers}\nThe graphs of $y = 3x+4$ and $y=16$ are shown below:\t\\newline\\\\\n\\begin{center}\n\\begin{tikzpicture}[scale=0.8]\n    \\begin{axis}\n    [\n    xlabel = $x$,\n    ylabel = $y$,\n    axis lines = middle,\n    axis line style={stealth-stealth},\n    axis line style={shorten >=-7.5pt, shorten <=-7.5pt},\n    xmin = 0, xmax = 5,\n    ymin = 0, ymax = 20,\n    ystep = 4,\n    xtick = {-4,-3,...,4},\n    ytick = {4,8,...,20},\n    grid,\n    every axis x label/.style = {at = {(ticklabel* cs:1)}, anchor = south},\n    every axis y label/.style = {at = {(ticklabel* cs:1)}, anchor = west}\n    ]\n    \\addplot[domain = 0:4.5, samples = 200, line width = 1.5, smooth, color=blue]{3*x+4};\n    \\addplot[domain = 0:5, samples = 200, line width = 1.5, smooth, color=red] {16};\n    \\addplot [mark = *] coordinates {(4, 16)} node [below right] {\\textbf{(4, 16)}};\n    \\end{axis}\n    \\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\n\\section{Solve and graph inequalities on a number line.}\n\n\n\\begin{frame}{Solving Inequalities}\nSolving inequalities is a lot like solving equations.\t\\newline\\\\\t\\pause\n\nThe biggest difference is that {\\color{blue}\\textbf{inequalities typically give you an infinite number of solutions.}}\t\\newline\\\\\t\\pause\n\nFor instance, there are an infinite number of values that you can substitute into $x$ for $x > -4$ to make it true.\n\\end{frame}\n\n\\begin{frame}{Visual Solutions to Inequalities}\nSince we can't list every possible solution, we can shade a region on a number line to represent this solution.\t\\newline\\\\\t\\pause\n\\begin{center}\n\\begin{tikzpicture}\n\t\\draw [<->, > = stealth] (-6,0) -- (-0,0);\n\t\\foreach \\x in {-5,-4,-3,-2,-1}\n\t\\draw (\\x, 0.1) -- (\\x, -0.1);\n\t\\foreach \\x in {-5,-4,-3,-2,-1}\n\t\\node at (\\x, -0.3) {$\\x$};\n\t\\draw [->, color = blue, line width = 2.5, >=stealth] (-3.92,0) -- (-0.25,0);\n\t\\draw [color = blue, fill=white] (-4,0) circle (3pt);\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Summary of Graphing Inequalities}\nIf your variable is on the \\alert{left side} when graphing an inequality, you can use the following table to help you graph:\t\\newline\\\\\n\\begin{center}\n\\setlength{\\extrarowheight}{4pt}\n\\begin{tabular}{c|c|c}  \n\\textbf{Expression}\t&\t\\textbf{Circle}\t&\t\\textbf{Shade}\t\\\\\n\\hline\n$x<$\t\t\t\t\t&\tOpen\t\t\t\t& \tLeft\t\t\\\\[4pt]\n\\hline\n$x>$\t\t\t\t\t&\tOpen\t\t\t\t&\tRight\t\\\\[4pt]\n\\hline\n$x \\leq$\t\t\t\t&\tClosed\t\t\t&\tLeft\t\t\\\\[4pt]\n\\hline\n$x \\geq$\t\t\t\t&\tClosed\t\t\t&\tRight\t\\\\[4pt]\n\\end{tabular}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 2}\nGraph each of the following on a number line.\t\\newline\\\\\n\\quad $x < 2$\t\\newline\\\\\t\n\\begin{center}\n\\onslide<2->{\n\t\\begin{tikzpicture}\n\t\\draw[<->] (-2,0) -- (2,0);\n\t\\draw (0,0.15) -- (0,-0.15) node [below] {$2$};\n\t\\onslide<3->{\\draw[color=blue,fill=white] (0,0) circle [radius=3pt];}\n\t\\onslide<4->{\\draw[->,color=blue,ultra thick, shorten <= 3pt] (0,0) -- (-2,0);}\n\t\\end{tikzpicture}\t\n}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Solving Inequalities}\nWith solving inequalities, you must remember to flip the inequality sign if you multiply or divide {\\color{blue}\\textbf{both sides}} by a \\alert{negative number}.\n\\end{frame}\n\n\\begin{frame}{Example 3}\nSolve and graph each.\t\\newline\\\\\n(a) \\quad $3x - 5 > -17$\n\\begin{align*}\n\\onslide<2->{3x-5 &> -17 &}\t\\\\[6pt]\n\\onslide<3->{3x &> -12 &\\text{add 5}} \\\\[6pt]\n\\onslide<4->{x &> -4 &\\text{divide by 3}} \\\\[6pt]\n\\end{align*}\n\\begin{center}\n\\onslide<5->{\n\t\\begin{tikzpicture}\n\t\\draw[<->] (-2,0) -- (2,0);\n\t\\draw (0,0.15) -- (0,-0.15) node [below] {$-4$};\n\t\\onslide<6->{\\draw[color=blue,fill=white] (0,0) circle [radius=3pt];}\n\t\\onslide<7->{\\draw[->,color=blue,ultra thick, shorten <= 3pt] (0,0) -- (2,0);}\n\t\\end{tikzpicture}\n}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(b) \\quad $2(x+4)-5 > 2x + 3$\n\\begin{align*}\n\\onslide<2->{2(x+4)-5 &> 2x+3 &} \\\\[6pt]\n\\onslide<3->{2x+8-5 &> 2x+3 &\\text{distribute the 2}} \\\\[6pt]\n\\onslide<4->{2x+3 &> 2x + 3 &\\text{combine like terms}} \\\\[6pt]\n\\onslide<5->{3 &> 3 &\\text{subtract $2x$ from both sides}}\n\\end{align*}\n\\onslide<6->{False statement. \\quad}\n\\onslide<7->{No Solution ($\\varnothing$)} \n\\begin{center}\n\\onslide<8->{\n\t\\begin{tikzpicture}\n\t\\draw[<->] (-2,0) -- (2,0);\n\t\\end{tikzpicture}\n}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(c) \\quad $3(x+1) \\geq 3x + 2$\n\\begin{align*}\n\\onslide<2->{3(x+1) &\\geq 3x+2 &} \\\\[6pt]\n\\onslide<3->{3x+3 &\\geq 3x+2 &\\text{distribute}} \\\\[6pt]\n\\onslide<4->{3 &\\geq 2 &\\text{subtract $3x$ from both sides}}\n\\end{align*}\n\\onslide<5->{True statement. \\quad}\n\\onslide<6->{All real numbers ($\\mathbb{R}$)}\n\\begin{center}\n\\onslide<7->{\n\t\\begin{tikzpicture}\n\t\\draw[<->] (-2,0) -- (2,0);\n\t\\onslide<8->{\\draw[<->,color=blue,ultra thick] (-2,0) -- (2,0);}\n\t\\end{tikzpicture}\n}\n\\end{center}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "8342d0aa0db22e30c6d392a8ecf246f905802ac5", "size": 8933, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Equations_and_Inequalities(BEAMER).tex", "max_stars_repo_name": "BryanBain/HA2_BEAMER", "max_stars_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Equations_and_Inequalities(BEAMER).tex", "max_issues_repo_name": "BryanBain/HA2_BEAMER", "max_issues_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Equations_and_Inequalities(BEAMER).tex", "max_forks_repo_name": "BryanBain/HA2_BEAMER", "max_forks_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:45.000Z", "avg_line_length": 30.6975945017, "max_line_length": 162, "alphanum_fraction": 0.6237546177, "num_tokens": 3603, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.8104788995148792, "lm_q1q2_score": 0.4115708009216088}}
{"text": "\\documentclass[8pt]{article}\n\n\\usepackage{fullpage}\n\\usepackage[margin=.7in]{geometry}\n\\usepackage{epic}\n\\usepackage{eepic}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{ragged2e}\n\\usepackage[parfill]{parskip}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\newcommand{\\proof}[1]{\n{\\noindent {\\it Proof.} {#1} \\rule{2mm}{2mm} \\vskip \\belowdisplayskip}\n}\n\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem{theorem}[lemma]{Theorem}\n\\newtheorem{claim}[lemma]{Claim}\n\\newtheorem{definition}[lemma]{Definition}\n\\newtheorem{corollary}[lemma]{Corollary}\n\n\\begin{document}\n\\hfill \\small{\\today} \\\\\n\\setlength{\\fboxrule}{.5mm}\\setlength{\\fboxsep}{1.2mm}\n\\newlength{\\boxlength}\\setlength{\\boxlength}{\\textwidth}\n\\addtolength{\\boxlength}{-4mm}\n\\begin{center}\\framebox{\\parbox{\\boxlength}{\\bf\n\\center{CS 577 - Homework 5}\n\\center{Sejal Chauhan, Vinothkumar Siddharth, Mihir Shete}\n}}\\end{center}\n\\vspace{5mm}\n\n\\section{Graded written problem}\n\n\\textbf{Input:} In a city there are $n$ bus drivers. There are also $n$ morning bus routes and $n$ afternoon bus routes, each with various lengths. Each driver is assigned one morning route\nand one evening route. For any driver, if his total route length for a day exceeds $d$, he has to\nbe paid overtime for every hour after the first $d$ hours at a fixed rate per hour.\n\\\\ \\\\\n\\textbf{Output:} Assign one morning route and one evening route to each bus driver so that the total overtime amount that the city authority has to pay is minimized.\n\n\\subsection{Algorithm}\nOur greedy algorithm begins by sorting the $n$ morning bus routes in reverse order (Longest route first) and the $n$ afternoon bus routes in order. To find a set $G\\{(m,a): \\forall m \\in M \\land \\forall a \\in A \\}$, where M is set of all morning routes and A is the set of all evening routes, we will use the following \\textit{strategy}:\n\\begin{enumerate}\n    \\item Starting from the first morning(largest) route we get the smallest available afternoon route and pair them.\n\\end{enumerate}\n\n\n\\begin{algorithm}\n\\caption{Pseudocode of our greedy strategy}\\label{euclid}\n\\begin{algorithmic}[1]\n\\Procedure{Find-All-Pairs}{$M$, $A$}\n\n\\State $i \\leftarrow 0$\n\n\\While{$i \\textless \\left\\vert{M}\\right\\vert$}\n        \\State Pair $M[i]$, $A[i]$\n        \\State $i \\leftarrow i + 1$\n\\EndWhile\n\\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n\n\\subsection{Exchange Argument}\nLet $r$ be all the route-pairs in a solution that are greater than $d$ and let $l_i$ be the length of the route-pair . $p(G) = \\sum_{r}(l_i - d)$ for our greedy solution $G$, similarly for an optimal Solution $S$ $p(S) = \\sum_{r}(l_i - d)$\n\nIf, $G = S$ then clearly $p(G) = p(S)$.\n\nOtherwise, $G \\neq S$. So, there must be some 2 routes in $G$ and $S$, such that the morning routes are the same but the paired afternoon routes are different. More formally, if ($M_G(i)$, $A_G(i)$), ($M_G(j)$, $A_G(j)$) are 2 pairs in G and ($M_S(k)$, $A_S(k)$), ($M_S(l)$, $A_S(l)$) are 2 pairs in S, then\n$$M_G(i) = M_S(k) \\And M_G(j) = M_S(l)$$\nbut,\n$$A_G(i) \\neq A_S(k) \\And A_G(j) \\neq A_S(l)$$ \\\\\nLet, $M_{ik} = M_G(i) = M_S(k)$ and $M_{jl} = M_G(j) = M_S(l)$\nNow, consider the following scenarios in $S$:\n\\begin{description}\n    \\item[$M_{ik} \\textgreater M_{jl}$] \\hfill \\\\\n        Let $S'$ denote a solution which would have selected the ($M_{ik}, A_S(l)$) and ($M_{jl}, A_S(k)$) pair contrary to $S$. $S'$ is similar to $G$ in a way that $G$ would also have chosen the same pairing as $S'$. So, given the constraint on morning routes $S'$ will choose the afternoon route first for $M_{ik}$ and it will pair with $A_S(l)$ if:\n\n    \\begin{enumerate}\n        \\item \\textbf{$A_S(l) \\textless A_S(k)$ and $M_{ik} + A_S(l) \\leq d$} \\hfill \\\\\n            For the above constraints $M_{jl} + A_S(k)$ can be less than, more than or equal to $d$, so lets analyze all the conditions:\n            Here, if $$M_{jl} + A_S(k) \\textgreater d$$ it follows that $$M_{ik} + A_S(k) \\textgreater d$$ But, $$p(S') = C + M_{jl} + A_S(k) - d$$\n            $$p(S) = C + M_{ik} + A_S(k) - d$$ $\\because M_{jl} \\textless M_{ik}$ it implies that $p(S') \\textless p(S)$ \\\\ \\\\\n            $M_{jl} + A_S(k) \\leq d$ then the overtime introduced by the swap is $0$ and so $p(S') \\leq p(S) $ \\\\ \\\\\n\n\n        \\item \\textbf{$A_S(l) \\textless A_S(k)$ and $M_{ik} + A_S(l) \\textgreater d$} \\hfill \\\\\n            For the above constraints $M_{jl} + A_S(k)$ can be less than, more than or equal to $d$, so lets analyze all the conditions:\n            Here, if $M_{jl} + A_S(k) \\textgreater d$ and $M_{jl} + A_S(l) \\textgreater d$ it is trivial to see that $p(S') = p(S)$ since the extra hours introduced for both the selections will be $M_{ik} + M_{jl} + A_S(k) + A_S(l) - 2$. \\\\ \\\\\n            But if $M_{jl} + A_S(k) \\textgreater d$ and $M_{jl} + A_S(l) \\leq d$\n            $$p(S) = M_{ik} + A_S(k) - d$$\n            $$p(S') = M_{ik} + A_S(l) + M_{jl} + A_S(k) - 2d = p(S) + M_{jl} + A_S(l) - d \\leq p(S) \\because M_{jl} + A_S(l) \\leq d$$\\\\\n\n            If, $M_{jl} + A_S(k) \\leq d$ then it implies that $M_{jl} + A_S(l) \\leq d$ from the constraints. $$p(S') =  C + M_{ik} + A_S(l) - d$$ And $$p(S) = C + M_{ik} + A_S(k) - d$$\n            And since $A_S(l) \\textless A_S(k)$ it is clear that $p(S') \\textless p(S)$\n    \\end{enumerate}\n\\end{description}\n\nFrom the above analysis it is clear that $p(S') \\leq p(S)$ whenever the order is changed according to greedy strategy. Hence, our greedy strategy will provide an optimal solution.\n\n\\subsection{Running Time Analysis}\nTo sort get the routes in correct order for our greedy algorithm to process we will have to spend $O(n\\log{n})$ time. The \\textbf{Find-All-Pairs} procedure will iterate over all $n$ elements in $M$ and all the operations in these iterations are constant time. So overall runtime is:\n\n\n$$O(n \\log{n} + c*n) = O(n \\log{n})$$\n\n\\end{document}\n", "meta": {"hexsha": "697d10763eafb00f6f1cfdd540029debca2d07c6", "size": 5983, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw5-take2.tex", "max_stars_repo_name": "smihir/cs577", "max_stars_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw5-take2.tex", "max_issues_repo_name": "smihir/cs577", "max_issues_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw5-take2.tex", "max_forks_repo_name": "smihir/cs577", "max_forks_repo_head_hexsha": "1a8e036e125bc571fe24713bbeb3b60d79d0e857", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0260869565, "max_line_length": 352, "alphanum_fraction": 0.6617081732, "num_tokens": 1967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.7981867873410141, "lm_q1q2_score": 0.41156100401999823}}
{"text": "% This is a comment, this will be not be read by the machine\n\n% Which type of document do you want?\n\\documentclass[a4paper,12pt]{article} \n\n% Use packages for different functioanlities\n\\usepackage[utf8]{inputenc} % For character encoding\n\\usepackage{natbib} % For bibliography\n\\usepackage{amsmath} % For mathematics\n\\usepackage{amssymb}\n\\usepackage{graphicx} % For graphics\n\\usepackage{url} % For including web links\n\\usepackage{tikz} % For advanced graphics with the language TikZ\n\\usepackage[font=footnotesize]{caption} \n\\linespread{1.33} % Control spread between lines\n\\usepackage[toc,page]{appendix} \n\\usepackage[colorlinks=true,linkcolor=red,urlcolor=red,citecolor=blue,backref=page]{hyperref} \n\\usepackage{rotating}\n\\usepackage{amsthm}\n% \\usepackage[top=2.5cm, bottom=2.5cm, left=3cm, right=3cm]{geometry}\n\n% Now comes the main part\n\\title{Introduction to \\LaTeX\\\\\n\\scriptsize{Put subtitle here}} %This sets up the title, note the `\\\\' command for a newline\n%\\title{new title}\n\\author{Abhinav Anand}\n%\\thanks{Herein goes thanks.}\n\n\\date{} %If you comment this out, the date will be displayed\n\n\\begin{document}\n\n\\maketitle %This command \"makes\" the title\n\n\\begin{abstract}\n\nHa ha ha what a funny abstract!\n\n\\end{abstract}\n\n\\section{What a funny section!}\n\\label{Funny_Label}\n\n\\LaTeX uses a ``markup language'' in order to convert text, combined with the markup, into a high quality document. For example, web pages work in a similar way: the HTML \n(Hyper Text Markup Language) is used to style the text document, and the browser presents it in its full glory --- with different colors, fonts, sizes, etc.\n%\\\\\\\\\\\\\nEach of the \\LaTeX commands begin with a backslash. This is \\LaTeX's way of knowing that whenever it sees a backslash, to expect some commands. Comments are not classed as a commands.\n\nYou can force a new line using \\\\\n%To force a new page, use \\newpage or \\clearpage\n\nthis is the ``right'' way\n\nthis is the ''wrong'' way\n\n\\section*{The section with no number}\n\nThat's how you do it --- with a star!\n\n\\subsection{Subsection}\n\nHere is my subsection\n\nIn order to have a subsection without a name, just use the old trick --- attach\na star to the end of the command: %\\subsection*{}\n\n\\subsubsection{This is my subsubsection}\n\nAgain, use the star in the relevant command to omit natural numbering of sections.\n\nNow let us introduce equations, since that's what we're here to learn!\n\n\\section{Support for Mathematics}\n\nYou can generate equations via the following ``environment'' --- the \nequation environment enclosed in the ``begin'' and ``end'' equations:\n% (Note the biggest mistake made in latex when enclosing quotes: `` vs '')$ \\dfrac{num}{den} $\n\n\\begin{equation}\n\\label{Eq:Number_1}\n\\int_{0}^{\\infty} e^{-\\rho} \\rho^{2l}\\left[ L_{n+l}^{2l+1} \\left(\\rho\n\\right) \\right]^2 \\rho^2 d\\rho = \\frac{2n \\left[\\left(n+l\\right)!\n\t\\right]^3}{(n-l-1)!}\n\\end{equation}\n\n$\\displaystyle\\sum_{i=0}^{i=\\infty}f^2$\n\nNeedless to say you can generate any equation of any arbitrary complexity and it is \nguaranteed to be rendered beautifully.\n\nIf you don't want the equation numbers you can use a star after the word \n``equation'' above. TeXstudio prompts you anyway regarding that.\n\nYet another way to generate anonymous equations is the following operator: %\\[\\]\n\n\\[\n\\bar{N}_j^g = \\frac{\\sum\\limits_{k} N_{jk} W_k}{\\sum\\limits_{K} W_k}\n\\]\n\n\n\n\nYou can also use equations inline by using the dollar signs and squeezing all\nmathematics within them. For example, $\\nexists$ a markup/typesetting language\nbetter than \\LaTeX  and it's as easy to see as $x^2 + x_1 + x = g(\\cdot)$.\\footnote{Let's add a footnote for fun!}\n\n\\subsection{Subequations}\n\nLet's now add subequations to complete the discussion\n\n\\begin{subequations}\n\t\\begin{equation}\n\te^{i\\pi} + 1 = 0\n\t\\label{1a}\n\t\\end{equation}\n\t\\begin{equation}\n\t\\nabla \\times \\mathbf{H} = \\frac{\\varepsilon}{c} \\frac{\\partial \\mathbf{E}}{\\partial{t}}\n\t\\label{1b}\n\t\\end{equation}\n\t\\label{1}\n\\end{subequations}\n\nMore mathematics:\n\n\n$\\sqrt[3]{5}$\n\n$\\frac{x}{y}$\n\n$\\dfrac{\\displaystyle\\int_{0}^{\\infty}fg d\\mu}{\\frac{\\varepsilon}{c}}$\n\n$A^{x} {y}$\n\n$\\sum {k=1}^n k$\n\n$2 \\ne 4$\n\n$\\phi \\in \\Psi$\n\n$\\hat{\\i} \\times \\hat{\\j} = \\hat{k}$\n\n$f^{\\prime}(\\xi)$\n\n180$^{\\circ}$C\n\n\n\\section{Figures}\n\nTo include figures in a document the package graphicx is required, so the command\n%\\usepackage{graphicx} \nmust be written in the preamble. To add a figure one can\nwrite the following commands.\n\n \\begin{figure}[h!tbp] % htbp\n \t\\centering\n \t\\includegraphics[width=12cm,height=6cm]{Boxplot_Integration.pdf}\n \t%\\includegraphics[width=0.5\\textwidth]{Boxplot_Integration.pdf}\n \t\\caption{Add fancy captions here}\n \t\\label{Fig:Label_Boxplot} \n \\end{figure}\n\nIn general we wish to add labels to figures, sections, tables etc. since it is very\nhandy to be able to refer to them as and when needed using the backslash ref command.\nYou can use labels to refer to the section maybe a hundred pages later\nby using it to go back to section \\ref{Funny_Label}. \n\n[h!] is an option of the figure environment. This tells \\LaTeX to put this image in\nthe next available space. Therefore if the image does not fit where it was written in\nthe .tex document, \\LaTeX will move the float to the next page and shift some text on top of\nit to minimise empty spaces. \n\nAnother example:\n\n \\begin{figure}[h!tbp] % htbp\n \t\\centering\n \t%\\includegraphics[width=12cm,height=6cm]{Boxplot_Integration.pdf}\n \t\\includegraphics[width=0.9\\textwidth]{Banking_Sector_US.pdf}\n \t\\caption{Add fancy captions here}\n \t\\label{Fig:Cum_fraction_eigen_US} \n \\end{figure}\n \n \\section{Typeface Styles}\n \n Have a look!\n \n \\subsection{Typeface}\n \n \\emph{Text}, \\textbf{Text}, \\texttt{Text}, \\textrm{Text},\n \\textsf{Text}, \\textsc{Text}, \\textit{Text}\n \n \\subsection{Size}\n \n {\\tiny Text}, {\\scriptsize Text}, {\\footnotesize Text},\n {\\small Text}, {\\normalsize Text}, {\\large Text}, {\\Large\n \tText}, {\\LARGE Text}, {\\huge Text}, {\\Huge Text}\n \n \\subsection{Alignment}\n \n \\begin{center} %/flushright/flushleft\n \tput things here for fun\n \\end{center} %/flushright/flushleft\n\n\\section{Lists}\n\nThere are two main types of lists that are popular --- bullet points and numbered lists\n\nHere is how you use the bullet points:\n\n\\begin{itemize}\n\t\\item this is one item\n\t\\item this is another item\n\\end{itemize}\n\nTo generate numbered lists:\n\n%\\ref{Fig:Label_Boxplot}\n\n\\begin{enumerate}\n\t\\item this is one item\n\t\\item this is another item\n\\end{enumerate}\n\nalso, you can use whatever symbol you wish!\n\n\\begin{itemize}\n\t\\item[$\\diamond$] this is one item\n\t\\item[$\\diamond$] this is another item\n\\end{itemize}\n\n\n\\section{Tables}\n\n\\begin{table}\n\t\\centering \n\t\\caption{Several types of tables can be accommodated}\n\t\\label{Table:Systemic_Banks}\n\t\\scriptsize{ \n\t\t\\begin{tabular}{llc} % Why lll? What about ccc or rrr or some combination?\n\t\t\t\\hline\n\t\t\t&\\textbf{G-SIB}\t\t\t&\\textbf{D-SIB} \t\t\\\\   \\hline\n\t\t\t&Bank of America\t\t\t&BB\\&T\t\t\t\t\t\\\\\n\t\t\t&JP Morgan Chase\t\t\t&Comerica\t\t\t\t\\\\\n\t\t\t&Wells Fargo\t\t\t\t&Huntington Bancshares\t\\\\\n\t\t\t&State Street\t\t\t\t&M\\&T Bank\t\t\t\t\\\\\n\t\t\t&Morgan Stanley\t\t\t\t&PNC\t\t\t\t\t\\\\\n\t\t\t&Goldman Sachs\t\t\t\t&Regions\t\t\t\t\\\\\n\t\t\t&Bank of New York Mellon\t&Zions\t\t\t\t\t\\\\\n\t\t\t&Citigroup\t\t\t\t\t&Fifth Third\t\t\t\\\\\n\t\t\t&\t\t\t\t\t\t\t&SunTrust\t\t\t\t\\\\\n\t\t\t&\t\t\t\t\t\t\t&US Bancorp\t\t\t\t\\\\\n\t\t\t&\t\t\t\t\t\t\t&KeyCorp\t\t\t\t\\\\\\hline\n\t\t\\end{tabular}\n\t}\n\\end{table}\n\n\nLet's try some more tables:\n\n\\begin{table}[ht]\n\t\\centering\n\t\\begin{tabular}{|r||c|c|} \\hline\n\t\tTrial & $n$ & $t$ \\\\ \\hline\n\t\t1 & 23 & 2 \\\\ \\hline\n\t\t2 & 15 & 10 \\\\ \\hline\n\t\t3 & 100 & 20 \\\\ \\hline\n\t\\end{tabular}\n\\end{table}\n\n\\section{References}\n\nFinally let's see how to build bibliography:\n\nMy hero Sergiu Hart: \\cite{FH:2009}\n\nOther types of citation include \\citep{FRB:2003}, \\cite{Brownlees_Engle:2015},\n\\cite{Haas:2009}, \\cite{Rachev:2005b}, \\nocite{Fahlenbrach_et_al:2016} etc.\n\n\n\n\\bibliographystyle{StyWorking_Paper}% Select the citation style e.g. ieeetr\n\\bibliography{Introduction_to_Bibliography_Dublin_Reading_Group_20170615}% use the .bib file\n\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "1191275673bac6314b0dc943632f9ae1cd933b83", "size": 7949, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Introduction_to_Latex_Dublin_Reading_Group_20170615.tex", "max_stars_repo_name": "abhinavananddwivedi/Intro_to_Latex", "max_stars_repo_head_hexsha": "7632efb16bf77c766e7722c40314bb978d7f5367", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Introduction_to_Latex_Dublin_Reading_Group_20170615.tex", "max_issues_repo_name": "abhinavananddwivedi/Intro_to_Latex", "max_issues_repo_head_hexsha": "7632efb16bf77c766e7722c40314bb978d7f5367", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Introduction_to_Latex_Dublin_Reading_Group_20170615.tex", "max_forks_repo_name": "abhinavananddwivedi/Intro_to_Latex", "max_forks_repo_head_hexsha": "7632efb16bf77c766e7722c40314bb978d7f5367", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6006944444, "max_line_length": 183, "alphanum_fraction": 0.7124166562, "num_tokens": 2488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7690802423634961, "lm_q1q2_score": 0.41153362917648034}}
{"text": "\\begin{figure*}\n%\\vspace{-1em}\n\\centering\n%\\includegraphics[width=0.99\\linewidth, trim={10cm 0 0 0},clip]{../yellowfin_iclr2018/manuscript_for_revision/experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n\\includegraphics[width=0.99\\linewidth]{../yellowfin_iclr2018/manuscript_for_revision/experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n\t\\vspace{-0.5em}\n\t\\caption{\n\tWhen running \\tuner, total momentum $\\hat{\\mu}_t$ equals algorithmic value in synchronous settings (left); $\\hat{\\mu}_t$ is greater than algorithmic value on 16 asynchronous workers (middle).\n\t\\Asynctuner automatically lowers algorithmic momentum and brings total momentum to match the target value (right).\n%Red dots are measured $\\hat{\\mu}_t$ at every step with red line as its running average.\n\tRed dots are total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \nThe solid red line is a running average of $\\hat{\\mu}_T$.\n%\tWhen running \\tuner, total momentum $\\hat{\\mu}_t$ is greater than algorithmic value on 16 asynchronous workers (left).\n%\t\\Asynctuner automatically lowers algorithmic momentum and matches total momentum to the target value (right).\n%%Red dots are measured $\\hat{\\mu}_t$ at every step with red line as its running average.\n%\tRed dots are total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%    The solid red line is a running average of $\\hat{\\mu}_T$.\t\n\t}\n\t\\label{fig:we-can-measure}\n%\\vspace{-0.35em}\n\\end{figure*}\n\n\\section{\\Asynctuner}\n\\label{sec:async_tuner}\n\nAsynchrony is a parallelization technique that avoids synchronization barriers \\citep{recht2011hogwild}. \nIn this section, we propose a {\\em closed momentum loop} variant of \\tuner to accelerate convergence in asynchronous training. \n%To handle the momentum dynamics of asynchronous parallelism, we propose a {\\em closed momentum loop} variant of \\tuner.\nAfter some preliminaries, we show the mechanism of the extension: \nit measures the dynamics on a running system and controls momentum with a negative feedback loop.\n\\paragraph{Preliminaries}\n%Asynchrony is a popular parallelization technique \\citep{recht2011hogwild} that avoids synchronization barriers.\nWhen training on $M$ asynchronous workers, staleness (the number of model updates between a worker's read and write operations) is on average $\\tau=M-1$,\ni.e., the gradient in the SGD update is delayed by $\\tau$ iterations as $\\nabla f_{S_{t - \\tau}}(x_{t - \\tau} )$.\nAsynchrony yields faster steps, but can\nincrease the number of iterations to achieve the same solution,\na tradeoff between hardware and statistical \nefficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n\\citet{mitliagkas2016asynchrony} interpret asynchrony as added momentum dynamics.\nExperiments in \\citet{hadjis2016omnivore} support this finding, and demonstrate that reducing algorithmic momentum can compensate for asynchrony-induced momentum\nand significantly reduce the number of iterations for convergence.\nMotivated by that result, we use the model\nin~\\eqref{equ:exp_async_update_app}, where the total momentum, $\\mu_T$, includes both asynchrony-induced and algorithmic  momentum, $\\mu$, in~\\eqref{eqn:momentum_gd}.\n\\begin{equation}\n\t\\mathbb{E}[ x_{t+1} - x_t ] \n\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n\\label{equ:exp_async_update_app}\n\\end{equation}\nWe will use this expression to design an estimator for the value of total momentum, $\\hat{\\mu}_T$.\nThis estimator is a basic building block of \\asynctuner, that {\\em removes the need to manually compensate for the effects of asynchrony}.\n\n\n\n\\paragraph{Measuring the momentum dynamics}\n\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\nEquation~\\eqref{equ:exp_async_update} gives an estimate of $\\hat{\\mu}_T$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update}.\n\\begin{align}\n\\hat{\\mu}_T\n\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n\t\t\t\t\t\\right)\n\\label{eqn:momentum_measurement}\n\\end{align}\nWe use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \nThis way we get a total momentum measurement from each variable; \nthe median combines them into a more robust estimate.\n\n\\paragraph{Closing the asynchrony loop}\nGiven a reliable measurement of $\\mu_{T}$, \nwe can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n\\Asynctuner in Algorithm~\\ref{alg:async-algo} %(in Appendix~\\ref{sec:async_yf}) \nuses a simple negative feedback loop to achieve the adjustment.\n%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%Closing the loop, as we will see, improves performance significantly.\n%Note for asynchronous-parallel training, as the estimates and parameter tuning is unstable in the beginning when there are only a small number of iterations, we use initial learning $\\frac{1}{\\tau + 1}$ instead of $1.0$ to prevent overflow in the beginning. \n\n%\\begin{algorithm}[H]\n%\t\\caption{\\Asynctuner}\n%\t\\begin{algorithmic}[1]\n%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%\t\\For { $t\\gets1$ to $T$}\n%\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n%\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n%\t\\State $\\hat{\\mu_T} \n%\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n%\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n%\t\\EndFor\n%\\end{algorithmic}\n%\\label{alg:async-algo}\n%\\end{algorithm}\n\n\n\n\n%In Section~\\ref{sec:async_tuner}, we briefly discuss the mechanism of our designed \\Asynctuner in asynchronous-parallel setting. In this appendix, we expand the details in total momentum estimator, $\\hat{\\mu_T}$, and present the full \\Asynctuner in Algorithm~\\ref{alg:async-algo} with extensive discussion.\n%\\paragraph{Measuring the momentum dynamics}\n%Remember, we use the formula in~\\eqref{equ:exp_async_update_app} to model the momentum dynamics in asynchronous-parallel systems\n%\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\n%\\begin{equation}\n%\t\\mathbb{E}[ x_{t+1} - x_t ] \n%\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n%\\label{equ:exp_async_update_app}\n%\\end{equation}\n%Equation~\\eqref{eqn:momentum_measurement_app} gives an estimate of $\\hat{\\mu_T}$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update_app}.\n%\\begin{align}\n%\\hat{\\mu_T}\n%\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)\n%\\label{eqn:momentum_measurement_app}\n%\\end{align}\n%We use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \n%This way we get a total momentum measurement from each variable; \n%the median combines them into a more robust estimate.\n%\n%%\\label{subsec:closed_loop_YF}\n%%\\begin{figure}\n%%\\centering\n%%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%%\t\\caption{\n%%\tMomentum dynamics on CIFAR100 ResNet.\n%%\tRunning \\tuner, total momentum is equal to algorithmic momentum in a synchronous setting (left). Total momentum is greater than algorithmic momentum on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%%\tUsing the momentum feedback mechanism of \\asynctuner, lowers algorithmic momentum and brings total momentum to match the target value on 16 asynchronous workers (right).\n%%\tRed dots are individual total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%%The solid red line is a running average of those estimates.\t\n%%\t}\n%%\t\\label{fig:we-can-measure}\n%%\\end{figure}\n%\n%\\paragraph{Closing the asynchrony loop}\n%Given a reliable measurement of $\\mu_{T}$, \n%we can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n%\\Asynctuner in Algorithm~\\ref{alg:async-algo} %(in Appendix~\\ref{sec:async_yf}) \n%uses a simple negative feedback loop to achieve the adjustment.\n%%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%%Closing the loop, as we will see, improves performance significantly.\n%%%Note for asynchronous-parallel training, as the estimates and parameter tuning is unstable in the beginning when there are only a small number of iterations, we use initial learning $\\frac{1}{\\tau + 1}$ instead of $1.0$ to prevent overflow in the beginning. \n%%\n%%%\\begin{algorithm}[H]\n%%%\t\\caption{\\Asynctuner}\n%%%\t\\begin{algorithmic}[1]\n%%%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%%\t\\For { $t\\gets1$ to $T$}\n%%%\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n%%%\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n%%%\t\\State $\\hat{\\mu_T} \n%%%\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n%%%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n%%%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%%%\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n%%%\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n%%%\t\\EndFor\n%%%\\end{algorithmic}\n%%%\\label{alg:async-algo}\n%%%\\end{algorithm}\n%%\n%\n%\n%\n\n\n\n\n\\begin{algorithm}[h]\n\t\\caption{\\Asynctuner}\n\t\\begin{algorithmic}[1]\n%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n\t\\For { $t\\gets1$ to $T$}\n\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n\t\\State $\\hat{\\mu_T} \n\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n\t\\EndFor\n\\end{algorithmic}\n\\label{alg:async-algo}\n\\end{algorithm}\n\n\n%%%%%%%%%%%%%%%%% latest backup version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%Asynchrony is a parallelization technique that avoids synchronization barriers \\citep{recht2011hogwild}. \n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to accelerate convergence in asynchronous training. \n%%To handle the momentum dynamics of asynchronous parallelism, we propose a {\\em closed momentum loop} variant of \\tuner.\n%%After some preliminaries, we show the mechanism of the extension: \n%%it measures the dynamics on a running system and controls momentum with a negative feedback loop.\n%%\\paragraph{Preliminaries}\n%%Asynchrony is a popular parallelization technique \\citep{recht2011hogwild} that avoids synchronization barriers.\n%%When training on $M$ asynchronous workers, staleness (the number of model updates between a worker's read and write operations) is on average $\\tau=M-1$,\n%%i.e., the gradient in the SGD update is delayed by $\\tau$ iterations as $\\nabla f_{S_{t - \\tau}}(x_{t - \\tau} )$.\n%%It yields faster steps, but can\n%%increase the number of iterations needed,\n%%a tradeoff between hardware and statistical \n%%efficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%It yields better hardware efficiency, i.e. faster steps, but can\n%increase the number of iterations to a given metric, i.e. statistical efficiency, as a tradeoff~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%%a tradeoff between hardware and statistical \n%%efficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to reduce the number of iterations it needs to converge in asynchronous training. \n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to reduce the number of iterations for convergence in asynchronous training.\n%%\\paragraph{\\Asynctuner}\n%\\citet{mitliagkas2016asynchrony} interpret asynchrony as added momentum dynamics.\n%%It is empirically supported in \\citet{hadjis2016omnivore} that manually reducing algorithmic momentum can compensate for asynchrony-induced momentum\n%%and significantly reduce the number of iterations to converge.\n%We design \\asynctuner, a variant of \\tuner to automatically control algorithmic momentum, compensate for asynchrony and accelerate convergence.\n%We use the formula in~\\eqref{equ:exp_async_update} to model the dynamics in the system, where the total momentum, $\\mu_T$, includes both asynchrony-induced and algorithmic  momentum, $\\mu$, in~\\eqref{eqn:momentum_gd}.\n%\\begin{equation}\n%\t\\mathbb{E}[ x_{t+1} - x_t ] \n%\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n%\\label{equ:exp_async_update}\n%\\end{equation}\n%We first use~\\eqref{equ:exp_async_update} to design an robust estimator $\\hat{\\mu}_T$ for the value of total momentum at every iteration.\n%%This estimator is a basic building block of \\asynctuner, that {\\em removes the need to manually compensate for the effects of asynchrony}. \n%Then we use a simple negative feedback control loop to adjust the value of algorithmic momentum so that $\\hat{\\mu}_T$ matches the \\emph{target momentum} decided by \\tuner in Algorithm~\\ref{alg:basic-algo}. \n%%We refer to Appendix~\\ref{sec:async_app} for details on estimator $\\hat{\\mu}_T$ and \\Asynctuner in Algorithm~\\ref{alg:async-algo}.\n%%\\Asynctuner in Algorithm~\\ref{alg:async-algo} (in Appendix~\\ref{sec:async_app}) %(in Appendix~\\ref{sec:async_yf}) \n%%uses a simple negative feedback loop to achieve the adjustment.\n%In Figure~\\ref{fig:we-can-measure}, \n%we demonstrate momentum dynamics in an asynchronous training system. \n%As directly using the target value as algorithmic momentum, \\tuner (middle) presents total momentum $\\hat{\\mu}_T$ strictly larger than the target momentum, due to asynchrony-induced momentum. \\Asynctuner (right) automatically brings down algorithmic momentum, match measured total momentum $\\hat{\\mu}_T$ to target value and, as we will see, speeds up convergence comparing to \\tuner. We refer to Appendix~\\ref{sec:async_app} for details on estimator $\\hat{\\mu}_T$ and \\Asynctuner in Algorithm~\\ref{alg:async-algo}.\n%%\n%%so that visually demonstrates the mechanism of \\Asynctuner in handling the momentum dynamics under asynchrony. In asynchronous-parallel setting, the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory.\n%%Closing the feedback loop (right plot) leads to total momentum matching the target momentum and, as we will see, improves performance significantly.\n%\n%%\\begin{figure*}\n%%%\\vspace{-2.5em}\n%%\\centering\n%%\\includegraphics[width=\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%%\t\\caption{\n%%\tWhen running \\tuner, total momentum $\\hat{\\mu}_t$ equals algorithmic value in synchronous settings (left); $\\hat{\\mu}_t$ is greater than algorithmic value on 16 asynchronous workers (middle).\n%%\t\\Asynctuner automatically lowers algorithmic momentum and brings total momentum to match the target value (right).\n%%Red dots are measured $\\hat{\\mu}_t$ at every step with red line as its running average.\n%%%\tRed dots are total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%%%The solid red line is a running average of $\\hat{\\mu}_T$.\t\n%%\t}\n%%\t\\vspace{-0.25em}\n%%\t\\label{fig:we-can-measure}\n%%\\end{figure*}\n\n\n%%%%%%%%%%%%%%%%%%%%%% latest backup versions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%\\begin{figure}\n%%\\centering\n%%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%%\t\\caption{\n%%%\tMomentum dynamics on CIFAR100 ResNet.\n%%\tRunning \\tuner on a ResNet, total momentum equals algorithmic value in a synchronous setting (left). Total momentum is greater than algorithmic value on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%%\t\\asynctuner automatically lowers algorithmic momentum and brings total momentum to match the target value (right).\n%%\tRed dots are total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%%The solid red line is a running average of $\\hat{\\mu}_T$.\t\n%%\t}\n%%\t\\label{fig:we-can-measure}\n%%\\end{figure}\n%Asynchrony is a parallelization technique that avoids synchronization barriers \\citep{recht2011hogwild}. \n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to accelerate convergence in asynchronous training. \n%%To handle the momentum dynamics of asynchronous parallelism, we propose a {\\em closed momentum loop} variant of \\tuner.\n%%After some preliminaries, we show the mechanism of the extension: \n%%it measures the dynamics on a running system and controls momentum with a negative feedback loop.\n%%\\paragraph{Preliminaries}\n%%Asynchrony is a popular parallelization technique \\citep{recht2011hogwild} that avoids synchronization barriers.\n%%When training on $M$ asynchronous workers, staleness (the number of model updates between a worker's read and write operations) is on average $\\tau=M-1$,\n%%i.e., the gradient in the SGD update is delayed by $\\tau$ iterations as $\\nabla f_{S_{t - \\tau}}(x_{t - \\tau} )$.\n%%It yields faster steps, but can\n%%increase the number of iterations needed,\n%%a tradeoff between hardware and statistical \n%%efficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%It yields better hardware efficiency, i.e. faster steps, but can\n%increase the number of iterations to a given metric, i.e. statistical efficiency, as a tradeoff~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%%a tradeoff between hardware and statistical \n%%efficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to reduce the number of iterations it needs to converge in asynchronous training. \n%%In this section, we propose a {\\em closed momentum loop} variant of \\tuner to reduce the number of iterations for convergence in asynchronous training.\n%%\\paragraph{\\Asynctuner}\n%\\citet{mitliagkas2016asynchrony} interpret asynchrony as added momentum dynamics.\n%%It is empirically supported in \\citet{hadjis2016omnivore} that manually reducing algorithmic momentum can compensate for asynchrony-induced momentum\n%%and significantly reduce the number of iterations to converge.\n%We design a {\\em closed momentum loop} variant of \\tuner to control algorithmic momentum, compensate for asynchrony and accelerate convergence.\n%We use the formula in~\\eqref{equ:exp_async_update} to model the dynamics in the system, where the total momentum, $\\mu_T$, includes both asynchrony-induced and algorithmic  momentum, $\\mu$, in~\\eqref{eqn:momentum_gd}.\n%\\begin{equation}\n%\t\\mathbb{E}[ x_{t+1} - x_t ] \n%\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n%\\label{equ:exp_async_update}\n%\\end{equation}\n%We first use this expression to design an robust estimator $\\hat{\\mu}_T$ for the value of total momentum.\n%%This estimator is a basic building block of \\asynctuner, that {\\em removes the need to manually compensate for the effects of asynchrony}.\n%Given $\\hat{\\mu}_T$,  \n%we use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} decided by \\tuner in Algorithm~\\ref{alg:basic-algo}. Specifically, we %\\asynctuner  %(in Appendix~\\ref{sec:async_yf}) \n%uses a simple negative feedback loop to achieve the adjustment. We refer to Appendix~\\ref{sec:async_app} for details on estimator $\\hat{\\mu}_T$ and \\Asynctuner in Algorithm~\\ref{alg:async-algo}.\n%%\\Asynctuner in Algorithm~\\ref{alg:async-algo} (in Appendix~\\ref{sec:async_app}) %(in Appendix~\\ref{sec:async_yf}) \n%%uses a simple negative feedback loop to achieve the adjustment.\n%Figure~\\ref{fig:we-can-measure} visually demonstrates the mechanism of \\Asynctuner in handling the momentum dynamics under asynchrony. In asynchronous-parallel setting, the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory.\n%Closing the feedback loop (right plot) leads to total momentum matching the target momentum and, as we will see, improves performance significantly.\n%\n%\\begin{figure}\n%\\centering\n%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%\t\\caption{\n%%\tMomentum dynamics on CIFAR100 ResNet.\n%\tRunning \\tuner on a ResNet, total momentum equals algorithmic value in a synchronous setting (left). Total momentum is greater than algorithmic value on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%\t\\asynctuner automatically lowers algorithmic momentum and brings total momentum to match the target value (right).\n%\tRed dots are total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%The solid red line is a running average of $\\hat{\\mu}_T$.\t\n%\t}\n%\t\\label{fig:we-can-measure}\n%\\end{figure}\n%\n\n%%%%%%%%%%%%%%%%%%%%%% below are old backup versions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%\\paragraph{Measuring the momentum dynamics}\n%\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\n%Equation~\\eqref{equ:exp_async_update} gives an estimate of $\\hat{\\mu_T}$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update}.\n%\\begin{align}\n%\\hat{\\mu_T}\n%\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)\n%\\label{eqn:momentum_measurement}\n%\\end{align}\n%We use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \n%This way we get a total momentum measurement from each variable; \n%the median combines them into a more robust estimate.\n\n%\\label{subsec:closed_loop_YF}\n%\\begin{figure}\n%\\centering\n%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%\t\\caption{\n%\tMomentum dynamics on CIFAR100 ResNet.\n%\tRunning \\tuner, total momentum is equal to algorithmic momentum in a synchronous setting (left). Total momentum is greater than algorithmic momentum on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%\tAdditionally applying the momentum feedback loop of \\asynctuner, lowers algorithmic momentum and matches total momentum to target value (right).\n%\tRed dots are individual total momentum estimates, $\\hat{\\mu}_T$, at each iteration, with\n%the solid red line as its running average.\t\n%\t}\n%\t\\label{fig:we-can-measure}\n%\\end{figure}\n\n%\\paragraph{Closing the asynchrony loop}\n%Given a reliable measurement of $\\mu_{T}$, \n%we can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n%\\Asynctuner in Algorithm~\\ref{alg:async-algo} (in Appendix~\\ref{sec:async_app}) %(in Appendix~\\ref{sec:async_yf}) \n%uses a simple negative feedback loop to achieve the adjustment.\n%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%Closing the loop, as we will see, improves performance significantly.\n%\n\n\n\n\n\n%To handle the momentum dynamics of asynchronous parallelism, we propose a {\\em closed momentum loop} variant of \\tuner.\n%After some preliminaries, we show the mechanism of the extension: \n%it measures the dynamics on a running system and controls momentum with a negative feedback loop.\n%\\paragraph{Preliminaries}\n%Asynchrony is a popular parallelization technique \\citep{recht2011hogwild} that avoids synchronization barriers.\n%When training on $M$ asynchronous workers, staleness (the number of model updates between a worker's read and write operations) is on average $\\tau=M-1$,\n%i.e., the gradient in the SGD update is delayed by $\\tau$ iterations as $\\nabla f_{S_{t - \\tau}}(x_{t - \\tau} )$.\n%Asynchrony yields faster steps, but can\n%increase the number of iterations to achieve the same solution,\n%a tradeoff between hardware and statistical \n%efficiency~\\citep{DBLP:journals/pvldb/ZhangR14}.\n%\\citet{mitliagkas2016asynchrony} interpret asynchrony as added momentum dynamics.\n%Experiments in \\citet{hadjis2016omnivore} support this finding, and demonstrate that reducing algorithmic momentum can compensate for asynchrony-induced momentum\n%and significantly reduce the number of iterations for convergence.\n%Motivated by that result, we use the model\n%in~\\eqref{equ:exp_async_update}, where the total momentum, $\\mu_T$, includes both asynchrony-induced and algorithmic  momentum, $\\mu$, in~\\eqref{eqn:momentum_gd}.\n%\\begin{equation}\n%\t\\mathbb{E}[ x_{t+1} - x_t ] \n%\t= \\mu_T \\mathbb{E}[x_t - x_{t-1}] - \\alpha \\mathbb{E}\\nabla f(x_{t})\n%\\label{equ:exp_async_update}\n%\\end{equation}\n%We will use this expression to design an estimator for the value of total momentum, $\\hat{\\mu_T}$.\n%This estimator is a basic building block of \\asynctuner, that {\\em removes the need to manually compensate for the effects of asynchrony}.\n%\n%\n%\n%\\paragraph{Measuring the momentum dynamics}\n%\\Asynctuner estimates total momentum $\\mu_{T}$ on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly.\n%Equation~\\eqref{equ:exp_async_update} gives an estimate of $\\hat{\\mu_T}$ on a system with staleness $\\tau$, based on \\eqref{equ:exp_async_update}.\n%\\begin{align}\n%\\hat{\\mu_T}\n%\t\t\t\t\t= \\mathop{\\mathsf{median}}\\left(\n%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau -1}} f(x_{t - \\tau - 1} )}\n%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%\t\t\t\t\t\\right)\n%\\label{eqn:momentum_measurement}\n%\\end{align}\n%We use $\\tau$-stale model values to match the staleness of the gradient,  and perform all operations in an elementwise fashion. \n%This way we get a total momentum measurement from each variable; \n%the median combines them into a more robust estimate.\n%\n%\\label{subsec:closed_loop_YF}\n%\\begin{figure}\n%\\centering\n%\\includegraphics[width=0.95\\linewidth]{experiment_results/resnet/mom_dynamic_3_annotated.pdf}\n%\t\\caption{\n%\tMomentum dynamics on CIFAR100 ResNet.\n%\tRunning \\tuner, total momentum is equal to algorithmic momentum in a synchronous setting (left). Total momentum is greater than algorithmic momentum on 16 asynchronous workers, due to asynchrony-induced momentum (middle).\n%\tUsing the momentum feedback mechanism of \\asynctuner, lowers algorithmic momentum and brings total momentum to match the target value on 16 asynchronous workers (right).\n%\tRed dots are individual total momentum estimates, $\\hat{\\mu}_T$, at each iteration. \n%The solid red line is a running average of those estimates.\t\n%\t}\n%\t\\label{fig:we-can-measure}\n%\\end{figure}\n%\n%\\paragraph{Closing the asynchrony loop}\n%Given a reliable measurement of $\\mu_{T}$, \n%we can use it to adjust the value of algorithmic momentum so that the total momentum matches the \\emph{target momentum} as decided by \\tuner in Algorithm~\\ref{alg:basic-algo}.\n%\\Asynctuner in Algorithm~\\ref{alg:async-algo} (in Appendix~\\ref{sec:async_app}) %(in Appendix~\\ref{sec:async_yf}) \n%uses a simple negative feedback loop to achieve the adjustment.\n%Figure~\\ref{fig:we-can-measure} demonstrates that under asynchrony the measured total momentum is strictly higher than the algorithmic momentum (middle plot), as expected from theory;\n%closing the feedback loop (right plot) leads to total momentum matching the target momentum.\n%Closing the loop, as we will see, improves performance significantly.\n%%Note for asynchronous-parallel training, as the estimates and parameter tuning is unstable in the beginning when there are only a small number of iterations, we use initial learning $\\frac{1}{\\tau + 1}$ instead of $1.0$ to prevent overflow in the beginning. \n%\n%%\\begin{algorithm}[H]\n%%\t\\caption{\\Asynctuner}\n%%\t\\begin{algorithmic}[1]\n%%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets \\frac{1}{\\tau + 1}$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%\t\\State Input: $\\mu\\gets0$, $\\alpha \\gets 0.0001$, $\\gamma\\gets0.01, \\tau$ (staleness)\n%%\t\\For { $t\\gets1$ to $T$}\n%%\t\\State $x_t\\!\\gets\\!x_{t - 1} + \\mu (x_{t - 1} - x_{t - 2} ) - \\alpha \\nabla_{S_t} f(x_{t - \\tau - 1} )$\n%%\t\\State $\\mu^*,\\alpha \\gets \\Call{\\tuner}{\\nabla_{S_t} f(x_{t - \\tau - 1} ), \\beta}$ %(get momentum from the dynamic range)\n%%\t\\State $\\hat{\\mu_T} \n%%\t\t\t\t\t\\gets \\mathop{\\mathsf{median}}\\left(\n%%\t\t\t\t\t\t\t\\frac{x_{t - \\tau} - x_{t - \\tau-1} + \\alpha \\nabla_{S_{t-\\tau-1}} f(x_{t - \\tau - 1} )}\n%%\t\t\t\t\t\t\t{x_{t - \\tau-1} - x_{t - \\tau-2}}\n%%\t\t\t\t\t\\right)$ \\Comment{Measuring total momentum}\n%%\t\\State $\\mu \\leftarrow \\mu + \\gamma \\cdot (\\mu^* - \\hat{\\mu_T})$ \\Comment{Closing the loop}\n%%\t\\EndFor\n%%\\end{algorithmic}\n%%\\label{alg:async-algo}\n%%\\end{algorithm}\n%\n", "meta": {"hexsha": "f18710bd2b7b80e11a7092816246a2333db22bb1", "size": 30297, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "async_yf.tex", "max_stars_repo_name": "mitliagkas/dshs", "max_stars_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "async_yf.tex", "max_issues_repo_name": "mitliagkas/dshs", "max_issues_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "async_yf.tex", "max_forks_repo_name": "mitliagkas/dshs", "max_forks_repo_head_hexsha": "6d5262af72288dd06544c2d5831d0c198db251bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.4766146993, "max_line_length": 515, "alphanum_fraction": 0.7373007228, "num_tokens": 8563, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4115336263443285}}
{"text": "%auto-ignore\n\\providecommand{\\MainFolder}{..}\n\\documentclass[\\MainFolder/Text.tex]{subfiles}\n\\begin{document}\n\n\\section{Homotopy transfer and effective action}\\label{Sec:HPL}\n\nIn \\cite{Doubek2018}, they consider multilinear operations $l_{lg}: V^{\\otimes l} \\rightarrow \\R$ for $l\\ge 1$, $g\\ge 0$ on an odd symplectic vector space~$V$ and write down an action $\\Action\\in \\Fun(V)$ in the form of~\\eqref{Eq:MyAction} with~$\\MC_{lg}$ replaced by~$l_{lg}^+$. We remark that their ``vertices'' are $l^+_{lg}(v,\\dotsc,v)$ for a ``field'' $v\\in V$, whereas ours are $\\MC_{lg}(v_1,\\dotsc,v_l)$ for a ``string of fields'' $v_1\\dotsb v_l\\in \\CycB(V)$. They consider the Schwarz's canonical $\\BV$-operator on $\\Fun(V)$ from~\\cite{Schwarz1992} and show that $\\Action$ satisfies the quantum master equation if and only if $(l_{lg})$ satisfy the relations of a quantum $\\LInfty$-algebra.\\footnote{This is equivalent to the notion of a loop homotopy algebra from \\cite{Markl1997} and to string brackets in closed string field theory from \\cite{Zwiebach1992}.} On the other hand, we have the string $\\BV$-operator on $\\Fun(\\CycB(V))$ and our action \\eqref{Eq:MyAction} satisfies the quantum master equation if and only if $\\MC=(\\MC_{lg})$ is a Maurer-Cartan element for $\\dIBL(\\CycC(V))$. Next, they consider a deformation retract ($\\eqqcolon\\mathrm{DR}$) as in \\eqref{Eq:DefRetr} and obtain explicit formulas for the homotopy transfered quantum $\\LInfty$-algebra on $V'$ together with all maps and homotopies via the Homological Perturbation Lemma ($\\eqqcolon\\mathrm{HPL}$). In what follows, we will sketch how to apply their construction to $\\IBLInfty$-algebras. We stress that the details have NOT been done yet!\n\nA DR \\eqref{Eq:DefRetr} induces a DR\n\\begin{equation*}\n\\begin{tikzcd}\n\\bigl(\\CycC(V),\\OPQ_{110}\\bigr) \\arrow[loop left]{l}{K_\\CycC}\\arrow[shift left]{r}{P_\\CycC} & \\arrow[shift left]{l}{I_\\CycC} \\bigl(\\CycC(V'),\\OPQ_{110}'\\bigr),\n\\end{tikzcd}\n\\end{equation*}\nwhich further induces a DR\n\\begin{equation}\\label{Eq:SDRSDR}\n\\begin{tikzcd}\n\\bigl(\\Fun(B(V)),\\hat{\\OPQ}_{110}\\bigr) \\arrow[loop left]{l}{K}\\arrow[shift left]{r}{P} & \\arrow[shift left]{l}{I} \\bigl(\\Fun(B(V')),\\hat{\\OPQ}_{110}'\\bigr).\n\\end{tikzcd}\n\\end{equation}\nIn~\\cite[Remark~3]{Doubek2018}, they write down a formula for $K$ on $\\Fun(V)$ given $\\Htp$ using a ``tensor trick'' due to Eilenberg Mac-Lane; the same method may apply to get~$K_C$ from~$\\Htp$ on $\\CycC(V)$ and $K$ on $\\Fun(\\CycB(V))$ from $K_C$ in our case. With such $K$'s, one can take $P_{\\CycC}$ and $P$, resp.~$I_{\\CycC}$ and~$I$ to be the natural extensions of $\\iota^*$, resp.~$\\pi^*$. Note that any surjective quasi-isomorphism over $\\R$ is a deformation retraction, but their formula is explicit and preserves special DR's, i.e., DR's satisfying $\\Htp^2 = \\Htp \\iota = \\pi \\Htp = 0$ ($\\eqqcolon\\mathrm{SDR}$). \\ToDo[caption={injectiv qi},noline]{Are injective quasi-isomorphisms sections of deformatino retractions?} The crucial idea of~\\cite{Doubek2018} translated to our situation is to view $\\BVOp$ and $\\BVOp^\\MC$ as perturbations of $\\{\\FreeAction,\\cdot\\} = \\hat{\\OPQ}_{110}$, which we denote by~$\\delta^{(1)}$ and~$\\delta^{(2)}$, respectively, and apply the HPL from~\\cite{Crainic2004}:\n\nFor $i=1$, $2$, suppose that $\\delta^{(i)}$ is ``small'', i.e., that $(\\Id - \\delta^{(i)} K)$ is invertible, and consider the maps\n\\begin{align*} \n \\BVOp^{(i)} &\\coloneqq \\hat{\\OPQ}_{110}' + P(\\Id - \\delta^{(i)}K)^{-1}\\delta^{(i)} I = \\hat{\\OPQ}_{110}' + P \\delta^{(i)} I + P \\delta^{(i)} K \\delta^{(i)} I + \\dotsb ,\\\\\n I^{(i)} &\\coloneqq I + K(\\Id - \\delta^{(i)}K)^{-1}\\delta^{(i)} I = I + K \\delta^{(i)} I + K \\delta^{(i)} K \\delta^{(i)} I + \\dotsb,\\\\\n P^{(i)} &\\coloneqq P + P(\\Id-\\delta^{(i)}K)^{-1}\\delta^{(i)} K = P + P \\delta^{(i)} K + P \\delta^{(i)} K \\delta^{(i)} K + \\dotsb,\\\\\n K^{(i)} &\\coloneqq K + K(\\Id-\\delta^{(i)}K)^{-1}\\delta^{(i)}K = K + K\\delta^{(i)} K + K \\delta^{(i)} K \\delta^{(i)} K + \\dotsb.\n\\end{align*}\nThe HPL asserts that if \\eqref{Eq:SDRSDR} is an SDR, then the following are SDR's as well:\n\\begin{equation*}\\begin{tikzcd}[execute at end picture={\n\\draw[->,dashed] (3.5,1.5) to[out=0,in=90] node[midway,right,xshift=.5cm]{$\\delta^{(1)} = \\BVOp_0$} (5,.75) to[out=-90,in=0] (3.5,0);\n\\draw[->,dashed] (3.5,1.5) to[out=0,in=0] node[pos=0.8,right,xshift=.3cm]{$\\delta^{(2)} = \\BVOp_0 + \\{\\IntAction,\\cdot\\}$} (3.5,-1.5);\n}]\n\\bigl(\\Fun(B(V)),\\hat{\\OPQ}_{110}\\bigr) \\arrow[loop left]{l}{K}\\arrow[shift left]{r}{P} & \\arrow[shift left]{l}{I} \\bigl(\\Fun(B(V')),\\hat{\\OPQ}_{110}'\\bigr) \\\\\n\\bigl(\\Fun(B(V)),\\BVOp \\bigr) \\arrow[loop left]{l}{K^{(1)}}\\arrow[shift left]{r}{P^{(1)}} & \\arrow[shift left]{l}{I^{(1)}} \\bigl(\\Fun(B(V')),\\BVOp^{(1)}\\bigr)\\\\\n\\bigl(\\Fun(B(V)),\\BVOp^\\MC \\bigr) \\arrow[loop left]{l}{K^{(2)}}\\arrow[shift left]{r}{P^{(2)}} & \\arrow[shift left]{l}{I^{(2)}} \\bigl(\\Fun(B(V')),\\BVOp^{(2)}\\bigr)\n\\end{tikzcd}\\end{equation*}\nOne defines the \\emph{effective action} \n$$W \\coloneqq \\log\\bigl(P^{(1)}(e^{\\IntAction})\\bigr) \\in \\Fun(\\CycB(V'))$$\nand the \\emph{path integral}\n$$ Z \\coloneqq L_{e^{-W}} \\circ P^{(1)} \\circ L_{e^{\\IntAction}}: \\Fun(\\CycB(V)) \\rightarrow \\Fun(\\CycB(V')). $$\nUnder certain circumstances, the following formulas hold:\n\\begin{equation}\\label{Eq:NiceEqns}\n\\BVOp^{(1)} = P\\BVOp_0 I,\\quad \\BVOp^{(2)}=\\BVOp^{(1)} + \\{W,\\cdot\\}^{(1)}\\quad\\text{and}\\quad P^{(2)} = Z.\n\\end{equation}\nThis is proven in \\cite{Doubek2018} on $\\Fun(V)$ when $V'=\\Harm$ is a ``harmonic'' subspace in a Hodge decomposition $V = \\Harm \\oplus C$ into odd symplectic subspaces, $\\pi$ and $\\iota$ are the canonical projection and inclusion, respectively, the homotopy $\\Htp$ is such that $(\\pi,\\iota,\\Htp)$ is an SDR, and the homotopy $K$ was constructed from $\\Htp$ via the tensor trick. Since we deal with the string $\\BV$-operator on $\\Fun(\\CycB(V))$, we can not talk about this ``symplectic compatibility'' and the proof of \\eqref{Eq:NiceEqns} might be based on another arguments.\n\n\\begin{Question}[HPL and $\\IBLInfty$]\\label{Q:EqForm}\nIf one picks an SDR of $V$ onto a harmonic subspace~$\\Harm$ as above (basically equivalent to the setting of \\cite[Section~11]{Cieliebak2015}) and constructs $K_\\CycC$ and $K$ in a particular way, can one achieve that \\eqref{Eq:NiceEqns} and the following identities hold?\n$$ \\BVOp^{(1)} = \\BVOp_0',\\quad \\BVOp^{(2)} = \\BVOp^\\MC, \\quad W = \\Action_{\\HTP_* \\MC},\\quad P^{(1)} = e^\\HTP,\\quad P^{(2)}= e^{\\HTP^\\MC}. $$\nHere, $\\Action_{\\HTP_*\\MC}$ denotes the action \\eqref{Eq:MyAction} for the Maurer-Cartan element $\\HTP_*\\MC$.\n\\end{Question}\n\n\\begin{Remark}[On $\\BV$-formalism for $\\IBLInfty$]\n\\begin{RemarkList}\n\\item As summarized in \\cite[Section~5]{Doubek2018}, given a $\\BV$-action $\\Action$, there are various approaches to obtain $W$ and $Z$ as summations over Feynman graphs (see \\cite{Mnev2017} for the stationary phase formula approach).\n\\item The appearance of Feynman graphs can be explained from the proof of \\cite[Theorem~2]{Doubek2018}, where they show that in the special setting above, it holds\n$$ P^{(1)} = P e^{D_{\\Prpg}} $$\nfor an order $\\le 2$ differential operator $D_{\\Prpg}$ which ``connects'' two legs with the propagator~$\\Prpg$ (obtained by ``rising one index'' of $\\Htp$ using the odd symplectic form). This is reminiscent of the Wick's Theorem for the (formal) perturbative expansion of the path integral (the classical approach to quantum field theories).\n\\item Having a $\\BV$-formulation of the $\\IBLInfty$-theory, it is intriguing to compare it to~\\cite{Muenster2011}, where certain $\\IBLInfty$-structures are considered in the context of open-closed string field theory.\\qedhere\n\\end{RemarkList}\n\\end{Remark}\n\\end{document}\n", "meta": {"hexsha": "2d53171cb62990357530d68162ae0e3928b18b45", "size": 7652, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Subfiles/BV_HPL.tex", "max_stars_repo_name": "p135246/phd-thesis", "max_stars_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subfiles/BV_HPL.tex", "max_issues_repo_name": "p135246/phd-thesis", "max_issues_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subfiles/BV_HPL.tex", "max_forks_repo_name": "p135246/phd-thesis", "max_forks_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 115.9393939394, "max_line_length": 1524, "alphanum_fraction": 0.6719811814, "num_tokens": 2796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.4115049378232469}}
{"text": "\\documentclass[]{article}\n\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{hyperref}\n\\usepackage{color}\n\\usepackage{soul}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\DeclareRobustCommand{\\hlcyan}[1]{{\\sethlcolor{cyan}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlgreen}[1]{{\\sethlcolor{green}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlred}[1]{{\\sethlcolor{red}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlyellow}[1]{{\\sethlcolor{yellow}\\hl{#1}}}\n\\DeclareRobustCommand{\\hlorange}[1]{{\\sethlcolor{orange}\\hl{#1}}}\n\n\n%opening\n\\title{Session 9}\n\\author{Fakhir}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Solutions}\n\n\\begin{enumerate}\n\t\\item \\begin{enumerate}\n\t\t\\item For continuity $\\lim_{x\\to0^{-}} f(x) = \\lim_{x\\to0^{+}} f(x) = 6$.\n\t\t\\item First derivative of the first piece must be equal to the first derivative of the second piece at 0. This means:\n\t\t$$ f'(0^{-}) = f'(0^{+})$$\n\t\t$$ 2ax + b = 10x^{4}+12x^{3}+8x+5 $$\n\t\tPutting $x = 0$ we get:\n\t\t$$b = 5$$\n\t\t\\item \\textit{(According to MiT solutions, no need to check this)} Second derivative of the first piece must be equal to the second derivative of the second piece at 0. This means:\n\t\t$$ f''(0^{-}) = f''(0^{+})$$\n\t\t$$ 2a = 40x^{3}+36x^{2}+8 $$\n\t\tPutting $x = 0$ we get:\n\t\t$$a = 4$$\n\t\t\n\t\t\\hlred{MiT Solution says: The first derivative has to be equal on both sides. We do not need to check the second derivative. So $b=5$ and a can be any real number.}\n\t\\end{enumerate}\n\t\n\t\\item \\begin{enumerate}\n\t\t\\item For continuity $\\lim_{x\\to1^{-}} f(x) = \\lim_{x\\to1^{+}} f(x)$. So plugging in $x=1$ in both pieces we get:\n\t\t\n\t\t$$ a+b+6 = 20 $$\n\t\t$$ a+b = 14 $$\n\t\t\\item First derivative of the first piece must be equal to the first derivative of the second piece at 1. This means:\n\t\t$$ f'(1^{-}) = f'(1^{+})$$\n\t\t$$ 2a+b = 10+12+8+5 $$\n\t\t$$ 2a+b = 35 $$\n\t\n\t\tSolving these two simultaneous equations we get:\n\t\t$$ 2a + (14-a) = 35 $$\n\t\t$$ a + 14 = 35 $$\n\t\t$$ a = 21 $$\n\t\t$$ b = -7 $$\n\t\n\t\tHence $a=21$ and $b=-7$.\n\t\n\t\\end{enumerate}\n\t\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "6f1a2848910a1d0a6facde39dd079a41486f3096", "size": 1990, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mit-ocw/[in progress] Single Variable Calculus, 2010/my solutions/1. Differentiation/Session9.tex", "max_stars_repo_name": "fakhirsh/JediTraining", "max_stars_repo_head_hexsha": "62189eb1515753acd9499bf2296af0311a76d23e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mit-ocw/[in progress] Single Variable Calculus, 2010/my solutions/1. Differentiation/Session9.tex", "max_issues_repo_name": "fakhirsh/JediTraining", "max_issues_repo_head_hexsha": "62189eb1515753acd9499bf2296af0311a76d23e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mit-ocw/[in progress] Single Variable Calculus, 2010/my solutions/1. Differentiation/Session9.tex", "max_forks_repo_name": "fakhirsh/JediTraining", "max_forks_repo_head_hexsha": "62189eb1515753acd9499bf2296af0311a76d23e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.8405797101, "max_line_length": 182, "alphanum_fraction": 0.6301507538, "num_tokens": 768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.41146595136376934}}
{"text": "\\input{../../style/preamble} \n\\input{../../latex-math/basic-math}\n\\input{../../latex-math/basic-ml}\n\\input{../../latex-math/ml-bagging.tex}\n\\input{../../latex-math/ml-boosting.tex}\n\\input{../../latex-math/ml-trees.tex}\n\n\\newcommand{\\titlefigure}{figure_man/adaboost_example_adjusted.PNG}\n\\newcommand{\\learninggoals}{\n  \\item Briefly cover the older AdaBoost and its general idea\n  \\item Understand difference between bagging and boosting\n}\n\n\\title{Introduction to Machine Learning}\n\\date{}\n\n\\begin{document}\n\n\\lecturechapter{Introduction to Boosting / AdaBoost}\n\\lecture{Introduction to Machine Learning}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Introduction to boosting}\n  \\begin{itemize}\n    \\item\n      Boosting is one of the most powerful learning ideas since 1990.\n    \\item\n      Originally designed for classification, (especially gradient) boosting handles regression (and many other supervised tasks) naturally nowadays.\n    \\item\n      Homogeneous ensemble method (like bagging), but fundamentally different approach.\n    \\item\n      {\\bf Idea:} Take a weak classifier and sequentially apply it to modified versions of the training data.\n    \\item\n      We will begin by describing an older, simpler boosting algorithm designed for binary classification, the popular \\enquote{AdaBoost}.\n  \\end{itemize}\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Boosting vs. Bagging}\n\n  \\begin{itemize}\n      \\item Homogeneous ensemble method (like bagging). \n  \\item {\\bf Idea:} Take a weak classifier and sequentially apply it to modified versions of the training data.\n    \\item Sequential not parallel model building, to minimize loss instead of variance reduction.\n  \\end{itemize}\n\n\n% The general concept of boosting is a sequential fitting of weak learner on the error:\n\\begin{center}\n\\includegraphics[width=0.40\\textwidth]{figure_man/bagging_vs_boosting.png}\n\\end{center}\n\n% In bagging, the models are fitted parallel and not sequential.\n\n\\end{vbframe}\n\n\\begin{vbframe}{Boosting as a theoretical problem}\n\nBoosting was developed as the answer to a theoretical problem:\n\n\\lz\n\n\\enquote{Does the existence of a weak learner for a certain problem imply\nthe existence of a strong learner?} (Kearns, 1988)\n\n\\lz\n\n\\begin{itemize}\n\\item \\textbf{Weak learners} are defined as a prediction rule with a correct classification rate that is at least slightly better than random guessing (> 50\\% accuracy on a balanced binary problem).\n\\item We call a learner a \\textbf{strong learner} \\enquote{if there exists a polynomial-time algorithm that achieves low error with high confidence for all concepts in the class} (Schapire, 1990).\n\n\\end{itemize}\n\n% In practice it is typically easy to construct weak learners, but difficult to build a strong one.\n\n% The proof of this ground-breaking idea generated the first boosting algorithm.\n\n\\begin{itemize}\n    \\item Any weak (base) learner can be iteratively boosted to become\na strong learner (Schapire and Freund, 1990).\n  \\item Idea was refined into \\textbf{AdaBoost} (Adaptive Boosting).\n\\end{itemize}\n\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n% \\section{AdaBoost}\n\n\\begin{vbframe}{AdaBoost}\n\n% Any weak (base) learner can be iteratively boosted to become\n% a strong learner (Schapire and Freund, 1990).\n% The proof of this ground-breaking idea generated the first boosting algorithm.\n\n\n% Leo Breiman (referring to the success of AdaBoost):\n% \\enquote{Boosting is the best off-the-shelf classifier in the world.}\n\n% \\framebreak\n\n\\begin{itemize}\n  \\item Assume binary classification with $y$ encoded as $\\setmp$.\n  \\item We use binary classifiers as weak base learners (e.g., tree stumps) from a hypothesis space $\\mathcal{B}$,\n      denoted $\\bmm$ (or $\\bmm(\\xv)$ or $\\bmmxth$), which are hard labelers and output from $\\setmp$.\n  \\item Decision score of the ensemble of size $M$ is weighted average:\n    $$\n    \\fx = \\sum_{m=1}^{M} \\betam \\bmmxth \\in \\R\n    $$\n  \\item The base learner is sequentially applied to weighted training observations. \n      After each base learner fit, currently misclassified observations receive a higher weight for\n    the next iteration, so we focus more on instances that are harder to classify.\n\\item BLs with higher predictive accuracy receive higher weights $\\betam$.\n  % \\item The number of iterations $M$ is the main tuning parameter.\n  % \\item The discrete prediction function is $h(\\xv) = \\text{sign}(\\fx) \\in \\setmp$.\n\\end{itemize}\n\n% \\framebreak\n% \n% \\begin{algorithm}[H]\n%   \\begin{algorithmic}[1]\n%     \\State Initialize observation weights: $w^{[1](i)} = \\frac{1}{n} \\quad \\forall i \\in \\nset$\n%     \\For {$m = 1 \\to M$}\n%       \\State Fit classifier to training data with weights $\\wm$ and get $\\bmmh$\n%       \\State Calculate weighted in-sample misclassification rate\n%       $$\n%         \\errm = \\frac{\\sumin \\wmi \\cdot \\mathds{1}_{\\{\\yi \\,\\neq\\, \\bmmh(\\xi)\\}}}{\\sumin \\wmi}\n%       $$\n%       \\State Compute: $ \\betamh = \\frac{1}{2} \\log \\left( \\frac{1 - \\errm}{\\errm}\\right)$\n%       \\State Set: $w^{[m+1](i)} = \\wmi \\cdot \\exp\\left(\\betamh \\cdot\n%         \\mathds{1}_{\\{\\yi \\,\\neq\\, \\bmmh(\\xi)\\}} \\right)$\n%     \\EndFor\n%     \\State Output: $\\fxh = \\sum_{m=1}^{M} \\betamh \\bmmh(\\xv)$\n%   \\end{algorithmic}\n%   \\caption{AdaBoost}\n% \\end{algorithm}\n\n%\\end{vbframe}\n\n\\framebreak\n\n\\begin{algorithm}[H]\n  \\begin{algorithmic}[1]\n    \\State Initialize observation weights: $w^{[1](i)} = \\frac{1}{n} \\quad \\forall i \\in \\nset$\n    \\For {$m = 1 \\to M$}\n      \\State Fit classifier to training data with weights $\\wm$ and get $\\bmmh$\n      \\State Calculate weighted in-sample misclassification rate\n      $$\n        \\errm = \\sumin \\wmi \\cdot \\mathds{1}_{\\{\\yi \\,\\neq\\, \\bmmh(\\xi)\\}}\n      $$\n      \\State Compute: $ \\betamh = \\frac{1}{2} \\log \\left( \\frac{1 - \\errm}{\\errm}\\right)$\n      \\State Set: $w^{[m+1](i)} = \\wmi \\cdot \\exp\\left(- \\betamh \\cdot\n        \\yi \\cdot \\hat{h}(\\xi)\\right) $\n      \\State Normalize $w^{[m+1](i)}$ such that $\\sumin w^{[m+1](i)} = 1$\n    \\EndFor\n    \\State Output: $\\fxh = \\sum_{m=1}^{M} \\betamh \\bmmh(\\xv)$\n  \\end{algorithmic}\n  \\caption{AdaBoost}\n\\end{algorithm}\n\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Adaboost illustration}\n\\begin{footnotesize}\n\n\\textbf{Example}\n\n\\begin{itemize}\n  \\item $n = 10$ observations and two features $x_1$ and $x_2$ \n  \\item Tree stumps as base learners $\\bmm(\\xv)$\n  \\item Balanced classification task with $y$ encoded as $\\setmp$\n  \\item $M = 3$ iterations $\\Rightarrow$ initial weights \n  $w^{[1](i)} = \\frac{1}{10} \\quad \\forall i \\in 1,\\dots ,10$. \n  % \\item The label of every observation is represented by triangle or circle.\n  % \\item Dark grey area: Base model in iteration $m$ predicts triangle.\n  % \\item Light grey area: Base model in iteration $m$ predicts circle.\n\\end{itemize}\n\n\\vfill\n\n\\begin{minipage}[b]{0.45\\textwidth}\n  \\includegraphics[width=0.9\\textwidth]{figure/adaboost_viz_mlr3_1.png}\\\\\n  \\textbf{Iteration} $m$ = 1:\n  \\begin{itemize}\n    \\item $\\text{err}^{[1]} = 0.3$\n    % \\item The ratio $(1 - \\errm) / \\errm$ used to calculate the weights \n    \\item $\\hat{\\beta}^{[1]} = \\frac{1}{2} \\log \\left( \\frac{1 - 0.3}{0.3} \n    \\right) \\approx 0.42$\n  \\end{itemize}\n\\end{minipage}%\n\\begin{minipage}[b]{0.55\\textwidth}\n  New observation weights:\n  \\begin{itemize}\n    %\\item $\\wmi \\cdot \\exp \\left(\\betamh \\cdot \\mathds{1}_{\\{\\yi \\neq \\bmmh(\\xi)\\}} \\right)$\n    \\item Prediction correct: \\\\\n      $w^{[2](i)} = w^{[1](i)} \\cdot \\exp \\left(-\\hat \\beta^{[1]} \\cdot 1 \n      \\right)$\\\\ $\\approx 0.065.$\n    \\item For 3 misclassified observations: \\\\\n      $w^{[2](i)} = w^{[1](i)} \\cdot \\exp \\left(-\\hat \\beta^{[1]} \\cdot (-1) \n      \\right)$\\\\ $\\approx 0.15.$\n    \\item After normalization: \n    \\begin{itemize}\n      \\begin{footnotesize}\n      \\item correctly classified: $w^{[2](i)} \\approx 0.07$\n      \\item misclassified: $w^{[2](i)} \\approx 0.17$\n      \\end{footnotesize}\n    \\end{itemize}\n\\end{itemize}\n\\end{minipage}\n\n\\end{footnotesize}\n\n% ------------------------------------------------------------------------------\n\n\\framebreak\n\n\\begin{minipage}[c]{0.4\\textwidth}\n  \\includegraphics[width = \\textwidth]{figure/adaboost_viz_mlr3_2.png}\n\\end{minipage}%\n\\begin{minipage}[c]{0.05\\textwidth}\n  \\phantom{foo}\n\\end{minipage}%\n\\begin{minipage}[c]{0.6\\textwidth}\n  \\begin{footnotesize}\n  \\textbf{Iteration} $m = 2$:\n  \\begin{itemize}\n    \\item $\\text{err}^{[2]} = 3 \\cdot 0.07 = 0.21$ \n    \\item $\\hat{\\beta}^{[2]} \\approx 0.65$\n    % \\item The ratio $(1 - \\errm) / \\errm$ used to calculate the weights \n  \\end{itemize}\n  New observation weights:\n  \\begin{itemize}\n    \\item E.g., for 3 misclassified observations:\n      $w^{[3](i)} = w^{[2](i)} \\cdot \\exp \\left(-\\hat \\beta^{[1]} \\cdot (-1) \n      \\right) \\approx 0.14.$\n    \\item After normalization: $w^{[3](i)} \\approx 0.17$ (misclassified)\n  \\end{itemize}\n  \\textbf{Iteration} $m = 3$:\n  \\begin{itemize}\n    \\item $\\text{err}^{[3]} = 3 \\cdot 0.045 \\approx 0.14$ \n    \\item $\\hat{\\beta}^{[3]} \\approx 0.92$\n  % \\item The ratio $(1 - \\errm) / \\errm$ used to calculate the weights \n  \\end{itemize}\n  \\end{footnotesize}\n\\end{minipage}\n\n\\vfill\n\n\\begin{footnotesize}\n\\textbf{Note:} the smaller the error rate of a base learner, the larger the \nweight, e.g., $\\text{err}^{[3]} \\approx 0.14 < \\text{err}^{[1]} \\approx 0.3$ \nand $\\hat \\beta^{[3]} \\approx 0.92 > \\hat \\beta^{[1]} \\approx 0.42.$\n\\end{footnotesize}\n\n\\framebreak\n\n% ------------------------------------------------------------------------------\n\nWith $\\fxh = \\sum_{m=1}^{M} \\betamh \\bmmh(\\xv)$ and $h(\\xv) = \\text{sign}(\\fx) \n\\in \\setmp$, \\\\we get:\n\n\\begin{center}\n  \\includegraphics[trim = 0 20 0 10, clip, width = 0.8\\textwidth]{figure_man/adaboost_example_adjusted.png}\n\\end{center}\n\nHence, when all three base classifiers are combined, all samples are classified \ncorrectly.\n\n\\end{vbframe}\n\n%\\begin{vbframe}{Adaboost illustration}\n\n%\\begin{columns}\n%\\column{7cm}\n\n%%\\includegraphics[width=7cm]{figure_man/adaboost_example2.png}\n%\\includegraphics[width=7cm]{figure_man/adaboost_example_adjusted.PNG}\n%%\n\n%{\\footnotesize Schapire, Boosting, 2012.}\n\n%\\column{3cm}\n\n%The three base models are combined into one classifier.\n\n%All observations are correctly classified.\n\n%\\end{columns}\n\n%\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Bagging vs Boosting}\n\n\\begin{minipage}[t]{0.47\\textwidth}\n  \\textbf{Random forest}\n  \\begin{itemize}\n    \\item Base learners are typically deeper decision trees (not only stumps!)\n    \\item Equal weights for BL\n    \\item BLs fitted independently\n    \\item Aim: variance reduction\n    \\item Tends \\textbf{not} to overfit if ensemble size grows\n  \\end{itemize}\n\\end{minipage}%\n\\begin{minipage}[t]{0.06\\textwidth}\n  \\phantom{foo}\n\\end{minipage}%\n\\begin{minipage}[t]{0.47\\textwidth}\n  \\textbf{AdaBoost}\n  \\begin{itemize}\n    \\item BLs are weak learners, e.g., only stumps\n    \\item BL are weighted\n    \\item Sequential fitting of BLs\n    \\item Aim: loss reduction\n    \\item Tends to overfit with more iterations\n  \\end{itemize}\n\\end{minipage}\n\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Bagging vs Boosting Stumps}\n\nRandom forest versus AdaBoost (both with stumps) on \\texttt{spirals} data from \n\\texttt{mlbench} ($n=200$, $sd=0$), with $5 \\times 5$ repeated CV.\n\n% \\begin{minipage}[c]{0.6\\textwidth}\n%   \\includegraphics[width = \\textwidth]{figure_man/stump_plot_ntree.png}\n% \\end{minipage}%\n% \\begin{minipage}[c]{0.4\\textwidth}\n%   \\begin{minipage}[c]{\\textwidth}\n%     \\includegraphics[width = \\textwidth]{figure_man/stump_plot_rf.png}\n%   \\end{minipage}\n%   \\begin{minipage}[c]{\\textwidth}\n%     \\includegraphics[width = \\textwidth]{figure_man/stump_plot_boost.png}\n%   \\end{minipage}\n% \\end{minipage}\n\n\\vfill\n\n\\includegraphics[width=\\textwidth]{figure/stump_plots.png}\n\n\\vfill\n\nWeak learners do not work well with bagging as only variance, but no bias reduction happens.\n\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n\\begin{vbframe}{Overfitting behavior}\n\nHistorically, the overfitting behavior of AdaBoost was often discussed.\n% Random Forest versus AdaBoost on \\texttt{Spirals} data from \\texttt{mlbench} ($n=200$, $sd=0.3$).\n% With $5 \\times 5$ repeated CV\nIncreasing standard deviation in \\texttt{spirals} to $sd = 0.3$ and allowing for more flexibility in \nthe base learners, AdaBoost overfits with increasing number of trees while the \nRF only saturates.\nThe overfitting of AdaBoost here is quite typical as data is very noisy.\n\n\\vfill\n\n\\includegraphics[width=\\textwidth]{figure/stump_plots_noisy.png}\n\n\\end{vbframe}\n\n% ------------------------------------------------------------------------------\n\n% \\begin{vbframe}{Overfitting behavior}\n\n% A long-lasting discussion in the context of AdaBoost is its overfitting behavior.\n\n% % \\lz\n\n% % \\emph{When a prediction rule concentrates too much on peculiarities of the specific sample of training observations, it will often perform poorly on a new data set.}\n\n% % \\lz\n\n% The main instrument to avoid overfitting is the stopping iteration $M$:\n% \\begin{itemize}\n% \\item High values of $M$ lead to complex solutions. Overfitting?\n% \\item Small values of $M$ lead to simple solutions. Underfitting?\n% \\end{itemize}\n% Although it will overfit eventually, AdaBoost in general shows a rather slow overfitting behavior.\n% \\framebreak\n\n% As an example we have a look on random forest vs. AdaBoost on the \\textit{Spiral} data\n% from \\texttt{mlbench} (n = 200, sd = 0.3). Performance (mmce) is measured\n% with 5-fold CV.\n\n% <<comparing-rf-ada1, echo=FALSE, fig.width=8, fig.height=4>>=\n% load(\"rsrc/overfitting_ada_rf.Rdata\")\n% result$M = as.numeric(as.character(result$M))\n% p = ggplot(result, aes(x = M, y = mmce, group = learner)) + \n%   geom_line()  +\n%   xlab(\"number trees\")\n% p\n% @\n\n% AdaBoost overfits with increasing number of trees while\n% the mmce of the random forest fluctuates on a constant level for the test data.\n% \\framebreak\n\n% This becomes even more apparent when we take a look on the prediction surface. \n  \n% <<comparing-rf-ada2, echo=FALSE, fig.width=13, fig.height=4.5 >>=\n% load(\"rsrc/overfitting_plots.RData\")\n% learnerPredPlot1 = learnerPredPlot1  + ggplot2::ggtitle(\"rf\") \n% learnerPredPlot2 = learnerPredPlot2 + ggplot2::ggtitle(\"adaboost\")\n% gridExtra::grid.arrange(learnerPredPlot1, learnerPredPlot2, ncol = 2)\n% @\n\n% \\end{vbframe}\n\n% % \\begin{vbframe}{Software in R}\n% %   \\begin{itemize}\n% %     \\item Bagging: Package \\pkg{mlr} is able to bag any learner with \\code{makeBaggingWrapper()}.\n% %   \\item Random Forests: Package \\pkg{randomForest} with function\n% %     \\code{randomForest()} based on CART.\n% %   \\item AdaBoost: included in the packages \\code{ada} and \\code{boosting}.\n% % \\end{itemize}\n% % \\end{vbframe}\n\n\n\n\\endlecture\n\\end{document}\n\n", "meta": {"hexsha": "3eed2c7c0f03388c41480b4ed4823ba40bd490f8", "size": 15073, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/boosting/slides-boosting-intro-adaboost.tex", "max_stars_repo_name": "jukaje/lecture_i2ml", "max_stars_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/boosting/slides-boosting-intro-adaboost.tex", "max_issues_repo_name": "jukaje/lecture_i2ml", "max_issues_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/boosting/slides-boosting-intro-adaboost.tex", "max_forks_repo_name": "jukaje/lecture_i2ml", "max_forks_repo_head_hexsha": "cd4900f5190e9d319867b4c0eb9d8e19f659fb62", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6505747126, "max_line_length": 198, "alphanum_fraction": 0.6522258343, "num_tokens": 4533, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.41142013306853226}}
{"text": "\\newappendix{Gridworld example where multi-step outperforms one-step}\\label{sec:app_grid}\n\nAs explained in the main text, this section presents an example that is only a slight modification of the one in Figure \\ref{fig:gridworld}, but where a multi-step approach is clearly preferred over just one step. The data-generating and learning processes are exactly the same (100 trajectories of length 100, discount 0.9, $ \\alpha = 0.1$ for reverse KL regularization). The only difference is that rather than using a behavior that is a mixture of optimal and uniform, we use a behavior that is a mixture of maximally suboptimal and uniform. If we call the suboptimal policy $ \\pi^-$ (which always goes down and left in our gridworld), then the behavior for the modified example is $ \\beta = 0.2 \\cdot \\pi^- + 0.8 \\cdot u$, where $ u $ is uniform. Results are shown in Figure \\ref{fig:multi_gridworld}.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=\\textwidth]{figures/offline-rl/gridworld/multi_gridworld_flat.png}\n    \\includegraphics[width=\\textwidth]{figures/offline-rl/gridworld/multi_gridworld_error.png}\n    \\caption{A gridworld example with modified behavior where multi-step is much better than one-step.}\n    \\label{fig:multi_gridworld}\n\\end{figure}\n\nBy being more likely to go to the noisy states, this behavior policy allows us to get lower variance estimates of the rewards. Essentially, the coverage of the behavior policy in this example reduces the magnitude of the evaluation errors. This allows for more aggressive planning using multi-step methods. Moreover, since the behavior is less likely to go to the good state, the behavior Q function does not propagate the signal from the rewarding state as far, harming the one-step method.\n\n\\newappendix{Connection to policy improvement guarantees}\\label{sec:app_improvement}\n\n\nThe regularized or constrained one-step algorithm performs an update that directly inherits guarantees from the literature on conservative policy improvement \\citep{kakade2002approximately, schulman2015trust, achiam2017constrained}. These original papers consider an online setting where more data is collected at each step, but the guarantee at each step applies to our one-step offline algorithm.\n\nThe key idea of this line of work begins with the performance difference lemma of \\cite{kakade2002approximately}, and then lower bounds the amount of improvement over the behavior policy. Define the discounted state visitation distribution for a policy $ \\pi$ by $ d^\\pi(s) := (1-\\gamma) \\sum_{t=0}^\\infty \\gamma^t \\Prob_{\\rho, P, \\pi}(s_t = s)$. We will also use the shorthand $ Q(s, \\pi) $ to denote $ \\E_{a\\sim\\pi|s}[Q(s,a)]$. Then we have the performance difference lemma as follows.\n\n\\begin{lemma}[Performance difference, \\cite{kakade2002approximately}]\nFor any two policies $ \\pi$ and $ \\beta$,\n\\begin{align}\n    J(\\pi) - J(\\beta) = \\frac{1}{1-\\gamma} \\E_{\\substack{s \\sim d^\\pi}}[ Q^\\beta(s,\\pi) - Q^\\beta(s, \\beta)]. %:= \\frac{1}{1-\\gamma} \\E_{\\substack{s \\sim d_\\pi }}[ A^\\beta_\\pi(s)].\n\\end{align}\n\\end{lemma}\n\nThen, Corollary 1 from \\cite{achiam2017constrained} (reproduced below) gives a guarantee for the one-step algorithm. The key idea is that when $ \\pi $ is sufficiently close to $ \\beta$, we can use $ Q^\\beta$ as an approximation to $ Q^\\pi$.\n\\begin{lemma}[Conservative Policy Improvement, \\cite{achiam2017constrained}]\nFor any two policies $ \\pi$ and $ \\beta$, let $ \\|A^\\beta_\\pi\\|_{\\infty} = \\sup_s  |Q^\\beta(s,\\pi) - Q^\\beta(s, \\beta)|$. Then,\n    \\begin{align}\n        J(\\pi) - J(\\beta) \\geq \\frac{1}{1-\\gamma} \\E_{\\substack{s \\sim d^\\beta}}\\left[ \\left(Q^\\beta(s,\\pi) - Q^\\beta(s, \\beta)\\right) - \\frac{2\\gamma \\|A^\\beta_\\pi\\|_\\infty}{1-\\gamma} D_{TV}(\\pi(\\cdot|s)\\|\\beta(\\cdot|s)) \\right]\n    \\end{align}\nwhere $ D_{TV}$ denotes the total variation distance.\n\\end{lemma}\n\nReplacing $ Q^\\beta$ with $ \\widehat Q^\\beta$ and the TV distance by the KL, we get precisely the objective that we optimize in the one-step algorithm. This shows that the one-step algorithm indeed optimizes a lower bound on the performance difference. Of course, in practice we replace the potentially large multiplier on the divergence term by a hyperparameter, but this theory at least motivates the soundness of the approach.\n\nWe are not familiar with similar guarantees for the iterative or multi-step approaches that rely on off-policy evaluation.\n\n\n\\newappendix{Experimental setup}\\label{sec:app_exp_setup}\n\n\\subsection{Benchmark experiments (Tables \\ref{tab:d4rl} and \\ref{tab:multi}, Figure \\ref{fig:learning_curves})}\n\n\\paragraph{Data.} We use the datasets from the D4RL benchmark \\citep{fu2020d4rl}. We use the latest versions, which are v2 for the mujoco datasets and v1 for the adroit datasets.\n\n\\paragraph{Hyperparameter tuning.}\n\\begin{table}[ht]\n\\vspace{-0.2cm}\n    \\centering\n    \\caption{Hyperparameter sweeps for each algorithm.}\n    \\begin{small}\n    \\begin{tabular}{lc}\n        \\toprule\n        Algorithm & Hyperparameter set \\\\\n        \\midrule\n        Reverse KL ($ \\alpha$) &\n                    \\{0.03, 0.1, 0.3, 1.0, 3.0, 10.0\\}\\\\\n        Easy BCQ ($ M$) &\n                    \\{2, 5, 10, 20, 50, 100\\}\\\\\n        Exponentially weighted ($ \\tau$) &\n                    \\{0.1, 0.3, 1.0, 3.0, 10.0, 30.0\\}\\\\\n        \\bottomrule\n    \\end{tabular}\n    \\end{small}\n    \\label{tab:hyperparams}\n\\end{table}\nWe follow the practice of \\cite{fu2020d4rl} and tune a small set of hyperparameters by interacting with the simulator to estimate the value of the policies learned under each hyperparameter setting. The hyperparameter sets for each algorithm can be seen in Table \\ref{tab:hyperparams}.\n\nThis may initially seem like ``cheating'', but can be a reasonable setup if we are considering applications like robotics where we can feasibly test a small number of trained policies on the real system. Also, since prior work has used this setup, it makes it easiest to compare our results if we use it too. While beyond the scope of this work, we do think that better offline model selection procedures will be crucial to make offline RL more broadly applicable. A good primer on this topic can be found in \\cite{paine2020hyperparameter}.\n\n\n\\paragraph{Models.} All of our Q functions and policies are simple MLPs with ReLU activations and 2 hidden layers of width 1024. Our policies output a truncated normal distribution with diagonal covariance where we can get reparameterized samples by sampling from a uniform distribution and computing the differentiable inverse CDF \\citep{Burkhardt2014truncated}. We found this to be more stable than the tanh of normal used by e.g. \\cite{fu2020d4rl}, but to achieve similar performance when both are stable. We use these same models across all experiments.\n\n\n\\paragraph{One-step training procedure.} For all of our one-step algorithms, we train our $ \\hat \\beta $ behavior estimate by imitation learning for 500k gradient steps using Adam \\citep{kingma2014adam} with learning rate 1e-4 and batch size 512. We train our $ \\widehat Q^\\beta$ estimator by fitted Q evaluation with a target network for 2 million gradient steps using Adam with learning rate 1e-4 and batch size 512. The target is updated softly at every step with parameter $ \\tau = 0.005$. All policies are trained for 100k steps again with Adam using learning rate 1e-4 and batch size 512.\n\nEasy BCQ does not require training a policy network and just uses $ \\hat \\beta$ and $ \\widehat Q^\\beta$ to define it's policy. For the exponentially weighted algorithm, we clip the weights at 100 to prevent numerical instability. To estimate reverse KL at some state we use 10 samples from the current policy and the density defined by our estimated $ \\hat \\beta$.\n\nEach random seed retrains all three models (behavior, Q, policy) from different initializations. We use three random seeds.\n\n\\paragraph{Multi-step training procedure.} For multi-step algorithms we use all the same hyperparameters as one-step. We initialize our policy and Q function from the same pre-trained $ \\hat \\beta$ and $ \\widehat Q^\\beta$ as we use for the one-step algorithm trained for 500k and 2 million steps respectively. Then we consider 5 policy steps. To ensure that we use the same number of gradient updates on the policy, each step consists of 20k gradient steps on the policy followed by 200k gradient steps on the Q function. Thus, we take the same 100k gradient steps on the policy network. Now the Q updates are off-policy so the next action $a'$ is sampled from the current policy $ \\pi_i$ rather than from the dataset.\n\n\\paragraph{Iterative training procedure.} For iterative algorithms we again use all the same hyperparameters and initialize from the same $ \\hat \\beta$ and $ \\widehat Q^\\beta$. We again take the same 100k gradient steps on the policy network. For each step on the policy network we take 2 off-policy gradient steps on the Q network.\n\n\n\n\\paragraph{Evaluation procedure.} To evaluate each policy we run 100 trajectories in the environment and compute the mean. We then report the mean and standard deviation over three training seeds.\n\n\n\n\n\\subsection{MSE experiment (Figure 3)}\n\n\\paragraph{Data.} To get an independently sampled dataset of the same size as the training set, we use the behavior cloned policy $ \\hat \\beta$ to sample 1000 trajectories. The checkpointed policies are taken at intervals of 5000 gradient steps from each of the three training seeds.\n\n\\paragraph{Training procedure.} The $\\widehat Q^{\\pi_i}$ training procedure is the same as before so we use Adam with step size 1e-4 and batch size 512 and a target network with soft updates with parameter 0.005. We train for 1 million steps.\n\n\\paragraph{Evaluation procedure.} To evaluate MSE, we sample 1000 state, action pairs from the original training set and from each state, action pair we run 3 rollouts. We take the mean over the rollouts and then compute squared error at each state, action pair and finally get MSE by taking the mean over state, action pairs. The reported reverse KL is evaluated by samples during training. At each state in a batch we take 10 samples to estimate the KL at that state and then take the mean over the batch.\n\n\n\\subsection{Gridworld experiment (Figure 4)}\n\n\\paragraph{Environment.} The environment is a 15 x 15 gridworld with deterministic transitions. The rewards are deterministically 1 for all actions taken from the state in the top right corner and stochastic with distribution $ \\mathcal{N}(-0.5, 1)$ for all actions taken from states on the left or bottom walls. The initial state is uniformly random. The discount is 0.9.\n\n\\paragraph{Data.} We collect data from a behavior policy that is a mixture of the uniform policy (with probability 0.8) and an optimal policy (with probability 0.2). We collect 100 trajectories of length 100.\n\n\\paragraph{Training procedure.} We give the agent access to the deterministic transitions. The only thing for the agent to do is estimate the rewards from the data and then learn in the empirical MDP. We perform tabular Q evaluation by dynamic programming. We initialize with the empirical rewards and do 100 steps of dynamic programming with discount 0.9. Regularized policy updates are solved for exactly by setting $ \\pi_i(a|s) \\propto \\beta(a|s) \\exp(\\frac{1}{\\alpha} \\widehat Q^{\\pi_{i-1}}(s,a))$.\n\n\n\n\n\\subsection{Overestimation experiment (Figure 5)}\n\nThis experiment uses the same setup as the MSE experiment. The main difference is we also consider the Q functions learned during training and demonstrate the overestimation relative to the Q functions trained on the evaluation dataset as in the MSE experiment.\n\n\n\\subsection{Mixed data experiment (Figure 6)}\n\nWe construct datasets with $ p_m = \\{0.0, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0\\}$ by mixing the random and medium datasets from D4RL and then run the same training procedure as we did for the benchmark experiments. Each dataset has the same size, but a different proportion of trajectories from the medium policy.\n\n\n\\newappendix{Learning curves}\\label{sec:app_extra_exp}\n\nIn this section we reproduce the learning curves and hyperparameter plots across the one-step, multi-step, and iterative algorithms with reverse KL regularization, as in Figure \\ref{fig:learning_curves}.\n\n\\vspace{-0.2cm}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-halfcheetah-medium-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-walker2d-medium-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-hopper-medium-v2.png}\n    \\vspace{-0.2cm}\n    \\caption{Learning curves on the medium datasets.}\n    \\label{fig:app_lc_medium}\n\\end{figure}\n\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-halfcheetah-medium-expert-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-walker2d-medium-expert-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-hopper-medium-expert-v2.png}\n    \\vspace{-0.2cm}\n    \\caption{Learning curves on the medium-expert datasets.}\n    \\label{fig:app_lc_medium-expert}\n\\end{figure}\n\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-halfcheetah-random-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-walker2d-random-v2.png}\n    \\includegraphics[width=0.85\\textwidth]{figures/offline-rl/learning curves/lc-hopper-random-v2.png}\n    \\vspace{-0.2cm}\n    \\caption{Learning curves on the random datasets.}\n    \\label{fig:app_lc_random}\n\\end{figure}\n\n\n\\printendnotes", "meta": {"hexsha": "d577743c52b0124190ee8813c55ecbb8dbd3eab3", "size": 13723, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/offline-rl-appendix.tex", "max_stars_repo_name": "willwhitney/dissertation", "max_stars_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-20T20:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-20T20:31:06.000Z", "max_issues_repo_path": "content/offline-rl-appendix.tex", "max_issues_repo_name": "willwhitney/doctoral-thesis", "max_issues_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/offline-rl-appendix.tex", "max_forks_repo_name": "willwhitney/doctoral-thesis", "max_forks_repo_head_hexsha": "a9842f84e53ca47ec849488b6cb9acb8a11336ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-25T13:01:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-25T13:01:43.000Z", "avg_line_length": 84.1901840491, "max_line_length": 805, "alphanum_fraction": 0.7600378926, "num_tokens": 3510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.41142013032770886}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\n\n\n\\title{Chapter 3\\\\Vector Analysis}\n\\author{solutions by Hikari}\n\\date{July 2021}\n\\begin{document}\n\n\\maketitle\n\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\M}{\\mathrm}\n\\newcommand{\\VE}{\\hat{\\V{e}}}\n\\newcommand{\\del}{\\boldsymbol{\\nabla}}\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\ppdv}[3]{\\frac{\\partial^2#1}{\\partial#2\\partial#3}}\n\\newcommand{\\dv}[2]{\\frac{d #1}{d #2}}\n\n\\section*{3.2 Vectors in 3-D Space}\n\n\\paragraph{3.2.1}\n$\\V{P}\\times \\V{Q}=\\sum_i \\hat{\\V{e}}_i\\sum_{jk}\\varepsilon_{ijk}P_j Q_k$.  $P_z=Q_z=0$, so $\\varepsilon_{ijk}P_j Q_k\\neq0$ only when $i=z$. So $\\sum_i \\hat{\\V{e}}_i\\sum_{jk}\\varepsilon_{ijk}P_j Q_k=\\hat{\\V{e}}_z(P_xQ_y-P_yQ_x)\\neq0$ because $\\V{P}$ and $\\V{Q}$ are nonparallel.\n\n\\paragraph{3.2.2}\n$(\\V{A}\\times \\V{B})\\cdot(\\V{A}\\times \\V{B})=(A_xB_y-A_yB_x)^2+(A_xB_z-A_zB_x)^2+(A_yB_z-A_zB_y)^2=A_x^2B_y^2+A_x^2B_z^2+A_y^2B_x^2+A_y^2B_z^2+A_z^2B_x^2+A_z^2B_y^2-2A_xB_xA_yB_y-2A_xB_xA_zB_z-2A_yB_yA_zB_z$. $(AB)^2-(\\V{A}\\cdot \\V{B})^2=(A_x^2+A_y^2+A_z^2)(B_x^2+B_y^2+B_z^2)-(A_xB_x+A_yB_y+A_zB_z)^2=A_x^2B_y^2+A_x^2B_z^2+A_y^2B_x^2+A_y^2B_z^2+A_z^2B_x^2+A_z^2B_y^2-2A_xB_xA_yB_y-2A_xB_xA_zB_z-2A_yB_yA_zB_z$, so $(\\V{A}\\times \\V{B})\\cdot(\\V{A}\\times \\V{B})=(AB)^2-(\\V{A}\\cdot \\V{B})^2$.\n\n\\paragraph{3.2.3}\n$\\sin(\\theta+\\psi)=\\frac{|\\V{P}\\times\\V{Q}|}{|\\V{P}||\\V{Q}|}=|(-\\sin{\\theta}\\cos{\\psi}-\\cos{\\theta}\\sin{\\psi})\\hat{e_z}|=\\sin{\\theta}\\cos{\\psi}+\\cos{\\theta}\\sin{\\psi}$.\n\n$\\cos{(\\theta+\\psi)}=\\frac{\\V{P}\\cdot\\V{Q}}{|\\V{P}||\\V{Q}|}=\\cos{\\theta}\\cos{\\psi}-\\sin{\\theta}\\sin{\\psi}$.\n\n\\paragraph{3.2.4}\n(a) $\\V{U}\\times\\V{V}=-3\\hat{\\V{e}}_y-3\\hat{\\V{e}}_z$ is perpendicular with $\\V{U}$ and $\\V{V}$.\n\n(b) $\\frac{\\V{U}\\times\\V{V}}{|\\V{U}\\times\\V{V}|}=\\frac{1}{\\sqrt{2}}\\VE_y+\\frac{1}{\\sqrt{2}}\\VE_z$\n\n\\paragraph{3.2.5}\nAll the four vectors are in the same plane, so both $\\V{a}\\times\\V{b}$ and $\\V{c}\\times\\V{d}$ are perpendicular to the plane, so $\\V{a}\\times\\V{b}$ and $\\V{c}\\times\\V{d}$ are parallel, so $(\\V{a}\\times\\V{b})\\times(\\V{c}\\times\\V{d})=0$. \n\n\\paragraph{3.2.6}\nThe area of the triangle $=\\frac{1}{2}|\\V{B}||\\V{C}|\\sin\\alpha=\\frac{1}{2}|\\V{A}||\\V{C}|\\sin\\beta=\\frac{1}{2}|\\V{A}||\\V{B}|\\sin\\gamma$. Devided by $|\\V{A}||\\V{B}||\\V{C}|/2$, we get $\\frac{\\sin\\alpha}{|\\V{A}|}=\\frac{\\sin\\beta}{|\\V{B}|}=\\frac{\\sin\\gamma}{|\\V{C}|}$.\n\n\\paragraph{3.2.7}\n$\\VE_x\\times\\V{B}=2\\VE_z-4\\VE_y$, $\\VE_y\\times\\V{B}=4\\VE_x-\\VE_z$, $\\VE_z\\times\\V{B}=\\VE_y-2\\VE_x$ by the experiments.  $\\VE_x\\cdot(\\VE_y\\times \\V{B})=\\V{B}\\cdot(\\VE_x\\times\\VE_y)=\\V{B}\\cdot(\\VE_z)=\\V{B}_z=4$, $\\VE_y\\cdot(\\VE_z\\times \\V{B})=\\V{B}\\cdot(\\VE_y\\times\\VE_z)=\\V{B}\\cdot(\\VE_x)=\\V{B}_x=1$, $\\VE_z\\cdot(\\VE_x\\times \\V{B})=\\V{B}\\cdot(\\VE_z\\times\\VE_x)=\\V{B}\\cdot(\\VE_y)=\\V{B}_y=2$. So $\\V{B}=\\VE_x+2\\VE_y+4\\VE_z$.\n\n\\paragraph{3.2.8}\n(a) $\\V{A}\\cdot\\V{B}\\times\\V{C}=(\\VE_x+\\VE_y)\\cdot(-\\VE_x+\\VE_y-\\VE_z)=0$. It is true because $\\V{B}$, $\\V{C}$ and $\\V{B}\\times\\V{C}$ are in the same plane, so the volume of the parallelepiped is zero.\n\n(b) $\\V{A}\\times(\\V{B}\\times\\V{C})=(\\VE_x+\\VE_y)\\times(-\\VE_x+\\VE_y-\\VE_z)=-\\VE_x+\\VE_y+2\\VE_z$.\n\n\\paragraph{3.2.9}\n$\\V{a}\\times(\\V{b}\\times\\V{c})+\\V{b}\\times(\\V{c}\\times\\V{a})+\\V{c}\\times(\\V{a}\\times\\V{b})=\\V{b}(\\V{a}\\cdot\\V{c})-\\V{c}(\\V{a}\\cdot\\V{b})+\\V{c}(\\V{b}\\cdot\\V{a})-\\V{a}(\\V{b}\\cdot\\V{c})+\\V{a}(\\V{c}\\cdot\\V{b})-\\V{b}(\\V{c}\\cdot\\V{a})=0$.\n\n\\paragraph{3.2.10}\n(a) $\\V{A}_r=\\hat{\\V{r}}(\\V{A}\\cdot\\hat{\\V{r}})$ is quite obvious by the definition.\n\n(b) $\\V{A}_t=\\V{A}-\\V{A}_r=\\V{A}(\\hat{\\V{r}}\\cdot\\hat{\\V{r}})-\\hat{\\V{r}}(\\V{A}\\cdot\\hat{\\V{r}})=-\\hat{\\V{r}}\\times(\\hat{\\V{r}}\\times\\V{A})$.\n\n\\paragraph{3.2.11}\nIf $\\V{A}$, $\\V{B}$, and $\\V{C}$ are coplanar, then $\\V{B}\\times\\V{C}$ is perpendicular to  $\\V{B}$, $\\V{C}$ and therefore perpendicular to $\\V{A}$, so $\\V{A}\\cdot\\V{B}\\times\\V{C}=0$. If $\\V{A}\\cdot\\V{B}\\times\\V{C}=0$, then $\\V{A}$ is perpendicular to $\\V{B}\\times\\V{C}$, but $\\V{B}\\times\\V{C}$ is perpendicular to the plane of $\\V{B}$ and $\\V{C}$, so $\\V{A}$, $\\V{B}$, and $\\V{C}$ are coplanar.\n\n\\paragraph{3.2.12}\n$\\V{A}\\cdot\\V{B}\\times\\V{C}=-120$, $\\V{A}\\times(\\V{B}\\times\\V{C})=-60\\VE_x-40\\VE_y+50\\VE_z$, $\\V{C}\\times(\\V{A}\\times\\V{B})=24\\VE_x+88\\VE_y-62\\VE_z$, $\\V{B}\\times(\\V{C}\\times\\V{A})=36\\VE_x-48\\VE_y+12\\VE_z$.\n\n\\paragraph{3.2.13}\n$(\\V{A}\\times\\V{B})\\cdot(\\V{C}\\times\\V{D})=(\\V{B}\\times(\\V{C}\\times\\V{D}))\\cdot\\V{A}=(\\V{C}(\\V{B}\\cdot\\V{D})-\\V{D}(\\V{B}\\cdot\\V{C}))\\cdot\\V{A}=(\\V{A}\\cdot\\V{C})(\\V{B}\\cdot\\V{D})-(\\V{A}\\cdot\\V{D})(\\V{B}\\cdot\\V{C})$.\n\n\\paragraph{3.2.14}\n$(\\V{A}\\times\\V{B})\\times(\\V{C}\\times\\V{D})=\\V{C}(\\V{A}\\times\\V{B}\\cdot\\V{D})-\\V{D}(\\V{A}\\times\\V{B}\\cdot\\V{C})=(\\V{A}\\cdot\\V{B}\\times\\V{D})\\V{C}-(\\V{A}\\cdot\\V{B}\\times\\V{C})\\V{D}$.\n\n\\paragraph{3.2.15}\n(a) $\\V{F}_2=q_2\\V{v}_2\\times\\V{B}=\\frac{\\mu_0}{4\\pi}\\frac{q_1q_2}{r^2}\\V{v}_2\\times(\\V{v}_1\\times\\hat{\\V{r}})$.\n\n(b) With $\\V{v}_1$ replaced by $\\V{v}_2$, $\\V{v}_2$ replaced by $\\V{v}_1$, $\\hat{\\V{r}}$ replaced by $-\\hat{\\V{r}}$, $\\V{F}_1=-\\frac{\\mu_0}{4\\pi}\\frac{q_1q_2}{r^2}\\V{v}_1\\times(\\V{v}_2\\times\\hat{\\V{r}})$.\n\n(c) $\\hat{\\V{r}}$ are perpendicular to $\\V{v}_2,\\V{v}_1$, and $\\V{v}_2,\\V{v}_1$ are parallel, so $\\V{F}_2=-\\frac{\\mu_0}{4\\pi}\\frac{q_1q_2}{r^2}v_2v_1\\hat{\\V{r}}=-\\V{F}_1$.\n\n\\section*{3.3 Coordinate Transformations}\n\n\\paragraph{3.3.1}\n\\[\n\\begin{pmatrix}\n\\cos(\\varphi_1+\\varphi_2)&\\sin(\\varphi_1+\\varphi_2)\\\\\n-\\sin(\\varphi_1+\\varphi_2)&\\cos(\\varphi_1+\\varphi_2)\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\cos\\varphi_2&\\sin\\varphi_2\\\\\n-\\sin\\varphi_2&\\cos\\varphi_2\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\varphi_1&\\sin\\varphi_1\\\\\n-\\sin\\varphi_1&\\cos\\varphi_1\n\\end{pmatrix}\n\\]\n\n\\paragraph{3.3.2}\nLet the three reflecting surfaces be parallel to $xy$, $xz$, $yz$ surfaces. Let the direction vector of the incident light be $(k_1,k_2,k_3)$. Then after each reflection, one of the coordinate changes sign, so the direction vector of reflected light is $(-k_1,-k_2,-k_3)$, parallel to the incident light.\n\n\\paragraph{3.3.3}\n$(\\V{x}')^T\\V{y}'=\\V{x}^T\\M{S}^T\\M{S}\\V{y}=\\V{x}^T\\V{y}$ because $\\M{S}$ is orthogonal.\n\n\\paragraph{3.3.4}\n(a) $\\det\\M{S}=1$\n\n(b) $\\V{a}\\cdot\\V{b}=-1$, $\\M{S}\\V{a}\\cdot\\M{S}\\V{b}=(0.8, 0.12, 1.16)\\cdot(1.2, 0.68, -1.76)=-1$\n\n(c) $\\V{a}\\times\\V{b}=(-2, 1, 2)$, $\\M{S}(\\V{a}\\times\\V{b})=(-1, 2.8, 0.4)$, $\\M{S}\\V{a}\\times\\M{S}\\V{b}=(-1, 2.8, 0.4)$. It is as expected because pseudovectors transform as vectors when the orthogonal transformation is not a reflection ($\\det (\\M{S})=-1$).\n\n\\paragraph{3.3.5}\n(a) $\\det (\\M{S})=-1$\n\n(b) $(\\M{S}\\V{a})\\times(\\M{S}\\V{b})=(-0.4, -1.64, -2.48)$; $\\M{S}(\\V{a}\\times\\V{b})=(0.4, 1.64, 2.48)$. The sign changes.\n\n(c) $(\\M{S}\\V{a}\\times\\M{S}\\V{b})\\cdot\\M{S}\\V{c}=-3$; $\\M{S}((\\V{a}\\times\\V{b})\\cdot\\V{c})=(\\V{a}\\times\\V{b})\\cdot\\V{c}=3$. The sign changes.\n\n(d) $\\M{S}\\V{a}\\times(\\M{S}\\V{b}\\times\\M{S}\\V{c})=(-0.4, -8.84, 7.12)$; $\\M{S}(\\V{a}\\times(\\V{b}\\times\\V{c}))=(-0.4, -8.84, 7.12)$. The sign does not change.\n\n(e) $\\V{a}\\times\\V{b}$ is a pseudovector, $(\\V{a}\\times\\V{b})\\cdot\\V{c}$ is a pseudoscalar, $\\V{a}\\times(\\V{b}\\times\\V{c})$ is a vector.\n\n\\section*{3.4 Rotations in $\\mathbb{R}^3$}\n\n\\paragraph{3.4.1}\nThe corresponding transformation matrix is \n\\[\n\\begin{pmatrix}\n\\cos\\psi&\\sin\\psi&0\\\\\n-\\sin\\psi&\\cos\\psi&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\theta&\\sin\\theta\\\\\n0&-\\sin\\theta&\\cos\\theta\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\varphi&\\sin\\varphi&0\\\\\n-\\sin\\varphi&\\cos\\varphi&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\]\nMake the substitution by $\\cos\\varphi=-\\sin\\alpha$, $\\sin\\varphi=\\cos\\alpha$, $\\cos\\theta=\\cos\\beta$, $\\sin\\theta=\\sin\\beta$, $\\cos\\psi=\\sin\\gamma$, $\\sin\\psi=-\\cos\\gamma$. The matrix becomes\n\\[\n\\begin{pmatrix}\n\\sin\\gamma&-\\cos\\gamma&0\\\\\n\\cos\\gamma&\\sin\\gamma&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\beta&\\sin\\beta\\\\\n0&-\\sin\\beta&\\cos\\beta\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n-\\sin\\alpha&\\cos\\alpha&0\\\\\n-\\cos\\alpha&-\\sin\\alpha&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\]\n\\[=\n\\begin{pmatrix}\n\\sin\\gamma&-\\cos\\gamma&0\\\\\n\\cos\\gamma&\\sin\\gamma&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n-\\sin\\alpha&\\cos\\alpha&0\\\\\n-\\cos\\beta\\cos\\alpha&-\\cos\\beta\\sin\\alpha&\\sin\\beta\\\\\n\\sin\\beta\\cos\\alpha&\\sin\\beta\\sin\\alpha&\\cos\\beta\\\\\n\\end{pmatrix}\n\\]\n\\[=\n\\begin{pmatrix}\n-\\sin\\gamma\\sin\\alpha+\\cos\\gamma\\cos\\beta\\cos\\alpha&\n\\sin\\gamma\\cos\\alpha+\\cos\\gamma\\cos\\beta\\sin\\alpha&\n-\\cos\\gamma\\sin\\beta\\\\\n-\\cos\\gamma\\sin\\alpha-\\sin\\gamma\\cos\\beta\\cos\\alpha&\n\\cos\\gamma\\cos\\alpha-\\sin\\gamma\\cos\\beta\\sin\\alpha&\n\\sin\\gamma\\sin\\beta\\\\\n\\sin\\beta\\cos\\alpha&\n\\sin\\beta\\sin\\alpha&\n\\cos\\beta\\\\\n\\end{pmatrix}\n\\]\nwhich is the same as the transformation matrix in Eq. (3.37).\n\n\\paragraph{3.4.2}\n(In the original system, the North Pole is in the $x_3$-axis direction, and the middle point of Prime Meridian($0^\\circ,0^\\circ$) is in the $x_2$-axis direction) Rotate $\\alpha=70^\\circ$ around $x_3$-axis to align $x_1$-axis with $20^\\circ$ west, and rotate $\\beta=60^\\circ$ around $x_2$-axis to align the North Pole with $30^\\circ$ north, and Rotate $\\gamma=-80^\\circ$ around $x_3$-axis to align the $10^\\circ$ west Meridian with the Meridian in new system). Calculating from Eq. (3.37), the transformation matrix is \n\\[\n\\begin{pmatrix}\n0.9551&-0.2552&-0.1504\\\\\n0.0052&0.5221&-0.8529\\\\\n0.2962&0.8138&0.5000\\\\\n\\end{pmatrix}\n\\]\n\n\\paragraph{3.4.3}\nAll the trigonometric function except $\\cos\\beta$ change sign. Substituting, we found that the rotation matrix $\\M{S}$ remains unchanged.\n\n\\paragraph{3.4.4}\n$\\M{S}(\\alpha,\\beta,\\gamma)=\\M{S}_3(\\gamma)\\M{S}_2(\\beta)\\M{S}_1(\\alpha)$. Note that $\\M{S}_i^{-1}(x)=\\tilde{\\M{S}}_i(x)$ (orthogonality) and $\\M{S}_i(x)^{-1}=\\M{S}_i(-x)$ (property of rotation matrix). So \n\\[\\M{S}^{-1}(\\alpha,\\beta,\\gamma)=\\M{S}_1^{-1}(\\alpha)\\M{S}_2^{-1}(\\beta)\\M{S}_3^{-1}(\\gamma)=\\tilde{\\M{S}}_1(\\alpha)\\tilde{\\M{S}}_2(\\beta)\\tilde{\\M{S}}_3(\\gamma)=\\tilde{(\\M{S}_3(\\gamma)\\M{S}_2(\\beta)\\M{S}_1(\\alpha))}=\\tilde{\\M{S}}(\\alpha,\\beta,\\gamma)\\]\n\\[\\M{S}^{-1}(\\alpha,\\beta,\\gamma)=\\M{S}_1^{-1}(\\alpha)\\M{S}_2^{-1}(\\beta)\\M{S}_3^{-1}(\\gamma)=\\M{S}_1(-\\alpha)\\M{S}_2(-\\beta)\\M{S}_3(-\\gamma)=\\M{S}_3(-\\alpha)\\M{S}_2(-\\beta)\\M{S}_1(-\\gamma)=\\M{S}(-\\gamma,-\\beta,-\\alpha)\\]\n\n\\paragraph{3.4.5}\n(a) Decompose $\\V{r}$ into $\\V{r}_{\\parallel}$ parallel to $\\hat{\\V{n}}$ and $\\V{r_{\\perp}}$ perpendicular to $\\hat{\\V{n}}$. \n$\\V{r}_{\\parallel}=\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r})$, $\\V{r_{\\perp}}=\\V{r}-\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r})$.\nAfter rotation, $\\V{r}_{\\parallel}$ remains unchanged, and $\\V{r_{\\perp}}$ becomes $\\frac{\\V{r_{\\perp}}}{|\\V{r_{\\perp}}|}\\times\\hat{\\V{n}}(|\\V{r_{\\perp}}|\\sin\\V{\\Phi})$ in the $\\VE_{\\V{\\Phi}}$ direction and $\\frac{\\V{r_{\\perp}}}{|\\V{r_{\\perp}}|}|\\V{r_{\\perp}}|\\cos\\V{\\Phi}$ in the $\\VE_{\\V{r}_{\\perp}}$ direction. So \n\\[\\V{r}'=\\V{r}_{\\parallel}+\\V{r_{\\perp}}\\times\\hat{\\V{n}}\\sin\\V{\\Phi}+\\V{r_{\\perp}}\\cos\\V{\\Phi}=\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r})+(\\V{r}-\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r}))\\times\\hat{\\V{n}}\\sin\\V{\\Phi}+(\\V{r}-\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r}))\\cos\\V{\\Phi}\\]\n\\[\n=\\V{r}\\cos\\V{\\Phi}+\\V{r}\\times\\hat{\\V{n}}\\sin\\V{\\Phi}+\\hat{\\V{n}}(\\hat{\\V{n}}\\cdot\\V{r})(1-\\cos\\V{\\Phi})\n\\]\n\n(b) Let $\\V{r}=(x,y,z)$, then \n\\[\n\\V{r}'=\n\\begin{pmatrix}x'\\\\y'\\\\z'\\end{pmatrix}=\n\\begin{pmatrix}x\\cos\\V{\\Phi}\\\\y\\cos\\V{\\Phi}\\\\z\\cos\\V{\\Phi}\\end{pmatrix}+\n\\begin{pmatrix}y\\sin\\V{\\Phi}\\\\-z\\sin\\V{\\Phi}\\\\0\\end{pmatrix}+\n\\begin{pmatrix}0\\\\0\\\\z(1-\\cos\\V{\\Phi})\\end{pmatrix}=\n\\begin{pmatrix}x\\cos\\V{\\Phi}+y\\sin\\V{\\Phi}\\\\-z\\sin\\V{\\Phi}+y\\cos\\V{\\Phi}\\\\z\\end{pmatrix}\n\\]\n\\[\n\\begin{pmatrix}x'\\\\y'\\\\z'\\end{pmatrix}=\n\\begin{pmatrix}\n\\cos\\V{\\Phi}&\\sin\\V{\\Phi}&0\\\\\n-\\sin\\V{\\Phi}&\\cos\\V{\\Phi}&0\\\\\n0&0&1\n\\end{pmatrix}\n\\begin{pmatrix}x\\\\y\\\\z\\end{pmatrix}\n\\]\nwhich is identical with Eq. (3.55).\n\n(c)\n$\\V{r}\\cdot(\\V{r}\\times\\hat{\\V{n}})=0$, $(\\V{r}\\times\\hat{\\V{n}})\\cdot\\hat{\\V{n}}=0$ because they are perpendicular. Let $\\theta$ be the angle between $\\V{r}$ and $\\hat{\\V{n}}$, then $|\\V{r}\\times\\hat{\\V{n}}|=r\\sin\\theta$, $|\\hat{\\V{n}}\\cdot\\V{r}|=r\\cos\\theta$. \\[r'^2=\\V{r}'\\cdot\\V{r}'=r^2\\cos^2\\Phi+(\\V{r}\\times\\hat{\\V{n}})^2\\sin^2\\Phi+(\\hat{\\V{n}}\\cdot\\V{r})^2(1-\\cos\\Phi)^2+2(\\hat{\\V{n}}\\cdot\\V{r})^2(\\cos\\Phi)(1-\\cos\\Phi)\\]\n\\[\n=r^2\\cos^2\\Phi+r^2\\sin^2\\theta\\sin^2\\Phi+r^2\\cos^2\\theta(1-\\cos\\Phi)^2+2r^2\\cos^2\\theta(\\cos\\Phi)(1-\\cos\\Phi)\n\\]\n\\[=r^2\\cos^2\\Phi+r^2\\sin^2\\theta\\sin^2\\Phi+r^2\\cos^2\\theta(1-\\cos^2\\Phi)\n\\]\n\\[\n=r^2\\cos^2\\Phi+r^2\\sin^2\\Phi\n\\]\n\\[\n=r^2\n\\]\n\n\\section*{3.5 Differential Vector Operators}\n\n\\paragraph{3.5.1}\n(a) $\\del\\V{S}=-3(x^2+y^2+z^2)^{-5/2}(x\\VE_x+y\\VE_y+z\\VE_z)=-3(14)^{-5/2}(1\\VE_x+2\\VE_y+3\\VE_z)$ at point $(1,2,3)$.\n\n(b) $\\del\\V{S}=3\\cdot14^{-5/2}\\cdot14^{1/2}=\\frac{3}{196}$\n\n(c) $(\\frac{-1}{\\sqrt{14}},\\frac{-2}{\\sqrt{14}},\\frac{-3}{\\sqrt{14}})$\n\n\\paragraph{3.5.2}\n(a) $(\\pdv{f}{x},\\pdv{f}{y},\\pdv{f}{z})\\cdot(dx,dy,dz)=df=0$ when $f(x,y,z)=constant$, so $(\\pdv{f}{x},\\pdv{f}{y},\\pdv{f}{z})$ is perpendicular to the equipotential surfaces. $\\del(x^2+y^2+z^2)=2x\\VE_x+2y\\VE_y+2z\\VE_z=2\\VE_x+2\\VE_y+2\\VE_z$ at point $(1,1,1)$, and its unit vector is $\\frac{\\VE_x+\\VE_y+\\VE_z}{\\sqrt{3}}$.\n\n(b) $(x-1,y-1,z-1)\\cdot(1,1,1)=0$, so the tangent surface is $x+y+z=3$.\n\n\\paragraph{3.5.3}\n$r_{12}=\\sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2}$, so $\\del_1r_{12}=\\pdv{r_{12}}{x}\\VE_x+\\pdv{r_{12}}{y}\\VE_y+\\pdv{r_{12}}{z}\\VE_z=\\frac{x_1-x_2}{r_{12}}\\VE_x+\\frac{y_1-y_2}{r_{12}}\\VE_y+\\frac{z_1-z_2}{r_{12}}\\VE_z=\\frac{\\V{r_{12}}}{r_{12}}$ which is the unit vector in the direction of $\\V{r_{12}}$.\n\n\\paragraph{3.5.4}\n\\[\\V{F}=F_x\\VE_x+F_y\\VE_y+F_z\\VE_z\\]\n\\[\nd\\V{F}=(\\pdv{F_x}{x}dx+\\pdv{F_x}{y}dy+\\pdv{F_x}{z}dz+\\pdv{F_x}{t}dt)\\VE_x+(\\pdv{F_y}{x}dx+\\pdv{F_y}{y}dy+\\pdv{F_y}{z}dz+\\pdv{F_y}{t}dt)\\VE_y+(\\pdv{F_z}{x}dx+\\pdv{F_z}{y}dy+\\pdv{F_z}{z}dz+\\pdv{F_z}{t}dt)\\VE_z\n\\]\n\\[=\n(dx\\pdv{}{x}+dy\\pdv{}{y}+dz\\pdv{}{z})F_x\\VE_x+(dx\\pdv{}{x}+dy\\pdv{}{y}+dz\\pdv{}{z})F_y\\VE_y+(dx\\pdv{}{x}+dy\\pdv{}{y}+dz\\pdv{}{z})F_z\\VE_z+(\\pdv{F_x}{t}\\VE_x+\\pdv{F_y}{t}\\VE_y+\\pdv{F_z}{t}\\VE_z)dt\n\\]\n\\[\n=(dx\\pdv{}{x}+dy\\pdv{}{y}+dz\\pdv{}{z})(F_x\\VE_x+F_y\\VE_y+F_z\\VE_z)+\\pdv{\\V{F}}{t}dt\n\\]\n\\[\n=(d\\V{r}\\cdot\\del)\\V{F}+\\pdv{\\V{F}}{t}dt\n\\]\n\n\\paragraph{3.5.5}\n$\\del(uv)=\\pdv{uv}{x}\\VE_x+\\pdv{uv}{y}\\VE_y+\\pdv{uv}{z}\\VE_z=(\\pdv{u}{x}v+u\\pdv{v}{x})\\VE_x+(\\pdv{u}{y}v+u\\pdv{v}{y})\\VE_y+(\\pdv{u}{z}v+u\\pdv{v}{z})\\VE_z$\\\\\n$=(\\pdv{u}{x}\\VE_x+\\pdv{u}{y}\\VE_y+\\pdv{u}{z}\\VE_z)v+u(\\pdv{v}{x}\\VE_x+\\pdv{v}{y}\\VE_y+\\pdv{v}{z}\\VE_z)=v\\del u+u\\del v$\n\n\\paragraph{3.5.6}\n(a) $\\Dot{\\V{r}}=\\frac{d\\V{r}}{dt}=-r\\omega\\sin{\\omega t}\\,\\VE_x+r\\omega\\cos{\\omega t}\\,\\VE_y$, so \n\\[\\V{r}\\times\\Dot{\\V{r}}=(r\\cos{\\omega t}\\,\\VE_x+r\\sin{\\omega t}\\,\\VE_t)\\times(-r\\omega\\sin{\\omega t}\\,\\VE_x+r\\omega\\cos{\\omega t}\\,\\VE_y)=r\\omega^2(\\cos^2{\\omega t}+\\sin^2{\\omega t})\\VE_z=r\\omega^2\\VE_z\\]\n\n(b) $\\Ddot{\\V{r}}=-r\\omega^2\\cos{\\omega t}\\,\\VE_x-r\\omega^2\\sin{\\omega t}\\,\\VE_y$, so $\\Ddot{\\V{r}}+\\omega^2\\V{r}=0$.\n\n\\paragraph{3.5.7}\n$\\V{A'}=\\M{S}\\V{A}$, which means $A'_i=\\sum_{j}\\M{S}_{ij}A_j$. Because $\\M{S}_{ij}$ is independent of $t$, so $\\frac{dA'_i}{dt}=\\sum_{j}\\M{S}_{ij}\\frac{dA_j}{dt}$, which means $\\frac{d\\V{A'}}{dt}=\\M{S}\\frac{d\\V{A}}{dt}$.\n\n\\paragraph{3.5.8}\n(a) $\\frac{d}{dt}(\\V{A}\\cdot\\V{B})=\\frac{d}{dt}(A_xB_x+A_yB_y+A_zB_z)=\\frac{dA_x}{dt}B_x+A_x\\frac{dB_x}{dt}+\\frac{dA_y}{dt}B_y+A_y\\frac{dB_y}{dt}+\\frac{dA_z}{dt}B_z+A_z\\frac{dB_z}{dt}$\\\\\n$=\\frac{d\\V{A}}{dt}\\cdot\\V{B}+\\V{A}\\cdot\\frac{d\\V{B}}{dt}$\n\\medskip\n\n(b) \n\\[\n\\frac{d}{dt}(\\V{A}\\times\\V{B})=\\frac{d}{dt}\\bigg( (A_yB_z-A_zB_y)\\VE_x+(A_zB_x-A_xB_z)\\VE_y+(A_xB_y-A_yB_x)\\VE_z \\bigg)\n\\]\n\\[\n=\n\\scriptstyle\\left(\\dv{A_y}{t}B_z+A_y\\dv{B_z}{t}-\\dv{A_z}{t}B_y-A_z\\dv{B_y}{t}\\right)\\VE_x+\\left(\\dv{A_z}{t}B_x+A_z\\dv{B_x}{t}-\\dv{A_x}{t}B_z-A_x\\dv{B_z}{t}\\right)\\VE_y+\\left(\\dv{A_x}{t}B_y+A_x\\dv{B_y}{t}-\\dv{A_y}{t}B_x-A_y\\dv{B_x}{t}\\right)\\VE_z\n\\]\n\\[\n=\n\\scriptstyle\\left(\\dv{A_y}{t}B_z-\\dv{A_z}{t}B_y\\right)\\VE_x+\\left(\\dv{A_z}{t}B_x-\\dv{A_x}{t}B_z\\right)\\VE_y+\\left(\\dv{A_x}{t}B_y-\\dv{A_y}{t}B_x\\right)\\VE_z+\n\\left(A_y\\dv{B_z}{t}-A_z\\dv{B_y}{t}\\right)\\VE_x+\\left(A_z\\dv{B_x}{t}-A_x\\dv{B_z}{t}\\right)\\VE_y+\\left(A_x\\dv{B_y}{t}-A_y\\dv{B_x}{t}\\right)\\VE_z\n\\]\n\n\\[\n=\\dv{\\V{A}}{t}\\times\\V{B}+\\V{A}\\times\\dv{\\V{B}}{t}\n\\]\n\n\\paragraph{3.5.9}\n$\\frac{d}{dx}a_ib_j=\\frac{da_i}{dx}b_j+a_i\\frac{db_j}{dx}$, so we can decompose $\\del\\cdot(\\V{a}\\times\\V{b})$ into $\\del_a\\cdot(\\V{a}\\times\\V{b})+\\del_b\\cdot(\\V{a}\\times\\V{b})$, with $\\del_a$ operating on $\\V{a}$ only, and $\\del_b$ operating on $\\V{b}$ only. Then by the symmetry of scalar triple product, $\\del_a\\cdot(\\V{a}\\times\\V{b})=\\V{b}\\cdot(\\del_a\\times\\V{a})=\\V{b}\\cdot(\\del\\times\\V{a})$, and $\\del_b\\cdot(\\V{a}\\times\\V{b})=\\V{a}\\cdot(\\V{b}\\times\\del_b)=-\\V{a}\\cdot(\\del_b\\times\\V{b})=-\\V{a}\\cdot(\\del\\times\\V{b})$. So $\\del\\cdot(\\V{a}\\times\\V{b})=\\V{b}\\cdot(\\del\\times\\V{a})-\\V{a}\\cdot(\\del\\times\\V{b})$.\n\n\\paragraph{3.5.10}\n$\\V{L}=\\V{r}\\times(-i\\del)=(x\\VE_x+y\\VE_y+z\\VE_z)\\times(-i\\pdv{}{x}\\VE_x-i\\pdv{}{y}\\VE_y-i\\pdv{}{z}\\VE_z)=\\\\-i\\left(y\\pdv{}{z}-z\\pdv{}{y} \\right)\\VE_x-i\\left(z\\pdv{}{x}-x\\pdv{}{z} \\right)\\VE_y-i\\left(x\\pdv{}{y}-y\\pdv{}{x} \\right)\\VE_z$\n\n\\paragraph{3.5.11}\n\\[L_xL_y-L_yL_x\\]\n\\[\n=-\\left(y\\pdv{}{z}-z\\pdv{}{y} \\right)\\left(z\\pdv{}{x}-x\\pdv{}{z} \\right)+\\left(z\\pdv{}{x}-x\\pdv{}{z} \\right)\\left(y\\pdv{}{z}-z\\pdv{}{y} \\right)\n\\]\n\\[\n=-\\left(y\\pdv{}{x}+yz\\ppdv{}{z}{x}-yx\\pdv{^2}{z^2}-z^2\\ppdv{}{y}{x}+xz\\ppdv{}{y}{z} \\right)+\\left(zy\\ppdv{}{x}{z}-z^2\\ppdv{}{x}{y}-xy\\pdv{^2}{z^2}+x\\pdv{}{y}+xz\\ppdv{}{z}{y} \\right)\n\\]\n\\[\n=x\\pdv{}{y}-y\\pdv{}{x}=iL_z\n\\]\n\n\\paragraph{3.5.12}\nThe problem is ill-defined because the way of vector multiplication has not been specified(scalar product, cross product or tensor product). If $[\\V{a},\\V{b}]=0$, $[\\V{a},\\V{L}]=0$, $[\\V{b},\\V{L}]=0$ means $[a_i,b_j]=0$, $[a_i,L_j]=0$, $[b_i,L_j]=0$ for all $i,j\\in\\{x,y,z\\}$, then $a$ and $b$, $a$ and $L$, $b$ and $L$ commute, but $L$ and $L$ do not commute ($[L_i,L_j]=iL_k$). So \n\\[[\\V{a}\\cdot\\V{L},\\V{b}\\cdot\\V{L}]\\]\n\\[=[a_xL_x+a_yL_y+a_zL_z,b_xL_x+b_yL_y+b_zL_z]\\]\n\\[=\\sum_{i=1}^3\\sum_{j=1}^3[a_iL_i,b_jL_j]\\]\n\\[\n=\\sum_{i=1}^3\\sum_{j=1}^3 (a_iL_ib_jL_j-b_jL_ja_iL_i)\\]\n\\[\n=\\sum_{i=1}^3\\sum_{j=1}^3(a_ib_jL_iL_j-b_ja_iL_jL_i)\n\\]\n\\[=\n\\scriptstyle a_xb_y(L_xL_y-L_yL_x)+a_xb_z(L_xL_z-L_zL_x)+a_yb_x(L_yL_x-L_xL_y)+a_yb_z(L_yL_z-L_zL_y)+a_zb_x(L_zL_x-L_xL_z)+a_zb_y(L_zL_y-L_yL_z)\n\\]\n\\[\n=a_xb_yiL_z-a_xb_ziL_y-a_yb_xiL_z+a_yb_ziL_x+a_zb_xiL_y-a_zb_yiL_x\n\\]\n\\[\n=i(a_yb_z-a_zb_y)L_x+i(a_zb_x-a_xb_z)L_y+i(a_xb_y-a_yb_x)L_z\n\\]\n\\[\n=i(\\V{a}\\times\\V{b})\\cdot\\V{L}\n\\]\n\n\n\\paragraph{3.5.13}\nA stream line of a vector field should be parallel to the vector at every point in the space. So $\\frac{dy}{dx}=\\frac{b_y}{b_x}=\\frac{x}{-y}$, where $y=y(x)$ is a stream line. Solving  the differential equation, $xdx+ydy=0$, $\\frac{x^2}{2}+\\frac{y^2}{2}=k'$, $x^2+y^2=k$, which is a circle. The direction of the stream line at $(1,1)$ is $-\\VE_x+\\VE_y$, which is counterclockwise relative $(0,0)$, the center of the circle. \n\n\\section*{3.6 Differential Vector Operators: Further Properties}\n\n\\paragraph{3.6.1}\nBy the identity in Exercise 3.5.9, $\\del\\cdot(\\V{u}\\times\\V{v})=\\V{v}\\cdot(\\del\\times\\V{u})-\\V{u}\\cdot(\\del\\times\\V{v})=0$ because $\\del\\times\\V{u}=0$ and $\\del\\times\\V{v}=0$ (irrotational).\n\n\\paragraph{3.6.2}\n$\\del\\cdot(\\V{A}\\times\\V{r})=\\V{r}\\cdot(\\del\\times\\V{A})-\\V{A}\\cdot(\\del\\times\\V{r})=0$ because both $\\V{A}$ and the position vector $\\V{r}=x\\VE_x+y\\VE_y+z\\VE_z$ are irrotational, so their curl vanish.\n\n\\paragraph{3.6.3}\nThe linear velocity $\\V{v}=\\boldsymbol{\\omega}\\times\\V{r}$, so $\\del\\cdot\\V{v}=\\del\\cdot(\\boldsymbol{\\omega}\\times\\V{r})=\\V{r}\\cdot(\\del\\times\\boldsymbol{\\omega})-\\boldsymbol{\\omega}\\cdot(\\del\\times\\V{r})=0$ because the curl of constant vector $\\boldsymbol{\\omega}$ and position vector $\\V{r}$ are zero. \n\n\\paragraph{3.6.4}\n$\\del\\times\\V{V}\\neq0$ but $\\del\\times(g\\V{V})=g(\\del\\times\\V{V})+(\\del g)\\times\\V{V}=0$. So $\\V{V}\\cdot\\big(g(\\del\\times\\V{V})+(\\del g)\\times\\V{V} \\big)=g\\V{V}\\cdot(\\del\\times\\V{V})+\\V{V}\\cdot((\\del g)\\times\\V{V})=0$. But $\\V{V}\\cdot((\\del g)\\times\\V{V})=0$ (perpendicular) and $g\\neq 0$, so $\\V{V}\\cdot(\\del\\times\\V{V})=0$.  \n\n\\paragraph{3.6.5}\nAll the terms of $\\V{A}\\times\\V{B}$ have the form $A_iB_j\\VE_k$, and $\\pdv{}{x}(A_iB_j)=\\pdv{A_i}{x}B_j+A_i\\pdv{B_j}{x}$. So we can separate $\\del\\times(\\V{A}\\times\\V{B})$ into $\\del_A\\times(\\V{A}\\times\\V{B})$ and $\\del_B\\times(\\V{A}\\times\\V{B})$, with $\\del_A$ acting only on $\\V{A}$, and $\\del_B$ acting only on $\\V{B}$. Using the BAC-CAB rule, but noting that $\\del_A$ must go before $\\V{A}$ and after $\\V{B}$, $\\del_B$ go before $\\V{B}$ and after $\\V{A}$, we get \n\\[\n\\del\\times(\\V{A}\\times\\V{B})=\\del_A\\times(\\V{A}\\times\\V{B})+\\del_B\\times(\\V{A}\\times\\V{B})\n\\]\n\\[\n=(\\V{B}\\cdot\\del_A)\\V{A}-\\V{B}(\\del_A\\cdot\\V{A})+\\V{A}(\\del_B\\cdot\\V{B})-(\\V{A}\\cdot\\del_B)\\V{B}\n\\]\n\\[\n=(\\V{B}\\cdot\\del)\\V{A}-\\V{B}(\\del\\cdot\\V{A})+\\V{A}(\\del\\cdot\\V{B})-(\\V{A}\\cdot\\del)\\V{B}\n\\]\n\n\\paragraph{3.6.6}\n\\[[(\\V{A}\\times\\del)\\times\\V{B}]_x=A_z\\pdv{B_z}{x}-A_x\\pdv{B_z}{z}-A_x\\pdv{B_y}{y}+A_y\\pdv{B_y}{x}\n\\]\n\\[[(\\V{B}\\times\\del)\\times\\V{A}]_x=B_z\\pdv{A_z}{x}-B_x\\pdv{A_z}{z}-B_x\\pdv{A_y}{y}+B_y\\pdv{A_y}{x}\n\\]\n\\[\n[\\V{A}(\\del\\cdot\\V{B})]_x=A_x\\pdv{B_x}{x}+A_x\\pdv{B_y}{y}+A_x\\pdv{B_z}{z}\n\\]\n\\[\n[\\V{B}(\\del\\cdot\\V{A})]_x=B_x\\pdv{A_x}{x}+B_x\\pdv{A_y}{y}+B_x\\pdv{A_z}{z}\n\\]\nSumming together we get \n\\[\nA_x\\pdv{B_x}{x}+B_x\\pdv{A_x}{x}+A_y\\pdv{B_y}{x}+B_y\\pdv{A_y}{x}+A_z\\pdv{B_z}{x}+B_z\\pdv{A_z}{x}\n\\]\nwhich is $\\pdv{(\\V{A}\\cdot\\V{B})}{x}=[\\del(\\V{A}\\cdot\\V{B})]_x$. The same is for $y$ and $z$ components. Therefore,\n\n\\[\\del(\\V{A}\\cdot\\V{B})=\n(\\V{A}\\times\\del)\\times\\V{B}+(\\V{B}\\times\\del)\\times\\V{A}+\\V{A}(\\del\\cdot\\V{B})+\\V{B}(\\del\\cdot\\V{A})\n\\]\n\n\\paragraph{3.6.7}\nTo distinguish between the two $\\V{A}$, let the first $\\V{A}$ be $\\V{A}_1$ and the second be $\\V{A}_2$. Applying BAC-CAB rule,  $\\V{A}_1\\times(\\del\\times\\V{A}_2)=\\del_2(\\V{A}_1\\cdot \\V{A}_2)-(\\V{A}_1\\cdot\\del)\\V{A}_2$ with $\\del_2$ acting only on $\\V{A}_2$. Noting that $\\del(\\V{A}_1\\cdot \\V{A}_2)=\\del_1(\\V{A}_1\\cdot \\V{A}_2)+\\del_2(\\V{A}_1\\cdot \\V{A}_2)$ and $\\del_1(\\V{A}_1\\cdot \\V{A}_2)=\\del_2(\\V{A}_1\\cdot \\V{A}_2)$, we have $\\del_2(\\V{A}_1\\cdot \\V{A}_2)=\\frac{\\del(\\V{A}_1\\cdot \\V{A}_2)}{2}$, so \\[\\V{A}\\times(\\del\\times\\V{A})=\\frac{1}{2}\\del(\\V{A}\\cdot \\V{A})-(\\V{A}\\cdot\\del)\\V{A}\\]\n\n\\paragraph{3.6.8}\n\\[\\del(\\V{A}\\cdot\\V{B}\\times\\V{r})=\\del(\\V{r}\\cdot\\V{A}\\times\\V{B})\\]\\[=\\del(x[\\V{A}\\times\\V{B}]_x+y[\\V{A}\\times\\V{B}]_y+z[\\V{A}\\times\\V{B}]_z)\\]\\[=[\\V{A}\\times\\V{B}]_x\\VE_x+[\\V{A}\\times\\V{B}]_y\\VE_y+[\\V{A}\\times\\V{B}]_z\\VE_z\\]\\[=\\V{A}\\times\\V{B}\\]\nbecause $\\V{A}\\times\\V{B}$ is constant, so $\\pdv{[\\V{A}\\times\\V{B}]_j}{x_i}=0$\n\n\\paragraph{3.6.9}\n\\[\n[\\del\\times(\\del\\times\\V{V})]_x=\\ppdv{V_y}{y}{x}-\\pdv{^2V_x}{z^2}-\\pdv{^2V_x}{z^2}+\\ppdv{V_z}{z}{x}\n\\]\n\\[\n[\\del(\\del\\cdot\\V{V})]_x=\\pdv{^2V_x}{x^2}+\\ppdv{V_y}{x}{y}+\\ppdv{V_z}{x}{z}\n\\]\n\\[\n-[\\del\\cdot\\del\\V{V}]_x=-\\pdv{^2V_x}{x^2}-\\pdv{^2V_y}{y^2}-\\pdv{^2V_z}{z^2}\n\\]\nSo $[\\del\\times(\\del\\times\\V{V})]_x=[\\del(\\del\\cdot\\V{V})]_x-[\\del\\cdot\\del\\V{V}]_x$, as well as the $y$ and $z$ components. Therefore\n\\[\\del\\times(\\del\\times\\V{V})=\\del(\\del\\cdot\\V{V})-\\del\\cdot\\del\\V{V}\\]\n\n\\paragraph{3.6.10}\n\\[\n[\\del\\times(\\varphi\\del\\varphi)]_x=\\pdv{}{y}\\left(\\varphi\\pdv{\\varphi}{z}\\right)-\\pdv{}{z}\\left(\\varphi\\pdv{\\varphi}{y}\\right)\n\\]\n\\[\n=\\pdv{\\varphi}{y}\\pdv{\\varphi}{z}+\\varphi\\ppdv{\\varphi}{y}{z}-\\pdv{\\varphi}{z}\\pdv{\\varphi}{y}-\\varphi\\ppdv{\\varphi}{z}{y}=0\n\\]\nThe same is for the $y$ and $z$ components. Therefore,\n$\\del\\times(\\varphi\\del\\varphi)=0$\n\n\\paragraph{3.6.11}\n(a) If $\\V{F}=\\V{G}+k$, $k$ is a constant, then $\\del\\times\\V{F}=\\del\\times\\V{G}$ beacuse $\\pdv{k}{x_i}=0$\n\n(b) If $\\V{F}=\\V{G}+\\del\\varphi$, then $\\del\\times\\V{F}=\\del\\times\\V{G}+\\del\\times(\\del\\varphi)=\\del\\times\\V{G}$ because $\\del\\times(\\del\\varphi)=0$. \n\n\\paragraph{3.6.12}\nFrom Exercise 3.6.7, $\\V{v}\\times(\\del\\times\\V{v})=\\frac{1}{2}\\del(v^2)-(\\V{v}\\cdot\\del)\\V{v}$, so \\[-\\del\\times\\big(\\V{v}\\times(\\del\\times\\V{v})\\big)=-\\frac{1}{2}\\del\\times\\del(v^2)+\\del\\times\\big((\\V{v}\\cdot\\del)\\V{v} \\big)=\\del\\times\\big((\\V{v}\\cdot\\del)\\V{v} \\big)\\]\nbecause $\\del\\times\\del(v^2)=0$.\n\n\\paragraph{3.6.13}\nFrom Exercise 3.5.9, \n\\[\\del\\cdot\\big((\\del u)\\times(\\del v) \\big)=(\\del v)\\cdot\\big(\\del\\times(\\del u) \\big)-(\\del u)\\cdot\\big(\\del\\times(\\del v) \\big)=0\\]\nbecause $\\del\\times(\\del u)=0$ and $\\del\\times(\\del v)=0$\n\n\\paragraph{3.6.14}\n$\\del\\cdot\\del\\varphi=\\del^2\\varphi=0$, and $\\del\\times\\del\\varphi=0$ for any $\\varphi$, so $\\del\\varphi$ is both solenoidal and irrotational.\n\n\\paragraph{3.6.15}\nBy Equation (3.70), $\\del\\times(\\del\\times\\V{A})=\\del(\\del\\cdot\\V{A})-(\\del\\cdot\\del)\\V{A}$, so the equation becomes\\\\ $\\del(\\del\\cdot\\V{A})-(\\del\\cdot\\del)\\V{A}-k^2\\V{A}=0$. Let $\\del\\cdot$ operate on both side of the equation, and note that\\\\ $\\del\\cdot\\big((\\del\\cdot\\del)\\V{A} \\big)=(\\del\\cdot\\del)(\\del\\cdot\\V{A})$ because $\\pdv{}{x_i}\\left(\\pdv{^2A_k}{x_j^2} \\right)=\\pdv{^2}{x_j^2}\\left(\\pdv{A_k}{x_i} \\right)$. So the equation becomes\\\\ $(\\del\\cdot\\del)(\\del\\cdot\\V{A})-(\\del\\cdot\\del)(\\del\\cdot\\V{A})-k^2(\\del\\cdot\\V{A})=-k^2(\\del\\cdot\\V{A})=0$, so $\\del\\cdot\\V{A}=0$. Substituting back to the second equation, we get  $(\\del\\cdot\\del)\\V{A}+k^2\\V{A}=\\del^2\\V{A}+k^2\\V{A}=0$\n\n\\paragraph{3.6.16}\nLet $\\Psi=\\frac{k}{2}\\Phi^2$, then \\[\\del^2\\Psi=\\frac{k}{2}\\left(\\pdv{^2\\Phi^2}{x^2}+\\pdv{^2\\Phi^2}{y^2}+\\pdv{^2\\Phi^2}{z^2} \\right)\\]\n\\[\n=\\frac{k}{2}\\left(\\pdv{}{x}\\left(2\\Phi\\pdv{\\Phi}{x}\\right)+\\pdv{}{y}\\left(2\\Phi\\pdv{\\Phi}{y}\\right)+\\pdv{}{z}\\left(2\\Phi\\pdv{\\Phi}{z}\\right)   \\right)\n\\]\n\\[=\\frac{k}{2}\\left(2\\pdv{\\Phi}{x}\\pdv{\\Phi}{x}+2\\Phi\\pdv{^2\\Phi}{x^2}+2\\pdv{\\Phi}{y}\\pdv{\\Phi}{y}+2\\Phi\\pdv{^2\\Phi}{y^2}+2\\pdv{\\Phi}{z}\\pdv{\\Phi}{z}+2\\Phi\\pdv{^2\\Phi}{z^2}\\right)\\]\n\\[\n=k\\left(\\left(\\pdv{\\Phi}{x}\\right)^2+\\left(\\pdv{\\Phi}{y}\\right)^2+\\left(\\pdv{\\Phi}{z}\\right)^2 \\right)\n=k|\\del\\Phi|^2\n\\]\nbecause $\\del^2\\Phi=\\pdv{^2\\Phi}{x^2}+\\pdv{^2\\Phi}{y^2}+\\pdv{^2\\Phi}{z^2}=0$. So $\\Psi=\\frac{k}{2}\\Phi^2$ is a solution of the equation.\n\n\\paragraph{3.6.17}\nSubstituting, we get\n\\renewcommand{\\arraystretch}{1.5}\n\\[\n\\begin{pmatrix}\n\\frac{1}{c}\\pdv{}{t}&-i\\pdv{}{z}&i\\pdv{}{y}\\\\\ni\\pdv{}{z}&\\frac{1}{c}\\pdv{}{t}&-i\\pdv{}{x}\\\\\n-i\\pdv{}{y}&i\\pdv{}{x}&\\frac{1}{c}\\pdv{}{t}\n\\end{pmatrix}\n\\begin{pmatrix}\nB_x-i\\frac{E_x}{c}\\\\\nB_y-i\\frac{E_y}{c}\\\\\nB_z-i\\frac{E_z}{c}\\\\\n\\end{pmatrix}\n\\]\n\\[\n=\\begin{pmatrix}\n\\left(\\frac{1}{c}\\pdv{B_x}{t}-\\frac{1}{c}\\pdv{E_y}{z}+\\frac{1}{c}\\pdv{E_z}{y} \\right)+i\\left(-\\frac{1}{c^2}\\pdv{E_x}{t}-\\pdv{B_y}{z}+\\pdv{B_z}{y} \\right)\\\\\n\\left(\\frac{1}{c}\\pdv{B_y}{t}-\\frac{1}{c}\\pdv{E_z}{x}+\\frac{1}{c}\\pdv{E_x}{z} \\right)+i\\left(-\\frac{1}{c^2}\\pdv{E_y}{t}-\\pdv{B_z}{x}+\\pdv{B_x}{z} \\right)\\\\\n\\left(\\frac{1}{c}\\pdv{B_z}{t}-\\frac{1}{c}\\pdv{E_x}{y}+\\frac{1}{c}\\pdv{E_y}{x} \\right)+i\\left(-\\frac{1}{c^2}\\pdv{E_z}{t}-\\pdv{B_x}{y}+\\pdv{B_y}{x} \\right)\\\\\n\\end{pmatrix}=0\n\\]\nThe real and imaginary part must to be zero, respectively. So the three equations from the real part form  $\\del\\times\\V{E}=-\\pdv{\\V{B}}{t}$, and the three equations from the imaginary part form  $\\del\\times\\V{B}=\\frac{1}{c^2}\\pdv{\\V{E}}{t}$.\n\n\\paragraph{3.6.18}\nNote that $\\boldsymbol{\\sigma}_i^2=\\boldsymbol{1}_2$, $\\boldsymbol{\\sigma}_i\\boldsymbol{\\sigma}_j=i\\boldsymbol{\\sigma}_k$. So \n\\[\n(\\boldsymbol{\\sigma}\\cdot\\V{a})(\\boldsymbol{\\boldsymbol{\\sigma}}\\cdot\\V{b})\\]\n\\[\n=(a_x\\boldsymbol{\\sigma}_1+a_y\\boldsymbol{\\sigma}_2+a_z\\boldsymbol{\\sigma}_3)(b_x\\boldsymbol{\\sigma}_1+b_y\\boldsymbol{\\sigma}_2+b_z\\boldsymbol{\\sigma}_3)\n\\]\n\\[\n=(a_xb_x+a_yb_y+a_zb_z)\\boldsymbol{1}_2+(a_xb_y-a_yb_x)i\\boldsymbol{\\sigma}_3+(a_yb_z-a_zb_y)i\\boldsymbol{\\sigma}_1+(a_zb_x-a_xb_z)i\\boldsymbol{\\sigma}_2\n\\]\n\\[\n=(\\V{a}\\cdot\\V{b})\\boldsymbol{1}_2+i\\boldsymbol{\\sigma}\\cdot(\\V{a}\\times\\V{b})\n\\]\n\n\\section*{3.7 Vector Integration}\n\n\\paragraph{3.7.1}\nThe total vector area is \n\\[\n\\int d\\boldsymbol{\\sigma}=\\frac{1}{2}\\V{B}\\times\\V{A}+\\frac{1}{2}\\V{C}\\times\\V{B}+\\frac{1}{2}\\V{A}\\times\\V{C}+\\frac{1}{2}(\\V{C}-\\V{B})\\times(\\V{A}-\\V{B})=0\n\\]\n\n\\paragraph{3.7.2}\n(a) $x^2+y^2=1$, so $y=\\sqrt{1-x^2}$\\,; $2xdx+2ydy=0$, so $dy=-\\frac{x}{y}dx=-\\frac{x}{\\sqrt{1-x^2}}dx$. So\n\\[\nw=\\int(-\\V{F})\\cdot d\\V{r}\\]\n\\[=\\int\\frac{y}{x^2+y^2}dx+\\int\\frac{-x}{x^2+y^2}dy\\]\n\\[=\\int_1^{-1}\\sqrt{1-x^2}\\,dx+\\int_1^{-1}\\frac{x^2}{\\sqrt{1-x^2}}\\,dx\\]\n\\[=\\int_1^{-1}\\frac{1}{\\sqrt{1-x^2}}\\,dx\\]\n\\[=\\int_{\\frac{\\pi}{2}}^{-\\frac{\\pi}{2}}\\frac{1}{\\sqrt{1-\\sin^2\\theta}}\\cos\\theta\\,d\\theta=-\\pi\\]\n\n(b) $x^2+y^2=1$, so $y=-\\sqrt{1-x^2}$\\,; $2xdx+2ydy=0$, so $dy=-\\frac{x}{y}dx=\\frac{x}{\\sqrt{1-x^2}}dx$. So\n\\[\nw=\\int(-\\V{F})\\cdot d\\V{r}\\]\n\\[=\\int\\frac{y}{x^2+y^2}dx+\\int\\frac{-x}{x^2+y^2}dy\\]\n\\[=-\\int_1^{-1}\\sqrt{1-x^2}\\,dx-\\int_1^{-1}\\frac{x^2}{\\sqrt{1-x^2}}\\,dx\\]\n\\[=\\int_1^{-1}\\frac{-1}{\\sqrt{1-x^2}}\\,dx\\]\n\\[=\\int_{\\frac{\\pi}{2}}^{-\\frac{\\pi}{2}}\\frac{-1}{\\sqrt{1-\\sin^2\\theta}}\\cos\\theta\\,d\\theta=\\pi\\]\n\n\\paragraph{3.7.3}\nChoose the path $(1,1)\\rightarrow(1,3)\\rightarrow(3,3)$. Then \n\\[\nw=\\int_1^3\\V{F}(x,1)\\cdot(dx\\VE_x)+\\int_1^3\\V{F}(3,y)\\cdot(dy\\VE_y)\n\\]\n\\[\n=\\int_1^3(x-1)\\,dx+\\int_1^3(3+y)\\,dy\n\\]\n\\[\n=2+10=12\n\\]\n\n\\paragraph{3.7.4}\n$\\oint\\V{r}\\cdot d\\V{r}=\\oint(xdx+ydy+zdz)=(\\frac{x^2}{2}+\\frac{y^2}{2}+\\frac{z^2}{2})\\big|_{\\V{a}}^{\\V{a}}=0$ where $\\V{a}$ is the starting point.\n\n\\paragraph{3.7.5}\nFor the surfaces parallel to $yz$ surface, \\[\\int\\displaylimits_{S_{yz}}\\V{r}\\cdot d\\boldsymbol{\\sigma}=\\int\\displaylimits_{S_{yz}}(x\\VE_x+y\\VE_y+z\\VE_z)\\cdot(d\\sigma\\VE_x)=\\int\\displaylimits_{S_{yz}}(xd\\sigma)=x\\]\nequals to $1$ at $x=1$ and $0$ at $x=0$. The same is for $y$ and $z$, so \\[\\frac{1}{3}\\int\\displaylimits_S\\V{r}\\cdot d\\boldsymbol{\\sigma}=\\frac{1}{3}(1+1+1)=1\\]\n\n\\section*{3.8 Integral Theorems}\n\n\\paragraph{3.8.1}\nLet $\\V{a}$ be a constant vector, then \\[\\V{a}\\cdot\\oint\\displaylimits_{\\partial V}d\\boldsymbol{\\sigma}=\\oint\\displaylimits_{\\partial V}\\V{a}\\cdot d\\boldsymbol{\\sigma}=\\int\\displaylimits_V(\\del\\cdot\\V{a})d\\tau=0\\]\nBecause $\\V{a}$ can be in arbitrary direction, $\\oint\\displaylimits_{\\delta V}d\\boldsymbol{\\sigma}$ must be zero.\n\n\\paragraph{3.8.2}\n\\[\n\\frac{1}{3}\\oint\\displaylimits_S \\V{r}\\cdot d\\boldsymbol{\\sigma}=\\frac{1}{3}\\int\\displaylimits_V (\\del\\cdot\\V{r})d\\tau=\\frac{1}{3}\\int\\displaylimits_V 3d\\tau=V\n\\]\n\n\\paragraph{3.8.3}\n\\[\n\\oint\\displaylimits_S\\V{B}\\cdot d\\boldsymbol{\\sigma}=\\oint\\displaylimits_S(\\del\\times\\V{A})\\cdot d\\boldsymbol{\\sigma}=\\int\\displaylimits_V\\del\\cdot(\\del\\times\\V{A})d\\tau=0\n\\]\nbecause the divergence of a curl vanishes.\n\n\\paragraph{3.8.4}\n$\\del\\cdot(\\varphi\\V{E})=(\\del\\varphi)\\cdot\\V{E}+\\varphi(\\del\\cdot\\V{E})$, so $\\rho\\varphi=\\varepsilon_0(\\del\\cdot\\V{E})\\varphi=\\varepsilon_0\\del\\cdot(\\varphi\\V{E})-\\varepsilon_0(\\del\\varphi)\\cdot\\V{E}$, and\n\\[\n\\int \\rho\\varphi\\,d\\tau=\\varepsilon_0\\int\\del\\cdot(\\varphi\\V{E})\\,d\\tau-\\varepsilon_0\\int(\\del\\varphi)\\cdot\\V{E}\\,d\\tau\n\\]\n\\[\n=\\varepsilon_0\\oint\\varphi\\V{E}\\cdot d\\boldsymbol{\\sigma}+\\varepsilon_0\\int E^2 d\\tau\n\\]\n$\\varphi$ vanishes at least as fast as $r^{-1}$, so $\\V{E}=-\\del\\varphi$ vanishes at least as fast as $r^{-2}$, and $\\varphi\\V{E}$ vanishes at least as fast as $r^{-3}$. But $d\\boldsymbol{\\sigma}$ is in the order of $r^2$, so $\\oint\\varphi\\V{E}\\cdot d\\boldsymbol{\\sigma}$ vanishes at large $r$. Therefore, \n\\[\n\\int \\rho\\varphi\\,d\\tau=\\varepsilon_0\\int E^2 d\\tau\n\\]\n\n\\paragraph{3.8.5}\n$\\del\\cdot\\V{J}=0$ because it is steady-state current distribution. So $\\del\\cdot(x_i\\V{J})=(\\del x_i)\\cdot\\V{J}+x_i(\\del\\cdot\\V{J})=(\\del x_i)\\cdot\\V{J}=\\VE_i\\cdot\\V{J}=J_i$. So \n\\[\n\\int J_i d\\tau=\\int\\del\\cdot(x_i\\V{J})d\\tau\n=\\oint x_i\\V{J}\\cdot d\\boldsymbol{\\sigma}=0\n\\]\nbecause $\\V{J}$ vanishes on the surface. So \n\\[\n\\int\\V{J}d\\tau=\\sum\\int J_i d\\tau\\,\\VE_i=0\n\\]\n\n\\paragraph{3.8.6}\n\\[\n\\frac{1}{2}\\oint \\V{t}\\cdot d\\boldsymbol{\\lambda}=\\frac{1}{2}\\int(\\del\\times\\V{t})\\cdot d\\boldsymbol{\\sigma}=\\frac{1}{2}\\int2\\VE_z\\cdot d\\boldsymbol{\\sigma}=A\n\\]\n\n\\paragraph{3.8.7}\n(a) $\\oint\\V{r}\\times d\\V{r}=\\oint(xdy-ydx)\\VE_z=2A\\VE_z$ from Exercise 3.8.6 .\n\\medskip\n\n(b) $\\V{r}=a\\cos\\theta\\VE_x+b\\sin\\theta\\VE_y$, so $d\\V{r}=-a\\sin\\theta d\\theta\\VE_x+b\\cos\\theta d\\theta\\VE_y$, and \n\\[\n\\oint\\V{r}\\times d\\V{r}=\\int_0^{2\\pi}ab(\\cos^2\\theta+\\sin^2\\theta)d\\theta=2\\pi ab=2A\n\\]\nso the area of the ellipse is $\\pi ab$.\n\n\\paragraph{3.8.8}\n\\[\n\\oint\\V{r}\\times d\\V{r}=-\\oint d\\V{r}\\times\\V{r}\n\\]\n\\[\n=-\\int\\displaylimits_S(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{r}\n\\]\n\\[\n=-\\int\\displaylimits_S\\left((dxdy\\VE_z)\\times(\\pdv{}{x}\\VE_x+\\pdv{}{y}\\VE_y+\\pdv{}{z}\\VE_z)\\right)\\times\\V{r}\n\\]\n\\[\n=-\\int\\displaylimits_S(-dxdy\\pdv{}{y}\\VE_x+dxdy\\pdv{}{x}\\VE_y)\\times(x\\VE_x+y\\VE_y)\n\\]\n\\[\n=-\\int\\displaylimits_S -2dxdy=2A\n\\]\n\n\\paragraph{3.8.9}\n\\[\n\\oint u\\del v\\cdot d\\boldsymbol{\\lambda}+\\oint v\\del u\\cdot d\\boldsymbol{\\lambda}\n=\\oint\\del(uv)\\cdot d\\boldsymbol{\\lambda}\n=\\int\\del\\times(\\del{uv})\\cdot d\\boldsymbol{\\sigma}=0\n\\]\nso $\\oint u\\del v\\cdot d\\boldsymbol{\\lambda}=-\\oint v\\del u\\cdot d\\boldsymbol{\\lambda}$.\n\n\\paragraph{3.8.10}\n$\\del\\times(f\\V{V})=(\\del f)\\times\\V{V}+f(\\del\\times\\V{V})$ from Eq. 3.73 . So\n\\[\n\\oint u\\del v\\cdot d\\boldsymbol{\\lambda}=\\int\\displaylimits_S\\del\\times(u\\del v)\\cdot d\\boldsymbol{\\sigma}\n\\]\n\\[\n=\\int\\displaylimits_S(\\del u)\\times(\\del v)\\cdot d\\boldsymbol{\\sigma}+\\int\\displaylimits_S u(\\del\\times(\\del v))\\cdot d\\boldsymbol{\\sigma}\n\\]\n\\[\n=\\int\\displaylimits_S(\\del u)\\times(\\del v)\\cdot d\\boldsymbol{\\sigma}\n\\]\nbecause $\\del\\times(\\del v)=0$.\n\n\\paragraph{3.8.11}\nLet $\\V{a}$ be a constant vector, then\n\\[\n\\int\\displaylimits_V\\del\\cdot(\\V{a}\\times\\V{P})d\\tau=\\int\\displaylimits_V(\\del\\times\\V{a})\\cdot\\V{P} d\\tau-\\int\\displaylimits_V\\V{a}\\cdot(\\del\\times\\V{P})d\\tau=-\\V{a}\\cdot\\int\\displaylimits_V\\del\\times\\V{P}d\\tau\n\\]\nAlso, \n\\[\n\\int\\displaylimits_V\\del\\cdot(\\V{a}\\times\\V{P})d\\tau=\\oint\\displaylimits_{\\partial V}\\V{a}\\times\\V{P}\\cdot d\\boldsymbol{\\sigma}=\\oint\\displaylimits_{\\partial V}\\V{P}\\times d\\boldsymbol{\\sigma}\\cdot\\V{a}=\\V{a}\\cdot\\oint\\displaylimits_{\\partial V}\\V{P}\\times d\\boldsymbol{\\sigma}\n\\]\nSo $\\V{a}\\cdot\\left(\\oint\\displaylimits_{\\partial V}\\V{P}\\times d\\boldsymbol{\\sigma}+\\int\\displaylimits_V\\del\\times\\V{P}d\\tau\\right)=0$. Because $\\V{a}$ can be in arbitrary direction, $\\oint\\displaylimits_{\\partial V}\\V{P}\\times d\\boldsymbol{\\sigma}+\\int\\displaylimits_V\\del\\times\\V{P}d\\tau$ must be zero, and therefore \\[\\oint\\displaylimits_{\\partial V}d\\boldsymbol{\\sigma}\\times\\V{P}=\\int\\displaylimits_V\\del\\times\\V{P}d\\tau\\]\n\n\\paragraph{3.8.12}\nLet $\\V{a}$ be a constant vector, then\n\\[\n\\oint\\displaylimits_{\\partial S}(\\V{a}\\varphi)\\cdot d\\V{r}=\\V{a}\\cdot\\oint\\displaylimits_{\\partial S}\\varphi d\\V{r}\n\\]\nAlso, \n\\[\n\\oint\\displaylimits_{\\partial S}(\\V{a}\\varphi)\\cdot d\\V{r}=\\int\\displaylimits_S\\del\\times(\\varphi\\V{a})\\cdot d\\boldsymbol{\\sigma}=\\int\\displaylimits_S(\\del\\varphi)\\times\\V{a}\\cdot d\\boldsymbol{\\sigma}=\\int\\displaylimits_S d\\boldsymbol{\\sigma}\\times(\\del\\varphi)\\cdot\\V{a}=\\V{a}\\cdot\\int\\displaylimits_S d\\boldsymbol{\\sigma}\\times(\\del\\varphi)\n\\]\nso $\\V{a}\\cdot\\left(\\int\\displaylimits_S d\\boldsymbol{\\sigma}\\times(\\del\\varphi)-\\oint\\displaylimits_{\\partial S}\\varphi d\\V{r} \\right)=0$.  Because $\\V{a}$ can be in arbitrary direction, $\\int\\displaylimits_S d\\boldsymbol{\\sigma}\\times(\\del\\varphi)-\\oint\\displaylimits_{\\partial S}\\varphi d\\V{r}$ must be zero, and therefore\n\\[\n\\int\\displaylimits_S d\\boldsymbol{\\sigma}\\times(\\del\\varphi)= \\oint\\displaylimits_{\\partial S}\\varphi d\\V{r}\n\\]\n\n\\paragraph{3.8.13}\nLet $\\V{a}$ be a constant vector, then\n\\[\n\\oint\\displaylimits_{\\partial S\n}(\\V{a}\\times\\V{P})\\cdot d\\V{r}=\\oint\\displaylimits_{\\partial S\n}(\\V{P}\\times d\\V{r})\\cdot\\V{a}=\\V{a}\\cdot\\oint\\displaylimits_{\\partial S\n}\\V{P}\\times d\\V{r}\n\\]\nBecause $\\V{a}$ is a constant, $\\del\\times(\\V{a}\\times\\V{P})=\\del_P\\times(\\V{a}\\times\\V{P})$, with $\\del_P$ acting only on $\\V{P}$. So $\\del_P$ needs to go before $\\V{P}$, but can go before and after $\\V{a}$. So \\[\\del_P\\times(\\V{a}\\times\\V{P})\\cdot d\\boldsymbol{\\sigma}=d\\boldsymbol{\\sigma}\\times\\del_P\\cdot(\\V{a}\\times\\V{P})=(d\\boldsymbol{\\sigma}\\times\\del_P)\\cdot\\V{a}\\times\\V{P}=-\\V{a}\\cdot(d\\boldsymbol{\\sigma}\\times\\del_P)\\times\\V{P}=-\\V{a}\\cdot(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}\\]\nand\n\\[\n\\oint\\displaylimits_S(\\V{a}\\times\\V{P})\\cdot d\\V{r}=\\int\\displaylimits_S\\del\\times(\\V{a}\\times\\V{P})\\cdot d\\boldsymbol{\\sigma}=-\\int\\displaylimits_S\\V{a}\\cdot(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}=-\\V{a}\\cdot\\int\\displaylimits_S(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}\n\\]\nso $\\V{a}\\cdot\\left(\\int\\displaylimits_S(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}+\\oint\\displaylimits_{\\partial S\n}\\V{P}\\times d\\V{r} \\right)=0$. Because $\\V{a}$ can be in arbitrary direction, $\\int\\displaylimits_S(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}+\\oint\\displaylimits_{\\partial S\n}\\V{P}\\times d\\V{r}$ must be zero, and therefore\n\\[\n\\int\\displaylimits_S(d\\boldsymbol{\\sigma}\\times\\del)\\times\\V{P}=\\oint\\displaylimits_{\\partial S\n}d\\V{r}\\times\\V{P}\n\\]\n\n\\section*{3.9 Potential Theory}\n\n\\paragraph{3.9.1}\n$\\V{F}=r^{2n}\\V{r}$\n\\medskip\n\n(a) $\\del\\cdot\\V{F}=(\\del r^{2n})\\cdot\\V{r}+r^{2n}(\\del\\cdot\\V{r})=2nr^{2n-1}\\frac{\\V{r}}{r}\\cdot\\V{r}+r^{2n}(3)=(2n+3)r^{2n}$\n\\medskip\n\n(b) $\\del\\times\\V{F}=(\\del r^{2n})\\times\\V{r}+r^{2n}(\\del\\times\\V{r})=2nr^{2n-1}\\frac{\\V{r}}{r}\\times\\V{r}+0=0$\n\\medskip\n\n(c) $\\del\\times\\V{F}=0$, so the scalar potential exists. $\\int_a^b\\V{F}\\cdot d\\V{r}=-\\int_a^b\\del\\varphi\\cdot d\\V{r}=-\\varphi\\big|_a^b=\\varphi(a)-\\varphi(b)$. Take the path $(0,0,0)\\rightarrow(x,0,0)\\rightarrow(x,y,0)\\rightarrow(x,y,z)$. Then\n\\[\n\\int_{(0,0,0)}^{(x,y,z)}\\V{F}\\cdot d\\V{r}=\\int_0^x x^{2n}xdx+\\int_0^y(x^2+y^2)^nydy+\\int_0^z(x^2+y^2+z^2)^nzdz\n\\]\n\\[\n=\\frac{x^{2n+2}}{2n+2}-0+\\frac{(x^2+y^2)^{n+1}}{2(n+1)}-\\frac{(x^2)^{n+1}}{2(n+1)}+\\frac{(x^2+y^2+z^2)^{n+1}}{2(n+1)}-\\frac{(x^2+y^2)^{n+1}}{2(n+1)}\n\\]\n\\[\n=\\frac{r^{2n+2}}{2n+2}=\\varphi(0,0,0)-\\varphi(x,y,z)\n\\]\nwhen $n\\neq-1$. Defining $\\varphi(0,0,0)$ to be zero, then $\\varphi(x,y,z)=-\\frac{r^{2n+2}}{2n+2}$.\n\\medskip\n\n(d) If $n=-1$, \n\\[\n\\int_{(1,1,1)}^{(x,y,z)}\\V{F}\\cdot d\\V{r}=\\int_1^x \\frac{1}{x}dx+\\int_1^y\\frac{y}{x^2+y^2}dy+\\int_1^z\\frac{z}{x^2+y^2+z^2}dz\n\\]\n\\[\n=\\ln|x|+\\frac{1}{2}\\ln|\\frac{x^2+y^2}{x^2}|+\\frac{1}{2}\\ln|\\frac{x^2+y^2+z^2}{x^2+y^2}|\n\\]\n\\[\n=\\frac{1}{2}\\ln|x^2+y^2+z^2|\\]\n\\[=\\ln r=\\varphi(1,1,1)-\\varphi(\\V{r})\n\\]\nDefining $\\varphi(1,1,1)=0$, then $\\varphi(\\V{r})=-\\ln r$ diverges at both the origin and infinity.\n\n\\paragraph{3.9.2}\nApplying Gauss law, at $r\\leq a$, $\\oint\\V{E}\\cdot d\\boldsymbol{\\sigma}=E4\\pi r^2=\\frac{Q}{\\varepsilon_0}\\frac{r^3}{a^3}$, so $E=\\frac{Qr}{4\\pi\\varepsilon_0a^3}$; at $r>a$, $\\oint\\V{E}\\cdot d\\boldsymbol{\\sigma}=E4\\pi r^2=\\frac{Q}{\\varepsilon_0}$, so $E=\\frac{Qr}{4\\pi\\varepsilon_0r^2}$. Defining the potential to be zero at $r\\to\\infty$, then $\\int_r^\\infty \\V{E}\\cdot d\\V{r}=\\varphi(r)-\\varphi(\\infty)=\\varphi(r)$. At $r>a$, $\\varphi(r)=\\int_r^\\infty\\frac{Q}{4\\pi\\varepsilon_0r^2}dr=\\frac{Q}{4\\pi\\varepsilon_0r}$; at $r\\leq a$, $\\varphi(r)=\\int_r^a\\frac{Qr}{4\\pi\\varepsilon_0a^3}dr+\\int_a^\\infty\\frac{Q}{4\\pi\\varepsilon_0r^2}dr=\\frac{Q}{4\\pi\\varepsilon_0a}\\left(\\frac{1}{2}-\\frac{1}{2}\\frac{r^2}{a^2} \\right)+\\frac{Q}{4\\pi\\varepsilon_0a}=\\frac{Q}{4\\pi\\varepsilon_0a}\\left(\\frac{3}{2}-\\frac{1}{2}\\frac{r^2}{a^2} \\right)$. So the electrostatic potential is \n\\[\n\\varphi(r)=\n\\begin{cases}\n\\frac{Q}{4\\pi\\varepsilon_0a}\\left(\\frac{3}{2}-\\frac{1}{2}\\frac{r^2}{a^2} \\right), & r\\leq a\\\\\n\\frac{Q}{4\\pi\\varepsilon_0r}, & r>a\n\\end{cases}\n\\]\n\n\\paragraph{3.9.3}\nIt can be verified that $\\del\\times\\V{F}=0$, so the potential exists. \n\\[\n\\int_{(0,0,0)}^{(x,y,z)}\\V{F}\\cdot d\\V{r}=\\varphi(0,0,0)-\\varphi(x,y,z)\n\\]\n\\[\n=\\frac{GMm}{R^3}\\int_{(0,0,0)}^{(x,y,z)}(-xdx-ydy+2zdz)\n\\]\n\\[\n=\\frac{GMm}{R^3}\\left(-\\frac{x^2}{2}-\\frac{y^2}{2}+z^2 \\right)=\\varphi(0,0,0)-\\varphi(x,y,z)\n\\]\nDefine $\\varphi(0,0,0)$ to be zero, then \\[\\varphi(x,y,z)=-\\frac{GMm}{R^3}\\left(-\\frac{x^2}{2}-\\frac{y^2}{2}+z^2 \\right)\\] \n\n\\paragraph{3.9.4}\n$\\del\\cdot\\V{B}=\\frac{\\mu_0I}{2\\pi}\\left(\\frac{2xy}{(x^2+y^2)^2}-\\frac{2xy}{(x^2+y^2)^2} \\right)=0$, so the vector potential exists. If $\\del\\times\\V{A}'=\\V{B}$, and let $\\del\\varphi=-A_x'\\VE_x$, then $\\V{A}=\\V{A}'+\\del\\varphi$ is also a vector potential with zero $x$-component because  $\\del\\times\\V{A}=\\del\\times\\V{A}'+\\del\\times(\\del\\varphi)=\\V{B}$. Let $\\V{A}=A_y\\VE_y+A_z\\VE_z$, then \n\\[\n\\del\\times\\V{A}=\\left(\\pdv{A_z}{y}-\\pdv{A_y}{z} \\right)\\VE_x-\\pdv{A_z}{x}\\VE_y+\\pdv{A_y}{x}\\VE_z\n\\]\n\\[\n=-\\frac{\\mu_0I}{2\\pi}\\frac{y}{x^2+y^2}\\VE_x+\\frac{\\mu_0I}{2\\pi}\\frac{x}{x^2+y^2}\\VE_y\n\\]\nFor the $y$-component, $-\\pdv{A_z}{x}=\\frac{\\mu_0I}{2\\pi}\\frac{x}{x^2+y^2}$, so $A_z=-\\frac{\\mu_0I}{4\\pi}\\ln(x^2+y^2)+C_1(y,z)$. For the $z$-component, $\\pdv{A_y}{x}=0$, so $A_y=C_2(y,z)$. Substituting into the equation of the $x$-component, we get $-\\frac{\\mu_0I}{2\\pi}\\frac{y}{x^2+y^2}+\\pdv{C_1}{y}-\\pdv{C_2}{z}=-\\frac{\\mu_0I}{2\\pi}\\frac{y}{x^2+y^2}$, so the equation will be satisfied if we simply choose $C_1=C_2=0$. Therefore, \n\\[\n\\V{A}=-\\frac{\\mu_0I}{4\\pi}\\ln(x^2+y^2)\\VE_z\n\\]\nis a vector potential of $\\V{B}$.\n\n\\paragraph{3.9.5}\n$\\del\\cdot\\V{B}=3\\frac{1}{r^3}-3\\frac{x^2+y^2+z^2}{r^5}=0$, so the vector potential exist. As in Exercise 3.9.4, we can make one component of the vector potential be zero, and we choose the $z$-component. So $\\V{A}=A_x\\VE_x+A_y\\VE_y$, and\n\\[\n\\del\\times\\V{A}=-\\pdv{A_y}{z}\\VE_x+\\pdv{A_x}{z}\\VE_y+\\left(\\pdv{A_y}{x}-\\pdv{A_x}{y} \\right)\\VE_z\n\\]\n\\[\n=\\frac{x}{r^3}\\VE_x+\\frac{y}{r^3}\\VE_y+\\frac{z}{r^3}\\VE_z\n\\]\nso\n\\[\n-\\pdv{A_y}{z}=\\frac{x}{r^3}\\;\\xrightarrow{integrating}\\;A_y=\\frac{-xz}{(x^2+y^2)r}+C_1(x,y)\n\\]\n\\[\n\\pdv{A_x}{z}=\\frac{y}{r^3}\\;\\xrightarrow{integrating}\\;A_x=\\frac{yz}{(x^2+y^2)r}+C_2(x,y)\n\\]\nSubstituted into $\\pdv{A_y}{x}-\\pdv{A_x}{y}=\\frac{z}{r^3}$, we get\n\\[\n\\frac{z}{r^3}+\\pdv{C_1}{x}-\\pdv{C_2}{y}=\\frac{z}{r^3}\n\\]\nwhich will be satisfied if we simply choose $C_1=C_2=0$. Therefore, \n\\[\n\\V{A}=\\frac{yz}{(x^2+y^2)r}\\VE_x-\\frac{xz}{(x^2+y^2)r}\\VE_y\n\\]\nis a solution of $\\del\\times\\V{A}=\\V{B}$\n\n\\paragraph{3.9.6}\nIf $\\V{B}$ is a constant vector, then\n\\[\n\\del\\times\\V{A}=\\frac{1}{2}\\del\\times(\\V{B}\\times\\V{r})\\]\n\\[=\\frac{1}{2}\\del_\\V{r}\\times(\\V{B}\\times\\V{r})\n\\]\n\\[\n=\\frac{1}{2}[\\V{B}(\\del_\\V{r}\\cdot\\V{r})-(\\V{B}\\cdot\\del_\\V{r})\\V{r}]\n\\]\n\\[\n=\\frac{1}{2}[3\\V{B}-\\V{B}]=\\V{B}\n\\]\nSo the two equations are satisfied by any constant vector $\\V{B}$.\n\n\\paragraph{3.9.7}\n(a) $\\del\\cdot\\V{B}=\\del\\cdot((\\del u)\\times(\\del v))=(\\del v)\\cdot(\\del\\times(\\del u))-(\\del u)\\cdot(\\del\\times(\\del v))=0$ because $\\del\\times(\\del u)=0$ and $\\del\\times(\\del v)=0$.\n\\medskip\n\n(b) \n\\[\n\\del\\times\\V{A}=\\frac{1}{2}\\del\\times(u\\del v)-\\frac{1}{2}\\del\\times(v\\del u)\n\\]\n\\[\n=\\frac{1}{2}(\\del u)\\times(\\del v)+\\frac{1}{2}u(\\del\\times(\\del v))-\\frac{1}{2}(\\del v)\\times(\\del u)-\\frac{1}{2}v(\\del\\times(\\del u))\n\\]\n\\[\n=(\\del u)\\times(\\del v)=\\V{B}\n\\]\n\n\\paragraph{3.9.8}\nLet $\\V{A}'=\\V{A}+\\del\\varphi$, then $\\V{B}'=\\del\\times(\\V{A}+\\del\\varphi)=\\del\\times\\V{A}=\\V{B}$ because $\\del\\times(\\del\\varphi)=0$, so the left side of the equation is unchanged. $\\oint\\V{A}'\\cdot d\\V{r}=\\oint \\V{A}\\cdot d\\V{r}+\\oint\\del\\varphi\\cdot d\\V{r}=\\oint \\V{A}\\cdot d\\V{r}$ because $\\oint\\del\\varphi\\cdot d\\V{r}=\\oint d\\varphi=0$, so the right side of the equation is unchanged.\n\n\\paragraph{3.9.9}\nChoose point $P$ to be the origin of the coordinate system $(0,0,0)$. Let $u=\\frac{1}{r}$, $v=\\varphi$, and apply Green's theorem Eq. 3.85, \n\\[\n\\int\\displaylimits_V\\left(\\frac{1}{r}\\del^2\\varphi-\\varphi\\del^2(\\frac{1}{r}) \\right)d\\tau=\\oint\\displaylimits_{\\partial V}\\left(\\frac{1}{r}\\del\\varphi-\\varphi\\del(\\frac{1}{r}) \\right)\\cdot d\\boldsymbol{\\sigma}\n\\]\nwhere the volume $V$ is a sphere centered at $(0,0,0)$ with radius $r$. Because there are no charges on or within the sphere, we have $\\del^2\\varphi=0$, and by Eq. 3.120, $\\del^2(\\frac{1}{r})=-4\\pi\\delta(\\V{r})$. So the left side of the equation equals to $\\int\\displaylimits_V4\\pi\\varphi\\delta(\\V{r})d\\tau=4\\pi\\varphi(0)$. As for the right side, \\[\\oint\\displaylimits_{\\partial V}\\frac{1}{r}\\del\\varphi\\cdot d\\boldsymbol{\\sigma}=\\frac{1}{r}\\int\\displaylimits_V\\del\\cdot(\\del\\varphi)d\\tau=\\frac{1}{r}\\int\\displaylimits_V\\del^2\\varphi d\\tau=0\\] \\[-\\oint\\displaylimits_V\\varphi\\del(\\frac{1}{r})\\cdot d\\boldsymbol{\\sigma}=\\oint\\displaylimits_V\\varphi\\frac{1}{r^2}\\hat{\\V{r}}\\cdot d\\boldsymbol{\\sigma}=\\frac{\\oint\\displaylimits_V\\varphi d\\sigma}{r^2}\\]\nso the equation becomes $4\\pi\\varphi(0)=\\frac{\\oint\\displaylimits_V\\varphi d\\sigma}{r^2}$, so $\\varphi(0)=\\frac{\\oint\\displaylimits_V\\varphi d\\sigma}{4\\pi r^2}$, which means the potential at $P$ is the average of the potential over the spherical surface centered on $P$ with radius $r$.\n\n\\paragraph{3.9.10}\n$\\del\\times\\V{B}=\\mu\\V{J}$ and $\\V{B}=\\del\\times\\V{A}$, so $\\del\\times(\\del\\times\\V{A})=\\mu\\V{J}$. But $\\del\\times(\\del\\times\\V{A})=\\del(\\del\\cdot\\V{A})-(\\del\\cdot\\del)\\V{A}=-\\del^2\\V{A}$ because $\\del\\cdot\\V{A}=0$, so $\\del^2\\V{A}=-\\mu\\V{J}$.\n\n\\paragraph{3.9.11}\nFrom the Maxwell's equations, $\\del\\times\\V{B}=\\mu_0\\V{J}+\\frac{1}{c^2}\\pdv{\\V{E}}{t}$, so \n\\[\n\\del\\times(\\del\\times\\V{A})\n\\]\n\\[\n=\\del(\\del\\cdot\\V{A})-(\\del\\cdot\\del)\\V{A}=\\mu_0\\V{J}+\\frac{1}{c^2}\\pdv{\\V{E}}{t}\n\\]\nUsing the Lorentz gauge Eq. 3.109, \\[\n\\del(\\del\\cdot\\V{A})=\\del(-\\frac{1}{c^2}\\pdv{\\varphi}{t})=-\\frac{1}{c^2}\\pdv{}{t}(\\del\\varphi)=\\frac{1}{c^2}\\pdv{}{t}(\\V{E}+\\pdv{\\V{A}}{t})=\\frac{1}{c^2}\\pdv{\\V{E}}{t}+\\frac{1}{c^2}\\pdv{^2\\V{A}}{t^2}\n\\]\nSubstitute into the first equation, we get\n\\[\n\\frac{1}{c^2}\\pdv{^2\\V{A}}{t^2}-\\del^2\\V{A}=\\mu_0\\V{J}\n\\]\n\n\\paragraph{3.9.12}\nAs in Exercise 3.9.4, we can make one component of the vector potential be zero, so we make $\\V{A}=(A_x,0,A_z)$. So\n\\[\n\\del\\times\\V{A}=\\pdv{A_z}{y}\\VE_x+\\left(\\pdv{A_x}{z}-\\pdv{A_z}{x} \\right)\\VE_y-\\pdv{A_x}{y}\\VE_z=B_x\\VE_x+B_y\\VE_y+B_z\\VE_z\n\\]\nFor the $x$- and $z$-components, \n\\[\n\\pdv{A_z}{y}=B_x\\;\\xrightarrow{integrating}\\;A_z=\\int_{y_0}^yB_x(x,y,z) dy+C_1(x,y)\n\\]\n\\[\n-\\pdv{A_x}{y}=B_z\\;\\xrightarrow{integrating}\\;A_x=-\\int_{y_0}^yB_z(x,y,z) dy+C_2(x,y)\n\\]\nSubstitute into the equation of $y$-component, \n\\[\n-\\pdv{}{z}\\int_{y_0}^yB_zdy+\\pdv{C_2}{z}-\\pdv{}{x}\\int_{y_0}^yB_xdy-\\pdv{C_1}{x}=B_y\n\\]\nLet $y=y_0$, and let $C_2=0$, then \n\\[\n-\\pdv{C_1}{x}=B_y(x,y_0,z)\\;\\xrightarrow{integrating}\\;C_1=-\\int_{x_0}^xB_y(x,y_0,z) dx\n\\]\nTherefore, \n\\[\n\\V{A}=-\\VE_x\\int_{y_0}^yB_z(x,y,z) dy+\\VE_z\\left[\\int_{y_0}^yB_x(x,y,z) dy-\\int_{x_0}^xB_y(x,y_0,z) dx \\right]\n\\]\n\n\\section*{3.10 Curvilinear Coordinates}\n\n\\paragraph{3.10.1}\n(a) The surfaces of $u=constant$ are hyperbolas with $x=0$ and $y=0$ as asymptotes when viewing from the $z$-axis.  The surfaces of $v=constant$ are hyperbolas with $y=x$ and $y=-x$ as asymptotes when viewing from the $z$-axis. The surfaces of $z=constant$ are surfaces parallel to the $x$-$y$ plane.\n\n(b) \n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{B.PNG}\n    \\caption{The purple lines are $xy=0$, $xy=1$, $xy=2$} the orange lines are $x^2-y^2=0$, $x^2-y^2=1$, $x^2-y^2=2$.\n    \\label{fig:B}\n\\end{figure}\n\n(c) Take the derivative of $xy=u$ we get $ydx+xdy=0$. That is, $(y,x)\\cdot(dx,dy)=0$, so $(y,x)$ is a normal vector of $xy=u$ and therefore in the direction of $\\VE_u$. Because $\\pdv{u}{x}=y$, so $\\VE_u$ should be in the direction of $(y,x)$, not $(-y,-x)$. Normalizing, we get $\\VE_u=\\frac{y}{\\sqrt{x^2+y^2}}\\VE_x+\\frac{x}{\\sqrt{x^2+y^2}}\\VE_y$. By a similar process, from $2xdx-2ydy=0$, we get $\\VE_v=\\frac{x}{\\sqrt{x^2+y^2}}\\VE_x+\\frac{-y}{\\sqrt{x^2+y^2}}\\VE_y$.\n\n(d) $\\VE_u\\times\\VE_v=\\frac{-x^2-y^2}{x^2+y^2}\\VE_z=-\\VE_z$, so it is a left-handed system.\n\n\\paragraph{3.10.2}\n\n\\,\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{C.PNG}\n    \\caption{The orange lines are $u=\\frac{\\pi}{6}$, $u=\\frac{\\pi}{4}$, $u=\\frac{\\pi}{3}$}the purple lines are $v=\\frac{\\pi}{6}$, $v=\\frac{\\pi}{4}$, $v=\\frac{\\pi}{3}$\n    \\label{fig:C}\n\\end{figure}\n\nThe unit vectors $\\VE_u$ and $\\VE_v$ are perpendicular to the lines, and pointing right at $x>0$ and pointing left at $x<0$. \n\n\\paragraph{3.10.3}\nThe unit vectors of orthogonal coordinates are perpendicular to each other, so we have $\\VE_i\\cdot\\VE_j=\\delta_{ij}$, and $\\VE_i\\times\\VE_j=\\VE_k$. Therefore, $(A_1\\VE_1+A_2\\VE_2+A_3\\VE_3)\\cdot(B_1\\VE_1+B_2\\VE_2+B_3\\VE_3)=A_1B_1+A_2B_2+A_3B_3$, and \\[(A_1\\VE_1+A_2\\VE_2+A_3\\VE_3)\\times(B_1\\VE_1+B_2\\VE_2+B_3\\VE_3)=(A_2B_3-A_3B_2)\\VE_1+(A_3B_1-A_1B_3)\\VE_2+(A_1B_2-A_2B_1)\\VE_3\\]\n\n\\paragraph{3.10.4}\n(a) $\\VE_1=1\\VE_1+0\\VE_2+0\\VE_3$. Using the divergence formula for curvilinear coordinates, \\[\\del\\cdot\\varphi=\\frac{1}{h_1h_2h_3}\\pdv{(h_2h_3)}{q_1}\\]\n\n(b) \n\\[\n\\del\\times\\VE_1=\\frac{1}{h_1h_2h_3}\n\\begin{vmatrix}\n\\VE_1h_1&\\VE_2h_2&\\VE_3h_3\\\\\n\\pdv{}{q_1}&\\pdv{}{q_2}&\\pdv{}{q_3}\\\\\nh_1&0&0\n\\end{vmatrix}\n\\]\n\\[\n=\\frac{1}{h_1h_2h_3}\\left[\\VE_2h_2\\pdv{h_1}{q_3}-\\VE_3h_3\\pdv{h_1}{q_2} \\right]\n\\]\n\\[\n=\\frac{1}{h_1}\\left[\\VE_2\\frac{1}{h_3}\\pdv{h_1}{q_3}-\\VE_3\\frac{1}{h_2}\\pdv{h_1}{q_2} \\right]\n\\]\n\n\\paragraph{*3.10.5}\n$\\VE_i\\cdot\\VE_i=1=\\frac{1}{h_i^2}\\pdv{\\V{r}}{q_i}\\cdot\\pdv{\\V{r}}{q_i}=\\frac{1}{h_i^2}\\left((\\pdv{x}{q_1})^2+(\\pdv{y}{q_1})^2+(\\pdv{x}{q_1})^2 \\right)$, so $h_i^2=(\\pdv{x}{q_i})^2+(\\pdv{y}{q_i})^2+(\\pdv{x}{q_i})^2$, in agreement with Eq. 3.131.\n\nFrom $h_i\\VE_i=\\pdv{\\V{r}}{q_i}$, we can get \\[\\pdv{h_i}{q_j}\\VE_i+h_i\\pdv{\\VE_i}{q_j}=\\pdv{(h_i\\VE_i)}{q_j}=\\pdv{^2\\V{r}}{q_j\\partial q_i}\n=\\pdv{^2\\V{r}}{q_i\\partial q_j}=\\pdv{(h_j\\VE_j)}{q_i}=\\pdv{h_j}{q_i}\\VE_j+h_j\\pdv{\\VE_j}{q_i}\n\\]\nso\n\\[\nh_i\\pdv{\\VE_i}{q_j}-\\pdv{h_j}{q_i}\\VE_j=h_j\\pdv{\\VE_j}{q_i}-\\pdv{h_i}{q_j}\\VE_i=\\V{a}\n\\]\nIf $\\V{a}=0$, then $\\pdv{\\VE_i}{q_j}=\\frac{1}{h_i}\\pdv{h_j}{q_i}\\VE_j$ can be proved. However, I don't know how to prove it. (I know $\\V{a}\\cdot\\VE_i=\\V{a}\\cdot\\VE_j=0$, and also by taking $\\V{a}\\cdot\\V{a}$, it is equivalent to prove $\\pdv{\\VE_i}{q_j}\\cdot\\pdv{\\VE_j}{q_i}=0$, however, I can't find a proof for this either)\n\nFrom $\\VE_i\\cdot\\VE_j=0$, we have $\\pdv{\\VE_i}{q_i}\\cdot\\VE_j+\\VE_i\\cdot\\pdv{\\VE_j}{q_i}=0$, so we have \\[\\pdv{\\VE_i}{q_i}\\cdot\\VE_j=-\\VE_i\\cdot\\pdv{\\VE_j}{q_i}=-\\VE_i\\cdot\\VE_i\\frac{1}{h_j}\\pdv{h_i}{q_j}=-\\frac{1}{h_j}\\pdv{h_i}{q_j}\\]\nAlso, $\\pdv{\\VE_i}{q_i}\\cdot\\VE_j=\\frac{1}{2}\\pdv{(\\VE_i\\cdot\\VE_i)}{q_i}=0$, so \n\\[\n\\pdv{\\VE_i}{q_i}=\\sum_{j\\neq i}\\VE_j(\\pdv{\\VE_i}{q_i}\\cdot\\VE_j)=-\\sum_{j\\neq i}\\VE_j\\frac{1}{h_j}\\pdv{h_i}{q_j}\n\\]\n\n\\paragraph{3.10.6}\n$\\V{r}=\\rho\\cos\\varphi\\VE_x+\\rho\\sin\\varphi\\VE_y+z\\VE_z$     \n\\medskip\n\n$\\pdv{\\V{r}}{\\rho}=\\cos\\varphi\\VE_x+\\sin\\varphi\\VE_y=h_\\rho\\VE_\\rho$, so $h_\\rho=1$ and $\\VE_\\rho=\\cos\\varphi\\VE_x+\\sin\\varphi\\VE_y$\n\n$\\pdv{\\V{r}}{\\varphi}=-\\rho\\sin\\varphi\\VE_x+\\rho\\cos\\varphi\\VE_y=h_\\varphi\\VE_\\varphi$, so $h_\\varphi=\\rho$ and $\\VE_\\varphi=-\\sin\\varphi\\VE_x+\\cos\\varphi\\VE_y$\n\n$\\pdv{\\V{r}}{z}=\\VE_z=h_z\\VE_z$, so $h_z=1$ and $\\VE_z=\\VE_z$\n\n\\paragraph{3.10.7}\nFrom Exercise 3.10.6,\n\n$\\cos\\varphi\\VE_\\rho-\\sin\\varphi\\VE_\\varphi=(\\cos^2\\varphi+\\sin^2\\varphi)\\VE_x=\\VE_x$, so $\\VE_x=\\cos\\varphi\\VE_\\rho-\\sin\\varphi\\VE_\\varphi$\n\n$\\sin\\varphi\\VE_\\rho+\\cos\\varphi\\VE_\\varphi=(\\sin^2\\varphi+\\cos^2\\varphi)\\VE_y=\\VE_y$, so $\\VE_y=\\sin\\varphi\\VE_\\rho+\\cos\\varphi\\VE_\\varphi$\n\n$\\VE_z=\\VE_z$\n\n\\paragraph{3.10.8}\nFrom exercise 3.10.6,\n$\\pdv{\\VE_\\rho}{\\varphi}=-\\VE_x\\sin\\varphi+\\VE_y\\cos\\varphi=\\VE_\\varphi$, and $\\pdv{\\VE_\\varphi}{\\varphi}=-\\VE_x\\cos\\varphi-\\VE_y\\sin\\varphi=-\\VE_\\rho$. All the other derivatives vanish because $\\VE_\\rho$ and $\\VE_\\varphi$ are functions of $\\varphi$ only, and $\\VE_z$ is a constant vector.\n\n\\paragraph{3.10.9}\nFrom exercise 3.10.8, $\\pdv{\\VE_\\rho}{\\varphi}=\\VE_\\varphi$ and $\\pdv{\\VE_\\varphi}{\\varphi}=-\\VE_\\rho$, so \n\\[\n\\del\\cdot\\V{V}=(\\VE_\\rho\\pdv{}{\\rho}+\\VE_\\varphi\\frac{1}{\\rho}\\pdv{}{\\varphi}+\\VE_z\\pdv{}{z})\\cdot(\\VE_\\rho V_\\rho+\\VE_\\varphi V_\\varphi+\\VE_z V_z)\n\\]\n\\[\n=\\VE_\\rho\\cdot(\\VE_\\rho\\pdv{V_\\rho}{\\rho}+\\VE_\\varphi\\pdv{V_\\rho}{\\rho}+\\VE_z\\pdv{V_z}{\\rho})\n+\\frac{1}{\\rho}\\VE_\\varphi\\cdot(\\VE_\\varphi V_\\rho+\\VE_\\rho\\pdv{V_\\rho}{\\varphi}-\\VE_\\rho V_\\varphi+\\VE_\\varphi\\pdv{V_\\varphi}{\\varphi}+\\VE_z\\pdv{V_z}{\\varphi})+\\VE_z\\cdot(\\VE_z\\pdv{V_z}{z})\n\\]\n\\[\n=\\pdv{V_\\rho}{\\rho}+\\frac{V_\\rho}{\\rho}+\\frac{1}{\\rho}\\pdv{V_\\varphi}{\\varphi}+\\pdv{V_z}{z}\n\\]\n\\[\n=\\frac{1}{\\rho}\\pdv{(\\rho V_\\rho)}{\\rho}+\\frac{1}{\\rho}\\pdv{V_\\varphi}{\\varphi}+\\pdv{V_z}{z}\n\\]\n\n\\paragraph{3.10.10}\n(a) From exercise 3.10.6, $\\VE_\\rho\\rho+\\VE_z z=\\VE_x\\rho\\cos\\varphi+\\VE_y\\rho\\sin\\varphi+\\VE_z z=\\VE_x x+\\VE_y y+\\VE_z z=\\V{r}$\n\n(b) \\[\\del\\cdot\\V{r}=\\frac{1}{\\rho}\\pdv{}{\\rho}(\\rho^2)+\\pdv{V_z}{z}=2+1=3\\] \n\\[\n\\del\\times\\V{r}=\\frac{1}{\\rho}\n\\begin{vmatrix}\n\\VE_\\rho&\\VE_\\varphi\\rho&\\VE_z\\\\\n\\pdv{}{\\rho}&\\pdv{}{\\varphi}&\\pdv{}{z}\\\\\n\\rho&0&z\n\\end{vmatrix}=0\n\\]\n\n\\paragraph{3.10.11}\n(a) A point $P=(\\rho\\cos\\varphi,\\rho\\sin\\varphi,z)$ after reflection would be $P'=(-\\rho\\cos\\varphi,-\\rho\\sin\\varphi,-z)=(\\rho\\cos(\\varphi\\pm\\pi),\\rho\\sin(\\varphi\\pm\\pi),-z)$, so it corresponds to the transformation \n\\[\n\\rho\\rightarrow\\rho,\\quad\\varphi\\rightarrow\\varphi\\pm\\pi,\\quad z\\rightarrow-z\n\\]\n\n(b) \n\\[\n\\VE_\\rho'=\\VE_x\\cos(\\varphi\\pm\\pi)+\\VE_y\\sin(\\varphi\\pm\\pi)=-\\VE_x\\cos\\varphi-\\VE_y\\sin\\varphi=-\\VE_\\rho\n\\]\n\\[\n\\VE_\\varphi'=-\\VE_x\\sin(\\varphi\\pm\\pi)+\\VE_y\\cos(\\varphi\\pm\\pi)=\\VE_x\\sin\\varphi-\\VE_y\\cos\\varphi=-\\VE_\\varphi\n\\]\n\\[\n\\VE_z'=\\VE_z\n\\]\n\n\\paragraph{3.10.12}\n(a) \n\\[\n\\V{v}=\\boldsymbol{\\omega}\\times\\V{r}=(\\omega\\VE_z)\\times(\\rho\\VE_\\varphi+z\\VE_z)=\\omega\\rho\\VE_\\varphi\n\\]\n\n(b)\n\\[\n\\del\\times\\V{v}=\\frac{1}{\\rho}\n\\begin{vmatrix}\n\\VE_\\rho&\\VE_\\varphi\\rho&\\VE_z\\\\\n\\pdv{}{\\rho}&\\pdv{}{\\varphi}&\\pdv{}{z}\\\\\n0&\\omega\\rho^2&0\n\\end{vmatrix}=\n\\frac{1}{\\rho}(2\\omega\\rho)\\VE_z=2\\boldsymbol{\\omega}\n\\]\n\n\\paragraph{3.10.13}\n\\[\n\\frac{d\\VE_\\rho}{dt}=-\\VE_x\\dot{\\varphi}\\sin\\varphi+\\VE_y\\dot{\\varphi}\\cos\\varphi=\\VE_\\varphi\\dot{\\varphi}\n\\]\n\\[\n\\frac{d\\VE_\\varphi}{dt}=-\\VE_x\\dot{\\varphi}\\cos\\varphi-\\VE_y\\dot{\\varphi}\\sin\\varphi=-\\VE_\\rho\\dot{\\varphi}\n\\]\n\\[\n\\frac{d\\VE_z}{dt}=0\n\\]\n\\[\n\\V{r}=\\VE_\\rho\\rho+\\VE_z z\n\\]\n\\[\n\\V{v}=\\dot{\\V{r}}=\\VE_\\varphi\\dot{\\varphi}\\rho+\\VE_\\rho\\dot{\\rho}+\\VE_z\\dot{z}\\]\n\\[\n=\\VE_\\rho\\dot{\\rho}+\\VE_\\varphi\\rho\\dot{\\varphi}+\\VE_z\\dot{z}\n\\]\n\\[\n\\V{a}=\\dot{\\V{v}}=\\VE_\\varphi\\dot{\\varphi}\\dot{\\rho}+\\VE_\\rho\\Ddot{\\rho}-\\VE_\\rho\\dot{\\varphi}\\rho\\dot{\\varphi}+\\VE_\\rho(\\dot{\\rho}\\dot{\\varphi}+\\rho\\Ddot{\\varphi})+\\VE_z\\Ddot{z}\n\\]\n\\[\n=\\VE_\\rho(\\Ddot{\\rho}-\\rho\\dot{\\varphi\n}^2)+\\VE_\\varphi(\\rho\\Ddot{\\varphi}+2\\dot{\\rho}\\dot{\\varphi})+\\VE_z\\Ddot{z}\n\\]\n\n\\paragraph{3.10.14}\n\\[\n\\del\\times\\V{v}=\\frac{1}{\\rho}\n\\begin{vmatrix}\n\\VE_\\rho&\\VE_\\varphi\\rho&\\VE_z\\\\\n\\pdv{}{\\rho}&\\pdv{}{\\varphi}&\\pdv{}{z}\\\\\nV_\\rho(\\rho,\\varphi)&\\rho V_\\varphi(\\rho,\\varphi)&0\n\\end{vmatrix}\n=\\frac{1}{\\rho}\\left[\\VE_z\\left(\\pdv{(\\rho V_\\varphi)}{\\rho}-\\pdv{V_\\rho}{\\varphi}\\right) \\right]\n\\]\n\n\\paragraph{3.10.15}\n\\[\n\\V{B}=\\del\\times\\V{A}=\\frac{1}{\\rho}\n\\begin{vmatrix}\n\\VE_\\rho&\\VE_\\varphi\\rho&\\VE_z\\\\\n\\pdv{}{\\rho}&\\pdv{}{\\varphi}&\\pdv{}{z}\\\\\n0&0&\\frac{\\mu I}{2\\pi}\\ln(\\frac{1}{\\rho})\n\\end{vmatrix}\n=\\frac{1}{\\rho}\\left[-\\VE_\\varphi\\rho\\frac{\\mu I}{2\\pi}\\rho\\frac{-1}{\\rho^2} \\right]=\\VE_\\varphi\\frac{\\mu I}{2\\pi\\rho}\n\\]\n\n\\paragraph{3.10.16}\n(a) From exercise 3.10.7, we have\n\\[\n\\V{F}=-(\\VE_\\rho\\cos\\varphi-\\VE_\\varphi\\sin\\varphi)\\frac{\\rho\\sin\\varphi}{\\rho^2}+(\\VE_\\rho\\sin\\varphi+\\VE_\\varphi\\cos\\varphi)\\frac{\\rho\\cos\\varphi}{\\rho^2}=\\VE_\\rho\\frac{1}{\\rho}\n\\]\n\n(b) \n\\[\n\\del\\times\\V{F}=\\frac{1}{\\rho}\n\\begin{vmatrix}\n\\VE_\\rho&\\VE_\\varphi\\rho&\\VE_z\\\\\n\\pdv{}{\\rho}&\\pdv{}{\\varphi}&\\pdv{}{z}\\\\\n0&\\rho\\frac{1}{\\rho}&0\n\\end{vmatrix}\n=0\n\\]\n\n(c)\n\\[\n\\oint(\\VE_\\varphi\\frac{1}{\\rho})\\cdot(\\VE_\\rho d\\rho+\\VE_\\varphi\\rho d\\varphi+\\VE_z dz)=\\oint d\\varphi=2\\pi\n\\]\n\n(d) The range of $\\varphi$ of cylindrical coordinates is $0\\leq\\varphi<2\\pi$, so $\\int_0^{2\\pi}d\\varphi$ is not defined.\n\n\\paragraph{3.10.17}\n\\[\n(\\V{B}\\cdot\\del)\\V{B}=B_\\varphi\\frac{1}{\\rho}\\pdv{}{\\varphi}(\\VE_\\varphi B_\\varphi(\\rho))=\\frac{B_\\varphi}{\\rho}[-\\VE_\\rho B_\\varphi+0]=-\\VE_\\rho\\frac{B_\\varphi^2}{\\rho}\n\\]\n\n\\paragraph{3.10.18}\n\\[\n\\pdv{\\V{r}}{r}=\\VE_x\\sin\\theta\\cos\\varphi+\\VE_y\\sin\\theta\\sin\\varphi+\\VE_z\\cos\\theta=h_r\\VE_r\\]\nso\n\\[h_r=1,\\quad \\VE_r=\\VE_x\\sin\\theta\\cos\\varphi+\\VE_y\\sin\\theta\\sin\\varphi+\\VE_z\\cos\\theta\n\\]\n\\[\n\\pdv{\\V{r}}{\\theta}=\\VE_xr\\cos\\theta\\cos\\varphi+\\VE_y r\\cos\\theta\\sin\\varphi-\\VE_z r\\sin\\theta=h_\\theta\\VE_\\theta\\]\nso\n\\[h_\\theta=r,\\quad \\VE_\\theta=\\VE_x\\cos\\theta\\cos\\varphi+\\VE_y\\cos\\theta\\sin\\varphi-\\VE_z\\sin\\theta\n\\]\n\\[\n\\pdv{\\V{r}}{\\varphi}=-\\VE_x r\\sin\\theta\\sin\\varphi+\\VE_y r\\sin\\theta\\cos\\varphi=h_\\varphi\\VE_\\varphi\n\\]\nso\n\\[\nh_\\varphi=r\\sin\\theta,\\quad\\VE_\\varphi=-\\VE_x\\sin\\varphi+\\VE_y\\cos\\varphi\n\\]\n\n\\paragraph{3.10.19}\n\\begin{equation}\n    \\VE_r=\\VE_x\\sin\\theta\\cos\\varphi+\\VE_y\\sin\\theta\\sin\\varphi+\\VE_z\\cos\\theta\n\\end{equation}\n\\begin{equation}\n    \\VE_\\theta=\\VE_x\\cos\\theta\\cos\\varphi+\\VE_y\\cos\\theta\\sin\\varphi-\\VE_z\\sin\\theta\n\\end{equation}\n\\begin{equation}\n    \\VE_\\varphi=-\\VE_x\\sin\\varphi+\\VE_y\\cos\\varphi\n\\end{equation}\n$\\cos\\theta\\times(1)-\\sin\\theta\\times(2)$, we get \n\\[\n\\VE_z=\\VE_r\\cos\\theta-\\VE_\\theta\\sin\\theta\n\\]\n$\\sin\\theta\\times(1)+\\cos\\theta\\times(2)$, we get \n\\begin{equation}\n    \\VE_r\\sin\\theta+\\VE_\\theta\\cos\\theta=\\VE_x\\cos\\varphi+\\VE_y\\sin\\varphi\n\\end{equation}\n$\\cos\\varphi\\times(4)-\\sin\\varphi\\times(3)$, we get\n\\[\n\\VE_x=\\VE_r\\sin\\theta\\cos\\varphi+\\VE_\\theta\\cos\\theta\\cos\\varphi-\\VE_\\varphi\\sin\\varphi\n\\]\n$\\cos\\varphi\\times(3)+\\sin\\varphi\\times(4)$, we get\n\\[\n\\VE_y=\\VE_r\\sin\\theta\\sin\\varphi+\\VE_\\theta\\cos\\theta\\sin\\varphi+\\VE_\\varphi\\cos\\varphi\n\\]\n\n\\paragraph{3.10.20}\n(a) The point $\\V{r}=(0,0,0)$ is related to $\\V{r'}=(0,\\theta,\\varphi)$ for any $0\\leq\\theta\\leq\\pi$ and $0\\leq\\varphi<2\\pi$. If $\\V{r'}=\\M{B}\\V{r}$, then $\\V{r}=(0,0,0)$ can only be related to $\\V{r'}=(0,0,0)$, a contradiction, so the matrix $\\M{B}$ cannot exist.\\\\\n(If $x,y,z\\neq0$, then simply \n\\[\\M{B}=\n\\begin{pmatrix}\n\\frac{r}{x}&0&0\\\\\n0&\\frac{\\theta}{y}&0\\\\\n0&0&\\frac{\\varphi}{z}\n\\end{pmatrix}\n\\]\nsatisfies the condition.)\n\n(b)\nFrom exercise 3.10.19,\n\\[\n\\V{V}=\\VE_xV_x+\\VE_yV_y+\\VE_zV_z\n\\]\n\\[\n=(\\VE_r\\sin\\theta\\cos\\varphi+\\VE_\\theta\\cos\\theta\\cos\\varphi-\\VE_\\varphi\\sin\\varphi)V_x\n\\]\n\\[+(\\VE_r\\sin\\theta\\sin\\varphi+\\VE_\\theta\\cos\\theta\\sin\\varphi+\\VE_\\varphi\\cos\\varphi)V_y\\]\n\\[+(\\VE_r\\cos\\theta-\\VE_\\theta\\sin\\theta)V_z\n\\]\n\\[\n=\\VE_rV_r+\\VE_\\theta V_\\theta+\\VE_\\varphi V_\\varphi\n\\]\nwhich is\n\\[\n\\begin{pmatrix}\nV_r\\\\V_\\theta\\\\V_\\varphi\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\sin\\theta\\cos\\varphi&\\sin\\theta\\sin\\varphi&\\cos\\theta\\\\\n\\cos\\theta\\cos\\varphi&\\cos\\theta\\sin\\varphi&-\\sin\\theta\\\\\n-\\sin\\varphi&\\cos\\varphi&0\n\\end{pmatrix}\n\\begin{pmatrix}\nV_x\\\\V_y\\\\V_z\n\\end{pmatrix}\n\\]\nLet the matrix be $\\M{M}$, and let its transpose be $\\V{M}^T$, then it can be verified that $\\M{M}\\M{M}^T=\\boldsymbol{1}$, so it is orthogonal.\n\n\\paragraph{3.10.21}\n(Let $\\varphi$ of spherical coordinate be $\\phi$, and $\\varphi$ of cylindrical coordinate remain the same.)\nThe relations between the two coordinates are $\\rho=r\\sin\\theta$, $\\varphi=\\phi$, $z=r\\cos\\theta$.\n\\[\n\\VE_r=\\pdv{\\V{r}}{r}=\\pdv{\\V{r}}{\\rho}\\pdv{\\rho}{r}+\\pdv{\\V{r}}{\\varphi}\\pdv{\\varphi}{r}+\\pdv{\\V{r}}{z}\\pdv{z}{r}\n=\\VE_\\rho\\sin\\theta+\\VE_\\varphi\\rho\\cdot0+\\VE_z\\cos\\theta\n\\]\n\\[\n=\\VE_\\rho\\sin\\theta+\\VE_z\\cos\\theta\n\\]\n\\[\n\\VE_\\theta=\\frac{1}{r}\\pdv{\\V{r}}{\\theta}=\\frac{1}{r}(\\pdv{\\V{r}}{\\rho}\\pdv{\\rho}{\\theta}+\\pdv{\\V{r}}{\\varphi}\\pdv{\\varphi}{\\theta}+\\pdv{\\V{r}}{z}\\pdv{z}{\\theta})=\n\\frac{1}{r}\\VE_\\rho r\\cos\\theta+\\frac{1}{r}\\VE_\\varphi\\rho\\cdot0+\\frac{1}{r}\\VE_z(-r\\sin\\theta)\n\\]\n\\[\n=\\VE_\\rho\\cos\\theta-\\VE_z\\sin\\theta\n\\]\n\\[\n\\VE_\\phi=\\frac{1}{r\\sin\\theta}\\pdv{\\V{r}}{\\phi}=\\frac{1}{r\\sin\\theta}(\\pdv{\\V{r}}{\\rho}\\pdv{\\rho}{\\phi}+\\pdv{\\V{\\phi}}{\\varphi}\\pdv{\\varphi}{\\phi}+\\pdv{\\V{r}}{z}\\pdv{z}{\\phi})=\n\\frac{1}{r\\sin\\theta}\\VE_\\varphi\\rho\\cdot1\n\\]\n\\[\n=\\VE_\\varphi\n\\]\nso\n\\[\n\\V{V}=V_r\\VE_r+V_\\theta\\VE_\\theta+V_\\phi\\VE_\\phi\n\\]\n\\[\n=V_r(\\VE_\\rho\\sin\\theta+\\VE_z\\cos\\theta)+V_\\theta(\\VE_\\rho\\cos\\theta-\\VE_z\\sin\\theta)+V_\\phi\\VE_\\varphi\n\\]\n\\[\n=V_\\rho\\VE_\\rho+V_\\varphi\\VE_\\varphi+V_z\\VE_z\n\\]\nwhich is \n\\[\n\\begin{pmatrix}\nV_\\rho\\\\V_\\varphi\\\\V_z\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\sin\\theta&\\cos\\theta&0\\\\\n0&0&1\\\\\n\\cos\\theta&-\\sin\\theta&0\n\\end{pmatrix}\n\\begin{pmatrix}\nV_r\\\\V_\\theta\\\\V_\\phi\n\\end{pmatrix}\n\\]\nLet the matrix be $\\M{M}$. Note that it is orthogonal, so the inverse transformation is \n\\[\n\\M{M}^{-1}=\\M{M}^T=\n\\begin{pmatrix}\n\\sin\\theta&0&\\cos\\theta\\\\\n\\cos\\theta&0&-\\sin\\theta\\\\\n0&1&0\n\\end{pmatrix}\n\\]\n\n\\paragraph{3.10.22}\n(a) \n\\begin{align*}\n    \\pdv{\\VE_r}{r}&=0 &\n    \\pdv{\\VE_r}{\\theta}&=\\VE_\\theta&\n    \\pdv{\\VE_r}{\\varphi}&=\\VE_\\varphi\\sin\\theta\\\\\n    \\pdv{\\VE_\\theta}{r}&=0 &\n    \\pdv{\\VE_\\theta}{\\theta}&=-\\VE_r&\n    \\pdv{\\VE_\\theta}{\\varphi}&=\\VE_\\varphi\\cos\\theta\\\\\n    \\pdv{\\VE_\\varphi}{r}&=0 &\n    \\pdv{\\VE_\\varphi}{\\theta}&=0&\n    \\pdv{\\VE_\\varphi}{\\varphi}&=-\\VE_r\\sin\\theta-\\VE_\\theta\\cos\\theta \\\\\n\\end{align*}\n\n(b)\n\\[\n\\del\\cdot\\del\\psi=(\\VE_r\\pdv{}{r}+\\VE_\\theta\\frac{1}{r}\\pdv{}{\\theta}+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi})\\cdot(\\VE_r\\pdv{\\psi}{r}+\\VE_\\theta\\frac{1}{r}\\pdv{\\psi}{\\theta}+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{\\psi}{\\varphi})\n\\]\n\\[\n=\\VE_r\\cdot\\left(\\VE_r\\pdv{^2\\psi}{r^2}+\\VE_\\theta(\\cdots)+\\VE_\\varphi(\\cdots) \\right)\n+\\frac{1}{r}\\VE_\\theta\\cdot\\left(\\VE_\\theta\\pdv{\\psi}{r}+\\VE_\\theta\\frac{1}{r}\\pdv{^2\\psi}{\\theta^2}+\\VE_r(\\cdots)+\\VE_\\varphi(\\cdots) \\right)\n\\]\n\\[\n+\\frac{1}{r\\sin\\theta}\\VE_\\varphi\\cdot\\left(\\VE_\\varphi\\sin\\theta\\pdv{\\psi}{r}+\\VE_\\varphi\\cos\\theta\\frac{1}{r}\\pdv{\\psi}{\\theta}+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{^2\\psi}{\\varphi^2}+\\VE_r(\\cdots)+\\VE_\\theta(\\cdots) \\right)\n\\]\n\\[\n=\\frac{2}{r}\\pdv{\\psi}{r}+\\pdv{^2\\psi}{r^2}+\\frac{\\cos\\theta}{r^2\\sin\\theta}\\pdv{\\psi}{\\theta}+\\frac{1}{r^2}\\pdv{^2\\psi}{\\theta^2}+\\frac{1}{r^2\\sin^2\\theta}\\pdv{^2\\psi}{\\varphi^2}\n\\]\n\\[\n=\\frac{1}{r^2\\sin\\theta}\\left[\\sin\\theta\\pdv{}{r}(r^2\\pdv{\\psi}{r})+\\pdv{}{\\theta}(\\sin\\theta\\pdv{\\psi}{\\theta})+\\frac{1}{\\sin\\theta}\\pdv{^2\\psi}{\\varphi^2} \\right]\n\\]\n\n\\paragraph{3.10.23}\n(a) $\\boldsymbol{\\omega}=\\VE_z\\omega=\\VE_r\\omega\\cos\\theta-\\VE_\\theta\\omega\\sin\\theta$, so\n\\[\n\\V{v}=\\boldsymbol{\\omega}\\times\\V{r}=(\\VE_r\\omega\\cos\\theta-\\VE_\\theta\\omega\\sin\\theta)\\times(\\VE_r r)=\\VE_\\varphi\\omega r \\sin\\theta\n\\]\n\n(b)\n\\[\n\\del\\times\\V{v}=\\frac{1}{r^2\\sin\\theta}\n\\begin{vmatrix}\n\\VE_r&\\VE_\\theta r&\\VE_\\varphi r\\sin\\theta\\\\\n\\pdv{}{r}&\\pdv{}{\\theta}&\\pdv{}{\\varphi}\\\\\n0&0&\\omega r^2\\sin^2\\theta\n\\end{vmatrix}\\]\n\\[=\\frac{1}{r^2\\sin\\theta}(\\VE_r2\\omega r^2\\sin\\theta\\cos\\theta-\\VE_\\theta2\\omega r^2\\sin^2\\theta)\\]\n\\[=2\\VE_r\\omega\\cos\\theta-2\\VE_\\theta\\omega\\sin\\theta=2\\boldsymbol{\\omega}\n\\]\n\n\\paragraph{3.10.24}\n\\[\n\\del\\times\\V{V}=\\frac{1}{r^2\\sin\\theta}\n\\begin{vmatrix}\n\\VE_r&\\VE_\\theta r&\\VE_\\varphi r\\sin\\theta\\\\\n\\pdv{}{r}&\\pdv{}{\\theta}&\\pdv{}{\\varphi}\\\\\n0&V_\\theta&V_\\varphi\n\\end{vmatrix}\n\\]\n\\[\n=\\frac{1}{r^2\\sin\\theta}\\left[\\VE_r(\\pdv{V_\\varphi}{\\theta}-\\pdv{V_\\theta}{\\varphi})-\\VE_\\theta r(\\pdv{V_\\varphi}{r})+\\VE_\\varphi r\\sin\\theta(\\pdv{V_\\theta}{r}) \\right]\n\\]\nhas no tangential components, so $\\pdv{V_\\varphi}{r}=\\pdv{V_\\theta}{r}=0$. That is, the tangential components of $\\V{V}$ have no radial dependence.\n\n\\paragraph{3.10.25}\n(a) A point $P=(r\\sin\\theta\\cos\\varphi,r\\sin\\theta\\sin\\varphi,r\\cos\\theta)$ after reflection would become\\\\ $P'=(-r\\sin\\theta\\cos\\varphi,-r\\sin\\theta\\sin\\varphi,-r\\cos\\theta)=(r\\sin(\\pi-\\theta)\\cos(\\varphi\\pm\\pi),r\\sin(\\pi-\\theta)\\sin(\\varphi\\pm\\pi),r\\cos(\\pi-\\theta))$, so it corresponds to the transformation \n\\[\nr\\rightarrow r,\\quad\\theta\\rightarrow\\pi-\\theta,\\quad \\varphi\\rightarrow\\varphi\\pm\\pi\n\\]\n\n(b) \n\n\\[\\VE_r'=\\VE_x\\sin(\\pi-\\theta)\\cos(\\varphi\\pm\\pi)+\\VE_y\\sin(\\pi-\\theta)\\sin(\\varphi\\pm\\pi)+\\VE_z\\cos(\\pi-\\theta)=-\\VE_r\n\\]\n\\[ \\VE_\\theta=\\VE_x\\cos(\\pi-\\theta)\\cos(\\varphi\\pm\\pi)+\\VE_y\\cos(\\pi-\\theta)\\sin(\\varphi\\pm\\pi)-\\VE_z\\sin(\\pi-\\theta)=\\VE_\\theta\n\\]\n\\[\n\\VE_\\varphi=-\\VE_x\\sin(\\varphi\\pm\\pi)+\\VE_y\\cos(\\varphi\\pm\\pi)=-\\VE_\\varphi\n\\]\n\n\\paragraph{3.10.26}\n(a)\n\\[\n(\\V{A}\\cdot\\del)\\V{r}=(A_x\\pdv{}{x}+A_y\\pdv{}{y}+A_z\\pdv{}{z})(x\\VE_x+y\\VE_y+z\\VE_z)\\]\n\\[=A_x\\VE_x+A_y\\VE_y+A_z\\VE_z=\\V{A}\n\\]\n\n(b) \nFrom exercise 3.10.22\n\\[\n(\\V{A}\\cdot\\del)\\V{r}=(A_r\\pdv{}{r}+A_\\theta\\frac{1}{r}\\pdv{}{\\theta}+A_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi})(r\\VE_r)=A_r\\VE_r+A_\\theta\\frac{1}{r}r\\VE_\\theta+A_\\varphi\\frac{1}{r\\sin\\theta}r\\sin\\theta\\VE_\\varphi\\]\n\\[=A_r\\VE_r+A_\\theta\\VE_\\theta+A_\\varphi\\VE_\\varphi=\\V{A}\n\\]\n\n\\paragraph{3.10.27}\nFrom exercise 3.10.22\n\\[\n\\frac{d\\VE_r}{dt}=\\pdv{\\VE_r}{r}\\pdv{r}{t}+\\pdv{\\VE_r}{\\theta}\\pdv{\\theta}{t}+\\pdv{\\VE_r}{\\varphi}\\pdv{\\varphi}{t}=\\VE_\\theta\\dot{\\theta}+\\VE_\\varphi\\sin\\theta\\dot{\\varphi}\n\\]\n\\[\n\\frac{d\\VE_\\theta}{dt}=\\pdv{\\VE_\\theta}{r}\\pdv{r}{t}+\\pdv{\\VE_\\theta}{\\theta}\\pdv{\\theta}{t}+\\pdv{\\VE_\\theta}{\\varphi}\\pdv{\\varphi}{t}=-\\VE_r\\dot{\\theta}+\\VE_\\varphi\\cos\\theta\\dot{\\varphi}\n\\]\n\\[\n\\frac{d\\VE_\\varphi}{dt}=\\pdv{\\VE_\\varphi}{r}\\pdv{r}{t}+\\pdv{\\VE_\\varphi}{\\theta}\\pdv{\\theta}{t}+\\pdv{\\VE_\\varphi}{\\varphi}\\pdv{\\varphi}{t}=-\\VE_r\\sin\\theta\\dot{\\varphi}-\\VE_\\theta\\cos\\theta\\dot{\\varphi}\n\\]\n\\[\n\\V{r}=\\VE_r r\n\\]\nso\n\\[\n\\V{v}=\\dot{\\V{r}}=\\VE_\\theta\\dot{\\theta}r+\\VE_\\varphi\\sin\\theta\\dot{\\varphi}r+\\VE_r\\dot{r}\n\\]\n\\[\n=\\VE_r\\dot{r}+\\VE_\\theta r\\dot{\\theta}+\\VE_\\varphi r\\sin\\theta\\dot{\\varphi}\n\\]\n\\[\n\\V{a}=\\dot{\\V{v}}=\\VE_\\theta\\dot{r}\\dot{\\theta}+\\VE_\\varphi\\dot{r}\\sin\\theta\\dot{\\varphi}+\\VE_r\\Ddot{r}-\\VE_r r{\\dot{\\theta}}^2+\\VE_\\varphi r\\cos\\theta\\dot{\\theta}\\dot{\\varphi}+\\VE_\\theta\\dot{r}\\dot{\\theta}+\\VE_\\theta r\\Ddot{\\theta}\\]\n\\[-\\VE_r r\\sin^2\\theta{\\dot{\\varphi}}^2-\\VE_\\theta r\\sin\\theta\\cos\\theta{\\dot{\\varphi}}^2+\\VE_\\varphi\\dot{r}\\sin\\theta\\dot{\\varphi}+\\VE_\\varphi r\\cos\\theta\\dot{\\theta}\\dot{\\varphi}+\\VE_\\varphi r\\sin\\theta\\Ddot{\\varphi}\n\\]\n\\[\n=\\VE_r(\\Ddot{r}-r{\\dot{\\theta}}^2-r\\sin^2\\theta{\\dot{\\varphi}}^2)+\\VE_\\theta(r\\Ddot{\\theta}+2\\dot{r}\\dot{\\theta}-r\\sin\\theta\\cos\\theta{\\dot{\\varphi}}^2)+\\VE_\\varphi(r\\sin\\theta\\Ddot{\\varphi}+2\\dot{r}\\sin\\theta\\dot{\\varphi}+2r\\cos\\theta\\dot{\\theta}\\dot{\\varphi})\n\\]\n\n\\paragraph{3.10.28}\n\\[\n\\del=\\VE_x\\pdv{}{x}+\\VE_y\\pdv{}{y}+\\VE_z\\pdv{}{z}\n\\]\n\\[\n=\\VE_r\\pdv{}{r}+\\VE_\\theta\\frac{1}{r}\\pdv{}{\\theta}+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi}\n\\]\n\\[\n=(\\VE_x\\sin\\theta\\cos\\varphi+\\VE_y\\sin\\theta\\sin\\varphi+\\VE_z\\cos\\theta)\\pdv{}{r}\n\\]\n\\[\n+(\\VE_x\\cos\\theta\\cos\\varphi+\\VE_y\\cos\\theta\\sin\\varphi-\\VE_z\\sin\\theta)\\frac{1}{r}\\pdv{}{\\theta}\n\\]\n\\[\n+(-\\VE_x\\sin\\varphi+\\VE_y\\cos\\varphi)\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi}\n\\]\n\\[\n=\\VE_x(\\sin\\theta\\cos\\varphi\\pdv{}{r}+\\cos\\theta\\cos\\varphi\\frac{1}{r}\\pdv{}{\\theta}-\\frac{\\sin\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi})\n\\]\n\\[\n+\\VE_y(\\sin\\theta\\sin\\varphi\\pdv{}{r}+\\cos\\theta\\sin\\varphi\\frac{1}{r}\\pdv{}{\\theta}+\\frac{\\cos\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi})\n\\]\n\\[\n+\\VE_z(\\cos\\theta\\pdv{}{r}-\\sin\\theta\\frac{1}{r}\\pdv{}{\\theta})\n\\]\nequating the $x,y,z$ components, we get\n\\[\n\\pdv{}{x}=\\sin\\theta\\cos\\varphi\\pdv{}{r}+\\cos\\theta\\cos\\varphi\\frac{1}{r}\\pdv{}{\\theta}-\\frac{\\sin\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi}\n\\]\n\\[\n\\pdv{}{y}=\\sin\\theta\\sin\\varphi\\pdv{}{r}+\\cos\\theta\\sin\\varphi\\frac{1}{r}\\pdv{}{\\theta}+\\frac{\\cos\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi}\n\\]\n\\[\n\\pdv{}{z}=\\cos\\theta\\pdv{}{r}-\\sin\\theta\\frac{1}{r}\\pdv{}{\\theta}\n\\]\n\n\\paragraph{3.10.29}\n$x=r\\sin\\theta\\cos\\varphi$, $y=r\\sin\\theta\\sin\\varphi$. Using results from exercise 3.10.28, we can have\n\\[\nx\\pdv{}{y}-y\\pdv{}{x}=r\\sin\\theta\\cos\\varphi(\\sin\\theta\\sin\\varphi\\pdv{}{r}+\\cos\\theta\\sin\\varphi\\frac{1}{r}\\pdv{}{\\theta}+\\frac{\\cos\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi})\\]\n\\[-r\\sin\\theta\\sin\\varphi(\\sin\\theta\\cos\\varphi\\pdv{}{r}+\\cos\\theta\\cos\\varphi\\frac{1}{r}\\pdv{}{\\theta}-\\frac{\\sin\\varphi}{r\\sin\\theta}\\pdv{}{\\varphi})\n=\\pdv{}{\\varphi}\n\\]\nso \n\\[-i\\left(x\\pdv{}{y}-y\\pdv{}{x}\\right)=-i\\pdv{}{\\varphi}\\]\n\n\\paragraph{3.10.30}\n\\[\n\\V{L}=-i(\\V{r}\\times\\del)=-i(\\VE_r r)\\times(\\VE_r\\pdv{}{r}+\\VE_\\theta\\frac{1}{r}\\pdv{}{\\theta}+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi})\n\\]\n\\[\n=\\VE_\\theta i\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi}-\\VE_\\varphi i\\pdv{}{\\theta}\n\\]\n\\[\n=(\\VE_x\\cos\\theta\\cos\\varphi+\\VE_y\\cos\\theta\\sin\\varphi-\\VE_z\\sin\\theta)i\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi}+(\\VE_x\\sin\\varphi-\\VE_y\\cos\\varphi)i\\pdv{}{\\theta}\n\\]\n\\[\n=\\VE_x(i\\sin\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\cos\\varphi\\pdv{}{\\varphi})+\\VE_y(-i\\cos\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\sin\\varphi\\pdv{}{\\varphi})+\\VE_z(-i\\pdv{}{\\varphi})\n\\]\nso\n\\[\nL_x+iL_y=i\\sin\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\cos\\varphi\\pdv{}{\\varphi}+\\cos\\varphi\\pdv{}{\\theta}-\\cot\\theta\\sin\\varphi\\pdv{}{\\varphi}\n\\]\n\\[\n=(\\cos\\varphi+i\\sin\\varphi)(\\pdv{}{\\theta}+i\\cot\\theta\\pdv{}{\\varphi})=e^{i\\varphi}(\\pdv{}{\\theta}+i\\cot\\theta\\pdv{}{\\varphi})\n\\]\n\\[\nL_x-iL_y=i\\sin\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\cos\\varphi\\pdv{}{\\varphi}-\\cos\\varphi\\pdv{}{\\theta}+\\cot\\theta\\sin\\varphi\\pdv{}{\\varphi}\n\\]\n\\[\n=(-\\cos\\varphi+i\\sin\\varphi)(\\pdv{}{\\theta}-i\\cot\\theta\\pdv{}{\\varphi})=-e^{-i\\varphi}(\\pdv{}{\\theta}-i\\cot\\theta\\pdv{}{\\varphi})\n\\]\n\n\\paragraph{3.10.31}\nFrom exercise 3.10.30\n\\[\n\\V{L}=\\VE_xL_x+\\VE_yL_y+\\VE_zL_z\\]\n\\[=\\VE_x(i\\sin\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\cos\\varphi\\pdv{}{\\varphi})+\\VE_y(-i\\cos\\varphi\\pdv{}{\\theta}+i\\cot\\theta\\sin\\varphi\\pdv{}{\\varphi})+\\VE_z(-i\\pdv{}{\\varphi})\n\\]\nso \n\\[\n\\V{L}\\times\\V{L}=\\VE_x(L_yL_z-L_zL_y)+\\VE_y(L_zL_x-L_zL_z)+\\VE_z(L_xL_y-L_yL_x)\n\\]\n\\[\n=\\VE_x(-\\sin\\varphi\\pdv{}{\\theta}-\\cot\\theta\\cos\\varphi\\pdv{}{\\varphi})+\\VE_y(\\cos\\varphi\\pdv{}{\\theta}-\\cot\\theta\\sin\\varphi\\pdv{}{\\varphi})+\\VE_z(\\pdv{}{\\varphi})\n\\]\n\\[\n=\\VE_xiL_x+\\VE_yiL_y+\\VE_ziL_z=i\\V{L}\n\\]\n\n\\paragraph{3.10.32}\n(a)(b) It is the first half of exercise 3.10.30.\n\n(c) The author suggest to do it in Cartesian coordinate, but I think it's easier to do in spherical coordinate, with the help of results from 3.10.22(a).\n\\[\n{\\V{L}}^2=\\V{L}\\cdot\\V{L}=-(\\VE_\\theta\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi}-\\VE_\\varphi\\pdv{}{\\theta})\\cdot(\\VE_\\theta\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi}-\\VE_\\varphi\\pdv{}{\\theta})\n\\]\n\\[\n=-\\left[\\VE_\\theta\\frac{1}{\\sin\\theta}\\cdot\\pdv{}{\\varphi}(\\VE_\\theta\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi}) +\\VE_\\varphi\\cdot\\pdv{}{\\theta}(\\VE_\\varphi\\pdv{}{\\theta})-\\VE_\\theta\\frac{1}{\\sin\\theta}\\cdot\\pdv{}{\\varphi}(\\VE_\\varphi\\pdv{}{\\theta})-\\VE_\\varphi\\cdot\\pdv{}{\\theta}(\\VE_\\theta\\frac{1}{\\sin\\theta}\\pdv{}{\\varphi})\\right]\n\\]\n\\[\n=-\\left[\\frac{1}{\\sin^2\\theta}\\pdv{^2}{\\varphi^2}+\\pdv{^2}{\\theta^2}+\\frac{\\cos\\theta}{\\sin\\theta}\\pdv{}{\\theta} \\right]\n\\]\n\\[\n=-\\frac{1}{\\sin\\theta}\\pdv{}{\\theta}(\\sin\\theta\\pdv{}{\\theta})-\\frac{1}{\\sin^2\\theta}\\pdv{^2}{\\varphi^2}\n\\]\n\\[\n=-r^2\\del^2+\\pdv{}{r}\\left(r^2\\pdv{}{r} \\right)\n\\]\n(We use Eq. 3.158 in the last equality.)\n\n\\paragraph{3.10.33}\n(a) \n\\[\n\\VE_r\\pdv{}{r}-i\\frac{\\V{r}\\times\\V{L}}{r^2}=\\VE_r\\pdv{}{r}-\\frac{\\V{r}\\times(\\V{r}\\times\\del)}{r^2}=\\VE_r\\pdv{}{r}-\\frac{\\V{r}(\\V{r}\\cdot\\del)-(\\V{r}\\cdot\\V{r})\\del}{r^2}=\\VE_r\\pdv{}{r}-\\frac{\\VE_r r(r\\pdv{}{r})-r^2\\del}{r^2}=\\del\n\\]\n\n(b) (\\textit{There is probably a mistake:} $\\del(1+r\\pdv{}{r})$ \\textit{should be} $\\del+\\del(r\\pdv{}{r})$)\n\\smallskip\n\n$r\\pdv{}{r}=\\V{r}\\cdot\\del$ in the spherical coordinate, so the left side of the equation is $\\V{r}\\del^2-\\del-\\del(\\V{r}\\cdot\\del)$.\n\\[\n\\left[\\V{r}\\del^2-\\del-\\del(\\V{r}\\cdot\\del) \\right]_x=x(\\pdv{^2}{x^2}+\\pdv{^2}{y^2}+\\pdv{^2}{z^2})-\\pdv{}{x}-\\pdv{}{x}(x\\pdv{}{x}+y\\pdv{}{y}+z\\pdv{}{z})\n\\]\n\\[\n=-2\\pdv{}{x}+x\\pdv{^2}{y^2}+x\\pdv{^2}{z^2}-y\\pdv{^2}{x\\partial y}-z\\pdv{^2}{x\\partial z}\n\\]\n\\[\n\\left[i\\del\\times\\V{L} \\right]_x=\\left[\\del\\times(\\V{r}\\times\\del) \\right]_x=\\pdv{}{y}(x\\pdv{}{y}-y\\pdv{}{x})-\\pdv{}{z}(z\\pdv{}{x}-x\\pdv{}{z})\n\\]\n\\[\n=-2\\pdv{}{x}+x\\pdv{^2}{y^2}+x\\pdv{^2}{z^2}-y\\pdv{^2}{x\\partial y}-z\\pdv{^2}{x\\partial z}\n\\]\nSo the $x$-components of two side of the equation are equal. It can be verified that so are the $y$- and $z$-components. Therefore,\n\\[\n\\V{r}\\del^2-\\del-\\del(\\V{r}\\cdot\\del)=i\\del\\times\\V{L}\n\\]\n\n\\paragraph{3.10.34}\n\\[\n\\frac{1}{r^2}\\frac{d}{dr}\\left[r^2\\frac{d\\psi}{dr} \\right]=\\frac{1}{r^2}(2r\\frac{d\\psi}{dr}+r^2\\frac{d^2\\psi}{dr^2})=\\frac{d^2\\psi}{dr^2}+\\frac{2}{r}\\frac{d\\psi}{dr}\n\\]\n\\[\n\\frac{1}{r}\\frac{d^2}{dr^2}\\left[r\\psi\\right]=\\frac{1}{r}\\frac{d}{dr}(\\psi+r\\frac{d\\psi}{dr})=\\frac{1}{r}(\\frac{d\\psi}{dr}+\\frac{d\\psi}{dr}+r\\frac{d^2\\psi}{dr^2})=\\frac{d^2\\psi}{dr^2}+\\frac{2}{r}\\frac{d\\psi}{dr}\n\\]\nso all the three form are equaivalant.\n\n\\paragraph{3.10.35}\n(a)\n\\[\n\\del\\times\\V{F}=\\frac{1}{r^2\\sin\\theta}\n\\begin{vmatrix}\n\\VE_r&\\VE_\\theta r&\\VE_\\varphi r\\sin\\theta\\\\\n\\pdv{}{r}&\\pdv{}{\\theta}&\\pdv{}{\\varphi}\\\\\n\\frac{2P\\cos\\theta}{r^3}&\\frac{P}{r^2}\\sin\\theta&0\\\\\n\\end{vmatrix}\n=\\frac{1}{r^2\\sin\\theta}\\left(\\VE_\\varphi r\\sin\\theta(-2\\frac{P}{r^3}\\sin\\theta+\\frac{2P\\sin\\theta}{r^3}) \\right)=0\n\\]\n\n(b) $r=1$ and $\\theta=\\frac{\\pi}{2}$, so $\\V{F}=\\VE_\\theta P$ and $d\\V{r}=\\VE_r dr+\\VE_\\varphi d\\varphi$. \n\\[\n\\oint\\V{F}\\cdot d\\V{r}=(\\VE_\\theta P)\\cdot(\\VE_r dr+\\VE_\\varphi d\\varphi)=0\n\\]\nWe cannot assert whether $\\V{F}$ is conservative or not unless we evaluate every integral over closed loop.\n\n(c) $\\int_a^b\\V{F}\\cdot d\\V{r}=\\psi(a)-\\psi(b)$. Take the path $(r,\\theta,\\varphi)\\rightarrow(\\infty,\\theta,\\varphi)$, and define the potential at infinity $\\psi(\\infty)$ to be zero. Then we have\n\\[\n\\psi(\\V{r})=\\psi(\\V{r})-\\psi(\\infty)=\\int_r^\\infty\\frac{2P\\cos\\theta}{r^3}dr=-\\frac{P\\cos\\theta}{r^2}\\Big|_r^\\infty=\\frac{P\\cos\\theta}{r^2}\n\\]\n\n\\paragraph{3.10.36}\n(a)\n\\[\n\\del\\times\\V{A}=\\frac{1}{r^2\\sin\\theta}\n\\begin{vmatrix}\n\\VE_r&\\VE_\\theta r&\\VE_\\varphi r\\sin\\theta\\\\\n\\pdv{}{r}&\\pdv{}{\\theta}&\\pdv{}{\\varphi}\\\\\n0&0&-\\cos\\theta\n\\end{vmatrix}\n=\\frac{1}{r^2\\sin\\theta}(\\VE_r\\sin\\theta)=\\frac{\\VE_r}{r^2}\n\\]\n\n(b) $r=\\sqrt{x^2+y^2+z^2}$, $\\theta=\\cos^{-1}\\frac{z}{r}$, $\\varphi=\\tan^{-1}\\frac{y}{x}$, $\\VE_\\varphi=-\\VE_x\\sin\\varphi+\\VE_y\\cos\\varphi$. So\n\\[\n\\V{A}=-(-\\VE_x\\frac{y}{\\sqrt{x^2+y^2}}+\\VE_y\\frac{x}{\\sqrt{x^2+y^2}})\\frac{z}{\\sqrt{x^2+y^2}}\\frac{1}{r}=\\VE_x\\frac{yz}{r(x^2+y^2)}-\\VE_y\\frac{xz}{r(x^2+y^2)}\n\\]\n\n(c)\n\\[\n\\del\\times\\V{A}=\\frac{1}{r^2\\sin\\theta}\n\\begin{vmatrix}\n\\VE_r&\\VE_\\theta r&\\VE_\\varphi r\\sin\\theta\\\\\n\\pdv{}{r}&\\pdv{}{\\theta}&\\pdv{}{\\varphi}\\\\\n0&-\\varphi\\sin\\theta&0\n\\end{vmatrix}\n=\\frac{1}{r^2\\sin\\theta}(\\VE_r\\sin\\theta)=\\frac{\\VE_r}{r^2}\n\\]\n\n\\paragraph{3.10.37}\n$\\V{r}=\\VE_r r$, so from exercise 3.10.22 we have $\\pdv{\\V{r}}{r}=\\VE_r$, $\\pdv{\\V{r}}{\\theta}=\\VE_\\theta r$, $\\pdv{\\V{r}}{\\varphi}=\\VE_\\varphi r\\sin\\theta$. So\n\\[\n\\V{E}=-\\del\\psi=-\\left[\\VE_r\\pdv{}{r}(\\frac{\\V{P}\\cdot\\V{r}}{4\\pi\\varepsilon_0r^3})+\\VE_\\theta\\frac{1}{r}\\pdv{}{\\theta}(\\frac{\\V{P}\\cdot\\V{r}}{4\\pi\\varepsilon_0r^3})+\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\pdv{}{\\varphi}(\\frac{\\V{P}\\cdot\\V{r}}{4\\pi\\varepsilon_0r^3}) \\right]\n\\]\n\\[\n=-\\VE_r\\left(\\frac{1}{4\\pi\\varepsilon_0r^3}\\V{P}\\cdot\\pdv{\\V{r}}{r}+\\frac{\\V{P}\\cdot\\V{r}}{4\\pi\\varepsilon_0}\\pdv{}{r}(\\frac{1}{r^3})\\right)-\\VE_\\theta\\frac{1}{r}\\frac{1}{4\\pi\\varepsilon_0r^3}\\V{P}\\cdot\\pdv{\\V{r}}{\\theta}-\\VE_\\varphi\\frac{1}{r\\sin\\theta}\\frac{1}{4\\pi\\varepsilon_0r^3}\\V{P}\\cdot\\pdv{\\V{r}}{\\varphi}\n\\]\n\\[\n=-\\VE_r(-2)\\frac{P_r}{4\\pi\\varepsilon_0r^3}-\\VE_\\theta\\frac{P_\\theta}{4\\pi\\varepsilon_0r^3}-\\VE_\\varphi\\frac{P_\\varphi}{4\\pi\\varepsilon_0r^3}\n\\]\n\\[\n=\\frac{1}{4\\pi\\varepsilon_0r^3}(3\\VE_rP_r-\\VE_rP_r-\\VE_\\theta P_\\theta-\\VE_\\varphi P_\\varphi)\n\\]\n\\[\n=\\frac{3\\hat{\\V{r}}(\\V{P}\\cdot\\hat{\\V{r}})}{4\\pi\\varepsilon_0r^3}\n\\]\nwhere $\\hat{\\V{r}}=\\VE_r$ is the unit vector in the $\\V{r}$ direction.\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "acd4fc0e76602e15c12255b7bb159b995bb4f6b4", "size": 74221, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 03/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 03/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 03/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.1, "max_line_length": 856, "alphanum_fraction": 0.6186793495, "num_tokens": 35640, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.615087862571909, "lm_q1q2_score": 0.4114201296681456}}
{"text": "%\n\\chapter[SI: An improved PNP-NS framework]%\n        {Supplementary information: An improved PNP-NS framework}\n%\n\\label{ch:epnpns_appendix}\n\n\\definecolor{shadecolor}{gray}{0.85}\n\\begin{shaded}\n  \\adapRSC{Willems-2020}\n\\newpage\n\\end{shaded}\n\n\n\\section{Weak forms of the {ePNP-NS} equations}\n%\n\\label{sec:epnpns_appendix:weak_forms}\n%\n\nTo solve partial differential equations with the finite element method, we must be derive their weak form.\nThis is achieved through multiplication of the equation with an arbitrary test function and integration over\ntheir relevant domains and boundaries (\\cref{fig:epnpns_model_boundaries}). The full computational domain of\nour model ($\\Omega$) is subdivided into domains for the pore ($\\Omega_p$), the lipid bilayer ($\\Omega_m$) and\nthe electrolyte reservoir ($\\Omega_w$). The relevant boundaries of these domains are also indicated, i.e. the\nreservoir's exterior edges at the \\cisi{} $\\Gamma_{w,c}$) and \\transi{} $\\Gamma_{w,t}$) sides, the outer edge\nof the lipid bilayer ($\\Gamma_{m}$) and the interface of the fluid with the nanopore and the bilayer\n($\\Gamma_{p+m}$).\n\nThe following paragraphs detail the weak forms of equations that were used in this\n\\cref{ch:epnpns,ch:trapping}.\n\n%\n\\begin{figure*}[t]\n  \\centering\n  %\n  \\includegraphics[scale=1]{epnpns_model_boundaries}\n  %\n  \n  \\caption[Computational domains and boundaries.]%\n  {\\textbf{Computational domains and boundaries.}\n    %\n    The full computational domain ($\\Omega$) of the model is subdivided into various subdomains---comprising\n    the reservoir ($\\Omega_w$), the lipid bilayer ($\\Omega_m$) and the pore ($\\Omega_p$)---and their limiting\n    boundaries---the exterior boundary at the \\cisi{} ($\\Gamma_{w,c}$) \\transi{} and the \\transi{}\n    ($\\Gamma_{w,t}$) sides of the reservoir, the exterior boundary of the membrane ($\\Gamma_m$) and the\n    interior boundary between the reservoir on the one hand, and the pore and membrane on the other\n    ($\\Gamma_{p+m}$).\n    %\n  }\\label{fig:epnpns_model_boundaries}\n\\end{figure*}\n%\n\n\n\\subsection{Poisson equation}\n%\n\nThe global potential distribution is described by the Poisson equation (PE)~\\cite{Lu-2012}\n%\n\\begin{align}\n  \\label{eq:epnpns_appendix:poisson}\n  \\nabla \\cdot \\displacement = -\\left( \\scdpore + \\scdion \\right)\n  \\text{\\quad with \\quad}\n  \\displacement = \\absperm \\relperm \\nabla \\potential\n  \\text{ ,}\n\\end{align}\n%\nwith $\\displacement$ the electrical displacement field, $\\potential$ the electric potential, $\\absperm$ the\nvacuum permittivity (\\SI{8.85419e-12}{\\farad\\per\\meter}), and $\\relperm$ the local relative permittivity\nof the medium. $\\scdpore$ and $\\scdion$ are the fixed (due to the pore) and mobile (due to the ions) charge\ndistributions, respectively.\n\nMultiplication of~\\cref{eq:epnpns_appendix:poisson} with the potential test function $\\psi$ and integration\nover the entire model $\\Omega=\\Omega_w+\\Omega_p+\\Omega_m$ gives\n%\n\\begin{align}\n  \\displaystyle\\int_{\\Omega}\n  \\left[\n    \\nabla \\cdot \\displacement\n  \\right]\n  \\psi \\,d\\Omega\n  ={}&\n  - \\displaystyle\\int_{\\Omega} \\left[ \\scdpore + \\scdion \\right] \\psi \\,d\\Omega \\text{ ,}\n\\end{align}\n%\nwhich, after applying the Gauss divergence theorem, yields the final weak formulation\n%\n\\begin{align}\n  \\displaystyle\\int_{\\Omega}\n  \\left[\n    \\nabla \\psi \\cdot \\displacement\n  \\right]\n  \\,d\\Omega\n  & - \\displaystyle\\int_{\\Gamma_\\text{PE}}\n  \\left[\n    \\psi \\displacement \\cdot \\vec{n}\n  \\right]\n  \\,d\\Gamma_\\text{PE} \\notag \\\\\n  & =\n  \\displaystyle\\int_{\\Omega} \\left[ \\psi \\scdpore \\right] \\,d\\Omega\n  +\n  \\displaystyle\\int_{\\Omega} \\left[ \\psi \\scdion \\right] \\,d\\Omega\n  \\text{ ,}\n\\end{align}\n%\nwith boundaries $\\Gamma_\\text{PE}=\\Gamma_{w,c}+\\Gamma_{w,t}+\\Gamma_m$ and $\\vec{n}$ their normal vector. The\nboundary integrals at $\\Gamma_{w,c}$ and $\\Gamma_{w,t}$ are evaluated using the Dirichlet \\glspl{bc}\n$\\potential=0$ and $\\potential=\\vbias$, respectively. A zero charge \\gls{bc}, $\\vec{n} \\cdot \\displacement =\n0$, is used for the integral at $\\Gamma_{m}$.\n\n\n\n\\subsection{Size-modified Nernst-Planck equation}\n%\n\nThe total ionic flux $\\flux_{i}$ of ion $i$ at steady-state is expressed by the \\gls{smnpe}~\\cite{Lu-2012}\n%\n\\begin{equation}\\label{eq:smnp}\n  \\pd{\\concentration_{i}}{t} = - \\nabla\\cdot\\flux_{i} = - \\nabla \\cdot\n  \\left(\n    \\diffusion_{i}\\nabla\\concentration_{i}\n    + \\chargen_{i}\\mobility_{i}\\concentration_{i}\\nabla\\potential\n    + \\diffusion_{i} \\vec{\\beta_{i}} \\concentration_{i}\n    - \\velocity\\concentration_{i}\n  \\right)\n  \\text{ ,}\n\\end{equation}\n%\nwhere\n%\n\\begin{equation}\\label{eq:steric_vector}\n  \\vec{\\beta_{i}} =\n    \\frac{\\ionsize_{i}^3/\\ionsize_{0}^3 \\dsum_{j} \\avogadro \\ionsize_{j}^3 \\nabla \\concentration_{j}}\n        {1 - \\dsum_{j} \\avogadro \\ionsize_{j}^3 \\concentration_{j}}\n  \\text{ ,}\n\\end{equation}\n%\nand with ion diffusion coefficient $\\diffusion_{i}$, concentration $\\concentration_{i}$, charge number\n$\\chargen_{i}$, mobility $\\mobility_{i}$, electrostatic potential $\\potential$, steric saturation factor\n$\\beta_{i}$ and fluid velocity $\\velocity$. $\\avogadro$ is Avogadro's constant (\\SI{6.022e23}{\\per\\mole}) and\n$\\ionsize_{i}$ and $\\ionsize_{0}$ are the limiting cubic diameters for ions and water, respectively. Using the\nion concentration test function $d_i$, the weak form of \\cref{eq:smnp} becomes\n%\n\\begin{align}\n  % Raw integral\n  \\displaystyle\\int_{\\Omega_w} \\left[ \\pd{\\concentration_{i}}{t} \\right] d_{i} \\,d\\Omega_w =\n  \\displaystyle\\int_{\\Omega_w} \\left[ - \\nabla \\cdot \\flux_{i} \\right] d_{i} \\,d\\Omega_w\n  \\text{, }\n\\end{align}\n%\nwhich can be split into the domain and boundary integrals\n%\n\\begin{align}\n  % Gauss divergence theorem\n  \\displaystyle\\int_{\\Omega_w} \\left[ d_{i} \\pd{\\concentration_{i}}{t} \\right] \\,d\\Omega_w ={}&\n  \\displaystyle\\int_{\\Omega_w} \\left[\\nabla d_{i} \\cdot \\flux_{i} \\right]\\,d\\Omega_w\n  - \\displaystyle\\int_{\\Gamma_\\text{NP}}\n  \\left[ d_{i} \\flux_{i} \\cdot \\vec{n} \\right]\\,d\\Gamma_\\text{NP} \\\\\n  % Fill in flux components\n  ={}&\n  % Domain\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[\n    \\nabla d_{i} \\cdot\n    \\left(\n      \\diffusion_{i}\\nabla\\concentration_{i}\n      + \\chargen_{i}\\mobility_{i}\\concentration_{i}\\nabla\\potential\n      + \\diffusion_{i} \\vec{\\beta_{i}} \\concentration_{i}\n      - \\velocity \\concentration_{i}\n    \\right)\n  \\right]\n  \\,d\\Omega_w \\notag \\\\\n  % Boundary\n  & - \\displaystyle\\int_{\\Gamma_\\text{NP}}\n  \\left[\n    d_{i}\n    \\left(\n      \\diffusion_{i} \\nabla \\concentration_{i}\n      + \\chargen_{i} \\mobility_{i} \\concentration_{i} \\nabla \\potential\n      + \\diffusion_{i} \\vec{\\beta_{i}} \\concentration_{i}\n      - \\velocity \\concentration_{i}\n    \\right)\n    \\cdot \\vec{n}\n  \\right]\n  \\,d\\Gamma_\\text{NP} \\notag\n  \\text{ .}\n\\end{align}\n%\nThe integrals on the boundaries $\\Gamma_\\text{NP} = \\Gamma_{w,c}+\\Gamma_{w,t}+\\Gamma_{p+m}$ are evaluated\nusing the Dirichlet \\gls{bc} $\\concentration_{i} = \\cbulk$ for $\\Gamma_{w,c}$ and $\\Gamma_{w,t}$, and the no\nflux \\gls{bc} $\\vec{n} \\cdot \\flux_{i} = 0$ for $\\Gamma_{p+m}$\n\n\n\\subsection{Variable density and viscosity Navier-Stokes equation}\n%\n\nThe steady-state, laminar fluid flow of an incompressible fluid with a variable density and viscosity is given\nby the system of equations~\\cite{Axelsson-2015}\n%\n\\begin{align}\n  \\label{eq:ns_density_continuity}\n  \\velocity \\cdot \\nabla \\density ={}& 0 \\\\\n  \\label{eq:ns_conservation}\n  \\left( \\velocity \\cdot \\nabla \\right) \\left( \\density\\velocity \\right)\n  + \\nabla \\cdot \\hydrostresstensor ={}& \\volumeforce \\text{\\quad with }\n  \\hydrostresstensor =\n    \\pressure\\identity - \\viscosity\\left[\\nabla\\velocity+\\left(\\nabla\\velocity \\right)^\\mathsf{T}\\right]\n  \\\\\n  \\label{eq:ns_velocity_continuity}\n  \\nabla \\cdot \\left( \\density\\velocity \\right) - \\velocity \\cdot \\nabla \\density ={}& 0\n  \\text { ,}\n\\end{align}\n%\nwith fluid velocity $\\velocity$, density $\\density$, hydrodynamic stress tensor $\\hydrostresstensor$,\nviscosity $\\viscosity$, pressure $\\pressure$ and body force $\\volumeforce$. The pressure test function $q$ is\nused to derive the weak forms of \\cref{eq:ns_density_continuity}\n%\n\\begin{align}\n  % Density continuity\n  \\displaystyle\\int_{\\Omega_w} \\left[ \\velocity \\cdot \\nabla \\density \\right] q \\,d\\Omega_w ={}&\n  \\displaystyle\\int_{\\Omega_w} \\left[ q \\velocity \\cdot \\nabla \\density \\right] \\,d\\Omega_w = 0 \\text{ ,}\n\\end{align}\n%\nand \\cref{eq:ns_velocity_continuity}\n%\n\\begin{align}\n  % Velocity continuity\n  \\displaystyle\\int_{\\Omega_w}\n  &\\left[\\nabla \\cdot \\left( \\density \\velocity \\right) - \\velocity \\cdot \\nabla \\density \\right] q\n  \\,d\\Omega_w \\\\ & =\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[\\nabla \\cdot \\left( \\density \\velocity \\right) \\right] q \\,d\\Omega_w\n  -\n  \\displaystyle\\int_{\\Omega_w} \n  \\left[ q \\velocity \\cdot \\nabla \\density \\right] \\,d\\Omega_w \\notag \\\\\n  & =\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[\\nabla q \\cdot \\left( \\density \\velocity \\right) \\right] \\,d\\Omega_w\n  -\n  \\displaystyle\\int_{\\Gamma_\\text{NS}}\n  \\left[ q \\left( \\density \\velocity \\right) \\cdot \\vec{n} \\right] \\,d\\Gamma_\\text{NS}\n  -\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[ q \\velocity \\cdot \\nabla \\density \\right] \\,d\\Omega_w \\notag\n  \\text{ ,}\n\\end{align}\n%\nwhile for \\cref{eq:ns_conservation} we use the velocity test function $\\vec{v}=\\left[v_r, v_\\phi, v_z\\right]$\n%\n\\begin{align}\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[\n    \\left( \\velocity \\cdot \\nabla \\right) \\left( \\density\\velocity \\right) + \\nabla \\cdot \\hydrostresstensor\n  \\right]\n  \\cdot \\vec{v} \\,d\\Omega_w\n  =\n  \\displaystyle\\int_{\\Omega_w} \\vec{\\force} \\cdot \\vec{v} \\,d\\Omega_w \n\\end{align}\n%\nwhich can be split into the domain and boundary integrals\n%\n\\begin{align}\n  % Conservation\n  \\displaystyle\\int_{\\Omega_w} \\vec{\\force} \\cdot \\vec{v} \\,d\\Omega_w =\n  \\displaystyle\\int_{\\Omega_w} &\n  \\left[\n    \\left( \\velocity \\cdot \\nabla \\right) \\left( \\density\\velocity \\right) \\cdot\\vec{v}\n  \\right] \n  \\,d\\Omega_w \n  -\n  \\displaystyle\\int_{\\Omega_w}\n  \\left[\n  \\hydrostresstensor \\cdot \\nabla\\vec{v}\n  \\right]\n  \\,d\\Omega_w \\notag \\\\\n  & +\n  \\displaystyle\\int_{\\Gamma_\\text{NS}}\n  \\left[\n  \\vec{v} \\cdot\n  \\hydrostresstensor\n  \\cdot\\vec{n}\n  \\right]\n  \\,d\\Gamma_\\text{NS}\n  \\text{ ,}\n\\end{align}\n%\nwith boundaries $\\Gamma_\\text{NS} = \\Gamma_{w,c}+\\Gamma_{w,t}+\\Gamma_{p+m}$. The no-slip Dirichlet \\gls{bc}\n$\\velocity = 0$ is applied to $\\Gamma_{p+m}$, and the no normal stress $\\hydrostresstensor\\vec{n}=0$ is used\nfor $\\Gamma_{w,c}$ and $\\Gamma_{w,t}$.\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Keep the following \\cleardoublepage at the end of this file, \n% otherwise \\includeonly includes empty pages.\n\\cleardoublepage\n\n% vim: tw=70 nocindent expandtab foldmethod=marker foldmarker={{{}{,}{}}}\n", "meta": {"hexsha": "dfc1a56a24af8308b82f404291bf7e0628bc1316", "size": 10627, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/epnpns_appendix/epnpns_appendix.tex", "max_stars_repo_name": "willemsk/phdthesis-text", "max_stars_repo_head_hexsha": "ff3e78e3c1d5a6a9225af3521b294ed9110be85c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-11T17:06:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-11T17:06:02.000Z", "max_issues_repo_path": "chapters/epnpns_appendix/epnpns_appendix.tex", "max_issues_repo_name": "willemsk/phdthesis-text", "max_issues_repo_head_hexsha": "ff3e78e3c1d5a6a9225af3521b294ed9110be85c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/epnpns_appendix/epnpns_appendix.tex", "max_forks_repo_name": "willemsk/phdthesis-text", "max_forks_repo_head_hexsha": "ff3e78e3c1d5a6a9225af3521b294ed9110be85c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6610738255, "max_line_length": 110, "alphanum_fraction": 0.6856121201, "num_tokens": 3577, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.41142011550960433}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%  leesedwards.tex\n%\n%  Lees Edwards Sliding Perioidic Boundary Conditions\n%\n%  Edinburgh Soft Matter and Statistical Physics Group and\n%  Edinburgh Parallel Computing Centre\n%\n%  (c) 2016 The University of Edinburgh\n%\n%  Contributing authors:\n%  Kevin Stratford (kevin@epcc.ed.ac.uk)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\section{Lees Edwards Sliding Periodic Boundary Conditions}\n\n\\subsection{Background}\n\nThe idea of introducing a Galilean transformation in a periodic\ncomputation to model uniform shear was introduced by Lees and\nEdwards in 1972 \\cite{lees-edwards1972}. It was first adapted\nto the lattice Boltzmann picture by Wagner and Pagonabarraga\nin 2000 \\cite{wagner-pagonabarraga2002}. The current\nimplementation follows the description of Adhikari\net~al.\\ \\cite{adhikari-desplat2005}.\n\n\\subsection{Distributions crossing the LE planes}\n\nWith the planes conceptually half-way between lattice sites, the\npropagation moves some of the distributions (namely, those with\n$c_x = \\pm1$) between different sliding blocks. While the collision\nstage is unaffected, action must be taken to adjust these\ndistributions when the LE boundary conditions are active. This\nis done in a two-stage process of reprojection and interpolation\nimplemented between the collision and propagation.\n\n\\subsubsection{Reprojection}\nThe post-collision distributions with\n$c_x = \\pm 1$ at sites adjacent to a boundary are modified to\ntake account of the velocity jump $\\pm u^{LE}_y$ between the sliding\nblocks. In terms of the hydrodynamic moments we have:\n\\begin{eqnarray}\n\\rho &\\rightarrow& \\rho', \\\\\n\\rho u_\\alpha &\\rightarrow& (\\rho u_\\alpha)' \\pm \\rho' u^{LE}_\\alpha, \\\\\nS_{\\alpha\\beta} &\\rightarrow&\nS'_{\\alpha\\beta} \\pm (\\rho u_\\alpha)' u^{LE}_\\beta\n\\pm (\\rho u_\\beta)' u^{LE}_\\alpha + \\rho' u^{LE}_\\alpha u^{LE}_\\beta.\n\\end{eqnarray}\nIf we work with the changes to the moments, then the density is\nunaffected $\\delta\\rho =  0$, the velocity is changed by\n$\\delta u_\\alpha = \\pm u^{LE}_\\alpha$, with an analogous expression for\nthe change in the stress\n\\begin{equation}\n\\delta S_{\\alpha\\beta} =\n\\pm (\\rho u_\\alpha)' u^{LE}_\\beta\n\\pm (\\rho u_\\beta)' u^{LE}_\\alpha + \\rho' u^{LE}_\\alpha u^{LE}_\\beta.\n\\end{equation}\nWe can then work out the change in the distributions by reprojecting\nvia Eq.\\ref{eq:}, i.e.,\n\\begin{equation}\nf_i \\rightarrow f_i' + w_i \\Bigg(\n\\frac{\\rho \\delta u_\\alpha c_{i\\alpha}}{c_s^2} +\n\\frac{\\delta S_{\\alpha\\beta}Q_{i\\alpha\\beta}}{2c_s^4} \\Bigg).\n\\end{equation}\nA similar set of expressions are given for the order parameter\ndistributions in Adhikari \\textit{et al.} \\cite{adhikari-desplat2005}.\n\n\\subsubsection{Interpolation of reprojected distributions}\nAs the sliding blocks are displaced continuously with\n$\\delta y = u_y^{LE}t$, which is not in general a whole number of\nlattice spacings, an interpolation is also required before\npropagation can take place. Consider the situation  from\na stationary frame where the frame above has translated a small\ndistance to the right ($\\delta y < \\Delta y$). In the stationary frame\nwe must interpolate the distributions with $c_x = 1$ to a\n`departure point' from which the propagation will move the\ndistribution exactly to the appropriate lattice site in the moving\nframe. Schematically,\n\\begin{equation}\nf_i'(x, y + \\delta y, z) = \n (1 - \\delta y) f_i^\\star(x, y, z) +\n\\delta y f_i^\\star(x, y + \\Delta y, z),\n\\end{equation}\nwhere $f_i'$ here represents the interpolated value and $f_i^\\star$\nis the reprojected post-collision quantity.\n\nIn the case where the displacement $\\delta y > 1$, the relevant\nlattice sites involved in the interpolation are displaced to the right\nby the integral part of $\\delta y$, while the relative weight given to\nthe two sites involves\nthe fractional part of $\\delta y$. To take account of the periodic\nboundary conditions\nin the $y$-direction, all displacements are modulo $L_y$.\n\n\n\\subsection{Order parameter gradients}\n\nWhen the order parameter gradient is computed at a given point\nnear the LE boundaries, the stencil may extend out of the stationary\nframe. The process of interpolation is slightly different to that\nfor the distributions.\n\nHere, we need to interpolate values in the moving frame to the position\nwhich is seen by the rest frame. If a five-point\nstencil is used to calculate the gradient at the central point\n$(x,y,z)$ in the\nrest frame. An interpolation of the $\\phi$-field of the form\n\\begin{equation}\n\\phi'(x + \\Delta x, y - \\delta y, z) =\n\\delta y \\phi(x + \\Delta x,  y - \\Delta y, z) + \n(1 - \\delta y) \\phi(x + \\Delta x, y, z)\n\\end{equation}\nmust then take place. In practice, the interpolated values are stored\nin the offset buffer. As the gradient calculation requires $\\phi$\nvalues in the halo regions, interpolated values for the buffer halo\nregion are also required.\n\nIn parallel, the interpolation requires data from at most two adjacent\nprocesses in the along-plane $y-$direction as long as the $\\phi$ halo\nregions are up-to-date. The rank of the processes involved is\ndetermined by the displacement $\\delta y$ as a function of time.\n\n\n\\subsection{Velocities and finite-difference fluxes}\n\nFor the finite-difference implementation, the velocity field at\nthe cell boundaries is required. At the planes, this means an\ninterpolation which takes the same form as that for\n$\\phi$ is needed.\n\nIn computing the advective fluxes between cells, we must then\nallow for the presence of the planes. This is done by computing\nseparately the 'east' and 'west' face fluxes in the $x$-direction\n(the flux that crosses the plane). Away from the planes, face-flux\nuniqueness $f_{ijk}^e = f_{i+1jk}^w$ ensures conservation of order\nparameter. However, at the planes, the non-linear combination of\nvelocity field and order parameter field does not in general give\nrise to consistent fluxes. In order to restore conservation, we\nreconcile east and west face fluxes at the plane by taking an\naverage\n\\begin{eqnarray}\nf_{ijk}^{e\\star}&=&{\\textstyle\\frac{1}{2}}(f_{ijk}^e + f_{i+1j'k}^w),\\quad \nf_{i+1j'k}^w  = \\delta y f_{i+1 j-1 k}^w + (1 - \\delta y) f_{i+1jk}^w,\\\\\nf_{i+1 j k}^{w\\star} &=& {\\textstyle\\frac{1}{2}}(f_{ij'k}^e + f_{i+1jk}^w),\\quad\nf_{ij'k}^e = (1 - \\delta y) f_{ijk}^e + \\delta y f_{ij+1k}^e.\n\\end{eqnarray}\nIn this way, we average the east face flux in the rest frame $f_{ijk}^e$\nwith the interpolated value of the west face flux in the moving frame\n$f_{i+1j'k}^w$, and vice-versa. One can then easily show that when\nintegrated over the length of the plane, the average fluxes are\nconsistent, i.e.,\n\\begin{equation}\n\\sum_j (f_{ijk}^{e\\star} - f_{i+1jk}^{w\\star}) = 0 \\quad\\forall k,\n\\end{equation}\nthus ensuring order parameter conservation.\n\nA similar correction is required when computing the force on the fluid\ndirectly via the divergence of the thermodynamic stress\n$F_\\alpha = \\nabla_\\beta P_{\\alpha\\beta}^{th}$. This is implemented\nby computing fluxes of momentum at cell faces in each direction, and\nthen taking the divergence to compute the force. At the planes, an\naveraging procedure is again used to ensure conservation of momentum.\n\n\n\n% End section\n\\vfill\n\\pagebreak\n", "meta": {"hexsha": "b7c7d5fac53494a05da1d2dc21782b4843c0ba1a", "size": 7220, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/leesedwards.tex", "max_stars_repo_name": "qikaifzj/ludwig", "max_stars_repo_head_hexsha": "e16d2d3472772fb3a36c1ee1bde028029c9ecd2d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2018-10-05T11:54:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T06:40:49.000Z", "max_issues_repo_path": "docs/leesedwards.tex", "max_issues_repo_name": "yangyang14641/ludwig", "max_issues_repo_head_hexsha": "25905b523bc67bc8f88bc757503f7e89362042af", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 108, "max_issues_repo_issues_event_min_datetime": "2018-07-26T11:01:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T07:51:10.000Z", "max_forks_repo_path": "docs/leesedwards.tex", "max_forks_repo_name": "yangyang14641/ludwig", "max_forks_repo_head_hexsha": "25905b523bc67bc8f88bc757503f7e89362042af", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2018-12-21T19:05:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T07:51:32.000Z", "avg_line_length": 41.976744186, "max_line_length": 80, "alphanum_fraction": 0.7361495845, "num_tokens": 2003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.41131078533415905}}
{"text": "\\chapter{3D source reconstruction: Imaging approach \\label{Chap:eeg:imaging}}\n\nThis chapter describes an Imaging approach to 3D source reconstruction.\n\n\\section{Introduction\\label{sec:imaginv_intro}}\nThis chapter focuses on the imaging (or distributed) method for implementing EEG/MEG source reconstruction in SPM. This approach results in a spatial projection of sensor data into (3D) brain space and considers brain activity as comprising a very large number of dipolar sources spread over the cortical sheet, with fixed locations and orientations. This renders the observation model linear, the unknown variables being the source amplitudes or power.\n\nGiven epoched and preprocessed data (see chapter \\ref{Chap:eeg:preprocessing}), the evoked and/or induced activity for each dipolar source can be estimated, for a single time-sample or a wider peristimulus time window.\n\nThe obtained reconstructed activity is in 3D voxel space and can be further analyzed using mass-univariate analysis in SPM.\n\nContrary to PET/fMRI data reconstruction, EEG/MEG source reconstruction is a non trivial operation. Often compared to estimating a body shape from its shadow, inferring brain activity from scalp data is mathematically ill-posed and requires prior information such as anatomical, functional or mathematical constraints to isolate a unique and most probable solution~\\cite{Baillet01}.\n\nDistributed linear models have been around for several decades now~\\cite{Dale93} and the proposed pipeline in SPM for an imaging solution is classical and very similar to common approaches in the field. However, at least two aspects are quite original and should be emphasized here:\n\n\\begin{itemize}\n\\item Based on an empirical Bayesian formalism, the inversion is meant to be generic in the sense it can incorporate and estimate the relevance of multiple constraints of varied nature; data-driven relevance estimation being made possible through Bayesian model comparison~\\cite{peb1,cp_empirical_eeg,jm_multiple,karl_induced}.\n\\item The subject's specific anatomy is incorporated in the generative model of the data, in a fashion that eschews individual cortical surface extraction. The individual cortical mesh is obtained automatically from a canonical mesh in MNI space, providing a simple and efficient way of reporting results in stereotactic coordinates.\n\\end{itemize}\n\nThe EEG/MEG imaging pipeline is divided into four consecutive steps which characterize any inverse procedure with an additional step of summarizing the results. In this chapter, we go through each of the steps that need completing when proceeding with a full inverse analysis:\n\n\\begin{enumerate}\n    \\item Source space modeling,\n    \\item Data co-registration,\n    \\item Forward computation,\n    \\item Inverse reconstruction.\n    \\item Summarizing the results of inverse reconstruction as an image.\n\\end{enumerate}\n\nWhereas the first three steps are part of the whole generative model, the inverse reconstruction step consists in Bayesian inversion, and is the only step involving actual EEG/MEG data.\\\\\n\n\\section{Getting started}\n\nEverything which is described hereafter is accessible from the SPM user-interface by choosing the ``EEG'' application, \\texttt{3D Source Reconstruction} button. When you press this button a new window will appear with a GUI that will guide you through the necessary steps to obtain an imaging reconstruction of your data. At each step, the buttons that are not yet relevant for this step will be disabled. When you open the window the only two buttons you can press are \\texttt{Load} which enables you to load a pre-processed SPM MEEG dataset and the \\texttt{Group inversion} button that will be described below. You can load a dataset which is either epoched with single trials for different conditions, averaged with one event related potential (ERP) per condition, or grand-averaged. An important pre-condition for loading a dataset is that it should contain sensors and fiducials. This will be checked when you load a file and loading will fail in case of a problem. You should make sure that for each modality present in the dataset as indicated by channel types (either EEG or MEG) there is a sensor description. If, for instance, you have an MEG dataset with some EEG channels that you don't actually want to use for source reconstruction, change their type to ``\\textit{LFP}'' or ``\\textit{Other}'' before trying to load the dataset (the difference is that \\textit{LFP} channels will stil be filtered and available for artefact detection whereas \\textit{Other} channels won't). MEG datasets converted by SPM from their raw formats will always contain sensor and fiducial descriptions. In the case of EEG for some supported channel setups (such as extended 10-20 or BioSemi) SPM will provide default channel locations and fiducials that you can use for your reconstruction. Sensor and fiducial descriptions can be modified using the \\texttt{Prepare} interface and in this interface you can also verify that these descriptions are sensible by performing a coregistration (see chapter \\ref{Chap:eeg:preprocessing} and also below for more details about coregistration).\n\nWhen you successfully load a dataset you are asked to give a name to the present analysis cell. In SPM it is possible to perform multiple reconstructions of the same dataset with different parameters. The results of these reconstructions will be stored with the dataset if you press the \\texttt{Save} button. They can be loaded and reviewed again using the 3D GUI and also with the SPM EEG \\textsc{Review} tool. From the command line you can access source reconstruction results via the \\texttt{D.inv} field of the \\texttt{meeg} object. This field (if present) is a cell array of structures and does not require methods to access and modify it. Each cell contains the results of a different reconstruction. In the GUI you can navigate between these cells using the buttons in the second row. You can also create, delete and clear cells. The label you input at the beginning will be attached to the cell for you to identify it.\n\n\n\\section{Source space modeling}\n\nAfter entering the label you will see the \\texttt{Template} and \\texttt{MRI} button enabled. The \\texttt{MRI} button will create individual head meshes describing the boundaries of different head compartments based on the subject's structural scan. SPM will ask for the subject's structural image. It might take some time to prepare the model as the image  needs to be segmented. The individual meshes are generated by applying the inverse of the deformation field needed to normalize the individual structural image to MNI template to canonical meshes derived from this template. This method is more robust than deriving the meshes from the structural image directly and can work even when the quality of the individual structural images is low.\n\nPresently we recommend the \\texttt{Template} button for EEG and a head model based on an individual structural scan for MEG. In the absence of individual structural scan combining the template head model with the individual headshape also results in a quite precise head model. The \\texttt{Template} button uses SPM's template head model based on the MNI brain. The corresponding structural image can be found under \\texttt{canonical$\\backslash$single\\_subj\\_T1.nii} in the SPM directory. When you use the template, different things will happen depending on whether your data is EEG or MEG. For EEG, your electrode positions will be transformed to match the template head. So even if your subject's head is quite different from the template, you should be able to get good results. For MEG, the template head will be transformed to match the fiducials and headshape that come with the MEG data. In this case having a headshape measurement can be quite helpful in providing SPM with more data to scale the head correctly. From the user's perspective the two options will look quite similar.\n\nNo matter whether the \\texttt{MRI} or \\texttt{Template} button was used the cortical mesh, which describes the locations of possible sources of EEG and MEG signal, is obtained from a template mesh. In the case of EEG the mesh is used as is, and in the case of MEG it is transformed with the head model. Three cortical mesh sizes are available ''coarse'', ''normal'' and ''fine'' (5124, 8196 and 20484 vertices respectively).  It is advised to work with the ''normal'' mesh. Choose ''coarse'' if your computer has difficulties handling the ''normal'' option. ''Fine'' will only work on 64-bit systems and is probably an overkill.\n\n\n\\section{Coregistration}\n\nIn order for SPM to provide a meaningful interpretation of the results of source reconstruction, it should link the coordinate system in which sensor positions are originally represented to the coordinate system of a structural MRI image (MNI coordinates). In general, to link between two coordinate systems you will need a set of at least 3 points whose coordinates are known in both systems. This is a kind of \\textit{Rosetta stone} that can be used to convert a position of any point from one system to the other. These points are called ``fiducials'' and the process of providing SPM with all the necessary information to create the \\textit{Rosetta stone} for your data is called ``coregistration''.\n\nThere are two possible ways of coregistrating the EEG/MEG data into the structural MRI space.\n\n\\begin{enumerate}\n    \\item A Landmark based coregistration (using fiducials only).\\\\\n    The rigid transformation matrices (Rotation and Translation) are computed such that they match each fiducial in the EEG/MEG space into the corresponding one in sMRI space. The same transformation is then applied to the sensor positions.\n    \\item Surface matching (between some headshape in MEG/EEG space and some sMRI derived scalp tesselation).\\\\\n    For EEG, the sensor locations can be used instead of the headshape. For MEG, the headshape is first coregistrated into sMRI space; the inverse transformation is then applied to the head model and the mesh.\\\\\nSurface matching is performed using an Iterative Closest Point algorithm (ICP). The ICP algorithm~\\cite{Besl_McKay} is an iterative alignment algorithm that works in three phases:\n\\begin{itemize}\n    \\item Establish correspondence between pairs of features in the two structures that are to be aligned based on proximity;\n    \\item Estimate the rigid transformation that best maps the first member of the pair onto the second;\n    \\item Apply that transformation to all features in the first structure. These three steps are then reapplied until convergence is concluded. Although simple, the algorithm works quite effectively when given a good initial estimate.\n\\end{itemize}\n\\end{enumerate}\n\nIn practice what you will need to do after pressing  the \\texttt{Coregister} button is to specify the points in the sMRI image that correspond to your M/EEG fiducials. If you have more fiducials (which may happen for EEG as in principle any electrode can be used as a fiducial), you will be ask at the first step to select the fiducials you want to use. You can select more than 3, but not less. Then for each M/EEG fiducial you selected you will be asked to specify the corresponding position in the sMRI image in one of 3 ways.\n\n\\begin{itemize}\n\\item \\texttt{select} - locations of some points such as the commonly used nasion and preauricular points and also CTF recommended fiducials for MEG (as used at the FIL) are hard-coded in SPM. If your fiducial corresponds to one of these points you can select this option and then select the correct point from a list.\n\\item \\texttt{type} - here you can enter the MRI coordinates in mm for your fiducial ($1 \\times 3$ vector). If your fiducial is not on SPM's hard-coded list, it is advised to carefully find the right point on either the template image or on your subject's own image normalized to the template. You can do it by just opening the image using SPM's Display/images functionality. You can then record the MNI coordinates and use them in all coregistrations you need to do using the ``type'' option.\n\\item \\texttt{click} - here you will be presented with a structural image where you can click on the right point. This option is good for ``quick and dirty'' coregistration or to try out different options.\n\\end{itemize}\n\nYou will also have the option to skip the current fiducial, but remember you can only do it if you eventually specify more than 3 fiducials in total. Otherwise the coregistration will fail.\n\nAfter you specify the fiducials you will be asked whether to use the headshape points if they are available. For EEG it is advised to always answer ``yes''. For MEG if you use a head model based on the subject's sMRI and have precise information about the 3 fiducials (for instance by doing a scan with fiducials marked by vitamin E capsules) using the headshape might actually do more harm than good. In other cases it will probably help, as in EEG.\n\nThe results of coregistration will be presented in SPM's graphics window. It is important to examine the results carefully before proceeding. In the top plot you will see the scalp, the inner skull and the cortical mesh with the sensors and the fiducials. For EEG make sure that the sensors are on the scalp surface. For MEG check that the head positon in relation to the sensors makes sense and the head does not for instance stick outside the sensor array. In the bottom plot the sensor labels will be shown in topographical array. Check that the top labels correspond to anterior sensors, bottom to posterior, left to left and right to right and also that the labels are where you would expect them to be topographically.\n\n\\section{Forward computation (\\textit{forward})}\nThis refers to computing for each of the dipoles on the cortical mesh the effect it would have on the sensors. The result is a $N \\times M$ matrix where N is the number of sensors and M is the number of mesh vertices (that you chose from several options at a previous step). This matrix can be quite big and it is, therefore, not stored in the header, but in a separate \\texttt{*.mat} file which has \\texttt{SPMgainmatrix} in its name and is written in the same directory as the dataset. Each column in this matrix is a so called ``lead field'' corresponding to one mesh vertex.\n\nThe lead fields are computed using the ``forwinv'' toolbox\\footnote{forwinv: \\url{http://fieldtrip.fcdonders.nl/development/forwinv}} developed by Robert Oostenveld, which SPM shares with FieldTrip. This computation is based on Maxwell's equations and makes assumptions about the physical properties of the head. There are different ways to specify these assumptions which are known as ``forward models''.\n\nThe ``forwinv'' toolbox can support different kinds of forward models. When you press \\texttt{Forward Model} button (which should be enabled after successful coregistration), you will have a choice of several head models depending on the modality of your dataset. We presently recommend useing a single shell model for MEG and ``EEG BEM'' for EEG. You can also try other options and compare them using model evidence (see below). The first time you use the EEG BEM option with a new structural image (and also the first time you use the \\texttt{Template} option) a lengthy computation will take place that prepares the BEM model based on the head meshes. The BEM will then be saved in a quite large \\texttt{*.mat} file with ending \\texttt{\\_EEG\\_BEM.mat} in the same directory with the structural image (''canonical'' subdirectory of SPM for the template). When the head model is ready, it will be displayed in the graphics window with the cortical mesh and sensor locations you should verify for the final time that everything fits well together.\n\nThe actual lead field matrix will be computed at the beginning of the next step and saved. This is a time-consuming step and it takes longer for high-resolution meshes. The lead field file will be used for all subsequent inversions if you do not change the coregistration and the forward model.\n\n\n\\section{Inverse reconstruction}\nTo get started press the \\texttt{Invert} button. The first choice you will see is between \\texttt{Imaging}, \\texttt{VB-ECD} and \\texttt{DCM}. For reconstruction based on an empirical Bayesian approach to localize either the evoked response, the evoked power or the induced power, as measured by EEG or MEG press the \\texttt{Imaging} button. The other options are explained in greater detail elsewhere.\n\nIf you have trials belonging to more than one condition in your dataset then the next choice you will have is whether to invert all the conditions together or to choose a subset. It is recommended to invert the conditions together if you are planning to later do a statistical comparison between them. If you have only one condition, or after choosing the conditions, you will get a choice between ``Standard'' and ``Custom'' inversion. If you choose ``Standard'' inversion, SPM will start the computation with default settings. These correspond to the multiple sparse priors (MSP) algorithm \\cite{karl_msp} which is then applied to the whole input data segment.\n\nIf you want to fine-tune the parameters of the inversion, choose the ``Custom'' option. You will then have the possibility to choose between several types of inversion differing by their hyperprior models (IID - equivalent to classical minimum norm, COH - smoothness prior similar to methods such as LORETA) or the MSP method .\n\nYou can then choose the time window that will be available for inversion. Based on our experience, it is recommended to limit the time window to the activity of interest in cases when the amplitude of this activity is low compared to activity at other times. The reason is that if the irrelevant high-amplitude activity is included, the source reconstruction scheme will focus on reducing the error for reconstructing this activity and might ignore the activity of interest. In other cases, when the peak of interest is the strongest peak or is comparable to other peaks in its amplitude, it might be better not to limit the time window to let the algorithm model all the brain sources generating the response and then to focus on the sources of interest using the appropriate contrast (see below). There is also an option to apply a hanning taper to the channel time series in order to downweight the possible baseline noise at the beginning and end of the trial. There is also an option to pre-filter the data. Finally, you can restrict solutions to particular brain areas by loading a \\texttt{*.mat} file with a $K \\times 3$ matrix containing MNI coordinates of the areas of interest. This option may initially seem strange, as it may seem to overly bias the source reconstructions returned. However, in the Bayesian inversion framework you can compare different inversions of the same data using Bayesian model comparison. By limiting the solutions to particular brain areas you greatly simplify your model and if that simplification really captures the sources generating the response, then the restricted model will have much higher model evidence than the unrestricted one. If, however, the sources you suggested cannot account for the data, the restriction will result in a worse model fit and depending on how much worse it is, the unrestricted model might be better in the comparison. So using this option with subsequent model comparison is a way, for instance, to integrate prior knowledge from the literature or from fMRI/PET/DTI into your inversion. It also allows for comparison of alternative prior models.\n\nNote that for model comparison to be valid all the settings that affect the input data, like the time window, conditions used and filtering should be identical.\n\nSPM imaging source reconstruction also supports multi-modal datasets. These are datasets that have both EEG and MEG data from a simultaneous recording. Datasets from the ''Neuromag'' MEG system which has two kinds of MEG sensors are also treated as multimodal. If your dataset is multimodal a dialogue box will appear asking to select the modalities for source reconstruction from a list. If you select more than one modality, multiomodal fusion will be performed. This option based on the paper by Henson et al. \\cite{rnah_fusion} uses a heuristic to rescale the data from different modalities so that they can be used together. \n\nOnce the inversion is completed you will see the time course of the region with maximal activity in the top plot of the graphics window. The bottom plot will show the maximal intensity projection (MIP) at the time of the maximal activation. You will also see the log-evidence value that can be used for model comparison, as explained above. Note that not all the output of the inversion is displayed. The full output consists of time courses for all the sources and conditions for the entire time window. You can view more of the results using the controls in the bottom right corner of the 3D GUI. These allow focusing on a particular time, brain area and condition. One can also display a movie of the evolution of neuronal activity.\n\n\\section{Summarizing the results of inverse reconstruction as an image}\nSPM offers the possibility of writing the results as 3D NIfTI images, so that you can then proceed with GLM-based statistical analysis using Random Field theory. This is similar to the 2nd level analysis in fMRI for making inferences about region and trial-specific effects (at the between subject level).\n\nThis entails summarizing the trial- and subject-specific responses with a single 3-D image in source space. Critically this involves prompting for a time-frequency contrast window to create each contrast image. This is a flexible and generic way of specifying the data feature you want to make an inference about (e.g., gamma activity around 300 ms or average response between 80 and 120 ms). This kind of contrast is specified by pressing the \\texttt{Window} button. You will then be asked about the time window of interest (in ms, peri-stimulus time). It is possible to specify one or more time segments (separated by a semicolon). To specify a single time point repeat the same value twice. The next question is about the frequency band. If you just want to average the source time course leave that at the default, zero. In this case the window will be weighted by a Gaussian. In the case of a single time point this will be a Gaussian with 8 ms full width half maximum (FWHM). If you specify a particular frequency or a frequency band, then a series of Morlet wavelet projectors will be generated summarizing the energy in the time window and band of interest.\n\nThere is a difference between specifying a frequency band of interest as zero, as opposed to specifying a wide band that covers the whole frequency range of your data. In the former case the time course of each dipole will be averaged, weighted by a gaussian. Therefore, if within your time window this time course changes polarity, the activity can average out and in an ideal case even a strong response can produce a value of zero. In the latter case the power is integrated over the whole spectrum ignoring phase, and this would be equivalent to computing the sum of squared amplitudes in the time domain.\n\nFinally, if the data file is epoched rather than averaged, you will have a choice between ``evoked'', ``induced'' and ``trials''. If you have multiple trials for certain conditions, the projectors generated at the previous step can either be applied to each trial and the results averaged (induced) or applied to the averaged trials (evoked). Thus it is possible to perform localization of induced activity that has no phase-locking to the stimulus. It is also possible to focus on frequency content of the ERP using the ``evoked'' option. Clearly the results will not be the same. The projectors you specified (bottom plot) and the resulting MIP (top plot) will be displayed when the operation is completed. ``trials'' option makes it possible to export an image per trial which might be useful for doing within-subject statistics. The images are exported as 4D-NIfTI with one file per condition including all the trials for that condition.\n\nThe \\texttt{Image} button is used to write out the contrast results. It is possible to export them as either values on a mesh (GIfTI) or volumetric 3D images (NIfTI). Both formats are supported by SPM statistical machinery. When generating an image per trial the images are exported as 4D-NIfTI with one file per condition including all the trials for that condition. The values of the exported images are normalized to reduce between-subject variance. Therefore, for best results it is recommended to export images for all the time windows and conditions that will be included in the same statistical analysis in one step. Note that the images exported from the source reconstruction are a little peculiar because of smoothing from a 2D cortical sheet into 3D volume. SPM statistical machinery has been optimized to deal with these peculiarities and get sensible results. If you try to analyze the images with older versions of SPM or with a different software package you might get different (less focal) results.\n\n\\section{Rendering interface}\nBy pressing the \\texttt{Render} button you can open a new GUI window which will show you a rendering of the inversion results on the brain surface. You can rotate the brain, focus on different time points, run a movie and compare the predicted and observed scalp topographies and time series. A useful option is ``virtual electrode'' which allows you to extract the time course from any point on the mesh and the MIP at the time of maximal activation at this point. Just press the button and click anywhere in the brain.\\\\\nAn additional tool for reviewing the results is available in the SPM M/EEG \\textsc{Review} function.\n\n\\section{Group inversion}\nA problem encountered with MSP inversion is that sometimes it is ``too good'', producing solutions that were so focal in each subject that the spatial overlap between the activated areas across subjects was not sufficient to yield a significant result in a between-subjects contrast. This could be improved by smoothing, but smoothing compromises the spatial resolution and thus subverts the main advantage of using an inversion method that can produce focal solutions.\n\nTo circumvent this problem we proposed a modification of the MSP method \\cite{vl_group} that effectively restricts the activated sources to be the same in all subjects with only the degree of activation allowed to vary. We showed that this modification makes it possible to obtain significance levels close to those of non-focal methods such as minimum norm while preserving accurate spatial localization.\n\nThe group inversion can yield much better results than individual inversions because it introduces an additional constraint for the ill-posed inverse problem, namely that the responses in all subjects should be explained by the same set of sources. Thus it should be your method of choice when analyzing an entire study with subsequent GLM analysis of the images.\n\nGroup inversion works very similarly to what was described above. You can start it by pressing the ``Group inversion'' button right after opening the 3D GUI. You will be asked to specify a list of M/EEG data sets to invert together. Then the routine will ask you to perform coregistration for each of the files and specify all the inversion parameters in advance. It is also possible to specify the contrast parameters in advance. Then the inversion will proceed by computing the inverse solution for all the files and will write out the output images. The results for each subject will also be saved in the header of the corresponding input file. It is possible to load this file into the 3D GUI after the inversion and explore the results as described above.\n\n\\section{Batching source reconstruction}\nThere is a possibility to run imaging source reconstruction using the SPM batch tool. It can be accessed by pressing the ``Batch'' button in the main SPM window and then going to ``M/EEG source reconstruction'' in the ``SPM'' under ``M/EEG''. There are separate tools there for building head models, computing the inverse solution and computing contrasts and generating images. This makes it possible for instance to generate images for several different contrasts from the same inversion. All the three tools support multiple datasets as inputs. In the case of the inversion tool group inversion will be done for multiple datasets.\n\n\\section{Appendix: Data structure}\nThe \\matlab\\ object describing a given EEG/MEG dataset in SPM is denoted as \\textit{D}.\nWithin that structure, each new inverse analysis will be described by a new cell of sub-structure\nfield \\textit{D.inv} and will be made of the following fields:\n\n\\begin{itemize}\n    \\item \\texttt{method}: character string indicating the method, either ``ECD'' or ``Imaging'' in present case;\n    \\item \\texttt{mesh}: sub-structure with relevant variables and filenames for source space and head modeling;\n    \\item \\texttt{datareg}: sub-structure with relevant variables and filenames for EEG/MEG data registration into MRI space;\n    \\item \\texttt{forward}: sub-structure with relevant variables and filenames for forward computation;\n    \\item \\texttt{inverse}: sub-structure with relevant variable, filenames as well as results files;\n    \\item \\texttt{comment}: character string provided by the user to characterize the present analysis;\n    \\item \\texttt{date}: date of the last modification made to this analysis.\n    \\item \\texttt{gainmat}: name of the gain matrix file.\n\\end{itemize}\n", "meta": {"hexsha": "c822967d24936aa6ff8726a6057bbd87e23edc1a", "size": 29780, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thirdparty/spm12/man/meeg/eeg_imaging.tex", "max_stars_repo_name": "spunt/bspm", "max_stars_repo_head_hexsha": "4a1b6510cb32db6e2e4dff57bb81e6ece993f9db", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2015-03-26T21:29:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:18:42.000Z", "max_issues_repo_path": "software/spm12/man/meeg/eeg_imaging.tex", "max_issues_repo_name": "wiktorolszowy/diffusion_fMRI", "max_issues_repo_head_hexsha": "2028515a244fcec88c072d4a66b97bbc57dc15c0", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-07-06T21:37:06.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-06T23:53:13.000Z", "max_forks_repo_path": "software/spm12/man/meeg/eeg_imaging.tex", "max_forks_repo_name": "wiktorolszowy/diffusion_fMRI", "max_forks_repo_head_hexsha": "2028515a244fcec88c072d4a66b97bbc57dc15c0", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-26T21:30:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T06:47:37.000Z", "avg_line_length": 199.8657718121, "max_line_length": 2122, "alphanum_fraction": 0.8025520484, "num_tokens": 6279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.4112872797488412}}
{"text": "\\documentclass[12pt, preprint]{aastex}\n\\usepackage{bm, graphicx, subfigure, amsmath, morefloats}\n\\bibliographystyle{apj}\n\n% naming macros\n\\newcommand{\\tc}{\\textsl{The~Cannon}}\n\\newcommand{\\apogee}{\\textsl{APOGEE}}\n\n% math and symbol macros\n\\newcommand{\\set}[1]{\\bm{#1}}\n\\newcommand{\\starlabel}{\\ell}\n\\newcommand{\\starlabelvec}{\\set{\\starlabel}}\n\\newcommand{\\mean}[1]{\\overline{#1}}\n\\newcommand{\\given}{\\,|\\,}\n\\newcommand{\\teff}{\\mbox{$\\rm T_{eff}$}}\n\\newcommand{\\kms}{\\mbox{$\\rm kms^{-1}$}}\n\\newcommand{\\feh}{\\mbox{$\\rm [Fe/H]$}}\n\\newcommand{\\xfe}{\\mbox{$\\rm [X/Fe]$}}\n\\newcommand{\\alphafe}{\\mbox{$\\rm [\\alpha/Fe]$}}\n\\newcommand{\\mh}{\\mbox{$\\rm [M/H]$}}\n\\newcommand{\\logg}{\\mbox{$\\rm \\log g$}}\n\\newcommand{\\noise}{\\sigma_{n\\lambda}}\n\\newcommand{\\scatter}{s_{\\lambda}}\n\\newcommand{\\pix}{\\mathrm{pix}}\n\\newcommand{\\rfn}{\\mathrm{ref}}\n\n\\begin{document}\n\n\\title{\\tc\\ in the Gaussian Process Framework: \\\\ Data-driven spectral\nmodel determination}\n\\author{A.Y.Q.~Ho\\altaffilmark{1},\nD.~Foreman-Mackey\\altaffilmark{2},\nM.~Ness\\altaffilmark{1},\nDavid~W.~Hogg\\altaffilmark{1,2,3}, \nH.-W.~Rix\\altaffilmark{1}\n}\n\\altaffiltext{1}{Max-Planck-Institut f\\\"ur Astronomie, K\\\"onigstuhl 17, D-69117 Heidelberg, Germany}\n\\altaffiltext{2}{Center for Cosmology and Particle Physics, Department of Phyics,\nNew York University, 4 Washington Pl., room 424, New York, NY, 10003, USA}\n\\altaffiltext{3}{Center for Data Science, New York University, 726 Broadway, 7th Floor, New York, NY 10003, USA}\n\n\\email{annaho@mpia.de}\n\n\\begin{abstract}\n\n\\tc\\ is a data-driven method for determining stellar labels (parameters and \nabundances) from stellar spectra in the context of vast spectroscopic surveys. \nFor a ``training set'' of stars with known labels, \\tc\\ fits for a spectral \nmodel that describes how the flux in each pixel of the spectrum depends on the \nlabels of the star. The model is then applied to the rest of the stars in the \nsurvey to solve for their labels. \nIn the first iteration of \\tc\\ \\ref{ness2015} the functional form of the \nspectral model was determined through empirical experimentation and held fixed\nacross the spectrum: only the coefficients varied between pixels. \nThis constituted a severe limitation: the functional form of the model was too \nflexible for some pixels \nnot flexible enough for others. In this paper, we cast \\tc\\ into the framework\nof a Gaussian Process. In this framework, instead of optimizing for \ncoefficients of a fixed spectral model at each pixel, we optimize for the\nfunctional form of the spectral model at each pixel. \n\n\\end{abstract}\n\n\\keywords{\nmethods: data analysis\n---\nmethods: statistical\n---\nstars:abundances\n---\nstars: fundamental parameters\n---\nsurveys\n---\ntechniques: spectroscopic}\n\n\\section{Introduction}\n\n\\tc\\ is a data-driven method for determining stellar labels (parameters and \nabundances) from stellar spectra in the context of vast spectroscopic surveys. \nFor a ``training set'' of stars with known labels, \\tc\\ fits for a spectral \nmodel that describes how the flux in each pixel of the spectrum depends on the \nlabels of the star. The model is then applied to the rest of the stars in the \nsurvey to solve for their labels. \nIn the first iteration of \\tc\\ \\ref{ness2015} the functional form of the \nspectral model was determined through empirical experimentation and held fixed\nacross the spectrum: only the coefficients varied between pixels. \n\nMore specifically, we took the \nspectral model to be characterized by a coefficient vector $\\theta_\\lambda$ \nthat allowed us to predict the flux at every pixel $f_{n \\lambda}$ for a \ngiven label vector $\\textbf{l}_n$:\n\n\\begin{equation}\n  f_{n\\lambda} = g(\\starlabelvec_n | \\set{\\theta}_\\lambda) + \\mbox{noise} \n\\end{equation}\n\n\\begin{equation}\n  f_{n\\lambda} = \\set{\\theta}_\\lambda^T \\cdot \\starlabelvec_n + \\mbox{noise}  \n\\end{equation}\n\nIn this case, we optimized for coefficients of a model that was quadratic in the\nlabels, such that the label vector was,\n\n\\begin{equation}\n  \\starlabelvec_n \\equiv \n  [1, \\teff, \\logg, \\feh, \\teff^2, \\teff\\cdot\\logg, \\teff\\cdot\\feh, \\logg^2, \\logg\\cdot\\feh, \\feh^2]\n\\end{equation}\n\nA major limitation of this existing framework is that the model is inflexible:\nalthough a set of coefficients is uniquely determined for each pixel, \nthe functional form of the model itself is held fixed across pixels. \nThis, however, is not physically motivated. Indeed, the\npolynomial family is probably not the best family of functions to be \nexploring, since they extrapolate badly (edge effects) and require explicit, \nqualitative choices about order and cross-terms. In that paper, we mentioned \nthe hope to eventually move to a non-parametric form for the functions, \nsuch that model complexity would be controlled by continuous parameters\nand at each pixel the functional form would only be complex as warranted\nby the training data.\n\nTo give a more specific example, different pixels should have \ndifferent functional dependencies on labels: for example, one might expect a \ncontinuum pixel to be linear, while a pixel in a magnesium line should show \npolynomial (?) dependence on temperature. In particular, absorption features,\nparticularly strong lines, are known to vary non-linearly as a function of \nstellar labels. And, indeed, in the paper, systematic discrepencies were found. \n\nExtending \\emph{The Cannon} to a Gaussian process framework is one way of \nallowing the training data to determine the functional form and complexity\nof the model at each pixel. We now provide a brief introduction to Gaussian\nProcesses: an excellent, more detailed review can be found here and here. \n\nA Gaussian Process is a probability distribution over functions. More\nprecisely, it is a collection of random variables, any finite number of which\nhave a joint Gaussian distribution. \nIt is an example of a stochastic process: the generalization\nof a probability distribution (which describes a finite-dimensional random\nvariable) to function space. Using some set of finite training data, our goal\nis to solve for a function that can make a predictions for all possible\ninput values: this is regression, input-output mapping (learning) for \ncontinuous inputs. This is a problem of induction: moving from points you\nknow to points you don't know. It basically entails doing inference in \nfunction space. \n\nIn order to fit for the function, you need to begin by making some assumptions \nabout the characteristics of the \nunderlying function. This entails assigning a prior probability to every \npossible function, essentially specifying a probability distribution over\nthe functions themselves, by specifying a mean and covariance function. \nThis is a prior distribution over the functions.\nIt turns out that you only need to deal with\nsome of the points in a function governed by a Gaussian distribution in order\nto get the answer that you would if you had access to all of the points. \nThis computational tractability is a big bonus of Gaussian processes. \nAnd at the end you get \na mean prediction and a posterior distribution.\n\nThe basic structure of \\tc\\ remains unchanged: we still have a training step\nin which we use a set of training objects to fit for a model, and then a test\nstep in which we apply that model to solve for labels of the test objects. \nBelow we walk through what it \nmeans to cast each step into the Gaussian Process framework.\n\n\\section{\\emph{The Cannon} Training Step in the Gaussian Process Framework}\n\nFor each pixel, we optimize for a set of five hyperparameters that fully \ndescribe the covariance matrix that characterizes the Gaussian process model.\n\nWe begin by selecting the functional form of the covariance between any \ntwo outputs (in this case, between the flux value at a given pixel for any\ntwo objects, across\nlabel space). We choose a squared exponential covariance function. \n\nFor a set of $N_{ref}$ reference objects $n_1, n_2, \\dots, n_{N_{ref}}$, \neach has a continuum-normalized\nflux measurement $f_{n \\lambda}$ at wavelength $\\lambda$ and a set of  \n$K$ training labels $l_{nk}$ \nSay we have a set of $N_{ref}$ training objects, each with $k$ training labels \n$l = l_{nk_1}, l_{nk_2}, \\cdots, l_{nk_K}$.\n\nAt any given pixel, the covariance between any pair of flux values for two\nstars $n_i$ and $n_j$ with label sets $l_{n_i k}$ and $l_{n_j k}$, \n$ f_{n_i \\lambda}$ and $f_{n_j \\lambda}$ across label space is: \n\n\\begin{equation}\n  Cov(f_{n_i \\lambda}, f_{n_j \\lambda}) = \n  a_\\lambda^2 \\exp(-\\frac{1}{2} \n  \\sum_{k=1}^K \\frac{(l_{n_i k}-l_{n_j k})^2}{\\tau_{\\lambda k}^2}) +\n  \\delta_{ij} s_\\lambda^2\n\\end{equation}\n\nMore compactly, the covariance matrix $\\Sigma$ can be written as follows:\n\n\\begin{equation}\n  \\Sigma_{ij} = \n  a_\\lambda^2 \\exp(-\\frac{1}{2} \n  \\sum_{k=1}^K \\frac{(l_{i k}-l_{j k})^2}{\\tau_{\\lambda k}^2}) +\n  \\delta_{ij} s_\\lambda^2\n\\end{equation}\n\nNote a few things. First, the covariance between outputs is a function of the \ninput labels. Second, this covariance approaches unity as the points become \ncloser together in label space and becomes smaller as the distance between \nthe points increases. Thus the variable $\\tau$ can informally be thought of \nas a length scale over which flux values become more ``different`` or contain \nless information about each other.\n\nIn this equation, the pixel-dependent values $a, \\tau_k, $ and $s$ constitute\na set of hyperparameters $\\theta$ that determine a Gaussian process model. Thus, \neach pixel has its own Gaussian process model characterized by hyperparameters,\nthe number of which depends on the number of labels. For three labels, then,\nthe set of hyperparameters at a given pixel would look like this:\n\n\\begin{equation}\n  \\theta_\\lambda = a_\\lambda, \n  \\tau_{\\lambda 0}, \\tau_{\\lambda 1}, \\tau_{\\lambda 2}, s_\\lambda\n\\end{equation}\n\nIn a nutshell, we optimize by maximizing the log marginal likelihood for a \nsingle pixel across all objects. The mathematics of how to do so is laid out \nbelow\\ldots\n\nThe marginal likelihood $p(g|X)$ is the integral of the likelihood times the\nprior. It refers to the marginalization over the function values g.  \n\n\\begin{equation}\n  p(f|X) = \\int p(f|g,X) p(g|X)dg\n  \\label{}\n\\end{equation}\n\nFor the special case of a Gaussian process model, we have that \n\n\\begin{equation}\n  \\ln{p}(\\textbf{f} | \\theta, X) = \n  -\\frac{1}{2} \\textbf{f}^{T}\\,\\Sigma^{-1}\\,\\textbf{f}-\\frac{1}{2}\\ln{|\\Sigma|}\n\\end{equation}\n\nIn practice, inverting the covariance matrix is computationally challenging.\nIt is faster and numerically more stable to avoid directly inverting the \nmatrix: here, we use Cholesky decomposition and the associated routines\nin the scipy linear algebra package. \n\nIn Cholesky decomposition, we decompose the covariance matrix as follows:\n\n\\begin{equation}\n  \\Sigma = L^T L  \n  \\label{}\n\\end{equation}\n\nwhere L is called the Cholesky factor. We also introduce $\\alpha$, \n\n\\begin{equation}\n  \\Sigma \\, \\alpha = \\textbf{f}\n  \\label{}\n\\end{equation}\n\nsuch that the expression for the log likelihood can be written as follows:\n\n\\begin{equation}\n  \\ln{p}(\\textbf{f} | \\theta, X) = \n  -\\frac{1}{2} \\textbf{f}^T \\alpha - \\sum_i \\ln{L_{ii}}\n\\end{equation}\n\nWe use the scipy optimize routine to find, for each pixel, the set of\nhyperparameters (in this case, five) that maximize the log likelihood. \nIn other words, we're looking for the hyperparameters that make it most likely\nthat this set of flux value and training label values would be measured.\n\nOnce we have those hyperparameters, the training step is over: we now have\na Gaussian Process model at each pixel of the spectrum. \n\n\n\\section{\\emph{The Cannon} Test Step in the Gaussian Process Framework}\n\nWhile the training step took place across pixel space, optimizing for \nhyperparameters across objects at each pixel independently, the test step \nwill take place across object space, optimizing for labels across pixels at \neach object independently.\n\nNow, we have a set of $(N_{ref}, K)$ hyperparameters where $N_{ref}$ is \nthe number of training objects and $K$ is the number of training labels \ndescribing each object.\n\n\nIn the end, we get a mean function and a variance function. \n\nWe have a vector of covariances between the test point and the training \npoints. Denote this $\\Sigma(X,X_*)$. Then the mean function is\n\n\\begin{equation}\n  \\bar{g}_* = \\Sigma(X_*, X)\\,\\Sigma(X, X)^{-1}\\,f\n  \\label{}\n\\end{equation}\n\nwhich, in the $\\alpha$ and $L$ framework we adopt for computational\ntractability, is\n\n\\begin{equation}\n  \\bar{g}_* = \\Sigma(X, X_*)\\,\\alpha\n  \\label{}\n\\end{equation}\n\nand the covariance array corresponding to the Gaussian process model is\n\n\\begin{equation}\n  \\sigma_* = \\Sigma(X_*, X_*)-\\Sigma(X_*,X)\\,\\Sigma(X,X)^{-1}\\,K(X,X_*)\n  \\label{}\n\\end{equation}\n\nFor some reason, that first term is actually just \n$\\Sigma(X_*, X_*) = a^2 + \\sigma$ where $\\sigma$ here is the uncertainties\nin the fluxes in the data. \n\n\\begin{equation}\n  \\sigma_* = \\sigma_f + a^2 - \\Sigma(X_*,X) (L^T)^{-1}L^{-1} K_*[0]\n  \\label{}\n\\end{equation}\n\nNow that we have both the mean and variance function, \nwe can write a test log likelihood function that optimizes over the full pixel\nand 3D label space in order to determine, for a particular object, which \ncombination of labels is most likely given the measured flux at that pixel.\n\n\\begin{equation}\n  \\ln{p(f|l)} = -\\frac{1}{2} \\frac{(f-\\bar{g}_*)^2}{\\sigma_*^2} - \\ln{\\sigma_*^2}\n  \\label{}\n\\end{equation}\n\nWe perform the optimization for each object individually, across all pixels,\nusing the scipy.optimize minimize routine. \n\n\\section{Results: Comparison with Quadratic Model}\n\n\\section{Discussion}\n\nOne challenge is the computational time. Much slower than simply choosing \na quadratic model. The training steps scales \nwith the cube of the number of training objects. In this case, with 544 \ntraining objects, it took 20 \nhours on a 4-core processor, with the operations running in parallel (all \npixels are independent.) \n\nLabels for the test objects can also be \nevaluated in parallel, and the test step took X hours on a 4-core processor. \nThe matrix inversion is the time-consuming step, but as you can see from this\nequation, this step only depends on the training set: thus, we can evalute\nthis for each pixel only once, before performing the optimization for each \npixel. \n\n\\section{Acknowledgements}\n\nAYQH was partially supported by a Fulbright grant through the German-American\nFulbright Commission.\n\nThe research has received funding from the European Research Council under the\nEuropean Union's Seventh Framework Programme (FP 7) ERC Grant Agreement n.\n[321035].\n\n\\begin{thebibliography}{24}\n\n  \\bibitem[{ {Ness}{ et~al.}(2015){Ness}, {Hogg}, {Rix}, {Ho}, \\&\n    {Zasowski}}]{ness2015}\n    {Ness}, M., {Hogg}, D.W., {Rix}, H.-W., {Ho}, A.Y.Q., \\& {Zasowski}, G. 2015\n\n  \\bibitem[{ {Rasmussen}{et~al.}(2006){Rasmussen}, \\& {Williams}}]{rasmussen2006}\n    {Rasmussen}, C.E., {Williams}, C.K.I. 2006\n\n\\end{thebibliography}\n\n\\end{document}\n\n\n", "meta": {"hexsha": "1f404b55ae63676564e2f856d160f118c9614bc9", "size": 14922, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/gp_cannon.tex", "max_stars_repo_name": "annayqho/gp-cannon", "max_stars_repo_head_hexsha": "66a2110c087f0345482cb495b7d66455dc5f2fe4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documents/gp_cannon.tex", "max_issues_repo_name": "annayqho/gp-cannon", "max_issues_repo_head_hexsha": "66a2110c087f0345482cb495b7d66455dc5f2fe4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documents/gp_cannon.tex", "max_forks_repo_name": "annayqho/gp-cannon", "max_forks_repo_head_hexsha": "66a2110c087f0345482cb495b7d66455dc5f2fe4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8983957219, "max_line_length": 112, "alphanum_fraction": 0.7490282804, "num_tokens": 4026, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4112872729274781}}
{"text": "\\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%\r\n\\usepackage[all,cmtip]{xy}\r\n\\usepackage{lscape}\r\n\\usepackage{amsfonts}\r\n\\usepackage{amssymb}\r\n\\usepackage{amsmath}\r\n\\usepackage{amsthm}\r\n\\usepackage{hyperref}\r\n\\usepackage{comment}\r\n%TCIDATA{OutputFilter=latex2.dll}\r\n%TCIDATA{Version=5.50.0.2960}\r\n%TCIDATA{LastRevised=Monday, November 20, 2017 19:13:24}\r\n%TCIDATA{SuppressPackageManagement}\r\n%TCIDATA{<META NAME=\"GraphicsSave\" CONTENT=\"32\">}\r\n%TCIDATA{<META NAME=\"SaveForMode\" CONTENT=\"1\">}\r\n%TCIDATA{BibliographyScheme=Manual}\r\n%BeginMSIPreambleData\r\n\\providecommand{\\U}[1]{\\protect\\rule{.1in}{.1in}}\r\n%EndMSIPreambleData\r\n\\iffalse\r\n\\newenvironment{proof}[1][Proof]{\\noindent\\textbf{#1.} }{\\ \\rule{0.5em}{0.5em}}\r\n\\fi\r\n\\voffset=-0.5cm\r\n\\hoffset=-1.0cm\r\n\\setlength\\textheight{24cm}\r\n\\setlength\\textwidth{15.5cm}\r\n\\newenvironment{verlong}{}{}\r\n\\newenvironment{vershort}{}{}\r\n\\newenvironment{noncompile}{}{}\r\n\\excludecomment{verlong}\r\n\\includecomment{vershort}\r\n\\excludecomment{noncompile}\r\n\\begin{document}\r\n\r\n\\title{\\fbox{$\\lambda$\\textbf{-rings: Definitions and basic properties}}}\r\n\\author{Darij Grinberg}\r\n\\date{Version 0.0.21, last revised\r\n%TCIMACRO{\\TeXButton{today}{\\today}}%\r\n%BeginExpansion\r\n\\today\r\n%EndExpansion\r\n}\r\n\\maketitle\r\n\\tableofcontents\r\n\r\n%\\begin{titlepage}\r\n%$\\ $\\\\[20mm]\r\n%\\begin{center}\r\n%\\textbf{\\LARGE $\\lambda$\\textbf{-rings: Definitions and basic properties}}\\\\[15mm]\r\n%\\Large\r\n%\\textit{Darij Grinberg}\r\n%\\\\[8mm]\r\n%Version ***\r\n%\\end{center}\r\n%\\end{titlepage}\r\n%\\newpage\r\n%$\\ \\ \\ $\r\n%\\newpage\r\n\r\n\r\n\\bigskip\r\n\r\nThis is a \\textbf{BETA VERSION} and has never been systematically proofread.\r\n\\textbf{Please notify me of any mistakes, typos and hard-to-understand\r\narguments you find!\\footnote{my email address is \\texttt{A@B.com}, where\r\n\\texttt{A=darijgrinberg} and \\texttt{B=gmail}}}\r\n\r\nThanks to Martin Brandenburg for pointing out several flaws.\r\n\r\nAt the moment, section 1 is missing a proof (namely, that the representation\r\nring is a \\textit{special} $\\lambda$-ring; I actually don't know this proof).\r\n\r\nMost exercises have solutions or at least hints given at the end of this text;\r\nhowever, some do not.\r\n\r\n\\bigskip\r\n\r\n\\subsection*{What is this?}\r\n\r\nThese notes try to cover some of the most important properties of $\\lambda\r\n$-rings with proofs.\r\n\r\nThey were originally meant to accompany a talk at an undergraduate seminar,\r\nbut quickly grew out of proportion to what could fit into a talk. Still they\r\nlack in anything really deep. At the moment, most of what is written here,\r\nexcept for the Todd homomorphism section, is also in Knutson's book\r\n\\cite{Knut73}, albeit sometimes with different proofs. Part of the plan was to\r\nadd some results from the Fulton/Lang book \\cite{FulLan85} with better proofs,\r\nbut this is not currently my short-term objective, given that I don't\r\nunderstand much of \\cite{FulLan85} to begin with. Most of the notes were\r\nwritten independently of Yau's 2010 text \\cite{Yau10}, but inevitably\r\nintersect with it.\r\n\r\nI do not introduce, nor use, the $\\lambda$-ring of symmetric functions (see\r\n\\cite{Knut73} and \\cite[\\S 9, \\S 16]{Hazewi08b} for it). My avoidance of\r\nsymmetric functions has no good reason\\footnote{Actually, the reason is that I\r\nhave started writing these notes before I understood symmetric functions\r\nwell.}; unfortunately, it makes part of the notes (particularly, everything\r\nrelated to the $\\lambda$-verification principle) unnecessarily unwieldy. This\r\nis one of the things I would have done differently if I were to rewrite these\r\nnotes from scratch.\r\n\r\n\\section*{0. Notation and conventions}\r\n\r\nSome notations that we will use later on:\r\n\r\n\\begin{itemize}\r\n\\item In the following, $\\mathbb{N}$ will denote the set $\\left\\{\r\n0,1,2,...\\right\\}  $. The elements of this set $\\mathbb{N}$ will be called the\r\n\\textit{natural numbers}.\r\n\r\n\\item When we say ``ring'', we will always mean ``commutative ring with\r\nunity''. A ``ring homomorphism'' is always supposed to send $1$ to $1$. When\r\nwe say ``$R$-algebra'' (with $R$ a ring), we will always mean ``commutative\r\n$R$-algebra with unity''.\r\n\r\n\\item Let $R$ be a ring. An \\textit{extension ring} of $R$ will mean a ring\r\n$S$ along with a ring monomorphism $R\\rightarrow S$. We will often sloppily\r\nidentify $R$ with a subring of $S$ if $S$ is an extension ring of $R$; we will\r\nthen also identify the polynomial ring $R\\left[  T\\right]  $ with a subring of\r\nthe polynomial ring $S\\left[  T\\right]  $, and so on. An extension ring $S$ of\r\n$R$ is called \\textit{finite-free} if and only if the $R$-module $S$ is\r\nfinite-free (i. e., a free $R$-module with a finite basis).\r\n\r\n\\item We will use multisets. If $I$ is a set, and $u_{i}$ is an object for\r\nevery $i\\in I$, then we let $\\left[  u_{i}\\mid i\\in I\\right]  $ denote the\r\nmultiset formed by all the $u_{i}$ where $i$ ranges over $I$ (this multiset\r\nwill contain each object $o$ as often as it appears as an $u_{i}$ for some\r\n$i\\in I$).\\newline If $I=\\left\\{  1,2,...,n\\right\\}  $ for some $n\\in\r\n\\mathbb{N}$, then we also denote the multiset $\\left[  u_{i}\\mid i\\in\r\nI\\right]  $ by $\\left[  u_{1},u_{2},...,u_{n}\\right]  $.\r\n\r\n\\item We have not defined $\\lambda$-rings yet, but it is important to mention\r\nsome discrepancy in notation between different sources. Namely, some of the\r\nliterature (including \\cite{Knut73}, \\cite{Hazewi08a}, \\cite{Hazewi08b} and\r\n\\cite{Yau10}) denotes as \\textit{pre-}$\\lambda$\\textit{-rings} what we call\r\n$\\lambda$-rings and denotes as $\\lambda$\\textit{-rings} what we call special\r\n$\\lambda$-rings. Even worse, the notations in \\cite{FulLan85} are totally\r\ninconsistent\\footnote{Often, \\textquotedblleft$\\lambda$-ring\\textquotedblright%\r\n\\ in \\cite{FulLan85} means \\textquotedblleft$\\lambda$-ring with a positive\r\nstructure\\textquotedblright\\ (such $\\lambda$-rings are automatically special),\r\nbut sometimes it simply means \\textquotedblleft$\\lambda$%\r\n-ring\\textquotedblright.}.\r\n\r\n\\item When we say \\textquotedblleft monoid\\textquotedblright, we always mean a\r\nmonoid with a neutral element. (The analogous notion without a neutral element\r\nis called \\textquotedblleft semigroup\\textquotedblright.) \\textquotedblleft\r\nMonoid homomorphisms\\textquotedblright\\ have to send the neutral element of\r\nthe domain to the neutral element of the target.\r\n\r\n\\item Most times you read an expression with a $\\sum$ or a $\\prod$ sign in\r\nmathematical literature, you know clearly what it means (e. g., the expression\r\n$\\prod\\limits_{k=1}^{n}\\sin k$ means the product $\\left(  \\sin1\\right)\r\n\\cdot\\left(  \\sin2\\right)  \\cdot...\\cdot\\left(  \\sin n\\right)  $). However,\r\nsome more complicated expressions with $\\sum$ and $\\prod$ signs can be\r\nambiguous, like the expression $\\prod\\limits_{k=1}^{n}\\sin k\\cdot n$: Does\r\nthis expression mean $\\left(  \\prod\\limits_{k=1}^{n}\\sin k\\right)  \\cdot n$ or\r\n$\\prod\\limits_{k=1}^{n}\\left(  \\left(  \\sin k\\right)  \\cdot n\\right)  $ ? The\r\nanswer depends on the author of the text.\\newline In \\textit{this} text, the\r\nfollowing convention should be resorted to when parsing an expression with\r\n$\\sum$ or $\\prod$ signs:\\newline The argument of a $\\prod$ sign ends as early\r\nas reasonably possible. Here, \\textquotedblleft reasonably\r\npossible\\textquotedblright\\ means that it cannot end before the last time the\r\nindex of the product appears (e. g., the argument of $\\prod\\limits_{k=1}%\r\n^{n}\\sin k\\cdot n$ cannot end before the last appearance of $k$), that it\r\ncannot end inside a bracket (e. g., the argument of $\\prod\\limits_{k=1}%\r\n^{n}\\left(  \\left(  \\sin k\\right)  \\cdot n\\right)  $ cannot end before the end\r\nof the $n$), that it cannot end between a symbol and its exponent or index or\r\nbetween a function symbol or its arguments, and that the usual rules of\r\nprecedence have to apply. For example, the expression $\\prod\\limits_{k=1}%\r\n^{n}\\sin k\\cdot n$ has to be read as $\\left(  \\prod\\limits_{k=1}^{n}\\sin\r\nk\\right)  \\cdot n$, and the expression $\\prod\\limits_{k=1}^{n}\\sin\r\nk\\cdot\\left(  \\cos k\\right)  ^{2}k\\cdot\\left(  n+1\\right)  kn$ has to be read\r\nas $\\left(  \\prod\\limits_{k=1}^{n}\\left(  \\sin k\\cdot\\left(  \\cos k\\right)\r\n^{2}\\cdot\\left(  n+1\\right)  k\\right)  \\right)  n$.\\newline Similar rules\r\napply to the parsing of a sum expression.\r\n\r\n\\item Let $R$ be a ring. Let $P\\in R\\left[  X_{1},X_{2},\\ldots,X_{m}%\r\n,Y_{1},Y_{2},\\ldots,Y_{n}\\right]  $ be a polynomial over $R$ in $m+n$\r\nvariables. Then, the \\textit{total degree} of $P$ with respect to the\r\nvariables $X_{1},X_{2},\\ldots,X_{m}$ is defined as the highest $d\\in\r\n\\mathbb{N}$ such that at least one monomial $X_{1}^{a_{1}}X_{2}^{a_{2}}\\cdots\r\nX_{m}^{a_{m}}Y_{1}^{b_{1}}Y_{2}^{b_{2}}\\cdots Y_{n}^{b_{n}}$ with $a_{1}%\r\n+a_{2}+\\cdots+a_{m}=d$ appears in $P$ with a nonzero coefficient. (This total\r\ndegree is defined to be $-\\infty$ if $P=0$.) Similarly, the total degree of\r\n$P$ with respect to the variables $Y_{1},Y_{2},\\ldots,Y_{n}$ is defined.\r\n\r\n\\item The similarly-looking symbols $\\Lambda$ (a capital Lambda) and $\\wedge$\r\n(a wedge symbol, commonly used for the logical operator \\textquotedblleft\r\nand\\textquotedblright) will have completely different meanings. The notation\r\n$\\wedge^{i}V$ (where $R$ is a ring, $V$ is an $R$-module and $i$ is a\r\nnonnegative integer) will stand for the $i$-th exterior power of the\r\n$R$-module $V$. On the other hand, the notation $\\Lambda\\left(  K\\right)  $\r\n(where $K$ is a ring) will stand for a certain ring defined in Chapter 4; this\r\nring is \\textbf{not} the exterior algebra of $K$ (despite some authors\r\ndenoting the latter by $\\Lambda\\left(  K\\right)  $).\r\n\\end{itemize}\r\n\r\n\\section{Motivations}\r\n\r\nWhat is the point of $\\lambda$-rings?\r\n\r\nFulton/Lang \\cite{FulLan85} motivate $\\lambda$-rings through vector bundles.\r\nHere we are going for a more elementary motivation, namely through\r\nrepresentation rings in group representation theory:\r\n\r\n\\subsection{Representation rings of groups}\r\n\r\nConsider a finite group $G$ and a field $k$ of characteristic $0$. In\r\nrepresentation theory, one define the so-called \\textit{representation ring}\r\nof the group $G$ over the field $k$. This ring can be constructed as follows:\r\n\r\nWe consider only finite-dimensional representations of $G$.\r\n\r\nLet $\\operatorname*{Rep}_{k}G$ be the set of all representations of the group\r\n$G$ over the field $k$. (We disregard the set-theoretic problematics stemming\r\nfrom the notion of such a big set. If you wish, you can call it a class or a\r\nSET instead of a set, or restrict yourself to a smaller subset containing\r\nevery representation up to isomorphism.)\r\n\r\nLet $\\operatorname*{FRep}_{k}G$ be the free abelian group on the set\r\n$\\operatorname*{Rep}_{k}G$. Let $I$ be the subgroup%\r\n\\begin{align*}\r\nI  &  =\\left\\langle U-V\\ \\mid\\ U\\text{ and }V\\text{ are two isomorphic\r\nrepresentations of }G\\right\\rangle \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\left\\langle U\\oplus V-U-V\\ \\mid\\ U\\text{ and }V\\text{\r\nare two representations of }G\\right\\rangle\r\n\\end{align*}\r\nof the free abelian group $\\operatorname*{FRep}_{k}G$ (written additively).\r\nThen, $\\operatorname*{FRep}_{k}G\\diagup I$ is an abelian group. Whenever $U$\r\nis a representation of $G$, we should denote the equivalence class of\r\n$U\\in\\operatorname*{FRep}_{k}G$ modulo the ideal $I$ by $\\overline{U}$;\r\nhowever, since we are going to work in $\\operatorname*{FRep}_{k}G\\diagup I$\r\nthroughout this Section 1 (because there is not much of interest to do in\r\n$\\operatorname*{FRep}_{k}G$ itself), we will simply write $U$ for this\r\nequivalence class. This means that whenever $U$ and $V$ are two isomorphic\r\nrepresentations of $G$, we will simply write $U=V$, and whenever $U$ and $V$\r\nare two representations of $G$, we will simply write $U+V=U\\oplus V$.\r\n\r\nDenote by $1$ the equivalence class of the trivial representation of $G$ on\r\n$k$ (with every element of $G$ acting as identity) modulo $I$. We now define a\r\nring structure on $\\operatorname*{FRep}_{k}G\\diagup I$ by letting $1$ be the\r\none of this ring, and defining the product of two representations of $G$ as\r\ntheir tensor product (over $k$). This is indeed a ring structure because we\r\nhave isomorphisms%\r\n\\begin{align*}\r\nU\\otimes\\left(  V\\otimes W\\right)   &  \\cong\\left(  U\\otimes V\\right)  \\otimes\r\nW,\\\\\r\n\\left(  U\\oplus V\\right)  \\otimes W  &  \\cong\\left(  U\\otimes W\\right)\r\n\\oplus\\left(  V\\otimes W\\right)  ,\\\\\r\nU\\otimes\\left(  V\\oplus W\\right)   &  \\cong\\left(  U\\otimes V\\right)\r\n\\oplus\\left(  U\\otimes W\\right)  ,\\\\\r\nU\\otimes V  &  \\cong V\\otimes U,\\\\\r\n1\\otimes U  &  \\cong U\\otimes1\\cong U,\\\\\r\n0\\otimes U  &  \\cong U\\otimes0\\cong0\r\n\\end{align*}\r\nfor any representations $U$, $V$ and $W$, and because tensor products preserve\r\nisomorphisms (this means that if $U$, $V$ and $W$ are three representations of\r\n$G$ such that $V\\cong W$ (as representations), then $U\\otimes V\\cong U\\otimes\r\nW$ and $V\\otimes U\\cong W\\otimes U$).\r\n\r\nThe ring $\\operatorname*{FRep}_{k}G\\diagup I$ is called the\r\n\\textit{representation ring of the group }$G$\\textit{ over the field }$k$. The\r\nelements of $\\operatorname*{FRep}_{k}G\\diagup I$ are called \\textit{virtual\r\nrepresentations}.\r\n\r\nThis ring $\\operatorname*{FRep}_{k}G\\diagup I$ is helpful in working with\r\nrepresentations. However, its ring structure does not yet reflect everything\r\nwe can do with representations. In fact, we can build direct sums of\r\nrepresentations (this is addition in $\\operatorname*{FRep}_{k}G\\diagup I$) and\r\nwe can build tensor products (this is multiplication in $\\operatorname*{FRep}%\r\n_{k}G\\diagup I$), but we can also build exterior powers of representations,\r\nand we have no idea yet what operation on $\\operatorname*{FRep}_{k}G\\diagup I$\r\nthis entails. So we see that the abstract notion of a ring is not enough to\r\nunderstand all of representation theory. We need a notion of a ring together\r\nwith some operations that ``behave like'' taking exterior powers. What axioms\r\nshould these operations satisfy?\r\n\r\nEvery representation $V$ of a group $G$ satisfies $\\wedge^{0}V\\cong1$ and\r\n$\\wedge^{1}V\\cong V$. Besides, for any two representations $V$ and $W$ of $G$\r\nand every $k\\in\\mathbb{N}$, there exists an isomorphism%\r\n\\begin{equation}\r\n\\wedge^{k}\\left(  V\\oplus W\\right)  \\cong\\bigoplus_{i=0}^{k}\\wedge^{i}%\r\nV\\otimes\\wedge^{k-i}W \\label{RepThV+W}%\r\n\\end{equation}\r\n(see Exercise 1.1). In the representation ring, this means%\r\n\\[\r\n\\wedge^{k}\\left(  V+W\\right)  =\\sum_{i=0}^{k}\\left(  \\wedge^{i}V\\right)\r\n\\cdot\\left(  \\wedge^{k-i}W\\right)  .\r\n\\]\r\nThis already gives us three axioms for the operations that we want to\r\nintroduce. If we extend these three axioms to arbitrary elements of\r\n$\\operatorname*{FRep}_{k}G\\diagup I$ (and not just actual representations), we\r\ncan compute $\\wedge^{k}$ of virtual representations (and it turns out that it\r\nis well-defined), and we obtain the notion of a $\\lambda$\\textit{-ring}.\r\n\r\nWe can still wonder whether these axioms are all that we can say about group\r\nrepresentations. The answer is no: In addition to the formula (\\ref{RepThV+W}%\r\n), there exist relations of the form\r\n\\begin{align}\r\n&  \\wedge^{k}\\left(  V\\otimes W\\right)  =P_{k}\\left(  \\wedge^{1}V,\\wedge\r\n^{2}V,...,\\wedge^{k}V,\\wedge^{1}W,\\wedge^{2}W,...,\\wedge^{k}W\\right)\r\n\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{ and any two\r\nrepresentations }V\\text{ and }W\\text{ of }G \\label{RepThVW}%\r\n\\end{align}\r\nand%\r\n\\begin{align}\r\n&  \\wedge^{k}\\left(  \\wedge^{j}\\left(  V\\right)  \\right)  =P_{k,j}\\left(\r\n\\wedge^{1}V,\\wedge^{2}V,...,\\wedge^{kj}V\\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N},\\text{ }j\\in\r\n\\mathbb{N}\\text{ and any representation }V\\text{ of }G, \\label{RepThLL}%\r\n\\end{align}\r\nwhere $P_{k}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{k}%\r\n,\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $ and $P_{k,j}\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{kj}\\right]  $ are ``universal'' polynomials\r\n(i. e., polynomials only depending on $k$ resp. on $k$ and $j$, but not on\r\n$V$, $W$ or $G$). These polynomials are rather hard to write down explicitly,\r\nso it will need some theoretical preparation to define them.\\footnote{Note\r\nthat these polynomials can have negative coefficients, so that the equality\r\n(\\ref{RepThVW}) does not necessarily mean an isomorphism of the kind%\r\n\\[\r\n\\wedge^{k}\\left(  V\\otimes W\\right)  \\cong\\text{direct sum of some tensor\r\nproducts of some }\\wedge^{i}V\\text{ and }\\wedge^{j}W,\r\n\\]\r\nbut generally means an isomorphism of the kind%\r\n\\begin{align*}\r\n&  \\wedge^{k}\\left(  V\\otimes W\\right)  \\oplus\\text{direct sum of some tensor\r\nproducts of some }\\wedge^{i}V\\text{ and }\\wedge^{j}W\\\\\r\n&  \\cong\\text{(another) direct sum of some tensor products of some }\\wedge\r\n^{i}V\\text{ and }\\wedge^{j}W,\r\n\\end{align*}\r\nand similarly (\\ref{RepThLL}) has to be understood.}\r\n\r\nThese relations (\\ref{RepThV+W}) and (\\ref{RepThLL}), generalized to arbitrary\r\nvirtual representations, abstract to the notion of a \\textit{special }%\r\n$\\lambda$\\textit{-ring}. So$\\ \\operatorname*{FRep}_{k}G\\diagup I$ is not just\r\na $\\lambda$-ring; it is a special $\\lambda$-ring. However, it has even more\r\nstructure than that: It is an \\textit{augmented }$\\lambda$\\textit{-ring with\r\npositive structure}. ``Augmented'' means the existence of a ring homomorphism\r\n$\\varepsilon:\\operatorname*{FRep}_{k}G\\diagup I\\rightarrow\\mathbb{Z}$ (a\r\nso-called \\textit{augmentation}) with certain properties; we will list these\r\nproperties later, but let us now notice that for our representation ring\r\n$\\operatorname*{FRep}_{k}G\\diagup I$, the obvious natural choice of\r\n$\\varepsilon$ is the homomorphism which maps every representation $V$ of $G$\r\nto $\\dim V\\in\\mathbb{Z}$. A ``positive structure'' is a subset of $K$ closed\r\nunder addition and multiplication and containing $1$, and satisfying other\r\nproperties; in our case, the best choice for a positive structure on\r\n$\\operatorname*{FRep}_{k}G\\diagup I$ is the subset%\r\n\\[\r\n\\left\\{  \\overline{V}\\mid V\\text{ is a representation of }G\\right\\}\r\n\\setminus0\\subseteq\\operatorname*{FRep}\\nolimits_{k}G\\diagup I.\r\n\\]\r\n\r\n\r\nThe reader may wonder how much the ring $\\operatorname*{FRep}_{k}G\\diagup I$\r\nactually tells us about representations of $G$. For example, if $U$ and $V$\r\nare two representations of $G$ such that $\\overline{U}=\\overline{V}$ in\r\n$\\operatorname*{FRep}_{k}G\\diagup I$, does this mean that $U\\cong V$ ? It\r\nturns out that this is true, thanks to the cancellative property of\r\nrepresentation theory\\footnote{This is the property that whenever $U$, $V$ and\r\n$W$ are three representations of a finite group $G$ such that $U\\oplus W\\cong\r\nV\\oplus W$ (where we recall once again that ``representation'' means\r\n``finite-dimensional representation'' for us!), then $U\\cong V$. This can be\r\nproven using the Krull-Remak-Schmidt theorem, or, when the characteristic of\r\nthe field is $0$, using semisimplicity of $k\\left[  G\\right]  $.}; hence,\r\nabstract algebraic identities that we can prove to hold in arbitrary special\r\n$\\lambda$-rings yield actual isomorphies of representations of finite groups.\r\n(Of course, they only yield them once we will have proven that\r\n$\\operatorname*{FRep}_{k}G\\diagup I$ is a special $\\lambda$-ring. At the\r\nmoment, this is not proven in this text, although it is rather easy to show\r\nusing character theory.)\r\n\r\n\\subsection{Grothendieck rings of groups}\r\n\r\nThe situation gets more complicated when the field over which we are working\r\nis not of characteristic $0$. In this case, it turns out that\r\n$\\operatorname*{FRep}_{k}G\\diagup I$ is not necessarily a special $\\lambda\r\n$-ring any more (although still a $\\lambda$-ring by Exercise 1.1). If we\r\ninsist on getting a special $\\lambda$-ring, we must modify our definition of\r\n$I$ to%\r\n\\begin{align*}\r\nI  &  =\\left\\langle V-U-W\\ \\mid\\ U\\text{, }V\\text{ and }W\\text{ are three\r\nrepresentations of }G\\text{ such that}\\right. \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left.  \\text{there\r\nexists an exact sequence }0\\rightarrow U\\rightarrow V\\rightarrow\r\nW\\rightarrow0\\right\\rangle .\r\n\\end{align*}\r\nThe resulting ring $\\operatorname*{FRep}_{k}G\\diagup I$ is called the\r\n\\textit{Grothendieck ring} of representations of $G$ over our field. A proof\r\nthat it is a special $\\lambda$-ring is sketched in \\cite[Example on page\r\n95]{Seiler88}, but I do not understand it. Anyway this result is not as strong\r\nas in characteristic $0$ anymore, because the equality $\\overline{U}%\r\n=\\overline{V}$ in the Grothendieck ring $\\operatorname*{FRep}_{k}G\\diagup I$\r\ndoes not imply $U\\cong V$ as representations of $G$ when $\\operatorname*{char}%\r\nk\\neq0$. So the Grothendieck ring is, in some sense, a pale shadow of the\r\nrepresentation theory of $G$.\r\n\r\n\\subsection{Vector bundles}\r\n\r\nVector bundles over a given compact Hausdorff space are similar to\r\nrepresentations of a given group in several ways: They are somehow\r\n``enriched'' vector space structures (a vector bundle is, roughly speaking, a\r\nfamily of vector spaces with additional topological structure; a\r\nrepresentation of a group is a vector space with a group action on it), so one\r\ncan form direct sums, tensor products and exterior powers of both of these.\r\nHence, it is not surprising that we can define a $\\lambda$-ring structure on a\r\nkind of ``ring of vector bundles over a space'' similarly to the $\\lambda\r\n$-ring structure on the representation ring of a group. However, just as in\r\nthe case of representations of a group over nonzero characteristic, we must be\r\ncareful with vector bundles, because this ``ring of vector bundles over a\r\nspace'' actually does not consist of vector bundles, but of equivalence\r\nclasses, and sometimes, different vector bundles can lie in one and the same\r\nequivalence class (just as representations of groups are no longer uniquely\r\ndetermined by their equivalence class in the representation ring when the\r\ncharacteristic of the ground field is not $0$). This ``ring of vector\r\nbundles'' is denoted by $K\\left(  X\\right)  $, where $X$ is the base space,\r\nand is the first fundamental object of study in K-theory. We will not delve\r\ninto K-theory here; we will only provide some of its backbone, namely the\r\nabstract algebraic theory of $\\lambda$-rings (which appear not only in\r\nK-theory, but also in representation theory and elsewhere).\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 1.1.} Let $G$ be a group, and let $V$ and $W$ be two\r\nrepresentations of $G$. Let $k\\in\\mathbb{N}$. Let $\\iota_{V}:V\\rightarrow\r\nV\\oplus W$ and $\\iota_{W}:W\\rightarrow V\\oplus W$ be the canonical injections.\r\n\r\nFor every $i\\in\\left\\{  0,1,...,k\\right\\}  $, we can define a vector space\r\nhomomorphism%\r\n\\[\r\n\\Phi_{i}:\\wedge^{i}V\\otimes\\wedge^{k-i}W\\rightarrow\\wedge^{k}\\left(  V\\oplus\r\nW\\right)\r\n\\]\r\nby requiring that it sends\r\n\\begin{align*}\r\n&  \\left(  v_{1}\\wedge v_{2}\\wedge...\\wedge v_{i}\\right)  \\otimes\\left(\r\nw_{1}\\wedge w_{2}\\wedge...\\wedge w_{k-i}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{to}%\r\n\\\\\r\n&  \\iota_{V}\\left(  v_{1}\\right)  \\wedge\\iota_{V}\\left(  v_{2}\\right)\r\n\\wedge...\\wedge\\iota_{V}\\left(  v_{i}\\right)  \\wedge\\iota_{W}\\left(\r\nw_{1}\\right)  \\wedge\\iota_{W}\\left(  w_{2}\\right)  \\wedge...\\wedge\\iota\r\n_{W}\\left(  w_{k-i}\\right)\r\n\\end{align*}\r\nfor all $v_{1},v_{2},...,v_{i}\\in V$ and $w_{1},w_{2},...,w_{k-i}\\in W$.\r\n\r\n\\textbf{(a)} Prove that this vector space homomorphism $\\Phi_{i}$ is a\r\nhomomorphism of representations.\r\n\r\n\\textbf{(b)} Prove that the vector space homomorphism%\r\n\\[\r\n\\bigoplus_{i=0}^{k}\\wedge^{i}V\\otimes\\wedge^{k-i}W\\rightarrow\\wedge^{k}\\left(\r\nV\\oplus W\\right)\r\n\\]\r\ncomposed of the homomorphisms $\\Phi_{i}$ for all $i\\in\\left\\{\r\n0,1,...,k\\right\\}  $ is a canonical isomorphism of representations.\r\n\\end{quotation}\r\n\r\n\\section{$\\lambda$-rings}\r\n\r\n\\subsection{The definition}\r\n\r\nThe following definition introduces our most important notions: that of a\r\n$\\lambda$-ring, that of a $\\lambda$-ring homomorphism, and that of a\r\nsub-$\\lambda$-ring. While these notions are rather elementary (and much easier\r\nto define than the ones in Sections 5 and later), they are the basis of our theory.\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} \\textbf{1)} Let $K$ be a ring. Let $\\lambda\r\n^{i}:K\\rightarrow K$ be a mapping\\footnote{Here, \\textquotedblleft\r\nmapping\\textquotedblright\\ actually means \\textquotedblleft\r\nmapping\\textquotedblright\\ and not \\textquotedblleft group\r\nhomomorphism\\textquotedblright\\ or \\textquotedblleft ring\r\nhomomorphism\\textquotedblright.} for every $i\\in\\mathbb{N}$ such that%\r\n\\begin{equation}\r\n\\lambda^{0}\\left(  x\\right)  =1\\text{ and }\\lambda^{1}\\left(  x\\right)\r\n=x\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K. \\label{lambda0}%\r\n\\end{equation}\r\nAssume that%\r\n\\begin{equation}\r\n\\lambda^{k}\\left(  x+y\\right)  =\\sum_{i=0}^{k}\\lambda^{i}\\left(  x\\right)\r\n\\lambda^{k-i}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }%\r\nk\\in\\mathbb{N},\\text{ }x\\in K\\text{ and }y\\in K. \\label{lambda1}%\r\n\\end{equation}\r\nThen, we call $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n$ a $\\lambda$\\textit{-ring}. We will also call $K$ itself a $\\lambda$-ring if\r\nthere is an obvious (from the context) choice of the sequence of mappings\r\n$\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}$ which makes $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ a $\\lambda$-ring.\r\n\r\n\\textbf{2)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ and $\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nbe two $\\lambda$-rings. Let $f:K\\rightarrow L$ be a map. Then, $f$ is called a\r\n$\\lambda$\\textit{-ring homomorphism} (or \\textit{homomorphism of }$\\lambda\r\n$\\textit{-rings}) if and only if $f$ is a ring homomorphism and satisfies\r\n$\\mu^{i}\\circ f=f\\circ\\lambda^{i}$ for every $i\\in\\mathbb{N}$.\r\n\r\n\\textbf{3)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Let $L$ be a subring of $K$. Then, $L$ is\r\nsaid to be a \\textit{sub-}$\\lambda$\\textit{-ring} of $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ if and only if $\\lambda\r\n^{i}\\left(  L\\right)  \\subseteq L$ for every $i\\in\\mathbb{N}$. Obviously, if\r\n$L$ is a sub-$\\lambda$-ring of $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $, then $\\left(  L,\\left(  \\lambda^{i}\\mid\r\n_{L}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring, and the\r\ncanonical inclusion $L\\rightarrow K$ is a $\\lambda$-ring homomorphism.\r\n\\end{quote}\r\n\r\n\\subsection{An alternative characterization}\r\n\r\nWe will now give an alternative characterization of $\\lambda$-rings:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 2.1.} Let $K$ be a ring. Let $\\lambda^{i}:K\\rightarrow K$ be a\r\nmapping\\footnote{Here, \\textquotedblleft mapping\\textquotedblright\\ actually\r\nmeans \\textquotedblleft mapping\\textquotedblright\\ and not \\textquotedblleft\r\ngroup homomorphism\\textquotedblright\\ or \\textquotedblleft ring\r\nhomomorphism\\textquotedblright.} for every $i\\in\\mathbb{N}$ such that\r\n$\\lambda^{0}\\left(  x\\right)  =1$ and $\\lambda^{1}\\left(  x\\right)  =x$ for\r\nevery $x\\in K$. Consider the ring $K\\left[  \\left[  T\\right]  \\right]  $ of\r\nformal power series in the indeterminate $T$ over the ring $K$. Define a map\r\n$\\lambda_{T}:K\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ by\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K.\r\n\\]\r\nNote that the power series $\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}$ has the coefficient\r\n$\\lambda^{0}\\left(  x\\right)  =1$ before $T^{0}$; thus, it is invertible in\r\n$K\\left[  \\left[  T\\right]  \\right]  $.\r\n\r\n\\textbf{(a)} Then,\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda\r\n_{T}\\left(  x+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\text{ and\r\nevery }y\\in K\r\n\\]\r\nif and only if $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ is a $\\lambda$-ring.\r\n\r\n\\textbf{(b)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Then,%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  0\\right)   &  =1;\\\\\r\n\\lambda_{T}\\left(  -x\\right)   &  =\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  ^{-1}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K;\\\\\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)   &\r\n=\\lambda_{T}\\left(  x+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in\r\nK\\text{ and every }y\\in K.\r\n\\end{align*}\r\n\r\n\r\n\\textbf{(c)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ and $\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nbe two $\\lambda$-rings. Consider the map $\\lambda_{T}:K\\rightarrow K\\left[\r\n\\left[  T\\right]  \\right]  $ defined above, and a similarly defined map\r\n$\\mu_{T}:L\\rightarrow L\\left[  \\left[  T\\right]  \\right]  $ for the $\\lambda\r\n$-ring $L$. Let $f:K\\rightarrow L$ be a ring homomorphism. Consider the rings\r\n$K\\left[  \\left[  T\\right]  \\right]  $ and $L\\left[  \\left[  T\\right]\r\n\\right]  $. Obviously, the homomorphism $f$ induces a homomorphism $f\\left[\r\n\\left[  T\\right]  \\right]  :K\\left[  \\left[  T\\right]  \\right]  \\rightarrow\r\nL\\left[  \\left[  T\\right]  \\right]  $ (defined by\r\n\\begin{align*}\r\n\\left(  f\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  \\sum\r\n\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)   &  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}f\\left(  a_{i}\\right)  T^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\sum\\limits_{i\\in\\mathbb{N}}a_{i}%\r\nT^{i}\\in K\\left[  \\left[  T\\right]  \\right]  \\text{ with }a_{i}\\in K\r\n\\end{align*}\r\n).\r\n\r\nThen, $f$ is a $\\lambda$-ring homomorphism if and only if $\\mu_{T}\\circ\r\nf=f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}$.\r\n\r\n\\textbf{(d)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Then, $\\lambda^{i}\\left(  0\\right)  =0$ for\r\nevery positive integer $i$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 2.1.]\\textbf{(a)} Every $x\\in K$ and every $y\\in K$ satisfy%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)   &  =\\left(\r\n\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}\\right)\r\n\\cdot\\left(  \\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  y\\right)\r\nT^{i}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}\\text{ and\r\n}\\lambda_{T}\\left(  y\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\ny\\right)  T^{i}\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}\\sum_{i=0}^{k}\\lambda^{i}\\left(  x\\right)\r\n\\lambda^{k-i}\\left(  y\\right)  \\cdot T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\nformal power series}\\right)\r\n\\end{align*}\r\nand%\r\n\\[\r\n\\lambda_{T}\\left(  x+y\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx+y\\right)  T^{i}=\\sum_{k\\in\\mathbb{N}}\\lambda^{k}\\left(  x+y\\right)  T^{k}.\r\n\\]\r\nHence, the equation $\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(\r\ny\\right)  =\\lambda_{T}\\left(  x+y\\right)  $ is equivalent to $\\sum\r\n\\limits_{k\\in\\mathbb{N}}\\sum\\limits_{i=0}^{k}\\lambda^{i}\\left(  x\\right)\r\n\\lambda^{k-i}\\left(  y\\right)  \\cdot T^{k}=\\sum\\limits_{k\\in\\mathbb{N}}%\r\n\\lambda^{k}\\left(  x+y\\right)  T^{k}$, which, in turn, means that every\r\n$k\\in\\mathbb{N}$ satisfies $\\sum\\limits_{i=0}^{k}\\lambda^{i}\\left(  x\\right)\r\n\\lambda^{k-i}\\left(  y\\right)  =\\lambda^{k}\\left(  x+y\\right)  $, and this is\r\nexactly the property (\\ref{lambda1}) from the definition of a $\\lambda$-ring.\r\nThus, we have $\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)\r\n=\\lambda_{T}\\left(  x+y\\right)  $ for every $x\\in K$ and every $y\\in K$ if and\r\nonly if $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is\r\na $\\lambda$-ring. This proves Theorem 2.1 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Theorem 2.1 \\textbf{(a)} tells us that $\\lambda_{T}\\left(\r\nx\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda_{T}\\left(  x+y\\right)  $\r\nfor every $x\\in K$ and every $y\\in K$ if and only if $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. Since we\r\nknow that $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a $\\lambda$-ring, we thus conclude that\r\n\\begin{equation}\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda\r\n_{T}\\left(  x+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\text{ and\r\nevery }y\\in K. \\label{2.1.pf.1}%\r\n\\end{equation}\r\nApplied to $x=y=0$, this rewrites as $\\lambda_{T}\\left(  0\\right)\r\n\\cdot\\lambda_{T}\\left(  0\\right)  =\\lambda_{T}\\left(  0+0\\right)  =\\lambda\r\n_{T}\\left(  0\\right)  $, what yields $\\lambda_{T}\\left(  0\\right)  =1$ (since\r\n$\\lambda_{T}\\left(  0\\right)  $ is invertible in $K\\left[  \\left[  T\\right]\r\n\\right]  $).\r\n\r\nOn the other hand, every $x\\in K$ satisfies\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  -x\\right)   &\r\n=\\lambda_{T}\\left(  0\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{2.1.pf.1}), applied to }y=-x\\right) \\\\\r\n&  =1,\r\n\\end{align*}\r\nhence $\\lambda_{T}\\left(  -x\\right)  =\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  ^{-1}$. Theorem 2.1 \\textbf{(b)} is thus proven.\r\n\r\n\\textbf{(c)} We have $\\left(  \\mu_{T}\\circ f\\right)  \\left(  x\\right)\r\n=\\mu_{T}\\left(  f\\left(  x\\right)  \\right)  =\\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\mu^{i}\\left(  f\\left(  x\\right)  \\right)  T^{i}$ (by the definition of\r\n$\\mu_{T}$) and $\\left(  f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda\r\n_{T}\\right)  \\left(  x\\right)  =\\left(  f\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  =\\left(  f\\left[\r\n\\left[  T\\right]  \\right]  \\right)  \\left(  \\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\lambda^{i}\\left(  x\\right)  T^{i}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}f\\left(  \\lambda^{i}\\left(  x\\right)  \\right)  T^{i}$ for every $x\\in K$.\r\nHence, $\\mu_{T}\\circ f=f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}$\r\nis equivalent to $\\sum\\limits_{i\\in\\mathbb{N}}\\mu^{i}\\left(  f\\left(\r\nx\\right)  \\right)  T^{i}=\\sum\\limits_{i\\in\\mathbb{N}}f\\left(  \\lambda\r\n^{i}\\left(  x\\right)  \\right)  T^{i}$ for every $x\\in K$, which in turn is\r\nequivalent to $\\mu^{i}\\left(  f\\left(  x\\right)  \\right)  =f\\left(\r\n\\lambda^{i}\\left(  x\\right)  \\right)  $ for every $x\\in K$ and every\r\n$i\\in\\mathbb{N}$, which in turn means that $\\mu^{i}\\circ f=f\\circ\\lambda^{i}$\r\nfor every $i\\in\\mathbb{N}$, which in turn means that $f$ is a $\\lambda$-ring\r\nhomomorphism. This proves Theorem 2.1 \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Applying the equality $\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}$ to $x=0$, we\r\nobtain $\\lambda_{T}\\left(  0\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  0\\right)  T^{i}$. But since $\\lambda_{T}\\left(  0\\right)  =1$,\r\nthis rewrites as $1=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  0\\right)\r\nT^{i}$. For every positive integer $i$, the coefficient of $T^{i}$ on the left\r\nhand side of this equality is $0$, while the coefficient of $T^{i}$ on the\r\nright hand side of this equality is $\\lambda^{i}\\left(  0\\right)  $. Since the\r\ncoefficients of $T^{i}$ on the two sides of an equality must be equal, this\r\nyields $0=\\lambda^{i}\\left(  0\\right)  $ for every positive integer $i$. This\r\nproves Theorem 2.1 \\textbf{(d)}.\r\n\\end{proof}\r\n\r\nThe map $\\lambda_{T}$ defined in Theorem 2.1 will follow us through the whole\r\ntheory of $\\lambda$-rings. It is often easier to deal with than the maps\r\n$\\lambda^{i}$, since (as Theorem 2.1 \\textbf{(a)} and \\textbf{(b)} show)\r\n$\\lambda_{T}$ is a monoid homomorphism from $\\left(  K,+\\right)  $ to $\\left(\r\nK\\left[  \\left[  T\\right]  \\right]  ,\\cdot\\right)  $ when $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. Many\r\nproperties of $\\lambda$-rings are easier to write in terms of $\\lambda_{T}$\r\nthan in terms of the separate $\\lambda^{i}$. We will later become acquainted\r\nwith the notion of ``special $\\lambda$-rings'', for which $\\lambda_{T}$ is not\r\nonly a monoid homomorphism but actually a $\\lambda$-ring homomorphism (but not\r\nto $K\\left[  \\left[  T\\right]  \\right]  $ but to a different $\\lambda$-ring\r\nwith a new ring structure).\r\n\r\n\\subsection{$\\lambda$-ideals}\r\n\r\nJust as rings have ideals and Lie algebras have Lie ideals, there is a notion\r\nof $\\lambda$-ideals defined for $\\lambda$-rings. Here is one way to define them:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $I$ be an ideal of the ring\r\n$K$. Then, $I$ is said to be a $\\lambda$\\textit{-ideal} of $K$ if and only if\r\nevery $t\\in I$ and every positive integer $i$ satisfy $\\lambda^{i}\\left(\r\nt\\right)  \\in I$.\r\n\\end{quote}\r\n\r\nJust as rings can be factored by ideals to obtain new rings, and Lie algebras\r\ncan be factored by Lie ideals to obtain new Lie algebras, we can factor\r\n$\\lambda$-rings by $\\lambda$-ideals and obtain new $\\lambda$-rings:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 2.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $I$ be a $\\lambda$-ideal\r\nof the ring $K$. For every $z\\in K$, let $\\overline{z}$ denote the residue\r\nclass of $z$ modulo $I$. (This $\\overline{z}$ lies in $K\\diagup I$.)\r\n\r\n\\textbf{(a)} If $x\\in K\\diagup I$ is arbitrary, and $y\\in K$ and $z\\in K$ are\r\ntwo elements of $K$ satisfying $\\overline{y}=x$ and $\\overline{z}=x$, then\r\n$\\overline{\\lambda^{i}\\left(  y\\right)  }=\\overline{\\lambda^{i}\\left(\r\nz\\right)  }$ for every $i\\in\\mathbb{N}$.\r\n\r\n\\textbf{(b)} For every $i\\in\\mathbb{N}$, define a map $\\widetilde{\\lambda}%\r\n^{i}:K\\diagup I\\rightarrow K\\diagup I$ as follows: For every $x\\in K\\diagup\r\nI$, let $\\widetilde{\\lambda}^{i}\\left(  x\\right)  $ be defined as\r\n$\\overline{\\lambda^{i}\\left(  w\\right)  }$, where $w$ is an element of $K$\r\nsatisfying $\\overline{w}=x$. (This is well-defined because the value of\r\n$\\overline{\\lambda^{i}\\left(  w\\right)  }$ does not depend on the choice of\r\n$w$\\ \\ \\ \\ \\footnote{In fact, any two choices of $w$ lead to the same value of\r\n$\\overline{\\lambda^{i}\\left(  w\\right)  }$ (this follows from Theorem 2.2\r\n\\textbf{(a)}).}.)\r\n\r\nThen, $\\left(  K\\diagup I,\\left(  \\widetilde{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring.\r\n\r\n\\textbf{(c)} The canonical projection $K\\rightarrow K\\diagup I$ is a $\\lambda\r\n$-ring homomorphism.\r\n\\end{quote}\r\n\r\nThe proof of Theorem 2.2 is given in the solution of Exercise 2.3.\r\n\r\nAlong with Theorem 2.2 comes the following result:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 2.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and $\\left(  L,\\left(  \\mu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be two $\\lambda$-rings. Let $f:K\\rightarrow L$ be\r\na $\\lambda$-ring homomorphism. Then, $\\operatorname*{Ker}f$ is a $\\lambda$-ideal.\r\n\\end{quote}\r\n\r\nThe proof of Theorem 2.3 is given in the solution of Exercise 2.4.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 2.1.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and $\\left(  L,\\left(  \\mu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be two $\\lambda$-rings. Let $f:K\\rightarrow L$ be\r\na ring homomorphism. Let $E$ be a generating set of the $\\mathbb{Z}$-module\r\n$K$.\r\n\r\n\\textbf{(a)} Prove that $f$ is a $\\lambda$-ring homomorphism if and only if\r\nevery $e\\in E$ satisfies $\\left(  \\mu_{T}\\circ f\\right)  \\left(  e\\right)\r\n=\\left(  f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\ne\\right)  $.\r\n\r\n\\textbf{(b)} Prove that $f$ is a $\\lambda$-ring homomorphism if and only if\r\nevery $e\\in E$ satisfies $\\left(  \\mu^{i}\\circ f\\right)  \\left(  e\\right)\r\n=\\left(  f\\circ\\lambda^{i}\\right)  \\left(  e\\right)  $ for every\r\n$i\\in\\mathbb{N}$.\r\n\r\n\\textit{Exercise 2.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $L$ be a subset of $K$\r\nwhich is closed under addition, multiplication and the maps $\\lambda^{i}$.\r\nAssume that $0\\in L$ and $1\\in L$. Then, the subset $L-L$ of $K$ (this subset\r\n$L-L$ is defined by $L-L=\\left\\{  \\ell-\\ell^{\\prime}\\mid\\ell\\in L,\\ \\ell\r\n^{\\prime}\\in L\\right\\}  $) is a sub-$\\lambda$-ring of $K$.\r\n\r\n\\textit{Exercise 2.3.} Prove Theorem 2.2.\r\n\r\n\\textit{Exercise 2.4.} Prove Theorem 2.3.\r\n\\end{quotation}\r\n\r\n\\section{Examples of $\\lambda$-rings}\r\n\r\n\\subsection{Binomial $\\lambda$-rings}\r\n\r\nBefore we go deeper into the theory, it is time for some examples.\r\n\r\nObviously, the trivial ring $0$ (the ring satisfying $0=1$) along with the\r\ntrivial maps $\\lambda^{i}:0\\rightarrow0$ is a $\\lambda$-ring. Let us move on\r\nto more surprising examples:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 3.1.} For every $i\\in\\mathbb{N}$, define a map $\\lambda\r\n^{i}:\\mathbb{Z}\\rightarrow\\mathbb{Z}$ by $\\lambda^{i}\\left(  x\\right)\r\n=\\dbinom{x}{i}$ for every $x\\in\\mathbb{Z}$.\\ \\ \\ \\ \\footnote{Note that\r\n$\\dbinom{x}{i}$ is defined to be $\\dfrac{x\\cdot\\left(  x-1\\right)\r\n\\cdot...\\cdot\\left(  x-i+1\\right)  }{i!}$ for every $x\\in\\mathbb{R}$ and\r\n$i\\in\\mathbb{N}$.} Then, $\\left(  \\mathbb{Z},\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 3.1.]Trivially, $\\lambda^{0}\\left(  x\\right)  =1$ and\r\n$\\lambda^{1}\\left(  x\\right)  =x$ for every $x\\in\\mathbb{Z}$. The only\r\nchallenge, if there is a challenge in this proof, is to verify the identity\r\n(\\ref{lambda1}) for $K=\\mathbb{Z}$. In other words, we have to prove that%\r\n\\begin{equation}\r\n\\dbinom{x+y}{k}=\\sum_{i=0}^{k}\\dbinom{x}{i}\\dbinom{y}{k-i} \\label{vandermonde}%\r\n\\end{equation}\r\nfor every $k\\in\\mathbb{N}$, $x\\in\\mathbb{Z}$ and $y\\in\\mathbb{Z}$. This is the\r\nso-called \\textit{Vandermonde convolution identity}, and various proofs of it\r\ncan easily be found in the literature\\footnote{For example, it follows\r\nimmediately from \\cite[Theorem 3.29]{Grin-detn}.}. Probably the shortest proof\r\nof (\\ref{vandermonde}) is the following: If we fix $k\\in\\mathbb{N}$, then\r\n(\\ref{vandermonde}) is a polynomial identity in both $x$ and $y$ (indeed, both\r\nsides of (\\ref{vandermonde}) are polynomials in $x$ and $y$ with rational\r\ncoefficients), and thus it is enough to prove it for all natural $x$ and $y$\r\n(because a polynomial identity holding for all natural variables must hold\r\neverywhere). But for $x$ and $y$ natural, we have%\r\n\\begin{align*}\r\n\\sum_{k=0}^{x+y}\\sum_{i=0}^{k}\\dbinom{x}{i}\\dbinom{y}{k-i}T^{k}  &\r\n=\\underbrace{\\sum_{i=0}^{x}\\dbinom{x}{i}T^{i}}_{\\substack{=\\left(  1+T\\right)\r\n^{x}\\\\\\text{(by the}\\\\\\text{binomial formula)}}}\\cdot\\underbrace{\\sum\r\n_{j=0}^{y}\\dbinom{y}{j}T^{j}}_{\\substack{=\\left(  1+T\\right)  ^{y}\\\\\\text{(by\r\nthe}\\\\\\text{binomial formula)}}}\\\\\r\n&  =\\left(  1+T\\right)  ^{x}\\cdot\\left(  1+T\\right)  ^{y}=\\left(  1+T\\right)\r\n^{x+y}=\\sum_{k=0}^{x+y}\\dbinom{x+y}{k}T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the binomial formula}\\right)\r\n\\end{align*}\r\nin the polynomial ring $\\mathbb{Z}\\left[  T\\right]  $. Comparing coefficients\r\nbefore $T^{k}$ in this equality, we quickly conclude that (\\ref{vandermonde})\r\nholds for each $k\\in\\mathbb{N}$. Thus, (\\ref{vandermonde}) is\r\nproven.\\footnote{\\textit{Remark.} It is tempting to apply this argument to the\r\ngeneral case (where $x$ and $y$ are not required to be natural), because the\r\nbinomial formula holds for negative exponents as well (of course, this\r\nrequires working in the formal power series ring $\\mathbb{Z}\\left[  \\left[\r\nT\\right]  \\right]  $ rather than in the polynomial ring $\\mathbb{Z}\\left[\r\nT\\right]  $), but I am not sure whether this argument is free of circular\r\nreasoning because it is not at all obvious that $\\left(  1+T\\right)\r\n^{x}\\left(  1+T\\right)  ^{y}=\\left(  1+T\\right)  ^{x+y}$ in $\\mathbb{Z}\\left[\r\n\\left[  T\\right]  \\right]  $ for negative $x$ and $y$, and I even fear that\r\nthis is usually proven using (\\ref{vandermonde}).} This proves Theorem 3.1.\r\n\\end{proof}\r\n\r\nOur next example is a generalization of Theorem 3.1:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. We call $K$ a \\textit{binomial ring}\r\nif and only if none of the elements $1$, $2$, $3$, $...$ is a zero-divisor in\r\n$K$, and $n!\\mid x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(  x-i+1\\right)\r\n$ for every $x\\in K$ and every $n\\in\\mathbb{N}$.\r\n\r\n\\textbf{Theorem 3.2.} Let $K$ be a binomial ring. For every $i\\in\\mathbb{N}$,\r\ndefine a map $\\lambda^{i}:K\\rightarrow K$ by $\\lambda^{i}\\left(  x\\right)\r\n=\\dbinom{x}{i}$ for every $x\\in K$ (where, again, $\\dbinom{x}{i}$ is defined\r\nto be $\\dfrac{x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(  x-i+1\\right)\r\n}{i!}$). Then, $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ is a $\\lambda$-ring.\r\n\\end{quote}\r\n\r\nSuch $\\lambda$-rings $K$ are called \\textit{binomial }$\\lambda$\\textit{-rings}.\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 3.2.]Obviously, $\\lambda^{0}\\left(  x\\right)  =1$ and\r\n$\\lambda^{1}\\left(  x\\right)  =x$ for every $x\\in K$, so it only remains to\r\nshow that (\\ref{lambda1}) is satisfied. This means proving (\\ref{vandermonde})\r\nfor every $k\\in\\mathbb{N}$, $x\\in K$ and $y\\in K$. But this is easy now: Fix\r\n$k\\in\\mathbb{N}$. Then, (\\ref{vandermonde}) is a polynomial identity in both\r\n$x$ and $y$, and since we know that it holds for every $x\\in\\mathbb{Z}$ and\r\nevery $y\\in\\mathbb{Z}$ (as we have seen in the proof of Theorem 3.1), it\r\nfollows that it holds for every $x\\in K$ and every $y\\in K$ (since a\r\npolynomial identity holding for all integer variables must hold everywhere).\r\nThis completes the proof of Theorem 3.2.\r\n\\end{proof}\r\n\r\nObviously, the $\\lambda$-ring $\\left(  \\mathbb{Z},\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ defined in Theorem 3.1 is a binomial $\\lambda\r\n$-ring. For other examples of binomial $\\lambda$-rings, see Exercise 3.1. Of\r\ncourse, every $\\mathbb{Q}$-algebra is a binomial ring as well.\r\n\r\n\\subsection{Adjoining a polynomial variable to a $\\lambda$-ring}\r\n\r\nBinomial $\\lambda$-rings are not the main examples of $\\lambda$-rings. We will\r\nsee an important example of $\\lambda$-rings in Theorem 5.1 and Exercise 6.1.\r\nAnother simple way to construct new examples from known ones is the following one:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. Let $L$ be a $K$-algebra. Consider the\r\nring $K\\left[  \\left[  T\\right]  \\right]  $ of formal power series in the\r\nindeterminate $T$ over the ring $K$, and the ring $L\\left[  \\left[  T\\right]\r\n\\right]  $ of formal power series in the indeterminate $T$ over the ring $L$.\r\nFor every $\\mu\\in L$, we can define a $K$-algebra homomorphism\r\n$\\operatorname*{ev}_{\\mu T}:K\\left[  \\left[  T\\right]  \\right]  \\rightarrow\r\nL\\left[  \\left[  T\\right]  \\right]  $ by setting $\\operatorname*{ev}_{\\mu\r\nT}\\left(  \\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}a_{i}\\mu^{i}T^{i}$ for every power series $\\sum\\limits_{i\\in\r\n\\mathbb{N}}a_{i}T^{i}\\in K\\left[  \\left[  T\\right]  \\right]  $ (which\r\nsatisfies $a_{i}\\in K$ for every $i\\in\\mathbb{N}$). (In other words,\r\n$\\operatorname*{ev}_{\\mu T}$ is the map that takes any power series in $T$ and\r\nreplaces every $T$ in this power series by $\\mu T$.)\r\n\r\n\\textbf{Theorem 3.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Consider the polynomial ring\r\n$K\\left[  S\\right]  $. For every $i\\in\\mathbb{N}$, define a map $\\overline\r\n{\\lambda}^{i}:K\\left[  S\\right]  \\rightarrow K\\left[  S\\right]  $ as follows:\r\nFor every $\\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}\\in K\\left[  S\\right]  $\r\n(with $a_{j}\\in K$ for every $j\\in\\mathbb{N}$), let $\\overline{\\lambda}%\r\n^{i}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}\\right)  $ be the\r\ncoefficient of the power series $\\prod\\limits_{j\\in\\mathbb{N}}\\lambda_{S^{j}%\r\nT}\\left(  a_{j}\\right)  \\in\\left(  K\\left[  S\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $ before $T^{i}$, where the power series $\\lambda_{S^{j}%\r\nT}\\left(  a_{j}\\right)  \\in\\left(  K\\left[  S\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $ is defined as $\\operatorname*{ev}_{S^{j}T}\\left(\r\n\\lambda_{T}\\left(  a_{j}\\right)  \\right)  $.\r\n\r\n\\textbf{(a)} Then, $\\left(  K\\left[  S\\right]  ,\\left(  \\overline{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. The ring $K$ is\r\na sub-$\\lambda$-ring of $\\left(  K\\left[  S\\right]  ,\\left(  \\overline\r\n{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $.\r\n\r\n\\textbf{(b)} For every $a\\in K$ and $\\alpha\\in\\mathbb{N}$, we have\r\n$\\overline{\\lambda}^{i}\\left(  aS^{\\alpha}\\right)  =\\lambda^{i}\\left(\r\na\\right)  S^{\\alpha i}$ for every $i\\in\\mathbb{N}$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 3.3.]For every $x\\in K$, we have\r\n\\begin{align}\r\n\\lambda_{S^{j}T}\\left(  x\\right)   &  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  x\\right)  \\left(  S^{j}T\\right)  ^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\lambda^{i}\\left(  x\\right)  T^{i}\\right) \\nonumber\\\\\r\n&  =\\underbrace{\\lambda^{0}\\left(  x\\right)  }_{\\substack{=1\\\\\\text{(by\r\n(\\ref{lambda0}))}}}\\underbrace{\\left(  S^{j}T\\right)  ^{0}}_{=1}%\r\n+\\underbrace{\\lambda^{1}\\left(  x\\right)  }_{\\substack{=x\\\\\\text{(by\r\n(\\ref{lambda0}))}}}\\underbrace{\\left(  S^{j}T\\right)  ^{1}}_{=S^{j}T}%\r\n+\\sum\\limits_{i\\geq2}\\lambda^{i}\\left(  x\\right)  \\underbrace{\\left(\r\nS^{j}T\\right)  ^{i}}_{=S^{ji}T^{i}}\\nonumber\\\\\r\n&  =1+xS^{j}T+\\underbrace{\\sum\\limits_{i\\geq2}\\lambda^{i}\\left(  x\\right)\r\nS^{ji}T^{i}}_{\\substack{=\\left(  \\text{sum of terms divisible by }%\r\nT^{2}\\right)  \\\\\\text{(since }T^{2}\\mid T^{i}\\text{ for every }i\\geq2\\text{)}%\r\n}}\\nonumber\\\\\r\n&  =1+xS^{j}T+\\left(  \\text{sum of terms divisible by }T^{2}\\right)  .\r\n\\label{thm.3.3.pf.1}%\r\n\\end{align}\r\n\r\n\r\n\\textbf{(a)} Define a map $\\overline{\\lambda}_{T}:K\\left[  S\\right]\r\n\\rightarrow\\left(  K\\left[  S\\right]  \\right)  \\left[  \\left[  T\\right]\r\n\\right]  $ by%\r\n\\begin{equation}\r\n\\overline{\\lambda}_{T}\\left(  u\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\overline{\\lambda}^{i}\\left(  u\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }u\\in K\\left[  S\\right]  . \\label{thm.3.3.pf.a.1}%\r\n\\end{equation}\r\nThen, according to the definition of the maps $\\overline{\\lambda}^{i}$, we\r\nhave\r\n\\begin{equation}\r\n\\overline{\\lambda}_{T}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}\\right)\r\n=\\prod\\limits_{j\\in\\mathbb{N}}\\lambda_{S^{j}T}\\left(  a_{j}\\right)  \\in\\left(\r\nK\\left[  S\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]\r\n\\label{thm.3.3.pf.a.lambdaol}%\r\n\\end{equation}\r\nfor every $\\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}\\in K\\left[  S\\right]  $\r\n(with $a_{j}\\in K$ for every $j\\in\\mathbb{N}$). Hence, for every $u\\in\r\nK\\left[  S\\right]  $, we have%\r\n\\begin{equation}\r\n\\sum\\limits_{i\\in\\mathbb{N}}\\overline{\\lambda}^{i}\\left(  u\\right)\r\nT^{i}=1+uT+\\left(  \\text{sum of terms divisible by }T^{2}\\right)\r\n\\label{thm.3.3.pf.a.2}%\r\n\\end{equation}\r\nin $\\left(  K\\left[  S\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]\r\n$\\ \\ \\ \\ \\footnote{\\textit{Proof of (\\ref{thm.3.3.pf.a.2}):} Let $u\\in\r\nK\\left[  S\\right]  $. Write $u$ in the form $u=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}a_{j}S^{j}$, where $a_{j}\\in K$ for every $j\\in\\mathbb{N}$. Then,\r\n(\\ref{thm.3.3.pf.a.1}) yields%\r\n\\begin{align*}\r\n\\sum\\limits_{i\\in\\mathbb{N}}\\overline{\\lambda}^{i}\\left(  u\\right)  T^{i}  &\r\n=\\overline{\\lambda}_{T}\\left(  \\underbrace{u}_{=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}a_{j}S^{j}}\\right)  =\\overline{\\lambda}_{T}\\left(  \\sum\\limits_{j\\in\r\n\\mathbb{N}}a_{j}S^{j}\\right)  =\\prod\\limits_{j\\in\\mathbb{N}}%\r\n\\underbrace{\\lambda_{S^{j}T}\\left(  a_{j}\\right)  }_{\\substack{=1+a_{j}%\r\nS^{j}T+\\left(  \\text{sum of terms divisible by }T^{2}\\right)  \\\\\\text{(by\r\n(\\ref{thm.3.3.pf.1}), applied to }x=a_{j}\\text{)}}}\\\\\r\n&  =\\prod\\limits_{j\\in\\mathbb{N}}\\left(  1+a_{j}S^{j}T+\\left(  \\text{sum of\r\nterms divisible by }T^{2}\\right)  \\right) \\\\\r\n&  =1+\\underbrace{\\left(  \\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}\\right)\r\n}_{=u}T+\\left(  \\text{sum of terms divisible by }T^{2}\\right) \\\\\r\n&  =1+uT+\\left(  \\text{sum of terms divisible by }T^{2}\\right)  .\r\n\\end{align*}\r\nThis proves (\\ref{thm.3.3.pf.a.2}).}. Hence, for every $u\\in K\\left[\r\nS\\right]  $, we have $\\overline{\\lambda}^{0}\\left(  u\\right)  =1$ (this is\r\nobtained by comparing coefficients before $T^{0}$ in the equality\r\n(\\ref{thm.3.3.pf.a.2})) and $\\overline{\\lambda}^{1}\\left(  u\\right)  =u$ (this\r\nis obtained by comparing coefficients before $T^{1}$ in the equality\r\n(\\ref{thm.3.3.pf.a.2})). Renaming $u$ as $x$ in this sentence, we obtain the\r\nfollowing: For every $x\\in K\\left[  S\\right]  $, we have $\\overline{\\lambda\r\n}^{0}\\left(  x\\right)  =1$ and $\\overline{\\lambda}^{1}\\left(  x\\right)  =x$.\r\n\r\nThus, we can apply Theorem 2.1 \\textbf{(a)} to $K\\left[  S\\right]  $, $\\left(\r\n\\overline{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}$ and $\\overline{\\lambda}_{T}$\r\ninstead of $K$, $\\lambda^{i}$ and $\\lambda_{T}$. As a result, we see that\r\n\\begin{equation}\r\n\\overline{\\lambda}_{T}\\left(  x\\right)  \\cdot\\overline{\\lambda}_{T}\\left(\r\ny\\right)  =\\overline{\\lambda}_{T}\\left(  x+y\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\left[  S\\right]  \\text{ and every\r\n}y\\in K\\left[  S\\right]  \\label{thm.3.3.pf.a.goal}%\r\n\\end{equation}\r\nif and only if $\\left(  K\\left[  S\\right]  ,\\left(  \\overline{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. Therefore,\r\nproving that $\\left(  K\\left[  S\\right]  ,\\left(  \\overline{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring boils down to\r\nverifying (\\ref{thm.3.3.pf.a.goal}). Let us therefore verify\r\n(\\ref{thm.3.3.pf.a.goal}):\r\n\r\n\\textit{Proof of (\\ref{thm.3.3.pf.a.goal}):} Let $x\\in K\\left[  S\\right]  $\r\nand $y\\in K\\left[  S\\right]  $. Write $x$ in the form $x=\\sum\\limits_{j\\in\r\n\\mathbb{N}}a_{j}S^{j}$ for some family $\\left(  a_{j}\\right)  _{j\\in\r\n\\mathbb{N}}\\in K^{\\mathbb{N}}$. Write $y$ in the form $y=\\sum\\limits_{j\\in\r\n\\mathbb{N}}b_{j}S^{j}$ for some family $\\left(  b_{j}\\right)  _{j\\in\r\n\\mathbb{N}}\\in K^{\\mathbb{N}}$. Adding the equalities $x=\\sum\\limits_{j\\in\r\n\\mathbb{N}}a_{j}S^{j}$ and $y=\\sum\\limits_{j\\in\\mathbb{N}}b_{j}S^{j}$, we\r\nobtain $x+y=\\sum\\limits_{j\\in\\mathbb{N}}a_{j}S^{j}+\\sum\\limits_{j\\in\r\n\\mathbb{N}}b_{j}S^{j}=\\sum\\limits_{j\\in\\mathbb{N}}\\left(  a_{j}+b_{j}\\right)\r\nS^{j}$. Applying the map $\\overline{\\lambda}_{T}$ to both sides of this\r\nequality, we find%\r\n\\begin{align*}\r\n\\overline{\\lambda}_{T}\\left(  x+y\\right)   &  =\\overline{\\lambda}_{T}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\left(  a_{j}+b_{j}\\right)  S^{j}\\right)\r\n=\\prod\\limits_{j\\in\\mathbb{N}}\\underbrace{\\lambda_{S^{j}T}\\left(  a_{j}%\r\n+b_{j}\\right)  }_{\\substack{=\\lambda_{S^{j}T}\\left(  a_{j}\\right)\r\n\\cdot\\lambda_{S^{j}T}\\left(  b_{j}\\right)  \\\\\\text{(since }\\lambda_{T}\\left(\r\na_{j}+b_{j}\\right)  =\\lambda_{T}\\left(  a_{j}\\right)  \\cdot\\lambda_{T}\\left(\r\nb_{j}\\right)  \\\\\\text{by Theorem 2.1 \\textbf{(a)})}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{thm.3.3.pf.a.lambdaol}), applied\r\nto }a_{j}+b_{j}\\text{ instead of }a_{j}\\right) \\\\\r\n&  =\\underbrace{\\prod\\limits_{j\\in\\mathbb{N}}\\lambda_{S^{j}T}\\left(\r\na_{j}\\right)  }_{\\substack{=\\overline{\\lambda}_{T}\\left(  \\sum\\limits_{j\\in\r\n\\mathbb{N}}a_{j}S^{j}\\right)  \\\\\\text{(by (\\ref{thm.3.3.pf.a.lambdaol}))}%\r\n}}\\cdot\\underbrace{\\prod\\limits_{j\\in\\mathbb{N}}\\lambda_{S^{j}T}\\left(\r\nb_{j}\\right)  }_{\\substack{=\\overline{\\lambda}_{T}\\left(  \\sum\\limits_{j\\in\r\n\\mathbb{N}}b_{j}S^{j}\\right)  \\\\\\text{(by (\\ref{thm.3.3.pf.a.lambdaol}),\r\napplied}\\\\\\text{to }b_{j}\\text{ instead of }a_{j}\\text{)}}}\\\\\r\n&  =\\overline{\\lambda}_{T}\\left(  \\underbrace{\\sum\\limits_{j\\in\\mathbb{N}%\r\n}a_{j}S^{j}}_{=x}\\right)  \\cdot\\overline{\\lambda}_{T}\\left(  \\underbrace{\\sum\r\n\\limits_{j\\in\\mathbb{N}}b_{j}S^{j}}_{=y}\\right)  =\\overline{\\lambda}%\r\n_{T}\\left(  x\\right)  \\cdot\\overline{\\lambda}_{T}\\left(  y\\right)  .\r\n\\end{align*}\r\nThus, (\\ref{thm.3.3.pf.a.goal}) is proven.\r\n\r\nAs we said, (\\ref{thm.3.3.pf.a.goal}) shows that $\\left(  K\\left[  S\\right]\r\n,\\left(  \\overline{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\n$\\lambda$-ring. The rest of Theorem 3.3 \\textbf{(a)} is yet easier to verify.\r\n\r\n\\textbf{(b)} We have $\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\right)\r\n=\\lambda_{S^{\\alpha}T}\\left(  a\\right)  $ as a particular case of\r\n(\\ref{thm.3.3.pf.a.lambdaol}). The equation $\\overline{\\lambda}^{i}\\left(\r\naS^{\\alpha}\\right)  =\\lambda^{i}\\left(  a\\right)  S^{\\alpha i}$ for every\r\n$i\\in\\mathbb{N}$ follows by comparing coefficients before $T^{i}$ in the\r\nequality $\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\right)  =\\lambda\r\n_{S^{\\alpha}T}\\left(  a\\right)  $. Thus, Theorem 3.3 \\textbf{(b)} is proven.\r\n\\end{proof}\r\n\r\nThe exercises below give some more examples.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 3.1.} Let $p\\in\\mathbb{N}$ be a prime. Prove that the\r\nlocalization $\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ of the ring\r\n$\\mathbb{Z}$ at the multiplicative subset $\\left\\{  1,p,p^{2},...\\right\\}  $\r\nis a binomial ring.\r\n\r\n\\textit{Exercise 3.2.} Let $K$ be a ring where none of the elements $1$, $2$,\r\n$3$, $...$ is a zero-divisor. Let $E$ be a subset of $K$ that generates $K$ as\r\na ring. Assume that $n!\\mid x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(\r\nx-n+1\\right)  $ for every $x\\in E$ and every $n\\in\\mathbb{N}$. Prove that $K$\r\nis a binomial ring.\r\n\r\n\\textit{Exercise 3.3.} \\textbf{(a)} Let $K$ be a binomial ring. Let $p\\in\r\nK\\left[  \\left[  T\\right]  \\right]  $ be a formal power series with\r\ncoefficient $1$ before $T^{0}$ (we will later denote the set of such power\r\nseries by $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$). For every\r\n$i\\in\\mathbb{N}$, define a map $\\lambda^{i}:K\\rightarrow K$ as follows: For\r\nevery $x\\in K$, let $\\lambda^{i}\\left(  x\\right)  $ be the coefficient of the\r\nformal power series $\\left(  1+pT\\right)  ^{x}$ (which is defined as\r\n$\\sum\\limits_{k\\in\\mathbb{N}}\\dbinom{x}{k}\\left(  pT\\right)  ^{k}%\r\n\\ \\ \\ \\ $\\footnote{If $K$ is a $\\mathbb{Q}$-algebra, then this power series\r\nalso equals $\\exp\\left(  x\\log\\left(  1+pT\\right)  \\right)  $, where\r\n$\\log\\left(  1+T\\right)  $ is the power series $\\log\\left(  1+T\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\dfrac{\\left(\r\n-1\\right)  ^{i-1}}{i}T^{i}$.}) before $T^{i}$. Prove that $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring.\r\n\r\n\\textbf{(b)} If $p=1$, prove that this $\\lambda$-ring is the one defined in\r\nTheorem 3.2.\r\n\r\n\\textit{Exercise 3.4.} Let $M$ be a commutative monoid, written\r\nmultiplicatively (this means, in particular, that we denote the neutral\r\nelement of $M$ as $1$). Define a $\\mathbb{Z}$-algebra $\\mathbb{Z}\\left[\r\nM\\right]  $ as follows:\r\n\r\nAs a $\\mathbb{Z}$-module, let $\\mathbb{Z}\\left[  M\\right]  $ be the free\r\n$\\mathbb{Z}$-module with the basis $M$. Let the multiplication on\r\n$\\mathbb{Z}\\left[  M\\right]  $ be the $\\mathbb{Z}$-linear extension of the\r\nmultiplication on the monoid $M$.\r\n\r\nFor every $i\\in\\mathbb{N}$, define a map $\\lambda^{i}:\\mathbb{Z}\\left[\r\nM\\right]  \\rightarrow\\mathbb{Z}\\left[  M\\right]  $ as follows: For every\r\n$\\sum\\limits_{m\\in M}\\alpha_{m}m\\in\\mathbb{Z}\\left[  M\\right]  $ (with\r\n$\\alpha_{m}\\in\\mathbb{Z}$ for every $m\\in M$), let $\\lambda^{i}\\left(\r\n\\sum\\limits_{m\\in M}\\alpha_{m}m\\right)  $ be the coefficient of the power\r\nseries $\\prod\\limits_{m\\in M}\\left(  1+mT\\right)  ^{\\alpha_{m}}\\in\\left(\r\n\\mathbb{Z}\\left[  M\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $\r\nbefore $T^{i}$.\r\n\r\nProve that $\\left(  \\mathbb{Z}\\left[  M\\right]  ,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring.\r\n\r\n\\textit{Exercise 3.5.} \\textbf{(a)} Let $M$ be a commutative monoid, written\r\nmultiplicatively (this means, in particular, that we denote the neutral\r\nelement of $M$ as $1$). Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring.\r\n\r\nDefine a $K$-algebra $K\\left[  M\\right]  $ as follows:\r\n\r\nAs a $K$-module, let $K\\left[  M\\right]  $ be the free $K$-module with the\r\nbasis $M$. Let the multiplication on $K\\left[  M\\right]  $ be the $K$-linear\r\nextension of the multiplication on the monoid $M$.\r\n\r\nFor every $i\\in\\mathbb{N}$, define a map $\\overline{\\lambda}^{i}:K\\left[\r\nM\\right]  \\rightarrow K\\left[  M\\right]  $ as follows: For every\r\n$\\sum\\limits_{m\\in M}\\alpha_{m}m\\in K\\left[  M\\right]  $ (with $\\alpha_{m}\\in\r\nK$ for every $m\\in M$), let $\\overline{\\lambda}^{i}\\left(  \\sum\\limits_{m\\in\r\nM}\\alpha_{m}m\\right)  $ be the coefficient of the power series $\\prod\r\n\\limits_{m\\in M}\\lambda_{mT}\\left(  \\alpha_{m}\\right)  \\in\\left(  K\\left[\r\nM\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $ before $T^{i}$, where\r\nthe power series $\\lambda_{mT}\\left(  \\alpha_{m}\\right)  \\in\\left(  K\\left[\r\nM\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $ is defined as\r\n$\\operatorname*{ev}_{mT}\\left(  \\lambda_{T}\\left(  \\alpha_{m}\\right)  \\right)\r\n$.\r\n\r\nProve that $\\left(  K\\left[  M\\right]  ,\\left(  \\overline{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. The ring $K$ is a\r\nsub-$\\lambda$-ring of $\\left(  K\\left[  M\\right]  ,\\left(  \\overline{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. For every $a\\in K$ and $m\\in M$, we\r\nhave $\\overline{\\lambda}^{i}\\left(  am\\right)  =\\lambda^{i}\\left(  a\\right)\r\nm^{i}$ for every $i\\in\\mathbb{N}$.\r\n\r\n\\textbf{(b)} Show that Exercise 3.4 is a particular case of \\textbf{(a)} for\r\n$K=\\mathbb{Z}$, and that Theorem 3.3 is a particular case of \\textbf{(a)} for\r\n$M\\cong\\mathbb{N}$ (where $\\mathbb{N}$ denotes the \\textit{additive} monoid\r\n$\\mathbb{N}$).\r\n\\end{quotation}\r\n\r\n\\section{Intermezzo: Symmetric polynomials}\r\n\r\nOur next plan is to introduce a rather general example of $\\lambda$-rings that\r\nwe will use as a prototype to the notion of \\textit{special }$\\lambda\r\n$\\textit{-rings}. Before we do this, we need some rather clumsy theory of\r\nsymmetric polynomials. In case you can take the proofs for granted, you don't\r\nneed to read much of this paragraph - you only need to know Theorems 4.3 and\r\n4.4 and the preceding definitions (only the goals of the definitions; not the\r\nactual constructions of the polynomials $P_{k}$ and $P_{k,j}$).\r\n\r\n\\subsection{Symmetric polynomials are generated by the elementary symmetric\r\nones}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 4.1 (characterization of symmetric polynomials).} Let $K$ be a\r\nring. Let $m\\in\\mathbb{N}$. Consider the ring $K\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $ (the polynomial ring in $m$ indeterminates $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$ over the ring $K$). For every $i\\in\\mathbb{N}$, let\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ be the so-called\r\n$i$\\textit{-th elementary symmetric polynomial} in the variables $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$. (In particular, $X_{0}=1$ and $X_{i}=0$ for every\r\n$i>m$.)\r\n\r\nA polynomial $P\\in K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ is called\r\n\\textit{symmetric} if it satisfies $P\\left(  U_{1},U_{2},...,U_{m}\\right)\r\n=P\\left(  U_{\\pi\\left(  1\\right)  },U_{\\pi\\left(  2\\right)  },...,U_{\\pi\r\n\\left(  m\\right)  }\\right)  $ for every permutation $\\pi$ of the set $\\left\\{\r\n1,2,...,m\\right\\}  $.\r\n\r\n\\textbf{(a)} Let $P\\in K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ be a symmetric\r\npolynomial. Then, there exists one and only one polynomial $Q\\in\r\n\\underbrace{K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n}_{\\text{polynomial ring}}$ such that $P\\left(  U_{1},U_{2},...,U_{m}\\right)\r\n=Q\\left(  X_{1},X_{2},...,X_{m}\\right)  $.\\ \\ \\ \\ \\footnote{In other words,\r\nthe $K$-subalgebra%\r\n\\[\r\n\\left\\{  P\\in K\\left[  U_{1},U_{2},...,U_{m}\\right]  \\ \\mid\\ P\\text{ is\r\nsymmetric}\\right\\}\r\n\\]\r\nof the polynomial ring $K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ is generated\r\nby the elements $X_{1}$, $X_{2}$, $...$, $X_{m}$. Moreover, these elements\r\n$X_{1}$, $X_{2}$, $...$, $X_{m}$ are algebraically independent; in other\r\nwords, the $K$-algebra homomorphism%\r\n\\[\r\n\\underbrace{K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n}_{\\text{polynomial ring}}\\rightarrow\\left\\{  P\\in K\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\ \\mid\\ P\\text{ is symmetric}\\right\\}\r\n\\]\r\nwhich maps every $\\alpha_{i}$ to $X_{i}$ is injective. Hence, this\r\nhomomorphism is an isomorphism.}\r\n\r\n\\textbf{(b)} Let $\\ell\\in\\mathbb{N}$. Assume, moreover, that $P\\in K\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ is a symmetric polynomial of total degree\r\n$\\leq\\ell$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$. Consider the\r\nunique polynomial $Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n$ from Theorem 4.1 \\textbf{(a)}. Then, the variables $\\alpha_{i}$ for $i>\\ell$\r\ndo not appear in the polynomial $Q$.\r\n\r\nThere is a canonical homomorphism $K\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{m}\\right]  \\rightarrow K\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{\\ell}\\right]  $ (which maps every $\\alpha_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\alpha_{i},\\text{ if }i\\leq\\ell;\\\\\r\n0,\\text{ if }i>\\ell\r\n\\end{array}\r\n\\right.  $)\\ \\ \\ \\ \\footnote{This homomorphism is a surjection if $\\ell\\leq m$\r\nand an injection if $\\ell\\geq m$.}. If we denote by $Q_{\\ell}$ the image of\r\n$Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ under this\r\nhomomorphism, then, $P\\left(  U_{1},U_{2},...,U_{m}\\right)  =Q\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  =Q_{\\ell}\\left(  X_{1},X_{2},...,X_{\\ell\r\n}\\right)  $.\r\n\\end{quote}\r\n\r\nWe are not going to prove Theorem 4.1 here, since it is a fairly well-known\r\nfact\\footnote{Proofs of Theorem 4.1 \\textbf{(a)} can be found in \\cite[proof\r\nof Theorem 1]{BluCos16}, in \\cite[Theorem 1.2.1]{Dumas08}, in \\cite[Chapter\r\nII, Theorem 8.1]{MiRiRu88}, in \\cite[Remark 4.16]{Neusel07}, in \\cite[\\S 1.1]%\r\n{Smith95} or in \\cite[Chapter 7, \\S 1, proof of Theorem 3]{CoLiOS15}. (Some of\r\nthese sources only state the result in the case when $K$ is a field, or when\r\n$K=\\mathbb{C}$; but the same proof applies more generally for any ring $K$.)\r\nVarious other sources give proofs of Theorem 4.1 \\textbf{(a)} under the\r\ncondition that $K$ is a field (or that $K=\\mathbb{C}$), but they can easily be\r\nmodified so that they become complete proofs of Theorem 4.1 \\textbf{(a)} for\r\nany commutative ring $K$. (For instance, in order to make a complete proof of\r\nThorem 4.1 \\textbf{(a)} out of \\cite[proof of Theorem 2.1.1]{DraGij09}, it\r\nsuffices to replace every occurence of $\\mathbb{C}$ by $K$, and to add the\r\nextra condition \\textquotedblleft the leading monomial of $f$ has coefficient\r\n$1$ in $f$\\textquotedblright\\ to \\cite[Exercise 2.1.2]{DraGij09}.) Also,\r\nvarious textbooks make claims which are easily seen to be equivalent to\r\nTheorem 4.1 \\textbf{(a)} (for example, \\cite[Theorems 3.4 and 3.5]{Newman12}).\r\nNote that I am not saying that all these proofs are distinct; in fact, many of\r\nthem are essentially identical (although written up in slightly different\r\nfashions and with varying levels of detail and constructiveness). Beware of\r\ntexts that use Galois theory to prove Theorem 4.1 \\textbf{(a)} in the case\r\nwhen $K$ is a field; such proofs usually don't generalize to the case when $K$\r\nis an arbitrary commutative ring (although they, too, can be salvaged with a\r\nbit of work: it is not too hard to derive the general case from the case when\r\n$K$ is a field).\r\n\\par\r\nVarious sources prove a result that is easily seen to be equivalent to Theorem\r\n4.1 \\textbf{(a)}. Namely, they prove the following result:\r\n\\par\r\n\\begin{quote}\r\n\\textbf{Theorem 4.1'.} Let $K$, $m$, $\\left(  U_{1},U_{2},\\ldots,U_{m}\\right)\r\n$ and $X_{i}$ be as in Theorem 4.1. Let $\\mathcal{S}$ be the $K$-module\r\nconsisting of all symmetric polynomials $P\\in K\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $. Then, the family $\\left(  X_{1}^{i_{1}}X_{2}^{i_{2}%\r\n}\\cdots X_{m}^{i_{m}}\\right)  _{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}$ is a basis of the $K$-module $\\mathcal{S}$.\r\n\\end{quote}\r\n\\par\r\nFor example, Theorem 4.1' is \\cite[(5.10) in Chapter SYM]{LLPT}.\r\n\\par\r\nLet us briefly explain how Theorem 4.1 \\textbf{(a)} follows from Theorem 4.1':\r\n\\par\r\n\\textit{[Proof of Theorem 4.1 \\textbf{(a)} using Theorem 4.1':} A family\r\n$\\left(  k_{g}\\right)  _{g\\in G}\\in K^{G}$ of elements of $K$ (where $G$ is an\r\narbitrary set) is said to be \\textit{finitely supported} if all but finitely\r\nmany $g\\in G$ satisfy $k_{g}=0$.\r\n\\par\r\nNotice that the finitely supported families $\\left(  k_{\\left(  i_{1}%\r\n,i_{2},\\ldots,i_{m}\\right)  }\\right)  _{\\left(  i_{1},i_{2},\\ldots\r\n,i_{m}\\right)  \\in\\mathbb{N}^{m}}\\in K^{\\mathbb{N}^{m}}$ of elements of $K$\r\nare in bijection with the polynomials in the polynomial ring $K\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $. Indeed, the bijection maps\r\neach finitely supported family $\\left(  k_{\\left(  i_{1},i_{2},\\ldots\r\n,i_{m}\\right)  }\\right)  _{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}$ to the polynomial $\\sum\\limits_{\\left(  i_{1},i_{2}%\r\n,\\ldots,i_{m}\\right)  \\in\\mathbb{N}^{m}}k_{\\left(  i_{1},i_{2},\\ldots\r\n,i_{m}\\right)  }\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}}\\cdots\\alpha_{m}^{i_{m}}$.\r\n\\par\r\nWe know that $P$ is a symmetric polynomial in $K\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $. In other words, $P\\in\\mathcal{S}$ (by the definition of\r\n$\\mathcal{S}$).\r\n\\par\r\nBut Theorem 4.1' shows that the family $\\left(  X_{1}^{i_{1}}X_{2}^{i_{2}%\r\n}\\cdots X_{m}^{i_{m}}\\right)  _{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}$ is a basis of the $K$-module $\\mathcal{S}$. Hence, $P$ can\r\nbe uniquely written as a $K$-linear combination of the elements of the family\r\n$\\left(  X_{1}^{i_{1}}X_{2}^{i_{2}}\\cdots X_{m}^{i_{m}}\\right)  _{\\left(\r\ni_{1},i_{2},\\ldots,i_{m}\\right)  \\in\\mathbb{N}^{m}}$ (since $P\\in\\mathcal{S}%\r\n$). In other words, there is a unique finitely supported family $\\left(\r\nk_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)  }\\right)  _{\\left(  i_{1}%\r\n,i_{2},\\ldots,i_{m}\\right)  \\in\\mathbb{N}^{m}}\\in K^{\\mathbb{N}^{m}}$ of\r\nelements of $K$ satisfying $P=\\sum\\limits_{\\left(  i_{1},i_{2},\\ldots\r\n,i_{m}\\right)  \\in\\mathbb{N}^{m}}k_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n}X_{1}^{i_{1}}X_{2}^{i_{2}}\\cdots X_{m}^{i_{m}}$.\r\n\\par\r\nIn other words, there is a unique polynomial $\\sum\\limits_{\\left(  i_{1}%\r\n,i_{2},\\ldots,i_{m}\\right)  \\in\\mathbb{N}^{m}}k_{\\left(  i_{1},i_{2}%\r\n,\\ldots,i_{m}\\right)  }\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}}\\cdots\\alpha\r\n_{m}^{i_{m}}\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $\r\nsatisfying $P=\\sum\\limits_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}k_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)  }X_{1}^{i_{1}%\r\n}X_{2}^{i_{2}}\\cdots X_{m}^{i_{m}}$ (because the finitely supported families\r\n$\\left(  k_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)  }\\right)  _{\\left(\r\ni_{1},i_{2},\\ldots,i_{m}\\right)  \\in\\mathbb{N}^{m}}\\in K^{\\mathbb{N}^{m}}$ of\r\nelements of $K$ are in bijection with the polynomials in $K\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $).\r\n\\par\r\nRenaming the polynomial $\\sum\\limits_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}k_{\\left(  i_{1},i_{2},\\ldots,i_{m}\\right)  }\\alpha\r\n_{1}^{i_{1}}\\alpha_{2}^{i_{2}}\\cdots\\alpha_{m}^{i_{m}}$ as $Q$ in this\r\nstatement, we obtain the following: There is a unique polynomial $Q\\in\r\nK\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ satisfying $P=Q\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  $. In other words, there is a unique polynomial\r\n$Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ satisfying\r\n$P\\left(  U_{1},U_{2},...,U_{m}\\right)  =Q\\left(  X_{1},X_{2},...,X_{m}%\r\n\\right)  $ (since $P\\left(  U_{1},U_{2},...,U_{m}\\right)  =P$). This proves\r\nTheorem 4.1 \\textbf{(a)}.]\r\n\\par\r\nThe first claim of Theorem 4.1 \\textbf{(b)} (namely, that the variables\r\n$\\alpha_{i}$ for $i>\\ell$ do not appear in the polynomial $Q$) can easily be\r\nobtained from the proof of Theorem 4.1 \\textbf{(a)}: In fact, each of the\r\nabove-mentioned proofs of Theorem 4.1 \\textbf{(a)} provides an actual\r\nalgorithm to find the polynomial $Q$, and this algorithm does not ever\r\nincrease the total degree of $P$ in the process. Thus, the first claim of\r\nTheorem 4.1 \\textbf{(b)} follows. The second claim of Theorem 4.1 \\textbf{(b)}\r\nfollows from the first (indeed, we have $Q\\left(  X_{1},X_{2},...,X_{m}%\r\n\\right)  =Q_{\\ell}\\left(  X_{1},X_{2},...,X_{\\ell}\\right)  $, because the\r\nvariables $\\alpha_{i}$ for $i>\\ell$ do not appear in the polynomial $Q$).\r\n\\par\r\n[\\textit{Remark:} Theorem 4.1 \\textbf{(b)} can be strengthened: Namely, we can\r\nreplace the assumption that $P$ has total degree $\\leq\\ell$ by the (weaker)\r\nassumption that $P$ is a $K$-linear combination of monomials of the form\r\n$U_{1}^{a_{1}}U_{2}^{a_{2}}\\cdots U_{m}^{a_{m}}$ where each $a_{i}$ is\r\n$\\leq\\ell$. This stronger version, again, can be easily derived from the\r\nclassical proofs of Theorem 4.1 \\textbf{(a)}.]}. But we are going to extend it\r\nto two sets of indeterminates:\r\n\r\nLet us state one piece of Theorem 4.1 \\textbf{(a)} separately, to facilitate\r\nits later use:\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 4.1a.} Let $K$ be a ring. Let $m\\in\\mathbb{N}$. Consider the\r\nring $K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (the polynomial ring in $m$\r\nindeterminates $U_{1}$, $U_{2}$, $...$, $U_{m}$ over the ring $K$). For every\r\n$i\\in\\mathbb{N}$, let $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$\r\nbe the so-called $i$\\textit{-th elementary symmetric polynomial} in the\r\nvariables $U_{1}$, $U_{2}$, $...$, $U_{m}$. (In particular, $X_{0}=1$ and\r\n$X_{i}=0$ for every $i>m$.)\r\n\r\nThen, the elements $X_{1}$, $X_{2}$, $...$, $X_{m}$ of $K\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $ are algebraically independent (over $K$).\r\n\\end{quote}\r\n\r\n\\subsection{UV-symmetric polynomials are generated by the elementary symmetric\r\nones}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 4.2 (characterization of UV-symmetric polynomials).} Let $K$\r\nbe a ring. Let $m\\in\\mathbb{N}$ and $n\\in\\mathbb{N}$. Consider the ring\r\n$K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $ (the\r\npolynomial ring in $m+n$ indeterminates $U_{1}$, $U_{2}$, $...$, $U_{m}$,\r\n$V_{1}$, $V_{2}$, $...$, $V_{n}$ over the ring $K$). For every $i\\in\r\n\\mathbb{N}$, let $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$\r\nbe the $i$-th elementary symmetric polynomial in the variables $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$. For every $j\\in\\mathbb{N}$, let $Y_{j}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =j}}\\prod\\limits_{k\\in S}V_{k}$ be the $j$-th elementary\r\nsymmetric polynomial in the variables $V_{1}$, $V_{2}$, $...$, $V_{n}$.\r\n\r\nA polynomial $P\\in K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}%\r\n\\right]  $ is called \\textit{UV-symmetric} if it satisfies%\r\n\\[\r\nP\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)  =P\\left(\r\nU_{\\pi\\left(  1\\right)  },U_{\\pi\\left(  2\\right)  },...,U_{\\pi\\left(\r\nm\\right)  },V_{\\sigma\\left(  1\\right)  },V_{\\sigma\\left(  2\\right)\r\n},...,V_{\\sigma\\left(  n\\right)  }\\right)\r\n\\]\r\nfor every permutation $\\pi$ of the set $\\left\\{  1,2,...,m\\right\\}  $ and\r\nevery permutation $\\sigma$ of the set $\\left\\{  1,2,...,n\\right\\}  $.\r\n\r\n\\textbf{(a)} Let $P\\in K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2}%\r\n,...,V_{n}\\right]  $ be a UV-symmetric polynomial. Then, there exists one and\r\nonly one polynomial $Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}%\r\n,\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ such that $P\\left(  U_{1}%\r\n,U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)  =Q\\left(  X_{1},X_{2}%\r\n,...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right)  $.\\ \\ \\ \\ \\footnote{In other words,\r\nthe $K$-subalgebra%\r\n\\[\r\n\\left\\{  P\\in K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]\r\n\\ \\mid\\ P\\text{ is UV-symmetric}\\right\\}\r\n\\]\r\nof the polynomial ring $K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2}%\r\n,...,V_{n}\\right]  $ is generated by the elements $X_{1}$, $X_{2}$, $...$,\r\n$X_{m}$, $Y_{1}$, $Y_{2}$, $...$, $Y_{n}$. Moreover, these elements $X_{1}$,\r\n$X_{2}$, $...$, $X_{m}$, $Y_{1}$, $Y_{2}$, $...$, $Y_{n}$ are algebraically\r\nindependent; in other words, the $K$-algebra homomorphism%\r\n\\[\r\n\\underbrace{K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta\r\n_{2},...,\\beta_{n}\\right]  }_{\\text{polynomial ring}}\\rightarrow\\left\\{  P\\in\r\nK\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  \\ \\mid\\ P\\text{\r\nis UV-symmetric}\\right\\}\r\n\\]\r\nwhich maps every $\\alpha_{i}$ to $X_{i}$ and every $\\beta_{j}$ to $Y_{j}$ is\r\ninjective. Hence, this homomorphism is an isomorphism.}\r\n\r\n\\textbf{(b)} Let $\\ell\\in\\mathbb{N}$ and $k\\in\\mathbb{N}$. Assume, moreover,\r\nthat $P\\in K\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $ is a\r\nUV-symmetric polynomial of total degree $\\leq\\ell$ in the variables $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$ and of total degree $\\leq k$ in the variables $V_{1}$,\r\n$V_{2}$, $...$, $V_{n}$. Consider the unique polynomial $Q\\in K\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]\r\n$ from Theorem 4.2 \\textbf{(a)}. Then, neither the variables $\\alpha_{i}$ for\r\n$i>\\ell$ nor the variables $\\beta_{j}$ for $j>k$ ever appear in the polynomial\r\n$Q$.\r\n\r\nThere is a canonical homomorphism%\r\n\\[\r\nK\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2}%\r\n,...,\\beta_{n}\\right]  \\rightarrow K\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{\\ell},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]\r\n\\]\r\n(which maps every $\\alpha_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\alpha_{i},\\text{ if }i\\leq\\ell;\\\\\r\n0,\\text{ if }i>\\ell\r\n\\end{array}\r\n\\right.  $ and every $\\beta_{j}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\beta_{j},\\text{ if }j\\leq k;\\\\\r\n0,\\text{ if }j>k\r\n\\end{array}\r\n\\right.  $). If we denote by $Q_{\\ell,k}$ the image of $Q\\in K\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]\r\n$ under this homomorphism, then%\r\n\\[\r\nP\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)  =Q_{\\ell\r\n,k}\\left(  X_{1},X_{2},...,X_{\\ell},Y_{1},Y_{2},...,Y_{k}\\right)  .\r\n\\]\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 4.2.]\\textbf{(a)} Consider $P$ as a polynomial in the\r\nindeterminates $V_{1}$, $V_{2}$, $...$, $V_{n}$ over the ring $K\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $. Then, $P$ is a symmetric polynomial in these\r\nindeterminates $V_{1}$, $V_{2}$, $...$, $V_{n}$ (since $P$ is UV-symmetric),\r\nso Theorem 4.1 \\textbf{(a)} (applied to $n$, $K\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $, $\\left(  V_{1},V_{2},\\ldots,V_{n}\\right)  $, $Y_{i}$,\r\n$\\left(  \\beta_{1},\\beta_{2},\\ldots,\\beta_{n}\\right)  $ and $\\widehat{Q}$\r\ninstead of $m$, $K$, $\\left(  U_{1},U_{2},...,U_{m}\\right)  $, $X_{i}$,\r\n$\\left(  \\alpha_{1},\\alpha_{2},\\ldots,\\alpha_{m}\\right)  $ and $Q$) yields the\r\nexistence of one and only one polynomial $\\widehat{Q}\\in\\underbrace{\\left(\r\nK\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\beta_{1},\\beta\r\n_{2},...,\\beta_{n}\\right]  }_{\\text{polynomial ring}}$ such that $P\\left(\r\nU_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)  =\\widehat{Q}\\left(\r\nY_{1},Y_{2},...,Y_{n}\\right)  $. Consider this $\\widehat{Q}$.\r\n\r\nFor every $n$-tuple $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$, let $Q_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda\r\n_{n}\\right)  }\\in K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ be the coefficient\r\nof this polynomial $\\widehat{Q}$ before $\\beta_{1}^{\\lambda_{1}}\\beta\r\n_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}$. Thus,%\r\n\\begin{equation}\r\n\\widehat{Q}=\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }\\beta_{1}^{\\lambda_{1}}\\beta_{2}^{\\lambda_{2}}...\\beta\r\n_{n}^{\\lambda_{n}}. \\label{4.2.pf.a.1}%\r\n\\end{equation}\r\nNow,%\r\n\\begin{align}\r\n&  P\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right) \\nonumber\\\\\r\n&  =\\widehat{Q}\\left(  Y_{1},Y_{2},...,Y_{n}\\right)  =\\sum_{\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{N}^{n}}Q_{\\left(\r\n\\lambda_{1},\\lambda_{2},\\ldots,\\lambda_{n}\\right)  }Y_{1}^{\\lambda_{1}}%\r\nY_{2}^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}} \\label{4.2.pf.a.2}%\r\n\\end{align}\r\n(this follows by evaluating both sides of (\\ref{4.2.pf.a.1}) at $\\left(\r\n\\beta_{1},\\beta_{2},\\ldots,\\beta_{n}\\right)  =\\left(  Y_{1},Y_{2},\\ldots\r\n,Y_{n}\\right)  $).\r\n\r\nNow, for every $n$-tuple $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda\r\n_{n}\\right)  \\in\\mathbb{N}^{n}$, the polynomial $Q_{\\left(  \\lambda\r\n_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }$ is a symmetric polynomial in the\r\nvariables $U_{1}$, $U_{2}$, $...$, $U_{m}$\\ \\ \\ \\ \\footnote{\\textit{Proof.}\r\nLet $\\sigma\\in S_{m}$. If we substitute $U_{\\sigma\\left(  1\\right)\r\n},U_{\\sigma\\left(  2\\right)  },\\ldots,U_{\\sigma\\left(  m\\right)  },V_{1}%\r\n,V_{2},\\ldots,V_{n}$ for $U_{1},U_{2},\\ldots,U_{m},V_{1},V_{2},\\ldots,V_{n}$\r\non both sides of the equality (\\ref{4.2.pf.a.2}), then we obtain%\r\n\\begin{align*}\r\n&  P\\left(  U_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)\r\n},...,U_{\\sigma\\left(  m\\right)  },V_{1},V_{2},...,V_{n}\\right) \\\\\r\n&  =\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }\\left(  U_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)\r\n},...,U_{\\sigma\\left(  m\\right)  }\\right)  Y_{1}^{\\lambda_{1}}Y_{2}%\r\n^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}}%\r\n\\end{align*}\r\n(indeed, the polynomials $Y_{1},Y_{2},\\ldots,Y_{n}$ stay the same under this\r\nsubstitution, since they are built of the variables $V_{1},V_{2},\\ldots,V_{n}%\r\n$). Hence,%\r\n\\begin{align*}\r\n&  \\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\r\n\\mathbb{N}^{n}}Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda_{n}\\right)\r\n}\\left(  U_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)\r\n},...,U_{\\sigma\\left(  m\\right)  }\\right)  Y_{1}^{\\lambda_{1}}Y_{2}%\r\n^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}}\\\\\r\n&  =P\\left(  U_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)\r\n},...,U_{\\sigma\\left(  m\\right)  },V_{1},V_{2},...,V_{n}\\right) \\\\\r\n&  =P\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }P\\text{ is UV-symmetric}\\right) \\\\\r\n&  =\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }Y_{1}^{\\lambda_{1}}Y_{2}^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{4.2.pf.a.2})}\\right)  .\r\n\\end{align*}\r\nSubtracting the right hand side of this equation from the left, we obtain%\r\n\\begin{align}\r\n&  \\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\r\n\\mathbb{N}^{n}}\\left(  Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }\\left(  U_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)\r\n},...,U_{\\sigma\\left(  m\\right)  }\\right)  -Q_{\\left(  \\lambda_{1},\\lambda\r\n_{2},\\ldots,\\lambda_{n}\\right)  }\\right)  Y_{1}^{\\lambda_{1}}Y_{2}%\r\n^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}}\\nonumber\\\\\r\n&  =0. \\label{4.2.pf.a.fn1.pf.1}%\r\n\\end{align}\r\nBut $Y_{1}$, $Y_{2}$, $...$, $Y_{n}$ are algebraically independent over\r\n$K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (as we can see by applying Corollary\r\n4.1a to $n$, $K\\left[  U_{1},U_{2},...,U_{m}\\right]  $, $\\left(  V_{1}%\r\n,V_{2},\\ldots,V_{n}\\right)  $ and $Y_{i}$ instead of $m$, $K$, $\\left(\r\nU_{1},U_{2},...,U_{m}\\right)  $ and $X_{i}$). Hence, (\\ref{4.2.pf.a.fn1.pf.1})\r\nentails that%\r\n\\[\r\nQ_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda_{n}\\right)  }\\left(\r\nU_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)  },...,U_{\\sigma\\left(\r\nm\\right)  }\\right)  -Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }=0\r\n\\]\r\nfor every $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$. In other words,%\r\n\\begin{equation}\r\nQ_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda_{n}\\right)  }\\left(\r\nU_{\\sigma\\left(  1\\right)  },U_{\\sigma\\left(  2\\right)  },...,U_{\\sigma\\left(\r\nm\\right)  }\\right)  =Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  } \\label{4.2.pf.a.fn1.pf.2}%\r\n\\end{equation}\r\nfor every $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$.\r\n\\par\r\nNow, forget that we fixed $\\sigma$. We thus have shown that\r\n(\\ref{4.2.pf.a.fn1.pf.2}) holds for every $\\sigma\\in S_{m}$ and every $\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{N}^{n}$.\r\n\\par\r\nNow, fix $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$. As we know, (\\ref{4.2.pf.a.fn1.pf.2}) holds for every\r\n$\\sigma\\in S_{m}$. Hence,\r\n\\[\r\nQ_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda_{n}\\right)  }\\left(\r\nU_{1},U_{2},\\ldots,U_{m}\\right)  =Q_{\\left(  \\lambda_{1},\\lambda_{2}%\r\n,\\ldots,\\lambda_{n}\\right)  }=Q_{\\left(  \\lambda_{1},\\lambda_{2}%\r\n,\\ldots,\\lambda_{n}\\right)  }\\left(  U_{\\sigma\\left(  1\\right)  }%\r\n,U_{\\sigma\\left(  2\\right)  },...,U_{\\sigma\\left(  m\\right)  }\\right)\r\n\\]\r\n(by (\\ref{4.2.pf.a.fn1.pf.2})) holds for every $\\sigma\\in S_{m}$. In other\r\nwords, the polynomial $Q_{\\left(  \\lambda_{1},\\lambda_{2},\\ldots,\\lambda\r\n_{n}\\right)  }$ is symmetric. Qed.}. Hence, by Theorem 4.1 \\textbf{(a)}\r\n(applied to $Q_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }$\r\ninstead of $P$), there exists one and only one polynomial $R_{\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }\\in\\underbrace{K\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  }_{\\text{polynomial ring}}$ such\r\nthat%\r\n\\[\r\nQ_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=R_{\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }\\left(  X_{1},X_{2}%\r\n,...,X_{m}\\right)  .\r\n\\]\r\nConsider this $R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }$.\r\nNow, (\\ref{4.2.pf.a.2}) becomes\r\n\\begin{align*}\r\n&  P\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right) \\\\\r\n&  =\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}\\underbrace{Q_{\\left(  \\lambda_{1},\\lambda_{2}%\r\n,\\ldots,\\lambda_{n}\\right)  }}_{=R_{\\left(  \\lambda_{1},\\lambda_{2}%\r\n,...,\\lambda_{n}\\right)  }\\left(  X_{1},X_{2},...,X_{m}\\right)  }%\r\nY_{1}^{\\lambda_{1}}Y_{2}^{\\lambda_{2}}...Y_{n}^{\\lambda_{n}}\\\\\r\n&  =\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}\\left(  X_{1},X_{2},...,X_{m}\\right)  Y_{1}^{\\lambda_{1}}Y_{2}^{\\lambda_{2}%\r\n}...Y_{n}^{\\lambda_{n}}.\r\n\\end{align*}\r\nThus, the polynomial $Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}%\r\n,\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ defined by%\r\n\\begin{equation}\r\nQ=\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\r\n\\mathbb{N}^{n}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right)  \\beta_{1}^{\\lambda_{1}%\r\n}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}} \\label{4.2.pf.a.defQ}%\r\n\\end{equation}\r\nsatisfies $P\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)\r\n=Q\\left(  X_{1},X_{2},...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right)  $. It only\r\nremains to prove that this is the only such polynomial. This amounts to\r\nshowing that $X_{1}$, $X_{2}$, $...$, $X_{m}$, $Y_{1}$, $Y_{2}$, $...$,\r\n$Y_{n}$ are algebraically independent over $K$. But this is clear (from\r\nExercise 4.3, applied to $S=K\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $, $T=K\\left[  U_{1},U_{2},...,U_{m}\\right]  $,\r\n$p_{i}=X_{i}$ and $q_{j}=Y_{j}$), since $X_{1}$, $X_{2}$, $...$, $X_{m}$ are\r\nalgebraically independent over $K$ (by Corollary 4.1a) and since $Y_{1}$,\r\n$Y_{2}$, $...$, $Y_{n}$ are algebraically independent over $K\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ (by Corollary 4.1a, applied to $n$, $K\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $, $\\left(  V_{1},V_{2},\\ldots,V_{n}\\right)  $\r\nand $Y_{i}$ instead of $m$, $K$, $\\left(  U_{1},U_{2},...,U_{m}\\right)  $ and\r\n$X_{i}$).\r\n\r\n\\textbf{(b)} Consider the polynomials $\\widehat{Q}$, $Q_{\\left(  \\lambda\r\n_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }$, $R_{\\left(  \\lambda_{1}%\r\n,\\lambda_{2},...,\\lambda_{n}\\right)  }$ and $Q$ defined in our proof of\r\nTheorem 4.2 \\textbf{(a)}.\r\n\r\nThe first claim of Theorem 4.1 \\textbf{(b)} (applied to $n$, $K\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $, $\\left(  V_{1},V_{2},\\ldots,V_{n}\\right)  $,\r\n$Y_{i}$, $\\left(  \\beta_{1},\\beta_{2},\\ldots,\\beta_{n}\\right)  $,\r\n$\\widehat{Q}$ and $k$ instead of $m$, $K$, $\\left(  U_{1},U_{2},...,U_{m}%\r\n\\right)  $, $X_{i}$, $\\left(  \\alpha_{1},\\alpha_{2},\\ldots,\\alpha_{m}\\right)\r\n$, $Q$ and $\\ell$) yields that the variables $\\beta_{j}$ for $j>k$ do not\r\nappear in the polynomial $\\widehat{Q}$. Hence, the coefficient of the\r\npolynomial $\\widehat{Q}$ before any monomial $\\beta_{1}^{\\lambda_{1}}\\beta\r\n_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}$ is $0$ unless this monomial\r\nsatisfies $\\lambda_{k+1}=\\lambda_{k+2}=\\cdots=\\lambda_{n}=0$. Since this\r\ncoefficient has been denoted by $Q_{\\left(  \\lambda_{1},\\lambda_{2}%\r\n,...,\\lambda_{n}\\right)  }$, we can rewrite this as follows: We have\r\n\\begin{equation}\r\nQ_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=0\r\n\\label{4.2.pf.b.1}%\r\n\\end{equation}\r\nfor every $n$-tuple $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$ that fails to satisfy $\\lambda_{k+1}=\\lambda_{k+2}%\r\n=\\cdots=\\lambda_{n}=0$. From this, we obtain%\r\n\\begin{equation}\r\nR_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=0\r\n\\label{4.2.pf.b.2}%\r\n\\end{equation}\r\nfor every $n$-tuple $\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}$ that fails to satisfy $\\lambda_{k+1}=\\lambda_{k+2}%\r\n=\\cdots=\\lambda_{n}=0$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Fix some $\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{N}^{n}$ that fails\r\nto satisfy $\\lambda_{k+1}=\\lambda_{k+2}=\\cdots=\\lambda_{n}=0$. We must show\r\nthat $R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=0$.\r\n\\par\r\nRecall that $Q_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}=R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  $. Hence, $R_{\\left(  \\lambda_{1},\\lambda\r\n_{2},...,\\lambda_{n}\\right)  }\\left(  X_{1},X_{2},...,X_{m}\\right)\r\n=Q_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=0$ (by\r\n(\\ref{4.2.pf.b.1})). Since $X_{1},X_{2},\\ldots,X_{m}$ are algebraically\r\nindependent over $K$ (by Corollary 4.1a), this entails that $R_{\\left(\r\n\\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }=0$. This proves\r\n(\\ref{4.2.pf.b.2}).}.\r\n\r\nConsider the polynomial ring $K\\left[  \\alpha_{1},\\alpha_{2},\\alpha_{3}%\r\n,\\ldots,\\beta_{1},\\beta_{2},\\beta_{3},\\ldots\\right]  $ in the infinitely many\r\nvariables $\\alpha_{i}$ (for $i\\in\\left\\{  1,2,3,\\ldots\\right\\}  $) and\r\n$\\beta_{j}$ (for $j\\in\\left\\{  1,2,3,\\ldots\\right\\}  $). For any\r\n$u\\in\\mathbb{N}$ and $v\\in\\mathbb{N}$, we shall consider the polynomial ring\r\n$K\\left[  \\alpha_{1},\\alpha_{2},\\ldots,\\alpha_{u},\\beta_{1},\\beta_{2}%\r\n,\\ldots,\\beta_{v}\\right]  $ as a subring of $K\\left[  \\alpha_{1},\\alpha\r\n_{2},\\alpha_{3},\\ldots,\\beta_{1},\\beta_{2},\\beta_{3},\\ldots\\right]  $ (by\r\nabuse of notation).\r\n\r\nNow, recall how $Q$ has been defined in (\\ref{4.2.pf.a.defQ}).\r\nThus,\\footnote{In the following computation, we are WLOG assuming that $k\\leq\r\nn$. Indeed, this assumption is legitimate, because in the case when $k>n$, the\r\nresult of the computation (namely, the claim that $Q\\in K\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $) is\r\nobvious anyway.}%\r\n\\begin{align*}\r\nQ  &  =\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right)  \\beta_{1}^{\\lambda_{1}%\r\n}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}\\\\\r\n&  =\\sum_{\\substack{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n};\\\\\\lambda_{k+1}=\\lambda_{k+2}=\\cdots=\\lambda_{n}%\r\n=0}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right)  \\underbrace{\\beta_{1}%\r\n^{\\lambda_{1}}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}}%\r\n_{\\substack{=\\beta_{1}^{\\lambda_{1}}\\beta_{2}^{\\lambda_{2}}...\\beta\r\n_{k}^{\\lambda_{k}}\\\\\\text{(since }\\lambda_{k+1}=\\lambda_{k+2}=\\cdots\r\n=\\lambda_{n}=0\\text{)}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\sum_{\\substack{\\left(  \\lambda_{1},\\lambda\r\n_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{N}^{n};\\\\\\text{not }\\lambda\r\n_{k+1}=\\lambda_{k+2}=\\cdots=\\lambda_{n}=0}}\\underbrace{R_{\\left(  \\lambda\r\n_{1},\\lambda_{2},...,\\lambda_{n}\\right)  }\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m}\\right)  }_{\\substack{=0\\\\\\text{(by (\\ref{4.2.pf.b.2}))}%\r\n}}\\beta_{1}^{\\lambda_{1}}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}\\\\\r\n&  =\\underbrace{\\sum_{\\substack{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda\r\n_{n}\\right)  \\in\\mathbb{N}^{n};\\\\\\lambda_{k+1}=\\lambda_{k+2}=\\cdots\r\n=\\lambda_{n}=0}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right)  \\beta_{1}^{\\lambda_{1}%\r\n}\\beta_{2}^{\\lambda_{2}}...\\beta_{k}^{\\lambda_{k}}}_{\\in K\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\underbrace{\\sum_{\\substack{\\left(  \\lambda\r\n_{1},\\lambda_{2},...,\\lambda_{n}\\right)  \\in\\mathbb{N}^{n};\\\\\\text{not\r\n}\\lambda_{k+1}=\\lambda_{k+2}=\\cdots=\\lambda_{n}=0}}0\\beta_{1}^{\\lambda_{1}%\r\n}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}}_{=0}\\\\\r\n&  \\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta\r\n_{2},...,\\beta_{k}\\right]  .\r\n\\end{align*}\r\nHence, the variables $\\beta_{j}$ for $j>k$ do not appear in the polynomial\r\n$Q$. A similar argument (but in which the roles of $m$, of $U_{i}$, of $X_{i}%\r\n$, of $\\alpha_{i}$ and of $\\ell$ are switched with the roles of $n$, of\r\n$V_{i}$, of $Y_{i}$, of $\\beta_{i}$ and of $k$) shows that the variables\r\n$\\alpha_{i}$ for $i>\\ell$ do not appear in the polynomial $Q$. Thus, we know\r\nthat neither the variables $\\alpha_{i}$ for $i>\\ell$ nor the variables\r\n$\\beta_{j}$ for $j>k$ ever appear in the polynomial $Q$. Therefore, the\r\nvariables which do appear in the polynomial $Q$ remain unchanged under the\r\nhomomorphism which sends $Q$ to $Q_{\\ell,k}$. Therefore, $Q_{\\ell,k}=Q$.\r\nTherefore,%\r\n\\[\r\nQ_{\\ell,k}\\left(  X_{1},X_{2},...,X_{\\ell},Y_{1},Y_{2},...,Y_{k}\\right)\r\n=Q\\left(  X_{1},X_{2},...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right)  .\r\n\\]\r\nHence,%\r\n\\begin{align*}\r\nP\\left(  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right)   &  =Q\\left(\r\nX_{1},X_{2},...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right) \\\\\r\n&  =Q_{\\ell,k}\\left(  X_{1},X_{2},...,X_{\\ell},Y_{1},Y_{2},...,Y_{k}\\right)  .\r\n\\end{align*}\r\nThis completes the proof of Theorem 4.2 \\textbf{(b)}.\r\n\\end{proof}\r\n\r\nNote that in the following, we are going to use Theorems 4.1 and 4.2 for\r\n$K=\\mathbb{Z}$ only, until Section 10 where we actually get to use them for\r\ngeneral $K$.\r\n\r\n\\subsection{Grothendieck's polynomials $P_{k}$}\r\n\r\nTheorem 4.2 allows us to make the following definition:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $k\\in\\mathbb{N}$. Our goal now is to define a\r\npolynomial $P_{k}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{k},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $ such that%\r\n\\begin{equation}\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=P_{k}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}%\r\n\\right)  \\label{Pk1}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $ for every $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$,\r\nwhere $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ is the $i$-th\r\nelementary symmetric polynomial in the variables $U_{1}$, $U_{2}$, $...$,\r\n$U_{m}$ for every $i\\in\\mathbb{N}$, and $Y_{j}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =j}}\\prod\\limits_{k\\in S}V_{k}$ is the $j$-th elementary\r\nsymmetric polynomial in the variables $V_{1}$, $V_{2}$, $...$, $V_{n}$ for\r\nevery $j\\in\\mathbb{N}$.\r\n\r\nIn order to do this, we first fix some $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$.\r\nThe polynomial%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}\\in\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]\r\n\\]\r\nis UV-symmetric. Thus, Theorem 4.2 \\textbf{(a)} yields that there exists one\r\nand only one polynomial $Q\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ such that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q\\left(  X_{1},X_{2},...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right)\r\n\\]\r\nin $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $.\r\nSince the polynomial $\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =k}}\\prod\\limits_{\\left(  i,j\\right)  \\in S}U_{i}V_{j}$ has total\r\ndegree $\\leq k$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$ and of total\r\ndegree $\\leq k$ in the variables $V_{1}$, $V_{2}$, $...$, $V_{n}$, Theorem 4.2\r\n\\textbf{(b)} yields that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q_{k,k}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2}%\r\n,...,Y_{k}\\right)  ,\r\n\\]\r\nwhere $Q_{k,k}$ is the image of the polynomial $Q$ under the canonical\r\nhomomorphism $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m},\\beta\r\n_{1},\\beta_{2},...,\\beta_{n}\\right]  \\rightarrow\\mathbb{Z}\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{k},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $.\r\nHowever, this polynomial $Q_{k,k}$ is not independent of $n$ and $m$ yet (as\r\nthe polynomial $P_{k}$ that we intend to construct should be), so we call it\r\n$Q_{k,k,\\left[  n,m\\right]  }$ rather than just $Q_{k,k}$.\r\n\r\nNow we forget that we fixed $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$. We have\r\nlearnt that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q_{k,k,\\left[  n,m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $ for every $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$.\r\nNow, define a polynomial $P_{k}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{k},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $ by\r\n$P_{k}=Q_{k,k,\\left[  k,k\\right]  }$.\r\n\r\n\\textbf{Theorem 4.3.} \\textbf{(a)} The polynomial $P_{k}$ just defined\r\nsatisfies the equation (\\ref{Pk1}) in the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $ for every $n\\in\r\n\\mathbb{N}$ and $m\\in\\mathbb{N}$. (Hence, the goal mentioned above in the\r\ndefinition is actually achieved.)\r\n\r\n\\textbf{(b)} For every $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\n\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  1+U_{i}V_{j}T\\right)  =\\sum_{k\\in\\mathbb{N}}%\r\nP_{k}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)  T^{k}\r\n\\label{Pk2}%\r\n\\end{equation}\r\nin the ring $\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $. (Note\r\nthat the right hand side of this equation is a power series with coefficient\r\n$1$ before $T^{0}$, since $P_{0}=1$.)\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 4.3.]\\textbf{(a)} \\textit{1st Step:} Fix $n\\in\\mathbb{N}$\r\nand $m\\in\\mathbb{N}$ such that $n\\geq k$ and $m\\geq k$. Then, we claim that\r\n$Q_{k,k,\\left[  n,m\\right]  }=P_{k}$.\r\n\r\n\\textit{Proof.} The definition of $Q_{k,k,\\left[  n,m\\right]  }$ yields\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q_{k,k,\\left[  n,m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $. Applying the canonical ring epimorphism\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]\r\n\\rightarrow\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{k},V_{1},V_{2},...,V_{k}%\r\n\\right]  $ (which maps every $U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq k;\\\\\r\n0,\\text{ if }i>k\r\n\\end{array}\r\n\\right.  $ and every $V_{j}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nV_{j},\\text{ if }j\\leq k;\\\\\r\n0,\\text{ if }j>k\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring and every\r\n$Y_{j}$ with $j\\geq1$ to the corresponding $Y_{j}$ of the image ring!), we\r\nobtain%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,k\\right\\}  \\times\\left\\{\r\n1,2,...,k\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q_{k,k,\\left[  n,m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{k},V_{1}%\r\n,V_{2},...,V_{k}\\right]  $. On the other hand, the definition of\r\n$Q_{k,k,\\left[  k,k\\right]  }$ yields%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,k\\right\\}  \\times\\left\\{\r\n1,2,...,k\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}=Q_{k,k,\\left[  k,k\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\]\r\nin the same ring. These two equations yield%\r\n\\[\r\nQ_{k,k,\\left[  n,m\\right]  }\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2}%\r\n,...,Y_{k}\\right)  =Q_{k,k,\\left[  k,k\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)  .\r\n\\]\r\nSince the elements $X_{1}$, $X_{2}$, $...$, $X_{k}$, $Y_{1}$, $Y_{2}$, $...$,\r\n$Y_{k}$ of $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{k},V_{1},V_{2},...,V_{k}%\r\n\\right]  $ are algebraically independent (by Theorem 4.2 \\textbf{(a)}), this\r\nyields $Q_{k,k,\\left[  n,m\\right]  }=Q_{k,k,\\left[  k,k\\right]  }$. In other\r\nwords, $Q_{k,k,\\left[  n,m\\right]  }=P_{k}$, and the 1st Step is proven.\r\n\r\n\\textit{2nd Step:} For every $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$, the\r\nequation (\\ref{Pk1}) is satisfied in the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $.\r\n\r\n\\textit{Proof.} Let $n^{\\prime}\\in\\mathbb{N}$ be such that $n^{\\prime}\\geq n$\r\nand $n^{\\prime}\\geq k$ (such an $n^{\\prime}$ clearly exists). Let $m^{\\prime\r\n}\\in\\mathbb{N}$ be such that $m^{\\prime}\\geq m$ and $m^{\\prime}\\geq k$ (such\r\nan $m^{\\prime}$ clearly exists). Then, the 1st Step (applied to $n^{\\prime}$\r\nand $m^{\\prime}$ instead of $n$ and $m$) yields that $Q_{k,k,\\left[\r\nn^{\\prime},m^{\\prime}\\right]  }=P_{k}$.\r\n\r\nThe definition of $Q_{k,k,\\left[  n^{\\prime},m^{\\prime}\\right]  }$ yields\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m^{\\prime}\\right\\}  \\times\\left\\{\r\n1,2,...,n^{\\prime}\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(\r\ni,j\\right)  \\in S}U_{i}V_{j}=Q_{k,k,\\left[  n^{\\prime},m^{\\prime}\\right]\r\n}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m^{\\prime}}%\r\n,V_{1},V_{2},...,V_{n^{\\prime}}\\right]  $. Applying the canonical ring\r\nepimorphism $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m^{\\prime}},V_{1}%\r\n,V_{2},...,V_{n^{\\prime}}\\right]  \\rightarrow\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $ (which maps every $U_{i}$ to\r\n$\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq m;\\\\\r\n0,\\text{ if }i>m\r\n\\end{array}\r\n\\right.  $ and every $V_{j}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nV_{j},\\text{ if }j\\leq n;\\\\\r\n0,\\text{ if }j>n\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring and every\r\n$Y_{j}$ with $j\\geq1$ to the corresponding $Y_{j}$ of the image ring!), we\r\nobtain%\r\n\\begin{align*}\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}  &  =\\underbrace{Q_{k,k,\\left[  n^{\\prime},m^{\\prime}\\right]\r\n}}_{=P_{k}}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right) \\\\\r\n&  =P_{k}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)\r\n\\end{align*}\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $. Hence, the equation (\\ref{Pk1}) is satisfied in\r\nthe polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  $. This completes the 2nd Step and proves Theorem 4.3\r\n\\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\n\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  1+U_{i}V_{j}T\\right)   &  =\\sum_{k\\in\\mathbb{N}%\r\n}\\underbrace{\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}%\r\n}\\prod_{\\left(  i,j\\right)  \\in S}U_{i}V_{j}}_{\\substack{=P_{k}\\left(\r\nX_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)  \\\\\\text{(according to\r\n(\\ref{Pk1}))}}}T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Exercise 4.2 \\textbf{(d)}, applied to}\\\\\r\nQ=\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\text{,}\\\\\r\nA=\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}%\r\n\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  \\text{,}\\\\\r\n\\text{ }t=T\\text{ and }\\alpha_{\\left(  i,j\\right)  }=U_{i}V_{j}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}P_{k}\\left(  X_{1},X_{2},...,X_{k},Y_{1}%\r\n,Y_{2},...,Y_{k}\\right)  T^{k}.\r\n\\end{align*}\r\nThis proves Theorem 4.3 \\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\textbf{Example.} The above definition of the polynomials $P_{k}$ was rather\r\nabstract. Let us sketch an example of how these polynomials are computed -\r\nnamely, let us compute $P_{2}$.\r\n\r\nWhile our definition of $P_{k}$ was somewhat indirect (we constructed $P_{k}$\r\nin multiple steps; while each of these steps is constructive, this still is a\r\nrather long way to $P_{k}$), the important thing about $P_{k}$ is that it\r\nsatisfies (\\ref{Pk1}). In fact, for every $m\\geq k$ and $n\\geq k$, the\r\npolynomial $P_{k}$ is uniquely determined by the equation (\\ref{Pk1}%\r\n)\\footnote{\\textit{Proof.} Theorem 4.2 \\textbf{(a)} yields that the elements\r\n$X_{1}$, $X_{2}$, $...$, $X_{m}$, $Y_{1}$, $Y_{2}$, $...$, $Y_{n}$ of the\r\npolynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2}%\r\n,...,V_{n}\\right]  $ are algebraically independent. Since $m\\geq k$ and $n\\geq\r\nk$, this yields that the elements $X_{1}$, $X_{2}$, $...$, $X_{k}$, $Y_{1}$,\r\n$Y_{2}$, $...$, $Y_{k}$ of the polynomial ring $\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $ are algebraically\r\nindependent. Hence, a polynomial $\\mathfrak{p}\\in\\mathbb{Z}\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{k},\\beta_{1},\\beta_{2},...,\\beta_{k}\\right]  $ is\r\nuniquely determined by the value $\\mathfrak{p}\\left(  X_{1},X_{2}%\r\n,...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)  $. Thus, the polynomial $P_{k}$ is\r\nuniquely determined by the equation (\\ref{Pk1}) (because the equation\r\n(\\ref{Pk1}) determines the value $P_{k}\\left(  X_{1},X_{2},...,X_{k}%\r\n,Y_{1},Y_{2},...,Y_{k}\\right)  $).}, so that we only need (\\ref{Pk1}) to find\r\n$P_{k}$.\r\n\r\nSince we want to compute $P_{2}$, let us pick $k=2$. Now we need to pick some\r\n$m\\geq k$ and $n\\geq k$; the best choice is $m=n=2$ (choosing greater $m$ or\r\n$n$ would lead to the same polynomial $P_{k}$ in the end, but the computations\r\nrequired to obtain it would involve some longer terms). So let $m=n=2$. Then,\r\nthe left hand side of (\\ref{Pk1}) is%\r\n\\begin{align*}\r\n&  \\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}U_{i}V_{j}\\\\\r\n&  =\\sum_{\\substack{S\\subseteq\\left\\{  1,2\\right\\}  \\times\\left\\{\r\n1,2\\right\\}  ;\\\\\\left\\vert S\\right\\vert =2}}\\prod_{\\left(  i,j\\right)  \\in\r\nS}U_{i}V_{j}\\\\\r\n&  =\\prod_{\\left(  i,j\\right)  \\in\\left\\{  \\left(  1,1\\right)  ,\\left(\r\n1,2\\right)  \\right\\}  }U_{i}V_{j}+\\prod_{\\left(  i,j\\right)  \\in\\left\\{\r\n\\left(  1,1\\right)  ,\\left(  2,1\\right)  \\right\\}  }U_{i}V_{j}+\\prod_{\\left(\r\ni,j\\right)  \\in\\left\\{  \\left(  1,1\\right)  ,\\left(  2,2\\right)  \\right\\}\r\n}U_{i}V_{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\prod_{\\left(  i,j\\right)  \\in\\left\\{  \\left(\r\n1,2\\right)  ,\\left(  2,1\\right)  \\right\\}  }U_{i}V_{j}+\\prod_{\\left(\r\ni,j\\right)  \\in\\left\\{  \\left(  1,2\\right)  ,\\left(  2,2\\right)  \\right\\}\r\n}U_{i}V_{j}+\\prod_{\\left(  i,j\\right)  \\in\\left\\{  \\left(  2,1\\right)\r\n,\\left(  2,2\\right)  \\right\\}  }U_{i}V_{j}\\\\\r\n&  =U_{1}^{2}V_{1}V_{2}+U_{1}U_{2}V_{1}^{2}+2U_{1}U_{2}V_{1}V_{2}+U_{1}%\r\nU_{2}V_{2}^{2}+U_{2}^{2}V_{1}V_{2},\r\n\\end{align*}\r\nwhile the right hand side is%\r\n\\[\r\nP_{k}\\left(  X_{1},X_{2},...,X_{k},Y_{1},Y_{2},...,Y_{k}\\right)  =P_{2}\\left(\r\nX_{1},X_{2},Y_{1},Y_{2}\\right)  .\r\n\\]\r\nThus our polynomial $P_{2}$ must satisfy\r\n\\[\r\nU_{1}^{2}V_{1}V_{2}+U_{1}U_{2}V_{1}^{2}+2U_{1}U_{2}V_{1}V_{2}+U_{1}U_{2}%\r\nV_{2}^{2}+U_{2}^{2}V_{1}V_{2}=P_{2}\\left(  X_{1},X_{2},Y_{1},Y_{2}\\right)\r\n\\]\r\nin $\\mathbb{Z}\\left[  U_{1},U_{2},V_{1},V_{2}\\right]  $. According to Theorem\r\n4.2 \\textbf{(a)}, the polynomial $P_{2}$ is uniquely determined by this\r\ncondition, but in order to actually compute it, we need to recall how Theorem\r\n4.2 \\textbf{(a)} was proven. In other words, we need to recall how to write a\r\nUV-symmetric polynomial as a polynomial in the elementary symmetric\r\npolynomials $X_{1}$, $X_{2}$, $...$ and $Y_{1}$, $Y_{2}$, $...$.\r\n\r\nLet us look what we did in our proof of Theorem 4.2 \\textbf{(a)} above, in the\r\nparticular case of the UV-symmetric polynomial\r\n\\[\r\nU_{1}^{2}V_{1}V_{2}+U_{1}U_{2}V_{1}^{2}+2U_{1}U_{2}V_{1}V_{2}+U_{1}U_{2}%\r\nV_{2}^{2}+U_{2}^{2}V_{1}V_{2}.\r\n\\]\r\nIn this case, the proof begins by considering $U_{1}^{2}V_{1}V_{2}+2U_{1}%\r\nU_{2}V_{1}^{2}+U_{1}U_{2}V_{1}V_{2}+U_{1}U_{2}V_{2}^{2}+U_{2}^{2}V_{1}V_{2}$\r\nas a polynomial in the indeterminates $V_{1}$, $V_{2}$ over the ring\r\n$\\mathbb{Z}\\left[  U_{1},U_{2}\\right]  $. This is a symmetric polynomial in\r\nthese indeterminates $V_{1}$, $V_{2}$. Thus, Theorem 4.1 \\textbf{(a)} yields\r\nthe existence of one and only one polynomial $\\widehat{Q}\\in\\left(  K\\left[\r\nU_{1},U_{2}\\right]  \\right)  \\left[  \\beta_{1},\\beta_{2}\\right]  $ such that%\r\n\\[\r\nU_{1}^{2}V_{1}V_{2}+U_{1}U_{2}V_{1}^{2}+2U_{1}U_{2}V_{1}V_{2}+U_{1}U_{2}%\r\nV_{2}^{2}+U_{2}^{2}V_{1}V_{2}=\\widehat{Q}\\left(  Y_{1},Y_{2}\\right)  .\r\n\\]\r\nThis polynomial $\\widehat{Q}$ can be obtained by any algorithm which writes a\r\nsymmetric polynomial as a polynomial in the elementary symmetric polynomials;\r\nI assume that you know such an algorithm (if not, read it up; most proofs of\r\nTheorem 4.1 \\textbf{(a)} give such an algorithm). Applying this algorithm, we\r\nget\r\n\\[\r\nU_{1}^{2}V_{1}V_{2}+U_{1}U_{2}V_{1}^{2}+2U_{1}U_{2}V_{1}V_{2}+U_{1}U_{2}%\r\nV_{2}^{2}+U_{2}^{2}V_{1}V_{2}=\\left(  U_{1}^{2}+U_{2}^{2}\\right)  Y_{2}%\r\n+U_{1}U_{2}Y_{1}^{2},\r\n\\]\r\nso that $\\widehat{Q}=\\left(  U_{1}^{2}+U_{2}^{2}\\right)  \\beta_{2}+U_{1}%\r\nU_{2}\\beta_{1}^{2}$.\r\n\r\nNow, for every $2$-tuple $\\left(  \\lambda_{1},\\lambda_{2}\\right)\r\n\\in\\mathbb{N}^{2}$, the coefficient $Q_{\\left(  \\lambda_{1},\\lambda\r\n_{2}\\right)  }$ of this polynomial $\\widehat{Q}$ before the monomial\r\n$\\beta_{1}^{\\lambda_{1}}\\beta_{2}^{\\lambda_{2}}$ is a symmetric polynomial in\r\nthe variables $U_{1}$, $U_{2}$. Hence, by Theorem 4.1 \\textbf{(a)}, there\r\nexists a polynomial $R_{\\left(  \\lambda_{1},\\lambda_{2}\\right)  }\\in\r\n\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}\\right]  $ such that this coefficient\r\nis $R_{\\left(  \\lambda_{1},\\lambda_{2}\\right)  }\\left(  X_{1},X_{2}\\right)  $.\r\nThis $R_{\\left(  \\lambda_{1},\\lambda_{2}\\right)  }$ can generally be computed\r\nby any algorithm which writes a symmetric polynomial as a polynomial in the\r\nelementary symmetric polynomials. In our case, the polynomial $\\widehat{Q}$\r\nhas only two nonzero coefficients: the coefficient $U_{1}^{2}+U_{2}^{2}$\r\nbefore $\\beta_{2}$ and the coefficient $U_{1}U_{2}$ before $\\beta_{1}^{2}$. So\r\nwe get two polynomials $R_{\\left(  0,1\\right)  }$ and $R_{\\left(  2,0\\right)\r\n}$, whereas all the other $R_{\\left(  \\lambda_{1},\\lambda_{2}\\right)  }$ are\r\nzero. More concretely, in order to obtain $R_{\\left(  0,1\\right)  }$, we write\r\nthe symmetric polynomial $Q_{\\left(  0,1\\right)  }=U_{1}^{2}+U_{2}^{2}$ (which\r\nis the coefficient of $\\widehat{Q}$ before $\\beta_{1}^{0}\\beta_{2}^{1}%\r\n=\\beta_{2}$) as a polynomial in the elementary symmetric polynomials; this\r\ngives us $U_{1}^{2}+U_{2}^{2}=X_{1}^{2}-2X_{2}$, so that $R_{\\left(\r\n0,1\\right)  }=\\alpha_{1}^{2}-2\\alpha_{2}$. Similarly, $R_{\\left(  2,0\\right)\r\n}=\\alpha_{2}$.\r\n\r\nNow, according to the proof of Theorem 4.2 \\textbf{(a)}, a polynomial $P_{2}$\r\nsatisfying $U_{1}V_{1}+U_{1}V_{2}+U_{2}V_{1}+U_{2}V_{2}=P_{2}\\left(\r\nX_{1},X_{2},Y_{1},Y_{2}\\right)  $ can be defined by the equation%\r\n\\[\r\nP_{2}=\\sum_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n\\in\\mathbb{N}^{n}}R_{\\left(  \\lambda_{1},\\lambda_{2},...,\\lambda_{n}\\right)\r\n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right)  \\beta_{1}^{\\lambda_{1}%\r\n}\\beta_{2}^{\\lambda_{2}}...\\beta_{n}^{\\lambda_{n}}.\r\n\\]\r\nIn our case, this simplifies to%\r\n\\[\r\nP_{2}=\\underbrace{R_{\\left(  0,1\\right)  }\\left(  \\alpha_{1},\\alpha\r\n_{2}\\right)  }_{=\\alpha_{1}^{2}-2\\alpha_{2}}\\beta_{1}^{0}\\beta_{2}%\r\n^{1}+\\underbrace{R_{\\left(  2,0\\right)  }\\left(  \\alpha_{1},\\alpha_{2}\\right)\r\n}_{=\\alpha_{2}}\\beta_{1}^{2}\\beta_{2}^{0}=\\left(  \\alpha_{1}^{2}-2\\alpha\r\n_{2}\\right)  \\beta_{2}+\\alpha_{2}\\beta_{1}^{2}=\\alpha_{1}^{2}\\beta_{2}%\r\n+\\alpha_{2}\\beta_{1}^{2}-2\\alpha_{2}\\beta_{2}.\r\n\\]\r\n\r\n\r\nSo we have found $P_{2}$. Similarly we can compute $P_{k}$ for all\r\n$k\\in\\mathbb{N}$, even though the computations get longer with increasing $k$\r\nvery rapidly. Here are the values for small $k$:%\r\n\\begin{align*}\r\nP_{0}  &  =1;\\\\\r\nP_{1}  &  =\\alpha_{1}\\beta_{1};\\\\\r\nP_{2}  &  =\\alpha_{1}^{2}\\beta_{2}+\\alpha_{2}\\beta_{1}^{2}-2\\alpha_{2}%\r\n\\beta_{2};\\\\\r\nP_{3}  &  =\\alpha_{1}^{3}\\beta_{3}+\\alpha_{3}\\beta_{1}^{3}+\\alpha_{1}%\r\n\\alpha_{2}\\beta_{1}\\beta_{2}-3\\alpha_{1}\\alpha_{2}\\beta_{3}-3\\alpha_{3}%\r\n\\beta_{1}\\beta_{2}+3\\alpha_{3}\\beta_{3};\\\\\r\nP_{4}  &  =\\alpha_{4}\\beta_{1}^{4}+\\alpha_{1}\\alpha_{3}\\beta_{1}^{2}\\beta\r\n_{2}+\\alpha_{1}^{2}\\alpha_{2}\\beta_{1}\\beta_{3}+\\alpha_{1}^{4}\\beta\r\n_{4}-4\\alpha_{4}\\beta_{1}^{2}\\beta_{2}+\\alpha_{2}^{2}\\beta_{2}^{2}-2\\alpha\r\n_{1}\\alpha_{3}\\beta_{2}^{2}-2\\alpha_{2}^{2}\\beta_{1}\\beta_{3}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ -\\alpha_{1}\\alpha_{3}\\beta_{1}\\beta_{3}-4\\alpha_{1}%\r\n^{2}\\alpha_{2}\\beta_{4}+2\\alpha_{4}\\beta_{2}^{2}+4\\alpha_{4}\\beta_{1}\\beta\r\n_{3}+2\\alpha_{2}^{2}\\beta_{4}+4\\alpha_{1}\\alpha_{3}\\beta_{4}-4\\alpha_{4}%\r\n\\beta_{4};\\\\\r\nP_{5}  &  =\\alpha_{5}\\beta_{1}^{5}+\\alpha_{1}\\alpha_{4}\\beta_{1}^{3}\\beta\r\n_{2}+\\alpha_{1}^{2}\\alpha_{3}\\beta_{1}^{2}\\beta_{3}+\\alpha_{1}^{3}\\alpha\r\n_{2}\\beta_{1}\\beta_{4}+\\alpha_{1}^{5}\\beta_{5}-5\\alpha_{5}\\beta_{1}^{3}%\r\n\\beta_{2}+\\alpha_{2}\\alpha_{3}\\beta_{1}\\beta_{2}^{2}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ -3\\alpha_{1}\\alpha_{4}\\beta_{1}\\beta_{2}^{2}%\r\n-2\\alpha_{2}\\alpha_{3}\\beta_{1}^{2}\\beta_{3}-\\alpha_{1}\\alpha_{4}\\beta_{1}%\r\n^{2}\\beta_{3}+\\alpha_{1}\\alpha_{2}^{2}\\beta_{2}\\beta_{3}-2\\alpha_{1}^{2}%\r\n\\alpha_{3}\\beta_{2}\\beta_{3}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ -3\\alpha_{1}\\alpha_{2}^{2}\\beta_{1}\\beta_{4}-\\alpha\r\n_{1}^{2}\\alpha_{3}\\beta_{1}\\beta_{4}-5\\alpha_{1}^{3}\\alpha_{2}\\beta\r\n_{5}+5\\alpha_{5}\\beta_{1}\\beta_{2}^{2}+5\\alpha_{5}\\beta_{1}^{2}\\beta\r\n_{3}-\\alpha_{2}\\alpha_{3}\\beta_{2}\\beta_{3}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +5\\alpha_{1}\\alpha_{4}\\beta_{2}\\beta_{3}+5\\alpha\r\n_{2}\\alpha_{3}\\beta_{1}\\beta_{4}+\\alpha_{1}\\alpha_{4}\\beta_{1}\\beta\r\n_{4}+5\\alpha_{1}\\alpha_{2}^{2}\\beta_{5}+5\\alpha_{1}^{2}\\alpha_{3}\\beta_{5}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ -5\\alpha_{5}\\beta_{2}\\beta_{3}-5\\alpha_{5}\\beta\r\n_{1}\\beta_{4}-5\\alpha_{2}\\alpha_{3}\\beta_{5}-5\\alpha_{1}\\alpha_{4}\\beta\r\n_{5}+5\\alpha_{5}\\beta_{5}.\r\n\\end{align*}\r\nNow, let us return to the general case.\r\n\r\n\\subsection{Grothendieck's polynomials $P_{k,j}$}\r\n\r\nJust as our above definition of the polynomials $P_{k}$ and Theorem 4.3 based\r\nupon Theorem 4.2, we can make another definition basing upon Theorem 4.1:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} For every set $H$ and every $j\\in\\mathbb{N}$, let us\r\ndenote by $\\mathcal{P}_{j}\\left(  H\\right)  $ the set of all $j$-element\r\nsubsets of $H$. (This is also often denoted as $\\dbinom{H}{j}$.)\r\n\r\nLet $j\\in\\mathbb{N}$. Let $k\\in\\mathbb{N}$. Our goal now is to define a\r\npolynomial $P_{k,j}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{kj}\\right]  $ such that%\r\n\\begin{equation}\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=P_{k,j}\\left(  X_{1},X_{2},...,X_{kj}\\right)  \\label{Pkj1}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $m\\in\\mathbb{N}$, where $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$\r\nis the $i$-th elementary symmetric polynomial in the variables $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$ for every $i\\in\\mathbb{N}$.\r\n\r\nIn order to do this, we first fix some $m\\in\\mathbb{N}$. The polynomial%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}U_{i}%\r\n\\in\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\]\r\nis symmetric. Thus, Theorem 4.1 \\textbf{(a)} yields that there exists one and\r\nonly one polynomial $Q\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{m}\\right]  $ such that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q\\left(  X_{1},X_{2},...,X_{m}\\right)  .\r\n\\]\r\nSince the polynomial $\\sum\\limits_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =k}%\r\n}\\prod\\limits_{I\\in S}\\prod\\limits_{i\\in I}U_{i}$ has total degree $\\leq kj$\r\nin the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$, Theorem 4.1 \\textbf{(b)}\r\nyields that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q_{k,j}\\left(  X_{1},X_{2},...,X_{kj}\\right)  ,\r\n\\]\r\nwhere $Q_{k,j}$ is the image of the polynomial $Q$ under the canonical\r\nhomomorphism $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n\\rightarrow\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{kj}\\right]  $.\r\nHowever, this polynomial $Q_{k,j}$ is not independent of $m$ yet (as the\r\npolynomial $P_{k,j}$ that we intend to construct should be), so we call it\r\n$Q_{k,j,\\left[  m\\right]  }$ rather than just $Q_{k,j}$.\r\n\r\nNow we forget that we fixed $m\\in\\mathbb{N}$. We have learnt that%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q_{k,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $m\\in\\mathbb{N}$. Now, define a polynomial $P_{k,j}\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{kj}\\right]  $ by $P_{k,j}=Q_{k,j,\\left[\r\nkj\\right]  }$.\r\n\r\n\\textbf{Theorem 4.4.} \\textbf{(a)} The polynomial $P_{k,j}$ just defined\r\nsatisfies the equation (\\ref{Pkj1}) in the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ for every $m\\in\\mathbb{N}$. (Hence, the goal\r\nmentioned above in the definition is actually achieved.)\r\n\r\n\\textbf{(b)} For every $m\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\n\\prod_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\left(  1+\\prod_{i\\in I}U_{i}\\cdot T\\right)  =\\sum_{k\\in\\mathbb{N}}%\r\nP_{k,j}\\left(  X_{1},X_{2},...,X_{kj}\\right)  T^{k} \\label{Pkj2}%\r\n\\end{equation}\r\nin the ring $\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)\r\n\\left[  \\left[  T\\right]  \\right]  $. (Note that the right hand side of this\r\nequation is a power series with coefficient $1$ before $T^{0}$, since\r\n$P_{0,j}=1$.)\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 4.4.]\\textbf{(a)} \\textit{1st Step:} Fix $m\\in\\mathbb{N}$\r\nsuch that $m\\geq kj$. Then, we claim that $Q_{k,j,\\left[  m\\right]  }=P_{k,j}$.\r\n\r\n\\textit{Proof.} The definition of $Q_{k,j,\\left[  m\\right]  }$ yields\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q_{k,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\nApplying the canonical ring epimorphism $\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\rightarrow\\mathbb{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{kj}\\right]  $ (which maps every $U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq kj;\\\\\r\n0,\\text{ if }i>kj\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring!), we\r\nobtain%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,kj\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q_{k,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{kj}\\right]  $. On\r\nthe other hand, the definition of $Q_{k,j,\\left[  kj\\right]  }$ yields%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,kj\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}%\r\nU_{i}=Q_{k,j,\\left[  kj\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n\\]\r\nin the same ring. These two equations yield%\r\n\\[\r\nQ_{k,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n=Q_{k,j,\\left[  kj\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)  .\r\n\\]\r\nSince the elements $X_{1}$, $X_{2}$, $...$, $X_{kj}$ of $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{kj}\\right]  $ are algebraically independent (by Theorem 4.1\r\n\\textbf{(a)}), this yields $Q_{k,j,\\left[  m\\right]  }=Q_{k,j,\\left[\r\nkj\\right]  }$. In other words, $Q_{k,j,\\left[  m\\right]  }=P_{k,j}$, and the\r\n1st Step is proven.\r\n\r\n\\textit{2nd Step:} For every $m\\in\\mathbb{N}$, the equation (\\ref{Pkj1}) is\r\nsatisfied in the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  $.\r\n\r\n\\textit{Proof.} Let $m^{\\prime}\\in\\mathbb{N}$ be such that $m^{\\prime}\\geq m$\r\nand $m^{\\prime}\\geq kj$ (such an $m^{\\prime}$ clearly exists). Then, the 1st\r\nStep (applied to $m^{\\prime}$ instead of $m$) yields that $Q_{k,j,\\left[\r\nm^{\\prime}\\right]  }=P_{k,j}$.\r\n\r\nThe definition of $Q_{k,j,\\left[  m^{\\prime}\\right]  }$ yields\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m^{\\prime\r\n}\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in\r\nI}U_{i}=Q_{k,j,\\left[  m^{\\prime}\\right]  }\\left(  X_{1},X_{2},...,X_{kj}%\r\n\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m^{\\prime}%\r\n}\\right]  $. Applying the canonical ring epimorphism $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m^{\\prime}}\\right]  \\rightarrow\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ (which maps every $U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq m;\\\\\r\n0,\\text{ if }i>m\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring!), we\r\nobtain%\r\n\\begin{align*}\r\n\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{I\\in S}\\prod_{i\\in I}U_{i}  &\r\n=\\underbrace{Q_{k,j,\\left[  m^{\\prime}\\right]  }}_{=P_{k,j}}\\left(\r\nX_{1},X_{2},...,X_{kj}\\right) \\\\\r\n&  =P_{k,j}\\left(  X_{1},X_{2},...,X_{kj}\\right)\r\n\\end{align*}\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\nThis means that the equation (\\ref{Pkj1}) is satisfied in the polynomial ring\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $. This completes the 2nd\r\nStep and proves Theorem 4.4 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\n&  \\prod_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\left(  1+\\prod_{i\\in I}U_{i}\\cdot T\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}\\underbrace{\\sum_{\\substack{S\\subseteq\\mathcal{P}%\r\n_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert\r\n=k}}\\prod_{I\\in S}\\prod\\limits_{i\\in I}U_{i}}_{\\substack{=P_{k,j}\\left(\r\nX_{1},X_{2},...,X_{kj}\\right)  \\\\\\text{(according to (\\ref{Pkj1}))}}}T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Exercise 4.2 \\textbf{(d)}, applied to}\\\\\r\nQ=\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\text{,\r\n}A=\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[\r\n\\left[  T\\right]  \\right]  \\text{,}\\\\\r\n\\text{ }t=T\\text{ and }\\alpha_{I}=\\prod\\limits_{i\\in I}U_{i}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}P_{k,j}\\left(  X_{1},X_{2},...,X_{kj}\\right)  T^{k}.\r\n\\end{align*}\r\nThis proves Theorem 4.4 \\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\textbf{Example.} Computing the polynomials $P_{k,j}$ can be done by\r\nretracking their definition, just as in the case of $P_{k}$. It is even easier\r\nthan computing $P_{k}$, because the definition of $P_{k}$ made use of Theorem\r\n4.2 \\textbf{(a)}, while that of $P_{k,j}$ did not. Thus all we need is\r\n(\\ref{Pkj1}) and an algorithm to write a symmetric polynomial as a polynomial\r\nin the elementary symmetric ones. I am not doing any example computations for\r\nthis here, but here are some results:%\r\n\\begin{align*}\r\nP_{0,j}  &  =1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }j\\in\\mathbb{N}\\text{;}\\\\\r\nP_{1,0}  &  =1;\\\\\r\nP_{1,j}  &  =\\alpha_{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all positive }%\r\nj\\in\\mathbb{N}\\text{;}\\\\\r\nP_{k,0}  &  =0\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all integers }k\\geq2\\text{;}\\\\\r\nP_{k,1}  &  =\\alpha_{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all positive }%\r\nk\\in\\mathbb{N}\\text{;}\\\\\r\nP_{2,2}  &  =\\alpha_{1}\\alpha_{3}-\\alpha_{4};\\\\\r\nP_{2,3}  &  =\\alpha_{6}-\\alpha_{1}\\alpha_{5}+\\alpha_{2}\\alpha_{4};\\\\\r\nP_{3,2}  &  =\\alpha_{6}+\\alpha_{1}^{2}\\alpha_{4}-2\\alpha_{2}\\alpha_{4}%\r\n-\\alpha_{1}\\alpha_{5}+\\alpha_{3}^{2};\\\\\r\nP_{3,3}  &  =\\alpha_{1}\\alpha_{4}^{2}+\\alpha_{2}^{2}\\alpha_{5}-2\\alpha\r\n_{1}\\alpha_{3}\\alpha_{5}-\\alpha_{1}\\alpha_{2}\\alpha_{6}+\\alpha_{1}^{2}%\r\n\\alpha_{7}-\\alpha_{4}\\alpha_{5}+3\\alpha_{3}\\alpha_{6}-\\alpha_{2}\\alpha\r\n_{7}-\\alpha_{1}\\alpha_{8}+\\alpha_{9};\\\\\r\nP_{4,2}  &  =\\alpha_{1}^{3}\\alpha_{5}+\\alpha_{1}\\alpha_{3}\\alpha_{4}%\r\n-3\\alpha_{1}\\alpha_{2}\\alpha_{5}-\\alpha_{1}^{2}\\alpha_{6}-\\alpha_{4}%\r\n^{2}+\\alpha_{3}\\alpha_{5}+2\\alpha_{2}\\alpha_{6}+\\alpha_{1}\\alpha_{7}%\r\n-\\alpha_{8}.\r\n\\end{align*}\r\nDo you see the pattern in the $P_{2,j}$? See Exercise 4.4 for the answer.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 4.1. (Computing }$P_{k}$ \\textit{and }$P_{k,j}$ \\textit{as\r\ncoefficients of determinants.)} The definitions of the polynomials $P_{k}$ and\r\n$P_{k,j}$ provide a possibility to recursively compute them for given values\r\nof $k$ and $j$ (at least if one knows the constructive proof of Theorem 4.1,\r\nwhich is fortunately the one given in most books). In this exercise, we will\r\nshow another way to compute explicit formulas for $P_{k}$ and $P_{k,j}$:\r\n\r\n\\textbf{(a)} Let $m\\in\\mathbb{N}$. In the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $, let $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in\r\nS}U_{k}$ be the $i$-th elementary symmetric polynomial in the variables\r\n$U_{1}$, $U_{2}$, $...$, $U_{m}$ for every $i\\in\\mathbb{N}$.\r\n\r\nDefine a matrix $F_{U}\\in\\left(  \\mathbb{Z}\\left[  X_{1},X_{2},...,X_{m}%\r\n\\right]  \\right)  ^{m\\times m}$ by%\r\n\\begin{align*}\r\n&  F_{U}\\\\\r\n&  =\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\n0 & 1 & 0 & 0 & \\cdots & 0\\\\\r\n0 & 0 & 1 & 0 & \\cdots & 0\\\\\r\n0 & 0 & 0 & 1 & \\cdots & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\vdots\\\\\r\n0 & 0 & 0 & 0 & \\cdots & 1\\\\\r\n\\left(  -1\\right)  ^{m-1}X_{m} & \\left(  -1\\right)  ^{m-2}X_{m-1} & \\left(\r\n-1\\right)  ^{m-3}X_{m-2} & \\left(  -1\\right)  ^{m-4}X_{m-3} & \\cdots & \\left(\r\n-1\\right)  ^{0}X_{1}%\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\nProve that the polynomial\r\n\\[\r\n\\det\\left(  TF_{U}+I_{m}\\right)  \\in\\left(  \\mathbb{Z}\\left[  X_{1}%\r\n,X_{2},...,X_{m}\\right]  \\right)  \\left[  T\\right]\r\n\\]\r\nequals $\\prod\\limits_{i=1}^{m}\\left(  1+U_{i}T\\right)  $.\r\n\r\n\\textbf{(b)} Let $m\\in\\mathbb{N}$ and $n\\in\\mathbb{N}$. In the polynomial ring\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]  $, let\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ be the $i$-th\r\nelementary symmetric polynomial in the variables $U_{1}$, $U_{2}$, $...$,\r\n$U_{m}$ for every $i\\in\\mathbb{N}$, and $Y_{j}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =j}}\\prod\\limits_{k\\in S}V_{k}$ be the $j$-th elementary\r\nsymmetric polynomial in the variables $V_{1}$, $V_{2}$, $...$, $V_{n}$ for\r\nevery $j\\in\\mathbb{N}$.\r\n\r\nSimilarly to the matrix $F_{U}$ defined in part \\textbf{(a)}, we can define a\r\nmatrix $F_{V}\\in\\left(  \\mathbb{Z}\\left[  Y_{1},Y_{2},...,Y_{n}\\right]\r\n\\right)  ^{n\\times n}$ by%\r\n\\begin{align*}\r\n&  F_{V}\\\\\r\n&  =\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\n0 & 1 & 0 & 0 & \\cdots & 0\\\\\r\n0 & 0 & 1 & 0 & \\cdots & 0\\\\\r\n0 & 0 & 0 & 1 & \\cdots & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\vdots\\\\\r\n0 & 0 & 0 & 0 & \\cdots & 1\\\\\r\n\\left(  -1\\right)  ^{n-1}Y_{n} & \\left(  -1\\right)  ^{n-2}Y_{n-1} & \\left(\r\n-1\\right)  ^{n-3}Y_{n-2} & \\left(  -1\\right)  ^{n-4}Y_{n-3} & \\cdots & \\left(\r\n-1\\right)  ^{0}Y_{1}%\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\n\r\n\r\nAlso, define a matrix $F_{U}\\in\\left(  \\mathbb{Z}\\left[  X_{1},X_{2}%\r\n,...,X_{m}\\right]  \\right)  ^{m\\times m}$ as in part \\textbf{(a)}. Let\r\n$\\mathcal{R}$ be the ring $\\mathbb{Z}\\left[  X_{1},X_{2},\\ldots,X_{m}%\r\n,Y_{1},Y_{2},\\ldots,Y_{n}\\right]  $. We can thus regard both $F_{U}$ and\r\n$F_{V}$ as matrices over the ring $\\mathcal{R}$: namely, $F_{U}\\in\r\n\\mathcal{R}^{m\\times m}$ and $F_{V}\\in\\mathcal{R}^{n\\times n}$. Hence, the\r\ntensor product $F_{U}\\otimes F_{V}$ of these two matrices is\r\ndefined\\footnote{It is defined as follows: The $m\\times m$-matrix $F_{U}$\r\ninduces an endomorphism of the free $\\mathcal{R}$-module $\\mathcal{R}^{m}$,\r\nwhereas the $n\\times n$-matrix $F_{V}$ induces an endomorphism of the free\r\n$\\mathcal{R}$-module $\\mathcal{R}^{n}$. The tensor product of these two\r\nendomorphisms is an endomorphism of the free $\\mathcal{R}$-module\r\n$\\mathcal{R}^{n}\\otimes_{\\mathcal{R}}\\mathcal{R}^{m}$. This latter\r\nendomorphism can be represented by an $mn\\times mn$-matrix once we have chosen\r\na basis of the free $\\mathcal{R}$-module $\\mathcal{R}^{n}\\otimes_{\\mathcal{R}%\r\n}\\mathcal{R}^{m}$. For the purposes of this exercise, it makes no matter which\r\nbasis we choose, as long as we do choose a basis. Anyway, we have thus\r\nobtained an $mn\\times mn$-matrix; this matrix is called $F_{U}\\otimes F_{V}$%\r\n.}; it is an $mn\\times mn$-matrix over $\\mathcal{R}$. Prove that the\r\npolynomial\r\n\\[\r\n\\det\\left(  -T\\left(  F_{U}\\otimes F_{V}\\right)  +I_{mn}\\right)  \\in\\left(\r\n\\mathbb{Z}\\left[  X_{1},X_{2},...,X_{m},Y_{1},Y_{2},...,Y_{n}\\right]  \\right)\r\n\\left[  T\\right]\r\n\\]\r\nequals $\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+U_{i}V_{j}T\\right)  $. Conclude\r\nthat the coefficient of this polynomial before $T^{k}$ equals the\r\n$Q_{k,k,\\left[  n,m\\right]  }\\left(  X_{1},X_{2},...,X_{k},Y_{1}%\r\n,Y_{2},...,Y_{k}\\right)  $ defined in the definition of $P_{k}$. How to\r\ncompute $P_{k}$ now? (Don't forget to choose $n$ and $m$ such that $n\\geq k$\r\nand $m\\geq k$.)\r\n\r\n\\textbf{(c)} Let $m\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$. Define the polynomials\r\n$X_{i}$ and an $m\\times m$-matrix $F_{U}$ as in part \\textbf{(a)}. Then, an\r\n$\\dbinom{m}{j}\\times\\dbinom{m}{j}$-matrix $\\wedge^{j}F_{U}$ over the ring\r\n$\\mathbb{Z}\\left[  X_{1},X_{2},...,X_{m}\\right]  $ is defined\\footnote{It is\r\ndefined as follows: Let $\\mathcal{M}$ be the ring $\\mathbb{Z}\\left[\r\nX_{1},X_{2},...,X_{m}\\right]  $. The $m\\times m$-matrix $F_{U}$ induces an\r\nendomorphism of the free $\\mathcal{R}$-module $\\mathcal{R}^{m}$. The $j$-th\r\nexterior power of this endomorphism is an endomorphism of the free\r\n$\\mathcal{R}$-module $\\wedge^{j}\\mathcal{R}^{m}$. This latter endomorphism can\r\nbe represented by an $\\dbinom{m}{j}\\times\\dbinom{m}{j}$-matrix once we have\r\nchosen a basis of the free $\\mathcal{R}$-module $\\wedge^{j}\\mathcal{R}^{m}$.\r\nFor the purposes of this exercise, it makes no matter which basis we choose,\r\nas long as we do choose a basis. Anyway, we have thus obtained an $\\wedge\r\n^{j}\\mathcal{R}^{m}$-matrix; this matrix is called $\\wedge^{j}F_{U}$.}. Prove\r\nthat the polynomial%\r\n\\[\r\n\\det\\left(  \\left(  -1\\right)  ^{j}T\\left(  \\wedge^{j}F_{U}\\right)\r\n+I_{\\dbinom{m}{j}}\\right)  \\in\\left(  \\mathbb{Z}\\left[  X_{1},X_{2}%\r\n,...,X_{m}\\right]  \\right)  \\left[  T\\right]\r\n\\]\r\nequals $\\prod\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  }\\left(  1+\\prod\\limits_{i\\in I}U_{i}\\cdot T\\right)  $. Conclude that\r\nthe coefficient of this polynomial before $T^{k}$ equals the $Q_{k,j,\\left[\r\nm\\right]  }\\left(  X_{1},X_{2},...,X_{kj}\\right)  $ defined in the definition\r\nof $P_{k,j}$. How to compute $P_{k,j}$ now? (Don't forget to choose $m$ such\r\nthat $m\\geq kj$.)\r\n\r\n\\textit{Exercise 4.2.}\r\n\r\n\\textbf{(a)} Let $\\alpha_{1}$, $\\alpha_{2}$, $...$, $\\alpha_{m}$ be any\r\nelements of a commutative ring $A$. Prove that%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1+\\alpha_{i}\\right)  =\\sum\\limits_{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  }\\prod\\limits_{k\\in S}\\alpha_{k}.\r\n\\]\r\n\r\n\r\n\\textbf{(b)} Let $\\alpha_{1}$, $\\alpha_{2}$, $...$, $\\alpha_{m}$ and $t$ be\r\nany elements of a commutative ring $A$. Then, prove that%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1+\\alpha_{i}t\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}\\alpha_{k}t^{i}.\r\n\\]\r\n\\footnote{Note that a product of the form $\\prod\\limits_{k\\in S}\\alpha\r\n_{k}t^{i}$ has to be read as $\\left(  \\prod\\limits_{k\\in S}\\alpha_{k}\\right)\r\nt^{i}$, rather than as $\\prod\\limits_{k\\in S}\\left(  \\alpha_{k}t^{i}\\right)\r\n$. This is a particular case of the general convention about parsing product\r\nexpressions that we made in Section 0.}\r\n\r\n\\textbf{(c)} Let $\\alpha_{1}$, $\\alpha_{2}$, $...$, $\\alpha_{m}$ and $t$ be\r\nany elements of a commutative ring $A$. Then, prove that%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1-\\alpha_{i}t\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\left(  -1\\right)  ^{i}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}t^{i}.\r\n\\]\r\n\r\n\r\n\\textbf{(d)} Let $Q$ be a finite set, and let $A$ be a commutative ring. Let\r\n$\\alpha_{q}$ be an element of $A$ for every $q\\in Q$. Let $t\\in A$. Then,\r\nprove that%\r\n\\[\r\n\\prod\\limits_{q\\in Q}\\left(  1+\\alpha_{q}t\\right)  =\\sum\\limits_{k\\in\r\n\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq Q;\\\\\\left\\vert S\\right\\vert\r\n=k}}\\prod\\limits_{q\\in S}\\alpha_{q}t^{k}.\r\n\\]\r\n\r\n\r\n(These are four variants of one and the same identity, which is very easy but\r\nbasic and used in much of the theory of symmetric polynomials.)\r\n\r\n\\textit{Exercise 4.3.} Let $K$ be a ring. Let $S$ be a $K$-algebra. Let $T$ be\r\na $K$-subalgebra of $S$. Let $p_{1}$, $p_{2}$, $...$, $p_{m}$ be $m$ elements\r\nof $T$, and let $q_{1}$, $q_{2}$, $...$, $q_{n}$ be $n$ elements of $S$.\r\nAssume that the elements $p_{1}$, $p_{2}$, $...$, $p_{m}$ are algebraically\r\nindependent over $K$, and that the elements $q_{1}$, $q_{2}$, $...$, $q_{n}$\r\nare algebraically independent over $T$. Prove that the $m+n$ elements $p_{1}$,\r\n$p_{2}$, $...$, $p_{m}$, $q_{1}$, $q_{2}$, $...$, $q_{n}$ are algebraically\r\nindependent over $K$.\r\n\r\n\\textit{Exercise 4.4.} Prove that $P_{2,j}=\\sum\\limits_{i=0}^{j-1}\\left(\r\n-1\\right)  ^{i+j-1}\\alpha_{i}\\alpha_{2j-i}$ for every $j\\in\\mathbb{N}$, where\r\n$\\alpha_{0}$ has to be interpreted as $1$.\r\n\r\n[The result of Exercise 4.4 is a result by John Hopkinson (\\cite[Proposition\r\n2.1]{Hopkin06}). His proof is different from the one I give in the solutions.\r\nHe also gives a similar, even if more complicated formula for $P_{3,j}$: see\r\n\\cite[Proposition 2.2]{Hopkin06}.]\r\n\\end{quotation}\r\n\r\n\\section{A $\\lambda$-ring structure on $\\Lambda\\left(  K\\right)  =1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$}\r\n\r\n\\subsection{Definition of the $\\lambda$-ring $\\Lambda\\left(  K\\right)  $}\r\n\r\nNow we are going to introduce a $\\lambda$-ring structure on a particular set\r\ndefined for any given ring $K$.\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. Consider the ring $K\\left[  \\left[\r\nT\\right]  \\right]  $ of formal power series in the variable $T$ over $K$. Let\r\n$K\\left[  \\left[  T\\right]  \\right]  ^{+}$ denote the subset%\r\n\\begin{align*}\r\nTK\\left[  \\left[  T\\right]  \\right]   &  =\\left\\{  \\sum_{i\\in\\mathbb{N}}%\r\na_{i}T^{i}\\in K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ a_{i}\\in K\\text{ for\r\nall }i,\\text{ and }a_{0}=0\\right\\} \\\\\r\n&  =\\left\\{  p\\in K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a\r\npower series with constant term }0\\right\\}\r\n\\end{align*}\r\nof the ring $K\\left[  \\left[  T\\right]  \\right]  $. We are going to define a\r\nring structure on the set\r\n\\begin{align*}\r\n1+K\\left[  \\left[  T\\right]  \\right]  ^{+}  &  =\\left\\{  1+u\\mid u\\in K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}\\right\\} \\\\\r\n&  =\\left\\{  p\\in K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a\r\npower series with constant term }1\\right\\}  .\r\n\\end{align*}\r\nFirst, we define an Abelian group structure on this set:\r\n\r\nDefine an addition $\\widehat{+}$ on the set $1+K\\left[  \\left[  T\\right]\r\n\\right]  ^{+}$ by $u\\widehat{+}v=uv$ for every $u\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ and $v\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$.\r\nIn other words, addition on $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ is\r\ndefined as multiplication of power series. The zero of $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ will be $1$. The subtraction $\\widehat{-}$ on the set\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ is given by $u\\widehat{-}%\r\nv=\\dfrac{u}{v}$ for every $u\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ and\r\n$v\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ (since every $v\\in1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$ is an invertible power series).\r\n\r\nThen, clearly, $\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}%\r\n,\\widehat{+}\\right)  $ is an Abelian group with zero $1$.\r\n\r\nNow, define a multiplication $\\widehat{\\cdot}$ on the set $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ by%\r\n\\[\r\n\\left(  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)  \\widehat{\\cdot}\\left(\r\n\\sum_{i\\in\\mathbb{N}}b_{i}T^{i}\\right)  =\\sum_{k\\in\\mathbb{N}}P_{k}\\left(\r\na_{1},a_{2},...,a_{k},b_{1},b_{2},...,b_{k}\\right)  T^{k}%\r\n\\]\r\n\\footnote{Here, the $\\sum\\limits_{k\\in\\mathbb{N}}$ sign means addition in\r\n$K\\left[  \\left[  T\\right]  \\right]  $, not in $1+K\\left[  \\left[  T\\right]\r\n\\right]  ^{+}$. The same holds for the $\\sum\\limits_{i\\in\\mathbb{N}}$ sign.}\r\nfor any two power series $\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\in1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$ and $\\sum\\limits_{i\\in\\mathbb{N}}b_{i}%\r\nT^{i}\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ (where $a_{i}$ and $b_{i}$\r\nlie in $K$ for every $i\\in\\mathbb{N}$).\\ \\ \\ \\ \\footnote{Of course, it is not\r\nobvious that this multiplication $\\widehat{\\cdot}$ is associative. See Theorem\r\n5.1 \\textbf{(a)} for the proof of this.}\r\n\r\nThe multiplicative unity of the ring $1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}$ will be $1+T$.\r\n\r\nAlso, for every $j\\in\\mathbb{N}$, define a mapping $\\widehat{\\lambda}%\r\n^{j}:1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\rightarrow1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ by%\r\n\\[\r\n\\widehat{\\lambda}^{j}\\left(  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)\r\n=\\sum_{k\\in\\mathbb{N}}P_{k,j}\\left(  a_{1},a_{2},...,a_{kj}\\right)  T^{k}%\r\n\\]\r\nfor every power series $\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\in1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$ (where $a_{i}\\in K$ for every $i\\in\r\n\\mathbb{N}$).\r\n\\end{quote}\r\n\r\nNote that we have denoted the newly-defined addition, subtraction and\r\nmultiplication on the set $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ by\r\n$\\widehat{+}$, $\\widehat{-}$ and $\\widehat{\\cdot}$ in order to distinguish\r\nthem from the addition $+$, subtraction $-$ and multiplication $\\cdot$\r\ninherited from $K\\left[  \\left[  T\\right]  \\right]  $. We will later continue\r\nin this spirit (for instance, we will denote a finite sum with respect to the\r\naddition $\\widehat{+}$ by the sign $\\widehat{\\sum}$, while a finite sum with\r\nrespect to the addition $+$ will be written using the normal $\\sum$\r\nsign).\\footnote{In \\cite{Knut73}, Knutson writes $\"+\"$, $\"-\"$ and $\"\\cdot\"$\r\n(with quotation marks) instead of $\\widehat{+}$, $\\widehat{-}$ and\r\n$\\widehat{\\cdot}$ for the newly-defined operations. In \\cite{FulLan85}, Fulton\r\nand Lang simply write $+$, $-$ and $\\cdot$ for $\\widehat{+}$, $\\widehat{-}$\r\nand $\\widehat{\\cdot}$, approving the danger of confusion with the ``old''\r\noperations $+$, $-$ and $\\cdot$ inherited from $K\\left[  \\left[  T\\right]\r\n\\right]  $.}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.1.} \\textbf{(a)} The multiplication $\\widehat{\\cdot}$ just\r\ndefined makes $\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}%\r\n,\\widehat{+},\\widehat{\\cdot}\\right)  $ a ring with multiplicative unity $1+T$.\r\nWe will call this ring $\\Lambda\\left(  K\\right)  $.\r\n\r\n\\textbf{(b)} The above defined maps $\\widehat{\\lambda}^{j}$ make $\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ a $\\lambda$-ring.\r\n\\end{quote}\r\n\r\nWe repeat again that the notation $\\Lambda\\left(  K\\right)  $ has nothing to\r\ndo with exterior algebras, even though some authors use it for them.\r\n\r\nBefore we prove this Theorem 5.1, we will have to do some preparatory work: We\r\nwill introduce a subset $1+K\\left[  T\\right]  ^{+}$ of $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ which consists of polynomials with constant term $1$.\r\nWe will show (Theorem 5.2) how we can factorize such polynomials into linear\r\nfactors in an extension of our ring $K$ (similarly to Galois theory, but\r\neasier, because we don't have to worry about the extension not being a field).\r\nThen, we will see how the operations $\\widehat{+}$, $\\widehat{\\cdot}$ and\r\n$\\widehat{\\lambda}^{j}$ act on factorized linear polynomials (Theorem 5.3).\r\nThen, with the help of some very basic point-set topology, we will see that\r\nthe subset $1+K\\left[  T\\right]  ^{+}$ is dense in an appropriate topology on\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ (Theorem 5.5 \\textbf{(a)}), that\r\nthis topology is Hausdorff (Theorem 5.5 \\textbf{(e)}), and that the operations\r\n$\\widehat{+}$, $\\widehat{\\cdot}$ and $\\widehat{\\lambda}^{j}$ are continuous\r\nwith respect to it (Theorem 5.5 \\textbf{(d)}); hence, in order to prove the\r\nring and $\\lambda$-ring axioms for $\\Lambda\\left(  K\\right)  $, we only need\r\nto prove them on elements of this dense subset $1+K\\left[  T\\right]  ^{+}$.\r\nThis will then be done using Theorems 5.2 and 5.3.\r\n\r\nEven if you are willing to believe me that Theorem 5.1 holds, you are advised\r\nto read this proof, since the ideas and notions it uses will be reused several\r\ntimes (e. g., in Sections 9 and 10).\r\n\r\n\\subsection{Preparing for the proof of Theorem 5.1: introducing $1+K\\left[\r\nT\\right]  ^{+}$}\r\n\r\nBefore we prove this Theorem 5.1, we try to motivate the above definition of\r\n$\\Lambda\\left(  K\\right)  $:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. Let $K\\left[  T\\right]  ^{+}$ be the\r\nsubset of the polynomial ring $K\\left[  T\\right]  $ defined by%\r\n\\begin{align*}\r\nK\\left[  T\\right]  ^{+}  &  =TK\\left[  T\\right]  =\\left\\{  \\sum_{i\\in\r\n\\mathbb{N}}a_{i}T^{i}\\in K\\left[  T\\right]  \\ \\mid\\ a_{i}\\in K\\text{ for all\r\n}i,\\text{ and }a_{0}=0\\right\\} \\\\\r\n&  =\\left\\{  p\\in K\\left[  T\\right]  \\ \\mid\\ p\\text{ is a polynomial with\r\nconstant term }0\\right\\}  .\r\n\\end{align*}\r\nThen, the set $1+K\\left[  T\\right]  ^{+}$ is a subset of $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$. The elements of $1+K\\left[  T\\right]  ^{+}$ are polynomials.\r\n\\end{quote}\r\n\r\nSo $1+K\\left[  T\\right]  ^{+}$ is the set of all polynomials $p\\in K\\left[\r\nT\\right]  $ with constant term $1$. Loosely speaking, this means that the\r\nelements of $1+K\\left[  T\\right]  ^{+}$ are monic polynomials\r\n\\textquotedblleft turned upside down\\textquotedblright\\ (in the sense that if\r\n$\\sum\\limits_{i=0}^{n}a_{i}T^{i}$ is a polynomial in $1+K\\left[  T\\right]\r\n^{+}$ of degree $n$ (with $a_{i}\\in K$ for every $i$), then $\\sum\r\n\\limits_{i=0}^{n}a_{n-i}T^{i}$ is a monic polynomial of degree $n$, and\r\nconversely). This allows us to take some properties of monic polynomials and\r\nuse them to derive similar properties for polynomials in $1+K\\left[  T\\right]\r\n^{+}$. For example, we can take Exercise 5.1 (which says that whenever $P$ is\r\na monic polynomial of degree $n$ over a ring $K$, we can find a finite-free\r\nextension ring of $K$ over which the polynomial $P$ factors into a product of\r\nmonic linear polynomials), and \\textquotedblleft turn it upside\r\ndown\\textquotedblright, obtaining the following fact about polynomials in\r\n$1+K\\left[  T\\right]  ^{+}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.2.} Let $K$ be a ring. For every element $p\\in1+K\\left[\r\nT\\right]  ^{+}$, there exists an integer $n$ (the degree of the polynomial\r\n$p$), a finite-free extension ring $K_{p}$ of the ring $K$ and $n$ elements\r\n$p_{1}$, $p_{2}$, $...$, $p_{n}$ of this extension ring $K_{p}$ such that\r\n$p=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  $ in $K_{p}\\left[  T\\right]\r\n$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.2.]Write the polynomial $p$ in the form $p=\\sum\r\n\\limits_{i=0}^{n}a_{i}T^{i}$, where $n=\\deg p$. Then, $a_{0}=1$ (since\r\n$p\\in1+K\\left[  T\\right]  ^{+}$).\r\n\r\nDefine a new polynomial $\\widetilde{p}=\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}\\in\r\nK\\left[  T\\right]  $. Then, the polynomial $\\widetilde{p}$ is monic (since\r\n$a_{0}=1$) and satisfies $n=\\deg\\widetilde{p}$. Hence, by Exercise 5.1\r\n(applied to $P=\\widetilde{p}$), there exists a finite-free extension ring\r\n$K_{\\widetilde{p}}$ of the ring $K$ and $n$ elements $\\widetilde{p}_{1}$,\r\n$\\widetilde{p}_{2}$, $...$, $\\widetilde{p}_{n}$ of this extension ring\r\n$K_{\\widetilde{p}}$ such that $\\widetilde{p}=\\prod\\limits_{i=1}^{n}\\left(\r\nT-\\widetilde{p}_{i}\\right)  $ in $K_{\\widetilde{p}}\\left[  T\\right]  $.\r\n\r\nConsider this ring $K_{\\widetilde{p}}$ and these $n$ elements $\\widetilde{p}%\r\n_{1}$, $\\widetilde{p}_{2}$, $...$, $\\widetilde{p}_{n}$. Let $K_{p}$ be the\r\nextension ring $K_{\\widetilde{p}}$, and let $p_{i}$ be the element\r\n$-\\widetilde{p}_{i}\\in K_{p}$ for every $i\\in\\left\\{  1,2,...,n\\right\\}  $.\r\nThen,\r\n\\[\r\n\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}=\\widetilde{p}=\\prod\\limits_{i=1}^{n}\\left(\r\nT-\\widetilde{p}_{i}\\right)  =\\prod\\limits_{i=1}^{n}\\left(\r\nT+\\underbrace{\\left(  -\\widetilde{p}_{i}\\right)  }_{=p_{i}}\\right)\r\n=\\prod\\limits_{i=1}^{n}\\left(  T+p_{i}\\right)  =\\prod\\limits_{i=1}^{n}\\left(\r\np_{i}+T\\right)  .\r\n\\]\r\nTherefore, Exercise 5.2 \\textbf{(a)} (applied to $L=K_{p}$) yields that\r\n$\\sum\\limits_{i=0}^{n}a_{i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}%\r\nT\\right)  $. Since $p=\\sum\\limits_{i=0}^{n}a_{i}T^{i}$, this rewrites as\r\n$p=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  $. Thus, Theorem 5.2 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{Preparing for the proof of Theorem 5.1: extending the ring to make\r\npolynomials split}\r\n\r\nTheorem 5.2 shows us that we can split every polynomial $p\\in1+K\\left[\r\nT\\right]  ^{+}$ into linear factors in a suitably large (but finite-free)\r\nextension ring of $K$. This is a rather useful fact: Whenever we have to prove\r\nsome facts about polynomials in $1+K\\left[  T\\right]  ^{+}$, it allows us to\r\n``adjoin roots of these polynomials'' to $K$. In this sense it is a partial\r\nreplacement of the fundamental theorem of algebra for arbitrary commutative\r\nrings. Of course, its use is limited by the fact that we don't know much about\r\nthe extension ring of $K$ in which $p$ factors, but the fact that it is\r\nfinite-free is enough for many things!\r\n\r\nTo make systematic use of Theorem 5.2, let us introduce some notation again:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $S$ be a set. Let $J_{s}$ be a set for each $s\\in S$.\r\nThen $\\bigcup\\limits_{s\\in S}^{\\cdot}J_{s}$ (the so-called \\textit{disjoint\r\nunion} of the sets $J_{s}$ over all $s\\in S$) is defined to be the set of all\r\npairs $\\left(  s,j\\right)  $ with $s\\in S$ and $j\\in J_{s}$. In other words,\r\n$\\bigcup\\limits_{s\\in S}^{\\cdot}J_{s}=\\bigcup\\limits_{s\\in S}\\left\\{\r\ns\\right\\}  \\times J_{s}$.\r\n\r\n\\textbf{Definition.} For every set $H$, let $\\mathcal{P}_{\\operatorname*{fin}%\r\n}^{\\ast}\\left(  H\\right)  $ denote the set of all finite multisets which\r\nconsist of elements of $H$. Also, we recall that we denote the multiset formed\r\nby the elements $u_{1}$, $u_{2}$, $...$, $u_{n}$ (with multiplicity) by\r\n$\\left[  u_{1},u_{2},...,u_{n}\\right]  $.\r\n\r\nFor our ring $K$, let $\\operatorname*{Exten}K$ be the set of all finite-free\r\nextension rings of $K$. (Again, this is not a set, but a proper class. Again,\r\nwe don't care. Basically it is enough to consider all finite-free extension\r\nrings of the form $K\\left[  X_{1},X_{2},...,X_{n}\\right]  \\diagup I$ with $I$\r\nbeing an ideal of $K\\left[  X_{1},X_{2},...,X_{n}\\right]  $, and\r\n\\textit{these} extension rings do form a set.)\r\n\r\nLet $K^{\\operatorname*{int}}$ be the subset\\footnote{Recall that\r\n$\\bigcup\\limits_{K^{\\prime}\\in\\operatorname*{Exten}K}^{\\cdot}\\mathcal{P}%\r\n_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime}\\right)  $ denotes the disjoint\r\nunion of the sets $\\mathcal{P}_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime\r\n}\\right)  $ over all $K^{\\prime}\\in\\operatorname*{Exten}K$; it is defined by\r\n$\\bigcup\\limits_{K^{\\prime}\\in\\operatorname*{Exten}K}^{\\cdot}\\mathcal{P}%\r\n_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime}\\right)  =\\bigcup\r\n\\limits_{K^{\\prime}\\in\\operatorname*{Exten}K}\\left\\{  K^{\\prime}\\right\\}\r\n\\times\\mathcal{P}_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime}\\right)  $.}%\r\n\\[\r\n\\left\\{  \\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)\r\n\\in\\bigcup\\limits_{K^{\\prime}\\in\\operatorname*{Exten}K}^{\\cdot}\\mathcal{P}%\r\n_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime}\\right)  \\ \\ \\mid\r\n\\ \\ \\prod\\limits_{i=1}^{n}\\left(  1+u_{i}T\\right)  \\in K\\left[  T\\right]\r\n\\right\\}\r\n\\]\r\nof $\\bigcup\\limits_{K^{\\prime}\\subseteq\\operatorname*{Exten}K}^{\\cdot\r\n}\\mathcal{P}_{\\operatorname*{fin}}^{\\ast}\\left(  K^{\\prime}\\right)  $. We then\r\ndefine a map%\r\n\\[\r\n\\Pi:K^{\\operatorname*{int}}\\rightarrow1+K\\left[  T\\right]  ^{+}%\r\n\\]\r\nthrough%\r\n\\begin{align*}\r\n\\Pi\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)   &\r\n=\\prod\\limits_{i=1}^{n}\\left(  1+u_{i}T\\right)  \\in1+K\\left[  T\\right]  ^{+}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  \\widetilde{K},\\left[\r\nu_{1},u_{2},...,u_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}}.\r\n\\end{align*}\r\n\\footnote{This map is well-defined, because every $\\left(  \\widetilde{K}%\r\n,\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}}$\r\nsatisfies $\\prod\\limits_{i=1}^{n}\\left(  1+u_{i}T\\right)  \\in K\\left[\r\nT\\right]  $ and therefore $\\prod\\limits_{i=1}^{n}\\left(  1+u_{i}T\\right)\r\n\\in1+K\\left[  T\\right]  ^{+}$ (since the polynomial $\\prod\\limits_{i=1}%\r\n^{n}\\left(  1+u_{i}T\\right)  $ clearly has constant term $1$).}\r\n\r\nEvery polynomial $p\\in1+K\\left[  T\\right]  ^{+}$ can be written as\r\n$p=\\Pi\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)  $\r\nfor some $\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)\r\n\\in K^{\\operatorname*{int}}$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let\r\n$p\\in1+K\\left[  T\\right]  ^{+}$ be a polynomial. Then, Theorem 5.2 shows that\r\nthere exists an integer $n$ (the degree of the polynomial $p$), a finite-free\r\nextension ring $K_{p}$ of the ring $K$ and $n$ elements $p_{1}$, $p_{2}$,\r\n$...$, $p_{n}$ of this extension ring $K_{p}$ such that $p=\\prod\r\n\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  $ in $K_{p}\\left[  T\\right]  $.\r\nConsider these $n$ and $K_{p}$ and these $p_{1}$, $p_{2}$, $...$, $p_{n}$.\r\nThen, $\\left(  K_{p},\\left[  p_{1},p_{2},\\ldots,p_{n}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ (since $\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}%\r\nT\\right)  =p\\in K\\left[  T\\right]  $). Moreover, the definition of $\\Pi$\r\nyields%\r\n\\[\r\n\\Pi\\left(  K_{p},\\left[  p_{1},p_{2},\\ldots,p_{n}\\right]  \\right)\r\n=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  =p.\r\n\\]\r\nHence, $p$ can be written as $p=\\Pi\\left(  \\widetilde{K},\\left[  u_{1}%\r\n,u_{2},...,u_{n}\\right]  \\right)  $ for some $\\left(  \\widetilde{K},\\left[\r\nu_{1},u_{2},...,u_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}}$ (namely,\r\nfor $\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{n}\\right]  \\right)\r\n=\\left(  K_{p},\\left[  p_{1},p_{2},\\ldots,p_{n}\\right]  \\right)  $). Qed.}. In\r\nother words, the map $\\Pi$ is surjective.\r\n\\end{quote}\r\n\r\nThe surjectivity of the map $\\Pi$ should remind you of the correspondence\r\nbetween polynomials over a field and their roots over extensions of that field\r\n(and the proof of Theorem 5.2 explains why); it will help us understand\r\n$\\widehat{+}$, $\\widehat{\\cdot}$ and $\\widehat{\\lambda}^{j}$ better.\r\n\r\n\\subsection{Preparing for the proof of Theorem 5.1: the ring structure on\r\n$\\Lambda\\left(  K\\right)  $ explained}\r\n\r\nIn fact, the following fact how the ring operations $\\widehat{+}$ and\r\n$\\widehat{\\cdot}$ and the $\\lambda$-operations $\\widehat{\\lambda}^{j}$ on\r\n$1+K\\left[  T\\right]  ^{+}$ act on images under the map $\\Pi$:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.3.} Let $K$ be a ring.\r\n\r\nLet $u\\in1+K\\left[  T\\right]  ^{+}$ and $v\\in1+K\\left[  T\\right]  ^{+}$.\r\nAssume that $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}%\r\n\\right]  \\right)  $ for some $\\left(  \\widetilde{K}_{u},\\left[  u_{1}%\r\n,u_{2},...,u_{m}\\right]  \\right)  \\in K^{\\operatorname*{int}}$, and that\r\n$v=\\Pi\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)\r\n$ for some $\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$. This, in particular, implies that\r\n$\\widetilde{K}_{u}$ and $\\widetilde{K}_{v}$ are finite-free extension rings of\r\n$K$. Let $\\widetilde{K}_{u,v}$ be a finite-free extension ring of $K$ which\r\ncontains both $\\widetilde{K}_{u}$ and $\\widetilde{K}_{v}$ as subrings.\r\n\r\n\\textbf{(a)} Such a ring $\\widetilde{K}_{u,v}$ always exists. For\r\ninstance,\\footnote{In the following, the $\\otimes$ sign always means\r\n$\\otimes_{K}$ until stated otherwise.} $\\widetilde{K}_{u}\\otimes\r\n\\widetilde{K}_{v}$ is a finite-free extension ring of $K$, and we can\r\ncanonically identify $\\widetilde{K}_{u}$ with the subring $\\widetilde{K}%\r\n_{u}\\otimes1$ of $\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$, and identify\r\n$\\widetilde{K}_{v}$ with the subring $1\\otimes\\widetilde{K}_{v}$ of\r\n$\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$; hence, we can set $\\widetilde{K}%\r\n_{u,v}=\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$.\r\n\r\n\\textbf{(b)} We have $u\\widehat{+}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[\r\nu_{1},u_{2},...,u_{m},v_{1},v_{2},...,v_{n}\\right]  \\right)  $.\r\n\r\n\\textbf{(c)} Also, $u\\widehat{\\cdot}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[\r\nu_{i}v_{j}\\mid\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  \\right]  \\right)  $.\r\n\r\n\\textbf{(d)} Let $j\\in\\mathbb{N}$. Then, $\\widehat{\\lambda}^{j}\\left(\r\nu\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in I}%\r\nu_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right]  \\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.3.]The assumption that $u=\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $ is just a different way\r\nto say that $u=\\prod\\limits_{i=1}^{m}\\left(  1+u_{i}T\\right)  $. Similarly,\r\n$v=\\prod\\limits_{j=1}^{n}\\left(  1+v_{j}T\\right)  $. Write the polynomials $u$\r\nand $v$ in the forms $u=\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}$ (with\r\n$a_{i}\\in K$) and $v=\\sum\\limits_{i\\in\\mathbb{N}}b_{i}T^{i}$ (with $b_{i}\\in\r\nK$).\r\n\r\nRecall that $\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}=u=\\prod\\limits_{i=1}%\r\n^{m}\\left(  1+u_{i}T\\right)  $. Hence, for every $i\\in\\mathbb{N}$, the element\r\n$a_{i}$ is the $i$-th elementary symmetric polynomial applied to $u_{1}$,\r\n$u_{2}$, $...$, $u_{m}$ (that is, we have $a_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}u_{k}$).\r\n\r\nSimilarly, for every $j\\in\\mathbb{N}$, the element $b_{j}$ is the $j$-th\r\nelementary symmetric polynomial applied to $v_{1}$, $v_{2}$, $...$, $v_{n}$\r\n(that is, we have $b_{j}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =j}}\\prod\\limits_{k\\in S}v_{k}$).\r\n\r\n\\textbf{(a)} The $K$-module $\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$ is\r\nfinite-free (being the tensor product of two finite-free $K$-modules). The\r\nembedding $K\\rightarrow\\widetilde{K}_{v}$ is injective; hence, the map\r\n$\\widetilde{K}_{u}\\otimes K\\rightarrow\\widetilde{K}_{u}\\otimes\\widetilde{K}%\r\n_{v}$ it induces must also be injective (since $\\widetilde{K}_{u}$ is\r\nfinite-free, and hence tensoring with $\\widetilde{K}_{u}$ is an exact\r\nfunctor). Thus, we can canonically identify $\\widetilde{K}_{u}$ with the\r\nsubring $\\widetilde{K}_{u}\\otimes K=\\widetilde{K}_{u}\\otimes1$ of\r\n$\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$. Similarly, we can canonically\r\nidentify $\\widetilde{K}_{v}$ with the subring $1\\otimes\\widetilde{K}_{v}$ of\r\n$\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}$. These two identifications are\r\n\\textquotedblleft compatible at $K$\\textquotedblright\\ (that is, they lead to\r\none and the same embedding of $K$ into $\\widetilde{K}_{u}\\otimes\r\n\\widetilde{K}_{v}$). As a consequence, $\\widetilde{K}_{u}\\otimes\r\n\\widetilde{K}_{v}$ is an extension ring of $K$. This proves Theorem 5.3\r\n\\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have\r\n\\begin{align*}\r\nu\\widehat{+}v  &  =uv=\\prod\\limits_{i=1}^{m}\\left(  1+u_{i}T\\right)\r\n\\prod\\limits_{j=1}^{n}\\left(  1+v_{j}T\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }u=\\prod\\limits_{i=1}^{m}\\left(\r\n1+u_{i}T\\right)  \\text{ and }v=\\prod\\limits_{j=1}^{n}\\left(  1+v_{j}T\\right)\r\n\\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{1},u_{2},...,u_{m},v_{1}%\r\n,v_{2},...,v_{n}\\right]  \\right)\r\n\\end{align*}\r\n(by the definition of $\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{1}%\r\n,u_{2},...,u_{m},v_{1},v_{2},...,v_{n}\\right]  \\right)  $). This proves\r\nTheorem 5.3 \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Consider the ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n,V_{1},V_{2},...,V_{n}\\right]  $ (the polynomial ring in $m+n$ indeterminates\r\n$U_{1}$, $U_{2}$, $...$, $U_{m}$, $V_{1}$, $V_{2}$, $...$, $V_{n}$ over the\r\nring $\\mathbb{Z}$). For every $i\\in\\mathbb{N}$, let $X_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ be the $i$-th elementary\r\nsymmetric polynomial in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$. For\r\nevery $j\\in\\mathbb{N}$, let $Y_{j}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =j}}\\prod\\limits_{k\\in S}V_{k}$\r\nbe the $j$-th elementary symmetric polynomial in the variables $V_{1}$,\r\n$V_{2}$, $...$, $V_{n}$.\r\n\r\nThere exists a ring homomorphism%\r\n\\[\r\n\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]\r\n\\rightarrow\\widetilde{K}_{u,v}%\r\n\\]\r\nwhich maps $U_{i}$ to $u_{i}$ for every $i\\in\\left\\{  1,2,\\ldots,m\\right\\}  $\r\nand $V_{j}$ to $v_{j}$ for every $j\\in\\left\\{  1,2,\\ldots,n\\right\\}  $. This\r\nhomomorphism maps $X_{i}$ to $a_{i}$ for every $i\\in\\mathbb{N}$ (because\r\n$a_{i}$ is the $i$-th elementary symmetric polynomial applied to $u_{1}$,\r\n$u_{2}$, $...$, $u_{m}$) and $Y_{j}$ to $b_{j}$ for every $j\\in\\mathbb{N}$\r\n(for a similar reason). Hence, applying this homomorphism (or, rather, the\r\nring homomorphism $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1}%\r\n,V_{2},...,V_{n}\\right]  \\left[  T\\right]  \\rightarrow\\widetilde{K}%\r\n_{u,v}\\left[  T\\right]  $ that it induces) to (\\ref{Pk2}), we obtain%\r\n\\[\r\n\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  1+u_{i}v_{j}T\\right)  =\\sum_{k\\in\\mathbb{N}}%\r\nP_{k}\\left(  a_{1},a_{2},...,a_{k},b_{1},b_{2},...,b_{k}\\right)  T^{k}.\r\n\\]\r\nBut%\r\n\\[\r\n\\sum_{k\\in\\mathbb{N}}P_{k}\\left(  a_{1},a_{2},...,a_{k},b_{1},b_{2}%\r\n,...,b_{k}\\right)  T^{k}=\\left(  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)\r\n\\widehat{\\cdot}\\left(  \\sum_{i\\in\\mathbb{N}}b_{i}T^{i}\\right)\r\n=u\\widehat{\\cdot}v,\r\n\\]\r\nso this becomes%\r\n\\[\r\n\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  1+u_{i}v_{j}T\\right)  =u\\widehat{\\cdot}v,\r\n\\]\r\nand thus%\r\n\\begin{align*}\r\nu\\widehat{\\cdot}v  &  =\\prod_{\\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+u_{i}%\r\nv_{j}T\\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{i}v_{j}\\mid\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]\r\n\\right)\r\n\\end{align*}\r\n(by the definition of $\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{i}v_{j}%\r\n\\mid\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right]  \\right)  $). This proves Theorem 5.3 \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Consider the polynomial ring $\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $. For every $i\\in\\mathbb{N}$, let $X_{i}%\r\n=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ be the $i$-th elementary\r\nsymmetric polynomial in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$.\r\n\r\nThere exists a ring homomorphism $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  \\rightarrow\\widetilde{K}_{u}$ which maps $U_{i}$ to $u_{i}$ for every\r\n$i\\in\\left\\{  1,2,\\ldots,m\\right\\}  $. This homomorphism maps $X_{i}$ to\r\n$a_{i}$ for every $i\\in\\mathbb{N}$ (because $a_{i}$ is the $i$-th elementary\r\nsymmetric polynomial applied to $u_{1}$, $u_{2}$, $...$, $u_{m}$). Hence,\r\napplying this homomorphism (or, rather, the ring homomorphism $\\mathbb{Z}%\r\n\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  T\\right]  \\rightarrow\r\n\\widetilde{K}_{u}\\left[  T\\right]  $ that it induces) to (\\ref{Pkj2}), we\r\nobtain%\r\n\\[\r\n\\prod_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\left(  1+\\prod_{i\\in I}u_{i}\\cdot T\\right)  =\\sum_{k\\in\\mathbb{N}}%\r\nP_{k,j}\\left(  a_{1},a_{2},...,a_{kj}\\right)  T^{k}.\r\n\\]\r\nBut%\r\n\\[\r\n\\sum_{k\\in\\mathbb{N}}P_{k,j}\\left(  a_{1},a_{2},...,a_{kj}\\right)\r\nT^{k}=\\widehat{\\lambda}^{j}\\left(  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)\r\n=\\widehat{\\lambda}^{j}\\left(  u\\right)  ,\r\n\\]\r\nso this becomes%\r\n\\[\r\n\\prod_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\left(  1+\\prod_{i\\in I}u_{i}\\cdot T\\right)  =\\widehat{\\lambda}^{j}\\left(\r\nu\\right)  ,\r\n\\]\r\nand thus%\r\n\\[\r\n\\widehat{\\lambda}^{j}\\left(  u\\right)  =\\prod_{I\\in\\mathcal{P}_{j}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\right)  }\\left(  1+\\prod_{i\\in I}u_{i}\\cdot\r\nT\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in I}%\r\nu_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right]  \\right)\r\n\\]\r\n(by the definition of $\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in\r\nI}u_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right]  \\right)  $). This proves Theorem 5.3 \\textbf{(d)}.\r\n\\end{proof}\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 5.4.} Let $K$ be a ring. Let $\\widetilde{K}$ be a\r\nfinite-free extension ring of $K$. Let $I$ be some finite set, and let $T_{i}$\r\nbe a finite set for every $i\\in I$. Let $u_{i,j}$ be an element of\r\n$\\widetilde{K}$ for every $i\\in I$ and every $j\\in T_{i}$. We will write\r\n$\\left[  u_{i,j}\\mid i\\in I\\text{ and }j\\in T_{i}\\right]  $ for the multiset\r\nformed by all these $u_{i,j}$ (where each element occurs as often as it occurs\r\namong these $u_{i,j}$).\r\n\r\n\\textbf{(a)} Then,%\r\n\\[\r\n\\widehat{\\sum_{i\\in I}}\\Pi\\left(  \\widetilde{K},\\left[  u_{i,j}\\mid j\\in\r\nT_{i}\\right]  \\right)  =\\Pi\\left(  \\widetilde{K},\\left[  u_{i,j}\\mid i\\in\r\nI\\text{ and }j\\in T_{i}\\right]  \\right)  .\r\n\\]\r\nHere, the sign $\\widehat{\\sum\\limits_{i\\in I}}$ means a finite sum based on\r\nthe addition $\\widehat{+}$ of the ring $\\Lambda\\left(  K\\right)  $ (for\r\ninstance, $\\widehat{\\sum\\limits_{i\\in\\left\\{  1,2,3\\right\\}  }}a_{i}$ means\r\n$a_{1}\\widehat{+}a_{2}\\widehat{+}a_{3}$ and not $a_{1}+a_{2}+a_{3}$).\r\n\r\n\\textbf{(b)} Also,%\r\n\\[\r\n\\widehat{\\prod_{i\\in I}}\\Pi\\left(  \\widetilde{K},\\left[  u_{i,j}\\mid j\\in\r\nT_{i}\\right]  \\right)  =\\Pi\\left(  \\widetilde{K},\\left[  \\prod_{i\\in\r\nI}u_{i,j_{i}}\\mid\\left(  j_{i}\\right)  _{i\\in I}\\in\\prod_{i\\in I}T_{i}\\right]\r\n\\right)  .\r\n\\]\r\nHere, the sign $\\widehat{\\prod\\limits_{i\\in I}}$ means a finite product based\r\non the multiplication $\\widehat{\\cdot}$ of the ring $\\Lambda\\left(  K\\right)\r\n$ (for instance, $\\widehat{\\prod\\limits_{i\\in\\left\\{  1,2,3\\right\\}  }}a_{i}$\r\nmeans $a_{1}\\widehat{\\cdot}a_{2}\\widehat{\\cdot}a_{3}$ and not $a_{1}\\cdot\r\na_{2}\\cdot a_{3}$).\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary 5.4.]Part \\textbf{(a)} follows by induction from Theorem\r\n5.3 \\textbf{(b)}, and part \\textbf{(b)} follows by induction from Theorem 5.3\r\n\\textbf{(c)}.\r\n\\end{proof}\r\n\r\nFor later use, we restate parts \\textbf{(b)}, \\textbf{(c)} and \\textbf{(d)} of\r\nTheorem 5.3 in somewhat more flexible notations (and in a slightly extended\r\nform). First, let us deal with Theorem 5.3 \\textbf{(b)}:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.3' (b).} Let $K$ be a ring. Let $u\\in1+K\\left[  T\\right]\r\n^{+}$ and $v\\in1+K\\left[  T\\right]  ^{+}$. Assume that $u=\\Pi\\left(\r\n\\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in I\\right]  \\right)  $ for some\r\n$\\left(  \\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in I\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$, and that $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[\r\nv_{j}\\mid j\\in J\\right]  \\right)  $ for some $\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{j}\\mid j\\in J\\right]  \\right)  \\in K^{\\operatorname*{int}}$.\r\nLet $\\widetilde{K}$ be a finite-free extension ring of $K$ such that\r\n$\\widetilde{K}_{u}$ and $\\widetilde{K}_{v}$ are subrings of $\\widetilde{K}$.\r\n\r\nWe have $u\\widehat{+}v=\\Pi\\left(  \\widetilde{K},\\left[  u_{i}\\mid i\\in\r\nI\\right]  \\cup\\left[  v_{j}\\mid j\\in J\\right]  \\right)  $. Here, for any two\r\nmultisets $X$ and $Y$, we let $X\\cup Y$ denote the multiset such that every\r\nobject $z$ satisfies%\r\n\\begin{align*}\r\n&  \\left(  \\text{the multiplicity of }z\\text{ in }X\\cup Y\\right) \\\\\r\n&  =\\left(  \\text{the multiplicity of }z\\text{ in }X\\right)  +\\left(\r\n\\text{the multiplicity of }z\\text{ in }Y\\right)  .\r\n\\end{align*}\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.3' \\textbf{(b)}.]The set $I$ is a finite set used merely\r\nfor labelling. Hence, we can WLOG assume that $I=\\left\\{  1,2,\\ldots\r\n,m\\right\\}  $ for some $m\\in\\mathbb{N}$. Assume this; thus, $\\left[  u_{i}\\mid\r\ni\\in I\\right]  =\\left[  u_{1},u_{2},\\ldots,u_{m}\\right]  $. Hence,\r\n$u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in I\\right]  \\right)  $\r\nrewrites as \\newline$u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2}%\r\n,\\ldots,u_{m}\\right]  \\right)  $.\r\n\r\nThe set $J$ is a finite set used merely for labelling. Hence, we can WLOG\r\nassume that $J=\\left\\{  1,2,\\ldots,n\\right\\}  $ for some $n\\in\\mathbb{N}$.\r\nAssume this; thus, $\\left[  v_{j}\\mid j\\in J\\right]  =\\left[  v_{1}%\r\n,v_{2},...,v_{n}\\right]  $. Hence, $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[\r\nv_{j}\\mid j\\in J\\right]  \\right)  $ rewrites as $v=\\Pi\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  $.\r\n\r\nFrom $\\left[  u_{i}\\mid i\\in I\\right]  =\\left[  u_{1},u_{2},\\ldots\r\n,u_{m}\\right]  $ and $\\left[  v_{j}\\mid j\\in J\\right]  =\\left[  v_{1}%\r\n,v_{2},...,v_{n}\\right]  $, we obtain%\r\n\\begin{align}\r\n\\left[  u_{i}\\mid i\\in I\\right]  \\cup\\left[  v_{j}\\mid j\\in J\\right]   &\r\n=\\left[  u_{1},u_{2},\\ldots,u_{m}\\right]  \\cup\\left[  v_{1},v_{2}%\r\n,...,v_{n}\\right] \\nonumber\\\\\r\n&  =\\left[  u_{1},u_{2},...,u_{m},v_{1},v_{2},...,v_{n}\\right]  .\r\n\\label{pf.thm.5.3'.b.1}%\r\n\\end{align}\r\nBut Theorem 5.3 \\textbf{(b)} shows that $u\\widehat{+}v=\\Pi\\left(\r\n\\widetilde{K},\\left[  u_{1},u_{2},...,u_{m},v_{1},v_{2},...,v_{n}\\right]\r\n\\right)  $. In view of (\\ref{pf.thm.5.3'.b.1}), this rewrites as\r\n$u\\widehat{+}v=\\Pi\\left(  \\widetilde{K},\\left[  u_{i}\\mid i\\in I\\right]\r\n\\cup\\left[  v_{j}\\mid j\\in J\\right]  \\right)  $. This proves Theorem 5.3'\r\n\\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.3' (c).} Let $K$ be a ring. Let $u\\in1+K\\left[  T\\right]\r\n^{+}$ and $v\\in1+K\\left[  T\\right]  ^{+}$. Assume that $u=\\Pi\\left(\r\n\\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in I\\right]  \\right)  $ for some\r\n$\\left(  \\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in I\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$, and that $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[\r\nv_{j}\\mid j\\in J\\right]  \\right)  $ for some $\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{j}\\mid j\\in J\\right]  \\right)  \\in K^{\\operatorname*{int}}$.\r\nLet $\\widetilde{K}$ be a finite-free extension ring of $K$ such that\r\n$\\widetilde{K}_{u}$ and $\\widetilde{K}_{v}$ are subrings of $\\widetilde{K}$.\r\n\r\nWe have $u\\widehat{\\cdot}v=\\Pi\\left(  \\widetilde{K},\\left[  u_{i}v_{j}%\r\n\\mid\\left(  i,j\\right)  \\in I\\times J\\right]  \\right)  $\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.3' \\textbf{(c)}.]We can derive Theorem 5.3' \\textbf{(c)}\r\nfrom Theorem 5.3 \\textbf{(c)} in the same way as Theorem 5.3' \\textbf{(b)} was\r\nderived from Theorem 5.3 \\textbf{(b)}.\r\n\\end{proof}\r\n\r\nFinally, let us restate Theorem 5.3 \\textbf{(d)}:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.3' (d)}. Let $K$ be a ring. Let $w\\in1+K\\left[  T\\right]\r\n^{+}$. Assume that $w=\\Pi\\left(  \\widetilde{K},\\left[  w_{\\ell}\\mid\\ell\\in\r\nL\\right]  \\right)  $ for some $\\left(  \\widetilde{K},\\left[  w_{\\ell}\\mid\r\n\\ell\\in L\\right]  \\right)  \\in K^{\\operatorname*{int}}$. Let $k\\in\\mathbb{N}$.\r\nThen,%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  w\\right)  =\\Pi\\left(  \\widetilde{K},\\left[\r\n\\prod_{\\ell\\in S}w_{\\ell}\\mid S\\in\\mathcal{P}_{k}\\left(  L\\right)  \\right]\r\n\\right)  .\r\n\\]\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.3' \\textbf{(d)}.]Since $L$ is a finite set used only for\r\nlabelling, we can WLOG assume that $L=\\left\\{  1,2,...,m\\right\\}  $ for some\r\n$m\\in\\mathbb{N}$. Thus, $w=\\Pi\\left(  \\widetilde{K},\\left[  w_{\\ell}\\mid\r\n\\ell\\in L\\right]  \\right)  $ rewrites as $w=\\Pi\\left(  \\widetilde{K},\\left[\r\nw_{\\ell}\\mid\\ell\\in\\left\\{  1,2,...,m\\right\\}  \\right]  \\right)  =\\Pi\\left(\r\n\\widetilde{K},\\left[  w_{1},w_{2},...,w_{m}\\right]  \\right)  $. Hence, we can\r\napply Theorem 5.3 \\textbf{(d)} to $u=w$, $j=k$, $\\widetilde{K}_{u}%\r\n=\\widetilde{K}$, and $u_{\\ell}=w_{\\ell}$\\ \\ \\ \\ \\footnote{To be fully precise,\r\nwe also need to specify $v$, $\\left(  \\widetilde{K}_{v},\\left[  v_{1}%\r\n,v_{2},\\ldots,v_{n}\\right]  \\right)  $ and $\\widetilde{K}_{u,v}$ in order to\r\napply Theorem 5.3 \\textbf{(d)}. But $v$ and $\\left(  \\widetilde{K}_{v},\\left[\r\nv_{1},v_{2},\\ldots,v_{n}\\right]  \\right)  $ have not been used in the proof of\r\nTheorem 5.3 \\textbf{(d)}, and $\\widetilde{K}_{u,v}$ can just be taken to be\r\n$\\widetilde{K}$.}, and obtain%\r\n\\begin{align*}\r\n\\widehat{\\lambda}^{k}\\left(  w\\right)   &  =\\Pi\\left(  \\widetilde{K},\\left[\r\n\\prod_{i\\in I}w_{i}\\mid I\\in\\mathcal{P}_{k}\\left(  \\underbrace{\\left\\{\r\n1,2,...,m\\right\\}  }_{=L}\\right)  \\right]  \\right)  =\\Pi\\left(  \\widetilde{K}%\r\n,\\left[  \\prod_{i\\in I}w_{i}\\mid I\\in\\mathcal{P}_{k}\\left(  L\\right)  \\right]\r\n\\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K},\\left[  \\prod_{\\ell\\in S}w_{\\ell}\\mid\r\nS\\in\\mathcal{P}_{k}\\left(  L\\right)  \\right]  \\right)\r\n\\end{align*}\r\n(here, we renamed $i$ and $I$ as $\\ell$ and $S$). This proves Theorem 5.3'\r\n\\textbf{(d)}.\r\n\\end{proof}\r\n\r\n\\subsection{Preparing for the proof of Theorem 5.1: the $\\left(  T\\right)\r\n$-topology}\r\n\r\nWe are approaching the proof of Theorem 5.1. The idea of the proof is: We have\r\nto show some identities for elements of $1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}$ (such as associativity of multiplication). Computing with elements of\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ can be difficult, but computing\r\nwith elements of $1+K\\left[  T\\right]  ^{+}$ is rather easy thanks to Theorem\r\n5.3. Hence, we are going to reduce Theorem 5.1 to the case when our elements\r\nare in $1+K\\left[  T\\right]  ^{+}$. The reader is encouraged to try doing this\r\non his own. In practice, it is a matter of noticing that for every\r\n$k\\in\\mathbb{N}$, only the first so and so many coefficients of the power\r\nseries $u$ and $v$ matter when computing the $k$-th coefficient of\r\n$u\\widehat{\\cdot}v$ (for instance), and thus we can truncate the power series\r\nat these coefficients, thus turning it into a polynomial. The abstract\r\nalgebraical way to formulate this argument is by introducing the so-called\r\n$\\left(  T\\right)  $\\textit{-topology} (also called the $\\left(  T\\right)\r\n$\\textit{-adic topology}) on $K\\left[  \\left[  T\\right]  \\right]  $:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. As a $K$-module, $K\\left[  \\left[\r\nT\\right]  \\right]  =\\prod\\limits_{k\\in\\mathbb{N}}KT^{k}$. Now, we define the\r\nso-called $\\left(  T\\right)  $\\textit{-topology} on the ring $K\\left[  \\left[\r\nT\\right]  \\right]  $ as the topology generated by%\r\n\\[\r\n\\left\\{  u+T^{N}K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ u\\in K\\left[\r\n\\left[  T\\right]  \\right]  \\text{ and }N\\in\\mathbb{N}\\right\\}  .\r\n\\]\r\nIn other words, the open sets of this topology should be all\r\ntranslates\\footnote{The notion of a \\textquotedblleft\r\ntranslate\\textquotedblright\\ is defined as follows: If $A$ is an additive\r\ngroup and $B$ is a subset of $A$, then a \\textit{translate} of $B$ (in $A$)\r\nmeans a subset of $A$ having the form%\r\n\\[\r\na+B=\\left\\{  a+b\\ \\mid\\ b\\in B\\right\\}\r\n\\]\r\nfor some $a\\in A$.} of the $K$-submodules $T^{N}K\\left[  \\left[  T\\right]\r\n\\right]  $ for $N\\in\\mathbb{N}$, as well as the unions of these\r\ntranslates\\footnote{This includes the empty union, which is $\\varnothing$.}.\r\n(Note that, for each $N\\in\\mathbb{N}$, the set $T^{N}K\\left[  \\left[\r\nT\\right]  \\right]  $ is actually an ideal of $K\\left[  \\left[  T\\right]\r\n\\right]  $, and consists of all power series $f\\in K\\left[  \\left[  T\\right]\r\n\\right]  $ whose coefficients before $T^{0},T^{1},\\ldots,T^{N-1}$ all vanish.\r\nThis ideal $T^{N}K\\left[  \\left[  T\\right]  \\right]  $ can also be described\r\nas the $N$-th power of the ideal $TK\\left[  \\left[  T\\right]  \\right]  $;\r\ntherefore, the $\\left(  T\\right)  $-topology on $K\\left[  \\left[  T\\right]\r\n\\right]  $ is precisely the so-called $TK\\left[  \\left[  T\\right]  \\right]\r\n$-adic topology. Also note that every translate of the submodule\r\n$T^{N}K\\left[  \\left[  T\\right]  \\right]  $ for $N\\in\\mathbb{N}$ actually has\r\nthe form $p+T^{N}K\\left[  \\left[  T\\right]  \\right]  $ for a polynomial $p\\in\r\nK\\left[  T\\right]  $ of degree $<N$, and this polynomial is uniquely\r\ndetermined.) It is well-known that the $\\left(  T\\right)  $-topology makes\r\n$K\\left[  \\left[  T\\right]  \\right]  $ into a topological ring.\r\n\\end{quote}\r\n\r\nThis $\\left(  T\\right)  $-topology is a particular case of several known\r\nconstructions; for example, a similar way exists to define a topology on the\r\ncompletion of any graded ring, or on a ring with a given ideal, or on the ring\r\nwith a given sequence of ideals satisfying certain properties. We will need\r\nonly the $\\left(  T\\right)  $-topology, however.\r\n\r\nNow, an easy fact:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.5.} Let $K$ be a ring. The $\\left(  T\\right)  $-topology on\r\nthe ring $K\\left[  \\left[  T\\right]  \\right]  $ restricts to a topology on its\r\nsubset $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$; we call this topology the\r\n$\\left(  T\\right)  $\\textit{-topology} again. Whenever we say ``open'',\r\n``continuous'', ``dense'', etc., we are referring to this topology.\r\n\r\n\\textbf{(a)} The subset $1+K\\left[  T\\right]  ^{+}$ is dense in $1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$.\r\n\r\n\\textbf{(b)} Let $f:1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\rightarrow\r\n1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ be a map such that for every\r\n$n\\in\\mathbb{N}$ there exists some $N\\in\\mathbb{N}$ such that the first $n$\r\ncoefficients of the image of a formal power series under $f$ depend only on\r\nthe first $N$ coefficients of the series itself (and not on the remaining\r\nones). Then, $f$ is continuous.\r\n\r\n\\textbf{(c)} Let $g:\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)\r\n\\times\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)\r\n\\rightarrow1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ be a map such that for\r\nevery $n\\in\\mathbb{N}$ there exists some $N\\in\\mathbb{N}$ such that the first\r\n$n$ coefficients of the image of a pair of formal power series under $f$\r\ndepend only on the first $N$ coefficients of the two series itself (and not on\r\nthe remaining ones). Then, $g$ is continuous.\r\n\r\n\\textbf{(d)} The map%\r\n\\begin{align*}\r\n\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)  \\times\\left(\r\n1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)   &  \\rightarrow1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+},\\\\\r\n\\left(  u,v\\right)   &  \\mapsto u\\widehat{+}v,\r\n\\end{align*}\r\nthe map%\r\n\\begin{align*}\r\n\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)  \\times\\left(\r\n1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)   &  \\rightarrow1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+},\\\\\r\n\\left(  u,v\\right)   &  \\mapsto u\\widehat{-}v,\r\n\\end{align*}\r\nthe map%\r\n\\begin{align*}\r\n\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)  \\times\\left(\r\n1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)   &  \\rightarrow1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+},\\\\\r\n\\left(  u,v\\right)   &  \\mapsto u\\widehat{\\cdot}v,\r\n\\end{align*}\r\nand the map $\\widehat{\\lambda}^{j}:1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}\\rightarrow1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ for every\r\n$j\\in\\mathbb{N}$ are continuous.\r\n\r\n\\textbf{(e)} The topological spaces $K\\left[  \\left[  T\\right]  \\right]  $ and\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ are Hausdorff spaces.\r\n\\end{quote}\r\n\r\nNote that Theorem 5.5 \\textbf{(d)} yields that any finite compositions of the\r\nmaps $\\widehat{+}$, $\\widehat{-}$, $\\widehat{\\cdot}$ and $\\widehat{\\lambda\r\n}^{j}$ are continuous (since finite compositions of continuous functions are\r\ncontinuous). In particular, any polynomial with integral coefficients acts on\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ as a continuous map.\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.5.]\\textbf{(a)} and \\textbf{(e)} are done in any\r\ncommutative algebra book such as \\cite[Chapter 10]{AtiMac69}.\r\n\r\n\\textbf{(b)} and \\textbf{(c)} are basic exercises in topology.\r\n\r\n\\textbf{(d)} follows from \\textbf{(b)} and \\textbf{(c)} together with the\r\ndefinitions of $\\widehat{+}$, $\\widehat{\\cdot}$ and $\\widehat{\\lambda}^{j}$.\r\n\\end{proof}\r\n\r\n\\subsection{Proof of Theorem 5.1}\r\n\r\nNow it comes:\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.1.]\\textbf{(a)} We have to prove the ring axioms for\r\n$\\left(  1+K\\left[  \\left[  T\\right]  \\right]  ^{+},\\widehat{+},\\widehat{\\cdot\r\n}\\right)  $ (including the unity axiom for $1+T$). There are several axioms to\r\nbe checked, but the idea is always the same, so we will only check the\r\nassociativity of $\\widehat{\\cdot}$ and leave the rest to the reader.\r\n\r\nIn order to prove that the operation $\\widehat{\\cdot}$ is associative, we must\r\nshow that $u\\widehat{\\cdot}\\left(  v\\widehat{\\cdot}w\\right)  =\\left(\r\nu\\widehat{\\cdot}v\\right)  \\widehat{\\cdot}w$ for all $u,v,w\\in1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$. Since the operation $\\widehat{\\cdot}$ is\r\ncontinuous (by Theorem 5.5 \\textbf{(d)}), and since $1+K\\left[  T\\right]\r\n^{+}$ is a dense subset of $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ (by\r\nTheorem 5.5 \\textbf{(a)}), this needs only to be shown for all $u,v,w\\in\r\n1+K\\left[  T\\right]  ^{+}$.\\ \\ \\ \\ \\footnote{At this point, we are actually\r\nalso using Theorem 5.5 \\textbf{(e)}. In fact, what we are using is the fact\r\nthat if two continuous maps from a topological space $\\mathfrak{P}$ to a\r\nHausdorff topological space $\\mathfrak{Q}$ are equal to each other on a dense\r\nsubset of $\\mathfrak{P}$, then they are equal to each other on the whole\r\n$\\mathfrak{P}$.} So let us assume that $u,v,w\\in1+K\\left[  T\\right]  ^{+}$.\r\nRecall that the map $\\Pi$ is surjective. Hence, there exist\r\n\r\n\\begin{itemize}\r\n\\item some $\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $,\r\n\r\n\\item some $\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $v=\\Pi\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  $,\r\n\r\n\\item some $\\left(  \\widetilde{K}_{w},\\left[  w_{1},w_{2},...,w_{\\ell}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $w=\\Pi\\left(  \\widetilde{K}%\r\n_{w},\\left[  w_{1},w_{2},...,w_{\\ell}\\right]  \\right)  $.\r\n\\end{itemize}\r\n\r\nConsider these elements of $K^{\\operatorname*{int}}$. Notice that\r\n\\[\r\nu=\\Pi\\left(  \\widetilde{K}_{u},\\underbrace{\\left[  u_{1},u_{2},...,u_{m}%\r\n\\right]  }_{=\\left[  u_{i}\\mid i\\in\\left\\{  1,2,\\ldots,m\\right\\}  \\right]\r\n}\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{i}\\mid i\\in\\left\\{\r\n1,2,\\ldots,m\\right\\}  \\right]  \\right)\r\n\\]\r\nand%\r\n\\[\r\nw=\\Pi\\left(  \\widetilde{K}_{w},\\underbrace{\\left[  w_{1},w_{2},...,w_{\\ell\r\n}\\right]  }_{=\\left[  w_{k}\\mid k\\in\\left\\{  1,2,\\ldots,\\ell\\right\\}  \\right]\r\n}\\right)  =\\Pi\\left(  \\widetilde{K}_{w},\\left[  w_{k}\\mid k\\in\\left\\{\r\n1,2,\\ldots,\\ell\\right\\}  \\right]  \\right)  .\r\n\\]\r\n\r\n\r\nLet $L=\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}\\otimes\\widetilde{K}_{w}$.\r\nClearly, $L$ is a finite-free $K$-module (since it is the tensor product of\r\nthe finite-free $K$-modules $\\widetilde{K}_{u}$, $\\widetilde{K}_{v}$,\r\n$\\widetilde{K}_{w}$). We identify the rings $\\widetilde{K}_{u}$,\r\n$\\widetilde{K}_{v}$, $\\widetilde{K}_{w}$ with the subrings $\\widetilde{K}%\r\n_{u}\\otimes1\\otimes1$, $1\\otimes\\widetilde{K}_{v}\\otimes1$, $1\\otimes\r\n1\\otimes\\widetilde{K}_{w}$ of the ring $L=\\widetilde{K}_{u}\\otimes\r\n\\widetilde{K}_{v}\\otimes\\widetilde{K}_{w}$, respectively\\footnote{This is\r\nlegitimate, because the canonical ring homomorphisms $\\widetilde{K}_{u}%\r\n\\otimes1\\otimes1\\rightarrow\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}%\r\n\\otimes\\widetilde{K}_{w}$, $1\\otimes\\widetilde{K}_{v}\\otimes1\\rightarrow\r\n\\widetilde{K}_{u}\\otimes\\widetilde{K}_{v}\\otimes\\widetilde{K}_{w}$ and\r\n$1\\otimes1\\otimes\\widetilde{K}_{w}\\rightarrow\\widetilde{K}_{u}\\otimes\r\n\\widetilde{K}_{v}\\otimes\\widetilde{K}_{w}$ are injective (indeed, the\r\n$K$-modules $\\widetilde{K}_{u}$, $\\widetilde{K}_{v}$ and $\\widetilde{K}_{w}$\r\nare finite free, and therefore tensoring with each of these $K$-modules is an\r\nexact functor).}. This way, $L$ becomes a finite-free extension ring of $K$\r\nwhich contains all three rings $\\widetilde{K}_{u}$, $\\widetilde{K}_{v}$,\r\n$\\widetilde{K}_{w}$ as subrings. Now, Theorem 5.3 \\textbf{(c)} yields%\r\n\\[\r\nu\\widehat{\\cdot}v=\\Pi\\left(  L,\\left[  u_{i}v_{j}\\mid\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]\r\n\\right)  .\r\n\\]\r\nHence, Theorem 5.3' \\textbf{(c)} (applied to $u\\widehat{\\cdot}v$, $w$, $L$,\r\n$\\left[  u_{i}v_{j}\\mid\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  \\right]  $, $\\widetilde{K}_{w}$, $\\left[\r\nw_{k}\\mid k\\in\\left\\{  1,2,\\ldots,\\ell\\right\\}  \\right]  $ and $L$ instead of\r\n$u$, $v$, $\\widetilde{K}_{u}$, $\\left[  u_{i}\\mid i\\in I\\right]  $,\r\n$\\widetilde{K}_{v}$, $\\left[  v_{j}\\mid j\\in J\\right]  $ and $\\widetilde{K}$)\r\nyields\r\n\\[\r\n\\left(  u\\widehat{\\cdot}v\\right)  \\widehat{\\cdot}w=\\Pi\\left(  L,\\left[\r\n\\left(  u_{i}v_{j}\\right)  w_{k}\\mid\\left(  \\left(  i,j\\right)  ,k\\right)\r\n\\in\\left(  \\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n\\right)  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right]  \\right)  .\r\n\\]\r\n\r\n\r\nAlso, Theorem 5.3 \\textbf{(c)} (applied to $v$, $w$, $\\widetilde{K}_{v}$,\r\n$\\left[  v_{1},v_{2},\\ldots,v_{n}\\right]  $, $\\widetilde{K}_{w}$, $\\left[\r\nw_{1},w_{2},\\ldots,w_{\\ell}\\right]  $ and $L$ instead of $u$, $v$,\r\n$\\widetilde{K}_{u}$, $\\left[  u_{1},u_{2},\\ldots,u_{m}\\right]  $,\r\n$\\widetilde{K}_{v}$, $\\left[  v_{1},v_{2},\\ldots,v_{n}\\right]  $ and\r\n$\\widetilde{K}_{u,v}$) yields%\r\n\\[\r\nv\\widehat{\\cdot}w=\\Pi\\left(  L,\\left[  v_{j}w_{k}\\mid\\left(  j,k\\right)\r\n\\in\\left\\{  1,2,...,n\\right\\}  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right]\r\n\\right)  .\r\n\\]\r\nHence, Theorem 5.3' \\textbf{(c)} (applied to $u$, $v\\widehat{\\cdot}w$,\r\n$\\widetilde{K}_{u}$, $\\left[  u_{i}\\mid i\\in I\\right]  $, $L$, $\\left[\r\nv_{j}w_{k}\\mid\\left(  j,k\\right)  \\in\\left\\{  1,2,...,n\\right\\}\r\n\\times\\left\\{  1,2,...,\\ell\\right\\}  \\right]  $ and $L$ instead of $u$, $v$,\r\n$\\widetilde{K}_{u}$, $\\left[  u_{i}\\mid i\\in I\\right]  $, $\\widetilde{K}_{v}$,\r\n$\\left[  v_{j}\\mid j\\in J\\right]  $ and $\\widetilde{K}$) yields%\r\n\\[\r\nu\\widehat{\\cdot}\\left(  v\\widehat{\\cdot}w\\right)  =\\Pi\\left(  L,\\left[\r\nu_{i}\\left(  v_{j}w_{k}\\right)  \\mid\\left(  i,\\left(  j,k\\right)  \\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left(  \\left\\{  1,2,...,n\\right\\}\r\n\\times\\left\\{  1,2,...,\\ell\\right\\}  \\right)  \\right]  \\right)  .\r\n\\]\r\n\r\n\r\nBut there is a canonical isomorphism of sets%\r\n\\[\r\n\\left(  \\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right)\r\n\\times\\left\\{  1,2,...,\\ell\\right\\}  \\rightarrow\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left(  \\left\\{  1,2,...,n\\right\\}  \\times\\left\\{  1,2,...,\\ell\\right\\}\r\n\\right)  ,\r\n\\]\r\nmapping every $\\left(  \\left(  i,j\\right)  ,k\\right)  $ to $\\left(  i,\\left(\r\nj,k\\right)  \\right)  $. Hence,%\r\n\\begin{align*}\r\n&  \\Pi\\left(  L,\\left[  \\left(  u_{i}v_{j}\\right)  w_{k}\\mid\\left(  \\left(\r\ni,j\\right)  ,k\\right)  \\in\\left(  \\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right)  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right]\r\n\\right) \\\\\r\n&  =\\Pi\\left(  L,\\left[  \\underbrace{\\left(  u_{i}v_{j}\\right)  w_{k}}%\r\n_{=u_{i}\\left(  v_{j}w_{k}\\right)  }\\mid\\left(  i,\\left(  j,k\\right)  \\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left(  \\left\\{  1,2,...,n\\right\\}\r\n\\times\\left\\{  1,2,...,\\ell\\right\\}  \\right)  \\right]  \\right) \\\\\r\n&  =\\Pi\\left(  L,\\left[  u_{i}\\left(  v_{j}w_{k}\\right)  \\mid\\left(  i,\\left(\r\nj,k\\right)  \\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left(  \\left\\{\r\n1,2,...,n\\right\\}  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right)  \\right]\r\n\\right)  .\r\n\\end{align*}\r\nThus,%\r\n\\begin{align*}\r\n\\left(  u\\widehat{\\cdot}v\\right)  \\widehat{\\cdot}w  &  =\\Pi\\left(  L,\\left[\r\n\\left(  u_{i}v_{j}\\right)  w_{k}\\mid\\left(  \\left(  i,j\\right)  ,k\\right)\r\n\\in\\left(  \\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n\\right)  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right]  \\right) \\\\\r\n&  =\\Pi\\left(  L,\\left[  u_{i}\\left(  v_{j}w_{k}\\right)  \\mid\\left(  i,\\left(\r\nj,k\\right)  \\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left(  \\left\\{\r\n1,2,...,n\\right\\}  \\times\\left\\{  1,2,...,\\ell\\right\\}  \\right)  \\right]\r\n\\right) \\\\\r\n&  =u\\widehat{\\cdot}\\left(  v\\widehat{\\cdot}w\\right)  .\r\n\\end{align*}\r\nThis proves the associativity of the operation $\\widehat{\\cdot}$. As I said\r\nabove, the other ring axioms can be proven similarly, so we can consider\r\nTheorem 5.1 \\textbf{(a)} as proven.\r\n\r\n\\textbf{(b)} It is easy to see that\r\n\\[\r\n\\widehat{\\lambda}^{0}\\left(  x\\right)  =1+T=\\left(  \\text{the multiplicative\r\nunity of the ring }\\left(  1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+},\\widehat{+},\\widehat{\\cdot}\\right)  \\right)\r\n\\]\r\nand\r\n\\[\r\n\\widehat{\\lambda}^{1}\\left(  x\\right)  =x\r\n\\]\r\nfor every $x\\in\\Lambda\\left(  K\\right)  $. It now remains to prove that%\r\n\\begin{equation}\r\n\\widehat{\\lambda}^{j}\\left(  u\\widehat{+}v\\right)  =\\widehat{\\sum_{i=0}^{j}%\r\n}\\widehat{\\lambda}^{i}\\left(  u\\right)  \\widehat{\\cdot}\\widehat{\\lambda}%\r\n^{j-i}\\left(  v\\right)  \\label{SpezLemma1}%\r\n\\end{equation}\r\nfor every $j\\in\\mathbb{N}$, $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\r\n\\Lambda\\left(  K\\right)  $. Here, the sign $\\widehat{\\sum\\limits_{i=0}^{j}}$\r\nmeans that the summation is based on the addition $\\widehat{+}$ of the ring\r\n$\\Lambda\\left(  K\\right)  $.\r\n\r\nLet us fix some $j\\in\\mathbb{N}$. Since the addition $\\widehat{+}$, the\r\nmultiplication $\\widehat{\\cdot}$ and the map $\\widehat{\\lambda}^{i}$ for every\r\n$i\\in\\mathbb{N}$ are continuous (by Theorem 5.5 \\textbf{(d)}), and since\r\n$1+K\\left[  T\\right]  ^{+}$ is a dense subset of $1+K\\left[  \\left[  T\\right]\r\n\\right]  ^{+}$ (by Theorem 5.5 \\textbf{(a)}), we only need to check\r\n(\\ref{SpezLemma1}) for all $u,v\\in1+K\\left[  T\\right]  ^{+}$. So let us assume\r\nthat $u,v\\in1+K\\left[  T\\right]  ^{+}$. Then, there exist some $\\left(\r\n\\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\nu_{1},u_{2},...,u_{m}\\right]  \\right)  $, and some $\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}%\r\n}$ such that $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2}%\r\n,...,v_{n}\\right]  \\right)  $. Let $\\widetilde{K}_{u,v}$ be a finite-free\r\nextension ring of $K$ which contains both $\\widetilde{K}_{u}$ and\r\n$\\widetilde{K}_{v}$ as subrings. (Such an extension ring exists, as was proven\r\nin Theorem 5.3 \\textbf{(a)}.) Theorem 5.3 \\textbf{(b)} yields%\r\n\\[\r\nu\\widehat{+}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{1},u_{2}%\r\n,...,u_{m},v_{1},v_{2},...,v_{n}\\right]  \\right)  .\r\n\\]\r\nIn other words, if we define $m+n$ elements $w_{1}$, $w_{2}$, $...$, $w_{m+n}$\r\nby\r\n\\[\r\nw_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nu_{i},\\text{ if }i\\leq m;\\\\\r\nv_{i-m},\\text{ if }i>m\r\n\\end{array}\r\n\\right.  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }i\\in\\left\\{\r\n1,2,...,m+n\\right\\}  ,\r\n\\]\r\nthen%\r\n\\[\r\nu\\widehat{+}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  w_{1},w_{2}%\r\n,...,w_{m+n}\\right]  \\right)  .\r\n\\]\r\nThus, Theorem 5.3 \\textbf{(d)} yields%\r\n\\[\r\n\\widehat{\\lambda}^{j}\\left(  u\\widehat{+}v\\right)  =\\Pi\\left(  \\widetilde{K}%\r\n_{u,v},\\left[  \\prod\\limits_{i\\in I}w_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(\r\n\\left\\{  1,2,...,m+n\\right\\}  \\right)  \\right]  \\right)  .\r\n\\]\r\nBut since%\r\n\\begin{align*}\r\n&  \\left[  \\prod\\limits_{i\\in I}w_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(\r\n\\left\\{  1,2,...,m+n\\right\\}  \\right)  \\right] \\\\\r\n&  =\\left[  \\prod\\limits_{\\gamma\\in I}w_{\\gamma}\\ \\mid\\ I\\in\\mathcal{P}%\r\n_{j}\\left(  \\left\\{  1,2,...,m+n\\right\\}  \\right)  \\right] \\\\\r\n&  =\\left[  \\prod\\limits_{\\gamma\\in J\\cup K^{\\prime}}w_{\\gamma}\\ \\mid\r\n\\ i\\in\\left\\{  0,1,...,j\\right\\}  \\text{, }J\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\text{, }K^{\\prime}\\in\\mathcal{P}_{j-i}\\left(\r\n\\left\\{  m+1,m+2,...,m+n\\right\\}  \\right)  \\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because every set }I\\in\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m+n\\right\\}  \\right)  \\text{ can be uniquely}\\\\\r\n\\text{written as a union }J\\cup K^{\\prime}\\text{ of two sets }J\\in\r\n\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\text{ and}\\\\\r\nK^{\\prime}\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  m+1,m+2,...,m+n\\right\\}\r\n\\right)  \\text{ for some }i\\in\\left\\{  0,1,...,j\\right\\} \\\\\r\n\\text{(namely, these two sets are }J=I\\cap\\left\\{  1,2,...,m\\right\\}  \\text{\r\nand}\\\\\r\nK^{\\prime}=I\\cap\\left\\{  m+1,m+2,...,m+n\\right\\}  \\text{, and }i\\text{ is the\r\ncardinality of }J\\text{)}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\left[  \\prod\\limits_{\\alpha\\in J}w_{\\alpha}\\prod\\limits_{\\beta\\in\r\nK^{\\prime}}w_{\\beta}\\ \\mid\\ i\\in\\left\\{  0,1,...,j\\right\\}  \\text{, }%\r\nJ\\in\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\text{,\r\n}K^{\\prime}\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  m+1,m+2,...,m+n\\right\\}\r\n\\right)  \\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\prod\\limits_{\\gamma\\in J\\cup\r\nK^{\\prime}}w_{\\gamma}=\\prod\\limits_{\\alpha\\in J}w_{\\alpha}\\prod\\limits_{\\beta\r\n\\in K^{\\prime}}w_{\\beta}\\text{ (because }J\\cap K^{\\prime}=\\varnothing\r\n\\text{)}\\right) \\\\\r\n&  =\\left[  \\prod\\limits_{\\alpha\\in J}w_{\\alpha}\\prod\\limits_{\\beta\\in\r\nM}w_{m+\\beta}\\ \\mid\\ i\\in\\left\\{  0,1,...,j\\right\\}  \\text{, }J\\in\r\n\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\text{, }%\r\nM\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  1,2,...,n\\right\\}  \\right)  \\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we have substituted }M=\\left\\{\r\nu-m\\mid u\\in K^{\\prime}\\right\\}  \\text{ for }K^{\\prime}\\right) \\\\\r\n&  =\\left[  \\prod\\limits_{\\alpha\\in J}u_{\\alpha}\\prod\\limits_{\\beta\\in\r\nM}v_{\\beta}\\ \\mid\\ i\\in\\left\\{  0,1,...,j\\right\\}  \\text{, }J\\in\r\n\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\text{, }%\r\nM\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  1,2,...,n\\right\\}  \\right)  \\right] \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }w_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nu_{i},\\text{ if }i\\leq m;\\\\\r\nv_{i-m},\\text{ if }i>m\r\n\\end{array}\r\n\\right.  \\right)  ,\r\n\\end{align*}\r\nthis becomes%\r\n\\begin{align*}\r\n&  \\widehat{\\lambda}^{j}\\left(  u\\widehat{+}v\\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  \\prod\\limits_{\\alpha\\in J}%\r\nu_{\\alpha}\\prod\\limits_{\\beta\\in M}v_{\\beta}\\ \\mid\\ i\\in\\left\\{\r\n0,1,...,j\\right\\}  \\text{, }J\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\text{, }M\\in\\mathcal{P}_{j-i}\\left(  \\left\\{\r\n1,2,...,n\\right\\}  \\right)  \\right]  \\right) \\\\\r\n&  =\\widehat{\\sum_{i=0}^{j}}\\underbrace{\\Pi\\left(  \\widetilde{K}_{u,v},\\left[\r\n\\prod\\limits_{\\alpha\\in J}u_{\\alpha}\\prod\\limits_{\\beta\\in M}v_{\\beta}%\r\n\\ \\mid\\ J\\in\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\text{, }M\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  1,2,...,n\\right\\}  \\right)\r\n\\right]  \\right)  }_{\\substack{=\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\n\\prod\\limits_{\\alpha\\in J}u_{\\alpha}\\ \\mid\\ J\\in\\mathcal{P}_{i}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\right)  \\right]  \\right)  \\widehat{\\cdot}%\r\n\\Pi\\left(  \\widetilde{K}_{v},\\left[  \\prod\\limits_{\\beta\\in M}v_{\\beta}%\r\n\\ \\mid\\ \\text{ }M\\in\\mathcal{P}_{j-i}\\left(  \\left\\{  1,2,...,n\\right\\}\r\n\\right)  \\right]  \\right)  \\\\\\text{(by Theorem 5.3' \\textbf{(c)})}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Corollary 5.4 \\textbf{(a)}}\\right) \\\\\r\n&  =\\widehat{\\sum_{i=0}^{j}}\\underbrace{\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\n\\prod\\limits_{\\alpha\\in J}u_{\\alpha}\\ \\mid\\ J\\in\\mathcal{P}_{i}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\right)  \\right]  \\right)  }%\r\n_{\\substack{=\\widehat{\\lambda}^{i}\\left(  u\\right)  \\\\\\text{(by Theorem 5.3\r\n\\textbf{(d)})}}}\\widehat{\\cdot}\\underbrace{\\Pi\\left(  \\widetilde{K}%\r\n_{v},\\left[  \\prod\\limits_{\\beta\\in M}v_{\\beta}\\ \\mid\\ \\text{ }M\\in\r\n\\mathcal{P}_{j-i}\\left(  \\left\\{  1,2,...,n\\right\\}  \\right)  \\right]\r\n\\right)  }_{\\substack{=\\widehat{\\lambda}^{j-i}\\left(  v\\right)  \\\\\\text{(by\r\nTheorem 5.3 \\textbf{(d)})}}}\\\\\r\n&  =\\widehat{\\sum_{i=0}^{j}}\\widehat{\\lambda}^{i}\\left(  u\\right)\r\n\\widehat{\\cdot}\\widehat{\\lambda}^{j-i}\\left(  v\\right)  ,\r\n\\end{align*}\r\nproving (\\ref{SpezLemma1}). Theorem 5.1 \\textbf{(b)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{$\\lambda_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ is an additive\r\ngroup homomorphism}\r\n\r\nThe following trivial fact is a foreshadowing of the notion of ``special\r\n$\\lambda$-rings'':\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.6.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Consider the map $\\lambda\r\n_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ defined by\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K.\r\n\\]\r\nThen, $\\lambda_{T}$ is an additive group homomorphism (where the additive\r\ngroup structure on $\\Lambda\\left(  K\\right)  $ is given by $\\widehat{+}$).\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.6.]The map $\\lambda_{T}$ is well-defined (i. e. every\r\n$x\\in K$ satisfies $\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)\r\nT^{i}\\in\\Lambda\\left(  K\\right)  $) because $\\lambda^{0}\\left(  x\\right)  =1$\r\nfor every $x\\in K$. The assertion that $\\lambda_{T}$ is an additive group\r\nhomomorphism follows from Theorem 2.1 \\textbf{(b)} (because as an additive\r\ngroup, $\\Lambda\\left(  K\\right)  =\\left(  \\Lambda\\left(  K\\right)\r\n,\\widehat{+}\\right)  =\\left(  \\Lambda\\left(  K\\right)  ,\\cdot\\right)  $).\r\nTheorem 5.6 is thus proven.\r\n\\end{proof}\r\n\r\nWhile Theorem 5.6 says that $\\lambda_{T}$ is an additive group homomorphism,\r\nit is not in general a ring homomorphism. But for many $\\lambda$-rings $K$, it\r\nis one - and even a $\\lambda$-ring homomorphism. These $\\lambda$-rings will be\r\nstudied in the next Section.\r\n\r\n\\subsection{On the evaluation (substitution) map}\r\n\r\nThe following properties of the map $\\operatorname*{ev}$ defined in Section 3\r\nwill turn out useful to us later:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 5.7.} Let $K$ be a ring.\r\n\r\n\\textbf{(a)} For every $\\mu\\in K$, the map $\\operatorname*{ev}_{\\mu\r\nT}:K\\left[  \\left[  T\\right]  \\right]  \\rightarrow K\\left[  \\left[  T\\right]\r\n\\right]  $ is continuous (with respect to the $\\left(  T\\right)  $-topology).\r\n\r\n\\textbf{(b)} Let $u\\in1+K\\left[  T\\right]  ^{+}$. Assume that $u=\\Pi\\left(\r\n\\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $ for some\r\n$\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$. Let $\\mu\\in K$. Then, $\\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\mu u_{1},\\mu\r\nu_{2},...,\\mu u_{m}\\right]  \\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\mu\r\nu_{i}\\mid i\\in\\left\\{  1,2,...,m\\right\\}  \\right]  \\right)  $.\r\n\r\n\\textbf{(c)} Let $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\\Lambda\\left(\r\nK\\right)  $. Let $\\mu\\in K$. Then, $\\operatorname*{ev}_{\\mu T}\\left(\r\nu\\right)  \\widehat{+}\\operatorname*{ev}_{\\mu T}\\left(  v\\right)\r\n=\\operatorname*{ev}_{\\mu T}\\left(  u\\widehat{+}v\\right)  $.\r\n\r\n\\textbf{(d)} Let $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\\Lambda\\left(\r\nK\\right)  $. Let $\\mu\\in K$ and $\\nu\\in K$. Then, $\\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  \\widehat{\\cdot}\\operatorname*{ev}_{\\nu T}\\left(  v\\right)\r\n=\\operatorname*{ev}_{\\mu\\nu T}\\left(  u\\widehat{\\cdot}v\\right)  $.\r\n\r\n\\textbf{(e)} Let $u\\in\\Lambda\\left(  K\\right)  $. Let $\\mu\\in K$. Let\r\n$k\\in\\mathbb{N}$. Then, $\\widehat{\\lambda}^{k}\\left(  \\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  \\right)  =\\operatorname*{ev}_{\\mu^{k}T}\\left(\r\n\\widehat{\\lambda}^{k}\\left(  u\\right)  \\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 5.7.]\\textbf{(a)} Obvious from Theorem 5.5 \\textbf{(b)} (or,\r\nmore precisely, from the assertion you get if you replace $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ by $K\\left[  \\left[  T\\right]  \\right]  $ in Theorem\r\n5.5 \\textbf{(b)}; but this assertion is proven in the same way as Theorem 5.5\r\n\\textbf{(b)}).\r\n\r\n\\textbf{(b)} By assumption, $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\nu_{1},u_{2},...,u_{m}\\right]  \\right)  =\\prod\\limits_{i=1}^{m}\\left(\r\n1+u_{i}T\\right)  $, so that%\r\n\\[\r\n\\operatorname{ev}_{\\mu T}\\left(  u\\right)  =\\prod\\limits_{i=1}^{m}\\left(\r\n1+u_{i}\\mu T\\right)  =\\prod\\limits_{i=1}^{m}\\left(  1+\\mu u_{i}T\\right)\r\n=\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\mu u_{1},\\mu u_{2},...,\\mu\r\nu_{m}\\right]  \\right)  ,\r\n\\]\r\nand Theorem 5.7 \\textbf{(b)} is proven.\r\n\r\n\\textbf{(d)} Since the operation $\\widehat{\\cdot}$ and the maps\r\n$\\operatorname*{ev}_{\\mu T}$, $\\operatorname*{ev}_{\\nu T}$ and\r\n$\\operatorname*{ev}_{\\mu\\nu T}$ are continuous (by Theorem 5.5 \\textbf{(d)\r\n}and Theorem 5.7 \\textbf{(a)}), and $1+K\\left[  T\\right]  ^{+}$ is a dense\r\nsubset of $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ (by Theorem 5.5\r\n\\textbf{(a)}), this needs only to be shown for all $u,v\\in1+K\\left[  T\\right]\r\n^{+}$. So let us assume that $u,v\\in1+K\\left[  T\\right]  ^{+}$. Then, there\r\nexist some $\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $, and some $\\left(\r\n\\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ such that $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[\r\nv_{1},v_{2},...,v_{n}\\right]  \\right)  $. Theorem 5.3 \\textbf{(a)} says that\r\nthere exists an extension ring $\\widetilde{K}_{u,v}$ containing both\r\n$\\widetilde{K}_{u}$ and $\\widetilde{K}_{v}$ as subrings. Now, Theorem 5.3\r\n\\textbf{(c)} yields $u\\widehat{\\cdot}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[\r\nu_{i}v_{j}\\mid\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  \\right]  \\right)  $, so that Theorem 5.7\r\n\\textbf{(b)} gives us%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{\\mu\\nu T}\\left(  u\\widehat{\\cdot}v\\right)   &\r\n=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  \\mu\\nu u_{i}v_{j}\\mid\\left(\r\ni,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n\\right]  \\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  \\mu u_{i}\\cdot\\nu v_{j}\\mid\\left(\r\ni,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n\\right]  \\right)  .\r\n\\end{align*}\r\n\r\n\r\nOn the other hand, Theorem 5.7 \\textbf{(b)} yields $\\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\mu u_{1},\\mu\r\nu_{2},...,\\mu u_{m}\\right]  \\right)  $ and (similarly) $\\operatorname*{ev}%\r\n_{\\nu T}\\left(  v\\right)  =\\Pi\\left(  \\widetilde{K}_{v},\\left[  \\nu v_{1},\\nu\r\nv_{2},...,\\nu v_{n}\\right]  \\right)  $. Thus, Theorem 5.3 \\textbf{(c)} yields%\r\n\\[\r\n\\operatorname*{ev}\\nolimits_{\\mu T}\\left(  u\\right)  \\widehat{\\cdot\r\n}\\operatorname*{ev}\\nolimits_{\\nu T}\\left(  v\\right)  =\\Pi\\left(\r\n\\widetilde{K}_{u,v},\\left[  \\mu u_{i}\\cdot\\nu v_{j}\\mid\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]\r\n\\right)  .\r\n\\]\r\nHence, $\\operatorname*{ev}_{\\mu T}\\left(  u\\right)  \\widehat{\\cdot\r\n}\\operatorname*{ev}_{\\nu T}\\left(  v\\right)  =\\operatorname*{ev}_{\\mu\\nu\r\nT}\\left(  u\\widehat{\\cdot}v\\right)  $. This proves Theorem 5.7 \\textbf{(d)}.\r\n\r\n\\textbf{(c)} We can prove Theorem 5.7 \\textbf{(c)} similarly to our above\r\nproof of Theorem 5.7 \\textbf{(d)}. However, there is also a much simpler proof\r\nof Theorem 5.7 \\textbf{(c)}: Since $\\operatorname*{ev}\\nolimits_{\\mu T}$ is a\r\nring homomorphism, we have $\\operatorname*{ev}\\nolimits_{\\mu T}\\left(\r\nu\\right)  \\cdot\\operatorname*{ev}\\nolimits_{\\nu T}\\left(  v\\right)\r\n=\\operatorname*{ev}\\nolimits_{\\mu T}\\left(  u\\cdot v\\right)  $. Since\r\n$\\widehat{+}$ is the multiplication on $1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}$, this rewrites as $\\operatorname*{ev}_{\\mu T}\\left(  u\\right)\r\n\\widehat{+}\\operatorname*{ev}_{\\mu T}\\left(  v\\right)  =\\operatorname*{ev}%\r\n_{\\mu T}\\left(  u\\widehat{+}v\\right)  $. This proves Theorem 5.7 \\textbf{(c)}.\r\n\r\n\\textbf{(e)} Since the maps $\\widehat{\\lambda}^{k}$ and $\\operatorname*{ev}%\r\n_{\\mu T}$ and $\\operatorname*{ev}\\nolimits_{\\mu^{k}T}$ are continuous (by\r\nTheorem 5.5 \\textbf{(d) }and Theorem 5.7 \\textbf{(a)}), and $1+K\\left[\r\nT\\right]  ^{+}$ is a dense subset of $1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}$ (by Theorem 5.5 \\textbf{(a)}), this needs only to be shown for all\r\n$u\\in1+K\\left[  T\\right]  ^{+}$. So, from now on we assume that $u\\in\r\n1+K\\left[  T\\right]  ^{+}$. Then, there exists some $\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in K^{\\operatorname*{int}%\r\n}$ such that $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2}%\r\n,...,u_{m}\\right]  \\right)  $. Theorem 5.3 \\textbf{(d)} then yields%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\n\\prod\\limits_{i\\in I}u_{i}\\ \\mid\\ I\\in\\mathcal{P}_{k}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right]  \\right)  =\\prod\\limits_{I\\in\r\n\\mathcal{P}_{k}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\left(\r\n1+\\prod\\limits_{i\\in I}u_{i}\\cdot T\\right)  ,\r\n\\]\r\nso that%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{\\mu^{k}T}\\left(  \\widehat{\\lambda}^{k}\\left(\r\nu\\right)  \\right)   &  =\\prod\\limits_{I\\in\\mathcal{P}_{k}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }\\left(  1+\\prod\\limits_{i\\in I}u_{i}\\cdot\\mu\r\n^{k}T\\right)  =\\prod\\limits_{I\\in\\mathcal{P}_{k}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }\\left(  1+\\prod\\limits_{i\\in I}\\left(  \\mu\r\nu_{i}\\right)  \\cdot T\\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in I}\\left(  \\mu\r\nu_{i}\\right)  \\ \\mid\\ I\\in\\mathcal{P}_{k}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  \\right]  \\right)  .\r\n\\end{align*}\r\nOn the other hand, Theorem 5.7 \\textbf{(b)} yields $\\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\mu u_{1},\\mu\r\nu_{2},...,\\mu u_{m}\\right]  \\right)  $ and thus, by Theorem 5.3 \\textbf{(d)}\r\nagain,%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  \\operatorname*{ev}\\nolimits_{\\mu T}\\left(\r\nu\\right)  \\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in\r\nI}\\left(  \\mu u_{i}\\right)  \\ \\mid\\ I\\in\\mathcal{P}_{k}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right]  \\right)  ,\r\n\\]\r\nso that we conclude $\\widehat{\\lambda}^{k}\\left(  \\operatorname*{ev}_{\\mu\r\nT}\\left(  u\\right)  \\right)  =\\operatorname*{ev}_{\\mu^{k}T}\\left(\r\n\\widehat{\\lambda}^{k}\\left(  u\\right)  \\right)  $, and Theorem 5.7\r\n\\textbf{(e)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{The functor $\\Lambda$}\r\n\r\nFinally, a small definition that turns $\\Lambda$ into a functor:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Every homomorphism $\\varphi:K\\rightarrow L$ of rings\r\ncanonically induces a $\\lambda$-ring homomorphism $\\Lambda\\left(  K\\right)\r\n\\rightarrow\\Lambda\\left(  L\\right)  $ (which sends every $\\sum\\limits_{i\\in\r\n\\mathbb{N}}a_{i}T^{i}\\in\\Lambda\\left(  K\\right)  $ to $\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\varphi\\left(  a_{i}\\right)  T^{i}\\in\\Lambda\\left(  L\\right)  $).\r\nThis homomorphism $\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(\r\nL\\right)  $ will be denoted by $\\Lambda\\left(  \\varphi\\right)  $.\r\n\\end{quote}\r\n\r\nIt is easy to see that this $\\Lambda\\left(  \\varphi\\right)  $ indeed is a\r\n$\\lambda$-ring homomorphism.\\footnote{Basically, this is because the $P_{k}$\r\nand $P_{k,j}$ are polynomials, and polynomials commute with ring\r\nhomomorphisms.} Besides, it has some obvious properties: If $\\varphi$ is\r\nsurjective, then so is $\\Lambda\\left(  \\varphi\\right)  $. If $\\varphi$ is\r\ninjective, then $\\Lambda\\left(  \\varphi\\right)  $ is injective as well; thus,\r\nif $L$ is an extension ring of $K$, then $\\Lambda\\left(  L\\right)  $ can be\r\ncanonically considered an extension ring of $\\Lambda\\left(  K\\right)  $.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 5.1.} Let $K$ be a ring. For every monic polynomial $P\\in\r\nK\\left[  T\\right]  $, there exists a finite-free extension ring $K_{P}$ of the\r\nring $K$ and $n$ elements $p_{1}$, $p_{2}$, $...$, $p_{n}$ of this extension\r\nring $K_{P}$ such that $P=\\prod\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)  $ in\r\n$K_{P}\\left[  T\\right]  $, where $n=\\deg P$.\r\n\r\n[This exercise is a particular case of \\cite[Theorem 5.5]{Laksov09}, and (more\r\ngenerally) a simple corollary of Laksov's theory of splitting algebras.]\r\n\r\n\\textit{Exercise 5.2.} Let $L$ be a ring. Let $n\\in\\mathbb{N}$, let $a_{0}$,\r\n$a_{1}$, $...$, $a_{n}$ be some elements of $L$, and let $p_{1}$, $p_{2}$,\r\n$...$, $p_{n}$ be some elements of $L$.\r\n\r\n\\textbf{(a)} If $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}=\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}+T\\right)  $ in the polynomial ring $L\\left[  T\\right]  $,\r\nthen prove that $\\sum\\limits_{i=0}^{n}a_{i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(\r\n1+p_{i}T\\right)  $.\r\n\r\n\\textbf{(b)} If $\\sum\\limits_{i=0}^{n}a_{i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(\r\n1+p_{i}T\\right)  $ in the polynomial ring $L\\left[  T\\right]  $, then prove\r\nthat $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(\r\np_{i}+T\\right)  $.\r\n\r\n\\textit{Exercise 5.3.} Let $K$ be a ring. Let $p$ be an element of $K$. Let\r\n$P\\in K\\left[  T\\right]  $ be a monic polynomial such that $P\\left(  p\\right)\r\n=0$. Let $n=\\deg P$. Then, there exists a finite-free extension ring\r\n$K_{P}^{\\prime}$ of the ring $K$ and $n$ elements $p_{1}$, $p_{2}$, $...$,\r\n$p_{n}$ of this extension ring $K_{P}^{\\prime}$ such that $P=\\prod\r\n\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)  $ in $K_{P}^{\\prime}\\left[  T\\right]\r\n$ and such that $p=p_{n}$.\r\n\r\n\\textit{Exercise 5.4.} Let $K$ be a ring, and $L$ an extension ring of $K$.\r\nFor some $n\\in\\mathbb{N}$, an element $u$ of $L$ is said to be $n$%\r\n\\textit{-integral} over $K$ if there exists a monic polynomial $P\\in K\\left[\r\nT\\right]  $ such that $\\deg P=n$ and $P\\left(  u\\right)  =0$.\r\n\r\nLet $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$. Let $\\alpha$ and $\\beta$ be two\r\nelements of $L$ such that $\\alpha$ is $n$-integral over $K$ and $\\beta$ is\r\n$m$-integral over $K$. Prove that $\\alpha\\beta$ is $nm$-integral over $K$.\r\n\r\n[This is a known fact, but it turns out to also be a corollary of our\r\nconstruction of the polynomials $P_{k}$ further above.]\r\n\r\n\\textit{Exercise 5.5.} Let $K$ be a ring, and $I$ be an ideal of $K$. Let\r\n$I\\left[  \\left[  T\\right]  \\right]  $ denote the $K$-submodule%\r\n\\begin{align*}\r\n&  \\left\\{  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\in K\\left[  \\left[  T\\right]\r\n\\right]  \\ \\mid\\ a_{i}\\in I\\text{ for all }i\\right\\} \\\\\r\n&  =\\left\\{  p\\in K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a\r\npower series with all its coefficients lying in }I\\right\\}\r\n\\end{align*}\r\nof $K\\left[  \\left[  T\\right]  \\right]  $. Let $I\\left[  \\left[  T\\right]\r\n\\right]  ^{+}$ denote the subset%\r\n\\begin{align*}\r\nTI\\left[  \\left[  T\\right]  \\right]   &  =\\left\\{  \\sum_{i\\in\\mathbb{N}}%\r\na_{i}T^{i}\\in I\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ a_{i}\\in I\\text{ for\r\nall }i,\\text{ and }a_{0}=0\\right\\} \\\\\r\n&  =\\left\\{  p\\in I\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a\r\npower series with constant term }0\\right\\}\r\n\\end{align*}\r\nof $I\\left[  \\left[  T\\right]  \\right]  $. Consider the subset $1+I\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$ of $1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}=\\Lambda\\left(  K\\right)  $.\\ \\ \\ \\ \\footnote{Notice that $I\\left[\r\n\\left[  T\\right]  \\right]  ^{+}\\neq I\\cdot\\left(  K\\left[  \\left[  T\\right]\r\n\\right]  ^{+}\\right)  $ in general!} Prove the following:\r\n\r\n\\textbf{(a)} We have $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}%\r\n=\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $, where $\\pi$\r\nis the canonical projection $K\\rightarrow K\\diagup I$.\r\n\r\n\\textbf{(b)} The set $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$ is a\r\n$\\lambda$-ideal of the $\\lambda$-ring $\\Lambda\\left(  K\\right)  $.\r\n\\end{quotation}\r\n\r\n\\section{Special $\\lambda$-rings}\r\n\r\n\\subsection{Definition}\r\n\r\nNow we will define a particular subclass of $\\lambda$-rings that we will be\r\ninterested in from now on:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} \\textbf{1)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. The map $\\lambda_{T}$ defined\r\nin Theorem 5.6 is an additive group homomorphism (by Theorem 5.6). We call\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ a\r\n\\textit{special }$\\lambda$\\textit{-ring} if this map $\\lambda_{T}:\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism.\r\n\r\n\\textbf{2)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Let $L$ be a sub-$\\lambda$-ring of $K$. If\r\n$\\left(  L,\\left(  \\lambda^{i}\\mid_{L}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is\r\na special $\\lambda$-ring, then we call $L$ a \\textit{special sub-}$\\lambda\r\n$\\textit{-ring} of $K$.\r\n\\end{quote}\r\n\r\nA different, more down-to-earth characterization of special $\\lambda$-rings:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 6.1.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring.\r\n\r\nThen, $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\nspecial $\\lambda$-ring if and only if%\r\n\\begin{align}\r\n&  \\lambda^{k}\\left(  xy\\right)  =P_{k}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{k}\\left(  x\\right)  ,\\lambda\r\n^{1}\\left(  y\\right)  ,\\lambda^{2}\\left(  y\\right)  ,...,\\lambda^{k}\\left(\r\ny\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }x\\in K\\text{\r\nand }y\\in K \\label{Lkxy}%\r\n\\end{align}\r\nand%\r\n\\begin{align}\r\n&  \\lambda^{k}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)  =P_{k,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{kj}\\left(  x\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }j\\in\r\n\\mathbb{N}\\text{ and }x\\in K. \\label{LkLjx}%\r\n\\end{align}\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 6.1.]According to the preceding definition, $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special\r\n$\\lambda$-ring if and only if the map $\\lambda_{T}$ is a $\\lambda$-ring\r\nhomomorphism. This map is always an additive group homomorphism (by Theorem\r\n5.6); hence, it is a $\\lambda$-ring homomorphism if and only if it satisfies\r\nthe three conditions%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in\r\nK\\text{ and }y\\in K,\\\\\r\n\\lambda_{T}\\left(  1\\right)   &  =1+T,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}\\\\\r\n\\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)   &  =\\widehat{\\lambda\r\n}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\text{ and }x\\in K\r\n\\end{align*}\r\n(note that $1+T$ is the multiplicative unity of $\\Lambda\\left(  K\\right)  $).\r\nThe second of these three conditions actually follows from the third one\r\n(since $\\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)\r\n=\\widehat{\\lambda}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  $, applied\r\nto $j=0$, yields $\\lambda_{T}\\left(  1\\right)  =1+T$), so we see that the map\r\n$\\lambda_{T}$ is a $\\lambda$-ring homomorphism if and only if it satisfies the\r\ntwo conditions%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in\r\nK\\text{ and }y\\in K,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}\\\\\r\n\\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)   &  =\\widehat{\\lambda\r\n}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\text{ and }x\\in K.\r\n\\end{align*}\r\n\r\n\r\nBut these two conditions are equivalent to (\\ref{Lkxy}) and (\\ref{LkLjx}),\r\nrespectively (because of the definitions of $\\widehat{\\cdot}$ and\r\n$\\widehat{\\lambda}^{j}$ and because two formal power series are equal if and\r\nonly if their respective coefficients are equal). This proves Theorem 6.1.\r\n\\end{proof}\r\n\r\n\\subsection{$\\Lambda\\left(  K\\right)  $ is special}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 6.2 (Grothendieck).} Let $K$ be a ring. Then, $\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a special $\\lambda$-ring.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 6.2.]According to Theorem 6.1, we only have to prove that%\r\n\\begin{align}\r\n&  \\widehat{\\lambda}^{k}\\left(  u\\widehat{\\cdot}v\\right)  =\\widehat{P_{k}%\r\n}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)  ,\\widehat{\\lambda}^{2}\\left(\r\nu\\right)  ,...,\\widehat{\\lambda}^{k}\\left(  u\\right)  ,\\widehat{\\lambda}%\r\n^{1}\\left(  v\\right)  ,\\widehat{\\lambda}^{2}\\left(  v\\right)\r\n,...,\\widehat{\\lambda}^{k}\\left(  v\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }u\\in\r\n\\Lambda\\left(  K\\right)  \\text{ and }v\\in\\Lambda\\left(  K\\right)  ,\r\n\\label{6.2.P.Lkxy}%\r\n\\end{align}\r\nand%\r\n\\begin{align}\r\n&  \\widehat{\\lambda}^{k}\\left(  \\widehat{\\lambda}^{j}\\left(  u\\right)\r\n\\right)  =\\widehat{P_{k,j}}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)\r\n,\\widehat{\\lambda}^{2}\\left(  u\\right)  ,...,\\widehat{\\lambda}^{kj}\\left(\r\nu\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }j\\in\r\n\\mathbb{N}\\text{ and }u\\in\\Lambda\\left(  K\\right)  . \\label{6.2.P.LkLjx}%\r\n\\end{align}\r\nHere, we are using the following \\textit{notation:} If $S\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{kj}\\right]  $ is a polynomial, then\r\n$\\widehat{S}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)  ,\\widehat{\\lambda\r\n}^{2}\\left(  u\\right)  ,...,\\widehat{\\lambda}^{kj}\\left(  u\\right)  \\right)  $\r\ndenotes the polynomial $S$ applied to $\\widehat{\\lambda}^{1}\\left(  u\\right)\r\n$, $\\widehat{\\lambda}^{2}\\left(  u\\right)  $, $...$, $\\widehat{\\lambda}%\r\n^{kj}\\left(  u\\right)  $ \\textit{as elements of the ring }$\\Lambda\\left(\r\nK\\right)  $ (and not as elements of the ring $K\\left[  \\left[  T\\right]\r\n\\right]  $). For instance, if $S=\\alpha_{1}+\\alpha_{2}+...+\\alpha_{kj}$, then\r\n$\\widehat{S}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)  ,\\widehat{\\lambda\r\n}^{2}\\left(  u\\right)  ,...,\\widehat{\\lambda}^{kj}\\left(  u\\right)  \\right)  $\r\nmeans $\\widehat{\\lambda}^{1}\\left(  u\\right)  \\widehat{+}\\widehat{\\lambda}%\r\n^{2}\\left(  u\\right)  \\widehat{+}...\\widehat{+}\\widehat{\\lambda}^{kj}\\left(\r\nu\\right)  $ (and not $\\widehat{\\lambda}^{1}\\left(  u\\right)  +\\widehat{\\lambda\r\n}^{2}\\left(  u\\right)  +...+\\widehat{\\lambda}^{kj}\\left(  u\\right)  $, where\r\n$+$ denotes the addition in the ring $K\\left[  \\left[  T\\right]  \\right]  $).\r\nThis explains how the right hand sides of the equations (\\ref{6.2.P.Lkxy}) and\r\n(\\ref{6.2.P.LkLjx}) should be understood.\r\n\r\nLet us first prove (\\ref{6.2.P.Lkxy}): Since the subset $1+K\\left[  T\\right]\r\n^{+}$ is dense in $1+K\\left[  \\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(\r\nK\\right)  $ (by Theorem 5.5 \\textbf{(a)}), and since $\\widehat{\\cdot}$ and\r\n$\\widehat{\\lambda}^{i}$ are continuous (by Theorem 5.5 \\textbf{(d)}), it will\r\nbe enough to verify (\\ref{6.2.P.Lkxy}) for $u\\in1+K\\left[  T\\right]  ^{+}$ and\r\n$v\\in1+K\\left[  T\\right]  ^{+}$. Then, there exist some $\\left(\r\n\\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K},\\left[\r\nu_{1},u_{2},...,u_{m}\\right]  \\right)  $, and some $\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}%\r\n}$ such that $v=\\Pi\\left(  \\widetilde{K},\\left[  v_{1},v_{2},...,v_{n}\\right]\r\n\\right)  $. By Theorem 5.3 \\textbf{(a)}, there exists a finite-free extension\r\nring $\\widetilde{K}_{u,v}$ of $K$ which contains both $\\widetilde{K}_{u}$ and\r\n$\\widetilde{K}_{v}$ as subrings. We replace $K$ by $\\widetilde{K}_{u,v}$ now\r\n(silently using the obvious fact that the injection $K\\rightarrow\r\n\\widetilde{K}_{u,v}$ canonically yields an injection $\\Lambda\\left(  K\\right)\r\n\\rightarrow\\Lambda\\left(  \\widetilde{K}_{u,v}\\right)  $). Hence, we can now\r\nassume that $u_{1}$, $u_{2}$, $...$, $u_{m}$, $v_{1}$, $v_{2}$, $...$, $v_{n}$\r\nall lie in $K$. Theorem 5.3 \\textbf{(c)} yields $u\\widehat{\\cdot}v=\\Pi\\left(\r\n\\widetilde{K}_{u,v},\\left[  u_{i}v_{j}\\mid\\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]  \\right)  $.\r\nSince we identified $\\widetilde{K}_{u,v}$ with $K$, this becomes%\r\n\\[\r\nu\\widehat{\\cdot}v=\\Pi\\left(  K,\\left[  u_{i}v_{j}\\mid\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]\r\n\\right)  .\r\n\\]\r\nThus, Theorem 5.3' \\textbf{(d)} (applied to $w=u\\widehat{\\cdot}v$,\r\n$\\widetilde{K}=K$, $L=\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  $ and $w_{\\left(  i,j\\right)  }=u_{i}v_{j}$) yields%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  u\\widehat{\\cdot}v\\right)  =\\Pi\\left(  K,\\left[\r\n\\prod_{\\left(  i,j\\right)  \\in S}u_{i}v_{j}\\mid S\\in\\mathcal{P}_{k}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right)\r\n\\right]  \\right)  .\r\n\\]\r\n\r\n\r\nThere exists a ring homomorphism%\r\n\\[\r\n\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]\r\n\\rightarrow\\Lambda\\left(  K\\right)\r\n\\]\r\nwhich maps $U_{i}$ to $1+u_{i}T$ for every $i$ and $V_{j}$ to $1+v_{j}T$ for\r\nevery $j$. This homomorphism maps $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in\r\nS}U_{k}$ to%\r\n\\begin{align*}\r\n\\widehat{\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}}\\widehat{\\prod\\limits_{k\\in S}}%\r\n\\underbrace{\\left(  1+u_{k}T\\right)  }_{=\\Pi\\left(  K,\\left[  u_{k}\\right]\r\n\\right)  }  &  =\\widehat{\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}}\\underbrace{\\widehat{\\prod\r\n\\limits_{k\\in S}}\\Pi\\left(  K,\\left[  u_{k}\\right]  \\right)  }_{\\substack{=\\Pi\r\n\\left(  K,\\left[  \\prod\\limits_{k\\in S}u_{k}\\right]  \\right)\r\n\\\\\\text{according to Corollary 5.4 \\textbf{(b)}}}}=\\widehat{\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}}\\Pi\\left(  K,\\left[  \\prod\\limits_{k\\in S}u_{k}\\right]\r\n\\right) \\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod\\limits_{k\\in S}u_{k}\\mid S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\ \\left\\vert S\\right\\vert =i\\right]  \\right) \\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod\\limits_{k\\in S}u_{k}\\mid S\\in\\mathcal{P}%\r\n_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  \\right]  \\right) \\\\\r\n&  =\\widehat{\\lambda}^{i}\\left(  u\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{after Theorem 5.3 \\textbf{(d)}}\\right)\r\n\\end{align*}\r\nand $Y_{j}$ to $\\widehat{\\lambda}^{j}\\left(  v\\right)  $ for every\r\n$j\\in\\mathbb{N}$ (according to a similar argument). Hence, applying this\r\nhomomorphism to (\\ref{Pk1}), we obtain%\r\n\\begin{align*}\r\n&  \\widehat{\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}%\r\n}}\\widehat{\\prod_{\\left(  i,j\\right)  \\in S}}\\left(  1+u_{i}T\\right)\r\n\\widehat{\\cdot}\\left(  1+v_{j}T\\right) \\\\\r\n&  =\\widehat{P_{k}}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)\r\n,\\widehat{\\lambda}^{2}\\left(  u\\right)  ,...,\\widehat{\\lambda}^{k}\\left(\r\nu\\right)  ,\\widehat{\\lambda}^{1}\\left(  v\\right)  ,\\widehat{\\lambda}%\r\n^{2}\\left(  v\\right)  ,...,\\widehat{\\lambda}^{k}\\left(  v\\right)  \\right)  .\r\n\\end{align*}\r\nBut combined with%\r\n\\begin{align*}\r\n&  \\widehat{\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}%\r\n}}\\widehat{\\prod_{\\left(  i,j\\right)  \\in S}}\\underbrace{\\left(\r\n1+u_{i}T\\right)  \\widehat{\\cdot}\\left(  1+v_{j}T\\right)  }_{\\substack{=\\Pi\r\n\\left(  K,\\left[  u_{i}\\right]  \\right)  \\widehat{\\cdot}\\Pi\\left(  K,\\left[\r\nv_{j}\\right]  \\right)  \\\\=\\Pi\\left(  K,\\left[  u_{i}v_{j}\\right]  \\right)\r\n\\text{ after}\\\\\\text{Theorem 5.3 \\textbf{(c)}}}}=\\widehat{\\sum\r\n_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}}\\underbrace{\\widehat{\\prod\r\n_{\\left(  i,j\\right)  \\in S}}\\Pi\\left(  K,\\left[  u_{i}v_{j}\\right]  \\right)\r\n}_{\\substack{=\\Pi\\left(  K,\\left[  \\prod\\limits_{\\left(  i,j\\right)  \\in\r\nS}u_{i}v_{j}\\right]  \\right)  \\\\\\text{after Corollary 5.4 \\textbf{(b)}}}}\\\\\r\n&  =\\widehat{\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}}\\Pi\\left(\r\nK,\\left[  \\prod\\limits_{\\left(  i,j\\right)  \\in S}u_{i}v_{j}\\right]  \\right)\r\n\\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod_{\\left(  i,j\\right)  \\in S}u_{i}v_{j}\\mid\r\nS\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n;\\ \\left\\vert S\\right\\vert =k\\right]  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{after Corollary 5.4 \\textbf{(a)}}\\right)\r\n\\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod_{\\left(  i,j\\right)  \\in S}u_{i}v_{j}\\mid\r\nS\\in\\mathcal{P}_{k}\\left(  \\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right)  \\right]  \\right) \\\\\r\n&  =\\widehat{\\lambda}^{k}\\left(  u\\widehat{\\cdot}v\\right)  ,\r\n\\end{align*}\r\nthis yields%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  u\\widehat{\\cdot}v\\right)  =\\widehat{P_{k}}\\left(\r\n\\widehat{\\lambda}^{1}\\left(  u\\right)  ,\\widehat{\\lambda}^{2}\\left(  u\\right)\r\n,...,\\widehat{\\lambda}^{k}\\left(  u\\right)  ,\\widehat{\\lambda}^{1}\\left(\r\nv\\right)  ,\\widehat{\\lambda}^{2}\\left(  v\\right)  ,...,\\widehat{\\lambda}%\r\n^{k}\\left(  v\\right)  \\right)  .\r\n\\]\r\nThus, (\\ref{6.2.P.Lkxy}) is proven.\r\n\r\nNext we are going to prove (\\ref{6.2.P.LkLjx}) (the argument will be similar\r\nto the above proof of (\\ref{6.2.P.Lkxy})):\r\n\r\nSince the subset $1+K\\left[  T\\right]  ^{+}$ is dense in $1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $ (by Theorem 5.5\r\n\\textbf{(a)}), and since all the $\\widehat{\\lambda}^{i}$ are continuous (by\r\nTheorem 5.5 \\textbf{(d)}), it will be enough to verify (\\ref{6.2.P.LkLjx}) for\r\nthe case $u\\in1+K\\left[  T\\right]  ^{+}$. But in this case, there exists some\r\n$\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K},\\left[\r\nu_{1},u_{2},...,u_{m}\\right]  \\right)  $. By definition, $\\widetilde{K}_{u}$\r\nis a finite-free extension of $K$.\r\n\r\nWe replace $K$ by $\\widetilde{K}_{u}$ now (silently using the obvious fact\r\nthat the injection $K\\rightarrow\\widetilde{K}_{u}$ canonically yields an\r\ninjection $\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(  \\widetilde{K}%\r\n_{u}\\right)  $). Hence, we can now assume that $u_{1}$, $u_{2}$, $...$,\r\n$u_{m}$ all lie in $K$. Theorem 5.3 \\textbf{(d)} yields $\\widehat{\\lambda}%\r\n^{j}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  \\prod\\limits_{i\\in\r\nI}u_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right]  \\right)  $. Since we identified $\\widetilde{K}_{u,v}$ with $K$, this\r\nbecomes%\r\n\\[\r\n\\widehat{\\lambda}^{j}\\left(  u\\right)  =\\Pi\\left(  K,\\left[  \\prod\r\n\\limits_{i\\in I}u_{i}\\ \\mid\\ I\\in\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right]  \\right)  .\r\n\\]\r\nThus, Theorem 5.3' \\textbf{(d)} (applied to $w=\\widehat{\\lambda}^{j}\\left(\r\nu\\right)  $, $\\widetilde{K}=K$, $L=\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  $ and $w_{I}=\\prod\\limits_{i\\in I}u_{i}$) yields%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  \\widehat{\\lambda}^{j}\\left(  u\\right)  \\right)\r\n=\\Pi\\left(  K,\\left[  \\prod_{I\\in S}\\prod\\limits_{i\\in I}u_{i}\\ \\mid\r\n\\ S\\in\\mathcal{P}_{k}\\left(  \\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right)  \\right]  \\right)  .\r\n\\]\r\n\r\n\r\nThere exists a ring homomorphism%\r\n\\[\r\n\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\rightarrow\\Lambda\\left(\r\nK\\right)\r\n\\]\r\nwhich maps $U_{i}$ to $1+u_{i}T$ for every $i$. This homomorphism maps\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ to\r\n$\\widehat{\\lambda}^{i}\\left(  u\\right)  $\\ \\ \\ \\ \\footnote{This can be proven\r\nexactly in the same way as we have showed, during the proof of\r\n(\\ref{6.2.P.Lkxy}), that the ring homomorphism\r\n\\[\r\n\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2},...,V_{n}\\right]\r\n\\rightarrow\\Lambda\\left(  K\\right)\r\n\\]\r\nwhich maps $U_{i}$ to $1+u_{i}T$ for every $i$ and $V_{j}$ to $1+v_{j}T$ for\r\nevery $j$ must map $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$\r\nto $\\widehat{\\lambda}^{i}\\left(  u\\right)  $ (where the notations are the ones\r\nwe introduced in our above proof of (\\ref{6.2.P.Lkxy})).}. Hence, applying\r\nthis homomorphism to (\\ref{Pkj1}), we obtain%\r\n\\[\r\n\\widehat{\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =k}}}\\widehat{\\prod\r\n_{I\\in S}}\\widehat{\\prod_{i\\in I}}\\left(  1+u_{i}T\\right)  =\\widehat{P_{k,j}%\r\n}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)  ,\\widehat{\\lambda}^{2}\\left(\r\nu\\right)  ,...,\\widehat{\\lambda}^{kj}\\left(  u\\right)  \\right)  .\r\n\\]\r\nBut combined with%\r\n\\begin{align*}\r\n\\widehat{\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =k}}}\\widehat{\\prod\r\n_{I\\in S}}\\underbrace{\\widehat{\\prod_{i\\in I}}\\left(  1+u_{i}T\\right)\r\n}_{\\substack{=\\Pi\\left(  K,\\left[  \\prod\\limits_{i\\in I}u_{i}\\right]  \\right)\r\n\\\\\\text{after Corollary 5.4 \\textbf{(b)}}}}  &  =\\widehat{\\sum\r\n_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  ;\\\\\\left\\vert S\\right\\vert =k}}}\\underbrace{\\widehat{\\prod_{I\\in S}%\r\n}\\Pi\\left(  K,\\left[  \\prod\\limits_{i\\in I}u_{i}\\right]  \\right)\r\n}_{\\substack{=\\Pi\\left(  K,\\left[  \\prod\\limits_{I\\in S}\\prod\\limits_{i\\in\r\nI}u_{i}\\right]  \\right)  \\\\\\text{after Corollary 5.4 \\textbf{(b)}}}}\\\\\r\n&  =\\widehat{\\sum_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =k}}}\\Pi\\left(\r\nK,\\left[  \\prod\\limits_{I\\in S}\\prod\\limits_{i\\in I}u_{i}\\right]  \\right) \\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod\\limits_{I\\in S}\\prod\\limits_{i\\in I}u_{i}%\r\n\\ \\mid\\ S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n;\\ \\left\\vert S\\right\\vert =k\\right]  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{after Corollary 5.4 \\textbf{(a)}}\\right)\r\n\\\\\r\n&  =\\Pi\\left(  K,\\left[  \\prod_{I\\in S}\\prod\\limits_{i\\in I}u_{i}\\ \\mid\r\n\\ S\\in\\mathcal{P}_{k}\\left(  \\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right)  \\right]  \\right) \\\\\r\n&  =\\widehat{\\lambda}^{k}\\left(  \\widehat{\\lambda}^{j}\\left(  u\\right)\r\n\\right)  ,\r\n\\end{align*}\r\nthis becomes%\r\n\\[\r\n\\widehat{\\lambda}^{k}\\left(  \\widehat{\\lambda}^{j}\\left(  u\\right)  \\right)\r\n=\\widehat{P_{k,j}}\\left(  \\widehat{\\lambda}^{1}\\left(  u\\right)\r\n,\\widehat{\\lambda}^{2}\\left(  u\\right)  ,...,\\widehat{\\lambda}^{kj}\\left(\r\nu\\right)  \\right)  .\r\n\\]\r\nThus, we have verified (\\ref{6.2.P.LkLjx}). Theorem 6.2 is thus proven.\r\n\\end{proof}\r\n\r\nTheorem 6.1 gives us an alternative definition of special $\\lambda$-rings via\r\nthe polynomials $P_{k}$ and $P_{k,j}$. Why, then, did we define the notion of\r\nspecial $\\lambda$-rings via the map $\\lambda_{T}:\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  \\Lambda\\left(\r\nK\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nrather than using Theorem 6.1? The reason is that while Theorem 6.1 provides\r\nan easy-to-formulate definition of special $\\lambda$-rings, it is rather hard\r\nto work with. In order to check that some given ring is a special $\\lambda\r\n$-ring using Theorem 6.1, we would have to prove the identities (\\ref{Lkxy})\r\nand (\\ref{LkLjx}), which is a difficult task since the polynomials $P_{k}$ and\r\n$P_{k,j}$ are very hard to compute explicitly. Using the definition that we\r\ngave, we would instead have to check that $\\lambda_{T}:\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism, and this is often\r\neasier since Exercise 2.1 reduces this to checking some identity at\r\n$\\mathbb{Z}$-module generators of $K$.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 6.1.} Let $K$ be a ring. Consider the localization $\\left(\r\n1+K\\left[  T\\right]  ^{+}\\right)  ^{-1}K\\left[  T\\right]  $ of the polynomial\r\nring $K\\left[  T\\right]  $ at the multiplicatively closed subset $1+K\\left[\r\nT\\right]  ^{+}$. \\ \\ \\ \\ \\footnote{When $K$ is a field, this localization is\r\nsimply the (local) ring of the (so-called) rational functions in one variable\r\nover $K$ which have no pole at $0$. (Note that the term ``rational function''\r\nis being used here for an element of the quotient field $\\operatorname*{Quot}%\r\n\\left(  K\\left[  T\\right]  \\right)  $. This is the standard meaning that the\r\nterm ``rational function'' has in modern literature. This meaning is somewhat\r\nconfusing: In fact, rational functions are not functions in the standard\r\nmeaning of this word; they \\textit{induce} functions (although no functions on\r\n$K$, but instead only functions on an open subset of $K$), but even these\r\ninduced functions don't determine them uniquely, so the word ``function'' in\r\n``rational function'' should not be taken literally. However, lacking a better\r\nword, everybody keeps calling the elements of $\\operatorname*{Quot}\\left(\r\nK\\left[  T\\right]  \\right)  $ ``rational functions'', and so do I.)} This\r\nlocalization $\\left(  1+K\\left[  T\\right]  ^{+}\\right)  ^{-1}K\\left[\r\nT\\right]  $ can be considered a subring of $K\\left[  \\left[  T\\right]\r\n\\right]  $ (since $K\\left[  T\\right]  \\subseteq K\\left[  \\left[  T\\right]\r\n\\right]  $, and every element of $1+K\\left[  T\\right]  ^{+}$ is invertible in\r\n$K\\left[  \\left[  T\\right]  \\right]  $). Prove that the set $\\left(\r\n1+K\\left[  T\\right]  ^{+}\\right)  ^{-1}K\\left[  T\\right]  \\cap\\Lambda\\left(\r\nK\\right)  $ is a special sub-$\\lambda$-ring of $\\Lambda\\left(  K\\right)  $.\r\n\r\n\\textit{Exercise 6.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring. Then, prove that:\r\n\r\n\\textbf{(a)} Every $n\\in\\mathbb{Z}$ and $i\\in\\mathbb{N}$ satisfy $\\lambda\r\n^{i}\\left(  n\\cdot1\\right)  =\\dbinom{n}{i}\\cdot1$, where $1$ denotes the unity\r\nof the ring $K$.\r\n\r\n\\textbf{(b)} None of the elements $1$, $2$, $3$, $...$ of the ring $K$ equals\r\nzero in $K$, unless $K$ is the trivial ring.\r\n\r\n\\textit{Exercise 6.3.} Consider the ring $\\mathbb{Z}\\left[  X\\right]\r\n\\diagup\\left(  X^{2},2X\\right)  =\\mathbb{Z}\\left[  x\\right]  $, where $x$\r\ndenotes the residue class of $X$ modulo the ideal $\\left(  X^{2},2X\\right)  $.\r\n\r\nDefine a map $\\lambda_{T}:\\mathbb{Z}\\left[  x\\right]  \\rightarrow\\left(\r\n\\mathbb{Z}\\left[  x\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $ by\r\n$\\lambda_{T}\\left(  a+bx\\right)  =\\left(  1+T\\right)  ^{a}\\left(  1+xT\\right)\r\n^{b}$ for every $a\\in\\mathbb{Z}$ and $b\\in\\mathbb{Z}$.\r\n\r\nDefine a map $\\lambda^{i}:\\mathbb{Z}\\left[  x\\right]  \\rightarrow\r\n\\mathbb{Z}\\left[  x\\right]  $ for every $i\\in\\mathbb{N}$ through the condition\r\n$\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}$ for every $x\\in\\mathbb{Z}\\left[  x\\right]  $.\r\n\r\nProve that $\\left(  \\mathbb{Z}\\left[  x\\right]  ,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a special $\\lambda$-ring. [This way, we see\r\nthat the additive group of a special $\\lambda$-ring needs not be torsion-free.]\r\n\r\n\\textit{Exercise 6.4.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $E$ be a generating set\r\nof the $\\mathbb{Z}$-module $K$.\r\n\r\nProve that the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special if and only if it satisfies%\r\n\\begin{align}\r\n&  \\lambda^{k}\\left(  xy\\right)  =P_{k}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{k}\\left(  x\\right)  ,\\lambda\r\n^{1}\\left(  y\\right)  ,\\lambda^{2}\\left(  y\\right)  ,...,\\lambda^{k}\\left(\r\ny\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }x\\in E\\text{\r\nand }y\\in E \\label{LkxyE}%\r\n\\end{align}\r\nand%\r\n\\begin{align}\r\n&  \\lambda^{k}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)  =P_{k,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{kj}\\left(  x\\right)  \\right) \\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N}\\text{, }j\\in\r\n\\mathbb{N}\\text{ and }x\\in E. \\label{LkLjxE}%\r\n\\end{align}\r\n\r\n\r\n\\textit{Exercise 6.5.} Let $K$ be a ring. Let $i\\in\\mathbb{N}$. Define a\r\nmapping $\\operatorname*{coeff}\\nolimits_{i}:\\Lambda\\left(  K\\right)\r\n\\rightarrow K$ by setting\r\n\\[\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\operatorname*{coeff}\\nolimits_{i}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}%\r\na_{j}T^{j}\\right)  =a_{i}\\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}%\r\n\\in\\Lambda\\left(  K\\right)  \\text{ (with }a_{j}\\in K\\text{ for every }%\r\nj\\in\\mathbb{N}\\text{)}%\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n(In other words, $\\operatorname*{coeff}\\nolimits_{i}$ is the mapping that\r\ntakes a power series and returns its coefficient before $T^{i}$.)\r\n\r\nProve that%\r\n\\[\r\n\\operatorname*{coeff}\\nolimits_{i}\\left(  u\\right)  =\\operatorname*{coeff}%\r\n\\nolimits_{1}\\left(  \\widehat{\\lambda}^{i}\\left(  u\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\Lambda\\left(  K\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Exercise 6.6.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring, and $A$ be a ring.\r\nLet $\\varphi:K\\rightarrow A$ be a ring homomorphism, and let\r\n$\\operatorname*{coeff}\\nolimits_{1}^{A}:\\Lambda\\left(  A\\right)  \\rightarrow\r\nA$ be the mapping defined by $\\operatorname*{coeff}\\nolimits_{1}^{A}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}\\right)  =a_{1}$ for every\r\n$\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}\\in\\Lambda\\left(  A\\right)  $ (with\r\n$a_{j}\\in A$ for every $j\\in\\mathbb{N}$). (In other words,\r\n$\\operatorname*{coeff}\\nolimits_{1}^{A}$ is the mapping that takes a power\r\nseries and returns its coefficient before $T^{1}$.)\r\n\r\nAs Theorem 5.1 \\textbf{(b)} states, $\\left(  \\Lambda\\left(  A\\right)  ,\\left(\r\n\\widehat{\\lambda}_{A}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda\r\n$-ring, where the maps $\\widehat{\\lambda}_{A}^{i}:\\Lambda\\left(  A\\right)\r\n\\rightarrow\\Lambda\\left(  A\\right)  $ are defined in the same way as the maps\r\n$\\widehat{\\lambda}^{i}:\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(\r\nK\\right)  $ (which we have defined in Section 5) but for the ring $A$ instead\r\nof $K$.\r\n\r\nProve that there exists one and only one $\\lambda$-ring homomorphism\r\n$\\widetilde{\\varphi}:K\\rightarrow\\Lambda\\left(  A\\right)  $ such that\r\n$\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\widetilde{\\varphi}=\\varphi$.\r\n\r\n\\textit{Exercise 6.7.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring, and $I$ be an ideal\r\nof $K$. Let $S$ be a subset of $I$ which generates the ideal $I$. Assume that\r\nevery $s\\in S$ and every positive integer $i$ satisfy $\\lambda^{i}\\left(\r\ns\\right)  \\in I$. Then, prove that $I$ is a $\\lambda$-ideal of $K$.\r\n\r\n\\textit{Exercise 6.8.} Let $K$ be a ring. For every $i\\in\\mathbb{N}$, we\r\ndefine a mapping $\\operatorname*{Coeff}\\nolimits_{i}:K\\left[  \\left[\r\nT\\right]  \\right]  \\rightarrow K$ by setting%\r\n\\[\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\operatorname*{Coeff}\\nolimits_{i}\\left(  P\\right)  =\\left(  \\text{the\r\ncoefficient of }P\\text{ before }T^{i}\\right) \\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every power series }P\\in K\\left[  \\left[\r\nT\\right]  \\right]\r\n\\end{array}\r\n\\right)\r\n\\]\r\n\\footnote{Equivalently, $\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}\\right)  =a_{i}$ for every\r\n$\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}\\in K\\left[  \\left[  T\\right]  \\right]\r\n$ (with $a_{j}\\in K$ for every $j\\in\\mathbb{N}$).}. (In other words,\r\n$\\operatorname*{Coeff}\\nolimits_{i}$ is the mapping that takes a power series\r\nand returns its coefficient before $T^{i}$.)\\ \\ \\ \\ \\ \\footnote{Note that we\r\nare denoting this mapping by $\\operatorname*{Coeff}\\nolimits_{i}$ with a\r\ncapital \\textquotedblleft C\\textquotedblright\\ to distinguish it from the\r\nmapping $\\operatorname*{coeff}\\nolimits_{i}$ defined in Exercise 6.5. This\r\ndistinction is necessary because these two mappings have different domains\r\n(namely, the map $\\operatorname*{Coeff}\\nolimits_{i}$ is defined on all of\r\n$K\\left[  \\left[  T\\right]  \\right]  $, whereas the map $\\operatorname*{coeff}%\r\n\\nolimits_{i}$ is defined only on $\\Lambda\\left(  K\\right)  $).}\r\n\r\nLet $m\\in\\mathbb{N}$. For every $i\\in\\left\\{  1,2,...,m\\right\\}  $, let\r\n$\\Phi_{i}\\in K\\left[  \\left[  T\\right]  \\right]  $ be a power series.\r\n\r\n\\textbf{(a)} We have $\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\prod\r\n\\limits_{i=1}^{m}\\Phi_{i}\\right)  =\\prod\\limits_{i=1}^{m}\\operatorname*{Coeff}%\r\n\\nolimits_{0}\\left(  \\Phi_{i}\\right)  $.\r\n\r\n\\textbf{(b)} Assume that $\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\Phi\r\n_{i}\\right)  =1$ for every $i\\in\\left\\{  1,2,...,m\\right\\}  $. Then,\r\n$\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\prod\\limits_{i=1}^{m}\\Phi\r\n_{i}\\right)  =1$ and $\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\prod\r\n\\limits_{i=1}^{m}\\Phi_{i}\\right)  =\\sum\\limits_{i=1}^{m}\\operatorname*{Coeff}%\r\n\\nolimits_{1}\\left(  \\Phi_{i}\\right)  $.\r\n\r\n\\textit{Exercise 6.9.} Let $K$ be a ring. For each $i\\in\\mathbb{N}$, define\r\nthe mapping $\\operatorname*{coeff}\\nolimits_{i}:\\Lambda\\left(  K\\right)\r\n\\rightarrow K$ as in Exercise 6.5. Then, show that $\\operatorname*{coeff}%\r\n\\nolimits_{1}:\\Lambda\\left(  K\\right)  \\rightarrow K$ is a ring\r\nhomomorphism\\footnote{but, generally, not a $\\lambda$-ring homomorphism, even\r\nwhen $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\nspecial $\\lambda$-ring!}.\r\n\r\n\\textit{Exercise 6.10.} In this exercise, the $\\otimes$ sign shall always mean\r\n$\\otimes_{\\mathbb{Z}}$. Let $A$, $B$ and $C$ be three rings. Let $\\iota\r\n_{1}:A\\rightarrow A\\otimes B$ be the ring homomorphism sending each $a\\in A$\r\nto $a\\otimes1\\in A\\otimes B$. Let $\\iota_{2}:B\\rightarrow A\\otimes B$ be the\r\nring homomorphism sending each $b\\in B$ to $1\\otimes b\\in A\\otimes B$. Let\r\n$\\alpha:A\\rightarrow C$ and $\\beta:B\\rightarrow C$ be two $\\mathbb{Z}$-module homomorphisms.\r\n\r\n\\textbf{(a)} There exists a unique $\\mathbb{Z}$-module homomorphism\r\n$\\phi:A\\otimes B\\rightarrow C$ satisfying%\r\n\\[\r\n\\left(  \\phi\\left(  a\\otimes b\\right)  =\\alpha\\left(  a\\right)  \\beta\\left(\r\nb\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times\r\nB\\right)  .\r\n\\]\r\n\r\n\r\n\\textbf{(b)} Assume that $\\alpha$ and $\\beta$ are ring homomorphisms. Consider\r\nthe unique $\\mathbb{Z}$-module homomorphism $\\phi:A\\otimes B\\rightarrow C$\r\nconstructed in Exercise 6.10 \\textbf{(a)}. Then, this $\\phi$ is a ring\r\nhomomorphism and satisfies $\\phi\\circ\\iota_{1}=\\alpha$ and $\\phi\\circ\\iota\r\n_{2}=\\beta$.\r\n\r\n[This exercise is not directly related to $\\lambda$-rings; it is just a mostly\r\ntrivial fact that will be cited in the next exercise.]\r\n\r\n\\textit{Exercise 6.11.} In this exercise, the $\\otimes$ sign shall always mean\r\n$\\otimes_{\\mathbb{Z}}$. Let $\\left(  A,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and $\\left(  B,\\left(  \\mu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be two $\\lambda$-rings. Define a map $\\lambda\r\n_{T}:A\\rightarrow\\Lambda\\left(  A\\right)  $ by\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in A.\r\n\\]\r\nDefine a map $\\mu_{T}:B\\rightarrow\\Lambda\\left(  B\\right)  $ by%\r\n\\[\r\n\\mu_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\mu^{i}\\left(  x\\right)\r\nT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in B.\r\n\\]\r\nNotice that $\\lambda_{T}$ is an additive group homomorphism from $A$ to\r\n$\\Lambda\\left(  A\\right)  $ (by Theorem 5.6, applied to $A$ instead of $K$),\r\nand thus a $\\mathbb{Z}$-module homomorphism. Similarly, $\\mu_{T}$ is a\r\n$\\mathbb{Z}$-module homomorphism.\r\n\r\nLet $\\iota_{1}:A\\rightarrow A\\otimes B$ be the ring homomorphism sending each\r\n$a\\in A$ to $a\\otimes1\\in A\\otimes B$. Let $\\iota_{2}:B\\rightarrow A\\otimes B$\r\nbe the ring homomorphism sending each $b\\in B$ to $1\\otimes b\\in A\\otimes B$.\r\nThe ring homomorphisms $\\iota_{1}:A\\rightarrow A\\otimes B$ and $\\iota\r\n_{2}:B\\rightarrow A\\otimes B$ canonically induce $\\lambda$-ring homomorphisms\r\n$\\Lambda\\left(  \\iota_{1}\\right)  :\\Lambda\\left(  A\\right)  \\rightarrow\r\n\\Lambda\\left(  A\\otimes B\\right)  $ and $\\Lambda\\left(  \\iota_{2}\\right)\r\n:\\Lambda\\left(  B\\right)  \\rightarrow\\Lambda\\left(  A\\otimes B\\right)  $\r\n(since $\\Lambda$ is a functor). Exercise 6.10 \\textbf{(a)} (applied to\r\n$C=\\Lambda\\left(  A\\otimes B\\right)  $, $\\alpha=\\Lambda\\left(  \\iota\r\n_{1}\\right)  \\circ\\lambda_{T}$ and $\\beta=\\Lambda\\left(  \\iota_{2}\\right)\r\n\\circ\\mu_{T}$) thus yields that there exists a unique $\\mathbb{Z}$-module\r\nhomomorphism $\\phi:A\\otimes B\\rightarrow\\Lambda\\left(  A\\otimes B\\right)  $\r\nsatisfying%\r\n\\[\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\phi\\left(  a\\otimes b\\right)  =\\left(  \\Lambda\\left(  \\iota_{1}\\right)\r\n\\circ\\lambda_{T}\\right)  \\left(  a\\right)  \\widehat{\\cdot}\\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right) \\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times B\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\nLet us denote this $\\phi$ by $\\tau_{T}$. For every $i\\in\\mathbb{N}$, we define\r\na map $\\tau^{i}:A\\otimes B\\rightarrow A\\otimes B$ as follows: For every $c\\in\r\nA\\otimes B$, let $\\tau^{i}\\left(  c\\right)  $ be the coefficient of the power\r\nseries $\\tau_{T}\\left(  c\\right)  \\in\\Lambda\\left(  A\\otimes B\\right)\r\n\\subseteq\\left(  A\\otimes B\\right)  \\left[  \\left[  T\\right]  \\right]  $\r\nbefore $T^{i}$. Prove the following facts:\r\n\r\n\\textbf{(a)} The pair $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring.\r\n\r\n\\textbf{(b)} If $\\left(  C,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a \\textbf{special} $\\lambda$-ring, and if $\\alpha:\\left(  A,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  C,\\left(\r\n\\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\beta:\\left(  B,\\left(\r\n\\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  C,\\left(  \\nu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ are two $\\lambda$-ring homomorphisms,\r\nthen the unique $\\mathbb{Z}$-module homomorphism $\\phi:A\\otimes B\\rightarrow\r\nC$ constructed in Exercise 6.10 \\textbf{(a)} is a $\\lambda$-ring homomorphism\r\n$\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  C,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $.\r\n\r\n\\textbf{(c)} Assume that the $\\lambda$-rings $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\left(  B,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ are special. Then, the map $\\iota\r\n_{1}$ is a $\\lambda$-ring homomorphism from $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ to $\\left(  A\\otimes B,\\left(\r\n\\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, and the map $\\iota_{2}$ is a\r\n$\\lambda$-ring homomorphism from $\\left(  B,\\left(  \\mu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ to $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $.\r\n\r\n\\textbf{(d)} Assume that the $\\lambda$-rings $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\left(  B,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ are special. Then, the $\\lambda$-ring\r\n$\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is special.\r\n\\end{quotation}\r\n\r\n\\section{Examples of special $\\lambda$-rings}\r\n\r\n\\subsection{Binomial $\\lambda$-rings}\r\n\r\nWe have learned a lot of examples for $\\lambda$-rings, but which of them are\r\nspecial? Of course, the trivial ring $0$ with the trivial maps $\\lambda\r\n^{i}:0\\rightarrow0$ is a special $\\lambda$-ring. Also, we know a vast class of\r\nspecial $\\lambda$-rings from Theorem 6.2. Obviously, every sub-$\\lambda$-ring\r\nof a special $\\lambda$-ring is special. On the other hand, the $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ defined in\r\nExercise 3.3 \\textbf{(a)} is not special unless $p=1$. What happens to the\r\nother examples from Section 3?\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 7.1.} The $\\lambda$-ring $\\left(  \\mathbb{Z},\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ defined in Theorem 3.1 is special.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 7.1.]According to Theorem 6.1, we just have to verify the\r\nidentities (\\ref{Lkxy}) and (\\ref{LkLjx}) for $K=\\mathbb{Z}$. In other words,\r\nwe have to prove that%\r\n\\begin{equation}\r\n\\dbinom{xy}{k}=P_{k}\\left(  \\dbinom{x}{1},\\dbinom{x}{2},...,\\dbinom{x}%\r\n{k},\\dbinom{y}{1},\\dbinom{y}{2},...,\\dbinom{y}{k}\\right)  \\label{7.1.Lkxy}%\r\n\\end{equation}\r\nfor every $k\\in\\mathbb{N}$, $x\\in\\mathbb{Z}$ and $y\\in\\mathbb{Z}$ and%\r\n\\begin{equation}\r\n\\dbinom{\\dbinom{x}{j}}{k}=P_{k,j}\\left(  \\dbinom{x}{1},\\dbinom{x}%\r\n{2},...,\\dbinom{x}{kj}\\right)  \\label{7.1.LkLjx}%\r\n\\end{equation}\r\nfor every $k\\in\\mathbb{N}$, $j\\in\\mathbb{N}$ and $x\\in\\mathbb{Z}$.\r\n\r\nLet us prove (\\ref{7.1.Lkxy}): Fix $k\\in\\mathbb{N}$. Then, (\\ref{7.1.Lkxy}) is\r\na polynomial identity in $x$ and in $y$. Hence, (for the same reason as in the\r\nproof of Theorem 3.1) it is enough to prove (\\ref{7.1.Lkxy}) for all natural\r\n$x$ and $y$. In this case, let $m=x$ and $n=y$. There exists a ring\r\nhomomorphism $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m},V_{1},V_{2}%\r\n,...,V_{n}\\right]  \\rightarrow\\mathbb{Z}$ mapping every $U_{i}$ to $1$ and\r\nevery $V_{j}$ to $1$. This homomorphism maps $X_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ to%\r\n\\[\r\n\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\underbrace{\\prod\\limits_{k\\in S}1}_{=1}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}1=\\sum\\limits_{S\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }1=\\left\\vert \\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right\\vert =\\dbinom{m}{i}%\r\n\\]\r\nfor every $i\\in\\mathbb{N}$, and (for similar reasons) maps $Y_{j}$ to\r\n$\\dbinom{n}{j}$ for every $j\\in\\mathbb{N}$. Thus, applying this homomorphism\r\nto the polynomial identity (\\ref{Pk1}), we obtain%\r\n\\[\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\prod_{\\left(  i,j\\right)\r\n\\in S}1\\cdot1=P_{k}\\left(  \\dbinom{m}{1},\\dbinom{m}{2},...,\\dbinom{m}%\r\n{k},\\dbinom{n}{1},\\dbinom{n}{2},...,\\dbinom{n}{k}\\right)  .\r\n\\]\r\nSince $m=x$, $n=y$ and\r\n\\begin{align*}\r\n\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  ;\\\\\\left\\vert S\\right\\vert =k}}\\underbrace{\\prod_{\\left(\r\ni,j\\right)  \\in S}1\\cdot1}_{=1}  &  =\\sum_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =k}}1=\\sum_{S\\in\\mathcal{P}_{k}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right)  }1\\\\\r\n&  =\\left\\vert \\mathcal{P}_{k}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  \\right)  \\right\\vert =\\dbinom{mn}{k}%\r\n=\\dbinom{xy}{k},\r\n\\end{align*}\r\nthis equality transforms into (\\ref{7.1.Lkxy}). Hence, (\\ref{7.1.Lkxy}) is\r\nproven (since, as we said, once (\\ref{7.1.Lkxy}) is proven for natural $x$ and\r\n$y$, it follows that (\\ref{7.1.Lkxy}) holds for all integers $x$ and $y$).\r\nJust as we have derived (\\ref{7.1.Lkxy}) from (\\ref{Pk1}), we can derive\r\n(\\ref{7.1.LkLjx}) from (\\ref{Pkj1}), and Theorem 7.1 is proven.\r\n\\end{proof}\r\n\r\nTheorem 7.1 generalizes to the following fact:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 7.2.} Let $K$ be a binomial ring. The $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ defined in Theorem\r\n3.2 is special.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 7.2.]This follows from our proof of Theorem 7.1 in the same\r\nway as Theorem 3.2 followed from our proof of Theorem 3.1. To be more precise:\r\nAccording to Theorem 6.1, the $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is special if it satisfies the\r\nidentities (\\ref{Lkxy}) and (\\ref{LkLjx}). This means (\\ref{7.1.Lkxy}) for\r\nevery $k\\in\\mathbb{N}$, $x\\in K$ and $y\\in K$ and (\\ref{7.1.LkLjx}) for every\r\n$k\\in\\mathbb{N}$, $j\\in\\mathbb{N}$ and $x\\in K$. In the proof of Theorem 7.1,\r\nwe have proven these identities for all $x\\in\\mathbb{Z}$ and $y\\in\\mathbb{Z}$;\r\nbut being polynomial identities (for fixed $k$ and $j$), these identities\r\ntherefore also hold for every $x\\in K$ and $y\\in K$, and Theorem 7.2 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{Adjoining a polynomial variable to a $\\lambda$-ring}\r\n\r\nTheorem 3.3 has a special version as well:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 7.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring. Then, the $\\lambda\r\n$-ring $\\left(  K\\left[  S\\right]  ,\\left(  \\overline{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ defined in Theorem 3.3 is special.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 7.3.]As in the proof of Theorem 3.3, we can define a map\r\n$\\overline{\\lambda}_{T}:K\\left[  S\\right]  \\rightarrow\\left(  K\\left[\r\nS\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $ by\r\n\\[\r\n\\overline{\\lambda}_{T}\\left(  u\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\overline{\\lambda}^{i}\\left(  u\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for\r\nevery }u\\in K\\left[  S\\right]  .\r\n\\]\r\nNoting that $\\overline{\\lambda}_{T}\\left(  u\\right)  \\in\\Lambda\\left(\r\nK\\left[  S\\right]  \\right)  $ for every $u\\in K\\left[  S\\right]  $ (since\r\n$\\left(  K\\left[  S\\right]  ,\\left(  \\overline{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring), we see that we can actually\r\nconsider $\\overline{\\lambda}_{T}$ as a map $K\\left[  S\\right]  \\rightarrow\r\n\\Lambda\\left(  K\\left[  S\\right]  \\right)  $.\r\n\r\nTheorem 5.6 (applied to $\\left(  K\\left[  S\\right]  ,\\left(  \\overline\r\n{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\overline{\\lambda}_{T}$\r\ninstead of $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nand $\\lambda_{T}$) yields that the map $\\overline{\\lambda}_{T}$ is an additive\r\ngroup homomorphism. In order to show that the $\\lambda$-ring $\\left(  K\\left[\r\nS\\right]  ,\\left(  \\overline{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis special, we must prove that this map $\\overline{\\lambda}_{T}$ is a\r\n$\\lambda$-ring homomorphism.\r\n\r\nObserve that $\\lambda_{T}$ is a $\\lambda$-ring homomorphism (as $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special\r\n$\\lambda$-ring). In particular, $\\lambda_{T}$ is a ring homomorphism. Thus,\r\n$\\lambda_{T}$ maps the unity $1$ of the ring $K$ to the unity $1+T$ of the\r\nring $\\Lambda\\left(  K\\right)  $. In other words, $\\lambda_{T}\\left(\r\n1\\right)  =1+T$.\r\n\r\nLet $E=\\left\\{  aS^{\\alpha}\\mid a\\in K,\\ \\alpha\\in\\mathbb{N}\\right\\}  $.\r\nObviously, $E$ is a generating set of the $\\mathbb{Z}$-module $K\\left[\r\nS\\right]  $. Notice that%\r\n\\begin{equation}\r\n\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\right)  =\\lambda_{S^{\\alpha}%\r\nT}\\left(  a\\right)  \\label{pf.7.3.1}%\r\n\\end{equation}\r\nfor every $a\\in K$ and $\\alpha\\in\\mathbb{N}$ (as shown in the proof of Theorem\r\n3.3 \\textbf{(b)}). Applying this to $a=1$ and $\\alpha=0$, we obtain%\r\n\\[\r\n\\overline{\\lambda}_{T}\\left(  1S^{0}\\right)  =\\lambda_{S^{0}T}\\left(\r\n1\\right)  =\\lambda_{T}\\left(  1\\right)  =1+T.\r\n\\]\r\nIn other words, $\\overline{\\lambda}_{T}\\left(  1\\right)  =1+T$ (since\r\n$1S^{0}=1$).\r\n\r\nFor every $a\\in K$, $\\alpha\\in\\mathbb{N}$, $b\\in K$ and $\\beta\\in\\mathbb{N}$,\r\nwe have%\r\n\\begin{align*}\r\n&  \\underbrace{\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\right)\r\n}_{\\substack{=\\lambda_{S^{\\alpha}T}\\left(  a\\right)  \\\\\\text{(by\r\n(\\ref{pf.7.3.1}))}}}\\widehat{\\cdot}\\underbrace{\\overline{\\lambda}_{T}\\left(\r\nbS^{\\beta}\\right)  }_{\\substack{=\\lambda_{S^{\\beta}T}\\left(  b\\right)\r\n\\\\\\text{(by (\\ref{pf.7.3.1}), applied to}\\\\b\\text{ and }\\beta\\text{ instead of\r\n}a\\text{ and }\\alpha\\text{)}}}\\\\\r\n&  =\\underbrace{\\lambda_{S^{\\alpha}T}\\left(  a\\right)  }_{=\\operatorname*{ev}%\r\n\\nolimits_{S^{\\alpha}T}\\left(  \\lambda_{T}\\left(  a\\right)  \\right)\r\n}\\widehat{\\cdot}\\underbrace{\\lambda_{S^{\\beta}T}\\left(  b\\right)\r\n}_{=\\operatorname*{ev}\\nolimits_{S^{\\beta}T}\\left(  \\lambda_{T}\\left(\r\nb\\right)  \\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\overline{\\lambda}_{T}\\left(\r\naS^{\\alpha}\\right)  =\\lambda_{S^{\\alpha}T}\\left(  a\\right)  \\text{ and\r\nsimilarly }\\overline{\\lambda}_{T}\\left(  bS^{\\beta}\\right)  =\\lambda\r\n_{S^{\\beta}T}\\left(  b\\right)  \\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{S^{\\alpha}T}\\left(  \\lambda_{T}\\left(\r\na\\right)  \\right)  \\widehat{\\cdot}\\operatorname*{ev}\\nolimits_{S^{\\beta}%\r\nT}\\left(  \\lambda_{T}\\left(  b\\right)  \\right)  =\\operatorname*{ev}%\r\n\\nolimits_{S^{\\alpha}S^{\\beta}T}\\left(  \\underbrace{\\lambda_{T}\\left(\r\na\\right)  \\widehat{\\cdot}\\lambda_{T}\\left(  b\\right)  }_{\\substack{=\\lambda\r\n_{T}\\left(  ab\\right)  \\\\\\text{(since }\\lambda_{T}\\text{ is a ring}%\r\n\\\\\\text{homomorphism)}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Theorem 5.7 \\textbf{(d)}, applied to }K\\left[  S\\right]  ,\\text{\r\n}\\lambda_{T}\\left(  a\\right)  ,\\text{ }\\lambda_{T}\\left(  b\\right)  ,\\text{\r\n}S^{\\alpha}\\text{ and }S^{\\beta}\\\\\r\n\\text{instead of }K,\\text{ }u,\\text{ }v,\\text{ }\\mu\\text{ and }\\nu\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{S^{\\alpha}S^{\\beta}T}\\left(  \\lambda\r\n_{T}\\left(  ab\\right)  \\right)  =\\lambda_{S^{\\alpha}S^{\\beta}T}\\left(\r\nab\\right)  =\\lambda_{S^{\\alpha+\\beta}T}\\left(  ab\\right)  =\\overline{\\lambda\r\n}_{T}\\left(  \\underbrace{ab\\cdot S^{\\alpha+\\beta}}_{=aS^{\\alpha}\\cdot\r\nbS^{\\beta}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\overline{\\lambda}_{T}\\left(  ab\\cdot S^{\\alpha+\\beta}\\right)\r\n=\\lambda_{S^{\\alpha+\\beta}T}\\left(  ab\\right)  \\text{ (by (\\ref{pf.7.3.1}),\r\napplied to}\\\\\r\nab\\text{ and }\\alpha+\\beta\\text{ instead of }a\\text{ and }b\\text{)}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\cdot bS^{\\beta}\\right)  .\r\n\\end{align*}\r\nIn other words, $\\overline{\\lambda}_{T}\\left(  e\\right)  \\widehat{\\cdot\r\n}\\overline{\\lambda}_{T}\\left(  f\\right)  =\\overline{\\lambda}_{T}\\left(\r\nef\\right)  $ for any two elements $e$ and $f$ of $E$. Since $E$ is a\r\ngenerating set of the $\\mathbb{Z}$-module $K\\left[  S\\right]  $, and since\r\n$\\overline{\\lambda}_{T}$ is already known to be an additive group\r\nhomomorphism, it thus follows that $\\overline{\\lambda}_{T}\\left(  x\\right)\r\n\\widehat{\\cdot}\\overline{\\lambda}_{T}\\left(  y\\right)  =\\overline{\\lambda}%\r\n_{T}\\left(  xy\\right)  $ for any two elements $x$ and $y$ of $K\\left[\r\nS\\right]  $. Since $\\overline{\\lambda}_{T}$ also maps the multiplicative unity\r\n$1$ of $K\\left[  S\\right]  $ to the multiplicative unity $1+T$ of\r\n$\\Lambda\\left(  K\\left[  S\\right]  \\right)  $ (because $\\overline{\\lambda}%\r\n_{T}\\left(  1\\right)  =1+T$), it thus follows that $\\overline{\\lambda}%\r\n_{T}:K\\left[  S\\right]  \\rightarrow\\Lambda\\left(  K\\left[  S\\right]  \\right)\r\n$ is a ring homomorphism.\r\n\r\nNow, for every $i\\in\\mathbb{N}$, let us define a map $\\widehat{\\overline\r\n{\\lambda}}^{i}:\\Lambda\\left(  K\\left[  S\\right]  \\right)  \\rightarrow\r\n\\Lambda\\left(  K\\left[  S\\right]  \\right)  $ in the same way as the map\r\n$\\widehat{\\lambda}^{i}:\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(\r\nK\\right)  $ was defined in Section 5 (but with $K$ replaced by $K\\left[\r\nS\\right]  $). Then, the diagram%\r\n\\begin{equation}\r\n\\xymatrixcolsep{4pc}\\xymatrix{ \\Lambda\\left(K\\right) \\ar@{^{(}->}[d] \\ar[r]^{\\widehat{\\lambda}^i} & \\Lambda\\left(K\\right) \\ar@{^{(}->}[d] \\\\ \\Lambda\\left(K\\left[S\\right]\\right) \\ar[r]_{\\widehat{\\overline{\\lambda}}^i} & \\Lambda\\left(K\\left[S\\right]\\right) }\r\n\\label{7.3.commdiag}%\r\n\\end{equation}\r\n(where the vertical arrows are induced by the canonical inclusion\r\n$K\\rightarrow K\\left[  S\\right]  $) is commutative (since the maps\r\n$\\widehat{\\lambda}^{i}:\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(\r\nK\\right)  $ and $\\widehat{\\overline{\\lambda}}^{i}:\\Lambda\\left(  K\\left[\r\nS\\right]  \\right)  \\rightarrow\\Lambda\\left(  K\\left[  S\\right]  \\right)  $\r\nwere defined in the same natural way).\r\n\r\nFor every $a\\in K$ and $\\alpha\\in\\mathbb{N}$, we have%\r\n\\begin{align*}\r\n&  \\left(  \\widehat{\\overline{\\lambda}}^{i}\\circ\\overline{\\lambda}_{T}\\right)\r\n\\left(  aS^{\\alpha}\\right)  =\\widehat{\\overline{\\lambda}}^{i}\\left(\r\n\\overline{\\lambda}_{T}\\left(  aS^{\\alpha}\\right)  \\right) \\\\\r\n&  =\\widehat{\\overline{\\lambda}}^{i}\\left(  \\operatorname*{ev}%\r\n\\nolimits_{S^{\\alpha}T}\\left(  \\lambda_{T}\\left(  a\\right)  \\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\overline{\\lambda}_{T}\\left(\r\naS^{\\alpha}\\right)  =\\lambda_{S^{\\alpha}T}\\left(  a\\right)\r\n=\\operatorname*{ev}\\nolimits_{S^{\\alpha}T}\\left(  \\lambda_{T}\\left(  a\\right)\r\n\\right)  \\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{\\left(  S^{\\alpha}\\right)  ^{i}T}\\left(\r\n\\widehat{\\overline{\\lambda}}^{i}\\left(  \\lambda_{T}\\left(  a\\right)  \\right)\r\n\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 5.7 \\textbf{(e)}, applied to\r\n}K\\left[  S\\right]  ,\\text{ }\\lambda_{T}\\left(  a\\right)  ,\\text{ }S^{\\alpha\r\n}\\text{ and }i\\text{ instead of }K,\\text{ }u,\\text{ }\\mu\\text{ and }k\\right)\r\n\\\\\r\n&  =\\operatorname*{ev}\\nolimits_{\\left(  S^{\\alpha}\\right)  ^{i}T}\\left(\r\n\\widehat{\\lambda}^{i}\\left(  \\lambda_{T}\\left(  a\\right)  \\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because the commutative diagram (\\ref{7.3.commdiag})}\\\\\r\n\\text{shows that }\\widehat{\\overline{\\lambda}}^{i}\\left(  \\lambda_{T}\\left(\r\na\\right)  \\right)  =\\widehat{\\lambda}^{i}\\left(  \\lambda_{T}\\left(  a\\right)\r\n\\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{\\left(  S^{\\alpha}\\right)  ^{i}T}\\left(\r\n\\lambda_{T}\\left(  \\lambda^{i}\\left(  a\\right)  \\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\widehat{\\lambda}^{i}\\circ\\lambda_{T}=\\lambda_{T}\\circ\\lambda\r\n^{i}\\text{ (because }\\lambda_{T}\\text{ is a }\\lambda\\text{-ring homomorphism)}%\r\n\\\\\r\n\\text{and thus }\\widehat{\\lambda}^{i}\\left(  \\lambda_{T}\\left(  a\\right)\r\n\\right)  =\\lambda_{T}\\left(  \\lambda^{i}\\left(  a\\right)  \\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\lambda_{\\left(  S^{\\alpha}\\right)  ^{i}T}\\left(  \\lambda^{i}\\left(\r\na\\right)  \\right)  =\\lambda_{S^{\\alpha i}T}\\left(  \\lambda^{i}\\left(\r\na\\right)  \\right)  =\\overline{\\lambda}_{T}\\left(  \\underbrace{\\lambda\r\n^{i}\\left(  a\\right)  S^{\\alpha i}}_{\\substack{=\\overline{\\lambda}^{i}\\left(\r\naS^{\\alpha}\\right)  \\\\\\text{(by Theorem 3.3 \\textbf{(b)})}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\overline{\\lambda}_{T}\\left(  \\lambda^{i}\\left(  a\\right)\r\nS^{\\alpha i}\\right)  =\\lambda_{S^{\\alpha i}T}\\left(  \\lambda^{i}\\left(\r\na\\right)  \\right)  \\text{ (by (\\ref{pf.7.3.1}), applied to}\\\\\r\n\\lambda^{i}\\left(  a\\right)  \\text{ and }\\alpha i\\text{ instead of }a\\text{\r\nand }b\\text{)}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\overline{\\lambda}_{T}\\left(  \\overline{\\lambda}^{i}\\left(  aS^{\\alpha\r\n}\\right)  \\right)  =\\left(  \\overline{\\lambda}_{T}\\circ\\overline{\\lambda}%\r\n^{i}\\right)  \\left(  aS^{\\alpha}\\right)\r\n\\end{align*}\r\nfor every $i\\in\\mathbb{N}$. In other words, every $e\\in E$ satisfies $\\left(\r\n\\widehat{\\overline{\\lambda}}^{i}\\circ\\overline{\\lambda}_{T}\\right)  \\left(\r\ne\\right)  =\\left(  \\overline{\\lambda}_{T}\\circ\\overline{\\lambda}^{i}\\right)\r\n\\left(  e\\right)  $ for every $i\\in\\mathbb{N}$.\r\n\r\nAltogether, we now know that $\\overline{\\lambda}_{T}:K\\left[  S\\right]\r\n\\rightarrow\\Lambda\\left(  K\\left[  S\\right]  \\right)  $ is a ring\r\nhomomorphism, that $E$ is a generating set of the $\\mathbb{Z}$-module\r\n$K\\left[  S\\right]  $, and that every $e\\in E$ satisfies $\\left(\r\n\\widehat{\\overline{\\lambda}}^{i}\\circ\\overline{\\lambda}_{T}\\right)  \\left(\r\ne\\right)  =\\left(  \\overline{\\lambda}_{T}\\circ\\overline{\\lambda}^{i}\\right)\r\n\\left(  e\\right)  $ for every $i\\in\\mathbb{N}$. Thus, by Exercise 2.1\r\n\\textbf{(b)}, it follows that $\\overline{\\lambda}_{T}$ is a $\\lambda$-ring\r\nhomomorphism. This proves Theorem 7.3.\r\n\\end{proof}\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 7.1.} Let $M$ be a commutative monoid. Prove that the\r\n$\\lambda$-ring $\\left(  \\mathbb{Z}\\left[  M\\right]  ,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ defined in Exercise 3.4 is special.\r\n\r\n\\textit{Exercise 7.2.} Let $M$ be a commutative monoid. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring.\r\nProve that the $\\lambda$-ring $\\left(  K\\left[  M\\right]  ,\\left(\r\n\\overline{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ defined in Exercise\r\n3.5 \\textbf{(a)} is special.\r\n\\end{quotation}\r\n\r\n\\section{The $\\lambda$-verification principle}\r\n\r\n\\subsection{$n$-operations of special $\\lambda$-rings}\r\n\r\nIn Section 5, we have constructed a family of $\\lambda$-rings $\\Lambda\\left(\r\nK\\right)  $ which are (comparatively) easy to work with due to the following\r\nproperty: If you want to prove an identity involving the ring structure of\r\n$\\Lambda\\left(  K\\right)  $ (the addition $\\widehat{+}$, the corresponding\r\nsubtraction $\\widehat{-}$, the zero $1$, the multiplication $\\widehat{\\cdot}$,\r\nand the multiplicative unity $1+T$) and the mappings $\\widehat{\\lambda}^{i}$,\r\nthen it is enough to verify it for elements of $1+K\\left[  T\\right]  ^{+}$\r\nonly (by continuity, according to Theorem 5.5); and this is usually much\r\neasier since we know what $\\widehat{+}$, $\\widehat{\\cdot}$ and\r\n$\\widehat{\\lambda}^{i}$ mean for elements of $1+K\\left[  T\\right]  ^{+}$ (this\r\nis what Theorem 5.3 is for).\r\n\r\nAs a consequence of this, it is no wonder that often an identity is more\r\neasily proven in $\\Lambda\\left(  K\\right)  $ than in arbitrary $\\lambda\r\n$-rings. However, it turns out that if an identity can be proven in\r\n$\\Lambda\\left(  K\\right)  $, then it automatically holds for arbitrary special\r\n$\\lambda$-rings! This is one of the so-called $\\lambda$\\textit{-verification\r\nprinciples}\\footnote{We are following \\cite[pp. 25--27]{Knut73} here, though\r\nour Theorem 8.1 is not exactly what \\cite{Knut73} calls ``verification\r\nprinciple''.}. Before we formulate this principle, let us first formally\r\ndefine what kind of identities it will hold for:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\operatorname*{Rng}^{\\operatorname*{S}\\Lambda}$\r\ndenote the so-called \\textit{category of special }$\\lambda$\\textit{-rings},\r\nwhich is defined as the category whose objects are the special $\\lambda$-rings\r\nand whose morphisms are $\\lambda$-ring homomorphisms between its objects.\r\n\r\nLet $\\operatorname*{USet}:\\operatorname*{Rng}^{\\operatorname*{S}\\Lambda\r\n}\\rightarrow\\operatorname*{Set}$ be the functor which maps every special\r\n$\\lambda$-ring to its underlying set. Let $n\\in\\mathbb{N}$. Let\r\n$\\operatorname*{USet}\\nolimits^{\\left(  n\\right)  }:\\operatorname*{Rng}%\r\n^{\\operatorname*{S}\\Lambda}\\rightarrow\\operatorname*{Set}$ be the functor\r\nwhich maps every special $\\lambda$-ring $K$ to the set $K^{n}$ (the $n$-th\r\npower of $K$ with respect to the Cartesian product), and maps every\r\nhomomorphism $f:K\\rightarrow L$ of special $\\lambda$-rings to the map\r\n$f^{\\times n}:K^{n}\\rightarrow L^{n}$. (Thus, $\\operatorname*{USet}%\r\n\\nolimits^{\\left(  1\\right)  }\\cong\\operatorname*{USet}$.) An $n$%\r\n-\\textit{operation of special }$\\lambda$\\textit{-rings} will mean a natural\r\ntransformation from the functor $\\operatorname*{USet}^{n}$ to\r\n$\\operatorname*{USet}$.\r\n\r\nIn other words, an $n$-operation $m$ of special $\\lambda$-rings is a family of\r\nmappings\\footnote{Here, ``mapping'' actually means ``mapping'' and not ``group\r\nhomomorphism'' or ``ring homomorphism''.} $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }:K^{n}\\rightarrow K$ for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ such that the diagram%\r\n\\begin{equation}\r\n\\xymatrixcolsep{5pc}\\xymatrix{ K^n \\ar[r]^{f^{\\times n}} \\ar[d]_{m_{\\left(K,\\left(\\lambda^i\\right)_{i\\in\\mathbb{N}}\\right)}} & L^n \\ar[d]^{m_{\\left(L,\\left(\\mu^i\\right)_{i\\in\\mathbb{N}}\\right)}} \\\\ K \\ar[r]_f & L }\r\n\\label{I-oper}%\r\n\\end{equation}\r\ncommutes for any two special $\\lambda$-rings $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\left(  L,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any $\\lambda$-ring homomorphism\r\n$f:\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $.\r\nHere, $f^{\\times n}$ means the map from $K^{n}$ to $L^{n}$ which equals $f$ on\r\neach coordinate.\r\n\\end{quote}\r\n\r\nIn practice, what are $n$-operations of special $\\lambda$-rings? The answer\r\nis: Pretty much every map $K^{n}\\rightarrow K$ which is defined for every\r\nspecial $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ just using addition, subtraction, multiplication, $0$\r\nand $1$ and the maps $\\lambda^{i}$ is an $n$-operation. In particular, every\r\npolynomial map (where the polynomial has integer coefficients) is an\r\n$n$-operation, and so are the maps $\\lambda^{i}:K\\rightarrow K$. To give a\r\ndifferent example, the family of maps $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }:K^{3}\\rightarrow K$ for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ defined by%\r\n\\[\r\nm_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(\r\na_{1},a_{2},a_{3}\\right)  =\\lambda^{5}\\left(  \\lambda^{2}\\left(  a_{1}\\right)\r\n-\\lambda^{4}\\left(  a_{2}\\right)  \\cdot a_{3}\\right)\r\n\\]\r\nis a $3$-operation of special $\\lambda$-rings.\r\n\r\n\\subsection{A useful triviality}\r\n\r\nNow, here is the theorem we came for:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 8.1 (}$\\lambda$\\textbf{-verification principle).} Let $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a special\r\n$\\lambda$-ring. Let $n\\in\\mathbb{N}$. Let $m$ and $m^{\\prime}$ be two\r\n$n$-operations of special $\\lambda$-rings.\r\n\r\nAssume that $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }=m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}$.\r\nThen, $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}=m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }%\r\n^{\\prime}$.\r\n\\end{quote}\r\n\r\nThe proof of this result turns out to be surprisingly simple. First a trivial lemma:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 8.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Define a mapping\r\n$\\operatorname*{coeff}\\nolimits_{1}:\\Lambda\\left(  K\\right)  \\rightarrow K$ by\r\n$\\operatorname*{coeff}\\nolimits_{1}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}%\r\na_{j}T^{j}\\right)  =a_{1}$ for every $\\sum\\limits_{j\\in\\mathbb{N}}a_{j}%\r\nT^{j}\\in\\Lambda\\left(  K\\right)  $ (with $a_{j}\\in K$ for every $j\\in\r\n\\mathbb{N}$). (In other words, $\\operatorname*{coeff}\\nolimits_{1}$ is the\r\nmapping that takes a power series and returns its coefficient before $T^{1}$.)\r\n\r\nThen, $\\operatorname*{coeff}\\nolimits_{1}\\circ\\lambda_{T}=\\operatorname*{id}%\r\n_{K}$.\r\n\\end{quote}\r\n\r\nNote that the definition of $\\operatorname*{coeff}\\nolimits_{1}$ in Theorem\r\n8.2 is a particular case of the definition of $\\operatorname*{coeff}%\r\n\\nolimits_{i}$ in Exercise 6.5.\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 8.2.]This is clear, since\r\n\\[\r\n\\left(  \\operatorname*{coeff}\\nolimits_{1}\\circ\\lambda_{T}\\right)  \\left(\r\nx\\right)  =\\operatorname*{coeff}\\nolimits_{1}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  =\\operatorname*{coeff}\\nolimits_{1}\\left(  \\sum\r\n\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}\\right)\r\n=\\lambda^{1}\\left(  x\\right)  =x\r\n\\]\r\nfor every $x\\in K$. Theorem 8.2 is now proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 8.1.]Since $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a special $\\lambda$-ring, the map $\\lambda\r\n_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ is a $\\lambda$-ring homomorphism.\r\nAccording to (\\ref{I-oper}), we thus have the two commutative diagrams%\r\n\\[\r\n\\xymatrixrowsep{5pc}\\xymatrixcolsep{4pc}\\xymatrix{\r\nK^n \\ar[r]^{\\left(\\lambda_T\\right)^{\\times n}} \\ar[d]_{m_{\\left(K,\\left(\\lambda^i\\right)_{i\\in\\mathbb{N}}\\right)}} & \\left(\\Lambda\\left(K\\right)\\right)^n \\ar[d]^{m_{\\left(\\Lambda\\left(K\\right),\\left(\\widehat{\\lambda}^i\\right)_{i\\in\\mathbb{N}}\\right)}} \\\\\r\nK \\ar[r]_{\\lambda_T} & \\Lambda\\left(K\\right)\r\n}\r\n\\]\r\nand%\r\n\\[\r\n\\xymatrixrowsep{5pc}\\xymatrixcolsep{4pc}\\xymatrix{\r\nK^n \\ar[r]^{\\left(\\lambda_T\\right)^{\\times n}} \\ar[d]_{m^{\\prime}_{\\left(K,\\left(\\lambda^i\\right)_{i\\in\\mathbb{N}}\\right)}} & \\left(\\Lambda\\left(K\\right)\\right)^n \\ar[d]^{m^{\\prime}_{\\left(\\Lambda\\left(K\\right),\\left(\\widehat{\\lambda}^i\\right)_{i\\in\\mathbb{N}}\\right)}} \\\\\r\nK \\ar[r]_{\\lambda_T} & \\Lambda\\left(K\\right)\r\n}.\r\n\\]\r\nHence, $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }=m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}$\r\nyields%\r\n\\[\r\n\\lambda_{T}\\circ m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  }=m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\circ\\left(  \\lambda_{T}\\right)\r\n^{\\times n}=m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\circ\\left(  \\lambda\r\n_{T}\\right)  ^{\\times n}=\\lambda_{T}\\circ m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}.\r\n\\]\r\nHence, $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}=m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }%\r\n^{\\prime}$ because $\\lambda_{T}$ is injective (due to Theorem 8.2). Theorem\r\n8.1 is thus proven!\r\n\\end{proof}\r\n\r\n\\subsection{$1$-dimensional elements}\r\n\r\nBefore we move on to concrete properties of special $\\lambda$-rings, let us\r\nmerge Theorems 8.1 and 5.5 into one simple principle for proving facts about\r\n$\\lambda$-rings -- our Theorem 8.4 below. Before we formulate it, let us\r\ndefine the notion of $1$\\textit{-dimensional} elements of a $\\lambda$-ring.\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ be a $\\lambda$-ring, and let $x\\in K$ be an element of\r\n$K$. Then, $x$ is said to be $1$\\textit{-dimensional} if and only if\r\n$\\lambda^{i}\\left(  x\\right)  =0$ for every integer $i>1$.\r\n\r\n\\textbf{Theorem 8.3.}\r\n\r\n\\textbf{(a)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Let $x\\in K$ be an element of $K$. The\r\nelement $x$ is $1$-dimensional if and only if $\\lambda_{T}\\left(  x\\right)\r\n=1+xT$ (where $\\lambda_{T}:K\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $\r\nis the map defined in Theorem 2.1).\r\n\r\n\\textbf{(b)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a special $\\lambda$-ring. Let $x$ and $y$ be two $1$%\r\n-dimensional elements of $K$. Then, $xy$ is $1$-dimensional as well.\r\n\r\n\\textbf{(c)} Let $K$ be a ring. Let $e\\in K$. Then, the element $1+eT$ of the\r\n$\\lambda$-ring $\\Lambda\\left(  K\\right)  $ is $1$-dimensional.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 8.3.]\\textbf{(a)} In fact,%\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}=\\underbrace{\\lambda^{0}\\left(  x\\right)  }_{=1}%\r\n+\\underbrace{\\lambda^{1}\\left(  x\\right)  }_{=x}T+\\sum\r\n\\limits_{\\substack{i>1\\\\\\text{integer}}}\\lambda^{i}\\left(  x\\right)\r\nT^{i}=1+xT+\\sum\\limits_{\\substack{i>1\\\\\\text{integer}}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}.\r\n\\]\r\nHence, $\\lambda_{T}\\left(  x\\right)  =1+xT$ if and only if $\\lambda^{i}\\left(\r\nx\\right)  =0$ for every integer $i>1$ (which means that $x$ is $1$%\r\n-dimensional). Theorem 8.3 \\textbf{(a)} is thus proven.\r\n\r\n\\textbf{(b)} Since the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special, the map $\\lambda_{T}$, seen as a map\r\nfrom $K$ to $\\Lambda\\left(  K\\right)  $, is a ring homomorphism, so that\r\n$\\lambda_{T}\\left(  xy\\right)  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  $. But Theorem 8.3 \\textbf{(a)} yields\r\n$\\lambda_{T}\\left(  x\\right)  =1+xT=\\Pi\\left(  K,\\left[  x\\right]  \\right)  $.\r\nSimilarly, $\\lambda_{T}\\left(  y\\right)  =\\Pi\\left(  K,\\left[  y\\right]\r\n\\right)  $. Thus,%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  =\\Pi\\left(  K,\\left[  x\\right]  \\right)\r\n\\widehat{\\cdot}\\Pi\\left(  K,\\left[  y\\right]  \\right)  =\\Pi\\left(  K,\\left[\r\nxy\\right]  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{after Theorem 5.3\r\n\\textbf{(c)}}\\right) \\\\\r\n&  =1+xyT.\r\n\\end{align*}\r\nBy Theorem 8.3 \\textbf{(a)} (applied to $xy$ instead of $x$), this yields that\r\n$xy$ is $1$-dimensional. Thus, Theorem 8.3 \\textbf{(b)} is proven.\r\n\r\n\\textbf{(c)} For every integer $i>1$, the element%\r\n\\begin{align*}\r\n\\widehat{\\lambda}^{i}\\left(  1+eT\\right)   &  =\\Pi\\left(\r\nK,\\underbrace{\\left[  \\prod_{i\\in I}e\\mid I\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1\\right\\}  \\right)  \\right]  }_{\\substack{\\text{empty multiset,}\\\\\\text{since\r\n}i>1\\text{ yields }\\mathcal{P}_{i}\\left(  \\left\\{  1\\right\\}  \\right)\r\n=\\varnothing}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 5.3 \\textbf{(d)}, since\r\n}1+eT=\\Pi\\left(  K,\\left[  e\\right]  \\right)  \\right) \\\\\r\n&  =\\Pi\\left(  K,\\text{ empty multiset}\\right)  =1\r\n\\end{align*}\r\nis the zero of $\\Lambda\\left(  K\\right)  $. Thus, $1+eT$ is $1$-dimensional.\r\nTheorem 8.3 \\textbf{(c)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{The continuous splitting $\\lambda$-verification principle}\r\n\r\nNow, we can formulate the desired result:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 8.4 (continuous splitting }$\\lambda$\\textbf{-verification\r\nprinciple).} Let $n\\in\\mathbb{N}$. Let $m$ and $m^{\\prime}$ be two\r\n$n$-operations of special $\\lambda$-rings.\r\n\r\nAssume that the following two assumptions hold:\r\n\r\n\\textit{Continuity assumption:} The maps $m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }:\\left(\r\n\\Lambda\\left(  K\\right)  \\right)  ^{n}\\rightarrow\\Lambda\\left(  K\\right)  $\r\nand $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}:\\left(  \\Lambda\\left(\r\nK\\right)  \\right)  ^{n}\\rightarrow\\Lambda\\left(  K\\right)  $ are continuous\r\nwith respect to the $\\left(  T\\right)  $-topology for every special $\\lambda\r\n$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $.\r\n\r\n\\textit{Split equality assumption:} For every special $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every $\\left(\r\nu_{1},u_{2},...,u_{n}\\right)  \\in K^{n}$ such that $u_{i}$ is the sum of\r\nfinitely many $1$-dimensional elements of $K$ for every $i\\in\\left\\{\r\n1,2,...,n\\right\\}  $, we have $m_{\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)  =m_{\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(\r\nu_{1},u_{2},...,u_{n}\\right)  $.\r\n\r\nThen, $m=m^{\\prime}$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 8.4.]We have to prove that $m=m^{\\prime}$. In other words,\r\nwe must show that $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  }=m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}^{\\prime}$ for every special $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. According to Theorem 8.1, this will\r\nimmediately follow once we have shown that $m_{\\left(  \\Lambda\\left(\r\nK\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}=m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }^{\\prime}$ for every special $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. So it\r\nremains to prove this.\r\n\r\nConsider a special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $. We must prove that $m_{\\left(  \\Lambda\\left(\r\nK\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}=m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }^{\\prime}$.\r\n\r\nConsider the $\\left(  T\\right)  $-topology on $\\Lambda\\left(  K\\right)  $. The\r\nmaps $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }$ and $m_{\\left(  \\Lambda\\left(\r\nK\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}^{\\prime}$ are continuous, while the subset $1+K\\left[  T\\right]  ^{+}$ of\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $ is\r\ndense (by Theorem 5.5 \\textbf{(a)}). Hence, in order to prove that $m_{\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  }=m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}$, it will\r\nbe enough to show that\r\n\\begin{equation}\r\nm_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)  =m_{\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  }^{\\prime}\\left(  u_{1},u_{2},...,u_{n}\\right)\r\n\\label{8.4.goal}%\r\n\\end{equation}\r\nfor every $\\left(  u_{1},u_{2},...,u_{n}\\right)  \\in\\left(  1+K\\left[\r\nT\\right]  ^{+}\\right)  ^{n}$.\r\n\r\nFix some $\\left(  u_{1},u_{2},...,u_{n}\\right)  \\in\\left(  1+K\\left[\r\nT\\right]  ^{+}\\right)  ^{n}$. For every $i\\in\\left\\{  1,2,...,n\\right\\}  $,\r\nthere exists some $\\left(  \\widetilde{K}_{u_{i}},\\left[  \\left(  u_{i}\\right)\r\n_{1},\\left(  u_{i}\\right)  _{2},...,\\left(  u_{i}\\right)  _{n_{i}}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $u_{i}=\\Pi\\left(\r\n\\widetilde{K}_{u_{i}},\\left[  \\left(  u_{i}\\right)  _{1},\\left(  u_{i}\\right)\r\n_{2},...,\\left(  u_{i}\\right)  _{n_{i}}\\right]  \\right)  $. According to\r\nTheorem 5.3 \\textbf{(a)} (applied several times)\\footnote{More precisely, what\r\nwe are using here is the following lemma:\r\n\\par\r\n\\textbf{Lemma.} Let $L_{1},L_{2},\\ldots,L_{n}$ be finitely many finite-free\r\nextension rings of a ring $K$. Then, there exists a finite-free extension ring\r\n$K^{\\prime}$ of $K$ which contains all of the $L_{1},L_{2},\\ldots,L_{n}$ as\r\nsubrings.\r\n\\par\r\n\\textit{Proof of the lemma.} By induction over $n$, it suffices to show that\r\nfor any two finite-free extension rings $L$ and $L^{\\prime}$ of $K$, there\r\nexists a finite-free extension ring $K^{\\prime}$ of $K$ which contains both\r\n$L$ and $L^{\\prime}$ as subrings. But this was essentially shown in our proof\r\nof Theorem 5.3 \\textbf{(a)}.}, there exists a finite-free extension ring\r\n$K^{\\prime}$ of $K$ which contains the $\\widetilde{K}_{u_{i}}$ for all\r\n$i\\in\\left\\{  1,2,...,n\\right\\}  $ as subrings. Consider such a $K^{\\prime}$.\r\nHence, $u_{i}=\\Pi\\left(  K^{\\prime},\\left[  \\left(  u_{i}\\right)  _{1},\\left(\r\nu_{i}\\right)  _{2},...,\\left(  u_{i}\\right)  _{n_{i}}\\right]  \\right)  $ for\r\nevery $i\\in\\left\\{  1,2,...,n\\right\\}  $.\r\n\r\nWe have $K\\subseteq K^{\\prime}$. Thus, $\\Lambda\\left(  K^{\\prime}\\right)  $ is\r\nan extension ring of $\\Lambda\\left(  K\\right)  $ (since $\\Lambda$ is a\r\nfunctor). In this extension ring $\\Lambda\\left(  K^{\\prime}\\right)  $, we have%\r\n\\begin{align}\r\nu_{i}  &  =\\Pi\\left(  K^{\\prime},\\left[  \\left(  u_{i}\\right)  _{1},\\left(\r\nu_{i}\\right)  _{2},...,\\left(  u_{i}\\right)  _{n_{i}}\\right]  \\right)\r\n=\\prod_{j=1}^{n_{i}}\\left(  1+\\left(  u_{i}\\right)  _{j}T\\right)\r\n=\\widehat{\\sum_{j=1}^{n_{i}}}\\left(  1+\\left(  u_{i}\\right)  _{j}T\\right)\r\n\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since addition in }\\Lambda\\left(\r\nK^{\\prime}\\right)  \\text{ is multiplication in }K^{\\prime}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\label{8.4.hilf}%\r\n\\end{align}\r\nfor each $i\\in\\left\\{  1,2,\\ldots,n\\right\\}  $. On the other hand, for every\r\n$j\\in\\left\\{  1,2,...,n_{i}\\right\\}  $, the element $1+\\left(  u_{i}\\right)\r\n_{j}T$ of $\\Lambda\\left(  K^{\\prime}\\right)  $ is $1$-dimensional (by Theorem\r\n8.3 \\textbf{(c)}, applied to $e=\\left(  u_{i}\\right)  _{j}$). Thus,\r\n(\\ref{8.4.hilf}) shows that $u_{i}$ is a sum of $1$-dimensional elements of\r\n$\\Lambda\\left(  K^{\\prime}\\right)  $ for every $i\\in\\left\\{\r\n1,2,...,n\\right\\}  $. Hence, applying the split equality assumption to the\r\nspecial $\\lambda$-ring $\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ instead of $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, we see that%\r\n\\begin{equation}\r\nm_{\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)\r\n=m_{\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  u_{1},u_{2}%\r\n,...,u_{n}\\right)  . \\label{8.4.fast}%\r\n\\end{equation}\r\nThis is an equality in the ring $\\Lambda\\left(  K^{\\prime}\\right)  $, but\r\nsince $\\Lambda\\left(  K\\right)  $ can be canonically seen as a sub-$\\lambda\r\n$-ring of $\\Lambda\\left(  K^{\\prime}\\right)  $ (because $K$ is a subring of\r\n$K^{\\prime}$), it easily yields the equality%\r\n\\[\r\nm_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)  =m_{\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  }^{\\prime}\\left(  u_{1},u_{2},...,u_{n}\\right)\r\n\\]\r\nin the ring $\\Lambda\\left(  K\\right)  $.\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let\r\n$\\iota$ denote the canonical inclusion $\\Lambda\\left(  K\\right)\r\n\\rightarrow\\Lambda\\left(  K^{\\prime}\\right)  $. Since $m$ was defined as a\r\nnatural transformation, and since the inclusion $\\iota:\\Lambda\\left(\r\nK\\right)  \\rightarrow\\Lambda\\left(  K^{\\prime}\\right)  $ is a $\\lambda$-ring\r\nhomomorphism, we then have $\\iota\\circ m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }=m_{\\left(\r\n\\Lambda\\left(  K^{\\prime}\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\circ\\iota^{\\times n}$. Now,%\r\n\\begin{align*}\r\n&  m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right) \\\\\r\n&  =\\iota\\left(  m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)\r\n\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\iota\\text{ is just the\r\ninclusion map }\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(  K^{\\prime\r\n}\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  \\iota\\circ m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\right)\r\n}_{=m_{\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\circ\\iota^{\\times n}}\\left(\r\nu_{1},u_{2},...,u_{n}\\right)  =\\left(  m_{\\left(  \\Lambda\\left(  K^{\\prime\r\n}\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}\\circ\\iota^{\\times n}\\right)  \\left(  u_{1},u_{2},...,u_{n}\\right) \\\\\r\n&  =m_{\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\underbrace{\\left(  \\iota^{\\times\r\nn}\\left(  u_{1},u_{2},...,u_{n}\\right)  \\right)  }_{\\substack{=\\left(\r\n\\iota\\left(  u_{1}\\right)  ,\\iota\\left(  u_{2}\\right)  ,...,\\iota\\left(\r\nu_{n}\\right)  \\right)  \\\\=\\left(  u_{1},u_{2},...,u_{n}\\right)  \\\\\\text{(since\r\n}\\iota\\text{ is just an inclusion map)}}}=m_{\\left(  \\Lambda\\left(  K^{\\prime\r\n}\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}\\left(  u_{1},u_{2},...,u_{n}\\right)\r\n\\end{align*}\r\nand similarly $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  u_{1},u_{2}%\r\n,...,u_{n}\\right)  =m_{\\left(  \\Lambda\\left(  K^{\\prime}\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(\r\nu_{1},u_{2},...,u_{n}\\right)  $. Thus, (\\ref{8.4.fast}) rewrites as\r\n\\[\r\nm_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  u_{1},u_{2},...,u_{n}\\right)  =m_{\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  }^{\\prime}\\left(  u_{1},u_{2},...,u_{n}\\right)  ,\r\n\\]\r\nqed.} Thus we have proven (\\ref{8.4.goal}). This proves Theorem 8.4.\r\n\\end{proof}\r\n\r\nRoughly speaking, Theorem 8.4 says that whether some identity holds on every\r\nspecial $\\lambda$-ring or not can be checked just by looking at the sums of\r\n$1$-dimensional elements. This is why it is worthwhile to study such sums. Let\r\nus record a property of these:\r\n\r\n\\subsection{$\\lambda^{i}$ of a sum of $1$-dimensional elements}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 8.5.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $u_{1}$, $u_{2}$, $...$,\r\n$u_{m}$ be $1$-dimensional elements of $K$. Let $i\\in\\mathbb{N}$. Then,%\r\n\\[\r\n\\lambda^{i}\\left(  u_{1}+u_{2}+...+u_{m}\\right)  =\\sum_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod_{k\\in S}%\r\nu_{k}.\r\n\\]\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 8.5.]We have%\r\n\\begin{align*}\r\n&  \\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  u_{1}+u_{2}+...+u_{m}\\right)\r\nT^{i}=\\lambda_{T}\\left(  u_{1}+u_{2}+...+u_{m}\\right) \\\\\r\n&  =\\prod_{j=1}^{m}\\lambda_{T}\\left(  u_{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 2.1 \\textbf{(a)}, applied several\r\ntimes}\\right) \\\\\r\n&  =\\prod_{j=1}^{m}\\left(  1+u_{j}T\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since the element }u_{j}\\text{ is\r\n}1\\text{-dimensional and thus satisfies }\\lambda_{T}\\left(  u_{j}\\right)\r\n=1+u_{j}T\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\nu_{k}\\cdot T^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Exercise 4.2 \\textbf{(b)}, applied to\r\n}A=K\\left[  T\\right]  \\text{, }\\alpha_{j}=u_{j}\\text{ and }t=T\\right)  .\r\n\\end{align*}\r\nComparing coefficients yields the assertion of Theorem 8.5.\r\n\\end{proof}\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 8.1.} Give a new solution to Exercise 6.9.\r\n\r\n\\textit{Exercise 8.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring. If $x\\in K$ is an\r\ninvertible $1$-dimensional element of $K$, then prove that $x^{-1}$ is\r\n$1$-dimensional as well.\r\n\r\n\\textit{Exercise 8.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $E$ be a generating set\r\nof the $\\mathbb{Z}$-module $K$ such that every element $e\\in E$ is $1$-dimensional.\r\n\r\nProve that the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special.\r\n\\end{quotation}\r\n\r\n\\section{Adams operations}\r\n\r\n\\subsection{The Hirzebruch-Newton polynomials}\r\n\r\nWe are now ready to define Adams operations of special $\\lambda$-rings. There\r\nare two different ways to do this; we will take one of these as the definition\r\nand the other one as a theorem.\r\n\r\nRemember how we defined the ``universal'' polynomials $P_{k}$ and $P_{k,j}$ in\r\nSection 4? Prepare for some more:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. Our\r\ngoal is to define a polynomial $N_{j}\\in\\mathbb{Z}\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{j}\\right]  $ such that%\r\n\\begin{equation}\r\n\\sum_{i=1}^{m}U_{i}^{j}=N_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\label{Nj1}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $m\\in\\mathbb{N}$, where $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$\r\nis the $i$-th elementary symmetric polynomial in the variables $U_{1}$,\r\n$U_{2}$, $...$, $U_{m}$ for every $i\\in\\mathbb{N}$.\r\n\r\nIn order to do this, we first fix some $m\\in\\mathbb{N}$. The polynomial\r\n$\\sum\\limits_{i=1}^{m}U_{i}^{j}\\in\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  $ is symmetric. Thus, Theorem 4.1 \\textbf{(a)} yields that there\r\nexists one and only one polynomial $Q\\in\\mathbb{Z}\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{m}\\right]  $ such that $\\sum\\limits_{i=1}^{m}U_{i}%\r\n^{j}=Q\\left(  X_{1},X_{2},...,X_{m}\\right)  $. Since the polynomial\r\n$\\sum\\limits_{i=1}^{m}U_{i}^{j}$ has total degree $\\leq j$ in the variables\r\n$U_{1}$, $U_{2}$, $...$, $U_{m}$, Theorem 4.1 \\textbf{(b)} yields that%\r\n\\[\r\n\\sum_{i=1}^{m}U_{i}^{j}=Q_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  ,\r\n\\]\r\nwhere $Q_{j}$ is the image of the polynomial $Q$ under the canonical\r\nhomomorphism $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n\\rightarrow\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $.\r\nHowever, this polynomial $Q_{j}$ is not independent of $m$ yet (as the\r\npolynomial $N_{j}$ that we intend to construct should be), so we call it\r\n$Q_{j,\\left[  m\\right]  }$ rather than just $Q_{j}$.\r\n\r\nNow we forget that we fixed $m\\in\\mathbb{N}$. We have learnt that%\r\n\\[\r\n\\sum_{i=1}^{m}U_{i}^{j}=Q_{j,\\left[  m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  ,\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $m\\in\\mathbb{N}$. Now, define a polynomial $N_{j}\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ by $N_{j}=Q_{j,\\left[\r\nj\\right]  }$.\r\n\r\nThis polynomial $N_{j}$ is called the $j$\\textit{-th Hirzebruch-Newton\r\npolynomial}.\\footnote{The ``Newton'' in the name of this polynomial $N_{j}$\r\nprobably refers to the fact that the explicit form of $N_{j}$ can be easily\r\ncomputed (recursively) from the so-called Newton identities (which relate the\r\npower sums and the elementary symmetric polynomials). See Theorem 9.6 and\r\nCorollary 9.7 for details.}\r\n\r\n\\textbf{Theorem 9.1.} \\textbf{(a)} The polynomial $N_{j}$ just defined\r\nsatisfies the equation (\\ref{Nj1}) in the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ for every $m\\in\\mathbb{N}$. (Hence, the goal\r\nmentioned above in the definition is actually achieved.)\r\n\r\n\\textbf{(b)} For every $m\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\nT\\sum_{i=1}^{m}\\dfrac{U_{i}}{1-U_{i}T}=\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  }N_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j} \\label{Nj2}%\r\n\\end{equation}\r\nin the ring $\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)\r\n\\left[  \\left[  T\\right]  \\right]  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.1.]\\textbf{(a)} This proof is going to be very similar to\r\nthat of Theorem 4.4 \\textbf{(a)}.\r\n\r\n\\textit{1st Step:} Fix $m\\in\\mathbb{N}$ such that $m\\geq j$. Then, we claim\r\nthat $Q_{j,\\left[  m\\right]  }=N_{j}$.\r\n\r\n\\textit{Proof.} By the definition of $Q_{j,\\left[  m\\right]  }$, we have%\r\n\\[\r\n\\sum_{i=1}^{m}U_{i}^{j}=Q_{j,\\left[  m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\nApplying the canonical ring epimorphism $\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\rightarrow\\mathbb{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{j}\\right]  $ (which maps every $U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq j;\\\\\r\n0,\\text{ if }i>j\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring), we\r\nobtain%\r\n\\[\r\n\\sum_{i=1}^{j}U_{i}^{j}=Q_{j,\\left[  m\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{j}\\right]  $. On\r\nthe other hand, the definition of $Q_{j,\\left[  j\\right]  }$ yields%\r\n\\[\r\n\\sum_{i=1}^{j}U_{i}^{j}=Q_{j,\\left[  j\\right]  }\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)\r\n\\]\r\nin the same ring. These two equations yield $Q_{j,\\left[  m\\right]  }\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  =Q_{j,\\left[  j\\right]  }\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  $. Since the elements $X_{1}$, $X_{2}$, $...$,\r\n$X_{j}$ of $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{j}\\right]  $ are\r\nalgebraically independent (by Theorem 4.1 \\textbf{(a)}), this yields\r\n$Q_{j,\\left[  m\\right]  }=Q_{j,\\left[  j\\right]  }$. In other words,\r\n$Q_{j,\\left[  m\\right]  }=N_{j}$, and the 1st Step is proven.\r\n\r\n\\textit{2nd Step:} For every $m\\in\\mathbb{N}$, the equation (\\ref{Nj1}) is\r\nsatisfied in the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  $.\r\n\r\n\\textit{Proof.} Let $m^{\\prime}\\in\\mathbb{N}$ be such that $m^{\\prime}\\geq m$\r\nand $m^{\\prime}\\geq j$. Then, the 1st Step (applied to $m^{\\prime}$ instead of\r\n$m$) yields that $Q_{j,\\left[  m^{\\prime}\\right]  }=N_{j}$.\r\n\r\nThe definition of $Q_{j,\\left[  m^{\\prime}\\right]  }$ yields\r\n\\[\r\n\\sum_{i=1}^{m^{\\prime}}U_{i}^{j}=Q_{j,\\left[  m^{\\prime}\\right]  }\\left(\r\nX_{1},X_{2},...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m^{\\prime}%\r\n}\\right]  $. Applying the canonical ring epimorphism $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m^{\\prime}}\\right]  \\rightarrow\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ (which maps every $U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq m;\\\\\r\n0,\\text{ if }i>m\r\n\\end{array}\r\n\\right.  $) to this equation (and noticing that this epimorphism maps every\r\n$X_{i}$ with $i\\geq1$ to the corresponding $X_{i}$ of the image ring), we\r\nobtain%\r\n\\[\r\n\\sum_{i=1}^{m}U_{i}^{j}=Q_{j,\\left[  m^{\\prime}\\right]  }\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\nThis means that the equation (\\ref{Nj1}) is satisfied in the polynomial ring\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (since $Q_{j,\\left[\r\nm^{\\prime}\\right]  }=N_{j}$). This completes the 2nd Step and proves Theorem\r\n9.1 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\nT\\sum_{i=1}^{m}\\dfrac{U_{i}}{1-U_{i}T}  &  =\\sum_{i=1}^{m}U_{i}%\r\nT\\underbrace{\\left(  1-U_{i}T\\right)  ^{-1}}_{=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\left(  U_{i}T\\right)  ^{j}}=\\sum_{i=1}^{m}\\sum_{j\\in\\mathbb{N}}\\left(\r\nU_{i}T\\right)  ^{j+1}=\\sum_{i=1}^{m}\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  }\\left(  U_{i}T\\right)  ^{j}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\sum_{i=1}^{m}\\left(\r\nU_{i}T\\right)  ^{j}=\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n}\\underbrace{\\sum_{i=1}^{m}U_{i}^{j}}_{\\substack{=N_{j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  \\\\\\text{by (\\ref{Nj1})}}}T^{j}=\\sum_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }N_{j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  T^{j},\r\n\\end{align*}\r\nand Theorem 9.1 \\textbf{(b)} is proven.\r\n\\end{proof}\r\n\r\n\\textit{Remark:} There is a subtle point here: We have defined, for every\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, a polynomial $N_{j}%\r\n\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ which\r\nsatisfies (\\ref{Nj1}) in the polynomial ring $\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $ for every $m\\in\\mathbb{N}$. We \\textit{cannot}\r\ndefine such a polynomial $N_{j}$ for $j=0$. In fact, if we would try to do\r\nthis as we did above, then the proof of Theorem 9.1 would fail (in fact, the\r\ncanonical ring epimorphism $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\rightarrow\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{j}\\right]  $ would\r\n\\textit{not} send $\\sum\\limits_{i=1}^{m}U_{i}^{j}$ to $\\sum\\limits_{i=1}%\r\n^{j}U_{i}^{j}$ anymore, because $0^{j}$ is not $0$ for $j=0$). This is why\r\n$N_{j}$ is well-defined only for $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $\r\nand not for all $j\\in\\mathbb{N}$.\r\n\r\n\\textbf{Example.} We can compute the polynomials $N_{j}$ in the same way as we\r\nhave computed the polynomials $P_{k,j}$ in Section 4 - by unraveling the\r\ndefinition. Here are the first few $N_{j}$:%\r\n\\begin{align*}\r\nN_{1}  &  =\\alpha_{1};\\\\\r\nN_{2}  &  =\\alpha_{1}^{2}-2\\alpha_{2};\\\\\r\nN_{3}  &  =\\alpha_{1}^{3}-3\\alpha_{1}\\alpha_{2}+3\\alpha_{3};\\\\\r\nN_{4}  &  =\\alpha_{1}^{4}-4\\alpha_{1}^{2}\\alpha_{2}+4\\alpha_{1}\\alpha\r\n_{3}+2\\alpha_{2}^{2}-4\\alpha_{4}.\r\n\\end{align*}\r\n\r\n\r\nThere are easier ways to compute the $N_{j}$, however. For example, Corollary\r\n9.7 gives a recurrent formula, and Exercise 9.6 \\textbf{(c)} gives an explicit\r\ndeterminantal one.\r\n\r\n\\subsection{Definition of Adams operations}\r\n\r\nNow, let us define Adams operations:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. For every $j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  $, we define a map $\\psi^{j}:K\\rightarrow K$ by%\r\n\\begin{equation}\r\n\\psi^{j}\\left(  x\\right)  =N_{j}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K. \\label{PsiDef}%\r\n\\end{equation}\r\nWe call $\\psi^{j}$ the $j$\\textit{-th Adams operation} (or the $j$\\textit{-th\r\nAdams character}) of the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $.\r\n\\end{quote}\r\n\r\n\\subsection{The equality $\\protect\\widetilde{\\psi}_{T}\\left(  x\\right)  =\r\n-T\\cdot\\frac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  $ for special $\\lambda\r\n$-rings}\r\n\r\nBefore we prove a batch of properties of these Adams characters, let us show\r\nanother approach to these Adams characters:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 9.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring.\r\n\r\nDefine a map $\\widetilde{\\psi}_{T}:K\\rightarrow K\\left[  \\left[  T\\right]\r\n\\right]  $ by $\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}$ for\r\nevery $x\\in K$.\\ \\ \\ \\ \\footnote{Note that we call this map $\\widetilde{\\psi\r\n}_{T}$ to distinguish it from the map $\\psi_{T}$ in \\cite{FulLan85} (which is\r\nmore or less the same but differs slightly).}\r\n\r\nLet $x\\in K$.\r\n\r\n\\textbf{(a)} We have%\r\n\\[\r\n\\psi^{j}\\left(  x\\right)  =\\left(  -1\\right)  ^{j+1}\\sum_{i=0}^{j}i\\lambda\r\n^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(  -x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  \\text{.}%\r\n\\]\r\n\r\n\r\n\\textbf{(b)} We have $\\widetilde{\\psi}_{T}\\left(  x\\right)  =-T\\cdot\\dfrac\r\n{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  $. Here, for every power series\r\n$u\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$, the \\textit{logarithmic\r\nderivative} $\\dfrac{d}{dT}\\log u$ of $u$ is defined by $\\dfrac{d}{dT}\\log\r\nu=\\dfrac{\\dfrac{d}{dT}u}{u}$ (this definition works even in the cases where\r\nthe logarithm doesn't exist, such as rings of positive characteristic), and\r\n$\\lambda_{-T}\\left(  x\\right)  $ denotes $\\operatorname*{ev}_{-T}\\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  $.\r\n\\end{quote}\r\n\r\nBefore we start proving this, let me admit that Theorem 9.2 can be\r\ngeneralized: It still holds if $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is an \\textit{arbitrary} (not necessarily\r\nspecial!) $\\lambda$-ring. However, the proof of Theorem 9.2 that we are going\r\nto give right now cannot be generalized to this situation; it requires the\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ to be special. The generalized version of Theorem 9.2 will be\r\nproven later (see the proof of Theorem 9.5 below), yielding another proof of\r\nTheorem 9.2. The reader is still advised to read the following proof of\r\nTheorem 9.2, even if it is not directly generalizable. In fact, its first two\r\nsteps will be used at later times (in particular, its 1st step will be used in\r\nthe proof of the generalized version), whereas its 4th step gives a good\r\nexample of how Theorem 8.4 can be applied to prove properties of special\r\n$\\lambda$-rings.\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.2.]\\textit{1st step:} For any fixed special $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any\r\nfixed $x\\in K$, the assertions \\textbf{(a)} and \\textbf{(b)} are equivalent.\r\n\r\n\\textit{Proof.} In $K\\left[  \\left[  T\\right]  \\right]  $, we have%\r\n\\[\r\n\\lambda_{-T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  \\left(  -T\\right)  ^{i}=\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)\r\n^{i}\\lambda^{i}\\left(  x\\right)  T^{i},\r\n\\]\r\nbut also%\r\n\\begin{align*}\r\n\\left(  \\lambda_{-T}\\left(  x\\right)  \\right)  ^{-1}  &  =\\lambda_{-T}\\left(\r\n-x\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  ^{-1}=\\lambda_{T}\\left(  -x\\right)  \\text{ by Theorem 2.1\r\n\\textbf{(b)}}\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  -x\\right)\r\nT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{due to }\\lambda_{-T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  x\\right)  T^{i}\\text{,}\\\\\r\n\\text{applied to }-x\\text{ instead of }x\r\n\\end{array}\r\n\\right)\r\n\\end{align*}\r\nand%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)   &  =\\dfrac{d}{dT}\\sum\r\n_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  x\\right)\r\nT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\lambda_{-T}\\left(  x\\right)\r\n=\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  x\\right)\r\nT^{i}\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  x\\right)\r\niT^{i-1}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the derivative of a\r\nformal power series}\\right)  .\r\n\\end{align*}\r\nThus,%\r\n\\begin{align*}\r\n&  -T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right) \\\\\r\n&  =-T\\cdot\\dfrac{\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  }{\\lambda\r\n_{-T}\\left(  x\\right)  }=-T\\cdot\\underbrace{\\dfrac{d}{dT}\\lambda_{-T}\\left(\r\nx\\right)  }_{=\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda\r\n^{i}\\left(  x\\right)  iT^{i-1}}\\cdot\\underbrace{\\left(  \\lambda_{-T}\\left(\r\nx\\right)  \\right)  ^{-1}}_{=\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)\r\n^{i}\\lambda^{i}\\left(  -x\\right)  T^{i}}\\\\\r\n&  =-T\\cdot\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\lambda\r\n^{i}\\left(  x\\right)  iT^{i-1}\\cdot\\sum\\limits_{i\\in\\mathbb{N}}\\left(\r\n-1\\right)  ^{i}\\lambda^{i}\\left(  -x\\right)  T^{i}\\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i+1}\\lambda^{i}\\left(\r\nx\\right)  iT^{i}\\cdot\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)\r\n^{i}\\lambda^{i}\\left(  -x\\right)  T^{i}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\sum_{i=0}^{j}\\left(  -1\\right)  ^{i+1}\\lambda\r\n^{i}\\left(  x\\right)  i\\cdot\\left(  -1\\right)  ^{j-i}\\lambda^{j-i}\\left(\r\n-x\\right)  T^{j}=\\sum_{j\\in\\mathbb{N}}\\left(  -1\\right)  ^{j+1}\\sum_{i=0}%\r\n^{j}i\\lambda^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(  -x\\right)  \\cdot\r\nT^{j}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)\r\n^{j+1}\\sum_{i=0}^{j}i\\lambda^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(\r\n-x\\right)  \\cdot T^{j}+\\underbrace{\\left(  -1\\right)  ^{0+1}\\sum_{i=0}%\r\n^{0}i\\lambda^{i}\\left(  x\\right)  \\lambda^{0-i}\\left(  -x\\right)  \\cdot T^{0}%\r\n}_{=0}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)\r\n^{j+1}\\sum_{i=0}^{j}i\\lambda^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(\r\n-x\\right)  \\cdot T^{j}.\r\n\\end{align*}\r\nOn the other hand, $\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}$.\r\nHence, $\\widetilde{\\psi}_{T}\\left(  x\\right)  =-T\\cdot\\dfrac{d}{dT}\\log\r\n\\lambda_{-T}\\left(  x\\right)  $ holds if and only if%\r\n\\[\r\n\\psi^{j}\\left(  x\\right)  =\\left(  -1\\right)  ^{j+1}\\sum_{i=0}^{j}i\\lambda\r\n^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(  -x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  \\text{.}%\r\n\\]\r\nThis proves that the assertions \\textbf{(a)} and \\textbf{(b)} are equivalent,\r\nand thus the 1st step is complete.\r\n\r\n\\textit{2nd step:} We will now show that the assertion \\textbf{(b)} holds for\r\nevery special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$ such that $x$ is the sum of\r\nfinitely many $1$-dimensional elements of $K$.\r\n\r\n\\textit{Proof.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a special $\\lambda$-ring, and let $x\\in K$ be a sum of finitely\r\nmany $1$-dimensional elements of $K$. In other words, $x=u_{1}+u_{2}%\r\n+...+u_{m}$ for some $1$-dimensional elements $u_{1}$, $u_{2}$, $...$, $u_{m}$\r\nof $K$. Consider these elements $u_{1}$, $u_{2}$, $...$, $u_{m}$.\r\n\r\nThen,%\r\n\\[\r\n\\lambda_{-T}\\left(  x\\right)  =\\lambda_{-T}\\left(  u_{1}+u_{2}+...+u_{m}%\r\n\\right)  =\\prod_{j=1}^{m}\\left(  1-u_{j}T\\right)\r\n\\]\r\n(since $\\lambda_{T}\\left(  u_{1}+u_{2}+...+u_{m}\\right)  =\\prod\\limits_{j=1}%\r\n^{m}\\left(  1+u_{j}T\\right)  $, as shown in the proof of Theorem 8.5), so\r\nthat, by the Leibniz formula,%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)   &  =\\sum_{k=1}^{m}\\left(\r\n\\underbrace{\\dfrac{d}{dT}\\left(  1-u_{k}T\\right)  }_{=-u_{k}}\\right)\r\n\\cdot\\underbrace{\\prod_{j\\in\\left\\{  1,2,...,m\\right\\}  \\setminus\\left\\{\r\nk\\right\\}  }\\left(  1-u_{j}T\\right)  }_{=\\left(  1-u_{k}T\\right)  ^{-1}%\r\n\\cdot\\prod\\limits_{j\\in\\left\\{  1,2,...,m\\right\\}  }\\left(  1-u_{j}T\\right)\r\n}\\\\\r\n&  =-\\sum_{k=1}^{m}\\dfrac{u_{k}}{1-u_{k}T}\\cdot\\underbrace{\\prod\r\n\\limits_{j\\in\\left\\{  1,2,...,m\\right\\}  }\\left(  1-u_{j}T\\right)  }%\r\n_{=\\lambda_{-T}\\left(  x\\right)  }=-\\sum_{k=1}^{m}\\dfrac{u_{k}}{1-u_{k}T}%\r\n\\cdot\\lambda_{-T}\\left(  x\\right)  .\r\n\\end{align*}\r\nHence,%\r\n\\begin{align}\r\n-T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)   &  =-T\\cdot\r\n\\dfrac{\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  }{\\lambda_{-T}\\left(\r\nx\\right)  }=-T\\cdot\\dfrac{-\\sum\\limits_{k=1}^{m}\\dfrac{u_{k}}{1-u_{k}T}%\r\n\\cdot\\lambda_{-T}\\left(  x\\right)  }{\\lambda_{-T}\\left(  x\\right)\r\n}\\nonumber\\\\\r\n&  =T\\cdot\\sum\\limits_{k=1}^{m}\\dfrac{u_{k}}{1-u_{k}T}=T\\sum\\limits_{i=1}%\r\n^{m}\\dfrac{u_{i}}{1-u_{i}T}. \\label{9.2.2step}%\r\n\\end{align}\r\nOn the other hand, Theorem 8.5 yields%\r\n\\[\r\n\\lambda^{i}\\left(  x\\right)  =\\lambda^{i}\\left(  u_{1}+u_{2}+...+u_{m}\\right)\r\n=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}u_{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}i\\in\\mathbb{N}.\r\n\\]\r\n\r\n\r\nConsider the polynomial ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n$. For every $i\\in\\mathbb{N}$, let $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in\r\nS}U_{k}$ be the $i$-th elementary symmetric polynomial in the variables\r\n$U_{1}$, $U_{2}$, $...$, $U_{m}$. There exists a ring homomorphism\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\rightarrow K$ which maps\r\n$U_{i}$ to $u_{i}$ for every $i$. This homomorphism therefore maps $X_{i}$ to\r\n$\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}u_{k}=\\lambda^{i}\\left(  x\\right)  $ for\r\nevery $i\\in\\mathbb{N}$. Hence, applying this homomorphism to (\\ref{Nj2}), we\r\nobtain%\r\n\\[\r\nT\\sum_{i=1}^{m}\\dfrac{u_{i}}{1-u_{i}T}=\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  }\\underbrace{N_{j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda\r\n^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)  }_{=\\psi\r\n^{j}\\left(  x\\right)  \\text{ by (\\ref{PsiDef})}}T^{j}=\\sum_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)\r\nT^{j}=\\widetilde{\\psi}_{T}\\left(  x\\right)  .\r\n\\]\r\nComparing this with (\\ref{9.2.2step}), we obtain%\r\n\\[\r\n-T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  =\\widetilde{\\psi}%\r\n_{T}\\left(  x\\right)  .\r\n\\]\r\nHence, the assertion \\textbf{(b)} holds for every special $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every\r\n$x\\in K$ such that $x$ is the sum of finitely many $1$-dimensional elements of\r\n$K$. This completes the 2nd step.\r\n\r\n\\textit{3rd step:} We will now show that the assertion \\textbf{(a)} holds for\r\nevery special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$ such that $x$ is the sum of\r\nfinitely many $1$-dimensional elements of $K$.\r\n\r\n\\textit{Proof.} This follows from the 2nd step, since \\textbf{(a)} and\r\n\\textbf{(b)} are equivalent (by the 1st step).\r\n\r\n\\textit{4th step:} We will now show that the assertion \\textbf{(a)} holds for\r\nevery special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$.\r\n\r\n\\textit{Proof.} We want to derive this from the 3rd step by applying Theorem 8.4.\r\n\r\nFix some $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $.\r\n\r\nDefine a $1$-operation $m$ of special $\\lambda$-rings by $m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }=\\psi^{j}$ for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $. (This is indeed a $1$-operation, since (\\ref{PsiDef}) shows that\r\n$\\psi^{j}$ is a polynomial in $\\lambda^{0}$, $\\lambda^{1}$, $\\lambda^{2}$,\r\n$...$, $\\lambda^{j}$ with integer coefficients.)\r\n\r\nDefine a $1$-operation $m^{\\prime}$ of special $\\lambda$-rings by%\r\n\\[\r\nm_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime\r\n}\\left(  x\\right)  =\\left(  -1\\right)  ^{j+1}\\sum_{i=0}^{j}i\\lambda^{i}\\left(\r\nx\\right)  \\lambda^{j-i}\\left(  -x\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}x\\in K\r\n\\]\r\nfor every $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $. (This is, again, a $1$-operation, since it is a\r\npolynomial in $\\lambda^{0}\\left(  x\\right)  $, $\\lambda^{1}\\left(  x\\right)\r\n$, $...$, $\\lambda^{j}\\left(  x\\right)$, $\\lambda^{0}\\left(  -x\\right)$,\r\n$\\lambda^{1}\\left(  -x\\right)$, $\\ldots$, $\\lambda^{j}\\left(  -x\\right)  $\r\nwith integer coefficients.)\r\n\r\nThese two $1$-operations $m$ and $m^{\\prime}$ satisfy both conditions of\r\nTheorem 8.4: The continuity assumption holds (since the operations $m$ and\r\n$m^{\\prime}$ are polynomials in $\\lambda^{1}$, $\\lambda^{2}$, $...$,\r\n$\\lambda^{j}$ with integer coefficients, so that the maps $m_{\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  }$ and $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}$ are\r\npolynomials in $\\widehat{\\lambda}^{1}$, $\\widehat{\\lambda}^{2}$, $...$,\r\n$\\widehat{\\lambda}^{j}$ with integer coefficients, and therefore continuous\r\nbecause of Theorem 5.5 \\textbf{(d)}), and the split equality assumption holds\r\n(since it states that for every special $\\lambda$-ring $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$ such that\r\n$x$ is the sum of finitely many $1$-dimensional elements of $K$, we have\r\n$m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(\r\nx\\right)  =m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}^{\\prime}\\left(  x\\right)  $; but this simply means that $\\psi^{j}\\left(\r\nx\\right)  =\\left(  -1\\right)  ^{j+1}\\sum\\limits_{i=0}^{j}i\\lambda^{i}\\left(\r\nx\\right)  \\lambda^{j-i}\\left(  -x\\right)  $, which was proven in the 3rd\r\nstep). Hence, by Theorem 8.4, we have $m=m^{\\prime}$. Hence, for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ and every $x\\in K$, we have%\r\n\\[\r\n\\psi^{j}\\left(  x\\right)  =m_{\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }\\left(  x\\right)  =m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  x\\right)  =\\left(\r\n-1\\right)  ^{j+1}\\sum_{i=0}^{j}i\\lambda^{i}\\left(  x\\right)  \\lambda\r\n^{j-i}\\left(  -x\\right)  .\r\n\\]\r\nThus, the assertion \\textbf{(a)} holds for every special $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every\r\n$x\\in K$. This completes the 4th step.\r\n\r\n\\textit{5th step:} We will now prove that the assertion \\textbf{(b)} holds for\r\nevery special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$.\r\n\r\n\\textit{Proof.} This follows from the 4th step, since \\textbf{(a)} and\r\n\\textbf{(b)} are equivalent (by the 1st step).\r\n\r\nThus, the proof of Theorem 9.2 is completed.\r\n\\end{proof}\r\n\r\n\\subsection{Adams operations are ring homomorphisms when the $\\lambda$-ring is\r\nspecial}\r\n\r\nThe Adams operations $\\psi^{j}$ have a lot of interesting properties (that\r\nmake them easier to deal with than $\\lambda$-operations!):\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 9.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring.\r\n\r\n\\textbf{(a)} For every $a\\in K$, we have $\\psi^{1}\\left(  a\\right)  =a$.\r\n\r\n\\textbf{(b)} For every $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, the map\r\n$\\psi^{j}:\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a $\\lambda$-ring homomorphism.\r\n\r\n\\textbf{(c)} For every $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $ and\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, we have $\\psi^{i}\\circ\\psi\r\n^{j}=\\psi^{j}\\circ\\psi^{i}=\\psi^{ij}$.\r\n\\end{quote}\r\n\r\nBefore we come to prove this, let us first show an analogue of Theorem 8.5 for\r\nthe $\\psi^{i}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 9.4.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $u_{1}$, $u_{2}$, $...$,\r\n$u_{m}$ be $1$-dimensional elements of $K$. Let $j\\in\\mathbb{N}\\setminus\r\n\\left\\{  0\\right\\}  $. Then,%\r\n\\[\r\n\\psi^{j}\\left(  u_{1}+u_{2}+...+u_{m}\\right)  =u_{1}^{j}+u_{2}^{j}%\r\n+...+u_{m}^{j}.\r\n\\]\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.4.]Let $x=u_{1}+u_{2}+...+u_{m}$. Just as in the proof of\r\nTheorem 9.2 (in the 2nd step)\\footnote{Here, we use the fact that the 2nd step\r\nof the proof of Theorem 9.2 works for \\textit{any} $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, not only for\r\nspecial ones.}, we can show that%\r\n\\[\r\nT\\sum\\limits_{i=1}^{m}\\dfrac{u_{i}}{1-u_{i}T}=\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}.\r\n\\]\r\n\r\n\r\nThus,%\r\n\\begin{align*}\r\n\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  T^{j}  &  =T\\sum\\limits_{i=1}^{m}\\dfrac{u_{i}}{1-u_{i}T}%\r\n=\\sum\\limits_{i=1}^{m}u_{i}T\\left(  1-u_{i}T\\right)  ^{-1}=\\sum\\limits_{i=1}%\r\n^{m}u_{i}T\\sum_{k\\in\\mathbb{N}}\\left(  u_{i}T\\right)  ^{k}\\\\\r\n&  =\\sum\\limits_{i=1}^{m}\\sum_{k\\in\\mathbb{N}}\\left(  u_{i}T\\right)\r\n^{k+1}=\\sum\\limits_{i=1}^{m}\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n}\\left(  u_{i}T\\right)  ^{j}=\\sum\\limits_{i=1}^{m}\\sum_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }u_{i}^{j}T^{j}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\sum\\limits_{i=1}%\r\n^{m}u_{i}^{j}T^{j}.\r\n\\end{align*}\r\nComparing coefficients yields $\\psi^{j}\\left(  x\\right)  =\\sum\\limits_{i=1}%\r\n^{m}u_{i}^{j}$ for every $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, and\r\nthus Theorem 9.4 is proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.3.]\\textbf{(a)} is trivial (for instance, by Theorem 9.2\r\n\\textbf{(a)}).\r\n\r\n\\textbf{(b)} Fix some $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. First,\r\nlet us prove that $\\psi^{j}:K\\rightarrow K$ is a ring homomorphism.\r\n\r\nThis means proving that%\r\n\\begin{align}\r\n\\psi^{j}\\left(  0\\right)   &  =0;\\label{9.3.1}\\\\\r\n\\psi^{j}\\left(  x+y\\right)   &  =\\psi^{j}\\left(  x\\right)  +\\psi^{j}\\left(\r\ny\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any }x\\in K\\text{ and }y\\in\r\nK;\\label{9.3.2}\\\\\r\n\\psi^{j}\\left(  1\\right)   &  =1;\\label{9.3.3}\\\\\r\n\\psi^{j}\\left(  xy\\right)   &  =\\psi^{j}\\left(  x\\right)  \\cdot\\psi^{j}\\left(\r\ny\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any }x\\in K\\text{ and }y\\in K.\r\n\\label{9.3.4}%\r\n\\end{align}\r\nOut of these four equations, two (namely, (\\ref{9.3.1}) and (\\ref{9.3.3})) are\r\ntrivial (just apply Theorem 9.4, remembering that $1$ is a $1$-dimensional\r\nelement), so it remains to prove the other two equations - namely,\r\n(\\ref{9.3.2}) and (\\ref{9.3.4}).\r\n\r\nFirst, let us prove (\\ref{9.3.4}):\r\n\r\nDefine a $2$-operation $m$ of special $\\lambda$-rings as follows: For every\r\nspecial $\\lambda$-ring $K$, let $m_{\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }:K^{2}\\rightarrow K$ be the map defined by\r\n$m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(\r\nx,y\\right)  =\\psi^{j}\\left(  xy\\right)  $ for every $x\\in K$ and $y\\in K$.\r\n(This is indeed a $2$-operation of special $\\lambda$-rings, since $\\psi^{j}$\r\nis a polynomial in the $\\lambda^{1}$, $\\lambda^{2}$, $...$, $\\lambda^{j}$ with\r\ninteger coefficients.)\r\n\r\nDefine a $2$-operation $m^{\\prime}$ of special $\\lambda$-rings as follows: For\r\nevery special $\\lambda$-ring $K$, let $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}:K^{2}\\rightarrow K$ be the\r\nmap defined by $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  }^{\\prime}\\left(  x,y\\right)  =\\psi^{j}\\left(  x\\right)  \\cdot\r\n\\psi^{j}\\left(  y\\right)  $ for every $x\\in K$ and $y\\in K$. (Again, this is\r\nreally a $2$-operation of special $\\lambda$-rings.)\r\n\r\nWe want to prove that $m=m^{\\prime}$. According to Theorem 8.4, this will be\r\ndone once we have verified the continuity assumption and the split equality\r\nassumption. The continuity assumption is obviously satisfied (since for every\r\nring $K$, the maps $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }:\\left(\r\n\\Lambda\\left(  K\\right)  \\right)  ^{2}\\rightarrow\\Lambda\\left(  K\\right)  $\r\nand $m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}:\\left(  \\Lambda\\left(\r\nK\\right)  \\right)  ^{2}\\rightarrow\\Lambda\\left(  K\\right)  $ are continuous by\r\nTheorem 5.5 \\textbf{(d)}, because they are polynomials in $\\widehat{\\lambda\r\n}^{1}$, $\\widehat{\\lambda}^{2}$, $...$, $\\widehat{\\lambda}^{j}$ with integer\r\ncoefficients). Hence, it remains to verify the split equality assumption. This\r\nassumption claims that for every special $\\lambda$-ring $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every $\\left(  x,y\\right)\r\n\\in K^{2}$ such that each of $x$ and $y$ is the sum of finitely many\r\n$1$-dimensional elements of $K$, we have $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(  x,y\\right)  =m_{\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(\r\nx,y\\right)  $.\r\n\r\nSince $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n}\\left(  x,y\\right)  =\\psi^{j}\\left(  xy\\right)  $ and $m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  x,y\\right)\r\n=\\psi^{j}\\left(  x\\right)  \\cdot\\psi^{j}\\left(  y\\right)  $, this is\r\nequivalent to claiming that for every special $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every $\\left(\r\nx,y\\right)  \\in K^{2}$ such that each of $x$ and $y$ is the sum of finitely\r\nmany $1$-dimensional elements of $K$, we have $\\psi^{j}\\left(  xy\\right)\r\n=\\psi^{j}\\left(  x\\right)  \\cdot\\psi^{j}\\left(  y\\right)  $.\r\n\r\nSo let us verify this assumption. Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring, and let $\\left(\r\nx,y\\right)  \\in K^{2}$ be such that each of $x$ and $y$ is the sum of finitely\r\nmany $1$-dimensional elements of $K$. Thus, there exist $1$-dimensional\r\nelements $u_{1}$, $u_{2}$, $...$, $u_{m}$ of $K$ such that $x=u_{1}%\r\n+u_{2}+...+u_{m}$, and there exist $1$-dimensional elements $v_{1}$, $v_{2}$,\r\n$...$, $v_{n}$ of $K$ such that $y=v_{1}+v_{2}+...+v_{n}$. Consider these\r\n$1$-dimensional elements. Then,%\r\n\\begin{align*}\r\n&  m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(\r\nx,y\\right) \\\\\r\n&  =\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(  \\left(  u_{1}+u_{2}%\r\n+...+u_{m}\\right)  \\left(  v_{1}+v_{2}+...+v_{n}\\right)  \\right) \\\\\r\n&  =\\psi^{j}\\left(  \\sum_{i=1}^{m}u_{i}\\sum_{i^{\\prime}=1}^{n}v_{i^{\\prime}%\r\n}\\right)  =\\psi^{j}\\left(  \\sum_{i=1}^{m}\\sum_{i^{\\prime}=1}^{n}%\r\nu_{i}v_{i^{\\prime}}\\right)  =\\sum_{i=1}^{m}\\sum_{i^{\\prime}=1}^{n}\\left(\r\nu_{i}v_{i^{\\prime}}\\right)  ^{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Theorem 9.4, applied to the }1\\text{-dimensional elements }%\r\nu_{i}v_{i^{\\prime}}\\text{,}\\\\\r\n\\text{which are }1\\text{-dimensional because of Theorem 8.3 \\textbf{(b)}}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{i=1}^{m}\\sum_{i^{\\prime}=1}^{n}u_{i}^{j}v_{i^{\\prime}}^{j}%\r\n=\\sum_{i=1}^{m}u_{i}^{j}\\sum_{i^{\\prime}=1}^{n}v_{i^{\\prime}}^{j}%\r\n=\\underbrace{\\left(  u_{1}^{j}+u_{2}^{j}+...+u_{m}^{j}\\right)  }%\r\n_{\\substack{=\\psi^{j}\\left(  u_{1}+u_{2}+...+u_{m}\\right)  \\\\\\text{by Theorem\r\n9.4}}}\\underbrace{\\left(  v_{1}^{j}+v_{2}^{j}+...+v_{n}^{j}\\right)\r\n}_{\\substack{=\\psi^{j}\\left(  v_{1}+v_{2}+...+v_{n}\\right)  \\\\\\text{by Theorem\r\n9.4}}}\\\\\r\n&  =\\psi^{j}\\left(  \\underbrace{u_{1}+u_{2}+...+u_{m}}_{=x}\\right)  \\cdot\r\n\\psi^{j}\\left(  \\underbrace{v_{1}+v_{2}+...+v_{n}}_{=y}\\right)  =\\psi\r\n^{j}\\left(  x\\right)  \\cdot\\psi^{j}\\left(  y\\right)  =m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  x,y\\right)  ,\r\n\\end{align*}\r\nand the proof of the split equality assumption is complete. Thus, using\r\nTheorem 8.4, we obtain that $\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(\r\nx\\right)  \\cdot\\psi^{j}\\left(  y\\right)  $ holds for any $x\\in K$ and any\r\n$y\\in K$.\r\n\r\nThe main idea of the above proof was that, using Theorem 8.4, we can reduce\r\nour goal - which was to show that $\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(\r\nx\\right)  \\cdot\\psi^{j}\\left(  y\\right)  $ for any $x\\in K$ and $y\\in K$ - to\r\na simpler goal - namely, to prove that \\textit{under the additional condition}\r\nthat each of $x$ and $y$ is the sum of finitely many $1$-dimensional elements\r\nof $K$, we have $\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(  x\\right)\r\n\\cdot\\psi^{j}\\left(  y\\right)  $. In other words, when proving the equality\r\n$\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(  x\\right)  \\cdot\\psi^{j}\\left(\r\ny\\right)  $, we could WLOG assume that each of $x$ and $y$ is the sum of\r\nfinitely many $1$-dimensional elements of $K$. Under this assumption, the\r\nequality $\\psi^{j}\\left(  xy\\right)  =\\psi^{j}\\left(  x\\right)  \\cdot\\psi\r\n^{j}\\left(  y\\right)  $ was an easy consequence of Theorem 9.4. This way, we\r\nhave proven (\\ref{9.3.4}). Similarly, we can show (\\ref{9.3.2}).\r\n\r\nAgain, for every $i\\in\\mathbb{N}$, we can use the same tactic to show that\r\n$\\left(  \\psi^{j}\\circ\\lambda^{i}\\right)  \\left(  x\\right)  =\\left(\r\n\\lambda^{i}\\circ\\psi^{j}\\right)  \\left(  x\\right)  $ for every $x\\in K$\r\n(namely, we use Theorem 8.4 to reduce the proof to the case when $x$ is the\r\nsum of finitely many $1$-dimensional elements of $K$, and we apply Theorems\r\n9.4, 8.5 and 8.3 \\textbf{(b)} to verify it in this case). Hence, $\\psi\r\n^{j}\\circ\\lambda^{i}=\\lambda^{i}\\circ\\psi^{j}$ for every $i\\in\\mathbb{N}$, and\r\nthus $\\psi^{j}$ is a $\\lambda$-ring homomorphism. Theorem 9.3 \\textbf{(b)} is proven.\r\n\r\n\\textbf{(c)} Fix $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $ and\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. We have to prove that $\\psi\r\n^{i}\\circ\\psi^{j}=\\psi^{j}\\circ\\psi^{i}=\\psi^{ij}$. In other words, we have to\r\nprove that $\\left(  \\psi^{i}\\circ\\psi^{j}\\right)  \\left(  x\\right)  =\\left(\r\n\\psi^{j}\\circ\\psi^{i}\\right)  \\left(  x\\right)  =\\psi^{ij}\\left(  x\\right)  $\r\nfor every $x\\in K$. This can be done by the same method as in the proof of\r\npart \\textbf{(b)}: First, reduce the proof to the case when $x$ is the sum of\r\nfinitely many $1$-dimensional elements of $K$ (by an application of Theorem\r\n8.4); then, verify $\\left(  \\psi^{i}\\circ\\psi^{j}\\right)  \\left(  x\\right)\r\n=\\left(  \\psi^{j}\\circ\\psi^{i}\\right)  \\left(  x\\right)  =\\psi^{ij}\\left(\r\nx\\right)  $ in this case by applying Theorems 9.4 and 8.3 \\textbf{(b)}. Thus,\r\nTheorem 9.3 \\textbf{(c)} is proven.\r\n\\end{proof}\r\n\r\n\\subsection{The equality $\\protect\\widetilde{\\psi}_{T}\\left(  x\\right)\r\n=-T\\cdot\\frac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  $ for arbitrary\r\n$\\lambda$-rings}\r\n\r\nNow, as promised, we are going to prove a generalization of Theorem 9.2 to\r\narbitrary $\\lambda$-rings:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 9.5.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring.\r\n\r\nDefine a map $\\widetilde{\\psi}_{T}:K\\rightarrow K\\left[  \\left[  T\\right]\r\n\\right]  $ by $\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}$ for\r\nevery $x\\in K$.\\ \\ \\ \\ \\footnote{Note that we call this map $\\widetilde{\\psi\r\n}_{T}$ to distinguish it from the map $\\psi_{T}$ in \\cite{FulLan85} (which is\r\nmore or less the same but differs slightly).}\r\n\r\nLet $x\\in K$.\r\n\r\n\\textbf{(a)} We have%\r\n\\[\r\n\\psi^{j}\\left(  x\\right)  =\\left(  -1\\right)  ^{j+1}\\sum_{i=0}^{j}i\\lambda\r\n^{i}\\left(  x\\right)  \\lambda^{j-i}\\left(  -x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  \\text{.}%\r\n\\]\r\n\r\n\r\n\\textbf{(b)} We have $\\widetilde{\\psi}_{T}\\left(  x\\right)  =-T\\cdot\\dfrac\r\n{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  $. Here, for every power series\r\n$u\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$, the \\textit{logarithmic\r\nderivative} $\\dfrac{d}{dT}\\log u$ of $u$ is defined by $\\dfrac{d}{dT}\\log\r\nu=\\dfrac{\\dfrac{d}{dT}u}{u}$ (this definition works even in the cases where\r\nthe logarithm doesn't exist, such as rings of positive characteristic), and\r\n$\\lambda_{-T}\\left(  x\\right)  $ denotes $\\operatorname*{ev}_{-T}\\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  $.\r\n\\end{quote}\r\n\r\nBefore we prove this, let us show a lemma about symmetric polynomials first -\r\na kind of continuation of Theorem 9.1:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 9.6.} Let $m\\in\\mathbb{N}$. Let us recall that, for every\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, we denote by $N_{j}$ the $j$-th\r\nHirzebruch-Newton polynomial (defined at the beginning of Section 9). Let us\r\nalso recall that for every $i\\in\\mathbb{N}$, we denote by $X_{i}$ the $i$-th\r\nelementary symmetric polynomial in the polynomial ring $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $.\r\n\r\nThen, every $n\\in\\mathbb{N}$ satisfies%\r\n\\[\r\nnX_{n}=\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}X_{n-j}N_{j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)\r\n\\]\r\nin the ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\n\\end{quote}\r\n\r\nThis theorem is more or less a rewriting of the famous \\textit{Newton\r\nidentities}.\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.6.]In the power series ring $\\left(  \\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $,\r\nwe have%\r\n\\begin{align}\r\n\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}T\\right)   &  =\\sum_{i\\in\\mathbb{N}%\r\n}\\left(  -1\\right)  ^{i}\\underbrace{\\sum_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}%\r\n}_{=X_{i}}T^{i}\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Exercise 4.2 \\textbf{(c)}, applied to }A=\\left(  \\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]\r\n\\text{,}\\\\\r\n\\alpha_{i}=U_{i}\\text{ and }t=T\r\n\\end{array}\r\n\\right) \\nonumber\\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}X_{i}T^{i}. \\label{9.6.pf0}%\r\n\\end{align}\r\n\r\n\r\nBut the product rule for several factors says that whenever $\\alpha_{1}$,\r\n$\\alpha_{2}$, $...$, $\\alpha_{m}$ are power series in $\\mathbb{K}\\left[\r\n\\left[  T\\right]  \\right]  $ (where $\\mathbb{K}$ is a commutative ring), we\r\nhave%\r\n\\[\r\n\\dfrac{d}{dT}\\prod\\limits_{i=1}^{m}\\alpha_{i}=\\sum_{j=1}^{m}\\left(  \\dfrac\r\n{d}{dT}\\alpha_{j}\\right)  \\prod_{\\substack{i\\in\\left\\{  1,2,...,m\\right\\}\r\n;\\\\i\\neq j}}\\alpha_{i}.\r\n\\]\r\nApplying this to the power series $\\alpha_{i}=1-U_{i}T$, we obtain%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}T\\right)   &  =\\sum\r\n_{j=1}^{m}\\underbrace{\\left(  \\dfrac{d}{dT}\\left(  1-U_{j}T\\right)  \\right)\r\n}_{=-U_{j}=-\\dfrac{U_{j}}{1-U_{j}T}\\left(  1-U_{j}T\\right)  }\\prod\r\n_{\\substack{i\\in\\left\\{  1,2,...,m\\right\\}  ;\\\\i\\neq j}}\\left(  1-U_{i}%\r\nT\\right) \\\\\r\n&  =\\sum_{j=1}^{m}\\left(  -\\dfrac{U_{j}}{1-U_{j}T}\\left(  1-U_{j}T\\right)\r\n\\right)  \\prod_{\\substack{i\\in\\left\\{  1,2,...,m\\right\\}  ;\\\\i\\neq j}}\\left(\r\n1-U_{i}T\\right) \\\\\r\n&  =-\\sum_{j=1}^{m}\\dfrac{U_{j}}{1-U_{j}T}\\underbrace{\\left(  1-U_{j}T\\right)\r\n\\prod_{\\substack{i\\in\\left\\{  1,2,...,m\\right\\}  ;\\\\i\\neq j}}\\left(\r\n1-U_{i}T\\right)  }_{=\\prod\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(\r\n1-U_{i}T\\right)  }\\\\\r\n&  =-\\sum_{j=1}^{m}\\dfrac{U_{j}}{1-U_{j}T}\\prod\\limits_{i\\in\\left\\{\r\n1,2,...,m\\right\\}  }\\left(  1-U_{i}T\\right)  =-\\sum\\limits_{i=1}^{m}%\r\n\\dfrac{U_{i}}{1-U_{i}T}\\prod\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(\r\n1-U_{i}T\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed }j\\text{ as }i\\text{ in\r\nthe first sum}\\right)  .\r\n\\end{align*}\r\nSince%\r\n\\begin{align*}\r\n&  \\dfrac{d}{dT}\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}T\\right) \\\\\r\n&  =\\dfrac{d}{dT}\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}X_{i}%\r\nT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{9.6.pf0})}\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)\r\n^{i}X_{i}iT^{i-1}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the\r\nderivative of a power series}\\right)  ,\r\n\\end{align*}\r\nthis rewrites as%\r\n\\begin{equation}\r\n\\sum_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)  ^{i}%\r\nX_{i}iT^{i-1}=-\\sum\\limits_{i=1}^{m}\\dfrac{U_{i}}{1-U_{i}T}\\prod\r\n\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(  1-U_{i}T\\right)  .\r\n\\label{9.6.pf2}%\r\n\\end{equation}\r\nNow,%\r\n\\begin{align*}\r\n\\sum_{n\\in\\mathbb{N}}\\left(  -1\\right)  ^{n}nX_{n}T^{n}  &  =\\sum\r\n_{n\\in\\mathbb{N}}\\left(  -1\\right)  ^{n}X_{n}nT^{n}=\\sum_{n\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)  ^{n}X_{n}nT^{n}%\r\n+\\underbrace{\\left(  -1\\right)  ^{0}X_{0}0T^{0}}_{=0}\\\\\r\n&  =\\sum_{n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)\r\n^{n}X_{n}nT^{n}\\\\\r\n&  =\\sum_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)\r\n^{i}X_{i}i\\underbrace{T^{i}}_{=TT^{i-1}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{here, we renamed }n\\text{ as }i\\right) \\\\\r\n&  =T\\underbrace{\\sum_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(\r\n-1\\right)  ^{i}X_{i}iT^{i-1}}_{\\substack{=-\\sum\\limits_{i=1}^{m}\\dfrac{U_{i}%\r\n}{1-U_{i}T}\\prod\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(\r\n1-U_{i}T\\right)  \\\\\\text{(by (\\ref{9.6.pf2}))}}}=-T\\sum\\limits_{i=1}^{m}%\r\n\\dfrac{U_{i}}{1-U_{i}T}\\prod\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(\r\n1-U_{i}T\\right) \\\\\r\n&  =-\\underbrace{\\left(  T\\sum\\limits_{i=1}^{m}\\dfrac{U_{i}}{1-U_{i}T}\\right)\r\n}_{\\substack{=\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }%\r\nN_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j}\\\\\\text{(by (\\ref{Nj2}))}%\r\n}}\\underbrace{\\left(  \\prod\\limits_{i\\in\\left\\{  1,2,...,m\\right\\}  }\\left(\r\n1-U_{i}T\\right)  \\right)  }_{\\substack{=\\sum\\limits_{i\\in\\mathbb{N}}\\left(\r\n-1\\right)  ^{i}X_{i}T^{i}\\\\\\text{(by (\\ref{9.6.pf0}))}}}\\\\\r\n&  =-\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }N_{j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\cdot\\sum\\limits_{i\\in\\mathbb{N}}\\left(\r\n-1\\right)  ^{i}X_{i}T^{i}\\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }N_{j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\cdot\\sum\\limits_{i\\in\\mathbb{N}}\\left(\r\n-\\left(  -1\\right)  ^{i}\\right)  X_{i}T^{i}\\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}\\left(  \\sum_{j=1}^{n}N_{j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  \\left(  -\\left(  -1\\right)  ^{n-j}\\right)\r\nX_{n-j}\\right)  T^{n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\nformal power series}\\right)  .\r\n\\end{align*}\r\nComparing the coefficients before $T^{n}$ on the two sides of this equation,\r\nwe obtain%\r\n\\[\r\n\\left(  -1\\right)  ^{n}nX_{n}=\\sum_{j=1}^{n}N_{j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\left(  -\\left(  -1\\right)  ^{n-j}\\right)  X_{n-j}%\r\n\\]\r\nfor every $n\\in\\mathbb{N}$. Dividing this equation by $\\left(  -1\\right)\r\n^{n}$, we arrive at%\r\n\\begin{align*}\r\nnX_{n}  &  =\\sum_{j=1}^{n}N_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\underbrace{\\dfrac{-\\left(  -1\\right)  ^{n-j}}{\\left(  -1\\right)  ^{n}}%\r\n}_{\\substack{=-\\left(  -1\\right)  ^{\\left(  n-j\\right)  -n}=-\\left(\r\n-1\\right)  ^{-j}\\\\=-\\left(  \\dfrac{1}{-1}\\right)  ^{j}=-\\left(  -1\\right)\r\n^{j}=\\left(  -1\\right)  ^{j-1}}}X_{n-j}\\\\\r\n&  =\\sum_{j=1}^{n}N_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\left(\r\n-1\\right)  ^{j-1}X_{n-j}=\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}X_{n-j}%\r\nN_{j}\\left(  X_{1},X_{2},...,X_{j}\\right)  .\r\n\\end{align*}\r\nThis proves Theorem 9.6.\r\n\\end{proof}\r\n\r\nAs a consequence of Theorem 9.6, we get the following fact (which can be used\r\nas a recurrence equation to easily compute the Hirzebruch-Newton polynomials\r\n$N_{j}$):\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 9.7.} Let us recall that, for every $j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  $, we denote by $N_{j}$ the $j$-th\r\nHirzebruch-Newton polynomial (defined at the beginning of Section 9). Then,\r\nevery $n\\in\\mathbb{N}$ satisfies%\r\n\\[\r\nn\\alpha_{n}=\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}%\r\nN_{j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{n}\\right]  $. Here, $\\alpha_{0}$ is to be understood as $1$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary 9.7.]We WLOG assume that $n>0$ (since for $n=0$, Corollary\r\n9.7 is trivial).\r\n\r\nLet $\\mathfrak{Q}_{1}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{n}\\right]  $ be the polynomial defined by $\\mathfrak{Q}_{1}=n\\alpha_{n}$.\r\nLet $\\mathfrak{Q}_{2}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{n}\\right]  $ be the polynomial defined by $\\mathfrak{Q}_{2}=\\sum\r\n\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{j}\\right)  $. We are going to prove that\r\n$\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nConsider the ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{n}\\right]  $ (the\r\npolynomial ring in $n$ indeterminates $U_{1}$, $U_{2}$, $...$, $U_{n}$ over\r\nthe ring $\\mathbb{Z}$). For every $i\\in\\mathbb{N}$, let $X_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,n\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ be the so-called $i$\\textit{-th\r\nelementary symmetric polynomial} in the variables $U_{1}$, $U_{2}$, $...$,\r\n$U_{n}$. (In particular, $X_{0}=1$ and $X_{i}=0$ for every $i>n$.) Applying\r\nTheorem 4.1 \\textbf{(a)} to $K=\\mathbb{Z}$, $m=n$ and $P=nX_{n}$, we conclude\r\nthat there exists one and only one polynomial $Q\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right]  $ such that $nX_{n}=Q\\left(\r\nX_{1},X_{2},...,X_{n}\\right)  $. In particular, there exists \\textit{at most\r\none} such polynomial $Q\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{n}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{n}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right]  \\text{ are two polynomials}\\\\\r\n\\text{such that }nX_{n}=\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{n}\\right)\r\n\\text{ and }nX_{n}=\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{n}\\right)\r\n\\text{,}\\\\\r\n\\text{then }\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{9.7.pf1}%\r\n\\end{equation}\r\n\r\n\r\nClearly, $\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{n}\\right)  =nX_{n}$\r\n(since $\\mathfrak{Q}_{1}=n\\alpha_{n}$). On the other hand,\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}  &  =\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}%\r\n\\alpha_{n-j}N_{j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  +\\left(  -1\\right)\r\n^{n-1}\\underbrace{\\alpha_{n-n}}_{=\\alpha_{0}=1}N_{n}\\left(  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{n}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  +\\left(  -1\\right)  ^{n-1}%\r\n1N_{n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right)  ,\r\n\\end{align*}\r\nso that%\r\n\\begin{align*}\r\n&  \\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{n}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}X_{n-j}N_{j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  +\\left(  -1\\right)  ^{n-1}\\underbrace{1}%\r\n_{=X_{0}=X_{n-n}}N_{n}\\left(  X_{1},X_{2},...,X_{n}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}X_{n-j}N_{j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  +\\left(  -1\\right)  ^{n-1}X_{n-n}N_{n}\\left(\r\nX_{1},X_{2},...,X_{n}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}X_{n-j}N_{j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right) \\\\\r\n&  =nX_{n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 9.6, applied to\r\n}m=n\\right)  .\r\n\\end{align*}\r\nHence, $\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}$ (due to (\\ref{9.7.pf1})). Since\r\n$\\mathfrak{Q}_{1}=n\\alpha_{n}$ and $\\mathfrak{Q}_{2}=\\sum\\limits_{j=1}%\r\n^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  $, this rewrites as $n\\alpha_{n}=\\sum\r\n\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{j}\\right)  $. This proves Corollary 9.7.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 9.5.]\\textit{1st step:} For any fixed $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any\r\nfixed $x\\in K$, the assertions \\textbf{(a)} and \\textbf{(b)} are equivalent.\r\n\r\n\\textit{Proof.} This proof is exactly the same as the proof of the 1st step of\r\nthe proof of Theorem 9.2. (In fact, during the 1st step of the proof of\r\nTheorem 9.2, we have never used the assumption that the $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is special.)\r\n\r\n\\textit{2nd step:} For any $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any $x\\in K$, we have%\r\n\\[\r\nn\\lambda^{n}\\left(  x\\right)  =\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}%\r\n\\lambda^{n-j}\\left(  x\\right)  \\psi^{j}\\left(  x\\right)\r\n\\]\r\nfor every $n\\in\\mathbb{N}$.\r\n\r\n\\textit{Proof.} Let $n\\in\\mathbb{N}$. Corollary 9.7 yields%\r\n\\begin{align*}\r\nn\\alpha_{n}  &  =\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha\r\n_{n-j}N_{j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  +\\left(  -1\\right)\r\n^{n-1}\\underbrace{\\alpha_{n-n}}_{=\\alpha_{0}=1}N_{n}\\left(  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{n}\\right) \\\\\r\n&  =\\sum\\limits_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}N_{j}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  +\\left(  -1\\right)  ^{n-1}%\r\n1N_{n}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right)  .\r\n\\end{align*}\r\nThis is a polynomial identity in $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{n}\\right]  $. Hence, we can apply this identity to\r\n$\\alpha_{1}=\\lambda^{1}\\left(  x\\right)  $, $\\alpha_{2}=\\lambda^{2}\\left(\r\nx\\right)  $, $...$, $\\alpha_{n}=\\lambda^{n}\\left(  x\\right)  $, and obtain%\r\n\\begin{align*}\r\nn\\lambda^{n}\\left(  x\\right)   &  =\\sum_{j=1}^{n-1}\\left(  -1\\right)\r\n^{j-1}\\lambda^{n-j}\\left(  x\\right)  N_{j}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\left(  -1\\right)  ^{n-1}\\underbrace{1}_{=\\lambda\r\n^{0}\\left(  x\\right)  =\\lambda^{n-n}\\left(  x\\right)  }N_{n}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{n}\\left(  x\\right)  \\right) \\\\\r\n&  =\\sum_{j=1}^{n-1}\\left(  -1\\right)  ^{j-1}\\lambda^{n-j}\\left(  x\\right)\r\nN_{j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\left(  -1\\right)  ^{n-1}\\lambda^{n-n}\\left(\r\nx\\right)  N_{n}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(\r\nx\\right)  ,...,\\lambda^{n}\\left(  x\\right)  \\right) \\\\\r\n&  =\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\lambda^{n-j}\\left(  x\\right)\r\n\\underbrace{N_{j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(\r\nx\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)  }_{=\\psi^{j}\\left(\r\nx\\right)  }\\\\\r\n&  =\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\lambda^{n-j}\\left(  x\\right)\r\n\\psi^{j}\\left(  x\\right)  .\r\n\\end{align*}\r\nThis proves the 2nd step.\r\n\r\n\\textit{3rd step:} For any $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any $x\\in K$, we have%\r\n\\[\r\n-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  =\\lambda_{T}\\left(  x\\right)\r\n\\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)  ,\r\n\\]\r\nwhere we denote the power series $\\operatorname*{ev}\\nolimits_{-T}\\left(\r\n\\widetilde{\\psi}_{T}\\left(  x\\right)  \\right)  $ by $\\widetilde{\\psi}%\r\n_{-T}\\left(  x\\right)  $.\r\n\r\n\\textit{Proof.} We have\r\n\\begin{align*}\r\n\\widetilde{\\psi}_{-T}\\left(  x\\right)   &  =\\operatorname*{ev}\\nolimits_{-T}%\r\n\\left(  \\widetilde{\\psi}_{T}\\left(  x\\right)  \\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\widetilde{\\psi}_{T}\\left(  x\\right)\r\n=\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  T^{j}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  \\underbrace{\\left(  -T\\right)  ^{j}}_{=\\left(  -1\\right)  ^{j}T^{j}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\operatorname*{ev}%\r\n\\nolimits_{-T}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  \\underbrace{\\left(  -1\\right)  ^{j}}_{=-\\left(  -1\\right)  ^{j-1}%\r\n}T^{j}=-\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi\r\n^{j}\\left(  x\\right)  \\left(  -1\\right)  ^{j-1}T^{j},\r\n\\end{align*}\r\nso that%\r\n\\[\r\n-\\widetilde{\\psi}_{-T}\\left(  x\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  \\left(  -1\\right)\r\n^{j-1}T^{j}.\r\n\\]\r\nMultiplying this formula with the equality $\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}$, we obtain%\r\n\\begin{align*}\r\n\\left(  -\\widetilde{\\psi}_{-T}\\left(  x\\right)  \\right)  \\cdot\\lambda\r\n_{T}\\left(  x\\right)   &  =\\left(  \\sum\\limits_{j\\in\\mathbb{N}\\setminus\r\n\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  \\left(  -1\\right)  ^{j-1}%\r\nT^{j}\\right)  \\cdot\\left(  \\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}\\right) \\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}\\left(  \\sum_{j=1}^{n}\\psi^{j}\\left(  x\\right)\r\n\\left(  -1\\right)  ^{j-1}\\lambda^{n-j}\\left(  x\\right)  \\right)  T^{n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\npower series}\\right) \\\\\r\n&  =\\sum_{n\\in\\mathbb{N}}\\underbrace{\\left(  \\sum_{j=1}^{n}\\left(  -1\\right)\r\n^{j-1}\\lambda^{n-j}\\left(  x\\right)  \\psi^{j}\\left(  x\\right)  \\right)\r\n}_{\\substack{=n\\lambda^{n}\\left(  x\\right)  \\\\\\text{(by the 2nd step)}}%\r\n}T^{n}=\\sum_{n\\in\\mathbb{N}}n\\lambda^{n}\\left(  x\\right)  T^{n}\\\\\r\n&  =\\sum_{n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }n\\lambda^{n}\\left(\r\nx\\right)  T^{n}+\\underbrace{0\\lambda^{0}\\left(  x\\right)  T^{0}}_{=0}%\r\n=\\sum_{n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }n\\lambda^{n}\\left(\r\nx\\right)  \\underbrace{T^{n}}_{=TT^{n-1}}\\\\\r\n&  =T\\cdot\\sum_{n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }n\\lambda\r\n^{n}\\left(  x\\right)  T^{n-1}.\r\n\\end{align*}\r\nNow, $\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  x\\right)  T^{i}=\\sum\\limits_{n\\in\\mathbb{N}}\\lambda^{n}\\left(\r\nx\\right)  T^{n}$, so that%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)   &  =\\dfrac{d}{dT}\\sum\r\n\\limits_{n\\in\\mathbb{N}}\\lambda^{n}\\left(  x\\right)  T^{n}=\\sum_{n\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }n\\lambda^{n}\\left(  x\\right)\r\nT^{n-1}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the derivative of a\r\nformal power series}\\right)  ,\r\n\\end{align*}\r\nand thus%\r\n\\begin{align*}\r\n-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)   &  =-\\underbrace{T\\cdot\r\n\\sum_{n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }n\\lambda^{n}\\left(\r\nx\\right)  T^{n-1}}_{=\\left(  -\\widetilde{\\psi}_{-T}\\left(  x\\right)  \\right)\r\n\\cdot\\lambda_{T}\\left(  x\\right)  }=-\\left(  -\\widetilde{\\psi}_{-T}\\left(\r\nx\\right)  \\right)  \\cdot\\lambda_{T}\\left(  x\\right) \\\\\r\n&  =\\lambda_{T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)  .\r\n\\end{align*}\r\nThis proves the 3rd step.\r\n\r\n\\textit{4th step:} For any fixed $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any fixed $x\\in K$, the assertion\r\n\\textbf{(b)} holds.\r\n\r\n\\textit{Proof.} By the 3rd step, we have\r\n\\[\r\n-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  =\\lambda_{T}\\left(  x\\right)\r\n\\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)  .\r\n\\]\r\n\r\n\r\nNow, every formal power series $\\alpha\\in K\\left[  \\left[  T\\right]  \\right]\r\n$ satisfies $\\operatorname*{ev}\\nolimits_{-T}\\left(  \\dfrac{d}{dT}%\r\n\\alpha\\right)  =-\\dfrac{d}{dT}\\left(  \\operatorname*{ev}\\nolimits_{-T}%\r\n\\alpha\\right)  $.\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $\\alpha\\in K\\left[\r\n\\left[  T\\right]  \\right]  $ be a formal power series. Write $\\alpha$ in the\r\nform $\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}T^{i}$ with $\\alpha_{i}\\in K$ for\r\nevery $i\\in\\mathbb{N}$. Then, $\\operatorname*{ev}\\nolimits_{-T}\\alpha\r\n=\\operatorname*{ev}\\nolimits_{-T}\\left(  \\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\alpha_{i}T^{i}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}\\left(\r\n-1\\right)  ^{i}T^{i}$ (by the definition of $\\operatorname*{ev}\\nolimits_{-T}%\r\n$), so that%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\left(  \\operatorname*{ev}\\nolimits_{-T}\\alpha\\right)   &\r\n=\\dfrac{d}{dT}\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}\\left(  -1\\right)\r\n^{i}T^{i}=\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\alpha\r\n_{i}\\left(  -1\\right)  ^{i}iT^{i-1}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the derivative of a\r\nformal power series}\\right)  .\r\n\\end{align*}\r\n\\par\r\nOn the other hand, $\\alpha=\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}T^{i}$, so\r\nthat%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}\\alpha &  =\\dfrac{d}{dT}\\sum\\limits_{i\\in\\mathbb{N}}\\alpha\r\n_{i}T^{i}=\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\alpha\r\n_{i}iT^{i-1}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the derivative of a\r\nformal power series}\\right) \\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i+1}\\left(  i+1\\right)  T^{i}%\r\n\\end{align*}\r\n(here we substituted $i$ for $i-1$). Thus,%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{-T}\\left(  \\dfrac{d}{dT}\\alpha\\right)   &\r\n=\\operatorname*{ev}\\nolimits_{-T}\\left(  \\sum\\limits_{i\\in\\mathbb{N}}%\r\n\\alpha_{i+1}\\left(  i+1\\right)  T^{i}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\alpha_{i+1}\\left(  i+1\\right)  \\left(  -1\\right)  ^{i}T^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\operatorname*{ev}%\r\n\\nolimits_{-T}\\right) \\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\alpha\r\n_{i}i\\underbrace{\\left(  -1\\right)  ^{i-1}}_{=-\\left(  -1\\right)  ^{i}}%\r\nT^{i-1}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we substituted }i\\text{ for\r\n}i+1\\right) \\\\\r\n&  =-\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\alpha\r\n_{i}\\underbrace{i\\left(  -1\\right)  ^{i}}_{=\\left(  -1\\right)  ^{i}i}%\r\nT^{i-1}=-\\underbrace{\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n}\\alpha_{i}\\left(  -1\\right)  ^{i}iT^{i-1}}_{=\\dfrac{d}{dT}\\left(\r\n\\operatorname*{ev}\\nolimits_{-T}\\alpha\\right)  }=-\\dfrac{d}{dT}\\left(\r\n\\operatorname*{ev}\\nolimits_{-T}\\alpha\\right)  ,\r\n\\end{align*}\r\nqed.} Applied to $\\alpha=\\lambda_{T}\\left(  x\\right)  $, this yields\r\n$\\operatorname*{ev}\\nolimits_{-T}\\left(  \\dfrac{d}{dT}\\lambda_{T}\\left(\r\nx\\right)  \\right)  =-\\dfrac{d}{dT}\\left(  \\operatorname*{ev}\\nolimits_{-T}%\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  $. Since\r\n$\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n=\\lambda_{-T}\\left(  x\\right)  $, this rewrites as $\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  \\right)\r\n=-\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  $. On the other hand, every\r\nformal power series $\\alpha\\in K\\left[  \\left[  T\\right]  \\right]  $ satisfies\r\n$\\operatorname*{ev}\\nolimits_{-T}\\left(  \\operatorname*{ev}\\nolimits_{-T}%\r\n\\alpha\\right)  =\\alpha$.\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $\\alpha\\in\r\nK\\left[  \\left[  T\\right]  \\right]  $ be a formal power series. Write $\\alpha$\r\nin the form $\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}T^{i}$ with $\\alpha_{i}\\in\r\nK$ for every $i\\in\\mathbb{N}$. Then, $\\operatorname*{ev}\\nolimits_{-T}%\r\n\\alpha=\\operatorname*{ev}\\nolimits_{-T}\\left(  \\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\alpha_{i}T^{i}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}\\left(\r\n-1\\right)  ^{i}T^{i}$ (by the definition of $\\operatorname*{ev}\\nolimits_{-T}%\r\n$), so that%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{-T}\\left(  \\operatorname*{ev}\\nolimits_{-T}%\r\n\\alpha\\right)   &  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\sum\r\n\\limits_{i\\in\\mathbb{N}}\\alpha_{i}\\left(  -1\\right)  ^{i}T^{i}\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}\\underbrace{\\left(  -1\\right)\r\n^{i}\\left(  -1\\right)  ^{i}}_{=1}T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the\r\ndefinition of }\\operatorname*{ev}\\nolimits_{-T}\\right) \\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\alpha_{i}T^{i}=\\alpha,\r\n\\end{align*}\r\nqed.} Applied to $\\alpha=\\widetilde{\\psi}_{T}\\left(  x\\right)  $, this yields\r\n$\\operatorname*{ev}\\nolimits_{-T}\\left(  \\operatorname*{ev}\\nolimits_{-T}%\r\n\\left(  \\widetilde{\\psi}_{T}\\left(  x\\right)  \\right)  \\right)\r\n=\\widetilde{\\psi}_{T}\\left(  x\\right)  $. Since $\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\widetilde{\\psi}_{T}\\left(  x\\right)  \\right)\r\n=\\widetilde{\\psi}_{-T}\\left(  x\\right)  $, this becomes $\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\widetilde{\\psi}_{-T}\\left(  x\\right)  \\right)\r\n=\\widetilde{\\psi}_{T}\\left(  x\\right)  $.\r\n\r\nNow,%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{-T}\\left(  -T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(\r\nx\\right)  \\right)   &  =-\\underbrace{\\operatorname*{ev}\\nolimits_{-T}\\left(\r\nT\\right)  }_{=-T}\\cdot\\underbrace{\\operatorname*{ev}\\nolimits_{-T}\\left(\r\n\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  \\right)  }_{=-\\dfrac{d}{dT}%\r\n\\lambda_{-T}\\left(  x\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{ev}\\nolimits_{-T}%\r\n\\text{ is a }K\\text{-algebra homomorphism}\\right) \\\\\r\n&  =-T\\cdot\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)\r\n\\end{align*}\r\nand%\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)  \\right)   &\r\n=\\underbrace{\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  }_{=\\lambda_{-T}\\left(  x\\right)  }\\cdot\r\n\\underbrace{\\operatorname*{ev}\\nolimits_{-T}\\left(  \\widetilde{\\psi}%\r\n_{-T}\\left(  x\\right)  \\right)  }_{=\\widetilde{\\psi}_{T}\\left(  x\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{ev}\\nolimits_{-T}%\r\n\\text{ is a }K\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\lambda_{-T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{T}\\left(  x\\right)  .\r\n\\end{align*}\r\nHence,%\r\n\\[\r\n-T\\cdot\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\underbrace{-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(\r\nx\\right)  }_{=\\lambda_{T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{-T}\\left(\r\nx\\right)  }\\right)  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda\r\n_{T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)  \\right)\r\n=\\lambda_{-T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{T}\\left(  x\\right)  ,\r\n\\]\r\nso that%\r\n\\[\r\n\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\dfrac{-T\\cdot\\dfrac{d}{dT}\\lambda\r\n_{-T}\\left(  x\\right)  }{\\lambda_{-T}\\left(  x\\right)  }=-T\\cdot\r\n\\underbrace{\\dfrac{\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  }{\\lambda\r\n_{-T}\\left(  x\\right)  }}_{=\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)\r\n}=-T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)  .\r\n\\]\r\nHence, assertion \\textbf{(b)} holds. This completes the proof of the 4th step.\r\n\r\n\\textit{5th step:} For any fixed $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and any fixed $x\\in K$, the assertion\r\n\\textbf{(a)} holds.\r\n\r\n\\textit{Proof.} This follows from the 4th step, since \\textbf{(a)} and\r\n\\textbf{(b)} are equivalent (by the 1st step).\r\n\r\nThus, the proof of Theorem 9.5 is complete.\r\n\\end{proof}\r\n\r\nTheorem 9.5 is clearly a generalization of Theorem 9.2, and thus our above\r\nproof of Theorem 9.5 is, at the same time, a new proof of Theorem 9.2.\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 9.1.} Let $K$ be a ring. Let $u\\in1+K\\left[  T\\right]  ^{+}$.\r\nFor every $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, let us denote by\r\n$\\widehat{\\psi}^{j}$ the $j$-th Adams operation of the $\\lambda$-ring $\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $.\r\n\r\nAssume that $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}%\r\n\\right]  \\right)  $ for some $\\left(  \\widetilde{K}_{u},\\left[  u_{1}%\r\n,u_{2},...,u_{m}\\right]  \\right)  \\in K^{\\operatorname*{int}}$. Let\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. Then, $\\widehat{\\psi}%\r\n^{j}\\left(  u\\right)  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1}^{j}%\r\n,u_{2}^{j},...,u_{m}^{j}\\right]  \\right)  $.\r\n\r\n[This gives a formula for $\\widehat{\\psi}^{j}$ similar to the formula for\r\n$\\widehat{\\lambda}^{j}$ given in Theorem 5.3 \\textbf{(d)}.]\r\n\r\n\\textit{Exercise 9.2.} Let $K$ be a ring. For each $i\\in\\mathbb{N}$, define a\r\nmapping $\\operatorname*{Coeff}\\nolimits_{i}:K\\left[  \\left[  T\\right]\r\n\\right]  \\rightarrow K$ as in Exercise 6.8.\r\n\r\nLet $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $.\r\n\r\n\\textbf{(a)} Prove that the map%\r\n\\begin{align*}\r\n\\Lambda\\left(  K\\right)   &  \\rightarrow K,\\\\\r\nu  &  \\mapsto\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log u\\right)\r\n\\end{align*}\r\nis a ring homomorphism.\r\n\r\n\\textbf{(b)} This fact, combined with Theorem 9.2 \\textbf{(b)}, can be used to\r\ngive a new proof of a part of Theorem 9.3 \\textbf{(b)}. Which part, and how?\r\n\r\n\\textit{Exercise 9.3.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring.\r\n\r\n\\textbf{(a)} Prove that%\r\n\\[\r\nn\\lambda^{n}\\left(  x\\right)  =\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}%\r\n\\lambda^{n-i}\\left(  x\\right)  \\psi^{i}\\left(  x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\text{ and }n\\in\\mathbb{N}\\text{.}%\r\n\\]\r\n\r\n\r\n\\textbf{(b)} Let $x\\in K$ and $n\\in\\mathbb{N}$. Let $A_{n}=\\left(\r\na_{i,j}\\right)  _{1\\leq i\\leq n,\\ 1\\leq j\\leq n}\\in K^{n\\times n}$ be the\r\nmatrix defined by%\r\n\\[\r\na_{i,j}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\psi^{i-j+1}\\left(  x\\right)  ,\\text{ if }i\\geq j;\\\\\r\ni,\\text{ if }i=j-1;\\\\\r\n0,\\text{ if }i<j-1\r\n\\end{array}\r\n\\right.  .\r\n\\]\r\nProve that $n!\\lambda^{n}\\left(  x\\right)  =\\det A_{n}$.\r\n\r\n[The matrix $A_{n}$ has the following form:%\r\n\\[\r\nA_{n}=\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\n\\psi^{1}\\left(  x\\right)  & 1 & 0 & \\cdots & 0 & 0\\\\\r\n\\psi^{2}\\left(  x\\right)  & \\psi^{1}\\left(  x\\right)  & 2 & \\cdots & 0 & 0\\\\\r\n\\psi^{3}\\left(  x\\right)  & \\psi^{2}\\left(  x\\right)  & \\psi^{1}\\left(\r\nx\\right)  & \\cdots & 0 & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots\\\\\r\n\\psi^{n-1}\\left(  x\\right)  & \\psi^{n-2}\\left(  x\\right)  & \\psi^{n-3}\\left(\r\nx\\right)  & \\cdots & \\psi^{1}\\left(  x\\right)  & n-1\\\\\r\n\\psi^{n}\\left(  x\\right)  & \\psi^{n-1}\\left(  x\\right)  & \\psi^{n-2}\\left(\r\nx\\right)  & \\cdots & \\psi^{2}\\left(  x\\right)  & \\psi^{1}\\left(  x\\right)\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n]\r\n\r\n\\textbf{(c)} Let $x\\in K$ and $n\\in\\mathbb{N}$. Let $B_{n}=\\left(\r\nb_{i,j}\\right)  _{1\\leq i\\leq n,\\ 1\\leq j\\leq n}\\in K^{n\\times n}$ be the\r\nmatrix defined by%\r\n\\[\r\nb_{i,j}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\ni\\lambda^{i}\\left(  x\\right)  ,\\text{ if }j=1;\\\\\r\n\\lambda^{i-j+1}\\left(  x\\right)  ,\\text{ if }i\\geq j>1;\\\\\r\n1,\\text{ if }i=j-1;\\\\\r\n0,\\text{ if }i<j-1\r\n\\end{array}\r\n\\right.  .\r\n\\]\r\nProve that $\\psi^{n}\\left(  x\\right)  =\\det B_{n}$, where we define $\\psi\r\n^{0}\\left(  x\\right)  $ to mean $1$.\r\n\r\n[The matrix $B_{n}$ has the following form:%\r\n\\[\r\nB_{n}=\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\n\\lambda^{1}\\left(  x\\right)  & 1 & 0 & \\cdots & 0 & 0\\\\\r\n2\\lambda^{2}\\left(  x\\right)  & \\lambda^{1}\\left(  x\\right)  & 1 & \\cdots &\r\n0 & 0\\\\\r\n3\\lambda^{3}\\left(  x\\right)  & \\lambda^{2}\\left(  x\\right)  & \\lambda\r\n^{1}\\left(  x\\right)  & \\cdots & 0 & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots\\\\\r\n\\left(  n-1\\right)  \\lambda^{n-1}\\left(  x\\right)  & \\lambda^{n-2}\\left(\r\nx\\right)  & \\lambda^{n-3}\\left(  x\\right)  & \\cdots & \\lambda^{1}\\left(\r\nx\\right)  & 1\\\\\r\nn\\lambda^{n}\\left(  x\\right)  & \\lambda^{n-1}\\left(  x\\right)  & \\lambda\r\n^{n-2}\\left(  x\\right)  & \\cdots & \\lambda^{2}\\left(  x\\right)  & \\lambda\r\n^{1}\\left(  x\\right)\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n]\r\n\r\n\\textit{Exercise 9.4.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a binomial $\\lambda$-ring. Prove that $\\psi\r\n^{n}=\\operatorname*{id}$ for every $n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n$.\r\n\r\n[Note that, if we recall the definition of a binomial $\\lambda$-ring and\r\nExercise 9.3 \\textbf{(c)}, then we could reformulate this result without\r\nreference to $\\lambda$-rings.]\r\n\r\n\\textit{Exercise 9.5.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a (not necessarily special) $\\lambda$-ring.\r\nProve that $\\psi^{j}:K\\rightarrow K$ is a homomorphism of additive groups for\r\nevery $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $.\r\n\r\n[This shows that at least part of Theorem 9.3 \\textbf{(b)} does not require\r\nthe $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ to be special.]\r\n\r\n\\textit{Exercise 9.6.} In this exercise, we are going to view $\\mathbb{Z}%\r\n\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ as a subring of\r\n$\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right]  $ for any two\r\n$m\\in\\mathbb{N}$ and $n\\in\\mathbb{N}$ satisfying $m\\leq n$. Thus, the\r\npolynomial $N_{m}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{m}\\right]  $ automatically becomes an element of $\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right]  $ whenever $1\\leq m\\leq n$.\r\n\r\n\\textbf{(a)} Prove that\r\n\\[\r\nn\\alpha_{n}=\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\alpha_{n-i}N_{i}\\text{ in\r\n}\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{n}\\right]\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}\\text{.}%\r\n\\]\r\nHere, $\\alpha_{0}$ is to be understood as $1$.\r\n\r\n\\textbf{(b)} Let $n\\in\\mathbb{N}$. Let $A_{n}=\\left(  a_{i,j}\\right)  _{1\\leq\r\ni\\leq n,\\ 1\\leq j\\leq n}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{n}\\right]  ^{n\\times n}$ be the matrix defined by%\r\n\\[\r\na_{i,j}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nN_{i-j+1},\\text{ if }i\\geq j;\\\\\r\ni,\\text{ if }i=j-1;\\\\\r\n0,\\text{ if }i<j-1\r\n\\end{array}\r\n\\right.  .\r\n\\]\r\nProve that $n!\\alpha_{n}=\\det A_{n}$.\r\n\r\n[The matrix $A_{n}$ has the following form:%\r\n\\[\r\nA_{n}=\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\nN_{1} & 1 & 0 & \\cdots & 0 & 0\\\\\r\nN_{2} & N_{1} & 2 & \\cdots & 0 & 0\\\\\r\nN_{3} & N_{2} & N_{1} & \\cdots & 0 & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots\\\\\r\nN_{n-1} & N_{n-2} & N_{n-3} & \\cdots & N_{1} & n-1\\\\\r\nN_{n} & N_{n-1} & N_{n-2} & \\cdots & N_{2} & N_{1}%\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n]\r\n\r\n\\textbf{(c)} Let $n\\in\\mathbb{N}$. Let $B_{n}=\\left(  b_{i,j}\\right)  _{1\\leq\r\ni\\leq n,\\ 1\\leq j\\leq n}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{n}\\right]  ^{n\\times n}$ be the matrix defined by%\r\n\\[\r\nb_{i,j}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\ni\\alpha_{i},\\text{ if }j=1;\\\\\r\n\\alpha_{i-j+1},\\text{ if }i\\geq j>1;\\\\\r\n1,\\text{ if }i=j-1;\\\\\r\n0,\\text{ if }i<j-1\r\n\\end{array}\r\n\\right.  .\r\n\\]\r\nProve that $N_{n}=\\det B_{n}$, where we define $N_{0}$ to mean $1$.\r\n\r\n[The matrix $B_{n}$ has the following form:%\r\n\\[\r\nB_{n}=\\left(\r\n\\begin{array}\r\n[c]{cccccc}%\r\n\\alpha_{1} & 1 & 0 & \\cdots & 0 & 0\\\\\r\n2\\alpha_{2} & \\alpha_{1} & 1 & \\cdots & 0 & 0\\\\\r\n3\\alpha_{3} & \\alpha_{2} & \\alpha_{1} & \\cdots & 0 & 0\\\\\r\n\\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots\\\\\r\n\\left(  n-1\\right)  \\alpha_{n-1} & \\alpha_{n-2} & \\alpha_{n-3} & \\cdots &\r\n\\alpha_{1} & 1\\\\\r\nn\\alpha_{n} & \\alpha_{n-1} & \\alpha_{n-2} & \\cdots & \\alpha_{2} & \\alpha_{1}%\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n]\r\n\r\n\\textbf{(d)} Derive the results of Exercise 9.3 from Exercise 9.6\r\n\\textbf{(a)}, \\textbf{(b)}, \\textbf{(c)}.\r\n\r\n\\textit{Exercise 9.7.} Let $p$ be a prime number. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a (not necessarily special)\r\n$\\lambda$-ring. Prove that $\\psi^{p}\\left(  x\\right)  \\equiv x^{p}%\r\n\\operatorname{mod}pK$ for every $x\\in K$.\r\n\r\n\\bigskip\r\n\\end{quotation}\r\n\r\n\\section{Todd homomorphisms of power series}\r\n\r\nWe now devote a section to the notion of Todd homomorphisms. First, two warnings:\r\n\r\n\\begin{itemize}\r\n\\item \\textbf{Warning:} The following may be wrong or differ from the standard\r\nnotations. I am trying to generalize \\cite[I \\S 6]{FulLan85} (mostly because\r\nit is slightly flawed\\footnote{\\cite[I \\S 6, p. 24]{FulLan85} states that\r\n$\\operatorname*{td}_{\\varphi}\\left(  e\\right)  $ is a universal polynomial in\r\n$\\lambda^{1}\\left(  e\\right)  $, $...$, $\\lambda^{r}\\left(  e\\right)  $,\r\ndetermined by $\\varphi$ alone. I think it isn't; instead, it is just a power\r\nseries. On the other hand, my generalization $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}$ is a universal polynomial.} and the generalization\r\nlooks more natural to me), but I cannot guarantee that this is the ``right'' generalization.\r\n\r\n\\item \\textbf{Another warning:} In the following, we will often formulate\r\nresults over a ring which we will call $\\mathbf{Z}$. The letter $\\mathbf{Z}$\r\nwill denote any ring (commutative with unity, of course). Please don't confuse\r\nit with the similarly-looking letter $\\mathbb{Z}$, which always denote the\r\nring of integers. The reason why I chose the letter $\\mathbf{Z}$ for the ring\r\nis that in most applications the ring $\\mathbf{Z}$ will indeed be the ring\r\n$\\mathbb{Z}$ of integers.\r\n\\end{itemize}\r\n\r\n\\subsection{The universal polynomials $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}$}\r\n\r\nWe begin this section with a construction similar to the construction of the\r\nAdams operations in Section 9. The goal of this construction is to find, for\r\nevery ring $\\mathbf{Z}$ (in most cases, this ring will be the ring\r\n$\\mathbb{Z}$ of integers) and every power series $\\varphi\\in1+\\mathbf{Z}%\r\n\\left[  \\left[  t\\right]  \\right]  ^{+}$ with constant term equal to $1$, a\r\npolynomial $\\operatorname*{Td}_{\\varphi,j}\\in\\mathbf{Z}\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ for every $j\\in\\mathbb{N}$ such that\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\nT^{j}%\r\n\\]\r\nin the ring $\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)\r\n\\left[  \\left[  T\\right]  \\right]  $ for every $m\\in\\mathbb{N}$, where\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ as usual. To\r\nachieve this goal, we must again work with symmetric polynomials. First a definition:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $R$ be any ring. Let $i\\in\\mathbb{N}$. Then, we\r\ndefine a map $\\operatorname*{Coeff}\\nolimits_{i}:R\\left[  \\left[  T\\right]\r\n\\right]  \\rightarrow R$ (where $R\\left[  \\left[  T\\right]  \\right]  $ is, as\r\nalways, the $R$-algebra of all formal power series in the variable $T$ over\r\nthe ring $R$) by%\r\n\\[\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\operatorname*{Coeff}\\nolimits_{i}\\left(  P\\right)  =\\left(  \\text{the\r\ncoefficient of }P\\text{ before }T^{i}\\right) \\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every power series }P\\in R\\left[  \\left[\r\nT\\right]  \\right]\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n\r\n\r\nIn other words, we define a map $\\operatorname*{Coeff}\\nolimits_{i}:R\\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow R$ by%\r\n\\[\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\operatorname*{Coeff}\\nolimits_{i}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}%\r\na_{j}T^{j}\\right)  =a_{i}\\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\sum\\limits_{j\\in\\mathbb{N}}a_{j}T^{j}\\in\r\nR\\left[  \\left[  T\\right]  \\right]  \\text{ (with }a_{j}\\in R\\text{ for every\r\n}j\\in\\mathbb{N}\\text{)}%\r\n\\end{array}\r\n\\right)  .\r\n\\]\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\nTwo remarks about this definition:\r\n\r\n\\begin{itemize}\r\n\\item The definition of $\\operatorname*{Coeff}\\nolimits_{i}$ that we just gave\r\nis clearly equivalent to the definition of $\\operatorname*{Coeff}%\r\n\\nolimits_{i}$ given in Exercise 9.2.\r\n\r\n\\item The only difference between the map $\\operatorname*{Coeff}\\nolimits_{i}$\r\njust defined and the map $\\operatorname*{coeff}\\nolimits_{i}$ defined in\r\nExercise 6.5 is that they have different domains (namely, the map\r\n$\\operatorname*{Coeff}\\nolimits_{i}$ is defined on all of $R\\left[  \\left[\r\nT\\right]  \\right]  $, whereas the map $\\operatorname*{coeff}\\nolimits_{i}$ is\r\ndefined only on $\\Lambda\\left(  R\\right)  $). This looks like a minor\r\ndifference, but is substantial enough to cause confusion if we neglect it! For\r\nexample, when we say that $\\operatorname*{coeff}\\nolimits_{i}$ is a\r\nhomomorphism of additive groups, we mean that it maps sums in $\\Lambda\\left(\r\nR\\right)  $ to sums in $R$; however, when we say that $\\operatorname*{Coeff}%\r\n\\nolimits_{i}$ is a homomorphism of additive groups, we mean that it maps sums\r\nin $R\\left[  \\left[  T\\right]  \\right]  $ to sums in $R$. These are two\r\ncompletely different assertions, even though $\\Lambda\\left(  R\\right)  $ is a\r\nsubset of $R\\left[  \\left[  T\\right]  \\right]  $ and the maps\r\n$\\operatorname*{coeff}\\nolimits_{i}$ and $\\operatorname*{Coeff}\\nolimits_{i}$\r\nare pointwise equal on this subset! (Actually, it is very easy to see that the\r\nassertion that $\\operatorname*{coeff}\\nolimits_{i}$ is a homomorphism of\r\nadditive groups is completely different from the assertion that\r\n$\\operatorname*{Coeff}\\nolimits_{i}$ is a homomorphism of additive groups. The\r\nlatter assertion holds for all $i\\in\\mathbb{N}$, whereas the former assertion\r\nholds only for $i=1$ (in general).)\r\n\r\n\\item It is clear that for every ring $R$ and for every $i\\in\\mathbb{N}$, the\r\nmap $\\operatorname*{Coeff}\\nolimits_{i}:R\\left[  \\left[  T\\right]  \\right]\r\n\\rightarrow R$ is an additive group homomorphism. It is also clear that if two\r\npower series $P\\in R\\left[  \\left[  T\\right]  \\right]  $ and $Q\\in R\\left[\r\n\\left[  T\\right]  \\right]  $ satisfy $\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{i}\\left(  P\\right)  =\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\nQ\\right)  \\text{ for all }i\\in\\mathbb{N}\\right)  $, then $P=Q$.\r\n\\end{itemize}\r\n\r\nNow let us define what we mean by $1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\mathbf{Z}$ be a ring. Consider the ring\r\n$\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $ of formal power series in the\r\nvariable $t$ over $\\mathbf{Z}$. Let $\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ denote the subset%\r\n\\begin{align*}\r\nt\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]   &  =\\left\\{  \\sum\r\n_{i\\in\\mathbb{N}}a_{i}t^{i}\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]\r\n\\ \\mid\\ a_{i}\\in\\mathbf{Z}\\text{ for all }i,\\text{ and }a_{0}=0\\right\\} \\\\\r\n&  =\\left\\{  p\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  \\ \\mid\\ p\\text{\r\nis a power series with constant term }0\\right\\}\r\n\\end{align*}\r\nof the ring $\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $. Note that\r\n\\begin{align*}\r\n1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}  &  =\\left\\{  1+u\\mid\r\nu\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}\\right\\} \\\\\r\n&  =\\left\\{  p\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  \\ \\mid\\ p\\text{\r\nis a power series with constant term }1\\right\\}  .\r\n\\end{align*}\r\n\r\n\\end{quote}\r\n\r\nWe notice that this is an exact copy of a definition we made in Section 5\r\n(namely, of the definition of $K\\left[  \\left[  T\\right]  \\right]  ^{+}$),\r\nwith the only difference that the ring that used to be called $K$ in Section 5\r\nis called $\\mathbf{Z}$ here, and that the variable that used to be $T$ in\r\nSection 5 is $t$ here.\r\n\r\nNow to our universal polynomials:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\\in\r\n1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$. Our goal is to define a polynomial\r\n$\\operatorname*{Td}_{\\varphi,j}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  $ for every $j\\in\\mathbb{N}$ such that%\r\n\\begin{equation}\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\nT^{j} \\label{Td1}%\r\n\\end{equation}\r\nin the ring $\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)\r\n\\left[  \\left[  T\\right]  \\right]  $ for every $m\\in\\mathbb{N}$, where\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ is the $i$-th\r\nelementary symmetric polynomial in the variables $U_{1}$, $U_{2}$, $...$,\r\n$U_{m}$ for every $i\\in\\mathbb{N}$.\r\n\r\nIn order to do this, we first fix some $m\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$.\r\nConsider the polynomial $\\operatorname*{Coeff}\\nolimits_{j}\\left(\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  \\in\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (this is the coefficient of\r\nthe power series $\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)\r\n\\in\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[\r\n\\left[  T\\right]  \\right]  $ before $T^{j}$). This polynomial\r\n$\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  $ is symmetric. Thus, Theorem 4.1\r\n\\textbf{(a)} yields that there exists one and only one polynomial\r\n$\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  }\\in\\mathbf{Z}%\r\n\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ such that\r\n$\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  =\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  }\\left(  X_{1},X_{2},...,X_{m}\\right)  $. Since\r\n$\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  $ is a polynomial of total degree $\\leq\r\nj$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}\\ \\ \\ \\ $%\r\n\\footnote{\\textit{Proof.} There are several ways to prove this; here is the\r\nsimplest one: We use the notion of an ``equigraded'' power series over a\r\ngraded ring; this notion was defined in \\cite{Grin-w4a}. Now let $A$ be the\r\ngraded ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $, where the\r\ngrading is given by the total degree (thus $U_{1}$, $U_{2}$, $...$, $U_{m}$\r\nall lie in the $1$-st graded component $A_{1}$). According to \\cite[Theorem 1\r\n\\textbf{(a)}]{Grin-w4a}, the set%\r\n\\[\r\n\\left\\{  \\alpha\\in A\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ \\text{the power\r\nseries }\\alpha\\text{ is equigraded}\\right\\}\r\n\\]\r\nis a sub-$A_{0}$-algebra of $A\\left[  \\left[  T\\right]  \\right]  $. Since the\r\npower series $\\varphi\\left(  U_{1}T\\right)  $, $\\varphi\\left(  U_{2}T\\right)\r\n$, $...$, $\\varphi\\left(  U_{m}T\\right)  $ all lie in this set (because they\r\nare equigraded - just look at them), it therefore follows that $\\prod\r\n\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  $ also lies in this set. In\r\nother words, the power series $\\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  $ is equigraded. Hence, the coefficient of the power series\r\n$\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  $ before $T^{j}$ lies in\r\nthe $j$-th graded component of $A$ (by the definition of ``equigraded''). In\r\nother words, the coefficient of the power series $\\prod\\limits_{i=1}%\r\n^{m}\\varphi\\left(  U_{i}T\\right)  $ before $T^{j}$ is a homogeneous polynomial\r\nof degree $j$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$. Since this\r\ncoefficient is $\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}%\r\n^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  $, this yields that\r\n$\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  $ is a homogeneous polynomial of degree\r\n$j$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$. Hence,\r\n$\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  $ is a polynomial of total degree $\\leq\r\nj$ in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$.}, Theorem 4.1\r\n\\textbf{(b)} yields that%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  ,\r\n\\]\r\nwhere $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j}$ is the\r\nimage of the polynomial $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  }$ under the canonical homomorphism $\\mathbf{Z}\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{m}\\right]  \\rightarrow\\mathbf{Z}\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $. However, this polynomial\r\n$\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j}$ is not\r\nindependent of $m$ yet (as the polynomial $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}$ that we intend to construct should be), so we call it\r\n$\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}$ rather than just $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j}$.\r\n\r\nNow we forget that we fixed $m\\in\\mathbb{N}$ (but still fix $j\\in\\mathbb{N}$).\r\nWe have learnt that%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $m\\in\\mathbb{N}$. Now, define a polynomial $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{j}\\right]  $ by $\\operatorname*{Td}\\nolimits_{\\varphi,j}%\r\n=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  j\\right]\r\n}$.\r\n\r\nThis polynomial $\\operatorname*{Td}\\nolimits_{\\varphi,j}$ is called the\r\n$j$\\textit{-th Todd polynomial of }$\\varphi$.\r\n\r\n\\textbf{Theorem 10.1.} The polynomials $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}$ just defined satisfy the equation (\\ref{Td1}) in the ring $\\left(\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $ for every $m\\in\\mathbb{N}$. (Hence, the goal mentioned\r\nabove in the definition is actually achieved.)\r\n\\end{quote}\r\n\r\nBefore we prove this, we need a lemma; it is not really a fact of independent\r\nimportance, but if we don't formulate it as a lemma we will have to run\r\nthrough its proof several times:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 10.2.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\\in\r\n1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$. Let $m\\in\\mathbb{N}$ and $n\\in\\mathbb{N}$ be such\r\nthat $m\\geq n$. Then, in the polynomial ring $\\mathbf{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{n}\\right]  $, we have $\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  n\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 10.2.]By the definition of $\\operatorname*{Todd}%\r\n\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]  }$, we have%\r\n\\begin{equation}\r\n\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\label{10.1.pf.1}%\r\n\\end{equation}\r\nin the polynomial ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\n\r\nLet $\\operatorname*{proj}\\nolimits_{m,n}$ be the canonical $\\mathbf{Z}%\r\n$-algebra epimorphism $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\rightarrow\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{n}\\right]  $ which maps every\r\n$U_{i}$ to $\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq n;\\\\\r\n0,\\text{ if }i>n\r\n\\end{array}\r\n\\right.  $. This $\\mathbf{Z}$-algebra homomorphism $\\operatorname*{proj}%\r\n\\nolimits_{m,n}$ induces a $\\mathbf{Z}$-algebra homomorphism\r\n$\\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]\r\n:\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow\\left(  \\mathbf{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{n}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $ which\r\nmaps every power series $\\sum\\limits_{k\\in\\mathbb{N}}a_{k}T^{k}$ (with\r\n$a_{k}\\in\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for every\r\n$k\\in\\mathbb{N}$) to $\\sum\\limits_{k\\in\\mathbb{N}}\\operatorname*{proj}%\r\n\\nolimits_{m,n}\\left(  a_{k}\\right)  T^{k}$. For every $i\\in\\left\\{\r\n1,2,...,m\\right\\}  $, this homomorphism $\\operatorname*{proj}\\nolimits_{m,n}%\r\n\\left[  \\left[  T\\right]  \\right]  $ satisfies $\\left(  \\operatorname*{proj}%\r\n\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\ \\text{if }i\\leq n;\\\\\r\n1,\\text{\\ if }i>n\r\n\\end{array}\r\n\\right.  \\ \\ \\ \\ $\\footnote{\\textit{Proof.} Write the power series $\\varphi\r\n\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $ in the form $\\varphi\r\n=\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}t^{k}$ with $\\varphi_{k}\\in\\mathbf{Z}$\r\nfor every $k\\in\\mathbb{N}$. Notice that $\\varphi_{0}=1$ since $\\varphi$ has\r\nconstant term $1$.\r\n\\par\r\nLet $i\\in\\left\\{  1,2,...,m\\right\\}  $. Since $\\varphi=\\sum\\limits_{k\\in\r\n\\mathbb{N}}\\varphi_{k}t^{k}$, we have $\\varphi\\left(  U_{i}T\\right)\r\n=\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}\\underbrace{\\left(  U_{i}T\\right)\r\n^{k}}_{=U_{i}^{k}T^{k}}=\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}U_{i}^{k}T^{k}%\r\n$. Thus,\r\n\\begin{align*}\r\n&  \\left(  \\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\left(  U_{i}T\\right)  \\right) \\\\\r\n&  =\\left(  \\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]\r\n\\right]  \\right)  \\left(  \\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}U_{i}%\r\n^{k}T^{k}\\right)  =\\sum\\limits_{k\\in\\mathbb{N}}%\r\n\\underbrace{\\operatorname*{proj}\\nolimits_{m,n}\\left(  \\varphi_{k}U_{i}%\r\n^{k}\\right)  }_{\\substack{=\\varphi_{k}\\left(  \\operatorname*{proj}%\r\n\\nolimits_{m,n}U_{i}\\right)  ^{k}\\\\\\text{(since }\\operatorname*{proj}%\r\n\\nolimits_{m,n}\\text{ is a }\\mathbf{Z}\\text{-algebra}\\\\\\text{homomorphism)}%\r\n}}T^{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]  \\right)\r\n\\\\\r\n&  =\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}\\left(  \\operatorname*{proj}%\r\n\\nolimits_{m,n}U_{i}\\right)  ^{k}T^{k}=\\sum\\limits_{k\\in\\mathbb{N}}\\varphi\r\n_{k}\\left(  \\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq n;\\\\\r\n0,\\text{ if }i>n\r\n\\end{array}\r\n\\right.  \\right)  ^{k}T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{proj}%\r\n\\nolimits_{m,n}U_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq n;\\\\\r\n0,\\text{ if }i>n\r\n\\end{array}\r\n\\right.  \\text{ by the definition of }\\operatorname*{proj}\\nolimits_{m,n}%\r\n\\right) \\\\\r\n&  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}U_{i}^{k}T^{k},\\text{ if }i\\leq n;\\\\\r\n\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}0^{k}T^{k},\\text{ if }i>n\r\n\\end{array}\r\n\\right.  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\text{ if }i\\leq n;\\\\\r\n1,\\text{ if }i>n\r\n\\end{array}\r\n\\right. \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}U_{i}^{k}T^{k}%\r\n=\\varphi\\left(  U_{i}T\\right)  \\text{ for }i\\leq n\\text{, but on the other\r\nhand}\\\\\r\n\\sum\\limits_{k\\in\\mathbb{N}}\\varphi_{k}0^{k}T^{k}=\\underbrace{\\varphi_{0}%\r\n}_{=1}\\underbrace{0^{0}}_{=1}\\underbrace{T^{0}}_{=1}+\\sum\r\n\\limits_{\\substack{k\\in\\mathbb{N};\\\\k\\neq0}}\\varphi_{k}\\underbrace{0^{k}%\r\n}_{\\substack{=0\\\\\\text{(since }k\\neq0\\text{)}}}T^{k}=1+\\underbrace{\\sum\r\n\\limits_{\\substack{k\\in\\mathbb{N};\\\\k\\neq0}}\\varphi_{k}0T^{k}}_{=0}=1\\text{\r\nfor }i>n\r\n\\end{array}\r\n\\right)  ,\r\n\\end{align*}\r\nqed.}. Now, since $\\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[\r\nT\\right]  \\right]  $ is a $\\mathbf{Z}$-algebra homomorphism, we have%\r\n\\begin{align*}\r\n\\left(  \\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)\r\n&  =\\prod\\limits_{i=1}^{m}\\underbrace{\\left(  \\operatorname*{proj}%\r\n\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  }_{=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\ \\text{if }i\\leq n;\\\\\r\n1,\\text{\\ if }i>n\r\n\\end{array}\r\n\\right.  }=\\prod\\limits_{i=1}^{m}\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\ \\text{if }i\\leq n;\\\\\r\n1,\\text{\\ if }i>n\r\n\\end{array}\r\n\\right. \\\\\r\n&  =\\prod\\limits_{i=1}^{n}\\underbrace{\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\ \\text{if }i\\leq n;\\\\\r\n1,\\text{\\ if }i>n\r\n\\end{array}\r\n\\right.  }_{=\\varphi\\left(  U_{i}T\\right)  \\text{ (since }i\\leq n\\text{)}%\r\n}\\cdot\\prod\\limits_{i=n+1}^{m}\\underbrace{\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\varphi\\left(  U_{i}T\\right)  ,\\ \\text{if }i\\leq n;\\\\\r\n1,\\text{\\ if }i>n\r\n\\end{array}\r\n\\right.  }_{=1\\text{ (since }i>n\\text{)}}\\\\\r\n&  =\\prod\\limits_{i=1}^{n}\\varphi\\left(  U_{i}T\\right)  \\cdot\\underbrace{\\prod\r\n\\limits_{i=n+1}^{m}1}_{=1}=\\prod\\limits_{i=1}^{n}\\varphi\\left(  U_{i}T\\right)\r\n.\r\n\\end{align*}\r\nBut the diagram%\r\n\\[\r\n\\xymatrixcolsep{5pc}\\xymatrix{\r\n\\left(\\mathbf Z\\left[U_1,U_2,...,U_m\\right]\\right)\\left[\\left[T\\right]\\right] \\ar[r]^{\\operatorname*{proj}_{m,n}\\left[\\left[T\\right]\\right]} \\ar[d]_{\\operatorname*{Coeff}_j} & \\left(\\mathbf Z\\left[U_1,U_2,...,U_m\\right]\\right)\\left[\\left[T\\right]\\right]  \\ar[d]_{\\operatorname*{Coeff}_j} \\\\\r\n\\mathbf Z\\left[U_1,U_2,...,U_m\\right] \\ar[r]^{\\operatorname*{proj}_{m,n}} & \\mathbf Z\\left[U_1,U_2,...,U_n\\right]\r\n}\r\n\\]\r\nis commutative (this is clear from the definitions of $\\operatorname*{Coeff}%\r\n\\nolimits_{j}$ and $\\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[\r\nT\\right]  \\right]  $), so that $\\operatorname*{proj}\\nolimits_{m,n}%\r\n\\circ\\operatorname*{Coeff}\\nolimits_{j}=\\operatorname*{Coeff}\\nolimits_{j}%\r\n\\circ\\left(  \\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]\r\n\\right]  \\right)  $ and thus%\r\n\\begin{align*}\r\n\\left(  \\operatorname*{proj}\\nolimits_{m,n}\\circ\\operatorname*{Coeff}%\r\n\\nolimits_{j}\\right)  \\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)   &  =\\left(  \\operatorname*{Coeff}\\nolimits_{j}%\r\n\\circ\\left(  \\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]\r\n\\right]  \\right)  \\right)  \\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\underbrace{\\left(\r\n\\operatorname*{proj}\\nolimits_{m,n}\\left[  \\left[  T\\right]  \\right]  \\right)\r\n\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  }%\r\n_{=\\prod\\limits_{i=1}^{n}\\varphi\\left(  U_{i}T\\right)  }\\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{n}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right) \\\\\r\n&  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[\r\nn\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{10.1.pf.1}), applied to }n\\text{\r\ninstead of }m\\right)  .\r\n\\end{align*}\r\nComparing this with%\r\n\\begin{align*}\r\n&  \\left(  \\operatorname*{proj}\\nolimits_{m,n}\\circ\\operatorname*{Coeff}%\r\n\\nolimits_{j}\\right)  \\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right) \\\\\r\n&  =\\operatorname*{proj}\\nolimits_{m,n}\\left(\r\n\\underbrace{\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}%\r\n^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  }_{\\substack{=\\operatorname*{Todd}%\r\n\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  \\\\\\text{(by (\\ref{10.1.pf.1}))}}}\\right)\r\n=\\operatorname*{proj}\\nolimits_{m,n}\\left(  \\operatorname*{Todd}%\r\n\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  \\right) \\\\\r\n&  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[\r\nm\\right]  }\\left(  \\operatorname*{proj}\\nolimits_{m,n}X_{1}%\r\n,\\operatorname*{proj}\\nolimits_{m,n}X_{2},...,\\operatorname*{proj}%\r\n\\nolimits_{m,n}X_{j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  m\\right]  }\\text{ is a polynomial over }\\mathbf{Z}\\\\\r\n\\text{and }\\operatorname*{proj}\\nolimits_{m,n}\\text{ is a }\\mathbf{Z}%\r\n\\text{-algebra homomorphism,}\\\\\r\n\\text{and since polynomials over }\\mathbf{Z}\\text{ commute}\\\\\r\n\\text{with }\\mathbf{Z}\\text{-algebra homomorphisms}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[\r\nm\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\operatorname*{proj}\\nolimits_{m,n}\\text{ is the }\\mathbf{Z}%\r\n\\text{-algebra homomorphism which maps}\\\\\r\n\\text{every }U_{i}\\text{ to }\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nU_{i},\\text{ if }i\\leq n;\\\\\r\n0,\\text{ if }i>n\r\n\\end{array}\r\n\\right.  \\text{,}\\\\\r\n\\text{and thus we know that it maps every }X_{i}\\text{ with }i\\geq1\\text{\r\nto}\\\\\r\n\\text{the corresponding }X_{i}\\text{ of the image ring, so}\\\\\r\n\\text{that }\\operatorname*{proj}\\nolimits_{m,n}X_{1}=X_{1}\\text{,\r\n}\\operatorname*{proj}\\nolimits_{m,n}X_{2}=X_{2}\\text{, }...\\text{,\r\n}\\operatorname*{proj}\\nolimits_{m,n}X_{j}=X_{j}%\r\n\\end{array}\r\n\\right)  ,\r\n\\end{align*}\r\nwe obtain%\r\n\\[\r\n\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  n\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)  =\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{n}\\right]  $.\r\nThis proves Lemma 10.2.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.1.]This proof is going to be very similar to the proofs\r\nof Theorem 4.4 \\textbf{(a)} and Theorem 9.1 \\textbf{(a)} - except that this\r\ntime, we already have done most of our work when proving Lemma 10.2.\r\n\r\n\\textit{1st Step:} Fix $m\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$ such that $m\\geq\r\nj$. Then, we claim that $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  ,j,\\left[  m\\right]  }=\\operatorname*{Td}\\nolimits_{\\varphi,j}$.\r\n\r\n\\textit{Proof.} Lemma 10.2 (applied to $n=j$) yields that\r\n$\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)  =\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  ,j,\\left[  j\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n$ in the polynomial ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{j}\\right]  $.\r\nSince the elements $X_{1}$, $X_{2}$, $...$, $X_{j}$ of $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{j}\\right]  $ are algebraically independent (by Theorem 4.1\r\n\\textbf{(a)}), this yields $\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  ,j,\\left[  m\\right]  }=\\operatorname*{Todd}%\r\n\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  j\\right]  }$. Thus,\r\n$\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[\r\nj\\right]  }=\\operatorname*{Td}\\nolimits_{\\varphi,j}$, and the 1st Step is proven.\r\n\r\n\\textit{2nd Step:} For every $m\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$, we have\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\]\r\nin the ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\n\r\n\\textit{Proof.} Let $m^{\\prime}\\in\\mathbb{N}$ be such that $m^{\\prime}\\geq m$\r\nand $m^{\\prime}\\geq j$. Then, the 1st Step (applied to $m^{\\prime}$ instead of\r\n$m$) yields that $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  m^{\\prime}\\right]  }=\\operatorname*{Td}\\nolimits_{\\varphi,j}$. On\r\nthe other hand, Lemma 10.2 (applied to $m^{\\prime}$ and $m$ instead of $m$ and\r\n$n$) yields that $\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  m^{\\prime}\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)  $ in the polynomial ring $\\mathbf{Z}%\r\n\\left[  U_{1},U_{2},...,U_{m}\\right]  $. Since $\\operatorname*{Todd}%\r\n\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m^{\\prime}\\right]\r\n}=\\operatorname*{Td}\\nolimits_{\\varphi,j}$, this rewrites as\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)  ,j,\\left[  m\\right]\r\n}\\left(  X_{1},X_{2},...,X_{j}\\right)  $. This proves the 2nd Step.\r\n\r\n\\textit{3rd Step:} For every $m\\in\\mathbb{N}$, the equation (\\ref{Td1}) is\r\nsatisfied in the ring $\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\right)  \\left[  \\left[  T\\right]  \\right]  $.\r\n\r\n\\textit{Proof.} Every power series $P\\in\\left(  \\mathbf{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $\r\nsatisfies $P=\\sum\\limits_{j\\in\\mathbb{N}}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{j}P\\right)  T^{j}$ (by the definition of $\\operatorname*{Coeff}%\r\n\\nolimits_{j}$). Applied to $P=\\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  $, this yields%\r\n\\begin{align*}\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)   &  =\\sum\\limits_{j\\in\r\n\\mathbb{N}}\\underbrace{\\operatorname*{Coeff}\\nolimits_{j}\\left(\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  }%\r\n_{\\substack{=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)  \\\\\\text{(by\r\n(\\ref{10.1.pf.1}))}}}T^{j}=\\sum\\limits_{j\\in\\mathbb{N}}%\r\n\\underbrace{\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)  }%\r\n_{\\substack{=\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  \\\\\\text{(by the 2nd step)}}}T^{j}\\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}%\r\n\\end{align*}\r\nin the ring $\\left(  \\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)\r\n\\left[  \\left[  T\\right]  \\right]  $. This proves the 3rd Step, and thus\r\nTheorem 10.1 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{Defining the Todd homomorphism}\r\n\r\nNow, let us define the Todd homomorphism:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$. We\r\ndefine a map $\\operatorname*{td}_{\\varphi,T}:K\\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  $ by%\r\n\\begin{equation}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)\r\n\\right)  T^{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K. \\label{ToddDef}%\r\n\\end{equation}\r\nWe call $\\operatorname*{td}\\nolimits_{\\varphi,T}$ the $\\varphi$-\\textit{Todd\r\nhomomorphism} of the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $.\r\n\\end{quote}\r\n\r\nAs already mentioned above, this notation $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}$ and the name ``$\\varphi$-Todd homomorphism'' by which I\r\ndenote it might not be standard terminology.\\footnote{For instance, what\r\n\\cite{FulLan85} calls ``\\textit{Todd homomorphism}'' is the map\r\n$\\operatorname*{td}_{\\varphi}:=\\operatorname*{td}\\nolimits_{\\varphi,1}$ (where\r\n$\\operatorname*{td}\\nolimits_{\\varphi,1}$ means ``take the formal power series\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}$ and replace every $T$ by $1$''),\r\nwhich is only defined on $x$ if $x$ is finite-dimensional, i. e. if $x$\r\nsatisfies $\\lambda^{i}\\left(  x\\right)  =0$ for all sufficiently large $i$.\r\nBut I prefer the power series $\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(\r\nx\\right)  $ since it is defined on \\textit{every }$x$.\r\n\\par\r\nI am not even sure whether there exists standard terminology for Todd\r\nhomomorphisms - there does not seem to be much literature about them.}\r\n\r\n\\subsection{The case when the power series is $1+ut$}\r\n\r\nAs complicated as this definition was, we might wonder whether there is a more\r\nexplicit approach to $\\varphi$-Todd homomorphisms. It turns out that there is,\r\nif $\\varphi$ is a polynomial factoring into linear polynomials of the form\r\n$1+ut$ with $u\\in\\mathbf{Z}$. Let us begin with computing the $\\varphi$-Todd\r\nhomomorphism for $\\varphi$ itself being of this form:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.3.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $u\\in\\mathbf{Z}$. For every $x\\in K$, we\r\nhave $\\operatorname*{td}\\nolimits_{1+ut,T}\\left(  x\\right)  =\\lambda\r\n_{uT}\\left(  x\\right)  $, where $\\lambda_{uT}\\left(  x\\right)  $ means\r\n$\\operatorname*{ev}\\nolimits_{uT}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n$.\r\n\\end{quote}\r\n\r\nTo prove this, we need to compute the $j$-th Todd polynomials of $1+ut$. This\r\ncan be done explicitly:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.4.} Let $\\mathbf{Z}$ be a ring. Let $u\\in\\mathbf{Z}$.\r\nThen, $\\operatorname*{Td}\\nolimits_{1+ut,j}=u^{j}\\alpha_{j}$ (in the\r\npolynomial ring $\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{j}\\right]  $) for every positive $j\\in\\mathbb{N}$.\r\n\\end{quote}\r\n\r\nNote that Proposition 10.4 makes no sense for $j=0$; this will cause us some\r\nminor trouble in the proof of Proposition 10.3.\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.4.]Let $m\\in\\mathbb{N}$. Consider the ring\r\n$\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (the polynomial ring in $m$\r\nindeterminates $U_{1}$, $U_{2}$, $...$, $U_{m}$ over the ring $\\mathbf{Z}$).\r\nFor every $i\\in\\mathbb{N}$, let $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in\r\nS}U_{k}$ be the so-called $i$\\textit{-th elementary symmetric polynomial} in\r\nthe variables $U_{1}$, $U_{2}$, $...$, $U_{m}$.\r\n\r\nWe know from Theorem 10.1 that (\\ref{Td1}) holds in the ring $\\left(\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $ whenever $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ is a power series with constant term equal to $1$. Applying\r\nthis to $\\varphi=1+ut$, we obtain%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1+ut\\right)  \\left(  U_{i}T\\right)  =\\sum\r\n_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{1+ut,j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  T^{j},\r\n\\]\r\nwhere $\\left(  1+ut\\right)  \\left(  U_{i}T\\right)  $ means \\textquotedblleft\r\nthe power series $1+ut$, applied to $U_{i}T$\\textquotedblright\\ (and not a\r\nproduct of $1+ut$ and $U_{i}T$, whatever such a product could mean). Since%\r\n\\begin{align*}\r\n&  \\prod\\limits_{i=1}^{m}\\underbrace{\\left(  1+ut\\right)  \\left(\r\nU_{i}T\\right)  }_{=1+uU_{i}T=1+U_{i}\\cdot uT}\\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1+U_{i}\\cdot uT\\right)  =\\sum_{i\\in\r\n\\mathbb{N}}\\underbrace{\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod_{k\\in S}U_{k}}_{=X_{i}}%\r\n\\underbrace{\\left(  uT\\right)  ^{i}}_{=u^{i}T^{i}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Exercise 4.2 \\textbf{(b)}, applied to }U_{i}\\text{, }\\left(\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  \\text{, and }uT\\\\\r\n\\text{instead of }\\alpha_{i}\\text{, }A\\text{, and }t\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}X_{i}u^{i}T^{i}=\\sum_{j\\in\\mathbb{N}}X_{j}u^{j}%\r\nT^{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the index }i\\text{ as\r\n}j\\right)  ,\r\n\\end{align*}\r\nthis rewrites as%\r\n\\[\r\n\\sum_{j\\in\\mathbb{N}}X_{j}u^{j}T^{j}=\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}%\r\n\\nolimits_{1+ut,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j}.\r\n\\]\r\nBy comparing coefficients in this equation, we conclude that%\r\n\\[\r\nX_{j}u^{j}=\\operatorname*{Td}\\nolimits_{1+ut,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\text{ in }\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }j\\in\\mathbb{N}\\text{.}%\r\n\\]\r\n\r\n\r\nNow we forget that we fixed $m$. Instead, fix some positive $j\\in\\mathbb{N}$,\r\nand take $m=j$. Then, we have just proved that\r\n\\[\r\nX_{j}u^{j}=\\operatorname*{Td}\\nolimits_{1+ut,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\text{ in }\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{j}\\right]\r\n.\r\n\\]\r\n\r\n\r\nApplying Theorem 4.1 \\textbf{(a)} to $K=\\mathbf{Z}$, $m=j$ and $P=X_{j}u^{j}$,\r\nwe conclude that there exists one and only one polynomial $Q\\in\\mathbf{Z}%\r\n\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ such that $X_{j}%\r\nu^{j}=Q\\left(  X_{1},X_{2},...,X_{j}\\right)  $. In particular, there exists\r\n\\textit{at most one} such polynomial $Q\\in\\mathbf{Z}\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{j}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in\\mathbf{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\text{ are two polynomials}\\\\\r\n\\text{such that }X_{j}u^{j}=\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{j}%\r\n\\right)  \\text{ and }X_{j}u^{j}=\\mathfrak{Q}_{2}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\text{,}\\\\\r\n\\text{then }\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{10.4.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nLet $\\mathfrak{Q}_{1}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{j}\\right]  $ be the polynomial defined by $\\mathfrak{Q}_{1}=u^{j}\\alpha_{j}%\r\n$. Let $\\mathfrak{Q}_{2}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{j}\\right]  $ be the polynomial defined by $\\mathfrak{Q}%\r\n_{2}=\\operatorname*{Td}\\nolimits_{1+ut,j}$. We are now going to prove that\r\n$\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nSince our two polynomials $\\mathfrak{Q}_{1}$ and $\\mathfrak{Q}_{2}$ satisfy%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{j}\\right)   &  =u^{j}%\r\nX_{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{1}=u^{j}\\alpha\r\n_{j}\\right) \\\\\r\n&  =X_{j}u^{j}%\r\n\\end{align*}\r\nand%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{j}\\right)   &  =\\operatorname*{Td}%\r\n\\nolimits_{1+ut,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{2}=\\operatorname*{Td}%\r\n\\nolimits_{1+ut,j}\\right) \\\\\r\n&  =X_{j}u^{j},\r\n\\end{align*}\r\nwe can conclude from (\\ref{10.4.pf.1}) that $\\mathfrak{Q}_{1}=\\mathfrak{Q}%\r\n_{2}$. Hence, $u^{j}\\alpha_{j}=\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n=\\operatorname*{Td}\\nolimits_{1+ut,j}$. This proves Proposition 10.4.\r\n\\end{proof}\r\n\r\n\\subsection{The $0$-th and $1$-st coefficients of $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  x\\right)  $}\r\n\r\nWe keep back the proof of Proposition 10.3 for a moment - instead, we first\r\nshow a proposition which gives the first two coefficients of the power series\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  $ in the general\r\ncase (with $\\varphi$ arbitrary):\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.5.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\n\r\n\\textbf{(a)} Then, $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  \\right)  =1$ for\r\nevery $x\\in K$.\r\n\r\n\\textbf{(b)} Let $\\varphi_{1}$ be the coefficient of the power series\r\n$\\varphi\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $ before $t^{1}$.\r\nThen, $\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  x\\right)  \\right)  =\\varphi_{1}x$ for every $x\\in\r\nK$.\r\n\\end{quote}\r\n\r\nTo prove this, we need to compute the $0$-th and the $1$-st Todd polynomials\r\nof $\\varphi$:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.6.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$.\r\n\r\n\\textbf{(a)} Then, $\\operatorname*{Td}\\nolimits_{\\varphi,0}=1$.\r\n\r\n\\textbf{(b)} Let $\\varphi_{1}$ be the coefficient of the power series\r\n$\\varphi\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $ before $t^{1}$.\r\nThen, $\\operatorname*{Td}\\nolimits_{\\varphi,1}=\\varphi_{1}\\alpha_{1}$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.6.]Let $m\\in\\mathbb{N}$. Consider the ring\r\n$\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ and its elements\r\n$X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ as in the\r\ndefinition of $\\operatorname*{Td}\\nolimits_{\\varphi,j}$.\r\n\r\nWe know from Theorem 10.1 that (\\ref{Td1}) holds in the ring $\\left(\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $. In other words,%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\nT^{j}.\r\n\\]\r\n\r\n\r\nThus,\r\n\\begin{equation}\r\n\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,0}\\left(  X_{1},X_{2},...,X_{0}\\right)  \\label{10.6.pf.1}%\r\n\\end{equation}\r\n\\footnote{The notation $\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(\r\nX_{1},X_{2},...,X_{0}\\right)  $ is somewhat unusual, but it should not be\r\nsurprising: The polynomial $\\operatorname*{Td}\\nolimits_{\\varphi,0}$ is an\r\nelement of $\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{0}\\right]  $,\r\nthat is, a polynomial in zero variables. (Of course, polynomials in zero\r\nvariables are just elements of the base ring - in this case, elements of\r\n$\\mathbf{Z}$.)} (by the definition of $\\operatorname*{Coeff}\\nolimits_{0}$)\r\nand%\r\n\\begin{equation}\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,1}\\left(  X_{1},X_{2},...,X_{1}\\right)  \\label{10.6.pf.2}%\r\n\\end{equation}\r\n(by the definition of $\\operatorname*{Coeff}\\nolimits_{1}$). Both of these\r\nequations (\\ref{10.6.pf.1}) and (\\ref{10.6.pf.2}) hold in the ring\r\n$\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\n\r\n\\textbf{(a)} Let $m=0$. Then, the polynomial rings $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  =\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{0}\\right]\r\n$ and $\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{0}\\right]  $ can be\r\ncanonically identified with the ring $\\mathbf{Z}$ (because they are polynomial\r\nrings in zero variables, and a polynomial ring in zero variables over a ring\r\n$K$ is the same as the ring $K$ itself). Under this identification, the\r\n``value'' $\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  X_{1},X_{2}%\r\n,...,X_{0}\\right)  $ corresponds to the polynomial $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,0}$, so that we can write $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,0}\\left(  X_{1},X_{2},...,X_{0}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,0}$.\r\n\r\nBut the equation (\\ref{10.6.pf.1}) holds in the ring $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  =\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{0}\\right]\r\n\\cong\\mathbf{Z}$. Hence, we have%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  X_{1},X_{2},...,X_{0}\\right)\r\n=\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\underbrace{\\prod\\limits_{i=1}%\r\n^{m}\\varphi\\left(  U_{i}T\\right)  }_{\\substack{=\\left(  \\text{empty\r\nproduct}\\right)  \\\\\\text{(since }m=0\\text{)}}}\\right)  =\\operatorname*{Coeff}%\r\n\\nolimits_{0}\\underbrace{\\left(  \\text{empty product}\\right)  }_{=1}=1\r\n\\]\r\nin the ring $\\mathbf{Z}$. Hence, $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,0}=\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  X_{1},X_{2},...,X_{0}%\r\n\\right)  =1$. This proves Proposition 10.6 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Let $m=1$. Then, $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n=\\mathbf{Z}\\left[  U_{1}\\right]  $, and in this ring $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ we have $X_{1}=U_{1}$ (because $X_{1}$ is the\r\n$1$-st elementary symmetric polynomial of the one variable $U_{1}$). Thus, in\r\nthis ring, we have%\r\n\\begin{align*}\r\n\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  U_{1}\\right)   &\r\n=\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  X_{1}\\right)\r\n=\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  X_{1},X_{2},...,X_{1}\\right)\r\n\\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\underbrace{\\prod\\limits_{i=1}%\r\n^{m}\\varphi\\left(  U_{i}T\\right)  }_{=\\varphi\\left(  U_{1}T\\right)  \\text{\r\n(since }m=1\\text{)}}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{10.6.pf.2})}\\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\varphi\\left(  U_{1}T\\right)\r\n\\right)  =\\left(  \\text{the coefficient of the power series }\\varphi\\left(\r\nU_{1}T\\right)  \\text{ before }T^{1}\\right) \\\\\r\n&  =U_{1}\\underbrace{\\left(  \\text{the coefficient of the power series\r\n}\\varphi\\text{ before }t^{1}\\right)  }_{=\\varphi_{1}}=U_{1}\\varphi_{1}.\r\n\\end{align*}\r\n\r\n\r\nNow, let $\\kappa$ be the $\\mathbf{Z}$-algebra homomorphism $\\mathbf{Z}\\left[\r\n\\alpha_{1}\\right]  \\rightarrow\\mathbf{Z}\\left[  U_{1}\\right]  $ which maps\r\n$\\alpha_{1}$ to $U_{1}$. This homomorphism $\\kappa$ must be an isomorphism\r\n(since $U_{1}$ is obviously algebraically independent). Since $\\kappa$ is a\r\n$\\mathbf{Z}$-algebra homomorphism and $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,1}$ is a polynomial, we have $\\kappa\\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,1}\\left(  \\alpha_{1}\\right)  \\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,1}\\left(  \\kappa\\left(  \\alpha_{1}\\right)  \\right)  $\r\n(because $\\mathbf{Z}$-algebra homomorphisms commute with polynomials). Now,%\r\n\\begin{align*}\r\n\\kappa\\left(  \\underbrace{\\operatorname*{Td}\\nolimits_{\\varphi,1}%\r\n}_{=\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\alpha_{1}\\right)\r\n}\\right)   &  =\\kappa\\left(  \\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(\r\n\\alpha_{1}\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(\r\n\\underbrace{\\kappa\\left(  \\alpha_{1}\\right)  }_{=U_{1}}\\right)\r\n=\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  U_{1}\\right) \\\\\r\n&  =\\underbrace{U_{1}}_{=\\kappa\\left(  \\alpha_{1}\\right)  }\\varphi_{1}%\r\n=\\kappa\\left(  \\alpha_{1}\\right)  \\varphi_{1}=\\varphi_{1}\\kappa\\left(\r\n\\alpha_{1}\\right)  =\\kappa\\left(  \\varphi_{1}\\alpha_{1}\\right)\r\n\\end{align*}\r\n(since $\\kappa$ is a $\\mathbf{Z}$-algebra homomorphism). Thus,\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,1}=\\varphi_{1}\\alpha_{1}$ (since\r\n$\\kappa$ is an isomorphism). This proves Proposition 10.6 \\textbf{(b)}.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.5.]Let $x\\in K$.\r\n\r\n\\textbf{(a)} We have%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\operatorname*{td}\\nolimits_{\\varphi\r\n,T}\\left(  x\\right)  \\right)   &  =\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{ToddDef})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{0}\\left(  x\\right)\r\n\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\operatorname*{Coeff}\\nolimits_{0}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}=1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by Proposition 10.6 \\textbf{(a)}}\\right)  .\r\n\\end{align*}\r\n\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\operatorname*{td}\\nolimits_{\\varphi\r\n,T}\\left(  x\\right)  \\right)   &  =\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{ToddDef})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{1}\\left(  x\\right)\r\n\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\operatorname*{Coeff}\\nolimits_{1}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\underbrace{\\lambda\r\n^{1}\\left(  x\\right)  }_{=x}\\right)  =\\operatorname*{Td}\\nolimits_{\\varphi\r\n,1}\\left(  x\\right)  =\\varphi_{1}x\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since Proposition 10.6 \\textbf{(b)}\r\nyields }\\operatorname*{Td}\\nolimits_{\\varphi,1}=\\varphi_{1}\\alpha_{1}\\right)\r\n.\r\n\\end{align*}\r\n\r\n\r\nProposition 10.5 is now proven.\r\n\\end{proof}\r\n\r\n\\subsection{Proof of Proposition 10.3}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.3.]Let $x\\in K$. Applying (\\ref{ToddDef}) to\r\n$\\varphi=1+ut$, we obtain%\r\n\\begin{align*}\r\n&  \\operatorname*{td}\\nolimits_{1+ut,T}\\left(  x\\right) \\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{1+ut,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}\\\\\r\n&  =\\underbrace{\\operatorname*{Td}\\nolimits_{1+ut,0}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{0}\\left(  x\\right)\r\n\\right)  }_{\\substack{=\\operatorname*{Td}\\nolimits_{1+ut,0}=1\\\\\\text{(by\r\nProposition 10.6 \\textbf{(a)},}\\\\\\text{applied to }\\varphi=1+ut\\text{)}}%\r\n}T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\underbrace{\\operatorname*{Td}%\r\n\\nolimits_{1+ut,j}}_{\\substack{=u^{j}\\alpha_{j}\\\\\\text{(by Proposition 10.4)}%\r\n}}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  T^{j}\\\\\r\n&  =1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\underbrace{\\left(\r\nu^{j}\\alpha_{j}\\right)  \\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda\r\n^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)  }%\r\n_{=u^{j}\\lambda^{j}\\left(  x\\right)  =\\lambda^{j}\\left(  x\\right)  u^{j}}%\r\nT^{j}=1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\lambda^{j}\\left(\r\nx\\right)  u^{j}T^{j}.\r\n\\end{align*}\r\nCompared with%\r\n\\begin{align*}\r\n\\lambda_{uT}\\left(  x\\right)   &  =\\operatorname*{ev}\\nolimits_{uT}\\left(\r\n\\underbrace{\\lambda_{T}\\left(  x\\right)  }_{=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\lambda^{j}\\left(  x\\right)  T^{j}}\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{uT}\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\lambda^{j}\\left(  x\\right)\r\nT^{j}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\lambda^{j}\\left(  x\\right)  u^{j}%\r\nT^{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\operatorname*{ev}\\nolimits_{uT}\\right) \\\\\r\n&  =\\underbrace{\\lambda^{0}\\left(  x\\right)  }_{=1}\\underbrace{u^{0}}%\r\n_{=1}T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\lambda^{j}\\left(  x\\right)\r\nu^{j}T^{j}=1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\lambda^{j}\\left(\r\nx\\right)  u^{j}T^{j},\r\n\\end{align*}\r\nthis yields that $\\operatorname*{td}\\nolimits_{1+ut,T}\\left(  x\\right)\r\n=\\lambda_{uT}\\left(  x\\right)  $. This proves Proposition 10.3.\r\n\\end{proof}\r\n\r\n\\subsection{The Todd homomorphism is multiplicative in $\\varphi$}\r\n\r\nOur next proposition is another step to making the $\\varphi$-Todd homomorphism manageable:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.7.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ and $\\psi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be two power series with constant terms equal to $1$. For every\r\n$x\\in K$, we have $\\operatorname*{td}\\nolimits_{\\varphi\\psi,T}\\left(\r\nx\\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)\r\n\\operatorname*{td}\\nolimits_{\\psi,T}\\left(  x\\right)  $.\r\n\\end{quote}\r\n\r\nAgain, this boils down to an identity for Todd polynomials:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.8.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ and $\\psi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be two power series\r\nwith constant terms equal to $1$. Then,%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  =\\sum\\limits_{i=0}^{j}\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{i}\\right)\r\n\\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j-i}\\right)\r\n\\]\r\n(in the polynomial ring $\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{j}\\right]  $) for every $j\\in\\mathbb{N}$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.8.]\\textit{1st Step:} We have $\\varphi\\psi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$.\r\n\r\n\\textit{Proof.} The constant term of the product of two power series always\r\nequals the product of the constant terms of these power series. Applying this\r\nto the power series $\\varphi$ and $\\psi$, we obtain%\r\n\\begin{align*}\r\n&  \\left(  \\text{constant term of the power series }\\varphi\\psi\\right) \\\\\r\n&  =\\underbrace{\\left(  \\text{constant term of the power series }%\r\n\\varphi\\right)  }_{=1\\text{ (since }\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}\\text{)}}\\cdot\\underbrace{\\left(  \\text{constant term\r\nof the power series }\\psi\\right)  }_{=1\\text{ (since }\\psi\\in1+\\mathbf{Z}%\r\n\\left[  \\left[  t\\right]  \\right]  ^{+}\\text{)}}\\\\\r\n&  =1\\cdot1=1,\r\n\\end{align*}\r\nso that $\\varphi\\psi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$.\r\nThe 1st Step is thus proven.\r\n\r\n\\textit{2nd Step:} We are going to show that for every $m\\in\\mathbb{N}$, we\r\nhave%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2},...,X_{j}%\r\n\\right)  =\\sum_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\nX_{1},X_{2},...,X_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  X_{1},X_{2},...,X_{j-i}\\right)\r\n\\]\r\nin the polynomial ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ for\r\nevery $j\\in\\mathbb{N}$ (where, as usual, $X_{i}$ denotes the polynomial\r\n$\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ (the $i$-th elementary symmetric\r\npolynomial in the variables $U_{1}$, $U_{2}$, $...$, $U_{m}$) for every\r\n$i\\in\\mathbb{N}$).\r\n\r\n\\textit{Proof.} Let $m\\in\\mathbb{N}$. By Theorem 10.1, the equality\r\n(\\ref{Td1}) holds in the ring $\\left(  \\mathbf{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $. In other\r\nwords,%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  T^{j}.\r\n\\]\r\nApplying this equality to $\\psi$ instead of $\\varphi$, we get%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\psi\\left(  U_{i}T\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\psi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\nT^{j}.\r\n\\]\r\nOn the other hand, applying it to $\\varphi\\psi$ instead of $\\varphi$, we get%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  \\varphi\\psi\\right)  \\left(  U_{i}T\\right)\r\n=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi\r\n,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j}.\r\n\\]\r\nHence,%\r\n\\begin{align*}\r\n&  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi\r\n,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j}\\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\underbrace{\\left(  \\varphi\\psi\\right)  \\left(\r\nU_{i}T\\right)  }_{=\\varphi\\left(  U_{i}T\\right)  \\psi\\left(  U_{i}T\\right)\r\n}=\\prod\\limits_{i=1}^{m}\\left(  \\varphi\\left(  U_{i}T\\right)  \\psi\\left(\r\nU_{i}T\\right)  \\right) \\\\\r\n&  =\\underbrace{\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  }%\r\n_{=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}}\\cdot\\underbrace{\\prod\\limits_{i=1}%\r\n^{m}\\psi\\left(  U_{i}T\\right)  }_{=\\sum\\limits_{j\\in\\mathbb{N}}%\r\n\\operatorname*{Td}\\nolimits_{\\psi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\nT^{j}}\\\\\r\n&  =\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  T^{j}\\right)  \\cdot\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\left(  \\sum_{i=0}^{j}\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,i}\\left(  X_{1},X_{2},...,X_{i}\\right)  \\cdot\r\n\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  X_{1},X_{2},...,X_{j-i}\\right)\r\n\\right)  T^{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\nformal power series}\\right)  .\r\n\\end{align*}\r\nComparing coefficients in this equation, we conclude that%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2},...,X_{j}%\r\n\\right)  =\\sum_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\nX_{1},X_{2},...,X_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  X_{1},X_{2},...,X_{j-i}\\right)\r\n\\]\r\nfor every $j\\in\\mathbb{N}$. This proves the 2nd Step.\r\n\r\n\\textit{3rd Step:} Let us now prove Proposition 10.8.\r\n\r\nFix some $j\\in\\mathbb{N}$. Let $m=j$. We are going to work in the ring\r\n$\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  =\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{j}\\right]  $.\r\n\r\nApplying Theorem 4.1 \\textbf{(a)} to $K=\\mathbf{Z}$, $m=j$ and\r\n$P=\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  $, we conclude that there exists one and only one\r\npolynomial $Q\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]\r\n$ such that $\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  =Q\\left(  X_{1},X_{2},...,X_{j}\\right)  $. In\r\nparticular, there exists \\textit{at most one} such polynomial $Q\\in\r\n\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in\\mathbf{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\text{ are two polynomials}\\\\\r\n\\text{such that }\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  =\\mathfrak{Q}_{1}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\text{ and}\\\\\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2},...,X_{j}%\r\n\\right)  =\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\text{, then\r\n}\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{10.8.pf.2}%\r\n\\end{equation}\r\n\r\n\r\nLet $\\mathfrak{Q}_{1}\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{j}\\right]  $ be the polynomial defined by $\\mathfrak{Q}_{1}%\r\n=\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  $. Let $\\mathfrak{Q}_{2}\\in\\mathbf{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ be the polynomial defined by\r\n$\\mathfrak{Q}_{2}=\\sum\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{i}\\right)  \\cdot\r\n\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{j-i}\\right)  $. We are now going to prove that $\\mathfrak{Q}%\r\n_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nSince our two polynomials $\\mathfrak{Q}_{1}$ and $\\mathfrak{Q}_{2}$ satisfy%\r\n\\[\r\n\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{j}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{1}=\\operatorname*{Td}%\r\n\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)\r\n\\right)\r\n\\]\r\nand%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{j}\\right)   &  =\\sum_{i=0}%\r\n^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  X_{1},X_{2},...,X_{i}%\r\n\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  X_{1}%\r\n,X_{2},...,X_{j-i}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{2}=\\sum\r\n\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j-i}\\right)  \\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the 2nd Step}\\right)\r\n,\r\n\\end{align*}\r\nwe can conclude from (\\ref{10.8.pf.2}) that $\\mathfrak{Q}_{1}=\\mathfrak{Q}%\r\n_{2}$. Hence,%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  =\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}=\\sum\r\n\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j-i}\\right)  .\r\n\\]\r\nThis proves Proposition 10.8.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.7.]\\textit{1st Step:} For every $j\\in\\mathbb{N}$ and\r\n$x\\in K$, we have%\r\n\\begin{align*}\r\n&  \\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)\r\n\\right) \\\\\r\n&  =\\sum\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{i}\\left(  x\\right)  \\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j-i}\\left(  x\\right)  \\right)  .\r\n\\end{align*}\r\n\r\n\r\n\\textit{Proof.} Let $j\\in\\mathbb{N}$ and $x\\in K$. Since the polynomials\r\n$\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  $ and $\\sum\\limits_{i=0}^{j}\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{i}\\right)\r\n\\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j-i}\\right)  $ are equal (by Proposition 10.8), their\r\nevaluations at $\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(\r\nx\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)  $ must also be equal. But\r\nsince the evaluation of $\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  $ at \\newline$\\left(  \\lambda\r\n^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(\r\nx\\right)  \\right)  $ is $\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  $, whereas the evaluation of $\\sum\r\n\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j-i}\\right)  $ at $\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  $ is \\newline$\\sum\\limits_{i=0}^{j}%\r\n\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{i}\\left(  x\\right)  \\right)\r\n\\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j-i}\\left(  x\\right)\r\n\\right)  $, this yields that the values $\\operatorname*{Td}\\nolimits_{\\varphi\r\n\\psi,j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  $ and \\newline$\\sum\\limits_{i=0}%\r\n^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{i}\\left(  x\\right)\r\n\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j-i}\\left(  x\\right)\r\n\\right)  $ are equal. This proves the 1st step.\r\n\r\n\\textit{2nd Step:} Now let us prove Proposition 10.7.\r\n\r\nLet $x\\in K$. By (\\ref{ToddDef}) (applied to $\\varphi\\psi$ instead of\r\n$\\varphi$), we have%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi\\psi,T}\\left(  x\\right)  =\\sum\r\n_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}.\r\n\\]\r\nBut%\r\n\\begin{align*}\r\n&  \\underbrace{\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)\r\n}_{\\substack{=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  T^{j}\\\\\\text{(by (\\ref{ToddDef}))}%\r\n}}\\underbrace{\\operatorname*{td}\\nolimits_{\\psi,T}\\left(  x\\right)\r\n}_{\\substack{=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi\r\n,j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  T^{j}\\\\\\text{(by (\\ref{ToddDef}),\r\napplied to }\\psi\\text{ instead of }\\varphi\\text{)}}}\\\\\r\n&  =\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  T^{j}\\right)  \\cdot\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\underbrace{\\left(  \\sum\\limits_{i=0}%\r\n^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{i}\\left(  x\\right)\r\n\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\lambda^{1}\\left(\r\nx\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{j-i}\\left(  x\\right)\r\n\\right)  \\right)  }_{\\substack{=\\operatorname*{Td}\\nolimits_{\\varphi\\psi\r\n,j}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)\r\n,...,\\lambda^{j}\\left(  x\\right)  \\right)  \\\\\\text{(by the 1st Step)}}}T^{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\nformal power series}\\right) \\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}=\\operatorname*{td}\\nolimits_{\\varphi\r\n\\psi,T}\\left(  x\\right)  .\r\n\\end{align*}\r\nThis proves Proposition 10.7.\r\n\\end{proof}\r\n\r\nAn easy consequence of Proposition 10.7:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.9.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $m\\in\\mathbb{N}$. For every $i\\in\\left\\{\r\n1,2,...,m\\right\\}  $, let $\\varphi_{i}\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. For every\r\n$x\\in K$, we have%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\prod\\limits_{i=1}^{m}\\varphi_{i},T}\\left(\r\nx\\right)  =\\prod\\limits_{i=1}^{m}\\operatorname*{td}\\nolimits_{\\varphi_{i}%\r\n,T}\\left(  x\\right)  .\r\n\\]\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.9.]This can be proven by induction over $m$. The\r\ninduction base (the case $m=0$) requires showing that $\\operatorname*{td}%\r\n\\nolimits_{1,T}\\left(  x\\right)  =1$, but this follows from Proposition\r\n10.3\\footnote{In fact, Proposition 10.3 (applied to $u=0$) yields\r\n$\\operatorname*{td}\\nolimits_{1+0t,T}\\left(  x\\right)  =\\lambda_{0T}\\left(\r\nx\\right)  $. Now $\\lambda_{0T}\\left(  x\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{0T}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  $. Since\r\n$\\operatorname*{ev}\\nolimits_{0T}$ is the map $K\\left[  \\left[  T\\right]\r\n\\right]  \\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ which sends every\r\npower series to its constant term (viewed as a constant power series), we have\r\n$\\operatorname*{ev}\\nolimits_{0T}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n=\\left(  \\text{constant term of the power series }\\lambda_{T}\\left(  x\\right)\r\n\\right)  =1$. Thus, $\\operatorname*{td}\\nolimits_{1,T}\\left(  x\\right)\r\n=\\operatorname*{td}\\nolimits_{1+0t,T}\\left(  x\\right)  =\\lambda_{0T}\\left(\r\nx\\right)  =\\operatorname*{ev}\\nolimits_{0T}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  =1$.}. The induction step is a straightforward application\r\nof Proposition 10.7. Thus Proposition 10.9 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{$\\operatorname*{td}\\nolimits_{\\varphi,T}$ takes sums into\r\nproducts}\r\n\r\nOur next goal is to show the following general property of $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.10.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\nLet $x\\in K$ and $y\\in K$. Then, $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T}\\left(  x\\right)  \\cdot\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(\r\ny\\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x+y\\right)  $.\r\n\\end{quote}\r\n\r\nHow can we prove a theorem like this? By using Proposition 10.3, we could\r\nprove it in the case of $\\varphi$ being a polynomial of the form $1+ut$ with\r\n$u\\in\\mathbf{Z}$. Using Proposition 10.9, we could therefore also prove it in\r\nthe case of $\\varphi$ being a product of finitely many such polynomials.\r\nHowever, the case of $\\varphi$ being a general power series does not directly\r\nfollow from any of our above-proven propositions. Not even the case of\r\n$\\varphi$ being a general polynomial - in fact, a general polynomial does not\r\nalways factor into polynomials of the form $1+ut$ with $u\\in\\mathbf{Z}$.\r\n\r\nHowever, we can prove Theorem 10.10 (and similar results) using the following\r\ntwo tricks: First, we need a kind of continuity (similar to the one we used in\r\nSection 5) to reduce the case of $\\varphi$ a power series to the case of\r\n$\\varphi$ a polynomial. Second, we need to split every arbitrary polynomial\r\n$\\varphi$ with constant term equal to $1$ into a product of polynomials of the\r\nform $1+ut$; this will be done by an appropriate extension of the ring\r\n$\\mathbf{Z}$ (again, similarly to how we extended $K$ in Section 5). However,\r\nthese tricks do not yet give us a proof of Theorem 10.10 unless we change our\r\nviewpoint to a more general one: Rather than working in a $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, we work\r\nwith power series over an arbitrary ring. Here is what we do, precisely:\r\n\r\n\\subsection{The $\\mathfrak{Todd}_{\\varphi}$ map}\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$\r\nbe a power series with constant term equal to $1$. We define a map\r\n$\\mathfrak{Todd}_{\\varphi}:K\\left[  \\left[  T\\right]  \\right]  \\rightarrow\r\nK\\left[  \\left[  T\\right]  \\right]  $ by\r\n\\begin{equation}\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }p\\in K\\left[\r\n\\left[  T\\right]  \\right]  . \\label{ToddFrak}%\r\n\\end{equation}\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\nThe reason why we can consider this a generalization of the $\\varphi$-Todd\r\nhomomorphism is the following:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.11.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\nThen, every $x\\in K$ satisfies $\\operatorname*{td}_{\\varphi,T}\\left(\r\nx\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.11.]Let $x\\in K$. Then, $\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}$, so that\r\nevery $k\\in\\mathbb{N}$ satisfies $\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{k}%\r\n\\left(  \\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}\\right)\r\n=\\lambda^{k}\\left(  x\\right)  $ (by the definition of $\\operatorname*{Coeff}%\r\n\\nolimits_{k}$). Thus, $\\left(  \\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  ,\\operatorname*{Coeff}\\nolimits_{2}%\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  ,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  =\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  $ for every $j\\in\\mathbb{N}$. Now,\r\n(\\ref{ToddFrak}) (applied to $p=\\lambda_{T}\\left(  x\\right)  $) yields%\r\n\\begin{align*}\r\n&  \\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)  \\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  ,\\operatorname*{Coeff}\\nolimits_{2}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  ,...,\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\lambda\r\n_{T}\\left(  x\\right)  \\right)  \\right)  T^{j}\\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{j}\\left(  x\\right)  \\right)  T^{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n,\\operatorname*{Coeff}\\nolimits_{2}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  ,...,\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  \\right)  =\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda\r\n^{2}\\left(  x\\right)  ,...,\\lambda^{j}\\left(  x\\right)  \\right)  \\right) \\\\\r\n&  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  .\r\n\\end{align*}\r\nThis proves Proposition 10.11.\r\n\\end{proof}\r\n\r\nNow let us generalize our above results about $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}$ to results about $\\mathfrak{Todd}_{\\varphi}$. This will\r\nbe rather easy since our proofs generalize.\r\n\r\nHere comes the generalization of Proposition 10.3:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.12.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a\r\n$\\mathbf{Z}$-algebra. Let $u\\in\\mathbf{Z}$. Let $p\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$. Then, $\\mathfrak{Todd}_{1+ut}\\left(  p\\right)\r\n=\\operatorname*{ev}\\nolimits_{uT}\\left(  p\\right)  $.\\ \\ \\ \\ \\footnote{Let us\r\nrecall that $\\operatorname*{ev}\\nolimits_{uT}$ denotes the map $K\\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow K\\left[  \\left[  T\\right]  \\right]  $\r\ndefined by%\r\n\\[\r\n\\operatorname*{ev}\\nolimits_{uT}\\left(  \\sum\\limits_{i\\in\\mathbb{N}}a_{i}%\r\nT^{i}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}a_{i}u^{i}T^{i}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every power series }\\sum\\limits_{i\\in\\mathbb{N}%\r\n}a_{i}T^{i}\\in K\\left[  \\left[  T\\right]  \\right]  \\text{ (with }a_{i}\\in\r\nK\\text{ for every }i\\text{).}%\r\n\\]\r\n}\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.12.]The coefficient of the power series $p$ before\r\n$T^{0}$ is $1$ (since $p\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$). In\r\nother words, $\\operatorname*{Coeff}\\nolimits_{0}p=1$ (since\r\n$\\operatorname*{Coeff}\\nolimits_{0}p$ is defined as the coefficient of the\r\npower series $p$ before $T^{0}$).\r\n\r\nFor every $j\\in\\mathbb{N}$, the coefficient of $p$ before $T^{j}$ is\r\n$\\operatorname*{Coeff}\\nolimits_{j}p$. Hence, $p=\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\left(  \\operatorname*{Coeff}\\nolimits_{j}p\\right)  \\cdot T^{j}$. Thus,\r\n\\begin{align*}\r\n\\operatorname*{ev}\\nolimits_{uT}p  &  =\\operatorname*{ev}\\nolimits_{uT}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\left(  \\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  \\cdot T^{j}\\right)  =\\sum\\limits_{j\\in\\mathbb{N}}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{j}p\\right)  \\cdot u^{j}T^{j}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\operatorname*{ev}%\r\n\\nolimits_{uT}\\right) \\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}u^{j}\\left(  \\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  T^{j}=\\underbrace{u^{0}}_{=1}\\underbrace{\\left(\r\n\\operatorname*{Coeff}\\nolimits_{0}p\\right)  }_{=1}T^{0}+\\sum_{\\substack{j\\in\r\n\\mathbb{N};\\\\j>0}}u^{j}\\left(  \\operatorname*{Coeff}\\nolimits_{j}p\\right)\r\nT^{j}\\\\\r\n&  =1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}u^{j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}.\r\n\\end{align*}\r\nCompared with%\r\n\\begin{align*}\r\n&  \\mathfrak{Todd}_{1+ut}\\left(  p\\right) \\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{1+ut,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{ToddFrak}), applied to }%\r\n\\varphi=1+ut\\right) \\\\\r\n&  =\\underbrace{\\operatorname*{Td}\\nolimits_{1+ut,0}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{0}p\\right)  }%\r\n_{\\substack{=\\operatorname*{Td}\\nolimits_{1+ut,0}=1\\\\\\text{(by Proposition\r\n10.6 \\textbf{(a)},}\\\\\\text{applied to }\\varphi=1+ut\\text{)}}}T^{0}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}%\r\n}\\underbrace{\\operatorname*{Td}\\nolimits_{1+ut,j}}_{\\substack{=u^{j}\\alpha\r\n_{j}\\\\\\text{(by Proposition 10.4)}}}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}\\\\\r\n&  =1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}\\underbrace{\\left(\r\nu^{j}\\alpha_{j}\\right)  \\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  }_{=u^{j}\\left(  \\operatorname*{Coeff}\\nolimits_{j}p\\right)  }%\r\nT^{j}\\\\\r\n&  =1T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}u^{j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j},\r\n\\end{align*}\r\nthis yields that $\\operatorname*{ev}\\nolimits_{uT}p=\\mathfrak{Todd}%\r\n_{1+ut}\\left(  p\\right)  $. This proves Proposition 10.12.\r\n\\end{proof}\r\n\r\nNext, the generalization of Proposition 10.5:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.13.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a\r\n$\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. Let $p\\in\r\nK\\left[  \\left[  T\\right]  \\right]  $.\r\n\r\n\\textbf{(a)} Then, $\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)  \\right)  =1$.\r\n\r\n\\textbf{(b)} Let $\\varphi_{1}$ be the coefficient of the power series\r\n$\\varphi\\in\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  $ before $t^{1}$.\r\nThen, $\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\mathfrak{Todd}_{\\varphi\r\n}\\left(  p\\right)  \\right)  =\\varphi_{1}\\operatorname*{Coeff}\\nolimits_{1}p$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.13.]\\textbf{(a)} We have%\r\n\\begin{align*}\r\n&  \\operatorname*{Coeff}\\nolimits_{0}\\left(  \\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{ToddFrak})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{0}p\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of\r\n}\\operatorname*{Coeff}\\nolimits_{0}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}=1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by Proposition 10.6 \\textbf{(a)}}\\right)  .\r\n\\end{align*}\r\n\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\n&  \\operatorname*{Coeff}\\nolimits_{1}\\left(  \\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{ToddDef})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{1}p\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of\r\n}\\operatorname*{Coeff}\\nolimits_{1}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p\\right)  =\\varphi_{1}\\operatorname*{Coeff}\\nolimits_{1}p\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since Proposition 10.6 \\textbf{(b)}\r\nyields }\\operatorname*{Td}\\nolimits_{\\varphi,1}=\\varphi_{1}\\alpha_{1}\\right)\r\n.\r\n\\end{align*}\r\n\r\n\r\nProposition 10.13 is now proven.\r\n\\end{proof}\r\n\r\nOur next generalization is that of Proposition 10.7:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.14.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a\r\n$\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ and $\\psi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ be two power series with constant terms equal to $1$. Let $p\\in K\\left[\r\n\\left[  T\\right]  \\right]  $. Then, $\\mathfrak{Todd}_{\\varphi\\psi}\\left(\r\np\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}%\r\n_{\\psi}\\left(  p\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.14.]For every $j\\in\\mathbb{N}$, we will abbreviate\r\n$\\operatorname*{Coeff}\\nolimits_{j}p$ by $p_{j}$. Then, $\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  =\\left(  p_{1}%\r\n,p_{2},...,p_{j}\\right)  $.\r\n\r\n\\textit{1st Step:} For every $j\\in\\mathbb{N}$, we have%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  p_{1},p_{2},...,p_{j}%\r\n\\right)  =\\sum\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\np_{1},p_{2},...,p_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  p_{1},p_{2},...,p_{j-i}\\right)  .\r\n\\]\r\n\r\n\r\n\\textit{Proof.} Let $j\\in\\mathbb{N}$. Since the polynomials\r\n$\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  $ and $\\sum\\limits_{i=0}^{j}\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{i}\\right)\r\n\\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j-i}\\right)  $ are equal (by Proposition 10.8), their\r\nevaluations at $\\left(  p_{1},p_{2},...,p_{j}\\right)  $ must also be equal.\r\nBut since the evaluation of $\\operatorname*{Td}\\nolimits_{\\varphi\\psi\r\n,j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  $ at $\\left(\r\np_{1},p_{2},...,p_{j}\\right)  $ is $\\operatorname*{Td}\\nolimits_{\\varphi\r\n\\psi,j}\\left(  p_{1},p_{2},...,p_{j}\\right)  $, whereas the evaluation of\r\n$\\sum\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{i}\\right)  \\cdot\\operatorname*{Td}%\r\n\\nolimits_{\\psi,j-i}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j-i}\\right)  $\r\nat $\\left(  p_{1},p_{2},...,p_{j}\\right)  $ is $\\sum\\limits_{i=0}%\r\n^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  p_{1},p_{2},...,p_{i}%\r\n\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  p_{1}%\r\n,p_{2},...,p_{j-i}\\right)  $, this yields that the values $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi\\psi,j}\\left(  p_{1},p_{2},...,p_{j}\\right)  $ and\r\n$\\sum\\limits_{i=0}^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(\r\np_{1},p_{2},...,p_{i}\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi\r\n,j-i}\\left(  p_{1},p_{2},...,p_{j-i}\\right)  $ are equal. This proves the 1st step.\r\n\r\n\\textit{2nd Step:} Now let us prove Proposition 10.14.\r\n\r\nBy (\\ref{ToddFrak}) (applied to $\\varphi\\psi$ instead of $\\varphi$), we have%\r\n\\begin{align*}\r\n\\mathfrak{Todd}_{\\varphi\\psi}\\left(  p\\right)   &  =\\sum\\limits_{j\\in\r\n\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\underbrace{\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  }_{=\\left(  p_{1}%\r\n,p_{2},...,p_{j}\\right)  }T^{j}\\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\np_{1},p_{2},...,p_{j}\\right)  T^{j}.\r\n\\end{align*}\r\nBut%\r\n\\begin{align*}\r\n&  \\underbrace{\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  }_{\\substack{=\\sum\r\n\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}\\\\\\text{(by\r\n(\\ref{ToddFrak}))}}}\\underbrace{\\mathfrak{Todd}_{\\psi}\\left(  p\\right)\r\n}_{\\substack{=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi\r\n,j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}%\r\n\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}%\r\n\\\\\\text{(by (\\ref{ToddFrak}), applied to }\\psi\\text{ instead of }%\r\n\\varphi\\text{)}}}\\\\\r\n&  =\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\underbrace{\\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  }_{=\\left(  p_{1},p_{2},...,p_{j}\\right)  }T^{j}\\right)\r\n\\cdot\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi\r\n,j}\\underbrace{\\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  }_{=\\left(  p_{1},p_{2},...,p_{j}\\right)  }T^{j}\\right) \\\\\r\n&  =\\left(  \\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  p_{1},p_{2},...,p_{j}\\right)  T^{j}\\right)  \\cdot\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\psi,j}\\left(\r\np_{1},p_{2},...,p_{j}\\right)  T^{j}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\underbrace{\\left(  \\sum\\limits_{i=0}%\r\n^{j}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  p_{1},p_{2},...,p_{i}%\r\n\\right)  \\cdot\\operatorname*{Td}\\nolimits_{\\psi,j-i}\\left(  p_{1}%\r\n,p_{2},...,p_{j-i}\\right)  \\right)  }_{\\substack{=\\operatorname*{Td}%\r\n\\nolimits_{\\varphi\\psi,j}\\left(  p_{1},p_{2},...,p_{j}\\right)  \\\\\\text{(by the\r\n1st Step)}}}T^{j}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\nformal power series}\\right) \\\\\r\n&  =\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi\\psi,j}\\left(\r\np_{1},p_{2},...,p_{j}\\right)  T^{j}=\\mathfrak{Todd}_{\\varphi\\psi}\\left(\r\np\\right)  .\r\n\\end{align*}\r\nThis proves Proposition 10.14.\r\n\\end{proof}\r\n\r\nNext, Proposition 10.9 generalizes to the following result:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.15.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a\r\n$\\mathbf{Z}$-algebra. Let $m\\in\\mathbb{N}$. For every $i\\in\\left\\{\r\n1,2,...,m\\right\\}  $, let $\\varphi_{i}\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. Let $p\\in\r\nK\\left[  \\left[  T\\right]  \\right]  $. Then,%\r\n\\[\r\n\\mathfrak{Todd}_{\\prod\\limits_{i=1}^{m}\\varphi_{i}}\\left(  p\\right)\r\n=\\prod\\limits_{i=1}^{m}\\mathfrak{Todd}_{\\varphi_{i}}\\left(  p\\right)  .\r\n\\]\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.15.]This can be proven by induction over $m$. The\r\ninduction base (the case $m=0$) requires showing that $\\mathfrak{Todd}%\r\n_{1}\\left(  p\\right)  =1$, but this is easy\\footnote{\\textit{Proof.} Applying\r\n(\\ref{ToddFrak}) to $\\varphi=1$, we obtain%\r\n\\begin{align*}\r\n&  \\mathfrak{Todd}_{1}\\left(  p\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{1,j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  T^{j}\\\\\r\n&  =\\underbrace{\\operatorname*{Td}\\nolimits_{1,0}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{0}p\\right)  }_{\\substack{=\\operatorname*{Td}\\nolimits_{1,0}%\r\n=1\\\\\\text{(by Proposition 10.6 \\textbf{(a)},}\\\\\\text{applied to }%\r\n\\varphi=1\\text{)}}}T^{0}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}%\r\n}\\underbrace{\\operatorname*{Td}\\nolimits_{1,j}}_{\\substack{=\\operatorname*{Td}%\r\n\\nolimits_{1+0t,j}=0^{j}\\alpha_{j}\\\\\\text{(by Proposition 10.4,}%\r\n\\\\\\text{applied to }u=0\\text{)}}}\\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  T^{j}\\\\\r\n&  =\\underbrace{1T^{0}}_{=1}+\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}%\r\n}\\underbrace{0^{j}}_{\\substack{=0\\\\\\text{(since }j>0\\text{)}}}\\alpha\r\n_{j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}%\r\n\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}\\\\\r\n&  =1+\\underbrace{\\sum_{\\substack{j\\in\\mathbb{N};\\\\j>0}}0\\alpha_{j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}}_{=0}=1.\r\n\\end{align*}\r\n}. The induction step is a straightforward application of Proposition 10.14.\r\nThus Proposition 10.15 is proven.\r\n\\end{proof}\r\n\r\nWe now formulate our generalization of Theorem 10.10 - it is through this\r\ngeneralization that we are going to prove Theorem 10.10:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.16.} Let $\\mathbf{Z}$ be a ring. Let $K$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$\r\nbe a power series with constant term equal to $1$. Let $p\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ and $q\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$.\r\nThen, $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  q\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)  $.\r\n\\end{quote}\r\n\r\nTo prove this theorem, we first reduce it to the case when $K=\\mathbf{Z}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 10.17.} Let $K$ be a ring. Let $\\varphi\\in1+K\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\nLet $p\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ and $q\\in1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$. Then, $\\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\cdot\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  pq\\right)  $.\r\n\\end{quote}\r\n\r\nWe will now prepare to the proof of this lemma. First, let us introduce the\r\nversion of continuity that we need.\r\n\r\n\\subsection{Preparing for the proof of Lemma 10.17}\r\n\r\nThe following two definitions are copies of two definitions which we made in\r\nSection 5, with the only difference that the variable that used to be $T$ in\r\nSection 5 is called $t$ here.\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $K$ be a ring. Let $K\\left[  t\\right]  ^{+}$ be the\r\nsubset of $K\\left[  t\\right]  $ defined by%\r\n\\begin{align*}\r\nK\\left[  t\\right]  ^{+}  &  =tK\\left[  t\\right]  =\\left\\{  \\sum_{i\\in\r\n\\mathbb{N}}a_{i}t^{i}\\in K\\left[  t\\right]  \\ \\mid\\ a_{i}\\in K\\text{ for all\r\n}i,\\text{ and }a_{0}=0\\right\\} \\\\\r\n&  =\\left\\{  p\\in K\\left[  t\\right]  \\ \\mid\\ p\\text{ is a polynomial with\r\nconstant term }0\\right\\}  .\r\n\\end{align*}\r\nThen, the set $1+K\\left[  t\\right]  ^{+}$ is a subset of $1+K\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$. The elements of $1+K\\left[  t\\right]  ^{+}$ are polynomials.\r\n\r\n\\textbf{Definition.} Let $K$ be a ring. As a $K$-module, $K\\left[  \\left[\r\nt\\right]  \\right]  =\\prod\\limits_{k\\in\\mathbb{N}}Kt^{k}$. Now, we define the\r\nso-called $\\left(  t\\right)  $\\textit{-topology} on the ring $K\\left[  \\left[\r\nt\\right]  \\right]  $ as the topology generated by%\r\n\\[\r\n\\left\\{  u+t^{N}K\\left[  \\left[  t\\right]  \\right]  \\ \\mid\\ u\\in K\\left[\r\n\\left[  t\\right]  \\right]  \\text{ and }N\\in\\mathbb{N}\\right\\}  .\r\n\\]\r\nIn other words, the open sets of this topology should be all translates of the\r\n$K$-submodules $t^{N}K\\left[  \\left[  t\\right]  \\right]  $ for $N\\in\r\n\\mathbb{N}$, as well as the unions of these translates\\footnote{This includes\r\nthe empty union, which is $\\varnothing$.}. (Note that, for each $N\\in\r\n\\mathbb{N}$, the set $t^{N}K\\left[  \\left[  t\\right]  \\right]  $ is actually\r\nan ideal of $K\\left[  \\left[  t\\right]  \\right]  $, and consists of all power\r\nseries $f\\in K\\left[  \\left[  t\\right]  \\right]  $ whose coefficients before\r\n$t^{0},t^{1},\\ldots,t^{N-1}$ all vanish. This ideal $t^{N}K\\left[  \\left[\r\nt\\right]  \\right]  $ can also be described as the $N$-th power of the ideal\r\n$tK\\left[  \\left[  t\\right]  \\right]  $; therefore, the $\\left(  t\\right)\r\n$-topology on $K\\left[  \\left[  t\\right]  \\right]  $ is precisely the\r\nso-called $tK\\left[  \\left[  t\\right]  \\right]  $-adic topology. Also note\r\nthat every translate of the submodule $t^{N}K\\left[  \\left[  t\\right]\r\n\\right]  $ for $N\\in\\mathbb{N}$ actually has the form $p+t^{N}K\\left[  \\left[\r\nt\\right]  \\right]  $ for a polynomial $p\\in K\\left[  t\\right]  $ of degree\r\n$<N$, and this polynomial is uniquely determined.) It is well-known that the\r\n$\\left(  t\\right)  $-topology makes $K\\left[  \\left[  t\\right]  \\right]  $\r\ninto a topological ring.\r\n\\end{quote}\r\n\r\nNow, we have:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.18.} Let $K$ be a ring. The $\\left(  t\\right)  $-topology\r\non the ring $K\\left[  \\left[  t\\right]  \\right]  $ restricts to a topology on\r\nits subset $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$; we call this topology\r\nthe $\\left(  t\\right)  $\\textit{-topology} again. Whenever we say ``open'',\r\n``continuous'', ``dense'', etc., we are referring to this topology.\r\n\r\n\\textbf{(a)} The subset $1+K\\left[  t\\right]  ^{+}$ is dense in $1+K\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$.\r\n\r\n\\textbf{(b)} Let $f:1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow\r\nK\\left[  \\left[  T\\right]  \\right]  $ be a map such that for every\r\n$n\\in\\mathbb{N}$ there exists some $N\\in\\mathbb{N}$ such that the first $n$\r\ncoefficients of the image of a formal power series under $f$ depend only on\r\nthe first $N$ coefficients of the series itself (and not on the remaining\r\nones). Then, $f$ is continuous. (Here, the topology on $K\\left[  \\left[\r\nT\\right]  \\right]  $ is supposed to be the $\\left(  T\\right)  $-topology\r\ndefined in Section 5.)\r\n\r\n\\textbf{(c)} The topological spaces $K\\left[  \\left[  t\\right]  \\right]  $ and\r\n$1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ are Hausdorff spaces.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.18.]The parts \\textbf{(a)} and \\textbf{(c)} of Theorem\r\n10.18 are obviously obtained from the parts \\textbf{(a)} and \\textbf{(e)} of\r\nTheorem 5.5 by renaming the variable $T$ as $t$. Hence, they follow from\r\nTheorem 5.5. Part \\textbf{(b)} of Theorem 10.18 is also true (it is an\r\nexercise in topology, proven in the same way as Theorem 5.5 \\textbf{(b)}).\r\nThis proves Theorem 10.18.\r\n\\end{proof}\r\n\r\nThe good thing about the topology on $1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ just defined is that it makes the map $1+K\\left[  \\left[  t\\right]\r\n\\right]  ^{+}\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $, $\\varphi\r\n\\mapsto\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  $ continuous for every given\r\n$p\\in K\\left[  \\left[  T\\right]  \\right]  $:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.19.} Let $K$ be a ring. Let $p\\in K\\left[  \\left[\r\nT\\right]  \\right]  $. Then, the map%\r\n\\[\r\n1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  ,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\varphi\\mapsto\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)\r\n\\]\r\nis continuous. Here, the topology on $1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ is supposed to be the $\\left(  t\\right)  $-topology, and the topology on\r\n$K\\left[  \\left[  T\\right]  \\right]  $ is supposed to be the $\\left(\r\nT\\right)  $-topology defined in Section 5.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.19.]Let $f$ denote the map\r\n\\[\r\n1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  ,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\varphi\\mapsto\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)  .\r\n\\]\r\nThen, in order to verify Proposition 10.19, we must prove that this map $f$ is continuous.\r\n\r\n\\textit{1st Step:} Let $n\\in\\mathbb{N}$. Let $\\varphi\\in1+K\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ and $\\psi\\in1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ be two power series such that the first $n$ coefficients\\footnote{Note\r\nthat when we say ``the first $n$ coefficients'' (of some power series), we\r\nmean the coefficients before $t^{0}$, $t^{1}$, $...$, $t^{n-1}$.} of $\\varphi$\r\nare equal to the respective coefficients of $\\psi$. Then, the first $n$\r\ncoefficients of the power series $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  $\r\nare equal to the respective coefficients of the power series $\\mathfrak{Todd}%\r\n_{\\psi}\\left(  p\\right)  $.\r\n\r\n\\textit{Proof.} Let $m\\in\\left\\{  0,1,...,n-1\\right\\}  $ be arbitrary.\r\n\r\nSince the first $n$ coefficients of the power series $\\varphi$ are equal to\r\nthe respective coefficients of the power series $\\psi$, we have $\\varphi\r\n\\equiv\\psi\\operatorname{mod}t^{n}$ in the ring $K\\left[  \\left[  t\\right]\r\n\\right]  $. Thus, there exists some formal power series $\\eta\\in K\\left[\r\n\\left[  t\\right]  \\right]  $ such that $\\varphi-\\psi=\\eta t^{n}$. Consider\r\nsuch an $\\eta$.\r\n\r\nConsider the polynomial ring $K\\left[  U_{1},U_{2},...,U_{m}\\right]  $ and its\r\nelements $X_{i}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ as in the\r\ndefinition of $\\operatorname*{Td}\\nolimits_{\\varphi,j}$.\r\n\r\nEvery $i\\in\\left\\{  1,2,...,m\\right\\}  $ satisfies%\r\n\\begin{align*}\r\n\\varphi\\left(  U_{i}T\\right)  -\\psi\\left(  U_{i}T\\right)   &\r\n=\\underbrace{\\left(  \\varphi-\\psi\\right)  }_{=\\eta t^{n}}\\left(\r\nU_{i}T\\right)  =\\left(  \\eta t^{n}\\right)  \\left(  U_{i}T\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{where }\\left(  \\eta t^{n}\\right)  \\left(  U_{i}T\\right)  \\text{ means\r\nthe application of the formal}\\\\\r\n\\text{power series }\\eta t^{n}\\in K\\left[  \\left[  t\\right]  \\right]  \\text{\r\nto }U_{i}T\\text{, and not a product of }\\eta t^{n}\\\\\r\n\\text{with }U_{i}T\\text{ (whatever that could mean)}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\eta\\left(  U_{i}T\\right)  \\cdot\\underbrace{\\left(  U_{i}T\\right)  ^{n}%\r\n}_{=U_{i}^{n}T^{n}}=\\eta\\left(  U_{i}T\\right)  \\cdot U_{i}^{n}T^{n}%\r\n\\end{align*}\r\nand thus $T^{n}\\mid\\varphi\\left(  U_{i}T\\right)  -\\psi\\left(  U_{i}T\\right)\r\n$, so that $\\varphi\\left(  U_{i}T\\right)  \\equiv\\psi\\left(  U_{i}T\\right)\r\n\\operatorname{mod}T^{n}$ in the ring $\\left(  K\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]  \\right]  $. Multiplying\r\nthe congruences $\\varphi\\left(  U_{i}T\\right)  \\equiv\\psi\\left(\r\nU_{i}T\\right)  \\operatorname{mod}T^{n}$ for all $i\\in\\left\\{\r\n1,2,...,m\\right\\}  $, we obtain $\\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\equiv\\prod\\limits_{i=1}^{m}\\psi\\left(  U_{i}T\\right)\r\n\\operatorname{mod}T^{n}$. In other words, the first $n$ coefficients of the\r\npower series $\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  $ are equal\r\nto the respective coefficients of the power series $\\prod\\limits_{i=1}^{m}%\r\n\\psi\\left(  U_{i}T\\right)  $. In other words, every $k\\in\\left\\{\r\n0,1,...,n-1\\right\\}  $ satisfies $\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)\r\n=\\operatorname*{Coeff}\\nolimits_{k}\\left(  \\prod\\limits_{i=1}^{m}\\psi\\left(\r\nU_{i}T\\right)  \\right)  $. Applied to $k=m$, this yields\r\n$\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{m}%\r\n\\left(  \\prod\\limits_{i=1}^{m}\\psi\\left(  U_{i}T\\right)  \\right)  $.\r\n\r\nAccording to Theorem 10.1, the equation (\\ref{Td1}) holds in the ring $\\left(\r\nK\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[  T\\right]\r\n\\right]  $. Thus,%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(\r\nU_{i}T\\right)  \\right)   &  =\\operatorname*{Coeff}\\nolimits_{m}\\left(\r\n\\sum_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by (\\ref{Td1})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}%\r\n\\right)  .\r\n\\end{align*}\r\nThe same argument, but applied to $\\psi$ instead of $\\varphi$, yields%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\prod\\limits_{i=1}^{m}\\psi\\left(\r\nU_{i}T\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\psi,m}\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  .\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)\r\n&  =\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\psi\\left(  U_{i}T\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\psi\r\n,m}\\left(  X_{1},X_{2},...,X_{m}\\right)  .\r\n\\end{align*}\r\n\r\n\r\nWe will now use this to prove $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,m}=\\operatorname*{Td}\\nolimits_{\\psi,m}$.\r\n\r\nIn fact, applying Theorem 4.1 \\textbf{(a)} to $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)  $ instead of $P$,\r\nwe conclude that there exists one and only one polynomial $Q\\in K\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ such that $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)  =Q\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  $. In particular, there exists \\textit{at most\r\none} such polynomial $Q\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{m}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{m}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in K\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m}\\right]  \\text{ are two polynomials}\\\\\r\n\\text{such that }\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  X_{1}%\r\n,X_{2},...,X_{m}\\right)  =\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{m}%\r\n\\right)  \\text{ and}\\\\\r\n\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)\r\n=\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{m}\\right)  \\text{, then\r\n}\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{10.11.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nLet $\\mathfrak{Q}_{1}\\in K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]\r\n$ be the polynomial defined by $\\mathfrak{Q}_{1}=\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,m}$. Let $\\mathfrak{Q}_{2}\\in K\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{m}\\right]  $ be the polynomial defined by\r\n$\\mathfrak{Q}_{2}=\\operatorname*{Td}\\nolimits_{\\psi,m}$. We are now going to\r\nprove that $\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nSince our two polynomials $\\mathfrak{Q}_{1}$ and $\\mathfrak{Q}_{2}$ satisfy%\r\n\\[\r\n\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{m}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{1}=\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,m}\\right)\r\n\\]\r\nand%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{m}\\right)   &  =\\operatorname*{Td}%\r\n\\nolimits_{\\psi,m}\\left(  X_{1},X_{2},...,X_{m}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{2}=\\operatorname*{Td}%\r\n\\nolimits_{\\psi,m}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  X_{1},X_{2},...,X_{m}%\r\n\\right)  ,\r\n\\end{align*}\r\nwe can conclude from (\\ref{10.11.pf.1}) that $\\mathfrak{Q}_{1}=\\mathfrak{Q}%\r\n_{2}$. Hence, $\\operatorname*{Td}\\nolimits_{\\varphi,m}=\\mathfrak{Q}%\r\n_{1}=\\mathfrak{Q}_{2}=\\operatorname*{Td}\\nolimits_{\\psi,m}$.\r\n\r\nNow,%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\right)   &  =\\operatorname*{Coeff}\\nolimits_{m}\\left(\r\n\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{ToddFrak})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,m}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{m}p\\right)  .\r\n\\end{align*}\r\nThe same argument, applied to $\\psi$ instead of $\\varphi$, yields%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\mathfrak{Todd}_{\\psi}\\left(\r\np\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\psi,m}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{m}p\\right)  .\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{m}\\left(  \\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\right)   &  =\\underbrace{\\operatorname*{Td}\\nolimits_{\\varphi,m}%\r\n}_{=\\operatorname*{Td}\\nolimits_{\\psi,m}}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{m}p\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\psi,m}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{m}p\\right)  =\\operatorname*{Coeff}\\nolimits_{m}\\left(\r\n\\mathfrak{Todd}_{\\psi}\\left(  p\\right)  \\right)  .\r\n\\end{align*}\r\n\r\n\r\nSo we have proven that $\\operatorname*{Coeff}\\nolimits_{m}\\left(\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\right)  =\\operatorname*{Coeff}%\r\n\\nolimits_{m}\\left(  \\mathfrak{Todd}_{\\psi}\\left(  p\\right)  \\right)  $ for\r\nevery $m\\in\\left\\{  0,1,...,n-1\\right\\}  $. In other words, for every\r\n$m\\in\\left\\{  0,1,...,n-1\\right\\}  $, the $m$-th coefficient of the power\r\nseries $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  $ equals the respective\r\ncoefficient of the power series $\\mathfrak{Todd}_{\\psi}\\left(  p\\right)  $. In\r\nother words, the first $n$ coefficients of the power series $\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)  $ are equal to the respective coefficients of the\r\npower series $\\mathfrak{Todd}_{\\psi}\\left(  p\\right)  $.\r\n\r\nThis proves the 1st Step.\r\n\r\n\\textit{2nd Step:} Let $n\\in\\mathbb{N}$. Let $\\varphi\\in1+K\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ and $\\psi\\in1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ be two power series such that the first $n$ coefficients\\footnote{Note\r\nthat when we say ``the first $n$ coefficients'' (of some power series), we\r\nmean the coefficients before $t^{0}$, $t^{1}$, $...$, $t^{n-1}$.} of $\\varphi$\r\nare equal to the respective coefficients of $\\psi$. Then, the first $n$\r\ncoefficients of the power series $f\\left(  \\varphi\\right)  $ are equal to the\r\nrespective coefficients of the power series $f\\left(  \\psi\\right)  $.\r\n\r\n\\textit{Proof.} This is just an equivalent restatement of the 1st Step, since\r\n$f\\left(  \\varphi\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  $ (by\r\nthe definition of $f$) and $f\\left(  \\psi\\right)  =\\mathfrak{Todd}_{\\psi\r\n}\\left(  p\\right)  $ (by the definition of $f$).\r\n\r\n\\textit{3rd Step:} We can rewrite the result of the 2nd Step as follows: If,\r\nfor some $n\\in\\mathbb{N}$, two power series $\\varphi$ and $\\psi$ in\r\n$1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ have the same first $n$\r\ncoefficients (i. e., the first $n$ coefficients of $\\varphi$ are equal to the\r\nrespective coefficients of $\\psi$), then the images $f\\left(  \\varphi\\right)\r\n$ and $f\\left(  \\psi\\right)  $ of these two power series under $f$ also have\r\nthe same first $n$ coefficients. In other words, for every $n\\in\\mathbb{N}$,\r\nthe first $n$ coefficients of the image of a formal power series under $f$\r\ndepend only on the first $n$ coefficients of the series itself (and not on the\r\nremaining ones).\r\n\r\nHence, for every $n\\in\\mathbb{N}$, there exists some $N\\in\\mathbb{N}$ such\r\nthat the first $n$ coefficients of the image of a formal power series under\r\n$f$ depend only on the first $N$ coefficients of the series itself (and not on\r\nthe remaining ones)\\footnote{Namely, we can take $N=n$.}. According to Theorem\r\n10.18 \\textbf{(b)}, this yields that $f$ is continuous.\r\n\r\nSince $f$ was defined as the map%\r\n\\[\r\n1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  ,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\varphi\\mapsto\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)  ,\r\n\\]\r\nthis shows that the map%\r\n\\[\r\n1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  ,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\varphi\\mapsto\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)\r\n\\]\r\nis continuous. Proposition 10.19 is thus proven.\r\n\\end{proof}\r\n\r\nSo much for the topology on $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$. We\r\nnow discuss extensions of $K$ that make polynomials factor.\r\n\r\nBy renaming the polynomial $p$ as $\\varphi$ and the variable $T$ as $t$ in\r\nTheorem 5.2, we obtain the following fact:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.20.} Let $K$ be a ring. For every element $\\varphi\r\n\\in1+K\\left[  t\\right]  ^{+}$, there exists an integer $n$ (the degree of the\r\npolynomial $\\varphi$), a finite-free extension ring $K_{\\varphi}$ of the ring\r\n$K$ and $n$ elements $p_{1}$, $p_{2}$, $...$, $p_{n}$ of this extension ring\r\n$K_{\\varphi}$ such that $\\varphi=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}%\r\nt\\right)  $ in $K_{\\varphi}\\left[  t\\right]  $.\r\n\\end{quote}\r\n\r\n\\subsection{Proof of Lemma 10.17}\r\n\r\nNow, finally, to the proof of Lemma 10.17:\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 10.17.]Fix $p\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$\r\nand $q\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$, but let $\\varphi\r\n\\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ vary.\r\n\r\n\\textit{1st Step:} For every $\\varphi\\in1+K\\left[  t\\right]  ^{+}$, we have\r\n$\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)  $.\r\n\r\n\\textit{Proof.} Assume that $\\varphi\\in1+K\\left[  t\\right]  ^{+}$. According\r\nto Theorem 10.20, there exists an integer $n$ (the degree of the polynomial\r\n$\\varphi$), a finite-free extension ring $K_{\\varphi}$ of the ring $K$ and $n$\r\nelements $p_{1}$, $p_{2}$, $...$, $p_{n}$ of this extension ring $K_{\\varphi}$\r\nsuch that $\\varphi=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}t\\right)  $ in\r\n$K_{\\varphi}\\left[  t\\right]  $. Consider this ring $K_{\\varphi}$ and these\r\n$n$ elements $p_{1}$, $p_{2}$, $...$, $p_{n}$.\r\n\r\nSince $K$ is a subring of $K_{\\varphi}$, we can canonically view the ring\r\n$K\\left[  t\\right]  $ as a subring of $K_{\\varphi}\\left[  t\\right]  $, and\r\nsimilarly we can view the ring $K\\left[  \\left[  t\\right]  \\right]  $ as a\r\nsubring of $K_{\\varphi}\\left[  \\left[  t\\right]  \\right]  $, and we can view\r\nthe ring $K\\left[  \\left[  T\\right]  \\right]  $ as a subring of $K_{\\varphi\r\n}\\left[  \\left[  T\\right]  \\right]  $.\r\n\r\nHere is a trivial observation that we will tacitly use: For every $r\\in\r\nK\\left[  \\left[  T\\right]  \\right]  $, the value of the term $\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  r\\right)  $ does not depend on whether we interpret\r\n$\\varphi$ as an element of $1+K\\left[  t\\right]  ^{+}$ or as an element of\r\n$1+K_{\\varphi}\\left[  t\\right]  ^{+}$, and also does not depend on whether we\r\ninterpret $r$ as an element of $K\\left[  \\left[  T\\right]  \\right]  $ or as an\r\nelement of $K_{\\varphi}\\left[  \\left[  T\\right]  \\right]  $. This is because\r\nthe definition of $\\mathfrak{Todd}_{\\varphi}\\left(  r\\right)  $ was functorial\r\nboth in $\\mathbf{Z}$ and in $K$.\r\n\r\nLet $r\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ be arbitrary. Proposition\r\n10.15 (applied to $r$, $K_{\\varphi}$, $K_{\\varphi}$, $n$ and $1+p_{i}t$\r\ninstead of $p$, $K$, $\\mathbf{Z}$, $m$ and $\\varphi_{i}$) yields that\r\n$\\mathfrak{Todd}_{\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}t\\right)  }\\left(\r\nr\\right)  =\\prod\\limits_{i=1}^{n}\\mathfrak{Todd}_{1+p_{i}t}\\left(  r\\right)\r\n$. Since $\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}t\\right)  =\\varphi$, this\r\nrewrites as%\r\n\\begin{equation}\r\n\\mathfrak{Todd}_{\\varphi}\\left(  r\\right)  =\\prod\\limits_{i=1}^{n}%\r\n\\underbrace{\\mathfrak{Todd}_{1+p_{i}t}\\left(  r\\right)  }%\r\n_{\\substack{=\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  r\\right)  \\\\\\text{(by\r\nProposition 10.12,}\\\\\\text{applied to }K_{\\varphi}\\text{, }K_{\\varphi}\\text{,\r\n}r\\text{ and }p_{i}\\\\\\text{instead of }\\mathbf{Z}\\text{, }K\\text{, }p\\text{\r\nand }u\\text{)}}}=\\prod\\limits_{i=1}^{n}\\operatorname*{ev}\\nolimits_{p_{i}%\r\nT}\\left(  r\\right)  . \\label{10.20.pf.1}%\r\n\\end{equation}\r\nApplying (\\ref{10.20.pf.1}) to $r=p$, we obtain $\\mathfrak{Todd}_{\\varphi\r\n}\\left(  p\\right)  =\\prod\\limits_{i=1}^{n}\\operatorname*{ev}\\nolimits_{p_{i}%\r\nT}\\left(  p\\right)  $. Applying (\\ref{10.20.pf.1}) to $r=q$, we obtain\r\n$\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  =\\prod\\limits_{i=1}^{n}%\r\n\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  q\\right)  $. Applying\r\n(\\ref{10.20.pf.1}) to $r=pq$, we obtain\r\n\\begin{align*}\r\n\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)   &  =\\prod\\limits_{i=1}%\r\n^{n}\\underbrace{\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  pq\\right)\r\n}_{\\substack{=\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  p\\right)\r\n\\cdot\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  q\\right)  \\\\\\text{(since\r\n}\\operatorname*{ev}\\nolimits_{p_{i}T}\\text{ is a ring}\\\\\\text{homomorphism)}%\r\n}}=\\prod\\limits_{i=1}^{n}\\left(  \\operatorname*{ev}\\nolimits_{p_{i}T}\\left(\r\np\\right)  \\cdot\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(  q\\right)  \\right)\r\n=\\underbrace{\\prod\\limits_{i=1}^{n}\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(\r\np\\right)  }_{=\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  }\\cdot\r\n\\underbrace{\\prod\\limits_{i=1}^{n}\\operatorname*{ev}\\nolimits_{p_{i}T}\\left(\r\nq\\right)  }_{=\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  }\\\\\r\n&  =\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  .\r\n\\end{align*}\r\nThis proves the 1st Step.\r\n\r\n\\textit{2nd Step:} Let $\\mathfrak{f}_{1}:1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ be the map which sends\r\nevery $\\varphi\\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ to\r\n$\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  $.\r\n\r\nLet $\\mathfrak{f}_{2}:1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow\r\nK\\left[  \\left[  T\\right]  \\right]  $ be the map which sends every $\\varphi\r\n\\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ to $\\mathfrak{Todd}_{\\varphi\r\n}\\left(  pq\\right)  $.\r\n\r\nThese maps $\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$ are equal to each other\r\non a dense subset of $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$.\r\n\r\n\\textit{Proof.} Every $\\varphi\\in1+K\\left[  t\\right]  ^{+}$ satisfies\r\n$\\mathfrak{f}_{1}\\left(  \\varphi\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\cdot\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  $ (by the definition\r\nof $\\mathfrak{f}_{1}$) and $\\mathfrak{f}_{2}\\left(  \\varphi\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)  $ (by the definition of\r\n$\\mathfrak{f}_{2}$). Thus, every $\\varphi\\in1+K\\left[  t\\right]  ^{+}$\r\nsatisfies%\r\n\\begin{align*}\r\n\\mathfrak{f}_{1}\\left(  \\varphi\\right)   &  =\\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  \\cdot\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  pq\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the 1st\r\nStep}\\right) \\\\\r\n&  =\\mathfrak{f}_{2}\\left(  \\varphi\\right)  .\r\n\\end{align*}\r\nIn other words, the maps $\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$ are equal\r\nto each other on the subset $1+K\\left[  t\\right]  ^{+}$. Since $1+K\\left[\r\nt\\right]  ^{+}$ is a dense subset of $1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ (by Theorem 10.18 \\textbf{(a)}), this yields that the maps\r\n$\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$ are equal to each other on a dense\r\nsubset of $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$. This proves the 2nd Step.\r\n\r\n\\textit{3rd Step:} Consider the maps $\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$\r\ndefined in the 2nd Step.\r\n\r\nThe map $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[\r\n\\left[  T\\right]  \\right]  $, $\\varphi\\mapsto\\mathfrak{Todd}_{\\varphi}\\left(\r\np\\right)  $ is continuous (by Proposition 10.19), and the map $1+K\\left[\r\n\\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[  T\\right]  \\right]\r\n$, $\\varphi\\mapsto\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)  $ is continuous\r\n(by Proposition 10.19, applied to $q$ instead of $p$). The pointwise product\r\nof these two maps is the map $1+K\\left[  \\left[  t\\right]  \\right]\r\n^{+}\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $, $\\varphi\\mapsto\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  $; this is clearly the map $\\mathfrak{f}_{1}$. Hence, we\r\nsee that the map $\\mathfrak{f}_{1}$ is the pointwise product of two continuous\r\nmaps. Thus, the map $\\mathfrak{f}_{1}$ itself is continuous (because the\r\nmultiplication map $K\\left[  \\left[  T\\right]  \\right]  \\times K\\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow K\\left[  \\left[  T\\right]  \\right]  $\r\nis continuous, and therefore the pointwise product of two continuous maps to\r\n$K\\left[  \\left[  T\\right]  \\right]  $ must be continuous itself).\r\n\r\nOn the other hand, the map $\\mathfrak{f}_{2}$ equals the map $1+K\\left[\r\n\\left[  t\\right]  \\right]  ^{+}\\rightarrow K\\left[  \\left[  T\\right]  \\right]\r\n$, $\\varphi\\mapsto\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)  $, and this map\r\nis continuous (by Proposition 10.19, applied to $pq$ instead of $p$). We thus\r\nsee that the map $\\mathfrak{f}_{2}$ is continuous.\r\n\r\nRecall the known fact that if two continuous maps from a topological space\r\n$\\mathfrak{P}$ to a Hausdorff topological space $\\mathfrak{Q}$ are equal to\r\neach other on a dense subset of $\\mathfrak{P}$, then they are equal to each\r\nother on the whole $\\mathfrak{P}$. Applying this to the two continuous maps\r\n$\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$ from the topological space\r\n$1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ to the Hausdorff topological\r\nspace $K\\left[  \\left[  T\\right]  \\right]  $, we conclude that the maps\r\n$\\mathfrak{f}_{1}$ and $\\mathfrak{f}_{2}$ are equal to each other on the whole\r\n$1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ (because we know from the 2nd\r\nStep that they are equal to each other on a dense subset of $1+K\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$).\r\n\r\nIn other words, every $\\varphi\\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$\r\nsatisfies $\\mathfrak{f}_{1}\\left(  \\varphi\\right)  =\\mathfrak{f}_{2}\\left(\r\n\\varphi\\right)  $. Since every $\\varphi\\in1+K\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ satisfies $\\mathfrak{f}_{1}\\left(  \\varphi\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  $ (by the definition of $\\mathfrak{f}_{1}$) and\r\n$\\mathfrak{f}_{2}\\left(  \\varphi\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\npq\\right)  $ (by the definition of $\\mathfrak{f}_{2}$), this rewrites as\r\nfollows: Every $\\varphi\\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$\r\nsatisfies $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  \\cdot\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  q\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)  $.\r\nThis proves Lemma 10.17.\r\n\\end{proof}\r\n\r\n\\subsection{Preparing for the proof of Theorem 10.16: some trivial\r\nfunctoriality facts}\r\n\r\nWe will eventually derive Theorem 10.16 from Lemma 10.17. This requires a very\r\neasy proposition and its corollary:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.21.} Let $\\mathbf{Z}$ and $\\mathbf{Z}^{\\prime}$ be two\r\nrings, and let $\\rho:\\mathbf{Z}\\rightarrow\\mathbf{Z}^{\\prime}$ be a ring\r\nhomomorphism. Let $j\\in\\mathbb{N}$. Clearly, the ring homomorphism\r\n$\\rho:\\mathbf{Z}\\rightarrow\\mathbf{Z}^{\\prime}$ canonically induces a ring\r\nhomomorphism $\\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]\r\n:\\mathbf{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\rightarrow\r\n\\mathbf{Z}^{\\prime}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ and\r\na ring homomorphism $\\rho\\left[  \\left[  t\\right]  \\right]  :\\mathbf{Z}\\left[\r\n\\left[  t\\right]  \\right]  \\rightarrow\\mathbf{Z}^{\\prime}\\left[  \\left[\r\nt\\right]  \\right]  $. It is also clear that the latter homomorphism\r\n$\\rho\\left[  \\left[  t\\right]  \\right]  $ maps the subset $1+\\mathbf{Z}\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$ to the subset $1+\\mathbf{Z}^{\\prime}\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$.\r\n\r\nEvery $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$\r\nsatisfies $\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  ,j}=\\rho\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{j}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\right)  $.\r\n\\end{quote}\r\n\r\nAll that this proposition tells us is that the object $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}$ is canonical with respect to the ring $\\mathbf{Z}$. You\r\nmay consider this obvious (it does, indeed, become obvious if you add to\r\nTheorem 4.1 \\textbf{(a)} the additional assertion that the polynomial $Q$, for\r\nfixed $P$, is canonical with respect to the ring $K$); if you do so, then you\r\ncan immediately continue to Corollary 10.22. Here is, however, an alternative\r\nproof of Proposition 10.21 which does not resort to this kind of handwaving:\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.21.]Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$.\r\n\r\nLet $m=j$. We are going to work in the ring $\\mathbf{Z}^{\\prime}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  =\\mathbf{Z}^{\\prime}\\left[  U_{1},U_{2}%\r\n,...,U_{j}\\right]  $. Note that the ring homomorphism $\\rho:\\mathbf{Z}%\r\n\\rightarrow\\mathbf{Z}^{\\prime}$ canonically induces a ring homomorphism\r\n$\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  :\\mathbf{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\rightarrow\\mathbf{Z}^{\\prime}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $. Also note that%\r\n\\[\r\n\\left(  \\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\right)  \\right)  \\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  =\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\right)  .\r\n\\]\r\n\\footnote{\\textit{Proof.} Let $\\rho^{\\prime}=\\rho\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $. Then, $\\rho^{\\prime}$ is the ring homomorphism\r\n$\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\rightarrow\\mathbf{Z}%\r\n^{\\prime}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ canonically induced by the\r\nring homomorphism $\\rho:\\mathbf{Z}\\rightarrow\\mathbf{Z}^{\\prime}$. Hence,\r\n$\\rho^{\\prime}$ is a $\\mathbf{Z}$-algebra homomorphism (where $\\mathbf{Z}%\r\n^{\\prime}$ becomes a $\\mathbf{Z}$-algebra by virtue of the ring homomorphism\r\n$\\rho:\\mathbf{Z}\\rightarrow\\mathbf{Z}^{\\prime}$) satisfying $\\rho^{\\prime\r\n}\\left(  U_{k}\\right)  =U_{k}$ for every $k\\in\\left\\{  1,2,...,m\\right\\}  $.\r\nThus,%\r\n\\begin{align*}\r\n\\rho^{\\prime}\\left(  X_{i}\\right)   &  =\\rho^{\\prime}\\left(  \\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }X_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}\\right) \\\\\r\n&  =\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}\\underbrace{\\rho^{\\prime}\\left(\r\nU_{k}\\right)  }_{=U_{k}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\rho^{\\prime\r\n}\\text{ is a }\\mathbf{Z}\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}=X_{i}%\r\n\\end{align*}\r\nfor every $i\\in\\mathbb{N}$. Thus, $\\left(  \\rho^{\\prime}\\left(  X_{1}\\right)\r\n,\\rho^{\\prime}\\left(  X_{2}\\right)  ,...,\\rho^{\\prime}\\left(  X_{j}\\right)\r\n\\right)  =\\left(  X_{1},X_{2},...,X_{j}\\right)  $.\r\n\\par\r\nSince $\\rho^{\\prime}$ is a $\\mathbf{Z}$-algebra homomorphism and\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}$ is a polynomial over $\\mathbf{Z}$,\r\nwe have $\\rho^{\\prime}\\left(  \\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  \\rho^{\\prime}\\left(  X_{1}\\right)  ,\\rho^{\\prime}\\left(\r\nX_{2}\\right)  ,...,\\rho^{\\prime}\\left(  X_{j}\\right)  \\right)  $ (because\r\n$\\mathbf{Z}$-algebra homomorphisms commute with polynomials over $\\mathbf{Z}%\r\n$).\r\n\\par\r\nOn the other hand, whenever $U\\in\\mathbf{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  $ is a polynomial and $x_{1}$, $x_{2}$, $...$,\r\n$x_{j}$ are $j$ elements of a commutative $\\mathbf{Z}^{\\prime}$-algebra, we\r\nhave $\\left(  \\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(\r\nU\\right)  \\right)  \\left(  x_{1},x_{2},...,x_{j}\\right)  =U\\left(  x_{1}%\r\n,x_{2},...,x_{j}\\right)  $ (because this is more or less how $U\\left(\r\nx_{1},x_{2},...,x_{j}\\right)  $ is defined). Applied to $U=\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}$ and $x_{k}=X_{k}$, this yields%\r\n\\begin{align*}\r\n\\left(  \\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\right)  \\right)  \\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)   &  =\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\underbrace{\\left(  X_{1},X_{2},...,X_{j}\\right)  }_{=\\left(  \\rho^{\\prime\r\n}\\left(  X_{1}\\right)  ,\\rho^{\\prime}\\left(  X_{2}\\right)  ,...,\\rho^{\\prime\r\n}\\left(  X_{j}\\right)  \\right)  }\\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\rho^{\\prime}\\left(\r\nX_{1}\\right)  ,\\rho^{\\prime}\\left(  X_{2}\\right)  ,...,\\rho^{\\prime}\\left(\r\nX_{j}\\right)  \\right) \\\\\r\n&  =\\underbrace{\\rho^{\\prime}}_{=\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n}\\left(  \\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\right) \\\\\r\n&  =\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\right)  ,\r\n\\end{align*}\r\nqed.}\r\n\r\nThe ring homomorphism $\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n:\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\rightarrow\\mathbf{Z}%\r\n^{\\prime}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ canonically induces a ring\r\nhomomorphism $\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[\r\nT\\right]  \\right]  :\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow\\mathbf{Z}^{\\prime}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  $ which is\r\ncontinuous with respect to the $\\left(  T\\right)  $-topology. By definition of\r\nthis ring homomorphism, the diagram%\r\n\\[\r\n\\xymatrixcolsep{6pc}\\xymatrix{\r\n\\mathbf Z\\left[U_1,U_2,...,U_m\\right]\\left[\\left[T\\right]\\right] \\ar[r]^{\\operatorname*{Coeff}_j} \\ar[d]_{\\rho\\left[U_1,U_2,...,U_m\\right]\\left[\\left[T\\right]\\right]} & \\mathbf Z\\left[U_1,U_2,...,U_m\\right] \\ar[d]^{\\rho\\left[U_1,U_2,...,U_m\\right]} \\\\\r\n\\mathbf Z^{\\prime}\\left[U_1,U_2,...,U_m\\right]\\left[\\left[T\\right]\\right] \\ar[r]^{\\operatorname*{Coeff}_j} & \\mathbf Z^{\\prime}\\left[U_1,U_2,...,U_m\\right]\r\n}\r\n\\]\r\ncommutes. Hence,\r\n\\[\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)\r\n\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\rho\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  \\left(\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  \\right)  .\r\n\\]\r\n\r\n\r\nAlso,\r\n\\[\r\n\\underbrace{\\operatorname*{Td}\\nolimits_{\\varphi,j}}%\r\n_{\\substack{=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi,j\\right)\r\n,j,\\left[  j\\right]  }\\\\=\\operatorname*{Todd}\\nolimits_{\\left(  \\varphi\r\n,j\\right)  ,j,\\left[  m\\right]  }\\\\\\text{(since }j=m\\text{)}}}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  =\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\varphi,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}%\r\n\\varphi\\left(  U_{i}T\\right)  \\right)\r\n\\]\r\n(by (\\ref{10.1.pf.1})), so that%\r\n\\begin{align}\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\right)   &\r\n=\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)\r\n\\right)  \\right) \\nonumber\\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\rho\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  \\left(  \\prod\r\n\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)  \\right)  .\r\n\\label{10.21.pf.3}%\r\n\\end{align}\r\n\r\n\r\nThe map $\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]\r\n\\right]  $ is a $\\mathbf{Z}$-algebra homomorphism continuous with respect to\r\nthe $\\left(  T\\right)  $-topology. Hence, it commutes with power series over\r\n$\\mathbf{Z}$. Thus, for every $i\\in\\left\\{  1,2,...,m\\right\\}  $, we have%\r\n\\[\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\varphi\\left(  U_{i}T\\right)  \\right)  =\\varphi\\left(  \\rho\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  \\left(\r\nU_{i}T\\right)  \\right)  .\r\n\\]\r\nSince $\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]\r\n\\right]  \\left(  U_{i}T\\right)  =U_{i}T$ (because the map $\\rho\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  $ is a ring\r\nhomomorphism which (by its definition) maps $U_{i}$ to $U_{i}$ and $T$ to\r\n$T$), this simplifies to%\r\n\\[\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\varphi\\left(  U_{i}T\\right)  \\right)  =\\varphi\\left(  U_{i}T\\right)\r\n=\\left(  \\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  \\right)  \\left(  U_{i}T\\right)  .\r\n\\]\r\nNow,%\r\n\\begin{align*}\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  \\right)   &\r\n=\\prod\\limits_{i=1}^{m}\\underbrace{\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\left[  \\left[  T\\right]  \\right]  \\left(  \\varphi\\left(  U_{i}T\\right)\r\n\\right)  }_{=\\left(  \\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  \\right)  \\left(  U_{i}T\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\rho\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  \\left[  \\left[  T\\right]  \\right]  \\text{ is a ring\r\nhomomorphism}\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  \\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  \\right)  \\left(  U_{i}T\\right)  ,\r\n\\end{align*}\r\nso that (\\ref{10.21.pf.3}) becomes%\r\n\\[\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\right)\r\n=\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\left(\r\n\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\r\n\\right)  \\right)  \\left(  U_{i}T\\right)  \\right)  .\r\n\\]\r\nCompared with%\r\n\\begin{align*}\r\n\\underbrace{\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  ,j}}%\r\n_{\\substack{=\\operatorname*{Todd}\\nolimits_{\\left(  \\left(  \\rho\\left[\r\n\\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)  ,j\\right)\r\n,j,\\left[  j\\right]  }\\\\=\\operatorname*{Todd}\\nolimits_{\\left(  \\left(\r\n\\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)\r\n,j\\right)  ,j,\\left[  m\\right]  }\\\\\\text{(since }j=m\\text{)}}}\\left(\r\nX_{1},X_{2},...,X_{j}\\right)   &  =\\operatorname*{Todd}\\nolimits_{\\left(\r\n\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\r\n\\right)  ,j\\right)  ,j,\\left[  m\\right]  }\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}^{m}\\left(\r\n\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\r\n\\right)  \\right)  \\left(  U_{i}T\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{10.1.pf.1}), applied to }\\left(\r\n\\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)  \\text{\r\ninstead of }\\varphi\\right)  ,\r\n\\end{align*}\r\nthis yields%\r\n\\begin{equation}\r\n\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\right)\r\n=\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  .\r\n\\label{10.21.pf.5}%\r\n\\end{equation}\r\n\r\n\r\nApplying Theorem 4.1 \\textbf{(a)} to $K=\\mathbf{Z}^{\\prime}$, $m=j$ and\r\n$P=\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  $,\r\nwe conclude that there exists one and only one polynomial $Q\\in\\mathbf{Z}%\r\n^{\\prime}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ such that\r\n$\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=Q\\left(  X_{1},X_{2},...,X_{j}\\right)  $. In particular, there exists\r\n\\textit{at most one} such polynomial $Q\\in\\mathbf{Z}^{\\prime}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in\\mathbf{Z}^{\\prime}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in\\mathbf{Z}^{\\prime\r\n}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\text{ are two\r\npolynomials}\\\\\r\n\\text{such that }\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[\r\nt\\right]  \\right]  \\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1}%\r\n,X_{2},...,X_{j}\\right)  =\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{j}%\r\n\\right)  \\text{ and}\\\\\r\n\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n=\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\text{, then\r\n}\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{10.21.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nLet $\\mathfrak{Q}_{1}\\in\\mathbf{Z}^{\\prime}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right]  $ be the polynomial defined by $\\mathfrak{Q}%\r\n_{1}=\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  ,j}$. Let $\\mathfrak{Q}_{2}%\r\n\\in\\mathbf{Z}^{\\prime}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $\r\nbe the polynomial defined by $\\mathfrak{Q}_{2}=\\rho\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{j}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\right)  $. We are now going to prove that $\\mathfrak{Q}%\r\n_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nSince our two polynomials $\\mathfrak{Q}_{1}$ and $\\mathfrak{Q}_{2}$ satisfy%\r\n\\[\r\n\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{j}\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  ,j}\\left(  X_{1},X_{2},...,X_{j}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{1}=\\operatorname*{Td}%\r\n\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  ,j}\\right)\r\n\\]\r\nand%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{j}\\right)   &  =\\left(  \\rho\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\right)  \\right)  \\left(  X_{1},X_{2},...,X_{j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{2}=\\rho\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\right)  \\right) \\\\\r\n&  =\\rho\\left[  U_{1},U_{2},...,U_{m}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  X_{1},X_{2},...,X_{j}\\right)  \\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  ,j}\\left(  X_{1},X_{2}%\r\n,...,X_{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{10.21.pf.5}%\r\n)}\\right)  ,\r\n\\end{align*}\r\nwe can conclude from (\\ref{10.21.pf.1}) that $\\mathfrak{Q}_{1}=\\mathfrak{Q}%\r\n_{2}$. Hence,%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}=\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n=\\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\right)  .\r\n\\]\r\nThis proves Proposition 10.21.\r\n\\end{proof}\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 10.22.} Let $\\mathbf{Z}$ and $\\mathbf{Z}^{\\prime}$ be two\r\nrings, and let $\\rho:\\mathbf{Z}\\rightarrow\\mathbf{Z}^{\\prime}$ be a ring\r\nhomomorphism. Clearly, the ring homomorphism $\\rho:\\mathbf{Z}\\rightarrow\r\n\\mathbf{Z}^{\\prime}$ canonically induces a ring homomorphism $\\rho\\left[\r\n\\left[  t\\right]  \\right]  :\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]\r\n\\rightarrow\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]  \\right]  $. It is also\r\nclear that the latter homomorphism $\\rho\\left[  \\left[  t\\right]  \\right]  $\r\nmaps the subset $1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ to the\r\nsubset $1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]  \\right]  ^{+}$.\r\n\r\nLet $K$ be a $\\mathbf{Z}^{\\prime}$-algebra. Then, $K$ also becomes a\r\n$\\mathbf{Z}$-algebra by virtue of the ring homomorphism $\\rho$. Let\r\n$\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power\r\nseries with constant term equal to $1$.\r\n\r\nLet $p\\in K\\left[  \\left[  T\\right]  \\right]  $. Then, $\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  p\\right)  =\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[\r\nt\\right]  \\right]  \\right)  \\left(  \\varphi\\right)  }\\left(  p\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary 10.22.]Clearly, the ring homomorphism $\\rho:\\mathbf{Z}%\r\n\\rightarrow\\mathbf{Z}^{\\prime}$ canonically induces a ring homomorphism\r\n$\\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  :\\mathbf{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\rightarrow\\mathbf{Z}^{\\prime\r\n}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $.\r\n\r\nLet $j\\in\\mathbb{N}$. Since $K$ is a $\\mathbf{Z}$-algebra by virtue of the\r\nring homomorphism $\\rho$, the value of $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}%\r\n\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  $ is actually\r\ndefined as%\r\n\\[\r\n\\left(  \\rho\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  \\left(\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\right)  \\right)  \\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)\r\n\\]\r\n(since $\\operatorname*{Td}\\nolimits_{\\varphi,j}$ itself is a polynomial over\r\n$\\mathbf{Z}$ rather than over $\\mathbf{Z}^{\\prime}$). Thus,%\r\n\\begin{align*}\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)   &  =\\underbrace{\\left(  \\rho\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{j}\\right]  \\left(  \\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\right)  \\right)  }_{\\substack{=\\operatorname*{Td}%\r\n\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  ,j}\\\\\\text{(by Proposition 10.21)}}}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  ,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  .\r\n\\end{align*}\r\n\r\n\r\nNow, forget that we fixed $j$. By (\\ref{ToddFrak}), we have%\r\n\\begin{align*}\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)   &  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\underbrace{\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  }_{=\\operatorname*{Td}%\r\n\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  ,j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}%\r\np,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  }T^{j}\\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\left(\r\n\\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)\r\n,j}\\left(  \\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}%\r\n\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  T^{j}.\r\n\\end{align*}\r\n\r\n\r\nOn the other hand, (\\ref{ToddFrak}) (applied to $\\mathbf{Z}^{\\prime}$ and\r\n$\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  $ instead of $\\mathbf{Z}$ and $\\varphi$) yields\r\n\\[\r\n\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  p\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}.\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)   &  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]\r\n\\right)  \\left(  \\varphi\\right)  ,j}\\left(  \\operatorname*{Coeff}%\r\n\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}p,...,\\operatorname*{Coeff}%\r\n\\nolimits_{j}p\\right)  T^{j}\\\\\r\n&  =\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  p\\right)  .\r\n\\end{align*}\r\nThis proves Corollary 10.22.\r\n\\end{proof}\r\n\r\n\\subsection{Proof of Theorems 10.16 and 10.10}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.16.]Since $K$ is a $\\mathbf{Z}$-algebra, there is a\r\ncanonical ring homomorphism $\\rho:\\mathbf{Z}\\rightarrow K$. This homomorphism\r\ninduces a canonical ring homomorphism $\\rho\\left[  \\left[  t\\right]  \\right]\r\n:\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  \\rightarrow K\\left[  \\left[\r\nt\\right]  \\right]  $, which maps the subset $1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ to $1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$.\r\nThus, $\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  \\in1+K\\left[  \\left[  t\\right]  \\right]  ^{+}$ (since\r\n$\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$).\r\n\r\nCorollary 10.22 yields $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)\r\n=\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  p\\right)  $. Corollary 10.22 (applied to $q$\r\ninstead of $p$) yields $\\mathfrak{Todd}_{\\varphi}\\left(  q\\right)\r\n=\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  q\\right)  $. Corollary 10.22 (applied to $pq$\r\ninstead of $p$) yields $\\mathfrak{Todd}_{\\varphi}\\left(  pq\\right)\r\n=\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  pq\\right)  $. Lemma 10.17 (applied to\r\n$\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  $ instead of $\\varphi$) yields $\\mathfrak{Todd}_{\\left(\r\n\\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)\r\n}\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  }\\left(  q\\right)  =\\mathfrak{Todd}%\r\n_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  }\\left(  pq\\right)  $. Now,\r\n\\[\r\n\\underbrace{\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  }_{=\\mathfrak{Todd}%\r\n_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  }\\left(  p\\right)  }\\cdot\\underbrace{\\mathfrak{Todd}_{\\varphi\r\n}\\left(  q\\right)  }_{=\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]\r\n\\right]  \\right)  \\left(  \\varphi\\right)  }\\left(  q\\right)  }=\\mathfrak{Todd}%\r\n_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)  \\left(\r\n\\varphi\\right)  }\\left(  p\\right)  \\cdot\\mathfrak{Todd}_{\\left(  \\rho\\left[\r\n\\left[  t\\right]  \\right]  \\right)  \\left(  \\varphi\\right)  }\\left(  q\\right)\r\n=\\mathfrak{Todd}_{\\left(  \\rho\\left[  \\left[  t\\right]  \\right]  \\right)\r\n\\left(  \\varphi\\right)  }\\left(  pq\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\npq\\right)  .\r\n\\]\r\nTheorem 10.16 is thus proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.10.]Theorem 2.1 \\textbf{(a)} yields $\\lambda_{T}\\left(\r\nx\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda_{T}\\left(  x+y\\right)  $\r\n(since $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\n$\\lambda$-ring). Proposition 10.11 yields $\\operatorname*{td}_{\\varphi\r\n,T}\\left(  x\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  $. Proposition 10.11 (applied to $y$ instead of $x$) yields\r\n$\\operatorname*{td}_{\\varphi,T}\\left(  y\\right)  =\\mathfrak{Todd}_{\\varphi\r\n}\\left(  \\lambda_{T}\\left(  y\\right)  \\right)  $. Hence,%\r\n\\begin{align*}\r\n&  \\underbrace{\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)\r\n}_{=\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n}\\cdot\\underbrace{\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  y\\right)\r\n}_{=\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  y\\right)  \\right)\r\n}=\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\cdot\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  y\\right)  \\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\r\n\\lambda_{T}\\left(  y\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 10.16, applied to }%\r\np=\\lambda_{T}\\left(  x\\right)  \\text{ and }q=\\lambda_{T}\\left(  y\\right)\r\n\\right)  .\r\n\\end{align*}\r\nProposition 10.11 (applied to $x+y$ instead of $x$) yields%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x+y\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  \\underbrace{\\lambda_{T}\\left(  x+y\\right)  }%\r\n_{\\substack{=\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)\r\n}}\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\cdot\\lambda_{T}\\left(  y\\right)  \\right)  .\r\n\\]\r\nThus,%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  \\cdot\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  y\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(\r\ny\\right)  \\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x+y\\right)\r\n.\r\n\\]\r\nTheorem 10.10 is thus proven.\r\n\\end{proof}\r\n\r\n\\subsection{ $\\operatorname*{td}_{\\varphi,T}$ is a homomorphism of additive\r\ngroups}\r\n\r\nA slightly improved restatement of Theorem 10.10:\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 10.23.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\nThen, $\\operatorname*{td}_{\\varphi,T}\\left(  K\\right)  \\subseteq\\Lambda\\left(\r\nK\\right)  $, and $\\operatorname*{td}_{\\varphi,T}:K\\rightarrow\\Lambda\\left(\r\nK\\right)  $ is a homomorphism of additive groups.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary 10.23.]Every $x\\in K$ satisfies $\\operatorname*{td}%\r\n_{\\varphi,T}\\left(  x\\right)  \\in\\Lambda\\left(  K\\right)  $ (since Proposition\r\n10.5 \\textbf{(a)} says that $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\operatorname*{td}_{\\varphi,T}\\left(  x\\right)  \\right)  =1$, so that the\r\npower series $\\operatorname*{td}_{\\varphi,T}\\left(  x\\right)  $ has the\r\nconstant term $1$, and thus $\\operatorname*{td}_{\\varphi,T}\\left(  x\\right)\r\n\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $). In\r\nother words, $\\operatorname*{td}_{\\varphi,T}\\left(  K\\right)  \\subseteq\r\n\\Lambda\\left(  K\\right)  $.\r\n\r\nNow we are going to prove that $\\operatorname*{td}_{\\varphi,T}:K\\rightarrow\r\n\\Lambda\\left(  K\\right)  $ is a homomorphism of additive groups.\r\n\r\nTheorem 10.10 (applied to $x=0$ and $y=0$) yields $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  0\\right)  \\cdot\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  0\\right)  =\\operatorname*{td}\\nolimits_{\\varphi\r\n,T}\\left(  0+0\\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(\r\n0\\right)  $. Since $\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  0\\right)  $\r\nis an invertible element of $K\\left[  \\left[  T\\right]  \\right]  $ (because\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  0\\right)  $ is a power series\r\nwith constant term $1$\\ \\ \\ \\ \\footnote{since $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  0\\right)  \\in\\operatorname*{td}\\nolimits_{\\varphi\r\n,T}\\left(  K\\right)  \\subseteq\\Lambda\\left(  K\\right)  =1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$}, and every such power series is an invertible\r\nelement of $K\\left[  \\left[  T\\right]  \\right]  $), we can cancel\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  0\\right)  $ from this\r\nequation, and obtain $\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  0\\right)\r\n=1$. Since $0$ is the neutral element of the additive group $K$, while $1$ is\r\nthe neutral element of the additive group $\\Lambda\\left(  K\\right)  $, this\r\nyields that the map $\\operatorname*{td}\\nolimits_{\\varphi,T}$ respects the\r\nneutral elements of the additive groups $K$ and $\\Lambda\\left(  K\\right)  $.\r\n\r\nAny $x\\in K$ and $y\\in K$ satisfy%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x+y\\right)   &\r\n=\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  \\cdot\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  y\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 10.10}\\right) \\\\\r\n&  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)  \\widehat{+}%\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  y\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since multiplication of power series}\\\\\r\n\\text{in }1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\text{ is addition in the\r\nring }\\Lambda\\left(  K\\right)\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\nCombined with the fact that the map $\\operatorname*{td}\\nolimits_{\\varphi,T}$\r\nrespects the neutral elements of the additive groups $K$ and $\\Lambda\\left(\r\nK\\right)  $, this yields: The map $\\operatorname*{td}_{\\varphi,T}%\r\n:K\\rightarrow\\Lambda\\left(  K\\right)  $ is a homomorphism of additive groups.\r\nCorollary 10.23 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{ $\\operatorname*{td}_{\\varphi,T}$ of a $1$-dimensional element}\r\n\r\nNext on our plan is to compute $\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(\r\nx\\right)  $ for $x$ any $1$-dimensional element of $K$. We recall that we\r\ndefined the notion of a $1$-dimensional element of a $\\lambda$-ring in Section 8.\r\n\r\nOur main claim here is:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.24.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $u$ be a $1$-dimensional element of $K$.\r\nLet $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power\r\nseries with constant term equal to $1$. Then, $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  u\\right)  =\\varphi\\left(  uT\\right)  $.\r\n\\end{quote}\r\n\r\nFor the proof of this, we again have to study the universal polynomials\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}$:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.25.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$. Let $j\\in\\mathbb{N}$. Let $\\varphi_{j}$ denote the\r\ncoefficient of the power series $\\varphi\\in1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ before $t^{j}$. Then, in the polynomial ring\r\n$\\mathbf{Z}\\left[  S\\right]  $, we have $\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\left(  S,0,0,...,0\\right)  =\\varphi_{j}S^{j}$. (Here, when $j=0$, the term\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  S,0,0,...,0\\right)  $ is\r\nunderstood to denote $\\operatorname*{Td}\\nolimits_{\\varphi,j}$.)\r\n\\end{quote}\r\n\r\nAnd again, we can generalize Proposition 10.24 (and in fact, we are going to\r\nprove Proposition 10.24 via this generalization):\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.26.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$. Let $K$ be a $\\mathbf{Z}$-algebra. Let $u\\in K$.\r\nThen, $\\mathfrak{Todd}_{\\varphi}\\left(  1+uT\\right)  =\\varphi\\left(\r\nuT\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.25.]Let $m=1$. Consider the ring $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ and its elements $X_{i}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}$ as in the definition of\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}$.\r\n\r\nSince $m=1$, we have $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n=\\mathbf{Z}\\left[  U_{1}\\right]  $, and in this ring $\\mathbf{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ we have $X_{1}=U_{1}$ (because $X_{1}$ is the\r\n$1$-st elementary symmetric polynomial of the one variable $U_{1}$).\r\n\r\nFor every integer $i>1$, we have%\r\n\\begin{align*}\r\nX_{i}  &  =\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}=\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1\\right\\}  ;\\\\\\left\\vert S\\right\\vert\r\n=i}}\\prod\\limits_{k\\in S}U_{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}m=1\\text{, so that }\\left\\{  1,2,...,m\\right\\}  =\\left\\{  1\\right\\}  \\right)\r\n\\\\\r\n&  =\\left(  \\text{empty sum}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\nthere doesn't exist any }S\\subseteq\\left\\{  1\\right\\}  \\text{ with }\\left\\vert\r\nS\\right\\vert =i\\text{ (because }i>1\\text{)}\\right) \\\\\r\n&  =0\r\n\\end{align*}\r\nin the ring $\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $. Thus, $\\left(\r\nX_{2},X_{3},...,X_{j}\\right)  =\\left(  0,0,...,0\\right)  $. Combining this\r\nwith $X_{1}=U_{1}$, we obtain $\\left(  X_{1},X_{2},...,X_{j}\\right)  =\\left(\r\nU_{1},0,0,...,0\\right)  $.\r\n\r\nWe know from Theorem 10.1 that (\\ref{Td1}) holds in the ring $\\left(\r\n\\mathbf{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  \\left[\r\nT\\right]  \\right]  $. In other words,%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\sum_{i\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  X_{1},X_{2},...,X_{i}\\right)\r\nT^{i}%\r\n\\]\r\n(this follows from (\\ref{Td1}) upon renaming the index $j$ as $i$). Since\r\n$\\prod\\limits_{i=1}^{m}\\varphi\\left(  U_{i}T\\right)  =\\varphi\\left(\r\nU_{1}T\\right)  $ (because $m=1$), this rewrites as\r\n\\[\r\n\\varphi\\left(  U_{1}T\\right)  =\\sum_{i\\in\\mathbb{N}}\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,i}\\left(  X_{1},X_{2},...,X_{i}\\right)  T^{i}.\r\n\\]\r\nThus,%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\varphi\\left(  U_{1}T\\right)\r\n\\right)   &  =\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\sum_{i\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,i}\\left(  X_{1},X_{2},...,X_{i}\\right)\r\nT^{i}\\right)  =\\operatorname*{Td}\\nolimits_{\\varphi,j}\\underbrace{\\left(\r\nX_{1},X_{2},...,X_{j}\\right)  }_{=\\left(  U_{1},0,0,...,0\\right)  }\\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  U_{1},0,0,...,0\\right)  .\r\n\\end{align*}\r\nCompared with%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\varphi\\left(  U_{1}T\\right)\r\n\\right)   &  =\\left(  \\text{the coefficient of the power series }%\r\n\\varphi\\left(  U_{1}T\\right)  \\text{ before }T^{j}\\right) \\\\\r\n&  =U_{1}^{j}\\underbrace{\\left(  \\text{the coefficient of the power series\r\n}\\varphi\\text{ before }t^{j}\\right)  }_{=\\varphi_{j}}=U_{1}^{j}\\varphi\r\n_{j}=\\varphi_{j}U_{1}^{j},\r\n\\end{align*}\r\nthis yields\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  U_{1},0,0,...,0\\right)\r\n=\\varphi_{j}U_{1}^{j}.\r\n\\]\r\n\r\n\r\nNow, let $\\kappa$ be the $\\mathbf{Z}$-algebra homomorphism $\\mathbf{Z}\\left[\r\nS\\right]  \\rightarrow\\mathbf{Z}\\left[  U_{1}\\right]  $ which maps $S$ to\r\n$U_{1}$. This homomorphism $\\kappa$ must be an isomorphism (since $U_{1}$ is\r\nobviously algebraically independent). Since $\\kappa$ is a $\\mathbf{Z}$-algebra\r\nhomomorphism and $\\operatorname*{Td}\\nolimits_{\\varphi,j}$ is a polynomial, we\r\nhave $\\kappa\\left(  \\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nS,0,0,...,0\\right)  \\right)  =\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\kappa\\left(  S\\right)  ,\\kappa\\left(  0\\right)  ,\\kappa\\left(  0\\right)\r\n,...,\\kappa\\left(  0\\right)  \\right)  $ (because $\\mathbf{Z}$-algebra\r\nhomomorphisms commute with polynomials). But $\\left(  \\kappa\\left(  S\\right)\r\n,\\kappa\\left(  0\\right)  ,\\kappa\\left(  0\\right)  ,...,\\kappa\\left(  0\\right)\r\n\\right)  =\\left(  U_{1},0,0,...,0\\right)  $ (since $\\kappa\\left(  S\\right)\r\n=U_{1}$ and $\\kappa\\left(  0\\right)  =0$). Thus,%\r\n\\begin{align*}\r\n\\kappa\\left(  \\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nS,0,0,...,0\\right)  \\right)   &  =\\operatorname*{Td}\\nolimits_{\\varphi\r\n,j}\\underbrace{\\left(  \\kappa\\left(  S\\right)  ,\\kappa\\left(  0\\right)\r\n,\\kappa\\left(  0\\right)  ,...,\\kappa\\left(  0\\right)  \\right)  }_{=\\left(\r\nU_{1},0,0,...,0\\right)  }=\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nU_{1},0,0,...,0\\right)  =\\varphi_{j}U_{1}^{j}\\\\\r\n&  =\\varphi_{j}\\kappa\\left(  S\\right)  ^{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }U_{1}=\\kappa\\left(  S\\right)  \\right) \\\\\r\n&  =\\kappa\\left(  \\varphi_{j}S^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\kappa\\text{ is a }\\mathbf{Z}\\text{-algebra homomorphism}\\right)\r\n.\r\n\\end{align*}\r\nThus, $\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  S,0,0,...,0\\right)\r\n=\\varphi_{j}S^{j}$ (since $\\kappa$ is an isomorphism). This proves Proposition 10.25.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.26.]For every $j\\in\\mathbb{N}$, let $\\varphi_{j}$\r\ndenote the coefficient of the power series $\\varphi\\in1+\\mathbf{Z}\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$ before $t^{j}$. Let $p=1+uT$. Then,\r\n$\\operatorname*{Coeff}\\nolimits_{1}p=u$ (by the definition of\r\n$\\operatorname*{Coeff}\\nolimits_{1}$) and $\\operatorname*{Coeff}%\r\n\\nolimits_{i}p=0$ for every integer $i>1$.\r\n\r\nLet $j\\in\\mathbb{N}$ be arbitrary. Proposition 10.25 yields\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  S,0,0,...,0\\right)\r\n=\\varphi_{j}S^{j}$ in the polynomial ring $\\mathbf{Z}\\left[  S\\right]  $.\r\nApplying this polynomial identity to $S=u$, we obtain $\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,j}\\left(  u,0,0,...,0\\right)  =\\varphi_{j}u^{j}$.\r\n\r\nOn the other hand, $\\left(  \\operatorname*{Coeff}\\nolimits_{2}%\r\np,\\operatorname*{Coeff}\\nolimits_{3}p,...,\\operatorname*{Coeff}\\nolimits_{j}%\r\np\\right)  =\\left(  0,0,...,0\\right)  $ (since $\\operatorname*{Coeff}%\r\n\\nolimits_{i}p=0$ for every integer $i>1$). Combining this with\r\n$\\operatorname*{Coeff}\\nolimits_{1}p=u$, we obtain%\r\n\\[\r\n\\left(  \\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}%\r\n\\nolimits_{2}p,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  =\\left(\r\nu,0,0,...,0\\right)  .\r\n\\]\r\nThus,%\r\n\\[\r\n\\operatorname*{Td}\\nolimits_{\\varphi,j}\\underbrace{\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  }_{=\\left(\r\nu,0,0,...,0\\right)  }=\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\nu,0,0,...,0\\right)  =\\varphi_{j}u^{j}.\r\n\\]\r\n\r\n\r\nNow forget that we fixed $j\\in\\mathbb{N}$. By (\\ref{ToddFrak}), we have%\r\n\\[\r\n\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n}\\underbrace{\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}p,\\operatorname*{Coeff}\\nolimits_{2}%\r\np,...,\\operatorname*{Coeff}\\nolimits_{j}p\\right)  }_{=\\varphi_{j}u^{j}}%\r\nT^{j}=\\sum\\limits_{j\\in\\mathbb{N}}\\varphi_{j}\\underbrace{u^{j}T^{j}}_{=\\left(\r\nuT\\right)  ^{j}}=\\sum\\limits_{j\\in\\mathbb{N}}\\varphi_{j}\\left(  uT\\right)\r\n^{j}.\r\n\\]\r\nOn the other hand, $\\varphi=\\sum\\limits_{j\\in\\mathbb{N}}\\varphi_{j}t^{j}$\r\n(since the coefficient of the power series $\\varphi$ before $t^{j}$ is\r\n$\\varphi_{j}$ for every $j\\in\\mathbb{N}$) and thus $\\varphi\\left(  uT\\right)\r\n=\\sum\\limits_{j\\in\\mathbb{N}}\\varphi_{j}\\left(  uT\\right)  ^{j}$.\r\n\r\nAltogether, $\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}}\\varphi_{j}\\left(  uT\\right)  ^{j}=\\varphi\\left(  uT\\right)  $.\r\nSince $1+uT=p$, we have $\\mathfrak{Todd}_{\\varphi}\\left(  1+uT\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  p\\right)  =\\varphi\\left(  uT\\right)  $. This\r\nproves Proposition 10.26.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.24.]Proposition 10.11 (applied to $x=u$) yields\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  \\lambda_{T}\\left(  u\\right)  \\right)  $. But Theorem 8.3\r\n\\textbf{(a)} (applied to $x=u$) yields that $\\lambda_{T}\\left(  u\\right)\r\n=1+uT$ (since the element $u$ is $1$-dimensional). Thus, $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  u\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\n\\underbrace{\\lambda_{T}\\left(  u\\right)  }_{=1+uT}\\right)  =\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  1+uT\\right)  =\\varphi\\left(  uT\\right)  $ (by Proposition\r\n10.26). This proves Proposition 10.24.\r\n\\end{proof}\r\n\r\nAs a consequence of Proposition 10.24, we can obtain the following formula for\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}$ on sums of $1$-dimensional elements:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.27.} Let $\\mathbf{Z}$ be a ring. Let $\\varphi\r\n\\in1+\\mathbf{Z}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power series with\r\nconstant term equal to $1$. Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that $K$ is a\r\n$\\mathbf{Z}$-algebra. Let $u_{1}$, $u_{2}$, $...$, $u_{m}$ be $1$-dimensional\r\nelements of $K$. Then,%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u_{1}+u_{2}+...+u_{m}\\right)\r\n=\\prod\\limits_{i=1}^{m}\\varphi\\left(  u_{i}T\\right)  .\r\n\\]\r\n\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.27.]By Corollary 10.23, we know that $\\operatorname*{td}%\r\n_{\\varphi,T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ is a homomorphism of\r\nadditive groups. Hence,%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  \\sum\\limits_{i=1}^{m}%\r\nu_{i}\\right)   &  =\\widehat{\\sum\\limits_{i=1}^{m}}\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  u_{i}\\right)  =\\prod\\limits_{i=1}^{m}%\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u_{i}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since the addition in the ring }\\Lambda\\left(  K\\right)  \\text{ is the\r\nmultiplication of power series,}\\\\\r\n\\text{so that }\\widehat{\\sum\\limits_{i=1}^{m}}=\\prod\\limits_{i=1}^{m}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\varphi\\left(  u_{i}T\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because every }i\\in\\left\\{  1,2,...,m\\right\\}  \\text{ satisfies\r\n}\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u_{i}\\right)  =\\varphi\\left(\r\nu_{i}T\\right) \\\\\r\n\\text{(by Proposition 10.24, applied to }u=u_{i}\\text{)}%\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\nSince $\\sum\\limits_{i=1}^{m}u_{i}=u_{1}+u_{2}+...+u_{m}$, this rewrites as\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u_{1}+u_{2}+...+u_{m}\\right)\r\n=\\prod\\limits_{i=1}^{m}\\varphi\\left(  u_{i}T\\right)  $. Theorem 10.27 is thus proven.\r\n\\end{proof}\r\n\r\n\\subsection{ $\\operatorname*{td}_{\\varphi,T}$ for special $\\lambda$-rings}\r\n\r\nTheorem 10.27 gives us a shortcut to working with $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}$ in the case when $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a \\textit{special} $\\lambda$-ring: In fact, in\r\nthis case, we can often prove a property of an arbitrary element of a special\r\n$\\lambda$-ring just by proving it for sums of $1$-dimensional elements\r\n(because of Theorem 8.4), and Theorem 10.27 gives us an explicit formula for\r\nthe value of $\\operatorname*{td}\\nolimits_{\\varphi,T}$ at every sum of\r\n$1$-dimensional elements. The next theorem (Theorem 10.28) will give an\r\nexample of this. First, a definition.\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. Let\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a\r\n$\\lambda$-ring. Define a homomorphism $\\theta_{T}^{j}:K\\rightarrow\r\n\\Lambda\\left(  K\\right)  $ of additive groups by $\\theta_{T}^{j}%\r\n=\\operatorname*{td}_{\\varphi_{j},T}$, where $\\varphi_{j}\\in\\mathbb{Z}\\left[\r\nt\\right]  $ is the polynomial $1+t+t^{2}+...+t^{j-1}=\\dfrac{1-t^{j}}{1-t}$.\r\n\\end{quote}\r\n\r\n[Again, \\cite{FulLan85} considers only $\\theta^{j}:=\\theta_{1}^{j}$, which\r\nagain is defined on $x$ only if $x$ is finite-dimensional. These $\\theta^{j}$\r\n(or $\\theta^{j}\\left(  x\\right)  $ ?) are called \\textit{Bott's cannibalistic\r\nclasses}, for whatever reason.]\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.28.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special $\\lambda$-ring. Let $x\\in K$. Let\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. Let $\\operatorname*{fr}%\r\n\\nolimits_{j}:K\\left[  \\left[  T\\right]  \\right]  \\rightarrow K\\left[  \\left[\r\nT\\right]  \\right]  $ be the map which sends every power series $\\sum\r\n\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}$ (with $a_{i}\\in K$ for every\r\n$i\\in\\mathbb{N}$) to the power series $\\sum\\limits_{i\\in\\mathbb{N}}a_{i}%\r\nT^{ji}$. Then, $\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[\r\n\\left[  T\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)\r\n\\right)  \\right)  =\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)\r\n=\\lambda_{-T}\\left(  x\\right)  \\theta_{T}^{j}\\left(  x\\right)  $ (where\r\n$\\psi^{j}\\left[  \\left[  T\\right]  \\right]  $ means the homomorphism $K\\left[\r\n\\left[  T\\right]  \\right]  \\rightarrow K\\left[  \\left[  T\\right]  \\right]  $\r\ndefined by $\\left(  \\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\right)\r\n\\left(  \\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\psi^{j}\\left(  a_{i}\\right)  T^{i}$ for every power series\r\n$\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\in K\\left[  \\left[  T\\right]  \\right]\r\n$).\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.28.]\\textit{1st Step:} The equality $\\operatorname*{td}%\r\n\\nolimits_{1-t^{j},T}\\left(  x\\right)  =\\lambda_{-T}\\left(  x\\right)\r\n\\theta_{T}^{j}\\left(  x\\right)  $ holds for every $x\\in K$ (no matter whether\r\nthe $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ is special or not).\r\n\r\n\\textit{Proof.} Let $\\varphi_{j}\\in\\mathbb{Z}\\left[  t\\right]  $ be the\r\npolynomial $1+t+t^{2}+...+t^{j-1}=\\dfrac{1-t^{j}}{1-t}$. According to the\r\ndefinition of $\\theta_{T}^{j}$, we have $\\theta_{T}^{j}=\\operatorname*{td}%\r\n_{\\varphi_{j},T}$.\r\n\r\nLet $x\\in K$. Applying Proposition 10.7 to $\\mathbf{Z}=\\mathbb{Z}$,\r\n$\\varphi=1-t$ and $\\psi=\\varphi_{j}$, we obtain $\\operatorname*{td}%\r\n\\nolimits_{\\varphi\\psi,T}\\left(  x\\right)  =\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T}\\left(  x\\right)  \\operatorname*{td}\\nolimits_{\\psi\r\n,T}\\left(  x\\right)  $. Since%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi\\psi,T}\\left(  x\\right)\r\n=\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because }\\varphi=1-t\\text{ and }\\psi=\\varphi_{j}=\\dfrac{1-t^{j}}%\r\n{1-t}\\text{,}\\\\\r\n\\text{so that }\\varphi\\psi=\\left(  1-t\\right)  \\cdot\\dfrac{1-t^{j}}%\r\n{1-t}=1-t^{j}%\r\n\\end{array}\r\n\\right)  ,\r\n\\]%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)   &\r\n=\\operatorname*{td}\\nolimits_{1+\\left(  -1\\right)  t,T}\\left(  x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\varphi=1-t=1+\\left(  -1\\right)\r\nt\\right) \\\\\r\n&  =\\lambda_{\\left(  -1\\right)  T}\\left(  x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Proposition 10.3, applied to }%\r\n\\mathbf{Z}=\\mathbb{Z}\\text{ and }u=-1\\right) \\\\\r\n&  =\\lambda_{-T}\\left(  x\\right)\r\n\\end{align*}\r\nand%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\psi,T}\\left(  x\\right)   &\r\n=\\underbrace{\\operatorname*{td}\\nolimits_{\\varphi_{j},T}}_{=\\theta_{T}^{j}%\r\n}\\left(  x\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\psi=\\varphi\r\n_{j}\\right) \\\\\r\n&  =\\theta_{T}^{j}\\left(  x\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)\r\n=\\lambda_{-T}\\left(  x\\right)  \\theta_{T}^{j}\\left(  x\\right)  $. This proves\r\nthe 1st Step.\r\n\r\n\\textit{2nd Step:} A remark about the map $\\operatorname*{fr}\\nolimits_{j}$:\r\nThis map sends every power series $P\\in K\\left[  \\left[  T\\right]  \\right]  $\r\nto the power series $P\\left(  T^{j}\\right)  $. It is easy to see that this map\r\n$\\operatorname*{fr}\\nolimits_{j}$ is a $K$-algebra homomorphism continuous\r\nwith respect to the $\\left(  T\\right)  $-topology. It satisfies\r\n$\\operatorname*{fr}\\nolimits_{j}\\left(  T\\right)  =T^{j}$ (obviously) and can\r\nbe shown to be the only continuous (with respect to the $\\left(  T\\right)\r\n$-topology) $K$-algebra homomorphism $K\\left[  \\left[  T\\right]  \\right]\r\n\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ which sends $T$ to $T^{j}$.\r\n\r\n\\textit{3rd Step:} The equality $\\operatorname*{fr}\\nolimits_{j}\\left(\r\n\\left(  \\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\lambda_{-T}\\left(  x\\right)  \\right)  \\right)  =\\operatorname*{td}%\r\n\\nolimits_{1-t^{j},T}\\left(  x\\right)  $ holds for every special $\\lambda\r\n$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and\r\nevery $x\\in K$ such that $x$ is the sum of finitely many $1$-dimensional\r\nelements of $K$.\r\n\r\n\\textit{Proof.} Let $\\varphi=1-t^{j}$.\r\n\r\nLet $x\\in K$ be such that $x$ is the sum of finitely many $1$-dimensional\r\nelements of $K$. In other words, $x=u_{1}+u_{2}+...+u_{m}$ for some\r\n$1$-dimensional elements $u_{1}$, $u_{2}$, $...$, $u_{m}$ of $K$. Consider\r\nthese elements $u_{1}$, $u_{2}$, $...$, $u_{m}$. Then,%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  x\\right)   &\r\n=\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(  u_{1}+u_{2}+...+u_{m}\\right)\r\n=\\prod\\limits_{i=1}^{m}\\underbrace{\\varphi\\left(  u_{i}T\\right)\r\n}_{\\substack{=1-\\left(  u_{i}T\\right)  ^{j}\\\\\\text{(since }\\varphi\r\n=1-t^{j}\\text{)}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 10.27}\\right)\r\n\\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1-\\underbrace{\\left(  u_{i}T\\right)  ^{j}%\r\n}_{=u_{i}^{j}T^{j}}\\right)  =\\prod\\limits_{i=1}^{m}\\left(  1-u_{i}^{j}%\r\nT^{j}\\right)  .\r\n\\end{align*}\r\nOn the other hand, $x=u_{1}+u_{2}+...+u_{m}=\\sum\\limits_{i=1}^{m}u_{i}$, so\r\nthat%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  x\\right)   &  =\\lambda_{T}\\left(  \\sum\\limits_{i=1}%\r\n^{m}u_{i}\\right)  =\\widehat{\\sum\\limits_{i=1}^{m}}\\lambda_{T}\\left(\r\nu_{i}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\lambda_{T}\\text{ is a\r\nring homomorphism}\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\lambda_{T}\\left(  u_{i}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since the addition in the ring }\\Lambda\\left(  K\\right)  \\text{ is\r\nthe}\\\\\r\n\\text{ multiplication of power series, and thus }\\widehat{\\sum\\limits_{i=1}%\r\n^{m}}=\\prod\\limits_{i=1}^{m}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1+u_{i}T\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n%\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because every }i\\in\\left\\{  1,2,...,m\\right\\}  \\text{ satisfies }%\r\n\\lambda_{T}\\left(  u_{i}\\right)  =1+u_{i}T\\\\\r\n\\text{(by Theorem 8.3 \\textbf{(a)} (applied to }u_{i}\\text{ instead of\r\n}x\\text{),}\\\\\r\n\\text{since }u_{i}\\text{ is }1\\text{-dimensional)}%\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\nNow,%\r\n\\begin{align*}\r\n\\lambda_{-T}\\left(  x\\right)   &  =\\operatorname*{ev}\\nolimits_{-T}\\left(\r\n\\underbrace{\\lambda_{T}\\left(  x\\right)  }_{=\\prod\\limits_{i=1}^{m}\\left(\r\n1+u_{i}T\\right)  }\\right)  =\\operatorname*{ev}\\nolimits_{-T}\\left(\r\n\\prod\\limits_{i=1}^{m}\\left(  1+u_{i}T\\right)  \\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\underbrace{\\operatorname*{ev}\\nolimits_{-T}\\left(\r\n1+u_{i}T\\right)  }_{\\substack{=1-u_{i}T\\\\\\text{(by the definition of\r\n}\\operatorname*{ev}\\nolimits_{-T}\\text{)}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\operatorname*{ev}\\nolimits_{-T}\\text{ is a ring homomorphism}%\r\n\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1-u_{i}T\\right)  .\r\n\\end{align*}\r\nThus,%\r\n\\begin{align*}\r\n\\left(  \\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\lambda_{-T}\\left(  x\\right)  \\right)   &  =\\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\prod\\limits_{i=1}^{m}\\left(\r\n1-u_{i}T\\right)  \\right)  =\\prod\\limits_{i=1}^{m}\\left(  1-\\underbrace{\\left(\r\n\\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  u_{i}T\\right)\r\n}_{\\substack{=\\psi^{j}\\left(  u_{i}\\right)  T\\\\\\text{(by the definition of\r\n}\\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\text{)}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\psi^{j}\\left[  \\left[  T\\right]\r\n\\right]  \\text{ is a ring homomorphism}\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1-\\psi^{j}\\left(  u_{i}\\right)  T\\right)  ,\r\n\\end{align*}\r\nso that%\r\n\\begin{align*}\r\n\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)   &  =\\operatorname*{fr}\\nolimits_{j}\\left(  \\prod\\limits_{i=1}%\r\n^{m}\\left(  1-\\psi^{j}\\left(  u_{i}\\right)  T\\right)  \\right)  =\\prod\r\n\\limits_{i=1}^{m}\\left(  1-\\psi^{j}\\left(  u_{i}\\right)\r\n\\underbrace{\\operatorname*{fr}\\nolimits_{j}\\left(  T\\right)  }_{=T^{j}}\\right)\r\n\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{fr}\\nolimits_{j}%\r\n\\text{ is a }K\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1-\\psi^{j}\\left(  u_{i}\\right)\r\nT^{j}\\right)  .\r\n\\end{align*}\r\n\r\n\r\nNow, for every $i\\in\\left\\{  1,2,...,m\\right\\}  $, we can apply Theorem 9.4 to\r\n$1$ and $u_{i}$ instead of $m$ and $u_{i}$, and obtain $\\psi^{j}\\left(\r\nu_{i}\\right)  =u_{i}^{j}$. Hence,%\r\n\\[\r\n\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)  =\\prod\\limits_{i=1}^{m}\\left(  1-\\underbrace{\\psi^{j}\\left(\r\nu_{i}\\right)  }_{=u_{i}^{j}}T^{j}\\right)  =\\prod\\limits_{i=1}^{m}\\left(\r\n1-u_{i}^{j}T^{j}\\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T}\\left(\r\nx\\right)  =\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)\r\n\\]\r\n(since $\\varphi=1-t^{j}$). This proves the 3rd Step.\r\n\r\n\\textit{4th Step:} The equality $\\operatorname*{fr}\\nolimits_{j}\\left(\r\n\\left(  \\psi^{j}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\lambda_{-T}\\left(  x\\right)  \\right)  \\right)  =\\operatorname*{td}%\r\n\\nolimits_{1-t^{j},T}\\left(  x\\right)  $ holds for every special $\\lambda\r\n$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and\r\nevery $x\\in K$.\r\n\r\n\\textit{Proof.} We want to derive this from the 3rd Step by applying Theorem 8.4.\r\n\r\nFix some $k\\in\\mathbb{N}$.\r\n\r\nDefine a $1$-operation $m$ of special $\\lambda$-rings by $m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }=\\operatorname*{Coeff}%\r\n\\nolimits_{k}\\circ\\operatorname*{fr}\\nolimits_{j}\\circ\\left(  \\psi^{j}\\left[\r\n\\left[  T\\right]  \\right]  \\right)  \\circ\\lambda_{-T}$ for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $. (This is indeed a $1$-operation, since (\\ref{PsiDef}) shows that\r\n$\\psi^{j}$ is a polynomial in $\\lambda^{1}$, $\\lambda^{2}$, $...$,\r\n$\\lambda^{j}$ with integer coefficients.)\r\n\r\nDefine a $1$-operation $m^{\\prime}$ of special $\\lambda$-rings by $m_{\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime\r\n}=\\operatorname*{Coeff}\\nolimits_{k}\\circ\\operatorname*{td}\\nolimits_{1-t^{j}%\r\n,T}$ for every $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $. (This is, again, a $1$-operation, since\r\n(\\ref{ToddDef}) shows that $\\operatorname*{Coeff}\\nolimits_{k}\\circ\r\n\\operatorname*{td}\\nolimits_{1-t^{j},T}=\\operatorname*{Td}\\nolimits_{1-t^{j}%\r\n,k}\\left(  \\lambda^{1},\\lambda^{2},...,\\lambda^{k}\\right)  $ is a polynomial\r\nin $\\lambda^{1}$, $\\lambda^{2}$, $...$, $\\lambda^{k}$ with integer coefficients.)\r\n\r\nThese two $1$-operations $m$ and $m^{\\prime}$ satisfy both conditions of\r\nTheorem 8.4: The continuity assumption holds (since the operations $m$ and\r\n$m^{\\prime}$ are obtained by taking polynomials (with integer coefficients)\r\nand compositions of finitely many of the $\\lambda^{1}$, $\\lambda^{2}$,\r\n$\\lambda^{3}$, $...$, so that the maps $m_{\\left(  \\Lambda\\left(  K\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }$ and\r\n$m_{\\left(  \\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  }^{\\prime}$ are obtained by taking polynomials (with\r\ninteger coefficients) and compositions of finitely many of the\r\n$\\widehat{\\lambda}^{1}$, $\\widehat{\\lambda}^{2}$, $\\widehat{\\lambda}^{3}$,\r\n$...$, and therefore continuous because of Theorem 5.5 \\textbf{(d)}), and the\r\nsplit equality assumption holds (since it states that for every special\r\n$\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ and every $x\\in K$ such that $x$ is the sum of finitely many\r\n$1$-dimensional elements of $K$, we have $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(  x\\right)  =m_{\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(\r\nx\\right)  $; but this simply means that $\\operatorname*{Coeff}\\nolimits_{k}%\r\n\\left(  \\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)  \\right)  $, which was\r\nproven in the 3rd step). Hence, by Theorem 8.4, we have $m=m^{\\prime}$. Hence,\r\nfor every special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$, we have $m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }\\left(  x\\right)  =m_{\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(\r\nx\\right)  $. Since $m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  }\\left(  x\\right)  =\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)  \\right)  $ (by the definition of $m_{\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }$) and $m_{\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime}\\left(  x\\right)\r\n=\\operatorname*{Coeff}\\nolimits_{k}\\left(  \\operatorname*{td}%\r\n\\nolimits_{1-t^{j},T}\\left(  x\\right)  \\right)  $ (by the definition of\r\n$m_{\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  }^{\\prime\r\n}$), this rewrites as follows: For every special $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and every $x\\in K$,\r\nwe have $\\operatorname*{Coeff}\\nolimits_{k}\\left(  \\operatorname*{fr}%\r\n\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)  \\right)  \\right)\r\n=\\operatorname*{Coeff}\\nolimits_{k}\\left(  \\operatorname*{td}%\r\n\\nolimits_{1-t^{j},T}\\left(  x\\right)  \\right)  $.\r\n\r\nNow fix some special $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ and some $x\\in K$, and forget that we fixed $k$.\r\nWe have just proven that $\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)  \\right)  $ for every\r\n$k\\in\\mathbb{N}$. In other words, we have just proven that each coefficient of\r\nthe power series $\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi\r\n^{j}\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(\r\nx\\right)  \\right)  \\right)  $ equals to the corresponding coefficient of the\r\npower series $\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)  $.\r\nThus, $\\operatorname*{fr}\\nolimits_{j}\\left(  \\left(  \\psi^{j}\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{-T}\\left(  x\\right)  \\right)\r\n\\right)  =\\operatorname*{td}\\nolimits_{1-t^{j},T}\\left(  x\\right)  $. This\r\nproves the 4th Step.\r\n\r\n\\textit{5th Step:} Theorem 10.28 now follows by combining the 1st Step and the\r\n4th Step.\r\n\\end{proof}\r\n\r\n\\subsection{A somewhat more general context for Todd homomorphisms}\r\n\r\nHaving proven Theorem 10.28, we are done proving all important properties of\r\nthe $\\varphi$-Todd homomorphisms. One thing that I still want to do is to give\r\na (not particularly unexpected, and apparently not particularly useful)\r\ngeneralization of our notion of $\\varphi$-Todd homomorphisms to the case when\r\nthe power series $\\varphi$ does not lie in $1+\\mathbf{Z}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ but, instead, lies in $1+\\mathbf{Z}^{\\prime}\\left[\r\n\\left[  t\\right]  \\right]  ^{+}$ for $\\mathbf{Z}^{\\prime}$ being a\r\n$\\mathbf{Z}$-algebra. In this case, it turns out, not much will change - but,\r\nof course, $\\operatorname*{td}\\nolimits_{\\varphi,T}$ will no longer be a map\r\n$K\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ but instead will be a map\r\n$K\\rightarrow\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[\r\n\\left[  T\\right]  \\right]  $. Here is the precise definition:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. We define a\r\nmap $\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}%\r\n:K\\rightarrow\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[\r\n\\left[  T\\right]  \\right]  $ by%\r\n\\begin{equation}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)\r\n\\otimes1,...,\\lambda^{j}\\left(  x\\right)  \\otimes1\\right)  T^{j}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K. \\label{ToddDefZ'}%\r\n\\end{equation}\r\n\r\n\r\nLet me explain what I mean by $\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)\r\n\\otimes1,...,\\lambda^{j}\\left(  x\\right)  \\otimes1\\right)  $ here: The tensor\r\nproduct $K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$ is both a $K$-algebra and a\r\n$\\mathbf{Z}^{\\prime}$-algebra (since the tensor product of two commutative\r\n$\\mathbf{Z}$-algebras is an algebra over each of its tensorands). Since it is\r\na $\\mathbf{Z}^{\\prime}$-algebra, we can apply the polynomial\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}\\in\\mathbf{Z}^{\\prime}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right]  $ to the elements $\\lambda\r\n^{1}\\left(  x\\right)  \\otimes1$, $\\lambda^{2}\\left(  x\\right)  \\otimes1$,\r\n$...$, $\\lambda^{j}\\left(  x\\right)  \\otimes1$ of $K\\otimes_{\\mathbf{Z}%\r\n}\\mathbf{Z}^{\\prime}$; the result of this application is what we denote by\r\n$\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\lambda^{1}\\left(  x\\right)\r\n\\otimes1,\\lambda^{2}\\left(  x\\right)  \\otimes1,...,\\lambda^{j}\\left(\r\nx\\right)  \\otimes1\\right)  $.\r\n\r\nWe call $\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$ the\r\n$\\left(  \\varphi,\\mathbf{Z}^{\\prime}\\right)  $-\\textit{Todd homomorphism} of\r\nthe $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $.\r\n\\end{quote}\r\n\r\nNote that, in the particular case when $\\mathbf{Z}^{\\prime}=\\mathbf{Z}$, the\r\nmap $\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$ is identical\r\nwith the map $\\operatorname*{td}\\nolimits_{\\varphi,T}$ if we make the\r\ncanonical identification of $K$ with $K\\otimes_{\\mathbf{Z}}\\mathbf{Z}$.\r\n\r\nAll results about maps of the form $\\operatorname*{td}\\nolimits_{\\varphi,T}$\r\nthat we have formulated possess analoga pertaining to $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$. Proving these analoga is usually\r\nas simple as repeating the proofs of the original results and replacing some\r\nof the $\\mathbf{Z}$'s by $\\mathbf{Z}^{\\prime}$'s, some of the $K$'s by\r\n$\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $'s, and some of the\r\n$\\lambda^{i}\\left(  x\\right)  $'s by $\\lambda^{i}\\left(  x\\right)  \\otimes\r\n1$'s. However, it is yet easier to prove these analoga by deriving them from\r\nthe corresponding properties of the maps $\\mathfrak{Todd}_{\\varphi}$. What\r\nmakes this possible is the following generalization of Proposition 10.11:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.29.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. Let\r\n$\\iota:K\\rightarrow K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$ be the canonical\r\nmap (mapping every $\\xi\\in K$ to $\\xi\\otimes1\\in K\\otimes_{\\mathbf{Z}%\r\n}\\mathbf{Z}^{\\prime}$). Then, every $x\\in K$ satisfies $\\operatorname*{td}%\r\n_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  =\\mathfrak{Todd}_{\\varphi\r\n}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  \\right)  $.\r\n\\end{quote}\r\n\r\nThe proof of this is very similar to that of Proposition 10.11, and is part of\r\nExercise 10.2.\r\n\r\nLet us formulate the analoga of our above-proven results about\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T}$. The proofs of all these analoga\r\nwill be done in Exercise 10.2.\r\n\r\nHere is the analogue of Proposition 10.3:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.30.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $u\\in\\mathbf{Z}^{\\prime}$. For every $x\\in K$, we have\r\n$\\operatorname*{td}\\nolimits_{1+ut,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\lambda_{\\left(  1\\otimes u\\right)  T}\\left(  x\\right)  $, where\r\n$\\lambda_{\\left(  1\\otimes u\\right)  T}\\left(  x\\right)  $ means\r\n$\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes u\\right)  T}\\left(  \\lambda\r\n_{T}\\left(  x\\right)  \\right)  $.\r\n\\end{quote}\r\n\r\nSimilarly, here is the analogue of Proposition 10.5:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.31.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$.\r\n\r\n\\textbf{(a)} Then, $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n\\right)  =1$ for every $x\\in K$.\r\n\r\n\\textbf{(b)} Let $\\varphi_{1}$ be the coefficient of the power series\r\n$\\varphi\\in\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]  \\right]  $ before\r\n$t^{1}$. Then, $\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  \\right)\r\n=\\varphi_{1}\\left(  x\\otimes1\\right)  $ for every $x\\in K$.\r\n\\end{quote}\r\n\r\nThe analogue of Proposition 10.7:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.32.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ and $\\psi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be two power series with constant terms equal to $1$. For every\r\n$x\\in K$, we have $\\operatorname*{td}\\nolimits_{\\varphi\\psi,T,\\mathbf{Z}%\r\n^{\\prime}}\\left(  x\\right)  =\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  \\operatorname*{td}\\nolimits_{\\psi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  $.\r\n\\end{quote}\r\n\r\nNext, the analogue of Proposition 10.9:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.33.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $m\\in\\mathbb{N}$. For every $i\\in\\left\\{  1,2,...,m\\right\\}  $,\r\nlet $\\varphi_{i}\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]  \\right]\r\n^{+}$ be a power series with constant term equal to $1$. For every $x\\in K$,\r\nwe have%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\prod\\limits_{i=1}^{m}\\varphi_{i},T,\\mathbf{Z}%\r\n^{\\prime}}\\left(  x\\right)  =\\prod\\limits_{i=1}^{m}\\operatorname*{td}%\r\n\\nolimits_{\\varphi_{i},T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  .\r\n\\]\r\n\r\n\r\n\r\n\\end{quote}\r\n\r\nNext, the analogue of Theorem 10.10:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.34.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. Let $x\\in K$\r\nand $y\\in K$. Then, $\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}%\r\n^{\\prime}}\\left(  x\\right)  \\cdot\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  y\\right)  =\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  x+y\\right)  $.\r\n\\end{quote}\r\n\r\nThe analogue of Corollary 10.23 is what one would expect it to be:\r\n\r\n\\begin{quote}\r\n\\textbf{Corollary 10.35.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}%\r\n$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]\r\n\\right]  ^{+}$ be a power series with constant term equal to $1$. Then,\r\n$\\operatorname*{td}_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  K\\right)\r\n\\subseteq\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $,\r\nand $\\operatorname*{td}_{\\varphi,T,\\mathbf{Z}^{\\prime}}:K\\rightarrow\r\n\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $ is a\r\nhomomorphism of additive groups.\r\n\\end{quote}\r\n\r\nWe can also generalize Proposition 10.24:\r\n\r\n\\begin{quote}\r\n\\textbf{Proposition 10.36.} Let $\\mathbf{Z}$ be a ring. Let $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring such that\r\n$K$ is a $\\mathbf{Z}$-algebra. Let $u$ be a $1$-dimensional element of $K$.\r\nLet $\\mathbf{Z}^{\\prime}$ be a $\\mathbf{Z}$-algebra. Let $\\varphi\r\n\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[  t\\right]  \\right]  ^{+}$ be a power\r\nseries with constant term equal to $1$. Then, $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  u\\right)  =\\varphi\\left(\r\n\\left(  u\\otimes1\\right)  T\\right)  $, where $u\\otimes1$ denotes the element\r\n$u\\otimes1$ of $K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$.\r\n\\end{quote}\r\n\r\nFinally, the analogue to Theorem 10.27:\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem 10.37.} Let $\\mathbf{Z}$ be a ring. Let $\\mathbf{Z}^{\\prime}$\r\nbe a $\\mathbf{Z}$-algebra. Let $\\varphi\\in1+\\mathbf{Z}^{\\prime}\\left[  \\left[\r\nt\\right]  \\right]  ^{+}$ be a power series with constant term equal to $1$.\r\nLet $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be a\r\n$\\lambda$-ring such that $K$ is a $\\mathbf{Z}$-algebra. Let $u_{1}$, $u_{2}$,\r\n$...$, $u_{m}$ be $1$-dimensional elements of $K$. Then,%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  u_{1}%\r\n+u_{2}+...+u_{m}\\right)  =\\prod\\limits_{i=1}^{m}\\varphi\\left(  \\left(\r\nu_{i}\\otimes1\\right)  T\\right)  .\r\n\\]\r\n\r\n\r\n\\bigskip\r\n\\end{quote}\r\n\r\n\\subsection{Exercises}\r\n\r\n\\begin{quotation}\r\n\\textit{Exercise 10.2.} Prove Proposition 10.29, Proposition 10.30,\r\nProposition 10.31, Proposition 10.32, Proposition 10.33, Theorem 10.34,\r\nCorollary 10.35, Proposition 10.36 and Theorem 10.37.\r\n\\end{quotation}\r\n\r\n\\bigskip\r\n\r\n\\begin{noncompile}\r\n\\fbox{\\textbf{WARNING:} The following is incomplete.}\r\n\r\n\\fbox{\\textbf{11. Representation and Grothendieck rings}}\r\n\r\nThis Section, once it is written, will contain Seiler's proof that\r\nrepresentation rings (Grothendieck rings of categories of representations on\r\nprojective modules) are special $\\lambda$-rings.\r\n\\end{noncompile}\r\n\r\n[...]\r\n\r\n\\section*{Appendix X. Positive structure on $\\lambda$-rings}\r\n\r\n\\fbox{\\textbf{WARNING:} The following appendix is incomplete.}\r\n\r\nAlmost all $\\lambda$-rings in Fulton/Lang \\cite{FulLan85} and many $\\lambda\r\n$-rings in nature carry an additional structure called a \\textit{positive\r\nstructure}:\r\n\r\n\\begin{quote}\r\n\\textbf{Definition.} \\textbf{1)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring. Let $\\varepsilon\r\n:K\\rightarrow\\mathbb{Z}$ be a surjective\\footnote{I am quoting this from\r\n\\cite{FulLan85}. Personally, I have never have met a non-surjective ring\r\nhomomorphism to $\\mathbb{Z}$ in my life.} ring homomorphism. Let $\\mathbf{E}$\r\nbe a subset of $K$ such that $\\mathbf{E}$ is closed under addition and\r\nmultiplication and contains the subset $\\mathbb{Z}^{+}$ of $K$ (that is, the\r\nimage of $\\mathbb{Z}^{+}$ under the canonical ring homomorphism $\\mathbb{Z}%\r\n^{+}\\rightarrow K$). Also assume that $K=\\mathbf{E}-\\mathbf{E}$ (that is,\r\nevery element of $K$ can be written as difference of two elements of\r\n$\\mathbf{E}$). Furthermore, assume that every $e\\in\\mathbf{E}$ satisfies%\r\n\\[\r\n\\varepsilon\\left(  e\\right)  >0;\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\lambda^{i}\\left(\r\ne\\right)  =0\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any }i>\\varepsilon\\left(  e\\right)\r\n,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and that }\\lambda^{\\varepsilon\\left(  e\\right)\r\n}\\left(  e\\right)  \\text{ is a unit in the ring }K.\r\n\\]\r\nBesides, we assume that for every invertible element $u\\in\\mathbf{E}$, the\r\ninverse of $u$ must lie in $\\mathbf{E}$ as well.\r\n\r\nThen, $\\left(  \\varepsilon,\\mathbf{E}\\right)  $ is called a \\textit{positive\r\nstructure} on the $\\lambda$-ring. The homomorphism $\\varepsilon:K\\rightarrow\r\n\\mathbb{Z}$ is called an \\textit{augmentation} for the $\\lambda$-ring $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ with its positive\r\nstructure $\\left(  \\varepsilon,\\mathbf{E}\\right)  $. The elements of the set\r\n$\\mathbf{E}$ are called the \\textit{positive elements} of the $\\lambda$-ring\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ with its\r\npositive structure $\\left(  \\varepsilon,\\mathbf{E}\\right)  $%\r\n.\\ \\ \\ \\ \\footnote{One remark about the assumption that for every invertible\r\nelement $u\\in\\mathbf{E}$, the inverse of $u$ must lie in $\\mathbf{E}$ as well:\r\n\\par\r\nFulton and Lang do not make this assumption in \\cite{FulLan85}, but this is a\r\nmistake on their side. In fact, they claim that the set of all $u\\in\r\n\\mathbf{E}$ such that $\\varepsilon\\left(  u\\right)  =1$ is a subgroup of\r\n$K^{\\times}$. But to make this claim, they need the above-mentioned assumption\r\n(or another similar one). In fact, here is an example of a $\\lambda$-ring\r\n$K\\ $which satisfies all of their assumptions, but for which the set of all\r\n$u\\in\\mathbf{E}$ such that $\\varepsilon\\left(  u\\right)  =1$ is \\textit{not} a\r\nsubgroup of $K^{\\times}$:\r\n\\par\r\nLet $Z$ be the free group on one generator. (This group $Z$ is, of course,\r\nnone other than $\\mathbb{Z}$, written multiplicatively; however we must avoid\r\ncalling it $\\mathbb{Z}$, lest it is confused with the \\textit{ring}\r\n$\\mathbb{Z}$.) Let $X$ be the generator of $Z$. Applying Exercise 3.4 to\r\n$M=Z$, we get a $\\lambda$-ring $\\left(  \\mathbb{Z}\\left[  Z\\right]  ,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. Now define a map\r\n$\\varepsilon:\\mathbb{Z}\\left[  Z\\right]  \\rightarrow\\mathbb{Z}$ by%\r\n\\[\r\n\\varepsilon\\left(  \\sum_{m\\in Z}\\alpha_{m}m\\right)  =\\sum_{m\\in Z}\\alpha\r\n_{m}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for all }\\left(  \\alpha_{m}\\right)  _{m\\in Z}%\r\n\\in\\mathbb{Z}^{\\left(  Z\\right)  }.\r\n\\]\r\nThen, $\\varepsilon$ is a surjective ring homomorphism. Define $\\mathbf{E}$ to\r\nbe the additive and multiplicative closure of the subset%\r\n\\[\r\n\\left\\{  1,X,X^{2},...\\right\\}  \\cup\\left\\{  1+X^{-1},1+X^{-2},1+X^{-3}%\r\n,...\\right\\}\r\n\\]\r\nof $\\mathbb{Z}\\left[  Z\\right]  $. It is easy to see that all of our\r\nconditions are satisfied, except for the assumption that for every invertible\r\nelement $u\\in\\mathbf{E}$, the inverse of $u$ must lie in $\\mathbf{E}$ as well.\r\nHence, if we would omit this assumption (as Fulton and Lang do in\r\n\\cite{FulLan85}), the pair $\\left(  \\varepsilon,\\mathbf{E}\\right)  $ would be\r\na positive structure on our $\\lambda$-ring $\\left(  \\mathbb{Z}\\left[\r\nZ\\right]  ,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. However,\r\nthe set of all $u\\in\\mathbf{E}$ such that $\\varepsilon\\left(  u\\right)  =1$ is\r\nnot a subgroup of $K^{\\times}$ in this case, since this set contains $X$ but\r\nnot its inverse $X^{-1}$ (in fact, it is easy to see that $X^{-1}%\r\n\\notin\\mathbf{E}$; otherwise $X^{-1}$ would be a sum of products of elements\r\nof $\\left\\{  1,X,X^{2},...\\right\\}  \\cup\\left\\{  1+X^{-1},1+X^{-2}%\r\n,1+X^{-3},...\\right\\}  $, and applying $\\varepsilon$ we would conclude that\r\nthe sum has only $1$ summand, which is easy to rule out).}\r\n\r\n[Some assumptions may still be missing here. For example, we might want to\r\nrequire that $\\lambda^{i}\\left(  \\mathbf{E}\\right)  \\subseteq\\mathbf{E}$.] [\\#2]\r\n\r\n\\textbf{2)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring with a positive structure $\\left(\r\n\\varepsilon,\\mathbf{E}\\right)  $. The subset $\\left\\{  u\\in\\mathbf{E}%\r\n\\ \\mid\\ \\varepsilon\\left(  u\\right)  =1\\right\\}  $ of $\\mathbf{E}$ is usually\r\ndenoted as $\\mathbf{L}$. The elements of $\\mathbf{L}$ are called the\r\n\\textit{line elements} of the $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ with its positive structure $\\left(\r\n\\varepsilon,\\mathbf{E}\\right)  $.\r\n\r\n\\textbf{Theorem X.1.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a $\\lambda$-ring with a positive structure\r\n$\\left(  \\varepsilon,\\mathbf{E}\\right)  $.\r\n\r\n\\textbf{(a)} Then, $\\mathbf{L}=\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ \\varepsilon\r\n\\left(  u\\right)  =1\\right\\}  $ is a subgroup of the (multiplicative) unit\r\ngroup $K^{\\times}$ of $K$.\r\n\r\n\\textbf{(b)} We have $\\mathbf{L}=\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ \\lambda\r\n_{T}\\left(  u\\right)  =1+uT\\right\\}  =\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ u\\text{\r\nis }1\\text{-dimensional}\\right\\}  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem X.1.]\\textbf{(b)} \\textit{1st Step:} We have $\\mathbf{L}%\r\n\\subseteq\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ u\\text{ is }1\\text{-dimensional}%\r\n\\right\\}  $.\r\n\r\n\\textit{Proof.} For every $u\\in\\mathbf{L}$, we have $\\varepsilon\\left(\r\nu\\right)  =1$ (by the definition of $\\mathbf{L}$) and $\\lambda^{i}\\left(\r\nu\\right)  =0$ for any $i>\\varepsilon\\left(  u\\right)  $ (by the axioms of a\r\npositive structure, since $u\\in\\mathbf{L}\\subseteq\\mathbf{E}$). Thus, for\r\nevery $u\\in\\mathbf{L}$, we have $\\lambda^{i}\\left(  u\\right)  =0$ for any\r\n$i>1$ (because for any $i>1$, we have $i>1=\\varepsilon\\left(  u\\right)  $ and\r\nthus $\\lambda^{i}\\left(  u\\right)  =0$). In other words, every $u\\in\r\n\\mathbf{L}$ is $1$-dimensional. Thus, $\\mathbf{L}\\subseteq\\left\\{\r\nu\\in\\mathbf{E}\\ \\mid\\ u\\text{ is }1\\text{-dimensional}\\right\\}  $.\r\n\r\n\\textit{2nd Step:} We have $\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ u\\text{ is\r\n}1\\text{-dimensional}\\right\\}  \\subseteq\\left\\{  u\\in\\mathbf{E}\\ \\mid\r\n\\ \\lambda_{T}\\left(  u\\right)  =1+uT\\right\\}  $.\r\n\r\n\\textit{Proof.} Every $1$-dimensional $u\\in\\mathbf{E}$ satisfies $\\lambda\r\n^{i}\\left(  u\\right)  =0$ for any $i>1$ (by the definition of ``$1$%\r\n-dimensional''). Now, every $1$-dimensional $u\\in\\mathbf{E}$ satisfies%\r\n\\[\r\n\\lambda_{T}\\left(  u\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nu\\right)  T^{i}=\\underbrace{\\lambda^{0}\\left(  u\\right)  }_{=1}%\r\n+\\underbrace{\\lambda^{1}\\left(  u\\right)  }_{=u}T+\\sum\\limits_{i\\geq\r\n2}\\underbrace{\\lambda^{i}\\left(  u\\right)  }_{\\substack{=0,\\text{ since}%\r\n\\\\i>1}}T^{i}=1+uT.\r\n\\]\r\nThus, we have shown that every $1$-dimensional $u\\in\\mathbf{E}$ satisfies\r\n$\\lambda_{T}\\left(  u\\right)  =1+uT$. In other words, $\\left\\{  u\\in\r\n\\mathbf{E}\\ \\mid\\ u\\text{ is }1\\text{-dimensional}\\right\\}  \\subseteq\\left\\{\r\nu\\in\\mathbf{E}\\ \\mid\\ \\lambda_{T}\\left(  u\\right)  =1+uT\\right\\}  $.\r\n\r\n\\textit{3rd Step:} We have $\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ \\lambda_{T}\\left(\r\nu\\right)  =1+uT\\right\\}  \\subseteq\\mathbf{L}$.\r\n\r\n\\textit{Proof.} Let $u\\in\\mathbf{E}$ be an element satisfying $\\lambda\r\n_{T}\\left(  u\\right)  =1+uT$. Then this $u$ must satisfy%\r\n\\[\r\n\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  u\\right)  T^{i}=\\lambda\r\n_{T}\\left(  u\\right)  =1+uT,\r\n\\]\r\nand thus (by comparison of coefficients) $\\lambda^{i}\\left(  u\\right)  =0$ for\r\nevery $i>1$, so that $\\varepsilon\\left(  u\\right)  \\leq1$ (because\r\n$\\lambda^{\\varepsilon\\left(  u\\right)  }\\left(  u\\right)  $ is a unit in the\r\nring $K$ (since $u\\in\\mathbf{E}$), so that $\\lambda^{\\varepsilon\\left(\r\nu\\right)  }\\left(  u\\right)  \\neq0$ and thus $\\varepsilon\\left(  u\\right)\r\n\\leq1$). Together with $\\varepsilon\\left(  u\\right)  >0$, this yields\r\n$\\varepsilon\\left(  u\\right)  =1$ and thus $u\\in\\mathbf{L}$.\r\n\r\nWe have thus proven that every $u\\in\\mathbf{E}$ satisfying $\\lambda_{T}\\left(\r\nu\\right)  =1+uT$ must satisfy $u\\in\\mathbf{L}$. In other words, we have proven\r\nthat $\\left\\{  u\\in\\mathbf{E}\\ \\mid\\ \\lambda_{T}\\left(  u\\right)\r\n=1+uT\\right\\}  \\subseteq\\mathbf{L}$.\r\n\r\n\\textit{4th Step:} Combining the results of the 1st Step, the 2nd Step and the\r\n3rd Step, we conclude that $\\mathbf{L}=\\left\\{  u\\in\\mathbf{E}\\ \\mid\r\n\\ \\lambda_{T}\\left(  u\\right)  =1+uT\\right\\}  =\\left\\{  u\\in\\mathbf{E}%\r\n\\ \\mid\\ u\\text{ is }1\\text{-dimensional}\\right\\}  $. This proves Theorem X.1\r\n\\textbf{(b)}.\r\n\r\n\\textbf{(a)} \\textit{1st Step:} Every $u\\in\\mathbf{L}$ is invertible in $K$,\r\nand the inverse of every $u\\in\\mathbf{L}$ lies in $\\mathbf{L}$.\r\n\r\n\\textit{Proof.} Let $u\\in\\mathbf{L}$. Then, $\\lambda^{\\varepsilon\\left(\r\nu\\right)  }\\left(  u\\right)  $ is a unit in the ring $K$ (since $u\\in\r\n\\mathbf{E}$). But $\\varepsilon\\left(  u\\right)  =1$ (since $u\\in\\mathbf{L}$)\r\nand thus $\\lambda^{\\varepsilon\\left(  u\\right)  }\\left(  u\\right)\r\n=\\lambda^{1}\\left(  u\\right)  =u$. Thus, $u$ is a unit in $K$; that is, $u$ is\r\ninvertible. Its inverse $u^{-1}$ must lie in $\\mathbf{E}$ as well (because\r\n$u\\in\\mathbf{L}\\subseteq\\mathbf{E}$, and because of our assumption that for\r\nevery invertible element $u\\in\\mathbf{E}$, the inverse of $u$ must lie in\r\n$\\mathbf{E}$ as well). Since $\\varepsilon$ is a ring homomorphism, we have\r\n$\\varepsilon\\left(  u^{-1}\\right)  =\\left(  \\underbrace{\\varepsilon\\left(\r\nu\\right)  }_{=1}\\right)  ^{-1}=1^{-1}=1$. This, together with $u^{-1}%\r\n\\in\\mathbf{E}$, yields $u^{-1}\\in\\mathbf{L}$ (by the definition of\r\n$\\mathbf{L}$).\r\n\r\nWe have thus proven that every $u\\in\\mathbf{L}$ is invertible in $K$, and the\r\ninverse of every $u\\in\\mathbf{L}$ lies in $\\mathbf{L}$.\r\n\r\n\\textit{2nd Step:} The set $\\mathbf{L}$ is closed under multiplication and\r\ncontains the multiplicative unity of $K$.\r\n\r\n\\textit{Proof.} This is trivial.\r\n\r\n\\textit{3rd Step:} Theorem X.1 \\textbf{(a)} trivially follows from the 1st\r\nStep and the 2nd Step.\r\n\\end{proof}\r\n\r\n\\begin{quote}\r\n\\textbf{Theorem X.2.} Let $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ be a special(?) $\\lambda$-ring with a positive\r\nstructure $\\left(  \\varepsilon,\\mathbf{E}\\right)  $. Let $e\\in\\mathbf{E}$, and\r\nlet $r=\\varepsilon\\left(  e\\right)  -1$. Define a polynomial $p_{e}\\in\r\nK\\left[  T\\right]  $ by $p_{e}\\left(  T\\right)  =\\sum\\limits_{i=0}%\r\n^{r+1}\\left(  -1\\right)  ^{i}\\lambda^{i}\\left(  e\\right)  T^{r+1-i}$. Set\r\n$K_{e}=K\\left[  T\\right]  \\diagup\\left(  p_{e}\\left(  T\\right)  \\right)\r\n=K\\left[  \\ell\\right]  $, where $\\ell$ denotes the equivalence class of $T$\r\nmodulo $p_{e}\\left(  T\\right)  $. Then, $K_{e}$ is a finite-free extension\r\nring of $K$. There exists a map $\\widetilde{\\lambda}^{i}:K_{e}\\rightarrow\r\nK_{e}$ for every $i\\in\\mathbb{N}$ such that $\\left(  K_{e},\\left(\r\n\\widetilde{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda\r\n$-ring such that the inclusion $K\\rightarrow K_{e}$ is a $\\lambda$-ring\r\nhomomorphism and such that $\\ell\\in K_{e}$ is a $1$-dimensional element.\r\nMoreover, there exists a positive structure $\\left(  \\varepsilon\r\n_{e},\\mathbf{E}_{e}\\right)  $ on $K_{e}$ defined by $\\varepsilon_{e}\\left(\r\n\\ell\\right)  =1$ and $\\mathbf{E}_{e}=\\left\\{  \\sum\\limits_{i\\in\\mathbb{N}%\r\n,\\ j\\in\\mathbb{N}}a_{i,j}\\ell^{i}\\left(  e-\\ell\\right)  ^{j}\\ \\mid\\text{\r\n}a_{i,j}\\in\\mathbf{E}\\text{ for all }i\\in\\mathbb{N}\\text{ and }j\\in\r\n\\mathbb{N}\\right\\}  $.\r\n\\end{quote}\r\n\r\nBy iterating the construction in Theorem X.2, we can find, for any\r\n$e\\in\\mathbf{E}$, an extension ring of $K$ with a $\\lambda$-ring structure in\r\nwhich $e$ is the sum of $r$ $1$-dimensional elements. This is called the\r\n\\textit{splitting principle}, and is what Fulton/Lang \\cite{FulLan85} use\r\ninstead of Theorem 8.4 above when they want to prove an identity just by\r\nverifying it for sums of $1$-dimensional elements. However, this way they can\r\nonly show it for positive elements, while Theorem 8.4 yields it for arbitrary elements.\r\n\r\n\\begin{noncompile}\r\n[add noncont. splitting principle generalizing 8.4][...]\r\n\\end{noncompile}\r\n\r\n\\section{Hints and solutions to exercises}\r\n\r\n\\subsection{To Section 1}\r\n\r\n\\subsection{To Section 2}\r\n\r\n\\textit{Exercise 2.1: Solution:} \\textbf{(a)} Theorem 2.1 \\textbf{(c)} says\r\nthat $f$ is a homomorphism of $\\lambda$-rings if and only if $\\mu_{T}\\circ\r\nf=f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}$. Thus, it remains to\r\nshow that $\\mu_{T}\\circ f=f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda\r\n_{T}$ holds if and only if every $e\\in E$ satisfies $\\left(  \\mu_{T}\\circ\r\nf\\right)  \\left(  e\\right)  =\\left(  f\\left[  \\left[  T\\right]  \\right]\r\n\\circ\\lambda_{T}\\right)  \\left(  e\\right)  $. Since $E$ is a generating set of\r\nthe $\\mathbb{Z}$-module $K$, this comes down to proving the following three facts:\r\n\r\n\\begin{itemize}\r\n\\item We have $\\left(  \\mu_{T}\\circ f\\right)  \\left(  0\\right)  =\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  0\\right)\r\n$.\r\n\r\n\\item We have $\\left(  \\mu_{T}\\circ f\\right)  \\left(  -x\\right)  =\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\n-x\\right)  $ for every $x\\in K$ which satisfies $\\left(  \\mu_{T}\\circ\r\nf\\right)  \\left(  x\\right)  =\\left(  f\\left[  \\left[  T\\right]  \\right]\r\n\\circ\\lambda_{T}\\right)  \\left(  x\\right)  $.\r\n\r\n\\item We have $\\left(  \\mu_{T}\\circ f\\right)  \\left(  x+y\\right)  =\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\nx+y\\right)  $ for any $x\\in K$ and $y\\in K$ which satisfy $\\left(  \\mu\r\n_{T}\\circ f\\right)  \\left(  x\\right)  =\\left(  f\\left[  \\left[  T\\right]\r\n\\right]  \\circ\\lambda_{T}\\right)  \\left(  x\\right)  $ and $\\left(  \\mu\r\n_{T}\\circ f\\right)  \\left(  y\\right)  =\\left(  f\\left[  \\left[  T\\right]\r\n\\right]  \\circ\\lambda_{T}\\right)  \\left(  y\\right)  $.\r\n\\end{itemize}\r\n\r\nWe will only prove the last of these three assertions (the other two are\r\nsimilar): If $\\left(  \\mu_{T}\\circ f\\right)  \\left(  x\\right)  =\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  x\\right)\r\n$ and $\\left(  \\mu_{T}\\circ f\\right)  \\left(  y\\right)  =\\left(  f\\left[\r\n\\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  y\\right)  $, then%\r\n\\begin{align*}\r\n&  \\left(  \\mu_{T}\\circ f\\right)  \\left(  x+y\\right) \\\\\r\n&  =\\mu_{T}\\left(  f\\left(  x+y\\right)  \\right)  =\\mu_{T}\\left(  f\\left(\r\nx\\right)  +f\\left(  y\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}f\\text{ is a ring homomorphism}\\right) \\\\\r\n&  =\\mu_{T}\\left(  f\\left(  x\\right)  \\right)  \\cdot\\mu_{T}\\left(  f\\left(\r\ny\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 2.1\r\n\\textbf{(a)}, applied to the }\\lambda\\text{-ring }\\left(  L,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  \\mu_{T}\\circ f\\right)  \\left(  x\\right)  }_{=\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  x\\right)\r\n}\\cdot\\underbrace{\\left(  \\mu_{T}\\circ f\\right)  \\left(  y\\right)  }_{=\\left(\r\nf\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  y\\right)\r\n}=\\left(  f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\nx\\right)  \\cdot\\left(  f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda\r\n_{T}\\right)  \\left(  y\\right) \\\\\r\n&  =\\left(  f\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\underbrace{\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)\r\n}_{=\\lambda_{T}\\left(  x+y\\right)  \\text{ by Theorem 2.1 \\textbf{(a)}}%\r\n}\\right)  =\\left(  f\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda\r\n_{T}\\right)  \\left(  x+y\\right)  ,\r\n\\end{align*}\r\nqed.\r\n\r\n\\textbf{(b)} This follows from \\textbf{(a)} in the same way as Theorem 2.1\r\n\\textbf{(c)} was proven.\r\n\r\n\\textit{Exercise 2.2: Solution:} It is an exercise in basic algebra to see\r\nthat $L-L$ is a subring of $K$. Thus, it only remains to show that\r\n$\\lambda^{i}\\left(  L-L\\right)  \\subseteq L-L$ for every $i\\in\\mathbb{N}$. In\r\nother words, we have to prove that $\\lambda^{i}\\left(  \\ell-\\ell^{\\prime\r\n}\\right)  \\in L-L$ for every $\\ell\\in L$ and $\\ell^{\\prime}\\in L$.\r\n\r\nWe are going to prove this by induction, so we assume that $\\lambda^{j}\\left(\r\n\\ell-\\ell^{\\prime}\\right)  \\in L-L$ for all $j<i$. Then,%\r\n\\begin{align*}\r\n\\lambda^{i}\\left(  \\ell\\right)   &  =\\lambda^{i}\\left(  \\left(  \\ell\r\n-\\ell^{\\prime}\\right)  +\\ell^{\\prime}\\right)  =\\sum_{j=0}^{i}\\lambda\r\n^{j}\\left(  \\ell-\\ell^{\\prime}\\right)  \\lambda^{i-j}\\left(  \\ell^{\\prime\r\n}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }%\r\n\\lambda\\text{-rings}\\right) \\\\\r\n&  =\\sum_{j=0}^{i-1}\\underbrace{\\lambda^{j}\\left(  \\ell-\\ell^{\\prime}\\right)\r\n}_{\\substack{\\in L-L,\\text{ since}\\\\j<i}}\\underbrace{\\lambda^{i-j}\\left(\r\n\\ell^{\\prime}\\right)  }_{\\substack{\\in L\\text{, since}\\\\\\ell^{\\prime}\\in\r\nL}}+\\lambda^{i}\\left(  \\ell-\\ell^{\\prime}\\right)  \\underbrace{\\lambda\r\n^{0}\\left(  \\ell^{\\prime}\\right)  }_{=1}\\\\\r\n&  \\in\\underbrace{\\left(  L-L\\right)  L}_{\\substack{\\subseteq LL-LL\\subseteq\r\nL-L\\\\\\text{(since }LL\\subseteq L\\text{)}}}+\\lambda^{i}\\left(  \\ell\r\n-\\ell^{\\prime}\\right)  \\subseteq\\left(  L-L\\right)  +\\lambda^{i}\\left(\r\n\\ell-\\ell^{\\prime}\\right)  .\r\n\\end{align*}\r\nBut $\\lambda^{i}\\left(  \\ell\\right)  $ itself lies in $L-L$ (since $\\ell\\in\r\nL$, so that $\\lambda^{i}\\left(  \\ell\\right)  \\in L$ and thus $\\lambda\r\n^{i}\\left(  \\ell\\right)  =\\underbrace{\\lambda^{i}\\left(  \\ell\\right)  }_{\\in\r\nL}-\\underbrace{0}_{\\in L}\\in L-L$), so this yields $\\lambda^{i}\\left(\r\n\\ell-\\ell^{\\prime}\\right)  \\in L-L$, and this completes our induction.\r\n\r\n\\textit{Exercise 2.3:} \\textit{Solution:}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 2.2.]\\textbf{(a)} Let $x\\in K\\diagup I$. Let $y\\in K$ and\r\n$z\\in K$ be two elements of $K$ satisfying $\\overline{y}=x$ and $\\overline\r\n{z}=x$. Then, $\\overline{y}=x=\\overline{z}$, so that $y\\equiv\r\nz\\operatorname{mod}I$. In other words, $y-z\\in I$.\r\n\r\nWe know (from the definition of $\\lambda$-ideals) that $I$ is a $\\lambda\r\n$-ideal of $K$ if and only if every $t\\in I$ and every positive integer $i$\r\nsatisfy $\\lambda^{i}\\left(  t\\right)  \\in I$. Since we know that $I$ is a\r\n$\\lambda$-ideal, we conclude that every $t\\in I$ and every positive integer\r\n$i$ satisfy $\\lambda^{i}\\left(  t\\right)  \\in I$. Applied to $t=y-z$, this\r\nyields that every positive integer $i$ satisfies $\\lambda^{i}\\left(\r\ny-z\\right)  \\in I$.\r\n\r\nFix $k\\in\\mathbb{N}$. The equality (\\ref{lambda1}), applied to $y-z$ and $z$\r\ninstead of $x$ and $y$, yields%\r\n\\begin{align*}\r\n\\lambda^{k}\\left(  \\left(  y-z\\right)  +z\\right)   &  =\\sum_{i=0}^{k}%\r\n\\lambda^{i}\\left(  y-z\\right)  \\lambda^{k-i}\\left(  z\\right)\r\n=\\underbrace{\\lambda^{0}\\left(  y-z\\right)  }_{\\substack{=1\\\\\\text{(since\r\n}\\lambda^{0}\\left(  t\\right)  =1\\\\\\text{for every }t\\in K\\text{)}%\r\n}}\\underbrace{\\lambda^{k-0}}_{=\\lambda^{k}}\\left(  z\\right)  +\\sum_{i=0}%\r\n^{k}\\underbrace{\\lambda^{i}\\left(  y-z\\right)  }_{\\substack{\\in\r\nI\\\\\\text{(since }i\\text{ is a positive}\\\\\\text{integer)}}}\\lambda^{k-i}\\left(\r\nz\\right) \\\\\r\n&  \\in\\underbrace{1\\lambda^{k}\\left(  z\\right)  }_{=\\lambda^{k}\\left(\r\nz\\right)  }+\\underbrace{\\sum_{i=0}^{k}I\\lambda^{k-i}\\left(  z\\right)\r\n}_{\\substack{\\subseteq I\\\\\\text{(since }I\\text{ is an ideal)}}}\\subseteq\r\n\\lambda^{k}\\left(  z\\right)  +I.\r\n\\end{align*}\r\nSince $\\left(  y-z\\right)  +z=y$, this rewrites as $\\lambda^{k}\\left(\r\ny\\right)  \\in\\lambda^{k}\\left(  z\\right)  +I$. In other words, $\\overline\r\n{\\lambda^{k}\\left(  y\\right)  }=\\overline{\\lambda^{k}\\left(  z\\right)  }$.\r\n\r\nNow, forget that we fixed $k$. We thus have proven that $\\overline{\\lambda\r\n^{k}\\left(  y\\right)  }=\\overline{\\lambda^{k}\\left(  z\\right)  }$ for every\r\n$k\\in\\mathbb{N}$. Renaming $k$ as $i$ in this claim, we conclude that we have\r\n$\\overline{\\lambda^{i}\\left(  y\\right)  }=\\overline{\\lambda^{i}\\left(\r\nz\\right)  }$ for every $i\\in\\mathbb{N}$. Theorem 2.2 \\textbf{(a)} is proven.\r\n\r\n\\textbf{(b)} First of all,%\r\n\\begin{equation}\r\n\\left(  \\widetilde{\\lambda}^{0}\\left(  x\\right)  =1\\text{ for every }x\\in\r\nK\\diagup I\\right)  \\label{2.3.sol.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{2.3.sol.1}):} Let $x\\in K\\diagup I$. By the\r\ndefinition of $\\widetilde{\\lambda}^{0}$, the value $\\widetilde{\\lambda}%\r\n^{0}\\left(  x\\right)  $ is defined as $\\overline{\\lambda^{0}\\left(  w\\right)\r\n}$, where $w$ is an element of $K$ satisfying $\\overline{w}=x$. So let $w$ be\r\nan element of $K$ satisfying $\\overline{w}=x$ (such a $w$ clearly exists).\r\nThen, $\\widetilde{\\lambda}^{0}\\left(  x\\right)  =\\overline{\\lambda^{0}\\left(\r\nw\\right)  }$. But $\\lambda^{0}\\left(  w\\right)  =1$ (since every $t\\in K$\r\nsatisfies $\\lambda^{0}\\left(  t\\right)  =1$). Thus, $\\overline{\\lambda\r\n^{0}\\left(  w\\right)  }=\\overline{1}=1$, so that $\\widetilde{\\lambda}%\r\n^{0}\\left(  x\\right)  =\\overline{\\lambda^{0}\\left(  w\\right)  }=1$. This\r\nproves (\\ref{2.3.sol.1}).}. Next,%\r\n\\begin{equation}\r\n\\left(  \\widetilde{\\lambda}^{1}\\left(  x\\right)  =x\\text{ for every }x\\in\r\nK\\diagup I\\right)  \\label{2.3.sol.2}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{2.3.sol.2}):} Let $x\\in K\\diagup I$. By the\r\ndefinition of $\\widetilde{\\lambda}^{1}$, the value $\\widetilde{\\lambda}%\r\n^{1}\\left(  x\\right)  $ is defined as $\\overline{\\lambda^{1}\\left(  w\\right)\r\n}$, where $w$ is an element of $K$ satisfying $\\overline{w}=x$. So let $w$ be\r\nan element of $K$ satisfying $\\overline{w}=x$ (such a $w$ clearly exists).\r\nThen, $\\widetilde{\\lambda}^{1}\\left(  x\\right)  =\\overline{\\lambda^{1}\\left(\r\nw\\right)  }$. But $\\lambda^{1}\\left(  w\\right)  =w$ (since every $t\\in K$\r\nsatisfies $\\lambda^{1}\\left(  t\\right)  =t$). Thus, $\\overline{\\lambda\r\n^{1}\\left(  w\\right)  }=\\overline{w}=x$, so that $\\widetilde{\\lambda}%\r\n^{1}\\left(  x\\right)  =\\overline{\\lambda^{1}\\left(  w\\right)  }=x$. This\r\nproves (\\ref{2.3.sol.2}).}. Finally,%\r\n\\begin{equation}\r\n\\left(  \\widetilde{\\lambda}^{k}\\left(  x+y\\right)  =\\sum_{i=0}^{k}%\r\n\\widetilde{\\lambda}^{i}\\left(  x\\right)  \\widetilde{\\lambda}^{k-i}\\left(\r\ny\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }k\\in\\mathbb{N},\\text{ }x\\in\r\nK\\diagup I\\text{ and }y\\in K\\diagup I\\right)  \\label{2.3.sol.3}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{2.3.sol.3}):} Let $x\\in K\\diagup I$, $y\\in\r\nK\\diagup I$ and $k\\in\\mathbb{N}$.\r\n\\par\r\nPick any $u\\in K$ satisfying $\\overline{u}=x$. (Such a $u$ clearly exists.)\r\nPick any $v\\in K$ satisfying $\\overline{v}=y$. (Such a $v$ clearly exists.)\r\n\\par\r\nLet $i\\in\\left\\{  0,1,...,k\\right\\}  $.\r\n\\par\r\nBy the definition of $\\widetilde{\\lambda}^{i}$, the value $\\widetilde{\\lambda\r\n}^{i}\\left(  x\\right)  $ is defined as $\\overline{\\lambda^{i}\\left(  w\\right)\r\n}$, where $w$ is an element of $K$ satisfying $\\overline{w}=x$. Thus,\r\n$\\widetilde{\\lambda}^{i}\\left(  x\\right)  =\\overline{\\lambda^{i}\\left(\r\nw\\right)  }$ for every $w\\in K$ satisfying $\\overline{w}=x$. Applied to $w=u$,\r\nthis yields $\\widetilde{\\lambda}^{i}\\left(  x\\right)  =\\overline{\\lambda\r\n^{i}\\left(  u\\right)  }$ (since $\\overline{u}=x$).\r\n\\par\r\nBy the definition of $\\widetilde{\\lambda}^{k-i}$, the value\r\n$\\widetilde{\\lambda}^{k-i}\\left(  y\\right)  $ is defined as $\\overline\r\n{\\lambda^{k-i}\\left(  w\\right)  }$, where $w$ is an element of $K$ satisfying\r\n$\\overline{w}=y$. Thus, $\\widetilde{\\lambda}^{k-i}\\left(  y\\right)\r\n=\\overline{\\lambda^{k-i}\\left(  w\\right)  }$ for every $w\\in K$ satisfying\r\n$\\overline{w}=y$. Applied to $w=v$, this yields $\\widetilde{\\lambda}%\r\n^{k-i}\\left(  y\\right)  =\\overline{\\lambda^{k-i}\\left(  v\\right)  }$ (since\r\n$\\overline{v}=y$).\r\n\\par\r\nNow forget that we fixed $i\\in\\left\\{  0,1,...,k\\right\\}  $. We thus have\r\nshown that every $i\\in\\left\\{  0,1,...,k\\right\\}  $ satisfies\r\n$\\widetilde{\\lambda}^{i}\\left(  x\\right)  =\\overline{\\lambda^{i}\\left(\r\nu\\right)  }$ and $\\widetilde{\\lambda}^{k-i}\\left(  y\\right)  =\\overline\r\n{\\lambda^{k-i}\\left(  v\\right)  }$. Thus,%\r\n\\[\r\n\\sum_{i=0}^{k}\\underbrace{\\widetilde{\\lambda}^{i}\\left(  x\\right)\r\n}_{=\\overline{\\lambda^{i}\\left(  u\\right)  }}\\underbrace{\\widetilde{\\lambda\r\n}^{k-i}\\left(  y\\right)  }_{=\\overline{\\lambda^{k-i}\\left(  v\\right)  }}%\r\n=\\sum_{i=0}^{k}\\overline{\\lambda^{i}\\left(  u\\right)  }\\overline{\\lambda\r\n^{k-i}\\left(  v\\right)  }=\\overline{\\sum_{i=0}^{k}\\lambda^{i}\\left(  u\\right)\r\n\\lambda^{k-i}\\left(  v\\right)  }.\r\n\\]\r\n\\par\r\nBy the definition of $\\widetilde{\\lambda}^{k}$, the value $\\widetilde{\\lambda\r\n}^{k}\\left(  x+y\\right)  $ is defined as $\\overline{\\lambda^{k}\\left(\r\nw\\right)  }$, where $w$ is an element of $K$ satisfying $\\overline{w}=x+y$.\r\nThus, $\\widetilde{\\lambda}^{k}\\left(  x+y\\right)  =\\overline{\\lambda\r\n^{k}\\left(  w\\right)  }$ for every $w\\in K$ satisfying $\\overline{w}=x+y$.\r\nApplied to $w=u+v$, this yields $\\widetilde{\\lambda}^{k}\\left(  x+y\\right)\r\n=\\overline{\\lambda^{k}\\left(  u+v\\right)  }$ (since $\\overline{u+v}%\r\n=\\underbrace{\\overline{u}}_{=x}+\\underbrace{\\overline{v}}_{=y}=x+y$). Thus,%\r\n\\begin{align*}\r\n\\widetilde{\\lambda}^{k}\\left(  x+y\\right)   &  =\\overline{\\lambda^{k}\\left(\r\nu+v\\right)  }=\\overline{\\sum_{i=0}^{k}\\lambda^{i}\\left(  u\\right)\r\n\\lambda^{k-i}\\left(  v\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since (\\ref{lambda1}) (applied to }u\\text{ and }v\\text{ instead of\r\n}x\\text{ and }y\\text{) yields}\\\\\r\n\\lambda^{k}\\left(  u+v\\right)  =\\sum\\limits_{i=0}^{k}\\lambda^{i}\\left(\r\nu\\right)  \\lambda^{k-i}\\left(  v\\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{i=0}^{k}\\widetilde{\\lambda}^{i}\\left(  x\\right)  \\widetilde{\\lambda\r\n}^{k-i}\\left(  y\\right)  .\r\n\\end{align*}\r\nThis proves (\\ref{2.3.sol.3}).}.\r\n\r\nNow, according to the definition of a $\\lambda$-ring, we know that $\\left(\r\nK\\diagup I,\\left(  \\widetilde{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a $\\lambda$-ring if and only if it satisfies the relations (\\ref{2.3.sol.1}%\r\n), (\\ref{2.3.sol.2}) and (\\ref{2.3.sol.3}). Since we have shown that it\r\nsatisfies the relations (\\ref{2.3.sol.1}), (\\ref{2.3.sol.2}) and\r\n(\\ref{2.3.sol.3}), we thus conclude that $\\left(  K\\diagup I,\\left(\r\n\\widetilde{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda\r\n$-ring. Theorem 2.2 \\textbf{(b)} is proven.\r\n\r\n\\textbf{(c)} Let $\\pi$ be the canonical projection $K\\rightarrow K\\diagup I$.\r\n\r\nThe definition of a $\\lambda$-ring homomorphism tells us: The map $\\pi$ is a\r\n$\\lambda$-ring homomorphism if and only if $\\pi$ is a ring homomorphism and\r\nsatisfies $\\widetilde{\\lambda}^{i}\\circ\\pi=\\pi\\circ\\lambda^{i}$ for every\r\n$i\\in\\mathbb{N}$. But since $\\pi$ is a ring homomorphism (because it is a\r\ncanonical projection of a ring onto a factor ring) and satisfies\r\n$\\widetilde{\\lambda}^{i}\\circ\\pi=\\pi\\circ\\lambda^{i}$ for every $i\\in\r\n\\mathbb{N}$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $i\\in\\mathbb{N}$. Let $z\\in\r\nK$. Then, $\\pi\\left(  z\\right)  =\\overline{z}$ (because $\\pi$ is the canonical\r\nprojection $K\\rightarrow K\\diagup I$) and $\\pi\\left(  \\lambda^{i}\\left(\r\nz\\right)  \\right)  =\\overline{\\lambda^{i}\\left(  z\\right)  }$ (for the same\r\nreason).\r\n\\par\r\nBy the definition of $\\widetilde{\\lambda}^{i}$, the value $\\widetilde{\\lambda\r\n}^{i}\\left(  \\overline{z}\\right)  $ is defined as $\\overline{\\lambda\r\n^{i}\\left(  w\\right)  }$, where $w$ is an element of $K$ satisfying\r\n$\\overline{w}=\\overline{z}$. Thus, $\\widetilde{\\lambda}^{i}\\left(\r\n\\overline{z}\\right)  =\\overline{\\lambda^{i}\\left(  w\\right)  }$ for every\r\n$w\\in K$ satisfying $\\overline{w}=\\overline{z}$. Applied to $w=z$, this yields\r\n$\\widetilde{\\lambda}^{i}\\left(  \\overline{z}\\right)  =\\overline{\\lambda\r\n^{i}\\left(  z\\right)  }$ (since $\\overline{z}=\\overline{z}$).\r\n\\par\r\nNow, $\\left(  \\widetilde{\\lambda}^{i}\\circ\\pi\\right)  \\left(  z\\right)\r\n=\\widetilde{\\lambda}^{i}\\left(  \\underbrace{\\pi\\left(  z\\right)  }%\r\n_{=\\overline{z}}\\right)  =\\widetilde{\\lambda}^{i}\\left(  \\overline{z}\\right)\r\n=\\overline{\\lambda^{i}\\left(  z\\right)  }=\\pi\\left(  \\lambda^{i}\\left(\r\nz\\right)  \\right)  =\\left(  \\pi\\circ\\lambda^{i}\\right)  \\left(  z\\right)  $.\r\n\\par\r\nNow forget that we fixed $z$. We thus have proven that $\\left(\r\n\\widetilde{\\lambda}^{i}\\circ\\pi\\right)  \\left(  z\\right)  =\\left(  \\pi\r\n\\circ\\lambda^{i}\\right)  \\left(  z\\right)  $ for every $z\\in K$. In other\r\nwords, $\\widetilde{\\lambda}^{i}\\circ\\pi=\\pi\\circ\\lambda^{i}$, qed.}, this\r\nyields that $\\pi$ is a $\\lambda$-ring homomorphism. Since $\\pi$ is the\r\ncanonical projection $K\\rightarrow K\\diagup I$, we thus have proven that the\r\ncanonical projection $K\\rightarrow K\\diagup I$ is a $\\lambda$-ring\r\nhomomorphism. Theorem 2.2 \\textbf{(c)} is proven.\r\n\\end{proof}\r\n\r\n\\textit{Exercise 2.4:} \\textit{Solution:}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 2.3.]Let $t\\in\\operatorname*{Ker}f$, and let $i$ be a\r\npositive integer. Since $t\\in\\operatorname*{Ker}f$, we have $f\\left(\r\nt\\right)  =0$, thus $\\mu^{i}\\left(  f\\left(  t\\right)  \\right)  =\\mu\r\n^{i}\\left(  0\\right)  =0$ (by Theorem 2.1 \\textbf{(d)}).\r\n\r\nSince $f$ is a $\\lambda$-ring homomorphism, we have $\\mu^{i}\\circ\r\nf=f\\circ\\lambda^{i}$, so that $\\left(  \\mu^{i}\\circ f\\right)  \\left(\r\nt\\right)  =\\left(  f\\circ\\lambda^{i}\\right)  \\left(  t\\right)  =f\\left(\r\n\\lambda^{i}\\left(  t\\right)  \\right)  $. Thus, $f\\left(  \\lambda^{i}\\left(\r\nt\\right)  \\right)  =\\left(  \\mu^{i}\\circ f\\right)  \\left(  t\\right)  =\\mu\r\n^{i}\\left(  f\\left(  t\\right)  \\right)  =0$, so that $\\lambda^{i}\\left(\r\nt\\right)  \\in\\operatorname*{Ker}f$.\r\n\r\nNow forget that we fixed $t$ and $i$. We have thus proven that every\r\n$t\\in\\operatorname*{Ker}f$ and every positive integer $i$ satisfy $\\lambda\r\n^{i}\\left(  t\\right)  \\in\\operatorname*{Ker}f$.\r\n\r\nBut the definition of a $\\lambda$-ideal tells us that $\\operatorname*{Ker}f$\r\nis a $\\lambda$-ideal if and only if every $t\\in\\operatorname*{Ker}f$ and every\r\npositive integer $i$ satisfy $\\lambda^{i}\\left(  t\\right)  \\in\r\n\\operatorname*{Ker}f$. Since we know that every $t\\in\\operatorname*{Ker}f$ and\r\nevery positive integer $i$ satisfy $\\lambda^{i}\\left(  t\\right)\r\n\\in\\operatorname*{Ker}f$, we thus conclude that $\\operatorname*{Ker}f$ is a\r\n$\\lambda$-ideal. Theorem 2.3 is proven.\r\n\\end{proof}\r\n\r\n\\subsection{To Section 3}\r\n\r\n\\textit{Exercise 3.1: Solution:}\r\n\r\n\\textit{First solution:} The localization $\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}$ is the subring $\\left\\{  \\dfrac{u}{p^{i}}\\ \\mid\r\n\\ u\\in\\mathbb{Z},\\ i\\in\\mathbb{N}\\right\\}  $ of $\\mathbb{Q}$. Let\r\n$x\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$. We then must show that\r\n$\\dbinom{x}{n}\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ for every\r\n$n\\in\\mathbb{N}$.\r\n\r\nSince $x\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}=\\left\\{  \\dfrac\r\n{u}{p^{i}}\\ \\mid\\ u\\in\\mathbb{Z},\\ i\\in\\mathbb{N}\\right\\}  $, we can write $x$\r\nin the form $\\dfrac{u}{p^{i}}$ for some $u\\in\\mathbb{Z}$ and $i\\in\\mathbb{N}$.\r\nThus,%\r\n\\begin{align*}\r\n\\dbinom{x}{n}  &  =\\dfrac{x\\left(  x-1\\right)  ...\\left(  x-n+1\\right)  }%\r\n{n!}=\\dfrac{\\prod\\limits_{k=0}^{n-1}\\left(  x-k\\right)  }{n!}=\\dfrac\r\n{\\prod\\limits_{k=0}^{n-1}\\left(  \\dfrac{u}{p^{i}}-k\\right)  }{n!}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }x=\\dfrac{u}{p^{i}}\\right) \\\\\r\n&  =\\dfrac{\\prod\\limits_{k=0}^{n-1}\\dfrac{u-kp^{i}}{p^{i}}}{n!}=\\dfrac\r\n{\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)  }{n!\\cdot\\left(\r\np^{i}\\right)  ^{n}}.\r\n\\end{align*}\r\n\r\n\r\nNow, let $p^{v}$ be the highest power of $p$ that divides $n!$. Then,\r\n$\\dfrac{n!}{p^{v}}$ is a positive integer not divisible by $p$. Denoting\r\n$\\dfrac{n!}{p^{v}}$ by $r$, we thus have shown that $r$ is a positive integer\r\nnot divisible by $p$. Thus, $p$ is coprime to $r$ (since $p$ is prime), so\r\nthat $p^{\\varphi\\left(  r\\right)  }\\equiv1\\operatorname{mod}r$ (by Euler's\r\ntheorem), where $\\varphi$ is Euler's totient function.\r\n\r\nNotice that $r=\\dfrac{n!}{p^{v}}$ yields $n!=p^{v}r$, so that $n!\\equiv\r\n0\\operatorname{mod}r$. On the other hand,%\r\n\\[\r\np^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  in}\\cdot\\prod\\limits_{k=0}%\r\n^{n-1}\\left(  u-kp^{i}\\right)  =\\prod\\limits_{k=0}^{n-1}\\left(  p^{\\left(\r\n\\varphi\\left(  r\\right)  -1\\right)  i}\\left(  u-kp^{i}\\right)  \\right)\r\n=\\prod\\limits_{k=0}^{n-1}\\left(  p^{\\left(  \\varphi\\left(  r\\right)\r\n-1\\right)  i}u-p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  i}kp^{i}\\right)\r\n.\r\n\\]\r\nSince $p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  i}kp^{i}=p^{\\left(\r\n\\varphi\\left(  r\\right)  -1\\right)  i+i}k=p^{\\varphi\\left(  r\\right)\r\ni}k=\\left(  \\underbrace{p^{\\varphi\\left(  r\\right)  }}_{\\equiv\r\n1\\operatorname{mod}r}\\right)  ^{i}k\\equiv1^{r}k=k\\operatorname{mod}r$, this\r\nbecomes%\r\n\\begin{align*}\r\np^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  in}\\cdot\\prod\\limits_{k=0}%\r\n^{n-1}\\left(  u-kp^{i}\\right)   &  \\equiv\\prod\\limits_{k=0}^{n-1}\\left(\r\np^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  i}u-k\\right)  =\\underbrace{n!}%\r\n_{\\equiv0\\operatorname{mod}r}\\dbinom{p^{\\left(  \\varphi\\left(  r\\right)\r\n-1\\right)  i}u}{n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\dfrac{\\prod\\limits_{k=0}%\r\n^{n-1}\\left(  p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  i}u-k\\right)\r\n}{n!}=\\dbinom{p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  i}u}{n}\\right) \\\\\r\n&  \\equiv0\\operatorname{mod}r.\r\n\\end{align*}\r\nThus, $\\dfrac{p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  in}\\cdot\r\n\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)  }{r}$ is an integer. Now,%\r\n\\begin{align*}\r\n\\dbinom{x}{n}  &  =\\dfrac{\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)\r\n}{n!\\cdot\\left(  p^{i}\\right)  ^{n}}=\\dfrac{r}{p^{\\left(  \\varphi\\left(\r\nr\\right)  -1\\right)  in}\\cdot\\left(  p^{i}\\right)  ^{n}n!}\\cdot\\dfrac\r\n{p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)  in}\\cdot\\prod\\limits_{k=0}%\r\n^{n-1}\\left(  u-kp^{i}\\right)  }{r}\\\\\r\n&  =\\underbrace{\\dfrac{r}{p^{\\left(  \\varphi\\left(  r\\right)  -1\\right)\r\nin}\\cdot\\left(  p^{i}\\right)  ^{n}p^{v}r}}_{=p^{-v-in-\\left(  \\varphi\\left(\r\nr\\right)  -1\\right)  in}}\\cdot\\underbrace{\\dfrac{p^{\\left(  \\varphi\\left(\r\nr\\right)  -1\\right)  in}\\cdot\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)\r\n}{r}}_{\\text{an integer}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }%\r\nn!=p^{v}r\\right)\r\n\\end{align*}\r\nis a product of a negative power of $p$ with an integer, and therefore lies in\r\n$\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$.\r\n\r\nSo we have shown that $\\dbinom{x}{n}\\in\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}$ for every $x\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}%\r\n\\mathbb{Z}$ and every $n\\in\\mathbb{N}$. This proves that $\\left\\{\r\n1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ is a binomial ring, qed.\r\n\r\n\\textit{Second solution (sketched):} Let $x\\in\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}$. Just as in the First solution, we can write $x$ in the form\r\n$\\dfrac{u}{p^{i}}$ for some $u\\in\\mathbb{Z}$ and $i\\in\\mathbb{N}$, and we see\r\nthat $\\dbinom{x}{n}=\\dfrac{\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)\r\n}{n!\\cdot\\left(  p^{i}\\right)  ^{n}}$. A careful analysis now shows that every\r\nprime $q$ that is distinct from $p$ appears in the prime factor decomposition\r\nof $\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)  $ at least as often as it\r\nappears in that of $n!\\cdot\\left(  p^{i}\\right)  ^{n}$. As a consequence, the\r\nratio $\\dfrac{\\prod\\limits_{k=0}^{n-1}\\left(  u-kp^{i}\\right)  }%\r\n{n!\\cdot\\left(  p^{i}\\right)  ^{n}}$, once brought to simplest form, can have\r\nno primes distinct from $p$ in its denominator. Thus, this ratio (which, as we\r\nknow, is $\\dbinom{x}{n}$) lies in $\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}$. So we have shown that $\\dbinom{x}{n}\\in\\left\\{\r\n1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ for every $x\\in\\left\\{  1,p,p^{2}%\r\n,...\\right\\}  ^{-1}\\mathbb{Z}$ and every $n\\in\\mathbb{N}$. This proves that\r\n$\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ is a binomial ring, qed.\r\n\r\n\\textit{Third solution:} \\cite[Exercise 3.26]{Grin-detn} shows that if $a$ and\r\n$b$ are two integers such that $b\\neq0$, and if $n\\in\\mathbb{N}$, then\r\n\\begin{equation}\r\n\\text{there exists some }N\\in\\mathbb{N}\\text{ such that }b^{N}\\dbinom{a/b}%\r\n{n}\\in\\mathbb{Z}. \\label{sol.3.1.sol3.1}%\r\n\\end{equation}\r\n\r\n\r\nLet $x\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$. We then must show\r\nthat $\\dbinom{x}{n}\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ for\r\nevery $n\\in\\mathbb{N}$.\r\n\r\nFix $n\\in\\mathbb{N}$. We have $x\\in\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}=\\left\\{  \\dfrac{u}{p^{i}}\\ \\mid\\ u\\in\\mathbb{Z},\\ i\\in\r\n\\mathbb{N}\\right\\}  $. Thus, $x=\\dfrac{u}{p^{i}}$ for some $u\\in\\mathbb{Z}$\r\nand $i\\in\\mathbb{N}$. But (\\ref{sol.3.1.sol3.1}) (applied to $a=u$ and\r\n$b=p^{i}$) shows that there exists some $N\\in\\mathbb{N}$ such that $\\left(\r\np^{i}\\right)  ^{N}\\dbinom{u/p^{i}}{n}\\in\\mathbb{Z}$. Consider this $N$. We\r\nhave $x=\\dfrac{u}{p^{i}}=u/p^{i}$, so that\r\n\\begin{align*}\r\n\\dbinom{x}{n}  &  =\\dbinom{u/p^{i}}{n}\\in\\dfrac{1}{\\left(  p^{i}\\right)  ^{N}%\r\n}\\mathbb{Z}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  p^{i}\\right)\r\n^{N}\\dbinom{u/p^{i}}{n}\\in\\mathbb{Z}\\right) \\\\\r\n&  \\subseteq\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}.\r\n\\end{align*}\r\n\r\n\r\nSo we have shown that $\\dbinom{x}{n}\\in\\left\\{  1,p,p^{2},...\\right\\}\r\n^{-1}\\mathbb{Z}$ for every $x\\in\\left\\{  1,p,p^{2},...\\right\\}  ^{-1}%\r\n\\mathbb{Z}$ and every $n\\in\\mathbb{N}$. This proves that $\\left\\{\r\n1,p,p^{2},...\\right\\}  ^{-1}\\mathbb{Z}$ is a binomial ring, qed.\r\n\r\n\\textit{Exercise 3.2:} \\textit{Hints to solution:} Let $\\mathbb{N}_{K}^{+}$ be\r\nthe subset $\\left\\{  1,2,3,...\\right\\}  $ of $K$. Obviously, this subset is\r\nmultiplicatively closed and contains no zero-divisors. Hence, the localization\r\n$\\left(  \\mathbb{N}_{K}^{+}\\right)  ^{-1}K$ can be considered as an extension\r\nring of $K$. We now can define $\\dbinom{x}{i}\\in\\left(  \\mathbb{N}_{K}%\r\n^{+}\\right)  ^{-1}K$ for every $x\\in\\left(  \\mathbb{N}_{K}^{+}\\right)  ^{-1}K$\r\nand $i\\in\\mathbb{N}$. It remains to show that $\\dbinom{x}{i}\\in K$ for every\r\n$x\\in K$ and $i\\in\\mathbb{N}$, given that $\\dbinom{x}{i}\\in K$ for every $x\\in\r\nE$ and $i\\in\\mathbb{N}$.\r\n\r\nThis will follow once we show the following three claims:\r\n\r\n\\textit{Claim 1:} Let $i\\in\\mathbb{N}$. Then, the polynomial $\\dbinom{X+Y}%\r\n{i}\\in\\mathbb{Q}\\left[  X,Y\\right]  $ is a polynomial in $\\dbinom{X}{0}$,\r\n$\\dbinom{X}{1}$, $...$, $\\dbinom{X}{i}$, $\\dbinom{Y}{0}$, $\\dbinom{Y}{1}$,\r\n$...$, $\\dbinom{Y}{i}$ with integer coefficients.\r\n\r\n\\textit{Claim 2:} Let $i\\in\\mathbb{N}$. Then, the polynomial $\\dbinom{-X}%\r\n{i}\\in\\mathbb{Q}\\left[  X\\right]  $ is a polynomial in $\\dbinom{X}{0}$,\r\n$\\dbinom{X}{1}$, $...$, $\\dbinom{X}{i}$ with integer coefficients.\r\n\r\n\\textit{Claim 3:} Let $i\\in\\mathbb{N}$. Then, the polynomial $\\dbinom{XY}%\r\n{i}\\in\\mathbb{Q}\\left[  X,Y\\right]  $ is a polynomial in $\\dbinom{X}{0}$,\r\n$\\dbinom{X}{1}$, $...$, $\\dbinom{X}{i}$, $\\dbinom{Y}{0}$, $\\dbinom{Y}{1}$,\r\n$...$, $\\dbinom{Y}{i}$ with integer coefficients.\r\n\r\n\\textit{Proof of Claim 1:} In our proof of Theorem 3.1, we have proven the\r\nidentity (\\ref{vandermonde}) for every $k\\in\\mathbb{N}$, $x\\in\\mathbb{Z}$ and\r\n$y\\in\\mathbb{Z}$. Renaming $i$ as $j$ in this identity, we can rewrite it as%\r\n\\[\r\n\\dbinom{x+y}{k}=\\sum_{j=0}^{k}\\dbinom{x}{j}\\dbinom{y}{k-j}.\r\n\\]\r\nApplying this to $k=i$, we obtain%\r\n\\begin{equation}\r\n\\dbinom{x+y}{i}=\\sum_{j=0}^{i}\\dbinom{x}{j}\\dbinom{y}{i-j}.\r\n\\label{sol.3.2.cl1.pf.0}%\r\n\\end{equation}\r\n\r\n\r\nNow, in the polynomial ring $\\mathbb{Q}\\left[  X,Y\\right]  $, we have the\r\nfollowing equality:%\r\n\\begin{equation}\r\n\\dbinom{X+Y}{i}=\\sum_{j=0}^{i}\\dbinom{X}{j}\\dbinom{Y}{i-j}.\r\n\\label{sol.3.2.cl1.pf.1}%\r\n\\end{equation}\r\n(\\textit{Proof of (\\ref{sol.3.2.cl1.pf.1}):} Both sides of the equality\r\n(\\ref{sol.3.2.cl1.pf.1}) are polynomials in $X$ and $Y$ with rational\r\ncoefficients. Hence, in order to prove this equality, we only need to check\r\nthat it holds whenever it is evaluated at $X=x$ and $Y=y$ for two nonnegative\r\nintegers $x$ and $y$. But the latter follows from (\\ref{sol.3.2.cl1.pf.0}).\r\nThus, (\\ref{sol.3.2.cl1.pf.1}) is proven.)\r\n\r\nThe equality (\\ref{sol.3.2.cl1.pf.1}) immediately proves Claim 2.\r\n\r\n\\textit{Proof of Claim 2:} We have the identity $\\dbinom{-X}{i}=\\left(\r\n-1\\right)  ^{i}\\dbinom{X+i-1}{i}$ (this is the so-called \\textit{upper\r\nnegation identity}). Thus,%\r\n\\[\r\n\\dbinom{-X}{i}=\\left(  -1\\right)  ^{i}\\underbrace{\\dbinom{X+i-1}{i}%\r\n}_{\\substack{=\\sum_{j=0}^{i}\\dbinom{X}{j}\\dbinom{i-1}{i-j}\\\\\\text{(by\r\n(\\ref{sol.3.2.cl1.pf.1}), with }i-1\\text{ substituted for }Y\\text{)}}}=\\left(\r\n-1\\right)  ^{i}\\sum_{j=0}^{i}\\dbinom{X}{j}\\dbinom{i-1}{i-j}.\r\n\\]\r\nThis proves Claim 2.\r\n\r\nClaim 3 is noticeably harder than each of Claims 1 and Claim 2. One way to\r\nprove Claim 3 is to use the proof of Theorem 7.1 below. For a completely\r\nelementary (combinatorial) proof of Claim 3 (leading to a different\r\npolynomial!!), see \\cite[Exercise 3.8]{Grin-detn}. Let me finally sketch a\r\nthird proof of Claim 3:\r\n\r\n\\textit{Proof of Claim 3:} Recall the fact (\\cite[Proposition I.7.3]{Harts77})\r\nthat the subset%\r\n\\[\r\n\\left\\{  p\\in\\mathbb{Q}\\left[  X\\right]  \\text{ }\\mid\\ p\\left(  n\\right)\r\n\\in\\mathbb{Z}\\text{ for every }n\\in\\mathbb{Z}\\right\\}\r\n\\]\r\nof the polynomial ring $\\mathbb{Q}\\left[  X\\right]  $ is the $\\mathbb{Z}%\r\n$-linear span of the polynomials $\\dbinom{X}{0}$, $\\dbinom{X}{1}$, $\\dbinom\r\n{X}{2}$, $...$. This generalizes to two variables: The subset\r\n\\[\r\n\\left\\{  p\\in\\mathbb{Q}\\left[  X,Y\\right]  \\text{ }\\mid\\ p\\left(  n,m\\right)\r\n\\in\\mathbb{Z}\\text{ for every }n\\in\\mathbb{Z}\\text{ and every }m\\in\r\n\\mathbb{Z}\\right\\}\r\n\\]\r\nof the polynomial ring $\\mathbb{Q}\\left[  X,Y\\right]  $ is the $\\mathbb{Z}%\r\n$-linear span of the polynomials $\\dbinom{X}{i}\\dbinom{Y}{j}$ for\r\n$i\\in\\mathbb{N}$ and $j\\in\\mathbb{N}$. Of course, the polynomial $\\dbinom\r\n{XY}{i}$ belongs to this subset, so we conclude that it belongs to this\r\n$\\mathbb{Z}$-linear span. This proves Claim 3 again.\r\n\r\nNow, all three Claims 1, 2 and 3 are proven. Using these claims, we can see\r\n(by induction) that the values%\r\n\\[\r\n\\dbinom{x}{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for }x\\in K\\text{ and }i\\in\\mathbb{N}%\r\n\\]\r\ncan be written as polynomials (with integer coefficients) in the values%\r\n\\[\r\n\\dbinom{x}{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for }x\\in E\\text{ and }i\\in\\mathbb{N}.\r\n\\]\r\nSince we have assumed that the latter values belong to $K$, we can therefore\r\nconclude that the former values also belong to $K$. This solves the exercise.\r\n\r\n\\textit{Exercise 3.3: Hints to solution:} \\textbf{(a)} Use Theorem 2.1\r\n\\textbf{(a)} and $\\left(  1+pT\\right)  ^{x}\\left(  1+pT\\right)  ^{y}=\\left(\r\n1+pT\\right)  ^{x+y}$.\r\n\r\n\\textbf{(b)} Use the binomial formula.\r\n\r\n\\textit{Detailed solution:} \\textbf{(a)} Define a map $\\lambda_{T}%\r\n:K\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ by%\r\n\\[\r\n\\left(  \\lambda_{T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\right)  .\r\n\\]\r\nThen,\r\n\\begin{equation}\r\n\\lambda_{T}\\left(  x\\right)  =\\left(  1+pT\\right)  ^{x}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K \\label{sol.3.3.a.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.3.3.a.1}):} Fix $x\\in K$. Then,\r\n$\\lambda_{T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}$. Hence, for every $i\\in\\mathbb{N}$, we have%\r\n\\begin{align*}\r\n&  \\left(  \\text{the coefficient of }T^{i}\\text{ in the power series }%\r\n\\lambda_{T}\\left(  x\\right)  \\right) \\\\\r\n&  =\\lambda^{i}\\left(  x\\right)  =\\left(  \\text{the coefficient of the power\r\nseries }\\left(  1+pT\\right)  ^{x}\\text{ before }T^{i}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\lambda^{i}\\left(\r\nx\\right)  \\right) \\\\\r\n&  =\\left(  \\text{the coefficient of }T^{i}\\text{ in the power series }\\left(\r\n1+pT\\right)  ^{x}\\right)  .\r\n\\end{align*}\r\nIn other words, $\\lambda_{T}\\left(  x\\right)  =\\left(  1+pT\\right)  ^{x}$.\r\nThis proves (\\ref{sol.3.3.a.1}).}. Thus, we can easily see that every $x\\in K$\r\nsatisfies $\\lambda_{T}\\left(  x\\right)  \\equiv1+xT\\operatorname{mod}%\r\nT^{2}K\\left[  \\left[  T\\right]  \\right]  $\\ \\ \\ \\ \\footnote{\\textit{Proof.}\r\nFix $x\\in K$. Recall that the power series $p$ has coefficient $1$ before\r\n$T^{0}$. Thus, $p\\equiv1\\operatorname{mod}TK\\left[  \\left[  T\\right]  \\right]\r\n$, so that $p-1\\in TK\\left[  \\left[  T\\right]  \\right]  $. Hence,\r\n$pT-T=T\\underbrace{\\left(  p-1\\right)  }_{\\in TK\\left[  \\left[  T\\right]\r\n\\right]  }\\in TTK\\left[  \\left[  T\\right]  \\right]  =T^{2}K\\left[  \\left[\r\nT\\right]  \\right]  $. In other words, $pT\\equiv T\\operatorname{mod}%\r\nT^{2}K\\left[  \\left[  T\\right]  \\right]  $.\r\n\\par\r\nNow, (\\ref{sol.3.3.a.1}) yields\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  x\\right)   &  =\\left(  1+pT\\right)  ^{x}=\\sum\r\n_{k\\in\\mathbb{N}}\\dbinom{x}{k}\\left(  pT\\right)  ^{k}\\\\\r\n&  =\\underbrace{\\dbinom{x}{0}}_{=1}\\underbrace{\\left(  pT\\right)  ^{0}}%\r\n_{=1}+\\underbrace{\\dbinom{x}{1}}_{=x}\\underbrace{\\left(  pT\\right)  ^{1}%\r\n}_{=pT}+\\sum_{\\substack{k\\in\\mathbb{N};\\\\k\\geq2}}\\dbinom{x}{k}%\r\n\\underbrace{\\left(  pT\\right)  ^{k}}_{\\substack{=p^{k}T^{k}=p^{k}T^{k-2}%\r\nT^{2}\\\\\\text{(since }k\\geq2\\text{)}}}\\\\\r\n&  =1+x\\underbrace{pT}_{\\equiv T\\operatorname{mod}T^{2}K\\left[  \\left[\r\nT\\right]  \\right]  }+\\sum_{\\substack{k\\in\\mathbb{N};\\\\k\\geq2}}\\dbinom{x}%\r\n{k}p^{k}T^{k-2}\\underbrace{T^{2}}_{\\equiv0\\operatorname{mod}T^{2}K\\left[\r\n\\left[  T\\right]  \\right]  }\\\\\r\n&  \\equiv1+xT+\\underbrace{\\sum_{\\substack{k\\in\\mathbb{N};\\\\k\\geq2}}\\dbinom\r\n{x}{k}p^{k}T^{k-2}0}_{=0}=1+xT\\operatorname{mod}T^{2}K\\left[  \\left[\r\nT\\right]  \\right]  ,\r\n\\end{align*}\r\nqed.}. Hence, we have $\\lambda^{0}\\left(  x\\right)  =1$ and $\\lambda\r\n^{1}\\left(  x\\right)  =x$ for every $x\\in K$\\ \\ \\ \\ \\footnote{\\textit{Proof.}\r\nLet $x\\in K$. Then, $\\lambda_{T}\\left(  x\\right)  \\equiv1+xT\\operatorname{mod}%\r\nT^{2}K\\left[  \\left[  T\\right]  \\right]  $. In other words,\r\n\\[\r\n\\left(  \\text{the coefficient of }T^{0}\\text{ in the power series }\\lambda\r\n_{T}\\left(  x\\right)  \\right)  =1\r\n\\]\r\nand%\r\n\\[\r\n\\left(  \\text{the coefficient of }T^{1}\\text{ in the power series }\\lambda\r\n_{T}\\left(  x\\right)  \\right)  =x.\r\n\\]\r\nBut from $\\lambda_{T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  x\\right)  T^{i}$, we obtain%\r\n\\[\r\n\\lambda^{0}\\left(  x\\right)  =\\left(  \\text{the coefficient of }T^{0}\\text{ in\r\nthe power series }\\lambda_{T}\\left(  x\\right)  \\right)  =1\r\n\\]\r\nand%\r\n\\[\r\n\\lambda^{1}\\left(  x\\right)  =\\left(  \\text{the coefficient of }T^{1}\\text{ in\r\nthe power series }\\lambda_{T}\\left(  x\\right)  \\right)  =x.\r\n\\]\r\nQed.}.\r\n\r\nOn the other hand, the equality (\\ref{vandermonde}) holds for every\r\n$k\\in\\mathbb{N}$, $x\\in K$ and $y\\in K$\\ \\ \\ \\ \\footnote{This was proven\r\nduring our proof of Theorem 3.2.}. In other words, every $k\\in\\mathbb{N}$,\r\n$x\\in K$ and $y\\in K$ satisfy%\r\n\\begin{equation}\r\n\\dbinom{x+y}{k}=\\sum_{i=0}^{k}\\dbinom{x}{i}\\dbinom{y}{k-i}.\r\n\\label{sol.3.3.a.vandermonde}%\r\n\\end{equation}\r\n\r\n\r\nNow, every $x\\in K$ and $y\\in K$ satisfy%\r\n\\begin{align*}\r\n&  \\underbrace{\\left(  1+T\\right)  ^{x}}_{\\substack{=\\sum_{k\\in\\mathbb{N}%\r\n}\\dbinom{x}{k}T^{k}\\\\\\text{(by the definition of }\\left(  1+T\\right)\r\n^{x}\\text{)}}}\\underbrace{\\left(  1+T\\right)  ^{y}}_{\\substack{=\\sum\r\n_{k\\in\\mathbb{N}}\\dbinom{y}{k}T^{k}\\\\\\text{(by the definition of }\\left(\r\n1+T\\right)  ^{y}\\text{)}}}\\\\\r\n&  =\\left(  \\sum_{k\\in\\mathbb{N}}\\dbinom{x}{k}T^{k}\\right)  \\left(  \\sum\r\n_{k\\in\\mathbb{N}}\\dbinom{y}{k}T^{k}\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}\\underbrace{\\left(  \\sum_{i=0}^{k}\\dbinom{x}%\r\n{i}\\dbinom{y}{k-i}\\right)  }_{=\\dbinom{x+y}{k}}T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\npower series}\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}\\dbinom{x+y}{k}T^{k}=\\left(  1+T\\right)  ^{x+y}%\r\n\\end{align*}\r\n(since $\\left(  1+T\\right)  ^{x+y}$ is defined as $\\sum_{k\\in\\mathbb{N}%\r\n}\\dbinom{x+y}{k}T^{k}$). We can substitute $pT$ for $T$ in this equality;\r\nthus, we obtain%\r\n\\[\r\n\\left(  1+pT\\right)  ^{x}\\left(  1+pT\\right)  ^{y}=\\left(  1+pT\\right)  ^{x+y}%\r\n\\]\r\nfor every $x\\in K$ and $y\\in K$. Now, if $x$ and $y$ are elements of $K$, then%\r\n\\[\r\n\\underbrace{\\lambda_{T}\\left(  x\\right)  }_{\\substack{=\\left(  1+pT\\right)\r\n^{x}\\\\\\text{(by (\\ref{sol.3.3.a.1}))}}}\\cdot\\underbrace{\\lambda_{T}\\left(\r\ny\\right)  }_{\\substack{=\\left(  1+pT\\right)  ^{y}\\\\\\text{(by\r\n(\\ref{sol.3.3.a.1}), applied}\\\\\\text{to }y\\text{ instead of }x\\text{)}%\r\n}}=\\left(  1+pT\\right)  ^{x}\\left(  1+pT\\right)  ^{y}=\\left(  1+pT\\right)\r\n^{x+y}.\r\n\\]\r\nComparing this with%\r\n\\[\r\n\\lambda_{T}\\left(  x+y\\right)  =\\left(  1+pT\\right)  ^{x+y}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.3.3.a.1}), applied to\r\n}x+y\\text{ instead of }x\\right)  ,\r\n\\]\r\nwe obtain\r\n\\begin{equation}\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda\r\n_{T}\\left(  x+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K\\text{ and\r\n}y\\in K. \\label{sol.3.3.a.almost}%\r\n\\end{equation}\r\nBut Theorem 2.1 \\textbf{(a)} shows that (\\ref{sol.3.3.a.almost}) holds if and\r\nonly if $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is\r\na $\\lambda$-ring. Thus, $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring (since (\\ref{sol.3.3.a.almost})\r\nholds). This solves Exercise 3.3 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Assume that $p=1$. Define a map $\\lambda_{T}:K\\rightarrow\r\nK\\left[  \\left[  T\\right]  \\right]  $ as in our solution to Exercise 3.3\r\n\\textbf{(a)}. Then,%\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  =\\left(  1+pT\\right)  ^{x}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in K.\r\n\\]\r\n(This is the identity (\\ref{sol.3.3.a.1}), and has already been proven above.)\r\nNow,%\r\n\\begin{equation}\r\n\\lambda^{i}\\left(  x\\right)  =\\dbinom{x}{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every\r\n}x\\in K\\text{ and }i\\in\\mathbb{N} \\label{sol.3.3.b.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.3.3.b.1}):} Let $x\\in K$. Comparing the\r\nidentity $\\lambda_{T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  x\\right)  T^{i}$ with $\\lambda_{T}\\left(  x\\right)  =\\left(\r\n1+\\underbrace{p}_{=1}T\\right)  ^{x}=\\left(  1+T\\right)  ^{x}$, we obtain\r\n$\\sum_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}=\\left(  1+pT\\right)\r\n^{x}$. Hence, for every $i\\in\\mathbb{N}$, we have%\r\n\\begin{align*}\r\n\\lambda^{i}\\left(  x\\right)   &  =\\left(  \\text{the coefficient of the power\r\nseries }\\left(  1+T\\right)  ^{x}\\text{ before }T^{i}\\right) \\\\\r\n&  =\\dbinom{x}{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  1+T\\right)\r\n^{x}=\\sum_{k\\in\\mathbb{N}}\\dbinom{x}{k}T^{k}\\right)  .\r\n\\end{align*}\r\nThis proves (\\ref{sol.3.3.b.1}).}. Thus, the maps $\\lambda^{i}$ defined in\r\nExercise 3.3 \\textbf{(a)} are identical with the maps $\\lambda^{i}$ defined in\r\nTheorem 3.2. Hence, the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ defined in Exercise 3.3 \\textbf{(a)} is identical\r\nwith the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ defined in Theorem 3.2. This solves Exercise 3.3\r\n\\textbf{(b)}.\r\n\r\n\\textit{Exercise 3.4: Hints to solution:} It is clear from the very definition\r\nof $\\lambda^{i}$ that Theorem 2.1 \\textbf{(a)} is to be applied here.\r\n\r\n\\textit{Exercise 3.5: Hints to solution:} Same idea as for Exercise 3.4.\r\n\r\n\\subsection{To Section 4}\r\n\r\n\\textit{Exercise 4.2: Detailed solution:} There are several ways to solve\r\nExercise 4.2 (many people would call it trivial). Here is not the simplest\r\none, but the easiest-to-formalize one:\r\n\r\n\\textbf{(a)} Let us prove that every $n\\in\\left\\{  0,1,...,m\\right\\}  $\r\nsatisfies%\r\n\\begin{equation}\r\n\\prod\\limits_{i=1}^{n}\\left(  1+\\alpha_{i}\\right)  =\\sum\\limits_{S\\subseteq\r\n\\left\\{  1,2,...,n\\right\\}  }\\prod\\limits_{k\\in S}\\alpha_{k}. \\label{4.2.pf.1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{4.2.pf.1}).} We will prove (\\ref{4.2.pf.1}) by\r\ninduction over $n$:\r\n\r\n\\textit{Induction base:} If $n=0$, then $\\prod\\limits_{i=1}^{n}\\left(\r\n1+\\alpha_{i}\\right)  =\\left(  \\text{empty product}\\right)  =1$ and\r\n\\begin{align*}\r\n\\sum\\limits_{S\\subseteq\\left\\{  1,2,...,n\\right\\}  }\\prod\\limits_{k\\in\r\nS}\\alpha_{k}  &  =\\sum\\limits_{S\\subseteq\\left\\{  1,2,...,0\\right\\}  }%\r\n\\prod\\limits_{k\\in S}\\alpha_{k}=\\prod\\limits_{k\\in\\varnothing}\\alpha_{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since the only subset }S\\ \\text{of\r\n}\\left\\{  1,2,...,0\\right\\}  \\text{ is }\\varnothing\\right) \\\\\r\n&  =\\left(  \\text{empty product}\\right)  =1.\r\n\\end{align*}\r\nThus, $\\prod\\limits_{i=1}^{n}\\left(  1+\\alpha_{i}\\right)  =\\sum\r\n\\limits_{S\\subseteq\\left\\{  1,2,...,n\\right\\}  }\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}$ holds for $n=0$. In other words, we have proven (\\ref{4.2.pf.1})\r\nfor $n=0$. This completes the induction base.\r\n\r\n\\textit{Induction step:} Let $N\\in\\left\\{  0,1,...,m-1\\right\\}  $. Assume that\r\n(\\ref{4.2.pf.1}) holds for $n=N$. Now let us prove (\\ref{4.2.pf.1}) for\r\n$n=N+1$.\r\n\r\nSince (\\ref{4.2.pf.1}) holds for $n=N$, we have%\r\n\\[\r\n\\prod\\limits_{i=1}^{N}\\left(  1+\\alpha_{i}\\right)  =\\sum\\limits_{S\\subseteq\r\n\\left\\{  1,2,...,N\\right\\}  }\\prod\\limits_{k\\in S}\\alpha_{k}.\r\n\\]\r\n\r\n\r\nNow, let $P$ be the set of all subsets of $\\left\\{  1,2,...,N\\right\\}  $.\r\nThen, $P$ is the set of all subsets $S$ of $\\left\\{  1,2,...,N+1\\right\\}  $\r\nsatisfying $N+1\\notin S$ (because subsets $S$ of $\\left\\{\r\n1,2,...,N+1\\right\\}  $ satisfying $N+1\\notin S$ are the same thing as subsets\r\nof $\\left\\{  1,2,...,N\\right\\}  $). Therefore, summing over all $S\\in P$ is\r\nthe same as summing over all subsets $S$ of $\\left\\{  1,2,...,N+1\\right\\}  $\r\nsatisfying $N+1\\notin S$. Hence, $\\sum\\limits_{S\\in P}\\prod\\limits_{k\\in\r\nS}\\alpha_{k}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,N+1\\right\\}\r\n;\\\\N+1\\notin S}}\\prod\\limits_{k\\in S}\\alpha_{k}$.\r\n\r\nOn the other hand, summing over all $S\\in P$ is the same as summing over all\r\nsubsets $S$ of $\\left\\{  1,2,...,N\\right\\}  $ (since $P$ is the set of all\r\nsubsets of $\\left\\{  1,2,...,N\\right\\}  $). Thus, $\\sum\\limits_{S\\in P}%\r\n\\prod\\limits_{k\\in S}\\alpha_{k}=\\sum\\limits_{S\\subseteq\\left\\{\r\n1,2,...,N\\right\\}  }\\prod\\limits_{k\\in S}\\alpha_{k}$.\r\n\r\nNotice that every $S\\in P$ is a subset of $\\left\\{  1,2,...,N\\right\\}  $\r\n(since $P$ is the set of all subsets of $\\left\\{  1,2,...,N\\right\\}  $) and\r\nthus satisfies $N+1\\notin S$.\r\n\r\nNow, let $Q$ be the set of all subsets $T$ of $\\left\\{  1,2,...,N+1\\right\\}  $\r\nsatisfying $N+1\\in T$. Then, summing over all $T\\in Q$ is the same as summing\r\nover all subsets $T$ of $\\left\\{  1,2,...,N+1\\right\\}  $ satisfying $N+1\\in\r\nT$. Thus, $\\sum\\limits_{T\\in Q}\\prod\\limits_{k\\in T}\\alpha_{k}=\\sum\r\n\\limits_{\\substack{T\\subseteq\\left\\{  1,2,...,N+1\\right\\}  ;\\\\N+1\\in T}%\r\n}\\prod\\limits_{k\\in T}\\alpha_{k}$. Renaming the index $T$ as $S$ in both sides\r\nof this equation, we obtain $\\sum\\limits_{S\\in Q}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}=\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,N+1\\right\\}\r\n;\\\\N+1\\in S}}\\prod\\limits_{k\\in S}\\alpha_{k}$.\r\n\r\nFrom the definitions of $P$ and $Q$, it easily follows that every $S\\in P$\r\nsatisfies $S\\cup\\left\\{  N+1\\right\\}  \\in Q$\\ \\ \\ \\ \\footnote{\\textit{Proof.}\r\nLet $S\\in P$. Then, $S$ is a subset of $\\left\\{  1,2,...,N\\right\\}  $ (since\r\n$P$ is the set of all subsets of $\\left\\{  1,2,...,N\\right\\}  $). Thus,\r\n$S\\cup\\left\\{  N+1\\right\\}  $ is a subset of $\\left\\{  1,2,...,N+1\\right\\}  $.\r\nClearly, $N+1\\in S\\cup\\left\\{  N+1\\right\\}  $. Thus, $S\\cup\\left\\{\r\nN+1\\right\\}  $ is a subset of $\\left\\{  1,2,...,N+1\\right\\}  $ satisfying\r\n$N+1\\in S\\cup\\left\\{  N+1\\right\\}  $. In other words, $S\\cup\\left\\{\r\nN+1\\right\\}  \\in Q$ (since $Q$ is the set of all subsets $T$ of $\\left\\{\r\n1,2,...,N+1\\right\\}  $ satisfying $N+1\\in T$), qed.}. Hence, we can define a\r\nmap $\\iota:P\\rightarrow Q$ by%\r\n\\[\r\n\\left(  \\iota\\left(  S\\right)  =S\\cup\\left\\{  N+1\\right\\}\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for any }S\\in P\\right)  .\r\n\\]\r\nThis map $\\iota$ is injective (because if two sets $S\\in P$ and $S^{\\prime}\\in\r\nP$ satisfy $\\iota\\left(  S\\right)  =\\iota\\left(  S^{\\prime}\\right)  $, then\r\n$S=S^{\\prime}$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $S\\in P$ and $S^{\\prime\r\n}\\in P$ be two sets satisfying $\\iota\\left(  S\\right)  =\\iota\\left(\r\nS^{\\prime}\\right)  $.\r\n\\par\r\nThe set $S$ is a subset of $\\left\\{  1,2,...,N\\right\\}  $ (since $S\\in P$ and\r\nsince $P$ is the set of all subsets of $\\left\\{  1,2,...,N\\right\\}  $). Hence,\r\n$N+1\\notin S$. But $\\iota\\left(  S\\right)  =S\\cup\\left\\{  N+1\\right\\}  $, so\r\nthat%\r\n\\[\r\n\\iota\\left(  S\\right)  \\setminus\\left\\{  N+1\\right\\}  =\\left(  S\\cup\\left\\{\r\nN+1\\right\\}  \\right)  \\setminus\\left\\{  N+1\\right\\}  =\\underbrace{\\left(\r\nS\\setminus\\left\\{  N+1\\right\\}  \\right)  }_{=S\\text{ (since }N+1\\notin\r\nS\\text{)}}\\cup\\underbrace{\\left(  \\left\\{  N+1\\right\\}  \\setminus\\left\\{\r\nN+1\\right\\}  \\right)  }_{=\\varnothing}=S\\cup\\varnothing=S.\r\n\\]\r\nSimilarly, $\\iota\\left(  S^{\\prime}\\right)  \\setminus\\left\\{  N+1\\right\\}\r\n=S^{\\prime}$. Hence, $S=\\underbrace{\\iota\\left(  S\\right)  }_{=\\iota\\left(\r\nS^{\\prime}\\right)  }\\setminus\\left\\{  N+1\\right\\}  =\\iota\\left(  S^{\\prime\r\n}\\right)  \\setminus\\left\\{  N+1\\right\\}  =S^{\\prime}$, qed.}) and surjective\r\n(because every $T\\in Q$ satisfies $T=\\iota\\left(  S\\right)  $ for some $S\\in\r\nP$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $T\\in Q$. We want to find an $S\\in P$\r\nsuch that $T=\\iota\\left(  S\\right)  $.\r\n\\par\r\nWe have $T\\in Q$. In other words, $T$ is a subset of $\\left\\{\r\n1,2,...,N+1\\right\\}  $ satisfying $N+1\\in T$ (since $Q$ is the set of all\r\nsubsets $T$ of $\\left\\{  1,2,...,N+1\\right\\}  $ satisfying $N+1\\in T$).\r\n\\par\r\nLet $S=T\\setminus\\left\\{  N+1\\right\\}  $. Since $T$ is a subset of $\\left\\{\r\n1,2,...,N+1\\right\\}  $, it is clear that $T\\setminus\\left\\{  N+1\\right\\}  $ is\r\na subset of $\\left\\{  1,2,...,N+1\\right\\}  \\setminus\\left\\{  N+1\\right\\}\r\n=\\left\\{  1,2,...,N\\right\\}  $, so that $T\\setminus\\left\\{  N+1\\right\\}  \\in\r\nP$ (since $P$ is the set of all subsets of $\\left\\{  1,2,...,N\\right\\}  $).\r\nHence, $S=T\\setminus\\left\\{  N+1\\right\\}  \\in P$.\r\n\\par\r\nSince $N+1\\in T$, we have $\\left\\{  N+1\\right\\}  \\subseteq T$ and thus\r\n$\\left(  T\\setminus\\left\\{  N+1\\right\\}  \\right)  \\cup\\left\\{  N+1\\right\\}\r\n=T$. Now, $\\iota\\left(  S\\right)  =S\\cup\\left\\{  N+1\\right\\}  =\\left(\r\nT\\setminus\\left\\{  N+1\\right\\}  \\right)  \\cup\\left\\{  N+1\\right\\}  =T$. Hence,\r\nwe have found an $S\\in P$ such that $T=\\iota\\left(  S\\right)  $. Qed.}). Thus,\r\n$\\iota$ is a bijective map. Hence, we can substitute $S$ for $\\iota\\left(\r\nS\\right)  $ in the sum $\\sum\\limits_{S\\in P}\\prod\\limits_{k\\in\\iota\\left(\r\nS\\right)  }\\alpha_{k}$, so that $\\sum\\limits_{S\\in P}\\prod\\limits_{k\\in\r\n\\iota\\left(  S\\right)  }\\alpha_{k}=\\sum\\limits_{S\\in Q}\\prod\\limits_{k\\in\r\nS}\\alpha_{k}$. Since every $S\\in P$ satisfies\r\n\\begin{align*}\r\n\\prod\\limits_{k\\in\\iota\\left(  S\\right)  }\\alpha_{k}  &  =\\prod\\limits_{k\\in\r\nS\\cup\\left\\{  N+1\\right\\}  }\\alpha_{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\iota\\left(  S\\right)  =S\\cup\\left\\{  N+1\\right\\}  \\right) \\\\\r\n&  =\\alpha_{N+1}\\prod\\limits_{k\\in S}\\alpha_{k}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }S\\in P\\text{, so that }N+1\\notin S\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $\\sum\\limits_{S\\in P}\\left(  \\alpha_{N+1}\\prod\\limits_{k\\in\r\nS}\\alpha_{k}\\right)  =\\sum\\limits_{S\\in Q}\\prod\\limits_{k\\in S}\\alpha_{k}$.\r\n\r\nNow,%\r\n\\begin{align*}\r\n\\sum\\limits_{S\\subseteq\\left\\{  1,2,...,N+1\\right\\}  }\\prod\\limits_{k\\in\r\nS}\\alpha_{k}  &  =\\underbrace{\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,N+1\\right\\}  ;\\\\N+1\\notin S}}\\prod\\limits_{k\\in S}\\alpha_{k}}%\r\n_{=\\sum\\limits_{S\\in P}\\prod\\limits_{k\\in S}\\alpha_{k}}+\\underbrace{\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,N+1\\right\\}  ;\\\\N+1\\in S}%\r\n}\\prod\\limits_{k\\in S}\\alpha_{k}}_{=\\sum\\limits_{S\\in Q}\\prod\\limits_{k\\in\r\nS}\\alpha_{k}=\\sum\\limits_{S\\in P}\\left(  \\alpha_{N+1}\\prod\\limits_{k\\in\r\nS}\\alpha_{k}\\right)  }\\\\\r\n&  =\\sum\\limits_{S\\in P}\\prod\\limits_{k\\in S}\\alpha_{k}+\\sum\\limits_{S\\in\r\nP}\\left(  \\alpha_{N+1}\\prod\\limits_{k\\in S}\\alpha_{k}\\right)  =\\sum\r\n\\limits_{S\\in P}\\underbrace{\\left(  \\prod\\limits_{k\\in S}\\alpha_{k}%\r\n+\\alpha_{N+1}\\prod\\limits_{k\\in S}\\alpha_{k}\\right)  }_{=\\left(\r\n1+\\alpha_{N+1}\\right)  \\prod\\limits_{k\\in S}\\alpha_{k}}\\\\\r\n&  =\\sum\\limits_{S\\in P}\\left(  1+\\alpha_{N+1}\\right)  \\prod\\limits_{k\\in\r\nS}\\alpha_{k}=\\left(  1+\\alpha_{N+1}\\right)  \\underbrace{\\sum\\limits_{S\\in\r\nP}\\prod\\limits_{k\\in S}\\alpha_{k}}_{=\\sum\\limits_{S\\subseteq\\left\\{\r\n1,2,...,N\\right\\}  }\\prod\\limits_{k\\in S}\\alpha_{k}=\\prod\\limits_{i=1}%\r\n^{N}\\left(  1+\\alpha_{i}\\right)  }\\\\\r\n&  =\\left(  1+\\alpha_{N+1}\\right)  \\prod\\limits_{i=1}^{N}\\left(  1+\\alpha\r\n_{i}\\right)  =\\prod\\limits_{i=1}^{N+1}\\left(  1+\\alpha_{i}\\right)  .\r\n\\end{align*}\r\nWe have thus shown that $\\prod\\limits_{i=1}^{N+1}\\left(  1+\\alpha_{i}\\right)\r\n=\\sum\\limits_{S\\subseteq\\left\\{  1,2,...,N+1\\right\\}  }\\prod\\limits_{k\\in\r\nS}\\alpha_{k}$. In other words, (\\ref{4.2.pf.1}) holds for $n=N+1$. This\r\ncompletes the induction step.\r\n\r\nWe have thus shown that (\\ref{4.2.pf.1}) holds for every $n\\in\\left\\{\r\n0,1,...,m\\right\\}  $. Thus, we can now apply (\\ref{4.2.pf.1}) to $n=m$, and\r\nobtain $\\prod\\limits_{i=1}^{m}\\left(  1+\\alpha_{i}\\right)  =\\sum\r\n\\limits_{S\\subseteq\\left\\{  1,2,...,m\\right\\}  }\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}$. This solves Exercise 4.2 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Applying Exercise 4.2 \\textbf{(a)} to $\\alpha_{k}t$ instead of\r\n$\\alpha_{k}$, we obtain%\r\n\\begin{align*}\r\n\\prod\\limits_{i=1}^{m}\\left(  1+\\alpha_{i}t\\right)   &  =\\underbrace{\\sum\r\n\\limits_{S\\subseteq\\left\\{  1,2,...,m\\right\\}  }}_{=\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}}\\underbrace{\\prod\\limits_{k\\in S}\\left(\r\n\\alpha_{k}t\\right)  }_{=\\left(  \\prod\\limits_{k\\in S}\\alpha_{k}\\right)\r\nt^{\\left\\vert S\\right\\vert }}\\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\left(  \\prod\\limits_{k\\in\r\nS}\\alpha_{k}\\right)  \\underbrace{t^{\\left\\vert S\\right\\vert }}%\r\n_{\\substack{=t^{i}\\\\\\text{(since }\\left\\vert S\\right\\vert =i\\text{)}}%\r\n}=\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}t^{i}.\r\n\\end{align*}\r\nThis solves Exercise 4.2 \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Applying Exercise 4.2 \\textbf{(b)} to $-\\alpha_{k}$ instead of\r\n$\\alpha_{k}$, we obtain%\r\n\\begin{align*}\r\n\\prod\\limits_{i=1}^{m}\\left(  1+\\left(  -\\alpha_{i}\\right)  t\\right)   &\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}\\underbrace{\\left(  -t\\right)  ^{i}}_{=\\left(  -1\\right)  ^{i}t^{i}%\r\n}=\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}\\left(  -1\\right)  ^{i}t^{i}\\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}\\sum\r\n\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =i}}\\prod\\limits_{k\\in S}\\alpha_{k}t^{i}.\r\n\\end{align*}\r\nThis simplifies to%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1-\\alpha_{i}t\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\left(  -1\\right)  ^{i}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}t^{i}.\r\n\\]\r\nThis proves Exercise 4.2 \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Since $Q$ is a finite set, and we only use the elements of $Q$ as\r\nlabels, we can WLOG assume that $Q=\\left\\{  1,2,...,m\\right\\}  $ for some\r\n$m\\in\\mathbb{N}$ (because otherwise, we can just relabel the elements of $Q$\r\nas $1$, $2$, $...$, $m$ for some $m\\in\\mathbb{N}$). Then,\r\n\\begin{align*}\r\n\\prod\\limits_{q\\in Q}\\left(  1+\\alpha_{q}t\\right)   &  =\\prod\\limits_{i\\in\r\nQ}\\left(  1+\\alpha_{i}t\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we\r\nsubstituted }i\\text{ for }q\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{m}\\left(  1+\\alpha_{i}t\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }Q=\\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\n\\alpha_{k}t^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Exercise 4.2 \\textbf{(b)}%\r\n}\\right) \\\\\r\n&  =\\sum\\limits_{i\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\r\nQ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}\\alpha_{k}t^{i}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left\\{  1,2,...,m\\right\\}  =Q\\right)\r\n\\\\\r\n&  =\\sum\\limits_{k\\in\\mathbb{N}}\\sum\\limits_{\\substack{S\\subseteq\r\nQ;\\\\\\left\\vert S\\right\\vert =k}}\\prod\\limits_{q\\in S}\\alpha_{q}t^{k}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we renamed }i\\text{ and }k\\text{ as\r\n}k\\text{ and }q\\right)  .\r\n\\end{align*}\r\nThis solves Exercise 4.2 \\textbf{(d)}.\r\n\r\n\\textit{Exercise 4.3: Detailed solution:} Let $P\\in K\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ be a\r\npolynomial satisfying $P\\left(  p_{1},p_{2},...,p_{m},q_{1},q_{2}%\r\n,...,q_{n}\\right)  =0$ (where $K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ denotes the polynomial ring\r\nin the $m+n$ indeterminates $\\alpha_{1}$, $\\alpha_{2}$, $...$, $\\alpha_{m}$,\r\n$\\beta_{1}$, $\\beta_{2}$, $...$, $\\beta_{n}$ over $K$). We want to prove that\r\n$P=0$ (as a polynomial).\r\n\r\nSince $P$ is a polynomial in $K\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $, we can write it in the form%\r\n\\begin{equation}\r\nP=\\sum\\limits_{\\left(  \\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  \\right)  \\in\\mathbb{N}^{m}\\times\\mathbb{N}^{n}%\r\n}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}}...\\alpha\r\n_{m}^{i_{m}}\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}},\r\n\\label{4.3.sol.1}%\r\n\\end{equation}\r\nwhere $\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1}%\r\n,j_{2},...,j_{n}\\right)  }$ is the coefficient of the polynomial $P$ before\r\nthe monomial $\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}}...\\alpha_{m}^{i_{m}}%\r\n\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}$ for every\r\n$\\left(  \\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  \\right)  \\in\\mathbb{N}^{m}\\times\\mathbb{N}^{n}$. So let us\r\nwrite it in this way. Then,%\r\n\\begin{align}\r\n0  &  =P\\left(  p_{1},p_{2},...,p_{m},q_{1},q_{2},...,q_{n}\\right) \\nonumber\\\\\r\n&  =\\sum\\limits_{\\left(  \\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  \\right)  \\in\\mathbb{N}^{m}\\times\\mathbb{N}^{n}%\r\n}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}\\cdot\r\nq_{1}^{j_{1}}q_{2}^{j_{2}}...q_{n}^{j_{n}}\\nonumber\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{because of (\\ref{4.3.sol.1})}\\right)\r\n\\nonumber\\\\\r\n&  =\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}}%\r\n\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\\mathbb{N}^{m}}%\r\n\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}\\cdot\r\nq_{1}^{j_{1}}q_{2}^{j_{2}}...q_{n}^{j_{n}}. \\label{4.3.sol.1a}%\r\n\\end{align}\r\nDefine a polynomial $\\widetilde{P}\\in T\\left[  \\beta_{1},\\beta_{2}%\r\n,\\ldots,\\beta_{n}\\right]  $ by%\r\n\\begin{equation}\r\n\\widetilde{P}=\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\r\n\\mathbb{N}^{n}}\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}%\r\n^{i_{m}}\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}.\r\n\\label{4.3.sol.1b}%\r\n\\end{equation}\r\nThen,%\r\n\\begin{align*}\r\n&  \\widetilde{P}\\left(  q_{1},q_{2},\\ldots,q_{n}\\right) \\\\\r\n&  =\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}}%\r\n\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\\mathbb{N}^{m}}%\r\n\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}\\cdot\r\nq_{1}^{j_{1}}q_{2}^{j_{2}}...q_{n}^{j_{n}}\\\\\r\n&  =0\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{4.3.sol.1a})}\\right)  .\r\n\\end{align*}\r\nHence, $\\widetilde{P}=0$ as polynomials (since $q_{1}$, $q_{2}$, $...$,\r\n$q_{n}$ are algebraically independent over $T$). Comparing this with\r\n(\\ref{4.3.sol.1b}), we obtain%\r\n\\begin{equation}\r\n0=\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}}%\r\n\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\\mathbb{N}^{m}}%\r\n\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}\\cdot\r\n\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}. \\label{4.3.sol.2}%\r\n\\end{equation}\r\n\r\n\r\nFor every $\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}$, define a\r\npolynomial $P_{\\left(  j_{1},j_{2},...,j_{n}\\right)  }\\in K\\left[  \\alpha\r\n_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ by $P_{\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }=\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)\r\n\\in\\mathbb{N}^{m}}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  }\\cdot\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}%\r\n}...\\alpha_{m}^{i_{m}}$. Then,\r\n\\[\r\nP_{\\left(  j_{1},j_{2},...,j_{n}\\right)  }\\left(  p_{1},p_{2},...,p_{m}%\r\n\\right)  =\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\\mathbb{N}%\r\n^{m}}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1}%\r\n,j_{2},...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}%\r\n\\]\r\nfor every $\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}$. Thus, in\r\nthe ring $T\\left[  \\beta_{1},\\beta_{2},\\ldots,\\beta_{n}\\right]  $, we have%\r\n\\begin{align*}\r\n&  \\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}%\r\n}P_{\\left(  j_{1},j_{2},...,j_{n}\\right)  }\\left(  p_{1},p_{2},...,p_{m}%\r\n\\right)  \\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}\\\\\r\n&  =\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}}%\r\n\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\\mathbb{N}^{m}}%\r\n\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot p_{1}^{i_{1}}p_{2}^{i_{2}}...p_{m}^{i_{m}}\\cdot\r\n\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}=0\r\n\\end{align*}\r\n(by (\\ref{4.3.sol.2})). Since the elements $\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}%\r\n}...\\beta_{n}^{j_{n}}$ (with $\\left(  j_{1},j_{2},...,j_{n}\\right)\r\n\\in\\mathbb{N}^{n}$) of the $T$-module $T\\left[  \\beta_{1},\\beta_{2}%\r\n,...,\\beta_{n}\\right]  $ are $T$-linearly independent (because these elements\r\nare the monomials), this yields that $P_{\\left(  j_{1},j_{2},...,j_{n}\\right)\r\n}\\left(  p_{1},p_{2},...,p_{m}\\right)  =0$ for every $\\left(  j_{1}%\r\n,j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}$. Hence, $P_{\\left(  j_{1}%\r\n,j_{2},...,j_{n}\\right)  }=0$ for every $\\left(  j_{1},j_{2},...,j_{n}\\right)\r\n\\in\\mathbb{N}^{n}$ (since $p_{1}$, $p_{2}$, $...$, $p_{m}$ are algebraically\r\nindependent over $K$). Now,%\r\n\\begin{align*}\r\nP  &  =\\sum\\limits_{\\left(  \\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  \\right)  \\in\\mathbb{N}^{m}\\times\\mathbb{N}^{n}%\r\n}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(  j_{1},j_{2}%\r\n,...,j_{n}\\right)  }\\cdot\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}}...\\alpha\r\n_{m}^{i_{m}}\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}\\\\\r\n&  =\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}%\r\n}\\underbrace{\\sum\\limits_{\\left(  i_{1},i_{2},...,i_{m}\\right)  \\in\r\n\\mathbb{N}^{m}}\\lambda_{\\left(  i_{1},i_{2},...,i_{m}\\right)  ,\\left(\r\nj_{1},j_{2},...,j_{n}\\right)  }\\cdot\\alpha_{1}^{i_{1}}\\alpha_{2}^{i_{2}%\r\n}...\\alpha_{m}^{i_{m}}}_{=P_{\\left(  j_{1},j_{2},...,j_{n}\\right)  }=0}%\r\n\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}\\\\\r\n&  =\\sum\\limits_{\\left(  j_{1},j_{2},...,j_{n}\\right)  \\in\\mathbb{N}^{n}%\r\n}0\\cdot\\beta_{1}^{j_{1}}\\beta_{2}^{j_{2}}...\\beta_{n}^{j_{n}}=0.\r\n\\end{align*}\r\n\r\n\r\nWe have thus proven that every polynomial $P\\in K\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m},\\beta_{1},\\beta_{2},...,\\beta_{n}\\right]  $ satisfying\r\n$P\\left(  p_{1},p_{2},...,p_{m},q_{1},q_{2},...,q_{n}\\right)  =0$ must satisfy\r\n$P=0$. In other words, the $m+n$ elements $p_{1}$, $p_{2}$, $...$, $p_{m}$,\r\n$q_{1}$, $q_{2}$, $...$, $q_{n}$ are algebraically independent over $K$.\r\nExercise 4.3 is solved.\r\n\r\n\\textit{Exercise 4.4:} \\textit{Detailed solution:} Fix some $j\\in\\mathbb{N}$.\r\n\r\n\\textit{1st Step:} Let $m\\in\\mathbb{N}$. We are going to prove that%\r\n\\[\r\nP_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  =\\sum\\limits_{i=0}^{j-1}\\left(\r\n-1\\right)  ^{i+j-1}X_{i}X_{2j-i}%\r\n\\]\r\nin the ring $\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\n\r\n\\textit{Proof.} It is a known (and very easy) fact that whenever $A$ is a\r\nring, $F$ is a finite set and $a_{I}$ is an element of $A$ for every $I\\in F$,\r\nthen%\r\n\\begin{equation}\r\n\\left(  \\sum\\limits_{I\\in F}a_{I}\\right)  ^{2}=\\sum\\limits_{I\\in F}a_{I}%\r\n^{2}+2\\sum\\limits_{S\\in\\mathcal{P}_{2}\\left(  F\\right)  }\\prod\\limits_{I\\in\r\nS}a_{I}. \\label{4.4.sol.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{4.4.sol.1}).} Let $A$ be a ring, let $F$ be a\r\nfinite set, and let $a_{I}$ be an element of $A$ for every $I\\in F$. We must\r\nprove (\\ref{4.4.sol.1}).\r\n\\par\r\nThe set $F$ is used only for indexing in (\\ref{4.4.sol.1}). Hence, we can WLOG\r\nassume that $F=\\left\\{  1,2,...,n\\right\\}  $ for some $n\\in\\mathbb{N}$. Assume\r\nthis, and consider this $n$.\r\n\\par\r\nSince $F=\\left\\{  1,2,...,n\\right\\}  $, we have $\\sum\\limits_{I\\in F}%\r\na_{I}=\\sum\\limits_{I\\in\\left\\{  1,2,...,n\\right\\}  }a_{I}=a_{1}+a_{2}%\r\n+...+a_{n}$ and $\\sum\\limits_{I\\in F}a_{I}^{2}=\\sum\\limits_{I\\in\\left\\{\r\n1,2,...,n\\right\\}  }a_{I}^{2}=a_{1}^{2}+a_{2}^{2}+...+a_{n}^{2}$.\r\n\\par\r\nOn the other hand, let $L$ be the set of all pairs $\\left(  i,j\\right)  \\in\r\nF\\times F$ satisfying $i<j$. Then, $\\sum\\limits_{\\left(  i,j\\right)  \\in\r\nL}a_{i}a_{j}=\\sum\\limits_{\\substack{\\left(  i,j\\right)  \\in F\\times\r\nF;\\\\i<j}}a_{i}a_{j}$. From the definition of $L$, it is clear that every\r\n$\\left(  i,j\\right)  \\in L$ satisfies $i<j$.\r\n\\par\r\nLet $\\mathfrak{S}$ denote the map%\r\n\\[\r\nL\\rightarrow\\mathcal{P}_{2}\\left(  F\\right)  ,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\ni,j\\right)  \\mapsto\\left\\{  i,j\\right\\}  .\r\n\\]\r\nThis map is a bijection. (In fact, the elements of $L$ are pairs $\\left(\r\ni,j\\right)  \\in F\\times F$ satisfying $i<j$; such pairs are clearly in\r\nbijection with the $2$-element subsets of $F$, and this bijection is given by\r\nthe map $\\mathfrak{S}$.)\r\n\\par\r\nFor every $\\left(  i,j\\right)  \\in L$, we have%\r\n\\begin{align*}\r\n\\prod_{I\\in\\mathfrak{S}\\left(  i,j\\right)  }a_{I}  &  =\\prod_{I\\in\\left\\{\r\ni,j\\right\\}  }a_{I}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{S}%\r\n\\left(  i,j\\right)  =\\left\\{  i,j\\right\\}  \\text{ by the definition of\r\n}\\mathfrak{S}\\right) \\\\\r\n&  =a_{i}a_{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  i,j\\right)  \\in\r\nL\\text{, so that }i<j\\right)  .\r\n\\end{align*}\r\n\\par\r\nNow,%\r\n\\[\r\n\\sum\\limits_{\\substack{\\left(  i,j\\right)  \\in F\\times F;\\\\i<j}}a_{i}%\r\na_{j}=\\sum\\limits_{\\left(  i,j\\right)  \\in L}\\underbrace{a_{i}a_{j}}%\r\n_{=\\prod\\limits_{I\\in\\mathfrak{S}\\left(  i,j\\right)  }a_{I}}=\\sum\r\n\\limits_{\\left(  i,j\\right)  \\in L}\\prod_{I\\in\\mathfrak{S}\\left(  i,j\\right)\r\n}a_{I}=\\sum\\limits_{S\\in\\mathcal{P}_{2}\\left(  F\\right)  }\\prod\\limits_{I\\in\r\nS}a_{I}%\r\n\\]\r\n(here we substituted $S$ for $\\mathfrak{S}\\left(  i,j\\right)  $ in the sum,\r\nsince $\\mathfrak{S}$ is a bijection). But $\\sum\\limits_{I\\in F}a_{I}%\r\n=a_{1}+a_{2}+...+a_{n}$, so that%\r\n\\[\r\n\\left(  \\sum\\limits_{I\\in F}a_{I}\\right)  ^{2}=\\left(  a_{1}+a_{2}%\r\n+...+a_{n}\\right)  ^{2}=\\underbrace{\\left(  a_{1}^{2}+a_{2}^{2}+...+a_{n}%\r\n^{2}\\right)  }_{=\\sum\\limits_{I\\in F}a_{I}^{2}}+2\\underbrace{\\sum\r\n\\limits_{\\substack{\\left(  i,j\\right)  \\in F\\times F;\\\\i<j}}a_{i}a_{j}}%\r\n_{=\\sum\\limits_{S\\in\\mathcal{P}_{2}\\left(  F\\right)  }\\prod\\limits_{I\\in\r\nS}a_{I}}=\\sum\\limits_{I\\in F}a_{I}^{2}+2\\sum\\limits_{S\\in\\mathcal{P}%\r\n_{2}\\left(  F\\right)  }\\prod\\limits_{I\\in S}a_{I}.\r\n\\]\r\nThis proves (\\ref{4.4.sol.1}).} Applied to $A=\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $, $F=\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  $ and $a_{I}=\\prod\\limits_{i\\in I}U_{i}$, this\r\nyields%\r\n\\[\r\n\\left(  \\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  }\\prod\\limits_{i\\in I}U_{i}\\right)  ^{2}=\\sum\\limits_{I\\in\r\n\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\left(\r\n\\prod\\limits_{i\\in I}U_{i}\\right)  ^{2}+2\\sum\\limits_{S\\in\\mathcal{P}%\r\n_{2}\\left(  \\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right)  }\\prod\\limits_{I\\in S}\\prod\\limits_{i\\in I}U_{i}.\r\n\\]\r\nSince\r\n\\begin{align*}\r\n\\sum\\limits_{S\\in\\mathcal{P}_{2}\\left(  \\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  \\right)  }\\prod\\limits_{I\\in S}\\prod\\limits_{i\\in\r\nI}U_{i}  &  =\\sum\\limits_{\\substack{S\\subseteq\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  ;\\\\\\left\\vert S\\right\\vert =2}}\\prod\\limits_{I\\in\r\nS}\\prod\\limits_{i\\in I}U_{i}=P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{Pkj1}), applied to }k=2\\right)\r\n,\r\n\\end{align*}\r\nthis becomes%\r\n\\begin{align*}\r\n\\left(  \\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  }\\prod\\limits_{i\\in I}U_{i}\\right)  ^{2}  &  =\\sum\\limits_{I\\in\r\n\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }%\r\n\\underbrace{\\left(  \\prod\\limits_{i\\in I}U_{i}\\right)  ^{2}}_{=\\prod\r\n\\limits_{i\\in I}U_{i}^{2}}+2\\underbrace{\\sum\\limits_{S\\in\\mathcal{P}%\r\n_{2}\\left(  \\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n\\right)  }\\prod\\limits_{I\\in S}\\prod\\limits_{i\\in I}U_{i}}_{=P_{2,j}\\left(\r\nX_{1},X_{2},...,X_{2j}\\right)  }\\\\\r\n&  =\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  }\\prod\\limits_{i\\in I}U_{i}^{2}+2P_{2,j}\\left(  X_{1},X_{2}%\r\n,...,X_{2j}\\right)  .\r\n\\end{align*}\r\nSince%\r\n\\begin{align*}\r\n\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\prod\\limits_{i\\in I}U_{i}  &  =\\sum\\limits_{\\substack{I\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert I\\right\\vert =j}}\\prod\\limits_{i\\in I}%\r\nU_{i}=\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =j}}\\prod_{k\\in S}U_{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the indices }I\\text{ and\r\n}i\\text{ as }S\\text{ and }k\\right) \\\\\r\n&  =X_{j}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }X_{j}\\text{ was defined as\r\n}\\sum_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nS\\right\\vert =j}}\\prod_{k\\in S}U_{k}\\right)  ,\r\n\\end{align*}\r\nthis rewrites as%\r\n\\begin{equation}\r\nX_{j}^{2}=\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}\r\n\\right)  }\\prod\\limits_{i\\in I}U_{i}^{2}+2P_{2,j}\\left(  X_{1},X_{2}%\r\n,...,X_{2j}\\right)  . \\label{4.4.sol.2}%\r\n\\end{equation}\r\n\r\n\r\nWe will now show that%\r\n\\begin{equation}\r\n\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\prod\\limits_{i\\in I}U_{i}^{2}=\\sum\\limits_{i=0}^{2j}\\left(  -1\\right)\r\n^{i+j}X_{i}X_{2j-i} \\label{4.4.sol.3}%\r\n\\end{equation}\r\n(an identity interesting for its own).\r\n\r\nIn fact, consider the polynomial $\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}%\r\n^{2}T^{2}\\right)  \\in\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n\\right)  \\left[  T\\right]  $. Exercise 4.2 \\textbf{(c)} (applied to $A=\\left(\r\n\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  T\\right]  $,\r\n$t=T^{2}$ and $\\alpha_{i}=U_{i}^{2}$) yields%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}^{2}T^{2}\\right)  =\\sum_{i\\in\\mathbb{N}%\r\n}\\left(  -1\\right)  ^{i}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\nU_{k}^{2}\\underbrace{\\left(  T^{2}\\right)  ^{i}}_{=T^{2i}}=\\sum_{i\\in\r\n\\mathbb{N}}\\left(  \\left(  -1\\right)  ^{i}\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in\r\nS}U_{k}^{2}\\right)  T^{2i}.\r\n\\]\r\nThus,%\r\n\\begin{align}\r\n&  \\left(  \\text{the coefficient of the polynomial }\\prod\\limits_{i=1}%\r\n^{m}\\left(  1-U_{i}^{2}T^{2}\\right)  \\text{ before }T^{2j}\\right) \\nonumber\\\\\r\n&  =\\left(  \\text{the coefficient of the polynomial }\\sum_{i\\in\\mathbb{N}%\r\n}\\left(  \\left(  -1\\right)  ^{i}\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}%\r\nU_{k}^{2}\\right)  T^{2i}\\text{ before }T^{2j}\\right) \\nonumber\\\\\r\n&  =\\left(  -1\\right)  ^{j}\\underbrace{\\sum\\limits_{\\substack{S\\subseteq\r\n\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =j}}}_{=\\sum\r\n\\limits_{S\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }%\r\n}\\prod\\limits_{k\\in S}U_{k}^{2}=\\left(  -1\\right)  ^{j}\\sum\\limits_{S\\in\r\n\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\prod\r\n\\limits_{k\\in S}U_{k}^{2}=\\left(  -1\\right)  ^{j}\\sum\\limits_{I\\in\r\n\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\prod\r\n\\limits_{i\\in I}U_{i}^{2}\\label{4.4.sol.4}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the indices }S\\text{ and\r\n}k\\text{ as }I\\text{ and }i\\right)  .\\nonumber\r\n\\end{align}\r\n\r\n\r\nBut Exercise 4.2 \\textbf{(c)} (applied to $A=\\left(  \\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  T\\right]  $, $t=T$ and\r\n$\\alpha_{i}=U_{i}$) yields%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1-U_{i}T\\right)  =\\sum_{i\\in\\mathbb{N}}\\left(\r\n-1\\right)  ^{i}\\underbrace{\\sum\\limits_{\\substack{S\\subseteq\\left\\{\r\n1,2,...,m\\right\\}  ;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}%\r\n}_{=X_{i}}T^{i}=\\sum_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}X_{i}T^{i}.\r\n\\]\r\nAlso, Exercise 4.2 \\textbf{(b)} (applied to $A=\\left(  \\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  \\right)  \\left[  T\\right]  $, $t=T$ and\r\n$\\alpha_{i}=U_{i}$) yields%\r\n\\[\r\n\\prod\\limits_{i=1}^{m}\\left(  1+U_{i}T\\right)  =\\sum_{i\\in\\mathbb{N}%\r\n}\\underbrace{\\sum\\limits_{\\substack{S\\subseteq\\left\\{  1,2,...,m\\right\\}\r\n;\\\\\\left\\vert S\\right\\vert =i}}\\prod\\limits_{k\\in S}U_{k}}_{=X_{i}}T^{i}%\r\n=\\sum_{i\\in\\mathbb{N}}X_{i}T^{i}.\r\n\\]\r\nNow,%\r\n\\begin{align*}\r\n\\prod\\limits_{i=1}^{m}\\underbrace{\\left(  1-U_{i}^{2}T^{2}\\right)  }_{=\\left(\r\n1-U_{i}T\\right)  \\left(  1+U_{i}T\\right)  }  &  =\\prod\\limits_{i=1}^{m}\\left(\r\n\\left(  1-U_{i}T\\right)  \\left(  1+U_{i}T\\right)  \\right)\r\n=\\underbrace{\\left(  \\prod\\limits_{i=1}^{m}\\left(  1-U_{i}T\\right)  \\right)\r\n}_{=\\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}X_{i}T^{i}%\r\n}\\underbrace{\\left(  \\prod\\limits_{i=1}^{m}\\left(  1+U_{i}T\\right)  \\right)\r\n}_{=\\sum\\limits_{i\\in\\mathbb{N}}X_{i}T^{i}}\\\\\r\n&  =\\left(  \\sum\\limits_{i\\in\\mathbb{N}}\\left(  -1\\right)  ^{i}X_{i}%\r\nT^{i}\\right)  \\cdot\\left(  \\sum\\limits_{i\\in\\mathbb{N}}X_{i}T^{i}\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\left(  \\sum_{k=0}^{i}\\left(  -1\\right)\r\n^{k}X_{k}X_{i-k}\\right)  T^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the product of two\r\npolynomials}\\right)  .\r\n\\end{align*}\r\nHence,\r\n\\begin{align*}\r\n&  \\left(  \\text{the coefficient of the polynomial }\\prod\\limits_{i=1}%\r\n^{m}\\left(  1-U_{i}^{2}T^{2}\\right)  \\text{ before }T^{2j}\\right) \\\\\r\n&  =\\left(  \\text{the coefficient of the polynomial }\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\left(  \\sum_{k=0}^{i}\\left(  -1\\right)  ^{k}X_{k}X_{i-k}\\right)\r\nT^{i}\\text{ before }T^{2j}\\right) \\\\\r\n&  =\\sum\\limits_{k=0}^{2j}\\left(  -1\\right)  ^{k}X_{k}X_{2j-k}=\\sum\r\n\\limits_{i=0}^{2j}\\left(  -1\\right)  ^{i}X_{i}X_{2j-i}%\r\n\\end{align*}\r\n(here we renamed the index $k$ as $i$). Compared to (\\ref{4.4.sol.4}), this\r\nyields%\r\n\\[\r\n\\left(  -1\\right)  ^{j}\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }\\prod\\limits_{i\\in I}U_{i}^{2}=\\sum\r\n\\limits_{i=0}^{2j}\\left(  -1\\right)  ^{i}X_{i}X_{2j-i}.\r\n\\]\r\nDivided by $\\left(  -1\\right)  ^{j}$, this yields%\r\n\\[\r\n\\sum\\limits_{I\\in\\mathcal{P}_{j}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\prod\\limits_{i\\in I}U_{i}^{2}=\\sum\\limits_{i=0}^{2j}\\underbrace{\\dfrac\r\n{\\left(  -1\\right)  ^{i}}{\\left(  -1\\right)  ^{j}}}_{=\\left(  -1\\right)\r\n^{i+j}}X_{i}X_{2j-i}=\\sum\\limits_{i=0}^{2j}\\left(  -1\\right)  ^{i+j}%\r\nX_{i}X_{2j-i}.\r\n\\]\r\nThus we have proven (\\ref{4.4.sol.3}).\r\n\r\nSubstituting (\\ref{4.4.sol.3}) into (\\ref{4.4.sol.2}), we obtain%\r\n\\[\r\nX_{j}^{2}=\\sum\\limits_{i=0}^{2j}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}%\r\n+2P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  .\r\n\\]\r\nSince%\r\n\\begin{align*}\r\n\\sum\\limits_{i=0}^{2j}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}  &\r\n=\\sum\\limits_{i=0}^{j}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}+\\sum\r\n\\limits_{i=j+1}^{2j}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}\\\\\r\n&  =\\underbrace{\\sum\\limits_{i=0}^{j}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}%\r\n}_{=\\left(  -1\\right)  ^{j+j}X_{j}X_{2j-j}+\\sum\\limits_{i=0}^{j-1}\\left(\r\n-1\\right)  ^{i+j}X_{i}X_{2j-i}}+\\sum\\limits_{i=0}^{j-1}\\underbrace{\\left(\r\n-1\\right)  ^{\\left(  2j-i\\right)  +j}}_{=\\left(  -1\\right)  ^{2\\left(\r\nj-i\\right)  +i+j}=\\left(  -1\\right)  ^{i+j}}X_{2j-i}\\underbrace{X_{2j-\\left(\r\n2j-i\\right)  }}_{=X_{i}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we substituted }2j-i\\text{ for\r\n}i\\text{ in the second sum}\\right) \\\\\r\n&  =\\underbrace{\\left(  -1\\right)  ^{j+j}}_{=\\left(  -1\\right)  ^{2j}%\r\n=1}\\underbrace{X_{j}X_{2j-j}}_{=X_{j}X_{j}=X_{j}^{2}}+\\sum\\limits_{i=0}%\r\n^{j-1}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}+\\sum\\limits_{i=0}^{j-1}\\left(\r\n-1\\right)  ^{i+j}\\underbrace{X_{2j-i}X_{i}}_{=X_{i}X_{2j-i}}\\\\\r\n&  =X_{j}^{2}+\\underbrace{\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)\r\n^{i+j}X_{i}X_{2j-i}+\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j}%\r\nX_{i}X_{2j-i}}_{=2\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j}%\r\nX_{i}X_{2j-i}}\\\\\r\n&  =X_{j}^{2}+2\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i},\r\n\\end{align*}\r\nthis becomes%\r\n\\[\r\nX_{j}^{2}=X_{j}^{2}+2\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j}%\r\nX_{i}X_{2j-i}+2P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  .\r\n\\]\r\nSubtracting $X_{j}^{2}$ from this and dividing by $2$ (we are allowed to\r\ndivide by $2$ since $2$ is not a zero-divisor in $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $), we obtain%\r\n\\[\r\n0=\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}+P_{2,j}\\left(\r\nX_{1},X_{2},...,X_{2j}\\right)  ,\r\n\\]\r\nso that%\r\n\\begin{align*}\r\nP_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)   &  =-\\sum\\limits_{i=0}%\r\n^{j-1}\\left(  -1\\right)  ^{i+j}X_{i}X_{2j-i}=\\sum\\limits_{i=0}^{j-1}%\r\n\\underbrace{\\left(  -\\left(  -1\\right)  ^{i+j}\\right)  }_{=\\left(  -1\\right)\r\n^{i+j-1}}X_{i}X_{2j-i}\\\\\r\n&  =\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j-1}X_{i}X_{2j-i}.\r\n\\end{align*}\r\nThis proves the 1st Step.\r\n\r\n\\textit{2nd Step:} Let us now prove $P_{2,j}=\\sum\\limits_{i=0}^{j-1}\\left(\r\n-1\\right)  ^{i+j-1}\\alpha_{i}\\alpha_{2j-i}$ now.\r\n\r\n\\textit{Proof.} Let $m=2j$. Applying Theorem 4.1 \\textbf{(a)} to\r\n$K=\\mathbb{Z}$ and $P=P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  $, we\r\nconclude that there exists one and only one polynomial $Q\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ such that $P_{2,j}\\left(\r\nX_{1},X_{2},...,X_{2j}\\right)  =Q\\left(  X_{1},X_{2},...,X_{m}\\right)  $. In\r\nparticular, there exists \\textit{at most one} such polynomial $Q\\in\r\n\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $. Hence,\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{if }\\mathfrak{Q}_{1}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m}\\right]  \\text{ and }\\mathfrak{Q}_{2}\\in\\mathbb{Z}\\left[\r\n\\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  \\text{ are two polynomials}\\\\\r\n\\text{such that }P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  =\\mathfrak{Q}%\r\n_{1}\\left(  X_{1},X_{2},...,X_{m}\\right)  \\text{ and}\\\\\r\nP_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  =\\mathfrak{Q}_{2}\\left(\r\nX_{1},X_{2},...,X_{m}\\right)  \\text{, then }\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}%\r\n\\end{array}\r\n\\right)  . \\label{4.4.sol.15}%\r\n\\end{equation}\r\n\r\n\r\nDefine a polynomial $\\mathfrak{Q}_{1}\\in\\mathbb{Z}\\left[  \\alpha_{1}%\r\n,\\alpha_{2},...,\\alpha_{m}\\right]  $ by $\\mathfrak{Q}_{1}=P_{2,j}$, and define\r\na polynomial $\\mathfrak{Q}_{2}\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m}\\right]  $ by $\\mathfrak{Q}_{2}=\\sum\\limits_{i=0}%\r\n^{j-1}\\left(  -1\\right)  ^{i+j-1}\\alpha_{i}\\alpha_{2j-i}$. We are going to\r\nprove that $\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}$.\r\n\r\nSince our two polynomials $\\mathfrak{Q}_{1}$ and $\\mathfrak{Q}_{2}$ satisfy%\r\n\\[\r\n\\mathfrak{Q}_{1}\\left(  X_{1},X_{2},...,X_{m}\\right)  =P_{2,j}\\left(\r\nX_{1},X_{2},...,X_{2j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\mathfrak{Q}_{1}=P_{2,j}\\text{ and }m=2j\\right)\r\n\\]\r\nand%\r\n\\begin{align*}\r\n\\mathfrak{Q}_{2}\\left(  X_{1},X_{2},...,X_{m}\\right)   &  =\\left(\r\n\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j-1}\\alpha_{i}\\alpha\r\n_{2j-i}\\right)  \\left(  X_{1},X_{2},...,X_{2j}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\mathfrak{Q}_{2}=\\sum\r\n\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j-1}\\alpha_{i}\\alpha_{2j-i}\\text{\r\nand }m=2j\\right) \\\\\r\n&  =\\sum\\limits_{i=0}^{j-1}\\left(  -1\\right)  ^{i+j-1}X_{i}X_{2j-i}\\\\\r\n&  =P_{2,j}\\left(  X_{1},X_{2},...,X_{2j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by the 1st Step}\\right)  ,\r\n\\end{align*}\r\nwe can conclude from (\\ref{4.4.sol.15}) that $\\mathfrak{Q}_{1}=\\mathfrak{Q}%\r\n_{2}$. Hence, $P_{2,j}=\\mathfrak{Q}_{1}=\\mathfrak{Q}_{2}=\\sum\\limits_{i=0}%\r\n^{j-1}\\left(  -1\\right)  ^{i+j-1}\\alpha_{i}\\alpha_{2j-i}$. This solves\r\nExercise 4.4.\r\n\r\n\\subsection{To Section 5}\r\n\r\n\\textit{Exercise 5.1: Hints to solution:} This can be proven by induction over\r\n$n$: The ring $K\\left[  T\\right]  \\diagup\\left(  P\\right)  $ is a finite-free\r\nextension of $K$ containing a root of the polynomial $P$ (namely, the\r\nequivalence class $\\overline{T}$ of $T\\in K\\left[  T\\right]  $ modulo $\\left(\r\nP\\right)  $). Now, the polynomial $\\dfrac{P\\left(  S\\right)  }{S-\\overline{T}%\r\n}\\in\\left(  K\\left[  T\\right]  \\diagup\\left(  P\\right)  \\right)  \\left[\r\nS\\right]  $ is monic and has degree $n-1$, so by induction there exists a\r\nfinite-free extension ring $K_{P}$ of the ring $K\\left[  T\\right]\r\n\\diagup\\left(  P\\right)  $ and $n-1$ elements $p_{2}$, $...$, $p_{n}$ of this\r\nextension ring $K_{P}$ such that $\\dfrac{P\\left(  S\\right)  }{S-\\overline{T}%\r\n}=\\prod\\limits_{i=2}^{n}\\left(  T-p_{i}\\right)  $ in $K_{P}\\left[  S\\right]\r\n$. Thus, $P\\left(  S\\right)  =\\left(  S-\\overline{T}\\right)  \\prod\r\n\\limits_{i=2}^{n}\\left(  T-p_{i}\\right)  $ in $K_{P}\\left[  S\\right]  $. If we\r\ndenote $\\overline{T}$ by $p_{1}$, this takes the form $P\\left(  S\\right)\r\n=\\prod\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)  $, which shows that we have\r\njust completed the induction step.\r\n\r\nNotice the similarity between this solution and the proof of the existence of\r\nsplitting fields in Galois theory.\r\n\r\n\\textit{Detailed solution:} We first show a lemma:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 5.1.S.1.} Let $K$ be a ring, and $P\\in K\\left[  T\\right]  $ be a\r\nmonic polynomial. Then, there exists a finite-free extension ring $K^{\\prime}$\r\nof the ring $K$ and an element $p\\in K^{\\prime}$ such that $P\\left(  p\\right)\r\n=0$ in $K^{\\prime}$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 5.1.S.1.]Let $n=\\deg P$. Let $K^{\\prime}$ be the quotient ring\r\n$K\\left[  T\\right]  \\diagup\\left(  P\\right)  $. For every $Q\\in K\\left[\r\nT\\right]  $, let us denote by $\\overline{Q}$ the projection of $Q$ onto\r\n$K\\left[  T\\right]  \\diagup\\left(  P\\right)  $ (that is, the residue class of\r\n$Q$ modulo $\\left(  P\\right)  $).\r\n\r\nSince the polynomial $P$ is monic of degree $n$, we can easily see that\r\n$\\left(  \\overline{T^{0}},\\overline{T^{1}},...,\\overline{T^{n-1}}\\right)  $ is\r\na basis of the $K$-module $K^{\\prime}$. This is because the sequence $\\left(\r\n\\overline{T^{0}},\\overline{T^{1}},...,\\overline{T^{n-1}}\\right)  $ is linearly\r\nindependent\\footnote{\\textit{Proof.} In fact, assume that we have a sequence\r\n$\\left(  \\alpha_{0},\\alpha_{1},...,\\alpha_{n-1}\\right)  \\in K^{n}$ such that\r\n$\\alpha_{0}\\overline{T^{0}}+\\alpha_{1}\\overline{T^{1}}+...+\\alpha\r\n_{n-1}\\overline{T^{n-1}}=0$.\r\n\\par\r\nThen, $0=\\alpha_{0}\\overline{T^{0}}+\\alpha_{1}\\overline{T^{1}}+...+\\alpha\r\n_{n-1}\\overline{T^{n-1}}=\\overline{\\alpha_{0}T^{0}+\\alpha_{1}T^{1}%\r\n+...+\\alpha_{n-1}T^{n-1}}$, so that $0\\equiv\\alpha_{0}T^{0}+\\alpha_{1}%\r\nT^{1}+...+\\alpha_{n-1}T^{n-1}\\operatorname{mod}\\left(  P\\right)  $. In other\r\nwords, $\\alpha_{0}T^{0}+\\alpha_{1}T^{1}+...+\\alpha_{n-1}T^{n-1}\\in\\left(\r\nP\\right)  $. In other words, $P\\mid\\alpha_{0}T^{0}+\\alpha_{1}T^{1}%\r\n+...+\\alpha_{n-1}T^{n-1}$. But $P$ is a monic polynomial of degree $n$, and\r\nthus every polynomial divisible by $P$ has either degree $\\geq n$ or is the\r\nzero polynomial. Hence, the polynomial $\\alpha_{0}T^{0}+\\alpha_{1}%\r\nT^{1}+...+\\alpha_{n-1}T^{n-1}$ must have either degree $\\geq n$ or be the zero\r\npolynomial (since $P\\mid\\alpha_{0}T^{0}+\\alpha_{1}T^{1}+...+\\alpha\r\n_{n-1}T^{n-1}$). Since this polynomial does not have degree $\\geq n$, it must\r\nthus be the zero polynomial. This means that all its coefficients are zero.\r\nThat is, $\\alpha_{i}=0$ for every $i\\in\\left\\{  0,1,...,n-1\\right\\}  $.\r\n\\par\r\nWe have thus proven that whenever a sequence $\\left(  \\alpha_{0},\\alpha\r\n_{1},...,\\alpha_{n-1}\\right)  \\in K^{n}$ satisfies $\\alpha_{0}\\overline{T^{0}%\r\n}+\\alpha_{1}\\overline{T^{1}}+...+\\alpha_{n-1}\\overline{T^{n-1}}=0$, it must\r\nsatisfy $\\alpha_{i}=0$ for every $i\\in\\left\\{  0,1,...,n-1\\right\\}  $. In\r\nother words, the sequence $\\left(  \\overline{T^{0}},\\overline{T^{1}%\r\n},...,\\overline{T^{n-1}}\\right)  $ is linearly independent.} and generates the\r\n$K$-module $K^{\\prime}$\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $K_{1}^{\\prime}$\r\nbe the $K$-submodule of $K^{\\prime}$ generated by $\\left(  \\overline{T^{0}%\r\n},\\overline{T^{1}},...,\\overline{T^{n-1}}\\right)  $. Then, we will prove that\r\n$K_{1}^{\\prime}=K^{\\prime}$.\r\n\\par\r\nFrom the definition of $K_{1}^{\\prime}$, it follows that $\\overline{T^{j}}\\in\r\nK_{1}^{\\prime}$ for every $j\\in\\left\\{  0,1,...,n-1\\right\\}  $.\r\n\\par\r\nWrite the polynomial $P$ in the form $P=\\sum\\limits_{i=0}^{n}\\beta_{i}T^{i}$\r\nfor some $\\left(  \\beta_{0},\\beta_{1},...,\\beta_{n}\\right)  \\in K^{n+1}$ (this\r\nis possible since $\\deg P=n$). Since $P$ is monic of degree $n$, we must then\r\nhave $\\beta_{n}=1$.\r\n\\par\r\nLet us prove that every $j\\in\\mathbb{N}$ satisfies $\\overline{T^{j}}\\in\r\nK_{1}^{\\prime}$.\r\n\\par\r\nIn fact, we will prove this by strong induction over $j$:\r\n\\par\r\n\\textit{Induction step:} Let $j\\in\\mathbb{N}$ be arbitrary. Assume that\r\n$\\overline{T^{\\ell}}\\in K_{1}^{\\prime}$ is already proven for every $\\ell\r\n\\in\\mathbb{N}$ satisfying $\\ell<j$. We must now prove that $\\overline{T^{j}%\r\n}\\in K_{1}^{\\prime}$.\r\n\\par\r\nIf $j\\in\\left\\{  0,1,...,n-1\\right\\}  $, then we are immediately done with\r\nproving $\\overline{T^{j}}\\in K_{1}^{\\prime}$ (since we already know that\r\n$\\overline{T^{j}}\\in K_{1}^{\\prime}$ for every $j\\in\\left\\{\r\n0,1,...,n-1\\right\\}  $). Thus, we assume that $j\\in\\left\\{\r\n0,1,...,n-1\\right\\}  $ is not the case. Hence, $j\\geq n$, so that $j-n\\geq0$.\r\nNow, $P=\\sum\\limits_{i=0}^{n}\\beta_{i}T^{i}$, so that%\r\n\\[\r\nP\\cdot T^{j-n}=\\sum\\limits_{i=0}^{n}\\beta_{i}T^{i}\\cdot T^{j-n}=\\sum\r\n\\limits_{i=0}^{n}\\beta_{i}T^{i+j-n}=\\sum\\limits_{i=0}^{n-1}\\beta_{i}%\r\nT^{i+j-n}+\\underbrace{\\beta_{n}}_{=1}\\underbrace{T^{n+j-n}}_{=T^{j}}%\r\n=\\sum\\limits_{i=0}^{n-1}\\beta_{i}T^{i+j-n}+T^{j}.\r\n\\]\r\nHence, $T^{j}=P\\cdot T^{j-n}-\\sum\\limits_{i=0}^{n-1}\\beta_{i}T^{i+j-n}%\r\n\\equiv-\\sum\\limits_{i=0}^{n-1}\\beta_{i}T^{i+j-n}\\operatorname{mod}\\left(\r\nP\\right)  $, so that%\r\n\\[\r\n\\overline{T^{j}}=\\overline{-\\sum\\limits_{i=0}^{n-1}\\beta_{i}T^{i+j-n}}%\r\n=-\\sum\\limits_{i=0}^{n-1}\\beta_{i}\\overline{T^{i+j-n}}.\r\n\\]\r\nEvery $i\\in\\left\\{  0,1,...,n-1\\right\\}  $ satisfies $\\overline{T^{i+j-n}}\\in\r\nK_{1}^{\\prime}$ (since $\\overline{T^{\\ell}}\\in K_{1}^{\\prime}$ is already\r\nproven for every $\\ell\\in\\mathbb{N}$ satisfying $\\ell<j$, and since every\r\n$i\\in\\left\\{  0,1,...,n-1\\right\\}  $ satisfies $\\underbrace{i}_{<n}+j-n<j$).\r\nThus,%\r\n\\[\r\n\\overline{T^{j}}=-\\sum\\limits_{i=0}^{n-1}\\beta_{i}\\underbrace{\\overline\r\n{T^{i+j-n}}}_{\\in K_{1}^{\\prime}}\\in K_{1}^{\\prime}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }K_{1}^{\\prime}\\text{ is a }K\\text{-module}\\right)  .\r\n\\]\r\nThis proves that $\\overline{T^{j}}\\in K_{1}^{\\prime}$. The induction step is\r\nthus complete.\r\n\\par\r\nWe have thus proven by strong induction that every $j\\in\\mathbb{N}$ satisfies\r\n$\\overline{T^{j}}\\in K_{1}^{\\prime}$.\r\n\\par\r\nThe $K$-module $K\\left[  T\\right]  $ is generated by the elements $T^{j}$ with\r\n$j\\in\\mathbb{N}$. Hence, the $K$-module $K^{\\prime}=K\\left[  T\\right]\r\n\\diagup\\left(  P\\right)  $ (being a quotient module of $K\\left[  T\\right]  $)\r\nis generated by the elements $\\overline{T^{j}}$ with $j\\in\\mathbb{N}$. Since\r\nall of these generators lie in $K_{1}^{\\prime}$ (because every $j\\in\r\n\\mathbb{N}$ satisfies $\\overline{T^{j}}\\in K_{1}^{\\prime}$), we can conclude\r\nthat $K^{\\prime}\\subseteq K_{1}^{\\prime}$. Combined with $K_{1}^{\\prime\r\n}\\subseteq K^{\\prime}$ (this is trivial), this yields $K^{\\prime}%\r\n=K_{1}^{\\prime}$. Since $K_{1}^{\\prime}$ is the $K$-submodule of $K^{\\prime}$\r\ngenerated by $\\left(  \\overline{T^{0}},\\overline{T^{1}},...,\\overline{T^{n-1}%\r\n}\\right)  $, this yields that the $K$-module $K^{\\prime}$ is generated by\r\n$\\left(  \\overline{T^{0}},\\overline{T^{1}},...,\\overline{T^{n-1}}\\right)  $.}.\r\nThus, the $K$-module $K^{\\prime}$ is finite-free. Also, since $\\left(\r\n\\overline{T^{0}},\\overline{T^{1}},...,\\overline{T^{n-1}}\\right)  $ is a basis\r\nof the $K$-module $K^{\\prime}$, its subsequence $\\left(  \\overline{T^{0}%\r\n}\\right)  =\\left(  \\overline{1}\\right)  $ is linearly independent. Hence, the\r\ncanonical map $K\\rightarrow K^{\\prime}$ is injective (because it maps the\r\nbasis $\\left(  1\\right)  $ of the $K$-module $K$ to the linearly independent\r\nsequence $\\left(  \\overline{1}\\right)  $ of the $K$-module $K^{\\prime}$).\r\nHence, we can view $K^{\\prime}$ as an extension ring of $K$.\r\n\r\nLet $p=\\overline{T}$. Then, $P\\left(  p\\right)  =P\\left(  \\overline{T}\\right)\r\n=\\overline{P\\left(  T\\right)  }=\\overline{P}=0$ (since $P\\equiv\r\n0\\operatorname{mod}\\left(  P\\right)  $). This proves Lemma 5.1.S.1.\r\n\\end{proof}\r\n\r\nAnother lemma:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 5.1.S.2.} Let $\\mathbf{Z}$ be a ring and $P\\in\\mathbf{Z}\\left[\r\nT\\right]  $ be a polynomial. Let $p$ be an element of $\\mathbf{Z}$ such that\r\n$P\\left(  p\\right)  =0$.\r\n\r\n\\textbf{(a)} Then, there exists a polynomial $Q\\in\\mathbf{Z}\\left[  T\\right]\r\n$ of degree $\\leq\\deg P-1$ such that $P=Q\\cdot\\left(  T-p\\right)  $.\r\n\r\n\\textbf{(b)} If the polynomial $P$ is monic, then this polynomial $Q$ is a\r\nmonic polynomial of degree $N-1$, where $N=\\deg P$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 5.1.S.2.]\\textbf{(a)} Lemma 5.1.S.2 \\textbf{(a)} is a known\r\nfact from basic algebra. We are not going to prove it.\r\n\r\n\\textbf{(b)} Assume that the polynomial $P$ is monic. Consider the polynomial\r\n$Q$ from Lemma 5.1.S.2 \\textbf{(a)}.\r\n\r\nLet $N=\\deg P$. Since $Q$ has degree $\\leq\\deg P-1$, we have $\\deg\r\nQ\\leq\\underbrace{\\deg P}_{=N}-1=N-1$. We can thus write the polynomial $Q$ in\r\nthe form $Q=\\sum\\limits_{i=0}^{N-1}q_{i}T^{i}$ for some $\\left(  q_{0}%\r\n,q_{1},...,q_{N-1}\\right)  \\in\\mathbf{Z}^{N}$. Writing it this way, we have%\r\n\\begin{align*}\r\nQ\\cdot\\left(  T-p\\right)   &  =\\sum\\limits_{i=0}^{N-1}q_{i}T^{i}\\cdot\\left(\r\nT-p\\right)  =\\sum\\limits_{i=0}^{N-1}q_{i}\\underbrace{T^{i}T}_{=T^{i+1}}%\r\n-\\sum\\limits_{i=0}^{N-1}q_{i}\\underbrace{T^{i}p}_{=pT^{i}}=\\sum\\limits_{i=0}%\r\n^{N-1}q_{i}T^{i+1}-\\sum\\limits_{i=0}^{N-1}q_{i}pT^{i}\\\\\r\n&  =\\sum\\limits_{i=1}^{N}q_{i-1}T^{i}-\\sum\\limits_{i=0}^{N-1}q_{i}%\r\npT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we substituted }i\\text{ for\r\n}i+1\\text{ in the first sum}\\right)  .\r\n\\end{align*}\r\nThus,%\r\n\\[\r\nP=Q\\cdot\\left(  T-p\\right)  =\\sum\\limits_{i=1}^{N}q_{i-1}T^{i}-\\sum\r\n\\limits_{i=0}^{N-1}q_{i}pT^{i}.\r\n\\]\r\nHence,%\r\n\\begin{align*}\r\n&  \\left(  \\text{the coefficient of the polynomial }P\\text{ before }%\r\nT^{N}\\right) \\\\\r\n&  =\\left(  \\text{the coefficient of the polynomial }\\sum\\limits_{i=1}%\r\n^{N}q_{i-1}T^{i}-\\sum\\limits_{i=0}^{N-1}q_{i}pT^{i}\\text{ before }T^{N}\\right)\r\n\\\\\r\n&  =\\underbrace{\\left(  \\text{the coefficient of the polynomial }%\r\n\\sum\\limits_{i=1}^{N}q_{i-1}T^{i}\\text{ before }T^{N}\\right)  }_{=q_{N-1}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ -\\underbrace{\\left(  \\text{the coefficient of the\r\npolynomial }\\sum\\limits_{i=0}^{N-1}q_{i}pT^{i}\\text{ before }T^{N}\\right)\r\n}_{=0}\\\\\r\n&  =q_{N-1}-0=q_{N-1}.\r\n\\end{align*}\r\nSince $\\left(  \\text{the coefficient of the polynomial }P\\text{ before }%\r\nT^{N}\\right)  =1$ (because $P$ is a monic polynomial with $\\deg P=N$), this\r\nrewrites as $1=q_{N-1}$. Since $\\deg q\\leq N-1$, this yields that $q$ is a\r\nmonic polynomial of degree $N-1$. This proves Lemma 5.1.S.2.\r\n\\end{proof}\r\n\r\nNow, let us solve Exercise 5.1:\r\n\r\nWe will prove the assertion of Exercise 5.1 by induction over $n$.\r\n\r\n\\textit{Induction base:} For $n=0$, the assertion of Exercise 5.1 is trivially\r\ntrue (take $K_{P}=K$). This completes the induction base.\r\n\r\n\\textit{Induction step:} Let $N\\in\\mathbb{N}$ be positive. Assume that the\r\nassertion of Exercise 5.1 is true for $n=N-1$. Let us now prove the assertion\r\nof Exercise 5.1 for $n=N$.\r\n\r\nFirst we recall that we assumed that the assertion of Exercise 5.1 is true for\r\n$n=N-1$. Hence,%\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{If }K^{\\prime}\\text{ is a ring, and if }Q\\in K^{\\prime}\\left[  T\\right]\r\n\\text{ is a monic polynomial such that}\\\\\r\n\\deg Q=N-1\\text{, then there exists a finite-free extension ring }%\r\nK_{Q}^{\\prime}\\text{ of}\\\\\r\n\\text{the ring }K^{\\prime}\\text{ and }N-1\\text{ elements }p_{1}\\text{, }%\r\np_{2}\\text{, }...\\text{, }p_{N-1}\\text{ of this extension}\\\\\r\n\\text{ring }K_{Q}^{\\prime}\\text{ such that }Q=\\prod\\limits_{i=1}^{N-1}\\left(\r\nT-p_{i}\\right)  \\text{ in }K_{Q}^{\\prime}\\left[  T\\right]\r\n\\end{array}\r\n\\right)  \\label{5.1.sol.1}%\r\n\\end{equation}\r\n(this follows from Exercise 5.1, applied to $K^{\\prime}$, $Q$ and $N-1$\r\ninstead of $K$, $P$ and $n$\\ \\ \\ \\ \\footnote{In fact, we are allowed to apply\r\nExercise 5.1 to $K^{\\prime}$, $Q$ and $N-1$ instead of $K$, $P$ and $n$,\r\nbecause we assumed that the assertion of Exercise 5.1 is true for $n=N-1$.}).\r\n\r\nLet $K$ be a ring, and let $P\\in K\\left[  T\\right]  $ be a monic polynomial\r\nsuch that $\\deg P=N$. According to Lemma 5.1.S.1, there exists a finite-free\r\nextension ring $K^{\\prime}$ of the ring $K$ and an element $p\\in K^{\\prime}$\r\nsuch that $P\\left(  p\\right)  =0$ in $K^{\\prime}$. Consider these $K^{\\prime}$\r\nand $p$.\r\n\r\nBy Lemma 5.1.S.2 \\textbf{(a)} (applied to $\\mathbf{Z}=K^{\\prime}$), there\r\nexists a polynomial $Q\\in K^{\\prime}\\left[  T\\right]  $ of degree $\\leq\\deg\r\nP-1$ such that $P=Q\\cdot\\left(  T-p\\right)  $ (since $P\\left(  p\\right)\r\n=0$)\\ \\ \\ \\ \\footnote{Note that $K^{\\prime}\\left[  T\\right]  $ denotes the\r\npolynomial ring in one indeterminate $T$ over $K^{\\prime}$. This $T$ here is\r\n\\textit{not} the $T$ that was used to construct $K^{\\prime}$ in the proof of\r\nLemma 5.1.S.1. In order to avoid confusing these two $T$'s, you are advised to\r\nforget the proof of Lemma 5.1.S.1 (you won't need it any more).}. Consider\r\nthis $Q$. By Lemma 5.1.S.2 \\textbf{(b)} (applied to $\\mathbf{Z}=K^{\\prime}$),\r\nthis polynomial $Q$ is a monic polynomial of degree $N-1$. That is, $Q$ is\r\nmonic and $\\deg Q=N-1$. According to (\\ref{5.1.sol.1}), there therefore exists\r\na finite-free extension ring $K_{Q}^{\\prime}$ of the ring $K^{\\prime}$ and\r\n$N-1$ elements $p_{1}$, $p_{2}$, $...$, $p_{N-1}$ of this extension ring\r\n$K_{Q}^{\\prime}$ such that $Q=\\prod\\limits_{i=1}^{N-1}\\left(  T-p_{i}\\right)\r\n$ in $K_{Q}^{\\prime}\\left[  T\\right]  $. Consider this $K_{Q}^{\\prime}$ and\r\nthese $p_{1}$, $p_{2}$, $...$, $p_{N-1}$.\r\n\r\nSince $K_{Q}^{\\prime}$ is a finite-free $K^{\\prime}$-module, and since\r\n$K^{\\prime}$ is a finite-free $K$-module, it is clear that $K_{Q}^{\\prime}$ is\r\na finite-free $K$-module\\footnote{Here we are using the following general fact\r\nfrom algebra: If $K$ is a ring, if $A$ is a $K$-algebra which is a finite-free\r\n$K$-module, and if $B$ is a finite-free $A$-module, then $B$ is a finite-free\r\n$K$-module.\r\n\\par\r\n\\textit{Proof of this fact.} Since $A$ is a finite-free $K$-module, we have\r\n$A\\cong K^{n}$ as $K$-modules for some $n\\in\\mathbb{N}$. Consider this $n$.\r\nSince $B$ is a finite-free $A$-module, we have $B\\cong A^{m}$ as $A$-modules\r\nfor some $m\\in\\mathbb{N}$. Consider this $m$. Since $B\\cong A^{m}$ as\r\n$A$-modules, we also have%\r\n\\begin{align*}\r\nB  &  \\cong A^{m}\\cong\\left(  K^{n}\\right)  ^{m}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }A\\cong K^{n}\\right) \\\\\r\n&  \\cong K^{nm}%\r\n\\end{align*}\r\nas $K$-modules. Thus, $B$ is a finite-free $K$-module, qed.}. Also, since\r\n$K_{Q}^{\\prime}$ is an extension ring of $K^{\\prime}$, and since $K^{\\prime}$\r\nis an extension ring of $K$, it is clear that $K_{Q}^{\\prime}$ is an extension\r\nring of $K$. Thus, $K_{Q}^{\\prime}$ is a finite-free extension ring of $K$.\r\n\r\nDefine $K_{P}=K_{Q}^{\\prime}$ and $p_{N}=p$. Then, $p_{1}$, $p_{2}$, $...$,\r\n$p_{N-1}$, $p_{N}$ are $N$ elements of the ring $K_{Q}^{\\prime}=K_{P}$. In\r\n$K_{P}\\left[  T\\right]  =K_{Q}^{\\prime}\\left[  T\\right]  $, we have%\r\n\\[\r\nP=\\underbrace{Q}_{=\\prod\\limits_{i=1}^{N-1}\\left(  T-p_{i}\\right)  }%\r\n\\cdot\\left(  T-\\underbrace{p}_{=p_{N}}\\right)  =\\prod\\limits_{i=1}%\r\n^{N-1}\\left(  T-p_{i}\\right)  \\cdot\\left(  T-p_{N}\\right)  =\\prod\r\n\\limits_{i=1}^{N}\\left(  T-p_{i}\\right)  .\r\n\\]\r\nThe ring $K_{P}$ is a finite-free extension ring of $K$ (since $K_{P}%\r\n=K_{Q}^{\\prime}$, and since we know that $K_{Q}^{\\prime}$ is a finite-free\r\nextension ring of $K$).\r\n\r\nSo we have proven that if $K$ is a ring, and if $P\\in K\\left[  T\\right]  $ is\r\na monic polynomial such that $\\deg P=N$, then there exists a finite-free\r\nextension ring $K_{P}$ of the ring $K$ and $N$ elements $p_{1}$, $p_{2}$,\r\n$...$, $p_{N}$ of this extension ring $K_{P}$ such that $P=\\prod\r\n\\limits_{i=1}^{N}\\left(  T-p_{i}\\right)  $ in $K_{P}\\left[  T\\right]  $. In\r\nother words, we have proven the assertion of Exercise 5.1 for $n=N$. Thus, the\r\ninduction step is complete, and Exercise 5.1 is solved.\r\n\r\n\\textit{Exercise 5.2:} \\textit{Hints to solution:} \\textbf{(a)} The idea is to\r\nevaluate the identity $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}=\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}+T\\right)  $ at $T=\\dfrac{1}{S}$, where $S$ is a new\r\nvariable. The only nontrivial part of the solution is to make formal sense of\r\nthis idea (this is what Lemma 5.2.S.1 in the solution below is for).\r\n\\textbf{(b)} is similar.\r\n\r\n\\textit{Detailed solution:} First we need the following lemma:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 5.2.S.1.} Let $L$ be a ring. Consider the polynomial ring\r\n$L\\left[  T\\right]  $ as a subring of the polynomial ring $L\\left[\r\nT,S\\right]  $. Let $P\\in L\\left[  T\\right]  $ be a polynomial such that\r\n$TS-1\\mid P$ in $L\\left[  T,S\\right]  $. Then, $P=0$.\r\n\\end{quote}\r\n\r\nThis is a known and very basic lemma and can be proven, for instance, using\r\nthe fact that the inclusion $L\\left[  T\\right]  \\rightarrow L\\left[\r\nT,S\\right]  $ induces an injective map $L\\left[  T\\right]  \\rightarrow\r\nL\\left[  T,S\\right]  \\diagup\\left(  TS-1\\right)  $. But let us give a slightly\r\ndifferent proof of this lemma, in the hope that a clever reader will find a\r\nbetter use for the trick it involves:\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 5.2.S.1.]Since $TS-1\\mid P$ in $L\\left[  T,S\\right]  $, there\r\nexists a polynomial $Q\\in L\\left[  T,S\\right]  $ such that $P=\\left(\r\nTS-1\\right)  \\cdot Q$. Consider this $Q$.\r\n\r\nLet $m$ be the degree of the polynomial $P\\in L\\left[  T\\right]  $.\r\n\r\nBy the universal property of the polynomial ring $L\\left[  T,S\\right]  $,\r\nthere exists a unique $L$-algebra homomorphism $L\\left[  T,S\\right]\r\n\\rightarrow L\\left[  T\\right]  $ which maps $T$ and $S$ to $T$ and $T^{m}$,\r\nrespectively. Denote this homomorphism by $\\varphi$. Then, $\\varphi$ maps $T$\r\nand $S$ to $T$ and $T^{m}$, respectively, so that $\\varphi\\left(  T\\right)\r\n=T$ and $\\varphi\\left(  S\\right)  =T^{m}$. Since $\\varphi$ is an $L$-algebra\r\nhomomorphism, we have\r\n\\[\r\n\\varphi\\left(  \\left(  TS-1\\right)  \\cdot Q\\right)  =\\left(\r\n\\underbrace{\\varphi\\left(  T\\right)  }_{=T}\\underbrace{\\varphi\\left(\r\nS\\right)  }_{=T^{m}}-1\\right)  \\cdot\\varphi\\left(  Q\\right)  =\\left(\r\nTT^{m}-1\\right)  \\cdot\\varphi\\left(  Q\\right)  =\\left(  T^{m+1}-1\\right)\r\n\\cdot\\varphi\\left(  Q\\right)  .\r\n\\]\r\n\r\n\r\nOn the other hand, $\\varphi\\left(  P\\right)  =P$%\r\n\\ \\ \\ \\ \\footnote{\\textit{Proof.} Since $P\\in L\\left[  T\\right]  $ and $\\deg\r\nP=m$, we can write $P$ in the form $P=\\sum\\limits_{i=0}^{m}\\beta_{i}T^{i}$ for\r\nsome $\\left(  \\beta_{0},\\beta_{1},...,\\beta_{m}\\right)  \\in L^{m+1}$. Thus,%\r\n\\begin{align*}\r\n\\varphi\\left(  P\\right)   &  =\\varphi\\left(  \\sum\\limits_{i=0}^{m}\\beta\r\n_{i}T^{i}\\right)  =\\sum\\limits_{i=0}^{m}\\beta_{i}\\left(  \\underbrace{\\varphi\r\n\\left(  T\\right)  }_{=T}\\right)  ^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\varphi\\text{ is an }L\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\sum\\limits_{i=0}^{m}\\beta_{i}T^{i}=P.\r\n\\end{align*}\r\n}. Now,%\r\n\\[\r\nP=\\varphi\\left(  \\underbrace{P}_{=\\left(  TS-1\\right)  \\cdot Q}\\right)\r\n=\\varphi\\left(  \\left(  TS-1\\right)  \\cdot Q\\right)  =\\left(  T^{m+1}%\r\n-1\\right)  \\cdot\\varphi\\left(  Q\\right)  .\r\n\\]\r\nHence, the polynomial $P$ is a multiple of $T^{m+1}-1$ in $L\\left[  T\\right]\r\n$. Since $T^{m+1}-1$ is a monic polynomial of degree $m+1$, this yields that\r\n$P$ is a multiple of a monic polynomial of degree $m+1$. But it is known that\r\na multiple of a monic polynomial of degree $m+1$ must either have degree $\\geq\r\nm+1$ or be the zero polynomial. Hence, the fact that $P$ is a multiple of a\r\nmonic polynomial of degree $m+1$ yields that $P$ has either degree $\\geq m+1$\r\nor is the zero polynomial. Since we know that $P$ does not have degree $\\geq\r\nm+1$ (because $\\deg P=m<m+1$), this tells us that $P$ is the zero polynomial.\r\nIn other words, $P=0$. Lemma 5.2.S.1 is proven.\r\n\\end{proof}\r\n\r\nNow let us solve Exercise 5.2. Consider the polynomial ring $L\\left[\r\nT\\right]  $ as a subring of the polynomial ring $L\\left[  T,S\\right]  $.\r\n\r\n\\textbf{(a)} Assume that $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}=\\prod\r\n\\limits_{i=1}^{n}\\left(  p_{i}+T\\right)  $. This is a polynomial identity, so\r\nwe can evaluate it at $T=S$ and obtain $\\sum\\limits_{i=0}^{n}a_{n-i}%\r\nS^{i}=\\prod\\limits_{i=1}^{n}\\left(  p_{i}+S\\right)  $. Thus,%\r\n\\begin{align*}\r\nT^{n}\\sum\\limits_{i=0}^{n}a_{n-i}S^{i}  &  =\\underbrace{T^{n}}_{=\\prod\r\n\\limits_{i=1}^{n}T}\\prod\\limits_{i=1}^{n}\\left(  p_{i}+S\\right)\r\n=\\prod\\limits_{i=1}^{n}T\\prod\\limits_{i=1}^{n}\\left(  p_{i}+S\\right)\r\n=\\prod\\limits_{i=1}^{n}\\underbrace{\\left(  T\\left(  p_{i}+S\\right)  \\right)\r\n}_{=p_{i}T+TS}\\\\\r\n&  =\\prod\\limits_{i=1}^{n}\\left(  p_{i}T+\\underbrace{TS}_{\\equiv\r\n1\\operatorname{mod}\\left(  TS-1\\right)  }\\right)  \\equiv\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}T+1\\right)  =\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)\r\n\\operatorname{mod}\\left(  TS-1\\right)  .\r\n\\end{align*}\r\nCombined with%\r\n\\begin{align*}\r\nT^{n}\\sum\\limits_{i=0}^{n}a_{n-i}S^{i}  &  =\\sum\\limits_{i=0}^{n}%\r\na_{n-i}\\underbrace{T^{n}}_{=T^{n-i}T^{i}}S^{i}=\\sum\\limits_{i=0}^{n}%\r\na_{n-i}T^{n-i}\\underbrace{T^{i}S^{i}}_{=\\left(  TS\\right)  ^{i}\\equiv\r\n1^{i}\\operatorname{mod}\\left(  TS-1\\right)  }\\\\\r\n&  \\equiv\\sum\\limits_{i=0}^{n}a_{n-i}T^{n-i}1^{i}=\\sum\\limits_{i=0}^{n}%\r\na_{n-i}T^{n-i}\\\\\r\n&  =\\sum\\limits_{i=0}^{n}a_{i}T^{i}\\operatorname{mod}\\left(  TS-1\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we renamed }n-i\\text{ as }i\\right)  ,\r\n\\end{align*}\r\nthis yields $\\sum\\limits_{i=0}^{n}a_{i}T^{i}\\equiv\\prod\\limits_{i=1}%\r\n^{n}\\left(  1+p_{i}T\\right)  \\operatorname{mod}\\left(  TS-1\\right)  $. In\r\nother words, $TS-1\\mid\\sum\\limits_{i=0}^{n}a_{i}T^{i}-\\prod\\limits_{i=1}%\r\n^{n}\\left(  1+p_{i}T\\right)  $. Thus, Lemma 5.2.S.1 (applied to $P=\\sum\r\n\\limits_{i=0}^{n}a_{i}T^{i}-\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  $)\r\nyields that $\\sum\\limits_{i=0}^{n}a_{i}T^{i}-\\prod\\limits_{i=1}^{n}\\left(\r\n1+p_{i}T\\right)  =0$. In other words, $\\sum\\limits_{i=0}^{n}a_{i}T^{i}%\r\n=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}T\\right)  $. This proves Exercise 5.2\r\n\\textbf{(a)}.\r\n\r\n\\textbf{(b)} Assume that $\\sum\\limits_{i=0}^{n}a_{i}T^{i}=\\prod\\limits_{i=1}%\r\n^{n}\\left(  1+p_{i}T\\right)  $. This is a polynomial identity, so we can\r\nevaluate it at $T=S$ and obtain $\\sum\\limits_{i=0}^{n}a_{i}S^{i}%\r\n=\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}S\\right)  $. Thus,%\r\n\\begin{align*}\r\nT^{n}\\sum\\limits_{i=0}^{n}a_{i}S^{i}  &  =\\underbrace{T^{n}}_{=\\prod\r\n\\limits_{i=1}^{n}T}\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}S\\right)\r\n=\\prod\\limits_{i=1}^{n}T\\prod\\limits_{i=1}^{n}\\left(  1+p_{i}S\\right)\r\n=\\prod\\limits_{i=1}^{n}\\underbrace{\\left(  T\\left(  1+p_{i}S\\right)  \\right)\r\n}_{=T+p_{i}TS}\\\\\r\n&  =\\prod\\limits_{i=1}^{n}\\left(  T+p_{i}\\underbrace{TS}_{\\equiv\r\n1\\operatorname{mod}\\left(  TS-1\\right)  }\\right)  \\equiv\\prod\\limits_{i=1}%\r\n^{n}\\underbrace{\\left(  T+p_{i}1\\right)  }_{=p_{i}+T}=\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}+T\\right)  \\operatorname{mod}\\left(  TS-1\\right)  .\r\n\\end{align*}\r\nCombined with%\r\n\\begin{align*}\r\nT^{n}\\sum\\limits_{i=0}^{n}a_{i}S^{i}  &  =\\sum\\limits_{i=0}^{n}a_{i}%\r\n\\underbrace{T^{n}}_{=T^{n-i}T^{i}}S^{i}=\\sum\\limits_{i=0}^{n}a_{i}%\r\nT^{n-i}\\underbrace{T^{i}S^{i}}_{=\\left(  TS\\right)  ^{i}\\equiv1^{i}%\r\n\\operatorname{mod}\\left(  TS-1\\right)  }\\equiv\\sum\\limits_{i=0}^{n}%\r\na_{i}T^{n-i}1^{i}=\\sum\\limits_{i=0}^{n}a_{i}T^{n-i}\\\\\r\n&  =\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}\\operatorname{mod}\\left(  TS-1\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we renamed }n-i\\text{ as }i\\right)  ,\r\n\\end{align*}\r\nthis yields $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}\\equiv\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}+T\\right)  \\operatorname{mod}\\left(  TS-1\\right)  $. In other\r\nwords, $TS-1\\mid\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}-\\prod\\limits_{i=1}%\r\n^{n}\\left(  p_{i}+T\\right)  $. Thus, Lemma 5.2.S.1 (applied to $P=\\sum\r\n\\limits_{i=0}^{n}a_{n-i}T^{i}-\\prod\\limits_{i=1}^{n}\\left(  p_{i}+T\\right)  $)\r\nyields that $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}-\\prod\\limits_{i=1}^{n}\\left(\r\np_{i}+T\\right)  =0$. In other words, $\\sum\\limits_{i=0}^{n}a_{n-i}T^{i}%\r\n=\\prod\\limits_{i=1}^{n}\\left(  p_{i}+T\\right)  $. This proves Exercise 5.2\r\n\\textbf{(b)}.\r\n\r\n\\textit{Exercise 5.3: Hints to solution:} Exercise 5.3 follows from Exercise\r\n5.1, applied to $\\dfrac{P}{T-p}$ instead of $P$.\r\n\r\n\\textit{Detailed solution:} By Lemma 5.1.S.2 \\textbf{(a)} (applied to\r\n$\\mathbf{Z}=K$), there exists a polynomial $Q\\in K\\left[  T\\right]  $ of\r\ndegree $\\leq\\deg P-1$ such that $P=Q\\cdot\\left(  T-p\\right)  $. Consider this\r\n$Q$. By Lemma 5.1.S.2 \\textbf{(b)} (applied to $\\mathbf{Z}=K$), this\r\npolynomial $Q$ is a monic polynomial of degree $N-1$, where $N=\\deg P$. Since\r\n$N=\\deg P=n$, this rewrites as follows: The polynomial $Q$ is a monic\r\npolynomial of degree $n-1$.\r\n\r\nThus, Exercise 5.1 (applied to $Q$ and $n-1$ instead of $P$ and $n$) yields\r\nthat there exists a finite-free extension ring $K_{Q}$ of the ring $K$ and\r\n$n-1$ elements $p_{1}$, $p_{2}$, $...$, $p_{n-1}$ of this extension ring\r\n$K_{Q}$ such that $Q=\\prod\\limits_{i=1}^{n-1}\\left(  T-p_{i}\\right)  $ in\r\n$K_{Q}\\left[  T\\right]  $. Consider this ring $K_{Q}$ and these $n-1$ elements\r\n$p_{1}$, $p_{2}$, $...$, $p_{n-1}$.\r\n\r\nDefine a further element $p_{n}$ of $K_{Q}$ by $p_{n}=p$. Then, $p_{1}$,\r\n$p_{2}$, $...$, $p_{n}$ are $n$ elements of $K_{Q}$ satisfying%\r\n\\[\r\nP=\\underbrace{Q}_{=\\prod\\limits_{i=1}^{n-1}\\left(  T-p_{i}\\right)  }%\r\n\\cdot\\left(  T-\\underbrace{p}_{=p_{n}}\\right)  =\\prod\\limits_{i=1}%\r\n^{n-1}\\left(  T-p_{i}\\right)  \\cdot\\left(  T-p_{n}\\right)  =\\prod\r\n\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)\r\n\\]\r\nin $K_{Q}\\left[  T\\right]  $.\r\n\r\nLet $K_{P}^{\\prime}=K_{Q}$. Then, $K_{P}^{\\prime}$ is a finite-free extension\r\nring of the ring $K$ (since $K_{Q}$ is a finite-free extension ring of the\r\nring $K$), and the $n$ elements $p_{1}$, $p_{2}$, $...$, $p_{n}$ of $K_{Q}$\r\nsatisfy $P=\\prod\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)  $ in $K_{P}^{\\prime\r\n}\\left[  T\\right]  $ and $p=p_{n}$. Thus, Exercise 5.3 is solved.\r\n\r\n\\textit{Exercise 5.4: Hints to solution:} First here is a rewriting of\r\nExercise 5.2 \\textbf{(b)}:\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 5.4.S.1.} Let $L$ be a ring. Let $\\ell\\in\\mathbb{N}$. Let\r\n$a_{0}$, $a_{1}$, $...$, $a_{\\ell}$ be elements of $L$. Let $S$ be a finite\r\nset with $\\left\\vert S\\right\\vert =\\ell$. For every $s\\in S$, let $p_{s}$ be\r\nan element of $L$. If $\\sum\\limits_{i=0}^{\\ell}a_{i}T^{i}=\\prod\\limits_{s\\in\r\nS}\\left(  1+p_{s}T\\right)  $ in the polynomial ring $L\\left[  T\\right]  $,\r\nthen $\\sum\\limits_{i=0}^{\\ell}a_{\\ell-i}T^{i}=\\prod\\limits_{s\\in S}\\left(\r\np_{s}+T\\right)  $.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 5.4.S.1.]Assume that $\\sum\\limits_{i=0}^{\\ell}a_{i}T^{i}%\r\n=\\prod\\limits_{s\\in S}\\left(  1+p_{s}T\\right)  $.\r\n\r\nSince the finite set $S$ is used only for labelling the elements $p_{s}$, we\r\ncan WLOG assume that $S=\\left\\{  1,2,...,\\ell\\right\\}  $ (since $\\left\\vert\r\nS\\right\\vert =\\ell$). Assume this. Then,\r\n\\[\r\n\\prod\\limits_{s\\in S}\\left(  1+p_{s}T\\right)  =\\prod\\limits_{s\\in\\left\\{\r\n1,2,...,\\ell\\right\\}  }\\left(  1+p_{s}T\\right)  =\\prod\\limits_{s=1}^{\\ell\r\n}\\left(  1+p_{s}T\\right)  =\\prod\\limits_{i=1}^{\\ell}\\left(  1+p_{i}T\\right)\r\n\\]\r\n(here we renamed the index $s$ as $i$) and%\r\n\\[\r\n\\prod\\limits_{s\\in S}\\left(  p_{s}+T\\right)  =\\prod\\limits_{s\\in\\left\\{\r\n1,2,...,\\ell\\right\\}  }\\left(  p_{s}+T\\right)  =\\prod\\limits_{s=1}^{\\ell\r\n}\\left(  p_{s}+T\\right)  =\\prod\\limits_{i=1}^{\\ell}\\left(  p_{i}+T\\right)\r\n\\]\r\n(here we renamed the index $s$ as $i$).\r\n\r\nNow, $\\sum\\limits_{i=0}^{\\ell}a_{i}T^{i}=\\prod\\limits_{s\\in S}\\left(\r\n1+p_{s}T\\right)  =\\prod\\limits_{i=1}^{\\ell}\\left(  1+p_{i}T\\right)  $. Hence,\r\nExercise 5.2 \\textbf{(b)} (applied to $n=\\ell$) yields $\\sum\\limits_{i=0}%\r\n^{\\ell}a_{\\ell-i}T^{i}=\\prod\\limits_{i=1}^{\\ell}\\left(  p_{i}+T\\right)\r\n=\\prod\\limits_{s\\in S}\\left(  p_{s}+T\\right)  $. This proves Lemma 5.4.S.1.\r\n\\end{proof}\r\n\r\nThe next lemma is more or less the statement of our exercise (except for that\r\nit has $-\\alpha\\beta$ instead of $\\alpha\\beta$, but this doesn't make that\r\nmuch of a difference):\r\n\r\n\\begin{quote}\r\n\\textbf{Lemma 5.4.S.2.} Let $K$ be a ring, and $L$ an extension ring of $K$.\r\nLet $n\\in\\mathbb{N}$ and $m\\in\\mathbb{N}$. Let $\\alpha$ and $\\beta$ be two\r\nelements of $L$ such that $\\alpha$ is $n$-integral over $K$ and $\\beta$ is\r\n$m$-integral over $K$. Then, $-\\alpha\\beta$ is $nm$-integral over $K$.\r\n\\end{quote}\r\n\r\n\\begin{proof}\r\n[Proof of Lemma 5.4.S.2.]Since $\\alpha$ is $n$-integral over $K$, there exists\r\na monic polynomial $P\\in K\\left[  T\\right]  $ such that $\\deg P=n$ and\r\n$P\\left(  \\alpha\\right)  =0$ (by the definition of ``$n$-integral'').\r\n\r\nSince $\\beta$ is $m$-integral over $K$, there exists a monic polynomial $Q\\in\r\nK\\left[  T\\right]  $ such that $\\deg Q=m$ and $Q\\left(  \\beta\\right)  =0$ (by\r\nthe definition of ``$m$-integral'').\r\n\r\nSince $\\deg P=n$, we can write the polynomial $P\\in K\\left[  T\\right]  $ in\r\nthe form $P=\\sum\\limits_{i=0}^{n}c_{i}T^{i}$ for some $\\left(  c_{0}%\r\n,c_{1},...,c_{n}\\right)  \\in K^{n+1}$. Consider this $\\left(  c_{0}%\r\n,c_{1},...,c_{n}\\right)  $. Then, $c_{n}=\\left(  \\text{the coefficient of\r\n}P\\text{ before }T^{n}\\right)  =1$ (since $P$ is a monic polynomial with $\\deg\r\nP=n$).\r\n\r\nSince $\\deg Q=m$, we can write the polynomial $Q\\in K\\left[  T\\right]  $ in\r\nthe form $Q=\\sum\\limits_{i=0}^{m}d_{i}T^{i}$ for some $\\left(  d_{0}%\r\n,d_{1},...,d_{m}\\right)  \\in K^{m+1}$. Consider this $\\left(  d_{0}%\r\n,d_{1},...,d_{m}\\right)  $. Then, $d_{m}=\\left(  \\text{the coefficient of\r\n}Q\\text{ before }T^{m}\\right)  =1$ (since $Q$ is a monic polynomial with $\\deg\r\nQ=m$).\r\n\r\nFor every $i\\in\\mathbb{N}$, define an element $a_{i}\\in K$ by $a_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nc_{n-i}\\text{, if }i\\leq n;\\\\\r\n0\\text{, if }i>n\r\n\\end{array}\r\n\\right.  $. For every $i\\in\\mathbb{N}$, define an element $b_{i}\\in K$ by\r\n$b_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nd_{m-i}\\text{, if }i\\leq m;\\\\\r\n0\\text{, if }i>m\r\n\\end{array}\r\n\\right.  $.\r\n\r\nLet $R\\in K\\left[  T\\right]  $ be the polynomial defined by%\r\n\\[\r\nR=\\sum\\limits_{i=0}^{mn}P_{mn-i}\\left(  a_{1},a_{2},...,a_{mn-i},b_{1}%\r\n,b_{2},...,b_{mn-i}\\right)  T^{i}.\r\n\\]\r\n\r\n\r\nNow we claim that $R$ is a monic polynomial, that $\\deg R=mn$ and that\r\n$R\\left(  -\\alpha\\beta\\right)  =0$.\r\n\r\n\\textit{Proof.} Exercise 5.3 (applied to $\\alpha$ and $L$ instead of $p$ and\r\n$K$) yields that there exists a finite-free extension ring $L_{P}^{\\prime}$ of\r\n$L$ and $n$ elements $p_{1}$, $p_{2}$, $...$, $p_{n}$ of this extension ring\r\n$L_{P}^{\\prime}$ such that $P=\\prod\\limits_{i=1}^{n}\\left(  T-p_{i}\\right)  $\r\nin $L_{P}^{\\prime}\\left[  T\\right]  $ and such that $\\alpha=p_{n}$. Consider\r\nthis extension ring $L_{P}^{\\prime}$ and these elements $p_{1}$, $p_{2}$,\r\n$...$, $p_{n}$. Denote this extension ring $L_{P}^{\\prime}$ by $M$. All we\r\nneed to know about $M$ is that $M$ is an extension ring of $L$ containing\r\n$p_{1}$, $p_{2}$, $...$, $p_{n}$.\r\n\r\nExercise 5.3 (applied to $Q$, $m$, $\\beta$ and $M$ instead of $P$, $n$, $p$\r\nand $K$) yields that there exists a finite-free extension ring $M_{Q}^{\\prime\r\n}$ of $M$ and $m$ elements $q_{1}$, $q_{2}$, $...$, $q_{m}$ of this extension\r\nring $M_{Q}^{\\prime}$ such that $Q=\\prod\\limits_{i=1}^{m}\\left(\r\nT-q_{i}\\right)  $ in $M_{Q}^{\\prime}\\left[  T\\right]  $ and such that\r\n$\\beta=q_{m}$. Consider this extension ring $M_{Q}^{\\prime}$ and these\r\nelements $q_{1}$, $q_{2}$, $...$, $q_{m}$. Denote this extension ring\r\n$M_{Q}^{\\prime}$ by $N$. All we need to know about $N$ is that $N$ is an\r\nextension ring of $L$ (since $N$ is an extension ring of $M$, which, in turn,\r\nis an extension ring of $L$) containing $p_{1}$, $p_{2}$, $...$, $p_{n}$\r\n(because it contains $L$ and because $L$ contains $p_{1}$, $p_{2}$, $...$,\r\n$p_{n}$) and containing $q_{1}$, $q_{2}$, $...$, $q_{m}$.\r\n\r\nLet $\\widetilde{P}\\in K\\left[  T\\right]  $ be the polynomial $\\sum\r\n\\limits_{i=0}^{n}c_{n-i}T^{i}$. This polynomial $\\widetilde{P}$ has constant\r\nterm $c_{n-0}=c_{n}=1$, hence lies in $1+K\\left[  T\\right]  ^{+}$.\r\n\r\nLet $\\widetilde{Q}\\in K\\left[  T\\right]  $ be the polynomial $\\sum\r\n\\limits_{i=0}^{m}d_{m-i}T^{i}$. This polynomial $\\widetilde{Q}$ has constant\r\nterm $d_{m-0}=d_{m}=1$, hence lies in $1+K\\left[  T\\right]  ^{+}$.\r\n\r\nWe have $\\sum\\limits_{i=0}^{n}\\underbrace{c_{n-\\left(  n-i\\right)  }}_{=c_{i}%\r\n}T^{i}=\\sum\\limits_{i=0}^{n}c_{i}T^{i}=P=\\prod\\limits_{i=1}^{n}%\r\n\\underbrace{\\left(  T-p_{i}\\right)  }_{=-p_{i}+T}=\\prod\\limits_{i=1}%\r\n^{n}\\left(  -p_{i}+T\\right)  $. Therefore, Exercise 5.2 \\textbf{(a)} (applied\r\nto $N$, $c_{n-i}$ and $-p_{i}$ instead of $L$, $a_{i}$ and $p_{i}$) yields\r\nthat%\r\n\\[\r\n\\sum\\limits_{i=0}^{n}c_{n-i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(  1+\\left(\r\n-p_{i}\\right)  T\\right)  .\r\n\\]\r\nThus,%\r\n\\[\r\n\\widetilde{P}=\\sum\\limits_{i=0}^{n}c_{n-i}T^{i}=\\prod\\limits_{i=1}^{n}\\left(\r\n1+\\left(  -p_{i}\\right)  T\\right)  =\\Pi\\left(  N,\\left[  -p_{1},-p_{2}%\r\n,...,-p_{n}\\right]  \\right)  .\r\n\\]\r\n\r\n\r\nWe have $\\sum\\limits_{i=0}^{m}\\underbrace{d_{m-\\left(  m-i\\right)  }}_{=d_{i}%\r\n}T^{i}=\\sum\\limits_{i=0}^{m}d_{i}T^{i}=Q=\\prod\\limits_{i=1}^{m}%\r\n\\underbrace{\\left(  T-q_{i}\\right)  }_{=-q_{i}+T}=\\prod\\limits_{i=1}%\r\n^{m}\\left(  -q_{i}+T\\right)  $. Therefore, Exercise 5.2 \\textbf{(a)} (applied\r\nto $N$, $m$, $d_{m-i}$ and $-q_{i}$ instead of $L$, $n$, $a_{i}$ and $p_{i}$)\r\nyields that%\r\n\\[\r\n\\sum\\limits_{i=0}^{m}d_{m-i}T^{i}=\\prod\\limits_{i=1}^{m}\\left(  1+\\left(\r\n-q_{i}\\right)  T\\right)  .\r\n\\]\r\nThus,%\r\n\\[\r\n\\widetilde{Q}=\\sum\\limits_{i=0}^{m}d_{m-i}T^{i}=\\prod\\limits_{i=1}^{m}\\left(\r\n1+\\left(  -q_{i}\\right)  T\\right)  =\\Pi\\left(  N,\\left[  -q_{1},-q_{2}%\r\n,...,-q_{m}\\right]  \\right)  .\r\n\\]\r\n\r\n\r\nSince $\\widetilde{Q}=\\Pi\\left(  N,\\left[  -q_{1},-q_{2},...,-q_{n}\\right]\r\n\\right)  $ and $\\widetilde{P}=\\Pi\\left(  N,\\left[  -p_{1},-p_{2}%\r\n,...,-p_{n}\\right]  \\right)  $, we can apply Theorem 5.3 \\textbf{(c)} to\r\n$u=\\widetilde{Q}$, $v=\\widetilde{P}$, $\\widetilde{K}_{u}=N$, $\\widetilde{K}%\r\n_{v}=N$, $\\widetilde{K}_{u,v}=N$, $u_{i}=-q_{i}$ and $v_{j}=-p_{j}$. As a\r\nresult we obtain%\r\n\\begin{align*}\r\n\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}  &  =\\Pi\\left(  N,\\left[\r\n\\underbrace{\\left(  -q_{i}\\right)  \\left(  -p_{j}\\right)  }_{=p_{j}q_{i}%\r\n}\\ \\mid\\ \\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right]  \\right) \\\\\r\n&  =\\Pi\\left(  N,\\left[  p_{j}q_{i}\\ \\mid\\ \\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  \\right]  \\right)\r\n=\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+p_{j}q_{i}T\\right)  .\r\n\\end{align*}\r\nThus, $\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}$ is a polynomial of degree%\r\n\\begin{align*}\r\n\\deg\\left(  \\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}\\right)   &  =\\deg\\left(\r\n\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+p_{j}q_{i}T\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\widetilde{Q}\\widehat{\\cdot\r\n}\\widetilde{P}=\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+p_{j}%\r\nq_{i}T\\right)  \\right) \\\\\r\n&  \\leq\\sum\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\underbrace{\\deg\\left(  1+p_{j}%\r\nq_{i}T\\right)  }_{\\leq1}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since the degree of a product of some polynomials}\\\\\r\n\\text{is }\\leq\\text{ to the sum of the degrees of these polynomials}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  \\leq\\sum\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }1=\\left\\vert \\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  \\right\\vert =mn.\r\n\\end{align*}\r\n\r\n\r\nBut%\r\n\\begin{align*}\r\n\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}  &  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nc_{n-i}\\text{, if }i\\leq n;\\\\\r\n0\\text{, if }i>n\r\n\\end{array}\r\n\\right.  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }a_{i}=\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nc_{n-i}\\text{, if }i\\leq n;\\\\\r\n0\\text{, if }i>n\r\n\\end{array}\r\n\\right.  \\right) \\\\\r\n&  =\\sum\\limits_{i=0}^{n}\\underbrace{\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nc_{n-i}\\text{, if }i\\leq n;\\\\\r\n0\\text{, if }i>n\r\n\\end{array}\r\n\\right.  }_{=c_{n-i}\\text{ (since }i\\leq n\\text{)}}T^{i}+\\sum\\limits_{i=n+1}%\r\n^{\\infty}\\underbrace{\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\nc_{n-i}\\text{, if }i\\leq n;\\\\\r\n0\\text{, if }i>n\r\n\\end{array}\r\n\\right.  }_{=0}T^{i}\\\\\r\n&  =\\sum\\limits_{i=0}^{n}c_{n-i}T^{i}+\\underbrace{\\sum\\limits_{i=n+1}^{\\infty\r\n}0T^{i}}_{=0}=\\sum\\limits_{i=0}^{n}c_{n-i}T^{i}=\\widetilde{P}%\r\n\\end{align*}\r\nand similarly $\\sum\\limits_{i\\in\\mathbb{N}}b_{i}T^{i}=\\widetilde{Q}$. Now,%\r\n\\begin{align*}\r\n\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}  &  =\\widetilde{P}\\widehat{\\cdot\r\n}\\widetilde{Q}=\\left(  \\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)\r\n\\widehat{\\cdot}\\left(  \\sum\\limits_{i\\in\\mathbb{N}}b_{i}T^{i}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\widetilde{P}=\\sum\\limits_{i\\in\r\n\\mathbb{N}}a_{i}T^{i}\\text{ and }\\widetilde{Q}=\\sum\\limits_{i\\in\\mathbb{N}%\r\n}b_{i}T^{i}\\right) \\\\\r\n&  =\\sum_{k\\in\\mathbb{N}}P_{k}\\left(  a_{1},a_{2},...,a_{k},b_{1}%\r\n,b_{2},...,b_{k}\\right)  T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\widehat{\\cdot\r\n}\\text{ at the beginning of Section 5}\\right)  .\r\n\\end{align*}\r\nHence, for every $k\\in\\mathbb{N}$, we have%\r\n\\[\r\n\\left(  \\text{the coefficient of the polynomial }\\widetilde{Q}\\widehat{\\cdot\r\n}\\widetilde{P}\\text{ before }T^{k}\\right)  =P_{k}\\left(  a_{1},a_{2}%\r\n,...,a_{k},b_{1},b_{2},...,b_{k}\\right)  .\r\n\\]\r\n\r\n\r\nBut since $\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}$ is a polynomial of\r\ndegree $\\leq mn$, we have%\r\n\\begin{align*}\r\n\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}  &  =\\sum_{k=0}^{mn}%\r\n\\underbrace{\\left(  \\text{the coefficient of the polynomial }\\widetilde{Q}%\r\n\\widehat{\\cdot}\\widetilde{P}\\text{ before }T^{k}\\right)  }_{=P_{k}\\left(\r\na_{1},a_{2},...,a_{k},b_{1},b_{2},...,b_{k}\\right)  }T^{k}\\\\\r\n&  =\\sum_{k=0}^{mn}P_{k}\\left(  a_{1},a_{2},...,a_{k},b_{1},b_{2}%\r\n,...,b_{k}\\right)  T^{k}\\\\\r\n&  =\\sum_{i=0}^{mn}P_{i}\\left(  a_{1},a_{2},...,a_{i},b_{1},b_{2}%\r\n,...,b_{i}\\right)  T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed\r\n}k\\text{ as }i\\right)  .\r\n\\end{align*}\r\nThus,%\r\n\\[\r\n\\sum_{i=0}^{mn}P_{i}\\left(  a_{1},a_{2},...,a_{i},b_{1},b_{2},...,b_{i}%\r\n\\right)  T^{i}=\\widetilde{Q}\\widehat{\\cdot}\\widetilde{P}=\\prod\\limits_{\\left(\r\ni,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n}\\left(  1+p_{j}q_{i}T\\right)  .\r\n\\]\r\nDefine $r_{\\left(  i,j\\right)  }$ to mean $p_{j}q_{i}$ for every $\\left(\r\ni,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}\r\n$. Then,%\r\n\\begin{align*}\r\n&  \\sum_{i=0}^{mn}P_{i}\\left(  a_{1},a_{2},...,a_{i},b_{1},b_{2}%\r\n,...,b_{i}\\right)  T^{i}\\\\\r\n&  =\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+\\underbrace{p_{j}q_{i}%\r\n}_{=r_{\\left(  i,j\\right)  }}T\\right)  =\\prod\\limits_{\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(\r\n1+r_{\\left(  i,j\\right)  }T\\right) \\\\\r\n&  =\\prod\\limits_{s\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  1+r_{s}T\\right)\r\n\\end{align*}\r\n(here, we renamed the index $\\left(  i,j\\right)  $ as $s$). Thus, Lemma\r\n5.4.S.1 (applied to $N$, $mn$, $P_{i}\\left(  a_{1},a_{2},...,a_{i},b_{1}%\r\n,b_{2},...,b_{i}\\right)  $, $\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  $ and $r_{s}$ instead of $L$, $\\ell$, $a_{i}$, $S$ and\r\n$p_{s}$) yields that%\r\n\\[\r\n\\sum\\limits_{i=0}^{mn}P_{mn-i}\\left(  a_{1},a_{2},...,a_{mn-i},b_{1}%\r\n,b_{2},...,b_{mn-i}\\right)  T^{i}=\\prod\\limits_{s\\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(  r_{s}+T\\right)\r\n.\r\n\\]\r\nSince $\\sum\\limits_{i=0}^{mn}P_{mn-i}\\left(  a_{1},a_{2},...,a_{mn-i}%\r\n,b_{1},b_{2},...,b_{mn-i}\\right)  T^{i}=R$, this rewrites as%\r\n\\begin{align*}\r\nR  &  =\\prod\\limits_{s\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }\\left(  r_{s}+T\\right)  =\\prod\\limits_{\\left(  i,j\\right)\r\n\\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(\r\n\\underbrace{r_{\\left(  i,j\\right)  }}_{=p_{j}q_{i}}+T\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we renamed the index }s\\text{ as\r\n}\\left(  i,j\\right)  \\right) \\\\\r\n&  =\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}\r\n\\times\\left\\{  1,2,...,n\\right\\}  }\\left(  p_{j}q_{i}+T\\right)  .\r\n\\end{align*}\r\nTherefore,%\r\n\\begin{equation}\r\nR\\left(  -\\alpha\\beta\\right)  =\\prod\\limits_{\\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(  p_{j}%\r\nq_{i}+\\left(  -\\alpha\\beta\\right)  \\right)  . \\label{5.4.sol.1}%\r\n\\end{equation}\r\nOne of the factors of the product on the right hand side of (\\ref{5.4.sol.1})\r\n(namely, the one for $\\left(  i,j\\right)  =\\left(  m,n\\right)  $) is%\r\n\\[\r\n\\underbrace{p_{n}}_{=\\alpha}\\underbrace{q_{m}}_{=\\beta}+\\left(  -\\alpha\r\n\\beta\\right)  =\\alpha\\beta+\\left(  -\\alpha\\beta\\right)  =0.\r\n\\]\r\nHence, the product on the right hand side of (\\ref{5.4.sol.1}) is $0$. Thus,\r\n(\\ref{5.4.sol.1}) simplifies to $R\\left(  -\\alpha\\beta\\right)  =0$.\r\n\r\nSince $R$ was defined by\r\n\\[\r\nR=\\sum\\limits_{i=0}^{mn}P_{mn-i}\\left(  a_{1},a_{2},...,a_{mn-i},b_{1}%\r\n,b_{2},...,b_{mn-i}\\right)  T^{i},\r\n\\]\r\nit is clear that the polynomial $R$ has degree $\\leq mn$, and that the\r\ncoefficient of $R$ before $T^{mn}$ is%\r\n\\[\r\nP_{mn-mn}\\left(  a_{1},a_{2},...,a_{mn-mn},b_{1},b_{2},...,b_{mn-mn}\\right)\r\n=P_{0}\\left(  a_{1},a_{2},...,a_{0},b_{1},b_{2},...,b_{0}\\right)  =P_{0}=1\r\n\\]\r\n(here we are using the fact that $P_{0}=1$; this is very easy to see from the\r\ndefinition of $P_{0}$). Thus, $R$ is a monic polynomial of degree $mn$. Hence\r\n$\\deg R=mn=nm$.\r\n\r\nSo we have found a monic polynomial $R\\in K\\left[  T\\right]  $ such that $\\deg\r\nR=nm$ and $R\\left(  -\\alpha\\beta\\right)  =0$. By the definition of\r\n``$nm$-integral'', this yields that $-\\alpha\\beta$ is $nm$-integral over $K$.\r\nThis proves Lemma 5.4.S.2.\r\n\\end{proof}\r\n\r\nNow let us finally solve the problem. Let $\\alpha$ and $\\beta$ be two elements\r\nof $L$ such that $\\alpha$ is $n$-integral over $K$ and $\\beta$ is $m$-integral\r\nover $K$. Then, Lemma 5.4.S.2 yields that $-\\alpha\\beta$ is $nm$-integral over\r\n$K$. Hence, Lemma 5.4.S.2 (applied to $nm$, $1$, $-\\alpha\\beta$ and $-1$\r\ninstead of $n$, $m$, $\\alpha$ and $\\beta$) yields that $\\left(  -\\alpha\r\n\\beta\\right)  \\left(  -1\\right)  $ is $\\left(  nm\\right)  \\cdot1$-integral\r\nover $K$ (since $-1$ is $1$-integral over $K$). In other words, $\\alpha\\beta$\r\nis $nm$-integral over $K$. This solves Exercise 5.4.\r\n\r\n\\textit{Exercise 5.5:} \\textit{Detailed solution:} \\textbf{(a)} Let $\\pi$ be\r\nthe canonical projection $K\\rightarrow K\\diagup I$. Then, $\\pi$ is a ring\r\nhomomorphism, and thus induces a canonical ring homomorphism $\\pi\\left[\r\n\\left[  T\\right]  \\right]  :K\\left[  \\left[  T\\right]  \\right]  \\rightarrow\r\n\\left(  K\\diagup I\\right)  \\left[  \\left[  T\\right]  \\right]  $ (which sends\r\nevery $\\sum\\limits_{i\\in\\mathbb{N}}a_{i}T^{i}\\in K\\left[  \\left[  T\\right]\r\n\\right]  $ to $\\sum\\limits_{i\\in\\mathbb{N}}\\pi\\left(  a_{i}\\right)  T^{i}%\r\n\\in\\left(  K\\diagup I\\right)  \\left[  \\left[  T\\right]  \\right]  $). The\r\nmorphism $\\Lambda\\left(  \\pi\\right)  $ is merely the restriction of this\r\nhomomorphism $\\pi\\left[  \\left[  T\\right]  \\right]  $ to the subset\r\n$\\Lambda\\left(  K\\right)  $ of $K\\left[  \\left[  T\\right]  \\right]  $ (due to\r\nthe definition of $\\Lambda\\left(  \\pi\\right)  $).\r\n\r\nNotice that $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}\\subseteq1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $.\r\n\r\n\\textit{1st step:} We have $1+I\\left[  \\left[  T\\right]  \\right]\r\n^{+}\\subseteq\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $.\r\n\r\n\\textit{Proof:} Let $q\\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$. Then,\r\n$q-1\\in I\\left[  \\left[  T\\right]  \\right]  ^{+}=TI\\left[  \\left[  T\\right]\r\n\\right]  \\subseteq I\\left[  \\left[  T\\right]  \\right]  $. Thus, we can write\r\n$q-1$ in the form $q-1=\\sum\\limits_{i\\geq0}r_{i}T^{i}$ for some sequence\r\n$\\left(  r_{0},r_{1},r_{2},...\\right)  $ of elements of $I$. Consider this\r\n$\\left(  r_{0},r_{1},r_{2},...\\right)  $. Clearly, $r_{i}\\in I$ for every\r\n$i\\geq0$. Thus, $\\pi\\left(  r_{i}\\right)  =0$ for every $i\\geq0$ (because\r\n$\\pi$ is the canonical projection $K\\rightarrow K\\diagup I$). Now, by the\r\ndefinition of $\\pi\\left[  \\left[  T\\right]  \\right]  $, we have%\r\n\\[\r\n\\left(  \\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  \\sum\r\n\\limits_{i\\geq0}r_{i}T^{i}\\right)  =\\sum\\limits_{i\\geq0}\\underbrace{\\pi\\left(\r\nr_{i}\\right)  }_{=0}T^{i}=\\sum\\limits_{i\\geq0}0T^{i}=0.\r\n\\]\r\nSince $\\sum\\limits_{i\\geq0}r_{i}T^{i}=q-1$, this rewrites as $\\left(\r\n\\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  q-1\\right)  =0$. Since%\r\n\\[\r\n\\left(  \\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  q-1\\right)\r\n=\\left(  \\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  q\\right)\r\n-1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\pi\\left[  \\left[  T\\right]\r\n\\right]  \\text{ is a ring homomorphism}\\right)  ,\r\n\\]\r\nthis rewrites as $\\left(  \\pi\\left[  \\left[  T\\right]  \\right]  \\right)\r\n\\left(  q\\right)  -1=0$. That is, $\\left(  \\pi\\left[  \\left[  T\\right]\r\n\\right]  \\right)  \\left(  q\\right)  =1$. Since $\\Lambda\\left(  \\pi\\right)  $\r\nis the restriction of $\\pi\\left[  \\left[  T\\right]  \\right]  $ to the subset\r\n$\\Lambda\\left(  K\\right)  $ of $K\\left[  \\left[  T\\right]  \\right]  $, and\r\nsince $q\\in\\Lambda\\left(  K\\right)  $, we have $\\left(  \\Lambda\\left(\r\n\\pi\\right)  \\right)  \\left(  q\\right)  =\\left(  \\pi\\left[  \\left[  T\\right]\r\n\\right]  \\right)  \\left(  q\\right)  =1$, so that $q\\in\\operatorname*{Ker}%\r\n\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $ (because the power series\r\n$1\\in\\Lambda\\left(  K\\diagup I\\right)  $ is the zero of the ring\r\n$\\Lambda\\left(  K\\diagup I\\right)  $).\r\n\r\nNow forget that we fixed $q$. We thus have proven that every $q\\in1+I\\left[\r\n\\left[  T\\right]  \\right]  ^{+}$ satisfies $q\\in\\operatorname*{Ker}\\left(\r\n\\Lambda\\left(  \\pi\\right)  \\right)  $. In other words, $1+I\\left[  \\left[\r\nT\\right]  \\right]  ^{+}\\subseteq\\operatorname*{Ker}\\left(  \\Lambda\\left(\r\n\\pi\\right)  \\right)  $. This completes the proof of the 1st step.\r\n\r\n\\textit{2nd step:} We have $\\operatorname*{Ker}\\left(  \\Lambda\\left(\r\n\\pi\\right)  \\right)  \\subseteq1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$.\r\n\r\n\\textit{Proof:} Let $q\\in\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)\r\n\\right)  $. Then, $q\\in\\Lambda\\left(  K\\right)  $ and $\\left(  \\Lambda\\left(\r\n\\pi\\right)  \\right)  \\left(  q\\right)  =1$ (because $1\\in\\Lambda\\left(\r\nK\\diagup I\\right)  $ is the zero of the ring $\\Lambda\\left(  K\\diagup\r\nI\\right)  $).\r\n\r\nSince $q\\in\\Lambda\\left(  K\\right)  \\subseteq K\\left[  \\left[  T\\right]\r\n\\right]  $, we can write $q$ in the form $q=\\sum\\limits_{i\\geq0}q_{i}T^{i}$\r\nfor some sequence $\\left(  q_{0},q_{1},q_{2},...\\right)  $ of elements of $K$.\r\nConsider this $\\left(  q_{0},q_{1},q_{2},...\\right)  $. Then, $q_{0}$ is the\r\nconstant term of the power series $q$.\r\n\r\nSince $q\\in\\Lambda\\left(  K\\right)  =1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}=\\left\\{  p\\in K\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a\r\npower series with constant term }1\\right\\}  $, we know that $q$ is a power\r\nseries with constant term $1$. In other words, the constant term of the power\r\nseries $q$ is $1$. Since $q_{0}$ is the constant term of the power series $q$,\r\nthis yields that $q_{0}=1$.\r\n\r\nSince $\\Lambda\\left(  \\pi\\right)  $ is the restriction of $\\pi\\left[  \\left[\r\nT\\right]  \\right]  $ to the subset $\\Lambda\\left(  K\\right)  $ of $K\\left[\r\n\\left[  T\\right]  \\right]  $, we have\r\n\\begin{align*}\r\n\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  \\left(  q\\right)   &  =\\left(\r\n\\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  q\\right)  =\\left(\r\n\\pi\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  \\sum\\limits_{i\\geq\r\n0}q_{i}T^{i}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }q=\\sum\r\n\\limits_{i\\geq0}q_{i}T^{i}\\right) \\\\\r\n&  =\\sum\\limits_{i\\geq0}\\pi\\left(  q_{i}\\right)  T^{i}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of }\\pi\\left[  \\left[\r\nT\\right]  \\right]  \\right)  .\r\n\\end{align*}\r\nSince $\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  \\left(  q\\right)  =1$, this\r\nrewrites as $1=\\sum\\limits_{i\\geq0}\\pi\\left(  q_{i}\\right)  T^{i}$.\r\n\r\nNow, let $j$ be a positive integer. Then, the coefficient of $T^{j}$ on the\r\nleft hand side of the equality $1=\\sum\\limits_{i\\geq0}\\pi\\left(  q_{i}\\right)\r\nT^{i}$ is $0$, while the coefficient of $T^{j}$ on the right hand side of this\r\nequality is $\\pi\\left(  q_{j}\\right)  $. Since the coefficients of $T^{j}$ on\r\nthe two sides of an equality must always be equal, this yields that\r\n$0=\\pi\\left(  q_{j}\\right)  $. But $\\pi$ is the canonical projection\r\n$K\\rightarrow K\\diagup I$. Hence, since we have $\\pi\\left(  q_{j}\\right)  =0$,\r\nwe conclude that $q_{j}\\in I$.\r\n\r\nNow forget that we fixed $j$. We thus have shown that $q_{j}\\in I$ for every\r\npositive integer $j$. Thus, $\\sum\\limits_{j>0}q_{j}T^{j}\\in I\\left[  \\left[\r\nT\\right]  \\right]  $. Since $\\sum\\limits_{j>0}q_{j}T^{j}$ is a power series\r\nwith constant term $0$, we thus have%\r\n\\[\r\n\\sum\\limits_{j>0}q_{j}T^{j}\\in\\left\\{  p\\in I\\left[  \\left[  T\\right]\r\n\\right]  \\ \\mid\\ p\\text{ is a power series with constant term }0\\right\\}\r\n=TI\\left[  \\left[  T\\right]  \\right]  =I\\left[  \\left[  T\\right]  \\right]\r\n^{+}.\r\n\\]\r\nNow,%\r\n\\[\r\nq=\\sum\\limits_{i\\geq0}q_{i}T^{i}=\\sum\\limits_{j\\geq0}q_{j}T^{j}%\r\n=\\underbrace{q_{0}}_{=1}\\underbrace{T^{0}}_{=1}+\\underbrace{\\sum\r\n\\limits_{j>0}q_{j}T^{j}}_{\\in I\\left[  \\left[  T\\right]  \\right]  ^{+}}%\r\n\\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}.\r\n\\]\r\n\r\n\r\nNow forget that we fixed $q$. We thus have proven that every $q\\in\r\n\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $ satisfies\r\n$q\\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$. In other words,\r\n$\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  \\subseteq\r\n1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$. This completes the proof of the\r\n2nd step.\r\n\r\n\\textit{3rd step:} We have proven that $1+I\\left[  \\left[  T\\right]  \\right]\r\n^{+}\\subseteq\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $\r\nand $\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)\r\n\\subseteq1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$. Combining these two\r\nrelations, we obtain $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}%\r\n=\\operatorname*{Ker}\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $. This solves\r\nExercise 5.5 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We know that $\\Lambda\\left(  \\pi\\right)  $ is a $\\lambda$-ring\r\nhomomorphism (since $\\pi$ is a ring homomorphism). Thus, $\\operatorname*{Ker}%\r\n\\left(  \\Lambda\\left(  \\pi\\right)  \\right)  $ is a $\\lambda$-ideal of\r\n$\\Lambda\\left(  K\\right)  $ (by Theorem 2.3, applied to $\\Lambda\\left(\r\nK\\right)  $, $\\Lambda\\left(  K\\diagup I\\right)  $ and $\\Lambda\\left(\r\n\\pi\\right)  $ instead of $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $, $\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ and $f$). Since $\\operatorname*{Ker}\\left(  \\Lambda\\left(\r\n\\pi\\right)  \\right)  =1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$ (by Exercise\r\n5.5 \\textbf{(a)}), this yields that $1+I\\left[  \\left[  T\\right]  \\right]\r\n^{+}$ is a $\\lambda$-ideal of $\\Lambda\\left(  K\\right)  $. This solves\r\nExercise 5.5 \\textbf{(b)}.\r\n\r\n\\subsection{To Section 6}\r\n\r\n\\textit{Exercise 6.1: Hints to solution:} Recall that $\\widehat{-}$ denotes\r\nthe subtraction of the ring $\\Lambda\\left(  K\\right)  $ (that is, the binary\r\noperation on $\\Lambda\\left(  K\\right)  $ that undoes the addition\r\n$\\widehat{+}$). Then, $p\\widehat{-}q=\\dfrac{p}{q}$ for any $p\\in\\Lambda\\left(\r\nK\\right)  $ and $q\\in\\Lambda\\left(  K\\right)  $ (by the definition of the ring\r\nstructure on $\\Lambda\\left(  K\\right)  $).\r\n\r\nFor every two subsets $U$ and $U^{\\prime}$ of $\\Lambda\\left(  K\\right)  $, let\r\n$U\\widehat{-}U^{\\prime}$ denote the subset $\\left\\{  u\\widehat{-}u^{\\prime\r\n}\\mid u\\in U,\\ u^{\\prime}\\in U^{\\prime}\\right\\}  $ of $\\Lambda\\left(\r\nK\\right)  $. Now,%\r\n\\begin{align*}\r\n&  \\underbrace{\\left(  1+K\\left[  T\\right]  ^{+}\\right)  ^{-1}K\\left[\r\nT\\right]  }_{=\\left\\{  \\dfrac{p}{q}\\ \\mid\\ p\\in K\\left[  T\\right]\r\n,\\ q\\in1+K\\left[  T\\right]  ^{+}\\right\\}  }\\cap\\underbrace{\\Lambda\\left(\r\nK\\right)  }_{=1+K\\left[  \\left[  T\\right]  \\right]  ^{+}}\\\\\r\n&  =\\left\\{  \\dfrac{p}{q}\\ \\mid\\ p\\in K\\left[  T\\right]  ,\\ q\\in1+K\\left[\r\nT\\right]  ^{+}\\right\\}  \\cap\\left(  1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}\\right) \\\\\r\n&  =\\left\\{  \\dfrac{p}{q}\\ \\mid\\ p\\in K\\left[  T\\right]  ,\\ q\\in1+K\\left[\r\nT\\right]  ^{+},\\ \\dfrac{p}{q}\\in1+K\\left[  \\left[  T\\right]  \\right]\r\n^{+}\\right\\} \\\\\r\n&  =\\left\\{  \\underbrace{\\dfrac{p}{q}}_{=p\\widehat{-}q}\\ \\mid\\ p\\in1+K\\left[\r\nT\\right]  ^{+},\\ q\\in1+K\\left[  T\\right]  ^{+}\\right\\} \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because two polynomials }p\\in K\\left[  T\\right]  \\text{ and }%\r\nq\\in1+K\\left[  T\\right]  ^{+}\\\\\r\n\\text{satisfy }\\dfrac{p}{q}\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}\\text{\r\nif and only if }p\\in1+K\\left[  T\\right]  ^{+}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\left\\{  p\\widehat{-}q\\ \\mid\\ p\\in1+K\\left[  T\\right]  ^{+},\\ q\\in\r\n1+K\\left[  T\\right]  ^{+}\\right\\} \\\\\r\n&  =\\left(  1+K\\left[  T\\right]  ^{+}\\right)  \\widehat{-}\\left(  1+K\\left[\r\nT\\right]  ^{+}\\right)  .\r\n\\end{align*}\r\nThe subset $1+K\\left[  T\\right]  ^{+}$ of $\\Lambda\\left(  K\\right)  $ is\r\nclosed under the addition $\\widehat{+}$, the multiplication $\\widehat{\\cdot}$\r\nand the maps $\\widehat{\\lambda}^{i}$ (according to Theorem 5.3, since\r\n$1+K\\left[  T\\right]  ^{+}=\\Pi\\left(  K^{\\operatorname*{int}}\\right)  $) and\r\ncontains the zero $1$ and the unity $1+T$. Thus, by Exercise 2.2 (applied to\r\n$\\Lambda\\left(  K\\right)  $ and $1+K\\left[  T\\right]  ^{+}$ instead of $K$ and\r\n$L$), we see that $\\left(  1+K\\left[  T\\right]  ^{+}\\right)  \\widehat{-}%\r\n\\left(  1+K\\left[  T\\right]  ^{+}\\right)  $ is a sub-$\\lambda$-ring of\r\n$\\Lambda\\left(  K\\right)  $. In other words, $\\left(  1+K\\left[  T\\right]\r\n^{+}\\right)  ^{-1}K\\left[  T\\right]  \\cap\\Lambda\\left(  K\\right)  $ is a\r\nsub-$\\lambda$-ring of $\\Lambda\\left(  K\\right)  $ (since $\\left(  1+K\\left[\r\nT\\right]  ^{+}\\right)  ^{-1}K\\left[  T\\right]  \\cap\\Lambda\\left(  K\\right)\r\n=\\left(  1+K\\left[  T\\right]  ^{+}\\right)  \\widehat{-}\\left(  1+K\\left[\r\nT\\right]  ^{+}\\right)  $). This sub-$\\lambda$-ring is clearly special (since\r\n$\\Lambda\\left(  K\\right)  $ is special). This solves Exercise 6.1.\r\n\r\n\\textit{Exercise 6.2: Solution:} \\textbf{(a)} Consider the map $\\lambda_{T}$\r\ndefined in Theorem 2.1. Fix some $x\\in K$. Define a map $\\Upsilon\r\n:\\mathbb{Z}\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ by%\r\n\\[\r\n\\Upsilon\\left(  n\\right)  =\\lambda_{T}\\left(  nx\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{Z}\\text{.}%\r\n\\]\r\nThis map $\\Upsilon$ is a group homomorphism from the group $\\left(\r\n\\mathbb{Z},+\\right)  $ to the group $\\left(  K\\left[  \\left[  T\\right]\r\n\\right]  ^{\\times},\\cdot\\right)  $ (because every two elements $n$ and $m$ of\r\n$\\mathbb{Z}$ satisfy\r\n\\begin{align*}\r\n\\Upsilon\\left(  n\\right)  \\cdot\\Upsilon\\left(  m\\right)   &  =\\lambda\r\n_{T}\\left(  nx\\right)  \\cdot\\lambda_{T}\\left(  mx\\right)  =\\lambda_{T}\\left(\r\nnx+mx\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{according to the formula }\\lambda_{T}\\left(  x\\right)  \\cdot\\lambda\r\n_{T}\\left(  y\\right)  =\\lambda_{T}\\left(  x+y\\right) \\\\\r\n\\text{given in Theorem 2.1 \\textbf{(b)}}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\lambda_{T}\\left(  \\left(  n+m\\right)  x\\right)  =\\Upsilon\\left(\r\nn+m\\right)  ,\r\n\\end{align*}\r\nand we have $\\Upsilon\\left(  0\\right)  =\\lambda_{T}\\left(  0x\\right)\r\n=\\lambda_{T}\\left(  0\\right)  =1$ by Theorem 2.1 \\textbf{(b)}). Thus,\r\n$\\Upsilon\\left(  n\\cdot1\\right)  =\\left(  \\Upsilon\\left(  1\\right)  \\right)\r\n^{n}$ for every $n\\in\\mathbb{Z}$. Since $\\Upsilon\\left(  n\\cdot1\\right)\r\n=\\Upsilon\\left(  n\\right)  =\\lambda_{T}\\left(  nx\\right)  $ and $\\Upsilon\r\n\\left(  1\\right)  =\\lambda_{T}\\left(  1x\\right)  =\\lambda_{T}\\left(  x\\right)\r\n$, this rewrites as $\\lambda_{T}\\left(  nx\\right)  =\\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  ^{n}$. Applying this to $x=1_{K}$, we obtain%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  n\\cdot1\\right)   &  =\\left(  \\lambda_{T}\\left(  1\\right)\r\n\\right)  ^{n}=\\left(  1+T\\right)  ^{n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\lambda_{T}\\left(  1\\right)\r\n=1+T\\text{, because the }\\lambda\\text{-ring }K\\text{ is special}\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\dbinom{n}{i}T^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by the binomial formula}\\right)  .\r\n\\end{align*}\r\nComparing this with $\\lambda_{T}\\left(  n\\cdot1\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\lambda^{i}\\left(  n\\cdot1\\right)  T^{i}$, we conclude that\r\n$\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  n\\cdot1\\right)  T^{i}%\r\n=\\sum_{i\\in\\mathbb{N}}\\dbinom{n}{i}T^{i}$. Comparing coefficients, we obtain\r\n$\\lambda^{i}\\left(  n\\cdot1\\right)  =\\dbinom{n}{i}\\cdot1$ for every\r\n$i\\in\\mathbb{N}$.\r\n\r\n\\textbf{(b)} Assume, for the sake of contradiction, that $m=0$ in $K$ for some\r\npositive integer $m$. Then, Theorem 2.1 \\textbf{(a)} yields%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  m\\right)   &  =\\lambda_{T}\\left(  \\underbrace{1+1+...+1}%\r\n_{m\\text{ times}}\\right)  =\\underbrace{\\lambda_{T}\\left(  1\\right)\r\n\\cdot\\lambda_{T}\\left(  1\\right)  \\cdot...\\cdot\\lambda_{T}\\left(  1\\right)\r\n}_{m\\text{ times}}=\\left(  \\lambda_{T}\\left(  1\\right)  \\right)  ^{m}\\\\\r\n&  =\\left(  \\lambda_{T}\\left(  1\\right)  \\right)  ^{m}=\\left(  1+T\\right)\r\n^{m}=1+\\sum_{i=1}^{m-1}\\dbinom{m}{i}T^{i}+T^{m}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by the binomial formula}\\right)\r\n\\end{align*}\r\nin $K\\left[  \\left[  T\\right]  \\right]  $. On the other hand, $\\lambda\r\n_{T}\\left(  m\\right)  =\\lambda_{T}\\left(  0\\right)  =1$. Contradiction (unless\r\n$K$ is the trivial ring).\r\n\r\n\\textit{Exercise 6.3: Hints to solution:} Use Exercise 6.4 or the very\r\ndefinition of special $\\lambda$-rings together with Exercise 2.1. Do not\r\nforget to check that the map $\\lambda_{T}$ is well-defined.\r\n\r\n\\textit{Exercise 6.4: Hints to solution:} Repeat the proof of Theorem 6.1,\r\nreplacing every appearance of ``$x\\in K$'' by ``$x\\in E$'' and every\r\nappearance of ``$y\\in K$'' by ``$y\\in E$''. You need the fact that\r\n$\\lambda_{T}$ is a $\\lambda$-ring homomorphism if and only if it satisfies the\r\nthree conditions%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in\r\nE\\text{ and }y\\in E,\\\\\r\n\\lambda_{T}\\left(  1\\right)   &  =1+T,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}\\\\\r\n\\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)   &  =\\widehat{\\lambda\r\n}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\text{ and }x\\in E.\r\n\\end{align*}\r\nThis is because the first two of these conditions, together with the\r\npreassumptions that $E$ is a generating set of $K$ as a $\\mathbb{Z}$-module\r\nand that $\\lambda_{T}$ is an additive group homomorphism, are equivalent to\r\nclaiming that $\\lambda_{T}$ is a ring homomorphism; and the third condition\r\nthen makes $\\lambda_{T}$ a $\\lambda$-ring homomorphism (according to Exercise\r\n2.1 \\textbf{(b)}).\r\n\r\n\\textit{Exercise 6.5: Hints to solution:} First, the mapping\r\n$\\operatorname*{coeff}\\nolimits_{i}:\\Lambda\\left(  K\\right)  \\rightarrow K$ is\r\ncontinuous (with respect to the $\\left(  T\\right)  $-topology on\r\n$\\Lambda\\left(  K\\right)  $ and \\textit{any arbitrary topology} on $K$), and\r\nthe operation $\\widehat{\\lambda}^{i}$ is continuous as well (by Theorem 5.5\r\n\\textbf{(d)}); besides, the subset $1+K\\left[  T\\right]  ^{+}$ of $1+K\\left[\r\n\\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $ is dense (by\r\nTheorem 5.5 \\textbf{(a)}). Hence, in order to prove that\r\n$\\operatorname*{coeff}\\nolimits_{i}\\left(  u\\right)  =\\operatorname*{coeff}%\r\n\\nolimits_{1}\\left(  \\widehat{\\lambda}^{i}\\left(  u\\right)  \\right)  $ for\r\nevery $u\\in\\Lambda\\left(  K\\right)  $, it is enough to verify that\r\n$\\operatorname*{coeff}\\nolimits_{i}\\left(  u\\right)  =\\operatorname*{coeff}%\r\n\\nolimits_{1}\\left(  \\widehat{\\lambda}^{i}\\left(  u\\right)  \\right)  $ for\r\nevery $u\\in1+K\\left[  T\\right]  ^{+}$.\\ \\ \\ \\ \\footnote{At this point, we are\r\nslightly cheating: This argument works only if the topological space $K$ is\r\nHausdorff. Thus we are not completely free in choosing the topology on $K$.\r\nHowever, there are still enough Hausdorff topologies on $K$ (for example, the\r\ndiscrete topology) to choose from - the argument works if we take any of\r\nthem.} So let us assume that $u\\in1+K\\left[  T\\right]  ^{+}$. Then, there\r\nexist some $\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $. Consider this $\\left(\r\n\\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  $. Then,\r\n\\begin{align*}\r\nu  &  =\\Pi\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)\r\n=\\prod_{i=1}^{m}\\left(  1+u_{i}T\\right)  =\\sum_{i\\in\\mathbb{N}}\\left(\r\n\\sum_{\\substack{K\\subseteq\\left\\{  1,2,...,m\\right\\}  ;\\\\\\left\\vert\r\nK\\right\\vert =i}}\\prod\\limits_{k\\in K}u_{k}\\right)  \\cdot T^{i}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Exercise 4.2 \\textbf{(b)}, applied to\r\n}A=\\widetilde{K}\\left[  \\left[  T\\right]  \\right]  \\text{, }\\alpha_{i}%\r\n=u_{i}\\text{ and }t=T\\right) \\\\\r\n&  =\\sum_{i\\in\\mathbb{N}}\\left(  \\sum_{K\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }\\prod\\limits_{k\\in K}u_{k}\\right)  \\cdot T^{i}%\r\n\\end{align*}\r\nand therefore $\\operatorname*{coeff}\\nolimits_{i}u=\\sum\\limits_{K\\in\r\n\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\prod\r\n\\limits_{k\\in K}u_{k}$. On the other hand, Theorem 5.3 \\textbf{(d)} yields%\r\n\\begin{align*}\r\n\\widehat{\\lambda}^{i}\\left(  u\\right)   &  =\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  \\prod\\limits_{k\\in K}u_{k}\\ \\mid\\ K\\in\\mathcal{P}_{i}\\left(\r\n\\left\\{  1,2,...,m\\right\\}  \\right)  \\right]  \\right) \\\\\r\n&  =\\prod_{K\\in\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)\r\n}\\left(  1+\\prod\\limits_{k\\in K}u_{k}T\\right)  =1+\\sum_{K\\in\\mathcal{P}%\r\n_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\prod\\limits_{k\\in K}%\r\nu_{k}\\cdot T+\\left(  \\text{higher powers of }T\\right)  ,\r\n\\end{align*}\r\nso that%\r\n\\[\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  \\widehat{\\lambda}^{i}\\left(\r\nu\\right)  \\right)  =\\sum_{K\\in\\mathcal{P}_{i}\\left(  \\left\\{\r\n1,2,...,m\\right\\}  \\right)  }\\prod\\limits_{k\\in K}u_{k}.\r\n\\]\r\nComparing with $\\operatorname*{coeff}\\nolimits_{i}u=\\sum\\limits_{K\\in\r\n\\mathcal{P}_{i}\\left(  \\left\\{  1,2,...,m\\right\\}  \\right)  }\\prod\r\n\\limits_{k\\in K}u_{k}$, we get $\\operatorname*{coeff}\\nolimits_{i}\\left(\r\nu\\right)  =\\operatorname*{coeff}\\nolimits_{1}\\left(  \\widehat{\\lambda}%\r\n^{i}\\left(  u\\right)  \\right)  $, qed.\r\n\r\n\\textit{Exercise 6.6: Hints to solution:} Consider the maps $\\widehat{\\lambda\r\n}^{i}:\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(  K\\right)  $ that we\r\nhave defined in Section 5. Theorem 5.1 \\textbf{(b)} yields that $\\left(\r\n\\Lambda\\left(  K\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring. Since $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special $\\lambda$-ring,\r\nthe map $\\lambda_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ defined in Theorem\r\n5.6 is a $\\lambda$-ring homomorphism. Also, we know that the ring homomorphism\r\n$\\varphi:K\\rightarrow A$ induces a $\\lambda$-ring homomorphism $\\Lambda\\left(\r\n\\varphi\\right)  :\\Lambda\\left(  K\\right)  \\rightarrow\\Lambda\\left(  A\\right)\r\n$. Now, consider the composed $\\lambda$-ring homomorphism $\\Lambda\\left(\r\n\\varphi\\right)  \\circ\\lambda_{T}:K\\rightarrow\\Lambda\\left(  A\\right)  $.\r\n\r\n\\textit{1st Step:} We claim that $\\operatorname*{coeff}\\nolimits_{1}^{A}%\r\n\\circ\\Lambda\\left(  \\varphi\\right)  \\circ\\lambda_{T}=\\varphi$.\r\n\r\n\\textit{Proof.} Define a mapping $\\operatorname*{coeff}\\nolimits_{i}%\r\n:\\Lambda\\left(  K\\right)  \\rightarrow K$ for every $i\\in\\mathbb{N}$ as in\r\nExercise 6.5. Then, $\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\Lambda\\left(\r\n\\varphi\\right)  =\\varphi\\circ\\operatorname*{coeff}\\nolimits_{1}$ (by the\r\ndefinition of $\\Lambda\\left(  \\varphi\\right)  $) and $\\operatorname*{coeff}%\r\n\\nolimits_{1}\\circ\\lambda_{T}=\\operatorname*{id}_{K}$ (by Theorem 8.2). Thus,\r\n$\\underbrace{\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\Lambda\\left(\r\n\\varphi\\right)  }_{=\\varphi\\circ\\operatorname*{coeff}\\nolimits_{1}}%\r\n\\circ\\lambda_{T}=\\varphi\\circ\\underbrace{\\operatorname*{coeff}\\nolimits_{1}%\r\n\\circ\\lambda_{T}}_{=\\operatorname*{id}_{K}}=\\varphi$, and the 1st Step is proven.\r\n\r\n\\textit{2nd Step:} We claim that if $\\widetilde{\\varphi}:K\\rightarrow\r\n\\Lambda\\left(  A\\right)  $ is a $\\lambda$-ring homomorphism such that\r\n$\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\widetilde{\\varphi}=\\varphi$, then\r\n$\\widetilde{\\varphi}=\\Lambda\\left(  \\varphi\\right)  \\circ\\lambda_{T}$.\r\n\r\n\\textit{Proof.} For every $i\\in\\mathbb{N}$, define a mapping\r\n$\\operatorname*{coeff}\\nolimits_{i}^{A}:\\Lambda\\left(  A\\right)  \\rightarrow\r\nA$ by $\\operatorname*{coeff}\\nolimits_{i}^{A}\\left(  \\sum\\limits_{j\\in\r\n\\mathbb{N}}a_{j}T^{j}\\right)  =a_{i}$ for every $\\sum\\limits_{j\\in\\mathbb{N}%\r\n}a_{j}T^{j}\\in\\Lambda\\left(  A\\right)  $ (with $a_{j}\\in A$ for every\r\n$j\\in\\mathbb{N}$). (In other words, $\\operatorname*{coeff}\\nolimits_{i}^{A}$\r\nis the mapping that takes a power series and returns its coefficient before\r\n$T^{i}$.) Then, Exercise 6.5 (applied to the ring $A$ instead of $K$) yields\r\n$\\operatorname*{coeff}\\nolimits_{i}^{A}=\\operatorname*{coeff}\\nolimits_{1}%\r\n^{A}\\circ\\widehat{\\lambda}_{A}^{i}$. Hence,%\r\n\\[\r\n\\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\widetilde{\\varphi}%\r\n=\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\underbrace{\\widehat{\\lambda}%\r\n_{A}^{i}\\circ\\widetilde{\\varphi}}_{\\substack{=\\widetilde{\\varphi}\\circ\r\n\\lambda^{i},\\\\\\text{since }\\widetilde{\\varphi}\\text{ is a}\\\\\\lambda\r\n\\text{-ring}\\\\\\text{homomorphism}}}=\\underbrace{\\operatorname*{coeff}%\r\n\\nolimits_{1}^{A}\\circ\\widetilde{\\varphi}}_{=\\varphi}\\circ\\lambda^{i}%\r\n=\\varphi\\circ\\lambda^{i}.\r\n\\]\r\nBut on the other hand,%\r\n\\[\r\n\\underbrace{\\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\Lambda\\left(\r\n\\varphi\\right)  }_{\\substack{=\\varphi\\circ\\operatorname*{coeff}\\nolimits_{i}%\r\n\\text{ by the}\\\\\\text{definition of }\\Lambda\\left(  \\varphi\\right)  }%\r\n}\\circ\\lambda_{T}=\\varphi\\circ\\underbrace{\\operatorname*{coeff}\\nolimits_{i}%\r\n\\circ\\lambda_{T}}_{\\substack{=\\lambda^{i}\\text{, by the}\\\\\\text{definition of\r\n}\\lambda_{T}}}=\\varphi\\circ\\lambda^{i}.\r\n\\]\r\nTherefore, $\\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\widetilde{\\varphi\r\n}=\\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\Lambda\\left(  \\varphi\\right)\r\n\\circ\\lambda_{T}$ for every $i\\in\\mathbb{N}$. Thus, $\\left(\r\n\\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\widetilde{\\varphi}\\right)  \\left(\r\nu\\right)  =\\left(  \\operatorname*{coeff}\\nolimits_{i}^{A}\\circ\\Lambda\\left(\r\n\\varphi\\right)  \\circ\\lambda_{T}\\right)  \\left(  u\\right)  $ for every\r\n$i\\in\\mathbb{N}$ for every $u\\in K$. In other words, for every $u\\in K$ and\r\nfor every $i\\in\\mathbb{N}$, the power series $\\widetilde{\\varphi}\\left(\r\nu\\right)  \\in\\Lambda\\left(  A\\right)  $ and $\\left(  \\Lambda\\left(\r\n\\varphi\\right)  \\circ\\lambda_{T}\\right)  \\left(  u\\right)  $ have the same\r\ncoefficient before $T^{i}$. Since this holds for all $i\\in\\mathbb{N}$ at the\r\nsame time, this simply means that for every $u\\in K$, the power series\r\n$\\widetilde{\\varphi}\\left(  u\\right)  \\in\\Lambda\\left(  A\\right)  $ and\r\n$\\left(  \\Lambda\\left(  \\varphi\\right)  \\circ\\lambda_{T}\\right)  \\left(\r\nu\\right)  $ are equal. In other words, $\\widetilde{\\varphi}=\\Lambda\\left(\r\n\\varphi\\right)  \\circ\\lambda_{T}$, and thus the 2nd Step is proven.\r\n\r\nTogether, the 1st and the 2nd Steps yield the assertion of Exercise 6.6 (in\r\nfact, the 1st Step yields the existence of a $\\lambda$-ring homomorphism\r\n$\\widetilde{\\varphi}:K\\rightarrow\\Lambda\\left(  A\\right)  $ such that\r\n$\\operatorname*{coeff}\\nolimits_{1}^{A}\\circ\\widetilde{\\varphi}=\\varphi$,\r\nnamely the homomorphism $\\Lambda\\left(  \\varphi\\right)  \\circ\\lambda_{T}$, and\r\nthe 2nd Step proves that this is the only such homomorphism).\r\n\r\n\\textit{Exercise 6.7:} \\textit{Solution:} Let $t\\in I$. Since $S$ generates\r\nthe ideal $I$, there exists some $r\\in\\mathbb{N}$, some elements $s_{1}$,\r\n$s_{2}$, $...$, $s_{r}$ of $S$, and some elements $a_{1}$, $a_{2}$, $...$,\r\n$a_{r}$ of $K$ such that $t=\\sum\\limits_{j=1}^{r}a_{j}s_{j}$. Consider this\r\n$r$, these $s_{1}$, $s_{2}$, $...$, $s_{r}$ and these $a_{1}$, $a_{2}$, $...$,\r\n$a_{r}$.\r\n\r\nConsider the map $\\lambda_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ defined\r\nin Theorem 5.6. Since $K$ is a special $\\lambda$-ring, this map $\\lambda_{T}$\r\nis a $\\lambda$-ring homomorphism. In particular, $\\lambda_{T}$ is a ring homomorphism.\r\n\r\nConsider the set $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$ defined in\r\nExercise 5.5. By Exercise 5.5 \\textbf{(b)}, this set $1+I\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ is a $\\lambda$-ideal of $\\Lambda\\left(  K\\right)  $,\r\nthus also an ideal of $\\Lambda\\left(  K\\right)  $.\r\n\r\nNow, for every $j\\in\\left\\{  1,2,...,r\\right\\}  $, we have $\\lambda_{T}\\left(\r\ns_{j}\\right)  \\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$%\r\n.\\ \\ \\ \\ \\footnote{\\textit{Proof.} Let $j\\in\\left\\{  1,2,...,r\\right\\}  $. By\r\nthe definition of $\\lambda_{T}$, we have%\r\n\\[\r\n\\lambda_{T}\\left(  s_{j}\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda\r\n^{i}\\left(  s_{j}\\right)  T^{i}=\\underbrace{\\lambda^{0}\\left(  s_{j}\\right)\r\n}_{\\substack{=1\\\\\\text{(since }\\lambda^{0}\\left(  x\\right)  =1\\\\\\text{for\r\nevery }x\\in K\\text{)}}}\\underbrace{T^{0}}_{=1}+\\sum\\limits_{i>0}\\lambda\r\n^{i}\\left(  s_{j}\\right)  T^{i}=1+\\sum\\limits_{i>0}\\lambda^{i}\\left(\r\ns_{j}\\right)  T^{i}.\r\n\\]\r\n\\par\r\nNow, we have assumed that every $s\\in S$ and every positive integer $i$\r\nsatisfy $\\lambda^{i}\\left(  s\\right)  \\in I$. Applied to $s=s_{j}$, this\r\nyields that every positive integer $i$ satisfies $\\lambda^{i}\\left(\r\ns_{j}\\right)  \\in I$. Thus, $\\sum\\limits_{i>0}\\lambda^{i}\\left(  s_{j}\\right)\r\nT^{i}\\in I\\left[  \\left[  T\\right]  \\right]  $. Since $\\sum\\limits_{i>0}%\r\n\\lambda^{i}\\left(  s_{j}\\right)  T^{i}$ is a power series with constant term\r\n$0$, we thus have%\r\n\\[\r\n\\sum\\limits_{i>0}\\lambda^{i}\\left(  s_{j}\\right)  T^{i}\\in\\left\\{  p\\in\r\nI\\left[  \\left[  T\\right]  \\right]  \\ \\mid\\ p\\text{ is a power series with\r\nconstant term }0\\right\\}  =TI\\left[  \\left[  T\\right]  \\right]  =I\\left[\r\n\\left[  T\\right]  \\right]  ^{+}.\r\n\\]\r\nNow, $\\lambda_{T}\\left(  s_{j}\\right)  =1+\\underbrace{\\sum\\limits_{i>0}%\r\n\\lambda^{i}\\left(  s_{j}\\right)  T^{i}}_{\\in I\\left[  \\left[  T\\right]\r\n\\right]  ^{+}}\\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$, qed.} But since\r\n$t=\\sum\\limits_{j=1}^{r}a_{j}s_{j}$, we have%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  t\\right)   &  =\\lambda_{T}\\left(  \\sum\\limits_{j=1}%\r\n^{r}a_{j}s_{j}\\right)  =\\widehat{\\sum\\limits_{j=1}^{r}}\\lambda_{T}\\left(\r\na_{j}\\right)  \\widehat{\\cdot}\\underbrace{\\lambda_{T}\\left(  s_{j}\\right)\r\n}_{\\in1+I\\left[  \\left[  T\\right]  \\right]  ^{+}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\lambda_{T}:K\\rightarrow\r\n\\Lambda\\left(  K\\right)  \\text{ is a ring homomorphism}\\right) \\\\\r\n&  \\in\\widehat{\\sum\\limits_{j=1}^{r}}\\lambda_{T}\\left(  a_{j}\\right)\r\n\\widehat{\\cdot}\\left(  1+I\\left[  \\left[  T\\right]  \\right]  ^{+}\\right)\r\n\\subseteq1+I\\left[  \\left[  T\\right]  \\right]  ^{+}%\r\n\\end{align*}\r\n(since $1+I\\left[  \\left[  T\\right]  \\right]  ^{+}$ is an ideal of\r\n$\\Lambda\\left(  K\\right)  $). In other words, $\\lambda_{T}\\left(  t\\right)\r\n-1\\in I\\left[  \\left[  T\\right]  \\right]  ^{+}\\subseteq I\\left[  \\left[\r\nT\\right]  \\right]  $. Thus, $\\lambda_{T}\\left(  t\\right)  -1$ is a power\r\nseries with all its coefficients lying in $I$.\r\n\r\nBy the definition of $\\lambda_{T}$, we have $\\lambda_{T}\\left(  t\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  t\\right)  T^{i}$. Thus,\r\n$\\left(  \\text{the coefficient before }T^{i}\\text{ in }\\lambda_{T}\\left(\r\nt\\right)  \\right)  =\\lambda^{i}\\left(  t\\right)  $ for every $i\\in\\mathbb{N}$.\r\n\r\nNow, let $i$ be a positive integer. Then, $\\left(  \\text{the coefficient\r\nbefore }T^{i}\\text{ in }\\lambda_{T}\\left(  t\\right)  -1\\right)  \\in I$\r\n(because $\\lambda_{T}\\left(  t\\right)  -1$ is a power series with all its\r\ncoefficients lying in $I$). In view of%\r\n\\begin{align*}\r\n&  \\left(  \\text{the coefficient before }T^{i}\\text{ in }\\lambda_{T}\\left(\r\nt\\right)  -1\\right) \\\\\r\n&  =\\underbrace{\\left(  \\text{the coefficient before }T^{i}\\text{ in }%\r\n\\lambda_{T}\\left(  t\\right)  \\right)  }_{=\\lambda^{i}\\left(  t\\right)\r\n}-\\underbrace{\\left(  \\text{the coefficient before }T^{i}\\text{ in }1\\right)\r\n}_{\\substack{=0\\\\\\text{(since }i\\text{ is positive)}}}=\\lambda^{i}\\left(\r\nt\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $\\lambda^{i}\\left(  t\\right)  \\in I$.\r\n\r\nNow, forget that we fixed $t$ and $i$. We thus have proven that every $t\\in I$\r\nand every positive integer $i$ satisfy $\\lambda^{i}\\left(  t\\right)  \\in I$.\r\nBut due to the definition of a $\\lambda$-ideal, this means precisely that $I$\r\nis a $\\lambda$-ideal of $K$.\r\n\r\nThus, we have proven that $I$ is a $\\lambda$-ideal of $K$. Exercise 6.7 is solved.\r\n\r\n\\textit{Exercise 6.8: Detailed solution:} \\textbf{(a)} For every\r\n$i\\in\\mathbb{N}$, the map $\\operatorname*{Coeff}\\nolimits_{i}:K\\left[  \\left[\r\nT\\right]  \\right]  \\rightarrow K$ is a $K$-linear map (for obvious reasons).\r\nIn particular, $\\operatorname*{Coeff}\\nolimits_{0}$ is a $K$-linear map. Now\r\nlet us show that $\\operatorname*{Coeff}\\nolimits_{0}$ is a $K$-algebra homomorphism.\r\n\r\nThe unity of the ring $K\\left[  \\left[  T\\right]  \\right]  $ is $1$. Hence,\r\n$\\operatorname*{Coeff}\\nolimits_{0}$ sends the unity of the ring $K\\left[\r\n\\left[  T\\right]  \\right]  $ to $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n1\\right)  =1$, which is the unity of $K$.\r\n\r\nLet $\\varphi\\in K\\left[  \\left[  T\\right]  \\right]  $ and $\\psi\\in K\\left[\r\n\\left[  T\\right]  \\right]  $ be two power series. Then, by the definition of\r\nthe product of two power series, we have%\r\n\\begin{equation}\r\n\\operatorname*{Coeff}\\nolimits_{n}\\left(  \\varphi\\psi\\right)  =\\sum_{k=0}%\r\n^{n}\\operatorname*{Coeff}\\nolimits_{k}\\varphi\\cdot\\operatorname*{Coeff}%\r\n\\nolimits_{n-k}\\psi\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}\\text{.}\r\n\\label{10.1.sol.0}%\r\n\\end{equation}\r\nApplied to $n=0$, this yields%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\varphi\\psi\\right)  =\\sum_{k=0}%\r\n^{0}\\operatorname*{Coeff}\\nolimits_{k}\\varphi\\cdot\\operatorname*{Coeff}%\r\n\\nolimits_{0-k}\\psi=\\operatorname*{Coeff}\\nolimits_{0}\\varphi\\cdot\r\n\\operatorname*{Coeff}\\nolimits_{0}\\psi.\r\n\\]\r\nThis yields that $\\operatorname*{Coeff}\\nolimits_{0}$ is a $K$-algebra\r\nhomomorphism from $K\\left[  \\left[  T\\right]  \\right]  $ to $K$ (because we\r\nalso know that $\\operatorname*{Coeff}\\nolimits_{0}$ is a $K$-linear map and\r\nsends the unity of the ring $K\\left[  \\left[  T\\right]  \\right]  $ to the\r\nunity of $K$). Hence, $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\prod\\limits_{i=1}^{m}\\Phi_{i}\\right)  =\\prod\\limits_{i=1}^{m}%\r\n\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\Phi_{i}\\right)  $. This solves\r\nExercise 6.8 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Exercise 6.8 \\textbf{(a)} yields $\\operatorname*{Coeff}%\r\n\\nolimits_{0}\\left(  \\prod\\limits_{i=1}^{m}\\Phi_{i}\\right)  =\\prod\r\n\\limits_{i=1}^{m}\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\Phi_{i}\\right)  }_{=1}=\\prod\\limits_{i=1}^{m}1=1$.\r\n\r\nNow let us prove that every $\\mu\\in\\left\\{  0,1,...,m\\right\\}  $ satisfies%\r\n\\begin{equation}\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{\\mu}\\Phi\r\n_{i}\\right)  =\\sum\\limits_{i=1}^{\\mu}\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\Phi_{i}\\right)  . \\label{10.1.sol.1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{10.1.sol.1}).} We will prove (\\ref{10.1.sol.1}) by\r\ninduction over $\\mu$:\r\n\r\n\\textit{Induction base:} If $\\mu=0$, then $\\prod\\limits_{i=1}^{\\mu}\\Phi\r\n_{i}=\\left(  \\text{empty product}\\right)  =1$ and thus $\\operatorname*{Coeff}%\r\n\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{\\mu}\\Phi_{i}\\right)\r\n=\\operatorname*{Coeff}\\nolimits_{1}1=0$, which rewrites as\r\n$\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{\\mu}\\Phi\r\n_{i}\\right)  =\\sum\\limits_{i=1}^{\\mu}\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\Phi_{i}\\right)  $ (because for $\\mu=0$ we also have $\\sum\\limits_{i=1}^{\\mu\r\n}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{i}\\right)  =\\left(\r\n\\text{empty sum}\\right)  =0$). Thus, (\\ref{10.1.sol.1}) holds for $\\mu=0$. The\r\ninduction base is thus complete.\r\n\r\n\\textit{Induction step:} Let $M\\in\\left\\{  0,1,...,m-1\\right\\}  $ be such that\r\n(\\ref{10.1.sol.1}) holds for $\\mu=M$. We must prove that (\\ref{10.1.sol.1})\r\nholds for $\\mu=M+1$ as well.\r\n\r\nSince (\\ref{10.1.sol.1}) holds for $\\mu=M$, we have $\\operatorname*{Coeff}%\r\n\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{M}\\Phi_{i}\\right)  =\\sum\r\n\\limits_{i=1}^{M}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{i}\\right)  $.\r\nLet $\\varphi=\\prod\\limits_{i=1}^{M}\\Phi_{i}$ and $\\psi=\\Phi_{M+1}$. Then,\r\n$\\varphi\\psi=\\left(  \\prod\\limits_{i=1}^{M}\\Phi_{i}\\right)  \\Phi_{M+1}%\r\n=\\prod\\limits_{i=1}^{M+1}\\Phi_{i}$. Since $\\varphi=\\prod\\limits_{i=1}^{M}%\r\n\\Phi_{i}$, we have\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{0}\\varphi &  =\\operatorname*{Coeff}%\r\n\\nolimits_{0}\\left(  \\prod\\limits_{i=1}^{M}\\Phi_{i}\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{M}\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}%\r\n\\left(  \\Phi_{i}\\right)  }_{=1}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\operatorname*{Coeff}\\nolimits_{0}\\text{ is a }K\\text{-algebra homomorphism}%\r\n\\right) \\\\\r\n&  =\\prod\\limits_{i=1}^{M}1=1\r\n\\end{align*}\r\nand%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{1}\\varphi=\\operatorname*{Coeff}\\nolimits_{1}%\r\n\\left(  \\prod\\limits_{i=1}^{M}\\Phi_{i}\\right)  =\\sum\\limits_{i=1}%\r\n^{M}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{i}\\right)  .\r\n\\]\r\nSince $\\psi=\\Phi_{M+1}$, we have $\\operatorname*{Coeff}\\nolimits_{0}%\r\n\\psi=\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\Phi_{M+1}\\right)  =1$ (because\r\n$\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\Phi_{i}\\right)  =1$ for every\r\n$i\\in\\left\\{  1,2,...,m\\right\\}  $). On the other hand, (\\ref{10.1.sol.0})\r\n(applied to $n=1$) yields%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\varphi\\psi\\right)   &  =\\sum\r\n_{k=0}^{1}\\operatorname*{Coeff}\\nolimits_{k}\\varphi\\cdot\\operatorname*{Coeff}%\r\n\\nolimits_{1-k}\\psi=\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}\\varphi\r\n}_{=1}\\cdot\\operatorname*{Coeff}\\nolimits_{1}\\underbrace{\\psi}_{=\\Phi_{M+1}%\r\n}+\\underbrace{\\operatorname*{Coeff}\\nolimits_{1}\\varphi}_{=\\sum\\limits_{i=1}%\r\n^{M}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{i}\\right)  }%\r\n\\cdot\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}\\psi}_{=1}\\\\\r\n&  =1\\cdot\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{M+1}\\right)\r\n+\\sum\\limits_{i=1}^{M}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi\r\n_{i}\\right)  \\cdot1\\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{M+1}\\right)\r\n+\\sum\\limits_{i=1}^{M}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi\r\n_{i}\\right)  =\\sum\\limits_{i=1}^{M+1}\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\Phi_{i}\\right)  .\r\n\\end{align*}\r\nSince $\\varphi\\psi=\\prod\\limits_{i=1}^{M+1}\\Phi_{i}$, this rewrites as\r\n$\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\prod\\limits_{i=1}^{M+1}\\Phi\r\n_{i}\\right)  =\\sum\\limits_{i=1}^{M+1}\\operatorname*{Coeff}\\nolimits_{1}\\left(\r\n\\Phi_{i}\\right)  $. In other words, (\\ref{10.1.sol.1}) holds for $\\mu=M+1$.\r\nThis completes the induction step.\r\n\r\nWe have thus proven (\\ref{10.1.sol.1}) by induction. Applying\r\n(\\ref{10.1.sol.1}) to $\\mu=m$, we get $\\operatorname*{Coeff}\\nolimits_{1}%\r\n\\left(  \\prod\\limits_{i=1}^{m}\\Phi_{i}\\right)  =\\sum\\limits_{i=1}%\r\n^{m}\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\Phi_{i}\\right)  $. This\r\nconcludes the solution of Exercise 6.8 \\textbf{(b)}.\r\n\r\n\\textit{Exercise 6.9: Hints to solution:} Use the fact that $u\\widehat{+}%\r\nv=uv$, the definition of $\\widehat{\\cdot}$ and the fact that $P_{1}=\\alpha\r\n_{1}\\cdot\\beta_{1}$.\r\n\r\n\\textit{Detailed solution:} We need to prove that $\\operatorname*{coeff}%\r\n\\nolimits_{1}:\\Lambda\\left(  K\\right)  \\rightarrow K$ is a ring homomorphism.\r\nIn order to prove this, we must verify that%\r\n\\begin{align}\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  1\\right)   &  =0;\\label{sol.6.9.1}\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{+}v\\right)   &\r\n=\\operatorname*{coeff}\\nolimits_{1}u+\\operatorname*{coeff}\\nolimits_{1}%\r\nv\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\Lambda\\left(  K\\right)  \\text{ and\r\n}v\\in\\Lambda\\left(  K\\right)  ;\\label{sol.6.9.2}\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  1+T\\right)   &  =1;\\label{sol.6.9.3}%\r\n\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{\\cdot}v\\right)   &\r\n=\\operatorname*{coeff}\\nolimits_{1}u\\cdot\\operatorname*{coeff}\\nolimits_{1}%\r\nv\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\Lambda\\left(  K\\right)  \\text{ and\r\n}v\\in\\Lambda\\left(  K\\right)  . \\label{sol.6.9.4}%\r\n\\end{align}\r\nThe equations (\\ref{sol.6.9.1}) and (\\ref{sol.6.9.3}) are immediately obvious.\r\nIt thus remains to prove (\\ref{sol.6.9.2}) and (\\ref{sol.6.9.4}).\r\n\r\n\\textit{Proof of (\\ref{sol.6.9.2}):} For every $i\\in\\mathbb{N}$, we define a\r\nmapping $\\operatorname*{Coeff}\\nolimits_{i}:K\\left[  \\left[  T\\right]\r\n\\right]  \\rightarrow K$ as in Exercise 6.8. Then, clearly,%\r\n\\begin{equation}\r\n\\operatorname*{coeff}\\nolimits_{i}P=\\operatorname*{Coeff}\\nolimits_{i}%\r\nP\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }P\\in\\Lambda\\left(  K\\right)  \\text{ and\r\n}i\\in\\mathbb{N}. \\label{sol.6.9.2.pf.1}%\r\n\\end{equation}\r\n\r\n\r\nLet $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\\Lambda\\left(  K\\right)  $. The\r\ndefinition of the addition $\\widehat{+}$ yields $u\\widehat{+}v=uv$. Now,\r\n$u\\in\\Lambda\\left(  K\\right)  $, so that $u$ is a power series with constant\r\nterm $1$. Hence, $\\operatorname*{Coeff}\\nolimits_{0}u=1$. Similarly,\r\n$\\operatorname*{Coeff}\\nolimits_{0}v=1$. But the definition of the product of\r\ntwo power series yields%\r\n\\[\r\n\\operatorname*{Coeff}\\nolimits_{n}\\left(  uv\\right)  =\\sum_{k=0}%\r\n^{n}\\operatorname*{Coeff}\\nolimits_{k}u\\cdot\\operatorname*{Coeff}%\r\n\\nolimits_{n-k}v\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }n\\in\\mathbb{N}\\text{.}%\r\n\\]\r\nApplying this to $n=1$, we obtain%\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  uv\\right)   &  =\\sum_{k=0}%\r\n^{1}\\operatorname*{Coeff}\\nolimits_{k}u\\cdot\\operatorname*{Coeff}%\r\n\\nolimits_{1-k}v\\\\\r\n&  =\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}u}_{=1}\\cdot\r\n\\operatorname*{Coeff}\\nolimits_{1}v+\\operatorname*{Coeff}\\nolimits_{1}%\r\nu\\cdot\\underbrace{\\operatorname*{Coeff}\\nolimits_{0}v}_{=1}\\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}v+\\operatorname*{Coeff}\\nolimits_{1}%\r\nu=\\underbrace{\\operatorname*{Coeff}\\nolimits_{1}u}%\r\n_{\\substack{=\\operatorname*{coeff}\\nolimits_{1}u\\\\\\text{(by\r\n(\\ref{sol.6.9.2.pf.1}), applied}\\\\\\text{to }P=u\\text{ and }i=1\\text{)}%\r\n}}+\\underbrace{\\operatorname*{Coeff}\\nolimits_{1}v}%\r\n_{\\substack{=\\operatorname*{coeff}\\nolimits_{1}v\\\\\\text{(by\r\n(\\ref{sol.6.9.2.pf.1}), applied}\\\\\\text{to }P=v\\text{ and }i=1\\text{)}}}\\\\\r\n&  =\\operatorname*{coeff}\\nolimits_{1}u+\\operatorname*{coeff}\\nolimits_{1}v.\r\n\\end{align*}\r\nNow, (\\ref{sol.6.9.2.pf.1}) (applied to $P=uv$ and $i=1$) yields\r\n$\\operatorname*{coeff}\\nolimits_{1}\\left(  uv\\right)  =\\operatorname*{Coeff}%\r\n\\nolimits_{1}\\left(  uv\\right)  =\\operatorname*{coeff}\\nolimits_{1}%\r\nu+\\operatorname*{coeff}\\nolimits_{1}v$. Since $u\\widehat{+}v=uv$, this\r\nrewrites as $\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{+}v\\right)\r\n=\\operatorname*{coeff}\\nolimits_{1}u+\\operatorname*{coeff}\\nolimits_{1}v$.\r\nThis proves (\\ref{sol.6.9.2}).\r\n\r\n\\textit{Proof of (\\ref{sol.6.9.4}):} Theorem 4.3 \\textbf{(b)} (applied to\r\n$n=1$ and $m=1$) shows that%\r\n\\[\r\n\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1\\right\\}  \\times\\left\\{  1\\right\\}\r\n}\\left(  1+U_{i}V_{j}T\\right)  =\\sum_{k\\in\\mathbb{N}}P_{k}\\left(  X_{1}%\r\n,X_{2},\\ldots,X_{k},Y_{1},Y_{2},\\ldots,Y_{k}\\right)  T^{k}%\r\n\\]\r\nin the polynomial ring $\\left(  \\mathbb{Z}\\left[  U_{1},V_{1}\\right]  \\right)\r\n\\left[  T\\right]  $. Hence,%\r\n\\[\r\n\\sum_{k\\in\\mathbb{N}}P_{k}\\left(  X_{1},X_{2},\\ldots,X_{k},Y_{1},Y_{2}%\r\n,\\ldots,Y_{k}\\right)  T^{k}=\\prod_{\\left(  i,j\\right)  \\in\\left\\{  1\\right\\}\r\n\\times\\left\\{  1\\right\\}  }\\left(  1+U_{i}V_{j}T\\right)  =1+U_{1}V_{1}T.\r\n\\]\r\nComparing coefficients before $T^{1}$ on both sides of this equality, we\r\nobtain $P_{1}\\left(  X_{1},Y_{1}\\right)  =U_{1}V_{1}$. But we are working in\r\n$\\mathbb{Z}\\left[  U_{1},V_{1}\\right]  $; hence, $X_{1}=U_{1}$ and\r\n$Y_{1}=V_{1}$. Thus, $P_{1}\\left(  \\underbrace{X_{1}}_{=U_{1}}%\r\n,\\underbrace{Y_{1}}_{=V_{1}}\\right)  =P_{1}\\left(  U_{1},V_{1}\\right)  $, so\r\nthat $P_{1}\\left(  U_{1},V_{1}\\right)  =P_{1}\\left(  X_{1},Y_{1}\\right)\r\n=U_{1}V_{1}$. Since $U_{1}$ and $V_{1}$ are algebraically independent, this\r\nyields $P_{1}=\\alpha_{1}\\beta_{1}$.\r\n\r\nNow, write the formal power series $u\\in\\Lambda\\left(  K\\right)  \\subseteq\r\nK\\left[  \\left[  T\\right]  \\right]  $ in the form $u=\\sum_{i\\in\\mathbb{N}%\r\n}a_{i}T^{i}$ (with $a_{i}\\in K$). Hence, $\\operatorname*{coeff}\\nolimits_{1}%\r\nu=a_{1}$.\r\n\r\nAlso, write the formal power series $v\\in\\Lambda\\left(  K\\right)  \\subseteq\r\nK\\left[  \\left[  T\\right]  \\right]  $ in the form $v=\\sum_{i\\in\\mathbb{N}%\r\n}b_{i}T^{i}$ (with $b_{i}\\in K$). Thus, $\\operatorname*{coeff}\\nolimits_{1}%\r\nv=b_{1}$.\r\n\r\nFrom $u=\\sum_{i\\in\\mathbb{N}}a_{i}T^{i}$ and $v=\\sum_{i\\in\\mathbb{N}}%\r\nb_{i}T^{i}$, we obtain%\r\n\\begin{align*}\r\nu\\widehat{\\cdot}v  &  =\\left(  \\sum_{i\\in\\mathbb{N}}a_{i}T^{i}\\right)\r\n\\widehat{\\cdot}\\left(  \\sum_{i\\in\\mathbb{N}}b_{i}T^{i}\\right)  =\\sum\r\n_{k\\in\\mathbb{N}}P_{k}\\left(  a_{1},a_{2},...,a_{k},b_{1},b_{2},...,b_{k}%\r\n\\right)  T^{k}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the definition of the operation\r\n}\\widehat{\\cdot}\\right)  .\r\n\\end{align*}\r\nHence, $\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{\\cdot}v\\right)\r\n=P_{1}\\left(  a_{1},b_{1}\\right)  =a_{1}b_{1}$ (since $P_{1}=\\alpha_{1}%\r\n\\beta_{1}$). In view of $\\operatorname*{coeff}\\nolimits_{1}u=a_{1}$ and\r\n$\\operatorname*{coeff}\\nolimits_{1}v=b_{1}$, this rewrites as\r\n$\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{\\cdot}v\\right)\r\n=\\operatorname*{coeff}\\nolimits_{1}u\\cdot\\operatorname*{coeff}\\nolimits_{1}v$.\r\nThis proves (\\ref{sol.6.9.4}).\r\n\r\nNow, all of the equalities (\\ref{sol.6.9.1}), (\\ref{sol.6.9.2}),\r\n(\\ref{sol.6.9.3}) and (\\ref{sol.6.9.4}) are proven. This completes the\r\nsolution of Exercise 6.9.\r\n\r\n\\textit{Exercise 6.10: Solution:} \\textbf{(a)} Define a map $\\eta:A\\times\r\nB\\rightarrow C$ by%\r\n\\[\r\n\\left(  \\eta\\left(  a,b\\right)  =\\alpha\\left(  a\\right)  \\beta\\left(\r\nb\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times\r\nB\\right)  .\r\n\\]\r\nThis map $\\eta$ is $\\mathbb{Z}$-bilinear (since the maps $\\alpha$ and $\\beta$\r\nare $\\mathbb{Z}$-linear). Thus, the universal property of the tensor product\r\n$A\\otimes B$ shows that there exists a unique $\\mathbb{Z}$-module homomorphism\r\n$\\phi:A\\otimes B\\rightarrow C$ satisfying%\r\n\\[\r\n\\left(  \\phi\\left(  a\\otimes b\\right)  =\\eta\\left(  a,b\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times B\\right)\r\n.\r\n\\]\r\nSince $\\eta\\left(  a,b\\right)  =\\alpha\\left(  a\\right)  \\otimes\\beta\\left(\r\nb\\right)  $ for every $\\left(  a,b\\right)  \\in A\\times B$, this statement\r\nrewrites as follows: There exists a unique $\\mathbb{Z}$-module homomorphism\r\n$\\phi:A\\otimes B\\rightarrow C$ satisfying%\r\n\\[\r\n\\left(  \\phi\\left(  a\\otimes b\\right)  =\\alpha\\left(  a\\right)  \\beta\\left(\r\nb\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times\r\nB\\right)  .\r\n\\]\r\nThis solves Exercise 6.10 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{equation}\r\n\\phi\\left(  a\\otimes b\\right)  =\\alpha\\left(  a\\right)  \\beta\\left(  b\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times B\r\n\\label{sol.6.10.b.1}%\r\n\\end{equation}\r\n(according to the definition of $\\phi$). Applying this to $\\left(  a,b\\right)\r\n=\\left(  1,1\\right)  $, we obtain\r\n\\[\r\n\\phi\\left(  1\\otimes1\\right)  =\\underbrace{\\alpha\\left(  1\\right)\r\n}_{\\substack{=1\\\\\\text{(since }\\alpha\\text{ is a ring}\\\\\\text{homomorphism)}%\r\n}}\\underbrace{\\beta\\left(  1\\right)  }_{\\substack{=1\\\\\\text{(since }%\r\n\\beta\\text{ is a ring}\\\\\\text{homomorphism)}}}=1.\r\n\\]\r\nIn other words, the map $\\phi$ sends the unity $1\\otimes1$ of $A\\otimes B$ to\r\nthe unity $1$ of $C$.\r\n\r\nNext, we claim that\r\n\\begin{equation}\r\n\\phi\\left(  x\\right)  \\phi\\left(  y\\right)  =\\phi\\left(  xy\\right)\r\n\\label{sol.6.10.b.2}%\r\n\\end{equation}\r\nfor every $x\\in A\\otimes B$ and $y\\in A\\otimes B$.\r\n\r\n\\textit{Proof of (\\ref{sol.6.10.b.2}):} Let $x\\in A\\otimes B$ and $y\\in\r\nA\\otimes B$. We need to prove the equality (\\ref{sol.6.10.b.2}). Since this\r\nequality is $\\mathbb{Z}$-linear in each of $x$ and $y$, we can WLOG assume\r\nthat $x$ and $y$ are pure tensors (since the $\\mathbb{Z}$-module $A\\otimes B$\r\nis spanned by pure tensors). Assume this. Thus, $x=a\\otimes b$ and\r\n$y=a^{\\prime}\\otimes b^{\\prime}$ for some $\\left(  a,b\\right)  \\in A\\times B$\r\nand $\\left(  a^{\\prime},b^{\\prime}\\right)  \\in A\\times B$. Consider these\r\n$\\left(  a,b\\right)  $ and $\\left(  a^{\\prime},b^{\\prime}\\right)  $.\r\n\r\nMultiplying the equalities $x=a\\otimes b$ and $y=a^{\\prime}\\otimes b^{\\prime}%\r\n$, we obtain $xy=\\left(  a\\otimes b\\right)  \\left(  a^{\\prime}\\otimes\r\nb^{\\prime}\\right)  =aa^{\\prime}\\otimes bb^{\\prime}$. Applying the map $\\phi$\r\nto both sides of this equality, we find%\r\n\\begin{align*}\r\n\\phi\\left(  xy\\right)   &  =\\phi\\left(  aa^{\\prime}\\otimes bb^{\\prime}\\right)\r\n\\\\\r\n&  =\\underbrace{\\alpha\\left(  aa^{\\prime}\\right)  }_{\\substack{=\\alpha\\left(\r\na\\right)  \\alpha\\left(  a^{\\prime}\\right)  \\\\\\text{(since }\\alpha\\text{ is a\r\nring}\\\\\\text{homomorphism)}}}\\underbrace{\\beta\\left(  bb^{\\prime}\\right)\r\n}_{\\substack{=\\beta\\left(  b\\right)  \\beta\\left(  b^{\\prime}\\right)\r\n\\\\\\text{(since }\\beta\\text{ is a ring}\\\\\\text{homomorphism)}}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by (\\ref{sol.6.10.b.1}), applied to }\\left(  aa^{\\prime},bb^{\\prime\r\n}\\right) \\\\\r\n\\text{instead of }\\left(  a,b\\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\alpha\\left(  a\\right)  \\alpha\\left(  a^{\\prime}\\right)  \\beta\\left(\r\nb\\right)  \\beta\\left(  b^{\\prime}\\right)  =\\alpha\\left(  a\\right)\r\n\\beta\\left(  b\\right)  \\alpha\\left(  a^{\\prime}\\right)  \\beta\\left(\r\nb^{\\prime}\\right)  .\r\n\\end{align*}\r\nComparing this with%\r\n\\[\r\n\\phi\\left(  \\underbrace{x}_{=a\\otimes b}\\right)  \\phi\\left(  \\underbrace{y}%\r\n_{=a^{\\prime}\\otimes b^{\\prime}}\\right)  =\\underbrace{\\phi\\left(  a\\otimes\r\nb\\right)  }_{\\substack{=\\alpha\\left(  a\\right)  \\beta\\left(  b\\right)\r\n\\\\\\text{(by (\\ref{sol.6.10.b.1}))}}}\\underbrace{\\phi\\left(  a^{\\prime}\\otimes\r\nb^{\\prime}\\right)  }_{\\substack{=\\alpha\\left(  a^{\\prime}\\right)  \\beta\\left(\r\nb^{\\prime}\\right)  \\\\\\text{(by (\\ref{sol.6.10.b.1}), applied to}\\\\\\left(\r\na^{\\prime},b^{\\prime}\\right)  \\text{ instead of }\\left(  a,b\\right)  \\text{)}%\r\n}}=\\alpha\\left(  a\\right)  \\beta\\left(  b\\right)  \\alpha\\left(  a^{\\prime\r\n}\\right)  \\beta\\left(  b^{\\prime}\\right)  ,\r\n\\]\r\nwe obtain $\\phi\\left(  x\\right)  \\phi\\left(  y\\right)  =\\phi\\left(  xy\\right)\r\n$. Thus, (\\ref{sol.6.10.b.2}) is proven.\r\n\r\nNow, we know that the map $\\phi$ is $\\mathbb{Z}$-linear, sends the unity\r\n$1\\otimes1$ of $A\\otimes B$ to the unity $1$ of $C$, and satisfies\r\n(\\ref{sol.6.10.b.2}) for every $x\\in A\\otimes B$ and $y\\in A\\otimes B$. In\r\nother words, $\\phi$ is a $\\mathbb{Z}$-algebra homomorphism. In other words,\r\n$\\phi$ is a ring homomorphism.\r\n\r\nEvery $a\\in A$ satisfies%\r\n\\begin{align*}\r\n\\left(  \\phi\\circ\\iota_{1}\\right)  \\left(  a\\right)   &  =\\phi\\left(\r\n\\underbrace{\\iota_{1}\\left(  a\\right)  }_{\\substack{=a\\otimes1\\\\\\text{(by the\r\ndefinition of }\\iota_{1}\\text{)}}}\\right)  =\\phi\\left(  a\\otimes1\\right)\r\n=\\alpha\\left(  a\\right)  \\underbrace{\\beta\\left(  1\\right)  }%\r\n_{\\substack{=1\\\\\\text{(since }\\beta\\text{ is a ring}\\\\\\text{homomorphism)}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.6.10.b.1}), applied to\r\n}\\left(  a,1\\right)  \\text{ instead of }\\left(  a,b\\right)  \\right) \\\\\r\n&  =\\alpha\\left(  a\\right)  .\r\n\\end{align*}\r\nIn other words, $\\phi\\circ\\iota_{1}=\\alpha$. Similarly, $\\phi\\circ\\iota\r\n_{2}=\\beta$. This completes the solution of Exercise 6.10 \\textbf{(b)}.\r\n\r\n\\textit{Exercise 6.11: Solution:} The definition of $\\tau_{T}$ shows that\r\n$\\tau_{T}:A\\otimes B\\rightarrow\\Lambda\\left(  A\\otimes B\\right)  $ is a\r\n$\\mathbb{Z}$-module homomorphism satisfying%\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{l}%\r\n\\tau_{T}\\left(  a\\otimes b\\right)  =\\left(  \\Lambda\\left(  \\iota_{1}\\right)\r\n\\circ\\lambda_{T}\\right)  \\left(  a\\right)  \\widehat{\\cdot}\\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right) \\\\\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times B\r\n\\end{array}\r\n\\right)  . \\label{sol.6.11.tauT-def}%\r\n\\end{equation}\r\n\r\n\r\nFor every $i\\in\\mathbb{N}$ and every ring $K$, we define a mapping\r\n$\\operatorname*{coeff}\\nolimits_{i}:K\\left[  \\left[  T\\right]  \\right]\r\n\\rightarrow K$ as in Exercise 6.5. For every two rings $K$ and $L$, every ring\r\nhomomorphism $f:K\\rightarrow L$ and every $i\\in\\mathbb{N}$, we have%\r\n\\begin{equation}\r\n\\operatorname*{coeff}\\nolimits_{i}\\circ\\Lambda\\left(  f\\right)  =f\\circ\r\n\\operatorname*{coeff}\\nolimits_{i} \\label{sol.6.11.coeffLambda}%\r\n\\end{equation}\r\n\\footnote{In other words, the diagram%\r\n\\[%\r\n%TCIMACRO{\\TeXButton{functoriality of coeff}{\\xymatrix{\r\n%\\Lambda\\left(K\\right) \\ar[r]^{\\Lambda\\left(f\\right)} \\ar[d]_{\\operatorname\r\n%{coeff}_i} & \\Lambda\\left(L\\right) \\ar[d]^{\\operatorname{coeff}_i} \\\\\r\n%K \\ar[r]_{f} & L\r\n%}}}%\r\n%BeginExpansion\r\n\\xymatrix{\r\n\\Lambda\\left(K\\right) \\ar[r]^{\\Lambda\\left(f\\right)} \\ar[d]_{\\operatorname\r\n{coeff}_i} & \\Lambda\\left(L\\right) \\ar[d]^{\\operatorname{coeff}_i} \\\\\r\nK \\ar[r]_{f} & L\r\n}%\r\n%EndExpansion\r\n\\]\r\nis commutative.}. (This follows from the definition of $\\Lambda\\left(\r\nf\\right)  $.)\r\n\r\nFor every ring two rings $K$ and $L$, every ring homomorphism $f:K\\rightarrow\r\nL$ and every $P\\in\\Lambda\\left(  K\\right)  $, we have%\r\n\\begin{equation}\r\n\\left(  \\Lambda\\left(  f\\right)  \\right)  \\left(  P\\right)  =\\left(  f\\left[\r\n\\left[  T\\right]  \\right]  \\right)  \\left(  P\\right)  .\r\n\\label{sol.6.11.Lambda-restricts}%\r\n\\end{equation}\r\n(This follows from the fact that the definitions of the maps $\\Lambda\\left(\r\nf\\right)  $ and $f\\left[  \\left[  T\\right]  \\right]  $ are identical, except\r\nfor the different domains.)\r\n\r\nFor every $c\\in A\\otimes B$ and $i\\in\\mathbb{N}$, we have defined $\\tau\r\n^{i}\\left(  c\\right)  $ as the coefficient of the power series $\\tau\r\n_{T}\\left(  c\\right)  \\in\\Lambda\\left(  A\\otimes B\\right)  \\subseteq\\left(\r\nA\\otimes B\\right)  \\left[  \\left[  T\\right]  \\right]  $ before $T^{i}$. In\r\nother words, for every $c\\in A\\otimes B$ and $i\\in\\mathbb{N}$, we have\r\n\\begin{equation}\r\n\\tau^{i}\\left(  c\\right)  =\\operatorname*{coeff}\\nolimits_{i}\\left(  \\tau\r\n_{T}\\left(  c\\right)  \\right)  . \\label{sol.6.11.taui}%\r\n\\end{equation}\r\nThus,%\r\n\\begin{equation}\r\n\\tau^{i}=\\operatorname*{coeff}\\nolimits_{i}\\circ\\tau_{T}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for each }i\\in\\mathbb{N}\r\n\\label{sol.6.11.taui.compos}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.6.11.taui.compos}):} Let $i\\in\\mathbb{N}%\r\n$. Then, every $c\\in A\\otimes B$ satisfies%\r\n\\begin{align*}\r\n\\tau^{i}\\left(  c\\right)   &  =\\operatorname*{coeff}\\nolimits_{i}\\left(\r\n\\tau_{T}\\left(  c\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{sol.6.11.taui})}\\right) \\\\\r\n&  =\\left(  \\operatorname*{coeff}\\nolimits_{i}\\circ\\tau_{T}\\right)  \\left(\r\nc\\right)  .\r\n\\end{align*}\r\nIn other words, $\\tau^{i}=\\operatorname*{coeff}\\nolimits_{i}\\circ\\tau_{T}$.\r\nThis proves (\\ref{sol.6.11.taui.compos}).}.\r\n\r\nFor every $x\\in A\\otimes B$, we have%\r\n\\begin{equation}\r\n\\tau_{T}\\left(  x\\right)  =\\sum_{i\\in\\mathbb{N}}\\tau^{i}\\left(  x\\right)\r\nT^{i} \\label{sol.6.11.tauT}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.6.11.tauT}):} Let $x\\in A\\otimes B$.\r\nRecall that for every $c\\in A\\otimes B$ and $i\\in\\mathbb{N}$, the coefficient\r\nof the power series $\\tau_{T}\\left(  c\\right)  \\in\\Lambda\\left(  A\\otimes\r\nB\\right)  \\subseteq\\left(  A\\otimes B\\right)  \\left[  \\left[  T\\right]\r\n\\right]  $ before $T^{i}$ is $\\tau^{i}\\left(  c\\right)  $. Applying this to\r\n$c=x$, we conclude that for every $i\\in\\mathbb{N}$, the coefficient of the\r\npower series $\\tau_{T}\\left(  x\\right)  \\in\\Lambda\\left(  A\\otimes B\\right)\r\n\\subseteq\\left(  A\\otimes B\\right)  \\left[  \\left[  T\\right]  \\right]  $\r\nbefore $T^{i}$ is $\\tau^{i}\\left(  x\\right)  $. Hence, $\\tau_{T}\\left(\r\nx\\right)  =\\sum_{i\\in\\mathbb{N}}\\tau^{i}\\left(  x\\right)  T^{i}$. This proves\r\n(\\ref{sol.6.11.tauT}).}.\r\n\r\n\\textbf{(a)} We have\r\n\\begin{equation}\r\n\\tau^{0}\\left(  x\\right)  =1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in A\\otimes\r\nB \\label{sol.6.11.a.tau0}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.6.11.a.tau0}):} Let $x\\in A\\otimes B$.\r\nThen, $\\tau_{T}\\left(  x\\right)  \\in\\Lambda\\left(  A\\otimes B\\right)  $ (since\r\n$\\tau_{T}$ is a map $A\\otimes B\\rightarrow\\Lambda\\left(  A\\otimes B\\right)\r\n$). Hence, $\\tau_{T}\\left(  x\\right)  $ is a power series in $\\left(  A\\otimes\r\nB\\right)  \\left[  \\left[  T\\right]  \\right]  $ with constant term $1$ (since\r\n$\\Lambda\\left(  A\\otimes B\\right)  $ is the set of all such power series).\r\nHence, the constant term of $\\tau_{T}\\left(  x\\right)  $ is $1$. In other\r\nwords, $\\operatorname*{coeff}\\nolimits_{0}\\left(  \\tau_{T}\\left(  x\\right)\r\n\\right)  =1$. But (\\ref{sol.6.11.taui}) (applied to $c=x$ and $i=0$) yields\r\n$\\tau^{0}\\left(  x\\right)  =\\operatorname*{coeff}\\nolimits_{0}\\left(  \\tau\r\n_{T}\\left(  x\\right)  \\right)  =1$. This proves (\\ref{sol.6.11.a.tau0}).}.\r\nAlso,%\r\n\\begin{equation}\r\n\\tau^{1}\\left(  x\\right)  =x\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in A\\otimes\r\nB \\label{sol.6.11.a.tau1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{sol.6.11.a.tau1}):} We have $\\tau\r\n^{1}=\\operatorname*{coeff}\\nolimits_{1}\\circ\\tau_{T}$ (by\r\n(\\ref{sol.6.11.taui.compos}), applied to $i=1$).\r\n\\par\r\nExercise 6.5 (applied to $K=A\\otimes B$) shows that $\\operatorname*{coeff}%\r\n\\nolimits_{1}:\\Lambda\\left(  A\\otimes B\\right)  \\rightarrow A\\otimes B$ is a\r\nring homomorphism. Hence, $\\operatorname*{coeff}\\nolimits_{1}:\\Lambda\\left(\r\nA\\otimes B\\right)  \\rightarrow A\\otimes B$ is a $\\mathbb{Z}$-module\r\nhomomorphism. Thus, $\\operatorname*{coeff}\\nolimits_{1}\\circ\\tau_{T}:A\\otimes\r\nB\\rightarrow A\\otimes B$ is a $\\mathbb{Z}$-module homomorphism (since both\r\n$\\operatorname*{coeff}\\nolimits_{1}$ and $\\tau_{T}$ are $\\mathbb{Z}$-module\r\nhomomorphisms). In other words, $\\tau^{1}:A\\otimes B\\rightarrow A\\otimes B$ is\r\na $\\mathbb{Z}$-module homomorphism (since $\\tau^{1}=\\operatorname*{coeff}%\r\n\\nolimits_{1}\\circ\\tau_{T}$).\r\n\\par\r\nEvery $\\left(  a,b\\right)  \\in A\\times B$ satisfies%\r\n\\begin{align*}\r\n\\tau^{1}\\left(  a\\otimes b\\right)   &  =\\operatorname*{coeff}\\nolimits_{1}%\r\n\\left(  \\underbrace{\\tau_{T}\\left(  a\\otimes b\\right)  }_{\\substack{=\\left(\r\n\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)\r\n\\widehat{\\cdot}\\left(  \\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)\r\n\\left(  b\\right)  \\\\\\text{(by (\\ref{sol.6.11.tauT-def}))}}}\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by (\\ref{sol.6.11.taui}), applied to }c=a\\otimes b\\\\\r\n\\text{and }i=1\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{coeff}\\nolimits_{1}\\left(  \\left(  \\Lambda\\left(  \\iota\r\n_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)  \\widehat{\\cdot}\\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right)\r\n\\right) \\\\\r\n&  =\\underbrace{\\operatorname*{coeff}\\nolimits_{1}\\left(  \\left(\r\n\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)\r\n\\right)  }_{=\\left(  \\operatorname*{coeff}\\nolimits_{1}\\circ\\Lambda\\left(\r\n\\iota_{1}\\right)  \\right)  \\left(  \\lambda_{T}\\left(  a\\right)  \\right)\r\n}\\cdot\\underbrace{\\operatorname*{coeff}\\nolimits_{1}\\left(  \\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right)\r\n\\right)  }_{=\\left(  \\operatorname*{coeff}\\nolimits_{1}\\circ\\Lambda\\left(\r\n\\iota_{2}\\right)  \\right)  \\left(  \\mu_{T}\\left(  b\\right)  \\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{coeff}%\r\n\\nolimits_{1}:\\Lambda\\left(  A\\otimes B\\right)  \\rightarrow A\\otimes B\\text{\r\nis a ring homomorphism}\\right) \\\\\r\n&  =\\underbrace{\\left(  \\operatorname*{coeff}\\nolimits_{1}\\circ\\Lambda\\left(\r\n\\iota_{1}\\right)  \\right)  }_{\\substack{=\\iota_{1}\\circ\\operatorname*{coeff}%\r\n\\nolimits_{1}\\\\\\text{(by (\\ref{sol.6.11.coeffLambda}), applied to }K=A\\text{,\r\n}L=A\\otimes B\\text{,}\\\\f=\\iota_{1}\\text{ and }i=1\\text{)}}}\\left(  \\lambda\r\n_{T}\\left(  a\\right)  \\right)  \\cdot\\underbrace{\\left(  \\operatorname*{coeff}%\r\n\\nolimits_{1}\\circ\\Lambda\\left(  \\iota_{2}\\right)  \\right)  }%\r\n_{\\substack{=\\iota_{2}\\circ\\operatorname*{coeff}\\nolimits_{1}\\\\\\text{(by\r\n(\\ref{sol.6.11.coeffLambda}), applied to }K=B\\text{, }L=A\\otimes\r\nB\\text{,}\\\\f=\\iota_{2}\\text{ and }i=1\\text{)}}}\\left(  \\mu_{T}\\left(\r\nb\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  \\iota_{1}\\circ\\operatorname*{coeff}\\nolimits_{1}%\r\n\\right)  \\left(  \\lambda_{T}\\left(  a\\right)  \\right)  }_{=\\iota_{1}\\left(\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  \\lambda_{T}\\left(  a\\right)\r\n\\right)  \\right)  }\\cdot\\underbrace{\\left(  \\iota_{2}\\circ\r\n\\operatorname*{coeff}\\nolimits_{1}\\right)  \\left(  \\mu_{T}\\left(  b\\right)\r\n\\right)  }_{=\\iota_{2}\\left(  \\operatorname*{coeff}\\nolimits_{1}\\left(\r\n\\mu_{T}\\left(  b\\right)  \\right)  \\right)  }\\\\\r\n&  =\\iota_{1}\\left(  \\underbrace{\\operatorname*{coeff}\\nolimits_{1}\\left(\r\n\\lambda_{T}\\left(  a\\right)  \\right)  }_{\\substack{=\\lambda^{1}\\left(\r\na\\right)  \\\\\\text{(since }\\lambda_{T}\\left(  a\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\lambda^{i}\\left(  a\\right)  T^{i}\\\\\\text{(by the definition of\r\n}\\lambda_{T}\\text{))}}}\\right)  \\cdot\\iota_{2}\\left(\r\n\\underbrace{\\operatorname*{coeff}\\nolimits_{1}\\left(  \\mu_{T}\\left(  b\\right)\r\n\\right)  }_{\\substack{=\\mu^{1}\\left(  b\\right)  \\\\\\text{(since }\\mu_{T}\\left(\r\nb\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\mu^{i}\\left(  b\\right)  T^{i}%\r\n\\\\\\text{(by the definition of }\\mu_{T}\\text{))}}}\\right) \\\\\r\n&  =\\iota_{1}\\left(  \\underbrace{\\lambda^{1}\\left(  a\\right)  }%\r\n_{\\substack{=a\\\\\\text{(since }\\left(  A,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  \\\\\\text{is a }\\lambda\\text{-ring)}}}\\right)\r\n\\cdot\\iota_{2}\\left(  \\underbrace{\\mu^{1}\\left(  b\\right)  }%\r\n_{\\substack{=b\\\\\\text{(since }\\left(  B,\\left(  \\mu^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  \\\\\\text{is a }\\lambda\\text{-ring)}}}\\right)\r\n=\\underbrace{\\iota_{1}\\left(  a\\right)  }_{\\substack{=a\\otimes1\\\\\\text{(by the\r\ndefinition}\\\\\\text{of }\\iota_{1}\\text{)}}}\\cdot\\underbrace{\\iota_{2}\\left(\r\nb\\right)  }_{\\substack{=1\\otimes b\\\\\\text{(by the definition}\\\\\\text{of }%\r\n\\iota_{2}\\text{)}}}\\\\\r\n&  =\\left(  a\\otimes1\\right)  \\cdot\\left(  1\\otimes b\\right)  =a\\otimes\r\nb=\\operatorname*{id}\\left(  a\\otimes b\\right)  .\r\n\\end{align*}\r\nIn other words, the two maps $\\tau^{1}:A\\otimes B\\rightarrow A\\otimes B$ and\r\n$\\operatorname*{id}:A\\otimes B\\rightarrow A\\otimes B$ are equal to each other\r\non each pure tensor. Since these two maps are $\\mathbb{Z}$-module\r\nhomomorphisms, this entails that these two maps must be identical (because the\r\npure tensors span the $\\mathbb{Z}$-module $A\\otimes B$). In other words,\r\n$\\tau^{1}=\\operatorname*{id}$. In other words, $\\tau^{1}\\left(  x\\right)  =x$\r\nfor every $x\\in A\\otimes B$. This proves (\\ref{sol.6.11.a.tau1}).}. Thus,\r\nTheorem 2.1 \\textbf{(a)} (applied to $A\\otimes B$, $\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}$ and $\\tau_{T}$ instead of $K$, $\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}$ and $\\lambda_{T}$) shows that we have%\r\n\\begin{equation}\r\n\\tau_{T}\\left(  x\\right)  \\cdot\\tau_{T}\\left(  y\\right)  =\\tau_{T}\\left(\r\nx+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in A\\otimes B\\text{ and\r\n}y\\in A\\otimes B \\label{sol.6.11.a.additive}%\r\n\\end{equation}\r\nif and only if $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ is a $\\lambda$-ring. Thus, $\\left(  A\\otimes B,\\left(  \\tau\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring (because\r\n(\\ref{sol.6.11.a.additive}) holds\\footnote{\\textit{Proof of\r\n(\\ref{sol.6.11.a.additive}):} Let $x\\in A\\otimes B$ and $y\\in A\\otimes B$.\r\nRecall that the addition $\\widehat{+}$ of the ring $\\Lambda\\left(  A\\otimes\r\nB\\right)  $ is defined by the rule that $u\\widehat{+}v=uv$ for all\r\n$u\\in\\Lambda\\left(  A\\otimes B\\right)  $ and $v\\in\\Lambda\\left(  A\\otimes\r\nB\\right)  $. Applying this rule to $u=\\tau_{T}\\left(  x\\right)  $ and\r\n$v=\\tau_{T}\\left(  y\\right)  $, we obtain $\\tau_{T}\\left(  x\\right)\r\n\\widehat{+}\\tau_{T}\\left(  y\\right)  =\\tau_{T}\\left(  x\\right)  \\cdot\\tau\r\n_{T}\\left(  y\\right)  $. Thus,%\r\n\\[\r\n\\tau_{T}\\left(  x\\right)  \\cdot\\tau_{T}\\left(  y\\right)  =\\tau_{T}\\left(\r\nx\\right)  \\widehat{+}\\tau_{T}\\left(  y\\right)  =\\tau_{T}\\left(  x+y\\right)\r\n\\]\r\n(since the map $\\tau_{T}$ is a $\\mathbb{Z}$-module homomorphism). This proves\r\n(\\ref{sol.6.11.a.additive}).}). This solves Exercise 6.11 \\textbf{(a)}.\r\n\r\n\\textbf{(b)} Let $\\left(  C,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n$ be a \\textbf{special} $\\lambda$-ring. Let $\\alpha:\\left(  A,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  C,\\left(\r\n\\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\beta:\\left(  B,\\left(\r\n\\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  C,\\left(  \\nu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ be two $\\lambda$-ring homomorphisms.\r\nConsider the unique $\\mathbb{Z}$-module homomorphism $\\phi:A\\otimes\r\nB\\rightarrow C$ constructed in Exercise 6.10 \\textbf{(a)}. The definition of\r\n$\\phi$ shows that%\r\n\\begin{equation}\r\n\\left(  \\phi\\left(  a\\otimes b\\right)  =\\alpha\\left(  a\\right)  \\beta\\left(\r\nb\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }\\left(  a,b\\right)  \\in A\\times\r\nB\\right)  . \\label{sol.6.11.b.phi-def}%\r\n\\end{equation}\r\nMoreover, Exercise 6.10 \\textbf{(b)} shows that this $\\phi$ is a ring\r\nhomomorphism and satisfies $\\phi\\circ\\iota_{1}=\\alpha$ and $\\phi\\circ\\iota\r\n_{2}=\\beta$. Since $\\phi:A\\otimes B\\rightarrow C$ is a ring homomorphism, we\r\nsee that $\\Lambda\\left(  \\phi\\right)  :\\Lambda\\left(  A\\otimes B\\right)\r\n\\rightarrow\\Lambda\\left(  C\\right)  $ is a $\\lambda$-ring homomorphism and\r\ntherefore a ring homomorphism.\r\n\r\nSince $\\Lambda$ is a functor, we have $\\Lambda\\left(  \\phi\\right)\r\n\\circ\\Lambda\\left(  \\iota_{1}\\right)  =\\Lambda\\left(  \\underbrace{\\phi\r\n\\circ\\iota_{1}}_{=\\alpha}\\right)  =\\Lambda\\left(  \\alpha\\right)  $ and\r\n$\\Lambda\\left(  \\phi\\right)  \\circ\\Lambda\\left(  \\iota_{2}\\right)\r\n=\\Lambda\\left(  \\underbrace{\\phi\\circ\\iota_{2}}_{=\\beta}\\right)\r\n=\\Lambda\\left(  \\beta\\right)  $.\r\n\r\nDefine a map $\\nu_{T}:C\\rightarrow\\Lambda\\left(  C\\right)  $ by%\r\n\\[\r\n\\nu_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\nu^{i}\\left(  x\\right)\r\nT^{i}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in C.\r\n\\]\r\nNotice that $\\left(  C,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is\r\na special $\\lambda$-ring if and only if the map $\\nu_{T}:\\left(  C,\\left(\r\n\\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  \\Lambda\\left(\r\nC\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a $\\lambda$-ring homomorphism (by the definition of a \\textquotedblleft\r\nspecial $\\lambda$-ring\\textquotedblright). Thus, the map $\\nu_{T}:\\left(\r\nC,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  C\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism (since $\\left(\r\nC,\\left(  \\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special $\\lambda\r\n$-ring). In particular, $\\nu_{T}$ is a ring homomorphism, and thus is a\r\n$\\mathbb{Z}$-module homomorphism. Thus, all four maps $\\tau_{T}$, $\\phi$,\r\n$\\nu_{T}$ and $\\Lambda\\left(  \\phi\\right)  $ are $\\mathbb{Z}$-module\r\nhomomorphisms. Hence, the compositions $\\Lambda\\left(  \\phi\\right)  \\circ\r\n\\tau_{T}$ and $\\nu_{T}\\circ\\phi$ are $\\mathbb{Z}$-module homomorphisms as well.\r\n\r\nTheorem 2.1 \\textbf{(c)} (applied to $\\left(  A,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $, $\\lambda_{T}$, $\\left(  C,\\left(  \\nu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $, $\\nu_{T}$ and $\\alpha$ instead of $\\left(\r\nK,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\lambda_{T}$,\r\n$\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\mu_{T}$ and\r\n$f$) shows that $\\alpha$ is a $\\lambda$-ring homomorphism if and only if\r\n$\\nu_{T}\\circ\\alpha=\\alpha\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}%\r\n$. Since $\\alpha$ is a $\\lambda$-ring homomorphism, we therefore conclude that%\r\n\\begin{equation}\r\n\\nu_{T}\\circ\\alpha=\\alpha\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}.\r\n\\label{sol.6.11.b.alpha}%\r\n\\end{equation}\r\nSimilarly, using the fact that $\\beta$ is a $\\lambda$-ring homomorphism, we\r\ncan prove that%\r\n\\begin{equation}\r\n\\nu_{T}\\circ\\beta=\\beta\\left[  \\left[  T\\right]  \\right]  \\circ\\mu_{T}.\r\n\\label{sol.6.11.b.beta}%\r\n\\end{equation}\r\n\r\n\r\nNow, we shall prove that the diagram%\r\n\\begin{equation}%\r\n%TCIMACRO{\\TeXButton{main claim of (b)}{\\xymatrix{\r\n%A \\otimes B \\ar[r]^-{\\phi} \\ar[d]_{\\tau_T} & C \\ar[d]^{\\nu_T} \\\\\r\n%\\Lambda\\left(A \\otimes B\\right) \\ar[r]_-{\\Lambda\\left(\\phi\\right)}\r\n%& \\Lambda\\left(C\\right)\r\n%}} }%\r\n%BeginExpansion\r\n\\xymatrix{\r\nA \\otimes B \\ar[r]^-{\\phi} \\ar[d]_{\\tau_T} & C \\ar[d]^{\\nu_T} \\\\\r\n\\Lambda\\left(A \\otimes B\\right) \\ar[r]_-{\\Lambda\\left(\\phi\\right)}\r\n& \\Lambda\\left(C\\right)\r\n}\r\n%EndExpansion\r\n\\label{sol.6.11.b.diagram}%\r\n\\end{equation}\r\nis commutative.\r\n\r\nIndeed, every $\\left(  a,b\\right)  \\in A\\times B$ satisfies%\r\n\\begin{align*}\r\n&  \\left(  \\Lambda\\left(  \\phi\\right)  \\circ\\tau_{T}\\right)  \\left(  a\\otimes\r\nb\\right) \\\\\r\n&  =\\left(  \\Lambda\\left(  \\phi\\right)  \\right)  \\left(  \\underbrace{\\tau\r\n_{T}\\left(  a\\otimes b\\right)  }_{\\substack{=\\left(  \\Lambda\\left(  \\iota\r\n_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)  \\widehat{\\cdot}\\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right)\r\n\\\\\\text{(by (\\ref{sol.6.11.tauT-def}))}}}\\right) \\\\\r\n&  =\\left(  \\Lambda\\left(  \\phi\\right)  \\right)  \\left(  \\left(\r\n\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)\r\n\\widehat{\\cdot}\\left(  \\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)\r\n\\left(  b\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  \\Lambda\\left(  \\phi\\right)  \\right)  \\left(  \\left(\r\n\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)\r\n\\right)  }_{=\\left(  \\Lambda\\left(  \\phi\\right)  \\circ\\Lambda\\left(  \\iota\r\n_{1}\\right)  \\circ\\lambda_{T}\\right)  \\left(  a\\right)  }\\widehat{\\cdot\r\n}\\underbrace{\\left(  \\Lambda\\left(  \\phi\\right)  \\right)  \\left(  \\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right)\r\n\\right)  }_{=\\left(  \\Lambda\\left(  \\phi\\right)  \\circ\\Lambda\\left(  \\iota\r\n_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  b\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\Lambda\\left(  \\phi\\right)  \\text{\r\nis a ring homomorphism}\\right) \\\\\r\n&  =\\left(  \\underbrace{\\Lambda\\left(  \\phi\\right)  \\circ\\Lambda\\left(\r\n\\iota_{1}\\right)  }_{=\\Lambda\\left(  \\alpha\\right)  }\\circ\\lambda_{T}\\right)\r\n\\left(  a\\right)  \\widehat{\\cdot}\\left(  \\underbrace{\\Lambda\\left(\r\n\\phi\\right)  \\circ\\Lambda\\left(  \\iota_{2}\\right)  }_{=\\Lambda\\left(\r\n\\beta\\right)  }\\circ\\mu_{T}\\right)  \\left(  b\\right) \\\\\r\n&  =\\underbrace{\\left(  \\Lambda\\left(  \\alpha\\right)  \\circ\\lambda_{T}\\right)\r\n\\left(  a\\right)  }_{\\substack{=\\left(  \\Lambda\\left(  \\alpha\\right)  \\right)\r\n\\left(  \\lambda_{T}\\left(  a\\right)  \\right)  \\\\=\\left(  \\alpha\\left[  \\left[\r\nT\\right]  \\right]  \\right)  \\left(  \\lambda_{T}\\left(  a\\right)  \\right)\r\n\\\\\\text{(by (\\ref{sol.6.11.Lambda-restricts}), applied to}\\\\K=A\\text{,\r\n}L=C\\text{, }f=\\alpha\\text{ and }P=\\lambda_{T}\\left(  a\\right)  \\text{)}%\r\n}}\\widehat{\\cdot}\\underbrace{\\left(  \\Lambda\\left(  \\beta\\right)  \\circ\\mu\r\n_{T}\\right)  \\left(  b\\right)  }_{\\substack{=\\left(  \\Lambda\\left(\r\n\\beta\\right)  \\right)  \\left(  \\mu_{T}\\left(  b\\right)  \\right)  \\\\=\\left(\r\n\\beta\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(  \\mu_{T}\\left(\r\nb\\right)  \\right)  \\\\\\text{(by (\\ref{sol.6.11.Lambda-restricts}), applied\r\nto}\\\\K=B\\text{, }L=C\\text{, }f=\\beta\\text{ and }P=\\mu_{T}\\left(  b\\right)\r\n\\text{)}}}\\\\\r\n&  =\\underbrace{\\left(  \\alpha\\left[  \\left[  T\\right]  \\right]  \\right)\r\n\\left(  \\lambda_{T}\\left(  a\\right)  \\right)  }_{=\\left(  \\alpha\\left[\r\n\\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  a\\right)\r\n}\\widehat{\\cdot}\\underbrace{\\left(  \\beta\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\mu_{T}\\left(  b\\right)  \\right)  }_{=\\left(  \\beta\\left[\r\n\\left[  T\\right]  \\right]  \\circ\\mu_{T}\\right)  \\left(  b\\right)\r\n}=\\underbrace{\\left(  \\alpha\\left[  \\left[  T\\right]  \\right]  \\circ\r\n\\lambda_{T}\\right)  }_{\\substack{=\\nu_{T}\\circ\\alpha\\\\\\text{(by\r\n(\\ref{sol.6.11.b.alpha}))}}}\\left(  a\\right)  \\widehat{\\cdot}%\r\n\\underbrace{\\left(  \\beta\\left[  \\left[  T\\right]  \\right]  \\circ\\mu\r\n_{T}\\right)  }_{\\substack{=\\nu_{T}\\circ\\beta\\\\\\text{(by (\\ref{sol.6.11.b.beta}%\r\n))}}}\\left(  b\\right) \\\\\r\n&  =\\underbrace{\\left(  \\nu_{T}\\circ\\alpha\\right)  \\left(  a\\right)  }%\r\n_{=\\nu_{T}\\left(  \\alpha\\left(  a\\right)  \\right)  }\\widehat{\\cdot\r\n}\\underbrace{\\left(  \\nu_{T}\\circ\\beta\\right)  \\left(  b\\right)  }_{=\\nu\r\n_{T}\\left(  \\beta\\left(  b\\right)  \\right)  }=\\nu_{T}\\left(  \\alpha\\left(\r\na\\right)  \\right)  \\widehat{\\cdot}\\nu_{T}\\left(  \\beta\\left(  b\\right)\r\n\\right) \\\\\r\n&  =\\nu_{T}\\left(  \\underbrace{\\alpha\\left(  a\\right)  \\beta\\left(  b\\right)\r\n}_{\\substack{=\\phi\\left(  a\\otimes b\\right)  \\\\\\text{(by\r\n(\\ref{sol.6.11.b.phi-def}))}}}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since\r\n}\\nu_{T}:C\\rightarrow\\Lambda\\left(  C\\right)  \\text{ is a ring homomorphism}%\r\n\\right) \\\\\r\n&  =\\nu_{T}\\left(  \\phi\\left(  a\\otimes b\\right)  \\right)  =\\left(  \\nu\r\n_{T}\\circ\\phi\\right)  \\left(  a\\otimes b\\right)  .\r\n\\end{align*}\r\nIn other words, the two maps $\\Lambda\\left(  \\phi\\right)  \\circ\\tau_{T}$ and\r\n$\\nu_{T}\\circ\\phi$ are equal to each other on each pure tensor in $A\\otimes\r\nB$. Since these two maps are $\\mathbb{Z}$-module homomorphisms, this entails\r\nthat these two maps must be identical (since the $\\mathbb{Z}$-module $A\\otimes\r\nB$ is spanned by the pure tensors). In other words, $\\Lambda\\left(\r\n\\phi\\right)  \\circ\\tau_{T}=\\nu_{T}\\circ\\phi$. This proves that the diagram\r\n(\\ref{sol.6.11.b.diagram}) is commutative.\r\n\r\nFrom this, it is easy to see that%\r\n\\[\r\n\\nu_{T}\\circ\\phi=\\phi\\left[  \\left[  T\\right]  \\right]  \\circ\\tau_{T}%\r\n\\]\r\n\\footnote{\\textit{Proof.} Every $x\\in A\\otimes B$ satisfies%\r\n\\begin{align*}\r\n&  \\underbrace{\\left(  \\nu_{T}\\circ\\phi\\right)  }_{\\substack{=\\Lambda\\left(\r\n\\phi\\right)  \\circ\\tau_{T}\\\\\\text{(since the diagram}%\r\n\\\\\\text{(\\ref{sol.6.11.b.diagram}) is commutative)}}}\\left(  x\\right) \\\\\r\n&  =\\left(  \\Lambda\\left(  \\phi\\right)  \\circ\\tau_{T}\\right)  \\left(\r\nx\\right)  =\\left(  \\Lambda\\left(  \\phi\\right)  \\right)  \\left(  \\tau\r\n_{T}\\left(  x\\right)  \\right)  =\\left(  \\phi\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\tau_{T}\\left(  x\\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.6.11.Lambda-restricts}),\r\napplied to }K=A\\otimes B\\text{, }L=C\\text{, }f=\\phi\\text{ and }P=\\tau\r\n_{T}\\left(  x\\right)  \\right) \\\\\r\n&  =\\left(  \\phi\\left[  \\left[  T\\right]  \\right]  \\circ\\tau_{T}\\right)\r\n\\left(  x\\right)  .\r\n\\end{align*}\r\nHence, $\\nu_{T}\\circ\\phi=\\phi\\left[  \\left[  T\\right]  \\right]  \\circ\\tau_{T}%\r\n$, qed.}.\r\n\r\nNow, Theorem 2.1 \\textbf{(c)} (applied to $\\left(  A\\otimes B,\\left(  \\tau\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\tau_{T}$, $\\left(  C,\\left(\r\n\\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\nu_{T}$ and $\\phi$ instead of\r\n$\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $,\r\n$\\lambda_{T}$, $\\left(  L,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $,\r\n$\\mu_{T}$ and $f$) shows that $\\phi$ is a $\\lambda$-ring homomorphism if and\r\nonly if $\\nu_{T}\\circ\\phi=\\phi\\left[  \\left[  T\\right]  \\right]  \\circ\\tau\r\n_{T}$. Therefore, $\\phi$ is a $\\lambda$-ring homomorphism (since we have\r\n$\\nu_{T}\\circ\\phi=\\phi\\left[  \\left[  T\\right]  \\right]  \\circ\\tau_{T}$). This\r\nsolves Exercise 6.11 \\textbf{(b)}.\r\n\r\n\\textbf{(c)} Assume that the $\\lambda$-rings $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\left(  B,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ are special. Notice that $\\left(\r\nA,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special\r\n$\\lambda$-ring if and only if the map $\\lambda_{T}:\\left(  A,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  A\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism (by the definition of a\r\n\\textquotedblleft special $\\lambda$-ring\\textquotedblright). Thus, the map\r\n$\\lambda_{T}:\\left(  A,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  \\Lambda\\left(  A\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism\r\n(since $\\left(  A,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\nspecial $\\lambda$-ring). In particular, $\\lambda_{T}$ is a ring homomorphism.\r\nHence, $\\lambda_{T}$ sends the unity $1$ of the ring $A$ to the unity $1+T$ of\r\nthe ring $\\Lambda\\left(  A\\right)  $. In other words, $\\lambda_{T}\\left(\r\n1\\right)  =1+T$. Similarly, $\\mu_{T}\\left(  1\\right)  =1+T$ (because the\r\n$\\lambda$-ring $\\left(  B,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis special).\r\n\r\nBut $\\iota_{2}$ is a ring homomorphism, and thus $\\Lambda\\left(  \\iota\r\n_{2}\\right)  $ is a $\\lambda$-ring homomorphism. Hence, $\\Lambda\\left(\r\n\\iota_{2}\\right)  $ is a ring homomorphism. Thus, $\\Lambda\\left(  \\iota\r\n_{2}\\right)  $ sends the unity $1+T$ of the ring $\\Lambda\\left(  B\\right)  $\r\nto the unity $1+T$ of the ring $\\Lambda\\left(  A\\otimes B\\right)  $. In other\r\nwords, $\\left(  \\Lambda\\left(  \\iota_{2}\\right)  \\right)  \\left(  1+T\\right)\r\n=1+T$. Now,%\r\n\\begin{equation}\r\n\\left(  \\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(\r\n1\\right)  =\\left(  \\Lambda\\left(  \\iota_{2}\\right)  \\right)  \\left(\r\n\\underbrace{\\mu_{T}\\left(  1\\right)  }_{=1+T}\\right)  =\\left(  \\Lambda\\left(\r\n\\iota_{2}\\right)  \\right)  \\left(  1+T\\right)  =1+T. \\label{sol.6.11.c.1}%\r\n\\end{equation}\r\n\r\n\r\nNow, we claim that%\r\n\\begin{equation}\r\n\\tau_{T}\\circ\\iota_{1}=\\iota_{1}\\left[  \\left[  T\\right]  \\right]\r\n\\circ\\lambda_{T} \\label{sol.6.11.c.cl1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{Proof of (\\ref{sol.6.11.c.cl1}):} Let $a\\in A$. Then, $\\lambda\r\n_{T}\\left(  a\\right)  \\in\\Lambda\\left(  A\\right)  $. Hence,\r\n(\\ref{sol.6.11.Lambda-restricts}) (applied to $K=A$, $L=A\\otimes B$,\r\n$f=\\iota_{1}$ and $P=\\lambda_{T}\\left(  a\\right)  $) yields\r\n\\[\r\n\\left(  \\Lambda\\left(  \\iota_{1}\\right)  \\right)  \\left(  \\lambda_{T}\\left(\r\na\\right)  \\right)  =\\left(  \\iota_{1}\\left[  \\left[  T\\right]  \\right]\r\n\\right)  \\left(  \\lambda_{T}\\left(  a\\right)  \\right)  =\\left(  \\iota\r\n_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\na\\right)  .\r\n\\]\r\nBut the definition of $\\iota_{1}$ yields $\\iota_{1}\\left(  a\\right)\r\n=a\\otimes1$. Now,\r\n\\begin{align*}\r\n\\left(  \\tau_{T}\\circ\\iota_{1}\\right)  \\left(  a\\right)   &  =\\tau_{T}\\left(\r\n\\underbrace{\\iota_{1}\\left(  a\\right)  }_{=a\\otimes1}\\right)  =\\tau_{T}\\left(\r\na\\otimes1\\right)  =\\underbrace{\\left(  \\Lambda\\left(  \\iota_{1}\\right)\r\n\\circ\\lambda_{T}\\right)  \\left(  a\\right)  }_{\\substack{=\\left(\r\n\\Lambda\\left(  \\iota_{1}\\right)  \\right)  \\left(  \\lambda_{T}\\left(  a\\right)\r\n\\right)  \\\\=\\left(  \\iota_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\r\n\\lambda_{T}\\right)  \\left(  a\\right)  }}\\widehat{\\cdot}\\underbrace{\\left(\r\n\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}\\right)  \\left(  1\\right)\r\n}_{\\substack{=1+T\\\\\\text{(by (\\ref{sol.6.11.c.1}))}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.6.11.tauT-def}), applied to\r\n}\\left(  a,1\\right)  \\text{ instead of }\\left(  a,b\\right)  \\right) \\\\\r\n&  =\\left(  \\iota_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda\r\n_{T}\\right)  \\left(  a\\right)  \\widehat{\\cdot}\\left(  1+T\\right)  =\\left(\r\n\\iota_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(\r\na\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }1+T\\text{ is the unity of the ring\r\n}\\Lambda\\left(  A\\otimes B\\right)  \\right)  .\r\n\\end{align*}\r\n\r\n\r\nNow, forget that we fixed $a$. We thus have shown that $\\left(  \\tau_{T}%\r\n\\circ\\iota_{1}\\right)  \\left(  a\\right)  =\\left(  \\iota_{1}\\left[  \\left[\r\nT\\right]  \\right]  \\circ\\lambda_{T}\\right)  \\left(  a\\right)  $ for every\r\n$a\\in A$. In other words, $\\tau_{T}\\circ\\iota_{1}=\\iota_{1}\\left[  \\left[\r\nT\\right]  \\right]  \\circ\\lambda_{T}$. This proves (\\ref{sol.6.11.c.cl1}).\r\n\r\nNow, Theorem 2.1 \\textbf{(c)} (applied to $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\lambda_{T}$, $\\left(  A\\otimes\r\nB,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\tau_{T}$ and\r\n$\\iota_{1}$ instead of $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $, $\\lambda_{T}$, $\\left(  L,\\left(  \\mu^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $, $\\mu_{T}$ and $f$) shows that $\\iota_{1}$ is a\r\n$\\lambda$-ring homomorphism if and only if $\\tau_{T}\\circ\\iota_{1}=\\iota\r\n_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}$. Therefore,\r\n$\\iota_{1}$ is a $\\lambda$-ring homomorphism (since we have $\\tau_{T}%\r\n\\circ\\iota_{1}=\\iota_{1}\\left[  \\left[  T\\right]  \\right]  \\circ\\lambda_{T}$).\r\nSimilarly, $\\iota_{2}$ is a $\\lambda$-ring homomorphism. This solves Exercise\r\n6.11 \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Assume that the $\\lambda$-rings $\\left(  A,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ and $\\left(  B,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ are special. Notice that $\\left(\r\nA,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special\r\n$\\lambda$-ring if and only if the map $\\lambda_{T}:\\left(  A,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  A\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism (by the definition of a\r\n\\textquotedblleft special $\\lambda$-ring\\textquotedblright). Thus, the map\r\n$\\lambda_{T}:\\left(  A,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  \\Lambda\\left(  A\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism\r\n(since $\\left(  A,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\nspecial $\\lambda$-ring). Similarly, the map $\\mu_{T}:\\left(  B,\\left(  \\mu\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  \\Lambda\\left(\r\nB\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $\r\nis a $\\lambda$-ring homomorphism.\r\n\r\nThe map $\\iota_{1}:A\\rightarrow A\\otimes B$ is a ring homomorphism; thus, the\r\nmap $\\Lambda\\left(  \\iota_{1}\\right)  :\\left(  \\Lambda\\left(  A\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism.\r\nHence, $\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}:\\left(  A,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(\r\n\\Lambda\\left(  A\\otimes B\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism (being the\r\ncomposition of the two $\\lambda$-ring homomorphisms $\\lambda_{T}$ and\r\n$\\Lambda\\left(  \\iota_{1}\\right)  $). Similarly, $\\Lambda\\left(  \\iota\r\n_{2}\\right)  \\circ\\mu_{T}:\\left(  B,\\left(  \\mu^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  \\rightarrow\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring\r\nhomomorphism. Also, $\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special\r\n$\\lambda$-ring (by Theorem 6.2, applied to $K=A\\otimes B$). Therefore,\r\nExercise 6.11 \\textbf{(b)} (applied to $\\left(  \\Lambda\\left(  A\\otimes\r\nB\\right)  ,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $,\r\n$\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}$, $\\Lambda\\left(  \\iota\r\n_{2}\\right)  \\circ\\mu_{T}$ and $\\tau_{T}$ instead of $\\left(  C,\\left(\r\n\\nu^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $, $\\alpha$, $\\beta$ and $\\phi$)\r\nshows that the unique $\\mathbb{Z}$-module homomorphism $\\phi:A\\otimes\r\nB\\rightarrow\\Lambda\\left(  A\\otimes B\\right)  $ constructed in Exercise 6.10\r\n\\textbf{(a)} (applied to $C=\\Lambda\\left(  A\\otimes B\\right)  $,\r\n$\\alpha=\\Lambda\\left(  \\iota_{1}\\right)  \\circ\\lambda_{T}$ and $\\beta\r\n=\\Lambda\\left(  \\iota_{2}\\right)  \\circ\\mu_{T}$) is a $\\lambda$-ring\r\nhomomorphism $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  \\rightarrow\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(\r\n\\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $. Since this unique\r\n$\\mathbb{Z}$-module homomorphism $\\phi:A\\otimes B\\rightarrow\\Lambda\\left(\r\nA\\otimes B\\right)  $ is our map $\\tau_{T}$ (because this is how we defined\r\n$\\tau_{T}$), we can rewrite this as follows: The map $\\tau_{T}$ is a $\\lambda\r\n$-ring homomorphism $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  \\rightarrow\\left(  \\Lambda\\left(  A\\otimes B\\right)\r\n,\\left(  \\widehat{\\lambda}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $.\r\n\r\nBut the $\\lambda$-ring $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special if and only if the map $\\tau\r\n_{T}:\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)\r\n\\rightarrow\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(  \\widehat{\\lambda\r\n}^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism (by\r\nthe definition of a \\textquotedblleft special $\\lambda$-ring\\textquotedblright%\r\n). Thus, the $\\lambda$-ring $\\left(  A\\otimes B,\\left(  \\tau^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special (since the map $\\tau_{T}:\\left(\r\nA\\otimes B,\\left(  \\tau^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  \\rightarrow\r\n\\left(  \\Lambda\\left(  A\\otimes B\\right)  ,\\left(  \\widehat{\\lambda}%\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a $\\lambda$-ring homomorphism).\r\nThis solves Exercise 6.11 \\textbf{(d)}.\r\n\r\n\\subsection{To Section 7}\r\n\r\n\\textit{Exercise 7.1: Hints to solution:} See the more general Exercise 7.2.\r\n\r\n\\textit{Exercise 7.2: Hints to solution:} Repeat the argument used in the\r\nproof of Theorem 7.3.\r\n\r\n\\subsection{To Section 8}\r\n\r\n\\textit{Exercise 8.1: Solution:} We need to prove that $\\operatorname*{coeff}%\r\n\\nolimits_{1}:\\Lambda\\left(  K\\right)  \\rightarrow K$ is a ring homomorphism.\r\nIn order to prove this, we must verify that%\r\n\\begin{align}\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  1\\right)   &  =0;\\label{8.2.1}\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{+}v\\right)   &\r\n=\\operatorname*{coeff}\\nolimits_{1}u+\\operatorname*{coeff}\\nolimits_{1}%\r\nv\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\Lambda\\left(  K\\right)  \\text{ and\r\n}v\\in\\Lambda\\left(  K\\right)  ;\\label{8.2.2}\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  1+T\\right)   &  =1;\\label{8.2.3}\\\\\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{\\cdot}v\\right)   &\r\n=\\operatorname*{coeff}\\nolimits_{1}u\\cdot\\operatorname*{coeff}\\nolimits_{1}%\r\nv\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }u\\in\\Lambda\\left(  K\\right)  \\text{ and\r\n}v\\in\\Lambda\\left(  K\\right)  . \\label{8.2.4}%\r\n\\end{align}\r\nThe equations (\\ref{8.2.1}) and (\\ref{8.2.3}) are immediately obvious. In\r\norder to verify the equations (\\ref{8.2.2}) and (\\ref{8.2.4}), we notice that\r\n$\\operatorname*{coeff}\\nolimits_{1}:\\Lambda\\left(  K\\right)  \\rightarrow K$ is\r\na continuous mapping (with respect to the $\\left(  T\\right)  $-topology on\r\n$\\Lambda\\left(  K\\right)  $ and \\textit{any arbitrary topology} on $K$) and\r\nthe operations $\\widehat{+}$ and $\\widehat{\\cdot}$ are continuous as well (by\r\nTheorem 5.5 \\textbf{(d)}), and the subset $1+K\\left[  T\\right]  ^{+}$ of\r\n$1+K\\left[  \\left[  T\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\right)  $ is\r\ndense (by Theorem 5.5 \\textbf{(a)}), so it suffices to verify the equations\r\n(\\ref{8.2.2}) and (\\ref{8.2.4}) for $u\\in1+K\\left[  T\\right]  ^{+}$ and\r\n$v\\in1+K\\left[  T\\right]  ^{+}$ only.\\footnote{At this point, we are slightly\r\ncheating: This argument works only if the topological space $K$ is Hausdorff.\r\nThus we are not completely free in choosing the topology on $K$. However,\r\nthere are still enough Hausdorff topologies on $K$ (for example, the discrete\r\ntopology) to choose from - the argument works if we take any of them.} So let\r\n$u\\in1+K\\left[  T\\right]  ^{+}$ and $v\\in1+K\\left[  T\\right]  ^{+}$.\r\n\r\nThen, there exist some $\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2}%\r\n,...,u_{m}\\right]  \\right)  \\in K^{\\operatorname*{int}}$ such that\r\n$u=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)\r\n$, and some $\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]\r\n\\right)  \\in K^{\\operatorname*{int}}$ such that $v=\\Pi\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  $. Obviously,%\r\n\\[\r\nu=\\Pi\\left(  \\widetilde{K},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)\r\n=\\prod_{i=1}^{m}\\left(  1+u_{i}T\\right)  =1+\\sum_{i=1}^{m}u_{i}\\cdot T+\\left(\r\n\\text{higher powers of }T\\right)\r\n\\]\r\nyields $\\operatorname*{coeff}\\nolimits_{1}u=\\sum\\limits_{i=1}^{m}u_{i}$.\r\nSimilarly, $\\operatorname*{coeff}\\nolimits_{1}v=\\sum\\limits_{j=1}^{n}v_{j}$.\r\n\r\nBy Theorem 5.3 \\textbf{(a)}, there exists a finite-free extension ring\r\n$\\widetilde{K}_{u,v}$ of $K$ which contains both $\\widetilde{K}_{u}$ and\r\n$\\widetilde{K}_{v}$ as subrings. Theorem 5.3 \\textbf{(c)} yields%\r\n\\begin{align*}\r\nu\\widehat{\\cdot}v  &  =\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{i}v_{j}%\r\n\\mid\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right]  \\right)  =\\prod_{\\left(  i,j\\right)  \\in\\left\\{\r\n1,2,...,m\\right\\}  \\times\\left\\{  1,2,...,n\\right\\}  }\\left(  1+u_{i}%\r\nv_{j}T\\right) \\\\\r\n&  =1+\\sum_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }u_{i}v_{j}\\cdot T+\\left(  \\text{higher powers of\r\n}T\\right)  ,\r\n\\end{align*}\r\nand thus%\r\n\\[\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{\\cdot}v\\right)\r\n=\\sum_{\\left(  i,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  }u_{i}v_{j}=\\sum_{i=1}^{m}\\sum_{j=1}^{n}u_{i}%\r\nv_{j}=\\underbrace{\\sum_{i=1}^{m}u_{i}}_{=\\operatorname*{coeff}\\nolimits_{1}%\r\nu}\\underbrace{\\sum_{j=1}^{n}v_{j}}_{=\\operatorname*{coeff}\\nolimits_{1}%\r\nv}=\\operatorname*{coeff}\\nolimits_{1}u\\cdot\\operatorname*{coeff}%\r\n\\nolimits_{1}v,\r\n\\]\r\nso that (\\ref{8.2.4}) is proven.\r\n\r\nBesides,%\r\n\\begin{align*}\r\nu\\widehat{+}v  &  =uv=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1}%\r\n,u_{2},...,u_{m}\\right]  \\right)  \\cdot\\Pi\\left(  \\widetilde{K}_{v},\\left[\r\nv_{1},v_{2},...,v_{n}\\right]  \\right) \\\\\r\n&  =\\prod_{i=1}^{m}\\left(  1+u_{i}T\\right)  \\cdot\\prod_{j=1}^{n}\\left(\r\n1+v_{j}T\\right)  =1+\\left(  \\sum_{i=1}^{m}u_{i}+\\sum_{j=1}^{n}v_{j}\\right)\r\n\\cdot T+\\left(  \\text{higher powers of }T\\right)  ,\r\n\\end{align*}\r\nand consequently%\r\n\\[\r\n\\operatorname*{coeff}\\nolimits_{1}\\left(  u\\widehat{+}v\\right)\r\n=\\underbrace{\\sum_{i=1}^{m}u_{i}}_{=\\operatorname*{coeff}\\nolimits_{1}%\r\nu}+\\underbrace{\\sum_{j=1}^{n}v_{j}}_{=\\operatorname*{coeff}\\nolimits_{1}%\r\nv}=\\operatorname*{coeff}\\nolimits_{1}u+\\operatorname*{coeff}\\nolimits_{1}v,\r\n\\]\r\nand (\\ref{8.2.2}) is proven. Thus, $\\operatorname*{coeff}\\nolimits_{1}%\r\n:\\Lambda\\left(  K\\right)  \\rightarrow K$ is a ring homomorphism, and Exercise\r\n6.9 is solved again. Thus, Exercise 8.1 is solved.\r\n\r\n\\textit{Exercise 8.2: Hints to solution:} Let $y=x^{-1}$. We proceed as in the\r\nproof of Theorem 8.3 \\textbf{(b)}, except that we don't know that $\\lambda\r\n_{T}\\left(  y\\right)  =\\Pi\\left(  K,\\left[  y\\right]  \\right)  $ and thus\r\ncannot conclude anything from this. Instead, $xy=xx^{-1}=1$ yields%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  1\\right)\r\n=1+T\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\lambda_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  \\text{ is a ring\r\nhomomorphism,}\\\\\r\n\\text{and }1+T\\text{ is the multiplicative unity of }\\Lambda\\left(  K\\right)\r\n\\end{array}\r\n\\right) \\\\\r\n&  =1+xyT=\\Pi\\left(  K,\\left[  xy\\right]  \\right)  =\\Pi\\left(  K,\\left[\r\nx\\right]  \\right)  \\widehat{\\cdot}\\Pi\\left(  K,\\left[  y\\right]  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 5.3 \\textbf{(c)}}\\right) \\\\\r\n&  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot}\\left(  1+yT\\right)  .\r\n\\end{align*}\r\nTogether with $\\lambda_{T}\\left(  xy\\right)  =\\lambda_{T}\\left(  x\\right)\r\n\\widehat{\\cdot}\\lambda_{T}\\left(  y\\right)  $, this yields $\\lambda_{T}\\left(\r\nx\\right)  \\widehat{\\cdot}\\lambda_{T}\\left(  y\\right)  =\\lambda_{T}\\left(\r\nx\\right)  \\widehat{\\cdot}\\left(  1+yT\\right)  $, so that $\\lambda_{T}\\left(\r\ny\\right)  =1+yT$ (since $\\lambda_{T}\\left(  x\\right)  \\in\\Lambda\\left(\r\nK\\right)  $ is invertible, because $x\\in K$ is invertible and $\\lambda\r\n_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ is a ring homomorphism), and\r\nTheorem 8.3 \\textbf{(a)} yields that $y$ is $1$-dimensional, qed.\r\n\r\n\\textit{Exercise 8.3: Hints to solution:} We notice first that every $x\\in E$\r\nis $1$-dimensional (by the assumption on $E$). Thus, for every $x\\in E$, we\r\nhave $\\lambda_{T}\\left(  x\\right)  =1+xT$ (by Theorem 8.3 \\textbf{(a)}). Thus,\r\nfor every $x\\in E$, the element $\\lambda_{T}\\left(  x\\right)  $ of\r\n$\\Lambda\\left(  K\\right)  $ is $1$-dimensional (since Theorem 8.3 \\textbf{(c)}\r\nshows that the element $1+xT$ of $\\Lambda\\left(  K\\right)  $ is $1$%\r\n-dimensional). In other words, for every $x\\in E$, we have $\\widehat{\\lambda\r\n}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  =1$ for every integer $j>1$\r\n(since $1$ is the zero of the ring $\\Lambda\\left(  K\\right)  $). Hence, for\r\nevery $x\\in E$, we have%\r\n\\begin{equation}\r\n\\widehat{\\lambda}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n1+T,\\text{ if }j=0;\\\\\r\n\\lambda_{T}\\left(  x\\right)  ,\\text{ if }j=1;\\\\\r\n1,\\text{ if }j>1\r\n\\end{array}\r\n\\right.  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}.\r\n\\label{sol.8.3.1}%\r\n\\end{equation}\r\n\r\n\r\nOn the other hand, every $x\\in E$ is $1$-dimensional. In other words, every\r\n$x\\in E$ satisfies $\\lambda^{j}\\left(  x\\right)  =0$ for every integer $j>1$.\r\nHence, every $x\\in E$ satisfies%\r\n\\begin{equation}\r\n\\lambda^{j}\\left(  x\\right)  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n1,\\text{ if }j=0;\\\\\r\nx,\\text{ if }j=1;\\\\\r\n0,\\text{ if }j>1\r\n\\end{array}\r\n\\right.  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}.\r\n\\label{sol.8.3.2}%\r\n\\end{equation}\r\n\r\n\r\nWe want to show that the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)\r\n_{i\\in\\mathbb{N}}\\right)  $ is special. According to Exercise 6.4, we only\r\nhave to prove that (\\ref{LkxyE}) and (\\ref{LkLjxE}) hold. This is equivalent\r\nto showing that%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =\\lambda_{T}\\left(  x\\right)  \\widehat{\\cdot\r\n}\\lambda_{T}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }x\\in\r\nE\\text{ and }y\\in E,\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}\\\\\r\n\\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right)   &  =\\widehat{\\lambda\r\n}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{for every }j\\in\\mathbb{N}\\text{ and }x\\in E\r\n\\end{align*}\r\n(because of the definitions of $\\widehat{\\cdot}$ and $\\widehat{\\lambda}^{j}$\r\nand since two formal power series are equal if and only if their respective\r\ncoefficients are equal). But this is true, since%\r\n\\begin{align*}\r\n\\lambda_{T}\\left(  xy\\right)   &  =1+xyT\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }xy\\text{ is }1\\text{-dimensional (by Theorem 8.3 \\textbf{(b)}%\r\n)}\\right) \\\\\r\n&  =\\Pi\\left(  K,\\left[  xy\\right]  \\right)  =\\Pi\\left(  K,\\left[  x\\right]\r\n\\right)  \\widehat{\\cdot}\\Pi\\left(  K,\\left[  y\\right]  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 5.3 \\textbf{(c)}}\\right) \\\\\r\n&  =\\left(  1+xT\\right)  \\cdot\\left(  1+yT\\right)  =\\lambda_{T}\\left(\r\nx\\right)  \\widehat{\\cdot}\\lambda_{T}\\left(  y\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }x\\text{ and }y\\text{ are\r\n}1\\text{-dimensional}\\right)\r\n\\end{align*}\r\nfor every $x\\in E$ and $y\\in E$, and since%\r\n\\begin{align*}\r\n&  \\lambda_{T}\\left(  \\lambda^{j}\\left(  x\\right)  \\right) \\\\\r\n&  =\\lambda_{T}\\left(  \\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n1,\\text{ if }j=0;\\\\\r\nx,\\text{ if }j=1;\\\\\r\n0,\\text{ if }j>1\r\n\\end{array}\r\n\\right.  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.8.3.2}%\r\n)}\\right) \\\\\r\n&  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\lambda_{T}\\left(  1\\right)  ,\\text{ if }j=0;\\\\\r\n\\lambda_{T}\\left(  x\\right)  ,\\text{ if }j=1;\\\\\r\n\\lambda_{T}\\left(  0\\right)  ,\\text{ if }j>1\r\n\\end{array}\r\n\\right.  =\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n1+T,\\text{ if }j=0;\\\\\r\n\\lambda_{T}\\left(  x\\right)  ,\\text{ if }j=1;\\\\\r\n1,\\text{ if }j>1\r\n\\end{array}\r\n\\right.  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{since }\\lambda_{T}\\left(  1\\right)  =1+T\\\\\r\n\\text{and }\\lambda_{T}\\left(  0\\right)  =1\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\widehat{\\lambda}^{j}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{sol.8.3.1})}\\right)\r\n\\end{align*}\r\nfor every $j\\in\\mathbb{N}$ and $x\\in E$.\r\n\r\n\\subsection{To Section 9}\r\n\r\n\\textit{Exercise 9.1: Hints to solution:} As before, we use the $\\widehat{\\sum\r\n}$ sign for summation inside the ring $\\Lambda\\left(  K\\right)  $. We remember\r\nthat the addition inside the ring $\\Lambda\\left(  K\\right)  $ was defined by\r\n$u\\widehat{+}v=uv$ for any $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\r\n\\Lambda\\left(  K\\right)  $ (in other words, addition in $\\Lambda\\left(\r\nK\\right)  $ is the multiplication inherited from $K\\left[  \\left[  T\\right]\r\n\\right]  $), so that $\\widehat{\\sum}=\\prod$. Now,\r\n\\[\r\nu=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)\r\n=\\prod_{i=1}^{m}\\left(  1+u_{i}T\\right)  =\\widehat{\\sum_{i=1}^{m}}\\left(\r\n1+u_{i}T\\right)  .\r\n\\]\r\nBut since $1+u_{i}T$ is a $1$-dimensional element of $\\Lambda\\left(\r\n\\widetilde{K}_{u}\\right)  $ for every $i\\in\\left\\{  1,2,...,m\\right\\}  $ (by\r\nTheorem 8.3 \\textbf{(c)}), Theorem 9.4 (applied to $1+u_{i}T$ and\r\n$\\Lambda\\left(  \\widetilde{K}_{u}\\right)  $ instead of $u_{i}$ and $K$) yields%\r\n\\[\r\n\\widehat{\\psi}^{j}\\left(  \\widehat{\\sum_{i=1}^{m}}\\left(  1+u_{i}T\\right)\r\n\\right)  =\\widehat{\\sum_{i=1}^{m}}\\left(  1+u_{i}T\\right)  ^{\\widehat{j}},\r\n\\]\r\nwhere $\\left(  1+u_{i}T\\right)  ^{\\widehat{j}}$ means the $j$-th power of\r\n$1+u_{i}T$ \\textit{in the ring }$\\Lambda\\left(  \\widetilde{K}_{u}\\right)  $\r\n(in other words, $\\left(  1+u_{i}T\\right)  ^{\\widehat{j}}=\\underbrace{\\left(\r\n1+u_{i}T\\right)  \\widehat{\\cdot}\\left(  1+u_{i}T\\right)  \\widehat{\\cdot\r\n}...\\widehat{\\cdot}\\left(  1+u_{i}T\\right)  }_{j\\text{ times}}$, as opposed to\r\n\\newline$\\left(  1+u_{i}T\\right)  ^{j}=\\underbrace{\\left(  1+u_{i}T\\right)\r\n\\cdot\\left(  1+u_{i}T\\right)  \\cdot...\\cdot\\left(  1+u_{i}T\\right)  }_{j\\text{\r\ntimes}}$ which is the $j$-th power of $1+u_{i}T$ \\textit{in the ring\r\n}$\\widetilde{K}_{u}\\left[  \\left[  T\\right]  \\right]  $).\r\n\r\nHence,%\r\n\\begin{align*}\r\n\\widehat{\\psi}^{j}\\left(  u\\right)   &  =\\widehat{\\psi}^{j}\\left(\r\n\\widehat{\\sum_{i=1}^{m}}\\left(  1+u_{i}T\\right)  \\right)  =\\widehat{\\sum\r\n_{i=1}^{m}}\\left(  1+u_{i}T\\right)  ^{\\widehat{j}}=\\widehat{\\sum_{i=1}^{m}%\r\n}\\underbrace{\\left(  \\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{i}\\right]\r\n\\right)  \\right)  ^{\\widehat{j}}}_{\\substack{=\\Pi\\left(  \\widetilde{K}%\r\n_{u},\\left[  u_{i}^{j}\\right]  \\right)  \\text{ by}\\\\\\text{Corollary 5.4\r\n\\textbf{(b)}}}}=\\widehat{\\sum_{i=1}^{m}}\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\nu_{i}^{j}\\right]  \\right) \\\\\r\n&  =\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1}^{j},u_{2}^{j},...,u_{m}%\r\n^{j}\\right]  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Corollary 5.4\r\n\\textbf{(a)}}\\right)  .\r\n\\end{align*}\r\n\r\n\r\n\\textit{Exercise 9.2: Hints to solution:} \\textbf{(a)} It is easy to see that\r\nthe map sends the zero $1$ of $\\Lambda\\left(  K\\right)  $ to the zero $0$ of\r\n$K$ and the multiplicative unity $1+T$ of $\\Lambda\\left(  K\\right)  $ to the\r\nmultiplicative unity $1$ of $K$. So it only remains to prove that any two\r\npower series $u\\in\\Lambda\\left(  K\\right)  $ and $v\\in\\Lambda\\left(  K\\right)\r\n$ satisfy%\r\n\\begin{equation}\r\n\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log\\left(  u\\widehat{+}v\\right)  \\right)  =\\left(  -1\\right)\r\n^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n+\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log v\\right)  \\label{9.2.plus}%\r\n\\end{equation}\r\nand%\r\n\\begin{equation}\r\n\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log\\left(  u\\widehat{\\cdot}v\\right)  \\right)  =\\left(  -1\\right)\r\n^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n\\cdot\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log v\\right)  . \\label{9.2.times}%\r\n\\end{equation}\r\nThis needs to be verified for $u\\in1+K\\left[  T\\right]  ^{+}$ and\r\n$v\\in1+K\\left[  T\\right]  ^{+}$ only (since the operations $\\widehat{+}$ and\r\n$\\widehat{\\cdot}$ and the mapping%\r\n\\begin{align*}\r\n\\Lambda\\left(  K\\right)   &  \\rightarrow K,\\\\\r\nu  &  \\mapsto\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log u\\right)\r\n\\end{align*}\r\nare continuous (where the topology on $K$ can be chosen arbitrarily), and\r\n$1+K\\left[  T\\right]  ^{+}$ is a dense subset of $1+K\\left[  \\left[  T\\right]\r\n\\right]  ^{+}=\\Lambda\\left(  K\\right)  $)\\ \\ \\ \\ \\footnote{At this point, we\r\nare slightly cheating: This argument works only if the topological space $K$\r\nis Hausdorff. Thus we are not completely free in choosing the topology on $K$.\r\nHowever, there are still enough Hausdorff topologies on $K$ (for example, the\r\ndiscrete topology) to choose from, and the argument works if we take any of\r\nthem.}. So let us assume that $u\\in1+K\\left[  T\\right]  ^{+}$ and\r\n$v\\in1+K\\left[  T\\right]  ^{+}$. Then, there exists some $\\left(\r\n\\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)  \\in\r\nK^{\\operatorname*{int}}$ such that $u=\\Pi\\left(  \\widetilde{K}_{u},\\left[\r\nu_{1},u_{2},...,u_{m}\\right]  \\right)  $ and some $\\left(  \\widetilde{K}%\r\n_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)  \\in K^{\\operatorname*{int}%\r\n}$ such that $v=\\Pi\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2}%\r\n,...,v_{n}\\right]  \\right)  $. Then, Theorem 5.3 \\textbf{(c)} yields that%\r\n\\[\r\nu\\widehat{\\cdot}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{\\ell}v_{j}%\r\n\\mid\\left(  \\ell,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right]  \\right)\r\n\\]\r\n(here, we renamed the index $i$ as $\\ell$ in Theorem 5.3 \\textbf{(c)}, because\r\nwe are already using the label $i$ for a fixed element of $\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  $).\r\n\r\nNow,%\r\n\\[\r\nu=\\Pi\\left(  \\widetilde{K}_{u},\\left[  u_{1},u_{2},...,u_{m}\\right]  \\right)\r\n=\\prod_{k=1}^{m}\\left(  1+u_{k}T\\right)\r\n\\]\r\nentails%\r\n\\begin{align*}\r\n\\dfrac{d}{dT}u  &  =\\dfrac{d}{dT}\\prod_{k=1}^{m}\\left(  1+u_{k}T\\right) \\\\\r\n&  =\\sum_{\\tau=1}^{m}\\underbrace{\\prod_{k\\in\\left\\{  1,2,...,m\\right\\}\r\n\\setminus\\left\\{  \\tau\\right\\}  }\\left(  1+u_{k}T\\right)  }_{=\\dfrac\r\n{\\prod\\limits_{k=1}^{m}\\left(  1+u_{k}T\\right)  }{1+u_{\\tau}T}}\\cdot\r\n\\underbrace{\\dfrac{d}{dT}\\left(  1+u_{\\tau}T\\right)  }_{=u_{\\tau}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the Leibniz rule}\\right) \\\\\r\n&  =\\sum_{\\tau=1}^{m}\\left(  \\underbrace{\\prod\\limits_{k=1}^{m}\\left(\r\n1+u_{k}T\\right)  }_{=u}\\right)  \\cdot\\dfrac{u_{\\tau}}{1+u_{\\tau}T}=u\\sum\r\n_{\\tau=1}^{m}\\dfrac{u_{\\tau}}{1+u_{\\tau}T}%\r\n\\end{align*}\r\nand thus%\r\n\\begin{align*}\r\n&  -T\\dfrac{d}{dT}\\log u\\\\\r\n&  =-T\\dfrac{\\dfrac{d}{dT}u}{u}=-T\\dfrac{u\\sum\\limits_{\\tau=1}^{m}%\r\n\\dfrac{u_{\\tau}}{1+u_{\\tau}T}}{u}=-T\\sum\\limits_{\\tau=1}^{m}\\dfrac{u_{\\tau}%\r\n}{1+u_{\\tau}T}=\\sum\\limits_{\\tau=1}^{m}\\left(  -u_{\\tau}T\\right)  \\left(\r\n1+u_{\\tau}T\\right)  ^{-1}\\\\\r\n&  =\\sum\\limits_{\\tau=1}^{m}\\left(  -u_{\\tau}T\\right)  \\sum_{\\rho\\in\r\n\\mathbb{N}}\\left(  -1\\right)  ^{\\rho}\\left(  u_{\\tau}T\\right)  ^{\\rho}%\r\n=\\sum\\limits_{\\tau=1}^{m}\\sum_{\\rho\\in\\mathbb{N}}\\left(  -1\\right)  ^{\\rho\r\n+1}\\left(  u_{\\tau}T\\right)  ^{\\rho+1}=\\sum\\limits_{\\tau=1}^{m}\\sum\r\n_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(  -1\\right)  ^{i}\\left(\r\nu_{\\tau}T\\right)  ^{i}\\\\\r\n&  =\\sum\\limits_{\\tau=1}^{m}\\sum_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n}\\left(  -1\\right)  ^{i}u_{\\tau}^{i}T^{i}=\\sum_{i\\in\\mathbb{N}\\setminus\r\n\\left\\{  0\\right\\}  }\\left(  -1\\right)  ^{i}\\sum\\limits_{\\tau=1}^{m}u_{\\tau\r\n}^{i}T^{i},\r\n\\end{align*}\r\nso that $\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\r\nu\\right)  =\\left(  -1\\right)  ^{i}\\sum\\limits_{\\tau=1}^{m}u_{\\tau}^{i}$\r\n(because $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $). In other words,\r\n$\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log u\\right)  =\\sum\\limits_{\\tau=1}^{m}u_{\\tau}^{i}$. Similarly,\r\n$v=\\Pi\\left(  \\widetilde{K}_{v},\\left[  v_{1},v_{2},...,v_{n}\\right]  \\right)\r\n$ yields $\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log v\\right)  =\\sum\\limits_{\\sigma=1}^{n}v_{\\sigma}^{i}$, and\r\n$u\\widehat{\\cdot}v=\\Pi\\left(  \\widetilde{K}_{u,v},\\left[  u_{\\ell}v_{j}%\r\n\\mid\\left(  \\ell,j\\right)  \\in\\left\\{  1,2,...,m\\right\\}  \\times\\left\\{\r\n1,2,...,n\\right\\}  \\right]  \\right)  $ yields $\\left(  -1\\right)\r\n^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\\left(\r\nu\\widehat{\\cdot}v\\right)  \\right)  =\\sum\\limits_{\\tau=1}^{m}\\sum\r\n\\limits_{\\sigma=1}^{n}\\left(  u_{\\tau}v_{\\sigma}\\right)  ^{i}$. Thus,%\r\n\\begin{align*}\r\n\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log\\left(  u\\widehat{\\cdot}v\\right)  \\right)   &  =\\sum\\limits_{\\tau\r\n=1}^{m}\\sum\\limits_{\\sigma=1}^{n}\\left(  u_{\\tau}v_{\\sigma}\\right)  ^{i}%\r\n=\\sum\\limits_{\\tau=1}^{m}\\sum\\limits_{\\sigma=1}^{n}u_{\\tau}^{i}v_{\\sigma}%\r\n^{i}\\\\\r\n&  =\\underbrace{\\sum\\limits_{\\tau=1}^{m}u_{\\tau}^{i}}_{=\\left(  -1\\right)\r\n^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n}\\cdot\\underbrace{\\sum\\limits_{\\sigma=1}^{n}v_{\\sigma}^{i}}_{=\\left(\r\n-1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\r\nv\\right)  }\\\\\r\n&  =\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log u\\right)  \\cdot\\left(  -1\\right)  ^{i}%\r\n\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log v\\right)  ,\r\n\\end{align*}\r\nand (\\ref{9.2.times}) is thus proven. Similarly we can show (\\ref{9.2.plus}).\r\nThis completes the proof.\r\n\r\n\\textbf{(b)} Using Exercise 9.2 \\textbf{(a)}, we can easily prove the\r\nfollowing fact:\r\n\r\n\\textit{Assertion }$\\mathcal{F}$\\textit{:} If $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a special $\\lambda$-ring, then,\r\nfor any $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, the $i$-th Adams\r\noperation $\\psi^{i}:K\\rightarrow K$ is a ring homomorphism.\r\n\r\nThis assertion is a part of Theorem 9.3 \\textbf{(b)}.\r\n\r\nIn order to prove Assertion $\\mathcal{F}$ using Exercise 9.2 \\textbf{(a)}, we\r\nproceed as follows:\r\n\r\nEvery $x\\in K$ satisfies%\r\n\\[\r\n\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{i}\\left(\r\nx\\right)  T^{i}=\\widetilde{\\psi}_{T}\\left(  x\\right)  =-T\\dfrac{d}{dT}%\r\n\\log\\lambda_{-T}\\left(  x\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem\r\n9.2 \\textbf{(b)}}\\right)  ,\r\n\\]\r\nwhat (upon the substitution of $-T$ for $T$) becomes%\r\n\\[\r\n\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{i}\\left(\r\nx\\right)  \\left(  -T\\right)  ^{i}=-\\left(  -T\\right)  \\dfrac{d}{d\\left(\r\n-T\\right)  }\\log\\lambda_{-\\left(  -T\\right)  }\\left(  x\\right)  =-T\\dfrac\r\n{d}{dT}\\log\\lambda_{T}\\left(  x\\right)  ,\r\n\\]\r\nwhat rewrites as $\\sum\\limits_{i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n}\\left(  -1\\right)  ^{i}\\psi^{i}\\left(  x\\right)  T^{i}=-T\\dfrac{d}{dT}%\r\n\\log\\lambda_{T}\\left(  x\\right)  $. Hence, for every $x\\in K$ and\r\n$i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, we have $\\left(  -1\\right)\r\n^{i}\\psi^{i}\\left(  x\\right)  =\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log\\lambda_{T}\\left(  x\\right)  \\right)  $ and therefore\r\n$\\psi^{i}\\left(  x\\right)  =\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}%\r\n\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\\lambda_{T}\\left(  x\\right)  \\right)\r\n$.\r\n\r\nNow fix $i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. We have shown that\r\nevery $x\\in K$ satisfies\r\n\\[\r\n\\psi^{i}\\left(  x\\right)  =\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}%\r\n\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\\lambda_{T}\\left(  x\\right)  \\right)\r\n.\r\n\\]\r\nIn other words, the map $\\psi^{i}$ is the composition of the map $\\lambda\r\n_{T}:K\\rightarrow\\Lambda\\left(  K\\right)  $ (which is a ring homomorphism,\r\nsince the $\\lambda$-ring $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\r\n\\mathbb{N}}\\right)  $ is special) with the map%\r\n\\begin{align*}\r\n\\Lambda\\left(  K\\right)   &  \\rightarrow K,\\\\\r\nu  &  \\mapsto\\left(  -1\\right)  ^{i}\\operatorname*{Coeff}\\nolimits_{i}\\left(\r\n-T\\dfrac{d}{dT}\\log u\\right)\r\n\\end{align*}\r\n(which is a ring homomorphism according to Exercise 9.2 \\textbf{(a)}). Thus,\r\n$\\psi^{i}$ is a ring homomorphism (since the composition of two ring\r\nhomomorphisms is a ring homomorphism). This proves Assertion $\\mathcal{F}$.\r\n\r\n\\textit{Exercise 9.3: Hints to solution:} \\textbf{(a)} We have solved Exercise\r\n9.3 \\textbf{(a)} in the 2nd step of the proof of Theorem 9.5 (with the only\r\ndifference that the index of summation that was called $i$ in Exercise 9.3\r\n\\textbf{(a)} was denoted by $j$ in the 2nd step of the proof of Theorem 9.5).\r\n\r\n\\begin{comment}\r\nHere is an alternative solution of Exercise 9.3 \\textbf{(a)} that makes of use\r\nTheorem 9.5 \\textbf{(b)}. Of course, this solution is pretty much useless as\r\nlong as our proof of Theorem 9.5 \\textbf{(b)} includes a solution of Exercise\r\n9.3 \\textbf{(a)}, but if I should ever write up a different proof of Theorem\r\n9.5 \\textbf{(b)}, this solution might become useful once again.\r\nBut here is an alternative proof of Exercise 9.3 \\textbf{(a)} using Theorem 9.5:\r\nAccording to Theorem 9.5 \\textbf{(b)}, we have $\\widetilde{\\psi}_{T}\\left(\r\nx\\right)  =-T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)\r\n=-T\\cdot\\dfrac{\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)  }{\\lambda\r\n_{-T}\\left(  x\\right)  }$ for every $x\\in K$, where the map $\\widetilde{\\psi\r\n}_{T}:K\\rightarrow K\\left[  \\left[  T\\right]  \\right]  $ is defined by\r\n$\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}$ for every $x\\in\r\nK$. Here, $\\lambda_{-T}\\left(  x\\right)  $ denotes $\\operatorname*{ev}%\r\n_{-T}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  $. Therefore, if we denote\r\n$\\operatorname*{ev}_{-T}\\left(  \\widetilde{\\psi}_{T}\\left(  x\\right)  \\right)\r\n$ by $\\widetilde{\\psi}_{-T}\\left(  x\\right)  $, then we have%\r\n\\begin{align*}\r\n\\widetilde{\\psi}_{-T}\\left(  x\\right)   &  =\\operatorname*{ev}\\nolimits_{-T}%\r\n\\left(  \\widetilde{\\psi}_{T}\\left(  x\\right)  \\right)  =\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  -T\\cdot\\dfrac{\\dfrac{d}{dT}\\lambda_{-T}\\left(  x\\right)\r\n}{\\lambda_{-T}\\left(  x\\right)  }\\right) \\\\\r\n&  =-\\left(  -T\\right)  \\cdot\\dfrac{\\dfrac{d}{d\\left(  -T\\right)  }%\r\n\\lambda_{-\\left(  -T\\right)  }\\left(  x\\right)  }{\\lambda_{-\\left(  -T\\right)\r\n}\\left(  x\\right)  }=-T\\cdot\\dfrac{\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)\r\n}{\\lambda_{T}\\left(  x\\right)  }.\r\n\\end{align*}\r\nThus,%\r\n\\begin{equation}\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)\r\n=-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  . \\label{9.ex3.s1}%\r\n\\end{equation}\r\nNow, $\\widetilde{\\psi}_{T}\\left(  x\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}$ yields\r\n$\\widetilde{\\psi}_{-T}\\left(  x\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  \\left(  -T\\right)\r\n^{j}=\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\left(\r\n-1\\right)  ^{j}\\psi^{j}\\left(  x\\right)  T^{j}$. Together with $\\lambda\r\n_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(\r\nx\\right)  T^{i}$, this yields%\r\n\\[\r\n\\lambda_{T}\\left(  x\\right)  \\cdot\\widetilde{\\psi}_{-T}\\left(  x\\right)\r\n=\\sum_{n\\in\\mathbb{N}}\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j}\\psi^{j}\\left(\r\nx\\right)  \\lambda^{n-j}\\left(  x\\right)  T^{n}.\r\n\\]\r\nOn the other hand, $\\lambda_{T}\\left(  x\\right)  =\\sum\\limits_{i\\in\\mathbb{N}%\r\n}\\lambda^{i}\\left(  x\\right)  T^{i}=\\sum\\limits_{n\\in\\mathbb{N}}\\lambda\r\n^{n}\\left(  x\\right)  T^{n}$ yields $\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{n\\in\\mathbb{N}}n\\lambda^{n}\\left(  x\\right)  T^{n-1}$ and thus\r\n$-T\\cdot\\dfrac{d}{dT}\\lambda_{T}\\left(  x\\right)  =-\\sum\\limits_{n\\in\r\n\\mathbb{N}}n\\lambda^{n}\\left(  x\\right)  T^{n}$. Hence, (\\ref{9.ex3.s1})\r\nbecomes%\r\n\\[\r\n\\sum_{n\\in\\mathbb{N}}\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j}\\psi^{j}\\left(\r\nx\\right)  \\lambda^{n-j}\\left(  x\\right)  T^{n}=-\\sum\\limits_{n\\in\\mathbb{N}%\r\n}n\\lambda^{n}\\left(  x\\right)  T^{n}.\r\n\\]\r\nThus, for every $n\\in\\mathbb{N}$, we have%\r\n\\[\r\n\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j}\\psi^{j}\\left(  x\\right)  \\lambda\r\n^{n-j}\\left(  x\\right)  =-n\\lambda^{n}\\left(  x\\right)  .\r\n\\]\r\nDividing this by $-1$, this becomes%\r\n\\[\r\n\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\psi^{j}\\left(  x\\right)  \\lambda\r\n^{n-j}\\left(  x\\right)  =n\\lambda^{n}\\left(  x\\right)  ,\r\n\\]\r\nwhich rewrites as%\r\n\\[\r\nn\\lambda^{n}\\left(  x\\right)  =\\sum_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\psi\r\n^{j}\\left(  x\\right)  \\lambda^{n-j}\\left(  x\\right)  =\\sum_{i=1}^{n}\\left(\r\n-1\\right)  ^{i-1}\\psi^{i}\\left(  x\\right)  \\lambda^{n-i}\\left(  x\\right)  ,\r\n\\]\r\nwhich is exactly what Exercise 9.3 \\textbf{(a)} claimed.\r\n\\end{comment}\r\n\r\n\r\n\\textbf{(b)} We will prove the equation $n!\\lambda^{n}\\left(  x\\right)  =\\det\r\nA_{n}$ by induction over $n$.\r\n\r\nThe base case, $n=0$, is trivial (for $0!=1$, $\\lambda^{0}\\left(  x\\right)\r\n=1$, and the determinant of a $0\\times0$ matrix is $1$ by definition). If you\r\ndo not believe in $0\\times0$ matrices, the $n=1$ case is trivial as well\r\n(since $\\lambda^{1}\\left(  x\\right)  =x$ and $\\psi^{1}\\left(  x\\right)  =x$ by\r\nTheorem 9.3 \\textbf{(a)}\\footnote{Here we are using the fact that Theorem 9.3\r\n\\textbf{(a)} holds for every $\\lambda$-ring $\\left(  K,\\left(  \\lambda\r\n^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ (not only for special ones). This is\r\nvery easy to see (but not really necessary because, as I said, we can just as\r\nwell take $n=0$ for the base case).}) and can equally serve as a base case.\r\nThe interesting part is the induction step.\r\n\r\nFor this step, we develop the determinant of the matrix $A_{n}$ along the\r\n$n$-th row. We obtain%\r\n\\begin{equation}\r\n\\det A_{n}=\\sum_{k=1}^{n}\\left(  -1\\right)  ^{n-k}\\psi^{n-k+1}\\left(\r\nx\\right)  \\cdot\\det\\left(  A_{n}\\left[  \\dfrac{\\sim k}{\\sim n}\\right]\r\n\\right)  , \\label{9.ex3.s2}%\r\n\\end{equation}\r\nwhere $A_{n}\\left[  \\dfrac{\\sim k}{\\sim n}\\right]  $ is the matrix obtained\r\nfrom $A_{n}$ by removing the $n$-th row and the $k$-th column.\r\n\r\nNow, the matrix $A_{n}\\left[  \\dfrac{\\sim k}{\\sim n}\\right]  $ turns out to be\r\na block-triangular matrix\\footnote{Here, when I say \\textquotedblleft\r\nblock-triangular matrix\\textquotedblright, I always mean a block-triangular\r\nmatrix whose diagonal blocks are square matrices.} (composed of four blocks),\r\nwith the left upper block (of size $\\left(  k-1\\right)  \\times\\left(\r\nk-1\\right)  $) being equal to $A_{k-1}$ and the right lower block (of size\r\n$\\left(  n-k\\right)  \\times\\left(  n-k\\right)  $) being a lower triangular\r\nmatrix with the numbers $k$, $k+1$, $...$, $n-1$ on its diagonal. Hence,\r\n$\\det\\left(  A_{n}\\left[  \\dfrac{\\sim k}{\\sim n}\\right]  \\right)  =\\det\r\nA_{k-1}\\cdot\\left(  k\\left(  k+1\\right)  ...\\left(  n-1\\right)  \\right)  $\r\n(since the determinant of any block-triangular matrix is known to equal the\r\nproduct of the determinants of its diagonal blocks\\footnote{See \\cite[Exercise\r\n6.30]{Grin-detn} for a proof of this statement (at least in the case of a\r\nblock-triangular matrix with four blocks, and with the upper-right block being\r\nthe zero matrix; but this is precisely the case which we are using).}). Since\r\nwe are proceeding by induction over $n$, we can take $\\det A_{k-1}=\\left(\r\nk-1\\right)  !\\lambda^{k-1}\\left(  x\\right)  $ for granted (since $k-1<n$), and\r\nthus obtain%\r\n\\begin{align*}\r\n\\det\\left(  A_{n}\\left[  \\dfrac{\\sim k}{\\sim n}\\right]  \\right)   &  =\\det\r\nA_{k-1}\\cdot\\left(  k\\left(  k+1\\right)  ...\\left(  n-1\\right)  \\right)\r\n=\\left(  k-1\\right)  !\\lambda^{k-1}\\left(  x\\right)  \\cdot\\left(  k\\left(\r\nk+1\\right)  ...\\left(  n-1\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  k-1\\right)  !\\cdot\\left(  k\\left(  k+1\\right)\r\n...\\left(  n-1\\right)  \\right)  }_{=\\left(  n-1\\right)  !}\\cdot\\lambda\r\n^{k-1}\\left(  x\\right)  =\\left(  n-1\\right)  !\\cdot\\lambda^{k-1}\\left(\r\nx\\right)  .\r\n\\end{align*}\r\n\r\n\r\nThus, (\\ref{9.ex3.s2}) becomes%\r\n\\begin{align*}\r\n\\det A_{n}  &  =\\sum_{k=1}^{n}\\left(  -1\\right)  ^{n-k}\\psi^{n-k+1}\\left(\r\nx\\right)  \\cdot\\left(  n-1\\right)  !\\cdot\\lambda^{k-1}\\left(  x\\right) \\\\\r\n&  =\\left(  n-1\\right)  !\\cdot\\sum_{k=1}^{n}\\left(  -1\\right)  ^{n-k}%\r\n\\psi^{n-k+1}\\left(  x\\right)  \\lambda^{k-1}\\left(  x\\right) \\\\\r\n&  =\\left(  n-1\\right)  !\\cdot\\underbrace{\\sum_{i=1}^{n}\\left(  -1\\right)\r\n^{i-1}\\psi^{i}\\left(  x\\right)  \\lambda^{n-i}\\left(  x\\right)  }%\r\n_{=n\\lambda^{n}\\left(  x\\right)  \\text{ by \\textbf{(a)}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we substituted }i\\text{ for\r\n}n-k+1\\text{ in the sum}\\right) \\\\\r\n&  =\\underbrace{\\left(  n-1\\right)  !\\cdot n}_{=n!}\\lambda^{n}\\left(\r\nx\\right)  =n!\\lambda^{n}\\left(  x\\right)  ,\r\n\\end{align*}\r\ncompleting the induction step, qed.\r\n\r\n\\textbf{(c)} The proof (by induction over $n$) is similar to that of part\r\n\\textbf{(b)}, but this time the induction step leads us through%\r\n\\begin{align*}\r\n\\det B_{n}  &  =\\sum_{k=1}^{n}\\left(  -1\\right)  ^{n-k}\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\lambda^{n-k+1}\\left(  x\\right)  ,\\text{ if }k>1;\\\\\r\nn\\lambda^{n}\\left(  x\\right)  ,\\text{ if }k=1\r\n\\end{array}\r\n\\right.  \\cdot\\psi^{k-1}\\left(  x\\right) \\\\\r\n&  =\\sum_{i=0}^{n-1}\\left(  -1\\right)  ^{n-i-1}\\left\\{\r\n\\begin{array}\r\n[c]{c}%\r\n\\lambda^{n-i}\\left(  x\\right)  ,\\text{ if }i>0;\\\\\r\nn\\lambda^{n}\\left(  x\\right)  ,\\text{ if }i=0\r\n\\end{array}\r\n\\right.  \\cdot\\psi^{i}\\left(  x\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here we substituted }i\\text{ for\r\n}k-1\\text{ in the sum}\\right) \\\\\r\n&  =\\underbrace{\\left(  -1\\right)  ^{n-1}}_{=-\\left(  -1\\right)  ^{n}}%\r\nn\\lambda^{n}\\left(  x\\right)  \\underbrace{\\psi^{0}\\left(  x\\right)\r\n}_{\\substack{\\text{we defined this}\\\\\\text{to mean }1}}+\\sum_{i=1}%\r\n^{n-1}\\underbrace{\\left(  -1\\right)  ^{n-i-1}}_{=\\left(  -1\\right)\r\n^{n}\\left(  -1\\right)  ^{i-1}}\\lambda^{n-i}\\left(  x\\right)  \\psi^{i}\\left(\r\nx\\right) \\\\\r\n&  =-\\left(  -1\\right)  ^{n}n\\lambda^{n}\\left(  x\\right)  +\\sum_{i=1}%\r\n^{n-1}\\left(  -1\\right)  ^{n}\\left(  -1\\right)  ^{i-1}\\lambda^{n-i}\\left(\r\nx\\right)  \\psi^{i}\\left(  x\\right) \\\\\r\n&  =\\left(  -1\\right)  ^{n}\\left(  -n\\lambda^{n}\\left(  x\\right)  +\\sum\r\n_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\lambda^{n-i}\\left(  x\\right)  \\psi\r\n^{i}\\left(  x\\right)  \\right) \\\\\r\n&  =\\left(  -1\\right)  ^{n}\\underbrace{\\left(  -\\sum_{i=1}^{n}\\left(\r\n-1\\right)  ^{i-1}\\lambda^{n-i}\\left(  x\\right)  \\psi^{i}\\left(  x\\right)\r\n+\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\lambda^{n-i}\\left(  x\\right)\r\n\\psi^{i}\\left(  x\\right)  \\right)  }_{=-\\left(  -1\\right)  ^{n-1}\\lambda\r\n^{n-n}\\left(  x\\right)  \\psi^{n}\\left(  x\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by part \\textbf{(a)}}\\right) \\\\\r\n&  =\\left(  -1\\right)  ^{n}\\left(  -\\left(  -1\\right)  ^{n-1}\\lambda\r\n^{n-n}\\left(  x\\right)  \\psi^{n}\\left(  x\\right)  \\right)\r\n=\\underbrace{\\lambda^{n-n}\\left(  x\\right)  }_{=\\lambda^{0}\\left(  x\\right)\r\n=1}\\psi^{n}\\left(  x\\right)  =\\psi^{n}\\left(  x\\right)  ,\r\n\\end{align*}\r\nwhat completes the proof.\r\n\r\n\\textit{Exercise 9.4: Hints to solution:} There are several ways to prove\r\nthis. Here is one:\r\n\r\nWe are going to prove that $\\psi^{n}=\\operatorname*{id}$ for all\r\n$n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. We will do this by strong\r\ninduction over $n$. Since a strong induction does not need an induction base,\r\nlet us start with the induction step:\r\n\r\nLet $n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. Assume (as the induction\r\nhypothesis) that we have already proven $\\psi^{i}=\\operatorname*{id}$ for all\r\n$i\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $ satisfying $i<n$. We now must\r\nprove that $\\psi^{n}=\\operatorname*{id}$.\r\n\r\nLet $x\\in K$. Exercise 9.3 \\textbf{(a)} yields%\r\n\\[\r\nn\\lambda^{n}\\left(  x\\right)  =\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}%\r\n\\lambda^{n-i}\\left(  x\\right)  \\psi^{i}\\left(  x\\right)  .\r\n\\]\r\nSince $\\lambda^{n}\\left(  x\\right)  =\\dbinom{x}{n}$ (since $\\left(  K,\\left(\r\n\\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a binomial $\\lambda$-ring)\r\nand $\\lambda^{n-i}\\left(  x\\right)  =\\dbinom{x}{n-i}$ for every $i\\in\\left\\{\r\n1,2,...,n\\right\\}  $ (for the very same reason), this rewrites as%\r\n\\begin{align*}\r\nn\\dbinom{x}{n}  &  =\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\dbinom{x}{n-i}%\r\n\\psi^{i}\\left(  x\\right) \\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x}{n-i}\\underbrace{\\psi\r\n^{i}}_{\\substack{=\\operatorname*{id}\\\\\\text{(since }i<n\\text{)}}}\\left(\r\nx\\right)  +\\left(  -1\\right)  ^{n-1}\\underbrace{\\dbinom{n}{n-n}}_{=\\dbinom\r\n{n}{0}=1}\\psi^{n}\\left(  x\\right) \\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x}{n-i}%\r\n\\underbrace{\\operatorname*{id}\\left(  x\\right)  }_{=x}+\\left(  -1\\right)\r\n^{n-1}\\psi^{n}\\left(  x\\right) \\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x}{n-i}x+\\left(\r\n-1\\right)  ^{n-1}\\psi^{n}\\left(  x\\right)  .\r\n\\end{align*}\r\nSince\\footnote{The following computation only makes sense in the case when\r\n$n\\geq2$. However, in the remaining case, the result of the computation can be\r\nchecked independently.}%\r\n\\begin{align*}\r\n&  \\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x}{n-i}\\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\left(  \\dbinom{x-1}{n-i}%\r\n+\\dbinom{x-1}{n-i-1}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{because }\\dbinom{x}{n-i}=\\dbinom{x-1}{n-i}+\\dbinom{x-1}{n-i-1}\\\\\r\n\\text{by the recurrence equation of the binomial coefficients}%\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x-1}{n-i}+\\sum\r\n_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x-1}{n-i-1}\\\\\r\n&  =\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x-1}{n-i}+\\sum_{i=2}%\r\n^{n}\\underbrace{\\left(  -1\\right)  ^{\\left(  i-1\\right)  -1}}_{=-\\left(\r\n-1\\right)  ^{i-1}}\\underbrace{\\dbinom{x-1}{n-\\left(  i-1\\right)  -1}%\r\n}_{=\\dbinom{x-1}{n-i}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{here, we substituted }i-1\\text{ for\r\n}i\\text{ in the second sum}\\right) \\\\\r\n&  =\\underbrace{\\sum_{i=1}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x-1}{n-i}%\r\n}_{=\\left(  -1\\right)  ^{1-1}\\dbinom{x-1}{n-1}+\\sum\\limits_{i=2}^{n-1}\\left(\r\n-1\\right)  ^{i-1}\\dbinom{x-1}{n-i}}+\\underbrace{\\sum_{i=2}^{n}\\left(  -\\left(\r\n-1\\right)  ^{i-1}\\right)  \\dbinom{x-1}{n-i}}_{=\\sum\\limits_{i=2}^{n-1}\\left(\r\n-\\left(  -1\\right)  ^{i-1}\\right)  \\dbinom{x-1}{n-i}+\\left(  -\\left(\r\n-1\\right)  ^{n-1}\\right)  \\dbinom{x-1}{n-n}}\\\\\r\n&  =\\underbrace{\\left(  -1\\right)  ^{1-1}}_{=1}\\dbinom{x-1}{n-1}%\r\n+\\underbrace{\\sum\\limits_{i=2}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom{x-1}%\r\n{n-i}+\\sum\\limits_{i=2}^{n-1}\\left(  -\\left(  -1\\right)  ^{i-1}\\right)\r\n\\dbinom{x-1}{n-i}}_{=\\sum\\limits_{i=2}^{n-1}\\left(  -1\\right)  ^{i-1}%\r\n\\dbinom{x-1}{n-i}-\\sum\\limits_{i=2}^{n-1}\\left(  -1\\right)  ^{i-1}\\dbinom\r\n{x-1}{n-i}=0}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +\\left(  -\\left(  -1\\right)  ^{n-1}\\right)\r\n\\underbrace{\\dbinom{x-1}{n-n}}_{=\\dbinom{x-1}{0}=1}\\\\\r\n&  =1\\dbinom{x-1}{n-1}+0+\\left(  -\\left(  -1\\right)  ^{n-1}\\right)\r\n1=\\dbinom{x-1}{n-1}-\\left(  -1\\right)  ^{n-1},\r\n\\end{align*}\r\nthis becomes%\r\n\\begin{align*}\r\nn\\dbinom{x}{n}  &  =\\left(  \\dbinom{x-1}{n-1}-\\left(  -1\\right)\r\n^{n-1}\\right)  x+\\left(  -1\\right)  ^{n-1}\\psi^{n}\\left(  x\\right) \\\\\r\n&  =\\dbinom{x-1}{n-1}x-\\left(  -1\\right)  ^{n-1}x+\\left(  -1\\right)\r\n^{n-1}\\psi^{n}\\left(  x\\right)  .\r\n\\end{align*}\r\nSince%\r\n\\begin{align*}\r\n\\dbinom{x-1}{n-1}x  &  =\\dfrac{\\left(  x-1\\right)  \\cdot\\left(  x-2\\right)\r\n\\cdot...\\cdot\\left(  \\left(  x-1\\right)  -\\left(  n-1\\right)  +1\\right)\r\n}{\\left(  n-1\\right)  !}x\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{because }\\dbinom{x-1}{n-1}=\\dfrac{\\left(\r\nx-1\\right)  \\cdot\\left(  x-2\\right)  \\cdot...\\cdot\\left(  \\left(  x-1\\right)\r\n-\\left(  n-1\\right)  +1\\right)  }{\\left(  n-1\\right)  !}\\right) \\\\\r\n&  =\\dfrac{\\left(  x-1\\right)  \\cdot\\left(  x-2\\right)  \\cdot...\\cdot\\left(\r\nx-n+1\\right)  }{\\left(  n-1\\right)  !}x=\\dfrac{x\\cdot\\left(  \\left(\r\nx-1\\right)  \\cdot\\left(  x-2\\right)  \\cdot...\\cdot\\left(  x-n+1\\right)\r\n\\right)  }{\\left(  n-1\\right)  !}\\\\\r\n&  =\\dfrac{x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(  x-n+1\\right)\r\n}{\\left(  n-1\\right)  !}=\\dfrac{x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(\r\nx-n+1\\right)  }{n!\\diagup n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\left(  n-1\\right)  !=n!\\diagup\r\nn\\right) \\\\\r\n&  =n\\underbrace{\\dfrac{x\\cdot\\left(  x-1\\right)  \\cdot...\\cdot\\left(\r\nx-n+1\\right)  }{n!}}_{=\\dbinom{x}{n}}=n\\dbinom{x}{n},\r\n\\end{align*}\r\nthis transforms into%\r\n\\[\r\nn\\dbinom{x}{n}=n\\dbinom{x}{n}-\\left(  -1\\right)  ^{n-1}x+\\left(  -1\\right)\r\n^{n-1}\\psi^{n}\\left(  x\\right)  .\r\n\\]\r\nThis simplifies to $\\left(  -1\\right)  ^{n-1}x=\\left(  -1\\right)  ^{n-1}%\r\n\\psi^{n}\\left(  x\\right)  $. In other words, $\\psi^{n}\\left(  x\\right)  =x$.\r\nSince this holds for every $x\\in K$, this shows that $\\psi^{n}%\r\n=\\operatorname*{id}$. This completes the induction step. Thus, $\\psi\r\n^{n}=\\operatorname*{id}$ for every $n\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}\r\n$, and Exercise 9.4 is solved.\r\n\r\n\\textit{Exercise 9.5: Solution:} \\textit{1st step:} Any two power series\r\n$u\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$ and $v\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ satisfy%\r\n\\begin{equation}\r\n-T\\dfrac{d}{dT}\\log\\left(  uv\\right)  =\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n+\\left(  -T\\dfrac{d}{dT}\\log v\\right)  . \\label{9.ex5.s1}%\r\n\\end{equation}\r\n\r\n\r\n\\textit{First proof of (\\ref{9.ex5.s1}).} Let $u\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ and $v\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$.\r\nLet us work with the notations of Exercise 9.2. For every $i\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  $, we have\r\n\\begin{align*}\r\n\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log\\left(\r\nuv\\right)  \\right)   &  =\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac\r\n{d}{dT}\\log\\left(  u\\widehat{+}v\\right)  \\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }uv=u\\widehat{+}v\\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n+\\operatorname*{Coeff}\\nolimits_{i}\\left(  -T\\dfrac{d}{dT}\\log v\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{9.2.plus}), divided by }\\left(\r\n-1\\right)  ^{i}\\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{i}\\left(  \\left(  -T\\dfrac{d}{dT}\\log\r\nu\\right)  +\\left(  -T\\dfrac{d}{dT}\\log v\\right)  \\right)  .\r\n\\end{align*}\r\nIn other words, the coefficients of the power series $-T\\dfrac{d}{dT}%\r\n\\log\\left(  uv\\right)  $ before $T^{1}$, $T^{2}$, $T^{3}$, $...$ are equal to\r\nthe respective coefficients of the power series $\\left(  -T\\dfrac{d}{dT}\\log\r\nu\\right)  +\\left(  -T\\dfrac{d}{dT}\\log v\\right)  $. Since the same holds for\r\nthe coefficients before $T^{0}$ (in fact, both power series $-T\\dfrac{d}%\r\n{dT}\\log\\left(  uv\\right)  $ and $\\left(  -T\\dfrac{d}{dT}\\log u\\right)\r\n+\\left(  -T\\dfrac{d}{dT}\\log v\\right)  $ are divisible by $T$ and thus have\r\nthe coefficient $0$ before $T^{0}$), this yields that the power series\r\n$-T\\dfrac{d}{dT}\\log\\left(  uv\\right)  $ and $\\left(  -T\\dfrac{d}{dT}\\log\r\nu\\right)  +\\left(  -T\\dfrac{d}{dT}\\log v\\right)  $ are identic. Thus,\r\n(\\ref{9.ex5.s1}) is proven.\r\n\r\n\\textit{Second proof of (\\ref{9.ex5.s1}).} Let $u\\in1+K\\left[  \\left[\r\nT\\right]  \\right]  ^{+}$ and $v\\in1+K\\left[  \\left[  T\\right]  \\right]  ^{+}$.\r\nWe have%\r\n\\begin{align*}\r\n-T\\underbrace{\\dfrac{d}{dT}\\log\\left(  uv\\right)  }_{=\\dfrac{\\dfrac{d}%\r\n{dT}\\left(  uv\\right)  }{uv}}  &  =-T\\dfrac{\\dfrac{d}{dT}\\left(  uv\\right)\r\n}{uv}=-T\\underbrace{\\dfrac{\\left(  \\dfrac{d}{dT}u\\right)  v+u\\left(  \\dfrac\r\n{d}{dT}v\\right)  }{uv}}_{=\\dfrac{\\dfrac{d}{dT}u}{u}+\\dfrac{\\dfrac{d}{dT}v}{v}%\r\n}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\dfrac{d}{dT}\\left(  uv\\right)\r\n=\\left(  \\dfrac{d}{dT}u\\right)  v+u\\left(  \\dfrac{d}{dT}v\\right)  \\text{ by\r\nthe Leibniz identity}\\right) \\\\\r\n&  =-T\\left(  \\underbrace{\\dfrac{\\dfrac{d}{dT}u}{u}}_{=\\dfrac{d}{dT}\\log\r\nu}+\\underbrace{\\dfrac{\\dfrac{d}{dT}v}{v}}_{=\\dfrac{d}{dT}\\log v}\\right)\r\n=-T\\left(  \\dfrac{d}{dT}\\log u+\\dfrac{d}{dT}\\log v\\right) \\\\\r\n&  =\\left(  -T\\dfrac{d}{dT}\\log u\\right)  +\\left(  -T\\dfrac{d}{dT}\\log\r\nv\\right)  .\r\n\\end{align*}\r\nThis proves (\\ref{9.ex5.s1}).\r\n\r\n\\textit{2nd step:} For every $x\\in K$ and $y\\in K$, we have $\\widetilde{\\psi\r\n}_{T}\\left(  x+y\\right)  =\\widetilde{\\psi}_{T}\\left(  x\\right)\r\n+\\widetilde{\\psi}_{T}\\left(  y\\right)  $, where the map $\\widetilde{\\psi}_{T}$\r\nis defined as in Theorem 9.5.\r\n\r\n\\textit{Proof.} Let $x\\in K$ and $y\\in K$. By Theorem 9.5 \\textbf{(b)}, we\r\nhave $\\widetilde{\\psi}_{T}\\left(  x\\right)  =-T\\cdot\\dfrac{d}{dT}\\log\r\n\\lambda_{-T}\\left(  x\\right)  $. By Theorem 9.5 \\textbf{(b)} (applied to $y$\r\ninstead of $x$), we have $\\widetilde{\\psi}_{T}\\left(  y\\right)  =-T\\cdot\r\n\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  y\\right)  $. By Theorem 9.5 \\textbf{(b)}\r\n(applied to $x+y$ instead of $x$), we have $\\widetilde{\\psi}_{T}\\left(\r\nx+y\\right)  =-T\\cdot\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x+y\\right)  $.\r\n\r\nBy Theorem 2.1 \\textbf{(b)}, we have $\\lambda_{T}\\left(  x\\right)\r\n\\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda_{T}\\left(  x+y\\right)  $. Now,%\r\n\\begin{align*}\r\n&  \\underbrace{\\lambda_{-T}\\left(  x\\right)  }_{=\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  }\\cdot\r\n\\underbrace{\\lambda_{-T}\\left(  y\\right)  }_{=\\operatorname*{ev}%\r\n\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  y\\right)  \\right)  }\\\\\r\n&  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  \\cdot\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(\r\ny\\right)  \\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\underbrace{\\lambda_{T}\\left(\r\nx\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  }_{=\\lambda_{T}\\left(  x+y\\right)\r\n}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\operatorname*{ev}%\r\n\\nolimits_{-T}\\text{ is a ring homomorphism}\\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x+y\\right)\r\n\\right)  =\\lambda_{-T}\\left(  x+y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{since }\\lambda_{-T}\\left(  x+y\\right)  \\text{ is defined as\r\n}\\operatorname*{ev}\\nolimits_{-T}\\left(  \\lambda_{T}\\left(  x+y\\right)\r\n\\right)  \\right)  .\r\n\\end{align*}\r\nNow,%\r\n\\begin{align*}\r\n\\widetilde{\\psi}_{T}\\left(  x+y\\right)   &  =-T\\cdot\\dfrac{d}{dT}%\r\n\\log\\underbrace{\\lambda_{-T}\\left(  x+y\\right)  }_{=\\lambda_{-T}\\left(\r\nx\\right)  \\cdot\\lambda_{-T}\\left(  y\\right)  }=-T\\dfrac{d}{dT}\\log\\left(\r\n\\lambda_{-T}\\left(  x\\right)  \\cdot\\lambda_{-T}\\left(  y\\right)  \\right) \\\\\r\n&  =\\underbrace{\\left(  -T\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  x\\right)\r\n\\right)  }_{=\\widetilde{\\psi}_{T}\\left(  x\\right)  }+\\underbrace{\\left(\r\n-T\\dfrac{d}{dT}\\log\\lambda_{-T}\\left(  y\\right)  \\right)  }_{=\\widetilde{\\psi\r\n}_{T}\\left(  y\\right)  }\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{9.ex5.s1}), applied to\r\n}u=\\lambda_{-T}\\left(  x\\right)  \\text{ and }v=\\lambda_{-T}\\left(  y\\right)\r\n\\right) \\\\\r\n&  =\\widetilde{\\psi}_{T}\\left(  x\\right)  +\\widetilde{\\psi}_{T}\\left(\r\ny\\right)  .\r\n\\end{align*}\r\nThis proves the 2nd step.\r\n\r\n\\textit{3rd step:} For every $x\\in K$ and $y\\in K$, we have $\\psi^{j}\\left(\r\nx+y\\right)  =\\psi^{j}\\left(  x\\right)  +\\psi^{j}\\left(  y\\right)  $ for every\r\n$j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $.\r\n\r\n\\textit{Proof.} Let $x\\in K$ and $y\\in K$. By the definition of\r\n$\\widetilde{\\psi}_{T}$, we have $\\widetilde{\\psi}_{T}\\left(  x\\right)\r\n=\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  T^{j}$, $\\widetilde{\\psi}_{T}\\left(  y\\right)  =\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  y\\right)  T^{j}$ and\r\n$\\widetilde{\\psi}_{T}\\left(  x+y\\right)  =\\sum\\limits_{j\\in\\mathbb{N}%\r\n\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x+y\\right)  T^{j}$. Now,%\r\n\\begin{align*}\r\n\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx+y\\right)  T^{j}  &  =\\widetilde{\\psi}_{T}\\left(  x+y\\right)\r\n=\\underbrace{\\widetilde{\\psi}_{T}\\left(  x\\right)  }_{=\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  x\\right)  T^{j}%\r\n}+\\underbrace{\\widetilde{\\psi}_{T}\\left(  y\\right)  }_{=\\sum\\limits_{j\\in\r\n\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(  y\\right)  T^{j}%\r\n}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by the 2nd step}\\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }\\psi^{j}\\left(\r\nx\\right)  T^{j}+\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  }%\r\n\\psi^{j}\\left(  y\\right)  T^{j}=\\sum\\limits_{j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  }\\left(  \\psi^{j}\\left(  x\\right)  +\\psi^{j}\\left(  y\\right)\r\n\\right)  T^{j}.\r\n\\end{align*}\r\nComparing coefficients before $T^{j}$ in this identity of power series, we\r\nconclude that $\\psi^{j}\\left(  x+y\\right)  =\\psi^{j}\\left(  x\\right)\r\n+\\psi^{j}\\left(  y\\right)  $ for every $j\\in\\mathbb{N}\\setminus\\left\\{\r\n0\\right\\}  $. This proves the 3rd step.\r\n\r\n\\textit{4th step:} For every $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, we\r\nhave $\\psi^{j}\\left(  0\\right)  =0$.\r\n\r\n\\textit{Proof.} Let $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $. The 3rd\r\nstep yields that $\\psi^{j}\\left(  x+y\\right)  =\\psi^{j}\\left(  x\\right)\r\n+\\psi^{j}\\left(  y\\right)  $ for every $x\\in K$ and $y\\in K$. Applying this to\r\n$x=0$ and $y=0$, we obtain $\\psi^{j}\\left(  0+0\\right)  =\\psi^{j}\\left(\r\n0\\right)  +\\psi^{j}\\left(  0\\right)  $. In other words, $\\psi^{j}\\left(\r\n0\\right)  =\\psi^{j}\\left(  0\\right)  +\\psi^{j}\\left(  0\\right)  $. This\r\nsimplifies to $\\psi^{j}\\left(  0\\right)  =0$. Thus, the 4th step is proven.\r\n\r\n\\textit{5th step:} The map $\\psi^{j}:K\\rightarrow K$ is a homomorphism of\r\nadditive groups for every $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $.\r\n\r\n\\textit{Proof.} This follows from the 3rd and 4th steps. This completes the\r\n5th step and thus solves the problem.\r\n\r\n\\textit{Exercise 9.6:} \\textit{Hints to solution:} \\textbf{(a)} Corollary 9.7\r\nyields%\r\n\\[\r\nn\\alpha_{n}=\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}%\r\nN_{j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)  .\r\n\\]\r\nSince we identify the polynomial $N_{j}\\left(  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{j}\\right)  $ with the polynomial $N_{j}$ (because we view the\r\npolynomial ring $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{j}\\right]  $ as a subring of $\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{n}\\right]  $), this becomes%\r\n\\[\r\nn\\alpha_{n}=\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha\r\n_{n-j}\\underbrace{N_{j}\\left(  \\alpha_{1},\\alpha_{2},...,\\alpha_{j}\\right)\r\n}_{=N_{j}}=\\sum\\limits_{j=1}^{n}\\left(  -1\\right)  ^{j-1}\\alpha_{n-j}%\r\nN_{j}=\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\alpha_{n-i}N_{i}%\r\n\\]\r\n(here, we renamed the index $j$ as $i$). This solves Exercise 9.6 \\textbf{(a)}.\r\n\r\n\\textbf{(b), (c)} To obtain a solution to Exercises 9.6 \\textbf{(b)} and\r\n\\textbf{(c)}, we only have to make the following changes to the solution to\r\nExercises 9.3 \\textbf{(b)} and \\textbf{(c)}:\r\n\r\n\\begin{itemize}\r\n\\item Replace every occurence of $\\lambda^{\\ell}\\left(  x\\right)  $ (where\r\n$\\ell$ is any nonnegative integer) by $\\alpha_{\\ell}$.\r\n\r\n\\item Replace every occurence of $\\psi^{\\ell}\\left(  x\\right)  $ (where $\\ell$\r\nis any nonnegative integer) by $N_{\\ell}$.\r\n\r\n\\item Replace the equalities $\\lambda^{1}\\left(  x\\right)  =x$ and $\\psi\r\n^{1}\\left(  x\\right)  =x$ by $\\alpha_{1}=\\alpha_{1}$ and $N_{1}=\\alpha_{1}$\r\n(this is very easy to prove).\r\n\r\n\\item Replace every reference to Exercise 9.3 \\textbf{(a)} by a reference to\r\nExercise 9.6 \\textbf{(a)}.\r\n\\end{itemize}\r\n\r\nThis solves Exercises 9.6 \\textbf{(b)} and \\textbf{(c)}.\r\n\r\n\\textbf{(d)} Let $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}%\r\n}\\right)  $ be a $\\lambda$-ring. Let $x\\in K$. Let $n\\in\\mathbb{N}$. By the\r\nuniversal property of a polynomial ring, there exists a $\\mathbb{Z}$-algebra\r\nhomomorphism $\\varrho:\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{n}\\right]  \\rightarrow K$ which maps $\\alpha_{i}$ to $\\lambda^{i}\\left(\r\nx\\right)  $ for every $i\\in\\left\\{  1,2,...,n\\right\\}  $. Consider this\r\nhomomorphism $\\varrho$. By its construction, this homomorphism $\\varrho$ maps\r\nevery polynomial $P\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha\r\n_{n}\\right]  $ to its value $P\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{n}\\left(  x\\right)  \\right)  $.\r\n\r\nEvery $i\\in\\left\\{  0,1,...,n\\right\\}  $ satisfies\r\n\\begin{equation}\r\n\\varrho\\left(  \\alpha_{i}\\right)  =\\lambda^{i}\\left(  x\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\text{and}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\varrho\\left(  N_{i}\\right)\r\n=\\psi^{i}\\left(  x\\right)  . \\label{9.6.sol.1}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{9.6.sol.1}).} We distinguish between two\r\ncases:\r\n\\par\r\n\\textit{Case 1:} We have $i=0$.\r\n\\par\r\n\\textit{Case 2:} We have $i>0$.\r\n\\par\r\nFirst consider Case 1: In this case, $\\alpha_{i}=\\alpha_{0}=1$, $\\lambda\r\n^{i}\\left(  x\\right)  =\\lambda^{0}\\left(  x\\right)  =1$, $\\psi^{i}\\left(\r\nx\\right)  =\\psi^{0}\\left(  x\\right)  =1$ and $N_{i}=N_{0}=1$. Also,\r\n$\\varrho\\left(  1\\right)  =1$ (since $\\varrho$ is a $\\mathbb{Z}$-algebra\r\nhomomorphism). Thus, $\\varrho\\left(  \\underbrace{\\alpha_{i}}_{=1}\\right)\r\n=\\varrho\\left(  1\\right)  =1=\\lambda^{i}\\left(  x\\right)  $ and $\\varrho\r\n\\left(  \\underbrace{N_{i}}_{=1}\\right)  =\\varrho\\left(  1\\right)  =1=\\psi\r\n^{i}\\left(  x\\right)  $.\r\n\\par\r\nWe have thus proven (\\ref{9.6.sol.1}) in Case 1.\r\n\\par\r\nNow let us consider Case 2: In this case, $i>0$ and $i\\in\\left\\{\r\n0,1,...,n\\right\\}  $, so that $i\\in\\left\\{  1,2,...,n\\right\\}  $. Hence, by\r\nthe definition of $\\varrho$, we know that $\\varrho$ maps $\\alpha_{i}$ to\r\n$\\lambda^{i}\\left(  x\\right)  $. In other words, $\\varrho\\left(  \\alpha\r\n_{i}\\right)  =\\lambda^{i}\\left(  x\\right)  $. Besides, we know that $\\varrho$\r\nmaps every polynomial $P\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{n}\\right]  $ to its value $P\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{n}\\left(  x\\right)  \\right)  $.\r\nHence, $\\varrho$ maps $N_{i}$ to $N_{i}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{n}\\left(  x\\right)  \\right)\r\n=\\psi^{i}\\left(  x\\right)  $. In other words, $\\varrho\\left(  N_{i}\\right)\r\n=\\psi^{i}\\left(  x\\right)  $.\r\n\\par\r\nWe have thus proven (\\ref{9.6.sol.1}) in Case 2.\r\n\\par\r\nSo we have proven (\\ref{9.6.sol.1}) in both possible cases, qed.}\r\n\r\nNow, let us derive Exercise 9.3 \\textbf{(a)} from Exercise 9.6 \\textbf{(a)}:\r\nAccording to Exercise 9.6 \\textbf{(a)}, the equality%\r\n\\[\r\nn\\alpha_{n}=\\sum_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\alpha_{n-i}N_{i}%\r\n\\]\r\nholds. Applying $\\varrho$ to both sides of the equation, we get $\\varrho\r\n\\left(  n\\alpha_{n}\\right)  =\\varrho\\left(  \\sum\\limits_{i=1}^{n}\\left(\r\n-1\\right)  ^{i-1}\\alpha_{n-i}N_{i}\\right)  $. Since%\r\n\\begin{align*}\r\n\\varrho\\left(  n\\alpha_{n}\\right)   &  =n\\underbrace{\\varrho\\left(  \\alpha\r\n_{n}\\right)  }_{\\substack{=\\lambda^{n}\\left(  x\\right)  \\\\\\text{(by\r\n(\\ref{9.6.sol.1}))}}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\varrho\\text{ is\r\na }\\mathbb{Z}\\text{-algebra homomorphism}\\right) \\\\\r\n&  =n\\lambda^{n}\\left(  x\\right)\r\n\\end{align*}\r\nand%\r\n\\begin{align*}\r\n\\varrho\\left(  \\sum\\limits_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\alpha_{n-i}%\r\nN_{i}\\right)   &  =\\sum\\limits_{i=1}^{n}\\left(  -1\\right)  ^{i-1}%\r\n\\underbrace{\\varrho\\left(  \\alpha_{n-i}\\right)  }_{\\substack{=\\lambda\r\n^{n-i}\\left(  x\\right)  \\\\\\text{(by (\\ref{9.6.sol.1}))}}}\\underbrace{\\varrho\r\n\\left(  N_{i}\\right)  }_{\\substack{=\\psi^{i}\\left(  x\\right)  \\\\\\text{(by\r\n(\\ref{9.6.sol.1}))}}}\\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since }\\varrho\\text{ is a }%\r\n\\mathbb{Z}\\text{-algebra homomorphism}\\right) \\\\\r\n&  =\\sum\\limits_{i=1}^{n}\\left(  -1\\right)  ^{i-1}\\lambda^{n-i}\\left(\r\nx\\right)  \\psi^{i}\\left(  x\\right)  ,\r\n\\end{align*}\r\nthis becomes%\r\n\\[\r\nn\\lambda^{n}\\left(  x\\right)  =\\sum\\limits_{i=1}^{n}\\left(  -1\\right)\r\n^{i-1}\\lambda^{n-i}\\left(  x\\right)  \\psi^{i}\\left(  x\\right)  .\r\n\\]\r\nThus we have proved Exercise 9.3 \\textbf{(a)} by means of Exercise 9.6\r\n\\textbf{(a)}. Similarly, we can derive Exercise 9.3 \\textbf{(b)} and\r\n\\textbf{(c)} from Exercise 9.6 \\textbf{(b)} and \\textbf{(c)} (again, by\r\napplying $\\varrho$).\r\n\r\n\\textit{Exercise 9.7:} \\textit{Detailed solution:} First, we will prove that\r\n$\\alpha_{1}^{p}-N_{p}\\in p\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{p}\\right]  $ (where $N_{p}$ is the $p$-th Hirzebruch polynomial\r\nas defined in the beginning of Section 9). Due to our implicit construction of\r\n$N_{p}$, this is not easy to prove directly. Instead, we will prove this by\r\ndefining a ``universal'' polynomial similar to our Hirzebruch polynomials, and\r\nthen prove that this polynomial actually is $\\dfrac{\\alpha_{1}^{p}-N_{p}}{p}$.\r\n\r\n\\textit{1st step:} Let $m\\in\\mathbb{N}$. The polynomial $\\dfrac{1}{p}\\left(\r\n\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}-\\left(  U_{1}^{p}+U_{2}%\r\n^{p}+...+U_{m}^{p}\\right)  \\right)  \\in\\mathbb{Q}\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $ actually lies in $\\mathbb{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $.\r\n\r\n\\textit{Proof.} We need the following fact as a lemma:%\r\n\\begin{equation}\r\n\\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{If }m\\in\\mathbb{N}\\text{, if }A\\text{ is a commutative ring with unity\r\nsuch that }p\\cdot1_{A}=0\\text{, and}\\\\\r\n\\text{if }x_{1}\\text{, }x_{2}\\text{, }...\\text{, }x_{m}\\text{ are }m\\text{\r\nelements of }A\\text{, then }\\left(  x_{1}+x_{2}+...+x_{m}\\right)  ^{p}%\r\n=x_{1}^{p}+x_{2}^{p}+...+x_{m}^{p}%\r\n\\end{array}\r\n\\right)  . \\label{9.7.sol.idiotbinom}%\r\n\\end{equation}\r\n\\footnote{\\textit{Proof of (\\ref{9.7.sol.idiotbinom}):} Let $m\\in\\mathbb{N}$.\r\nLet $A$ be a commutative ring with unity such that $p\\cdot1_{A}=0$. Let\r\n$x_{1}$, $x_{2}$, $...$, $x_{m}$ be $m$ elements of $A$.\r\n\\par\r\nLet $\\Phi:A\\rightarrow A$ be the map defined by $\\left(  \\Phi\\left(  y\\right)\r\n=y^{p}\\text{ for every }y\\in A\\right)  $. Then, $\\Phi$ is known to be a ring\r\nhomomorphism (since $p\\cdot1_{A}=0$). Thus,\r\n\\[\r\n\\Phi\\left(  x_{1}+x_{2}+...+x_{m}\\right)  =\\Phi\\left(  x_{1}\\right)\r\n+\\Phi\\left(  x_{2}\\right)  +...+\\Phi\\left(  x_{m}\\right)  =\\sum\\limits_{i=1}%\r\n^{m}\\underbrace{\\Phi\\left(  x_{i}\\right)  }_{\\substack{=x_{i}^{p}\\\\\\text{(by\r\nthe definition of }\\Phi\\text{)}}}=\\sum\\limits_{i=1}^{m}x_{i}^{p}=x_{1}%\r\n^{p}+x_{2}^{p}+...+x_{m}^{p}.\r\n\\]\r\nCompared with $\\Phi\\left(  x_{1}+x_{2}+...+x_{m}\\right)  =\\left(  x_{1}%\r\n+x_{2}+...+x_{m}\\right)  ^{p}$ (by the definition of $\\Phi$), this yields\r\n$\\left(  x_{1}+x_{2}+...+x_{m}\\right)  ^{p}=x_{1}^{p}+x_{2}^{p}+...+x_{m}^{p}%\r\n$. This proves (\\ref{9.7.sol.idiotbinom}).}\r\n\r\nNow, let $A$ be the ring $\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  \\right)  \\diagup\\left(  p\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  \\right)  $. For every $u\\in\\mathbb{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  $, let $\\overline{u}$ denote the residue class of $u$\r\nmodulo the ideal $p\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $; this\r\n$\\overline{u}$ lies in $\\left(  \\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  \\right)  \\diagup\\left(  p\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  \\right)  =A$. Since $p\\cdot1_{\\mathbb{Z}\\left[  U_{1},U_{2}%\r\n,...,U_{m}\\right]  }\\in p\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $, we\r\nhave $\\overline{p\\cdot1_{\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  }}%\r\n=0$. Since $\\overline{p\\cdot1_{\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]\r\n}}=p\\cdot1_{A}$, this rewrites as $p\\cdot1_{A}=0$. Thus,\r\n(\\ref{9.7.sol.idiotbinom}) (applied to $x_{i}=\\overline{U_{i}}$) yields\r\n$\\left(  \\overline{U_{1}}+\\overline{U_{2}}+...+\\overline{U_{m}}\\right)\r\n^{p}=\\overline{U_{1}}^{p}+\\overline{U_{2}}^{p}+...+\\overline{U_{m}}^{p}$.\r\nSince $\\left(  \\overline{U_{1}}+\\overline{U_{2}}+...+\\overline{U_{m}}\\right)\r\n^{p}=\\overline{\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}}$ and $\\overline\r\n{U_{1}}^{p}+\\overline{U_{2}}^{p}+...+\\overline{U_{m}}^{p}=\\overline{U_{1}%\r\n^{p}+U_{2}^{p}+...+U_{m}^{p}}$, this rewrites as $\\overline{\\left(\r\nU_{1}+U_{2}+...+U_{m}\\right)  ^{p}}=\\overline{U_{1}^{p}+U_{2}^{p}%\r\n+...+U_{m}^{p}}$. In other words,%\r\n\\[\r\n\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}\\equiv U_{1}^{p}+U_{2}^{p}%\r\n+...+U_{m}^{p}\\operatorname{mod}p\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}%\r\n\\right]  .\r\n\\]\r\nIn other words, $\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}-\\left(  U_{1}%\r\n^{p}+U_{2}^{p}+...+U_{m}^{p}\\right)  \\in p\\mathbb{Z}\\left[  U_{1}%\r\n,U_{2},...,U_{m}\\right]  $. Thus, $\\dfrac{1}{p}\\left(  \\left(  U_{1}%\r\n+U_{2}+...+U_{m}\\right)  ^{p}-\\left(  U_{1}^{p}+U_{2}^{p}+...+U_{m}%\r\n^{p}\\right)  \\right)  \\in\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $.\r\nThis proves the 1st step.\r\n\r\n\\textit{2nd step:} Until now, $m$ could be any nonnegative integer. From now\r\non, set $m=p$.\r\n\r\nThe polynomial $\\dfrac{1}{p}\\left(  \\left(  U_{1}+U_{2}+...+U_{m}\\right)\r\n^{p}-\\left(  U_{1}^{p}+U_{2}^{p}+...+U_{m}^{p}\\right)  \\right)  $ lies in\r\n$\\mathbb{Z}\\left[  U_{1},U_{2},...,U_{m}\\right]  $ (due to the 1st step) and\r\nis symmetric (since it is a $\\mathbb{Q}$-linear combination of the polynomials\r\n$\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}$ and $U_{1}^{p}+U_{2}%\r\n^{p}+...+U_{m}^{p}$, both of which are symmetric). Thus, Theorem 4.1\r\n\\textbf{(a)} (applied to $K=\\mathbb{Z}$ and $P=\\dfrac{1}{p}\\left(  \\left(\r\nU_{1}+U_{2}+...+U_{m}\\right)  ^{p}-\\left(  U_{1}^{p}+U_{2}^{p}+...+U_{m}%\r\n^{p}\\right)  \\right)  $) yields that there exists one and only one polynomial\r\n$Q\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2},...,\\alpha_{m}\\right]  $ such\r\nthat%\r\n\\begin{equation}\r\n\\dfrac{1}{p}\\left(  \\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}-\\left(\r\nU_{1}^{p}+U_{2}^{p}+...+U_{m}^{p}\\right)  \\right)  =Q\\left(  X_{1}%\r\n,X_{2},...,X_{m}\\right)  . \\label{9.7.sol.Q}%\r\n\\end{equation}\r\nConsider this $Q$. Note that $Q\\in\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{m}\\right]  =\\mathbb{Z}\\left[  \\alpha_{1},\\alpha\r\n_{2},...,\\alpha_{p}\\right]  $ (since $m=p$).\r\n\r\nFor every $i\\in\\mathbb{N}$, let $X_{i}$ be defined as in Theorem 4.1. For\r\nevery $j\\in\\mathbb{N}\\setminus\\left\\{  0\\right\\}  $, define $N_{j}$ as in the\r\nbeginning of Section 9. Applying (\\ref{Nj1}) to $j=p$, we obtain%\r\n\\[\r\n\\sum_{i=1}^{m}U_{i}^{p}=N_{p}\\underbrace{\\left(  X_{1},X_{2},...,X_{p}\\right)\r\n}_{\\substack{=\\left(  X_{1},X_{2},...,X_{m}\\right)  \\\\\\text{(since\r\n}p=m\\text{)}}}=N_{p}\\left(  X_{1},X_{2},...,X_{m}\\right)  .\r\n\\]\r\nOn the other hand, $X_{1}=U_{1}+U_{2}+...+U_{m}$ (because $X_{1}$ is the\r\n$1$-st elementary symmetric polynomial in the variables $U_{1}$, $U_{2}$,\r\n$...$, $U_{m}$), so that $X_{1}^{p}=\\left(  U_{1}+U_{2}+...+U_{m}\\right)\r\n^{p}$. Now,%\r\n\\begin{align*}\r\n\\left(  \\alpha_{1}^{p}-N_{p}\\right)  \\left(  X_{1},X_{2},...,X_{m}\\right)   &\r\n=\\underbrace{X_{1}^{p}}_{=\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}%\r\n}-\\underbrace{N_{p}\\left(  X_{1},X_{2},...,X_{m}\\right)  }_{=\\sum\r\n\\limits_{i=1}^{m}U_{i}^{p}=U_{1}^{p}+U_{2}^{p}+...+U_{m}^{p}}\\\\\r\n&  =\\left(  U_{1}+U_{2}+...+U_{m}\\right)  ^{p}-\\left(  U_{1}^{p}+U_{2}%\r\n^{p}+...+U_{m}^{p}\\right) \\\\\r\n&  =p\\cdot\\underbrace{\\dfrac{1}{p}\\left(  \\left(  U_{1}+U_{2}+...+U_{m}%\r\n\\right)  ^{p}-\\left(  U_{1}^{p}+U_{2}^{p}+...+U_{m}^{p}\\right)  \\right)\r\n}_{\\substack{=Q\\left(  X_{1},X_{2},...,X_{m}\\right)  \\\\\\text{(by\r\n(\\ref{9.7.sol.Q}))}}}\\\\\r\n&  =pQ\\left(  X_{1},X_{2},...,X_{m}\\right)  =\\left(  pQ\\right)  \\left(\r\nX_{1},X_{2},...,X_{m}\\right)  .\r\n\\end{align*}\r\nSince the elements $X_{1}$, $X_{2}$, $...$, $X_{m}$ of $\\mathbb{Z}\\left[\r\nU_{1},U_{2},...,U_{m}\\right]  $ are algebraically independent (by Theorem 4.1\r\n\\textbf{(a)}), this yields $\\alpha_{1}^{p}-N_{p}=pQ$. This shows that\r\n$\\alpha_{1}^{p}-N_{p}\\in p\\mathbb{Z}\\left[  \\alpha_{1},\\alpha_{2}%\r\n,...,\\alpha_{p}\\right]  $.\r\n\r\n\\textit{3rd step:} Let $x\\in K$. Applying (\\ref{PsiDef}) to $j=p$, we obtain%\r\n\\[\r\n\\psi^{p}\\left(  x\\right)  =N_{p}\\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right)  .\r\n\\]\r\nNow, we recall that $\\alpha_{1}^{p}-N_{p}=pQ$, so that%\r\n\\begin{align*}\r\n\\left(  \\alpha_{1}^{p}-N_{p}\\right)  \\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right)   &\r\n=\\left(  pQ\\right)  \\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(\r\nx\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right) \\\\\r\n&  =p\\underbrace{Q\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(\r\nx\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right)  }_{\\in K}\\in pK.\r\n\\end{align*}\r\nSince%\r\n\\begin{align*}\r\n\\left(  \\alpha_{1}^{p}-N_{p}\\right)  \\left(  \\lambda^{1}\\left(  x\\right)\r\n,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right)   &\r\n=\\underbrace{\\alpha_{1}^{p}\\left(  \\lambda^{1}\\left(  x\\right)  ,\\lambda\r\n^{2}\\left(  x\\right)  ,...,\\lambda^{p}\\left(  x\\right)  \\right)  }_{=\\left(\r\n\\lambda^{1}\\left(  x\\right)  \\right)  ^{p}}-\\underbrace{N_{p}\\left(\r\n\\lambda^{1}\\left(  x\\right)  ,\\lambda^{2}\\left(  x\\right)  ,...,\\lambda\r\n^{p}\\left(  x\\right)  \\right)  }_{=\\psi^{p}\\left(  x\\right)  }\\\\\r\n&  =\\left(  \\underbrace{\\lambda^{1}\\left(  x\\right)  }%\r\n_{\\substack{=x\\\\\\text{(by the definition}\\\\\\text{of a }\\lambda\\text{-ring)}%\r\n}}\\right)  ^{p}-\\psi^{p}\\left(  x\\right)  =x^{p}-\\psi^{p}\\left(  x\\right)  ,\r\n\\end{align*}\r\nthis rewrites as $x^{p}-\\psi^{p}\\left(  x\\right)  \\in pK$. In other words,\r\n$\\psi^{p}\\left(  x\\right)  \\equiv x^{p}\\operatorname{mod}pK$. Exercise 9.7 is solved.\r\n\r\n\\subsection{To Section 10}\r\n\r\n\\textit{Exercise 10.2: Solution:}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.29.]Let $x\\in K$. Then, $\\lambda_{T}\\left(  x\\right)\r\n=\\sum\\limits_{i\\in\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}$, so that%\r\n\\[\r\n\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  =\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\sum\\limits_{i\\in\r\n\\mathbb{N}}\\lambda^{i}\\left(  x\\right)  T^{i}\\right)  =\\sum\\limits_{i\\in\r\n\\mathbb{N}}\\underbrace{\\iota\\left(  \\lambda^{i}\\left(  x\\right)  \\right)\r\n}_{\\substack{=\\lambda^{i}\\left(  x\\right)  \\otimes1\\\\\\text{(by the definition\r\nof }\\iota\\text{)}}}T^{i}=\\sum\\limits_{i\\in\\mathbb{N}}\\left(  \\lambda\r\n^{i}\\left(  x\\right)  \\otimes1\\right)  T^{i}.\r\n\\]\r\nHence, every $k\\in\\mathbb{N}$ satisfies $\\operatorname*{Coeff}\\nolimits_{k}%\r\n\\left(  \\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  \\right)  =\\operatorname*{Coeff}\\nolimits_{k}\\left(\r\n\\sum\\limits_{i\\in\\mathbb{N}}\\left(  \\lambda^{i}\\left(  x\\right)\r\n\\otimes1\\right)  T^{i}\\right)  =\\lambda^{k}\\left(  x\\right)  \\otimes1$ (by the\r\ndefinition of $\\operatorname*{Coeff}\\nolimits_{k}$). Thus,\r\n\\begin{align}\r\n&  \\left(  \\operatorname*{Coeff}\\nolimits_{1}\\left(  \\iota\\left[  \\left[\r\nT\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)\r\n,\\operatorname*{Coeff}\\nolimits_{2}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)\r\n,...,\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  \\right)\r\n\\nonumber\\\\\r\n&  =\\left(  \\lambda^{1}\\left(  x\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)\r\n\\otimes1,...,\\lambda^{j}\\left(  x\\right)  \\otimes1\\right)  \\label{10.29.pf.1}%\r\n\\end{align}\r\nfor every $j\\in\\mathbb{N}$. Now, (\\ref{ToddFrak}) (applied to $p=\\iota\\left[\r\n\\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  $)\r\nyields%\r\n\\begin{align*}\r\n&  \\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right) \\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)\r\n,\\operatorname*{Coeff}\\nolimits_{2}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)\r\n,...,\\operatorname*{Coeff}\\nolimits_{j}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  \\right)\r\nT^{j}\\\\\r\n&  =\\sum\\limits_{j\\in\\mathbb{N}}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(\r\n\\lambda^{1}\\left(  x\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)\r\n\\otimes1,...,\\lambda^{j}\\left(  x\\right)  \\otimes1\\right)  T^{j}%\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by (\\ref{10.29.pf.1})}\\right) \\\\\r\n&  =\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(\r\nx\\right)  .\r\n\\end{align*}\r\nThis proves Proposition 10.29.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.30.]Let $\\iota:K\\rightarrow K\\otimes_{\\mathbf{Z}%\r\n}\\mathbf{Z}^{\\prime}$ be the canonical map (mapping every $\\xi\\in K$ to\r\n$\\xi\\otimes1\\in K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$). Proposition 10.29\r\n(applied to $\\varphi=1+ut$) yields%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{1+ut,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)   &\r\n=\\mathfrak{Todd}_{1+ut}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]  \\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  \\right)  =\\underbrace{\\operatorname*{ev}%\r\n\\nolimits_{uT}}_{\\substack{=\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes\r\nu\\right)  T}\\\\\\text{(since }uT=\\left(  1\\otimes u\\right)  T\\\\\\text{in }\\left(\r\nK\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[  T\\right]\r\n\\right]  \\text{)}}}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]  \\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  \\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Proposition 10.12, applied to }\\mathbf{Z}^{\\prime}\\text{, }%\r\nK\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\text{ and }\\iota\\left[  \\left[\r\nT\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right) \\\\\r\n\\text{instead of }\\mathbf{Z}\\text{, }K\\text{ and }p\r\n\\end{array}\r\n\\right) \\\\\r\n&  =\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes u\\right)  T}\\left(\r\n\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  \\right)  =\\left(  \\operatorname*{ev}\\nolimits_{\\left(  1\\otimes\r\nu\\right)  T}\\circ\\iota\\left[  \\left[  T\\right]  \\right]  \\right)  \\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  .\r\n\\end{align*}\r\nBut the diagram%\r\n\\[\r\n\\xymatrixcolsep{5pc}\\xymatrix{\r\nK \\left[\\left[T\\right]\\right] \\ar[r]^{\\iota \\left[\\left[T\\right]\\right]} \\ar[dr]_{\\operatorname*{ev}_{\\left(1\\otimes u\\right)T}} & \\left(K \\otimes_{\\mathbf Z} \\mathbf Z^{\\prime}\\right) \\left[\\left[T\\right]\\right] \\ar[d]^{\\operatorname*{ev}_{\\left(1\\otimes u\\right)T}} \\\\\r\n&  \\left(K \\otimes_{\\mathbf Z} \\mathbf Z^{\\prime}\\right) \\left[\\left[T\\right]\\right]\r\n}\r\n\\]\r\ncommutes (since the definition of the map $\\operatorname*{ev}\\nolimits_{\\mu\r\nT}:K\\left[  \\left[  T\\right]  \\right]  \\rightarrow L\\left[  \\left[  T\\right]\r\n\\right]  $ for any ring $K$, any $K$-algebra $L$ and any element $\\mu$ of $L$\r\nwas canonical with respect to $K$). Thus, $\\operatorname*{ev}%\r\n\\nolimits_{\\left(  1\\otimes u\\right)  T}\\circ\\iota\\left[  \\left[  T\\right]\r\n\\right]  =\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes u\\right)  T}$. Now,%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{1+ut,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\underbrace{\\left(  \\operatorname*{ev}\\nolimits_{\\left(  1\\otimes u\\right)\r\nT}\\circ\\iota\\left[  \\left[  T\\right]  \\right]  \\right)  }_{=\\operatorname*{ev}%\r\n\\nolimits_{\\left(  1\\otimes u\\right)  T}}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  =\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes u\\right)  T}\\left(\r\n\\lambda_{T}\\left(  x\\right)  \\right)  .\r\n\\]\r\nThis proves Proposition 10.30.\r\n\\end{proof}\r\n\r\nAlternatively, we could have proven Proposition 10.30 by repeating the proof\r\nof Proposition 10.3 with some minor changes.\r\n\r\nWe could derive Proposition 10.31 from Proposition 10.13 (just as we derived\r\nProposition 10.30 from Proposition 10.12) using Proposition 10.29, but let us\r\ninstead prove it directly:\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.31.]Let $x\\in K$.\r\n\r\n\\textbf{(a)} We have%\r\n\\begin{align*}\r\n&  \\operatorname*{Coeff}\\nolimits_{0}\\left(  \\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{0}\\left(  \\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\lambda^{1}\\left(  x\\right)\r\n\\otimes1,\\lambda^{2}\\left(  x\\right)  \\otimes1,...,\\lambda^{j}\\left(\r\nx\\right)  \\otimes1\\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{ToddDefZ'})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}\\left(  \\lambda^{1}\\left(\r\nx\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)  \\otimes1,...,\\lambda\r\n^{0}\\left(  x\\right)  \\otimes1\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\nthe definition of }\\operatorname*{Coeff}\\nolimits_{0}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,0}=1\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\text{by Proposition 10.6 \\textbf{(a)}, applied to }\\mathbf{Z}^{\\prime}\\text{\r\ninstead of }\\mathbf{Z}\\right)  .\r\n\\end{align*}\r\n\r\n\r\n\\textbf{(b)} We have%\r\n\\begin{align*}\r\n&  \\operatorname*{Coeff}\\nolimits_{1}\\left(  \\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  \\right) \\\\\r\n&  =\\operatorname*{Coeff}\\nolimits_{1}\\left(  \\sum_{j\\in\\mathbb{N}%\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,j}\\left(  \\lambda^{1}\\left(  x\\right)\r\n\\otimes1,\\lambda^{2}\\left(  x\\right)  \\otimes1,...,\\lambda^{j}\\left(\r\nx\\right)  \\otimes1\\right)  T^{j}\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\n(\\ref{ToddDefZ'})}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\lambda^{1}\\left(\r\nx\\right)  \\otimes1,\\lambda^{2}\\left(  x\\right)  \\otimes1,...,\\lambda\r\n^{1}\\left(  x\\right)  \\otimes1\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by\r\nthe definition of }\\operatorname*{Coeff}\\nolimits_{1}\\right) \\\\\r\n&  =\\operatorname*{Td}\\nolimits_{\\varphi,1}\\left(  \\underbrace{\\lambda\r\n^{1}\\left(  x\\right)  }_{=x}\\otimes1\\right)  =\\operatorname*{Td}%\r\n\\nolimits_{\\varphi,1}\\left(  x\\otimes1\\right)  =\\varphi_{1}\\left(\r\nx\\otimes1\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{since Proposition 10.6 \\textbf{(b)}\r\n(applied to }\\mathbf{Z}^{\\prime}\\text{ instead of }\\mathbf{Z}\\text{) yields\r\n}\\operatorname*{Td}\\nolimits_{\\varphi,1}=\\varphi_{1}\\alpha_{1}\\right)  .\r\n\\end{align*}\r\n\r\n\r\nProposition 10.31 is now proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.32.]To obtain a proof of Proposition 10.32, read the\r\nproof of Proposition 10.7, doing the following replacements:\r\n\r\n\\begin{itemize}\r\n\\item Replace every $\\lambda^{k}\\left(  x\\right)  $ by $\\lambda^{k}\\left(\r\nx\\right)  \\otimes1$ for $k$ any nonnegative integer (that is, replace\r\n$\\lambda^{1}\\left(  x\\right)  $ by $\\lambda^{1}\\left(  x\\right)  \\otimes1$,\r\nreplace $\\lambda^{2}\\left(  x\\right)  $ by $\\lambda^{2}\\left(  x\\right)\r\n\\otimes1$, etc.).\r\n\r\n\\item Replace every $\\operatorname*{td}\\nolimits_{\\varphi,T}$ by\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$.\r\n\r\n\\item Replace every $\\operatorname*{td}\\nolimits_{\\psi,T}$ by\r\n$\\operatorname*{td}\\nolimits_{\\psi,T,\\mathbf{Z}^{\\prime}}$.\r\n\r\n\\item Replace every $\\operatorname*{td}\\nolimits_{\\varphi\\psi,T}$ by\r\n$\\operatorname*{td}\\nolimits_{\\varphi\\psi,T,\\mathbf{Z}^{\\prime}}$.\r\n\r\n\\item Replace all references to Proposition 10.7 by references to Proposition 10.32.\r\n\r\n\\item Replace all references to (\\ref{ToddDef}) by references to\r\n(\\ref{ToddDefZ'}).\r\n\\end{itemize}\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.33.]This can be proven by induction over $m$. The\r\ninduction base (the case $m=0$) requires showing that $\\operatorname*{td}%\r\n\\nolimits_{1,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  =1$, but this follows\r\nfrom Proposition 10.30\\footnote{In fact, Proposition 10.30 (applied to $u=0$)\r\nyields $\\operatorname*{td}\\nolimits_{1+0t,T,\\mathbf{Z}^{\\prime}}\\left(\r\nx\\right)  =\\lambda_{\\left(  1\\otimes0\\right)  T}\\left(  x\\right)  $. Now\r\n$\\lambda_{\\left(  1\\otimes0\\right)  T}\\left(  x\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{\\left(  1\\otimes0\\right)  T}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  $. Since $\\operatorname*{ev}\\nolimits_{\\left(  1\\otimes0\\right)\r\nT}=\\operatorname*{ev}\\nolimits_{0T}$ is the map $K\\left[  \\left[  T\\right]\r\n\\right]  \\rightarrow\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)\r\n\\left[  \\left[  T\\right]  \\right]  $ which sends every power series to its\r\nconstant term tensored with $1$ (viewed as a constant power series over\r\n$K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$), we have $\\operatorname*{ev}%\r\n\\nolimits_{\\left(  1\\otimes0\\right)  T}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  =\\underbrace{\\left(  \\text{constant term of the power series }%\r\n\\lambda_{T}\\left(  x\\right)  \\right)  }_{=1}\\otimes1=1\\otimes1=1$. Thus,\r\n$\\operatorname*{td}\\nolimits_{1,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\operatorname*{td}\\nolimits_{1+0t,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\lambda_{\\left(  1\\otimes0\\right)  T}\\left(  x\\right)  =\\operatorname*{ev}%\r\n\\nolimits_{\\left(  1\\otimes0\\right)  T}\\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  =1$.}. The induction step is a straightforward application of\r\nProposition 10.32. Thus Proposition 10.33 is proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.34.]Theorem 2.1 \\textbf{(a)} yields $\\lambda_{T}\\left(\r\nx\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  =\\lambda_{T}\\left(  x+y\\right)  $\r\n(since $\\left(  K,\\left(  \\lambda^{i}\\right)  _{i\\in\\mathbb{N}}\\right)  $ is a\r\n$\\lambda$-ring).\r\n\r\nLet $\\iota:K\\rightarrow K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$ be the\r\ncanonical map (mapping every $\\xi\\in K$ to $\\xi\\otimes1\\in K\\otimes\r\n_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$). Then, Proposition 10.29 yields\r\n$\\operatorname*{td}_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  $. Proposition 10.29\r\n(applied to $y$ instead of $x$) yields $\\operatorname*{td}_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  y\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\n\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  y\\right)\r\n\\right)  \\right)  $. Hence,%\r\n\\begin{align*}\r\n&  \\underbrace{\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}%\r\n}\\left(  x\\right)  }_{=\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[\r\nT\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)\r\n}\\cdot\\underbrace{\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}%\r\n}\\left(  y\\right)  }_{=\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[\r\nT\\right]  \\right]  \\left(  \\lambda_{T}\\left(  y\\right)  \\right)  \\right)  }\\\\\r\n&  =\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\right)  \\right)  \\cdot\\mathfrak{Todd}%\r\n_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda\r\n_{T}\\left(  y\\right)  \\right)  \\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\n\\underbrace{\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(\r\nx\\right)  \\right)  \\cdot\\iota\\left[  \\left[  T\\right]  \\right]  \\left(\r\n\\lambda_{T}\\left(  y\\right)  \\right)  }_{\\substack{=\\iota\\left[  \\left[\r\nT\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\\lambda\r\n_{T}\\left(  y\\right)  \\right)  \\\\\\text{(since }\\iota\\left[  \\left[  T\\right]\r\n\\right]  \\text{ is a ring homomorphism)}}}\\right) \\\\\r\n&  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 10.16, applied to }%\r\np=\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  x\\right)\r\n\\right)  \\text{ and }q=\\iota\\left[  \\left[  T\\right]  \\right]  \\left(\r\n\\lambda_{T}\\left(  y\\right)  \\right)  \\right) \\\\\r\n&  =\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)\r\n\\right)  \\right)  .\r\n\\end{align*}\r\nProposition 10.29 (applied to $x+y$ instead of $x$) yields%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x+y\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\underbrace{\\lambda_{T}\\left(  x+y\\right)  }_{\\substack{=\\lambda\r\n_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)  }}\\right)  \\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(  y\\right)\r\n\\right)  \\right)  .\r\n\\]\r\nThus,%\r\n\\[\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n\\cdot\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(\r\ny\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  \\lambda_{T}\\left(  x\\right)  \\cdot\\lambda_{T}\\left(\r\ny\\right)  \\right)  \\right)  =\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  x+y\\right)  .\r\n\\]\r\nTheorem 10.34 is thus proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Corollary 10.35.]Every $x\\in K$ satisfies $\\operatorname*{td}%\r\n_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  \\in\\Lambda\\left(\r\nK\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $ (since Proposition 10.31\r\n\\textbf{(a)} says that $\\operatorname*{Coeff}\\nolimits_{0}\\left(\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n\\right)  =1$, so that the power series $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)  $ has the constant term $1$, and thus\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x\\right)\r\n\\in1+\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[\r\nT\\right]  \\right]  ^{+}=\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}%\r\n^{\\prime}\\right)  $). In other words, $\\operatorname*{td}_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  K\\right)  \\subseteq\\Lambda\\left(\r\nK\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $.\r\n\r\nNow we are going to prove that $\\operatorname*{td}_{\\varphi,T,\\mathbf{Z}%\r\n^{\\prime}}:K\\rightarrow\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime\r\n}\\right)  $ is a homomorphism of additive groups.\r\n\r\nTheorem 10.34 (applied to $x=0$ and $y=0$) yields $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)  \\cdot\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)\r\n=\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(\r\n0+0\\right)  =\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}%\r\n}\\left(  0\\right)  $. Since $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)  $ is an invertible element of\r\n$\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[\r\nT\\right]  \\right]  $ (because $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)  $ is a power series with constant\r\nterm $1$\\ \\ \\ \\ \\footnote{since $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)  \\in\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  K\\right)  \\subseteq\r\n\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  =1+\\left(\r\nK\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[  T\\right]\r\n\\right]  ^{+}$}, and every such power series is an invertible element of\r\n$\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[\r\nT\\right]  \\right]  $), we can cancel $\\operatorname*{td}\\nolimits_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)  $ from this equation, and obtain\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  0\\right)\r\n=1$. Since $0$ is the neutral element of the additive group $K$, while $1$ is\r\nthe neutral element of the additive group $\\Lambda\\left(  K\\otimes\r\n_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $, this yields that the map\r\n$\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$ respects the\r\nneutral elements of the additive groups $K$ and $\\Lambda\\left(  K\\otimes\r\n_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $.\r\n\r\nAny $x\\in K$ and $y\\in K$ satisfy%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  x+y\\right)\r\n&  =\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(\r\nx\\right)  \\cdot\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}%\r\n}\\left(  y\\right)  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(  \\text{by Theorem 10.34}\\right)\r\n\\\\\r\n&  =\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(\r\nx\\right)  \\widehat{+}\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}%\r\n^{\\prime}}\\left(  y\\right)\r\n\\end{align*}\r\n(since multiplication of power series in $1+\\left(  K\\otimes_{\\mathbf{Z}%\r\n}\\mathbf{Z}^{\\prime}\\right)  \\left[  \\left[  T\\right]  \\right]  ^{+}$ is\r\naddition in the ring $\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime\r\n}\\right)  $). Combined with the fact that the map $\\operatorname*{td}%\r\n\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}$ respects the neutral elements of\r\nthe additive groups $K$ and $\\Lambda\\left(  K\\otimes_{\\mathbf{Z}}%\r\n\\mathbf{Z}^{\\prime}\\right)  $, this yields: The map $\\operatorname*{td}%\r\n_{\\varphi,T,\\mathbf{Z}^{\\prime}}:K\\rightarrow\\Lambda\\left(  K\\otimes\r\n_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\right)  $ is a homomorphism of additive\r\ngroups. Corollary 10.35 is proven.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Proposition 10.36.]Let $\\iota:K\\rightarrow K\\otimes_{\\mathbf{Z}%\r\n}\\mathbf{Z}^{\\prime}$ be the canonical map (mapping every $\\xi\\in K$ to\r\n$\\xi\\otimes1\\in K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}$). Then,\r\n$\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  1+uT\\right)  =1+\\left(\r\nu\\otimes1\\right)  T$.\r\n\r\nProposition 10.29 (applied to $x=u$) yields $\\operatorname*{td}_{\\varphi\r\n,T,\\mathbf{Z}^{\\prime}}\\left(  u\\right)  =\\mathfrak{Todd}_{\\varphi}\\left(\r\n\\iota\\left[  \\left[  T\\right]  \\right]  \\left(  \\lambda_{T}\\left(  u\\right)\r\n\\right)  \\right)  $. But Theorem 8.3 \\textbf{(a)} (applied to $x=u$) yields\r\nthat $\\lambda_{T}\\left(  u\\right)  =1+uT$ (since the element $u$ is\r\n$1$-dimensional). Thus,%\r\n\\begin{align*}\r\n\\operatorname*{td}\\nolimits_{\\varphi,T,\\mathbf{Z}^{\\prime}}\\left(  u\\right)\r\n&  =\\mathfrak{Todd}_{\\varphi}\\left(  \\iota\\left[  \\left[  T\\right]  \\right]\r\n\\left(  \\underbrace{\\lambda_{T}\\left(  u\\right)  }_{=1+uT}\\right)  \\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  \\underbrace{\\iota\\left[  \\left[  T\\right]\r\n\\right]  \\left(  1+uT\\right)  }_{=1+\\left(  u\\otimes1\\right)  T}\\right)\r\n=\\mathfrak{Todd}_{\\varphi}\\left(  1+\\left(  u\\otimes1\\right)  T\\right) \\\\\r\n&  =\\varphi\\left(  \\left(  u\\otimes1\\right)  T\\right)\r\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\left(\r\n\\begin{array}\r\n[c]{c}%\r\n\\text{by Proposition 10.26, applied to}\\\\\r\n\\mathbf{Z}^{\\prime}\\text{, }K\\otimes_{\\mathbf{Z}}\\mathbf{Z}^{\\prime}\\text{ and\r\n}u\\otimes1\\text{ instead of }\\mathbf{Z}\\text{, }K\\text{ and }u\r\n\\end{array}\r\n\\right)  .\r\n\\end{align*}\r\nThis proves Proposition 10.36.\r\n\\end{proof}\r\n\r\n\\begin{proof}\r\n[Proof of Theorem 10.37.]Theorem 10.37 can be proven with the help of\r\nProposition 10.36 in the same way as we proved Theorem 10.27 with the help of\r\nProposition 10.24. We leave the details to the reader.\r\n\\end{proof}\r\n\r\n\\begin{thebibliography}{999999999}                                                                                        %\r\n\r\n\r\n\\bibitem[AtiMac69]{AtiMac69}M. F. Atiyah, I. G. Macdonald,\r\n\\textit{Introduction to Commutative Algebra}, Addison-Wesley 1969.\r\n\r\n\\bibitem[BluCos16]{BluCos16}Ben Blum-Smith, Samuel Coskey, \\textit{The\r\nFundamental Theorem on Symmetric Polynomials: History's First Whiff of Galois\r\nTheory}, 8 April 2016, arXiv:1301.7116v4.\\newline\\url{http://arxiv.org/abs/1301.7116v4}\r\n\r\n\\bibitem[CoLiOS15]{CoLiOS15}David A. Cox, John Little, Donal O'Shea,\r\n\\textit{Ideals, Varieties, and Algorithms: An Introduction to Computational\r\nAlgebraic Geometry and Commutative Algebra}, Undergraduate Texts in\r\nMathematics, 4th Edition, Springer 2015.\r\n\r\n\\bibitem[DraGij09]{DraGij09}Jan Draisma and Dion Gijswijt, \\textit{Invariant\r\nTheory with Applications}, 8 October 2009.\\newline\\url{http://www.win.tue.nl/~jdraisma/teaching/invtheory0910/lecturenotes12.pdf}\r\n\r\n\\bibitem[Dumas08]{Dumas08}Fran\\c{c}ois Dumas, \\textit{An introduction to\r\nnoncommutative polynomial invariants}, lecture notes (Cimpa-Unesco-Argentina\r\n\\textquotedblleft Homological methods and representations of non-commutative\r\nalgebras\\textquotedblright, Mar del Plata, Argentina March 6 - 17,\r\n2006).\\newline\\url{http://math.univ-bpclermont.fr/~fdumas/fichiers/CIMPA.pdf}\r\n\r\n\\bibitem[FulLan85]{FulLan85}William Fulton, Serge Lang, \\textit{Riemann-Roch\r\nalgebra}, Grundlehren der mathematischen Wissenschaften \\#277, Springer, New\r\nYork 1985.\r\n\r\n\\bibitem[Grin-w4a]{Grin-w4a}Darij Grinberg, \\textit{Witt\\#4a: Equigraded power\r\nseries}.\\newline\\url{http://www.cip.ifi.lmu.de/~grinberg/algebra/witt4a.pdf}\r\n\r\n\\bibitem[Grin-detn]{Grin-detn}Darij Grinberg, \\textit{Notes on the\r\ncombinatorial fundamentals of algebra}, version of 10 January 2019.\\newline%\r\n\\url{https://github.com/darijgr/detnotes/releases/tag/2019-01-10}\\newline(This\r\nis the URL of the frozen version of 10 January 2019, guaranteed to have its\r\nnumbering match the references above. For a version which is getting updated,\r\nsee \\url{http://www.cip.ifi.lmu.de/~grinberg/primes2015/sols.pdf} .)\r\n\r\n\\bibitem[Harts77]{Harts77}Robin Hartshorne, \\textit{Algebraic Geometry},\r\nGraduate Texts in Mathematics \\#52, Springer 1977.\r\n\r\n\\bibitem[Hazewi08a]{Hazewi08a}Michiel Hazewinkel, \\textit{Niceness theorems},\r\narXiv:0810.5691v1 [math.HO], 2008.\\newline\\url{http://arxiv.org/abs/0810.5691v1}\r\n\r\n\\bibitem[Hazewi08b]{Hazewi08b}Michiel Hazewinkel, \\textit{Witt vectors. Part\r\n1}, arXiv:0804.3888v1 [math.RA], 2008.\\newline\\url{http://arxiv.org/abs/0804.3888v1}\r\n\r\n\\bibitem[Hopkin06]{Hopkin06}John R. Hopkinson, \\textit{Universal Polynomials\r\nin Lambda rings and the K-theory of the infinite loop space }$tmf$, PhD thesis\r\nat MIT, June 2006.\\newline\\url{http://dspace.mit.edu/handle/1721.1/34544}\r\n\r\n\\bibitem[Knut73]{Knut73}Donald Knutson, $\\lambda$\\textit{-Rings and the\r\nRepresentation Theory of the Symmetric Group}, Lecture Notes in Mathematics\r\n\\#308, Springer, New York 1973.\r\n\r\n\\bibitem[Laksov09]{Laksov09}Dan Laksov, \\textit{Splitting algebras,\r\nfactorization algebras, and residues}, 28 January 2009.\\newline\\url{https://people.kth.se/~laksov/art/splittingmonthly.pdf}\r\n\r\n\\bibitem[LLPT95]{LLPT}D. Laksov, A. Lascoux, P. Pragacz, and A. Thorup,\r\n\\textit{The LLPT Notes}, edited by A. Thorup, 1995,\\newline%\r\n\\url{http://www.math.ku.dk/~thorup/notes/sympol.pdf} .\r\n\r\n\\bibitem[MiRiRu88]{MiRiRu88}Ray Mines, Fred Richman, Wim Ruitenburg, \\textit{A\r\nCourse in Constructive Algebra}, Universitext, Springer 1988.\r\n\r\n\\bibitem[Neusel07]{Neusel07}Mara D. Neusel, \\textit{Invariant Theory}, Student\r\nMathematical Library \\#36, AMS 2007.\r\n\r\n\\bibitem[Newman12]{Newman12}Stephen C. Newman, \\textit{A classical\r\nintroduction to Galois theory}, Wiley 2012.\r\n\r\n\\bibitem[Seiler88]{Seiler88}Wolfang K. Seiler, $\\lambda$\\textit{-rings and\r\nAdams operations in algebraic K-Theory}, in: M. Rapoport, N. Schappacher, P.\r\nSchneider (eds.), \\textit{Beilinson's Conjectures on Special Values of }%\r\n$L$\\textit{-functions}, Academic Press 1988, pp. 93--102.\r\n\r\n\\bibitem[Smith95]{Smith95}Larry Smith, \\textit{Polynomial Invariants of Finite\r\nGroups}, A K Peters 1995.\r\n\r\n\\bibitem[Yau10]{Yau10}Donald Yau, \\textit{Lambda-rings}, World Scientific\r\n2010.\\newline%\r\n\\url{http://www.worldscientific.com/worldscibooks/10.1142/7664}\\newline%\r\n(includes downloadable Chapter 1).\r\n\\end{thebibliography}\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "15a1fcfcfcb5c63c463d4bf766680258acd0f5a8", "size": 861941, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lambda.tex", "max_stars_repo_name": "darijgr/lambda", "max_stars_repo_head_hexsha": "ef1cd56a54e4f3eb0bbe29dbebf06b8ff2527252", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-25T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-25T17:15:00.000Z", "max_issues_repo_path": "lambda.tex", "max_issues_repo_name": "darijgr/lambda", "max_issues_repo_head_hexsha": "ef1cd56a54e4f3eb0bbe29dbebf06b8ff2527252", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lambda.tex", "max_forks_repo_name": "darijgr/lambda", "max_forks_repo_head_hexsha": "ef1cd56a54e4f3eb0bbe29dbebf06b8ff2527252", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5637882669, "max_line_length": 291, "alphanum_fraction": 0.6125894928, "num_tokens": 358265, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555713, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.41115398203192044}}
{"text": "\\chapter{Reduced memory consumption}\n\nThe initial implementation has a couple of problems, one of which is it's memory consumption. This excessive memory consumption is mostly caused by the implementation of the memory preallocation for the matrices \\texttt{L}, \\texttt{D} and \\texttt{U}. Using \\texttt{zeros(m,n)} results in full matrices for \\texttt{L}, \\texttt{D} and \\texttt{U}, while they are often far from full.\\\\\n\n\\noindent The painful part is the fact that matrices \\texttt{L}, \\texttt{D} and \\texttt{U} grow dynamically with each iteration of the \\texttt{for}-loop. Adding to the problem is that fill-in makes it impossible to know a priory by just how much they grow each iteration. Memory preallocation is a real pig in these type of situations and resorting to a full \\texttt{zeros} matrix is often the only way that doesn't involve very complicated or convoluted code.\\\\\n\n\\noindent Dynamic growth of a matrix in a \\texttt{for}-loop is evil, mostly because matrices require a contiguous memory block. Adding data to a matrix involves allocating an entirely new contiguous block of memory for the matrix, copying the old values from the previous block to the new, then releasing the old block for potential reuse. These memory operations are time consuming and should be avoided in \\texttt{for}-loops. The most common way to deal with this problem is to use memory preallocation, but the other possibility is to use a data structure that drops the contiguous memory range requirement.\\\\\n\n\\noindent With an eye on making the implementation more memory efficient for a variety or reasons, an effort was undertaken to tackle the problem. As stated earlier, preallocation is difficult to achieve. With this in mind, the plan was to NOT use memory preallocation, but instead write the code in such a way that the negative effects of not using memory preallocation are largely avoided. MATLAB has a data structure known as a \"cell array\"\\autocite[]{math_doc_cell}, the most obvious differentiating qualities between it and a matrix data structure are:\n\n\\begin{itemize}\n    \\item Can contain different kind of elements. A collection of an \"int\", a matrix and a string can all be stored in the same cell array.\n    \\item No contiguous memory range required. The separate entries of the cell array may require a contiguous memory range, but the collection of the entries might be stored separately.\n\\end{itemize}\n\n\\noindent The most obvious quality that cell arrays and matrices share is their ability to be indexed, something that a \"struct\" lacks\\autocite[]{math_doc_struct}. The improved implementation uses cell arrays to store the additions of the matrices \\texttt{L}, \\texttt{D} and \\texttt{U}, with each element of the cell array containing a COO representation of the \\texttt{for}-loop additions\\autocite[]{wiki_coo}.\\\\\n\n\\section{The code}\n\n\\lstinputlisting{code/MLDU_Simple_cell.m}\n\n\\section{Discussion of the code}\n\nThis implementation creates one new nested function, two new local functions and increases the number of lines from $47$ to $91$, so the reduced memory consumption does come at the cost of code complexity.\n\n\\newpage\n\n\\section{Profiler results}\n\n\\noindent The profiler results below are generated by running:\\\\\n\n\\noindent \\texttt{[ E ] = Test\\_Function\\_1( 100, @MLDU\\_Simple\\_cell )}\\\\\n\n\\begin{figure}[h!]\n    \\includegraphics[width=\\linewidth]{figures/Profile_MLDU_Simple_cell_1.eps}\n    \\centering\n\\end{figure}\n\n\\noindent This is exactly the same as the previous situation. The error is also acceptable:\\\\\n\n\\noindent \\texttt{E =}\\\\\n\\\\\n\\noindent \\texttt{   1.1287e-13}\\\\\n\n\\noindent Apart from the targeted result that the memory consumption has decreased, a couple of other noteworthy positive changes occurred as well.\\\\\n\n\\noindent One of the positive aspect is that calculating the error has a vastly reduced runtime, from about $10$ seconds to just under one second. This is caused by the fact that matrices \\texttt{L}, \\texttt{D} and \\texttt{U} are now sparse, making the calculation a lot faster.\n\n\\begin{figure}[h!]\n    \\includegraphics[width=\\linewidth]{figures/Profile_MLDU_Simple_cell_2.eps}\n    \\centering\n\\end{figure}\n\n\\noindent The runtime required to save the matrices \\texttt{L}, \\texttt{D} and \\texttt{U} has actually decreased. The initial implementation spends $2.243$ seconds at lines $19$ through $21$ while the cell array implementation takes a total of $1.187$ seconds at lines $19, 20, 21$ and $33, 34, 35$.\\\\\n\n\\noindent Lastly and maybe the most significant side effect of the cell array implementation is the runtime reduction of line $26$, from about $17$ seconds to about $13$ seconds, a reduction of about $25 \\%$. This is probably caused by the reduced memory consumption itself, allowing the cache of the CPU to operate more effectively.", "meta": {"hexsha": "2caba8ff4af05c990c3d1fb188b447771cd47a4c", "size": 4796, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/chapters/MLDU_Simple_cell.tex", "max_stars_repo_name": "lucasbekker/Block-MLDU", "max_stars_repo_head_hexsha": "80415ec2e28017f0e128d0425e2e06742bb05233", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/chapters/MLDU_Simple_cell.tex", "max_issues_repo_name": "lucasbekker/Block-MLDU", "max_issues_repo_head_hexsha": "80415ec2e28017f0e128d0425e2e06742bb05233", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/chapters/MLDU_Simple_cell.tex", "max_forks_repo_name": "lucasbekker/Block-MLDU", "max_forks_repo_head_hexsha": "80415ec2e28017f0e128d0425e2e06742bb05233", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 85.6428571429, "max_line_length": 612, "alphanum_fraction": 0.7796080067, "num_tokens": 1141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555713, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.41115397595457037}}
{"text": "\\theoremstyle{plain}\n\\newtheorem{Theorem}{Theorem}[section]\n\\newtheorem{Lemma}[Theorem]{Lemma}\n\\newtheorem{Corollary}[Theorem]{Corollary}\n\\newtheorem*{With Space}{With Space}\n\\newtheorem{Proposition}{Proposition}[section]\n\\newtheorem{Conjecture}[Proposition]{Conjecture}\n\\newtheorem{WithoutSpace}{WithoutSpace}[section]\n\\newtheorem{KL}{Klein’s Lemma}[section]\n\\theoremstyle{definition}\n\\newtheorem{Definition}{Definition}[section]\n\\theoremstyle{remark}\n\\newtheorem{Case}{Case}[section]\n\n\\hypertarget{demo}{%\n\\chapter{Demo}\\label{demo}}\n\n\\begin{Theorem}[within parenthesis]\nplain theoremstyle \\emph{here}\n\nWe can use pandoc-crossref style \\ref{simplestEquation} and\n\\eqref{simplestEquation} and cite before definition.\n\\end{Theorem}\n\n\\begin{Theorem}\\label{simplestEquation}\n\\leavevmode\\vadjust pre{\\hypertarget{simplestEquation}{}}%\nLabel and reference:\n\n\\[E=mc^2\\]\n\\end{Theorem}\n\nFrom the \\ref{simplestEquation}, we see that\\ldots{} Or\n\\eqref{simplestEquation}, \\ldots{}\n\n\\begin{With Space}[\\textbf{This} is \\emph{markdown}.]\nEnvironment name has a space, and is unnumbered.\n\\end{With Space}\n\n\\begin{Lemma}[can cite \\ref{simplestEquation}]\nThis one share counter with Theorem.\n\\end{Lemma}\n\n\\begin{Definition}[pandoc-crossref style cite \\ref{simplestEquation}]\ndefinition theoremstyle here\n\\end{Definition}\n\n\\begin{Case}[within parenthesis]\nremark theoremstyle here\n\\end{Case}\n\n\\begin{proof}[Proof of the Main Theorem]\nPredefined proof theoremstyle here\n\\end{proof}\n\n\\begin{proof}[Proof of the \\emph{little} theorem]\nPredefined proof theoremstyle here with markdown info.\n\\end{proof}\n\n\\begin{proof}\nBare proof here.\n\\end{proof}\n\n\\begin{KL}\nKlein's Lemma from amsthm doc.\n\\end{KL}\n\n\\begin{Definition}\n\\begin{verbatim}\ncode here\n\\end{verbatim}\n\\end{Definition}\n\n\\hypertarget{counter-test}{%\n\\chapter{Counter test}\\label{counter-test}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\hypertarget{next-level}{%\n\\section{Next level}\\label{next-level}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\hypertarget{level-3}{%\n\\subsection{Level 3}\\label{level-3}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\hypertarget{level-4}{%\n\\subsubsection{Level 4}\\label{level-4}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\hypertarget{level-5}{%\n\\paragraph{Level 5}\\label{level-5}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\hypertarget{level-6}{%\n\\subparagraph{Level 6}\\label{level-6}}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n\n\\begin{Theorem}\nsome theorem\n\\end{Theorem}\n", "meta": {"hexsha": "d0bde14e210e720cc06cac3168d5ac936cd767c0", "size": 2680, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tests/model-latex.tex", "max_stars_repo_name": "ickc/pandoc-amsthm", "max_stars_repo_head_hexsha": "ee5153afc2a86a1c234c34c108261328e2e1245c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2016-05-22T19:25:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T04:55:33.000Z", "max_issues_repo_path": "tests/model-latex.tex", "max_issues_repo_name": "ickc/pandoc-amsthm", "max_issues_repo_head_hexsha": "ee5153afc2a86a1c234c34c108261328e2e1245c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2016-04-23T08:43:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-16T00:20:36.000Z", "max_forks_repo_path": "tests/model-latex.tex", "max_forks_repo_name": "ickc/pandoc-amsthm", "max_forks_repo_head_hexsha": "ee5153afc2a86a1c234c34c108261328e2e1245c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-03-11T04:22:55.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-01T03:38:23.000Z", "avg_line_length": 19.4202898551, "max_line_length": 69, "alphanum_fraction": 0.7638059701, "num_tokens": 835, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.41112471775722176}}
{"text": "% When using TeXShop on the Mac, let it know the root document. The following must be one of the first 20 lines.\n% !TEX root = ../design.tex\n\n\\chapter[Generalized Linear Models]{Generalized Linear Models}\n\n\\begin{moduleinfo}\n\\item[Author] \\href{mailto:lpei@gopivotal.com}{Liquan Pei}\n\\item[Author] \\href{mailto:lhuang@pivotal.io}{Lei Huang}\n\\item[History]\n    \\begin{modulehistory}\n        \\item[v0.1] Initial version\n        \\item[v0.2] Extention to multivariate response and ordinal response case\n    \\end{modulehistory}\n\\end{moduleinfo}\n\n% Abstract. What is the problem we want to solve?\n\n\\section{Introduction}\n\nLinear regression model assumes that the dependent variable $Y$ is equal to a linear combination $\\vec{X}^\\top \\vec{\\beta}$ and a normally distributed error term\n\\begin{align*}\nY = \\vec{X}^\\top \\vec{\\beta} + \\epsilon\n\\end{align*}\nwhere $\\vec{\\beta} = (\\beta_{1}, \\dots, \\beta_{m})^\\top$ is a vector of unknown parameters and $\\vec{X} = (X_1, \\dots, X_{m})^\\top$ is a vector of independent variables.\n\nIn a generalized linear model (GLM), the distribution of dependent variable $Y$ is a member from the \\emph{exponential family} and the mean $\\mu = \\mathbf{E}(Y)$ depends on the independent variables $\\vec{X}$ through\n\\begin{align*}\n\\mu = \\mathbf{E}(Y) = g^{-1}(\\eta) =g^{-1}(\\vec{X}^\\top \\beta)\n\\end{align*}\nwhere $\\eta = \\vec{X}^\\top \\beta$ is the \\emph{linear predictor} and $g$ is the \\emph{link function}.\n\nIn what follows, we denote $G(\\eta) = g^{-1}(\\eta)$ as the inverse link function.\n\n\\subsection{Exponential Family}\nA random variable $Y$ is a member from the exponantial family if its probability function or its density function has the form\n\\begin{align*}\nf(y,\\theta, \\psi) = \\exp \\left\\{ \\frac{y\\theta - b(\\theta)}{a(\\psi)} + c(y, \\psi)\\right\\}\n\\end{align*}\nwhere $\\theta$ is the canonical parameter.\nThe mean and variance of the exponential family are\n\\begin{itemize}\n\\item $\\mathbf{E}(Y) = \\mu = b'(\\theta)$\n\\item $\\mathbf{Var}(Y) = V(\\mu)a(\\psi) = b''(\\theta)a(\\psi)$\n\\end{itemize}\n\n\\subsection{Linear Predictor}\nThe linear predictor $\\eta$ incorporates the information about the independent variables into the model. It is related to the expected value of the data through link functions.\n\n\\subsection{Link Function}\nThe link function provides the relationship between $\\eta$, the linear predictor and $\\mu$, the mean of the distribution function. There are many commonly used link functions, and their choice can be somewhat arbitrary. It makes sense to try to match the domain of the link function to the range of the distribution function's mean.\n\nFor canonical parameter $\\theta$, the canonical link function is the function that expresses $\\theta$ in terms of $\\eta = g(\\mu)$. In what follows we treat $\\theta = \\theta(\\eta) = h(g(\\mu))$. If we choose $h$ to be an identical function, then $\\theta = \\eta$\nand $\\mu = G(\\eta) = \\mu(\\theta)$.\n\n\\section{Parameter Estimation}\nWe estimate unknown parameters $\\beta$ by maximizing the log-likelihood of a GLM. Given the examples $\\vec{Y} = (Y_1, \\dots, Y_n)^\\top$ and denote their mean as $\\vec{\\mu} = (\\mu_1, \\dots, \\mu_{n})^\\top$, the log-likelihood for a GLM is\n\n\\begin{align*}\nl(\\vec{Y}, \\vec{\\mu}, \\psi) & =\\sum_{i=1}^{n} \\log f(Y_i, \\theta_{i}, \\psi) \\\\\n& =\\sum_{i=1}^{n}\\left\\{ \\frac{Y_i \\theta_{i} - b\\left(\\theta_{i}\\right)}{a\\left(\\psi\\right)} - c(Y_i, \\psi)\\right\\}\n\\end{align*}\nwhere $\\theta_{i} = \\theta(\\eta_{i}) = \\theta(x_i^\\top \\beta)$\n\nNote that $a(\\psi)$ and $c(Y_i, \\psi)$ dose not depend on $\\beta$, we then maximize\n\\begin{align}\n\\label{likelihood}\n\\tilde{l}(\\vec{Y}, \\vec{\\mu}) = \\sum_{i = 1}^{n} \\left\\{ Y_i \\theta_{i} - b(\\theta_{i}) \\right\\}\n\\end{align}\nwith respect to $\\vec{\\beta}$.\nIn what follows, we denote $\\vec{x_i}$ to be the vector of values of independent variables for $Y_i$.\n\\subsection{Iterative Reweighted Least Squares Algorithm}\nWe use iterative reweighted least squares (IRLS) algorithm to find $\\vec{\\beta}$ that maximize $\\tilde{l}(\\vec{Y},\\vec{\\mu})$. Specifically, we use Fisher scoring algorithm which updates $\\vec{\\beta}$ at step $k+1$ using\n\\begin{align*}\n\\vec{\\beta}^{k+1} = \\vec{\\beta}^{k} + \\left\\{\\mathbf{E}[H(\\beta^{k})]\\right\\}^{-1} \\nabla_{\\vec{\\beta}}\\tilde{l}(\\vec{\\beta}^{k})\n\\end{align*}\nwhere $\\mathbf{E}[H]$ is the mean of Hessian over examples $\\vec{Y}$ and $\\nabla_{\\vec{\\beta}}\\tilde{l}$ is the gradient.\nFor GLM, the gradient is\n\\begin{align*}\n\\nabla_{\\vec{\\beta}}\\tilde{l} &= \\sum_{i = 1}^{n}\\left\\{Y_i - b'(\\theta_{i})\\right\\}\\nabla_{\\vec{\\beta}}\\theta_{i} \\\\\n\\end{align*}\nNote that $\\mu_{i} = G(\\eta_{i}) = G(\\vec{x_i}^\\top \\vec{\\beta}) = b'(\\theta_{i})$, we have\n\\begin{align*}\n\\nabla_{\\vec{\\beta}}\\theta_{i} &= \\frac{G'(\\eta_{i})}{V(\\mu_{i})} \\vec{x_i}\n\\end{align*}\n%and\n%\\begin{align*}\n%\\frac{\\partial^2 \\theta_{i}}{\\partial \\beta \\partial \\beta^{T}} = \\frac{G''(\\eta_{i})V(\\mu_{i}) - G'(\\eta_{i})^2 V'(\\mu_i)}{V(\\mu_{i})^2}x_i x_i^T\n%\\end{align*}\nthen\n\\begin{align*}\n\\nabla_{\\vec{\\beta}}\\tilde{l} &= \\sum_{i = 1}^{n}\\left\\{Y_i - \\mu_{i}\\right\\}\\frac{G'(\\eta_{i})}{V(\\mu_{i})}\\vec{x_i}\n\\end{align*}\nThe Hessian is\n\\begin{align*}\nH(\\beta) &= \\sum_{i = 1}^{n} \\left\\{-b''(\\theta_{i}) \\nabla_{\\vec{\\beta}}\\theta_{i} {\\nabla_{\\vec{\\beta}}\\theta_{i}}^\\top - \\left\\{Y_i - b'(\\theta_{i})\\right\\}\\nabla_{\\vec{\\beta}}^2 \\theta_{i}\\right\\} \\\\\n& = \\sum_{i = 1}^{n} \\left\\{ \\frac{G'(\\eta_{i})^2}{V(\\mu_{i})} - \\left\\{Y_i - \\mu_{i}\\right\\}\\nabla_{\\vec{\\beta}}^2 \\theta_{i}\\right\\}\\vec{x_i} \\vec{x_i}^\\top\n\\end{align*}\nNote that $\\mathbf{E}[Y_i] = \\mu_{i}$, we have\n\\begin{align*}\n\\mathbf{E}[H(\\beta)] = \\sum_{i = 1}^{n} \\left\\{\\frac{G'(\\eta_{i})^2}{V(\\mu_{i})}\\right\\}\\vec{x_i} \\vec{x_i}^\\top\n\\end{align*}\nDefine the weight matrix\n\\begin{align*}\n\\vec{W} = \\text{diag}\\left( \\frac{G'(\\eta_{1})^2}{V(\\mu_{1})}, \\dots, \\frac{G'(\\eta_{n})^2}{V(\\mu_{n})} \\right)\n\\end{align*}\nand define\n\\begin{align*}\n\\vec{\\tilde{Y}} = \\left(\\frac{Y_1 - \\mu_1}{G'(\\eta_{1})}, \\dots, \\frac{Y_n - \\mu_{n}}{G'(\\eta_{n})}\\right)^\\top\n\\end{align*}\nand the design matrix\n\\begin{align*}\n\\vec{X}^\\top = \\left(\\vec{x_1}, \\dots, \\vec{x_n}\\right)\n\\end{align*}\nFinally, the update rule for GLM is\n\\begin{align*}\n\\vec{\\beta}^{k+1}  &= \\vec{\\beta}^{k} + (\\vec{X}^\\top \\vec{W} \\vec{X})^{-1}\\vec{X}^\\top \\vec{W}\\tilde{\\vec{Y}} \\\\\n&= (\\vec{X}^\\top \\vec{W} \\vec{X})^{-1}\\vec{X^\\top WZ}\n\\end{align*}\nwhere  $\\vec{Z} = (Z_1, \\dots, Z_n)$ is a vector of \\emph{adjusted dependent variables}\n\\begin{align*}\nZ_i = \\vec{x_i}^\\top \\vec{\\beta}^{k} + \\frac{Y_i - \\mu_{i}}{G'(\\eta_{i})}\n\\end{align*}\nNote that each step is the result of a weighted least square regression on the adjusted variables $Z_i$ on $x_i$ and this the reason that this algorithm is called iterative reweighted least squares.\n\nThe IRLS algorithm for GLM is as follows\n\\begin{algorithm}\n\\alginput{$\\vec{X}$, $\\vec{Y}$, inverse link function $G(\\eta)$, dispersion function $V(\\mu)$ and initial values $\\vec{\\beta}^0$}\n\\algoutput{$\\vec{\\beta}$ that maximize $\\tilde{l}(\\vec{Y}, \\vec{\\mu})$}\n\\begin{algorithmic}[1]\n    \\State $k \\leftarrow 0$\n    \\Repeat\n        \\State Compute $\\vec{\\mu}$ where $\\mu_{i} = G(\\eta_{i}) = G(\\vec{x_i}^\\top \\vec{\\beta}^{k})$\n        \\State Compute $\\vec{Z}$ where $Z_i = \\vec{x_i}^\\top \\vec{\\beta}^{k} + \\frac{Y_i - \\mu_{i}}{G'(\\eta_{i})}$\n        \\State Compute $\\vec{W}$ where $W_{ii} = \\frac{G'(\\eta_{i})^2}{V(\\mu_{i})}$\n        \\State $\\vec{\\beta}^{k+1} = \\vec{(X^\\top W X)}^{-1} \\vec{X^\\top WZ}$\n    \\Until{$\\vec{\\beta}^{k+1}$ converges}\n\\end{algorithmic}\n\\label{alg:IRLS}\n\\end{algorithm}\n\n\\subsection{Functions for contructing the exponential families}\nTable \\ref{tab:glm_func} \\cite{fox2008applied} provides functions $a(), b()$ and $c()$ to contruction the exponential families,\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{cccc}\nFamily & $a(\\psi)$ & $b(\\theta)$ & $\\c(y, \\psi)$ \\\\\n\\hline\nGaussian & $\\psi$ & $\\theta^2/2$ & $-\\frac{1}{2}\\left[y^2/\\psi+\\log_e(2\\pi\\psi)\\right]$ \\\\\nBinomial & 1/n & $\\log_e(1+e^\\theta)$ & $\\log_eC^n_{ny}$ \\\\\nPoisson & 1 & $e^\\theta$ & $-log_ey!$ \\\\\nGamma & $\\psi$ & $-\\log_e(-\\theta)$ & $\\psi^{-1}\\log_e(y/\\psi) - \\log_ey - \\log_e\\Gamma(\\psi^{-1})$ \\\\\nInverse-Gaussian & $-\\psi$ & $\\sqrt{2\\theta}$ & $-\\frac{1}{2}\\left[\\log_e(\\pi\\psi y^3)^3 + 1/(\\psi y) \\right]$ \\\\\n\\end{tabular}\n\\caption{Functions for constructing the exponential families}\n\\label{tab:glm_func}\n\\end{table}\n\n\\subsection{Multivariate response family}\n\\label{subsec::multinomreg}\nInstead of a single scalar number, some response variable follows a multivariate distribution (i.e. the response variable is a vector instead of a scalar number). One example is multinomial GLM where the response variable is an indictor vector containing zeros and ones to dummy code the corresponding categories. For illustration purpose, in this section, we are discussing multinomial GLM. However, other distributions can be easily extended.\n\nLet $J$ denote the number of categories, $y_i=(y_{i1}, y_{i2}, ..., y_{i(J-1)})^T$ be the indicator vector for $i$th subject where each $y_{ij}$ is the binary indicator whether subject $i$ is in categories $j$, $\\mu_{ij}$ will be the probabilty subject $i$ is in category $j$. Therefore, we can have the log likelihood as below,\n\n\\begin{align*}\nl & = \\sum_{i=1}^{I} \\left(\\sum_{j=1}^{J-1} y_{ij} \\log{\\frac{\\mu_{ij}}{1-\\sum_{j=1}^{J}\\mu_{ij}}} + \\log(1-\\sum_{j=1}^{J-1}) \\right)\\\\\n & = \\sum_{i=1}^I \\left( \\sum_{j=1}^{J-1} y_{ij} \\theta_{ij} - \\log(1+\\sum_{j=1}^{J-1}\\exp\\theta_{ij}) \\right)\n\\end{align*}\n\nDefine $b(\\theta_i) = \\log(1+\\sum_{j=1}^{J-1}\\exp\\theta_{ij})$, then it can be showed $\\triangledown b(\\theta_i) = \\mu_i$ and\n\\[\n\\triangledown \\triangledown^T b(\\theta_i) = \\left( \\begin{array}{cccc}\n\\mu_{i1}(1-\\mu_{i1}) & -\\mu_{i1}\\mu_{i2} & ... & -\\mu_{i1}\\mu_{i(J-1)} \\\\\n-\\mu_{i2}\\mu_{i1} & \\mu_{i2}(1-\\mu_{i2}) & ... & -\\mu_{i2}\\mu_{i(J-1)} \\\\\n\\vdots & \\vdots & \\vdots & \\vdots \\\\\n-\\mu_{i(J-1)}\\mu_{i1} & -\\mu_{i(J-1)}\\mu_{i2} & ... & \\mu_{i(J-1)}\\mu_{i(J-1)}\n\\end{array} \\right)\n\\]\nWe set $V = \\triangledown \\triangledown^T b(\\theta_i)$\n\nLet $\\eta_{ij} = g_j(\\mu_i)$ and $g() = (g_1(), g_2(), ..., g_{J-1}())^T$ be the link map, which is $\\Re^{J-1}$ to $\\Re^{J-1}$. Also we have $\\mu_i = G(\\eta_i)$ be its inverse map. We define the derivative of $G$ to be $G^\\prime = \\left(\\frac{\\partial\\mu_i}{\\partial\\eta_{i1}}, \\frac{\\partial\\mu_i}{\\partial\\eta_{i2}}, ..., \\frac{\\partial\\mu_i}{\\partial\\eta_{i(J-1)}} \\right)$. For example, in multinomial logistic regression, $\\eta_{ij} = \\theta_{ij}$, then $G^\\prime = V$.\n\nDenote the coefficient to be $\\beta_{kj}$ where $k$ stands for the $k$th predictor and $j$ stands for the $j$th category. Then we have\n\\begin{align*}\n\\frac{\\partial l_i}{\\partial \\beta_{kj}} & = (y_i - \\triangledown b(\\theta_i) )^T \\frac{\\partial \\theta_i}{\\partial \\mu_i} \\frac{\\partial \\mu_i}{\\partial \\eta_{ij}} \\frac{\\partial \\eta_{ij}}{\\partial \\beta_{kj}} \\\\\n& = (y_i - \\mu_i )^T V^{-1} G^\\prime_j x_{ik}\n\\end{align*}\nwhere $G^\\prime_j$ is the $j$th column of $G^\\prime$.\n\\begin{align*}\n\\frac{\\partial^2 l_i}{\\partial\\beta_{kj} \\partial\\beta_{lh}} &= -x_{il} (G^\\prime_h)^T V^{-1} \\triangledown \\triangledown^T b(\\theta_i) V^{-1} G^\\prime_j x_{ik} \\\\\n& = -x_{il} (G^\\prime_h)^T V^{-1} G^\\prime_j x_{ik}\n\\end{align*}\n\nAs a entire vector $\\beta$,\n\\begin{align*}\n\\triangledown_\\beta l_i &= \\left((y_i - \\mu_i)^T V^{-1} G^\\prime(\\mu_i) \\right)^T \\otimes X_i \\\\\nE\\left[\\triangledown \\triangledown^T_\\beta l_i\\right] & = - \\left( [G^\\prime(\\mu_i)]^T V^{-1} [G^\\prime(\\mu_i)] \\right) \\otimes (X_i X_i^T)\n\\end{align*}\nwhere $X_i = (x_{i1}, x_{i2}, ... , x_{ip})^T$.\n\nFinally, we can use the below update equation for Newton-Raphson method,\n\\[\n\\beta^{k+1} = \\beta^k + \\left\\{ \\sum_{i=1}^I\\left([G^\\prime(\\mu_i)]^T V^{-1} [G^\\prime(\\mu_i)] \\right) \\otimes (X_i X_i^T)\\right\\}^{-1}\\sum_{i=1}^I\\left\\{\\left((y_i - \\mu_i)^T V^{-1} G^\\prime(\\mu_i) \\right)^T \\otimes X_i\\right\\}\n\\]\n\n\\subsection{Ordinal logistic regression}\nIn statistics, the ordered logit model (also ordered logistic regression or proportional odds model), is a regression model for ordinal dependent variables. For example, if one question on a survey is to be answered by a choice among \"poor\", \"fair\", \"good\", \"very good\", and \"excellent\", and the purpose of the analysis is to see how well that response can be predicted by the responses to other questions, some of which may be quantitative, then ordered logistic regression may be used. It can be thought of as an extension of the logistic regression model that applies to dichotomous dependent variables, allowing for more than two (ordered) response categories.\n\nThe model we implement here only applies to data that meet the proportional odds assumption, the meaning of which can be exemplified as follows.\n\n\\[\n\\log\\left( \\frac{\\Pr(Y_i \\le j)}{1-\\Pr(Y_i \\le j)} \\right) = \\alpha_j - \\beta_1 x_{i1} - \\beta_2 x_{i2} - ... - \\beta_p x_{ip}\n\\]\nwhere $\\Pr(Y_i \\le j)$ is the cumulative probability that the $i$th subject belongs to the first $j$th categories; $\\alpha_j$ is category-specific intercept and $\\beta_k$ is feature-specific coefficient. Using the notation in the subsection \\ref{subsec::multinomreg}, the link function is\n\\[\ng\\left([\\mu_1, \\mu_2, ..., \\mu_{J-1}]^T\\right) = \\left[\\log\\left(\\frac{\\mu_1}{1-\\mu_1}\\right), \\log\\left(\\frac{\\mu_1+\\mu_2}{1-\\mu_1-\\mu_2}\\right), ..., \\log\\left(\\frac{\\mu_1+\\mu_2+...+\\mu_{J-1}}{1-\\mu_1-\\mu_2-...-\\mu_{J-1}}\\right)\\right]^T\n\\] \nThen the inverse of link function G is,\n\\begin{align*}\nG\\left([\\eta_1, \\eta_2, ..., \\eta_{J-1}]^T\\right) & = \\left[\\frac{\\exp(\\eta_1)}{1+\\exp(\\eta_1)}, \\frac{\\exp(\\eta_2)}{1+\\exp(\\eta_2)} - \\frac{\\exp(\\eta_1)}{1+\\exp(\\eta_1)},\\right. \\\\\n\t\t\t\t\t\t  &    \\left. ..., \\frac{\\exp(\\eta_{J-1})}{1+\\exp(\\eta_{J-1})} - \\frac{\\exp(\\eta_{J-2})}{1+\\exp(\\eta_{J-2})}\\right]^T\n\\end{align*}\nIts derivative matrix $G^\\prime$ is\n\\begin{align*}\nG^\\prime & = \\left[\\frac{\\partial \\mu}{\\partial \\eta_1}, \\frac{\\partial \\mu}{\\partial \\eta_2}, ..., \\frac{\\partial \\mu}{\\partial \\eta_{J-1}}\\right] \\\\\n& = \\left[ \\begin{array}{ccccc}\n\t      \\frac{\\exp(\\eta_1)}{(1+\\exp(\\eta_1))^2} & 0 & 0 & ... & 0 \\\\\n\t     -\\frac{\\exp(\\eta_1)}{(1+\\exp(\\eta_1))^2} & \\frac{\\exp(\\eta_2)}{(1+\\exp(\\eta_2))^2} & 0 & ... & 0 \\\\\n\t     0 & -\\frac{\\exp(\\eta_2)}{(1+\\exp(\\eta_2))^2} & \\frac{\\exp(\\eta_3)}{(1+\\exp(\\eta_3))^2} & ... & 0 \\\\\n\t     \\vdots & \\vdots & \\vdots & ... & \\vdots \\\\\n\t     0 & 0 & 0 & ... & \\frac{\\exp(\\eta_{J-1})}{(1+\\exp(\\eta_{J-1}))^2}\n\t   \\end{array} \\right]\n\\end{align*}\n\nDefine $h_i = \\sum_{j=1}^{J-1} \\frac{\\partial \\mu_i}{\\partial \\eta_{ij}}$, then as a entire coefficient vector $\\gamma = [\\alpha_1, \\alpha_2, ..., \\alpha_{J-1}, \\beta_1, \\beta_2, ..., \\beta_p]^T$,\n\\begin{align*}\n\\triangledown_\\gamma l_i &= \\left[ \\begin{array}{c}\n\t\t\t\t\t\\left\\{(y_i - \\mu_i)^T V^{-1} G_i^{\\prime} \\right\\}^T \\\\\n\t\t\t\t\t-(y_i - \\mu_i)^T V^{-1} h_i X_i\n\t\t\t\t   \\end{array} \\right] \\\\\nE\\left[\\triangledown \\triangledown^T_\\gamma l_i\\right] & = - \\left[ \\begin{array}{cc}\n\t\t\t\t\t\t\t(G_i^\\prime)^T V^{-1} G_i^\\prime & -(G_i^\\prime)^T V^{-1} h_i X_i^T \\\\\n\t\t\t\t\t\t\t-X_i h_i^T V^{-1} G_i & h_i^T V^{-1} h_i X_iX_i^T\n\t\t\t\t\t\t      \\end{array} \n\t\t\t\t\t\t\\right]\n\\end{align*}\nwhere $X_i = (x_{i1}, x_{i2}, ... , x_{ip})^T$, $G_i^\\prime = G^\\prime(\\eta_{i1},\\eta_{i2},...,\\eta_{iJ-1})$. We can then implement Newton-Raphson method using above gradient and Hessian matrix.\n\n\\subsection{Ordinal probit model}\nIn the ordinal probit model, instead of logistic link function used in ordinal logistic regression, the probit function $\\Phi(x)$ is used. Therefore the model becomes,\n\\[\n\\Phi^{-1}\\left( \\Pr(Y_i \\le j) \\right) = \\alpha_j - \\beta_1 x_{i1} - \\beta_2 x_{i2} - ... - \\beta_p x_{ip}\n\\]\nand the link function is \n\\[\ng\\left([\\mu_1, \\mu_2, ..., \\mu_{J-1}]^T\\right) = \\left[\\Phi^{-1}(\\mu_1), \\Phi^{-1}(\\mu_1+\\mu_2), ..., \\Phi^{-1}(\\mu_1+\\mu_2+...+\\mu_{J-1})\\right]^T\n\\] \nThen the inverse of link function G is,\n\\[\nG\\left([\\eta_1, \\eta_2, ..., \\eta_{J-1}]^T\\right)  = \\left[\\Phi(\\eta_1), \\Phi(\\eta_2) - \\Phi(\\eta_1), ..., \\Phi(\\eta_{J-1}) - \\Phi(\\eta_{J-2})\\right]^T\n\\]\nIts derivative matrix $G^\\prime$ is\n\\begin{align*}\nG^\\prime & = \\left[\\frac{\\partial \\mu}{\\partial \\eta_1}, \\frac{\\partial \\mu}{\\partial \\eta_2}, ..., \\frac{\\partial \\mu}{\\partial \\eta_{J-1}}\\right] \\\\\n& = \\left[ \\begin{array}{ccccc}\n\t      \\phi(\\eta_1) & 0 & 0 & ... & 0 \\\\\n\t     -\\phi(\\eta_1) & \\phi(\\eta_2) & 0 & ... & 0 \\\\\n\t     0 & -\\phi(\\eta_2) & \\phi(\\eta_3) & ... & 0 \\\\\n\t     \\vdots & \\vdots & \\vdots & ... & \\vdots \\\\\n\t     0 & 0 & 0 & ... & \\phi(\\eta_{J-1})\n\t   \\end{array} \\right]\n\\end{align*}\nwhere $\\Phi(x)$ and $\\phi(x)$ are the cumulative probability and density probability of standard normal distribution.\n", "meta": {"hexsha": "90d40d06b9b8b20b43bcbf42747c49805b9fef41", "size": 16575, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/design/modules/glm.tex", "max_stars_repo_name": "fmcquillan99/apache-madlib", "max_stars_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-09-18T07:44:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T19:45:18.000Z", "max_issues_repo_path": "doc/design/modules/glm.tex", "max_issues_repo_name": "fmcquillan99/apache-madlib", "max_issues_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-09-06T05:50:17.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-06T05:50:17.000Z", "max_forks_repo_path": "doc/design/modules/glm.tex", "max_forks_repo_name": "fmcquillan99/apache-madlib", "max_forks_repo_head_hexsha": "e2dea62d1eadc7f662f2d926c71f42332f414ca0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-03T20:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-03T20:50:13.000Z", "avg_line_length": 60.4927007299, "max_line_length": 664, "alphanum_fraction": 0.6342684766, "num_tokens": 6151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.41112471775722176}}
{"text": "%!TeX encoding=utf8\n\n\\section{Bose Einstein Condensate}\n\n\\subsection{Questions}\n\\begin{itemize}\n        \\item $\\int \\frac{1}{r^{n}} \\mathrm{d^{3}r}$ divergent just for $n \\leq 3 $ ?\n        \\item What is an s-wave?\n        \\item if $l < \\frac{n-3}{2}$,\n        \\item and like $k^{n-2}$ otherwise (Landau and Lishitz, 1977). For a van der\n        Waals-like potential $(n = 6)$, only $l = 0$ (s-wave) matters at low energies. Whats with $l=0$? Lifschitz is a typo?\n        \\item In the notes: eq. 1.8 to 1.9 the commutator $[\\psi, \\psi^{\\dagger}]$ was used, but from 1.9 to 1.10 Bogoliubov aproximation was used, why not directly on 1.8 ?\n        \\item What is the derivation of 1.11? Its a FFT, but what are the xact steps?\n        \\item What are the python packages to use operators like $\\hat{\\psi}$? There is some sympy implementation, but probably there is a better one?\n        \\item how to get from 1.11 to 1.12? Is it a commutator expansion? Why $q$ is disappearing?\n        \\item In 1.17 $\\omega_{\\rho}$ part has a factor 2, but $\\omega_{z}$ not, despite beeing symmetric in $\\psi$. Why?\n        \\item What is variable $a$? Why should $a > 0$ as repulsive short-range interactions stabilize the BEC (p.10)?\n        \\item ``When the atomic density grows due to the attractive interaction, three-body losses predominantly occur in the high-density region. '' What does three-body losses mean?\n        \\item ``As the collapse occurs mainly in the x-y direction due to anisotropy of the DDI (in the absence of inelastic losses, the condensate would indeed become an infinitely thin cigar-shaped cloud along z),\n        and therefore the condensate explodes essentially radially, producing the anisotropic\n        shape of the cloud.'' Why is the collaps not along z axis?\n        \\item How are the regions stable, metastable, unstable derived in Figure 1.5, here Figure \\ref{fig:acrit}?\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{IMAGE/acrit.png}\\\\\n    \\caption{Logo}\n    \\textsc{Santos}, \\emph{title} (year)\n    \\label{fig:acrit}\n\\end{figure}\n\n\\begin{itemize}\n        \\item Typo in ``we obtain a 1D equation similar to the a GP equation'', just the or a\n        \\item ``ground-state wave-function is independent of the in-plane coordinates '' Why?\n        \\item 1.26 to 1.27, where does the $U_{dd}$ go?\n        \\item Typo If: ``roton momentum. if this were so''\n        \\item Why should a modulation with a finite wavelength allow superfluids?\n        \\item Typo repeatance: ``the width of the width''\n        \\item What are the spin-F matrizes?\n        \\item Is the occurance of these spin textures in Figure \\ref{fig:helical} special?\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{IMAGE/helical.png}\\\\\n    \\caption{Is the occurance of these textures special?}\n    \\textsc{Santos}, \\emph{title} (year)\n    \\label{fig:helical}\n\\end{figure}\n\n\\subsection{Summary}\n\\begin{itemize}\n        \\item dipol-dipol interaction (DDI): \\begin{equation}\n          U(r) = \\underbrace{g \\delta (r)}_{\\frac{4 \\pi \\hbar^{2} a(d) \\delta(r)}{m}} + \\underbrace{U_{dd}(r)}_{\\frac{C_{dd}}{4 \\pi} \\frac{(e_{1} \\cdot e_{2}) r^{2} - 3(e_{1} \\cdot r) (e_{2} \\cdot r)}{r^{5}}}\n        \\end{equation}\n        \\item Use pseudo potential as dipol-dipol interaction is anisotropic and all partial wave (different l) mix\n        \\item coupling of different channels generates short-range contribution in the s-channel $s=0$ $\\Rightarrow$ by changing DDI strength $a$ gets modified too $\\Rightarrow$ shape resonances $\\Rightarrow$ virtual state transform into a new ground state\n        \\item for fermions s-channel does not exists, so just long-range\n        \\item FFT of $U_{dd}$ using sperical harmonics $Y_{lm}$ gives:\n        \\begin{equation}\n          \\tilde{U_{dd}}(k) = \\int \\mathrm{d^{r} r} U_{dd}(r) e^{-ik \\cdot r}= \\frac{C_{dd}}{3}\\left(3 \\cos^{2}(\\theta_{k}) - 1 \\right)\n        \\end{equation}\n        \\item Use DDI in Gross-Pitajevski Equation, FFT, approximate to 2nd order, diagonalize with Bogoliubov transform\n        \\item As a result the square root can be imaginary, so the BEC gets dynamically unstable for long-wave length (phonon-instability):\n            \\begin{align}\n              \\epsilon(p) &= \\sqrt{\\frac{p^{2}}{2m} \\left[\\frac{p^{2}}{2m} + 2 n_{0} \\left( g + \\tilde{U_{dd}(p)} \\right)\\right]} \\\\\n              &= p c_{s} \\sqrt{1 + \\epsilon_{dd} \\left( 3 \\cos^{2} \\theta_{p} - 1 \\right)} \\\\\n              &\\underset{p \\rightarrow 0}{=} p c_{s} \\sqrt{1 - \\epsilon_{dd}}\n            \\end{align}\n        \\item For dipolar BEC the trap geometry is crucial (for non-dipolar not)\n        \\item ``pancake traps'' can stabilize the phonon-instability\n        \\item qualitative features for $a_{crit}(\\lambda)$ by gaussian ansatz, for exact numerical solution non-local Gross-Pitaevskii Equation needed\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{IMAGE/stability.png}\\\\\n    \\caption{Logo}\n    \\textsc{Santos}, \\emph{title} (year)\n    \\label{fig:stability}\n\\end{figure}\n\n\\begin{itemize}\n        \\item for sufficiently strong interactions, we may neglect quantum pressure, and consider the Thomas-Fermi (TF) regime\n        \\item TF solution for the trapped BEC has the same inverted parabola shape (as in non-dipolar case)\n        \\item BEC is prolat for $0 < \\kappa < 1$ and $1 < \\kappa$ oblat\n        \\item Bogoliubov-de Gennes Equation shows that the nonlocal character of the DDI causes a momentum dependend coupling constant, leading to a roton-like dispersion law, leading to dynamically instability, when the roton $\\beta = \\frac{g_{d}}{g}$ touches zero (experimetally not obeserved yet)\n        \\item by varying the density, the frequency of the confinement, and the short-range coupling,\n        one can control the spectrum (roton minimum deeper/shallower)\n        \\item sequence of the non-local non-linearity 2D bright solitary waves may become stable\nunder appropriate conditions (Pedri and Santos, 2005)\n        \\item two instability regions for 2D solitons (against col-\n        lapse and against unlimited expansion)\n  \\item $\\tilde{g}_{cr}(\\beta) \\equiv \\frac{g N_{cr}}{2 \\pi l_{z}}$, so stable 2D anisotropic self-localised solitons exists just for $N < N_{cr}$\n        \\item non-dipolar BECs scatter elastically, the scattering of dipolar solitons is inelastic due to the lack integrability\n        \\item The solitons may transfer centre-of-mass energy into internal vibrational modes,\n        resulting in intriguing scattering properties:\n\n        \\begin{itemize}\n          \\item including soliton fusion (Fig. 1.8)\n          \\item appearance of strong inelastic resonances\n          \\item possibility of observing 2D- soliton spiraling as that already observed in photo-refractive materials\n        \\end{itemize}\n\n        \\item Dipolar effects in spinor condensates\n        \\begin{itemize}\n            \\item spinor BECs: we focus on an effect which resembles the Einstein-de Haas effect\n            \\item Because of Zeeman sub-levels short-range interactions may occur in different s-wave scattering channels with different total angular momentum (for bosons even number) ( spin-1 bosons we have just F = 0 and F = 2)\n            \\item Each scattering channel has an associated s-wave scattering length $a_{F}$\n            \\item short-range interactions necessarily preserve the spin projection Sz\n            \\item DDI does not necessarily conserve the spin projection along the quantisation axis as DDI is anisotropic\n            \\item for initially maximally stretched state ($m_{F} =  - F$)\n            \\item short-range interactions cannot induce any spinor dynamics (due to conservation of total magnetisation $S_{z}$\n            \\item DDI may induce a transfer to $m_{F} + 1$\n            \\item for cylindrical symmetry around the quantisation axis, this violation of the spin projection is accompanied by a transfer of angular momentum to the centre of mass, resembling the well known Einstein-de Haas effect $\\Rightarrow$ initially spin-polarised dipolar condensate can generate dynamically vorticity\n            \\item Einstein-de Haas effect is destroyed by weak magnetic fields (1 mG)\n            \\item the dominant Larmor precession, and invoking rotating-wave-approximation arguments, the physics must be constrained to manifolds of preserved magnetisation (2D optical lattices could help)\n            \\item Effect of DDI could be even observable under conserved $S_{z}$ (alkali spinor condensates)\n            \\item spin-changing collisions: collisions that conserve $S_{z}$, but do not conserve the relative population of the different Zeeman components\n            \\item Spin-changing collisions are characterised by an energy scale proportional\nto the difference between scattering lengths at different channels\n            \\item this difference is very small, so can be significantly modified by the presence of other small energy scales (DDI) $\\Rightarrow$ helical spin textures\n        \\end{itemize}\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{IMAGE/acrit.png}\\\\\n    \\caption{Logo}\n    \\textsc{Santos}, \\emph{title} (year)\n    \\label{fig:acrit}\n\\end{figure}\n\n\\begin{itemize}\n        \\item Typo in ``we obtain a 1D equation similar to the a GP equation'', just the or a\n        \\item ``ground-state wave-function is independent of the in-plane coordinates '' Why?\n        \\item 1.26 to 1.27, where does the $U_{dd}$ go?\n        \\item Typo If: ``roton momentum. if this were so''\n        \\item Why should a modulation with a finite wavelength allow superfluids?\n        \\item Typo repeatance: ``the width of the width''\n        \\item What are the spin-F matrizes?\n        \\item Is the occurance of these spin textures in Figure \\ref{fig:helical} special?\n\\end{itemize}\n\n\\section{Supersolids}\n\n\\begin{itemize}\n    \\item supersolid: features both the crystalline structure of a solid and the frictionless flow of a superfluid\nIn this state, every constituent atom is part of the solid and the superfluid simultaneously\n    \\item direct observation was limited to systems where the structure formation was mediated by external light fields\n    \\item beyond mean-field approximation leads to corrections to the ground\nstate energy stemming from quantum fluctuations of the collective modes in a BEC (LHY-correction)\n    \\item In 2018 quantum droplets in a Bose-Bose mixture were observed\n    \\item mean- field energy depends on the difference of the two coupling constants $\\delta(g) = |g_{rep}| - |g_{att}|$ \\item LHY-correction depends on the individual coupling constants\n    \\item For weakly attractive combination of interactions, a repulsive beyond mean-field correction can stabilize the BEC\n    \\item after a peak density increasing the number of particles only leads to an increase in the\nsize of the droplet\n    \\item eGPE: kinetic energy, external trapping, and two-body interactions, LHY\n    \\item beyond mean-field correction has only been calculated for a homogeneous system and can therefore only be included within a local-density approximation\n    \\item QMC calculations in full many-body system verified the formation\n    \\item intra-species scattering lengths $a_{11}$ and $a_{22}$ lead to different equilibrium densities $n^{(i)}_{0}$ for the two components of the mixture.\n    \\item droplet forms an intrinsic imbalance in the atom numbers of the two components ($\\frac{N1}{N2} = \\sqrt{\\frac{a_{22}}{a_{11}}}$ )\n    \\item larger density than in original BEC increases the rate of three-body loss $\\Rightarrow$ extra term in eGPE\n\\end{itemize}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{IMAGE/droplet.png}\\\\\n    \\caption{Peak density of the droplet saturates in z-driection}\n    \\textsc{Santos}, \\emph{title} (year)\n    \\label{fig:droplet}\n\\end{figure}\n", "meta": {"hexsha": "22843b7e7c8c413c0188988071c557390f912d5c", "size": 11915, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "text.tex", "max_stars_repo_name": "LuisSantosSanchez/supersolids_notes", "max_stars_repo_head_hexsha": "bc4f35a82e58046a019ffb9260719c36f33de1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "text.tex", "max_issues_repo_name": "LuisSantosSanchez/supersolids_notes", "max_issues_repo_head_hexsha": "bc4f35a82e58046a019ffb9260719c36f33de1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "text.tex", "max_forks_repo_name": "LuisSantosSanchez/supersolids_notes", "max_forks_repo_head_hexsha": "bc4f35a82e58046a019ffb9260719c36f33de1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.4770114943, "max_line_length": 325, "alphanum_fraction": 0.7011330256, "num_tokens": 3169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177487, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.41112470406106505}}
{"text": "% !TeX root = ../main.tex\n\n\\section{Data set}\nThe Epinions data set \\citep{Massa} is a very good case to demonstrate the Recursive\nK-Nearest Neighbors algorithm because of its sparsity. As demonstrated in \\autoref{chap:3},\nthis algorithm manages to overcome the limitations of the conventional KNN algorithm, which\ncannot make predictions for ratings with no direct associations to other users or items.\nThis dataset consists of 40163 users and 139738 items and 664824 ratings.\nAs we mentioned previously, the sparsity percentage is 0,99988154.\nThe structure of the dataset is shown in the table below:\n\\begin{table}[H]\n\\centering\n\\caption{Epinions Dataset Sample}\n\\label{table:Epinions_sample}\n\\begin{tabular}{ |c|c|c| }\n\\hline\n\\textbf{user} & \\textbf{item} & \\textbf{Rating} \\\\\n\\hline\n36153 & 62461 & 5 \\\\\n\\hline\n427 & 38005 & 5  \\\\\n\\hline\n751 & 53361 & 4 \\\\\n\\hline\n11001 & 118950 & 4 \\\\\n\\hline\n1169 & 66176 & 5 \\\\\n\\hline\n9808 & 84459 & 2 \\\\\n\\hline\n85 & 7446 & 4 \\\\\n\\hline\n14717 & 3397 & 2 \\\\\n\\hline\n\\end{tabular}\n\\end{table}\nThe user and item columns contain the ids of users and items respectively, and the rating\ncolumn contains the rating of a user to an item. To test the accuracy of\nKNN and Recursive-KNN algorithms this ratings matrix was split in a\ntrain set and a test set. The train set is used so the algorithms can learn the\npatterns of the data. Either how users rate or how items are being rated.\nThe similarity metrics discussed in \\autoref{chap:2} will be computed based on\nthe train set and the rating predictions will be calculated based on this set's\nratings. The rating predictions will be both user-based and item based.\nThe test set is used to evaluate the rating predictions produced by the trained algorithms\nto this set using an aggregating error function between the predictions\nand the truth values. The train set consists of 520203\nratings(78\\%) and the test set consists of 144621 ratings(22\\%). The train\nset is stratified by users, which means that it contains a proportion of each\nuser's ratings. Below there are some descriptive information about the Epinions dataset and the splitting method.\n\\begin{table}[H]\n\\centering\n\\caption{Epinions Descriptive}\n\\label{table:epinions_descriptive}\n\\begin{tabular}{ |c|c|c|c| }\n\\hline\n&\\textbf{Ratings Matrix} & \\textbf{Train} & \\textbf{Test}\\\\\n\\hline\ncount & 664824 & 520203 & 144621\\\\\n\\hline\nmean & 3.9917 & 3.99 & 3.9975\\\\\n\\hline\nstd & 1.2068 & 1.2072 & 1.2053\\\\\n\\hline\nmin & 1 & 1 & 1\\\\\n\\hline\n25\\% & 3 & 3 & 3\\\\\n\\hline\n50\\% & 4 & 4 & 4\\\\\n\\hline\n75\\% & 5 & 5 & 5\\\\\n\\hline\nmax & 5 & 5 & 5\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\nIn the subsections below we present some basic descriptive information about each of the similarity\nmethods and in \\autoref{sec:4.3} we will present the best result from the\nrating predictions.\n\n\\subsection{Cosine Similarity}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{chapter_4/boxplots/cosine/cosine_boxplot.jpg}\n\\caption{Cosine Similarity Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:cosine_similarity_boxplot}\n\\end{figure}\n\nBoth item and user similarity values have a minimum value near zero.The items' right whisker value is\naround 0.8 and the users' around 0.18. Both items and users similarity outliers seem to reach the value of 1.\nAlso the number of outliers in item cosine appears significantly lower than that of the users.\nAt least 75\\% of users similarities are lower than 0.1. In contrast, at least 50\\% of\nitem similarities are larger than 0.1 and at least 25\\% are larger than 0.35.\n\n\\begin{table}[H]\n\\centering\n\\caption{Cosine Similarity Descriptive}\n\\label{table:cosine_similarity_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n\t\t  & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 14614164       & 18672616       \\\\ \\hline\nmean      & 0.063717709    & 0.2590515005   \\\\ \\hline\nstd       & 0.0852396246   & 0.2948759498   \\\\ \\hline\nmin       & 0.0001118907   & 0.0001876405   \\\\ \\hline\n25\\%      & 0.0184512236   & 0.0467473495   \\\\ \\hline\n50\\%      & 0.0389925088   & 0.1290322581   \\\\ \\hline\n75\\%      & 0.0758098044   & 0.3638034376   \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 26742          & 1519527        \\\\ \\hline\nmin count & 1              & 1              \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Cosine Similarity Count Descriptive}\n\\label{table:cosine_similarity_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 39156           & 121140         \\\\ \\hline\nmean      & 746.4584737971  & 308.281591547  \\\\ \\hline\nstd       & 1174.5013754664 & 666.5799806645 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 40              & 37             \\\\ \\hline\n50\\%      & 246             & 120            \\\\ \\hline\n75\\%      & 944             & 338            \\\\ \\hline\nmax       & 13843           & 31057          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 793             & 545            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Modified Cosine Similarity}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.9\\textwidth]{chapter_4/boxplots/modified_cosine/modified_cosine_boxplot.jpg}\n\\caption{Modified Cosine Similarity Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:modified_cosine_similarity_boxplot}\n\\end{figure}\n\nModified cosine similarity seems to have the same effect in the values for both items\nand users. Both these boxplots have the majority of their values at 1. Their minimum values\nare a little less than 0.4. Any value other than 1 can be interpreted as an outlier.\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Cosine Similarity Descriptive}\n\\label{table:modified_cosine_similarity_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 14614164       & 18672616       \\\\ \\hline\nmean      & 0.9923727737   & 0.9970178776   \\\\ \\hline\nstd       & 0.0345699768   & 0.0205710501   \\\\ \\hline\nmin       & 0.3846153846   & 0.3846153846   \\\\ \\hline\n25\\%      & 1              & 1              \\\\ \\hline\n50\\%      & 1              & 1              \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 12887451       & 17728374       \\\\ \\hline\nmin count & 1170           & 263            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Cosine Similarity Count Descriptive}\n\\label{table:modified_cosine_similarity_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 39156           & 121140         \\\\ \\hline\nmean      & 746.4584737971  & 308.281591547  \\\\ \\hline\nstd       & 1174.5013754664 & 666.5799806645 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 40              & 37             \\\\ \\hline\n50\\%      & 246             & 120            \\\\ \\hline\n75\\%      & 944             & 338            \\\\ \\hline\nmax       & 13843           & 31057          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 793             & 545            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Adjusted Cosine Similarity}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/adjusted_cosine/adjusted_cosine_boxplot.jpg}\n\\caption{Adjusted Cosine Similarity Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:adjusted_cosine_similarity_boxplot}\n\\end{figure}\n\nAdjusted cosine similarity seems to have distributed the values both for users and items very well.\nThere are no outliers for either of these boxplots. Although, items have at least 50\\% of their\nvalues at 1, users have at least 50\\% of their values over 0.7. They both have their minimum\nvalue at -1.\n\n\\begin{table}[H]\n\\centering\n\\caption{Adjusted Cosine Similarity Descriptive}\n\\label{table:adjusted_cosine_similarity_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 14547343       & 18578462       \\\\ \\hline\nmean      & 0.073856558    & 0.09784622     \\\\ \\hline\nstd       & 0.9611564664   & 0.9793750112   \\\\ \\hline\nmin       & -1             & -1             \\\\ \\hline\n25\\%      & -1             & -1             \\\\ \\hline\n50\\%      & 0.7255719661   & 1              \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 6998746        & 9729527        \\\\ \\hline\nmin count & 5753489        & 7845237        \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Adjusted Cosine Similarity Count Descriptive}\n\\label{adjusted_cosine_similarity_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 38302           & 119634         \\\\ \\hline\nmean      & 759.6127095191  & 310.5883277329 \\\\ \\hline\nstd       & 1179.0168839062 & 666.8475091836 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 45              & 39             \\\\ \\hline\n50\\%      & 260             & 123            \\\\ \\hline\n75\\%      & 968             & 340            \\\\ \\hline\nmax       & 13798           & 30920          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 569             & 398            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Modified Adjusted Cosine Similarity}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/modified_adjusted_cosine/modified_adjusted_cosine_boxplot.jpg}\n\\caption{Modified Adjusted Cosine Similarity Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:modified_adjusted_cosine_similarity_boxplot}\n\\end{figure}\n\nThe modification used in adjusted cosine similarity seems to have enclosed the values near zero.\nTheir median is aligned very close to zero. The whiskers for items are around -0.4 and 0.4\nfor left and right respectively. For users, the whiskers are around -0.12 and 0.12 for left and right\nrespectively. Items similarities behave like a wider version of users similarities, probably\nbecause items are more than twice the size of users which allows them to form a wider range of\ndifferent similarities.\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Adjusted Cosine Similarity Descriptive}\n\\label{table:modified_adjusted_cosine_similarity_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 14547343       & 18578462       \\\\ \\hline\nmean      & 0.0004873924   & 0.0165982167   \\\\ \\hline\nstd       & 0.1313835099   & 0.398039276    \\\\ \\hline\nmin       & -1             & -1             \\\\ \\hline\n25\\%      & -0.0280684821  & -0.0701974943  \\\\ \\hline\n50\\%      & 0.0012377237   & 0.0033406502   \\\\ \\hline\n75\\%      & 0.029188451    & 0.096874534    \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 17005          & 863028         \\\\ \\hline\nmin count & 11891          & 679602         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Adjusted Cosine Similarity Count Descriptive}\n\\label{table:modified_adjusted_cosine_similarity_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 38302           & 119634         \\\\ \\hline\nmean      & 759.6127095191  & 310.5883277329 \\\\ \\hline\nstd       & 1179.0168839062 & 666.8475091836 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 45              & 39             \\\\ \\hline\n50\\%      & 260             & 123            \\\\ \\hline\n75\\%      & 968             & 340            \\\\ \\hline\nmax       & 13798           & 30920          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 569             & 398            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Pearson Correlation Coefficient}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/pearson/pearson_boxplot.jpg}\n\\caption{Pearson Correlation Coefficient Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:pearson_corr_coef_boxplot}\n\\end{figure}\n\nThe similarities formed using the Pearson correlation coefficient seem well distributed across\nthe range -1 to 1. No outliers exist in both users and items. In the users' boxplot at least 50\\% of the\nvalues appear to be near 1. In the items' boxplot at least 50\\% of the values are over 0.8. The\nminimum value for both of the similarities is at -1.\n\n\\begin{table}[H]\n\\centering\n\\caption{Pearson Correlation Coefficient Descriptive}\n\\label{table:pearson_corr_coef_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 12801832       & 9114131        \\\\ \\hline\nmean      & 0.2437009881   & 0.0973284577   \\\\ \\hline\nstd       & 0.9285318435   & 0.9625193963   \\\\ \\hline\nmin       & -1             & -1             \\\\ \\hline\n25\\%      & -1             & -1             \\\\ \\hline\n50\\%      & 1              & 0.940706152    \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 6825146        & 4489219        \\\\ \\hline\nmin count & 4163467        & 3678485        \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Pearson Correlation Coefficient Count Descriptive}\n\\label{table:pearson_corr_coef_boxplot}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 26166           & 40409          \\\\ \\hline\nmean      & 978.5089046855  & 451.0941126977 \\\\ \\hline\nstd       & 1227.2905909627 & 753.2523780236 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 148             & 90             \\\\ \\hline\n50\\%      & 507             & 222            \\\\ \\hline\n75\\%      & 1353            & 500            \\\\ \\hline\nmax       & 12486           & 17515          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 89              & 16             \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Pearson Modification 1}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/modified_pearson_1/modified_pearson_1_boxplot.jpg}\n\\caption{Modified Pearson 1 Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:modified_pearson_1_boxplot}\n\\end{figure}\n\nThe minimum value for both users and items similarities is at -1. Users have at least 50\\% of their\nvalues over 0.8 and at least 25\\% at 1. Items' median is around 0.4. Items also seem to have\na 25\\% of their value at 1. Both have their minimum at -1. At least 25\\% of the similarities\nfor both users and items are negative.\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Pearson 1 Descriptive}\n\\label{table:modified_pearson_1_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 1161526        & 560066         \\\\ \\hline\nmean      & 0.3619158933   & 0.1343440987   \\\\ \\hline\nstd       & 0.8153387654   & 0.8305601334   \\\\ \\hline\nmin       & -1             & -1             \\\\ \\hline\n25\\%      & -0.5           & -0.8703882798  \\\\ \\hline\n50\\%      & 0.8947368421   & 0.3942210015   \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 529709         & 184408         \\\\ \\hline\nmin count & 227880         & 133046         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Pearson 1 Count Descriptive}\n\\label{modified_pearson_1_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 19566          & 25208          \\\\ \\hline\nmean      & 118.7290197281 & 44.4355760076  \\\\ \\hline\nstd       & 266.6999446542 & 153.5700823656 \\\\ \\hline\nmin       & 1              & 1              \\\\ \\hline\n25\\%      & 5              & 2              \\\\ \\hline\n50\\%      & 23             & 6              \\\\ \\hline\n75\\%      & 105            & 24             \\\\ \\hline\nmax       & 5003           & 5401           \\\\ \\hline\nmax count & 1              & 1              \\\\ \\hline\nmin count & 2066           & 5234           \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\n\\subsection{Pearson Modification 2}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/modified_pearson_2/modified_pearson_2_boxplot.jpg}\n\\caption{Modified Pearson 2 Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:modified_pearson_2_boxplot}\n\\end{figure}\n\nAt a first glance, these boxplots look very similar to \\autoref{figure:modified_adjusted_cosine_similarity_boxplot}.\nThis is probably because the modification in both cases was to include the entire vectors in the\ndenominator (see \\autoref{eq:modified_adjusted_cosine} and \\autoref{eq:pearson_2}). Both boxplots have\ntheir median near zero. They both have many outliers that spread both left and right of the boxes with\nminimum value at -1 and maximum at 1. The whiskers are around -0.2 to -0.15 from the left\nside and 0.15 to 0.2 from the right side.\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Pearson 2 Descriptive}\n\\label{table:modified_pearson_2_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 12801832       & 9114131        \\\\ \\hline\nmean      & 0.0218434042   & 0.0101521404   \\\\ \\hline\nstd       & 0.089326644    & 0.1385987076   \\\\ \\hline\nmin       & -1             & -1             \\\\ \\hline\n25\\%      & -0.0093795851  & -0.0251329949  \\\\ \\hline\n50\\%      & 0.0076098072   & 0.0037092894   \\\\ \\hline\n75\\%      & 0.0367446145   & 0.0372677996   \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 3              & 710            \\\\ \\hline\nmin count & 2              & 412            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Modified Pearson 2 Count Descriptive}\n\\label{table:modified_pearson_2_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 26166           & 40409          \\\\ \\hline\nmean      & 978.5089046855  & 451.0941126977 \\\\ \\hline\nstd       & 1227.2905909627 & 753.2523780236 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 148             & 90             \\\\ \\hline\n50\\%      & 507             & 222            \\\\ \\hline\n75\\%      & 1353            & 500            \\\\ \\hline\nmax       & 12486           & 17515          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 89              & 16             \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{MSD}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/msd/msd_boxplot.jpg}\n\\caption{MSD Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:msd_boxplot}\n\\end{figure}\n\nThe minimum similarity value for both users and items is very close to zero. Their median\nis around 1 and 75\\% of the similarities are below 2. They both have a lot of outliers that\nreach a score around 15. Item similarity has some more extreme outliers that are very close to 25.\n\n\\begin{table}[H]\n\\centering\n\\caption{MSD Descriptive}\n\\label{table:msd_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 9805108        & 12434536       \\\\ \\hline\nmean      & 0.6661864961   & 0.6544694584   \\\\ \\hline\nstd       & 0.5256923021   & 0.4628208708   \\\\ \\hline\nmin       & 0.0625         & 0.0625         \\\\ \\hline\n25\\%      & 0.25           & 0.25           \\\\ \\hline\n50\\%      & 1              & 1              \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 13             & 25             \\\\ \\hline\nmax count & 1              & 1              \\\\ \\hline\nmin count & 598720         & 800571         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{MSD Count Descriptive}\n\\label{msd_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 38442          & 120382         \\\\ \\hline\nmean      & 510.1247593778 & 206.5846388995 \\\\ \\hline\nstd       & 850.5223750077 & 484.7004513454 \\\\ \\hline\nmin       & 1              & 1              \\\\ \\hline\n25\\%      & 25             & 22             \\\\ \\hline\n50\\%      & 156            & 72             \\\\ \\hline\n75\\%      & 613            & 213            \\\\ \\hline\nmax       & 11014          & 23589          \\\\ \\hline\nmax count & 1              & 1              \\\\ \\hline\nmin count & 1182           & 1563           \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{MAD}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/mad/mad_boxplot.jpg}\n\\caption{MAD Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:mad_boxplot}\n\\end{figure}\n\nAs expected, mean absolute difference boxplots are very similar to that of mean squared difference\n\\autoref{figure:msd_boxplot}. It is clear that the boxes have shrunk, due to the\nfact that MAD uses the absolute values instead of the squared ones and this modification\nlowers the standard deviation between the similarities.\n\n\\begin{table}[H]\n\\centering\n\\caption{MAD Descriptive}\n\\label{table:mad_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 9805108        & 12434536       \\\\ \\hline\nmean      & 0.7962500349   & 0.7668765592   \\\\ \\hline\nstd       & 0.4338056858   & 0.3639417506   \\\\ \\hline\nmin       & 0.25           & 0.25           \\\\ \\hline\n25\\%      & 0.5            & 0.5            \\\\ \\hline\n50\\%      & 1              & 1              \\\\ \\hline\n75\\%      & 1              & 1              \\\\ \\hline\nmax       & 13             & 25             \\\\ \\hline\nmax count & 1              & 1              \\\\ \\hline\nmin count & 598720         & 800571         \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{MAD Count Descriptive}\n\\label{table:mad_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & users          & items          \\\\ \\hline\ncount     & 38442          & 120382         \\\\ \\hline\nmean      & 510.1247593778 & 206.5846388995 \\\\ \\hline\nstd       & 850.5223750077 & 484.7004513454 \\\\ \\hline\nmin       & 1              & 1              \\\\ \\hline\n25\\%      & 25             & 22             \\\\ \\hline\n50\\%      & 156            & 72             \\\\ \\hline\n75\\%      & 613            & 213            \\\\ \\hline\nmax       & 11014          & 23589          \\\\ \\hline\nmax count & 1              & 1              \\\\ \\hline\nmin count & 1182           & 1563\t\t\t\\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\subsection{Jaccard Coefficient}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_4/boxplots/jaccard/jaccard_boxplot.jpg}\n\\caption{Jaccard Boxplot (Whiskers= -+1.5IQR)}\n\\label{figure:jaccard_boxplot}\n\\end{figure}\n\nBoth item and user similarity values have a minimum value near zero. The items' right whisker value is\naround 0.45 and for the users around 0.04. Both items and users similarity outliers appear to reach the value\n1. Also the number of outliers in item cosine seems significantly lower than users. At least 75\\% of\nusers similarities are lower than 0.1. In contrast, at least 25\\% of item similarities are larger than 0.2.\nUsers' boxplot is very narrow which indicates that 50\\% of the values are very close to each other. It\ncovers a range of merely 0.02. On the other hand, the items' boxplot is relatively wider. It covers a range of about 0.19,\nwhich confirms the wider spread of the values.\n\n\\begin{table}[H]\n\\centering\n\\caption{Jaccard Descriptive}\n\\label{table:jaccard_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users} & \\textbf{items} \\\\ \\hline\ncount     & 14614164       & 18672616       \\\\ \\hline\nmean      & 0.0307346429   & 0.1733928584   \\\\ \\hline\nstd       & 0.0544456926   & 0.2779653358   \\\\ \\hline\nmin       & 0.0006485084   & 0.0006060606   \\\\ \\hline\n25\\%      & 0.0112359551   & 0.0153846154   \\\\ \\hline\n50\\%      & 0.0196078431   & 0.0476190476   \\\\ \\hline\n75\\%      & 0.0344827586   & 0.2            \\\\ \\hline\nmax       & 1              & 1              \\\\ \\hline\nmax count & 26746          & 1522328        \\\\ \\hline\nmin count & 1              & 1              \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Jaccard Count Descriptive}\n\\label{table:jaccard_count_descriptive}\n\\begin{tabular}{|c|c|c|}\n\\hline\n          & \\textbf{users}  & \\textbf{items} \\\\ \\hline\ncount     & 39156           & 121140         \\\\ \\hline\nmean      & 746.4584737971  & 308.281591547  \\\\ \\hline\nstd       & 1174.5013754664 & 666.5799806645 \\\\ \\hline\nmin       & 1               & 1              \\\\ \\hline\n25\\%      & 40              & 37             \\\\ \\hline\n50\\%      & 246             & 120            \\\\ \\hline\n75\\%      & 944             & 338            \\\\ \\hline\nmax       & 13843           & 31057          \\\\ \\hline\nmax count & 1               & 1              \\\\ \\hline\nmin count & 793             & 545            \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\n\\section{Evaluation Metrics}\nThe accuracy of the predictions is one of the most important goals in recommender\nsystems as it gives more chances that the prediction will be relevant to the\nuser. As discussed in \\autoref{chap:1} other goals include the novelty of the\nrecommendations, serendipity and diversity. In this thesis the focus is\non the accuracy of the predictions. Four metrics will be discussed to evaluate the\nRecursive Nearest Neighbors algorithm on the Epinions dataset.\n\\subsection{Root Mean Squared Error (RMSE)}\nRMSE is one of the most popular accuracy estimators.\nIt sums the squared error between the true and estimated value divided by the\nnumber of the predictions the model was able to extract. Finally it is square\nrooted so that the error corresponds to units of ratings instead of square\nunits. \\citep{Ricci}\n$$RMSE = \\sqrt{\\frac{\\sum_{(u,i) \\in \\mathcal{T}(r_{u,i} - \\hat{r}_{u,i})^2}}{n}}$$\nwhere,\n\\begin{itemize}\n\t\\item[] $\\mathcal{T}$ is the test set\n\t\\item[] $r_{u,i}$ is the true rating of user $u$ to item $i$ in $\\mathcal{T}$\n\t\\item[] $\\hat{r}_{u,i}$ is the rating prediction for user $u$ to item $i$\n\t\\item[] $n$ is the number of predictions\n\\end{itemize}\n\n\\subsection{Mean Absolute Error (MAE)}\nMAE is another popular metric for accuracy estimation. It sums the absolute\nvalue between the difference between the true and estimated ratings\ndivided by the number of predictions. \\citep{Ricci}\n$$MAE = \\frac{\\sum_{(u,i) \\in \\mathcal{T}\\left|r_{u,i} - \\hat{r}_{u,i}\\right|}}{n}$$\nwhere,\n\\begin{itemize}\n\t\\item[] $\\mathcal{T}$ is the test set\n\t\\item[] $r_{u,i}$ is the true rating of user $u$ to item $i$ in $\\mathcal{T}$\n\t\\item[] $\\hat{r}_{u,i}$ is the rating prediction for user $u$ to item $i$\n\t\\item[] $n$ is the number of predictions\n\\end{itemize}\n\n\\subsection{Mean Absolute User Error (MAUE)}\nWhile RMSE and MAE estimate the global error to the system MAUE first\ncalculates the MAE score for each user then averages all user errors to find\nhow much the system diverges on average from each user \\citep{Massa}.\n$$MAUE = \\frac{1}{n}\\sum_{u \\in \\mathcal{T}}\\frac{\\sum_{i \\in \\mathcal{I}_u\\mathopen|r_{u,i} - \\hat{r}_{u,i}\\mathclose|}}{n_u}$$\nwhere,\n\\begin{itemize}\n\t\\item[] $\\mathcal{T}$ is the test set\n\t\\item[] $r_{u,i}$ is the true rating of user $u$ to item $i$ in $\\mathcal{T}$\n\t\\item[] $\\hat{r}_{u,i}$ is the rating prediction for user $u$ to item $i$\n\t\\item[] $n_u$ is the number of predictions for user $u$\n\t\\item[] $n$ is the number of users for whom predictions were made for\n\\end{itemize}\n\\subsection{Root Mean Squared User Error (RMSUE)}\nLike in MAUE, the equation for RMSE can be used to produce a per user rmse estimate.\nIn this metric first the RMSE for every user is computed. Then the RMSEs of\nthe users are averaged to form the RMSUE score with is an estimate in the\nerror of the model per user of the dataset.\n$$RMSUE = \\frac{1}{n}\\sum_{u \\in \\mathcal{T}}\\sqrt{\\frac{\\sum_{i \\in \\mathcal{I}_u(y_{u,i} - \\hat{y}_{u,i})^2}}{n_u}}$$\nwhere,\n\\begin{itemize}\n\t\\item[] $\\mathcal{T}$ is the test set\n\t\\item[] $r_{u,i}$ is the true rating of user $u$ to item $i$ in $\\mathcal{T}$\n\t\\item[] $\\hat{r}_{u,i}$ is the rating prediction for user $u$ to item $i$\n\t\\item[] $n_u$ is the number of predictions for user $u$\n\t\\item[] $n$ is the number of users for whom predictions were made for\n\\end{itemize}\n\n\\section{Evaluation Results and Benchmarks}\\label{sec:4.3}\nFor this experiment item-based and user-based similarities discussed in \\autoref{chap:2} where used.\nAny similarity metrics that could contain\nnegative similarities, had those negative similarities excluded from the\ncomputations.\nFor the K-Nearest Neighbors, the following 22 different values\nof $\\mathcal{K}$ were used:\n$$\\mathcal{K} = [1, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]$$\nFor the Recursive K-Nearest Neighbors, as defined in the\nalgorithmic steps of \\autoref{chap:3}, 22 different values of $\\mathcal{M}$\nwere also used:\n$$\\mathcal{M} = [1, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]$$\n\nBelow, the best outcome based on each evaluation metric for user-based and\nitem-based CF will be presented. The combined errors for KNN and Recursive-KNN\nfor RMSE and MAE below are computed using these formulas:\n\\begin{itemize}\n\t\\item[] \\textbf{Total RMSE:}\n\t$$RMSE_{Total} = \\sqrt{\\frac{n_{KNN}*RMSE_{KNN}^2 + n_{R-KNN}*RMSE_{R-KNN}^2}{n_{KNN} + n_{R-KNN}}}$$\n\twhere,\n\t\\begin{itemize}\n\t\t\\item[] $n_{KNN}$ is the number of predictions made using the KNN algorithm\n\t\t\\item[] $RMSE_{KNN}$ is the RMSE score using the KNN algorithm\n\t\t\\item[] $n_{R-KNN}$ is the number of predictions made using the Recursive KNN algorithm\n\t\t\\item[] $RMSE_{R-KNN}$ is the RMSE score using the Recursive KNN algorithm\n\t\\end{itemize}\n\t\\item[] \\textbf{Total MAE:}\n\t$$MAE_{Total} = \\frac{n_{KNN}*MAE_{KNN} + n_{R-KNN}*MAE_{R-KNN}}{n_{KNN} + n_{R-KNN}}$$\n\twhere,\n\t\\begin{itemize}\n\t\t\\item[] $n_{KNN}$ is the number of predictions made using the KNN algorithm\n\t\t\\item[] $MAE_{KNN}$ is the MAE score using the KNN algorithm\n\t\t\\item[] $n_{R-KNN}$ is the number of predictions made using the Recursive KNN algorithm\n\t\t\\item[] $MAE_{R-KNN}$ is the MAE score using the Recursive KNN algorithm\n\t\\end{itemize}\n\\end{itemize}\n\n\\autoref{chap:appendix_src} has a link to\nthe code written in Python(version 3.6) using the Anaconda distribution \\citep{anaconda}\nthat calculated the similarities, rating predictions\nand the errors. It also contains the train and test data, the \\LaTeX{} structure\nthat this thesis was build on and the numerical results.\n\\autoref{chap:appendix_results} contains all the plots produced by the\nnumerical results. All plots in this thesis were produced using the Matplotlib library\n\\citep{Hunter:2007}.\n\n\\subsection{User-Based}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_user_rmse.eps}\n\\caption{User-based Total RMSE Best Score}\n\\label{figure:user_best_total_rmse}\n\\end{figure}\nThe best RMSE score for user-based CF was produced using $\\mathcal{K}=100$ and $\\mathcal{M}=3$.\nThe exact RMSE score is 1.1604146071 and it was calculated based on 124433 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the modified cosine similarity(\\autoref{eq:modified_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_user_mae.eps}\n\\caption{User-based Total MAE Best Score}\n\\label{figure:user_total_mae}\n\\end{figure}\n\nThe best MAE score for user-based CF was produced using $\\mathcal{K}=50$ and $\\mathcal{M}=3$.\nThe exact MAE score is 0.854066176 and it was calculated based on 124433 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the jaccard coefficient(\\autoref{eq:jaccard})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/knn/User_RMSUE_KNN.eps}\n\\caption{User-based KNN RMSUE Scores}\n\\label{figure:User_knn_rmsue}\n\\end{figure}\n\nThe best KNN RMSUE score for user-based CF was produced using $\\mathcal{K}=100$.\nThe exact KNN RMSUE score is 1.0031145695 and it was calculated based on 100311 rating\npredictions(\\autoref{table:prediction_counters_by_sim})\nusing the modified cosine similarity(\\autoref{eq:modified_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_user_rmsue.eps}\n\\caption{User-based Recursive-KNN RMSUE Best Score}\n\\label{figure:User_rknn_rmsue}\n\\end{figure}\n\nThe best Recursive-KNN RMSUE score for user-based CF was produced using $\\mathcal{K}=100$ and $\\mathcal{M}=3$.\nThe exact Recursive-KNN RMSUE score is 0.9089525549 and it was calculated based on 24122 rating\npredictions(\\autoref{table:prediction_counters_by_sim})\nusing the modified cosine similarity(\\autoref{eq:modified_cosine})\nout of the 25061 pairs for which KNN was unable to find neighbors(\\autoref{table:users_log}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/knn/User_MAUE_KNN.eps}\n\\caption{User-based KNN MAUE Scores}\n\\label{figure:User_knn_maue}\n\\end{figure}\n\nThe best KNN MAUE score for user-based CF was produced using $\\mathcal{K}=50$.\nThe exact KNN MAUE score is 0.8819077974 and it was calculated based on 100311 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the cosine similarity(\\autoref{eq:cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_user_maue.eps}\n\\caption{User-based Recursive-KNN MAUE Best Score}\n\\label{figure:User_rknn_maue}\n\\end{figure}\n\nThe best Recursive-KNN MAUE score for user-based CF was produced using $\\mathcal{K}=75$ and \\\\$\\mathcal{M}=20$.\nThe exact Recursive-KNN MAUE score is 0.8558869566 and it was calculated based on 34392 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nout of the 36278 pairs for which KNN was unable to find neighbors(\\autoref{table:users_log}).\n\n\\subsection{Item-based}\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_item_rmse.eps}\n\\caption{Item-based Total RMSE Best Score}\n\\label{figure:Item_knn_rmse}\n\\end{figure}\n\nThe best RMSE score for item-based CF was produced using $\\mathcal{K}=100$ and $\\mathcal{M}=3$.\nThe exact RMSE score is 1.3155259043 and it was calculated based on 123115 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_item_mae.eps}\n\\caption{Item-based Total MAE Best Score}\n\\label{figure:Item_knn_mae}\n\\end{figure}\n\nThe best MAE score for item-based CF was produced using $\\mathcal{K}=100$ and $\\mathcal{M}=3$.\nThe exact MAE score is 0.9707211649 and it was calculated based on 123115 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/knn/Item_RMSUE_KNN.eps}\n\\caption{Item-based KNN RMSUE Scores}\n\\label{figure:Item_knn_rmsue}\n\\end{figure}\n\nThe best KNN RMSUE score for item-based CF was produced using $\\mathcal{K}=100$.\nThe exact KNN RMSUE score is 1.0328968801 and it was calculated based on 89800 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_item_rmsue.eps}\n\\caption{Item-based Recursive-KNN RMSUE Best Score}\n\\label{figure:Item_rknn_rmsue}\n\\end{figure}\n\nThe best Recursive-KNN RMSUE score for item-based CF was produced using $\\mathcal{K}=100$ and $\\mathcal{M}=3$.\nThe exact Recursive-KNN RMSUE score is 1.0367245756 and it was calculated based on 33315 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nout of the 35280 pairs for which KNN was unable to find neighbors(\\autoref{table:items_log}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/knn/Item_MAUE_KNN.eps}\n\\caption{Item-based KNN MAUE Scores}\n\\label{figure:Item_knn_maue}\n\\end{figure}\n\nThe best KNN MAUE score for item-based CF was produced using $\\mathcal{K}=30$.\nThe exact KNN MAUE score is 0.9318609947 and it was calculated based on 89800 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the modified adjusted cosine similarity(\\autoref{eq:modified_adjusted_cosine})\nfor the 144621 ratings in the test set(\\autoref{table:epinions_descriptive}).\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{chapter_4/evaluation/evaluation_item_maue.eps}\n\\caption{Item-based KNN MAUE Best Score}\n\\label{figure:Item_rknn_maue}\n\\end{figure}\n\nThe best Recursive-KNN MAUE score for item-based CF was produced using $\\mathcal{K}=90$ and $\\mathcal{M}=3$.\nThe exact Recursive-KNN MAUE score is 0.9864005988 and it was calculated based on 33315 rating predictions(\\autoref{table:prediction_counters_by_sim})\nusing the adjusted cosine similarity(\\autoref{eq:adjusted_cosine})\nout of the 35280 pairs for which KNN was unable to find neighbors(\\autoref{table:items_log}).\n\n\\subsection{Benchmarks}\n\\begin{table}[H]\n\\centering\n\\caption{Rating Predicted with KNN and Recursive-KNN}\n\\label{table:prediction_counters_by_sim}\n\\begin{tabular}{ccc|ccc|c}\n\\multicolumn{3}{c|}{\\textbf{USERS}}            & \\multicolumn{3}{c|}{\\textbf{ITEMS}}            &                          \\\\ \\cline{1-6}\n\\textbf{KNN} & \\textbf{R-KNN} & \\textbf{TOTAL} & \\textbf{KNN} & \\textbf{R-KNN} & \\textbf{TOTAL} & \\textbf{SIMILARITY}      \\\\ \\hline\n88379        & 34392          & 122771         & 89800        & 33315          & 123115         & Adjusted Cosine          \\\\\n\\textbf{100311}       & 24122          & \\textbf{124433}         & \\textbf{100311}       & 24122          & \\textbf{124433}         & Cosine                   \\\\\n\\textbf{100311}       & 24122          & \\textbf{124433}         & \\textbf{100311}       & 24122          & \\textbf{124433}         & Jaccard                  \\\\\n93924        & 29747          & 123671         & 94528        & 29203          & 123731         & MAD                      \\\\\n93924        & 29747          & 123671         & 94528        & 29203          & 123731         & MSD                      \\\\\n88379        & 34392          & 122771         & 89800        & 33315          & 123115         & Modified Adjusted Cosine \\\\\n\\textbf{100311}       & 24122          & \\textbf{124433}         & \\textbf{100311}       & 24122          & \\textbf{124433}         & Modified Cosine          \\\\\n59017        & \\textbf{40470}          & 99487          & 54644        & \\textbf{34096}          & 88740          & Modified Pearson 1       \\\\\n89936        & 28183          & 118119         & 84511        & 24357          & 108868         & Modified Pearson 2       \\\\\n89936        & 28183          & 118119         & 84511        & 24357          & 108868         & Pearson\n\\end{tabular}\n\\end{table}\n\nCosine, Jaccard and Modified Cosine were able to produce the most rating predictions, 124433 in total,\nboth for user-based and item-based. Modified Pearson 1 was the one with the least similarities\n(\\autoref{table:modified_pearson_1_descriptive}) and therefore the one with the least rating\npredictions, even though, it managed to predict a total of 99487 ratings user-based\nand 88740 item-based. The outcome however was very poor for this similarity formula for any\nevaluation metric. The average boost in rating predictions using the Recursive-KNN method was\nabout 25\\% for user-based CF and 24\\% for item-based CF.\n\\newpage\nThe two tables below are the logs produced for user-based(\\autoref{table:users_log})\nand item-based(\\autoref{table:items_log}) KNN and Recursive-KNN algorithms.\nThe first three columns refer to the KNN algorithm and present the number of pairs that KNN\nalgorithm was unable to predict. The first column indicates the number of pairs\n(user, item) for which relevant nearest neighbors did not exist. The second column\nindicates the number of pairs that either the item in user-based or user in\nitem-based did not exist in the train set. The third column indicates the number\nof pairs that either the user in user-based or item in\nitem-based did not exist in the train set and therefore KNN could not find similarities.\nThe test was for 22 different values of $\\mathcal{K}$. The total compute time for each similarity\nmetric for all $\\mathcal{K}$'s is indicated in the fourth column.\nThe next two columns refer to Recursive-KNN algorithm. The fifth column indicates\nthe number of pairs that could not be predicted due to no further neighbors\nafter the completion of the Recursive-KNN algorithm.\nThe sixth column is the time the Recursive-KNN took for completing all the available combinations\n484 in count between $\\mathcal{K}$'s and $\\mathcal{M}$'s (i.e. ($\\mathcal{M}$=1, $\\mathcal{K}$=1),\n($\\mathcal{M}$=1, $\\mathcal{K}$=3), ($\\mathcal{M}$=3, $\\mathcal{K}$=1) e.t.c.).\n\nThe computations were run on a cloud computing platform.\nThe specifications of the machine were the following:\n\\begin{itemize}\n\t\\item[] \\textbf{OS:} Ubuntu Server 16.04.3\n\t\\item[] \\textbf{CPU:} Intel Xeon E5-2697A v4 @ 2.60GHz\n\t\\item[] \\textbf{RAM:} 3GB DDR4 + 1GB SWAP\n\\end{itemize}\n\n\\begin{table}[H]\n\\centering\n\\caption{User-based KNN and Recursive-KNN Log}\n\\label{table:users_log}\n\\begin{tabular}{|c|c|c|c|c|c|c|}\n\\cline{1-6}\n\\multicolumn{4}{|c|}{\\textbf{KNN}}                                               & \\multicolumn{2}{c|}{\\textbf{Recursive-KNN}} & \\multicolumn{1}{l}{}                          \\\\ \\hline\n\\textbf{No NN} & \\textbf{Not in Train} & \\textbf{No Similarity} & \\textbf{Time} & \\textbf{R-No NN} & \\textbf{R-Time}\t\t& \\multicolumn{1}{c|}{\\textbf{Similarity}}      \\\\ \\hline\n36278          & 18939                 & 1025                  & 0:3:58        & 1886             & 4:3:9           \t\t& \\multicolumn{1}{c|}{adjusted cosine}          \\\\ \\hline\n25061          & 18939                 & 310                   & 0:5:17        & 939              & 4:1:57          \t\t& \\multicolumn{1}{c|}{cosine}                   \\\\ \\hline\n25061          & 18939                 & 310                   & 0:3:41        & 939              & 2:57:58         \t\t& \\multicolumn{1}{c|}{jaccard}                  \\\\ \\hline\n31200          & 18939                 & 558                   & 0:4:16        & 1453             & 3:2:29          \t\t& \\multicolumn{1}{c|}{mad}                      \\\\ \\hline\n31200          & 18939                 & 558                   & 0:4:9         & 1453             & 3:9:12          \t\t& \\multicolumn{1}{c|}{msd}                      \\\\ \\hline\n36278          & 18939                 & 1025                  & 0:4:13        & 1886             & 4:3:56          \t\t& \\multicolumn{1}{c|}{modified adjusted cosine} \\\\ \\hline\n25061          & 18939                 & 310                   & 0:4:31        & 939              & 2:42:42         \t\t& \\multicolumn{1}{c|}{modified cosine}          \\\\ \\hline\n48886          & 18939                 & 17779                 & 0:3:8         & 8416             & 1:33:26         \t\t& \\multicolumn{1}{c|}{modified pearson 1}       \\\\ \\hline\n29450          & 18939                 & 6296                  & 0:3:18        & 1267             & 3:4:17          \t\t& \\multicolumn{1}{c|}{modified pearson 2}       \\\\ \\hline\n29450          & 18939                 & 6296                  & 0:3:8         & 1267             & 2:48:48         \t\t& \\multicolumn{1}{c|}{pearson}                  \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[H]\n\\centering\n\\caption{Item-based KNN and Recursive-KNN Log}\n\\label{table:items_log}\n\\begin{tabular}{|c|c|c|c|c|c|c}\n\\cline{1-6}\n\\multicolumn{4}{|c|}{\\textbf{KNN}}                                               & \\multicolumn{2}{c|}{\\textbf{Recursive-KNN}} & \\multicolumn{1}{l}{}                          \\\\ \\hline\n\\textbf{No NN} & \\textbf{Not in  Train} & \\textbf{No Similarity} & \\textbf{Time} & \\textbf{R-No NN}      & \\textbf{R-Time}     & \\multicolumn{1}{c|}{\\textbf{Similarity}}      \\\\ \\hline\n35280          & 0                      & 19541                  & 0:3:2         & 1965                  & 2:18:35             & \\multicolumn{1}{c|}{adjusted cosine}          \\\\ \\hline\n25188          & 0                      & 19122                  & 0:3:43        & 1066                  & 2:26:56             & \\multicolumn{1}{c|}{cosine}                   \\\\ \\hline\n25188          & 0                      & 19122                  & 0:3:37        & 1066                  & 2:12:56             & \\multicolumn{1}{c|}{jaccard}                  \\\\ \\hline\n30827          & 0                      & 19266                  & 0:3:22        & 1624                  & 1:54:18             & \\multicolumn{1}{c|}{mad}                      \\\\ \\hline\n30827          & 0                      & 19266                  & 0:3:28        & 1624                  & 1:58:50             & \\multicolumn{1}{c|}{msd}                      \\\\ \\hline\n35280          & 0                      & 19541                  & 0:3:10        & 1965                  & 2:32:4              & \\multicolumn{1}{c|}{modified adjusted cosine} \\\\ \\hline\n25188          & 0                      & 19122                  & 0:3:37        & 1066                  & 2:11:18             & \\multicolumn{1}{c|}{modified cosine}          \\\\ \\hline\n41037          & 0                      & 48940                  & 0:2:14        & 6941                  & 0:39:1              & \\multicolumn{1}{c|}{modified pearson 1}       \\\\ \\hline\n25332          & 0                      & 34778                  & 0:2:58        & 975                   & 1:49:35             & \\multicolumn{1}{c|}{modified pearson 2}       \\\\ \\hline\n25332          & 0                      & 34778                  & 0:2:52        & 975                   & 1:46:24             & \\multicolumn{1}{c|}{pearson}                  \\\\ \\hline\n\\end{tabular}\n\\end{table}\n", "meta": {"hexsha": "0c135fd3107e572b0c99cb38e4967daaf8853e42", "size": 46709, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diploma/chapters/chapter_4.tex", "max_stars_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_stars_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-06T16:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-06T16:08:44.000Z", "max_issues_repo_path": "diploma/chapters/chapter_4.tex", "max_issues_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_issues_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "diploma/chapters/chapter_4.tex", "max_forks_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_forks_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7109295199, "max_line_length": 184, "alphanum_fraction": 0.6175683487, "num_tokens": 14708, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.41105149448783884}}
{"text": "\\subsubsection{ValueDuration}\n\\label{ValueDurationPP}\nThe \\xmlNode{ValueDuration} PostProcessor is a tool to construct a particular kind of histogram, where the\nindependent variable is the number of times a variable exceeds a particular value, and the dependent variable\nis the values themselves.  An example of this is the Load Duration Curve in energy modeling. This approach is\nsimilar to that used in Lebesgue integration. Note that for each realization in the input\n\\xmlNode{HistorySet}, a separate load duration curve will be created for each target.\n\nThe \\xmlNode{ValueDuration} PostProcessor can only act on \\xmlNode{HistorySet} data objects, and generates a\n\\xmlNode{HistorySet} in return.  Two output variables are created for each \\xmlAttr{target}:\n\\xmlString{counts\\_x} and \\xmlString{bins\\_x}, where \\xmlString{x} is replaced by the name of the target.\nThese must be specified in the output data object in order to be collected.\n\nTo plot a traditional Load Duration Curve, the x-axis should be the bins variable, and the y-axis should be\nthe counts variable.\n\n\\ppType{ValueDuration}{ValueDuration}\n%\n\\begin{itemize}\n  \\item \\xmlNode{target}, \\xmlDesc{comma separated strings, required field}, specifies the names of the\n    target(s) for which Value Duration histograms should be generated.\n  \\item \\xmlNode{bins}, \\xmlDesc{integer, required field}, specifies the number of bins that the values of the\n    targets should be counted into.\n\\end{itemize}\n\n\\textbf{Example:}\n\n\\begin{lstlisting}[style=XML]\n<Simulation>\n ...\n  <Models>\n    ...\n    <PostProcessor name=\"pp\" subType=\"ValueDuration\">\n      <target>x, y</target>\n      <bins>100</bins>\n    </PostProcessor>\n    ...\n  </Models>\n ...\n</Simulation>\n\\end{lstlisting}\n", "meta": {"hexsha": "bcc3096b1c4e67a8b5026c3ffdac9675a6d66a66", "size": 1734, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user_manual/PostProcessors/ValueDuration.tex", "max_stars_repo_name": "dgarrett622/raven", "max_stars_repo_head_hexsha": "f36cc108f7500b0e2717df4832b69b801b43960d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/user_manual/PostProcessors/ValueDuration.tex", "max_issues_repo_name": "dgarrett622/raven", "max_issues_repo_head_hexsha": "f36cc108f7500b0e2717df4832b69b801b43960d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/user_manual/PostProcessors/ValueDuration.tex", "max_forks_repo_name": "dgarrett622/raven", "max_forks_repo_head_hexsha": "f36cc108f7500b0e2717df4832b69b801b43960d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2857142857, "max_line_length": 110, "alphanum_fraction": 0.7606689735, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.41105149448783884}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n\\usepackage{subfig}\n\\usepackage[\nbackend=biber,\nstyle=alphabetic,\nsorting=ynt\n]{biblatex}\n\n\\addbibresource{ssvgd.bib}\n\n\n\n\n\\title{State Space Reporting Delay}\n\n\\date{January 2018}\n\n\\begin{document}\n\n\\subsection*{Introduction}\n\nState-Space models have become popular tools in the analysis of time-series. They allow for arbitrary transition and observation dynamics. The researcher can assign a latent data generating process, while simultaneously allowing for observational error on that process. The classic algorithm for fitting non-Gaussian SSMs is given by the particle filter. Although many variations exist, we generally refer to the sampling importance re-sampling (SIR) filter when discussing particle filtering. Although a powerful inference tool, particle filtering suffers from several well known drawbacks. The first is the problem of filter degeneracy. This occurs when the observations are far from the state predicted by the latent dynamics. The second is the excessive run-times on longer time series with complex dynamics. \nWe propose an alternative approach that we hope will do better than particle filtering in practice.  In this approach, Stein Variational Gradient Descent (SVGD) is used to sequentially estimate the distribution of state variables in each time step, conditional on observed data up through that time.  \n\n\\subsection*{Overview of SVGD}\nStein Variational Gradient Descent can be used to estimate a continuous distribution by a set of particles. By iteratively transporting samples from an initial distribution in the direction of the likelihood, we are able to generate compute Monte Carlo estimates of the posterior. The usefulness of this approximation is apparent in Bayesian statistics, where the usually intractable normalizing constant disappears in the particle update step. The particles are subject to the following gradient ascent procedure. \n\n$$x_i^{l+i} \\leftarrow x_i^{l}+\\epsilon_l\\hat{\\phi^*(x_i^l)}   $$\n$$\\hat{\\phi^*(x)} = \\frac{1}{n}\\sum_{j=1}^n[k(x_j^l,x)\\nabla_{x_j^l}log\\ p(x_j^l) + \\nabla_{x_j^l}k(x_j^l,x)]$$\n\n\n\nfor an arbitrary positive definite kernel function $k(.,.)$ usually chosen to be a Gaussian kernel.\n\n\n\\subsection*{State Space Models}\nSuppose we are given a time series $Y_1,Y_2,...,Y_t$ for $Y \\in \\mathbb{R}$. We model the sequence as a state-space model parameterized by an observation density $p(y_t | x_t)$ and a transition density $p(x_t | x_{t-1})$ Figure 1.\n\n\\begin{center}\n\\includegraphics[scale=.5]{/home/gcgibson/ssm.png}\n\\end{center}\n\n\n\n\n\nWe are interested in the filtering distribution $p(x_1,...,x_n | y_1,...,y_n)$ which by Bayes formula is $$p(x_1,...,x_n | y_1,...,y_n) = \\frac{p(y_1,...,y_n | x_1,...,x_n) p(x_1,...,x_n)}{Z}$$.\n\nBecause computing the normalizing constant $Z$ is intractable for many choices of $p(y_t | x_t)$ and $p(x_t | x_{t-1})$, we must resort to Monte Carlo algorithms. The classic approach that incorporates the sequential nature of the data is given by the particle filtering algorithm. Particle filtering approximates the filtering density using sequential importance sampling. We instead focus on the following recursion. \n\n$$p(x_t | y_{1:t}) = \\int p(x_{0:t} | y_{1:t})d_{x_0:t-1}$$\n$$=\\frac{p(y_t | x_t)}{\\int p(y_t|x_t)p(x_t | y_{1:t-1})dx_t}p(x_t | y_{1:t-1})$$\n\n$$\\propto p(y_t|x_t)p(x_t | y_{1:t-1})$$\n$$\\propto p(y_t|x_t)p(x_t | y_{1:t-1})$$\n$$\\propto p(y_t|x_t)\\int_{x_{t-1}}p(x_t,x_{t-1} | y_{1:t-1})d_{x_{t-1}}$$\n\n$$\\propto p(y_t|x_t)\\int_{x_{t-1}}p(x_t |x_{t-1} )p(x_{t-1}| y_{1:t-1})d_{x_{t-1}}$$\n\nwhich we can approximate using svgd as \n$$\\approx p(y_t|x_t) \\frac{1}{n}\\sum_{i=1}^n p(x_t | x_{t-1}^{(i)})$$\nWe can now estimate $p(x_{t+1}|y_{1:t+1})$ using the same algebra as above. \n(proof in apendix A) \n\n\n\n\\subsection*{Locally Level Gaussian Noise Model}\nIn order to demonstrate that the approximation is reasonable we evaluate the predictive accuracy under an analytically tractable model, the locally level Gaussian model. This model takes the form \n$$X_t \\sim N(X_{t-1},\\sigma_1^2)$$\n$$Y_t \\sim N(X_t, \\sigma_2^2)$$\n\n\n\\begin{figure}[!tbp]\n\\centering\n\\subfloat[SSVGD]{\\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/ssvgd_locally_level.pdf}\\label{fig:f1}}\n  \\hfill\n  \\subfloat[PF]{\\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/pf_locally_level.pdf}\n\\label{fig:f2}}\n  \\caption{Comparison of locally level Gaussian model}\n\\end{figure}\n\n\n\n\\subsection*{Poisson Observation Model With Seasonal State-Space Dynamics}\n\nIn order to evaluate the performance on more involved dynamics we consider the following state-space model.\n$$\\begin{pmatrix} X_{t,1} \\\\ X_{t,2} \\end{pmatrix} = \\begin{pmatrix} cos(2\\pi/s) & sin(2\\pi/s) \\\\ -sin(2\\pi/s) & cos(2\\pi/s) \\end{pmatrix} \\begin{pmatrix} X_{t-1,1} \\\\ X_{t-1,2} \\end{pmatrix} $$\n$$Y_t \\sim Pois(e^{X_{t,1}})$$\n\n\n\\begin{figure}[!tbp]\n\\centering\n\\subfloat[SSVGD]{\\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/ssvgd_seasonal.pdf}\\label{fig:f1}}\n  \\hfill\n  \\subfloat[PF]{\\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/pf_seasonal.pdf}\n\\label{fig:f2}}\n  \\caption{Comparison of seasonal Poisson model}\n\\end{figure}\n\n\\subsection*{Divergent Particle Filter}\n\nWe next investigate the ability of SSVGD to perform in the presence of poor initialization. This is a well known issue with current particle filter implementations: starting far from a plausible value of $x_0$ forces all particles to receive weight $0$ under the likelihood, leading to a degenerate filtering distribution. However, under SSVGD, we can simply increase the number of iterations, allowing for arbitrarily poor starting points. Standard particle filtering algorithms use effective sample size as a measure of degeneracy. This is commonly defined as $$S^{pf}_{eff} = \\frac{1}{\\sum_i (w_t^i)^2}$$. The common rule of thumb is to not allow this quantity to drop below 50. The natural translation of this metric into particle filtering is compute the same metric based on the samples obtained by SSVGD. \n\n\n\\subsection*{Results}\nStandard particle filtering algorithms use effective sample size as a measure of degeneracy. This is commonly defined as $$S_{eff} = \\frac{1}{\\sum_i (w_i)^2}$$. The common rule of thumb is to not allow this quantity to fall below 50. Indeed, software implementations such as Biips throws an error if the number of effective particles falls below 50. We compute the effective sample size in an analogous way to the particle filter, where $w_i$ is defined as in the SIR particle filter. \n\n\\subsection*{Discussion}\n\n\\cite{liu_stein_2016-4}\n\n\n\\printbibliography\n\n\\end{document}\n", "meta": {"hexsha": "5b76a38f258e9b445367b4b0941ce2774a41719a", "size": 6757, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/ssvgd.tex", "max_stars_repo_name": "gcgibson/ssvgd", "max_stars_repo_head_hexsha": "8f47dca7588a3ccbc13069860f342efcd5bbf644", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-02-06T20:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-06T20:18:28.000Z", "max_issues_repo_path": "manuscript/ssvgd.tex", "max_issues_repo_name": "gcgibson/ssvgd", "max_issues_repo_head_hexsha": "8f47dca7588a3ccbc13069860f342efcd5bbf644", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manuscript/ssvgd.tex", "max_forks_repo_name": "gcgibson/ssvgd", "max_forks_repo_head_hexsha": "8f47dca7588a3ccbc13069860f342efcd5bbf644", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.3852459016, "max_line_length": 813, "alphanum_fraction": 0.7519609294, "num_tokens": 1939, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.611381973294151, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.41105147292437877}}
{"text": "\\documentclass{article}\n\n\\usepackage[main=english,vietnamese]{babel}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage[sexy]{evan}\n\\usepackage{matchsticks}\n\\usepackage{wrapfig}\n\\usepackage{listings}\n\n\\title{The Power of Mathematical Reasoning - Part Two}\n\\author{Nghia Doan \\& Catherine Doan}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Casework}\n\nSometimes, when the problem at hand is more complicated, \nlooking at all possible cases, or caseworking, can help to find the correct answer.\n\n\\begin{example*}[Who stole what?]\n    \\label{example:pi-2022-4-p8}\n    Father was not happy when he heard that Mother could not make his favourite cake because butter, eggs and milk all were stolen.\n    Mother told him that she saw Chipmunk, Groundhog, and Sparrow sneaking out of the kitchen.\n    Everyone was carrying something, and it was not clear who was carrying what.\n    After a brief investigation all stolen ingredients were found at the places of Chipmunk, Groundhog, and Sparrow.\n    Here were what they said,\n    \\begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]\n        \\ii Chipmunk: Groundhog stole the butter.\n        \\ii Groundhog: Sparrow stole the eggs.\n        \\ii Sparrow: I stole the milk.\n    \\end{itemize}\n    As it happened, \\textit{the one, who stole the butter, told the truth} and \\textit{the one, who stole the eggs, lied.}\n\n    Who stole what?\n\\end{example*}\n\n\\begin{soln} \\nameref{example:pi-2022-4-p8}\n    Let's try casework on \\textit{who stole the butter.}\n    \\begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]\n        \\ii \\textit{Case 1:} Assume that Sparrow have stolen the butter. \n        Then she would told the truth, but she said she stole the milk. So it was not possible.\n        \\ii \\textit{Case 2:} If Chipmunk stole the butter, then what she said about Groundhog is true,\n        thus Groundhog stole the butter, which is a contradiction.\n        \\ii \\textit{Case 3:} Groundhog must have stolen the butter. \n        Thus what Groundhog said was true, so Sparrow stole the eggs, therefore Chipmunk stole the milk.\n    \\end{itemize}    \n    The answer is \\framebox{Groundhog stole the butter, Sparrow stole the eggs, and Chipmunk stole the milk.}\n\\end{soln}\n\n\\section*{Knights and Liars, Patients and Doctors, and other stories}\n\nClassic stories have some twists. Inductive reasoning leads us to a general conclusion.\nDeductive reasoning applies a general assumption to a specific case.\n\n\\begin{example*}[Who killed the dragon?]\n    \\label{example:pi-2022-4-p10}\n    On the Island of Knights and Liars, there are two types of people:\n    the knights who always tell the truth and the liars who always lie.\n\n    Three mighty warriors live on the island.\n    Their names are Albert, David, and Victor.\n    Two of them are Liars, and one is a Knight.\n    The friends keep their secrets so nobody know who was what.\n\n    One of their great deeds was a battle with a terrible dragon\n    that was terrorizing the students of the Math, Chess, and Codding Club.\n    Not much is known about this battle except that the dragon was slayed by a Knight.\n    In a recently discovered letter, Albert stated that Victor had slayed the dragon\n    and David were merely watching.\n\n    Who actually killed the dragon?\n\\end{example*}\n\n\\begin{soln} \\nameref{example:pi-2022-4-p10}\n    If Albert is a Knight, then Victor slayed the dragon.\n    Because the dragon slayer was a Knight, this would make Victor a Knight,\n    which is impossible because only one of them is a Knight.\n    Therefore Albert is a Liar, which means that Victor did not kill the dragon.\n    \n    Thus, \\framebox{David was the dragon-slayer.}\n\\end{soln}\n\n\\begin{example*}[Who were removed?]\n    \\label{example:pi-2022-4-p11}\n    In the Mental Hospital of Geniuses there are only doctors and patients.\n    Each of these inhabitants is sane or insane, but cannot be both.\n    The sane people were a hundred percent accurate in all of their beliefs, \n    and the insane people were a hundred percent inaccurate in all of their beliefs.\n    \n    After being in the hospital for a while, some patients got cured and became sane.\n    Unfortunately some doctors lost their minds and became insane.\n    The sane patients and insane doctors, if found, were removed from the hospital.\n    \n    One day, Inspector Melanie visited the hospital in order to determine who should be removed.\n    She interviewed three people $A$, $B$, and $C$:\n    \\begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]\n        \\ii $A$ said $B$ was insane.\n        \\ii $B$ said $A$ is a doctor.\n        \\ii $C$ said $B$ is a patient and $A$ is insane.\n    \\end{itemize}\n\n    Did Inspector Melanie remove $A$, $B$, or both of them?\n\\end{example*}\n\n\\begin{soln} \\nameref{example:pi-2022-4-p11}\n    Suppose that $A$ was sane. Then, what $A$ said was true, so $B$ was insane, and therefore $B$'s belief that $A$ was a doctor\n    was false, thus, $A$ is a sane patient and should be removed.\n    $C$ said $A$ was insane, so $C$ was insane, thus $B$ was a doctor, thus $B$ should be removed as well.\n    \n    Now, if $A$ was insane, then $B$ was sane, and therefore $A$ was a insane doctor and should be removed.\n    $C$ said $A$ was insane, so $C$ was sane, thus $B$ was patient, so $B$ should also be removed.\n    \n    Thus, \\framebox{both $A$ and $B$ should be removed.}\n\\end{soln}\n\n\\section*{Exercises}\n\n\\begin{exercise*}[Which room has the tiger?]\n    \\label{exercise:pi-2022-4-p9}\n    Karl was captured while sneaking into the Kingdom of the Hungry Tigers.\n    He was lead in front of three rooms, each with a separate door marked with a sign,\n    as shown below in \\Cref{fig:pi-2022-4-p9}.\n    \\begin{figure}[h]\n        \\centering\n        \\begin{tabular}{|c|c|c|}\n        \\hline\n        I & II & III \\\\\n        Room III is empty & The tiger is in Room I & This room is empty \\\\ \\hline\n        \\end{tabular}\n        \\caption{\\nameref{exercise:pi-2022-4-p9}}\n        \\label{fig:pi-2022-4-p9}\n    \\end{figure}\n    A large treasure chest was placed in one of the rooms and a hungry tiger in another.\n    A beautiful girl told him that,\n    \\begin{enumerate}[topsep=0pt, partopsep=0pt, itemsep=0pt]\n        \\ii The sign on the door of the room containing the treasure was true,\n        \\ii The sign on the door of the room with the tiger was false, and\n        \\ii The sign on the door of the empty room could be either true or false.\n        \\ii If he opens the room with the tiger, he will be eaten.\n        \\ii If he opens the room with the chest, they will set him free and give him the chest.\n    \\end{enumerate}\n\n    Which room has the tiger?\n\\end{exercise*}\n\n\\begin{soln} \\nameref{exercise:pi-2022-4-p9}\n    Instead of looking for the tiger, let's \\textit{look for the treasure, because the sign on its room is true.}\n    \n    It cannot be in room II, because then according to the sign, room I has the tiger, room III is empty.\n    Thus, the sign on room I is true, which contradicts that the sign on the room with the tiger is false.\n    \n    It cannot be in room III, because the according to the sign, room III is empty.\n    Therefore the treasure is in room I, room III is empty, and the tiger is in room II.\n\\end{soln}\n\n\\begin{exercise*}[Was Sam awake?]\n    \\label{exercise:pi-2022-4-p12}\n    Whenever Rob the bandit is asleep, everything he believes is wrong.\n    In other words, everything Rob believes in his sleep is false.\n    On the other hand, everything he believes while he is awake is true.\n    Last night at $10$ o'clock sharp,\n    while guarding the newly captured treasure chest,\n    Rob believed that he and Sam the thug were asleep at that time.\n    \n    Was Sam asleep or awake at that time?\n\\end{exercise*}\n\n\\begin{soln} \\nameref{exercise:pi-2022-4-p12}\n    If Rob the bandit was awake at the time, he could not have had \\textit{the false belief\n    that both he and Sam the thug were asleep.}\n    Therefore he was asleep. This means that his belief was false,\n    so it is not true that both were asleep.\n    Therefore Sam was awake.\n\\end{soln}\n\n\\end{document}", "meta": {"hexsha": "9301fe8fe463e2db458204c6c4658278fe0bf3b0", "size": 8079, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pi-2022-5.tex", "max_stars_repo_name": "nghia71/pi", "max_stars_repo_head_hexsha": "f352a30eb694c70401ef34c4396e8bc8a2a57a19", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pi-2022-5.tex", "max_issues_repo_name": "nghia71/pi", "max_issues_repo_head_hexsha": "f352a30eb694c70401ef34c4396e8bc8a2a57a19", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pi-2022-5.tex", "max_forks_repo_name": "nghia71/pi", "max_forks_repo_head_hexsha": "f352a30eb694c70401ef34c4396e8bc8a2a57a19", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.8833333333, "max_line_length": 131, "alphanum_fraction": 0.7057804184, "num_tokens": 2199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727231, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.41105115396555997}}
{"text": "\\chapter{Parameter Estimation}\\label{ch:parameterEstimation}\nIn this chapter, we discuss our approach toward parameter estimation.\nSpecifically, we aim to address the problem of maximum likelihood.\n\n\\section{Intractable Likelihood Functions}\\label{sec:intractableLikelihoodFunctions}\n\\begin{figure}[t]\n    \\centering{\\input{include/floats/likelihood-general.tex}}\n    \\caption{General figure depicting a smooth likelihood distribution (blue).\n    The maximum likelihood point of this distribution is the intersection of the black dashed line and the blue line.\n    }\\label{fig:likelihoodGeneral}\n\\end{figure}\n\nWe denote $\\theta$ to be a set of parameters values, $\\Theta$ to be the space all of our parameters values reside in,\n$\\mathcal{D}$ to be a collection of observed data, and $\\mathcal{D}'$ to\nbe a collection of generated data.\nThe \\emph{likelihood} of some parameter values $\\theta \\in \\Theta$ is the joint probability that $\\theta$ produces\nsome observed data $\\mathcal{D}$.\nLet $\\mathcal{M},\\mathcal{V} : \\theta \\mapsto \\mathcal{D}'$ define a function that maps parameter values $\\theta$ and random variables\n$\\mathcal{V}$ to generated data $\\mathcal{D}'$.\nGiven that $\\mathcal{V}$ is random, different $\\mathcal{D}'$ may be returned for the same parameter values\n$\\theta$.\n%In other words, $\\mathcal{M}$ represents some stochastic simulator model which produces some random data.\nGiven \\emph{discrete and countable} observations $\\mathcal{D}$, the likelihood of parameter values $\\theta \\in \\Theta$\nis the probability that our generated data equals our observed data~\\cite{lintusaariFundamentalsRecentDevelopments2017}.\n\\begin{equation}\\label{eq:likelihood1}\n    \\mathcal{L}(\\theta) = \\Pr(\\mathcal{D} = \\mathcal{M}(\\theta))\n\\end{equation}\n\nOne technique to calculate a maximum likelihood for our parameter values involves finding the critical points of\n$\\mathcal{L}$ (where $\\frac{d\\mathcal{L}}{d\\theta} = 0$) and choosing the point $\\hat{\\theta}$ with the largest value\nof $\\mathcal{L}$.\nIn~\\autoref{fig:likelihoodGeneral}, the maximum of such a likelihood is displayed at the intersection of the blue and\nblack dashed lines.\nThere are however, several problems with this approach:\n\\begin{enumerate}\n    \\item A large range $\\mathcal{D}'$ for simulator $\\mathcal{M}$ indicates that the frequency of exact observed --\n        generated matches will be too low to make inferences.\n    \\item This assumes that we can explicitly express $\\mathcal{L}$.\n        For simulator based $\\mathcal{M}$ like ours, this is not trivial to do.\n\\end{enumerate}\nConsequently, we must look into other approaches to \\textit{infer} $\\mathcal{L}$.\nThe two problems this chapter aims to address are (a) how to efficiently compute $\\mathcal{L}$ for a single $\\theta$\nand (b) how to infer $\\mathcal{L}$ for all $\\theta$.\n\n\\section{Approximate Bayesian Computation}\\label{sec:approximateBayesianComputation}\nIn this section, we discuss an approximate method to compute the likelihood $\\mathcal{L}$ for some parameter values\n$\\theta$.\n\nAs previously mentioned, to find $\\mathcal{L}$ is to find the joint probability that our model and parameters produce\nthe observed data.\nWe expand~\\autoref{eq:likelihood1} to make this explicit for $r$ sets of observed data\nin~\\autoref{eq:jointProbabilityLikelihood}.\n$\\theta$ remains the same, however the randomness of $\\mathcal{V}$ may result in different probabilities.\nFor brevity, $\\mathcal{V}$ is implicit in $\\mathcal{M}$ from this point forward.\n\\begin{equation}\\label{eq:jointProbabilityLikelihood}\n    \\mathcal{L}(\\theta) = \\prod_{i=1}^{r} \\Pr\\left(\\mathcal{M}(\\theta) = \\mathcal{D}_i \\right)\n\\end{equation}\n\nLet $\\mathcal{D}$ represent the set of observed samples from the Columbian populace.\nHow do we determine the probability of our model generating some $\\mathcal{D}_i \\in \\mathcal{D}$ to\ndetermine $\\mathcal{L}(\\theta)$?\nHere, we take a frequentist approach and perform the following steps:\n\\begin{enumerate}\n    \\item Run our simulator once to get $\\mathcal{D}'_1$.\n    \\item Check if $\\mathcal{D}'_1$ matches $\\mathcal{D}_1$.\n    \\item Repeat steps 1 and 2 some number of times $T_1$, for different simulated samples but the same\n        observed sample.\n        We define $\\Pr\\left( \\mathcal{M}(\\theta) = \\mathcal{D}_1 \\right)$ as the frequency of exact matches.\n    \\item Repeat step 3 for all observed samples to get $\\Pr\\left( \\mathcal{M}(\\theta) = \\mathcal{D}_2 \\right)$,\n        \\ldots, $\\Pr\\left( \\mathcal{M}(\\theta) = \\mathcal{D}_r \\right)$.\n    \\item To find the $\\mathcal{L}$ is to multiply all $r$ probabilities together.\n\\end{enumerate}\n\nThis approach seems simple enough, but there exists one caveat: the frequency of exact matches is too low to interpret\nanything meaningful.\nThe microsatellite repeat length set $\\mathbb{M}$ consists of roughly 30 elements, meaning that roughly 30 dimensions\nmust exactly match.\nIn addition to this, each frequency resides in some large set whose elements are between $[0, 1]$.\nThe solution we propose here is a technique known as \\emph{Approximate Bayesian Computation}, or ABC for short.\nABC has two parts: the use of \\emph{approximate} matches and the use of summary\nstatistics~\\cite{lintusaariFundamentalsRecentDevelopments2017}.\nIn the following sections, I discuss how we define approximate, what summary statistics are, and why we are not using\nthem for this problem.\n\n\\begin{figure}[t]\n    \\centering{\\input{include/floats/approximate-likelihood.tex}}\n    \\caption{General figure depicting a true likelihood surface (blue) and an approximate surface (red).\n    The true likelihood may not be found in a reasonable amount time, whereas the approximate likelihood is wider but\n    taller (making it more tractable, but less defined).\n    }\\label{fig:approximateLikelihood}\n\\end{figure}\n\n\\subsection{Approximate Matches: $\\epsilon$}\\label{subsec:approximateMatches}\nLet us dissect $\\mathcal{D}$ and $\\mathcal{D}'$ further.\nA given $\\mathcal{D}_i \\in \\mathcal{D}$ and $\\mathcal{D}'_i \\in \\mathcal{D}'$ define $| \\mathbb{M} |$-sized tuples,\nwhose values exist in $[0, 1]$.\nTo compare a given $\\mathcal{D}_i$ and $\\mathcal{D}'_i$ is to iterate through each element (repeat unit) in both\ntuples and measure their proximity to each other.\nLet $\\delta : \\mathcal{D}_i,\\mathcal{D}'_i \\mapsto [0, 1]$ represent some function that accepts the observed and\ngenerated sample, and outputs some distance between 0 and 1.\nThe comparison between our observed and generated samples is given by $\\delta(\\mathcal{D}_i, \\mathcal{D}'_i)$.\n\nWe were only able to explore one $\\delta$ function: the angular (or Cosine) distance.\nThe angular distance treats $\\mathcal{D}_i$ and $\\mathcal{D}'_i$ as $| \\mathbb{M} |$-dimensional vectors\nand aims to quantify some difference between the two.\nAn output of 0 indicates that both samples are completely similar, while an output of 1 indicates that two vectors\nare maximally dissimilar (orthogonal).\nThe angular distance $\\delta_A$ is defined below~\\cite{chaComprehensiveSurveyDistance2007a}:\n\\begin{equation}\n    \\delta_A(\\mathcal{D}_i, \\mathcal{D}'_i) = \\frac{2}{\\pi} \\arccos \\left(\n    \\frac{\\sum_{\\ell=\\kappa}^{\\Omega} \\mathcal{D}_i[\\ell] \\cdot \\mathcal{D}'_i[\\ell]}{\n        \\sqrt{\\sum_{\\ell=\\kappa}^{\\Omega} \\left(\\mathcal{D}_i[\\ell]\\right)^2} \\cdot\n        \\sqrt{\\sum_{\\ell=\\kappa}^{\\Omega} \\left(\\mathcal{D}'_i[\\ell]\\right)^2}\n    } \\right)\n\\end{equation}\nwhere $\\mathcal{D}_i[\\ell]$ and $\\mathcal{D}'_i[\\ell]$ represent the frequency of repeat length $\\ell$ for the observed\nand generated samples respectively.\n\nWith some distance is quantified, the next step is defining what ``approximate'' means.\nAccording to ABC, two samples $\\mathcal{D}_i$ and $\\mathcal{D}'_i$ are approximate matches if their distance falls below\nsome threshold $\\epsilon \\in [0, 1]$~\\cite{marjoramMarkovChainMonte2003}:\n\\begin{equation}\n    \\left(\\delta(\\mathcal{D}_i, \\mathcal{D}'_i) < \\epsilon \\right) \\Leftrightarrow\n    \\left(\\mathcal{D}_i \\text { and } \\mathcal{D}'_i\n    \\text{ are approximate matches} \\right)\n\\end{equation}\nBy increasing $\\epsilon$, the frequency of exact observed -- generated matches increases as well.\n%By making this problem more tractable though, we increase the noise associated with drawing from $\\mathcal{L}$.\nThis results in a flatter curve, as seen in~\\autoref{fig:approximateLikelihood}.\n\nThe next question that follows is ``How do we know which $\\epsilon$ to use?''\nIf $\\epsilon$ is too small, the problem becomes intractable.\nIf $\\epsilon$ is too large, we draw values that are not representative of the original distribution.\nThere is no clear answer to this question, and Lintusaari et.\\ al.\\ states this choice is typically made by\nexperimenting with different $(\\mathcal{D}, \\theta)$ pairs~\\cite{lintusaariFundamentalsRecentDevelopments2017}.\nWe define our threshold $\\epsilon$ as a \\emph{hyperparameter}, a parameter we must specify and often experiment with)\nto find the parameters of interest $\\theta$.\n\n\\subsection{Dimension Reduction: Summary Statistics}\\label{subsec:dimensionReductionSummaryStatistics}\nAn alternative to using a distance function $\\delta$ that deals with $| \\mathbb{M} |$-dimensional tuples is to use a\nfunction that reduces, or \\emph{summarizes} the data into two points $\\bar{\\mathcal{D}}, \\bar{\\mathcal{D}'}$ of lower\ndimensionality and finds a distance between both $\\bar{\\mathcal{D}}, \\bar{\\mathcal{D}'}$.\nWe specify a distance function $\\delta_S$ that performs this transformation using functions\n$h : \\mathcal{D}_i \\mapsto \\bar{\\mathcal{D}_i}$ and $h' : \\mathcal{D}'_i \\mapsto \\bar{\\mathcal{D}'_i}$ as such:\n\\begin{equation}\n    \\bar{\\delta_S}(\\mathcal{D}_i, \\mathcal{D}'_i)  = \\bar{\\delta}(h(\\mathcal{D}_i), h'(\\mathcal{D}'_i))\n\\end{equation}\nA common choice for $h, h'$ is the mean or median.\nFor us, it may make sense to use the focal unit computation $\\hat{\\ell}$ as our summary statistic.\n\nUsing summary statistics avoids the curse of dimensionality (see~\\cite{bellmanDynamicProgramming2013}) for high\ndimension distance functions, but this adds yet another item we must specify: ``Which summary statistic is the best?''.\nIf we summarize our data wrong, we again run into the problem of drawing values that do not represent our original\ndistribution.\nWe ran several trials without reducing our dimensionality and have not run into any problems thus far.\nTo reduce noise, we are only using the angular distance $\\delta_A$ for $| \\mathbb{M} |$-dimensional vectors.\n\n\\section{Markov Chain Monte Carlo}\\label{sec:markovChainMonteCarlo}\nIn this section, we discuss the Markov Chain Monte Carlo (MCMC) approach to approximating a likelihood function.\n\n\\begin{figure}[t]\n    \\centering{\\input{include/floats/likelihood-mcmc.tex}}\n    \\caption{General figure depicting the random walk of Metropolis sampler around some surface poportional to our\n    likelihood (the posterior).\n    We start at initial state $\\theta^{(1)}$.\n    We accept $\\theta^{(2)}$ and $\\theta^{(3)}$ which leads to regions of higher likelihood but later accept\n    $\\theta^{(4)}$, a less likely point due to the randomness of $\\mathcal{V}$.\n    }\\label{fig:metropolisAlgorithm}\n\\end{figure}\n\n\\subsection{Monte Carlo}\\label{subsec:monteCarlo}\nIn~\\autoref{sec:approximateBayesianComputation}, we explored how to determine the likelihood of a single point $\\theta$.\nWe are now interested in the most likely $\\theta$ out of all possible parameter values $\\Theta$.\nWe considered a naive approach to determining the most likely point $\\hat{\\theta}$\nin~\\autoref{sec:intractableLikelihoodFunctions}, which involved determining the derivative of some function we can\nexplicitly express.\nGiven that we cannot express our function as such, this is not an option.\nThe solution Monte Carlo algorithms propose is choosing $\\theta$ randomly and select the most likely $\\theta$ out of\nall runs.\n\nLet $p$ define a probability distribution that determines how we draw $\\theta$.\n$p$ is more commonly known as a \\emph{prior distribution}, and allows us to insert any prior beliefs we have about our\nlikelihood before finding $\\mathcal{L}(\\theta)$ itself.\nIn Bayesian inference, the characterization of the uncertainty of some $\\theta$ given observations $\\mathcal{D}$ is\ngiven by another distribution known as the\n\\emph{posterior distribution}~\\cite{lintusaariFundamentalsRecentDevelopments2017}:\n\\begin{equation}\n    \\Pr(\\theta \\mid \\mathcal{D}) \\propto \\mathcal{L}(\\theta) p(\\theta)\n\\end{equation}\nAccording to Baye's law, the posterior is proportional to likelihood function we are trying to find.\nIf we can explicitly express our posterior, then the $\\hat{\\theta}$ that maximizes $\\Pr(\\theta \\mid \\mathcal{D})$ also\nmaximizes $\\mathcal{L}(\\theta)$.\n\n\\subsection{Markov Chains}\\label{subsec:markovChainMonteCarlo}\nWith the Monte Carlo strategy, our general procedure now becomes:\n\\begin{enumerate}\n    \\item Draw $\\theta_i$ from our prior $p(\\theta)$.\n    \\item Determine the likelihood of this point $\\mathcal{L}(\\theta_i)$.\n    \\item Repeat until we have a representative set of samples.\n    \\item Fit our samples to a curve, and return the $\\hat{\\theta}$ that maximizes $\\mathcal{L}(\\theta)$.\n\\end{enumerate}\nThe main problem with this approach is our reliance on the prior.\nA misinformed prior will produce samples that are not representative of the posterior.\nAs an example if $E(p(\\theta)) = 500$ but our posterior is centered around $\\theta = 1$, we will end up with a small or\nnonexistent posterior.\n\\emph{Markov Chain Monte Carlo} methods solve this by sampling more often from regions of higher likelihood.\n\nMarkov Chain Monte Carlo methods work by constructing a Markov chain such that the posterior distribution is its\nequilibrium distribution.\nWe start by defining a $\\Theta$-sized vector $Y$, indexed by all distinct $\\theta \\in \\Theta$ and whose values represent\nprobabilities associated with each $\\theta$.\n$Y$ is said to be a distribution here.\nNext we define a matrix $G$ of size $\\Theta \\times \\Theta$, whose entries describe the probability of transitioning\nfrom one $\\theta$ (row) to another $\\theta$ (column).\n$G$ is known as a \\emph{transition matrix}.\nWe are able to move from distribution $Y^{(i)}$ to $Y^{(i + 1)}$ using $G$:\n\\begin{equation}\n    Y^{(i + 1)} = Y^{(i)} G\n\\end{equation}\n$Y$ is said to be at \\emph{equilibrium} if the following holds true for some transition matrix $G$:\n\\begin{equation}\n    Y^{(i)} = Y^{(i)} G\n\\end{equation}\nThe goal of MCMC is to draw samples $X$ from $Y$ such that $Y$ represents our posterior $\\Pr (\\theta \\mid \\mathcal{D})$.\nLet $X$ represent this \\emph{chain} of states, or parameter values $\\theta$, that satisfy the\nconditions below to draw from such a distribution~\\cite{hanadaMarkovChainMonte2018}:\n\\begin{enumerate}\n    \\item \\emph{$X$ is a Markov chain}.\n        The probability of obtaining $X^{(i)} \\in X$ from $X^{(i - 1)} \\in X$ does not depend on any other configuration\n        $X^{(i - 2)}, X^{(i - 3)}, \\ldots, X^{(1)}$ other than $X^{(i - 1)}$ itself.\n    \\item \\emph{$X$ is irreducible}.\n        This states that we are able to travel to all of $\\Theta$ from any given $\\theta$ in a finite number of\n        transitions.\n    \\item \\emph{$X$ is aperiodic for all configurations}.\n        A state $\\theta$ is aperiodic if there exists a $i$ such that for all $j \\geq i$:\n        \\begin{equation}\n            \\Pr \\left( X^{(j)} = \\theta \\mid X^{(1)} = \\theta \\right) > 0\n        \\end{equation}\n    \\item \\emph{$X$ is positive recurrent}.\n        The states that the expected number of transitions to move to back to the same state is finite.\n\\end{enumerate}\nMCMC comprises a class of algorithms that are able to produce $X$ that satisfy these conditions.\n\n\\subsection{Metropolis Algorithm}\\label{subsec:metropolisAlgorithm}\nAs per our last section, we want to generate some chain of states $X$ such that the given conditions are satisfied.\nIn this section, we describe the Metropolis algorithm-- a procedure that is able to generate a chain of states such that\nthese conditions above are met.\nThere are three main steps to the Metropolis algorithm:\n\\begin{enumerate}\n    \\item \\emph{Proposal}: We define some function $g : \\Theta,\\mathbb{V} \\rightarrow \\Theta$ which generates a\n        new and random $\\theta_i$ given an old $\\theta'$.\n        This relates to the transition matrix $G$ from~\\autoref{subsec:markovChainMonteCarlo}, and constructs different\n        $G$ for different values of $\\theta_i$.\n        The Metropolis algorithm is a special case of the \\emph{Metropolis-Hastings algorithm} in which this proposal is\n        \\emph{symmetric}.\n        A symmetric proposal indicates that the probability of drawing our new value given our current value is equal to\n        the probability of drawing our current value given our new value.\n    \\item \\emph{Calculate}: We determine the acceptance ratio $\\alpha$, which is a ratio of the proposed $\\theta^{(i)}$\n        to the old $\\theta'$.\n    \\begin{equation}\n        \\alpha = \\frac{\\mathcal{L}(\\theta_i)}{\\mathcal{L}(\\theta)}\n    \\end{equation}\n    \\item \\emph{Accept}: We save $\\theta_i$ and $\\mathcal{L}(\\theta_i)$ to our collection of states if and only if\n        $\\theta_i$ is more likely than the old $\\theta'$ \\emph{or} the ratio of proposed to old likelihoods is greater\n        than some uniform random variable $U(0, 1)$.\n        If this is not true, then we go back to step (1) until we have run $T_2$ iterations.\n\\end{enumerate}\n\n\\begin{algorithm}[t]\n    \\SetAlgoLined\n    \\DontPrintSemicolon\n    \\Fn{MetropolisSampler \\ {$(T_2, \\mathcal{L}, \\theta^{(1)}, g)$}} {\n        \\KwIn{number of algorithm iterations $T_2$, likelihood function $\\mathcal{L}$, initial state $\\theta_1$,\n        proposal function $g$}\n        \\KwOut{samples from our posterior distribution $\\Pr(\\theta \\mid \\mathcal{D})$}\n        $X \\gets \\emptyset$, $\\theta' \\gets \\theta^{(1)}$ \\;\n        \\For{$i \\gets 1$ \\KwTo $T_2$}{\n            $\\theta^{(i)} \\gets g(\\theta')$ \\;\n\n            \\If{$\\mathcal{L}(\\theta^{(i)}) \\cdot \\mathcal{L}(\\theta')^{-1} \\leq \\ \\sim U(0, 1)$}{\n                $\\theta' \\gets \\theta_i$, $X \\gets X \\cup \\{ \\theta^{(i)} \\}$ \\;\n            }\n        }\n\n        \\Return $X$ \\;\n    }\n%    \\textbf{end} \\;\n    \\caption{The Metropolis algorithm, used to produce samples from a posterior distribution proportional to our\n    likelihood.}\n    \\label{alg:metropolis}\n\\end{algorithm}\n\nNote that we have introduced three new hyperparameters here: our initial Markov chain position $\\theta^{(1)}$,\nour proposal function $g$, and the number of Metropolis sampler iterations $T_2$.\nIf $\\theta^{(1)}$ is nowhere near the regions of high likelihood, if $g$ is too tightly or loosely distributed, or if we\ndo not run our sampler for enough iterations, we say that our Markov chain has not \\emph{converged}.\nNonconvergence means that we cannot interpret anything meaningful from $X$, making the selection of these\nhyperparameters \\emph{and} some convergence verification process critical.\n\n\\section{Maximum Likelihood Estimation}\\label{sec:maximumLikelihoodEstimation}\nIn this section, we explore a high level view of our approach to maximum likelihood estimation.\nUsing the Metropolis sampler, we are able to get a collection of states $X$ from a distribution proportional to our\nlikelihood.\nWe now want to tie this back into our original question: ``Which parameter values $\\theta \\in \\Theta$ are the most\nlikely to produce our observations $\\mathcal{D}$?''.\nGiven states $X$ from our posterior, we determine this most likely point $\\theta$ by (a) constructing histograms, (b)\nfitting the histograms to the equation of some distribution, and (c) determining the mean of this distribution.\n\nWe start by constructing our histogram.\nFor this project, each $\\theta$ represents a 2-tuple of $c$ and $d$.\nWe construct sets $C, D$ which consist of each $c$ and $d$ element for all $\\theta \\in X$:\n\\begin{align}\n    C &= \\{c \\mid c \\in \\theta \\land \\theta \\in X \\} \\\\\n    D &= \\{d \\mid d \\in \\theta \\land \\theta \\in X \\}\n\\end{align}\nWe now want to partition each set $C$ and $D$ sets into consecutive, non-overlapping intervals or \\emph{bins}\n$C^\\star$ and $D^\\star$ respectively.\nThe partitioning itself is governed by the boundaries of our results $[\\min(C), \\max(C)]$,\n$[\\min(D),\\max(D)]$, and the \\emph{bin widths} $b_c$ and $b_d$ for the $c$ and $d$ parameters respectively.\nThis gives us the number of bins:\n\\begin{equation}\n    \\begin{aligned}\n        | C^\\star | &= \\left\\lceil \\frac{\\max(C) - \\min(C)}{b_c} \\right\\rceil \\\\\n        | D^\\star | &= \\left\\lceil \\frac{\\max(D) - \\min(D)}{b_d} \\right\\rceil\n    \\end{aligned}\n\\end{equation}\nWe build our histogram for $c$ by constructing the function $w_c : [0, |C^\\star |] \\rightarrow [0, 1]$ that accepts\nan integer that enumerates our bins and outputs the frequency of associated with that bin.\nThe end result must follow the property in~\\autoref{eq:densityFunction} to ensure our histogram\nrepresents some probability density function.\n\\begin{equation} \\label{eq:densityFunction}\n    \\int_{i=C^\\star} w(i) di = 1\n\\end{equation}\n\nThe next step is to fit our histogram $w_c$ to some known distribution.\nWe explored two distributions here: the normal distribution and the gamma distribution.\nIf we assume that our posterior for some $C$ is normally distributed, we can use the function below:\n\\begin{equation}\\label{eq:normalDistribution}\n    w_{cN}(c) = \\frac{\\exp(\\frac{\\left( \\sfrac{(c - \\mathit{loc})}{\\mathit{scale}} \\right)^2}{2} )}\n    {\\mathit{scale} \\cdot \\sqrt{2\\pi}}\n\\end{equation}\nTo get the point of maximum likelihood point $\\hat{c}$ using $w_{N}(c)$ is to obtain its mean.\nFor the distribution in~\\autoref{eq:normalDistribution}, this is the $\\mathit{loc}$ parameter with variance\n$\\mathit{scale}$.\nIf we instead assume our posterior for some $C$ is gamma distributed, we can use the function below:\n\\begin{equation}\n    w_{c\\Gamma}(c) = \\frac{(x-\\mathit{loc})^{a-1}\\exp(-\\frac{c-\\mathit{loc}}{\\mathit{scale}})}{\\mathit{scale}^a\n    \\cdot \\Gamma(a)}\n\\end{equation}\nwhere $\\mathit{loc}$ represents a horizontal shifting parameter, $\\mathit{scale}$ represents the scaling parameter of\nour distribution, and $a$ represents the gamma distribution \\emph{shape} or skew parameter.\nAgain, the maximum likelihood $\\hat{c}$ using this $w_\\Gamma(c)$ is the mean.\nFor the distribution given above, this is equal to $a \\cdot \\mathit{scale} + \\mathit{loc}$ with variance\n$a \\cdot \\mathit{scale}^2$.\nFor both cases, these steps are then repeated for $D$ to obtain $\\hat{d}$.\n", "meta": {"hexsha": "cdbd283786fb59ad9f09a610f9f62e9eb2cb2b3b", "size": 22473, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/include/parameter.tex", "max_stars_repo_name": "glennga/kumulaau", "max_stars_repo_head_hexsha": "18a6b1b8dbde1c78f5615af6bf391ef52c98cf77", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/include/parameter.tex", "max_issues_repo_name": "glennga/kumulaau", "max_issues_repo_head_hexsha": "18a6b1b8dbde1c78f5615af6bf391ef52c98cf77", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/include/parameter.tex", "max_forks_repo_name": "glennga/kumulaau", "max_forks_repo_head_hexsha": "18a6b1b8dbde1c78f5615af6bf391ef52c98cf77", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.1264044944, "max_line_length": 134, "alphanum_fraction": 0.7289636453, "num_tokens": 6135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4110511474443969}}
{"text": "%\\section{Physical Human Factors Report: Tristan Griffith}\n\\rhead{\\today}\n\\begin{center}\n{\\large  Tristan Griffith}\\\\\n\\vspace{2mm}\n{\\large Dr. James Hubbard Jr.}\n\\noindent\\rule{\\textwidth}{2pt}\n\\end{center}\n\\setcounter{section}{1}\n\n%\\begin{wrapfigure}{r}{0.45\\textwidth}\n%\\centering\n%\\includegraphics[scale=.3]{../../../figures/demo_map.png} \n%\\caption{Modal Heatmap for Subject 32}\n%\\end{wrapfigure}\n\\subsection{Introduction}\nWe inquire concerning the nature of traveling waves in the brain. Under this head there are three points of inquiry:\n\\begin{enumerate}\n\\item Whether the brain has traveling waves?\n\\item Whether fMRI waves are connected to EEG waves?\n\\item If traveling waves exist, are they relevant to clinical outcomes?\n\\end{enumerate}\n\\subsection{Whether the brain has traveling waves?}\n\\textbf{Keyword differences:} First, note that the notion of a traveling wave is different for neuroscience and engineering. Neuroscientists would denote any brain wave that is observable across the sensor locations as a traveling wave. Engineers reserve traveling wave for behavior which is not in phase across the spatial sensors. In phase behavior is called a standing wave, while out of phase is a traveling wave. Neuroscientists would call both traveling waves. Going forward, I will use traveling wave in the engineering sense, denoting standing waves where needed. \\\\\n\\textbf{Objection 1:} Prior work has shown repeated decoherence among spatially distributed recordings of brain activity. Theta oscillations in humans are postulated to have only local mechanisms \\cite{doi:10.1152/jn.00409.2005}. \n\\begin{displayquote}\n We found that, whereas nearby gated sites $(<20 \\textit{mm})$ were often but not always coherent, distant gated sites were almost never coherent. Our results imply that there are local mechanisms for the generation of cortical theta.\n\\end{displayquote}\n\\textbf{Objection 2:} While inter-electrode spatial correlations in the gamma band have been discovered in animals, the same was not found in humans \\cite{MENON199689}.\n\\begin{displayquote}\nThe findings suggest that the surface diameters of domains of spatially correlated activity underlying perceptual categorization in human gamma band ECoG are limited to less than 2 cm and that the intermittent synchronization observed across separations of 1 cm and 1.4 cm is not solely due to volume conduction. Thus, if such gamma band spatial patterns exist in the human brain, no existing technology would be capable of measuring them at the scalp, and subdural electrode arrays for cortical surface recording would have to have spacings under 5 mm.\n\\end{displayquote}\n\\textbf{Objection 3:} Using statistical methods, EEG coherence was found to decline substantially in space across all frequency bands \\cite{BULLOCK1995161}.\n\\begin{displayquote}\nIn both the subdural surface samples and those from temporal lobe depth electrode arrays coherent declines with distance between electrodes of the pair, on the average quite severely in millimeters. This is nearly the same for all frequency bands. \n\\end{displayquote}\n\\textbf{On the contrary,} it has been found most recently that when \\textbf{phase} is considered as part of the spatial coherence, traveling and standing waves are observed across a broad spectrum for most subjects \\cite{ZHANG20181269}.\\\\\n\nI argue that, in each of the objections above, the possibility of complex traveling waves was ignored. In each of these studies, it was assumed that the spatial activity of the brain's electrical activity would be described by perfect sine and cosine waves in two dimensions. This excludes the possibility of damping in the oscillatory behavior of the electrical activity. Many mechanical systems have damping, so why should we exclude this possibility in the analysis of the brain? To this end, our output only modal analysis has shown significant spatial dependence when both proportional and non-proportional damping is considered. Unlike the objections above, the naiveté of our engineering first approach is a strength, because it does not exclude the possibility of complex eigenmodes. Further, studies \\cite{doi:10.1152/jn.00409.2005} and \\cite{BULLOCK1995161} argue that low correlation of the band power is sufficient evidence to exclude the possibility of spatial dependence in the activity of the brain. I argue that a single, simple statistical tool is not sufficient proof for such a broad claim. There is no consideration of phase or damping.  Ultimately, we discovered that 20\\% of the eigenmodes are damped on average, with 50\\% showing some out of phase behavior. At present this issue is \\textbf{closed.}\n\\subsection{Whether fMRI waves are connected to EEG waves?}\n\\textbf{Objection 1:} Using band power and statistical tests, EEG and fMRI were found to be inversely correlated on average, but not significantly enough to report \\cite{LAUFS20031463}:\n\\begin{displayquote}\nA more general problem is that our current understanding of EEG and fMRI (or PET) signals does not allow us to extrapolate whether and, if so, how the oscillatory synchronization of electrical synaptic activity in the alpha band translates into hemodynamic signals. The mere fact that synaptic activity takes on the temporal structure of an oscillation does not mean that net synaptic activity changes over time, and the oscillation frequencies of physiological rhythms themselves are beyond the temporal resolution of hemodynamic signals.\n\\end{displayquote}\n\\textbf{Objection 2:} In a comprehensive survey, \\cite{SALEKHADDADI2003110} reports that despite improvements in sensing technology, disparate studies considering many different hypotheses have been unable to realize a unified connection between fMRI and EEG. Questions even arise concerning the nature of spontaneous EEG (e.g. is the rest state actually a rest state?). Because it is difficult to define consistent operating conditions from subject to subject a connection between fMRI and EEG is non-trivia:\n\\begin{displayquote}\nWe have reviewed the existing literature on this topic and have explored both the theoretical and practical limitations of EEG/fMRI with specific emphasis on studying the generators of IEDs. We envisage that further characterization of the BOLD correlates of spontaneous EEG activity and the development of ever more sophisticated fMRI models will constitute a significant effort over the next few years.\n\\end{displayquote}\n\\textbf{Further,} A despite a great amount of effort, experimental and theoretical work has been unable to explain the link between EEG and BOLD signals, as discussed in \\cite{10.3389/fneur.2013.00001}:\n\\begin{displayquote}\nThe most consensual evidence comes from the recording of electrical activity using micro-electrodes implanted in the cortex of (non-human) animals, simultaneously with fMRI, indicating that the BOLD signal reflects mostly slow, post-synaptic input activity measured by local field potentials (LFPs), rather than fast, spiking output activity measured by single/multi-unit activity (S/MUA; Logothetis et al., 2001). In humans, a growing number of simultaneous EEG-fMRI studies on healthy subjects as well as epilepsy patients have now been reported (Goldman et al., 2002; Laufs et al., 2003, 2006; Moosmann et al., 2003; de Munck et al., 2009), and biophysical models of the neurovascular coupling have been proposed (Riera et al., 2006, 2007). Overall, reports in the literature do not provide a clear picture of the link between EEG and BOLD signals. In particular, contradictory results have been presented regarding the dependency of BOLD changes on the EEG power and spectral profiles. These include, for example, positive and negative BOLD correlations with specific frequency band power changes in the human EEG (de Munck et al., 2009), BOLD decoupling from LFP power in mice (Ekstrom, 2010), and negative BOLD associated with large increases in LFP and MUA during seizures also in mice (Schridde et al., 2008). Rosa et al. (2010b) addressed this topic by comparing different models of the transfer function between EEG and BOLD signals, in the prediction of fMRI data, in a visual stimulation experiment with human healthy subjects. The models explored included the EEG total power (TP; Wan et al., 2006); linear combinations of the power from different frequency bands (Goense and Logothetis, 2008); and several variations of a heuristic model proposed by Kilner et al. (2005) in which BOLD changes are assumed to be proportional to the root mean square frequency (RMSF) of the EEG spectrum. The results obtained showed a clear superiority of the RMSF metrics in predicting the BOLD signal, when compared to power-weighted metrics.\n\\end{displayquote}\n\\textbf{At present,} I argue that our modal decomposition method offers a compelling spatial representation of the data which may be more easily compared with a BOLD time series. \\textcolor{red}{I estimate it would take approximately 3 weeks to process a data set with EEG and fMRI signals in order to compare the modes.} We have seen some empirical evidence that the shapes are similar, but more work is needed to verify frequencies and mode shapes are significant. At present this issue is \\textbf{\\textcolor{red}{open}} in both our work and the broader literature.\n\n\\subsection{If traveling waves exist, are they relevant to clinical outcomes?}\n\\textbf{Objection 1:} \\cite{Massimini6862} found that while a standing wave was present during sleep, there was not enough evidence to say if it was a function of the cognitive state or the natural resting state of the brain.\n\\begin{displayquote}\nThe pattern of origin and propagation of sleep slow oscillations is reproducible across nights and subjects and provides a blueprint of cortical excitability and connectivity. The orderly propagation of correlated activity along connected pathways may play a role in spike timing-dependent synaptic plasticity during sleep.\n\\end{displayquote}\n\\textbf{Objection 2:} \\cite{Takahashi0} found that as in animal brains, there are standing waves in human brains that propagate 180\\degree to each other during motor tasks. However, the same wave was observed in the ``rest\" state.\n\\begin{displayquote}\nThis study shows that the two properties of propagating beta waves are present in MI of a tetraplegic human patient while he was instructed to perform an instruction delay center-out task using a cursor controlled by the chin. Moreover, we show that beta waves are sustained and have similar properties whether the subject was engaged in the task or at rest.\n\\end{displayquote}\n\\textbf{Objection 3:} While local bursts of gamma activity were found to generate standing alpha waves, they were not connected to a task as subjects were in the ``rest\" state\\cite{Bahramisharif18849}:\n\\begin{displayquote}\nIn short, we have demonstrated here that bursts of gamma activity propagate over neocortex and the propagating gamma bursts are locked to the phase of traveling alpha waves. Our findings suggest that not only do alpha oscillations serve to coordinate the gamma activity in time, but also in space. In future work to uncover the functional role of this phenomenon would be of great interest.\n\\end{displayquote}\n\\textbf{On the contrary,} it was found that standing waves are generated reliably during a memory task, and accordingly return to a baseline level a few hundred milliseconds after the stimulus has passed \\cite{doi:10.1152/jn.00409.2005}:\n\\begin{displayquote}\nWe confirmed that these patterns were reliable by measuring the time course of mean traveling wave DC at the group level. Following cue onset, traveling waves in the temporal and frontal lobes showed increases in DC above baseline levels (Figure 4E). Inversely, traveling waves from occipitoparietal clusters showed decreased DC during this same period, which was significantly different from the DC increase in the frontal and temporal lobes. Because frontal and temporal regions specifically show increased DC following cue onset, it indicates that traveling waves in these areas move more consistently during memory retrieval.\n\\end{displayquote}\nI argue that simply observing a consistent pattern of traveling and standing waves is insufficient to draw conclusions from. Using our modal decomposition technique, we should seek to find mathematical connections between certain modes and certain tasks. As with the fMRI comparison, this is something we can look at in the coming months that has not been resolved in the larger neuroscience community. At present this issue is \\textbf{\\textcolor{red}{open}} in both our work and the broader literature.\n\n\n\n\n\n%\\begin{displayquote}\n%The class of monotone DNF expressions is learnable via an algorithm $B$ that uses $L=L(h,d)$ calls of examples and $dt$ calls of oracle, where $d$ is the degree of the DNF expression $f$ to be learnt and $t$ the number of variables.\n%\\end{displayquote}\n\n\n%\\begin{wrapfigure}{r}{0.55\\textwidth}\n%\\centering\n%\\includegraphics[scale=.5]{../figures/complexity.png} \n%\\caption{The Error-Complexity Trade Off}\n%\\end{wrapfigure}\n\n", "meta": {"hexsha": "8e107ac0c0eecb3a0e55d26fd7a0745b2620e99c", "size": 13081, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/forensic_modules/Module 2/latex_format/sections/summary.tex", "max_stars_repo_name": "tdgriffith/OoMA-omniscient", "max_stars_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/forensic_modules/Module 2/latex_format/sections/summary.tex", "max_issues_repo_name": "tdgriffith/OoMA-omniscient", "max_issues_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/forensic_modules/Module 2/latex_format/sections/summary.tex", "max_forks_repo_name": "tdgriffith/OoMA-omniscient", "max_forks_repo_head_hexsha": "1c8219588e54f8d89e974b211bdc7ac95080beed", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 146.9775280899, "max_line_length": 2039, "alphanum_fraction": 0.8083479856, "num_tokens": 2846, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4110511474443969}}
{"text": "\\chapter{parreset}\n\n\\section{Introduction}\n\nAn LPE may have parameters of which the values are not used anymore after a particular state.\nIf such parameters can have different values after that state, they continue to add states to the state space for each of those values -- \\emph{without} adding any new behavior!\n\nThe \\texttt{parreset} command tries to determine whether the value of a parameter is used by an LPE after a particular summand.\nIf this is the case, the parameter is said to be \\emph{relevant} for that summand; otherwise, the summand can `reset' the parameter, meaning that it can be assigned a default value.\n\nTo determine the relevance of parameters, \\texttt{parreset} analyzes the reachability of summands in a generalized, symbolic manner.\nThe \\texttt{datareset} command, serving a similar purpose (see \\ref{datareset}), does a control-flow analysis instead.\n\n\\section{Formal background}\n\n\\subsection{Possible successors} \\label{possiblesuccessors}\n\nConsider summands $s_\\alpha$ and $s_\\beta$, referencing their elements conform \\ref{summandelements}.\nSummand $s_\\beta$ is said to be a \\emph{possible successor} of $s_\\alpha$ if the following expression \\emph{could be} satisfiable:\n\\begin{align*}\ng_\\alpha \\land {g_\\beta}[v \\rightarrow q(v) \\;|\\; v \\in \\varsof{g_\\beta} \\setminus P][p \\rightarrow v_\\alpha(p) \\;|\\; p \\in P]\n\\end{align*}\n\nwhere $q(v)$ is a bijective function that relates variable $v$ to a fresh variable.\n\n\\section{Algorithm}\n\nThe algorithm is a generalization of an existing algorithm \\cite{van2009state}.\nIt consists of two phases.\n\nDuring the first phase (the preparation phase), we determine all successors of each summand of the LPE using the equation from the previous section.\n\nThe second phase (the iteration phase) follows these steps:\n\n\\begin{enumerate}\n\n\\item For each summand $s_\\alpha$ of the LPE, create a set $R_\\alpha$ that contains all parameters of the LPE.\nThis means that, initially, we assume that all parameters of the LPE are used by one or more of the successors of $s_\\alpha$; that is, \\emph{relevant} to $s_\\alpha$.\n\n\\item For each summand $s_\\alpha$ of the LPE, set the value of $R_\\alpha$ to $\\bigcup\\limits_{s_\\beta \\in S_\\alpha}^{} r(s_\\beta)$ where $S_\\alpha$ is the set of all successors of $s_\\alpha$ (as determined during the preparation phase) and where $r$ is the function\n\\begin{align*}\nr(s_\\beta) = \\left( \\text{vars}(g_\\beta) \\cup \\bigcup\\limits_{x \\in R_\\beta}^{} \\text{vars}(v_\\beta(x)) \\right) \\setminus C_\\beta\n\\end{align*}\n\n\\item Repeat the previous step until the fixpoint of $R_\\alpha$ is reached for each summand $s_\\alpha$ of the LPE.\n\n\\item For each summand $s_\\alpha$ and for all $p \\in P \\setminus R_\\alpha$, change the expression $v_\\alpha(p)$ (which defines the value of LPE parameter $p$ after the application of $s$) to $v_I(p)$, the value of $p$ in this initial state of the LPE.\n\n\\end{enumerate}\n\n\\section{Example}\n\nConsider the following LPE:\n\n\\begin{lstlisting}\n//Process definition:\nPROCDEF example[A :: Int, B](x, y :: Int)\n  = A ? i [[x==0]] >-> example[A, B](1, i)\n  + A ? i [[x==1 && i==y]] >-> example[A, B](2, y)\n  + B [[x==2]] >-> example[A, B](3, y)\n  + B [[x==3]] >-> example[A, B](0, y)\n  ;\n\n//Initialization:\nexample[A, B](0, 0);\n\\end{lstlisting}\n\nLet the summands be represented by $s_1$ from $s_4$ (from top to bottom).\n\nFinding the successors of each summand is easy: each summand has exactly one successor, namely the next one, except in case of $s_4$, where the $s_1$ is the successor.\n\nIt is also obvious that $x$ will always be in $R_\\alpha$ for each summand $s_\\alpha$, because each summand $s_\\alpha$ uses $x$ in its guard.\n\nProcess parameter $y$ will always be in $R_1$ because $y$ is used in the guard of $s_1$'s successor, $s_2$.\nAfter a few iterations, however, $y$ is removed from $R_2$, $R_3$, and $R_4$.\nThis means that $y$ is assigned a default value in $s_2$, $s_3$, and $s_4$.\nChoosing the initial value of $y$ as its default value gives\n\n\\begin{lstlisting}\n//Process definition:\nPROCDEF example[A :: Int, B](x, y :: Int)\n  = A ? i [[x==0]] >-> example[A, B](1, i)\n  + A ? i [[x==1 && i==y]] >-> example[A, B](2, 0)\n  + B [[x==2]] >-> example[A, B](3, 0)\n  + B [[x==3]] >-> example[A, B](0, 0)\n  ;\n\n//Initialization:\nexample[A, B](0, 0);\n\\end{lstlisting}\n\n\\section{Benchmark results}\n\nThe following durations were measured with a benchmark for several models:\n\\begin{itemize}\n\\item The average duration of \\txs{} to make 500 steps in a model after it has been converted to LPE form;\n\\item The average duration of \\txs{} to make 500 steps in a model after it has been converted to LPE form and after the \\texttt{parreset} operation has been applied.\n\\end{itemize}\n\nWhen plotting the second series of measurements against the first (see Figure~\\ref{parreset-vs-lpe-only:fig}), it is easy to see that the impact is insignificant in most cases.\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{charts/parreset-vs-lpe-only}\n\\caption{Benchmark results: parreset vs LPE transformation}\n\\label{parreset-vs-lpe-only:fig}\n\\end{center}\n\\end{figure}\n\n\n", "meta": {"hexsha": "db52229b5c349ae574a30c26aff1bcf23ead5fb5", "size": 5094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sys/lpeops/tex/lpeopsDoc/parreset.tex", "max_stars_repo_name": "ikbendedjurre/TorXakis", "max_stars_repo_head_hexsha": "a791ce9960e88df576733404fe4d60114c35e50a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 44, "max_stars_repo_stars_event_min_datetime": "2017-06-09T08:17:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-08T02:17:01.000Z", "max_issues_repo_path": "sys/lpeops/tex/lpeopsDoc/parreset.tex", "max_issues_repo_name": "ikbendedjurre/TorXakis", "max_issues_repo_head_hexsha": "a791ce9960e88df576733404fe4d60114c35e50a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 746, "max_issues_repo_issues_event_min_datetime": "2017-06-13T07:36:42.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T19:14:31.000Z", "max_forks_repo_path": "sys/lpeops/tex/lpeopsDoc/parReset.tex", "max_forks_repo_name": "ikbendedjurre/txs-develop", "max_forks_repo_head_hexsha": "bc11f4b93a15e220bf6941d395d5b4cd361bfe74", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2017-11-16T11:33:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-26T16:33:36.000Z", "avg_line_length": 45.8918918919, "max_line_length": 265, "alphanum_fraction": 0.7196702002, "num_tokens": 1498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4110511474443968}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\title{Weekly Report}\n\\author{Junior Team }\n\\date{June 2020}\n\n\\usepackage{natbib}\n\\usepackage{graphicx}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{IRB Data Analysis}\nOnce we had the IRB model set up and could optimize over $P_t$, $P_n$, and the maximum width, our goal was to begin to identify trends in the data.\n\n\\section{Normal and Tangential Impulses}\nThe first interesting correlation we found was between the tangential impulse ($P_t$) and the optimal patch width, which can also be interpreted as the moment applied due to the patch width.\n\n\n\\begin{figure}[h!]\n\\centering\n\\caption{Tangential Impulse vs Optimal Width}\n\\includegraphics[scale=0.2]{tanImpulse}\n\\label{fig:tanImpulse}\n\\end{figure}\n\n\\noindent In the figure above, the constraint $\\mbox{width} \\leq 1 \\mbox{cm}$ was used for 1000 different impacts. The correlation coefficient between $P_t$ and width was $ -0.9283$. \\\\\n\n\\noindent  When examining normal impulse ($P_n$) we did not find a clear linear trend, however there seemed to be an impulse threshold below which the optimal width was only zero. From this, we hypothesized that perhaps, those cases to the left of the threshold were below a certain energy threshold, or were lower energy impacts. This would lead to a smaller increase in angular velocity after impact, and less energy in the restitution phase. As a consequence, a patch width which creates a moment and greatly increases the angular velocity ($\\dot\\theta$) would not be optimal.\\\\\n\n\\noindent To test this hypothesis, we plotted pre- and post-impact kinetic energy versus the optimal patch width. The plots seem to disprove the idea that there is any relationship between zero patch width being optimal and a lower energy collision. \n\n\\begin{figure}[ht]\n    \\caption{Kinetic Energy Analysis}\n    \\centering\n    \\begin{subfigure}[b]{0.45\\linewidth}\n        \\includegraphics[scale=0.12]{preImpactEnergy.jpg}\n        \\caption{Pre Impact KE}\n        \\label{fig:preKE}\n    \\end{subfigure}\n    \\quad\n    \\begin{subfigure}[b]{0.45\\linewidth}\n       \\includegraphics[scale=0.12]{postImpactEnergy.jpg}\n        \\caption{Post Impact KE}\n        \\label{fig:postKE}\n    \\end{subfigure}\n\\end{figure}\n\n\\noindent Additionally, we took a look at the correlation between the net moment and impulses generated from the impact. When inspecting the normal impulse, we found no correlation between the normal impulse and the net moment generated by the ellipse. This is expected, since the configuration of the ellipse as it contacts the surface can be varied greatly, so there should be no definite correlation if the trajectory of the ellipse is not meant to be uniform. \\\\\n\n\\noindent On the other hand, when inspecting the tangential impulse of the ellipse, we find an interesting scatter plot that illustrates a negative correlation between net moment and tangential impulse. Since we assume that the tangential impulse mostly consists of frictional forces and we know that friction tends to oppose motion, we would expect the tangential impulse to be negative when the ellipse has a positive rotation and vice versa. Hence the negative correlation which can be depicted in Fig \\ref{fig:tanImpulse2}.\n\n\n\\begin{figure}[ht]\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.35]{netMomentvsNormImpulse.jpg}\n    \\caption{Normal Impulse}\n    \\label{fig:normImpulse}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.35]{netMomentvsTanImpulse.jpg}\n    \\caption{Tangential Impulse}\n    \\label{fig:tanImpulse2}\n  \\end{subfigure}\n  \\caption{Impulse vs Net Moment}\n\\end{figure}\n\n\\newpage\n\\section{Pre-Impact Angle}\nThe next thing we chose to explore was the relationship between the pre-impact angle ($\\theta^+$) and the optimal width. After a plot with a clear trend whose shape resembled an X and Dr. Posa's recommendation, we adjusted the angle transformation to get a cleaner range of angles (wrapped from [$-\\pi, \\pi$]). We then found another interesting correlation, when the pre-impact angle was plotted with the optimal width, the curve resembled a sin curve. \n\n\\begin{figure}[h!]\n\\centering\n\\caption{Pre-Impact Angle vs. Optimal Width}\n\\includegraphics[scale=0.2]{preImpactAngle}\n\\label{fig:preAngle}\n\\end{figure}\n\n\\noindent The red curve Width $= \\frac{1}{100}(sin(2\\theta)+0.3)$ clearly correlates with the data. The next thing we checked was whether there was a similar relationship with angular velocity (either $\\dot\\theta^+$ or $\\dot\\theta^-$), but there appeared to be nothing. \\\\\n\n\\noindent Interestingly, when we plotted error vs. pre-impact angle for the AP Poisson model and the change in rotational velocity vs. pre-impact angle for the IRB model, the plots also followed a $sin(2\\theta)$ trend. \\\\\n\n\\noindent We wanted to explore whether the width depended on the moment arms (Tangential moment arm: vertical distance from the contact point to the COM, normal moment arm: horizontal distance from the contact point to the COM). \\\\\n\n\\noindent The following figures were made without any sort of optimization or considering any impulses. These are just geometric relationships that occur because of the elliptical shape of the object. Whenever the optimal width graphs are mentioned, Figure \\ref{fig:preAngle} of Optimal width vs Angle is referenced. \\\\\n\n\\noindent Figure \\ref{fig:TanMomentArmVsAngle} shows the relation between the orientation of the ellipse and the tangential moment arm. It shows how that the optimal width is at its max when the tangential moment arm is at its minimum and vice versa, since the optimal width takes the form of a sine wave and the tangential moment arm takes the form of a flipped cosine wave. They both have the same frequency, y-offset, and scaling. The only difference is the amplitude. \n\n\\noindent Figure \\ref{fig:NormMomentArmVsAngle} shows the relation between the orientation of the ellipse and the normal moment arm. It shows that the optimal width and the normal moment arm are \\textbf{\\textit{identical}} in every way, except for the y offset and the reflection of the sine graph of the normal moment arm on the x-axis. This means that there is a direct correlation between the horizontal distance between the contact point and the COM, and the optimal width to account for the rotational impulse.\n\n\\begin{figure}[ht]\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.14]{TanMomentArmVsAngle.jpg}\n    \\caption{ Tangential Moment Arm}\n    \\label{fig:TanMomentArmVsAngle}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.14]{NormMomentArmVsAngle.jpg}\n    \\caption{Normal Moment Arm}\n    \\label{fig:NormMomentArmVsAngle}\n  \\end{subfigure}\n  \\caption{Moment Arms vs Angle}\n\\end{figure}\n\n\\noindent These relations agree with our predictions and reason.\n\n\\section{Moment and Patch Size}\n\\noindent Initially, we investigated patch size by taking the absolute value of moment. With this, we would see a plot fairly symmetric about $x = 0$ which makes sense since extending the patch from either direction of the center of the contact point should theoretically yield moments equal in magnitude but opposite in sign. However, when we remove this restriction, we can see a linear relationship between net moment and width (Fig \\ref{fig:momentPSize}). Dr.\\ Posa believed that all of this was pointing towards the idea that error and net moment are correlated, and predicted moment is essentially off by a linear factor:\n\\begin{align}\n    M_{actual} = k * M_{predicted}\n\\end{align}\n\n\\begin{figure}[h!]\n\\centering\n\\caption{Net Moment vs. Optimal Patch Size}\n\\includegraphics[scale=0.55]{momentPSize}\n\\label{fig:momentPSize}\n\\end{figure}\n\n\\begin{align}\n    \\mbox{Best Fit Line: } width = 10.06 * M_{net} - 0.0345\n\\end{align}\n\\begin{center}\n    Where width and the net moment match the units from the axes in Fig \\ref{fig:momentPSize}.\n\\end{center}\n\n\\newpage\n\n\\section{Clumping and Convexity}\nWhen we were investigating different potential correlations we began to notice clumping around a patch width of 0 (Fig \\ref{fig:tanImpulse}, Fig \\ref{fig:preKE}, Fig \\ref{fig:postKE}) when we capped the maximum width. For the optimal patch width to be around zero for a given trial when the width is capped below the optimal width, but then have a nonzero optimal width when the range is increased means our solutions were non-convex. This goes against expectations for this sort of problem.To look more closely into why the clumping was occurring, we made fixed width vs error plots for different trials. The shapes of the graphs however, did not give us much insight on why we found clumping, since they seemed to point towards a convex solution. \n\n\\begin{figure}[ht]\n  \\centering\n  \\caption{Set Width vs Error Plots for Individual Trials}\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.4]{Nat1.jpg}\n    \\caption{Trial 8}\n    \\label{fig:cov1}\n  \\end{subfigure}\n  \\begin{subfigure}[b]{0.4\\linewidth}\n    \\includegraphics[scale=0.4]{Nat2.jpg}\n    \\caption{Trial 31}\n    \\label{fig:cov2}\n  \\end{subfigure}\n\\end{figure}\n\n\\noindent This is something we will continue to investigate, but for now we will stick to not capping the width at the previously used $1cm$ since we know nearly all of the clumping can be avoided if the cap is raised just half a centimeter to $width_{max} = 1.5cm$.\n\n\\newpage\n\n\\section{AP Poisson and Wang Mason}\nAnother thing we did this week was see if we could replicate some of our findings from the IRB model in the two models we had previously worked on and whether we would see similar trends. For the Wang Mason model, we checked for a $x_1$ position we could apply the impulsive forces to minimize error that was within 30\\% of it's original value. The plots involving tangential or normal impulse vs. moment matched nicely with those from the IRB model (Fig \\ref{fig:normImpulse}, Fig \\ref{fig:tanImpulse2}). \\\\\n\n\\noindent A similar approach was taking with the AP Poisson model, where the $x_1$ position was shifted to add an additional moment, also within 30\\% of the original value. The tangential and normal impulse plots resembled both Wang and IRB but were not quite as similar. We did observe the same trend between error and pre-impact angle:\n\n\\begin{figure}[h!]\n\\centering\n\\caption{Error vs Pre-Impact Angle (AP Poisson)}\n\\includegraphics[scale=0.25]{andy1}\n\\label{fig:andy1}\n\\end{figure}\n\n\\noindent The figure shows how the normalized velocity error follows a similar $sin(2\\theta)$ trend to what was observed in the IRB model.\n\n\n\\end{document}\n", "meta": {"hexsha": "fc19b2237cfdeeb4760959b41149d74546cad303", "size": 10651, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Weekly Reports/Weekly Report 621/main.tex", "max_stars_repo_name": "DAIRLab/ImpactModeling", "max_stars_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-19T21:01:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-02T08:56:34.000Z", "max_issues_repo_path": "Weekly Reports/Weekly Report 621/main.tex", "max_issues_repo_name": "DAIRLab/ImpactModeling", "max_issues_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Weekly Reports/Weekly Report 621/main.tex", "max_forks_repo_name": "DAIRLab/ImpactModeling", "max_forks_repo_head_hexsha": "f6c28898845da6d48efdd6c1c696db2fb3716edf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T21:01:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T21:01:28.000Z", "avg_line_length": 61.2126436782, "max_line_length": 749, "alphanum_fraction": 0.7700685382, "num_tokens": 2673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.41105114380030705}}
{"text": "\\documentclass{article}\r\n\r\n\\title{\\sc\\LARGE CSCA67 Tutorial, Week 2\\\\\r\n{\\Large Sept. 21st-25th, 2015}}\r\n\\date{}\r\n\\author{\\sc Compiled by {\\em G. Singh Cadieux}\\\\[1ex]\r\n\\sc Adapted from\\\\\r\nA. Bretscher, \\href{http://www.utsc.utoronto.ca/~bretscher/a67/lectures/w2.pdf}{\\em CSCA67 Week 2 Lecture Notes},\\\\\r\n\\href{http://www.intmath.com/counting-probability/3-permutations.php}{\\em Interactive Mathematics: Permutations (Ordered Arrangements)},\\\\\r\n\\href{http://www.intmath.com/counting-probability/4-combinations.php}{\\em Interactive Mathematics: Combinations (Unordered Selections)},\\\\\r\nHunter, David J. \\textit{Essentials of Discrete Mathematics.} Jones \\& Bartlett, 2012. \\&\\\\\r\nLov\\'{a}sz, et al. \\textit{Discrete Mathematics: Elementary and Beyond.} Springer, 2003.}\r\n\r\n\\usepackage{fullpage}\r\n\\usepackage{amsmath,amssymb}\r\n%\\usepackage{color}\r\n%\\usepackage{multicol}\r\n\\usepackage{tikz}\r\n\\usepackage{hyperref}\r\n\r\n\\setlength{\\parindent}{0pt}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\r\n\\section{\\sc Review of week 2's lecture}\r\n\\subsection{\\em Sum rule vs. product rule}\r\n\\begin{tabular}{p{0.5\\textwidth}|p{0.5\\textwidth}}\r\n{\\bf Sum Rule}&{\\bf Product Rule}\\\\[0.5ex]\\hline\\hline\\noalign{\\smallskip}\r\nUsed for counting the \\textbf{total \\# of possible outcomes} of an operation which can be performed $n$ ways, each with some number of outcomes.&\r\nUsed for counting the \\textbf{total \\# of possible ways} an operation can be performed when the operation takes $k$ steps, each of which can be performed in some number of ways.\\\\\\hline\r\n\\begin{equation*}\r\n\\sum\\limits_{i=1}^n x_i\r\n\\end{equation*}\r\nwhere way $i$ has $x_i$ possible outcomes.&\r\n\\begin{equation*}\r\n\\prod\\limits_{i=1}^k x_i\r\n\\end{equation*}\r\nwhere step $k$ can be performed in $x_i$ ways.\\\\\\hline\\noalign{\\smallskip}\r\n\\multicolumn{2}{c}{\\em From Week 1's pizza example:}\\\\\\hline\\noalign{\\smallskip}\r\nUsed for counting the number of combinations of up to 5 pizza toppings.\\newline\r\nRecall:\\newline\r\n\\# of combinations of up to 5 toppings =\r\n\\begin{flushright}\r\n\\# of combinations of no toppings +\\\\\r\n\\# of combinations of 1 topping +\\\\\r\n\\ldots +\\\\\r\n\\# of combinations of 5 toppings\r\n\\end{flushright}\r\n&\r\nUsed for counting the number of combinations of 5 pizza toppings (and 4, 3, etc.).\\newline\r\nRecall:\\newline\r\n\\# of (non-unique) combinations of 5 toppings =\r\n\\begin{flushright}\r\n\\# of ways to choose first topping $\\times$\\\\\r\n\\# of ways to choose second topping $\\times$\\\\\r\n\\ldots $\\times$\\\\\r\n\\# of ways to choose fifth topping\r\n\\end{flushright}\r\n\\end{tabular}\r\n\r\n\\subsection{\\em Permutation vs. combination}\r\n\\begin{tabular}{c|c}\r\n{\\bf Permutation}&{\\bf Combination}\\\\[0.5ex]\\hline\\hline\\noalign{\\smallskip}\r\n\\textit{Ordered} arrangement of a group of objects.& \\textit{Unordered} arrangement of a group of objects.\\\\[0.5ex]\\hline\\noalign{\\smallskip}\r\nTotal \\# of permutations of $n$ objects: $n!$&Total \\# of combinations of $n$ objects: 1\\\\[0.5ex]\\hline\\noalign{\\smallskip}\r\n{\\bf $r$-permutation:}&{\\bf $r$-combination:}\\\\\r\npermutation of $r$ objects from a group of $n$ objects&combination of $r$ objects from a group of $n$ objects\\\\[1ex]\r\nTotal \\# of $r$-permutations: $\\dfrac{n!}{(n-r)!}$&Total \\# of $r$-combinations: $\\dfrac{n!}{(n-r)!\\,r!}$\\\\[0.5ex]\\noalign{\\smallskip}\\hline\\noalign{\\smallskip}\r\nRepresented $P(n,r)$&Represented $C(n,r)$ or $\\binom{n}{r}$\r\n\\end{tabular}\\\\[2ex]\r\n\\textsc{Consider first} the number of permutations of $n$ objects.\\\\[1ex]\r\nThis is equivalent to considering the number of ways we can arrange $n$ objects. We can see that this will require $n$ steps: the first step is selecting the first object in the arrangement; the second step is selecting the second object, and so on.\\\\[1ex]\r\nUsing the product rule, we determine that\r\n\\begin{multline*}\r\n\\text{\\bf\\# of ways of permuting }n\\text{ \\bf objects}=\\text{\\# of ways of selecting the first object }\\times\\\\\r\n\\text{\\# of ways of selecting the second object }\\times\\ldots\\times\\text{\\# of ways of selecting the }n\\text{th object}\r\n\\end{multline*}\r\nWhen we select the first object, there are $n$ objects from which to choose, meaning that there are $n$ ways to select an object. When we select the second object, we select from the reduced group of $(n-1)$ objects, since we have already selected one; this means that there are $(n-1)$ ways to choose. Eventually, when we select the final, $n$th object, we select from a group of only 1 object, which can only be done in 1 way.\\\\[1ex]\r\nOverall, we can see that\r\n\\begin{equation*}\r\n\\text{\\# of ways of permuting }n\\text{ objects}=n\\times(n-1)\\times\\ldots\\times 1=n!\r\n\\end{equation*}\r\n\\textsc{Using this result,} we can determine the number of $r$-permutations of $n$ objects.\\\\[1ex]\r\nIf we select a subset of $r$ objects from an overall group of $n$ objects, we ignore the remaining $(n-r)$ objects.\\\\[1em]\r\nConsider the 2-permutations of \\{A, B, C, D, E\\}.\\\\[1ex]\r\nIf we select \\{A, B\\}, we have 2 possible 2-permutations: AB and BA. We can permute all 5 objects to obtain (among others) ABCDE, ABCED, and ABDEC. However, because we have selected only \\{A, B\\} to permute, and ABCDE, ABCED, and ABDEC contain the same permutation AB of \\{A, B\\}, these 3 are equivalent here.\\\\[1ex]\r\nTo determine the number of 2-permutations, we can diminish the number of 5-permutations (permutations of all 5 objects) by the number of 5-permutations we consider to be equivalent.\\\\[1ex]\r\nHaving selected 2 ordered objects, the remaining 3 objects can be permuted $3!$ times: by the same reasoning as above, we can select the third object from 3 in 3 ways; then we can select the fourth object from 2 in 2 ways; and finally, we can select the fifth object from the remaining 1 object in only 1 way.\\\\\r\nSince we are interested only in the order of the first 2 objects we selected, there are $3!$ ways that the remaining 3 objects can be selected to produce permutations we consider equivalent. So of the $5!$ total 5-permutations, we consider only 1 out of $3!$ to be a unique 2-permutation.\\\\\r\nAnd thus, there are $\\dfrac{5!}{3!}=20$ 2-permutations of \\{A, B, C, D, E\\}.\\\\[1em]\r\nWe can generalize this to say that\r\n\\begin{equation*}\r\n\\text{total \\# of }r\\text{-perms.}=\\dfrac{\\text{total \\# of perms. of }n\\text{ objects}}{\\text{total \\# of perms. of the remaining }(n-r)\\text{ objects}}=\\dfrac{n!}{(n-r)!}\r\n\\end{equation*}\\\\[1em]\r\n\\textsc{We can use this result} to determine the number of $r$-combinations of $n$ objects.\\\\[1ex]\r\nUnlike an $r$-permutation, an $r$-combination is unordered. From all possible $r$-permutations of $n$ objects, we have multiple equivalent $r$-combinations.\\\\[1em]\r\nConsider again the 2-permutations of \\{A, B, C, D, E\\}.\\\\[1ex]\r\nIf we select \\{A, B\\}, we have 2 possible 2-permutations: AB and BA. However, these are equivalent $r$-combinations, since both are composed of the same objects. For every possible 2-permutation \\{object1, object2\\}, there is another 2-permutation \\{object2, object1\\} that contains the same objects in the reverse order.\\\\[1ex]\r\nTo determine the number of 2-combinations, we can diminish the total number of 2-permutations by the number of 2-permutations which contain the same group of 2 objects.\\\\\r\nHere, there are $\\dfrac{5!}{3!}\\dfrac{1}{2}=\\dfrac{20}{2}=10$ 2-combinations of \\{A, B, C, D, E\\}.\\\\[1em]\r\nWe can generalize this to say that, in a group of $n$ objects, the number of $r$-permutations containing the same group of $r$ objects is $r!$, the number of ways that $r$ objects can be ordered. So of the $\\dfrac{n!}{(n-r)!}$ total $r$-permutations, only 1 out of $r!$ is a unique $r$-combination.\r\n\\begin{equation*}\r\n\\text{total \\# of }r\\text{-combs.}=\\dfrac{\\text{total \\# of }r\\text{-perms. of }n\\text{ objects}}{\\text{total \\# of perms. of the selected }r\\text{ objects}}=\\dfrac{n!}{(n-r)!\\,r!}\r\n\\end{equation*}\r\n\r\n\\subsection{\\em Permutation with repetition}\r\nConsider the group of letters that form the word ``banana\": \\{b, a, n, a, n, a\\}.\\\\[1ex]\r\n\\textsc{Q: How many ways can we ``arrange\" (here, permute) these letters?}\\\\[1em]\r\nIf all 6 letters were distinct, we know that there would be $6!$ arrangements. We come to this total by multiplying together the 6 ways to choose the first letter from 6 possibilities, and the 5 ways to choose the second letter from 5 possibilities, and so on.\\\\[1ex]\r\nBut because the letters here are not unique, there are fewer than 6 different ways to choose the first letter, and fewer than 5 different ways to choose the second, and so on.\\\\[1em]\r\n\\textsc{Suppose} that we convert this to a problem in which all the letters are distinct: \\{b, a$_1$, n$_1$, a$_2$, n$_2$, a$_3$\\}.\\\\[1ex]\r\nThen the arrangements ``ba$_1$a$_2$a$_3$n$_1$n$_2$\", ``ba$_1$a$_2$a$_3$n$_2$n$_1$\", and ``ba$_1$a$_3$a$_2$n$_1$n$_2$\" are distinct. But without the distinguishing subscripts - that is, where all `a's are considered equivalent and all `n's are considered equivalent - these arrangements are not distinct.\\\\[1ex]\r\nWe can re-order equivalent letters to form equivalent arrangements.\\\\\r\nFor example, we can form the same arrangement ``baanna\" by ordering the `a's and `n's as ``ba$_1$a$_2$n$_1$n$_2$a$_3$\", ``ba$_1$a$_2$n$_2$n$_1$a$_3$\", ``ba$_1$a$_3$n$_1$n$_2$a$_2$\", and ``ba$_2$a$_3$n$_1$n$_2$a$_1$\", among other ways. What differs between these is the order of the equivalent letters, but not their overall position in the arrangement.\\\\[1ex]\r\nThus, the total number of equivalent arrangements is the total number of ways we can order the equivalent letters: we can order 3 `a's in $3!$ ways, and 2 `n's in $2!$ ways. Then, by the product rule, we can order both `a's and `n's in $3!\\times 2!$ ways.\r\n\\begin{equation*}\r\n\\text{total \\# of distinct arrangements}=\\dfrac{\\text{total \\# of arrangements}}{\\text{\\# of equivalent arrangements}}=\\dfrac{6!}{3!\\,2!}=60\r\n\\end{equation*}\r\n\r\n\\textsc{Alternatively,} rather than constructing an arrangement by selecting the first letter of the arrangement, followed by the second letter, and so on, let us select one letter out of the group and assign it a place within the arrangement. Then, we select another letter from the group and assign it one of the remaining places in the arrangement. We continue this until all the letters from the group have been placed into the arrangement. For example,\r\n\\begin{center}\r\n\\begin{tikzpicture}\r\n\\draw (0,0) -- (0.5,0) node[below,align=center] {letter$_1$} -- (1,0);\r\n\\draw (1.25,0) -- (1.75,0) node[below,align=center] {letter$_2$} -- (2.25,0);\r\n\\draw (2.5,0) -- (3,0) node[below,align=center] {letter$_3$} -- (3.5,0);\r\n\\draw (3.75,0) -- (4.25,0) node[below,align=center] {letter$_4$} -- (4.75,0);\r\n\\draw (5,0) -- (5.5,0) node[below,align=center] {letter$_5$} -- (6,0);\r\n\\draw (6.25,0) -- (6.75,0) node[below,align=center] {letter$_6$} -- (7.25,0);\r\n\\node[above,align=center] at (1.75,0) {a};\r\n\\node[above,align=center] at (3,0) {b};\r\n\\node[above,align=center] at (5.5,0) {a};\r\n\\node[font=\\large] at (8.5,0.5) {a};\r\n\\node[font=\\large] at (9.5,0.4) {n};\r\n\\node[font=\\large] at (8.75,0) {n};\r\n\\draw (8.25,-0.25) rectangle (9.75,0.75);\r\n\\end{tikzpicture}\r\n\\end{center}\r\nThen, the total number of possible arrangements is the product of the number of places possible for the first letter selected, and the number of places possible for the second letter selected, and so on.\\\\[1ex]\r\nIf all 6 letters are distinct, then this gives us 6 possible places for the first letter, 5 possible places for the second, and so on, which is $6!$ in total, as expected.\\\\[1ex]\r\nHowever, because the letters here are not all distinct, if we assign one letter to letter$_1$ and another instance of that letter to letter$_3$, this is equivalent to having first assigned that letter to letter$_3$ and then, another instance of it to letter$_1$. Yet we counted fewer possible places for the first assignment than the second assignment.\\\\[1ex]\r\nTo deal with these equivalences, we assign places to all identical letters simultaneously; that is, we assign places to all 3 `a's simultaneously, and to both `n's simultaneously.\\\\[1ex]\r\nFor example, this means that the number of possible places for `n's is $\\dbinom{\\text{\\# of unassigned places}}{2}$.\\\\\r\nNote that this is no different if the letters are all distinct: $\\binom{6}{1}\\binom{5}{1}\\binom{4}{1}\\binom{3}{1}\\binom{2}{1}\\binom{1}{1}=6\\times 5\\times 4\\times 3\\times 2\\times 1=6!$.\\\\[1ex]\r\nThus, by this reasoning,\r\n\\begin{align*}\r\n\\text{total \\# of distinct arrangements}& =\\dbinom{\\text{\\# of unass. places}}{\\text{\\# of `a's}}\\dbinom{\\text{\\# of unass. places}}{{\\text{\\# of `n's}}}\\dbinom{\\text{\\# of unass. places}}{{\\text{\\# of `b's}}}\\\\\r\n& =\\dbinom{6}{3}\\dbinom{6-3}{2}\\dbinom{6-3-2}{1}\\\\\r\n& =\\dfrac{6!}{(6-3)!\\,3!}\\dfrac{3!}{(3-2)!\\,2!}\\dfrac{1!}{(1-1)!\\,1!}\\\\\r\n& =\\dfrac{6!}{3!\\,2!\\,1!}=60\r\n\\end{align*}\r\n\r\n\\textsc{In general,} there are\r\n\\begin{equation*}\r\n\\dbinom{n}{r_1}\\dbinom{n-r_1}{r_2}\\ldots\\dbinom{n-r_1-r_2-\\ldots-r_{m-1}}{r_m}=\\dfrac{n!}{r_1!\\,r_2!\\,\\ldots\\,r_m!}\r\n\\end{equation*}\r\ndistinct arrangements/permutations of $n$ objects divided into $m$ types, where $r_i$ is the number of objects of type $i=1,2,\\ldots,m$.\\\\[1ex]\r\nNote that the $n$ objects are \\textit{partitioned} into $m$ types; that is, $r_1+r_2+\\ldots+r_m=n$.\r\n\r\n\\subsection{\\em Combination/selection with repetition}\r\n\r\nConsider a situation in which a supermarket has 3 kinds of bagels: poppy seed, sesame seed, and plain.\\\\[1ex]\r\n\\textsc{Q: If you want to buy 6 bagels, how many combinations of different kinds can you get?}\\\\[1ex]\r\nIf we were selecting 6 bagels from a group of $n$ unique bagels, we know that there would be $\\dbinom{n}{6}=\\dfrac{n!}{(n-6)!\\,6!}$ possible combinations.\\\\[1ex]\r\nBut because we are selecting 6 bagels \\textit{with repetition} (we have only 3 types from which to choose, so we must have more than 1 of at least 1 type of bagel), some of these $\\binom{n}{6}$ combinations are equivalent.\\\\[1ex]\r\nFor example, suppose that we convert this to a problem in which all the bagels are unique. Then the combinations\r\n\\begin{center}\r\n\\begin{tikzpicture}\r\n\\draw (0,0) rectangle (1,1);\r\n\\draw (1.25,0) rectangle (2.25,1);\r\n\\draw (2.5,0) rectangle (3.5,1);\r\n\\draw (3.75,0) rectangle (4.75,1);\r\n\\draw (5,0) rectangle (6,1);\r\n\\draw (6.25,0) rectangle (7.25,1);\r\n\r\n\\filldraw[red] (0.5,0.5) circle (0.35);\r\n\\filldraw[white] (0.5,0.5) circle (0.15);\r\n\r\n\\filldraw[red] (1.75,0.5) circle (0.35);\r\n\\filldraw[white] (1.75,0.5) circle (0.15);\r\n\r\n\\filldraw[red] (3,0.5) circle (0.35);\r\n\\filldraw[white] (3,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (4.25,0.5) circle (0.35);\r\n\\filldraw[white] (4.25,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (5.5,0.5) circle (0.35);\r\n\\filldraw[white] (5.5,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (6.75,0.5) circle (0.35);\r\n\\filldraw[white] (6.75,0.5) circle (0.15);\r\n\r\n\\node [font=\\small] at (0.5,0.5) {1};\r\n\\node [font=\\small] at (1.75,0.5) {2};\r\n\\node [font=\\small] at (3,0.5) {3};\r\n\r\n\\node [font=\\small] at (5.5,0.5) {1};\r\n\\node [font=\\small] at (6.75,0.5) {2};\r\n\\end{tikzpicture}\\\\\r\nand\\\\[1ex]\r\n\\begin{tikzpicture}\r\n\\draw (0,0) rectangle (1,1);\r\n\\draw (1.25,0) rectangle (2.25,1);\r\n\\draw (2.5,0) rectangle (3.5,1);\r\n\\draw (3.75,0) rectangle (4.75,1);\r\n\\draw (5,0) rectangle (6,1);\r\n\\draw (6.25,0) rectangle (7.25,1);\r\n\r\n\\filldraw[red] (0.5,0.5) circle (0.35);\r\n\\filldraw[white] (0.5,0.5) circle (0.15);\r\n\r\n\\filldraw[red] (1.75,0.5) circle (0.35);\r\n\\filldraw[white] (1.75,0.5) circle (0.15);\r\n\r\n\\filldraw[red] (3,0.5) circle (0.35);\r\n\\filldraw[white] (3,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (4.25,0.5) circle (0.35);\r\n\\filldraw[white] (4.25,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (5.5,0.5) circle (0.35);\r\n\\filldraw[white] (5.5,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (6.75,0.5) circle (0.35);\r\n\\filldraw[white] (6.75,0.5) circle (0.15);\r\n\r\n\\node [font=\\small] at (0.5,0.5) {2};\r\n\\node [font=\\small] at (1.75,0.5) {3};\r\n\\node [font=\\small] at (3,0.5) {5};\r\n\r\n\\node [font=\\small] at (5.5,0.5) {3};\r\n\\node [font=\\small] at (6.75,0.5) {4};\r\n\\end{tikzpicture}\r\n\\end{center}\r\nare distinct. But without the distinguishing identifiers - that is, where all bagels of the same type are considered equivalent - these combinations are not distinct.\\\\[1ex]\r\n\\textsc{Since all} bagels of the same type are equivalent, rather than considering how to select 6 bagels one by one for the arrangement, let us consider how to divide our arrangement into 3 groups of types of bagels.\\\\\r\nFor example, we can divide our 6 possibilities into a group of 1 poppy seed bagel, a group of 4 sesame seed bagels, and a group of 1 plain bagel:\r\n\\begin{center}\r\n\\begin{tikzpicture}\r\n\\draw (0,0) rectangle (1,1);\r\n\\draw (1.25,0) rectangle (2.25,1);\r\n\\draw (2.5,0) rectangle (3.5,1);\r\n\\draw (3.75,0) rectangle (4.75,1);\r\n\\draw (5,0) rectangle (6,1);\r\n\\draw (6.25,0) rectangle (7.25,1);\r\n\\draw (7.5,0) rectangle (8.5,1);\r\n\\draw (8.75,0) rectangle (9.75,1);\r\n\r\n\\filldraw[red] (0.5,0.5) circle (0.35);\r\n\\filldraw[white] (0.5,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (3,0.5) circle (0.35);\r\n\\filldraw[white] (3,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (4.25,0.5) circle (0.35);\r\n\\filldraw[white] (4.25,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (5.5,0.5) circle (0.35);\r\n\\filldraw[white] (5.5,0.5) circle (0.15);\r\n\r\n\\filldraw[cyan] (6.75,0.5) circle (0.35);\r\n\\filldraw[white] (6.75,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (9.25,0.5) circle (0.35);\r\n\\filldraw[white] (9.25,0.5) circle (0.15);\r\n\r\n\\draw (1.25,0) -- (2.25,1);\r\n\\draw (7.5,0) -- (8.5,1);\r\n\\end{tikzpicture}\r\n\\end{center}\r\nTo mark the separation between groups, we use an empty pigeonhole. To divide our bagels into 3 groups, we require 2 pigeonholes to act as separators, and 6 filled pigeonholes + 2 empty pigeonholes = 8 piegeonholes in total.\\\\[1ex]\r\n\\textsc{In general,} to partition any number of objects into $n$ groups, we require $n-1$ empty pigeonholes.\\\\[1ex]\r\nWe can divide our 6 possibilities into 3 groups by selecting which pigeonholes will be filled and which will be empty. For example, if we select all but these pigeonholes to be filled\r\n\\begin{center}\r\n\\begin{tikzpicture}\r\n\\draw (0,0) rectangle (1,1);\r\n\\draw (1.25,0) rectangle (2.25,1);\r\n\\draw (2.5,0) rectangle (3.5,1);\r\n\\draw (3.75,0) rectangle (4.75,1);\r\n\\draw (5,0) rectangle (6,1);\r\n\\draw (6.25,0) rectangle (7.25,1);\r\n\\draw (7.5,0) rectangle (8.5,1);\r\n\\draw (8.75,0) rectangle (9.75,1);\r\n\r\n\\draw (2.5,0) -- (3.5,1);\r\n\\draw (3.75,0) -- (4.75,1);\r\n\\end{tikzpicture}\r\n\\end{center}\r\nthen our groups are 2 poppy seed bagels, 0 sesame seed bagels, and 4 plain bagels:\r\n\\begin{center}\r\n\\begin{tikzpicture}\r\n\\draw (0,0) rectangle (1,1);\r\n\\draw (1.25,0) rectangle (2.25,1);\r\n\\draw (2.5,0) rectangle (3.5,1);\r\n\\draw (3.75,0) rectangle (4.75,1);\r\n\\draw (5,0) rectangle (6,1);\r\n\\draw (6.25,0) rectangle (7.25,1);\r\n\\draw (7.5,0) rectangle (8.5,1);\r\n\\draw (8.75,0) rectangle (9.75,1);\r\n\r\n\\filldraw[red] (0.5,0.5) circle (0.35);\r\n\\filldraw[white] (0.5,0.5) circle (0.15);\r\n\r\n\\filldraw[red] (1.75,0.5) circle (0.35);\r\n\\filldraw[white] (1.75,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (5.5,0.5) circle (0.35);\r\n\\filldraw[white] (5.5,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (6.75,0.5) circle (0.35);\r\n\\filldraw[white] (6.75,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (8,0.5) circle (0.35);\r\n\\filldraw[white] (8,0.5) circle (0.15);\r\n\r\n\\filldraw[green] (9.25,0.5) circle (0.35);\r\n\\filldraw[white] (9.25,0.5) circle (0.15);\r\n\r\n\\draw (2.5,0) -- (3.5,1);\r\n\\draw (3.75,0) -- (4.75,1);\r\n\\end{tikzpicture}\r\n\\end{center}\r\n\\textsc{The question} then becomes: in how many ways can we choose our 2 empty pigeonholes, or our 6 filled pigeonholes?\\\\[1ex]\r\nSince these pigeonholes are unordered, the answer is simply $\\dbinom{8}{6}=28$.\\\\[1ex]\r\n\\textsc{In general,} there are\r\n\\begin{equation*}\r\n\\dbinom{\\text{total \\# of pigeonholes}}{\\text{\\# of objects being selected}}=\\dbinom{r+(n-1)}{r}\r\n\\end{equation*}\r\ndistinct combinations of $r$ objects from a group of $n$ types of objects.\r\n\r\n\\section{\\sc Counting problems: Permutations and combinations}\r\n\r\n\\subsection*{Q: {\\em How many ways can the letters A, B, and C be arranged?}}\r\nWe are being asked how many different ways 3 distinct objects, the letters A, B, and C, can be permuted.\\\\[1ex]\r\nThere are $n!\\Rightarrow 3!=6$ permutations of 3 objects.\r\n\r\n\\subsection*{Q: {\\em How many ways can 4 different resistors be arranged in series?}}\r\nAgain, we are being asked how many different ways 4 distinct objects - 4 resistors - can be permuted.\\\\[1ex]\r\nThere are $n!\\Rightarrow 4!=24$ permutations of 4 objects.\r\n\r\n\\subsection*{Q: {\\em How many ways can a supermarket manager display 5 brands of cereal in 3 spaces on a shelf?}}\r\nWe are again being asked about an arrangement, or permutation, of multiple objects. However, here we must determine the number of $r$-permutations: permutations of 3 brands out of the 5 possible brands.\\\\[1ex]\r\nThere are $\\dfrac{n!}{(n-r)!}\\Rightarrow\\dfrac{5!}{(5-3)!}=60$ permutations of 3 objects from 5.\r\n\r\n\\subsection*{Q: {\\em How many different license plates for cars can be made if each contains 4 of the digits 0-9, followed by a letter A-Z, assuming}}\r\n\\subsubsection*{a) {\\em no repetition of digits?}}\r\n\\begin{tikzpicture}\r\n\\draw[thick,rounded corners](0,0)rectangle(5.25,1.45);\r\n\\draw[thick,rounded corners](-.1,-.1)rectangle(5.35,1.55);\r\n\\node[color=blue] at (2.62,1.15) {\\sc Ontario};\r\n\\draw(0.25,0.2) -- (0.625,0.2) node [align=center,above,font={\\Large\\bf},color=blue] {D$_1$} -- (1,0.2);\r\n\\draw(1.25,0.2) -- (1.625,0.2) node [align=center,above,font={\\Large\\bf},color=blue] {D$_2$} --(2,0.2);\r\n\\draw(2.25,0.2) -- (2.625,0.2) node [align=center,above,font={\\Large\\bf},color=blue] {D$_3$} --(3,0.2);\r\n\\draw(3.25,0.2) -- (3.625,0.2) node [align=center,above,font={\\Large\\bf},color=blue] {D$_4$} --(4,0.2);\r\n\\draw(4.25,0.2) -- (4.625,0.2) node [align=center,above,font={\\Large\\bf},color=blue] {L} --(5,0.2);\r\n\\end{tikzpicture}\\\\[1ex]\r\nLet us consider all 4 digits as a single entity \\textbf{D}. Then, using the multiplication principle,\r\n\\begin{align*}\r\n\\text{\\# of combinations of \\textbf{D} and \\textbf{L}}& =\\text{\\# of ways of choosing \\textbf{D}}\\times\\text{\\# of ways of choosing \\textbf{L}}\\\\\r\n& =\\text{\\# of perms. of 4 digits}\\times\\text{\\# of letters}\r\n\\end{align*}\r\nThe number of permutations of 4 digits, with no repetition of digits, is the number of 4-permutations of 10 objects, since there are 10 digits from which we select. So\r\n\\begin{align*}\r\n\\text{\\# of combinations of \\textbf{D} and \\textbf{L}}& =\\left(\\dfrac{10!}{(10-4)!}\\right)\\times 26\\\\\r\n& =5040\\times 26\\\\\r\n& =131\\,040\r\n\\end{align*}\r\n\r\n\\subsubsection*{b) {\\em possible repetition of digits?}}\r\nIf repetition of digits (using the same digit more than once) is possible, then we are no longer dealing with permutations. Instead, using the product rule, we determine that the number of ways of choosing \\textbf{D} is the product of the number of ways of choosing the first digit D$_1$, and then the second digit D$_2$, and so on.\\\\[1ex]\r\nSince repetition is possible, at each step, we are choosing from the same set of 10 digits, meaning that there are 10 ways to choose each digit.\r\n\\begin{align*}\r\n\\text{\\# of combinations of \\textbf{D} and \\textbf{L}}& =\\text{\\# of ways of choosing \\textbf{D}}\\times\\text{\\# of ways of choosing \\textbf{L}}\\\\\r\n& =\\left(\\text{\\# of ways of choosing D}_1\\times\\ldots\\times\\text{\\# of ways of choosing D}_4\\right)\\times\\text{\\# of letters}\\\\\r\n& =\\left(10\\times 10\\times 10\\times 10\\right)\\times 26\\\\\r\n& =260\\,000\r\n\\end{align*}\r\n\r\n%\\subsection*{Q: {\\em How many different sets of 4 letters can be selected from the alphabet?}\\\\\r\n%{\\normalsize Eg., \\{A, E, R, T\\} and \\{E, A, T, R\\} are the same set, but are different from \\{Q, D, P, T\\}.}}\r\n%We are being asked how many different ways 4 letters from the alphabet can be combined. We know that these are combinations rather than permutations because sets are, by definition, unordered.\\\\[1ex]\r\n%There are $\\dfrac{n!}{(n-r)!\\,r!}\\Rightarrow \\dfrac{26!}{(26-4)!\\,4!}=14\\,950$ combinations of 4 objects from 26.\r\n%\r\n%\\subsection*{Q: {\\em In how many ways can 3 components be selected from a batch of 20 different components?}}\r\n%Again, we are being asked how many different ways 3 objects from a group of 20 objects can be combined.\\\\[1ex]\r\n%There are $\\dfrac{n!}{(n-r)!\\,r!}\\Rightarrow \\dfrac{20!}{(20-3)!\\,3!}=1140$ combinations of 3 objects from 20.\r\n\r\n\\subsection*{Q: {\\em In how many ways can a group of 4 boys be selected from 10 if}}\r\n\\subsubsection*{a) {\\em the eldest boy is included in each group?}}\r\nIf the eldest boy is included in each group, we select only the remaining 3 boys in the group; and we select these other 3 group members from 9 rather than from 10, since we have already selected 1 boy.\\\\[1ex]\r\nSo we are asked how many different ways 3 objects can be combined from a group of 9 objects.\\\\[1ex]\r\nThere are $\\dfrac{n!}{(n-r)!\\,r!}\\Rightarrow \\dfrac{9!}{(9-3)!\\,3!}=84$ possible groups that include the eldest boy.\r\n\r\n\\subsubsection*{b) {\\em the eldest boy is excluded from all groups?}}\r\nIf the eldest boy is excluded from all groups, we select 4 boys to form a group, but we select from 9 rather than from 10, since we have eliminated 1 possible boy.\\\\[1ex]\r\nThere are $\\dfrac{n!}{(n-r)!\\,r!}\\Rightarrow \\dfrac{9!}{(9-4)!\\,4!}=126$ possible groups that exclude the eldest boy.\r\n\r\n\\subsubsection*{c) {\\em What proportion of all possible groups contain the eldest boy?}}\r\nSince there are only two possibilities - either a group includes the eldest boy or it does not - and both possibilities cannot be true simultaneously - a group cannot simultaneously include \\textit{and} exclude the eldest boy - the total number of possible groups must be the sum of the number of groups that include the eldest boy and the number of groups that do not.\r\n\\begin{align*}\r\n\\text{total \\# of possible groups}& =\\text{\\# of groups incl. the eldest boy}+\\text{\\# of groups excl. the eldest boy}\\\\\r\n& =84+126\\\\\r\n& =210\r\n\\end{align*}\r\nAlternatively, we can calculate the total number of possible groups as the total number of combinations of 4 boys from 10, with no restrictions:\r\n\\begin{equation*}\r\n\\text{total \\# of possible groups}=\\dfrac{10!}{(10-4)!\\,4!}=210\r\n\\end{equation*}\r\nThe proportion of groups containing the eldest boy is then\r\n\\begin{equation*}\r\n\\dfrac{\\text{\\# of groups incl. the eldest boy}}{\\text{total \\# of possible groups}}=\\dfrac{84}{210}=40\\%\r\n\\end{equation*}\r\n\r\n\\section{\\sc Counting problems with repetition}\r\n\r\n\\subsection*{Q: {\\em How many different ways can the letters of the word ``mammal\" be arranged?}}\r\nThis question is directly analogous to the ``banana\" example above: we want to determine the number of arrangements of a group of objects, where some objects are of the same type.\\\\[1ex]\r\nSpecifically, we have $n=6$ letters, $r_1=3$ of which are `m's, $r_2=2$ of which are `a's, and $r_3=1$ of which are `l's.\r\n\\begin{equation*}\r\n\\dfrac{n!}{r_1!\\,r_2!\\,r_3!}\\Rightarrow\\dfrac{6!}{3!\\,2!\\,1!}=60\\text{ ways to arrange ``mammal\"}\r\n\\end{equation*}\r\n\r\n\\subsection*{Q: {\\em How many different ways can 3 red, 4 yellow, and 2 blue bulbs be arranged in a string of Christmas lights with 9 sockets?}}\r\nAgain, we are asked to determine the number of arrangements of a group of objects with repetition.\\\\[1ex]\r\nWe have $n=9$ bulbs, $r_1=3$ of which are red, $r_2=4$ of which are yellow, and $r_3=2$ of which are blue.\r\n\\begin{equation*}\r\n\\dfrac{n!}{r_1!\\,r_2!\\,r_3!}\\Rightarrow\\dfrac{9!}{3!\\,4!\\,2!}=1260\\text{ ways to arrange bulbs in 9 sockets}\r\n\\end{equation*}\r\n\\textsc{Note} that we are able to use the formula for calculating the number of arrangements with repetition, derived above, because we are asked to arrange 9 objects (in 9 sockets) and have $3+4+2=9$ objects in total.\\\\\r\nThat is,\r\n\\begin{equation*}\r\nr_1+r_2+\\ldots+r_m=3+4+2=9=n\r\n\\end{equation*}\r\n\r\n%\\subsection*{{\\normalsize You want to send postcards to 12 friends. In the shop, there are only 3 kinds of postcards.}\\\\\r\n%Q: {\\em How many ways can you send the postcards if}}\r\n%\\subsubsection*{a) {\\em there is a large number of each kind, and you want to send 1 card to each friend?}}\r\n%If we are sending 1 postcard to 12 friends, we must select 12 postcards in total. However, because there are only $n=3$ kinds of postcards, some friends will receive the same kind of card.\\\\\r\n%So we are being asked how many ways we can select $r=12$ postcards, with repetition. We can determine this using the formula for selection with repetition, derived above:\r\n%\\begin{equation*}\r\n%\\binom{r+(n-1)}{r}\\Rightarrow\\binom{12+(3-1)}{12}=\\dfrac{14!}{12!\\,(14-12)!}=91\\text{ ways to select 12 postcards}\r\n%\\end{equation*}\r\n%\r\n%\\subsubsection*{b) {\\em there is a large number of each kind, and you are willing to send 1 or more cards to each friend, but no one should get more than 1 of the same kind of card?}}\r\n%We are again being asked how many ways we can select \\textit{at least} 12 postcards, with repetition. We cannot send more than 3 to any friend because there are only 3 types, and so, we would be sending at least more than 1 of the same type.\\\\[1ex]\r\n%The number of cards we want to select can be as few as 12 (if we only send 1 to each friend) or as many as 36 (if we send 3 to each friend). This makes it difficult to use the same method as in \\textbf{(a)}. Instead, we can use the product rule:\r\n%\\begin{equation*}\r\n%\\text{\\# of ways to send 1-3 cards 12 times}=\\underbrace{\\text{\\# of ways to send 1-3 cards}}_\\text{friend1}\\times\\ldots\\times\\underbrace{\\text{\\# of ways to send 1-3 cards}}_\\text{friend12}\r\n%\\end{equation*}\r\n%Then, using the sum rule, we determine that, for each friend,\r\n%\\begin{multline*}\r\n%\\text{\\# of ways to send 1-3 cards}=\\\\\r\n%\\text{\\# of ways to send 1 card }+\\text{ \\# of ways to send 2 cards }+\\text{ \\# of ways to send 3 cards}\r\n%\\end{multline*}\r\n%Since we cannot have repetition when selecting 2 or 3 postcards, and there are only 3 unique postcards from which to choose, we find the number of ways to choose $r=1,2,3$ postcards from $n=3$:\r\n%\\begin{align*}\r\n%\\text{\\# of ways to send 1-3 postcards}& =\\binom{3}{1}+\\binom{3}{2}+\\binom{3}{3}\\\\\r\n%& =3+3+1\\\\\r\n%& =7\r\n%\\end{align*}\r\n%And finally, we determine that\r\n%\\begin{equation*}\r\n%\\text{\\bf\\# of ways to send 1-3 postcards 12 times}=7^{12}=13\\,841\\,287\\,201\r\n%\\end{equation*}\r\n%\r\n%\\subsubsection*{c) {\\em there are only 4 of each kind, and you want to send 1 card to each friend?}}\r\n%There are 4 of 3 kinds of postcards, meaning that there are $n=12$ cards in total from which to choose.\\\\[1ex]\r\n%If we suppose the order in which we select the postcards to be meaningful - that is, we send the first card we select to friend1, the second to friend2, etc. - then we are being asked to determine the number of ways in which we can select 12 cards, where some cards are of the same type.\r\n%\\begin{equation*}\r\n%\\dfrac{n!}{r_1!\\,r_2!\\,r_3!}\\Rightarrow\\dfrac{12!}{4!\\,4!\\,4!}=34\\,650\\text{ ways to send 12 postcards}\r\n%\\end{equation*}\r\n\r\n\\subsection*{Q: {\\em How many solutions are there to the equation $x_1+x_2+x_3+x_4+x_5=13$ if $x_1,\\ldots,x_5$ must be non-negative integers?}}\r\nWe can consider this question to be asking how many ways we can distribute 13 units among the five variables $x_1,\\ldots,x_5$. (We can make the question more intuitive by imagining that, as in the example above, we have five types of bagels and want to select 13 bagels in total.)\\\\[1ex]\r\nFor example, the solution $x_1=4,\\,x_2=0,\\,x_3=5,\\,x_4=1,\\,x_5=3$ distributes 13 1's into the five groups:\r\n\\begin{equation*}\r\n\\underbrace{\\;1\\;1\\;1\\;1\\;}_{x_1}|\\underbrace{\\;}_{x_2}|\\underbrace{\\;1\\;1\\;1\\;1\\;1\\;}_{x_3}|\\underbrace{\\;1\\;}_{x_4}|\\underbrace{\\;1\\;1\\;1\\;}_{x_5}\r\n\\end{equation*}\r\nNote that a unique solution is a set of assignments to $x_1,\\ldots,x_5$: thus, $x_1=4,\\,x_2=0,\\,x_3=5,\\,x_4=1,\\,x_5=3$ is a different solution than $x_1=5,\\,x_2=1,\\,x_3=3,\\,x_4=4,\\,x_5=0$.\r\n\\begin{equation*}\r\n\\binom{r+(n-1)}{r}\\Rightarrow\\binom{13+(5-1)}{13}=\\dfrac{17!}{13!\\,(17-13)!}=2380\\text{ unique solutions}\r\n\\end{equation*}\r\n\r\n\\section{\\sc Additional practice problems}\r\n\r\nAt a competition of 100 athletes, only the order of the first 10 is recorded.\\\\\r\n{\\bf Q: How many different outcomes does the competition have?}\\\\[1ex]\r\nSuppose we record the order of all 100 athletes.\\\\\r\n{\\bf Q: How many different outcomes can we have then?}\\hfill(1)\\\\[1ex]\r\n{\\bf Q: How many of the outcomes in {\\normalfont(1)} give the same result for the first 10 places?}\\hfill(2)\\\\[1ex]\r\n{\\bf Q: Show that the number of outcomes for the first 10 places can also be obtained using {\\normalfont(1)} and {\\normalfont(2)}.}\\\\[1em]\r\nPossible grades for a class are A, B, C, D, and F. (No +/-'s).\\\\\r\n{\\bf Q: How many ways are there to assign grades to a class of seven students?}\\\\[1ex]\r\n{\\bf Q: How many ways are there to assign grades to a class of seven students, if nobody receives an F and exactly one person receives an A?}\\\\[1em]\r\n{\\bf Q: How many ways are there to arrange the letters in the word ``inaneness\"?}\\\\[1em]\r\nTwo teams, A and B, play a best-of-seven match. The match ends when one team wins four games.\\\\\r\n{\\bf Q: How many different win or loss scenarios are possible?}\r\n\r\n\\end{document}", "meta": {"hexsha": "16e98b356a0f579bcc0ef705ae8353abe178165c", "size": 32953, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "teaching/resources/Combinatorics-cont-Tut.tex", "max_stars_repo_name": "ozhanghe/ozhanghe.github.io", "max_stars_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-23T17:23:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-23T17:23:00.000Z", "max_issues_repo_path": "teaching/resources/Combinatorics-cont-Tut.tex", "max_issues_repo_name": "ozhanghe/ozhanghe.github.io", "max_issues_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2017-06-05T03:48:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-18T03:30:18.000Z", "max_forks_repo_path": "teaching/resources/Combinatorics-cont-Tut.tex", "max_forks_repo_name": "ozhanghe/ozhanghe.github.io", "max_forks_repo_head_hexsha": "7b58b8e325da2c788c4dd7cf5bec4d08d77c24fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-11T13:35:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T05:34:01.000Z", "avg_line_length": 65.906, "max_line_length": 458, "alphanum_fraction": 0.6908020514, "num_tokens": 11101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5851011397337391, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4110511409232334}}
{"text": "\\chapter{Basic Statistics in Spreadsheets}\n\nWhen you completed the problems in the last section, you probably noticed\nhow long it took to compute statistics like the mean, the median,\nand variance by hand. Luckliy, computers were designed to free us from these\nsorts of tedious tasks. The most basic tool for automating\ncalculations is the spreadsheet program.\\index{spreadsheet}\n\nThere are lots of spreadsheet programs including Microsoft's Excel and\nApple's Numbers. Any spreadsheet program will work; they are all very\nsimilar. The instructions and screenshots here will be from Google\nSheets -- a free spreadsheet program you use through your web browser.\n\n\\section{Your First Spreadsheet}\n\nIn whatever spreadsheet program you are using, create a new spreadsheet document.\n\nA spreadsheet is essentially a grid of cells. In each cell you can put data (like numbers or text) and a formulas.\n\n\\includegraphics[width=0.6\\textwidth]{BlankSheet.png}\n\nLet's put some labels in the column:\n\\begin{itemize}\n\\item Select the first cell (A1) and type ``A number''.\n\\item Select the cell below it (A2) and type ``Another number''.\n\\item Select the cell below that one (A3) and type ``Their product''.\n\\item In the next column, type the number 5 in B1 and 7 in B2.\n\\end{itemize}\n\nIt should look like this:\n\n\\includegraphics[width=0.5\\textwidth]{NoFormulas.png}\n\nNow put a formula in cell B3. Select B3, and type ``= B1 + B2''. The spreadsheet knows this is a formula because it starts with `=`. It will look like this as you type:\\index{Spreadsheet!Entering formula}\n\n\\includegraphics[width=0.5\\textwidth]{TypingFirstFormula.png}\n\nWhen you press Return or Tab, the spreadsheet will remember the formula, but display its value:\n\n\\includegraphics[width=0.5\\textwidth]{FirstCalc.png}\n\nIf you change the values of cell B1 or B2, the cell B3 will automatically be recalculated. Try it.\n\n\\section{Formatting}\n\nEvery spreadsheet lets you change the formatting of your columns and cells. They are all a little different, so play with your spreadsheet a little now. Try to do the following:\n\\begin{itemize}\n\\item Set the background of the first column to light gray.\n\\item Right-justify the text in the first column.\n\\item Make the text in the first column bold.\n\\item Make the numbers in the second column have one digit after the decimal point.\n\\end{itemize}\n\nIt should look something like this:\n\n\\includegraphics[width=0.6\\textwidth]{FirstFormatting.png}\n\nThat's a spreadsheet. You have grid of cells. Each cell can hold a\nvalue or a formula that uses values from other cells. The cells with\nformulas automatically update as you edit the values in the other\ncells.\n\n\\section{Comma-Separated Values}\n\nA lot of data is exchanged in a file format called\n\\textit{Comma-Separated Values} or just CSV. Each CSV file holds one\ntable of data. It is a text file, and each line of text corresponds to\none row of data in the table. The data in each column is separated by\na comma. The first line of a CSV is usually the names of the\ncolumns. A CSV might look like this:\n\n\\begin{Verbatim}\nstudentID,firstName,lastName,height,weight\n1,Marvin,Sumner,260,45.3\n2,Lucy,Harris,242,42.2\n3,James,Boyd,261,44.2\n\\end{Verbatim}\n\nIn your digital resources for this module, you should have a file\ncalled \\path{1000cars.csv}. It is a CSV with only one column called\n``speed''. The first few lines look like this:\n\n\\begin{Verbatim}\nspeed\n33.8000\n29.9920\n34.8699\n27.9936\n\\end{Verbatim}\n\nThere is a title line and 1000 data lines.\n\nImport this CSV into your spreadsheet program. In Google Sheets, it looks like this:\n\n\\includegraphics[width=0.5\\textwidth]{ImportingCSV.png}\n\nYou should see a long, long column of data appear. (Mine goes from cell A2 through A1001.)\n\n\\includegraphics[width=0.5\\textwidth]{ImportedCSV.png}\n\n\\section{Statistics in Spreadsheets}\n\nLet's take the mean all 1000 numbers.  In cell B2, type in a label:\n``Mean''. (Feel free to format your labels as you wish. Bolding is recommended.)\n\nIn cell C2, enter the formula ``=AVERAGE(A2:A1001)''. When\nyou press return, the cell will show the mean: 31.70441, if done correctly .\n\n\\includegraphics[width=0.4\\textwidth]{Spread_mean.png}\n\nNotice that by specifing that the function \\pyfunction{AVERAGE} was to\nbe performed on a range of cells: cells A2 through A1001.\n\nDo the calculations for variance, standard deviation, and median.\n\n\\begin{itemize}\n\\item The function for variance is \\pyfunction{VAR}.\n\\item The function for standard deviation is \\pyfunction{STDEV}.\n\\item The function for median is \\pyfunction{MEDIAN}.\n\\end{itemize}\n\n\\includegraphics[width=0.4\\textwidth]{var_stdev_median.png}\n\n\\section{Histogram}\n\nMost spreadsheets have the ability to create a histogram. In Google\nSheets, you select the entire range A2:A1001 by selecting the first\ncell and then shift-clicking the last. Then you choose\nInsert$\\rightarrow$Chart. In the inspector, change the type of the\nchart to histogram. This will get you a basic histogram.\n% Add: Define histogram or give example, defined in basic statistics, must come previous\n\n\\includegraphics[width=0.7\\textwidth]{default_histogram.png}\n\nPlay with the formatting to see how unquie you can make data. Here is an example:\n\n\\includegraphics[width=0.8\\textwidth]{final_histogram.png}\n\n\\begin{Exercise}[title={RMS}, label=rms_spreadsheet]\n\n  In your spreadsheet, calculate the quadratic mean (the root-mean-squared) of the speeds.\n\n  You will need the following three functions:\n  \\begin{itemize}\n  \\item \\pyfunction{SUMSQ} returns the sum of the squares of a range of cells.\n  \\item \\pyfunction{COUNT} returns the number of cells in a range that contain numbers.\n  \\item \\pyfunction{SQRT} returns the square root of a number.\n  \\end{itemize}\n\n\n\\end{Exercise}\n\\begin{Answer}[ref=rms_spreadsheet]\n\nThe formula for the RMS is ``=SQRT(SUMSQ(A2:A1001)/COUNT(A2:A1001))''.\n% KA: https://www.khanacademy.org/computing/ap-computer-science-principles/data-analysis-101/data-tools/a/learning-from-data-sets\n\n\\end{Answer}\n\n", "meta": {"hexsha": "55dc59eb39bc4dad8bb8298efa4478210a362b1a", "size": 5979, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Modules/MatterEnergy/stat_spreadsheets-en_US.tex", "max_stars_repo_name": "hillegass/sequence", "max_stars_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-06-13T17:19:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-05T00:43:44.000Z", "max_issues_repo_path": "Modules/MatterEnergy/stat_spreadsheets-en_US.tex", "max_issues_repo_name": "hillegass/sequence", "max_issues_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Modules/MatterEnergy/stat_spreadsheets-en_US.tex", "max_forks_repo_name": "hillegass/sequence", "max_forks_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-05T00:43:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-05T00:43:58.000Z", "avg_line_length": 37.6037735849, "max_line_length": 204, "alphanum_fraction": 0.7762167587, "num_tokens": 1549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7853085733507947, "lm_q1q2_score": 0.4110464874859598}}
{"text": "\\section{Proof of Theorem~\\ref{th:main}}\\label{se:proof}\n\\begin{proof}\nTo simplify our proof we introduce the notion of \\emph{canonical scenario} for the the ledger $\\ledger_2$. In a canonical scenario the ledger\n$\\ledger_2$ is executed in the standard way. More precisely, \nwe assume the existence of a genesis block and that $\\asmp_2[\\tau]$=1 for all $\\tau \\geq 0$. Let $\\parties$ be the set of parties that is running $\\ledger_2$. Also, \nlet $t_j$ be the smallest time slot in which $B_j$ appears in  $\\state_2^{P_i}[t_j]$ for each $P_i\\in\\parties$ and let $t_{j+k}$ be smallest time slot in which $B_{j+k}$ appears in %\\nnote{$\\state_2^{P_i}[t_{j+k}]$}\n$\\state_2^{P_i}[t_{j+k}]$ for each $P_i\\in\\parties$.\nWe are now ready to prove the security of $\\Pi$.\n\nIn the protocol $\\Pi$, by assumption, we have that $\\asmp_2[\\tau]=1$ for all $\\tau \\geq t$. \n%From the description of $\\Pi$ we can claim that $t \\leq t_{P_1}+k\\cg^{-1}=t_{P_1}+\\Delta_1$.\n%That is, when an honest party is activated she waits to be sure that also the other honest parties are activated. %Hence, from the chain-growth and the common-prefix parameters\n%each party needs to wait at most $\\Delta_1=k\\cg^{-1}$ time slots.\nFrom the moment when $\\asmp_2$ becomes true the activation process takes $\\Delta\\leq k \\cg^{-1} + k \\cg^{-1}$  time slots to be completed.\nThis is because the parties need to wait that the $(j+k)$-th block of $\\state_1$ is part of $\\check \\state_1^{P_i}[t]$  for all $P_i$ and that $k$ blocks are generated in $\\state_2$. Note that when $k$ blocks are generated in $\\state_2$ at least \n$k$ blocks are generated in $\\state_1$ since $\\ledger_2$ and $\\ledger_1$ have the same parameters and that the honest parties that maintain $\\ledger_1$ are greater or equal than the parties that maintain $\\ledger_2$. Therefore, the parties need to wait the \\emph{special genesis block} of $\\ledger_2$ to appear \nin $\\state_2^P$ for each honest $P\\in\\activep$. Given that a block in $\\ledger_1$ ($\\ledger_2$) takes at most $\\cg^{-1}$ time slots then we have that $\\Delta \\leq k \\cg^{-1} + k \\cg^{-1}$.\nIn the moment that a \\emph{candidate} block $B^i_{j+k}$ becomes available to an honest party $P_i\\in\\activep$ (i.e., $B^i_{j+k}$ is part of $\\check \\state_1^{P_i}$) then she starts running $\\ledger_2$\nusing ${B^i}'$ which is computed from $B^i_{j+k}$ as described earlier (we recall that at this time slot the assumption $\\asmp_2$ holds).\nLet $t'$ be the smallest time slot in which $B_{j+k}$ appears in $ \\state_2^{P_i}[t']$\n%\\nnote{$\\state_2^{P_i}[t']$}\n for each $P_i\\in\\parties$.\nIf we take the execution of the protocol from time $t$ and $t'$ this can be seen as a canonical execution of $\\ledger_2$ given\nthat the parameters of $\\ledger_1$ and $\\ledger_2$ are the same. The only difference between this and the canonical scenario is\nthat the blocks $B_{j}, B_{j+1},\\dots, B_{j+k}$  are generated using $\\ledger_1$, but this does not represent an issue since we are assuming that\nany block of $\\state_1$ can be turned into a block of $\\state_2$. \\end{proof}\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "15ff1894e472ae878e67b3f555620ccfc76c093b", "size": 3051, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/FC20/paper/sections/proof.tex", "max_stars_repo_name": "MitchellTesla/decentralized-software-updates", "max_stars_repo_head_hexsha": "89f5873f82c0ff438e2cd3fff83cc030a46e29da", "max_stars_repo_licenses": ["ECL-2.0", "Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2019-01-25T19:38:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-06T02:08:38.000Z", "max_issues_repo_path": "papers/FC20/paper/sections/proof.tex", "max_issues_repo_name": "MitchellTesla/decentralized-software-updates", "max_issues_repo_head_hexsha": "89f5873f82c0ff438e2cd3fff83cc030a46e29da", "max_issues_repo_licenses": ["ECL-2.0", "Apache-2.0"], "max_issues_count": 120, "max_issues_repo_issues_event_min_datetime": "2019-03-06T18:29:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-24T10:20:09.000Z", "max_forks_repo_path": "papers/FC20/paper/sections/proof.tex", "max_forks_repo_name": "MitchellTesla/decentralized-software-updates", "max_forks_repo_head_hexsha": "89f5873f82c0ff438e2cd3fff83cc030a46e29da", "max_forks_repo_licenses": ["ECL-2.0", "Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-07-18T13:38:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-16T10:39:00.000Z", "avg_line_length": 84.75, "max_line_length": 311, "alphanum_fraction": 0.7099311701, "num_tokens": 949, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4109839536767612}}
{"text": "\\section{genetic Personalized Community Detection}\n\n%\nMy proposed gPCD model contains an offline and an online step. Figure \\ref{fig:pipeline} shows the pipeline of the whole framework. The offline step first encodes the user-independent binary community tree (\\textit{Section \\ref{sc:c3_offline}}), and subsequently learns embedding representations for both user need and nodes on the binary community tree (\\textit{Section \\ref{sc:c3_representation}}). The online step introduces the genetic personalized community detection approach (\\textit{Section \\ref{sc:c3_online}}). To accelerate the running speed, a distributed version of gPCD model is also deployed on HDFS (\\textit{Section \\ref{sc:c3_distributed}}).  To disambiguate the notations mentioned in this section to better explain the gPCD model, some commonly used notations can be found in Table \\ref{tab:notation}. \n\n\\subsection{Offline Community Tree Index} \\label{sc:c3_offline}\n\nOne challenge of solving personalized community detection problem is the computational cost due to the complexity of personalization and graph structure. In order to reduce the online workload, most of computation cost is put into the one-time offline step whose time cost can be excluded from the online personalized community detection step. Thus, I first convert the graph into a binary community tree offline to retain user-independent community information. \n\nInfomap algorithm \\cite{rosvall2011multilevel} is employed to generate the user-independent communities solely based on the graph \\textit{G(V, E)}. Infomap algorithm simulates a random walker wandering on the graph and indexes the  description length of his / her random walk path via multilevel codebooks. By minimizing the description length based on the map equation below, community structures are formed for the graph.\n%\\begin{equation} \\small\n%\\textit{$L(\\mathcal{M})$} = q_{\\curvearrowright}H(\\mathcal{Q})+\\sum_{i=1}^{m} \\textit{$p_{\\circlearrowright}^{i}$}H(\\textit{$\\mathcal{P}^{i}$}) \n%\\end{equation}\n%where $L(\\mathcal{M})$ is the description length for a random walker in the current community $\\mathcal{M}$. $q_{\\curvearrowright}$ and $p_{\\circlearrowright}^{i}$ are the jumping rates between communities and within the $i_{th}$ community. $H(\\mathcal{Q})$ is the frequency-weighted average length of codewords in the global index codebook and $H(\\mathcal{P}^{i})$ is frequency-weighted average length of codewords in the $i_{th}$ community codebook.\n\n\\begin{equation} \n\\textit{$L(\\pi)$} = \\sum_{i}^{m}q_{\\curvearrowright}^{i}H(\\mathcal{Q})+\\sum_{i=1}^{m} \\textit{$p_{\\circlearrowright}^{i}$}H(\\textit{$\\mathcal{P}^{i}$}) \n\\end{equation}\nwhere \\textit{$L(\\pi)$} is the description length for a random walker under current community partition $\\pi$. $q_{\\curvearrowright}^{i}$ and $p_{\\circlearrowright}^{i}$ are the jumping rates between communities and within the $i_{th}$ community in each step. $H(\\mathcal{Q})$ is the frequency-weighted average length of codewords in the global index codebook and $H(\\mathcal{P}^{i})$ is frequency-weighted average length of codewords in the $i_{th}$ community codebook. Followed by this equation to partition communities into sub-communities , a hierarchical community tree \\textit{$T_{c}(N^{c},L^{c})$} is constructed from the original graph $G(V,E)$. \n\\begin{figure}  \n\t% \\advance\\leftskip-1cm  \n\t\\center\n\t\\includegraphics[width=1.0\\columnwidth]{img/chapter3/4.pdf}\n\t%  \\vspace{-3em}\n\t\\caption{The framework of gPCD model. (a) refers to the offline construction step on the original graph and (b) refers to the online genetic pruning step to generate personalized communities.} \n\t\\label{fig:pipeline}\n\t%  \\vspace{-1em} \n\\end{figure}\nIn \\textit{$T_{c}(N^{c},L^{c})$}, each parent node can have multiple child nodes which can be regarded as a community partition on the parent node. For instance, a node $N_{k}^{c} \\in N^{c}$ from $T_{c}(N^{c},L^{c})$ represents a community of vertices.  Its $m$ child nodes $\\{N_{k_{1}}^{c},N_{k_{2}}^{c},...,N_{k_{m}}^{c}\\}$ represent $m$ sub-communities of vertices from $G(V,E)$ where we have $\t\\bigcap_{i=1}^{m} N_{k_{i}}^{c} = \\varnothing$ and  $\t\\bigcup_{i=1}^{m} N_{k_{i}}^{c} =  N_{k}^{c}$.  \n\n\n\nIn order to achieve an efficient personalized community detection in the following online step, I convert the hierarchical community tree \\textit{$T_{c}(N^{c},L^{c})$} to a binary community tree \\textit{$T_{b}(N^{b},L^{b})$} for index. Specifically, for $m$ child nodes of a parent node $N_{k}^{c}$, a bottom-up approach is proposed to merge a selected pair of sibling nodes as a new node in an iterative manner. The approach runs until all $m$ child nodes merged together to form the parent node $N_{k}^{c}$. To avoid an unbalanced tree where small communities are always left to merge with huge communities in the end, I first select the node with the smallest community size among all sibling nodes in each merging step. It is merged with its sibling node with the largest normalized linked weight (Please refer to Figure \\ref{fig:pipeline}(a)). The normalized linked weight function $w(\\cdot)$ between  two nodes $N_{i}^{c}$ and $N_{j}^{c}$ is defined as:\n\\begin{equation} \n\\textit{$w(N_{i}^{c},N_{j}^{c})$} =\\frac{\\textit{$N_{i}^{c}\\odot N_{j}^{c}$}-\\frac{\\mathcal{D}(N_{i}^{c})\\cdot \\mathcal{D}(N_{j}^{c})}{2|E|} }{\\textit{$| N_{i}^{c}||N_{j}^{c}|$}} \n\\end{equation} \nwhere \\textit{$N_{i}^{c}\\odot N_{j}^{c}$} denotes the number of edges linked between vertices in node \\textit{$N_{i}^{c}$} and \\textit{$N_{j}^{c}$}, which can be interpreted as the linkage strength between them; \\textit{$|N_{i}^{c}|$} is the number of vertices inside node \\textit{$N_{i}^{c}$}; \\textit{$\\mathcal{D}(N_{i}^{c})$} is the out-degree of node \\textit{$N_{i}^{c}$} (the total number of edges linked to other nodes) and \\textit{$|E|$} is the total number of edges in the original graph $G(V,E)$ . $\\frac{\\mathcal{D}(N_{i}^{c})\\cdot \\mathcal{D}(N_{j}^{c})}{2|E|} $ denotes the random linkage strength between node \\textit{$N_{i}^{c}$} and \\textit{$N_{j}^{c}$}. The \\textit{$w(\\cdot)$} function calculates how much that two nodes are better connected beyond random connection and is normalized by node size. Given the node $N_{i}^{c}$ with the smallest community size and all its sibling node set $S$, The merging step can be formulated as:\n\\begin{equation}  \n\\begin{aligned} \n& N_{j}^{c} \\Leftarrow \\argmax_{N_{j}^{c} \\in S}w(N_{i}^{c},N_{j}^{c})\\\\\n& N_{*}^{c} = N_{i}^{c}\\bigcup N_{j}^{c}\n\\end{aligned}\n\\end{equation}\nThe bottom-up process will stop until all child nodes are merged together to form the parent node. In the end, the hierarchical community tree \\textit{$T_{c}(N^{c},L^{c})$} is fully converted to a binary community tree \\textit{$T_{b}(N^{b},L^{b})$} with user-independent community information.  The node size $|N^{b}|$ as well as the link size $|L^{b}|$  in \\textit{$T_{b}(N^{b},L^{b})$} is at most $2|V|$ which is smaller than the size of original graph $G(V,E)$. If I consider to form the binary community tree with only $k$ levels, the size of \\textit{$T_{b}(N^{b},L^{b})$} can be even smaller. \n\n\\begin{table}[h]\n\t%\\scriptsize\n\t%\t\\small\n\t\\centering\n\t\n\t\\begin{tabular}{|p{3cm}|p{11cm}|} \n\t\t\\hline\n\t\t\\textbf{Notations} & \\textbf{Descriptions} \\\\ \\hline\n\t\t$G(V,E)$ & Original graph $G$ with vertex set $V$ and edge set $E$ \\\\ \\hline\n\t\t\\textit{$T_{c}(N^{c},L^{c})$} & The hierarchical community tree generated from graph $G(V,E)$ with node set $N^{c}$ and link set $L^{c}$. Each node  $N^{c}_{k} \\in N^{c}$ denotes a group of vertices belonging to $V$. \\\\\\hline\n\t\t\\textit{$T_{b}(N^{b},L^{b})$} & The binary community tree reconstructed from \\textit{$T_{c}(N^{c},L^{c})$}. Each node $N^{b}_{k} \\in N^{b}$ denotes a group of vertices belonging to $V$. \\\\ \\hline\n\t\t$B$ & The binary codebook for \\textit{$T_{b}(N^{b},L^{b})$}. Particularly, $B_{k} \\in B$ denotes the binary code of both $N_{k}^{b} \\in N^{b}$ and $L_{k}^{b}\\in L^{b}$ where $L_{k}^{b}$ is the link points to node $N_{k}^{b}$.\n\t\t\\\\ \\hline\n\t\\end{tabular}\n\t\\caption{Commonly used notations in gPCD model}\n\t\\label{tab:notation}\n\t\\vspace{-1em}\n\\end{table} \n\n\nFor running time analysis, calculating normalized linked weight takes constant time. In each merging step, node pair selection takes linear time. Therefore, in the worst case, the time complexity of binary community tree construction is $O(|V|^2)$ where the depth of the hierarchical community tree $T_{c}(N^{c},L^{c})$ is 1 and each vertex in $G(V,E)$ forms a single-vertex community.\n\nTo encode the nodes and links on $T_{b}(N^{b},L^{b})$ as binary code, the root node is encoded as `null' first. For a parent node \\textit{$N_{k}^{b}$} with its left child node \\textit{$N^{b}_{k_{l}}$} and right child node \\textit{$N^{b}_{k_{r}}$}, the binary code of a child node and the related link defined in the Notation Table \\ref{tab:notation} is calculated as: \n\n\\begin{eqnarray}\\text{$B_{k_{i}}$}=\n\\begin{cases}\n\\text{$B_{k}$}+``0\", & i = ``l\"\\cr \n\\text{$B_{k}$}+``1\", & i = ``r\"\n\\end{cases}\n\\end{eqnarray} \n\nFor instance, if the node \\textit{$N_{k}^{b}$} is with binary code ``$00$,\" its left child node's binary code is ``$000$\" while the right child node's binary code is ``$001$.\" The link \\textit{$L_{k}^{b}$} that points to \\textit{$N_{k}^{b}$} also has the binary code ``$00$\". \n\n\\subsection{Community and User Need Representation} \\label{sc:c3_representation}\n\nNode2vec \\cite{grover2016node2vec} helps to learn fixed-length embeddings for both user need and communities. It simulates random walks on the graph $G(V,E)$ and learns the vertex embedding by optimizing the sequential relationships from random walk paths. In the end, each vertex $V_{k}$ in graph $G(V,E)$ has a vector representation as $\\vec{V_k}$. Each node $N_{k}^{b}$ on the binary community tree \\textit{$T_{b}(N^{b},L^{b})$} refers to a vertex community $C_{k}$ in the graph $G(V,E)$. Its representation $\\vec{C_{k}}$ is calculated as the averaged embedding of all vertices inside the community. In the end, the binary community tree \\textit{$T_{b}(N^{b},L^{b})$} represents the hierarchical community partition of Graph $G(V,E)$. Each node \\textit{$N_{k}^{b}$} on the tree is indexed with three attributes: a group of vertices from graph $G(V,E)$, a binary code \\textit{$B_{k}$}, and an embedding representation \\textit{$\\vec{C}_{k}$}.\n\nOn the other hand, User need (query) $I$ can also be represented by a combination of $t$ different vertices $\\{V_1, V_2... V_t\\}$ in the graph $G(V,E)$. In this study, two different scenarios for user need representation are offered:\n\n\\textbf{Vertex-based Query}. User need can be directly represented by the vertices based on the generation probability $P(V_k|I)$ between them. Hence the user need representation $\\vec{I}$ is calculated as:\n\n\\begin{equation}\n\\vec{I} = \\sum_{k=1}^{t} P(V_k|I) \\cdot \\vec{V_k} \n\\end{equation} \nFor instance, in a music sharing network, each vertex $V_k$ denotes a music and a user listing history can be used to reflect the user need $I$. $P(V_k|I)$ therefore can be regarded as the probability that a music being listened by the user. \n\n\\textbf{Text-based Query}. Under this scenario, user need $I$ is represented as a text query, and each vertex $V_{k}$ in the graph $G(V,E)$ also contains textual content. From language model viewpoint, each vertex importance weight is the query likelihood $P(I|V_k)$, and the user need can is the weighted average of vertex embedding: \n\n\\begin{equation}\n\\vec{I} = \\frac{\\sum_{k=1}^{t} P(I|V_k) \\cdot \\vec{V_k}}{\\sum_{k=1}^{t} P(I|V_k)}\n\\end{equation}\n\nIn either case, user need is conceptualized as an embedding with the same dimension as the node embeddings on the binary community tree. It enables very efficient online personalized community detection in later steps. And running Node2vec takes most of the time in this step.   \n\n\\subsection{Online Genetic Pruning} \\label{sc:c3_online}\n\nThe whole process, as the Figure \\ref{fig:pipeline} shows, is to generate communities by pruning the constructed binary community tree. After each cut on a link, the original tree  will be separated into two sub-trees. After a specific number of cuts to the links on the tree, a fixed number of communities with different resolutions are detected.  By applying genetic selection, crossover, and mutation steps, the model converges to the optimized solution efficiently with a clear-defined fitness function. The details are shown in the following paragraphs.\n\n\\subsubsection{Genetic Representation} \n\nA chromosome is formed by a set of genes \\{$g_{1},g_{2},...,g_{K-1}$\\}, and each gene $g_{i}$ holds a cut link $L_{i}^{b}$ in the binary community tree \\text{$T_{b}(N^{b},L^{b})$}. Since communities can be created by cutting links on the offline tree, a chromosome can be represented as a generated community partition of the original graph $G(V,E)$ in this way. \nTo constrain a chromosome so that it can be decoded to a fixed number of communities, four \\textbf{Cutting Rules} are necessarily to be applied: \n\\begin{itemize} %\\itemsep0em\n\t\\item \\textbf{ Rule 1}: If a link $L_{i}^{b}$ is picked to cut on the binary community tree \\text{$T_{b}(N^{b},L^{b})$}, its pointing node $N_{i}^{b}$ will be retrieved and all the vertices within it form a community. \n\t\\item \\textbf{ Rule 2}: If a link {$L_{i}^{b}$} and its ancestor link {$L_{j}^{b}$} are stored in the same chromosome, all vertices in {$L_{i}^{b}$}'s related node {$N_{i}^{b}$} are a subset of vertices in {$L_{j}^{b}$}'s related node {$N_{j}^{b}$}. In this case, the two cut links generate two communities where community $C_{i}$ is all vertices in $ N_{i}^{b}$ and community $C_{j}$ is the remaining vertices in $ N_{j}^{b}$ but not in $ N_{i}^{b}$. It can be formulated as   $C_{i} = \\bigcup_{k}\\{V_{k}|(V_{k}\\in N_{i}^{b})\\}$ and community $C_{j} = \\bigcup_{k}\\{V_{k}|(V_{k}\\in N_{j}^{b}) \\cap (V_{k}\\notin N_{i}^{b})\\}$.  \n\t\\item \\textbf{ Rule 3}: Sibling links can't be stored in the same chromosome, and it is not allowed to store duplicated links in a chromosome.\n\t\\item \\textbf{ Rule 4}: The depth's upper bound is set to be $d$, which means all eligible cut links should be located in the first $d$ depth on the binary community tree. It avoids to generate super tiny communities and hugely reduces the genetic searching scope on cut links.\n\\end{itemize} \n\nBy applying the cutting rules to the online pruning process, I ensure a $K$ community partition can be retrieved from a chromosome with $K-1$ cut links.  \n\n\n\\subsubsection{Initialization}\n\nInitially, the model generates a given number $P$  chromosomes as the seed ``chromosome population\". And each iteration in the genetic approach breeds a new ``generation'' of chromosome population. In order to ensure a chromosome is an encoder of a $K$ community partition, $K-1$ links will be randomly picked (on the binary community tree) following the cutting rules and stored in the related genes of a chromosome. \n\n\\subsubsection{Fitness Function} \n\nAs each chromosome can be decoded as a community partition, it is important to measure the quality of each generated chromosome (how well the generated communities can satisfy user need). The measurement is hosted in a fitness function. \n\n\nIn the proposed model, the fitness function simulates the user searching behavior on the graph given the community partition. For instance, a user can be more likely to pick the most relevant communities while avoiding the redundant information already selected. With the help of the offline step, the relevance score of node $N_{i}^{b}$ (community $C_{i}$) towards user need $I$ can be calculated with the cosine similarity $cos(\\vec{I},\\vec{C_{i}})$, and the information redundancy can be $\\sum_{C_{j} \\in S_c}cos(\\vec{C_{j}},\\vec{C_{i}})$ where $S_{c}$ is the set of communities that the user have already picked from the communities decoded from the target chromosome. Following this, I use a greedy selection approach to iteratively rank and pick communities given a chromosome (community partition) until all communities are picked: \n\n\\begin{equation}  \\argmax_{C_{i}}\\lambda \\cdot cos(\\vec{I},\\vec{C_{i}})-(1-\\lambda)\\cdot \\frac{\\sum_{C_{j} \\in S_c}^{ }cos( \\vec{C_j},\\vec{C_{i}})}{|S_c|}\n\\end{equation} \n\nwhere $C_i$ is the candidate community to be picked and $|S_c|$ is the number of communities already been picked. $\\lambda$ is a parameter controls  whether user prefers to obtain new useful information or to avoid redundant information.  \n\nFor chromosome quality evaluation, a query-generated vertex ranking list $l_{q}$ is first created by retrieving top $n$ vertices relevant to the query (user need) with the largest cosine similarities on embeddings of graph $G(V,E)$. I store the top $n$ vertex ranking label $R(l_{q})=\\{1,2,...,n\\}$ as the pseudo ground truth. On the other hand, given the $k_{th}$ chromosome $ch_k$ in the current chromosome generation, I can also retrieve the community-generated ranking of each vertex $V_{k} \\in l_{q}$ from the sequentially selected communities decoded by the chromosome. I assign the ranking label on each vertex $V_{k}$ based on the following formula:\n\\begin{equation}\n\\sum_{V_{j} \\in l_{q}}\\Phi(\\delta(V_{j}) < \\delta(V_{k})) + 1\n\\end{equation} \n\n$V_{j}$ refers to all vertices in $l_{q}$. $\\delta(V_{j})$ shows the ranking (selection sequence) of the community which $V_{j}$ belongs to. $\\Phi$ is a binary operator to determine whether $V_{j}$ satisfy the condition $\\delta(V_{j}) < \\delta(V_{q})$. This formula helps to construct the community-generated ranking label $R(l_c)$. For instance, when $n=3$, I have a query-generated ranking list $l_q = \\{V_1,V_2,V_3\\}$ and its related ranking label $R(l_q) = \\{1,2,3\\}$. Given a chromosome where the community of $V_1$ and $V_2$ is the same and selected before $V_3$, I can generate the related community ranking label $R(l_c) = \\{1,1,3\\}$ with the same vertex sequence of $l_q$.\n\nThen, I define the fitness function $f(\\cdot)$ to evaluate the chromosome $ch_{k}$. As I have the query-generated ranking label $R(l_{q})$ (ground truth) and community-generated ranking label $R(l_{c})$ from $ch_{k}$, I calculate their Kendall's $\\tau$  correlation coefficient  as the fitness score $f(ch_k)$ of chromosome $ch_k$ where higher score means the chromosome $ch_{k}$ can  generate better personalized communities to meet with user need. \n\n\\begin{equation}\n\\textit{$f(ch_{k})$} = 1-\\frac{\\sum_{i=1}^{n} R(l_{ci})\\cdot R(l_{qi})}{\\sum_{i=1}^{n} R(l_{ci})^2\\cdot \\sum_{i=1}^{n}R(l_{qi})^2}\n\\end{equation} \nwhere $R(l_{ci})$ is the $i_{th}$ vertex ranking in community-generated ranking label $R(l_{c})$ and $R(l_{qi})$ is the $i_{th}$ vertex ranking in query-generated ranking label $R(l_{q})$. Kendall's $\\tau$ is a widely used metric to evaluate the correlation between two lists where higher score means stronger correlation. Thus, higher fitness score reflects that the generated community ranking $R(l_{c})$ can better meet with user need $R(l_{q})$. \n\nMoreover, it is clear that the fitness function aims to separate all top $n$ vertices in different communities to get the optimal case. It matches the research goal to generate high resolution communities on vertices which are more relevant to user need. As the number of community is a given number $K$, it also leads to a coarser manner partition on the remaining less relevant vertices. On the other hand, the binary community tree $T_{b}(N^{b},L^{b})$ and the Cutting Rule 4 naturally preserve the community structure and unite the most relevant vertices in the same community. Hence the whole genetic approach is a gambling process. The final chromosome result is the equilibrium case to detect communities both contain graph topological structure and meet with user need.\n\n\n\\subsubsection{Selection}\n\nI select the superior chromosomes from current chromosome population based on their fitness scores. The probability that the $k_{th}$ chromosome $ch_k$ is picked can be calculated via the Softmax normalization function $p(ch_{i}) = \\frac{exp(f(ch_{k}))}{\\sum_{i=1}^{P}exp(f(ch_{i}))}$. Then, the Fitness Proportionate Selection method is applied to randomly select $P$ chromosomes into chromosome pairs based on probability distribution. In order to enhance optimization efficiency, I also use elitism selection to ensure the best chromosome in the current generation will always be selected to the next generation. \n\n\\subsubsection{Crossover} \n\nTo reach global optimum community partition efficiently, given a pair of chromosomes, the crossover operation can randomly exchange part of the genes in both chromosomes to produce a new pair of chromosomes with a certain crossover rate.\n\nIn order to make sure that the newly generated chromosomes meet the cutting rules, an \\textbf{Exchange Rule} is defined to restrict gene exchange: If gene \\textit{$g$} contains link $L^{b}_{g}$, \\textit{$g$} can't do crossover process with genes that contain either link $L^{b}_{g}$ or its sibling link $L^{b'}_{g}$. This rule can help avoid having duplicated links or sibling links stored together in the newly generated chromosome (To satisfy Cutting rule 3). \n\nAfter \\textit{$m$} random numbers are selected from \\{$1,2,...,K-1$\\} as exchanged gene position indexes, genes located in the chosen positions of two chromosomes will exchange the stored link restricted by the Exchange Rule.\n\\subsubsection{Mutation} \nMutation operation is applied to avoid local optimization. If a chromosome is chosen to mutate, a gene within the chromosome will be randomly picked, and its stored link will be changed to another link restricted by the Exchange Rules. An example is illustrated in Figure \\ref{fig:pipeline}(b) where the link stored in the second gene is changed from ``001'' to ``01''. \n\n\\subsubsection{Termination}\n\nAfter $T$ iterations, the whole process stops and the current best chromosome is retrieved as the final result. Choosing the number of $T$ is dependent on the task. In order to decode the final chromosome to the related community partition, all genes in the chromosome are sorted in an ascending order based on the binary code of their stored cut link. Vertices whose binary codes start with the same cut link's binary code will be assigned to the same community label. And its later assigned community label can overwrite the previous assigned community label. For instance, if there are a vertex with binary code ``0011'' and two cut links with binary code ``00'' and ``001'', the vertex will be assigned to a community label ``00'' first, and its community label is overwritten by ``001'' afterwards. The Termination step in Figure \\ref{fig:pipeline}(b) also illustrates a vivid example. In this way, the binary code of the binary community tree can help to decode the final chromosome into communities in an efficient way. \n \n\n\\subsection{Distributed gPCD} \\label{sc:c3_distributed}\n \nTo enhance the online step efficiency, a MapReduce framework is utilized to enable the distributed genetic evolution. Figure \\ref{fig:distributed} depicts the personalized community detection under a MapReduce framework. The chromosome collection is either originally initialized from binary community tree or obtained from the last generation. It contains the whole chromosome population in the central depository. In its first ``Splitter'' process, all chromosomes are split into $M$ groups based on their hash values and sent out to related $M$  Mappers to calculate the ``Fitness'' scores. In the same Mapper, after all chromosomes are assigned fitness scores, based on their scores, a Combiner groups all chromosomes together and random select equal number of chromosomes with duplicated as the ``Selection'' step. All the selected chromosomes are sent to $R$ reducers (I set $R = M$ arbitrarily in order to better represent time complexity) to form pairs for the ``Crossover'' and  ``Mutation'' step, calculate new chromosome offsprings for the next generation and store them back to the central repository. \n \n\\begin{figure}  \n\t% \\advance\\leftskip-4cm \n\t\\center\n\t\\includegraphics[width=1\\columnwidth]{img/chapter3/parallel.png}\n\t%  \\vspace{-3em}\n\t\\caption{Online parallel computing process on Hadoop Distributed File System (HDFS)}\n\t%  \\vspace{-1em} \n\t\\label{fig:distributed}\n\\end{figure}\n\nThe complexity of the proposed algorithm is $O(2^dKP)$ without parallel computing and $O(\\frac{2^dKP}{M})$ with  parallel computing, where $d$ denotes the upper bound where the cut links are restricted in the top $d$ depth of the binary community tree $T_{b}(N^{b},L^{b})$; $K$ denotes the community number; $P$ denotes the initialized population size of the genetic algorithm and $M$ denotes the number of Mappers/Reducers in parallel environment. As all the parameters are considerably small (compared with the node/edge size in the original graph), the whole process runs very fast to retrieve the final community partition.", "meta": {"hexsha": "6013cc820bb35c7e117257bd98312b5ac0b65cc2", "size": 24880, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter3/chapter3.2.tex", "max_stars_repo_name": "RoyZhengGao/thesis", "max_stars_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter3/chapter3.2.tex", "max_issues_repo_name": "RoyZhengGao/thesis", "max_issues_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter3/chapter3.2.tex", "max_forks_repo_name": "RoyZhengGao/thesis", "max_forks_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 135.2173913043, "max_line_length": 1114, "alphanum_fraction": 0.738022508, "num_tokens": 6800, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.41082963149216317}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on 03/08/21\n\n\\section{Extension of Fields}\n\\label{sec:extension_of_fields}\n\n\\begin{defn}\n\tIf \\(K\\) is a field containing a subfield \\(F\\), then \\(K\\) is said to be an \\textbf{extension of \\(F\\)}, denoted by \\(K / F\\).\\\\\n\n\tThe field \\(F\\) is sometimes called the \\textbf{base field} of the extension.\n\\end{defn}\nNote that if \\(K\\) is an extension of a field \\(F\\), then \\(K\\) is a \\(F\\)-vector space via the typical \\(F\\) action.\n\n\\begin{defn}\n\tThe \\textbf{degree} or \\textbf{index} of a field extension \\(K / F\\), denoted \\([K:F]\\), is defined to be \\(\\textrm{dim}_F K\\), the dimension of \\(K\\) as an \\(F\\)-vector space.\n\\end{defn}\nFor example, \\([\\Q(\\sqrt{2} ) : \\Q] = 2\\) and \\([\\C: \\R] = 2\\). One can see the latter example by observing that \\(\\C\\cong \\R[x] / (x^2+1)\\).\n\n% Recall that we denote by \\(F(\\theta )\\) the field \\(F\\) adjoined by the root \\(\\theta \\), which is spanned by powers of \\(\\theta \\) as an \\(F\\)-vector space.\n\\begin{thm}\n\tLet \\(F\\) be a field and \\(p(x) \\in F[x]\\) be an irreducible polynomial. Then \\(\\exists \\) a field extension \\(K\\) of \\(F\\) in which \\(p(x)\\) has a root.\n\\end{thm}\nThis field is given by \\(K := F[x] / (p(x))\\), but we will show this more formally later.\n\n\\begin{thm}\n\tLet \\(p(x) \\in F[x]\\) be an irreducible polynomial of degree over \\(F\\), and let \\(K\\) be the field \\(F[x] / (p(x))\\). Take \\(\\theta := x + (p(x))\\) (root of \\(p(x)\\) ). Then\n\t\\begin{enumerate}\n\t\t\\item The elements \\(\\left\\{ 1_F, \\theta , \\theta ^2, \\ldots, \\theta ^{n-1} \\right\\} \\) are an \\(F\\)-vector space basis of the \\(F\\)-vector space \\(K\\).\n\t\t\\item \\([K:F] = n\\) \n\t\t\\item \\(K = \\left\\{a_0 + a_1\\theta + a_2\\theta^2 + \\ldots + a_{n-1}\\theta ^{n-1} \\mid a_0,\\ldots,a_{n-1} \\in F \\right\\} \\) as an \\(F\\)-vector space.\n\t\\end{enumerate}\n\\end{thm}\nAnother nice example to be familiar with is \\(K = \\mathbb{F}_2[x] / (x^2+x+1)\\). This is a field extension of \\(\\mathbb{F}_2\\) as \\(x^2+x+1\\) is irreducible in \\(\\mathbb{F}_2\\). We can see that \\([\\mathbb{F}_2[x] / (x^2+x+1) : \\mathbb{F}_2[x]] = 2\\) simply because the degree of the polynomial is \\(2\\), but we can also directly count elements in the set and see that it has twice the elements of \\(\\mathbb{F}_2[x]\\).\\\\\n\nNow let's define fields formed by adjoining roots more formally.\n\n\\begin{defn}\n\tLet \\(K / F\\) be a field extension, and let \\(\\alpha_1,\\alpha_2,\\ldots \\in K\\) be elements. The smallest subfield of \\(K\\) containing both \\(F\\) and the elements \\(\\alpha_1,\\alpha_2,\\ldots,\\) denoted \\(F(\\alpha_1,\\alpha_2,\\ldots)\\) is called the \\textbf{field generated by \\(\\alpha_1, \\alpha_2,\\ldots\\) over \\(F\\)}.\n\\end{defn}\n\n\\begin{defn}\n\tThe field \\(F(\\alpha )\\) generated by a single element \\(\\alpha \\) over \\(F\\) is called a \\textbf{simple extension of \\(F\\)}, and the element \\(\\alpha \\) in this case is called \\textbf{primitive}.\n\\end{defn}\n\n\\begin{thm}\n\tLet \\(F\\) be a field and let \\(p(x) \\in F[x]\\) be an irreducible polynomial. Suppose \\(K\\) is an extension of \\(F\\) containing a root \\(\\alpha \\) of \\(p(x)\\). Then \\(F[x] / (p(x)) \\cong F(\\alpha )\\).\n\\end{thm}\nIt is natural to view field extensions as the base field appended with roots, and as a result a few definitions arise.\n\n\\begin{defn}[Algebraic and Transcendental Elements]\n\tAn element \\(\\alpha \\in K\\) is called \\textbf{algebraic over \\(F\\)} if \\(\\alpha \\) is a root of some nonzero polynomial \\(f(x) \\in F[x]\\).\\\\\n\n\tIf \\(\\alpha  \\in K\\) is not algebraic over \\(F\\), then we say that \\(\\alpha \\) is \\textbf{transcendental over \\(F\\)}.\n\\end{defn}\nThe extension \\(K / F\\) is \\textbf{algebraic over \\(F\\)} if all elements of \\(K\\) are algebraic over \\(F\\).\n\n\\begin{exmp}[Examples of Algebraic and Transcendental Elements]\n\t\\begin{itemize}\n\t\t\\item \\(\\sqrt{2} \\) is an algebraic element over \\(\\Q\\) via the polynomial \\(x^2-2\\). This actually holds for all \\(\\sqrt[n]{2} \\) with \\(x^{n}-2\\).\n\t\t\\item \\(i\\) is algebraic over \\(\\R\\) and \\(\\Q\\) via the polynomial \\(x^2+1\\) \n\t\t\\item Transcendental elements are much rarer-- examples include \\(\\pi \\) and \\(e\\), but it is non-trivial to show an element is transcendental.\n\t\\end{itemize}\n\\end{exmp}\n\\end{document}\n", "meta": {"hexsha": "86bc89f168fcdcd8aa9407c15238102ea253d561", "size": 4548, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture15 - IntroFieldExtn.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture15 - IntroFieldExtn.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture15 - IntroFieldExtn.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.4634146341, "max_line_length": 419, "alphanum_fraction": 0.6479771328, "num_tokens": 1558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8152324803738429, "lm_q1q2_score": 0.4108006772761069}}
{"text": "% !TEX root = ../zeth-protocol-specification.tex\n\n\\section{Instantiating $\\mkhash$}\\label{instantiation:mkhash}\n\nIn this section we describe the instantiation of $\\mkhash$ with a compression function based on \\mimc{}~\\cite{albrecht2016mimc}. We firstly show how the compression function is constructed, and prove that this instantiation complies with the security requirements mentioned in~\\cref{zeth-protocol:sec-req}\n\n\\subsection{\\mimc{} Encryption}\\label{instantiation:mkhash:mimc-encryption}\n\n\\mimc{} is a block cipher with a simple design, consisting of a number of rounds (denoted $\\rounds$). During the $i$-th round, the message $\\msg$ is mixed with the encryption key $\\key{}$ and a randomly chosen constant $c[i]$, and a permutation function is applied to generate a new value of $\\msg$. The permutation function consists of exponentiation with a carefully chosen exponent $\\exponent{}$ (see~\\cref{instantiation:mkhash:mimc-encryption:security}). Note that \\rounds{} depends on the desired security level $\\secpar$. We denote the encryption function by \\mimcEnc{} and illustrate it in~\\cref{instantiation:fig:mimc}.\n\n\\begin{figure*}[ht]\n    \\centering\n    \\procedure[linenumbering]{$\\mimcEnc(\\key, \\msg, c, \\exponent{}, \\rounds)$}{\n        \\pcforeach\\ i \\in [\\rounds]:\\\\\n        \\t \\msg \\gets {(\\key\\ \\mathsf{OP}\\ c[i]\\ \\mathsf{OP}\\ \\msg)}^\\exponent{}\\\\\n        \\pcreturn (\\msg\\ \\mathsf{OP}\\ \\key)\n    }\n    \\caption{\\mimc{} Encryption function.}\\label{instantiation:fig:mimc}\n\\end{figure*}\n\n\\mimcEnc{} can be defined on both binary and prime fields, and as such the $\\mathsf{OP}$ operation corresponds to either $\\oplus$ or $+ \\pmod{p}$~\\cite{albrecht2016mimc, grassi2016mpc}.\nFor general prime $p$ (resp.~positive integer $n$), we denote by $\\mimcPrime{p}$ (resp.~$\\mimc{}_{2^n}$) the \\mimcEnc{} function defined over \\FFx{p} (resp.~\\FFx{2^n}).\n\n\\subsubsection{Security parameters and analysis}\\label{instantiation:mkhash:mimc-encryption:security}\n\nIn this document, we only consider \\mimc{} defined over prime fields (in particular, the field $\\FFx{\\rCURVE}$ over which \\zksnark~operates).\n\nSince block ciphers are usually defined over the product space of keys and messages, we consider the variables $c$, \\rounds{} and \\exponent{} as fixed. We thereby consider an instantiation of $\\mimc{}$ with signature\n\\begin{align*}\n    \\mimcPrime{\\rCURVE} &: \\FFx{\\rCURVE} \\times \\FFx{\\rCURVE} \\to \\FFx{\\rCURVE}\n\\end{align*}\n\nIn the sections below, and as in ~\\cite{albrecht2016mimc}, we will consider exponents of the form $\\exponent{} = 2^t-1$ and $\\exponent{} = 2^t+1$ where $\\gcd(\\exponent{}, \\rCURVE-1) = 1$. We note that the term cancellation happening with exponents of the form $\\exponent{} = 2^t+1$ does not immediatelly translate to the context where $\\mimc{}$ is carried out over prime fields of large odd characteristic. In fact, in the case of $\\FFx{\\rCURVE}$, where $\\rCURVE > \\binom{\\exponent}{\\lfloor \\exponent / 2 \\rfloor}$, polynomials $(x + y)^{\\exponent}$ are not sparse.\nThis comes from the \\emph{Binomial Theorem}\n\\[\n  (x + y)^\\exponent = \\sum_{i = 0}^{\\exponent} \\binom{\\exponent}{i} x^{i}y^{\\exponent - i}\n\\]\nand the observation that if $\\binom{\\exponent}{i} < \\rCURVE$ then $\\binom{\\exponent}{i} \\bmod \\rCURVE = \\binom{\\exponent}{i}$, hence ensuring that all the polynomial coefficients are greater than $0$, and that the polynomial is dense.\n\nTo achieve a security of $\\secpar$, we require that $\\rounds \\geq \\secpar \\log_{\\exponent}(2)$.\nImportantly, since we use $\\mimc{}$ over prime fields $\\FFx{\\rCURVE}$ which are large (where $\\rCURVE$ is the prime characteristic of the scalar field of an elliptic curve group, such that $\\ceil{\\log_2(\\rCURVE)} > \\secpar$\\footnote{Longer elements are needed in Elliptic Curve Cryptography (\\ecc) to resist algebraic attacks such as Number Field Sieve (\\acrnfs)-based attacks on discrete logs~\\cite{DBLP:journals/siamdm/Gordon93} for instance}), then, picking $\\rounds = \\left\\lceil \\frac{\\log_2 \\rCURVE}{\\log_2 \\exponent{}} \\right\\rceil > \\secpar \\log_{\\exponent}(2)$ provides a margin of safety on the number of rounds selected to instantiate $\\mimc{}$ with desired security level $\\secpar$.\n\nWe refer to the $\\mimc{}$ paper~\\cite[Section 4.2 and 5.1]{albrecht2016mimc} and to~\\cref{appendix:mimc-security} for more details on the security analysis and attacks on the scheme in the different settings. Note that $\\mimcPrime{\\rCURVE}$ does not suffer from \\emph{inversion subfield attacks} as there are no proper subfields of $\\FFx{\\rCURVE}$.\n\n\\subsection{\\mimc{}-based compression function}\\label{instantiation:mkhash:mimc-compressionf}\n\nThere exist two main techniques to construct a hash function from a block-cipher (or permutation): sponge functions~\\cite{bertoni2007sponge} and iterated compression functions~\\cite{black2002black}.\n\nA Merkle tree is a binary tree of values of fixed size, where the values in each ``layer'' are generated by hashing pairs of values from the previous ``layer''. That is, we require a compression function $\\mkhash$, which we construct via the Miyaguchi-Preneel scheme. (Miyaguchi-Preneel is more secure~\\cite[$f_5$ function]{black2002black} than the more flexible Davies-Meyer construct~\\cite[Section 3]{gazzoni2006maelstrom}, but this flexibility is not required in our case).\n\n\\subsubsection{Miyaguchi-Preneel compression construct}\n\nMiyaguchi-Preneel (MP)~\\cite[$f_3$ function]{black2002black} is a general scheme for constructing compression functions from block ciphers (see~\\cref{preliminaries:definitions:hashcomp}). Given a block cipher \\Enc, the corresponding compression function by \\fMP{} is given in~\\cref{instantiation:fig:mp-constructions}. The original construction is defined over binary fields, however \\zeth~operates over prime fields. Hence, in the general discussion here we replace the bitwise addition operator $\\oplus$ by modular addition in $\\FFx{\\rCURVE}$ (see~\\cite{mp-security-ethsnarks}).\n\nWe denote by \\mimcMP{} the compression function defined by the application of the Miyaguchi-Preneel construct over \\mimc{}. Similarly, for general prime $p$ we denote by $\\mimcMPPrime{p}$ (see~\\cref{instantiation:fig:mimc-mp-constructions}) the compression function defined by application of the Miyaguchi-Preneel construct over $\\mimcPrime{p}$.\n\n\\begin{figure*}[ht]\n    \\begin{minipage}[t]{0.50\\textwidth}\n        \\procedure[linenumbering]{$\\fMP{} (\\key, \\msg)$}{\n            res \\gets \\Enc_\\key(\\msg) \\\\\n            \\pcreturn (res + \\msg + \\key) \\pmod{\\rCURVE}\n        }\n        \\caption{\\MP{} construct in $\\FFx{\\rCURVE}$.}\\label{instantiation:fig:mp-constructions}\n    \\end{minipage}%\n    \\begin{minipage}[t]{0.50\\textwidth}\n        \\procedure[linenumbering]{$\\mimcMPPrime{\\rCURVE}(\\key, \\msg)$}{\n            res \\gets \\mimcPrime{\\rCURVE}(\\key, \\msg) \\\\\n            \\pcreturn (res + \\key + \\msg) \\pmod{\\rCURVE}\n        }\n    \\caption{$\\mimcMPPrime{\\rCURVE}$ construction.}\\label{instantiation:fig:mimc-mp-constructions}\n    \\end{minipage}%\n\\end{figure*}\n\n\\subsection{An efficient instantiation of \\mimc{} primitives}\\label{instantiation:mkhash:efficient-instance}\n\nTo select appropriate instances of $\\mimcPrime{\\rCURVE}$ and $\\mimcMPPrime{\\rCURVE}$, we consider the cost (in terms of gas consumption and prover efficiency). For given $\\exponent{}$ and $\\rounds{}$, the final definition of $\\mimcMPPrime{\\rCURVE}$ is given in \\cref{instantiation:fig:mimcp-construction} and \\cref{instantiation:fig:mimcp-mp-construction}.\n\n\\newcommand{\\initRoundConstants}{\\algostyle{InitRoundConstants}}\n\n\\begin{figure*}[ht]\n    \\begin{minipage}[t]{0.5\\textwidth}\n        \\centering\n        \\procedure[linenumbering]{$\\mimcPrime{\\rCURVE}(\\key, \\msg)$}{\n            c \\gets \\initRoundConstants() \\\\\n            \\pcforeach i \\in [\\rounds]:\\\\\n            \\t \\msg \\gets {(\\key + c[i] + \\msg)}^\\exponent{} \\pmod{\\rCURVE}\\\\\n            \\pcreturn (\\msg + \\key) \\pmod{\\rCURVE}\n        }\n    \\end{minipage}%\n    \\begin{minipage}[t]{0.5\\textwidth}\n        \\centering\n        \\procedure{$\\initRoundConstants()$}{\n            iv \\gets \\keccak{256} (\\text{``clearmatics\\_mt\\_seed''}) \\\\\n            c[0] \\gets 0 \\\\\n            c[1] \\gets \\keccak{256} (iv) \\\\\n            \\pcforeach i \\in \\range{2}{\\rounds}:\\\\\n            \\t  c[i] \\gets \\keccak{256} (c[i-1])\\\\\n            \\pcreturn c = (c[0], \\ldots, c[\\rounds-1])\n        }\n    \\end{minipage}%\n    \\caption{$\\mimcPrime{\\rCURVE}$ full construction}\\label{instantiation:fig:mimcp-construction}\n\\end{figure*}\n\n\\begin{figure*}[ht]\n    \\centering\n    \\begin{minipage}[t]{0.5\\textwidth}\n        \\procedure{$\\mimcMPPrime{\\rCURVE}(\\key, \\msg)$}{\n            \\pcreturn \\mimcPrime{\\rCURVE}(\\key, \\msg) + \\msg + \\key \\pmod{\\rCURVE}\n        }\n    \\caption{\\mimcMPPrime{\\rCURVE} full construction}\\label{instantiation:fig:mimcp-mp-construction}\n    \\end{minipage}%\n\\end{figure*}\n\n\\begin{remark}\n    Note that \\keccak{256} is the $256$-bit digest instance of the \\keccak{} family that won the NIST SHA-3 competition~\\cite{keccak-submission}. It is supported by the \\evm via an opcode (see~\\cite[Appendix G]{wood2014ethereum}), making it convenient for use in smart contracts.\n\\end{remark}\n\n\\begin{remark}\n    To increase the security of the $\\mathsf{\\mkhash}$, different round constants for each level of the Merkle tree could be used.\n\\end{remark}\n\nWe define $\\mkhash$ to be $\\mimcMPPrime{}$ over $\\FFx{\\rCURVE}$. Thereby, for input values $m_0$ and $m_1$, $\\mkhash : \\FFx{\\rCURVE} \\times \\FFx{\\rCURVE} \\to \\FFx{\\rCURVE}$ is defined by\n\\begin{equation}\\label{instantiation:eq:mkhash-instantiation}\n    \\mkhash(\\msg_0, \\msg_1) = \\mimcMPPrime{\\rCURVE}(m_0, m_1)\n\\end{equation}\n\n\\newcommand{\\constraints}{\\varstyle{constraints}}\n\nFor specific values of $\\rCURVE$ (such as $\\rBN$ for $\\BNCurve$ or $\\rBLS$ for $\\BLSCurve$), it remains to select concrete values of $\\exponent{}$ and rounds, where $\\rounds = \\lceil \\frac{\\log_2 \\rCURVE}{\\log_2 \\exponent{}} \\rceil$).  These values influence the number of constraints in the arithmetic circuit (see~\\cref{zeth-protocol:statement} for details of the statement) and the gas cost of Merkle tree operations on the contract (see~\\cref{zeth-protocol:process-tx} for details of the specific operations).\n\nIn the arithmetic circuit, an invocation of $\\mimcMPPrime{}$ requires $\\rounds \\cdot \\mults$ constraints, where $\\mults$ is the number of multiplications required for exponentiation. For exponents of the form $\\exponent = 2^t - 1$, we have $\\mults = 2 \\cdot t - 2$, (using the \\emph{square-and-multiply} algorithm~\\cite{menezes1996handbook}), and for $\\exponent = 2^t + 1$ we have $mults = t + 1$. Thus we expect that exponents of the latter form are more optimal. The implementation in the contract performs a very similar set of arithmetic operations (exponentiation in the field through a series of multiplications and modulo reductions), and so the cost is dominated by the same number $\\rounds \\cdot \\mults$ as for the circuit.  Hence, values of $\\exponent$ and $\\rounds$ that are optimal for the circuit will also result in gas-efficient implementations in the contract.\n\nFor several concrete values of $\\exponent{}$, the number of $\\rounds$ required to attain the desired security level, along with the number of constraints, are shown in~\\cref{table:mimc-exp-analysis}.\n\n\\definecolor{Gray}{gray}{0.9}\n\\begin{table}\n  \\centering\n    \\begin{minipage}[t]{0.50\\textwidth}\n        \\centering\n        \\begin{tabular}{r c c c c}\n            \\toprule\n            \\multirow{2}{*}{$\\exponent{}$} & \\multicolumn{2}{c}{\\BNCurve} & \\multicolumn{2}{c}{\\BLSCurve} \\\\ [0.5ex]\n            & $\\rounds$ & $\\constraints$ & $\\rounds$ & $\\constraints$ \\\\ [0.5ex]\n            \\midrule\n            \\rowcolor{Gray}\n            5 & 110 & 331 & & \\\\\n            7 & 91 & 365 & & \\\\\n            \\rowcolor{Gray}\n            17 & 65 & 316 & 62 & 311 \\\\\n            31 & 52 & 417 & 51 & 409 \\\\\n            127 & 37 & 445 & 37 & 445 \\\\\n            \\rowcolor{Gray}\n            257 & 32 & 289 & 32 & 289 \\\\\n            511 & 29 & 465 & & \\\\\n            2047 & 24 & 481 & 23 & 461 \\\\\n            8191 & 20 & 481 & 20 & 481 \\\\\n            32676 & 17 & 477 & & \\\\\n            \\rowcolor{Gray}\n            65537 & 16 & 273 & 16 & 273 \\\\\n            131071 & 15 & 481 & 15 & 481 \\\\\n            524287 & 14 & 505 & 14 & 505 \\\\\n            \\rowcolor{Gray}\n            1048577 & 13 & 274 & 13 & 274 \\\\\n            2097151 & 13 & 521 & & \\\\\n            \\bottomrule\n        \\end{tabular}\n    \\end{minipage}%\n    \\caption{Arithmetic constraints required to represent \\mimcMP{} as an R1CS program, for different exponents $\\exponent{}$ and curves. Grey (resp.~white) lines represent exponents of shape $2^t + 1$ (resp.~$2^t - 1$). Missing entries where $\\gcd(\\exponent{},\\rCURVE - 1) \\neq 1$}\\label{table:mimc-exp-analysis}\n\\end{table}\n\nFor the case of \\BNCurve~we set $\\exponent{} = 17$ with $\\rounds{} = 65$, to achieve a $254$-bit security level. For \\BLSCurve~we set $\\exponent{} = 17$ with $\\rounds{} = 62$, to achieve $253$-bit security. These values are chosen such that they satisfy the requirement that $\\gcd(\\exponent{},\\rCURVE - 1) = 1$, and give a balance between the number of constraints in the arithmetic circuit and the gas cost of hashing on the contract.\n\n\\subsection{Security requirements satisfaction}\\label{instantiation:mkhash:security}\n\nAfter presenting the state of the art of MiMC cryptanalysis, we present the security proof of \\mimcMPPrime{} collision resistance.\n\n\\subsubsection{Cryptanalysis of $\\mimc{}$ block cipher and primitives}\\label{instantiation:mkhash:security:cryptanalysis}\n\n\\mimc{}'s security is increasingly being analysed since the primitive has gained traction in zero-knowledge and cryptocurrency communities for its succinct algebraic constraint representation. As of today, we do not know of any attacks breaking \\mimc{} on prime fields on full rounds.\n\nThe first attack on \\mimc{} was an interpolation attack~\\cite{li2019improved} which targets a reduced-round version for a scenario in which the attacker has only limited memory.\nAn attack on Feistel-based \\mimc{}~\\cite{bonnetain2019collisions} was discovered shortly after, by using generic properties of the used Feistel construction (instead of exploiting properties of the primitive itself).\nAdditionally,~\\cite{albrecht2019algebraic} proposes an attack based on Gr\\\"{o}bner basis. The authors state that by introducing a new intermediate variable in each round, the resulting multivariate system of equations is a Gr\\\"{o}bner basis. As such, the first step of a Gr\\\"{o}bner basis attack can be obtained for free. However, the following steps of the attack are so computationally demanding that the attack becomes infeasible in practice.\nA recent work~\\cite{DBLP:conf/asiacrypt/Eichlseder0LORS20} targets \\mimc{} on binary fields, and achieves a full-round break of the scheme. While, the attack presented does not apply to prime fields, the authors note that it ``can be generalized to include ciphers over $\\FFx{p}$'', and that only the lack of efficient distinguishers over prime fields precludes this.\nAnother attack from Beyne et al~\\cite{cryptoeprint:2020:188} uses a low complexity distinguisher against full \\mimc{} permutation leading to a practical collision attack on reduced round sponge-based \\mimc{} hash defined with security of 128 bits.\n\n\\subsubsection{Security proof of \\mimcMPPrime{} collision resistance}\\label{instantiation:mkhash:security:colres-proof}\nWe now prove that this compression scheme satisfies all the security requirements listed in~\\cref{zeth-protocol:sec-req}. To do so, we first assume that the round constants are pseudo-random, i.e.~that $\\keccak{256}$ is a \\prf{}.\n\n\\begin{lemma}\n\t\\keccak{256} is a $\\prf$ with $\\lambda=128$.\n\\end{lemma}\n\nThe security of \\mimcMPPrime{} derives from a more general result, i.e.~from modelling \\mimcPrime{} as an ideal cipher (see~\\cref{preliminaries:def:ICM}). More specifically, we show a security result for the \\MP{} construction on \\FFx{\\rCURVE} by proving that, in the Ideal Cipher Model, the collision resistance advantage of any adversary is bounded by $\\frac{q(q+1)}{\\rCURVE}$, where $q$ is the number of different queries that the attacker makes to the oracle. This means that, assuming a maximum $q$ number of possible encryption/decryption queries, parameter $\\rCURVE$ can be chosen to make the advantage small as needed and $\\fMP$ considered collision resistant. Similar result applies to the ${2^n}$ case.\n\nThe instance of \\mimc{} we use is modelled as an ideal cipher defined on field elements, for this reason we consider a variant of the ICM model where the keys, inputs and outputs are field elements in $\\FFx{\\rCURVE}$ and the block cipher scheme, with key $\\key$, correspond to a family of $\\rCURVE$ independent random permutations $f_{\\key}: \\FFx{\\rCURVE} \\times \\FFx{\\rCURVE} \\to \\FFx{\\rCURVE}$.\n\nIn the proof, without loss of generality, we assume the following conventions for an adversary \\adv{}:\n\\begin{itemize}\n    \\item the adversary asks distinct queries: i.e.~if \\adv{} asks a query $\\oracleEnc(\\key,\\msg)$ and this returns $y$, then \\adv{} does not ask a subsequent query of $\\oracleEnc(\\key,\\msg)$ or $\\oracleDec(\\key,y)$, and inversely;\n    \\item the adversary necessarily obtained the candidate collision from the oracle. This property follows suite from modelling \\mimc{} as an ideal cipher.\n\\end{itemize}\n\n\\begin{lemma}\\label{lemma:colrescomp}\n    Let \\fMP{} be the \\MP{} compression function built on an ideal block-cipher \\Enc{} on \\FFx{\\rCURVE}, the probability for an adversary \\adv{} to find a collision is not greater than $q(q+1)/\\rCURVE$ where $q$ is a (positive) number of distinct oracle queries.\n\\end{lemma}\n\nThe following proof has been adapted from~\\cite[Lemma 3.3]{black2002black}\\footnote{It states the collision resistance of a set of compression functions $f_1,,\\ldots,,f_{12}$, denoted as \\emph{group-1 compression functions} and showed in~\\cite[Figure 3]{black2002black}. As mentioned above, Miyaguchi-Preneel corresponds to $f_3$ of that group. Since the proof of~\\cite[Lemma 3.3]{black2002black} shows collision resistance of $f_1$, we slightly modified it to work for $f_3$.}.\n\n\\begin{proof}\n    Fix $h_0\\in\\FFx{\\rCURVE}$. Let \\adv{} be an adversary attacking the compression function \\fMP{}.\n    Assume that \\adv{} asks the oracles \\oracleEnc{} and \\oracleDec{} a total of \\emph{distinct} $q$ queries. Let us denote the result of the $q$ queries and output of the attacker (candidate collision) as $\\left ( (\\key_1, \\msg_1, y_1), \\ldots , (\\key_q, \\msg_q, y_q), \\text{out} \\right )$.\n    If \\adv{} is successful it means that it outputs $(\\key, \\msg)$, $(\\key', \\msg')$ such that either $(\\key, \\msg) \\neq (\\key', \\msg')$ and $\\fMP(\\key, \\msg) = \\fMP(\\key', \\msg')$ or $\\fMP(\\key, \\msg) = h_0$.\n    By the definition of \\fMP, we have that $\\Enc_\\key(\\msg) + \\msg + \\key = \\Enc_{\\key'}(\\msg') + \\msg' + \\key'$ for the first case, or $\\Enc_\\key(\\msg) + \\msg + \\key = h_0$ for the second.\n    So either there are distinct $r, s \\in [1,\\ldots, q]$ such that $(\\key_r, \\msg_r, y_r) = (\\key, \\msg, \\Enc_\\key(\\msg))$ and $(\\key_s,\\msg_s, y_s) = (\\key',\\msg', \\Enc_{\\key'}(\\msg'))$ and $\\Enc_{\\key_r}(\\msg_r) + \\msg_r + \\key_r = \\Enc_{\\key_s}(\\msg_s) + \\msg_s + \\key_s$ or else there is an $r \\in [1,\\ldots, q]\\ \\suchthat\\ (\\key_r, \\msg_r, y_r) = (\\key, \\msg, h_0)$ and $\\Enc_{\\key_r}(\\msg_r) + \\msg_r + \\key_r = h_0$. We show that this event is unlikely.\n\n    In fact, for each $i \\in [1,\\ldots, q]$, let $C_i$ be the event that either $y_i + \\msg_i + \\key_i = h_0$ or does exist $j \\in [1,\\ldots, i-1]\\ \\suchthat\\ y_i + \\msg_i + \\key_i = y_j + \\msg_j + \\key_j$. When carrying out the simulation $y_i$ or $\\msg_i$ was randomly selected from a set of at least $\\rCURVE - (i-1)$ elements, so $\\prob{C_i}\\leq i / (\\rCURVE-i)$. This means that for the collision advantage of \\adv{}, \\advCollMP it holds that $\\advCollMP \\leq \\prob{C_1 \\lor \\cdots \\lor C_q} \\leq \\sum_{i=1}^{q} \\prob{C_i}$. For $q \\leq \\frac{\\rCURVE}{2}$ this probability is bounded by $l \\cdot \\frac{q(q+1)}{\\rCURVE}$. However, we allow only a polynomial number of queries, thus for $q = \\poly$ this probability becomes $\\frac{\\poly}{\\rCURVE}$, where $\\rCURVE \\approx 2^\\secpar$.\n\\end{proof}\n\n\\begin{notebox}\n   \\cref{lemma:colrescomp} is applicable to our case by the strong assumption of \\mimcPrime{\\rCURVE} being an ideal cipher. In other words, the proof does not take into account any structural weakness or knowledge that an attacker is aware of. Any such additional information could make~\\cref{lemma:colrescomp} invalid, and consequently could be used to break the collision resistance.\n\\end{notebox}\n\n\\begin{remark}\n    Note that from~\\cref{lemma:colrescomp} follows that the collision resistance security of the \\zeth{} Merkle tree is $\\log_2(\\rCURVE/2)$ (around $127$ bits for $\\rCURVE = \\rBN$ or $\\rBLS$).\n\\end{remark}\n\n\\begin{notebox}\n    $\\mimc{}$ has \\emph{not} received as much cryptanalytic scrutiny as other ``older'' and more established hash functions. This is important to note since, for these type of primitives which are not provably secure, the amount of attacks received by a scheme is a great indicator of its security and robustness.\n    A natural alternative to $\\mimc{}$ here consists in using Pedersen hash which is provably collision resistant under the discrete-logarithm assumption.\n\\end{notebox}\n", "meta": {"hexsha": "86732711ee38f0df551a961145722d6f2d5032b9", "size": 21365, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chap03-sec02.tex", "max_stars_repo_name": "clearmatics/zeth-specifications", "max_stars_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-29T18:22:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-29T18:22:00.000Z", "max_issues_repo_path": "chapters/chap03-sec02.tex", "max_issues_repo_name": "clearmatics/zeth-specifications", "max_issues_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2020-10-27T10:41:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-16T10:57:05.000Z", "max_forks_repo_path": "chapters/chap03-sec02.tex", "max_forks_repo_name": "clearmatics/zeth-specifications", "max_forks_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-07-26T04:51:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-26T04:51:29.000Z", "avg_line_length": 92.0905172414, "max_line_length": 876, "alphanum_fraction": 0.7071378423, "num_tokens": 6399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5195213219520929, "lm_q1q2_score": 0.41069735619847864}}
{"text": "\\documentclass[12pt,a4]{article}\n\n\\newcommand{\\handoutdate}{Friday, 2020-04-17}\n\\newcommand{\\firstduedate}{Friday, 2019-04-24}\n\\newcommand{\\finalduedate}{Tuesday, 2020-05-01}\n\n\n\\input{preamble}\n\n\\setcounter{section}{3}\n\n\\section{Bottleneck Paths}\n\nLet $G=(V,E)$ be a directed graph with an edge capacity function $c: E \\rightarrow \\R^+$. For a path\n$p = u_0 u_1 \\dots u_t$ define its {\\em capacity} to be\n\\begin{align}\n   c(p) := \\min_{1 \\leq i \\leq t} c( \\{u_{i-1}, u_i\\}) \\ .\n\\end{align}\n\n\\begin{quotation}\n    \\textbf{Maximum Capacity Path Problem (MCP).} Given a directed graph $G = (V,E)$, an edge capacity function\n    $c: E \\rightarrow \\R^+$, and two vertices $s, t \\in V$, compute the path $p^*$ maximizing $c(p)$. We\n    denote by $p^*$ the optimal path and by $c^* := c(p^*)$ its cost. \n\\end{quotation}\n\n\n\n\\begin{exercise}\n   Suppose the edges $e_1,\\dots,e_m$ are sorted by their cost. Show how to solve MCP in time $O(n+m)$.\n\\end{exercise}\n\n\\begin{proof}\nDesign a algorithm following Pseudocode shows(Suppose the edges are sorted decreased, See in Algorithm 1):\n\nAnd then we think about the correctness and complexity.\n\nThe algorithm means we can enum the answer. When we find a edge between the point visited and not visited, we can go through all the edges which's costs is higher than this edge. If now s is connected to t, means this edge is the largest edge while going through all edges higher than it from $s$ to $t$. That fits the answer we want.\n\nNow, let's think about the complexity. For every node, it may be in queue at least once. And for every edge, it may be in $G'$ and used in bfs at least once. So the time complexity is $O(n+m)$.\n\\begin{algorithm}[H]\n\\caption{Solve MCP in time $\\Theta(n+m)$ with all the edges sorted by their cost}\n\\begin{algorithmic}\n\\Procedure{MCP}{$G, s, t$}\n\t\\State Initiate $visited \\gets s$ and $G' \\leftarrow \\emptyset$\n\t\\For {$e \\in G$}\n\t\t\\If{$e.from\\in visited$ and $e.to\\notin visited$}\n\t\t\t\\State $bfs\\_graph(e.to, G')$\n\t\t\\Else\n\t\t\t\\State $G'\\gets G' \\cup {e}$\n\t\t\\EndIf\n\t\t\\If{$t \\in visited$}\n\t\t\t\\State \\Return $e.weight$\n\t\t\\EndIf\n\t\\EndFor\n\\EndProcedure\n\\Procedure{bfs\\_graph}{$s, G$}\n\t\\State $visited \\gets visited \\cup {s}$\n\t\\State push s into the queue\n\t\\While {queue is not empty}\n\t\t\\State Let top be the head of the queue and pop the head.\n\t\t\\For{$e \\in {edges\\ in\\ G\\ from\\ top}$}\n\t\t\t\\If {$e.to \\notin visited$}\n\t\t\t\t\\State $visited \\gets visitied \\cup{e.to}$\n\t\t\t\t\\State push e.to into the queue\n\t\t\t\\EndIf\n\t\t\\EndFor\n\t\\EndWhile\n\\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n\\end{proof}\n\n\\begin{exercise}\n   Give an algorithm for MCP of running time $O(m \\log \\log m)$. \\textbf{Hint:} Using the median-of-medians algorithm,\n   you can determine an edge $e$ such that at most $m/2$ edges are cheaper than $e$ and at most $m/2$ edges are\n   more expensive than $e$. Can you determine, in time $O(n+m)$, whether $c^* < c(e)$, $c^* = c(e)$, or $c^* > c(e)$?\n   Iterate to shrink the set of possible\n    values for $c^*$ to $m/4$, $m/8$, and so on.\n\\end{exercise}\n\\begin{proof}\n\tAs is shown by the hint, during each iteration, we can shrink the\n\tset of possible values of $c^{*}$, i.e. \n\t\\[\nE_1= \\{e \\mid c\\left( e \\right) \\le M,e\\in E'\\}, \n\t\tE_2 = \\{e \\mid c\\left( e \\right) > M, e\\in E'\\}\n\t\t\\]\n\tWe we can find a path in  $E_2$, then the lower bound $L$ of $c^{*}$ can \n\tbe updated to $M$. Since if $c^{*}>L$, we must have a \n\tpath $e$ with all the edges larger then $L$.\n\n\tOtherwise, the upper bound $U$ will be $M$ as there is no such path with \n\tall edges larger than $M$. However, if we take iterations until \n\t$L = U$, we will have $O\\left( m\\log m  \\right)  $ running time. So we only do \n\t$ \\log(s\\left( m \\right) )$ \n\titerations. Here $s$ is a place holder to decide later\n\n\tConsider the following algorithm\n\t\\begin{algorithm}[H]\n\t\t\\caption{Solve MCP in time $n\\log\\log n$ }\n\t\t\\begin{algorithmic}\n\t\t\t\t\\State $i=0, U = \\infty, L = 0$\n\t\t\t\t\\While {$i < \\log s\\left( m \\right) $ }\n\t\t\t\t\\State Determine the median of $\\{e \\mid e\\in E',c\\left( e \\right) \\le U\\} $.\n\t\t\t\t\\If{ $\\left( V,E_2 \\right) $ is $s$- $t$ connected }\n\t\t\t\t\\State $E' \\leftarrow E_2, L = M$,\n\t\t\t\t\\Else \n\t\t\t\t\\State $U = M$\n\t\t\t\t\\EndIf\n\t\t\t\t\\State $i=i+1$\n\t\t\t\t\\EndWhile\t\n\t\t\t\t\\State Number $t$ edges in set $\\{e \\in E' \\mid c\\left( e \\right) \\le U\\} $ according to increasing order $e_1,e_2,\\ldots.$\n\t\t\t\t\\State Solve instance by \\textbf{Algorithm 1} with the following \n\t\t\t\tordering, i.e. the place of $e$ in the sorted array \n\t\t\t\t\\[\n\t\t\t\t\t\tl\\left( e \\right) = \\begin{cases}\n\t\t\t\t\t\t\t\t1, \\quad c\\left( e \\right) \\le L \\\\\n\t\t\t\t\t\t\t\ti, \\quad  \\exists i,e =e_{i} \\\\\n\t\t\t\t\t\t\t\tt, \\quad c \\left( e \\right) > U\n\t\t\t\t\t\t\\end{cases}\n\t\t\t\t.\\] \n\t\t\\end{algorithmic}\n\\end{algorithm}\nNow we prove this algotihm is $n\\log \\log n$, just notice that \n\\[\n\t\tt = O\\left( \\frac{m}{s\\left( m \\right) } \\right) \n.\\] \nSince every iteration we make the set $\\{ e  \\mid  e\\in E', c\\left( e \\right) \n< U\\} $ shrinks to $\\frac{1}{2}$. That is \nthe size $t = \\lvert  E'\\rvert \\le \\frac{m}{2^{\\log s\\left( m \\right) }}$. \n\nThus the running time is \n\\[\n\\log\\left( s\\left( m \\right) \\right)\\cdot m + t \\log t + t\n\\]\nconsidering the sorting of the \n$t$ edges plus the running time of \\textbf{Algorithm 1} ,\nnow we choose $s\\left( m \\right) = \\log m $ to minimize the time which is \n\\[\n\t\tm\\left( \\frac{\\log m}{s} - \\frac{\\log s}{s} \\right) \n.\\] \nHence \n\\[\n\t\tT =O\\left( m \\log\\log m \\right) + O \\left( \\frac{m}{\\log m} \\log \\left( \\frac{m}{\\log m } \\right) \\right) + \n\t\tO \\left( \\log m \\right) \n\t\t= O\\left( m\\log\\log m  \\right) \n.\\] \n\\end{proof}\n\n\n\\begin{exercise}\n   Give an algorithm for MCP that runs in time $O(m \\log \\log \\log m)$? How about $O(m \\log \\log \\log \\log m)$? How far can you get?\n\\end{exercise}\n\\begin{proof}\n\t\tWe can have a better algorithm runs in $O\\left( m \\log\\ldots\\log m \\right) $ (arbitrary number of log), \n\n\t\tConsider a set of edge $E$ with $\\frac{m}{k}$ elements. We apply  \\textbf{median of median} algorithm\n\t\t$k$ rounds. Each round we break one block into 2 parts. For example, in the first round, we find the median \n\t\t $M$ of $E$, and break $E$ into\n\t\t\\[\n\t\t\t\tE_1=\\{e \\mid c\\left( e \\right) < M, e\\in E\\} , E_2 = \\{e  \\mid c \\left( e \\right) \\ge M, e\\in E\\} \n\t\t.\\] \n\t\tAnd in the second round, we can obtain 4 blocks by apply MOM to $E_1,E_2$ respectively. Finally we have $2^{k}$ blocks $A_1,\\ldots,A_{2^{k}}$ by using the above method\n\t\trecursively, while\n\t\teach block has $\\frac{m}{k 2^{k}}$ elements. Plus by the property of median\n\t\t\\[\n\t\t\t\t\\forall i<j, \\forall e_1 \\in A_i, e_2\\in A_j, c\\left( e_1 \\right) < c\\left( e_2 \\right) \n\t\t.\\] \n\t\tHence we can apply the idea we used in \\textbf{Exercise 2}. That is, \n\n\t\\begin{algorithm}[H]\n\t\t\\caption{The key idea to solve MCP in time $n\\log\\ldots\\log n$ }\n\t\t\\begin{algorithmic}\n\t\t\t\t\\State $E' = \\bigcup_{i\\le 2^{k}} A_{i}, L = 0, U = \\max\\left( E \\right) $\n\t\t\t\t\\For{$i$ in range$(2^{k})$}\n\t\t\t\t\\If{ $\\left( V,A_i \\right) $ is $s$- $t$ connected}\n\t\t\t\t\\State $E' \\leftarrow A_i$, $L = \\min \\left( A_i \\right) $ \n\t\t\t\t\\Else \n\t\t\t\t\\State $U = \\min \\left( A_i \\right) $\n\t\t\t\t\\EndIf\n\t\t\t\t\\EndFor\t\n\t\t\\end{algorithmic}\n\\end{algorithm}\nHence our problem is reduced to a edge set $E'$ with whose size is $O\\left( \\frac{m}{k 2^{k}} \\right) $, we\ncall this one  iteration. And this \ncosts \n \\[\n\t\t T = \\sum_{i=1}^{k} \\sum_{j=1}^{i} O\\left( \\frac{m}{k 2^{i}} \\right) = k O\\left( \\frac{m}{k} \\right) = O\\left( m \\right) \n.\\] \nAnd let $f\\left( k \\right)  = k 2^{k}$, assume that after $r$ iterations, we can decide $c^{*}$ i.e. there is only one integer in the interval $E'$, we have \n\\[\n\t\tf^{r-1}\\left( 1 \\right) <  m \\le  f^{r} \\left( 1 \\right) \n.\\] \nWhich leads that $m \\ge g^{r-1}\\left( 1 \\right)  $, in which $g\\left( x \\right) = 2^{x}$. Hence $r$ is the \nsmallest integer such that \n$1 \\le  \\log \\log\\ldots\\log m$ with $r$ log, that means we only need \n$r$ iterations to reduce the problem,  hence the overall running time is \n$O\\left( r m  \\right)  $. Actually we can prove $\\forall s$, $\\exists m$\n\\[\n\t\tr < \\log\\log\\ldots\\log m \\left( \\text{with } s \\log \\right) \n.\\] \nOtherwise $1 < \\log\\ldots\\log r $ with $r-s$ log. Hence  $r >f^{r-s} \\left( 1 \\right) $, which\nleads to a contradiction since $m$ and  $r$ can be arbitrarily large but $s$ is fixed.\nHence the running time could be written as $O\\left( m \\log \\log \\ldots\\log m \\right) $ (arbitrary number of log). \n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "f2280f9169183c47da8aa08e123264dec987fe7f", "size": 8341, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Week4/week4.tex", "max_stars_repo_name": "yujie6/CS217-Notes", "max_stars_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Week4/week4.tex", "max_issues_repo_name": "yujie6/CS217-Notes", "max_issues_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Week4/week4.tex", "max_forks_repo_name": "yujie6/CS217-Notes", "max_forks_repo_head_hexsha": "b74b6ce9d2ccfcac47dd7b73f22338d3e0180068", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2946859903, "max_line_length": 334, "alphanum_fraction": 0.6296607121, "num_tokens": 3064, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.7905303112671295, "lm_q1q2_score": 0.41069735235269855}}
{"text": "\n\\documentclass[11pt]{article}\n\\setlength{\\textwidth}{7in} \\setlength{\\textheight}{9.8in}\n\\setlength{\\topmargin}{-0.8in} \\setlength{\\oddsidemargin}{-0.25in}\n\\setlength{\\evensidemargin}{-0.25in}\n\n\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}\n\\usepackage{color}\n\\usepackage{hyperref}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n%\\usepackage{algpseudocode}\n\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Homework2  Page \\thepage}\n\\lhead{Shen Qu}\n\\chead{STAT 671}\n\n\\DeclareMathOperator{\\trace}{trace}\n\n\n\\begin{document}\n\n%\\includegraphics{../../../psulogo_horiz_bw.eps}\\hfill\\includegraphics{../../../deptlogo}\n\\noindent\nThis homework is an exan that was given during a previous iteration of this course. I have voluntarily kept the presentation as it was for the exam. \n\\noindent\n\\noindent \n\n\\section{Multivariate Fisher Kernel}\nThe Fisher kernel is a kernel for data in $\\mathbb{R}^d$ which is based on a probabilistic model. Specifically, let $x \\in \\mathbb{R}^d$, and let $p_{\\theta}$ be a probability density function indexed by a parameter vector $\\theta \\in \\mathbb{R}^k$.  First, fix some $\\theta_0 \\in \\mathbb{R}^k$ and define the Fisher score of a data point $x$, by $\\phi(x)$, the gradient of the logarithm of $p_{\\theta}$ evaluated at $\\theta=\\theta_0$. That is, \n\\begin{equation}\n\\phi(x)=\\nabla_\\theta \\ln p_{\\theta}(x) |_{\\theta=\\theta_0}\n\\end{equation}\nThus $\\phi: \\mathbb{R}^d \\to \\mathbb{R}^k$. \n\nhttp://yongyuan.name/blog/fim-fisher-kernel.html\n\nhttps://wiseodd.github.io/techblog/2018/03/11/fisher-information/\n\nNext, define the Fisher information matrix as the following expected value:\n\\begin{equation}\nI = E_{p_{\\theta_0}}[\\phi(X)\\phi^T(X)]\n\\end{equation}\nNote that $I$ is a $(k,k)$ matrix. You can use the fact that this matrix is symmetric and positive definite. \nFinally, define the Fisher kernel as \n\\begin{equation}\nK(x,y)=\\phi(x)^T I^{-1} \\phi(y)\n\\end{equation}\nfor any couple of points $(x,y)$, both in $\\mathbb{R}^d$\n\\begin{enumerate}  \n\\item Verify that $K$ is symmetric\n\n\\begin{align*}\nE_{p_{\\theta_0}}[\\phi(X)] &= E_{p_{\\theta_0}}\\left[\\nabla_\\theta \\ln p_{\\theta}(x) |_{\\theta=\\theta_0} \\right]= \\int \\nabla \\ln p_{\\theta}(x) \\, p_{\\theta}(x) \\, \\text{d}x = \\int \\frac{\\nabla p_{\\theta}(x)}{p_{\\theta}(x)} p_{\\theta}(x) \\, \\text{d}x \\\\\n&= \\int \\nabla p_{\\theta}(x) \\, \\text{d}x = \\nabla \\int p_{\\theta}(x) \\, \\text{d}x = \\nabla 1 = 0\n\\end{align*}\n\n$I = E_{p_{\\theta_0}}[\\phi(X)\\phi^T(X)]=E[\\phi(X)^2]=V[\\phi(X)^2]-E[\\phi(X)]^2=V[\\phi(X)^2]-0\\ge 0$\n\nFor $\\underset{(k,k)}{I}$ is symmetric and positive definite, $I^{-1}=L^TL$ by Cholesky decomposition, where $L$ is a lower triangular matrix with real and positive diagonal entries.\n\n\\begin{align*}\nK(x,y)&=\\phi(x)^T I^{-1} \\phi(y)=\\phi(x)^T L^T L \\phi(y)=(L\\phi(x))^T (L \\phi(y))\\\\\n      &=\\langle L\\phi(x),L\\phi(y)\\rangle_{\\mathcal{H}}=\\langle L\\phi(y),L\\phi(x)\\rangle_{\\mathcal{H}}=K(y,x)\n\\end{align*}\n\nwhere $\\mathcal{H}$ is a Hilber Space. $L\\phi(\\cdot)$ is a function $\\mathcal{X}\\to \\mathbb{R}$\n\n\n\\item Verify that $K$ is positive definite\n\nChoose $x_1,..x_n\\in\\mathcal{X}$; $\\alpha_1,..\\alpha_n\\in\\mathbb{R}$\n\n$$\\sum_{i,j=1}^n\\alpha_i\\alpha_j k(x_i,x_j)=\\sum_{i,j=1}^n\\alpha_i\\alpha_j(L\\phi(x_i))^T (L \\phi(x_j))=(\\sum_{i=1}^n\\alpha_i L\\phi(x_i))^T (\\sum_{j=1}^n\\alpha_j L \\phi(x_j))=\\|\\alpha L\\phi(x)\\|^2_{\\mathcal{H}}\\ge 0$$\n\n\n\n\n\\item\nConsider the following multivariate Normal model with given invertible covariance matrix $\\Lambda^{-1}$: \n$p_\\theta(x)=(2\\pi)^{-d/2}(\\det{\\Lambda})^{1/2}\\exp\\left(-\\frac{1}{2}(x-\\theta)^T\\Lambda (x-\\theta)\\right)$\nShow that \n$\\phi(x)=\\Lambda (x - \\theta_0)$\n\n\n\n\\begin{align*}\n\\phi(x)&=\\nabla_\\theta \\ln p_{\\theta}(x) |_{\\theta=\\theta_0}=\\nabla_\\theta \\ln(2\\pi)^{-d/2}(\\det{\\Lambda})^{1/2}\\exp\\left(-\\frac{1}{2}(x-\\theta_0)^T\\Lambda (x-\\theta_0)\\right)\\\\\n&=\\nabla_\\theta -\\frac{d}2\\ln(2\\pi)+\\frac{1}2(\\det{\\Lambda})-\\frac{1}2(x-\\theta_0)^T\\Lambda (x-\\theta_0)\\\\\n&=-\\frac{2}2\\Lambda (x-\\theta_0)(-1)=\\Lambda (x - \\theta_0)\n\\end{align*}\n\n\n\n\\item Compute the Fisher information matrix $I$ for this model\n\\begin{align*}\nI &= E_{p_{\\theta_0}}[\\phi(X)\\phi^T(X)]=E_{p_{\\theta}}[(\\Lambda (x - \\theta))^T\\Lambda (x - \\theta)]\\\\\n  &=\\Lambda E_{p_{\\theta}}[(x - \\theta)^T (x - \\theta)]\\Lambda=\\Lambda^3\n\\end{align*}\n\n\\item Compute the Fisher kernel for this model\n\n\\begin{align*}\nK(x,y)&=\\phi(x)^T I^{-1} \\phi(y)=(\\Lambda (x - \\theta_0))^T(\\Lambda^3)^{-1}\\Lambda (x - \\theta_0)\\\\\n  &=(x - \\theta_0)^T\\Lambda(\\Lambda\\Lambda\\Lambda)^{-1}\\Lambda (y - \\theta_0)=(x-\\theta_0)^T\\Lambda^{-1}(y - \\theta_0)\n\\end{align*}\n\n\n\n\\end{enumerate}\n\n\\section{Optimal ordering}\nWe consider a binary classification problem where the training set is $\\mathcal{D}=\\{(x_i,y_i), 1\\leq i \\leq n\\}$, with $x_i \\in \\mathbb{R}^d$ and $y_i \\in \\{-1,+1\\}$ is the class. For convenience, we consider the following subset of indices \n\\begin{eqnarray}\nI_-&=&\\{i, 1\\leq i \\leq n, y_i=-1\\}\\\\\nI_+&=& \\{i, 1\\leq i \\leq n, y_i=+1\\}\n\\end{eqnarray}\nMoreover, notate $n_-$ the number of elements in $I_-$, and $n_+$ the number of elements in $I_+$. Thus \n\\begin{equation}\nn_-+n_+=n\n\\end{equation}\n Our objective is to use $\\mathcal{D}$ to construct a function $f:\\mathbb{R}^d \\to \\mathbb{R}$ that assign larger values to the data points in the positive class than to the data points in the negative class while being smooth in some sense. \n\nThus, we propose to choose $f$ in a RKHS with a kernel K that minimizes the following functional:\n\\begin{equation}\nJ_0(f) = \\frac{1}{n_- n_+}\\sum_{i \\in I_-}\\sum_{j \\in I_+} \\mathbb{I}_{f(x_i)>f(x_j)} + \\lambda ||f||_H^2\n\\end{equation}\n where $\\mathbb{I}_u$ is the indicator function of the event $u$. It takes the value 1 if the event u occurs and 0 otherwise and $\\lambda>0$. \n\nSince $J_0$ is not convex, we propose instead to minimize\n\\begin{equation}\nJ(f) = \\frac{1}{n_- n_+}\\sum_{i \\in I_-}\\sum_{j \\in I_+}\\left(1-\\left(f(x_j)-f(x_i)\\right)\\right) + \\lambda ||f||_H^2\n\\end{equation}\n\n\\begin{enumerate}\n\\item Show that the minimum is achieved for a function $f$ index by a parameter $\\alpha \\in \\mathbb{R}^d$ and of the form\n\\begin{equation}\nf(x)=\\sum_{i=1}^n \\alpha_i K(x_i,x)\n\\end{equation}\nNote: do not invoke the representer theorem. Instead, use the key elements in the proof of this theorem applied to this particular case. \n\nLet $v=\\text{span} [k(\\cdot,x_i),..,k(\\cdot,x_n)]$ $\\mathcal{V}$ is closed linear subspace of $\\mathcal{H}$. Then all minimizers of $J$ belong to  $\\mathcal{V}$.\nThus, there is an unique decomposition $f=f_v+f_{\\perp}$ with $f_v\\in\\mathcal{V}$\n\n$\\forall f\\in\\mathcal{V}$, $\\langle f_{\\perp},g\\rangle=0$\n\n$$\\|f\\|^2_{\\mathcal{H}}=\\|f_v+f_{\\perp}\\|^2_{\\mathcal{H}}=\\langle f_v+f_{\\perp},f_v+f_{\\perp}\\rangle=\\langle f_v,f_v\\rangle+\\langle f_{\\perp},f_{\\perp}\\rangle+\\underbrace{2\\langle f_v,f_{\\perp}\\rangle}_{0}=\\|f_v\\|^2_{\\mathcal{H}}+\\|f_{\\perp}\\|^2_{\\mathcal{H}}$$\n\n$$f(x_i)=\\langle f,k(\\cdot,x_i)\\rangle=\\langle f_{v}+f_{\\perp},k(\\cdot,x_i)\\rangle=\\langle f_{v},k(\\cdot,x_i)\\rangle+\\underbrace{\\langle f_{\\perp},k(\\cdot,x_i)\\rangle}_{0}=f_v(x_i)$$\n\nFor $f$ is strictly increasing\n\n\\begin{align*}\nJ(f)-J(f_v) &= \\frac{1}{n_- n_+}\\sum_{i \\in I_-}\\sum_{j \\in I_+} [1-\\left(f(x_j)-f(x_i)\\right)]+ \\lambda\\|f\\|_{\\mathcal{H}}^2\n              -\\frac{1}{n_- n_+}\\sum_{i \\in I_-}\\sum_{j \\in I_+} [1-\\left(f_v(x_j)-f_v(x_i)\\right)]- \\lambda\\|f_v\\|_{\\mathcal{H}}^2\\\\\n&=\\lambda \\|f\\|_{\\mathcal{H}}^2-\\lambda \\|f_v\\|_{\\mathcal{H}}^2=\\lambda \\|f_{\\perp}\\|_{\\mathcal{H}}^2\\ge 0\n\\end{align*}\n\nThe representer theorem allows us to reduce the optimization problem to a finite dimensional optimization problem.\n\nLet $\\alpha=(\\alpha_1,..,\\alpha_n)^T\\in\\mathbb{R}^n$ is the solution of $\\min J(f)$, the function $f(x)=\\sum_{i=1}^n \\alpha_i k(x_i,x)$,$f \\in\\mathcal{H}$ that minimizes $J(f)$\n\n\\item Rewrite then $J(f)$ as a functional $J(\\alpha)$ using the notation  $K$ for the $(n,n)$ matrix $K_{ij}=K(x_i,x_j)$ and $K_i$ for the $i^{th}$ column of $K$.\n\n$$\\|f\\|^2_{\\mathcal{H}}=\\langle f,f\\rangle_{\\mathcal{H}}=\\langle \\sum_{i=1}^n\\alpha_i k(\\cdot,x_i),\\sum_{j=1}^n\\alpha_j k(\\cdot,x_j)\\rangle_{\\mathcal{H}}=\\sum_{i,j=1}^n\\alpha_i\\alpha_j\\underbrace{\\langle k(\\cdot,x_i),k(\\cdot,x_j)\\rangle_{\\mathcal{H}}}_{k(x_i,x_j)}=\\underset{(1,n)}{\\alpha^T}\\underset{(n,n)}{K}\\underset{(n,1)}{\\alpha}$$\n\n$$f(x_i)=\\sum_{j=1}^n\\alpha_j k(x_i,x_j)=\\sum_{j=1}^n\\alpha_j[\\underset{(n,n)}{K}]_{i,j}=[K\\alpha]_i$$\n\n$$J(\\sum_{i=1}^n\\alpha_i k(x_i,\\cdot))=\\frac{1}{n_- n_+}\\sum_{i \\in I_-}\\sum_{j \\in I_+} [1-([K\\alpha]_j-[K\\alpha]_i)]+ \\lambda \\alpha^T{K}\\alpha$$\n\n\n\n\\item Simplify further the expression $J(\\alpha)$ using the notations:\n\n$K_-=\\frac{1}{n_-}\\sum_{i \\in I_-}K_i$;\n$K_+=\\frac{1}{n_+}\\sum_{i \\in I_+}K_i$;\n\n$$J(\\alpha)=1-[\\frac{1}{n_+}\\sum_{j \\in I_+}[K\\alpha]_j-\\frac{1}{n_-}\\sum_{i \\in I_-}[K\\alpha]_i)]+ \\lambda \\alpha^T{K}\\alpha=1-[K_+-K_-]\\alpha+ \\lambda \\alpha^T{K}\\alpha$$\n\n\n\\item Compute $\\nabla_\\alpha J(\\alpha)$, the gradient in $\\alpha$ of $J(\\alpha)$. Solve for $\\alpha$, assuming that $K$ \nis invertible. \n\np.d. $K,X$ is symmetric, $K=K^T$, $X=X^T$; $K=P\\Lambda P^T$; $I=PP^T$; $\\Lambda$ is diagonal matrix with $\\gamma_1,..,\\gamma_n$.\n\n$\\lambda>0$,$\\gamma_i>0$, $K+\\lambda I=P(\\Lambda+\\lambda I) P^T$ is inversible.\n\n\\begin{align*}\n\\nabla_\\alpha J&=\\frac{\\partial}{\\partial\\alpha}(1-[K_+-K_-]\\alpha+ \\lambda \\alpha^T{K}\\alpha)=-[K_+-K_-]+ \\lambda \\frac{\\partial}{\\partial\\alpha}\\langle\\alpha,K\\alpha\\rangle\\\\\n&=-[K_+-K_-]+ \\lambda (IK\\alpha+K^T\\alpha)=-[K_+-K_-]+2\\lambda K\\alpha\\overset{set}{=}0\\\\\n\\end{align*}\n\n$$\\alpha^\\star=(2\\lambda K)^{-1}[K_+-K_-]$$\n\n\\item Bonus question: Compute $f^*(x)$, where $f^*$ is the minimizer of $J(f)$ for the linear kernel $K(x,y)=x^Ty$. Use the notations\n${x}_-=\\frac{1}{n_-}\\sum_{i \\in I_-}x_i$;\n${x}_+=\\frac{1}{n_+}\\sum_{i \\in I_+}x_i$\n\n\\end{enumerate}\n\n$$\\frac{1}{n_+}\\sum_{j \\in I_+}f(x_l)=\\frac{1}{n_+}\\sum_{j \\in I_+}\\sum_{l=1}^n\\alpha_l k(x_l,x_j)= \\sum_{l=1}^n\\alpha_l x_l\\frac{1}{n_+}\\sum_{j \\in I_+}x_j=\\alpha^T K x_+=f(.) x_+$$\n\n$$\\frac{1}{n_-}\\sum_{i \\in I_-}f(x_l)=\\frac{1}{n_-}\\sum_{i \\in I_-}\\sum_{l=1}^n\\alpha_l k(x_l,x_i)= \\sum_{l=1}^n\\alpha_l x_l\\frac{1}{n_-}\\sum_{i \\in I_-}x_j=\\alpha^T K x_-=f(.) x_-$$\n\n\n$$J(f)=1-(f(.) x_+-f(.) x_-)+ \\lambda f(.)^T f(.)$$\n\n\n\\begin{align*}\n\\nabla_{f(.)} J&=\\frac{\\partial}{\\partial f(.)}[1-(f(.) x_+-f(.) x_-+ \\lambda f(.)^T f(.)]=-[x^T_+-x^T_-]+ \\lambda \\frac{\\partial}{\\partial\\alpha}\\langle f(.),f(.)\\rangle\\\\\n&=-[x^T_+-x^T_-]+ 2\\lambda f(.)\\overset{set}{=}0\\\\\n\\end{align*}\n\n$$f^\\star(x)=(2\\lambda)^{-1} [x^T_+-x^T_-]$$\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "93c9f846dbf7ec8fabba31f935e040f1bc142077", "size": 10570, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "static/stat671/hw/hw4_stat671.tex", "max_stars_repo_name": "UrbanStudy/stat2019_website", "max_stars_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-29T12:51:19.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T12:51:19.000Z", "max_issues_repo_path": "static/stat671/hw/hw4_stat671.tex", "max_issues_repo_name": "UrbanStudy/stat2019_website", "max_issues_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "static/stat671/hw/hw4_stat671.tex", "max_forks_repo_name": "UrbanStudy/stat2019_website", "max_forks_repo_head_hexsha": "9d41d5caf4ece4c62bf0c301eb8c90429b17ce7d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.1572052402, "max_line_length": 445, "alphanum_fraction": 0.6452223273, "num_tokens": 4273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6757646010190477, "lm_q1q2_score": 0.41063726911888604}}
{"text": "\\chapter{M/EEG modelling and statistics}\n\\label{ch:eeg_stats}\nAfter projection to 2D- or a 3D-space (source reconstruction), the\ndata is in voxel-space and ready to be analysed. There are several\nways how one can proceed. In this chapter, we will focus on analyzing\nepoched time-series data. These can be event-related responses (ERPs),\nevent-related fields (ERFs) or single trials (M/EEG). \n\nIn the following, we will go through the various stages of modelling\nusing typical examples to illustrate the procedures.\n\n\\section{Preliminary remarks}\nAll analyses can be done using either the graphical user interface\n(GUI) or a batch system (i.e. using scripts in the SPM2-fashion,\ns.~below). The GUI has the advantage that one doesn't need\nmatlab-knowledge to analyse data. The batch system has the\nadvantage that it is a fast and efficient way of entering model and\ndata. Its disadvantage is that some Matlab-Knowledge is\nrequired. However, with this distribution, we provide some template\nscripts to analyse (typical) data in batch mode. We assume that with slight\nmodifications these scripts can be used for most analyses.\n\n\\section{How epoched time-series are analysed in SPM}\nAfter preprocessing the data (i.e.~epoching, filtering, etc...) and\nprojection to voxel-space, we have discretely sampled versions of\ncontinuous fields \\cite{kiebel_spm_eeg1}. These data can be analysed\nwith a mass-univariate approach using results from Random Field theory\n(RFT) to adjust p-values for multiple comparisons \\cite{kjw_hbf2}. The\nmodel used at each voxel is a general linear model\n\\cite{kiebel_spm_eeg2}. Typically one wants to analyse\nmultiple subjects' data acquired under multiple conditions. Given that\neach evoked-response has up to hundreds of time points, this is an\nawful lot of data at each voxel. The ideal way to analyse these data\nwould be to specify a single hierarchical model (1st level: within-subject,\n2nd level: over subjects) and estimate its parameters. However, this\nis computationally not feasible because of the length of the data\nvector at each voxel. Fortunately, such a 2-level model can usually be\nsplit up into two models: The 1st level and the 2nd level model. The\ninput data to the 2nd model are contrasts of the 1st level model\n\\cite{kiebel_spm_eeg2}. In all cases considered in this chapter, this\n2-stage procedure \ngives exactly the same results as the 2-level model. The reason for\nthis is that we are not really \\textit{modelling} the data at the 1st\nlevel, but simply forming weighted sums of the data, over time. For\nexample, if we are interested in the N170 component, one could average\nthe data from 150 to 190 milliseconds. This is exactly the approach\nused in conventional ERP analysis. This approach is not a model,\nbecause simply taking sums corresponds to using an identity matrix as\ndesign matrix. This procedure leaves no degrees of freedom for error\nestimation.\\\\\n\nIn summary, the SPM-approach is to form, at each voxel, weighted sums of\nthe data, over time, at the 1st level. We refer to these weighted sums\nas contrast images. These form the input to the 2nd level, where\none usually tests for differences betwen conditions or between groups\n(s.~below). The second level models are usually the same as the ones\none would use for functional magnetic resonance imaging (fMRI). Importantly,\nthese 2nd level models have enough degrees of freedom to estimate the\nerror, i.e.~statistics can be computed.\\\\\n\nThe output of such a 2nd level analysis is a\nvoxel-volume (or map), where each voxel contains one statistical\nvalue. The associated p-value is adjusted for multiple\ncomparisons \\cite{kjw_hbf2}. This adjustment is important, because there are many\nother voxels or channels. One (disadvantageous) alternative to\nadjustment is to consider only pre-selected channels or averages over\nchannels. This is why the adjustment is especially important for\nhigh-density measurements, because there are many channels to\nselect from. We believe that it is generally too subjective\nto select channels for analysis a-priori. We see the\nGFT-adjustment as a good way of looking at the whole data without any\nprior selection. This has been already demonstrated for EEG data (in\nanother context) by \\cite{james_rft}.\n\n\\section{1st level}\nAt the 1st level, we select periods or time points in\nperi-stimulus time that we would like to analyse. Critically, this\nchoice must be made a-priori by you. The alternative would be to not\ntreat peri-stimulus time as a factor, but as a dimension of a Random\nField approach. This alternative approach is often used in\ntime-frequency analysis of induced and evoked oscillations, where it\nseems sometimes difficult to specifiy areas of interest on the\ntime-frequency plane a-priori \\cite{james_rft}. \n\nIn the present approach, time is a factor, and\nyou have to form weighted-sums over peri-stimulus time to provide\ninput to the 2nd level. Of course, you don't need to constrain\nyourself to a single contrast around a specific peri-stimulus time,\nbut you can compute as many as you like. For example, to analyse\nmultiple aspects of an ERP, it is not uncommon to form averages around\nseveral time-points of an ERP. At the 2nd level, these can be either\nanalysed independently or within one model to make inferences about\ninteractions between conditions and peri-stimulus time.\n\nIn the follwing, we will go through model specification and\ncomputation of contrast images. This guide is not written as a\ntutorial (i.e.~detailed instructions for a given data set), but\ndescribes each design option and hopefully provides deeper background\nknowledge.\n\n\\subsection{The aim}\nThe aim of the 1st level is to compute contrast images that provide\nthe input to the 2nd level. We will describe this using the example of\n2D-data, i.e.~data that has not been source reconstructed but, for\neach peri-stimulus time point, has been projected to a 2D-plane\n(s.~chapter \\ref{ch:eeg_source}).\n\n\\subsection{Start}\nStart SPM by the command \\textit{'spm eeg'} from the matlab command\nline. Press the \\textit{EEG/MEG} button. Your first choice is to\neither specify the model design or the input data. One always starts\nwith the design. Currently, there are two design options: (i)\n\\textit{all options} and (ii) \\textit{ERP/ERF}. The latter option is a\nshortcut to quickly input an evoked responses study. We will first\ndescribe \\textit{all options} and then treat the \\textit{ERP/ERF}\noption as a special case.\n\n\\subsection{All options} \nYou first have to answer the question whether\nthis is a 1st level design. This determines whether SPM expects to\nmodel peri-stimulus time as a factor. Also, if one models first-level\ndata, SPM will ask next for \\textbf{one} M/EEG-matfile before the\ndata was projected to voxel-space. The reason for this is that the voxel-images\nlost important information during the conversion. For example, all timing\ninformation were lost. With the nifti-images only, SPM doesn't\nknow the peri-stimulus time of each data point. However, this\ninformation is critical as soon as you try to specify (later on)\nlinear weights in terms of peri-stimulus time. So, when you select an\nM/EEG file, SPM will read timing information from this file. For an\nERP-study, the M/EEG-file of the average (ERP) is a good choice.\n\n\\subsection{How many factors?}\nThis question starts off the design specification proper. SPM needs to\nknow the number of factors which you want to model. At the 1st level,\nthere are typically only factors \\textit{peri-stimulus time} and\n\\textit{condition}. If you like, you can further subdivide the\ncondition-factor in its components. For instance, if you have a 2x2\nfactorial design, you may want to specify 3 factors: \\textit{factor1},\n\\textit{factor2} and  \\textit{peri-stimulus time}. \n\n\\subsection{Factor names and \\# of levels for factors}\nFor each factor, you now input its name, e.g.~condition, and enter the\nnumber of levels. For instance, if you have 2 conditions, you enter\n2. For peri-stimulus time, you enter the number of time points in your\nevoked responses. Important: You should call the peri-stimulus time\nfactor  'time'. For the number of levels for this special factor, SPM\ndefaults to the correct number of peri-stimulus time points. (Note\nthat it is currently not possible to model only a subset of time points.)\n\n\\subsection{Select design component}\nYou have the choice between \\textit{Identity} and\n\\textit{Constant}. Your selected design components are combined (by\nKronecker tensor product) to form the 1st level design matrix. This\nhas also been described in \\cite{kiebel_spm_eeg2}. For the 1st level,\nyou simply choose for all factors \\textit{identity}. This completes\nmodel specification.\n\n\\subsection{Data}\nFor selecting data, press the \\textit{EEG/MEG} button again. After\nselecting the \\textit{SPM.mat} file, you are asked to select data for\neach factor. The order in which you input data  depends on the order\nof how you named the individual factors. We recommend that you make\nthe \\textit{peri-stimulus time} factor the last factor. After\nprojection to voxel-space, the data are stored as 4-dimensional files\nwith the third dimension $z = 1$. If you want to input all\nperi-stimulus time points for a given file, you have to select all\nvolumes along the 4th dimension. This is done by setting the number\n'1' in the SPM-file selector (below the 'Filt' line) to '1:101', where\n'101' is the total number of peri-stimulus time points. Of course, you\nhave to replace '101' by the number of time points of your\ndata (or by any natural number bigger than that). This choice will make\nall time points selectable. Then right-click over the file \nnames and \\textit{Select all}. Press \\textit{done} to confirm your\nchoice. This completes data selection.\n\n\\subsection{'Estimation'}\nAlthough there is actually nothing to estimate, clicking the\n\\textit{Estimation} button will prepare some internal structure for\nthe results section. We kept this (otherwise redundant) estimation step to\nprovide for greater similiarity with other analyses using SPM.\n\n\\subsection{Results}\nAfter clicking on \\textit{Results}, choose the appropriate\n\\textit{SPM} and the contrast manager will pop up. In contrast to a usual\nSPM study, we don't use the contrast manager to compute\nstatistics, but contrasts only!\n\nClick \\textit{Define new contrast...} and enter a name for your\ncontrast. Then note a (new) button called \\textit{components} which is\nonly visible for M/EEG models. Clicking this button opens the contrast\ncomponents manager. This is simply a tool that exploits the knowledge\nabout the factors which you have specified earlier. Knowing the\nfactors and their levels makes it easy to split up a (long) contrast\nweight vector into a few components. For each contrast weight vector,\neach factor contributes one component. By using the Kronecker tensor\nproduct, these components can be combined into the resulting contrast\nweight vector. This is not only time-saving, but many people tend to\nfind this approach more intuitive than the usual approach of figuring\nour the contrasts yourself. For instance, if you have specified\ntwo conditions, you might be interested in their difference. Enter a\n$[-1 \\; \\; 1]$ as contrast component. For the \\textit{time} factor,\ninstead of entering one number for each time point, better click on \nthe \\textit{Generate} button. Click on the 'Time' button and specify\na rectangular averaging window by providing the start and end of this\nwindow (in milliseconds). Press \\textit{Compute}. You can see now in\nthe contrast manager window that your contrast weights have been\ncomputed and are displayed above the identity (design)\nmatrix. You can also specify the contrast weights as usual in the\ncontrast box, but this would require to enter several hundreds to\nthousands of numbers. Press \\textit{ok} to proceed and compute the\ncontrast.\n\n\\subsection{Display}\nYou can display the resulting contrast image by using the\n\\textit{Display} button.\n\n\\subsection{ERP/ERF}\nYou can shortcut some of the question and especially the data\nselection by choosing the \\textit{ERP/ERF} option (instead of\n\\textit{all options} when specifying a design. This options assumes\nthat you have two factors, \\textit{condition} and \\textit{time}. There\nare less questions during design specification. When selecting data,\nyou don't need to select all time point, but only the first! SPM will\nassume that you want to select all time points of the selected\nfile. Using this option will otherwise result in the same model\nas described above.\n\n\\subsection{Multiple subjects}\nFor each of your subjects, you perform these operations in a separate\n1st-level analysis. For each subject, you want to compute the same\ncontrasts and use them as input to a model, where subjects is the\nrepetition factor. \n\n\\section{2nd level models}\nFor 2nd level modelling, you can use different ways to specify a\nmodel. There is \\textit{Basic models} which was primarily developed for\nPET/fMRI but is equally appropriate for EEG/MEG data. These are\nsuited best when the model is simple (like a 1-sample or 2-sample\nt-test). In our experience, most EEG/MEG models fall into this\ncategory of simple models. If models are more complicated, like, e.g.,\ntwo groups with multiple subjects/conditions, we recommend using the\n\\textit{EEG/MEG} models.\n\n\\subsection{All options}\nAs above, go for \\textit{All options}. This time, press 'no' for the\nquestion 'Is this a first-level design'. \n\n\\subsection{Factors}\nThis includes all factors, even repetition factors. For example, at\nthe 2nd level a 2x2 factorial design has 3 factors: \\textit{subject},\n\\textit{factor1} and \\textit{factor2}.\n \n\\subsection{Design partitions and design components}\nThe way this modelling device constructs a design matrix is by using the\nKronecker tensor product on the hierarchy of specified design\ncomponents. However, some/many designs can't be constructed in this\nway. For example, the design matrix of a paired two sample-test\nconsists of two merged partitions, each of which is a Kronecker tensor\nproduct of design components. For each partition, the factors and the\nlevels are the same. The difference is in the choice of the design\ncomponents for each factor under each partition. For example, for a\npaired two-sample-test, one has 2 factors (subjects and conditions)\nand 2 design partitions. For the 1st partition, choose\n\\textit{Constant} for subjects and \\textit{Identity} for\nconditions. For the 2nd partition, it's the other way around,\ni.e.~\\textit{Identity} for subjects and \\textit{Constant} for\nconditions.\n\n\\subsection{Covariance components}\nSpecification of the covariance components determines the error\nmodel \\cite{daniel_hbf2}. For each factor, there are two questions:\n(i) Identical variance for\nfactor $xxx$, and (ii) Independence for factor $xxx$. SPM constructs all the\nvariance components from your answers. The first question pertains to\nthe assumption whether each level of this factor has identical\nvariance. The second questions asks whether the different levels for a\ngiven factor are correlated. Some examples: For a repetition factor\nlike subjects, you should always answer both questions with yes. For a\ngroup factor, one would assume that the levels of this factor (the\ngroups) have unequal variance structures, but are uncorrelated (i.e.,\n(i) no, (ii) yes). For a condition factor, the choice is up to\nyou. A very restrained model would follow from using (i) yes (ii)\nyes, whereas the most liberal model is given by (i) no (ii) no. \n\n\\subsection{Data}\nFor each combination of factors, SPM asks you for the filenames of the\ndata. Sometimes, this process can be more convient for you, when you\nhave specified the factors in a specific order. For example, if you\nhave two factors \\textit{subjects} and \\textit{condition}, the order\n(i) subjects, (ii) condition will ask for all images for each\nsubject. This is convienient if you have stored the contrast images\nin their individual subject folder. This is the case, if you\nhave computed 1st level contrasts following the approach described\nabove. However, if, in an intermediate step, you have saved contrasts\nin condition-specific folders, the alternative order ((i) condition, (ii)\nsubjects) is more appropriate.\n\n\\subsection{Estimation and Results}\nThe estimation follows the usual scheme, i.e.~for a classical\nestimation procedure we use exactly the same routine as for PET/fMRI\ndata (i.e.~maximum-likelihood estimators for the parameters and Restricted \nMaximum Likelihood for estimation of the variance parameters).\n\nFor specification of contrasts, you have the option to specify\ncontrasts component-wise. This can be useful for complex designs, when\nit's no longer easy to work out the interaction contrasts.\n\nFor 2D data the statistical map is displayed instead of the usual\nglass brain. You can invoke all the usual functions that are also\navailable for fMRI/PET data. An additional option is \\textit{channels}\nwhich let you visualise to which voxel each channel maps. You can\nselect this option by right-clicking the button on the statistical \nmap background. SPM asks you then for one of the original M/EEG-mat\nfiles to read the channel mapping.\n\n", "meta": {"hexsha": "634a360ae097d75f09162a75fcaa0d529a826ca8", "size": 17168, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lib/spm5/man/meeg/eeg_stats.tex", "max_stars_repo_name": "awangga/braindecoding", "max_stars_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/spm5/man/meeg/eeg_stats.tex", "max_issues_repo_name": "awangga/braindecoding", "max_issues_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-10-13T13:34:45.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-13T14:23:51.000Z", "max_forks_repo_path": "lib/BDTB-1.2.2/open/spm5/man/meeg/eeg_stats.tex", "max_forks_repo_name": "awangga/braindecoding", "max_forks_repo_head_hexsha": "97128a8346263c81c9ccd606cfa54b35dacd6ca1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.3291139241, "max_line_length": 81, "alphanum_fraction": 0.7940936626, "num_tokens": 4119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788308, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.41063726745204304}}
{"text": "\\label{sec:Res}\n\\section*{Results}\n\nWe partitioned variance due to the species effect, i.e. the part of the variance explained by the species of individuals (see~\\autoref{fig:aov}). Depending on the trait, the species effect could explain between 27\\% up to 75\\% of the variability of our data. While species effect can explain over 75\\% of the variability in wood density, it only explains less than 30\\% of the variability in AGR.\n\nTo test how growth was affected by individual traits we made growth mixed-model for each one of them (see~\\autoref{tab:seltraits} for traits and~\\autoref{tab:growth_mod} for models) as predictors of the AGR. Based on the adapted R-squared for mixed-models~\\citep{nakagawa_general_2013}, we selected the best model for each trait (see~\\autoref{tab:growth_mod}).\n\nFor all traits models with distance measures were better than model with only species average term. But for wood density and SLA, hierarchical distances model performed as well as indvidual's trait models. By adding a distance term to the species average term model, we gained in predictive power, shown by the increase of condition R-squared between models.\n\nFor bark thickness the absolute distance model improved the conditional R-squared by 0.025 compared to the model with only species average trait. For wood density hierarchical distance model improved the R-squared by 0.056 (10\\% of total $\\text{R}^2$) compared to species average model. While for SLA hierarchical distance model only increased $\\text{R}^2$ by 0.004. For laminar chlorophyll and toughness the hierarchical distance models gained 0.001 of R-squared compared to the species average term models.\n\nUsing the best models (in bold in~\\autoref{tab:growth_mod}) that included a distance term we predicted AGR for a range of individual trait values and species average values. To underline the interplay between intra- and inter-specific variabilities we plotted the centered species average trait value vs. the hierarchical distance of indivdual's (see~\\autoref{fig:simul}). We obtained AGR \"landscapes\", that show the pattern of variations of variation as a function of individual and species trait variation. Depending on the trait we had different patterns, for SLA and wood density we had similar patterns: the larger the species average trait value, the lower the AGR, and the higher the individual hierarchical distance the lower the AGR. For example, an increase of $10\\text{cm}^2.\\text{g}^{-1}$ in SLA species average decreases the growth by $0.035\\text{mm}.\\text{yr}^{-1}$ while the same increase in hierarchical distance decreases the AGR by $0.02\\text{mm}.\\text{yr}^{-1}$. For laminar chlorophyll content we observe that increasing species average as well as increasing hierarchical distance lead to increasing AGR. While for leaf toughness, species average and hierarchical AGR gradients are opposed: an increase in species average decreases AGR, and an increase individual hierarchical distance increases AGR. Because the best model for bark thickness was an absolute distance model, we observe the symmetrical patterns of AGR variations for change in hierarchical distance: globally, the higher the hierarchical distance the lower the AGR, while the higher the species average, the lower the growth.\n\\begin{table*}[!pt]\n\t\\begin{center}\n\t\t\\begin{tabular}{llcccc}\n\t\t  \\hline\n\t\t Trait Name & Model Type & Marginal $\\text{R}^2$ & Cond. $\\text{R}^2$ & AIC & logLikelihood \\\\ \n\t\t  \\hline\n\t\tBark Thickness & Species Avg. & 0.104 & 0.472 & -2790 & 1407 \\\\ \n\t\t            & Hierarchical Distance & 0.106 & 0.471 & -2794 & 1410 \\\\ \n\t\t            & \\textbf{Absolute Distance} & 0.100 & \\textbf{0.497} & -2860 & \\textbf{1443} \\\\ \n\t\t            & Individual Trait & 0.102 & 0.470 & -2792 & 1408 \\\\\n\t\t  \\cline{2-6}\n\t\t  Wood Density & Species Avg. & 0.142 & 0.474 & -1838 & 931 \\\\ \n\t\t               & \\textbf{Hierarchical Distance} & 0.139 & \\textbf{0.530} & -1910 & \\textbf{968} \\\\ \n\t\t               & Absolute Distance & 0.140 & 0.529 & -1906 & 966 \\\\ \n\t\t               & \\textbf{Individual Trait} & 0.137 & \\textbf{0.530} & -1911 & \\textbf{968} \\\\\n\t\t  \\cline{2-6}\n\t\t  SLA & Species Avg. & 0.094 & 0.485 & -3081 & 1553 \\\\ \n\t\t      & \\textbf{Hierarchical Distance} & 0.095 & \\textbf{0.489} & -3092 & \\textbf{1559} \\\\ \n\t\t      & Absolute Distance & 0.096 & 0.459 & -3000 & 1513 \\\\ \n\t\t      & \\textbf{Individual Trait} & 0.096 & \\textbf{0.490} & -3093 & \\textbf{1559} \\\\ \n\t\t  \\cline{2-6}\n\t\t  Chloro. Content & Species Avg. & 0.092 & 0.487 & -3143 & 1583 \\\\ \n\t\t                  & \\textbf{Hierarchical Distance} & 0.093 & \\textbf{0.488} & -3145 & \\textbf{1586} \\\\ \n\t\t                  & Absolute Distance & 0.092 & 0.486 & -3143 & 1584 \\\\ \n\t\t                  & Individual Trait & 0.100 & 0.469 & -3075 & 1550 \\\\\n\t\t  \\cline{2-6}\t\n\t\t  Toughness & Species Avg. & 0.088 & 0.478 & -3136 & 1580 \\\\ \n\t\t            & \\textbf{Hierarchical Distance} & 0.088 & \\textbf{0.479} & -3135 & \\textbf{1581} \\\\ \n\t\t            & Absolute Distance & 0.088 & 0.478 & -3134 & 1580 \\\\ \n\t\t            & Individual Trait & 0.088 & 0.479 & -3134 & 1579 \\\\\n\t\t  \\cline{2-6}\n\t\t  All Traits & Species Avg. & 0.133 & 0.524 & -1739 & 885 \\\\ \n\t\t             & \\textbf{Hierarchical Distance} & 0.143 & \\textbf{0.532} & -1761 & \\textbf{901} \\\\\n\t\t             & Absolute Distance & 0.138 & 0.524 & -1743 & 892 \\\\\n\t\t             & Individual Trait & 0.138 & 0.528 & -1766 & 899 \\\\ \n\t\t   \\hline\n\t\t\\end{tabular}\n\t\t\\caption{\\textbf{Summary table of tested trait-specific growth models.} We modeled radial growth using linear-mixed model, all models contained plot and species random effects, as well as DBH and $\\log\\text{DBH}$ terms to take growth curve shape into account~\\citep{herault_functional_2011}. Then, for each trait, we added a fixed effect that contained different terms: \\textbf{Species Avg.}, only the species average trait value; \\textbf{Hierarchical Distance}, the species average plus the difference between individual trait and species average; \\textbf{Absolute Distance}, the species average plus the absolute difference between individual trait and species average; \\textbf{Individual Trait}, only the trait value of individuals. Models indicated in \\textbf{bold} are those with the highest logarithmic likelihood per trait. Not all traits had been measured on each tree, giving a different number of comprised tree for each model, thus the likelihood of models for each trait are not comparable.}\n\t\t\\label{tab:growth_mod}\n\t\\end{center}\n\\end{table*}\n\\begin{figure*}[!tb]\n\t\\centering\n\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\\includegraphics[scale=0.75]{figures/Plots_Map_2015-05-26.pdf}\n\t\t\\caption{}\n\t\t\\label{fig:map}\n\t\\end{subfigure}\n\t\\begin{subfigure}[c]{0.5\\textwidth}\n\t\t\\includegraphics[scale=0.7]{figures/Aov_Var_Traits_2015-05-25.pdf}\n\t\t\\caption{}\n\t\t\\label{fig:aov}\n\t\\end{subfigure}\n\t\\caption{\\textbf{(a) Plots map.} 9 1-ha plots were used, spread in French Guiana, two plots were surveyed both in Nouragues and in Paracou (see~\\citealp{baraloto_decoupled_2010}) \\textbf{(b) Explained variance by species effect in ANOVAs.} Dot-plot of explained variance in ANOVA by the species effect for traits and AGR. \\textbf{Chloro. Content}: Laminar Chlorophyll Content, \\textbf{AGR}: Annual Growth Rate (in diameter).}\n\t\\label{fig:gen}\n\\end{figure*}\n\n\\begin{figure*}[!ptb]\n\t\\centering\n\t\\includegraphics{figures/Sel_Traits_Simul_AGR_2015-05-30.pdf}\n\t\\caption{\\textbf{Predictions of AGR depending on intra-specific and inter-specific variabilities in traits.} Surface plots of predicted AGR of simulated range of data: X-axis, centered species average trait (species average trait minus mean of all species average trait); Y-axis, individual distance to species average trait. Black lines are equal-AGR lines over the surface, i.e. on those line each point has the same AGR value, each line mark a $5e^{-3}\\text{mm}.\\text{yr}^{-1}$ break. For details on traits see~\\autoref{tab:seltraits}.}\n\t\\label{fig:simul}\n\\end{figure*}", "meta": {"hexsha": "95ef1410e66601b8515ad3b5dc9b24cb17a96fab", "size": 7959, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "3-Results.tex", "max_stars_repo_name": "Rekyt/report-ecofog-2015", "max_stars_repo_head_hexsha": "145863f6c43200f3348ec5a82ca750eb348145ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "3-Results.tex", "max_issues_repo_name": "Rekyt/report-ecofog-2015", "max_issues_repo_head_hexsha": "145863f6c43200f3348ec5a82ca750eb348145ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "3-Results.tex", "max_forks_repo_name": "Rekyt/report-ecofog-2015", "max_forks_repo_head_hexsha": "145863f6c43200f3348ec5a82ca750eb348145ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.12, "max_line_length": 1611, "alphanum_fraction": 0.7144113582, "num_tokens": 2276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190477, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4106372595160938}}
{"text": "%\\documentstyle[11pt,epsfig,psfig,times]{article} \n\n%\\textheight 9in\n%\\topmargin 1in\n%\\footheight 0.5in\n%\\textwidth 6.8in\n%\\oddsidemargin -0.2in\n\n%\\usepackage{latex8}\n%\\usepackage{psfig}\n%\\usepackage{epsfig}\n%\\usepackage{latexsym}\n%\\usepackage{amssymb}\n\n%\\begin{document}\n\nLet ${\\tt preset}(t)$ and ${\\tt postset}(t)$ denote the preset and postset of\na transition $t$.  ${\\tt preset}(p)$ and ${\\tt postset}(p)$ are similarly \ndefined for a place $p$.   \n\n\n\\subsection{Transform 0: Merge Parallel Places}\n\\label{reduce0}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform0-a,width=27.5mm} \\hspace{5mm} &\n\\psfig{figure=xform0-b,width=22.5mm} \\\\\n(a) \\hspace{6mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform0}Transform 0. Merge parallel places.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform0}(a) shows two places in parallel.  They can be\nmerged into a single place as shown in Figure~\\ref{xform0}(b) if the following requirements hold:\n\\begin{itemize}\n\\item {\\tt preset(p1) = preset(p2)}.  \n\\item {\\tt postset(p1) = postset(p2)}.  \n\\item {\\tt marking(p1) = marking(p2)}\n\\end{itemize}\n\n%\\clearpage\n\n\\subsection{Transform 1: Remove a Place in a Self Loop}\n\\label{reduce}\n\n\\begin{figure}[!tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform1-a,width=31.25mm} \\hspace{5mm} &\n\\psfig{figure=xform1-b,width=35mm} \\\\\n(a) \\hspace{6mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform1}Transform 1. Remove a self loop on a\n    transition.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform1}(a) shows a transition $t$ with a self loop, where a \nplace $p$ is in ${\\tt preset}(t)$ and ${\\tt postset}(t)$, and is marked.\nThe transformation removes $p$ and its incoming and outgoing flow relations.\nThen, the upper bound delay of the flow relations entering $t$ are \nmodified such that the upper bound is the maximum of the current max\nand that of the flow relation between $p$ and $t$.\nThe new TPN is shown in Figure~\\ref{xform1}(b).  If there is only the\nsame one place in the preset and postset of $t$, this place is not\nremoved as shown in Figure~\\ref{bad}(c). \n\n%\\clearpage \n\n\\subsection{Transform 2: (BAD TRANSFORM) Remove a Transition in a Loop}\n\\label{reduce1}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform2-a,width=27.5mm} \\hspace{5mm} &\n\\psfig{figure=xform2-b,width=22.5mm} \\\\\n(a) \\hspace{6mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform2}Transform 2. Remove a transition in a loop.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform2}(a) shows a loop formed by a transition $t_3$, where the size\nof the preset and postset of $t_3$ is 1. The semantics\nof this TPN can be interpreted as transition $t_4$ can fire after the\ninfinite number of times of firings of transition $t_2$ and $t_3$.\nIf ${\\tt u}(p_1) + {\\tt u}(p_2) > 0$, by changing ${\\tt u}(p2)$ to $\\infty$, \nthe timing of $t_4$ is preserved.  The new TPN after removing transition \n$t_3$ and its incoming and outgoing flow relations is shown in \nFigure~\\ref{xform2}(b).\n\nThe code implemented the above transformation is in the function call \n{\\em xform\\_1} in postproc.cc.  \n\n%\\clearpage\n\n\\subsection{Transform 3: Remove a Transition With a Single Place in the Postset}\n\\label{reduce2}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform3a-a,width=35mm} \\hspace{10mm} &\n\\psfig{figure=xform3a-b,width=50mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform3a}Transform 3a. Remove the transition with\n    the size of postset of 1.}}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform3b-a,width=37.5mm} \\hspace{10mm} &\n\\psfig{figure=xform3b-b,width=62.5mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform3b}Transform 3b. The transformation in\n    Figure~\\ref{xform3a} without the restriction that places in preset(t)\n    have postset sizes of 1.}}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform3c-a,width=35mm} \\hspace{10mm} &\n\\psfig{figure=xform3c-b,width=57.5mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform3c}Transform 3c.  The transformation in\n    Figure~\\ref{xform3a} without the restriction that the place in\n    postset(t) have preset size of 1.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform3a}(a) shows a transition $t$ with only one place in its\npostset.  Suppose $t$ is removed.  The incoming and outgoing flow relations\nof $t$ are also removed.  Then the place in ${\\tt postset}(t)$ is \nmerged with those in ${\\tt preset}(t)$.  The delay bounds of the place in \n${\\tt postset}(t)$ are added to the delay bounds of the places in \n${\\tt preset}(t)$, as shown in Figure~\\ref{xform3a}(b).\nThe transformation in Figure~\\ref{xform3a}  has the restrictions that\nfor each place $p$ in\n${\\tt preset}(t)$, the size of ${\\tt postset}(p)$ equals 1 and  for the\nplace $p$ in ${\\tt postset}(t)$, the size of ${\\tt preset}(p)$ equals\n1.  Figures \\ref{xform3b} and \\ref{xform3c} show the same\ntransformations without each restriction respectively.\n\nFigure~\\ref{bad}(a) and (b) show where these above transformations\ncannot be applied.\n\nAll places in preset(t) must have same marking (all marked or all\nunmarked) and place in postset(t) can be marked.  If either preset(t)\nor postset(t) is marked, new combined places are marked.\n\n%\\clearpage\n\n\\subsection{Transform 4: Remove A Transition With A Single Place in the Preset}\n\\label{xform-3}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform4a-a,width=40mm} \\hspace{10mm} &\n\\psfig{figure=xform4a-b,width=41.25mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform4a}Transform 4a. Remove a transition with\n    preset of size 1.}}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform4b-a,width=37.5mm} \\hspace{10mm} &\n\\psfig{figure=xform4b-b,width=40mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform4b}Transform 4b. Transformation in Figure~\\ref{xform4a}\n    without restriction that the places in preset(t) have a preset of\n    size 0.}}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform4c-a,width=40mm} \\hspace{10mm} &\n\\psfig{figure=xform4c-b,width=45mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform4c}Transform 4c. Transformation in Figure~\\ref{xform4a}\n    without restriction that the places in postset(t) each have a preset of\n    size 1.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform4a}(a) shows a transition $t$ with only one place in its\npreset.  Suppose $t$ is removed.  The incoming and outgoing flow relations\nof $t$ are also removed.  The the place in ${\\tt preset}(t)$ is \nmerged with those in ${\\tt postset}(t)$.  The delay bounds of the place in \n${\\tt preset}(t)$ are added to the delay bounds of the places in \n${\\tt postset}(t)$, as shown in Figure~\\ref{xform4a}(b).\nThe transformation in Figure~\\ref{xform4a} as the restrictions that\nfor the place $p$ in\n${\\tt preset}(t)$, the size of ${\\tt postset}(p)$ equals 1 and for each\nplace $p$ in ${\\tt postset}(t)$, the size of ${\\tt preset}(p)$ equals\n1, too.  Figures~\\ref{xform4b} and \\ref{xform4c} demonstrate the same\ntransform where these restrictions are loosened.\n\nThe above transformations are also \nrestricted by the conditions shown in Figure~\\ref{bad}(a) and (b).\n\nAll places in postset(t) must have same marking (all marked or all\nunmarked) and place in preset(t) can be marked.  If anything is\nmarked, new combined places are marked.\n\n%\\clearpage\n\n\\subsection{Transform 5: Merge Transitions With the same preset and postset}\n\\label{merge-1}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform5a-a,width=58.75mm} \\hspace{10mm} &\n\\psfig{figure=xform5a-b,width=48.75mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform5a}Transform 5a. Merge transitions with the same\n    preset and postset}}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform5b-a,width=48.75mm} \\hspace{10mm} &\n\\psfig{figure=xform5b-b,width=46.25mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform5b}Transform 5b. Merge transitions where the\n    places in their preset and postset have the same preset and\n    postset.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform5a}(a) shows two transitions $t_6$ and $t_7$ with \nthe same preset and postset.  Those two transitions can be merged together\nwithout affecting the behavior on transitions $t_{10}$, $t_{11}$, and \n$t_{12}$ as shown in Figure~\\ref{xform5a}(b).  Since no places are\nbeing removed, no marking restrictions apply.\n\n%Note: Transform 5b is not turned on by default.  It was found to have\n%minimal effect except for in a few examples and was computationaly\n%intensive.  Additionally, the correctness of this transformation in\n%its current form is in question.\n\nAnother case is where the two transitions do not have the same preset\nand postset, but the places in their preset and postset have the same\npreset and postset as shown in Figure~\\ref{xform5b}(a).  The two\ntransitions can still be merged along with the places in their preset\nand postset. This transformation is depicted in Figure~\\ref{xform5b}.\nIn order for the transformation to be applied certain timing\nconstraints must be satisfied.  Specifically, arcs between the places\nin the postset to transitions in the postsets of the postset must have\nthe same timing bounds.  Furthermore, the place to transition arcs\nfeeding the transitions to be merged must have the same timing\nconstraints.\n\n%There is also requirement on this transformation that the places in\n%the preset of the merged two transitions must have same postset\n%excluding the merging transitions, and the places in the postset of\n%the merged two transitions must have same preset excluding the merging\n%transitions.  For example, in Figure~\\ref{xform5b}(a), the places in\n%the preset of $t_3$ and $t_4$ are $p_1$ and $p_2$.  The postset of\n%$p_1$ and $p_2$ contains only $t_2$, excluding $t_3$ and $t_4$.  The\n%places in the postset of $t_3$ and $t_4$ are $p_3$ and $p_4$.  The\n%preset of $p_3$ and $p_4$ contains only $t_5$, excluding $t_3$ and\n%$t_4$.\n\n%\\clearpage\n\n\\subsection{Transform 6: Merge Transitions With the same preset}\n\\label{merge-2}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform6-a,width=57.5mm} \\hspace{5mm} &\n\\psfig{figure=xform6-b,width=50mm} \\\\\n(a) \\hspace{5mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform6}Transform 6. Merge transitions with the same\n    preset.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform6}(a) shows two transitions $t_1$ and $t_2$ with \nthe same preset.  It is also required that the places in the postset of \n$t_1$ and $t_2$ must have the same preset aside from the two\ntransitions being merged.  Additionally, there can only be one place\nin the postsets of t1 and t2.  Those two \ntransitions can be merged together without affecting the behavior on \ntransitions $t_3$, $t_4$, and $t_5$ as shown in Figure~\\ref{xform6}(b).\n\nSince the places in the postset of the merging transitions will be\nmerged, they must have a consistent marking.  The newly merged place\nwill have the same marking as the places being merged.\n%\\clearpage\n\n\\subsection{Transform 7: Merge Transitions With the same postset}\n\\label{merge-3}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=xform7-a,width=51.25mm} \\hspace{10mm} &\n\\psfig{figure=xform7-b,width=51.25mm} \\\\\n(a) \\hspace{10mm} & (b)\n\\end{tabular}\n{\\caption{\\label{xform7}Transform 7. Merge transitions with the same\n    postset.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{xform7}(a) shows two transitions $t_1$ and $t_2$ with \nthe same postset.  It is also required that the places in the preset of \n$t_1$ and $t_2$ must have the same postset aside from $t_1$ and $t_2$.\nThose two \ntransitions can be merged together without affecting the behavior on \ntransitions $t_3$, $t_4$, and $t_5$ as shown in\nFigure~\\ref{xform7}(b).  Additionally, the transitions being merged\nmay each only have one place in their presets.  The places in the\npreset of the transitions\nbeing merged should have consistent markings.  The newly merged place\nin the transformed net should have the same marking as the places that\nare merged.\n\n\n\n%\\clearpage\n\n\\subsection{Illegal Transformations}\n\n\\begin{figure}[tbh]\n\\begin{center}\n\\begin{tabular}{cc}\n\\psfig{figure=bad-1,width=25mm} \\hspace{5mm} &\n\\psfig{figure=bad-2,width=32.5mm} \\\\\n(a) \\hspace{6mm} & (b) \\\\\n\\psfig{figure=bad-3,width=20mm} \\hspace{5mm} &\n\\psfig{figure=bad-4,width=12.5mm} \\\\\n(c) \\hspace{6mm} & (d)\n\\end{tabular}\n{\\caption{\\label{bad}Illegal transformations.}}\n\\end{center}\n\\end{figure}\n\nFigure~\\ref{bad} shows several illegal transformations. In Figure~\\ref{bad}(a),\nneither $t_1$ nor $t_2$ can be removed using transformations in \nsection~\\ref{reduce1} and \\ref{reduce2}.  \nThey may be merged by transformations insection~\\ref{merge-1}, \n\\ref{merge-2}, or \\ref{merge-3}.  In Figure~\\ref{bad}(b), $t_3$ cannot be\nremoved in that it is impossible to have two places connected without a\ntransition in between. Figure~\\ref{bad}(c) shows a stand-alone self loop which\nis not removed for some reason.  I think it can be removed if the wire of \nthat transition is not used in any levels.  Figure~\\ref{bad}(d) shows a\ndangling transition $t_2$.  It cannot be removed because safety failure\nmaybe hidden; otherwise.\n\n%\\clearpage\n\n\\subsection{To Do and Notes}\n\n\\begin{itemize}\n\\item Transforms 3d and 4d.  Same As 3a and 4a but with both\n  restrictions removed.\n\\end{itemize}\n\n%\\end{document}", "meta": {"hexsha": "32e93134b1497bcb0ec03c5f574e8f5d3dfb6c80", "size": 13574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/xform/xform.tex", "max_stars_repo_name": "MyersResearchGroup/ATACS", "max_stars_repo_head_hexsha": "d6eeec63fbc53794f0376592e7357ad08a7dddd1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2017-03-10T14:55:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-10T10:44:21.000Z", "max_issues_repo_path": "doc/xform/xform.tex", "max_issues_repo_name": "MyersResearchGroup/ATACS", "max_issues_repo_head_hexsha": "d6eeec63fbc53794f0376592e7357ad08a7dddd1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 77, "max_issues_repo_issues_event_min_datetime": "2016-11-07T08:44:57.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-11T03:19:13.000Z", "max_forks_repo_path": "doc/xform/xform.tex", "max_forks_repo_name": "MyersResearchGroup/ATACS", "max_forks_repo_head_hexsha": "d6eeec63fbc53794f0376592e7357ad08a7dddd1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-10T10:44:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-10T10:44:22.000Z", "avg_line_length": 34.9845360825, "max_line_length": 97, "alphanum_fraction": 0.7295565051, "num_tokens": 4359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4106372578492505}}
{"text": "% !TEX root = ../thesis.tex\n\n\n\\chapter{Theoretical Background}\n% \\label{cha:eva_theory}\nIn this chapter, I will present the theory behind evaporative cooling and the simulation of gas dynamics in a rarefied atomic gas.\n\nI will first explain the concept of evaporative cooling in an arbitrary power law potential, including the conditions that need to be reached to achieve efficient evaporation. In the second section, I will describe the general problem of a molecular dynamics simulation and the simulation method used in this work.\n\n\\section{Theory of Evaporative Cooling}\n% \\label{sec:evaporative_cooling_theory}\nEvaporative cooling is a method to reach temperatures below the recoil limit as well as high phase space densities, which is a requirement for the onset of Bose-Einstein condensation~\\cite{pethick_smith_2008}. The concept of evaporative cooling is illustrated in \\cref{fig:evaporative_cooling_sketch}. A gas of atoms with temperature $T_0$ is trapped in potential with depth $U_0$. In equilibrium, the speeds in the gas are distributed according to a Maxwell-Boltzmann distribution. If the potential depth is then lowered to $U'$, a portion of atoms with energies above $U'$ can leave the trap. The remaining atoms then thermalise to a lower temperature $T'$. \n\n\\vfill\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[clip, trim=0 4px 0 0]{Evap/EvaporationSketch1}\n    % \\input{TexContents/Figures/Evap/EvaporationSketch.pgf}\n    \\caption[Concept of evaporative cooling]{By selectively removing the hottest atoms from a gas, the remaining portion will have a lower temperature than before, after equilibrium is reached.}\n    \\label{fig:evaporative_cooling_sketch}\n\\end{figure}\n\\vfill\n\n% Many textbooks constrain themselves to a harmonic potential for a model of evaporative cooling\\insertcite{}. However, as we want to simulate a box potential, I will use a generalised power-law potential to derive basic scaling laws for the evaporation process.\n\n\\subsection{The Ideal Gas in a Power-Law-Potential}\nWe look at an ideal gas in a general power-law-potential\n%\n\\begin{equation*}\n    U(\\vec{r}) = U_x \\left| \\frac{x}{x_0} \\right|^{\\alpha_x} + U_y \\left| \\frac{y}{y_0} \\right|^{\\alpha_y} + U_z \\left| \\frac{z}{z_0} \\right|^{\\alpha_z}\n\\end{equation*}\nwhere $\\vec{r}^\\mathsf{T} = (x,y,z)$ is the spatial coordinate.\n%\nThe density of states in such a potential has been derived in \\cite{PhysRevA.35.4354}, but because there is a slight error in their derivation, making it incorrect for any odd $\\alpha_x$, $\\alpha_y$ or $\\alpha_z$, the complete and correct derivation is presented in \\cref{sec:appendix_dos}. The result is\n%\n\\begin{equation*} %\\label{eq:general_dos}\n    D(E) = \\left(\\frac{2m}{\\pi\\hbar^2}\\right)^\\frac{3}{2} \\frac{x_0 y_0 z_0}{U_x^{1/\\alpha_x} U_y^{1/\\alpha_y} U_z^{1/\\alpha_z}} \\frac{F(\\alpha_x,\\alpha_y,\\alpha_z)}{\\Gamma(\\xi)} \\times E^{\\xi - 1}\n\\end{equation*}\nwith the energy $E$,\n\\begin{equation*}\n    \\xi = \\frac{3}{2} + \\frac{1}{\\alpha_x} + \\frac{1}{\\alpha_y} + \\frac{1}{\\alpha_z} \\quad \\text{and} \\quad F(\\alpha_x, \\alpha_y, \\alpha_z) = \\prod_{i \\in \\{x,y,z\\}} \\Gamma\\!\\left(1 + \\frac{1}{\\alpha_i}\\right).\n\\end{equation*}\n%\nFrom the density of states, we can calculate the partition function $Z$ as\n\\begin{align*}\n    Z &= \\int_0^\\infty D(E)\\exp{\\!\\left(-\\frac{E}{\\kB T}\\right)} \\diff{E} \\nonumber \\\\\n      &= \\left(\\frac{2m}{\\pi\\hbar^2}\\right)^\\frac{3}{2} \\frac{x_0 y_0 z_0}{U_x^{1/\\alpha_x} U_y^{1/\\alpha_y} U_z^{1/\\alpha_z}} F(\\alpha_x, \\alpha_y, \\alpha_z) \\times (\\kB T)^\\xi\n\\end{align*}\nand using the relation\n\\begin{equation}\n    U = -N \\frac{\\partial \\ln Z}{\\partial \\beta} \\quad \\text{with} \\quad \\beta = \\frac{1}{\\kB T} \\nonumber\n\\end{equation}\nfrom \\cite{laurendeau_2005}, we can write down the internal energy $U$:\n\\begin{equation*}\n    U = N \\xi \\kB T.\n\\end{equation*}\nThis is consistent with the well known results of $U = 3N\\kB T$ for the harmonic oscillator potential and $U = \\frac{3}{2} N \\kB T$ for the 3D box potential.\n\nBy integrating out parts of the phase space distribution function\n\\begin{equation*}\n    f(\\vec{r},\\vec{p}) = Z^{-1}\\exp\\!{\\left(-\\frac{\\frac{\\vec{p}^2}{2m} + U(\\vec{r})}{\\kB T}\\right)}\n\\end{equation*}\nwe can calculate both the spatial density $n(\\vec{r})$ and the momentum distribution $n(\\vec{p})$.\n\nIntegrating out the momenta and multiplying with the atom number $N$ gives us the spatial density\n\\begin{align}\n    n(\\vec{r}) &= N\\int_{-\\infty}^\\infty \\frac{\\multidiff{3}{p}}{(2\\pi\\hbar)^3} f(\\vec{r},\\vec{p}) \\nonumber \\\\\n    %\n    &= 4\\pi N Z^{-1} (2\\pi\\hbar)^{-3} \\int_0^\\infty \\diff{p}\\, p^2 \\exp\\!\\left(-\\frac{\\frac{\\vec{p}^2}{2m} + U(\\vec{r})}{\\kB T}\\right) \\nonumber \\\\\n    %\n    &= N \\left(\\frac{m\\kB T}{2\\pi\\hbar^2}\\right)^{\\frac{3}{2}} Z^{-1} \\exp\\!\\left(-\\frac{U(\\vec{r})}{\\kB T}\\right) \\nonumber \\\\\n    %\n    &= \\underbrace{\\underbrace{\\frac{N}{8x_0y_0z_0}}_{=n_\\text{Box}}\\frac{1}{F(\\alpha_x\\alpha_y\\alpha_z)}\\prod_{i\\in\\{x,y,z\\}}\\left(\\frac{U_i}{\\kB T}\\right)^{\\frac{1}{\\alpha_i}}}_{\\equiv\\, n_0} \\exp\\!\\left(-\\frac{U(\\vec{r})}{\\kB T}\\right) \\label{eq:spatial_density}\n\\end{align}\nwhere we have defined the peak density $n_0$. In the case of a 3D box potential where $\\alpha_x = \\alpha_y = \\alpha_z \\rightarrow \\infty$, the density is constant and given by $n_\\text{Box} = \\frac{N}{8x_0y_0z_0}$.\n\nFor future reference, we also want to calculate the average density $\\langle n\\rangle$ here. The average of any quantity $Q$ over a given density distribution $n(\\vec{r})$ is given by\n\\[\\langle Q\\rangle = \\frac{\\int_{-\\infty}^\\infty \\multidiff{3}{r}\\; Q n(\\vec{r})}{\\int_{-\\infty}^\\infty \\multidiff{3}{r}\\; n(\\vec{r})} = \\frac{1}{N} \\int_{-\\infty}^\\infty \\multidiff{3}{r}\\; Q n(\\vec{r})\\]\nso for the average density we put\n\\begin{align}\n    \\langle n\\rangle &= \\frac{1}{N} \\int_{-\\infty}^{\\infty} \\multidiff{3}{r} \\left(n(\\vec{r})\\right)^2 \\nonumber \\\\\n    &= \\frac{N}{(8x_0y_0z_0)^2} \\frac{1}{\\left(F(\\alpha_x,\\alpha_y,\\alpha_z)\\right)^2} \\left(\\prod_{i\\in\\{x,y,z\\}} \\left(\\frac{U_i}{\\kB T}\\right)^{\\frac{1}{\\alpha_i}} \\right)^2 \\int_{-\\infty}^{\\infty} \\multidiff{3}{r} \\exp\\!\\left(-\\frac{2U(\\vec{r})}{\\kB T}\\right) \\nonumber \\\\\n    &= \\frac{N}{(8x_0y_0z_0)^2} \\frac{1}{\\left(F(\\alpha_x,\\alpha_y,\\alpha_z)\\right)^2} \\left(\\prod_{i\\in\\{x,y,z\\}} \\left(\\frac{U_i}{\\kB T}\\right)^{\\frac{1}{\\alpha_i}} \\right)^2 \\nonumber \\\\\n    &\\phantom{=} \\times 8x_0y_0z_0 \\prod_{i\\in\\{x,y,z\\}} \\left(\\frac{\\kB T}{2 U_i}\\right)^{\\frac{1}{\\alpha_i}} F(\\alpha_x,\\alpha_y,\\alpha_z) \\nonumber \\\\\n    &= \\frac{N}{8x_0y_0z_0} \\frac{2^{\\frac{3}{2} - \\xi}}{F(\\alpha_x,\\alpha_y,\\alpha_z)} \\prod_{i\\in\\{x,y,z\\}} \\left(\\frac{U_i}{\\kB T}\\right)^{\\frac{1}{\\alpha_i}} \\nonumber \\\\\n    &= \\frac{1}{2^{\\xi - \\frac{3}{2}}} n_0. \\label{eq:mean_density}\n\\end{align}\nFor example, in the harmonic oscillator potential, this is $\\langle n\\rangle = \\frac{n_0}{\\sqrt{8}}$.\n\nSimilarly, if we integrate out the spatial coordinates, we get the momentum distribution\n\\begin{align}\n    n(\\vec{p}) &= Z^{-1} \\left[\\int_{-\\infty}^\\infty \\frac{\\multidiff{3}{r}}{(2\\pi\\hbar)^3} \\exp\\!\\left(-\\frac{U(\\vec{r})}{\\kB T}\\right) \\right]\\exp\\!\\left(-\\frac{\\vec{p}^2}{2m\\kB T}\\right)\\nonumber \\\\\n    %\n    &= \\frac{8x_0y_0z_0}{Z(2\\pi\\hbar)^3} \\prod_{i\\in\\{x,y,z\\}} \\left(\\frac{\\kB T}{U_i}\\right)^{\\frac{1}{\\alpha_i}} F(\\alpha_x,\\alpha_y,\\alpha_z) \\exp\\!\\left(-\\frac{\\vec{p}^2}{2m\\kB T}\\right) \\nonumber \\\\\n    %\n    &= \\frac{1}{(2\\pi m \\kB T)^\\frac{3}{2}} \\exp\\!\\left(-\\frac{\\vec{p}^2}{2m\\kB T}\\right), \\nonumber\n\\end{align}\nrecovering the Maxwell-Boltzmann distribution.\nFrom this, the mean speed $\\langle c\\rangle$ follows as\n\\begin{equation}\n    \\langle c\\rangle = \\frac{\\langle |\\vec{p}| \\rangle}{m} = \\frac{1}{m}\\int \\multidiff{3}{p} |\\vec{p}|n(\\vec{p}) = \\sqrt{\\frac{8\\kB T}{\\pi m}}.\n\\end{equation}\n\n\\subsection{Model for Evaporative Cooling}\nFollowing the simple model explained above, we describe evaporative cooling as a sequence of infinitesimal steps in which a number \\diff{N} of atoms is removed from the cloud by reducing the trap depth to a value $\\eta \\kB T$. Evaporative cooling is described for example in \\cite{KETTERLE1996181}. Assuming $\\eta \\gg 1$, the loss in internal energy can be approximated as\n\\begin{equation}\n    \\diff{U} \\simeq \\eta \\kB T \\diff{N}\n\\end{equation}\nwhich reduces the temperature after thermalisation by \\diff{T} and the internal energy to the final value\n\\begin{equation}\n    U_\\text{f} = \\xi (N - \\diff{N}) \\kB (T - \\diff{T}).\n\\end{equation}\nBy subtracting the change in internal energy from the initial value $U_\\text{i}$, we can get a relation between the change in atom number and the change in temperature:\n\\begin{align}\n    U_\\text{i} - \\diff{U} &= U_\\text{f} \\nonumber \\\\\n    \\xi N \\kB T - \\eta \\kB T \\diff{N} &= \\xi (N - \\diff{N}) \\kB (T - \\diff{T}) \\nonumber \\\\\n    &\\simeq \\xi (TN - N\\diff{T} - T\\diff{N})\\kB \\nonumber\n\\end{align}\nomitting second order terms in \\diff{T} and \\diff{N}.\nThis can be reduced to\n\\begin{equation*}\n    \\frac{\\frac{\\diff{T}}{T}}{\\frac{\\diff{N}}{N}} = \\frac{\\diff{\\ln T}}{\\diff{\\ln N}} = \\frac{\\eta}{\\xi} -1 \\equiv \\nu\n\\end{equation*}\nwhere we define the parameter $\\nu$. Trivially, for certain starting conditions $N_0$ and $T_0$ we get\n\\begin{equation*}\n    \\frac{T}{T_0} = \\left(\\frac{N}{N_0}\\right) ^\\nu.\n\\end{equation*}\nBecause the goal of evaporative cooling is to reach quantum degeneracy, cooling alone is not enough. It is also necessary to increase the phase space density \\PSD which is given by\n\\begin{equation*}\n    \\PSD = n_0(N,T)\\cdot \\left(\\lambdadB(T)\\right)^3\n\\end{equation*}\nwith the de Broglie wavelength\n\\begin{equation*}\n    \\lambdadB = \\sqrt{\\frac{2\\pi\\hbar^2}{m\\kB T}}.\n\\end{equation*}\nPlugging in our result for $n_0$ from \\cref{eq:spatial_density} and the scaling of temperature with atom number, we find\n\\begin{equation*}\n    \\PSD \\propto NT^{-\\left(\\xi - \\frac{3}{2}\\right)} \\cdot T^{-\\frac{3}{2}} \\propto N^{1 - \\xi\\nu} = N^{1 + \\xi - \\eta}.\n\\end{equation*}\n\nThe decrease in temperature is achieved by thermalisation, which relies on elastic collisions. In an ideal gas, the elastic collision rate \\Rcoll is given by \\cite[8]{bird1994}\n\\begin{equation*}\n   \\Rcoll = n \\meanProb\n\\end{equation*}\nwhere $n$ is the density and \\meanProb the ensemble average of the product of cross section and relative velocity. As we are dealing with low temperatures, only s-wave scattering needs to be considered \\cite{joachain}. For this simple model, we also set the cross section to be constant. Furthermore, the mean relative speed is proportional to the mean speed. Inserting our result for the mean density from above, we find\n% \\begin{align}\n%     \\langle \\Rcoll\\rangle &= \\langle n\\rangle\\cdot \\meanProb = \\langle n\\rangle \\cdot \\sigma \\cdot \\langle\\crel\\rangle \\nonumber \\\\\n%     &\\propto NT^{-\\left(\\xi - \\frac{3}{2}\\right)} \\cdot \\text{const.} \\cdot T^{\\frac{1}{2}} \\nonumber = NT^{1-\\xi} \\nonumber \\\\\n%     &\\propto N^{\\eta \\left(\\frac{2}{\\xi} - 1\\right) + \\xi - 1}. \\nonumber\n% \\end{align}\n\\begin{equation*}\n    \\langle \\Rcoll\\rangle = \\langle n\\rangle \\cdot \\sigma \\cdot \\langle\\crel\\rangle \\propto N^{\\eta \\left(\\frac{2}{\\xi} - 1\\right) + \\xi - 1}.\n\\end{equation*}\n\n\\subsubsection*{Conditions for Efficient Evaporation}\nNecessary conditions to achieve evaporation are that the temperature decreases and the phase space density increases with decreasing atom number. The collision rate should at least stay constant, if it increases with atom number, \\emph{runaway evaporation} occurs. As we know the scaling behaviour of these quantities with $N$, we can give the requirements for $\\eta$ that have to be fulfilled to achieve each of these conditions. These are calculated in \\cref{tab:eva_scalings} for a linear trap (e.g.\\ quadrupole trap, $\\xi = 4.5$), a harmonic trap (e.g.\\ Ioffe-Pritchard trap, $\\xi = 3$) and a box trap ($\\xi = 1.5$).\n\\begin{table}[htbp]\n    \\centering\n    \\caption{Scaling laws and requirements for the parameter $\\eta$ to achieve (runaway) evaporation}\n    \\begin{tabular}{lcccl}\n        \\toprule\n        Quantity & Scaling $N^{\\{\\ \\}}$ & \\multicolumn{3}{c}{Requirement for $\\eta$} \\\\\n        \\cmidrule{3-5}\n        & & \\multicolumn{1}{c}{Linear} & \\multicolumn{1}{c}{Harmonic} & \\multicolumn{1}{c}{Box} \\\\\n        \\midrule \n        Temperature $T$ & $-1 + \\frac{\\eta}{\\xi}$ & $\\eta > \\num{4.5}$ & $\\eta > \\num{3}$ & $\\eta > \\num{1.5}$ \\\\\n        Phase space density $\\PSD$ & $1 + \\xi - \\eta$ & $\\eta > \\num{5.5}$ & $\\eta > \\num{4}$ & $\\eta > \\num{2.5}$ \\\\\n        Collision rate \\Rcoll & $\\xi - 1 + \\eta\\left(\\frac{2}{\\xi} - 1\\right)$ & $\\eta > \\num{6.3}$ & $\\eta > \\num{6}$ & $\\eta < \\num{-1.5}$ \\\\\n        \\bottomrule\n    \\end{tabular}\n    \\label{tab:eva_scalings}\n\\end{table}\nAs we can see, efficient evaporation in a stationary box potential cannot be achieved. This result is very intuitive as the local density is independent of the position in this case, which means it can only decrease with a decrease in atom number. Therefore, thermalisation times increase exponentially. \nThis adverse interplay between density and the thermalisation rate also plays a role for other trapping configurations and several papers have been published about methods to circumvent this problem in optical dipole traps (dimple trap \\cite{Jacob_2011}, tilted trap \\cite{PhysRevA.78.011604, PhysRevA.79.061406}, crossed beam trap \\cite{ARNOLD20113288}, zoom lenses \\cite{PhysRevA.71.011602}).\n\n% Our concept, as explained in \\cref{char:eva_motivation} is a very similar ansatz, but for a box potential instead.\n% It should be immediately obvious that evaporative cooling in a box potential is not something that could be meaningfully pursued. However, all the previous considerations assumed that the parameters $U_{\\{x,y,z\\}}$ and $x_0,y_0,z_0$ stay constant during the evaporation trajectory. If the volume of a hypothetical box potential could shrink while evaporation is performed, the adverse effect of the decreasing density could be conquered. Similar\\insertcite{}, concepts have been developed and are frequently implemented with optical evaporation, where two traps with different confinement overlap or where zoom lenses are used to compress the atomic cloud during the cooling stage. \n\n\\subsection{Inelastic Atom Loss}\n\\label{sec:inelastic_losses}\nUp until now we only considered elastic collisions between atoms from the cold cloud, because these are the driving mechanism behind evaporative cooling. Elastic collisions with the background gas as well as inelastic collisions between the atoms however are detrimental to the cooling effect. Atoms removed through these are not exclusively from the high-temperature end of the Maxwell-Boltzmann distribution. Since inelastic losses occur through density dependent effects, atoms are more likely to be lost from high-density regions. In non-uniform potentials, this is where cold atoms are usually accumulated. \n\n\\subsubsection*{Background Collisions}\nCollisions with the background gas in the vacuum chamber lead to atom loss because the background atoms (being in equilibrium with the walls of the chamber) are usually at room temperature (\\SI{300}{K}), which means that a collision often imparts more kinetic energy onto the trapped atom than the trap depth. The collision rate with the background gas atoms is calculated via\n\\begin{equation*}\n    \\Gamma_\\text{BG} = \\sum_i n_i \\langle \\sigma v \\rangle_{X,i} \n\\end{equation*}\nwhere the indices $i$ represent the different atomic species in the background gas and $X$ is the trapped atomic species. The densities $n_i$ are related to the partial pressures $P_i$ by\n\\begin{equation}\n    n_i = \\frac{P_i}{\\kB T}. \\nonumber\n\\end{equation}\nFor ultracold atoms, the background loss rate is simply the trap lifetime at low density~\\cite{PhysRevLett.91.123201}.\n\n\\subsubsection*{Two-Body Collisions -- Spin Relaxation} \nCollisions of two trapped atoms can only be inelastic if the spin projections of the involved atoms change during the collisions. \nThis process is called spin relaxation and in magnetic traps, one of the departing states can be untrapped. However, these kinds of processes can usually be suppressed by preparing the atomic cloud in a stretched spin state \\cite{PhysRevLett.99.223201}.\n\n\\subsubsection*{Three-Body Collisions -- Molecule Formation}\nThe final process we include is the three-body collision, where two atoms form a bound state and transfer the binding energy and momentum difference to a third atom \\cite{PhysRevLett.91.123201}. Usually, this leads to all three atoms being lost from the trap.\n\nThe loss rate for three-body recombination depends roughly on the square of the local density as three atoms need to be present. This also means that it can often be neglected at low densities but becomes dominant at very high densities, limiting the maximum achievable density \\cite{PhysRevA.85.053647}.\n\n\\subsubsection*{Loss Rate Equation}\nIf the rates for background ($K_1$), 2-body ($K_2$) and 3-body ($K_3$) losses are known, the local\\footnote{If we wanted to describe losses for the whole sample, we would need to take the averages $\\langle n\\rangle$ and $\\langle n^2 \\rangle$ instead.} loss rate can be expressed as\n\\begin{align} \\label{eq:lossrate}\n    \\frac{1}{N}\\frac{\\diff{N}}{\\diff{t}} = - K_1 - K_2 n - K_3 n^2.\n\\end{align}\nwhere $\\frac{\\diff{N}}{N}$ represents the probability of an individual atom to be lost in an infinitesimal timestep $\\diff{t}$.\n\n\n\n% \\section{Scattering Theory}\n% \\todo[inline]{derive the cross section formula used later and the mean collision rate}\n\n\\section{Numerical Simulation of Gas Dynamics}\n% \\label{sec:dsmc_theory}\n\nSimulating evaporative cooling is, in a bigger picture, the same as simulating any gas flow. A large number $N$ of particles, atoms or molecules, move according to a set of equations, can collide with each other and may or may not have interactions with a confining potential. A parameter that decides which model is best used to describe a gas flow is the Knudsen number \\Kn\n\\begin{equation*}\n    \\Kn = \\frac{\\lambda}{L}\n\\end{equation*}\nwhere $\\lambda$ is the mean free path and $L$ is the length scale of the surrounding environment, in our case the side length of the volume in which the atoms are confined. Based only on this ratio, gas flows can be separated roughly into four different regimes \\cite{schaaf:1958}:\n\\begin{itemize}\n    \\item $\\Kn < \\num{.01}$: Continuum regime\n    \\item $\\num{.01} < \\Kn < \\num{.1}$: Slip regime\n    \\item $\\num{.1} < \\Kn < \\num{10}$: Transition regime\n    \\item $\\Kn > 10$: Free molecular flow\n\\end{itemize}\n\nUltracold atomic gases, as they are present during evaporative cooling, usually exhibit a high Knudsen number. For example, a gas of $^{87}$Rb (scattering length $a\\sim 100\\, a_0$ \\cite{PhysRevA.87.053614}) atoms confined in a box with a side length of \\SI{2}{mm} with a density of \\SI{e11}{\\per\\centi\\meter\\cubed} would have a Knudsen number of $\\Kn = \\num{7.1}$. For this calculation, a constant cross section $\\sigma = 8\\pi a^2$ was assumed, which is justified at low temperatures. The more correct s-wave scattering cross section for identical bosons is given by \\cite{dalibardCollision}\n\\begin{equation}  \\label{eq:crosssection}\n    \\sigma(k) = \\frac{8\\pi a^2}{1 + (ak)^2} \n\\end{equation}\nwhere $k=\\frac{m\\crel}{2\\hbar}$ is the absolute value of the collision wave vector. This cross section will be used in the full simulation. For low collision energies, it approaches the constant value $8\\pi a^2$.\n\nWe can therefore safely assume a rarefied or highly rarefied gas flow that fulfills the conditions of the transition or even free molecular regimes. The simulation method most appropriate for these regimes is the Direct Simulation Monte Carlo (DSMC) method originally developed by G.~A.~Bird \\cite{bird1994}.\n% In a very simple, but near complete model, interparticle dynamics are described as forces acting between the particles. This gives the complete force $\\vec{F}$ acting on one particle denoted with the index $i$:\n% %\n% \\begin{equation}\n%     \\vec{F}_i = -\\nabla U(\\vec{r}_i) + \\sum_{j = 0,\\, i\\neq j}^N \\vec{F}_{ij}\n% \\end{equation}\n% %\n% Here, $U$ is the external potential and $\\vec{F}_{ij}$ is the interparticle force between particles $i$ and $j$. Naively, one could program a simulation that would calculate each of these forces at discretised timesteps and integrate the system with any differential equation solver. It is however immediately obvious why this is not feasible, at least as soon the system is a many-particle system. With ultracold gases, atom numbers $\\sim$\\num{E8} are not uncommon\\insertcite{}. This means, there are $\\sim$\\num{E16} calculations necessary to get all interparticle forces, and this has to be repeated in each step. Current computer hardware is simply not powerful enough to handle extensive calculations like this. However, evaporative cooling is an example of a rarefied gas flow. The classical mean free path is given by\n% \\begin{equation}\n%     \\lambda = \\frac{1}{n\\sigma}\n% \\end{equation}\n% and from, the Knudsen number $\\text{Kn}$ is derived as\n% \\begin{equation}\n%     \\text{Kn} = \\frac{\\lambda}{L}\n% \\end{equation}\n% where $L$ is the characteristic length scale of the medium. For an ultracold gas at typical conditions during evaporative cooling, i.e.\\ a temperature of \\SI{1}{\\micro\\kelvin}, a density of \\SI{e11}{\\per\\cubic\\centi\\metre}, and a scattering length on the order of $200a_0$ that has a diameter of \\SI{1}{mm}, the Knudsen number would be \n% \\[\\text{Kn} > 1 \\]\n% which puts us into the transition regime or almost into the regime of free molecular flow. When a gas is rarefied like this, numerical methods can be used to limit the computational expense necessary. Specifically, we will use the DSMC (Direct Simulation Monte Carlo) method, which is valid for Knudsen numbers $\\text{Kn} > \\num{0.1}$.\\insertcite{MULTIPLES}\n\n\n\\section{The DSMC Method}\nSimulating the flow of a gas with upwards of \\num{e8} particles is a computational expensive task. Over a certain time $\\Dt$, the probability of two particles colliding with each other is proportional to the cross section and the relative velocity. This can be imagined as the cylindrical volume that a circle with an area equal to the cross section traces out while moving with the relative velocity \\cite[7]{bird1994}. As the number of possible particle pairs scales quadratically with the number of particles, calculating the probabilities for all pairs becomes a virtually impossible task. \n\nIn DSMC, several measures are taken that reduce the computational expense significantly, making it possible to run a simulation on a home desktop or a laptop.\n\nTime is discretised into small timesteps that are much smaller than the mean collision time. The simulation volume is divided into cells, each of which is treated separately for the collision handling. The number of particles in the simulation is far lower than the number of simulated real particles. For the sake of better readability and because our simulation only deals with monatomic gases, a particle in the real world will be described as an \\emph{atom} from now on, while particles present in the simulation will be described as \\emph{particles}. A particle in the simulation represents a certain number of atoms in the real world. This number is called the statistic weight $W$ and plays an important role in the collision handling. Over one timestep, the particle movement is uncoupled from the collisions. The process of a DSMC simulation is sketched in \\cref{fig:dsmc_flowchart}. The following subsections will go into more detail on each of the steps.\n\\vfill\n\\begin{figure}[htbp]\n    \\centering\n    \\input{TexContents/Figures/Evap/DSMCFlowchart/DSMCFlowchart.tikz}\n    \\caption[The process of a DSMC simulation]{The steps outlined in the flowchart are further described in the following sections of this and the following chapter.}\n    \\label{fig:dsmc_flowchart}\n\\end{figure}\n\\vfill\n\n\n\\subsection{Particle Motion}\nThe motion of particles of mass $m$ in a potential $U(\\vec{r})$ is a well known problem with equally well known solutions. If every particle is treated separately, the problem reduces to the single-particle equation of motion\n\\begin{equation*}\n    \\ddot{\\vec{r}} = -\\frac{1}{m}\\nabla U(\\vec{r})\n\\end{equation*}\nwith known starting conditions for the velocity $\\dot{\\vec{r}}$ and position $\\vec{r}$. In many cases, a very simple method like leapfrog etc.\\ is sufficient. However, with a surrounding potential that is highly dependent on the position of the particles, more advanced methods are required to preserve energy as well as possible.\n\n\\subsection{Boundary Conditions}\nIn evaporative cooling, particle loss is an essential step. After all particles have been moved, it is checked if they have moved outside a certain boundary. If they have, they get removed from the simulation. \n\nBecause the total number of atoms usually decreases by a few orders of magnitude during evaporation, after some time a large number of particles would be lost from the simulation. However, the number of particles in a collisional cell should stay above a certain threshold for accurate collision numbers \\cite{SUN20111}. To circumvent this problem, we impose a threshold on the number of simulated particles $N$. Once this threshold is reached, all particles still present are copied and the statistic weight is halved. Of course, this means that we have to start with a certain power of 2 as the statistic weight. To copy the particles, the $x$ and $y$ values of their position and velocity are mirrored across the origin and the $z$ value is kept the same. This imposes the restriction on the surrounding potential that it has to be conforming to this symmetry. The $z$ values are explicitly not mirrored to retain the possibility of having gravity as a potential in the simulation.\n\n\\subsection{Collisions}\n\\label{sec:eva_theory_collisions}\nIn each collision step, a number of particle pairs is calculated in every cell, given by\n\\begin{equation} \\label{eq:ntc_npairs}\n    N_\\text{P} = \\frac{1}{\\VCell} \\NCell \\overline{\\NCell} \\maxProb \\Dt\n\\end{equation}\nwhere $\\VCell$ is the volume of one cell, $\\NCell$ is the instantaneous number of particles in this cell, $\\overline{\\NCell}$ is the corresponding time averaged value and \\maxProb is the maximum value of the product of cross section and relative velocity over all particle pairs. \nThen, $N_\\text{P}$ particle pairs are chosen randomly from the cell and a collision between them is performed if \n\\begin{equation*} %\\label{eq:ntc_fraction}\n    \\frac{\\sigma \\crel}{\\maxProb} > R\n\\end{equation*} \nwhere $R$ is a random number between 0 and 1.\nIf \\maxProb was to be calculated in every step, this would still be very inefficient as it would again require iterating over all possible particle pairs. However, because the number of pairs is proportional to \\maxProb and the probability is antiproportional to it, it suffices to calculate (or even guess) \\maxProb only once at the beginning. If a higher value is encountered subsequently, it can be updated. Even more, the true value of the maximum for $\\sigma \\crel$ is only a lower bound for the \\maxProb parameter. In our simulation, we will prefer better statistics by artificially increasing the number of pairs chosen through a higher than necessary value of \\maxProb.\n\n\\subsubsection*{Transient Adaptive Sub-Cell Technique}\nTo enforce near neighbor collisions, every cell is even further subdivided into sub-cells during every step. This technique has been described in \\cite{SU20101136}. When a particle pair is chosen for a collision attempt, the first particle is chosen from the whole cell. If the sub-cell with this particle contains other particles, the collision partner is chosen from the same sub-cell. Otherwise, sub-cells are gradually searched outwards to select a viable collision partner. We also perform collision tracking meaning that a particle $j$ is not viable for a collision with particle $i$ if $i$ and $j$ have been each other's last collision partner.\n\nThis technique is called transient, because the sub-cell division happens locally in each step and adaptive, because the number of sub-cells is chosen such that each sub-cell contains a certain number of particles on average. In practice, we aim for maximum 2 particles per sub-cell. This means that the total number of sub-cells in $x$, $y$ and $z$ direction is given by\n\\begin{equation} \\label{eq:tas_ncells}\n    N_i = \\lfloor\\sqrt[3]{\\NCell / 2}\\rfloor + 1.\n\\end{equation}\nIn almost all cases, this means there are fewer than 2 particles in each sub-cell.\n\n\\subsubsection*{Calculation of the Post-Collision Velocities}\nIt has been mentioned before that only s-wave scattering is considered. Therefore, the collisions are isotropic and the post-collision velocities can be calculated trivially. The absolute value of the relative velocity of the two particles does not change, only its direction.\n\nThe centre-of-mass $\\vec{c}_\\text{COM}$ and relative velocity $\\vec{c}_\\text{r}$ before the collision are given by\n\\begin{equation*}\n    \\vec{c}_\\text{COM} = \\frac{1}{2}(\\vec{c}_1 + \\vec{c}_2), \\quad \\vec{c}_\\text{r} = \\vec{c}_1 - \\vec{c}_2.\n\\end{equation*}\nWe calculate a unit vector of random direction as\n\\begin{equation*}\n    \\hat{\\vec{R}} = \\begin{pmatrix}\n        \\cos(\\theta) \\\\ \\sin(\\theta) \\cos(\\phi) \\\\ \\sin(\\theta) \\sin(\\phi)\n    \\end{pmatrix}\n\\end{equation*}\nwhere $\\phi$ is randomly chosen between $0$ and $2\\pi$ and $\\cos(\\theta)$ is randomly chosen between $-1$ and $1$.\nThen the post collision velocities $\\vec{c}_1'$ and $\\vec{c}_2'$ are simply\n\\begin{equation*}\n    \\vec{c}_1' = \\vec{c}_\\text{COM} + \\frac{1}{2} |\\vec{c}_\\text{r}| \\cdot \\hat{\\vec{R}}, \\quad \\vec{c}_2' = \\vec{c}_\\text{COM} - \\frac{1}{2} |\\vec{c}_\\text{r}| \\cdot \\hat{\\vec{R}}.\n\\end{equation*}\n\n\n% One possible approach in order to reduce the computational complexity of the task at hand is to decouple the particle motion from the collisions over a small timestep, i.e.\\ calculating and applying the motion first and then handling the collisions in a separate step. To get accurate collision numbers, the domain of the simulaion is separated into smaller cells such that in each cell, a constant density can be assumed. The size of the cells also needs to be smaller than the local mean free path\\insertcite{}. With a sufficiently small timestep only near neighbor collisions, i.e.\\ collisions inside the same cell, are possible. Then, the probability of a collision between two particles is given by\n% %\n% \\begin{equation}\n%     P = \\sigma \\crel \\Dt / \\Vcell.\n% \\end{equation}\n% %\n% Here, $\\sigma$ is the collisional cross-section, \\crel the relative speed of the particles and \\Vcell the volume of the cell. One could then compute the expected number of collisions in one timestep from the collision rate, choose particle pairs at random and evaluate collisions between them based on an acceptance-rejection method. This involves choosing a random number and accepting a collision if the probability $P$ exceeds this random number and rejecting it if it does not. This approach brings the problem that $P$ is usually a very small quantity, meaning a very large number of pairs would have to be tested for collisions in each step to reach the expected collision numbers. \n\n\n\n% G.~A.~Bird first proposed and developed many of the algorithms that this work is based on\\insertcite{}. In his \\enquote{No-Time-Counter} (NTC) method, the problem mentioned above is solved the following way: A number of particle pairs is selected from each cell and the collisions are then sampled among them. Specifically,\n% %\n% \\begin{equation} \\label{eq:ntc_npairs_incomplete}\n%     \\frac{1}{2\\Vcell} N (N - 1) \\maxProb \\Dt\n% \\end{equation}\n% %\n% pairs are chosen. Here, $N$ is the number of particles in the cell and \\maxProb represents the maximum value of the product of cross-section and relative speed over all particle pairs in the cell. A collision of a pair $(ij)$ is accepted if\n% %\n% \\begin{equation} \\label{eq:ntc_fraction}\n%     \\frac{(\\sigma\\crel)_{ij}}{\\maxProb} > R\n% \\end{equation}\n% %\n% with a random number $0 \\leq R \\leq 1$. Now the value of the deciding fraction in \\cref{eq:ntc_fraction} is much closer to 1 than if the probability $P$ had been calculated for each pair separately. This means that a lower number of pairs tested get's rejected, reducing the time necessary to complete one collision time step in one cell. The value of \\maxProb also does not have to be calculated in each step which would take the benefits away again. Instead, it is calculated once in the beginning of the simulation and then subsequently updated if a larger value is encountered. \n\n% Up until now we are still dealing with an enormous amount of calculations if both the motion and collision processing have to be done for $\\sim$\\num{1e8} particles. Arguably the most important step to achieving lower computation times is to let each particle in the simulation be representative of a number of actual physical particles. The simulated particles are called \\emph{macro}-particles from now on to avoid confusion. The number of particles represented by one macro-particle is called the statistic weight $W$. In simulations where the average number of particles is approximately constant over the simulated duration, this weight can be chosen almost arbitrarily\\footnote{of cource, lower values for $W$ result in better statistic accuracy.}. However, in evaporative cooling, particle loss is inherent to the process. This means that we have to choose the weight as a power of $2$. If the number of macro-particles drops below a threshold during the simulation, the weight is halved and each macro-particle is duplicated. During this duplication procedure, the velocity and position are mirrored along at least one axis to make it impossible for the duplicated particles to collide with the \\enquote{old} ones immediately after the duplication process. [\\textbf{NOTE:} This requires the external potential to have spatial symmetry in at least one direction, otherwise potential energy would not be conserved.]\n% With this technique, the behaviour of \\num{E8} particles can be simulated using only e.g.\\ $\\sim$\\num{12000} macro-particles, each with a statistic weight of $W=2^{13} = \\num{8192}$. \n% With the inclusion of the statistic weight, equation \\cref{eq:ntc_npairs_incomplete} becomes\n% %\n% \\begin{equation} \\label{eq:ntc_npairs}\n%     N_\\text{pairs} = \\frac{1}{2\\Vcell} W N (N-1) \\maxProb \\Dt.\n% \\end{equation}\n% %\n\n% \\paragraph{Transient Adaptive Sub-Cell Technique} ~\\\\\n% Because the macroscopic parameters of an atomic cloud change rapidly during evaporative cooling, a fixed number of cells might not always guarantee the conditions that the cell size should be about $1/2$ - $1/3$ the local mean free path. However, the accuracy of the simulation can be maintained by introducing sub-cells \\insertcite{}. In each step, every cell gets subdivided into sub-cells, such that each sub-cell contains a previously specified number of macro-particles. During the collision procedure, first collision partner is chosen from the whole cell. If the sub-cell of this contains other macro-particles, the second collision partner is chosen from the same sub-cell. Otherwise, the adjacent sub-cells are searched for a collision partner. \n\n% The technique is called \\enquote{transient} because the sub-cells are created in every step and \\enquote{adaptive} because the number of sub-cells can change between steps, depending on the number of macro-particles present.\n\n\n\n% \\subsection{Collisions}\n% \\label{sec:eva_theory_collisions}\n% In ultracold gases, only s-wave collisions are possible due to the very low temperatures. This simplifies the calculation of the velocities in a particle pair after a collision significantly, as a hard-sphere model can be applied. This means that the magnitude of the relative velocity between the particles does not change during the collision, only its direction is reassigned at random. In a gas with identical atoms, the centre-of-mass velocity is simply given by\n% %\n% \\begin{equation}\n%     \\cCOM = \\frac{1}{2}(\\vec{c}_1 + \\vec{c}_2)\n% \\end{equation}\n% %\n% and the relative velocity is\n% %\n% \\begin{equation}\n%     \\vec{c}_\\text{rel} = \\vec{c}_1 - \\vec{c}_2.\n% \\end{equation}\n% %\n% The velocities after the collision are then calculated as\n% %\n% \\begin{align}\n%     \\vec{c}_1^* &= \\cCOM + \\frac12 |\\vec{c}_\\text{rel}|\\cdot\\vec{\\hat{R}} \\\\\n%     \\vec{c}_2^* &= \\cCOM - \\frac12 |\\vec{c}_\\text{rel}|\\cdot\\vec{\\hat{R}}\n% \\end{align}\n% %\n% where $\\vec{\\hat{R}}$ is a unit vector of random direction.\n\n% \\iffalse\n% \\subsection{Summary}\n% A number of particles is represented as a smaller number of macro-particles, each with a the number of particles per macro-particle as a statistic weight. The domain is divided into smaller cells for near neighbour collisions.\n% In one timestep, the following steps are executed:\n% \\begin{enumerate}\n%     \\item move all particles according to the external forces.\n%     \\item apply boundary conditions (e.g.\\ eject particles that have moved outside of the domain).\n%     \\item perform collisions in each cell seperately according to the scheme described above.\n% \\end{enumerate}\n% \\fi\n\n\n", "meta": {"hexsha": "96b6bbcd364b914732bf69116d8e75222be44119", "size": 37210, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TexContents/22EVA-Theory.tex", "max_stars_repo_name": "AvonHaaren/mphil-thesis", "max_stars_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TexContents/22EVA-Theory.tex", "max_issues_repo_name": "AvonHaaren/mphil-thesis", "max_issues_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TexContents/22EVA-Theory.tex", "max_forks_repo_name": "AvonHaaren/mphil-thesis", "max_forks_repo_head_hexsha": "f96a6c352420c34632b4d5e502a1b38024753a74", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 92.5621890547, "max_line_length": 1422, "alphanum_fraction": 0.7377317925, "num_tokens": 10399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.410637253881276}}
{"text": "\\chapter{A stochastic agent-based network model}\n\\label{ch:abms}\n\\section{Agent-based models}\nAgent-based modelling is a computational method that models interacting individuals in an environment using a `bottom-up' approach\\cite{abm-gilbert}. The individuals are given preferences, actions available to them and ways to perceive not only themselves and their environment but also other agents. This method has proved useful in modelling a wide variety of complex systems in biology\\cite{kroese-uppal}, social science\\cite{epstein} and economics\\cite{abm-economics}.\\\\\n\\\\\nIts utility derives from allowing researchers to solely define the characteristics of the individuals without saying anything explicit about the system they are trying to model. They then see what happens when those individuals are free to interact with each other and the environment in the ways defined. This lets researchers to model complex system-wide phenomena without making any system-wide assumptions.\n\\subsection{The components}\nAn agent-based model (ABM) has four essential elements: agents, the environment, the rules that define how the two of these work together and time.\\\\\n\\\\\n%agents\nThe agents can represent anything from an individual person to a company, from a bacteria to a country. Anything that has `agency' can be an agent in an ABM. That is, anything that has the ability to act. They are programmed to react to other agents, which may or may not be of the same type. So a person can interact with another person but could also interact with an agent that is a frog or a country.\\\\\n\\\\\n%Environment\nThe environment is a virtual world the agents both exist in and interact with\\cite{abm-gilbert}. The environment may be abstract such as a network with the agents as nodes and an edge between two nodes signifying that those agents can interact with each other. However, it might also be very specific and concrete such as a geographically accurate rendering of a city.\\\\\n\\\\\nThe rules bind these two elements. They define things like how many agents of each type there are in the environment, when agents can act and who with.\\\\\n\\\\\n%Time\nFor an ABM to be a useful model of a system by definition the agents need to act. For something to act, we need time to evolve. So time is an inherent part of ABMs. However, representing time in any computer program is a challenge. One can either approximate continuous time or be explicitly discrete. Due to the difficulties of approximating continuous time, most ABMs have time incrementing in discrete steps. We call the units of time \\textit{ticks}.\\\\\n\\\\\nTo make this a bit easy to grasp and see how it works in practice, we will look at one in-depth but simple example.\n\n\\subsection{Example: Boltzmann wealth model}\\label{sec:boltzmann-wealth}\n%\\subsubsection{Introduction}\nWe will build a simple agent-based model to illustrate how they typically work. Taking a short break from the area of epidemiology and revolutions, we will try to model the unequal distribution of wealth in society. Econophysics is a trendy area of research, applying concepts from statistical mechanics to the study of economics\\cite{econophysics2}. The model we will look at will be inspired by this area and, in particular, a model of Dr\\u agulescu\\cite{econophysics1} and Yakovenko\\cite{boltzmann-tutorial}. The model is incredibly simple with only one type of agent, a minimal environment and just three rules. Despite its simplicity, this model can provide interesting and unexpected results.\n\\subsubsection{Setup}\n%Agents, environment, time\nIn our model the agents are people. They have a non-negative integer amount of wealth $w\\in\\mathbb{N}^{\\geq 0}$. They also have the ability to transfer money, if they have any, to other agents. The environment connects all agents to each other, allowing any agent to transfer money to any other. We will use discrete time in this model.\\\\\n\\\\\n%\\paragraph{Rules}\nThe rules are simple:\n\\begin{enumerate}[\n%\tnosep,\n%\tlabel={Rule \\arabic*}\n\t]\n\t\\item\\label{} There are $n$ agents.\n\t\\item\\label{} All agents start with $1$ unit of wealth.\n\t\\item\\label{} At each time-step, each agent that has at least one unit of wealth gives one unit to another agent, chosen randomly.\n\t\\setcounter{rule}{\\value{enumi}}\n\\end{enumerate}\n\\subsubsection{Implementation}\nABMs are essentially computer programs and so to implement the ideas above we need to write a program that will run in line with the set-up we have described.\\\\\n\\\\\nThe implementation of an agent-based model typically has two main classes: the model and the agents. The model class defines the environment, the rules and controls time. It also holds the global variables such as the number of agents and is in charge of keeping track of all the agents. The agent class defines the interacting individuals. Typically this class will hold an agent's own properties and will define the functions that allow the agent to sense their environment and interact with other agents.\\\\\n\\\\\n%\\paragraph{Implementing This}\nThe rules tell us what we need in the program.\n\\begin{enumerate}[\n%\tnosep,\n%\tlabel={From rule \\arabic*}\n\t]\n\t\\item\\label{} We need the model class to hold an integer $n$, the number of agents in the model. We also need the model to have a way of creating agents.\n\t\\item\\label{} We need each agent class to hold the units of wealth that they have. We also need the model class to initialise each agent with $1$ unit of wealth.\n\t\\item\\label{} The agent class needs a function to distribute wealth. At each tick, if the agent has positive wealth, they decrease their wealth by 1 and increase the wealth of another agent by $1$.\n\\end{enumerate}\nAn example of a bare bones implementation of this is:\n\\lstinputlisting[language=python]{../Code/illustrative/boltzmann-wealth/bare-bones-1.py}\nNote that we also assign each agent a `unique ID'. This is helpful for collecting data about the model, in particular for creating visual representations of the model or alternatively looking at typical behaviour of individual agents.\n\\subsubsection{Running the model}\nWe still need to add a few lines to make the code run and get a visual output. Letting it run for $100$ ticks with $100$ agents and plotting the results using\n\\lstinputlisting[language=python]{../Code/illustrative/boltzmann-wealth/bare-bones-2.py}\nwe get figure \\ref{fig:single-init-1}.\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/single-init-1.png}\n\t\\caption{Graph of the density of agent's wealth after one $100$ step run of the Boltzmann wealth model with $100$ agents with initial wealth $1$}\n\t\\label{fig:single-init-1}\n\\end{figure}\nThough the program begins with the money equally spread throughout the population, it quickly becomes centred around a few very wealthy individuals. Around half of the population end up with nothing at all.\\\\\n\\\\\n%\\paragraph{Batch Run}\nThe above graph was generated using just a single run of the program. One way we can get a clearer and firmer understanding of the system is to do `batch runs' where we run the simulation multiple times with the same parameters and compile all of the results. The following graph comes from running 100 of the simulations and creating a histogram of the wealth of the agents at the end.\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/batch-init-1.png}\n\t\\caption{Batch run of the Boltzmann Wealth model}\n\t\\label{fig:batch-init-1}\n\\end{figure}\n%would be cool to fit boltzmann curve to this\nThis shows the same disparity, perhaps even more starkly. Counter-intuitively, at least to me, despite having a constant process of redistributing wealth that seems to be in favour of the poor, we end up with a vastly unequal distribution. Almost half of all agents have 0 units of wealth while less than $10\\%$ have $4$ or more. One agent in one of the runs ends with a wealth of $15$. Through a simple and easily comprehensible system we have found some intriguing results.\\\\\n\\\\\nOne of the benefits of defining a social system as a program is that it makes it easy to run social experiments that would be difficult or unethical in real life. For example we can ask: what about if there is just more money around? Would that make the wealth distribution more equal? Exploring this is as easy as editing one initial value. If we start each individual with an initial wealth of $10$, though it takes longer to get there, we still end up with this inequality eventually. After 10000 ticks we end up with Figure \\ref{fig:single-init-10}.\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/single-init-10.png}\n\t\\caption{Histogram showing the result of increasing agent's initial wealth to $10$ on the Boltzmann wealth model.}\n\t\\label{fig:single-init-10}\n\\end{figure}\nSo, in this system at least, economic inequality cannot be fixed by more money.\\\\\n\\\\\nWe can then analyse this data as if it was field data. The fact that the distribution of wealth seems to move towards the same shape suggests some underlying equilibrium distribution. It turns out that the distribution of the wealth resulting from this model is actually a Boltzmann distribution\\cite{dragulescu}. This is an exponential distribution typically linked to stochastic systems that try to reduce their energy potential.\\\\\n\\\\\nABMs typically need some exterior reassurance that they are actually modelling the real world. Otherwise one can make many simplifications and assumptions and end up with a model that may or may not represent the system it is attempting to talk about. In this case one might consider real datasets of the income of a population. Indeed datasets show that income in the U.S.A. is distributed in a similar way to a Boltzmann distribution\\cite{econophysics1}.\\\\\n\\\\\nIf the data and model agree, researchers can use the model's results as evidence for bolder theses. In this case, researchers have argued that the Boltzmann distribution is in fact the \\textit{expected} distribution of wealth in a capitalist society\\cite{econophysics1}. The idea that this is a fundamental fact can be tested by seeing the result's robustness to different parameter values, rules and even different models. In this way, ABMs provide an interesting way to move back and forth between the world of theory and real world data.\n\\section{Social networks}\n%\\paragraph{Introduction}\nIn the Boltzmann wealth model the individuals exist in a very abstract space in which they interact with every other individual. In practice this is quite an unusual situation, as in general each person has some people they are more likely to interact with than others. People interact with the same people each day and have different relationships with others: friends, colleagues, stranger, daughter, spouse. This affects the interactions. This is also not unique to people. Companies, animals and countries have similar preferences and histories.\\\\\n\\\\\nWe can consider each agent in a population as a node and we have an edge connecting two nodes if the two people have some form of social interaction such as friendship or acquaintance. This defines a social network\\cite{networks}. An example of a social network is given by the author's Facebook friend network in Figure \\ref{fig:facebook-network}.\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=.7\\linewidth]{social-networks/joe-facebook-network-cropped}\n\t\\caption{The author's Facebook friend network. Each node represents a Facebook friend and an edge between two nodes represents that those two people are friends on Facebook. Three main groups are revealed. The lower left contains people from Newcastle where I grew up. The top left are people from Manchester and university. The top right are people from Montreal where I studied for a year.}\n\t\\label{fig:facebook-network}\n\\end{figure}\\\\\n\\\\\nFor the success of an ABM that has a network structure underlying it, it is important to ensure that the network of the simulation accurately represents the features of a typical network. In particular for our case of modelling a revolution it is important to find a social network that accurately reflects the social graph of influence around transmitting political views and actions between citizens.\\\\\n\\\\\nThere are two main ways we can find suitable networks to use in a model. Firstly, we can consider random graphs. These are a general species of graphs that are formed by a set of rules and reflect some aspect of real-life networks. The second option is to use datasets of real-life networks. Both have their merits and drawbacks.\n\\subsection{Random graphs}\n%--Features of social networks: random, power-law tail, high clustering.--\\\\\nA key feature of real-life networks is that they are irregular. They are much messier than well-ordered graphs such as complete graphs and lattices (see section \\ref{sec:graph-theory}). To approximate this we need to look at graphs that can incorporate probability into some aspects of its structure. There are three main species of random graph we will look at: the Erd\\H{o}s-R{\\'e}nyi graph, scale-free graphs and small-world graphs.\n%\\\\\\\\\n%We also desire it to have a power-law tail and high clustering.\n\\subsubsection{Erd\\H{o}s-R{\\'e}nyi graph, $G(n,p)$}\nThe prototypical and perhaps simplest random graph is the Erd\\H{o}s-R{\\'e}nyi graph\\footnote{Also known as the Poisson random graph, the Bernoulli random graph or simply the random graph.} $G(n,p)$. It is so prototypical it is often called \\textit{the} random graph. It is defined in terms of two parameters: the number of nodes $n$ and the probability that there is an edge between any two nodes $p$. Figure \\ref{fig:erdos-renyi-graphs} shows three graphs generated by this model.\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{.45\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\linewidth]{erdos-renyi/G(10,0'5).png}\n\t\t\\caption{$G(10,0.5)$}\n\t\t\\label{fig:K5}\n\t\\end{subfigure}\n\\begin{subfigure}{0.5\\textwidth}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{erdos-renyi/e-r-prob-dist-1.png}\n\t\\caption{$G(10,0.5)$}\n\t\\label{fig:K5}\n\\end{subfigure}\n\t\\begin{subfigure}{.45\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\linewidth]{erdos-renyi/G(59,0'2).png}\n\t\t\\caption{$G(59,0.2)$}\n\t\t\\label{fig:K16}\n\t\\end{subfigure}\n\\begin{subfigure}{0.5\\textwidth}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{erdos-renyi/e-r-prob-dist-2.png}\n\t\\caption{$G(10,0.5)$}\n\t\\label{fig:K5}\n\\end{subfigure}\n\t\\begin{subfigure}{.45\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\linewidth]{erdos-renyi/G(70,0'02).png}\n\t\t\\caption{$G(70,0.02)$}\n\t\t\\label{fig:K16}\n\t\\end{subfigure}\n\\begin{subfigure}{.5\\textwidth}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{erdos-renyi/e-r-prob-dist-3.png}\n\t\\caption{$G(70,0.02)$}\n\t\\label{fig:K16}\n\\end{subfigure}\n\t\\caption{Examples of Erd\\H{o}s-R{\\'e}nyi graphs on the left with the expected probability distributions of Erd\\H{o}s-R{\\'e}nyi graphs with these parameters.}\n\t\\label{fig:erdos-renyi-graphs}\n\\end{figure}\n%\\paragraph{Limitations}\nUnfortunately $G(n,p)$ has two major limitations in modelling real-world social networks: it has an unrealistic degree distribution and it has low clustering.\\\\\n\\\\\n%\\paragraph{Degree Distribution}\nFirstly, the degree distribution of $G(n,p)$ is a binomial distribution. That is to say the probability of a node being connected to $k$ others is:\n\\begin{equation}\n\tp_k=\\binom{n-1}{k}p^k(1-p)^{n-1-k}\n\\end{equation}\nThis is easily understood. Each node can be connected to $n-1$ others, there are $\\binom{n-1}{k}$ ways to be connected to $k$ of them, and the probability of having exactly $k$ edges is $p^k(1-p)^{n-1-k}$. This means that the degree of the vertices has the binomial distribution $B(n-1,p)$. However, the binomial distribution does not have `heavy tails', a feature often found in real-world networks including social networks\\cite{barabasi-albert}. This limits the ability of $G(n,p)$ to model social networks.\\\\\n\\\\\nIt is worth explaining the meaning of `heavy-tailed'. Qualitatively this means that in a sample from a heavy-tailed distribution you are more likely to get a small number of very high values. Quantitatively it means that the right tail of the distribution has a heavier tail than the exponential distribution\\cite{heavy-tailed}. That means that the probability distribution function has higher values for large $x$ (Figure \\ref{fig:heavy-tailed}).\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{erdos-renyi/heavy-tailed.png}\n\t\\caption{A graph showing the pdf of the exponential distribution in blue against the `heavy-tailed' log-normal distribution in orange.}\n\t\\label{fig:heavy-tailed}\n\\end{figure}\n%\\textit{Mark: say something about what it means to be heavy-tailed}\n\\label{mmd}\n\\\\\n\\\\\n%\\paragraph{Clustering}\nSecondly, $G(n,p)$ does not show nodes clustering as much as a real-world network. The clustering coefficient, $C$ is a measure of how likely nodes are to be in clusters. Formally, it is the probability that two neighbours of a vertex are also neighbours of each other\\cite{networks}. In the Erd\\H{o}s-R{\\'e}nyi graph, this probability is independent of all other edges. Hence the expectation of the clustering coefficient is simply $\\langle C\\rangle=p$.\\\\\n\\\\\nThis says that two neighbours are just as likely to be connected if they have a neighbour in common as if they do not. Most real social networks have high clustering, resulting from a phenomena called triadic closure\\cite{simmel}\\cite{strength-weak}. This just means that two of your friends are more likely to know each other than two random people. To see this, think of all your mutual friends and also how you tend to meet your friend's friends eventually.\\\\\n\\\\\n%\\subsubsection{Summary}\nWhilst the Erd\\H{o}s-R{\\'e}nyi graph does not provide an accurate representation of most social networks, its simplicity makes it useful for running some models. However, we will also consider some graphs that avoid the problems faced by the Erd\\H{o}s-R{\\'e}nyi graph.\n\\subsubsection{Scale-free graphs: the Barab\\'asi-Albert model}\nScale-free graphs are defined as graphs that have distributions of node degree that follow a power law. That is the probability of a node being connected to exactly $k$ others is $p_k\\sim k^{-\\gamma}$ where $\\gamma>0$. Early promoters of scale-free networks claim that they are prevalent throughout real-world networks\\cite{barabasi-albert}. However, recent reviews of large datasets suggest that there is limited evidence for this\\cite{scale-free-rare}.\\\\\n%\\\\\n%\\textit{Say what scale-free means here}\n\\label{mmd}\n%\\\\\n\\\\\nRegardless, the Barab\\'asi-Albert model is one of the most widely known models that can generate scale-free networks. It does so by generating graphs by a process of \\textit{preferential attachment}\\cite{barabasi-albert}. \n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{barabasi-albert/700.png}\n\t\\caption{A graph with 700 nodes created from the Barab\\'asi-Albert model}\n\t\\label{fig:ba-700}\n\\end{figure}\n%\\paragraph{Setup}\nA Barab\\'asi-Albert graph is made by the following process. Start with a graph of two connected nodes. We take discrete steps in time and at each step we add one node and connect it to one existing node. The existing node is chosen with probability proportional to its degree. That is, a node with degree $k$ is $k/l$ times more likely to connect to  than a node with degree $l$\\cite{galla}.\\\\\n\\\\\n%\\paragraph{Properties}\nThis preferential attachment results in a graph with a heavy-tailed distribution in which there are a few highly connected `super-nodes' and many nodes with only a few connections. This is similar to real-world networks. We can find the probability distribution of the node degree. Using a master equation method that describes the evolution of the graph, we can derive that $p_k\\sim k^{-3}$\\cite{galla}. This confirms that the distribution is roughly the right shape. \n\\\\\n\\\\\n%\\paragraph{Limitations}\nWhilst the Barab\\'asi-Albert model produces a reasonable degree distribution, it fails to give a clustering coefficient as high as those in social networks\\footnote{Whilst there are simpler heuristic estimates of the exact clustering coefficient, the exact analytic value is $\\frac{m-1}{8}\\frac{(\\log n)^2}{n}$\\cite{ba-cluster}}. This motivates the development of another graph model.\n\\subsubsection{Small-world graphs: the Watts-Strogatz model}\nThe Watts-Strogatz Model avoids this shortcoming and captures the property of many real networks of having both high clustering and short path lengths\\cite{watts-strogatz}. A graph having short path lengths means that there is a short path between any two nodes in a connected component. This gives the Watts-Strogatz its alternative name of the `small-world model'.\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth]{watts-strogatz/500,0`5.png}\n\t\\caption{A graph of 500 nodes created from the Watts-Strogatz model with a rewiring probability $0.5$}\n\t\\label{fig:ba-700}\n\\end{figure}\n\\\\\n\\\\\nThe Watts-Strogatz model is constructed in two parts.\n\\begin{enumerate}[nosep]\n\t\\item\\label{w-s-1} \\textit{Make a ring lattice} Take $n$ nodes. These are each given a number $i$. Then the $i^{\\text{th}}$ node is connected to $K/2$ nodes below it and $K/2$ nodes above it, modulo $n$. \n\t\\item\\label{w-s-2} \\textit{Rewire} Then after this, for each pair of nodes, rewire them with probability $\\beta$. To rewire an edge means to remove that edge and replace it with another that avoids loops or parallel edges.\\\\\n\\end{enumerate}\nStep \\ref{w-s-1} creates the high clustering and the random links introduced in step \\ref{w-s-2} give the short average path lengths. The parameter $\\beta$ mediates between these two characteristics. Indeed in the limit $\\beta=1$, it approximates an Erd\\H{o}s-R{\\'e}nyi graph which as we've seen has low clustering. In the limit $\\beta=0$ it is a ring lattice which has long average path lengths.\\\\\n\\\\\nHowever, it now fails where the Barab\\'asi-Albert graphs succeeded in that its probability distribution is not as long-tailed as a real-network. Hence choosing between these two graphs is a trade-off. In practice the best choice depends on what features one is investigating.\n%\\subsubsection{Exponential Random Graphs}\n%-- Wait for Data Science Institute talk on this next week --\n\\subsection{Real-world network datasets}\nAn alternative to using a random graph is to use a real-world dataset. For example, Facebook have access to a dataset of the social network of almost 2 billion people\\cite{num-fb-users}. Whilst researcher's access to this data is becoming rapidly more limited due to very valid privacy concerns it is still easy to obtain a subset of this data by `scraping' the friends list of public profiles, as seen in Figure \\ref{fig:facebook-network}. This has the problem that there are people who are not on Facebook and also that many users do not have their friend lists accessible to the public. A readily available and anonymised set of data can be found online\\cite{fb-ego-data}. This is a graph of $4039$ nodes and $88234$ edges.\\\\\n\\\\\nCurrently the largest open-source dataset of a social network is a dataset of the Friendster network\\cite{friendster-data-archive}. This graph dwarfs the pre-organised Facebook data, containing $117,751,379$ nodes and $2,586,147,869$ directed edges. A slightly tamed version exists \\cite{friendster-data-stanford} that takes the induced subgraph of users who are have at least some connection to the rest of the community, ignoring the stand-alone users. Whilst this is too large and unwieldy for this paper, a more manageable dataset could be attained by choosing a node and considering the induced graph of all nodes within a path of length, say, three from this node.\\\\\n\\\\\nFor specific problems it may be worth conducting data gathering missions to map specific networks. For example sometimes research is done on specific communities such as the social networks of autistic school children\\cite{anderson_locke_kretzmann_kasari_2015} or the relationships between Chilean astronomers\\cite{chilean-astronomers}. The benefits of using datasets are that we know that the networks we are simulating on relate to some real-world network. This means we have some guarantee that it at least looks a bit like the underlying network we are trying to model.\\\\\n\\\\\nThe negatives of this route are that it is just one instance of a network. It seems like, for example, the Facebook friendship network \\textit{could} have looked differently but kept similar features. One way to deal with this shortcoming is by using exponential random graphs. This is a family of random graphs whose probability distribution is designed to make it highly likely that a graph drawn from this distribution shares certain key properties such as mean degree or degree distribution\\cite{networks}. This feature has made them of use in modelling social networks\\cite{exponential-random-graph}.\n%\\textit{Mark: I’d say something like “this is a family of random graphs whose probability distribution is designed to make it highly likely that a graph drawn from the distribution shares certain key properties—mean degree, or degree distribution—}\n\\label{mm}\n%This is a family of random graphs that are generated in such a way that it makes it highly likely the a are graphs that can take the properties of the specific instance of the graph to created many more with the same properties\\cite{networks}.\nAnother, less avoidable, problem is that network data that serves as a proxy or approximation for a real underlying data will often be incomplete, particularly if the dataset is large and automatically collected such as the Facebook or Friendster data.\n\\subsection{Example: Boltzmann wealth model on a network}\nSo far we have developed a model of the transfer of wealth that assumed that relationships between agents are homogeneous. That is, they can transfer money with every agent equally easily. We can think of the agents as nodes and the ability to transfer wealth between two agents as an edge. Then the model we were previously using is the equivalent of a complete graph, the graph in which each node is joined by an edge to every other\\footnote{See Chapter \\ref{ch:games-on-networks} for a primer on graph theory.}.\\\\\n\\\\\nAs explored in the previous section, many real situations are not as homogeneous as this. Therefore it makes sense to consider cases in which some agents cannot transfer to others. To do this in an ABM we keep the agents the same but change the environment in which they exist and the rules they interact by.\n\\subsubsection{On a 2D Lattice}\nOne interesting thing to do is to make the environment a 2-dimensional lattice which the agents can move on. Then the nodes of the graph do not represent individual agents but spaces in which the agents can inhabit. That is we consider each agent as being at a certain position on a 2D lattice. We can add some rules to the Boltzmann wealth model to do this:\n\\begin{enumerate}[\n%\tlabel={Rule \\arabic*}\n\t]\n\t\\setcounter{enumi}{\\value{rule}}\n\t\\item At each tick, an agent moves to a neighbouring square.\n\t\\item Multiple occupancy is allowed\n\t\\item An agent can transfer money to any agent on a neighbouring square, including on their own square\n\\end{enumerate}\nImplementing this requires that the individuals store two extra parameters: x and y position. They also need a method to allow them to both move position and check the position of other agents to see if they are neighbours.\\\\\n\\\\\nImplementing this on a 2D lattice with the Moore neighbourhood gives a new model with different dynamics. Running this program with 100 agents on a $10\\times10$ grid and plotting the result after 100 ticks gives figure \\ref{fig:space-1}. The graph shows the wealthiest agent in that square. Interestingly the wealthiest agents with $3$ or $4$ units of wealth are usually surrounded by a high proportion of agents with $0$ units of wealth.\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/space-1.png}\n\t\\caption{The Boltzmann wealth model on a 2D lattice. The grid on the left is the 2D lattice with the colours representing the wealth of the wealthiest agent in that square. Specifically yellow represents a wealth of $4$ and the dark blue a wealth of $0$.}\n\t\\label{fig:space-1}\n\\end{figure}\n\\subsubsection{On an Barab\\'asi-Albert network}\nWe can also consider the same basic model but on other types of network. Moving back to the assumption that  the agents are fixed in their neighbours and do not move, we let each agent be a node in the network. Running the simulation on a Barab\\'asi-Albert network provides an interesting augmentation of the original model.\\\\\n\\\\\nWe choose to perform 100 runs of this simulation with $50$ agents on an Barab\\'asi-Albert network. Plotting the same graph of frequency density of wealth shows that the network simply amplifies the inequality we saw previously (Figure \\ref{fig:network-ba-1}).\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/network-ba-1-log.png}\n\t\\caption{Boltzmann wealth model on a Barab\\'asi-Albert network. The resulting wealth inequality is so severe that the graph has to be plotted with a log scale on the y-axis. Around 80\\% of the population have a wealth of $0$ while there are individuals with wealths of $40$.}\n\t\\label{fig:network-ba-1}\n\\end{figure}\nIf we look in more detail we can see that the wealth of an agent is positively correlated to the degree of the node (Figure \\ref{fig:network-ba-cor}). Now over $80\\%$ of the population has $0$ units of wealth and some agents end runs with over $40$ units, constituting $80\\%$ of the total wealth in their population.\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=.9\\linewidth]{boltzmann-wealth/network-ba-cor2.png}\n\t\\caption{Correlation between node degree and wealth in the Boltzmann wealth model on the Barab\\'asi-Albert network. Each point represents the node degree of an agent and its wealth at the end of a run. This plot shows the result of 1000 runs each time running with 50 agents for 100 steps. The data is fit with a sigmoidal curve of best fit.}\n\t\\label{fig:network-ba-cor}\n\\end{figure}\n\n%Could say something about measures of gini\n%To summarise, changing the underlying network of a model can have a major effect on the dynamics.\n\\section{Converting deterministic epidemiological models to ABMs}\nWe have learnt how ABMs can work, typical ways of analysing them and how the underlying network can affect the dynamics. With this we can move back towards studying epidemiology and revolutions. The first step we can make is to adapt the ideas from the deterministic compartmental models in Chapter \\ref{ch:compartments} to an agent-based model on a network that can incorporate discreteness and stochasticity.\n\\subsection{Stochastic SIR model}\n\\subsubsection{Building the model}\n%put on graph\nWe will start by adapting the simplest SIR compartmental model to make an ABM. The first step is to make the agents discrete. To do this we represent each agent as a node, creating $n$ nodes. We then have some edges joining them. We don't need to define the edges yet but we know that in general they join some nodes and not others. These edges together with the nodes form a graph $G$.\\\\\n\\\\\n%states and moving between states: infective to removed\nThe next step is to adapt the properties of classes in the population to properties of each agent. For example, instead of a class's size decreasing by a certain rate, we want each individual in that state to have a certain probability of moving to another state in any time. Previously we had three classes. To adopt this we have three states agents can be in: susceptible, infected and removed. Before we had that the infective class decreases at a rate of of $\\alpha I$ whilst the infective class increases at the same rate. To adopt this we have that each individual moves from infective to removed with rate $\\alpha$.\\\\\n\\\\\n%moving between states: susceptible to infective\nReinterpreting the movement from susceptible to infected takes a bit more thought. Previously to define the rate of contacts we assumed the law of mass action. However as we will incorporate a network structure for the environment, we are looking for something more sophisticated than this. Specifically we want to represent that some agents are more likely to come into contact than others.\\\\\n\\\\\nTo do this it helps to break down the meaning of the contact rate $\\beta$ from chapter \\ref{ch:compartments}. Technically $\\beta$ is the product of two parameters: the probability of contact between two individuals, $p$, and the probability of a contact leading to infection, $c$. In the previous compartmental model through the assumption of mass action we assumed that the probability of contact between any two individuals, $p$, was equal. However on a general network this is not true.\\\\\n\\\\\nNow we have $p=0$ for any non-neighbours and $p\\neq0$ for neighbours. It makes intuitive sense for $c$ to be constant for any disease regardless of the model we are using. Therefore to make the values of $\\beta$ we use comparable between the compartmental and agent-based models we need to adjust the value of $p$. Define $\\hat n$ to be the average number of neighbours a node has. Let $\\hat p$ be the probability of contact between two individuals in the network model. Then we need $\\hat n \\hat p = p N$. This ends up making the contact rate in the ABM $\\hat\\beta=\\beta N/\\hat n$.\\\\\n%\\\\\n%\\textit{Mark: I see what you mean about this section. Do you have a clearer idea of what you want to say now?}\n\\label{mmd}\n\\\\\nFinally, mirroring the initial conditions we set just a single node as infective.\\\\\n\\\\\nWe can summarise all of this succinctly:\n\\begin{enumerate}[nosep]\n\t\\item There is a graph of $n$ nodes where each node is an individual\n\t\\item The individual can be in one of three states: susceptible, infective or removed\n\t\\item Two neighbouring individuals come into contact at a rate $p$. This contact rate is independent of the degrees of the two nodes.\n%\t\\textit{Mark: Is this contact rate independent of the degrees (or number of neighbours) of the  two nodes?}\n\t\\label{mmd}\n\t\\item An infective infects a susceptible upon contact with probability $c$, after which the susceptible becomes infective\n\t\\item Infectives are removed at a rate $\\alpha$\n\t\\item Initially there is a single node that is infective\t\n\\end{enumerate}\n\\subsubsection{Running the simulation}\nTo support the agent-based modelling, the code uses the MESA framework. This is an open-source modular framework that aims to aid research in modelling, analysing and visualising agent-based systems in Python\\cite{mesa-github}. Using MESA we can create an interactive sandpit for experimenting with different parameter values on this model (Figure \\ref{fig:SIR-interactive}).\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{SIR-network/SIR-interactive.png}\n\t\\caption{The interactive screen of the SIR model. We have a similar screen for all following ABMs. On the left we can adjust parameter values, in the centre there is a live view of the dynamic network, below that an updating graph of class size against time and at the bottom we have some key statistics such as the value of $R_0$. The top bar allows the user to stop and start the simulation as well as find out further information about the model.}\n\t\\label{fig:SIR-interactive}\n\\end{figure}\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{.3\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\linewidth,trim={19.275cm 16cm 14cm 4.5cm},clip]{SIR-network/SIR-interactive.png}\n\t\t\\caption{$t=0$}\n\t\t\\label{fig:SIR-network-1}\n\t\\end{subfigure}%\n\\begin{subfigure}{.3\\textwidth}\n\t\\centering\n\t\\includegraphics[width=1\\linewidth,trim={19.275cm 16cm 14cm 4.5cm},clip]{SIR-network/SIR-interactive-2.png}\n\t\\caption{$t=15$}\n\t\\label{fig:SIR-network-2}\n\\end{subfigure}%\n\t\\begin{subfigure}{.3\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=1\\linewidth,trim={19.275cm 16cm 14cm 4.5cm},clip]{SIR-network/SIR-interactive-3.png}\n\t\t\\caption{$t=30$}\n\t\t\\label{fig:SIR-network-3}\n\t\\end{subfigure}\n\t\\caption{The evolving network in the agent-based SIR model with $70$ nodes. Green, red and grey dots represent susceptible, infective and removed individuals respectively. Black edges represent that the infection could still be passed through that edge whilst grey edges mean that neither of the two nodes are susceptible.}\n\t\\label{fig:SIR-network-run}\n\\end{figure}\n\\\\\n\\\\\nWe start by running a simulation with a small number of individuals (Figure \\ref{fig:SIR-network-run}). We can see that this new model can reflect the fact that the growth of classes is stochastic, going both up and down, such as at the peak of the infective class's size in Figure \\ref{fig:SIR-graph-1}.\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{SIR-network/1.png}\n\t\\caption{A graph of the change in the three classes size through time in the agent-based SIR model with $70$ nodes.}\n\t\\label{fig:SIR-graph-1}\n\\end{figure}\\\\\n\\\\\nWith a higher number of individuals, if the revolution gets going we see that it is very smooth due to the law of large numbers (Figure \\ref{fig:SIR-graph-2}). In this case we can see that the dynamics approximate the dynamics seen in the continuous compartmental models which is reassuring.\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{SIR-network/2.png}\n\t\\caption{The SIR ABM with $40000$ agents.}\n\t\\label{fig:SIR-graph-2}\n\\end{figure}\\\\\n\\\\\nThe important distinction between the compartmental model and the ABM is that now the infection can die out even with $R_0>1$.\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{SIR-network/3.png}\n\t\\caption{An infection dying out on the SIR model even with $R_0=1.07>1$}\n\t\\label{fig:SIR-graph-3}\n\\end{figure}\nThe probability that the infection dies with the first infective is $\\beta\\hat n/(\\alpha+\\beta\\hat n)$. This is because the time it takes on average for an infective to infect a susceptible is exponentially distributed with parameter $\\beta \\hat n$ where $\\hat n$ is the average number of neighbours a node has. Also the time it takes for an infective to be removed is exponentially distributed with parameter $\\alpha$. So the probability that the infection will run out in the early stages is $>\\beta\\hat n/(\\alpha+\\beta\\hat n)$.\n\\subsection{Stochastic SEIR model}\nNext, as before, we introduce the exposed class. Exposed nodes become active at a rate of $\\gamma$ and active nodes are removed at a rate of $\\alpha$. The mechanism for moving from susceptible to active now describes the move from susceptible to exposed. Again putting all of the rules in a list and using italics to highlight the rules that differ from the SIR model:\n\\begin{enumerate}[nosep]\n\t\\item There is a graph of $n$ nodes where each node is an individual\n\t\\item The individual can be in one of \\textit{four} states: susceptible, \\textit{exposed}, infective or removed\n\t\\item Two neighbouring individuals come into contact at a rate $p$\n\t\\item An infective infects a susceptible upon contact with probability $c$, after which the susceptible becomes \\textit{exposed}\n\t\\item \\textit{Exposed individuals become infective at a rate $\\gamma$}\n\t\\item Infectives are removed at a rate $\\alpha$\n\t\\item Initially there is a single node that is infective\n\\end{enumerate}\n\\bigskip\nRunning this we see, as in the compartmental SEIR model that the introduction of the exposed class dampens the rate of increase in the infected population (Figure \\ref{fig:SEIR-network-1}).\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{SEIR-network/1.png}\n\t\\caption{}\n\t\\label{fig:SEIR-network-1}\n\\end{figure}\nAlso because of the stochastic elements the model permits wipe-out even with $R_0>1$.\n\\subsection{Stochastic agent-based revolution model}\\label{sec:abm-rev}\nNow we can fully describe and implement a stochastic agent-based model of a revolution on a network.\\\\\n\\\\\nThe movements from $S\\rightarrow E$, $I\\rightarrow R$ are the same as described in the SEIR model. However we need to incorporate a version of the non-linear movement from $E\\rightarrow I$ that we devised in section \\ref{sssec:zealots}. The part we need to adapt is the threshold $k$ for social influence. In the compartmental model of revolution $k$ was a fraction of the population which represented the threshold for non-zealots to become involved in a revolution. However, one of the key benefits of simulating on a network is that we do not assume each individual has an omniscient view of the population. Instead their view is highly localised and limited to their neighbours on the graph. So instead of a proportion of the population we want $k$ to represent a threshold for how many neighbours need to be active for an individual to become active. That is, the value given will be the number of active neighbours, $\\hat i$, an exposed individual has to have for them to turn their idea into action. Based on the research we justified our previous decision with, this is around $3$ people\\cite{asch-conformity}. So we now set $\\hat k=3$. Then an exposed individual moves to active with probability\n\\begin{equation}\\label{eq:non-zealot-abm}\n\\gamma \\frac{\\hat i^n}{k^n+\\hat i^n}\n\\end{equation}\nFurther we give every agent an attribute: zealot or non-zealot. This determines if they will move to the active state when exposed with rate given by equation \\ref{eq:non-zealot-abm} or the zealot rate $\\delta$. This is a property held all the time by all agents and does not change. However it only affects their transition rate $E\\rightarrow I$.\\\\\n\\\\\nWritten out these rules are:\n\\begin{enumerate}[nosep]\n\t\\item There is a graph of $n$ nodes where each node is an individual\n\t\\item The individual can be in one of four states: susceptible, exposed, infective or removed\n\t\\item \\textit{Each individual is of one of two types: zealot or non-zealot}\n\t\\item Two neighbouring individuals come into contact at a rate $p$\n\t\\item An infective infects a susceptible upon contact with probability $c$, after which the susceptible becomes exposed\n\t\\item \\textit{If an exposed individual is a zealot, they become infective at a rate $\\gamma \\frac{\\hat i}{k^n+\\hat i^n}$}\n\t\\item \\textit{Otherwise if an exposed individual is a non-zealot they become infective at a rate $\\delta$}\n\t\\item Infectives are removed at a rate $\\alpha$\n\t\\item Initially there is a single node that is infective\n\\end{enumerate}\n\\bigskip\nWe choose to first run this model on a Watts-Strogatz network with 70 nodes (\\ref{fig:abm-rev-70}). \n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{rev-abm/rev-ws.png}\n\t\\caption{A typical trajectory using default parameters on a Watts-Strogatz network with $70$ agents.}\n\t\\label{fig:abm-rev-70}\n\\end{figure}\nMaking the number of nodes much larger confirms that the model shares many qualitative properties with the previous compartmental model of Section \\ref{sec:rev-compartment}.\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{rev-abm/rev-abm-2.png}\n\t\\caption{A typical trajectory using default parameters on a Watts-Strogatz network with $7000$ agents}\n\t\\label{fig:abm-rev-7000}\n\\end{figure}\nAgain, importantly the model allows the possibility of the growth of the infective class ending prematurely even with $R_0>1$ meaning it does not follow the same qualitative pattern as the compartmental model. Whilst this is an obvious strength, there are many more benefits to this network model. However they are more nuanced and we need to interrogate the results from a network perspective to see them.\n\\subsubsection{The effects of an agent's limited perspective}\nAs we have moved from a homogeneous model to one which incorporates the limited perspective of individuals it is interesting to see how this creates localised dynamics. One interesting feature in this model is how the infectives and exposed classes are distributed within the network quite differently. The infectives are highly clustered, huddled around the original infective. However, the exposed class tends to be spread throughout the network.\\\\\n\\\\\nIntuitively, the infectives need the support of their community to be active. However, the long range links provided by the small world model mean that contacts occur between the infective population and outside communities. So occasionally the idea jumps out of the active population to further away communities who are not currently active. However, the receiver of this idea has no other actives in sight and so does little about it. This means they stay as exposed and do not transfer to active.\n%\\textit{Mark: stick to one term: exposed or active}\n\\label{mmd}\nInstead they lie waiting for the action to reach them.\\\\\n\\\\\nTo comment on this quantitatively we need some measure of clustering and spread of classes on networks. We do not want the measures to be explicitly dependent on the size of the class. We also choose to normalise the measure so that it is between $0$ and $1$ to help us compare between classes easily.\\\\\n\\\\\nOne way to define clustering of classes is as the average fraction of neighbours of the same class a node in that class has. Formally, let $G$ be a graph of $n$ nodes. Each node is in exactly one state $c_i$. In our model $c_i$ is equal to one of the states susceptible, exposed, infective or removed. Let the class $C_i$ be the set of all nodes in state $c_i$. Then $\\abs{C_i}$ corresponds to the size of one of the compartments $S,E,I,R$ as given in the compartmental models. Write the neighbourhood of vertex $v$, excluding vertex $v$, as $N(v)$. We write $v\\in C_i$ if $v$ is in state $c_i$.\n%\\textit{Mark: where the state of the $i$-th node is $c_i$. Joe: I don't mean that but clearly the notation is not very clear}\n\\label{mmd}\nThen the clustering of class $C_i$ is\n\\[\\Gamma_i(t)=\\frac{1}{\\abs{C_i}}\\sum_{v\\in C_i}\\frac{\\abs{N(v)\\cap C_i}}{\\abs{N(v)}}\\]\n\\\\\n\\\\\nTo define spread, the idea that we want to capture is that the exposed class is more homogeneously spread through the network. One desirable option would be to calculate the shortest path from each node that is not in a state $c_i$ to a node in state $c_i$. However, calculating shortest paths is computationally very expensive. Instead we can approximate this by seeing if the shortest path is of length $1$. That is to say we see if the node has a neighbour in state $c_i$.\\\\\n\\\\\nWe define spread of type as the proportion of number of nodes not in state $c_i$ that have a neighbour in state $c_i$. Let $\\theta_i$ be a characteristic function indicating if a set of nodes has a node of type $c_i$\n\\[\\theta_i(X)= \\left\\{\\begin{array}{lr}\n1, & \\text{if } X\\cap C_i\\neq\\emptyset\\\\\n0, & \\text{otherwise}\n\\end{array}\\right\\}\\]\nThen\n\\[S_i(t)=\\frac{1}{n-\\abs{C_i}}\\sum_{v\\in V(G)\\setminus C_i} \\theta_i(N(v)) \\]\n\\\\\n\\\\\nWith these two measures we can test the clustering and diffusion quantitatively. Running a simulation we find that the two populations do indeed cluster and spread as described (Figure \\ref{fig:clustering-diffusion-rev-abm}). The idea spreads through the population widely, even when the revolution is not very developed, as seen from Figure \\ref{fig:diffusion-rev-abm}. The community of revolutionaries tends to be very clustered (Figure \\ref{fig:clustering-rev-abm}). However, the community of people who have the idea is unclustered and spread out. This provides suitable foundations for when the revolution does actually arrive. As we can see the exposed class is quickly depleted as more people become active.\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{rev-abm/clustering2.png}\n\t\t\\caption{Clustering}\n\t\t\\label{fig:clustering-rev-abm}\n\t\\end{subfigure}%\n\\\\\n\t\\begin{subfigure}{\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{rev-abm/diffusion2.png}\n\t\t\\caption{}\n\t\t\\label{fig:diffusion-rev-abm}\n\t\\end{subfigure}\n\t\\caption{Clustering and spread in the revolution ABM with default parameters. Figure \\ref{fig:clustering-rev-abm} shows that the active population is consistently more clustered than the exposed population. Figure \\ref{fig:diffusion-rev-abm} shows that the exposed class increase their spread through the population before being suddenly depleted near the peak of the revolution as they convert to the rapidly burgeoning active population.\\label{mmd}}\n\t\\label{fig:clustering-diffusion-rev-abm}\n\\end{figure}\n\\\\\n\\begin{tcolorbox}\n\t\\paragraph{Lesson for revolutionaries:} Ideas travel further than action. The idea can be widely distributed and lie dormant until action reaches it.\n\\end{tcolorbox}\n\\section{The Empire Strikes Back}\nAn interesting option is to introduce an adversarial agent to the model: the regime. It is an interesting question to ask what tactics they should adopt. In the previous model we have an equal chance of each active individual being removed. Instead we allow the option of the regime removing nodes based on their properties.\\\\\n%\\\\\n%To distinguish this from the current case, it would be most revealing to simulate on an Barab\\'asi-Albert graph as this has a probability distribution closer to real world networks and will provide more insight into a principle that relies on the distribution of node degree.\\\\\n\\\\\nTo stop the revolutionary idea spreading the regime wants to limit the number of nodes the idea can reach. The most effective way to do this is to separate the graph into two components with one containing all active revolutionaries and the other containing the rest. This means the regime could use Menger's Theorem to disconnect the graph efficiently.\n%\\textit{Mark: tell us what Menger's theorem is}\n\\label{mmd}\nMenger's Theorem states that the minimum number of nodes one needs to remove to disconnect two disjoint subgraphs $U, V\\subset V(G)$ is equal to $k$, the number of distinct paths from $U$ to $V$\\cite{graph-theory-reference}. In our example $U$ can be the set of exposed and infective nodes and $V$ the set of susceptible and removed nodes. These are clearly disjoint as a node is in exactly one of these states at one time so Menger's theorem for these two sets. The regime could then instantaneously remove $k$ active nodes to disconnect the two subgraphs. \nHowever, the assumption that the regime is able to identify and efficiently take out just the nodes that will separate the graph is incredibly strong, requiring exact knowledge of the network and the ability to pick out any individual.\\\\\n\\\\\nInstead we assume that the regime becomes aware of revolutionaries only through attempted contacts with susceptibles. With this ability, what is the best option for the regime? It makes sense for them to pick out active revolutionaries with the highest number of contacts. This makes the problem one of attack tolerance in networks\\cite{attack-tolerence-network}. In practice this means that more high-profile revolutionaries are at greater risk. This is based on the idea everyone is at some risk and this is proportional to the number of contacts $p\\hat n$ they can and do make. Based on historical evidence this is often what happens: regimes target high-profile individuals both because they are more easily detected as well as them making a better example. Whilst this can provoke the populace it can also serve to provide a split in tactics and leadership. For these reasons we will consider this option.\\\\\n\\\\\nSome graphs are more resilient to this targeted node removal than others. Scale-free graphs have a low attack tolerance as removing just a few supernodes can drastically disconnect the graph. However, in a more egalitarian network such as the Watts-Strogatz network or Erd{\\H{o}}s-R{\\'{e}}nyi graph this is harder to do\\cite{attack-tolerence-network}.\\\\\n\\\\\nSome naturally occurring networks seem to be naturally catered to tolerating attacks and failures. The social network of the bottlenose dolphins community of Doubtful Sound fjord has been studied in detail and shows an unusually high level of interconnection with no clear hubs and also low clustering\\cite{dolphin-network}. The network was found by taking observations of a community of 64 dolphins over 6 years. There is an edge between two dolphins if they are seen together more often than expected by chance.\n\\label{mmd} The result of this network organisation is that if a few dolphins die it is very unlikely to break apart the social network and so they will stay as a single component. That is, they have evolved to have a high failure tolerance.\\\\\n\\\\\nThe findings of the benefits of decentralised movements reflects a growing historical trend of egalitarian organisation in successful non-violent resistance\\cite{battle-of-seattle}. As Eddie Yuen writes in \\textit{The Battle of Seattle} on the trends that developed through the 20th century to lead to the increasing success of non-violent protest\\cite{logic-non-violence} and in particular the Seattle protests against the WTO in 1999:\n\\begin{quote}\n\tThe second [of these adoptions] is a commitment to direct democracy, as specifically the organisational forms of the affinity group, decentralized spokes-council meetings and consensus process.\n\\end{quote}\n\\begin{tcolorbox}\n\t\\paragraph{Lesson for revolutionaries:} \\textit{Be like a dolphin}. Decentralised and interwoven networks are more immune to targeted attacks. Pursue organisational structures which avoid unnecessary hierarchy by pursuing tactics such as direct democracy.\n\\end{tcolorbox}\n%\\section{Revolution on a Network}\n%\\subsection{Model Specification}\n%This model involves one category of actors: 'citizens'. Following Epstein\\cite{epstein}, we include two exogenous factors: hardship ($H$) and legitimacy ($L$).\\\\\n%$H$ \n%\\subsection{Agent Specification}\n%They are members of the general population and may be in one of four states: susceptible ($S$), inactive revolutionaries ($I_1$), active revolutionaries ($I_2$), and removed ($R$). As in many agent-based models, they are heterogeneous in many respects.\n", "meta": {"hexsha": "8bf560606c0904e41c08dca8379e4e712d416e6e", "size": 54011, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Writing/TeX_files/abms.tex", "max_stars_repo_name": "joekroese/math-of-revolution", "max_stars_repo_head_hexsha": "c831ea3d5f6c56c3861522f71ec47e1a22f9ff2c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-12-07T18:16:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T10:54:20.000Z", "max_issues_repo_path": "Writing/TeX_files/abms.tex", "max_issues_repo_name": "joekroese/math-of-revolution", "max_issues_repo_head_hexsha": "c831ea3d5f6c56c3861522f71ec47e1a22f9ff2c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Writing/TeX_files/abms.tex", "max_forks_repo_name": "joekroese/math-of-revolution", "max_forks_repo_head_hexsha": "c831ea3d5f6c56c3861522f71ec47e1a22f9ff2c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 105.079766537, "max_line_length": 1204, "alphanum_fraction": 0.7830812242, "num_tokens": 13033, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4106372538812759}}
{"text": "\\section{pa-monad}\n\\label{sec:pa-monad}\n\n\n\\begin{enumerate}\n\\item debug \\\\\n  tags file\n\\begin{bluetext}\n  \"monad_test.ml\" : pp(camlp4o -parser pa_monad.cmo)\n  camlp4o -parser pa_monad.cmo monad_test.ml -printer o\n\n  (** filter *)\n\n  let a = perform let b = 3 in  b\n  let bind x f = f x \n  let c = perform c <-- 3 ; c \n  (* output\n  let a = let b = 3 in b\n  let bind x f = f x\n  let c = bind 3 (fun c -> c)\n  *)\n\n\n\nlet bind x f = List.concat (List.map f x)\nlet return x = [x]\nlet bind2 x f = List.concat (List.map f x)\n\nlet c = perform \n    x <-- [1;2;3;4]; \n    y <-- [3;4;4;5]; \n    return (x+y)\n\n\nlet d = perform with bind2 in \n    x <-- [1;2;3;4]; \n    y <-- [3;4;4;5]; \n    return (x+y)\n\nlet _ = List.iter print_int c \nlet _ = List.iter print_int d \n\n(*\nlet bind x f = List.concat (List.map f x)\nlet return x = [ x ]\nlet bind2 x f = List.concat (List.map f x)\nlet c =\n  bind [ 1; 2; 3; 4 ]\n    (fun x -> bind [ 3; 4; 4; 5 ] (fun y -> return (x + y)))\nlet d =\n  bind2 [ 1; 2; 3; 4 ]\n    (fun x -> bind2 [ 3; 4; 4; 5 ] (fun y -> return (x + y)))\nlet _ = List.iter print_int c\nlet _ = List.iter print_int d\n*)  \n\n\\end{bluetext}\n\n\\item translation rule \\\\\n  it's simple. \\textbf{perform} or \\textbf{perform with bind in } then\n  it will translate all phrases ending with \\textit{;}; \\textit{x <--\n me;} will be translated into \\textit{me >>= (fun x -> )};\n\\textit{me;} will be translated into \\textit{me >>= (fun \\_ -> ... )}\nyou should refer \\textit{pa\\_monad.ml} for more details \n\\textit{perform with exp1 and exp2 in exp3} uses the first given\nexpression as bind and the second as match-failure function.\n\\textit{perform with module Mod in exp } use the function named bind\nfrom module Mod. In addition ues the module's failwith in refutable patterns\n\n\\begin{alternate}\n  let a = perform with (flip Option.bind) in a <-- Some 3;  b<-- Some 32; Some (a+ b) ;;\n  val a : int option = Some 35\n\\end{alternate}\n\nit will be translated into\n\\begin{bluetext}\nlet a =\n  flip Option.bind (Some 3)\n    (fun a -> flip Option.bind (Some 32) (fun b -> Some (a + b)))\n\\end{bluetext}\n\\item ParameterizedMonad \\\\\n\n\\begin{ocamlcode}\nclass ParameterizedMonad m where\n  return :: a -> m s s a\n  (>>=) :: m s1 s2 t -> (t -> m s2 s3 a) -> m s1 s3 a\n\ndata Writer cat s1 s2 a = Writer {runWriter :: (a, cat s1 s2)}\n\ninstance (Category cat) => ParameterizedMonad (Writer cat) where\n  return a = Writer (a,id)\n  m >>= k = Writer $ let\n    (a,w) = runWriter\n    (b,w') = runWriter (k a)\n    in (b, w' . w)\n    \n\\end{ocamlcode}\n% $\n\n\\begin{bluetext}\n  \nmodule State : sig \n  type ('a,'s) t = 's -> ('a * 's)\n  val return : 'a -> ('a,'s) t \n  val bind : ('a,'s ) t -> ('a -> ('b,'s) t ) -> ('b,'s) t\n  val put : 's -> (unit,'s) t \n  val get :  ('s,'s) t\nend = struct \n type ('a,'s) t = ('s -> ('a * 's))\n let return v = fun s -> (v,s)\n let bind (v : ('a,'s) t) (f : 'a -> ('b,'s) t) : ('b,'s) t = fun s -> \n   let a,s' = v s in \n   let a',s'' = f a s' in \n   (a',s'')\n let put s = fun _ -> (), s \n let get = fun s -> s,s \nend \n\n\nmodule PState : sig \n  type ('a, 'b, 'c) t = 'b -> 'a * 'c\n  val return : 'a -> ('a,'b,'b) t\n  val bind : ('b,'a,'c)t -> ('b -> ('d,'c, 'e) t ) -> ('d,'a,'e) t\n  val put : 's -> (unit,'b,'s)t\n  val get : ('s,'s,'s) t \nend  = struct \n type ('a,'s1,'s2) t = 's1 -> ('a * 's2)\n let return v = fun s -> (v,s)\n let bind v f = fun s -> \n   let a,s' = v s in \n   let a',s'' = f a s' in \n   (a',s'')\n let put s = fun _ -> (), s \n let get = fun s -> s,s \nend \n  \n\\end{bluetext}\n\n\\begin{ocamlcode}\nlet v = State.(perform  x <-- return 1 ; y <-- return 2 ; let _ =\nprint_int (x+y) in return (x+y) );;\n\\end{ocamlcode}\n\\begin{ocamlcode}\nval v : (int, '_a) State.t = <fun>  \n\\end{ocamlcode}\n\n\\begin{ocamlcode}\nlet v = State.(perform x <-- return 1 ; y <-- return 2 ; z <-- get ; put (x+y+z) ; \n  z<-- get ; let _ = print_int z in return (x+y+z));;\n\\end{ocamlcode}\n\\begin{ocamlcode}\n val v : (int, int) State.t = <fun>  \n\\end{ocamlcode}\n\n\\begin{alternate}\n  v 3;;\n6- : int * int = (9, 6)\n\\end{alternate}\n\n\n\\begin{ocamlcode}\nlet v = PState.(perform x <-- return 1 ; y <-- return 2 ; z <-- get ; put (x+y+z) ; \nz<-- get ; let _ = print_int z in return (x+y+z));;\n\\end{ocamlcode}\n\n\\begin{ocamlcode}\nval v : (int, int, int) PState.t = <fun>\n\\end{ocamlcode}\n\n\\begin{alternate}\nv 3 ;;\n6- : int * int = (9, 6)  \n\\end{alternate}\n\n\\begin{ocamlcode}\nlet v = PState.(perform x <-- return 1 ; y <-- return 2 ; z <-- get ; \nput (string_of_int (x+y+z)) ; return z );;\n\\end{ocamlcode}\n\\begin{ocamlcode}\nval v : (int, int, string) PState.t = <fun>\n\\end{ocamlcode}\n\n\\begin{alternate}\n# v 3;;\nv 3;;\n- : int * string = (3, \"6\")\n\\end{alternate}\n\n\\end{enumerate}\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"../master\"\n%%% End: \n", "meta": {"hexsha": "337f8ce116af77743bcef5437a80abfcbc9a89d0", "size": 4709, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "library/monad.tex", "max_stars_repo_name": "mgttlinger/ocaml-book", "max_stars_repo_head_hexsha": "09a575b0d1fedfce565ecb9a0ae9cf0df37fdc75", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 142, "max_stars_repo_stars_event_min_datetime": "2015-01-12T16:45:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T00:47:37.000Z", "max_issues_repo_path": "library/monad.tex", "max_issues_repo_name": "mgttlinger/ocaml-book", "max_issues_repo_head_hexsha": "09a575b0d1fedfce565ecb9a0ae9cf0df37fdc75", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-10-09T13:53:43.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-03T04:15:48.000Z", "max_forks_repo_path": "library/monad.tex", "max_forks_repo_name": "mgttlinger/ocaml-book", "max_forks_repo_head_hexsha": "09a575b0d1fedfce565ecb9a0ae9cf0df37fdc75", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2015-02-10T18:12:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-21T06:57:32.000Z", "avg_line_length": 24.0255102041, "max_line_length": 88, "alphanum_fraction": 0.5625398174, "num_tokens": 1787, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4105057790965624}}
{"text": "% !TeX root = ../thesis.tex\n\\paragraph{}\nIn some situations, the FEM mesh can be so locally coarse that some localized phenomena can not be captured.\nHowever, a naive implemented mesh generation algorithm usually produce a uniform mesh where small elements are created even though they are only necessary in limited areas.\nX-FEM \\citep{Moes1999} or the Generalized FEM \\citep{STROUBOULIS20014081,doi:10.1002/nme.4954} was proposed to enrich the model when the mesh is so coarse that the local scale phenomena (crack for example) can not be taken into account.\nOthers developed the multigrid algorithms which permits relevant computations while keeping the computational cost acceptable to solve this problem \\citep{doi:10.1002/nme.2427, doi:10.1002/nme.3037}.\nHowever, only ad-hoc softwares support enriched finite element model or multigrid \\citep{Duval2018}, which leads to the fact that these methods may not be applicable to all circumstances, especially for the users of the softwares that lack of such features.\n\n\\paragraph{}\nAs a consequence, methods using a posteriori error estimator to refine the mesh adaptively was proposed and widely adopted in FEM \\citep{Duval2018, doi:10.1002/gamm.201490020,PRUDHOMME20091887,BAUMAN2009799, doi:10.1002/nme.1620121010, doi:10.1002/nme.1620240618,Oden1989,doi:10.1002/nme.1620240206,doi:10.1002/nme.1620330702,doi:10.1002/nme.1620330703, BOROOMAND1999127, ZIENKIEWICZ1999111, Ainsworth1993} and BEM \\citep{Zhao1998, Guiggiani1990, KAMIYA1992223, KITA199421,ZHAO1999793,KITA2000317}.\nA posteriori error estimator using stress recovery technique for the SBFEM was also proposed \\citep{NME:NME439}.\nHowever, some of these error estimators require extra work such as stress recovery.\nBesides, it could be difficult to determine the most suitable error indicator to a given problem.\nMachine learning and deep neural network introduced in Sec.~\\ref{lr_sec:machine_learning} allows the usage of multiple error indicators was proposed \\citep{SaeedIqbal;Graham.F.Carey2005}.\nHowever, the fact that only the geometric properties were considered and the lack of physical indicators limit the effectiveness of this method.\n", "meta": {"hexsha": "ce7d997faa93721f346097f5c82d38a76451b5ec", "size": 2159, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "literature/lr_adap.tex", "max_stars_repo_name": "fa93hws/thesis", "max_stars_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-30T12:14:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-30T12:14:47.000Z", "max_issues_repo_path": "literature/lr_adap.tex", "max_issues_repo_name": "fa93hws/thesis", "max_issues_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "literature/lr_adap.tex", "max_forks_repo_name": "fa93hws/thesis", "max_forks_repo_head_hexsha": "c397ddc18e5ff5d6e9b8d6de2e53be4c9c7b7a2d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 134.9375, "max_line_length": 498, "alphanum_fraction": 0.8188976378, "num_tokens": 580, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.41050577665035964}}
{"text": "\\section{The PID control law}\n\\subsection{}\n\n\\begin{frame}\n\\frametitleTC{The overall law}\n\\framesubtitleTC{recap in preparation for the implementation}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The control signal $u(k)$ is the sum of the Proportional (P), the Integral (I)\\\\\n       and the derivative (D) action:\n       \\begin{displaymath}\n        u(k) = u_P(k)+u_I(k)+u_D(k).\n       \\end{displaymath}\n \\item Some action may not be present, giving rise to the P, I, PI, PD laws -- with\\\\\n       obvious meaning -- besides the complete PID one (D and ID make little\\\\\n       -- if any -- sense in practice, we omit further discussions).\n \\item We shall now study the three actions, then deal with actuator limits,\\\\\n       and finally move to the algorithm.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The P action}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The P action $u_P(k)$ is computed as\n       \\begin{displaymath}\n        u_P(k) = K e(k).\n       \\end{displaymath}\n \\item Its role is to respond \\TC{promptly} to an error variation.\n \\item Since there is no dynamics, that response is in fact instantaneous\\\\\n       (if not for computation delay and machine-related timing facts\\\\\n       at large).\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The I action}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The I action $u_I(k)$ is computed as\n       \\begin{displaymath}\n        u_I(k) = u_I(k-1) + \\frac{KT_s}{T_i} e(k).\n       \\end{displaymath}\n \\item Its role is to guarantee \\TC{zero steady-state error}.\n \\item At steady state everything (including $u_I$) is constant, and therefore\\\\\n       the error must be zero because in the opposite case $u_I$ would vary.\n \\item In general, if your control scheme has to ensure that some variable\\\\\n       is zero at steady state, just make that variable the input of an\\\\\n       integrator. \n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The D action}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The D action \\TC{in the CT domain} is expressed as\n       \\begin{displaymath}\n        u_D(t) = K T_d \\frac{de(t)}{dt}\n       \\end{displaymath}\n       where $T_d$ is called the \\TC{derivative time}.\n \\item Its role is to attempt to \\TC{anticipate the error} over a horizon $T_d$ in the future.\n \\item Interpretation (and \\emph{caveat} to not make $T_d$ too large):\n       \\begin{center}\n        \\includegraphics[width=0.45\\columnwidth]{./Unit-06/img/D-action-interpretation.pdf}\n       \\end{center}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The D action}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Sometimes the D action may respond too nervously, and therefore it is in fact computed as\n       \\begin{displaymath}\n        u_D(k) = \\beta u_D(k-1) + (1-\\beta) K T_d \\frac{e(k)-e(k-1)}{Ts}, \\quad 0 < \\beta < 1.\n       \\end{displaymath}\n \\item In this course we provide no notion of \\TC{frequency response} -- another hook for the\\\\\n       interested -- but it should be intuitive that if $u_D(k)$ contains a fraction\\\\\n       $\\beta$ of $u_D(k-1)$ while the new input's contribution only weighs $1-\\beta$,\\\\\n       this combination acts as a \\TC{lowpass filter}, i.e., smooths out the abrupt\\\\\n       variations of $u_D$ that the input would otherwise provoke.\n \\item In $z$ form we thus have\n       \\begin{displaymath}\n        \\frac{u_D(k)}{e(k)} = \\frac{1-\\beta}{z-\\beta} \\frac{K T_d}{T_s} \\frac{z-1}{z}.\n       \\end{displaymath}\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The D action}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item For reasons we do not have the time to fully discuss here (but ask if interested)\\\\\n       it is convenient to set\n       \\begin{displaymath}\n        \\beta = \\frac{T_d}{T_d+NT_s}, \\qquad N>0,\n       \\end{displaymath}\n       in a nutshell because doing so\n       \\begin{itemize}[<+-| alert@+>]\n       \\item the pole $\\beta$ of the $u_D/e$ transfer function is surely in the range $(0,1)$,\n       \\item if $T_d=0$ (PI only) $\\beta$ vanishes as well,\n       \\item parameter $N$ is a good knob to control the amount of smoothing applied\\\\\n             to $u_D$ (higher $N$ means lower $\\beta$, thus less of $u_D(k-1)$ in $u_D(k)$, thus\\\\\n             less smoothing --- and clearly \\textit{vice versa}). \n       \\end{itemize}\n \\item We are now ready for a PID ``quasi-algorithm''.\n \\item In fact now we write just the essentials and then, after discussing\\\\\n       control limits, we get to the real thing, also introducing some\\\\\n       practically useful additions.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile,label={pag:PID-quasi-alg}]\n\\frametitleTC{A PID quasi-algorithm}\n\\framesubtitleTC{to be executed periodically with timestep $T_s$}\n\\myPause\n \\begin{verbatim}\n  e      = w-y;\n  up     = K*e;\n  ui     = ui_old+K*Ts/Ti*e;\n  ud     = beta*ud_old+(1-beta)*K*Td/Ts*(e-e_old);\n  u      = up+ui+ud;\n  e_old  = e;\n  ui_old = ui;\n  ud_old = ud;\n \\end{verbatim}\n\\end{frame}\n\n", "meta": {"hexsha": "0e302f605b9835839e976dfbd9cb54ca712625f8", "size": 5034, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/Unit-06/sections/03-ThePIDlaw.tex", "max_stars_repo_name": "albertoleva/PID4CSE", "max_stars_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-19T16:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-19T16:38:10.000Z", "max_issues_repo_path": "slides/Unit-06/sections/03-ThePIDlaw.tex", "max_issues_repo_name": "albertoleva/PID4CSE", "max_issues_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/Unit-06/sections/03-ThePIDlaw.tex", "max_forks_repo_name": "albertoleva/PID4CSE", "max_forks_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0147058824, "max_line_length": 98, "alphanum_fraction": 0.6539531188, "num_tokens": 1530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4105057728901339}}
{"text": "\n\\paragraph{Data:}\n\nIn the following, we refer to our algorithm as \\smug\\footnote{Online gamma Process Autoregressive Spike Sorting}.\nWe used two different datasets to demonstrate the efficacy of \\smug.  First, the ever popular, publicly available HC1 dataset %\\footnote{http://crcns.org/data-sets/hc/hc-1/}\nas described in \\cite{Henze2000}.  We used the dataset d533101 that consisted of an extracellular tetrode and a single intracellular electrode.  The recording was made simultaneously on all electrodes and was set up such that the cell with the intracellular electrode was also recorded on the extracellular array implanted in the hippocampus of an anesthetized rat. The intracellular recording is relatively noiseless and gives nearly certain firing times of the intracellular neuron.  The extracellular recording contains the spike waveforms from the intracellular neuron as well as an unknown number of additional neurons.  The data is a 4-minute recording at a 10 kHz sampling rate.  \n\nThe second dataset comes from novel NeuroNexus devices implanted in the rat motor cortex.  The data was recorded at 32.5 kHz in freely-moving rats.  The first device we consider is a set of 3 channels of data (Fig.\\ \\ref{3dev}).  The neighboring electrode sites in these devices have 30 $\\mu$m between electrode edges and 60 $\\mu$m between electrode centers.  These devices are close enough that a locally-firing neuron could appear on multiple electrode sites \\cite{Prentice2011}, so neighboring channels warrant joint processing.  The second device has 8-channels (see Fig.\\ \\ref{8dev}), but is otherwise similar to the first.\n\n\nFor both datasets, we preprocessed with a high-pass filter at 800 Hz using a fourth order Butterworth filter before we analyzed the time series.  To \ndefine $\\bD$, we used the first five principle components of all spikes detected with a threshold (three times the standard deviation of the noise above the mean) in the first five seconds.  The noise standard deviation was estimated both over the first five seconds of the recording as well as the entire recording, and the estimate was nearly identical.  Our results were also robust to minor variations in the choice of the number of principal components.  The autoregressive parameters were estimated by using lag-1 autocorrelation on the same set of data.  For the multichannel algorithms we estimate the covariance between channels and normalize by our noise variance estimate.\n\n\nEach algorithm gives a clustering of the detected spikes.  In this dataset, we only have a partial ground truth, so we can only verify accuracy for the neuron with the intracellular (IC) recording.  We define a detected spike to be an IC spike if the IC recording has a spike within 0.5 milliseconds (ms) of the detected spike in the extracellular recording.  We define the cluster with the greatest number of intracellular spikes as a the ``IC cluster''.   We refer to these data as ``partial ground truth data'', because we know the ground truth spike times for one of the neurons, but not all the others.  \n\n\n\n\\vspace{-.1in}\n\\paragraph{Algorithm Comparisons}\n\nWe compare a number of variants of \\smug, as well as several previously proposed methods, as described below.  The vanilla version of \\smug\\ operates on a single channel with colored noise.  When using multiple channels, we append an ``\\sct{M}'' to obtain \\sct{M}\\smug.  When we model the mean of the waveforms as an auto-regressive process, we ``post-pend'' to obtain \\smug\\sct{R}.  \nWe compare these variants of \\smug\\ to Gaussian mixture models and k-means \\citep{Lewicki} with N components (\\sct{Gmm-N} and \\sct{K-N}, respectively), where \\sct{N} indicates the number of components.  We compare with a Dirichlet Process Mixture Model (\\sct{DPMM}) \\cite{WoodBla2008} as well as the  Focused Mixture Model (\\sct{Fmm}) \\cite{FMM}, a recently proposed Bayesian generative model with state-of-the-art performance.  Finally, with compare with \\sct{OSORT} \\cite{OSORT}, an online sorting algorithm.  Only \\smug\\ and \\sct{OSORT} methods were online as we desired to compare to the state-of-the-art \\emph{batch} algorithms which use all the data. \n% could not find any previous code available for online spike sorting, despite a small literature on the topic \\cite{??}.  \nNote that \\smug\\ algorithms learned $\\bD$ from the first five seconds of data, whereas all other algorithms used a dictionary learned from the entire data set.  \n% Supplementary Fig.\\ \\ref{fig:waveforms} shows the two different dictionaries and the relative fraction of variance explained.\n\n% \n% \nThe single-channel experiments were all run on channel 2 (the results were nearly identical for all channels).  The spike detections for the offline methods used a threshold of three times the noise standard deviation \\cite{Lewicki} (unless stated otherwise), and windowed at a size $L=30$.  For multichannel data, we concatenated the $M$ channels for each waveform to obtain a $M\\times L$-dimensional vector.\n%, and PCA was used to reduce the space to $K$=5 for the experiments. \n\n% \\subsection{Results}\n\n% The online algorithms were all run with weakly informative parameters (\\dec{add parameters once I get vinayak's notation}). The parameters were insensitive to minor changes.  Running time in unoptimized MATLAB code for 4 minutes of data was 31s was a single channel and 3 minutes for all 4 channels on a 3.2 GHz Intel Core i5 machine with 6 GB of memory.\n\nThe online algorithms were all run with weakly informative parameters. For the normal-Wishart, we used  $\\mb{\\mu}_0=\\mb{0}$ $,\\lambda_0=0.1,\\bW=10\\bI$, and $\\nu=1$ ($\\bI$ is the identity matrix).  \nThe AR process corresponded to a GP with length-scale $30$ seconds, and variance $0.1$.\n%we set $\\bB=(1-\\mathsf{exp}(-2\\times 10^{-6}))\\bI$ and $r_t\\sim\\mathsf{N}(0,\\mathsf{exp}(-4\\times 10^{-6})\\bI$.  \n$\\alpha$ was set to $0.1$. The parameters were insensitive to minor changes.  Running time in unoptimized MATLAB code for 4 minutes of data was 31 seconds for a single channel and 3 minutes for all 4 channels on a 3.2 GHz Intel Core i5 machine with 6 GB of memory (see Supplementary Fig.\\ \\ref{fig:timing} for details).\n\n\\vspace{-.1in}\n\\paragraph{Performance on partial ground truth data}\n\n\n\nThe main empirical result of our contribution is that all variants of \\smug\\ detect more true positives with fewer false positives than any of the other algorithms on the partial ground truth data (see Fig.\\ \\ref{hc1res}).  The only comparable result is the \\sct{OSORT}; however, the \\sct{OSORT} algorithm split the IC cluster into 2 different clusters and we combined the two clusters into one by hand.  Our improved sensitivity and specificity is \\emph{despite} \nthe fact that \\smug\\ is fully online, whereas all the algorithms (besides \\sct{OSORT}) that we compare to are batch algorithms using all data for all spikes.   Note that all the comparison algorithms pre-process the data via thresholding at some constant (which we set to three standard deviations above the mean).  To assess the extent to which performance of \\smug\\ is due to \\emph{not} thresholding, we implement \\sct{Fake}-\\smug, which thresholds the data.  Indeed, \\sct{Fake}-\\smug's performance is much like that of the batch algorithms.  To get uncertainty estimates, we split the data into ten random two minute segments and repeat this analysis and the results are qualitatively similar. % (see Supplementary Fig.\\ \\ref{sfig:hc1res}).\n\n\nOne possible explanation for the relatively poor performance of the batch algorithms as compared to \\smug\\ is a poor choice of the important---but often overlooked---threshold parameter.  The right panel of Fig.\\ \\ref{hc1res} shows the receiver operating characteristic (ROC) curve for the k-means algorithms as well as \\smug\\ and \\sct{M}\\smug\\ (where \\sct{M} indicates multichannel, see below for detail).  Although we typically run \\smug\\ without tuning parameters, the prior on $\\Lambda$ sets the expected number of spikes, which we can vary in a kind of ``empirical Bayes'' strategy.  Indeed, the \\smug\\ curves are fully above the batch curves for all thresholds and priors, suggesting that regardless of which threshold one chooses for pre-processing, \\smug\\ always does better on these data than all the competitor algorithms.  Moreover, in \\smug we are able to infer the parameter $\\Lambda$ at a reasonable point, and the inferred $\\Lambda$ is shown in the left panel of Fig.\\ \\ref{hc1res}. and the points along the curve in the right panel.  These figures also reveal that using the correlated noise model greatly improves performance.\n\nThe above analysis suggests \\smug's ability to detect signals more reliably than thresholding contributes to its success.  In the following, we provide evidence suggesting how several of \\smug's key features are fundamental to this improvement.\n%\n\\begin{center}\n\\begin{SCfigure}[3]\n\t\\includegraphics[width=0.28\\textwidth]{../figs/truefalsepositive.pdf}\n\t\\includegraphics[width=0.3\\textwidth]{../figs/new/icroc.pdf}\n% \\begin{subfigure}[b]{.49\\textwidth}\n% \\centering\n% \\includegraphics[width=\\textwidth]{../figs/truefalsepositive.pdf}\n% \\caption{}\n% \\label{hc1res}\n% \\end{subfigure}\n% \\begin{subfigure}[b]{.49\\textwidth}\n% \\includegraphics[width=\\textwidth]{../figs/new/icroc.pdf}\n% \\caption{}\n% \\label{fig:roc}\n% \\end{subfigure}\n\\caption{\\smug\\ achieves improved sensitivity and specificity over all competing methods on partial ground truth data. % (where true positives from one neuron are known from intracellular recordings).  \n(a) True positive and false positive rates for all variants of \\smug\\ and several competing \n% state-of-the-art \\emph{batch} \nalgorithms.  \n(b) ROC curves demonstrating that \\smug\\ outperforms all competitor algorithms, regardless of threshold (\\jovo{$\\bullet$} indicates learning $\\Lambda$ from the data).\\label{hc1res}}\n\\end{SCfigure}\n\\end{center}\n% \n% \n% \n\\vspace{-10pt}\n\\vspace{-.1in}\n\\paragraph{Overlapping Spike Detection}\n\n\n\nA putative reason for the improved sensitivity and specificity of \\smug\\ over other algorithms is its ability to detect overlapping spikes.   When spikes overlap, although the result can accurately be modeled as a linear sum in voltage space, the resulting waveform often does not appear in any cluster in PC space (see \\cite{Pillow2013}).  However, our online approach can readily find such overlapping spikes.  Fig.\\ \\ref{fig:overlapping} (top left panel) shows one example of 135 examples where \\smug\\ believed that multiple waveforms were overlapping.\nNote that even though the waveform peaks are approximately 1 ms from one another, thresholding algorithms do not pick up these spikes, because they look different in PC space. \n%\\jovo{@dec - can we show that in the Supplement?}.\n\nIndeed, by virtue of estimating the presence of multiple spikes, the residual squared error between the expected voltage and observed voltage shrinks for this snippet (bottom left).  The right panel of Fig.\\ \\ref{fig:overlapping} shows the density of the residual errors for all putative overlapping spikes.  The mass of this density is significantly smaller than the mass of the other scenarios.  Of all the true spikes that we detect, 37 of them we believe to be overlapping.  Thus, while it seems detecting overlapping spikes helps, it does not fully explain the improvements over the competitor algorithms.\n%\\jovo{@jovo - add an actual statistical test test.} \n\n\n% It is possible for action potentials to fire close to simultaneously so that a given window would have 2 or move action potent ions.  It is possible for the algorithm to detect and fit overlapping spikes as they come in.  Out of the 3593 spikes detected by the algorithm, there are 124 pairs of overlapping spikes within 1 ms of one another (3.45\\%).  An example of an overlapping waveform is shown in Fig.\\ \\ref{overlapping}.\n\n\n\\begin{center}\n\\begin{SCfigure}[3]\n\\includegraphics[width=.28\\textwidth]{../figs/alloverlappingspikes/olspike3}\n\\includegraphics[width=.28\\textwidth]{../figs/overlappingstatv2.pdf}\n% \\begin{subfigure}[b]{.3\\textwidth}\n% \\includegraphics[width=\\textwidth]{../figs/alloverlappingspikes/olspike3}\n% \\caption{}\n% \\label{fig:overlapping}\n% \\end{subfigure}\n% \\begin{subfigure}[b]{.3\\textwidth}\n% \\includegraphics[width=\\textwidth]{../figs/overlappingstatv2.pdf}\n% \\caption{asdf}\n% \\label{fig:resid}\n% \\end{subfigure}\n\\vspace{-.1in}\n\\caption{\\smug\\ detects multiple overlapping waveforms (Top Left) The observed voltage (solid black), MAP waveform 1 (red), MAP waveform 2 (blue), and waveform from the sum (dashed-black). (Bottom Left) Residuals from same example snippet, showing a clear improvement in residuals.  %(c) {Histogram of residuals for all putative overlapping examples.}\n    } \\label{fig:overlapping}\n\\end{SCfigure}\n\\end{center}\n\n\n\\vspace{-10pt}\n\\vspace{-.1in}\n\\paragraph{Time-Varying Waveform Adaptation} \\label{sub:adapt}\n\n\nAs has been demonstrated previously \\cite{calabrese2011kalman}, the waveform shape of a neuron may change over time.  The mean waveform over time for the intracellular neuron is shown in Fig.\\ \\ref{evohc1}.  Clearly, the mean waveform is changing over time.  Moreover, these changes are reflected in the principal component space (Fig.\\ \\ref{fig:clusterevo}).  We therefore compared means and variances \\smug\\ with \\smug\\sct{R}, which models the mean of the dictionary weights via an auto-regressive process.  Fig.\\ \\ref{fig:AR} shows that the auto-regressive model for the mean dictionary weights yields a time-varying posterior (top), whereas the static prior yields a constant posterior mean with increasing posterior marginal variances (bottom).  More precisely, the mean of the posterior standard deviations for the time-varying prior is about half of that for the static prior's posteriors. \nIndeed, the \\smug\\sct{R} yields 11 more true detections than \\smug.\n \n% \\jovo{plot 3 ARs on top of each other, and also plot 3 stationary on top of each other.}\n% \\jovo{AR: mean 0.0037  std  0.0038\n   % other: mean 0.0077  std  0.0071}\n\n\\begin{center}\n\\begin{figure}\n\\begin{subfigure}[b]{.33\\textwidth}\n\\includegraphics[width=\\textwidth]{../figs/evohc1}\n\\caption{}\n\\label{evohc1}\n\\end{subfigure}\n\\begin{subfigure}[b]{.33\\textwidth}\n\\includegraphics[width=\\textwidth]{../figs/new/clusterevo.pdf}\n\\caption{}\n\\label{fig:clusterevo}\n\\end{subfigure}\n\\begin{subfigure}[b]{.33\\textwidth}\n\\includegraphics[width=\\textwidth]{../figs/new/ARvsStationary.pdf}\n\\caption{}\n\\label{fig:AR}\n\\end{subfigure}\n\\vspace{-.3in}\n\\caption{\nThe IC waveform changes over time, which our posterior parameters track. \n(a) Mean IC waveforms over time.  Each colored line represents the mean of the waveform averaged over 24 seconds with color denoting the time interval.  This neuron decreases in amplitude over the period of the recording. \n(b) The same waveforms plotted in PC space still captures the temporal variance.\n(c) The mean and standard deviation of the waveforms at three time points for the auto-regressive prior on the mean waveform (top) and static prior (bottom). While the auto-regressive prior admits adaptation to the time-varying mean, the posterior of the static prior simply increases its variance.  \n}\n\\end{figure}\n\\end{center}\n\n\\vspace{-10pt}\n\\paragraph{Multielectrode Array} \\label{sub:multi}\n% \\vspace{-5pt}\n\n\n\\smug\\ achieved a heightened sensitivity by incorporating \\emph{multiple} channels (see \\sct{M}\\smug\\ point in Fig.\\ \\ref{hc1res}).  \n% Another key feature of \\smug\\ is its ability to incorporate multiple channels.  For the HC1 data, \\sct{M}\\smug\\ (the multielectrode variant) achieved \\jovo{??} more true positives, while only missing an additional \\jovo{??} spikes (see Fig.\\ \\ref{hc1res}).  \nWe further evaluate the impact of multiple channels using a three channel NeuroNexus shank (Supp.\\ Fig.\\ \\ref{3dev}). In Fig.\\ \\ref{ext31} we show the top two most prevalent waveforms from these data across the three electrodes.  Had only the third electrode been used, these two waveforms would not be distinct (as evidenced by their substantial overlap in PC space upon using only the third channel in Fig.\\ \\ref{3chpca}).  This suggests that borrowing strength across electrodes improves detection accuracy. Supplementary Fig.\\ \\ref{sfig:8} shows a similar plot for the eight channel data.  \n\n\n% In the tetrode case the waveform undoubtedly appears on all channels at once; it is possible to concatenate the channels to jointly process the data \\cite{wood2009}.  When the action potential will only appear on a subset of channels it is nice to allow the action potential to vary in a low-dimensional subset in each of the channels instead of a low-dimensional subset over all the channels. \\cite{Prentice2011}\n\n\n % The top 2 clusters found in the first 10 minutes of data on the 3-channel device are shown in Figures \\ref{ex31}, \\ref{ex32}.  The waveform in channel 3 is very similar for the waveforms in Fig.\\\\ref{ex31} and \\ref{ex32}, and would be difficult to separate if we were analyzing each channel individually; the representation of those two clusters in PCA space on channel 3 is shown in Fig.\\\\ref{chpca}.  We gain the ability to distinguish the waveforms by looking at all the channels simultaneously.  The top 3 clusters found in the 8-channel device can be found in Figures \\ref{ex81}, \\ref{ex82}, and \\ref{ex83}.\n\n\n\n\\begin{center}\n\\begin{SCfigure}[3]\n\t\\includegraphics[width=.3\\textwidth]{../figs/3devim/clus1}\n\t\\includegraphics[width=.3\\textwidth]{../figs/3devim/clus2}\n% \\begin{subfigure}[b]{.28\\textwidth}\n% \\includegraphics[width=\\textwidth]{../figs/3devim/clus1}\n% \\caption{}\n%\n% \\end{subfigure}\n% \\begin{subfigure}[b]{.28\\textwidth}\n% \\includegraphics[width=\\textwidth]{../figs/3devim/clus2}\n% \\caption{}\n% \\label{ex32}\n% \\end{subfigure}\n\\caption{\nImproving \\smug\\ by incorporating {multiple} channels.\nThe top 2 most prevalent waveforms from the NeuroNexus dataset with three channels.  Note that the left panel has a waveform that appears on both channel 2 and channel 3, whereas the waveform in the right panel  only appears in channel 3.  If only channel 3 was used, it would be difficult to separate these waveform.\n} \n\\end{SCfigure} \\label{ext31}\n\\end{center}\n\\vspace{-.1in}\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "f9dc463ff2c3d09d51d040feedbf777d869d29f6", "size": 18203, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/results.tex", "max_stars_repo_name": "jovo/online-spike-sorting", "max_stars_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/results.tex", "max_issues_repo_name": "jovo/online-spike-sorting", "max_issues_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/results.tex", "max_forks_repo_name": "jovo/online-spike-sorting", "max_forks_repo_head_hexsha": "24b8bac41bff449381c5c60a9d09ac40995035b5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.5144230769, "max_line_length": 1143, "alphanum_fraction": 0.7724001538, "num_tokens": 4583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4105057691299082}}
{"text": "\\chapter{Numerical Solution}\n\\label{chap:model_soln}\n\\index{Numerical Solution%\n@\\emph{Numerical Solution}}%\n\n\n\n%\\pagestyle{empty}\n\n\nWhen solving for the full transition path, we solve the model in two steps.  First, we solve for the steady state prices and allocations.  Next, we iterate backwards solving for prices and allocations along the transition path to the steady state.  Here we define the solution to the model, starting with the steady-state solution.\n\n\n\\section{Solving for stationary steady-state equilibrium}\\label{AppSSsolve}\n\n  This section describes the solution method for the stationary steady-state equilibrium described in Definition \\ref{DefEquilSS}.  To obtain the steady-state equilibrium, we do the following:\n  \n \n   \\begin{enumerate}\n    \\item Use the techniques in Chapter \\ref{AppPopGrowth} to solve for the steady-state population distribution vector $\\bm{\\bar{\\omega}}$ of the exogenous population process.\n    \\item Choose an initial guess for the stationary steady-state wage rate, $\\bar{w}$ and real interest rate, $\\bar{r}$.\n%      \\begin{itemize}\n%        \\item A good first guess is a large positive number for all the $\\bar{n}_{j,s}$ that is slightly less than $\\tilde{l}$ and to choose some small positive number for $\\bar{b}_{j,s+1}$ that is small enough to be less than the minimum income that an individual might have $\\bar{w}e_{j,s}\\bar{n}_{j,s}$.\n%      \\end{itemize}\n   \\item With $\\bar{w}$ and $\\bar{r}$, use an unconstrained root finder to solve the $4\\times 2 \\times M$ equations defining the steady-state version of the firms' problem.  This will yield $\\bar{I}_{m,c}$, $\\bar{EL}_{m,c}$, $\\bar{V}_{m,c}$, $\\bar{p}_{m,c}$.\n   \\item Using $\\bar{p}_{m,c}$ and the fixed coefficient matrix $\\Pi$, we can determine $\\bar{p}_{i}$, the price of consumption goods.\n   \\item $\\bar{p}_{i}$ and maximization of the consumer's subutility function imply $\\bar{p}_{s}$, the price of the composite consumption good.\n    \\item Perform an unconstrained root finder that chooses $\\bar{c}_{j,s}$ and $\\bar{b}_{j,s+1}$ that solves the $2JS$ stationary steady-state Euler equations.\n    \\item Make sure none of the implied steady-state consumptions $\\bar{c}_{j,s}+\\sum_{i=1}^{I}c_{i,s}$ exceeds income.\n      \\begin{itemize}\n        \\item If consumption exceeds income, the individual can not afford the minimum required consumption amounts.  We then...\n      \\end{itemize}\n    \\item Given consumption demand and the fixed coefficient matrix $\\Xi$, find the implied demand for output, $X_{m}$.\n    \\item Use the consumer's subutility function over corporate and non-corporate goods to determine demand for corporate and non-corporate production goods to get $X_{m,n}$ and $X_{m,nc}$.\n    \\item Make sure that demand for these production goods matches the supply given firm's decisions in (iii).\n    \\item Make sure that none of the Euler errors is too large in absolute value for interior stationary steady-state values. A steady-state Euler error is the following, which is supposed to be close to zero for all $j$ and $s$:\n      \\begin{align}\n        \\begin{split}\n          &\\frac{\\chi^n_{s}\\left(\\frac{b}{\\tilde{l}}\\right)\\left(\\frac{\\bar{n}_{j,s}}{\\tilde{l}}\\right)^{v-1}\\left[1 - \\left(\\frac{\\bar{n}_{j,s}}{\\tilde{l}}\\right)\\right]^{\\frac{1-v}{v}}}{(\\bar{c}_{j,s})^{-\\sigma}\\left(\\bar{w} e_{j,s} - \\frac{\\partial\\bar{T}_{j,s}}{\\partial \\bar{n}_{j,s}}\\right)} - 1 \\\\\n          &\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\forall j\\quad\\text{and}\\quad E+1\\leq s\\leq E+S\n        \\end{split} \\label{EqSSeulerrLab} \\\\\n        \\begin{split}\n          &\\frac{e^{-g_y\\sigma}\\left(\\rho_s\\chi^b \\left(\\bar{b}_{j,s+1}\\right)^{-\\sigma} + \\beta(1-\\rho_s)(\\bar{c}_{j,s+1})^{-\\sigma}\\left[(1 + \\bar{r}) - \\frac{\\partial \\bar{T}_{j,s+1}}{\\partial \\bar{b}_{j,s+1}}\\right]\\right)}{(\\bar{c}_{j,s})^{-\\sigma}} - 1 \\\\\n          &\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\forall j \\quad\\text{and}\\quad E+1\\leq s\\leq E+S-1 \\\\\n        \\end{split} \\label{EqSSeulerrSav} \\\\\n        &\\frac{\\chi^b e^{-g_y\\sigma}(\\bar{b}_{j,E+S+1})^{-\\sigma}}{\\left(\\bar{c}_{j,E+S}\\right)^{-\\sigma}} - 1 \\quad\\forall j \\label{EqSSeulerrBeq}\n      \\end{align}\n  \\end{enumerate}\n  \n   \n\n%FIRMS STUFF:\n%\\section{Solving the model}\n%\n%\n%\\subsection{Solving for the steady state}\n%\n%On the supply side (with one sector), we have to solve for the factor prices, $\\bar{i}$ and $bar{w}$ (the price of output $\\bar{p}^{C}$ is normalized to one), the shadow price of capital, $\\bar{q}^{C}$, and the allocations $\\bar{EL}^{C}$, $\\bar{K}^{C}$, $\\bar{I}^{C}$.  From these all the other variables follow trivially.  \n%\n%Start by solving for the steady-states of Equations \\ref{eqn:opt_i} and \\ref{eqn:foc_k}.  Equation \\ref{eqn:opt_i} becomes:\n%\n%\\begin{equation}\n%\\label{eqn:opt_i_ss}\n%\\bar{q}^{C}=\\underbrace{1-b^{C}-\\bar{\\Omega}^{C}\\bar{\\tau}^{b}(f_{e}-f_{b}b^{C})-f_{d}(1-f_{e})\\bar{Z}^{C}}_{\\text{function of only parameters}}\n%\\end{equation}\n%\n%This yields the solution to $\\bar{q}^{C}$.\n%\n%Next, consider the steady-state of Equation \\ref{eqn:foc_k}:\n%\n%\\begin{equation}\n%\\label{eqn:foc_k_ss}\n%\\bar{q}^{C}=\\frac{1}{1+\\bar{\\theta}}\\left[(1-\\delta^{C})\\bar{q}^{C} + \\frac{\\partial \\bar{X}^{C}}{\\partial \\bar{K}^{C}} - \\{(1-\\bar{\\tau}^{b})\\bar{\\Omega}^{C}\\bar{\\tau}^{pC} + (1-f_{i}\\bar{\\tau}^{i})\\bar{i}\\bar{\\Omega}^{C}b^{C} - \\delta^{C}(1-b^{C}-\\bar{\\Omega}^{C}(1-f_{p}\\bar{\\tau}^{b}b^{C}))\\}\\right]\n%\\end{equation}\n%\n%We can rearrange this and solve for the steady-state marginal product of capital in sector $C$:\n%\n%\\begin{equation}\n%\\label{eqn:mpk_ss}\n%\\frac{\\partial \\bar{X}^{C}}{\\partial \\bar{K}^{C}} = (\\bar{\\theta}+\\delta^{C})\\bar{q}^{C} + (1-\\bar{\\tau}^{b})\\bar{\\Omega}^{C}\\bar{\\tau}^{pC} + (1-f_{i}\\bar{\\tau}^{i})\\bar{i}\\bar{\\Omega}^{C}b^{C} - \\delta^{C}(1-b^{C}-\\bar{\\Omega}^{C}(1-f_{p}\\bar{\\tau}^{b}b^{C}))\n%\\end{equation}\n%\n%Notice that given Equation \\ref{eqn:opt_i_ss}, the RHS to the above equation is function of parameters and the steady state nominal interest rate, $\\bar{i}$.  The LHS of the equation is a function of $\\bar{K}^{C}$ and $\\bar{EL}^{C}$.\n%\n%I think we can use the following to identify the SS values of the variables of interest:\n%\\begin{enumerate}\n%\\item $\\bar{i}$ will be determined by the SS of the household's Euler equations (I think this can be done as described in the HH sol'n method)\n%\\item $\\bar{w}$ will be determined by the SS of the household's FOCs for labor supply ((I think this can be done as described in the HH sol'n method)\n%\\item $\\bar{q}^{C}$ is determined by Equation \\ref{eqn:opt_i_ss}\n%\\item $\\bar{EL}^{C}$ is determined by the SS version of Equation \\ref{eqn:foc_l}, plus $\\bar{w}$\n%\\item $\\bar{K}^{C}$ is determined by Equation \\ref{eqn:mpk_ss} and $\\bar{i}$\n%\\item $\\bar{I}^{C}$ is then solved for using the steady state law of motion for capital $\\implies \\bar{I}^{C}=\\delta^{C}\\bar{K}^{C}$\n%\\end{enumerate}\n%\n%In solving for $\\bar{EL}^{C}$ and $\\bar{K}^{C}$, note that we'll have use the MPK and the MPL simultaneously.  Given our production function, we have:\n%\n%\\begin{equation}\n%\\label{eqn:mpk}\n%\\frac{\\partial X^{C}_{u}}{\\partial K^{C}_{u}} = \\left[(\\gamma_{C})^{1/\\epsilon_{C}}(K^{C}_{u})^{(\\epsilon_{C}-1)/\\epsilon_{C}}+(1-\\gamma_{C})^{1/\\epsilon_{C}}(EL^{C}_{u})^{(\\epsilon_{C}-1)/\\epsilon_{C}}\\right]^{1/(\\epsilon_{C}-1)}(\\gamma_{C})^{1/\\epsilon_{C}}(K^{C}_{u})^{-1/\\epsilon_{C}}\n%\\end{equation}\n%\n%and \n%\n%\\begin{equation}\n%\\label{eqn:mpl}\n%\\frac{\\partial X^{C}_{u}}{\\partial EL^{C}_{u}} = \\left[(\\gamma_{C})^{1/\\epsilon_{C}}(K^{C}_{u})^{(\\epsilon_{C}-1)/\\epsilon_{C}}+(1-\\gamma_{C})^{1/\\epsilon_{C}}(EL^{C}_{u})^{(\\epsilon_{C}-1)/\\epsilon_{C}}\\right]^{1/(\\epsilon_{C}-1)}(1-\\gamma_{C})^{1/\\epsilon_{C}}(EL^{C}_{u})^{-1/\\epsilon_{C}}\n%\\end{equation}\n%\n%We know that, at an optimum, the marginal revenue product of labor equals the wage rate, and the marginal revenue product of capital equals a function of the interest rate, marginal $q$, and the model parameters.  Call this function $g(i_{u},q^{C}_{u},q^{C}_{u-1},\\Theta)$.  We thus have $p^{C}_{u}\\frac{\\partial X^{C}_{u}}{\\partial EL^{C}_{u}} =w_{u}$ and $p^{C}_{u}\\frac{\\partial X^{C}_{u}}{\\partial K^{C}_{u}}=g(i_{u},q^{C}_{u},q^{C}_{u-1},\\Theta)$.  Dividing these two equations, we have:\n%\n%\\begin{equation}\n%\\label{eqn:cap_lab_ratio}\n%\\begin{split}\n%& \\frac{\\frac{\\partial X^{C}_{u}}{\\partial K^{C}_{u}}}{\\frac{\\partial X^{C}_{u}}{\\partial EL^{C}_{u}}} =\\frac{(\\gamma_{C})^{1/\\epsilon_{C}}(K^{C}_{u})^{-1/\\epsilon_{C}}}{(1-\\gamma_{C})^{1/\\epsilon_{C}}(EL^{C}_{u})^{-1/\\epsilon_{C}}}-=\\frac{g(i_{u},q^{C}_{u},q^{C}_{u-1},\\Theta)}{w_{u}} \\\\\n%& \\implies \\frac{K^{C}_{u}}{EL^{C}_{u}} =\\frac{(1-\\gamma_{C})}{\\gamma_{C}}\\left(\\frac{w_{u}} {g(i_{u},q^{C}_{u},q^{C}_{u-1},\\Theta)}\\right)^{\\epsilon_{C}} \\\\\n%\\end{split}\n%\\end{equation}\n%\n%We can use the SS version of Equation \\ref{eqn:cap_lab_ratio} to solve for capital as function of labor (and $\\bar{q}, \\bar{i}, \\bar{w}$), and then use that in the SS version of Equation \\ref{eqn:mpl} to solve for labor as s function of $\\bar{q}, \\bar{i}, \\bar{w}$.  We then go back to the SS version of Equation \\ref{eqn:cap_lab_ratio} to get the SS choice of capital as a function of $\\bar{q}, \\bar{i}, \\bar{w}$.\n%\n%All of the above will work for each sector in a model with any number of sectors (though care has to be taken to include the prices of output and capital in those other sectors, since only one sector's output can be the numeraire).\n%\n%\\subsection{Solving for the transition path}\n%\n%I believe we can just use the Euler equations to go backwards in time, from the SS back along the transition path to $t=0$.  Assume period $T$ is the SS,  The solution would look like the following:\n%\n%\\begin{enumerate}\n%\\item Use Equation \\ref{eqn:foc_k} to solve for the for $q^{C}_{T-1}$ since we have the solution to the RHS of the equation after we've solved for the SS.\n%\\item Use the law of motion for capital to find: $K^{C}_{T-1}=\\frac{K^{C}_{T}-I^{C}_{T-1}}{(1-\\delta^{C})}=\\frac{\\bar{K}^{C}-I^{C}_{T-1}}{(1-\\delta^{C})}$\n%\\item Use Equation \\ref{eqn:opt_i} and the value of $q^{C}_{T-1}$ to find $I^{C}_{T-1}$ (and $K^{C}_{T-1}$ given the law of motion relationship.\n%\\item Given $w_{T-1}$ we can use the FOC for labor demand to find $EL^{C}_{T-1}$\n%\\item Given $i_{T-1}$ we can use Equation \\ref{eqn:foc_k} to solve for $q^{C}_{T-2}$ \n%\\item We then repeat the above steps until we work back to $t=0$.\n%\\end{enumerate}\n%\n%\n%\n%To solve for any stationary non-steady-state equilibrium time path of the economy from an arbitrary current state to the steady state, we follow the time path iteration (TPI) method of \\citet{AuerbachKotlikoff:1987}. Appendix \\ref{AppNonSSsolve} details how to solve for the non-steady-state equilibrium time path using the TPI method. The approach is to choose an arbitrary time path for the stationary aggregate capital stock $\\hat{K}_t$, stationary aggregate labor $\\hat{L}_t$, and total bequests received $\\hat{BQ}_{j,t}$ for each type $j$. This initial guess of a path implies arbitrary beliefs that violate the rational expectations requirement. We then solve for households' optimal decisions given the time paths of those variables, which decisions imply new time paths of those variables. We then update the time path as a convex combination of the initial guess and the new implied path. Figure \\ref{FigKpathTPI} shows the equilibrium time path of the aggregate capital stock for the calibration described in Table \\ref{TabExogVars} for $T=160$ periods starting from an initial distribution of savings in which $b_{j,s,1}=\\bm{\\bar{\\Gamma}}$ for all $j$ and $s$ in the case that no policy experiment takes place. The initial capital stock $\\hat{K}_1$ is not at the steady state $\\bar{K}$ because the initial population distribution is not at the steady-state.\n%\n%\n%\n%\n\n\\section{Solving for stationary non-steady-state equilibrium by time path iteration}\\label{AppNonSSsolve}\n\n  \\setcounter{equation}{0}\n\n  This section outlines the benchmark time path iteration (TPI) method of \\citet{AuerbachKotlikoff:1987} for solving the stationary non-steady-state equilibrium transition path of the distribution of savings. TPI finds a fixed point for the transition path of the distribution of capital for a given initial state of the distribution of capital. The idea is that the economy is infinitely lived, even though the agents that make up the economy are not. Rather than recursively solving for equilibrium policy functions by iterating on individual value functions, one must recursively solve for the policy functions by iterating on the entire transition path of the endogenous objects in the economy (see \\citet[ch. 17]{StokeyLucas:1989}).\n\n  The key assumption is that the economy will reach the steady-state equilibrium described in Definition \\ref{DefEquilSS} in a finite number of periods $T<\\infty$ regardless of the initial state. Let $\\bm{\\hat{\\Gamma}}_t$ represent the distribution of stationary savings at time $t$.\n  \\begin{equation}\\tag{\\ref{EqSavDist}}\n    \\bm{\\hat{\\Gamma}}_t \\equiv \\Bigl\\{\\bigl\\{\\hat{b}_{j,s,t}\\bigr\\}_{j=1}^J\\Bigr\\}_{s=E+2}^{E+S+1}, \\quad\\forall t\n  \\end{equation}\n  In Section \\ref{SecMCEqlbm}, we describe how the stationary non-steady-state equilibrium time path of allocations and price is described by functions of the state $\\bm{\\hat{\\Gamma}}_t$ and its law of motion. TPI starts the economy at any initial distribution of savings $\\bm{\\hat{\\Gamma}}_1$ and solves for its equilibrium time path over $T$ periods to the steady-state distribution $\\bm{\\bar{\\Gamma}}_T$.\n\n  The first step is to assume an initial transition path for aggregate stationary capital $\\bm{\\hat{K}}^i = \\left\\{\\hat{K}_1^i,\\hat{K}_2^i,...\\hat{K}_T^i\\right\\}$, aggregate stationary labor $\\bm{\\hat{L}}^i = \\left\\{\\hat{L}_1^i,\\hat{L}_2^i,...\\hat{L}_T^i\\right\\}$, and total bequests received $\\bm{\\hat{BQ}}_j^i=\\{\\hat{BQ}_{j,1}^i,\\hat{BQ}_{j,2}^i,...\\hat{BQ}_{j,T}^i\\}$ for each ability type $j$ such that $T$ is sufficiently large to ensure that $\\bm{\\hat{\\Gamma}}_T = \\bar{\\bm{\\Gamma}}$, $\\hat{K}_T^i\\left(\\bm{\\Gamma}_T\\right)$, $\\hat{L}_T^i\\left(\\bm{\\Gamma}_T\\right) = \\bar{L}\\left(\\bar{\\bm{\\Gamma}}\\right)$, and $\\hat{BQ}_{j,T}^i\\left(\\bm{\\Gamma}_T\\right) = \\bar{BQ}_j\\left(\\bar{\\bm{\\Gamma}}\\right)$ for all $t\\geq T$. The superscript $i$ is an index for the iteration number. The transition paths for aggregate capital and aggregate labor determine the transition paths for both the real wage $\\bm{\\hat{w}}^i = \\left\\{\\hat{w}_1^i,\\hat{w}_2^i,...\\hat{w}_T^i\\right\\}$ and the real return on investment $\\bm{r}^i = \\left\\{r_1^i,r_2^i,...r_T^i\\right\\}$. The time paths for the total bequests received also figure in each period's budget constraint and are determined by the distribution of savings and intended bequests.\n\n  The exact initial distribution of capital in the first period $\\bm{\\hat{\\Gamma}}_1$ can be arbitrarily chosen as long as it satisfies the stationary capital market clearing condition \\eqref{EqMktClrCapStat}.\n  \\begin{equation}\\label{EqMktClrCapStat1}\n    \\hat{K}_1 = \\frac{1}{1 + \\tilde{g}_{n,1}}\\sum_{s=E+2}^{E+S+1}\\sum_{j=1}^{J}\\hat{\\omega}_{s-1,0}\\lambda_j \\hat{b}_{j,s,1}\n  \\end{equation}\n  Simiilarly, each initial value of total bequests received $\\hat{BQ}_{j,1}^i$ must be consistent with the initial distribution of capital through the stationary version of \\eqref{EqTotBeq}.\n  \\begin{equation}\\label{EqTotBeqStat1}\n    \\hat{BQ}_{j,1} = \\frac{(1+r_1)\\lambda_j}{1+\\tilde{g}_{n,1}}\\sum_{s=E+1}^{E+S}\\rho_s\\hat{\\omega}_{s,0}\\hat{b}_{j,s+1,1} \\quad\\forall j\n  \\end{equation}\n  However, this is not the case with $\\hat{L}_1^i$. Its value will be endogenously determined in the same way the $K_2^i$ is. For this reason, a logical initial guess for the time path of aggregate labor is the steady state in every period $L_t^1 = \\bar{L}$ for all $1\\leq t\\leq T$.\n\n  It is easiest to first choose the initial distribution of savings $\\bm{\\hat{\\Gamma}}_1$ and then choose an initial aggregate capital stock $\\hat{K}_1^i$ and initial total bequests received $\\hat{BQ}_{j,1}^i$ that correspond to that distribution. As mentioned earlier, the only other restrictions on the initial transition paths for aggregate capital, aggregate labor, and total bequests received is that they equal their steady-state levels $\\hat{K}_T^i = \\bar{K}\\left(\\bm{\\bar{\\Gamma}}\\right)$, $\\hat{L}_T^i = \\bar{L}\\left(\\bm{\\bar{\\Gamma}}\\right)$, and $\\hat{BQ}_{j,T}^i = \\bar{BQ}_j\\left(\\bm{\\bar{\\Gamma}}\\right)$ by period $T$. \\citet{EvansPhillips:2014} have shown that the initial guess for the aggregate capital stocks $\\hat{K}_t^i$ for periods $1<t<T$ can take on almost any positive values satisfying the constraints above and still have the time path iteration converge.\n\n  Given the initial savings distribution $\\bm{\\hat{\\Gamma}}_1$ and the transition paths of aggregate capital $\\bm{\\hat{K}}^i = \\left\\{\\hat{K}_1^i,\\hat{K}_2^i,...\\hat{K}_T^i\\right\\}$, aggregate labor $\\bm{\\hat{L}}^i = \\left\\{\\hat{L}_1^i,\\hat{L}_2^i,...\\hat{L}_T^i\\right\\}$, and total bequests received $\\bm{\\hat{BQ}}_j^i = \\left\\{\\hat{BQ}_{j,1}^i,\\hat{BQ}_{j,2}^i,...\\hat{BQ}_{j,T}^i\\right\\}$, as well as the resulting real wage $\\bm{\\hat{w}}^i = \\left\\{\\hat{w}_1^i,\\hat{w}_2^i,...\\hat{w}_T^i\\right\\}$, and real return to savings $\\bm{r}^i = \\left\\{r_1^i,r_2^i,...r_T^i\\right\\}$, one can solve for the period-1 optimal labor supply and intended bequests for each type $j$ of $s=E+S$-aged agents in the last period of their lives $n_{j,E+S,1}=\\phi_{j,E+S}(\\hat{b}_{j,E+S,1},\\hat{BQ}_{j,E+S,1},\\hat{w}_1,r_1)$ and $\\hat{b}_{j,E+S+1,2}=\\psi_{j,E+S}(\\hat{b}_{j,E+S,1},\\hat{BQ}_{j,E+S,1},\\hat{w}_1,r_1)$ using his two $s=E+S$ static Euler equations \\eqref{EqEulerLabStat} and \\eqref{EqEulerSavEpSstat}.\n  \\begin{equation}\\label{EqEulerSlabt1}\n    \\begin{split}\n      &(\\hat{c}_{j,E+S,1})^{-\\sigma}\\Biggl(\\hat{w}_1^i e_{j,E+S} - \\frac{\\partial\\hat{T}_{j,E+S,1}}{\\partial n_{j,E+S,1}}\\Biggr) = ... \\\\\n      &\\qquad\\qquad\\qquad\\qquad \\chi^n_{E+S}\\biggl(\\frac{b}{\\tilde{l}}\\biggr)\\biggl(\\frac{n_{j,E+S,1}}{\\tilde{l}}\\biggr)^{v-1}\\Biggl[1 - \\biggl(\\frac{n_{j,E+S,1}}{\\tilde{l}}\\biggr)\\Biggr]^{\\frac{1-v}{v}} \\quad\\forall j \\\\\n      &\\quad\\text{where}\\quad \\hat{c}_{j,E+S,1} = ... \\\\\n      &\\qquad\\qquad\\qquad \\left(1 + r_1^i\\right)\\hat{b}_{j,E+S,1} + \\hat{w}_1^i e_{j,E+S}n_{j,E+S,1} + \\frac{\\hat{BQ}_{j,1}}{\\lambda_j} - e^{g_y}\\hat{b}_{j,E+S+1,2} - \\hat{T}_{j,E+S,1} \\\\\n      &\\quad\\text{and}\\quad \\frac{\\partial \\hat{T}_{j,E+S,1}}{\\partial n_{j,E+S,1}} = ... \\\\\n      &\\qquad\\qquad\\qquad \\hat{w}_1^i e_{j,E+S}\\biggl[\\tau^I\\bigl(F\\hat{a}_{j,E+S,1}\\bigr) + \\frac{\\hat{a}_{j,E+S,1}CDF\\bigl[2A(F\\hat{a}_{j,E+S,1})+B\\bigr]}{\\bigl[A(F\\hat{a}_{j,E+S,1})^2+B(F \\hat{a}_{j,E+S,1})+C\\bigr]^2} + \\tau^P\\Biggr]\n    \\end{split}\n  \\end{equation}\n  \\begin{equation}\\label{EqEulerSbeqt1}\n    (\\hat{c}_{j,E+S,1})^{-\\sigma} = \\chi^b e^{-g_y\\sigma}(\\hat{b}_{j,E+S+1,2})^{-\\sigma} \\quad\\forall j\n  \\end{equation}\n  Note that this is simply two equations \\eqref{EqEulerSlabt1} and \\eqref{EqEulerSbeqt1} and two unknowns $n_{j,E+S,1}$ and $\\hat{b}_{j,E+S+1,2}$.\n\n  We then solve the problem for all $j$ types of $E+S-1$-aged individuals in period $t=1$, each of which entails labor supply decisions in the current period $n_{j,E+S-1,1}$ and in the next period $n_{j,E+S,2}$, a savings decision in the current period for the next period $\\hat{b}_{j,E+S,2}$ and an intended bequest decision in the last period $\\hat{b}_{j,E+S+1,3}$. The labor supply decision in the initial period and the savings period in the initial period for the next period for each type $j$ of $E+S-1$-aged individuals are policy functions of the current savings and the total bequests received and prices in this period and the next $\\hat{b}_{j,E+S,2} = \\psi_{j,E+S-1}(\\hat{b}_{j,E+S-1,1},\\{\\hat{BQ}_{j,t},\\hat{w}_t,r_t\\}_{t=1}^2)$ and $\\hat{n}_{j,E+S-1,1} = \\phi_{j,E+S-1}(\\hat{b}_{j,E+S-1,1},\\{\\hat{BQ}_{j,t},\\hat{w}_t,r_t\\}_{t=1}^2)$. The labor supply and intended bequests decisions in the next period are simply functions of the savings, total bequests received, and prices in that period $\\hat{n}_{j,E+S,2} = \\phi_{j,E+S}(\\hat{b}_{j,E+S,2},\\hat{BQ}_{j,2},\\hat{w}_2,r_2)$ and $\\hat{b}_{j,E+S+1,3} = \\psi_{j,E+S}(\\hat{b}_{j,E+S,2},\\hat{BQ}_{j,2},\\hat{w}_2,r_2)$. These four functions are characterized by the following versions of equations \\eqref{EqEulerLabStat}, \\eqref{EqEulerSavStat}, and \\eqref{EqEulerSavEpSstat}.\n  \\begin{equation}\\label{EqEulerSm1labt1}\n    \\begin{split}\n      &(\\hat{c}_{j,E+S-1,1})^{-\\sigma}\\Biggl(\\hat{w}_1^i e_{j,E+S-1} - \\frac{\\partial\\hat{T}_{j,E+S-1,1}}{\\partial n_{j,E+S-1,1}}\\Biggr) = ... \\\\\n      &\\qquad\\qquad\\qquad \\chi^n_{E+S-1}\\biggl(\\frac{b}{\\tilde{l}}\\biggr)\\biggl(\\frac{n_{j,E+S-1,1}}{\\tilde{l}}\\biggr)^{v-1}\\Biggl[1 - \\biggl(\\frac{n_{j,E+S-1,1}}{\\tilde{l}}\\biggr)\\Biggr]^{\\frac{1-v}{v}} \\quad\\forall j\n    \\end{split}\n  \\end{equation}\n  \\begin{equation}\\label{EqEulerSm1savt1}\n    \\begin{split}\n      &(\\hat{c}_{j,E+S-1,1})^{-\\sigma} = ... \\\\\n      &e^{-g_y\\sigma}\\Biggl(\\rho_{E+S-1}\\chi^b \\bigl(\\hat{b}_{j,E+S,2}\\bigr)^{-\\sigma} + \\beta(1-\\rho_{E+S-1})(\\hat{c}_{j,E+S,2})^{-\\sigma}\\Biggl[(1 + r_2^i) - \\frac{\\partial T_{j,E+S,2}}{\\partial b_{j,E+S,2}}\\Biggr]\\Biggr) \\\\\n      &\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\qquad\\forall j \\\\\n      &\\qquad\\text{where}\\quad \\frac{\\partial T_{j,E+S,2}}{\\partial b_{j,E+S,2}} = ...\\\\\n      &\\qquad\\qquad r_2^i\\Biggl(\\tau^I(F\\hat{a}_{j,E+S,2}) + \\frac{F\\hat{a}_{j,E+S,2}CD\\left[2A(F\\hat{a}_{j,E+S,2}) + B\\right]}{\\left[A(F\\hat{a}_{j,E+S,2})^2 + B(F\\hat{a}_{j,E+S,2}) + C\\right]^2}\\Biggr) ... \\\\\n      &\\qquad\\qquad \\tau^W(\\hat{b}_{j,E+S,2}) + \\frac{\\hat{b}_{j,E+S,2}PHM}{\\left(H\\hat{b}_{j,E+S,2} + M\\right)^2}\n    \\end{split}\n  \\end{equation}\n  \\begin{equation}\\label{EqEulerSlabt2}\n    \\begin{split}\n      &(\\hat{c}_{j,E+S,2})^{-\\sigma}\\Biggl(\\hat{w}_2^i e_{j,E+S} - \\frac{\\partial\\hat{T}_{j,E+S,2}}{\\partial n_{j,E+S,2}}\\Biggr) = ... \\\\\n      &\\qquad\\qquad\\qquad \\chi^n_{E+S}\\biggl(\\frac{b}{\\tilde{l}}\\biggr)\\biggl(\\frac{n_{j,E+S,2}}{\\tilde{l}}\\biggr)^{v-1}\\Biggl[1 - \\biggl(\\frac{n_{j,E+S,2}}{\\tilde{l}}\\biggr)\\Biggr]^{\\frac{1-v}{v}} \\quad\\forall j\n    \\end{split}\n  \\end{equation}\n  \\begin{equation}\\label{EqEulerSsavt2}\n    (\\hat{c}_{j,E+S,2})^{-\\sigma} = \\chi^b e^{-g_y\\sigma}(\\hat{b}_{j,E+S+1,3})^{-\\sigma} \\quad\\forall j\n  \\end{equation}\n  Note that this is four equations \\eqref{EqEulerSm1labt1}, \\eqref{EqEulerSm1savt1}, \\eqref{EqEulerSlabt2}, and \\eqref{EqEulerSsavt2} and four unknowns $n_{j,E+S-1,1}$, $\\hat{b}_{j,E+S,2}$, $n_{j,E+S,2}$, and $\\hat{b}_{j,E+S+1,3}$.\n\n  This process is repeated for every age of household alive in $t=1$ down to the age $s=E+1$ household at time $t=1$. Each of these households $j$ solves the full set of remaining $S-s+1$ labor supply decisions, $S-s$ savings decisions, and one intended bequest decision at the end of life. After the full set of lifetime decisions has been solved for all the households alive at time $t=1$, each ability $j$ household born in period $t\\geq 2$ can be solved for, the solution to which is characterized by the following full set of Euler equations analogous to \\eqref{EqEulerLabStat}, \\eqref{EqEulerSavStat}, and \\eqref{EqEulerSavEpSstat}.\n  \\begin{equation}\\label{EqEulerslabt}\n    \\begin{split}\n      &(\\hat{c}_{j,s,t})^{-\\sigma}\\Biggl(\\hat{w}_t^i e_{j,s} - \\frac{\\partial\\hat{T}_{j,s,t}}{\\partial n_{j,s,t}}\\Biggr) =  \\chi^n_{s}\\biggl(\\frac{b}{\\tilde{l}}\\biggr)\\biggl(\\frac{n_{j,s,t}}{\\tilde{l}}\\biggr)^{v-1}\\Biggl[1 - \\biggl(\\frac{n_{j,s,t}}{\\tilde{l}}\\biggr)\\Biggr]^{\\frac{1-v}{v}} \\\\\n      &\\qquad\\qquad\\qquad\\qquad\\qquad\\forall j \\quad\\text{and}\\quad E+1\\leq s\\leq E+S\\quad\\text{and}\\quad t\\geq 2\n    \\end{split}\n  \\end{equation}\n\n  \\begin{equation}\\label{EqEulersSavt}\n    \\begin{split}\n      &(\\hat{c}_{j,s,t})^{-\\sigma} = ... \\\\\n      &e^{-g_y\\sigma}\\Biggl(\\rho_{s}\\chi^b \\bigl(\\hat{b}_{j,s+1,t+1}\\bigr)^{-\\sigma} + \\beta(1-\\rho_{s})(\\hat{c}_{j,s+1,t+1})^{-\\sigma}\\Biggl[(1 + r_{t+1}^i) - \\frac{\\partial T_{j,s+1,t+1}}{\\partial b_{j,s+1,t+1}}\\Biggr]\\Biggr) \\\\\n      &\\qquad\\qquad\\qquad\\forall j \\quad\\text{and}\\quad E+1\\leq s\\leq E+S-1 \\quad\\text{and}\\quad t\\geq 2\n    \\end{split}\n  \\end{equation}\n\n  \\begin{equation}\\label{EqEulerSsavt}\n    (\\hat{c}_{j,E+S,t})^{-\\sigma} = \\chi^b e^{-g_y\\sigma}(\\hat{b}_{j,E+S+1,t+1})^{-\\sigma} \\quad\\forall j \\quad\\text{and}\\quad t\\geq 2\n  \\end{equation}\n  For each household of ability type $j$ entering the economy in period $t\\geq 1$, the entire set of $2S$ lifetime decisions is characterized by the $2S$ equations represented in \\eqref{EqEulerslabt}, \\eqref{EqEulersSavt}, and \\eqref{EqEulerSsavt}.\n\n  We can then solve for the entire lifetime of savings and labor supply decisions for each age $s=1$ individual in periods $t=2,3,...T$. The central part of the schematic diagram in Figure \\ref{FigTPIdiag} shows how this process is done in order to solve for the equilibrium time path of the economy from period $t=1$ to $T$. Note that for each full lifetime savings and labor supply path solved for an individual born in period $t\\geq 2$, we can solve for the aggregate capital stock and total bequests received implied by those savings decisions $\\bm{\\hat{K}}^{i'}$ and $\\bm{\\hat{BQ}}_{j}^{i'}$ and aggregate labor implied by those labor supply decisions $\\bm{\\hat{L}}^{i'}$.\n\n  \\begin{figure}[p]\\centering \\captionsetup{width=4.0in}\n    \\caption{\\label{FigTPIdiag}\\textbf{Diagram of TPI solution method within each iteration for $S=4$ and $J=1$}}\n    \\fbox{\\resizebox{4.2in}{6.0in}{\\includegraphics{images/TPIdiag.pdf}}}\n  \\end{figure}\n\n\n  % THIS IS THE CODE FOR THE TABLE UNDERLYING THE FIGURE ABOVE\n  % \\begin{tabular}{>{\\footnotesize}l| >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c >{\\footnotesize}c}\n  %          & Initial & & & & & & & & Implied \\\\\n  %          & Aggr. & & \\multicolumn{5}{c}{Implied distribution of savings $\\bm{\\hat{\\Gamma}}_t$} & & Aggr. \\\\\n  %   Period & Paths    & & \\multicolumn{5}{c}{and labor supply}   & & Paths    \\\\\n  %   \\hline\n  %   & & & & & & & & & \\\\\n  %   $t=1$ & $\\begin{matrix}\\hat{K}_1^i, \\: \\hat{BQ}_{j,1}^i \\\\ \\hat{L}_1^i\\end{matrix}$ & $\\begin{matrix}= \\\\ \\rightarrow\\end{matrix}$ & $\\begin{matrix}\\: \\\\ n_{1,1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,1} \\\\ n_{2,1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,1} \\\\ n_{3,1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,1} \\\\ n_{4,1}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,1} \\\\ \\,\\end{matrix}$ & $\\begin{matrix}= \\\\ \\rightarrow\\end{matrix}$ & $\\begin{matrix}\\hat{K}_1^i, \\: \\hat{BQ}_{j,1}^{i'} \\\\ \\hat{L}^{i'}_1\\end{matrix}$ \\\\[10mm]\n  %   $t=2$ & $\\begin{matrix}\\hat{K}_2^i, \\: \\hat{BQ}_{j,2}^i \\\\ \\hat{L}^i_2\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,2} \\\\ n_{2,2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,2} \\\\ n_{3,2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,2} \\\\ n_{4,2}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,2} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_2^{i'}, \\: \\hat{BQ}_{j,2}^{i'} \\\\ \\hat{L}^{i'}_2\\end{matrix}$ \\\\[10mm]\n  %   $t=3$ & $\\begin{matrix}\\hat{K}_3^i, \\: \\hat{BQ}_{j,3}^i \\\\ \\hat{L}^i_3\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,3}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,3} \\\\ n_{2,3}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,3} \\\\ n_{3,3}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,3} \\\\ n_{4,3}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,3} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_3^{i'}, \\: \\hat{BQ}_{j,3}^{i'} \\\\ \\hat{L}^{i'}_3\\end{matrix}$ \\\\[10mm]\n  %   $t=4$ & $\\begin{matrix}\\hat{K}_4^i, \\: \\hat{BQ}_{j,4}^i \\\\ \\hat{L}^i_4\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,4}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,4} \\\\ n_{2,4}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,4} \\\\ n_{3,4}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,4} \\\\ n_{4,4}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,4} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_4^{i'}, \\: \\hat{BQ}_{j,4}^{i'} \\\\ \\hat{L}^{i'}_4\\end{matrix}$ \\\\[10mm]\n  %   $\\quad\\vdots$ & $\\vdots$ & & $\\vdots$ & $\\vdots$ & $\\vdots$ & $\\vdots$ & $\\vdots$ & & $\\vdots$ \\\\[10mm]\n  %   $t=T-2$ & $\\begin{matrix}\\hat{K}_{T-2}^i, \\: \\hat{BQ}_{j,T-2}^i \\\\ \\hat{L}^i_{T-2}\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,T-2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,T-2} \\\\ n_{2,T-2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,T-2} \\\\ n_{3,T-2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,T-2} \\\\ n_{4,T-2}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T-2} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_{T-2}^{i'}, \\: \\hat{BQ}_{j,T-2}^{i'} \\\\ \\hat{L}^{i'}_{T-2}\\end{matrix}$ \\\\[10mm]\n  %   $t=T-1$ & $\\begin{matrix}\\hat{K}_{T-1}^i, \\: \\hat{BQ}_{j,T-1}^i \\\\ \\hat{L}^i_{T-1}\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,T-1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,T-1} \\\\ n_{2,T-1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,T-1} \\\\ n_{3,T-1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,T-1} \\\\ n_{4,T-1}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T-1} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_{T-1}^{i'}, \\: \\hat{BQ}_{j,T-1}^{i'} \\\\ \\hat{L}^{i'}_{T-1}\\end{matrix}$ \\\\[10mm]\n  %   $t=T$ & $\\begin{matrix}\\hat{K}_{T}^i, \\: \\hat{BQ}_{j,T}^i \\\\ \\hat{L}^i_{T}\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\: \\\\ n_{1,T}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{2,T} \\\\ n_{2,T}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,T} \\\\ n_{3,T}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,T} \\\\ n_{4,T}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_{T}^{i'}, \\: \\hat{BQ}_{j,T}^{i'} \\\\ \\hat{L}^{i'}_{T}\\end{matrix}$ \\\\[10mm]\n  %   $t=T+1$ & $\\begin{matrix}\\hat{K}_{T+1}^i, \\: \\hat{BQ}_{j,T+1}^i \\\\ \\hat{L}^i_{T+1}\\end{matrix}$ & $\\rightarrow$ & $\\bullet$ & $\\begin{matrix}\\hat{b}_{2,T+1} \\\\ n_{2,T+1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{3,T+1} \\\\ n_{3,T+1}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,T+1} \\\\ n_{4,T+1}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T+1} \\\\ \\,\\end{matrix}$ & $\\rightarrow$ & $\\begin{matrix}\\hat{K}_{T+1}^{i'}, \\: \\hat{BQ}_{j,T+1}^{i'} \\\\ \\:\\end{matrix}$ \\\\[10mm]\n  %   $t=T+2$ & $\\begin{matrix}\\hat{K}_{T+2}^i, \\: \\hat{BQ}_{j,T+2}^i \\\\ \\hat{L}^i_{T+2}\\end{matrix}$ & $\\rightarrow$ & $\\bullet$ & $\\bullet$ & $\\begin{matrix}\\hat{b}_{3,T+2} \\\\ n_{3,T+2}\\end{matrix}$ & $\\begin{matrix}\\hat{b}_{4,T+2} \\\\ n_{4,T+2}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T+2} \\\\ \\,\\end{matrix}$ & & \\\\[10mm]\n  %   $t=T+3$ & $\\begin{matrix}\\hat{K}_{T+3}^i, \\: \\hat{BQ}_{j,T+3}^i \\\\ \\hat{L}^i_{T+3}\\end{matrix}$ & $\\rightarrow$ & $\\bullet$ & $\\bullet$ & $\\bullet$ & $\\begin{matrix}\\hat{b}_{4,T+3} \\\\ n_{4,T+3}\\end{matrix}$ & $\\begin{matrix}\\hat{bq}_{5,T+3} \\\\ \\,\\end{matrix}$ & & \\\\[10mm]\n  %   $t=T+4$ & $\\begin{matrix}\\hat{K}_{T+4}^i, \\: \\hat{BQ}_{j,T+4}^i \\\\ \\hat{L}^i_{T+4}\\end{matrix}$ & $\\rightarrow$ & $\\bullet$ & $\\bullet$ & $\\bullet$ & $\\bullet$ & $\\begin{matrix}\\hat{bq}_{5,T+4} \\\\ \\,\\end{matrix}$ & & \\\\\n  % \\end{tabular}\n  % \\clearpage\n\n  Once the set of lifetime saving and labor supply decisions has been computed for all individuals alive in $1\\leq t\\leq T$, we use the household decisions to compute a new implied time path of the aggregate capital stock and aggregate labor. The implied paths of the aggregate capital stock $\\bm{\\hat{K}}^{i'}=\\{\\hat{K}_1^i,\\hat{K}_2^{i'},...\\hat{K}_T^{i'}\\}$, aggregate labor $\\bm{\\hat{L}}^{i'}=\\{\\hat{L}_1^i,\\hat{L}_2^{i'},...\\hat{L}_T^{i'}\\}$, and total bequests received $\\bm{\\hat{BQ}}_j^{i'}=\\{\\hat{BQ}_{j,1}^i,\\hat{BQ}_{j,2}^{i'},...\\hat{BQ}_{j,T}^{i'}\\}$ in general do not equal the initial guessed paths $\\bm{\\hat{K}}^{i}=\\{\\hat{K}_1^i,\\hat{K}_2^{i},...\\hat{K}_T^{i}\\}$, $\\bm{\\hat{L}}^{i}=\\{\\hat{L}_1^i,\\hat{L}_2^{i},...\\hat{L}_T^{i}\\}$, and $\\bm{\\hat{BQ}}_j^{i}=\\{\\hat{BQ}_{j,1}^i,\\hat{BQ}_{j,2}^{i},...\\hat{BQ}_{j,T}^{i}\\}$ used to compute the household savings and labor supply decisions $\\bm{\\hat{K}}^{i'}\\neq\\bm{\\hat{K}}^i$, $\\bm{\\hat{L}}^{i'}\\neq\\bm{\\hat{L}}^i$, and $\\bm{\\hat{BQ}}_j^{i'}\\neq\\bm{\\hat{BQ}}_j^i$.\n\n  Let $\\norm{\\:\\cdot\\:}$ be a norm on the space of time paths of the aggregate capital stock $\\bm{\\hat{K}}\\in\\mathcal{K}\\subset\\mathbb{R}_{++}^T$, aggregate labor supply $\\bm{\\hat{L}}\\in\\mathcal{L}\\subset\\mathbb{R}_{++}^T$, and $J$ paths of total bequests received $\\bm{\\hat{BQ}}_j\\in\\mathcal{B}\\subset\\mathbb{R}_{++}^T$. Then the fixed point necessary for the equilibrium transition path from Definition \\ref{DefEquilNonSS} has been found when the distance between these $J+2$ paths is arbitrarily close to zero.\n  \\begin{equation}\\label{EqTPIconverge}\n    \\norm{\\Bigl[\\bm{\\hat{K}}^{i'}, \\bm{\\hat{L}}^{i'},\\bigl\\{\\bm{\\hat{BQ}}_j^{i'}\\bigr\\}_{j=1}^J\\Bigr] - \\Bigl[\\bm{\\hat{K}}^{i},\\bm{\\hat{L}}^{i},\\bigl\\{\\bm{\\hat{BQ}}_j^{i}\\bigr\\}_{j=1}^J\\Bigr]} \\leq \\ve \\quad\\text{for}\\quad \\ve>0\n  \\end{equation}\n  If the fixed point has not been found $\\norm{\\Bigl[\\bm{\\hat{K}}^{i'}, \\bm{\\hat{L}}^{i'},\\bigl\\{\\bm{\\hat{BQ}}_j^{i'}\\bigr\\}_{j=1}^J\\Bigr] - \\Bigl[\\bm{\\hat{K}}^{i},\\bm{\\hat{L}}^{i},\\bigl\\{\\bm{\\hat{BQ}}_j^{i}\\bigr\\}_{j=1}^J\\Bigr]} > \\ve$, then new transition paths for the aggregate capital stock and aggregate labor are generated as a convex combination of $\\Bigl[\\bm{\\hat{K}}^{i'},\\bm{\\hat{L}}^{i'},\\bigl\\{\\bm{\\hat{BQ}}_j^{i'}\\bigr\\}_{j=1}^J\\Bigr]$ and $\\Bigl[\\bm{\\hat{K}}^{i},\\bm{\\hat{L}}^{i},\\bigl\\{\\bm{\\hat{BQ}}_j^{i}\\bigr\\}_{j=1}^J\\Bigr]$.\n  \\begin{equation}\\label{EqTPInewpath}\n    \\begin{split}\n      \\bm{\\hat{K}}^{i+1} &= \\nu\\bm{\\hat{K}}^{i'} + (1-\\nu)\\bm{\\hat{K}}^{i} \\\\\n      \\bm{\\hat{L}}^{i+1} &= \\nu\\bm{\\hat{L}}^{i'} + (1-\\nu)\\bm{\\hat{L}}^{i} \\\\\n      \\bm{\\hat{BQ}}_1^{i+1} &= \\nu\\bm{\\hat{BQ}}_1^{i'} + (1-\\nu)\\bm{\\hat{BQ}}_1^{i} \\\\\n      &\\vdots \\\\\n      \\bm{\\hat{BQ}}_J^{i+1} &= \\nu\\bm{\\hat{BQ}}_J^{i'} + (1-\\nu)\\bm{\\hat{BQ}}_J^{i}\n    \\end{split} \\quad\\quad\\text{for}\\quad \\nu\\in(0,1]\n  \\end{equation}\n  This process is repeated until the initial transition paths for the aggregate capital stock, aggregate labor, and total bequests received are consistent with the transition paths implied by those beliefs and household and firm optimization.\n\n  In essence, the TPI method iterates on individual beliefs about the time path of prices represented by a time paths for the aggregate capital stock $\\bm{\\hat{K}}^i$, aggregate labor $\\bm{\\hat{L}}^i$, and total bequests received $\\bm{\\hat{BQ}}_j^i$ until a fixed point in beliefs is found that are consistent with the transition paths implied by optimization based on those beliefs.\n\n  The following are the steps for computing a stationary non-steady-state equilibrium time path for the economy.\n  \\begin{enumerate}\n    \\item Input all initial parameters. See Table \\ref{TabExogVars}.\n      \\begin{enumerate}\n        \\item The value for $T$ at which the non-steady-state transition path should have converged to the steady state should be at least as large as the number of periods it takes the population to reach its steady state $\\bm{\\bar{\\omega}}$ as described in Appendix \\ref{AppPopGrowth}.\n      \\end{enumerate}\n\n    \\item Choose an initial distribution of savings and intended bequests $\\bm{\\hat{\\Gamma}}_1$ and then calculat the initial state of the stationarized aggregate capital stock $\\hat{K}_1$ and total bequests received $\\hat{BQ}_{j,1}$ consistent with $\\bm{\\hat{\\Gamma}}_1$ according to \\eqref{EqMktClrCapStat} and \\eqref{EqTotBeqStat1}.\n      \\begin{enumerate}\n        \\item Note that you must have the population weights from the previous period $\\hat{\\omega}_{s,0}$ and the growth rate between period 0 and period 1 $\\tilde{g}_{n,1}$to calculate $\\hat{BQ}_{j,1}$.\n      \\end{enumerate}\n    \\item Conjecture transition paths for the stationarized aggregate capital stock $\\bm{\\hat{K}}^1=\\{\\hat{K}^1_t\\}_{t=1}^\\infty$, stationarized aggregate labor $\\bm{\\hat{L}}^1=\\{\\hat{L}^1_t\\}_{t=1}^\\infty$, and total bequests received $\\bm{\\hat{BQ}}_j^1=\\{\\hat{BQ}^{1}_{j,t}\\}_{t=1}^\\infty$ where the only requirements are that $\\hat{K}^i_1$ and $\\hat{BQ}^i_{j,1}$ are functions of the initial distribution of savings $\\bm{\\hat{\\Gamma}}_1$ for all $i$ is your initial state and that $\\hat{K}^i_t=\\bar{K}$, $\\hat{L}^i_t=\\bar{L}$, and $\\hat{BQ}^i_{j,t}= \\bar{BQ}_j$ for all $t\\geq T$. The conjectured transition paths of the aggregate capital stock $\\bm{\\hat{K}}^i$ and aggregate labor $\\bm{\\hat{L}}^i$ imply specific transition paths for the real wage $\\bm{\\hat{w}}^i=\\{\\hat{w}^i_t\\}_{t=1}^\\infty$ and the real interest rate $\\bm{r}^i=\\{r^i_t\\}_{t=1}^\\infty$ through expressions \\eqref{EqFOCwageStat} and \\eqref{EqFOCrate}.\n      \\begin{enumerate}\n        \\item An intuitive choice for the time path of aggregate labor is the steady-state in every period $\\hat{L}^1_t = \\bar{L}$ for all $t$.\n      \\end{enumerate}\n    \\item With the conjectured transition paths $\\bm{\\hat{w}}^i$, $\\bm{r}^i$, and $\\bm{\\hat{BQ}}_j^i$ one can solve for the lifetime policy functions of each household alive at time $1\\leq t\\leq T$ using the systems of Euler equations of the form \\eqref{EqEulerLabStat}, \\eqref{EqEulerSavStat}, and \\eqref{EqEulerSavEpSstat} and following the diagram in Figure \\ref{FigTPIdiag}.\n    \\item Use the implied distribution of savings and labor supply in each period (each row of $\\hat{b}_{j,s,t}$ and $n_{j,s,t}$ in Figure \\ref{FigTPIdiag}) to compute the new implied time paths for the aggregate capital stock $\\bm{\\hat{K}}^{i'} = \\{\\hat{K}_1^i,\\hat{K}_2^{i'},...\\hat{K}_T^{i'}\\}$, aggregate labor supply $\\bm{\\hat{L}}^{i'} = \\{\\hat{L}_1^i,\\hat{L}_2^{i'},...\\hat{L}_T^{i'}\\}$, and total bequests received $\\bm{\\hat{BQ}}_j^{i'} = \\{\\hat{BQ}_{j,1}^i,\\hat{BQ}_{j,2}^{i'},...\\hat{BQ}_{j,T}^{i'}\\}$.\n    \\item Check the distance between the two sets time paths.\n      \\begin{equation*}\n        \\norm{\\Bigl[\\bm{\\hat{K}}^{i'}, \\bm{\\hat{L}}^{i'},\\bigl\\{\\bm{\\hat{BQ}}_j^{i'}\\bigr\\}_{j=1}^J\\Bigr] - \\Bigl[\\bm{\\hat{K}}^{i},\\bm{\\hat{L}}^{i},\\bigl\\{\\bm{\\hat{BQ}}_j^{i}\\bigr\\}_{j=1}^J\\Bigr]}\n      \\end{equation*}\n      \\begin{enumerate}\n        \\item If the distance between the initial time paths and the implied time paths is less-than-or-equal-to some convergence criterion $\\ve>0$, then the fixed point has been achieved and the equilibrium time path has been found \\eqref{EqTPIconverge}.\n        \\item If the distance between the initial time paths and the implied time paths is greater than some convergence criterion $\\norm{\\cdot}>\\ve$, then update the guess for the time paths according to \\eqref{EqTPInewpath} and repeat steps (4) through (6) until a fixed point is reached.\n      \\end{enumerate}\n  \\end{enumerate}\n\n", "meta": {"hexsha": "2bdcd042303e58179588eda52a1d3db098803323", "size": 38519, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Model Writeup/Model_soln.tex", "max_stars_repo_name": "lnsongxf/OG-USA", "max_stars_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-05-23T13:57:53.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-23T13:57:53.000Z", "max_issues_repo_path": "Model Writeup/Model_soln.tex", "max_issues_repo_name": "lnsongxf/OG-USA", "max_issues_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Model Writeup/Model_soln.tex", "max_forks_repo_name": "lnsongxf/OG-USA", "max_forks_repo_head_hexsha": "9e92129e67f4aea5f3a6b8da4110bf67b99ce88a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-03T19:06:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-03T19:06:24.000Z", "avg_line_length": 123.4583333333, "max_line_length": 1369, "alphanum_fraction": 0.6506139827, "num_tokens": 14149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4105057616094565}}
{"text": "\\subsubsection{Scalable Nonparametric Directed Graphical Model Inference\nand Learning}\n\nAuthor: Kai Londenberg (Kai.Londenberg@gmail.com), June 2014\n\n\\paragraph{Abstract}\n\nThis short article tries to give an overview over complementary\ntechniques over MCMC for general inference in arbitrary directed\nprobabilistic graphical models. The focus lies on techniques and\nalgorithms for creating hybrid models which can be scaled to high\n\ndimensional problems, problems with huge data sets and distributed among\nmultiple machines.\n\n\\paragraph{Motivation}\n\nTwo papers got me thinking:\n\\href{http://www.dauwels.com/Papers/Particle.pdf}{Dauwels et al:\nParticle Methods as Message Passing}, which gives a nice overview of how\nto generalize Message Passing methods, by mixing sampling based methods\nfreely with exact or fast approximate inference algorithms.\n\nThe second is \\href{http://arxiv.org/pdf/1311.4780v1.pdf}{Neiswanger et\nal: Embarassingly Parallel MCMC}, where an algorithm is described which\ncan be used to scale MCMC to problems with huge data sets.\n\nBoth algorithms actually suffer from the same problem, namely the\n\\textbf{Message Fusion} problem (described way down). A problem which\nhas luckily been successfully solved before. I add to that list by\nproposing a new approach to efficient density estimation from MCMC\nmodels, called \\textbf{Density Mapping}\n\nWhat I hope is, that these ideas can lead to a practical implementation\nof a general, flexible inference system with semantics similar to those\nfound in common MCMC packages for Bayesian Inference, but with the\ncapability to outperform these for problems with huge data sets or a\nlarge number of dimensions if the distribution can be factorized into\nsmaller problems somehow.\n\nI hope to be able to extend the existing Bayesian Modeling Toolkit for\nPython \\href{https://github.com/pymc-devs/pymc}{PyMC3} via my\nside-project \\href{https://github.com/kadeng/pypgmc}{PyPGMc} to support\nthe algorithms mentioned in this article.\n\nSo this article is both an overview, and sort of a collection of ideas\nand roadmap items.\n\n\\paragraph{Introduction to Directed Graphical Models}\n\nDirected Probabilistic Graphical Models (DGMs) provide a flexible and\npowerful framework for probabilistic reasoning. In all generality, they\nare a way to efficiently represent complex probability distributions in\nhigh dimensional spaces by factorizing the joint distribution into\nconditional distributions.\n\nGiven a set of random variables \\$ x\\_i \\sim X\\_i \\$ and their joint\nrandom vector \\$ x \\sim X \\$ with \\$ x = \\{ x\\_1, \\ldots, x\\_N \\} \\$ we\nrepresent their joint distribution as the product of a set of\nconditional distributions\n\n\\[\nP(X) = \\prod_i^N P_i(X_i|{pa}(X_i)\n\\]\n\nWhere \\$ pa(X\\_i) \\$ is the set of parents of variable \\$ X\\_i \\$ in a\ndirected graph \\$ G \\$, where each vertex in the graph represents one of\nthe random variables.\n\nEach vertex in this graph could assign an arbitrary probability\ndistribution to it's random variables. But this probability distribution\nmay only depend on the parents of the variable in the graph.\n\nSuch a representation has many advantages, even to list them completely\nwould be out of the scope of this article. An excellent overview is\npresent in the book\n\\href{http://mitpress.mit.edu/books/probabilistic-\\%20graphical-models}{Probabilistic\nGraphical Models} by Daphne Koller, who also offers a\n\\href{https://www.coursera.org/course/pgm}{Coursera course} by the same\nname, which is highly recommended.\n\n\\paragraph{D-Separation / Conditional Independence}\n\nMost importantly, the graph encodes information about (conditional)\nindependencies among the variables. By a property called D-Separation\nwhich can be determined using a few simple rules, we can safely\ndetermine whether the probability distribution of a given set of\nvariables in the graph can be affected by changes in the probability of\nanother set of variables \\textbf{given} another set of variables which\nare held fixed.\n\nIf the conditional dependencies that hold over a joint probability\ndistribution are a subset of the conditional independence assumptions\nmade by the graph, this distribution is compatible to the graph in the\nsense that the distribution can be faithfully represented by a\nfactorization of the distribution along that graph.\n\n\\paragraph{Causal Models}\n\nA very common form of these models is to restrict parent / child\nrelationships to cause/effect pairs. Furthermore, the network must be\ncomplete in the sense that no common causes of any two variables are\nmissing from the model.\n\nWhile it is not neccessary for the machinery of DGMs to work that they\nare causal models, this can, under certain circumstances, be used to\nperform so called causal inference or causal reasoning using DGMs. More\non that can be found in Judea Pearl's excellent book on\n\\href{http://bayes.cs.ucla.edu\\%20/BOOK-2K/}{Causality}.\n\nOne important rule to note is, that in order to perform causal inference\nin such a causal network, i.e.~to estimate the impact of an explicit\n\\textbf{action} where the value of a variable is forced to have a\ncertain value (in contrast to observing it having that value) it is\nneccessary to sever all ties from the parents of said variable to it\n(since they are no longer causally connected). Furthermore, the network\n\nIn Pearl's see/do calculus, he discerns between \\$ P(x\\textbar{}y) \\$ (\nprobability of x given that I \\emph{see} $y$ ) and \\$\nP(x\\textbar{}do(y)) \\$ ( probability of x given that I \\emph{do} x).\n\nWhile not of further concern here, Pearl provides a great deal of\ninformal insights and formal rules into when and how observations can be\nconverted into causal claims, how to transfer the results of studies\nfrom one setting to another.\n\n\\paragraph{Common types of DGMs}\n\nSome common types of DGMs that you might have heard about include:\n\n\\begin{itemize}\n\\item\n  Bayesian Networks (BNs)\n\\item\n  Hierarchical Bayesian Models\n\\item\n  (Gaussian) Mixture Models (GMMs)\n\\end{itemize}\nAlso a lot of common models for time-series can be thought of as DGMs,\namong them:\n\n\\begin{itemize}\n\\item\n  Vector Auto-Regressive Models (VAR)\n\\item\n  Hidden Markov Models (HMMs)\n\\item\n  State Space Models (SSM)\n\\item\n  Dynamic Bayesian Networks (DBNs)\n\\end{itemize}\nMany of these models have their own set of specialized inference and\nlearning algorithms, their own set of advantages and disadvantages.\n\n\\paragraph{Inference / Reasoning in Graphical Models}\n\nGenerally speaking, we can use these graphical models to reason about\nthe marginal probability distributions, most likely configurations (MLE\n/ MAP configurations) etc. of variables of interest \\textbf{given\nevidence}. This in turn can be used in many applications, from decision\nsupport (making decisions under uncertainty) and as a key component for\nsupervised, unsupervised and semi- supervised learning.\n\n\\paragraph{Parametric VS Nonparametric representations}\n\nIf we can restrict our probability distributions to come from specifiy\nfamilies of distributions, inference can be made very efficient in some\ncases. But if you want to have a general model which can capture any\nkind of weird multi-modal and non-continous distributions, you are\nlimited to very slow inference using MCMC methods. Also, the scalability\nin these cases is very limited, because most MCMC algorithms are not\nmade to be distributed.\n\n\\textbar{} Family \\textbar{} Advantages \\textbar{} Disadvantages\n\\textbar{}\n\\textbar{}------------------------------------------\\textbar{}----------------\\textbar{}-------------------\n--------------------------------------------------------------------------------\n-----------------------------------------------------------------------\\textbar{}\n\\textbar{} Conditional Linear Gaussian (CLG) \\textbar{} Very Fast\n\\textbar{} Are your distributions linear combinations of gaussians ?\n\\textbar{} \\textbar{} Discrete (Categorical) \\textbar{} Fast \\textbar{}\nHigh number of parameters if number of parents of any variable, or\nnumber of discrete ``bins'' of variables becomes too large. Quickly\nbecomes intractable in these cases. \\textbar{} \\textbar{} Generic\n(arbitrary functions of parents) \\textbar{} Most Flexible \\textbar{}\nVery slow inference (MCMC) or strongly biased approximate inference,\nhard to determine convergence / mixing. Usually intractable in high\ndimensions. \\textbar{}\n\n\\paragraph{Hierarchical Bayesian Models and MCMC}\n\nIn Bayesian Hierarchical Modeling, we are usually either interested in\nestimating marginals of certain model parameters in order to gain\ninsights into specific problems, or we are interested in evaluating the\nexpected value of some (utility- or loss-) function over the posterior\nof a set of random variables.\n\nGiven that in the Bayesian view, the unknown parameters of a model are\nrandom variables like any other, so we can use the machinery of DGM\ninference. Since these models can have almost arbitrary functional\nrelations between variables, it is commong to perform Markov Chain Monte\nCarlo simulation to sample from the posterior distribution.\n\nWhat is problematic about these methods is that inference is usually\nslow, and it is hard to determine whether the model has converged\n(mixed) to a stable posterior. Generally, MCMC does not scale well to\nhigh-dimensional problems using established methods (yet), despite the\nfact that there have been some special areas where MCMC methods could be\napplied to solve high dimensional problems such as large scale matrix\nfactorization for recommender systems.\n\nMCMC, while an approximate approach, is asymptotically exact if applied\ncorrectly.\n\n\\paragraph{Message Passing Algorithms}\n\nAmong the most efficient algorithms for exact and approximate inference\nin discrete and conditional linear gaussian DGMs are so called Message\nPassing (MP) or Belief Propagation Algorithms. These algorithms operate\non a so-called factor graph, which is very similar to a DGM, except that\nvertices (factors) may represent joint distributions of multiple\nvariables. If factors share variables, they have to be connected (at\nleast indirectly) using a chain of factors where each factor contains\nthat variable.\n\nCorrespondingly, edges (along which messages are passed) need to be able\nto convey information about joint distributions of several variables at\nonce.\n\nBy collapsing a DGM into a factor graph tree (so called Clique Tree or\nJunction Tree), it is possible to perform efficient exact inference on\ndiscrete and conditional linear gaussian networks using message passing\ninference. That is, unless the resulting tree has at some point a too\nlarge tree-width (loosely, the result of a large but too dense graph),\nwhich can make exact inference intractable.\n\nEven in those cases where exact inference is intractable, the Loopy\nBelief Propagation algorithm can provide very fast approximate\n(asymptotically biased) inference, providing good solutions (empirical\nresults) in cases where other algorithms fail or are too slow.\n\nIt is important to note that the core algorithm (message passing) of\napproximate Loopy Belief Propagation and exact Clique Tree Inference are\nthe same.\n\nAgain, I refer to the book\n\\href{http://mitpress.mit.edu/books/probabilistic-graphical-models}{Probabilistic\nGraphical Models} by Daphne Koller and her\n\\href{https://www.coursera.org/course/pgm}{Coursera course} for details.\n\n\\paragraph{Nonparametric and Particle Belief Propagation / Message\nPassing}\n\nAs Dauwels et al. have pointed out in the Paper\n\\href{http://www.dauwels.com/Papers/Particle.pdf}{Particle Methods as\nMessage Passing}, it is actually possible to combine parametric exact\ninference and nonparametric approximate inference by using\n\\textbf{Particle Lists} as messages in the message passing algorithm.\n\nThey used this approach to show that it is possible to view common MCMC\nprocedures such as Gibbs Sampling, Metropolis Hastings and Importance\nSampling as special cases of \\textbf{Particle Message Passing}.\n\nWhat is also important here: Each factor \\textbf{could be an independend\nMCMC sampler working on a subset of the variables and / or evidence}. Or\na faster parametric inference algorithm, if the problem allows.\n\nOther fast inference algorithms such as \\textbf{Expectation Propagation}\nand other Forms of Variational Inference such as \\textbf{Mean-Field}\nbased method can be also be cast as variants of Message Passing\nprocedures.\n\nThere are several key papers which describe important aspects and\napproaches that might be taken:\n\n\\begin{itemize}\n\\item\n  \\href{http://www.dauwels.com/Papers/Particle.pdf}{Dauwels et Al:\n  Particle Methods as Message Passing}\n\\item\n  \\href{http://ssg.mit.edu/nbp/papers/nips03.pdf}{Ihler, Sudderth et al:\n  Nonparametric Belief Propagation}\n\\item\n  \\href{http://ssg.mit.edu/nbp/papers/nips03.pdf}{Ihler, Sudderth et al:\n  Efficient Multiscale Sampling from Products of Gaussian Mixtures}\n\\item\n  \\href{http://machinelearning.wus\\%20tl.edu/mlpapers/paper\\_files/AISTATS09\\_IhlerM.pdf}{Ihler,\n  Mc. Allister: Particle Belief Propagation}\n\\item\n  \\href{http://robotics.stanford.edu/~koller/Papers/Koller+al:UAI99.pdf}{Koller\n  et al: A General Algorithm for Approximate Inference and Its\n  Application to Hybrid Bayes Nets}\n\\end{itemize}\n\\subparagraph{The Message Fusion Problem}\n\nAll of the above papers identify a single performance bottleneck in\nthese algorithms.\n\nIf we have two factors which share at least one continuous variable \\$ x\n\\$ with a smoot pdf, the probability that two factors will independently\nchoose the same value for that variable is essentially zero.\n\nSo if we have two factors represented using discrete particle lists \\$\n\\phi(x) \\$ and \\$ \\theta(x) \\$, their product will be zero with near\ncertainty everywhere.\n\nWhat we need to do is to perform so called \\textbf{Message Fusion}, for\nwhich several approaches have been proposed.\n\nThe standard approach is to use some form of \\textbf{Kernel Density\nEstimation} (KDE), which effectively represents each particle/sample not\nas a discrete probability spike, but smoothes the density using an\nappropriate kernel. Usually, Gaussian Kernels are used. Given an\nefficient sampling procedure from products of Gaussian Mixtures, such as\n\\href{http://ssg.mit.edu/nbp/papers/nips03.pdf}{Ihler, Sudderth et al:\nEfficient Multiscale Sampling from Products of Gaussian Mixtures}, we\ncan efficiently sample from these. More on that approach is found in\n\\href{http://ssg.mit.edu/nbp/papers/nips03.pdf}{Ihler, Sudderth et al:\nNonparametric Belief Propagation}\n\nBut a problem remains: It's computationally expensive to evaluate the\nprobability density and curvature (Jacobian and Hessian) of these\nmessages. And that might be important if we would like to sample from a\nproduct of such a mixture density message with the probability density\nfunction of a factor.\n\n\\paragraph{Particle Belief Propagation Approach}\n\nIn\n\\href{http://machinelearning.wus\\%20tl.edu/mlpapers/paper\\_files/AISTATS09\\_IhlerM.pdf}{Ihler,\nMc. Allister: Particle Belief Propagation} it has been proposed to\nsample from the particles in the messages themselves. This is similar to\nwhat happens in \\textbf{Particle Filters}. While potentially a good\nidea, it (like Particle Filters) suffers from the \\emph{thinning}\nproblem: If the message and the factor do not agree, the number of\nuseable particles gets very low and the procedure produces unreliable\nand/or inaccurate results.\n\nLike with Particle Filters, one approach to fix this problem is to use\n\\textbf{resampling}. That is, loosely speaking, we tell the original\nfactor where we got the message from, that we would like to have samples\nof a finer resolution in certain regions. Then the original factor\nreplies with a new (importance sampled) message list, where it provides\nnew samples, with more (but downweighted) samples in the corresponding\nregions of interest.\n\nThis procedure can already provide accurate distributed inference. It\njust has one problem: It is probably pretty slow (all this re-sampling)\nand requires lots of communication.\n\nIf we let the numbers of particles in each list become low, it can be\nseen as a form of Gibbs Sampling where we exchange not just one particle\n(the sample), but multiple of them.\n\nThis procedure, as inefficient as it might seem, might have a distinct\nadvantage over most MCMC Algorithms: \\textbf{It allows for much easier\nconvergence diagnostics}. By measuring the convergence on a per-message\nlevel, we can probably automatically determine when the algorithm has\nconverged to a final solution, given that we can determine this for each\nfactor individually.\n\nWhile this sounds not so much of a great deal, actually it is: For MCMC\nyou usually need a human expert who decides if the numbers of samples\nhave been sufficient, if all relevant states have been visited etc. But\neven then, that person can never be sure. Much the less, if the problem\ngets high-dimensional. Having a clear convergence diagnostic opens the\ndoor for novel applications in large scale risk analysis.\n\n\\paragraph{Compact Message Density Estimation for Message Fusion}\n\nAnother approach, which has also been taken or at least proposed by\nseveral researchers ( see\n\\href{http://mach\\%20inelearning.wustl.edu/mlpapers/paper\\_files/AISTATS09\\_IhlerM.pdf}{Ihler,\nMc. Allister: Particle Belief Propagation} for an overview) is to try to\nestimate message densities using some form of nonparametric density\nestimation technique which both smoothes the distribution, and\ncompresses the amount of data required to transfer the message. See\n\\href{http://robotics.stanford.edu/~koller/Papers/Koller+al:UAI99.pdf}{Koller\net al: A General Algorithm for Approximate Inference and Its Application\nto Hybrid Bayes Nets} for a more thorough discussion of this.\n\nIn that paper, Density Estimation Trees (DETs) with GMMs at the leaves\nhave been used with success by Koller et. al. as density estimators, so\nthat might be a good choice to make as well. They iteratively refined\nthese density estimates using an iterative approach, similar to the\nresampling mentioned above.\n\nGenerally, Multivariate Gaussian Mixture Models (GMMs) trained with\nRegularized Expectation Maximization (EM) might be a another good\nchoice. See \\href{http://www.cs.ubc.ca/~murphyk/MLbook/}{Kevin Murphy:\nMachine Learning: A Probabilistic Perspective, Chapter 11}. These would\nlend themselves to the fast methods in\n\\href{http://ssg.mit.edu/nbp/papers/nips03.pdf}{Ihler, Sudderth et al:\nEfficient Multiscale Sampling from Products of Gaussian Mixtures}\n\nBut how do we determine the optimal number of mixture components ? Maybe\nwe can make the algorithm automatically choose the number of components\nbased on the data ?\n\nOne obvious but very slow approach would be to use cross-validation to\nselect an optimal number of components. But this gets prohibitevely\nslow. A different approach would be to use a\n\\href{http://www.gatsby.ucl.ac.uk/~edward/pub/inf.mix.nips.99.pdf}{Dirichlet\nProcess Clustering}, also called \\textbf{Infinite Gaussian Mixture\nModel} to choose a data-dependent number of components. Alternatively, a\npossibly better alternative is not to use the Dirichlet Process Prior\nfor the number of components, but rather a\n\\href{http://en.wikipedia.org/wiki/Pitman\\%E2\\%80\\%93Yor\\_process}{Pitman-Yor\nProcess}, a more flexible two-parameter generalization of the Dirichlet\nProcess which allows for Power-Law (fat) tails.\n\nThere are a lot of ready-made implementations of these (except for the\nPitman- Yor Process Clustering), see\n\\href{http\\%20://scikit-learn.org/stable/modules/mixture.html}{Scikit-Learn\nDocumentation: Mixtures}\n\nAnother (novel) approach is the following, which might be more efficient\nif the Particle Lists are created using MCMC Sampling.\n\n\\paragraph{Embarassingly Parallel MCMC}\n\nIn a recent paper (\n\\href{http://arxiv.org/pdf/1311.4780v1.pdf}{Neiswanger et al:\u0003\nEmbarassingly Parallel MCMC} ) an asymptotically exact algorithm for\nperforming embarassingly parallel distributed MCMC was presented.\nInterestingly, the main problem solved in that paper is almost exactly\nthe Message Fusion problem stated above. So by solving one problem, we\nget to solve inference for both high-dimensional and big-data problems.\n\n\\paragraph{Density Mapping (DRAFT)}\n\nThe core idea for Density Mapping is to combine MCMC, Gradient Ascent or\nEM and Kernel Density Estimation (KDE) into a single, more efficient\nalgorithm for Kernel Density Estimation which can be used in the context\nof large scale distributed Nonparametric Message Passing inference\nengines.\n\nWe sample from a density function, and then modify the sampling density\nfunction by subtracting from it density estimates around local modes.\nThis way, the probability density gets simultaneously \\emph{mapped out},\nensuring that the MCMC chain spends it's computational time efficiently\nby mapping so far uncovered regions of the probability space.\n\nLet \\$ f\\^{}\\emph{: \\mathbb{R}\\^{}D \\mapsto \\mathbb{R} \\$ be our\nunnormalized posterior density function which we can evaluate at any\npoint. The corresponding normalized density is \\$ P\\^{}} \\$ with \\$\nP\\^{}\\emph{(x) = \\frac{1}{Z} f\\^{}}(x) \\$ and \\$ x \\in\n\\mathbb{R}\\^{}D \\$, with \\$ Z \\$ being the normalization constant, i.e.\n\\$ Z = \\int{f^*(x) dx} \\$\n\nWe assume that we can consistently estimate the density \\$ P\\^{}* \\$\n(usually a posterior) using a suitable Markov Chain Monte Carlo\nalgorithm such as a Metropolis Hastings sampler given the unnormalized\ndensity function \\$ f\\^{}*(x) \\$\n\nNow let us assume we have a kernel probability density estimate which\nhas been estimated step by step from N point probability masses:\n\n\\[\nP^{E}(x) = \\frac{1}{H} \\sum_{i=1}^{N} \\gamma_i \\cdot K_i(x)\n\\]\n\nWhere \\$ H = \\sum{\\gamma_i} \\$ and each \\$ K\\_i \\$ is itself a properly\nnormalized density function (Kernel) with a single mode \\$k\\_i =\n\\{argmax\\}\\_\\{x\\} K\\_i(x) \\$ with \\$ k\\_i \\in \\mathbb{R}\\^{}D \\$. We\ndefine the unnormalized kernel density at time step N as\n\n\\[\nf_N^E(x) =  \\sum_{i=1}^{N} \\frac{f_i^E(k_i)}{K_i(k_i)} \\cdot K_i(x)\n\\]\n\nwith \\$ f\\_0\\^{}E(x) = f\\^{}\\emph{(x) \\$. Correspondingly, we define \\$\n\\gamma\\_i = \\frac{f^*(k_i)}{f_i^E(k_i)} \\$ which ensures that \\$\nf\\_N\\^{}E(x) = P\\^{}\\{E\\}(x) = f\\^{}}(x) \\$ for all points \\$ x \\in \\{\nk\\_1, \\ldots, k\\_N \\} \\$.\n\nWe define the \\textbf{Unnormalized Sampling Function} as:\n\n\\[\nf^F(x) = min(max(f^*(x)-f^E(x), f^*(x)^\\frac{1}{s}), f^*(x))\n\\]\n\nWith \\$ s \\textgreater{} 1 \\$ being a cooling factor which flattens the\noriginal distribution. Plausible initial values for s might be in the\nrange from 2 to 100 depending on how flat we would like the distribution\nto become.\n\nIf we chose the density estimation Kernels \\$ K\\_i \\$ such that they (at\nleast approximately) have limited support around their mode or mean \\$\nx\\_i \\$, this Sampling Function can be calculated (or approximated)\nquickly, even if N (the number of kernels in the density estimate) is\nlarge, by just taking the nearest kernels to a given point into account.\nSuch a lookup can be made efficient using \\textbf{KD-Trees} or\n\\textbf{Cover-Trees} to be performed in \\$ O(D \\cdot \\log(N)) \\$ time,\nwith \\$ N \\$ being the number of components, and \\$ D \\$ being the\ndimensionality of the points.\n\nDuring or after MCMC sampling, we should check for each sample whether\n\\$ f\\textsuperscript{*(x)-f}E(x) \\$ becomes negative at that point. This\nwould indicate regions where we over-estimate the density. In such a\ncase, it should be possible to shrink the variance of the responsible\ncomponent of f\\^{}E(x) in that direction. Since this is computationally\nintensive (we have to re-compute all mixture components), this should be\nprevented by scaling down the variance of the kernel components in\ndirections of high variance.\n\n\\paragraph{Density Mapping Algorithm (DRAFT)}\n\nNow, after initializing s to a sensible value, and starting with \\$\nf\\^{}E=0\\$ (constant), the density estimation procedure works like this:\n\n\\begin{enumerate}[1.]\n\\item\n  Run MCMC to collect a number of samples from \\$ f\\^{}F \\$ . Discard\n  burn-in samples.\n\\item\n  Check all sampled points for values with negative\n  f\\textsuperscript{*(x)-f}E(x). Shrink the variance of responsible\n  components of \\$ f\\^{}E \\$.\n\\item\n  Pick a random sample, and perform gradient ascent or EM to find a\n  local optimum/mode of \\$ f\\^{}F \\$: called \\$ k\\_i \\$\n\\item\n  Check if this is a new local optimum. If not: Increase \\$ s \\$ and\n  continue at 1.)\n\\item\n  Create a Kernel density estimate \\$ K\\_i \\$ around local optimum \\$\n  k\\_i \\$ (use the Hamiltonian of \\$ f\\^{}* \\$ at \\$ k\\_i \\$ as a\n  scale/precision matrix, apply sensible regularization)\n\\item\n  (Optional): Add \\$ k\\_i \\$ to a KD-Tree index to speed up\n  nearest-neighbour lookups\n\\item\n  Update \\$ f\\^{}E \\$ and \\$ f\\^{}F \\$ using the new kernel estimate \\$\n  K\\_i \\$\n\\item\n  Stopping criterion: Has the density been flattened enough ? Then stop.\n\\item\n  otherwise go to 3.) or 1.)\n\\end{enumerate}\nThe result (so I hope) is a rather good density estimate. This algorithm\nhas yet to be tried in practice.\n\n\\subparagraph{Conclusions}\n\nIt seems like everything is ready to build a generic framework for large\nscale inference in directed probabilistic graphical models. Someone just\nhas to do it.\n", "meta": {"hexsha": "a5f43929ab5a409092aebe44a49cd6c4737e6151", "size": 25160, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/Large Scale PGM Inference.tex", "max_stars_repo_name": "kadeng/pypgmc", "max_stars_repo_head_hexsha": "909445fa3a426b07b39b65d2cb8979b1db8cdfca", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-29T14:57:53.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-22T11:40:34.000Z", "max_issues_repo_path": "docs/Large Scale PGM Inference.tex", "max_issues_repo_name": "kadeng/pypgmc", "max_issues_repo_head_hexsha": "909445fa3a426b07b39b65d2cb8979b1db8cdfca", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/Large Scale PGM Inference.tex", "max_forks_repo_name": "kadeng/pypgmc", "max_forks_repo_head_hexsha": "909445fa3a426b07b39b65d2cb8979b1db8cdfca", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8287795993, "max_line_length": 107, "alphanum_fraction": 0.7757154213, "num_tokens": 6090, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.4104233055159951}}
{"text": "\\documentclass[14pt]{article}\n\\usepackage[left=0.5in, right=.5in, top=0.5in, bottom=0.75in]{geometry}\n\\usepackage{enumitem}\n\\usepackage{amsmath}\n\\usepackage{bbold}\n\n\\usepackage[left=0.5in, right=.5in, top=0.5in, bottom=0.75in]{geometry}\n\\usepackage{hyperref}\n\\usepackage{subfig}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\hypersetup{colorlinks,linkcolor={blue},citecolor={blue}, urlcolor={red}}\n\\begin{document}\n\t\\title{Lab works : Subject 1}\n\t\\date{}\n\\author{\\textbf{Mahmoud El Omar}}\n\n\\maketitle\n\\pagenumbering{arabic}\n\\section*{Theoretical Study in the case of sine wave}\nWe have the following signal :\n\\begin{align*}\n\tx(t) = a\\cos(2\\pi f_0t + \\phi) \n\\end{align*}\n\t\\begin{enumerate}[label=\\alph*)]\n\t \\item We already know that $\\mathcal{F}_{cc}\\{\\cos(2\\pi f_0t)\\} = \\frac{1}{2}(\\delta (f-f_0) + \\delta(f+f_0))$ and $\\mathcal{F}_{cc}\\{\\sin(2\\pi f_0t)\\} = \\frac{1}{2j}(\\delta (f-f_0) - \\delta(f+f_0))$ \\break\n\t\\newline\n\t $x(t) = a\\cos(2\\pi f_0t + \\phi) = a(\\cos(2\\pi f_0t)\\cos(\\phi) - \\sin(2\\pi f_0t)\\sin(\\phi)) \\Rightarrow \\newline \n\t \\newline $For the sake of notation simplicity, let's denote $ \\boxed{X(f) =  \\mathcal{F}_{cc}x(f)}$ and $\\boxed{X_s(\\lambda) = \\mathcal{F}_{dc}x_s(\\lambda)}$ \\newline \\newline\n\t \\begin{equation*}\n\t \tX(f) = \\frac{a}{2}\\cos(\\phi)(\\delta (f-f_0) + \\delta(f+f_0)) + \\frac{a}{2j}\\sin(\\phi)(\\delta (f-f_0) - \\delta(f+f_0)) \\Rightarrow \\newline \\newline\n\t  \\boxed{X(f) = \\frac{a}{2}(\\delta(f-f_0)e^{j\\phi} + \\delta(f+f_0)e^{-j\\phi})}\n\t \\end{equation*}\n\n\t  \\item The sampled signal  $x_s[n] = x(nT_s) = x(\\frac{n}{f_s}) = a\\cos(2\\pi \\frac{f_0}{f_s}n + \\phi) = a\\cos(2\\pi \\lambda_0 n + \\phi)$ with $\\lambda_0 = \\frac{f_0}{f_s}$\n\t  \\begin{equation*}\n\t  \tX_s(\\lambda) = \\sum_{n=-\\infty}^{\\infty} x_s[n]e^{-j2\\pi \\lambda n} = \\sum_{n=-\\infty}^{\\infty} a\\cos(2\\pi \\lambda_0 n+ \\phi)e^{-j2\\pi \\lambda n}\n\t \\end{equation*}\n\t \n\t \\begin{equation*}\n\t X_s(\\lambda) = \\frac{a}{2}\\sum_{n=-\\infty}^{\\infty}e^{j2\\pi \\lambda_0 n}e^{-j2\\pi \\lambda n}e^{j\\phi} + e^{-j2\\pi \\lambda_0 n}e^{-j2\\pi \\lambda n}e^{-j\\phi}\n\t \\end{equation*}\n\t\n\t\\begin{align*}\n\t\tX_s(\\lambda) = e^{j\\phi}\\frac{a}{2}\\sum_{n=-\\infty}^{\\infty}e^{-j2\\pi (\\lambda - \\lambda_0) n} + \\sum_{n=-\\infty}^{\\infty}e^{-j2\\pi (\\lambda + \\lambda_0) n}\n \t\\end{align*}\n \t\\begin{equation*}\n \t\\boxed{\n \t\tX_s(\\lambda) = \\frac{a}{2}e^{j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(\\lambda - \\lambda_0 - k) +\\frac{a}{2}e^{-j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(\\lambda + \\lambda_0 - k)}\n \t\\end{equation*}\nUsing the scaling property of the Dirac delta function : $|a|\\delta(at) = \\delta(t)$, and since $\\lambda = \\frac{f}{f_s}$ and $\\lambda_0 = \\frac{f_0}{f_s}$, we can reach the following : \n\t\\begin{equation*}\n\t\t\\mathcal{F}_{dc}x_s(\\lambda) = \\mathcal{F}_{dc}x_s(\\frac{f}{f_s}) = \\frac{a}{2}e^{j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(\\frac{f-f_0 - kf_s}{f_s}) +  \\frac{a}{2}e^{-j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta{\\frac{f+f_0 - kf_s}{f_s})}\n\t\\end{equation*}\n\t\\begin{equation*}\n\t\t\\mathcal{F}_{dc}x_s(\\frac{f}{f_s}) =  \\frac{af_s}{2}e^{j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(f-f_0 - kf_s) +  \\frac{af_s}{2}e^{-j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(f+f_0 - kf_s)\n\t\\end{equation*}\t\n\n\t\\begin{equation*}\n\t\t\\boxed{\\frac{1}{f_s}\\mathcal{F}_{dc}x_s(\\frac{f}{f_s}) =  \\frac{a}{2}e^{j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(f-f_0 - kf_s) +  \\frac{af_s}{2}e^{-j\\phi}\\sum_{k = -\\infty}^{\\infty}\\delta(f+f_0 - kf_s)}\n\t\\end{equation*}\n\n\t\\item The Fourier Transform of rect${_N{_t}}$ is the Dirichlet kernel $D_{N_{t}}(\\lambda)$ as defined in the course notes.\n\t\\begin{equation*}\n\ty[n] = x_s[n]\\text{rect}_{N_t} \\iff Y(\\lambda) = X_s(\\lambda)*D_{N_{t}}(\\lambda)\n\t\\end{equation*}\n\t\\begin{equation*}\n\t\\boxed{Y(\\lambda) = \\frac{a}{2}e^{j\\phi}\\sum_{k = -\\infty}^{\\infty}D_{N_{t}}(\\lambda - \\lambda_0 - k) +\\frac{a}{2}e^{-j\\phi}\\sum_{k = -\\infty}^{\\infty}D_{N_{t}}(\\lambda + \\lambda_0 - k)}\n\t\\end{equation*}\n\t\\newpage\n\t\\item Since $f_s >>2f_0$, therefore the Shannon condition is satisfied and the periodic spectrums do not overlap, we can perform all our calculations on just one period of the spectrum $Y(\\lambda)$ without loss of generalisation. We can chose any portion of the spectrum that is equal to 1 \\textit{(since $Y(\\lambda)$ is 1-periodic)}. So for reasons of symmetry, I will chose the period centred around 0, that corresponds to $k=0$ in the previous equation.\n\t\\newline \\newline\n\tFrom here on out, I will consider that : \n\t\\begin{equation*}\n\tY(\\lambda) = \\frac{a}{2}e^{j\\phi}D_{N_t}(\\lambda - \\lambda_0) + \\frac{a}{2}e^{-j\\phi}D_{N_t}(\\lambda + \\lambda_0)\n\t\\end{equation*}\n\tTo sample $Y(\\lambda)$, we need to take its value at frequencies multiple of $\\frac{1}{N_f}$, so if we multiply $Y(\\lambda)$ with a discrete comb of repeated deltas with period equal to $\\frac{1}{N_f}$. In other words, replace $\\lambda$ with $\\frac{n}{N_f} \\text{where} n \\in \\mathbb{Z}$ in $Y(\\lambda)$ and we will manage to get the desired sampled spectrum : \n\t\\begin{equation*}\n\tY_{N_f}[n] = Y(\\lambda)\\textbf{1}_{\\uparrow N_f}[n] = \tY(\\lambda)\\sum_{k = -\\infty}^{\\infty}\\delta[n - \\frac{k}{N_f}]\t = Y(\\frac{k}{N_f})\n\t\\end{equation*}\n\t\\begin{equation*}\n\t\tY_{N_f}[n] = \\frac{a}{2}e^{j\\phi}D_{N_t}(\\frac{n - n_0}{N_f}) + \\frac{a}{2}e^{-j\\phi}D_{N_t}(\\frac{n + n_0}{N_f})\n\t\\end{equation*}\n\t\\begin{figure}[hp]\n\t\t\\centering\t\t\n\t\t\\includegraphics[width = 10cm]{1}\n\t\t\\caption{Plot of the Spectrum of $x(t)$.}\n\t\t\\label{fig1}\n\t\\end{figure}\n\t\\begin{figure}[hp]\n\t\t\\centering\t\t\n\t\t\\includegraphics[width = 16cm]{3.png}\n\t\t\\caption{Plot of the Spectrum of $x_s[n]$.}\n\t\t\\label{fig2}\n\t\\end{figure}\n\t\n\t\\begin{figure}[t]\n\t\t\\centering\t\t\n\t\t\\includegraphics[width = 20cm]{2.jpg}\n\t\t\\caption{Plot of the Spectrum of $y[n]$ over 2 periods.}\n\t\t\\label{fig1}\n\t\\end{figure}\n\n\t\\end{enumerate}\n\t\\section*{Numerical Implementation}\n\t\\begin{enumerate}[label=\\alph*)]\n\t\\item If $N_f$ = $N_t$, we can recognise the formula for the Discrete Fourier Transform, where the result of this computation is the discrete spectrum of the discrete time signal $y[n]$, and it allows us to obtain the spectral samples directly from the time samples.\n\t\\item If $N_f \\geq N_t$, then we can zero samples after the $N_t -1 $ sample of the original signal until we can have $N_f = N_t$ and then, we'll be able to calculate the Discrete Fourier Transform and obtain the spectral samples.\n\t\\end{enumerate}\t\n\t\n\\end{document}\nw", "meta": {"hexsha": "bac760af4b1fe5d804948ee14b9e40625956591a", "size": 6308, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "spectral analysis in matlab/report/Untitled.tex", "max_stars_repo_name": "MahmoudElOmar/signal-processing-work", "max_stars_repo_head_hexsha": "a334602a4f1e1bced9f9463bf8fccb90b51fb750", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "spectral analysis in matlab/report/Untitled.tex", "max_issues_repo_name": "MahmoudElOmar/signal-processing-work", "max_issues_repo_head_hexsha": "a334602a4f1e1bced9f9463bf8fccb90b51fb750", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spectral analysis in matlab/report/Untitled.tex", "max_forks_repo_name": "MahmoudElOmar/signal-processing-work", "max_forks_repo_head_hexsha": "a334602a4f1e1bced9f9463bf8fccb90b51fb750", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.3214285714, "max_line_length": 457, "alphanum_fraction": 0.6485415346, "num_tokens": 2542, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301064, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.41042330550272577}}
{"text": "\n\\subsection{The Investment Saving - Liquidity preference - Money supply (IS-LM) model}\n\nThe IS curve plots output against the (real) interest rate. As (real) interest rates rise, investment and therefore output falls.\n\nThe LM curve plots output against the (nominal) interest rate. As output rises, (nominal) interest rates fall to ensure clearing.\n\nAs prices are fixed in the IS-LM model, we can use the real and nominal rates interchangably.\n\nThe IS-LM model identifies the intercepts of the two curves and the equilibrium output and interest rate.\n\nThis model takes prices, money supply, taxes and government spending to be exogenous.\n\n\\subsubsection{Effect of monetary expansion}\n\nIn the LM model a monetary expansion lowers interest rates.\n\nIn the IS-LM model this effect is lessened. The lower interest rates cause higher output, increasing money demand, and raising interest rates.\n\n\\subsubsection{Effect of fiscal expansion}\n\nIs the IS model a fiscal expansion caused a corresponding increase in output.\n\nIn the IS-LM model this is lessened because the increase also causes more real money demand, raising interest rates, and lowering output.\n\n", "meta": {"hexsha": "3fd36b026ae02e9c3189f3d15ce28fab7098c938", "size": 1153, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/neoKeynesian/02-04-IS-LM.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/neoKeynesian/02-04-IS-LM.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/neoKeynesian/02-04-IS-LM.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.3461538462, "max_line_length": 142, "alphanum_fraction": 0.7979184735, "num_tokens": 238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4104142985064469}}
{"text": "\\documentclass[../Thesis]{subfiles}\n\n\\begin{document}\n\n\\chapter{Introduction}\n\\chaptermark{Chapter 1 title} % optional for veryy long chapter, you can rename what appear in the header\n\\section{Start}\n\\subsection{Basic info}\nI studied \\autocite{C01} and that was fun. I also looked at \\autocite{C02} \\footnote{you should do footnotes like this. More details here \\url{https://www.overleaf.com/learn/latex/Footnotes}}.\n\nI also wrote this \\autocite{C05}\n\nURI should be included like this \\url{https://github.com/jackred/Heriot_Watt_Thesis_Template}.\n\n\\subsection{Equation}\nEquations placed on separate lines from the text should be numbered whether or not they are referred to in the text. Numbering should appear in round brackets at the right hand side of the page and be ordered consecutively either throughout the thesis as (1) etc, or in each chapter (1.1) etc. Equations should be referred to in the text as equation(1) etc.\\par\n\\bigskip\nBelieve it or not, this is the equation for the canonical version of PSO, using the inertia factor, first proposed in 1998.\n\\begin{equation} \n    V_{i} = wV_{i} + c_{1} * U(0,1) * (P_{i} - X_{i}) + c_{2} * U(0,1) * (L_{i} - X_{i}) \n    \\label{eqn:velocityInertia} \n\\end{equation} \n\n% you refer an equation like this\nAnd here you have the constriction factor equation, which have the same role as the inertia factor defined in \\eref{eqn:velocityInertia}, but is used differently. Proposed in 1999. \n\\begin{equation} \n    \\chi = \\dfrac{2}{|2 - \\phi - \\sqrt{\\phi^{2} - 4\\phi}|} \n    \\label{eqn:velocityConstriction} \n\\end{equation} \n\nWas I just lazy and copied the equation of my Master Thesis? Not at all. Look, here is the gravity equation for PSO2011, proposed, as the name suggest, in 2011.\n\\begin{equation} \n    G_{i} = \\dfrac{X_{i} + (X_{i}+U(0,1)c(P_{i}-X_{i})) + (X_{i}+U(0,1)c(L_{i}-X_{i}))}{3}\n    \\label{eqn:gravityVelocity2011} \n\\end{equation} \n\n\\clearpage  % aesthetic purpose\n\n\\subsection{Tables}\nTables, figures etc. shall be numbered either consecutively throughout the thesis–Table 1, Figure 1 etc., or within individual chapters Chapter –Table1.1, but not within sections or subsections. With in the text tables should be referred to as table 1etc.\n\n\\begin{table}[H]\n    \\centering\n        \\begin{tabular}{llllll}\n        D10 & min      & max      & median   & std      & average  \\\\\n        f1  & 0.00E+00 & 0.00E+00 & 0.00E+00 & 0.00E+00 & 0.00E+00 \\\\\n        f3  & 4.40E-02 & 1.37E+08 & 3.49E+05 & 2.18E+07 & 6.46E+06 \\\\\n        f8  & 2.01E+01 & 2.05E+01 & 2.03E+01 & 8.44E-02 & 2.03E+01 \\\\\n        f9  & 1.51E+00 & 6.96E+00 & 4.54E+00 & 1.21E+00 & 4.53E+00 \\\\\n        f15 & 1.41E+02 & 1.04E+03 & 7.16E+02 & 2.26E+02 & 6.64E+02 \\\\\n        f20 & 1.26E+00 & 3.82E+00 & 3.02E+00 & 5.67E-01 & 2.93E+00 \\\\\n        f21 & 1.00E+02 & 4.00E+02 & 4.00E+02 & 1.05E+02 & 3.33E+02 \\\\\n        f22 & 8.79E+01 & 8.30E+02 & 4.83E+02 & 2.00E+02 & 4.91E+02 \\\\\n        f25 & 2.04E+02 & 2.23E+02 & 2.15E+02 & 3.73E+00 & 2.15E+02\n        \\end{tabular}\n    \\rule{35em}{0.5pt} \n    \\caption[Example table]{Summary Statistics for the 10 dimensional case of PSO 2007 with a ring neighborhood of 4. I know you don't know what it means. But at least you have an example of a table. More info here \\url{https://www.overleaf.com/learn/latex/Tables}}\n    \\label{tab:PSO_2007_D10_R4}\n\\end{table}\n\n\n\\subsection{Figures}\nBecause I think you are very interested in PSO (or I am just very lazy) here is a nice figure explaining how PSO 2006 works.\n\\begin{figure}[H] \n    \\centering \n    \\includegraphics[]{Figures/pso2006.png} \n    \\rule{35em}{0.5pt} \n    \\caption[SPSO 06/07 movement]{SPSO 2006 and 2007 particle's position update. $X'_{i}$ and $X\"_{i}$ are temporary point to explain the second and third terms of equation \\ref{eqn:velocityInertia}.} \n    \\label{fig:schemaPSO2006Update} \n\\end{figure} \n\n\n\\clearpage % aesthetic purpose\n\nAnd while we are at it, look at the 2011 version, that you can't probably understand without the context, but eh, it's a figure to illustrate how to put some. We can see it is different than \\fref{fig:schemaPSO2006Update}\n\\begin{figure}[H] \n    \\centering \n    \\includegraphics[]{Figures/pso2011.png} \n    \\rule{35em}{0.5pt} \n    \\caption[SPSO 2011 movement]{SPSO 2011 particle's position update. $X'_{i}$ is generated inside the hyper-sphere of center $G_{i}$.} \n    \\label{fig:schemaPSO2011Update} \n\\end{figure}\n\nI placed my figure right after the text, but you will usually use other option to place them, such as \\textit{htpb}. More info \\url{https://www.overleaf.com/learn/latex/Positioning_of_Figures}. \n\n\\begin{figure}[H] \n    \\centering \n    \\rotatebox{90}{\\includegraphics[width=22cm]{Figures/rk4_0-100_dt-0-0001}}\n    \\rule{35em}{0.5pt} \n    \\caption[Sideways picture]{How to put a very big picture sideways. It is in French but who cares?} \n    \\label{fig:veryBigFigure} \n\\end{figure}\n\n\\end{document}\n", "meta": {"hexsha": "08fa00ccdd88dcc91854a2ad84ae968efcaef5d6", "size": 4874, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/Chapter1-Introduction.tex", "max_stars_repo_name": "jackred/Heriot_Watt_Thesis_Template", "max_stars_repo_head_hexsha": "df64498e5c5c6228746ba30ee9b82dab6d52f2e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-07-13T03:56:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-13T14:03:32.000Z", "max_issues_repo_path": "Chapters/Chapter1-Introduction.tex", "max_issues_repo_name": "jackred/Heriot_Watt_Thesis_Template", "max_issues_repo_head_hexsha": "df64498e5c5c6228746ba30ee9b82dab6d52f2e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/Chapter1-Introduction.tex", "max_forks_repo_name": "jackred/Heriot_Watt_Thesis_Template", "max_forks_repo_head_hexsha": "df64498e5c5c6228746ba30ee9b82dab6d52f2e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.3052631579, "max_line_length": 361, "alphanum_fraction": 0.6885514977, "num_tokens": 1713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4104142985064469}}
{"text": "\\subsection{Energies of Isolated Atoms}\\index{EISOL}\\index{EHEAT}\\index{ATHEAT}\r\nThe $\\Delta H_f$ calculated by semiempirical methods is defined as the  energy\r\nin kcal.mol$^{-1}$ required to form one mole of the system in the gas phase at\r\n298K from its elements in their standard state:\r\n$$\r\n\\Delta H_f = E_{elect} + E_{nuc} + \\sum_AE_{isol}(A) +\\sum_AE_{atom}(A)\r\n$$\r\nIn order to calculate $\\Delta H_f$, the quantity $E_{isol}$ must be \r\ndetermined; this is the energy required to form the isolated atom from its \r\nvalence electrons:\r\n$$\r\nE_{isol}(A)=E_{\\rm neutral\\ atom}(A) -E_{\\rm nucleus}(A)-\r\nE_{\\rm valence\\ electrons}(A)\r\n$$\r\nIn the calculation of $E_{elect}$, the energy of valence electrons is  defined\r\nas zero, likewise in calculating $E_{nuc}$, the energy of the  isolated nucleus\r\nis defined as zero, therefore the calculation of $E_{isol}$ simplifies to the\r\ncalculation of $E_{\\rm neutral\\ atom}$.\r\n\r\nThe energy of $E_{eisol}$ is the energy released when the valence  electrons\r\nare added to the nucleus.  For example, for the hydrogen atom, this would be \r\n$U_{ss}$.  For poly-electronic atoms, the electron-electron  interactions must\r\nbe included, in addition to the one-electron contributions. Most elements have\r\nopen shell ground states, and for these systems, the  nature of the state is\r\nimportant.\r\n\r\nFor all main group elements, that is, elements with valence shell\r\nconfigurations of the form $ns^anp^b$, other than the alkali metals, the value\r\nof $E_{isol}$ is  given by:\r\n$$\r\nE_{isol} =aU_{ss}+bU_{pp}+(a-1)G_{ss}+a.bG_{sp}+(b(b-1))/2G_{p2}-bH_{sp}-\r\ncH_{pp}\r\n$$\r\nin which $c=min(b(b-1)/2,(6-b).(5-b)/2)$.  Except for the $H_{pp}$ term, all\r\nthe contributions to $E_{isol}$ are obvious.  Non-zero $H_{pp}$ terms occur\r\nwhen there are two or more unpaired electrons in the ground state, in  which\r\ncase there is an exchange stabilization that is otherwise absent.\r\n\r\nBecause $H_{pp}$ is usually written as $1/2(G_{pp}-G_{p2})$, the expression \r\nfor systems with 2 to 4 $p$ electrons is recast as:\r\n$$\r\nE_{isol} =aU_{ss}+bU_{pp}+(a-1)G_{ss}+a.bG_{sp}+((b(b-1))/2+c/2)G_{p2}-\r\n(a-1)bH_{sp}-c/2G_{pp},\r\n$$\r\nor\r\n$$\r\nE_{isol} =2U_{ss}+bU_{pp}+G_{ss}+2.bG_{sp}+((b(b-1))/2+c/2)G_{p2}-\r\n(a-1)bH_{sp}-c/2G_{pp}.\r\n$$\r\nFor the alkali metals, the equation for $E_{isol}$ is the same as that for \r\nhydrogen.\r\n\r\nFor the transition metals, the coefficients for the $d-d$ interactions are more\r\ncomplicated.\r\n\r\nThe general form for $E_{isol}$ for a transition metal of configuration\r\n$s^md^n$s, in which there are $m_a$ $\\alpha$ $s$-electrons and $m_b$ $\\beta$ \r\n$s$-electrons, and $n_a$ $\\alpha$ $d$-electrons and $n_b$ $\\beta$ \r\n$d$-electrons, and the total angular quantum number is $L$, is:\r\n\\begin{eqnarray} \\nonumber\r\nE_{isol}&=&mU_{ss}+nU_{dd}+\r\n(m(m-1))/2G_{ss}+m.nG_{sd}-(m_an_a+m_bn_b)H_{sd}\\\\ \\nonumber\r\n&& +(n(n-1))/2\\frac{G_{dd}^0}{5} +(-4(n_a^2+n_b^2)+13n-3/2(L(L+1)))\\frac{G_{dd}^2}{49}\\\\ \\nonumber \r\n&& +(-(n_a^2+n_b^2)/2-9/2n+5/6(L(L+1)))\\frac{G_{dd}^4}{49}. \\nonumber\r\n\\end{eqnarray}\r\nAs might be imagined, derivation of this expression is by no means  obvious,\r\nparticularly the terms for $G_{dd}^2$ and $G_{dd}^4$.  Interested readers are\r\nreferred to Racah's paper in {\\it Phys Rev}, {\\bf 61}, 186 (1942). In this,\r\nRacah derived an expression for the $d$ orbital energy of the ground  state in\r\nterms of three quantities, $A$, $B$, and $L$, the total angular momentum:\r\n$$\r\n<\\! ^{n+1}L|H|^{n+1}L>=\\frac{1}{2}n(n-1)(A-8B)+\\frac{3}{2}[6n-L(L+1)]B.\r\n$$\r\n\r\nThe quantities $A$ and $B$, and a third quantity, $C$, not used here, are\r\nrelated  to the $G_k$ as follows:\r\n\\begin{eqnarray} \\nonumber\r\nA&=&G_{dd}^0-49G_{dd}^2\\\\ \\nonumber\r\nB&=&G_{dd}^2-5G_{dd}^4\\\\ \\nonumber\r\nC&=&35G_{dd}^4 \\\\ \\nonumber\r\n\\end{eqnarray}\r\nUsing Racah's equation, derivation of  $E_{isol}$ is straightforward.  In texts\r\non transition metal ion theory, the quantities $G_{dd}^0$, $G_{dd}^0$, and \r\n$G_{dd}^0$ are usually represented by the symbols $F_0$, $F_2$, and $F_4$,\r\nrespectively.  However, care should be exercised when reading these texts:\r\nsometimes other quantities, $F^0$, $F^2$, and $F^4$ are used.  The relationship\r\nbetween these three sets of symbols is as follows:\r\n\\begin{eqnarray}\\nonumber\r\nG_{dd}^0  =  F_0 &=& F^0 \\\\ \\nonumber\r\nG_{dd}^2  =  F_2 &=& \\frac{1}{49}F^2 \\\\ \\nonumber\r\nG_{dd}^4  =  F_4 &=& \\frac{1}{441}F^4 \\\\ \\nonumber\r\n\\end{eqnarray}\r\n\r\n\r\nBecause the coefficients for the two electron terms are so complicated,  values\r\nfor all elements likely to be parameterized for semiempirical  methods are\r\npresented in Table~\\ref{confs}.  From this table, the values of some \r\ncoefficients are readily derived.  Thus for the $s$-$d$ coulomb integral,\r\n$G_{sd}$, the coefficient is simply the number of $s$ electrons times the\r\nnumber of $d$ electrons.  One $s$-$d$ exchange integral, $H_{sd}$, exists for \r\neach electron in the $s$ shell for which there is an electron of the  same spin\r\nin the $d$ shell.  For elements with two $s$ electrons, this is simply the\r\nnumber of $d$ electrons, for elements with one $s$ electron, the Aufbau\r\nprinciple indicates that the $d$ shell with higher occupancy has the same spin\r\nas that of the $s$ electron.  Finally, the coefficients for the  simple $d$-$d$\r\nrepulsion integral, $G_{dd}^0$, are given by the number of possible $d$-$d$\r\ninteractions.\r\n\r\nNote also that there are no elements with both $p$ and $d$ valence electrons,\r\ntherefore terms of the type $G_{pd}$ are not necessary.\r\n\r\n\\begin{table}\r\n\\caption{\\label{confs}Two Electron Energy Contributions to EISOL for Atoms in \r\ntheir Ground States}\r\n\\begin{center}\r\n\\compresstable\r\n\\begin{tabular}{cclcccccccccccc}\\hline\r\n\\multicolumn{2}{c}{Element}   &  Orbital & State&  &\r\nG$_{ss}$ & G$_{sp}$&H$_{sp}$& G$_{pp}$ &G$_{p2}$ &G$_{sd}$&\r\nH$_{sd}$&G$_{dd}^0$&G$_{dd}^2$& G$_{dd}^4$\\\\ \r\n%                       Gss  Gsp Hsp  Gpp   Gp2  Gsd Hsd Gdd0 Gdd2 Gdd4\r\n&   & Config.& & Mult.: & 1  & 1  &-1 & -1/2&1/2 &  1& -1/5 &1 &-1/49&-1/49\\\\\r\n\\hline\r\n1&H  & $1s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n2&He & $1s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n3&Li & $2s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n4&Be & $2s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n5&B  & $2s^22p^1$ &$^2P$&& 1  & 2  & 1 &     &    &   &   &    &    &     \\\\\r\n6&C  & $2s^22p^2$ &$^3P$&& 1  & 4  & 2 &  1  &  3 &   &   &    &    &     \\\\\r\n7&N  & $2s^22p^3$ &$^4S$&& 1  & 6  & 3 &  3  &9   &   &   &    &    &     \\\\\r\n8&O  & $2s^22p^4$ &$^3P$&& 1  & 8  & 4 &  1  &13  &   &   &    &    &     \\\\\r\n9&F  & $2s^22p^5$ &$^2P$&& 1  & 10 & 5 &     &20  &   &   &    &    &     \\\\\r\n10&Ne & $2s^22p^6$ &$^1S$&& 1  & 12 & 6 &     &30  &   &   &    &    &     \\\\\r\n11&Na & $3s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n12&Mg & $3s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n13&Al & $3s^23p^1$ &$^2P$&& 1  & 2  & 1 &     &    &   &   &    &    &     \\\\\r\n14&Si & $3s^23p^2$ &$^3P$&& 1  & 4  & 2 &  1  &3   &   &   &    &    &     \\\\\r\n15&P  & $3s^23p^3$ &$^4S$&& 1  & 6  & 3 &  3  &9   &   &   &    &    &     \\\\\r\n16&S  & $3s^23p^4$ &$^3P$&& 1  & 8  & 4 &  1  &13  &   &   &    &    &     \\\\\r\n17&Cl & $3s^23p^5$ &$^2P$&& 1  & 10 & 5 &     &20  &   &   &    &    &     \\\\\r\n18&Ar & $3s^23p^6$ &$^1S$&& 1  & 12 & 6 &     &30  &   &   &    &    &     \\\\\r\n19&K  & $4s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n20&Ca & $4s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n21&Sc & $4s^23d^1$ &$^2D$&& 1  &    &   &     &    & 2 & 1 &    &    &     \\\\\r\n22&Ti & $4s^23d^2$ &$^3F$&& 1  &    &   &     &    & 4 & 2 & 1  & 8  & 1   \\\\\r\n23&V  & $4s^23d^3$ &$^4F$&& 1  &    &   &     &    & 6 & 3 & 3  & 15 & 8   \\\\\r\n24&Cr & $4s^13d^5$ &$^7S$&&    &    &   &     &    & 5 & 5 & 10 & 35 & 35  \\\\\r\n25&Mn & $4s^23d^5$ &$^6S$&& 1  &    &   &     &    &10 & 5 & 10 & 35 & 35  \\\\\r\n26&Fe & $4s^23d^6$ &$^5D$&& 1  &    &   &     &    &12 & 6 & 15 & 35 & 35  \\\\\r\n27&Co & $4s^23d^7$ &$^4F$&& 1  &    &   &     &    &14 & 7 & 21 & 43 & 36  \\\\\r\n28&Ni & $4s^23d^8$ &$^3F$&& 1  &    &   &     &    &16 & 8 & 28 & 50 & 43  \\\\\r\n29&Cu & $4s^13d^{10}$&$^2S$&&  &    &   &     &    &10 & 5 & 45 & 70 & 70  \\\\\r\n30&Zn & $4s^2     $&$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n31&Ga & $4s^24p^1$ &$^2P$&& 1  & 2  & 1 &     &    &   &   &    &    &     \\\\\r\n32&Ge & $4s^24p^2$ &$^3P$&& 1  & 4  & 2 &  1  &3   &   &   &    &    &     \\\\\r\n33&As & $4s^24p^3$ &$^4S$&& 1  & 6  & 3 &  3  &9   &   &   &    &    &     \\\\\r\n34&Se & $4s^24p^4$ &$^3P$&& 1  & 8  & 4 &  1  &13  &   &   &    &    &     \\\\\r\n35&Br & $4s^24p^5$ &$^2P$&& 1  & 10 & 5 &     &20  &   &   &    &    &     \\\\\r\n36&Kr & $4s^24p^6$ &$^1S$&& 1  & 12 & 6 &     &30  &   &   &    &    &     \\\\\r\n37&Rb & $5s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n38&Sr & $5s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n39&Y  & $5s^24d^1$ &$^2D$&& 1  &    &   &     &    & 2 & 1 &    &    &     \\\\\r\n40&Zr & $5s^24d^2$ &$^3F$&& 1  &    &   &     &    & 4 & 2 & 1  & 8  & 1   \\\\\r\n41&Nb & $5s^14d^4$ &$^6D$&&    &    &   &     &    & 4 & 4 & 6  & 21 & 21  \\\\\r\n42&Mo & $5s^14d^5$ &$^7S$&&    &    &   &     &    & 5 & 5 & 10 & 35 & 35  \\\\\r\n43&Tc & $5s^24d^5$ &$^6S$&& 1  &    &   &     &    &10 & 5 & 10 & 35 & 35  \\\\\r\n44&Ru & $5s^14d^7$ &$^5F$&&    &    &   &     &    & 7 & 5 & 21 & 43 & 36  \\\\\r\n45&Rh & $5s^14d^8$ &$^4F$&&    &    &   &     &    & 8 & 5 & 28 & 50 & 43  \\\\\r\n46&Pd & $5s^04d^{10}$&$^1S$&&  &    &   &     &    &   &   & 45 & 70 & 70  \\\\\r\n47&Ag & $5s^14d^{10}$&$^2S$&&  &    &   &     &    &10 & 5 & 45 & 70 & 70  \\\\\r\n\\hline\r\n\\end{tabular}\r\n\\end{center}\r\n\\end{table}\r\n\r\n\\begin{table}\r\n\\caption{Two Electron Energy Contributions to EISOL for Atoms in their Ground \r\nStates}\r\n\\begin{center}\r\n\\compresstable\r\n\\begin{tabular}{cclcccccccccccc} \\hline\r\n\\multicolumn{2}{c}{Element}  &  Orbital & State& &\r\nG$_{ss}$ & G$_{sp}$&H$_{sp}$& G$_{pp}$ &G$_{p2}$ &G$_{sd}$&\r\nH$_{sd}$&G$_{dd}^0$&G$_{dd}^2$& G$_{dd}^4$\\\\ \r\n%                     Gss  Gsp Hsp  Gpp   Gp2  Gsd Hsd Gdd0 Gdd2 Gdd4\r\n&   & Config.& & Mult.: & 1  & 1  &-1 & -1/2&1/2 &  1& -1/5 &1 &-1/49&-1/49\\\\\r\n\\hline\r\n48&Cd & $5s^2     $&$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\ \r\n49&In & $5s^25p^1$ &$^2P$&& 1  & 2  & 1 &     &    &   &   &    &    &     \\\\\r\n50&Sn & $5s^25p^2$ &$^3P$&& 1  & 4  & 2 &  1  &3   &   &   &    &    &     \\\\\r\n51&Sb & $5s^25p^3$ &$^4S$&& 1  & 6  & 3 &  3  &9   &   &   &    &    &     \\\\\r\n52&Te & $5s^25p^4$ &$^3P$&& 1  & 8  & 4 &  1  &13  &   &   &    &    &     \\\\\r\n53&I  & $5s^25p^5$ &$^2P$&& 1  & 10 & 5 &     &20  &   &   &    &    &     \\\\\r\n54&Xe & $5s^25p^6$ &$^1S$&& 1  & 12 & 6 &     &30  &   &   &    &    &     \\\\\r\n55&Cs & $6s^1    $ &$^2S$&&    &    &   &     &    &   &   &    &    &     \\\\\r\n56&Ba & $6s^2    $ &$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n72&Hf & $6s^25d^2$ &$^3F$&& 1  &    &   &     &    & 4 & 2 & 1  & 8  & 1   \\\\\r\n73&Ta & $6s^25d^3$ &$^4F$&& 1  &    &   &     &    & 6 & 3 & 3  & 15 & 8   \\\\\r\n74&W  & $6s^25d^4$ &$^5D$&& 1  &    &   &     &    & 8 & 4 & 6  & 21 & 21  \\\\\r\n75&Re & $6s^25d^5$ &$^6S$&& 1  &    &   &     &    &10 & 5 & 10 & 35 & 35  \\\\\r\n76&Os & $6s^25d^6$ &$^5D$&& 1  &    &   &     &    &12 & 6 & 15 & 35 & 35  \\\\\r\n77&Ir & $6s^25d^7$ &$^4F$&& 1  &    &   &     &    &14 & 7 & 21 & 43 & 36  \\\\\r\n78&Pt & $6s^15d^9$ &$^3D$&&    &    &   &     &    & 9 & 5 & 36 & 56 & 56  \\\\\r\n79&Au & $6s^15d^{10}$&$^2S$&&  &    &   &     &    &10 & 5 & 45 & 70 & 70  \\\\\r\n80&Hg & $6s^2     $&$^1S$&& 1  &    &   &     &    &   &   &    &    &     \\\\\r\n81&Tl & $6s^26p^1$ &$^2P$&& 1  & 2  & 1 &     &    &   &   &    &    &     \\\\\r\n82&Pb & $6s^26p^2$ &$^3P$&& 1  & 4  & 2 &  1  &3   &   &   &    &    &     \\\\\r\n83&Bi & $6s^26p^3$ &$^4S$&& 1  & 6  & 3 &  3  &9   &   &   &    &    &     \\\\\r\n84&Po & $6s^26p^4$ &$^3P$&& 1  & 8  & 4 &  1  &13  &   &   &    &    &     \\\\ \r\n85&At & $6s^25p^5$ &$^2P$&& 1  & 10 & 5 &     &20  &   &   &    &    &     \\\\\r\n\\hline\r\n\\end{tabular}\r\n\\end{center}\r\n\\end{table}\r\n", "meta": {"hexsha": "2e1b18543f81c870deb13895af1f272e13f651ae", "size": 12091, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuals/MOPAC2000_manual/t_eisol.tex", "max_stars_repo_name": "openmopac/MOPAC-archive", "max_stars_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-12-16T20:53:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-16T20:54:11.000Z", "max_issues_repo_path": "manuals/MOPAC2000_manual/t_eisol.tex", "max_issues_repo_name": "openmopac/MOPAC-archive", "max_issues_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "manuals/MOPAC2000_manual/t_eisol.tex", "max_forks_repo_name": "openmopac/MOPAC-archive", "max_forks_repo_head_hexsha": "01510e44246de34a991529297a10bcf831336038", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.2372093023, "max_line_length": 100, "alphanum_fraction": 0.4567033331, "num_tokens": 5540, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.41040482267156103}}
{"text": "%% It is just an empty TeX file.\n%% Write your code here.\n\\graphicspath{{sec06/images/}{sec06/code/}}\n\\lstset{inputpath=sec06/code/}\n\n\\subsection{Define macros}\n\n\n\\begin{frame}\\relax\n\n{\\centering\\Huge \\TeX\\ is Turing-complete language\n\n}\n\\inclassFrag{Who understand, what does it means?}\nIn basic words, it means, that you can write in \\TeX\\ and \\LaTeX\\ any algoritms, that you can write in C++, Java, Python... Moreover, some \\TeX syntax is really familiar to functional languages\n\\skfootnote{\\vspace{-3ex}\\stExC{https://stackoverflow.com/questions/2968411/ive-heard-that-latex-is-turing-complete-are-there-any-programs-written-in-late} \\overC{https://www.overleaf.com/learn/latex/Articles/LaTeX_is_More_Powerful_than_you_Think_-_Computing_the_Fibonacci_Numbers_and_Turing_Completeness} \\url{http://sdh33b.blogspot.com/2008/07/icfp-contest-2008.html}}\n     \n\\end{frame}\n\n\n\\begin{frame}{Define macros \\tW\\magicPage}\n     In \\TeX\\ you can define new macros via \\ccol\\def.\n\n\\twocolImg{\n\\lstinputlisting[linerange={8-9, 14-16}]{commandwith.tex}\n}{commandwith}\n     \n    Use \\ccol\\global\\ prefix to define macros not just inside ``group''. \n    \n    Use \\ccol\\long\\ prefix to define macros that can have multiple paragraphs as an argument.\n    \n    \\skfootnote{\\tugC{https://www.tug.org/utilities/plain/cseq.html\\#def-rp} \\knuthc{20}[209]}\n\\end{frame}\n\n\\begin{frame}{Define with pattern matching\\tw\\magicPage}\\relax\n\nThe syntax with writing each argument seems to be an over-use. But it is needed because of \\textit{pattern matching}\n  \n\\twocolImg{\n\\lstinputlisting[linerange={11-13}]{commandpattern.tex}\n}{commandpattern}   \n\n\\end{frame}\n\n\\subsection{Conditions}\n\n\\begin{frame}[fragile]{Compare strings (macros)\\tW\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={12-21}]{ifmy.tex}\n}{ifmy}   \n\n    {\\csk \\verb|\\ifx\\<first>\\<second>  <code1>  [\\else  <code2>]  \\fi|}\n    \n\\end{frame}\n\n\\begin{frame}[fragile]{Compare numbers\\tW\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={12-20}]{ifnummy.tex}\n}{ifnummy}   \n\n    {\\csk \\verb|\\ifnum<first><operator><second>  <code1>  [\\else  <code2>]  \\fi|}. Only ``='', ``>'' or ``<'' are allowed.\n    \n    Use {\\csk \\verb|\\ifcase|} to check different stuff.\n    \n    Also use {\\csk \\verb|\\ifodd|} to check if num is odd or even\n    \n\\end{frame}\n\n\\begin{frame}[fragile]{Check modes\\tW\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={12-22}]{ifmodemy.tex}\n}{ifmodemy}   \n\\begin{itemize}\n    \\item {\\csk\\verb|\\ifmmode|} to check if in mathematical mode\n    \\item {\\csk\\verb|\\ifvmode|} to check if in vertical mode\n    \\item {\\csk\\verb|\\ifhmode|} to check if in horizontal mode\n    \\item {\\csk\\verb|\\ifinner|} to check if \\TeX\\ is in internal vertical mode, or restricted horizontal mode, or (nondisplay) mathmode\n     \n\\end{itemize}\n\n\\skfootnote{other ``if'''s can be found in \\knuthc{20}[221]}\n\\end{frame}\n\n\n\\begin{frame}{Compare in \\LaTeX\\lW\\magicPage}\\relax\n\\twocolImg{\n\\lstinputlisting[linerange={7-7, 12-16}]{ifstring.tex}\n}{ifstring}  \n      \\ncol\\usepackage{xstring}\n      \n      also see \\ncol\\usepackage{ifthen}\n      \n      \\hrule \n      \n      you can check if you are in \\XeLaTeX by \\ncol\\usepackage{ifxetex}\n      \n      \\skfootnote{read about the xstring package! It has lots of things: strings, substrings,.. what to do with them,.. replace strings etc\\\\ \\stExC{https://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation}}\n\\end{frame}\n\n\\subsection{Loops and recursion}\n\n\\begin{frame}[fragile]{Loop \\tW\\magicPage}\\relax\n\\twocolImg{\n\\lstinputlisting[linerange={12-17}]{loopmy.tex}\n}{loopmy}\n\n\\ccol\\loop\\ for start loop, <code> inside, then {\\csk\\verb|\\if<..>|}-family, another bunch of <code>, ended with \\ccol\\repeat.\n\n     \\skfootnote{\\knuthc{20}[228]}\n\\end{frame}\n\n\\begin{frame}[fragile]{Reqursion \\tW\\magicPage}\\relax\n\\twocolImg{\n\\lstinputlisting[linerange={12-13}]{reqmy.tex}\n}{reqmy}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]{For loop\\lW\\magicPage}\\relax\n\\twocolImg{\n\\lstinputlisting[linerange={8-8, 13-16}]{forloopmy.tex}\n}{forloopmy}\n\\ncol \\usepackage{forloop}\n\n\\twocolImg{\n\\lstinputlisting[linerange={8-8, 13-15}]{foreachmy.tex}\n}{foreachmy}\n\n\\ncol \\usepackage{pgffor}, part of pgf, part of TikZ\n\n\\skfootnote{\\stExC{https://stackoverflow.com/questions/2561791/iteration-in-latex}}\n\\end{frame}\n\n\\subsection{Related things to macros creation}\n\n\\begin{frame}[fragile]{``let'' command\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={11-21}]{letmy.tex}\n}{letmy}\n\n\nThe statement ``\\ccol\\let\\verb|\\a=\\b|'' gives \\string\\a\\ the current meaning of \\string\\b. If \\string\\b\\ changes after the assignment is made, \\string\\a\\ does not change.\n\n\\skfootnote{\\knuthc{20}[217] \\tugc{https://www.tug.org/utilities/plain/cseq.html\\#let-rp}}\n     \n\\end{frame}\n\n\\begin{frame}[fragile]{Usecase with \\ccol\\let: ``decorator''\\magicPage}\\relax\n\nImagine: you have some \\string\\command used inside the document multiple times. You want to \\textit{add some addition behaviour} to the command -- decorate (or ``wrap'', or ``redefine with the use of itself''). You can do it with \\ccol\\let:\n\n\\begin{lstlisting}\n\\let\\oldCommand=\\command\n\\def\\command#1{<some code>\\oldCommand}\n\\end{lstlisting}\n\nAnd the same for enviruments using \\ncol\\usepackage{etoolbox} or \\ccol{\\g@addto@macro}\n\n\n\n\\skfootnote{\\stExC{https://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself} \\stExC{https://tex.stackexchange.com/questions/467435/environment-decorators}}\n     \n\\end{frame}\n\n\n\\subsection{Programming examples}\n\n\\begin{frame}{99 Bottles of Beer\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={9-26}]{bottles.tex}\n}{bottles}\n\n\\skfootnote{\\url{https://rosettacode.org/wiki/99_Bottles_of_Beer#LaTeX}}\n     \n\\end{frame}\n\n\\begin{frame}{not-AND logical gate\\magicPage}\\relax\n\n\\twocolImg{\n\\lstinputlisting[linerange={11-29}]{nand.tex}\n}{nand}\n\n\\skfootnote{\\url{https://rosettacode.org/wiki/99_Bottles_of_Beer#LaTeX}}\n\\end{frame}\n\n\\begin{frame}{Split words\\magicPage}\\relax\n\\twocolImg{\n\\lstinputlisting[linerange={11-31}, basicstyle=\\tiny]{splitmy.tex}\n}{splitmy}\n\n     \\skfootnote{\\stExC{https://tex.stackexchange.com/questions/12810/how-do-i-split-a-string/12811}}\n\\end{frame}\n", "meta": {"hexsha": "9fe00b4aba53bbed833cc197cde7fe7d374daa5f", "size": 6200, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2019_skoltech_ISP/05_command_creation/sec06/sec06.tex", "max_stars_repo_name": "Lavton/latexLectures", "max_stars_repo_head_hexsha": "f8491351b2f74884689db24bbce2aa2270fa556a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-01-11T08:19:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-24T11:30:48.000Z", "max_issues_repo_path": "2019_skoltech_ISP/05_command_creation/sec06/sec06.tex", "max_issues_repo_name": "Lavton/latexLectures", "max_issues_repo_head_hexsha": "f8491351b2f74884689db24bbce2aa2270fa556a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2019_skoltech_ISP/05_command_creation/sec06/sec06.tex", "max_forks_repo_name": "Lavton/latexLectures", "max_forks_repo_head_hexsha": "f8491351b2f74884689db24bbce2aa2270fa556a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-01-20T17:52:16.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-20T17:52:16.000Z", "avg_line_length": 31.1557788945, "max_line_length": 370, "alphanum_fraction": 0.7219354839, "num_tokens": 1993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4104048194936292}}
{"text": "\\documentclass[11pt, oneside]{article}\n\\usepackage[a4paper,bindingoffset=0.2in,%\n            left=1in,right=1in,top=1in,bottom=1in,%\n            footskip=.25in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{enumerate}\n\\usepackage{url}\n\\usepackage{hyperref}\n\\usepackage{pbox}\n\\usepackage{CJKutf8}\n\n\n\\begin{document}\n\\title{Part III Eigen Decomposition and SVD (Introduction)}\n\\author{Xiyou Zhou, 13307130189 \\\\ Computer Science and Technology}\n\\maketitle\n\\section{Question}\nWhat's the relationship between eigendecomposition and singular value decomposition?\n\\section{Math Perspective}\n\nConsidering eigendecomposition in the form of $A = PDP^{-1}$ and SVD $A=U\\Sigma{}V^*$.\\\\\n\nFor Hermitian matrices, there is no fundamental difference between the SVD and eigenvalue decompositions. The squared singular values are eigenvalues of the normal matrix:\n$$\\sigma_i(A)=\\sqrt{\\lambda_i(AA^*)}=\\sqrt{\\lambda_i(AA^*)}$$\nWhere\n$$A^*A=(V\\Sigma{}U^*)(U\\Sigma{}V^*)=V\\Sigma^2V^*$$\n\nFor other matrices, SVD can be applied to any kind of rectangular or square matrix while the eigendecomposition can only be applied to some of the square matrices. SVD requires the diagonal matrix $\\Sigma$ to be real and non-negative while in eigendecomposition the entries of D can be complex value. Other difference can be directly derived from the form of decomposition.\n\n\\section{Code Implementation Perspective}\nSVD can be a more general implementation for eigendecomposition calculation on Hermitian (symmetric) matrices.\n\nSpecifically, we can derive all eigenvalues in $O(n^3)$ then calculate the eigendecomposition value. The SVD can be computed by performing an eigenvalue computation for the normal matrix $A^*A$ (a positive-semidefinite matrix) in $\\sim{}O(mn^2)$ time.\n\n\\begin{thebibliography}{9}\n\\bibitem{Lecture5handout}\nAleksandar Donev: Scientific Computing-Eigen and Singular Values,\n\\\\\\texttt{http://cims.nyu.edu/~donev/Teaching/SciComp-Spring2012/Lecture5.handout.pdf}\n\n\\bibitem{Svdnote}\nFrank Dellaert: Singular Value and Eigenvalue Decompositions\n\\\\\\texttt{http://www.cc.gatech.edu/~dellaert/pub/svd-note.pdf}\n\\end{thebibliography}\n\n\\end{document}", "meta": {"hexsha": "258555cb1a9d65c4698c31a6fe01214803aa91cc", "size": 2134, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment0/report.tex", "max_stars_repo_name": "zxybazh/PRML-Assignment", "max_stars_repo_head_hexsha": "2b750fecf91d468a2d5638bdfd13f741de013a47", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-07-06T06:56:01.000Z", "max_stars_repo_stars_event_max_datetime": "2017-07-08T14:29:56.000Z", "max_issues_repo_path": "assignment0/report.tex", "max_issues_repo_name": "zxybazh/PRML-Assignment", "max_issues_repo_head_hexsha": "2b750fecf91d468a2d5638bdfd13f741de013a47", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment0/report.tex", "max_forks_repo_name": "zxybazh/PRML-Assignment", "max_forks_repo_head_hexsha": "2b750fecf91d468a2d5638bdfd13f741de013a47", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.4222222222, "max_line_length": 373, "alphanum_fraction": 0.7760074977, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.554470450236115, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.41040481495093417}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{fullpage}  % More space\n\\usepackage{tgpagella} % Better font\n\\usepackage{microtype} % Slightly improved typography\n\n\\usepackage{hyperref}\n\\usepackage{cleveref}\n\\usepackage{todonotes}\n\n\\usepackage{amsmath, amsfonts, amsthm, amssymb, mathtools} % math\n\\usepackage{mathpartir}\n\n\\usepackage{syntax}\n\\setlength{\\grammarindent}{4em} % increase separation between LHS/RHS\n\n\\usepackage{macro/generic}\n\\usepackage{macro/code}\n\n\n%=====================================================================\n% Author\n%=====================================================================\n\n\\title{A Regular Expression Library for Haskell}\n\\author{Josh Acay \\\\ \\href{mailto:ca483@cornell.edu}{ca483@cornell.edu}}\n\\date{May 22, 2018}\n\n\n%=====================================================================\n% Macros\n%=====================================================================\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{example}{Example}\n\n\\DeclareMathOperator{\\lang}{\\mathcal{L}}\n\\DeclareMathOperator{\\derivative}{D}\n\\DeclareMathOperator{\\nullable}{nullable}\n\n\\newcommand{\\transpose}{^\\top}\n\n\\newcommand{\\by}[1]{\\parens{\\text{#1}}}\n\\newcommand{\\since}[1]{\\parens{\\text{since #1}}}\n\\newcommand{\\eqBy}[1]{\\braces{\\text{#1}}}\n\n\\newcommand{\\haskell}{\\lstinline}\n\n\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n  I detail the implementation of a regular expression library for Haskell.\\footnote{%\n    Available online at \\url{https://github.com/cacay/regexp}.}\n  Unlike similar libraries in the wild, this one supports more than just matching strings: it can compute intersections and complements, take derivatives \\'a la Brzozowski \\cite{Brzozowski64}, check for equivalence, and solve systems of linear equations with regular expression coefficients. In addition, the library is designed to be generic over the alphabet (even allowing infinite ones) so it is not tied to Haskell's builtin \\haskell{Char} and \\haskell{String} types.\n\\end{abstract}\n\n\n\\section{Introduction}\n  Regular expressions provide a simple yet powerful language for string searching and matching. They are expressive enough to describe many common patterns that arise in practice (e.g.\\ alternatives and repetition) but restrictive enough that many desirable properties are effectively decidable (e.g.\\ equivalence and containment checking). Additionally, regular languages are closed under intersection, union, and complement making it possible to expose a natural interface that uses familiar connectives like ``and'', ``or'', and ``not''.\n\n  Unfortunately, practical implementations of regular expressions focus too much on string matching and forego all the benefits of having a restricted language. For instance, I was\n  unable to find a single popular regular expression library (for any programming language) that supports equivalence checking.\n  % Very few support complement and/or intersection, but do so by extending the language\n  % rather than computing the complement or intersection in terms of the basic operators.\n  In fact, many modern implementations add features such as capture groups and backreferences which break most closure properties and make equivalence checking undecidable \\cite{CampeanuSY03}.\n\n  Although string matching is sufficient for many application, there are cases where the additional power is useful (e.g.\\ during design and development) or necessary.\\footnote{%\n    I sketch the application this library was built for in \\cref{application}.}\n  Here, I detail the design and development of a Haskell library that exposes this additional power to the user.\n\n\n\\section{Specification}\n\nGiven an alphabet $\\Sigma$, regular expressions have the following syntax:\n\\begin{grammar}\n  <exp> ::= 1\n  \\alt <exp> + <exp>\n  \\alt <exp> $\\cdot$ <exp>\n  \\alt <exp>$^*$\n  \\alt $l \\subseteq \\Sigma$\n\\end{grammar}\n\nThe interpretation of these expressions is standard:\n$1$ matches the empty word,\n$e_1 + e_2$ matches either $e_1$ or $e_2$,\n$e_1 \\cdot e_2$ matches $e_1$ followed by $e_2$,\n$e^*$ matches zero or more copies of $e$,\nand the literal $l$ matches single character words $a$ where $a \\in l$.\nThis is a generalization of the standard syntax which only allows single characters as literals rather than sets of characters or \\emph{character classes} and encodes the set $\\set{a_1, a_2, \\ldots, a_n}$ as $a_1 + a_2 + \\cdots + a_n$. I use character classes directly since they generalize to infinite alphabets (which I will discuss in \\cref{effective-boolean-algebra}) and are more efficient to implement. The expression 0---which matches no strings---is represented with the empty character class $\\emptyset$.\n\nIt is easy enough to define a parametrized algebraic data type \\haskell{RegExp $\\Sigma$} that mirrors this syntax. I implement the following operations on regular expressions:\n\\begin{itemize}\n  \\item \\haskell{matches :: RegExp $\\Sigma$ -> [$\\Sigma$] -> Bool}\\\\\n    \\haskell{matches $e$ $w$} returns \\haskell{True} whenever the expression $e$ matches the word $w$.\n\n  \\item \\haskell{complement :: RegExp $\\Sigma$ -> RegExp $\\Sigma$}\\\\\n    \\haskell{complement $e$} returns a regular expression that matches precisely the words $e$ does not match.\n\n  \\item \\haskell{intersection :: RegExp $\\Sigma$ -> RegExp $\\Sigma$ -> RegExp $\\Sigma$}\\\\\n    \\haskell{intersection $e_1$ $e_2$} returns a regular expression that matches words both $e_1$ and $e_2$ match.\n\n  \\item \\haskell{equivalent :: RegExp $\\Sigma$ -> RegExp $\\Sigma$ -> Either [$\\Sigma$] ()}\\\\\n    \\haskell{equivalent $e_1$ $e_2$} returns \\haskell{Right ()} (i.e.\\ ``true'') if $e_1$ and $e_2$ are equivalent, and \\haskell{Left $w$} otherwise. Here, the word $w$ is a counterexample that is matched by one expression but not the other.\n\n  \\item \\haskell{solve :: LinearSystem $\\Sigma$ -> RegExp $\\Sigma$}: given a system of linear equations of the form:\n    \\begin{gather*}\n      X_1 = e_1^0 + e_1^1 X_1 + e_1^2 X_2 + \\cdots e_1^n X_n\\\\\n      X_2 = e_2^0 + e_2^1 X_1 + e_2^2 X_2 + \\cdots e_2^n X_n\\\\\n          \\vdots\\\\\n      X_m = e_m^0 + e_m^1 X_1 + e_m^2 X_2 + \\cdots e_m^n X_n\n    \\end{gather*}\n    where each $e_i^j$ is non-nullable (i.e.\\ doesn't match the empty string), solve for $X_1$.\\footnote{%\n    Actual type of \\haskell{solve} is slightly different, but amounts to the same thing.} Note that all coefficients need to be on the same of the variables to ensure there is a solution. I arbitrarily pick left.\n\n    \\haskell{solve} is a versatile and powerful function. It can derive \\haskell{intersection}, \\haskell{complement}, and many other operators. However, I observed that going through deterministic finite automata gives more succinct expressions.\n\\end{itemize}\n\n\n\\section{Implementation}\n\n\\subsection{Derivatives of Regular Expressions}\n\nThe entirety of this library reduces to Brzozowski derivatives, deterministic finite state automata (DFAs), and the correspondence between them. The derivative of a regular expression $e$ with respect to a character $a \\in \\Sigma$ is a regular expression $e'$ such that $e'$ matches a word $w$ if and only if $e$ matches $a w$. Brzozowski showed that derivatives always exist and that they could be computed syntactically \\cite{Brzozowski64}. This has an obvious extension to arbitrary words $w$, which I denote by $\\derivative_w{(e)}$. This gives a trivial way to implement matching:\n\\begin{equation*}\n  \\haskell{matches $e$ $w$ = nullable ($\\derivative_w{(e)}$)}\n\\end{equation*}\nwhere \\haskell{nullable $e$} if and only if $e$ can match the empty word. There is no need to explicitly convert to a DFA, although one might still want to for efficiency's sake.\n\n\\subsection{Computing Intersection and Complement}\n\nTo compute intersection and complement, I go through the standard motions of converting regular expressions to DFAs, performing the relevant operation on the DFA representations (product construction for intersection and flipping accepting/non-accepting states for complement), and converting back. Although the concept of going through DFAs is not new, the methods I use are hard to come by in real-world code (even though they are not novel theoretically).\n\nIn the forward direction, I construct a DFA directly from a regular expression using Brzozowski derivatives instead of determinizing a nondeterministic finite state automaton, which is what most implementations do. The idea is simple: derivatives of a regular expression are the states of the deterministic automaton and there is an $a$ transition from $e$ to $e'$ if $\\derivative_a{(e)} = e'$. Considering the derivative with respect to all words gives the full automaton. Brzozowski showed in \\cite{Brzozowski64} that this process generates only finitely many states as long as regular expressions are compared modulo associativity, commutativity, and idempotence of $+$ (ACI). I achieve this by keeping the type \\haskell{RegExp} abstract and only exposing ``smart'' constructors that normalize regular expressions with respect to the following equalities:\n\\begin{mathpar}\n(r + s) + t = r + (s + t)\n\\and r + s = s + t\n\\and r + r = r\n%\n\\\\ 0 + r = r\n%\n\\\\ (r \\cdot s) \\cdot t = r \\cdot (s \\cdot t)\n\\and 1 \\cdot r = r = r \\cdot 1\n\\and 0 \\cdot r = 0 = r \\cdot 0\n%\n\\\\ (r^*)^* = r^*\n\\and 0^* = 1\n\\and 1^* = 1\n\\end{mathpar}\nThe first three equalities are required for termination as discussed; others reduce the number of states generated which speeds up execution and results in smaller more readable expressions. To get even smaller expressions, I keep regular expressions in strong star normal form, which was introduced as a linear time simplification method in \\cite{GruberG10}. Very basically, the strong star normal form limits applications of $^*$ to non-nullable expressions, so $(1 + a)^*$ would get converted to the equivalent $a^*$.\n\n\nThe other direction, converting a DFA into a regular expression, is essentially unimplemented: I was unable to find a single library, or even a single piece of working code that does it\\footnote{%\n  I did find a Coq library described in \\cite{DoczkalKS13} that implements DFA to regular expression conversion and does so in a mechanically verified way, but being a constructive proof, the implementation was so inefficient it was unable to convert the expression $0$ to a DFA and back.}.\n  Worse yet, a web search yields no results that are easy to turn into an algorithm. Most sources talk about solving a system of linear equations but offer no insight into how. Such methods might work if one is doing this by hand, but of course a computer requires a more formal specification.\n\n  The method I settled on is due to Kozen \\cite{Kozen94}. The idea is simple and elegant: represent the DFA in matrix form as a triple $\\angled{u, M, v}$ where $u$ and $v$ are $\\set{0, 1}$ vectors representing starting and accepting states, respectively, and $M$ is the transition matrix. Then, $u\\transpose M^* v$ gives a regular expression that matches the set of words accepted by this DFA\\@. I use a home-baked implementation of sparse vectors and sparse matrices to represent DFAs since I was unable to find an existing Haskell library that was up to the task. The most interesting part of this is the implementation of Kleene star for matrices, which uses the divide-and-conquer method of \\cite{Kozen94}. Further details on the technique can be found in \\cite{Kozen94}.\n\n\n\\subsection{Equality Checking}\n\nI use Hopcroft and Karp's bisimulation algorithm for checking DFA equivalence \\cite{HopcroftK71} modified to use a union-find structure as described in \\cite{BonchiP11}. However, I generate the DFAs on the fly using Brzozowski derivatives instead of computing them upfront. This gives the algorithm a chance to fail early and avoid the exponential time process of converting to a DFA\\@. The implementation is able to generate a counterexample if the expressions are not equivalent.\n\n\n\\subsection{Solving Systems of Linear Equations}\n\nGiven a system of linear equations of the form\n\\begin{gather*}\n  X_1 = e_1^0 + e_1^1 X_1 + e_1^2 X_2 + \\cdots e_1^n X_n\\\\\n  X_2 = e_2^0 + e_2^1 X_1 + e_2^2 X_2 + \\cdots e_2^n X_n\\\\\n      \\vdots\\\\\n  X_m = e_m^0 + e_m^1 X_1 + e_m^2 X_2 + \\cdots e_m^n X_n\n\\end{gather*}\nwhere $e_i^j$ are non-nullable, it is possible to solve for $X_1$ using Arden's lemma and Gaussian elimination. Arden's lemma states that the unique solution to the equation $X = A \\cdot X + B$ is $A^* B$ as long as $A$ is non-nullable. Using the lemma, it is possible to eliminate variables one at a time by walking down the list\\footnote{%\nApply the lemma to the first equation to get an equation for $X_1$ that doesn't refer to itself, then substitute it in for $X_1$ in all following equations. Rinse and repeat until you reach the bottom.} until $X_m$ is reached. At this point, the equation for $X_m$ only refers to itself, so apply Arden's lemma to get a closed expression for $X_m$. This can be propagated back using substitution by walking up the list. At each step, the equation for a variable will only contain that variable so Arden's lemma gives a closed form solution.\n\nLinear equation solving is useful for many applications, one of which is computing intersection and complement. It is easy to see that\n\\[ \\haskell{intersection $e_1$ $e_2$}\n  = (\\haskell{nullable $e_1$} = \\haskell{nullable $e_2$}) + \\sum_{a \\in \\Sigma}{a  \\cdot \\haskell{intersection (derivative $a$ $e_1$) (derivative a $e_2$)}}\n\\]\nand\n\\[ \\haskell{complement $e$}\n  = \\neg(\\haskell{nullable $e$}) + \\sum_{a \\in \\Sigma}{a \\cdot \\haskell{complement (derivative $a$ $e$)}}\n\\]\n(interpreting booleans as regular expressions in the expected way). Unfolding these definitions indefinitely and treating every application of the operator to unique input(s) as a fresh variable results in a finite system of linear equations since every regular expression has a finite set of derivatives modulo ACI as discussed.\n\n\n\\subsection{Generalizing Literals}\\label{effective-boolean-algebra}\n\nRather than fixing literals to be sets of characters, I define them to be elements of an effective boolean algebra $\\angled{\\Sigma, U, \\bracks{\\cdot}, \\sqcup, \\sqcap, \\bot, \\top}$.\nThe implementation closely follows the presentation in \\cite{KeilT14} so I will elide the details. The important thing to note is that effective boolean algebras have many useful instantiations including finite subsets of a finite alphabet, finite and cofinite (a set whose complement is finite) subsets of an infinite alphabet, a logic of decidable propositions over an alphabet and so on.\n\nMy implementation is generic against this abstract interface so all these options can be made to work easily, but I only provide an implementation of finite and cofinite subsets of a \\emph{finite} alphabet. One might wonder the point of supporting cofinite subsets of a finite alphabet since they are finite sets after all. The reason is that supporting cofinite subsets gives major speedups when working with very large alphabets such as the set of Unicode characters. For example, the representation of \\haskell{complement $\\set{a}$} is simply the complemented set $\\neg\\set{a}$ which needs to list a single element. Representing this set directly would require listing all characters that are not ``a'' of which there are millions.\n\n\n\\section{Testing and Verification}\n\nI employ a mix of static and dynamic techniques to ensure correctness. Static guarantees are a result of Haskell's incredibly powerful type system. For example, I use algebraic data types to ensure all regular expressions conform to the syntax described in this paper. With normalized regular expressions, I had to go a step further and use generalized algebraic data types (a.k.a.\\ indexed algebraic data types) \\cite{CheneyH03} to check invariants such as ``Kleene star is only applied to non-nullable regular expressions''. This is achieved by indexing the data type of regular expression by a boolean \\haskell{isNullable} with the obvious meaning. The implementation of sparse vectors and sparse matrices goes yet another step further straight into the dependently typed territory. These types are indexed by their size to enforce invariants such as ``only vectors of equal length are added together''. I use the singletons library \\cite{Singletons} for this purpose, which gives Haskell limited dependent programming capabilities. I insert dynamic assertions wherever the type system falls short. These dynamic checks are useful for two reasons: (1) they increase the likelihood of catching bugs, and (2) they make tracking down the root cause of said bugs much easier.\\footnote{%\n  I discovered one bug due to an assertion failure. A different unrelated bug in the regular expression to DFA conversion code was discovered during testing by manual inspection of output, but I tracked it down by inserting dynamic checks (which, in hindsight, should have been there to begin with).\n}\n\nIn addition to static checks, I use unit tests and property testing to further increase the confidence in the library. Unit tests are assertions on ground terms such as\n  \\[ \\haskell{intersection $(a + b)^*$ $a^*$} = a^* \\]\n  where $a$, $b$ are concrete elements of a concrete type $\\Sigma$, say, \\haskell{Char}.  Haskell's hspec library\\footnote{%\n  \\url{https://hackage.haskell.org/package/hspec}\n} provides a good framework for writing such tests. I use SmallCheck \\cite{SmallCheck} and QuickCheck \\cite{QuickCheck} for property testing. These libraries allow one to write logical assertions such as\n\\[ \\forall e_1, e_2. \\haskell{equivalent $e_1$ $e_2$} = \\haskell{Right ()}\n   \\implies \\forall w. \\haskell{matches $e_1$ $w$} = \\haskell{matches $e_2$ $w$}\n \\]\nand verifies these assertions by instantiating them with concrete terms. QuickCheck randomly generates a fixed number of examples whereas SmallCheck systematically generates \\emph{all} inputs. I use QuickCheck to test against a large alphabet (Unicode characters), and SmallCheck to tests against a very small alphabet with three characters. SmallCheck was very helpful for catching bugs at corner cases and generating simple counterexamples (since the alphabet is very small).\n\nDuring random testing, I frequently ran into exponential behavior with functions \\haskell{equivalent}, \\haskell{intersection}, and \\haskell{complement}. These operations have proven lower bounds \\cite{Kozen77,GeladeN12} so occasional bad behavior is unavoidable, but the usual claim is that they fare much better on real-world inputs (see \\cite{FosterKM0T15} for instance). It is interesting to note that this claim apparently does not extend to \\emph{random} inputs. As a solution, I limit the size of randomly generated regular expressions to 4 or 5 operators which is sufficient to get high code coverage.\n\nThis was the first time I took testing seriously and it certainly paid off. I had been of the opinion that having the backing of a powerful type system like Haskell's and writing well-structured code would make it nigh impossible to introduce bugs. However, despite being extra careful and utilizing Haskell's type system to its fullest, I discovered half a dozen bugs during testing. On the plus side, I was able to focus on writing ``interesting'' tests thanks to Haskell's type system (users of untyped languages have to write hundreds of tests essentially asserting their program is well-typed). This goes on to show that type systems and testing go hand in hand.\n\n\\section{An Application: Unicode Grapheme Cluster Breaks}\\label{application}\n\nIn this section, I briefly talk about the reason this library exists in the first place.\n\nUnicode has become the de facto standard for international text. However, it is such a complicated beast that most people have misconceptions about how Unicode works. One of these misconceptions is the idea that each character you see on the screen corresponds to a single Unicode code point. This is a reasonable expectation since ``a'', ``!'', and ``$\\Omega$'' are all Unicode code points. However, there are ``characters'' that require more than one Unicode code point to represent. For example, G with acute accent \\'G requires two. Such a group of code points that represent a single user-perceived character is called a grapheme cluster.\n\nUnicode strings are transmitted as flat sequences of code points, so breaking them up into their grapheme clusters might (and should) be a first step in any code that is to handle Unicode correctly. The Unicode standard gives a declarative specification of how this should be done\\footnote{\\url{http://unicode.org/reports/tr29}} using an ordered list of rules with the following two forms: $e_1 \\times e_2$ meaning break at positions where the left-hand side matches $e_1$ and the right-hand side matches $e_2$, and $e_1 \\div e_2$ meaning do not break at matching positions. When rules overlap, the first one in the list applies. The Unicode technical report claims without proof that these rules can be converted into a regular expression that can be used to extract grapheme clusters (by repeating a longest match for example).\n\nI thought this was an interesting way to specify text segmentation rules, so I wanted to come up with an algorithm to do this translation for the general case. I had a translation in mind that used intersection and complement extensively, so I implemented this library to see the algorithm in action. Unfortunately, that algorithm was not correct, and fixing it is left for future work.\n\n\\section{Conclusion and Future Work}\n  I presented a regular expressions library for Haskell that implements very well-known theoretical results that somehow never made their appearance in popular tools. As always, some work remains to be done. First, there is significant room for optimization.  My implementation of sparse vectors and sparse matrices could use a lot of work, and suppressing Haskell's default lazy semantics in computation heavy regions might lead to significant speedups. Second, I would like to implement DFA minimization and use it to simplify regular expressions generated by \\haskell{intersection} and \\haskell{complement} operations. Normalizing regular expressions already simplifies them quite a bit, and going through DFAs using Brzozowski derivatives generally produces readable (and perhaps even minimal) expressions, but there are cases where the output is quite hairy. I'm hoping minimizing DFAs could remedy this situation. Finally, the interface could use some work. The code is modularized in a way that makes sense from the implementer's perspective, but it is not the interface that should be exposed to the user.\n\n\n\n%=====================================================================\n% Bibliography\n%=====================================================================\n\n\\bibliographystyle{acm}\n\\bibliography{bibliography,bibliography-extra}\n\n\\end{document}\n", "meta": {"hexsha": "922aab7159202a59af9dfafe3c4dcb0ed6bab651", "size": 22801, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/report.tex", "max_stars_repo_name": "cacay/regexp", "max_stars_repo_head_hexsha": "25fd123edb00ce0dbd8b6fd6732a7aeca37e4a47", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-06-15T15:04:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-22T01:45:27.000Z", "max_issues_repo_path": "paper/report.tex", "max_issues_repo_name": "cacay/regexp", "max_issues_repo_head_hexsha": "25fd123edb00ce0dbd8b6fd6732a7aeca37e4a47", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-01-10T23:21:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-10T23:21:41.000Z", "max_forks_repo_path": "paper/report.tex", "max_forks_repo_name": "cacay/regexp", "max_forks_repo_head_hexsha": "25fd123edb00ce0dbd8b6fd6732a7aeca37e4a47", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-05-22T04:09:50.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-22T04:09:50.000Z", "avg_line_length": 94.6099585062, "max_line_length": 1285, "alphanum_fraction": 0.7584755055, "num_tokens": 5420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6442251064863698, "lm_q1q2_score": 0.4103912402878924}}
{"text": "\\section{Experimental Evaluation} \n\\label{sec:Eval} \n\n\nThis section presents experiments to evaluate how much running time costs in terms of performance. The experiments will show that, in practice, \\dyntset is faster by a factor of $O(\\log n)$ per operation than that of the theoretical analysis (Section\\ref{sec:TechDes}).\n\nThis section is organised as follows. Firstly, we describe the experimental setup. Secondly, a brief description in the implementation of test sets is provided. We then present experimental studies of the three different operations in \\dyntset. Finally, we present an additional experiment for the cases where laziness as speeding up factor in favor of the running times for the dynamic tree operations.\n\n\n\\subsection{Experimental Setup}\nFunctions \\link, \\cut, \\conn, \\code{root} and \\code{reroot} were implemented by the author in Haskell and compiled with \\code{ghc} version 8.0.1 with optimisation \\code{-O2}. The experiments were performed on a 2.2 GHz Intel Core i7 MacBook Pro with 16 GB 1600 MHz DDR3 running macOS High Sierra version 10.13.1 (17B1003). We imported the following libraries into our code from the online package repository Hackage: \\cite{HaskellFT} code for finger trees, \\cite{HaskellSet} for conventional sets and \\cite{HaskellEdison} for lazy sets.\n\nThe running time of a given computation was determined by the mean of three executions.\n\n\\subsection{Data structure} \n\nThe values maintained by the data structures (sets and finger trees) are stored as fixed-precision \\code{Int} types, holding values from $-2^{29}$ up to $2^{28}$ although we test only the positive values.\n\nThe structures are initialized with a fixed number of nodes (or vertices) $n$; this number does not change during the execution. This allow us to know the initial size of the forest and we subtract it from the benchmarking.\n\nSince \\dyntset is not called by any application, the random generation of nodes for \\link or \\cut does not necessarily be effective. Actually, around 70\\% of the generated nodes $x$ and $y$ passed to \\link and \\cut were not valid, that is, their result turned out to be the original forest. In order to overcome this, we stored the random generated nodes that were effective into a plain files and from there benchmarking the dynamic tree operations.\n\n\n\\subsection{Incremental operations} \nWe start with an empty forest (just singleton-trees); given $n=20,000$ nodes we perform $1 \\ldots 20,000$ \\link operations. Upon reaching a target length, we plot the total time taken. Then, we divide the time taken by the number of operations to calculate the time per operation and then multiply it by a constant (x1000) to make the curve visible in the same chart.\n\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.4]{./Images/plotLink} \n\\end{center}\n\\caption{Sequence of {\\link}s from empty forest up to a single tree in such forest}\n\\label{fig:incLink}\n\\end{figure}\n\n\\textit{\\emph{Results}}. The behaviour of the curve regarding the time per \\link operation shows that in practice it takes $O(1)$ against $O(\\log n^2)$ in theory back in Section~\\ref{sec:TechDes}, or the linear behaviour by the \\link operations in bulk.\n\n\\subsection{Fully dynamic operations} \nWe start with the incremental process as before for $n=10,000$. Then, for \\cut we start in the opposite direction, that is, cutting from a single tree in the forest until only singleton-trees remain in such forest. To this performance we subtract the time take for the incremental bit. For \\conn performance we compute first an interleaved operation of \\link and \\cut (not necessarily in this order). We measure the time taken for \\conn followed by the corresponding \\link or \\cut and then we subtract the interleaved process. The following figures show our three dynamic operations in bulk and per operation.\n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[scale=0.38]{./Images/plotEach}\n  \\caption{In bulk}\n%  \\label{fig:sub1}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[scale=0.38]{./Images/plotOpsIndiv}\n  \\caption{Per operation}\n%  \\label{fig:sub2}\n\\end{subfigure}\n\\caption{Time taken by operation, and interleaved \\link and \\cut}\n\\label{fig:EachOp}\n\\end{figure}\n\n\\textit{\\emph{Results}}. We observe that \\cut and \\conn obey the same pattern as \\link. That is, $O(1)$ time per operation being \\textit{connectivity} the fastest of the dynamic tree operations, as expected.\n\nFrom the above analyses, we notice that \\link performs better when is interleaved with \\cut. To see this behaviour closer, we present the bulk and individual cases in the following charts varying the forest size under the same amount of operations.\n\n\\begin{figure}[H]\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[scale=0.38]{./Images/plotForests}\n  \\caption{In bulk}\n%  \\label{fig:sub1}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n  \\centering\n  \\includegraphics[scale=0.38]{./Images/plotLCForests}\n  \\caption{Per operation}\n%  \\label{fig:sub2}\n\\end{subfigure}\n\\caption{Time taken when \\link and \\cut are interleaved with different forest sizes}\n\\label{fig:EachOp}\n\\end{figure}\n\n\\subsection{Selection of the set data structure}\nThe set-like data structure is crucial in our implementation and testing of \\dyntset since is the search engine for the nodes when any operation is applied to a forest. There are plenty of implementations for such set-like structure, mostly as binary balanced search trees. In our case, where Haskell is a lazy-evaluation language by default, we select two main choices to compare: \\code{Data.Set} which is a strict data type definition and \\code{Data.Edison.Coll.LazyPairingHeap} which is semi-lazy or semi-strict data type. The following figure shows the performance for each.\n\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[scale=0.4]{./Images/plotSets} \n\\end{center}\n\\caption{Dynamic operations through different sets structures as monoidal annotations}\n\\label{fig:plotSets}\n\\end{figure}\n\nThe above curves show that, although by a constant factor, laziness speeds up the running time in the computation of dynamic tree operations through the set-like data structures.\n\n\\tcb{Amortised over what??}\n", "meta": {"hexsha": "3be12e24d0bba876bacc5646a5b5a71c103d3193", "size": 6245, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pub/Eval/Eval.tex", "max_stars_repo_name": "jcsaenzcarrasco/ETdynTs", "max_stars_repo_head_hexsha": "4bf251c1d6a7ac4de916254e7efd2083aa9f9ad8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pub/Eval/Eval.tex", "max_issues_repo_name": "jcsaenzcarrasco/ETdynTs", "max_issues_repo_head_hexsha": "4bf251c1d6a7ac4de916254e7efd2083aa9f9ad8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pub/Eval/Eval.tex", "max_forks_repo_name": "jcsaenzcarrasco/ETdynTs", "max_forks_repo_head_hexsha": "4bf251c1d6a7ac4de916254e7efd2083aa9f9ad8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.4361702128, "max_line_length": 609, "alphanum_fraction": 0.7783827062, "num_tokens": 1552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.41039124028789237}}
{"text": "\\section{Time Integration} \\label{se:TimeIntegration}\n\nSuppose that an algebraic closure based on Fermi-Dirac statistics is used (i.e., the Eddington factor satisfies Eq.~\\eqref{eq:eddingtonFactorBounds}).\nHere we consider the construction of an Implicit-Explicit (IMEX) time integration scheme that maintains the bounds in Eq.~\\eqref{eq:MomentsBounds}.  \nThe semi-discretization of the two-moment model results in a system of ordinary differential equations of the form\n\\begin{equation}\n  \\dot{\\vect{u}} = \\vect{\\cT}(\\vect{u}) + \\vect{\\cQ}(\\vect{u}),\n\\end{equation}\nwhere the solution vector\n\\begin{equation}\n  \\vect{u}(t) = \\left( \\bcM_{1}(t),\\ldots,\\bcM_{N}(t)\\right) ^{T}\n\\end{equation}\nis the collection of all cell-averaged moments, $\\vect{\\cT}$ is the transport operator, corresponding to the first term on the right-hand side of Eq.~\\eqref{eq:SemiDiscretizatedMomentEquation}, and $\\vect{\\cQ}$ is the collision operator, corresponding to the second term on the right-hand side of Eq.~\\eqref{eq:SemiDiscretizatedMomentEquation}.  \n\nSince the set of realizable moments is convex, convex-invariant schemes, which map the initial values into this set, can be used to design realizability-preserving methods for the two-moment model.\nIdeally, the scheme should also be high-order accurate and work well in the asymptotic diffusion limit (characterized by frequent collisions and long time scales).  \nThe following discussion considers the construction of such convex-invariant schemes.  \n\n\\subsection{Standard IMEX Schemes}\n\nTreating the transport operator explicitly and the collision operator implicitly, a standard $s$-stage IMEX scheme takes the following form~\\cite{pareschiRusso_2005}: \n\\begin{align}\n  \\vect{u}^{(i)}\n  &=\\vect{u}^{n}\n  +\\dt\\sum_{j=1}^{i-1}\\tilde{a}_{ij}\\,\\vect{\\cT}(\\vect{u}^{(j)})\n  +\\dt\\sum_{j=1}^{i}a_{ij}\\,\\vect{\\cQ}(\\vect{u}^{(j)}),\n  \\quad i=1,\\ldots,s, \\label{imexStages} \\\\\n  \\vect{u}^{n+1}\n  &=\\vect{u}^{n}\n  +\\dt\\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\vect{\\cT}(\\vect{u}^{(i)})\n  +\\dt\\sum_{i=1}^{s}w_{i}\\,\\vect{\\cQ}(\\vect{u}^{(i)}), \\label{imexIntermediate} \n\\end{align}\nwhere $(\\tilde{a}_{ij})$ and $(a_{ij})$, coefficients of the $i$-th stage, are elements of matrices $\\tilde{A}$ and $A$, respectively.\nThe matrices $\\tilde{A}$ and $A$ are lower triangular.\n($\\tilde{A}$ is strictly lower triangular so that the transport part is explicit.)  \nThe vectors $\\tilde{\\vect{w}}=(\\tilde{w}_{1},\\ldots,\\tilde{w}_{s})^{T}$ and $\\vect{w}=(w_{1},\\ldots,w_{s})^{T}$ are the weights in the assembly step in Eq.~\\eqref{imexIntermediate}.\nThese coefficients and weights must satisfy certain order conditions for consistency, accuracy, and other properties.  \nFor second-order temporal accuracy, the following conditions are required~\\cite{hairer_1981}:\n\\begin{equation}\n  \\sum_{i=1}^{s}\\tilde{w}_{i}=\\sum_{i=1}^{s}w_{i}=1,\n  \\label{orderConditions1}\n\\end{equation}\nand\n\\begin{equation}\n  \\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\tilde{c}_{i}\n  =\\sum_{i=1}^{s}\\tilde{w}_{i}\\,c_{i}\n  =\\sum_{i=1}^{s}w_{i}\\,\\tilde{c}_{i}\n  =\\sum_{i=1}^{s}w_{i}\\,c_{i}=\\f{1}{2}, \n  \\label{orderConditions2}\n\\end{equation}\nwhere $\\tilde{c}_{i} = \\sum_{j=1}^{s}\\tilde{a}_{ij}$ and $c_{i}=\\sum_{j=1}^{s}a_{ij}$.\n\nThe IMEX scheme is called globally stiffly accurate (GSA) if the coefficients satisfy~\\cite{dimarcoPareschi2013}:\n\\begin{equation}\n  a_{si}=w_{i} \\quad\\text{and}\\quad \\tilde{a}_{si}=\\tilde{w}_{i}, \\quad \\text{for} \\quad i=1,\\ldots,s.\n\\end{equation}\nThen, $\\vect{u}^{n+1} = \\vect{u}^{(s)}$, which is simplifying because the assembly step in Eq.~\\eqref{imexIntermediate} is omitted.  \nIMEX schemes are further classified by the structure of the implicit matrix $A$.  \nIf $A$ is invertible, the IMEX scheme is of type~A~\\cite{pareschiRusso_2005}.  \nIf $a_{i1} = 0$ for $i=1,\\ldots,s$, $w_{1} = 0$, and the submatrix consisting of the last $s-1$ rows and columns is invertible, the IMEX scheme is of type~ARS~\\cite{ascher_etal_1997,pareschiRusso_2005}.  \n\n\\subsection{Convex-Invariant IMEX Schemes}\n\nTo be convex-invariant, the coefficients and weights defining the IMEX scheme must satisfy additional constraints.\nOur goal is to find constraints on $a_{ij}$, $\\tilde{a}_{ij}$, $\\tilde{w}_{i}$, and $w_{i}$ that enable each $\\vect{u}^{(i)}$ in Eq.~\\eqref{imexStages} to be expressed as a convex combination of realizable states.  \nFollowing Hu et al.~\\cite{hu_etal_2018}, the stage values in Eq.~\\eqref{imexStages} can be rewritten as\n\\begin{equation}\n  \\vect{u}^{(i)}\n  =\\sum_{j=0}^{i-1}c_{ij}\\Big[\\,\\vect{u}^{(j)}+\\hat{c}_{ij}\\,\\dt\\,\\vect{\\cT}(\\vect{u}^{(j)})\\,\\Big] + a_{ii}\\,\\dt\\,\\vect{\\cQ}(\\vect{u}^{(i)}),\\quad i=1,\\ldots,s,\n  \\label{eq:imexStagesRewrite}\n\\end{equation}\nwhere $c_{ij}$ and $\\hat{c}_{ij}\\equiv\\tilde{c}_{ij}/c_{ij}$ are defined in terms of $a_{ij}$ and $\\tilde{a}_{ij}$.\nFor IMEX schemes of type~ARS, $c_{ij}$ and $\\tilde{c}_{ij}$ are given by~\\cite{hu_etal_2018}\n    \\begin{equation}\n     \\begin{aligned}\n      c_{i0} &= 1-\\sum_{j=2}^{i-1}\\sum_{l=j}^{i-1}a_{il}b_{lj}, \\quad &\n      c_{ij} &= \\sum_{l=j}^{i-1}a_{il}b_{lj}, \\\\\n      \\tilde{c}_{i0} &= \\tilde{a}_{i1}+\\sum_{j=2}^{i-1}a_{ij}\\tilde{b}_{j1}, \\quad &\n      \\tilde{c}_{ij} &= \\tilde{a}_{ij}+\\sum_{l=j+1}^{i-1}a_{il}\\tilde{b}_{lj},  \n     \\end{aligned}\n     \\label{eq:positivityCoefficientsARS}\n    \\end{equation}\n    \\begin{equation}\n      b_{ii} = \\f{1}{a_{ii}}, \\quad\n      b_{ij} = -\\f{1}{a_{ii}}\\sum_{l=j}^{i-1}a_{il}b_{lj}, \\quad\n      \\tilde{b}_{ij} = -\\f{1}{a_{ii}}\\Big(\\tilde{a}_{ij}+\\sum_{l=j+1}^{i-1}a_{il}\\tilde{b}_{lj}\\Big).  \n    \\end{equation}\nNote that $c_{i1}=\\tilde{c}_{i1}=0$ in Eq.~\\eqref{eq:positivityCoefficientsARS}, so that $\\sum_{j=0}^{i-1}c_{ij}=1$.\n\nIf the IMEX scheme is GSA, $\\vect{u}^{n+1} = \\vect{u}^{(s)}$.  \nMoreover, if $c_{ij},\\tilde{c}_{ij}\\ge0$ and $a_{ii}>0$, each stage in Eq.~\\eqref{eq:imexStagesRewrite} is a convex combination of explicit Euler steps (with time step $\\hat{c}_{ij}\\dt$), followed by an implicit Euler step.  \nEach of the explicit Euler steps has a time step condition that ensures its realizability given by $\\hat{c}_{ij}\\,\\dt\\leq\\dx$; the CFL condition of the scheme.\nUsing results proved in~\\cite{chu_etal_2018} and discussed in Section~\\ref{se:SpatialDiscretization}, the IMEX scheme is convex-invariant and realizability-preserving for the two-moment model in Section~\\ref{se:SpatialDiscretization} provided\n\\begin{equation}\n  \\max(\\hat{c}_{ij})\\,\\dt \\leq \\dx.  \n\\end{equation}\n(This CFL condition becomes more restrictive with high-order DG spatial discretization~\\cite{chu_etal_2018}.)\n\n\\subsection{Diffusion Accurate, Convex-Invariant IMEX Schemes}\n\nAccuracy in the diffusion limit is another important property to consider when an IMEX scheme is applied to the two-moment model.  \nIn the diffusion limit, the distribution function is nearly isotropic, so $\\vect{\\cK}\\approx\\f{1}{3}\\,\\cJ\\,\\vect{I}$ and $\\vect{\\cH}\\approx-\\f{1}{3}\\,\\tau\\,\\nabla\\cJ$, and the two-moment model is approximately governed by (e.g., \\cite{jinLevermore_1996})\n\\begin{equation}\n  \\pd{\\cJ}{t} + \\nabla\\cdot\\vect{\\cH} = 0\n  \\quad\\text{and}\\quad\n  \\vect{\\cH} = - \\tau\\,\\nabla\\cdot\\vect{\\cK}.  \n  \\label{eq:diffusionLimit}\n\\end{equation}\nIn the context of IMEX schemes, the above relationships imply that the following relations should hold~\\cite{chu_etal_2018}:\n\\begin{equation}\n   \\vect{e}_{i}^{T}A^{-1}\\tilde{A}\\,\\vect{e} = 1, \\quad i=1,\\ldots,s,\n   \\label{diffusionAccuracy}\n\\end{equation}\nwhere $\\vect{e}_{i}$ is the $i$th column of the $s\\times s$ identity matrix, $\\vect{e}$ is the vector of ones, and $A$ and $\\tilde{A}$ are the matrices of the coefficients $(\\tilde{a}_{ij})$ and $(a_{ij})$.\nEq.~\\eqref{diffusionAccuracy} implies:\n\\begin{equation}\n  c_{i} = \\tilde{c}_{i}, \\quad i=1,\\ldots,s.\n\\end{equation}\nWe have proved in \\cite{chu_etal_2018} that only IMEX schemes of type~ARS can be both diffusion accurate and convex-invariant.  \n(Another short proof follows from the fact that IMEX schemes of type~A have $\\tilde{c}_1 = 0$ while $c_i \\neq 0$.)  \n\n\\subsection{PD-ARS IMEX schemes}\n\nUnfortunately, coefficients satisfying the order conditions in Eqs.~\\eqref{orderConditions1}-\\eqref{orderConditions2} and the conditions for convex-invariance do not exist for the standard IMEX scheme in Eqs.~\\eqref{imexStages}-\\eqref{imexIntermediate}, unless a small time step is invoked that makes the scheme essentially explicit.  \nTo circumvent this problem, correction steps can be introduced after the assembly step in Eq.~\\eqref{imexIntermediate} (e.g., \\cite{chertock_etal_2015,hu_etal_2018}).  \nHowever, the correction steps can impose time step constraints for realizability or accuracy in the diffusion limit that ruin the efficiency gains expected from the IMEX scheme.  \nBecause of this, we sacrifice overall high-order accuracy, and aim for IMEX schemes that are high-order accurate in the streaming limit, diffusion accurate, and convex-invariant.  \nCombining these requirements we seek GSA IMEX schemes of type~ARS with coefficients satisfying the following constraints~\\cite{hu_etal_2018,chu_etal_2018}:\n\\begin{enumerate}\n    \\item Consistency of the implicit coefficients:\n    \\begin{equation}\n      \\sum_{i=1}^{s}w_{i}=1.\n    \\end{equation}\n    \\item High-order accuracy in the streaming limit.\n    For second-order accuracy:\n    \\begin{equation}\n      \\sum_{i=1}^{s}\\tilde{w}_{i}=1\n      \\quad\\text{and}\\quad\n      \\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\tilde{c}_{i}=\\f{1}{2}.\n      \\label{eq:orderConditionsEx}\n    \\end{equation}\n    For third-order accuracy: \n    \\begin{equation}\n    \\sum_{i=1}^{s}\\tilde{w}_{i}=1,\n          \\quad\n          \\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\tilde{c}_{i}=\\f{1}{2},\n          \\quad\n          \\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\tilde{c_{i}}^2 = \\f{1}{3}\n          \\quad\\text{and}\\quad\n          \\sum_{i=1}^{s}\\tilde{w}_{i}\\,\\tilde{a_{ij}}\\tilde{c}_{j}= \\f{1}{6}.\n    \\end{equation}\n    \\item Diffusion accuracy:\n    \\begin{equation}\n      c_{i}=\\tilde{c}_{i}, \\quad i=1,\\ldots,s.\n      \\label{eq:diffusionCondition}\n    \\end{equation}\n    \\item Convex-invariance:\n    \\begin{align}\n      &a_{ii}>0, \\quad c_{i0},\\tilde{c}_{i0}\\ge0, \\quad \\text{for} \\quad i=2,\\ldots,s, \\nonumber \\\\\n      &\\text{and} \\quad c_{ij},\\tilde{c}_{ij}\\ge0, \\quad \\text{for} \\quad i=3,\\ldots,s, \\quad\\text{and}\\quad j=2,\\ldots,i-1,\n      \\label{eq:convexInvariant}\n    \\end{align}\n    with $\\sum_{j=0}^{i-1}c_{ij}=1$, for $i=1,\\ldots,s$, and $c_{\\Sch}:=\\min_{\\substack{i = 2,\\ldots,s \\\\ \n                  j = 0,2,\\ldots,i-1}}\\,\\f{1}{\\hat{c}_{ij}}>0$.\n                  \n    (Note that the greater the $c_{\\Sch}$, the larger the time step can be.\n    And $c_{\\Sch} \\leq 1$.)\n    \\item Having less than five stages ($s\\le4$)\\label{cod:statges}.\n    \\item Are globally stiffly accurate: $a_{si}=w_{i}$ and $\\tilde{a}_{si}=\\tilde{w}_{i},\\quad i=1,\\ldots,s$. \n\\end{enumerate}\nFortunately, these IMEX schemes are easy to find.  \n(The constraint in \\eqref{cod:statges} is introduced from efficiency considerations to limit the number of implicit solves.)\nWe call the IMEX schemes satisfying the above conditions {PD-ARS} (see also Definition~3 in~\\cite{chu_etal_2018}), and we provide two optimal PD-ARS schemes below: PD-ARS2 and PD-ARS3, each limiting to the optimal second-order and third-order SSPRK schemes from~\\cite{shuOsher_1988}, respectively.\n\\subsubsection{PD-ARS2}\n\nThe optimal 3-stage PD-ARS, PD-ARS2, in the standard double Butcher tableau form, with explicit tableau ($\\tilde{A}$) on the left and implicit tableau ($A$) on the right, is given by\n\\begin{align}\n  &\\begin{array}{c | c c c}\n  \t0 & 0   & 0 & 0 \\\\\n  \t1 & 1   & 0 & 0 \\\\\n  \t1 & 1/2 & 1/2 & 0 \\\\ \\hline\n  \t  & 1/2 & 1/2 & 0 \n  \\end{array}\n  \\qquad\n  \\begin{array}{c | c c c}\n  \t0 & 0 & 0            & 0            \\\\\n  \t1 & 0 & 1            & 0            \\\\\n  \t1 & 0 & 1/2 & 1/2 \\\\ \\hline\n  \t  & 0 & 1/2 & 1/2\n  \\end{array}\n\\end{align}\nNote its explicit tableau is SSPRK2. \nFor this scheme, only two implicit solves are needed per time step and $c_{\\Sch}= 1$, which implies that the time step restriction for preserving moment realizability is only due to the explicit part.  \n\n\\subsubsection{PD-ARS3}\n\nThe optimal 4-stage PD-ARS, PD-ARS3, is given in its standard double Butcher tableau form (explicit tableau on the left and implicit tableau on the right) by\n\\begin{align}\n  &\\begin{array}{c | c c c c}\n  \t    &     &     &     &  \\\\\n  \t 1  & 1   &     &     &  \\\\\n  \t1/2 & 1/4 & 1/4 &  \\\\\n  \t 1  & 1/6 & 1/6 & 2/3 &  \\\\ \\hline\n  \t    & 1/6 & 1/6 & 2/3 &\n  \\end{array}\n  \\qquad\n  \\begin{array}{c | c c c c}\n  \t0 & 0 & 0            & 0            \\\\\n  \t1 & 0 & 1            & 0            \\\\\n  \t1/2 & 0 & 1/4 & 1/4 \\\\ \n  \t1 & 0 & 1/6 & 1/6 & 2/3\\\\\\hline\n  \t  & 0 & 1/6 & 1/6 & 2/3\n  \\end{array}\n\\end{align}\nIts explicit tableau is SSPRK3. \nThis scheme requires three implicit solves per time step, and $c_{\\Sch}= 1$.  \nSince PD-ARS3 is not more accurate than PD-ARS2 in collision-dominated regions (see our results in Section~\\ref{se:NumericalTests}), it may not offer any practical advantage over PD-ARS2.  \n", "meta": {"hexsha": "55014af78b7d7b7b11611cfb026c105012635a4f", "size": 12998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/Astronum_2018/sections/TimeIntegration.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/Astronum_2018/sections/TimeIntegration.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/Astronum_2018/sections/TimeIntegration.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 59.623853211, "max_line_length": 346, "alphanum_fraction": 0.6685643945, "num_tokens": 4593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4103912356725751}}
{"text": "\\input{wpg03_notation_define.tex}\n\n%%%\n\\chapter{WPG v.03: WPG considering external forces}\n\n\\gbox{\n    \\red{Warning:}\n    This module is unsupported -- the documentation may contain errors. Refer\n    to \\cite{Agravante2016preprint} and \\cite{Agravante2016icra} for more\n    information.\n}\n\nThis version of the pattern generator is based on a model that considers external forces.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Model}\nSeparating the coplanar contact forces $\\fCoplanar$ and an external wrench in the CoM frame:\n$[\\fExt^\\top ~ \\tExt^\\top]^\\top$, the equations of motion are:\n\n\\begin{align}\n m(\\comA + \\gravity) &= \\fExt + \\sum_i \\fCoplanar  \\\\\n \\momAngD &= \\tExt + \\sum_i (\\pCoplanar - \\comP) \\times \\fCoplanar\n\\end{align}\n\nBy following the derivations:\n\\begin{equation}\n m \\comP \\times (\\comA + \\gravity) + \\momAngD - \\tExt - (\\comP \\times \\fExt)\n =\n \\sum_i \\pCoplanar \\times \\fCoplanar\n\\end{equation}\n\nDividing to get the Center of Pressure expression on the right hand part:\n\\begin{equation}\n \\frac{m \\comP \\times (\\comA + \\gravity) + \\momAngD - \\tExt - (\\comP \\times \\fExt) }\n {m(\\ddot{c}^z + g^z) - f_{ext}^z}\n =\n \\frac{\\sum_i \\pCoplanar \\times \\fCoplanar}\n {\\sum_i f_i^z}\n\\end{equation}\n\nFor a flat ground $p_i^z = 0$ and $\\gravity^{x,y} = \\mathbf{0}$ and using the approximations: $\\ddot{c}^z = 0$ and $\\momAngD = 0$ the ZMP in the\nplane is:\n\\begin{equation}\n \\zmp^{x,y}\n =\n \\frac{\\sum_i f^z_i \\pCoplanar^{x,y}}{\\sum_i f_i^z}\n =\n \\left( \\frac{m g^z}{m g^z - f^z_{ext}} \\right)\n \\left( \\comP^{x,y} - \\frac{c^z}{g^z} \\comA^{x,y} \\right)\n -\n \\mathbf{S}\n \\left( \\frac{\\tExt^{x,y} + (\\comP \\times \\fExt)^{x,y} }{mg^z - f^z_{ext}} \\right)\n\\end{equation}\nwhere\n\\begin{equation}\n \\mathbf{S} =\n \\begin{bmatrix}\n  0 & -1 \\\\\n  1 & 0\n \\end{bmatrix}\n\\end{equation}\n\nDeveloping further:\n\n\\begin{equation}\n \\zmp^{x,y}\n =\n \\left( \\frac{m g^z}{m g^z - f^z_{ext}} \\right)\n \\left( \\comP^{x,y} - \\frac{c^z}{g^z} \\comA^{x,y} \\right)\n -\n \\mathbf{S}\n \\left( \\frac{\\tExt^{x,y} }{mg^z - f^z_{ext}} \\right)\n -\n \\left( \\frac{\\comP^{x,y}\\fExt^z - \\comP^z\\fExt^{x,y}}{mg^z - f^z_{ext}} \\right)\n\\end{equation}\n\nGrouping the terms:\n\\begin{equation}\n \\zmp^{x,y}\n =\n \\left( \\comP^{x,y} - \\left( \\frac{c^z}{g^z} \\right) \\left( \\frac{m g^z }{m g^z - f^z_{ext}} \\right) \\comA^{x,y}  \\right)\n -\n \\mathbf{S}\n \\left( \\frac{\\tExt^{x,y} }{mg^z - f^z_{ext}} \\right)\n +\n \\left( \\frac{\\comP^z\\fExt^{x,y}}{mg^z - f^z_{ext}} \\right)\n\\end{equation}\n\n\\section{MPC}\nThe model in $x$ is:\n\\begin{equation}\n \\begin{bmatrix}\n \\dot{c}^x \\\\\n \\ddot{c}^x \\\\\n \\dddot{c}^x\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n  0 & 1 & 0 \\\\\n  0 & 0 & 1 \\\\\n  0 & 0 & 0\n \\end{bmatrix}\n \\begin{bmatrix}\n c^x \\\\\n \\dot{c}^x \\\\\n \\ddot{c}^x\n \\end{bmatrix}\n +\n \\begin{bmatrix}\n 0 \\\\\n 0 \\\\\n 1\n \\end{bmatrix}\n \\dddot{c}^x\n\\end{equation}\n\n\\begin{equation}\n z^x\n =\n \\begin{bmatrix}\n 1 &\n 0 &\n -\\frac{m g^z}{(m g^z - f^z_{ext} ) \\omega^2}\n \\end{bmatrix}\n \\begin{bmatrix}\n c^x \\\\\n \\dot{c}^x \\\\\n \\ddot{c}^x\n \\end{bmatrix}\n +\n \\frac{n^y_{ext} + c^z f^x_{ext}}{mg^z - f^z_{ext}}\n\\end{equation}\n\nRewriting:\n\\begin{equation}\n \\begin{bmatrix}\n \\dot{c}^x \\\\\n \\ddot{c}^x \\\\\n \\dddot{c}^x\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n  0 & 1 & 0 \\\\\n  0 & 0 & 1 \\\\\n  0 & 0 & 0\n \\end{bmatrix}\n \\begin{bmatrix}\n c^x \\\\\n \\dot{c}^x \\\\\n \\ddot{c}^x\n \\end{bmatrix}\n +\n \\begin{bmatrix}\n  0 \\\\\n  0 \\\\\n  1\n \\end{bmatrix}\n \\dddot{c}^x\n\\end{equation}\n\n\\begin{equation}\n z^x\n =\n \\begin{bmatrix}\n  1 &\n  0 &\n  -\\frac{m g^z}{(m g^z - f^z_{ext} ) \\omega^2}\n \\end{bmatrix}\n \\begin{bmatrix}\n c^x \\\\\n \\dot{c}^x \\\\\n \\ddot{c}^x\n \\end{bmatrix}\n +\n \\begin{bmatrix}\n  \\frac{1}{m g^z - f^z_{ext}} &\n  \\frac{c^z}{m g^z - f^z_{ext}}\n \\end{bmatrix}\n \\begin{bmatrix}\n  n^y \\\\\n  f^x\n \\end{bmatrix}\n\\end{equation}\n\nThe model is of the form\n\\begin{align}\n \\mathbf{\\dot{x}} &= \\mathbf{A} \\mathbf{x} + \\mathbf{B} \\mathbf{u} \\\\\n \\mathbf{y} &= \\mathbf{D} \\mathbf{x} + \\mathbf{G} \\mathbf{f}\n\\end{align}\n\nDiscretization and concatenating the $x$ and $y$ DOFs leads to:\n\\begin{align}\n \\cstate_{k+1}\t=& \\M{A}_k \\cstate_k\t  + \\M{B}_k \\mathbf{u}_k \\\\\n \\cop_{k+1} \t=& \\M{D}_{k+1} \\cstate_{k+1} + \\M{G}_{k+1} \\mathbf{f}_{k+1} \\\\\n\t\t=& \\M{D}_{k+1}\\M{A}_k\\cstate_{k} + \\M{D}_{k+1}\\M{B}_k \\mathbf{u}_k + \\M{G}_{k+1} \\mathbf{f}_{k+1}\n\\end{align}\n\\begin{equation}\n\\M{A}_k =\n\\begin{bmatrix}\n    1       & T_k   & T_k^2/2   & 0 & 0 & 0\\\\\n    0       & 1     & T_k       & 0 & 0 & 0\\\\\n    0       & 0     & 1         & 0 & 0 & 0\\\\\n    0 & 0 & 0                   & 1       & T_k   & T_k^2/2   \\\\\n    0 & 0 & 0                   & 0       & 1     & T_k       \\\\\n    0 & 0 & 0                   & 0       & 0     & 1         \\\\\n\\end{bmatrix}\n\\quad\n\\M{B}_k =\n\\begin{bmatrix}\n    T_k^3/6 & 0 \\\\\n    T_k^2/2 & 0 \\\\\n    T       & 0 \\\\\n    0       & T_k^3/6 \\\\\n    0       & T_k^2/2 \\\\\n    0       & T\n\\end{bmatrix}\n\\end{equation}\n\n\\begin{equation}\n\\M{D}_{k} =\n\\begin{bmatrix}\n    1 & 0 & -\\frac{m g^z}{(m g^z - f^z_k ) \\omega_k^2}\n  & 0 & 0 & 0 \\\\\n\n    0 & 0 & 0\n  & 1 & 0 & -\\frac{m g^z}{(m g^z - f^z_k ) \\omega_k^2}  \\\\\n\\end{bmatrix}\n\\M{G}_{k} =\n\\begin{bmatrix}\n  \\frac{1}{m g^z - f^z_k}  & \\frac{c^z_k}{m g^z - f^z_k} & 0 & 0 \\\\\n  0 & 0 & -\\frac{1}{m g^z - f^z_k}  & \\frac{c^z_k}{m g^z - f^z_k}  \\\\\n\\end{bmatrix}\n\\end{equation}\n\\begin{equation}\n \\omega_k = \\sqrt{\\frac{g}{c^z_k}}\n \\quad\n \\mathbf{u}_k =\n \\begin{bmatrix}\n  \\dddot{c}^x_k \\\\\n  \\dddot{c}^y_k\n \\end{bmatrix}\n \\quad\n \\mathbf{f}_k =\n \\begin{bmatrix}\n  n^y_k \\\\\n  f^x_k \\\\\n  n^x_k \\\\\n  f^y_k\n \\end{bmatrix}\n\\end{equation}\n\nCondensing the model results in:\n\\begin{align}\n    \\begin{bmatrix}\n        \\cstate_1 \\\\\n        \\vdots\\\\\n        \\cstate_{N}\\\\\n    \\end{bmatrix}\n    =&\n    \\M{U}_x \\cstate_0\n    +\n    \\M{U}_u\n    \\begin{bmatrix}\n        \\mathbf{u}_0 \\\\\n        \\vdots \\\\\n        \\mathbf{u}_{N-1} \\\\\n    \\end{bmatrix} \\\\\n%\n    \\begin{bmatrix}\n        \\cop_1 \\\\\n        \\vdots \\\\\n        \\cop_{N} \\\\\n    \\end{bmatrix}\n    =&\n    \\M{O}_x \\cstate_0\n    +\n    \\M{O}_u\n    \\begin{bmatrix}\n        \\mathbf{u}_0 \\\\\n        \\vdots \\\\\n        \\mathbf{u}_{N-1} \\\\\n    \\end{bmatrix}\n    +\n    \\M{O}_f\n    \\begin{bmatrix}\n        \\mathbf{f}_1 \\\\\n        \\vdots \\\\\n        \\mathbf{f}_{N} \\\\\n    \\end{bmatrix} \\\\\n\\end{align}\n\nor:\n\\begin{align}\n    \\cState\n    =&\n    \\M{U}_x \\cstate_0\n    +\n    \\M{U}_u\n    \\dddot{\\M{C}}\\\\\n%\n    \\hat{\\M{Z}}\n    =&\n    \\M{O}_x \\cstate_0\n    +\n    \\M{O}_u\n    \\dddot{\\M{C}}\n    +\n    \\M{O}_f\n    \\hat{\\M{F}}\\\\\n\\end{align}\n\nexpressing the ZMP to local coordinates:\n\\begin{align}\n    \\cState\n    =&\n    \\M{U}_x \\cstate_0\n    +\n    \\M{U}_u\n    \\dddot{\\M{C}}\\\\\n%\n    \\left(\n        \\M{V}_0 \\fp_0\n        +\n        \\M{V} \\FP\n        +\n        \\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}}\n        \\CoP\n    \\right)\n    =&\n    \\M{O}_x \\cstate_0\n    +\n    \\M{O}_u\n    \\dddot{\\M{C}}\n    +\n    \\M{O}_f\n    \\hat{\\M{F}}\\\\\n\\end{align}\n\nrearranging and grouping the unknowns: $\\dddot{\\M{C}}$ and $\\FP$\n\\begin{align}\n    \\cState\n    =&\n    \\underbrace{\n    \\begin{bmatrix}\n        \\M{U}_u    &   \\M{0} \\\\\n    \\end{bmatrix}\n    }_{\\M{S}}\n    \\underbrace{\n    \\begin{bmatrix}\n        \\dddot{\\M{C}}\\\\\n        \\FP\\\\\n    \\end{bmatrix}\n    }_{\\V{X}}\n    +\n    \\underbrace{\n    \\M{U}_x \\cstate_0\n    }_{\\V{s}}\\\\\n%\n    \\CoP\n    =&\n    \\underbrace{\n    \\begin{bmatrix}\n        \\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top} \\M{O}_u    &\n       -\\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top} \\M{V} \\\\\n    \\end{bmatrix}\n    }_{\\M{S}_{z}}\n    \\underbrace{\n    \\begin{bmatrix}\n        \\dddot{\\M{C}}\\\\\n        \\FP\\\\\n    \\end{bmatrix}\n    }_{\\V{X}}\n    +\n    \\underbrace{\n    \\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top}\n    \\left(\n    \\M{O}_x \\cstate_0\n    +\n    \\M{O}_f \\hat{\\M{F}}\n    -\n    \\M{V}_0 \\fp_0\n    \\right)\n    }_{\\V{s}_{z}}\\\\\n\\end{align}\n\nThe CoM velocity is:\n\\begin{equation}\n    \\cVel =\n        \\diag{N}{\\M{I}_{v}} \\cState =\n        \\diag{N}{\\M{I}_{v}} \\left( \\M{S}\\V{X} + \\V{s} \\right)=\n        \\M{S}_v \\V{X} + \\V{s}_v\n\\end{equation}\n\n\\section{QP}\nThe Constraints are:\n\nCoP positions\n\\begin{align}\n  \\ubarV{Z} \\le \\CoP \\le \\barV{Z} \\\\\n  \\ubarV{Z} \\le \\M{S}_{z} \\V{X} + \\V{s}_{z} \\le \\barV{Z}\n\\end{align}\n\n\nFoot positions\n\\begin{equation}\n  \\ubarV{P} \\le \\FP \\le \\barV{P}\n\\end{equation}\n\nThe Objectives are:\n\nTracking a reference velocity:\n\\begin{equation}\n    \\NORME{\\cVel - \\cVel_{ref}} = \\NORME{\\M{S}_v \\V{X} + \\V{s}_v - \\cVel_{ref}},\n\\end{equation}\n\nMinimize CoM jerk:\n\\begin{equation}\n    \\NORME{\\dddot{\\M{C}}},\n\\end{equation}\n\nMinimize the distance between the CoP positions and the centers of the feet\n\\begin{equation}\n    \\NORME{\\CoP} = \\NORME{\\M{S}_{z} \\V{X} + \\V{s}_{z}}.\n\\end{equation}\n\n\\section{General notes on the external wrench term}\n\n\n\\subsection{Prediction of future values}\nKnowledge of future forces and torques $f^x, f^y, n^x, n^y$ is required in the vector $\\hat{\\M{F}}$ and $f^z$ in the matrices $\\M{D}_{k}, \\M{G}_{k}$\nand consequently $\\M{O}_{x}, \\M{O}_{u}, \\M{O}_{f}$. Note, $n^z$ was implicitly ignored during the modeling.\n\nHere, we assume knowledge of the present wrench $\\mathbf{h}_0$. So a prediction model is required to obtain $\\mathbf{h}_1 \\ldots \\mathbf{h}_N$\n\nSome simple models can be used (mostly for testing):\n\nConstant throughout the preview horizon\n\\begin{equation}\n \\mathbf{h}_1 = \\mathbf{h}_2 = \\ldots = \\mathbf{h}_N = \\mathbf{h}_0\n\\end{equation}\n\nLinear\n\\begin{equation}\n \\mathbf{h}_k = m k T_k +  \\mathbf{h}_0\n\\end{equation}\n\nOther prediction models are also presented in the specific use cases\n\n\\subsection{Frame of reference}\nNote that the modeling placed the external wrench in the CoM frame. However, $\\mathbf{h}_0$ may be expressed in another frame, the hand force sensor\nframes for example. For this, the wrench transformation matrix $^{com}\\M{H}^{ref}$ can be used:\n\\begin{equation}\n \\mathbf{h}_k = {}^{com}\\M{H}^{ref}_k ~^{ref}\\mathbf{h}\n\\end{equation}\n\nwhere:\n\\begin{equation}\n  \\M{H}\n  =\n  \\begin{bmatrix}\n  \\M{R} & \\M{0}\\\\\n  [\\mathbf{t}]_\\times \\M{R} & \\M{R}\n \\end{bmatrix}\n\\end{equation}\n\n\\section{Case 1: Solo-carrying an object}\nFor an object of known mass $m^{obj}$ and location (relative to the CoM), the external wrench is:\n\\begin{equation}\n \\mathbf{h}_k\n  =\n \\begin{bmatrix}\n  \\M{I} & \\M{0}\\\\\n  [\\mathbf{t}_k]_\\times & \\M{I}\n \\end{bmatrix}\n \\begin{bmatrix}\n  0\\\\\n  0\\\\\n  m^{obj} g^z\\\\\n  0\\\\\n  0\\\\\n  0\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n  0\\\\\n  0\\\\\n  m^{obj} g^z\\\\\n  y_k m^{obj} g^z\\\\\n -x_k m^{obj} g^z\\\\\n  0\n \\end{bmatrix}\n\\end{equation}\nwhere $x$ and $y$ are the distances between the 2 CoMs (object and robot)\n\nIn general:\n\\begin{equation}\n \\mathbf{t}_k = {}^{rob}\\mathbf{t}_k^{obj} = {}^w\\mathbf{t}_k^{obj} - {}^{w}\\mathbf{t}_k^{com}\n\\end{equation}\n\nA first approximation is to assume $x_0, y_0$ from the current configuration remains constant.\n\\begin{equation}\n \\mathbf{t}_1 = \\mathbf{t}_2 = \\ldots = \\mathbf{t}_N = \\mathbf{t}_0\n\\end{equation}\n\nA better model might be to use: the future com positions from the model $\\hat{\\M{C}}$\n\\begin{equation}\n    \\cPos =\n        \\diag{N}{\\M{I}_{p}} \\cState =\n        \\diag{N}{\\M{I}_{p}} \\left( \\M{S}\\V{X} + \\V{s} \\right)=\n        \\M{S}_p \\V{X} + \\V{s}_p\n\\end{equation}\n\nAlong with this, knowledge of the future object position in the plane ${}^wx_k, {}^wy_k$ is required. If a trajectory is available, it can be used to\nobtain\nthis.\n\nWithout having the object trajectory, one approximation is that the reference com velocity is\nperfectly imparted on the object such that:\n\\begin{equation}\n \\hat{\\V{t}} =\n \\begin{bmatrix}\n  x_1 \\\\\n  y_1 \\\\\n  \\vdots \\\\\n  x_N \\\\\n  y_N\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n  1 & 0 \\\\\n  0 & 1 \\\\\n  \\vdots \\\\\n  1 & 0 \\\\\n  0 & 1 \\\\\n \\end{bmatrix}\n \\begin{bmatrix}\n  x_0 \\\\\n  y_0\n \\end{bmatrix}\n +\n \\diag{k = 1 \\dots N}{k T_k} \\cVel_{ref}\n -\n \\M{S}_p \\V{X} - \\V{s}_p\n\\end{equation}\n\nFinally, the external wrench vector required in the QP is:\n\\begin{equation}\n \\hat{\\V{F}}\n =\n \\begin{bmatrix}\n  n_1^y \\\\\n  f_1^x \\\\\n  n_1^x \\\\\n  f_1^y \\\\\n  \\vdots \\\\\n  n_N^y \\\\\n  f_N^x \\\\\n  n_N^x \\\\\n  f_N^y\n \\end{bmatrix}\n =\n \\diag{N}{\\begin{bmatrix}\n           -1 & 0 \\\\\n            0 & 0 \\\\\n            0 & 1 \\\\\n            0 & 0\n          \\end{bmatrix}}\n \\hat{\\V{t}}\n ~\n (m^{obj} g^z)\n\\end{equation}\n\nThis slightly changes the ZMP formulation for the QP since $\\hat{\\V{F}}$ is now a function of $\\V{X}$\n\n\\section{Case 2: Collaborative-carrying}\n% One general thing to exploit could be giving a meaning to the weights of the QP objectives. The external wrench term only appears in the CoP and\n% there is already an objective where an external CoM velocity is given. Using these 2 tasks together can be seen as a form of damping control, with the\n% ratio of these task weights the damping factor.\n\n\\subsection{As leader}\nFor leading, a clear and independent intention is necessary. However, a good leader still needs to account for what the follower is doing, this is\nwhere the external wrench model comes in.\n\n% often we use the reference CoM velocity $\\cVel_{ref}$.\n%\n% Another idea is to add the external wrench as a decision variable of the QP, trying to track the result as a target force in the whole-body control\n% part\n\n\\textbf{Idea 1: Reference trajectory tracking}\n\nIf a clear trajectory is known before hand, a better objective for the leader might be a ``trajectory tracking task'' instead of just a reference\nvelocity . This can be formulated as:\n\\begin{equation}\n  \\NORME{\n  g_m(\\cAcc_{ref} - \\cAcc) +\n  g_b(\\cVel_{ref} - \\cVel) +\n  g_k(\\cPos_{ref} - \\cPos)\n  }\n\\end{equation}\nwhere $g_m, g_b, g_k$ are gains. To be concise, an appropriate gain matrix can be used:\n\\begin{equation}\n  \\NORME{\n  \\M{G}_{mbk}(\\cState_{ref} - \\cState)\n  }\n\\end{equation}\n\n\\textbf{Idea 2: Wrench in the QP decision variables}\n\nAnother idea was to place the external wrench as a decision variable of the QP. This will result in:\n\\begin{align}\n    \\cState\n    =&\n    \\underbrace{\n    \\begin{bmatrix}\n        \\M{U}_u    &   \\M{0}  &   \\M{0}\\\\\n    \\end{bmatrix}\n    }_{\\M{S}}\n    \\underbrace{\n    \\begin{bmatrix}\n        \\dddot{\\M{C}}\\\\\n        \\FP\\\\\n        \\hat{\\M{F}}\n    \\end{bmatrix}\n    }_{\\V{X}}\n    +\n    \\underbrace{\n    \\M{U}_x \\cstate_0\n    }_{\\V{s}}\\\\\n%\n    \\CoP\n    =&\n    \\underbrace{\n    \\begin{bmatrix}\n        \\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top} \\M{O}_u    &\n       -\\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top} \\M{V} &\n\t\\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top} \\M{O}_f\n    \\end{bmatrix}\n    }_{\\M{S}_{z}}\n    \\underbrace{\n    \\begin{bmatrix}\n        \\dddot{\\M{C}}\\\\\n        \\FP\\\\\n        \\hat{\\M{F}}\n    \\end{bmatrix}\n    }_{\\V{X}}\n    +\n    \\underbrace{\n    \\diag{k = 1 \\dots N}{\\M[\\hat{p}_k][]{R}^\\top}\n    \\left(\n    \\M{O}_x \\cstate_0\n    -\n    \\M{V}_0 \\fp_0\n    \\right)\n    }_{\\V{s}_{z}}\\\\\n\\end{align}\n\nAs the force is part of the ZMP expression, this might allow the robot to balance itself by applying the appropriate forces. For\nsafety, the applied wrench may need to be constrained\n\\begin{equation}\n  \\hat{\\ubarV{F}} \\le \\hat{\\M{F}} \\le \\hat{\\barV{F}}\n\\end{equation}\n\nand/or minimized as:\n\\begin{equation}\n  \\NORME{\\hat{\\M{F}}}\n\\end{equation}\n\n\\subsection{As follower}\nFor following, the robot needs to act based on the leader's intention.\n\n% To do this, we used to change the target reference $\\cVel_{ref}$ as a function\n% of the sensed force (a damping-based control). With the new model, it might be possible to do the same concept but using the QP weights.\n\n\\textbf{Idea 1: Impedance control objective}\n\nIt may be possible to do planar impedance control, first defining the selection matrix $\\M{S}_{xy}$ to select only the $f^x, f^y$ components. The\nimpedance parameter matrix $\\M{G}_{mbk}$ is defined similar to the trajectory tracking task gain.\n\\begin{equation}\n  \\NORME{\n  \\M{G}_{mbk}\\cState -\\M{S}_{xy}\\hat{\\M{F}}\n  }\n\\end{equation}\n\nThis could replace the reference velocity objective and the external controller to compute this reference.\n\n\\textbf{Idea 2: Force prediction models}\n\nA better following behavior requires a ``proactive'' behavior which attempts to predict the intention of the leader. This corresponds\nto predicting the future external wrench. A better prediction model should correspond to a better\nproactive behavior.\n\nSince the target application is for collaborating with humans, this model amounts to predicting the human partner's intention. One possible\nassumption is to take the results presented in Bussy:IROS:2012 and infer from this 2 models to predict the forces:\n\\begin{enumerate}\n \\item constant acceleration model - constant force\n \\item constant jerk model - linear force\n\\end{enumerate}\n\n\n\\subsection{A combined approach}\nOnce a good leader and follower approach are formulated, it might be possible to reformulate it into a combined approach\n\n\n\\input{wpg03_notation_undefine.tex}\n", "meta": {"hexsha": "481b50851669f4758648727f0c35b975f7b17bd4", "size": 16647, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "extra_modules/wpg03/doc/wpg03.tex", "max_stars_repo_name": "bip-team/humoto-module-wpg03-collaboration", "max_stars_repo_head_hexsha": "9855f56d7794e865f7d30305fbf65ea57a065e8a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "extra_modules/wpg03/doc/wpg03.tex", "max_issues_repo_name": "bip-team/humoto-module-wpg03-collaboration", "max_issues_repo_head_hexsha": "9855f56d7794e865f7d30305fbf65ea57a065e8a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "extra_modules/wpg03/doc/wpg03.tex", "max_forks_repo_name": "bip-team/humoto-module-wpg03-collaboration", "max_forks_repo_head_hexsha": "9855f56d7794e865f7d30305fbf65ea57a065e8a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6463068182, "max_line_length": 152, "alphanum_fraction": 0.5855109029, "num_tokens": 6481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.41039123140922157}}
{"text": "\\chapter{Experiment Specifications} \\label{sec:Experiment Specifications}\n\\begin{mydef} \\label{def:GPU Speedup}\n    GPU Speedup: Ratio of model's execution time with GPU ``set'' to that with CPU ``set''. The script's data preprocessing runtime is ignored but the time taken to transfer data from CPU to GPU is included in calculating GPU ``set'' time elapsed. (Speedup = $\\frac{CPU-time}{GPU-time\\; +\\; Transfer-time}$)\n\\end{mydef}\n\nWe conducted several tests for optimization and GPU Speedup to test both our models. After initializing all parameters randomly (with specific seeds for reproduction and uniformity between tests), the models were run for 1000 or 10000 epochs depending on the complexity of the model.\n\n\\section{Datasets} \\label{sec:Datasets}\nWe conducted two types of tests: \\textbf{optimization tests on original datasets} and \\textbf{GPU Speedup tests on randomly generated datasets}. Data was loaded or generated as Floating Point 32 (FP32) units but was stored with less precision (up to 15 significant figures) to reduce secondary memory usage.\n\nThe original dataset available from eBird observations contained 173 time units ($T$) and 116 Avicache locations ($J$) \\cite{EBird}. For the GPU Speedup runs, a random dataset of 173 time units ($T$) and 232 locations ($J$) was generated beforehand using NumPy (without any seed). The number of locations in the random dataset was higher than that in the original dataset to aim for a clear trend if the models were to be scaled. We believe that speedup tests on original datasets would give similar results, though we used randomly generated datasets because the original dataset could not be flawlessly extrapolated. The models were timed for the executed operations in a neural network and the LP, including transfer times of tensors between the RAM and GPU's internal memory. Time taken for preprocessing was ignored. \n\n\\section{Test-Machine Configuration} \\label{sec:Test-Machine Configuration}\nHardware specifications and software versions used for the experiments are listed in \\Cref{tab:Hardware Specifications and Software Versions Used for Experiments}. Though we couldn't eliminate extraneous computing usage by background processes on the test-machine, we restricted it by switching off X (Graphical User Interface for Ubuntu OS) and performing tests in CLI (Command Line Interface), and ending user processes. One should obtain similar GPU Speedup results when repeating the experiments, though background processes and threads might give varying runtime values.\n\\begin{table}[!htbp]\n    \\centering\n    \\caption{Hardware Specifications and Software Versions Used for Experiments}\n    \\label{tab:Hardware Specifications and Software Versions Used for Experiments}\n    \\begin{tabular}{|c|c|}\n        \\hline\n        \\multicolumn{2}{c}{\\textbf{Hardware}}\\\\\n        \\hline\n        \\textbf{Type} & \\textbf{Unit/Specs}\\\\\n        \\hline\n        Desktop & Dell Precision Tower 3620\\\\\n        CPU & Intel Core i7-7700K\\tablefootnote{Hyper-threaded with 4 cores, 8 threads @ 4.20-4.50 GHz}\\\\\n        RAM & 16GB\\\\\n        GPU & NVIDIA Quadro P4000\\tablefootnote{1792 CUDA Cores @ 1.2-1.5 GHz}\\\\\n        \\hline\n    \\end{tabular}\\quad\n    \\begin{tabular}{|c|c|}\n        \\hline\n        \\multicolumn{2}{c}{\\textbf{Software}}\\\\\n        \\hline\n        \\textbf{Library/Package} & \\textbf{Version}\\\\\n        \\hline\n        Ubuntu OS & 16.04.2 LTS x86\\textunderscore64\\\\\n        CUDA & 8.0\\\\\n        cuDNN & 5.1.10\\\\\n        MKL & 2017.0.3\\\\\n        Python & 2.7.13 (Anaconda)\\\\\n        PyTorch & 0.1.12\\textunderscore2\\\\\n        NumPy & 1.12.1\\\\\n        SciPy & 0.19.0\\\\\n        \\hline\n    \\end{tabular}\n\\end{table}\n\n\\paragraph{GPU ``set'' and CPU ``set'' Clarification}\nBy GPU ``set'' we mean \\textit{distributing} operations in the scripts between CPU and GPU, while by CPU ``set'' we mean that the operations were executed \\textit{only} on the CPU. Since GPUs are inferior than CPUs at handling most operations other than simple arithmetic matrix ones due to parallelism (see \\Cref{sec:Computation Using GPUs}), we used --- and recommend using --- both the CPU and the GPU in GPU ``set'' to handle operations each is superior at (useful for large datasets). However, since the models in \\Cref{alg:Algorithm for the Identification Problem,alg:Solving the Pricing Problem} (not the full scripts) primarily comprise of arithmetic operations on  tensors, it is clear that they were executed on the GPU when it was ``set'' and on the CPU when the CPU was ``set''. Other than this optimization, we did not specifically design any parallelized algorithm for either configurations, relying on the PyTorch's and NumPy-SciPy's inbuilt implementation.\n\n\\section{Algorithm Choice} \\label{sec:Algorithm Choice}\nOn the algorithm side, we used Adam's algorithm for \\textsc{Gradient-Descent}($\\cdot$), after testing performances of several algorithms\\footnote{PyTorch lets you choose the corresponding function/module} including, but not limited to, Stochastic Gradient Descent (SGD) \\cite{SGD}, Adam's Algorithm \\cite{Adam} and Adagrad \\cite{Adagrad}. In \\Cref{sec:Results}, we only discuss and show tests using the Adam's algorithm, since it was found to work best with both models over all test runs.\n\n\\section{Running the Identification Problem's Model} \\label{sec:Running the Identification Problem's Model}\n\\subsection{Optimizing the Original Dataset} \\label{sec:Identification Problem-Optimizing the Original Dataset}\nThe 3-layered neural network was run for 10000 epochs on the original dataset, which was split 80:20 along ($T$) for training and testing sets, with different learning rates = $\\{10^{-2}, 10^{-3}, 10^{-4}, 10^{-5}\\}$. Since we were aiming for optimization, we ran multiple tests (5 different seeds with each learning rate) of the model only with the GPU ``set''.\n\nTo compare this model's optimization results with other model structures, the previously studied 2-layered network \\cite{Xue2016Avi2} and a 4-layered neural network were used. The 4-layered network had another hidden layer with reLU, equivalent to the hidden layer in the current 3-layered network in \\Cref{fig:3-dimensional view of the network slice taking in Fv}. The results from the 2-layered network were obtained from the previous study, and those from the 4-layered network were attained on the same original dataset with same specifications (learning rates, epochs etc.).\n\n\\subsection{Testing GPU Speedup on the Random Dataset} \\label{sec:Identification Problem-Testing GPU Speedup on the Random Dataset}\nAfter generating a random dataset and splitting it 80:20 for training and testing (to emulate testing on the original dataset), we ran our 3-layered model with different batch-sizes $J = \\{11,37,63,90,116,145,174,203,232\\}$ ($T = 173$) and different seeds with both GPU and CPU ``set'', logging the elapsed time for model execution. The total time elapsed was averaged for a batch-size on a device, which were used to generate scatter/line plots (see \\Cref{sec:IdProbRes - GPU}).\n\n\\section{Running the Pricing Problem's Model} \\label{sec:Running the Pricing Problem's Model}\n\\subsection{Optimizing the Original Dataset} \\label{sec:Pricing Problem-Optimizing the Original Dataset}\nAfter obtaining the set of weights $\\matr{w_1}$ and $\\matr{w_2}$ optimized using different seeds, we tested to find the best rewards (with the lowest loss --- \\Cref{eqn:pricing_problem}) with random $\\vect{r}$ initialization. To obtain the best rewards, the model was run on all sets of weights obtained from the Identification Problem for 1000 epochs with different learning rates. In search for the best rewards with the minimum loss, we took this approach:\n\\begin{enumerate}\n    \\item Run differently seeded rewards on all sets of weights obtained from the Identification Problem, and identify a set of weights which performed better than the others (low $Z_I$ --- \\Cref{eqn:pricing_problem}) on average. The learning rate was fixed to $10^{-3}$ in this case.\n    \\item Use that set of weights to run a number of tests with varying seeds and learning rates = $\\{10^{-2}, 5 \\times 10^{-3}, 10^{-3}, 5 \\times 10^{-4}, 10^{-4}, 5 \\times 10^{-5}, 10^{-5}\\}$, and choose the rewards that gave the lowest loss value $Z_I$ during execution\\footnote{This means that we selected the rewards before completion if the loss at that epoch was lower than that in the end.}. \n\\end{enumerate}\n\nTwo sets of rewards were tested for loss values as baseline comparisons to our model --- a randomly generated set, and another with elements inversely proportional to the number of visits at each location. While the former was a random baseline, the latter captured the idea of allocating higher rewards to relatively under-sampled locations. The best loss values were compared for all tests with the baselines.\n\n\\subsection{Testing GPU Speedup on the Random Dataset} \\label{sec:Pricing Problem-Testing GPU Speedup on the Random Dataset}\nInitially, we ran the Pricing Problem's model with different batch-sizes $J = \\{11, 37, 63, 90, 116\\}$ ($T = 173$), different seeds with both GPU and CPU ``set'', and learning rate = $10^{-3}$ for 1000 epochs. Since we couldn't find a clear trend, we tested on more locations $J = \\{145, 174, 203, 232\\}$.\n\nWe relied on SciPy's Optimize Module to solve our LP sub-problem (see \\Cref{sec:Constraining Rewards}) because PyTorch does not provide a GPU-accelerated Simplex LP solver. Since SciPy's implementation does not utilize the GPU, we expected the LP problem to be executed on the CPU, thus delivering equal runtimes in both GPU and CPU ``set'' configurations.", "meta": {"hexsha": "cd4ec91208122cdd2a952199aebe12915465ce0c", "size": 9611, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/exp_specs.tex", "max_stars_repo_name": "anmolkabra/avicaching-summ17", "max_stars_repo_head_hexsha": "3b85c1b70adcbe5d5b2764195090b28093081b1f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/exp_specs.tex", "max_issues_repo_name": "anmolkabra/avicaching-summ17", "max_issues_repo_head_hexsha": "3b85c1b70adcbe5d5b2764195090b28093081b1f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/exp_specs.tex", "max_forks_repo_name": "anmolkabra/avicaching-summ17", "max_forks_repo_head_hexsha": "3b85c1b70adcbe5d5b2764195090b28093081b1f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 124.8181818182, "max_line_length": 972, "alphanum_fraction": 0.7577775466, "num_tokens": 2359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.41039123140922157}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{tikz}\n\\usepackage{array}\n\n\n\n\\title{Chapter 12\\\\Further Topics in Analysis}\n\\author{solutions by Hikari}\n\\date{November 2021}\n\n\\begin{document}\n\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\del}{\\boldsymbol{\\nabla}}\n\\newcommand{\\lfpr}[1]{\\left(#1\\right)}\n\\newcommand{\\lfbr}[1]{\\left[#1\\right]}\n%dashint\n\\def\\Xint#1{\\mathchoice\n   {\\XXint\\displaystyle\\textstyle{#1}}%\n   {\\XXint\\textstyle\\scriptstyle{#1}}%\n   {\\XXint\\scriptstyle\\scriptscriptstyle{#1}}%\n   {\\XXint\\scriptscriptstyle\\scriptscriptstyle{#1}}%\n   \\!\\int}\n\\def\\XXint#1#2#3{{\\setbox0=\\hbox{$#1{#2#3}{\\int}$}\n     \\vcenter{\\hbox{$#2#3$}}\\kern-.5\\wd0}}\n\\def\\ddashint{\\Xint{\\;\\,-}}\n\\def\\dashint{\\Xint-}\n\n\\maketitle\n\n\\section*{12.1 Orthogonal Polynomials}\n\n\\paragraph{12.1.1}\n\\[\ng(x,t)=\\sum_{n=0}^\\infty\\frac{1}{n!}H_n(x)t^n\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{(-1)^n}{n!}t^ne^{x^2}\\left(\\frac{d}{dx}\\right)^ne^{-x^2}\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{(-1)^n}{n!}t^ne^{x^2}\\frac{n!}{2\\pi i}\\oint\\displaylimits_{c}\\frac{e^{-z^2}}{(z-x)^{n+1}}dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\left(\\sum_{n=0}^\\infty\\left(\\frac{-t}{z-x}\\right)^n\\frac{e^{x^2-z^2}}{2\\pi i(z-x)} \\right)dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{1}{1-\\frac{-t}{z-x}}\\frac{e^{x^2-z^2}}{2\\pi i(z-x)}\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{e^{x^2-z^2}}{2\\pi i(z-x+t)}dz\n\\]\nThe function has a simple pole at $z=x-t$ with residue\n\\[\n\\lim_{z\\to x-t}(z-x+t)\\cdot\\frac{e^{x^2-z^2}}{2\\pi i(z-x+t)}=\\frac{e^{-t^2+2xt}}{2\\pi i}\n\\]\nso we have\n\\[\ng(x,t)=2\\pi i\\cdot\\frac{e^{-t^2+2xt}}{2\\pi i}=e^{-t^2+2xt}\n\\]\n\n\\paragraph{12.1.2}\n(a) \n\\[\nw(x)=\\frac{1}{x}\\cdot e^{\\int\\frac{1-x}{x}dx}=\\frac{1}{x}\\cdot e^{\\ln x-x}=e^{-x}\n\\]\nUsing the Rodrigues formula, \n\\[\ny_n(x)=e^x\\left(\\frac{d}{dx}\\right)^n\\left[e^{-x}x^n\\right]\n\\]\n\n(b)\n(Using the rescaled polynomials with a factor $\\frac{1}{n!}$ from the table)\n\\[\ng(x,t)=\\sum_{n=0}^\\infty L_n(x)t^n\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{e^xt^n}{n!}\\left(\\frac{d}{dx}\\right)^n\\left[x^ne^{-x} \\right]\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{e^xt^n}{n!}\\frac{n!}{2\\pi i}\\oint\\displaylimits_c\\frac{z^ne^{-z}}{(z-x)^{n+1}}dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\left(\\sum_{n=0}^\\infty\\left(\\frac{tz}{z-x}\\right)^n\\frac{e^{x-z}}{2\\pi i(z-x)} \\right)dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{1}{1-\\frac{tz}{z-x}}\\frac{e^{x-z}}{2\\pi i(z-x)}dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{e^{x-z}}{2\\pi i(1-t)(z-\\frac{x}{1-t})}dz\n\\]\nThe function has a simple pole at $z=\\frac{x}{1-t}$ with residue \n\\[\n\\lim_{z\\to\\frac{x}{1-t}}(z-\\frac{x}{1-t})\\cdot\\frac{e^{x-z}}{2\\pi i(1-t)(z-\\frac{x}{1-t})}=\\frac{e^{\\frac{-xt}{1-t}}}{2\\pi i(1-t)}\n\\]\nso we have\n\\[\ng(x,t)=2\\pi i\\cdot\\frac{e^{\\frac{-xt}{1-t}}}{2\\pi i(1-t)}=\\frac{e^{\\frac{-xt}{1-t}}}{1-t}\n\\]\n\n\\paragraph{12.1.3}\nFrom Equation 12.10:\n\\[\np\\left[wp^n\\right]'=wp^n\\left[(n-1)p'+q\\right]\n\\]\nNote that $\\frac{d^kp}{dx^k}=0$ for $k>2$, so we have\n\\[\n\\left(\\frac{d}{dx} \\right)^{n+1}\\left(p\\left[wp^n\\right]' \\right)=\\sum_{k=0}^{n+1}\\binom{n+1}{k}\\frac{d^kp}{dx^k}\\frac{d^{n+1-k}\\left[wp^n\\right]'}{dx^{n+1-k}}\n\\]\n\\[\n=p\\lfpr{\\frac{d}{dx}}^{n+2}\\lfbr{wp^n}+(n+1)p'\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}+\\frac{(n+1)n}{2}p''\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}\n\\]\nAlso note that $\\frac{d^k[(n-1)p'+q]}{dx^k}=0$ for $k>1$, so we have\n\\[\n\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{(n-1)p'+q}wp^n=\\sum_{k=0}^{n+1}\\binom{n+1}{k}\\frac{d^k\\lfbr{(n-1)p'+q}}{dx^k}\\frac{d^{n+1-k}\\lfbr{wp^n}}{dx^{n+1-k}}\n\\]\n\\[\n=\\lfbr{(n-1)p'+q}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}\\;+\\;(n+1)\\lfbr{(n+1)p''+q'}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}\n\\]\nEquating the two sides of the equation, dividing by $w$, rearranging, and using $y_n=\\frac{1}{w}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}$, we have\n\\[\n\\frac{p}{w}\\lfpr{\\frac{d}{dx}}^{n+2}\\lfbr{wp^n}+\\frac{2p'-q}{w}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}-\\lfbr{\\frac{n^2-n-2}{2}p''+(n+1)q'}y_n=0\n\\]\n\n\\paragraph{12.1.4}\nFrom Equation 12.12:\n\\[\n\\frac{p}{w}\\lfpr{\\frac{d}{dx}}^{n+2}\\lfbr{wp^n}+\\frac{2p'-q}{w}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}=\\lfbr{\\frac{n^2-n-2}{2}p''+(n+1)q'}y_n\n\\]\nCalculate $py_n''$ and $qy_n'$:\n\\begin{align*}\n    & p\\,y_n''=p\\lfbr{\\frac{1}{w}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}}''=\\frac{p}{w}\\lfpr{\\frac{d}{dx}}^{n+2}\\lfbr{wp^n}+2p\\frac{dw^{-1}}{dx}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}+p\\frac{d^2w^{-1}}{dx^2}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}\\\\\n    & q\\,y_n'=q\\lfbr{\\frac{1}{w}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}}'=\\frac{q}{w}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}+q\\frac{dw^{-1}}{dx}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}\n\\end{align*}\nNote that by definition we have\n\\begin{align*}\n    & \\frac{dw^{-1}}{dx}=-\\frac{w'}{w^2}=\\frac{p'-q}{wp}\\\\\n    & \\frac{d^2w^{-1}}{dx^2}=\\frac{p''-q'}{wp}-\\frac{p'-q}{(wp)^2}(wp)'=\\frac{1}{wp}\\lfbr{p''-q'-\\frac{q(p'-q)}{p}}\n\\end{align*}\nSubstituting, summing together and using Equation 12.12, we have\n\\[\np\\,y_n''+q\\,y_n'=\\frac{p}{w}\\lfpr{\\frac{d}{dx}}^{n+2}\\lfbr{wp^n}+\\frac{2p'-q}{w}\\lfpr{\\frac{d}{dx}}^{n+1}\\lfbr{wp^n}+\\frac{p''-q'}{w}\\lfpr{\\frac{d}{dx}}^n\\lfbr{wp^n}\n\\]\n\\[\n=\\lfbr{\\frac{n^2-n-2}{2}p''+(n+1)q'}y_n+\\lfbr{p''-q'}y_n=\\lfbr{\\frac{n^2-n}{2}p''+nq'}y_n\n\\]\nwhich is Equation 12.16:\n\\[\np\\,y_n''+q\\,y_n'-\\lfbr{\\frac{n^2-n}{2}p''+nq'}y_n=0\n\\]\n\n\\paragraph{12.1.5}\n(a)\n\\[\ng(x,t)=\\sum_{n=0}^\\infty J_n(x)t^n\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{t^n}{2\\pi i}\\oint\\displaylimits_c e^{\\frac{x}{2}(z-\\frac{1}{z})}z^{-n-1}dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\lfpr{\\sum_{n=0}^\\infty\\frac{e^{\\frac{x}{2}{(z-\\frac{1}{z})}}}{2\\pi iz}\\lfpr{\\frac{t}{z}}^n }dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{e^{\\frac{x}{2}{(x-\\frac{1}{z})}}}{2\\pi iz}\\frac{1}{1-\\frac{t}{z}}dz\n\\]\n\\[\n=\\oint\\displaylimits_c\\frac{e^{\\frac{x}{2}{(z-\\frac{1}{z})}}}{2\\pi i(z-t)}dz\n\\]\nThe function has a simple pole at $z=t$ with residue\n\\[\n\\lim_{z\\to t}(z-t)\\cdot\\frac{e^{\\frac{x}{2}{(z-\\frac{1}{z})}}}{2\\pi i(z-t)}=\\frac{e^{\\frac{x}{2}{(t-\\frac{1}{t})}}}{2\\pi i}\n\\]\nSo the generating function of Bessel functions is\n\\[\ng(x,t)=e^{\\frac{x}{2}{(t-\\frac{1}{t})}}\n\\]\n\n(b)\nWith similar process, the generating function of modified Bessel functions is\n\\[\ng(x,t)=e^{\\frac{x}{2}{(t+\\frac{1}{t})}}\n\\]\n\n\\paragraph{12.1.6}\n\\[\n\\lfbr{1+(t^2-2tz)}^{-\\frac{1}{2}}=1-\\frac{1}{2}\\lfpr{t^2-2tz}+\\frac{3}{8}\\lfpr{t^2-2tz}^2+\\cdots=1+zt+\\frac{3z^2-1}{2}t^2+\\cdots\n\\]\nso the coefficient is\n\\begin{align*}\n    & a_0=P_0(z)=1\\\\\n    & a_1=P_1(z)=z\\\\\n    & a_2=P_2(z)=\\frac{1}{2}\\lfpr{3z^2-1}\n\\end{align*}\n\n\\paragraph{12.1.7}\n\\begin{align*}\n    & \\pdv{}{t}\\lfpr{\\frac{1}{1-2xt+t^2}}=\\frac{2x-2t}{(1-2xt+t^2)^2}=\\frac{2x-2t}{1-2xt+t^2}\\sum_{n=0}^\\infty U_n(x)t^n\\\\\n    & \\pdv{}{t}\\lfpr{\\sum_{n=0}^\\infty U_n(x)t^n}=\\sum_{n=1}^\\infty nU_n(x)t^{n-1}\n\\end{align*}\nEquating the two sides, we have\n\\[\n\\sum_{n=0}^\\infty 2xU_nt^n-\\sum_{n=0}^\\infty2U_nt^{n+1}=\\sum_{n=1}^\\infty nU_nt^{n-1}-\\sum_{n=1}^\\infty 2xnU_nt^n+\\sum_{n=1}^\\infty nU_nt^{n+1}\n\\]\nCollect the terms of $t^n$, we have\n\\[\n2xU_n-2U_{n-1}=(n+1)U_{n+1}-2xnU_n+(n-1)U_{n-1}\n\\]\nso the recurrence relation is (for $n\\geq1$):\n\\[\nU_{n+1}(x)-2xU_n(x)+U_{n-1}(x)=0\n\\]\n\n\\section*{12.2 Bernoulli Numbers}\n\n\\paragraph{12.2.1}\n\\[\n\\frac{t}{e^t-1}=\\frac{-te^{-t}}{e^{-t}-1}=\\frac{-t(e^{-t}-1)-t}{e^{-t}-1}=\\frac{-t}{e^{-t}-1}-t\n\\]\n\\[\n\\frac{te^{t}}{e^t-1}=\\frac{t}{1-e^{-t}}=\\frac{-t}{e^{-t}-1}\n\\]\n\n\\paragraph{12.2.2}\n\\begin{equation*}\n    \\begin{split}\n        \\frac{te^{ts}}{e^t-1} & =\\frac{t(1+ts+\\frac{t^2s^2}{2}+\\cdots)}{1+t+\\frac{t^2}{2}+\\frac{t^3}{6}+\\cdots-1}\\\\\n        & =\\frac{1+ts+\\frac{t^2s^2}{2}+\\cdots}{1+\\frac{t}{2}+\\frac{t^2}{6}+\\cdots}\\\\\n        & =(1+ts+\\frac{t^2s^2}{2}+\\cdots)(1-\\frac{t}{2}-\\frac{t^2}{6}+\\frac{t^2}{4}+\\cdots)\\\\\n        & =1+(s-\\frac{1}{2})t+(\\frac{s^2}{2}-\\frac{s}{2}+\\frac{1}{12})t^2+\\cdots\\\\\n        & =B_0+B_1t+\\frac{B_2}{2}t^2\n    \\end{split}\n\\end{equation*}\nso we have\n\\begin{equation*}\n    \\begin{split}\n        B_0(s) & =1\\\\\n        B_1(s) & =s-\\frac{1}{2}\\\\\n        B_2(s) & =s^2-s+\\frac{1}{6}\n    \\end{split}\n\\end{equation*}\n\n\\paragraph{12.2.3}\n\\[\n\\cot 2x=\\frac{\\cos 2x}{\\sin 2x}=\\frac{\\cos^2x-\\sin^2x}{2\\sin x\\cos x}=\\frac{\\cot x}{2}-\\frac{\\tan x}{2}\n\\]\nso\n\\[\n\\tan x=\\cot x-2\\cot2x\n\\]\nFrom Equation 12.35, we have\n\\begin{equation*}\n    \\begin{split}\n        \\cot x & =\\sum_{n=0}^\\infty(-1)^nB_{2n}\\frac{2^{2n}x^{2n-1}}{(2n)!}\\\\\n        2\\cot2x & =\\sum_{n=0}^\\infty(-1)^nB_{2n}\\frac{2^{2n+1}(2x)^{2n-1}}{(2n)!}=\\sum_{n=0}^\\infty(-1)^nB_{2n}\\frac{2^{4n}x^{2n-1}}{(2n)!}\n    \\end{split}\n\\end{equation*}\nso\n\\[\n\\tan x & =\\cot x-2\\cot 2x\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{(-1)^n2^{2n}(1-2^{2n})B_{2n}}{(2n)!}x^{2n-1}\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{(-1)^{n-1}2^{2n}(2^{2n}-1)B_{2n}}{(2n)!}x^{2n-1}\n\\]\n\n\\section*{12.3 Euler-Maclaurin Integration Formula}\n\n\\paragraph{12.3.1}\n\\begin{equation*}\n    \\begin{split}\n        \\sum_{m=1}^n m &= \\int_1^n xdx+\\frac{1}{2}+\\frac{n}{2}+\\frac{B_2}{2!}[1-1]\\\\\n        & =\\frac{n^2-1}{2}+\\frac{n+1}{2}=\\frac{1}{2}n(n+1)\\\\\n        \\sum_{m=1}^n m^2 & =\\int_1^n x^2 dx+\\frac{1}{2}+\\frac{n^2}{2}+\\frac{B_2}{2!}[2n-2]\\\\\n        & =\\frac{n^3-1}{3}+\\frac{n^2+1}{2}+\\frac{n-1}{6}=\\frac{1}{6}n(n+1)(2n+1)\\\\\n        \\sum_{m=1}^n m^3 & =\\int_1^n x^3dx+\\frac{1}{2}+\\frac{n^3}{2}+\\frac{B_2}{2!}[3n^2-3]+\\frac{B_4}{4!}[6-6]\\\\\n        & =\\frac{n^4-1}{4}+\\frac{n^3+1}{2}+\\frac{n^2-1}{4}=\\frac{1}{4}n^2(n+1)^2\\\\\n        \\sum_{m=1}^n m^4 & =\\int_1^n x^4 dx+\\frac{1}{2}+\\frac{n^4}{2}+\\frac{B_2}{2!}[4n^3-4]+\\frac{B_4}{4!}[24n-24]\\\\\n        & =\\frac{n^5-1}{5}+\\frac{n^4+1}{2}+\\frac{n^3-1}{3}-\\frac{n-1}{30}\\\\\n        & =\\frac{1}{30}n(n+1)(2n+1)(3n^2+3n-1)\n    \\end{split}\n\\end{equation*}\n\n\\paragraph{12.3.2}\n\\[\n\\gamma=\\lim_{n\\to\\infty}\\lfpr{\\sum_{s=1}^n\\frac{1}{s}-\\ln n}=\\sum_{s=1}^n\\frac{1}{s}-\\ln n+\\lim_{n'\\to\\infty}\\lfpr{\\sum_{s=n+1}^{n'}\\frac{1}{s}-\\ln\\frac{n'}{n}}\n\\]\nThe last term can be evaluated by Euler-Maclaurin formula:\n\n\\begin{equation*}\n    \\begin{split}\n        \\lim_{n'\\to\\infty}\\lfpr{\\sum_{s=n+1}^{n'}\\frac{1}{s}-\\int\\displaylimits_{n}^{n'}\\frac{1}{s}ds} & =\\lim_{n'\\to\\infty}\\lfbr{\\frac{\\frac{1}{n'}-\\frac{1}{n}}{2}+\\sum_{k=1}^N\\frac{B_{2k}}{(2k)!}\\lfpr{f^{(2k-1)}(n')-f^{2k-1}(n) } }+remainder\\\\\n        & =\\lim_{n'\\to\\infty}\\lfbr{\\frac{1}{2n'}-\\frac{1}{2n}-\\sum_{k=1}^N\\frac{B_{2k}}{2k}\\lfpr{\\frac{1}{(n')^{2k}}-\\frac{1}{n^{2k}} } }+remainder\\\\\n        & =-\\frac{1}{2n}+\\sum_{k=1}^N\\frac{B_{2k}}{(2k)n^{2k}}+remainder\n    \\end{split}\n\\end{equation*}\nwhere we have evaluated \n\\[\nf^{(2k-1)}(n)=-(2k-1)!\\frac{1}{n^{2k}}\n\\]\nSo by ignoring the remainder term, we have\n\\[\n\\gamma=\\sum_{s=1}^n\\frac{1}{s}-\\ln n-\\frac{1}{2n}+\\sum_{k=1}^N\\frac{B_{2k}}{(2k)n^{2k}}\n\\]\nLet $n=1000$ and $N=2$ (evaluate the term of $B_2$ and $B4$), we have\n\\[\n\\gamma=0.577215664902\n\\]\n\n\\section*{12.4 Dirichlet Series}\n\n\\paragraph{12.4.1}\nUse $N-1=\\sum_{n=1}^{N-1}\\binom{2N}{2n}B_{2n}$ to obtain $B_{2n}$, and use $B_{2n}=(-1)^{n+1}\\frac{2(2n)!}{(2\\pi)^{2n}}\\zeta(2n)$ to obtain $\\zeta(2n)$:\n\\begin{alignat*}{3}\n    & n=1: \\qquad && B_{2}=\\frac{1}{6}\\qquad && \\zeta(2)=\\frac{\\pi^2}{6}\\\\\n    & n=2: \\qquad && B_4=-\\frac{1}{30}\\qquad && \\zeta(4)=\\frac{\\pi^4}{90}\\\\\n    & n=3: \\qquad && B_6=\\frac{1}{42}\\qquad && \\zeta(6)=\\frac{\\pi^6}{945}\\\\\n    & n=4: \\qquad && B_8=-\\frac{1}{30}\\qquad && \\zeta(8)=\\frac{\\pi^8}{9450}\\\\\n    & n=5: \\qquad && B_{10}=\\frac{5}{66}\\qquad && \\zeta(10)=\\frac{\\pi^{10}}{93555}\n\\end{alignat*}\n\n\\paragraph{12.4.2}\nUsing the substitution $1-x=e^{-t}$, we have\n\\begin{equation*}\n\\begin{split}\n    \\int_0^1\\lfbr{\\ln(1-x)}^2\\frac{dx}{x} & =\\int_0^\\infty\\frac{t^2e^{-t}}{1-e^{-t}}dt\\\\\n    & =\\int_0^\\infty\\lfpr{t^2e^{-t}\\sum_{n=0}^\\infty e^{-nt} }dt\\\\\n    & =\\sum_{n=0}^\\infty\\int_0^\\infty t^2e^{-(1+n)t}dt\\\\\n    & =\\sum_{n=0}^\\infty\\frac{2}{(1+n)^3}\\\\\n    & =\\sum_{n=1}^\\infty\\frac{2}{n^3}\\\\\n    & =2\\zeta(3)\n\\end{split}\n\\end{equation*}\nwhere we expanded $(1-e^{-t})^{-1}$, and integrated by parts.\n\n\\paragraph{12.4.3}\n(This is essentially Exercise 11.8.18)\n\\medskip\n\n(a)\n\\[\n\\int\\displaylimits_0^\\infty\\frac{(\\ln z)^2}{1+z^2}dz=\\int\\displaylimits_0^1\\frac{(\\ln z)^2}{1+z^2}dz+\\int\\displaylimits_1^\\infty\\frac{(\\ln z)^2}{1+z^2}dz\n\\]\nBy the substitution $z=\\frac{1}{t}$, the first integral becomes\n\\[\n\\int\\displaylimits_0^1\\frac{(\\ln z)^2}{1+z^2}dz=\\int\\displaylimits_{\\infty}^1\\frac{(-\\ln t)^2}{1+t^{-2}}(-t^{-2}dt)=\\int\\displaylimits_1^\\infty\\frac{(\\ln t)^2}{1+t^2}dt\n\\]\nwhich is the same with the second integral. By another substitution $z=e^t$, we have\n\\[\n\\int\\displaylimits_1^\\infty\\frac{(\\ln z)^2}{1+z^2}dz\n=\\int\\displaylimits_0^\\infty\\frac{t^2e^t}{1+e^{2t}}dt=\\int\\displaylimits_0^\\infty\\frac{t^2e^{-t}}{1+e^{-2t}}dt\n\\]\n\\[\n=\\int\\displaylimits_0^\\infty\\left(\\sum_{n=0}^\\infty(-1)^n\\,t^2\\, e^{-(2n+1)t} \\right)dt\n\\]\n\\[\n=\\sum_{n=0}^\\infty(-1)^n\\int\\displaylimits_0^\\infty t^2\\,e^{-(2n+1)t}dt\n\\]\n\\[\n=\\sum_{n=0}^\\infty(-1)^n\\left[\\frac{2e^{-(2n+1)t}}{-(2n+1)^3} \\right]_0^\\infty\n\\]\n\\[\n=2\\sum_{n=0}^\\infty(-1)^n(2n+1)^{-3}\n\\]\nso\n\\[\n\\int\\displaylimits_0^\\infty\\frac{(\\ln z)^2}{1+z^2}dz=2\\int\\displaylimits_1^\\infty\\frac{(\\ln z)^2}{1+z^2}dz\\]\n\\[=4\\sum_{n=0}^\\infty(-1)^n(2n+1)^{-3}\\]\n\\[=4\\lfpr{1-\\frac{1}{3^3}+\\frac{1}{5^3}-\\frac{1}{7^3}+\\cdots}\n\\]\n\n(b)\nBy the substitution $z=e^t$, we have\n\\[\nI=\\int\\displaylimits_0^\\infty\\frac{(\\ln z)^2}{1+z^2}dz=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{1+e^{2t}}\\cdot e^t dt=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{e^t+e^{-t}}dt\n\\]\nThe function has poles at $z=(n+\\frac{1}{2})i\\pi$, and the pole at $z=\\frac{i\\pi}{2}$ is\n\\[\n\\lim_{z\\to\\frac{i\\pi}{2}}(z-\\frac{i\\pi}{2})\\cdot\\frac{z^2e^z}{1+e^{2z}}=\\lim_{z\\to\\frac{i\\pi}{2}}\\frac{z^2e^z}{2e^{2z}}=\\frac{\\pi^2i}{8}\n\\]\nTake the contour to be that in Figure 11.29. Integral on the two vertical segments vanish as $R\\to\\infty$, and integral on the segment at $x+i\\pi$ is\n\\[\n\\int\\displaylimits_{\\infty}^{-\\infty}\\frac{(t+i\\pi)^2}{e^{t+i\\pi}+e^{-t-i\\pi}}dt=\\int\\displaylimits_{-\\infty}^\\infty\\frac{(t+i\\pi)^2}{e^t+e^{-t}}\\]\n\\[=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{e^t+e^{-t}}dt+\\int\\displaylimits_{-\\infty}^\\infty\\frac{2i\\pi t}{e^t+e^{-t}}dt+\\int\\displaylimits_{-\\infty}^\\infty\\frac{-\\pi^2}{e^t+e^{-t}}dt\n\\]\nThe first integral is $I$, the second integral vanishes as it is an odd function, and the third integral is\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{-\\pi^2}{e^t+e^{-t}}dt=\\int\\displaylimits_0^\\infty\\frac{-\\pi^2}{x^2+1}dx=-\\pi^2\\Big[\\tan^{-1}x\\Big]_0^\\infty=-\\frac{\\pi^3}{2}\n\\]\nUsing the residue theorem, we have\n\\[\nI+I-\\frac{\\pi^3}{2}=2\\pi i\\cdot\\frac{\\pi^2i}{8}\n\\]\n\\[\nI=\\frac{\\pi^3}{8}\n\\]\n\n\\paragraph{12.4.4}\n\\begin{alignat*}{4}\n    & \\beta(2)=1 && -\\frac{1}{3^2} && +\\frac{1}{5^2} && -\\frac{1}{7^2}+\\cdots \\\\\n    & \\zeta(2)=1+\\frac{1}{2^2} && +\\frac{1}{3^2}+\\frac{1}{4^2} && +\\frac{1}{5^2}+\\frac{1}{6^2} && +\\frac{1}{7^2}+\\cdots\n\\end{alignat*}\nso\n\\[\n\\zeta(2)+\\beta(2)=2\\lfpr{1+\\frac{1}{5^2}+\\frac{1}{9^2}+\\cdots}+\\lfpr{\\frac{1}{2^2}+\\frac{1}{4^2}+\\frac{1}{6^2}+\\cdots}\n\\]\n\\[\n=2\\sum_{k=1}^\\infty(4k-3)^{-2}+\\frac{1}{4}\\zeta(2)\n\\]\nTherefore\n\\[\n\\beta(2)=2\\sum_{k=1}^\\infty(4k-3)^{-2}-\\frac{3}{4}\\zeta(2)\n\\]\n\\[\n=2\\sum_{k=1}^\\infty(4k-3)^{-2}-\\frac{\\pi^2}{8}\n\\]\n\n\\paragraph{12.4.5}\n(a)\n\\begin{equation*}\n    \\begin{split}\n        \\int_0^1\\frac{\\ln(1+x)}{x}dx & =\\int_0^1\\frac{1}{x}\\left(x-\\frac{x^2}{2}+\\frac{x^3}{3}-\\frac{x^4}{4}+\\cdots\\right)dx\\\\\n        & =\\int_0^1\\left(1-\\frac{x}{2}+\\frac{x^2}{3}-\\frac{x^3}{4}+\\cdots \\right)dx\\\\\n        & =\\left[x-\\frac{x^2}{2^2}+\\frac{x^3}{3^2}-\\frac{x^4}{4^2}+\\cdots \\right]_0^1\\\\\n        & =\\frac{1}{1^2}-\\frac{1}{2^2}+\\frac{1}{3^2}-\\frac{1}{4^2}+\\cdots\n    \\end{split}\n\\end{equation*}\nLet the integral be $S$, and note that\n\\[\n\\zeta(2)=\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\frac{1}{4^2}+\\cdots\n\\]\nso\n\\[\n\\zeta(2)-S=2\\left(\\frac{1}{2^2}+\\frac{1}{4^2}+\\frac{1}{6^2}+\\cdots \\right)\n\\]\n\\[\n=\\frac{1}{2}\\left(\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\cdots \\right)=\\frac{1}{2}\\zeta(2)\n\\]\nTherefore,\n\\[\nS=\\frac{1}{2}\\zeta(2)\n\\]\n\n(b)\n\\begin{equation*}\n    \\begin{split}\n        \\lim_{a\\to1}\\int_0^a\\frac{\\ln(1-x)}{x}dx & =\\lim_{a\\to1}\\int_0^a\\frac{-1}{x}\\left(x+\\frac{x^2}{2}+\\frac{x^3}{3}+\\frac{x^4}{4}+\\cdots \\right)dx \\\\\n        & =-\\lim_{a\\to1}\\int_0^a\\left(1+\\frac{x}{2}+\\frac{x^2}{3}+\\frac{x^3}{4}+\\cdots \\right)dx\\\\\n        & =-\\lim_{a\\to1}\\left[x+\\frac{x^2}{2^2}+\\frac{x^3}{3^2}+\\frac{x^4}{4^2}+\\cdots \\right]_0^a\\\\\n        & =-\\left(\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\frac{1}{4^2}+\\cdots \\right)\\\\\n        & =-\\zeta(2)\n    \\end{split}\n\\end{equation*}\n\n\\paragraph{12.4.6}\n(a)\n\\[\n\\sum_{s=2}^n 2^{-s}\\zeta(s)=\\sum_{s=2}^n 2^{-s}\\sum_{p=1}^\\infty\\frac{1}{p^s}=\\sum_{s=2}^n\\sum_{p=1}^\\infty\\frac{1}{(2p)^s}\n\\]\n\\[\n\\sum_{p=1}^\\infty(2p)^{-n-1}\\left[1-\\frac{1}{2p} \\right]^{-1}=\\sum_{p=1}^\\infty\\sum_{s=n+1}^\\infty\\frac{1}{(2p)^s}\n\\]\nTherefore,\n\\begin{equation*}\n    \\begin{split}\n         & \\quad\\,\\sum_{s=2}^n 2^{-s}\\zeta(2)+\\sum_{p=1}^\\infty(2p)^{-n-1}\\left[1-\\frac{1}{2p} \\right]^{-1}\\\\\n        & =  \\sum_{p=1}^\\infty\\left(\\sum_{s=2}^n\\frac{1}{(2p)^s}+\\sum_{n+1}^\\infty\\frac{1}{(2p)^s} \\right)\\\\\n        & =  \\sum_{p=1}^\\infty\\sum_{s=2}^\\infty\\frac{1}{(2p)^s}=\\sum_{p=1}^\\infty\\frac{\\frac{1}{(2p)^2}}{1-\\frac{1}{2p}}\\\\\n        & =  \\sum_{p=1}^\\infty\\frac{1}{2p(2p-1)}=\\sum_{p=1}^\\infty\\lfpr{\\frac{1}{2p-1}-\\frac{1}{2p} }\\\\\n        & =  1-\\frac{1}{2}+\\frac{1}{3}-\\frac{1}{4}+\\cdots\\\\\n        & =  \\ln 2\n    \\end{split}\n\\end{equation*}\n\n(b)\n\\[\n\\sum_{p=1}^\\infty(2p)^{-n-1}\\lfbr{1-\\frac{1}{2p} }^{-1}<\\sum_{p=1}^\\infty(2p)^{-n-1}\\cdot2=\\frac{1}{2^n}\\zeta(n+1)<1\\times10^{-6},\\qquad n\\geq20\n\\]\nSo by taking $n=20$, we can obtain $\\ln 2$ from the first summation of the precision to the sixth decimal place:\n\\[\n\\sum_{s=2}^{20}2^{-s}\\zeta(s)=0.693146\n\\]\n\n\\paragraph{12.4.7}\n(a)\n\\[\n\\sum_{s=1}^n 4^{-2s}\\zeta(2s)=\\sum_{s=1}^n 4^{-2s}\\sum_{p=1}^\\infty\\frac{1}{p^{2s}}=\\sum_{s=1}^n\\sum_{p=1}^\\infty\\frac{1}{(4p)^{2s}}\n\\]\n\\[\n\\sum_{p=1}^\\infty(4p)^{-2n-2}\\lfbr{1-\\frac{1}{(4p)^2}}^{-1}=\\sum_{p=1}^\\infty\\sum_{s=n+1}^\\infty\\frac{1}{(4p)^{2s}}\n\\]\nTherefore, \n\\begin{equation*}\n    \\begin{split}\n        & \\quad\\,\\, 1-2\\sum_{s=1}^n 4^{-2s}\\zeta(2s)-2\\sum_{p=1}^\\infty(4p)^{-2n-2}\\lfbr{1-\\frac{1}{(4p)^2} }^{-1}\\\\\n        & =1-2\\sum_{p=1}^\\infty\\lfpr{\\sum_{s=1}^n\\frac{1}{(4p)^{2s}}+\\sum_{s=n+1}^\\infty\\frac{1}{(4p)^{2s}} }\\\\\n        & =1-2\\sum_{p=1}^\\infty\\sum_{s=1}^\\infty\\frac{1}{(4p)^{2s}}=1-2\\sum_{p=1}^\\infty\\frac{\\frac{1}{(4p)^2}}{1-\\frac{1}{(4p)^2}}\\\\\n        & =1-2\\sum_{p=1}^\\infty\\frac{1}{(4p+1)(4p-1)}=1-\\sum_{p=1}^\\infty\\lfpr{\\frac{1}{4p-1}-\\frac{1}{4p+1} }\\\\\n        & =1-\\frac{1}{3}+\\frac{1}{5}-\\frac{1}{7}+\\frac{1}{9}-\\cdots\\\\\n        & =\\frac{\\pi}{4}\n    \\end{split}\n\\end{equation*}\n\n(b)\n\\[\n2\\sum_{p=1}^\\infty(4p)^{-2n-2}\\lfbr{1-\\frac{1}{(4p)^2} }^{-1}<2\\sum_{p=1}^\\infty(4p)^{-2n-2}\\cdot2=\\frac{1}{4^{2n+1}}\\zeta(2n+2)<1\\times10^{-6},\\qquad n\\geq5\n\\]\nSo by taking $n=5$, we can obtain $\\frac{\\pi}{4}$ from the equation of the precision to the sixth decimal place:\n\\[\n1-2\\sum_{s=1}^5 4^{-2s}\\zeta(2s)=0.785398\n\\]\n\n\\section*{12.5 Infinite Products}\n\n\\paragraph{12.5.1}\n(There should be a condition that $0\\leq a_n<1$)\n\nFor the $1+a_n$ case, if $\\sum a_n$ converges,\n\\[\n1+a_n\\leq e^{a_n}\n\\]\n\\[\n|\\ln(1+a_n)|\\leq a_n\n\\]\n$\\sum a_n$ converges, so $\\sum\\ln(1+a_n)$ converges by comparison test. Therefore, $\\ln\\prod(1+a_n)$ converges, which implies $\\prod(1+a_n)$ converges.\n\\medskip\n\nFor the $1+a_n$ case, if $\\sum a_n$ diverges, \n\\[\np_n=\\prod_{n=1}^N(1+a_n)\\geq\\sum_{n=1}^N a_n=s_n\n\\]\n$s_n$ is monotonically increasing but diverges, which implies it is infinite, so $p_n$ is infinite and diverges.\n\\medskip\n\nFor $1-a_n$ case, note that for $a_n<\\frac{1}{2}$, we have $(1-a_n)\\geq(1+2a_n)^{-1}$ and $(1-a_n)\\leq(1+a_n)^{-1}$:\n\\[\n|\\ln(1-a_n)|\\leq|\\ln(1+2a_n)|\\leq 2a_n\n\\]\nSo if $\\sum a_n$ converges, then $\\sum\\ln(1-a_n)$ converges, and therefore $\\prod(1-a_n)$ converges.\n\\[\n-\\ln(1-a_n)\\geq\\ln(1+a_n)\n\\]\nSo if $\\sum a_n$ diverges, $\\sum\\ln(1+a_n)$ diverges, $\\sum\\ln(1-a_n)$ diverges, and therefore $\\prod(1-a_n)$ diverges.\n\n\\paragraph{12.5.2}\n\\[\n\\prod_{n=1}^\\infty\\lfpr{\\frac{1+\\frac{a}{n}}{1+\\frac{b}{n}} }=\\prod_{n=1}^\\infty\\lfpr{1+\\frac{a-b}{n+b} }\n\\]\n$\\sum\\frac{a-b}{n+b}=(a-b)\\sum\\frac{1}{n+b}$ diverges when $a\\neq b$, so $\\prod\\lfpr{\\frac{1+\\frac{a}{n}}{1+\\frac{b}{n}} }$ diverges by Theorem in Exercise 12.5.1.\n\n\\paragraph{12.5.3}\nFrom Equation 11.89 and 11.90:\n\\[\n\\sin z=z\\prod_{n=1}^\\infty\\lfpr{1-\\frac{z^2}{n^2\\pi^2} } =z\\prod_{n=1}^\\infty\\lfpr{1-\\frac{(2z)^2}{(2n)^2\\pi^2} } =z\\prod_{n\\;even}\\lfpr{1-\\frac{(2z)^2}{n^2\\pi^2} }\n\\]\n\\[\n\\cos z=\\prod_{n=1}^\\infty\\lfpr{1-\\frac{z^2}{(n-\\frac{1}{2})^2\\pi^2} }=\\prod_{n=1}^\\infty\\lfpr{1-\\frac{(2z)^2}{(2n-1)^2\\pi^2} } =\\prod_{n\\;odd}\\lfpr{1-\\frac{(2z)^2}{n^2\\pi^2} }\n\\]\nTherefore,\n\\[\n2\\sin z\\cos z=2z\\prod_{n=1}^\\infty\\lfpr{1-\\frac{(2z)^2}{n^2\\pi^2} }=\\sin2z\n\\]\n\n\\paragraph{12.5.4}\n\\[\n\\prod_{n=2}^\\infty\\lfpr{1+\\frac{(-1)^n}{n} }=\\prod_{n\\;even}\\lfpr{1+\\frac{1}{n} }\\lfpr{1+\\frac{-1}{n+1} }=\\prod_{n\\;even}\\frac{n+1}{n}\\frac{n}{n+1}=1\n\\]\n\n\\paragraph{12.5.5}\n\\[\n\\prod_{n=2}^\\infty\\lfbr{1-\\frac{2}{n(n+1)} }=\\prod_{n=2}^\\infty\\frac{(n-1)(n+2)}{n(n+1)}=\\prod_{n=2}^\\infty\\frac{n-1}{n}\\prod_{n=4}^\\infty\\frac{n}{n-1}=\\frac{1}{2}\\cdot\\frac{2}{3}=\\frac{1}{3}\n\\]\n\n\\paragraph{12.5.6}\n\\[\n\\prod_{n=2}^\\infty\\lfpr{1-\\frac{1}{n^2} }=\\prod_{n=2}^\\infty\\frac{(n-1)(n+1)}{n\\cdot n}=\\prod_{n=2}^\\infty\\frac{n-1}{n}\\prod_{n=3}^\\infty\\frac{n}{n-1}=\\frac{1}{2}\n\\]\n\n\\paragraph{12.5.7}\n\\[\n\\prod_{p=1}^\\infty(1+z^p)=\\prod_{p=1}^\\infty\\frac{1-z^{2p}}{1-z^p}=\\frac{\\prod_{q=1}^\\infty(1-z^{2q})}{\\prod_{p=1}^\\infty(1-z^p)}=\\frac{1}{\\prod_{q=1}^\\infty(1-z^{2q-1})}=\\prod_{q=1}^\\infty(1-z^{2q-1})^{-1}\n\\]\nThe convergence of the infinite product requires the condition $|z|<1$ because $\\sum z^n$ converges when $|z|<1$.\n\n\\paragraph{12.5.8}\n\\[\n\\prod_{r=1}^\\infty\\lfpr{1+\\frac{x}{r}}e^{-\\frac{x}{r}}=\\prod_{r=1}^\\infty\\lfpr{1+\\frac{x}{r}}\\lfpr{1-\\frac{x}{r}+\\sum_{n=2}^\\infty a_n\\left(\\frac{x}{r}\\right)^n}=\\prod_{r=1}^\\infty\\lfpr{1+\\sum_{n=2}^\\infty b_n\\left(\\frac{x}{r}\\right)^n }\n\\]\nTo verify the convergence, evaluate the sum:\n\\[\n\\sum_{r=1}^\\infty\\sum_{n=2}^\\infty b_n\\lfpr{\\frac{x}{r}}^n=\\sum_{n=2}^\\infty\\sum_{r=1}^\\infty b_n\\lfpr{\\frac{x}{r}}^n=\\sum_{n=2}^\\infty b_nx^n\\zeta(n)\n\\]\nwhich converges for finite $x$, so the infinte products converges.\n\n\\paragraph{12.5.9}\nFrom Equation 12.35,\n\\[\n\\cot x=\\frac{1}{x}+\\sum_{n=1}^\\infty(-1)^n B_{2n}\\frac{(2x)^{2n-1}}{(2n)!}\n\\]\nso by integrating $\\frac{d(\\ln\\sin x)}{dx}=\\cot x$, we have\n\\[\n\\ln\\sin x=\\ln x+\\sum_{n=1}^\\infty(-1)^nB_{2n}\\frac{(2x)^{2n}}{(2n)\\cdot(2n)!}=\\ln x+\\sum_{n=1}^\\infty\\frac{(-1)^n 2^{2n}B_{2n}}{(2n)\\cdot(2n)!}x^{2n}\n\\]\nso we have\n\\[\na_0=0,\\qquad a_{2n-1}=0,\\qquad a_{2n}=\\frac{(-1)^n2^{2n}B_{2n}}{(2n)\\cdot(2n)!}\n\\]\nfor $n\\in\\mathbb{N}$.\n\n\\paragraph{12.5.10}\nFrom Equation 11.89,\n\\[\n\\ln\\sin z=\\ln z+\\sum_{n=1}^\\infty\\ln\\lfpr{1-\\left(\\frac{z}{n\\pi}\\right)^2 }=\\ln z-\\sum_{n=1}^\\infty\\sum_{m=1}^\\infty\\frac{1}{m}\\lfpr{\\frac{z}{n\\pi} }^{2m}\n\\]\nTherefore,\n\\[\nz\\cot z=z\\frac{d(\\ln\\sin z)}{dz}=z\\cdot\\frac{1}{z}-z\\sum_{n=1}^\\infty\\sum_{m=1}^\\infty2\\frac{z^{2m-1}}{(n\\pi)^{2m}}=1-2\\sum_{m,n=1}^\\infty\\lfpr{\\frac{z}{n\\pi} }^{2m}=1-2\\sum_{m=1}^\\infty\\frac{\\zeta(2m)}{\\pi^{2m}}z^{2m}\n\\]\nFrom Equation 12.35, we have\n\\[\nz\\cot z=1+\\sum_{n=1}^\\infty\\frac{(-1)^n2^{2n}B_{2n}}{(2n)!}z^{2n}\n\\]\nSo by equating each term in the summation of the two expression of $z\\cot z$, we have\n\\[\n\\frac{(-1)^n2^{2n}B_{2n}}{(2n)!}=-\\frac{2\\zeta(2n)}{\\pi^{2n}}\n\\]\n\\[\nB_{2n}=(-1)^{n-1}\\frac{2(2n)!}{(2\\pi)^{2n}}\\zeta(2n)\n\\]\n\n\\section*{12.6 Asymptotic Series}\n\n\\paragraph{12.6.1}\nFrom Exercise 11.8.26, we have\n\\[\n\\int_0^\\infty\\cos\\frac{\\pi u^2}{2}du=\\int_0^\\infty\\sin\\frac{\\pi u^2}{2}du=\\frac{1}{2}\n\\]\nso\n\\[\nC(x)=\\frac{1}{2}-\\int_x^\\infty\\cos\\frac{\\pi u^2}{2}du\n\\]\n\\[\ns(x)=\\frac{1}{2}-\\int_x^\\infty\\sin\\frac{\\pi u^2}{2}du\n\\]\n\n(a)\nSubstitute $\\frac{\\pi u^2}{2}=t$ and integrate by parts continuously, we have\n\\begin{equation*}\n    \\begin{split}\n        C(x) & =\\frac{1}{2}-\\int_{\\frac{\\pi x^2}{2}}^\\infty\\frac{\\cos t}{\\sqrt{2\\pi t}}\\,dt\\\\\n        & \\approx\\frac{1}{2}-\\left[\\frac{\\sin t}{(2\\pi t)^{\\frac{1}{2}}}-(-\\pi)\\frac{-\\cos t}{(2\\pi t)^{\\frac{3}{2}}}+(-\\pi)(-3\\pi)\\frac{-\\sin t}{(2\\pi t)^{\\frac{5}{2}}}-(-\\pi)(-3\\pi)(-5\\pi)\\frac{\\cos t}{(2\\pi t)^{\\frac{7}{2}}}+\\cdots \\right]_{\\frac{\\pi x^2}{2}}^\\infty\\\\\n        &  \\approx\\frac{1}{2}+\\frac{1}{\\pi x}\\sin\\frac{\\pi x^2}{2}-\\frac{\\pi}{(\\pi x)^3}\\cos\\frac{\\pi x^2}{2}-\\frac{1\\cdot3\\cdot\\pi^2}{(\\pi x)^5}\\sin\\frac{\\pi x^2}{2}+\\frac{1\\cdot3\\cdot5\\cdot\\pi^3}{(\\pi x)^7}\\cos\\frac{\\pi x^2}{2}+\\cdots\n    \\end{split}\n\\end{equation*}\nNote that the sign changes every two terms.\n\\medskip\n\n(b)\nSubstitute $\\frac{\\pi u^2}{2}=t$ and integrate by parts continuously, we have\n\\begin{equation*}\n    \\begin{split}\n        s(x) & =\\frac{1}{2}-\\int_{\\frac{\\pi x^2}{2}}^\\infty\\frac{\\sin t}{\\sqrt{2\\pi t}}\\,dt\\\\\n        & \\approx\\frac{1}{2}-\\left[\\frac{-\\cos t}{(2\\pi t)^{\\frac{1}{2}}}-(-\\pi)\\frac{-\\sin t}{(2\\pi t)^{\\frac{3}{2}}}+(-\\pi)(-3\\pi)\\frac{\\cos t}{(2\\pi t)^{\\frac{5}{2}}}-(-\\pi)(-3\\pi)(-5\\pi)\\frac{\\sin t}{(2\\pi t)^{\\frac{7}{2}}}+\\cdots \\right]_{\\frac{\\pi x^2}{2}}^\\infty\\\\\n        &  \\approx\\frac{1}{2}-\\frac{1}{\\pi x}\\cos\\frac{\\pi x^2}{2}-\\frac{\\pi}{(\\pi x)^3}\\sin\\frac{\\pi x^2}{2}+\\frac{1\\cdot3\\cdot\\pi^2}{(\\pi x)^5}\\cos\\frac{\\pi x^2}{2}+\\frac{1\\cdot3\\cdot5\\cdot\\pi^3}{(\\pi x)^7}\\cos\\frac{\\pi x^2}{2}-\\cdots\n    \\end{split}\n\\end{equation*}\nNote that the sign changes every two terms.\n\n\\paragraph{12.6.2}\nIntegrate by parts continuously:\n\\begin{equation*}\n    \\begin{split}\n        & \\quad Ci(x)+i\\,si(x) \\\\ \n        & =-\\int_x^\\infty\\frac{e^{it}}{t}dt\\\\\n        & \\approx -\\left[\\frac{e^{it}}{i}\\frac{1}{t}-\\frac{e^{it}}{i^2}\\frac{(-1)}{t^2}+\\frac{e^{it}}{i^3}\\frac{(-1)(-2)}{t^3}-\\frac{e^{it}}{i^4}\\frac{(-1)(-2)(-3)}{t^4}+\\frac{e^{it}}{i^5}\\frac{(-1)(-2)(-3)(-4)}{t^5}-\\cdots \\right]_x^\\infty\\\\\n        & \\approx -\\frac{i\\,e^{it}}{t}\\left[1-i\\lfpr{\\frac{1!}{t}}-\\lfpr{\\frac{2!}{t^2}}+i\\lfpr{\\frac{3!}{t^3}}+\\lfpr{\\frac{4!}{t^4}}-\\cdots \\right]\n    \\end{split}\n\\end{equation*}\nwhich is Equation 12.92, so the asymptotic expansions of $Ci(x)$ and $si(x)$ are the same with that given in the text.\n\n\\paragraph{12.6.3}\n\\begin{equation*}\n    \\begin{split}\n        \\mathrm{erf}(x) & =1-\\frac{2}{\\sqrt{\\pi}}\\int_x^\\infty e^{-t^2}dt\\\\\n        & =1-\\frac{1}{\\sqrt{\\pi}}\\int_{x^2}^\\infty\\frac{e^{-u}}{\\sqrt{u}}\\,du\\\\\n        & \\approx 1-\\frac{1}{\\sqrt{\\pi}}\\lfbr{\\frac{-e^{-u}}{u^{\\frac{1}{2}}}-\\lfpr{-\\frac{1}{2}}\\frac{e^{-u}}{u^{\\frac{3}{2}}}+\\lfpr{-\\frac{1}{2}}\\lfpr{-\\frac{3}{2}}\\frac{-e^{-u}}{u^{\\frac{5}{2}}}-\\lfpr{-\\frac{1}{2}}\\lfpr{-\\frac{3}{2}}\\lfpr{-\\frac{5}{2}}\\frac{e^{-u}}{u^{\\frac{7}{2}}}+\\cdots }_{x^2}^\\infty\\\\\n        & \\approx 1+\\frac{1}{\\sqrt{\\pi}}\\lfbr{-\\frac{e^{-x^2}}{x}+\\frac{1}{2}\\frac{e^{-x^2}}{x^3}-\\frac{1\\cdot3}{2^2}\\frac{e^{-x^2}}{x^5}+\\frac{1\\cdot3\\cdot5}{2^3}\\frac{e^{-x^2}}{x^7}-\\cdots }\\\\\n        & \\approx 1-\\frac{e^{-x^2}}{\\sqrt{\\pi}x}\\lfbr{1-\\frac{1}{2x^2}+\\frac{1\\cdot3}{2^2x^4}-\\frac{1\\cdot3\\cdot5}{2^3x^6}+\\cdots+(-1)^n\\frac{(2n-1)!!}{2^nx^{2n}} }\n    \\end{split}\n\\end{equation*}\n \n\\paragraph{12.6.4}\nLet $P_\\nu(z)=1+\\sum_{n=1}^\\infty a_n$, then\n\\[\n\\lim_{n\\to\\infty}\\left|\\frac{a_n}{a_{n-1}} \\right|=\\frac{(4n)^2(4n)^2}{(2n)(2n)(8z)^2}=\\frac{n^2}{z^2}\\to\\infty\n\\]\nas $n\\to\\infty$ for finite $z$, so $P_\\nu(z)$ diverges and can only be an asymptotic series. Similarly is $Q_\\nu(z)$.\n\n\\paragraph{12.6.5}\n$\\sum_{n=0}^\\infty(-1)^n\\frac{1}{x^{n+1}}$ is an alternating series and $\\lim_{n\\to\\infty}\\frac{1}{x^{n+1}}=0$, so it converges and is therefore not an asymptotic series.\n\n\\paragraph{12.6.6}\nBy the definition,\n\\[\n\\gamma=\\lim_{N\\to\\infty}\\left(\\sum_{s=1}^Ns^{-1}-\\ln N \\right)=\\left(\\sum_{s=1}^ns^{-1}-\\ln n \\right)+\\lim_{N\\to\\infty}\\left(\\sum_{s=n+1}^N s^{-1}-\\ln\\frac{N}{n} \\right)\n\\]\nLet $f(x)=x^{-1}$, then $f^{(2k-1)}(x)=-(2k-1)!\\,x^{-2k}$. By Euler-Maclaurin integration formula, we have\n\\[\n\\sum_{s=n+1}^\\infty s^{-1}=\\int_n^Ns^{-1}ds+\\frac{\\frac{1}{N}-\\frac{1}{n}}{2}+\\sum_{k=1}^p\\frac{B_{2k}}{(2k)!}\\left(-\\frac{(2k-1)!}{N^{2k}}+\\frac{(2k-1)!}{n^{2k}} \\right)+R_p\n\\]\nso\n\\[\n\\lim_{N\\to\\infty}\\lfpr{\\sum_{s=n+1}^Ns^{-1}-\\ln\\frac{N}{n} }=-\\frac{1}{2n}+\\sum_{k=1}^p\\frac{B_{2k}}{(2k)n^{2k}}+R_p\n\\]\nwhere $R_p$ can be arbitrarily small when $p$ is large enough. Therfore,\n\\[\n\\gamma\\approx\\sum_{s=1}^ns^{-1}-\\ln n-\\frac{1}{2n}+\\sum_{k=1}^\\infty\\frac{B_{2k}}{(2k)n^{2k}}\n\\]\n\n\\paragraph{12.6.7}\n\\textit{(The answer given is incorrect. It is the asymptotic series for $\\int_0^\\infty\\frac{e^{-xv}}{(1+v^2)}dv$)}\n\nSubstitute $u=xv$ and use the binomial expansion, we have\n\\begin{equation*}\n\\begin{split}\n    & \\quad\\int_0^\\infty\\frac{e^{-xv}}{(1+v^2)^2}dv \\\\\n    & =\\int_0^\\infty e^{-u}\\lfpr{1+\\frac{u^2}{x^2} }^{-2}\\frac{du}{x}\\\\\n    & =\\int_0^\\infty e^{-u}\\sum_{n=0}^\\infty\\binom{-2}{n}\\frac{u^{2n}}{x^{2n+1}}du\\\\\n    & =\\sum_{n=0}^\\infty\\binom{-2}{n}\\frac{1}{x^{2n+1}}\\int_0^\\infty e^{-u}u^{2n}du\\\\\n    & =\\sum_{n=0}^\\infty\\frac{(-1)^n(n+1)\\cdot(2n)!}{x^{2n+1}}\\\\\n    & \\approx\\frac{1}{x}-\\frac{2\\cdot2!}{x^{3}}+\\frac{3\\cdot4!}{x^5}-\\cdots+\\frac{(-1)^n(n+1)\\cdot(2n)!}{x^{2n+1}}\n\\end{split}\n\\end{equation*}\nwhere we have used $\\binom{-2}{n}=(-1)^n(n+1)$ and $\\int_0^\\infty e^{-u}u^ndu=n!$.\n\n\\section*{12.7 Method of Steepest Descents}\n\\paragraph{12.7.1}\n\\textit {The statement that \"$|F(z)|^2$ can have no extremum in the interior of a region in which $F$ is analytic\" is incorrect. Let $F(z)=z$, then $|F(z)|^2$ has a minimum at $z=0$. However, the fact used in the text is that \"$\\ln|F|$\" has no extremum in the interior where $F$ is analytic (Equation 12.100), and it is a true statement which we are going to prove.}\n\nWe first prove that $\\ln|F(z)|$ is harmonic (satisfies the Laplace equation) if $F(z)$ is analytic. Let $F(z)=u(z)+iv(z)$, then\n\\begin{equation*}\n\\begin{split}\n    \\ln|F| & = \\ln|\\sqrt{u^2+v^2}|=\\frac{1}{2}\\ln(u^2+v^2)\\\\\n    \\pdv{\\ln|F|}{x} & =\\frac{u\\pdv{u}{x}+v\\pdv{v}{x}}{u^2+v^2}\\\\\n    \\pdv{^2\\ln|F|}{x^2}&=\\frac{\\lfpr{\\pdv{u}{x}}^2+\\lfpr{\\pdv{v}{x}}^2+u\\pdv{^2u}{x^2}+v\\pdv{^2v}{x^2}}{u^2+v^2}-\\frac{2\\lfpr{u\\pdv{u}{x}+v\\pdv{v}{x} }^2}{(u^2+v^2)^2}\\\\\n    &=\\frac{-(u^2-v^2)\\lfbr{\\lfpr{\\pdv{u}{x}}^2-\\lfpr{\\pdv{v}{x}}^2 }-4uv\\pdv{u}{x}\\pdv{v}{x}+u\\pdv{^2u}{x^2}+v\\pdv{^2v}{x^2} }{(u^2+v^2)^2}\\\\\n    \\pdv{^2\\ln|F|}{y^2}&=\\frac{-(u^2-v^2)\\lfbr{\\lfpr{\\pdv{u}{y}}^2-\\lfpr{\\pdv{v}{y}}^2 }-4uv\\pdv{u}{y}\\pdv{v}{y}+u\\pdv{^2u}{y^2}+v\\pdv{^2v}{y^2} }{(u^2+v^2)^2}\n\\end{split}\n\\end{equation*}\nSumming the two equations, and noting that by  Cauchy-Riemann conditions $\\pdv{u}{x}=\\pdv{v}{y}$,\\; $\\pdv{u}{y}=-\\pdv{v}{x}$, we have\n\\[\n\\lfpr{\\pdv{u}{x}}^2-\\lfpr{\\pdv{v}{x}}^2+\\lfpr{\\pdv{u}{y}}^2-\\lfpr{\\pdv{v}{y}}^2=\\lfpr{\\pdv{u}{x}}^2-\\lfpr{\\pdv{v}{x}}^2+\\lfpr{\\pdv{v}{x}}^2-\\lfpr{\\pdv{u}{x}}^2=0\n\\]\n\\[\n\\pdv{u}{x}\\pdv{v}{x}+\\pdv{u}{y}\\pdv{v}{y}=\\pdv{u}{x}\\pdv{v}{x}-\\pdv{v}{x}\\pdv{u}{x}=0\n\\]\n\\[\n\\pdv{^2u}{x^2}+\\pdv{^2u}{y^2}=0\\qquad \\pdv{^2v}{x^2}+\\pdv{^2v}{y^2}=0\n\\]\nTherefore,\n\\[\n\\pdv{^2\\ln|F|}{x^2}+\\pdv{^2\\ln|F|}{y^2}=0\n\\]\nwhich means $\\ln|F|$ is harmonic. By the mean value property of harmonic function (the 3D version of which has been proved in Exercise 3.9.9), we have\n\\[\n\\ln|F(z_0)|=\\frac{1}{2\\pi r}\\int_0^{2\\pi}\\ln|F(z_0+re^{i\\theta})|\\,rd\\theta\n\\]\nso the mean value of $\\ln|F|$ on a circle about any point $z_0$ is equal to $\\ln|F|$. Therefore, there cannot be an extremum of $\\ln|F|$ at $z_0$, otherwise the mean value on an circle around $z_0$ will be less than or greater than $\\ln|F(z_0)|$ (For the case $z_0$ being an maximum or minimum, respectively.)\n\n\\paragraph{12.7.2}\n\\[\n\\int_0^s\\cos x^2\\,dx+i\\int_0^s\\sin x^2\\,dx=\\int_0^s e^{ix^2}dx=s\\int_0^1 e^{is^2z^2}dz=\\sqrt{t}\\int_0^1 e^{itz^2}dz\n\\]\nLet $w(z)=itz^2$, then $w'(z)=2itz$,\\; $w''(z)=2it$. So the saddle point is $z=0$, and the direction of steepest descent is\n\\[\n\\theta=-\\frac{\\arg w''}{2}+\\frac{\\pi}{2}=\\frac{\\pi}{4}\n\\]\nWhich means the original path moving from $(0,0)$ to $(1,0)$, is deformed to the path that starts from $(0,0)$, moving in the $\\frac{\\pi}{4}$ direction, and ends at $(1,0)$. To use Equation 12.108, note that in Equation 12.104 which is derived from , there is a factor \"$2$\" since both the ascending and descending parts are included, while in this problem since the saddle point happens to be the start point, only the descending part is involved in the integration. Therefore, use Equation 12.108 with an additional factor $\\frac{1}{2}$, we have\n\\[\nf(t)\\approx\\frac{1}{2}\\sqrt{t}e^0e^{i\\frac{\\pi}{4}}\\sqrt{\\frac{2\\pi}{|2it|}}=\\sqrt{\\frac{\\pi}{8}}+\\sqrt{\\frac{\\pi}{8}}i\n\\]\nso\n\\[\n\\int_0^s\\cos x^2\\,dx\\approx\\sqrt{\\frac{\\pi}{8}}\n\\]\n\\[\n\\int_0^s\\sin x^2\\,dx\\approx\\sqrt{\\frac{\\pi}{8}}\n\\]\n\n\\paragraph{12.7.3}\nLet $s=|s|e^{i\\alpha}$, then\n\\[\n\\Gamma(s+1)=\\int_0^\\infty \\rho^s e^{-\\rho}d\\rho=s^{s+1}\\int_0^\\infty e^{s(\\ln z-z)}dz\n\\]\nProceeding as in Example 12.7.1, the saddle point is still $z=1$, and since $w''(1,s)=-s=-|s|e^{\\alpha}$, we have\n\\[\n\\theta=-\\frac{\\arg w''}{2}+(\\frac{\\pi}{2}\\; or\\; \\frac{3\\pi}{2})=-\\frac{\\alpha}{2}\\; or\\; \\pi-\\frac{\\alpha}{2}\n\\]\nChoose $\\theta=-\\frac{\\alpha}{2}$, and use Equation 12.108,\n\\[\n\\Gamma(s+1)\\approx s^{s+1}e^{-s}e^{-\\frac{i\\alpha}{2}}\\sqrt{\\frac{2\\pi}{|s|}}=\\sqrt{2\\pi s}\\,s^se^{-s}\\frac{\\sqrt{s}}{\\sqrt{|s|e^{i\\alpha}}}=\\sqrt{2\\pi s}\\,s^se^{-s}\n\\]\nNote that at the vicinity of the saddle point $z=1$,\\; $\\mathfrak{Im}[s(\\ln z-z)]=-|s|\\cos\\alpha$ is constant.\n\n\\section*{12.8 Dispersion Relations}\n\\paragraph{12.8.1}\nLet $f(z)=u(z)+iv(z)$ be a function meeting the conditions of Schwarz reflection principle. For real number $x$,\\; $f(x)=f^*(x^*)=f^*(x)$, which means $f(z)$ is real when $x$ is real, so $v(x)=0$. By the dispersion relation, $u(x)=0$, so $f(x)=0$. Therefore,\n\\[\nf(z)=\\frac{1}{2\\pi i}\\int_{-\\infty}^\\infty\\frac{f(x)}{x-z}dx=0\n\\]\nwhich means $f(z)$ is identically zero.\n\n\\paragraph{12.8.2}\n\\begin{equation*}\n    \\begin{split}\n        f(x_0) & =\\frac{1}{2\\pi i}\\left\\{\\int\\displaylimits_{-\\infty}^{x_0-\\delta}\\frac{f(x)}{x-x_0}dx+\\int\\displaylimits_{x_0+\\delta}^\\infty\\frac{f(x)}{x-x_0}dx \\right\\}+\\frac{1}{2\\pi i}\\int\\displaylimits_C\\frac{f(x)}{x-x_0}dx\\\\\n        & =\\frac{1}{2\\pi i}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{f(x)}{x-x_0}dx+\\frac{f(x_0)}{2}\n    \\end{split}\n\\end{equation*}\nTherefore,\n\\[\nf(x_0)=\\frac{1}{\\pi i}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{f(x)}{x-x_0}dx\n\\]\n\n\\paragraph{12.8.3}\n(a)\nLet $f(z)=e^{iz}$, then by Jordan's lemma, since $\\lim_{R\\to\\infty}\\frac{1}{z-z_0}=0$,\n\\[\n\\lim_{R\\to\\infty}\\int\\displaylimits_C\\frac{e^{iz}}{z-z_0}dz=0\n\\]\nwhere $C$ is a semicircle of radius $R$ in the upper half-plane with center at the origin. Therefore, using the same contour, Equation 12.116 still holds:\n\\[\nf(z_0)=\\frac{1}{2\\pi i}\\int\\displaylimits_{-\\infty}^\\infty\\frac{f(x)}{x-z_0}dx\n\\]\n\n(b)\n$e^{ix}=\\cos x+i\\sin x$, so\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x}{x-x_0}dx=\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin(x+x_0)}{x}dx=\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x\\cos x_0}{x}dx+\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x\\sin x_0}{x}dx\n\\]\n$\\frac{\\sin x}{x}$ is an even function, so by Exercise 1.10.2,\n\\[\n\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x}{x}dx=2\\int\\displaylimits_0^\\infty\\frac{\\sin x}{x}dx=\\pi\n\\]\n$\\frac{\\cos x}{x}$ is an odd function, so\n\\[\n\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x}{x}dx=0\n\\]\nTherefore,\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x}{x-x_0}dx=\\cos x_0\n\\]\nwhich is the first part of the dispersion relations. The second part can be proved similarly:\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x}{x-x_0}dx\n=\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos(x+x_0)}{x}dx\n=\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x\\cos x_0}{x}dx-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x\\sin x_0}{x}dx\n\\]\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x}{x-x_0}dx=-\\sin x_0\n\\]\n\n\\paragraph{12.8.4}\nIf $f(x)=u(x)+iv(x)$ and $f(x)=f^*(-x)$, then $u(x)+iv(x)=u(-x)-iv(-x)$, which means $u(x)$ is even and $v(x)$ is odd.\n\\medskip\n\n(a)\n\\begin{equation*}\n    \\begin{split}\n        u(x_0) & =\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{v(x)}{x-x_0}dx\\\\\n        & =\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{v(x)}{-x_0}\\left(1+\\frac{x}{x_0}+\\cdots \\right)dx\\\\\n        & \\approx -\\frac{1}{\\pi x_0}\\ddashint\\displaylimits_{-\\infty}^\\infty v(x)dx-\\frac{1}{\\pi x_0^2}\\ddashint\\displaylimits_{-\\infty}^\\infty xv(x)dx\n    \\end{split}\n\\end{equation*}\n$v(x)$ is odd, so the first integral vanishes. $xv(x)$ is even, so the second integral becomes $2\\int_0^\\infty xv(x)dx$. Therefore,\n\\[\nu(x_0)\\approx-\\frac{2}{\\pi x_0^2}\\int_0^\\infty xv(x)dx\n\\]\n\n(b)\n\\begin{equation*}\n    \\begin{split}\n        v(x_0) & =-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{u(x)}{x-x_0}dx\\\\\n        & =-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{u(x)}{-x_0}\\left(1+\\frac{x}{x_0}+\\cdots \\right)dx\\\\\n        & \\approx\\frac{1}{\\pi x_0}\\ddashint\\displaylimits_{-\\infty}^\\infty u(x)dx+\\frac{1}{\\pi x_0^2}\\ddashint\\displaylimits_{-\\infty}^\\infty xu(x)dx\n    \\end{split}\n\\end{equation*}\n$u(x)$ is even, so the first integral becomes $2\\int_0^\\infty u(x)dx$.\\; $xu(x)$ is odd, so the second integral vanishes. Therefore,\n\\[\nv(x_0)\\approx\\frac{2}{\\pi x_0}\\int_0^\\infty u(x)dx\n\\]\n\n\\paragraph{12.8.5}\n(a)\nFrom the dispersion relations, \n\\begin{equation*}\n    \\begin{split}\n        v(x_0)&=-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{u(x)}{x-x_0}dx=-\\frac{1}{1+x_0^2}\\\\\n        u(x_0) & =\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty \\frac{v(x)}{x-x_0}dx\\\\\n        & =-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{1}{1+x^2}\\frac{1}{x-x_0}dx\n    \\end{split}\n\\end{equation*}\nThe function has three simple poles:\n\\begin{alignat*}{2}\n    & z=i\\qquad && residue=\\frac{1}{2i(i-x_0)}\\\\\n    & z=-i\\qquad && residue=\\frac{1}{2i(i+x_0)}\\\\\n    & z=x_0\\qquad && residue=\\frac{1}{1+x_0^2}\n\\end{alignat*}\nThe contour encloses $z=i$, and passes a semi-circle at $z=x_0$, so by the residue theorem,\n\\[\nu(x_0)=-\\frac{1}{\\pi}\\lfbr{2\\pi i\\cdot\\frac{1}{2i(i-x_0)}+\\pi i\\frac{1}{1+x_0^2} }=\\frac{x_0}{1+x_0^2}\n\\]\n\n(b)\nSubstituting,\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{u(x)}{x-x_0}dx=\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{x}{(1+x^2)(x-x_0)}dx\n\\]\nFind the poles with residues and use the residue theorem:\n\\[\n\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{u(x)}{x-x_0}dx  =\\frac{1}{\\pi}\\lfbr{2\\pi i\\cdot\\frac{i}{2i(i-x_0)}+\\pi i\\cdot\\frac{x_0}{1+x_0^2} }=\\frac{1}{1+x_0^2}\n\\]\n\n(c)\n\\[\nf(z)|_{y=0}=u(x)+iv(x)=\\frac{x}{1+x^2}-\\frac{i}{1+x^2}=(x-i)^{-1}\n\\]\nTherefore,\n\\[\nf(z)=(z-i)^{-1}\n\\]\nSince $\\lim_{R\\to\\infty}z\\cdot\\frac{f(z)}{z-z_0}=0$, the semicircular part of the integral vanishes, so the conditions for the Hilbert transforms are satisfied.\n\\medskip\n\n(d)\n$f(-x)=(-x-i)^{-1}\\neq f^*(x)=(x+i)^{-1}$, so the crossing conditions are not satisfied.\n\n\\paragraph{12.8.6}\nBy the dispersion relations:\n\\begin{equation*}\n    \\begin{split}\n        \\mathfrak{Re}\\lfbr{n^2(\\omega_0)-1 }& =k\\\\\n        \\mathfrak{Im}\\lfbr{n^2(\\omega_0)-1 }& =-\\frac{2}{\\pi}\\dashint\\displaylimits_0^\\infty\\frac{\\omega_0k}{\\omega^2-\\omega_0^2}d\\omega\\\\\n        & =-\\frac{k}{\\pi}\\lim_{\\delta\\to0}\\lfpr{\\lfbr{\\ln\\frac{\\omega_0-\\omega}{\\omega+\\omega_0} }_0^{\\omega_0-\\delta}+\\lfbr{\\ln\\frac{\\omega-\\omega_0}{\\omega+\\omega_0}}_{\\omega_0+\\delta}^\\infty}\\\\\n        & =-\\frac{k}{\\pi}\\lim_{\\delta\\to0}\\left(\\ln\\frac{2\\omega_0+\\delta}{2\\omega_0-\\delta}\\right)\\\\\n        & =0\n    \\end{split}\n\\end{equation*}\nwhich means when the real part is constant, the imaginary part is zero.\n\\medskip\n\n(b)\nIt is just the converse of (a).\n\n\\paragraph{12.8.7}\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty |v(x)|^2dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{1}{(x^2+1)^2}dx\n\\]\nThe function has a second pole at $z=i$ with residue\n\\[\nresidue=\\lim_{z\\to i}\\frac{d}{dz}\\lfbr{(z-i)^2\\cdot\\frac{1}{(z^2+1)^2} }=\\frac{1}{4i}\n\\]\nTherefore,\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty|v(x)|^2dx=2\\pi i\\cdot\\frac{1}{4i}=\\frac{\\pi}{2}\n\\]\nNote that $|u(x)|^2+|v(x)|^2=\\frac{1}{x^2+1}$, and\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{1}{x^2+1}dx=2\\pi i\\cdot\\frac{1}{2i}=\\pi\n\\]\nso \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty|u(x)|^2dx=\\pi-\\frac{\\pi}{2}=\\frac{\\pi}{2}\n\\]\n\n\\paragraph{12.8.8}\n(a)\nUsing the Hilbert transform:\n\\begin{equation*}\n    \\begin{split}\n        v(y)& =-\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{\\delta(x)}{x-y}dx=\\frac{1}{\\pi y}\\\\\n        \\delta(w)& =\\frac{1}{\\pi}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{v(y)}{y-w}dy=\\frac{1}{\\pi^2}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{dy}{y(y-w)}\n    \\end{split}\n\\end{equation*}\n\n(b)\nChanging the variables $w=s-t$,\\; $x=y+t$, so $y=x-t$,\\; $y-w=x-s$, then the equation becomes\n\\[\n\\delta(s-t)=\\frac{1}{\\pi^2}\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{dx}{(x-t)(x-s)}\n\\]\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "3c570e047550324d0f717e84efefd48decb5b820", "size": 40527, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 12/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 12/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 12/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2452830189, "max_line_length": 547, "alphanum_fraction": 0.5786019197, "num_tokens": 19858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.4103912270578769}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage{amssymb}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\n\\usetikzlibrary{automata,positioning}\n\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#4}\n\\newcommand{\\hmwkDueDate}{Due 21st September 2018}\n\\newcommand{\\hmwkClass}{Classical Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{Prof.Manas Kulkarni}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\\maketitle\n\\begin{homeworkProblem}\n\t\\textbf{Part (a)}\\\\\n\tThe formal definition of the functional derivative is given by,\n\t\n\t\\begin{equation*}\n\t\\dfrac{\\delta F[q(x)]}{\\delta q(y)} = \\lim\\limits_{\\epsilon \\rightarrow 0} \\dfrac{F[q(y) + \\epsilon \\delta (x-y)] - F[q(y)]}{\\epsilon}\n\t\\end{equation*}\n\tUsing familiar notions from calculus, we can write the following\n\t\n\tConsider the variation of the action $ S = \\int L (q,\\dot{q},t)dt $,\n\t\\begin{align*}\n\t\\delta S &= \\int \\delta L dt\\\\\n\t&= \\int \\qty(\\pdv{L}{q} \\delta q + \\pdv{L}{\\dot{q}} \\delta \\dot{q} )dt\\\\\n\t&= \\int \\qty(\\pdv{L}{q} \\delta q + \\dv{t}\\qty(\\pdv{L}{\\dot{q}} \\delta {q}) - \\dv{t}\\qty(\\pdv{L}{\\dot{q}}) \\delta {q} )dt\\\\\n\t&= \\int \\qty(\\pdv{L}{q} - \\dv{t}\\qty(\\pdv{L}{\\dot{q}})) \\delta {q} dt + \\eval{\\pdv{L}{\\dot{q}} \\delta {q}}_{x_1}^{x_2}\n\t\\end{align*}\n\tAs the variation at the end points in zero, the second term vanishes. The variation of the action $ \\delta S $ should also be zero, and the only way this can happen is if,\n\t\\begin{equation*}\n\t\\pdv{L}{q} - \\dv{t}\\qty(\\pdv{L}{\\dot{q}}) = 0\n\t\\end{equation*}\n\twhich is the Euler-Lagrange equation.\n\t\n\t\\textbf{Part (b)}\\\\\n\tThe Lagrangian for the linear harmonic chain can be written as follows,\n\t\\begin{equation*}\n\tL = \\sum_n \\dfrac{1}{2}m \\dot{x}_i^2 - \\dfrac{1}{2}k (x_i - x_{i-1})^2\n\t\\end{equation*}\n\twhere the $ x_i $'s are the displacements from the mean positions of the respective particles. Lets change our notations such that $ \\phi_i = x_i $. Hence,\n\t\\begin{equation*}\n\tL = \\sum_n \\dfrac{1}{2}m \\dot{\\phi}_i^2 - \\dfrac{1}{2}k (\\phi_i - \\phi_{i-1})^2\n\t\\end{equation*}\n\tIn the limit of separation between successive $ \\phi_i $'s $ \\rightarrow 0 $ and $ n \\rightarrow \\infty $, the potential terms becomes a spatial derivative. The whole expression can be written as,\n\t\\begin{equation*}\n\tL =  \\int dx \\qty( \\dfrac{1}{2}m \\dot{\\phi}^2(x,t) - \\dfrac{1}{2}k \\phi'^2(x,t) ) \n\t\\end{equation*}\n\tThe term in the parenthesis is called the \\textit{Lagrangian Density} $\\mathcal{L}$. Obtaining the equations of motion is fairly straighforward by,\n\t\\begin{align*}\n\t\\partial_\\mu \\qty(\\pdv{\\mathcal{L}}{(\\partial_\\mu \\phi)}) - \\pdv{\\mathcal{L}}{\\phi} &= 0\\\\\n\tm \\ddot{\\phi} - k \\phi'' &= 0 \\implies \\qq{wave equation}\n\t\\end{align*}\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}\n\tThe idea is to write the equations of motion of this system in a combined matrix form as $ \\ddot{X} = (M^{-1} V) X $. $ M $ and $ V $ can be written as follows,\n\t\\begin{equation*}\n\tM = \\mqty(\\dmat{m_1,m_2,m_3}) \\qq{and} V = \\mqty(k_1 & -k_1 & 0 \\\\ -k_1 & k_1 + k_2 & -k_2 \\\\ 0 & -k_2 & k_2)\n\t\\end{equation*}\n\tThe normal mode frequencies are given by the eigenvalues of the matrix $ M^{-1} V $. The eigenvalues are given by,\n\t\\begin{align*}\n\t\\omega_1 &= 0 \\\\\n\t\\omega_2 &= \\frac{\\sqrt{\\frac{k_2 m_1 m_2^2+k_1 m_3 m_2^2+k_1 m_1 m_3 m_2+k_2 m_1 m_3 m_2-\\sqrt{m_2^2 \\left(\\left(k_1 \\left(m_1+m_2\\right) m_3+k_2 m_1 \\left(m_2+m_3\\right)\\right){}^2-4 k_1 k_2 m_1 m_2 m_3 \\left(m_1+m_2+m_3\\right)\\right)}}{m_1 m_2^2 m_3}}}{\\sqrt{2}}\\\\\n\t\\omega_3 &= \\frac{\\sqrt{\\frac{k_2 m_1 m_2^2+k_1 m_3 m_2^2+k_1 m_1 m_3 m_2+k_2 m_1 m_3 m_2+\\sqrt{m_2^2 \\left(\\left(k_1 \\left(m_1+m_2\\right) m_3+k_2 m_1 \\left(m_2+m_3\\right)\\right){}^2-4 k_1 k_2 m_1 m_2 m_3 \\left(m_1+m_2+m_3\\right)\\right)}}{m_1 m_2^2 m_3}}}{\\sqrt{2}}\n\t\\end{align*}\n\t\n\tNow that we have obtained the normal mode frequencies, let's consider a few special cases,\n\t\\begin{itemize}\n\t\t\\item  $ m_1 = m_2 = m_3 = m $, $ k_1 = k_2 = k $ $\\rightarrow$ $ \\omega_1 = 0 , \\omega_2 = \\sqrt{\\dfrac{k}{m}}, \\omega_3 = \\sqrt{\\dfrac{3k}{m}}$\n\t\t\\item $ m_1 = m_3 = m $, $ k_1 = k_2 = k $ $ \\rightarrow$ $ \\omega_1 = 0 , \\omega_2 = \\sqrt{\\dfrac{k}{m}}, \\omega_3 = \\sqrt{\\dfrac{k(2m + m_2)}{m m_2}} $\n\t\\end{itemize}\n\t Let's calculate the normal mode frequencies for CO$ _2 $. $m_O = 2.66 \\cross 10^{-26} $ kg and $ m_C = 1.99 \\cross 10^{-26} $ kg and $ k = 840  $ N/m. This gives $ \\omega_1 = 0 , \\omega_2 = 1.78 \\cross 10^{14} $ s$ ^{-1} $ and $ \\omega_3 = 3.41 \\cross 10^{14} $ s$ ^{-1} $.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}\nThe Lagrangian for this system can be written as,\n\\begin{equation*}\nL = \\dfrac{1}{2}m_1 \\abs{\\dot{\\vb{r_1}}}^2 + \\dfrac{1}{2}m_2 \\abs{\\dot{\\vb{r_2}}}^2 - V(\\vb{r_1}-\\vb{r_2})\n\\end{equation*}\nWe also know, from the question, that\n\\begin{equation*}\n\\vb{R} = \\dfrac{m_1\\vb{r_1} + m_2\\vb{r_2}}{m_1 + m_2} \\qq{and} \\vb{r} = \\vb{r_1} - \\vb{r_2}\n\\end{equation*}\nThis leads us to,\n\\begin{equation*}\n\\vb{r_1} = \\vb{R} + \\dfrac{m_2 \\vb{r}}{m_1 + m_2} \\qq{and} \\vb{r_2} = \\vb{R} - \\dfrac{m_1 \\vb{r}}{m_1 + m_2}\n\\end{equation*}\n\\begin{equation*}\n\\abs{\\dot{\\vb{r_1}}}^2 = \\abs{\\dot{\\vb{R}}}^2 + \\dfrac{m_2^2 \\abs{\\dot{\\vb{r}}}^2}{(m_1 + m_2)^2} + \\dfrac{2 m_2}{m_1 + m_2}\\dot{\\vb{R}} \\vdot \\dot{\\vb{r}} \\qq{and} \\abs{\\dot{\\vb{r_2}}}^2 = \\abs{\\dot{\\vb{R}}}^2 + \\dfrac{m_1^2 \\abs{\\dot{\\vb{r}}}^2}{(m_1 + m_2)^2} - \\dfrac{2 m_1}{m_1 + m_2}\\dot{\\vb{R}} \\vdot \\dot{\\vb{r}}\n\\end{equation*}\nSubstituting into the expression for the Lagrangian, one gets,\n\\begin{equation*}\nL = \\dfrac{M}{2}\\abs{\\dot{\\vb{R}}}^2  + \\dfrac{\\mu}{2}\\abs{\\dot{\\vb{r}}}^2 - V(\\vb{r}) \\qq{where} M = m_1 + m_2 \\qq{,} \\mu = \\dfrac{m_1 m_2}{M}\n\\end{equation*}\nEach component of $ \\dot{\\vb{R}} $ will be conserved separately as all of them are cyclic coordinates. Using $ \\vb{R} = X \\vu{x} + Y \\vu{y} + Z \\vu{z} $ and $ \\dot{\\vb{{r}}} = \\dot{r}\\vu{r} + r \\dot{\\vu{r}} $,\n\\begin{equation*}\nL = \\dfrac{M}{2} (\\dot{X}^2 + \\dot{Y}^2 )  + \\dfrac{\\mu}{2} (\\dot{r}^2 + r^2 \\dot{\\theta}^2)- V(r) \n\\end{equation*}\n\\textbf{Part (a)}\\\\\nWe can see from the form of the above Lagrangian that,\n\\begin{equation*}\nM\\dot{X}= constant \\qq{,} M\\dot{Y}= constant \\qq{,} \\mu r^2 \\dot{\\theta}= constant  \n\\end{equation*}\nConsider the infinitesimal area swept by the vector $\\vb{r}$, \n\\begin{equation*}\ndA = \\frac{r^2 d\\theta}{2} \\implies \\dot{A} = r^2 \\dfrac{\\dot{\\theta}}{2} = constant = l\n\\end{equation*}\nHence, the radius vector sweeps equal areas in equal intervals of time.\n\\\\\n\n\\textbf{Part (b)}\\\\\nIf $  m_2 \\gg m_1 $, $ \\vb{R} \\approx \\vb{r_2}$, $ \\mu \\approx m_1 $ and the mass $ m_2  $ does not move. Using energy conservation (and  the fact that the centre of mass does not move),\n\\begin{equation*}\n\t\\dfrac{\\mu}{2} (\\dot{r}^2 + r^2 \\dot{\\theta}^2) + V(r) = E \\implies \\dot{r}^2 + \\dfrac{4 l^2}{r^2} = \\dfrac{2}{\\mu} (E - V(r))\n\\end{equation*}\n$ r(t) $ will be given by the solution of this differential equation.\\\\\n\n\\textbf{Part (c)}\\\\\nThe Euler-Lagrange equation for the coordinate $ r $ is given by,\n\\begin{equation*}\n\\mu \\ddot{r} = \\mu r \\dfrac{4 l^2}{r^4}- \\dfrac{k}{r^2} \\implies \\ddot{r} - \\dfrac{4l^2}{r^3} + \\dfrac{k}{\\mu r^2} = 0\n\\end{equation*}\nMultiplying by $ \\dot{r} $ and integrating with time, we get,\n\\begin{equation*}\n\\dot{r}^2 + \\dfrac{2l^2}{r^2} - \\dfrac{k}{\\mu r} = constant = E\n\\end{equation*}\n\\end{homeworkProblem}\n\\end{document}\n", "meta": {"hexsha": "8c3fe37e9c19bcbbe48ce8c7b43ce505843bec2e", "size": 10315, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/cmech/assign_3/cmech_assign_3.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/cmech/assign_3/cmech_assign_3.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/cmech/assign_3/cmech_assign_3.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.3702290076, "max_line_length": 320, "alphanum_fraction": 0.660203587, "num_tokens": 4145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792043, "lm_q2_score": 0.8080672227971211, "lm_q1q2_score": 0.4103461228715252}}
{"text": "\\documentclass[11pt,oneside]{article}\t%use\"amsart\"insteadof\"article\"forAMSLaTeXformat\n\\usepackage{geometry}\t\t%Seegeometry.pdftolearnthelayoutoptions.Therearelots.\n\\geometry{letterpaper}\t\t%...ora4paperora5paperor...\n%\\geometry{landscape}\t\t%Activateforforrotatedpagegeometry\n%\\usepackage[parfill]{parskip}\t\t%Activatetobeginparagraphswithanemptylineratherthananindent\n\\usepackage{graphicx}\t\t\t\t%Usepdf,png,jpg,orepsßwithpdflatex;useepsinDVImode\n\t\t\t\t\t\t\t\t%TeXwillautomaticallyconverteps-->pdfinpdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\n%----macros begin---------------------------------------------------------------\n\\usepackage{color}\n\\usepackage{amsthm}\n\n\\def\\conv{\\mbox{\\textrm{conv}\\,}}\n\\def\\aff{\\mbox{\\textrm{aff}\\,}}\n\\def\\E{\\mathbb{E}}\n\\def\\R{\\mathbb{R}}\n\\def\\Z{\\mathbb{Z}}\n\\def\\tex{\\TeX}\n\\def\\latex{\\LaTeX}\n\\def\\v#1{{\\bf #1}}\n\\def\\p#1{{\\bf #1}}\n\\def\\T#1{{\\bf #1}}\n\n\\def\\vet#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\\def\\mat#1{{\\left(\\begin{array}{cccccccccccccccccccc}#1\\end{array}\\right)}}\n\n\\def\\lin{\\mbox{\\rm lin}\\,}\n\\def\\aff{\\mbox{\\rm aff}\\,}\n\\def\\pos{\\mbox{\\rm pos}\\,}\n\\def\\cone{\\mbox{\\rm cone}\\,}\n\\def\\conv{\\mbox{\\rm conv}\\,}\n\\newcommand{\\homog}[0]{\\mbox{\\rm homog}\\,}\n\\newcommand{\\relint}[0]{\\mbox{\\rm relint}\\,}\n\n%----macros end-----------------------------------------------------------------\n\n\\title{Modeling Geometry with Assemblies in SysML\n\\footnote{This document is part of the \\emph{Linear Algebraic Representation with CoChains} (LAR-CC) framework~\\cite{cclar-proj:2013:00}. \\today}\n}\n%\\author{TheAuthor}\n%\\date{}\t\t\t\t\t\t\t%Activatetodisplayagivendateornodate\n\n\\begin{document}\n\\maketitle\n\\nonstopmode\n\n\\begin{abstract}\nIn this module a preliminary concept implementation is provided for the possible introduction of a novel kind of 3D diagram in SysML. Such ``Assembly\" Diagram in used to specify an operable description of the 3D geometry of a system part.\n\\end{abstract}\n\n\\tableofcontents\n\n%===============================================================================\n\\section{Introduction}\n%===============================================================================\n%-------------------------------------------------------------------------------\n\\subsection{bbbbbbbb}\n%-------------------------------------------------------------------------------\n%===============================================================================\n\\section{Implementation}\n%===============================================================================\n%-------------------------------------------------------------------------------\n\\subsection{Diagram initialization}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Uniform cell sizing}\n\nA cuboidal 3-complex is generated by the script below, where the cells have uniform dimension on each coordinate direction. \n\n%-------------------------------------------------------------------------------\n@D Diagram initialization\n@{\"\"\" Diagram initialization \"\"\"\ndef assemblyDiagramInit(shape):\n\tprint \"\\n shape =\",shape\n\t# shape must be 3D, i.e. a python array with 3 indices\n\tassert len(shape) == 3\n\tdiagram = larCuboids(shape)\n\treturn diagram\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Non-uniform cell sizing}\n\nThe parameter \\texttt{quoteList} is used here to generate the new vertices of the \\texttt{diagram}, previously generated with uniform spacing between the cell vertices in every coordinate direction.\nEach \\texttt{pattern} in \\texttt{quoteList} is a list of positive numbers, each corresponding to the size of the corresponding \"coordinate stripe\".\n\n%-------------------------------------------------------------------------------\n@D Diagram initialization (non-uniform sizing)\n@{\"\"\" Diagram initialization \"\"\"\ndef assemblyDiagramInit (shape):\n\tdef assemblyDiagram (quoteList):\n\t\tprint \"\\n shape =\",shape\n\t\t# shape and quoteList must be 3D, i.e. a python array with 3 indices\n\t\tassert (len(shape) == 3) and (len(quoteList) == 3)\n\t\tcoordList = [list(cumsum([0]+pattern)) for pattern in quoteList]\n\t\tverts = CART(coordList)\n\t\t_,CV = larCuboids(shape)\n\t\treturn verts,CV\n\treturn assemblyDiagram\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{Diagram scaling to cuboid of given size}\nThe \\texttt{size} parameter is the array of lateral dimensions to which to scale the \n\\texttt{diagram} parameter. \\texttt{size} must be an array of 3 numbers; \\texttt{diagram} is\na LAR model\n\n%-------------------------------------------------------------------------------\n@D Diagram scaling to sized cuboid\n@{\"\"\" Diagram scaling to given size \"\"\"\ndef unitDiagram(diagram, size=[1,1,1]):\n\tV,CV = diagram\n\tprint \"\\n shape =\",shape\n\t# size must be a python array with 3 numbers\n\tassert (len(size) == 3) and (AND(AA(ISNUM)(size)) == True)\n\tV_ = array(V) / AA(float)(max(V))\n\tV = (V_ * size).tolist()\n\tdiagram = V,CV\n\treturn diagram\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Diagram segmentation}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Boundary cells ($3D\\to 2D$) computation}\nThe computations of boundary cells is executed by calling the \\texttt{boundaryCells} from the \\texttt{larcc} module.\n\n%-------------------------------------------------------------------------------\n@D Boundary cells ($3D\\to 2D$) computation\n@{def lar2boundaryFaces(CV,FV):\n\t\"\"\" Boundary cells computation \"\"\"\n\treturn boundaryCells(CV,FV)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Interior partitions ($3D\\to 2D$) computation}\nThe indices of the boundary 2-cells are returned in \\texttt{boundarychain2D}, and subtracted from the set $\\{0,1,\\ldots,|E|-1\\}$ in order to return the indices of the \\texttt{interiorCells}.\n%-------------------------------------------------------------------------------\n@D Interior partitions ($3D\\to 2D$) computation\n@{def lar2InteriorFaces(CV,FV):\n\t\"\"\" Boundary cells computation \"\"\"\n\tboundarychain2D = boundaryCells(CV,FV)\n\ttotalChain2D = range(len(FV))\n\tinteriorCells = set(totalChain2D).difference(boundarychain2D)\n\treturn interiorCells\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Subdiagram mapping}\n%-------------------------------------------------------------------------------\n\nThe aim of this section is to allow for separate development of subdiagrams of a geometric diagram.\nWhen satisfied with the current design situation,  the developer may map a whole diagram into a single 3D cell of the upper-level diagram --- in the following called the \\emph{master} diagram.\nOf course, such nesting may happen several times within a (father) master, producing a hierarchical decomposition (of any depth) of the geometry diagrams.\n\n\n\\paragraph{Task decomposition}\nThe procedure to map a diagram to a sub diagram is described below in a top-down manner,\ndecomposing the task into an ordered set of subtasks.\n\n\nThe \\texttt{diagram2cell} functions below works as follows.  Its job is to map the LAR model \\texttt{diagram} (semantically a 3-array of cuboidal blocks) onto the 3D-cell of the \\texttt{master} LAR model (another 3-array of cuboidal blocks), indexed by the integer \\texttt{cell} parameter. In few words: mapping \\texttt{diagram} onto the given \\texttt{cell} of \\texttt{master}.\n\nFirst, the matrix \\texttt{mat}of this 3D-window to 3D-viewport transformation is computed, by invoking \\texttt{diagram2cellMatrix}. Then, the \\texttt(mat) transformation is applied to \\texttt{vertices}.\nThen both such LAR models are passed as parameters of the \\texttt{vertexSieve} function, that returns a single vertex list \\texttt{V}, two (reindexed) lists \\texttt{CV1} and \\texttt{CV2}, and the number \\texttt{n12} of common vertices.\n\n\nWe can look at their common incidence matrix as shown in Figure~\\ref{}.\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[width=0.4\\linewidth]{images/merge} \n   \\caption{Structure of the characteristic matrix $M(CV)$ afre the merge of two LAR models, and identification of the common vertices.}\n   \\label{fig:example}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n@D Subdiagram to diagram mapping\n@{\n@< 3D window to viewport transformation @>\n\ndef diagram2cell(diagram,master,cell):\n\tmat = diagram2cellMatrix(diagram)(master,cell)\n\tdiagram =larApply(mat)(diagram)\t\n\t(V1,CV1),(V2,CV2) = master,diagram\n\tn1,n2 = len(V1), len(V2)\n\t\n\t# identification of common vertices\n\tV, CV1, CV2, n12 = vertexSieve(master,diagram)\n\tcommonRange = range(n1-n12, n1)\n\tnewRange = range(n1,n1-n12+n2)\n\t\n\t# addition of incident vertices into the adjacents of theCell\n\tdef checkInclusion(V,theCell,newRange):\n\t\ttheVerts = [V[v] for v in theCell]\n\t\ttheMin, theMax = min(theVerts), max(theVerts)\n\t\ttheCell += [v for v in newRange if (\n\t\t\ttheMin[0] <= V[v][0] and theMin[1] <= V[v][1] and theMin[2] <= V[v][2] \n\t\t\tand \n\t\t\tV[v][0] <= theMax[0] and V[v][1] <= theMax[1] and V[v][2] <= theMax[2] \n\t\t\t)]\n\t\treturn theCell\n\t\n\t# addition of new vertices into the adjacents of cell c\n\tCV1 = [checkInclusion(V,c,newRange) \n\t\t\tif set(c).intersection(commonRange) != set() else c\n\t\t\t for c in CV1]\n\t\n\t# masterBoundaryFaces = boundaryOfChain(CV,FV)([cell])\n\t# diagramBoundaryFaces = lar2boundaryFaces(CV,FV)\n\tCV = [c for k,c in enumerate(CV1) if k != cell] + CV2\n\t\n\tmaster = V, CV\n\treturn master\n@}\n%-------------------------------------------------------------------------------\n\n\n\\paragraph{3D window to viewport transformation}\n%-------------------------------------------------------------------------------\n@D 3D window to viewport transformation\n@{\"\"\" 3D window to viewport transformation \"\"\"\ndef diagram2cellMatrix(diagram):\n\tdef diagramToCellMatrix0(master,cell):\n\t\twdw = min(diagram[0]) + max(diagram[0])\t\t\t# window3D\n\t\tcV = [master[0][v] for v in master[1][cell]]\n\t\tvpt = min(cV) + max(cV)\t\t\t\t\t\t\t\t# viewport3D\n\t\tprint \"\\n window3D =\",wdw\n\t\tprint \"\\n viewport3D =\",vpt\n\t\t\n\t\tmat = zeros((4,4))\n\t\tmat[0,0] = (vpt[3]-vpt[0])/(wdw[3]-wdw[0])\n\t\tmat[0,3] = vpt[0] - mat[0,0]*wdw[0]\n\t\tmat[1,1] = (vpt[4]-vpt[1])/(wdw[4]-wdw[1])\n\t\tmat[1,3] = vpt[1] - mat[1,1]*wdw[1]\n\t\tmat[2,2] = (vpt[5]-vpt[2])/(wdw[5]-wdw[2])\n\t\tmat[2,3] = vpt[2] - mat[2,2]*wdw[2]\n\t\tmat[3,3] = 1\n\t\tprint \"\\n mat =\",mat\n\t\treturn mat\n\treturn diagramToCellMatrix0\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n%===============================================================================\n\\section{Topological consistency}\n%===============================================================================\n%-------------------------------------------------------------------------------\n\nWhen a 3D diagram is generated as a Cartesian product of 1D complexes, it is relatively easy to \ncompute its cells of any dimension. For this purpose, see the the module \\texttt{largrid}\nand/or the function \\texttt{gridSkeletons(shape)}, that returns the list of skeletons \ngenerated by the cellular complex of a given \\texttt{shape}.\n\nTwo different strategies may be used to guarantee the correctness of topology after\nlocal refinements, that provide a replacement of single cells with subdivided complexes. Such two \nstrategies are \ndiscussed and developed in the next two subsections.\n\n%-------------------------------------------------------------------------------\n\\subsection{Decomposition of the whole space}\n%-------------------------------------------------------------------------------\nAs already coped with in module \\texttt{larcc}, the facets, i.e.~the ($d-1$)-faces, \nof a cellular $d$-complex may be easily computed using the product of the sparse \ncharacteristic matrix $M_d$ times its transpose $M_d^t$. It is easy to see that \neach element $a_{ij}$ of \n\\[\nA_d = M_d\\, M_d^t = (a_{ij})\n\\] \nprovides the number of common vertices between the $d$-face $\\gamma_i$ and the \n$d$-face $\\gamma_j$. When this number is greater or equal than $d$, there is a common\n$(d-1)$-face shared between $\\gamma_i$ and $\\gamma_j$.\n\nIn order to guarantee that all $(d-1)$-faces can be discovered by this method, a \ncellular decomposition of the whole $\\E^d$ must be maintained, including both \\emph{solid} cells,\ni.e.~the decomposition of the interior space, and \\emph{empty} cells, corresponding to a \ndecomposition of the exterior space.\n\n\\paragraph{Exterior space of a block diagram}\n\n%-------------------------------------------------------------------------------\n@D Exterior space of a block diagram\n@{\"\"\" Exterior space of a block diagram \"\"\"\ndef exteriorCells(diagram):\n\tV,CV = diagram\n\tminVert, maxVert = min(V), max(V)\n\td = len(V[0])\n\toutchain = [[] for k in range(2*d)]\n\tfor k,v in enumerate(V):\n\t\tfor h in range(d):\n\t\t\tif v[h] == minVert[h]: outchain[h] += [k]\n\t\t\tif v[h] == maxVert[h]: outchain[h+d] += [k]\n\treturn outchain\n@}\n%-------------------------------------------------------------------------------\n\nThe aim of computing che chain of exterior cells is associated to the computation of \nof the $(d-1)$-skeleton, in turn needed for the computation of the boundary and coboundary operators.\nLook to Section~\\ref{sec:exterior} for a worked example.\n\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Promoting local upgrades in all dimensions}\n%-------------------------------------------------------------------------------\n\n\n\n%===============================================================================\n\\section{Library export}\n%===============================================================================\n%-------------------------------------------------------------------------------\n\\subsection{Exporting the library}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O larlib/larlib/sysml.py\n@{\"\"\" sysml library \"\"\"\nfrom larlib import *\nDRAW = COMP([VIEW,STRUCT,MKPOLS])\n\n@< To compute the boundary (d-1)-chain of a given d-chain @>\n@< Diagram initialization (non-uniform sizing) @>\n@< Boundary cells ($3D\\to 2D$) computation @>\n@< Interior partitions ($3D\\to 2D$) computation @>\n@< Diagram scaling to sized cuboid @>\n@< Drawing numbers of cells @>\n@< Subdiagram to diagram mapping @>\n@< Exterior space of a block diagram @>\n@< Place vertices of two LAR models in a common space @>\n@}\n%-------------------------------------------------------------------------------\n\n%===============================================================================\n\\section{Tests}\n%===============================================================================\n%-------------------------------------------------------------------------------\n\\subsection{Diagram initialization}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/sysml/test01.py\n@{\"\"\" testing initial steps of Assembly Diagram construction \"\"\"\nfrom larlib import *\n\nshape = [1,2,2]\nsizePatterns = [[1],[2,1],[0.8,0.2]]\ndiagram = assemblyDiagramInit(shape)(sizePatterns)\nprint \"\\n diagram =\",diagram\nVIEW(SKEL_1(STRUCT(MKPOLS(diagram))))\n\nVV,EV,FV,CV = gridSkeletons(shape)\nboundaryFaces = lar2boundaryFaces(CV,FV)\ninteriorFaces = list(set(range(len(FV))).difference(boundaryFaces))\nprint \"\\n boundary faces =\",boundaryFaces\nprint \"\\n interior faces =\",interiorFaces\ndiagram1 = unitDiagram(diagram)\nVIEW(SKEL_1(STRUCT(MKPOLS(diagram1))))\n\nhpc = SKEL_1(STRUCT(MKPOLS(diagram1)))\nV = diagram1[0]\nhpc = cellNumbering((V,FV),hpc)(interiorFaces,YELLOW,.5)\nVIEW(hpc)\nhpc = cellNumbering((V,EV),hpc)([f for f in interiorFaces],GREEN,.4)\nVIEW(hpc)\nhpc = cellNumbering((V,VV),hpc)(range(len(VV)),RED,.3)\nVIEW(hpc)\n\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Diagram merging}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n@O test/py/sysml/test02.py\n@{\"\"\" definition and merging of two diagrams into a single diagram \"\"\"\nfrom larlib import *\n\nmaster = assemblyDiagramInit([2,2,2])([[.4,.6],[.4,.6],[.4,.6]])\ndiagram = assemblyDiagramInit([3,3,3])([[.4,.2,.4],[.4,.2,.4],[.4,.2,.4]])\nVIEW(SKEL_1(STRUCT([DRAW(master),T(2)(1),DRAW(diagram)])))\n\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),WHITE,.5)\nVIEW(hpc)\n\nmaster = diagram2cell(diagram,master,7)\nVIEW(SKEL_1(STRUCT( MKPOLS(master) )))\n\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Diagram visualization}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n@O test/py/sysml/test03.py\n@{\"\"\" definition and merging of two diagrams into a single diagram \"\"\"\nfrom larlib import *\n\nmaster = assemblyDiagramInit([2,2,2])([[.4,.6],[.4,.6],[.4,.6]])\ndiagram = assemblyDiagramInit([3,3,3])([[.4,.2,.4],[.4,.2,.4],[.4,.2,.4]])\n\nVV,EV,FV,CV = gridSkeletons([2,2,2])\nV,CV = master\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(CV)),CYAN,.5)\nVIEW(hpc)\n\nmaster = diagram2cell(diagram,master,7)\nVIEW(SKEL_1(STRUCT( MKPOLS(master) )))\n\nVIEW(EXPLODE(1.5,1.5,1.5)(MKPOLS(larFacets(master))))\n\nmasterBoundaryFaces = boundaryOfChain(CV,FV)([7])\ndiagramBoundaryFaces = lar2boundaryFaces(CV,FV)\n@}\n%-------------------------------------------------------------------------------\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/mastermerged} \n   \\includegraphics[height=0.49\\linewidth,width=0.49\\linewidth]{images/masterfacets} \n   \\caption{Example of a geometry diagram merged in a master diagram}\n   \\label{fig:mastermerged}\n\\end{figure}\n\n\\begin{figure}[htbp] %  figure placement: here, top, bottom, or page\n   \\centering\n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig2} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig4} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig5} \n\n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig6} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig7} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig8} \n\n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig9} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig10} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig11} \n\n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig12} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig13} \n   \\includegraphics[height=0.3\\linewidth,width=0.3\\linewidth]{images/fig14} \n\n   \\caption{The construction process of the \\texttt{master} block diagram built by the example \\texttt{test/py/sysml/test4.py} of Section~\\ref{sec:master}.}\n   \\label{fig:master}\n\\end{figure}\n\n%-------------------------------------------------------------------------------\n\\subsection{progressive refinement of a block diagram}\n\\label{sec:master}\n%-------------------------------------------------------------------------------\n\nIn this example, a step-by step generation of a simple apartment is produced, using \n\\texttt{assemblyDiagramInit} to produce a block diagram of given \\texttt{shape} and \n\\texttt{size}, the \\texttt{cellNumbering} function to generate an \\emph{hpc} value\nwith the numbers of 3-cells in the current \"master\" diagram, the \\texttt{diagram2cell}\nfunction to map and merge a \\texttt{diagram} into a \\texttt{cell} of the \\texttt{master}.\n\nThe construction process is visualised in Figure~\\ref{fig:master}.\n\nRemember that in \\texttt{lar-cc} the numbering of cells in a model is 0-based (like\nin python). Conversely, in \\texttt{pyplasm} the numbering of cells (for example of \nvertex indices in \\texttt{MKPOL}) is 1-based, like in Fortran or MATLAB.   \n\n%-------------------------------------------------------------------------------\n@O test/py/sysml/test04.py\n@{\"\"\" progressive refinement of a block diagram \"\"\"\nfrom larlib import *\n\nmaster = assemblyDiagramInit([5,5,2])([[.3,3.2,.1,5,.3],[.3,4,.1,2.9,.3],[.3,2.7]])\nV,CV = master\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(CV)),CYAN,2)\nVIEW(hpc)\n\ntoRemove = [13,33,17,37]\nmaster = V,[cell for k,cell in enumerate(CV) if not (k in toRemove)]\nDRAW(master)\n\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n\ntoMerge = 29\ncell = MKPOL([master[0],[[v+1 for v in  master[1][toMerge]]],None])\nVIEW(STRUCT([hpc,cell]))\n\ndiagram = assemblyDiagramInit([3,1,2])([[2,1,2],[.3],[2.2,.5]])\nmaster = diagram2cell(diagram,master,toMerge)\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n\ntoRemove = [47]\nmaster = master[0], [cell for k,cell in enumerate(master[1]) if not (k in toRemove)]\nDRAW(master)\n\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n\ntoMerge = 34\ncell = MKPOL([master[0],[[v+1 for v in  master[1][toMerge]]],None])\nVIEW(STRUCT([hpc,cell]))\n\ndiagram = assemblyDiagramInit([5,1,3])([[1.5,0.9,.2,.9,1.5],[.3],[1,1.4,.3]])\nmaster = diagram2cell(diagram,master,toMerge)\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n\ntoRemove = [53,59]\nmaster = master[0], [cell for k,cell in enumerate(master[1]) if not (k in toRemove)]\nDRAW(master)\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Using the cochain of exterior cells}\n\\label{sec:exterior}\n%-------------------------------------------------------------------------------\n\nHere we develop the same example \\texttt{} given above, but using also a cochain of empty cells,\nin order to be able to extract the boundary and coboundary operators of the cell decompositions. \nThe \\texttt{exteriorChain}\nof the \\texttt{master} diagram is first computed after the \\texttt{master} initialisation, and later updated with cells defined as empty\n\n%-------------------------------------------------------------------------------\n@O test/py/sysml/test05.py\n@{\"\"\" boundary extraction of a block diagram \"\"\"\nfrom larlib import *\n\nDRAW = COMP([VIEW,STRUCT,MKPOLS])\n\nmaster = assemblyDiagramInit([5,5,2])([[.3,3.2,.1,5,.3],[.3,4,.1,2.9,.3],[.3,2.7]])\ndiagram1 = assemblyDiagramInit([3,1,2])([[2,1,2],[.3],[2.2,.5]])\ndiagram2 = assemblyDiagramInit([5,1,3])([[1.5,0.9,.2,.9,1.5],[.3],[1,1.4,.3]])\n\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n \nmaster = diagram2cell(diagram2,master,39)\nmaster = diagram2cell(diagram1,master,31)\n\nhpc = SKEL_1(STRUCT(MKPOLS(master)))\nhpc = cellNumbering (master,hpc)(range(len(master[1])),CYAN,2)\nVIEW(hpc)\n\nemptyChain = [17,13,32,36,52,58,65]\nsolidCV = [cell for k,cell in enumerate(master[1]) if not (k in emptyChain)]\nDRAW((master[0],solidCV))\n\nexteriorCV =  [cell for k,cell in enumerate(master[1]) if k in emptyChain]\nexteriorCV += exteriorCells(master)\nCV = solidCV + exteriorCV\nV = master[0]\nFV = [f for f in larFacets((V,CV),3,len(exteriorCV))[1] if len(f) >= 4]\nVIEW(EXPLODE(1.5,1.5,1.5)(MKPOLS((V,FV))))\n\nBF = boundaryCells(solidCV,FV)\nboundaryFaces = [FV[face] for face in BF]\nB_Rep = V,boundaryFaces\nVIEW(EXPLODE(1.1,1.1,1.1)(MKPOLS(B_Rep)))\nVIEW(STRUCT(MKPOLS(B_Rep)))\n\n@< Transform the LAR boundary model in a triangle model @>\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Transform the LAR boundary model in a triangles model}\nThe transformation from a boundary representation made by general 2D convex faces to a set of triangle faces is provided below.\n\n%-------------------------------------------------------------------------------\n@D Transform the LAR boundary model in a triangle model\n@{\nverts, triangles = quads2tria(B_Rep)\nB_Rep = V,boundaryFaces\nVIEW(EXPLODE(1.1,1.1,1.1)(MKPOLS((verts, triangles))))\nVIEW(STRUCT(MKPOLS((verts, triangles))))\n@}\n@}\n%-------------------------------------------------------------------------------\n\n\n%===============================================================================\n\\appendix\n\\section{Utilities}\n%===============================================================================\n\n%-------------------------------------------------------------------------------\n@D To compute the boundary (d-1)-chain of a given d-chain\n@{\ndef boundaryOfChain(cells,facets):\n\tcsrBoundaryMat = larBoundary(cells,facets)\n\tcsrChain = zeros((len(cells),1))\n\tdef boundaryOfChain0(chain):\n\t\tfor cell in chain:  csrChain[cell,0]=1.0\n\t\tcsrBoundaryChain = matrixProduct(csrBoundaryMat, csrChain)\n\t\tboundaryCells = [k for k,val in enumerate(csrBoundaryChain.tolist()) \n\t\t\t\t\t\t\tif val == [1.0]]\n\t\treturn boundaryCells\n\treturn boundaryOfChain0\n@}\n%-------------------------------------------------------------------------------\n\n\n%-------------------------------------------------------------------------------\n\\subsection{Initial import of modules}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Initial import of modules}\n\n%-------------------------------------------------------------------------------\n@D Initial import of modules\n@{\"\"\" Initial import of modules \"\"\"\nfrom lar2psm import *\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsection{Reordering of vertex coordinates}\n%-------------------------------------------------------------------------------\n\nA global reordering of vertex coordinates is executed as the first step of the Boolean algorithm, in order to eliminate the duplicate vertices, by substituting duplicate vertex copies (coming from two close points) with a single instance. \n\nTwo dictionaries are created, then merged in a single dictionary, and finally split into three subsets of (vertex,index) pairs, with the aim of rebuilding the input representations, by making use of a novel and more useful vertex indexing.\n\nThe union set of vertices is finally reordered using the three subsets of vertices belonging (a) only to the first argument, (b) only to the second argument and (c) to both, respectively denoted as $V_1, V_2, V_{12}$. A top-down description of this initial computational step is provided by the set of macros discussed in this section.\n\n%-------------------------------------------------------------------------------\n@D Place vertices of two LAR models in a common space\n@{\"\"\" Place vertices of two LAR models in a common space \"\"\"\n@< Initial indexing of vertex positions @>\n@< Merge two dictionaries with keys the point locations @>\n@< Filter the common dictionary into three subsets @>\n@< Compute an inverted index to reorder the vertices of arguments @>\n@< Return the single reordered pointset and the two $d$-cell arrays @>\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsubsection{Re-indexing of vertices}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Initial indexing of vertex positions}\nThe input LAR models are located in a common space by (implicitly) joining \\texttt{V1} and \\texttt{V2} in a same array, and (explicitly) shifting the vertex indices in \\texttt{CV2} by the length of \\texttt{V1}.\n%-------------------------------------------------------------------------------\n@D Initial indexing of vertex positions\n@{from collections import defaultdict, OrderedDict\n\ndef vertexSieve(model1, model2):\n\tV1,CV1 = model1; V2,CV2 = model2\n\tn = len(V1); m = len(V2)\n\tdef shift(CV, n): \n\t\treturn [[v+n for v in cell]for cell in CV]\n\tCV2 = shift(CV2,n)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Merge two dictionaries with point location as keys}\nSince currently \\texttt{CV1} and \\texttt{CV2} point to a set of vertices larger than their initial sets \n\\texttt{V1} and \\texttt{V2}, we index the set $\\texttt{V1} \\cup \\texttt{V2}$ using a Python \\texttt{defaultdict} dictionary, in order to avoid errors of \"missing key\". As dictionary keys, we use the string representation of the vertex position vector provided by the \\texttt{vcode(4)} function given in the Appendix.\n%-------------------------------------------------------------------------------\n@D Merge two dictionaries with keys the point locations\n@{\n\tvdict1 = defaultdict(list)\n\tfor k,v in enumerate(V1): vdict1[vcode(4)(v)].append(k) \n\tvdict2 = defaultdict(list)\n\tfor k,v in enumerate(V2): vdict2[vcode(4)(v)].append(k+n) \n\t\n\tvertdict = defaultdict(list)\n\tfor point in vdict1.keys(): vertdict[point] += vdict1[point]\n\tfor point in vdict2.keys(): vertdict[point] += vdict2[point]\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Example of string coding of a vertex position}\nThe position vector of a point of real coordinates is provided by the function \\texttt{vcode(4)}.\nAn example of coding is given below. The \\emph{precision} of the string representation can be tuned at will.\n{\\small\n\\begin{verbatim}\n>>> vcode(4)([-0.011660381062724849, 0.297350056848685860])\n'[-0.0116604, 0.2973501]'\n\\end{verbatim}}\n\n\n\n\\paragraph{Filter the common dictionary into three subsets}\n\\texttt{Vertdict}, dictionary of vertices, uses as key stye position vectors of vertices coded as string, and as values the list of integer indices of vertices on the given position. If the point position belongs either to the first or to second argument only, it is stored in \\texttt{case1} or \\texttt{case2} lists respectively. If the position (\\texttt{item.key}) is shared between two vertices, it is stored in \\texttt{case12}.\nThe variables \\texttt{n1}, \\texttt{n2}, and \\texttt{n12} remember the number of vertices respectively stored in each repository.\n%-------------------------------------------------------------------------------\n@D Filter the common dictionary into three subsets\n@{\n\tcase1, case12, case2 = [],[],[]\n\tfor item in vertdict.items():\n\t\tkey,val = item\n\t\tif len(val)==2:  case12 += [item]\n\t\telif val[0] < n: case1 += [item]\n\t\telse: case2 += [item]\n\tn1 = len(case1); n2 = len(case12); n3 = len(case2)\n@}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Compute an inverted index to reorder the vertices of Boolean arguments}\nThe new indices of vertices are computed according with their position within the storage repositories \\texttt{case1}, \\texttt{case2}, and \\texttt{case12}. Notice that every \\texttt{item[1]} stored in \\texttt{case1} or \\texttt{case2} is a list with only one integer member. Two such values are conversely stored in each \\texttt{item[1]} within \\texttt{case12}.\n%-------------------------------------------------------------------------------\n@D Compute an inverted index to reorder the vertices of arguments\n@{\n\tinvertedindex = list(0 for k in range(n+m))\n\tfor k,item in enumerate(case1):\n\t\tinvertedindex[item[1][0]] = k\n\tfor k,item in enumerate(case12):\n\t\tinvertedindex[item[1][0]] = k+n1\n\t\tinvertedindex[item[1][1]] = k+n1\n\tfor k,item in enumerate(case2):\n\t\tinvertedindex[item[1][0]] = k+n1+n2\n@}\n%-------------------------------------------------------------------------------\n\n%-------------------------------------------------------------------------------\n\\subsubsection{Re-indexing of d-cells}\n%-------------------------------------------------------------------------------\n\n\\paragraph{Return the single reordered pointset and the two $d$-cell arrays}\nWe are now finally ready to return two reordered LAR models defined over the same set \\texttt{V} of vertices, and where (a) the vertex array \\texttt{V} can be written as the union of three disjoint sets of points $C_1,C_{12},C_2$; (b) the $d$-cell array \\texttt{CV1} is indexed over $C_1\\cup C_{12}$; (b) the $d$-cell array \\texttt{CV2} is indexed over $C_{12}\\cup C_{2}$. \n\nThe \\texttt{vertexSieve} function will return the new reordered vertex set $V = (V_1 \\cup V_2) \\setminus (V_1 \\cap V_2)$, the two renumbered $s$-cell sets \\texttt{CV1} and \\texttt{CV2}, and the size \\texttt{len(case12)} of $V_1 \\cap V_2$.\n%-------------------------------------------------------------------------------\n@D Return the single reordered pointset and the two $d$-cell arrays\n@{\n\tV = [eval(p[0]) for p in case1] + [eval(p[0]) for p in case12] + [eval(\n\t\t\t\tp[0]) for p in case2]\n\tCV1 = [sorted([invertedindex[v] for v in cell]) for cell in CV1]\n\tCV2 = [sorted([invertedindex[v] for v in cell]) for cell in CV2]\n\treturn V, CV1, CV2, len(case12)\n@}\n%-------------------------------------------------------------------------------\n\n\n\n\n\n\\bibliographystyle{amsalpha}\n\\bibliography{sysml}\n\n\\end{document}\n", "meta": {"hexsha": "b81e89ec50e58e7aa67991e6ceff8bf00b2647c6", "size": 33767, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/tex/sysml.tex", "max_stars_repo_name": "cvdlab/lar-cc", "max_stars_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-09-20T04:48:12.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-20T04:48:12.000Z", "max_issues_repo_path": "src/tex/sysml.tex", "max_issues_repo_name": "Ahdhn/lar-cc", "max_issues_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-02-20T21:57:07.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-21T07:18:11.000Z", "max_forks_repo_path": "src/tex/sysml.tex", "max_forks_repo_name": "Ahdhn/lar-cc", "max_forks_repo_head_hexsha": "7092965acf7c0c78a5fab4348cf2c2aa01c4b130", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-04T10:47:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-10T17:32:50.000Z", "avg_line_length": 44.139869281, "max_line_length": 430, "alphanum_fraction": 0.5645156514, "num_tokens": 8312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4103220533157198}}
{"text": "\\chapter{Image Segmentation}\n\\label{ch:image_segmentation}\nInitially, the notion of segmentation stands for the process of classifying pixels into groups which corresponds to the same type or class \\cite{Margaritondo2011}. The segmentation allows to obtain more meaningful and potentially hidden information from original images, what let to bring indeed numerous insights for various business problems. \n\nFor instance, in medicine analysis segmentation invokes various uses cases such as to measure volume of an organ, to render a 3D view of an organ, surface-based registration and many others. Before moving forward I will explicitly distinguish segmentation types from general point of view.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=10cm]{images/semantic_instance_segmenattion.png}\n    \\caption{An example of semantic and instance segmentation.}\n    \\label{fig:image_segmentation}\n\\end{figure}\n\nMoving from the left to the right side on the Figure \\ref{fig:image_segmentation}, we in deed can transparently notice 2 main types of segmentation. From the very begging there is a original 3D CT image, after applying particular segmentation method, on the second image we see the resulting image where every pixel belongs to a certain class (either blue: cervical, green: thoracic, red: lumbar). Pixels which belongs the same class are represented by the same color. Such type of segmentation is called \"semantic segmentation\". \n\nThe very last image has assigned a particular class to each pixel of the image as well. However, different objects of the same class have different colors. Such type of segmentation is called \"instance segmentation\".\n\n\\section{Classical Segmentation Methods} \nNow we are good to go with classical segmentation methods section. I will cover basic thresholding method, then modified version of thresholding so called region growing. Afterwards I will speak about edge detection segmentation and clustering based segmentation. On top of that I will demonstrate the performance of each dedicated technique within the following baseline Figure \\ref{fig:sample_vertebrae} of vertebrae.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=2cm]{images/sample_vertebrae.jpeg}\n    \\caption{Sample CT scan of vertebrae.}\n    \\label{fig:sample_vertebrae}\n\\end{figure}\n\n\n\\subsection{Region Based Segmentation}\nSometimes region based segmentation method is mentioned as thresholding. Actually, it one of the simplest methods for classifying pixels based on solely on their intensity values \\cite{Butchiraju2019}. In thresholding we have options to choose either upper and lower bound values or to choose just one threshold value which can be for instance the mean of the original image values. \n\nMathematically, the algorithm can be defined as:\n\\[\n    f(x, y)= \n\\begin{cases}\n    0 & \\text{, if } f(x, y) > T \\\\\n    255 & \\text{, otherwise}\n\\end{cases}\n,\\]\nwhere $T$ is threshold value, $x$ and $y$ certain coordinates of pixel.\n\nAfter applying proposed algorithm with the mean threshold on the baseline Figure \\ref{fig:sample_vertebrae}, I had obtained following segmented image depicted on Figure \\ref{fig:sample_vertebrae_thresholding}. \n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=2cm]{images/sample_vertebrae_thresholding.png}\n    \\caption{Applied thresholding algorithm for sample CT scan of vertebrae.}\n    \\label{fig:sample_vertebrae_thresholding}\n\\end{figure}\n\nThe problem within simple thresholding is that it does not take into consideration any spatial information of an image, meaning each pixel is evaluated no matter where it is located. Beyond, each time we have to find best way to define either range of values or value for threshold.    \n\n\\subsection{Region Growing Segmentation}\nUnlike basic thresholding, region growing segmentation indeed takes into consideration spatial information starting with the small set of seed pixels and then growing out from them \\cite{Khaloo2017}. \n\nLet me assume following example. There is set of pixels $4 \\cdot 4$ which should be colored (segmented). The threshold range is between $10$ and $100$. Some of the cells are already filled with red color, another cells are potential candidates to be segmented. The task is to fill (segment) the \"non red\" cells with a red color based on predefined thresholding. Mathematically region growing can be defined as following equitation: \n\\[\n    f(x, y) = \n\\begin{cases}\n    \\text{segment as red} & \\text{, if } 10 \\leq \\text{intensity} \\leq 100 \\\\\n    \\text{keep same} & \\text{, otherwise}\n\\end{cases}\n,\\]\nwhere intensity is the pixel value with $x$ and $y$ coordinates. \n\nAll it all, region growing is an iterative method used to extract similar parts of an image. One or several points are chosen as a start. The region then grows until it is finally blocked by the stop criteria. This criteria is generally an inside/outside region comparison such as size or others. \n\nExactly the same manner growing region thresholding method can be applied for the previously chosen baseline Figure \\ref{fig:sample_vertebrae}. The resulting segmentation shown on Figure \\ref{fig:sample_vertebrae_grwoing}.\n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=2cm]{images/sample_vertebrae_regiongrowing.png}\n    \\caption {Applied region growing algorithm for sample CT scan of vertebrae.}\n    \\label{fig:sample_vertebrae_grwoing}\n\\end{figure}    \n\nThere is a huge potential room for improvements making the method more sophisticated by coming up with different conditions for inclusion or exclusion of pixels.\n\n\\subsection{Edge Detection Segmentation}\nThe detection of edges approach outputs meaningful semantic information that facilitate the understanding of an image. It is often used as auxiliary function or filter to perform segmentation. Edge detection can be used to directly segment edges and regions of images but it is particularly useful when we want to use that as part of another segmentation algorithm.\n\nAs Muthukrishnan \\cite{Muthukrishnan2011} described, there are four possible sources of edges in an image: surface normal discontinuity (surface changes direction sharply), depth discontinuity (one surface behind another), surface color discontinuity (single surface changes color), illumination discontinuity (shadows or lighting).\n\nIn order to perform edge detection usually it is applied high-pass filters such as Laplacian, Sobel, Prewitt or Canny whereas the corresponding output is so called filter mask which shows the transition values. After filtering it is usually applied thresholding to retrieve edges.\n\n\\subsubsection{Edge Basics}\nEdges occur in images when the magnitude of the gradient is high. In order to find the gradient, we firstly have to find the derivatives in both the $x$ and $y$ directions. These actions can be mathematically considered as:\n\\[ \\frac{\\partial f (x)}{\\partial x} = \\lim_{\\delta{f} \\to 0} \\dfrac{f(x) - f(x - \\delta x)}{\\delta x}  = f'(x); \\]\n\\[ \\frac{\\partial f (x)}{\\partial x} = \\dfrac{f(x) - f(x - 1)}{1}  = f'(x); \\]\n\\[ \\frac{\\partial f (x)}{\\partial x} = f(x) - f(x - 1) = f'(x); \\]\n\nAlso it is possible to take the derivative in three different ways and represent them as filter (convoluting the filter with the image gives the derivative) as:\n\\begin{align*}\nBackward: f'(x) = f(x) - f(x - 1) \\to [0, 1, -1]; \\\\\nForward:  f'(x) = f(x + 1) - f(x) \\to [-1, 1, 0]; \\\\\nCentral:  f'(x) = \\dfrac{(x + 1) - f(x - 1)}{2} \\to [1, 0, -1];\n\\end{align*}\n\nThe gradient ($\\nabla f$), gradient magnitude ($|\\nabla f(x, y)|$) and gradient angle ($\\Theta$) can be accordingly calculated as: \n\\begin{align*}\n\\nabla f(x, y) = \\left[ \\frac{\\partial{f (x, y)}}{\\partial{x}}, \\frac{\\partial{f (x, y)}}{\\partial{y}} \\right]  = [f_x, f_y]; \\\\\n|\\nabla f(x, y)| = \\sqrt{f^2_x + f^2_y}; \\\\\n\\Theta = \\tan^{-1} \\frac{f_y}{f_x};\n\\end{align*}\n\n\\subsubsection{Convolution}\nConvolution itself is a mathematical operation on two functions ($f$ and $g$) that produces a third function ($f \\cdot g$) that expresses how the shape of one is modified by the other \\cite{Pang2018}. Considering, mathematical notion of convolutional operation is:\n\\[(f \\ast g)(t) := \\int_{-\\infty}^{+\\infty} f(\\tau)g(t - \\tau)\\partial\\tau \\]\n\nAll it all, convolution operation can be described as: while a filter is sliding or convolving around an input image, it has been multiplying the values in the filter with the original pixel values of the image (computing element wise multiplications).\n\n\nTo show convolutional mathematical background I will use Figure \\ref{fig:sample_1_channel_image}.   \n\\begin{figure}[h]\n    \\centering \\includegraphics[width=4cm]{images/1_channel.jpg}\n    \\caption {Sample 1 channel image.}\n    \\label {fig:sample_1_channel_image}\n\\end{figure}\n\nSuppose we have 1 channel (gray scale) Figure \\ref{fig:sample_1_channel_image} image with size of $5 \\cdot 5$. Also there is a filter (kernel) which I had defined as: \n\\[ \\begin{pmatrix} 1 & 0 & -1 \\\\ 0 & 1 & 0 \\\\ -1 & 0 & 1 \\end{pmatrix} \\]\n\nNow I need to calculate the convolution with filter (kernel) which I had defined above. The size of filter is $3 \\cdot 3$, padding is $1 \\cdot 1$ and stride $1$.\n\nTo be aware in the correctness of the result, I would like to know the output size of convolution operation. In mathematical terms it is calculated as: \\[ \\text{size of output volume} = \\frac{W-F+2 \\cdot P}{S+1} \\] where $W$ - is the input volume size, $F$ - is the receptive field size, $S$ - the stride with which they are applied and $P$ - is the padding.\n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=10cm]{images/convolution_operation.jpeg}\n    \\caption {Example of convolution operation.}\n    \\label{fig:convolution}\n\\end{figure}\n\nOn the Figure \\ref{fig:convolution} I partially depicted step-wise convolution operation. Mathematically, red colored cell on the resulting convolution \\ref{fig:convolution} can be calculated as:    \n\\[ \\begin{pmatrix} 0 & 0 & 0 \\\\ 0 & 5 & 2 \\\\ 0 & 3 & 1 \\end{pmatrix} \\odot \\begin{pmatrix} 1 & 0 & -1 \\\\ 0 & 1 & 0 \\\\ -1 & 0 & 1 \\end{pmatrix} = \\]\n\\[ = 0 \\cdot 1 + 0 \\cdot 0 + 0 \\cdot (-1) + 0 \\cdot 0 + 5 \\cdot 1 + 2 \\cdot 0 + 0 \\cdot (-1) + 3 \\cdot 0 + 1 \\cdot 1 = \\] \n\\[ = 0 + 0 + 0 + 0 + 5 + 0 + 0 + 0 + 1= 6 \\]\n\n\\subsubsection{Sobel Filter}\nNow I can emphasize that each filter utilizes various functionalities described above. The Sobel filter performs a 2-D spatial gradient measurement on an image and so emphasizes regions of high spatial frequency that correspond to edges. Typically it is used to find the approximate absolute gradient magnitude at each point in an input gray scale image. This is how Sobel filter performs on baseline Figure \\ref{fig:sample_vertebrae}.\n\n\\begin{figure}[h] \n\\centering\n\\includegraphics[width=2cm]{images/sample_vertebrae_sobel.jpeg}\n    \\caption {Applied Sobel filter for sample CT scan of vertebrae.}\n    \\label{fig:sobel}\n\\end{figure}\n\nIn general, each edge detector can be either separate convolution operation within special filter and threshold or combination such as: suppressing noise, computing gradient magnitude and direction, applying non-maximum suppression, applying hysteresis thresholding and finally utilizing connectivity analysis to detect edges (Canny Edge Detector).\n\nBy the reason of edge detection is based on derivatives it can easily degrade with variations and noise. But issues which should be considered are size of the neighborhood as well as what exactly represents a transition on the image. \n\n\\subsection{Segmentation Based on Clustering}\nAnother was to approach segmentation is clustering. The obvious question I can ask myself whether I can use clustering techniques to divide images into segments. And the answer is - yes, I can! All it all, the aim is to group objects (instances) into so-called clusters, such that objects in the same cluster are (or, at least, should be) more similar to each other than to the objects belonging to other clusters \\cite{Dhanachandra2017}. \n\nWithin clustering there are multiple algorithms to be issued. Few of them are \nDynamic Time Warping, Hierarchical Agglomerate Clustering and k-Means \\cite{Dhanachandra2017}. Beyond it should be intuition behind what is similarity in terms of clustering, but I will not dig around this part, instead focus on most popular and in the public eye algorithm so called k-Means.  \n\nk-Means algorithm is a common and simple clustering method whereas usually the data set is represented as the a scatter plot in some feature space.\n\nThe Figure \\ref{fig:triangle} and Figure \\ref{fig:clustering} helps to understand how indeed images data can be represented in some feature space. On the Figure  \\ref{fig:clustering} depicted the representation of colored triangle in 3D space, where each dimension represents each color.\n\n\\begin{figure}[h]\n    \\centering\n    \\begin{minipage}[b]{0.4\\textwidth}\n    \\includegraphics[width=\\textwidth]{images/k_mean_triangle.png}\n    \\caption{Colorful triangle.}\n    \\label{fig:triangle}\n    \\end{minipage}\n    \\hfill\n    \\begin{minipage}[b]{0.4\\textwidth}\n    \\includegraphics[width=\\textwidth]{images/k_mean_triangle_clustered.jpg}\n    \\caption{Feature space representation.}\n    \\label{fig:clustering}\n    \\end{minipage}\n\\end{figure}\n\nConsidering k-Means mathematically, given $D \\subseteq D_1 \\times D_2 \\times ... \\times D_m$, a distance measure $d$ (or similarity measure $s$) and the number of clusters $k$, where $k \\ll n$. The goal is to find cluster centers $c_1, c_2, ..., c_k$ and a mapping $p: D \\rightarrow {1, 2, .., k} $ such that \\[ \\sum_{i=1}^{n} d(x_i, c_p_{x_i}) - \\text{is minimal}\\]\n\nThe algorithm itself can be assumed as:\n\\begin{itemize}\n    \\item Initialize $c_1, c_2, ..., c_k$ such that for all $i = {1, 2, .., k}$\n    \\subitem $c_i \\in D$ (random initialization), or\n    \\subitem or $c_i = \\frac{\\sum_{x, p(x) = x^X}}{\\sum_{x, p(x) = x^1}}$\n    \\item compute $p$ such that\n    \\subitem $\\sum_{i=1}^n d(x_i, c_p_{(x_i)})$ is minimal\n    \\item update $c_i$ for all $i = {1,2, ..., k}$ where changed then goto step 2\n    \\item return $p$ and $c_1, c_2, ..., c_k$\n\\end{itemize}\n    \n\nTo demonstrate the method performance I will proceed with the same baseline CT spine Figure \\ref{fig:sample_vertebrae}. As for regressors number (number of clusters) I had chosen $k=3$.  \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=2.5cm]{images/sample_vertebrae_kmeans.png}\n    \\caption {Applied k-Means algorithm for sample CT scan of vertebrae.}\n    \\label{fig:k_menas}\n\\end{figure}\n\nEventually, as it can be noticed on Figure \\ref{fig:k_menas}, clustering is a really \"good to go\" approach for image segmentation, but there are various disadvantages such as tackling with number of clusters, being dependent on initial values, clustering outliers and scaling with number of dimensions.\n\n\\section{Modern Segmentation Methods}\nAt present, I have wrapped up classical-wise methods for image segmentation. There are numerous amount of another techniques as well, but now I would like to narrate about recent techniques which live under umbrella of deep learning family. Before exploring the deep learning methods I have to relate basic mathematical operations, notions and general intuition for neural networks.        \n\n\\subsection{Deep Learning Basics}\nFor simplicity I will represent neuron's mathematical model graphically on Figure \\ref{fig:neuron}. In the mathematical model of the neuron, the body of the neuron, where the input signals accumulates, is denoted by a summarizing neuron. In addition, the biological neuron also has axons and dendrites, which get the inputs and send the outputs. \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=10cm]{images/neuron_math_model.jpeg}\n    \\caption {Mathematical model of neuron.}\n    \\label{fig:neuron}\n\\end{figure} \n\nAccordingly, in our mathematical model of the neuron, we will add inputs and outputs to the summarizing neuron. It is also worth to keep in mind the biological neuron applies some actions with the signals that come into it, namely, it accumulates charge until it reaches some threshold and only after that forwards it further. This is what we will do in the mathematical model of the neuron using the activation functions. Mathematical definition of neuron model is written as:\n\\begin{align*}\ny = f(z) = f(w_0 \\cdot x_0+w_1 \\cdot x_1+w_2 \\cdot x_2+b) = f(\\sum\\limits_{i=0}^{N-1} w_i \\cdot x_i+b) = f(\\langle w, x \\rangle + b),\n\\end{align*}\nwhere: $x_0, x_1, x_2$ - inputs, $w_0, w_1, w_2$ - weights,  $b$ - some bias for increasing non-linearity, $f(z)$ - some activation function. \n\nInputs can be either single number or vector of numbers. As for weights, we mainly should remember they are tuned parameters. Moreover it should be considered 2 potential situations to manage with. \n\nThe first one is initialization of the weights. Here we have multiple options whereas we literally can define them either randomly or apply special initialisation techniques such as 'He' initialization or 'Xavier' initialization and others. \n\nThe second situation we should be aware of is to somehow change the weights during model fitting, meaning weights should be changed in iterative manner from epoch to epoch. To approach it we will apply backpropagation algorithm \\cite{Benvenuto1992}. \n\nConcerning the bias, which is like a weights, meaning tuned parameter, we can consider it allows to shift the activation function by adding a constant to the input of neuron. Hence, the last but not least component is activation function. In simplified terms, activation function is used to determine the output of neuron in a manner: 'yes' or 'no'. It maps the resulting values in range between 0 to 1 or -1 to 1.            \n\n\\subsubsection{Activation Function}\nThere is a significant number of various activation functions. Assuming the very basic one named \"step function\" and figure out from general point of view how it works in both mathematical and geometrical sense.   \nThe \"step function\" is defined as:\n\\begin{align*}\nf(x) = \\begin{cases} 0, & \\mbox{if } x\\mbox{ $\\leq$ 0} \\\\ 1, & \\mbox{if } x\\mbox{ $>$ 0} \\end{cases}\n\\end{align*}\n\nThe function has 2 strongly distinguished values: $0$ and $1$. The place where the function changes it's value from $0$ to $1$ is named as dividing surface \\cite{Apicella2021}. Hence, the dividing surface place is where the argument of activation function is equal $0$.\n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=7cm]{images/step_function.jpeg}\n    \\caption {Geometrical representation of step function.}\n\\end{figure}\n\nThe geometrical representation of step function can be derived as following. There is the neuron formula:\n\\begin{align*}\ny = f(\\langle w, x \\rangle + b)\n\\end{align*}\n\nThe neuron does some linear operation, which is denoted by 2 parameters: $w$ (vector of weights) and $b$ (bias).\nAccordingly, the dividing surface is defined by following equitation which denotes equitation of straight line:\n\\[\\langle w, x \\rangle + b = 0\\]\n\nOn one hand the value of step function is equal $1$ and on the other hand $0$. The activation function is equal $1$ that side of dividing surface where the vector $w$ points out. From geometrical point of view it is represented on Figure \\ref{fig:dividing_surface}.  \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=6cm]{images/dividing_surface.jpeg}\n    \\caption {Sample geometrical representation of dividing surface for single neuron.}\n    \\label{fig:dividing_surface}\n\\end{figure}\n\nAs it was mentioned earlier, there are many more functions. For instance sigmoid activation function showed on Figure \\ref{fig:sigmoid} which unlike step function does not have discontinuity point at zero. \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=10cm]{images/sigmoid_function.jpeg}\n    \\caption {Sigmoid activation function.}\n    \\label{fig:sigmoid}\n\\end{figure}\n\nThe sigmoid activation function formed as:\n\\begin{align*}\n\\sigma(x) = \\dfrac{1}{1+e^x}\n\\end{align*}\n\n\\[ \\sigma(x) = \\begin{cases} 1, & \\mbox{if } x\\mbox{$\\xrightarrow{} + \\infty$} \\\\ 0, & \\mbox{if } x\\mbox{$\\xrightarrow{} - \\infty$} \\end{cases} \\]\n\nOne more activation function is rectified linear activation function \\cite{Eckle2019}. For short it is a piece-wise linear function which outputs input directly if it is positive otherwise outputs zero. It has become the common-wise activation function for many types of neural networks.\n\n\\subsubsection{From Neuron to Neural Network}\nSo far I have covered the properties and functional of just a single neuron, which as a result outcomes a linear divide surface as shown on Figure \\ref{fig:dividing_surface}. Unlike, multiple neurons as shown on Figure \\ref{fig:dividing_surface_2}, meaning when we concatenate the multiple neurons in some architecture we may achieve some nonlinear divide surfaces.\n\n\\begin{figure}[h]\n    \\begin{center}\n        \\includegraphics[width=10cm]{images/neuron_to_neural_net.jpeg}\n        \\caption {Sample geometrical representation of dividing surface for single neuron versus multiple neurons.}\n        \\label{fig:dividing_surface_2}\n    \\end{center}\n\\end{figure}\n\nNow the question is how do we get the nonlinear dividing surface. Simply put, define 3 neurons with linear activation function as shown on Figure \\ref{fig:1_layer_net}. \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=6cm]{images/3_neurons_net.jpeg}\n    \\caption {Sample 1 layer neural net with linear activation functions.}\n    \\label{fig:1_layer_net}\n\\end{figure}\n\nMathematically, results of performing the net can be considered as:\n\\[ y_3 = f(w_2^3 \\cdot y_2+w_1^3 \\cdot y_1+b^3) = \\]\nBy the reason $f$ is simple linear function, equation can be derived as:\n\\[ = w_2^3 \\cdot y_2+w_1^3 \\cdot y_1+b^3 = \\] \n\\[ = w_2^3 \\cdot f(w_2^1\\cdot x_1+w_2^2 \\cdot x_2+b^2) + w_1^3 \\cdot f(w_1^1 \\cdot x_1+w_1^2 \\cdot x_2+b^1) + b^3 = \\]   \n\\[ = w_2^3 \\cdot w_2^1 \\cdot x_1+w_2^3 \\cdot w_2^2 \\cdot x_2+b^2 + w_1^3 \\cdot w_1^1 \\cdot x_1+w_1^3 \\cdot w_1^2 \\cdot x_2+b^1+b^3 = \\]\n\\[ = x_1[w_2^3 \\cdot w_1^2 + w_1^3 \\cdot w_1^1] + x_2[w_2^3 \\cdot w_2^2 + w_1^3 \\cdot w_2^1] + [w_2^3 \\cdot b^2+w_1^3 \\cdot b^1+b^3] = \\]\n\\[ =  x_1\\cdot \\tilde{w_1} + x_2\\cdot \\tilde{w_2} + \\tilde{b} \\]\nMeaning the obtained equitation is just linear combination of inputs into the neural net. \n\n\\subsubsection{Loss function}\nCharacteristically for neural networks, we keen to minimize the error of net predictions. There are many ways (functions) that could be potentially used to estimate an error of a neural network. Usually it comes to make use of so called loss functions or cost functions \\cite{Janocha2016}. Below I considered few popular losses.\n\nMean Squared Error (MSE) is the average of the squared error that is used as the loss function for least squares regression. To streamline, MSE is the sum over all the data points of the square of the difference between the predicted and actual target variables divided by the number of data points. Mathematically, it is defined as:\n\\begin{align*}\n\\text{MSE} = \\frac{{1}}{n} \\sum_{i=1}^{n} (y_i - \\hat{y_i})^2,\n\\end{align*}\nwhere $y$ is the ground truth value, and $\\hat{y_i}$ is neural network prediction.\n\nFrequently, loss functions are utilized in combination with regularization terms \\cite{Chen2019}. The purpose of regularization terms is establish additional rules for penalizing the loss function for errors. Meaning the regularization will manage whether the weights are important (good) or not. One of such regularization techniques is $l2$ regularization or so called weight decay. The definition is as:\n\\[ \\lambda \\cdot \\sum_{i=1}^{n} \\alpha_i^2 \\]\n\nIn terms of mean squared error loss function, the addition of regularization considered as:\n\\[ \\sum_{i=1}^n(\\hat{y}-y_i)^2 + \\lambda \\cdot \\sum_{i=1}^{n} \\alpha_i^2\\]\n\nOne more commonly used function is so called cross-entropy loss or log loss. It measures the performance of a model whose output is a probability value between 0 and 1. Cross-entropy loss increases as the predicted probability diverges from the actual label \\cite{Boudiaf2020}. For discrete probability distributions $p$ and $q$ with the same support $X$ over a given set it is defined as follows:\n\\[H(p,q) = - \\sum_{x \\in X} p(x) \\log q(x), \\]\nwhere $p$ and $q$ are discrete probability distributions. \n\n\\subsubsection{Gradient Descent}\nOptimization of neural net is the key component in terms of training any model. The optimization of the net should be considered as the on-the-spot training. There are variety of optimization algorithms but the pillar algorithm in the list is gradient descent \\cite{Zou2020}.\n\nSuppose a function which is defined by some level lines as shown on Figure \\ref{fig:gradient}. The function has 2 minimums. It worth to understand by distancing from the minimums the function value increases. \nSo far, we have a neural net with some parameters (weights and biases) which outputs some value of loss function (error). As we remember the task is to decrease the value of loss function. Hence, the question is how to achieve that? \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=8cm]{images/gradient_descent.jpeg}\n    \\caption {Sample gradient descent visualization.}\n    \\label{fig:gradient}\n\\end{figure}\n\nWell, the very first provision is as follows. The vector of function surface will be defined by $w_0$, where $w_0$ denotes vector of all weights and biases of the net. It will be represented as: \n\\[ w_0 = [w_1^1, w_1^2,...,w_1^n, w_2^1,...,w_2^n,...,w_n^n, b1^1, b1^2,...,b1^n, b2^1,...,b2^n,...,b_n^n] \\]\n\nAccordingly, we need to take a derivative of loss function (meaning gradient, which is vector, which consists of derivatives per each coordinate of the function). It is performed as:\n\\[ \\delta{f} = \\left[ \\frac{\\partial{f}}{\\partial{w_0}}, \\frac{\\partial{f}}{\\partial{w_1}}, ... ,\\frac{\\partial{f}}{\\partial{w_n}} \\right] \\]\nAs the result, we have calculated the gradient of loss function at the point ($w_0$) where we currently located. The gradient of loss function points out at the direction of greater loss function growth. But, oppositely, we on demand of lower loss function growth, meaning we need to make an opposite step against calculated gradient descent. It can be considered as:\n\\begin{align*}\nw_1 = w_0 - \\alpha \\cdot \\delta{f(w_0)},\n\\end{align*}\nwhere $w_0$ - the initial vector of weights and biases of neural net, $\\alpha$ - parameter for regulating the speed of training of neural net. \n\nThese steps could be performed calculating gradient of $w_n$ vector until it would not converge or reach the stop criteria as:\n\\begin{align*}\nw_n = w_{n-1} - \\alpha \\cdot \\delta{f(w_{n-1})}\n\\end{align*}\n\nAs well, there are different variations of gradient descent within their scopes, pros and cons. Some of them are stochastic gradient descent, batch gradient descent and mini-batch gradient descent. \n\n\\subsection{Convolutional neural networks (CNN)}\nSo far I have wrapped up the very basics behind neural networks fundamentals. Within these basics now I can introduce convolutional neural networks. The cons of such kind of neural networks are that they can perfectly find the latent consistencies within structured data such as images or videos. Using CNNs we can solve various computer vision tasks such as object detection, object localisation, image segmentation or even more complex as face verification and recognition or neural style transfer \\cite{Jing2020}. As Baicen Xiao concluded \\cite{Hosseini2017}, CNNs have\nachieved state-of-the-art performance on a variety of computer vision tasks, particularly visual classification problems, where new algorithms reported to achieve or even surpass the human performance.  \n\nTo present simple distinguish example, suppose, there is an RGB image sized $224 \\cdot 224$ where a dog is located in the middle of image. The goal is to classify whether the dog is on the image. The usual (for instance sigmoid feed forward) neural network will come up with the mask of the dog based on the image. But once new image will be revealed and the dog will not be located in the middle of it, the net will not be able to find and classify the dog. Whilst convolutional neural networks could be generalized independently of the location of the dog, because the convolution itself is invariant operation.         \n\nThere are few more essential properties within CNNs such as pooling, dropout and others, but I'm aim to focus on following architectures and their performance. \n\n\\subsection{Unet}\nThe U-net is convolutional network architecture for fast and precise segmentation of images. It was proposed by Olaf Ronneberger, Philipp Fischer, and Thomas Brox at 2015 \\cite{Ronneberger2015}. \n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=10cm]{images/unet.png}\n    \\caption {Unet architecture.}\n    \\label{fig:unet}\n\\end{figure}\n\nUsing original terminology of the authors \\cite{Ronneberger2015} the net consist of a contracting path (left side) and an expansive path (right side) as shown on Figure \\ref{fig:unet}. The contracting path follows the typical architecture of a convolutional network. In simplified terms it can be considered as downsampling or encoder which formed as\na five repeats of double $3 \\cdot 3$ convolutions (unpadded convolutions) with rectified linear unit and $2 \\cdot 2$ max pooling operation with stride 2. Thus expansive path which can be considered as upsampling or decoder consists of 4 repeats of double $2 \\cdot 2$ convolutions (up-convolution) which halve number of feature channels. In total the network has 23 convolutional layers. \n\nU-net proved itself multiple times and still is one of the main backbone architectures for medical image analysis. As author \\cite{Ahmed2020} observed in his work \"Comparison results of segmentation models using top view person data set\", U-net still remains one of the best ones. Within Table \\ref{tab:classical_versus_modern} it is shown the comparison across classical and modern methods from the original U-net paper \\cite{Ronneberger2015}.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|l|c|c|c|c|c|}\n\\hline\nMethod & Precision & Recall & F1-score & Pixel Accuracy \\\\\n\\hline \\hline\nOtsu & 50\\% & 80\\% & 70\\% & 78\\%  \\\\\n\\hline\nWatershred & 52\\% & 82\\% & 74\\% & 80\\% \\\\\n\\hline\nGaussian mixture-based model & 60\\% & 82\\% & 76\\% & 82\\%  \\\\\n\\hline\nBackground subtraction-based model & 65\\% & 84\\% & 74\\% & 84\\% \\\\\n\\hline\nRE-weighted HOG & 68\\% & 82\\% & 75\\% & 82\\%  \\\\\n\\hline\nFCN & 62\\% & 92\\% & 76\\% & 91\\%  \\\\\n\\hline\nU-net & 74\\% & 92\\% & 81\\% & 92\\% \\\\\n\\hline\nDeepLabV3 & 80\\% & 96\\% & 83\\% & 93\\% \\\\\n\\hline\n\\end{tabular}\n\\caption{Table of comparison \"Classical versus Modern segmentation methods\"}\n\\label{tab:classical_versus_modern}\n\\end{table}\n\n\\subsection{DoubleU-Net}\nThe doubleU-net is enhancement wrapper over U-net, which make the architecture less flexible but more scope-wise related. It consists of 2 U-nets, pretrained (encoder) and 2 non pretrained (decoders) accordingly as shown on Figure \\ref{fig:double_unet}.\n\n\\begin{figure}[h]\n    \\centering \\includegraphics[width=8cm]{images/DoubleU-Net.png}\n    \\caption {DoubleU-Net architecture.}\n    \\label{fig:double_unet}\n\\end{figure}\n\nThe encoder used in the network is pretrained VGG-19, which is trained on ImageNet. Additionally, it uses Atrous Spatial Pyramid Pooling (ASPP). The output from encoder (OUTPUT 1) is represented as binary attention mask which retrieves important and less important pixels denoted as $1$ and $0$ accordingly. The output from decoder (OUTPUT 2) is represented as binary attention mask as well but the results are obtained in a different way. The final output architecture output is a concatenation of OUTPUT 1 and OUTPUT 2.\n\nLooking more closely on Figure \\ref{fig:double_unet}, first network (NETWORK 1) is the use of VGG-19 marked in yellow, ASPP marked in blue, and decoder block marked in light green. The squeeze-and-excite block is used in the encoder of NETWORK 1 and decoder blocks of NETWORK 1 and NETWORK 2. An element-wise multiplication is performed between the output of NETWORK 1 with the input of the same network. The difference between DoubleU-Net and U-Net in the second network (NETWORK 2) is only the use of ASPP and squeeze-and-excite block. All other components remain the same.\n\nAt the original paper \\cite{Jha2020} it was concluded the experimental results shows that doubleU-net achieved a Dice score of $0.7649$ and a mIoU of $0.6255$ what is better in comparison with U-net. \n\n\\section{Summary}\nThe applications of the classical techniques and traditional machine learning methods, such as region growing, edge detection based algorithms and clustering in medical image classification began long ago. However, each certain method has advantages and disadvantages which I had narrated above. \n\nTo sum them up, the performance is far from the practical standard and the developing of them is quite slow in recent years. Likewise, the feature extracting and selection are time-consuming and vary according to different objects. The advent of deep neural networks, especially the CNNs hugely impacted in changing image classification tasks and had achieved significant performance since 2012.\n\nSome research on medical image classification by CNN has achieved performances rivaling human experts. It was perfectly demonstrated in the recent research work \\cite{Anwar2018} that indeed the CNN based methods can achieve highly precise accuracy in various tasks such as classification and segmentation. \n\nAdditionally, as it was emphasised in one of  \\href{https://www.itnonline.com/content/deep-learning-medical-imaging-create-300-million-market-2021}{\\color{blue}\"Image Technology News\"} journal articles: ``Deep learning is a truly transformative technology and the longer-term impact on the radiology market should not be underestimated. It’s more a question of when, not if, machine learning will be routinely used in imaging diagnosis``. \n\n\n", "meta": {"hexsha": "f0b23ea75159fe18050a51754adf06e2b8d1cb13", "size": 33871, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/image_segmentation.tex", "max_stars_repo_name": "KumundzhievMaxim/E-tv-sLor-ndUniversity2021", "max_stars_repo_head_hexsha": "7ba0b4591369615dfc86c2e6797b7660970d067d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-05T13:10:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-05T13:10:03.000Z", "max_issues_repo_path": "chapters/image_segmentation.tex", "max_issues_repo_name": "KumundzhievMaxim/E-tv-sLor-ndUniversity2021", "max_issues_repo_head_hexsha": "7ba0b4591369615dfc86c2e6797b7660970d067d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/image_segmentation.tex", "max_forks_repo_name": "KumundzhievMaxim/E-tv-sLor-ndUniversity2021", "max_forks_repo_head_hexsha": "7ba0b4591369615dfc86c2e6797b7660970d067d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.5093896714, "max_line_length": 622, "alphanum_fraction": 0.7581411827, "num_tokens": 8751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4103220490088027}}
{"text": "\\begin{landscape}\n\\begin{multicols}{2}\n\\chapter{Code Listing}\n\nIn the following section we include the code that implements the unsupervised deep learning models used.\n\n\\begingroup\n\n\\lstset{\n    frame=none,\n    breaklines=true,\n    breakautoindent=true,\n    postbreak={},\n    upquote=true\n}\n\n\\renewcommand{\\thesubsection}{\\arabic{subsection}}\n\n\\renewcommand{\\addcontentsline}[3]{}% Do nothing\n\n\\subsection{Autoencoder}\n\n\\begin{lstlisting}[language=Python]\n\"\"\"\nImplements a simple stacked autoencoder.\n\nHyperparameters to tune:\n------------------------\n- Learning rate\n- Activation function (sigmoid, ReLU, atan)\n- Amount of neurons in each layer\n- Learning function (GradientDescentOptimizer, RMSProp, AdamOptimizer)\n- Batch size\n\"\"\"\n\"\"\"\nImplements a simple stacked autoencoder.\n\nHyperparameters to tune:\n------------------------\n- Learning rate\n- Activation function (sigmoid, ReLU, atan)\n- Amount of neurons in each layer\n- Learning function (GradientDescentOptimizer, RMSProp, AdamOptimizer)\n- Batch size\n\"\"\"\nimport numpy as np\nimport tensorflow as tf\n\nfrom sys import stdout, path\nfrom os import path as ospath\n\nfrom sklearn.preprocessing import MinMaxScaler\n\npath.append(ospath.dirname(ospath.dirname(ospath.abspath(__file__))))\nimport helpers\n\nclass AutoEncoder():\n    \"\"\"\n    Implements an autoencoder that tries to learn a representation for web page traces.\n\n    Atrributes:\n        - activation_func is a tensorflow function, representing the activation function used.\n            *(Often found in `tf.nn`)*\n        - encoder is a computation, representing the encoder layers\n        - decoder is another computtational graph, representing the decoder layers\n        - loss is the operation for the mean squared error (MSE)\n        - train_op is the train operation (`RMSProp`)\n        - layers is a list of integerrs, determining the amount of layers and their size\n        - is_training is a boolean representing whether you are training the autoencoder or not *(used in the batch_norm layer)*.\n        - batch_size\n        - learning_rate\n    \"\"\"\n\n    def __init__(self, layers, batch_size, activation_func=tf.nn.sigmoid, saved_graph=None, sess=None, learning_rate=0.0001, batch_norm=False):\n        \"\"\"\n        @param layers is a list of integers, determining the amount of layers and their size\n            starting with the input size\n        \"\"\"\n        if len(layers) < 2:\n            print(\"Amount of layers must be greater than 1\")\n            exit(0)\n\n        self.batch_size = batch_size\n        self.learning_rate = learning_rate\n        self.activation_func = activation_func\n        self.batch_norm = batch_norm\n\n        self.is_training = True\n\n        # Use this in data preprocessing\n        self.layers = layers\n\n        self._make_graph(layers)\n\n        if saved_graph is not None and sess is not None:\n            self.import_from_file(sess, saved_graph)\n\n    def _make_graph(self, layers):\n        \"\"\"\n        Constructs the computational graph\n\n        @param layers is a list of integers, determining the size of the layers\n        \"\"\"\n        self._init_placeholders(layers[0])\n\n        self.encoder = self._init_encoder(layers)\n        self.decoder = self._init_decoder(layers)\n\n        self._init_train()\n\n    def _init_placeholders(self, first_layer):\n        \"\"\"\n        The main placeholders for input and output data\n        \"\"\"\n        self.encoder_inputs = tf.placeholder(tf.float32, [self.batch_size, first_layer])\n\n        # We could technically use the same value as encoder_inputs but we do not\n        # for future possible extensions\n        self.decoder_targets = tf.placeholder(tf.float32, [self.batch_size, first_layer])\n\n\n    def _get_layer(self, layer_input, size_last_layer, size_current_layer):\n        \"\"\"\n        Returns a layer with a batch normalized input, depending on the `batch_norm flag`\n\n        @param layer_input is the value used as an input to the layer.\n        @param size_last_layer is the size of the last layer (used in weight) or the size of the input\n        @param size_current_layer is the size of the current layer (used in weight and bias)\n        \"\"\"\n        weight = tf.Variable(tf.random_normal([size_last_layer, size_current_layer]))\n        bias = tf.Variable(tf.random_normal([size_current_layer]))\n\n        if not self.batch_norm:\n            return self.activation_func(tf.add(tf.matmul(layer_input, weight), bias))\n\n\n        layer_input = tf.contrib.layers.batch_norm(layer_input,\n                         center=True, scale=True,\n                         is_training=self.is_training,\n                         scope='bn{}-{}'.format(size_last_layer, size_current_layer))\n\n        return self.activation_func(tf.add(tf.matmul(layer_input, weight), bias))\n\n    def _init_encoder(self, layers):\n        \"\"\"\n        Creates the layers of the decoder and returns the last layer.\n        \"\"\"\n        previous_layer = None\n\n        # We don't want to enumerate over the last one\n        for i in range(len(layers) - 1):\n            current_layer = None\n            if previous_layer is None:\n                current_layer = self._get_layer(self.encoder_inputs, layers[i], layers[i + 1])\n            else:\n                current_layer = self._get_layer(previous_layer, layers[i], layers[i + 1])\n\n            previous_layer = current_layer\n\n        # Will be the last layer\n        return previous_layer\n\n    def _init_decoder(self, layers):\n        \"\"\"\n        Creates the decoder graph and returns the last layer\n        \"\"\"\n        previous_layer = None\n\n        # We don't want to enumerate over the last one\n        for i in range(len(layers) - 1, 0, -1):\n            current_layer = None\n            if previous_layer is None:\n                current_layer = self._get_layer(self.encoder, layers[i], layers[i - 1])\n            else:\n                current_layer = self._get_layer(previous_layer, layers[i], layers[i - 1])\n\n            previous_layer = current_layer\n\n        # Will be the last layer\n        return previous_layer\n\n    def _init_train(self):\n        \"\"\"\n        Create the train operation\n        \"\"\"\n        self.loss = tf.reduce_sum(tf.square(self.decoder_targets - self.decoder))\n\n        # Which optimizer to use? `GradientDescentOptimizer`, `AdamOptimizer` or `RMSProp`?\n        self.train_op = tf.train.AdamOptimizer(self.learning_rate).minimize(self.loss)\n\n    def _init_batch_norm(self):\n        \"\"\"\n        Adds a batch normalization layer.\n        \"\"\"\n        self.decoder = tf.contrib.layers.batch_norm(self.decoder,\n                        center=True, scale=True,\n                        is_training=self.is_training,\n                        scope='bn')\n\n    def set_is_training(is_training):\n        \"\"\"\n        Sets the `is_training` class variable, used in th batch normalization layer.\n        If `batch_norm == False`, this does not make a difference but if it is true, this variable should be set to false after training.\n        \"\"\"\n        self.is_training = is_training\n\n    def _process_trace(self, trace, n):\n        \"\"\"\n        Cuts the traces after `n` steps or pads them such that they are of length `n`.\n        \"\"\"\n        features = []\n\n        for packet in trace:\n            # Either positive or negative depending on whether its incoming or outgoing.\n            features.append(packet[0] * packet[1])\n\n            if len(features) == n:\n                break\n\n        for i in range(len(features), n):\n            features.append(0)\n\n        return features\n\n\n    def next_batch(self, batches, in_memory):\n        \"\"\"\n        Returns the next batch in some fixed-length representation.\n        Currently we use Panchenko et al.'s cumulative traces\n\n        @param batches an iterator with all of the batches (\n            if in_memory == True:\n                in batch-major form without padding\n            else:\n                A list of paths to the files\n        )\n        @param in_memory is a boolean value\n\n        @return if in_memory is False, returns a tuple of (dict, [paths]) where paths is a list of paths for each batch\n            else it returns a dict for training\n        \"\"\"\n        batch = next(batches)\n        data_batch = batch\n\n        if not in_memory:\n            data_batch = [helpers.read_cell_file(path) for path in batch]\n\n        data_batch = [self._process_trace(trace, self.layers[0]) for trace in data_batch]\n\n        min_max_scaler = MinMaxScaler()\n        data_batch = min_max_scaler.fit_transform(data_batch)\n\n        encoder_inputs_ = data_batch\n        decoder_targets_ = data_batch\n\n        train_dict = {\n            self.encoder_inputs: encoder_inputs_,\n            self.decoder_targets: decoder_targets_,\n        }\n\n        if not in_memory:\n            return (train_dict, batch)\n        return train_dict\n\n    def save(self, sess, file_name):\n        \"\"\"\n        Save the model in a file\n\n        @param sess is the session\n        @param file_name is the file name without the extension\n        \"\"\"\n        saver = tf.train.Saver()\n        saver.save(sess, file_name)\n\n    def import_from_file(self, sess, file_name):\n        \"\"\"\n        Imports the graph from a file\n\n        @param sess is the session\n        @param file_name is a string that represents the file name\n            without the extension\n        \"\"\"\n\n        # Get the graph\n        saver = tf.train.Saver()\n\n        # Restore the variables\n        saver.restore(sess, file_name)\n\n\n\ndef train_on_copy_task(sess, model, data,\n                       batch_size=100,\n                       max_batches=None,\n                       batches_in_epoch=1000,\n                       verbose=False):\n    \"\"\"\n    Train the `AutoEncoder` on a copy task\n\n    @param sess is a tensorflow session\n    @param model is the autoencoder model\n    @param data is the data (in batch-major form and not padded or a list of files (depending on `in_memory`))\n    \"\"\"\n    batches = helpers.get_batches(data, batch_size=batch_size)\n\n    loss_track = []\n\n    batches_in_data = len(data) // batch_size\n    if max_batches is None or batches_in_data < max_batches:\n        max_batches = batches_in_data - 1\n\n    try:\n        for batch in range(max_batches):\n            print(\"Batch {}/{}\".format(batch, max_batches))\n            fd, _ = model.next_batch(batches, False)\n            _, l = sess.run([model.train_op, model.loss], fd)\n\n            loss_track.append(l)\n\n            if batch == 0 or batch % batches_in_epoch == 0:\n                model.save(sess, 'autoencoder_model')\n                helpers.save_object(loss_track, 'loss_track.pkl')\n\n                if verbose:\n                    stdout.write('  minibatch loss: {}\\n'.format(sess.run(model.loss, fd)))\n                    predict_ = sess.run(model.decoder_outputs, fd)\n                    for i, (inp, pred) in enumerate(zip(fd[model.encoder_inputs].swapaxes(0, 1), predict_.swapaxes(0, 1))):\n                        stdout.write('  sample {}:\\n'.format(i + 1))\n                        stdout.write('    input     > {}\\n'.format(inp))\n                        stdout.write('    predicted > {}\\n'.format(pred))\n                        if i >= 0:\n                            break\n                    stdout.write('\\n')\n\n    except KeyboardInterrupt:\n        stdout.write('training interrupted')\n        model.save(sess, 'autoencoder_model')\n        exit(0)\n\n    model.save(sess, 'autoencoder_model')\n    helpers.save_object(loss_track, 'loss_track.pkl')\n\n    return loss_track\n\ndef get_vector_representations(sess, model, data, save_dir,\n                       batch_size=100,\n                       max_batches=None,\n                       batches_in_epoch=1000,\n                       extension=\".cell\"):\n    \"\"\"\n    Given a trained model, gets a vector representation for the traces in batch\n\n    @param sess is a tensorflow session\n    @param model is the autoencoder model\n    @param data is the data (in batch-major form and not padded or a list of files (depending on `in_memory`))\n    \"\"\"\n    batches = helpers.get_batches(data, batch_size=batch_size)\n\n    batches_in_data = len(data) // batch_size\n    if max_batches is None or batches_in_data < max_batches:\n        max_batches = batches_in_data - 1\n\n    try:\n        for batch in range(max_batches):\n            print(\"Batch {}/{}\".format(batch, max_batches))\n            fd, paths = model.next_batch(batches, False)\n            l = sess.run(model.encoder, fd)\n\n            file_names = [helpers.extract_filename_from_path(path, extension) for path in paths]\n\n            for file_name, features in zip(file_names, list(l)):\n                helpers.write_to_file(features, save_dir, file_name, new_extension=\".cellf\")\n\n    except KeyboardInterrupt:\n        stdout.write('Interrupted')\n        exit(0)\n\n    return results\n\n\\end{lstlisting}\n\n\\subsection{Sequence-to-sequence model}\n\n\\begin{lstlisting}[language=Python]\n\"\"\"\nThis file implements a RNN encoder-decoder model (also known as sequence-to-sequence models).\n\nWe made the choice not to implement an attention mechanism (which means that the decoder is allowed to have a 'peak' at the input).\nThe reason why is because we are not trying to maximize the output of the decoder but instead the feature selection process.\n(http://suriyadeepan.github.io/2016-06-28-easy-seq2seq/)\n\nWe will use batch-major rather than time-major even though time-major is slightly more efficient\nsince it makes the feature extraction process a lot easier.\n\nWe will not be using bucketing because traces of the same webpage will have the same length.\nTherefore every batch, we will most likely be training the seq2seq model on one webpage\n\n! Does encoder share weights with decoder or not (Less computation vs natural (https://arxiv.org/pdf/1409.3215.pdf))\n! Reverse traces (https://arxiv.org/pdf/1409.3215.pdf)\n\nHyperparameters to tune:\n------------------------\n- Learning rate\n- Which cell to use (GRU vs LSTM) or a deep RNN architecture using `MultiRNNCell`\n- Reversing traces\n- Bidirectional encoder\n- Other objective functions (such as MSE,...)\n- Amount of encoder and decoder hidden states\n\"\"\"\nimport numpy as np\nimport tensorflow as tf\n\nfrom sys import stdout, path\nfrom os import path as ospath\n\nfrom tensorflow.contrib.rnn import LSTMStateTuple\n\npath.append(ospath.dirname(ospath.dirname(ospath.abspath(__file__))))\nimport helpers\n\n\nclass Seq2SeqModel():\n    \"\"\"\n    Implements a sequence to sequence model for real values\n\n    Attributes:\n        - encoder_cell is the cell that will be used for encoding\n            (Should be part of `tf.nn.rnn_cell`)\n        - decoder cell is the cell used for decoding\n            (Should be part of `tf.nn.rnn_cell`)\n\n        - seq_width shows how many features each input in the sequence has\n            (For website fingerprinting this is only 2 (packet_size, incoming))\n        - batch_size\n\n        - bidirectional is a boolean value that determines whether the encoder is bidirectional or not\n        - reverse is also a boolean value that when if true, reversed the traces for training\n    \"\"\"\n\n    def __init__(self, encoder_cell, decoder_cell, seq_width, batch_size=100, bidirectional=False, reverse=False, saved_graph=None, sess=None, learning_rate=0.0006):\n        \"\"\"\n        @param saved_graph is a string, representing the path to the saved graph\n        \"\"\"\n        # Constants\n        self.PAD = 0\n        self.EOS = -1\n\n        self.reverse = reverse\n        self.seq_width = seq_width\n        self.batch_size = batch_size\n        self.learning_rate = learning_rate\n\n        self.bidirectional = bidirectional\n\n        self.encoder_cell = encoder_cell\n        self.decoder_cell = decoder_cell\n\n        self._make_graph()\n\n        if saved_graph is not None and sess is not None:\n            self.import_from_file(sess, saved_graph)\n\n    def _make_graph(self):\n        \"\"\"\n        Construct the graph\n        \"\"\"\n\n        self._init_placeholders()\n\n        self._init_encoder()\n        self._init_decoder()\n\n        self._init_train()\n\n    def _init_placeholders(self):\n        \"\"\"\n        The main placeholders used for the input data, and output\n        \"\"\"\n        # The usual format is: `[self.batch_size, max_sequence_length, self.seq_width]`\n        # But we define `max_sequence_length` as None to make it dynamic so we only need to pad\n        # each batch to the maximum sequence length\n        self.encoder_inputs = tf.placeholder(tf.float32,\n            [self.batch_size, None, self.seq_width])\n\n        self.encoder_inputs_length = tf.placeholder(tf.int32, [self.batch_size])\n\n        self.decoder_targets = tf.placeholder(tf.float32,\n            [self.batch_size, None, self.seq_width])\n\n    def _init_encoder(self):\n        \"\"\"\n        Creates the encoder attributes\n\n        Attributes:\n            - encoder_outputs is shaped [max_sequence_length, batch_size, seq_width]\n                (since time-major == True)\n            - encoder_final_state is shaped [batch_size, encoder_cell.state_size]\n        \"\"\"\n        if not self.bidirectional:\n            with tf.variable_scope('Encoder') as scope:\n                self.encoder_outputs, self.encoder_final_state = tf.nn.dynamic_rnn(\n                    cell=self.encoder_cell,\n                    dtype=tf.float32,\n                    sequence_length=self.encoder_inputs_length,\n                    inputs=self.encoder_inputs,\n                    time_major=False)\n        else:\n            ((encoder_fw_outputs,\n              encoder_bw_outputs),\n             (encoder_fw_final_state,\n              encoder_bw_final_state)) = (\n                tf.nn.bidirectional_dynamic_rnn(cell_fw=self.encoder_cell,\n                    cell_bw=self.encoder_cell,\n                    inputs=self.encoder_inputs,\n                    sequence_length=self.encoder_inputs_length,\n                    dtype=tf.float32, time_major=False)\n                )\n\n            self.encoder_outputs = tf.concat((encoder_fw_outputs, encoder_bw_outputs), 2)\n\n            if isinstance(encoder_fw_final_state, LSTMStateTuple):\n                encoder_final_state_c = tf.concat(\n                    (encoder_fw_final_state.c, encoder_bw_final_state.c), 1)\n\n                encoder_final_state_h = tf.concat(\n                    (encoder_fw_final_state.h, encoder_bw_final_state.h), 1)\n\n                self.encoder_final_state = LSTMStateTuple(\n                    c=encoder_final_state_c,\n                    h=encoder_final_state_h\n                )\n\n            else:\n                self.encoder_final_state = tf.concat(\n                    (encoder_fw_final_state, encoder_bw_final_state), 1)\n\n    def _init_decoder(self):\n        \"\"\"\n        Creates decoder attributes.\n        We cannot simply use a dynamic_rnn since we are feeding the outputs of the\n        decoder back into the inputs.\n        Therefore we use a raw_rnn and emulate a dynamic_rnn with this behavior.\n        (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/rnn.py)\n        \"\"\"\n        # EOS token added\n        self.decoder_inputs_length = self.encoder_inputs_length + 1\n\n        def loop_fn_initial(time, cell_output, cell_state, loop_state):\n            elements_finished = (time >= self.decoder_inputs_length)\n\n            # EOS token (0 + self.EOS)\n            initial_input = tf.zeros([self.batch_size, self.decoder_cell.output_size], dtype=tf.float32) + self.EOS\n            initial_cell_state = self.encoder_final_state\n            initial_loop_state = None  # we don't need to pass any additional information\n\n            return (elements_finished,\n                    initial_input,\n                    initial_cell_state,\n                    None,  # cell output is dummy here\n                    initial_loop_state)\n\n        def loop_fn(time, cell_output, cell_state, loop_state):\n            if cell_output is None:  # time == 0\n                return loop_fn_initial(time, cell_output, cell_state, loop_state)\n\n            cell_output.set_shape([self.batch_size, self.decoder_cell.output_size])\n\n            emit_output = cell_output\n\n            next_cell_state = cell_state\n\n            elements_finished = (time >= self.decoder_inputs_length)\n            finished = tf.reduce_all(elements_finished)\n\n            next_input = tf.cond(\n                finished,\n                lambda: tf.zeros([self.batch_size, self.decoder_cell.output_size], dtype=tf.float32), # self.PAD\n                lambda: cell_output # Use the input from the previous cell\n            )\n\n            next_loop_state = None\n\n            return (\n                elements_finished,\n                next_input,\n                next_cell_state,\n                emit_output,\n                next_loop_state\n            )\n\n        decoder_outputs_ta, decoder_final_state, _ = tf.nn.raw_rnn(self.decoder_cell, loop_fn)\n        self.decoder_outputs = decoder_outputs_ta.stack()\n        self.decoder_outputs = tf.transpose(self.decoder_outputs, [1, 0, 2])\n\n        with tf.variable_scope('DecoderOutputProjection') as scope:\n            self.decoder_outputs = self.projection(self.decoder_outputs, self.seq_width, scope)\n\n    def _init_train(self):\n        self.loss = tf.reduce_sum(tf.square(self.decoder_targets - self.decoder_outputs))\n\n        # Which optimizer to use? `GradientDescentOptimizer`, `AdamOptimizer` or `RMSProp`?\n        self.train_op = tf.train.AdamOptimizer(self.learning_rate).minimize(self.loss)\n\n    def projection(self, inputs, projection_size, scope):\n        \"\"\"\n        Projects the input with a known amount of features to a `projection_size amount of features`\n\n        @param inputs is shaped like [time, batch, input_size] or [batch, input_size]\n        @param projection_size int32\n        @param scope outer variable scope\n        \"\"\"\n        input_size = inputs.get_shape()[-1].value\n\n        with tf.variable_scope(scope) as scope:\n            W = tf.get_variable(name='W', shape=[input_size, projection_size],\n                                dtype=tf.float32)\n\n            b = tf.get_variable(name='b', shape=[projection_size],\n                                dtype=tf.float32,\n                                initializer=tf.constant_initializer(0, dtype=tf.float32))\n\n        input_shape = tf.unstack(tf.shape(inputs))\n\n        if len(input_shape) == 3:\n            time, batch, _ = input_shape  # dynamic parts of shape\n            inputs = tf.reshape(inputs, [-1, input_size])\n\n        elif len(input_shape) == 2:\n            batch, _depth = input_shape\n\n        else:\n            raise ValueError(\"Weird input shape: {}\".format(inputs))\n\n        linear = tf.add(tf.matmul(inputs, W), b)\n\n        if len(input_shape) == 3:\n            linear = tf.reshape(linear, [time, batch, projection_size])\n\n        return linear\n\n    def next_batch(self, batches, in_memory, max_time_diff=float(\"inf\")):\n        \"\"\"\n        Returns the next batch.\n\n        @param batches an iterator with all of the batches (\n            if in_memory == True:\n                in batch-major form without padding\n            else:\n                A list of paths to the files\n        )\n        @param in_memory is a boolean value\n        @param max_time_diff **(should only be defined if `in_memory == False`)**\n            specifies what the maximum time different between the first packet in the trace and the last one should be\n\n        @return if in_memory is False, returns a tuple of (dict, [paths], max_length) where paths is a list of paths for each batch\n            else it returns a dict for training\n        \"\"\"\n        batch = next(batches)\n        data_batch = batch\n\n        if not in_memory:\n            data_batch = [helpers.read_cell_file(path, max_time_diff=max_time_diff) for path in batch]\n            for i, cell in enumerate(data_batch):\n                data_batch[i] = [packet[0] * packet[1] for packet in cell]\n\n        data_batch, encoder_input_lengths_ = helpers.pad_traces(data_batch, reverse=self.reverse, seq_width=self.seq_width)\n        encoder_inputs_ = data_batch\n\n        decoder_targets_ = helpers.add_EOS(data_batch, encoder_input_lengths_)\n\n        train_dict = {\n            self.encoder_inputs: encoder_inputs_,\n            self.encoder_inputs_length: encoder_input_lengths_,\n            self.decoder_targets: decoder_targets_,\n        }\n\n        if not in_memory:\n            return (train_dict, batch, max(encoder_input_lengths_))\n        return train_dict\n\n    def save(self, sess, file_name):\n        \"\"\"\n        Save the model in a file\n\n        @param sess is the session\n        @param file_name is the file name without the extension\n        \"\"\"\n        saver = tf.train.Saver()\n        saver.save(sess, file_name)\n        # saver.export_meta_graph(filename=file_name + '.meta')\n\n    def import_from_file(self, sess, file_name):\n        \"\"\"\n        Imports the graph from a file\n\n        @param sess is the session\n        @param file_name is a string that represents the file name\n            without the extension\n        \"\"\"\n\n        # Get the graph\n        saver = tf.train.Saver()\n\n        # Restore the variables\n        saver.restore(sess, file_name)\n\n\ndef train_on_copy_task(sess, model, data,\n                       batch_size=100,\n                       max_batches=None,\n                       batches_in_epoch=1000,\n                       max_time_diff=float(\"inf\"),\n                       verbose=False):\n    \"\"\"\n    Train the `Seq2SeqModel` on a copy task\n\n    @param sess is a tensorflow session\n    @param model is the seq2seq model\n    @param data is the data (in batch-major form and not padded or a list of files (depending on `in_memory`))\n    \"\"\"\n    batches = helpers.get_batches(data, batch_size=batch_size)\n\n    loss_track = []\n\n    batches_in_data = len(data) // batch_size\n    if max_batches is None or batches_in_data < max_batches:\n        max_batches = batches_in_data - 1\n\n    try:\n        for batch in range(max_batches):\n            print(\"Batch {}/{}\".format(batch, max_batches))\n            fd, _, length = model.next_batch(batches, False, max_time_diff)\n            _, l = sess.run([model.train_op, model.loss], fd)\n            loss_track.append(l / length)\n\n            if batch == 0 or batch % batches_in_epoch == 0:\n                model.save(sess, 'seq2seq_model')\n                helpers.save_object(loss_track, 'loss_track.pkl')\n\n                if verbose:\n                    stdout.write('  minibatch loss: {}\\n'.format(sess.run(model.loss, fd)))\n                    predict_ = sess.run(model.decoder_outputs, fd)\n                    for i, (inp, pred) in enumerate(zip(fd[model.encoder_inputs].swapaxes(0, 1), predict_.swapaxes(0, 1))):\n                        stdout.write('  sample {}:\\n'.format(i + 1))\n                        stdout.write('    input     > {}\\n'.format(inp))\n                        stdout.write('    predicted > {}\\n'.format(pred))\n                        if i >= 0:\n                            break\n                    stdout.write('\\n')\n\n    except KeyboardInterrupt:\n        stdout.write('training interrupted')\n        model.save(sess, 'seq2seq_model')\n        exit(0)\n\n    model.save(sess, 'seq2seq_model')\n    helpers.save_object(loss_track, 'loss_track.pkl')\n\n    return loss_track\n\ndef get_vector_representations(sess, model, data, save_dir,\n                       batch_size=100,\n                       max_batches=None,\n                       batches_in_epoch=1000,\n                       max_time_diff=float(\"inf\"),\n                       extension=\".cell\"):\n    \"\"\"\n    Given a trained model, gets a vector representation for the traces in batch\n\n    @param sess is a tensorflow session\n    @param model is the seq2seq model\n    @param data is the data (in batch-major form and not padded or a list of files (depending on `in_memory`))\n    \"\"\"\n    batches = helpers.get_batches(data, batch_size=batch_size)\n\n    batches_in_data = len(data) // batch_size\n    if max_batches is None or batches_in_data < max_batches:\n        max_batches = batches_in_data - 1\n\n    try:\n        for batch in range(max_batches):\n            print(\"Batch {}/{}\".format(batch, max_batches))\n            fd, paths, _ = model.next_batch(batches, False, max_time_diff)\n            l = sess.run(model.encoder_final_state, fd)\n\n            # Returns a tuple, so we concatenate\n            if isinstance(l, LSTMStateTuple):\n                l = np.concatenate((l.c, l.h), axis=1)\n\n            file_names = [helpers.extract_filename_from_path(path, extension) for path in paths]\n\n            for file_name, features in zip(file_names, list(l)):\n                helpers.write_to_file(features, save_dir, file_name, new_extension=\".cellf\")\n\n    except KeyboardInterrupt:\n        stdout.write('Interrupted')\n        exit(0)\n\\end{lstlisting}\n\n\\subsection{Batch-normalized LSTM cell}\n\n\\begin{lstlisting}[language=Python]\n\"\"\"\nImplements batch normalized LSTM cells described in https://arxiv.org/pdf/1510.01378.pdf.\n\"\"\"\n\nfrom tensorflow.contrib.rnn import LSTMCell, LSTMStateTuple\n\nfrom tensorflow.python.framework import ops\nfrom tensorflow.python.framework import tensor_shape\nfrom tensorflow.python.framework import tensor_util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import clip_ops\nfrom tensorflow.python.ops import embedding_ops\nfrom tensorflow.python.ops import init_ops\nfrom tensorflow.python.ops import math_ops\nfrom tensorflow.python.ops import nn_ops\nfrom tensorflow.python.ops import partitioned_variables\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.ops import variable_scope as vs\n\nfrom tensorflow.python.ops.math_ops import sigmoid\nfrom tensorflow.python.ops.math_ops import tanh\nfrom tensorflow.python.ops.rnn_cell_impl import _RNNCell as RNNCell\n\nfrom tensorflow.python.platform import tf_logging as logging\nfrom tensorflow.python.util import nest\n\nfrom tensorflow.contrib.layers import batch_norm\n\nimport contextlib\n\n_BIAS_VARIABLE_NAME = \"biases\"\n_WEIGHTS_VARIABLE_NAME = \"weights\"\n\n@contextlib.contextmanager\ndef _checked_scope(cell, scope, reuse=None, **kwargs):\n  if reuse is not None:\n    kwargs[\"reuse\"] = reuse\n  with vs.variable_scope(scope, **kwargs) as checking_scope:\n    scope_name = checking_scope.name\n    if hasattr(cell, \"_scope\"):\n      cell_scope = cell._scope  # pylint: disable=protected-access\n      if cell_scope.name != checking_scope.name:\n        raise ValueError(\n            \"Attempt to reuse RNNCell %s with a different variable scope than \"\n            \"its first use.  First use of cell was with scope '%s', this \"\n            \"attempt is with scope '%s'.  Please create a new instance of the \"\n            \"cell if you would like it to use a different set of weights.  \"\n            \"If before you were using: MultiRNNCell([%s(...)] * num_layers), \"\n            \"change to: MultiRNNCell([%s(...) for _ in range(num_layers)]).  \"\n            \"If before you were using the same cell instance as both the \"\n            \"forward and reverse cell of a bidirectional RNN, simply create \"\n            \"two instances (one for forward, one for reverse).  \"\n            \"In May 2017, we will start transitioning this cell's behavior \"\n            \"to use existing stored weights, if any, when it is called \"\n            \"with scope=None (which can lead to silent model degradation, so \"\n            \"this error will remain until then.)\"\n            % (cell, cell_scope.name, scope_name, type(cell).__name__,\n               type(cell).__name__))\n    else:\n      weights_found = False\n      try:\n        with vs.variable_scope(checking_scope, reuse=True):\n          vs.get_variable(_WEIGHTS_VARIABLE_NAME)\n        weights_found = True\n      except ValueError:\n        pass\n      if weights_found and reuse is None:\n        raise ValueError(\n            \"Attempt to have a second RNNCell use the weights of a variable \"\n            \"scope that already has weights: '%s'; and the cell was not \"\n            \"constructed as %s(..., reuse=True).  \"\n            \"To share the weights of an RNNCell, simply \"\n            \"reuse it in your second calculation, or create a new one with \"\n            \"the argument reuse=True.\" % (scope_name, type(cell).__name__))\n\n    # Everything is OK.  Update the cell's scope and yield it.\n    cell._scope = checking_scope  # pylint: disable=protected-access\n    yield checking_scope\n\nclass BNLSTMCell(LSTMCell):\n  \"\"\"Long short-term memory unit (LSTM) recurrent network cell.\n  The default non-peephole implementation is based on:\n    http://deeplearning.cs.cmu.edu/pdfs/Hochreiter97_lstm.pdf\n  S. Hochreiter and J. Schmidhuber.\n  \"Long Short-Term Memory\". Neural Computation, 9(8):1735-1780, 1997.\n  The peephole implementation is based on:\n    https://research.google.com/pubs/archive/43905.pdf\n  Hasim Sak, Andrew Senior, and Francoise Beaufays.\n  \"Long short-term memory recurrent neural network architectures for\n   large scale acoustic modeling.\" INTERSPEECH, 2014.\n  The class uses optional peep-hole connections, optional cell clipping, and\n  an optional projection layer.\n  \"\"\"\n\n  def __init__(self, num_units, input_size=None,\n               use_peepholes=False, cell_clip=None,\n               initializer=None, num_proj=None, proj_clip=None,\n               num_unit_shards=None, num_proj_shards=None,\n               forget_bias=1.0, state_is_tuple=True,\n               activation=tanh, is_training=True, batch_norm=True):\n    \"\"\"Initialize the parameters for an LSTM cell.\n    Args:\n      num_units: int, The number of units in the LSTM cell\n      input_size: Deprecated and unused.\n      use_peepholes: bool, set True to enable diagonal/peephole connections.\n      cell_clip: (optional) A float value, if provided the cell state is clipped\n        by this value prior to the cell output activation.\n      initializer: (optional) The initializer to use for the weight and\n        projection matrices.\n      num_proj: (optional) int, The output dimensionality for the projection\n        matrices.  If None, no projection is performed.\n      proj_clip: (optional) A float value.  If `num_proj > 0` and `proj_clip` is\n        provided, then the projected values are clipped elementwise to within\n        `[-proj_clip, proj_clip]`.\n      num_unit_shards: Deprecated, will be removed by Jan. 2017.\n        Use a variable_scope partitioner instead.\n      num_proj_shards: Deprecated, will be removed by Jan. 2017.\n        Use a variable_scope partitioner instead.\n      forget_bias: Biases of the forget gate are initialized by default to 1\n        in order to reduce the scale of forgetting at the beginning of\n        the training.\n      state_is_tuple: If True, accepted and returned states are 2-tuples of\n        the `c_state` and `m_state`.  If False, they are concatenated\n        along the column axis.  This latter behavior will soon be deprecated.\n      activation: Activation function of the inner states.\n      is_training: Python boolean describing whether or not you are currently\n        training. Should only be changed if `batch_norm == True`\n      batch_norm: Python boolean that indicated whether or not the cell is\n        batch normalized\n    \"\"\"\n    self._is_training = is_training\n    self._batch_norm = batch_norm\n\n    super().__init__(num_units, input_size=input_size,\n                 use_peepholes=use_peepholes, cell_clip=cell_clip,\n                 initializer=initializer, num_proj=num_proj, proj_clip=proj_clip,\n                 num_unit_shards=num_unit_shards, num_proj_shards=num_proj_shards,\n                 forget_bias=forget_bias, state_is_tuple=state_is_tuple,\n                 activation=activation)\n\n\n  def __call__(self, inputs, state, scope=None):\n    \"\"\"Run one step of LSTM.\n    Args:\n      inputs: input Tensor, 2D, batch x num_units.\n      state: if `state_is_tuple` is False, this must be a state Tensor,\n        `2-D, batch x state_size`.  If `state_is_tuple` is True, this must be a\n        tuple of state Tensors, both `2-D`, with column sizes `c_state` and\n        `m_state`.\n      scope: VariableScope for the created subgraph; defaults to \"lstm_cell\".\n    Returns:\n      A tuple containing:\n      - A `2-D, [batch x output_dim]`, Tensor representing the output of the\n        LSTM after reading `inputs` when previous state was `state`.\n        Here output_dim is:\n           num_proj if num_proj was set,\n           num_units otherwise.\n      - Tensor(s) representing the new state of LSTM after reading `inputs` when\n        the previous state was `state`.  Same type and shape(s) as `state`.\n    Raises:\n      ValueError: If input size cannot be inferred from inputs via\n        static shape inference.\n    \"\"\"\n    num_proj = self._num_units if self._num_proj is None else self._num_proj\n\n    if self._state_is_tuple:\n      (c_prev, m_prev) = state\n    else:\n      c_prev = array_ops.slice(state, [0, 0], [-1, self._num_units])\n      m_prev = array_ops.slice(state, [0, self._num_units], [-1, num_proj])\n\n    dtype = inputs.dtype\n    input_size = inputs.get_shape().with_rank(2)[1]\n    if input_size.value is None:\n      raise ValueError(\"Could not infer input size from inputs.get_shape()[-1]\")\n    with _checked_scope(self, scope or \"lstm_cell\",\n                        initializer=self._initializer) as unit_scope:\n      if self._num_unit_shards is not None:\n        unit_scope.set_partitioner(\n            partitioned_variables.fixed_size_partitioner(\n                self._num_unit_shards))\n      # i = input_gate, j = new_input, f = forget_gate, o = output_gate\n      lstm_matrix = _linear([inputs, m_prev], 4 * self._num_units, bias=True)\n      i, j, f, o = array_ops.split(\n          value=lstm_matrix, num_or_size_splits=4, axis=1)\n      # Diagonal connections\n      if self._use_peepholes:\n        with vs.variable_scope(unit_scope) as projection_scope:\n          if self._num_unit_shards is not None:\n            projection_scope.set_partitioner(None)\n          w_f_diag = vs.get_variable(\n              \"w_f_diag\", shape=[self._num_units], dtype=dtype)\n          w_i_diag = vs.get_variable(\n              \"w_i_diag\", shape=[self._num_units], dtype=dtype)\n          w_o_diag = vs.get_variable(\n              \"w_o_diag\", shape=[self._num_units], dtype=dtype)\n\n      if self._use_peepholes:\n        res = (sigmoid(f + self._forget_bias + w_f_diag * c_prev) * c_prev +\n             sigmoid(i + w_i_diag * c_prev) * self._activation(j))\n        if self._batch_norm:\n          c = batch_norm(res,\n                         center=True, scale=True,\n                         is_training=self._is_training,\n                         scope='bn')\n        else:\n          c = res\n      else:\n        res = (sigmoid(f + self._forget_bias) * c_prev + sigmoid(i) *\n             self._activation(j))\n        if self._batch_norm:\n          c = batch_norm(res,\n                         center=True, scale=True,\n                         is_training=self._is_training,\n                         scope='bn')\n        else:\n          c = res\n\n      if self._cell_clip is not None:\n        # pylint: disable=invalid-unary-operand-type\n        c = clip_ops.clip_by_value(c, -self._cell_clip, self._cell_clip)\n        # pylint: enable=invalid-unary-operand-type\n      if self._use_peepholes:\n        m = sigmoid(o + w_o_diag * c) * self._activation(c)\n      else:\n        m = sigmoid(o) * self._activation(c)\n\n      if self._num_proj is not None:\n        with vs.variable_scope(\"projection\") as proj_scope:\n          if self._num_proj_shards is not None:\n            proj_scope.set_partitioner(\n                partitioned_variables.fixed_size_partitioner(\n                    self._num_proj_shards))\n          m = _linear(m, self._num_proj, bias=False)\n\n        if self._proj_clip is not None:\n          # pylint: disable=invalid-unary-operand-type\n          m = clip_ops.clip_by_value(m, -self._proj_clip, self._proj_clip)\n          # pylint: enable=invalid-unary-operand-type\n\n    new_state = (LSTMStateTuple(c, m) if self._state_is_tuple else\n                 array_ops.concat([c, m], 1))\n    return m, new_state\n\ndef _linear(args, output_size, bias, bias_start=0.0):\n  \"\"\"Linear map: sum_i(args[i] * W[i]), where W[i] is a variable.\n  Args:\n    args: a 2D Tensor or a list of 2D, batch x n, Tensors.\n    output_size: int, second dimension of W[i].\n    bias: boolean, whether to add a bias term or not.\n    bias_start: starting value to initialize the bias; 0 by default.\n  Returns:\n    A 2D Tensor with shape [batch x output_size] equal to\n    sum_i(args[i] * W[i]), where W[i]s are newly created matrices.\n  Raises:\n    ValueError: if some of the arguments has unspecified or wrong shape.\n  \"\"\"\n  if args is None or (nest.is_sequence(args) and not args):\n    raise ValueError(\"`args` must be specified\")\n  if not nest.is_sequence(args):\n    args = [args]\n\n  # Calculate the total size of arguments on dimension 1.\n  total_arg_size = 0\n  shapes = [a.get_shape() for a in args]\n  for shape in shapes:\n    if shape.ndims != 2:\n      raise ValueError(\"linear is expecting 2D arguments: %s\" % shapes)\n    if shape[1].value is None:\n      raise ValueError(\"linear expects shape[1] to be provided for shape %s, \"\n                       \"but saw %s\" % (shape, shape[1]))\n    else:\n      total_arg_size += shape[1].value\n\n  dtype = [a.dtype for a in args][0]\n\n  # Now the computation.\n  scope = vs.get_variable_scope()\n  with vs.variable_scope(scope) as outer_scope:\n    weights = vs.get_variable(\n        _WEIGHTS_VARIABLE_NAME, [total_arg_size, output_size], dtype=dtype)\n    if len(args) == 1:\n      res = math_ops.matmul(args[0], weights)\n    else:\n      res = math_ops.matmul(array_ops.concat(args, 1), weights)\n    if not bias:\n      return res\n    with vs.variable_scope(outer_scope) as inner_scope:\n      inner_scope.set_partitioner(None)\n      biases = vs.get_variable(\n          _BIAS_VARIABLE_NAME, [output_size],\n          dtype=dtype,\n          initializer=init_ops.constant_initializer(bias_start, dtype=dtype))\n    return nn_ops.bias_add(res, biases)\n\\end{lstlisting}\n\n\\subsection{Batch-normalized GRU cell}\n\\begin{lstlisting}[language=Python]\n\"\"\"\nImplements a batch normalized GRU cell.\nUnfortunately, there aren't any research papers that examine how to exactly implement this.\n\nBut most of it is based on https://arxiv.org/pdf/1510.01378.pdf\n\"\"\"\n\nfrom tensorflow.contrib.rnn import GRUCell\n\nfrom tensorflow.python.framework import ops\nfrom tensorflow.python.framework import tensor_shape\nfrom tensorflow.python.framework import tensor_util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import clip_ops\nfrom tensorflow.python.ops import embedding_ops\nfrom tensorflow.python.ops import init_ops\nfrom tensorflow.python.ops import math_ops\nfrom tensorflow.python.ops import nn_ops\nfrom tensorflow.python.ops import partitioned_variables\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.ops import variable_scope as vs\n\nfrom tensorflow.python.ops.math_ops import sigmoid\nfrom tensorflow.python.ops.math_ops import tanh\nfrom tensorflow.python.ops.rnn_cell_impl import _RNNCell as RNNCell\n\nfrom tensorflow.python.platform import tf_logging as logging\nfrom tensorflow.python.util import nest\n\nfrom tensorflow.contrib.layers import batch_norm\n\nimport contextlib\n\n_BIAS_VARIABLE_NAME = \"biases\"\n_WEIGHTS_VARIABLE_NAME = \"weights\"\n\n@contextlib.contextmanager\ndef _checked_scope(cell, scope, reuse=None, **kwargs):\n  if reuse is not None:\n    kwargs[\"reuse\"] = reuse\n  with vs.variable_scope(scope, **kwargs) as checking_scope:\n    scope_name = checking_scope.name\n    if hasattr(cell, \"_scope\"):\n      cell_scope = cell._scope  # pylint: disable=protected-access\n      if cell_scope.name != checking_scope.name:\n        raise ValueError(\n            \"Attempt to reuse RNNCell %s with a different variable scope than \"\n            \"its first use.  First use of cell was with scope '%s', this \"\n            \"attempt is with scope '%s'.  Please create a new instance of the \"\n            \"cell if you would like it to use a different set of weights.  \"\n            \"If before you were using: MultiRNNCell([%s(...)] * num_layers), \"\n            \"change to: MultiRNNCell([%s(...) for _ in range(num_layers)]).  \"\n            \"If before you were using the same cell instance as both the \"\n            \"forward and reverse cell of a bidirectional RNN, simply create \"\n            \"two instances (one for forward, one for reverse).  \"\n            \"In May 2017, we will start transitioning this cell's behavior \"\n            \"to use existing stored weights, if any, when it is called \"\n            \"with scope=None (which can lead to silent model degradation, so \"\n            \"this error will remain until then.)\"\n            % (cell, cell_scope.name, scope_name, type(cell).__name__,\n               type(cell).__name__))\n    else:\n      weights_found = False\n      try:\n        with vs.variable_scope(checking_scope, reuse=True):\n          vs.get_variable(_WEIGHTS_VARIABLE_NAME)\n        weights_found = True\n      except ValueError:\n        pass\n      if weights_found and reuse is None:\n        raise ValueError(\n            \"Attempt to have a second RNNCell use the weights of a variable \"\n            \"scope that already has weights: '%s'; and the cell was not \"\n            \"constructed as %s(..., reuse=True).  \"\n            \"To share the weights of an RNNCell, simply \"\n            \"reuse it in your second calculation, or create a new one with \"\n            \"the argument reuse=True.\" % (scope_name, type(cell).__name__))\n\n    # Everything is OK.  Update the cell's scope and yield it.\n    cell._scope = checking_scope  # pylint: disable=protected-access\n    yield checking_scope\n\n\nclass BNGRUCell(GRUCell):\n  \"\"\"Gated Recurrent Unit cell (cf. http://arxiv.org/abs/1406.1078).\"\"\"\n\n  def __init__(self, num_units, input_size=None, activation=tanh, is_training=True, batch_norm=True):\n    self._is_training = is_training\n    self._batch_norm = batch_norm\n\n    super().__init__(num_units, input_size, activation)\n\n  def __call__(self, inputs, state, scope=None):\n    \"\"\"Gated recurrent unit (GRU) with nunits cells.\"\"\"\n    with _checked_scope(self, scope or \"gru_cell\"):\n      with vs.variable_scope(\"gates\"):  # Reset gate and update gate.\n        # We start with bias of 1.0 to not reset and not update.\n        value = sigmoid(_linear(\n          [inputs, state], 2 * self._num_units, True, 1.0))\n        r, u = array_ops.split(\n            value=value,\n            num_or_size_splits=2,\n            axis=1)\n      with vs.variable_scope(\"candidate\"):\n        res = self._activation(_linear([inputs, r * state],\n                                     self._num_units, True))\n\n        if self._batch_norm:\n          c = batch_norm(res,\n                         center=True, scale=True,\n                         is_training=self._is_training,\n                         scope='bn1')\n        else:\n          c = res\n\n      new_h = u * state + (1 - u) * c\n    return new_h, new_h\n\ndef _linear(args, output_size, bias, bias_start=0.0):\n  \"\"\"Linear map: sum_i(args[i] * W[i]), where W[i] is a variable.\n  Args:\n    args: a 2D Tensor or a list of 2D, batch x n, Tensors.\n    output_size: int, second dimension of W[i].\n    bias: boolean, whether to add a bias term or not.\n    bias_start: starting value to initialize the bias; 0 by default.\n  Returns:\n    A 2D Tensor with shape [batch x output_size] equal to\n    sum_i(args[i] * W[i]), where W[i]s are newly created matrices.\n  Raises:\n    ValueError: if some of the arguments has unspecified or wrong shape.\n  \"\"\"\n  if args is None or (nest.is_sequence(args) and not args):\n    raise ValueError(\"`args` must be specified\")\n  if not nest.is_sequence(args):\n    args = [args]\n\n  # Calculate the total size of arguments on dimension 1.\n  total_arg_size = 0\n  shapes = [a.get_shape() for a in args]\n  for shape in shapes:\n    if shape.ndims != 2:\n      raise ValueError(\"linear is expecting 2D arguments: %s\" % shapes)\n    if shape[1].value is None:\n      raise ValueError(\"linear expects shape[1] to be provided for shape %s, \"\n                       \"but saw %s\" % (shape, shape[1]))\n    else:\n      total_arg_size += shape[1].value\n\n  dtype = [a.dtype for a in args][0]\n\n  # Now the computation.\n  scope = vs.get_variable_scope()\n  with vs.variable_scope(scope) as outer_scope:\n    weights = vs.get_variable(\n        _WEIGHTS_VARIABLE_NAME, [total_arg_size, output_size], dtype=dtype)\n    if len(args) == 1:\n      res = math_ops.matmul(args[0], weights)\n    else:\n      res = math_ops.matmul(array_ops.concat(args, 1), weights)\n    if not bias:\n      return res\n    with vs.variable_scope(outer_scope) as inner_scope:\n      inner_scope.set_partitioner(None)\n      biases = vs.get_variable(\n          _BIAS_VARIABLE_NAME, [output_size],\n          dtype=dtype,\n          initializer=init_ops.constant_initializer(bias_start, dtype=dtype))\n    return nn_ops.bias_add(res, biases)\n\\end{lstlisting}\n\n\\endgroup\n\n\\end{multicols}\n\\end{landscape}\n", "meta": {"hexsha": "6ffc50bfec209d8c39c129ae4deb1f85b66373c0", "size": 48860, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/appendices/code_listing.tex", "max_stars_repo_name": "AxelGoetz/website-fingerprinting", "max_stars_repo_head_hexsha": "17b1c8d485c48fee2d1f963eeba7a03ddf8e4fc6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2017-08-26T15:54:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T03:38:07.000Z", "max_issues_repo_path": "report/appendices/code_listing.tex", "max_issues_repo_name": "henghengxiong/website-fingerprinting", "max_issues_repo_head_hexsha": "17b1c8d485c48fee2d1f963eeba7a03ddf8e4fc6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/appendices/code_listing.tex", "max_forks_repo_name": "henghengxiong/website-fingerprinting", "max_forks_repo_head_hexsha": "17b1c8d485c48fee2d1f963eeba7a03ddf8e4fc6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2017-12-30T14:23:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-25T11:33:01.000Z", "avg_line_length": 38.3215686275, "max_line_length": 165, "alphanum_fraction": 0.641260745, "num_tokens": 10757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.5660185351961013, "lm_q1q2_score": 0.4102900186571495}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[a4paper, total={6.5in, 10in}]{geometry}\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{multirow}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{floatrow}\n\\restylefloat{table}\n\\usepackage[colorinlistoftodos]{todonotes}\n\\usepackage{float}\n\\title{Vector-Valued Image Regularization with PDEs}\n\n\\author{Meet Kathiriya, Shreyas Pimpalgaonkar, Saiteja Talluri \\\\ 160050001,160050024,160050098}\n\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n\nWe focussed on techiniques for vector-valued image regularization, based on variational methods and PDEs. We performed denoising, image reconstruction, inpainting, magnification and flow visualization on color images using these techinques and presented our results and conclusions.\n\\end{abstract}\n\n\\section{Theory}\n\\label{sec:theory}\n\\hspace{5mm}The problem of image regularisation can be solved by three interconnected models of functional \\\\ minimisation, divergence expressions and oriented laplacians. \n\nThe structure tensor is used here, and it's eigen vectors represent directions of maximum variation. Therefore, the problem can be formulated as minimising the generalised functional representing the variation in the image using the eigen vectors as follows\n$$\\min_{I:\\Omega\\to\\mathcal{R}^{n}} E(I) = \\int_{\\Omega} \\psi(\\lambda_{+},\\lambda_{-})\\,d\\Omega$$\n\n The above equation can be converted to the divergence of a diffusion matrix with gradient of the Image channel by using Euler-Lagrange theorem, heat equations, orthogonality of eigen vectors and simple partial differential equation chain rules as done in the appendix 1 of the original paper. \n        $$\\frac{\\partial I_i}{\\partial t} = div ( D \\nabla I )          \\qquad  (i = 1..n) $$ \n        $$ \\textbf{D} = \\frac{\\partial \\psi}{\\partial \\lambda_+} \\theta_+ \\theta_+^T  +  \\frac{\\partial \\psi}{\\partial \\lambda_-} \\theta_- \\theta_-^T$$\n    where $n$ is the number of channels and $\\theta_+,\\theta_-$ are the eigen vectors of the structure tensor. If a $\\psi$ exists, eigenvalues of the divergence tensor D can be seen it's gradient and obtaining $I_i$ is easy for every channel.\n    \nThe oriented laplacian equation can be written as the following PDE\n$$\\frac { \\partial I _ { i } } { \\partial t } = c _ { 1 } I _ { i \\epsilon \\varepsilon } + c _ { 2 } I _ { i m } = \\operatorname { trace } \\left( \\mathbf { T } H _ { i } \\right)$$\n $$ I _ { i ( t ) } = I _ { i _ { ( t = 0 ) } } * G ^ { ( \\mathbf { T } , t ) }$$ \nwhere $*$ stands for the convolution with the oriented Gaussian kernel \n$$G ^ { ( \\mathbf { T } , t ) } ( \\mathbf { x } ) = \\frac { 1 } { 4 \\pi t } \\exp \\left( - \\frac { \\mathbf { x } ^ { T } \\mathbf { T } ^ { - 1 } \\mathbf { x } } { 4 t } \\right) \\quad \\text { with } \\quad \\mathbf { x } = ( x \\quad y ) ^ { T }$$\n\n$$\\frac { \\partial I _ { i } } { \\partial t } = \\operatorname { trace } \\left( \\mathbf { T } \\mathbf { H } _ { i } \\right) \\quad ( i = 1 . . n )$$\n\nwhere $\\textbf{T}$ is the tensor field defined pointwise as \n    \n$$\\mathbf { T } = f _ { - } \\left( \\sqrt { \\lambda _ { + } ^ { * } + \\lambda _ { - } ^ { * } } \\right) \\theta _ { - } ^ { * } \\theta _ { - } ^ { * T } + f _ { + } \\left( \\sqrt { \\lambda _ { + } ^ { * } + \\lambda _ { - } ^ { * } } \\right) \\theta _ { + } ^ { * } \\theta _ { + } ^ { * } T$$\n\nwhere $\\lambda_{\\pm}^*$ and $\\theta_{\\pm}^*$ are defined to be the spectral elements of $G_\\sigma = G * G_{\\sigma'}$ , a Gaussian smoothed version of the structure tensor G, allowing us to retrieve a more coherent vector geometry giving a better approximation of the vector discontinuity directions.  \n\nFor our experiments we choose, $f _ { + } ( s ) = \\frac { 1 } { 1 + s ^ { 2 } } .\\text { and } f _ { - } ( s ) = \\frac { 1 } { \\sqrt { 1 + s ^ { 2 } } }$ \\newline\n\nFinally, a high level overview of the algorithm is to convolve the image with a gaussian that solves the PDE of Oriented Laplacians with $\\textbf{T}$ and $f$ as in the above section. This is equivalent to using the trace formula in section 2.3 and also is proved in the original paper.\n    \n\\pagebreak\n\\section{Results and Inferences}\n\n\\subsection{Image Inpainting}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=1\\textwidth]{glasses.png}\n\\caption{\\label{fig:data} Inpainting with 21x21 neighbourhood, t=5 and 10 iterations}\n\\end{figure}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=1\\textwidth]{parrot1.png}\n\\caption{\\label{fig:data} Inpainting with 10x10 neighbourhood, t=2 and 20 iterations}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{redparrot.png}\n\\caption{\\label{fig:data} Inpainting with 20x20 neighbourhood, t=3 and 20 iterations Also the black prints at boundaries and some darker regions in image is due to the fact that the mask we are using is imperfect as it contains more white region at some locations than the cage obstacle in real image.}\n\\end{figure}\n\n\\pagebreak\n\\subsection{Image Denoising}\n\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=1\\textwidth]{baby.png}\n\\caption{\\label{fig:data} From L to R : Noisy image, image filtered with gaussian smoothing with 5x5 kernel, image filtered with PDE regularisation with t=3, 3x3 neighbourhood and 5 iterations - better performance and lower noise especially on left and top parts of the image }\n\\end{figure}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.8\\textwidth,height=0.4\\textwidth]{face.png}\n\\caption{\\label{fig:data} From L to R : Noisy image, image filtered with PDE with t=3, 3x3 neighbourhood and 5 iterations }\n\\end{figure}\n\n\\subsection{Image Magnification}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{jerry.png}\n\\caption{\\label{fig:data}\n    From L to R : Original Image. This image was downsampled by 4 to serve as input for the two algorithms. Magnified image using bi-linear interpolation, magnified image using PDE regularisation with t=3, 3x3 neighbourhood and 10 iterations. \n}\n\n\\end{figure}\n\n\\pagebreak\n\n\\subsection{Flow Visualisation}\n\n\\begin{table}[H]\n\\caption{Input images, flow vectors and output images, with dt = 0.01, 100 iterations and sobel gradient vectors for Hessian Matrix. Paralallised code, runs much faster compared to others}\n\\begin{tabular}{c c c}\n\\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{1} & \\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{5} & \n\\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{2}\\\\\n\\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{4} & \\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{6} &\n\\includegraphics[width=0.33\\textwidth,height=0.4\\textwidth]{3}\n\\end{tabular}\n\\end{table}\n\n\\subsection{Image Restoration}\n\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\textwidth]{obama.png}\n\\caption{\\label{fig:data}\n    From L to R : Input Image, image with 50 \\% pixels removed in 2x2 granularity, output image with SSIM of 0.995, better than results with median filter. Also, median filter will become less accurate on increasing the box sizes. }\n\n\\end{figure}\n\n\\begin{figure}[H] \\label{frow}\n \\begin{floatrow} \n {\\includegraphics[width=0.5\\textwidth]{l1}}\n {\\includegraphics[width=0.5\\textwidth]{l2}}\n \\end{floatrow}\n \\caption{\\label{fig:data} from L to R : image with 50 \\% pixels removed and SSIM = 0.23, restored image with t=4, 10 iterations with 3x3 neighbourhood, SSIM = 0.966 with original image}\n\\end{figure}\n\n\n\n\n\\section{Experimental Observations and Conclusions}\n\n\\begin{enumerate}\n    \\item This technique is hard to parallelise in MATLAB as we have to calculate the eigen vectors and eigen values of the  structure tensor at each pixel (The matrix $\\textbf{T}$). The MATLAB eig function doesn't provide this functionality. We tried to do this using parfor but it takes too much time to setup the threads and ultimately is slower.\n    \n    \\item Image Inpainting fails drastically as the size of the width of continuous portion of mask increases. Inpainting by this framework is only suitable for removing shapes like cylinders/spheres with small radii. On increasing the width, the lost information is harder to recover due to the high variability in diffusion. Some techniques that specialise in hole filling on the basis of similar patterns like used in Mean Shift Segmentation can be used to give better results. Also, machine learning models can be trained to predict the missing parts, rather than regularisation.\n    \n    \\item This technique performs almost similar to bilateral filtering in denoising images, with a lot more computation overhead.\n    \n    \\item Algorithm follows three main parameters neighbourhood,number of iterations and time. From our experimentation we observed that neighbourhood size highly affects the regularization and it determines amount of smoothing (directly proportional) and edge preservation (indirectly proportional), number of iteration also determines above mentioned image characteristics but they characteristic change start to converge as the number of iteration increases. the time parameter we observed to be least affecting on result as in a very large t worked as a mean filter and very small t there was no significant regularization on image. \n    \n    \\item While using PDE for image magnification we didn't obtain desired results when the down sampling ratio is high. The possible reason for this could be that we are applying PDE on image magnified with bi-linear interpolation which doesn't retain global features like edges for high down sampling ratios.\n    \n    \\item Flow visualization with PDEs doesn't require calculation of Tensor field at each point unlike denoising and inpainting so with vector manipulations in MATLAB we could very efficiently compute it if the Field vector is not dependent on local variations at each pixel. \n    \n\\end{enumerate}\n\n\\begin{thebibliography}{9}\nD. Tschumperle ́ and R. Deriche, “Vector-valued image regularization with PDE’s: A common framework for different applications,” IEEE Trans. PAMI, vol. 27, no. 4, pp. 506–517, 2005. \n\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "63cd96938d1f95fe1c7ba49633883fdbbfe9e1b7", "size": 10119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/report.tex", "max_stars_repo_name": "saiteja-talluri/vector-valued-image-regularization", "max_stars_repo_head_hexsha": "a14152526dfd4f3002bb81de788562ef1fdacdc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/report.tex", "max_issues_repo_name": "saiteja-talluri/vector-valued-image-regularization", "max_issues_repo_head_hexsha": "a14152526dfd4f3002bb81de788562ef1fdacdc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/report.tex", "max_forks_repo_name": "saiteja-talluri/vector-valued-image-regularization", "max_forks_repo_head_hexsha": "a14152526dfd4f3002bb81de788562ef1fdacdc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-16T13:51:17.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-16T13:51:17.000Z", "avg_line_length": 60.9578313253, "max_line_length": 637, "alphanum_fraction": 0.7335705109, "num_tokens": 2789, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.41029000804405}}
{"text": "\\documentclass[10pt, a4paper, twocolumn, oneside]{article}\n\n\\usepackage[mono]{codebookpkg}\n\n\\team{NCTU\\_a}{National Chiao Tung University}\n\\codetheme{default}\n\n\\begin{document}\n\n\\fontsize{7.2pt}{9pt}\\selectfont\n\n\\tableofcontents\n\\newpage\n\n\\section{Misc}\n    \\subsection{Contest}\n        \\subsubsection{Debug List}\n            \\inputminted{md}{content/misc/debug-list.txt}\n        \\subsubsection{Makefile}\n            \\inputminted{makefile}{content/misc/makefile}\n        \\subsubsection{Default Code}\n            \\cppfile{content/misc/default.cpp}\n        \\subsubsection{acceleration yes}\n            \\cppfile{content/misc/pragmas.cpp}\n        \\subsubsection{C++17 constexpr}\n            \\cppfile{content/misc/constexpr.cpp}\n        \\subsubsection{Changing Stack Size}\n            \\cppfile{content/misc/stack-size.cpp}\n    \\subsection{Utils}\n        \\subsubsection{SplitMix64}\n            \\cppfile{content/misc/splitmix64.cpp}\n        \\subsubsection{Random}\n            \\cppfile{content/misc/random.cpp}\n        \\subsubsection{Bit Twiddling}\n            \\cppfile{content/misc/bit-hacks.cpp}\n        \\subsubsection{Floating Point Comparison}\n            \\cppfile{content/misc/epsilon.cpp}\n        \\subsubsection{Floating Point Binary Search}\n            \\cppfile{content/misc/float-binary-search.cpp}\n    \\subsection{Misc Algorithms}\n        \\subsubsection{Mo's Algorithm on Tree}\n            \\cppfile{content/misc/mo-tree.cpp}\n        \\subsubsection{Longest Increasing Subsequence}\n            \\cppfile{content/misc/lis.cpp}\n        \\subsubsection{Aliens Trick}\n            \\cppfile{content/misc/aliens.cpp}\n\n\\section{Data Structures}\n    \\subsection{GNU PBDS}\n        \\cppfile{content/ds/pbds.cpp}\n    \\subsection{Segment Tree}\n        \\cppfile{content/ds/segtree.cpp}\n    \\subsection{Line Container}\n        \\cppfile{content/ds/line-container.cpp}\n    \\subsection{Heavy-Light Decomposition}\n        \\cppfile{content/ds/hld.cpp}\n    \\subsection{Link-cut Tree}\n        \\cppfile{content/ds/lct.cpp}\n\n\\section{Math}\n    \\subsection{Number Theory}\n        \\subsubsection{Modular}\n            \\cppfile{content/math/number-theory/modular.cpp}\n        \\subsubsection{Extended GCD}\n            \\cppfile{content/math/number-theory/extgcd.cpp}\n        \\subsubsection{Chinese Remainder}\n            \\cppfile{content/math/number-theory/crt.cpp}\n        \\subsubsection{Sieve}\n            \\cppfile{content/math/number-theory/sieve.cpp}\n        \\subsubsection{Miller-Rabin}\n            \\cppfile{content/math/number-theory/miller-rabin.cpp}\n        \\subsubsection{Pollard's Rho}\n            \\cppfile{content/math/number-theory/pollard-rho.cpp}\n        \\subsubsection{Tonelli-Shanks}\n            \\cppfile{content/math/number-theory/tonelli-shanks.cpp}\n        \\subsubsection{Baby-Step Giant-Step}\n            \\cppfile{content/math/number-theory/bsgs.cpp}\n        \\subsubsection{Multiplicative Function Sum}\n            \\cppfile{content/math/number-theory/djs.cpp}\n    \\subsection{Combinatorics}\n        \\subsubsection{De Brujin Sequence}\n            \\cppfile{content/math/combinatorics/de-brujin.cpp}\n        \\subsubsection{Multinomial}\n            \\cppfile{content/math/combinatorics/multinomial.cpp}\n        \\subsubsection{Not Burnside's Lemma}\n            \\input{content/math/combinatorics/burnside.tex}\n        \\subsubsection{Matroid Intersection}\n            \\input{content/math/combinatorics/matroid.tex}\n    \\subsection{Theorems}\n        \\input{content/math/theorem.tex}\n\n\\section{Numeric}\n    \\subsection{long long Multiplication}\n        \\cppfile{content/numeric/ll-mul.cpp}\n    \\subsection{Barrett Reduction}\n        \\cppfile{content/numeric/barrett-reduction.cpp}\n    \\subsection{Polynomial Interpolation}\n        \\cppfile{content/numeric/interpolation.cpp}\n    \\subsection{Fast Fourier Transform}\n        \\cppfile{content/numeric/fft.cpp}\n    \\subsection{Fast Walsh-Hadamard Transform}\n        \\cppfile{content/numeric/fwht.cpp}\n    \\subsection{FFT Convolution}\n        \\cppfile{content/numeric/fftc.cpp}\n    \\subsection{Linear Recurrence}\n        \\subsubsection{Calculation}\n            \\cppfile{content/numeric/linear-recurrence.cpp}\n        \\subsubsection{Berlekamp-Massey}\n            \\cppfile{content/numeric/berlekamp-massey.cpp}\n        \\subsubsection{Composite Modulus Recurrence}\n            \\cppfile{content/numeric/min25-rec.cpp}\n    \\subsection{Matrix Determinant}\n        \\cppfile{content/numeric/det.cpp}\n    \\subsection{Matrix Inverse}\n        \\cppfile{content/numeric/inverse.cpp}\n    \\subsection{Linear Equations}\n        \\cppfile{content/numeric/linear-eq.cpp}\n    \\subsection{Simplex}\n        \\cppfile{content/numeric/simplex.cpp}\n\n\\section{Graph}\n    \\subsection{Modeling}\n        \\input{content/graph/model.tex}\n    \\subsection{Flow}\n        \\subsubsection{Dinic}\n            \\cppfile{content/graph/flow/dinic.cpp}\n        \\subsubsection{Gomory-Hu Tree}\n            \\cppfile{content/graph/flow/gomory-hu.cpp}\n        \\subsubsection{Global Minimum Cut}\n            \\cppfile{content/graph/flow/sw.cpp}\n        \\subsubsection{Min Cost Max Flow}\n            \\cppfile{content/graph/flow/mcmf.cpp}\n    \\subsection{Matching}\n        \\subsubsection{Kuhn-Munkres}\n            \\cppfile{content/graph/matching/km.cpp}\n        \\subsubsection{Bipartite Minimum Vertex Cover}\n            \\cppfile{content/graph/matching/min-bi-cover.cpp}\n        \\subsubsection{Maximum General Matching}\n            \\cppfile{content/graph/matching/edmonds.cpp}\n        \\subsubsection{Min Weight Perfect Matching}\n            \\cppfile{content/graph/matching/min-weight-general.cpp}\n        \\subsubsection{Stable Marriage}\n            \\cppfile{content/graph/matching/marriage.cpp}\n    \\subsection{Centroid Decomposition}\n        \\cppfile{content/graph/centroid-decomposition.cpp}\n    \\subsection{Minimum Mean Cycle}\n        \\cppfile{content/graph/min-mean-cycle.cpp}\n    \\subsection{Bellman-Ford}\n        \\cppfile{content/graph/bellman-ford.cpp}\n    \\subsection{Directed Minimum Spanning Tree}\n        \\cppfile{content/graph/dmst.cpp}\n    \\subsection{Maximum Clique}\n        \\cppfile{content/graph/clique.cpp}\n    \\subsection{Tarjan}\n        \\subsubsection{Strongly Connected Components}\n            \\cppfile{content/graph/tarjan-scc.cpp}\n        \\subsubsection{Articulation Point}\n            \\cppfile{content/graph/tarjan-ap.cpp}\n        \\subsubsection{Bridge}\n            \\cppfile{content/graph/tarjan-b.cpp}\n    \\subsection{2-SAT}\n        \\cppfile{content/graph/2sat.cpp}\n    \\subsection{Dominator Tree}\n        \\cppfile{content/graph/dominator-tree.cpp}\n    \\subsection{Biconnected Components}\n        \\cppfile{content/graph/bcc.cpp}\n    \\subsection{Edge BCC}\n        \\cppfile{content/graph/edge-bcc.cpp}\n    \\subsection{Manhattan MST}\n        \\cppfile{content/graph/manhattan-mst.cpp}\n    \\subsection{Notes}\n        \\inputminted{text}{content/graph/notes.txt}\n\n\\section{Geometry}\n    \\subsection{Basic 2D}\n        \\cppfile{content/geometry/basic-2d.cpp}\n    \\subsection{Angular Sort}\n        \\cppfile{content/geometry/angular-sort.cpp}\n    \\subsection{Convex Hull}\n        \\cppfile{content/geometry/convex-hull.cpp}\n    \\subsection{Convex Polygon Point Inclusion}\n        \\cppfile{content/geometry/convex-inclusion.cpp}\n    \\subsection{Convex Polygon Minkowski Sum}\n        \\cppfile{content/geometry/minkowski-sum.cpp}\n    \\subsection{Closest Pair}\n        \\cppfile{content/geometry/closest-pair.cpp}\n    \\subsection{Minimum Enclosing Circle}\n        \\cppfile{content/geometry/min-circle.cpp}\n    \\subsection{Half Plane Intersection}\n        \\cppfile{content/geometry/half-plane.cpp}\n    \\subsection{Delaunay Triangulation}\n        \\cppfile{content/geometry/delaunay.cpp}\n    \\subsection{Spherical Coordinates}\n        \\cppfile{content/geometry/spherical.cpp}\n    \\subsection{Quaternion}\n        \\cppfile{content/geometry/quaternion.cpp}\n    \\subsection{3D Convex Hull}\n        \\cppfile{content/geometry/3d-hull.cpp}\n\n\\section{Strings}\n    \\subsection{Z-value}\n        \\cppfile{content/strings/z-value.cpp}\n    \\subsection{Manacher}\n        \\cppfile{content/strings/manacher.cpp}\n    \\subsection{Minimum Rotation}\n        \\cppfile{content/strings/min-rotation.cpp}\n    \\subsection{Aho-Corasick}\n        \\cppfile{content/strings/ahocorasick.cpp}\n    \\subsection{Suffix Array}\n        \\cppfile{content/strings/suffix-array.cpp}\n    \\subsection{Suffix Tree}\n        \\cppfile{content/strings/suffix-tree.cpp}\n\n\n\\end{document}\n", "meta": {"hexsha": "969eb2ea23fe5231a421d2f86c3d46898ce9e0a9", "size": 8411, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "codebook.tex", "max_stars_repo_name": "ToxicPie/codebook", "max_stars_repo_head_hexsha": "fc084c4b61026f33a03f2901430b6fe36d2c1e6f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-06-28T06:58:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-13T04:51:48.000Z", "max_issues_repo_path": "codebook.tex", "max_issues_repo_name": "ToxicPie/codebook", "max_issues_repo_head_hexsha": "fc084c4b61026f33a03f2901430b6fe36d2c1e6f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "codebook.tex", "max_forks_repo_name": "ToxicPie/codebook", "max_forks_repo_head_hexsha": "fc084c4b61026f33a03f2901430b6fe36d2c1e6f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-06T12:17:34.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-06T12:17:34.000Z", "avg_line_length": 38.9398148148, "max_line_length": 67, "alphanum_fraction": 0.6756628225, "num_tokens": 2141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.4102750252069574}}
{"text": "\\documentclass{article} % For LaTeX2e\r\n\\usepackage{times}\r\n\\usepackage{hyperref}\r\n\\usepackage{url}\r\n\r\n\\usepackage{amsmath}\r\n\\usepackage{mathtools}\r\n\\usepackage{amssymb}\r\n\r\n\\usepackage[T1]{fontenc}\r\n\r\n\\title{Efficient Calculation of Polynomial Features on Sparse Matrices}\r\n\r\n\r\n%\\author{Andrew Nystrom \\\\\r\n%Savvysherpa Inc.\\\\\r\n%6200 Shingle Creek Pkwy \\\\\r\n%Suite 400 \\\\\r\n%Minneapolis, MN 55430, USA \\\\\r\n%\\texttt{awnystrom@gmail.com} \\\\\r\n%\\And\r\n%John F. Hughes \\\\\r\n%Department of Computer Science \\\\\r\n%Brown University \\\\\r\n%Providence, RI \\\\\r\n%\\texttt{jfh@cs.brown.edu} \\\\\r\n%}\r\n\r\n\\author{\r\n  Nystrom, Andrew\\\\\r\n  \\texttt{awnystrom@gmail.com}\r\n  \\and\r\n  Hughes, John\\\\\r\n  \\texttt{jfh@cs.brown.edu}\r\n}\r\n\r\n% The \\author macro works with any number of authors. There are two commands\r\n% used to separate the names and addresses of multiple authors: \\And and \\AND.\r\n%\r\n% Using \\And between authors leaves it to \\LaTeX{} to determine where to break\r\n% the lines. Using \\AND forces a linebreak at that point. So, if \\LaTeX{}\r\n% puts 3 of 4 authors names on the first line, and the last on the second\r\n% line, try using \\AND instead of \\And before the third author name.\r\n\r\n%\\newcommand{\\fix}{\\marginpar{FIX}}\r\n%\\newcommand{\\new}{\\marginpar{NEW}}\r\n\r\n\\begin{document}\r\n\r\n\r\n\\maketitle\r\n\r\n\\begin{abstract}\r\nWe provide an algorithm for polynomial feature expansion that operates directly on a sparse matrix.\r\nFor a vector of dimension $D$ and density $d$, the algorithm has time and space complexity $O(d^kD^k)$ where $k$ is the polynomial order.\r\n\\end{abstract}\r\n\r\n% this is a test-change for Spike to see whether Git seems to work for him. Ignore. \r\n\r\n\\section{Introduction}\r\n\r\nPolynomial feature expansion has long been used in statistics to approximate nonlinear functions~\\cite{gergonne1974application, smith1918standard}.\r\nDespite this, we are unaware of any efforts to optimize calculating them.\r\nHere we provide an algorithm for calculating polynomial features for a vector of dimension $D$ and density $d$ with time and space complexity $O(d^kD^k)$ where $k$ is the polynomial order, and $0 \\le d \\le 1$ is the fraction of elements that are nonzero.\r\nThe standard algorithm has time and space complexity $O(D^k)$, so the added factor of $d^k$ represents a significant complexity reduction.\r\nThe algorithm avoids densification of the vector, i.e. the vector remains in compressed sparse row form, so the space complexity is also $O(d^kD^k)$ as opposed to $O(D^k)$. \r\n\r\n\\section{Algorithm}\r\nIn the naive computation of polynomial features for a vector $\\vec{x}$, we create a new feature for each product (with repetition) of $k$ features in $\\vec{x}$ (or without repetition, for ``interaction features'').\r\nThis ignores data sparsity and will yield a product of zero any time one of the features involved in the product is zero.\r\nIn a sparse matrix, such zero-products are common.\r\n%If $\\vec{x}$ has density $d$, the fraction of nonzero elements of the $k$-order expansion will be $\\frac{\\left(\\binom{dD+k-1}{k}\\right)}{\\left(\\binom{D+k-1}{k}\\right)} = \\frac{[(dD+k-1)(dD+k-2) \\dots (dD+k)](D-1)!}{(dD-1)!} = $\r\nIf we store vectors in a sparse matrix format, these zero-products need not be computed or stored. \r\n\r\nThe main idea behind our algorithm is to leverage sparsity by only computing products that do not involve zeros.\r\nIn a compressed sparse row matrix, the columns containing nonzero data are the only columns that are stored.\r\nWe can therefore iterate over products of combinations with repetition of order $k$ of \\emph{only these columns} for each row to calculate $k$-degree polynomial features.\r\n\r\nWhile the idea is straightforward, there is yet an unaddressed challenge:\r\nGiven a multiset of column indices whose corresponding nonzero components were multiplied to produce a polynomial feature, where in the augmented polynomial vector does the result of the product belong?\r\nTo address this, we give a bijective mapping from the set of possible column index combinations-with-repetition of order $k$ onto the column index space of the polynomial feature matrix. Thus the map has the form\r\n\r\n\\begin{equation}\r\n(i_0, i_1, \\dots, i_{k-1}) \\rightarrowtail \\hspace{-1.9ex} \\twoheadrightarrow p_{i_0i_1 \\dots i_{k-1}} \\in \\{0,1,\\dots,\\binom{D}{k}\\} \r\n\\end{equation}\r\nsuch that $ 0 \\le i_0 \\le i_1 \\le \\dots \\le i_{k-1} < D$\r\nwhere $(i_0, i_1, \\dots, i_{k-1})$ are column indicies of a row vector $\\vec{x}$ of an $N \\times D$ input matrix, and $p_{i_0i_1 \\dots i_{k-1}}$ is a column index into the polynomial expansion vector for $\\vec{x}$ where the product of elements corresponding to indices $i_0, i_1, \\dots, i_{k-1}$ will be stored.\r\n%and $\\left(\\binom{D}{k}\\right)$ is the number of combinations with repetition of size $k$ drawn from $D$ objects.\r\n%In general, $\\left(\\binom{n}{k}\\right) = \\binom{n+k-1}{n-1} = \\binom{n+k-1}{k}$, as given by \\cite{stanley1986enumerative}.\r\n\r\n\\subsection{Construction of Mappings}\r\n\r\nFor the second degree case, we seek a map from matrix indices $(i, j)$ (with $0 \\le i < j < D$ ) to numbers $f(i, j)$ with $0 \\le f(i, j) < \\frac{D(D-1)}{2}$, one that follows the pattern indicated by \r\n\\begin{align}\r\n\\begin{bmatrix}\r\nx & 0 & 1 & 3 \\\\\r\nx & x & 2 & 4 \\\\\r\nx & x & x & 5 \\\\\r\nx & x & x & x\r\n\\end{bmatrix}\r\n\\label{eq:4x4mat}\r\n\\end{align}\r\nwhere the entry in row $i$, column $j$, displays the value $f(i, j)$. We let $T_2(n) = \\frac{1}{2} n(n+1)$ \r\nbe the $n$th triangular number; then in Equation~\\ref{eq:4x4mat}, column $j$ (for $j > 0$) contains entries with  \r\n$T_2(j-1) \\le e < T_2(j)$; the entry in the $i$th row is just $i + T_2(j-1)$. Thus we have\r\n$\r\nf(i, j) \r\n= i + T_2(j-1) =  \\frac{1}{2}(2i + j^2-j).$\r\nFor instance, in column $j = 2$ in our example (the \\emph{third} column), the entry in row $i = 1$ is \r\n$i + T_2(j-1) = 1 + 1 = 2$. \r\n\r\nWith one-based indexing in both the domain and codomain, the formula above becomes\r\n$f_1(i, j)  = \\frac{1}{2}(2i + j^2 - 3j + 2).$\r\n\r\nFor \\emph{polynomial} features, we seek a similar map $g$, one that also handles the case $i = j$. In this case, a similar analysis yields\r\n$ g(i, j) = i + T_2(j) = \\frac{1}{2} (2i + j^2 + j + 1).$\r\n\r\n\r\nTo handle \\emph{three-way interactions}, we need to map triples of indices in a 3-index array to a flat list, and similarly for higher-order interactions. For this, we'll need the tetrahedral numbers $T_3(n) = \\sum_{i=1}^n T_{2}(n) = \r\n\\frac{1}{6}(n^3 + 3n^2 + 2n)$.\r\n\r\nFor three indices, $i,j,k$, with $0 \\le i < j < k < D$, we have a similar recurrence. Calling the mapping $h$, we have \r\n\\begin{align}\r\nh(i,j,k) = i + T_2(j-1) + T_3(k-2);\r\n\\end{align}\r\nif we define $T_1(i) = i$, then this has the very regular form\r\n\\begin{align}\r\nh(i,j,k) =  T_1(i) + T_2(j-1) + T_3(k-2);\r\n\\end{align}\r\nand from this the generalization to higher dimensions is straightforward. The formulas for ``higher triangular numbers'', i.e., those defined by\r\n\\begin{align}\r\nT_k(n) &= \\sum_{i=1}^n T_{k-1}(n)\r\n\\end{align}\r\nfor $k > 1$ can be determined inductively.\r\n\r\nThe explicit formula for 3-way interactions, with zero-based indexing, is \r\n\\begin{align}\r\nh(i, j, k) &= 1 + (i-1) + \\frac{(j-1)j}{2} + \\\\\r\n& \\frac{(k-2)^3 + 3(k-2)^2 + 2(k-2)}{6}. \r\n\\end{align}\r\n\r\n\\section{Complexity Analysis}\r\n%\\subsection{Analytical}\r\n\r\nCalculating $k$-degree polynomial features via our method for a vector of dimensionality $D$ and density $d$ requires $\\binom{dD}{k}$ (with repetition) products.\r\nThe complexity of the algorithm, for fixed $k \\ll dD$, is therefore\r\n\\begin{align}\r\nO\\left(\\binom{dD+k-1}{k}\\right) & = O\\left(\\frac{(dD+k-1)!}{k!(dD-1)!}\\right)\\\\\r\n& = O\\left(\\frac{(dD+k-1)(dD+k-2) \\dots (dD)}{k!}\\right)\\\\\r\n& = O\\left((dD+k-1)(dD+k-2) \\dots (dD)\\right) \\mbox{ for } k \\ll dD\\\\\r\n& = O\\left(d^kD^k\\right)\r\n\\end{align}\r\n\r\n%\\subsection{Empirical}\r\n%\\section{Conclusion}\r\n\r\n\r\n\\bibliography{sparse_poly}\r\n\\bibliographystyle{iclr2016_workshop}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "4df7e7517a64e8d1eefafc2a0e4d06886efeba8c", "size": 7866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/workshop/sparse_poly.tex", "max_stars_repo_name": "AWNystrom/SparseInteraction", "max_stars_repo_head_hexsha": "68ac222d7a826a344675d0e5196d82cb1711a69a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2016-01-08T17:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-16T15:35:26.000Z", "max_issues_repo_path": "paper/workshop/sparse_poly.tex", "max_issues_repo_name": "AWNystrom/SparseInteraction", "max_issues_repo_head_hexsha": "68ac222d7a826a344675d0e5196d82cb1711a69a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/workshop/sparse_poly.tex", "max_forks_repo_name": "AWNystrom/SparseInteraction", "max_forks_repo_head_hexsha": "68ac222d7a826a344675d0e5196d82cb1711a69a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-01-08T17:28:39.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-08T17:36:00.000Z", "avg_line_length": 48.5555555556, "max_line_length": 312, "alphanum_fraction": 0.6898042207, "num_tokens": 2461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.41027501137060884}}
{"text": "\\documentclass[parskip=half]{scrartcl}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage[citestyle=authoryear-icomp,bibstyle=authoryear]{biblatex}\n\\usepackage{booktabs}\n\\usepackage[style=british]{csquotes}\n\\usepackage{fontspec}\n\\usepackage{siunitx}\n\n\\setmainfont[Numbers=Lowercase]{TeX Gyre Pagella}\n\\newfontfamily\\dispfamily{TeX Gyre Pagella}\n\\addtokomafont{disposition}{\\dispfamily}\n\n\\MakeAutoQuote{«}{»}\n\\DeclareMathOperator{\\Res}{Res}\n\n\\addbibresource{cable.bib}\n\n\\title{Analytic solution to passive cable model}\n\\author{Sam Yates}\n\\date{October 20, 2016}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Background}\n\nThe Rallpack suite \\parencite{bhalla1992} is a set of three tests for cable-based neuronal\nsimulators, for validation and benchmarking. Validation data is provided with the\ndistribution of the suite, which at the time of writing can now be found within the\n\\textsc{Genesis} simulator simulator distribution.\\footnote{see \\url{http://genesis-sim.org}.}\n\nThe first two of the tests are based on passive cable models which admit analytic\nsolutions, and the Rallpack suite includes code that can generate the reference curves\nfor these models. The reference code, however, requires hand-tuning of the iterations;\nthe authors state in the internal documentation that\n«the use of 10 terms gives at least six figure accuracy», but this is for the\nfixed time increments used in their dataset and is not validated within the code\nor by the supplied material.\n\nFor flexibility of testing and cross-checking of the Rallpack reference data,\nit would be useful to have at hand a robust calculator of the passive cable\npotential solution.\n\n\\section{The Rallpack 1 model}\n\nThe model comprises a cylindrical cable segment with the physical and electrical\nproperties as described in Table~\\ref{tbl:rallpack1}. A current of \\SI{0.1}{\\nA}\nis injected at the left end of the cable from $t=0$, and the initial potential\nis the reversal potential.\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{lSl}\n        \\toprule\n        Term & {Value} & Property\\\\\n        \\midrule\n        $d$    & \\SI{1.0}{\\um}                 & cable diameter \\\\\n        $L$    & \\SI{1.0}{\\mm}                 & cable length \\\\\n        $R_A$  & \\SI{1.0}{\\ohm\\m}              & bulk axial resistivity \\\\\n        $R_M$  & \\SI{4.0}{\\ohm\\m\\squared}      & areal membrane resistivity \\\\\n        $C_M$  & \\SI{0.01}{\\F\\per\\m\\squared}   & areal membrane capacitance \\\\\n        $E_M$  & \\SI{-65.0}{\\mV}               & membrane reversal potential \\\\\n        \\bottomrule\n    \\end{tabular}\n    \\caption{Cable properties for the Rallpack 1 model.}\n    \\label{tbl:rallpack1}\n\\end{table}\n\nThe potential on a constant-radius passive cable is governed by the PDE\n\\begin{equation}\n    \\lambda^2 \\frac{\\partial^2 v}{\\partial x^2} =\n    \\tau\\frac{\\partial v}{\\partial t} + v - E,\n\\end{equation}\nwhere $E$ is the membrane reversal potential, and $\\lambda$ and $\\tau$ are the\nelectrotonic length and time constants for the cable. It is convenient\nto consider the electrical properties of the cable per unit-length, in terms\nof the linear axial resistivity $r$, the linear membrane capacitance $r$,\nand the linear membrane capacitance $c$. These determine $\\lambda$ and $\\tau$ by\n\\begin{gather*}\n    \\lambda = \\frac{1}{r\\cdot g},\\\\\n    \\tau = r\\cdot c.\n\\end{gather*}\n\nWith the model boundary conditions,\n\\begin{subequations}\n    \\begin{align}\n        v(x, 0) &= E, \\\\\n        \\left.\\frac{\\partial v}{\\partial x}\\right\\vert_{x=0} & = -Ir, \\\\\n         \\left.\\frac{\\partial v}{\\partial x}\\right\\vert_{x=L} & = 0,\n    \\end{align}\n\\end{subequations}\nwhere $I$ is the injected current and $L$ is the cable length.\n\nThe solution $v(x, t)$ can be expressed in terms of the solution $g(x, t; L)$\nto a normalized version of the cable equation,\n\\begin{subequations}\n    \\begin{align}\n        \\label{eq:normcable}\n        \\frac{\\partial^2 g}{\\partial x^2} & =\n        \\frac{\\partial g}{\\partial t} + g,\n        \\\\\n        \\label{eq:normcableinitial}\n        g(x, 0) &= 0,\n        \\\\\n        \\label{eq:normcableleft}\n        \\left.\\frac{\\partial g}{\\partial x}\\right\\vert_{x=0} & = 1,\n        \\\\\n        \\label{eq:normcableright}\n        \\left.\\frac{\\partial g}{\\partial x}\\right\\vert_{x=L} & = 0\n    \\end{align}\n\\end{subequations}\nby\n\\begin{equation}\n    v(x, t)= E - Ir\\lambda \\cdot g(\\frac{x}{\\lambda}, \\frac{t}{\\tau};  \\frac{L}{\\lambda}).\n\\end{equation}\n\n\\section{Solution to the normalized cable equation}\n\nLet $G(x, s)$ be the Laplace transform of $g(x, t)$ with respect to $t$.\nIf the inverse transform of $G$ exists, it must agree with $g$ almost everywhere\nfor $t>0$, or for all $t>0$ given the continuity of $g$.\n\nFrom\n\\eqref{eq:normcable} and \\eqref{eq:normcableinitial},\n\\begin{equation}\n    \\label{eq:lap}\n    \\frac{\\partial^2 G}{\\partial x^2} = sG + G.\n\\end{equation}\nThe boundary conditions \\eqref{eq:normcableleft} and \\eqref{eq:normcableright} give\n\\begin{align}\n    \\label{eq:lapleft}\n    \\frac{\\partial G}{\\partial x}(0, s) & = \\frac{1}{s}\n    \\\\\n    \\label{eq:lapright}\n    \\frac{\\partial G}{\\partial x}(L, s) & = 0.\n\\end{align}\n\nSolutions to \\eqref{eq:lap} must be of the form\n\\begin{equation}\n    G(x, s) = A(s) e^{mx} +B(s) e^{-mx}\n\\end{equation}\nwhere $m=\\sqrt{1+s}$. From \\eqref{eq:lapleft} and \\eqref{eq:lapright},\n\\begin{align*}\n    mA(s) - mB(s) & = \\frac{1}{s}\n    \\\\\n    mA(s)e^{mL} -mB(s)e^{-mL} & = 0\n\\end{align*}\nand thus\n\\begin{align*}\n    A(s) & = \\frac{1}{sm (1-e^{2mL})}\n    \\\\\n    B(s) & = \\frac{e^{2mL}}{sm (1-e^{2mL})}.\n\\end{align*}\n\nConsequently,\n\\begin{equation}\n    \\begin{aligned}\n        G(x, s) &= \\frac{1}{ms}\\cdot\\frac{e^{mx}+e^{2mL-mx}}{1-e^{2mL}}\\\\\n                &= - \\frac{1}{ms}\\cdot\\frac{\\cosh m(L-x)}{\\sinh mL}.\n    \\end{aligned}\n\\end{equation}\n\n\\subsection*{Inversion}\n\nSufficient conditions for the inverse transform of $G(x,s)$ to exist\nand be representable in series form are as follows\n\\parencite[][Theorem 4]{churchill1937}:\n\\begin{enumerate}\n\\item\n    $G(x, s)$ is analytic in some right half-plane $H$,\n\\item\n    the singularities of $G(x, s)$ are all poles, and\n\\item for some $k>1$, $|s^k G(x, s)|$ is bounded in $H$ and\n    on the circles $|s|=\\rho_i$, where $\\rho_i$ is an unbounded monotonically\n    increasing sequence.\n\\end{enumerate}\nIf in addition all the poles $\\sigma_j$ of $G$ are simple, then\nthe series expansion of the inverse transform is given by\n\\begin{equation}\n    g(x,t) = \\sum_j e^{\\sigma_j t}\\, \\Res(G;\\sigma_j),\\quad t>0.\n\\end{equation}\n\n$G(x,s)$ has poles when $s=0$, $m=0$, or $\\sinh mL=0$.\nIn the following, let\n\\begin{gather*}\n    a_k = k\\pi /L\\\\\n    m_k = a_k i\\\\\n    s_k = m_k^2 -1 = -k^2\\pi^2/L^2-1.\n\\end{gather*}\nfor $k\\in\\mathbb{Z}$.\nThe poles are then $0$, $-1$, and $s_k$ for $k\\geq 1$.\n\nThere are no branch points\narising from $m=\\sqrt{1+s}$, as letting $m=-\\sqrt{1+s}$ leaves $G$ unchanged.\n\nFor $|s+1|>\\epsilon$,\n\\begin{equation}\n    \\begin{aligned}\n        |s^{3/2}G(x,s)|^2\n            & \\leq (1+\\epsilon)^{-1} \\left| \\frac{\\cosh m(L-x)}{\\sinh mL} \\right|^2\n        \\\\\n            & \\leq (1+\\epsilon)^{-1} (1+|\\coth mL|)^2\n    \\label{eq:gbounds}\n    \\end{aligned}\n\\end{equation}\nwhich is bounded in the half-plane $\\Re(s) \\geq  -1+\\epsilon$. \nAs $\\coth u+iv$ is periodic in $v$, \\eqref{eq:gbounds} is also bounded outside\nthe regions $\\{s: m\\in D_k\\}$, where $D_k$ are non-overlapping $\\delta$-neighborhoods of $m_k$\nfor some fixed small $\\delta>0$. These are contained within disks of radius\n$2k\\pi\\delta/L+\\delta^2$ about $s_k$ for $k\\geq 1$, which then are separated by\ncircles $|s|=\\rho_k$ about the origin for some $\\rho_k$ in $(|s_k|, |s_k+1|)$.\n\n\\textbf{Pole at $s=0$}.\\\\\nRecalling $m=\\sqrt{1+s}$, $m$ and $\\sinh mL$ are non-zero in\na neighbourhood of $s=0$, and so the pole is simple and\n\\begin{equation}\n    \\begin{aligned}\n        \\Res(G; 0) & = - \\frac{1}{m}\\cdot\\left.\\frac{\\cosh m(L-x)}{\\sinh mL}\\right|_{s=0}\\\\\n                   & = - \\frac{\\cosh (L-x)}{\\sinh L}.\n    \\end{aligned}\n\\end{equation}\n\n\\textbf{Pole at $s=-1$}.\\\\\nLet $G(x,s)=f(x,s)/h(s)$, where\n\\begin{equation}\n    \\begin{aligned}\n        f(x, s) &= -\\frac{1}{s}\\cosh m(L-x)\\\\\n        h(s) &= m\\sinh mL.\n    \\end{aligned}\n    \\label{eq:hf}\n\\end{equation}\nNoting that $dm/ds = \\frac{1}{2}m^{-1}$,\n\\begin{equation}\n    \\begin{aligned}\n        h'(s) &= \\frac{1}{2}m^{-1}\\sinh mL + \\frac{1}{2}L\\cosh mL \\\\\n              &= \\frac{1}{2}L + \\frac{1}{2}L + O(m^2) \\quad(m\\to 0) \\\\\n              &= L + O(s+1) \\quad(s\\to -1).\n    \\label{eq:hprime}\n    \\end{aligned}\n\\end{equation}\nThe pole is therefore simple, and\n\\begin{equation}\n    \\Res(G; -1) = f(x, -1)/h'(-1) = -\\frac{1}{L}.\n\\end{equation}\n\n\\textbf{Pole at $s=s_k$, $k \\geq 1$}.\\\\\nTaking $h$ and $f$ as above \\eqref{eq:hf},\n$m_k$ is non-zero for $k\\geq 1$ and\n\\[\n    h'(s_k) = \\frac{1}{2}L\\cosh m_kL.\n\\]\nConsequently the pole is simple and\n\\begin{equation}\n    \\begin{aligned}\n        \\Res(G; s_k)\n            & = f(x, s_k)/h'(s_k)\\\\\n            & =  -\\frac{2}{s_k L}\\frac{\\cosh m_k(L-x)}{\\cosh m_kL} \\\\\n            & =  -\\frac{2}{s_k L}\\frac{\\cosh m_kL\\cosh m_kx-\\sinh m_kL\\sinh m_kL}{\\cosh m_kL} \\\\\n            & =  -\\frac{2}{s_k L}\\cosh m_k x,\n    \\end{aligned}\n\\end{equation}\nas $\\sinh m_k=0$.\n\nIn terms of $a_k$,\n\\begin{equation}\n    \\Res(G; s_k) = \\frac{2}{L}\\cdot\\frac{1}{1+a_k^2}\\cdot\\cos a_kx.\n\\end{equation}\n\nThe series exapnsion for $g(x, t)$ therefore is\n\\begin{equation}\n    g(x, t) = -\\frac{\\cosh(L-x)}{\\sinh L} + \\frac{1}{L}e^{-t}\\left\\{\n        1+2\\sum_{k=1}^\\infty \\frac{e^{-ta_k^2}}{1+a_k^2}\\cos a_k x\\right\\}.\n    \\label{eq:theg}\n\\end{equation}\n\n\\section{Computation of series}\n\nAs $t$ approaches zero, the series \\eqref{eq:theg} converges increasingly slowly.\nFor computational purposes, an estimate on the series residual allows the determination\nof stopping criteria for a given tolerance.\n\nLet $g_n$ be the partial sum\n\\begin{equation}\n    g_n(x, t) = -\\frac{\\cosh(L-x)}{\\sinh L} + \\frac{1}{L}e^{-t}\\left\\{\n        1+2\\sum_{k=1}^n \\frac{e^{-ta_k^2}}{1+a_k^2}\\cos a_k x\\right\\}.\n\\end{equation}\nso that $g(x, t) =\\lim_{n\\to\\infty} g_n(x,t)$. Let $\\bar{g}_n = |g-g_n|$ be the\nresidual. The $a_k$ form an increasing sequence, so\n\\begin{equation}\n    \\begin{aligned}\n        \\bar{g}_n(x,t)\n            & \\leq \\frac{2}{L}e^{-t}\\sum_{n+1}^\\infty\\frac{e^{-ta_k^2}}{1+a_k^2}\\\\\n            & \\leq \\frac{2}{L}e^{-t}\\int_{a_n}^\\infty \\frac{e^{-tu^2}}{1+u^2}\\,du\\\\\n            & < \\frac{2}{L}e^{-t}\\int_{a_n}^\\infty \\frac{e^{-tu^2}}{u^2}\\,du.\n    \\end{aligned}\n    \\label{eq:gbar}\n\\end{equation}\nSubstituting $u=\\sqrt{v/t}$ gives the identity\n\\begin{equation}\n    \\int_{a}^\\infty \\frac{e^{-tu^2}}{u^2}\\,du\n    = \\frac{1}{2}\\sqrt{t}\\int_{a^2t}^\\infty e^{-tv} v^{\\frac{-3}{2}}\\,dv\n    = \\frac{1}{2}\\sqrt{t}\\,\\Gamma(-\\frac{1}{2},a^2 t),\n\\end{equation}\nwhere $\\Gamma(\\alpha, z)$ is the upper incomplete gamma function.\n\nFor real $\\alpha<1$ and $z>0$, \\textcite[][Theorem 2.3]{borwein2009} give the upper bound\n\\[\n    \\Gamma(\\alpha, z) \\leq z^{\\alpha-1} e^{-z}.\n\\]\nSubstituting into \\eqref{eq:gbar} gives\n\\begin{equation}\n    \\begin{aligned}\n        \\bar{g}_n(x,t)\n            & < \\frac{1}{L}e^{-t}\\sqrt{t}\\,\\Gamma(-\\frac{1}{2},a_n^2 t) \\\\\n            & \\leq \\frac{1}{L}e^{-t}\\sqrt{t}\\,(a_n^2 t)^{-\\frac{3}{2}}e^{-a_n^2t} \\\\\n            & = \\frac{e^{-t(1+a_n^2)}}{L t a_n^3}.\n    \\end{aligned}\n\\end{equation}\n\n\\printbibliography\n\\end{document}\n", "meta": {"hexsha": "888aa8a11890879818e2964ba4644744e434ab79", "size": 11321, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/math/passive_cable/cable_computation.tex", "max_stars_repo_name": "kabicm/arbor", "max_stars_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/math/passive_cable/cable_computation.tex", "max_issues_repo_name": "kabicm/arbor", "max_issues_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/math/passive_cable/cable_computation.tex", "max_forks_repo_name": "kabicm/arbor", "max_forks_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8338461538, "max_line_length": 96, "alphanum_fraction": 0.6217648618, "num_tokens": 4095, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4102067672265197}}
{"text": "\\documentclass{beamer}\n\n\\mode<presentation> {\n  \\usetheme{Madison}\n%    \\usetheme[left,hideallsubsections,width=1cm]{UWThemeB}\n  \\usefonttheme[onlymath]{serif}\n}\n\n% % % % to make navigation two lines\n\\usepackage{ragged2e}\n\n\\makeatletter\n\\setbeamertemplate{section in head/foot}{%\n    \\parbox[c][0.33cm][t]{\\dimexpr(\\textwidth-1.3cm)/\\beamer@sectionmax\\relax}{%\n        \\RaggedRight\\fontsize{4}{4}\\selectfont\\insertsectionhead}}\n\\setbeamertemplate{footline}[frame number]\n\\makeatother\n% % % %\n\\usepackage{booktabs, calc, rotating}\n\\usepackage{scalefnt}\n\\usepackage[english]{babel}\n\\usepackage[latin1]{inputenc}\n\\usepackage{times}\n%\\usepackage[T1]{fontenc}\n\\usepackage{alltt}\n\n  \\setbeamertemplate{navigation symbols}{}\n  \\setbeamertemplate{blocks}[rounded][shadow=true]\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%  CHANGE THE TITLE AND INPUT FILE ACCORDING TO THE CHAPTER THAT YOU WISH TO COMPILE\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\title[Severity]{Severity Distributions}\n\n\\date[Fall 2017]{Fall 2017}\n%Personal definitions - Bayes Regression\n\\def\\bsb{\\boldsymbol \\beta}\n\\def\\bsa{\\boldsymbol \\alpha}\n\\def\\bsm{\\boldsymbol \\mu}\n\\def\\bsS{\\boldsymbol \\Sigma}\n\\def\\bsx{\\boldsymbol \\xi}\n\n\\begin{document}\n\n\\frame{\\titlepage}\n\n\\begin{frame}\n  \\frametitle{Outline}\n    %\\tableofcontents[part=1,pausesections]\n     \\tableofcontents[part=1]\n\\end{frame}\n\n\\part<presentation>{Main Talk}\n\n\n\\section[Foundations]{Severity Distributions Foundation}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Important Severity Distributions}\n\nThree important loss severity distributions: \\vspace{2mm}\n\\begin{itemize}\n\\item \\textbf{Gamma}\n\\begin{itemize}\n\\item Fits medium tail lines like physical damage auto and homeowners well\n\\item Member of the ``exponential family of distributions''. This means that it is easy to incorporate rating variables into the distribution via generalized linear modeling\n(GLMs) \\vspace{2mm}\n\\end{itemize}\n\\item \\textbf{Pareto}\n\\begin{itemize}\n\\item Fits longer tail lines like injury liability in auto and workers' compensation well\n\\item Simple to work with analytically (hence can provide intuition as we develop theory and explain the theory to\nothers) \\vspace{2mm}\n\\end{itemize}\n\\item \\textbf{GB2 - Generalized Beta of the Second Kind}\n\\begin{itemize}\n\\item A four parameter distribution family, complex\n\\item Yet, many severity distributions can be expressed as a special case of this distribution (good for programming)\n\\item Some applications have been fit well by the GB2 where others do not seem to\nwork \\vspace{2mm}\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Gamma Distribution}\n\n\\begin{itemize}\\scalefont{0.9}\n\\item The gamma distribution has two parameters,  $\\alpha$ and $\\theta$ %\\vspace{2mm}\n\n\\item The probability density function is 0 for $x \\le 0$ and for $x>0$\n\\begin{eqnarray*}\nf(x) &=& \\frac{(\\frac{x}{\\theta})^{\\alpha} e^{-x/\\theta}}{x\\Gamma(\\alpha)} = \\frac{1}{\\theta^{\\alpha} \\Gamma(\\alpha)} x^{\\alpha - 1} e^{-x/\\theta}\n\\end{eqnarray*} %\\vspace{2mm}\n\n\\item If $\\alpha=1$, the gamma reduces to the familiar \\textit{exponential} distribution\n%\\vspace{2mm}\n\\item The function $\\Gamma(\\cdot)$ is known as the \\textit{gamma function}, defined as\n\\begin{equation*}\n\\Gamma(\\alpha) =  \\int_0^{\\infty} x^{\\alpha-1} e^{-x} ~dx\n\\end{equation*} %\\vspace{2mm}\n\\item Some important facts about the gamma function: %\\vspace{2mm}\n\n\\begin{itemize}\\scalefont{0.9}\n\\item For a positive integer $n$, $\\Gamma(n) = (n-1)!$ %\\vspace{2mm}\n\n\\item For more general arguments, one needs to rely on numerical integration to evaluate $\\Gamma(\\cdot)$. The two main exceptions are:\n\\begin{itemize}\\scalefont{0.9}\n\\item For any $\\alpha>0$, $\\Gamma(\\alpha+1)=\\alpha\\Gamma(\\alpha)$\n\\item $\\Gamma(0.5)=\\sqrt{\\pi}$\n\\end{itemize}\\end{itemize}\nThus, for example, $\\Gamma(2.5)=1.5 \\Gamma(1.5) = 1.5 (0.5)\n\\Gamma(0.5) = \\frac{3}{4} \\sqrt{\\pi} $\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Exercise} \\emph{Example.} Suppose that $X \\sim\ngamma(\\alpha=2, \\theta=100)$, that is, the random variable $X$ has a\ngamma distribution with parameters $\\alpha=2$ and  $\\theta=100$\n\\vspace{2mm}\n\nDetermine $\\Pr(X \\le 60)$\n\n\\end{frame}\n\n%\\begin{frame}[shrink=2]\n%\\frametitle{Incomplete Gamma Function}\n%\\begin{itemize}\n%   \\item More generally, we define the \\textit{incomplete gamma function}\n%\\begin{equation*}\n%\\Gamma(\\alpha;x) =  \\int_0^x t^{\\alpha-1} e^{-t} ~dt\n%\\end{equation*} \\vspace{2mm}\n\n%\\item With this, we may express the gamma distribution function as\n%\\begin{equation*}\n%F(x) = \\Gamma(\\alpha; \\frac{x}{\\theta}),\n%\\end{equation*}\n%so that computing the gamma distribution function is evaluating the\n%incomplete gamma function at a rescaled value of $x$ \\vspace{2mm}\n\n%\\begin{itemize}\\item In general, this is done via numerical integration\n%\\item However, when $\\alpha$ is a positive integer, one can use integration by parts as in the preceding example to get:\n%\\begin{equation*}\n%\\Gamma(\\alpha; x) = 1 - \\sum_{j=0}^{\\alpha-1} ~ \\frac{x^j\n%e^{-x}}{j!}\n%\\end{equation*}\n%In their book, KPW have this as Theorem A.1 \\vspace{2mm}\n%\\end{itemize}\n%\\item \\emph{Example - Continued.} Suppose that $X \\sim gamma(\\alpha=2, \\theta=100)$. Determine $\\Pr(X \\le 60)$.\n%\\end{itemize}\n%\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Gamma Moments} Use the gamma function to calculate\nmoments of a gamma distribution \\vspace{2mm}\n\\begin{itemize}\n\\item Define the $k$th \\textit{raw moment} to be\n\\begin{eqnarray*}\n\\mu_k^{\\prime} &=& \\mathrm{E~} X^k = \\int_0^{\\infty} x^k f(x) dx\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item Using a change of variable, $t=x/\\theta$, we have\n\\begin{eqnarray*}\n\\mu_k^{\\prime}\n&=& \\frac{1}{\\theta^{\\alpha} \\Gamma(\\alpha)} \\int_0^{\\infty} x^{\\alpha+k-1} \\exp(-x/\\theta) ~dx \\\\\n&=& \\frac{\\theta^{\\alpha+k}}{\\theta^{\\alpha} \\Gamma(\\alpha)} \\int_0^{\\infty} t^{\\alpha+k-1} \\exp(-t) dt \\\\\n&=& \\frac{\\theta^k }{\\Gamma(\\alpha)} \\Gamma(\\alpha+k).\n\\end{eqnarray*} \\vspace{2mm}\n\\item With $k=1$, we have $\\mu = \\mu_1^{\\prime}\n= \\theta \\frac{\\Gamma(\\alpha+1)}{\\Gamma(\\alpha)} = \\alpha \\theta$\n\\vspace{2mm}\n\\item Check that:\n\\begin{itemize}\n\\item $ \\mu_2^{\\prime} = \\theta^2 \\alpha (\\alpha+1), $ \\hspace{0.2in} $ \\mathrm{Var}(X)  =\\theta^2\n\\alpha,\n$ \\hspace{0.2in} $\\mu_k^{\\prime} = \\theta^k(\\alpha+k-1) \\cdots\n\\alpha$\n\\end{itemize}\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Gamma Moment Generating Function}\n\\begin{itemize}\n\\item The gamma moment generating function (mgf) is\n\\begin{eqnarray*}\nM(t) = \\mathrm{E~} e^{tX} &=& \\frac{1}{\\theta^{\\alpha}\\Gamma(\\alpha)}\\int_0 ^{\\infty} x^{\\alpha-1} e^{tx} e^{-x/\\theta} dx\\\\\n&=& \\frac{1}{\\theta^{\\alpha}\\Gamma(\\alpha)}\\int_0 ^{\\infty} x^{\\alpha-1} \\exp\\left\\{-x\\left(\\frac{1-\\theta t}{\\theta}\\right)\\right\\} dx\\\\\n&=& \\frac{1}{\\theta^{\\alpha}\\Gamma(\\alpha)} \\left(\\frac{\\theta}{1-\\theta t}\\right)^{\\alpha} \\Gamma(\\alpha)\\\\\n&=& (1 - \\theta t)^{-\\alpha} .\n\\end{eqnarray*}\n\\item To check this result, first note that $M(0) = (1 - \\theta 0)^{-\\alpha} = 1$, as anticipated. Next, taking derivatives, we have\n\\begin{eqnarray*}\nM^{\\prime}(t) = \\frac{\\partial}{\\partial t} M(t) &=& -\\alpha (1 - \\theta t)^{-\\alpha - 1}(-\\theta) = \\alpha \\theta (1 - \\theta t)^{-\\alpha - 1}\n\\end{eqnarray*}\n\\item Evaluating this at 0 yields $M^{\\prime}(0) = \\alpha \\theta =\\mu$, as anticipated\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Pareto Distribution}\n\\begin{itemize}\\scalefont{0.9}\n\\item The Pareto with parameters $\\alpha$ and $\\theta$ has probability density function:\n\\begin{eqnarray*}\n\\mathrm{f}(x) = \\frac{\\alpha \\theta^{\\alpha}}{(x+\\theta)^{\\alpha+1}}\n\\end{eqnarray*} %\\vspace{2mm}\nand moments\n\\begin{eqnarray*}\n\\mu_k^{\\prime}= \\frac{\\theta^k k!}{(\\alpha-1) \\cdots (\\alpha-k)}\n\\end{eqnarray*} %\\vspace{2mm}\n\\item Because moments are not finite when $k \\ge \\alpha$, the moment generating function is not well-defined %\\vspace{2mm}\n\\item Unlike the gamma, there is a simple expression for the distribution function\n\\begin{eqnarray*}\n\\mathrm{F}(x) &=& \\int^x_0 \\mathrm{f}(y) dy = 1 -\n\\left(\\frac{\\theta}{x+\\theta}\\right)^{\\alpha}\n\\end{eqnarray*} %\\vspace{2mm}\n\\item This means that it is easy to compute quantiles\n\\begin{itemize}\\scalefont{0.9}\n\\item For example, find $x$ so that 0.95 = F(x) (the 95th percentile) %\\vspace{2mm}\n\\item Easy calculations show that this is $\\theta \\left[(0.05)^{-1/\\alpha} - 1\\right]$ %\\vspace{2mm}\n\\item In general, the $p$th percentile/quantile is $\\theta \\left[(1-p)^{-1/\\alpha} - 1\\right]$\n\\end{itemize}\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{GB2 - Generalized Beta of the Second Kind}\n\\begin{itemize}\n\\item In KPW, the GB2 is known as a \\textit{transformed beta\ndistribution} \\vspace{2mm}\n\n\\item The pdf (KPW, Appendix A2.1.1) is\n\\begin{eqnarray*}\nf(x) &=& \\frac{\\Gamma(\\alpha + \\tau)}{\\Gamma(\\alpha)\\Gamma(\\tau)}\n   \\frac{\\gamma (x/\\theta)^{\\gamma \\tau}}\n   {x\\left[1+(x/\\theta)^{\\gamma}\\right]^{\\alpha + \\tau}}\n\\end{eqnarray*} \\vspace{2mm}\n\nwith moments\n\\begin{eqnarray*}\n\\mathrm{E~}X^k &=& \\theta^k \\frac{\\Gamma(\\tau + \\frac{k}{\\gamma})\\Gamma(\\alpha-\\frac{k}{\\gamma})}{\\Gamma(\\alpha)\\Gamma(\\tau)} .\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item In the text by Frees on Regression, the GB2 distribution is cited but with the parameters\n$\\alpha_1  = \\alpha$, $\\alpha_2  =\\tau$, $\\gamma = 1/\\sigma$,\n$\\theta = e^\\mu$\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{GB2 Special Cases} The GB2 a four parameter family of\ndistributions that captures many other distributions, either as\nspecial cases or as limiting results: \\vspace{2mm}\n\n\\begin{itemize}\n\\item \\textit{Special Case: Burr Distribution}. Use the GB2 distribution with $\\tau =\n1$ \\vspace{2mm}\n\n\\item \\textit{Special Case: Pareto Distribution}. Use the GB2 distribution with $\\gamma=\\tau =\n1$ \\vspace{2mm}\n\n\\item \\textit{Limiting Case: Generalized Gamma Distribution} \\vspace{2mm}\n\nReplace $\\theta$ by $\\theta \\tau^{1/\\gamma}$ \\vspace{2mm}\n\nThen, one can show that\n\\begin{eqnarray*}\n\\lim_{\\tau \\to \\infty} f_{GB2}(x; \\theta \\tau^{1/\\gamma}, \\alpha, \\tau, \\gamma) = f(x),\n\\end{eqnarray*}\nthe pdf of a \\textit{generalized gamma}. In KPW, Appendix A.3.1,\np.673, the generalized gamma is called a \\emph{transformed gamma}\n\\end{itemize}\n\\end{frame}\n\n\n\\section{Creating Distributions Using Transformations}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Creating Distributions Using Transformations} There are\nmany distributions available to the analyst \\vspace{2mm}\n\n\\begin{itemize}\n\\item In this section, we consider distributions that are created by transforming the random variable of a distribution.\nSpecifically: \\vspace{2mm}\n\n\\begin{itemize}\n\\item  Multiplication by a constant ($Y = cX$) \\\\\n\\item Raising to a power ($Y = X^\\tau$)\\\\\n\\item Exponentiation $(Y = e^X)$\\\\\n\\end{itemize}\\vspace{2mm}\n\n\\item In the next section, we consider ways of combining distributions to form a distribution of interest. Specifically: \\vspace{2mm}\n\n\\begin{itemize}\n\\item Mixing\n\\item Splicing\n\\end{itemize}\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Multiplication by a Constant}\n\\begin{itemize}\n\\item Multiplying a random variable by a positive constant is a simple type of\ntransformation \\vspace{2mm}\n\n\\item It is also easy to interpret: \\vspace{2mm}\n\n\\begin{itemize}\n\\item Think of $X$ as this year's losses and assume that we have an 8\\% inflation rate. Then, we can model next year's losses as $Y =\n1.08X$ \\vspace{2mm}\n\n\\item We also want to readily go from dollars to thousands of dollars ($c=1/1000$) or from dollars to Euros (or swapping any set of\ncurrencies) \\vspace{2mm}\n\n\\end{itemize}\n\\item More generally, let $Y=cX$ and use\n\\begin{eqnarray*}\nF_Y (y) &=& \\Pr( Y \\le y) = \\Pr \\left(X \\le \\frac{y}{c}\\right)= F_X \\left(\\frac{y}{c}\\right)\\\\\nf_Y (y) &=& \\frac{1}{c}~f_X\\left(\\frac{y}{c}\\right)\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Scale Distributions}\n\\begin{itemize}\\scalefont{0.9}\n\\item In a location-scale distribution, the transformed variable $Y = c(X-a)$ has a distribution from the same family as the random variable $X$ %\\vspace{2mm}\n\\begin{itemize}\\scalefont{0.9}\n\\item Here, $a$ and $c>0$ are constants\n\\item The normal distribution is the usual example %\\vspace{2mm}\n\\end{itemize}\n\\item In a scale distribution,  the transformed variable $Y = c X$ has a distribution from the same family as the random variable $X$ %\\vspace{2mm}\n\\begin{itemize}\\scalefont{0.9}\n\\item Many loss distributions are scale distributions\n\\item Typically, one uses $\\theta$ as the scale parameter. If $X$ comes from a distribution with parameter $\\theta$, then $Y = c X$ has the same distribution with scale parameter $\\theta^{\\ast} = c \\theta$ %\\vspace{2mm}\n\\end{itemize}\n\\item \\textit{Example: Special Case - Gamma Distribution}. Suppose that $X$ has a gamma distribution with $\\alpha = 4$ and $\\theta = 10,000$ %\\vspace{2mm}\n\\begin{itemize}\\scalefont{0.9}\n\\item The mean is $\\alpha \\theta = 40,000$ and the standard deviation is $\\theta \\sqrt{\\alpha} = 20,000$ %\\vspace{2mm}\n\\item Suppose that $Y = X/1000$\n\\begin{itemize}\\scalefont{0.9}\n\\item This has mean 40 and standard deviation 20\n\\item Further $Y$ has a gamma distribution with parameters $\\alpha = 4$ and $\\theta^{\\ast} = \\theta/1000 = 10$\\end{itemize}\n\\end{itemize}\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=.5]\n\\frametitle{Raising to a Power}\n\\begin{itemize}\\scalefont{0.9}\n\\item Another type of transformation involves raising the random variable to a power, say, $\\tau$ %\\vspace{2mm}\n\\item Consider the transformed random variable $Y = X^{\\tau}$. We examine three cases: %\\vspace{2mm}\n\\scalefont{0.9}\n\\begin{eqnarray*}\n&\\tau>0&  \\text{transformed}\\\\\n&\\tau=-1 &  \\text{inverse}\\\\\n&\\tau<0 & \\text{inverse transformed}\n\\end{eqnarray*}\\scalefont{1.1111} %\\vspace{2mm}\n\\item \\textit{Special Case: Exponential Distribution}. Suppose that $X$ has an exponential distribution with parameter $\\theta^{\\ast}$ and consider $Y=1/X$ %\\vspace{2mm}\n\\begin{itemize}\\scalefont{0.9}\n\\item The distribution function of $Y$ is\n\\begin{eqnarray*}\n\\Pr(Y \\le y) &=& \\Pr(\\frac{1}{X} \\le y) = \\Pr(\\frac{1}{y} \\le X) = \\exp\\left(-\\frac{1}{y \\theta^\\ast}\\right) .\n\\end{eqnarray*}\n\\item Now, define a new parameter $\\theta = \\frac{1}{\\theta^{\\ast}}$. With this notation,\n\\begin{eqnarray*}\n\\Pr(Y \\le y) &=& \\exp\\left(-\\frac{\\theta}{y}\\right).\n\\end{eqnarray*}\n\\item This distribution is known as an \\textit{inverse exponential distribution} with parameter $\\theta$. See the appendix of KPW\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Exponential to get a Weibull}\n\\textit{Example: Transforming an Exponential to get a Weibull}.\n\\begin{itemize}\n\\item Start with $X \\sim $ exponential distribution with parameter 1. Define the transformed random\nvariable:\n\\begin{eqnarray*}\nY = \\theta X^{1/\\tau}\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item This has distribution\n\\begin{eqnarray*}\nF_Y(y) &=& \\Pr(Y \\le y)\\\\\n&=& \\Pr(X^{1/\\tau} \\le \\frac{y}{\\theta}) = \\Pr(X \\le (\\frac{y}{\\theta})^{\\tau})\\\\\n&=& 1 - \\exp\\left(-(\\frac{y}{\\theta})^\\tau\\right) ,\n\\end{eqnarray*}\nknown as a \\textit{Weibull distribution} \\vspace{2mm}\n\n\\item This result will be handy if you want to \\emph{simulate} outcomes from a Weibull distribution in Excel (exponential simulation is easy, Weibull is not available)\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Transforming the Pareto Distribution} This is from KPW\nExercise 5.3. We assume that $X \\sim$  Pareto with parameters\n$(\\alpha, \\theta)$ and consider the transformed variable $Y =\nX^{1/\\tau}$. We wish to determine the df of $Y$ when $\\tau$ is\npositive, equal to -1, and negative\n\n\\bigskip\n\n\\textit{Solution.} Begin by recalling the df of the Pareto\n\\begin{eqnarray*}\n\\mathrm{F}_X (x) &=& 1 - \\left(\\frac{\\theta}{x+\\theta}\\right)^{\\alpha} .\n\\end{eqnarray*}\n\n\\textit{Case} \\textcircled{1}. Assume $\\tau > 0$. Then,\n\\begin{eqnarray*}\n\\mathrm{F}_Y (y) &=& \\Pr (X^{1/\\tau} \\le y ) = \\Pr (X \\le y^\\tau ) \\\\\n& =& \\mathrm{F}_X (y^\\tau)\\\\\n&=& 1 - \\left(\\frac{\\theta}{y^\\tau+\\theta}\\right)^{\\alpha} .\n\\end{eqnarray*}\nNow, define the new parameter $\\theta^{\\ast} = \\theta^{1/\\tau} $ so that $\\theta^{\\ast \\tau} = \\theta$. With this notation, we have\n\\begin{eqnarray*}\n\\mathrm{F}_Y (y) &=& 1 - \\left(\\frac{\\theta^{\\ast \\tau}}{y^{\\tau}+\\theta^{\\ast \\tau}}\\right)^{\\alpha} .\n\\end{eqnarray*}\nThis is known as a \\emph{Burr distribution} with parameters $\n(\\alpha, \\theta^{\\ast}, \\tau = \\gamma)$\n\\end{frame}\n\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Exponentiation}\n\\begin{itemize}\\scalefont{0.9}\n\\item Another type of transformation involves exponentiating a random variable so that $Y=\\exp(X)$ %\\vspace{2mm}\n\\item The main example of this is the normal distribution. If $X \\sim$ normal, then $Y=e^{X} \\sim $ a \\textit{lognormal\ndistribution} %\\vspace{2mm}\n\\item We can develop the distribution of the new random variable through the relation with the df\n\\begin{eqnarray*}\nF_Y (y) = \\Pr ( \\exp(X) \\le y) = \\Pr( X \\le \\ln y) = F_X (\\ln y)\n \\end{eqnarray*} %\\vspace{2mm}\nand the pdf\n\\begin{eqnarray*}\nf_Y (y) = \\frac{1}{y} f_X (\\ln y) .\n \\end{eqnarray*} %\\vspace{2mm}\n\\item Remark. This provides a way to simulate a Pareto distribution, by first simulating an exponential random variable and then transforming it\n\\end{itemize}\n\n\\end{frame}\n\n\n\n\\section{Creating Distributions by Mixing}\n\n\\subsection{Motivation}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Motivation for Mixing}\n\\begin{itemize}\n\\item In a mixture distribution,  the outcome (random variable) can be thought of as a random draw from a population of\noutcomes \\vspace{2mm}\n\n\\item \\textit{Example: Pareto Distribution}. Consider the Pareto distribution with survival function\n\\begin{eqnarray*}\nS(x) = \\left(\\frac{\\theta}{x+\\theta}\\right)^\\alpha,\n\\end{eqnarray*}\nand mean $ \\mathrm{E~}X = \\frac{\\theta}{\\alpha-1}$. Let us think\nabout two types of populations: \\vspace{2mm}\n\n$X_1 \\sim \\text{Pareto} (\\alpha_1, \\theta_1)$ \"Good Driver\"\n\n$X_2 \\sim \\text{Pareto} (\\alpha_2, \\theta_2)$ \"Bad Driver\"\n\\vspace{2mm}\n\n\\item Suppose that with probability $a$ we draw the loss from a good driver, $X_1$, and with probability $1-a$ we draw the loss from a bad driver,\n$X_2$:\n\\begin{eqnarray*}\nY =\n\\begin{cases}\nX_1 & \\text{with probability~} a\\\\\nX_2 &  \\text{with probability~} 1-a\n\\end{cases}\n\\end{eqnarray*} \\vspace{2mm}\n\nOur interest is in the distribution of $Y$\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Mixing Moments}\n\\begin{itemize}\n\\item To begin, focus on the mean. Using the law of total\nexpectations: \\vspace{2mm}\n\n\\begin{eqnarray*}\n\\mathrm{E~}Y = a\\mathrm{E~}X_1 + (1-a)\\mathrm{E~}X_2 = a \\frac{\\theta_1}{\\alpha_1-1} +  (1-a) \\frac{\\theta_2}{\\alpha_2-1} .\n\\end{eqnarray*} \\vspace{2mm}\n\nWe can also write \\vspace{2mm}\n\n\\begin{eqnarray*}\n\\hspace{-0.8in}Y^2 =\n\\begin{cases}\nX_{1}^2 & \\text{with probability~} a\\\\\nX_{2}^2 &  \\text{with probability~} 1-a\n\\end{cases}\n\\end{eqnarray*} \\vspace{2mm}\n\nThus, we have \\vspace{2mm}\n\n\\begin{eqnarray*}\n\\mathrm{E~}Y^2 = a\\mathrm{E~}X_{1}^2 + (1-a)\\mathrm{E~}X_{2}^2 .\n\\end{eqnarray*} \\vspace{2mm}\n\nThe same argument holds for any moment\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Mixing Distribution Function}\n\\begin{itemize}\n\\item For the distribution function, we have \\vspace{2mm}\n\\begin{eqnarray*}\n\\Pr(Y \\le y) &=& \\Pr(Y \\le y, \\text{Good Driver}) + \\Pr(Y \\le y, \\text{Bad Driver})\\\\\n&=& \\Pr(X_1 \\le y, \\text{Good Driver}) + \\Pr(X_2 \\le y, \\text{Bad Driver})\\\\\n&=& \\Pr(X_1 \\le y)\\Pr(\\text{Good Driver}) + \\Pr(X_2 \\le y)\\Pr(\\text{Bad Driver})\\\\\n&=& a F_{X_1}(y) + (1-a) F_{X_2}(y)\n\\end{eqnarray*}\n\\end{itemize} \\vspace{4mm}\n\n\\textit{Example from Exam M Spring 05 \\#34}. Suppose that $a$ = 0.8,\nand $X_1 \\sim \\text{Pareto}(\\alpha = 2, \\theta = 100), X_2 \\sim\n\\text{Pareto}(\\alpha = 4, \\theta = 3000)$ \\vspace{2mm}\n\nDetermine $\\Pr(Y \\le 200)$\n\\end{frame}\n\n\n\n\\subsection{Finite Mixture Distributions}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Finite Mixture Distributions}\n\\begin{itemize}\\scalefont{0.9}\n\\item \\emph{Definition.} Let $X_1, \\ldots, X_k$ be random variables and define\n\\begin{eqnarray*}\nY =\\left\\{\n\\begin{array}{cc}\nX_1 & with~probability~a_1 \\\\\n\\vdots & \\vdots \\\\\nX_k & with~probability~a_k \\\\\n\\end{array}\n\\right.\n\\end{eqnarray*}\nHere, $a_{j}>0$ and $ a_1+ \\cdots + a_k = 1.$ Then, $Y$ is a $k$-point mixture random variable. The df is\n\\begin{eqnarray*}\nF_Y(y) = a_1 F_{X_1}(y)+ \\cdots +a_k F_{X_k}(y)\n\\end{eqnarray*}\nwith mean\n\\begin{eqnarray*}\n\\mathrm{E~}Y = a_1 \\mathrm{E~}X_1 + \\cdots + a_k \\mathrm{E~}X_k.\n\\end{eqnarray*}\n\\item If $k$ is unknown (but not random), then this a \\emph{variable component mixture\ndistribution} %\\vspace{2mm}\n\\item We can always select one or more of the underlying $X_j$ variables to be degenerate (that is, equal to a number with probability one). In this way, we can use the finite mixture framework to create discrete and mixed distributions\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Exponential Example}\n\\textit{Example}. Suppose, for a fixed parameter $\\theta$, that\n$X|\\theta \\sim$ exponential with parameter $\\theta$. Thus,\n\\begin{equation*}\n\\Pr(X \\le x | \\theta) = 1 - e^{-x/\\theta}.\n\\end{equation*} \\vspace{2mm}\n\nNow, think of two populations, each having an exponential\ndistribution, but with different parameter values. For concreteness,\nassume\n\\begin{equation*}\n \\Theta =\n\\begin{cases}\n10 &  \\text{with prob~}\\alpha\\\\\n200 & \\text{with prob~}(1-\\alpha)\\\\\n\\end{cases}\n\\end{equation*} \\vspace{2mm}\n\nAs with the $x$'s, we use an upper case $\\Theta$ for a random\nvariable and a lower case $\\theta$ for a realization of the random\nvariable\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Exponential Example II}\n\\begin{itemize}\n\\item Using the discrete mixing framework, we may write the df of $X$ as\n\\begin{equation*}\n\\Pr(X \\le x) = \\alpha(1 - e^{-x/10}) + (1-\\alpha)(1-e^{-x/200}) .\n\\end{equation*} \\vspace{2mm}\n\n\\item More generally, we can consider $k$ populations, each with the same\nform of the distribution function $\\mathrm{F}(\\cdot|\\theta)$ and\nallow $\\theta$ to vary as\n\\[\n\\Theta=\\left\\{\n\\begin{array}{ll}\n\\theta_1  & \\text{prob~} \\alpha_1  \\\\\n\\theta_2  & \\text{prob~} \\alpha_2  \\\\\n\\vdots & \\vdots \\\\\n\\theta_K & \\text{prob~} \\alpha_K \\\\\n\\end{array}\n\\right.\n\\] \\vspace{2mm}\n\nThis is our \\textit{finite mixture} distribution\n\\end{itemize}\n\\end{frame}\n\n\\subsection{Continuous Mixtures}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Continuous Mixtures}\n\\begin{itemize}\n\\item Extend this idea by thinking about an infinite number of\npopulations, each with a conditional distribution function that has\nthe same structure $\\mathrm{F}(\\cdot|\\theta)$ (e.g., exponential)\nbut with a parameter $\\theta$ that accounts for population\ndifferences \\vspace{2mm}\n\n\\item Assume that the random variable $\\Theta$ has pdf $f_\\Theta\n(\\theta)$ \\vspace{2mm}\n\n\\item Then, the df is:\n\\begin{eqnarray*}\n\\mathrm{F}_X(x) = \\Pr(X \\le x) &=& E_{\\Theta} \\Pr(X \\le x|\\Theta)\\\\\n&=& \\int \\Pr(X \\le x|\\theta)f_{\\Theta}(\\theta) d\\theta =\\int\n\\mathrm{F}(x|\\theta)f_{\\Theta}(\\theta) d\\theta\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item The pdf is:\n\\begin{eqnarray*}\nf_X (x) &=& \\int f_{x | \\theta}(x) f_{\\Theta}(\\theta) d\\theta\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Special Case: Gamma Mixtures of Exponentials}\n\\begin{itemize}\\scalefont{0.9}\n\\item \\textit{Special case: Gamma Mixtures of Exponentials}. Suppose that each population has an exponential distribution with parameter $1/\\theta$, that is, $X|\\theta \\sim \\text{exponential}(\\frac{1}{\\theta})$:\n\\begin{eqnarray*}\nf_{X|\\theta}(x) &=& \\theta e^{-\\theta x}\n\\end{eqnarray*} %\\vspace{2mm}\n\\item Suppose that the distribution of population parameters is governed by a gamma distribution such that $\\Theta \\sim \\text{gamma}(\\alpha, \\beta)$ %\\vspace{2mm}\n\\begin{eqnarray*}\nf_{\\theta}(\\theta) &=&\n\\frac{1}{\\Gamma(\\alpha)\\beta^{\\alpha}}\\theta^{\\alpha-1}e^{-\\theta/\\beta}\n\\end{eqnarray*} %\\vspace{2mm}\n\n\\item The pdf of $X$ is\n\\begin{eqnarray*}\nf_X (x) &=&\\int f_{x | \\theta}(x) f_{\\Theta}(\\theta) d\\theta \\\\\n&=& \\frac{1}{\\Gamma(\\alpha)\\beta^{\\alpha}}\\int_0 ^{\\infty}\n\\theta^{\\alpha} e^{{-\\theta}(x+1/\\beta)}d\\theta = \\frac{\\alpha\n\\beta}{(1+x\\beta)^{\\alpha+1}}\n\\end{eqnarray*} %\\vspace{2mm}\n\\item We recognize this as a Pareto distribution with parameters $\\alpha$ and $\\theta=1/\\beta $\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Mixture Expectations}\n\\begin{itemize}\n\\item For some mixtures such as the above example, we can compute the\nmixture distribution in closed-form \\vspace{2mm}\n\n\\item However, it is often helpful to\njust consider the moments. For the mean function, using the\n\\textit{law of iterated expectations}, we have\n\\begin{eqnarray*}\n\\mathrm{E~}X &=& \\mathrm{E}_{\\Theta}[\\mathrm{E}(X|\\Theta)]\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item This is easily extended to the $k$th moment\n\\begin{eqnarray*}\n\\mathrm{E~}X^k &=& \\mathrm{E}_{\\Theta}[\\mathrm{E}(X^k|\\Theta)]\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\n\\bigskip\n\\begin{frame}[shrink=2]\n\\frametitle{Mixture Expectations Example}\n\\textit{Example. Gamma Mixtures of Exponentials}.\n\\begin{itemize}\n\\item Assume that $X|\\theta \\sim$ exponential with parameter $(\\frac{1}{\\theta})$. Thus, the mean is $\\mathrm{E}(X|\\theta) =\n1/\\theta$, the second raw moment is $\\mathrm{E}(X^2|\\theta) =\n2/\\theta^2$, and the variance is $\\mathrm{Var}(X|\\theta) = 1/\n\\theta^2$ \\vspace{2mm}\n\n\\item For the parameter distribution, we have $\\theta \\sim \\text{gamma}(\\alpha,\n\\beta)$ \\vspace{2mm}\n\n\\item One can check that\n\\begin{eqnarray*}\n\\mathrm{E~}X = \\frac{1}{\\beta(\\alpha-1)}\n\\end{eqnarray*}\nand\n\\begin{eqnarray*}\n\\mathrm{Var~}X = \\frac{\\alpha}{\\beta^2(\\alpha-1)^2(\\alpha-2)}\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item This is consistent with a Pareto distribution with parameters $\\alpha$ and $\\theta=1/\\beta $ (good practice to check)\n\\end{itemize}\n\\end{frame}\n\n\\subsection{Splicing}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Splicing}\n\\begin{itemize}\n\\item Join (splice) together different probability density functions to form a pdf over the support of a random\nvariable \\vspace{2mm}\n\\[\nf_X (x)=\\left\\{\n\\begin{array}{ll}\n\\alpha_1 f_1 (x) & c_0  < x < c_1  \\\\\n\\alpha_2 f_2 (x) & c_1  < x < c_2  \\\\\n\\vdots & \\vdots \\\\\n\\alpha_{k}f_{k}(x) & c_{k-1} < x < c_{k}  \\\\%\n\\end{array}%\n\\right.\n\\]% \\vspace{2mm}\n\n$\\alpha_1  + \\alpha_2  \\cdots + \\alpha_{k} = 1$\\\\ \\vspace{2mm}\n\nEach $f_j$ is a pdf, so that $\\int_{c_{j-1}}^{c_{j}}f_{j}(x)dx =\n1$\\\\ \\vspace{2mm}\n\n$c_{j}$'s are typically known\\\\ \\vspace{2mm}\n\n\\item \\textit{Example: Life Contingencies}.\n\\begin{itemize}\\item It is common to use an exponential distribution in the early ages, e.g., from $x=5$ to $x=40$. The exponential has a constant hazard rate and is well suited to model mortality from\naccidents \\vspace{2mm}\n\n\\item Beginning at age $x=40$, one use another mortality law, e.g., Gompertz, that reflects mortality that increases with age $x$\n\\end{itemize}\\end{itemize}\n\\end{frame}\n\n\n\\section{Risk Retention -- Deductibles and Limits}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Risk Retention Framework}\n\\begin{itemize}\n\\item Now consider the following framework: \\vspace{2mm}\n\n\\begin{itemize}\n\\item The policyholder or insured suffers a loss in the amount $X$ \\vspace{2mm}\n\n\\item Under the insurance contract, the insurer is obligated to covered a portion of this\namount \\vspace{2mm}\n\n\\item The insurer may have entered into a separate contract with a reinsurer that relieves the insurer of a portion of its\nobligations \\vspace{2mm}\n\\end{itemize}\n\n\\item This section introduces standard mechanisms that insurers use to reduce, or mitigate, their risk, including deductibles and policy\nlimits \\vspace{2mm}\n\n\\item Further, we examine how the distribution of the insurers obligations depends on these mechanisms\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Risk Retention Function}\n\\begin{itemize}\\scalefont{0.8}\n\\item Recall that $X$ represents the amount of an insurable loss and use $Y$ to represent the insurer's\nobligation %\\vspace{2mm}\n\\item There is a known function $g(\\cdot)$ that maps the amount insured to the amount retained by the insurer, that is, $Y=g(X)$ %\\vspace{2mm}\n\\item \\textbf{Special Case 1. Deductible (d)} %\\vspace{2mm}\n\\begin{equation*}\ng(x) = (x-d)_+ =\n\\begin{cases}\n0 & x \\le d\\\\\nx - d & x > d .\n\\end{cases}\n\\end{equation*}\nThe notation ``$(\\cdot)_+$'' means ``take the positive part of.''\n$Y=g(X)$ as the loss in excess of the deductible $d$ \\vspace{2mm}\n\\item \\textbf{Special Case 2. Limit (u)} %\\vspace{2mm}\n\\begin{equation*}\ng(x) = x \\wedge u =\n\\begin{cases}\nx & x \\le u\\\\\nu & x > u .\n\\end{cases}\n\\end{equation*}\nThe notation ``$\\wedge$'' means ``take the minimum of.'' In this case, the insurance only pays up to a specified limit $u$. The random variable $Y= X \\wedge u = \\min(X,u)$ is the claim paid %\\vspace{2mm}\n\\item \\textbf{Special Case 3. Coinsurance}. Define $Y = c X$. Typically, $0<c<1$, and so represents the proportion of claims retained by the insurer\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Risk Retention Function II}\n\\begin{itemize}\n\\item One handy way of combining the three special cases is through the expression\n\\begin{equation*}\ng(x) =\n\\begin{cases}\n0      & x \\le d\\\\\nc(x-d) & d \\le x < u \\\\\nc(u-d) & x \\ge u .\n\\end{cases}\n\\end{equation*} \\vspace{2mm}\n\n\\item Think about these as parameters in a contract between a policyholder and an insurer and so represent ``modifications'' of the underlying\ncontract \\vspace{2mm}\n\n\\item Also interpret the risk retention function as the result from a reinsurance\ncontract \\vspace{2mm}\n\n\\begin{itemize}\n\\item For example, it is common in such a contract for an insurer to retain 50\\% of each risk and ``cede'' 50\\% to the reinsurer\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Information Set for Deductibles}\n\\begin{itemize}\\scalefont{0.9}\n\\item Specify what type of information, sometimes known as the ``information set,'' that is available to the\ninsurer %\\vspace{2mm}\n\\item \\textbf{Special Case 4. Policyholder Deductible}. Define:\n\\begin{equation*}\ng_P(x) =\n\\begin{cases}\n\\text{undefined/not observed} & x \\le d\\\\\nx - d & x > d\n\\end{cases}\n\\end{equation*} %\\vspace{2mm}\n\\item The insurance only pays amounts in excess of the deductible $d$. If the loss is less than the deductible, then the insurer does not observe the loss. The random variable $Y^P = g(X)$ is the claim that an insurer\nobserves %\\vspace{2mm}\n\\item We have placed a ``$P$'' subscript to remind ourselves that the retained loss is on what is sometimes known as a ``per payment'' basis %\\vspace{2mm}\n\\item In statistical terms, this retained loss is \\emph{truncated} in the sense that values of $X$ below $d$ are not\nobserved %\\vspace{2mm}\n \\item To distinguish this from the other case where a zero is observed for losses $X<d$, the terminology \\textbf{per loss} is used.  Some sources use the notation $Y^L = (X-d)_+$ for the loss amount on a \\textbf{per loss} basis\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Distributions of Retained Risks - Deductible}\n\\begin{itemize}\n\\item Consider two types of \\textit{ordinary deductible}: \\vspace{2mm}\n\n\\begin{enumerate}\n\\item Cost (amount of payment) per loss event\n  \\begin{eqnarray*}\nY^L=(X-d)_+&=&\n\\left \\{\n\\begin{array}{cc}\n0 & X<d\\\\\nX-d & X\\ge d\\\\\n\\end{array}\n\\right.\\text{(a censored rv)}\n  \\end{eqnarray*} \\vspace{2mm}\n\n\\item Cost (amount of payment) per payment event\n  \\begin{eqnarray*}\nY^P &=&\n\\left \\{\n\\begin{array}{cc}\nundefined & X<d\\\\\nX-d & x\\ge d\\\\\n\\end{array}\n\\right. \\text{(a truncated rv)}\n  \\end{eqnarray*}\n\\end{enumerate}\n\\end{itemize} \\vspace{2mm}\n\n\\textit{Example. Exponential Distribution.} Suppose that the loss\n$X$ has distribution function $F(x) = 1-\\exp{(-x/1000)}$. Compute\nthe distribution function and pdf for $Y^L$ and $Y^P$ with $d=250$\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Pareto Per Payment Deductible}\n\\begin{itemize}\n\\item Assume a deductible $d = 1,000$ \\vspace{2mm}\n\nThen, the claim amount on a per payment basis is\n\\begin{equation*}\nY^{P} =\n\\begin{cases}\n\\text{undefined/not observed} & X < 1000\\\\\n1000 & X \\ge 1000\n\\end{cases}\n\\end{equation*} \\vspace{2mm}\n\n\\item Identify the distribution of $Y^P$\n\\end{itemize}\n\\end{frame}\n\n\n\\subsection{Expectations of Retained Risks}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Limited Expected Value}\n\\begin{itemize}\n\\item Use a generic ``$u$'' for the upper limit. To compute the expected value of the limited loss variable $\\min(X, u)$, we have\n\\begin{eqnarray*}\n\\mathrm{E~}\\min(X, u) = \\int_0^u \\left(1-F(x)\\right) dx =  \\int_0^u S(x)dx .\n\\end{eqnarray*}\n\n\\textit{Pareto Policy Limit}. Recall\n\\begin{equation*}\n1-F(x)=  S(x) = \\Pr(X > x) = \\left(\\frac{\\theta}{x + \\theta}\\right)^{\\alpha}\n\\end{equation*}\nwith mean $\\mathrm{E~}(X) = \\frac{\\theta}{\\alpha - 1}$. Thus, the limited expected value is\n\\begin{eqnarray*}\n\\mathrm{E~}\\min(X, u)  &=& \\theta^{\\alpha}\\int_0^u (x + \\theta)^{-\\alpha} dx =\\theta^{\\alpha} \\left.\\frac{(x + \\theta)^{-\\alpha+1}}{-\\alpha + 1}\\right|_0^u\\\\\n&=& \\theta^{\\alpha}\\left(\\frac{\\theta^{-\\alpha+1} - (u+\\theta)^{-\\alpha+1}}{\\alpha - 1}\\right)\\\\\n&=& \\frac{\\theta}{\\alpha-1}\\left\\{1 - \\left(\\frac{\\theta}{u + \\theta}\\right)^{\\alpha-1} \\right\\}.\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\n\n\\begin{frame}[shrink=2]\n\\frametitle{Pareto Deductible}\n\\begin{itemize}\n\\item The claim amount on a ``per loss'' basis is $Y^L = (X-d)_+$ for a deductible\n$d$ \\vspace{2mm}\n\n\\item To calculate $\\mathrm{E~} (X-d)_+$, we can use the relation, $X \\wedge d + (X - d)_{+} =\nX$ \\vspace{2mm}\n\n\\item For the Pareto distribution, recall $\\mathrm{E~}X = \\frac{\\theta}{\\alpha - 1}$ and\n\\begin{eqnarray*}\n\\mathrm{E~}\\min(X, d)  &=&  \\frac{\\theta}{\\alpha-1}\\left\\{1 - \\left(\\frac{\\theta}{d + \\theta}\\right)^{\\alpha-1} \\right\\}.\n\\end{eqnarray*} \\vspace{2mm}\n\nThus,\n\\begin{eqnarray*}\n\\mathrm{E~}(X-d)_+ &=& \\mathrm{E~} X -\n\\mathrm{E~}\\min(X, d)  =  \\frac{\\theta}{\\alpha-1} -\\frac{\\theta}{\\alpha-1}\\left\\{1 - \\left(\\frac{\\theta}{d + \\theta}\\right)^{\\alpha-1} \\right\\} \\\\\n&=& \\frac{\\theta}{\\alpha-1} \\left\\{\\left(\\frac{\\theta}{d + \\theta}\\right)^{\\alpha-1} \\right\\} .\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Mean Residual Life}\n\\begin{itemize}\\scalefont{0.9}\n\\item For the ``per payment'' random variable associated with the policyholder deductible case,\n\\begin{equation*}\ng_P(x) =\n\\begin{cases}\n\\text{undefined/not observed} & x \\le d\\\\\nx - d & x > d\n\\end{cases}\n\\end{equation*}\nwe can calculate the expectation as\n\\begin{eqnarray*}\ne_X(d) &=& e(d) = \\mathrm{E~}(X - d|X > d)\n\\end{eqnarray*} %\\vspace{2mm}\n\\item Here, $e_X(d)$ is known as the \\textit{mean residual life} %\\vspace{2mm}\n\\item We can write this as\n\\begin{eqnarray*}\ne(d) &=&  \\mathrm{E~}(X - d|X > d)\\\\\n&=& \\frac{\\int_d^{\\infty} (x-d) f(x)dx}{S(d)} = \\frac{\\mathrm{E~}(X - d)_+}{S(d)}\n\\end{eqnarray*} %\\vspace{2mm}\nThus,\n\\begin{eqnarray*}\ne(d) &=& \\frac{\\int_d^{\\infty} S(x)dx}{S(d)}\n\\end{eqnarray*}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Example} \\textit{Example. Exam M Fall 2005, Exercise\n26.} For an insurance:\n\n\\begin{enumerate}\n\\item Losses have density function\n\\begin{eqnarray*}\nf_X(x)&=& \\left \\{\n\\begin{array}{cc}\n0.02x & 0<x<10\\\\\n0 & \\text{elsewhere}\\\\\n\\end{array}\n\\right.\n\\end{eqnarray*} \\vspace{2mm}\n\n\\item The insurance has an ordinary deductible of $4$ per loss \\vspace{2mm}\n\n\\item $Y^P$ is the claim payment per payment random variable \\vspace{2mm}\n\n\\end{enumerate}\nCalculate $\\mathrm{E~}[Y^P]$\\\\\n\\end{frame}\n\n\n\\begin{frame}%[shrink=2]\n\\frametitle{Summary of Limited Loss Variables}\n\\scalefont{0.8}\n\\[\n\\begin{tabular}{ll}\n\\hline\n\\textbf{Random Variable} & \\textbf{Expectation} \\\\ \\hline\n\\emph{Excess loss random variable} & $e_{X}(d)=\\mathrm{E}~Y=\\mathrm{E}%\n(X-d|X>d)$ \\\\\n$Y=X-d$ if $X>d$ & mean excess loss function \\\\\nleft \\emph{truncated} & mean residual life function \\\\\n& complete expectation of life \\\\\n& $e_{X}^{k}(d)=\\mathrm{E}\\left[ \\left( X-d\\right) ^{k}|X>d\\right] $ \\\\\n\\hline\n$\\left( X-d\\right) _{+}=\\left\\{\n\\begin{array}{ll}\n0 & X<d \\\\\nX-d & X\\geq d\n\\end{array}\n\\right. $ & $\\mathrm{E~}\\left( X-d\\right) _{+}=e(d)S(d)$ \\\\\nleft-\\emph{censored} and shifted variable & $\\mathrm{E~}\\left(\nX-d\\right) _{+}^{k}=e^{k}(d)S(d)$ \\\\ \\hline\n$\\mathrm{min}(X,d)=X\\wedge d=\\left\\{\n\\begin{array}{ll}\nX & X<d \\\\\nd & X\\geq d\n\\end{array}\n\\right. $ \\  & $\\mathrm{E}\\left( X\\wedge d\\right) -$ limited expected value\n\\\\ \\emph{limited loss variable} - right \\emph{censored} &\n\\\\ \\hline\n\\end{tabular}\n\\]\n\nNote that $\\left( X-d\\right) _{+}+\\left( X\\wedge d\\right) =X.$ \\\nThus, $ \\mathrm{E~}\\left( X-d\\right) _{+}+\\mathrm{E}\\left( X\\wedge\nd\\right) =\\mathrm{E}~X$ %\\vspace{2mm}\n\nFor nonnegative, continuous random variables,\n\\begin{equation*}\n\\mathrm{E}\\left( X \\wedge d\\right) =\\int_{0}^{d} S\\left( x\\right)\ndx\\text{ \\ \\ and \\ \\ \\ }\\mathrm{E}( X-d) _{+} = \\int_{d}^{\\infty\n}S\\left( x \\right) dx\n\\end{equation*}\n\\end{frame}\n\n\n\\subsection{Loss Elimination Ratio (LER)}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Loss Elimination Ratio (LER)}\n\\begin{itemize}\n\\item Consider an ordinary deductible, cost (amount of payment) per loss event\n\\begin{eqnarray*}\nLER&=&\\frac{\\mathrm{E~}X - (\\mathrm{E~}X-\\mathrm{E~}(X\\wedge\nd))}{\\mathrm{E~}X}\n=\\frac{\\mathrm{E~}(X\\wedge d)}{\\mathrm{E~}X}\\\\\n&=&\\frac{\\text{limited exp value}}{\\text{exp value}}\n\\end{eqnarray*}\nWhat fraction of losses have been eliminated by introducing the deductible?\\\\\n\\end{itemize}\n\n\\textit{Example.} Losses have a lognormal distribution with $\\mu=6$\nand $\\sigma=2$. There is a deductible of 2,000, and 10 losses are\nexpected each year \\vspace{2mm}\n\nDetermine the loss elimination ratio\n\n\\end{frame}\n\n\n\\end{document}\n\n\\begin{frame}[shrink=2]\n\\frametitle{Instructor Notes}\n\\begin{itemize}\n\\item\n\\end{itemize}\n\\end{frame}\n\n\\textcolor{blue}{temp}\n", "meta": {"hexsha": "cc93d64082b3239dfce66d5b089b34d6a3bd633d", "size": 37681, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LatexSourceCode/Chap3Severity/Chap3SeverityDistributions_Fall2017.tex", "max_stars_repo_name": "ewfrees/LossDataAnalyticsOverheads", "max_stars_repo_head_hexsha": "130b86e2a6a1bcf4e1d9282ff55cbf6e5b206795", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-10-24T15:54:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-01T17:41:45.000Z", "max_issues_repo_path": "LatexSourceCode/Chap3Severity/Chap3SeverityDistributions_Fall2017.tex", "max_issues_repo_name": "ewfrees/LossDataAnalyticsOverheads", "max_issues_repo_head_hexsha": "130b86e2a6a1bcf4e1d9282ff55cbf6e5b206795", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LatexSourceCode/Chap3Severity/Chap3SeverityDistributions_Fall2017.tex", "max_forks_repo_name": "ewfrees/LossDataAnalyticsOverheads", "max_forks_repo_head_hexsha": "130b86e2a6a1bcf4e1d9282ff55cbf6e5b206795", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-01-24T13:09:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-27T19:52:11.000Z", "avg_line_length": 34.6332720588, "max_line_length": 236, "alphanum_fraction": 0.689206762, "num_tokens": 13144, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4102067541760191}}
{"text": "\n\\subsection{Bertrand competition}\n\nEach player decides what price to sell at.\n\nFirms who price above the lowest have no sales. Prices converge to cost.\n\n", "meta": {"hexsha": "2993b6a63632bbc5f6939bbc7bfc047dbe3fc05f", "size": 154, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/producer/03-01-bertrand.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/producer/03-01-bertrand.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/producer/03-01-bertrand.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.25, "max_line_length": 72, "alphanum_fraction": 0.7857142857, "num_tokens": 33, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.41020674086169745}}
{"text": "%**************************************************************\n% Lab 11: Processor\n%**************************************************************\n\\chapter{Processor}\n\n\\section{Purpose}\n\nA \\acf{CPU} is arguably one of the most important digital logic devices. \\acp{CPU} are found in all computers and many other embedded logic devices. They are versatile circuits that can be used to control many processes and peripheral devices. The purpose of this lab is to lay the foundation of \\ac{CPU} operation.\n\n\\subsection{A Definition} \n\nWhen asked to define ``\\ac{CPU}'' many students offer poetic definitions like ``it is the brain of the computer.'' This may be somewhat artistic but is not very helpful in defining \\ac{CPU} for digital logic purposes. Here is a much better definition:\n\n\\begin{quote}\n\tA \\acf{CPU} is a hardware device that is designed to translate binary codes stored in software into signals that control hardware. Thus, a \\ac{CPU} is the interface between software and hardware.\n\\end{quote}\n\nThe purpose of this lab is to demonstrate how binary codes can be used to manipulate hardware devices, like registers and adders, to move data through a circuit and accomplish a purpose. While the circuit developed in this lab is not a practical start for a \\ac{CPU} is does serve as an introduction to the concept of hardware manipulation by software codes. \n\n\\section{Procedure}\n\nThis processor contains only three subcircuits connected by several bus lines and each of the three subcircuits are reasonably simple to understand.\n\n\\subsection{Arithmetic-Logic Unit}\n\nThis processor starts with a simple \\ac{ALU}, as in Figure \\ref{fig:11-01}.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-01}\n\t\\caption{Simple ALU}\n\t\\label{fig:11-01}\n\\end{figure}\n\nTo be sure, this \\ac{ALU} is not very complex but uses the same principles developed in Lab \\ref{lab04}, \\nameref{lab04}. It contains only three arithmetic functions, increment, add, and negate; four logic functions, \\texttt{AND}, \\texttt{OR}, \\texttt{XOR}, \\texttt{NOT}; and one constant zero output. There are two data input ports but note that some of the functions only use the lower input, and one output port. The multiplexer determines which of the functions will be connected to the output and that is controlled by a signal named \\textit{ALUCtl}.\n\nThe \\ac{ALU} is then expanded somewhat to make it usable in a \\ac{CPU}. For simplicity, Figure \\ref{fig:11-02} shows only the left side of the ALU.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-02}\n\t\\caption{Left Side of ALU}\n\t\\label{fig:11-02}\n\\end{figure}\n\nFigure \\ref{fig:11-03} shows the right side of the ALU.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-03}\n\t\\caption{Full ALU}\n\t\\label{fig:11-03}\n\\end{figure}\n\nThe simple \\ac{ALU} functions are found in the center of Figure \\ref{fig:11-02}. However, what started as \\textit{DataInA} has been replaced by a register named \\textit{ALUBuffer}.\\footnote{IMPORTANT NOTE: All registers in this Processor circuit are triggered on the Falling Edge of the clock. The reason for this will become evident when the circuit is tested.} The \\textit{ALUBuffer's} inputs are from Tunnels (\\textit{Wiring} library) because those inputs are used in more than one location in the subcircuit.\\footnote{Tunnels are used extensively in this circuit to simplify the diagrams and aid in tracing signals.}\n\nThe \\ac{ALU} output is routed through a register named \\textit{Acc}, for \\textit{Accumulator}, which is the commonly-used name for the \\ac{ALU} output in a \\ac{CPU} circuit.\n\nOn the left side of the subcircuit are the three input ports. \\textit{DataIn} is an eight-bit number that is sent to both the \\textit{ALUBuffer} and the lower \\textit{DataIn} bus. The \\textit{ALUCtl} signal is split into two components. Bits 0-2 are sent to the multiplexer to select which of the eight functions will be output. Bit 3 of the \\textit{ALUCtl} signal is sent to the \\textit{AccEna} tunnel and when that is high the \\textit{Acc} register will be enabled but when that signal is low then the \\textit{ALUBuffer} register will be enabled. Finally, the clock input is sent to both registers.\n\n\\subsection{General Registers}\n\nA \\ac{CPU} must have several general registers available to hold data temporarily while an instruction is being carried out. For example, it may be necessary to hold the \\textit{Acc} output until it is needed in a later step so that value can be stored in a register and then recovered when needed. \n\nThe processor circuit being built in this lab has four general registers. Figure \\ref{fig:11-04} illustrates the \\lstinline[columns=fixed]|GenReg| subcircuit.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-04}\n\t\\caption{General Registers}\n\t\\label{fig:11-04}\n\\end{figure}\n\nThe \\lstinline[columns=fixed]|GenReg| subcircuit does not require any novel digital logic concepts. Starting on the left side of the circuit:\n\n\\begin{itemize}\n\t\\item \\textit{DataIn} is connected to the data bus and is the main input port for the registers. Note that \\textit{DataIn} is connected to the \\textit{Data} port on all four registers. \n\t\\item The register that actually stores the input data is determined by the Decoder (\\textit{Plexers} library) in the lower left corner of the subcircuit. The two low-order bits from the \\textit{RegSel} signal activate one of the output lines from the Decoder and that line is tied to the Write Enable port of the register. On the next clock pulse that register will lock in the data present on the \\textit{DataIn} port.\n\t\\item The outputs from all of the registers are wired to a Multiplexer (\\textit{Plexers} library). The select bits from the Decoder that are used to select the storage register are also used to select the register output line which is, in turn, wired to the \\textit{DataOut} port.\n\t\\item The high-order bit from the \\textit{RegSel} control signal is used to determine if data are stored to or read from a register. When that bit is high the decoder is active and will select a storage register but when that bit is low the output multiplexer will be activated and send a register's stored value to the output port.\n\\end{itemize}\n\n\\subsection{Control}\n\nThe \\lstinline[columns=fixed]|Control| subcircuit in this device is very simple and could, in all actuality, be eliminated. However, in a true \\ac{CPU} the \\lstinline[columns=fixed]|Control| subcircuit is rather complex and critical to the operation of the circuit so a \\lstinline[columns=fixed]|Control| subcircuit is included in this lab as an example. Figure \\ref{fig:11-05} illustrates the \\lstinline[columns=fixed]|Control| subcircuit.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-05}\n\t\\caption{Control Subcircuit}\n\t\\label{fig:11-05}\n\\end{figure}\n\nThe \\lstinline[columns=fixed]|Control| subcircuit includes a nine-bit input named \\textit{mCode} (for ``Microcode''). That input is latched by a register\\footnote{Note, as an exception to the other registers in the Processor circuit, the register in the control subcircuit must be set to trigger on the leading edge of the clock rather than the falling edge.} and the output of that register is split into three components.\n\n\\begin{description}\n\t\\item[Bits 0-3] These are the \\ac{ALU} control bits and they are sent to the \\lstinline[columns=fixed]|ALU| subcircuit.\n\t\\item[Bits 4-6] These are the register control bits and are sent to that subcircuit.\n\t\\item[Bits 7-8] These are the \\textit{dBus} (``Data Bus'') control bits. The data bus is found in the \\lstinline[columns=fixed]|main| circuit and carries the data to each of the subcircuits. The dBus control is just a multiplexer that controls which subcircuit's output has control of the data bus.\n\\end{description}\n\n\\subsection{Main}\n\nThe \\lstinline[columns=fixed]|main| circuit ties the three subcircuits together with three control busses and one data bus. Figure \\ref{fig:11-06} illustrates the \\lstinline[columns=fixed]|main| circuit.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\maxwidth{.95\\linewidth}]{gfx/11-06}\n\t\\caption{Main Circuit}\n\t\\label{fig:11-06}\n\\end{figure}\n\nThere are no novel digital logic functions used in this circuit. The first input is \\textit{mCode} which is the microcode used to control the flow of data in the dBus (``data bus''). the other input, \\textit{LdImm} (``Load Immediate'') can contain an eight-bit number that is to be loaded into one of the registers for processing. In a full \\ac{CPU} that input would be wired to a \\ac{RAM} device.\n\n\\subsection{Testing the Circuit}\n\nThe circuit should be tested by inputting these signals and observing the output.\n\n\\subsubsection{Copy LdImm To R0}\n%Checked\nEnter some value in the \\textit{LdImm} input port, set the \\textit{mCode} input to 101000000 (the first three values in the table below), and then pulse the \\textit{clk}. When completed, the \\textit{dBus} and \\textit{R0} should both contain the value of the \\textit{LdImm} port.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t10 & 100 & 0000 & LdImm & R0 <- LdImm \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R0 <- LdImm}\n\t\\label{tab:11-01}\n\\end{table}\n\n\\subsubsection{Copy LdImm To R1}\n% Checked\nEnter some value in the \\textit{LdImm} input port, set the \\textit{mCode} input to 101010000 (the first three values in the table below), and then pulse the \\textit{clk}. When completed, the \\textit{dBus} and \\textit{R1} should both contain the value of the \\textit{LdImm} port.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t10 & 101 & 0000 & LdImm & R1 <- LdImm\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R1 <- LdImm}\n\t\\label{tab:11-02}\n\\end{table}\n\n\\subsubsection{Copy LdImm To ALUbuf}\n%Checked\nEnter some value in the \\textit{LdImm} input port, set the \\textit{mCode} input to 100000000 (the first three values in the table below), and then pulse the \\textit{clk}. When completed, the \\textit{dBus} and \\textit{ALUbuf} should both contain the value of the \\textit{LdImm} port.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t10 & 000 & 0000 & LdImm & ALU <- LdImm\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{ALU <- LdImm}\n\t\\label{tab:11-03}\n\\end{table}\n\n\\subsubsection{Increment R0}\n\n\\marginpar{Use the LdImm function to initialize R0.}Incrementing the value in R0 requires two steps. Set the \\textit{mCode} input to the first three values in the table below and pulse the \\textit{clk} for each of the steps. When completed, \\textit{R0} will contain the original value of the \\textit{R0}$ +1 $.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t01 & 000 & 1000 & R0 & Acc <- R0+1 \\\\\n\t\t\t00 & 100 & 0000 & Acc & R0 <- Acc \\\\\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R0 <- Inc(R0)}\n\t\\label{tab:11-04}\n\\end{table}\n\n\\subsubsection{Add R0 And R1, Store In R0}\n\n\\marginpar{Use the LdImm function to initialize R0 and R1.}Adding the values of \\textit{R0} and \\textit{R1} and storing the result in \\textit{R0} requires three steps. Set the \\textit{mCode} input to the first three values in the table below and pulse the \\textit{clk} for each of the steps. When completed, the sum of the original values of \\textit{R0} and \\textit{R1} will be stored in \\textit{R0}.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t01 & 001 & 0001 & R1 & ALU <- R1 \\\\\n\t\t\t01 & 000 & 1001 & R0 & Acc <- R0 + R1 \\\\\n\t\t\t00 & 100 & 0001 & Acc & R0 <- Acc \n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R0 <- R0 + R1}\n\t\\label{tab:11-05}\n\\end{table}\n\n\\subsubsection{Subtract R1 From R0, Store In R0}\n\n\\marginpar{Use the LdImm function to initialize R0 and R1.}Subtracting the value of \\textit{R1} from \\textit{R0} and storing the result in \\textit{R0} requires four steps. Set the \\textit{mCode} input to the first three values in the table below and pulse the \\textit{clk} for each of the steps. When completed, the difference of the original values of \\textit{R0} and \\textit{R1} will be stored in \\textit{R0}.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t01 & 000 & 0010 & R0 & ALUbuf <- R0 \\\\\n\t\t\t01 & 001 & 1010 & R1 & Acc <- \\textasciitilde R1 \\\\\n\t\t\t00 & 100 & 1001 & R0-R1 & dBus <- Acc \\\\\n\t\t\t00 & 100 & 0111 & dBus+1 & R0 <- R0 - R1\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R0 <- R0 - R1}\n\t\\label{tab:11-06}\n\\end{table}\n\n\\subsubsection{Copy R0 to R1}\n\n\\marginpar{Use the LdImm function to initialize R0.}Copying the value of \\textit{R0} to \\textit{R1} requires four steps. Set the \\textit{mCode} input to the first three values in the table below and pulse the \\textit{clk} for each of the steps. When completed, the value of \\textit{R0} will be stored in \\textit{R1}.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t00 & 000 & 1111 & 0 & dBus <- 0 \\\\\n\t\t\t00 & 000 & 0100 & 0 & ALU <- dBus \\\\\n\t\t\t01 & 000 & 1100 & Acc & Acc <- ALU OR R0 \\\\\n\t\t\t00 & 101 & 0111 & Acc & R1 <- Acc\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R1 <- R0}\n\t\\label{tab:11-07}\n\\end{table}\n\n\\subsubsection{Swap R0 And R1}\n\n\\marginpar{Use the LdImm function to initialize R0 and R1.}Swapping the values of \\textit{R0} and \\textit{R1} requires 12 steps. Set the \\textit{mCode} input to the first three values in the table below and pulse the \\textit{clk} for each of the steps. When completed, the values of \\textit{R0} and \\textit{R1} will exchanged.\n\n\\begin{table}[H]\n\t\\sffamily\n\t\\newcommand{\\head}[1]{\\textcolor{white}{\\textbf{#1}}}\t\t\n\t\\begin{center}\n\t\t\\rowcolors{2}{gray!10}{white} % Color every other line a light gray\n\t\t\\begin{tabular}{ccccl} \n\t\t\t\\textbf{dBus} & \\textbf{Reg} & \\textbf{ALU} & \\textbf{dBus} & \\textbf{Notes} \\\\\n\t\t\t00 & 000 & 1111 & 0 & dBus <- 0 (Move R0 to R2)\\\\\n\t\t\t00 & 000 & 0100 & 0 & ALU <- dBus \\\\\n\t\t\t01 & 000 & 1100 & Acc & Acc <- ALU OR R0 \\\\\n\t\t\t00 & 110 & 0111 & Acc & R2 <- Acc \\\\\n \t\t\t& & & & \\\\ %Empty line\n\n\t\t\t00 & 000 & 1111 & 0 & dBus <- 0 (Move R1 to R0)\\\\\n\t\t\t00 & 000 & 0100 & 0 & ALU <- dBus \\\\\n\t\t\t01 & 001 & 1100 & Acc & Acc <- ALU OR R1 \\\\\n\t\t\t00 & 100 & 0111 & Acc & R0 <- Acc \\\\\n \t\t\t& & & & \\\\ %Empty line\n\n\t\t\t00 & 000 & 1111 & 0 & dBus <- 0 (Move R2 to R1)\\\\\n\t\t\t00 & 000 & 0100 & 0 & ALU <- dBus \\\\\n\t\t\t01 & 010 & 1100 & Acc & Acc <- ALU OR R2 \\\\\n\t\t\t00 & 101 & 0111 & Acc & R1 <- Acc\n\t\t\\end{tabular}\n\t\\end{center}\n\t\\caption{R0 <-> R1}\n\t\\label{tab:11-08}\n\\end{table}\n\n\\section{About Programming Languages}\n\nThe codes that were input for the last example (swap \\textit{R0} and \\textit{R1}) would create the following program.\n\n\\begin{Verbatim}[frame=lines,\nxleftmargin=10mm,\nxrightmargin=10mm]\n000001111\n000000100\n010001100\n001100111\n000001111\n000000100\n010011100\n001000111\n000001111\n000000100\n010101100\n001010111\n\\end{Verbatim}\n\nThis group of instructions would be considered ``CPU Microcode,'' which is a very highly specialized form of programming. It is the code that is built into a \\ac{CPU} circuit and it determines what gates, registers, and other devices are active for each step of the code. When Intel, AMD, Motorola, or other manufacturers create a new \\ac{CPU}, one of their main challenges is creating the microcode that will, for example, ``add the contents of register one to the contents of register two and store the result in register zero.'' The microcode must be able to activate and deactivate various devices within the \\ac{CPU} so data appear on the appropriate bus at the right time in order to achieve the objective. Normally, microcode steps must be executed over several clock cycles in order to do a single job. For example, in one clock cycle the contents of register one may be placed on the data bus, the next clock cycle will load that data into the ALU register, and so forth until the entire process is complete.\n\nMicrocode is usually stored in \\ac{ROM} that is built into the \\ac{CPU}. This is typically called ``firmware'' since it is a string of ones and zeros, like software, but it cannot be changed, like hardware.\n\nIt is important to keep in mind the difference between instructions contained in a software program (like Word) and those contained in microcode. A single instruction in software is interpreted and executed by the \\ac{CPU} using, perhaps, dozens of microcode steps. As an example, the software may want to move a single byte from \\ac{RAM} to the video card. The \\ac{CPU} may process that instruction by first moving the byte from \\ac{RAM} to register one and then moving it from there to the video card's input register and then activating the video card input function. Those moves may require several clock cycles as various multiplexers and other devices are activated in the correct sequence to move the data to its destination. \n\nA software program, like Word, is nothing more than a series of ones and zeros, organized into groups, commonly 64 in modern computers. Each group of bits forms a single ``word'' of information; or a single instruction which would then be used by the \\ac{CPU} to trigger a microcode sequence. When viewed at the level of ones and zeros, a software program is said to be in ``machine code,'' and could look something like the following (note, only the first 32 bits of each word are shown).\n\n\\begin{Verbatim}[frame=lines,\nxleftmargin=10mm,\nxrightmargin=10mm]\n10010100101100101001101011001010\n01101001101011000111101011101011\n00011011110010000111010111100101\n\\end{Verbatim}\n\nIf a programmer could master machine code, then those programs would be as concise and efficient as possible since they would be written in machine code the \\ac{CPU} can execute directly. Of course, as it is easy to imagine, no one actually writes machine code due to its complexity.\n\nThe next level higher than machine code is called ``Assembly'' code. Assembly uses easy-to-remember abbreviations to represent the various \\ac{CPU} instructions available; and it looks something like this: \n\n\\begin{Verbatim}[frame=lines,\nxleftmargin=10mm,\nxrightmargin=10mm]\nINP\nSTA FIRST \nINP\nSTA SECOND \nLDA FIRST \nSUB SECOND\nOUT\nHLT\nFIRST DAT\nSECOND DAT\n\\end{Verbatim}\n\nOnce the program has been written in Assembly, it must be ``assembled'' into machine code before it can be executed. An assembler is a fairly simply program that converts a file containing assembly codes into machine codes that can be executed by the \\ac{CPU}.\n\nMany programming languages have been developed that are considered ``higher'' than Assembly; for example, C++, Java, and Visual Basic. These languages tend to be easy to master and can enable a programmer to quickly create very complex programs. Programs written in each of these languages must be compiled, or changed into machine code, before they can be executed. Here is an example Java program:\n\n\\begin{Verbatim}[frame=lines,\nxleftmargin=10mm,\nxrightmargin=10mm]\npublic class HelloWorldExample{\n  public static void main(String args[]){\n  System.out.println(\"Hello World !\"); \n  }\n}\n\\end{Verbatim}\n\nIn the end, while there are dozens of different programming languages, they are all designed to be reduced into a series of machine codes which the \\ac{CPU} can then execute.\n\n\\section{Challenge}\n\nUsing the examples in the ``Testing the Circuit'' section, create the microcode necessary to carry out these functions:\n\n\\begin{enumerate}\n\t\\item Store the value contained in \\textit{LdImm} in \\textit{R2} (\\textit{R2} <- \\textit{LdImm}). (Assume that \\textit{LdImm} is pre-loaded with the value to store.)\n\t\n\t\\item Store the value contained in \\textit{LdImm} in \\textit{R3} (\\textit{R3} <- \\textit{LdImm}). (Assume that \\textit{LdImm} is pre-loaded with the value to store.)\n\t\n\t\\item Store the 2s complement of the value in \\textit{R0} back into \\textit{R0} (\\textit{R0} <- \\textasciitilde \\textit{R0}). The subtraction example will help with this function.\n\t\n\t\\item Store the bitwise NOT of the value in \\textit{R0} back into \\textit{R0} (\\textit{R0} <- \\textit{R0'}).\n\\end{enumerate}\n\n\\section{Deliverable}\n\nTo receive a grade for this lab, build the Processor circuit and then complete the Challenge. Be sure the standard identifying information is at the top left of the Processor \\lstinline{main} circuit, similar to: \n\n\\bigskip\n% The minipage environment keeps the three lines together - no page break.\n\\begin{minipage}{\\linewidth}\n\t\\begin{verbatim}\n\tGeorge Self\n\tLab 11: Processor\n\tApril 5, 2018\n\t\\end{verbatim}\n\\end{minipage}\n\\bigskip\n\nSave the Processor circuit in a file with this name: \\textit{Lab11\\_Processor}. Complete the code required in the Challenge and store that in a text file with the name \\textit{Lab11\\_Code.txt}. Submit both files for grading.\n", "meta": {"hexsha": "691e4178466c84d868054992a3daecc1dc3a859b", "size": 22093, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/11_Processor.tex", "max_stars_repo_name": "tingwei628/CIS221_Lab_Manual", "max_stars_repo_head_hexsha": "93dbcb211fdce8468d5066e659d5319c5f52bc73", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2018-12-12T21:47:51.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T17:07:42.000Z", "max_issues_repo_path": "Chapters/11_Processor.tex", "max_issues_repo_name": "tingwei628/CIS221_Lab_Manual", "max_issues_repo_head_hexsha": "93dbcb211fdce8468d5066e659d5319c5f52bc73", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/11_Processor.tex", "max_forks_repo_name": "tingwei628/CIS221_Lab_Manual", "max_forks_repo_head_hexsha": "93dbcb211fdce8468d5066e659d5319c5f52bc73", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2019-11-10T13:48:42.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T12:15:01.000Z", "avg_line_length": 56.794344473, "max_line_length": 1017, "alphanum_fraction": 0.7343955099, "num_tokens": 6593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4101776429820769}}
{"text": "%%%%%%%%%%%%%%%%%%%%%definitions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\input{../../doc/related_pages/header.tex}\r\n\\input{../../doc/related_pages/newcommands.tex}\r\n\\usepackage{minted}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DOCUMENT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{document}\r\n\r\n\\title{The esol project}\r\n\\author{M.~Held}\r\n\\maketitle\r\n\r\n\\begin{abstract}\r\n  This is a program for 2d isothermal full-f gyro-fluid turbulence simulations \r\nthat cover the edge and scrape off layer and include different treatments of the \r\npolarization charge\r\n\\end{abstract}\r\n\r\n\\section{Equations}\r\nCurrently we implemented $4$ slightly different sets of equations. $n$ is the \r\nelectron density, $N$ is the ion gyrocentre density. $\\phi$ is the electric \r\npotential. We\r\nuse Cartesian coordinates $x$, $y$.\r\n\\subsection{Models}\r\n\\subsubsection{Full-F gyro-fluid models}\r\nThe full-f models (\"ff-O2-OB\" \\& \"ff-lwl-OB\" \\& \"ff-lwl\" \\& \"ff-O2\") share the \r\nsame evolution equations\r\n\\begin{subequations}\r\n\\begin{align}\r\n \\frac{\\partial n}{\\partial t}     &= \r\n    \\frac{1}{B}\\{ n, \\phi\\} \r\n  + \\kappa n\\frac{\\partial \\phi}{\\partial y} \r\n  -\\kappa \\frac{\\partial n}{\\partial y} + \\Lambda_{n,\\parallel}\r\n  - \\nu \\Delta_\\perp^2 n  \\\\\r\n  \\frac{\\partial N}{\\partial t} &=\r\n  \\frac{1}{B}\\{ N, \\psi\\} \r\n  + \\kappa N\\frac{\\partial \\psi}{\\partial y} \r\n  + \\tau \\kappa\\frac{\\partial N}{\\partial y} + \\Lambda_{N,\\parallel}-\\nu \r\n\\Delta_\\perp^2 N \\\\\r\n   \\vec{\\nabla}\\cdot \\vec{P}_2 &= \\Gamma_1 N-n\r\n\\end{align}\r\n\\end{subequations}\r\nand are based upon a ``radially'' varying magnetic field magnitude\r\n\\begin{align}\r\n B(x)^{-1} = \\kappa x +1-\\kappa X \r\n\\end{align}\r\nThe full-f models differ only in the treatment the  polarization terms \r\n\\(\\psi_2\\) and \\(\\vec{P}_2\\), given in Sec.~\\ref{sec:polarization}\r\n%%%%%\r\n\\subsubsection{Polarization and FLR terms}\r\n\\label{sec:polarization}\r\nThe FLR and polarization operators enter the gyro-fluid potential (\\(\\psi)\\) as \r\nwell as the polarization density.\r\nThe operators and gyro-fluid potential are\r\n\\begin{align}\r\n \\Gamma_1 &= ( 1- \\tau/2 \\Delta_{\\perp})^{-1} &\r\n \\Gamma_0 &= ( 1- \\tau\\Delta_{\\perp})^{-1} &\r\n   \\psi = \\Gamma_1 \\phi + \\psi_2 \r\n\\end{align}\r\nThe  (negative) polarization charge is~\\cite{Held2020} \r\n\\begin{align}\r\n  \\vec{\\nabla}\\cdot \\vec{P}_2 &=    \r\n\\begin{cases}\r\n-\\frac{N_0}{B_0^2}\\Delta_{\\perp} \\phi , \r\n        &\\ \\text{if \"ff-lwl-OB\"} \\\\\r\n-\\frac{N_0}{B_0^2}\\Gamma_0\\Delta_{\\perp} \\phi, \r\n      &\\ \\text{if \"ff-O2-OB\"} \\\\\r\n-\\nabla\\cdot \\left(\\frac{N}{B^2} \\nabla_\\perp \\phi\\right)\r\n       &\\ \\text{if \"ff-lwl\"} \\\\\r\n-\\sqrt{\\Gamma_0}\\nabla\\cdot \\left(\\frac{N}{B^2} \\nabla_\\perp\\sqrt{\\Gamma_0} \r\n\\phi\\right) \r\n         &\\ \\text{if \"ff-O2\"} \r\n\\end{cases}\r\n\\end{align}\r\nThe polarization part of the gyro-fluid potential is\r\n\\begin{align}\r\n\\psi_2&=    \r\n\\begin{cases}\r\n0 , \r\n        &\\ \\text{if \"ff-lwl-OB\"} \\\\\r\n0, \r\n      &\\ \\text{if \"ff-O2-OB\"} \\\\\r\n- \\frac{1}{2} \\frac{(\\nabla\\phi)^2}{B^2}\r\n       &\\ \\text{if \"ff-lwl\"} \\\\\r\n- \\frac{1}{2} \\frac{(\\nabla\\sqrt{\\Gamma_0}\\phi)^2}{B^2}\r\n         &\\ \\text{if \"ff-O2\"} \r\n\\end{cases}\r\n\\end{align}\r\n\\subsubsection{Closure of the parallel dynamics}\r\n\\label{sec:parallelclosure}\r\nThe closure terms for the parallel dynamics exploit a two region \r\napproach~\\cite{HeldPhD}: a closed field line and an open field line region. The \r\ntransition between this regions is mimiced by the damping function \\( \r\nh_{\\pm}(x)\\)\r\nwhere \\(h_{+}\\) is a polynomial Heaviside function (cf. feltor docu) and the \r\n\\(-\\) refers to its reflection in x-direction. The polynomial Heaviside function \r\nparameters are \\(x_s\\) and \\(\\sigma_s\\).\r\nHere, \\(x_s\\) represents the position of the separatrix and \\(\\sigma_s\\) is the \r\nwidth of the transition. \r\n\\\\\r\nThe complete parallel closure consists then of two contributions:\r\n\\begin{align}\r\n \\Lambda_{n,\\parallel} &= \\sum_{b \\in \\left\\{+,-\\right\\} \r\n}\\Lambda_{n,\\parallel,b} &\r\n \\Lambda_{N,\\parallel} &= \\sum_{b \\in \\left\\{+,-\\right\\} } \r\n\\Lambda_{N,\\parallel,b}\r\n\\end{align}\r\n\r\n\\paragraph{Edge:} In the edge region we take the modified Hasegawa-Waktani \r\nclosure~\\cite{Held2018}\r\n\\begin{align}\r\n \\Lambda_{n,\\parallel,-} &= \\alpha h_{-}(x) \\left[\\widetilde{\\phi} - \r\n\\widetilde{\\ln(n)} \\right] \\\\\r\n \\Lambda_{N,\\parallel,-} &= 0\r\n\\end{align}\r\nwith the fluctuation given by \\(\\widetilde{f} := f - \\langle f\\rangle_y\\) and \r\nthe y-average \\(\\langle f\\rangle_y:= \\int dy f / L_y\\). The adiabaticity \r\nparameter is defined as \\(\\alpha := T_{e,\\parallel} \r\nk_\\parallel^2/(\\eta_\\parallel e^2 n_{e,0} \\Omega_{i,0} )\\).\r\n\r\n\\paragraph{Scrape-off-Layer:} In the scrape off layer we assume Bohm sheath \r\nboundary conditions~\\cite{Mosetto2015}~\\footnote{Note that strictly speaking the \r\nboundary conditions for the density and electric potential are Neumann, in \r\nparticular \\(\\partial_s n_e (\\vec{x}) |_{\\pm L_\\parallel /2 } =0 \\) and \r\n\\(\\partial_s  n_e (\\vec{x}) |_{\\pm L_\\parallel /2 } = 0\\).}\r\n\\begin{align}\r\nn_e (x,y,\\pm L_\\parallel /2 ) &= n_e (\\vec{x}) &\r\n\\phi (x,y,\\pm L_\\parallel /2 ) &= \\phi (\\vec{x})\\\\\r\n u_e (x,y,\\pm L_\\parallel /2 ) &= \\pm \\exp{(\\Lambda_{sh} - \\phi)} &\r\n U_i (x,y,\\pm L_\\parallel /2 ) &= \\pm\\sqrt{1+\\tau}\r\n\\end{align}\r\nwhere we introduced the constant (also known as sheath or Bohm potential) \r\n\\(\\Lambda_{sh} := \\ln \\sqrt{m_i/(2 \\pi m_e)} = \\ln  (1/\\sqrt{|\\mu_e| 2 \\pi})\\). \r\nWith this we obtain for the closure terms~\\cite{HeldPhD}\r\n\\begin{align}\r\n \\Lambda_{n,\\parallel,+} &:= -h_{+}(x) n \\lambda \\exp{(\\Lambda_{sh} - \\phi)} \\\\\r\n \\Lambda_{N,\\parallel,+} &:=  -\\sqrt{1 + \\tau} \\lambda \\Gamma_1^{-1} ( h_{+}(x)  \r\nn)\r\n\\end{align}\r\nwith the so called sheath dissipation parameter \\(\\lambda = \r\n\\rho_s/L_\\parallel\\).\r\nNote that this results into the following term in the vorticity density equation\r\n\\begin{align}\r\n \\Lambda_{\\mathcal{W},\\parallel,+} := \\Gamma_1\\Lambda_{N,\\parallel,+} - \r\n\\Lambda_{n,\\parallel,+} = -\\lambda  h_{+}(x)  n \\sqrt{1 + \\tau} \\left[1  -  \r\n\\frac{1}{\\sqrt{1 + \\tau}}\\exp{(\\Lambda_{sh} - \\phi)} \\right]\r\n\\end{align}\r\n\\subsubsection{Sources}\r\nThe particle source is related to the the ion gyro-center source \r\nand the electric potential via the transformation rule\r\n\\begin{align}\r\n S_n =\\Gamma_1 S_N +\r\n \\begin{cases}\r\n0, \r\n        &\\ \\text{if \"ff-lwl-OB\"} \\\\\r\n0, \r\n      &\\ \\text{if \"ff-O2-OB\"} \\\\\r\n\\nabla\\cdot \\left(\\frac{S_N}{B^2} \\nabla_\\perp \\phi\\right)\r\n       &\\ \\text{if \"ff-lwl\"} \\\\\r\n\\sqrt{\\Gamma_0}\\nabla\\cdot \\left(\\frac{S_N}{B^2} \\nabla_\\perp\\sqrt{\\Gamma_0} \r\n\\phi\\right) \r\n         &\\ \\text{if \"ff-O2\"} \r\n\\end{cases}\r\n\\end{align}\r\nInstead, we could use the long wavelength approximation \\(\r\nS_N =(1+\\tau/2 \\Delta_\\perp) S_n + \\vec{\\nabla} \\cdot \\left(\\frac{S_n}{B^2} \r\n\\vec{\\nabla}_\\perp \\phi\\right)\\). However this transformation rule is not exact \r\nand care has to be taken when short wavelength structures arise! \\\\\r\nAnother possibility is to neglect the polarization charge term in the exact transformation rule, which results in a vanishing source term in the evolution equation of the polarization charge density.\r\n\\paragraph{Forced profile (``forced'')}\r\nThe following source forces the poloidally averaged profile to a prescribed profile in a limited region if the averaged profile is below the prescribed profile. \r\n\\begin{align}\r\n S_N := \\omega_s p \\Theta\\left(p \\right)\r\n\\end{align}\r\nwith \\(p = h_s (n_{prof,s} - \\langle N \\rangle_y)\\) with \\(h_s\\) a polynomial heaviside function.\r\n\r\n\\paragraph{Constant influx (``flux'')}\r\n\\begin{align}\r\n S_N := \\omega_s n_{prof,s} \r\n\\end{align}\r\nwith the source profile function \r\n\\begin{align}\r\n n_{prof,s}&:= \r\n \\begin{cases}\r\n   e^{1+\\left(\\frac{(x-x_s)^2}{2 \\sigma_s^2}-1\\right)^{-1}}, &\\frac{(x-x_s)^2}{2 \r\n\\sigma_s^2}<1  \\\\\r\n   0, & else\r\n \\end{cases}\r\n\\end{align}\r\nwith \\(x_s:= l_x  f_s\\)\r\n\\subsection{Initialization}\r\nWe follow the strategy to enforce the initial fields of the physical variables, \r\nthe electron density \\(n\\) and the electric potential \\(\\phi\\), in order to \r\ncompute the initial ion gyro-center density.\r\n\\subsubsection{Non-rotating Gaussian (\"blob\")}\r\nInitialization of $n$ is a Gaussian \r\n\\begin{align}\r\n    n(x,y,0) &= 1 + A\\exp\\left( -\\frac{(x-X)^2 + (y-Y)^2}{2\\sigma^2}\\right) \\\\\r\n    \\phi(x,y)&=const.\r\n\\end{align}\r\nwhere $X = p_x l_x$ and $Y=p_yl_y$ are the initial centre of mass position \r\ncoordinates, $A$ is the amplitude and $\\sigma$ the\r\nradius of the blob.\r\nWe initialize \r\n\\begin{align}\r\n    N &= \\Gamma_1^{-1} n \r\n\\end{align}\r\n\\subsubsection{Gaussian with zero polarization charge density(\"blob\")}\r\nInitialization of $n$ is a Gaussian \r\n\\begin{align}\r\n    n(x,y,0) &= 1 + A\\exp\\left( -\\frac{(x-X)^2 + (y-Y)^2}{2\\sigma^2}\\right) \\\\\r\n\\end{align}\r\nwhere $X = p_x l_x$ and $Y=p_yl_y$ are the initial centre of mass position \r\ncoordinates, $A$ is the amplitude and $\\sigma$ the radius of the blob. We \r\ninitialize then\r\n\\begin{align}\r\n    N &= n \r\n\\end{align}\r\nso that the total polarization charge vanishes  \\(\\vec{\\nabla}\\cdot \\vec{P}=0\\).\r\n\\subsection{Diagnostics}\r\nDiagnostics are the mass \\(M\\)\r\n\\begin{align}\r\n    M(t) &:= \\int dA (n)  \\\\\r\n\\end{align}\r\n\\section{Numerical methods}\r\ndiscontinuous Galerkin on structured grid\r\n\\rowcolors{2}{gray!25}{white} %%% Use this line in front of longtable\r\n\\begin{longtable}{ll>{\\RaggedRight}p{7cm}}\r\n\\toprule\r\n\\rowcolor{gray!50}\\textbf{Term} &  \\textbf{Method} & \\textbf{Description}  \\\\ \r\n\\midrule\r\ncoordinate system & Cartesian 2D & equidistant discretization of $[0,l_x] \\times \r\n[0,l_y]$, equal number of Gaussian nodes in x and y \\\\\r\nmatrix inversions & multigrid conjugate gradient &  \\\\\r\nmatrix functions & cauchy integral  method & \\\\\r\n\\ExB advection & centered upwind-scheme\\\\\r\ncurvature terms & centered difference & \\\\\r\ntime &  adaptive explicit RK or explicit multistep  &  \\\\\r\n\\bottomrule\r\n\\end{longtable}\r\n\\section{Compilation and useage}\r\nThere are two programs esol.cu and esol\\_hpc.cu . Compilation with\r\n\\begin{verbatim}\r\nmake <esol esol_hpc esol_mpi> device = <omp gpu>\r\n\\end{verbatim}\r\nRun with\r\n\\begin{verbatim}\r\npath/to/feltor/src/esol/esol input.json\r\npath/to/feltor/src/esol/esol_hpc input.json output.nc\r\necho np_x np_y | mpirun -n np_x*np_y path/to/feltor/src/esol/esol_mpi/\r\n    input.json output.nc\r\n\\end{verbatim}\r\nAll programs write performance informations to std::cout.\r\nThe first is for shared memory systems (OpenMP/GPU) and opens a terminal window \r\nwith life simulation results.\r\n The\r\nsecond can be compiled for both shared and distributed memory systems and uses \r\nserial netcdf in both cases\r\nto write results to a file.\r\nFor distributed\r\nmemory systems (MPI+OpenMP/GPU) the program expects the distribution of \r\nprocesses in the\r\nx and y directions as command line input parameters.\r\n\r\n\\subsection{Input file structure}\r\nInput file format: json\r\n\\begin{minted}[texcomments]{js}\r\n\"grid\":\r\n{\r\n    \"n\" :  5,    //Legendre polynomial order in x and y \r\n    \"Nx\" : 32,   //grid points in x\r\n    \"Ny\" : 32,   //grid points in y\r\n    \"lx\"  : 64,  //Box size in x in units of $\\rho_s$\r\n    \"ly\"  : 64   //Box size in y in units of $\\rho_s$\r\n},\r\n\"timestepper\":\r\n{\r\n    \"type\": \"adaptive\", //\"adaptive\" (explicit adaptive RK) or \"multistep\" (explicit multistep)\r\n    \"tableau\": \"Bogacki-Shampine-4-2-3\", // recommended \"Bogacki-Shampine-4-2-3\" (default adaptive) or \"TVB-3-3\" (multistep)\r\n    \"rtol\": 1e-10, //relative tolerance of adaptive time stepper\r\n    \"atol\": 1e-12, //absolute tolerance of adaptive time stepper\r\n    \"dt\" : 0.1   //time step in units of $c_s/\\rho_s$ for multistep. Also determines together with itstep output step $dt_{out} = dt itstp$\r\n},\r\n\"output\":\r\n{\r\n    \"type\": \"glfw\",  // output format \"glfw\" & \"netcdf\",\r\n    \"itstp\"  : 1,    //time steps between outputs\r\n    \"maxout\" : 2,    //\\# of netcdf outputs\r\n    \"n\" : 5,         //Legendre polynomial order in x and y for netcdf output\r\n    \"Nx\" : 32,       //grid points in x for netcdf output\r\n    \"Ny\" : 32        //grid points in y for netcdf output\r\n},    \r\n\"elliptic\":\r\n{\r\n    \"stages\"     : 3, //\\# of stages of the multigrid solver for the (tensor) elliptic operator\r\n    \"eps_pol\"    : [1e-6,1.0,1.0], //accuracy at each stage of the multigrid solver\r\n    \"jumpfactor\": 1 //jump factor of the (tensor) elliptic operator\r\n},\r\n\"helmholtz\":\r\n{\r\n    \"eps_gamma1\" :   1e-8, //accuracy of the $\\Gamma_1$ operator\r\n    \"eps_gamma0\" :   1e-6, //accuracy of the $\\Gamma_0$ or $\\sqrt{\\Gamma_0}$ operator\r\n    \"maxiter_sqrt\":  200,  //max iterations of the $\\sqrt{\\Gamma_0}$ computation\r\n    \"maxiter_cauchy\": 35,  //max iterations of the Cauchy terms in $\\sqrt{\\Gamma_0}$ computation\r\n    \"eps_cauchy\" :  1e-12  //accuracy of the Cauchy integral in the $\\sqrt{\\Gamma_0}$ computation\r\n},\r\n\r\n\"physical\":\r\n{\r\n    \"curvature\"  : 0.00015, //$\\kappa$\r\n    \"tau\"  : 4.0,           //$\\tau_i = T_{i0}/(T_{e0} Z_i)$\r\n    \"alpha\"  : 0.005,       //adiabaticity $\\alpha:= T_{e,\\parallel} k_\\parallel^2/(\\eta_\\parallel e^2 n_{e,0} \\Omega_{i,0} )$\r\n    \"lambda\"  : 0.000001,    //sheath dissipation $\\lambda:= \\rho_{s0}/L_\\parallel$\r\n    \"mu_e\"  : -0.000272121, //$\\mu_e:=m_e/(Z_e m_i)$ negative electron to ion mass ratio\r\n    \"equations\": \"ff-O2\",   //model $\\in$ (\"ff-lwl-OB\" ,\"ff-O2-OB\" ,\"ff-lwl\" ,\"ff-O2\" ,\"ff-O4\" )\r\n    \"xfac_sep\"  : 0.3,      //$f_s$ x-position of separatrix in units of $l_x$     \r\n    \"sigma_sep\"  : 0.5      //$sigma_s$ width of damping function $h_{pm}$ of separatrix in units of $\\rho_{s0}$    \r\n},\r\n\"source\":\r\n{\r\n     \"source_type\" : \"flux\",    //type of source $\\in$ (\"forced\", \"flux\")\r\n     \"source_rel\" : \"zero_pol\", //relation for source, $\\in$ (\"zero-pol\", \"finite-pol\")\r\n     \"omega_s\" : 0.005,         //source rate in units of $\\Omega_i$\r\n     \"xfac_s\": 0.1,             //position of source in units of the $l_x$\r\n     \"sigma_s\" : 2.0              //width of source in units of $\\rho_{s0}$\r\n},\r\n\"profile\":\r\n{\r\n     \"bgprofamp\" : 1.0, //amplitude of background in units of $n_{e0}$, typically 1\r\n     \"profamp\": 0.0,    //amplitude of profile in units of $n_{e0}$\r\n     \"sigma_p\": 20.0    //width of gradient region of the profile in units of $\\rho_{s0}$\r\n},\r\n\"init\":\r\n{\r\n    \"type\"       : \"blob\",  // Gaussian blob initialization\r\n    \"amplitude\"  :1.0,      //$A$ of the Gaussian blob\r\n    \"sigma\"  : 5,           //$\\sigma$ of Gaussian blob units of $\\rho_s$\r\n    \"posX\"  : 0.5,          //x initial position $\\in (0,1)$\r\n    \"posY\"  : 0.5           //y initial position $\\in (0,1)$\r\n},\r\n\"nu_perp\"  : 0e-5,          //hyper-diffusion parameter\r\n\"bc_x\"  : \"DIR_NEU\",        //Boundary condtion in x\r\n\"bc_y\"  : \"PER\"             //Boundary condtion in y\r\n\\end{minted}\r\n\\subsection{Structure of output file}\r\nOutput file format: netcdf-4/hdf5\r\n%\r\n%Name | Type | Dimensionality | Description\r\n%---|---|---|---|\r\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\r\n\\toprule\r\n\\rowcolor{gray!50}\\textbf{Name} & \r\n \\textbf{Type} & \\textbf{Dimension} & \\textbf{Description}  \\\\ \\midrule\r\ninputfile  &             text attribute & 1 & verbose input file as a string \\\\\r\nenergy\\_time             & Dataset & 1 & timesteps at which 1d variables are \r\nwritten \\\\\r\ntime                     & Dataset & 1 & time at which fields are written \\\\\r\nx                        & Dataset & 1 & x-coordinate  \\\\\r\ny                        & Dataset & 1 & y-coordinate \\\\\r\nelectrons                & Dataset & 3 (time, y, x) & electon density $n$ \\\\\r\nions                     & Dataset & 3 (time, y, x) & ion density $N$ \\\\\r\npotential                & Dataset & 3 (time, y, x) & electric potential $\\phi$  \r\n\\\\\r\nvorticity                & Dataset & 3 (time, y, x) & z-component of ExB \r\nvorticity  $\\Omega_E = \\vec{\\nabla}\\cdot (B^{-1} \\vec{\\nabla}_{\\perp}\\phi)$  \\\\\r\nlperpinv                 & Dataset & 3 (time, y, x) & inverse perp density gradient length scale $L_\\perp^{-1} := |\\nabla_\\perp n| / n$ \\\\\r\nlperpinvphi                 & Dataset & 3 (time, y, x) & inverse perp eletric potential gradient length scale $L_{\\perp,\\phi}^{-1} := |\\nabla_\\perp \\phi| $ \\\\\r\n% dEdt                     & Dataset & 1 (energy\\_time) & change of energy per \r\n% dissipation              & Dataset & 1 (energy\\_time) & diffusion integrals  \r\n\\\\\r\n% energy                   & Dataset & 1 (energy\\_time) & total energy integral  \r\n\\\\\r\n% mass                     & Dataset & 1 (energy\\_time) & mass integral   \\\\\r\n\\bottomrule\r\n\\end{longtable}\r\n%..................................................................\r\n\\bibliography{../../doc/related_pages/references}\r\n%..................................................................\r\n\\bibliographystyle{aipnum4-1.bst}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "cb4e6479704f253ae781f10f44cfa0f6b63f6c57", "size": 16451, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/esol/esol.tex", "max_stars_repo_name": "mrheld/feltor", "max_stars_repo_head_hexsha": "c70bc6bb43f39261f6236df88e16610d08cb98ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-11T10:59:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-11T10:59:44.000Z", "max_issues_repo_path": "src/esol/esol.tex", "max_issues_repo_name": "mrheld/feltor", "max_issues_repo_head_hexsha": "c70bc6bb43f39261f6236df88e16610d08cb98ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-02T13:43:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-02T13:43:25.000Z", "max_forks_repo_path": "src/esol/esol.tex", "max_forks_repo_name": "mrheld/feltor", "max_forks_repo_head_hexsha": "c70bc6bb43f39261f6236df88e16610d08cb98ca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0654450262, "max_line_length": 200, "alphanum_fraction": 0.6217251231, "num_tokens": 5312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4101776293770088}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.67.084023 equation (19)}\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'hamiltonian.json'\n   cdblib.create (jsonfile)\n\n   # --------------------------------------------------------------------------\n   # Hamiltonian constraint\n\n   Ham := R + K_{a b} g^{a b} K_{c d} g^{c d} - K_{a b} K_{c d} g^{a c} g^{b d}.  # cdb (Ham.101,Ham)\n\n   defK2ABarD := K_{i j} -> \\exp(4\\phi) ABar_{i j} + (1/3) g_{i j} trK.\n   defG2GBarD := g_{a b} -> \\exp(4\\phi) gBar_{a b}.\n   defG2GBarU := g^{a b} -> \\exp(-4\\phi) gBar^{a b}.\n\n   substitute     (Ham, defK2ABarD)   # cdb (Ham.102,Ham)\n   substitute     (Ham, defG2GBarD)   # cdb (Ham.103,Ham)\n   substitute     (Ham, defG2GBarU)   # cdb (Ham.104,Ham)\n   distribute     (Ham)               # cdb (Ham.105,Ham)\n   Ham = product_sort (Ham)           # cdb (Ham.106,Ham)\n   rename_dummies (Ham)               # cdb (Ham.107,Ham)\n   canonicalise   (Ham)               # cdb (Ham.108,Ham)\n   map_sympy      (Ham, \"simplify\")   # cdb (Ham.109,Ham)\n\n   foo := gBar_{a b} gBar^{a b} -> 3.\n   bah := gBar_{a c} gBar^{b c} -> gBar_{a}^{b}.\n\n   substitute (Ham, foo)              # cdb (Ham.110,Ham)\n   substitute (Ham, bah)              # cdb (Ham.111,Ham)\n   eliminate_kronecker (Ham)          # cdb (Ham.112,Ham)\n\n   foo := gBar_{a b} gBar^{a b} -> 3.\n   bah := gBar_{a}^{a} -> 3.\n   moo := ABar_{a b} gBar^{a b} -> 0.\n\n   substitute     (Ham, foo)          # cdb (Ham.113,Ham)\n   substitute     (Ham, bah)          # cdb (Ham.114,Ham)\n   substitute     (Ham, moo)          # cdb (Ham.115,Ham)\n\n   foo := ABar_{c d} gBar^{c a} gBar^{d b} -> ABar^{a b}.\n\n   substitute     (Ham, foo)          # cdb (Ham.116,Ham)\n   rename_dummies (Ham)               # cdb (Ham.117,Ham)\n\n   cdblib.put ('Ham',Ham,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      {\\cal H}\n          = \\Cdb*{Ham.101}\n          = \\Cdb*[\\hskip2cm\\hfill]{Ham.102}\n          = \\Cdb*{Ham.103}\n          = \\Cdb*{Ham.104}\n          = \\Cdb*[\\hskip2cm\\hfill]{Ham.105}\n          = \\Cdb*{Ham.106}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*}\n      {\\cal H}\n          = \\Cdb*[\\hskip2cm\\hfill]{Ham.107}\n          = \\Cdb*[\\hskip2cm\\hfill]{Ham.108}\n          = \\Cdb*{Ham.109}\n          = \\Cdb*{Ham.110}\n          = \\Cdb*{Ham.111}\n          = \\Cdb*{Ham.112}\n          = \\Cdb*{Ham.113}\n          = \\Cdb*{Ham.114}\n          = \\Cdb*{Ham.115}\n          = \\Cdb*{Ham.116}\n          = \\Cdb*{Ham.117}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   # --------------------------------------------------------------------------\n   # Check against prd67.\n\n   foo := @(Ham).                                       # cdb(prd67.eq19.lcb,foo)\n   bah  = cdblib.get('prd67.eq19.rhs','prd67.json')     # cdb(prd67.eq19.prd,bah)\n\n   diff := @(foo) - @(bah).\n\n   distribute     (diff)\n   diff = product_sort (diff)\n   rename_dummies (diff)\n   map_sympy      (diff, \"simplify\")\n   canonicalise   (diff)                                # cdb(prd67.eq19.chk,diff)\n\\end{cadabra}\n\n% \\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{prd67.eq19.lcb} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{prd67.eq19.prd} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{prd67.eq19.chk} \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "c1b4b7a9eeca1b91c0adaee16fc11e02ddb52b3d", "size": 3333, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/hamiltonian.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-equations", "max_stars_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-13T18:47:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-13T18:47:34.000Z", "max_issues_repo_path": "source/hamiltonian.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-equations", "max_issues_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/hamiltonian.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-equations", "max_forks_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7327586207, "max_line_length": 101, "alphanum_fraction": 0.4911491149, "num_tokens": 1241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4100454318272387}}
{"text": "\\section{Consistency of spectral clustering}\n\\label{ch:ulrike2008}\n\n\\textit{Consistency of spectral clustering} by Ulrike Von Luxburg.\\\\\nCited by 241. \\textit{The Annals of Statistics, 2008}.\n\\newline\n\n\\textbf{Main point} is that \\begin{inparaenum}[\\itshape a\\upshape)]\n\\item normalized spectral clustering converges under some very general conditions, \n\\item but unnormalized spectral clustering is only consistent under strong additional assumptions, \n\\end{inparaenum} thus it conclude normalized spectral clustering is superior in practical application\n", "meta": {"hexsha": "5d48f79e70766ef5595fd32a0bd29f12b131ac89", "size": 556, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/references/reference_research/ulrike2008.tex", "max_stars_repo_name": "wsgan001/AnomalyDetection", "max_stars_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/references/reference_research/ulrike2008.tex", "max_issues_repo_name": "wsgan001/AnomalyDetection", "max_issues_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/references/reference_research/ulrike2008.tex", "max_forks_repo_name": "wsgan001/AnomalyDetection", "max_forks_repo_head_hexsha": "397673dc6ce978361a3fc6f2fd34879f69bc962a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-03-16T21:50:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-16T21:50:52.000Z", "avg_line_length": 46.3333333333, "max_line_length": 101, "alphanum_fraction": 0.8129496403, "num_tokens": 134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.4100454272583616}}
{"text": "%!TEX root = ../main.tex\n\\documentclass[../main.tex]{subfiles}\n\\begin{document}\n\\subsection{Additional Tables and Figures} \\label{app:tables_and_figures}\n\\subsubsection{Correlation Heatmap of Task Choices}\n\\begin{figure}[!htbp]\n\t\\centering\n\t\\includegraphics[scale=0.7]{./FIG/corr_heatmap.png} \n\t\\caption{Heatmap of correlation coefficients of task choices in periods $t-1$ and $t$ of the base period as well as their squared values. Notice that the scale is compressed and only covers values between 0.95 and 1.0 to make the small differences visible.}\n\t\\label{fig:corr_heatmap}\n\\end{figure}\n\n\\FloatBarrier\n\\subsubsection{Estimation Results in Base Period}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table 1 %%%%%%%%%%%%%%%%%\n\\begin{table}[!htbp]\n\\begin{center}\n\\begin{tabular}{lclc}\n\\toprule\n\\textbf{Dep. Variable:}    & $\\Delta w_{i,t}$ & \\textbf{  R-squared (uncentered):}      &     0.999   \\\\\n\\textbf{No. Observations:} &       100        & \\textbf{  Adj. R-squared (uncentered):} &     0.999   \\\\\n\\textbf{F-statistic:}      &  5.720e+04      & \\textbf{  Prob (F-statistic):}          & 4.87e-151   \\\\\n\\bottomrule\n\\end{tabular}\n\\begin{tabular}{lcccccc}\n                  & \\textbf{coef} & \\textbf{std err} & \\textbf{t} & \\textbf{P$> |$t$|$} & \\textbf{[0.025} & \\textbf{0.975]}  \\\\\n\\midrule\n\\textbf{$\\lambda_{i, t-1}^{*}$}   &       -0.4989  &        0.002     &   -240.382  &         0.000        &        -0.503    &        -0.495     \\\\\n\\textbf{$\\lambda_{i, t-1}^{*2}$} &        1.0001  &        0.004     &    278.381  &         0.000        &         0.993   &         1.007    \\\\\n\\bottomrule\n\\end{tabular}\n\n\\end{center}\n\\caption{Results of an OLS estimation of wage changes in the base period on both, $\\lambda_{i, t-1}^{*}$ and $\\lambda_{i, t-1}^{*2}$. This estimation result is from one of the $M = 1000$ simulated datasets used in the Monte Carlo estimation. Regressors do not include a constant because the true model intersects the point of origin due to the normalization of $w_{i,j=1,t} = 0$.}\n\\label{tab:base_period_regression_rlst_t-1}\n\\end{table}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Table 2 %%%%%%%%%%%%%%%%%\n\\begin{table}[!htbp]\n\\begin{center}\n\\begin{tabular}{lclc}\n\\toprule\n\\textbf{Dep. Variable:}    & $\\Delta w_{i,t}$ & \\textbf{  R-squared (uncentered):}      &      0.999   \\\\\n\\textbf{No. Observations:} &       100        & \\textbf{  Adj. R-squared (uncentered):} &      0.999   \\\\\n\\textbf{F-statistic:}      &  7.081e+04       & \\textbf{  Prob (F-statistic):}          & 1.42e-155   \\\\\n\\bottomrule\n\\end{tabular}\n\\begin{tabular}{lcccccc}\n                  & \\textbf{coef} & \\textbf{std err} & \\textbf{t} & \\textbf{P$> |$t$|$} & \\textbf{[0.025} & \\textbf{0.975]}  \\\\\n\\midrule\n\\textbf{$\\lambda_{i, t}^{*}$}   &        -0.4841  &        0.002     &    -264.802 &         0.000        &         -0.488   &         -0.480    \\\\\n\\textbf{$\\lambda_{i, t}^{*2}$} &        \t 0.9686  &        0.003     &     308.259  &         0.000        &          0.962    &          0.975    \\\\\n\\bottomrule\n\\end{tabular}\n\n\\end{center}\n\\caption{Results of an OLS estimation of wage changes in the base period on both, $\\lambda_{i, t}^{*}$ and $\\lambda_{i, t}^{*2}$. This estimation result is from one of the $M = 1000$ simulated datasets used in the Monte Carlo estimation. Regressors do not include a constant because the true model intersects the point of origin due to the normalization of $w_{i,j=1,t} = 0$.}\n\\label{tab:base_period_regression_rlst_t}\n\\end{table}\n\\FloatBarrier\n\n\\end{document}", "meta": {"hexsha": "742a270af62baad469d1354f94a03974e271174e", "size": 3496, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex_files/Appendix/tables_and_figures.tex", "max_stars_repo_name": "DaLueke/estimating_skill_prices", "max_stars_repo_head_hexsha": "bc895c8b0b0439f86c1f2dd53b34108f1eaf69a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "latex_files/Appendix/tables_and_figures.tex", "max_issues_repo_name": "DaLueke/estimating_skill_prices", "max_issues_repo_head_hexsha": "bc895c8b0b0439f86c1f2dd53b34108f1eaf69a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex_files/Appendix/tables_and_figures.tex", "max_forks_repo_name": "DaLueke/estimating_skill_prices", "max_forks_repo_head_hexsha": "bc895c8b0b0439f86c1f2dd53b34108f1eaf69a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.3114754098, "max_line_length": 380, "alphanum_fraction": 0.5846681922, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283035, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4100454233926549}}
{"text": "\\RequirePackage[l2tabu,orthodox]{nag}\n\n% TODO: decide if one-sided/two-sided\n%\\documentclass[headsepline,footsepline,footinclude=false,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc,BCOR=12mm,DIV=12]{scrbook} % two-sided\n\\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided\n\n% TODO: change citation style in settings\n\\input{settings}\n\n% TODO: change thesis information\n\\newcommand*{\\getUniversity}{Technische Universität München}\n\\newcommand*{\\getFaculty}{Department of Informatics}\n\\newcommand*{\\getTitle}{\\textls*[+13]{Proof of the Amortized Time Complexity} \\textls*[-11]{of an Efficient Union-Find Data Structure} in Isabelle/HOL\\par}\n\\newcommand*{\\getTitleGer}{Beweis der amortisierten Laufzeit einer effizienten Union-Find-Datenstruktur in Isabelle/HOL\\par}\n\\newcommand*{\\getAuthor}{Adrián Löwenberg Casas}\n\\newcommand*{\\getDoctype}{Bachelor's Thesis in Informatics}\n\\newcommand*{\\getSupervisor}{Prof. Tobias Nipkow, Ph.D.}\n\\newcommand*{\\getAdvisor}{Maximilian P.L. Haslbeck, M.Sc.}\n\\newcommand*{\\getSubmissionDate}{September 16th, 2019}\n\\newcommand*{\\getSubmissionLocation}{Munich}\n\n\\begin{document}\n\n% Set page numbering to avoid \"destination with the same identifier has been already used\" warning for cover page.\n% (see https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Problems_with_Links_and_Pages).\n\\pagenumbering{alph}\n\\input{pages/cover}\n\n\\frontmatter{}\n\n\\input{pages/title}\n\\input{pages/disclaimer}\n\\input{pages/acknowledgments}\n\\input{pages/abstract}\n\\microtypesetup{protrusion=false}\n\\tableofcontents{}\n\\microtypesetup{protrusion=true}\n\n\\mainmatter{}\n\n%\\input{chapters/01_introduction}\n% TODO: add more chapters here\n\n\\chapter{Introduction}\n\nOne of the main subjects of computer science is the study of algorithms and data structures. When a new algorithmic idea is developed two problems arise, firstly if the algorithm solves the problem \\textit{(functional correctness)} and secondly whether the running time is always reasonable \\textit{(worst-case running time analysis)} for every operation, or for a sequence of operations \\textit{(amortized running time analysis)}. In this thesis we provide computer assisted formal proofs of both properties for the Union-Find data structure. \n\nIn the first chapter we present the data structure abstractly and our implementation of it. In the second chapter we introduce the Ackermann function, its properties and those of its inverse, which is asymptotically the amortized running time for the operations provided by the data structure. Finally, we outline the proof of the functional correctness and amortized time complexity of the data structure developed in Isabelle/HOL and explain the significance of the main results.\n\n\\section{Union-Find and Partial Equivalence Relations}\n\nThe Union-Find data structure mathematically models a partial equivalence relation over a finite domain. This is implemented efficiently by disjoint set forests, which are forests of rooted trees, each tree representing an equivalence class, with every node being an element and the root a representative of the equivalence class.\nClassically, the operations supported are \\textit{Union}, where two equivalence classes are merged into one, and \\textit{Find}, where it is checked whether two given elements belong to the same class.\n\nIn our implementation, we represent the disjoint set forest by an array representing the child-parent relationship, every index in the array represents a node, and the content of the array at that index is the parent of the node. A root node is modeled as having itself as a parent.\n\nNote that this approach requires every node to be just a number, when in practice a user of the data structure might want to store arbitrary data in it. This is however easily solvable by the user by associating the index of the node with the data required by the use case, which does not need to be stored in the array.\n\nAdditionally, we use another array of the same length to store the \\textit{ranks} of the nodes, its significance will reveal itself during the running time analysis. \n\n\n\n\\begin{figure}[!htb]\n\t\\centering\n\t\\begin{tikzpicture}[<-,level/.style={sibling distance = 5cm/#1,\n\t\t\tlevel distance = 1.5cm}] \n\t\t\\node (root)[first] {} \n\t\t\tchild{ node (leftchild) [dsf1] {$0$} \n\t\t\t\tchild{ node [dsf1] {$2$}} \n\t\t\t\tchild{ node [dsf1] {$3$}\n\t\t\t\t\tchild{ node [dsf1] {$4$}}\n\t\t\t\t}\n\t\t\t}\n\t\t\tchild{ node (rightchild) [dsf2] {$1$}\n\t\t\t\tchild{ node [dsf2] {$5$}\n\t\t\t\t\tchild{ node [dsf2] {$6$}}\n\t\t\t\t}\n\t\t\t}                            \n\t\t; \n\t\t\\path (leftchild) edge [loop above] node {} (leftchild);\n\t\t\\path (rightchild) edge [loop above] node {} (rightchild);\n\t\t\\path [-{Latex[width=1cm]}, shorten >=-2mm] (rightchild) edge[white, ultra thick] node {} (root);\n\t\t\\path [-{Latex[width=1cm]}, shorten >=-2mm] (leftchild) edge[white, ultra thick] node {} (root);\n\t\t\\end{tikzpicture}\n\t\t\n\t\t\\begin{tikzpicture}[box/.style={rectangle,draw=black, minimum size=1cm}]\n\t\t\n\t\t\\foreach \\y [count=\\x] in {0,1,0,0,3,1,5}{\n\t\t\t\n\t\t\t\\ifthenelse{\\x=2 \\OR \\x=6 \\OR \\x=7}\n\t\t\t{\\node[box, fill=TUMAccentOrange] at (\\x-1,0){\\y};}\n\t\t\t{\\node[box, fill=TUMAccentLightBlue] at (\\x-1,0){\\y};}\n\t\t\t\n\t\t\t\\node at (\\x-1,-1){\t\t\t\\pgfmathparse{\\x-1}\\pgfmathprintnumber{\\pgfmathresult}};\n\t\t\t\\ifthenelse{\\x=1 \\OR \\x=2}\n\t\t\t{}\n\t\t\t{\\draw[->] (\\x-1,0.5) .. controls (\\y+0.25\\x-0.25\\y+0.75, 1.5) and (\\y+0.75\\x-0.75\\y+0.25, 1.5) .. (\\y,0.5);}\n\t\t}\n\t\t\n\t\t\\node at (-2,0) {Array:};\t\n\t\t\\node at (-2,-1) {Indexes:};\n\t\t\n\t\t\n\t\t\\end{tikzpicture}\n\t\t\\caption{Two equivalence classes and their representation as a disjoint set forest.}\n\\end{figure}\n\n\nUsing arrays is arguably more efficient than a pointer-based implementation. Of course, this fixes the domain size to the length of the array at the moment of instantiating the data structure. This restriction could easily be removed by using a dynamic array instead. If its operations occur in amortized constant time, the resulting amortized time of the \\textit{Union} and \\textit{Find} operations is the same. We will try to give hints to where adjustments would need to be made to the mathematical analysis to accommodate the varying domain. This and other ideas for future work will be marked by \\HandPencilLeft. \n\n\\subsection{Path Compression and Union by Rank}\n\nThe efficiency of this implementation relies on two heuristics that dramatically improve running time. Very roughly, as with any data structure involving trees, we want to keep the trees as flat as possible, to minimize the number of iterations to the root.\n\n\\begin{itemize}\n\t\\item \\textbf{Union by rank}: When merging two trees, in order for the resulting tree to be as flat as possible, the root of the tree with more nodes should be the new root. It is possible to keep track of the size of every tree, as did Lammich \\cite{Lam19} in his implementation, and according to Tarjan et al. \\cite{Tarjan84} the resulting time complexity would be the same, however we follow Charguéraud and Pottier \\cite{chargueraud17} and use the \\textit{rank} approximation, which is an upper bound on the size of the tree.\n\tOn initialization, every node is a childless root and has a rank of zero. When merging two trees, the root of the tree with the largest rank becomes the new root and its rank is incremented by one.\n\t\\item \\textbf{Path compression}: Every time the representative of a node is searched for, an iteration from said node to the root is performed. To achieve a flatter tree, the path is compressed, this means that every node visited during the iteration is updated to have the root as its parent. This is without penalty to the running time of the original representative search operation. Every subsequent iteration to the root from any updated node is therefore only one step.\n\t\n\t\n\t\\begin{figure}[!htb]\n\t\t\\centering\n\t\t\\begin{tikzpicture}[<-,level/.style={sibling distance = 5cm/#1,\n\t\t\tlevel distance = 1.5cm}] \n\t\t\\node (root)[first] {} \n\t\tchild{ \n\t\t\tnode (leftchild) [dsf1] {$0$} \n\t\t\tchild{ \n\t\t\t\t{ node[itria] {\\,\\,\\,\\,\\,\\,} }\n\t\t\t\tnode [dsf1] {$1$}\n\t\t\t\tchild{ \n\t\t\t\t\t{ node[itria] {\\,\\,\\,\\,\\,\\,} }\n\t\t\t\t\tnode [dsf1] {$2$} \n\t\t\t\t\tchild{ node [dsf1] {$3$} { node[itria] {\\,\\,\\,\\,\\,\\,} } }\n\t\t\t\t\tchild[missing] child[missing]\n\t\t\t\t} child[missing] child[missing]\n\t\t\t} child[missing] child[missing]\n\t\t} \n\t\tchild{ \n\t\t\tnode (rightchild) [dsf1] {$0$}\n\t\t\tchild{ { node[itria] {\\,\\,\\,\\,\\,\\,} } node [dsf1] {$1$}}\n\t\t\tchild{ { node[itria] {\\,\\,\\,\\,\\,\\,} } node [dsf1] {$2$}}\n\t\t\tchild{ { node[itria] {\\,\\,\\,\\,\\,\\,} } node [dsf1] {$3$}}\n\t\t}                            \n\t\t; \n\t\t\\path (leftchild) edge [loop above] node {} (leftchild);\n\t\t\\path (rightchild) edge [loop above] node {} (rightchild);\n\t\t\\path [-{Latex[width=1cm]}, shorten >=-2mm] (rightchild) edge[white, ultra thick] node {} (root);\n\t\t\\path [-{Latex[width=1cm]}, shorten >=-2mm] (leftchild) edge[white, ultra thick] node {} (root);\n\t\t\\end{tikzpicture}\n\t\t\\caption{The state before and after performing path compression at the node $3$.}\n\t\\end{figure}\n\\end{itemize}\n\n\\subsection{Implementation}\n\nOur implementation is based on the one by Lammich, for which Haslbeck and Lammich provided a non-optimal amortized time complexity bound \\cite{HaslRef19}. This implementation did not compress on \\textit{Union}, so its running time could not be optimal\\label{bug}. The code has been adapted to use ranks and to compress on every occasion. The data structure is represented by two arrays, the disjoint set forest and the rank array, and such is the implementation in Imperative/HOL:\n\n\\begin{lstlisting}[mathescape=true,caption=The Datatype Representing the Data Structure,captionpos=b, label={The Datatype Representing the Data Structure}]\n\ttype_synonym uf = nat array $\\times$ nat array\n\\end{lstlisting}\n\\subsubsection{Initialization}\n\nOn initialization the size of the arrays has to be fixed, so it is provided as a parameter to \\verb|uf_init|:\n\n\\begin{lstlisting}[mathescape=true,caption=The Initialisation Function,captionpos=b,label={The Initialisation Function}]\n\tdefinition uf_init :: nat $\\Rightarrow$ uf Heap where\n\tuf_init n $\\equiv$ do {\n\t\tl $\\leftarrow$ Array.of_list [0..<n];\n\t\tszl $\\leftarrow$ Array.new n (0::nat);\n\t\treturn (szl,l)\n\t}\n\\end{lstlisting}\n\n\\vspace{-0.6cm}\n\n\\subsubsection{Find}\n\nThe \\textit{Find} operation, or \\verb|uf_cmp|, is implemented here in a modular way, which eases the correctness proof and the running time analysis. The usual implementations in the literature, prominently in CLRS \\cite{CLRS09} and also the one by Charguéraud and Pottier \\cite{chargueraud17} use an arguably more natural pointer structure to represent the forest, search for a representative recursively, and do the path compression on backtracking. Our implementation relies on the \\verb|uf_rep_of_c| function, which searches for the representative first (\\verb|uf_rep_of|), and on a second pass, it compresses the equivalence class (\\verb|uf_compress|). The \\verb|uf_cmp| function retrieves both representatives and returns whether they are equal.\n\\vspace{2cm}\n\n\\begin{lstlisting}[mathescape=true,caption=The Representative Search Function,captionpos=b]\n\tpartial_function (heap) uf_rep_of :: nat array $\\Rightarrow$ nat $\\Rightarrow$ nat Heap\n\twhere [code]: \n\tuf_rep_of p i = do {\n\t\tn $\\leftarrow$ Array.nth p i;\n\t\tif n=i then return i else uf_rep_of p n\n\t}\n\\end{lstlisting}\n\\vspace{-0.2cm}\n\\begin{lstlisting}[mathescape=true,caption=The Iterated Path Compression Function,captionpos=b]\n\tpartial_function (heap) uf_compress :: nat $\\Rightarrow$ nat $\\Rightarrow$ nat array $\\Rightarrow$ unit Heap\n\twhere [code]: \n\tuf_compress i ci p = (\n\t\tif i=ci then return ()\n\t\telse do {\n\t\t\tni $\\leftarrow$ Array.nth p i;\n\t\t\tuf_compress ni ci p;\n\t\t\tArray.upd i ci p;\n\t\t\treturn ()\n\t})\n\\end{lstlisting}\n\\vspace{-0.2cm}\n\\begin{lstlisting}[mathescape=true,caption=The Representative Search and Compression Function,captionpos=b]\t\n\tdefinition uf_rep_of_c :: nat array $\\Rightarrow$ nat $\\Rightarrow$ nat Heap where \n\tuf_rep_of_c p i $\\equiv$ do {\n\t\tci $\\leftarrow$ uf_rep_of p i;\n\t\tuf_compress i ci p;\n\t\treturn ci\n\t}\n\\end{lstlisting}\n\\vspace{-0.2cm}\n\\begin{lstlisting}[mathescape=true,caption=The Find Operation,captionpos=b]\t\n\tdefinition uf_cmp :: uf $\\Rightarrow$ nat $\\Rightarrow$ nat $\\Rightarrow$ bool Heap where\n\tuf_cmp u i j $\\equiv$ do {\n\t\tlet (s,p) = u;\n\t\tn $\\leftarrow$ Array.len p;\n\t\tif (i$\\geq$n $\\lor$ j$\\geq$n) then return False\n\t\telse do {\n\t\t\tci $\\leftarrow$ uf_rep_of_c p i;\n\t\t\tcj $\\leftarrow$ uf_rep_of_c p j;\n\t\t\treturn (ci=cj)\n\t\t}\n\t}\n\\end{lstlisting}\n\n\\subsubsection{Union}\nThe \\textit{Union} operation, here \\verb|uf_union|, also makes use of the \\verb|uf_rep_of_c| function, as it needs to find the roots of the trees representing the equivalence classes of its arguments to merge them. Beginning in line \\ref{line:reps} of the \\verb|uf_union| code, the ranks of the roots are retrieved, and then the root with the highest rank becomes the new root and its rank is incremented.\n\n\n\\begin{lstlisting}[mathescape=true, caption=The Union Operation,captionpos=b,escapechar=|]\t\n\tdefinition uf_union :: uf $\\Rightarrow$ nat $\\Rightarrow$ nat $\\Rightarrow$ uf Heap where \n\tuf_union u i j $\\equiv$ do {\n\t\tlet (r,p) = u;\n\t\tci $\\leftarrow$ uf_rep_of_c p i;\n\t\tcj $\\leftarrow$ uf_rep_of_c p j;\n\t\tif (ci=cj) then return (r,p) \n\t\telse do {\n\t\t\tri $\\leftarrow$ Array.nth r ci; |\\label{line:reps}|\n\t\t\trj $\\leftarrow$ Array.nth r cj;\n\t\t\tif ri<rj then do {\n\t\t\t\tArray.upd ci cj p;\n\t\t\t\t(if (ri=rj) then do {\n\t\t\t\t\tArray.upd cj (ri+1) r\n\t\t\t\t} else return r);\n\t\t\t\treturn (r,p)\n\t\t\t} else do { \n\t\t\t\tArray.upd cj ci p;\n\t\t\t\tif (ri=rj) then do {\n\t\t\t\t\tArray.upd ci (ri+1) r;\n\t\t\t\t\treturn (r,p)\n\t\t\t\t} else return (r,p)\n\t\t\t}\n\t\t}\n\t}\n\\end{lstlisting}\n\n\\section{Applications}\n\nThe Union-Find data structure is important and used in several foundational algorithms, as equivalence relations are a very flexible modeling tool. An equivalence relation can represent the partition of a set, for example the connected components of an undirected graph. The Union-Find data structure can be used for example in an efficient implementation of the Kruskal algorithm to check if two vertices are connected or whether a cycle is created when adding an edge. \nThe earlier version of Union-Find implemented in Imperative/HOL is used by Haslbeck et al. to implement Kruskal \\cite{Kruskal-AFP}. The version presented here is a drop-in replacement which automatically would improve the time complexity of the whole algorithm (see \\ref{bug}). Another important application is an efficient implementation of Huet's algorithm for unification \\cite{Knight89}.\n\n\n\n\\chapter{The Ackermann Function}\n\nIn this chapter we define the Ackermann function exactly as Charguéraud and Pottier \\cite{chargueraud17}, who follow the definition by Alstrup et al. \\cite{Alstrup14} and, more clasically, by Tarjan \\cite{Tarjan1975b}. We then prove some important properties about it, including monotonicity in every argument and under iteration.\nThe theory Ackermann.thy can be used together with InverseNatNat.thy completely independently from the rest of the theories presented in this thesis.\n\n\\section{Relationship to other Ackermann Function Definitions}\n\nIt is important to note that there are several definitions of the Ackermann function in the literature. The definition already existing in Isabelle (HOL/ex/Primrec.thy) follows Mendelson \\cite[pg. 345]{Mendelson09}, which in turn follows the classical definition by Ackermann \\cite{Ackermann22}. All three of these occurrences focus on the property of this function not being primitive recursive.\n\nThe definition by Charguéraud and Pottier follows Tarjan, who states it is a ``slight variant of Ackermann's function; it is not primitive recursive'' \\cite{Tarjan1975b}. The reasons for this variation are not clear to us, and the statement about it not being primitive recursive seems to not have been proved, but it rather probably follows from the fundamentally similar definitions.\nHowever, this property is of no interest for the purpose of this thesis except for the qualitative statement that a function growing faster than every primitive recursive function is \\textit{very} fast-growing, so its inverse is \\textit{very} slow-growing.\n\n\\section{Definition}\n\nThe definition by Charguéraud and Pottier is modular, and enables proving the properties of the Ackermann function through properties about simpler functions.\n\n\n\\begin{definition}{Ackermann}\n\t\\begin{align}\n\t\\mathrm{astep} \\, f \\, x &:= f^{(x+1)} \\, x \\\\\n\tA \\, k \\, n &:= (\\mathrm{astep}^{(k)} \\, \\mathrm{Suc}) \\, n\n\t\\end{align}\n\t$A$ is the Ackermann function, and it satisfies the following alternative equation, unfolding all definitions:\n\t\\begin{equation}\n\tA \\, k \\, n = ((\\lambda \\, f \\, x. \\, f ^ {(x + 1)}\\, x) ^ {(k)} \\, \\mathrm{Suc}) \\, n\n\t\\end{equation}\n\tThe notation $f ^{(n)} \\, x$ corresponds to Isabelle's $(f \\, \\textasciicircum \\textasciicircum \\, n) \\, x$ and refers to function iteration:\n\t\\begin{equation}\n\tf^{(n)} \\, x := \\begin{cases}\n\t\t\t\t\tx \\quad \\quad \\quad \\quad \\quad \\, \\, n = 0 \\\\\n\t\t\t\t\tf^{(n-1)} \\, (f \\, x) \\quad n > 0\n\t\t\t\t\t\\end{cases}\n\t\\end{equation}\n\tAnd $\\mathrm{Suc}$ is, for the purposes of this thesis, just $\\mathrm{Suc}\\,x := x + 1$.\n\\end{definition}\n\nThe definition abstracts the recursion inherent to the Ackermann function and thus enables the use of the existing lemmas about function iteration, in particular the powerful \\textit{funpow\\_mono2} (see \\ref{funpow}). Of course, this definition corresponds to the equations by Tarjan:\n\n\\begin{lemma}{Tarjan characteristic equations}\n\t\\begin{align}\n\tA \\, 0 \\, x &= x + 1 \\quad \\quad \\quad \\quad \\text{Ackermann\\_base\\_eq} \\\\\n\tA \\, (k + 1)\\, x &= (A\\, k)^{(x + 1)}\\, x \\quad \\text{Ackermann\\_step\\_eq}\n\t\\end{align}\n\\end{lemma}\n\n\\section{Explicit Equations and Bounds}\n\nThe Ackermann function satisfies the following explicit equations for the first values of $k$, which gives an idea of how fast the function grows:\n\n\\begin{lemma}{Ackermann\\_1\\_eq}\n\t\\begin{equation}\n\tA \\, 1 \\, x = 2x + 1\n\t\\end{equation}\n\\end{lemma}\n\n\\begin{lemma}{Ackermann\\_2\\_eq}\n\t\\begin{equation}\n\tA \\, 2 \\, x = 2^{x+1} (x + 1) - 1\n\t\\end{equation}\n\\end{lemma}\n\nIt also fulfills the following lower bound for $A\\,2$:\n\n\\begin{lemma}{Ackermann\\_2\\_log\\_lower\\_bound}\n\t\\begin{equation}\n\t\tn \\leq A \\, 2 \\, (\\log{n})\n\t\\end{equation}\n\tWhere $\\log$ is the discrete binary logarithm as defined in the Isabelle/HOL distribution (HOL-Library.Discrete).\n\\end{lemma}\n\nAs well as the following, already impressive, lower bound for $A\\,3$:\n\n\\begin{lemma}{Ackermann\\_3\\_lower\\_bound}\n\t\\begin{equation}\n\t\\underbrace{2^{2^{\\iddots^{2}}}}_{x \\text{times}} \\leq A \\, 3 \\, x\n\t\\end{equation}\n\\end{lemma}\n\nOr, more formally: $((\\textasciicircum) \\, 2) ^ {(x + 1)} \\, 0 \\leq A \\, 3 \\, x$\n\n\n\\section{Further Contributions in this Theory}\n\nThere are some more properties of the Ackermann function which have been generalized and proved for\ngeneral iterated functions, as well as many technical lemmas which enable for more direct proofs about monotonicity and inflationarity of iterated functions.\nA very useful lemma which already existed in the Nat.thy theory was \\textit{funpow\\_mono2}, which states:\n\\begin{lemma}{funpow\\_mono2} \\newline \\label{funpow}\n\t\\textbf{Assume:} mono $f$; $i \\leq j$; $x \\leq y$; $x \\leq f \\, x$\n\t\\begin{equation}\n\tf ^{(i)} \\, x \\leq f ^ {(j)} \\, y\n\t\\end{equation}\n\\end{lemma}\n\nWe provided among others the following lemmas, which extend this lemma to the comparison of two functions, under some assumptions about the relationship between them:\n\n\\begin{lemma}{compow\\_mono\\_in\\_f} \\newline\n\t\\textbf{Assume:} mono $f$; mono $g$; $\\forall x. f \\, x \\leq g \\, x$\n\t\\begin{equation}\n\tf ^{(i)} \\, x \\leq g ^ {(i)} \\, x\n\t\\end{equation}\n\\end{lemma}\n\n\\begin{lemma}{compow\\_mono\\_in\\_f\\_and\\_i'} \\newline\n\t\\textbf{Assume:} mono $f$; mono $g$; inflationary $g$;\n\t$\\forall x\\, y.\\, x \\leq y \\rightarrow f\\, x \\leq g\\, y$; $x \\leq y$; $i \\leq j$\n\t\\begin{equation}\n\tf ^{(i)} \\, x \\leq g ^ {(j)} \\, y\n\t\\end{equation}\n\\end{lemma}\n\nWe also proved some properties about the asymptotics of the Ackermann function, which of course goes to infinity as any variable grows, which are proved following some more general lemmas about asymptotics of iterated strictly inflationary functions.\n\n\\section{Inverses of Functions between Natural Numbers}\n\nIn this section we present two notions of inverses for functions $f: \\mathrm{nat} \\Rightarrow \\mathrm{nat}$. To our knowledge, this notation was introduced by Chargeraud et al. \\cite{chargueraud17} to modularize the definition of the inverse Ackermann function, as well as to ease some proofs by providing lemmas to change the proof obligations in both directions between a function and its inverse.\nIn Isabelle/HOL, this theory provides a locale which specifies the requirements to the function. For the sake of simplicity we require the function to be strictly monotonic and to tend to infinity. Many of the lemmas, as well as the definition itself, only require monotonicity. Without the asymptotic condition however, one cannot prove the existence of the inverse at every point.\n\nThis theory can be useful independently of the current context of the inverse Ackermann function. Some important concepts in the abstract analysis of the Union-Find data structure which are not directly inverses of the Ackermann function are defined using $\\alpha_f$ and $\\beta_f$, as this provides many useful lemmas.\n\n\\subsection{Definitions}\n\n\\begin{definition}{Upper inverse}\n\t\\begin{equation}\n\t\\alpha_f \\, y := \\min\\{x \\, \\mid \\, y \\le f\\, x\\}\n\t\\end{equation}\n\t$\\alpha_f\\, y$ is therefore the smallest $x$ for which $y \\le f\\, x$ holds. As the function is monotonic, this holds for all further $x$, so $y \\le f\\, x$ is equivalent to $\\alpha_f \\,y \\le f\\,x$, which makes $\\alpha_f$ an upper inverse of $f$.\n\\end{definition}\n\n\\begin{definition}{Lower inverse}\n\t\\begin{equation}\n\t\\beta_f \\, y := \\max\\{x \\, \\mid \\, f\\,x \\le y \\}\n\t\\end{equation}\n\tHere the existence is not guaranteed, as $f$ may start above $y$, so we need to require $f\\,0 \\le y$. If we have a $\\beta_f\\,y$, then it is the largest $x$, for which $f\\,x\\le y$ holds. By monotonicity the property holds for all smaller $x$. Therefore $f\\,x \\le y$ is equivalent to $x \\le \\beta_f\\,y$, which makes $\\beta_f$ a lower inverse of $f$.\n\\end{definition}\n\nThis functions of course differ by at most one, and coincide if $y$ is the image under $f$ of some $x$. In Isabelle, they are defined by the \\textit{Least} and \\textit{Greatest} operators, and the existence is shown in separate lemmas. \n\nImportant lemmas that always apply to these functions are monotonicity and that they tend to infinity (this is of course important for the inverse Ackermann function).\n\n\\begin{figure}\n\t\\centering\n\t\\resizebox{\\columnwidth}{!}{%\n\t\\begin{tikzpicture}\n\t\\begin{axis}\n\t[\n\tdomain=0:8,\n\trestrict y to domain=0:8,\n\tsamples=200,\n\txlabel=$x$,\n\tylabel=$y$, \n\txmajorgrids=true,\n\txtick distance = 1,\n\taxis lines=middle,\n\tticklabel style={font=\\tiny,fill=white},\n\tlegend pos=north east,\n\tlegend style={font=\\tiny},\n\tlegend style={at={(0.9,0.05)},anchor=south east}\n\t]\n\t\\addplot [color=TUMAccentGreen,thick]  {x^(1.3)};\n\t\\addplot [color=TUMGray] {x^(0.7692)}; \n\t\\addplot [color=TUMDarkGray,thick, forget plot] {x};\n\t\\addplot [color=TUMAccentOrange] coordinates {\n\t\t(0.0, 0.0)\n(0.01, 1.0)\n(1.0, 1.0)\n(1.0, 2.0)\n(2.46, 2.0)\n\t\t(2.46, 3.0)\n(4.17, 3.0)\n(4.17, 4.0)\n(6.06, 4.0)\n(6.06, 5.0)\n\t\t(8.0, 5.0)\n\t};\n\t\\addplot [color=TUMBlue] coordinates {\n\t(0.0, 0.0) (1.0, 0.0)\n(1.0, 1.0)\n(2.46, 1.0)\n(2.46, 2.0)\n\t(4.17, 2.0)\n(4.17, 3.0)\n(6.06, 3.0)\n(6.06, 4.0)\t(8.0, 4.0)\n\t};\n\t\\legend{$f$,$f^{-1}$,$\\alpha_f$,$\\beta_f$}\n\t\\end{axis}\n\t\\end{tikzpicture}\n}\n\\caption{Visualization of $\\alpha_f$ and $\\beta_f$ and their relationship to an exact real inverse.}\n\\caption*{Only the integer points are defined in our case.}\n\\end{figure}\n\n\\section{Inverse Ackermann Function}\n\\label{sec:inverseackermann}\n\\subsection{Historical Definitions}\n\nThe name $\\alpha_f$ suggestively relates to the historical definition of $\\alpha$ as the ``functional inverse'' of the Ackermann function \\cite{Tarjan1975b}. According to the Nist \\cite{dadsalpha} which is the most canonical source we could find the function is defined as: \\begin{equation}\n\\alpha\\,m\\,n := \\min\\{k \\geq 1 \\, \\mid \\, A\\, k\\, \\left \\lfloor {m/n} \\right \\rfloor > \\log{n} \\} \n\\end{equation}\nAnother important source is Nivasch's Ph.D. thesis \\cite{navasch09}, which uses the inverse Ackermann function for a lower bound in computational geometry. The definition is very similar to ours, albeit with rather differing notation, but with very similar bounds and same asymptotic behavior. There is also a section dedicated more thoroughly to the different versions of $A$ and $\\alpha$ in the literature.\n\n\\subsection{Definition}\nWe naturally want to use our theory about inverses of natural functions to define $\\alpha$, as did Charguéraud and Pottier We define two versions of the function, one would be the more natural single argument version of the inverse and the other follows Alstrup et al. \\cite{Alstrup14} and adds a parameter.\n\n\\begin{definition}{Inverse Ackermann function}\n\t\\begin{equation}\n\t\\alpha \\, n := \\alpha_{\\lambda k.\\, A\\, k\\, 1} \\, n\n\t\\end{equation}\n\tWhich unfolded yields:\n\t\\begin{equation}\n\t\\alpha \\, n = \\min \\{ k \\,\\mid\\, A\\, k\\, 1 \\geq n \\}\n\t\\end{equation}\n\\end{definition}\n\nThis is exactly the definition given in CLRS \\cite[pg. 574]{CLRS09}. The choice of the constant 1 seems arbitrary, but fixing the second argument of $A$ does not change much, as the first one makes the function more powerful as it grows. Following Alstrup et al. we also define a version of $\\alpha$ for an arbitrary parameter as a second argument to $A$:\n\n\\begin{definition}{Parametrized inverse}\n\\begin{equation}\n\t\\alpha_r \\, n := 1 + \\alpha_{\\lambda k.\\, A\\, k\\, r} \\, (n + 1) \\label{alphar}\n\\end{equation}\nWhich unfolded yields:\n\\begin{equation}\n\t\\alpha_r \\, n = 1 + \\min\\{ k \\,\\mid\\, A\\, k\\, r \\geq (n + 1) \\}\n\\end{equation}\n\\end{definition}\n\nThis definition is very similar to Nivasch's, except for some shifting by one. Throughout the rest of the thesis, we will assume a fixed and positive $r$, and prove all statements related to the inverse Ackermann function using $\\alpha_r$, including the final Hoare-Triples, which shows that the election of a specific $r$ is not important.\n\nWe also prove lemmas that hint at the slow rate at which $\\alpha$ grows. \n\n\\begin{lemma}{$\\alpha$\\_n\\_0\\_$\\alpha$\\_logn}\n\t\\newline\n\t\\textbf{Assume:} $16 \\leq n$\n\t\\begin{equation}\n\t\\alpha \\, n \\leq 1 + (\\alpha \\, (\\log{n}))\n\t\\end{equation}\n\t\n\\end{lemma}\n\nAccording to Charguéraud and Pottier, this lemma is far-reaching, as it shows that $\\alpha \\, n$ and $\\alpha \\, (\\log{n})$ are asymptotically equivalent. It is in fact an exercise in CLRS to show this is the case. One could even substitute $\\log$ by the iterated logarithm, or any reasonable slow-growing function, recall the fact that $A$ grows faster than any primitive recursive function.\n\nThe following lemma is much more explicit, and was one of the initial motivations for the authors to start this project:\n\n\\begin{lemma}{observable\\_universe\\_$\\alpha$}\n\t\t\\newline\n\t\\textbf{Assume:} $n \\leq 10^{80} $\n\t\\begin{equation}\n\t\\alpha \\, n \\leq 4 \\label{universealpha}\n\t\\end{equation}\n\\end{lemma}\n\nThe figure $10^{80}$ is one of the current estimates of the number of atoms in the universe. If the estimate ever grows, even significantly, it would not change the bound, as, following CLRS, we were able to prove that $A\\, 4\\, 1 > 16^{512}$. This means that for all ``practical'' inputs, with a very liberal interpretation of the word, $\\alpha$ is at most $4$.\n\n\n\n\n\n\n\\chapter{The Proof in Isabelle}\n\nThe goal of this thesis was to prove the $\\alpha$-bound asymptotic time complexity of the \\textit{Union} and \\textit{Find} operations. This proof is famously non-trivial and has been improved over the years to the current standard version in CLRS, which however has lost any insight into why the inverse Ackermann function arises. This proof does not include most details, and a formalized proof would require a far too extensive level of creativity.\n\nThe paper by Alstrup et al. improves the bound slightly by limiting the argument of $\\alpha$ to the size of the largest equivalence class, instead of the whole domain, and crucially provides some detailed proofs. They introduce some new concepts which allow for more context-sensitivity of the bounds, most importantly they link all bounds to the rank of the existing nodes (a lower bound on the size of the equivalence class) instead of to the size of the data structure, which was in earlier proofs fixed. \n\nThis is used by Charguéraud and Pottier to implement a dynamic, pointer based implementation of Union-Find in OCaml, which they verify using a similar framework implementing separation logic with time credits in Coq \\cite{Gueneau18}. The result they use for the Hoare-Triples is slightly weaker than the one by Alstrup et al. as the $\\alpha$ bound refers to the current size of the whole domain, but they formalize the tighter bound as well, which we will also prove.\n\n\nOur implementation is based on the work by Haslbeck and Lammich \\cite{HaslRef19}, which had already proved the correctness and worst-case logarithmic asymptotic complexity of an array-based implementation. In order to minimize the duplication of work, we started as close as possible to them. We decided also to follow the proof by Charguéraud and Pottier for the abstract analysis of the data structure. It was crucial that both proofs separate the abstract, mathematical view of the data structure as a relation, a graph or a list and its properties from the proof about the imperative program. This allowed us to mimic most of the Coq analysis in Isabelle, with some adaptations, even though the resulting implementation is vastly different, as are the frameworks for modeling the imperative semantics and the tools they provide. In principle, this means that many lemmas can be reused in future work by diverging implementations of Union-Find.\n\nThe proof in Coq is about 4KLoc, and our resulting proof is of similar length. This proof required many more fine-grained concepts about the data-structure, much theory surrounding them, and a different, stronger invariant (see the following section) than the one used in the worst-case analysis.\n\n\n\\section{Porting from Coq}\n\nThis section aims to give an anecdotal but hopefully practical view on the problems that arose while porting proofs from Coq to Isabelle/HOL. It should be noted as a starting remark that the authors are users only of Isabelle/HOL and have only a superficial understanding of the Coq system. A special thank you goes to Armaël Guéneau, who introduced the authors to Coq. This comparison deviates from others in the literature by providing a practical view on the current state of theorem proving in both systems rather than comparing the theoretical foundations \\cite{Comparison}.\n\nSuperficially, the Gallina language used by Coq is similar to the \\textit{apply-style} scripts that are often considered bad style in the Isabelle/HOL community. It is however much richer than that, and for the writer of proofs there does not seem to be much of a difference in the expressiveness. In particular, and in contrast to \\textit{apply-style} scripts, it is possible to construct forward proofs by explicitly stating new subgoals which can later be referenced. The Isar language is of course specifically targeted to making proofs easier to read without the proof state at every point. However, in our opinion, the current proof state is in both systems necessary to follow a difficult proof in detail. The differences lay of course much more on the tactics available, and the quality of the proof library.\n\nAll in all Coq has many more specialized tactics \\cite{CoqRefMan} which allow for some fine grained manipulation of assumptions and goals. Isabelle's tactics seem to be more powerful, and the Isar language allows for complex proofs without editing the terms explicitly. However, some tactics could be useful to improve backwards reasoning in Isabelle/HOL. The clearest advantage of Isabelle/HOL over Coq is of course the Sledgehammer tool, which simplifies proof exploration and finalization enormously. Because of this aspect alone, together with the better IDE support and the greater interactivity of the proof process we would deem the current Isabelle/jEdit system the most user-friendly, both being mostly equivalent in their power to develop proofs.\n\n\\subsection{Reasoning about Arithmetic}\n\\subsubsection{$\\mathrm{Suc}\\, x$ and $x + 1$}\n\nThis is mostly a small complaint about some lemmas which are by default in the simpset in Isabelle/HOL. Many times, a forward style arithmetic proof using Isar's equational reasoning is unnecessarily tedious, as it requires to write every step explicitly. When the steps involve precise lemmas needed to move forward, it normally boils down to looking up the lemma, tailoring the next step to use it, and proving the step by applying the lemma.\n\nIn this case a simple backward proof applying the equations and rules available is easier to follow, and much easier to write. In most cases, however, providing the lemmas to higher level tactics such as auto or simp is not enough in every step because these tend to rewrite things like $1$ to $\\mathrm{Suc}\\, 0$. Of course, a careful presentation of the lemmas helps, but is often not enough, and the proof ends up cluttered with very low level substitutions between the actual steps which make progress, which of course hinders readability. Some examples of this problem can be found in Ackermann.thy.\n\nCoq does not seem to have any tendency to rewrite \\verb|n + 1| to \\verb|S n|, so the backwards proofs are more readable.\n\n\\subsubsection{generalize dependent}\n\nConsider the following equation (easy for a human or a CAS, but difficult for the automatic tactics of a proof assistant):\n\n\\begin{equation*}\n\t2 (2 ^ i  (1 + x) - 1) + 1 = 2 \\cdot 2 ^ i(1 + x) - 1\n\\end{equation*}\n\nThe factors $2^i$ and $(1+x)$ are probably being unfolded and mangled with by the tactics, when they are not key to the identity. So one could replace them by two new variables $n$ and $y$, yielding:\n\n\\begin{equation*}\n2 (ny - 1) + 1 = 2 \\cdot n \\cdot y - 1\n\\end{equation*}\n\nwhich can be proved by a tactic, as the search space is much smaller (with an explicit and large $i$, such in the proofs about the observable universe bound of $\\alpha$, the tactics really do unfold too much and take seconds to finish).\n\nIn Coq, you can explicitly declare new variables to replace those expressions (do not pay much attention to the \\verb|intros|, that is a standard Coq idiom for a goal of the form $A \\longrightarrow B$):\n\n\\begin{lstlisting}\n\tgeneralize dependent (2^i); intro n; intros.\n\tgeneralize dependent (1+x); intro y; intros.\n\\end{lstlisting}\n\nIn Isabelle/HOL you would need to either prove the second equation first and then instantiate it or obtain some new variables relating to the old and rewriting all terms.\n\n\\subsubsection{Generalized Rewriting}\n\nThe default rewriting method in Isabelle/HOL is subst. In Coq you have \\verb|rewrite| and \\verb|replace term1 with term2|. \n\n\\verb|rewrite| is superficially mostly equivalent to subst, except for a more pleasant syntax that reduces the need for the symmetric parameter. It is possible to use it on named assumptions instead of only on an indexed occurrence. When applied to an assumption, it also does not change the whole goal from a list of assumptions and a goal $B$ to a goal of the form $A_1 \\Longrightarrow \\dots \\Longrightarrow A_n \\Longrightarrow B$.\n\nMoreover, it also allows for rewriting inequalities, so if we have an assumption of the form $A_1: B \\leq C$ and we want to show $A \\leq C$, the tactic \\verb|rewrite |$A_1$\\verb|.| will change the goal to $A \\leq B$, which in Isabelle/HOL would require to apply a transitivity rule.\n\nGeneralized rewriting can be extended to many more forms of equations axiomatically \\cite{CoqRefMan}, so it is a very powerful and extendable mechanism to deal with chains of equations.\n\n\\verb|replace| enables to rewrite equations not yet proved, so it transforms \\verb|term1| to \\verb|term2|, and then generates a subgoal for this not yet proven equality. It allows to perform simple transformations which can be proved automatically without cluttering the proof with named lemmas, or the need to recall the names of existing low level lemmas. This is also useful in making backward proofs more readable.\n\n\\subsection{Trivia}\n\n\\subsubsection{unpack}\n\nThis tactic comes from the LibTactics library by Charguéraud \\cite{LibTactics}, and destructs conjuntions and existentials in the assumptions. This is useful for example when an invariant is assumed, which is a conjunction of several properties, and when proving a specific subgoal only one of them is needed. It is also superior to the simple existential introduction rule, which only allows the existential quantifier at the outer most level.\n\n\n\\section{Abstract Analysis}\n\n\n\\begin{figure}\n\t\\centering\n\t\\resizebox{1.1\\columnwidth}{!}{%\n\t\t\\begin{tikzpicture}[transform shape]\n\t\t\n\t\t% Draw diagram elements\n\t\t\\path \\defnodea {1}{$\\alpha_f$};\n\t\t\\path (p1.south)+(5.0,0.51) \\defnodea{2}{$\\beta_f$};\n\t\t\n\t\t\\path (p1.south)+(0.0,-2.25) \\defnodeb{3}{$A$};\n\t\t\\path (p3.south)+(0.0,-1.0) \\defnodeb{5}{$\\alpha$, $\\alpha_r$};\n\t\t\\path (p3.south)+(5.0,-1.0) \\defnodeb{4}{Further contributions};\n\t\t\n\t\t\\path (p3.south)+(-7,-1) \\defnodec{6}{$\\mathcal{L}$, $\\mathcal{R}$};\n%p6\n\t\t\\path (p6.south)+(0.0,-1.0) \\defnodec{60}{level, index}; %p7\n\t\t\n\t\t\\path (p60.south)+(-2.5,-1.25) \\defnodec{7}{State Evolution};\n\t\t\\path (p60.south)+(2.5,-1.25) \\defnodec{8}{Pleasantness};\n\t\t\\path (p8.south)+(0.0,-1.0) \\defnodec{80}{Invariants};\n\t\t\n\t\t\n\t\t\\path (p7.south)+(0.0,-1.0) \\defnodec{70}{Iterated Path Compression};\n\t\t\n\t\t\\path (p70.south)+(2.5,-1.25) \\defnodec{71}{$\\phi$ and $\\Phi$};\n\t\t\\path (p71.south)+(0,-1.00) \\defnodec{72}{The Public Theorems};\n\t\t\n\t\t\n\t\t\\path (p72.south)+(-2.5,-2.5) \\defnoded{9}{$\\mathtt{init}\\, \\in \\mathcal{O}(n)$};\n\t\t\\path (p9.south)+(3,0.5) \\defnoded{10}{$\\mathtt{cmp}\\,\\in\\mathcal{O}(\\alpha\\, n)$};\n\t\t\\path (p10.south)+(3,0.5) \\defnoded{11}{$\\mathtt{union}\\,\\in\\mathcal{O}(\\alpha\\, n)$};\n\t\t\n\t\t\\path [line] (p5.east) -- +(1.3,0.0) -- +(1.3,4.3) -- node [above] {} (p1);\t\n\t\t\\path [line] (p5.east) -- +(1.3,0.0) -- +(1.3,4.3) -- node [above] {} (p2);\n\t\t\n\t\t\\path [line] (p6.north)+(0.0,0.5) -- +(0.0,1.0) -- node [above] {} (p3);\n\t\t\\path [line] (p6.north)+(0.0,0.5) -- +(0.0,1.0) -- +(4.5,1.0) -- +(4.5,-0.51) \n\t\t-- node [above] {} (p5);\n\t\t\n\t\t\\path [line] (p60.north) -- node [above] {} (p6);\n\t\t\\path [line] (p70.north) -- node [above] {} (p7);\n\t\t\n\t\t\\path [line] (p60.west) -- +(-1.35,0.0) -- node [above] {} (p7);\n\t\t\\path [line] (p7.west) -- +(-0.25,0.0) -- +(-0.25,3.3) -- node [above] {} (p6);\n\t\t\n\t\t\\path [line] (p8.north) -- +(0.0,0.25) -- +(-2.5,0.25) -- node [above] {} (p60);\n\t\t\\path [line] (p60.east) -- +(13.0,0.00) -- +(13.0,5.82) -- node [above] {} (p2);\n\t\t\n\t\t\\path [line] (p80.east) -- +(0.25,0.0) -- +(0.25,4.82) -- node [above] {} (p6);\t\n\t\t\n\t\t\\path [line] (p71.north) -- +(0.0,2.8)-- node [above] {} (p7);\t\n\t\t\\path [line] (p71.north) -- +(0.0,1.25) -- node [above] {} (p70);\t\n\t\t\\path [line] (p71.north) -- +(0.0,2.8)-- node [above] {} (p8);\t\n\t\t\\path [line] (p71.north) -- +(0.0,1.25) -- node [above] {} (p80);\t\n\t\t\n\t\t\\path [line] (p72.north) -- node [above] {} (p71);\n\t\t\n\t\t\\path [line] (p10.north)+(-0.5,0.5) -- node [above] {} (p72);\n\n\t\t\n\t\t\\background{p1}{p1}{p2}{p2}{InverseNatNat}\n\t\t\\background{p3}{p3}{p4}{p4}{Ackermann}\n\t\t\\background{p7}{p6}{p8}{p72}{Abstract Analysis}\n\t\t\\background{p9}{p9}{p11}{p11}{Imperative Verification}\n\t\t\n\t\t\n\t\t\\end{tikzpicture}\n\t}\n\t\\caption{Overview of the logical dependencies between the theories presented.} \\caption*{An arc points to the theory or section containing a required definition or lemma.}\n\\end{figure}\n\n\\subsection{Important Definitions}\nThe abstract analysis deals with the data structure as two lists, one with the tree structure $\\mathcal{L}$ and one with the corresponding ranks $\\mathcal{R}$. This view point is not enough, as we want to prove properties about the modeled disjoint set forest, equivalence class, and the transformations performed by \\textit{Union}, and by path compression.\n\n\\begin{definition}{Disjoint set forest}\n\nThe parent of a node i is: \n\\begin{equation}\n\\LL!i\n\\end{equation}\n\nThe representative of a node is:\n\\begin{equation}\n\\repof i := \\begin{cases}\ni &\\mathrm{if}\\,\\, \\LL!i = i \\\\\n\\repof (\\LL!i) &\\mathrm{otherwise}\n\\end{cases}\n%\\mathrm{if}\\,\\, \\LL!i = i \\,\\,\\mathrm{then}\\,\\, i\\,\\, \\mathrm{else}\\,\\, \\repof (\\LL!i)\n\\end{equation}\n\nThrough the representative, we identify the equivalence classes of the disjoint set forest:\n\n\\begin{equation}\n\\ufaalpha := \\{(x,y) \\,\\mid\\, x<|\\LL| \\land y<|\\LL| \\land \\repof x = \\repof y\\}\n\\end{equation}\n\nAnd the height of a node:\n\n\\begin{equation}\n\t\\mathrm{height\\_of}_\\LL\\, i := \\begin{cases}\n\t0 &\\mathrm{if}\\,\\, \\LL!i=i\\\\\n\t1 + \\mathrm{height\\_of}_\\LL\\, (\\LL!i) &\\mathrm{otherwise}\n\t\\end{cases}\n\t %\\mathrm{if}\\,\\, \\LL!i=i\\,\\, \\mathrm{then}\\,\\, 0 \\,\\,\\mathrm{else}\\,\\, 1 + \\mathrm{height\\_of}_\\LL\\, (\\LL!i)\n\\end{equation}\n\nWe also define the more precise child-parent relation:\n\n\\begin{equation}\n\\ufabstart := \\{(x,y) \\,\\mid\\, x<|\\LL| \\land y<|\\LL| \\land x \\neq y \\land \\LL!x = y \\}\n\\end{equation}\n\nIts closures, the strict and non-strict paths in the graph:\n\n\\begin{equation}\n\\ufabtrans := (\\ufabstart)^+ \\quad \\ufabrefl := (\\ufabstart)^*\n\\end{equation}\n\nWhere $R^+$ and $R^*$ are respectively the transitive and reflexive transitive hull of a relation $R$.\n\nAnd the descendants and ancestors of a node:\n\n\\begin{align}\n\\mathrm{descendants}_\\LL \\, i := \\{j \\,\\mid\\, (j,i) \\in \\ufabrefl\\} \\\\\n\\mathrm{ancestors}_\\LL \\, i := \\{j \\,\\mid\\, (i,j) \\in \\ufabrefl\\}\n\\end{align}\n\n\\end{definition}\n\n\\HandPencilLeft\\,\\, This relations are ultimately defined depending on $\\LL$, but any other functional relation (where a node has only one parent) satisfying the same classical properties of the hull could be used. All following lemmas would just need to replace any occurrence of $i < |\\LL|$ with $i \\in \\mathrm{Dom}\\, R$. In our case we did not do it, as of course $\\mathrm{Dom}\\, \\ufabrefl = \\{0, \\dots, |\\LL| - 1\\}$.\n\nWe only want to allow lists which represent a disjoint set forest, so $\\ufabtrans$ cannot have any cycles. This is characterized by the first part of the invariant required:\n\n\\begin{definition}{ufa\\_invar}\n\t\\begin{equation}\n\t\\mathrm{ufa\\_invar} \\, \\LL \\, := \\forall i < |\\LL|.\\, i \\in \\mathrm{Dom}\\, \\repof \\land \\LL!i < |\\LL|\n\t\\end{equation}\n\t\n\\end{definition}\n\nThis is equivalent to not having any cycles, as every node in a cycle would not be in the domain of $\\repof$. On top of that, we do not allow parents outside the domain.\n\nFinally, we define the full invariant enforced on the data structure (we will then show that union and path compression preserve the invariant):\n\n\\begin{definition}{invar\\_rank}\n\\begin{align}\n\\mathrm{invar\\_rank}\\, \\LL \\, \\RR := \n&\\mathrm{ufa\\_invar} \\, \\LL \\, \\land \\\\\n&|\\LL| = |\\RR| \\, \\land \\\\\n&(\\forall (i,j) \\in \\ufabstart. \\, \\RR!i < \\RR!j) \\\\\n&(\\forall i < |\\LL|.\\, \\LL!i = i \\longrightarrow 2^{\\RR!i} \\leq |\\mathrm{descendants}_\\LL \\, i|)\n\\end{align}\n\\end{definition}\n\nWhich in words means: \n\\begin{itemize}\n\t\\item $\\LL$ models a disjoint set forest.\n\t\\item The domain of the rank is the same as the domain of the child-parent relation.\n\t\\item The rank of a parent is greater than the rank of any of its children.\n\t\\item The rank of a root never exceeds the logarithm of the size of its descendants.\n\\end{itemize}\n\n\\subsection{The Rank}\n\nWe have mentioned before that the rank of a node is an upper bound on its height in the tree, this is specified by the lemma \\textit{rank\\_bounds\\_height}, which states that if there is a path from $i$ to $j$ of length $k$, then $k \\leq \\RR!j$ (or, more precisely $\\RR!i + k \\leq \\RR!j$). The longest path from a node is the one to the root, and the length of this path defines the height. As the height, the rank is bounded by $\\log{|\\LL|}$.\n\nFollowing \\cite{Alstrup14}, we will for most purposes use a modified rank:\n\n\\begin{definition}{rankr}\n\t\\begin{equation}\n\t\t\\RR_r \\, i := \\RR!i + r\n\t\\end{equation}\n\tRecall $r$ from \\ref{alphar} is a fixed parameter.\n\\end{definition}\n\nThe (modified) rank always grows along paths, and strictly along non-trivial paths, and by extension of course $\\alpha_r \\, (\\RR_r \\, i)$ also grows along paths, as $\\alpha_r$ is monotonic.\n\n\\subsection{The Level and the Index}\n\nThe potential function $\\Phi$ refers to the ``entropy'' of the data structure, so a higher potential means more disorder. The potential grows when cheap operations are performed, and decreases with expensive operations. This models the credit method defined by Tarjan when he introduced amortized analysis \\cite{Tarjan85}, a high potential means credits are saved for extra work. In our case, we will store $\\Phi$ time credits in the heap, which will be enough, together with the advertised cost, to pay for each operation. This is the key to amortized analysis with time credits.\n\nThe potential of the Union-Find data structure was defined similarly in all proofs since \\cite{Tarjan1975b}, but this form was introduced by Alstrup et al. \\cite{Alstrup14}. In order to define it, we need two subtle concepts, the index and the level (only defined for non-root nodes):\n\n\\begin{definition}{level}\n\t\\begin{align}\n\t\\mathrm{defk}\\, i \\, k &:= A\\, k \\, (\\RR_r\\ i) \\\\\n\t\\level i &:= 1 + (\\beta_{defk} \\, (\\RR_r\\ (\\LL!i)))\n\t\\end{align}\n\n\twhich unfolded yields\n\t\n\t\\begin{equation}\n\t\\level i = 1 + \\max \\{k \\,\\mid\\, \\RR_r \\, (\\LL!i) \\geq A\\, k \\, (\\RR_r\\, i)\\}\n\t\\end{equation}\n\\end{definition}\n\nThe level is well-defined, as the following $k$ always satisfies the inequality:\n\n\\begin{lemma}{level\\_exists}\n\t\\begin{equation}\n\tA\\, 0\\, (\\RR_r\\, i) \\leq \\RR_r\\, (\\LL!i)\n\t\\end{equation}\n\\end{lemma}\n\nAccording to Charguéraud and Pottier, the level of a node is a measure of the distance of its rank to the rank of its parent. Where these ranks are closest we have $\\RR_r\\, (\\LL!i) = 1 + (\\RR_r\\, i)$, so the level is exactly one. When the ranks are furthest away, we get the following lemma:\n\n\\begin{lemma}{level\\_lt\\_$\\alpha_r$} \n\t\\begin{equation}\n\t\t\\level i < \\alpha_r\\, (\\RR_r\\, (\\LL!i)) \\label{levelalpha}\n\t\\end{equation}\n\\end{lemma}\n\nThe proof of this lemma is simple because we can make use of the lemmas from the InverseNatNat.thy theory, so we can easily transform the goals into a form for which the lemmas available in Ackermann.thy apply.\n\n\\begin{definition}{index}\n\t\\begin{align}\n\t\\mathrm{prei}\\, i \\, j &:= (A\\, (\\level i - 1))^{(j)} \\, (\\RR_r\\, i)\\\\\n\t\\iindex i &:= \\beta_{prei}\\, (\\RR_r\\, (\\LL!i))\n\t\\end{align}\n\t\n\twhich unfolded yields:\n\t\n\t\\begin{equation}\n\t\\iindex i = \\max\\{j \\,\\mid\\, \\RR_r\\, (\\LL!i) \\geq (A\\, (\\level i - 1))^{(j)}\\, (\\RR_r\\, i)\\}\n\t\\end{equation}\n\\end{definition}\n\nThe index is of course always well defined, as there is always a $j$ satisfying the inequality:\n\n\\begin{lemma}{index\\_exists}\n\t\\begin{equation}\n\t(A (\\level i - 1))^{(0)} (\\RR_r\\, i) \\leq \\RR_r\\, (\\LL!i)\n\t\\end{equation}\n\\end{lemma}\n\nThe index satisfies the following lower and upper bounds:\n\n\\begin{lemma}{index\\_ge\\_1\\_le\\_rank}\n\\begin{equation}\n\t1 \\leq \\iindex i \\leq \\RR_r\\, i\n\\end{equation}\n\\end{lemma}\n\n\\subsection{The Potential Function $\\Phi$}\n\nWe define first the potential for a single node:\n\n%\\begin{definition}{$\\phi$}\n%\t\\begin{align}\n%\t\\begin{split}\n%\t\\philr i := &\\mathrm{if}\\, \\LL!i=i \\, \\mathrm{then}\\, \\alpha_r\\, (\\RR_r\\, i) \\cdot (1 + (\\RR_r\\, i)) \\\\\n%\t&\\mathrm{else} \\, (\\mathrm{if}\\, \\alpha_r\\, (\\RR_r\\, i) = \\alpha_r\\, (\\RR_r\\, (\\LL!i))\\\\\n%\t&\\quad\\quad\\,\\,\t\\mathrm{then}\\, (\\alpha_r\\, (\\RR_r\\, i) - \\level i) \\cdot \\RR_r\\, i - \\iindex i + 1 \\\\\n%\t&\\quad\\quad\\,\\, \\mathrm{else}\\, 0)\n%\t\\end{split}\n%\t\\end{align}\n%\\end{definition}\n\n\\begin{definition}{$\\phi$}\n\t\t\\begin{equation*}\n\t\t\\philr i :=\n\t\t\\begin{cases}\n\t\t\\alpha_r\\, (\\RR_r\\, i) \\cdot (1 + (\\RR_r\\, i)) & \\mathrm{if}\\, \\LL!i=i \\,   \\\\\n\t\t (\\alpha_r\\, (\\RR_r\\, i) - \\level i) \\cdot \\RR_r\\, i - \\iindex i + 1  &\\mathrm{if}\\, \\alpha_r\\, (\\RR_r\\, i) = \\alpha_r\\, (\\RR_r\\, (\\LL!i))\\\\\n\t\t0 & \\mathrm{otherwise}\n\t\t\\end{cases}\n\t\t\\end{equation*}\n\\end{definition}\n\n\nThere are according lemmas that guarantee that the subtractions will not result in a negative number. In fact, except in the last case, where $\\phi$ is explicitly set to $0$, we have $\\philrb \\geq 1$.\n\nTo define the potential of the entire data structure, we sum over every node:\n\n\\begin{definition}{$\\Phi$}\n\t\\begin{equation}\n\t\\Philr :=  \\sum_{i = 0}^{|\\LL| - 1}{\\philr i}\n\t\\end{equation}\n\t\n\\HandPencilLeft \\, \\, Recall again that $\\{0,\\dots, |\\LL|-1\\}$ is in this case the domain of our equivalence relation. In an alternative implementation of the data structure, this would be a sum over its domain.\n\n\\end{definition}\n\n\\subsection{State Evolution}\n\nOn our way to analyzing the behavior of \\verb|uf_union| and \\verb|uf_cmp|, we first define the union of two disjoint set trees and a single step of path compression abstractly. These are the only operations that modify the state and thus need to be analyzed to ensure they do not break the invariant:\n\n\\begin{definition}{Abstract Union}\n\t\\newline\n\tFirst, we define the union of the equivalence classes of two nodes:\n\t\\begin{equation}\n\t\\ufaunion x \\, y := \\LL[\\repof x := \\repof y]\n\t\\end{equation}\n\t\n\tHowever, we only perform unions according to the rank heuristic, therefore we define the operations that, given a disjoint set forest list and a rank list, return the modified lists:\n\t\n\t\\begin{align}\n\t%\\ufaunionl x\\,y := \\mathrm{if} \\, \\RR!x < \\RR!y \\,&\\mathrm{then}\\, \\ufaunion x\\,y \\\\\n\t%&\\mathrm{else}\\, \\ufaunion y\\,x\n\t\\ufaunionl x\\,y &:= \\begin{cases} \\ufaunion x\\,y &\\,\\,\\,\\, \\mathrm{if} \\, \\RR!x < \\RR!y \\\\\\ufaunion y\\,x &\\,\\,\\,\\, \\mathrm{otherwise}\n\t\\end{cases}\n\t\\\\\n\t%\\ufaunionrkl x\\, y := \\mathrm{if} \\, \\RR!x = \\RR!y \\,&\\mathrm{then}\\, \\RR[x := 1 + \\RR!x] \\\\\n\t%&\\mathrm{else}\\, \\RR\n\t\\ufaunionrkl x\\, y &:= \\begin{cases} \\RR[x := 1 + \\RR!x] & \\mathrm{if} \\, \\RR!x = \\RR!y \\\\\\RR & \\mathrm{otherwise}\n\t\\end{cases}\n\t\\end{align}\n\t\n\tThe operation $\\mathcal{L}[x := y]$ is just the list update operation, replacing the element in $\\mathcal{L}$ at position $x$ by $y$.\n\t\n\\end{definition}\n\n\nWe have yet to consider the iterated path compression, which not only links a node to the root, but also all the nodes on the path to the root. Before that, we prove that union of two trees and a single step of compression preserve the invariant. These two elementary operations are what we call in the Isabelle proof \\textit{State Evolution}. We modify the state of the data structure only through composition of these operations.\n\n\\begin{lemma}{invar\\_rank\\_union}\\newline\n\\textbf{Assume: } $\\mathrm{invar\\_rank}\\,\\LL\\,\\RR$; $x,y < |\\LL|$; $x \\neq y$; $x = \\LL!x$; $y = \\LL!y$\n\\begin{equation}\n\\mathrm{invar\\_rank}\\,(\\ufaunionl x\\,y)\\,(\\ufaunionrkl x\\,y)\n\\end{equation}\n\\end{lemma}\n\n\\begin{lemma}{invar\\_rank\\_compress}\\newline\n\\textbf{Assume: } $\\mathrm{invar\\_rank}\\,\\LL\\,\\RR$; $(x,y) \\in \\ufabstart$\n\\begin{equation}\n\t\\mathrm{invar\\_rank}\\, (\\LL[x := \\repof y])\\, \\RR\n\\end{equation}\n\\end{lemma}\n\nThe change of the rank during state evolution is more or less trivial. It is monotone and only really increases for roots. The analysis of the level and the index is more subtle, and we come to the following conclusions (we refer to the Isabelle proof for the detailed statements): \n\\begin{itemize}\n\t\\item \\mbox{\\textbf{Lemma.} \\textit{levelx\\_levely\\_compress} \\eqnum:} \\newline During compression on $x$, either the rank or the index increase. \n\t\\item \\mbox{\\textbf{Lemma.} \\textit{level\\_v\\_grows}} \\eqnum: \\newline During any state evolution step, as the rank of a non-root node $x$ is constant while the rank of its parent may grow, the level of $x$ can only grow.\n\t\\item \\mbox{\\textbf{Lemma.} \\textit{index\\_v\\_grows\\_if\\_level\\_v\\_constant}} \\eqnum: \\newline After a state evolution step, if the level remains constant, the index can only grow.\n\\end{itemize}\n\n\\subsection{Iterated Path Compression}\n\nWe define two equivalent inductive predicates which encode the operation of compressing a whole path, up to the root:\n\n\\begin{definition}{Forward and backward iterated path compression}\n\\begin{align}\n\\begin{split}\n\t&\\text{ BWIPCBase: \n\t\\AxiomC{$x = \\mathcal{L}!x$}\n\t\\UnaryInfC{$\\mathrm{bw\\_ipc}\\, \\mathcal{L}\\, x\\, 0\\, \\mathcal{L}$}\n\t\\DisplayProof\n\t} \\\\\n\t\\\\\n\t&\\text{ BWIPCStep: \n\t\t\\AxiomC{$(x,y) \\in \\ufabstart$}\n\t\t\\AxiomC{$\\mathrm{bw\\_ipc}\\, \\mathcal{L}\\, y\\, i\\, \\mathcal{L}'$}\n\t\t\\BinaryInfC{$\\mathrm{bw\\_ipc}\\, \\mathcal{L}\\, x\\, (i + 1)\\, \\mathcal{L}'[x := \\repof x]$}\n\t\t\\DisplayProof\n\t}\n\\end{split}\n\\\\\n\\begin{split}\n\t&\\\\\n\t&\\text{ FWIPCBase: \n\t\\AxiomC{$x = \\mathcal{L}!x$}\n\t\\UnaryInfC{$\\mathrm{fw\\_ipc}\\, \\mathcal{L}\\, x\\, 0\\, \\mathcal{L}$}\n\t\\DisplayProof\n\t} \\\\\n\t\\\\\n\t&\\text{ FWIPCStep: \n\t\\AxiomC{$(x,y) \\in \\ufabstart$}\n\t\\AxiomC{$\\mathrm{fw\\_ipc}\\, \\mathcal{L}\\, y\\, i\\, \\mathcal{L}'[x := \\repof y]$}\n\t\\BinaryInfC{$\\mathrm{fw\\_ipc}\\, \\mathcal{L}\\, x\\, (i + 1)\\, \\mathcal{L}'$}\n\t\\DisplayProof\n\t}\n\\end{split}\n\\end{align}\n\nipc stands in both cases for iterated path compression and, in words, $\\mathrm{ipc}\\,  \\mathcal{L}\\, x\\, i\\, \\mathcal{L}'$ means that in the initial state $\\mathcal{L}$, performing path compression along the path starting at $x$ leads in $i$ steps to the final state $\\mathcal{L}'$.\n\\end{definition}\n\nThe forward variant corresponds intuitively to a two-pass algorithm, similar to our implementation, in which a first pass finds the representative of x, and the second pass performs the compression. This is clearly the composition of several compression steps formulated in the previous section. This formulation therefore makes the proof of many lemmas simpler.\n\nThe backwards variant is more alike a one-pass, recursive algorithm for path compression, similar to the one by Charguéraud and Pottier, where path compression is performed while unwinding the stack created by recursively finding the representative. This formulation is not clearly the composition of several compression steps as it is not trivial that the representative of $x$ before compression remains the same after compression.\n\nIn a non-formal proof, one could say it is obvious that paths and representatives on trees not affected by compression are not changed, or that the final state $\\mathcal{L}'$ is always defined and unique, and indeed that the two predicates are equivalent. All these statements were inductively proved in this formal context. \n\n\n\\subsection{Pleasantness}\n\nWe define the notion of pleasantness, which is the property of a node of having a strict non-root ancestor with identical level, and we derive an upper bound on the amount of unpleasant nodes. This part of the analysis was particularly challenging, as it required a more comprehensive theory about preservation of invariants and paths than the previous lemmas, among others the preservation of $\\mathrm{ufa\\_invar}$ after arbitrary compressions that do not generate a cycle, as well as a very careful use of contexts and generalizations.\n\n\\begin{definition}{top\\_part}\\newline\n\tWe define a node to be in the top part of its tree if $\\alpha_r$ of its rank is the same as $\\alpha_r$ of the rank of the root (its representative):\n\t\\begin{equation}\n\t\\toppart x := (\\alpha_r\\, (\\RR_r\\, x)) = (\\alpha_r\\, (\\RR_r\\, \\repof x))\n\t\\end{equation}\n\tthe plesantness notion:\n\t\\begin{align}\n\t\\begin{split}\n\t\\pleasant x := \\, & \\toppart x \\, \\land \\\\\n\t\t\t& (\\exists y.\\, y\\neq \\LL!y \\land ((\\LL!x),y)\\in\\ufabrefl \\,\\land \\\\\n\t\t\t& \\level x = \\level y)\n\t\\end{split}\n\t\\end{align}\n\tthis is a sound definition of the top-part, as it is preserved when going up the graph (\\textbf{Lemma.} top\\_part\\_hereditary \\eqnum).\n\t\n\tWe define the displeasure of a node as the number of unpleasant ancestors:\n\t\\begin{equation}\n\t\\displeasure x\\, := \\, |(\\mathrm{ancestors}_{\\LL}\\, x) \\cap \\{y\\,\\mid\\, \\lnot \\pleasant y\\}|\n\t\\end{equation}\n\\end{definition}\n\nThe displeasure of a parent grows by exactly one if the child was unpleasant, and stays constant if the child was pleasant. (\\textbf{Lemma.} \\textit{displeasure\\_parent\\_if\\_unpleasant} \\eqnum\\, and \\textbf{Lemma.} \\textit{displeasure\\_parent\\_if\\_pleasant} \\eqnum).\n\nFinally, we show that the displeasure of a node is bounded by the number of distinct levels of its non-root ancestors (this number is called in the proof the \\textit{levels} of a node), and in turn this is bounded by $\\alpha_r$ of the rank of its representative. To prove this, we need to distinguish between pleasant and unpleasant nodes, establish a bound that relates to their \\textit{levels}, and at the end relate \\textit{levels} to $\\alpha_r$. There are also several lemmas about the conservation of displeasure after compression. \n\nAt the end, we arrive at the main result in Alstrup et al.'s paper, from which we will derive the public theorems:\n\n\\begin{lemma}{bounded\\_displeasure\\_alstrup} \\newline\n\t\\textbf{Assume: } $\\toppart x$; $x<|\\LL|$\n\t\\begin{equation}\n\t\t\\displeasure x \\leq \\alpha_r\\, (\\RR_r\\, (\\repof x))\n\t\\end{equation}\n\\end{lemma}\n\nThis result ultimately follows from \\ref{levelalpha}, and the monotonicity of the level along paths.\n\n\\subsection{The Public Theorems}\n\nWe called this theorems public, as they are in principle the only ones needed by a user of the abstract data structure to prove the correctness and the asymptotic properties of an implementation. If we regard the whole proof as a black box, these are the only really interesting results.\n\n\\subsubsection{Theorems for the Amortized Analysis}\n\nThe main theorem relates the steps required to perform an iterated path compression, the potential before and after the compression, and $\\alpha_r$ of some measure in the data structure. These theorems implicitly assume the invariant for the lists. We will start with the strong result by Alstrup et al.:\n\n\\begin{theorem}{amortized\\_cost\\_of\\_iterated\\_path\\_compression\\_local} \\newline\n\t\\textbf{Assume: } $x < |\\LL|$\n\t\\begin{align}\n\t\\begin{split}\n\t\\exists i\\, \\LL'.\\,& \\mathrm{bw\\_ipc}\\, \\LL\\, x\\, i\\, \\LL'\\, \\land\\\\\n\t& \\Phi\\, \\LL'\\, \\RR\\, + i < \\Philr + 2 \\cdot \\alpha_r\\, (\\RR_r\\, (\\repof x))\n\t\\end{split}\n\t\\end{align}\n\tIt is called local because the bound refers to the rank of the representative, so it is just bounded by the size of the equivalence class instead of by the size of the whole data structure. \n\t\n\t\\HandPencilLeft\\, We could use this theorem to prove a tighter bound in the Hoare-Triple, which also does not depend on the size of the domain.\n\\end{theorem}\n\nWe know that the rank is bound by the logarithm of the size of its equivalence class, and in turn this is roughly bound by the size of the domain:\n\n\\begin{theorem}{amortized\\_cost\\_of\\_iterated\\_path\\_compression\\_global} \\newline\n\t\\textbf{Assume: } $x < |\\LL|$\n\t\\begin{align}\n\t\\begin{split}\n\t\\exists i\\, \\LL'.\\,& \\mathrm{bw\\_ipc}\\, \\LL\\, x\\, i\\, \\LL'\\, \\land\\\\\n\t& \\Phi\\, \\LL'\\, \\RR\\, + i < \\Philr + 2 \\cdot \\alpha_r\\, (|\\LL| + (r - 1))\n\t\\end{split}\n\t\\end{align}\n\\end{theorem}\n\nThis theorem will be used to prove the Hoare-Triple for \\verb|uf_rep_of_c|, which is our implementation of the iterated path compression, and the other bounds just follow as a composition of this result and constant size operations.\n\nMuch less spectacularly, we must also prove that during the union of two trees the potential only changes by a constant. We can safely assume that the union will occur on roots, as in practice this is the only case:\n\n\\begin{theorem}{potential\\_increase\\_during\\_link} \\newline\n\t\\textbf{Assume: } $x \\neq y$; $x<|\\LL|$; $y<|\\LL|$; $x=\\LL!x$; $y=\\LL!y$\n\t\\begin{equation}\n\t\\Phi\\, (\\mathrm{union\\_by\\_rank}_{\\LL,\\RR}^{(\\LL)}\\,x\\,y) \\, (\\mathrm{union\\_by\\_rank}_{\\LL,\\RR}^{(\\RR)}\\,x\\,y) \\leq \\Philr + 2\n\t\\end{equation}\n\\end{theorem}\n\n\\subsubsection{Theorems for the Functional Correctness}\n\nThe Hoare-Triples of course also provide the correctness of the implementation, so the following lemmas also need to be provided (here presented only informally):\n\n\\begin{itemize}\n\t\\item \\textbf{Lemma. }\\textit{invar\\_rank\\_evolution} \\eqnum: A State Evolution step preserves the full invariant.\n\t\\item \\textbf{Lemma. }\\textit{ufa\\_union\\_correct} \\eqnum: The \\textit{Union} operation, defined as the merging of the two trees, merges the equivalence classes. This lemma and its proof come from the work by Lammich.\n\t\\item \\textbf{Lemma. }\\textit{bw\\_ipc\\_root\\_unique} \\eqnum: Performing backward iterated path compression on a root can only yield the same list after $0$ steps. This is used as an induction basis.\n\t\\item \\textbf{Lemma. }\\textit{ufa\\_compress\\_aux} \\eqnum: A disjoint set forest remains a disjoint set forest after compression to a root (a generalized version was needed for the abstract analysis which enables arbitrary compressions within a tree).\n\t\\item \\textbf{Lemma. }\\textit{rep\\_of\\_invar\\_along\\_path} \\eqnum: The representative of all nodes sharing a path is the same.\n\\end{itemize}\n\n\\section{Separation Logic with Time Credits}\n\nThe concept that time credits can be ``stored'' in a data structure to be used later in time as a way to simplify amortized complexity analysis was introduced by Tarjan \\cite{Tarjan85}, and later formalized by Atkey \\cite{Atkey10} within separation logic \\cite{Reynolds02}. Separation logic is used here, very roughly, as a way to reason about mutable resources in a heap. This is a very natural way of formalizing and proving Hoare-Triples for modular programs, as every separated part of the heap can be dealt with separately.\n\nWe will not go into detail about the exact definition of the low-level concepts of separation logic, but for the sake of explaining the notation used in the Hoare-Triples, we will provide an informal explanation of the most important components:\n\\begin{itemize}\n\t\\item $\\uparrow(P)$ holds if the heap is empty and $P$ holds as a predicate.\n\t\\item true and false hold respectively for every heap and for no heap.\n\t\\item $p \\mapsto_a xs$ is the ``points-to'' assertion. The memory cell at location $p$ exists, is ``owned by us'' and contains an array representing the list $xs$.\n\t\\item $P_1 * P_2$ is the separating conjunction. It holds if the heap can be split into two disjoint parts which respectively satisfy $P_1$ and $P_2$.\n\t\\item $\\exists_A x.\\, P$ is just existential quantification lifted to assertions.\n\\end{itemize}\n\n\nIn our analysis, we use the framework by Zhan and Haslbeck \\cite{ZhanHasl18}, which implements Separation Logic with Time Credits as an extension to the already existing separation logic for Imperative/HOL \\cite{Bulwahn08}. The idea of this new semantics is that for any execution to succeed, there has to be as many time credits available as ``atomic steps'' of computation performed. \n\n\\begin{definition}{Hoare-Triple}\n\t\\begin{equation}\n\t\t\\langle P \\rangle \\quad \\verb|c| \\quad \\langle Q \\rangle\n\t\\end{equation}\n\tstates that for every heap $h$ satisfying $P$ the following holds: the execution of \\verb|c| is successful with a new heap $h'$ and a return value $r$ after $t$ time steps, $P$ contains $n \\geq t$ time credits, $Q$ contains $n-t$ time credits, and the new heap $h'$ satisfies $Q\\, r$.\n\\end{definition}\n\nIn our analysis we will always use the short notation $\\langle P \\rangle \\quad \\verb|c|\\quad \\langle Q \\rangle_t$ which stands for $\\langle P \\rangle \\quad \\verb|c|\\quad \\langle Q * \\mathrm{true} \\rangle$. As the $\\mathrm{true}$ assertion holds for every heap, we can in this way ignore some of the remaining time credits, as $\\$(a + b) = \\$a * \\$b$, and $\\mathrm{true}$ holds for $\\$b$. This means that the assertion $Q$ does not need to store all of the $n - t$ remaining credits and we may ``throw away'' the rest. If an implementation change required some additional amount of time credits to execute, and there were enough spare credits being thrown away, there would be no need to change the analysis or the Hoare-Triples. This is sometimes referred to in the literature about Separation Logic with Time Credits as ``garbage collection'', as the part of the heap not longer owned and thrown away can model an idealized garbage collection \\cite{chargueraud17}.\n\n\n\\section{The Hoare-Triples}\n\nIn this section we will present the semantic public interface of the data structure, which guarantees the amortized time bound. Following the reasoning above, the idea of an amortized analysis through separation logic with time credits in practice is the following: \n\\begin{itemize}\n\t\\item Define an assertion which abstracts the data structure and ``stores'', together with the data itself, $\\Phi$ time credits.\n\t\\item Prove the following Hoare-Triples: assuming you have as a precondition the assertion defined above together with an advertised cost of $f\\, n$ time credits, you can execute the operation and at the end you have the corresponding assertion of the modified structure.\n\\end{itemize}\n\nAt the end of a sequence of $k$ operations, only the advertised cost has been paid every time, so the sequence has costed $k \\cdot (f\\, n)$ time credits. This means by definition that the operation has an amortized time complexity of $f$. How many credits were used in every operation, and therefore stored according to the following assertion is from this perspective unknown, but is irrelevant to the statement about the amortized complexity.\nWe define the assertion abstracting our union-find data structure as follows:\n\n\\begin{definition}{is\\_uf}\n\t\\begin{align}\n\t\\begin{split}\n\t\\mathrm{is\\_uf}\\, \\mathcal{X} \\, (s,p) := \n\t&\\exists_A \\LL\\, \\RR.\\, p \\mapsto_a \\LL * s \\mapsto_a \\RR\\, * \\\\\n\t&\\uparrow (\\ufaalpha = \\mathcal{X} \\land \\mathrm{invar\\_rank}\\, \\LL \\, \\RR)\\, * \\\\\n\t&\\$(4\\cdot\\Philr)\n\t\\end{split}\n\t\\end{align}\n\t\nThe existential quantification is necessary so that $\\mathrm{is\\_uf}$ only depends on the arrays and not on the lists modeled by them. This is only a minor inconvenience in the proofs, which of course require the lists to apply the abstract lemmas.\n\\end{definition}\n\nIn words, this assertion states the following: \\begin{itemize}\n\t\\item There exist lists $\\mathcal{L}$ and $\\mathcal{R}$ which model the contents of the arrays $p$ and $s$ respectively.\n\t\\item $\\mathcal{L}$ and $\\mathcal{R}$ satisfy the invariant, in particular, $\\mathcal{L}$ is a disjoint set forest and $\\mathcal{R}$ has been well formed according to our specification.\n\t\\item The equivalence relation modeled by the disjoint set forest is exactly $\\mathcal{X}$.\n\t\\item We have $4\\cdot \\Phi$ time credits stored, which can be used additionally to the advertised cost of an operation.\n\\end{itemize}\n\n\nAs a small disclaimer, the concrete advertised cost functions are only asymptotically optimal. No effort has been put into tightening linear factors, as this is in any case implementation dependent, and in our opinion it does not add anything to the significance of the result, making it however more difficult to make small changes to the implementation.\n\n\n\n\\catcode`\\_=13 \n\\def_{\\textunderscore}\n\\subsection{uf_init}\n\\catcode`_=8\n\n\\begin{definition}{uf\\_init\\_time}\n\t\\begin{equation}\n\t\\mathrm{uf\\_init\\_time}\\, n := 16n + 12\n\t\\end{equation}\n\\end{definition}\n\n\\begin{lemma}\n\t\\begin{equation}\n\t\\mathrm{uf\\_init\\_time}\\, \\in \\mathcal{O}(n)\n\t\\end{equation}\n\\end{lemma}\n\n\\begin{theorem}{uf\\_init\\_rule}\n\t\\begin{equation}\n\t\\left\\langle \\$(\\mathrm{uf\\_init\\_time}\\, n) \\right\\rangle \\quad \\mathtt{uf\\_init}\\, n\n\t\\quad \\left\\langle \\mathrm{is\\_uf}\\, \\{(i,i) \\,\\mid\\, i<n\\} \\right\\rangle_t\n\t\\end{equation}\n\\end{theorem}\n\n\n\\subsection{Hoare-Triples for the Private Functions}\n\n\\verb|uf_compress| and \\verb|uf_rep_of| will ultimately only be used as a subroutine of \\verb|uf_rep_of_c|, in turn a subroutine of \\verb|uf_cmp| and \\verb|uf_union|, so these do not require the more abstract version of the Hoare-Triple, with the existentially quantified lists. Therefore the Hoare-Triples are a bit lengthier, but are really conceptually simpler.\n\n\\begin{lemma}{uf\\_rep\\_of\\_rule}\\newline\n\t\\textbf{Assume: } $\\mathrm{ufa\\_invar}\\, l$; $i<|\\LL|$\n\t\\begin{align}\n\t\\begin{split}\n\t\\left\\langle p\\mapsto_a \\LL \\, * \\$(\\mathrm{height\\_of}_\\LL\\, i + 2) \\right\\rangle \\quad & \\mathtt{uf\\_rep\\_of} \\, p\\,i \\\\ \n\t&\\left\\langle \\lambda\\, r.\\, p\\mapsto_a \\LL \\, * \\uparrow(r = \\repof i)\\right\\rangle_t\n\t\\end{split}\n\t\\end{align}\n\t\n\t\n\\end{lemma}\n\n\\begin{lemma}{uf\\_compress\\_rule}\\newline\n\t\\textbf{Assume: } $\\mathrm{invar\\_rank}\\,\\LL\\,\\RR$; $i<|\\LL|$; $c = \\repof i$; $\\mathrm{bw\\_ipc}\\, \\LL \\, i\\, d\\, \\LL'$\n\t\\begin{align}\n\t\\begin{split}\n\t\\left\\langle p \\mapsto_a \\LL\\, * \\$(1 + d + 3)\\right\\rangle \\quad \n\t&\\mathtt{uf\\_compress}\\, i\\, c \\\\\n\t&\\langle \\lambda\\,\\_.\\, p \\mapsto_a \\LL'\\, *\t\\uparrow(\\mathrm{invar\\_rank}\\,\\LL'\\,\\RR \\land |\\LL'|=|\\LL| \\land\\\\\n\t&(\\forall i<|\\LL|.\\, \\repof i = \\mathrm{rep\\_of}_{\\LL'}\\, i)) \\rangle_t\n\t\\end{split}\n\t\\end{align}\n\tThis lemma links the abstract concept of iterated path compression with its imperative implementation. The proof is by induction on the predicate $\\mathrm{bw\\_ipc}$ and requires some bookkeeping, but really just follows the code.\n\\end{lemma}\n\n\\catcode`\\_=13 \n\\def_{\\textunderscore}\n\\subsubsection{Compressing when Looking for a Representative}\n\\catcode`_=8\n\nThe function \\verb|uf_rep_of_c| performs a representative search and iterated path compression on the path to this representative. The function is therefore the key to the adequacy of $\\Phi$ as the potential function. It is here that the important theorem \\textit{amortized\\_cost\\_of\\_iterated\\_path\\_compression\\_global} is used, so we can advertise a cost of $\\alpha_r$. The fact that compression is performed is of course crucial to this efficiency bound.\n\n\\begin{definition}{uf\\_rep\\_of\\_c\\_time}\n\\begin{equation}\n\t\\mathrm{uf\\_rep\\_of\\_c\\_time}\\, n := 8 \\cdot \\alpha_r\\, (n + (r - 1)) + 16\n\\end{equation}\n\\end{definition}\n\n\\begin{lemma}{uf\\_rep\\_of\\_c\\_rule}\\newline\n\t\\textbf{Assume: } $\\mathrm{invar\\_rank}\\,\\LL\\,\\RR$; $i<|\\LL|$\n\t\\begin{align}\n\t\\begin{split}\n\t\\langle p\\mapsto_a\\LL\\, * &\\$(4 \\cdot \\Philr + \\mathrm{uf\\_rep\\_of\\_c\\_time}\\, |\\LL|) \\rangle \\quad \\mathtt{uf\\_rep\\_of\\_c}\\, p\\, i \\\\\n\t&\\langle \\lambda\\, r.\\, \\exists_A \\LL'.\\, p\\mapsto_a \\LL' \\, *\\\\\n\t& \\uparrow(r = \\repof i \\land \\mathrm{invar\\_rank}\\,\\LL'\\,\\RR \\land |\\LL|=|\\LL'| \\land \\\\\n\t& (\\forall i<|\\LL|.\\, \\repof i = \\mathrm{rep\\_of}_{\\LL'}\\, i)) * \\$(4 \\cdot \\Phi \\,\\LL'\\,\\RR)\\rangle_t\n\t\\end{split}\n\t\\end{align}\n\t\n\\end{lemma}\n\n\\catcode`\\_=13 \n\\def_{\\textunderscore}\n\\subsection{uf_cmp}\n\\catcode`_=8\n\nThe Hoare-Triple present here is in the abstract form. The reader is encouraged to look into the Isabelle code to see how this is refined from statements similar to the ones in the previous subsection.\n\n\\begin{definition}{uf\\_cmp\\_time}\n\t\\begin{equation}\n\t\\mathrm{uf\\_cmp\\_time}\\, n := 2 \\cdot \\mathrm{uf\\_rep\\_of\\_c\\_time}\\, n + 10\n\t\\end{equation}\n\\end{definition}\n\n\\begin{lemma}\n\t\\begin{equation}\n\t\\mathrm{uf\\_cmp\\_time}\\, \\in \\mathcal{O}(\\alpha_r\\,n)\n\t\\end{equation}\n\\end{lemma}\n\n\\begin{theorem}{uf\\_cmp\\_rule}\n\t\\begin{align}\n\t\\begin{split}\n\t\\langle \\mathrm{is\\_uf}\\, \\mathcal{X}\\, u\\, * \\$(\\mathrm{uf\\_cmp\\_time}\\, |\\mathrm{Dom}\\, \\mathcal{X}|)\\rangle \\quad &\\mathtt{uf\\_cmp}\\, u\\, i\\, j\\\\\n\t&\\langle \\mathrm{is\\_uf}\\, \\mathcal{X}\\, u\\, * \\uparrow(r \\leftrightarrow (i,j)\\in\\mathcal{X}) \\rangle_t\n\t\\end{split}\n\t\\end{align}\n\t$u$ is here the tuple of arrays representing the data structure. It is not explicitly unfolded to highlight that the data structure should be viewed only in its abstract form here.\n\\end{theorem}\n\n\\catcode`\\_=13 \n\\def_{\\textunderscore}\n\\subsection{uf_union}\n\\catcode`_=8\n\n\\begin{definition}{uf\\_union\\_time}\n\t\\begin{equation}\n\t\\mathrm{uf\\_union\\_time}\\, n := 2 \\cdot \\mathrm{uf\\_rep\\_of\\_c\\_time}\\, n + 20\n\t\\end{equation}\n\\end{definition}\n\\begin{lemma}\n\t\\begin{equation}\n\t\\mathrm{uf\\_union\\_time}\\, \\in \\mathcal{O}(\\alpha_r\\,n)\n\t\\end{equation}\n\\end{lemma}\n\\begin{theorem}{uf\\_union\\_rule} \\newline\n\t\\textbf{Assume: } $i,j \\in \\mathrm{Dom}\\, \\mathcal{R}$\n\t\\begin{align}\n\t\\begin{split}\n\t\\langle \\mathrm{is\\_uf}\\, \\mathcal{X}\\, u\\, * \\$(\\mathrm{uf\\_union\\_time}\\, |\\mathrm{Dom}\\, \\mathcal{X}|)\\rangle \\quad &\\mathtt{uf\\_union}\\, u\\, i\\, j\\\\\n\t&\\langle \\mathrm{is\\_uf}\\, (\\mathrm{per\\_union}\\, \\mathcal{X}\\, i\\, j)\\rangle_t\n\t\\end{split}\n\t\\end{align}\n\t$\\mathrm{per\\_union}$ is just the function that merges the two equivalence classes belonging to $i$ and $j$, exactly what \\verb|uf_union| is supposed to do.\n\\end{theorem}\n\nThe proof of this theorem is 400 LoC long, but it is very repetitive and many of the small steps could be replaced with more tailored arguments to the sep\\_auto tactic. It would still not be trivial, but all lemmas required to instantiate the correct lists and prove the invariant after the transformation are present, so it is just a matter of optimizing the proof both in length and readability.\n\n\n\n\\chapter{Conclusions}\n\n\n\nIn this thesis we have proved the classical result about the $\\alpha$-bound amortized complexity of an imperative Union-Find data structure. We have further formalized all the mathematical analysis required to prove the state of the art bound by Alstrup et al. for a differing implementation which allows for a growth of the domain of the equivalence relation. This is, to our knowledge, together with the Coq formalization by Charguéraud and Pottier, the only result of this kind. \n\nOn top of that, we provide a more comprehensive theory about the Ackermann function and the first theory about the inverse Ackermann function in Isabelle/HOL, as well as a theory about inverses of natural number functions, which can be used in different contexts. Our formalization of the lemma \\ref{universealpha} is, to our knowledge, unprecedented, and thus the first formalization of this intuitively impressive result about the actual slow rate at which $\\alpha$ grows.\n\nThe proofs of the Hoare-Triples are still a bit too long. This is partly due to lack of optimization of the proofs, because of our limited time, but also to the still lacking support for linear arithmetic by the automation in the Separation Logic with Time Credits framework, and its too aggressive instantiation of existentially quantified variables. This is nonetheless an improvement to the situation in Coq, where, to our knowledge, no such automation is provided. The sep\\_auto method is, for instance, very capable of automatically proving statements about pure separation logic.\n\nIn our opinion, this result further demonstrates the feasibility of formally verifying the functional correctness and running time bounds for non-trivial algorithm implementations. As it is always the case with formal proofs, it is sometimes necessary to invest time proving intuitively trivial facts, but sometimes this process highlights some necessary hidden assumptions, which are too often ignored in non-formal contexts.\n\n\n\n\\appendix{}\n\n\\microtypesetup{protrusion=false}\n\\lstlistoflistings{}\n\\listoffigures{}\n%\\listoftables{}\n\\microtypesetup{protrusion=true}\n\\printbibliography{}\n\n\\end{document}\n", "meta": {"hexsha": "3d1a1f84af45e0fe8d5aa9b9ff99fda8846e2013", "size": 75057, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tum-thesis-latex-master/main.tex", "max_stars_repo_name": "adrilow/Proof-of-the-amortized-time-complexity-of-the-Union-Find-data-structure-in-Isabelle-HOL", "max_stars_repo_head_hexsha": "293b12752261dac7f741483b62b27891bf4be1cc", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tum-thesis-latex-master/main.tex", "max_issues_repo_name": "adrilow/Proof-of-the-amortized-time-complexity-of-the-Union-Find-data-structure-in-Isabelle-HOL", "max_issues_repo_head_hexsha": "293b12752261dac7f741483b62b27891bf4be1cc", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tum-thesis-latex-master/main.tex", "max_forks_repo_name": "adrilow/Proof-of-the-amortized-time-complexity-of-the-Union-Find-data-structure-in-Isabelle-HOL", "max_forks_repo_head_hexsha": "293b12752261dac7f741483b62b27891bf4be1cc", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-05T10:54:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-05T10:54:16.000Z", "avg_line_length": 57.4709035222, "max_line_length": 965, "alphanum_fraction": 0.7251955181, "num_tokens": 22051, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283035, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4100454233926549}}
{"text": "\\chapter{Overview}\n\\label{cha:overview}\n\nThis chapter gives informal introduction to the RFSM language and of how to use it to describe \nFSM-based systems.\n\n\\section{Introductory example}\n\\label{sec:first-example}\n\nListing~\\ref{lst:rfsm-gensig} is an example of a simple RFSM program\\footnote{This program is\n  provided in the distribution, under directory \\texttt{examples/single/gensig/v2}.}. This program is\nused to describe and simulate the model of a calibrated pulse generator. Given an input clock\n\\verb|H|, with period $T_H$, it generates a pulse of duration $n \\times T_H$ whenever input\n\\texttt{E} is set when event $H$ occurs.\n\n\\begin{lstlisting}[language=Rfsm,frame=single,numbers=left,caption=A simple RFSM\n  program,label={lst:rfsm-gensig},float]\n@\\label{gensig-1a}@fsm model gensig <n: int> (\n  in h: event,\n  in e: bool,\n  out s: bool)\n{\n  states: E0, E1;\n@\\label{gensig-3}@  vars: k: int<0:n>;\n  trans:\n  | E0 -> E1 on h when e=1 with k:=1,s:=1\n@\\label{gensig-4}@  | E1 -> E1 on h when k<n with k:=k+1\n@\\label{gensig-5}@  | E1 -> E0 on h when k=n with s:=0;\n  itrans:\n  | -> E0 with s:=0;\n@\\label{gensig-1b}@}\n\n@\\label{gensig-2a}@input H : event = periodic (10,0,80)\ninput E : bool = value_changes (0:0, 25:1, 35:0)\n@\\label{gensig-2b}@output S : bool \n\n@\\label{gensig-6}@fsm g = gensig<4>(H,E,S)\n\\end{lstlisting}\n\nThe program can be divided in four parts.\n\n\\medskip The first part (lines \\ref{gensig-1a}--\\ref{gensig-1b}) gives a \\textbf{generic model} of\nthe generator behavior. The model, named \\verb|gensig|, has one parameter, \\verb|n|, two inputs,\n\\verb|h| and \\verb|e|, of type \\verb|event| and \\verb|bool| respectively, and one output \\verb|s| of\ntype \\verb|bool|. Its behavior is specified as a reactive FSM with two states, \\verb|E0| and\n\\verb|E1|, and one internal variable \\verb|k|. The transitions of this FSM are given after the\n\\verb|trans:| keyword in the form :\n\\begin{center}\n  \\framebox{\\lstinline[language=Rfsm]{| source_state -> destination_state on ev when guard with\n    actions}}\n\\end{center}\nwhere\n\\begin{itemize}\n\\item \\emph{ev} is the event trigerring the transition,\n\\item \\emph{guard} is a set of (boolean) conditions,\n\\item \\emph{actions} is a set of actions performed when the transition is enabled.\n\\end{itemize}\nThe semantics is that the transition is enabled\nwhenever the FSM is in the source state, the event \\emph{ev} occurs and all the conditions in the\nguard are true. The associated actions\nare then performed and the FSM moves to the destination state. For example, the first transition is\nenabled whenever an event occurs on input \\verb|h| and, at this instant, the value of input \\verb|e|\nis 1. The FSM then goes from state \\verb|E0| to state \\verb|E1| and sets its internal variable \n\\verb|k| and its output \\verb|s| to 1. The \\emph{initial transition} of the FSM is given \nafter the \\verb|itrans:| keyword in the form :\n\\begin{center}\n  \\framebox{\\lstinline[language=Rfsm]{| -> initial_state with actions}}\n\\end{center}\nHere the FSM is initially in state \\verb|E0| with output \\verb|s| set to 0.\n\nA graphical representation of the \\verb|gensig| model is given in\nFig.~\\ref{fig:rfsm-gensig-model} (this representation was actually automatically generated from the\nprogram in Listing~\\ref{lst:rfsm-gensig}, as explained in Chap.~\\ref{cha:rfsmc}). \n\n\\begin{figure}[!h]\n   \\includegraphics[height=8cm]{figs/gensig-model}\n   \\centering\n  \\caption{A graphical representation of FSM model defined in Listing~\\ref{lst:rfsm-gensig}}\n  \\label{fig:rfsm-gensig-model}\n\\end{figure}\n\nNote that, at this level, the value of the parameter \\verb|n|, used in the type of the internal\nvariable \\verb|k| (line~\\ref{gensig-3}) and in the transition conditions (lines \\ref{gensig-4} and\n\\ref{gensig-5}) is left unspecified, making the \\verb|gensig| model a \\emph{generic} one.\n\n\\medskip The second part of the program (lines \\ref{gensig-2a}--\\ref{gensig-2b}) lists \\textbf{global inputs and\n  outputs}\\footnote{In case of multi-FSM programs, this part will also contains the declaration of\n  \\emph{shared} events and variables. See Sec.~\\ref{sec:globals}.}.  For global outputs the\ndeclaration simply gives a name and a type.  For global inputs, the declaration also specifies the\n\\textbf{stimuli} which are attached to the corresponding input for simulating the system. The\nprogram of Listing~\\ref{lst:rfsm-gensig} uses two kinds of stimuli\\footnote{See\n  Sec.~\\ref{sec:globals} for a complete description of stimuli.}. The stimuli attached to input\n\\verb|H| are declared as \\emph{periodic}, with a period of 10 time units, a start time of 0 and a\nend time of 80. This means than an event will be produced on this input at time 0, 10, 20, 30, 40,\n50, 60, 70 and 80. The stimuli attached to input \\verb|E| say that this input will respectively take\nvalue 0, 1 and 0 at time 0, 25 and 35 (thus producing a ``pulse'' of duration 10 time units starting\nat time 25).\n\n\\medskip\nThe third and last part of the program (line~\\ref{gensig-6}) consists in building the global model of the system by\n\\emph{instanciating} the FSM model(s).\nInstanciating a model creates a ``copy'' of this model for which\n\\begin{itemize}\n\\item the generic parameters (\\verb|n| here) are now bound to actual values (4 here),\n\\item the inputs and outputs are connected to the global inputs or outputs. \n\\end{itemize}\n\n\\medskip\nA graphical representation of the system described in Listing~\\ref{lst:rfsm-gensig} is given in\nFig.~\\ref{fig:rfsm-gensig-top}\\footnote{Again, this representation was actually automatically generated from the\nprogram in Listing~\\ref{lst:rfsm-gensig}, as explained in Chap.~\\ref{cha:rfsmc}}. \n\n\\begin{figure}[!h]\n   \\includegraphics[height=8cm]{figs/gensig-top}\n   \\centering\n  \\caption{A graphical representation of system described in Listing~\\ref{lst:rfsm-gensig}}\n  \\label{fig:rfsm-gensig-top}\n\\end{figure}\n\n\\subsection*{Simulating}\n\\label{sec:simulating-1}\n\nSimulating the program means computing the reaction of the system to the input stimuli. Simulation\ncan be performed the RFSM command-line compiler or the IDE (see Chap.~\\ref{cha:rfsmc} and\n\\ref{cha:gui} resp.). It produces a set of\n\\emph{traces} in VCD (Value Change Dump) format which can visualized using \\emph{waveform viewers}\nsuch as \\texttt{gtkwave}. The simulation results for the program in Listing~\\ref{lst:rfsm-gensig}\nare illustrated in Fig.~\\ref{fig:rfsm-gensig-chrono}.\n\n\\begin{figure}[!h]\n   \\includegraphics[width=\\textwidth]{figs/gensig-chrono}\n   \\centering\n  \\caption{Simulation results for the program in Listing~\\ref{lst:rfsm-gensig}, viewed using\n    \\texttt{gtkwave}}\n  \\label{fig:rfsm-gensig-chrono}\n\\end{figure}\n\n\\subsection*{Code generation}\n\\label{sec:code-generation-1}\n\nRFSM can also generate code implementing the described systems simulation and/or\nintegration to existing applications.\n\n\\medskip\nCurrently, three backends are provided :\n\\begin{itemize}\n\\item a backend generating a C-based implementation of each FSM instance,\n\\item a backend generating a \\emph{testbench} implementation in SystemC (FSM instances + stimuli\n  generators),\n\\item a backend generating a \\emph{testbench} implementation in VHDL (FSM instances + stimuli\n  generators).\n\\end{itemize}\n\n\\medskip\nThe target language for the C backend is a C-like language augmented with\n\\begin{itemize}\n\\item a \\verb|task| keyword for naming generated behaviors,\n\\item \\verb|in|, \\verb|out| and \\verb|iinout| keywords for identifying inputs and outputs,\n\\item a builtin \\verb|event| type,\n\\item primitives for handling events : \\verb|wait_ev()|, \\verb|wait_evs()| and\n  \\verb|notify_ev()|. \n\\end{itemize}\nThe idea is that the generated code can be turned into an application for a multi-tasking operating\nsystem by providing actual implementations of the corresponding constructs and primitives.\n\n\\medskip\nFor the SystemC and VHDL backends, the generated code can actually be compiled and executed for\nsimulation purpose and. The FSM implementations generated by the VHDL backend can also be\nsynthetized to be implemented hardware using hardware-specific tools\\footnote{We use the\n  \\textsc{quartus} toolchain from Intel/Altera.}. \n\n\\medskip\nAppendices C1, C2 and C3 respectively give the C and SystemC code generated from the example in\nListing~\\ref{lst:rfsm-gensig}. \n\n\\clearpage\n\\section{The RFSM language}\n\\label{sec:rfsm-language}\n\nThis section is more thorough presentation of the RFSM language introduced in the previous\nsection. This presentation is deliberately informal. The complete language syntax can\nbe found in Appendix~A.\n\n\\subsection{Types}\n\\label{sec:types}\n\nThere are two categories of types~: builtin types and user defined types.\n\n\\medskip\n\\textbf{Builtin types} are : \\texttt{bool}, \\texttt{int}, \\texttt{float}, \\texttt{char}, \\texttt{event} and\n\\texttt{array}s.\n\n\\step Objects of type \\texttt{bool} can have only two values : \\texttt{0} (false) and \\texttt{1} (true).\n\n\\step Values of type \\texttt{char} are\ndenoted using single quotes. For example, for a variable \\verb|c| having type \\verb|char| :\n\\begin{center}\n  \\example{\\lstinline[language=Rfsm]|c := 'A'|}\n\\end{center}\nThey can be converted from/to they internal representation as integers using the \"\\verb|::|\" \\emph{cast}\noperator. For example, if \\verb|c| has type \\verb|char| and \\verb|n| type \\verb|int|, then \n\\begin{center}\n  \\example{\\lstinline[language=Rfsm]|n := 'A'::int; c:=(n+1)::char|}\n\\end{center}\nassigns value 65 to \\verb|n| (ASCII code) and, then, value \\verb|'B'| to \\verb|c|.\n\n\n\\step The type \\texttt{int} can be refined using a \\emph{size} or a \\emph{range annotation}. The\ntype \\verb|int<sz>|, where \\verb|sz| is an integer, is the type of integers which can be encoded using\n\\verb|n| bits. The type \\verb|int<min:max>|, where both \\verb|min| and \\verb|max| are integers, is\nthe type of integers whose value ranges from \\verb|min| to \\verb|max|. The size and range limits,\ncan be constants or expressions whose value can be computed as compile time\n(expressions involving parameter values, as exemplified line 9 in Listing~\\ref{lst:rfsm-gensig}).\n\n\\step Supported operations on values of type \\texttt{int} are described in Table~\\ref{tab:int-ops}.\nIf \\verb|n| is an integer and \\verb|hi| (resp. \\verb|lo|) an integer expression then \\verb|n[hi:lo]|\ndesignates the value represented by the bits \\verb|hi|...\\verb|lo| in the binary representation of\n\\verb|n|. Bit ranges can be both read (ex: \\verb|x=y[6:2]|) or written (ex: \\verb|x[8:4]:=0|). The\nsyntax \\verb|n[i||, where \\verb|n| is an integer is equivalent to \\verb|n[i:i]|. The \\emph{cast}\noperator (\\verb|::|) can be used to combine integers with different sizes (for example, if \\verb|n|\nhas type \\verb|int<16>| and \\verb|m| has type \\verb|int<8>|, writing \\verb|n:=n+m| is not allowed\nand mus be written, instead, \\verb|n:=n+m::int<16>|. Note that the\nlogical ``or'' operator is denoted ``\\verb+||+'' because the single ``\\verb+|+'' is already used in\nthe syntax.\n\n\\begin{table}\n\\begin{center}\n\\begin{tabular}{|l|l|} \\hline\n\\verb|+|, \\verb|-|, \\verb|*|, \\verb|/|, \\verb|%| (modulo) & arithmetic operations \\\\ \\hline \n\\verb|>>|, \\verb|<<| & (logical) shift right and left \\\\ \\hline \n\\verb|&|, \\verb+||+, \\verb|^| & bitwise and, or and xor \\\\ \\hline \n\\verb|[.:.]| & bit range extraction (ex: \\verb|n:=m[5:3]|) \\\\ \\hline \n\\verb|[.]| & single bit extraction (ex: \\verb|b:=m[4]|) \\\\ \\hline \n\\verb|::| & resize (ex: \\verb|n::8|) \\\\ \\hline \n\\end{tabular}\n\\caption{\\label{tab:int-ops}Builtin operations on integers}\n\\end{center}\n\\end{table}\n\n\\step The operations on values of type \\texttt{float} are : \"\\verb|+.|\", \"\\verb|-.|\", \"\\verb|*.|\" and\n\"\\verb|/.|\" (the dot suffix is required to distinguish them from the corresponding operations on\n\\texttt{int}s).\n\n\n\\step Arrays are 1D, fixed-size collections of \\verb|int|s, \\verb|bool|s or \\verb|float|s. Indices\nrange from 0 to \\verb|n-1| where \\verb|n| is the size of the array. For example,\n \\verb|int array[4]| is the type describing arrays of four integers. If \\verb|t| is an object\n  with an array type, its cell with index $i$ is denoted \\verb|t[i]|.\n\n\n\\medskip\n\\textbf{User defined types} are either \\emph{type abbreviations}, \\emph{enumerations} or\n\\emph{records}.\n\n\\step Type abbreviations are introduced with the following declaration\n\\begin{center}\n  \\framebox{\\lstinline[language=Rfsm]{type typename = type_expression}}\n\\end{center}\nEach occurrence of the defined type in the program is actually substituted by the corresponding type\nexpression.\n% Type expressions in type abbreviations are currently limited to builtin types.\n\n\\medskip\n\\step Enumerated types  are introduced with the following declaration\n\\begin{center}\n  \\framebox{\\lstinline[language=Rfsm]|type typename = enum \\{ C1, ..., Cn \\}|}\n\\end{center}\nwhere \\verb|C1|, \\ldots, \\verb|Cn| are the enumerated values, each being denoted by an identifier\nstarting with an uppercase letter. For example : \n\\begin{center}\n  \\example{\\lstinline[language=Rfsm]|type color = \\{ Red, Green, Orange \\}|}\n\\end{center}\n\n\\medskip\n\\step Record types are introduced with the following declaration\n\\begin{center}\n  \\framebox{\\lstinline[language=Rfsm]|type typename = record \\{ fid1: ty1, ..., fidn: tyn \\}|}\n\\end{center}\nwhere \\verb|fid1|, \\ldots, \\verb|fidn| and \\verb|ty1|, \\ldots, \\verb|tyn| are respectively the name\nand type of each record field For example : \n\\begin{center}\n  \\example{\\lstinline[language=Rfsm]|type coord = record \\{ x: int, y: int\\}|}\n\\end{center}\n\nIndividual fields of a value with a record type can be accessed using the classical ``dot''\nnotation. For example, with a variable \\verb|c| having type \\verb|record| as defined above :\n\\begin{center}\n  \\example{\\lstinline[language=Rfsm]|c.x := c.x+1|}\n\\end{center}\n\n\n\\subsection{FSM models}\n\\label{sec:fsm-models}\n\nAn FSM model, introduced by the \\verb|fsm model| keywords, describes the interface and behavior of a\n\\emph{reactive finite state machine}. A reactive finite state machine is a finite state machine\nwhose transitions can only be caused by the occurrence of \\emph{events}.\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]|fsm model <interface> { <body> }|}\n\\end{center}\n\n\\medskip\nThe \\textbf{interface} of the model gives its name, a list of parameters (which can be empty) and a\nlist of inputs and outputs. All parameters and IOs are typed. Inputs and outputs are explicitely\ntagged. An IO tagged \\verb|inout| acts both as input and output (it can be read and written by the\nmodel). Inputs and outputs are listed between \\verb|(...)|. Parameters, if present are given between\n\\verb|<...>|. Examples :\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|fsm model cntmod8 (in h: event, out s: int<0..7>) \\{ ... \\}|}\n\\end{center}\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|fsm model gensig<n:int> (in h: event, in  e: bit, out s: bit) \\{ ... \\}|}\n\\end{center}\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|fsm model update (in top: event, inout  lock: bool) \\{ ... \\}|}\n\\end{center}\n\n\\medskip\nThe model \\textbf{body}, written between \\verb|{...}|, generally comprises four sections :\n\\begin{itemize}\n\\item a section giving the list of \\emph{states},\n\\item a section introducing local (internal) \\emph{variables},\n\\item a section giving the list of \\emph{transition},\n\\item a section specifying the \\emph{initial transition}.\n\\end{itemize}\n\nEach section starts with the corresponding keyword (\\verb|states:|, \\verb|vars:|, \\verb|trans:| and\n\\verb|itrans:| resp.) and ends with a semi-colon.\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]| fsm model ... ( ... ) \\{ states: ...; vars: ...; trans: ...; itrans: ...; \\}|}\n\\end{center}\n\n\\subsubsection*{States}\n\\label{sec:states}\n\n\nThe \\verb|states:| section gives the set of internal states, as a comma-separated list of\nidentifiers (each starting with a uppercase letter). Example :\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|states: Idle, Wait1, Wait2, Done;|}\n\\end{center}\n\n\\subsubsection*{Variables}\n\\label{sec:variables}\n\nThe \\verb|vars:| section gives the set of internal variables, each with its type. Example :\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|vars: cnt: int, stop: bool;|}\n\\end{center}\n\nThe type of a variable may depend on parameters listed in the model interface. Example\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]|fsm gensig<n: int> (...) \\{ ... vars: k: int<0..n>; ... \\}|}\n\\end{center}\n\nThe \\verb|vars:| section may be omitted.\n\n\\subsubsection*{Transitions}\n\\label{sec:transitions}\n\nThe \\verb|trans:| section gives the set of transitions between states. Each transition is denoted\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{| src_state -> dst_state on ev when guards with actions}}\n\\end{center}\n\nwhere\n\\begin{itemize}\n\\item \\emph{src\\_state} and \\emph{dst\\_state} respectively designates the source state and destination state,\n\\item \\emph{ev} is event trigerring the transition,\n\\item \\emph{guards} is a set a enabling conditions,\n\\item \\emph{actions} is a set of actions performed when then transition is enabled.\n\\end{itemize}\n\n\\medskip The semantics is that the transition is enabled whenever the FSM is in the source state,\nthe triggering event occurs and all conditions evaluate to true. The associated actions are then\nperformed and the FSM moves to the destination state.\n\n\\medskip\nThe triggering event must be listed in the inputs.\n\n\\medskip\nEach condition listed in \\emph{guards} must evaluate to a boolean value. The guard is true if\n\\emph{all} conditions evaluate to true (conjonctive semantics).\nThe guards may involve inputs and/or internal variables.\n\n\\medskip\nThe guard can be empty. In this case, the transition is denoted\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{| src_state -> dst_state on ev with actions}}\n\\end{center}\n\n\\medskip The \\textbf{actions} associated to a transition consists in modifications of the outputs\nand/or internal variables or emissions of events. Modifications of outputs and internal variables\nare denoted\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{id := expr}}\n\\end{center}\n\nwhere \\emph{id} is the name of the output (resp. variable) and \\emph{expr} an expression involving\ninputs, outputs and variables and operations allowed on the corresponding types. The set of allowed\noperations is given in Table~\\ref{tab:type-ops}.\n\n\\begin{table}\n\\begin{minipage}[c]{1.0\\linewidth}\n\\small\n\\begin{center}\n\\begin{tabular}{|l|l|} \\hline\n{\\tt int}       & {\\tt + - * / mod = != > < >= <=} \\\\  \\hline\n{\\tt bool}      & {\\tt = !=} \\\\ \\hline \n{\\tt enumeration}     & {\\tt = !=} \\\\  \\hline\n\\end{tabular}\n\\caption{Operations on types}\n\\label{tab:type-ops}\n\\end{center}\n\\end{minipage}\n\\end{table}\n\n\\medskip\nThe action of emitting of an event  is simply denoted by the name of this event.\n\n\\medskip\nExamples :\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'S0 -> S1 on top '}\n\\end{center}\n\nIn the above example, the enclosing FSM switches from state \\verb|S0| to state \\verb|S1| when the\nevent \\verb|top| occurs. \n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'Idle -> Wait on Clic with ctr:=0, received'}\n\\end{center}\n\nIn the above example, the enclosing FSM switches from state \\verb|Idle| to state \\verb|Wait|, resetting the internal variable\n  \\verb|ctr| to 0 and emitting event \\verb|received| whenever an event occurs on its \\verb|Clic| input.\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'Wait -> Wait on Top when ctr<8 with ctr:=ctr+1'}\n\\end{center}\n\nIn the above example, the enclosing FSM stays in state \\verb|Wait| but increments the internal\nvariable \\verb|ctr| whenever an event \\verb|Top| occurs and that, \\emph{at this instant}, the\nvalue of variable \\verb|ctr| is smaller than 8. \n\n\\medskip\nExpressions may also involve the C-like ternary conditional operator \\verb|?:|.\nFor example, in the example below, the enclosing FSM stays in state \\verb|S0| but updates the variable \\verb|k|\nat each occurrence of event \\verb|H| so that is incremented if its current value is less than 8 or\nreset to 0 otherwise.\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'S0 -> S0 on H with k:=k<8?k+1:0'}\n\\end{center}\n\n\\medskip\nThe set of actions may be empty. In this case, the transition is denoted :\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{src_state -> dst_state on ev when guard}}\n\\end{center}\n\n\\subsubsection*{Initial transition}\n\\label{sec:initial-transition}\n\nThe \\verb|itrans:| section specifies the initial transition of the FSM. This transition is denoted~:\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{| -> init_state with actions}}\n\\end{center}\n\nwhere \\emph{init\\_state} is the initial state and \\emph{actions} a list of actions to be performed\nwhen initializing the FSM. The latter can be empty. in this case the initial transition is simply\ndenoted~:\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]{| -> init_state}}\n\\end{center}\n\n\\subsection{Globals}\n\\label{sec:globals}\n\nGlobals are used to connect model instances to the external world or to other instances.\n\n\\subsubsection*{Inputs and outputs}\n\\label{sec:inputs-outputs}\n\nInterface to the external world are represented by \\verb|input| and \\verb|output| objects.\n\n\\step For outputs the declaration simply gives a name and a type~:\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'output name : typ'}\n\\end{center}\n\n\\step For inputs, the declaration also specifies the \\textbf{stimuli} which are attached to the\ncorresponding input for simulating the system.\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'input name : typ = stimuli'}\n\\end{center}\n\nThere are three types of stimuli~:\nperiodic and\nsporadic stimuli for inputs of type \\verb|event| and value changes for scalar inputs.\n\n\\medskip\nPeriodic stimuli are specified with a period, a starting time and an ending time.\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'periodic(period,t0,t1)'}\n\\end{center}\n\nSporadic stimuli\nare simply a list of dates at which the corresponding input event occurs.\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'sporadic(t1,...,tn)'}\n\\end{center}\n\nValue changes are given as\nlist of pairs \\verb|t:v|, where \\verb|t| is a date and \\verb|v| the value assigned to the\ncorresponding input at this date. \n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'value_changes(t1:v1,...,tn:vn)'}\n\\end{center}\n\n\\medskip\nExamples:\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'input Clk: event = periodic(10,10,120)'}\n\\end{center}\n\nThe previous declaration declares \\verb|Clk| as a global input producing periodic events with period 10, starting\n  at t=10 and ending at t=100\\footnote{Note that, at this level, there's no need for an absolute\n    unit for time.}.\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'input Clic: event = sporadic(25,75,95)'}\n\\end{center}\n\nThe previous declaration declares \\verb|Clic| as a global input producing events at t=25, t=75 and\n  t=95.\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'input E : bool = value_changes (0:false, 25:true, 35:false)'}\n\\end{center}\n\nThe previous declaration declares \\verb|E| as a global boolean input taking value \\texttt{false} at\nt=0, \\texttt{true} at t=25 and \\texttt{false} again at t=35.\n\n\\subsubsection*{Shared objects}\n\\label{sec:shared}\n\nShared objects are used to represent interconnexions between FSM instances. This situation only\noccurs when the system model involves several FSM instances and when the input of a given instance\nis provided by the output of another one (see Section~\\ref{sec:fsm-instances}).\n\n\\step For shared objects the declaration simply gives a name and a type~:\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'shared name : typ'}\n\\end{center}\n\n\\subsection{Instances and system}\n\\label{sec:fsm-instances}\n\nThe description of the system is carried out by instanciating\n-- and, possibly, inter-connecting -- previously defined FSM models.\n\n\\medskip\nInstanciating a model creates a ``copy'' of the corresponding FSM for which\n\\begin{itemize}\n\\item the parameters of the model are bound to their actual value,\n\\item the declared inputs and outputs are connected to global inputs, outputs or shared\n  objects.\n\\end{itemize}\n\n\\medskip\nThe syntax for declaring a model instance is as follows~:\n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]'fsm inst_name = model_name<param_values>(actual_ios)'} \n\\end{center}\n\nwhere\n\\begin{itemize}\n\\item \\emph{inst\\_name} is the name of the created instance,\n\\item \\emph{model\\_name} is the name of the instanciated model,\n\\item \\emph{param\\_values} is a comma-separated list of values to be assigned to the formal\n  (generic) parameters,\n\\item \\emph{actual\\_ios} is a comma-separated list of global inputs, outputs or shared objects to be\n  connected to the instanciated model.\n\\end{itemize}\n\nBinding of parameter values and IOs is done by position. Of course the number and respective types\nof the formal and actual parameters (resp. IOs) must match.\n\n\\medskip\nFor example, the last line of the program given in Listing~\\ref{lst:rfsm-gensig}\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'fsm g = gensig<4>(H,E,S)'}\n\\end{center}\n\ncreates an instance of model \\verb|gensig| for which \\verb|n=4| and whose inputs (resp. output) are\nconnected to the global inputs (resp. output) \\texttt{H} and \\texttt{E} (resp. \\texttt{S}).\n\n\\subsubsection*{Multi-FSM models}\n\\label{sec:multi-fsm-models}\n\nIt is of course possible to build a system model as a \\emph{composition} of FSM instances.  An\nexample is given in Listing~\\ref{lst:rfsm-cntmod8}. The system is a simple modulo 8 counter, here\ndescribed as a combination of three event-synchronized modulo 2 counters\\footnote{This program is\n  provided in the distribution, under directory \\texttt{examples/multi/ctrmod8}.}.\n\n\\medskip\nHere a single FSM model (\\texttt{cntmod2}) is instanciated thrice, as \\texttt{C0}, \\texttt{C1} and\n\\texttt{C2}. These instances are synchronized using two \\textbf{shared events}, \\texttt{R0} and \\texttt{R1}. \n\n\\medskip\nThe graphical representation of the program is given in Fig.~\\ref{fig:rfsm-cntmod8-top}. Simulation\nresults are illustrated in Fig~\\ref{fig:rfsm-cntmod8-vcd}. \n\n\\begin{lstlisting}[language=Rfsm,frame=single,numbers=left,caption=A multi-model RFSM\n  program,label={lst:rfsm-cntmod8},float]\nfsm model cntmod2(\n  in h: event,\n  out s: int<0:1>,\n  out r: event)\n{\n  states: E0, E1;\n  trans:\n  | E0 -> E1 on h with s:=1\n  | E1 -> E0 on h with r, s:=0;\n  itrans:\n  | -> E0 with s:=0;\n}\n\ninput H: event = periodic(10,10,100)\noutput S0, S1, S2: int<0:1>\noutput R2: event\n\nshared R0, R1: event\n\nfsm C0 = cntmod2(H,S0,R0) \nfsm C1 = cntmod2(R0,S1,R1) \nfsm C2 = cntmod2(R1,S2,R2) \n\\end{lstlisting}\n\n\\begin{figure}[!h]\n   \\includegraphics[height=9cm]{figs/ctrmod8-top}\n   \\centering\n  \\caption{A graphical representation of program described in Listing~\\ref{lst:rfsm-cntmod8}}\n  \\label{fig:rfsm-cntmod8-top}\n\\end{figure}\n\n\\clearpage\n\\begin{figure}[!h]\n   \\includegraphics[width=\\textwidth]{figs/ctrmod8-chrono}\n   \\centering\n  \\caption{Simulation results for the program in Listing~\\ref{lst:rfsm-cntmod8}}\n  \\label{fig:rfsm-cntmod8-vcd}\n\\end{figure}\n\n\\subsection{Functions}\n\\label{sec:functions}\n\nConditions and actions associated to FSM transitions can use globally defined functions. An example\nis given in listing~\\ref{lst:rfsm-heron}\\footnote{This example can be found in directory\n  \\texttt{examples/heron/v2} in the distribution.}. The FSM described here computes an approximation\nof its input \\verb|u| using Heron's classical algorithm. Successive approximations are computed in\nstate \\verb|Iter| and the end of computation is detected when the square of the current\napproximation \\verb|x| differs from the argument (\\verb|a|) from less than a given threshold\n\\verb|eps|. For this, the model uses the global function \\verb|f_abs| defined at the beginning of\nthe program. This function computes the absolute value of its argument and is used twice in the\ndefinition of the FSM model \\verb|heron|, for defining the condition associated to the two\ntransitions going out of state \\verb|Iter|.\n\n\\begin{lstlisting}[language=Rfsm,frame=single,numbers=left,caption=An RFSM program using a global\n  function definition,label={lst:rfsm-heron},float]\nfunction f_abs(x: float) : float { return x < 0.0 ? -.x : x }\n\nfsm model Heron<eps: float>(\n  in h: event,\n  in start: bool,\n  in u: float,\n  out rdy: bool,\n  out niter: int,\n  out r: float)\n{\n  states: Idle, Iter;\n  vars: a: float, x: float, n: int;\n  trans:\n  | Idle -> Iter on h when start=1 with a:=u, x:=u, rdy:=0, n:=0\n  | Iter -> Iter on h when f_abs(x*.x-.a)>=eps with x:=(x+.a/.x)/.2.,\n                                                    n:=n+1\n  | Iter -> Idle on h when f_abs(x*.x-.a)<eps with r:=x, niter:=n, rdy:=1;\n  itrans:\n  | -> Idle with rdy:=1;\n}\n\ninput H : event = periodic (10,10,200)\ninput U : float = value_changes (5:2.0)\ninput Start : bool = value_changes (0:0, 25:1, 35:0)\noutput Rdy : bool\noutput R : float\noutput niter : int\n\nfsm heron = Heron<0.00000001> (H,Start,U,Rdy,niter,R)\n\\end{lstlisting}\n\n\\medskip\n\\step The general form for a function definition is \n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]| function name (<arg\\_1>:<type\\_1>, ..., <arg\\_n>:<type\\_n>)\\ :\\ <type\\_r> \\{ return <expr> \\}|}\n\\end{center}\n\n\\noindent\nwhere\n\\begin{itemize}\n\\item \\lstinline[language=Rfsm]|<arg_i>| (resp. \\lstinline[language=Rfsm]|<type_i>|) is the name\n  (resp. type) of the i$^{th}$ argument,\n\\item \\lstinline[language=Rfsm]|<type_r>| is the type of value returned by the function,\n\\item \\lstinline[language=Rfsm]|<expr>| is the expression defining the function value.\n\\end{itemize}\n\n\\medskip\n\\step Functions can only return one result and cannot use local variables. There are therefore more\nlike so-called \\emph{macros} in the C language than full-fledged functions and are typically used to\nimprove readability of the programs.\n\n\\clearpage\n\\subsection{Constants}\n\\label{sec:constants}\n\nGlobal constants can be defined using the following syntax~:  \n\n\\begin{center}\n\\framebox{\\lstinline[language=Rfsm]|constant name : <type> = <value>|}\n\\end{center}\n\n\\noindent\nwhere\n\\begin{itemize}\n\\item \\lstinline[language=Rfsm]|<type>| is the type of the defined constant (currently limited to\n  \\verb|int|, \\verb|float| and arrays of \\verb|int|s or \\verb|float|s,\n\\item \\lstinline[language=Rfsm]|<value>| is the value of the constant (which must be an \\verb|int|\n  or \\verb|float| literal or an array of such literals).\n\\end{itemize}\n\nGlobal constants, just like global functions, have a global scope and hence can be used in any FSM\nmodel or instance.\n\n\\subsection{Semantic issues}\n\\label{sec:semantic-issues}\n\nThis presentation of the language has deliberately focused on syntax. Formalizing the semantics of programs made of\nreactive finite state machines -- and in particular when several of these machines are interacting\n-- is actually far from trivial and will not be carried out here. \n\nInstead, this section will describe some ``practical'' problems that may arise when simulating such\nsystems and how the language currently addresses them, without delving too much into the underlying\nsemantics issues\\footnote{This is not that these issues do not deserve a formal treatment. Of\n  course, they do ! But we think we this document is not the right place to do it.}.\n\n\\subsubsection{Priorities}\n\\label{sec:priorities}\n\nThe FSM models involved in programs should normally be \\emph{deterministic}. In other words, a\nsituation where several transitions are enabled at the same instant should normally never arise. But\nthis condition may actually be difficult to enforce, especially for models reacting to several input\nevents. Consider for example, the model described in Listing~\\ref{lst:rfsm-prio-pb}. This model\ndescribes a (simplified) stopwatch. It starts counting seconds (materialized by event \\verb|sec|)\nas soon as event \\verb|startstop| occurs and stops as soon as it occurs again.\n\n\\begin{lstlisting}[language=Rfsm,frame=single,numbers=left,caption=A program showing a potentially non-deterministic\n  model,label={lst:rfsm-prio-pb},float]\nfsm model chrono (\n     in sec: event,\n     in startstop: event,\n    out aff: int)\n  {\n  states: Stopped, Running;\n  vars: ctr: int;\n  trans:\n  | Stopped -> Running on startstop with ctr:=0; aff:=0\n  | Running -> Running on sec with ctr:=ctr+1; aff:=ctr\n  | Running -> Stopped on startstop;\n  itrans:\n  |-> Stopped;\n  }\n\ninput StartStop: event = sporadic(25,70)\ninput H:event = periodic(10,10,110)\noutput Aff: int\n\nfsm c = chrono(H,StartStop,Aff)\n\\end{lstlisting}\n\nThe problem is that if both events occur simultaneously  then\nboth the transitions at line 10 and 11 are enabled. In fact, here's the error message produced by\nthe compiler when trying to simulate the above program :\n\n\\small\n\\begin{verbatim}\nError when simulating FSM c: non deterministic transitions found at t=70:\n\t- Running--h|ctr:=ctr+1; aff:=ctr->Running[0]\n\t- Running--startstop->Stopped[0]\n\\end{verbatim}\n\\normalsize\n\nOf course, this could be avoided by modifying the stimuli attached to input \\verb|StartStop| so that the\ncorresponding events are never emitted at time $t=n\\times 10$. But this is, in a sence, cheating,\nsince this event is supposed to modelize user interaction which occur, by essence, at impredictible\ndates. \n\nThe above problem can be solved by assigning a \\emph{priority} to transitions. In the current\nimplementation, this is achieved by tagging some transitions as ``high priority''\ntransitions\\footnote{Future versions may evolve towards a more sophisticated mechanism allowing\n  numeric priorities.}.  When several transitions are enabled, if one is tagged as ``high priority''\nthan it is automatically selected\\footnote{If none (resp. several) is (resp. are) tagged, the\n  conflict remains, of course.}. \n\nSyntaxically, tagging a transition is simply achieved by replacing the leading ``\\verb+|+'' by a\n``\\verb|!|''.  In the\ncase of the example above, the modified program is given in\nListing~\\ref{lst:rfsm-prio-solved}. Tagging the last transition is here equivalent to give to the\n\\verb|startstop| precedence against the \\verb|h| event when the model is in state\n\\verb|Running|.\n\n\\begin{lstlisting}[language=Rfsm,frame=single,numbers=left,caption=A rewriting of the model defined\n  in Listing~\\ref{lst:rfsm-prio-pb}, label={lst:rfsm-prio-solved},float]\nfsm model chrono (...)\n  {\n  ...\n  trans:\n    ...\n    | Running -> Running on sec with ctr:=ctr+1; aff:=ctr\n    ! Running -> Stopped on startstop\n  itrans: -> Stopped;\n  }\n...\n\\end{lstlisting}\n\n\\subsubsection{Sequential vs. synchronous actions}\n\\label{sec:sequ-vs.-synchr}\n\nAn important question is whether, when a transition specifying \\emph{several actions} to be\nperformed is taken, the corresponding actions are performed sequentially or not. \n\nConsider for example, the following transition, in which \\verb|x| and \\verb|y| are internal\nvariables of the enclosing FSM :\n\n\\begin{center}\n\\example{\\lstinline[language=Rfsm]'S0 -> S1 on H with x:=x+1, y:=x*2'}\n\\end{center}\n\nSuppose that the value of variable \\verb|x| is 1 just before event \\verb|H| occurs. What will the value of\nvariables \\verb|x| and \\verb|y| after this transition ?\n\n\\step With a \\textbf{sequential interpretation}, actions are performed sequentially, one after the\nother, in the order they are specified. With this interpretation, order of execution matters. In the example above, it will\nassign the value 2 to \\verb|x| and 4 to \\verb|y|.\n\n\\step With a \\textbf{synchronous interpretation}, actions are performed in parallel, the value of each variable\noccuring in right-hand-side expressions being the one \\emph{before} the transition. With this\ninterpretation, order of executions does \\emph{not} matter. In the example above, it will\nassign the value 2 to \\verb|x| and 2 to \\verb|y|.\n\n\\medskip\nA sequential interpretation naturally fits a software execution model, in which FSM variables are\nimplemented as program variables and actions as immediate modifications of these variables, whereas\na synchronous interpretation reflects hardware execution models, in which FSM variables are\ntypically implemented as registers which are updated in parallel at each clock cycle.\n\n\\medskip\nBy default, the \\verb|rfsmc| compiler relies on a sequential interpretation, both for simulation and\ncode production\\footnote{For the C and SystemC backends, this means that FSM variables are\n  implemented as local variables of the function implementing the FSM model. For the VHDL backend,\n  these variables are implemented as \\texttt{variable}s withing the process implementing the\n  FSM.}. But, in certain cases, and in particular when specifying models to be synthetized on\nhardware, a synchronous interpretation is more natural and/or can lead to more efficient\nimplementations. Switching to a synchronous interpretation is possible by invoking the \\verb|rfsmc|\ncompiler with the \\verb|-synchronous_actions| option\\footnote{For the VHDL backend, in particular, the\n  \\texttt{-synchronous\\_actions} option forces the FSM variables to be implemented as\n  \\texttt{signal}s.}.  \n\n% \\medskip\n% \\textbf{Note}. As a syntactic reminder, list of actions are printed in diagrams using ``\\verb|;|'' as a separator when using\n% a sequential interpretation and using ``\\verb|,|'' when using a synchronous interpretation.\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"rfsm\"\n%%% End: \n", "meta": {"hexsha": "30dd59f4049788a52122ec6e6921d962414e3de4", "size": 37226, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/um/overview.tex", "max_stars_repo_name": "jserot/rfsm-gui", "max_stars_repo_head_hexsha": "4eee507ae6e06088fbc66fd2383d5533af49090b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/um/overview.tex", "max_issues_repo_name": "jserot/rfsm-gui", "max_issues_repo_head_hexsha": "4eee507ae6e06088fbc66fd2383d5533af49090b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/um/overview.tex", "max_forks_repo_name": "jserot/rfsm-gui", "max_forks_repo_head_hexsha": "4eee507ae6e06088fbc66fd2383d5533af49090b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.9526952695, "max_line_length": 132, "alphanum_fraction": 0.7435394617, "num_tokens": 10638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.41004541495807073}}
{"text": "\\subsection{Cross Sections}\nSome of the primary quantities we are interested in predicting and measuring in proton-proton collisions are \\emph{cross sections}, which can be thought of as a measure of the probability\\footnote{More precisely, a cross section is measured in units of distance squared. However, the characteristic cross section of a process is synonymous with its probability of occuring and it is more intuitive to describe cross sections in these terms.} of a specific process occurring.\nThe QCD factorization theorem~\\cite{Collins:1989gx} allows the cross section for an arbitrary deep inelastic proton-proton collision to be written in terms of two components: a perturbatively calculable hard term and a non-perturbative PDF.\nThus, the cross section for $pp \\to X + Y$ can be calculated in the following way:\n\\begin{equation} \n    \\sigma(pp \\to X + Y) = \\sum_{i,j} \\int dx_i dx_j f(x_i, Q^2) f(x_j, Q^2) \\sigma(q_i q_j \\to Y),\n\\end{equation}\nin which $X$ may be any hadronic final state, and $Y$ is an arbitrary final state for the inelastic scattering of two partons $q_i$ and $q_j$.\nThe sum is calculated over all partons and integrated over all possible momentum fractions for the PDFs of each parton.\nThe hard term, $\\sigma(q_i q_j \\to Y)$, can be calculated perturbatively in QCD.\nIn practice, these calculations are done through the use of Monte Carlo generators, described in greater detail in Sec.~\\ref{sec:pp_mc}.\nCross sections for typical processes of interest at pp collision experiments are shown as a function of the center-of-mass energy in Fig.~\\ref{fig:pp_xs}.\n\\begin{figure}[htbp!]\n    \\centering\n    \\includegraphics[width=0.6\\linewidth]{figures/physics_of_pp/pp_cross_sections.png}\n    \\caption{Cross sections for typical processes of interest in pp collision experiments, shown as a function of the center-of-mass energy, $\\sqrt{s}$. Taken from~\\cite{Campbell:2006wx}.}\n    \\label{fig:pp_xs}\n\\end{figure}\n\n\\subsection{Parton Showers, Hadronization, and Jets} \\label{sec:pp_physics_jets}\nHigh energy processes involving the strong interaction are very well-described by perturbative QCD calculations.\nHowever, at lower energies (less than or equal to about 1 GeV), the perturbative appraoch fails to provide an accurate description of the SM phenomena: the strong coupling $\\alpha_s$ of QCD becomes close to unity, as shown in Fig.~\\ref{fig:pp_qcd_coupling}.\n\\begin{figure} [htbp!]\n    \\centering\n    \\includegraphics[width=0.6\\linewidth]{figures/physics_of_pp/pp_qcd_coupling.png}\n    \\caption{The strong coupling constant $\\alpha_s$ of QCD as a function of $Q^2$. Different colored lines correspond to various renormalization schemes. Taken from~\\cite{Deur:2016tte}.}\n    \\label{fig:pp_qcd_coupling}\n\\end{figure}\nWhen the coupling $\\alpha_s$ nears unity, the perturbative approach fails for the following reason: perturbative expansions are made in powers of the coupling, so the coupling must be significantly less than one in order for a finite expansion to provide a good approximation.\nIn describing phenomena like parton showers and hadronization, energy scales of $\\mathcal O(1)$ GeV are relevant, and a strictly perturbative calculation will not provide a satisfactory description.\n\nA \\emph{parton shower} refers to the process by which a high energy parton stemming from the hard interaction produce showers of ``soft'' particles at lower energies.\nTypically, this is either gluon splitting, in which a gluon converts into a quark-antiquark pair, or gluon radiation, in which a quark radiates a gluon.\nIn practice, parton showers are modeled with Monte Carlo generators which utilize Sudakov form factors~\\cite{Sudakov:1954sw} and splitting functions to simplify calculations~\\cite{Hoche:2014rga}.\n\nAs discussed in Sec.~\\ref{sec:theory_qcd}, quarks and gluons are confined to bound states which must be colorless.\nMoreover, the potential energy of a hadron increases as a function of the distance between the partons.\nAt a large enough distance, it becomes energetically favorable to break the original bound state in which they existed and instead form new hadrons.\nThis process is called \\emph{hadronization}.\nIn high energy collisions, quarks and gluons are often ejected from the hard interaction with high enough momentum for hadronization to occur. \nFrequently, the newly formed hadron will initiate a cascade of decays and gluon radiation, forming a cone of hadronic activity.\nThis cone of particles stemming from the hadronization of a quark or gluon is called a \\emph{hadronic jet}.\nHadronization cannot be adequately described through perturbative calculations alone, and instead phenomenological models like the Lund-String Model~\\cite{Andersson:1983ia} are employed.\n\n\\subsection{Underlying Event and Pileup}\nIn a given bunch crossing, there is typically only one hard scattering interaction of interest from a physics point of view.\nIn addition to this hard interaction, there are additional lower energy ``soft'' scattering interactions.\nThe soft scattering may be due either to interactions between partons other than those involved in the hard scattering interaction or interactions between protons other than those involved in the hard scattering interaction.\nThe former is called the \\emph{underlying event}, while the latter interactions are called \\emph{pileup} interactions.\nThe modeling of underlying event and pileup is often performed through heuristic approaches which extrapolate directly from experimental collision data.\n\nThough soft scattering interactions from underlying event and pileup are typically not of interest, it is still imperative to understand and adequately model them in order to study physics processes of interest.\nA large portion of the hadronic activity in an event at the LHC stems from these soft interactions and will effect, for example, the jet multiplicity and missing transverse momentum calculation in that event.\nPhysics analyses often use the jet multiplicity and missing transverse momentum to identify regions of high signal purity (for example, an analysis searching for supersymmetric particles will typically select for events with high missing transverse momentum) -- for these reasons, it is vital to understand the contribution of underlying event and pileup to these distributions in order to properly model the targeted signal process and accurately estimate the relevant SM background processes.\n\nParton showers, hadronization, and underlying event are visually depicted for a hadron-hadron collision in Fig.~\\ref{fig:pp_event_schematic}.\n\n\\begin{figure} [htbp!]\n    \\centering\n    \\includegraphics[width=0.7\\linewidth]{figures/physics_of_pp/pp_event_schematic.png}\n    \\caption[Schematic of a hadron-hadron collision. Taken from~\\cite{Hoche:2014rga}.]{Schematic of a hadron-hadron collision. The red blob indicates the hard scattering interaction and the subsequent tree-like structure depicts parton showers, while the purple blob indicates an underlying event scattering interaction. Light green blobs depict hadronization, dark green blobs depict subsequent decays of those hadrons, and yellow lines depict soft Bremsstrahlung radiation. Taken from~\\cite{Hoche:2014rga}.}\n    \\label{fig:pp_event_schematic}\n\\end{figure}\n", "meta": {"hexsha": "a0b0d9b727fab01a3781fa65e816f2b85155038e", "size": 7242, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "physics_of_pp/pp_collisions.tex", "max_stars_repo_name": "sam-may/phd_thesis", "max_stars_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "physics_of_pp/pp_collisions.tex", "max_issues_repo_name": "sam-may/phd_thesis", "max_issues_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "physics_of_pp/pp_collisions.tex", "max_forks_repo_name": "sam-may/phd_thesis", "max_forks_repo_head_hexsha": "acd61f340e5677deba412b1b3baecd124c32440f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 113.15625, "max_line_length": 509, "alphanum_fraction": 0.8055785695, "num_tokens": 1657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.41004252428185856}}
{"text": "\\clearpage\n\\chapter{BASIC TYPESETTING}\n\\doublespacing\n\n\n$$\\kappa^(23)$$\n\nAlbert Einstein's theory of relativity stated that $E=mc^2$ \\cite{Einstein:1944a} \n\n\nIn these paragraphs, we will display examples for many common features in \\LaTeX. The code is shown in \\texttt{main.tex} and the associated output in \\texttt{main.pdf}. We assume you already know the basic syntactical structure of \\TeX with its commands and environments. If you are not familiar, it is recommended you read \\texttt{intro to latex.pdf} provided in this package. We will start with the most basic examples of different fonts and styles.\n\n\\section*{Fonts and Styles}\n\n\\textbf{Bold} font is made using the \\texttt{\\textbackslash textbf} command. \\textit{Italic} font is made using the \\texttt{\\textbackslash textit} command. \\underline{Underline} font is made using the \\texttt{\\textbackslash underline} command. \\texttt{Monospace/teletype} font is made using the \\texttt{\\textbackslash texttt} command. \\textsf{Sans-serif} font is made using the \\texttt{\\textbackslash textsf} command.\n\n\\section*{Math}\n\nOne of \\LaTeX's greatest strengths is its mathemetical typesetting. You can enter inline math $\\mathrm{e}^{\\mathrm{i}\\pi}$. You can also have a math block.\n\n$$\nf(x) = \\int _{-\\infty} ^\\infty g(x) \\, \\mathrm{d}x\n$$\n\n\n\nYou can have $f(x) = \\int _{-\\infty} ^\\infty g(x) \\, \\mathrm{d}x$ numbered equations with the \\texttt{equation} environment.\n\n\\begin{equation}\n\t\\Phi(n) = \\gamma^n + \\Delta \\gamma \\cdot \\vec{\\zeta} \\label{eqn:exampleEqn}\n\\end{equation}\n\nYou can also align equations by using a \\texttt{\\&} in the \\texttt{align*} environment. Omitting the \\texttt{*} will number each line.\n\n\\begin{align*}\n\th_1 &= \\mathbf{X}_1 + N \\\\\n\th_2 &= \\mathbf{X}_1 + N \\\\\n\t&\\vdots \\\\\n\th_n &= \\mathbf{X}_n + N \\\\\n\\end{align*}\n\nMake sure you use the proper notation for your field. A common mistake is to italicize units in math mode. Units are supposed to be typset in a roman font because $\\mu m$ in italic means you are multiplying two variables and $\\mathrm{\\upmu m}$ means your value is in micrometers. A similar mistake is often made for special functions. If you are using a multi-letter function such as $\\sin()$ or $\\mathrm{floor}()$, it should not be italic for the same reason as before. To fix these issues, you can use the \\texttt{\\textbackslash mathrm} command when in math mode to set your text as roman (or upright). Greek letters need to be specified as upright by prepending `up' to the command, e.g., \\texttt{\\$\\textbackslash upmu\\$}.\n\n\\section*{Quotation marks}\nQuotes are written in latex using \\texttt{\\`} for opening and \\texttt{\\'} for closing. They can be used for `single' and ``double'' quotes alike.\n\n\\section*{Lists}\nBulleted lists are made with the \\texttt{itemize} environment. Numbered lists are made with hte \\texttt{enumerate} environment. They can be made hierrarchal by embedding another lists within. A bulleted list:\n\\begin{itemize}\n\t\\item First level\n\t\\begin{itemize}\n\t\t\\item second level\n\t\\end{itemize}\n\\end{itemize}\nA numbered list:\n\\begin{enumerate}\n\t\\item First level\n\t\\begin{enumerate}\n\t\t\\item second level\n\t\\end{enumerate}\n\\end{enumerate}\n\n\\section*{Code Listing}\nYou can make a code block using the \\texttt{verbatim} environment. Be mindful that unlike most \\TeX environments, it is senstive to spaces (but not tabs) at the beginning of lines so that you may indent your code.\n\\begin{verbatim}\nclass Fill:\n  def __init__(self, color=BLACK, style='solid'):\n    self.color = color\n    self.style = style\n\\end{verbatim}\n\n\\section*{Figures}\nFigures can be included using the \\texttt{\\textbackslash includegraphics} command, and their placement and captioning can be configured using the \\texttt{figure} environment. Generally, \\LaTeX can determine the best placement of your figure on the page itself, but you can give it a placement option of \\texttt{h}, \\texttt{t}, \\texttt{b}, or \\texttt{p} to place it \\underline{h}ere, on \\underline{t}op, on \\underline{b}ottom, or on its own \\underline{p}age. Note that in \\texttt{main.tex}, we have already set the graphics path with the \\texttt{\\textbackslash graphicspath\\{ \\{Figures/ \\} \\}} command, which means it is always going to look in that folder for your figures.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=4 in]{elbee.jpg}\n\t\\caption{This is our new mascot!}\n\t\\label{fig:exampleFig}\n\\end{figure}\n\n$$20 (epsilon / 2) = \\sqrt{5}$$\n\n\\section*{Tables}\nTables can be generated using the \\texttt{tabular} environment, and their placement and captioning is configured with the \\texttt{table} environment, like with figures. In the \\texttt{tabular} environment, you provide a section parameter that configures your number ofcolumns, their text alignment, and vertical borders.\n\n\\begin{table}[ht]\n\t\\centering\n\t\\caption{An example of a table}\n\t\\begin{tabular}{l c c c}\n\t\t\\hline\n\t\tColor\t&  Radius, $r$ [mm] & RMS Voltage, $v$ [V]  & Height \\\\\n\t\t\\hline\n\t\tCyan\t&\t72.2\t&\t2.1 \\\\\n\t\tMagenta\t&\t45.2\t&\t5.5 \\\\\n\t\tYellow\t&\t78.5\t&\t1.3 \\\\\n\t\tBlack\t&\t33.3\t&\t6.9 \\\\\n\t\tBlue    &   20.9    &   2.1 \\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\label{tab:exampleTable}\n\\end{table}\n\n\\section*{Citations and Cross-references}\nYou can add citations \\cite{customBibLabel} from \\cite{Q} your \\texttt{references.bib} file \\cite{Burka:1993a} using the \\texttt{\\textbackslash cite} command \\cite{customBibLabel2}. You can also cross-reference equations, figures, and tables and many other items by giving them a custom label with the \\texttt{\\textbackslash label} command, and using the  \\texttt{\\textbackslash ref} command to call them. Citations and references like this are very nice because you don't have to worry about item numbering and how it may change as you develop your document; you tell \\LaTeX where you want it, and it will handle the numbering so it makes sense. And in PDF viewers, the cross-references are clickable intra-document links that will take you to the associated item. Figure \\ref{fig:exampleFig}. Table \\ref{tab:exampleTable}. Equation \\ref{eqn:exampleEqn}.\n\n\\section*{Footnotes}\nFootnotes can be placed with the \\texttt{\\textbackslash footnote} command\\footnote{This is a footnote but it's a very long footnote so that we can test the indent of the footnote text when it leads onto a second line at the bottom of the page.}. \n", "meta": {"hexsha": "e3e8371318e5abcb6387e98a28dc34dedb67aef1", "size": 6270, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis template/Chapters/chapter1.tex", "max_stars_repo_name": "csulb-datascience/CSULB-thesis-template", "max_stars_repo_head_hexsha": "7a0c2c9da0b6bcbe69c72693db8818f052a12235", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis template/Chapters/chapter1.tex", "max_issues_repo_name": "csulb-datascience/CSULB-thesis-template", "max_issues_repo_head_hexsha": "7a0c2c9da0b6bcbe69c72693db8818f052a12235", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis template/Chapters/chapter1.tex", "max_forks_repo_name": "csulb-datascience/CSULB-thesis-template", "max_forks_repo_head_hexsha": "7a0c2c9da0b6bcbe69c72693db8818f052a12235", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.5229357798, "max_line_length": 855, "alphanum_fraction": 0.7429027113, "num_tokens": 1807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.4100425214259156}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% CS638: Applied Machine Learning\n% Copyright 2016 Pejman Ghorbanzade <pejman@ghorbanzade.com>\n% Creative Commons Attribution-ShareAlike 4.0 International License\n% More info: https://github.com/ghorbanzade/beacon\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\def \\topDirectory {.}\n\\def \\srcDirectory {\\topDirectory/src}\n\\def \\texDirectory {\\srcDirectory/tex}\n\\def \\imgDirectory {\\topDirectory/../build/umb-cs638-2016s/img}\n\n\\documentclass[12pt,letterpaper,twoside]{article}\n\n\\usepackage{\\texDirectory/directives}\n\\input{\\texDirectory/config}\n\\usepackage{\\texDirectory/report}\n\n\\begin{document}\n\n\\doc{title}{Solution to Assignment 2}\n\\doc{date-pub}{Feb 11, 2016 at 4:00 PM}\n\\doc{date-due}{Feb 18, 2016 at 4:00 PM}\n\n\\makeHeader\n\n\\section*{Question}\n\nProfit of stores of a coffeehouse chain has been recorded and provided in \\texttt{data.txt} file, along with population of the city they are in.\n\nThe coffeehouse is planning an expansion and is deciding which city to expand to.\n\nObjective is to use the dataset to predict profit of the new store given population of the city in which it will operate.\n\n\\subsection*{Solution}\n\nTo understand the data, profit of the stores based on population of the city they operate in is visualized in Figure \\ref{fig1}.\n\n\\begin{figure}[H]\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-01.png}\n\\caption{Profit of Coffee Shop based on Population of the City}\\label{fig1}\n\\end{figure}\n\nCorrelation of the dataset is calculated at 0.837 which ensures there is a correlation between the profit (dependant variable) and the city population (independant variable).\n\nAs there is only one single feature in our dataset, the hypothesis function for linear regression will be of the form shown in Eq. \\ref{eq1}.\n\n\\begin{equation}\\label{eq1}\nh(x) = \\theta_0 + \\theta_1 x\n\\end{equation}\n\nApplying linear regression on the dataset, coefficients $\\theta_0$ and $\\theta_1$ of the hypothesis function will be obtained.\n\n\\begin{equation}\\label{eq2}\n\\begin{split}\n\\theta_0 = -3.89578\\\\\n\\theta_1 = 1.19303\n\\end{split}\n\\end{equation}\n\n\\begin{terminal}\nlm.out <- lm(data$profit ~ data$population)\ntheta <- coef(lm.out)\n\\end{terminal}\n\nThus, the best fitted regression line will be as depicted in Fig. \\ref{fig2}.\n\n\\begin{figure}[H]\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-03.png}\n\\caption{Best-Fitted Regression Line for the Dataset}\\label{fig2}\n\\end{figure}\n\nUsing previously obtained $\\theta_0$ and $\\theta_1$, the cost function can be obtained as shown in Eq. \\ref{eq3}.\n\n\\begin{equation}\\label{eq3}\n\\begin{split}\nJ(\\theta_0, \\theta_1) & = \\frac{1}{2m}\\sum\\limits_{i=1}^m \\left(h_{\\theta}(x^{(i)})-y^{(i)}\\right)^{2} \\\\\n & = \\frac{1}{2 \\times 97}\\sum\\limits_{i=1}^{97} \\left({-3.90} + {1.19}x^{(i)} - y^{(i)}\\right)\\\\\n & = 4.476971\n\\end{split}\n\\end{equation}\n\n\\begin{terminal}\ncost <- sum((x%*%theta)-y)^2)/(2*m)\n\\end{terminal}\n\n\\subsubsection*{Cost Function Minimization using Gradient Descent}\n\nTo measure the impact of the learning rate, the cost function is minimized using gradient descent as shown in Eq. \\ref{eq4}.\n\n\\begin{equation}\\label{eq4}\n\\theta_j := \\theta_j - \\alpha \\frac{\\partial}{\\partial\\theta_j}J(\\theta_0, \\theta_1)\n\\end{equation}\n\nTaking $\\alpha = 0.02$ and the number of iterations $i = 500$, final values for $\\theta_0$ and $\\theta_1$ are obtained as $\\theta_0 = 3.261$ and $\\theta_1 = 1.130$.\nMeanwhile, using the same number of iterations, choosing $\\alpha = 0.005$ will result in $\\theta_0 = -1.367$ and $\\theta_1 = 0.939$ which is much closer to the values obtained using linear regression tool in Eq. \\ref{eq2}.\n\n\\begin{terminal}\ngradient_descent <- function(x, y, alpha) {\n\tx <- cbind(1, x)\n\titerations <- 500\n\ttheta <- c(0, 0)\n\tfor (i in 1:iterations)\n\t{\n\t\ttheta[1] <- theta[1] - alpha * (1/m) * sum(((x%*%theta)- y))\n\t\ttheta[2] <- theta[2] - alpha * (1/m) * sum(((x%*%theta)- y)*x[,2])\n\t}\n\treturn(theta)\n}\ntheta <- gradient_descent(data$population, data$profit, 0.02)\ntheta <- gradient_descent(data$population, data$profit, 0.005)\n\\end{terminal}\n\nTo better illustrate the impact of the learning rate, Fig. \\ref{fig3} is presented in which $\\theta_i$ values obtained by applying gradient descent model with 500 iterations are plotted for different values of $\\alpha$.\n\n\\begin{figure}\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-05.png}\n\\caption{$\\theta_0$ and $\\theta_1$ values obtained from gradient descent algorithm for different learning rates and fixed number of iterations}\\label{fig3}\n\\end{figure}\n\nWe can also investigate changes in normalized error of coefficient values obtained by gradient descent algorithm for different learning rates, as shown in Fig. \\ref{fig4}.\n\n\\begin{figure}\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-06.png}\n\\caption{Normalized error of gradient descent algorithm for different learning rates with fixed number of iterations}\\label{fig4}\n\\end{figure}\n\nAs is clearly deducted from Fig. \\ref{fig4}, if the learning rate $\\alpha$ is too small, more iterations will be needed to achieve the same level of accuracy.\nTo visualize this point, Fig. \\ref{fig5} is provided where number if iterations to achieve errors of less than 1\\% (compared to values obtained in Eq. \\ref{eq2}) is plotted for different learning rates $\\alpha$.\n\n\\begin{figure}\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-07.png}\n\\caption{Number of required iterations for different learning rates to achieve the same level of accuracy}\\label{fig5}\n\\end{figure}\n\n\\newpage\n\n\\subsubsection*{Linear Regression Model to Predict Profit based on Population}\n\nGiven the linear regression line shown in Fig. \\ref{fig2} and values given in Eq. \\ref{eq2}, it is easy to predict profit of a future store, given the population of the city in which it is going to operate.\nAs an instance, given that Boston has a population of 645966, profit of the store can be projected as follows.\n\n\\begin{equation}\\label{eq5}\n\\begin{split}\n\\mathit{profit}_\\mathit{Boston} & = \\theta_0 + \\theta_1 \\times \\mathit{population}_\\mathit{Boston} \\\\\n & = -3.89578 + 1.19303 * 64.5966 \\\\\n & = 73.17014\n\\end{split}\n\\end{equation}\n\nTherefore, based on current dataset, a new store for the coffee house chain is projected to have \\$731701 profit.\n\nFig. \\ref{fig6} visualizes the dataset along with the newly estimated profit for Boston branch.\n\n\\begin{figure}[H]\\centering\n\\includegraphics[width=0.8\\textwidth]{\\imgDirectory/umb-cs638-2016s-hw02-08.png}\n\\caption{Dataset including the estimated profit for potential branch in Boston}\\label{fig6}\n\\end{figure}\n\n\\cleardoublepage\n\n\\section*{Appendices}\n\n\\subsection*{Source Code}\n\n\\lstset{language=r,tabsize=4}\n\\lstinputlisting[firstline=1]{\\srcDirectory/r/hw02.r}\n\n\\end{document}\n", "meta": {"hexsha": "435f2ef0d5d694440043705b4c88c06c33d48927", "size": 6929, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "umb-cs638-2016s/src/tex/hw02-report.tex", "max_stars_repo_name": "ghorbanzade/beacon", "max_stars_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-13T20:00:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-01T11:16:51.000Z", "max_issues_repo_path": "umb-cs638-2016s/src/tex/hw02-report.tex", "max_issues_repo_name": "ghorbanzade/beacon", "max_issues_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "umb-cs638-2016s/src/tex/hw02-report.tex", "max_forks_repo_name": "ghorbanzade/beacon", "max_forks_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-20T05:58:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-06T17:18:05.000Z", "avg_line_length": 40.7588235294, "max_line_length": 222, "alphanum_fraction": 0.7328618848, "num_tokens": 2024, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7718434925908524, "lm_q1q2_score": 0.4100104980417982}}
{"text": "\\section{Model}\r\n\r\nLet index $i$ runs through\r\nusers, index $j$ runs through items, index $k$ runs through topics,\r\nand index $n$ runs through terms in an item. Let $M, N, K$ and $W$ denote\r\nthe numbers of users, items, topics and distinct terms in the\r\nvocabulary, respectively. $W_j$ denotes the number of terms in item\r\n$j$ (with duplicate terms preserved). We also abuse the notation a\r\nlittle by letting $x_i$, $x_j$ and $x_{ij}$ denote the feature vectors\r\nfor user $i$, item $j$ and the dyad $(i,j)$, respectively.\r\nThe model is specified in the following table.\\\\\r\n\r\n\\noindent\r\n\\begin{tabular}{lllr}\r\n\\hline \r\n\t\\multicolumn{4}{c}{{\\bf LDA-based Regression Latent Factor Model}} \\\\\r\n\\hline \r\n\t\\multicolumn{4}{c}{\\vspace{-0.1in}} \\\\\r\n{\\bf Rating:} &\r\n\t\\multicolumn{2}{l}{$y_{ij} \\sim \\mathcal{N}(m_{ij}, \\sigma^2), \\textrm{or}$\r\n\t~~~ (Gaussian)} & \\\\\r\n\t%~$[y_{ij} | X_{ij}, \\delta_{ij}, \\Theta_1]$\r\n \t&\r\n\t\\multicolumn{2}{l}{$y_{ij} \\sim \\textrm{Bernoulli}(m_{ij})$\r\n\t~~~~ (Logistic)} & \\\\\r\n\t\\vspace{0.07in}\r\n\t& \\multicolumn{2}{l}{\r\n\t$l(m_{ij}) = (x_{ij}^{\\prime}\\, b) \\gamma_i  + \\alpha_i + \\beta_j + \r\n\t\t\t\t\t u_{i}^{\\prime} \\, v_{j} +\r\n\t\t\t\t\t s_{i}^{\\prime} \\, \\bar{z}_{j}$\r\n\t} &  \\\\ \r\n{\\bf User factors:}\r\n& \t$\\alpha_i = g_{0}^{\\prime}x_i + \\epsilon_{i}^{\\alpha}$,\r\n\t\t& $\\epsilon_{i}^{\\alpha} \\sim \\mathcal{N}(0,a_{\\alpha})$ &  \\\\\r\n& \t$\\gamma_i = c_{0}^{\\prime}x_i + \\epsilon_{i}^{\\gamma}$,\r\n\t\t& $\\epsilon_{i}^{\\gamma} \\sim \\mathcal{N}(1,a_{\\gamma})$ &  \\\\\r\n& \t$u_i = G x_i + \\epsilon_{i}^{u}$,\r\n\t\t& $\\epsilon_{i}^{u} \\sim \\mathcal{N}(\\bm{0},A_u)$ & \\\\\r\n& \t$s_i = H x_i + \\epsilon_{i}^{s}$,\r\n\t\t& $\\epsilon_{i}^{s} \\sim \\mathcal{N}(\\bm{0},A_s)$ & \\vspace{0.07in} \\\\\r\n{\\bf Item factors:}\r\n& \t$\\beta_j = d_{0}^{\\prime}x_j + \\epsilon_{j}^{\\beta}$,\r\n\t\t& $\\epsilon_{j}^{\\beta} \\sim \\mathcal{N}(0,a_{\\beta})$ & \\\\\r\n&  $v_j = D x_j + \\epsilon_{j}^{v}$,\r\n\t   & $\\epsilon_{j}^{v} \\sim \\mathcal{N}(\\bm{0},A_v)$ & \\\\\r\n& \t$\\bar{z}_{j} = \\sum_n z_{jn} ~/~ W_j$\r\n\t\t& &  \\vspace{0.07in}\\\\ \r\n{\\bf Topic model:}\r\n& \t$\\theta_j \\sim \\textrm{Dirichlet}(\\lambda)$\r\n\t\t& (Topic distribution of item $j$) & \\\\\r\n& \t$\\Phi_k \\sim \\textrm{Dirichlet}(\\eta)$\r\n\t\t& (Word distribution of topic $k$) & \\\\\r\n&  $z_{jn} \\sim \\textrm{Multinom}(\\theta_j)$\r\n\t\t& (Topic of the $n$th word in $j$) & \\\\ \r\n&  $w_{jn} \\sim \\textrm{Multinom}(\\Phi \\, z_{jn})$\r\n\t\t& ($n$th observed word in $j$) &  \\vspace{0.07in}\\\\ \\hline\r\n\\end{tabular}\r\n\\\\\r\n\r\n\\noindent {\\bf Notes:}\r\n\\begin{itemize}\r\n\\item $y_{ij}$ is the observed rating given by user $i$ to item $j$.\r\n\r\n\\item $l(m_{ij}) = m_{ij}$ for Gaussian; $l(m_{ij}) = \\log\\frac{m_{ij}}{1-m_{ij}}$ for Logistic.\r\n\r\n\\item $x_{ij}$, $x_i$ and $x_j$ are the dyadic, user and item feature vectors for user $i$ and item $j$, respectively.\r\n\r\n\\item $\\alpha_i$ and $\\beta_j$ are the main factors for user $i$ and item $j$, respectively, intuitively representing the ``default'' rating that user $i$ would give to a random item and the overall popularity of item $j$. $u_i$ and $v_j$ are latent-factor vectors. We call the length of a latent-factor vector the number of latent dimensions.\r\n\r\n\\item $z_{jn}$ is a vector of zeros except for one position being one, which is the position representing the topic of the word. $\\Phi = [\\Phi_1, ..., \\Phi_K]$ and $\\Phi \\, z_{jn} = \\Phi_k$ such that $z_{jnk} = 1$. $\\eta$ is a scalar for the symmetric Dirichlet prior, but $\\lambda$ is a vector.\r\n\r\n\\item $\\bar{z}_j$ represents the probability distribution of topics in item $j$, and $s_i$ represents user $i$'s affinity to different topics. They are vectors of length equal to the number of topics. Notice that $x_{ij}$ may include TF/IDF similarity\r\nbetween the profile of user $i$ (e.g., top 200 entities in the items\r\nthat user $i$ frequently clicks) and the text of item $j$, and other\r\nIR similarity measures between user $i$ and item $j$.  Thus,\r\n$s_{i}^{\\prime} \\, \\bar{z}_{j}$ captures user $i$'s affinity to\r\nrelatively coarse-grained topics, while $x_{ij}^{\\prime}$ captures\r\nuser $i$'s affinity to fine-grained topics/entities. $b$ quantifies\r\nhow important each element of $x_{ij}$ is. For fine-grained\r\ntopic affinity, this model does not try to fit regression coefficients\r\nbecause of data sparseness at fine granularities.\r\n\r\n\\item $\\gamma_i$ is a scaling factor that gives the relative\r\nimportance of find-grained affinity $x_{ij}$ to coarse-grained\r\naffinity $s_{i}^{\\prime} \\, \\bar{z}_{j}$. Intuitively, this relative\r\nimportance should be different for different users. To prevent from\r\nadding too many factors (instead of replacing $b$ by $b_i$, which is a\r\nvector, for each user), we only add a single scaling factor $\\gamma_i$\r\nfor each user.  If $x_{ij}$ only has one element, then we just set $b$\r\nto 1. Whether we really need $\\gamma_i$ is not clear. I just include this so that we can try this out.\r\n\r\n\\item $b$, $g_0$, $d_0$ and $c_0$ are regression weight vectors. $G$, $D$ and $H$ are regression weight matrices.\r\n\r\n\\item $a_{\\alpha}$, $a_{\\beta}$ and $a_\\gamma$ are unknown variances. $A_u$, $A_v$ and $A_s$ are unknown variance-covariance matrices.\r\n\r\n\\end{itemize}\r\n", "meta": {"hexsha": "c607ebff49b5fb5de7aafbf0219111ccd8e91d91", "size": 5084, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/LDA-RLFM/doc/model.tex", "max_stars_repo_name": "beechung/Latent-Factor-Models", "max_stars_repo_head_hexsha": "bda67b6fab8fa3a4219d5360651d9105e006a8c7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 86, "max_stars_repo_stars_event_min_datetime": "2015-02-02T21:49:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T08:24:53.000Z", "max_issues_repo_path": "src/LDA-RLFM/doc/model.tex", "max_issues_repo_name": "TotallyBullshit/Latent-Factor-Models", "max_issues_repo_head_hexsha": "3815cbb311da8819b686661ce7007a7cb62e0f7a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-05-05T19:40:11.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-31T01:14:49.000Z", "max_forks_repo_path": "src/LDA-RLFM/doc/model.tex", "max_forks_repo_name": "TotallyBullshit/Latent-Factor-Models", "max_forks_repo_head_hexsha": "3815cbb311da8819b686661ce7007a7cb62e0f7a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 36, "max_forks_repo_forks_event_min_datetime": "2015-01-26T05:13:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-24T05:37:19.000Z", "avg_line_length": 52.412371134, "max_line_length": 344, "alphanum_fraction": 0.641620771, "num_tokens": 1783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8198933271118221, "lm_q2_score": 0.5, "lm_q1q2_score": 0.40994666355591103}}
{"text": "%\\documentclass[8pt]{extarticle} % Use for smaller font size.\n\\documentclass[10pt]{article} % 10pt is smallest font size for 'article'.\n\\usepackage[utf8]{inputenc}\n\\usepackage{multicol}\n\\usepackage{calc}\n\\usepackage{ifthen}\n\\usepackage[portrait]{geometry}\n\\usepackage{amsmath,amsthm,amsfonts,amssymb}\n\\usepackage{mathtools}\n\\usepackage{wasysym}\n\\usepackage{tensor}\n\\usepackage{color,graphicx,overpic}\n\\usepackage{hyperref}\n\\usepackage{enumerate}\n\\usepackage{etoolbox} % Required for \\appto.\n\\usepackage{centernot}\n\n\\usepackage{xargs}\n\n\\usepackage{ifthen}\n\n% Define emphasis to be bold face and italic.\n\\DeclareTextFontCommand{\\emph}{\\bfseries\\em}\n\n% Removes most of whitespace above and below equations.\n\\newcommand{\\zerodisplayskips}{%\n  \\setlength{\\abovedisplayskip}{-5pt}% Default: 12pt plus 3pt minus 9pt\n  \\setlength{\\belowdisplayskip}{3pt}% Default: 0pt plus 3pt\n  \\setlength{\\abovedisplayshortskip}{-5pt}% Default: 12pt plus 3pt minus 9pt\n  \\setlength{\\belowdisplayshortskip}{3pt}% Default: 7pt plus 3pt minus 4pt\n}\n\\appto{\\normalsize}{\\zerodisplayskips}\n\\appto{\\small}{\\zerodisplayskips}\n\\appto{\\footnotesize}{\\zerodisplayskips}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Theorem Environment Setup %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\usepackage{amsthm}\n\n% New environments for definitions and theorems. These will let us put in the\n% exact reference to the definition/theorems in the notes, e.g.\n%\n% \\begin{definition}{5.1.1}{}\n%     ...\n% \\end{definition}\n%\n% to create a definition with title \"Definition 5.1.1\", referencing the\n% definition with the same number in the notes.\n\\newenvironmentx{definition}[2][\\empty] {\n\n    \\newcommand{\\Title}{Definition}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{theorem}[2][\\empty] {\n\n    \\newcommand{\\Title}{Theorem}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{lemma}[2][\\empty] {\n\n    \\newcommand{\\Title}{Lemma}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\n\\newenvironmentx{proposition}[2][\\empty] {\n\n    \\newcommand{\\Title}{Proposition}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{corollary}[2][\\empty] {\n\n    \\newcommand{\\Title}{Corollary}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{remark}[2][\\empty] {\n\n    \\newcommand{\\Title}{Remark}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{example}[2][\\empty] {\n\n    \\newcommand{\\Title}{Example}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\\newenvironmentx{exercise}[2][\\empty] {\n\n    \\newcommand{\\Title}{Exercise}\n\n    \\ifthenelse{ \\equal{#2}{\\empty} }{\n        % Only one argument supplied, don't need parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1}.\n        \\ignorespaces\n    }{\n        % Two arguments supplied, show in parantheses.\n        \\par\\addvspace{\\topsep}\n        \\noindent\\textbf{\\Title\\  #1} (#2).\n        \\ignorespaces\n    }\n}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Commands for Mathematical Typesetting %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Redefine \\leq and \\geq to something nicer looking:\n\\renewcommand{\\leq}{\\leqslant}\n\\renewcommand{\\geq}{\\geqslant}\n\n% Inner Product:\n\\DeclareRobustCommand{\\InnerProduct}[2]{\n    \\ifmmode\n        \\left( #1,#2 \\right)\n    \\else\n        \\GenericError{\\space\\space\\space\\space}\n        {Attempting to use \\InnerProduct outside of math mode}\n    \\fi\n}\n\n% Vector Norm: \n\\DeclareRobustCommand{\\Norm}[1]{\n    \\ifmmode\n        \\left\\lVert #1 \\right\\rVert\n    \\else\n        \\GenericError{\\space\\space\\space\\space}\n        {Attempting to use \\Norm outside of math mode}\n    \\fi\n}\n\n% Image of Function:\n\\DeclareMathOperator{\\im}{im}\n\n% Sign:\n\\DeclareMathOperator{\\sgn}{sgn}\n\n% Norm of a Vector:\n\\newcommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\n% Set of Matrices:\n\\DeclareMathOperator{\\Mat}{Mat}\n\n% Proof Hint:\n\\newcommand{\\Hint}{\\vspace{0.2em}\\textit{Hint: }}\n\n% Identity Mapping:\n\\DeclareMathOperator{\\id}{id}\n\n% This sets page margins to .5 inch if using letter paper, and to 1cm\n% if using A4 paper. (This probably isn't strictly necessary.)\n% If using another size paper, use default 1cm margins.\n\\ifthenelse{\\lengthtest { \\paperwidth = 11in}}\n    { \\geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }\n    {\\ifthenelse{ \\lengthtest{ \\paperwidth = 297mm}}\n        {\\geometdry{top=1cm,left=1cm,right=1cm,bottom=1cm} }\n        {\\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }\n    }\n\n% Turn off header and footer\n\\pagestyle{empty}\n\n% Redefine section commands to use less space\n\\makeatletter\n\\renewcommand{\\section}{\\@startsection{section}{1}{0mm}%\n                                {-1ex plus -.5ex minus -.2ex}%\n                                {0.5ex plus .2ex}%x\n                                {\\normalfont\\large\\bfseries}}\n\\renewcommand{\\subsection}{\\@startsection{subsection}{2}{0mm}%\n                                {-1explus -.5ex minus -.2ex}%\n                                {0.5ex plus .2ex}%\n                                {\\normalfont\\normalsize\\bfseries}}\n\\renewcommand{\\subsubsection}{\\@startsection{subsubsection}{3}{0mm}%\n                                {-1ex plus -.5ex minus -.2ex}%\n                                {1ex plus .2ex}%\n                                {\\normalfont\\small\\bfseries}}\n\\makeatother\n\n% Define BibTeX command\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\n\n% Don't print section numbers\n\\setcounter{secnumdepth}{0}\n\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{0pt plus 0.5ex}\n\n%My Environments\n%\\newtheorem{example}[section]{Example}\n% -----------------------------------------------------------------------\n\n\\begin{document}\n\\raggedright\n\\footnotesize\n\\begin{multicols}{3}\n\n\n% multicols parameters\n% These lengths are set only within the two main columns\n%\\setlength{\\columnseprule}{0.25pt}\n\\setlength{\\premulticols}{1pt}\n\\setlength{\\postmulticols}{1pt}\n\\setlength{\\multicolsep}{1pt}\n\\setlength{\\columnsep}{2pt}\n\\setlength{\\columnseprule}{0.4pt} % For vertical lines separating columns.\n\n\\begin{center}\n     \\Large{Algebra} \\\\\n     \\footnotesize{Sebastian Müksch, v2, 2018/19}\n\\end{center}\n\n% Cauchy-Schwarz Inequality.\n%\\begin{theorem}{5.2.5}{Cauchy-Schwarz}\n%\n%    $\\vec{v},\\vec{w}$ in inner product space, then\n%\n%        \\begin{align*}\n%            \\left| \\InnerProduct{\\vec{v}}{\\vec{w}} \\right| \\leq \\Norm{\\vec{v}} \\Norm{\\vec{w}}\n%        \\end{align*}\n%\n%    with equality if linearly \\emph{dependent}.\n%\n%\\end{theorem}\n\n%%%%%%%%%%%%%%%%%\n% Vector Spaces %\n%%%%%%%%%%%%%%%%%\n\n\\section{Vector Spaces}\n\n% Zero-Conclusions in Vector Spaces.\n\\begin{lemma}{1.2.4}{Product with Zero Vector}\n\n    Let $V$ be an $F$-vector space, then $\\forall \\lambda \\in F: \\lambda \\vec{0} = \\vec{0}$. Furthermore, $\\lambda \\vec{v} = \\vec{0} \\Rightarrow \\lambda = 0$ or $\\vec{v} = 0$.\n\n\\end{lemma}\n\n% Generated Subspace Is Minimal Containing Subspace.\n\\begin{proposition}{1.4.5}{Generating a Vector Subspace From a Set}\n\n    Let $T \\subseteq V$, $V$ begin vector space over $F$. Then $\\langle T \\rangle$ is the smallest subspace of $V$ containing $T$.\n\n\\end{proposition}\n\n% Vectors In Span Do Not Change The Span.\n\\begin{example}{1.4.6}{}\n\n    Let $T \\subseteq V$, $\\vec{v} \\in \\langle T \\rangle$. Then $\\langle T \\cup \\{\\vec{v}\\} \\rangle = \\langle T \\rangle$.\n\n\\end{example}\n\n% Intersection of Subspaces is Subspace.\n\\begin{exercise}{4}{}\n\n    Any intersection of vector subspaces is a vector subspace.\n\n\\end{exercise}\n\n% Properties of Bases.\n\\begin{theorem}{1.5.12}{Characterisation of Bases}\n\n    Let $E \\subseteq V$ of vector space $V$. The following are equivalent:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $E$ is a basis;\n            \\item $E$ is a \\emph{minimal generating} set, i.e. $\\forall \\vec{v} \\in E: E \\setminus \\{\\vec{v}\\}$ is not generating;\n            \\item $E$ is \\emph{maximal linearly independent} set, $\\forall \\vec{v} \\in V: E \\cup \\{\\vec{v}\\}$ is not linearly independent.\n        \\end{enumerate}\n\n\\end{theorem}\n\n% Every Finite Vector Space Has a Basis.\n\\begin{corollary}{1.5.13}{The Existence of a Basis}\n\n    Let $V$ be a finite vector space over field $F$. Then $V$ has a basis.\n\n    \\Hint Take finite generating set, reduce until linearly independent.\n\n\\end{corollary}\n\n\\begin{theorem}{1.5.14}{Useful Variant on Characterisation of Bases}\n\n    Let $V$ be a vector space.\n\n        \\begin{enumerate}[(1)]\n            \\item If $L \\subset V$ is linearly independent and $E$ is minimal generating set s.t. $L \\subseteq E$, then $E$ is a basis.\n            \\item If $E \\subseteq V$ is generating and $L$ is maximal linearly independent set s.t. $L \\subseteq E$, then $L$ is a basis.\n        \\end{enumerate}\n\n\\end{theorem}\n\n% Vectors Have Unique Way of Being Written as Combination of Bases Vectors.\n\\begin{theorem}{1.5.16}{A Useful Variant on Linear Combinations of Basis Elements}\n\n    Let $V$ be a $F$-vector space, $F$ being a field and $(\\vec{v}_i)_{i \\in I}$ a family of vectors in $V$. The following are equivalent:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item Family $(\\vec{v}_i)_{i \\in I}$ is a basis for $V$;\n            \\item $\\forall \\vec{v} \\in V$, there exists \\emph{precisely one} family $(a_i)_{i \\in I}$ of elements in $F$, almost all zero, s.t. $\\vec{v} = \\sum_{i \\in I}a_i\\vec{v}_i$.\n        \\end{enumerate}\n\n\\end{theorem}\n\n% Linearly Independent Sets Are At Most As Big As Generating Sets.\n\\begin{theorem}{1.6.1}{Fundamental Estimate of Linear Algebra}\n\n    Let $V$ be a vector space, $L \\subset V$ a linearly independent subset and $E \\subseteq V$ a generating set. Then $|L| \\leq |E|$.\n\n\\end{theorem}\n\n\\begin{theorem}{1.6.2}{Steinitz Exchange Theorem}\n\n    Let $V$ be a vector space, $L \\subset V$ a \\emph{finite} linearly independent subset and $E \\subseteq V$ a generating set. Then we can swap elements of $E$ with elements of $L$ and keep it a generating set.\n\n\\end{theorem}\n\n\\begin{lemma}{1.6.3}{Exchange Lemma}\n\n    Let $V$ be a vector space, $M \\subseteq V$ a linearly independent, $E$ a generating set s.t. $M \\subseteq E$. If $\\vec{w} \\in V \\setminus M$ s.t. $M \\cup \\{ \\vec{w} \\}$ is linearly independent, then $\\exists \\vec{e} \\in E \\setminus M$ s.t. $(E \\setminus \\{\\vec{e}\\} \\cup \\{\\vec{w}\\})$ is generating.\n\n    \\Hint $\\vec{w} = \\sum \\alpha_i \\vec{e}_i,\\ \\vec{e}_i \\in E$, $M \\cup \\{ \\vec{w} \\} \\Rightarrow \\exists \\vec{e}_i \\not\\in M$, express that $\\vec{e}_i$ with $\\vec{w}$.\n\n\\end{lemma}\n\n% Finite Vector Spaces Have Finite Bases of Equal Size.\n\\begin{corollary}{1.6.4}{Cardinality of Bases}\n\n    Let $V$ be a \\emph{finitely} generated vector space.\n\n    \\begin{enumerate}[(1)]\n        \\setlength{\\parskip}{0em}\n        \\item $V$ has a finite basis;\n        \\item $V$ cannot have an infinite basis;\n        \\item Any two bases of $V$ have the same number of elements.\n    \\end{enumerate}\n\n    \\Hint Theorem 1.6.1 \\& Contradiction.\n\n\\end{corollary}\n\n% Dimension of Zero Vector Space.\n\\begin{example}{1.6.7}{}\n\n    Basis of zero vector space is $\\emptyset \\Rightarrow$ dimension of zero vector space is $0$.\n\n\\end{example}\n\n% Bounds on Sizes of Linearly Independent and Generating Sets.\n\\begin{corollary}{1.6.8}{Cardinality Criterion for Bases}\n\n    Let $V$ be a finitely generated vector space.\n\n        \\begin{enumerate}[(1)]\n            \\item $L \\subset V$ linearly independent, then $|L| \\leq \\dim{V}$ and $|L| = \\dim{V} \\Rightarrow$ $L$ is a basis.\n            \\item $E \\subseteq V$ generating, then $\\dim{V} \\leq |E|$ and $|E| = \\dim{V} \\Rightarrow$ $E$ is a basis.\n        \\end{enumerate}\n\n    \\Hint Theorem 1.6.1 \\& 1.5.12.\n\n\\end{corollary}\n\n% Proper Subspaces Have Strictly Lower Dimensions.\n\\begin{corollary}{1.6.9}{Dimension Estimate of Vector Subspaces}\n\n    Let $U \\subset V$ be a proper subspace of \\emph{finite} vector space $V$. Then $\\dim{U} < \\dim{V}$.\n\n\\end{corollary}\n\n% Arbitrary Subspace Conclusions Based on Dimensionality.\n\\begin{remark}{1.6.10}{}\n\n    If $U \\subseteq V$ subspace of arbitrary vector space, then $\\dim{U} \\leq \\dim{V}$ and $\\dim{U} = \\dim{V} < \\infty \\Rightarrow U = V$.\n\n\\end{remark}\n\n% Dimensionality of Subspace Spanned by Two Subspaces.\n% N.B.: This looks a lot like Inclusion-Exclusion Principle.\n\\begin{theorem}{1.6.11}{The Dimension Theorem}\n\n    Let $U,W \\subseteq V$ be subspaces. Then\n\n        \\begin{align*}\n            \\dim{(U + W)} + \\dim{(U \\cap W)} = \\dim{U} + \\dim{W} \\\\\n            \\dim{(U + W)} = \\dim{U} + \\dim{W} - \\dim{(U \\cap W)}\n        \\end{align*}\n\n    \\Hint $f: U \\oplus W \\to V$; $(\\vec{u},\\vec{w}) \\mapsto \\vec{u} + \\vec{w}$ $\\Rightarrow \\im{f} = U + W$, $\\ker{f} = U \\cap W$. Rank-Nullity.\n\n\\end{theorem}\n\n% Dimension of Cartesian Product.\n\\begin{exercise}{6}{}\n\n    Let $V_1,\\hdots,V_n$ be $F$-vector spaces, then $\\dim(V_1 \\oplus \\hdots \\oplus V_n)$ $= \\dim(V_1) + \\hdots + \\dim(V_n)$.\n\n\\end{exercise}\n\n% Linear Mappings Map Vector Subspaces to Vector Subspaces.\n\\begin{exercise}{10}{}\n\n    The image/preimage of a vector subspace under a linear mapping is a vector subspace.\n\n\\end{exercise}\n\n% Combining Linear Mappings.\n\\begin{exercise}{12}{}\n\n    Let $V_1,\\hdots,V_n,W$ be vector spaces, $f_i:V_i \\to W$ linear mappings. Then $f: V_1 \\oplus \\hdots \\oplus V_n \\to W$ with $f(\\vec{v}_1,\\hdots,\\vec{v}_n) = f_1(\\vec{v}_1) + \\hdots + f_i(\\vec{v}_n)$ is a new linear mapping. This gives a bijection:\n\n        \\begin{align*}\n            \\mathrm{Hom}(V_1,W) \\times \\hdots \\times \\mathrm{Hom}(V_n,W) \\\\ \\xrightarrow{\\sim} \\mathrm{Hom}(V_1 \\oplus \\hdots \\oplus V_n,W)\n        \\end{align*}\n\n    with inverse $f \\mapsto (f \\circ \\mathrm{in}_i)_i$.\n\n\\end{exercise}\n\n% n Dimensional Vector Spaces Are Isomorphic to F^n.\n\\begin{theorem}{1.7.7}{Classification of Vector Space by Dimension}\n\n    Let $V$ be vector space over $F$, $n \\in \\mathbb{N}$. Then $F^n \\cong V \\Leftrightarrow \\dim{V} = n$.\n\n\\end{theorem}\n\n% Linear Maps From Subspaces Can Be Extended.\n\\begin{exercise}{17}{}\n\n    Let $U \\subseteq V$ be subspace of vector space $V$ and $f: U \\to W$. Then $f$ can be extended to a \\emph{linear} mapping $\\tilde{f}: V \\to W$.\n\n\\end{exercise}\n\n% Rank-Nullity Theorem.\n\\begin{theorem}{1.8.4}{Rank-Nullity Theorem}\n\n    Let $f: V \\to W$ be a linear mapping. Then\n\n        \\begin{align*}\n            \\dim{V} = \\dim{(\\im{f})} + \\dim{(\\ker{f})}\n        \\end{align*}\n\n    \\Hint $V$ finite $\\Rightarrow \\im{f},\\ker{f}$ finite, contrapositive shows Theorem holds for $V$ infinite case. Assume $V$ finite, then Cor. 1.5.13 \\& Ex. 18.\n\n\\end{theorem}\n\n% Linear Map Partitions Basis into Bases for Kernel and Image.\n\\begin{exercise}{18}{}\n\n    Let $f: V \\to W$ be a linear map. If $\\vec{v}_1, \\hdots, \\vec{v}_s$ is a basis for $\\ker{f}$ and extended by $\\vec{v}_{s+1}, \\hdots, \\vec{v}$ it is basis of $V$, then $f(\\vec{v}_{s+1}),\\hdots,f(\\vec{v}_n)$ is basis of $\\im{f}$.\n\n\\end{exercise}\n\n% Complementary Subspaces Partition The Space.\n\\begin{exercise}{19}{}\n\n    Let $U,W \\subseteq V$ be subspaces of $V$. $U,W$ are complementary $\\Leftrightarrow$ $V = U + W$ and $U \\cap W = \\{0\\}$.\n\n\\end{exercise}\n\n% Complementary Subspaces Span The Space and Are Small Enough.\n\\begin{exercise}{20}{}\n\n    Let $U,W \\subseteq V$ be subspaces of $V$. $U,W$ are complementary $\\Leftrightarrow$ $V = U + W$ and $\\dim{U} + \\dim{W} \\leq \\dim{V}$.\n\n\\end{exercise}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Linear Mappings and Matrices %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Linear Mappings and Matrices}\n\n% Square Matrices Are Products of Elementary Ones.\n\\begin{theorem}{2.2.3}{}\n\n    Every square matrix with entries in a field can be written as a product of elementary matrices.\n\n\\end{theorem}\n\n% Every Matrix Has a Smith Normal Form.\n\\begin{theorem}{2.2.5}{}\n\n    For every $A \\in \\Mat(n \\times m;F)$ there exist \\emph{invertible} matrices $P,Q$ s.t. $PAQ$ is in Smith Normal Form.\n\n    \\Hint First row operations to echelon form, then column operations.\n\n\\end{theorem}\n\n% Column Rank And Row Rank Are Equal.\n\\begin{theorem}{2.2.7}{}\n\n    For any matrix, column and row rank are equal.\n\n    \\Hint Column \\& Row rank of matrix and its Smith Normal Form are equal as $P,Q$ in Theorem 2.2.5 are invertible.\n\n\\end{theorem}\n\n% Change From One Basis to Another.\n\\begin{theorem}{2.4.3}{Change of Basis}\n\n    Let $f: V \\to W$, $\\mathcal{A},\\mathcal{A}'$ ordered bases of $V$, $\\mathcal{B},\\mathcal{B}'$ ordered bases of $W$. Then\n\n        \\begin{align*}\n            \\tensor[_{\\mathcal{B}'}]{[f]}{_{\\mathcal{A}'}} = \\tensor[_{\\mathcal{B}'}]{[\\mathrm{id}_W]}{_{\\mathcal{B}}} \\circ \\tensor[_{\\mathcal{B}}]{[f]}{_{\\mathcal{A}}} \\circ \\tensor[_{\\mathcal{A}}]{[\\mathrm{id}_V]}{_{\\mathcal{A}'}}\n        \\end{align*}\n\n\\end{theorem}\n\n% Shortcut For Changing Bases.\n\\begin{corollary}{(unlisted)}{}\n\n    Let $f: \\mathbb{R}^n \\to \\mathbb{R}^m$, $\\mathcal{A} = \\{\\vec{a}_i\\}$ ordered basis of $\\mathrm{R}^n$, $\\mathcal{B} = \\{ \\vec{b}_i \\}$ ordered basis of $\\mathbb{R}^m$. Then\n\n        \\begin{align*}\n            \\tensor[_{\\mathcal{B}}]{[f]}{_{\\mathcal{A}}} = (\\tensor[_{\\mathcal{S}(m)}]{[\\mathrm{id}_{\\mathbb{R}^m}]}{_{\\mathcal{B}}})^{-1} \\circ \\tensor[_{\\mathcal{S}(m)}]{[f]}{_{\\mathcal{A}}} = \\\\\n            (\\vec{b}_1|\\vec{b}_2|\\hdots|\\vec{b}_m)^{-1}(f(\\vec{a}_1)|f(\\vec{a}_2)|\\hdots|f(\\vec{a}_n))\n        \\end{align*}\n\n\\end{corollary}\n\n% Faster Change of Basis For Endomorphisms.\n\\begin{theorem}{2.4.4}{}\n\n    Let $f: V \\to V$, $\\mathcal{A},\\mathcal{A}'$ ordered bases of $V$. Then\n\n        \\begin{align*}\n            \\tensor[_{\\mathcal{A}'}]{[f]}{_{\\mathcal{A}'}} = (\\tensor[_{\\mathcal{A}}]{[\\mathrm{id}_V]}{_{\\mathcal{A}'}})^{-1} \\circ \\tensor[_{\\mathcal{A}}]{[f]}{_{\\mathcal{A}}} \\circ \\tensor[_{\\mathcal{A}}]{[\\mathrm{id}_V]}{_{\\mathcal{A}'}}\n        \\end{align*}\n\n\\end{theorem}\n\n% Shape of Nilpotent Matrices And Nilpotent to Power of Size is Zero.\n\\begin{exercise}{32}{}\n\n    Let $f: V \\to V$. Then $f$ nilpotent $\\Rightarrow$ there exists an order basis of $V$ s.t. representing matrix of $f$ is upper triangular with only $0$'s along diagonal. Additionally, $M \\in \\Mat(n;F)$ upper triangular with only $0$'s along diagonal $\\Rightarrow$ $M^n = 0$.\n\n\\end{exercise}\n\n% Trace is Invariant to Commutation in Matrix Product.\n\\begin{exercise}{33}{}\n\n    Let $A,B$ be matrices of appropriate sizes, then $\\mathrm{tr}(AB) = \\mathrm{tr}(BA)$.\n\n\\end{exercise}\n\n% Conjugate Matrices Have Equal Trace.\n\\begin{corollary}{33}{}\n\n    Conjugate matrices have equal trace.\n\n    \\Hint Ex. 33 with $A=T^{-1}M,B=T$.\n\n\\end{corollary}\n\n% Calculate Dimension of Image of Idempotent Map Via Trace.\n\\begin{exercise}{35}{}\n\n    Let $f: V \\to V$ be idempotent, i.e. $f^2 = f$, then $\\mathrm{tr}(f) = \\dim{(\\im{f})}$.\n\n\\end{exercise}\n\n%%%%%%%%%%%%%%%%%%%%%\n% Rings and Modules %\n%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Rings and Modules}\n\n% Field Integers Modulo m.\n\\begin{proposition}{3.1.11}{}\n\n    Let $m \\in \\mathbb{N}$, then $\\mathbb{Z}/m\\mathbb{Z}$ is a field if and only if $m$ is prime.\n\n    \\Hint $(\\!\\Rightarrow\\!)$ $\\overline{a} \\in \\mathbb{Z}/m\\mathbb{Z} \\Rightarrow \\exists \\overline{b} \\in \\mathbb{Z}/m\\mathbb{Z}$ s.t. $\\overline{ab} = 1 \\Leftrightarrow ab = km + 1$. $a$ does not divide $1$, so cannot divide $m$. $(\\Longleftarrow)$ $\\overline{a} \\in \\mathbb{Z}/m\\mathbb{Z}$, $\\mathrm{hcf}(a,m)=1 \\Leftrightarrow ab + mk = 1 \\Leftrightarrow \\overline{ab} = 1$.\n\n\\end{proposition}\n\n% Multiplication group of units in a ring.\n\\begin{proposition}{3.2.10}{}\n    The set $R^{\\times}$ of units in $R$ forms a \\emph{group under multiplication}.\n\\end{proposition}\n\n% Zero-related conclusions in integral domain.\n\\begin{remark}{(unknown)}{}\n    If $R$ is an integral domain, then for $a,b \\in R$:\n\n    \\begin{enumerate}[(1)]\n        \\setlength{\\parskip}{0em}\n        \\item $ab = 0 \\Rightarrow a = 0$ or $b = 0$, and\n        \\item $a \\neq 0$ and $b \\neq 0 \\Rightarrow ab \\neq 0$.\n    \\end{enumerate}\n\\end{remark}\n\n% Cancellation Law of Integral Domains.\n\\begin{proposition}{3.2.16}{Cancellation Law of Integral Domains}\n\n    Let $R$ be an integral domain and $a,b,c \\in R$. Then $ac = bc$ and $c \\neq 0$ implies $a = b$.\n\n    \\Hint $ac = bc \\Leftrightarrow (a - b)c = 0$.\n\n\\end{proposition}\n\n% When integer factor ring is an integral domain.\n\\begin{proposition}{3.2.17}{}\n\n    Let $m \\in \\mathbb{N}$, then $\\mathbb{Z}/m\\mathbb{Z}$ is an integral domain if and only if $m$ is prime.\n\n    \\Hint $(\\Leftarrow)$ $\\overline{k},\\overline{l}$ zero-divisors $\\Rightarrow$ $\\overline{kl}=\\overline{0}$ $\\Rightarrow$ $m$ divides $k$ or $l$ as $m$ prime, so $\\overline{k} = 0$ or $\\overline{l} = 0$, contradiction. $(\\Rightarrow)$ $m$ not prime, then $m = kl$, $1 < k,l < m$, then $\\overline{k} \\neq 0$ or $\\overline{l} \\neq 0$ but $\\overline{kl} = \\overline{0}$.\n\n\\end{proposition}\n\n% Finite Integral Domains are Fields.\n\\begin{theorem}{3.2.18}{}\n\n    Every \\emph{finite} integral domain is a field.\n\n    \\Hint $\\lambda_a: R \\to R; b \\mapsto ab$, cancellation law gives injectivity, finite gives surjectivity.\n\n\\end{theorem}\n\n% Zero-divisor Properties Inherited By Polynomial Rings.\n\\begin{lemma}{3.3.3}{}\n\n    \\begin{enumerate}[(i)]\n        \\item If $R$ has no zero-divisors, then $R[X]$ has no zero-divisors and $\\mathrm{deg}(PQ) = \\mathrm{deg}(P) + \\mathrm{deg}(Q)$.\n        \\item If $R$ is an integral domain, so is $R[X]$.\n    \\end{enumerate}\n\n\\end{lemma}\n\n% Existence and Uniqueness of Dividing Polynomial and Remainder.\n\\begin{theorem}{3.3.4}{Division and Remainder}\n\n    Let $R$ be an integral domain and $P,Q \\in R[X]$ with $Q$ \\emph{monic}. Then there exists \\emph{unique} $A,B \\in R[X]$ s.t. $P = AQ + B$ and $\\deg(B) < \\deg(Q)$ or $B = 0$.\n\n    \\Hint Choose $A$ s.t. $\\deg(P - AQ)$ minimal (possible as degree non-negative. Suppose $\\deg(P - AQ) = r \\geq \\deg(Q) = d$ $\\Rightarrow$ $\\deg(P - A + a_rX^{r-d}Q) < \\deg(P - AQ)$.\n\n\\end{theorem}\n\n% Units in Polynomial Ring over Integral Domain.\n\\begin{exercise}{42}{}\n\n    If $R$ is an integral domain, then $R[X]^{\\times} = R^{\\times}$.\n\n\\end{exercise}\n\n% Polynomials Are Not Just Special Functions.\n\\begin{exercise}{43}{}\n\n    Let $R=\\mathbb{F}_p$, where $p$ is prime. Then the mapping $R[X] \\to \\mathrm{Maps}(R,R)$ is not injective.\n\n    \\Hint $X^p - X \\in \\mathbb{F}_p[X]$ \\& Fermat's Little Theorem.\n\n\\end{exercise}\n\n% Root-related Factor of a Polynomial.\n\\begin{proposition}{3.3.9}{}\n\n    Let $R$ be a commutative ring, $\\lambda \\in R$ and $P(X) \\in R[X]$. Then $\\lambda$ is a root of $P(X)$ if and only if $(X - \\lambda)$ divides $P(X)$.\n\n\\end{proposition}\n\n% Maximum Number of Roots in Polynomial.\n\\begin{theorem}{3.3.10}{}\n\n    Let $R$ be an integral domain. Then a non-zero polynomial $P \\in R[X]$ has at most $\\mathrm{deg}(P)$ roots in $R$.\n\n    \\Hint $\\lambda_{1,\\hdots,m}$ distinct roots of $P$ $\\Rightarrow$ $i \\geq 2:$ $0 = P(\\lambda_i) = A(\\lambda_i)(\\lambda_i - \\lambda_1)$ and $\\lambda_i - \\lambda_1 \\neq 0$, induction.\n\n\\end{theorem}\n\n% Fundamental Theorem of Algebra.\n\\begin{theorem}{3.3.13}{Fundamental Theorem of Algebra}\n\n    The field $\\mathbb{C}$ is algebraically closed.\n\n\\end{theorem}\n\n% Linear Factor Decomposition of Polynomials.\n\\begin{theorem}{3.3.14}{}\n\n    Let $F$ be an algebraically closed field. Then every non-zero polynomial $P \\in F[X]$ \\emph{decomposes into linear factors}\n\n        \\begin{align*}\n            P = c(X - \\lambda_1)\\hdots(X - \\lambda_n)\n        \\end{align*}\n\n    with $n \\geq 0$, $c \\in F^{\\times}$ and $\\lambda_i \\in F$. This decomposition is \\emph{unique}, up to reordering.\n\n\\end{theorem}\n\n% Possible Values of Identity under Homomorphism.\n\\begin{remark}{3.4.4}{}\n\n    Let $R,S$ be rings and $f: R \\to S$ be a homomorphism. Then $f(1_R)$ is \\emph{idempotent}, i.e. $f(1_R)^2=f(1_R) \\Leftrightarrow f(1_r)[f(1_R) - 1_S]=0_S$. If $S$ has no zero-divisors, then either $f(1_R) = 0_S$ or $f(1_R) = 1_S$.\n\n\\end{remark}\n\n% Properties of Homomorphisms.\n\\begin{lemma}{3.4.5}{}\n\n    Let $f: R \\to S$ be a ring homomorphism. Then for all $x,y \\in R$, $m \\in \\mathbb{Z}$:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $f(0_R) = 0_S$;\n            \\item $f(-x) = -f(x)$;\n            \\item $f(x-y) = f(x)-f(y)$;\n            \\item $f(mx) = mf(x)$.\n        \\end{enumerate}\n\n\\end{lemma}\n\n% Homomorphism Not Sending Identity to Identity.\n\\begin{remark}{3.4.6}{}\n\n    \\begin{enumerate}[(1)]\n        \\setlength{\\parskip}{0em}\n        \\item Let $f$ be a homomorphism. Then $f(x^n)=(f(x))^n$ for all $n \\in \\mathbb{N}$.\n        \\item Let $f: \\mathbb{R} \\to \\textrm{Mat}(2;\\mathbb{R}); x \\mapsto \\bigl( \\begin{smallmatrix}x & 0\\\\ 0 & 0\\end{smallmatrix}\\bigr)$, then $f$ does not send identity to identity.\n    \\end{enumerate}\n\n\\end{remark}\n\n% Set Failing Last Axiom of Ideals.\n\\begin{example}{3.4.10}{}\n\n    $I = \\{ \\bigl( \\begin{smallmatrix}0 & b\\\\ 0 & d\\end{smallmatrix}\\bigr): b,d \\in \\mathbb{R} \\subset \\Mat(2;\\mathbb{R})$ is not an ideal, it fails to satisfy $ir \\in I$.\n\n\\end{example}\n\n\\begin{proposition}{3.4.14}{}\n\n    Let $R$ be a commutative ring, $T \\subseteq R$. Then $\\tensor[_R]{\\langle T \\rangle}{}$ is the smallest ideal of $R$ containing $T$.\n\n    \\Hint Minimality: $I \\unlhd R, t_1, \\hdots, t_m \\in I \\Rightarrow \\sum_{i=1}^m r_it_i \\in I$.\n\n\\end{proposition}\n\n% Kernel of a Homomorphism is an Ideal.\n\\begin{proposition}{3.4.18}{}\n\n    Let $f: R \\to S$ be a ring homomorphism. Then $\\ker{f} \\unlhd R$.\n\n\\end{proposition}\n\n% Injectivity if and only if Trivial Kernel.\n\\begin{lemma}{3.4.20}{}\n\n    $f$ injective $\\Leftrightarrow \\ker{f} = \\{0\\}$.\n\n\\end{lemma}\n\n% Intersection of Ideals is an Ideal.\n\\begin{lemma}{3.4.21}{}\n\n    $I, J \\unlhd R \\Rightarrow I \\cap J \\unlhd R$.\n\n\\end{lemma}\n\n% The Sum of Ideals is an Ideal.\n\\begin{lemma}{3.4.21}{}\n\n    $I, J \\unlhd R \\Rightarrow I + J = \\{a + b: a \\in I, b \\in J\\} \\unlhd R$.\n\n\\end{lemma}\n\n% Subring with Different Identity.\n\\begin{example}{3.4.25}{}\n\n    If $F$ is a field, then for any $m,n \\in \\mathbb{N}$, with $m \\leq n$, $\\Mat(m;F)$ is a subring of $\\Mat(n,F)$. \\emph{But}, identities are \\emph{not} equal, i.e. $\\mathbb{I}_m \\neq \\mathbb{I}_n$.\n\n\\end{example}\n\n% Test for a Subring.\n\\begin{proposition}{3.4.26}{Test for a Subring}\n\n    Let $R'$ be a subset of ring $R$. Then $R'$ is a subring of $R$ if and only if:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $R'$ has a multiplicative identity;\n            \\item $a,b \\in R' \\Rightarrow a - b \\in R'$; and\n            \\item $R'$ is closed under multiplication.\n        \\end{enumerate}\n\n\\end{proposition}\n\n% Sending Units to Units.\n\\begin{proposition}{3.4.29}{}\n\n    Let $f: R \\to S$ be a ring homomorphism and assume $f(1_R)=1_S$. Then $x \\in R^{\\times} \\Rightarrow f(x) \\in S^{\\times}$ and $(f(x))^{-1} = f(x^{-1})$.\n\n    \\Hint $f(x)f(x^{-1}) = f(xx^{-1}) = f(1_R)$.\n\n\\end{proposition}\n\n% Factor Rings inherit Commutativity.\n\\begin{exercise}{52}{}\n\n    Let $R$ be a ring and $I \\unlhd R$. If $R$ is commutative, so is $R/I$.\n\n\\end{exercise}\n\n% Requirement for Non-Trivial Factor Ring.\n\\begin{exercise}{53}{}\n\n    Let $R$ be a ring and $I \\unlhd R$. $R/I$ is a non-zero ring if and only if $I \\neq R$.\n\n\\end{exercise}\n\n% Factor Rings inherit Units.\n\\begin{exercise}{54}{}\n\n    Let $R$ be a ring and $I$ be a \\emph{proper} ideal of $R$. If $r \\in R^{\\times}$, then $r + I \\in (R/I)^{\\times}$ with $(r + I)^{-1} = r^{-1} + I$.\n\n\\end{exercise}\n\n\\begin{theorem}{3.6.7}{The Universal Property of Factor Rings}\n\n    Let $R$ be a ring and $I \\unlhd R$.\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $\\mathrm{can}: R \\to R/I; r \\mapsto r + I$ is a surjective ring homomorphism with kernel $I$.%, i.e. $\\mathrm{can}^{-1}(0) = I$.\n            \\item If $f: R \\to S$ is a ring homomorphism with $f(I) = \\{0_S\\}$, so that $I \\subseteq \\ker{f}$, then there exists a unique ring homomorphism $\\overline{f}: R/I \\to S$ such that $f = \\overline{f} \\circ \\mathrm{can}$.\n        \\end{enumerate}\n\n    \\Hint $f(x + I) = f(x) + f(I) = \\{f(x)\\}$, so $\\overline{f}(x + I) = f(x)$ only possible map.% s.t. $f = \\overline{f} \\circ \\mathrm{can}$.\n\n\\end{theorem}\n\n% First Isomorphism Theorem for Rings.\n\\begin{theorem}{3.6.9}{First Isomorphism Theorem for Rings}\n\n    Let $R,S$ be rings, then every homomorphism $f: R \\to S$ induces an isomorphism:\n\n        \\begin{align*}\n            \\overline{f}: R/\\ker{f} \\xrightarrow{\\sim} \\im{f}.\n        \\end{align*}\n\n    \\Hint $\\overline{f}$ from Universal Property, $\\ker{\\overline{f}} = \\{0 + \\ker{f}\\}$ and Lemma 3.4.20.\n\n\\end{theorem}\n\n% Z-Modules are Exactly Abelian Groups.\n\\begin{example}{3.7.4}{}\n\n    A $\\mathbb{Z}$-module is exactly the same as abelian group.\n\n\\end{example}\n\n% Ideals are Modules.\n\\begin{example}{3.7.6}{}\n\n    Let $I \\unlhd R$, then $I$ is an $R$-module.\n\n\\end{example}\n\n% Construction of Modules.\n\\begin{example}{3.7.7}{}\n\n    Let $R$ be a ring, $M_1,\\hdots,M_n$ be $R$-modules, then $M_1 \\times M_2 \\times \\hdots \\times M_n$ is an $R$-module with addition and scalar multiplication defined componentwise.\n\n\\end{example}\n\n% No Zero-Conclusion in Modules.\n\\begin{example}{3.7.9}{}\n\n    Let $R = \\Mat(2;\\mathbb{C})$ and $M = \\mathbb{C}^2$. Then $\\bigl( \\begin{smallmatrix}0 & 1\\\\ 0 & 0\\end{smallmatrix}\\bigr) \\bigl( \\begin{smallmatrix}1 \\\\ 0\\end{smallmatrix}\\bigr) = \\bigl( \\begin{smallmatrix}0 \\\\ 0\\end{smallmatrix}\\bigr)$, so $\\lambda \\vec{v} = 0 \\centernot\\Rightarrow \\lambda = 0$ or $\\vec{v} = \\vec{0}$.\n\n\\end{example}\n\n% Test for a Submodule.\n\\begin{proposition}{3.7.20}{Test for a Submodule}\n\n    Let $R$ be a ring and let $M$ be an $R$-module. Let $M'$ be a subset of $M$, then $M'$ is a submodule if and only if:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $0_M \\in M'$;\n            \\item $a,b \\in M' \\Rightarrow a-b \\in M'$;\n            \\item $r \\in R, a \\in M' \\Rightarrow ra \\in M'$.\n        \\end{enumerate}\n\n\\end{proposition}\n\n% Kernel and Images are Submodules.\n\\begin{lemma}{3.7.21}{}\n\n    Let $f: M \\to N$ be an $R$-homomorphism. Then $\\ker{f}$ is a submodule of $M$ and $\\im{f}$ is a submodule of $N$.\n\n\\end{lemma}\n\n% Generated Submodule is Smallest Module Containing the Set.\n\\begin{lemma}{3.7.28}{}\n\n    Let $T \\subseteq M$. Then $\\tensor[_R]{\\langle T \\rangle}{}$ is the smalles submodule of $M$ containing $T$.\n\n\\end{lemma}\n\n% Arbitrary Submodule Intersections are Submodules\n\\begin{lemma}{3.7.29}{}\n\n    The intersection of \\emph{any} collection of submodules of $M$ is a submodule of $M$.\n\n\\end{lemma}\n\n% Adding Submodules Gives a Submodule.\n\\begin{lemma}{3.7.30}{}\n\n    Let $M_1,M_2$ be a submodule of $M$. Then $M_1 + M_2$ is a submodule of $M$.\n\n\\end{lemma}\n\n% Universal Property of Factor Modules.\n\\begin{theorem}{3.7.32}{The Universal Property of Factor Modules}\n\n    Let $R$ be a ring, $L,M$ $R$-modules and $N$ a submodule of $M$.\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $\\mathrm{can}: M \\to M/N; a \\mapsto a + N$ is a surjective $R$-homomorphism with kernel $N$.%, i.e. $\\mathrm{can}^{-1}(0) = I$.\n            \\item If $f: M \\to L$ is an $R$-homomorphism with $f(N) = \\{0_L\\}$, so that $N \\subseteq \\ker{f}$, then there exists a unique homomorphism $\\overline{f}: M/N \\to L$ such that $f = \\overline{f} \\circ \\mathrm{can}$.\n        \\end{enumerate}\n\n\\end{theorem}\n\n% First Isomorphism Theorem for Modules.\n\\begin{theorem}{3.6.9}{First Isomorphism Theorem for Modules}\n\n    Let $R$ be a ring, $M,N$ be $R$-modules, then every $R$-homomorphism $f: M \\to N$ induces an $R$-isomorphism:\n\n        \\begin{align*}\n            \\overline{f}: M/\\ker{f} \\xrightarrow{\\sim} \\im{f}.\n        \\end{align*}\n\n    \\Hint $\\overline{f}$ from Universal Property, $\\ker{\\overline{f}} = \\{0 + \\ker{f}\\}$ for injectivity.\n\n\\end{theorem}\n\n% Second Isomorphism Theorem for Modules.\n\\begin{exercise}{59}{Second Isomorphism Theorem for Modules}\n\n    Let $N,K$ be submodules of $R$-module $M$. Then $K$ is submodule of $N + K$, $N \\cap K$ is a submodule of $N$ and\n\n        \\begin{align*}\n            \\frac{N+K}{K} \\cong \\frac{N}{N \\cap K}.\n        \\end{align*}\n\n\\end{exercise}\n\n% Third Isomorphism Theorem for Modules.\n\\begin{exercise}{60}{Third Isomorphism Theorem for Modules}\n\n    Let $N,K$ be submodules of $R$-module $M$, s.t. $K \\subseteq N$. Then $N/K$ is a submodule of $M/K$ and\n\n        \\begin{align*}\n            \\frac{M/K}{N/K} \\cong M/N.\n        \\end{align*}\n\n\\end{exercise}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Determinants and Eigenvalues Redux %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Determinants and Eigenvalues Redux}\n\n% Length of Identity and Transpositions.\n\\begin{example}{4.1.4}{}\n\n    The identity of $\\mathfrak{S}_n$ has length $0$. A transposition swapping $i$ and $j$ has length $2|i - j| - 1$.\n\n\\end{example}\n\n% Sign of Product is Product of Sign.\n\\begin{lemma}{4.1.5}{Multiplicativity of Sign}\n\n    For each $n \\in \\mathbb{N}$, sign of permutation $\\sgn: \\mathfrak{S}_n \\to \\{\\pm 1\\}$ produces group homomorphism, i.e. $\\forall \\sigma, \\tau \\in \\mathfrak{S}_n: \\sgn(\\sigma \\tau) = \\sgn(\\sigma)\\sgn(\\tau)$.\n\n\\end{lemma}\n\n% Cost of Moving Element to Front.\n\\begin{exercise}{61}{}\n\n    Let $\\sigma \\in \\mathfrak{S}_n$ be permutation s.t. it moves $i$ to the first place and leaves rest unchanged. Then $\\sigma$ has $i-1$ inversions and $\\sgn(\\sigma) = (-1)^{i-1}$.\n\n\\end{exercise}\n\n% Decomposing Permutations into Transpositions.\n\\begin{exercise}{62}{}\n\n    Every permutation in $\\mathfrak{S}_n$ can be written as product of transpositions of neighbouring numbers, i.e. permutations of form $(i\\ i+1)$.\n\n\\end{exercise}\n\n% Leibniz Formula.\n\\begin{definition}{4.2.1}{}\n\n    Let $A \\in \\Mat(n;R)$, where $R$ is a ring. Then\n\n        \\begin{align*}\n            \\det{A} = \\sum_{\\sigma \\in \\mathfrak{S}_n} \\sgn\\!{(\\sigma)}a_{1\\sigma(a)}\\hdots a_{n\\sigma{n}}\n        \\end{align*}\n\n    In degenerate case $n=0$, ``empty matrix\" is assigned determinant of $1$.\n\n\\end{definition}\n\n% Determinant of Upper Triangular Matrix.\n\\begin{example}{4.2.4}{}\n\n    The determinant of an upper triangular matrix is the product of the entries along the main diagonal.\n\n\\end{example}\n\n%% Determinant of Block-Upper Triangular Matrix.\n%\\begin{exercise}{63}{}\n%\n%    Let $A$ be block-upper triangular matrix s.t. $A_1,\\hdots,A_t$ are the matrices along the diagonal. Then $\\det{A} = \\det(A_1)\\hdots\\det(A_t)$.\n%\n%\\end{exercise}\n\n% Determinant of Block-Upper Triangular Matrix.\n\\begin{exercise}{63}{}\n\n    Let $\\mathbb{A}$ be a block-upper triangular matrix with diagonal entries $\\mathbb{A}_{ii} = A_i$, for $A_i \\in \\Mat(n;R)$. Then $\\det{\\mathbb{A}} = \\det{(A_1)}\\det{(A_2)}\\hdots\\det{(A_n)}$.\n\n\\end{exercise}\n\n\\begin{remark}{(unknown)}{}\n\n    $|\\det(L)|$ describes how much linear mapping $L$ changes areas. If sign of $\\det(L)$ is positive, then $L$ preserves orientation, if negative, then $L$ reverses orientation.\n\n\\end{remark}\n\n% Alternative Form of Alternating Bilinear Form Axiom.\n\\begin{remark}{4.3.2}{}\n\n    If $H: U \\times U \\to W$, $U,W$ being $F$-vector spaces, is an \\emph{alternating} bilinear form, then $\\forall a,b \\in U: H(a,b) = -H(b,a)$. If $1_F + 1_F \\neq 0_F$, then $\\forall a,b \\in U: H(a,b) = -H(b,a)$ implies $H$ is alternating. N.B.: this does \\emph{not} hold in $F=\\mathbb{F}_2$!\n\n\\end{remark}\n\n% Alternative Form of Alternating Multilinear Form Axiom.\n\\begin{remark}{4.3.5}{}\n\n    If $H: V \\times V \\times \\hdots \\times V \\to W$, $V,W$ being $F$-vector spaces, is an \\emph{alternating} bilinear form, then\n\n        \\begin{align*}\n            H(\\vec{v}_1,\\hdots,\\vec{v}_i,\\hdots,\\vec{v}_j,\\hdots,\\vec{v}_n) = \\\\\n            -H(\\vec{v}_1,\\hdots,\\vec{v}_j,\\hdots,\\vec{v}_i,\\hdots,\\vec{v}_n)\n        \\end{align*}\n\n    More generally, for $\\sigma \\in \\mathfrak{S}_n$:\n\n        \\begin{align*}\n            H(\\vec{v}_{\\sigma(1)},\\hdots,\\vec{v}_{\\sigma(n)}) = \\sgn(\\sigma)H(\\vec{v}_1,\\hdots,\\vec{v}_n)\n        \\end{align*}\n\n    Converse is true provided $1_F + 1_F \\neq 0_F$.\n\n\\end{remark}\n\n% Characterisation of the Determinant\n\\begin{theorem}{4.3.6}{Characterisation of the Determinant}\n\n    Let $F$ be a \\emph{field}. The mapping $\\det: \\Mat(n;F) \\to F$ is the unique alternating multilinear form on $n$-tuples of column vectors with values in $F$ s.t. $\\det{\\mathbb{I}_n} = 1_F$.\n\n\\end{theorem}\n\n% Multilinear Forms Reduce to Identity and Determinant.\n\\begin{exercise}{64}{}\n\n    Let $d: \\Mat(n;F) \\to F$ be an \\emph{alternating} multilinear form on $n$-tuples of column vectors in $F^n$, then $\\forall A \\in \\Mat(n;F): d(A) = d(e_1|\\hdots|e_n)\\det{(A)}$.\n\n\\end{exercise}\n\n% Determinant of Product is Product of Determinant\n\\begin{theorem}{4.4.1}{Multiplicativity of the Determinant}\n\n    Let $R$ be a commutative ring, $A,B \\in \\Mat(n;R)$. Then $\\det\\!{(AB)} = (\\det{A})(\\det{B})$.\n\n    %\\Hint TODO\n\n\\end{theorem}\n\n% Matrix Invertible If and Only If Determinant Non-Zero.\n\\begin{theorem}{4.4.2}{Determinantal Criterion for Invertibility}\n\n    Let $F$ be a field, $A \\in \\Mat(n;F)$. Then $\\det{A} \\neq 0 \\Leftrightarrow A$ invertible.\n\n    \\Hint $(\\Leftarrow)\\ B = A^{-1},\\ \\det{(AB)} = 1$ by multiplicativity, $(\\Rightarrow)$ A not invertible, then dependent column(s), then alternating form $0$.\n\n\\end{theorem}\n\n% Consequences of Intertibility Criterion.\n\\begin{remark}{4.4.3}{}\n\n    From Theorem 4.4.2 follows that $\\det{A^{-1}} = (\\det{A})^{-1}$ and $\\det{(A^{-1}BA)} = \\det{B}$. Latter asserts that there exists unique determinant for an endomorphism.\n\n\\end{remark}\n\n\\begin{theorem}{4.4.7}{Laplace's Expansion of the Determinant}\n\n    Let $A = (a_{ij})$ with entries in commutative ring $R$. For fixed $i$, $i$-th row expansion is\n\n        \\begin{align*}\n            \\det{A} = \\sum_{j=0}^n a_{ij} C_{ij}\n        \\end{align*}\n\n    and for fixed $j$, $j$-th column expansion is\n\n        \\begin{align*}\n            \\det{A} = \\sum_{i=0}^n a_{ij} C_{ij}\n        \\end{align*}\n\n\\end{theorem}\n\n% Using the Adjoint to Compute the Determinant.\n\\begin{theorem}{4.4.9}{Cramer's Rule}\n\n    Let $A \\in \\Mat(n;R)$, $R$ being a commutative ring. Then $A \\cdot \\mathrm{adj}(A) = (\\det{A}) \\mathbb{I}_n$.\n\n\\end{theorem}\n\n% Invertibility Equivalent to Determinant Being a Unit.\n\\begin{corollary}{4.4.11}{Invertibility of Matrices}\n\n    Let $A \\in \\Mat(n;R)$, $R$ being a commutative ring. Then $A$ invertible $\\Leftrightarrow \\det{A} \\in R^{\\times}$.\n\n\\end{corollary}\n\n% Existence of Eigenvalues for Endomorphisms.\n\\begin{theorem}{4.5.4}{Existence of Eigenvalues}\n\n    Let $f: V \\to V$ be an endomorphism, $V$ a non-zero, finite dimensional vector space over $F$, where $F$ is algebraically closed. Then $f$ has an eigenvalue.\n\n\\end{theorem}\n\n% Cannot Make Existence of Eigenvalues Any More General.\n\\begin{remark}{4.5.5}{}\n\n    Requirements in Theorem 4.5.4 are as tight as possible: consider infinite dimensional vector space $\\mathbb{C}[X]$ with $f: P \\mapsto X \\cdot P$ and non-algebraically closed $\\mathbb{R}^2$ with rotation by $90$ degrees.\n\n\\end{remark}\n\n% Roots of Characteristic Polynomial are Eigenvalues.\n\\begin{theorem}{4.5.8}{Eigenvalues and Characteristic Polynomials}\n\n    Let $A \\in \\Mat(n;F)$, $F$ being a field. The eigenvalues of $A: F^n \\to F^n$ are the roots of $\\chi_A$.\n\n    \\Hint $\\lambda$ eigenvalue of $A$ $\\Leftrightarrow$ $\\exists \\vec{v} \\neq 0$ s.t. $A\\vec{v} = \\lambda \\vec{v}$ $\\Leftrightarrow$ $\\ker(A - \\lambda \\mathbb{I}_n) \\neq \\{\\vec{0}\\}$ $\\Leftrightarrow$ $\\det(A - \\lambda \\mathbb{I}_n)$.\n\n\\end{theorem}\n\n% Coefficients in Characteristic Polynomial.\n\\begin{exercise}{67}{}\n\n    Let $A \\in \\Mat(n;F)$, $F$ being a field. Then $\\chi_A(x) = (-x)^n + \\mathrm{tr}(A)(-x)^{n-1} + \\hdots + \\det{(A)}$.\n\n\\end{exercise}\n\n% Conjugate Matrices Have Equal Characteristic Polynomial.\n\\begin{remark}{4.5.9}{}\n\n    \\begin{enumerate}\n        \\setlength{\\parskip}{0em}\n        \\item [(2)] Let $A,B \\in \\Mat(n;R)$ be representing matrices of $f: V \\to V$ with respect to different bases. Then $A$ and $B$ are conjugate.\n        \\item [(3)] Let $A,B \\in \\Mat(n;R)$, $R$ being a commutative ring, be \\emph{conjugate}. Then $\\chi_A = \\chi_B$.\n        \\item [(4)] Let $f: V \\to V$, $V$ being an $n$-dimensional vector space over field $F$ and let $A$ be the representing matrix for $f$ with respect to \\emph{any} basis. Then $\\chi_f = \\chi_A$.\n    \\end{enumerate}\n\n\\end{remark}\n\n% Conjugacy is Equivalent to Existing Endomorphism.\n\\begin{exercise}{68}{}\n\n    Let $A,B \\in \\Mat(n;F)$, $F$ begin a field. Then $A$ and $B$ are conjugate $\\Leftrightarrow \\exists f: V \\to V$ s.t. $A$ and $B$ are representing matrices of $f$.\n\n\\end{exercise}\n\n% Triangularisability Equivalent To Linear Factor Decomposition of Characteristic Polynomial\n\\begin{proposition}{4.6.1}{Triangularisability}\n\n    Let $f: V \\to V$, $V$ being a finite dimensional $F$-vector space. Then the following is equivalent:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $f$ is \\emph{triangularisable}.\n            \\item $\\chi_f$ decomposes into linear factors in $F[X]$.\n        \\end{enumerate}\n\n\\end{proposition}\n\n% Equivalent Statements to Triangularisability.\n\\begin{remark}{4.6.2}{}\n\n    \\begin{enumerate}\n        \\setlength{\\parskip}{0em}\n        \\item [(1)] Endomorphism $A: F^n \\to F^n$ is triangularisable $\\Leftrightarrow$ $A$ is conjugate to an upper triangular matrix.\n        \\item [(3)] Endomorphism $f: F^n \\to F^n$ is triangularisable $\\Leftrightarrow$ there exists sequence of subspaces $\\{ 0 \\} = V_0 \\subset V_1 \\subset V_2 \\subset \\hdots \\subset V_n = V$ s.t. $V_i$ is $i$-dimensional and $f(V_i) \\subseteq V_i$.\n    \\end{enumerate}\n\n\\end{remark}\n\n% Characteristic Polynomial of Nilpotent Matrices.\n\\begin{remark}{4.6.4}{}\n\n    Let $A \\in \\Mat(n;F)$, then $A$ \\emph{nilpotent} $\\Leftrightarrow$ $\\chi_A(x) = (-x)^n$.\n\n\\end{remark}\n\n% Eigenvectors for Different Eigenvalues are Linearly Independent.\n\\begin{lemma}{4.6.8}{Linear Independence of Eigenvectors}\n\n    Let $f: V \\to V$ with eigenvectors $\\vec{v}_1,\\hdots,\\vec{v}_n$ with pairwise different eigenvalues $\\lambda_1,\\hdots,\\lambda_n$. Then $\\vec{v}_1,\\hdots,\\vec{v}_n$ are linearly independent.\n\n    \\Hint Consider $(f-\\lambda_2 \\id_V) \\circ \\hdots \\circ (f - \\lambda_n \\id_V)(\\vec{v}_j) = $ $\\prod_{i=2}^n (\\lambda_i - \\lambda_j)\\vec{v}_i$, $0$ if $i \\neq 1$ and $\\prod_{i=2}^n (\\lambda_1 - \\lambda_j)\\vec{v}_1$ if $i = 1$. Apply to $\\sum_{i=1}^n \\alpha_i \\vec{v}_i = \\vec{0}$ $\\Rightarrow$ $\\alpha_1 \\prod_{i=2}^n (\\lambda_1 - \\lambda_j)\\vec{v}_1 = \\vec{0}$ $\\Rightarrow$ $\\alpha_1 = 0$. Repeat for rest.\n\n\\end{lemma}\n\n% Characteristic Polynomial of Nilpotent Matrices.\n\\begin{remark}{4.6.3}{}\n\n    Let $A \\in \\Mat(n;F)$, then $A$ nilpotent $\\Leftrightarrow \\chi_A(x) = (-x)^n$.\n\n\\end{remark}\n\n% Matrix is Root of Its Characteristic Polynomial.\n\\begin{theorem}{4.6.9}{The Cayley-Hamilton Theorem}\n\n    Let $A \\in \\Mat(n;R)$, with \\emph{commutative ring} R. Then $\\chi_A(A) = 0$, the zero matrix.\n\n    \\Hint $B = A - x\\mathbb{I} \\in \\Mat(n,R[x])$, Cramer's Rule $\\Rightarrow$ $B \\cdot \\mathrm{adj}(B) =$ $\\det(B)\\mathbb{I} =$ $\\chi_A(x) \\mathbb{I}$, $\\mathrm{adj}(B) \\in \\Mat(n,R[x])$. Equally $\\mathrm{adj}(B) \\in \\Mat(n,R)[x]$ $\\Rightarrow$ $\\mathrm{adj}(B) = \\sum_{i \\geq 0} x^i K_i$. Substitute s.t. $\\chi_A(x) \\mathbb{I} = AK_0 + \\sum_{i \\geq 1} x^i (AK_i - K_{i-1})$. Evaluate at $A$ and cancel s.t. $\\chi_A(x) \\mathbb{I} = A^{n+1}C_n$. Degree of cofactors of $\\mathrm{adj}(B)$ at most $n-1$, so $C_n = 0$.\n\n\\end{theorem}\n\n% Stochastic Matrices Have Eigenvalue 1.\n\\begin{lemma}{4.7.6}{}\n\n    Let $M \\in \\Mat(n;\\mathbb{R})$ be a Markov matrix. Then $\\lambda = 1$ is an eigenvalue of $M$.\n\n    \\Hint Columns of $M - \\mathbb{I}_n$ sum to $0 \\Rightarrow$ sum of row vectors is $\\vec{0} \\Rightarrow$ linear dependence $\\Rightarrow \\det{(M - \\mathbb{I}_n)} = 0 \\Rightarrow \\chi_M(1) = 0$.\n\n\\end{lemma}\n\n% Stochastic Matrices with Positive Entries Have Special Eigenspace for 1.\n\\begin{theorem}{4.7.10}{Perron, 1907}\n\n    Let $M \\in \\Mat(n;\\mathbb{R})$ be a Markov matrix with \\emph{positive} entries, then eigenspace $\\mathrm{E}(1,M)$ is one dimensional. There exists a unique basis vector $\\vec{v} \\in \\mathrm{E}(1,M)$ whose entries are positive and sum to 1.\n\n\\end{theorem}\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n% Inner Product Spaces %\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Inner Product Spaces}\n\n% Standard Inner Product for C^n.\n\\begin{example}{5.1.4}{}\n\n    Let $\\vec{v},\\vec{w} \\mathbb{C}^n$, then \\emph{standard inner product} is $\\InnerProduct{\\vec{v}}{\\vec{w}} = \\vec{v}^T \\circ \\overline{\\vec{w}}$. N.B.: Conjugate on second.\n\n\\end{example}\n\n\\begin{example}{5.1.6}{}\n\n    Let $\\vec{v}, \\vec{w}$ be orthogonal. Then Pythagoras' Theorem holds: $\\norm{\\vec{v} + \\vec{w}}^2 = \\norm{\\vec{v}}^2 + \\norm{\\vec{w}}^2$.\n\n\\end{example}\n\n% Finite Inner Product Spaces Have Orthonormal Bases.\n\\begin{theorem}{5.1.10}{}\n\n    Every \\emph{finite} dimensional inner product space $V$ has an \\emph{orthonormal} basis.\n\n    \\Hint Induction on $\\dim{V}$. Base Case $\\dim{V} = 0$ trivial. $\\dim{V} = n > 0 \\Rightarrow \\exists \\vec{v} \\in V$, normalize to $\\vec{v}_1$ and consider $\\InnerProduct{-}{\\vec{v}_1}: V \\to \\mathbb{R}; \\vec{w} \\to \\InnerProduct{\\vec{w}}{\\vec{v}_1}$. Kernel of that has dim. $n-1$ by Rank-Nullity.\n\n\\end{theorem}\n\n% Orthogonal Sets are Subspace and Equal to Orthogonal Complement of Generated Subspace.\n\\begin{exercise}{73}{}\n\n    Let $V$ be an inner product space, then $\\forall T \\subseteq V$ $T^{\\perp}$ is a subspace and $T^{\\perp} = \\langle T \\rangle^{\\perp}$.\n\n\\end{exercise}\n\n% Subspace and Orthogonal Complement Partition The Space.\n\\begin{proposition}{5.2.2}{}\n\n    Let $U \\subseteq V$ be finite dimensional subspace of inner product space $V$. Then $U,U^{\\perp}$ are complementary, i.e. $V = U \\oplus U^{\\perp}$.\n\n    \\Hint Exercise 19. $\\vec{v} \\in U \\cap U^T$ $\\Rightarrow$ $\\InnerProduct{\\vec{v}}{\\vec{v}} = 0$ $\\Rightarrow$ $\\vec{v} = \\vec{0}$. Want $\\vec{v} = \\vec{p} + \\vec{r}$ s.t. $\\vec{p} \\in U$, $\\vec{r} \\in U^{\\perp}$. Thrm 5.1.10 $\\Rightarrow$ $U$ has orthonormal basis $\\{\\vec{v}_i$ s.t. $\\vec{p} = \\sum_{i=1}^n \\InnerProduct{\\vec{v}}{\\vec{v}_i} \\vec{v}_i$. Take $\\vec{r} = \\vec{v} - \\vec{p}$ s.t. $\\InnerProduct{\\vec{r}}{\\vec{v}_j} = 0$ $\\Rightarrow$ $\\vec{r} \\in U^{\\perp}$.\n\n\\end{proposition}\n\n% Properties of Orthogonal Projection.\n\\begin{proposition}{5.2.4}{}\n\n    Let $U \\subseteq V$ be finite dimensional subspace of inner product space $V$.\n\n        \\begin{enumerate}[(1)]\n            \\item $\\pi_U$ is a linear mapping with $\\im{(\\pi_u)} = U$, $\\ker{(\\pi_U)} = U^{\\perp}$;\n            \\item if $\\{ \\vec{v}_1, \\hdots, \\vec{v}_n \\}$ \\emph{orthonormal} basis of $U$, then for $\\vec{v} \\in V$: $\\pi_U(\\vec{v}) = \\sum_{i=1}^n \\InnerProduct{\\vec{v}}{\\vec{v}_i} \\vec{v}_i$;\n%            \\item if $\\{ \\vec{v}_1, \\hdots, \\vec{v}_n \\}$ \\emph{orthonormal} basis of $U$, then for $\\vec{v} \\in V$:\n%\n%                \\begin{align*}\n%                    \\pi_U(\\vec{v}) = \\sum_{i=1}^n \\InnerProduct{\\vec{v}}{\\vec{v}_i} \\vec{v}_i\n%                \\end{align*}\n            \\item $\\pi_U^2 = \\pi_U$, i.e. $\\pi_U$ idempotent.\n        \\end{enumerate}\n\n\\end{proposition}\n\n% Cauchy-Schwarz Inequality.\n\\begin{theorem}{5.2.5}{Cauchy-Schwarz Inequality}\n\n    Let $\\vec{v},\\vec{w} \\in V$, inner product space. Then\n\n        \\begin{align*}\n            |\\InnerProduct{\\vec{v}}{\\vec{w}} \\leq \\norm{\\vec{v}} \\norm{\\vec{w}}\n        \\end{align*}\n\n    with \\emph{equality} $\\Leftrightarrow \\vec{v},\\vec{w}$ \\emph{linearly dependent}.\n\n    \\Hint $\\vec{w} = \\vec{0}$ trivially true; $\\vec{w} \\neq 0$, $W = \\langle \\vec{w} \\rangle$, $\\vec{x} = \\vec{v} - \\pi_{W}(\\vec{v})$ $\\Rightarrow$ $\\vec{x} \\perp \\pi_{W}(\\vec{v})$ so Pythagoras holds: $\\norm{\\vec{v}}^2 = \\norm{\\vec{x} + \\pi_{W}(\\vec{v})}^2 =$ $\\norm{\\vec{x}}^2 + \\norm{\\pi_{W}(\\vec{v})}^2$, $\\pi_{W}(\\vec{v})$ from Prop. 5.2.4.\n\n\\end{theorem}\n\n% Properties of Norm of Inner Product Spaces.\n\\begin{corollary}{5.2.6}{}\n\n    Let $\\norm{\\cdot}$ be the norm on inner product space $V$, then $\\forall \\vec{v},\\vec{w} \\in V$:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $\\norm{\\vec{v}} \\geq 0$, equality $\\Leftrightarrow$ $\\vec{v} = 0$;\n            \\item $\\norm{\\lambda \\vec{v}} = |\\lambda|\\norm{\\vec{v}}$;\n            \\item \\emph{Triangle Inequality:} $\\norm{\\vec{v} + \\vec{w}} = \\norm{\\vec{v}} + \\norm{\\vec{w}}$\n        \\end{enumerate}\n\n\\end{corollary}\n\n% Adjoint of Adjoint is Original.\n\\begin{exercise}{75}{}\n\n    Let $T^*$ be adjoint of $T$. Then $(T^*)^*=T$.\n\n\\end{exercise}\n\n% Every Endomorphism Has Unique Adjoint.\n\\begin{theorem}{5.3.4}{}\n\n    Let $T: V \\to V$, $V$ begin a finite dimensional inner product space. Then $T^*$ exists and is \\emph{unique}.\n\n    \\Hint $\\phi \\coloneqq \\InnerProduct{T(-)}{\\vec{w}}: V \\to F$, linear as $\\InnerProduct{-}{\\vec{w}}$, $T$ are. Thrm 5.1.10 $\\Rightarrow$ $\\exists \\{\\vec{e}_i\\}_{1 \\leq i \\leq n}$ orthonormal basis of $V$ $\\Rightarrow$ for $\\vec{v} = \\sum_{i=1}^n \\InnerProduct{\\vec{v}}{\\vec{e}_i}\\vec{e}_i$ $\\Rightarrow$ $\\phi(\\vec{v}) =$ $\\sum_{i=1}^n \\InnerProduct{\\vec{v}}{\\vec{e}_i}\\phi(\\vec{e}_i) =$ $\\InnerProduct{\\vec{v}}{\\sum_{i=1}^n \\overline{\\phi(\\vec{e}_i)} \\vec{e}_i}$ $\\Rightarrow$ $\\exists$ $\\vec{u}$ s.t. $\\phi(\\vec{v}) = \\InnerProduct{\\vec{v}}{\\vec{u}} = \\InnerProduct{\\vec{v}}{T^*(\\vec{w})}$ $\\Rightarrow$ $T^*$ exists. $\\InnerProduct{\\vec{v}}{\\vec{u} - \\vec{u}'} =$ $\\phi(\\vec{v}) - \\phi{\\vec{v}}$ for uniqueness \\& show linearity with uniqueness.\n\n\\end{theorem}\n\n% Self-Adjoint Linear Maps Have Nice Eigenvalues and Eigenvectors.\n\\begin{theorem}{5.3.7}{}\n\n    Let $T: V \\to V$ be a \\emph{self-adjoint} linear mapping on inner product space $V$. Then\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item every eigenvalue of $T$ is real;\n            \\item if $\\lambda,\\mu$ are distinct eigenvalues of $T$, then the corresponding eigenvectors are orthogonal;\n            \\item $T$ has an eigenvalue.\n        \\end{enumerate}\n\n    \\Hint (1) $\\lambda \\InnerProduct{\\vec{v}}{\\vec{v}} =$ $\\InnerProduct{T\\vec{v}}{\\vec{v}} = $ $\\InnerProduct{\\vec{v}}{T\\vec{v}} = $ $\\overline{\\lambda}\\InnerProduct{\\vec{v}}{\\vec{v}}$. (2) $\\lambda \\InnerProduct{\\vec{v}}{\\vec{w}} =$ $\\InnerProduct{T\\vec{v}}{\\vec{w}} = $ $\\InnerProduct{\\vec{v}}{T\\vec{w}} = $ $\\mu\\InnerProduct{\\vec{v}}{\\vec{w}}$. (3) Over $\\mathbb{R}$. $R(\\vec{v}) = \\frac{\\InnerProduct{T\\vec{v}}{\\vec{v}}}{\\InnerProduct{\\vec{v}}{\\vec{v}}}$ restricted to unit sphere, Heine-Borel Thrm $\\Rightarrow$ maximum at $\\vec{v}_+$ in unit sphere \\& $R(\\lambda \\vec{v}) = R(\\vec{v})$ $\\Rightarrow$ $\\vec{v}_+$ is max. overall. $R_{\\vec{w}}(t) = R(\\vec{v}_+ + t\\vec{w})$ is well-defined and\n\n        \\begin{align*}\n            R_{\\vec{w}}'(0) = \\frac{\\InnerProduct{T\\vec{w}}{\\vec{v}_+} + \\InnerProduct{T\\vec{v}_+}{\\vec{w}}}{\\InnerProduct{\\vec{v}_+}{\\vec{v}_+}} - \\\\ \\frac{2 \\InnerProduct{T\\vec{v}_+}{\\vec{v}_+} \\InnerProduct{\\vec{v}_+}{\\vec{w}}}{\\InnerProduct{\\vec{v}_+}{\\vec{v}_+}^2}.\n        \\end{align*}\n\n    Use $\\vec{w}^{\\perp} \\in V$ s.t. $\\vec{v}_+ \\perp \\vec{w}^{\\perp}$ $\\Rightarrow$ $R_{\\vec{w}^{\\perp}}'(0) = \\frac{\\InnerProduct{T\\vec{w}^{\\perp}}{\\vec{v}_+} + \\InnerProduct{T\\vec{v}_+}{\\vec{w}^{\\perp}}}{\\InnerProduct{\\vec{v}_+}{\\vec{v}_+}} = 0$ $\\Rightarrow$ $\\InnerProduct{T\\vec{w}^{\\perp}}{\\vec{v}_+} = - \\InnerProduct{T\\vec{v}_+}{\\vec{w}^{\\perp}}$ $\\Rightarrow$ $\\vec{w}^{\\perp} \\perp T\\vec{v}_+$ $\\Rightarrow$ $T\\vec{v}_+ \\in ( \\langle \\vec{v}_+ \\rangle^{\\perp} )^{\\perp} = \\langle \\vec{v}_+ \\rangle$ $\\Rightarrow$ $\\exists \\lambda \\in \\mathbb{R}: T\\vec{v}_+ = \\lambda \\vec{v}_+$.\n\n\\end{theorem}\n\n% Self-Adjoint Mappings Produce Orthonormal Bases.\n\\begin{theorem}{5.3.9}{The Spectral Theorem for Self-Adjoint Endomorphisms}\n\n    Let $T: V \\to V$ be a \\emph{self-adjoint} linear map, $V$ being a finite dimensional inner product space. Then $V$ has an orthonormal basis consisting of eigenvectors of $T$.\n\n    \\Hint Induction on $\\dim{V}$. $\\dim{V} = 1$ holds by Thrm 5.3.7. For $\\dim{V} = n > 1$ take any eigenvalue $\\lambda$ of $T$, exists by Thrm 5.3.7, and \\emph{normalized} eigenvector $\\vec{u}$. $U = \\langle \\vec{u} \\rangle$, $\\vec{v} \\in U^{\\perp}$. $\\InnerProduct{\\vec{u}}{T\\vec{v}} =$ $\\lambda \\InnerProduct{\\vec{u}}{\\vec{v}} = 0$ $\\Rightarrow$ $T(U^{\\perp}) \\subseteq U^{\\perp}$, so $\\left.T\\right|_{U^{\\perp}}: U^{\\perp} \\to U^{\\perp}$ self-adjoint, induction hypothesis $\\Rightarrow$ $\\exists$ orthonormal basis $B$ $\\Rightarrow$ $B \\cup \\{\\vec{u}\\}$ orthonormal basis $V$.\n\n\\end{theorem}\n\n% Orthonormal Matrices Form Orthonormal Bases.\n\\begin{exercise}{76}{}\n\n    Let $P \\in \\Mat(n;\\mathbb{R})$, then $P^T P = \\mathbb{I}_n$ $\\Leftrightarrow$ columns of $P$ form orthonormal basis for $\\mathbb{R}^n$.\n\n\\end{exercise}\n\n% Real Symmetric Matrices Are Diagonalisable.\n\\begin{corollary}{5.3.12}{The Spectral Theorem for Real Symmetric Matrices}\n\n    Let $A \\in \\Mat(n,\\mathbb{R})$ be \\emph{symmetric}. Then there exists $P \\in \\Mat(n,\\mathbb{R})$ \\emph{orthogonal} s.t.\n\n        \\begin{align*}\n            P^TAP = P^{-1}AP = \\mathrm{diag}(\\lambda_1,\\hdots,\\lambda_n)\n        \\end{align*}\n\n    where $\\lambda_1,\\hdots,\\lambda_n \\in \\mathrm{R}$ are eigenvalues of $A$, repeated accordingly.\n\n    \\Hint Spectral Theorem \\& Exercise 76.\n\n\\end{corollary}\n\n% Unitary Matrices Form Orthonormal Bases.\n\\begin{exercise}{78}{}\n\n    Let $P \\in \\Mat(n;\\mathbb{C})$, then $\\overline{P}^T P = \\mathbb{I}_n$ $\\Leftrightarrow$ columns of $P$ form orthonormal basis for $\\mathbb{C}^n$.\n\n\\end{exercise}\n\n% Real Symmetric Matrices Are Diagonalisable.\n\\begin{corollary}{5.3.15}{The Spectral Theorem for Hermitian Matrices}\n\n    Let $A \\in \\Mat(n,\\mathbb{C})$ be \\emph{hermitian}. Then there exists $P \\in \\Mat(n,\\mathbb{C})$ \\emph{unitary} s.t.\n\n        \\begin{align*}\n            P^TAP = P^{-1}AP = \\mathrm{diag}(\\lambda_1,\\hdots,\\lambda_n)\n        \\end{align*}\n\n    where $\\lambda_1,\\hdots,\\lambda_n \\in \\mathrm{R}$ are eigenvalues of $A$, repeated accordingly.\n\n\\end{corollary}\n\n% Automatic Self-Adjoint Endomorphism.\n\\begin{exercise}{Hw.6, Ex.3}{}\n\n    Let $T: V \\to V$ be an endomorphism of a finite-dimensional inner product space. Let $T^*$ be the adjoint of $T$. Then\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $T^*T$ is self-adjoint; and\n            \\item if $T^*T=0$, then $T=0$.\n        \\end{enumerate}\n\n\\end{exercise}\n\n% Determinants of Special Matrices.\n\\begin{exercise}{Hw.6, Ex.4}{}\n\n    \\begin{enumerate}[(1)]\n        \\item Let $A \\in \\Mat(n;\\mathbb{R})$ be an orthogonal matrix. Then $\\det{A} \\in \\{\\pm 1\\}$.\n        \\item Let $A \\in \\Mat(n;\\mathbb{C})$ be a unitary matrix. Then $\\det{A}$ lies on the unit circle in $\\mathbb{C}$.\n    \\end{enumerate}\n\n    \\Hint Spectral Theorem \\& Exercise 78.\n\n\\end{exercise}\n\n%%%%%%%%%%%%%%%%%\n% Miscellaneous %\n%%%%%%%%%%%%%%%%%\n\n\\section{Miscellaneous}\n\n% Result about Equivalence Classes.\n\\begin{remark}{(unknown)}{}\n    Let $\\sim$ be an equivalence relation on $X$, $x,y \\in X$ and $E(x), E(y)$ equivalence classes for $x,y$ respectively. The following are equivalent:\n\n    \\begin{enumerate}[(1)]\n        \\setlength{\\parskip}{0em}\n        \\item $x \\sim y$;\n        \\item $E(x) = E(y)$;\n        \\item $E(x) \\cap E(y) \\neq \\emptyset$.\n    \\end{enumerate}\n\\end{remark}\n\n% Transpose of the Sum is the Sum of the Transposes:\n\\begin{proposition}{(unknown)}{}\n\n    $A,B$ matrices, then $(A + B)^T = A^T + B^T$.\n\n\\end{proposition}\n\n% Determinant of Conjugate Transpose is Conjugate Transpose of Determinant.\n\\begin{proposition}{(unknown)}{}\n\n    $A \\in \\Mat(n;\\mathbb{C})$, then $\\det(\\overline{A}^T) = \\overline{\\det(A)}$.\n\n\\end{proposition}\n\n% Lagrange's Theorem.\n\\begin{theorem}{(Lagrange's Theorem)}{}\n\n    Let $G$ be a finite group and $H$ a subgroup, then $|H|$ divides $|G|$.\n\n\\end{theorem}\n\n%%%%%%%%%%%%%%%\n% Definitions %\n%%%%%%%%%%%%%%%\n\n% N.B.: Definitions are at the very and as they will likely be the thing\n% accessed the least.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Vector Spaces Definitions %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Definitions}\n\n% Vector Subspace Addition.\n\\begin{definition}{(unknown)}{}\n\n    Let $U,W$ be subspace of $V$, then $U + W \\coloneqq \\langle U \\cup W \\rangle$, i.e. subspace generated by $U$ and $W$ together.\n\n\\end{definition}\n\n% Direct Sum of Vector Spaces.\n\\begin{definition}{1.7.6}{}\n\n    Two vector spaces $V_1$ and $V_2$ are \\emph{complementary} if addition defines a bijection $V_1 \\times V_2 \\xrightarrow{\\sim} V$. This produces a bijection $V_1 \\oplus V_2 \\xrightarrow{\\sim} V$, we say $V = V_1 \\oplus V_2$ is the \\emph{(internal) direct sum} of $V_1, V_2$.\n\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Linear Mappings and Matrices Definitions %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Elementary Matrices.\n\\begin{definition}{2.2.2}{}\n\n    An \\emph{elementary matrix} is a matrix which differs from the identity in at most one entry.\n\n\\end{definition}\n\n% Smith Normal Form.\n\\begin{definition}{2.2.4}{}\n\n    A matrix with only $0$'s except possibly along the diagonal, where first only $1$'s then $0$'s, is in \\emph{Smith Normal Form}.\n\n\\end{definition}\n\n% Column And Row Rank.\n\\begin{definition}{2.2.6}{}\n\n    \\emph{Column/Row} rank of a matrix is dimension of subspace spanned by columns/rows of said matrix.\n\n\\end{definition}\n\n% Rank of a Matrix.\n\\begin{definition}{2.2.8}{}\n\n    \\emph{Rank of a matrix} $A$, $\\mathrm{rk}A$, is column/row rank. If rank of a matrix is equal to number of rows/columns, then matrix has \\emph{full rank}.\n\n\\end{definition}\n\n% Nilpotent\n\\begin{definition}{32}{}\n\n    Endomorphism $f: V \\to V$ is \\emph{nilpotent} if there exists $d \\in \\mathbb{N}$ s.t. $f^d = 0$.\n\n\\end{definition}\n\n% Trace of a Matrix.\n\\begin{definition}{2.4.6}{}\n\n    The \\emph{trace} of a matrix $A$, $\\mathrm{tr}(A)$, is the \\emph{sum} of the diagonal entries.\n\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Rings and Modules Definitions %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Field.\n\\begin{definition}{3.1.8}{}\n\n    A \\emph{field} is a non-zero, commutative ring $F$ in which every non-zero element $a \\in F$ has an inverse $a^{-1} \\in F$.\n\n\\end{definition}\n\n% Division Ring.\n\\begin{definition}{3.1.9}{}\n\n    A \\emph{skewfield} or \\emph{division ring} is a non-zero ring $F$ in which every non-zero element $a \\in F$ has an inverse $a^{-1} \\in F$. N.B.: does \\emph{not} have to be commutative.\n\n\\end{definition}\n\n% Unit.\n\\begin{definition}{3.2.6}{}\n    Let $R$ be a ring. Element $a \\in R$ is a \\emph{unit} if $a^{-1} \\in R$, i.e. $a$ is \\emph{invertible}.\n\\end{definition}\n\n% Zero-Divisor.\n\\begin{definition}{3.2.12}{}\n    Let $R$ be a ring. Element $a \\in R$ is a \\emph{zero-divisor} if $a \\neq 0$ and $\\exists \\, b \\in R$ s.t. $b \\neq 0$ and either $ab = 0$ or $ba = 0$.\n\\end{definition}\n\n% Integral Domain.\n\\begin{definition}{3.2.13}{}\n    An \\emph{integral domain} is a \\emph{non-zero, commutative} ring with \\emph{no zero-divisors}.\n\\end{definition}\n\n% Algebraically Closed.\n\\begin{definition}{3.3.11}{}\n\n    A field $F$ is algebraically closed if each non-constant polynomial with coefficients in $F$ has a root in $F$.\n\n\\end{definition}\n\n% Ideal of a Ring.\n\\begin{definition}{3.4.7}{}\n\n    Let $R$ be a ring and $I \\subseteq R$. Then $I$ is an \\emph{ideal} of $R$, $I \\unlhd R$, if:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n            \\item $I \\neq \\emptyset$;\n            \\item $a,b \\in I \\Rightarrow a - b \\in I$;\n            \\item $\\forall i \\in I, r \\in R: ri, ir \\in I$.\n        \\end{enumerate}\n\n    E.g. $m\\mathbb{Z} \\unlhd \\mathbb{Z}$, $R \\unlhd R$, $\\{0\\} \\unlhd R$.\n\n\\end{definition}\n\n% Generated Ideal.\n\\begin{definition}{3.4.11}{}\n\n    Let $R$ be a commutative ring, $T \\subset R$. Then the \\emph{ideal of $R$ generated by $T$} is the set:\n\n        \\begin{align*}\n            \\tensor[_R]{\\langle T \\rangle}{} = \\{r_1t_1 + \\hdots + r_mt_m : t_i \\in T, r_i \\in R\\}\n        \\end{align*}\n\n    including $0_R$ in case $T = \\emptyset$.\n\n\\end{definition}\n\n% Principal Ideal.\n\\begin{definition}{3.4.15}{}\n\n    Let $R$ be a commutative ring. Then $I \\unlhd R$ is a \\emph{principal ideal} if $\\exists t \\in R: I = \\langle t \\rangle$.\n\n\\end{definition}\n\n% Well-Definedness.\n\\begin{definition}{3.5.7}{}\n\n    A map $g: (X/\\sim) \\to Z$ is \\emph{well-defined} if there exists a map $f: X \\to Z$ with property $x \\sim y \\Rightarrow f(x) = f(y)$ and $g = \\overline{f}$, where $\\overline{f}(E(x)) = f(x)$.\n\n\\end{definition}\n\n% Cosets of Ideals.\n\\begin{definition}{3.6.1}{}\n\n    Let $I \\unlhd R$, $x \\in R$ then the set\n\n        \\begin{align*}\n            x + I = \\{x + i: i \\in I \\} \\subseteq R\n        \\end{align*}\n\n    is the \\emph{coset of $x$ with respect to $I$ in $R$}.\n\n\\end{definition}\n\n% Factor Ring.\n\\begin{definition}{3.6.3}{}\n\n    Let $R$ be a ring, $I \\unlhd R$ and $\\sim$ an equivalence relation defined by $x \\sim y \\Leftrightarrow x - y \\in I$. Then $R/I$, \\emph{the factor ring of $R$ by $I$} or \\emph{the quotient of $R$ by $I$} is the set $(R/I)$ of cosets of $I$ in $R$.\n\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Determinants and Eigenvalues Redux Definitions %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Tansposition.\n\\begin{definition}{4.1.1}{}\n\n    A \\emph{transposition} is a permutation swapping exactly two elements.\n\n\\end{definition}\n\n% Inversion.\n\\begin{definition}{4.1.2}{}\n\n    An \\emph{inversion} of a permutation $\\sigma \\in \\mathfrak{S}_n$ is a pair $(i,j)$ s.t. $1 \\leq i < j \\leq n$ and $\\sigma(i) > \\sigma(j)$.\n\n    The number of inversions of the permutation $\\sigma$ is \\emph{length of $\\sigma$}, $\\ell(\\sigma)$:\n\n        \\begin{align*}\n            \\ell(\\sigma) = |\\{(i,j) : 1 \\leq i < j \\leq n \\,\\mathrm{but}\\, \\sigma(i) > \\sigma(j)\\}|\n        \\end{align*}\n\n    The \\emph{sign of $\\sigma$} is $\\sgn\\!{(\\sigma)} = (-1)^{\\ell(\\sigma)}$.\n\n\\end{definition}\n\n% Bilinear Form.\n\\begin{definition}{4.3.1}{}\n\n    Let $U,V,W$ be $F$-vector spaces. A \\emph{bilinear form} $H: U \\times V \\to W$ is a mapping s.t. for all $a,b \\in U$ and $c,d \\in V$ and all $\\lambda \\in F$:\n\n        \\begin{align*}\n            H(a + b,c) &= H(a,c) + H(b,c) \\\\\n            H(\\lambda a,c) &= \\lambda H(a,c) \\\\\n            H(a,c + d) &= H(a,c) + H(a,d) \\\\\n            H(a,\\lambda c) &= \\lambda H(a,c)\n        \\end{align*}\n\n    A bilinear form is \\emph{symmetric} if $U = V$ and\n\n        \\begin{align*}\n            \\forall a,b \\in U: H(a,b) = H(b,a)\n        \\end{align*}\n\n    and \\emph{alternating} or \\emph{antisymmetric} if $U = V$ and\n\n        \\begin{align*}\n            \\forall a \\in U: H(a,a) = 0.\n        \\end{align*}\n    \n\\end{definition}\n\n% Alternating Multilinear Form.\n\\begin{definition}{4.3.4}{}\n\n    Let $V, W$ be $F$-vector spaces, $H: V \\times \\hdots \\times V$ multilinear form. Then $H$ is \\emph{alternating} if it vanishes on any $n$-tuple of elements of $V$ where at least two entries are equal:\n\n        \\begin{align*}\n            (\\exists i \\neq j: v_i = v_j) \\Rightarrow H(v_1, \\hdots, v_n) = 0.\n        \\end{align*}\n\n\\end{definition}\n\n% Cofactor of a Matrix.\n\\begin{definition}{4.4.6}{}\n\n    Let $A \\in \\Mat(n;R)$, $R$ commutative ring. Let $1 \\leq i,j \\leq n$. The \\emph{$(i,j)$ cofactor of $A$} is $C_{ij} = (-1)^{i+j}\\det{(A\\langle i,j \\rangle)}$ where $A\\langle i,j \\rangle$ is $A$ with row $i$ and column $j$ removed.\n\n\\end{definition}\n\n% Adjoint of a Matrix.\n\\begin{definition}{4.4.8}{}\n\n    Let $A \\in \\Mat(n;R)$, $R$ being a commutative ring. Let $C_{ji}$ be the $(j,i)$-cofactor of $A$, then the \\emph{adjugate matrix} $\\mathrm{adj}(A)$ is the matrix with entries $\\mathrm{adj}(A)_{ij} = C_{ji}$.\n\n\\end{definition}\n\n% Characteristic Polynomial.\n\\begin{definition}{4.5.6}{}\n\n    Let $A \\in \\Mat(n;R)$, $R$ being a commutative ring. Then the \\emph{characteristic polynomial of $A$} is $\\chi_A(x) \\coloneqq \\det{(A - x\\mathbb{I}_n)} $.\n\n\\end{definition}\n\n% Conjugate Matrices.\n\\begin{definition}{4.5.9}{}\n\n    Let $A,B \\in \\Mat(n;R)$, $R$ being a commutative ring. Then $A,B$ are \\emph{conjugate} if there exists invertible $P \\in \\mathrm{GL}(n;R)$ s.t. $B = P^{-1}AP$.\n\n\\end{definition}\n\n% Triangularisability.\n\\begin{definition}{4.6.1}{}\n\n    Let $f: V \\to V$, $V$ being a finite dimensional $F$-vector space. Then $f$ is \\emph{triangularisable} if there exists an ordered basis for $V$ s.t. the representing matrix of $f$ with respect to the basis is triangular.\n\n\\end{definition}\n\n% Diagonalisability.\n\\begin{definition}{4.6.5}{}\n\n    An endomorphism $f: V \\to V$ of $F$-vector space $V$ is \\emph{diagonalisable} if and only if there exists a basis of $V$ consisting of eigenvectors of $f$. For finite dimensional $V$ this is equivalent to representing matrix being diagonal with eigenvalues of $f$ as entries.\n\n\\end{definition}\n\n% Stochastic Matrix.\n\\begin{definition}{4.7.5}{}\n\n    A \\emph{Markov matrix} or \\emph{stochastic matrix}, is a matrix $M$ s.t. each entry is non-negative and the columns sum to $1$.\n\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Inner Product Spaces Definitions %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Inner Product for R-vector space.\n\\begin{definition}{5.1.1}{}\n    $V$ vector space over $\\mathbb{R}$, \\emph{inner product} is mapping $\\InnerProduct{-}{-}: V \\times V \\to \\mathbb{R}$ such that for $\\vec{x},\\vec{y},\\vec{z} \\in V$, $\\lambda, \\mu \\in \\mathbb{R}$:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n\n            \\item $\\InnerProduct{\\lambda \\vec{x} + \\mu \\vec{y}}{\\vec{z}} = \\lambda\\InnerProduct{\\vec{x}}{\\vec{z}} + \\mu\\InnerProduct{\\vec{y}}{\\vec{z}}$;\n\n            \\item $\\InnerProduct{\\vec{x}}{\\vec{y}} = \\InnerProduct{\\vec{y}}{\\vec{z}}$;\n\n            \\item $\\InnerProduct{\\vec{x}}{\\vec{x}} \\geq 0$ and $0 \\Leftrightarrow \\vec{x} = \\vec{0}$.\n        \\end{enumerate}\n\n\\end{definition}\n\n% Inner Product for C-vector space.\n\\begin{definition}{5.1.1}{}\n    $V$ vector space over $\\mathbb{C}$, \\emph{inner product} is mapping $\\InnerProduct{-}{-}: V \\times V \\to \\mathbb{C}$ such that for $\\vec{x},\\vec{y},\\vec{z} \\in V$, $\\lambda, \\mu \\in \\mathbb{C}$:\n\n        \\begin{enumerate}[(1)]\n            \\setlength{\\parskip}{0em}\n\n            \\item $\\InnerProduct{\\lambda \\vec{x} + \\mu \\vec{y}}{\\vec{z}} = \\lambda\\InnerProduct{\\vec{x}}{\\vec{z}} + \\mu\\InnerProduct{\\vec{y}}{\\vec{z}}$;\n\n            \\item $\\InnerProduct{\\vec{x}}{\\vec{y}} = \\overline{\\InnerProduct{\\vec{y}}{\\vec{z}}}$;\n\n            \\item $\\InnerProduct{\\vec{x}}{\\vec{x}} \\geq 0$ and $0 \\Leftrightarrow \\vec{x} = \\vec{0}$.\n        \\end{enumerate}\n\n    N.B.: Complex inner product is hermitian, and so sesquilinear.\n\n\\end{definition}\n\n% Skew-Linearity.\n\\begin{definition}{5.1.4}{}\n\n    A map $f: V \\to W$, $V,W$ complex vector spaces, is \\emph{skew-linear} if for $\\vec{v},\\vec{u} \\in V$, $\\lambda \\in \\mathbb{C}$:\n\n        \\begin{enumerate}[(i)]\n            \\setlength{\\parskip}{0em}\n            \\item $f(\\vec{v} + \\vec{u}) = f(\\vec{v}) + f(\\vec{u})$;\n            \\item $f(\\lambda\\vec{v}) = \\overline{\\lambda} f(\\vec{v})$.\n        \\end{enumerate}\n\n\\end{definition}\n\n% Sesquilinearity.\n\\begin{definition}{5.1.4}{}\n\n    A map $f: V_1 \\times V_2 \\to W$, complex vector spaces, that is linear in its first and skew-linear in its second variable is a \\emph{sesquilinear form}, i.e.:\n\n        \\begin{enumerate}[(i)]\n            \\setlength{\\parskip}{0em}\n            \\item $f(\\lambda \\vec{v},\\vec{u}) = \\lambda f(\\vec{v},\\vec{u})$\n            \\item $f(\\vec{v},\\lambda \\vec{u}) = \\overline{\\lambda} f(\\vec{v},\\vec{u})$\n        \\end{enumerate}\n\n\\end{definition}\n\n% Hermitian.\n\\begin{definition}{5.1.4}{}\n\n    Let $f$ be a sesquilinear form and let $f(\\vec{v},\\vec{u}) = \\overline{f(\\vec{u},\\vec{v})}$, then $f$ is \\emph{hermitian}.\n\n\\end{definition}\n\n% Inner Product Norm.\n\\begin{definition}{5.1.5}{}\n\n    In complex or real inner product space, the \\emph{length} or \\emph{inner product norm} $\\norm{\\vec{v}} \\in \\mathbb{R}$ is defined $\\norm{\\vec{v}} = \\sqrt{\\InnerProduct{\\vec{v}}{\\vec{v}}}$.\n\n\\end{definition}\n\n% Orthonormal Family.\n\\begin{definition}{5.1.7}{}\n\n    A family $(\\vec{v}_i)_{i \\in I}$ of vectors in an inner product space is an \\emph{orthonormal family} if all $\\vec{v}_i$ have length $1$ and are pairwise orthogonal, i.e. $\\InnerProduct{\\vec{v}_i}{\\vec{v}_j} = \\delta_{ij}$.\n\n    If an orthonormal family is a basis, it is an \\emph{orthonormal basis}.\n\n\\end{definition}\n\n% Orthogonal Set.\n\\begin{definition}{5.2.1}{}\n\n    Let $V$ inner product space, $T \\subseteq V$. Then\n\n        \\begin{align*}\n            T^{\\perp} = \\{ \\vec{v} \\in V: \\vec{v} \\perp \\vec{t}, \\forall \\vec{t} \\in T \\}\n        \\end{align*}\n\n    is the \\emph{orthogonal} to $T$.\n\n\\end{definition}\n\n% Orthogonal Complement and Projection.\n\\begin{definition}{5.2.3}{}\n\n    Let $U \\subseteq V$ be finite dimensional subspace of inner product space $V$. $U^{\\perp}$ is \\emph{orthogonal complement to $U$}.\n\n    The map $\\pi_U: V \\to V; \\vec{v} = \\vec{p} + \\vec{r} \\mapsto \\vec{p}$, $\\vec{p} \\in U$, $\\vec{r} \\in U^{\\perp}$ is the \\emph{orthogonal projection from V onto U}.\n\n\\end{definition}\n\n% Hermitian Matrices.\n\\begin{definition}{5.3.6}{}\n\n    Let $A \\in \\Mat(n,\\mathbb{C})$ s.t. $A = \\overline{A}^T$, then $A$ is \\emph{hermitian}.\n\n\\end{definition}\n\n% Orthogonal Matrix.\n\\begin{definition}{5.3.11}{}\n\n    Let $P \\in \\Mat(m,\\mathbb{R})$. $P$ is \\emph{orthogonal} if $P^TP = \\mathbb{I}_n$, i.e. $P^{-1} = P^T$.\n\n\\end{definition}\n\n% Unitary Matrix.\n\\begin{definition}{5.3.14}{}\n\n    Let $P \\in \\Mat(m,\\mathbb{C})$. $P$ is \\emph{unitary} if $\\overline{P}^TP = \\mathbb{I}_n$, i.e. $P^{-1} = \\overline{P}^T$.\n\n\\end{definition}\n\n\\end{multicols}\n\n\\end{document}\n", "meta": {"hexsha": "f5d2c31826e95612c762674925a3f20c96762014", "size": 71429, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "smueksch/algebra-overview", "max_stars_repo_head_hexsha": "729f922b92ab7cad30d70b0c36ef0683aa3155ae", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "smueksch/algebra-overview", "max_issues_repo_head_hexsha": "729f922b92ab7cad30d70b0c36ef0683aa3155ae", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "smueksch/algebra-overview", "max_forks_repo_head_hexsha": "729f922b92ab7cad30d70b0c36ef0683aa3155ae", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6076769691, "max_line_length": 751, "alphanum_fraction": 0.6157443055, "num_tokens": 24616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795672, "lm_q2_score": 0.7772998714925403, "lm_q1q2_score": 0.4098830658588308}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\setlength\\parindent{2pt}\n\\usepackage{multirow}\n\\usepackage{graphicx}\n\\usepackage{siunitx}\n\\usepackage{float}\n\\usepackage{derivative}\n\\usepackage{amsmath,amssymb}\n\n\n\\title{SURP Computing Project 2020: Lechun Xing \\\\ CTA200H \\\\ Supervisor: Jonathan Braden}\n\\author{Lechung Xing - 1004705170 }\n\\date{May 8th 2020}\n\n\\begin{document}\n\n\\maketitle\n% Part 1\n\\section{Clone folder from Github}\ngit branch:\\\\ * dev(development branch)\\\\   master(main branch)\n% Part 2\n\\section{Units}\n\\subsection{(a) find dimensions of field $\\phi$ and potential energy density $V(\\phi)$}\nGiven: $[c]=light speed=LT^{-1}$ and \n$[\\hbar]=ML^2{T^{-1}}=[S]$\n\n\\vspace{3mm}\nAction $S=\\int{d^d{x}dt({(\\dot{\\phi}})^2}/{2c^2}-{(\\partial_x{\\phi})^2}/2-V(\\phi))$\n\n\\vspace{3mm}\nReplace\n$[\\dot{\\phi}]=[\\phi]T^{-1}$ and\n$[\\partial_x{\\phi}]=[\\phi]/x=[\\phi]x^{-1}$ where [x]=[L]\n\n\\vspace{3mm}\nDimension $[S]=L^d{T}({[\\phi]^2{T^{-2}}}/L^2{T^{-2}}-[\\phi]^2{L^{-2}}-[V(\\phi)]$\n\n\\vspace{3mm}\nSimplify $[S]={L^{d-2}T}({[\\phi]^2}-[\\phi]^2-L^2[V(\\phi)])=[\\hbar]=ML^2{T^{-1}}$\n\n\\vspace{3mm}\nAfter cancelling the ${[\\phi]^2}$ terms and collecting the $L$ terms:\n\n\\vspace{3mm}\nWe derived the dimension of \n$[V(\\phi)]=ML^{2-d}T^{-2}$\n\n\\vspace{5mm}\nRecall PDE: $\\frac{1}{c^2}{\\frac{\\partial^2\\phi}{\\partial{t^2}}}-{\\frac{\\partial^2\\phi}{\\partial{x^2}}}+{\\frac{\\partial{V}}{\\partial{\\phi}}}=0$\n\n\\vspace{3mm}\nThe first 2 terms differ only by a constant $A$, they share the same dimension as in the Action expression [S] listed above. Thus, we can rewrite PDE:\n\n\\vspace{3mm}\n$A[\\phi]L^{-2}+[V][\\phi]^{-1}=0$ Replace the dimension of [V] and collect $[\\phi]$ terms:\n\n\\vspace{3mm}\nWe derived the dimension of \n$[\\phi]=(-A)^{-1/2}L[V]^{1/2}=(L^{4-d})^{1/2}M^{1/2}T^{-1}$, in which $d$ is spatial dimensions.\n\n\\subsection{(b) introduce scalar $\\Lambda, x_0, t_0$, rewrite action S}\n\nGiven: $\\phi=\\Lambda{\\bar{\\phi}}$ and $x=x_0{\\bar{x}}$ and $t=t_o{\\bar{t}}$\n\n\\vspace{3mm}\nDerive: $\\dot{\\phi}=\\Lambda{\\dot{\\bar\\phi}}=\\Lambda{\\partial_t}{\\bar\\phi}$ and $\\partial_x{\\phi}=\\frac{\\partial\\phi}{\\partial{x}}=\\frac{\\partial\\phi}{\\partial}{{(x_0\\bar{x})}}=\\frac{1}{x_0}{\\partial_\\bar{x}}{(\\Lambda{\\bar\\phi})}=\\frac{\\Lambda}{x_0}{\\partial_\\bar{x}}{\\bar\\phi}$\n\n\\vspace{3mm}\nSimilarly convert the differentials: $dx=x_0{d\\bar{x}}$ and $dt=t_0{d\\bar{t}}$\n\n\\vspace{3mm}\nAction $S=\\int{{x_0}^d{(d\\bar{x}})^d{(t_0{d\\bar{t}})}[\\frac{\\Lambda^2{\\dot{\\bar{\\phi}}}^2}{2c^2}-\\frac{1}{2}{(\\frac{\\Lambda}{x_0})^2(\\partial_{\\bar{x}}{\\bar\\phi}})^2-V(\\Lambda\\bar\\phi)]}$\n\n\\subsection{(c) rewrite PDE in terms of  derivatives of $\\bar{t}, \\bar{x}$}\nSubstitute 3 scalars into PDE: $\\frac{1}{c^2}{\\frac{\\partial^2}{\\partial{t^2}}(\\Lambda\\bar\\phi)}-\\frac{\\partial^2}{\\partial{x^2}}(\\Lambda\\bar\\phi)+\\frac{\\partial{V}}{\\partial(\\Lambda\\bar\\phi)}=0$\n\n\\vspace{3mm}\nPull out $\\Lambda$: $\\frac{\\Lambda}{{c^2}{t_0}^2}{{\\partial^2}_{\\bar{t}}\\bar\\phi}-{\\frac{\\Lambda}{{x_0}^2}{\\partial^2_{\\bar{x}}}}{\\bar\\phi}+{\\frac{\\partial{V(\\bar\\phi)}}{\\partial{\\bar\\phi}}}=0$\n\n\n%Which code file? Which eqn?\n\\subsection{(d) rewrite dimensionless eqn. in the code for  $\\hbar=c=1$}\nFor $\\hbar=c=1$: \n$\\frac{\\Lambda}{{t_0}^2}{{\\partial^2}_{\\bar{t}}\\bar\\phi}-{\\frac{\\Lambda}{{x_0}^2}{\\partial^2_{\\bar{x}}}}{\\bar\\phi}+{\\frac{\\partial{V}}{\\partial{\\bar\\phi}}}=0$ all expressed in terms of scaling factors or dimensionless quantities. If implement this equation into codes, we need to specify all the scalars in front of derivative terms before hand. Here, the potential expression is $V(\\bar\\phi)$.\n%Part 3\n\\section{Plot field evolution $\\phi(x, t)$}\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_default.png}\n    \\caption{Field evolution $\\phi(t, x)$ plotted from $<fields.dat>$ with the normalized lattice sites $x\\in{[0, 1024*dx]}$ and the normalized time steps $t\\in{[0, 200]}$.}\n    \\label{fig:Q3}\n\\end{figure}\n\n$\\phi(t, x)$ values drop across all 1024 lattice sites as t increases. The slanted bands extending over Fig.1 indicate the fluctuations of $\\phi(t, x)$ values among the overall decreasing trend for larger t. There appears a wall near $t=25$, separating the True Vacuum from the False vacuum, marking the boundary of the distinct mean $\\phi$ values. \n\n% Part 4\n\\section{Energy conservation}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{E_dev_alph=4}\n    \\caption{Violation of Energy conservation vs. output time steps $dt_{out}$. Blue data is calculated from $<fields.dat>$ according to $E=\\sum_i(\\frac{1}{2}{\\dot\\phi_i}^2+\\frac{1}{2}{(\\nabla{\\phi})^2}_i+V(\\phi_i))$, $i$ means summation over 1024 lattice sites. Red dashed line is the power fitting model $E = a*{t}^b$, a, b are parameters. $t=dt'$ array, determined by $\\alpha=dx/dt$ in $<evolve-scalar.f90>$}\n    \\label{fig:Q4}\n\\end{figure}\n\nThe fitting model depicted in Fig.2 caption was my initial idea for testing the scaling relationship between $|E(t) - E(0)|$ and $\\alpha$. The size of Energy deviation $|E(t) - E(0)|$ seems to increases linearly with t. When $\\alpha = 0.95$ or any value smaller than 1., the code does not output data file, this prevents the integrator to yield far-off values. The $dl$ in the legend of Fig.2 indicates \"double precision\" in the code file. When adjusting $\\alpha$, I only alters the numerical value before $dl$ in Part 5. \n\n% Part 5\n\\section{Energy violation: adjust $\\alpha$}\n\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{E_dev_alph_all}\n    \\includegraphics[scale=0.7]{E_dev_alph_all_log}\n    \\caption{Combined $|E(t) - E(0)|$ plot for 6 $\\alpha$ values. The bottom plot is with log y axis. The new fitting model is $Error = a*(dt')**b$, where $dt'$ is fixed and is unique for each $\\alpha$. We are only interested in $b$. }\n    \\label{fig:Q5}\n\\end{figure}\n\nFig.3 shows $|E(t) - E(0)|$ decreases as $\\alpha$ increases from 1. to 32..\n\n I realized this part is asking for how Energy conservation error is scaled with dt' instead of the time evolution of $E(t) - E(0)$, the irrelevant fitting plots are attached in my codes. I noticed from Fig.3.(log scale) that for each dt', the Error size satisfies $\\frac{Error[i]}{Error[j]}\\propto({\\frac{dt'[i]}{dt'[j]}})^{b}$, where i,j are indices from dt' array. Averaging over the 6 b-values [8.83619719 8.55494879 8.93256013 8.98341054 8.98661886 8.72344764] (for 6 dt'), I conclude $b\\approx8.836\\approx9$. This is the exponent $b$ for Part 6. In general, $a$ for the 6 $\\alpha$ are assumed to be of the same order of magnitude. Thus, I omitted $a$ in the fractional equation mentioned above.  \n\n\\vspace{3mm}\n\n\n\\section{Field evolution: adjust $\\lambda$ the shape of $V(\\phi)$}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_L1point5.png}\n    \\includegraphics[scale=0.7]{Phi_evo_L1point3.png}\n    \\caption{$\\lambda=1.5 and 1.3$}\n    \\label{fig:Q1}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_Lpoint9.png}\n    \\includegraphics[scale=0.7]{Phi_evo_Lpoint8.png}\n    \\caption{$\\lambda=0.9 and 0.8$}\n    \\label{fig:Q1}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_L1.png}\n    \\caption{$\\lambda=1.$}\n    \\label{fig:Q1}\n\\end{figure}\n\nWhen $\\lambda$ is far away from $1.2$, I no longer see the clear cut (wall) between True vacuum and the False vacuum. Especially when $\\lambda=1.5>1.2$, field evolves to a stage filled with fluctuations.\nWhen $\\lambda=1.$, the plot shows distorted patches of extremely large or small $\\phi$, but the rest of region has little fluctuations. This is particularly interesting, unlike other $\\lambda$ conditions.\n\n\\section{Field evolution: adjust initial conditions}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_8617.png}\n    \\includegraphics[scale=0.7]{Phi_evo_8618.png}\n    \\caption{(86, 17), (86,18) initial conditions}\n    \\label{fig:Q1}\n\\end{figure}\n\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_8719.png}\n    \\includegraphics[scale=0.7]{Phi_evo_8818.png}\n    \\caption{(87, 19), (88,18) initial conditions}\n    \\label{fig:Q1}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\includegraphics[scale=0.7]{Phi_evo_8710.png}\n    \\caption{(87,10) initial conditions}\n    \\label{fig:Q1}\n\\end{figure}\n\nFor random seeds close to the default (87, 18), the field evolution does not change much in terms of the $\\phi$ value difference above and below the wall. Related to Part 6, although both $\\lambda$ and the random seeds can prepare different initial conditions, the lattice system's evolution is more sensitive to $\\lambda$ rather than (*, *) in Part 7. \n\n\\vspace{5mm}\n\nNote: Due to the large numbers of complicated plots above, I insert their .PNG version but have uploaded the .PDF version into my Github computational(underscore)assignment folder. Otherwise, I cannot git push this report to Github.\n\n\\end{document}", "meta": {"hexsha": "4894e48bb05d4678fa0da68cd1d16156fe5b937e", "size": 8872, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "computational_assignment/report_png.tex", "max_stars_repo_name": "xinglech/CTA200-assignment", "max_stars_repo_head_hexsha": "c6c764241d9be99836783cda25e30d37d31d4dda", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "computational_assignment/report_png.tex", "max_issues_repo_name": "xinglech/CTA200-assignment", "max_issues_repo_head_hexsha": "c6c764241d9be99836783cda25e30d37d31d4dda", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "computational_assignment/report_png.tex", "max_forks_repo_name": "xinglech/CTA200-assignment", "max_forks_repo_head_hexsha": "c6c764241d9be99836783cda25e30d37d31d4dda", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.1914893617, "max_line_length": 702, "alphanum_fraction": 0.684625789, "num_tokens": 2995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7772998663336158, "lm_q1q2_score": 0.4098830631384445}}
{"text": "\\documentclass{llncs}\n\n\\pagestyle{plain}\n\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{mathtools}\n\\usepackage{bookmark}\n\\setcounter{tocdepth}{3}\n\n\\newcommand{\\G}{\\mathbb{G}}\n\\newcommand{\\F}{\\mathbb{F}}\n\\newcommand{\\hash}{\\mathcal{H}}\n\\newcommand{\\func}[1]{\\mathsf{#1}}\n\\newcommand{\\addr}{\\func{addr}}\n\\newcommand{\\com}{\\func{Com}}\n\\newcommand{\\comm}{\\func{Comm}}\n\\newcommand{\\oracle}{\\mathcal{O}^{\\func{DAP}}}\n\n\n\\begin{document}\n\n\\title{Lelantus Spark: Secure and Flexible Private Transactions}\n\\author{Aram Jivanyan\\inst{1,2}\\thanks{Corresponding author: \\email{aram@firo.org}} \\and Aaron Feickert\\inst{3}}\n\\institute{Firo \\and Yerevan State University \\and Cypher Stack}\n\\maketitle\n\n\\begin{abstract}\n    We propose a modification to the Lelantus private transaction protocol to provide recipient privacy, improved security, and additional usability features.\n    Our decentralized anonymous payment (DAP) construction, Spark, enables non-interactive one-time addressing to hide recipient addresses in transactions.\n    The modified address format permits flexibility in transaction visibility.\n    Address owners can securely provide third parties with opt-in visibility into incoming transactions or all transactions associated to the address; this functionality allows for offloading chain scanning and balance computation without delegating spend authority.\n    It is also possible to delegate expensive proving operations without compromising spend authority when generating transactions.\n    Further, the design is compatible with straightforward linear multisignature operations to allow mutually non-trusting parties to cooperatively receive and generate transactions associated to a multisignature address.\n    We prove that Spark satisfies formal DAP security properties of balance, non-malleability, and ledger indistinguishability.\n\\end{abstract}\n\n\n\\section{Introduction}\n\nDistributed digital asset protocols have seen a wealth of research since the introduction of the Bitcoin transaction protocol, which enables transactions generating and consuming ledger-based outputs, and provides a limited but useful scripting capability.\nHowever, Bitcoin-type protocols have numerous drawbacks relating to privacy: a transaction reveals source addresses and amounts, and subsequent spends reveal destination addresses.\nFurther, data and metadata associated with transactions, like script contents, can provide undesired fingerprinting of transactions.\n\nMore recent research has focused on mitigating or removing these limitations, while permitting existing useful functionality like multisignature operations or opt-in third-party transaction viewing.\nDesigns in privacy-focused cryptocurrencies like Beam, Firo, Grin, Monero, and Zcash take different approaches toward this goal, with a variety of different tradeoffs.\nThe RingCT-based protocol currently used in Monero, for example, practically permits limited sender anonymity due to the space and time scaling of its underlying signature scheme \\cite{ringct,clsag}.\nThe Sprout and Sapling protocols supported by Zcash \\cite{zcash} (and their currently-deployed related updates) require trusted parameter generation to bootstrap their circuit-based proving systems, and interact with transparent Bitcoin-style outputs in ways that can leak information \\cite{zcash_sprout,zcash_sapling}.\nThe Mimblewimble-based construction used as the basis for Grin can leak graph information prior to a merging operation performed by miners \\cite{mw}.\nTo mitigate Mimblewimble's linkability issue, Beam has designed and implemented into its system an adaption of Lelantus for use with the Mimblewimble protocol which enables obfuscation of the transaction graph \\cite{LMW}.\nThe Lelantus protocol currently used in Firo does not provide recipient privacy; it supports only mints and signer-ambiguous spends of arbitrary amounts that interact with transparent Bitcoin-style outputs, which can leak information about recipient identity \\cite{lelantus}.\nSeraphis \\cite{seraphis} is a transaction protocol framework of similar design being developed concurrently.\n\nHere we introduce Spark, an iteration on the Lelantus protocol enabling trustless private transactions which supports sender, recipient, and transaction amount privacy.\nTransactions in Spark, like those in Lelantus and Monero, use specified sender anonymity sets composed of previously-generated shielded outputs.\nA parallel proving system adapted from a construction by Groth and Bootle \\textit{et al.} \\cite{groth,bootle} (of independent interest and used in other modified forms in Lelantus\\cite{lelantus} and Triptych \\cite{triptych}) proves that a consumed output exists in the anonymity set; amounts are encrypted and hidden algebraically in Pedersen commitments, and a tag derived from a verifiable random function \\cite{dodis,omniring} prevents consuming the same output multiple times, which in the context of a transaction protocol would constitute a double-spend attempt.\n\nSpark transactions support efficient verification in batches, where range and spend proofs can take advantage of common proof elements and parameters to lower the marginal cost of verifying each proof in such a batch; when coupled with suitably-chosen sender anonymity sets, the verification time savings of batch verification can be significant.\n\nSpark enables additional useful functionality.\nThe use of a modified Chaum-Pedersen discrete logarithm proof, which asserts spend authority and correct tag construction, enables efficient signing and multisignature operations similar to those of \\cite{musig,frost,schnorrwithschnorr} where computationally-expensive proofs may be offloaded to more capable devices with limited trust requirements.\nThe protocol further adds three levels of opt-in visibility into transactions without delegating spend authority.\nIncoming view keys allow a designated third party to identify transactions containing outputs destined for an address, as well as the corresponding amounts and encrypted memo data.\nFull view keys allow a designated third party to additionally identify when received outputs are later spent (but without any recipient data), which enables balance auditing and further enhances accountability in threshold multisignature applications where this property is desired.\nPayment proofs allow a sender to assert the destination, value, and memo of a coin while proving (in zero knowledge) that it knows the secret data used to produce the coin; this permits more fine-grained disclosure without revealing view keys.\n\nAll constructions used in Spark require only public parameter generation, ensuring that no trusted parties are required to bootstrap the protocol or ensure soundness.\n\n\n\\section{Cryptographic Preliminaries}\n\nThroughout this paper, we use additive notation for group operations.\nLet $\\mathbb{N}$ be the set $\\{0,1,2,\\ldots\\}$ of non-negative integers.\n\n\n\\subsection{Pedersen Commitment Scheme}\n\nA homomorphic commitment scheme is a construction producing one-way algebraic representations of input values.\nThe Pedersen commitment scheme is a homomorphic commitment scheme that uses a particularly simple linear combination construction.\nLet $pp_{\\text{com}} = (\\G, \\F, G, H)$ be the public parameters for a Pedersen commitment scheme, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $G,H \\in \\G$ are uniformly-sampled independent generators.\nThe commitment scheme contains an algorithm $\\com: \\F^2 \\to \\G$, where $\\com(v,r) = vG + rH$ that is homomorphic in the sense that $$\\com(v_1,r_1) + \\com(v_2,r_2) = \\com(v_1 + v_2,r_1 + r_1)$$ for all such input values $v_1,v_2 \\in \\F$ and masks $r_1,r_2 \\in \\F$.\nFurther, the construction is perfectly hiding and computationally binding.\n\nThis definition extends naturally to a double-masked commitment scheme.\nLet $pp_{\\text{comm}} = (\\G, \\F, F, G, H)$ be the public parameters for a double-masked Pedersen commitment scheme, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $F,G,H \\in \\G$ are uniformly-sampled independent generators.\nThe commitment scheme contains an algorithm $\\comm: \\F^3 \\to \\G$, where $\\comm(v,r,s) = vF + rG + sH$ that is homomorphic in the sense that $$\\comm(v_1,r_1,s_1) + \\comm(v_2,r_2,s_2) = \\comm(v_1 + v_2,r_1 + r_2,s_1 + s_2)$$ for all such input values $v_1,v_2 \\in \\F$ and masks $r_1,r_2,s_1,s_2 \\in \\F$.\nFurther, the construction is perfectly hiding and computationally binding.\n\n\n\\subsection{Representation proving system}\n\nA representation proof is used to demonstrate knowledge of a set of discrete logarithms in zero knowledge.\nLet $pp_{\\text{rep}} = (\\G, \\F)$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problems is hard and $\\F$ is its scalar field.\n\nThe proving system itself is a tuple of algorithms $(\\func{RepProve},\\func{RepVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{rep}}, G, \\{Y_i\\}_{i=0}^{l-1} \\subset \\G ; \\{y_i\\}_{i=0}^{l-1} \\subset \\F : \\forall i \\in [0,l), Y_i = y_i G \\right\\}$$\n\nWe require that the proving system be complete, special honest-verifier zero knowledge, and special sound; these definitions are standard \\cite{groth}.\n\nAn aggregated Schnorr proving system, like that in \\cite{batchschnorr}, may be used for this purpose.\n\nAs a matter of notational convenience, we drop the set and subscript notation from these algorithms in the case where $l = 1$; this represents the case of a standard (non-aggregated) representation proof.\n\n\n\\subsection{Modified Chaum-Pedersen Proving System}\n\nA Chaum-Pedersen proof is used to demonstrate discrete logarithm equality in zero knowledge.\nHere we require a modification to the standard proving system that uses additional group generators and supports multiple assertions within a single proof.\nLet $pp_{\\text{chaum}} = (\\G, \\F, F, G, H, U)$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $F,G,H,U \\in \\G$ are uniformly-sampled independent generators.\n\nThe proving system is a tuple of algorithms $(\\func{ChaumProve},\\func{ChaumVerify})$ for the following relation:\n\\begin{multline*}\n\\left\\{ pp_{\\text{chaum}}, \\{S_i, T_i\\}_{i=0}^{l-1} \\subset \\G^2 ; (\\{x_i, y_i, z_i\\}_{i=0}^{l-1}) \\subset \\F^3 : \\right. \\\\\n\\left. \\forall i \\in [0,l), S_i = x_i F + y_i G + z_i H, U = x_i T_i + y_i G \\right\\}\n\\end{multline*}\n\nWe require that the proving system be complete, special honest-verifier zero knowledge, and special sound.\n\nWe present an instantiation of such a proving system in Appendix \\ref{app:chaum}, along with security proofs.\n\n\n\\subsection{Parallel One-out-of-Many Proving System}\n\nWe require the use of a parallel one-out-of-many proving system that shows knowledge of openings of commitments to zero at the same index among two sets of group elements in zero knowledge.\nIn the context of the Spark protocol, this will be used to mask consumed coin serial number and value commitments for balance, ownership, and double-spend purposes.\nWe show how to produce such a proving system as a straightforward modification of a construction by Groth and Kohlweiss \\cite{groth} that was generalized by Bootle \\textit{et al.} \\cite{bootle}, with a further optimization from Esgin \\textit{et al.} \\cite{matrict}.\n\nLet $pp_{\\text{par}} = (\\G, \\F, n, m, pp_{\\text{com}}, pp_{\\text{comm}})$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, $n > 1$ and $m > 1$ are integer-valued size decomposition parameters, $pp_{\\text{com}}$ are the public parameters for a Pedersen commitment construction, and $pp_{\\text{comm}}$ are the public parameters for a double-masked Pedersen commitment construction.\n\nThe proving system itself is a tuple of algorithms $(\\func{ParProve},\\func{ParVerify})$ for the following relation, where we let $N = n^m$:\n\\begin{multline*}\n\\left\\{ pp_{\\text{par}}, \\{S_k,V_k\\}_{k=0}^{N-1} \\subset \\G^2, S',V' \\in \\G ; l \\in \\mathbb{N}, (s,v) \\in \\F : \\right. \\\\\n\\left. 0 \\leq l < N, S_l - S' = \\comm(0,0,s), V_l - V' = \\com(0,v) \\right\\}\n\\end{multline*}\n\nWe require that the proving system be complete, special honest-verifier zero knowledge, and special sound.\n\nWe present an instantiation of such a proving system in Appendix \\ref{app:parallel}.\n\n\n\\subsection{Authenticated Encryption Scheme}\n\nWe require the use of an authenticated symmetric encryption with associated data (AEAD) scheme.\nIn the context of the Spark protocol, this construction is used to encrypt value, memo, and other data for use by the recipient of a transaction.\n\nLet $pp_{\\text{aead}}$ be the public parameters for such a construction.\nThe construction itself is a tuple of algorithms $(\\func{AEADKeyGen},\\func{AEADEncrypt},\\func{AEADDecrypt})$.\nHere $\\func{AEADKeyGen}$ is a key derivation function that accepts as input an arbitrary string, and produces a key in the appropriate key space.\nThe algorithm $\\func{AEADEncrypt}$ accepts as input a key, associated data, and arbitrary message string, and produces ciphertext in the appropriate space.\nThe algorithm $\\func{AEADDecrypt}$ accepts as input a key, associated data, and ciphertext string, and produces a message in the appropriate space if authentication succeeds (and fails otherwise).\n\nAssume that such a construction is indistinguishable against adaptive chosen-ciphertext attacks (IND-CCA2) and key-private under chosen-ciphertext attacks (IK-CCA) in this context \\cite{keyprivacy}.\n\n\n\\subsection{Symmetric Encryption Scheme}\n\nWe require the use of a symmetric encryption scheme.\nIn the context of the Spark protocol, this construction is used to encrypt diversifier indices used to produce public addresses.\n\nLet $pp_{\\text{sym}}$ be the public parameters for such a construction.\nThe construction itself is a tuple of algorithms $(\\func{SymKeyGen},\\func{SymEncrypt},\\func{SymDecrypt})$.\nHere $\\func{SymKeyGen}$ is a key derivation function that accepts as input an arbitrary string, and produces a key in the appropriate key space.\nThe algorithm $\\func{SymEncrypt}$ accepts as input a key and arbitrary message string, and produces ciphertext in the appropriate space.\nThe algorithm $\\func{SymDecrypt}$ accepts as input a key and ciphertext string, and produces a message in the appropriate space.\n\nAssume that such a construction is indistinguishable against adaptive chosen-ciphertext attacks (IND-CCA2) in this context.\n\n\n\\subsection{Range Proving System}\n\nWe require the use of a zero-knowledge range proving system.\nA range proving system demonstrates that a commitment binds to a value within a specified range.\nIn the context of the Spark protocol, it avoids overflow that would otherwise fool the balance definition by effectively binding to invalid negative values.\nLet $pp_{\\text{rp}} = (\\G, \\F, v_{\\text{max}}, pp_{\\text{com}})$ be the relevant public parameters for such a construction, where $pp_{\\text{com}}$ are the public parameters for a Pedersen commitment construction.\n\nThe proving system itself is a tuple of algorithms $(\\func{RangeProve},\\func{RangeVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{rp}}, C \\in \\G ; (v, r) \\in \\F : 0 \\leq v \\leq v_{\\text{max}}, C = \\com(v,r) \\right\\}$$\n\nWe require that the proving system be complete, special honest-verifier zero knowledge, and special sound.\n\nIn practice, an efficient instantiation like Bulletproofs \\cite{bp} or Bulletproofs+ \\cite{bp_plus} may be used to satisfy this requirement.\n\n\n\\section{Concepts and Algorithms}\n\nWe now define the main concepts and algorithms used in the Spark transaction protocol.\n\n\\textbf{Keys and addresses}. Users generate keys and addresses that enable transactions.\nA set of keys consists of a tuple $$(\\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{\\text{sk}}).$$\nIn this notation, $\\addr_{\\text{in}}$ is an incoming view key used to identify received funds, $\\addr_{\\text{full}}$ is a full view key used to identify outgoing funds and conduct certain computationally-heavy proving operations, and $\\addr_{\\text{sk}}$ is the spend key used to generate transactions.\nSpark addresses are constructed in such a way that a single set of keys can be used to construct any number of \\textit{diversified} public addresses that appear indistinguishable from each other or from public addresses produced from a different set of keys.\nDiversified addressing allows a recipient to provide distinct public addresses to different senders, but scan transactions on chain only once for identification and recovery of incoming coins destined for any of its diversified public addresses.\n\n\\textbf{Coins.} A coin encodes the abstract value which is transferred through the private transactions. Each coin is associated with:\n\\begin{itemize}\n\\item A secret nonce\n\\item A recipient address\n\\item An integer value\n\\item A memo containing arbitrary recipient data\n\\end{itemize}\nThe recipient address and value are hidden using commitments.\nThe nonce, a part of the recipient address, the value, and the memo are encrypted to the recipient (unless the value is made public as part of a mint operation).\n\n\\textbf{Private Transactions}. There are two types of private transactions in Spark:\n\\begin{itemize}\n    \\item Mint transactions.\n    A mint transaction generates new coins of public value destined for a recipient public address in a confidential way, either through a consensus-enforced mining process, or by consuming transparent outputs from a non-Spark base layer.\n    In this transaction type, a representation proof is included to show that the minted coins are of the expected values.\n    \\item Spend transactions.\n    A spend transaction consumes existing coins and generates new coins destined for one or more recipient public addresses in a confidential way.\n    In this transaction type, a representation proof is included to show that the hidden input and output values are equal.\n\\end{itemize}\n\n\\textbf{Tags.} Tags are used to prevent coins from being consumed in multiple transactions.\nWhen generating a spend transaction, the sender produces the tag for each consumed coin and includes it on the ledger.\nWhen verifying transactions are valid, it suffices to ensure that tags do not appear on the ledger in any previous transactions.\nTags are uniquely bound to validly-recoverable coins, but cannot be associated to specific coins without the corresponding full view key.\n\n\\textbf{Algorithms}. Spark is a decentralized anonymous payment (DAP) system defined as the following polynomial-time algorithms:\n\\begin{itemize}\n\\item $\\func{Setup}$: This algorithm produces all public parameters used by the protocol and its underlying components.\nThe setup process does not require any trusted parameter generation.\n\\item $\\func{CreateKeys}$: This algorithm produces keys that are used when constructing addresses, processing coins, and spending coins.\n\\item $\\func{CreateAddress}$: This algorithm produces diversified public addresses used for receiving coins.\n\\item $\\func{CreateCoin}$: This algorithm produces a coin of a given value that is destined for a recipient public address.\n\\item $\\func{Mint}$: This algorithm produces a transaction transferring public value to recipient public addresses.\n\\item $\\func{Identify}$: This algorithm processes a coin to determine if it is destined for a diversified address controlled by a recipient.\n\\item $\\func{Recover}$: This algorithm processes a coin to determine if it is destined for a diversified address controlled by a recipient, and produces additional data used for spending the coin or determining if it is already spent.\n\\item $\\func{Spend}$: This algorithm produces a transaction consuming existing coins and generating new coins of hidden value to recipient public addresses.\n\\item $\\func{Verify}$: This algorithm determines if a given transaction is valid.\n\\end{itemize}\n\nWe provide detailed descriptions below, and show security of the resulting protocol in Appendix \\ref{app:security}.\n\n\n\\section{Algorithm Constructions}\n\nIn this section we provide detailed description of the DAP scheme algorithms.\n\n\n\\subsection{\\texorpdfstring{$\\func{Setup}$}{Setup}}\n\nThis algorithm produces public parameters required for the protocol.\nThe security parameter and resulting public parameters are assumed to be available to all other algorithms, even where not specifically noted.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, size decomposition parameters $n > 1$ and $m > 1$, maximum value parameter $v_{\\text{max}}$\n\n\\textbf{Outputs:} Public parameters $pp$\n\n\\begin{enumerate}\n\\item Sample a prime-order group $\\G$ in which the discrete logarithm, decisional Diffie-Hellman, and computational Diffie-Hellman problems are hard.\nLet $\\F$ be the scalar field of $\\G$.\n\\item Sample $F,G,H,U \\in \\G$ uniformly at random.\nIn practice, these generators may be chosen using a suitable cryptographic hash function on public input.\n\\item Sample cryptographic hash functions $$\\hash_k, \\hash_{Q_2},\\hash_{\\text{ser}},\\hash_{\\text{val}},\\hash_{\\text{ser}'},\\hash_{\\text{val}'},\\hash_{\\text{bind}}: \\{0,1\\}^* \\to \\F$$ and $$\\hash_{\\text{div}}: \\{0,1\\}^* \\to \\G$$ uniformly at random.\nIn practice, these hash functions may be chosen using domain separation of a single suitable cryptographic hash function on public input.\n\\item Compute the public parameters $pp_{\\text{com}} = (\\G,\\F,G,H)$ of a Pedersen commitment scheme.\n\\item Compute the public parameters $pp_{\\text{comm}} = (\\G,\\F,F,G,H)$ of a double-masked Pedersen commitment scheme.\n\\item Compute the public parameters $pp_{\\text{rep}} = (\\G,\\F)$ of a representation proving system.\n\\item Compute the public parameters $pp_{\\text{chaum}} = (\\G,\\F,F,G,H,U)$ of the modified Chaum-Pedersen proving system.\n\\item Compute the public parameters $pp_{\\text{par}} = (\\G,\\F,n,m,pp_{\\text{com}},pp_{\\text{comm}})$ of the parallel one-out-of-many proving system.\n\\item Compute the public parameters $pp_{\\text{aead}}$ of an authenticated symmetric encryption scheme.\n\\item Compute the public parameters $pp_{\\text{sym}}$ of a symmetric encryption scheme.\n\\item Compute the public parameters $pp_{\\text{rp}} = (\\G,\\F,v_{\\text{max}},pp_{\\text{com}})$ of a range proving system.\n\\item Output all generated public parameters and hash functions as $pp$.\n\\end{enumerate}\n\n\n\\subsection{\\texorpdfstring{$\\func{CreateKeys}$}{CreateKeys}}\n\nWe describe the construction of key types used in the protocol.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$\n\n\\textbf{Outputs:} Key tuple $(\\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{sk})$\n\n\\begin{enumerate}\n\\item Sample $s_1, s_2, r \\in \\F$ uniformly at random, and let $D = \\comm(0, r, 0)$ and $P_2 = \\comm(s_2, r, 0)$.\n\\item Set $\\addr_{\\text{in}} = (s_1, P_2)$.\n\\item Set $\\addr_{\\text{full}} = (s_1, s_2, D, P_2)$.\n\\item Set $\\addr_{\\text{sk}} = (s_1, s_2, r)$.\n\\item Output the tuple $(\\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{\\text{sk}})$.\n\\end{enumerate}\n\n\n\\subsection{\\texorpdfstring{$\\func{CreateAddress}$}{CreateAddress}}\n\nThis algorithm generates a \\textit{diversified} public address from an incoming view key.\nA given public address is privately and deterministically tied to an index called the \\textit{diversifier}.\nDiversified public addresses share the same set of keys for efficiency purposes, but are not linkable without non-public information.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, incoming view key $\\addr_{\\text{in}}$, diversifier $i \\in \\mathbb{N}$\n\n\\textbf{Outputs:} Diversified address $\\addr_{\\text{pk}}$\n\n\\begin{enumerate}\n\\item Parse the incoming view key $\\addr_{\\text{in}} = (s_1, P_2)$.\n\\item Compute the diversified address components:\n\\begin{align*}\nd &= \\func{SymEncrypt}(\\func{SymKeyGen}(s_1),i) \\\\\nQ_{1,i} &= s_1 \\hash_{\\text{div}}(d) \\\\\nQ_{2,i} &= \\comm(\\hash_{Q_2}(s_1,i),0,0) + P_2\n\\end{align*}\n\\item Set $\\addr_{\\text{pk}} = (d,Q_{1,i},Q_{2,i})$ and output this tuple.\n\\end{enumerate}\nNote that we drop the diversifier index $i$ from subsequent notation when referring to addresses in operations performed by entities other than the incoming view key holder, since such users are not provided this index and cannot compute it.\n\n\n\\subsection{\\texorpdfstring{$\\func{CreateCoin}$}{CreateCoin}}\n\nThis algorithm generates a new coin destined for a given public address.\nIt uses a type bit to determine if the value is intended to be publicly visible.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, destination public address $\\addr_{\\text{pk}}$, value $v \\in [0, v_{\\text{max}})$, memo $m$, type bit $b$\n\n\\textbf{Outputs:} Coin $\\func{Coin}$, nonce $k$\n\n\\begin{enumerate}\n\\item Parse the recipient address $\\addr_{\\text{pk}} = (d, Q_1, Q_2)$.\n\\item Sample a nonce $k \\in \\F$.\n\\item Compute the recovery key $K = \\hash_k(k)\\hash_{\\text{div}}(d)$.\n\\item Compute the serial number commitment $$S = \\comm(\\hash_{\\text{ser}}(k), 0, 0) + Q_2.$$\n\\item Generate the value commitment $C = \\com(v, \\hash_{\\text{val}}(k))$.\n\\item If $b=0$, generate a range proof $$\\Pi_{\\text{rp}} = \\func{RangeProve}(pp_{\\text{rp}},C;(v,\\hash_{\\text{val}}(k)).$$\n\\item If $b = 0$, set the recipient data $r = (v,d,k,m)$; otherwise, set $r = (d,k,m)$.\n\\item Generate an AEAD encryption key $k_{\\text{aead}} = \\func{AEADKeyGen}(\\hash_k(k)Q_1)$; encrypt the recipient data $$\\overline{r} = \\func{AEADEncrypt}(k_{\\text{aead}},\\texttt{r},r).$$\n\\item If $b=0$, output the coin $\\func{Coin} = (S, K, C, \\Pi_{\\text{rp}}, \\overline{r})$ and nonce $k$; otherwise, output the coin $\\func{Coin} = (S, K, C, v, \\overline{r})$ and nonce $k$.\n\\end{enumerate}\nThe case $b=0$ represents a coin with hidden value being generated in a spend transaction, while the case $b=1$ represents a coin with plaintext value being generated in a mint transaction.\n\nThe nonce $k$ is returned for use by other algorithms, but is not public.\n\n\n\\subsection{\\texorpdfstring{$\\func{Mint}$}{Mint}}\n\nThis algorithm generates new coins from either a consensus-determined mining process, or by consuming non-Spark outputs from a base layer with public value.\nNote that while such implementation-specific auxiliary data may be necessary for generating such a transaction and included, we do not specifically list this here.\nNotably, the coin value used in this algorithm is assumed to be the sum of all public input values as specified by the implementation.\n\n\\textbf{Inputs}:\n\\begin{itemize}\n    \\item Security parameter $\\lambda$ and public parameters $pp$\n    \\item A set of $t$ output coin public addresses, values, and memos: $$\\{\\addr_{\\text{pk},j}, v_j, m_j\\}_{j=0}^{t-1}$$\n\\end{itemize}\n\n\\textbf{Outputs}: Mint transaction $\\text{tx}_{\\text{mint}}$\n\n\\begin{enumerate}\n    \\item Generate a set $\\func{OutCoins} = \\{\\func{CreateCoin}(\\addr_{\\text{pk},j}, v_j, m_j, 1)\\}_{j=0}^{t-1}$ of output coins.\n    \\item Parse the output coin value commitments $\\{\\overline{C}_j\\}_{j=0}^{t-1}$ from $\\func{OutCoins}$, where each $\\overline{C}_j$ contains nonce $k_j$.\n    \\item Generate a representation proof for value assertion: $$\\Pi_{\\text{val}} = \\func{RepProve}\\left( pp_{\\text{rep}}, H, \\{ \\overline{C}_j - \\com(v_j,0) \\}_{j=0}^{t-1}; \\{\\hash_{\\text{val}}(k_j)\\}_{j=0}^{t-1} \\right)$$\n    \\item Output the mint transaction $\\func{tx}_{\\text{mint}} = (\\func{OutCoins}, \\Pi_{\\text{val}})$.\n\\end{enumerate}\n\n\n\\subsection{\\texorpdfstring{$\\func{Identify}$}{Identify}}\n\nThis algorithm allows a recipient (or designated entity) to determine if it controls a coin; if so, it computes the value, memo, and diversifier from the coin (in addition to the coin nonce).\nIt requires the incoming view key used to produce diversified addresses to do so.\nIf the coin is not destined for any diversified address, the algorithm returns failure.\n\nIt is assumed that the recipient has run the $\\func{Verify}$ algorithm on the transaction generating the coin being identified.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, incoming view key $\\addr_{\\text{in}}$, coin $\\func{Coin}$\n\n\\textbf{Outputs:} Value $v$, memo $m$, diversifier $i$, nonce $k$\n\n\\begin{enumerate}\n\\item Parse the incoming view key $\\addr_{\\text{in}} = (s_1, P_2)$.\n\\item If $\\func{Coin}$ was generated in a mint transaction, parse $\\func{Coin} = (S, K, C, v, \\overline{r})$; otherwise, parse $\\func{Coin} = (S, K, C, \\Pi_{\\text{rp}}, \\overline{r})$.\n\\item Generate an AEAD encryption key $k_{\\text{aead}} = \\func{AEADKeyGen}(s_1 K)$ and decrypt $$r = \\func{AEADDecrypt}(k_{\\text{aead}},\\texttt{r},\\overline{r});$$ if decryption fails, return failure.\n\\item If $\\func{Coin}$ was generated in a mint transaction, parse the recipient data $r = (d, k, m)$; otherwise, parse $r = (v, d, k, m)$.\n\\item Check that $K = \\hash_k(k)\\hash_{\\text{div}}(d)$, and return failure otherwise.\n\\item Check that $C = \\com(v,\\hash_{\\text{val}}(k))$, and return failure otherwise.\n\\item Decrypt the diversifier $i = \\func{SymDecrypt}(\\func{SymKeyGen}(s_1),d)$.\n\\item Check that $$S = \\comm(\\hash_{\\text{ser}}(k),0,0) + \\comm(\\hash_{Q_2}(s_1,i),0,0) + P_2,$$ and return failure otherwise.\n\\item Output $(v, m, i, k)$.\n\\end{enumerate}\n\n\n\\subsection{\\texorpdfstring{$\\func{Recover}$}{Recover}}\n\nThis algorithm allows a recipient (or designated entity) to determine if it controls a coin; if so, it computes the serial number, tag, value, memo, and diversifier from the coin (in addition to the coin nonce).\nIt requires the full view key used to produce diversified addresses to do so.\nIf the coin is not destined for any diversified address, the algorithm returns failure.\n\nIt is assumed that the recipient has run the $\\func{Verify}$ algorithm on the transaction generating the coin being recovered.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, full view key $\\addr_{\\text{full}}$, coin $\\func{Coin}$\n\n\\textbf{Outputs:} Serial number $s$, tag $T$, value $v$, memo $m$, diversifier $i$, nonce $k$\n\n\\begin{enumerate}\n\\item Parse the full view key $\\addr_{\\text{full}} = (s_1, s_2, D, P_2)$.\n\\item Arrange the corresponding incoming view key $\\addr_{\\text{in}} = (s_1, P_2)$.\n\\item Run $\\func{Identify}(\\addr_{\\text{in}},\\func{Coin}$ to obtain $(v, m, i, k)$, and return failure if this operation fails.\n\\item Compute the serial number $$s = \\hash_{\\text{ser}}(k) + \\hash_{Q_2}(s_1,i) + s_2$$ and tag $$T = (1/s)(U - D).$$\n\\item If $T$ has been constructed in any other valid recovery, return failure.\n\\item Output $(s, T, v, m, i, k)$.\n\\end{enumerate}\n\n\n\\subsection{\\texorpdfstring{$\\func{Spend}$}{Spend}}\n\nThis algorithm allows a recipient to generate a transaction that consumes coins it controls, and generates new coins destined for arbitrary public addresses.\nThe process is designed to be modular; in particular, only the full view key is required to generate the parallel one-out-of-many proof, which may be computationally expensive.\nThe use of spend keys is only required for the final Chaum-Pedersen proof step, which is of lower complexity.\n\nIt is assumed that the recipient has run the $\\func{Recover}$ algorithm on all coins that it wishes to consume in such a transaction.\n\n\\textbf{Inputs:}\n\\begin{itemize}\n    \\item Security parameter $\\lambda$ and public parameters $pp$\n    \\item A full view key $\\addr_{\\text{full}}$\n    \\item A spend key $\\addr_{\\text{sk}}$\n    \\item A set of $N$ input coins $\\func{InCoins}$ as part of a cover set\n    \\item For each $u \\in [0,w)$ coin to spend, the index in $\\func{InCoins}$, serial number, tag, value, and nonce: $(l_u, s_u, T_u, v_u, k_u)$\n    \\item An integer fee value $f \\in [0,v_{\\text{max}})$\n    \\item A set of $t$ output coin public addresses, values, and memos: $$\\{\\addr_{\\text{pk},j}, v_j, m_j\\}_{j=0}^{t-1}$$\n\\end{itemize}\n\n\\textbf{Outputs:} Spend transaction $\\text{tx}_{\\text{spend}}$\n\n\\begin{enumerate}\n    \\item Parse the required full view key component $D$ from $\\addr_{\\text{full}}$.\n    \\item Parse the spend key $\\addr_{\\text{sk}} = (s_1, s_2, r)$.\n    \\item Parse the cover set serial number commitments and value commitments $\\{(S_i, C_i)\\}_{i=0}^{N-1}$ from $\\func{InCoins}$.\n    \\item For each $u \\in [0,w)$:\n    \\begin{enumerate}\n        \\item Compute the serial number commitment offset: $$S_u' = \\comm(s_u, 0, -\\hash_{\\text{ser}'}(s_u, D)) + D$$\n        \\item Compute the value commitment offset: $$C_u' = \\com(v_u, \\hash_{\\text{val}'}(s_u, D))$$\n        \\item Generate a parallel one-out-of-many proof:\n        \\begin{multline*}\n        (\\Pi_{\\text{par}})_u = \\func{ParProve}(pp_{\\text{par}},\\{S_i, C_i\\}_{i=0}^{N-1}, S_u',C_u'; \\\\\n        (l_u, \\hash_{\\text{ser}'}(s_u, D), \\hash_{\\text{val}}(k) - \\hash_{\\text{val}'}(s_u, D)))\n        \\end{multline*}\n    \\end{enumerate}\n    \\item Generate a set $\\func{OutCoins} = \\{\\func{CreateCoin}(\\addr_{\\text{pk},j}, v_j, m_j, 0)\\}_{j=0}^{t-1}$ of output coins.\n    \\item Parse the output coin value commitments $\\{\\overline{C}_j\\}_{j=0}^{t-1}$ from $\\func{OutCoins}$, where each $\\overline{C}_j$ contains nonce $k_j$.\n    \\item Generate a representation proof for balance assertion:\n    \\begin{multline*}\n    \\Pi_{\\text{bal}} = \\func{RepProve}\\left( pp_{\\text{rep}}, H, \\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0); \\right. \\\\\n    \\left. \\sum_{u=0}^{w-1} \\hash_{\\text{val}'}(s_u,D) - \\sum_{j=0}^{t-1} \\hash_{\\text{val}}(k_j) \\right)\n    \\end{multline*}\n    \\item Let $\\mu = \\hash_{\\text{bind}}( \\func{InCoins}, \\func{OutCoins}, f, \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )$.\n    \\item Generate a modified Chaum-Pedersen proof, where we additionally bind $\\mu$ to the initial transcript:\n    \\begin{multline*}\n    \\Pi_{\\text{chaum}} = \\func{ChaumProve}((pp_{\\text{chaum}}, \\mu), \\{S_u', T_u\\}_{u=0}^{w-1}; \\\\\n    (\\{s_u, r, -\\hash_{\\text{ser}'}(s_u, D)\\}_{u=0}^{w-1}))\n    \\end{multline*}\n    \\item Output the tuple:\n    \\begin{multline*}\n    \\text{tx}_{\\text{spend}} = ( \\func{InCoins}, \\func{OutCoins}, f, \\\\\n    \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, \\Pi_{\\text{chaum}} \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )\n    \\end{multline*}\n\\end{enumerate}\nNote that it is possible to modify the balance proof to account for other input or output values not represented by coin value commitments, similarly to the handling of fees.\nThis observation can allow for the transfer of value into new coins without the use of a mint transaction, or a transfer of value to a transparent base layer.\nSuch transfer functionality is likely to introduce practical risk that is not captured by the protocol security model, and warrants thorough analysis.\n\n\n\\subsection{\\texorpdfstring{$\\func{Verify}$}{Verify}}\n\nThis algorithm assesses the validity of a transaction.\n\n\\textbf{Inputs:} either a mint transaction $\\text{tx}_{\\text{mint}}$ or a spend transaction $\\text{tx}_{\\text{spend}}$\n\n\\textbf{Outputs:} a bit that represents the validity of the transaction\n\nIf the input transaction is a mint transaction:\n\\begin{enumerate}\n    \\item Parse the transaction $\\text{tx}_{\\text{mint}} = (\\func{OutCoins}, \\Pi_{\\text{val}})$.\n    \\item Parse the output coin values serial number commitments, and value commitments $\\{(v_j, \\overline{S}_j, \\overline{C}_j)\\}_{j=0}^{t-1}$ from $\\func{OutCoins}$.\n    \\item For each $j \\in [0,t)$:\n    \\begin{enumerate}\n        \\item If $\\overline{S}_j$ appears in an output coin in this transaction or in any previously-verified transaction, output 0.\n        \\item Check that $v_j \\in [0,v_{\\text{max}})$, and output 0 if this fails.\n    \\end{enumerate}\n    \\item Check that $\\func{RepVerify}\\left( pp_{\\text{rep}}, \\Pi_{\\text{val}}, H, \\{\\overline{C}_j - \\com(v_j, 0)\\}_{j=0}^{t-1} \\right)$, and output 0 if this fails.\n    \\item Output 1.\n\\end{enumerate}\n\nIf the input transaction is a spend transaction:\n\\begin{enumerate}\n    \\item Parse the transaction:\n    \\begin{multline*}\n    \\text{tx}_{\\text{spend}} = ( \\func{InCoins}, \\func{OutCoins}, f, \\\\\n    \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, \\Pi_{\\text{chaum}} \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )\n    \\end{multline*}\n    \\item Parse the cover set serial number commitments and value commitments $\\{(S_i, C_i)\\}_{i=0}^{N-1}$ from $\\func{InCoins}$.\n    \\item Parse the output coin serial commitments, value commitments, and range proofs $\\{ \\overline{S}_j, \\overline{C}_j, (\\Pi_{\\text{rp}})_j \\}_{j=0}^{t-1}$ from $\\func{OutCoins}$.\n    \\item For each $u \\in [0,w)$:\n    \\begin{enumerate}\n        \\item Check that $T_u$ does not appear again in this transaction or in any previously-verified transaction, and output 0 if it does.\n        \\item Check that $\\func{ParVerify}(pp_{\\text{par}},(\\Pi_{\\text{par}})_u,\\{S_i,C_i\\}_{i=0}^{N-1},S_u',C_u')$, and output 0 if this fails.\n    \\end{enumerate}\n    \\item Compute the binding hash $\\mu$ as before, check that $$\\func{ChaumVerify}((pp_{\\text{chaum}},\\mu),\\Pi_{\\text{chaum}},\\{S_u',T_u\\}_{u=0}^{w-1}),$$ and output 0 if this fails.\n    \\item For each $j \\in [0,t)$:\n    \\begin{enumerate}\n        \\item If $\\overline{S}_j$ appears in an output coin in this transaction or in any previously-verified transaction, output 0.\n        \\item Check that $\\func{RangeVerify}(pp_{\\text{rp}},(\\Pi_{\\text{rp}})_j,C)$, and output 0 if this fails.\n    \\end{enumerate}\n    \\item Check that $f \\in [0,v_{\\text{max}})$, and output 0 if this fails.\n    \\item Check that $$\\func{RepVerify}\\left( pp_{\\text{rep}}, \\Pi_{\\text{bal}}, H, \\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0) \\right)$$ and output 0 if this fails.\n    \\item Output 1.\n\\end{enumerate}\n\n\n\\section{Multisignature Operations}\n\nIt is often useful to permit transactions requiring multiple parties to authorize; the parties may be mututally untrusting, and it may not be sufficient to rely on a separate trusted third party.\nIn this case, we require processes for distributed key and spend transaction generation that require either a set of specified parties or a threshold subset of a given size to complete.\nSpecifically, we describe a method for such signing groups to perform the $\\func{CreateKeys}$ and $\\func{Spend}$ algorithms to produce keys and spend transactions indistinguishable from others.\nThis method uses techniques from \\cite{musig,schnorr,schnorrwithschnorr}.\nWe defer a complete security analysis to future work.\n\nThroughout this section, suppose we have a group of $\\nu$ players who wish to collaboratively produce keys, and such that a specified threshold $1 \\leq t \\leq \\nu$ of the players is required to produce an authorizing proof spending coins directed to any address associated to the keys.\n\nFor the modified algorithms we present here, sample cryptographic hash functions $$\\hash_{\\text{pok}},\\hash_{s_1},\\hash_{s_2},\\hash_{\\rho},\\hash_{F},\\hash_{H}: \\{0,1\\}^* \\to \\F$$ uniformly at random.\n\n\n\\subsection{\\texorpdfstring{$\\func{CreateKeys}$}{CreateKeys}}\n\nTo produce key components, each player $1 \\leq \\alpha \\leq \\nu$ engages in the following two-round key generation process:\n\\begin{enumerate}\n    \\item Selects a set of coefficients $\\{a_{\\alpha,j}\\}_{j=0}^{t-1} \\subset \\F$ uniformly at random, and uses them to define the polynomial $f_\\alpha(x) = \\sum_{j=0}^{t-1} a_{\\alpha,j}x^j$.\n    \\item Selects view key shares $s_{1,\\alpha},s_{2,\\alpha} \\in \\F \\setminus \\{0\\}$ uniformly at random.\n    \\item Produces a proof of knowledge of $a_{\\alpha,0}$:\n    \\begin{enumerate}\n        \\item Chooses $k_\\alpha \\in \\F$ uniformly at random.\n        \\item Sets $R_\\alpha = k_\\alpha G$.\n        \\item Sets $c_\\alpha = \\hash_{\\text{pok}}(\\alpha,a_{\\alpha,0}G,R_\\alpha)$.\n        \\item Sets $\\mu_\\alpha = k_\\alpha + a_{\\alpha,0}c_\\alpha$.\n    \\end{enumerate}\n    \\item Produces a vector of commitments $C_\\alpha = \\{C_{\\alpha,j}\\}_{j=0}^{t-1} = \\{a_{\\alpha,j}G\\}_{j=0}^{t-1}$ to its coefficients.\n    \\item Sends the tuple $(R_\\alpha,\\mu_\\alpha,C_\\alpha,s_{1,\\alpha},s_{2,\\alpha})$ to all other players $1 \\leq \\beta \\neq \\alpha \\leq \\nu$.\n    \\item On receipt of a tuple $(R_\\beta,\\mu_\\beta,C_\\beta,s_{1,\\beta},s_{2,\\beta})$ from another player $\\beta$:\n    \\begin{enumerate}\n        \\item Checks that $s_{1,\\beta} \\neq 0$ and $s_{2,\\beta} \\neq 0$ and aborts otherwise.\n        \\item Verifies the proof of knowledge by checking that $$\\mu_\\beta G - \\hash_{\\text{pok}}(\\beta,C_{\\beta,0},R_\\beta)C_{\\beta,0} = R_\\beta$$ and aborting otherwise.\n    \\end{enumerate}\n    \\item For each $1 \\leq \\beta \\leq \\nu$, computes a player share $\\widehat{r}_{\\alpha,\\beta} = f_\\alpha(\\beta)$ and sends it to player $\\beta$.\n    \\item On receipt of a player share $\\widehat{r}_{\\beta,\\alpha}$ from another player $\\beta$, verifies the share by checking that $$\\sum_{j=0}^{t-1} \\alpha^jC_{\\beta,j} = \\widehat{r}_{\\beta,\\alpha}G$$ and aborting otherwise.\n    \\item Computes its private spend key share $r_\\alpha = \\sum_{\\beta=1}^\\nu \\widehat{r}_{\\beta,\\alpha}$ and full view key component $D = \\sum_{\\beta=1}^\\nu C_{\\beta,0}$.\n    \\item Computes the group view keys:\n    \\begin{align*}\n        s_1 &= \\sum_{\\beta=1}^\\nu \\hash_{s_1}(\\{s_{1,\\gamma}\\}_{\\gamma=1}^\\nu,\\beta)s_{1,\\beta} \\\\\n        s_2 &= \\sum_{\\beta=1}^\\nu \\hash_{s_2}(\\{s_{2,\\gamma}\\}_{\\gamma=1}^\\nu,\\beta)s_{2,\\beta}\n    \\end{align*}\n\\end{enumerate}\nUsing the tuple $(s_1,s_2,D)$, any player can additionally compute the full view key component $P_2 = \\comm(s_2,0,0) + D$.\nSince each player holds the aggregate incoming view key, it can compute public addresses using $\\func{CreateAddress}$ as needed.\n\nNote that each player should confirm that all other players have completed the key generation process before making addresses available to receive coins; otherwise, a malicious player might selectively fail to send its shares to all other players, meaning some players may be unable to properly compute their private spend key shares.\n\n\n\\subsection{\\texorpdfstring{$\\func{Precompute}$}{Precompute}}\n\nThe signing group can reduce the communication complexity of proof generation by precomputing and sharing sets of nonce data.\nEach future signing operation uses one such nonce set for each signing player, which cannot be reused.\nThe signing group can precompute as many nonce sets as needed for expected signing operations, and can perform this operation whenever additional nonce sets are required.\nIn particular, the group may wish to do so during the key generation process, where the added communication round may be less impactful than during later proof generation.\n\nTo precompute $\\pi$ sets of nonce data, each player $1 \\leq \\alpha \\leq \\nu$ engages in the following one-round process:\n\\begin{enumerate}\n    \\item For $0 \\leq k < \\pi$, it selects $d_{\\alpha,k}, e_{\\alpha,k} \\in \\F$ uniformly at random and defines $D_{\\alpha,k} = d_{\\alpha,k}G$ and $E_{\\alpha,k} = e_{\\alpha,k}G$.\n    \\item Generates a vector $L_\\alpha$ such that for $0 \\leq k < \\pi$, we have $L_{\\alpha,k} = (D_{\\alpha,k}, E_{\\alpha,k})$; that is, $L_{\\alpha}$ contains $\\pi$ nonce pairs.\n    \\item Sends $L_\\alpha$ to all other players.\n    \\item On receipt of a vector $L_\\beta$ from another player $\\beta$, checks that $D_{\\beta,k} \\neq 0$ and $E_{\\beta,k} \\neq 0$ for all $0 \\leq k < \\pi$, and aborts otherwise.\n\\end{enumerate}\n\n\n\n\\subsection{\\texorpdfstring{$\\func{Spend}$}{Spend}}\n\nBecause all players possess the aggregate full view key corresponding to public addresses, any player can use it to construct all transaction components except the modified Chaum-Pedersen proof.\nWe describe now how a threshold of $t$ signers collaboratively produce such a proof to authorize the spending of coins, with the following proof inputs (using our previous notation):\n$$\\{pp_{\\text{chaum}}, \\{S_u', T_u\\}_{u=0}^{w-1}; (\\{s_u, r, -\\hash_{\\text{ser}'}(s_u, D)\\}_{u=0}^{w-1})\\}$$\n\nFor the sake of notation convenience, we assume that the signing players are indexed $1 \\leq \\alpha \\leq t$.\nFurther, assume that each nonce list $L_\\alpha$ contains $k + 1 \\geq w$ unused nonces.\nWe also assume the context binding value $\\mu$ has been defined.\nEach such player $\\alpha$ engages in the following one-round process:\n\\begin{enumerate}\n    \\item Parses the next available set of nonces $\\{(D_{\\beta,k-u},E_{\\beta,k-u})\\}_{u=0}^{w-1}$ in each $L_\\beta$ for $1 \\leq \\beta \\leq t$ (and removes them from each list after use) to compute, for $0 \\leq u < w$, the following:\n    $$\\rho_u = \\hash_{\\rho}(\\{\\beta,D_{\\beta,k-u},E_{\\beta,k-u}\\}_{\\beta=1}^{t},\\mu,S_u',T_u)$$\n    \\item Sets the initial proof commitments:\n    \\begin{align*}\n        A_1 &= \\sum_{u=0}^{w-1} \\left( \\hash_F(\\rho_u)F + \\hash_H(\\rho_u)H + \\sum_{\\beta=1}^t \\left( D_{\\beta,k-u} + \\rho E_{\\beta,k-u} \\right) \\right) \\\\\n        \\{A_{2,u}\\}_{u=0}^{w-1} &= \\left\\{ \\hash_F(\\rho_u)T_u + \\sum_{\\beta=1}^t \\left( D_{\\beta,k-u} + \\rho E_{\\beta,k-u} \\right) \\right\\}\n    \\end{align*}\n    \\item Computes the challenge $c$ using the proof transcript as in the original $\\func{Spend}$ description.\n    \\item Computes its Lagrange coefficient $$\\lambda_\\alpha = \\prod_{\\beta=1,\\beta \\neq \\alpha}^t \\left( \\frac{\\beta}{\\beta-\\alpha} \\right)$$ and the response share $$t_{2,\\alpha} = \\sum_{u=0}^{w-1} (d_{\\alpha,k-u} + \\rho_u e_{\\alpha,k-u} + \\lambda_\\alpha r_\\alpha c^u),$$ and sends $t_{2,\\alpha}$ to the other signing players.\n    \\item On receipt of $t_{2,\\beta}$ from another player, checks that $$t_{2,\\beta}G = \\sum_{u=0}^{w-1} \\left( D_{\\beta,k-u} + \\rho_u E_{\\beta,k-u} + c^u\\lambda_{\\beta} \\sum_{\\gamma=1}^{\\nu}\\sum_{j=0}^{t-1} \\beta^j C_{\\gamma,j} \\right)$$ and aborts otherwise.\n    \\item On receipt of all $t_{2,\\beta}$ values, computes the proof responses:\n    \\begin{align*}\n        \\{t_{1,u}\\}_{u=0}^{w-1} &= \\{ \\hash_F(\\rho_u) + c^u s_u \\} \\\\\n        t_2 &= \\sum_{\\beta=1}^t t_{2,\\beta} \\\\\n        t_3 &= \\sum_{u=0}^{w-1} (\\hash_H(\\rho_u) - c^u \\hash_{\\text{ser}'}(s_u,D))\n    \\end{align*}\n\\end{enumerate}\n\n\n\\section{View Keys and Payment Proofs}\n\nThe key and proof structures in Spark enable flexible and useful functionality relating to transaction scanning, generation, and disclosure.\n\nThe incoming view key is used in $\\func{Identify}$ operations to determine when a coin is directed to an associated public address, and to determine the coin's value and associated memo data.\nThis permits two use cases of note.\nIn one case, blockchain scanning can be delegated to a device or service without delegating spend authority for identified coins.\nIn another case, wallet software in possession of a spend key can keep this key encrypted or otherwise securely stored during scanning operations, reducing key exposure risks.\n\nThe full view key is used in $\\func{Recover}$ operations to additionally compute the serial number and tag for coins directed to an associated public address.\nThese tags can be used to identify a transaction spending the coin.\nProviding this key to a third party permits identification of incoming transactions and detection of outgoing transactions, which additionally provides balance computation, without delegating spend authority.\nUsers like public charities may wish to permit public oversight of funds with this functionality.\nOther users may wish to provide this functionality to an auditor or accountant for bookkeeping purposes.\nIn the case where an address is used in threshold multisignature operations, a cosigner may wish to know if or when another cohort of cosigners has produced a transaction spending funds.\n\nFurther, the full view key is used in $\\func{Spend}$ to generate one-out-of-many proofs.\nSince the parallel one-out-of-many proof used in Spark can be computationally expensive, it may be unsuitable for generation by a computationally-limited device like a hardware wallet.\nProviding this key to a more powerful device enables easy generation of this proof (and other transaction components like range proofs), while ensuring that only the device holding the spend key can complete the transaction by generating the simple modified Chaum-Pedersen proof.\n\nPayment proofs, which we introduce in Appendix \\ref{app:payment}, allow for disclosure of data for individual coins.\nSpecifically, a payment proof asserts in zero knowledge that the prover knows the spend key used to authorize the transaction generating a given coin that is destined for a given public address.\nThe proof convinces a verifier that the holder of the incoming view key for the public address can successfully identify the coin, as well as provides the verifier with the value and memo for the coin.\nUnlike view keys, which provide broad visibility into transactions associated to a public address, a payment proof is limited to a single coin and can be bound to an arbitrary proof context to prevent replay.\n\nPayment proofs may be useful in a number of circumstances.\nFor example, a customer may issue a payment to a retailer, but fail to use the correct diversified address or memo required by the retailer to associate the payment to the customer's order.\nBy providing the retailer with a payment proof, the customer can assert that it produced a coin destined for the retailer's address.\nIn another use case, a business may wish to make public details of a donation to a charity without publicly disclosing its full view key.\nBy providing a payment proof, anyone can verify that the specified coin was destined for the charity's address and confirm the value and memo associated to the coin.\n\n\n\\section{Efficiency}\n\nIt is instructive to examine the efficiency of spend transactions in size, generation complexity, and verification complexity.\nIn addition to our previous notation for parameters, let $v_{\\text{max}} = 2^{64}$, so coin values and fees can be represented by $8$-byte unsigned integers.\nFurther, suppose coin memos are fixed at $M$ bytes in length, diversifiers are restricted to $I$ bytes in length, with a $16$-byte authentication tag; this is the case for the ChaCha20-Poly1305 authenticated symmetric encryption construction, for example \\cite{chachapoly}.\nAdditionally, the arguments in \\cite{schnorr} imply that Schnorr representation proofs can use truncated hash outputs for reduced proof size.\nTransaction size data for specific component instantiations is given in Table \\ref{table:size}, where we consider the size in terms of group elements, field elements, and other data.\nNote that we do not include input ambiguity set references in this data, as this depends on implementation-specific selection and representation criteria.\n\n\\begin{table}\n    \\caption{Spend transaction size by component}\n    \\label{table:size}\n    \\centering\n    \\begin{tabular}{|l|l|r|r|r|}\n        \\hline\n        \\textbf{Component} & \\textbf{Instantiation} & \\textbf{Size ($\\G$)} & \\textbf{Size ($\\F$)} & \\textbf{Size (bytes)} \\\\\n        \\hline\n        $f$ & & & & $8$ \\\\\n        $\\Pi_{\\text{rp}}$ & Bulletproofs+ & $2 \\lceil \\lg(64t) \\rceil + 3$ & $3$ & \\\\\n        $\\Pi_{\\text{bal}}$ & Schnorr (short)& & $1.5$ & \\\\\n        $\\Pi_{\\text{chaum}}$ & this paper & $w + 1$ & $w + 2$ & \\\\\n        \\hline\n        \\multicolumn{5}{|c|}{Input data ($w$ coins)} \\\\\n        \\hline\n        $(S',C')$ & & $2w$ & & \\\\\n        $\\Pi_{\\text{par}}$ & this paper & $(2m + 2)w$ & $[m(n-1) + 3]w$ & \\\\\n        \\hline\n        \\multicolumn{5}{|c|}{Output data ($t$ coins)} \\\\\n        \\hline\n        $(S,K,C)$ & & $3t$ & & \\\\\n        $\\overline{r}$ & ChaCha20-Poly1305 & & & $(8 + M + I + 16)t$ \\\\\n        \\hline\n    \\end{tabular}\n\\end{table}\n\nTo evaluate the verification complexity of spend transactions using these components, we observe that verification in constructions like the parallel one-out-of-many proving system in this paper, Bulletproof+ range proving system, Schnorr representation proving system, and modified Chaum-Pedersen proving system in this paper all reduce to single linear combination evaluations in $\\G$.\nBecause of this, proofs can be evaluated in batches if the verifier first weights each proof by a random value in $\\F$, such that distinct group elements need only appear once in the resulting weighted linear combination.\nNotably, techniques like that of \\cite{pippenger} can be used to reduce the complexity of such evaluations by up to a logarithmic factor.\nSuppose we wish to verify a batch of $B$ transactions, each of which spends $w$ coins and generates $t$ coins.\nTable \\ref{table:time} shows the verification batch complexity in terms of total distinct elements of $\\G$ that must be included in a linear combination evaluation.\n\n\\begin{table}\n    \\caption{Spend transaction batch verification complexity for $B$ transactions with $w$ spent coins and $t$ generated coins}\n    \\label{table:time}\n    \\centering\n    \\begin{tabular}{|l|r|}\n        \\hline\n        \\textbf{Component} & \\textbf{Complexity} \\\\\n        \\hline\n        Parallel one-out-of-many & $B[w(2m + 2) + 2n^m] + 2mn + 1$ \\\\\n        Bulletproofs+ & $B(t + 2\\lg(64t) + 3) + 128T + 2$ \\\\\n        Modified Chaum-Pedersen & $B(3w + 1) + 4$ \\\\\n        Schnorr & $B(w + t + 1) + 2$ \\\\\n        \\hline\n    \\end{tabular}\n\\end{table}\n\nWe further comment that the parallel one-out-of-many proving system presented in this paper may be further optimized in verification.\nBecause corresponding elements of the $\\{S_i\\}$ and $\\{V_i\\}$ input sets are weighted identically in the protocol verification equations, it may be more efficient (depending on implementation) to combine these elements with a sufficient weight prior to applying the proof-specific weighting identified above for batch verification.\nInitial tests using a variable-time curve library suggest significant reductions in verification time with this technique.\n\n\n\\section*{Acknowledgments}\n\nThe authors thank pseudonymous collaborator \\texttt{koe} for ongoing discussions during the development of this work.\nThe authors gratefully acknowledge Nikolas Kr\\\"{a}tzschmar for identifying an earlier protocol flaw relating to tag generation.\n\n\n\\bibliographystyle{splncs04}\n\\bibliography{main}\n\n\\appendix\n\n\n\\section{Modified Chaum-Pedersen Proving System}\n\\label{app:chaum}\n\nThe proving system is a tuple of algorithms $(\\func{ChaumProve},\\func{ChaumVerify})$ for the following relation:\n\\begin{multline*}\n\\left\\{ pp_{\\text{chaum}}, \\{S_i, T_i\\}_{i=0}^{l-1} \\subset \\G^2 ; (\\{x_i, y_i, z_i\\}_{i=0}^{l-1}) \\subset \\F^3 : \\right. \\\\\n\\left. \\forall i \\in [0,l), S_i = x_i F + y_i G + z_i H, U = x_i T_i + y_i G \\right\\}\n\\end{multline*}\nOur protocol uses a power-of-challenge technique inspired by a method used for aggregating Schnorr signatures \\cite{batchschnorr}.\nThe protocol proceeds as follows:\n\\begin{enumerate}\n    \\item The prover selects random $\\{r_i,s_i\\}_{i=0}^{l-1}, t \\in \\F$.\n    It computes the values\n    \\begin{align*}\n        A_1 &= \\sum_{i=0}^{l-1} r_i F + \\sum_{i=0}^{l-1} s_i G + tH \\\\\n        \\{A_{2,i}\\}_{i=0}^{l-1} &= \\{r_i T_i + s_i G\\}_{i=0}^{l-1}\n    \\end{align*}\n    and sends these values to the verifier.\n    \\item The verifier selects a random challenge $c \\in \\F$ and sends it to the prover.\n    \\item The prover computes responses\n    \\begin{align*}\n        \\{t_{1,i}\\}_{i=0}^{l-1} &= \\{r_i + c^{i+1} x_i\\}_{i=0}^{l-1} \\\\\n        t_2 &= \\sum_{i=0}^{l-1} (s_i + c^{i+1} y_i) \\\\\n        t_3 &= t + \\sum_{i=0}^{l-1} c^{i+1} z_i\n    \\end{align*}\n    and sends them to the verifier.\n    \\item The verifier accepts the proof if and only if $$A_1 + \\sum_{i=0}^{l-1} c^{i+1} S_i = \\sum_{i=0}^{l-1} t_{1,i} F + t_2 G + t_3 H$$ and $$\\sum_{i=0}^{l-1} (A_{2,i} + c^{i+1} U) = \\sum_{i=0}^{l-1} t_{1,i} T_i + t_2 G.$$\n\\end{enumerate}\n\nThis interactive protocol can be made non-interactive using the Fiat-Shamir technique, which replaces the verifier challenge $c$ with the output of a cryptographic hash function on transcript inputs.\nWe now prove that the protocol is complete, special sound, and special honest-verifier zero knowledge.\n\n\\begin{proof}\nCompleteness of the protocol follows by inspection.\n\nWe now show it is (l+1)-special sound by building a polynomial-time extractor as follows.\nGiven a statement and initial proof transcript $(A_1, \\{A_{2_i}\\}_{i=0}^{l-1})$, the verifier sends $l+1$ distinct challenge values $c_0, c_1, \\ldots, c_l$ and receives the corresponding transcript values $(\\{t^0_{1,i}\\}_{i=0}^{l-1}, t^0_2, t^0_3), \\ldots, (\\{t^l_{1,i}\\}_{i=0}^{l-1}, t^l_2, t^l_3)$ from the prover.\nFrom the first verification equation, we build the following linear system:\n\\begin{align*}\nA_1 + \\sum_{i=0}^{l-1} c_0^{i+1} S_i &= \\sum_{i=0}^{l-1} t^0_{1,i} F + t^0_2 G + t^0_3 H \\\\\nA_1 + \\sum_{i=0}^{l-1} c_1^{i+1} S_i &= \\sum_{i=0}^{l-1} t^1_{1,i} F + t^1_2 G + t^1_3 H \\\\\n&\\vdotswithin{=} \\\\\nA_1 + \\sum_{i=0}^{l-1} c_l^{i+1} S_i &= \\sum_{i=0}^{l-1} t^l_{1,i} F + t^l_2 G + t^l_3 H\n\\end{align*}\n\nSubtracting the first equation from the rest, we obtain another linear system:\n\\begin{gather}\n\\begin{aligned}\n\\label{eqn:chaum}\n\\sum_{i=0}^{l-1} (c_1^{i+1} - c_0^{i+1}) S_i &= \\sum_{i=0}^{l-1} (t^1_{1,i} - t^0_{1,i})F + (t^1_2 - t^0_2)G + (t^1_3 - t^0_3)H \\\\\n\\sum_{i=0}^{l-1} (c_2^{i+1} - c_0^{i+1}) S_i &= \\sum_{i=0}^{l-1} (t^2_{1,i} - t^0_{1,i})F + (t^2_2 - t^0_2)G + (t^2_3 - t^0_3)H \\\\\n&\\vdotswithin{=} \\\\\n\\sum_{i=0}^{l-1} (c_l^{i+1} - c_0^{i+1}) S_i &= \\sum_{i=0}^{l-1} (t^l_{1,i} - t^0_{1,i})F + (t^l_2 - t^0_2)G + (t^l_3 - t^0_3)H\n\\end{aligned}\n\\end{gather}\n\nFinally, we let the set $\\{x_i\\}_{i=0}^{l-1} \\subset \\F$ be defined through the following linear system:\n\\begin{align*}\n\\sum_{i=0}^{l-1} (c_1^{i+1} - c_0^{i+1})x_i &= \\sum_{i=0}^{l-1} (t^1_{1,i} - t^0_{1_i}) \\\\\n\\sum_{i=0}^{l-1} (c_2^{i+1} - c_0^{i+1})x_i &= \\sum_{i=0}^{l-1} (t^2_{1,i} - t^0_{1_i}) \\\\\n&\\vdotswithin{=} \\\\\n\\sum_{i=0}^{l-1} (c_l^{i+1} - c_0^{i+1})x_i &= \\sum_{i=0}^{l-1} (t^l_{1,i} - t^0_{1_i})\n\\end{align*}\nSince each challenge is uniformly distributed at random, the square coefficient matrix corresponding to the system has nonzero determinant except with negligible probability, and hence the system is solvable for all $\\{x_i\\}_{i=0}^{l-1}$.\nFurther, we can form similar linear systems to define corresponding $\\{y_i\\}_{i=0}^{l-1}$ and $\\{z_i\\}_{i=0}^{l-1}$ such that we let $S_i = x_i F + y_i G + z_i H$ and the equations in system \\ref{eqn:chaum} hold.\n\nIt remains to show that these solutions are unique; that is, that no $S_i$ has a different representation with coefficients $x_i',y_i',z_i'$ consistent with successful verification.\nIf this were the case, then we must have the polynomial equation $\\sum_{i=0}^{l-1} c^{i+1}(x_i - x_i') = 0$ in $c$; however, since $c$ is selected randomly by the verifier, all coefficients of the polynomial must (with overwhelming probability) be zero by the Schwartz-Zippel lemma.\nHence each $x_i = x_i'$ (and by the same reasoning, $y_i = y_i'$ and $z_i = z_i'$), and the extracted witness set is unique.\n\nTo show the protocol is special honest-verifier zero knowledge, we construct a valid simulator producing transcripts identically distributed to those of valid proofs.\nThe simulator chooses a random challenge $c \\in \\F$ and random values $\\{t_{1,i}\\}_{i=0}^{l-1}, t_2, t_3 \\in \\F$.\nIt also randomly selects $\\{A_{2,i}\\}_{i=1}^{l-1} \\in \\G$, and sets $$A_1 = \\sum_{i=0}^{l-1} t_{1,i} F + t_2 G + t_3 H - \\sum_{i=0}^{l-1} c^{i+1} S_i$$ and $$A_{2,0} = \\sum_{i=0}^{l-1} t_{1,i} T_i + t_2 G - \\sum_{i=1}^{l-1} A_{2,i} -  \\sum_{i=0}^{l-1} c^{i+1} U.$$\nThe forms of $A_1$ and $A_{2,0}$ are defined such that the verification equations hold, and therefore such a transcript will be accepted by an honest verifier.\nObserve that all transcript elements in a valid proof are independently distributed uniformly at random if the generators $F,G,H,U$ are independent, as are transcript elements produced by the simulator.\n\nThis completes the proof.\n\\end{proof}\n\n\n\\section{Parallel One-out-of-Many Proving System}\n\\label{app:parallel}\n\nThe proving system itself is a tuple of algorithms $(\\func{ParProve},\\func{ParVerify})$ for the following relation, where we let $N = n^m$:\n\\begin{multline*}\n\\left\\{ pp_{\\text{par}}, \\{S_k,V_k\\}_{i=0}^{N-1} \\subset \\G^2, S',V' \\in \\G ; l \\in \\mathbb{N}, (s,v) \\in \\F : \\right. \\\\\n\\left. 0 \\leq l < N, S_l - S' = \\comm(0,0,s), V_l - V' = \\com(0,v) \\right\\}\n\\end{multline*}\n\nLet $\\delta(i,j): \\mathbb{N}^2 \\to \\F$ be the Kronecker delta function.\nFor any integers $k$ and $j$ such that $0 \\leq k < N$ and $0 \\leq j < m$, let $k_j$ denote the $j$ digit of the $n$-ary decomposition of $k$.\nLet $\\func{MatrixCom}: \\F^{mn} \\times \\F^{mn} \\times \\F \\to \\G$ be an additively-homomorphic matrix commitment construction that commits to the entries of two matrices, and is perfectly hiding and computationally binding.\n\nThe protocol proceeds as follows, where we use some of the notation of \\cite{lelantus,triptych}:\n\\begin{enumerate}\n    \\item The prover selects $$r_A, r_B, \\{a_{j,i}\\}_{j=0,i=1}^{m-1,n-1} \\in \\F$$ uniformly at random, and, for each $j \\in [0,m)$, sets $$a_{j,0} = -\\sum_{i=1}^{n-1} a_{j,i}.$$\n    \\item The prover computes the following:\n    \\begin{align*}\n        A &\\equiv \\func{MatrixCom}\\left(\\{a_{j,i}\\}_{j,i=0}^{m-1,n-1}, \\{-a_{j,i}^2\\}_{j,i=0}^{m-1,n-1}, r_A\\right) \\\\\n        B &\\equiv \\func{MatrixCom}\\left(\\{\\delta(l_{j},i)\\}_{j,i=0}^{m-1,n-1}, \\lbrace a_{j,i}(1-2\\delta(l_j,i))\\rbrace_{j,i=0}^{m-1,n-1}, r_B\\right)\n    \\end{align*}\n    \\item For each $j \\in [0,m)$, the prover selects $\\rho_j, \\rho'_j \\in \\F$ uniformly at random, and computes the following:\n    \\begin{align*}\n        X_j &\\equiv \\sum_{k=0}^{N-1}p_{k,j}(S_k - S') + \\comm(0, 0, \\rho_j) \\\\\n        X'_j &\\equiv \\sum_{k=0}^{N-1}p_{k,j}(V_k - V') + \\com(0, \\rho'_j)\n    \\end{align*}\n    Here each $p_{k,j}$ is defined such that for all $k \\in [0,N)$ we have $$\\prod_{j=0}^{m-1} \\left( \\delta(l_j,k_j)x + a_{j,k_j} \\right) = \\delta(l,k)x^m + \\sum_{j=0}^{m-1} p_{k,j}x^j$$ for indeterminate $x$.\n    \\item The prover sends $A, B, \\{X_j, X'_j\\}_{j=0}^{m-1}$ to the verifier.\n    \\item The verifier selects $x \\in \\F$ uniformly at random and sends it to the prover.\n    \\item For each $j \\in [0,m)$ and $i \\in [1,n)$, the prover computes $f_{j,i} \\equiv \\delta(l_{j},i)x + a_{j,i}$ and the following values:\n    \\begin{align*}\n        z &\\equiv r_A + xr_B \\\\\n        z_S &\\equiv sx^m -  \\sum_{j=0}^{m-1}\\rho_j x^j \\\\\n        z_V &\\equiv vx^m - \\sum_{j=0}^{m-1}\\rho'_j x^j\n    \\end{align*}\n    \\item The prover sends $\\{f_{j,i}\\}_{j=0,i=1}^{m-1,n-1}, z, z_S, z_V$ to the verifier.\n    \\item For each $j \\in [0,m)$, the verifier sets $f_{j,0} \\equiv x - \\sum_{i=1}^{n-1} f_{j,i}$ and accepts the proof if and only if\n    $$A + xB = \\func{MatrixCom}\\left(\\lbrace f_{j,i} \\rbrace_{j,i=0}^{m-1,n-1}, \\lbrace f_{j,i}(x - f_{j,i})\\rbrace_{j,i=0}^{m-1,n-1}, z\\right)$$\n    and\n    \\begin{align*}\n        \\sum_{k=0}^{N-1} \\left(\\prod_{j=0}^{m-1} f_{j,k_j}\\right)(S_k - S') - \\sum_{j=0}^{m-1} x^j X_j &= \\comm(0, 0, z_S) \\\\\n        \\sum_{k=0}^{N-1} \\left(\\prod_{j=0}^{m-1} f_{j,k_j}\\right)(V_k - V') - \\sum_{j=0}^{m-1} x^j X'_j &= \\com(0, z_V)\n    \\end{align*}\n    are true.\n\\end{enumerate}\n\nThis interactive protocol can be made non-interactive using the Fiat-Shamir technique, which replaces the verifier challenge $x$ with the output of a cryptographic hash function on transcript inputs.\n\nWe now prove that the above protocol is complete, special sound, and honest-verifier zero knowledge.\nThe proofs proceed similarly to those of \\cite{bootle,lelantus,triptych}.\n\n\\begin{proof}\n    Completeness of the protocol follows by straightforward algebra.\n\n    To show that the protocol is special honest-verifier zero knowledge, we construct a simulator that, when provided a valid statement and random verifier challenge $x$, produces a proof transcript identically distributed to that of a real proof.\n\n    To produce our simulated transcript on random $x$, the simulator samples $$B,\\{X_j,X'_j\\}_{j=1}^{m-1} \\in \\G$$ and $$z,z_S,z_V,\\{f_{j,i}\\}_{j=0,i=1}^{m-1,n-1} \\in \\F$$ uniformly at random.\n    It defines\n    $$f_{j,0} = x - \\sum_{i=1}^{n-1} f_{j,i}$$\n    for each $j \\in [0,m)$, and sets\n    $$A = \\func{MatrixCom}\\left(\\lbrace f_{j,i} \\rbrace_{j,i=0}^{m-1,n-1}, \\lbrace f_{j,i}(x - f_{j,i})\\rbrace_{j,i=0}^{m-1,n-1}, z\\right) - xB$$\n    as well.\n    It uses the final two verification equations to compute $X_0$ and $X'_0$:\n    \\begin{alignat*}{1}\n        X_0 &= \\sum_{k=0}^{N-1} \\left(\\prod_{j=0}^{m-1} f_{j,k_j}\\right)(S_k - S') - \\sum_{j=1}^{m-1} x^j X_j - \\comm(0, 0, z_S) \\\\\n        X'_0 &= \\sum_{k=0}^{N-1} \\left(\\prod_{j=0}^{m-1} f_{j,k_j}\\right)(V_k - V') - \\sum_{j=1}^{m-1} x^j X'_j - \\com(0, z_V)\n    \\end{alignat*}\n\n    Since the challenge $x$ is sampled uniformly at random by construction, the commitment constructions are perfectly hiding, $\\{\\rho_j,\\rho'_j\\}_{j=0}^{m-1}$ are sampled uniformly at random in a real proof, and the decisional Diffie-Hellman problem is hard in $\\G$, all proof elements in both the simulation and real proofs are either independently uniformly distributed at random or uniquely determined by other transcript elements.\n    Hence the protocol is special honest-verifier zero knowledge.\n\n    We now show that the protocol is $(m+1)$-special sound for $m > 1$.\n    That is, we construct an extractor that, when presented with a set of $m+1$ distinct challenges and corresponding responses to the same initial statement, produces a set of extracted witness elements consistent with the statement.\n    Consider a collection of $m+1$ distinct challenges $\\{x_\\iota\\}_{\\iota=0}^m$, and corresponding valid responses:\n    $$\\left\\{ \\{f_{j,i}^{(\\iota)}\\}_{j=0,i=1}^{m-1,n-1}, z^{(\\iota)}, z_S^{(\\iota)}, z_V^{(\\iota)} \\right\\}_{\\iota=0}^m$$\n    Successful verification on indices $\\iota \\in \\{0,1\\}$ gives the following:\n    \\begin{multline*}\n        (x^{(0)} - x^{(1)})B = \\func{MatrixCom}\\left( \\{f_{j,i}^{(0)} - f_{j,i}^{(1)}\\}_{j,i=0}^{m-1,n-1}, \\right. \\\\\n        \\left. \\{f_{j,i}^{(0)}(x^{(0)} - f_{j,i}^{(0)}) - f_{j,i}^{(1)}(x^{(1)} - f_{j,i}^{(1)})\\}_{j,i=0}^{m-1,n-1}, z^{(0)} - z^{(1)} \\right)\n    \\end{multline*}\n    For all $j \\in [0,m)$ and $i \\in [0,n)$, if we let\n    $$b_{j,i} = \\frac{f_{j,i}^{(0)} - f_{j,i}^{(1)}}{x^{(0)} - x^{(1)}}$$\n    and\n    $$c_{j,i} = \\frac{f_{j,i}^{(0)}(x^{(0)} - f_{j,i}^{(0)}) - f_{j,i}^{(1)}(x^{(1)} - f_{j,i}^{(1)})}{x^{(0)} - x^{(1)}}$$\n    and\n    $$r_B = \\frac{z^{(0)} - z^{(1)}}{x^{(0)} - x^{(1)}},$$\n    then we can express\n    $$B = \\func{MatrixCom}\\left( \\{b_{j,i}\\}_{j,i=0}^{m-1,n-1}, \\{c_{j,i}\\}_{j,i=0}^{m-1,n-1}, r_B \\right).$$\n    If for $j \\in [0,m)$ and $i \\in [0,n)$ we further define\n    $$a_{j,i} = f_{j,i}^{(0)} - x^{(0)}b_{i,j}$$\n    and\n    $$d_{i,j} = f_{j,i}^{(0)}(x^{(0)} - f_{j,i}^{(0)}) - x^{(0)}c_{j,i}$$\n    and $r_A = z^{(0)} - x^{(0)}r_B$, then we can express\n    $$A = \\func{MatrixCom}\\left( \\{a_{j,i}\\}_{j,i=0}^{m-1,n-1}, \\{d_{j,i}\\}_{j,i=0}^{m-1,n-1}, r_A \\right)$$\n    as well.\n    Observe that since the commitment construction is computationally binding, for all $\\iota \\in [0,m]$ we must have $b_{j,i}x^{(\\iota)} + a_{j,i} = f_{j,i}^{(\\iota)}$ and $c_{j,i}x^{(\\iota)} + d_{j,i} = f_{j,i}^{(\\iota)}(x^{(\\iota)} - f_{j,i}^{(\\iota)})$ for $j \\in [0,m)$ and $i \\in [0,n)$.\n    This implies in particular that for $\\iota \\in \\{0,1,2\\}, j \\in [0,m), i \\in [0,n)$ we have\n    $$c_{j,i}x^{(\\iota)} + d_{j,i} = b_{j,i}(1 - b_{j,i})x^{(\\iota) 2} + (1 - 2b_{j,i})a_{j,i}x^{(\\iota)} - a_{j,i}^2$$\n    and hence $b_{j,i}(1 - b_{j,i}) = 0$, so each $b_{j,i} \\in \\{0,1\\}$.\n\n    We also have, by construction, that\n    $$x^{(\\iota)} = \\sum_{i=0}^{n-1} f_{j,i}^{(\\iota)} = x^{(\\iota)} \\sum_{i=0}^{n-1} b_{j,i} + \\sum_{i=0}^{n-1} a_{j,i}$$\n    for $\\iota \\in [0,m], j \\in [0,m)$, so $\\sum_{i=0}^{n-1} b_{j,i} = 1$.\n    This means we can extract $l \\in [0,N)$ such that each $b_{j,i} = \\delta(l_j,i)$.\n\n    Now if we define for each $k \\in [0,N)$ the polynomial\n    $$p_k(x) = \\prod_{j=0}^{m-1} \\left[ \\delta(l_j,k_j)x + a_{j,k_j} \\right]$$\n    in $x$, we have $\\deg(p_k) = m$ if and only if $k = l$.\n    Verification can therefore be expressed as\n    \\begin{align*}\n        x^{(\\iota)m}(S_l - S') - \\sum_{j=0}^{m-1} x^{(\\iota)j} \\overline{X}_j &= \\comm(0,0,z_S^{(\\iota)}) \\\\\n        x^{(\\iota)m}(V_l - V') - \\sum_{j=0}^{m-1} x^{(\\iota)j} \\overline{X}'_j &= \\com(0,0,z_V^{(\\iota)})\n    \\end{align*}\n    for $\\iota \\in [0,m]$, where the sets $\\{\\overline{X}_j\\}_{j=0}^{m-1}$ and $\\{\\overline{X}'_j\\}_{j=0}^{m-1}$ can be uniquely derived.\n    Consider a Vandermonde matrix $V$ such that the $\\iota$ row is the vector $(1, x^{(\\iota)}, \\ldots, x^{(\\iota)m})$, and note since each challenge is distinct, we have $\\det(V) \\neq 0$ with high probability, so the rows of $V$ span $\\F^{m+1}$.\n    This means we can find $\\{\\theta_\\iota\\}_{\\iota=0}^m$ such that the equation\n    $$\\sum_{\\iota=0}^m \\theta_\\iota x^{(\\iota)j} = \\delta(j,m)$$\n    holds for $j \\in [0,m]$.\n\n    We can therefore build a linear combination of each of the two above verification equations, taking advantage of the Vandermonde-derived weights:\n    \\begin{align*}\n        S_l - S' &= \\sum_{\\iota=0}^m \\theta_\\iota x^{(\\iota)m}(S_l - S') + \\sum_{\\iota=0}^m \\theta_\\iota \\left(x^{(\\iota)j}\\overline{X}_j\\right) = \\comm\\left(0, 0, \\sum_{\\iota=0}^m \\theta_\\iota z_S^{(\\iota)}\\right) \\\\\n        V_l - V' &= \\sum_{\\iota=0}^m \\theta_\\iota x^{(\\iota)m}(S_l - S') + \\sum_{\\iota=0}^m \\theta_\\iota \\left(x^{(\\iota)j}\\overline{X}'_j\\right) = \\com\\left(0, \\sum_{\\iota=0}^m \\theta_\\iota z_V^{(\\iota)}\\right)\n    \\end{align*}\n    These equations provide the remaining extractions\n    $$s = \\sum_{\\iota=0}^m \\theta_\\iota z_S^{(\\iota)}$$\n    and\n    $$v = \\sum_{\\iota=0}^m \\theta_\\iota z_V^{(\\iota)}$$\n    such that $S_l - S' = \\comm(0,0,s)$ and $V_l - V' = \\com(0,v)$, which completes the proof.\n\\end{proof}\n\n\\section{Payment System Security}\n\\label{app:security}\n \nZerocash \\cite{zerocash} established a robust security framework for decentralized anonymous payment (DAP) scheme security that captures a realistic threat model with powerful adversaries who are permitted to add malicious coins into transactions' input ambiguity sets, control the choice of transaction inputs, and produce arbitrary transactions to add to a ledger.\nHere we formally prove Spark's security within a related (but modified) security model; proofs follow somewhat similarly to that of \\cite{zerocash}.\n\nThe DAP construction is a tuple of algorithms\n\\begin{multline*}\n(\\func{Setup}, \\func{CreateKeys}, \\func{CreateAddress}, \\func{CreateCoin}, \\\\\n\\func{Mint}, \\func{Identify}, \\func{Recover}, \\func{Spend}, \\func{Verify})\n\\end{multline*}\nthat is secure if it satisfies properties of completeness, balance, non-malleability, and ledger indistinguishability.\n\nEach security property is formalized as a game between a polynomial-time adversary $\\mathcal{A}$ and a challenger $\\mathcal{C}$, where in each game the behavior of honest parties is simulated via an oracle $\\oracle$.\nThe oracle $\\oracle$ maintains a ledger $L$ of transactions and provides an interface for executing the $\\func{CreateAddress}$, $\\func{Mint}$, and $\\func{Spend}$ algorithms.\nTo simulate behavior from honest parties, $\\mathcal{A}$ passes a query to $\\mathcal{C}$, which makes sanity checks and then proxies the queries to $\\oracle$, returning the responses to $\\mathcal{A}$ as needed.\nFor $\\func{CreateAddress}$ queries, the oracle first runs the $\\func{CreateKeys}$ protocol algorithm, then calls $\\func{CreateAddress}$ using the resulting incoming view key and a randomly-selected diversifier index, and finally returns the public address $\\addr_{\\text{pk}}$.\nFor $\\func{Mint}$ queries, the adversary specifies the value, memo, and destination public address for the transaction, and the resulting transaction is produced and returned if the inputs are semantically valid.\nFor $\\func{Spend}$ queries, the adversary specifies the input coins to be consumed, as well as the values, memos, and destination public addresses for the transaction, and the resulting transaction is produced after coin recovery if the inputs are semantically valid, all consumed coins are validly controlled by an address produced by the oracle, and all consumed coins are unspent according to the ledger state.\nThe oracle $\\oracle$ also provides an $\\func{Insert}$ query that allows the adversary to insert arbitrary and potentially malicious $\\text{tx}_{\\text{mint}}$ or $\\text{tx}_{\\text{spend}}$ transactions into the ledger $L$, provided they are semantically valid and pass verification by the oracle.\n\nFor each security property, we say the DAP satisfies the property if the adversary can win the corresponding game with only negligible probability.\n\nWe now state a lemma that will be useful when examining the security of our construction.\n\n\\begin{lemma}\\label{lem:extract}\n    Given a ledger, two otherwise valid spend transactions reveal the same tag only if there exist coins with serial commitments $S_1,S_2$ produced in previous valid transactions and an extractor that produces representations of the following form:\n    \\begin{alignat*}{1}\n        S_1 &= \\comm(x,y,\\beta_1) \\\\\n        S_2 &= \\comm(x,y,\\beta_2)\n    \\end{alignat*}\n\\end{lemma}\n\n\\begin{proof}\n    Let $T$ be the tag common to the two spend transactions.\n    Each transaction has a valid modified Chaum-Pedersen proof.\n    One transaction's valid proof yields statement values $T,S_1' \\in \\G$ and witness values $x_1,y_1,z_1 \\in \\F$ such that $U = x_1 T + y_1 G$ and $S_1' = x_1 F + y_1 G + z_1 H$.\n    Similarly, the other transaction's valid proof yields statement values $T,S_2' \\in \\G$ and witness values $x_2,y_2,z_2 \\in \\F$ such that $U = x_2 T + y_2 G$ and $S_2' = x_2 F + y_2 G + z_2 H$.\n    Since $U$ and $G$ are independent and Pedersen commitments are computationally binding, we must have (except with negligible probability) that $x_1 = x_2 = x$ and $y_1 = y_2 = y$.\n    Hence $S_1' = xF + yG + z_1 H$ and $S_2' = xF + yG + z_2 H$.\n\n    Each transaction further has a valid parallel one-of-many proof.\n    From the first transaction's proof we have (by index extraction referencing an element of its input cover set) a group element $S_1 \\in \\G$ and scalar $\\alpha_1 \\in \\F$ such that $S_1 - S_1' = \\alpha_1 H$.\n    For the second proof, we similarly have $S_2 \\in \\G$ and $\\alpha_2 \\in \\F$ such that $S_2 - S_2' = \\alpha_2 H$.\n\n    This means in particular that $$S_1 = xF + yG + (z_1 + \\alpha_1)H$$ and $$S_2 = xF + yG + (z_2 + \\alpha_2)H$$ by combining these results.\n    Since transaction validity requires all input cover set elements to exist as outputs of previous valid transactions, we have extracted representations of the desired form by setting $\\beta_1 = z_1 + \\alpha_1$ and $\\beta_2 = z_2 + \\alpha_2$.\n\\end{proof}\nObserve that the result also holds for duplicate tags revealed in the same (otherwise valid) transaction, with almost identical reasoning.\n\n\\subsection{Completeness}\n\nCompleteness requires that no bounded adversary can prevent an honest user from spending a coin.\nSpecifically, this means that if the user is able to identify a coin using its incoming view key, then it can recover the coin using its full view key and generate a valid spend transaction consuming the coin using its spend key.\n\nTo see why this property holds, note that by construction, if an honest user is unable to produce a spend transaction for a coin with serial commitment $S$ that it has recovered, the corresponding tag $T$ must appear in a previous valid transaction.\nThe identified coin $S$ must be a commitment of the form $S = \\comm(s,r,0)$ for serial number $s$ and spend key component $r$ according to the $\\func{Identify}$ definition.\nBy Lemma \\ref{lem:extract}, any previous transaction revealing $T$ must consume a coin with serial commitment $\\overline{S} = \\comm(s,r,z)$ for $z \\neq 0$ (since coins must have unique serial commitments).\nSince the user cannot have identified $\\overline{S}$ because $z$ is nonzero, it did not generate the transaction consuming $\\overline{S}$, a contradiction since that transaction implies knowledge of the spend key $r$ by extraction.\n\n\n\\subsection{Balance}\n\nBalance requires that no bounded adversary $\\mathcal{A}$ can control more coins than are minted or spent to it.\nIt is formalized by a $\\func{BAL}$ game.\nThe adversary $\\mathcal{A}$ adaptively interacts with $\\mathcal{C}$ and the oracle with queries, and at the end of the interaction outputs a set of coins $\\func{AdvCoins}$.\nLetting $\\func{ADDR}$ be set of all addresses of honest users generated by $\\func{CreateAddress}$ queries, $\\mathcal{A}$ wins the game if\n$$v_{\\text{unspent}} + v_{\\mathcal{A} \\to \\func{ADDR}} > v_{\\text{mint}} + v_{\\func{ADDR} \\to \\mathcal{A}},$$\nwhich implies that the total value the adversary can spend or has spent already is greater than the value it has minted or received.\nHere:\n\\begin{itemize}\n    \\item $v_{\\text{unspent}}$ is the total value of unspent coins in $\\func{AdvCoins}$;\n    \\item $v_{\\text{mint}}$ is the total value minted by $\\mathcal{A}$ to itself through $\\func{Mint}$ or $\\func{Insert}$ queries;\n    \\item $v_{\\func{ADDR} \\xrightarrow{} \\mathcal{A}}$ is the total value of coins received by $\\mathcal{A}$ from addresses in $\\func{ADDR}$; and\n    \\item $v_{\\mathcal{A} \\xrightarrow{} \\func{ADDR}}$ is the total value of coins sent by the adversary to the addresses in $\\func{ADDR}$.\n\\end{itemize}\nWe say a DAP scheme $\\Pi$ is $\\func{BAL}$-secure if the adversary $\\mathcal{A}$ wins the game $\\func{BAL}$ only with negligible probability:\n$$\\text{Pr}[\\func{BAL}(\\Pi, \\mathcal{A}, \\lambda) = 1] \\leq \\text{negl}(\\lambda)$$\n\nAssume the challenger maintains an extra augmented ledger $(L, \\vec{a})$ where each $a_i$ contains secret data from transaction $\\text{tx}_i$ in $L$.\nIn that case where $\\text{tx}_i$ was produced by a query from $\\mathcal{A}$ to the challenger $\\mathcal{C}$, $a_i$ contains all secret data used by $\\mathcal{C}$ to produce the transaction.\nIf instead $\\text{tx}_i$ was produced by a direct $\\func{Insert}$ query from $\\mathcal{A}$, $a_i$ consists of all extracted witness data from proofs contained in the transaction.\nThe resulting augmented ledger $(L, \\vec{a})$ is balanced if the following conditions are true:\n\\begin{enumerate}\n    \\item\\label{cond:distinct} Each valid spend transaction $\\text{tx}_{\\text{spend},k}$ in $(L, \\vec{a})$ consumes distinct coins, and each consumed coin is the output of a valid $\\text{tx}_{\\text{mint},i}$ or $\\text{tx}_{\\text{spend},j}$ transaction for some $i < k$ or $j < k$.\n    This requirement implies that all transactions spend only valid coins, and that no coin is spent more than once within the same valid transaction.\n    \n    \\item\\label{cond:multiple} No two valid spend transactions in $(L, \\vec{a})$ consume the same coin.\n    This implies no coin is spent through two different transactions.\n    Together with the first requirement, this implies that each coin is spent at most once.\n    \n    \\item\\label{cond:value} For each $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ consuming input coins with value commitments $\\{C_u\\}_{u=0}^{w-1}$, for each $u \\in [0,w)$:\n    \\begin{itemize}\n        \\item If $C_u$ is the output of a valid mint transaction with augmented ledger witness $a'$, then the value of $C_u$ contained in $a'$ is the same as the corresponding value contained in $a$ for the value commitment offset $C_u'$.\n        \\item If $C_u$ is the output of a valid spend transaction with augmented ledger witness $a'$, then the value of $C_u$ contained in $a'$ is the same as the corresponding value contained in $a$ for the value commitment offset $C_u'$.\n    \\end{itemize}\n    This implies that values are maintained between transactions.\n    \n    \\item\\label{cond:balance} For each $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ with fee $f$ that consumes input coins with value commitment offsets $\\{C_u'\\}_{u=0}^{w-1}$ and generates coins with value commitments $\\{\\overline{C}_j\\}_{j=0}^{t-1}$, $a$ contains values $\\{v_u\\}_{u=0}^{w-1}$ and $\\{\\overline{v}_j\\}_{j=0}^{t-1}$ corresponding to the commitments such that the balance equation\n    $$\\sum_{u=0}^{w-1} v_u = \\sum_{j=0}^{t-1} \\overline{v}_j + f$$\n    holds.\n    For each $(\\text{tx}_{\\text{mint}}, a)$ in $(L, \\vec{a})$ generating coins with value commitments $\\{\\overline{C}_j\\}_{j=0}^{t-1}$ and public values $\\{\\overline{v}_j\\}_{j=0}^{t-1}$, $a$ contains values $\\{\\overline{v}'_j\\}_{j=0}^{t-1}$ corresponding to the commitments such that $\\overline{v}_j = \\overline{v}'_j$ for all $j \\in [0,t)$.\n    This implies that values cannot be created arbitrarily.\n    \n    \\item\\label{cond:honest} For each $\\text{tx}_{\\text{spend}}$ in $(L, \\vec{a})$ inserted by $\\mathcal{A}$ through an $\\func{Insert}$ query, each consumed coin in $\\text{tx}_{\\text{spend}}$ is not recoverable by any address in $\\func{ADDR}$.\n    This implies that the adversary cannot generate a transaction consuming coins it does not control.\n\\end{enumerate}\nIf these five conditions hold, then $\\mathcal{A}$ did not spend or control more money than was previously minted or spent to it, and the inequality\n$$v_{\\text{mint}} + v_{\\func{ADDR} \\to \\mathcal{A}} \\leq v_{\\text{unspent}} + v_{\\mathcal{A} \\to \\func{ADDR}}$$\nholds.\nWe now prove that Spark is $\\func{BAL}$-secure under this definition.\n\n\\begin{proof}\nBy way of contradiction, assume the adversary $\\mathcal{A}$ interacts with $\\mathcal{C}$ leading to a non-balanced augmented ledger $(L, \\vec{a})$ with non-negligible probability; then at least one of the five conditions described above is violated with non-negligible probability:\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:distinct}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition 1 is non-negligible.\nEach $\\text{tx}_{\\text{spend}}$ generated by a non-$\\func{Insert}$ oracle query satisfies this condition already, so there must exist a transaction $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ inserted by $\\mathcal{A}$.\n\nSuppose there exist inputs $u_1,u_2 \\in [0,w)$ of $\\text{tx}_{\\text{spend}}$ that consume the same coin with serial commitment $S$.\nValidity of the modified Chaum-Pedersen proof $\\Pi_{\\text{chaum}}$ gives extracted openings $S_{u_1}' = s_{u_1} F + r_{u_1} G + y_{u_1} H$ and $S_{u_2}' = s_{u_2} F + r_{u_2} G + y_{u_2} H$ and tag representations such that $U = s_{u_1} T_{u_1} + r_{u_1} G$ and $U = s_{u_2} T_{u_2} + r_{u_2} G$.\nBecause transaction validity implies $T_{u_1} \\neq T_{u_2}$, we must have $(s_{u_1},r_{u_1}) \\neq (s_{u_2},r_{u_2})$.\nValidity of the corresponding parallel one-out-of-many proofs $(\\Pi_{\\text{par}})_{u_1}$ and $(\\Pi_{\\text{par}})_{u_2}$ yields indices (corresponding to the same input set group element $S$) and discrete logarithm extractions such that $S - S_{u_1}' = x_{u_1} H$ and $S - S_{u_2}' = x_{u_2} H$.\nThis means\n$$S = \\comm(s_{u_1},r_{u_1},x_{u_1}+y_{u_1}) = \\comm(s_{u_2},r_{u_2},x_{u_2}+y_{u_2}),$$\na contradiction since the commitment scheme is computationally binding.\n\nThe second possibility for violation of the condition is that the transaction $\\text{tx}_{\\text{spend}}$ consumes a coin that is not generated in any previous valid transaction.\nThis follows immediately using similar reasoning as above, since transaction validity asserts knowledge of an opening to a commitment contained in the input set, all of which must have been previously generated in valid transactions by definition.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:multiple}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:multiple} is non-negligible.\nThis means the augmented ledger $(L, \\vec{a})$ contains two valid spend transactions consuming the same coin but producing distinct tags.\nSimilarly to the previous argument, this implies distinct openings of the coin serial number commitment, which is a contradiction.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:value}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:value} is non-negligible.\nLet $C$ be the value commitment of the coin consumed by an input of $\\text{tx}_{\\text{spend}}$ and generated in a previous transaction (of either type) in $(L, \\vec{a})$.\nSince the generating transaction is valid, we have an extracted opening $C = vG + aH$ from either the value proof (in a mint transasction) or the range proof (in a spend transaction).\nValidity of the corresponding parallel one-out-of-many proof in $\\text{tx}_{\\text{spend}}$ gives an extracted discrete logarithm $C - C' = xH$, where $C'$ is the input's value commitment offset.\nBut this immediately gives $C' = vG + (a - x)H$, a contradiction since the commitment scheme is binding.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:balance}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:balance} is non-negligible.\nIf the augmented ledger $(L, \\vec{a})$ contains a spend transaction that violates the balance equation, this immediately implies a break in the commitment binding property since the corresponding balance proof $\\Pi_{\\text{bal}}$ is valid, which is a contradiction.\nIf instead the augmented ledger $(L, \\vec{a})$ contains a mint transaction that violates the balance requirement, this immediately implies a break in the commitment binding property since the corresponding value proof $\\Pi_{\\text{val}}$ is valid, again a contradiction.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:honest}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:honest} is non-negligible.\nThat is, $\\mathcal{A}$ produces a spend transaction $\\text{tx}_{\\text{spend}}$ by an $\\func{Insert}$ question that is valid on the augmented ledger $(L, \\vec{a})$ and consumes a coin corresponding to a coin serial number commitment $S$ that can be recovered by a public address $(d, Q_1, Q_2) \\in \\func{ADDR}$.\n\nValidity of the Chaum-Pedersen proof corresponding to $\\text{tx}_{\\text{spend}}$ yields an extracted representation $S' = s'F + r'G + yH$.\nValidity of the corresponding parallel one-of-many proof gives a serial number commitment $S$ and extraction such that $S - S' = xH$, so $S = s'F + r'G + (x + y)H$.\n\nNow let $(s_1,s_2,r)$ be the spend key corresponding to the address $(d,Q_1,Q_2)$.\nSince $\\text{tx}_{\\text{spend}}$ consumes a coin recoverable by this address, a serial number commitment for the recovered coin is\n\\begin{align*}\n\\overline{S} &= \\hash_{\\text{ser}}(k)F + Q_2 \\\\\n&= (\\hash_{\\text{ser}}(k) + \\hash_{Q_2}(s_1,i) + s_2)F + rG\n\\end{align*}\nfor nonce $k$ and some diversifier index $i$.\n\nSince the commitment scheme is binding, we must therefore have $r' = r$, which is a contradiction since $\\mathcal{A}$ cannot extract this discrete logarithm from the public address.\n\nThis completes the proof.\n\\end{proof}\n\n\n\\subsection{Transaction Non-Malleability}\n\nThis property requires that no bounded adversary can substantively alter a valid transaction. \nIn particular, non-malleability prevents malicious adversaries from modifying honest users' transactions by altering data or redirecting the outputs of a valid transaction before the transaction is added to the ledger.\nSince non-malleability of mint transactions is offloaded to authorizations relating to consensus rules or base-layer operations, we need only consider the case of spend transactions.\n\nThis property is formalized by an experiment $\\func{TRNM}$, in which a bounded adversary $\\mathcal{A}$ adaptively interacts with the oracle $\\oracle$, and then outputs a spend transaction $\\text{tx}'$.\nIf we let $T$ denote the set of all transactions produced by $\\func{Spend}$ queries to $\\oracle$, and $L$ denote the final ledger, $\\mathcal{A}$ wins the game if there exists $\\text{tx} \\in T$ such that:\n\\begin{itemize}\n    \\item $\\text{tx}' \\neq \\text{tx}$; \n    \\item $\\text{tx}'$ reveals a tag also revealed by $\\text{tx}$; and\n    \\item both $\\text{tx}'$ and $\\text{tx}$ are valid transactions with respect to the ledger $L^{\\prime}$ containing all transactions preceding $\\text{tx}$ on $L$.\n\\end{itemize}\n\nWe say a DAP scheme $\\Pi$ is $\\func{TRNM}$-secure if the adversary $\\mathcal{A}$ wins the game $\\func{TRNM}$ only with negligible probability:\n$$\\text{Pr}[\\func{TRNM}(\\Pi, \\mathcal{A}, \\lambda) = 1] \\leq \\text{negl}(\\lambda)$$\n\nLet $\\mathcal{T}$ be the set of all $\\text{tx}_{\\text{spend}}$ transactions generated by the $\\oracle$ in response to $\\func{Spend}$ queries.\nSince these transactions are generated by these oracle queries, $\\mathcal{A}$ does not learn any secret data used to produce these transactions.\n\n\\begin{proof}\nAssume that the adversary $\\mathcal{A}$ wins the game with non-negligible probability.\nThat is, $\\mathcal{A}$ produces a transaction $\\text{tx}'$ revealing a tag $T$ also revealed in a transaction $\\text{tx}$.\nWithout loss of generality, assume each transaction consumes a single coin.\n\nObserve that a valid spend binds all transaction elements except for the modified Chaum-Pedersen proof into each such proof via $\\hash_{\\text{bind}}$ and the proof transcripts.\nTherefore, in order to produce valid $\\text{tx}' \\neq \\text{tx}$, we consider two cases:\n\\begin{itemize}\n    \\item the modified Chaum-Pedersen proofs are identical, but $\\text{tx}'$ and $\\text{tx}$ differ in another element of the transaction structures; or\n    \\item the modified Chaum-Pedersen proof in $\\text{tx}'$ is distinct from the proof in $\\text{tx}$.\n\\end{itemize}\n\nIn the first case, at least one input to the binding hash $\\hash_{\\text{bind}}$ used to initialize the modified Chaum-Pedersen transcripts must differ between the proofs.\nBecause we model this hash function as a random oracle, the outputs differ except with negligible probability, a contradiction since the resulting proof structures must be identical.\n\nIn the second case, because the tag revealed in both $\\text{tx'}$ and $\\text{tx}$ is identical, Lemma \\ref{lem:extract} gives extractions of the form $(s,r,y)$ and $(s,r,0)$ respectively.\nFurther, the coin $S = \\comm(s,r,0)$ consumed in $\\text{tx}$ was generated such that $r$ is a spend key component for an address $(d,Q_1,Q_2)$ not controlled by $\\mathcal{A}$.\nSince $\\mathcal{A}$ does not control this address, it cannot produce $r$ without extracting from $S$ or from any set of corresponding diversified address components $\\{Q_{2,i}\\}_i$ produced from the same spend key.\nHowever, each $Q_{2,i}$ is produced linearly against $Q_2$ and querying $\\hash_{Q_2}$ with unique $(s_1,i)$ input, a contradiction.\n\\end{proof}\n\n\n\\subsection{Ledger Indistinguishability}\n\nThis property implies that no bounded adversary $\\mathcal{A}$ received any information from the ledger except what is already publicly revealed, even if it can influence valid ledger operations by honest users.\n\nLedger indistinguishability is formalized through an experiment $\\func{LIND}$ between a bounded adversary $\\mathcal{A}$ and a challenger $\\mathcal{C}$, which terminates with a binary output $b^{\\prime}$ by $\\mathcal{A}$.\nAt the beginning of the experiment, $\\mathcal{C}$ samples $\\func{Setup}(1^\\lambda) \\to pp$ and sends the parameters to $\\mathcal{A}$; next it samples a random bit $b \\in \\lbrace 0,1 \\rbrace$ and initializes two separate DAP oracles $\\oracle_0$ and $\\oracle_1$, each with its own separate ledger and internal state.\nAt each consecutive step of the experiment:\n\\begin{enumerate}\n\\item $\\mathcal{C}$ provides $\\mathcal{A}$ two ledgers $(L_{\\text{left}} = L_b, L_{\\text{right}} = L_{1-b})$ where $L_b$ and $L_{1-b}$ are the current ledgers of the oracles $\\oracle_b$ and $\\oracle_{1-b}$ respectively. \n\\item $\\mathcal{A}$ sends to $\\mathcal{C}$ two queries $Q, Q^{\\prime}$ of the same type (one of $\\func{CreateAddress}$, $\\func{Mint}$, $\\func{Spend}$, or $\\func{Insert}$). \n\\begin{itemize}\n    \\item If the query type is $\\func{Insert}$ or $\\func{Mint}$, $\\mathcal{C}$ forwards $Q$ to $L_{b}$ and $Q^\\prime$ to $L_{1-b}$, permitting $\\mathcal{A}$ to insert its own transactions or mint new coins to $L_{\\text{left}}$ and $L_{\\text{right}}$.\n    \\item For all queries of type $\\func{CreateAddress}$ or $\\func{Spend}$, $\\mathcal{C}$ first checks if the two queries $Q$ and $Q^\\prime$ are publicly consistent, and then forwards $Q$ to $\\oracle_0$ and $Q^\\prime$ to $\\oracle_1$.\n    It receives the two oracle answers $(a_0,a_1)$, but returns $(a_b,a_{1-b})$ to $\\mathcal{A}$.\n\\end{itemize}\n\\end{enumerate}\nAs the adversary does not know the bit $b$ and the mapping between $(L_{\\text{left}}, L_{\\text{right}})$ and $(L_0, L_1)$, it cannot learn whether it affects the behavior of honest parties on $(L_0, L_1)$ or on $(L_1, L_0)$.\nAt the end of the experiment, $\\mathcal{A}$ sends $\\mathcal{C}$ a bit $b^\\prime \\in \\lbrace 0,1 \\rbrace$.\nThe challenger outputs 1 if $b = b^\\prime$, and 0 otherwise.\n\nWe require the queries $Q$ and $Q^\\prime$ be publicly consistent as follows\nIf the query type of $Q$ and $Q^\\prime$ is $\\func{CreateAddress}$, both oracles generate the same address.\nIf the query type of $Q$ and $Q^\\prime$ is $\\func{Mint}$, then the number of generated coins and the public value of each coin must be equal in both queries.\nIf the query type of $Q$ and $Q^\\prime$ is $\\func{Spend}$, then:\n\\begin{itemize}\n    \\item Both $Q$ and $Q^\\prime$ must be well-formed and valid, so the referenced input coins must have been generated in a previous transaction on the ledger and be unspent.\n    Further, the transaction must balance.\n    \\item The number of spent coins and output coins must be the same in $Q$ and $Q^\\prime$.\n    \\item If a consumed coin in $Q$ references a coin in $L_0$ posted by $\\mathcal{A}$ through an $\\func{Insert}$ query, then the corresponding index in $Q^\\prime$ must also reference a coin in $L_1$ posted by $\\mathcal{A}$ through an $\\func{Insert}$ query and the values of these two coins must be equal as well (and vice versa for $Q^\\prime$). \n    \\item If an output coin referenced by $Q$ does not reference a recipient address in the oracle $\\func{ADDR}$ list (and therefore is controlled by $\\mathcal{A}$), then the corresponding value must equal that of the corresponding coin referenced by $Q$ at the same index (and vice versa for $Q^\\prime$).\n\\end{itemize}\n\nWe say a DAP scheme $\\Pi$ is $\\func{LIND}$-secure if $\\mathcal{A}$ wins the game $\\func{LIND}$ only probability at most negligibly better than chance:\n$$\\text{Pr}[\\func{LIND}(\\Pi, \\mathcal{A}, \\lambda) = 1] - \\frac{1}{2} \\leq \\text{negl}(\\lambda)$$\n\n\\begin{proof}\nIn order to prove that $\\mathcal{A}$'s advantage in the $\\func{LIND}$ experiment is negligible, we first consider a simulation experiment $\\mathcal{D}^{\\text{sim}}$, in which $\\mathcal{A}$ interacts with $\\mathcal{C}$ as in the $\\func{LIND}$ experiment, but with modifications.\n\n\\textbf{The simulation experiment $\\mathcal{D}^{\\text{sim}}$}: Since the parallel one-out-of-many, modified Chaum-Pedersen, representation, and range proving systems are all special honest-verifier zero knowledge, we can take advantage of the simulator for each.\nGiven input statements and verifier challenges, each proving system's simulator produces transcripts indistinguishable from honest proofs.\nAdditionally, we now define the behavior of the full simulator.\n\n\\textbf{The simulation.} The simulation $\\mathcal{D}^{\\text{sim}}$ works as follows.\nAs in the original experiment, $\\mathcal{C}$ samples the system parameters $\\func{Setup}(1^\\lambda) \\to pp$ and a random bit $b$, and initializes DAP oracles $\\oracle_0$ and $\\oracle_1$.\nThen $\\mathcal{D}^{\\text{sim}}$ proceeds in steps.\nAt each step, it provides $\\mathcal{A}$ with ledgers $L_{\\text{\\text{left}}} = L_{b}$ and $L_{\\text{\\text{right}}} = L_{1-b}$,after which $\\mathcal{A}$ sends two publicly-consistent queries $(Q, Q^\\prime)$ of the same type.\nRecall that the queries $Q$ and $Q^\\prime$ are consistent with respect to public data and information related to the addresses controlled by $\\mathcal{A}$.\nDepending on the query type, the challenger acts as follows:\n\\begin{itemize}\n    \\item Answering $\\func{Insert}$ queries: The challenger proceeds as in the original $\\func{LIND}$ experiment.\n    \\item Answering $\\func{CreateAddress}$ queries: In this case the challenger replaces the public address components $(d,Q_1,Q_2)$ with random strings of the appropriate lengths, producing $\\addr_{\\text{pk}}$ that is returned to $\\mathcal{A}$.\n    \\item Answering $\\func{Mint}$ queries: The challenger does the following to answer $Q$ and $Q^\\prime$ separately, where $t$ is the number of generated coins specified by $\\mathcal{A}$ as part of its queries:\n    \\begin{enumerate}\n        \\item For each $j \\in [0,t)]$:\n        \\begin{enumerate}\n            \\item If $\\mathcal{A}$ provided a public address $\\addr_{\\text{pk}}$ not generated by the challenger, it produces a coin using $\\func{CreateCoin}$ as usual.\n            \\item Otherwise, it simulates coin generation:\n            \\begin{enumerate}\n                \\item Samples a recovery key $K_j$ uniformly at random.\n                \\item Samples a serial number commitment $S_j$ uniformly at random.\n                \\item Samples a value commitment $\\overline{C}_j$ uniformly at random.\n                \\item Samples a random input used to produce an AEAD encryption key $\\func{AEADKeyGen} \\to k_{\\text{enc}}$.\n                \\item Simulates the recipient data encryption by selecting random $r$ of the proper length, and encrypting it to produce $$\\func{AEADEncrypt}(k_{\\text{enc}},\\texttt{r},r) \\to \\overline{r}.$$\n            \\end{enumerate}\n        \\end{enumerate}\n        \\item Simulates the value proof $\\Pi_{\\text{val}}$ on the statement $\\{ \\overline{C}_j - \\com(v_j,0)\\}_{j=0}^{t-1}$.\n        \\item Assembles the transaction and adds it to the ledger as appropriate.\n    \\end{enumerate}\n    \\item Answering $\\func{Spend}$ queries: The challenger does the following to answer $Q$ and $Q^\\prime$ separately, where $w$ is the number of consumed coins and $t$ the number of generated coins specified by $\\mathcal{A}$ as part of its queries:\n    \\begin{enumerate}\n        \\item Parse the input cover set serial number commitments and value commitments as $\\func{InCoins} = \\{(S_i, C_i)\\}_{i=0}^{N-1}$.\n        \\item For each $u \\in [0,w)$, where $l_u$ represents the index of the consumed coin in $\\func{InCoins}$:\n        \\begin{enumerate}\n            \\item Samples a tag $T_u$ uniformly at random.\n            \\item Samples a serial number commitment offset $S_u'$ and value commitment offset $C_u'$ uniformly at random.\n            \\item Simulates a parallel one-out-of-many proof $(\\Pi_{\\text{par}})_u$ on the statement $(\\{S_i, C_i\\}_{i=0}^{N-1},S_u',C_u')$.\n        \\end{enumerate}\n        \\item For each $j \\in [0,t)$:\n        \\begin{enumerate}\n            \\item If $\\mathcal{A}$ provided a public address $\\addr_{\\text{pk}}$ not generated by the challenger, it produces a coin using $\\func{CreateCoin}$ as usual.\n            \\item Otherwise, it simulates coin generation:\n            \\begin{enumerate}\n                \\item Samples a recovery key $K_j$ uniformly at random.\n                \\item Samples a serial number commitment $S_j$ uniformly at random.\n                \\item Samples a value commitment $\\overline{C}_j$ uniformly at random.\n                \\item Samples a random input used to produce an AEAD encryption key $\\func{AEADKeyGen} \\to k_{\\text{enc}}$.\n                \\item Simulates the recipient data encryption by selecting random $r$ of the proper length, and encrypting it to produce $$\\func{AEADEncrypt}(k_{\\text{enc}},\\texttt{r},r) \\to \\overline{r}.$$\n                \\item Simulates a range proof $(\\Pi_{\\text{rp}})_j$ on the statement $(\\overline{C}_j)$.\n            \\end{enumerate}\n        \\end{enumerate}\n        \\item Simulates the balance proof $\\Pi_{\\text{bal}}$ on the statement $$\\left(\\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0)\\right).$$\n        \\item For each $u \\in [0,w)$, computes the binding hash $\\mu$ as defined and simulates the modified Chaum-Pedersen proof $\\Pi_{\\text{chaum}}$ on the statement $(\\{S_u', T_u\\}_{u=0}^{w-1})$.\n        \\item Assembles the transaction and adds it to the ledger as appropriate.\n    \\end{enumerate}\n\\end{itemize}\n\nFor experiments defined below, we define $\\func{Adv}^{\\mathcal{D}}$ as the advantage of $\\mathcal{A}$ in some experiment $\\mathcal{D}$ over the original $\\func{LIND}$ game.\nBy definition, all answers sent to $\\mathcal{A}$ in $\\mathcal{D}^{\\text{sim}}$ are computed independently of the bit $b$, so $\\func{Adv}^{\\mathcal{D}^{\\text{sim}}} = 0$. We will prove that $\\mathcal{A}$'s advantage in the real experiment $\\mathcal{D}^{\\text{real}}$ is at most negligibly different than $\\mathcal{A}$'s advantage in $\\mathcal{D}^{\\text{sim}}$.\nTo show this, we construct intermediate experiments in which $\\mathcal{C}$ performs a specific modification of $\\mathcal{D}^{\\text{real}}$ against $\\mathcal{A}$.\n\n\\textbf{Experiment $\\mathcal{D}_1$}: This experiment modifies $\\mathcal{D}^{\\text{real}}$ by simulating all one-out-of-many proofs, range proofs, representation proofs, and modified Chaum-Pedersen proof.\nAs all these protocols are special honest-verifier zero knowledge, the simulated proofs are indistinguishable from the real proofs generated in $\\mathcal{D}^{\\text{real}}$.\nHence $\\func{Adv}^{\\mathcal{D}_1} = 0$.\n\n\\textbf{Experiment $\\mathcal{D}_2$}: This experiment modifies $\\mathcal{D}_{1}$ by replacing all encrypted recipient data in transactions with challenger-generated recipient public addresses with encryptions of random values of appropriate lengths under keys chosen uniformly at random, and by replacing recovery keys with uniformly random values.\nSince the underlying authenticated symmetric encryption scheme is IND-CCA and IK-CCA secure and we assume the decisional Diffie-Hellman problem is hard, the adversarial advantage in distinguishing ledger output in the $\\mathcal{D}_2$ experiment is negligibly different from its advantage in the $\\mathcal{D}_{1}$ experiment.\nHence $\\lvert \\func{Adv}^{\\mathcal{D}_2} - \\func{Adv}^{\\mathcal{D}_1} \\rvert$ is negligible.\n\n\\textbf{Experiment $\\mathcal{D}^{\\text{sim}}$}: The $\\mathcal{D}^{\\text{sim}}$ experiment is formally defined above.\nIn particular, it differs from $\\mathcal{D}_{2}$ by replacing consumed coin tags, serial number commitment offset, and value commitment offsets with uniformly random values; and by replacing output coin serial number and value commitments with random values.\nIn previous experiments (including $\\mathcal{D}^{\\text{real}}$), tags are generated using a pseudorandom function \\cite{dodis}, and the other given values are generated as commitments with masks derived from hash functions modeled as independent random oracles, so the adversarial advantage in distinguishing ledger output in $\\mathcal{D}^{\\text{sim}}$ is negligibly different from its advantage in the $\\mathcal{D}_2$ experiment.\nHence $\\lvert \\func{Adv}^{\\mathcal{D}^{\\text{sim}}} - \\func{Adv}^{\\mathcal{D}_2} \\rvert$ is negligible.\n\nThis shows that the adversary has only negligible advantage in the real $\\func{LIND}$ game over the simulation, where it can do no better than chance, which completes the proof.\n\\end{proof}\n\n\n\\section{Payment Proofs}\n\\label{app:payment}\n\nWe describe now the informal security properties required for a payment proving system, describe such a construction, and (informally) prove that our construction meets the requirements.\n\nThe security requirements of a payment proving system are as follows:\n\\begin{enumerate}\n    \\item\\label{pay:context} The proof cannot be replayed in a different context.\n    \\item\\label{pay:secret} The prover asserts that it knows secret data sufficient to authorize the transaction originally generating a specified coin.\n    \\item\\label{pay:value_memo} The verifier can obtain and confirm the value and memo associated to the coin.\n    \\item\\label{pay:identify} The holder of an incoming view key corresponding to a specified public address can successfully identify the coin.\n    \\item\\label{pay:malicious} A computationally-bound adversary cannot produce valid proofs for the same coin claiming distinct public addresses.\n\\end{enumerate}\n\nWe note that coin identification relies on the assumption that the claimed recipient address was generated using the protocol-specified method from an incoming view key.\n\n\n\\subsection{Protocol}\n\nA prover wishes to produce a payment proof on a given coin $\\func{Coin}$ with nonce $k$ to a claimed destination public address $(d,Q_1,Q_2)$.\nSuppose that $\\text{tx}$ is the spend transaction on a ledger that produced $\\func{Coin}$.\nThe prover does the following:\n\\begin{enumerate}\n    \\item Parses the serial number commitment, value commitment, and recovery key from $\\func{Coin}$: $(S,C,K)$\n    \\item Generates a modified Chaum-Pedersen proof $\\Pi_{\\text{auth}}$ using the same inputs and proving system as the proof $\\Pi_{\\text{chaum}}$ from $\\text{tx}$, but also binding the tuple $(\\func{Coin},k,d,Q_1,Q_2)$, any context relevant to the payment proof instance, and a globally-fixed payment proof domain separator to the proof context.\n    \\item Assembles the payment proof: $\\Pi_{\\text{pay}} = (\\func{Coin},k,d,Q_1,Q_2,\\Pi_{\\text{auth}})$\n\\end{enumerate}\n\nTo verify a payment proof on a coin, the verifier does the following:\n\\begin{enumerate}\n    \\item Parses the payment proof: $\\Pi_{\\text{pay}} = (\\func{Coin},k,d,Q_1,Q_2,\\Pi_{\\text{auth}})$\n    \\item Parses public data from $\\func{Coin}$: $(S,C,K,\\overline{r})$\n    \\item Verifies that $\\text{tx}$ is a valid transacton on its own ledger that originally generated $\\func{Coin}$.\n    \\item Verifies the proof $\\Pi_{\\text{auth}}$ using the data from $\\text{tx}$ and the additional binding tuple $(\\func{Coin},k,d,Q_1,Q_2)$, and aborts if verification fails.\n    \\item Generates an AEAD key $k_{\\text{aead}} = \\func{AEADKeyGen}(\\hash_k(k) Q_1)$ and decrypts the recipient data: $$(v, d', k', m) = \\func{AEADDecrypt}(k_{\\text{aead}},\\texttt{r},\\overline{r})$$\n    If decryption fails, or if $k' \\neq k$, or if $d' \\neq d$, aborts.\n    \\item Checks that $K = \\hash_k(k)\\hash_{\\text{div}}(d)$, and aborts otherwise.\n    \\item Checks that $S = \\comm(\\hash_{\\text{ser}}(k),0,0) + Q_2$, and aborts otherwise.\n    \\item Checks that $C = \\com(v, \\hash_{\\text{val}}(k))$, and aborts otherwise.\n\\end{enumerate}\n\n\n\\subsection{Security}\n\nWe now describe why this construction meets our security requirements.\n\n\\textbf{Requirement \\ref{pay:context}}. To show that a payment proof cannot be replayed in another context, note that since proof context is bound to the transcript of $\\Pi_{\\text{auth}}$ along with the statement and coin data, the overall payment proof $\\Pi_{\\text{pay}}$ cannot be successfully replayed against any other context.\n\n\\textbf{Requirement \\ref{pay:secret}}. To show that successful verification of a payment proof asserts the prover knows secret data sufficient to authorize the transaction that generated the coin, we simply note that the modified Chaum-Pedersen proof $\\Pi_{\\text{chaum}}$ from $\\text{tx}$ uses the same statement input as $\\Pi_{\\text{auth}}$ (albeit with different proof context).\n\n\\textbf{Requirement \\ref{pay:value_memo}}. To show that the verifier can obtain the correct value and memo for the coin on successful verification of a payment proof, we simply note that successful AEAD decryption provides the unique values for the value and memo originally used to produce the coin, and that the decrypted value uniquely corresponds to the coin's value commitment since the commitment scheme is binding and successful verification implies an opening to this commitment.\n\n\\textbf{Requirement \\ref{pay:identify}}. We now show that if the given address $(d,Q_1,Q_2)$ was generated from an incoming view key $(s_1,P_2)$, this key can identify $\\textsf{Coin}$ if a payment proof verifies.\nSuccessful verification of a payment proof implies in particular that $K = \\hash_k(k)\\hash_{\\text{div}}(d)$ and that AEAD decryption succeeds on a key generated using $\\hash_k(k) Q_1$.\nThis implies that the incoming view holder uses the AEAD key\n\\begin{align*}\n    s_1 K &= s_1 \\hash_k(k)\\hash_{\\text{div}}(d) \\\\\n    &= \\hash_k(k) Q_1\n\\end{align*}\nand hence decryption succeeds.\nThe remaining steps for identification follow from corresponding steps taken during payment proof verification.\n\n\\textbf{Requirement \\ref{pay:malicious}}. We now show that a computationally-bound adversary cannot produce valid proofs against the same coin for distinct destination addresses.\nSuppose such an adversary produces for the same coin valid payment proofs\n$$\\Pi_{\\text{pay}} = (\\mathsf{Coin},k,d,Q_1,Q_2,\\Pi_{\\text{auth}})$$\nand\n$$\\Pi_{\\text{pay}}' = (\\mathsf{Coin},k',d',Q_1',Q_2',\\Pi_{\\text{auth}}')$$\non addresses $(d,Q_1,Q_2) \\neq (d',Q_1',Q_2')$.\nNote that $\\mathsf{Coin} = (S,C,K,\\overline{r})$ must be identical in both proofs by definition.\n\nSuccessful AEAD decryption of $\\overline{r}$ on both proofs implies in particular that $d = d'$ and $k = k'$ except with negligible probability.\nFurther, the AEAD keys derived in both proofs must be equal (again except with negligible probability), so $\\hash_k(k) Q_1 = \\hash_k(k') Q_1'$ requires $Q_1 = Q_1'$.\nFinally, since\n\\begin{alignat*}{1}\n    S &= \\comm(\\hash_{\\text{ser}}(k),0,0) + Q_2 \\\\    \n    &= \\comm(\\hash_{\\text{ser}}(k'),0,0) + Q_2'\n\\end{alignat*}\nit also follows that $Q_2 = Q_2'$, a contradiction.\n\n\n\\end{document}\n", "meta": {"hexsha": "d63a814d2f2b3eb0ea81fe24f08d4bbcd91ae07e", "size": 109101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "firoorg/spark-paper", "max_stars_repo_head_hexsha": "2fb8f217b53fe692832b78e1739a9718ebab8caa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-09-15T06:09:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-14T02:09:41.000Z", "max_issues_repo_path": "main.tex", "max_issues_repo_name": "firoorg/spark-paper", "max_issues_repo_head_hexsha": "2fb8f217b53fe692832b78e1739a9718ebab8caa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "firoorg/spark-paper", "max_forks_repo_head_hexsha": "2fb8f217b53fe692832b78e1739a9718ebab8caa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-13T06:59:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-13T06:59:18.000Z", "avg_line_length": 82.4648526077, "max_line_length": 568, "alphanum_fraction": 0.7133940111, "num_tokens": 31641, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5273165233795672, "lm_q1q2_score": 0.40988306041805844}}
{"text": "\\subsection{Actuators and Sensors}\nHere we consider the actions that may be chosen to be performed by actuators and percepts that may be received by sensors. The problem of \\textit{target localisation} in the context of this chapter requires the agent to move around a discrete grid and use a calibrated sensor to record noisy readings that indicate whether the target is present or not at the location of the reading. We therefore describe the set of possible actions to be performed by the actuators by the set of all $n$ possible grid locations that the agent can move to and take a sensor reading at, indexed by an arbitrary ordering: $\\{move\\_x_1, move\\_x_2, ..., move\\_x_n\\}$. We did not restrict the agent to only move between adjacent grid cells since our use case deals with agile aerial vehicles, which can move freely between any two grid points. We add search termination actions to this set, $\\{terminate\\_search\\_x_{i}\\}$, for $i \\in \\{1, 2, ..., n, n+1\\}$, which lead to an absorbing terminal state representing the agent's conclusion regarding whether a target is present or not, $terminated\\_x_{i}$. To summarise, the agent may either choose a move action or a search termination action, which respectively move the agent to a new grid location at which they record a sensor reading, or conclude the search and return the most likely target location $x_i$. \\par\n\nThe set of percepts that the agent will receive from its sensors come from the binary set \\{1, 0\\}, indicating the target has or has not been detected, respectively.\\par\n", "meta": {"hexsha": "a1467af3898f5ffad6ed287724d85369f2777f07", "size": 1550, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/ActuatorsSensors.tex", "max_stars_repo_name": "DavidLSmyth/ResearchMScThesis", "max_stars_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/ActuatorsSensors.tex", "max_issues_repo_name": "DavidLSmyth/ResearchMScThesis", "max_issues_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-06-18T11:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-18T11:59:42.000Z", "max_forks_repo_path": "Chapters/MultiAgentTargetDetection/InitialAgentDesign/ActuatorsSensors.tex", "max_forks_repo_name": "DavidLSmyth/ResearchMScThesis", "max_forks_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 310.0, "max_line_length": 1343, "alphanum_fraction": 0.7819354839, "num_tokens": 350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5273165233795672, "lm_q1q2_score": 0.40988306041805844}}
{"text": "\\section{Drone learning}\n\\label{sec:dlearn}\n\nThe training of the drone network requires that the original network is\nextensively probed in the parameter space in which accuracy is desired.\nThe principle utilised in the training of the drone is that sufficient\napproximation of the original network is achieved with sufficient expansion\nof the hyperparameter space of the drone, and that the same global minimum\nof the loss function can be found, as reported in Ref.~\\cite{losssurfaces}.\nThe ability of a neural network with a continuous, bounded, non-constant activation\nfunction to approximate functions to an arbitrary degree has been indeed known\nsince the early 1990s~\\cite{HORNIK1991251}.\n\n\\subsection{Initial drone structure and corresponding training}\n\nThe drone chosen for use in this article is initialised as a\nneural network with a single intermediate (hidden) layer of 5\nnodes using a standard sigmoid activation function. The network\nhas the number of inputs determined from the number of desired\ncharacteristics of the decay signature. A single output is taken\nfrom the network and a linear model is used to relate layers.\n\nThe model is made to approximate the original classifier through\na supervised learning technique, though not in the traditional sense.\nInstead of a label as {\\tt signal} or {\\tt background} taken from the training data, the\noutput of the original classifier is used as a label. This means that the\nloss function is defined as\n\\begin{align}\n\\mathcal{L} = \\sum_i \\left( F(\\vec{x}_i) - G_i(\\vec{x}_i) \\right)^2,\n\\end{align}\nwhere $F(\\vec{x}_i)$ and $G(\\vec{x}_i)$ are the outputs\nof the original and drone models on datapoint\n$i$ of the mini-batch, respectively. The advantage of such a loss function is per-event\nequivalence of the original and drone model, in addition to equivalence\nof performance. For the drone training detailed in this article, standard\nmini-batch stochastic gradient descent is used. A feature of this method\nis that the drone classifier does not see any training data,\nbut rather learns the same properties from the original classifier,\nand thus is a neural network that learns from another neural network in an\nempirical manner.\n\n\\subsection{Model morphing during the learning phase}\n\nIn order to keep the hyperparameter space to the minimum required level,\nadditional degrees of freedom are added only when required.\nThis removes the possibility of choosing an incorrect size of the\ndrone network. During the learning phase, the following conditions are required\nto trigger the extension of the hidden layer in the $j^{\\rm th}$ epoch:\n\\begin{align}\n\\delta_{j} &\\equiv |\\mathcal{L}_j-\\mathcal{L}_{j-1}|/\\mathcal{L}_j < \\kappa,\\label{eq:cond1}\\\\\n\\sigma_{j} &\\equiv m (1 - e^{-b(\\hat{t} + n)})\\delta_{j}\\mathcal{L}_j \\nonumber\\\\\n\\mathcal{L}_j &< \\hat{\\mathcal{L}} - \\sigma_{j} \\label{eq:cond2},\n\\end{align}\nwhere $\\kappa$ is the required threshold, $\\sigma$ is the required minimum improvement\nof the loss function and $\\hat{\\mathcal{L}}$ is the value of the loss function when\nthe hidden layer was last extended. The required improvement starts from a minimum at $n$,\nincreases with epoch number after previous extension $\\hat{t}$ and steepness $b$\nuntil a maximum at $m$. The precise values of the parameters\n$\\kappa$, $n$, $m$, $b$ are not of particular importance. Rather, the topology described by\neqs.~\\ref{eq:cond1} and \\ref{eq:cond2} is crucial. The relative loss function improvement,\n$\\delta_{j}$, can never realistically be larger than $1$ and the limit, $\\kappa$, at which\nno significant improvement occurs is acceptably set at 0.02 (smaller than $2\\sigma$\nstandard deviations). The descent in loss space, $\\hat{\\mathcal{L}} - \\mathcal{L}_j$,\nis further required to be significantly large, minimizing the chance of getting stuck in\nisolated local minima. The function, $\\sigma_{j}$, is chosen to increase this requirement\nwith each epoch for two reasons - it is bounded and can approach its asymptote arbitrarily fast.\nIt scales $\\delta_{j}$ such that the loss descent must be significant\nbefore an update is triggered. Since $\\delta_{j}$ is expected to decrease with epoch number,\nthe minumum and maximum values of $\\sigma_{j}$ are chosen as such:\n\\begin{align}\n\\sigma_{j}(\\hat{t} = 0) &\\equiv min(\\sigma_{j}) \\equiv 2.5\\delta_{j}\\mathcal{L}_j \\implies 5\\sigma ~\\text{std.dev.} \\\\\n\\sigma_{j}(\\hat{t} = \\infty) &\\equiv min(\\sigma_{j}) \\equiv 25\\delta_{j}\\mathcal{L}_j \\implies 50\\sigma ~\\text{std.dev.}\n\\end{align}\nThe steepness, $b$, is chosen such that the transition from the minimum to maximum takes\non average 50 epochs. This ensures a change cannot be triggered immediately\nafter a previous one and the learning can still proceed if more freedom is indeed required.\nAlso, it allows the network to stabilize after a big change.\n\nWhen the conditions in eqs.~\\ref{eq:cond1} and \\ref{eq:cond2} are met, the linear model\nis updated to extend the weights matrices and bias vectors\nto accommodate the layer addition.\nThe associated neurons are initialised with a zero weight\nto ensure continuity of the loss function value.\n", "meta": {"hexsha": "3df606b47e4e5bcb7d746a63dda98dc7c84c99db", "size": 5094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/paper/teaching.tex", "max_stars_repo_name": "Tevien/NNDrone", "max_stars_repo_head_hexsha": "76dce457324ea03a8757d74f6403fbf60132294b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-11-06T11:21:20.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-20T14:47:21.000Z", "max_issues_repo_path": "documents/paper/teaching.tex", "max_issues_repo_name": "Tevien/NNDrone", "max_issues_repo_head_hexsha": "76dce457324ea03a8757d74f6403fbf60132294b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-01-12T15:49:40.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-06T02:29:56.000Z", "max_forks_repo_path": "documents/paper/teaching.tex", "max_forks_repo_name": "Tevien/NNDrone", "max_forks_repo_head_hexsha": "76dce457324ea03a8757d74f6403fbf60132294b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2018-01-12T15:46:35.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-21T22:41:56.000Z", "avg_line_length": 60.6428571429, "max_line_length": 120, "alphanum_fraction": 0.7734589713, "num_tokens": 1285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.40988306041805833}}
{"text": "\\input{../../assignment-header}\n\n% Special settings for matlab code on exam\n\\lstset{morekeywords={runSloppySimulation,runSimBadly,simStepMidpointMethod}}\n\n\\newcommand{\\scoreMark}[0]{$\\rule{1.5cm}{0.15mm}$ / $\\rule{1.5cm}{0.15mm}$}\n\n%========================================================================\n\\title{ME 149:  Midterm Exam}\n\\date{March 15  ---  Start: 6:00pm  ---  End: 7:15pm}\n\\author{Optimal Control for Robotics}\n%========================================================================\n\\begin{document}\n\\maketitle\n\n\\begin{abstract*}\nNo calculators, notes, books, or computers allowed. Total time:  75 minutes.\n\\end{abstract*}\n%=================================================\n\n\\vspace{1em}\n\n\\section*{Student Name:  $\\rule{10cm}{0.3mm}$}\n\n\\vspace{1em}\n\n\\section*{How to optimize your score?}\n\n\\begin{itemize}  \\setlength\\itemsep{0.1em} \\setlength\\itemindent{18pt}\n  \\item Be neat and well organized\n  \\item For longer problems, show intermediate steps and box your\n  \\fbox { \\parbox{3em}{answer} }\n  \\item If you need extra space...\n        use the back of the page,\n        the final (blank) page of the exam,\n        or ask for more paper.\n        Clearly indicate where the extra work is.\n  \\item Define all variables that you use and state any assumptions that you make.\n\\end{itemize}\n\n\n\\vspace{1em}\n\n\\section*{Score:  \\scoreMark}\n\\vspace{1em}\n\\begin{large}\n\\begin{multicols}{2}\n\\begin{enumerate}  \\setlength\\itemsep{1.1em} \\setlength\\itemindent{36pt}\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\item \\scoreMark\n\\end{enumerate}\n\\end{multicols}\n\\end{large}\n\n\n% Force enumerated lists to use letters\n\\renewcommand{\\theenumi}{\\Alph{enumi}}\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\pagebreak\n\\section{Newton's Method}\n\n\\begin{enumerate}\n  \\item Suppose that you want to solve the scalar nonlinear equation $f(x) = 0$. \\\\\n        The current estimate of the root is given by $x_k$\n        and the next estimate of the root is given by $x_{k+1}$.\n        Derive the Newton-Rhapson update that computes $x_{k+1}$ given $x_k$.\n  \\vspace{25em}\n  \\item What is the difference between the Newton--Rhapson\n        and the secant methods for scalar root finding?\n        In what situation would you prefer one to the other?\n\n  \\pagebreak\n  \\item Draw a figure that clearly demonstrates a situation in which\n        Newton's method will fail to converge to a root of the function.\n        Why does the Newton--Rhapson method fail in this situation?\n  \\vspace{25em}\n\\end{enumerate}\n\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\section{Midpoint Method Implementation}\n\nImplement the function \\texttt{simStepMidpoint()} on the following page.\nThis function computes a single simulation step using the midpoint method.\nYou code should be clear, correct, and follow the best practices that\nhave been discussed throughout the course.\nUse the space below for planning your solution.\nWrite your Matlab code inside of the function template on the following page.\n\n\n\n\\pagebreak\n\\lstset{stepnumber=0}\n\\lstinputlisting{simStepMidpoint.m}\n\n\n\n\\pagebreak\n\\section{Bisection Search}\n\\begin{NoHyper}\nUse a bisection search to iteratively reduce the interval that is known\nto bracket the root of the function shown in Figure \\ref{fig:RootSolveExampleFigure}.\n\\textbf{Populate the table below}, showing the bracket for the first five iterations\nand the new point that will be evaluated on that iteration.\n\\end{NoHyper}\n\\begin{itemize}  \\setlength\\itemsep{0.3em}\n  \\item \\texttt{Iter 0:   bracket: [-1.000,  \\hspace{2.9em} 1.000]  \\hspace{1em}  xNew = }\n  \\item \\texttt{Iter 1:   bracket: [ \\hspace{10em} ]  \\hspace{1em}  xNew = }\n  \\item \\texttt{Iter 2:   bracket: [ \\hspace{10em} ]  \\hspace{1em}  xNew = }\n  \\item \\texttt{Iter 3:   bracket: [ \\hspace{10em} ]  \\hspace{1em}  xNew = }\n  \\item \\texttt{Iter 4:   bracket: [ \\hspace{10em} ]  \\hspace{1em}  xNew = }\n\\end{itemize}\n\n\\begin{figure}[ht]\n\t\\centering\n  \\includegraphics[width=\\textwidth]{RootSolveExampleFigure.pdf}\n  \\caption{Bisection Search Example Figure}\n  \\label{fig:RootSolveExampleFigure}\n\\end{figure}\n\n\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\pagebreak\n\\section{Scalar Taylor Series}\n\nWrite Taylor series approximation of $f(t)$ to second-order around the point $t_0$.\n\n\\vspace{2em}\n\\begin{equation*}\n  f(t) \\approx \\hspace{50em}\n\\end{equation*}\n\\vspace{7em}\n\n\\section{Vector Taylor Series}\n\nWrite the Taylor series approximation of $f(t, \\bm{x}, \\bm{u})$ to first-order\nabout the point: $t_0$, $\\bm{x}_0$, and $\\bm{u}_0$.\n\n\\vspace{2em}\n\\begin{equation*}\n  f(t, \\bm{x}, \\bm{u}) \\approx \\hspace{46em}\n\\end{equation*}\n\\vspace{4em}\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\pagebreak\n\\section{Function Handle Gymnastics}\n\\textbf{What will the following script print to the command prompt?} \\\\\nFor each part A, B, C, show your work and then put a box around\nthe text that Matlab will print to the command prompt.\n\n\\lstinputlisting{functionHandleGymnastics.m}\n\n\\subsection*{Part A:}\n\\vspace{7em}\n\\subsection*{Part B:}\n\\vspace{9em}\n\\subsection*{Part C: }\n\\vspace{11em}\n\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\\pagebreak\n\\section{Matlab Programming Style}\nThe program below simulates a simple pendulum. It works, but is written poorly. \\\\\n\\textbf{Clearly identify at least 5 distinct issues with the code.}\n\n\\lstset{stepnumber=1}\n\\lstinputlisting{runSloppySimulation.m}\n\n\\vspace{30em}\n\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\n\\pagebreak\n\\section{Linearized Dynamical System}\n\nGiven the non-linear system dynamics described below,\n\n\\begin{equation*}\n\n  \\dot{\\bm{z}} =\n\n  \\begin{bmatrix}\n    \\dot{\\alpha}  \\\\\n    \\dot{\\gamma}  \\\\\n    \\dot{\\theta}\n  \\end{bmatrix}\n\n  =\n\n  \\begin{bmatrix}\n    \\beta * \\gamma + \\theta^2 \\\\\n    \\alpha \\, \\sigma  - \\theta\\\\\n    \\sin(\\sigma) + \\beta \\, \\gamma\n  \\end{bmatrix}\n\n  = \\bm{f}(\\bm{z}, \\bm{u})\n\n  \\quad \\quad \\quad \\quad \\quad \\quad\n\n  \\bm{z} =\n  \\begin{bmatrix}\n    \\alpha \\\\\n    \\gamma \\\\\n    \\theta\n  \\end{bmatrix}\n\n\\quad \\quad \\quad \\quad \\quad \\quad\n\n  \\bm{u} =\n  \\begin{bmatrix}\n    \\beta \\\\\n    \\sigma\n  \\end{bmatrix}\n\n\n\\end{equation*}\n\n\n\n\\vspace{0.5em}\n\\begin{enumerate}\n  \\item \\textbf{List the state variables: }\n  \\vspace{0.6em}\n  \\item \\textbf{List the control variables: }\n  \\vspace{0.6em}\n  \\item \\textbf{What is the difference between a state and a control variable? }\n  \\vspace{4em}\n  \\item \\textbf{Compute: } $\\dfrac{\\delta \\bm{f}}{\\delta \\bm{z}} = $\n  \\vspace{15em}\n  \\item \\textbf{Compute: } $\\dfrac{\\delta \\bm{f}}{\\delta \\bm{u}} = $\n  \\vspace{15em}\n\\end{enumerate}\n\n\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\pagebreak\n\\section{Trajectory Optimization}\n\nGiven the following continuous-time trajectory optimization problem.\n\n\\begin{align*}\n  & \\text{minimize: } \\qquad \\int_0^T \\! \\bm{g}(t,\\, \\bm{x},\\, \\bm{u}) \\, dt \\\\\n  & \\text{subject to: } \\qquad \\bm{0} = \\bm{h}(\\bm{x}(0), \\, \\bm{x}(T)) \\\\\n  & \\text{dynamics: } \\qquad \\dot{\\bm{x}} = \\bm{f}(t,\\, \\bm{x},\\, \\bm{u}) \\\\\n\\end{align*}\n\nSuppose that you plan to solve the optimization using\ndirect multiple shooting with Euler's method\non a uniform grid of $N$ segments with one integration step per segment.\nWrite out the decision variables,\nobjective function, and constraints that will form the resulting non-linear program.\nThe objective function and constraints should be written in terms of the\ndecision variables, known parameters ($T$),\nand known functions ($\\bm{g}$, $\\bm{h}$, $\\bm{f}$).\n\n\\begin{enumerate}\n  \\item \\textbf{Decision Variables}\n  \\vspace{4em}\n  \\item \\textbf{Objective Function}\n  \\vspace{6em}\n  \\item \\textbf{Boundary Constraints}\n  \\vspace{10em}\n  \\item \\textbf{System Dynamics Constraints}\n  \\vspace{10em}\n\\end{enumerate}\n\n\\pagebreak\n\\section*{Blank page for additional work space for any problem.}\n\n\n%=================================================\n\\end{document}\n", "meta": {"hexsha": "9cf925b022f08f2a55e3071c3e46358f066a66cb", "size": 8120, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "topics/midterm-exam/exam/ME149-midterm-exam.tex", "max_stars_repo_name": "ShaneRozenLevy/ME149_Spring2018", "max_stars_repo_head_hexsha": "0cd1960cd3699ef4f24f824c89b32a64c73b5b99", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2018-01-10T15:55:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T22:54:58.000Z", "max_issues_repo_path": "topics/midterm-exam/exam/ME149-midterm-exam.tex", "max_issues_repo_name": "Boyang--Li/ME149_Spring2018", "max_issues_repo_head_hexsha": "333dcf4891ca05f007590f3a40f67ae46cf2cf6b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "topics/midterm-exam/exam/ME149-midterm-exam.tex", "max_forks_repo_name": "Boyang--Li/ME149_Spring2018", "max_forks_repo_head_hexsha": "333dcf4891ca05f007590f3a40f67ae46cf2cf6b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2018-02-24T00:15:06.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-23T14:08:38.000Z", "avg_line_length": 27.9037800687, "max_line_length": 90, "alphanum_fraction": 0.63091133, "num_tokens": 2364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.40988306041805833}}
{"text": "%!TEX root = ../notes.tex\n\\section{March 17, 2022}\n\\subsection{Midterm Review}\n\\subsubsection*{General Advice}\n\\begin{itemize}\n    \\item 5-7pm. Location: Barus \\& Holley 168.\n    \\item There are 5 problems:\n          \\begin{itemize}\n              \\item Each are weighted equally, some have multiple sections in them.\n              \\item There is a bonus problem for a \\emph{token} number of points.\n          \\end{itemize}\n    \\item Think about problems before starting! Don't begin immediately.\n\\end{itemize}\n\n\\subsubsection*{Key Topics}\n\\begin{enumerate}[1)]\n    \\item\n          Unique factorization in $\\ZZ$ (\\cref{thm:unique-factorization}). Key points:\n          \\begin{itemize}\n              \\item Existence (using well-ordering of $\\ZZ_+$)\n              \\item Uniqueness (using prime elements being irreducible elements in $\\ZZ$)\n          \\end{itemize}\n    \\item\n          $\\ZZ$ is a Euclidean domain with Euclidean function $\\mathsf{abs}$ (absolute value) (\\cref{cor:z-euclidean}).\n          \\begin{itemize}\n              \\item Argument uses well-ordering of $\\ZZ_+$ applied to the set $S = \\{a - bq\\mid b\\in \\ZZ\\}$ when trying to divide $a$ by $b$.\n              \\item Repeated application of this property yields the Euclidean algorithm for finding $\\gcd$'s.\n          \\end{itemize}\n    \\item\n          Bezout's Identity (\\emph{not} Bezout's Theorem)\n\n          If $a, b\\in\\ZZ$ are integers (not both $0$) and $c\\in \\ZZ$, then there exists $x, y\\in\\ZZ$ such that\n          \\[ax + by = c\\]\n          if and only if $\\gcd(a, b)\\mid c$.\n          \\begin{itemize}\n              \\item We take set $S = \\{ax + by\\mid x, y\\in\\ZZ\\}$ and use well-ordering to show that the smallest element has to be $c$.\n          \\end{itemize}\n    \\item\n          From Bezout to solving linear congruences in $1$ variable, the linear congruence\n          \\[ax\\equiv b\\pmod{m}\\]\n          is equivalent to\n          \\[ax - my = b\\]\n          for some $y\\in \\ZZ$. Applying Bezout's tells us that this equation is solvable if and only if $\\gcd(a, b)\\mid b$. When a solution exists, there are $d$ solutions modulo $m$.\n          \\begin{itemize}\n              \\item Showing there are $d$ solutions: you divide $a, b, m$ by $\\gcd(a, m)$, then you have a modulus $\\frac{m}{\\gcd(a, m)}$ where we have a unique solution. We lift up to solutions modulo $m$.\n          \\end{itemize}\n    \\item\n          Sunzi's theorem (\\cref{thm:crt}). For $m, n\\in\\ZZ_+$ with $(m, n) = 1$. And $a, b\\in\\ZZ$, then the simultaneous congruences\n          \\begin{align*}\n              x\\equiv a\\pmod{m} \\\\\n              x\\equiv b\\pmod{n}\n          \\end{align*}\n          have a \\emph{unique} solution modulo $mn$.\n          \\begin{itemize}\n              \\item We have $\\pi : \\ZZ/mn\\ZZ\\to \\ZZ/m\\ZZ\\times \\ZZ/n\\ZZ$ be the natural projectsion where $\\ker(\\pi) = \\{0\\}$ since $(m, n) = 1$.\n          \\end{itemize}\n    \\item\n          Structure of group of units (\\cref{cor:cyclicity-of-unit-groups}). $U(m)$ is cyclic $\\iff$ $m = 1, 2, 4, p^e, 2p^e$.\n\\end{enumerate}\n\n\\subsubsection*{Practice Problems}\n\\begin{problem}\nFind the integer $0\\leq a\\leq 36$ such that\n\\[3777^{\\left(1144523^{56245501}\\right)} \\equiv a\\pmod{37}\\]\n\\end{problem}\nWe can reduce the base $3777\\equiv 3\\pmod{37}$. We reduce $1144523\\equiv 11\\pmod{\\phi(37)}$. We can reduce the upper power $56245501\\equiv 1\\pmod{\\phi(\\phi(37))}$. This reduces to\n\\[3^{11}\\equiv a\\pmod{37}\\]\nwhich gives $a\\equiv 28\\pmod{37}$.\n\n\\begin{problem}\nLet $p\\in\\ZZ$ be a prime and let $g$ be a primitive root mod $p$. Describe the set\n\\[\\{g^k\\mid g^k \\text{ is a primitive root mod $p$}\\}\\]\n\\end{problem}\n\\begin{proof}\n    We claim that $\\gcd(k, p-1) = 1$. Then for any element $a = g^\\alpha$, we can find power $(g^k)^\\beta = g^\\alpha$ since we have $g^{p-1}\\equiv 1$ so $k\\beta - x(p-1) = \\alpha$ for some $x$, which only has solutions by Bezout's identity when $\\gcd(k, p-1)$.\n\\end{proof}\n\n\\begin{lemma*}\n    Prove that for any finite group $G$ of order $n$ and any $g\\in G$, the cyclic group $\\langle g^k\\rangle$ for $k$ such that $\\gcd(k, \\ord(g)) = 1$ equals $\\langle g\\rangle$.\n\\end{lemma*}\n\\begin{proof}\n    Let $d = (k, \\ord(g))$. Then there exists $x, y\\in\\ZZ$ such that\n    \\[\\ord(g)\\cdot x + k\\cdot y = d\\]\n    so\n    \\begin{align*}\n        g^d & = g^{\\ord(g)\\cdot x + ky}        \\\\\n            & = g^{\\ord(g)\\cdot x}\\cdot g^{ky} \\\\\n            & = g^{ky}\n    \\end{align*}\n    so $g^d\\in \\langle g^k\\rangle \\implies \\langle g^d\\rangle \\subseteq \\langle g^k\\rangle$. We have $\\langle g^k\\rangle\\subseteq \\langle g^d\\rangle$ since $d\\mid k$. Thus $\\langle g^d\\rangle = \\langle g^k\\rangle$.\n\n    We also have that $(g^k)^{\\ord(g)/d} = (g^{\\ord{g}})^{k/d} = 1$ so if $d = (k, \\ord(g))>1$ then $\\ord(g^k)< \\ord(g)$.\n\n    So together we have that $\\langle g\\rangle = \\langle g^k\\rangle$ if and only if $(g, \\ord(g))=1$.\n\\end{proof}\n\n\\begin{problem}\nProve\n\\begin{proposition*}\n    If $f : \\ZZ_+\\to \\CC$ is a nonzero multiplicative function, then $f^{-1}$ (the Dirichlet inverse) exists and is multiplicative.\n\\end{proposition*}\n\\end{problem}\n\\begin{proof}\n    Let $h$ be given by\n    \\begin{align*}\n        h(p^k) & = f^{-1}(p^k)\\qquad\\text{prime powers $p^k$} \\\\\n        h(n)   & = h(p_1^{e_1})\\cdots h(p_k^{e_k})\n    \\end{align*}\n    then $(f\\star h)(p^k) = I(p^k)$. Both $f\\star h$ and $I$ are multiplicative, so\n    \\[(f\\star h)(n) = I(n)\\quad\\forall n\\in\\ZZ\\]\n    and $h = f^{-1}$.\n\n    (Existence, $f(1) = 1$ for any multiplicative function, so in particular our given $f$ satisfies $f(1)\\neq 0$.)\n\\end{proof}\n\n\\begin{problem}\nDefine $\\lambda : \\ZZ_+\\to \\CC$ by\n\\[\\lambda(n) = (-1)^{e_1 + e_2 + \\cdots}\\]\nwhere the $e_i$'s are the exponents on the prime factorization of $n$. Let\n\\[g(n) = \\sum_{d\\mid n}\\lambda(d)\\]\nProve that\n\\[g(n) = \\begin{cases}\n        1 & \\text{if $n$ is square} \\\\\n        0 & \\text{otherwise}\n    \\end{cases}\\]\n\\end{problem}\n\\begin{proof}\n    We note that $\\lambda$ is multiplicative, and $g$ is a summatory function of $\\lambda$ which is multiplicative. So we just prove on prime powers. If we have prime power with even exponent, then $p, p^2, \\dots, p^{e_1}\\mid p^{e_1}$ gives $1 + (-1) + 1 + (-1) + \\cdots + 1 = 1$. We have $0$ otherwise.\n\\end{proof}", "meta": {"hexsha": "69fd627bca7affa10279daf0541310fb8e277100", "size": 6189, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-03-17.tex", "max_stars_repo_name": "jchen/math1560-notes", "max_stars_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-02T15:41:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T20:28:48.000Z", "max_issues_repo_path": "lectures/2022-03-17.tex", "max_issues_repo_name": "jchen/math1560-notes", "max_issues_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-03-17.tex", "max_forks_repo_name": "jchen/math1560-notes", "max_forks_repo_head_hexsha": "a3605894c69d4e3dd7f90829523ff3ec3c73a6f4", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.976744186, "max_line_length": 303, "alphanum_fraction": 0.5960575214, "num_tokens": 2116, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4098787521849062}}
{"text": "\\subsubsection{Hyperboloids of Two Sheets}\r\n\\noindent\r\nA hyperboloid of two sheets has 2 -'s and 1 + in its equation. It is made up of two disconnected, mirror image, surfaces.\r\n\r\n[INSERT IMAGE]", "meta": {"hexsha": "817a5a47fb6945d1bd5ad55f04ed1245e5b73e0f", "size": 194, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "multiCalc/differentialMultivariableCalculus/hyperboloidTwoSheet.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "multiCalc/differentialMultivariableCalculus/hyperboloidTwoSheet.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "multiCalc/differentialMultivariableCalculus/hyperboloidTwoSheet.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8, "max_line_length": 122, "alphanum_fraction": 0.7525773196, "num_tokens": 53, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4098787489370863}}
{"text": "\\chapter{Reinforcement Learning}\nThe robot controls its motors using artificial neural networks (ANN) and the deep deterministic policy gradient (DDPG) algorithm, developed by Lillicrap et al.\\ \\cite{lillicrap_2016}. The system runs in Python 3 \\cite{python3}, leaning heavily on the TensorFlow library with GPU support \\cite{tensorflow} for artificial neural network instantiation, updating, and saving. After training, the system actuates each of the four drive motors to move the robot to a desired position and orientation in the Roborodentia field while minimizing the velocity and effort applied (i.e. energy spent). Two different approaches are implemented to compare DDPG performance with three separate single-output actors versus a single multiple-output actor. Before delving into the implementation and results, the following sections briefly cover reinforcement learning (RL) techniques that form the foundation of DDPG. It is worth noting that Sutton's introductory book on RL provides excellent background on many of the following algorithms and more \\cite{sutton_2017}. \n\n\\section{Reinforcement Learning Background}\nReinforcement learning (RL) is a subset of machine learning that aims to solve control and action selection problems rather than to perform classification or data clustering. In other words, the concern lies in determining which actions an actor should take in an environment to receive the greatest reward. Most reinforcement learning problems involve six main elements: an actor, the environment, rewards, a policy, a value function, and sometimes a model. An actor (sometimes called an agent) takes actions in an environment which returns a state and reward, illustrated in Figure \\ref{fig:actor_env_loop}. The full state encompasses all the parameters of the environment and actor such as position, velocity, color, size, or any other measurable quantity; although the term ``state'' in this context refers to the subset of parameters observed by the actor. The actor's primary goal is to maximize the accumulated reward received from the environment. A policy determines which actions the actor takes given the current state. The value function indicates the long-term reward expected from a state and is defined for all possible states. To compare reward with value, even if a state only has a small immediate reward, it may possess high value since it leads to future high reward states. Finally, some algorithms involve a model of the environment, allowing prediction of the next state from the current state and action. Table \\ref{tab:rl_defs} summarizes some common terms and definitions used in the reinforcement learning literature.\n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=3in, height=3.85in, keepaspectratio]{figures/actor_env_loop.pdf}\n\t\\caption{Actor-Environment Feedback Loop}\\label{fig:actor_env_loop}\n\\end{figure}\n\\LTXtable{\\textwidth}{tables/tab_rl_defs.tex}\n\nTo better conceptualize these terms, consider a game of tic-tac-toe as shown in Figure \\ref{fig:tictactoe}. The \\textbf{environment} is the game itself, including the rules and game board. The two \\textbf{actors} (players) sequentially take the \\textbf{action} of placing marks in the boxes. The actions are encoded into some numeric form as defined by the designer. For example, $a=0$ might represent putting an X in the top left corner while $a=9$ might mean an X in the bottom right corner. Winning the game would grant a good \\textbf{reward} while tying or losing might yield a bad reward. The reward could also come turn-by-turn instead of at the end of the game. Lining up marks for a win might produce a good reward while letting the opponent set a trap might be bad. The designer could even assign reward magnitudes to weight the significance of each state. Note that the descriptors ``good'' and ``bad'' are deliberately vague as numerous valid implementations of the reward exist. Conceptually, the reward allows the actor to differentiate between desirable and undesirable actions and states. No single ``correct'' reward implementation exists, but one should be chosen to reflect the desired policy. Each of the nine spaces can take one of three values (blank, X, or O) so the game has $3^9=19,683$ possible \\textbf{states} (although some states are not achievable as the game would end once a player gets three in a row). Like the action, the rewards and states are represented numerically.\n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=2in, height=3.85in, keepaspectratio]{figures/tictactoe.pdf}\n\t\\caption{A Game of Tic Tac Toe}\\label{fig:tictactoe}\n\\end{figure}\n\n\\subsection{Long-Term Reward}\nActors strive to maximize the long-term discounted reward, $G_t$, where the subscript $t$ denotes the time step \\cite{sutton_2017}. As mentioned previously, reward reflects the actor's policy. For example, the goal of tic tac toe is to win which, to the actor, is equivalent to taking actions that lead to states that lead to good rewards. In RL problems with a definitive end (denoted by $t=T$) such as a game of chess, $G_t$ is finite and can be calculated simply as the sum of all future rewards as shown in Equation \\ref{eq:Gt_simple}. Additionally, the long-term aspect accounts for problems with intermediate rewards at each step. In chess, constantly trying to capture enemy pieces might yield some immediate good reward but may not actually be the best strategy for long-term success (i.e. winning the game).\n\\begin{equation}\n\t\\label{eq:Gt_simple}\n\tG_t=R_{t+1}+R_{t+2}+\\dots + R_{T}=\\sum_{k=t}^{T-1} R_{k+1}\n\\end{equation}\n\nHowever, continuous problems, such as maintaining the temperature of a refrigerator, have no maximum time step and therefore, a possibly infinite $G_t$. Shown in Equation \\ref{eq:Gt_discount}, the introduction of a discount factor, $\\gamma$, makes such a situation manageable. The discount factor weights the worth of future rewards exponentially by their distance into the future and ranges from 0--1 where 0 completely devalues future rewards while a discount factor of 1 weights all future rewards equally. In practice, the discount factor is less than 1 in order to allow $G_t$ to converge \\cite{sutton_2017}. The discount factor can be considered a knob that sets the algorithm's outlook between myopic (short-sighted, only values immediate rewards) and far-sighted (willing to sacrifice immediate reward for greater long-term returns).\n\\begin{equation}\n\\label{eq:Gt_discount}\n\tG_t=R_{t+1}+\\gamma R_{t+2}+\\gamma^2 R_{t+3} + \\dots = \\sum_{k=0}^{\\infty} \\gamma^k R_{t+k+1}\n\\end{equation}\n\n\\subsection{Value Functions}\nThe \\textbf{value} function $V_\\pi(s)$ is the expected long-term reward $G_t$ as a function of the state $s$ under a certain policy $\\pi$, written out in Equation \\ref{eq:value_func}. The $\\mathbb{E}_\\pi$ operator evaluates the expected value provided the actor continues to take actions following policy $\\pi$.\n\\begin{equation}\n\t\\label{eq:value_func}\n\tV_\\pi(s)=\\mathbb{E}_\\pi [G_t | s]\n\\end{equation}\n\nRelated but slightly different, the \\textbf{Q-function} or \\textbf{action-value} function $\tQ_\\pi(s,a)$ is the expected long-term reward $G_t$ as a function of the state $s$ \\textbf{and action} $a$ under a certain policy $\\pi$, shown in Equation \\ref{eq:q_func}. The important distinction from the value function is dependency on the action. While the value function describes the expected long-term reward from being in a particular state and continuing to follow actions under the policy $\\pi$, the Q-function returns the expected long-term reward from being in a particular state, taking a specific action, then continuing to follow actions under the policy $\\pi$. Since the Q-function uses three variables ($s$, $a$, and $Q$), it can be plotted in three dimensions as in Figure \\ref{fig:q_ex_plot}. Note that this is arbitrary plot for demonstration purposes more than representing actual Q-values for any particular environment. \n\nConsidering tic tac toe, if $s=0$ represents the starting, i.e. blank, state of the game, the red slice of Figure \\ref{fig:q_ex_plot} would represent the Q-values or expected long-term reward for each of the nine possible starting actions. Likewise, every slice would represent Q-values for the various actions taken in other game states, and the plot would have as many slices as there exist game states. Again, note that this is only an example and not the actual plot of tic tac toe's Q-function; it would use discrete points rather than the continuous function shown. The Q-function is defined for all possible states and actions so tic tac toe contains $19,683 \\text{ states} \\cdot 9 \\text{ actions} = 177,147$ discrete Q-values. Notice that the Q-function is non-obvious, highly non-linear, and may be continuous or discrete depending on the specific problem.\n\\begin{equation}\n\t\\label{eq:q_func}\n\tQ_\\pi(s,a)=\\mathbb{E}_\\pi [G_t |s,a]\n\\end{equation}\n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=4in, height=3.85in, keepaspectratio]{figures/q_ex_plot.png}\n\t\\caption{3D Q-Function Example}\\label{fig:q_ex_plot}\n\\end{figure}\n\n\\subsection{Policies}\nVarious policies exist but some of the most common include optimal, greedy, $\\epsilon$-greedy, and random. The optimal policy $\\pi_*$, by definition, produces greater or equal value for every possible state than any other policy $\\pi$, expressed in Equation \\ref{eq:optimalpol}, where $v_{\\pi_*}$ represents the value function of the optimal policy, $v_{\\pi}$ is the value function of any other policy $\\pi$, and $\\mathcal{S}$ is the set of all possible states. Ideally, the actor would eventually discover the optimal policy, but in reality, training always produces a sub-optimal policy except for the simplest of environments. \n\\begin{equation}\n\t\\label{eq:optimalpol}\nv_{\\pi_*}(s) \\geq v_{\\pi}(s), \\forall s \\in \\mathcal{S}\n\\end{equation}\nAn actor under the random policy always takes random actions while the greedy policy directs the actor to take the action with the highest value or Q-value depending on implementation. Although greediness does lead the actor to take actions that it believes maximize the reward, it may also cause the actor to get stuck following a suboptimal policy. For example, if a greedy actor is learning tic tac toe, it may discover that putting an X in the middle of the top row as the first move led it to win. Being greedy, it will keep putting the mark there since it sometimes leads to a reward. However, if the actor would stop being greedy and try something new, it would eventually discover that putting the first mark in a corner leads to victory more often. In other words, an actor following a greedy policy may not sufficiently explore the environment, i.e. try new things to discover better actions or states which lead to even greater reward. To allow a balance between exploration (discovering better rewards) and exploitation (obtaining as much reward as it can), the $\\epsilon$-greedy policy tells an actor to pick the greedy action with probability $1-\\epsilon$ and a random action with probability $\\epsilon$ where $\\epsilon$ ranges between 0 and 1. \n\n\n\\section{Reinforcement Learning Algorithms}\nMany reinforcement learning algorithms have been applied to action selection and control problems including Q-Learning, State-Action-Reward-State-Action (SARSA), deep Q-network (DQN), policy gradients (PG), deep policy gradients (DPG), and deep deterministic policy gradients (DDPG), among others \\cite{sutton_2017}\\cite{sutton_policygrad}\\cite{silver_2017}\\cite{silver_lever_heess_degris_wierstra_riedmiller}\\cite{lillicrap_2016}. Note that these methods differ from evolutionary algorithms in that they actively learn as they interact with the environment. Instead, evolutionary techniques evaluate the performance of individual actors in a population by determining how much reward each produces while operating in the environment, take the best performers, mutate them slightly to produce new behaviors, and repeat until a good policy emerges. The process is highly reminiscent of natural selection while the algorithms to be discussed are more akin to a child learning to walk \\cite{natural_selection}.\n\nRL algorithms can be classified by their use of models (model-based vs.\\ model-free) and actor policy (on-policy vs.\\ off-policy) \\cite{sutton_2017}. Model-based strategies first develop a model of the environment and then use a planning algorithm along with the model to create a controller, while model-free algorithms forgo the model entirely. On-policy strategies learn the policy followed by the actor while off-policy techniques learn a policy different from the one followed by the actor. For example, in Q-learning, the Q-function updates its weights based on the next state and the greedy action (which is not actually executed) even if the actor is following the random policy \\cite{sutton_2017}. The greedy action is determined by searching the Q-function in the next state for the action producing the highest Q-value, further explained in the Q-Learning section.\n\n\\subsection{Q-Learning}\nQ-Learning is an off-model, off-policy algorithm that estimates the Q-function of the environment \\cite{sutton_2017}. The Q-function represents the ``quality'' of every possible action in every possible state. Given a particular state, the Q-function returns the quality, i.e.\\ predicted goodness, of each possible action the player could take. Therefore, the optimal action to take is simply the one with the highest Q-value. \n\nClearly, the Q-function always exists but not necessarily in an analytic or obvious form. So-called tabular Q-learning methods use a 2-D matrix to represent the Q-function with rows for all possible states and columns for all possible actions \\cite{mccullock}. The table is initialized with guesses (possibly randomly or with all elements set to 0) and iteratively updated to produce an approximation closer and closer to the true Q-function $Q^*$ using the Bellman equation presented in Equation \\ref{eq:bellman}. The equation states that the expected long-term reward Q for state $s$ and action $a$ is equal to the reward received from being in state $s$ plus the discounted ($\\gamma$) maximum Q of the next state $s'$. In simpler terms, the expected long-term reward is the current state's reward plus the best reward obtainable in the next state (weighted by $\\gamma$). For clarity, the $\\text{max}_{a'}(\\cdot)$ operator chooses $a'$ to maximize its argument $(\\cdot)$ so $\\text{max}_{a'}(Q(s',a'))$ means the maximum Q of the next state $s'$ irrespective of the action $a'$. The proof that the Bellman equation does allow iterative Q-value calculation is beyond the scope of this thesis, but Sutton's book, \\textit{Reinforcement Learning: An Introduction}, provides further explanation \\cite{sutton_2017}.\n\\begin{equation}\n\t\\label{eq:bellman}\n\tQ(s,a)=R(s) + \\gamma (\\text{max}_{a'}(Q(s',a')))\n\\end{equation}\n\nTo improve convergence, i.e. when the estimated Q-function approaches the optimal $Q^*$, Equation \\ref{eq:bellman} is modified to include the learning rate $\\alpha$, ranging between 0 and 1, which reduces the change in the Q-function with each iteration, shown in Equation \\ref{eq:bellman_alpha}. The pseudocode for Q-learning presented by Sutton is reproduced in Table \\ref{list:qlearning_pseudo} with permission. Some environments, like chess, eventually terminate (at the end of the game) while others, such as maintaining a refrigerator's temperature, may never actually terminate.\n\\begin{equation}\n\t\\label{eq:bellman_alpha}\n\tQ(s,a)=(1-\\alpha)Q(s,a) + \\alpha[R(s) + \\gamma (\\text{max}_{a'}(Q(s',a')))]\n\\end{equation}\n\\begin{clisting}[caption={Q-Learning Pseudocode},label={list:qlearning_pseudo}]\nInitialize Q(s,a) arbitrarily. \nRepeat for each episode: \n\tInitialize s\n\tRepeat for each step of episode:\n\t\tChoose a from s using policy derived from Q (e.g., epsilon-greedy)\n\t\tTake action a, observe r, s'\n\t\tQ(s,a) = (1 - alpha) * Q(s,a) + alpha * [r + gamma * max_a(Q(s',a'))]\n\t\ts = s';\n\tuntil s is terminal \n\\end{clisting}\n\nNotice the algorithm recursively updates the Q-value, $Q(s,a)$, from the Q-value of the next state and greedy policy action, $\\text{max}_{a'}Q(s',a')$, regardless of the policy and action taken by the actor. This characteristic makes Q-learning an off-policy algorithm. The Q-value for a particular state and action only updates when the actor visits said state and action so the actor must still explore (i.e.\\ not always take greedy actions) for Q-learning to converge. Figure \\ref{fig:q_learning_ex} illustrates an example of one step of recursive Q-function update using the tic tac toe. \n\\begin{figure}   % [h] means here\n\t\\centering \\includegraphics[width=6in, height=8.5in, keepaspectratio]{figures/q_learning_ex.pdf}\n\t\\caption{Tabular Q Update Example}\\label{fig:q_learning_ex}\n\\end{figure}\n\nClearly, the tabular Q method quickly becomes unfeasible for more complex problems, especially when the states or actions are continuous rather than discrete. When the action or state spaces are continuous, the algorithm must discretize them, forcing a tradeoff between resolution and tractability. For the tic-tac-toe example, the table would be 19,683 rows by 9 columns for a total of 177,147 Q-values while the Q-value table for a game of chess would possess more elements than there are atoms in the known universe. Hence, methods such as the yet-to-be-discussed Deep Q-Network Method represent the Q-function using other structures like artificial neural networks.\n\n\\subsection{State-Action-Reward-State-Action (SARSA)}\nSARSA is an on-policy algorithm which shares many characteristics with Q-learning \\cite{sutton_2017}. The name comes from the fact that the Q update equation uses the current \\textbf{s}tate and \\textbf{a}ction as well as the next \\textbf{r}eward, \\textbf{s}tate, and \\textbf{a}ction. The pseudocode for SARSA presented by Sutton is reproduced in Table \\ref{list:sarsa} with permission.\n\\begin{clisting}[caption={SARSA Pseudocode},label={list:sarsa}]\nInitialize Q(s,a) arbitrarily. \nRepeat for each episode: \n\tInitialize s\n\tChoose a from s using policy derived from Q (e.g., epsilon-greedy)\n\tRepeat for each step of episode:\n\t\tTake action a, observe r, s'\n\t\tChoose a' from s' using policy derived from Q (e.g., epsilon-greedy)\n\t\tQ(s,a) = (1 - alpha) * Q(s,a) + alpha * [r + gamma * Q(s',a')]\n\t\ts = s'; a = a';\n\tuntil s is terminal \n\\end{clisting}\n\nUnlike Q-learning, SARSA updates Q-values from the next state and next action $Q(s',a')$, making it an on-policy strategy. Like Q-learning, the actor must take exploratory actions for the algorithm to update Q at all states and actions and achieve convergence.\n\n\\subsection{Deep Q Network (DQN)}\nDeep Q Networks, developed by Mnih et al. \\cite{Mnih_2015}, aim to solve two significant problems with Q-learning and SARSA: the inability to handle situations with large state and action spaces and the inability to generalize learnings to new situations \\cite{sutton_policygrad}. As mentioned previously, maintaining Q-values for the entire state and action space of a complex problem requires enormous memory. The second problem has to do with how the Q-value table updates. In both Q-learning and SARSA, the algorithms iteratively update Q-values for visited (state, action) pairs. However, to fully update the Q-value table means exploring every possible state and action combination multiple times, a non-trivial task. In other words, the algorithms cannot provide reasonable Q-value estimates for unvisited situations.\n\nTo overcome these limitations, DQN replaces the tabular Q concept with an artificial neural network (ANN) where the inputs are the state and action and the output is the Q-value. The Q-network is denoted as $Q(s,a;\\theta_i)$ where $\\theta_i$ represents the network weights. The loss function, displayed in Equation \\ref{eq:dqn_loss_func}, is the squared error between the Q-network output and the ``target Q-value'' as defined by the Bellman equation, $y_j = r + \\gamma \\text{max}_{a'}Q(s', a';\\theta^-_i)$  \\cite{Mnih_2015}. For complete clarity, $Q(s,a;\\theta^-_i)$ represents an identical but separate copy of Q-network $Q(s,a;\\theta_i)$ except with weights $\\theta^-_i$ from a previous iteration, explained later.\n\\begin{equation}\n\t\\label{eq:dqn_loss_func}\nL_i(\\theta_i) = (r + \\gamma \\text{max}_{a'}Q(s', a';\\theta^-_i)-Q(s,a;\\theta_i))^2\n\\end{equation}\n\nTo assist DQN training, Mnih et al.\\ used a technique called experience replay \\cite{Mnih_2015} As the actor explores within environment, the algorithm records transitions consisting of the current state, action taken, reward, and next state at each time step into a so-called experience replay buffer. After collecting a minimum number of experiences, the artificial neural network trains from data sampled randomly from the buffer, hence the name ``experience replay''. The technique removes time correlations in the training data, improves convergence, and also allows experience reuse, advantageous when obtaining data is difficult or costly. In the context of ANNs, convergence refers to when the ANN output approaches the function being approximated by the network.\n\nThe second technique Mnih et al.\\ used to counter training instability, i.e. when the network weights oscillate instead of settling, involves generating target Q-values, $y_j$, from an identical but separate ANN, called the target Q-network $\\hat{Q}$ with weights $\\theta^-_i$. In effect, this creates a time delay between when the weights of $Q$ are updated and when those updates affect the policy and target Q-network, reducing the likelihood of policy instability. For example, using a size 64 mini-batch, the network randomly samples 64 transitions from the experience replay buffer and trains the network $Q$ with 64 iterations as in Equation \\ref{eq:dqn_loss_func}. After, the target network $\\hat{Q}$ clones the weights $\\theta_i$ from $Q$ and the process repeats.\n\nThe DQN method replaces the tabular Q with an artificial neural network to solve RL problems with large Q spaces. However, the algorithm's policy still uses a discrete action space, posing a problem for situations requiring continuously variable actions. For example, a system with five continuous actions discretized into a mere four bits each already produces $(2^4)^5=1,048,576$ different action combinations. Policy gradient methods can overcome this limitation as described next.\n\n\\subsection{Stochastic Policy Gradient Method}\nQ-Learning, SARSA, and DQN are value-based methods as they rely on finding the environment's underlying Q-function and produce a policy to maximize Q. Policy gradient methods find the optimal policy directly, making them policy-based strategies \\cite{sutton_policygrad}. DeepMind's AlphaGo demonstrated PG's viability by famously defeating grandmaster Go player Fan Hui in 2015 and Lee Sedol in 2016 \\cite{silver_2017}.\n\nThe core of the policy gradient method is the parametrized probabilistic action distribution $P[a|s;\\theta]$. Essentially, the distribution defines the probability of taking any particular action in the set of all possible actions for a particular given state $s$. For example, if an actor has three possible actions, they might occur 10\\%, 30\\%, and 60\\% of the time, respectively. However, since $P[a|s;\\theta]$ is continuous, the policy would produce continuous-valued actions rather than three discrete ones. The parameters $\\theta$ adjust the distribution's shape and therefore the likelihoods of each action. \n\nThe underlying premise of stochastic policy gradients is simple: get a state, take a particular action picked stochastically from probability distribution $P[a|s;\\theta]$, and record the reward. If the reward is ``good'', increase the probability of taking that action by modifying $\\theta$ or decrease it if the reward is ``bad''.\\footnote{Note that the terms ``good'' and ``bad'' are intentionally vague as to not constrain them to one particular interpretation.} After many iterations, the actor will most likely take actions that produce good rewards. But of course, not all is so simple. Much like the so-called ``butterfly effect'' \\cite{Lorenz_1963}, a single action can cascade into a multitude of unknown futures meaning the worth of a particular action cannot be determined by the immediate reward produced.\n\nInstead, the rewards are accumulated for a long period in episodes, at the end of which actions are judged based on the total reward. Now, a different issue arises: the credit assignment problem \\cite{fu_2008}. If an episode contains 1,000 actions, which ones ultimately produced the good reward and which were inconsequential or detrimental? Rather than determining the individual ones responsible, the algorithm deems all the actions in the episode culpable so if the episode's outcome is good, all actions taken become more likely and if not, the inverse occurs \\cite{karpathy_2016}. Like AlphaGo, many policy gradient implementations use an artificial neural network to represent the action probability distribution where the inputs are states and outputs are action probabilities \\cite{silver_2017}. Therefore, the act of making actions more or less probable is carried out with gradient descent similar to back propagation for ANNs \\cite{karpathy_2016}. However, the specific implementation details are beyond the scope of the thesis.\n\n\\subsection{Deterministic Policy Gradient Method (DPG)}\nThe deterministic policy gradient method (DPG), developed by Silver et al., shares the same foundation as stochastic policy gradients, but instead of representing the policy as a probability distribution, the policy deterministically chooses an action given a particular state \\cite{silver_lever_heess_degris_wierstra_riedmiller}. Silver et al.\\ have shown that the DPG is actually a limiting case of stochastic policy gradients where the policy distribution variance is 0. Another key difference is that while the stochastic policy gradient integrates over the state and action spaces, the DPG only integrates over the state space. Consequently, the stochastic case requires more samples to compute. Specific details can be found in the original paper. Finally, while the stochastic policy inherently chooses exploratory actions due to its probabilistic nature, the deterministic case is more akin to a greedy policy. Therefore, Silver developed an off-policy learning algorithm using a stochastic policy to ensure sufficient exploration despite producing a deterministic policy.\n\n\\subsection{Deep Deterministic Policy Gradient (DDPG)} \\label{sec:ddpg}\nThe robot's motors are controlled with continuous actions so the policy gradient method provides a decent solution. However, PG methods converge more slowly and have less learning stability than the DQN algorithm, as compared in Table \\ref{tab:dqn_pg_comparison} \\cite{yu_dqn_vs_pg}. Therefore, the deep deterministic policy gradient (DDPG), developed by Lillicrap et al., augments the DPG algorithm with techniques from DQN to obtain the best of both worlds.\n\n\\begin{table}[h]\n\t\\caption{DQN and PG Comparison \\cite{yu_dqn_vs_pg}}  \\label{tab:dqn_pg_comparison}\n\t\\begin{tabularx}{\\textwidth}{@{} l|c|c @{}}\n\t\t\\toprule\n\t\t& Deep Q-Network Method & Policy Gradient Method \\\\ \n\t\t\\midrule\n\t\tPolicy Action Space & Discrete & Continuous \\\\\n\t\tPolicy State Space & Continuous & Continuous \\\\\n\t\tQ-Function Action Space & Continuous & n/a \\\\\n\t\tQ-Function State Space & Continuous & n/a \\\\\n\t\tLearning Stability & More Stable & Less Stable \\\\\n\t\tConvergence Speed & Faster & Slower \\\\\n\t\t\\bottomrule\n\t\\end{tabularx} \n\\end{table}\n\nThe DDPG algorithm is a model-free, off-policy actor-critic strategy based on Silver et al.'s DPG algorithm combined with learnings from Mnih et al.'s work on the DQN algorithm \\cite{lillicrap_2016}\\cite{Mnih_2015}\\cite{silver_lever_heess_degris_wierstra_riedmiller}. DDPG improves on DPG by representing the actor's policy with an ANN and applying the experience replay and target network techniques from DQN. The actor-critic architecture, shown in Figure \\ref{fig:actor_critic}, uses techniques from policy-based methods (find the policy directly) as well as value-based methods (estimate Q-function) \\cite{actor_critic}. Each DDPG network uses an ANN for the actor and critic each plus another two for the target networks for a total of four ANNs. \n\\begin{figure} [h] %means here\n\t\\centering \\includegraphics[width=6in, height=3.5in, keepaspectratio]{figures/actor_critic.pdf}\n\t\\caption{Actor-Critic Architecture}\\label{fig:actor_critic}\n\\end{figure}\n\nThe two major steps in any actor-critic method are actor improvement and critic evaluation \\cite{actor_critic}. During actor improvement, the Q-values (more specifically, the gradient thereof) produced by the critic are used to train the actor network to better follow the policy. During critic evaluation, the critic, which is really just a Q-approximator as implemented in DQN, is improved using the Bellman equation. Conceptually, the actor and critic are much like a basketball player and coach. The coach learns the game and comes up with a strategy while the player focuses on executing the plan as best as possible.\n\nAdditionally, Lillicrap et al.\\ adapted batch normalization from Ioffe's work to allow ANN hyper-parameter generalization for environments with features of varying magnitude \\cite{2015arXiv150203167I}; each feature in a minibatch is normalized to unit mean and variance. In other words, the DDPG algorithm can use the same set of hyper-parameters, e.g. learning rates, discount factor, update parameter $\\tau$, etc., for widely different environments. In their implementation, batch normalization was applied to network inputs, all layers of the policy network, and all layers of the Q network before the action input (detailed later).\n\nTo ensure adequate exploration, Lillicrap et al.\\ added Ornstein-Uhlenbeck process noise to the policy output $\\mu(s_t | \\theta^\\mu_t)$ to create the exploration policy $\\mu'(s_t)$ as shown in Equation \\ref{eq:exploration_policy} \\cite{lillicrap_2016}. The Ornstein-Uhlenbeck process satisfies the condition shown in Equation \\ref{eq:ornstein-uhlenbeck} where $x_t$ is the process position at time $t$, $\\theta$ and $\\sigma$ are parameters, and $W_t$ is the Weiner process \\cite{uhlenbeck_ornstein}. The process produces random, time-correlated values that drift toward a long-term mean, in this case 0. The Ornstein-Uhlenbeck action noise class shown in Listing \\ref{list:ornstein-uhlenbeck} is provided by OpenAI under the MIT License \\cite{ddpg_noise}.\n\\begin{equation}\n\\label{eq:exploration_policy}\n\\mu'(s_t) = \\mu(s_t | \\theta^\\mu_t) + \\mathcal{N}\n\\end{equation}\n\\begin{equation}\n\\label{eq:ornstein-uhlenbeck}\ndx_t = \\theta(\\mu-x_t) dt + \\sigma dW_t, \\theta>0, \\sigma>0\n\\end{equation}\n\nLillicrap et al.\\ used DDPG to solve over 25 different simulated physics environments such as cart pole swing-up and driving using the same network architecture and hyper-parameters, demonstrating the generalizability of the technique. For details of the environments, see OpenAI Gym \\cite{openaigym}. Although the approach required about 2.5 million steps of experience to solve most problems, this represents 20 times less than DQN while still providing better performance in most cases.\n\nTo reiterate, the important advantage of the DDPG technique is its ability to handle both continuous action and state spaces of varying magnitude, critical to many real-life control problems. Specific algorithm details are covered in the Implementation section.\n\n\\begin{python}[caption={Ornstein-Uhlenbeck Action Noise \\cite{ddpg_noise}},label={list:ornstein-uhlenbeck}]\nclass OrnsteinUhlenbeckActionNoise:\n    def __init__(self, mu, sigma=0.3, theta=.15, dt=0.05, x0=None):\n        self.theta = theta\n        self.mu = mu\n        self.sigma = sigma\n        self.dt = dt\n        self.x0 = x0\n        self.reset()\n\n    def __call__(self):\n        x = self.x_prev + self.theta * (self.mu - self.x_prev) * self.dt + \\\n                self.sigma * np.sqrt(self.dt) * np.random.normal(size=self.mu.shape)\n        self.x_prev = x\n        return x\n\n    def reset(self):\n        self.x_prev = self.x0 if self.x0 is not None else np.zeros_like(self.mu)\n\n    def __repr__(self):\n        return 'OrnsteinUhlenbeckActionNoise(mu={}, sigma={})'.format(self.mu, self.sigma)\n\\end{python}\n\n\\section{Implementation}\nAll code is implemented in Python 3.6 and uses modules from TensorFlow \\cite{tensorflow} (ANN implementation), OpenAI Gym (Ornstein-Uhlenbeck action noise) \\cite{openaigym}, and Pyglet (environment rendering). An implementation of Lillicrap's DDPG algorithm from Patrick Emami's reinforcement learning primer formed the initial code base to which modifications and new developments were added \\cite{emami_2016}.\n\n\n\\subsection{Coordinate Definitions}\nThe Roborodentia field is 2438.4 mm long in the $x$ direction and 1219.2 mm wide in $y$ as shown in Figure \\ref{fig:field_defs} \\cite{roborodentia}. Viewed from above, the coordinate (0 mm, 0 mm) is the bottom-left corner while (2438.4 mm, 1219.2 mm) is the top-right. Units of position ($x$ and $y$), orientation, linear velocity, and rotational velocity are mm, mm/s, radians, and radians/s, respectively.\n\nThe robot position and orientation, ($x$, $y$, $\\theta$), is represented as a vector in the field plane where the vector's tail is positioned at the robot center and tip at the robot's front. Note that the vector orientation deviates from standard notation. At 0 radians, the vector points in the $+y$ direction, and at $+\\pi/2$ radians, it points towards $-x$. \n\nThe $x$ and $y$ velocity of the robot refer to motion parallel to the field's x-axis and y-axis while the rotational velocity refers to the robot's rotation about its center. They are defined as $\\dot{x}$, $\\dot{y}$, and $\\dot{\\theta}$. \n\nThree control inputs $u_x$, $u_y$, and $u_\\theta$ correspond to the force applied to the robot and range between -2 to +2. For absolute clarity, positive $u_x$ moves the robot in the direction of the positive x-axis, positive $u_y$ pushes towards the positive y-axis, and positive $u_\\theta$ torques the robot in the positive $\\theta$ direction. \n\\begin{figure}[H]\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/field_defs.png}\n\t\\caption{Roborodentia Field Definitions} \\label{fig:field_defs}\n\\end{figure}\n\n\\subsection{Robot Simulation}\nSince training the network using the real-life robot is difficult and time-consuming, episodes take place in a simulation of the robot and competition field. While an ideal simulation would model many kinematics and dynamics of the robot, robust system modeling is beyond the scope of the thesis. Instead, a rudimentary model serves to demonstrate the efficacy of the DDPG algorithm. \n\nThe simulation accounts for maximum wheel velocity and acceleration and calculates robot movement as a function of the four wheel velocities using the mecanum wheel equations \\cite{li_2018}\\cite{rahman_2014}. It also handles collision with the environment walls. The simulation does not model unequal loading and friction between wheels, the momentum of the robot as a whole, or small differences between the motors and wheels.\n\n\\subsection{Reward Assignment}\nThe reward assignment must reflect the actor's goal: to move the robot to a desired position and orientation in the field. The resulting policy after training depends greatly on careful selection of which actions and/or states receive better or worse rewards. The rewards as implemented, shown in Equations \\ref{eq:reward_x} to \\ref{eq:reward_uth}, consist of three categories: distance from the set point, velocity, and action value. Note that the $\\text{norm}(\\cdot)$ function normalizes the angle to between $-\\pi$ and $+\\pi$. Each of the nine reward equations produces a maximum reward of 0 and includes squared terms to introduce quadratic reward scaling.\n\nThe coefficients for $r_\\theta$, $r_{\\dot{\\theta}}$, and $r_{u_\\theta}$ come from OpenAI Gym's pendulum environment \\cite{openai_pendulum}. The other coefficients scale the reward magnitudes within each category close to each other. For example, the minimum $r_{y} = -0.00001 (1200 - 0)^2 = -14.4$ while the minimum $r_{\\theta} = -1.0 (\\pi)^2 = -9.9$. Finally, the coefficients were adjusted through trial-and-error: the algorithm was run multiple times with slightly varied coefficients until the author felt the policy was ``good enough''. Future work includes a more systematic way to determine these coefficients.\n\\begin{align}\nr_x &= -0.00001 (x-x_{desired})^2 \\label{eq:reward_x}\\\\\nr_y &= -0.00001 (y-y_{desired})^2 \\\\\nr_\\theta &= -1.0 (norm(\\theta)-norm(\\theta_{desired}))^2 \\\\\nr_{\\dot{x}} &= -0.0000005 \\dot{x}^2 \\\\\nr_{\\dot{y}} &= -0.0000005 \\dot{y}^2 \\\\\nr_{\\dot{\\theta}} &= -0.1 \\dot{\\theta}^2 \\\\\nr_{u_x} &= -0.001u_x^2 \\\\\nr_{u_y} &= -0.001u_y^2 \\\\\nr_{u_\\theta} &= -0.001u_\\theta^2 \\label{eq:reward_uth}\n\\end{align}\n\n\\subsection{Artificial Neural Networks}\n\\subsubsection{Critic Network}\nListing \\ref{list:critic_net} implements the critic network class. The function \\\\\n\\mbox{\\pythoninline{create_critic_network()}} at line 55 instantiates the TensorFlow network graph. The critic consists of a \\mbox{\\pythoninline{s_dim}-node} state input layer, another \\mbox{\\pythoninline{a_dim}-node} action input layer, two fully connected hidden layers, and a 1-node output layer, illustrated in Figure \\ref{fig:critic_net}. The state input layer enters into the first hidden layer while the action input layer connects to the second hidden layer. The first hidden layer uses a fully connected network layer of weights with biases, a batch normalization layer described previously in Section \\ref{sec:ddpg}, and the Rectified Linear Unit (ReLU) activation function $ReLU(x) = max(0,x)$. Deep neural networks widely use the ReLU function for speeding up large computations both in forward and backward passes of the network \\cite{2017arXiv171005941R}. The derivative of the ReLU function is simply 1 for positive inputs and 0 otherwise, greatly simplifying the back propagation algorithm. The second hidden layer consists of 600 nodes, half of which connect to the first hidden layer output and half that connect to the action input layer. Finally, the output layer is a single node with no activation function to obtain linear output.\n\nThe \\pythoninline{action_gradients()} function returns a list of the gradients of the output with respect to each action, used by the actor network to update its weights. Finally, the \\pythoninline{train()} function optimizes network weights and biases to minimize the loss function using the Adam optimizer \\cite{adam_opt}. The loss is defined as the mean square value of the difference between the mini-batch of critic outputs and the mini-batch of predicted Q-value from the target network equivalent to Equation \\ref{eq:dqn_loss_func}. The Adam method, developed by Kingma and Ba, stands for ``adaptive moment estimation'' and possesses many of the benefits afforded by the AdaGrad and RMSProp algorithms including compatibility with sparse gradients, parameter update magnitudes invariant to gradient rescaling, step size annealing, and bounded step size \\cite{duchi_2011}\\cite{adam_opt}\\cite{tieleman_2012}.\n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=6in, height=8.5in, keepaspectratio]{figures/critic_net.pdf}\n\t\\caption{Critic ANN Structure}\\label{fig:critic_net}\n\\end{figure}\n\n\\begin{python}[caption={Critic Network Class},label={list:critic_net}]\nCRITIC_L1_NODES = 400\nCRITIC_L2_NODES = 300\n\nclass CriticNetwork(object):\n    \"\"\"\n    Input to the network is the state and action, output is Q(s,a).\n    The action must be obtained from the output of the Actor network.\n\n    \"\"\"\n\n    def __init__(self, sess, state_dim, action_dim, learning_rate, tau, gamma, num_actor_vars):\n        self.sess = sess\n        self.s_dim = state_dim\n        self.a_dim = action_dim\n        self.learning_rate = learning_rate\n        self.tau = tau\n        self.gamma = gamma\n\n        # Create the critic network\n        self.inputs, self.action, self.out = self.create_critic_network()\n\n        self.network_params = tf.trainable_variables()[num_actor_vars:]\n\n        # Target Network\n        self.target_inputs, self.target_action, self.target_out = self.create_critic_network()\n\n        self.target_network_params = tf.trainable_variables()[(len(self.network_params) + num_actor_vars):]\n\n        # Op for periodically updating target network with online network\n        # weights with regularization\n        self.update_target_network_params = [self.target_network_params[i].assign( \\\n            tf.multiply(self.network_params[i], self.tau) + \\\n            tf.multiply(self.target_network_params[i], 1. - self.tau)) \\\n                for i in range(len(self.target_network_params))]\n\n        # Network target (y_i)\n        self.predicted_q_value = tf.placeholder(tf.float32, [None, 1])\n\n        # Define loss and optimization Op\n        self.loss = tflearn.mean_square(self.predicted_q_value, self.out)\n        self.optimize = tf.train.AdamOptimizer(\n            self.learning_rate).minimize(self.loss)\n\n        # Get the gradient of the net w.r.t. the action.\n        # For each action in the mini-batch (i.e., for each x in xs),\n        # this will sum up the gradients of each critic output in the mini-batch\n        # w.r.t. that action. Each output is independent of all\n        # actions except for one.\n        self.action_grads = tf.gradients(self.out, self.action)\n\n        self.num_trainable_vars = len(\n            self.network_params) + len(self.target_network_params)\n\n\n    def create_critic_network(self):\n        inputs = tflearn.input_data(shape=[None, self.s_dim], name='CriticInputs')\n        action = tflearn.input_data(shape=[None, self.a_dim], name='CriticAction')\n        net = tflearn.fully_connected(inputs, CRITIC_L1_NODES, name='CriticInputsNet')\n        net = tflearn.layers.normalization.batch_normalization(net)\n        net = tflearn.activations.relu(net)\n\n        # Add the action tensor in the 2nd hidden layer\n        # Use two temp layers to get the corresponding weights and biases\n        t1 = tflearn.fully_connected(net, CRITIC_L2_NODES, name='CriticNetT1')\n        t2 = tflearn.fully_connected(action, CRITIC_L2_NODES, name='CriticActionT2')\n\n        net = tflearn.activation(\n            tf.matmul(net, t1.W) + tf.matmul(action, t2.W) + t2.b, activation='relu')\n\n        # linear layer connected to 1 output representing Q(s,a)\n        # Weights are init to Uniform[-3e-3, 3e-3]\n        w_init = tflearn.initializations.uniform(minval=-0.003, maxval=0.003)\n        out = tflearn.fully_connected(net,1, weights_init=w_init,name='CriticNetOut')\n        return inputs, action, out\n\n    def train(self, inputs, action, predicted_q_value):\n        return self.sess.run([self.out, self.optimize], feed_dict={\n            self.inputs: inputs,\n            self.action: action,\n            self.predicted_q_value: predicted_q_value\n        })\n\n    def predict(self, inputs, action):\n        return self.sess.run(self.out, feed_dict={\n            self.inputs: inputs,\n            self.action: action\n        })\n\n    def predict_target(self, inputs, action):\n        return self.sess.run(self.target_out, feed_dict={\n            self.target_inputs: inputs,\n            self.target_action: action\n        })\n\n    def action_gradients(self, inputs, actions):\n        return self.sess.run(self.action_grads, feed_dict={\n            self.inputs: inputs,\n            self.action: actions\n        })\n\n    def update_target_network(self):\n        self.sess.run(self.update_target_network_params)\n\\end{python}\n\n\\subsubsection{Actor Network}\nListing \\ref{list:actor_net} implements the actor ANN. The function \\pythoninline{create_actor_network()} at line 56 defines the TensorFlow graph of the network. The actor uses an \\pythoninline{s_dim}-node input layer, two fully connected hidden layers, and a  \\pythoninline{a_dim}-node output layer, illustrated in Figure \\ref{fig:actor_net}. The two hidden layers consist of a fully connected network layer of weights with biases, a batch normalization layer described previously, and the ReLU activation function. The two hidden layers use 400 and 300 nodes, respectively, matching Lillicrap's implementation \\cite{lillicrap_2016}. Finally, the output layer is a fully connected network, $\\text{tanh}(\\cdot)$ activation function to limit the output to $[-1,+1]$, and a multiplier to scale the output to $[-$\\pythoninline{action_bound}$,+$\\pythoninline{action_bound}$]$.\n\nThe \\pythoninline{train()} function implements the key idea of the policy gradient method. The gradient of the output with respect to the network weights and biases are calculated and weighted the by the action gradients obtained from the critic. The weighting step effectively makes ``good'' actions more likely and ``bad'' actions less likely. The gradients are normalized by the batch size and then applied to the network weights and biased according to the Adam optimization method. \n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/actor_net.pdf}\n\t\\caption{Actor ANN Structure}\\label{fig:actor_net}\n\\end{figure}\n\\newpage\n\\begin{python}[caption={Actor Network Class},label={list:actor_net}]\nACTOR_L1_NODES = 400\nACTOR_L2_NODES = 300\n\nclass ActorNetwork(object):\n    \"\"\"\n    Input to the network is the state, output is the action\n    under a deterministic policy.\n\n    The output layer activation is a tanh to keep the action\n    between -action_bound and action_bound\n    \"\"\"\n\n    def __init__(self, sess, state_dim, action_dim, action_bound, learning_rate, tau, batch_size):\n        self.sess = sess\n        self.s_dim = state_dim\n        self.a_dim = action_dim\n        self.action_bound = action_bound\n        self.learning_rate = learning_rate\n        self.tau = tau\n        self.batch_size = batch_size\n\n        # Actor Network\n        self.inputs, self.out, self.scaled_out = self.create_actor_network()\n\n        self.network_params = tf.trainable_variables()\n\n        # Target Network\n        self.target_inputs, self.target_out, self.target_scaled_out = self.create_actor_network()\n\n        self.target_network_params = tf.trainable_variables()[\n            len(self.network_params):]\n\n        # Op for periodically updating target network with online network\n        # weights\n        self.update_target_network_params = [self.target_network_params[i].assign( \\\n                tf.multiply(self.network_params[i], self.tau) + \\\n                tf.multiply(self.target_network_params[i], 1. - self.tau))\n                for i in range(len(self.target_network_params))]\n\n        # This gradient will be provided by the critic network\n        self.action_gradient = tf.placeholder(tf.float32, [None, self.a_dim])\n\n        # Combine the gradients here\n        self.unnormalized_actor_gradients = tf.gradients(\n            self.scaled_out, self.network_params, -self.action_gradient)\n        self.actor_gradients = list(map(lambda x: tf.div(x, self.batch_size), \n            self.unnormalized_actor_gradients))\n\n        # Optimization Op\n        self.optimize = tf.train.AdamOptimizer(self.learning_rate).\\\n            apply_gradients(zip(self.actor_gradients, self.network_params))\n\n        self.num_trainable_vars = len(\n            self.network_params) + len(self.target_network_params)\n\n    def create_actor_network(self):\n        inputs = tflearn.input_data(shape=[None, self.s_dim], name='ActorInputs')\n        net = tflearn.fully_connected(inputs, ACTOR_L1_NODES, name='ActorInputsNet')\n        net = tflearn.layers.normalization.batch_normalization(net, name='ActorBatchNorm1Net')\n        net = tflearn.activations.relu(net)\n        net = tflearn.fully_connected(net, ACTOR_L2_NODES, name='ActorNetNet')\n        net = tflearn.layers.normalization.batch_normalization(net, name='ActorBatchNorm2Net')\n        net = tflearn.activations.relu(net)\n        # Final layer weights are init to Uniform[-3e-3, 3e-3]\n        w_init = tflearn.initializations.uniform(minval=-0.003, maxval=0.003)\n        out = tflearn.fully_connected(\n            net, self.a_dim, activation='tanh', weights_init=w_init, name='ActorOutNet')\n        # Scale output to -action_bound to action_bound\n        scaled_out = tf.multiply(out, self.action_bound)\n        return inputs, out, scaled_out\n\n    def train(self, inputs, a_gradient):\n        self.sess.run(self.optimize, feed_dict={\n            self.inputs: inputs,\n            self.action_gradient: a_gradient\n        })\n\n    def predict(self, inputs):\n        return self.sess.run(self.scaled_out, feed_dict={\n            self.inputs: inputs\n        })\n\n    def predict_target(self, inputs):\n        return self.sess.run(self.target_scaled_out, feed_dict={\n            self.target_inputs: inputs\n        })\n\n    def update_target_network(self):\n        self.sess.run(self.update_target_network_params)\n\n    def get_num_trainable_vars(self):\n        return self.num_trainable_vars\n\\end{python}\n\nBoth actor and critic classes create a regular and target network in the \\mbox{\\pythoninline{__init__()}} function. Each target network is structurally identical to its respective actor or critic network. Recall the network weights are denoted as $\\theta_i$ while target network weights use $\\theta^-_i$. Each class provides a function \\pythoninline{update_target_network()}  that adjusts target network weights to be closer to the regular network weights by the factor $\\tau=0.001$ as in Equation \\ref{eq:target_update}. The \\pythoninline{predict()} and \\pythoninline{predict_targets()} functions return the forward pass output of the regular and target networks, respectively.\n\\begin{equation}\n\\label{eq:target_update}\n\\theta^-_i \\gets \\tau\\theta_i + (1-\\tau)\\theta^-_i\n\\end{equation}\n\n\\subsection{DDPG}\nFigure \\ref{fig:ddpg_flow} displays the DDPG training algorithm flowchart. The network testing section is not core to DDPG but provides helpful insight into the change in system performance throughout training. The program continues training the network indefinitely until the user quits the program. The list below details algorithm steps with accompanying code snippets.\n\\begin{enumerate}\n\\item Set training parameters such as learning rates, discount factor $\\gamma$, target network update parameter $\\tau$, and mini-batch size. The arguments use default values unless specified in the program arguments list.\n\\begin{python}[caption={Training Parameter Initialization},label={list:train_param_init},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\nparser.add_argument('--actor-lr', help='actor network learning rate', default=0.001) \nparser.add_argument('--critic-lr', help='critic network learning rate', default=0.0001) \nparser.add_argument('--gamma', help='discount factor for critic updates', default=0.99) \nparser.add_argument('--tau', help='soft target update parameter', default=0.001) \nparser.add_argument('--buffer-size', help='max size of the replay buffer', default=1000000)\nparser.add_argument('--minibatch-size', help='size of minibatch for minibatch-SGD', default=64)\n\\end{python}\n\\item Initialize the actor network, critic network, Ornstein-Uhlenbeck exploration noise, and experience replay buffer. Set the random seed to a specific value for repeatability.\n\\begin{python}[caption={Network, Noise, and Experience Replay Buffer Initialization},label={list:net_init},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\nprint(\"Instantiating actor...\")\nactor = ActorNetwork(sess, state_dim, action_dim, action_bound,\n                     float(args['actor_lr']), float(args['tau']),\n                     int(args['minibatch_size']))\n\nprint(\"Instantiating critic...\")\ncritic = CriticNetwork(sess, state_dim, action_dim,\n                       float(args['critic_lr']), float(args['tau']),\n                       float(args['gamma']),\n                       actor.get_num_trainable_vars())\nactor_noise = OrnsteinUhlenbeckActionNoise(mu=np.zeros(action_dim), dt=env.dt)\nreplay_buffer = ReplayBuffer(int(args['buffer_size']), int(args['random_seed']))\n\\end{python}\n\\item Initialize TensorFlow variables and \\pythoninline{tf.train.Saver()} for saving trained models to disk.\n\\begin{python}[caption={Saver Initialization},label={list:saver_init},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\nsess.run(tf.global_variables_initializer())\nsaver = tf.train.Saver()\n\\end{python}\n\\item Start training loop. Each run of this loop is one episode.\n\t\\begin{enumerate}\n\t\\item Reset the environment randomly and get the initial state. Reset the episode reward and average maximum Q, described in Section \\ref{sec:xtrans_results}, for each step. These two quantities are not part of the network itself but are used to track actor performance. \n\t\\begin{python}[caption={Episode Reset},label={list:ep_reset},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\ns = env.reset()\n\n# Track the episode reward and average max q\nep_reward = 0\nep_ave_max_q = 0\n\t\\end{python}\n\t\\item Start step loop. Each run of this loop is one step in the episode.\n\t\t\\begin{enumerate}\n\t\t\\item Predict an action (i.e. forward pass through actor network) and add Ornstein-Uhlenbeck exploration noise. Execute the action and receive a reward, next state, and if the environment is terminating. Add the transition to the experience replay buffer.\n\t\t\\begin{python}[caption={Actor Predict and Step},label={list:act_pred_step},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\n# Predict action and add exploration noise\na = actor.predict(np.reshape(s, (1, actor.s_dim))) + actor_noise()\naction = a[0]\n\n# Execute action in environment to change state\ns2, r, terminal, info = env.step(action)\n\nreplay_buffer.add(np.reshape(s, (actor.s_dim,)), \\\n        np.reshape(action, (actor.a_dim,)), r, terminal, \\\n        np.reshape(s2, (actor.s_dim,)))\n\t\t\\end{python}\n\t\t\\item If the experience replay buffer contains at least the mini-batch number of transitions, sample a mini-batch of transitions. Use the target critic network to produce a target Q and calculate $y_i$ from the mini-batch of transitions for use in the critic loss function. Update critic and actor network weights then target critic and actor weights.\n\t\t\\begin{python}[caption={Network Update},label={list:net_update},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\n# Keep adding experience to the memory until\n# there are at least minibatch size samples\nif replay_buffer.size() > int(args['minibatch_size']):\n\ts_batch, a_batch, r_batch, t_batch, s2_batch = \\\n\t  \treplay_buffer.sample_batch(int(args['minibatch_size']))\n\t\n\t# Calculate targets\n\ttarget_q = critic.predict_target(\n\t  \ts2_batch, actor.predict_target(s2_batch))\n\t\n\ty_i = []\n\tfor k in range(int(args['minibatch_size'])):\n\t  \tif t_batch[k]:\n\t      \ty_i.append(r_batch[k])\n\t  \telse:\n\t      \ty_i.append(r_batch[k] + critic.gamma * target_q[k])\n\t\n\t# Update the critic given the targets\n\tpredicted_q_value, _ = critic.train( s_batch, a_batch, \\\n\t  \tnp.reshape(y_i, (int(args['minibatch_size']), 1)))\n\t\n\tep_ave_max_q += np.amax(predicted_q_value)\n\t\n\t# Update the actor policy using the sampled gradient\n\ta_outs = actor.predict(s_batch)\n\tgrads = critic.action_gradients(s_batch, a_outs)\n\tactor.train(s_batch, grads[0])\n\t\n\t# Update target networks\n\tactor.update_target_network()\n\tcritic.update_target_network()\n\t\t\\end{python}\t\n\t\t\\end{enumerate}\n\t\\item Update state for the next step and increment episode reward.\n\t\\begin{python}[caption={Step Cleanup},label={list:ep_clean},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\n# Update state for next step\ns = s2\n\n# Increment episode reward\nep_reward += r\n\t\\end{python}\n\t\\item If the environment is terminated, break out of the episode. Otherwise, loop back.\n\t\\begin{python}[caption={Episode Termination},label={list:ep_term},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\n# End of episode\nif terminal:\n  \tbreak\n\t\\end{python}\n\t\\item Print episode information to track progress.\n\t\\begin{python}[caption={Print Episode Results},label={list:print_ep},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\nprint('Ep: %d | Reward: %d | Qmax: %0.4f' % \\\n\t(i, int(ep_reward), ep_ave_max_q / float(ep_len)))\n\t\\end{python}\n\t\\item Periodically test the network performance (detailed in the subsection Actor Testing), record test results, save network weights to file, and produce contour plots of actor and critic outputs.\n\t\\begin{python}[caption={Network Evaluation},label={list:net_eval},xleftmargin=\\dimexpr-\\csname @totalleftmargin\\endcsname]\n# Test the network's performance\nif (i % test_period == 0):\n    # Test the network and get the total reward\n    print(\"Testing network in %d cases...\" % (num_test_cases))\n    test_reward, episodes = testNetworkPerformance(env, args, actor, num_test_cases)\n    plotEpisodes(env.net_index, episodes, env.dt, i+1)\n\n    # Save network session\n    filepath = \"./results/%s/%s_%d_%d/model.ckpt\" % (sess_dir, args['env'], i+1,int(test_reward))\n    save_path = saver.save(sess, filepath)\n\n    # Contour plots of ANN output\n    if (args['env'] != 'all'):\n        plotANN(env.net_index, actor, i+1, 0)\n        plotANN(env.net_index, critic, i+1, 1)\n\t\\end{python}\t\n\t\\end{enumerate}\n\\end{enumerate}\n\\begin{figure}[H]   % [h] means here\n\t\\centering \\includegraphics[width=6in, height=8.5in, keepaspectratio]{figures/ddpg_flow.pdf}\n\t\\caption{DDPG Flowchart}\\label{fig:ddpg_flow}\n\\end{figure}\n\n\\subsection{Two Approaches}\nSince the robot's mecanum wheels permit omni-directional movement, position and orientation control can be broken down into three separate DDPG actors, referred to as the ``x translation'', ``y translation'', and ``rotation'' or ``angle'' networks. Each actor receives two state inputs: position ($x$, $y$, or $\\theta$) and velocity ($\\dot{x}$, $\\dot{y}$, or $\\dot{\\theta}$) and outputs one of three orthogonal controls ($u_x$, $u_y$, and $u_\\theta$). This will be referred to as the ``three actors'' approach. Each of the three networks trains in isolation from the other two; for example, when training the x translation network, $u_y$ and $u_\\theta$ are fixed at 0.\n\nAfter the networks generate the control signals, some post-processing is required to simultaneously apply the effects of each control. They are converted to four individual motor voltages ($v_0$, $v_1$, $v_2$, and $v_3$) by calculating the translation vector magnitude $V_d = \\sqrt{u_x^2 + u_y^2}/2$ and angle $\\theta_d = \\text{atan2}(u_y / u_x)$ then using Equations \\ref{eq:mecanum_v0} through \\ref{eq:mecanum_v3} \\cite{li_2018}\\cite{rahman_2014}. The desired voltages are then communicated to the microcontroller which generates the appropriate signals.\n\\begin{align}\nv_0 &= V_d \\text{sin}(\\theta_d + \\pi/4) - u_\\theta  \\label{eq:mecanum_v0}\\\\\nv_1 &= V_d \\text{cos}(\\theta_d + \\pi/4) + u_\\theta  \\label{eq:mecanum_v1}\\\\\nv_2 &= V_d \\text{sin}(\\theta_d + \\pi/4) + u_\\theta  \\label{eq:mecanum_v2}\\\\\nv_3 &= V_d \\text{cos}(\\theta_d + \\pi/4) - u_\\theta  \\label{eq:mecanum_v3}\n\\end{align}\n\nIn the alternative ``single actor'' approach, a single actor receives $x$, $y$, $\\theta$, $\\dot{x}$, $\\dot{y}$, and $\\dot{\\theta}$ then produces the three control components $u_x$, $u_y$, and $u_\\theta$. \n\nThe three actor approach provides a few significant benefits over the single actor. First, it allows for partial system retraining. For example, if the y translation network does not meet the design specification, it can be retrained independently whereas the single actor would require complete retraining. Additionally, separate actors simplify troubleshooting and reward assignment tuning by isolating effects and reducing problem complexity as well as improve training convergence speed. On the other hand, the approach does not account for possible effects of simultaneously-applied control components as with the single actor case. It also suffers from reduced speed due to processing three networks at each step versus just one. \n\nA hybrid approach would start with the three actors approach, to tune and refine the reward assignments and hyper-parameters, and finish with the single actor to reap the processing speed advantage as shown in Figure \\ref{fig:hybrid_approach_flow}.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/hybrid_approach_flow.pdf}\n\t\\caption{Hybrid Approach Flow} \\label{fig:hybrid_approach_flow}\n\\end{figure}\n\n\\subsection{Training}\nEach episode lasts 10 seconds with 0.05 second steps for a total of 200 steps per episode. The learning rates, discount factor, target network update parameter $\\tau$, and mini-batch size for the three actors approach come from the original DDPG publication. The learning rates and $\\tau$ for the single actor variant are 10 times smaller to improve stability. Table \\ref{tab:training_params} summarizes the training parameters.\n\\begin{table}[h]\n\t\\caption{Training Parameters}  \\label{tab:training_params}\n\t\\centering\n\t\\begin{tabular}{l|c|c}\n\t\t\\toprule\n\t\tParameter & Three Actors & Single Actor \\\\ \n\t\t\\midrule\n\t\tEpisode Length (s) & 10 & 10 \\\\\n\t\tEpisode Step (s) & 0.05 & 0.05 \\\\\n\t\tActor Learning Rate $\\alpha_{actor}$ & $10^{-4}$ & $10^{-5}$ \\\\\n\t\tCritic Learning Rate $\\alpha_{critic}$  & $10^{-3}$ & $10^{-4}$ \\\\\n\t\tDiscount Factor $\\gamma$ & 0.99 & 0.99 \\\\\n\t\tTarget Network Update Parameter $\\tau$ & $10^{-3}$ & $10^{-4}$ \\\\\n\t\tMini-Batch Size & 64 & 128 \\\\\n\t\t\\bottomrule\n\t\\end{tabular} \n\\end{table}\n\nTraining took place on a desktop computer with an Intel i5-4670K CPU and Nvidia GeForce GTX 980 Ti GPU running Microsoft Windows 10 Pro \\cite{intel}\\cite{980ti}\\cite{windows}. The computer processed 21,200 episodes of single actor training in about 23 hours and 51 minutes, achieving an average rate of 1 episode every 4.08 seconds.\n\n\\subsection{Testing}\nThe training loop periodically tests the actor to evaluate performance with the \\pythoninline{testNetworkPerformance()} function shown in Listing \\ref{list:actor_testing}. The actor steps through a series of predefined test cases. For example, the robot orientation $\\theta$ ranges from $-\\pi$ to $+\\pi$. If using 11 test cases, the robot would begin at $\\theta=[-\\pi, -0.8\\pi, -0.6\\pi,\\allowbreak -0.4\\pi,\\allowbreak -0.2\\pi,\\allowbreak 0, +0.2\\pi, +0.4\\pi, +0.6\\pi, +0.8\\pi, +\\pi]$ to evaluate behavior at various states. Additionally, the action does not receive Ornstein-Uhlenbeck exploration noise during testing so the actor only takes greedy actions. The function returns the average reward per episode as the measure of actor performance. The testing procedure as implemented uses 41 test cases. \\\\\n\n\\begin{python}[caption={Actor Testing Function},label={list:actor_testing}]\n# Tests the actor network against a number of test cases\ndef testNetworkPerformance(env, args, actor, num_test_cases = 10, render = False):\n    test_total_reward = 0.0\n    episodes = []\n\n    # Test the network against random scenarios\n    env.setWallCollision(True)\n    for m in range(num_test_cases + 1):\n        transitions = []\n        s = env.reset(False, True, m, num_test_cases)\n        ep_reward = 0.0\n        for n in range(int(args['max_episode_len'])):\n            if (args['render_env'] and render == True):\n                env.render()\n\n            # Choose action based on inputs\n            a = actor.predict(np.reshape(s, (1, actor.s_dim)))\n            action = a[0]\n\n            # Execute action and get new state, reward\n            s, r, terminal, info = env.step(action)\n            ep_reward += r\n\n            transition = (action, s, r)\n            transitions.append(transition)\n            if terminal:\n                break\n        episodes.append(transitions)\n        test_total_reward += ep_reward\n\n    env.setWallCollision(False)\n\n    # Return the average test reward\n    return (test_total_reward / (m+1), episodes)\n\n\\end{python}\n%\\begin{python}[caption={Caption},label={list:label}]\n%\n%\\end{python}\n\n\\section{Results}\n\\subsubsection{X Translation Network} \\label{sec:xtrans_results}\nThe $x$ translation network takes in the robot's $x$ error, the difference between the desired and actual $x$ positions, and velocity $\\dot{x}$ and outputs control $u_x$. The reward is calculated as shown in Equation \\ref{eq:x_reward}. The actor receives a higher reward for keeping the robot near the desired $x$ set point, minimizing the $x$ velocity, and minimizing the effort (i.e. low $u_x$ values). Since reaching the set point quickly is desirable, it may seem odd to minimize velocity. However, the velocity reward magnitude is significantly smaller than that of position, so the actor prioritizes getting to the set point quickly and later focuses on reducing speed.\n\\begin{equation}\nr = -0.00001(x-x_{desired})^2-0.0000005\\dot{x}^2-0.001u_x^2\n\\label{eq:x_reward}\n\\end{equation}\n\nAs described above in the Testing section, the networks are periodically tested to observe their change in performance with more training. Figures \\ref{fig:x_r} and \\ref{fig:x_rzoom} show the average testing episode reward produced by the \\mbox{\\pythoninline{testNetworkPerformance()}} function versus the number of episodes trained. Figure \\ref{fig:x_q} shows the average max Q versus number of episodes trained. The average max Q is calculated as the average maximum Q within each mini-batch of predicted Q's. Since the algorithm is model-free and the actor starts with zero knowledge of the environment, the initial test rewards remain near -2000. However, the actor quickly learns and achieves a -58 test reward after 161 episodes. After 181 episodes, the test reward begins to decrease, indicating the possibility of over-training. Interestingly, the critic produces invalid Q estimates visible in Figure \\ref{fig:x_q}; the maximum reward for any step, and therefore Q, is 0. However, this does not impact the actor's ability to determine desirable actions.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/x_r.pdf}\n\t\\caption{X Translation Test Reward} \\label{fig:x_r}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/x_rzoom.pdf}\n\t\\caption{X Translation Test Reward Zoomed} \\label{fig:x_rzoom}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/x_q.pdf}\n\t\\caption{X Translation Network Average Max Q} \\label{fig:x_q}\n\\end{figure}\n\nFigure \\ref{fig:x_perf} shows the action $u_x$, error from the set point, and reward versus time for eight episodes with different initial conditions after 161 episodes trained. Appendix \\ref{appendix:x_perf} provides additional plots for different numbers of episodes trained. Regardless of the starting distance from the set point, the actor appears to drive the robot at maximum speed to reach the set point as quickly as possible since the positional error affects the reward most drastically. Soon after reaching the desired $x$ position, the action decays to zero.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/transx_transitions/1_161.pdf}\n\t\\caption{X Translation Network Performance -- 161 Episodes}\\label{fig:x_perf}\n\\end{figure}\n\nFigure \\ref{fig:x_actor_contour} displays a series of contour plots of the actor outputs as functions of the two inputs over different numbers of episodes trained where the color indicates the action $u_x$. The plots reveal the trained actor's output as highly polarized with only a sliver of low-valued $u_x$. Figure \\ref{fig:x_critic_contour} shows a similar series of plots for the critic output. Since Q is a function of both the state and action, each point represents the highest Q-value among all actions at the particular state. The plot of Q follows intuition: the nearer the robot to the desired $x$ location, the greater the expected long-term reward.\n\\begin{figure}\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_41.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_81.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_121.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_161.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_201.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_241.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_actor/Actor1_281.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{X Translation Actor Output Progression}\\label{fig:x_actor_contour}\n\\end{figure}\n\\begin{figure}\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_41.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_81.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_121.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_161.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_201.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_241.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transx_critic/Critic1_281.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{X Translation Critic Output Progression}\\label{fig:x_critic_contour}\n\\end{figure}\n\n\\subsubsection{Y Translation Network}\nThe $y$ translation network is nearly identical to the $x$ translation but with a variable change so refer to the above for details. Figures \\ref{fig:y_r} through \\ref{fig:y_q} contain plots equivalent to those shown for the $x$ translation network. The test reward shows the same pattern of low test reward followed by a steep climb to a plateau. The jump in test reward aligns with the jump in average max Q at episode 161. The network also suffers from a decline in test reward from over training.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/y_r.pdf}\n\t\\caption{Y Translation Test Reward} \\label{fig:y_r}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/y_rzoom.pdf}\n\t\\caption{Y Translation Test Reward Zoomed} \\label{fig:y_rzoom}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/y_q.pdf}\n\t\\caption{Y Translation Network Average Max Q} \\label{fig:y_q}\n\\end{figure}\n\nFigure \\ref{fig:y_perf} displays the actor's transient response from eight different initial starting points after 221 episodes trained. Appendix \\ref{appendix:y_perf} contains additional plots for other episodes trained. The robot reaches the set point with a small overshoot, and the action decays to zero as desired, indicating a successful policy.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=6in, keepaspectratio]{figures/train_figs/transy_transitions/2_221.pdf}\n\t\\caption{Y Translation Network Performance -- 221 Episodes}\\label{fig:y_perf}\n\\end{figure}\n\nFigures \\ref{fig:y_actor_contour} and \\ref{fig:y_critic_contour} show the actor and critic contour plots, respectively. As expected, the contours are highly reminiscent of those for the $x$ translation network.\n\\begin{figure}[H]\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_41.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_81.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_181.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_221.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_261.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_301.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_actor/Actor2_341.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{Y Translation Actor Output Progression}\\label{fig:y_actor_contour}\n\\end{figure}\n\\begin{figure}[H]\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_41.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_81.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_181.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_221.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_261.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_301.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/transy_critic/Critic2_341.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{Y Translation Critic Output Progression}\\label{fig:y_critic_contour}\n\\end{figure}\n\n\\subsubsection{Rotation Network}\nThe angle network receives the robot's angle error as $\\text{cos}(\\theta-\\theta_{desired})$ and $\\text{sin}(\\theta-\\theta_{desired})$ as well as the rotational velocity $\\dot{\\theta}$ and outputs $u_\\theta$. The reward is calculated as shown in Equation \\ref{eq:angle_reward} where the $\\text{norm}()$ function normalizes the angle to between $-\\pi$ and $+\\pi$.\n\\begin{equation}\nr = -1.0(\\text{norm}(\\theta)-\\text{norm}(\\theta_{desired}))^2-0.1\\dot{\\theta}^2-0.001u_\\theta^2\n\\label{eq:angle_reward}\n\\end{equation}\n\nFigures \\ref{fig:angle_r} and \\ref{fig:angle_rzoom} show test reward progress. The rotation network learns faster than either the $x$ or $y$ actors, achieving a reasonably good policy after only 41 episodes of training, due to the cyclical nature of rotation. Even if the actor decides to constantly spin the robot in one direction, it passes the set point with each revolution, obtaining useful experiences near the desired angle. However, in the $x$ or $y$ translation case, a constant movement in one direction leads the robot away from the set point and eventually gets it stuck at a wall instead of gaining effective experiences.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/angle_r.pdf}\n\t\\caption{Angle Test Reward} \\label{fig:angle_r}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/angle_rzoom.pdf}\n\t\\caption{Angle Test Reward Zoomed} \\label{fig:angle_rzoom}\n\\end{figure}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/angle_q.pdf}\n\t\\caption{Angle Network Average Max Q} \\label{fig:angle_q}\n\\end{figure}\n\nAs seen in Figure \\ref{fig:angle_perf}, the rotation actor monotonically brings the robot to the desired angle with no overshoot and reduces the action to 0 afterwards. Appendix \\ref{appendix:angle_perf} provides additional plots for different numbers of episodes trained. \n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/angle_transitions/0_61.pdf}\n\t\\caption{Angle Network Performance -- 61 Episodes}\\label{fig:angle_perf}\n\\end{figure}\n\nFigures \\ref{fig:angle_actor_contour} and \\ref{fig:angle_critic_contour} contain contour plots of the actor and critic outputs. As expected, the plots are periodic with respect to $\\theta$. The actor contours take on a vaguely sinusoidal shape with only a thin sliver of area producing low action values, much like the other two networks. The critic network produces high Q values for states near the desired angle and low angular velocity.\n\\begin{figure}[H]\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_21.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_61.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_81.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_121.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_161.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_221.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_actor/Actor0_301.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{Angle Actor Output Progression}\\label{fig:angle_actor_contour}\n\\end{figure}\n\\begin{figure}[H]\n\t\\begin{tabular}{cc}\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_1.pdf} &  \n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_21.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_61.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_81.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_121.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_161.pdf} \\\\\n\t\t\\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_221.pdf} &   \\includegraphics[width=65mm]{figures/train_figs/angle_critic/Critic0_301.pdf} \\\\\n\t\\end{tabular}\n\t\\caption{Angle Critic Output Progression}\\label{fig:angle_critic_contour}\n\\end{figure}\n\n\\subsection{Three Actors Combined}\nAfter the three networks were trained, the best iteration of each (determined as rapid settling time, low or no overshoot, and decaying action value) was combined. At each time step, each actor produces its respective control component which merge together using Equations \\ref{eq:mecanum_v0} through \\ref{eq:mecanum_v3} as described previously. Figure \\ref{fig:three_actor_response} displays the response to eight varied initial states. Although the robot reaches the desired $x$, $y$, and $\\theta$ position, it takes longer than in the individual tests above since the robot's movement is now divided amongst the three directions $x$, $y$, and $\\theta$. The actions still decay to 0. \n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, height=5in, keepaspectratio]{figures/three_actor_response.pdf}\n\t\\caption{Combined Response} \\label{fig:three_actor_response}\n\\end{figure}\n\n\\subsection{Single Actor Network}\nSince single actor approach required reduced learning rates to prevent training instability, the network trained for substantially longer before achieving reasonable performance. Figures \\ref{fig:all_r} and \\ref{fig:all_rzoom} show that the learning ``jump'' lasts nearly 1,000 episodes versus 20-60 episodes in the three actor case. Notably, Figure \\ref{fig:all_rzoom} shows that, on average, the test reward continues to very slightly increase with further training at a rate of 1.6 reward per 1,000 additional episodes trained. In Figure \\ref{fig:all_q}, the average max Q overshoots the ideal maximum of 0 but settles to negative values with further training.\n\\begin{figure}[H]\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/all_r.pdf}\n\t\\caption{Training and Test Reward} \\label{fig:all_r}\n\\end{figure}\n\\begin{figure}[H]\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/all_rzoom.pdf}\n\t\\caption{Training and Test Reward Zoomed} \\label{fig:all_rzoom}\n\\end{figure}\n\\begin{figure}[H]\n\t\\includegraphics[width=6in, height=3.85in, keepaspectratio]{figures/train_figs/all_q.pdf}\n\t\\caption{Average Max Q} \\label{fig:all_q}\n\\end{figure}\n\nFigure \\ref{fig:all_perf} shows the single actor response to eight various initial $x$, $y$, and $\\theta$ values. Appendix \\ref{appendix:all_perf} contains additional plots for other episodes trained. Although the actor does successfully bring the robot to the set point, it fails to reduce the action to 0. Instead, the actions exhibit limit cycles, oscillating to keep the net velocity at 0. In this respect, the three actors approach provides the distinct advantage.\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=6in, keepaspectratio]{figures/train_figs/all_transitions/3_17281.pdf}\n\t\\caption{All Network Performance -- 17281 Episodes}\\label{fig:all_perf}\n\\end{figure}\n\n\\section{Conclusion}\nThe deep deterministic policy gradient algorithm successfully solved position and orientation control of the robot using two different approaches. The three actors approach proved to be easier to tune, faster to converge, and better in performance versus the single actor case. Therefore, where possible, dividing a system by its orthogonal controls improves training convergence and hyper-parameter tuning and also allows partial retraining, a major advantage when obtaining experiences is costly. The author hypothesizes that these benefits are a function of system complexity where reduced complexity is desirable.  Future work includes experiments to further demonstrate the efficacy of control division in other environments. Nevertheless, designers should consider the single actor method when processing speed is the limiting factor.\n\nIn the context of Roborodentia, the trained network provides the control loop by which the robot gets to specific locations in the field. The programmer need only supply a series of coordinates defining the robot's path and can expect the robot's DDPG network to determine the requisite motor voltages and wheel speeds to follow it closely. Although the robot's travel path to key Roborodentia field features are hard-coded, reinforcement learning could feasibly solve the pathfinding problem as well. \n\nDespite the efforts to build the hardware and develop the code base, the robot did not end up competing. The DDPG network was destined to run on the Raspberry Pi. However, a fatal design flaw not discovered until mere hours before the competition caused instability in the Pi and runtime errors. Later investigation revealed the particular Raspberry Pi as out of spec; the robot's on-board power supply provided 5.1 V to the Pi as required by the documentation but experiments showed that 5.3 V was necessary for stability. Therefore, the author would like to recommend avoiding the use of Raspberry Pi's in battery-powered systems and ensuring adequate power delivery if usage is unavoidable.\n\n\\section{Future Work}\nThe process of developing reward assignments for the environment could be improved by taking a more systematic approach than guess-and-check. Despite successfully achieving the goal of moving the robot to the desired position, it is unclear if the chosen reward calculations were anywhere near optimal. \n\nAlthough DDPG does successfully solve varied environments, it still depends on proper reward assignment to achieve the desired policy. A heuristic algorithm for automatically scaling rewards would improve on the theme of generalization. \n\nThe simulation of the robot only accounts for some basic kinematics, but future designs could incorporate a much greater range of factors. The closer the simulation to reality, the easier it is to train the robot in simulation and expect similar performance when the learned network weights and biases are transferred to the real robot.\n\nFinally, training the network directly on the real robot would allow complete omission of the simulation altogether at the expense of time and effort. However, the resulting policy would most accurately conform to the conditions and environments of the application.", "meta": {"hexsha": "ede734a64ddec67ab6df246893bedde80e06cc24", "size": 83488, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/chapters/rl.tex", "max_stars_repo_name": "okayjustin/roborodentia2017", "max_stars_repo_head_hexsha": "34d8fa51198be3b0f8d10982b69b79d277682638", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-01-03T06:12:14.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-03T06:12:14.000Z", "max_issues_repo_path": "report/chapters/rl.tex", "max_issues_repo_name": "okayjustin/roborodentia2017", "max_issues_repo_head_hexsha": "34d8fa51198be3b0f8d10982b69b79d277682638", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/chapters/rl.tex", "max_forks_repo_name": "okayjustin/roborodentia2017", "max_forks_repo_head_hexsha": "34d8fa51198be3b0f8d10982b69b79d277682638", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 93.3870246085, "max_line_length": 1544, "alphanum_fraction": 0.7680864316, "num_tokens": 20308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4098787489370863}}
{"text": "\\documentclass[12pt,letterpaper]{article} %12-point font, US letter size\n\\usepackage{mathptmx} %Times new roman with math support\n\\usepackage{fontenc}\n\\usepackage[english]{babel}\n\\usepackage{amsmath,amssymb} %math support\n\\usepackage{setspace} %double spacing\n\\usepackage{lineno} %line numbers\n\n\\doublespacing\n\\linenumbers\n\n\\begin{document}\n\n\\section*{Sufficient conditions for the existence of an evolutionary tipping point}\n\nHere we sketch out in more detail what is required for an evolutionary tipping point to exist for any continuous, real, thrice differentiable fitness function, $r(z)$, which is monotonically declining from a sufficiently positive local maxima at $z=\\theta$ to a negative number as the lag between the local maxima and trait value increases, $l=\\theta-z\\rightarrow\\infty$.\n\nLet the position of the local maxima, $\\theta$, at time $t$ be $k t$. % +\\epsilon_\\theta$, where $\\epsilon_\\theta$ at any time $t$ is a random normal variable with mean 0 and variance $\\sigma_\\theta^2$ and is uncorrelated across time.\nExpected population mean fitness then monotonically declines from, $\\mathrm{E}[\\bar{r}|\\bar{l}=0] = \\bar{r}_m > 0$, as the expected population mean lag, $\\mathrm{E}[\\bar{l}] = E[\\theta - \\bar{z}] = k t - \\bar{g}$, increases from 0. \nLet $\\bar{l}_c$ be the mean lag that causes an expected population growth rate of zero, $\\mathrm{E}[\\bar{r}|\\bar{l}=\\bar{l}_c] = 0$.\nWe then have $\\mathrm{E}[\\bar{r}|\\bar{l}] > 0\\;\\forall\\;\\bar{l}\\in[0,\\bar{l}_c)$ and $\\mathrm{E}[\\bar{r}|\\bar{l}] < 0\\;\\forall\\;\\bar{l}\\in(\\bar{l}_c,\\infty)$.\n\nAs described in the main text, the expected rate of evolution given mean additive genetic value $\\bar{g}$ is approximately $E\\left[\\frac{\\mathrm{d} \\bar{g}}{\\mathrm{d} t} \\big| \\bar{g} \\right]\\approx \\sigma_{g}^2 \\frac{\\mathrm{d} \\bar{r}}{\\mathrm{d} \\bar{g}}$, where $\\sigma_g^2>0$ is the additive genetic variance (a constant that is independent of $k$) and $\\bar{r}$ is population mean fitness.\nA quasi-steady-state is reached when the expected rate of evolution equals the expected rate of change in the optimum, or equivalently, $\\frac{\\mathrm{d} \\bar{r}}{\\mathrm{d} \\bar{l}} = -k/\\sigma_{g}^2$.\nOne then wants to solve this equation for the steady-state lag, $\\hat{l}$, which is the mean lag at which mean fitness declines with mean lag at rate $k/\\sigma_g^2$.\n\nGiven that fitness, $r$, and thus mean growth rate, $\\bar{r}$, has a local maxima at $\\theta$, in a constant environment, $k=0$, a quasi-steady-state is achieved when the mean lag is zero, $\\bar{l}=0$.\nSince the expected growth rate at this lag is positive, $\\mathrm{E}[\\bar{r}|\\bar{l}=0] = \\bar{r}_m>0$, the population can persist at this steady-state.\nWe assume this is the starting point of the population.\nBecause mean growth rate, $\\bar{r}$, is continuous and monotonically declining as mean lag, $\\bar{l}$, increases from zero, i.e., $\\frac{\\mathrm{d}\\bar{r}}{\\mathrm{d}\\bar{l}}<0$ for all $\\bar{l}>0$, we are guaranteed that near $\\bar{l}=0$ the steady-state lag increases with $k$.\nThis is because near the local maxima, $\\theta$, the mean growth rate is necessarily concave down, $\\frac{\\mathrm{d}^2\\bar{r}}{\\mathrm{d}\\bar{l}^2}<0$, i.e., the strength of selection, and thus the rate of evolution with constant additive genetic variance, increases with increasing mean lag near $\\bar{l}=0$.\nHowever, as we depart from $\\bar{l}=0$ the monotonicity of $\\bar{r}$ is not enough to determine the sign of  $\\frac{\\mathrm{d}^2\\bar{r}}{\\mathrm{d}\\bar{l}^2}$.\nThus, the expected rate of evolution, $\\sigma_g^2\\frac{\\mathrm{d}\\bar{r}}{\\mathrm{d}\\bar{l}}$, can increase or decrease as mean lag increases.\nIn particular, inflection points in the fitness function, which cause inflection points in mean growth rate, $\\frac{\\mathrm{d}^2\\bar{r}}{\\mathrm{d}\\bar{l}^2}=0$, create local minima and maxima in the expected rate of evolution as a function of mean lag.\n\nLet $L=\\{\\bar{l}_1,\\bar{l}_2,...,\\bar{l}_n\\}$ be the ordered set of mean lags at which there are local minima and maxima in the expected rate of evolution (i.e., at which there are inflection points in the fitness function, $\\frac{\\mathrm{d}^2 r}{\\mathrm{d} \\bar{l}^2}$) and let $M=\\{m_1, m_2, ..., m_n\\}$ be the corresponding expected rates of evolution, i.e., $\\mathrm{E}[\\frac{\\mathrm{d} \\bar{g}}{\\mathrm{d} t}|\\bar{l}_i] = m_i$.\nDue to the monotonicity of mean growth rate, $\\bar{r}$, the first extrema, at $\\bar{l}=\\bar{l}_1$, must be a maximum.\nIf the lag that causes this first maxima in the rate of evolution is greater than the lag that causes a mean growth rate of zero, $\\bar{l}_1>\\bar{l}_c$, then the expected rate of evolution is monotonically increasing as the mean lag increases from 0 to $\\bar{l}_c$, and therefore the expected rate of evolution at $\\bar{l}=\\bar{l}_c$ is the critical rate of environmental change (i.e., the $k$ that causes $\\bar{r}=0$).\nIf, however, $\\bar{l}_1<\\bar{l}_c$, then the steady-state lag continuously increases as the rate of environmental change, $k$, increases from 0 to $m_1$, where the population can persist (given $\\bar{l}_1<\\bar{l}_c$), after which the steady-state lag makes a discontinuous increase.\nTechnically, there is a saddle-node bifurcation at $k = m_1$.\nThe size of the discontinuous increase in the steady-state lag as the rate of environmental change, $k$, increases through the first maxima in the rate of evolution, $m_1$, and the consequences for population persistence, depends on the other lags that cause extrema, $L$, and their respective rates of evolution, $M$.\nIn particular, if the first local maxima is the global maxima, $m_1>m_i\\;\\forall\\;i>1$, then there is no quasi-steady-state solution when the rate of environmental change is greater than it, $k>m_1$, and the mean lag will increases towards infinity.\nThus the population will go extinct for any $k>m_1$ and $m_1$ is an evolutionary tipping point.\nThis is the situation discussed in the main text, as our alternative fitness function only creates one extrema in the rate of evolution as a function of mean lag.\nHowever, if there is a maxima that is greater than the first, $m_1<m_i$ for some $i>1$, then as the rate of environmental change, $k$, increases through $m_1$ the steady-state lag increases to the next largest mean lag that produces an expected rate of evolution slightly larger than $m_1$.\nIf this next largest mean lag is greater than the lag that causes a mean growth rate of zero, $\\bar{l}_c$, the population is still expected to go extinct for any $k>m_1$, and $m_1$ is still an evolutionary tipping point.\nBut if the next largest mean lag that produces an expected rate of evolution slightly larger than $m_1$ is less than $\\bar{l}_c$, then $m_1$ is not an evolutionary tipping point and the arguments above for $\\bar{l}_1$ can be repeated for $\\bar{l}_3$ (the next maxima).\nI.e., if $\\bar{l}_3>\\bar{l}_c$ then the critical rate of change determines persistence, while if $\\bar{l}_3<\\bar{l}_c$ the other lags and respective evolutionary extrema determine whether $\\bar{l}_3$ is an evolutionary tipping point or not. \n\nThis argument can be generalized by letting $\\bar{l}_j$ be the mean lag in $[0,\\bar{l}_c]$ that produces the maximum expected rate of evolution.\nIf $\\bar{l}_j<\\bar{l}_c$ it must cause a local maximum in the rate of evolution and thus be in $L$ (with $j$ odd).\nExtinction then occurs whenever $k>m_j$.\nWe then call the height of the largest local maxima in the expected rate of evolution within the persistence zone, $m_j$, an evolutionary tipping point, as a saddle-node bifurcation occurs as $k$ increases through $m_j$.\nThis bifurcation causes long-run population growth rates to go from $\\mathrm{E}[\\bar{r}|\\bar{l}=\\bar{l}_j]>0$ to a negative value without ever crossing zero.  \n\n\\end{document}", "meta": {"hexsha": "78a4a87df480d939b68893b3d9a07a633f6525d2", "size": 7751, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SOM/tipconditions.tex", "max_stars_repo_name": "mmosmond/EvolTippingPoint", "max_stars_repo_head_hexsha": "06db2341450d77ba5d8b1be3a0328ba8ade2bacd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SOM/tipconditions.tex", "max_issues_repo_name": "mmosmond/EvolTippingPoint", "max_issues_repo_head_hexsha": "06db2341450d77ba5d8b1be3a0328ba8ade2bacd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SOM/tipconditions.tex", "max_forks_repo_name": "mmosmond/EvolTippingPoint", "max_forks_repo_head_hexsha": "06db2341450d77ba5d8b1be3a0328ba8ade2bacd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 138.4107142857, "max_line_length": 432, "alphanum_fraction": 0.7339698103, "num_tokens": 2184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4098422930795862}}
{"text": "\\documentclass{article}\n\\usepackage{cite}\n\\usepackage[utf8]{inputenc}\n\\newcommand\\independent{\\protect\\mathpalette{\\protect\\independenT}{\\perp}}\n\\def\\independenT#1#2{\\mathrel{\\rlap{$#1#2$}\\mkern2mu{#1#2}}}\n\\title{Report for Comprehensive Exam}\n\\author{Siyuan Zhao}\n\\date{April 2017}\n\n\\usepackage[linesnumbered,ruled]{algorithm2e}\n\\usepackage{amsmath, mathtools}\n\\usepackage{amsfonts}\n\\begin{document}\n\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\n\\section{Topic 1: Ways to Personalized}\n\\subsection{Q1: Estimating Treatment Effect}\n\\paragraph{Question:} You have explored at least one way to personalize.  That is to try to learn in an RCT which conditions that should be given to which types of students.   Review the methods you are aware (1) Susan Athey’s Random Causal Forest and 2) Counterfactual inference for causal inference/individual treatment effect, , 3) individual treatment rules from the medical literature and 4) Susan Murph's methods) of and how are they different and similar.\n\\\\ [0.1in]\n\n\\paragraph{Strong Ignorability}\nThe treatment assignment is defined to be strongly ignorable\n\\cite{rosenbaum1983central} if the following two conditions hold: 1).\n$(Y(1), Y(0)) \\independent t\\mid X$ and 2). $0 < \\Pr (t=1 \\mid X) <\n1$. The first condition says that treatment assignment is independent\nof the potential outcomes conditional on the observed features of subjects. The second condition says that every subject has a nonzero\nprobability to receive either treatment. The aforementioned first\ncondition is also referred to as the \"no-hidden confounding variables\"\nassumption that all factors determining the outcome of each condition\nare observed.\n\n\\subsubsection{Random Causal Forests}~\\label{sect:rcf}\n\\cite{wager2015estimation} proposed random causal forest (RCF) to\ninfer treatment effect. From the conceptual point of view, causal trees can be viewed as\nnearest neighbor methods with an adaptive neighborhood metric. Assume\nthat there are $n$ observed independent samples $(X_i, Y_i,\nW_i)_{i=1}^n$. The workflow of the RCF is that a causal tree is first\nbuilt by recursively splitting the feature space until all samples are\npartitioned into a set of leaves $L$, each of which contains a few\ntraining samples. Then, for a data point $x$, the predicted outcome $\\hat{\\mu}(x)$\nis evaluated by identifying the leaf $L(x)$ containing $x$ and\ncalculating\n\n$$\\hat{\\mu} = \\frac{1}{\\left | \\left \\{ i: X_i \\in L(x) \\right \\}\n  \\right |} \\sum_{\\left \\{ i: X_i \\in L(x) \\right \\}} Y_i$$\n\nGiven a test point $x$, the closest points to $x$ are those fall in the same\nleaf as it. The authors believe that the leaf is small enough that the\nresponses $Y_i$ are roughly identically distributed. Then the\ntreatment effect $\\hat{\\tau}$ for any $x \\in L(x)$ is estimated as\nfollowing:\n\n\\begin{align} \n\\hat{\\tau}(x) & = \\frac{1}{\\left | \\left \\{ i: W_i=1, X_i \\in L(x) \\right \\}\n                \\right |} \\sum_{\\left \\{ i: W_i = 1, X_i \\in L(x)\n                \\right \\}} Y_i \\nonumber \\\\\n              & - \\frac{1}{\\left | \\left \\{ i: W_i=0, X_i \\in L(x) \\right \\}\n  \\right |} \\sum_{\\left \\{ i: W_i = 0, X_i \\in L(x) \\right \\}} Y_i \\label{eq:tree-treatment-effect}\n\\end{align}\n\nRCF assumes that\nthere is overlapping in the data, i.e., for some $\\epsilon > 0$ and\nall $x \\in \\left [ 0, 1\\right ]^d$,\n\n$$\\epsilon < \\mathbb{P}\\left [ W=1 \\mid X=x \\right ] < 1-\\epsilon$$\n\nThis condition effectively guarantees that, for large enough $n$,\nthere will be enough treatment and control units near any test point\n$x$ for local methods to work.\n\n\\paragraph{Honest Trees and Forests}\nThe authors also define the Honest Trees and Forests in \\cite{wager2015estimation}.\nA tree is honest if, for each training example $i$, it only uses the\nresponse $Y_i$ to estimate the within-leaf treatment effect $\\tau$\nusing Equation~\\ref{eq:tree-treatment-effect} or\nto decide where to place the splits, but not\nboth. There are two causal forest algorithms proposed from\n\\cite{wager2015estimation} that satisfy this condition.\n\nThe first algorithm, which is called double-sample trees, achieves\nhonesty by dividing its training data into two halves\n$\\mathcal{I}$ and $\\mathcal{J}$. Then, it uses the\n$\\mathcal{J}$-sample to place the splits, while holding out the\n$\\mathcal{I}$-sample to do within-leaf estimation. The details of the\nalgorithm is shown in Algorithm~\\ref{algo:double-sample-trees}.\n\n\\LinesNumberedHidden\n\\begin{algorithm}[h]\n  \\SetKwInOut{Input}{Input}\n  \\Input{$n$ training examples of $(X_i, Y_i, W_i)$, where $X_i$ are\n    features, $Y_i$ is the response, and $W_i$ is the treatment\n    assignment. \\\\\n    A minimum leaf size $k$.\n  }\n\n  \\caption{Double-sample Causal Trees}~\\label{algo:double-sample-trees}\n  \\ShowLn Draw a random subsample of size $s$ from $\\{1, \\ldots, n\\}$ without\n  replacement, and then divide it into two disjoint sets of size\n  $|\\mathcal{I}|=\\left \\lfloor s/2 \\right \\rfloor$ and\n  $|\\mathcal{J}|=\\left \\lceil s/2 \\right \\rceil$ \\\\\n  \\ShowLn Grow a tree via recursive partitioning. The splits are chosen using\n  any data from the $\\mathcal{J}$ sample and $X$- or $W$-observations\n  from the $\\mathcal{I}$ sample, but without using $Y$-observations\n  from $\\mathcal{I}$-sample. \\\\\n  \\ShowLn Estimate leaf-wise response using only the $\\mathcal{I}$-sample\n  observations. \\\\ [1\\baselineskip]\n\nThe algorithm estimates $\\hat{\\tau}(x)$ using\nEquation~\\ref{eq:tree-treatment-effect} on the $\\mathcal{I}$\nsample. The splitting criteria is to maximize the variance of\n$\\hat{\\tau}(X_i)$ for $i \\in \\mathcal{J}$. Each leaf of the tree must\ncontain $k$ or more $\\mathcal{I}$-sample observations of each\ntreatment class.\n\\end{algorithm}\nAnother approach to build honest trees is inspired by the idea of\npropensity score matching, which is called propensity trees. The idea\nbehind this approach is to train a classification tree to predict the\npropensity score, which is the treatment assignments $W_i$, and ignore the outcome $Y_i$ when\nplacing splits. This method is useful in observational studies\nsince propensity score is aimed to reduce the selection bias by\nequating groups based on these features. The details of the\nalgorithm is shown in Algorithm~\\ref{algo:propensity-trees}.\n\n\\LinesNumberedHidden\n\\begin{algorithm}[h]\n  \\SetKwInOut{Input}{Input}\n  \\Input{$n$ training examples of $(X_i, Y_i, W_i)$, where $X_i$ are\n    features, $Y_i$ is the response, and $W_i$ is the treatment\n    assignment. \\\\\n    A minimum leaf size $k$.\n  }\n  \\ShowLn Draw a random subsample $\\mathcal{I} \\in {1, \\ldots, n}$ of\n  size $|\\mathcal{I}| = s$ (no replacement). \\\\\n  \\ShowLn Train a classification tree using sample $\\mathcal{I}$ where\n  the outcome is the treatment assignment, i.e., on the $(X_i, W_i)$\n  pairs with $i \\in \\mathcal{I}$. Each leaf of the tree must have $k$\n  or more observations of each treatment class. \\\\\n  \\ShowLn Estimate $\\tau(x)$ using\n  Equation~\\ref{eq:tree-treatment-effect} on the leaf containing $x$.\n  \\caption{Propensity Trees}~\\label{algo:propensity-trees}\n\\end{algorithm}\n\n\\subsubsection{Counterfactual Inference}~\\label{sect:bnn}\nThe problem of causal inference is often framed in terms of\ncounterfactual problems such as \"Would this particular student benefit\nmore from the video hint or the text hint when the student cannot\nsolve a problem?\" In the binary intervention set, there are two possible interventions\n$\\mathcal{T} = \\left \\{  0, 1 \\right \\}$, where intervention 1 is\noften referred as the \"treated\" and intervention 0 is the \"control.\"\nGiven a sample of subjects and a treatment, each subject has a pair of\npotential outcomes: $Y_0$ and $Y_1$, the outcomes under the\ncontrol and the treatment, respectively. Let $t$ be an indicator\nvariable denoting the treatment received ($t = 0$ for the control and\n$t=1$ for the treatment). Only one outcome, which is called factual\noutcome, $y_F(\\mathbf{x}) =t\\cdot Y_1(\\mathbf{x}) +\n(1-t) \\cdot Y_0(\\mathbf{x})$, is observed for the\nsubject $\\mathbf{x}$, where\n$\\mathbf{x} \\in \\mathcal{X}$ are the\nobserved features for the subject. The unobserved outcomes are referred to as the\ncounterfactual outcome, denoted as $y_{CF}(\\mathbf{x}) = (1-t)\\cdot Y_1(\\mathbf{x}) +\nt \\cdot Y_0(\\mathbf{x})$. In other words, when a subject $\\mathbf{x}$ is assigned to the\n\"control\" ($t = 0$), $y_F(\\mathbf{x})$ is equal to $Y_1(\\mathbf{x})$, and $y_{CF}(\\mathbf{x})$ is\nequal to $Y_0(\\mathbf{x})$. The other way around, $y_F(\\mathbf{x})$ is equal to\n$Y_0(\\mathbf{x})$, and $y_{CF}(\\mathbf{x})$ is equal to $Y_1(\\mathbf{x})$. The estimated\nindividual treatment effect (ITE) is then calculated by\n$\\mathrm{ITE}(\\mathbf{x})=Y_1(\\mathbf{x}) - Y_0(\\mathbf{x})$. The goal\nof counterfactual inference is to predict the counterfactual outcome\ngiven the observed data $D_n=\\{(\\mathbf{x}_i,t_i,y_F^i)_{i=1}^n\\}$ from either RCTs or observational studies in\norder to estimate the ITE.\n\nWe assume $n$ samples $\\left \\{ (x_i, t_i, y_F^i) \\right \\}_{i=1}^n$\nform an empirical distribution $\\hat{p}^F  = \\left \\{ (x_i, t_i)\n\\right \\}_{i=1}^n$. We call this empirical distribution $\\hat{p}^F\n\\sim p^F$ the empirical factual distribution. In order to calculate\nITE, we need to infer the counterfactual outcome which is dependent on\nthe empirical distribution $\\hat{p}^{CF}  = \\left \\{ (x_i, 1-t_i)\n\\right \\}_{i=1}^n$, which is called the empirical counterfactual distribution $\\hat{p}^{CF}\n\\sim p^{CF}$. The $p^{F}$ and $p^{CF}$ may not be equal because the\ndistributions of the control and the treated populations may be\ndifferent. The inequality of two distributions may cause the\ncounterfactual inference over a different distribution than the one\nobserved from the experiment. In machine learning terms, this scenario\nis usually referred to as domain adaptation, where the distribution of\nfeatures in test data are different than the distribution of features\nin training data.\n\n\\cite{Johansson2016-dh} proposed Balancing Neural Networks (BNN) which\ncan be applied to solve the counterfactual inference problem. They\nused a form of regularizer to enforce the similarity between the\ndistributions of representations learned for populations with\ndifferent interventions, for example, the representations for students\nwho received text hints versus those who received video hints.This\nreduces the variance from fitting a model on one distribution and\napplying it to another. Because of random assignment to the\ninterventions in RCTs, the distributions of the populations within\ndifferent interventions are highly likely to be identical. However, in\nthe observational study, we may end up with the situation where only\nmale students receive video hints and female students receive text\nhints. Without enforcing the similarity between the distributions of\nrepresentations for male and female students, it is not safe to make a\nprediction of the outcome if male students receive text hints.\n\nThe Counterfactual Regression (CFR) \\cite{Shalit2016-qk} is built on the BNN. The important difference between these two models is that the CFR uses a more powerful distribution metric in the form of IPMs to learn a balancing representation.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.95\\columnwidth]{cfr.png}\n  \\caption{CFR for ITE estimation. $L$ is a loss function, IPM is an integral probability metric}.\n  ~\\label{fg:cfr-model}\n\\end{figure}\n\nThe structure of CFR is illustrated in Figure~\\ref{fg:cfr-model}. To learn a representation of deep features $\\Phi$, the CFR uses fully connected layers with ReLu activation function, where $Relu(z) = max(0, z)$. We need to generalize from factual distribution to counterfactual distribution in the feature representation $\\Phi$ to obtain accurate estimation of counterfactual outcome. The common successful approaches for domain adaptation encourage similarity between the latent feature representations w.r.t the different distributions. This similarity is often enforced by minimizing a certain distance between the domain-specific hidden features. The distance between two distributions is usually referred to as the discrepancy distance, introduced by \\cite{Mansour2009-fh}, which is a hypothesis class dependent distance measure tailored for domain adaptation. \n\nIntegral Probability Metric (IPM) are used to measure the distance between two distributions $p_0 = p(x|t = 0)$, and $p_1 = p(x|t = 1)$, also known as the control and treated distributions. The IPM for $p_0$ and $p_1$ is defined as\n$$\\mathrm{IPM}_{\\mathcal{F}}(p_0, p_1) := \\sup_{f\\in \\mathcal{F}} \\left |\\int_S f dp_0 -\\int_S f d p_1 \\right |,$$\n\nwhere $\\mathcal{F}$ is a class of real-valued bounded measurable functions on $S$. \n\nThe choice of functions is the crucial distinction between IPMs \\cite{Sriperumbudur2009-pf}. Two specific IPMs are used in our experiments: the Maximum Mean Discrepancy (MMD), and the Wasserstein distance. $\\mathrm{IPM}_{\\mathcal{F}}$ is called MMD, when $\\mathcal{F} = \\left \\{ f : \\left \\| f \\right \\| _\\mathcal{H}\\leq 1\\right \\}$, where $\\mathcal{H}$ represents a reproducing kernel Hilbert space (RKHS) with $k$ as its reproducing kernel. In other words, the family of norm-1 reproducing kernel Hilbert space (RKHS) functions lead to the MMD. The family of 1-Lipschitz functions $\\mathcal{F} = \\left \\{ f:\\left \\| f\\right \\|_L \\leq 1 \\right \\}$, where $\\left \\| f\\right \\|_L$ is the Lipschitz semi-norm of a bounded continuous real-valued function $f$, make IPM the Wasserstein distance. Both the Wasserstein and MMD metrics have consistent estimators which can be efficiently computed in the finite sample case \\cite{Sriperumbudur2012-sz}. The important property of IPM is that $$p_0 = p_1~\\mathrm{iff}~ \\mathrm{IPM}_{\\mathcal{F}}(p_0, p_1) = 0.$$\n\nThe representation with reduction of the discrepancy between the control and the treated populations helps the model to focus on balancing features across two populations when inferring the counterfactual outcomes. For instance, if in an experiment, almost no male student ever received intervention A, inferring how male students would react to intervention A is highly prone to error and a more conservative use of the gender feature might be warranted.\n\nAfter obtaining the representation for subject $\\mathbf{x_i}$, CFR\nconcatenates the treatment assignment $t_i$ to the representation $\\Phi(\\mathbf{x}_i)$ and feeds $[\\Phi(\\mathbf{x}_i), t_i]$ to another two fully connected layers to generate the predicted outcome.\n\\subsubsection{Individualized Treatment Rules}\nAn individual treatment rule (ITR) $d: \\mathcal{X} \\rightarrow \\mathcal{T}$ is a deterministic decision\nrule from subject $\\mathbf{x} \\in \\mathcal{X}$ into the intervention space $\\mathcal{T}$. In experiments, we observe a triplet $(\\mathbf{x}, t, y)$ from each\nsubject, where $\\mathbf{x}=(x_1, x_2, \\ldots, x_n)^T \\in\n\\mathcal{X}$ denotes the participant's observed features, $t \\in \\mathcal{T}\n= {-1,1}$ denotes the treatment assignment, and $y \\in Y$ is the\nobserved outcome, also called the \"reward\" in the literature on\nreinforcement learning. Note that $t=-1$ means that the subject is\nassigned to the control and $t=1$ mean that the subject is assigned to\nthe treatment in the\ncontext of ITR. Let $p(t|\\mathbf{x})$ be the probability of assigning the subject\nwith features $\\mathbf{x}$ to the intervention $t$. \\cite{Qian2011-vz}\nshowed that the\nvalue of $d$ satisfies\n$$V(d) = E \\left [ \\frac{y}{p(t|x)}\\mathbb{I}_{t=d(\\mathbf{x})}\\right\n],$$\nwhere $\\mathbb{I}(\\cdot)$ is an indicator function. The goal of the\nITR is to find an optimal ITR, $d^{*}$, which is a rule that has the maximal value such\nthat,\n\n$$d^{*} \\in \\operatorname*{arg\\,max}_d V(d).$$\n\\cite{Qian2011-vz} also showed that finding $d^{*}$ is equivalent to minimizing the following equation:\n\\begin{equation} \\label{eq:d_min}\nd^{*} \\in \\operatorname*{arg\\,min}_d E \\left [\n  \\frac{y}{p(t|x)}\\mathbb{I}_{t \\neq d(\\mathbf{x})}\\right\n]\n\\end{equation}\n\nAssume that the observed data $\\left \\{\n  (\\mathbf{x}_i,t_i,y_i),~i=1,\\ldots , n \\right \\}$ are collected\nindependently. For any decision function $f(\\mathbf{x})$, let\n$d_f(\\mathbf{x}) = sign(f(\\mathbf{x}))$ be the associated rule, where\n$sign(u) = 1$ for $u > 0$ and $-1$ otherwise. The particular choice of\nthe value of $sign(0)$ is not important. With the observed data, the\nweighted classification error in Equation \\ref{eq:d_min} can be approximated by\nthe empirical risk\n\n\\begin{equation} \\label{eq:d_empirical_min}\n  \\frac{1}{n}\\sum_{i=1}^{n}\\frac{y_i}{p(t_i|x_i)}\\mathbb{I}_{t_i \\neq\n    d_f(\\mathbf{x_i})} .\n\\end{equation}\n\n\\cite{Qian2011-vz} proposed a two-step procedure that first train a\nmodel using the observed data to estimate\na conditional mean for the outcome $E(y|\\mathbf{x},t)$, and then determines the treatment\nrule by comparing the predicted value $E(y|\\mathbf{x},t=1)$ between $E(y|\\mathbf{x},t=-1)$.\n\nIn contrast, \\cite{zhao2012estimating} proposed one-step procedure by\nshowing that find an optimal ITR is equivalent to a classification task\nwhere we want to classify $t$ with $\\mathbf{x}$ as the input. Outcome weighted learning (OWL) proposed by\n\\cite{zhao2012estimating} use the hinge loss function and the\nregularization technique aiming to minimize\n\n\\begin{equation}\n  \\frac{1}{n}\\sum_{i=1}^{n}\\frac{y_i}{p(t_i|x_i)}(1-t_if(\\mathbf{x}_i))_{+}+\\lambda\\left\n    \\| f \\right \\|^2 ~\\label{eq:d_owl_empirical_min},\n\\end{equation}\nwhere $(u)_+=\\max(u,0)$ is the positive part of $u$, $\\left \\| f\n\\right \\|$ is some norm for $f$, and $\\lambda$ is a tuning parameter\ncontrolling the trade-off between empirical risk and complexity of the\ndecision function $f$.\n\n\\cite{Zhou_undated-ps} showed that decision rule in\nEquation~\\ref{eq:d_owl_empirical_min} is\naffected by a simple shift of the outcome $y$ and proposed Residual\nweighted learning (RWL) to relieve this issue. The idea behind RWL is\nto introduce a function $g$ to reduce the variance of\n$\\frac{y-g(\\mathbf{x})}{p(t|\\mathbf{x})}\\mathbb{I}_{t \\neq\n  d(\\mathbf{x})}$ and a reasonable candidate of $g$ is\n\\begin{equation}\n  g^{*}(\\mathbf{x}) = \\frac{\\mathbb{E}(y|\\mathbf{x},\n    t=1)+\\mathbb{E}(y|\\mathbf{x}, t=-1)}{2} = \\mathbb{E} \\left (\n    \\frac{y}{2p(t, \\mathbf{x})} | \\mathbf{x} \\right ).~\\label{eq:g-choice}\n\\end{equation}\n\nRWL thus is to minimize the following empirical risk:\n\\begin{equation}\n   \\frac{1}{n}\\sum_{i=1}^{n}\\frac{y_i-\\hat{g}^{*}(\\mathbf{x}_i)}{p(t_i|\\mathbf{x_i})}\\mathbb{I}_{t_i \\neq\n    d_f(\\mathbf{x_i})}\n  ~\\label{eq:rwl-risk}\n\\end{equation}\nwhere $\\hat{g}^{*}$ is an estimate of $g^{*}$. For simplicity, let\n$\\hat{r}_i = y_i - \\hat{g}^{*}(\\mathbf{x}_i)$. As in OWL,\n\\cite{Zhou_undated-ps} consider a surrogate loss function $T$ to replace\nthe 0-1 loss in Equation~\\ref{eq:rwl-risk}. The non-convex loss $T$\nhas the following form:\n\\begin{equation}\nT(u) =  \\left\\{\\begin{array}{ll}\n 0 & \\mathrm{if} \\: u \\geq 1, \\\\ \n (1-u)^2 & \\mathrm{if} \\: 0 \\leq u < 1, \\\\ \n 2-(1+u)^2 & \\mathrm{if} \\: -1 \\leq u < 0, \\\\ \n 2 & \\mathrm{if} \\: u < -1\n\\end{array}\\right.\n\\end{equation}\nIt is called the smoothed ramp loss in \\cite{Zhou_undated-ps}. By\nincorporating the regularization, RWL is eventually aimed to minimize\nthe following empirical risk:\n\\begin{equation}\n    \\frac{1}{n}\\sum_{i=1}^{n}\\frac{\\hat{r}_i}{p(t_i|x_i)}T(t_if(\\mathbf{x}_i))_{+}+\\lambda\\left\n    \\| f \\right \\|^2 ~\\label{eq:d_owl_empirical_min},\n\\end{equation}\nwhere $\\left \\| f \\right \\|$ is the norm for $f$, and $\\lambda$ is a\ntuning parameter.\n\\subsubsection{Comparison}\nAll three aforementioned methods (RCF,\nCounterfactual Inference, ITR) can be trained on the data from either RCTs or\nobservational studies and can be used to assign a subject to a\npredicted optimal condition. Propensity trees from RCF \\cite{wager2015estimation} and BNN from\ncounterfactual inference \\cite{Johansson2016-dh} are specifically\noptimized for observational studies. Propensity tress uses the idea\nfrom propensity score matching to reduce possible variance in features\nof subjects between two conditions, while BNN uses deep learning\napproaches for domain adaptation to enforce the similarity between the\ndistributions of representations of subjects from two condition.\n\nSince ITR is a deterministic rule aimed to assign a subject to optimal\ncondition based on the observed features, ITR does not focus on\nestimating the treatment effect. BNN predicts two potential outcomes\n(the treatment outcome and the control outcome)\nfor each subject, so BNN is designed to estimate the individual\ntreatment effect. RCF assumes that subjects on the same leaf have the\nsame potential outcomes, so RCF usually estimates the treatment effect\non a small subset of populations from two conditions.\n\n\\subsection{Q2: Bayesian Optimization}\n\\paragraph{Question:} You have been doing stuff with Bandits. When might\nbe learning a function to predict goodness of hints across students be\na good idea?  Look into Bayesian Optimization.  How is that different\nthan what you are planning on doing.  How might you use such methods?\n\\\\ [0.1in]\n\nBayesian optimization is a sequential model-based approach for global\noptimization of an unknown objective function $f$. The problem can be\nmathematically expressed as:\n\n\\begin{equation}\n  \\mathbf{x}^* = \\underset{\\mathbf{x} \\in \\mathcal{X}}{\\mathrm{arg \\,\n      max} \\, f(\\mathbf{x})}\n\\end{equation}\nwhere $\\mathcal{X}$ is the design space of interest. Bayesian optimization is the combination of two main\ncomponents: a surrogate probabilistic model which captures our beliefs\nabout the behavior of the unknown objective function $f$ and is updated\nonce new observation is gathered, and an acquisition function $\\alpha: \\mathcal{X} \\rightarrow \\mathbb{R}$ which performs the selection\nof the optimal sequence of queries based on the previous model. Since\nthe objective function $f$ is unknown, the Bayesian\nstrategy is to place a prior over it which captures our beliefs about the behavior of the\nfunction. After gathering the function evaluations, which are treated\nas data, the prior is updated to form the posterior distribution\nover the objective function. Equipped with the posterior distribution,\nan acquisition function $\\alpha$\nis induced to determines what the\nnext query point should be. The trade-off between the exploration and\nthe exploitation is determined by the acquisition function leveraging the\nuncertainty in the posterior. Examples of acquisition functions includes\nprobability of improvement, expected improvement, Bayesian expected\nlosses, upper confidence bounds (UCB), and mixtures\nof these. The purpose of the trade-off is to\nminimize the number of function evaluations. As such, Bayesian\noptimization is well suited for functions that are very expensive to\nevaluate. The details of Bayesian\nOptimization is shown in Algorithm~\\ref{algo:bo}.\n\nThe Gaussian process (GP) is the most popular surrogate model. The\nobjective function is modeled as a sample from the GP distribution. Attributes of the\nGP such as mean and variance are used by the acquisition function to\ndecide the successive query points. More information about GP in the\nbandit setting can be found in Section~\\ref{sect:gp}.\n\n\\begin{algorithm}[h]\n  \\SetKwInOut{Input}{Input}\n  \\Input{$n$ observations $\\mathcal{D}=\\{ (\\mathbf{x}_i,\n    y_i)\\}_{i=1}^n$ from objective function $f$}\n\n \\caption{Bayesian optimization}~\\label{algo:bo}\n \\For{$t = n+1,n+2,\\ldots$} {\n   select new $\\mathbf{x}_{t}$ by maximizing acquisition function\n   $\\alpha$\n   $$\n     \\mathbf{x}_{t} = \\underset{\\mathbf{x}}{\\mathrm{arg \\, max}} \\, \\alpha(\\mathbf{x};\\mathcal{D})\n     $$\\\\\n     query objective function to observe $y_{t} =\n     f(\\mathbf{x}_{t})$ \\\\\n     augment data $\\mathcal{D}=\\{ \\mathcal{D},\n     (\\mathbf{x}_{t}, y_{t}) \\}$\\\\\n     update statistical model\n }\n\\end{algorithm}\n\n\\subsubsection{Thompson Sampling}\nThompson sampling for Beta-Bernoulli bandit perhaps is the simplest non-trivial multi-armed\nbandit strategy in Bayesian optimization \\cite{Shahriari2016-ho}. Bernoulli bandit problem is\nthe bandit problem when the rewards are either 0 or 1, and for arm $i$\nthe probability of success (reward=1) is $\\mu_i$. The Thompson\nsampling maintains Bayesian priors on the Bernoulli means\n$\\mu_i$'s. Beta distribution turns out to be a very convenient choice\nof priors for Bernoulli rewards. The pdf of $\\mathrm{Beta}(\\alpha,\n\\beta)$ with parameters $\\alpha > 0, \\beta > 0$ is given by\n\\begin{equation}\n  f(x;\\alpha, \\beta) = \\frac{\\Gamma(\\alpha + \\beta)}{\\Gamma(\\alpha)\\Gamma(\\beta)}x^{\\alpha-1}(1-x)^{\\beta-1}.\n\\end{equation}\n\nThe mean of $\\mathrm{Beta}(\\alpha,\\beta)$ is $\\alpha / (\\alpha +\n\\beta)$; and higher the $\\alpha, \\beta$, tighter is the concentration\nof $\\mathrm{Beta}(\\alpha,\\beta)$ around the mean. If the prior\nfor each arm is a $\\mathrm{Beta}(\\alpha,\\beta)$ distribution, then\nafter observing a Bernoulli trial, the posterior distribution is\nsimply $\\mathrm{Beta}(\\alpha + 1,\\beta)$ or\n$\\mathrm{Beta}(\\alpha,\\beta +1)$, depending on whether the trial\nresulted in a success or failure, respectively. Thompson sampling then\nsamples from these posterior distributions across all arms and chooses\nthe arm with largest sample value. This procedure is summarized in\nAlgorithm~\\ref{algo:thompson-sampling}.\n\n\\begin{algorithm}[h] \\label{algo:thompson-sampling}\n  \\SetKwInOut{Input}{Input}\n  \\Input{$\\alpha, \\beta$: hyperparameters of the beta prior}\n\n  \\caption{Thompson sampling for Beta-Bernoulli bandit}\n  Initialize $n_{a,0}=n_{a,1}=i=0$ for all $K$ arms $a$ \\\\\n  \\Repeat{stopping criterion reached} {\n    \\For{$a = 1,\\ldots, K$}{\n      $w_a \\sim \\mathrm{Beta}(\\alpha + n_{a,1}, \\beta + n_{a,0})$\n    }\n    $a_i = \\underset{a}{\\mathrm{arg\\, max}}\\, w_a$ \\\\\n    Observe $y_i$ by pulling arm $a_i$ \\\\\n    \\eIf{$y_i = 0$}{\n      $n_{a_i,0} = n_{a_i,0} + 1$\n      \n    }{\n      $n_{a_i,1} = n_{a_i,1} + 1$\n    }\n    $i = i + 1$ \\\\\n }\n\\end{algorithm}\n\nIn summary, Thompson sampling is the simplest non-trivial multi-armed\nbandit strategy in Bayesian Optimization. Since the Thompson sampling\nmodels the arms as independent, Thompson sampling must try every arm\nat least once. It will be an issue if the number of arms becomes\nlarge. In this case, Bayesian optimization with GP is an alternative\nto the Thompson sampling and alleviate this issue.\n\n\\subsubsection{Choice between function predictor and multi-armed bandit algorithm}\nIn many experiments, the designs space available to the designers have\ncomponents that can be varied independently. For example, in designing\nan advertisement, one has choices such arkwork, font style, and\nsize. If there are five choices for each, the total number of possible\nconfigurations is 125.\n\nIn general, this number grows combinatorially in the number of\ncomponents. This presents challenges for approaches such as the Thompson sampling, since the Thompson sampling models the arms as independent, which will lead\nto strategies that must try every arm at least once. This rapidly\nbecomes infeasible in the large design spaces.\n\nEven if the total number of possible design configuration is\nrelatively small, it is still challenging for multi-armed bandit\nalgorithms, such as Thompson sampling, when the number of available subjects is limited for these\nalgorithms to figure out the optimal arm.\n\nTo alleviate this issue, a commonly used approach is to learn a\nfunction, whose input is a feature vector of the arm and output is\nassociated reward of the arm, capturing dependence between the arms. Assume that each possible arm $a$ has an\nassociated feature vector $\\mathbf{x}_a\\in \\mathbb{R}^d$. The expected\nreward of each arm can be expressed as a function of this feature\nvector, such as $f(a) = f(\\mathbf{x}_a)$. The goal is to learn this\nfunction $f:\\mathbb{R}^d \\rightarrow \\mathbb{R}$ from the experiment\ndata in order to choose the arm with the highest reward among all\npossible arms.\n\n\\subsection{Q3: Contextual Bandit vs. Causal Inference}\n\\paragraph{Question:} In what conditions to use different ways to\npersonalize: Bandits (contextual) or Causal inference (Including Susan\nAthey's Random Causal Forest and things like counterfactual inference\nfor personalized learning) \\\\ [0.1 in]\n\nThe ultimate goal of contextual bandit algorithms and causal inference\nis the same: find the good intervention for each subject based on the\nobserved features. The contextual bandit algorithms are widely used in\nthe sequential experiments. In this setting, single interventions from\na pre-defined set are repeatedly performed to evaluate their goodness\nvia observed feedback. But explicit experiments may be difficult to be\nconducted in some research areas. Thus, contextual bandit algorithms\ncannot be directly applied and causal inference models are commonly\nused here. The idea behind causal inference models is to predict the\noutcome of an intervention from the observed data without explicitly\nperforming it.\n\n\\subsection{Q4: Online Learning vs. Batch Learning}\n\\paragraph{Question:} Why can BKT not update itself in real-time while\nThompson sampling can update itself online? \\\\ [0.1in]\n\nThere are four parameters in BKT that are learned from enough training\ndata. Before deploying BKT online, we need to collect reliable\ntraining data and learn these four parameters offline. On the\ncontrary, Thompson sampling is non-parametric model, so collecting\ntraining data is not necessary for it. Thompson sampling is a sequential\nmethod, which means it makes use of observations one at a time, or in\nsmall batches. Thus, it can be used in real-time sequential experiments.\n\nFour parameters in BKT are usually learned via\nExpectation-Maximization (EM) algorithm. EM algorithm is an iterative\nmethod to find the optimal values for parameters. An iterative method\nis a sequence of improving approximate solutions and requires\ncomputational time and resources. It will take some amount of time to\nupdate BKT parameters in real-time. On the contrary, Thompson sampling\nhas a simple close form to update its posterior distribution after\nreceiving new observations.\n\n\\subsection{Q5: Semi-Supervised Learning}\n\\paragraph{Question:} What is Semi-supervised learning?  How is that\nrelated to Mitchel's CoLearning? Is the same idea under a different\nname?  Can it be used to help solve your problems related to\nPeerASSIST?  \\\\ [0.1 in]\n\nIn the setting of semi-supervised learning, the training data consists\nof $l$ labeled instances $\\left \\{ (\\mathbf{x}_i, y_i)\n\\right \\}_{i=1}^{l}$ and $u$ unlabeled instances $\\left \\{ (\\mathbf{x}_j)\n\\right \\}_{j=l+1}^{l+u}$, often with $l \\ll u$. The goal of\nsemi-supervised learning is to learn a model with better performance\nfrom the combination of labeled data and unlabeled data than from\nlabeled data alone. The benefit of semi-supervised learning is that\nthe labeled data can be hard and expensive to obtain since labels may\nrequire human experts, and the unlabeled data is often cheap in large\nquantity. Figure~\\ref{fg:ssl_model} illustrates how unlabeled data\nhelp models achieve a better performance.\n\n\\begin{figure}[h] \n  \\centering\n  \\includegraphics[width=0.95\\columnwidth]{ssl.png}\n  \\caption{An illustrative example on how semi-supervised learning helps\n    the model have a better performance.}~\\label{fg:ssl_model}\n\\end{figure}\n\n\\subsubsection{Co-training}\nCo-training \\cite{blum1998combining} is a technique in semi-supervised learning that requires two\nviews of the data. It assumes that each example is described using two\ndifferent feature sets that provide different, complementary\ninformation about the example. Co-training first learns a separate\nclassifier for each view using any labeled examples. The most\nconfident predictions of each classifier on the unlabeled data are\nthen used to iteratively construct additional labeled training\ndata. The details of co-training algorithm is described in Algorithm~\\ref{algo:co-training}.\n\\begin{algorithm}[h] \\label{algo:co-training}\n  \\SetKwInOut{Input}{Input}\n  \\Input{labeled data $\\left \\{ (\\mathbf{x}_i, y_i)\n\\right \\}_{i=1}^{l}$, unlabeled data $\\left \\{ \\mathbf{x}_j\n\\right \\}_{j=l+1}^{l+u}$ \\\\\neach instance has two views $\\mathbf{x}_i=\\left [ \\mathbf{x}_i^{(1)},\n  \\mathbf{x}_i^{(2)} \\right ]$ \\\\\nand a learning speed $k$\n}\nLet $L_1 = L_2 = \\left \\{ (\\mathbf{x}_1, y_1), \\ldots, (\\mathbf{x}_l, y_l)\n\\right \\}.$ \\\\\n\\Repeat {unlabeled data is used up}{\n  Train view-1 $f^{(1)}$ from $L_1$, view-2 $f^{(2)}$ from $L_2$ \\\\\n  Classify unlabeled data with $f^{(1)}$ and $f^{(2)}$ separately. \\\\\n  Add $f^{(1)}$'s top $k$ most-confident predictions $(\\mathbf{x},\n  f^{(1)}(\\mathbf{x}))$ to $L_2$ \\\\\n  Add $f^{(2)}$'s top $k$ most-confident predictions $(\\mathbf{x},\n  f^{(2)}(\\mathbf{x}))$ to $L_1$ \\\\\n  Remove these from the unlabeled data.\n}\n\n\\caption{Co-training Algorithm for Semi-Supervised Learning}\n\\end{algorithm}\n\nThere are three important assumptions which guarantee the performance of\nco-training algorithm: 1). feature split $x=[x^{(1)};x^{(2)}]$\nexists; 2). $x^{(1)}$ or $x^{(2)}$ alone is sufficient to train a good\nclassifier; 3). $x^{(1)}$ and $x^{(2)}$ are conditionally independent\ngiven the class.\n\n\\subsubsection{Application in PeerASSIST}\nSemi-supervised learning approaches come in handy in PeerASSIST when\nwe try to learn a function to predict the effectiveness of peer\nexplanations. In the setting of PeerASSIST, not every peer explanation will be received by students,\nand thus, some of the explanations have no observed data on their\neffectiveness (e.g., the popularity, next problem correctness). When\nlearning the function, these peer explanations without observed data\nare discarded, which is a waste of the data. Moreover, if there are not enough\nobserved data, it becomes difficult to accurately learn the\nfunction. Semi-supervised learning approaches can be applied in this\nscenario to learn a better function.\n\n\\section{Topic 2: Application of Deep Learning to EDM and related issues}\n\\subsection{Q1: Natural Language Processing for Enhancing Learning}\n\\paragraph{Question:} You have done some work in using memory network to\npredict NLP classifications in a Kaggle Data set.   What are some\napplications you can put those skills to that will drive new designs\nthat could improve student learning? I think I have heard to throw out\na few ideas (1) the evaluation of the quality of open response from\nstudents, or 2) Which kids are improving or slacking? Or 3) Sentiment\nanalysis of posts or comments from students.  Is there a reasonable\nway to think about how to use NLP in your PeerASSIST feature? Pitch a\ncomplete idea of something you think practical  (you don't have to\nwant to do it, but if you did that would be nice). \\\\ [0.1 in]\n\n\\subsubsection{Confusion Detector}\nGiven the enormous student/instructor ratio in a MOOC's discussion\nforums, it is difficulty for an instructor to read all posts in a\nMOOC's discussion forums. To address this issue, \\cite{Agrawal2015-hp}\ncollected and created the Stanford MOOCPosts dataset: a corpus\ncomposed of 29,604 anonymized learner forum posts from eleven Stanford\nUniversity public online classes. Each post in the MOOCPosts dataset\nwas scored across six dimensions -- confusion, sentiment, urgency,\nquestion, answer, and opinion -- and subsequently augmented with\nadditional metadata. Then the authors built a confusion classifier from\nthe Stanford MOOCPost dataset to automatically detect confusion from\nstudents posts and proposed a recommendation algorithm, which takes the\nstudent confusion as input, to automatically recommended a\nvideo lecture from a collection of several video lectures related to\nthe course.\n\\subsubsection{Automated Essay Scoring}\nAutomated grading is a critical part of Massive Open Online Courses (MOOCs) system and any intelligent tutoring systems (ITS) at scale. Essay writing is usually a common student assessment process in schools and universities. In this task, students are required to write essays of various length, given a prompt or essay topic. Some standard tests, such as Test of English as a Foreign Language (TOEFL) and Graduate Record Examination (GRE), assess student writing skills. Manually grading these essay will be time-consuming. Thus automated essay scoring (AES) systems has been used in these tests to reduce the time and cost of grading essays. Moreover, as massive open online courses (MOOCs) become widespread and the number of students enrolled in one course increases, the need for grading and providing feedback on written assignments are ever critical.\n\nAES has employed numerous efforts to improving its performance. AES uses statistical and Natural Language Processing (NLP) techniques to automatically predict a score for an essay based on the essay prompt and rubric. Most existing AES systems are built on the basis of predefined features, e.g. number of words, average word length, and number of spelling errors, and a machine learning algorithm \\cite{Chen2013-zw}. It is normally a heavy burden to find out effective features for AES. Moreover, the performance of the AES systems is constrained by the effectiveness of the predefined features. Recently another kind of approach has emerged, employing neural network models to learn the features automatically in an end-to-end manner \\cite{Taghipour2016-ns}. By this means, a direct prediction of essay scores can be achieved without performing any feature extraction. The model based on long short-term memory (LSTM) networks in \\cite{Taghipour2016-ns} has demonstrated promise in accomplishing multiple types of automated grading tasks.\n\n\\subsubsection{NLP in PeerASSIST}\nThe goal of PeerASSIST is to crowdsource the explanation (in the\nformat of texts) of how to solve a\ngiven problem from students and apply multi-armed bandit algorithm to\nefficiently select the most helpful and useful peer explanation from all collected\npeer explanations for a given problem. The effectiveness of each peer\nexplanations is measured in three dimensions: teacher's rating (thumb\nup or thumb down), student's rating (thumb up or thumb down), and the\nstudent next problem correctness after receiving the peer explanation.\n\nA potential application of NLP techniques to PeerASSIST is to build a\nclassifier to predict the probability of a peer explanation being an\neffective one based on the content of the explanation. As mentioned\nabove, NLP techniques, especially deep learning approaches for NLP,\nhave achieved promising results on text classification tasks. The\npredicted probabilities can potentially used to select the optimal\nexplanation when one is needed to be delivered to the students. In\nthis scenario, we can deliver the explanation with the highest\nprobability to students. Another possible use of the predicted\nprobabilities is to treat these values as a part of the contextual\ninformation for the explanations and incorporate this contextual\ninformation into contextual multi-armed bandit algorithms.\n\nThe explanations collected from students are not always of good\nquality. Since the classifier can automatically detect explanations\nwith bad quality (i.e., the explanations with low probability values),\none can quickly filter out these potential bad explanations, which\nsaves multi-armed bandit algorithm from wasting attempts trying these\nexplanations. When the explanations\nthat students type in are detected as bad ones by the classifier, we\ncan also build an intervention by\ntelling students that the algorithm thinks that their explanations\nneed some improvement. Then the students have a second chance to\nsubmitting new explanations. We hope that there will be observable\nimprovement on the quality of peer explanations for these students.\n\n\\subsection{Q2a: Reliable Crowdsourcing}\n\\paragraph{Question:} Besides assessing the learning gains associated\nwith each learning artifacts, it can also be useful to characterize\nthem for certain features. Suppose you ask many students to rate a\nbunch of learning artifacts along different dimensions, e.g., media\nformat, pedagogical approach, difficulty to understand, etc. How do\nyou know which learners to trust, and how do you combine their\nopinions into aggregate labels? What kinds of algorithms exist for\nthis purpose and how do they work? \\\\ [0.1 in]\n\nDuring this process of asking\nstudents to rate the learning artifacts, we might\ngather noisy rating from students due to the fact that students may\nhave a wide ranging level of rating expertise which are unknown, and\nin some cases may be adversarial. To learn the ground truth of these\nlearning artifacts, we need to aggregate their opinions to recover the\ntrue, unknown label of each learning artifacts.\n\n\\subsubsection{Majority Voting}\nGiven each item is labeled by different workers, it is a\nstraightforward approach to take the majority label as the true\nlabel. From reported experimental results on real crowdcourcing data\n\\cite{Snow2008-rm}, majority voting performs significantly better on\naverage than individual workers. However, majority voting considers\neach item independently and gives the same weight across all workers\nwho label the item when aggregating true label.\n\n\\subsubsection{Dawid-Skene Model}\n\\cite{dawid1979maximum} were among the first to consider such a\nproblem setup. They assume each workers are conditionally independent\ngiven the true labels and each worker is associated with a\nprobabilistic confusion matrix that generates her labels. Each entry\nof the matrix indicates the probability that items in one class are\nlabeled as another. Given the\nobserved responses, the true labels for each items and the confusion\nmatrices for each worker can be jointly estimated by a maximum\nlikelihood method. The optimization can be implemented by the\nexpectation-maximization (EM) algorithm.\n\n\n\\subsubsection{GLAD}\n\\cite{NIPS2009_3644} proposed a richer graphic model which includes\nitem difficulty and the expertise of the worker. The difficulty of\nitem is modeled by the parameter $1/\\beta_j \\in [0,\\infty)$. Here $1/\\beta_j = \\infty$\nmeans the image is very ambiguous and hence the most proficient worker\nhas a random chance of labeling it correctly. $1/\\beta_j = 0$ means the item is\nso easy that even the most obtuse worker will always label it correctly.\n\nThe expertise of each worker $i$ is modeled using the parameter\n$\\alpha_i \\in (-\\infty, +\\infty)$. Here $\\alpha = +\\infty$ means the\nworker always labels items correctly; $-\\infty$ means the worker\nalways labels items incorrectly.\n\nThe labels given by worker $i$ to item $j$ are denoted as $L_{ij}$\nand are generated as follows:\n\n\\begin{equation} \\label{eq:glad_label}\n  p(L_{ij}=Z_j|\\alpha_i , \\beta_j) = \\frac{1}{1+e^{-\\alpha_i \\beta_j}}\n\\end{equation}\n\nAs the difficulty $1/\\beta_j$ of an item increases, the probability of\nthe label being correct moves toward 0.5. Similarly, as the worker's\nexpertise decreases (lower $\\alpha_i$), the chance of correctly\nlabeling drops to 0.5. Figure~\\ref{fg:glad_model} shows the structure\nof the graphical model.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.95\\columnwidth]{glad.png}\n  \\caption{An illustrative example on how semi-supervised learning helps\n    the model have a better performance.}~\\label{fg:glad_model}\n\\end{figure}\n\n\\subsubsection{Deep Learning Approach}\n\\cite{Shaham2016-nh} showed that the Dawid and Skene model is\nequivalent to a Restricted Boltzmann Machine (RBM) with a single\nhidden node under the assumption that all workers are conditionally\nindependent. Thus the posterior probabilities of the true labels can\nbe estimated via a trained RBM.\n\nA RBM is an undirected bipartite graphical model, consisting of a\nvisible layer $X$ and a hidden layer $H$. The visible layer consists\nof $d$ binary random variables and the hidden layer $m$ binary random\nvariables. These two layers are fully connected to each other. A RBM\nis parametrized by $\\lambda = (W, a, b)$, where $W$ is the weight\nmatrix of the connections between the visible and hidden units, and\n$a,b$ are the bias vectors of the visible and hidden layers,\nrespectively. An illustration of a RBM is depicted in Figure~\\ref{fg:rbm_model}.\n\nA RBM implies the conditional probabilities\n\n\\begin{align*}\np_{\\lambda}(X_i=1|H) &= \\sigma (a_i+W_{i\\cdot}H) \\\\\np_{\\lambda}(H_j=1|X) &= \\sigma (b_j+X^{T}W_{\\cdot j}),\n\\end{align*}\nwhere $\\sigma (z)$ is the sigmoid function, $W_{i\\cdot}$ is the $i$-th\nrow of $W$ and $W_{\\cdot j}$ is its $j$-th column.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.95\\columnwidth]{rbm.png}\n  \\caption{Diagram of a restricted Boltzmann machine with four visible\n  units and three hidden units (no bias units)} ~\\label{fg:rbm_model}\n\\end{figure}\n\nTo relax the assumption on the conditional independence of the\nvariables $X_1,\\ldots,X_d$, a RBM-based Deep Neural Net (DNN) is\nproposed to estimate the posterior probabilities\n$p_{\\theta}(Y|X)$. The mechanism to stack multiple RBMs is that the\nhidden layer of each RBM is the input for the successive RBM. The RBMs\nare trained one at a time from bottom to top. Specifically, given\ntraining data $x^{(1)}, \\ldots, x^{(n)} \\in \\{ 0,1 \\}^d$, the bottom\nRBM is trained first, and then obtain the hidden representation of the\nfirst layer by sampling $h^{(i)}$ from the conditional RBM\ndistribution $p_{\\lambda}(H|X=x^{(i)})$. The vector $h^{(1)}, \\ldots,\nh^{(n)}$ are then used as a training set for the second RBM and so\non. An illustration of a RBM is depicted in Figure~\\ref{fg:rbm-dnn-model}.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.75\\columnwidth]{rbm-dnn.png}\n  \\caption{Diagram of RBM-based DNN with two hidden layers.}\n  ~\\label{fg:rbm-dnn-model}\n\\end{figure}\n\n\\subsubsection{Minimax Entropy}\n\\cite{Zhou2012-ry} proposed a minimax entropy principle to estimate\nthe ground truth given the observed labels by workers. The model is\nillustrated in Figure~\\ref{fg:minimax_entropy_model}. Each row\ncorresponds to a worker indexed by $i$ (from 1 to $m$). Each column\ncorresponds to an item to be labeled, indexed by $j$ (from 1 to\n$n$). Each item has an unobserved label represented as a vector\n$y_{jl}$, which is 1 when item $j$ is in class $l$ (from 1 to $c$),\nand 0 otherwise. Observed data is a tensor of labels $z_{ijk}$, which\nis 1 when the item $i$ is labeled as class $k$ by the worker $i$, and\n0 otherwise. We assume that $z_{ij}$ are drawn from\n$\\pi_{ij}$. $\\pi_{ij}$ can be represented as a tensor $\\pi_{ijk}$,\nwhich is the probability that worker $i$ labels item $j$ as class\n$k$. The proposed model will estimate $y_{jl}$ from the observed\n$z_{ij}$.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.95\\columnwidth]{minimax_entropy.png}\n  \\caption{Left: observed labels. Right: underlying\n    distributions. Highlights on both tables indicate that rows and\n    columns of the distributions are constrained by sums over observations.}\n  ~\\label{fg:minimax_entropy_model}\n\\end{figure}\n\n$\\pi_{ij}$ is modeled through the principle of maximum entropy with the\nconstraints from the ideas of majority voting and Dawid and Skene's\nmodel. Using the principle of maximum entropy to estimate the\nprobability distribution provides the largest remaining uncertainty\n(i.e., the maximum entropy) consistent with the constraints. Majority voting indicates that the number of observed votes per\nclass per item  $\\sum_{i}z_{ijk}$ should match\n$\\sum_{i}\\pi_{ijk}$. Dawid and Skene's model indicates that the\nobserved confusion matrix per worker $\\sum_{j}y_{jl}z_{ijk}$ should match $\\sum_{j}y_{jl}\\pi_{ijk}$. Thus, the maximum entropy model for $\\pi_{ij}$ given $y_{jl}$ is as\nfollows:\n\n\\begin{align}\n\\max_{\\pi} & -\\sum_{i=1}^{m}\\sum_{j=1}^{n}\\sum_{k=1}^{c} \\pi_{ijk}\n\\ln \\pi_{ijk} \\nonumber \\\\\n  \\mathrm{s.t.} & \\sum_{i=1}^{m}\\pi_{ijk} = \\sum_{i=1}^{m}z_{ijk},\n                  \\forall j,k, ~ \\sum_{j=1}^{n}y_{jl}\\pi_{ijk} =\n                  \\sum_{j=1}^{n}y_{jl}z_{ijk} \\forall i,k,l, \\nonumber\n  \\\\\n  & \\sum_{k=1}^{c}\\pi_{ijk}=1, \\forall i,j, \\pi_{ijk} \\geq 0, \\forall\n    i,j,k. \\label{eq:max_entropy}\n\\end{align}\n\nTo infer $y_{jl}$, the authors proposed to choose $y_{jl}$ to minimize the\nentropy in Equation~\\ref{eq:max_entropy}, which leaves $z_{ij}$ the\nleast random given $y_{jl}$.\n\n\\begin{align}\n\\min_{y}\\max_{\\pi} & -\\sum_{i=1}^{m}\\sum_{j=1}^{n}\\sum_{k=1}^{c} \\pi_{ijk}\n\\ln \\pi_{ijk} \\nonumber \\\\\n  \\mathrm{s.t.} & \\sum_{i=1}^{m}\\pi_{ijk} = \\sum_{i=1}^{m}z_{ijk},\n                  \\forall j,k, ~ \\sum_{j=1}^{n}y_{jl}\\pi_{ijk} =\n                  \\sum_{j=1}^{n}y_{jl}z_{ijk} \\forall i,k,l, \\nonumber\n  \\\\\n  & \\sum_{k=1}^{c}\\pi_{ijk}=1, \\forall i,j, \\pi_{ijk} \\geq 0, \\forall\n    i,j,k, \\sum_{l=1}^{c}y_{jl}=1, \\forall j, y_{jl} \\geq 0, \\forall\n    j, l. \\label{eq:minimax_entropy}\n\\end{align}\n\n\\subsubsection{Control Items}\nControl items with known answers can be used to evaluation workers'\nreliability and bias, and hence weight their answers accordingly on target\nitems with unknown answers. There is a trade-off in this\nscenario: we can better estimate workers' reliability and bias by\nletting them answer more control items, but there are fewer\nopportunities left for the\ntarget items. On the other hand, using fewer control items produces poor\nestimates of worker's reliability and bias, which leads to a bad\nresult when aggregating workers' answers. \\cite{Liu2013-ck} examined\nthe effectiveness of control items and provided insights on how many control items are enough under\ndifferent scenarios, which can help crowdsourcing practitioners make\ntheir own decisions. Aforementioned methods\n(except for majority voting) evaluate workers' reliability by\ncomparing their agreement with other workers and control items can be\nincorporated into these methods.\n\n\\subsection{Q2b: Gaussian Processes in Contextual\n  Bandit}\\label{sect:gp}\n\\paragraph{Question:} For the purposes of identifying the most effective\nlearning artifact, how do contextual bandits relate to Gaussian\nprocesses? How are they different/similar? \\\\ [0.1 in]\n\nThe reward function in contextual bandit setting is usually an unknown\nfunction and expensive to evaluate (performing an arm on a\nsubject). In this case, Gaussian process (GP) is an ideal method to model\nour belief on the behavior of the reward function. The reward function\nis modeled as a sample from GP.\n\nThe Gaussian process $\\mathrm{GP}(\\mu_0,k)$ is a non-parametric model\nthat is fully characterized by its prior mean function $\\mu_0 :\n\\mathcal{X}\\rightarrow \\mathbb{R}$ and its positive-definite kernel,\nor covariance function, $k: \\mathcal{X} \\times \\mathcal{X} \\rightarrow\n\\mathbb{R}$.\n\nLet $\\mathcal{D}_n = \\left \\{( \\mathbf{x}_i, y_i \\right )\\}$ denote a\nset of $n$ observations and $\\mathbf{x}$ denote the arbitrary test\npoint. The random variable $f(\\mathbf{x})$ is also a GP distribution\nconditioned on observations $\\mathcal{D}_n$ with following mean\n$\\mu_n(\\mathbf{x})$ and variance $\\sigma_n^2(\\mathbf{x})$:\n\\begin{align}\n \\mu_n(\\mathbf{x}) &= \\mu_0(\\mathbf{x}) +\n                     \\mathbf{k}(\\mathbf{x})^T(\\mathbf{K}+\\sigma^2\\mathbf{I})^{-1}(\\mathbf{y}-\\mathbf{m})\n  \\\\\n  \\sigma_n^2(\\mathbf{x}) &= k(\\mathbf{x}, \\mathbf{x}) -\n                           \\mathbf{k}(\\mathbf{x})^T(\\mathbf{K}+\\sigma^2\\mathbf{I})^{-1}\\mathbf{k}(\\mathbf{x})\n\\end{align}\nwhere $m_i := \\mu_0(\\mathbf{x}_i)$, $K_{i,j} := k(\\mathbf{x_i, x_j})$,\nand $\\mathbf{k}(\\mathbf{x})$ is a vector of covariance terms between\n$\\mathbf{x}$ and $\\mathbf{x}_{1:n}$.\n\nThe posterior mean and variance evaluated at any point $\\mathbf{x}$\nrepresent the model's prediction and uncertainty in the objective\nfunction at the point $\\mathbf{x}$. In order to apply GP under the\nsetting of multi-armed bandit, we need a acquisition function to select\nthe next query point given the posterior model. The acquisition\nfunction should be carefully design to trade off exploration of the\nsearch area and exploitation of current promising areas.\n\n\\subsubsection{GP-UCB}\nTo decrease uncertainty globally, one strategy could be to pick the\npoint which maximums the variance $\\mathbf{x}_{n+1}=\n\\underset{\\mathbf{x} \\in\n  D}{\\mathrm{arg\\,max}}~\\sigma_n(\\mathbf{x})$. However, this strategy\nis not well suited for multi-armed bandit problem since it can be\nwasteful. Another idea is to\nselect the point which maximizes the expected reward given the\nposterior model $\\mathbf{x}_{n+1}=\n\\underset{\\mathbf{x} \\in\n  D}{\\mathrm{arg\\,max}}~\\mu_n(\\mathbf{x})$. However, this idea is too\ngreedy and tends to end up with a local optima. To balance exploration\nand exploitation, a combined strategy is to choose\n\\begin{equation}\n  \\mathbf{x}_{n+1} = \\underset{\\mathbf{x} \\in D}{\\mathrm{arg \\,\n      max}}\\,\\mu_n(\\mathbf{x})+\\beta_n \\sigma_n(\\mathbf{x}),\n\\end{equation} \\label{eq:gp-ucb-query}\nwhere $\\beta_n$ are constants. There are theoretically motivated\nguidelines for setting and scheduling the hyperparameter $\\beta_n$ to\nachieve optimal regret.\n\nSince Equation~\\ref{eq:gp-ucb-query} is an upper confidence bound of\nthe marginal posterior $P(f(\\mathbf{x})|\\mathbf{y}_n)$, a natural\ninterpretation of this strategy is that it selects the point\n$\\mathbf{x}$ such that $f(\\mathbf{x})$ is a reasonable upper bound on\n$f(\\mathbf{x})$. This algorithm is called Gaussian process upper\nconfidence bound (GP-UCB), introduced by \\cite{Srinivas2010-hi}. The\nGP-UCB selection rule is motivated by the UCB algorithm for the\nclassical multi-armed bandit problem.\n\n\\subsubsection{Contextual GP-UCB}\nMotivated by GP-UCB algorithm mentioned above, \\cite{Krause2011-sb}\nextended the generalization of this algorithm by incorporating\ncontextual information\n\\begin{equation}\n  \\mathbf{x}_{n+1} = \\underset{\\mathbf{x} \\in D}{\\mathrm{arg \\,\n      max}}\\,\\mu_n(\\mathbf{x}, \\mathbf{z}_n)+\\beta_n\n  \\sigma_n(\\mathbf{x}, \\mathbf{z}_n),\n\\end{equation} \\label{eq:cgp-ucb-query}\nwhere $z_n \\in Z$ is the contextual information from a set $Z$ of\ncontexts, $\\mu_n(\\cdot)$ and $\\sigma_n^2(\\cdot)$ are the posterior mean\nand variance of the GP conditioned on observations $\\mathcal{D}_n =\n\\left \\{( \\mathbf{x}_i, \\mathbf{z}_i, y_i \\right )\\}.$ The authors\ncalled the selection rule the contextual Gaussian process UCB\nalgorithm (GCP-UCB).\n\nTo derive the kernel $k$ on the product space $Z\\times X$ of contexts and\nactions, a natural approach to start with kernel functions $k_Z:\nZ\\times Z \\rightarrow \\mathbb{R}$ and $k_X:X \\times X \\rightarrow\n\\mathbb{R}$ on the space of contexts and actions. \\cite{Krause2011-sb}\nproposed two possibilities of constructing composite kernel $k$ from\ncontext kernel $k_Z$ and action kernel $k_X$. One is to calculate a\nproduct kernel $k=k_Z\\otimes k_X$, by setting\n\\begin{equation}\n  (k_Z\\otimes k_X)((\\mathbf{z}, \\mathbf{x}),(\\mathbf{z}^{\\prime},\n  \\mathbf{x}^{\\prime})) = k_Z(\\mathbf{z}, \\mathbf{z}^{\\prime})k_X(\\mathbf{x}, \\mathbf{x}^{\\prime}).\n\\end{equation}\n\nAn alternative is to calculate the additive kernel $k=k_Z\\oplus k_X$,\nby setting\n\n\\begin{equation}\n  (k_Z\\oplus k_X)((\\mathbf{z}, \\mathbf{x}),(\\mathbf{z}^{\\prime},\n  \\mathbf{x}^{\\prime})) = k_Z(\\mathbf{z}, \\mathbf{z}^{\\prime})+k_X(\\mathbf{x}, \\mathbf{x}^{\\prime}).\n\\end{equation}\n\n\\subsection{Q2c: Selection Bias \\& Propensity Score Matching}\n\n\\paragraph{Question:} how precisely are estimates of the effectiveness of\na learning artifact biased when the student herself can choose which\nartifact she receives (selection bias)? How can methods such as\npropensity score matching partially reduce this bias? \\\\ [0.1 in]\n\nIn RCTs, students are randomly assigned to conditions so treatment is assigned by randomization. As a consequence of\nrandomization, an unbiased estimate of the ATE can be directly\ncomputed from the data. An unbiased estimate of the ATE is\n$E[Y_i(1)-Y_i(0)]=E[Y(1)] - E[Y(0)]$. When the student can choose\nwhich artifact she receives, randomization of treatment assignment\ndoes not exist. As a consequence, the treated students often differ\nsystematically from untreated students. In general, $E[Y(1)\\mid t=1]\n\\neq E[Y(1)]$ holds. Thus, an unbiased estimate of the ATE cannot be\nobtained by directly comparing outcomes between the the treated and the control groups.\n\nA propensity score \\cite{rosenbaum1983central} is the probability of a unit (e.g., student,\nclassroom, school) being assigned to a particular treatment given a\nset of observed features. Propensity scores are used to reduce\nselection bias by equating groups based on these features.\n\nSuppose that we have a binary treatment $T=\\{0,1\\}$, an outcome $Y$, and\nobserved features $X$. The propensity score is defined as the\nconditional probability of treatment given background variables:\n$$p(x):= \\Pr(T=1 \\mid X=x)$$\n\nDue to random treatment assignment in RCT, the propensity score is\nknown. However, the actual propensity score in observational experiments is\nunknown and it can be estimated using statistical or machine\nlearning models from the experiment data. The most commonly used model\nis a logistic regression model, in which treatment assignment $T$ is\nthe dependent variable and features $X$ are independent variables. Beyond logistic regression, the\nuse of bagging or boosting \\cite{Lee2010-zr}, tree-based model\n(Propensity trees) and causal random forests\n\\cite{wager2015estimation}, and neural networks\n\\cite{setoguchi2008evaluating} have been proposed to estimate the\npropensity score.\n\nThe purpose of Propensity score matching (PSM) \\cite{austin2011introduction} is to form matched sets\nof the treated and\nthe control subjects who share a similar value of the predicted propensity\nscore. The most common\nimplementation of PSM is one-to-one or pair matching, in which pairs\nof the control and the treated subjects are formed, such that matched\nsubjects have similar values of the propensity score. Once a matched\nsample has been formed, the treatment effect can be estimated by\ndirectly comparing outcomes between treated and untreated subjects in\nthe matched sample. PSM attempts to mimic randomization by creating a\nsample of units that received the treatment that is comparable on all\nobserved covariates to a sample of units that did not receive the\ntreatment. In summary, the analysis of a propensity score matched sample can mimic that of an\nRCT: one can directly compare outcomes between the treated and the control\nsubjects within the propensity score matched sample. \n\nThe aforementioned methods, propensity trees\n\\cite{wager2015estimation} in section~\\ref{sect:rcf} and balancing\nneural networks (BNN) \\cite{Johansson2016-dh} in\nsection~\\ref{sect:bnn}, can also be used to reduce the selection\nbias. The propensity trees is inspired by the idea of propensity score\nmatching. The goal of propensity trees is to train a classification\ntree to predict the treatment assignments. The subjects on the same\nleaf are considered as matched subjects. Due to the selection bias,\ntwo distributions of observed covariates for the control and the\ntreated groups may be different. Thus, the problem of counterfactual\ninference may require inference over a different distribution than the\none from which samples are given. In other words, the features\ndistribution of the test data differs from that of the training\ndata. This is a special case of domain adaptation. BNN uses deep learning\napproaches for domain adaptation to learn a balanced representation\nbetween the control and the treatment groups to reduce the selection\nbias.\n\n\\section{Topic 3: Crowdsourcing for Education.  More on the HCI side and HCOMP ideas}\n\\subsection{Q1: Peer Assessment}\n\\paragraph{Question:} Chris Schunn works on peer grading.  What\nliterature in that is relevant to your dissertation?  Do people make\ngood reviewers? Do they learn from reviewing?  Do authors benefit from\ngetting reviews?  (Do they essay they right get better if they get a\nreview?) \\\\ [0.1 in]\n\nAfter going through Chris Schunn's publications, I find these papers\n\\cite{patchan2016understanding,patchan2015understanding,\nschunn2016reliability, cho2006validity}\nrelated to my dissertation. The summary of research findings from\nthese paper is listed below.\n\nIn \\cite{cho2006validity, schunn2016reliability}, the authors run a\nset of studies to investigate the reliability and validity of peer\nassessment of writing on college level and high school level,\nrespectively. The authors use term reliability to refer to the extent\nto which students' assessment of writing correlate with each other and\nuse validity to describe the extent to which students can accurately\njudge the quality of the writing. These two papers reach the\nconclusion that the assessments from students at college level and\nhigh school level have strong reliability and validity. In other\nwords, peers in general are capable of providing valid ratings for\nothers' writing, and their feedback is usually thought to be helpful\nby other students. Students improved their writing ability from peer\nassessment, and specifically from providing feedback to peers.\n\n\\cite{patchan2016understanding} investigated the relationship between\nwriter ability and reviewer ability and found several interesting interactions\nbetween these two factors. Often lower-ability writers were more\nwilling to improve their writing using feedback from other low-ability\nreviewers than from high-ability reviewers, while higher-ability\nwriters benefited equally from receiving feedback from lower-ability\nand higher-ability reviewers, which is inconsistent with student\nbeliefs that only feedback from high-ability peers is worthwhile.\n\nIn terms of the style of the feedback, \\cite{patchan2015understanding} found that low reviewer provided more praise than high reviewers\nwhereas high reviewers provided more criticism than low\nreviewers. This criticism described more problems and offered more\nsolutions. There was one interesting interaction between reviewer\nability and text quality -- high reviewers described more problems in\nthe low-quality texts than in the high-quality texts, whereas low\nreviewers did not make this distinction.\n\n\\subsection{Q2: DALITE}\n\\paragraph{Question:} How would that be adapted to deal with DALITE\nobjects? \\\\ [0.1 in]\n\nDistributed Active Learning Technology Integrated Environment\n(DALITE) \\cite{bhatnagar2015analysis} is a web-based application for an asynchronous peer\ninstruction. In DALITE, students are asked to submit their\nexplanations for their choice after answering a multiple-choice\nquestion. Then they are prompted with several explanations from other\nstudents. Half of these peer explanations are for the choice that\nstudents select, and the other half of the peer explanations are for a\ndifferent choice. Students have a chance to reflect their thinking by\ncomparing their explanations with prompted explanations and make a\nsecond choice. Students can also select the best explanation among\nthose displayed.\n\nSimilarly to \\cite{cho2006validity, schunn2016reliability}, we should\nfirst investigate in DALITE whether students can learn from providing their own explanations and from reflecting their thinking by\ncomparing their explanations with other students'\nexplanations. Another investigation should be focused on the quality\nof peer explanations and students' perceptions about the asynchronous\npeer instruction workflow.\n\n\\cite{patchan2016understanding} found that lower-ability writers were more\nwilling to improve their writing using feedback from other low-ability\nreviewers than from high-ability reviewers, while higher-ability\nwriters benefited equally from receiving feedback from lower-ability\nand higher-ability reviewers. This inspires us to investigate whether\nthis conclusion holds in the context of DALITE. We usually believe\nthat high-ability students produce high-quality explanations and both\nhigh-ability and low-ability students benefit from these\nexplanations. If the aforementioned conclusion holds in DALITE, an\nadaptive strategy can be applied to select the prompted explanations\nfor students based on their ability. In other words, for low-ability students,\nexplanations from other low-ability students should be selected.\n\nAnother interesting topic inspired by \\cite{patchan2015understanding}\nis the style of peer explanations. There are two factors of the\nstudents which play an important role in this\nsetting: the ability of solving a question and the ability of providing\na high-quality explanations. We can look at the interactions between\nthe style and these two factors.\n\n\\subsection{Q3: Learnersourcing Subgoal Labels}\n\\paragraph{Question:} How is the work by Rob Miller and Juho about\nlearning subgoal related to PeerASSIST? \\\\ [0.1 in]\n\n\\cite{Weir2015-hg} presented a three-stage workflow for learners to generate\nsubgoal labels for how-to video while they are learning from the\nvideos. The goal of the first stage (Generation) is to let learners submit the\nsubgoal labels after a certain interval during watching the\nvideos. The goal of the second stage (Evaluation) is to let learners select the\nmost relevant answer for the video section, as well as discard\npotential spam answers. The goal of the third stage (Proofreading) is\nto let learners evaluate the most popular subgoal labels from stage 2\nfor quality and eventually agree on a final label for that\nsubgoal. During stage 2 and stage 3, learners always have a option to\nrefine the label.\n\nIn PeerASSIST, only students who receive 0 on a problem are\nprompted with a peer explanation from one of students who answer the same\nproblem correctly. Then these students have a option to give a rating\n(thumb up or thumb down) to the peer explanation that they\nreceive. The students, who answer the problem correctly in the first\nattempt, do not have a chance seeing and rating the peer\nexplanations. If\na certain problem is relatively easy, there will be few students who\nreceive 0 and it is difficult to find the optimal peer explanations\nbased on students' ratings. Even if the problem is relatively\ndifficult, we miss the contribution from the students with correct\nanswer in the first attempt when deciding the optimal peer\nexplanations. Motivated by \\cite{Weir2015-hg}, we can apply two-stage\nworkflow to collect ratings from students in terms of the quality of\nthe peer explanations after they submit an answer. Assume that there\nare several peer explanations available for a given problem and the\nranking of these peer explanations are already decided by some\nalgorithm (e.g., multi-armed bandit algorithm) based on the history data.\n\nOn stage 1, students are prompted with several (i.e., 3) peer\nexplanations and have a option to rate these explanations after they\nsubmit an answer. The goal of this stage is to collect students'\nopinions on these explanations and use these data as one of the\nindicators to determine the most effective explanation and discard\nspam explanations. In terms of\nwhich explanations should be prompted to students on this stage,\nseveral simple approaches can be applied: random selection from all\navailable explanations or newly added explanations. Exploration strategy can be applied in this scenario. For the purpose of\nexploration, explanations with high uncertainty are prompted with\nstudents. This strategy can potentially reduce the uncertainty of\nthese explanations and help multi-armed bandit algorithm efficiently\nfind the optimal explanations.\n\nOn stage 2, student are prompted with the currently optimal peer explanation\nfrom the ranking algorithm and asked to evaluate whether this peer\nexplanation is highly effective. The goal of this stage is to let\nstudents to evaluate the optimal explanation for quality and analog to\nthe goal of exploration strategy in multi-armed bandit algorithm.\n\n\\subsection{Q4: HCOMP \\& CSCW}\n\\paragraph{Question:} Look at the two most recent  HCOMP conference and\nthe CSCL conferences.   What do you see in those conferences that\nrelate to what you want to propose for your dissertation?   I assume\nsome will be methodological, while others will be on the design side.\nFor the purpose of this question let's look at the design side. \\\\\n[0.1 in]\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.75\\columnwidth]{learnersourcing.png}\n  \\caption{Reprinted from \\cite{Glassman2016-yy}. In the\n    self-reflection workflow, students generate hints by reflecting on\n  an obstacle they themselves have recently overcome. In the\n  comparison workflow, students compare their own solutions to those\n  of other students, generating a hint as a byproduct of explaining\n  how one might get from one solution to the other.}\n  ~\\label{fg:learnersourcing-model}\n\\end{figure}\n\nThe aforementioned paper, Learnersoucring Subgoal Labels for How-to Videos\n\\cite{Weir2015-hg}, is published in CSCW 2015. In this paper, the\nauthors showed that students were qualified to generate subgoal labels\nfor how-to videos based on their new expertise. Motivated by this prior\nwork, another paper, Learnersourcing Personalized Hints\n\\cite{Glassman2016-yy}, is published in CSCW 2016. In\n\\cite{Glassman2016-yy}, the authors designed two workflows aimed to\nengage students in creating personalized hints. Results showed that students can create helpful hints for their\npeers that augment or even replace teachers’ personalized assistance,\nwhen that assistance is not available.\n\nIn the self-reflection workflow, students iteratively work on their\nsolutions to pass as many teacher-created tests as possible. There are\nhints available for any verification. Students can ask for these hints\nto help them pass the test case. After fixing a bug in their own\nsolution, students can generate a new hint for others struggling with\nthe same error.\n\nIn the comparison workflow, students compare their solution to\nalternative solution submitted by other students or teachers. If their\nsolution performs better than a solution $W$, they are asked to submit\nan optimization hint for students who have solutions like $W$. If\ntheir solution performs worse than a solution $B$, they are prompted\nto generate an optimization hint for students who have solutions like\ntheir own. Figure~\\ref{fg:learnersourcing-model} illustrates both workflows.\n\n\\cite{Yoon2016-nk} developed a new multi-modal annotation (e.g.,\ngesture and waveform) tool, called\n$\\mathrm{RichReview}^{++}$. The aim of this tool is to texts, audios\nand gestures to mimic face-to-face communication experience for\ncollaborators reviewing and providing feedback on documents. It is\nalso extended to support peer discussion.\n\\bibliographystyle{apalike}\n\\bibliography{references}\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "21e38094548839fbf5e99f8f7fe6080169916eae", "size": 70200, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report.tex", "max_stars_repo_name": "siyuanzhao/Comp-Exam", "max_stars_repo_head_hexsha": "91dee9ae95237e0a0a38723c15b00a6eadafa9e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report.tex", "max_issues_repo_name": "siyuanzhao/Comp-Exam", "max_issues_repo_head_hexsha": "91dee9ae95237e0a0a38723c15b00a6eadafa9e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report.tex", "max_forks_repo_name": "siyuanzhao/Comp-Exam", "max_forks_repo_head_hexsha": "91dee9ae95237e0a0a38723c15b00a6eadafa9e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.3191489362, "max_line_length": 1052, "alphanum_fraction": 0.7657834758, "num_tokens": 18273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.40983812539548636}}
{"text": "\\section{Lexer and Parser}\nThe parser is implemented as a simple $LL(\\infty)$ parser using parser combinators so it may be quite slow on large inputs, but it's sufficient\nfor our purpose.\n\nOur AST for terms is defined as follows, for brevity, AST for other objects are not described here.\n\n\\begin{center}\n\\begin{minted}{haskell}\ntype Name = String\ntype Index = Int\n\ndata Term =\n    TmRel\n      Name       -- name of the variable, used for pretty printing\n      Index      -- 0 based DeBruijn index\n  | TmVar\n      Name       -- name of the variable\n  | TmAppl\n      [Term]     -- the first is the abstraction and the rest are the arguments\n  | TmProd\n      Name       -- name of the abstracted variable, used for pretty printing\n      Term       -- type of the abstracted variable\n      Term       -- body of the abstraction\n  | TmLambda\n      Name       -- name of the abstracted variable, used for pretty printing\n      Term       -- type of the abstracted variable\n      Term       -- body of the abstraction\n  | TmFix\n      Int        -- the index of the decreasing variable\n      Term       -- body of the fix definition\n  | TmLetIn\n      Name       -- name of the local binding variable\n      Term       -- type of the local binding\n      Term       -- body of the local binding\n      Term       -- let body, the binding will be added here\n  | TmIndType\n      Name       -- name of the inductive type constructor\n      [Term]     -- argument list\n  | TmConstr\n      Name       -- name of the term constructor\n      [Term]     -- argument list\n  | TmType\n  | TmTypeHigher\n  | TmMatch\n      Int        -- how many parameters does the inductive type need\n      Term       -- the term pattern matching on\n      Name       -- the name of the local binding of the term in the return type\n      [Name]     -- the matching name list for the return type\n      Term       -- return type\n      [Equation] -- equations, described below\n  deriving (Eq, Show)\n\ndata Equation =\n    Equation\n      [Name]     -- matching name list for the term constructor\n      Term       -- body of the equation\n    deriving (Eq, Show)\n\\end{minted}\n\\end{center}\n", "meta": {"hexsha": "4a5453eb734ea8c3e2d17dffb82dcc0bb9753e74", "size": 2137, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/report/parser.tex", "max_stars_repo_name": "lsrcz/mini-prover", "max_stars_repo_head_hexsha": "0aa4cdf3b495ddf6707f27dcbee810d519b43177", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2018-05-31T05:55:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T20:17:52.000Z", "max_issues_repo_path": "tex/report/parser.tex", "max_issues_repo_name": "lsrcz/mini-prover", "max_issues_repo_head_hexsha": "0aa4cdf3b495ddf6707f27dcbee810d519b43177", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/report/parser.tex", "max_forks_repo_name": "lsrcz/mini-prover", "max_forks_repo_head_hexsha": "0aa4cdf3b495ddf6707f27dcbee810d519b43177", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6166666667, "max_line_length": 143, "alphanum_fraction": 0.6265793168, "num_tokens": 531, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.40983812539548636}}
{"text": "\\documentclass[10pt]{article}\n\n\\usepackage[mode=buildnew,subpreambles=true]{standalone}\n\\input{preamble}\n\n\\title{\\bf Short summary}\n\\author{Yann-Edwin Keta}\n\\date{November 12th, 2019}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Model}\n\nWe consider an ensemble of $N$ spherical ABPs $i$, with positions $\\underline{r}_i$ and orientations $\\theta_i$, which are self-propelled along the direction $\\underline{u}_i \\equiv (\\cos(\\theta_i), \\sin(\\theta_i))$. We have the following dimensionless equations of motion \\cite{nemoto_optimizing_2019},\n\\begin{equation}\n\\begin{aligned}\n\\dot{\\underline{r}}_i(t) &= \\frac{1}{3} \\frac{\\sigma}{l_p} \\tilde{\\underline{F}}_{i, ex}(t) + \\underline{u}_i(t) + \\sqrt{\\frac{2}{3}\\frac{\\sigma}{l_p}} \\underline{\\eta}_i(t),\\\\\n\\dot{\\theta_i}(t) &= \\sqrt{2\\frac{\\sigma}{l_p}} \\xi_i(t),\n\\end{aligned}\n\\label{EOM}\n\\end{equation}\nwhere $\\tilde{\\underline{F}}_{i, ex}$ is the total force applied on particle $i$ deriving from a WCA potential, $l_p$ is the persistence length, $\\sigma$ is the particle diameter, and $\\underline{\\eta}_i \\equiv (\\eta_{x, i}, \\eta_{y, i})$ and $\\xi_i$ are independent Gaussian white noises of unit variance and zero mean.\\\\\n\nWe define the normalised rate of active work,\n\\begin{equation}\nw(t_0; \\tau) = \\frac{1}{N \\tau} \\, (S)\\int_{t_0}^{t_0 + \\tau} \\sum_{i=1}^{N} \\underline{u}_i(t) \\cdot \\text{d}\\underline{r}_i(t) = \\frac{1}{2 N \\tau \\, \\Delta t} \\sum_{t=0}^{\\tau - 1} \\sum_{i=1}^n \\left(\\underline{u}(\\theta_{i, t_0 + t + 1}) + \\underline{u}(\\theta_{i, t_0 + t})\\right) \\cdot \\left(\\underline{r}_{i, t_0 + t + 1} - \\underline{r}_{i, t_0 + t}\\right),\n\\end{equation}\nwhich we can write as a sum of three terms,\n\\begin{equation}\n\\begin{aligned}\nw_f(t_0; \\tau) &= \\frac{1}{2 N \\tau} \\sum_{t=0}^{\\tau - 1} \\sum_{i=1}^n \\left(\\underline{u}(\\theta_{i, t_0 + t + 1}) + \\underline{u}(\\theta_{i, t_0 + t})\\right) \\cdot \\frac{1}{3} \\frac{\\sigma}{l_p} \\tilde{\\underline{F}}_{i, ex, t_0 + t},\\\\\nw_{\\theta}(t_0; \\tau) &= \\frac{1}{2}\\left(1 + \\frac{1}{N\\tau} \\sum_{t=0}^{\\tau - 1} \\sum_{i=1}^N \\cos(\\theta_{i,t_0 + t  + 1} - \\theta_{i,t_0 + t})\\right),\\\\\nw_{\\eta}(t_0; \\tau) &= \\frac{1}{2N \\tau} \\sum_{t=0}^{\\tau - 1} \\sum_{i=1}^N \\left(\\underline{u}(\\theta_{i,t_0 + t  + 1}) + \\underline{u}(\\theta_{i, t_0 + t})\\right) \\cdot \\sqrt{\\frac{2}{3} \\frac{\\sigma}{l_p} \\frac{1}{\\Delta t}} \\, \\underline{\\eta}_{i, t_0 + t + 1},\n\\end{aligned}\n\\end{equation}\nrespectively the \\textit{force}, \\textit{orientation}, and \\textit{noise} part of the active work.\\\\\n\nWe also define an order parameter,\n\\begin{equation}\n\\underline{\\nu}(t) = \\frac{1}{N} \\sum_{i=1}^N \\underline{u}(\\theta_i(t)),\n\\end{equation}\nwith mean and correlations \\footnote{Refer to appendix E of \\cite{nemoto_optimizing_2019} for the derivation of the order parameter norm dynamics which we use to infer the corresponding results of equation \\ref{meanVarOrder}.}\n\\begin{equation}\n\\begin{aligned}\n\\left<\\underline{\\nu}(t_0)\\right> &= 0,\\\\\n\\left<|\\underline{\\nu}(t_0)|\\right> &= \\frac{1}{\\sqrt{2N}},\\\\\n\\left<\\delta \\underline{\\nu}(t_0 + \\tau) \\cdot \\delta\\underline{\\nu}(t_0)\\right> &= \\frac{1}{N} \\exp\\left(-\\frac{\\sigma}{l_p}\\tau\\right),\\\\\n\\left<\\delta |\\underline{\\nu}|(t_0 + \\tau) \\, \\delta |\\underline{\\nu}|(t_0)\\right> &= \\frac{1}{4N} \\exp\\left(- 2\\frac{\\sigma}{l_p} \\tau\\right),\n\\end{aligned}\n\\label{meanVarOrder}\n\\end{equation}\nin the absence of symmetry breaking.\n\n\\section{One-particle quantities}\n\nWe check our algorithm and set benchmarks by considering the \\textit{free} or \\textit{single particle} case, $\\tilde{\\underline{F}}_{i, ex} = 0$.\\\\\n\nWe can analytically derive the mean squared displacement,\n\\begin{equation}\n\\left<(\\underline{r}(t_0 + \\Delta t) - \\underline{r}(t_0))^2\\right> = \\frac{l_p}{\\sigma}\\left(\\Delta t + \\frac{l_p}{\\sigma}\\left(\\exp\\left(-\\frac{\\sigma}{l_p} \\Delta t\\right) - 1\\right)\\right) + \\frac{4}{3} \\frac{\\sigma}{l_p} \\Delta t.\n\\end{equation}\nand the active work mean and correlations\n\\begin{equation}\n\\begin{aligned}\n\\left<w(t_0; \\tau)\\right> &= 1,\\\\\n\\forall \\tau \\geq \\tau_0,~ \\left<\\delta w(t_0; \\tau_0) \\delta w(t_0; \\tau)\\right> &= \\frac{2}{3} \\frac{\\sigma}{l_p} \\frac{1}{\\tau},\\\\\n\\forall \\tau \\geq \\tau_0,~ \\left<\\delta w(t_0; \\tau_0) \\delta w(t_0 + \\tau; \\tau_0)\\right> &= 0.\n\\end{aligned}\n\\end{equation}\nThese theoretical predictions match the numerical results.\n\n\\section{Active work covariances}\n\nWe argue that\n\\begin{equation}\n\\left<\\delta w(t_0; \\tau_0) \\delta w(t_0 + \\tau; \\tau_0)\\right> \\approx \\left<\\delta w_f(t_0; \\tau_0) \\delta w_f(t_0 + \\tau; \\tau_0)\\right> + \\left<\\delta w_{\\eta}(t_0; \\tau_0) \\delta w_f(t_0 + \\tau; \\tau_0)\\right>,\n\\end{equation}\nsince that the fluctuations of the orientation part of the active work are negligible for low integration time steps, and that the orientational and translational noises are independent.\\\\\n\nWe plot the covariances between the different part of the active work with a delay $\\tau$ in figure \\ref{crossCor}.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{crossCor_Nm2000_Dk6500_En1000.eps}\n\\caption{Covariances of active work parts with a delay $\\tau$, for $l_p/\\sigma = 20$ (dashed lines) and $l_p/\\sigma = 100$ (dash-dotted lines). All available intervals but those overlapping with $t_0 \\leq 3 l_p/\\sigma$ were used to compute the means. These curves are qualitatively independent of the choice of $\\tau_0$, this particular choice is a balance between noise reduction and low time resolution. Purple curves correpond to the total active work covariance.}\n\\label{crossCor}\n\\end{figure}\n\nWe observe that\n\\begin{itemize}\n  \\item the covariance of the force part of the active work and itself with a delay $\\tau$ is a positive, monotonically decreasing function of $\\tau$, with a length scale which increases with persistence length,\n  \\item the covariance of the noise part of the active work and the force part with a delay $\\tau$ is a negative, monotonically increasing function of $\\tau$, with a length scale which is qualitatively independent of the persistence length,\n  \\item the covariance of the active work and itself with a delay $\\tau$ is a non-monotonic function of $\\tau$, with a peak at $\\tau \\approx 10^{-1}$.\n\\end{itemize}\n\n\\subsection{Covariance of noise and force part}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{crossCorNoiseForce_No1000_Dk6500_Em2000.eps}\n\\caption{Covariance of the noise part of the active workand the force part with a delay $\\tau$.}\n\\label{crossCorNoiseForce}\n\\end{figure}\n\nWe have that for the few values of persistence length tested, $2 \\leq l_p/\\sigma \\leq 20$, the time scale of decrease of the absolute value of $\\left<\\delta w_{\\eta}(t_0; \\tau_0) \\delta w_f(t_0 + \\tau; \\tau_0)\\right>$ is qualitatively independent of the persistence length (figure \\ref{crossCorNoiseForce}).\\\\\n\nWe argue that this time scale is set by the interaction potential. Consider a single particle in a harmonic potential\n\\begin{align*}\nV(\\underline{r}(t)) = \\frac{1}{2} k \\underline{r}(t)^2.\n\\end{align*}\nMotivated by figures \\ref{crossCor} and \\ref{crossCorNoiseForce}, we assume that $l_p/\\sigma \\gg \\tau_d$, where $\\tau_d$ is the relevant time scale of decrease, \\ie we can consider that the orientation of the particle is constant. We then have the following equation of motion\n\\begin{equation}\n\\dot{\\underline{r}}(t) = - \\frac{1}{3} \\frac{\\sigma}{l_p} \\nabla V(\\underline{r}(t)) + \\underline{u}_0 + \\sqrt{\\frac{2}{3} \\frac{\\sigma}{l_p}} \\underline{\\eta}(t).\n\\end{equation}\nWe can write\n\\begin{align*}\n\\text{d}\\left<\\left(\\underline{\\eta}_i(t_0) \\cdot \\underline{u}_0\\right) \\, \\left(\\nabla V(\\underline{r}(t_0 + t)) \\cdot \\underline{u}_0\\right)\\right> &= \\left<\\left(\\underline{\\eta}_i(t_0) \\cdot \\underline{u}_0\\right) \\, \\left(\\underbrace{\\nabla^2 V(\\underline{r}(t_0 + t))}_{k} \\,\\text{d}\\underline{r}(t_0 + t) \\cdot \\underline{u}_0\\right)\\right>\\\\\n&= - k \\frac{1}{3} \\frac{\\sigma}{l_p} \\left<\\left(\\underline{\\eta}_i(t_0) \\cdot \\underline{u}_0\\right) \\, \\left(\\nabla V(\\underline{r}(t_0 + t)) \\cdot \\underline{u}_0\\right)\\right> \\, \\text{d}t,\n\\end{align*}\nsuch that\n\\begin{equation}\n\\left<\\left(\\underline{\\eta}_i(t_0) \\cdot \\underline{u}_0\\right) \\, \\left(\\nabla V(\\underline{r}(t_0 + \\tau)) \\cdot \\underline{u}_0\\right)\\right> \\propto \\exp\\left(- k \\frac{1}{3} \\frac{\\sigma}{l_p} \\tau\\right).\n\\end{equation}\n\n\\subsection{Covariance of force part and itself}\n\nAccording to figure \\ref{crossCorForceLP}, we have that $\\left<\\delta w_f(t_0; \\tau_0) \\delta w_f(t_0 + \\tau; \\tau_0)\\right>$\n\\begin{itemize}\n  \\item decays algebraically at low persistence length $l_p/\\sigma = 2$,\n  \\item decays logarithmically at high persistence length $l_p/\\sigma = 20$.\n\\end{itemize}\nWe show the buildup of this covariance with increasing persistence length in figure \\ref{crossCorForceN}.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.49\\textwidth]{crossCorForceForce_Dk6500_Ll2000_Em2000.eps}\n\\hfill\n\\includegraphics[width=0.49\\textwidth]{crossCorForceForce_Dk6500_Lm2000_Em2000.eps}\n\\caption{Covariance of the force part of the active work and itself with a delay $\\tau$ for $l_p/\\sigma = 2$ (left) and $l_p/\\sigma = 20$ (right).}\n\\label{crossCorForceLP}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{crossCorForceForce_No1000_Dk6500_Em2000.eps}\n\\caption{Covariance of the force part of the active work and itself with a delay $\\tau$ for $2 \\leq l_p/\\sigma \\leq 20$ at $N=10^3$ particles.}\n\\label{crossCorForceN}\n\\end{figure}\n\nAccording to \\cite{tociu_how_2018}, the mean force part of the normalised rate of active work in steady state is linked to the structure of the liquid,\n\\begin{equation}\n\\left<w_f\\right> = \\phi \\int g(\\underline{r}) \\left\\{[\\nabla V(\\underline{r})]^2 - \\frac{2}{3}\\frac{\\sigma}{l_p} \\nabla^2 V(\\underline{r})\\right\\} \\, \\text{d}\\underline{r} + \\phi^2 \\iint g_3(\\underline{r}, \\underline{r}^{\\prime}) \\nabla V(\\underline{r}) \\cdot \\nabla V(\\underline{r}^{\\prime}) \\, \\text{d}\\underline{r} \\, \\text{d}\\underline{r}^{\\prime},\n\\end{equation}\nwhere $g$ and $g_3$ are the two- and three-body density correlations among particles.\\\\\n\nMaybe then is the decay of $\\left<\\delta w_f(t_0; \\tau_0) \\delta w_f(t_0 + \\tau; \\tau_0)\\right>$ linked to the relaxation of the structure. We have that at $l_p/\\sigma = 2$ the system resembles an homogeneous liquid, while at $l_p/\\sigma = 20$ denser regions -- clusters -- appear (figure \\ref{screenshots}). Moreover, clusters are expected to get denser as the persistence length increases, and particles move more slowly in denser regions \\cite{cates_motility-induced_2015}. We can thus imagine that the buildup of the covariance of the force part of the active work and itself with a delay $\\tau$ is directly linked to this changing dynamical picture with increasing persistence length. Such a link remains to be demonstrated.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.49\\textwidth]{o_Nm2000_Dk6500_Ll2000.eps}\n\\hfill\n\\includegraphics[width=0.49\\textwidth]{o_Nm2000_Dk6500_Lm2000.eps}\n\\caption{Screenshots of the system for $l_p/\\sigma = 2$ (left) and $l_p/\\sigma = 20$ (right). Colors refer to the orientation of the particles.}\n\\label{screenshots}\n\\end{figure}\n\n\\section{Order and active work}\n\nWe compute the correlation function between the flucutations of the order parameter norm at time $t_0$ and the flucutations of the normalised rate of active work on the interval $[t_0; t_0 + \\tau]$ (figure \\ref{Cawo}),\n\\begin{equation}\nC^{(a)}_{wo}(\\tau) = \\frac{\\left<\\delta w(t_0; \\tau) \\, \\delta |\\underline{\\nu}(t_0)|\\right>}{\\sqrt{\\left<\\delta w(t_0; \\tau)^2\\right> \\, \\left<\\delta |\\underline{\\nu}(t_0)|^2\\right>}}.\n\\label{eqCawo}\n\\end{equation}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.7\\textwidth]{corWorkOrderAve_Nm2000_Dk6500_Em1000.eps}\n\\caption{Correlation function between the flucutations of the order parameter norm at time $t_0$ and the flucutations of the normalised rate of active work on the interval $[t_0; t_0 + \\tau]$.}\n\\label{Cawo}\n\\end{figure}\n\nFirst of all, we note that this correlation function is non-monontic. This can rationalised by the fact that the variance of the active work,\n\\begin{align*}\n\\tau \\mapsto \\left<\\delta w(t_0; \\tau)^2\\right>,\n\\end{align*}\nis a monotonically decreasing function of $\\tau$.\\\\\n\nWe have that the fluctuations of the normalised rate of active work $w$ over an interval $[t_0; t_0 + \\tau]$ are positively correlated with fluctuations of the order parameter $|\\underline{\\nu}|$ at the beginning of this interval. This may indicate that positive fluctuations of the order parameter norm at a given time leads to an increased active work at following times. This can be explained by the fact that nematically ordered particles -- \\ie high $|\\underline{\\nu}|$ -- have fewer collisions, so that active forces translates more efficiently into particle motion \\cite{nemoto_optimizing_2019}.\\\\\n\nWe also note that these correlations decay on a length scale larger than the rotational diffusion time -- the dashed black line is here for illustration purposes and does not reflect any theoretical predicition. Furthermore, we have that the correlations between the averaged active work and the order parameter norm are higher for $l_p/\\sigma=100$ than for $l_p/\\sigma = 20$ -- this may however be due, in part or completely, to the fact that the variance of the active work is higher in the latter.\\\\\n\nWe also compute the covariance of the order parameter norm and the normalised rate of active work with a delay $\\tau$ (figure \\ref{covWorkOrder}),\n\\begin{equation}\n\\tau \\mapsto \\left<\\delta |\\underline{\\nu}(t_0)| \\delta w(t_0 + \\tau; \\tau_0)\\right>,\n\\end{equation}\nwhich is linked to the numerator in equation \\ref{eqCawo} by summation over the interval $[t_0; t_0 + \\tau]$.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.49\\textwidth]{corWorkOrderIns_Nm2000_Dk6500_Lm2000_Em1000_Ip5000.eps}\n\\hfill\n\\includegraphics[width=0.49\\textwidth]{corWorkOrderIns_Nm2000_Dk6500_Ln1000_Em1000_Ip5000.eps}\n\\caption{Covariance of the order parameter norm and the normalised rate of active work with a delay $\\tau$ for $l_p/\\sigma = 20$ (left) and $l_p/\\sigma = 100$ (right).}\n\\label{covWorkOrder}\n\\end{figure}\n\nWe have a monotonic decrease of this covariance with a length scale $\\sim \\frac{1}{2} \\frac{l_p}{\\sigma}$ for both tested values of the persistence length.\n\n%%%%%%%%%%%%%%\n% REFERENCES %\n%%%%%%%%%%%%%%\n\n\\bibliographystyle{unsrtnat}\n{\\renewcommand{\\bibname}{References}\\bibliography{ref}}\n\n\\end{document}\n", "meta": {"hexsha": "3cd856731c7a8c2e63aa205c68656ea4a0de9db2", "size": 14444, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Summaries/summary_19_11/main.tex", "max_stars_repo_name": "yketa/DAMTP_2019_Wiki", "max_stars_repo_head_hexsha": "9995202a586d5f301f2bdffe868b1fcec6fbb990", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Summaries/summary_19_11/main.tex", "max_issues_repo_name": "yketa/DAMTP_2019_Wiki", "max_issues_repo_head_hexsha": "9995202a586d5f301f2bdffe868b1fcec6fbb990", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Summaries/summary_19_11/main.tex", "max_forks_repo_name": "yketa/DAMTP_2019_Wiki", "max_forks_repo_head_hexsha": "9995202a586d5f301f2bdffe868b1fcec6fbb990", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.9543378995, "max_line_length": 729, "alphanum_fraction": 0.7205760177, "num_tokens": 4783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4098381170512219}}
{"text": "\\chapter{Conclusion}\\label{chap:Conclusion}\nIn this thesis, we investigated the Asymptotic Safety scenario for quantum gravity and studied its phase diagram within the Einstein-Hilbert truncation in a background field approximation. We used non-perturbative Functional Renormalization Group techniques to compute the running of Newton's constant $g_k$ and of the cosmological constant $\\lambda_k$.  \\\\\n\nIn chapters 1 to 3 we introduced the background knowledge, needed for a general understanding of the conducted calculations. After briefly discussing the general idea of the Asymptotic Safety conjecture, in chapter \\ref{chap:EHT} we solved the flow equation for a pure-gravity system in a transverse-traceless spin-two graviton approximation to get a first insight into the underlying structures of the theory setting. The mathematical tools we used to solve the flow equation, such as the York decomposition of the fluctuation field and the heat-kernel techniques to compute the functional traces, were introduced very detailed. We computed the $\\beta$-functions for $g_k$ and $\\lambda_k$ and determined the fixed points of the flow. Besides the non-interacting Gaussian fixed point at $(g_k, \\lambda_k)=(0, 0)$ we found an UV-attractive fixed point at $(g_k, \\lambda_k)=(0.86, 0.18)$, providing further evidence for the Asymptotic Safety scenario as a promising candidate for a non-perturbative renormalizable quantum field theory of gravity. In chapter \\ref{chap:Matter} we extended our truncation: First of all, the previously neglected trace mode and the Faddeev-Popov ghosts associated with the graviton sector were included to complete the calculation from chapter \\ref{chap:EHT}. Then we investigated the impact of minimally coupled scalars, fermions and gauge fields on the Non-Gaussian fixed point. We explained in full detail how to solve the functional traces for all three matter types separately and presented the most important and insightful steps. After finishing the computation of all contributions, we were able to determine the $\\beta$-functions for $g_k$ and $\\lambda_k$ as a function of the number of matter fields. Neglecting all the contributions from the different anomalous dimensions and expanding the $\\beta$-functions in some neighborhood of the Gaussian fixed point up to second order in the couplings, we qualitatively analyzed the behavior of the values for both couplings. We found out, that for an increasing amount of scalar fields, the values of the couplings tend to increase drastically. The fermionic fields and especially the gauge fields seem to have a stabilizing effect on the system. These results are almost in agreement with the results from earlier investigations, where similar conventions have been chosen, see e.\\,g \\cite{DonaEichhornPercacci2013}.\nAt the end, in chapter \\ref{chap:BGindependence}, we highlighted some problems associated with the background field approximation, e.\\,g. the loss of background independence as a consequence of violating the Nielsen identities. \\\\\n\nThis work may not provide fundamentally new results, but it still demonstrates some of the central concepts and calculations related to the subject. Due to the fact, that we worked in a rather simple truncation and chose a Litim-type cutoff, we we able to solve all the problems in this thesis analytically. Interesting modifications of our setup could include the employment of more sophisticated regulators or the inclusion of higher-order curvature terms. Compared to more recent results, the outcomes of our calculations should be treated with care. Nevertheless, this thesis provides a suitable framework for further investigations of asymptotically safe quantum gravity. Based on our discussion in chapter \\ref{chap:BGindependence}, one may consider abandoning the background field approximation in future projects. ", "meta": {"hexsha": "a9a5c03bd4242d6bc3e1c8a5f821bd8247772f18", "size": 3857, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/content/07_conclusion.tex", "max_stars_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_stars_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-22T15:05:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-22T15:05:57.000Z", "max_issues_repo_path": "Thesis/content/07_conclusion.tex", "max_issues_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_issues_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/content/07_conclusion.tex", "max_forks_repo_name": "mathieukaltschmidt/BSc-Thesis", "max_forks_repo_head_hexsha": "d930ee60ab526835c904252e68272408f3d6a16f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-25T05:06:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-25T05:06:03.000Z", "avg_line_length": 551.0, "max_line_length": 2399, "alphanum_fraction": 0.8177339901, "num_tokens": 789, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.40983811705122186}}
{"text": "\\documentclass{article}\n\\usepackage{latexsym}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\setlength{\\bigskipamount}{8em}\n\\setlength{\\parindent}{3em}\n\\setlength{\\parskip}{1em}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{question}{Q.}\n\n\\begin{document}\n\\author{Dave Neary}\n\\title{Fundamental Theorem of Algebra}\n\n\\maketitle\n\n\\section{Introduction}\n\nWe will talk about some of the number systems you will come across, and work\nup to the Fundamental Theorem of Arithmetic: that positive whole numbers have\na unique representation as the product of prime numbers.\n\n\\section{Number systems}\n\nThere are several number systems that we will come across in number theory.\nYou might say that mathematics is a journey, inventing new number systems\nand abstractions to allow us to solve new types of problems we could not\nwith the tools available before.\n\nWe start with the natural numbers $\\mathbb{N} = \\{1,2,3,\\cdots\\}$, or the\nnatural numbers including 0 $\\mathbb{N}_0 = \\{0,1,2,\\cdots\\}$ - this\nis the foundation of mathematics, counting objects. The natural numbers are\nclosed under the operations addition and multiplication, but not under\nsubtraction. In general, we cannot find $a-b \\in \\mathbb{N}$ for $a,b \\in\n\\mathbb{N}$.\n\nTo enable closure under subtraction, we can extend the natural numbers to\ninclude negative numbers to produce the integers\n\\[\\mathbb{Z} = \\{\\cdots,-3,-2,-1,0,1,2,3,\\cdots\\}\\] This number system is\nclosed under addition, multiplication, \\textbf{and} subtraction, but still\nhas a limitation under division. When we try to divide a whole number into\nparts, we cannot do this in the integers.\n\nTo enable closure under division, we can extend the integers to include the\nrational numbers - fractions: \\[\\mathbb{Q} = \\{\\frac{a}{b} | a,b\\in \\mathbb{Z},\nb \\neq 0 \\}\\]\n\nFinally, for now, we can extend the rational numbers to include numbers which\ncannot be represented by a fraction, but which can be measured on the number\nline, to the real numbers $\\mathbb{R}$, which are essentially the rational\nnumbers with the gaps filled in. We call a number which is in the real numbers,\nbut is not a rational number, an irrational number.\n\nThe irrational numbers can also be subdivided into two groups. The algebraic\nnumbers are a superset of the rational numbers which includes all \nexact solutions of polynomial equations with rational coefficients. This group\nincludes all the square roots, cube roots, and in general the $n$th roots,\nand any combination of them (for example, $\\sqrt[3]{7+\\sqrt{13}}$ is an\nalgebraic number).\n\nAny number which is not the solution to any such polynomial is called a\ntranscendental number. Well known numbers like $\\pi$ and $e$ are transcendental\nnumbers.\n\nFor now, we will focus mostly on the characteristics of the natural numbers and\nthe integers. There will be plento of opportunity in the future to get into the\nother number systems - and to discover others!\n\n\\section{The Fundamental Theorem of Arithmetic}\n\nNatural numbers can be grouped into different subsets. For example, we learn\nearly in school that the numbers 2,4,6,8,... are special - they are all whole\nnumber multiples  of 2, and we call them the even numbers. If a number is not even,\nit is odd.\n\nThere is nothing special about 2 though - we can find the set of nultiples of 3, and\ncan even define it in general as $S = \\{3,6,9,\\cdots\\} = \\{ 3n | n \\in \\mathbb{N}\\}$\n- that is, the set contains all of the numbers which can be expressed as $3k$ for some\n$k\\in \\mathbb{N}$. We will often use this type of set definition short-hand.\n\nEvery natural number has natural number divisors. Some numbers can only be divided in\nnatural numbers by themselves and 1. We call these numbers \\textbf{prime numbers}. The\nfirst few prime numbers are 2, 3, 5, 7, 11, 13, 17. A natural number which is not a\nprime number is called a composite number, which means that we can write the number\n$n = a \\cdot b$ for $a,b > 1 \\in \\mathbb{N}$. 4, 6, 8, 9 are the first composite numbers.\n\nThe number 1 is special - it is neither prime nor composite, by convention (which\nmeans, it's just useful to think of it as being neither - people have fought about\nthat stuff in the past). Next, we will bring these threads together to state the\nFundamental Theorem of Algebra. It is very powerful, and almost completely obvious.\n\n\\begin{theorem}[The Fundamental Theorem of Arithmetic]\n\nEvery number $n \\in \\mathbb{N}$ can be expressed as a \\textbf{unique}\nproduct of primes. We can write $n = p_1^{\\alpha_1}p_2^{\\alpha_2}\\cdots p_k^{\\alpha_k}$\nfor some set of primes $\\{p_i\\}$ and exponents $\\{\\alpha_i\\} \\in \\mathbb{N}$.\n\\end{theorem}\n\nStarting from just this theorem, we can already prove some nice results.\n\n\\subsection{Problems}\n\n\\begin{question}Prove that $\\sqrt{5}$ is irrational.\\end{question}\n\n\\emph{Proof:} We will use proof by contradiction. Assume that $\\sqrt{5}$ is rational,\nthat is, that there exist $a,b\\in \\mathbb{N}$ such that $\\gcd(a,b)=1$ and \n$\\sqrt{5}=\\frac{a}{b}$.\n\nThen since:\n\\[ 5 = \\frac{a^2}{b^2} \\implies a^2=5b^2 \\]\nWe know that $5 | a^2$ and therefore $5|a$ (since if there is a 5 in the prime\ndecomposition of $a^2$ there must also be a 5 in the prime decomposition of $a$).\n\nSo we can write $a=5m$ and $25m^2 = 5b^2 \\implies 5m^2 = b^2$ - and by repeating the\nsame logic, we can show that $5 | b$. But if 5 divides both $a$ and $b$, then\n$\\gcd(a,b) = 5k$ for some $k \\in \\mathbb{N}$, which is a contradiction with our\ninitial assumption that $\\gcd(a,b)=1$ - so our original assumption, that $\\sqrt{5}$\nis rational, must be false. \n$\\square$\n\n\\begin{question}How many positive integer divisors does 36 have?\\end{question}\n\n$36 = 2^2 \\cdot 3^2$, so every factor of 36 will have the form \n$2^{\\alpha}\\cdot 3^{\\beta}$ with $\\alpha \\in \\{0,1,2\\}$ and $\\beta \\in \\{0,1,2\\}$.\n\nWe can find all of the factors of 36 by combining the possible values of $\\alpha$\nand $\\beta$ in all possible combinations, so the total number of factors of 36 is \n$3 \\times 3 = 9$, since we have 3 choices for $\\alpha$ and 3 choices for $\\beta$.\n\n\n\\begin{question} $n! = n\\cdot (n-1)\\cdot (n-2) \\cdots 2 \\cdot 1$ (called $n$\nfactorial). How many trailing zeros are there in $25!$?\\end{question}\n\\vspace*{\\bigskipamount}\n\n\\begin{question}How many positive integer factors does 720 have?\\end{question}\n\\vspace*{\\bigskipamount}\n\n\\begin{question}Write all the factors of $7^{21}$ and compute their sum.\\end{question}\n\\vspace*{\\bigskipamount}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "bad25392ebc11b9dd1daaa517fe753a25444831a", "size": 6430, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fundamental_theorem_arithmetic.tex", "max_stars_repo_name": "dneary/math", "max_stars_repo_head_hexsha": "129b2093c01b12ddc2e61abd331c95da2177803c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "fundamental_theorem_arithmetic.tex", "max_issues_repo_name": "dneary/math", "max_issues_repo_head_hexsha": "129b2093c01b12ddc2e61abd331c95da2177803c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fundamental_theorem_arithmetic.tex", "max_forks_repo_name": "dneary/math", "max_forks_repo_head_hexsha": "129b2093c01b12ddc2e61abd331c95da2177803c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0410958904, "max_line_length": 89, "alphanum_fraction": 0.7391912908, "num_tokens": 1832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.40983811705122186}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n%\\usepackage{cite}\n%\\usepackage{wrapfig}\n%\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\n\n\\title{Lecture 8: Atmospheric Stability}\n\\author{}\n\n\\begin{document}\n\\maketitle\n\\section*{Overview}\n\nWe determine the variation of density, pressure, and temperature with height in the Earth's atmosphere. Using the temperature gradient, we can classify the atmosphere as stable or unstable to vertical motions. \n\n\\section{Pressure variation}\nDue to gravity, we expect the density of air to decrease as we go higher up in the atmosphere. We want to determine the characterstic height at which density or pressure fall to $1/e$ of their surface values. Assuming the atmosphere to be thin (height of atmosphere $\\ll$ diamter of the Earth) and temperature to be constant through the domain, we can write\n\\begin{align*}\n\\frac{dp}{dz} = \\rho_a (-g)\n\\end{align*}\n\nwhere $p$ is the pressure, $z$ is the vertical height measured from ground and $\\rho_a$ is density of the air. Using the ideal gas equation of state $p=\\rho_a \\hat{R}_a T$, we get\n\\begin{align*}\n\\frac{dp}{dz} &= \\frac{p(-g)}{\\hat{R}_a T} \\\\\n\\Rightarrow p &= p_0 e^{-gz/\\hat{R}_a T}\n\\end{align*}\n\nThis gives the pressure variation with height. The characterstic length scale for this variation is $\\frac{\\hat{R}_a T}{g}$. Note that $\\hat{R}_a$ is defined per unit mass. Taking $T=300K$, we get the characterstic height as $\\sim 8.4$ km . Therefore, pressure and density drop to $1/e$ of their surface value at about 8.4 km above Earth's surfce.\n\n\\section{Temperature variation}\nPressure and density decrease exponentially under these assumptions. Even if these are relaxed, their variation is at least monotonic. But temperature varation is not monotonic throughout the atmosphere. We can though, derive an expression for the temperature variation in the Troposphere. In order to derive the temperature variation, we will consider a Lapse-Rate Atmosphere. A Lapse-Rate Atmosphere is a hypothetical neutral object that seperates stable and unstable atmosphere. \n\nStability of the atmosphere, in this context, refers to its susceptibility to vertical motions. Basically, we want to know the fate of a (vertically) displaced parcel of fluid. If a parcel displaced upwards experiences buoyancy and continues to go upwards, then the atmosphere is unstable. If it falls back, then the atmosphere is stable. Lapse-Rate Atmosphere is the hypothetical neutral configuration between the two.\n\nOur objective is to calculate the temperature gradient of the Lapse-Rate Atmosphere or, in other words, the rate of change of temperature of a parcel of air when it is vertically displaced in a Lapse-Rate Atmosphere. Note that a neutrally stable atmosphere does not have a uniform temperature throughout because of the pressure variation. \n\\subsection{Dry Adiabatic Lapse Rate}\nWe assume the process of the parcel rising through the atmosphere to be reversible and adiabatic. Then using the first law of thermodynamics, with $\\delta q=0$, we get\n\\begin{align*}\nde = -\\delta W = -p dV\n\\end{align*}\n\nThis tells us that work is done at the expense of internal energy. For ideal gas, $e\\equiv e(T)$. Therefore, as a parcel rises and moves into a lower pressure region, it expands and does work. This work causes reduction in the internal energy and hence temperature drops as the parcel rises up. Further assuming air to be calorically perfect ($C_p$ and $C_v$ are independent of T), and using the adiabatic expansion relation $p \\propto \\rho^{\\gamma}$ gives us the result\n\\begin{align*}\n\\frac{dT}{dz} = \\frac{-g}{C_p}\n\\end{align*}\n\nThis comes out to be nearly $10 K/Km$. Hence temperature of the parcel falls by about $10K$ for each $1 Km$ rise in height. This is called the Dry Adiabatic Lapse Rate (DALR). Dry - because we haven't yet considered the effect of water vapour present in the air parcel. \n\n\\subsection{Moist Adiabatic Lapse Rate}\n\nIn order to incorporate the effect of vapour, note that the parcel is rising into a region of lower pressure and temperature. Water tends to evaporate at low pressure and condense at low temperature. If it so happens that the fall in temperature overcompensates the effect of fall in pressure, then water will condense. This condensation will cause the release of latent heat of vaporization which will heat the air parcel. Therefore, the net cooling of the air parcel will be less than $10K/Km$ (usually varies between $4 - 9 K/Km$). This is called the Moist Adiabatic Lapse Rate (MALR). Once all the water inside the parcel condenses, the rate of cooling again approaches DALR.\n\nIn order to derive an expression for it, we proceed as for the DALR, but now $\\delta q \\neq 0$. The parcel is getting heated due to the latent heat and therefore, $\\delta q = -L dW_v$. Here $dW_v$ is the mass of water-vapour per unit mass of air and $L$ is the latent heat of water per unit mass. The negative sign denotes that it is decreasing with height. With this modification, we get the MALR as\n\\begin{align*}\n\\frac{dT}{dz} &= \\frac{-g/C_p}{1+\\frac{L}{C_v}\\frac{dW_v}{dT}}\\\\\n\\end{align*}\n\nThis expression differs from the DALR only if $\\frac{dW_v}{dT}$ is non-zero i.e. after the parcel becomes saturated and there is condensation. If $dT$ is more, then parcel can hold more vapour and hence $\\frac{dW_v}{dT} > 0$. Therefore,\n\\begin{align*}\n|MALR| &<|DALR|\n\\end{align*}\n\nAs parcel rises, the partial pressure of water vapour\\footnote{Fraction of total pressure that is being exerted by the vapour molecules} decreases. Also the temperature, and hence the vapour pressure\\footnote{Pressure required to condense the vapour molecules at a given temperature} decreases. But the vapour pressure decreases faster than the partial pressure and the parcel invariably becomes saturated.\n\n\\section{Atmospheric stability}\n\nWe know that the cooling rate of an unsaturated parcel is DALR. If the atmospheric cooling rate is faster than this, then a raised parcel will find itself in a cooler environment and will continue to rise. Therefore if atmospheric cooling rate is faster than DALR, then it's unstable. Similarly we can see that if the atmospheric cooling rate is slower than DALR then it's stable and atmosphere is neutral if they are equal.\n\n\\subsection{Conditional Stability}\n\nSuppose the cooling rate of atmosphere is slower than DALR but more than MALR. Since it is slower than DALR, the atmosphere appears to be stable (as discussed before). But if due to some mechanism, an air parcel gets kicked high enough so that it becomes satured and the vapour inside it begins to condense, then the effective cooling rate becomes MALR. Now, the cooling rate of the parcel is slower than cooling rate of atmosphere. So an upward displaced parcel will find itself in a warmer environment and will continue to rise.\n\n\\section{Appendix}\n\\subsection{Derivation for DALR}\n\\subsection{Derivation for MALR}\n\\subsection{Equation of state for water vapour}\nStarting with the Gibbs-Duhem equation applied at the phase boundary between water and water vapour\n\\begin{align*}\n&(\\nu dp - s dT) = d\\mu \\\\\n\\Rightarrow &(\\nu dp - s dT)_l = (\\nu dp - s dT)_g \\\\\n\\Rightarrow &\\frac{dP_{v}}{dT} = \\frac{s_v - s_l}{\\nu_v} \\quad \\quad \\quad \\text{\\footnotesize{$(\\nu_l \\ll \\nu_v)$}} \\\\\n\\Rightarrow &\\frac{dP_{v}}{dT} = \\frac{T(s_v - s_l)}{T \\nu_v} \\\\\n\\Rightarrow &\\frac{dP_{v}}{dT} = \\frac{L \\rho_v}{T} \\quad \\quad (T\\Delta s = L, 1/nu_v = \\rho_v) \\\\\n\\end{align*}\nUsing ideal gas equation, \n\\begin{align*}\n\\Rightarrow &\\frac{dP_{v}}{dT} = -\\frac{L p_v}{\\hat{R}_v T}\n\\end{align*}\nwhich finally gives,\n\\begin{align*}\np_v(T) = A e^{\\frac{-L}{\\hat{R}_v T}}\n\\end{align*}\n\nThis is the equation of state for water vapour.\n\n\\subsection{Layers of the atmosphere}\n\\begin{itemize}\n\\item Troposphere - upto $\\sim$ 12 km\n\\item Stratosphere - (15 - 50 Km)\n\\item Mesosphere - (50 - 80 Km)\n\\item Thermosphere - (80 - 700 Km)\n\\item Exosphere - 700 Km and upwards\n\\end{itemize}\n\n\n\\end{document}\n", "meta": {"hexsha": "dae69456d1dfba0824d07329b04ea1460510c6a6", "size": 8070, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex_files/lecture09.tex", "max_stars_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_stars_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-16T04:19:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-16T04:19:07.000Z", "max_issues_repo_path": "tex_files/lecture09.tex", "max_issues_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_issues_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex_files/lecture09.tex", "max_forks_repo_name": "pulkitkd/Fluid_Dynamics_notes", "max_forks_repo_head_hexsha": "f4ffd25fa16fa08c2c2a5d465bb8a19a1d02d850", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.7027027027, "max_line_length": 679, "alphanum_fraction": 0.7623296159, "num_tokens": 2122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.40983810870695725}}
{"text": "%-----------------------------------------------------------------------------\n%\n%               Template for sigplanconf LaTeX Class\n%\n% Name:         sigplanconf-template.tex\n%\n% Purpose:      A template for sigplanconf.cls, which is a LaTeX 2e class\n%               file for SIGPLAN conference proceedings.\n%\n% Guide:        Refer to \"Author's Guide to the ACM SIGPLAN Class,\"\n%               sigplanconf-guide.pdf\n%\n% Author:       Paul C. Anagnostopoulos\n%               Windfall Software\n%               978 371-2316\n%               paul@windfall.com\n%\n% Created:      15 February 2005\n%\n%-----------------------------------------------------------------------------\n\n\n\\documentclass[preprint]{sigplanconf}\n\n% The following \\documentclass options may be useful:\n\n% preprint      Remove this option only once the paper is in final form.\n% 10pt          To set in 10-point type instead of 9-point.\n% 11pt          To set in 11-point type instead of 9-point.\n% numbers       To obtain numeric citation style instead of author/year.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\usepackage{amsmath,amsfonts}\n\\usepackage{hyperref}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\usepackage{amsthm}\n\\makeatletter\n\\def\\th@definition{%\n  \\thm@notefont{}% same as heading font\n  \\normalfont % body font\n}\n\\makeatother\n\\theoremstyle{definition}\n\\newtheorem{problem}{Problem}\n\\newtheorem{defn}{Definition}\n\\newtheorem{note}{Note}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\usepackage{courier}\n%\\usepackage{pxfonts}\n\\usepackage{listings}\n\\lstset{\n    %language=Haskell,\n    basicstyle=\\ttfamily\\footnotesize,\n    keywordstyle=\\bfseries\\ttfamily\\footnotesize,\n    showstringspaces=false,\n    %morekeywords={class,data,type,family,instance, where, ghci},\n    morekeywords={ghci},\n    %basicstyle=\\footnotesize,\n    literate={->}{{$\\rightarrow$}}2 {>=}{{$\\geq$}}2 {<-}{{$\\leftarrow$}}2\n             {<=}{{$\\leq$}}2 {=>}{{$\\Rightarrow$}}2\n             {~}{\\tiny{$\\sim$}}1\n    %keywordstyle=\\lst@ifdisplaystyle\\color{blue}\\fi,\n    %commentstyle=\\color{gray}\n}\n\\lstMakeShortInline|\n\n\\newcommand{\\cL}{{\\cal L}}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\newcommand{\\homoiconic}{{\\ttfamily homoiconic}~}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{filecontents}{paper.bib}\n@article{birkhoff1970heterogeneous,\n  title={Heterogeneous algebras},\n  author={Birkhoff, Garrett and Lipson, John D},\n  journal={Journal of Combinatorial Theory},\n  volume={8},\n  number={1},\n  pages={115--133},\n  year={1970},\n  publisher={Elsevier}\n}\n\n@article{goldberg1991,\n  title={What every computer scientist should know about floating-point arithmetic},\n  author={Goldberg, David},\n  journal={ACM Computing Surveys (CSUR)},\n  volume={23},\n  number={1},\n  pages={5--48},\n  year={1991},\n  publisher={ACM}\n}\n\n@inproceedings{jones2001playing,\n  title={Playing by the rules: rewriting as a practical optimisation technique in GHC},\n  author={Jones, Simon Peyton and Tolmach, Andrew and Hoare, Tony},\n  booktitle={Haskell workshop},\n  volume={1},\n  pages={203--233},\n  year={2001}\n}\n\n@book{higham2002,\n  title={Accuracy and stability of numerical algorithms},\n  author={Higham, Nicholas J},\n  year={2002},\n  publisher={Siam}\n}\n\n@inproceedings{sheard2002template,\n  title={Template meta-programming for Haskell},\n  author={Sheard, Tim and Jones, Simon Peyton},\n  booktitle={Proceedings of the 2002 ACM SIGPLAN workshop on Haskell},\n  pages={1--16},\n  year={2002},\n  organization={ACM}\n}\n\n@article{swierstra2008,\n  title={Data types {\\`a} la carte},\n  author={Swierstra, Wouter},\n  journal={Journal of functional programming},\n  volume={18},\n  number={04},\n  pages={423--436},\n  year={2008},\n  publisher={Cambridge Univ Press}\n}\n\n@inproceedings{schrijvers2009complete,\n  title={Complete and decidable type inference for GADTs},\n  author={Schrijvers, Tom and Peyton Jones, Simon and Sulzmann, Martin and Vytiniotis, Dimitrios},\n  booktitle={ACM Sigplan Notices},\n  volume={44},\n  number={9},\n  pages={341--352},\n  year={2009},\n  organization={ACM}\n}\n\n@book{hamming2012,\n  title={Numerical methods for scientists and engineers},\n  author={Hamming, Richard},\n  year={2012},\n  publisher={Courier Corporation}\n}\n\n@inproceedings{gupta2015,\n  title={Deep Learning with Limited Numerical Precision},\n  author={Gupta, Suyog and Agrawal, Ankur and Gopalakrishnan, Kailash and Narayanan, Pritish},\n  booktitle={Proceedings of the 32nd International Conference on Machine Learning (ICML-15)},\n  pages={1737--1746},\n  year={2015}\n}\n\n@article{eisenberg2015promoting,\n  title={Promoting functions to type families in Haskell},\n  author={Eisenberg, Richard A and Stolarek, Jan},\n  journal={ACM SIGPLAN Notices},\n  volume={49},\n  number={12},\n  pages={95--106},\n  year={2015},\n  publisher={ACM}\n}\n\n@inproceedings{panchekha2015automatically,\n  title={Automatically improving accuracy for floating point expressions},\n  author={Panchekha, Pavel and Sanchez-Stern, Alex and Wilcox, James R and Tatlock, Zachary},\n  booktitle={Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation},\n  pages={1--11},\n  year={2015},\n  organization={ACM}\n}\n@misc{viewpatterns,\n  author = {GHC Wiki},\n  title = {View patterns: lightweight views for Haskell},\n  url = {https://ghc.haskell.org/trac/ghc/wiki/ViewPatterns},\n  note = {Accessed: 2016-06-09}\n}\n\n@misc{patternsynonyms,\n  author = {GHC Wiki},\n  title = {Pattern Synonyms},\n  url = {https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms},\n  note = {Accessed: 2016-06-09}\n}\n\\end{filecontents}\n\\immediate\\write18{bibtex paper}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{document}\n\n\\special{papersize=8.5in,11in}\n\\setlength{\\pdfpageheight}{\\paperheight}\n\\setlength{\\pdfpagewidth}{\\paperwidth}\n\n\\conferenceinfo{CONF 'yy}{Month d--d, 20yy, City, ST, Country}\n\\copyrightyear{20yy}\n\\copyrightdata{978-1-nnnn-nnnn-n/yy/mm}\n\\copyrightdoi{nnnnnnn.nnnnnnn}\n\n% Uncomment the publication rights you want to use.\n%\\publicationrights{transferred}\n%\\publicationrights{licensed}     % this is the default\n%\\publicationrights{author-pays}\n\n\\titlebanner{Preprint}        % These are ignored unless\n\\preprintfooter{Preprint}   % 'preprint' option specified.\n\n%\\title{What's the point of homoiconicity?}\n%\\title{The (floating) point of homoiconicity}\n%\\title{Homoiconicity Without Template Haskell}\n\\title{Homoicoicity with FAlgebras}\n%\\subtitle{Functional Pearl}\n\n\\authorinfo{Mike Izbicki}\n           {UC Riverside}\n           {mike@izbicki.me}\n%\\authorinfo{Name2\\and Name3}\n           %{Affiliation2/3}\n           %{Email2/3}\n\n\\maketitle\n\n\\begin{abstract}\nWe say a function is \\emph{homoiconic} if it can be converted into an isomorphic abstract syntax tree (AST).\nThis AST can then be manipulated arbitrarily and converted back into a function.\nTemplate Haskell gives a limited form of homoiconicity to Haskell programs,\nbut this paper introduces another form.\nThe technique relies on an isomorphism between certain Haskell classes and FAlgebras.\nThe \\homoiconic library provides tools for using the technique.\n%To make the technique more widely applicable,\n%we introduce the Haskell community to the heterogeneous FAlgebra\n%polymorphism and GHC's type programming capabilities.\n%We also present the \\homoiconic library that facilitates working with this technique.\n%To motivate our technique,\n%we construct a small library that automatically transforms numerically unstable code into stable code.\n\n%This paper shows that many Haskell functions are \\emph{homoiconic}.\n%That is, we can convert these functions into isomorphic abstract syntax trees (ASTs),\n%and these ASTs can be converted back into their original Haskell functions.\n%%These ASTs are ordinary Haskell data types,\n%%so they can be manipulated arbitrarily to perform program transformations.\n%The construction does not require template Haskell,\n%and so works on expressions available at either compile or run time.\n%To motivate this homoiconicity,\n%we construct a small library that automatically transforms numerically unstable code into stable code.\n\n%Floating point numbers are dangerous.\n%Due to their limited precision,\n%seemingly correct mathematical formulae can give wildly inaccurate results.\n%This paper shows that Haskell's type system can mitigate this danger.\n%\n%The main observation is that many numerical Haskell functions are \\emph{homoiconic}.\n%That is, we can easily convert them into isomorphic abstract syntax trees (ASTs).\n%The construction does not use template Haskell, and so works at both compile and run time.\n%We will use these ASTs to solve two problems with floating point numbers:\n%\\begin{enumerate}\n%\\item\n%We will write higher order functions that automatically stabilize (or optimize!) mathematical formulae.\n%%This lets one programmer write naive floating point code;\n%%then an expert on numerical analysis can write code that automatically improves the naive code.\n%\\item\n%We will specify type class laws for floating point arithmetic that can be automatically tested.\n%Existing test frameworks do not work on floating point numbers because floats do not obey many traditional algebraic laws like associativity.\n%\\end{enumerate}\n%We demonstrate these techniques using GHC's built-in numeric class hierarchy,\n%but these techniques generalize to user defined class hierarchies as well.\n\\end{abstract}\n\n%\\category{CR-number}{subcategory}{third-level}\n\n% general terms are not compulsory anymore,\n% you may leave them out\n%\\terms\n%term1, term2\n\n%\\keywords\n%floating point, homoiconic, type classes\n\n\\section{Introduction}\n\nTemplate Haskell \\cite{sheard2002template} is the standard tool for metaprogramming in Haskell.\n%Using quotations, we can convert Haskell code into an abstract syntax tree (AST),\n%and using splices, we can insert arbitrary ASTs into our code.\n%Template Haskell is enormously useful, but it also has limitations.\nIn this paper, we introduce a different style of metaprogramming and an accompanying library called \\homoiconic.\n\nFor example, imagine you're using a library that exports a function\n\\begin{lstlisting}\nlogLogistic :: Floating a => a -> a\n\\end{lstlisting}\nThere is no way to use Template Haskell to get the abstract syntax tree (AST) of this function.\nWith \\homoiconic, however, we \\emph{can} inspect the |logLogistic| function and get its AST.\nA ghci session to do this might look like:\n\\begin{lstlisting}\nghci> logLogistic var1 :: AST Floating Var\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate var1)))))\n\\end{lstlisting}\nIn this paper, we'll call any function homoiconic if we can convert it into an AST.\nSo the |logLogistic| function above is homoiconic.\n\nThe \\homoiconic library also lets us perform arbitrary program transformations.\nA careful look at the output above will reveal that |logLogistic| is numerically unstable.\nWhen specialized to the |Double| type,\nthe |exp| function overflows to infinity for inputs greater than (approximately) $709$.\n%This overflow causes |logLogistic| to take the |log| of 0, which is undefined.\nTherefore, on an input of $-710$,\n|logLogisitic| will take the |log| of 0,\nreturning negative infinity when the true answer is actually very close to $-710$.\nUsing \\homoiconic, we can write a function\n\\begin{lstlisting}\nstabilize :: AST Floating a -> AST Floating a\n\\end{lstlisting}\nthat converts the AST of an unstable function into a stable function.\nWe could write a similar transformation in Template Haskell,\nbut there would be no way for us to get the AST to apply it on!\n\nThe key idea of the \\homoiconic library is simple:\nCertain type classes have FAlgebras that completely capture their structure.\nFrom FAlgebras, we can create ASTs.\nAnd we can use these ASTs to represent expressions generated by the corresponding type classes.\n%It's important to note that \\homoiconic is much more limited than Template Haskell in other ways.\n%In particular, it will only work on certain (but not all!) expressions.\n%\\footnote{\n%FAlgebras are a standard Haskell design pattern for domain specific languages.\n%There are many existing references, but Data Types \\`a la Carte \\cite{swierstra2008} is probably the most famous.\n%}\n%From these FAlgebras, we can in turn generate ASTs for functions.\n\nThe remainder of this paper describes these constructions.\nSection \\ref{sec:homogeneous} introduces \\emph{homogeneous} type classes and functions.\nHomogeneous type classes have a particularly simple FAlgebra construction that is a natural extension of the Data Types \\`a la Carte approach \\cite{swierstra2008}.\nSection \\ref{sec:stabilize} illustrates how to write program transformations like |stabilize| with a handful of examples operating on numerical functions.\nFinally, Section 4 introduces \\emph{heterogeneous} type classes.\nThe naming stems from the intuition that homogeneous classes generate ASTs that contain a single type,\nbut heterogeneous classes generate ASTs that contain multiple types.\nThe resulting constructions for the heterogeneous case is significantly more complicated.\n\n\\section{Homogeneous functions are homoiconic}\n\\label{sec:homogeneous}\n\nIn this section we first define homogeneous type classes and functions.\nThen we show that there is an FAlgebra for each homogeneous type class,\nand that this FAlgebra makes homogeneous functions homoiconic.\nAll of the constructions discussed here can be found in \\homoiconic's |Homogeneous.FAlgebra| module.\n\n\\begin{defn}\nWe call a type class homogeneous if:\n\\begin{enumerate}\n\\item\nit has a single parameter of kind |Type|; and\n\\item\nthe class's constraints contain only homogeneous type classes applied directly to the parameter.\n\\end{enumerate}\nFor example, all of the classes in the Prelude are homogeneous.\nSome of these classes are shown in Figure \\ref{code:ghc}.\nFigure 2 (near the end of the paper) shows type classes which are not homogeneous due to the presence of type families in the constraints.\n\\end{defn}\n\n\\begin{defn}\nWe call a function homogeneous if:\n\\begin{enumerate}\n\\item\nthere is exactly one type variable in the signature, which we denote by |a|;\n\\item\neach of the function's parameters is either\n\\begin{enumerate}\n\\item\n|a|, or\n\\item\nconcrete;\n\\end{enumerate}\n\\item\nthe function's return type is |a|; and\n\\item\nthe constraints contain exactly one homogeneous type classes applied to |a| and nothing else.\n\\end{enumerate}\nThe |logLogistic| function is homogeneous,\nand Figure \\ref{code:ghc} shows many more examples and counterexamples taken from the |Prelude|'s numeric hierarchy.\n\\end{defn}\n\n%In the remainder of this section we describe a canonical method for constructing FAlgebras from homogeneous type classes and show that this construction makes homogeneous functions homoiconic.\n%The construction is tedious to implement by hand,\n%so the \\homoiconic library provides the function |mkFAlgebra| to automate the boilerplate.\n%This function is provided as a convenience and is not strictly necessary for the technique.\n\n%In this section, we will show that every type class has an associated monad representing the abstract syntax tree of the class's homogeneous functions.\n%Our construction is closely related to other constructions involving initial algebras, FAlgebras, and free monads.\n%See for example \\cite{swierstra2008}.\n\n%Our goal in this section is to convert homogeneous functions into ASTs.\n%These ASTs will contain only a single parameter type, and so are relatively simple.\n%The construction will use FAlgebras\\cite{swierstra2008}.\n\n\\begin{figure}\n\\begin{lstlisting}\nclass Num a where\n    (+), (-), (*)       :: a -> a -> a\n    negate              :: a -> a\n    abs, signum         :: a -> a\n    fromInteger         :: Integer -> a\n\nclass Num a => Fractional a where\n    (/)                 :: a -> a -> a\n    recip               :: a -> a\n    fromRational        :: Rational -> a\n\nclass Fractional a => Floating a where\n    pi                  :: a\n    exp, log, sqrt      :: a -> a\n    (**), logBase       :: a -> a -> a\n    sin, cos, tan       :: a -> a\n    asin, acos, atan    :: a -> a\n    sinh, cosh, tanh    :: a -> a\n    asinh, acosh, atanh :: a -> a\n\nclass Eq a where\n    (==), (/=)          :: a -> a -> Bool\n\nclass Eq a => Ord a where\n    compare             :: a -> a -> Ordering\n    (<),(<=),(>),(>=)   :: a -> a -> Bool\n    max, min            :: a -> a -> a\n\\end{lstlisting}\n\\caption{\n    A portion of the numeric and comparison hierarchies defined in GHC's Prelude.\n    %Functions highlighted in bold are homogeneous,\n    %and the remainder are not.\n}\n\\label{code:ghc}\n\\end{figure}\n\n\n\\subsection{A type class for FAlgebras}\nEvery homogeneous type class has an associated FAlgebra.\nWe represent this FAlgebra with the following type class.\n\\begin{lstlisting}\nclass Functor (Sig alg) => FAlgebra alg where\n    data Sig alg a\n    runSig :: alg a => Sig alg a -> a\n\\end{lstlisting}\nThe |FAlgebra| class is unusual in that its parameter has kind |Type->Constraint|.\nThis means that instances of |FAlgebra| will be other type classes\n(instead of types or type constructors).\n\nIt is easiest to understand the |FAlgebra| class by walking through an example instance.\nBelow is the instance for |Fractional|.\n\\begin{lstlisting}\ninstance FAlgebra Fractional where\n    data Sig Fractional a\n        = Sig_div a a\n        | Sig_recip a\n        | Sig_fromRational Rational\n        | Sig_Fractional_Num (Sig Num a)\n    runSig (Sig_div a1 a2)        = a1/a2\n    runSig (Sig_recip a)          = recip a\n    runSig (Sig_fromRational r)   = fromRational r\n    runSig (Sig_Fractional_Num s) = runSig s\n\\end{lstlisting}\n\nThe data family |Sig| encodes what mathematicians call the \\emph{signature} of the FAlgebra.\nThe signature defines all the operations that can be performed on an FAlgebra.\nEach |Sig| data instance can have many constructors,\nand these constructors come in two flavors.\nFirst is the \\emph{function constructor}.\nThere should be one function constructor for each homogeneous class function, and\nthis constructor should have the same parameters as the function.\nFor the |Fractional| example, we've defined the three constructors |Sig_div|, |Sig_recip|, and |Sig_fromRational| for the three class methods |(/)|, |recip|, and |fromRational| respectively.\nThe second constructor flavor is the \\emph{superclass constructor}.\nThere should be one superclass constructor for each superclass, and\nthis constructor should store the |Sig| of the corresponding superclass.\nFor the |Fractional| example, we have the |Sig_Fractional_Num| constructor corresponding to the |Num| superclass.\n\nThe |runSig| class method evaluates an FAlgebra's signature.\nMathematicians sometimes call this function simply an \\emph{algebra}.\nFor each function constructor, |runSig| should call the corresponding function.\nFor each superclass constructor, |runSig| recursively calls |runSig| on the superclass's |Sig|.\nThis is exactly what the |Fractional| instance above does.\n\nThe F in FAlgebra comes from the fact that every signature is actually a functor.\nIn Haskell, we encode this by enforcing that |Sig alg| must be an instance of the |Functor| class.\nAs usual, there is only a single valid |Functor| instance.\nFor |Fractional|, it is:\n\\begin{lstlisting}\ninstance Functor (Sig Fractional) where\n    fmap f (Sig_div a1 a2) = Sig_div (f a1) (f a2)\n    fmap f (Sig_recip a) = Sig_recip (f a)\n    fmap f (Sig_fromRational r) = Sig_fromRational r\n    fmap f (Sig_Fractional_Num s) = fmap f s\n\\end{lstlisting}\n\n\\subsection{Constructing the AST}\n\\label{sec:hom.cons}\n\nFor every FAlgebra, there is an associated AST.\nThis AST is sometimes called an \\emph{initial algebra},\nand has a standard construction via the \\emph{free monad}.\nIn Haskell, the free monad is defined as\n\\begin{lstlisting}\ndata Free f a\n    = Pure a\n    | Free (f (Free f a))\n\\end{lstlisting}\nwhich lets us define our AST as\n\\begin{lstlisting}\ntype AST alg a = Free (Sig alg) a\n\\end{lstlisting}\nIntuitively,\nthe |Pure| constructor represents a leaf in the AST,\nand the |Free| constructor represents a branch.\nThe parameter to |Free| is filled by the appropriate |Sig| data instance.\nThe constructor used for the |Sig| instance corresponds to an operation,\nand the parameters to the constructor will contain ASTs nested recursively.\n\nFor example, consider the expression |(1+2)+3|.\nWe can create a corresponding AST using |Num|'s |FAlgebra| instance.\n\\begin{lstlisting}\nexpr1 :: AST Num Double\nexpr1 = Free\n  (Sig_plus\n    (Free\n      (Sig_plus\n        (Pure 1)\n        (Pure 2)\n      )\n    )\n    (Pure 3)\n  )\n\\end{lstlisting}\nThe type signature is not necessary, but shown for clarity.\n\nWe can also create an AST for the same expression using any subclass of |Num|.\nBelow is the same expression encoded using |Floating|'s |FAlgebra| instance.\n\\begin{lstlisting}\nexpr2 :: AST Floating Double\nexpr2 = Free\n  (Sig_Floating_Fractional\n    (Sig_Fractional_Num\n      (Sig_plus\n        (Free\n          (Sig_Floating_Fractional\n            (Sig_Fractional_Num\n              (Sig_plus\n                (Pure 1)\n                (Pure 2)\n              )\n            )\n          )\n        )\n        (Pure 3)\n      )\n    )\n  )\n\\end{lstlisting}\nNotice that the |Sig_plus| constructor must be embedded into |Floating|'s |Sig| with calls to |Sig_Floating_Fractional| and |Sig_Fractional_Num|.\nThese embeddings create considerable boilerplate,\nmaking the construction of ASTs by hand a tedious process.\n\nWe can avoid this boilerplate with a type class that performs these embeddings for us.\\footnote{\n    The name {\\ttfamily View} stems from the fact that the class methods are actually what GHC calls ``view patterns.''\n    See Section \\ref{sec:viewpatterns} for details on how the {\\ttfamily ViewPatterns} language extension lets us use the {\\ttfamily View} type class for easier pattern matching on our ASTs.\n}\n\\begin{lstlisting}\nclass (FAlgebra alg1, FAlgebra alg2)\n    => View alg1 alg2 where\n    embedSig         :: Sig alg1 a -> Sig alg2 a\n    unsafeExtractSig :: Sig alg2 a -> Sig alg1 a\n\\end{lstlisting}\nInstances of |View| should satisfy the property that |alg1| is either equal to |alg2| or is a superclass of |alg2|, and\nall such relationships should have a corresponding instance.\nThis property ensures that the |Sig alg1 a| data instance can always be embedded into a |Sig alg2 a| data instance (via a chain of superclass constructors).\nIt is only sometimes true that we can extract a |Sig alg1 a| from a |Sig alg2 a|,\nso the function is partial and hence labeled |unsafe|.\nFor example,\nwe have the following |View Num Floating| instance because |Num| is a superclass of |Floating| via |Fractional|.\n\\begin{lstlisting}\ninstance View Num Floating\n    embedSig s\n        = Sig_Fractional_Floating (embedSig s)\n    unsafeExtractSig (Sig_Fractional_Floating s)\n        = unsafeExtractSig s\n\\end{lstlisting}\nThe |embedSig| function shows us how to embed a |Sig Num| into a |Sig Floating| by calling the appropriate superclass constructors.\nNotice that the recursive call to |embedSig| relies on a |View Num Fractional| instance also existing.\nSimilarly, the |unsafeExtractSig| function extracts the |Sig Num| instance by pattern matching on the appropriate superclass constructors.\n\nArmed with this |View| class, we can create a uniform representation for |FAlgebra|'s ASTs.\nThe expression |(1+2)+3| can now be represented polymorphically as:\n\\begin{lstlisting}\nexpr3 :: View Floating alg => AST alg Double\nexpr3 = Free\n  (embedSig\n    (Sig_plus\n      (Free\n        (embedSig\n          (Sig_plus\n            (Pure 1)\n            (Pure 2)\n          )\n        )\n      )\n      (Pure 3)\n    )\n  )\n\\end{lstlisting}\n\nUsing our uniform representation of an AST,\nwe can make the |AST| type an instance of any homogeneous type class.\nAs an example, the |Fractional| instance is shown below.\n\\begin{lstlisting}\ninstance\n    ( View Fractional alg\n    , View Num alg\n    ) => Fractional (AST alg a) where\n    (/) e1 e2 = Free $ embedSig $ Sig_div e1 e2\n    recip e   = Free $ embedSig $ Sig_recip e\n    fromRational r\n        = Free $ embedSig $ Sig_fromRational r\n\\end{lstlisting}\nFor each function in the type class,\nwe simply embed the function's constructor into the AST by prepending the expression |Free $ embedSig $|.\nThe constrainst |View num alg| is not used directly in the instance.\nIt is inherrited from the |Num (AST alg a)| instance,\nwhere it is used directly.\nIn general, a type class instance for |AST| will require a |View| constraint for every superclass,\nnot just those parent classes listed in the context.\n\nThese instances let us easily create ASTs.\nThe |Num| AST can be created with the expression\n\\begin{lstlisting}\nexpr4 :: AST Num Double\nexpr4 = (1+2)+3\n\\end{lstlisting}\nAnd the |Floating| AST can be created by just changing the type signature.\n\\begin{lstlisting}\nexpr5 :: AST Floating Double\nexpr5 = (1+2)+3\n\\end{lstlisting}\nNotice that in these last two examples we did not embed the numbers into the AST with the |Pure| constructor.\nSince |AST| is an instance of |Num|,\nGHC will call |fromInteger| to embed the number for us automatically.\n\n\\subsection{Showing the AST}\nNow that we can create our ASTs, we want to actually do something with them!\nIn this section we will convert them into a |String| for display.\nThis is an easy procedure of writing |Show| instances for the |Sig| and |Free| data types.\n\nThere are no tricks in the |Show| instance for |Sig|.\nThe instance for |Fractional| is shown below.\n\\begin{lstlisting}\ninstance Show a => Show (Sig Fractional a) where\n    show (Sig_div a1 a2) = show a1++\"/\"++show a2\n    show (Sig_recip a) = \"recip \"++show a\n    show (Sig_fromRational r) = \"fromRational \"++show r\n    show (Sig_Fractional_Num s) = show s\n\\end{lstlisting}\nFor each function constructor, we simply show the corresponding function and its parameters.\nIf the function is an operator, we'll display it infix for convenience.\nFor each superclass constructor, we simply recursively call show on the superclass's |Sig|.\n\nThe |Free| type's |Show| instance is similarly straightforward.\n\\begin{lstlisting}\ninstance (Show a, Show (f (Free f a)))\n    => Show (Free f a) where\n    show (Pure a) = show a\n    show (Free f) = \"(\"++show f++\")\"\n\\end{lstlisting}\nIf the syntax tree contains only a single leaf, we just show that leaf.\nIf the syntax tree contains a branch,\nthen put parenthesis around the branch,\nand show the functor (i.e. the |Sig|) in the middle.\n\nNow, when we type a numeric expression into ghci without a type signature,\nghci will evaluate the expression like normal.\n\\begin{lstlisting}\nghci> (1+2)+3\n6\n\\end{lstlisting}\nBut when we add the appropriate type signature,\nthe full AST is displayed.\n\\begin{lstlisting}\nghci> (1+2)+3 :: AST Floating Double\n(((fromInteger 1)+(fromInteger 2))+(fromInteger 3))\n\\end{lstlisting}\nAgain, the way ghci works, all integer literals automatically have |fromInteger| applied to them,\nwhich is why this function appears in the AST above.\nIt would be easy to create a pretty printer that does not display |fromInteger| or the excess parentheses,\n%but this is left as an exercise for the reader :)\nbut we that would take us too far afield here.\n\n\\subsection{Showing functions}\nReconsider our |logLogistic| function.\nIt has type\n\\begin{lstlisting}\nlogLogistic :: Floating a => a -> a\n\\end{lstlisting}\nWhat happens if we specialize the |a| parameter to be an |AST|?\nWe'll get a peek at the function's internals.\n\\begin{lstlisting}\nghci> logLogistic 1 :: AST Floating Double\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (fromInteger 1))))))\n\\end{lstlisting}\nWe don't just have to input single numbers;\nwe can also input full expressions.\nThese expressions will also get displayed,\nintermixed with the original function.\n\\begin{lstlisting}\nghci> logLogistic (1*3+4) :: AST Floating Double\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (((fromInteger 1)*(fromInteger 3))\n    +(fromInteger 4)))))))\n\\end{lstlisting}\nAnd we can even display the resulting AST of nested function calls.\n\\begin{lstlisting}\nghci> logLogistic (logLogistic 1)\n    :: AST Floating Double\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (log ((fromInteger 1)/((fromInteger 1)\n    +(exp (negate (fromInteger 1)))))))))))\n\\end{lstlisting}\nIt would be nice if the displayed function could show variables,\nrather than just numbers.\nTo accomplish this, we need a variable type.\n\\begin{lstlisting}\nnewtype Var = Var String\n\\end{lstlisting}\nValues of type |Var| cannot be plugged directly into the |logLogistic| function because |Var| is not an instance of |Floating|.\nFortunately, we have a way to make any type an instance of |Floating| via |Floating|'s |AST| type.\nMore generically, we define the following variables.\n\\begin{lstlisting}\nvar1 :: AST alg Var\nvar1 = Pure \"var1\"\n\nvar2 :: AST alg Var\nvar2 = Pure \"var2\"\n\nvar3 :: AST alg Var\nvar3 = Pure \"var3\"\n\\end{lstlisting}\nAnd we can use them to recover the exact AST of a function.\n\\begin{lstlisting}\nghci> logLogistic var1 :: AST Floating Var\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate var1)))))\n\\end{lstlisting}\nAt this point, you might be tempted to write a |Show| instance for functions.\n\\begin{lstlisting}\ninstance\n    ( FAlgebra alg\n    , Show (Sig alg (Free (Sig alg) Var))\n    ) => Show (AST alg Var -> AST alg Var) where\n    show f = show (f var1)\n\\end{lstlisting}\nUnfortunately, if you try to use the instance naively\n\\begin{lstlisting}\nghci> logLogistic\n\\end{lstlisting}\nthen ghci will complain about ambiguous type variables.\nGHC's defaulting mechanism is not powerful enough for it to properly specialize the function without a type signature.\nSo while this construction does give us a convenient way to inspect the contents of a function,\nit's not quite powerful enough for a proper |Show| instance.\n\n\\subsection{Evaluating the syntax tree}\nOur last task is to evaluate the ASTs.\nThat is, we need to run them to generate the value the tree represents.\n\nTo do this, we will take advantage of the free monad's structure.\n(Recall that the |AST| type we've been using is a synonym for the free monad.)\nThe free monad is so called because as long as the parameter |f| is a |Functor|,\nthen |Free| has a valid |Monad| instance.\nSince all |Monad|s are by necessity also |Functor|s,\n|Free| has a valid |Functor| instance as well.\n\\begin{lstlisting}\ninstance Functor f => Functor (Free f) where\n    fmap g (Pure a) = Pure (g a)\n    fmap g (Free f) = Free (fmap (fmap g) f)\n\\end{lstlisting}\nFor our purposes, that's all the structure we'll need.\n\nThe following simple function evaluates the syntax tree.\n\\begin{lstlisting}\nrunAST :: (FAlgebra alg, alg a) => AST alg a -> a\nrunAST (Pure a) = a\nrunAST (Free f) = runSig (fmap evalHom f)\n\\end{lstlisting}\nIf our syntax tree already consists of just a single value (i.e. it is the |Pure| constructor),\nthen we just return that value.\nOtherwise, we use the |Functor| instance to recursively convert the |Sig|s into types of |a|,\ncombining the results with |runSig|.\n\nWhen we evaluate an AST for an expression,\nwe get the same result as if we had just evaluated the expression directly.\n\\begin{lstlisting}\nghci> logLogistic 10 :: Double\n-4.539889921682063e-5\n\nghci> runAST (logLogistic 10 :: AST Floating Double)\n-4.539889921682063e-5\n\\end{lstlisting}\nWe've finally demonstrated that homogeneous functions are in fact homoiconic.\n\n\\subsection{Boilerplate}\n\nFor each homogeneous type class,\nthere are many boilerplate instances that we need to write.\nThe \\homoiconic library provides a template Haskell function |mkFAlgebra| in the |Homogeneous.FAlgebra| module that generates the |FAlgebra|, |Functor|, |Show|, and |View| instances plus all of the pattern synonyms (discussed in the next section) for a given class.\nAll of constructions above can be generated by the single invocation\n\\begin{lstlisting}\nmkFAlgebra ''Fractional\n\\end{lstlisting}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Writing program transformations}\n\\label{sec:stabilize}\n\nWe're now ready to write program transformations that manipulate the ASTs created in the previous section.\nIn this section, we'll first demonstrate how to pattern match on our ASTs using the |ViewPatterns| and |PatternSynonyms| language extensions.\n%Then we'll see three simple examples of program transformations implemented in this way.\nWe'll also see three motivating examples of useful transformations on floating point operations.\n\n%Automatically stabilizing floating point expressions is an active area of research.\n%One way of doing this is to create a library of program transformations that fix many different types of expressions.\n%Then combining everything in the library on your problem.\n%In this section, we'll create a very small library for these floating point issues,\n%and don't claim to have completely solved the floating point problem.\n%This is simply a motivating example for homoiconicity.\n\n\\subsection{Pattern matching the AST}\n\\label{sec:patternmatch}\n\nConsider the following simple,\nbut numerically unstable function.\n\\begin{lstlisting}\ntestFunc1 :: Floating a => a -> a\ntestFunc1 = log (exp a)\n\\end{lstlisting}\nAs in our |logLogistic| function,\n|testFunc| gives incorrect answers when |a| is specialized to |Double|.\nInputs greater than (approximately) 710 cause the |exp| function to overflow to infinity;\nthe log of infinity is still infinity;\nso the returned answer is infinity.\nBut this wrong.\nOn the real numbers, the $\\log$ function is defined to be the inverse of $\\exp$,\nso the final result should be exactly the same as the input.\nWe'll write a program transformation that stabilizes the |testFunc1| function,\nthen we'll demonstrate how the |ViewPatterns| and |PatternSynonyms| language extensions simplify this transformation.\n\\label{sec:viewpatterns}\n\nOur goal is to take an input AST,\nfind all occurrences of the expression |log (exp x)|,\nand replace them with just |x|.\n(Here |x| can be an arbitrary AST, not just a single value.)\nWe will create a series of four functions to accomplish this task,\neach improving on the previous.\nHere is the first.\n\\begin{lstlisting}\nlogexpAST1 :: AST Floating a -> AST Floating a\nlogexpAST1 (Free (Sig_log (Free (Sig_exp a)))) = a\n\\end{lstlisting}\nThis function has two syntactic warts.\nFirst, the pattern is verbose.\nTo properly match the expression, we must alternate between the |Free| and |Sig_| constructors.\nIt would be better to have a single constructor per operation.\nSecond, the function is specialized to the |Floating| type class.\nWe would like our transformation to also works on subclasses of |Floating|.\n\nWe'll start by correcting the second problem.\nThe |ViewPatterns| language extension provides syntactic sugar that lets us pattern match on the return value of a function.\\footnote{\n    The GHC wiki \\cite{viewpatterns} provides details on exactly how the desugaring works.\n}\nWe can use |ViewPatterns| to write polymorphic patterns by using polymorphic functions in the pattern.\nWe need a polymorphic function for extracting a |Sig alg a| type from a |Sig Floating a| whenever |alg| is a subclass of |Floating|.\nFortunately, we've already defined such a function:\n\\begin{lstlisting}\nunsafeExtractSig :: View alg1 alg2\n    => Sig alg2 a -> Sig alg1 a\n\\end{lstlisting}\nUsing it in the pattern gives us our second program transformation.\n\\begin{lstlisting}\nlogexpAST2 :: View Floating alg\n    => AST alg a -> AST alg a\nlogexpAST2\n    (Free (unsafeExtractSig -> Sig_log\n    (Free (unsafeExtractSig -> Sig_exp a))))\n    = a\n\\end{lstlisting}\nThis modified transformation has the correct polymorphic type signature\n(so we've solved problem 2),\nbut the pattern matches are even uglier\n(so we've made problem 1 worse).\n\nThe |PatternSynonyms| extension lets us define new patterns,\\footnote{\n    Again, see the GHC Wiki \\cite{patternsynonyms} for details on this language extension.\n}\nand we will use this feature to clean up our syntax.\nSpecifically, we define a pattern synonym for each function contained in an FAlgebra.\nOur naming convention is to prefix |AST_| to the name of the function.\nThese pattern synonyms combine the |Free| constructor with the view pattern from the previous example.\nThe synonyms for the |log| and |exp| functions are shown below.\n\\begin{lstlisting}\npattern AST_log :: View Floating alg\n    => AST alg a -> AST alg a\npattern AST_log e\n    <- Free (unsafeExtractSig -> Sig_log e)\n\npattern AST_exp :: View Floating alg\n    => AST alg a -> AST alg a\npattern AST_exp e\n    <- Free (unsafeExtractSig -> Sig_exp e)\n\\end{lstlisting}\nArmed with these pattern synonyms,\nwe can rewrite our function in a much simpler form.\n\\begin{lstlisting}\nlogexpAST3 :: View Floating alg\n    => AST alg a -> AST alg a\nlogexpAST3 (AST_log (AST_exp a)) = a\n\\end{lstlisting}\nThis simple function works on our the motivating test case:\n\\begin{lstlisting}\nghci> logexpAST3 $ testFunc1 var1 :: AST Floating Var\nvar1\n\\end{lstlisting}\n%stopzone\nbut it fails on this slightly more complex function:\n\\begin{lstlisting}\ntestFunc2 :: Floating a => a -> a\ntestFunc2 a = 1+exp(log a)\n\\end{lstlisting}\nThe problem is that we haven't told our program transformations what to do when they don't pattern match!\nWhen pattern matching fails, we want our transformations to recurse into the subexpressions,\napplying the transformations there as well.\nIn the free monad, recursion is handled by a call to |fmap| and the base case is handled by extracting the contents of |Pure|.\n\nHere is our final version of the program transformation.\n\\begin{lstlisting}\nlogexpAST4 :: View Floating alg\n    => AST alg a -> AST alg a\nlogexpAST4 (AST_log (AST_exp a)) = a\nlogexpAST4 (Free f) = Free (fmap logexpAST4 f)\nlogexpAST4 (Pure a) = Pure a\n\\end{lstlisting}\nIt correctly recurses into subexpressions.\n\\begin{lstlisting}\nghci> logexpAST4 $ testFunc2 var1\n    :: AST Floating Var\n((fromInteger 1)+var1)\n\\end{lstlisting}\n%stopzone\nBut there's still one last wrinkle.\nWhat if we need to apply the program transformation multiple times?\nConsider the following test function.\n\\begin{lstlisting}\ntestFunc3 :: Floating a => a -> a\ntestFunc3 a = 1+log(log(log(exp(exp(exp a)))))\n\\end{lstlisting}\nApplying our program transformation directly doesn't correct the function because the transformation needs to be applied repeatedly.\n\\begin{lstlisting}\nghci> logexpAST4 $ testFunc3 var1\n    :: AST Floating Var\n((fromInteger 1)+(log (log (exp (exp var1)))))\n\\end{lstlisting}\n%stopzone\nWhat we want is the \\emph{fixed point} of the program transformation.\nThat is, we want to apply the program transformation repeatedly until it stops changing the AST.\nThe |fixAST| function below takes as input a transformation and returns the fixed point of that transformation.\n\\begin{lstlisting}\nfixAST ::\n    ( Eq (Sig alg (Free (Sig alg) a))\n    , Eq a\n    ) => (AST alg a -> AST alg a)\n      -> (AST alg a -> AST alg a)\nfixAST f ast = if ast==ast'\n    then ast\n    else fixAST f ast'\n    where\n        ast' = f ast\n\\end{lstlisting}\nNow we can correctly modify the |testFunc3| function.\n\\begin{lstlisting}\nghci> fixAST logexpAST4 $ testFunc3 var1\n    :: AST Floating Var\n((fromInteger 1)+var1)\n\\end{lstlisting}\n%stopzone\nAnd that's all there is to writing a program transformation.\nMore complex transformations just involve more complex pattern matching.\n\n\\subsection{More complex transformations}\n\nThe transformation in in the previous section is relatively simple.\nFor example, it could have been implemented using GHC's rewrite rules \\cite{jones2001playing}.\nRewrite rules are the primary mechanism for optimising source code in GHC,\nbut they are limited to transformations that involve no computation.\nThis limitation prevents rewrite rules from implementing a number of optimizations,\none of them being being constant folding.\nConstant folding is the process of reducing an expression containing several constants into a single constant.\nFor example, converting the expression |(1+2)+3| into just the number |6|.\n%(Due to this limitation, GHC has special ad-hoc code just for constant folding.)\nOur program transformations can implement arbitrary computation and so are powerful enough to handle constant folding.\n\nThe following function performs constant folding on expressions containing addition and multiplication of integers.\n\\begin{lstlisting}\nfoldConstants :: View Num alg\n    => AST alg a -> AST alg a\nfoldConstants (AST_plus\n    (AST_fromInteger a1)\n    (AST_fromInteger a2))\n    = AST_fromInteger (a1+a2)\nfoldConstants (AST_mul\n    (AST_fromInteger a1)\n    (AST_fromInteger a2))\n    = AST_fromInteger (a1*a2)\nfoldConstants (Free sig)\n    = Free (fmap foldConstants sig)\nfoldConstants (Pure a) = Pure a\n\\end{lstlisting}\nIt is straightforward to extend this function to work for other operations,\nbut for space reasons these were omitted.\n\nLet's see an example of constant folding in action.\nFirst define a simple function with two parameters and a handful of constants.\n\\begin{lstlisting}\nfunc :: Num a => a -> a -> a\nfunc x1 x2 = x1*2+(7+2)*x2\n\\end{lstlisting}\nIf we call |func| with two constant parameters,\nour |foldConstants| function is able to simplify the resulting expression into a single constant.\n\\begin{lstlisting}\nghci> fixAST foldConstants (func 2 3)\n    :: AST Floating Double\n(fromInteger 31)\n\\end{lstlisting}\nAlternatively, we can call the function with two variable parameters.\nOnly the constants in the original function will be folded.\n\\begin{lstlisting}\nghci> fixAST foldConstants (func var1 var2)\n    :: AST Floating Var\n((var1*(fromInteger 2))+((fromInteger 9)*var2))\n\\end{lstlisting}\nAnd finally, we can call the function with one constant and one variable parameter.\n\\begin{lstlisting}\nghci> fixAST foldConstants (func var1 3)\n    :: AST Floating Var\n((var1*(fromInteger 2))+(fromInteger 27))\n\\end{lstlisting}\n\n\\subsection{The log-logistic function}\n\nNow let's see how to stabilize the |logLogistic| function.\nHere's an example of what a stable implementation might look like.\n\\begin{lstlisting}\nlogLogistic2 :: (Floating x, Ord x) => x -> x\nlogLogistic2 x = m+log(1/(exp(m)+exp(-x+m)))\n    where\n        m = min 0 x\n\\end{lstlisting}\nNotice that it has a different type signature---we've had to add the |Ord| constraint due to the use of the |min| function.\nRecall that one of the requirements for a function to be homogeneous is that it have only a single class in the context.\nTherefore the stabilized function |logLogistic2| is not homogeneous.\n\nWe can make an equivalent implementation, however, that is homogeneous by introducing the following type class\n\\begin{lstlisting}\nclass (Floating a, Ord a) => FloatingOrd a\n\\end{lstlisting}\nand the following instance\n\\begin{lstlisting}\ninstance {-#OVERLAPPABLE#-} (Floating a, Ord a)\n    => FloatingOrd a\n\\end{lstlisting}\nNote that the |OVERLAPPABLE| pragma is required so that we can create an |Ord| instance for |AST FloatingOrd a| per the construction in Section \\ref{sec:hom.cons}.\n\nWe can now write a function that stabilizes |logLogistic|\n\\begin{lstlisting}\nstabilize :: AST Floating a -> AST FloatingOrd a\nstabilize\n    (AST_log\n        (AST_div\n            (AST_fromInteger 1)\n            (AST_plus\n                (AST_fromInteger 1)\n                (AST_exp\n                    (AST_negate x)\n                )\n            )\n        )\n    )\n    = m+log(1/(exp(m)+exp(-x+m)))\n        where\n            m = min 0 x\n\\end{lstlisting}\nNotice that in this transformation, the type signature of the AST actually changes.\n\nThis transformation works, but it feels like cheating.\nIf we have to manually write a unique program transformation for every numeric function,\nthen we're not reducing our workload.\nFortunately we don't have to.\nDesigning generic program transformations that stabilize floating point numbers is an actively researched problem.\nFor example, a team from the University of Washington recently created the Herbie tool to stabilize floating point expressions \\cite{panchekha2015automatically}.\nThe output of such a program can easily be used to implement a significantly more advanced version of |stabilize|.\n%Since we can perform arbitrary computations inside our program transformations,\n%there's nothing stopping us from just plugging\n%Actually doing this is left as an exercise for the reader.\n%Any of these techniques can be used with these program transformations described in this section.\n%We can use programs like herbie within our Haskell programs.\n%In order to call out to a foreign program, we need to be in the |IO| monad.\n%\\begin{lstlisting}\n%herbie :: AST Floating a -> IO (AST FloatingOrd a)\n%\\end{lstlisting}\n%The is essentially how the Herbie GHC plugin works.\n\n\\section{Heterogeneous functions are homoiconic}\n\nIn the 1970's, mathematicians noticed a deficiency in the definition of FAlgebras.\nThe signature of an FAlgebra can only contain a single type,\nbut many structures involve multiple types.\nFor example, the definition of a vector space requires both a scalar type and a vector type.\nThe concept of heterogeneous FAlgebras was introduced to formalize these algebraic structures over multiple types \\cite{birkhoff1970heterogeneous}.\n\n%The same pattern happens in Haskell.\nSimilarly in Haskell, homogeneous type classes are not sufficient to describe all the structures we want to work with.\nFor example, Figure \\ref{code:vector} shows a simple extension to GHC's numerics hierarchy for working with vectors.\nThe |Vector| and |Hilbert| type classes are not homogeneous because they rely on a type family to describe the relationship between multiple types.\nUsing this class hierarchy, we can implement functions like the logistic loss:\n\\begin{lstlisting}\nlogLoss :: Vector a => a -> a -> Scalar a\nlogLoss a1 a2 = logLogistic (dotproduct a1 a2)\n\\end{lstlisting}\nAnd again, this function is not homogeneous due to the type family in the signature.\nNonetheless, we would still like to be able to convert this function into an AST as we did for homogeneous functions.\n\nIn this section we introduce the notion of heterogeneous type classes and functions.\nWe will see that for every heterogeneous type class,\nthere exists a corresponding heterogeneous FAlgebra.\nFrom this heterogeneous FAlgebra,\nwe can construct an AST using the heterogeneous free monad.\nThis construction gives us homoiconicity for heterogeneous functions.\nUnfortunately, type families as implemented in GHC Haskell have many limitations,\nand the limitations will complicate the heterogeneous constructions.\nWe will require considerably more type hackery in this section.\nFortunately, this complexity is contained within the construction of the heterogeneous AST.\nFrom a user's perspective, the heterogeneous AST is just as easy to work with as the homogeneous one.\n\n\\begin{figure}\n\\begin{lstlisting}\ntype family Scalar a\n\nclass (Num a, Floating (Scalar a))\n    => Vector a where\n    (.*) :: Scalar a -> a -> a\n\nclass Vector a => Hilbert a where\n    dotproduct :: a -> a -> Scalar a\n\ndata Vec3 = Vec3 a a a\ntype Scalar (Vec3 a) = a\n\\end{lstlisting}\n\\caption{\n    A simple extension to GHC's numeric hierarchy for vector arithmetic.\n    A vector space is a special type of number---{\\ttfamily (+)} represents vector addition, and {\\ttfamily (*)} represents elementwise multiplication---that has an associated {\\ttfamily Scalar} type and the ability to perform scalar multiplication with {\\ttfamily (.*)}.\n    A Hilbert space is a vector space with dot products.\n}\n\\label{code:vector}\n\\end{figure}\n\n%Unfortunately, this function is not homogeneous due to the application of a type family in the return type.\n%So we cannot use the construction of Section \\ref{sec:homogeneous} to generate an AST for this function.\n%In this section, we introduce the more general notion of heterogeneous type classes and functions.\n%These concepts are called heterogeneous because they allow the construction of ASTs over multiple types through the use of type families.\n\n\\begin{defn}\nWe call a type class heterogeneous if:\n\\begin{enumerate}\n\\item\nit has a single parameter of kind |Type|; and\n\\item\nthe class's constraints contain only heterogeneous type classes applied either directly to the parameter \\emph{or to a type family applied to a parameter}.\n\\end{enumerate}\nFor example, every homogeneous type class is also heterogeneous.\nThe type classes in Figure 2 are all heterogeneous, but not homogeneous.\n%Multiparameter type classes are not heterogeneous.\n\\end{defn}\n\n\\begin{defn}\nWe call a function heterogeneous if:\n\\begin{enumerate}\n\\item\nthere is exactly one type variable in the signature, which we denote by |a|;\n\\item\neach of the function's parameters is either\n\\begin{enumerate}\n\\item\n|a|,\n\\item\nconcrete, or\n\\emph{\n\\item\na type family applied to }|a|;\n\\end{enumerate}\n\\item\nthe function's return type is either |a| \\emph{or a type family applied to} |a|; and\n\\item\nthe constraints contain only heterogeneous type classes applied to |a| \\emph{or type family applied to} |a|.\n\\end{enumerate}\nAll homogeneous functions are heterogeneous.\nThe |logLoss| function is heterogeneous but not homogeneous.\n\nHeterogeneous functions come in two types.\nType 0 functions have no type family applications in the return type.\nFor example, |(.*)| is a type 0 function.\nType 1 functions have one type family application in the return type.\nFor example, |dotProduct| is a type 1 function.\\footnote{\nIn general, a type $n$ function has $n$ type family applications in the return type.\nThe techniques in this section can be used to support type $n$ functions for arbitrary $n$,\nbut for simplicity, we restrict ourselves to just type 0 and 1 functions.\n}\n\\end{defn}\n\n\\begin{note}\nThe heterogeneous constructions in this section will use many of the same names as the homogeneous constructions in Section \\ref{sec:homogeneous}.\nUnless its clear from context, we will always be referring to the heterogeneous version of the construction for the remainder of the paper.\nIn the \\homoiconic library, the constructions in this section are contained in the |Heterogeneous.FAlgebra| module.\n\\end{note}\n\n\\subsection{The problems of heterogeneous types}\n\\label{sec:het.probs}\nBefore describing how to construct the heterogeneous ASTs,\nwe will look at three problems that type families introduce to the homogeneous AST construction.\n\n\\begin{problem}[the superclass problem]\nConsider the |Vector| class in Figure \\ref{code:vector}.\nThis class is not homogeneous because of the superclass constraint involving a type family application.\nIf we follow the formulation for making a homogeneous FAlgebra, we get\n\\begin{lstlisting}\ninstance FAlgebra Vector where\n    data Sig Vector a\n        = Sig_dotmul (Scalar a) a\n        | Sig_Vector_Num (Sig Num a)\n        | Sig_Vector_Floating\n            (Sig Floating (Scalar a))\n    runSig (Sig_dotmul s a) = s.* a\n    runSig (Sig_Vector_Num s) = runSig s\n    runSig (Sig_Vector_Floating s) = runSig s\n\\end{lstlisting}\nThis definition does not type check.\nIn the last clause of |runSig|'s definition,\nthe type checker will try to match the |a| type with |Scalar a| (because |s| has type |Sig Floating (Scalar a)| instead of |Sig Floating a|) and fail.\nTo fix this problem, we will need to modify the way we create superclass constructors.\n\\end{problem}\n\n\\begin{problem}[the parameter problem]\nNow consider what happens when we write the |Functor| instance\n\\begin{lstlisting}\ninstance Functor (Sig Vector) where\n    fmap f (Sig_dotmul s a) = Sig_dotmul (f s) (f a)\n    fmap f (Sig_Vector_Num s) = Sig_Vector_Num (f s)\n    fmap f (Sig_Vector_Floating s)\n        = Sig_Vector_Floating (f s)\n\\end{lstlisting}\nHere type checking fails on |fmap|'s first clause in the expression |(f s)|.\nThe function |f| has type |a->b|, but the |s| variable has type |Scalar a|.\nTo fix this problem, we will need a modified |fmap| function.\n\\end{problem}\n\n\\begin{problem}[the return type problem]\nConsider the |Hilbert| class in Figure \\ref{code:vector}.\nThe |dotProduct| function is not homogeneous because of the type family in the return type.\nIf we follow the formulation for making a homogeneous FAlgebra, we get\n\\begin{lstlisting}\ninstance FAlgebra Hilbert where\n    data Sig Hilbert a\n        = Sig_Hilbert_Module (Sig Module a)\n        | Sig_dotProduct a a\n    runSig (Sig_Hilbert_Module s) = runSig s\n    runSig (Sig_dotProduct a1 a2) = dotProduct a1 a2\n\\end{lstlisting}\nHere, type checking fails in the last clause of |runSig|.\nThe return type of |runSig| should be |a|,\nbut |dotProduct| returns a |Scalar a|.\nTo fix this problem, we need to change the way we run a signature.\n\\end{problem}\n\n\\subsection{Dealing with type families}\nTo address these problems, we first need to consider a limitation of GHC's type families.\nConsider the declaration\n\\begin{lstlisting}\nnewtype Wrap1 (t::Type->Type) a = Wrap1 (t a)\n\\end{lstlisting}\nThe list constructor |[]| has kind |Type->Type|,\nso the following expression type checks.\n\\begin{lstlisting}\nWrap1 [1] :: Wrap1 [] Int\n\\end{lstlisting}\nThe |Scalar| type family also has kind |Type->Type|,\nso we would like to use it similarly.\n\\begin{lstlisting}\nWrap1 1 :: Wrap1 Scalar (Vec3 Int)\n\\end{lstlisting}\nUnfortunately, this expression does not type check because GHC requires that type families be fully applied anywhere they appear in a type signature.\nIn this section, we will create a workaround that allows us to pass type families as arguments to types.\\footnote{\n    The {\\ttfamily singletons} package provides a similar construction in Section 4.3 of the packages paper \\cite{eisenberg2015promoting}.\n    %The {\\ttfamily singletons}' construction is more general than the one presented here.\n    Their construction allows for the promotion of ordinary functions to type families,\n    and is therefore more complicated.\n    For ease of presentation, we do not use their construction.\n}\n\nThe first step is to create a new data type for each type family.\nThe naming convention used by \\homoiconic is to put a |T| in front of the family's name.\nFor example, we declare\n\\begin{lstlisting}\ndata TScalar\n\\end{lstlisting}\nfor the type family |Scalar|.\nWe call types created in this way ``tags,''\nand create the following type synonym to refer to them.\n\\begin{lstlisting}\ntype Tag = Type\n\\end{lstlisting}\nWe would get more type safety if |Tag| were introduced as a new kind distinct from |Type|;\nbut this requires open kinds, which is a feature not yet available in GHC.\\footnote{\n    Issue \\#11080 on GHC Trac has an extensive discussion of this feature.\n    See \\url{https://ghc.haskell.org/trac/ghc/ticket/11080}.\n}\n\nNext, we need a way to apply tags to a type as if they were a type family.\nThe |AppTag| type family serves this role.\n\\begin{lstlisting}\ntype family AppTag (t::Tag) (a::Type) :: Type\n\\end{lstlisting}\nThe |t| parameter is the tag representing the type family we want to apply,\nand the |a| parameter is the type to which we want to apply the family.\nThe |Scalar| instance looks like\n\\begin{lstlisting}\ntype instance AppTag TScalar a = Scalar a\n\\end{lstlisting}\nAnd now we can create a modified version of our |Wrap1| type above that works for type families.\n\\begin{lstlisting}\nnewtype Wrap2 (t::Tag) a = Wrap2 (AppTag t a)\n\\end{lstlisting}\n\nFrequently, we will want to deal with not just a single type family application,\nbut rather a sequence of zero or more type family applications.\nWe can represent these applications with kind |[Tag]| using GHC's type level lists.\nThe following type family applies a sequence of tags to a type.\n\\begin{lstlisting}\ntype family AppTags (t::[Tag]) (a::Type) :: Type\ntype instance AppTags '[]       a = a\ntype instance AppTags (x ': xs) a\n    = AppTag x (AppTags xs a)\n\\end{lstlisting}\nFor example, the type\n|AppTags '[TScalar,TScalar] a|\nis equivalent to the type\n|Scalar (Scalar a)|,\nand\n|AppTags '[] a| is equivalent to |a|.\n%\\begin{lstlisting}\n%AppTags '[TScalar,TScalar] a\n%\\end{lstlisting}\n%is equivalent to the type\n%\\begin{lstlisting}\n%Scalar (Scalar a)\n%\\end{lstlisting}\n\nNow we can create an even more powerful wrapper that can handle arbitrary applications of type families.\n\\begin{lstlisting}\nnewtype Wrap3 (t::[Tag]) a = Wrap3 (AppTags t a)\n\\end{lstlisting}\n\n\\subsection{Heterogeneous FAlgebras}\n\nAt last we are ready to see our type class for heterogeneous FAlgebras.\n\\newpage\n\\begin{lstlisting}\nclass FAlgebra alg where\n  data Sig alg (t::[Tag]) a\n\n  runSig0 :: alg a => proxy a\n    -> Sig alg t (AppTags t a)\n    -> AppTags t a\n\n  runSig1 :: alg a => proxy a\n    -> Sig alg (s ': t) (AppTags t a)\n    -> AppTags (s ': t) a\n\n  mapRun\n    :: (forall s. Free (Sig alg') s a -> AppTags s a)\n    -> Sig alg t (Free (Sig alg') t' a)\n    -> Sig alg t (AppTags t' a)\n\\end{lstlisting}\nDon't panic!\nUnderstanding exactly how this class works is not necessary for using the ASTs it generates.\n(To just get a feel for using the heterogeneous ASTs,\nskim the rest of this paper for code snippets containing \\textbf{\\footnotesize\\ttfamily ghci}.)\n\n%We now begin the step-by-step explanation of the heterogeneous |FAlgebra|.\n%The most important difference between the homogeneous and heterogeneous |FAlgebra| class is that the |Sig| data family has been given a new type parameter |t::[Tag]|.\n%This parameter tells us which type families have been applied to the variable |a|.\n%Exactly what this means will become more clear as we see how to create instances of |FAlgebra|.\n\nFirst we discuss how to define instances of the |Sig| family.\nWe will need to use GADTs \\cite{schrijvers2009complete} to ensure the |t| parameter is set correctly.\nAs before, the constructors come in two flavors.\nFor function constructors,\nthe parameters remain exactly the parameters of the function they correspond to.\nThe return type, however, depends on the return type of the function.\nFor type 0 functions (no type family applications in the return type),\nthe |t| parameter is set to |'[]|.\nFor example, the function constructor for |Vector|'s |(.*)| function is\n\\begin{lstlisting}\nSig_dotmul :: Scalar a -> a -> Sig Vector '[] a\n\\end{lstlisting}\nFor type 1 functions (one type family application in the return type),\nthe |t| parameter is the singleton list containing the family's tag.\nFor example, the return type for |Hilbert|'s |dotProduct| function is |Scalar a|,\nso the corresponding function constructor is\n\\begin{lstlisting}\nSig_dotProduct :: a -> a -> Sig Hilbert '[TScalar] a\n\\end{lstlisting}\nUnlike function constructors, superclass constructors are parametric in their |t| parameter.\nSuperclass constructors take a single parameter,\nwhich is the |Sig| of the superclass.\nIf the corresponding constraint does not involve a type family,\nthen the |t| parameter is the same for the superclass and the returned value.\nFor example, the |Num a| constraint in the |Vector| instance gets the constructor\n\\begin{lstlisting}\nSig_Vector_Num :: Sig Num t a -> Sig Vector t a\n\\end{lstlisting}\nIf the class constraint does involve a type family,\nthen we prepend the type family's tag to |t| in the constructor's return type.\nFor example, the |Floating (Scalar a)| constraint in the |Vector| instance gets the constructor\n\\begin{lstlisting}\nSig_Vector_Floating\n  :: Sig Floating t a -> Sig Vector (TScalar ': t) a\n\\end{lstlisting}\nThese changes to the |Sig| type are the core of the differences between heterogeneous and homogeneous |FAlgebra|s.\nThere will be many changes to all of the other constructions,\nbut they are all a result of these changes to the signature.\n\nThe |runSig| function tells us how to evaluate the signature of an FAlgebra.\nIt has been split into two functions:\n|runSig0| is for running type 0 functions (no type family in the return type),\nand |runSig1| is for running type 1 functions (one type family in the return type).\nCalling the wrong |run| function will result in a runtime error,\nbut our construction of the heterogeneous free monad (in Section \\ref{sec:het.eval}) will make this impossible.\n|runSig0| works just like the homogeneous |runSig|,\nbut has a more complicated type signature due to the addition of the |t| parameter to |Sig|.\nRecall that the |t| type variable represents the type families that have already been applied to the signature;\nso when we run the |Sig|, the result needs to reflect those applications.\nThus, the parameter to |runSig0| is |Sig alg t (AppTags t a)|,\nand the return type is |AppTags t a|.\nBecause the |a| type variable appears only inside type family applications,\nwe need the |proxy a| argument to avoid an ambiguous type.\nTo implement the |runSig0| function, function constructors recursively call |runSig0| on their argument (with an appropriate |Proxy| parameter representing the type family application in the constraint);\ntype 0 function constructors are evaluated exactly as in the homogeneous case,\nand type 1 function constructors are not evaluated at all because there is no way to make them type check.\nFor example, here is |Vector|'s |runSig0| function\n\\begin{lstlisting}\nrunSig0 _ (Sig_Vector_Num s)\n    = runSig0 (Proxy::Proxy a) s\nrunSig0 _ (Sig_Vector_Floating s)\n    = runSig0 (Proxy::Proxy (Scalar a)) s\nrunSig0 _ (Sig_dotmul s a) = s.*a\n\\end{lstlisting}\nand |Hilbert|'s |runSig0| function\n\\begin{lstlisting}\nrunSig0 _ (Sig_Hilbert_Vector s)\n    = runSig0 (Proxy::Proxy a) s\n\\end{lstlisting}\nThe return type of |runSig1| contains an extra |Tag| applied to it that the content of |Sig| does not have.\nThis lets us evaluate type 1 functions.\nTo implement |runSig1|, superclass constructors get called recursively as before,\nbut this time only type 1 functions can be evaluated,\nand type 0 functions will not type check.\nHere are the |runSig1| functions for |Vector| and |Hilbert|.\n\\begin{lstlisting}\nrunSig1 _ (Sig_Vector_Num s)\n    = runSig0 (Proxy::Proxy a) s\nrunSig1 _ (Sig_Vector_Floating s)\n    = runSig0 (Proxy::Proxy (Scalar a)) s\n\nrunSig1 _ (Sig_Hilbert_Vector s)\n    = runSig1 (Proxy::Proxy a) s\nrunSig1 _ (Sig_dotproduct a1 a2) = dotproduct a1 a2\n\\end{lstlisting}\n\nThe last component of the |FAlgebra| is the |mapRun| function.\nSince our new |Sig| type cannot be made an instance of |Functor|\n(see problem 2 in Section \\ref{sec:het.probs}),\nthis function performs the role that |fmap| performed in the homogeneous FAlgebras.\nThat is, it will allow recursion over the AST.\nWe will discuss the function in more detail in Section \\ref{sec:het.eval} when we discuss evaluating ASTs.\n%Before we get to that,\n%we'll discuss how to construct and show the ASTs.\n\n\\subsection{Constructing the AST}\n\nTo construct an AST out of the |Sig| functor requires a heterogeneous version of the free monad.\nIt is defined as\n\\begin{lstlisting}\ndata Free (f::[Tag]->Type->Type) (t::[Tag]) a where\n  Free1::f (s ':t)(Free f t a)->Free f (s ':t) a\n  Free0::f      t (Free f t a)->Free f      t  a\n  Pure ::AppTags t a -> Free f t a\n\\end{lstlisting}\nand the corresponding AST is\n\\begin{lstlisting}\ntype AST alg t a = Free (Sig alg) t a\n\\end{lstlisting}\nThere are two major changes in the heterogeneous free monad.\nFirst, the kind of the |Free| type constructor has changed.\nWe've added an additional parameter |t::[Tag]| that represents the type families that need to get applied to |a| to evaluate the syntax tree.\nThe type signature of the |runAST| function (discussed in detail in Section \\ref{sec:het.eval}) makes this clear.\n\\begin{lstlisting}\nrunAST :: (FAlgebra alg, alg a)\n    => Free (Sig alg) t a -> AppTags t a\n\\end{lstlisting}\nNotice that the return type applies |t| to |a|.\nChanging the type of |t| changes the type we get when evaluating the AST.\n\nThe second change is that there are now three constructors instead of two.\nThe |Pure| constructor again represents leaves in the AST.\nThese leaves now have type |AppTags t a| instead of just |a| in order to accommodate the modified return type of |runAST|.\nThe |Free0| and |Free1| constructors represent branches in the AST.\nThese branches correspond to type 0 and type 1 functions respectively.\nNotice that in type 1 branches, all of the subtrees have a different type than the tree itself.\n\nAn example should illustrate the relationship between the three constructors.\nConsider the expression\n\\begin{lstlisting}\nexp (dotProduct (Vec3 1 2 3) (Vec3 2 3 4))\n\\end{lstlisting}\n|Vec3| is an instance of |Hilbert|, so we can create a corresponding AST using |Hilbert|'s |FAlgebra| instance.\n\\begin{lstlisting}\nexpr1 :: AST Hilbert '[TScalar] (Vec3 Double)\nexpr1 = Free0\n  ( Sig_Hilbert_Vector\n    ( Sig_Vector_Floating\n      ( Sig_exp\n        ( Free1\n          ( Sig_dotProduct\n            ( Pure (Vec3 1 2 3)\n              :: AST Hilbert '[] (Vec3 Double)\n            )\n            ( Pure (Vec3 2 3 4)\n              :: AST Hilbert '[] (Vec3 Double)\n            )\n          )\n          :: Sig Hilbert '[TScalar]\n            (AST Hilbert '[] (Vec3 Double))\n        )\n        :: AST Hilbert '[TScalar] (Vec3 Double)\n      )\n      :: Sig Hilbert '[TScalar]\n        (AST Hilbert '[TScalar] (Vec3 Double))\n    )\n    :: Sig Hilbert '[TScalar]\n      (AST Hilbert '[TScalar] (Vec3 Double))\n  )\n\\end{lstlisting}\nThe type signatures on each expression are labeled to emphasize how the type of the tree changes with the application of the |Free0| and |Free1| constructors.\nSpecifically, because the dot product is a type 1 function (its return type is |Scalar a|),\nthe |Sig_dotProduct| function gets embedded into the AST using the |Free1| constructor.\nThis changes the type of the tree by adding |TScalar| to the list of tags.\nWhen we evaluate the resulting tree, we will get a scalar,\nso it is now safe to perform scalar operations.\nThe |exp| function is an example of a scalar operation.\nThe design of the |Sig_Vector_Floating| constructor lets us embed the |Sig_exp| constructor into the tree only because of the |TScalar| tag generated by |Sig_dotProduct|.\nSince |Sig_exp| is a type 0 function,\nit is embedded into the tree using the |Free0| constructor.\n\nWe can make |AST| an instance of any heterogeneous type class.\nThis is a two step process.\nFirst, we generate appropriate type instances.\nFor each type family used in a heterogeneous type class,\ndefine a type instance for |AST| that adds the family's tag to the list of tags.\nFor example, the |Scalar| of an |AST| is given by\n\\begin{lstlisting}\ntype Scalar (AST alg t a) = AST alg (TScalar ': t) a\n\\end{lstlisting}\n\n%The main difference is that we will need a new |View| class for converting between |Sig|s.\nThe next step is to define an appropriate |View| class.\nThe heterogeneous |View| class not only converts the |alg| parameter, but also the |t| parameter.\n\\begin{lstlisting}\nclass (FAlgebra alg1, FAlgebra alg2)\n    => View alg1 t1 alg2 t2 where\n    embedSig\n        :: Sig alg1 t1 a -> Sig alg2 t2 a\n    unsafeExtractSig\n        :: Sig alg2 t2 a -> Sig alg1 t1 a\n\\end{lstlisting}\n%Instances of |View| should satisfy the property that\n\nArmed with these |View| instances, creating heterogeneous type class instances is easy.\nIt follows the same pattern as the homogeneous case,\nexcept that type 0 functions are embedded in the tree using the |Free0| constructor,\nand type 1 functions are embedded using the |Free1| constructor.\nThe |Vector| instance is shown below.\n\\begin{lstlisting}\ninstance\n    ( View Vector '[] Num '[]\n    , View Vector '[] Floating '[TScalar]\n    , View Vector '[] Fractional '[TScalar]\n    , View Vector '[] Num '[TScalar]\n    ) => Vector (AST alg t a) where\n    (.*) s a = Free0 $ embedSig $ Sig_dotmul s a\n\\end{lstlisting}\nAnd here is the |Hilbert| instance.\n\\begin{lstlisting}\ninstance\n    ( View Hilbert '[] Vector '[]\n    , View Hilbert '[] Num '[]\n    , View Hilbert '[] Floating '[TScalar]\n    , View Hilbert '[] Fractional '[TScalar]\n    , View Hilbert '[] Num '[TScalar]\n    => Hilbert (AST alg t a) where\n    dotProduct a1 a2\n        = Free1 $ embedSig $ Sig_dotProduct a1 a2\n\\end{lstlisting}\n\nThese instances let us easily create ASTs.\nThe only difference from the homogeneous case is that we must now explicitly tag the type signature to indicate how the return type of the expression relates to the AST's root type.\nFor example, here's an expression over |Double|s.\n\\begin{lstlisting}\nexpr1 :: AST Floating '[] Double\nexpr1 = (1+2)+3 :: AST Floating '[]\n\\end{lstlisting}\nAnd here is the same expression expressed as the |Scalar| of |Vec3 Double|.\n\\begin{lstlisting}\nexpr2 :: AST Hilbert '[TScalar] (Vec3 Double)\nexpr2 = (1+2)+3\n\\end{lstlisting}\nWe will see more complex examples in the next section's discussion of showing ASTs.\n\n\\subsection{Showing the AST}\n\nTo convert the heterogeneous AST into a |String|,\nwe need a |Show| instance for for |Free| and a |Show| instance for each |Sig|.\nAs is typical for heterogeneous ASTs,\nwriting these instances is painful,\nbut using them is easy.\n\nThe |Show| instance for |Free| is given below.\n\\begin{lstlisting}\ninstance\n    ( Show      (AppTags t a)\n    , Show      (f t (Free f t a))\n    , ShowUntag (f t (Free f t a))\n    ) => Show (Free f t a) where\n    show (Pure  a ) = show a\n    show (Free0 f0) = \"(\"++show f0++\")\"\n    show (Free1 f1) = \"(\"++show f1++\")\"\n\\end{lstlisting}\nThe instance is similar to the homogeneous instance except for the |ShowUntag| type family in the constraints.\nThis family provides the |Show| instance needed to apply |show| to the |f1| variable.\nThis variable is declared in the |Free1| constructor,\nbut because of this constructor's definition,\nthe type of |f1| is not mentioned anywhere in the instance signature!\nThe |ShowUntag| function extracts the type of |f1| from instance parameter |t| when it is available and provides a |Show| instance.\nWhen the type cannot be extracted, GHC is able to prove that the pattern match on |Free1| always fails, and so no constraint is needed.\nThe |ShowUntag| family is defined as:\n\n\\newpage\n\\begin{lstlisting}\ntype family ShowUntag (f::Type) :: Constraint where\n    ShowUntag (f (s ': t) (Free f (s ': t) a))\n        = Show (f (s ': t) (Free f t a))\n    ShowUntag a = ()\n\\end{lstlisting}\n\nThe |Show| instance for the |Sig| type follows the same pattern as the homogeneous case.\nFor each function constructor,\nsimply show the constructor's arguments connected in an appropriate way by the function's name.\nFor each superclass constructor, recursively call show on the superclass.\nAs an example, |Vector|'s show instance is given below.\n\\begin{lstlisting}\ninstance (Show a, Show (Scalar a))\n    => Show (Sig Vector t a) where\n    show (Sig_Vector_Num s) = show s\n    show (Sig_Vector_Floating s) = show s\n    show (Sig_dotmul a1 a2)\n        = show a1++\".*\"++show a2\n\\end{lstlisting}\nNotice that we had to add the |Show (Scalar a)| constraint above because the |a1| variable in the last line has type |Scalar a|.\nIn general, whenever a function constructor contains a parameter with a type class,\nwe will need to add a |Show| constraint for the corresponding class.\n\nUnfortunately, we can't yet use these two instances to show an |AST|.\nWhen we call |show| on an expression of type |AST Vector t a|,\nthe constraint solver looks for a |Show| instance of |Scalar (AST Vector t a)|.\nThis sends the constraint solver into a loop.\nRecall that we defined\n\\begin{lstlisting}\ntype Scalar (AST alg t a)\n    = AST alg (TScalar ': t) a\n\\end{lstlisting}\nSo in order to satisfy the |Show| instance for |AST Vector t a|,\nthe constraint solver needs a |Show| instance for |AST Vector '[TScalar] a|,\nwhich in turn needs a |Show| instance for |AST Vector '[TScalar,TScalar] a|,\nand so on.\nThe nesting of these |TScalar| tags continues indefinitely.\nThe solution is to create the following overlapping instance.\n\\begin{lstlisting}\ninstance {-#OVERLAPS#-} Show\n    (Sig Module (t1 ': t2 ': t3 ': ts) a) where\n    show _ = \"<<overflow>>\"\n\\end{lstlisting}\nOnce there are at least three |TScalar|s in the list of tags,\nthis new instance becomes more specific,\nand is thus selected by GHC.\nSince this instance has no constraints,\nthat ends the recursion.\nOf course there is nothing special about the choice of three elements in the list above;\nthe only requirement is that the list be longer than any sequence of type family applications your program actually uses.\n\nNow that these |Show| instances are written,\nactually showing expressions is straightforward.\nAs in the homogeneous case,\nyou just have to add the appropriate type signature to the expression.\n\\begin{lstlisting}\nghci> logLogistic 3 :: AST Floating '[] Double\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (fromInteger 3))))))\n\\end{lstlisting}\nThis same expression can be shown via the |Hilbert| AST as well.\n\\begin{lstlisting}\nghci> logLogistic 3 :: AST Hilbert '[TScalar] (Vec3 Double)\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (fromInteger 3))))))\n\\end{lstlisting}\nIn order to display functions,\nwe create the |Var| type as before.\n\\begin{lstlisting}\nnewtype Var a = Var String\n\\end{lstlisting}\nWhen we define values of type |Var|,\nwe want them to be usable in all expressions regardless of the tag.\nThis means they need to be parametric in both the |alg| and |t| parameters.\nRecall that the argument to the |Pure| construct takes type |AppTags t a|,\nso in order to embed a |Var| into an AST using |Pure|,\nwe need to guarantee that |AppTags t Var~Var|.\\footnote{The {\\ttfamily mkFAlgebra} function generates type instances for {\\ttfamily Var} for all type families used in a heterogeneous class.\nAll of these instances satisfy the property that {\\ttfamily AppTags t Var~Var},\nbut GHC is unable to prove that all the instances satisfy this property.\nThat is why the constraint is explicitly added to the type signature of each {\\ttfamily varN} variable.\n}\n\\begin{lstlisting}\nvar1 :: AppTags t Var~Var => AST alg t Var\nvar1 = Pure $ Var \"var1\"\n\nvar2 :: AppTags t Var~Var => AST alg t Var\nvar2 = Pure $ Var \"var2\"\n\nvar3 :: AppTags t Var~Var => AST alg t Var\nvar3 = Pure $ Var \"var3\"\n\\end{lstlisting}\n%stopzone\n\n\\begin{lstlisting}\nghci> logLogistic var1 :: AST Floating '[] Var\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate var1)))))\n\\end{lstlisting}\nRecall that |Floating| appeared as a constraint for the |Hilbert| class.\nSo you might think we could specialize the expression above to the |Hilbert| AST.\n\\begin{lstlisting}\nghci> logLogistic var1 :: AST Hilbert '[] Var\nNo instance for\n    (View Floating ('[] Tag) Hilbert ('[] Tag))\n\\end{lstlisting}\n%\\begin{lstlisting}\n%ghci> logLogistic var1 :: AST Hilbert '[] Var\n%\\end{lstlisting}\n%This code give us an error message about the following missing instance.\n%\\begin{lstlisting}\n%View Floating ('[] Tag) Hilbert ('[] Tag)\n%\\end{lstlisting}\nJust because something implements |Hilbert| does not guarantee that it implements |Floating| as well.\nIt only guarantees that its |Scalar| implements |Floating|.\nThe following modified expression works just fine.\n\\begin{lstlisting}\nghci> logLogistic var1 :: AST Hilbert '[TScalar] Var\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate var1)))))\n\\end{lstlisting}\nNow we demonstrate this technique works with the |logLoss| function,\nwhich is heterogeneous but not homogeneous.\n\\begin{lstlisting}\nghci> logLoss var1 var2 :: AST Hilbert '[TScalar] Var\n(log ((fromInteger 1)/((fromInteger 1)+(exp\n    (negate (dotProduct var1 var2))))))\n\\end{lstlisting}\nAnd finally, we can have arbitrarily complex expressions in both the scalar and vector section of an expression.\n\\begin{lstlisting}\nghci> (var1+exp var2).*(var3+var1.*var3)\n    :: AST Hilbert '[] Var\n((var1+(exp var2)).*(var3+(var1.*var3)))\n\\end{lstlisting}\nNote that in the above expression, |var1| and |var2| are used as scalars whereas |var3| is used as a vector.\n %(var1+exp var2).*var3 :: AST Hilbert '[] Var\n%((var1+(exp var2)).*var3)\n\\subsection{Evaluating the AST}\n\\label{sec:het.eval}\n\nOur last step in demonstrating the homoiconicity of heterogeneous functions is to evaluate their ASTs.\nWe will first discuss the |runAST| function.\nIn so doing we will see the motivation for the |mapRun| function from the definition of the heterogeneous |FAlgebra| type.\nFinally, we'll see some examples.\n\nThe |runAST| function is shown below.\n\\begin{lstlisting}\nrunAST :: forall alg t a. (FAlgebra alg, alg a)\n    => Free (Sig alg) t a -> AppTags t a\nrunAST (Pure  a) = a\nrunAST (Free0 s)\n    = runSig0 (Proxy::Proxy a) $ mapAST runAST s\nrunAST (Free1 s)\n    = runSig1 (Proxy::Proxy a) $ mapAST runAST s\n\\end{lstlisting}\nIt has three differences from the homogeneous case.\nFirst, (as we've already discussed)\nthe type signature is different.\nThe |t| parameter to |AST| tracks the type represented by the tree.\nSo the type from running the tree must apply |t| to |a|.\nSecond, since the free monad has an additional constructor,\nthe |runAST| function needs an additional clause pattern matching against this constructor.\nThe clauses for the |Free0| and |Free1| constructors are essentially the same though.\nFinally, we use the |mapRun| function instead of |fmap| for recursion.\nRecall the signature of |mapRun|.\n\\begin{lstlisting}\nmapRun\n  :: (forall s. Free (Sig alg') s a -> AppTags s a)\n  -> Sig alg t (Free (Sig alg') t' a)\n  -> Sig alg t (AppTags t' a)\n\\end{lstlisting}\nThis function uses |Rank2Types| to ensure that the function we are mapping can be applied to any syntax tree no matter what type it represents.\n\nAs in the homogeneous case,\nwhen we evalaute an AST for an expression,\nwe get the same result as if we had just evaluated the expression directly.\n\\begin{lstlisting}\nghci> logLoss (Vec3 1 2 3) (Vec3 2 3 4)\n-2.0611536942919273e-9\n\\end{lstlisting}\n\n\\begin{lstlisting}\nghci> runAST (logLoss (Vec3 1 2 3) (Vec3 2 3 4)\n    :: AST Hilbert '[TScalar] (Vec3 Double))\n-2.0611536942919273e-9\n\\end{lstlisting}\nWe've finally demonstrated that heterogeneous functions are also homoiconic.\n\n\\subsection{Boilerplate}\n\nConstructing heterogeneous FAlgebras is a pain.\nThe \\homoiconic library provides a |mkFAlgebra| function in the |Heterogeneous.FAlgebra| module to automate this process.\n\n\\section{Conclusion}\n\nThe \\homoiconic library lets you construct ASTs from type classes.\nThe construction is easiest for homogeneous type classes and more difficult for heterogeneous type classes.\nBut in either case, \\homoiconic provides Template Haskell functions to shield you from the details and boilerplate.\nYour existing Haskell code bases likely include many type classes on which these constructions work.\n\n\n%\\subsection{Transforming heterogeneous functions}\n%\n%In order to perform program transformations on heterogeneous functions,\n%we need two things.\n%First, we need convenient way to pattern match.\n%The construction is identical to the construction presented in Section \\ref{sec:patternmatch}.\n%For each function heterogeneous function in a heterogeneous type class,\n%we get a pattern that is the name of the function prefixed by |AST_|.\n%\n%For example, recall the |testFunc1| function we defined before.\n%\\begin{lstlisting}\n%testFunc1 :: Floating a => a -> a\n%testFunc1 = log (exp a)\n%\\end{lstlisting}\n%We wrote a program transformation that removed the |log| and |exp| function calls.\n%The same program transformation works, but with a modified type signature to account for the heterogeneous ASTs.\n%\\begin{lstlisting}\n%logexpAST3 :: View Floating '[] alg t\n    %=> AST alg t a -> AST alg t a\n%logexpAST3 (AST_log (AST_exp a)) = a\n%\\end{lstlisting}\n%Finally, we need a way to perform recursion.\n%\n%\\begin{lstlisting}\n%mapTrans :: (forall s. View Floating '[] alg s => AST alg s a -> AST alg s a)\n    %-> Sig alg t (AST alg t a)\n    %-> Sig alg t (AST alg t a)\n%mapTrans f = undefined\n%\\end{lstlisting}\n%\n%\\begin{lstlisting}\n%\\end{lstlisting}\n\n%\\section{Conclusion}\n%\n%Heterogeneous FAlgebras probably seem scary at this point.\n\n%The \\homoiconic package gives Haskell programmers a new metaprogramming tool based on FAlgebras.\n%Homogeneous FAlgebras are closely related\n%\n%Heterogeneous FAlgebras are scary to construct,\n%but \\homoiconic provides a |mkFAlgebra| function that generates the obnoxious details for you.\n%Most of the pain from the heterogeneous FAlgebra type class is due to short comings in the way GHC handles type families.\n\n%It's possible that some future development in the type system will make heterogeneous FAlgebras more pleasant to work with.\n\n%In this paper, we've provided a slight twist on the homogeneous FAlgebra construction that Haskellers know and love and introduced the heterogeneous FAlgebra to the community.\n%Both of these structures give us a new form of metaprogr\n%Heterogeneous FAlgebras are a pain to define in Haskell.\n%But they're not that bad to work with.\n%Essentially the only difference is that we must tag our ASTs with the appropriate type families.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%\\appendix\n%\\section{Appendix Title}\n%\n%This is the text of the appendix, if you need one.\n%Most notably, it is not generic.\n%\n%\\acks\n%\n%Acknowledgments, if needed.\n%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\bibliographystyle{abbrvnat}\n\\bibliography{paper}\n\n\n\\end{document}\n", "meta": {"hexsha": "db581295956d337fc092c50eb0cef90fe5370fbe", "size": 80766, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/paper.tex", "max_stars_repo_name": "mikeizbicki/topology", "max_stars_repo_head_hexsha": "be44c481a904a4aeddace8b3828876324fb9eab6", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2016-06-07T17:31:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-19T09:17:25.000Z", "max_issues_repo_path": "paper/paper.tex", "max_issues_repo_name": "mikeizbicki/topology", "max_issues_repo_head_hexsha": "be44c481a904a4aeddace8b3828876324fb9eab6", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-05-15T01:50:46.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-16T01:55:35.000Z", "max_forks_repo_path": "paper/paper.tex", "max_forks_repo_name": "mikeizbicki/topology", "max_forks_repo_head_hexsha": "be44c481a904a4aeddace8b3828876324fb9eab6", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-11-09T12:16:17.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-03T10:07:53.000Z", "avg_line_length": 41.3548387097, "max_line_length": 271, "alphanum_fraction": 0.7396924448, "num_tokens": 20450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.4098156312804247}}
{"text": "\\section{Combining isochrone fitting with Gyrochronology: Motivation}\n\\label{section:motivation}\n\nIn order to demonstrate why a combination of gyrochronology and isochrone\nfitting can provide more precise ages than either method used in isolation, we\ncalculated the information provided by each method for a range of stellar\nmasses, ages and evolutionary stages.\n\nAccording to observations of cluster stars and the Sun, the decrease in\nrotation period with time is roughly proportional to the inverse square root\nof age, $\\frac{dP_{\\mathrm{rot}}}{dt} \\propto \\mathrm{Age}^{-n}$, where\nn$\\sim$0.5.\nThis corresponds to a large rate of change relative to typical rotation\nperiod measurement uncertainties.\nFor example, the Sun's rotation period is currently decreasing at a rate of\naround 3 days per billion years \\citep[unless it has already stopped spinning\ndown, \\eg][]{vansaders2016}, and the 1 billion year-old Sun\nspun down at a rate of around 6 days per billion years.\nThese are relatively large changes compared with the average uncertainties on\nrotation period measurements: the median rotation period uncertainty in the\n\\citet{mcquillan2014} catalog is around 0.1 days.\nIn contrast, the temperature of a K dwarf changes by about 20 K every billion\nyears which is small compared to typical observational uncertainties of 20-100\nK.\nRotational isochrones, or `gyrochrones' provide much more {\\it information}\nabout age than traditional isochrones.\nThe difference in information conveyed by rotation vs \\teff\\ and $L$ can be\nquantified by calculating the time derivatives of a star's observables.\nThe rate of change of \\teff\\ and $L$ dictates the minimum theoretically\nachievable uncertainty on an age inferred via isochrone fitting, given some\nobservational uncertainties.\nSimilarly, the rate of change of rotation period dictates the minimum\nachievable uncertainty on an age inferred via gyrochronology.\nIn order to quantify the minimum theoretical uncertainty on ages calculated\nvia isochrone fitting and gyrochronology, we calculated the Fisher information\nfor the MIST isochrones \\citep{paxton2011, paxton2013, paxton2015, dotter2016,\nchoi2016, paxton2018} and an empirical polynomial gyrochronology model we fit\nto the Praesepe cluster.\nThe Fisher information quantifies the amount of information that an observable\nimparts onto an unknown parameter.\nIn the case of isochrone fitting on a CMD using \\Gaia\\ data, the observables\nare \\Gaia\\ absolute magnitude $M_G$ and color, \\gcolor\\ and the parameter is\nage, or time, $t$.\nThe Fisher information is the variance of the parameter, $t$, given the\ncovariance of the observables and their derivatives with respect to $t$.\nThe inverse covariance matrix of the parameters (in this case we have just one\nparameter, age or time, $t$), given the covariance matrix of the data,\n${\\bf y} = [M_G, G_{BP} - G_{RP}]$, is given by the following equation,\n\\begin{equation}\n    C_{\\mathrm{Age}}^{-1} = \\left[\\frac{d{\\bf y}}{dt}\\right]^T\n    C_{\\bf y}^{-1} \\left[\\frac{d{\\bf y}}{dt}\\right].\n\\end{equation}\nSince we just have one parameter, $C_\\mathrm{Age}^{-1}$ is a scalar, the\ninverse variance of age, $\\sigma_{\\mathrm{Age}}^{-2}$.\nIn order to calculate the age uncertainty from the MIST isochrones, we\ncalculated numerical derivatives of $\\frac{dG}{dt}$,\nand $\\frac{d(G_{BP} - G_{RP})}{dt}$ at every point on the MIST model grids.\nWe then calculated the isochronal age uncertainty, $\\sigma_{\\mathrm{Age}}$ at\nevery point on the grid.\nFigure \\ref{fig:iso_fisher} shows Solar-metallicity MIST isochrones, colored\nby $\\sigma_{\\mathrm{Age}}$.\n\nFigure \\ref{fig:iso_fisher}\\footnote{Figures \\ref{fig:iso_fisher} and\n\\ref{fig:gyro_fisher} were generated in a {\\it Jupyter} notebook available at\nthe following url:\n\\url{https://github.com/RuthAngus/stardate/blob/master/paper/code/Fisher_information.ipynb}}\nshows the minimum theoretical absolute age uncertainty,\n$\\sigma_{\\mathrm{Age}}$ (left panel), calculated using typical uncertainties\non \\Gaia\\ absolute magnitude, $M_G$, of $\\pm$0.05 and a color spread of 0.05\nthat (conservatively) accounts for scatter induced by metallicities ranging\nfrom -0.25 to +0.25 dex.\nThese uncertainties are represented as black errorbars in the top right\ncorner.\nThe typical \\Gaia\\ uncertainties are $0.5$ in both $M_G$ and \\gcolor.\nThese estimates are based on a calculation of the median uncertainty on \\Gaia\\\nabsolute G-magnitude of cool stars which is dominated by the parallax\nuncertainty.\nWe assumed the same uncertainty on \\gcolor.\nThe minimum uncertainty on isochronal age ranges from around 10 million years\nat MS turn off (upper left yellow area) to around the age of the Universe for\nK dwarfs (middle to lower-right blue area).\nThe minimum {\\it relative} age uncertainty,\n$\\sigma_{\\mathrm{Age}}/\\mathrm{Age} \\times 100$, plotted in the right-hand\npanel ranges from less than 1\\% for old MS turn off stars with ages\naround 13 Gyr and age uncertainties less than 0.1 Gyr, up to tens-of-thousands\nof percent for the youngest K and M dwarfs with unconstrained ages.\n\nWe also calculated the Fisher information for a {\\it combined isochronal and\ngyrochronology model.}\nIn this case we effectively had four observables: $M_G$ and \\gcolor,\ndetermined by the MIST isochrones; and $P_{\\mathrm{rot}}$ (rotation period)\nand \\gcolor\\ {\\it again}, this time determined by the gyrochronology model.\nWe used a simple gyrochronology model, calibrated by fitting a fourth-order\npolynomial in rotation period-\\Gaia\\ color space and a first order polynomical\nin rotation period-age space to the 650 Myr Praesepe cluster and the Sun,\nonly.\nThis model is described in more detail later in this section.\nWe calculated analytic derivatives for $\\frac{dP_{\\mathrm{rot}}}{dt}$ and\n$\\left(\\frac{d(G_{BP} - G_{RP})}{dt}\\right)_{\\mathrm{gyro}}$ and combined\nthese with the numerical derivatives of $\\frac{dG}{dt}$ and\n$\\left(\\frac{d(G_{BP} - G_{RP})}{dt}\\right)_{\\mathrm{iso}}$ in order to\ncalculate the total age uncertainty, $\\sigma_{\\mathrm{Age~(iso~\\&~gyro)}}$.\nFigure \\ref{fig:gyro_fisher} shows Solar-metallicity MIST isochrones, colored\nby $\\sigma_{\\mathrm{Age~(iso~\\&~gyro)}}$.\nThe results are presented the same way as figure \\ref{fig:iso_fisher} however,\nfigure \\ref{fig:gyro_fisher} shows age uncertainties calculated using\nisochrones {\\it and a polynomial gyrochronology model}.\nThe age uncertainties were calculated using typical \\Gaia\\ $M_G$ and \\gcolor\\\nuncertainties, represented as black errorbars in the top right corner, and\nrotation period uncertainties of 1 day.\nThe minimum theoretical absolute age uncertainty inferred using gyrochronology\nand isochrone fitting simultaneously, $\\sigma_{\\mathrm{Age~(iso~\\&~gyro)}}$\n(left panel of figure \\ref{fig:gyro_fisher}), ranges from tens of millions of\nyears for stars at MS turn off to a few billion years (up to around 3 Gyr for\nold G dwarfs).\nThe very precise ages at MS turn off are still provided by isochrone fitting\n-- the incredible precision achievable with isochrone fitting at MS turn off\ndominates over the precision provided by gyrochronology.\nOn the MS however, gyrochronology provides extremely precise ages and its\nprecision dominates over isochrone fitting.\nThe gyrochronology model used to calculate the Fisher information is not\nappropriate for stars turning off the MS as it does not account for a rapid\ndecrease in rotation period that may be caused by the stellar radius\nincreasing \\citep[see][]{vansaders2013}.\n% However, it provides an upper limit on $\\sigma_{\\mathrm{Age,~gyro}}$ which is\n% is, in any case, dominated by $\\sigma_{\\mathrm{Age,~iso}}$.\nThe right-hand panel of figure \\ref{fig:gyro_fisher} shows the {\\it relative}\nage uncertainty achievable with joint isochronal and gyrochronal age\ninference.\nRelative age uncertainty,\n$\\mathrm{Age}/\\sigma_{\\mathrm{Age~(iso~\\&~gyro)}}\\times 100$ ranges from less\nthan 1\\% at MS turn off, where isochrones provide precise ages because they\nare widely spaced, to a maximum of around 30\\% for young G dwarfs, where\ngyrochrones are at their most tightly spaced.\nThe dramatic improvement in age precision seen across the MS when\ngyrochronology is used provides the motivation for combining isochrone fitting\nwith gyrochronology.\nThe minimum relative age uncertainty for GKM stars on the MS is typically\naround 20\\% -- gyrochronology predicts precise ages for these kinds of stars.\n20\\% age precision for gyrochronology was also predicted in previous studies.\n\\citep{epstein2014}.\nGyrochronology and isochrone fitting are extremely complementary:\ngyrochronology contributes most of the precision on the MS because rotation\nperiod information dominates over color and luminosity information, however\nit is not applicable to hot stars without deep convection zones\nand evolved stars.\nThese are precisely the stars optimally fitted with isochrone models.\n\\cocomment{This analysis does raise a question however.\nCombining two independent dating methods is useful when both are contributing\ninformation, \\ie\\ near MS turn off, however given that isochrone fitting\nprovides so little information on the MS, is there any point in including it\nthere at all?\nWhy not just abandon isochrone fitting and use gyrochronology exclusively?\nAlthough isochrones and stellar evolution tracks do not provide precise ages\nfor MS stars, they do provide {\\it masses}, and mass is essential for\nobtaining a precise gyrochronal age.\nConversely, gyrochronology can actually enhance mass measurements too by\nproviding a tighter age constraint: since mass and age are weakly correlated,\nthis results in a tighter mass constraint.\nThere are other good reasons to model stars with both isochrones and\ngyrochronology on the MS.\nFirstly, gyrochronology is not applicable to hot stars \\citep[\\teff $\\gtrsim$\n6250,][]{kraft1967} or evolved stars but it is not possible to know whether a\nstar is evolved, or hot and not just reddened, without modelling it.\nModelling stars with isochrones/stellar evolution tracks is required in order\nto know whether gyrochronology is applicable or not.\nSecondly, most gyrochronology models are calibrated to either $B-V$ color\n(most commonly) or mass.\nMass is usually not directly observable, so must be inferred via modelsj and\n$B-V$ is {\\it also} not directly observed for every star.\nFor example, the most widely available colors are now \\gaia\\ \\gcolor\\ colors,\nand most \\Gaia\\ stars do not have $B-V$ colors.\nIn order to calculate gyrochronal ages for stars with {\\it any} apparent\nmagnitudes, not just $B-V$, it is necessary to model stars with isochrones and\ngyrochronology simultaneously.}\n\nAn important caveat of this demonstration is that this is the minimum\ntheoretical precision given the {\\it adopted} gyrochronology model and, since\nthe model used for this calculation does not include intrinsic scatter (which\nis particularly large for young stars), these minimum age uncertainty\ncalculations are over-optimistic, especially for young stars.\nSimilarly, our model does not account for weakened magnetic braking at old\nages \\citep{vansaders2016} so is also optimistic for old dwarfs.\nStill, figures \\ref{fig:iso_fisher} and \\ref{fig:gyro_fisher} provide an idea\nof the improvement provided by gyrochronology over isochrone fitting alone.\n% The Praesepe model\n\nIn order to calculate analytic derivatives of the gyrochronology model, we\nfit a linear model to the Praesepe open cluster and the Sun (see figure\n\\ref{fig:praesepe}.\nWe used a three-dimensional polynomial model to predict age as a\nfunction of \\gaia\\ color and rotation period for Praesepe and the Sun.\nThis model consists of a 4th order polynomial in logarithmic Gaia color:\n\\gcolor, which we write as $C_G$ for simplicity, and a 1st order polynomial (a\nstraight line) in logarithmic age.\nFor this analysis, rotation periods for Praesepe were obtained from\n\\citet{douglas2017} and their \\gaia\\ colors were obtained by crossmatching\ntheir sky-projected positions with the \\gaia\\ DR2 catalog.\n% We used \\gcolor\\ instead of (B-V) because, due to the $\\sim$ billion stars\n% observed by \\gaia, it is now the most abundant and widely available\n% photometric color.\n% Our gyrochronology likelihood function is designed to compare observed\n% rotation period to predicted rotation period.\n% For this reason the gyrochronology model we used must predict rotation period\n% as a function of age and color.\nWhen fitting this gyrochronology model, we chose to make {\\it age} the\ndependent variable because the uncertainties on stellar age are much greater\nthan the uncertainties on rotation period.\nWe fit the following model to Praesepe members:\n\\begin{equation}\n    \\log_{10}(A) = a + b\\log_{10}(C_G) + c\\log_{10}^2(C_G) +\n    d\\log_{10}^3(C_G) + e\\log_{10}^4(C_G) + f\\log_{10}(P)\n\\label{eqn:gyro_age_praesepe}\n\\end{equation}\nwhere $P$ is rotation period in days, $C_G$ is Gaia color, $A$ is stellar age\nin years and the lower case letters are free parameters.\nWe adopted an age for Praesepe of 650 $\\pm$ 100 million years\n\\citep{fossati2008, gossage2018}, a Solar age of 4.56 $\\pm$ 0.01 Gyr\n\\citep{connelly2012}, and a Solar rotation period of 26 days \\citep[][Morris\n\\etal, in prep]{balthasar1986, howe2000}.\nThe Sun's color in the Gaia color is 0.82 \\citep{casagrande2018}.\nWe found best-fit values: $a = 7.37 \\pm 0.03,~b = -1.4 \\pm 0.1,~c = 5.0 \\pm\n0.8,~d = -34 \\pm 3,~e = 66 \\pm 14$, and $f = 1.49 \\pm 0.02$.\nThis model and the data it was fit to are plotted in figure\n\\ref{fig:praesepe}.\nTo be clear, this model was only used to calculate the Fisher information and\nproduce figures \\ref{fig:iso_fisher} and \\ref{fig:gyro_fisher}, because it has\nsimple analytic derivatives.\nSince it was only fit to a single cluster and the Sun it is not generally\napplicable and was not used in any other aspects of the analysis performed in\nthis paper.\nThe gyrochronology model used throughout the rest of the analysis is described\nin section \\ref{section:method} and equation \\ref{eqn:gyro}.\n% The $f$ parameter is the inverse of the slope of the rotation period and age\n% which was originally measured to be around 0.5.\n% Our Praesepe and Sun-only fit results in a slightly steeper age dependence of\n% around 0.67, however this value is likely be\n% We inverted this relation to predict rotation period as a function of color\n% and age,\n% \\begin{equation}\n%     \\log_{10}(P) = \\frac{\\log_{10}(A) - a - b\\log_{10}(C_G) - c\\log_{10}^2(C_G) -\n%     d\\log_{10}^3(C_G) - e\\log_{10}^4(C_G)}{f}.\n% \\label{eqn:gyro_age_praesepe}\n% \\end{equation}\n% Both gyrochronology models of equations \\ref{eqn:gyro} and\n% \\ref{eqn:gyro_age_praesepe} are used to predict the ages of individual\n% Praesepe stars from their rotation periods and apparent magnitudes in section\n% \\ref{section:results}.\n\n\n% \\begin{figure}\n%   \\caption{\n%     This figure shows Solar-metallicity MIST isochrones in \\Gaia\\ absolute\n%     G-band magnitude and Gaia $G_{BP} - G_{RP}$ color.\n%     In the left panel the isochrones are colored by the minimum absolute age\n%     uncertainty at each point on the CMD, calculated using the Fisher\n%     information.\n%     This calculation is based on the typical uncertainties of\n%     \\Gaia\\ $G$-band photometry, and a color spread that covers metallicities\n%     ranging from -0.25 to 0.25 dex (represented by black errorbars in the\n%     upper right).\n%     The Sun's position \\citep{casagrande2018} is indicated with the Solar\\\n%     symbol.\n%     The purple color in the top left corresponds to small age uncertainties,\n%     \\ie\\ good age precision.\n%     Age precision increases as stars begin to turn off the MS.\n%     On the MS however, particularly at low masses, the age precision is poor.\n%     For late K dwarfs, for example, isochrone fitting age uncertainties exceed\n%     the age of the Universe.\n%     This makes sense when you consider that typical \\Gaia\\ uncertaintes on $G$\n%     and $G_{BP} - G_{RP}$ exceed the entire width of the MS, which spans\n%     0.01-14 Gyrs.\n%     Isochrone fitting is not an appropriate age-dating method for MS stars,\n%     especially at low masses.\n%     In the right panel the isochrones are colored by the logarithmic\n%     {\\it relative} age precision at each point in the CMD.\n%     Relative age uncertainties range from 100\\% for the oldest MS GKM stars,\n%     to several thousand percent for the youngest.\n%     These age uncertainties were calculated using the derivatives of $G$ and\n%     $G_{BP} - G_{RP}$ with age, \\ie\\ the rate of change in a star's luminosity\n%     and temperature.\n%     For example, K dwarf temperatures increase at a rate of only around 20 K\n%     per billion years.\n%     The precision with which an age can be measured is related to the\n%     separation between isochrones, which indicate epochs of rapid change\n%     (steep gradients).\n%     This figure was created using the following Jupyter notebook:\n%     \\url{https://github.com/RuthAngus/stardate/blob/master/paper/code/Fisher_information.ipynb}\n%     \\label{fig:fischer_iso}\n% }\n%   \\centering\n%     \\includegraphics[width=1\\textwidth]{iso_fisher.pdf}\n% \\label{fig:iso_fisher}\n% \\end{figure}\n\n% \\begin{figure}\n%   \\caption{\n%     As figure \\ref{fig:iso_fisher}, however in this case the minimum age\n%     uncertainties are calculated based on isochrone fitting and gyrochronology\n%     {\\it combined}.\n%     The isochrones are colored by the minimum relative age uncertainty at each\n%     point on the CMD, calculated using the Fisher information.\n%     This calculation is based on the typical uncertainties of\n%     \\Gaia\\ $G$-band photometry, a color spread that covers metallicities\n%     ranging from -0.25 to 0.25 dex (represented by black errorbars in the\n%     upper right), and Kepler rotation period uncertainties (conservatively\n%     estimated at around 1 day).\n%     In contrast to figure \\ref{fig:iso_fisher}, here the left panel shows the\n%     {\\it logarithmic} absolute age and the right panel shows the linear\n%     relative age.\n%     The isochrones still supply precise ages at the MS turn off (purple, upper\n%     left) however, gyrochronology supplies precise ages on the MS (15 - 25\\%\n%     relative precision).\n%     Gyrochronology and isochrone fitting complement each other and when used\n%     together, all subgiants and MS stars can have ages more precise than 30\\%.\n%     This figure was created using the following Jupyter notebook:\n%     \\url{https://github.com/RuthAngus/stardate/blob/master/paper/code/Fisher_information.ipynb}\n%     \\label{fig:fischer_gyro}\n% }\n%   \\centering\n%     \\includegraphics[width=1\\textwidth]{gyro_fisher.pdf}\n% \\label{fig:gyro_fisher}\n% \\end{figure}\n", "meta": {"hexsha": "8b9ce9fd7c26a2978fa87c4265b1c43a6996e35c", "size": 18593, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/motivation.tex", "max_stars_repo_name": "john-livingston/stardate", "max_stars_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-02-19T13:46:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-31T23:46:36.000Z", "max_issues_repo_path": "paper/motivation.tex", "max_issues_repo_name": "john-livingston/stardate", "max_issues_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-02-21T21:37:05.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-09T10:38:15.000Z", "max_forks_repo_path": "paper/motivation.tex", "max_forks_repo_name": "john-livingston/stardate", "max_forks_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2019-02-11T02:46:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T22:16:53.000Z", "avg_line_length": 57.3858024691, "max_line_length": 97, "alphanum_fraction": 0.7681385468, "num_tokens": 4869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.5428632831725053, "lm_q1q2_score": 0.40981562828708945}}
{"text": "\\lab{Profiling}{Profiling}\n\\objective{Efficiency is essential to algorithmic programming.\nProfiling is the process of measuring the complexity and efficiency of a program, allowing the programmer to see what parts of the code need to be optimized.\nIn this lab we present common techniques for speeding up Python code, including the built-in profiler and the Numba module.\n}\n\n\\section*{Magic Commands in IPython} % ----------------------------------------\n\nIPython has tools for quickly timing and profiling code.\nThese ``magic commands'' start with one or two \\li{\\%} characters---one for testing a single line of code, and two for testing a block of code.\n\\begin{itemize}\n\\item \\li{<p<\\%time>p>}: Execute some code and print out its execution time.\n\\item \\li{<p<\\%timeit>p>}: Execute some code several times and print out the average execution time.\n\\item \\li{<p<\\%prun>p>}: Run a statement through the Python code profiler,\\footnote{{\\color{purple}{\\texttt{\\%prun}}} is a shortcut for \\texttt{cProfile.run()}; see \\url{https://docs.python.org/3/library/profile.html} for details.} printing the number of function calls and the time each takes. We will demonstrate this tool a little later.\n\\end{itemize}\n\n\\begin{lstlisting}\n# Time the construction of a list using list comprehension.\n<g<In [1]:>g> <p<%time>p> x = [i**2 for i in range(int(1e5))]\n<<CPU times: user 36.3 ms, sys: 3.28 ms, total: 39.6 ms\nWall time: 40.9 ms>>\n\n# Time the same list construction, but with a regular for loop.\n<g<In [2]:>g> <p<%%time>p>                      # Use a double %% to time a block of code.\n   <g<...:>g> x = []\n   <g<...:>g> for i in range(int(1e5)):\n   <g<...:>g>     x.append(i**2)\n   <g<...:>g>\n<<CPU times: user 50 ms, sys: 2.79 ms, total: 52.8 ms\nWall time: 55.2 ms>>                  # The list comprehension is faster!\n\\end{lstlisting}\n\n% Use \\li{<p<\\%time>p>} and \\li{<p<\\%timeit>p>} to select fast code snippets, functions, and algorithms (for example, using a list comprehension where possible instead of a regular loop).\n% For the complete list of magic IPython commands, see \\url{http://ipython.readthedocs.io/en/stable/interactive/magics.html}.\n\n\\subsection*{Choosing Faster Algorithms} % ------------------------------------\n\nThe best way to speed up a program is to use an efficient algorithm.\nA bad algorithm, even when implemented well, is never an adequate substitute for a good algorithm.\n\n\\begin{problem} % Triangle path sums from Project Euler.\nThis problem comes from \\url{https://projecteuler.net} (problems 18 and 67).\n\nBy starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.\n\\begin{center}\n\\textbf{\\color{red}{3}}\\\\\n\\textbf{\\color{red}{7}} 4\\\\\n2 \\textbf{\\color{red}{4}} 6\\\\\n8 5 \\textbf{\\color{red}{9}} 3\n\\end{center}\nThat is, $3 + 7 + 4 + 9 = 23$.\n\nThe following function finds the maximum path sum of the triangle in \\texttt{triangle.txt} by recursively computing the sum of every possible path---the ``brute force'' approach.\n\\begin{lstlisting}\ndef max_path(filename=\"triangle.txt\"):\n    \"\"\"Find the maximum vertical path in a triangle of values.\"\"\"\n    with open(filename, 'r') as infile:\n        data = [[int(n) for n in line.split()]\n                        for line in infile.readlines()]\n    def path_sum(r, c, total):\n        \"\"\"Recursively compute the max sum of the path starting in row r\n        and column c, given the current total.\n        \"\"\"\n        total += data[r][c]\n        if r == len(data) - 1:      # Base case.\n            return total\n        else:                       # Recursive case.\n            return max(path_sum(r+1, c,   total), # Next row, same column.\n                       path_sum(r+1, c+1, total)) # Next row, next column.\n\n    return path_sum(0, 0, 0)        # Start the recursion from the top.\n\\end{lstlisting}\n\nThe data in \\texttt{triangle.txt} contains 15 rows and hence 16384 paths, so it is possible to solve this problem by trying every route.\nHowever, for a triangle with 100 rows, there are $2^{99}$ paths to check, which would take billions of years to compute even for a program that could check one trillion routes per second.\nNo amount of improvement to \\li{max_path()} can make it run in an acceptable amount of time on such a triangle---we need a different algorithm.\n\nWrite a function that accepts a filename containing a triangle of integers.\nCompute the largest path sum with the following strategy: starting from the next to last row of the triangle, replace each entry with the sum of the current entry and the greater of the two ``child entries.''\nContinue this replacement up through the entire triangle.\nThe top entry in the triangle will be the maximum path sum.\nIn other words, work from the bottom instead of from the top.\n\n\\begin{center}\n\\begin{tabular}{ccccccc}\n\\begin{tabular}{c}\n3\\\\\n7 4\\\\\n2 4 6\\\\\n\\color{red}{8 5 9 3}\n\\end{tabular}\n&$\\longrightarrow$&\n\\begin{tabular}{c}\n3\\\\\n7 4\\\\\n\\color{red}{10 13 15}\\\\\n\\color{black}{8 5 9 3}\n\\end{tabular}\n&$\\longrightarrow$&\n\\begin{tabular}{c}\n3\\\\\n\\color{red}{20 19}\\\\\n\\color{black}{10 13 15}\\\\\n\\color{black}{8 5 9 3}\n\\end{tabular}\n&$\\longrightarrow$&\n\\begin{tabular}{c}\n\\color{red}{\\textbf{23}}\\\\\n\\color{black}{20 19}\\\\\n\\color{black}{10 13 15}\\\\\n\\color{black}{8 5 9 3}\n\\end{tabular}\n\\end{tabular}\n\\end{center}\n\nUse your function to find the maximum path sum of the 100-row triangle stored in \\texttt{triangle\\_large.txt}.\nMake sure that your new function still gets the correct answer for the smaller \\texttt{triangle.txt}.\nFinally, use \\li{<p<\\%time>p>} or \\li{<p<\\%timeit>p>} to time both functions on \\texttt{triangle.txt}.\nYour new function should be about 100 times faster than the original.\n\\end{problem}\n\n\\subsection*{The Profiler} % --------------------------------------------------\n\nThe profiling command \\li{<p<\\%prun>p>} lists the functions that are called during the execution of a piece of code, along with the following information.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{c|l}\n    Heading & Description \\\\ \\hline\n    \\li{primitive calls} & The number of calls that were not caused by recursion.\\\\\n    \\li{ncalls} & The number of calls to the function. If recursion occurs, the output\\\\ & is \\texttt{<total number of calls>/<number of primitive calls>}.\\\\\n    \\li{tottime} & The amount of time spent in the function, not including calls to other functions.\\\\\n    \\li{percall} & The amount of time spent in each call of the function.\\\\\n    \\li{cumtime} & The amount of time spent in the function, including calls to other functions.\\\\\n\\end{tabular}\n\\end{table}\n\n\\begin{lstlisting}\n# Profile the original function from Problem 1.\n<g<In[3]:>g> <p<%prun>p> max_path(\"triangle.txt\")\n\\end{lstlisting}\n\n{\\small\n\\begin{verbatim}\n         81947 function calls (49181 primitive calls) in 0.036 seconds\n   Ordered by: internal time\n\n   ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n  32767/1    0.025    0.000    0.034    0.034 profiling.py:18(path_sum)\n    16383    0.005    0.000    0.005    0.000 {built-in method builtins.max}\n    32767    0.003    0.000    0.003    0.000 {built-in method builtins.len}\n        1    0.002    0.002    0.002    0.002 {method `readlines' of `_io._IOBase' objects}\n        1    0.000    0.000    0.000    0.000 {built-in method io.open}\n        1    0.000    0.000    0.036    0.036 profiling.py:12(max_path)\n        1    0.000    0.000    0.000    0.000 profiling.py:15(<listcomp>)\n        1    0.000    0.000    0.036    0.036 {built-in method builtins.exec}\n        2    0.000    0.000    0.000    0.000 codecs.py:318(decode)\n        1    0.000    0.000    0.036    0.036 <string>:1(<module>)\n       15    0.000    0.000    0.000    0.000 {method `split' of `str' objects}\n        1    0.000    0.000    0.000    0.000 _bootlocale.py:23(getpreferredencoding)\n        2    0.000    0.000    0.000    0.000 {built-in method _codecs.utf_8_decode}\n        1    0.000    0.000    0.000    0.000 {built-in method _locale.nl_langinfo}\n        1    0.000    0.000    0.000    0.000 codecs.py:259(__init__)\n        1    0.000    0.000    0.000    0.000 codecs.py:308(__init__)\n        1    0.000    0.000    0.000    0.000 {method `disable' of `_lsprof.Profiler' objects}\n\\end{verbatim}\n}\n\n\\section*{Optimizing Python Code} % ===========================================\n\nA poor implementation of a good algorithm is better than a good implementation of a bad algorithm, but clumsy implementation can still cripple a program's efficiency.\nThe following are a few important practices for speeding up a Python program.\nRemember, however, that such improvements are futile if the algorithm is poorly suited for the problem.\n\n\\subsection*{Avoid Repetition} % ----------------------------------------------\n\n% {\\small\n% \\begin{verbatim}\n%    ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n%   32767/1    0.025    0.000    0.034    0.034 profiling.py:18(path_sum)\n%     16383    0.005    0.000    0.005    0.000 {built-in method builtins.max}\n%     32767    0.003    0.000    0.003    0.000 {built-in method builtins.len}\n%         1    0.002    0.002    0.002    0.002 {method `readlines' of `_io._IOBase' objects}\n%        15    0.000    0.000    0.000    0.000 {method `split' of `str' objects}\n% \\end{verbatim}\n% }\n\nA clean program does no more work than is necessary.\nThe \\li{ncalls} column of the profiler output is especially useful for identifying parts of a program that might be repetitive.\nFor example, the profile of \\li{max_path()} indicates that \\li{len()} was called 32,767 times---exactly as many times as \\li{path_sum()}.\nThis is an easy fix: save \\li{len(data)} as a variable somewhere outside of \\li{path_sum()}.\n\\begin{lstlisting}\n<g<In [4]:>g> def max_path_clean(filename=\"triangle.txt\"):\n   <g<...:>g>     with open(filename, 'r') as infile:\n   <g<...:>g>         data = [[int(n) for n in line.split()]\n   <g<...:>g>                         for line in infile.readlines()]\n   <g<...:>g>     N = len(data)       # Calculate len(data) outside of path_sum().\n   <g<...:>g>     def path_sum(r, c, total):\n   <g<...:>g>         total += data[r][c]\n   <g<...:>g>         if r == N - 1:  # Use N instead of len(data).\n   <g<...:>g>             return total\n   <g<...:>g>         else:\n   <g<...:>g>             return max(path_sum(r+1, c,   total),\n   <g<...:>g>                        path_sum(r+1, c+1, total))\n   <g<...:>g>     return path_sum(0, 0, 0)\n   <g<...:>g>\n<g<In [5]:>g> <p<%prun>p> max_path_clean(\"triangle.txt\")\n\\end{lstlisting}\n{\\small\n\\begin{verbatim}\n         49181 function calls (16415 primitive calls) in 0.026 seconds\n   Ordered by: internal time\n\n   ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n  32767/1    0.020    0.000    0.025    0.025 <ipython-input-5-9e8c48bb1aba>:6(path_sum)\n    16383    0.005    0.000    0.005    0.000 {built-in method builtins.max}\n        1    0.002    0.002    0.002    0.002 {method `readlines' of `_io._IOBase' objects}\n        1    0.000    0.000    0.000    0.000 {built-in method io.open}\n        1    0.000    0.000    0.026    0.026 <ipython-input-5-9e8c48bb1aba>:1(max_path_clean)\n        1    0.000    0.000    0.000    0.000 <ipython-input-5-9e8c48bb1aba>:3(<listcomp>)\n        1    0.000    0.000    0.027    0.027 {built-in method builtins.exec}\n       15    0.000    0.000    0.000    0.000 {method `split' of `str' objects}\n        1    0.000    0.000    0.027    0.027 <string>:1(<module>)\n        2    0.000    0.000    0.000    0.000 codecs.py:318(decode)\n        1    0.000    0.000    0.000    0.000 _bootlocale.py:23(getpreferredencoding)\n        2    0.000    0.000    0.000    0.000 {built-in method _codecs.utf_8_decode}\n        1    0.000    0.000    0.000    0.000 {built-in method _locale.nl_langinfo}\n        1    0.000    0.000    0.000    0.000 codecs.py:308(__init__)\n        1    0.000    0.000    0.000    0.000 codecs.py:259(__init__)\n        1    0.000    0.000    0.000    0.000 {built-in method builtins.len}\n        1    0.000    0.000    0.000    0.000 {method `disable' of `_lsprof.Profiler' objects}\n\\end{verbatim}\n}\n\nNote that the total number of primitive function calls decreased from 49,181 to 16,415.\nUsing \\li{<p<\\%timeit>p>} also shows that the run time decreased by about 15\\%.\nMoving code outside of a loop or an often-used function usually results in a similar speedup.\n\nAnother important way of reducing repetition is carefully controlling loop conditions to avoid unnecessary iterations.\nConsider the problem of identifying Pythagorean triples, sets of three distinct integers $a < b < c$ such that $a^2 + b^2 = c^2$.\nThe following function identifies all such triples where each term is less than a parameter $N$ by checking all possible triples.\n\n\\begin{lstlisting}\n>>> def pythagorean_triples_slow(N):\n...     \"\"\"Compute all pythagorean triples with entries less than N.\"\"\"\n...     triples = []\n...     for a in range(1, N):               # Try values of a from 1 to N-1.\n...         for b in range(1, N):           # Try values of b from 1 to N-1.\n...             for c in range(1, N):       # Try values of c from 1 to N-1.\n...                 if a**2 + b**2 == c**2 and a < b < c:\n...                     triples.append((a,b,c))\n...     return triples\n...\n\\end{lstlisting}\n\nSince $a < b < c$ by definition, any computations where $b \\le a$ or $c \\le b$ are unnecessary.\nAdditionally, once $a$ and $b$ are chosen, $c$ can be no greater than $\\sqrt{a^2 + b^2}$.\nThe following function changes the loop conditions to avoid these cases and takes care to only compute $a^2 + b^2$ once for each unique pairing $(a,b)$.\n\n\\begin{lstlisting}\n>>> from math import sqrt\n>>> def pythagorean_triples_fast(N):\n...     \"\"\"Compute all pythagorean triples with entries less than N.\"\"\"\n...     triples = []\n...     for a in range(1, N):               # Try values of a from 1 to N-1.\n...         for b in range(a+1, N):         # Try values of b from a+1 to N-1.\n...             _sum = a**2 + b**2\n...             for c in range(b+1, min(int(sqrt(_sum))+1, N)):\n...                 if _sum == c**2:\n...                     triples.append((a,b,c))\n...     return triples\n...\n\\end{lstlisting}\n\nThese improvements have a drastic impact on run time, even though the main approach---checking by brute force---is the same.\n\n\\begin{lstlisting}\n<g<In [6]:>g> <p<%time>p> triples = pythagorean_triples_slow(500)\n<<CPU times: user 1min 51s, sys: 389 ms, total: 1min 51s\nWall time: 1min 52s>>         # 112 seconds.\n\n<g<In [7]:>g> <p<%time>p> triples = pythagorean_triples_fast(500)\n<<CPU times: user 1.56 s, sys: 5.38 ms, total: 1.57 s\nWall time: 1.57 s>>           # 98.6% faster!\n\\end{lstlisting}\n\n\\begin{problem}\nThe following function computes the first $N$ prime numbers.\n\\begin{lstlisting}\ndef primes(N):\n    \"\"\"Compute the first N primes.\"\"\"\n    primes_list = []\n    current = 2\n    while len(primes_list) < N:\n        isprime = True\n        for i in range(2, current):     # Check for nontrivial divisors.\n            if current % i == 0:\n                isprime = False\n        if isprime:\n            primes_list.append(current)\n        current += 1\n    return primes_list\n\\end{lstlisting}\nThis function takes about 6 minutes to find the first 10,000 primes on a fast computer.\n\nWithout significantly modifying the approach, rewrite \\li{primes()} so that it can compute 10,000 primes in under 0.1 seconds.\nUse the following facts to reduce unnecessary iterations.\n\\begin{itemize}\n\\item A number is not prime if it has one or more divisors other than 1 and itself.\n\\\\(Hint: recall the \\li{break} statement.)\n\\item If $p\\nmid n$, then $ap\\nmid n$ for any integer $a$.\nAlso, if $p \\mid n$ and $0 < p < n$, then $p \\le \\sqrt{n}$.\n\\item Except for $2$, primes are always odd.\n\\end{itemize}\nYour new function should be helpful for solving problem 7 on \\url{https://projecteuler.net}.\n\\label{prob:profiling-primes-naive}\n\\end{problem}\n\n\\subsection*{Avoid Loops} % ---------------------------------------------------\n\n% Most repetition occurs in a looping structure.\n% \\textbf{Avoid loops where possible, especially nested loops} (loops within loops).\n% If nested loops are unavoidable, focus optimization efforts on the innermost loop, since that part of the code gets the most repetitions.\n\nNumPy routines and built-in functions are often useful for eliminating loops altogether. %, a process called \\emph{vectorization}.\nConsider the simple problem of summing the rows of a matrix, implemented in three ways.\n\n\\begin{lstlisting}\n>>> def row_sum_awful(A):\n...     \"\"\"Sum the rows of A by iterating through rows and columns.\"\"\"\n...     m,n = A.shape\n...     row_totals = np.empty(m)        # Allocate space for the output.\n...     for i in range(m):              # For each row...\n...         total = 0\n...         for j in range(n):          # ...iterate through the columns.\n...             total += A[i,j]\n...         row_totals[i] = total       # Record the total.\n...     return row_totals\n...\n>>> def row_sum_bad(A):\n...     \"\"\"Sum the rows of A by iterating through rows.\"\"\"\n...     return np.array([sum(A[i,:]) for i in range(A.shape[0])])\n...\n>>> def row_sum_fast(A):\n...     \"\"\"Sum the rows of A with NumPy.\"\"\"\n...     return np.<<sum>>(A, axis=1)    # Or A.sum(axis=1).\n...\n\\end{lstlisting}\n\nNone of the functions are fundamentally different, but their run times differ dramatically.\n\n\\begin{lstlisting}\n<g<In [8]:>g> import numpy as np\n<g<In [9]:>g> A = np.random.random((10000, 10000))\n\n<g<In [10]:>g> <p<%time>p> rows = row_sum_awful(A)\n<<CPU times: user 22.7 s, sys: 137 ms, total: 22.8 s\nWall time: 23.2 s>>         # SLOW!\n\n<g<In [11]:>g> <p<%time>p> rows = row_sum_bad(A)\n<<CPU times: user 8.85 s, sys: 15.6 ms, total: 8.87 s\nWall time: 8.89 s>>         # Slow!\n\n<g<In [12]:>g> <p<%time>p> rows = row_sum_fast(A)\n<<CPU times: user 61.2 ms, sys: 1.3 ms, total: 62.5 ms\nWall time: 64 ms>>          # Fast!\n\\end{lstlisting}\n\nIn this experiment, \\li{row_sum_fast()} runs several hundred times faster than \\li{row_sum_awful()}.\nThis is primarily because looping is expensive in Python, but NumPy handles loops in C, which is much quicker.\nOther NumPy functions like \\li{np.<<sum>>()} with an \\li{axis} argument can often be used to eliminate loops in a similar way.\n\n\\begin{problem} % Naive Nearest Neighbor with vectorization.\nLet $A$ be an $m\\times n$ matrix with columns $\\a_0, \\ldots, \\a_{n-1}$, and let $\\x$ be a vector of length $m$.\nThe \\emph{nearest neighbor problem}\\footnote{The nearest neighbor problem is a common problem in many fields of artificial intelligence. The problem can be solved more efficiently with a $k$-d tree, a specialized data structure for storing high-dimensional data.} is to determine which of the columns of $A$ is ``closest'' to $\\x$ with respect to some norm.\nThat is, we compute\n\\[\\underset{j}{\\text{argmin }} \\|\\a_j - \\x\\|.\\]\nThe following function solves this problem na\\\"ively for the usual Euclidean norm.\n\\begin{lstlisting}\ndef nearest_column(A, x):\n    \"\"\"Find the index of the column of A that is closest to x.\"\"\"\n    distances = []\n    for j in range(A.shape[1]):\n        distances.append(np.linalg.norm(A[:,j] - x))\n    return np.argmin(distances)\n\\end{lstlisting}\n\nWrite a new version of this function without any loops or list comprehensions, using array broadcasting and the \\li{axis} keyword in \\li{np.linalg.norm()} to eliminate the existing loop.\nTry to implement the entire function in a single line.\n\\\\(Hint: See the NumPy Visual Guide in the Appendix for a refresher on array broadcasting.)\n\nProfile the old and new versions with \\li{<p<\\%prun>p>} and compare the output.\nFinally, use \\li{<p<\\%time>p>} or \\li{<p<\\%timeit>p>} to verify that your new version runs faster than the original.\n\\end{problem}\n\n\\subsection*{Use Data Structures Correctly} % ---------------------------------\n\nEvery data structure has strengths and weaknesses, and choosing the wrong data structure can be costly.\nHere we consider three ways to avoid problems and use sets, dictionaries, and lists correctly.\n\n\\begin{itemize}\n\\item \\textbf{Membership testing}. The question ``is \\li{<value>} a member of \\li{<container>}'' is common in numerical algorithms.\nSets and dictionaries are implemented in a way that makes this a trivial problem, but lists are not.\nIn other words, the \\li{in} operator is near instantaneous with sets and dictionaries, but not with lists.\n\n\\begin{lstlisting}\n<g<In [13]:>g> a_list = list(range(int(1e7)))\n\n<g<In [14]:>g> a_set = set(a_list)\n\n<g<In [15]:>g> <p<%timeit>p> 12.5 in a_list\n<<413 ms +- 48.2 ms per loop (mean+-std.dev. of 7 runs, 1 loop each)>>\n\n<g<In [16]:>g> <p<%timeit>p> 12.5 in a_set\n<<170 ns +- 3.8 ns per loop (mean+-std.dev. of 7 runs, 10000000 loops each)>>\n\\end{lstlisting}\n\nLooking up dictionary values is also almost immediate.\nUse dictionaries for storing calculations to be reused, such as mappings between letters and numbers or common function outputs.\n\n\\item \\textbf{Construction with comprehension}.\nLists, sets, and dictionaries can all be constructed with comprehension syntax.\nThis is slightly faster than building the collection in a loop, and the code is highly readable.\n% TODO (?): map().\n\n\\begin{lstlisting}\n# Map the integers to their squares.\n<g<In [17]:>g> <p<%%time>p>\n   <g<...:>g> a_dict = {}\n   <g<...:>g> for i in range(1000000):\n   <g<...:>g>     a_dict[i] = i**2\n   <g<...:>g>\n<<CPU times: user 432 ms, sys: 54.4 ms, total: 486 ms\nWall time: 491 ms>>\n\n<g<In [18]:>g> <p<%time>p> a_dict = {i:i**2 for i in range(1000000)}\n<<CPU times: user 377 ms, sys: 58.9 ms, total: 436 ms\nWall time: 440 ms>>\n\\end{lstlisting}\n\n\\item \\textbf{Intelligent iteration}.\nUnlike looking up dictionary values, indexing into lists takes time.\nInstead of looping over the indices of a list, loop over the entries themselves.\nWhen indices and entries are both needed, use \\li{enumerate()} to get the index and the item simultaneously.\n\n\\begin{lstlisting}\n<g<In [19]:>g> a_list = list(range(1000000))\n\n<g<In [20]:>g> <p<%%time>p>          # Loop over the indices of the list.\n    <g<...:>g> for i in range(len(a_list)):\n    <g<...:>g>     item = a_list[i]\n    <g<...:>g>\n<<CPU times: user 103 ms, sys: 1.78 ms, total: 105 ms\nWall time: 107 ms>>\n\n<g<In [21]:>g> <p<%%time>p>          # Loop over the items in the list.\n    <g<...:>g> for item in a_list:\n    <g<...:>g>     _ = item\n    <g<...:>g>\n<<CPU times: user 61.2 ms, sys: 1.31 ms, total: 62.5 ms\nWall time: 62.5 ms>>      # Almost twice as fast as indexing!\n\\end{lstlisting}\n% <g<In [X]:>g> <p<%%time>p>          # Use enumerate() to get both indices and items.\n%     <g<...:>g> for i, item in enumerate(a_list):\n%     <g<...:>g>     _ = item\n%     <g<...:>g>\n% <<CPU times: user 92.5 ms, sys: 1.58 ms, total: 94.1 ms\n% Wall time: 94.4 ms>>      # Still slightly faster than indexing.\n% \\end{lstlisting}\n\\end{itemize}\n\n\\begin{comment} % USELESS\nSecond, swap values with a single assignment.\n\n\\begin{lstlisting}\n>>> a, b = 1, 2\n>>> a, b = b, a\n>>> a, b\n(2, 1)\n\\end{lstlisting}\n\nThird, many non-Boolean objects in Python have truth values.\nFor example, numbers are \\li{False} when equal to zero and \\li{True} otherwise.\nSimilarly, lists and strings are \\li{False} when they are empty and \\li{True} otherwise.\nThe following code gives some examples.\n\n\\begin{lstlisting}\n# Use the truth values of numbers.\n>>> if 10:\n...     print(\"Non-zero\")\n...\nNon-zero\n\n# Use the truth values of a list.\n>>> my_list = [i for i in range(5)]\n>>> if my_list:\n...     print(my_list[0])\n...\n0\n\\end{lstlisting}\n\\end{comment}\n\n\\begin{problem} % Name scores.\nThis is problem 22 from \\url{https://projecteuler.net}.\n\nUsing the rule $A\\mapsto 1, B\\mapsto 2, \\ldots, Z\\mapsto 26$, the \\emph{alphabetical value} of a name is the sum of the digits that correspond to the letters in the name.\nFor example, the alphabetic value of ``COLIN'' is $3 + 15 + 12 + 9 + 14 = 53$.\n\nThe following function reads the file \\texttt{names.txt}, containing over five-thousand first names, and sorts them in alphabetical order.\nThe \\emph{name score} of each name in the resulting list is the alphabetic value of the name multiplied by the name's position in the list, starting at 1.\n``COLIN'' is the 938th name alphabetically, so its name score is $938 \\times 53 = 49714$.\nThe function returns the total of all the name scores in the file.\n\n\\begin{lstlisting}\ndef name_scores(filename=\"names.txt\"):\n    \"\"\"Find the total of the name scores in the given file.\"\"\"\n    with open(filename, 'r') as infile:\n        names = sorted(infile.read().replace('\"', '').split(','))\n    total = 0\n    for i in range(len(names)):\n        name_value = 0\n        for j in range(len(names[i])):\n            alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n            for k in range(len(alphabet)):\n                if names[i][j] == alphabet[k]:\n                    letter_value = k + 1\n            name_value += letter_value\n        total += (names.index(names[i]) + 1) * name_value\n    return total\n\\end{lstlisting}\n\nRewrite this function---removing repetition, eliminating loops, and using data structures correctly---so that it runs in less than 10 milliseconds on average.\n\\end{problem}\n\n\\subsection*{Use Generators} % ------------------------------------------------\n\nA \\emph{generator} is an iterator that yields multiple values, one at a time, as opposed to returning a single value.\nFor example, \\li{range()} is a generator.\nUsing generators appropriately can reduce both the run time and the spatial complexity of a routine.\nConsider the following function, which constructs a list containing the entries of the sequence $\\{x_n\\}_{n=1}^N$ where $x_{n} = x_{n-1} + n$ with $x_1 = 1$.\n\n\\begin{lstlisting}\n>>> def sequence_function(N):\n...     \"\"\"Return the first N entries of the sequence x_n = x_{n-1} + n.\"\"\"\n...     sequence = []\n...     x = 0\n...     for n in range(1, N+1):\n...         x += n\n...         sequence.append(x)\n...     return sequence\n...\n>>> sequence_function(10)\n[1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n\\end{lstlisting}\n\nA potential problem with this function is that all of the values in the list are computed before anything is returned.\nThis can be a big issue if the parameter $N$ is large.\nA generator, on the other hand, \\emph{yields} one value at a time, indicated by the keyword \\li{yield} (instead of \\li{return}).\nWhen the generator is asked for the next entry, the code resumes right where it left off.\n% The only visible difference between a generator and a function is the use of \\li{yield} in place of \\li{return}.\n% In the following example, note that \\li{sequence_generator()} does not keep track of the entire sequence like \\li{sequence_function()} does.\n\n\\begin{lstlisting}\n>>> def sequence_generator(N):\n...     \"\"\"Yield the first N entries of the sequence x_n = x_{n-1} + n.\"\"\"\n...     x = 0\n...     for n in range(1, N+1):\n...         x += n\n...         yield x         # \"return\" a single value.\n...\n# Get the entries of the generator one at a time with next().\n>>> generated = sequence_generator(10)\n>>> next(generated)\n1\n>>> next(generated)\n3\n>>> next(generated)\n6\n\n# Put each of the generated items in a list, as in sequence_function().\n>>> list(sequence_generator(10))    # Or [i for i in sequence_generator(10)].\n[1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n\n# Use the generator in a for loop, like range().\n>>> for entry in sequence_generator(10):\n...     print(entry, end=' ')\n...\n1 3 6 10 15 21 28 36 45 55\n\\end{lstlisting}\n\nMany generators, like \\li{range()} and \\li{sequence_generator()}, only yield a finite number of values.\nHowever, generators can also continue yielding indefinitely.\nFor example, the following generator yields the terms of $\\{x_n\\}_{n=1}^\\infty$ forever.\nIn this case, using \\li{enumerate()} with the generator is helpful for tracking the index $n$ as well as the entry $x_n$.\n\n\\begin{lstlisting}\n>>> def sequence_generator_forever():\n...     \"\"\"Yield the sequence x_n = x_{n-1} + n forever.\"\"\"\n...     x = 0\n...     n = 1\n...     while True:\n...         x += n\n...         n += 1\n...         yield x         # \"return\" a single value.\n...\n\n# Sum the entries of the sequence until the sum exceeds 1000.\n>>> total = 0\n>>> for i, x in enumerate(sequence_generator_forever()):\n...     total += x\n...     if total > 1000:\n...         print(i)        # Print the index where the total exceeds.\n...         break           # Break out of the for loop to stop iterating.\n...\n17\n\n# Check that 18 terms are required (since i starts at 0 but n starts at 1).\n>>> print(sum(sequence_generator(17)), sum(sequence_generator(18)))\n969 1140\n\\end{lstlisting}\n\n\\begin{warn} % Use xrange() in Python 2.\nIn Python 2.7 and earlier, \\li{range()} is \\textbf{not} a generator.\nInstead, it constructs an entire list of values, which is often significantly slower than yielding terms individually as needed.\nIf you are using old versions of Python, use \\li{xrange()}, the equivalent of \\li{range()} in Python 3.0 and later.\n\\end{warn}\n\n\\begin{problem} % Fibonacci sequence.\nThis is problem 25 from \\url{https://projecteuler.net}.\n\nThe \\emph{Fibonacci sequence} is defined by the recurrence relation $F_{n} = F_{n-1} + F_{n-2}$, where $ F_1 = F_2 = 1$.\nThe 12th term, $F_{12} = 144$, is the first term to contain three digits.\n\nWrite a generator that yields the terms of the Fibonacci sequence indefinitely.\nNext, write a function that accepts an integer $N$.\nUse your generator to find the first term in the Fibonacci sequence that contains $N$ digits.\nReturn the index of this term.\n\\\\(Hint: a generator can have more than one \\li{yield} statement.)\n\\end{problem}\n\n% See \\url{https://docs.python.org/3/tutorial/classes.html#generators} for more about generators.\n% and \\url{https://wiki.python.org/moin/Generators}\n\n\\begin{problem} % Sieve of Eratosthenes.\nThe function in Problem \\ref{prob:profiling-primes-naive} could be turned into a prime number generator that yields primes indefinitely, but it is not the only strategy for yielding primes.\nThe \\emph{Sieve of Eratosthenes}\\footnote{See \\url{https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes}.} is a faster technique for finding all of the primes below a certain number.\n\\begin{enumerate}\n\\item Given a cap $N$, start with all of the integers from $2$ to $N$.\n\\item Remove all integers that are divisible by the first entry in the list. \\label{step:profiling-sieve-of-eratos}\n\\item Yield the first entry in the list and remove it from the list.\n\\item Return to step \\ref{step:profiling-sieve-of-eratos} until the list is empty.\n\\end{enumerate}\n\nWrite a generator that accepts an integer $N$ and that yields all primes (in order, one at a time) that are less than $N$ using the Sieve of Eratosthenes.\nYour generator should be able to find all primes less than 100,000 in under $5$ seconds.\n\nYour generator and your fast function from Problem \\ref{prob:profiling-primes-naive} may be helpful in solving problems 10, 35, 37, 41, 49, and 50 (for starters) of \\url{https://projecteuler.net}.\n\\end{problem}\n\n\\section*{Numba} % ============================================================\n\nPython code is simpler and more readable than many languages, but Python is also generally much slower than compiled languages like C.\nThe \\li{numba} module\n%\\footnote{Numba is \\textbf{not} part of the standard library, but it is included in the Anaconda distribution. For installation details, see \\url{https://numba.pydata.org/}.}\nbridges the gap by using \\emph{just-in-time} (JIT) compilation to optimize code, meaning that the code is actually compiled right before execution.\n\n\\begin{lstlisting}\n>>> from numba import jit\n\n>>> @jit                # Decorate a function with @jit to use Numba.\n... def row_sum_numba(A):\n...     \"\"\"Sum the rows of A by iterating through rows and columns,\n...     optimized by Numba.\n...     \"\"\"\n...     m,n = A.shape\n...     row_totals = np.empty(m)\n...     for i in range(m):\n...         total = 0\n...         for j in range(n):\n...             total += A[i,j]\n...         row_totals[i] = total\n...     return row_totals\n\\end{lstlisting}\n\nPython is a \\emph{dynamically typed} language, meaning variables are not defined explicitly with a datatype (\\li{x = 6} as opposed to \\li{int x = 6}).\nThis particular aspect of Python makes it flexible, easy to use, and slow.\n% One of the reasons compiled languages like C are so much faster than Python is because they have explicitly defined datatypes.\nNumba speeds up Python code primarily by assigning datatypes to all the variables.\nRather than requiring explicit definitions for datatypes, Numba attempts to infer the correct datatypes based on the datatypes of the input.\nIn \\li{row_sum_numba()}, if \\li{A} is an array of integers, Numba will infer that \\li{total} should also be an integer.\nOn the other hand, if \\li{A} is an array of floats, Numba will infer that \\li{total} should be a \\emph{double} (a similar datatype to float in C).\n\nOnce all datatypes have been inferred and assigned, the original Python code is translated to machine code. % by the LLVM library.\nNumba caches this compiled version of code for later use.\nThe first function call takes the time to compile and then execute the code, but subsequent calls use the already-compiled code.\n\n\\begin{lstlisting}\n<g<In [22]:>g> A = np.random.random((10000, 10000))\n\n# The first function call takes a little extra time to compile first.\n<g<In [23]:>g> <p<%time>p> rows = row_sum_numba(A)\n<<CPU times: user 408 ms, sys: 11.5 ms, total: 420 ms>>\nWall time: 425 ms\n\n# Subsequent calls are consistently faster that the first call.\n<g<In [24]:>g> <p<%timeit>p> row_sum_numba(A)\n<<138 ms +- 1.96 ms per loop (mean +- std. dev. of 7 runs, 10 loops each)>>\n\\end{lstlisting}\n\nNote that the only difference between \\li{row_sum_numba()} and \\li{row_sum_awful()} from a few pages ago is the \\li{@jit} decorator, and yet the Numba version is about 99\\% faster than the original!\n\nThe inference engine within Numba does a good job, but it's not always perfect.\nAdding the keyword argument \\li{nopython=True} to the \\li{@jit} decorator raises an error if Numba is unable to convert each variable to explicit datatypes.\nThe \\li{inspect_types()} method can also be used to check if Numba is using the desired types.\n\n\\begin{lstlisting}\n# Run the function once first so that it compiles.\n>>> rows = row_sum_numba(np.random.random((10,10)))\n>>> row_sum_numba.inspect_types()\n# The output is very long and detailed.\n\\end{lstlisting}\n\nAlternatively, datatypes can be specified explicitly in the \\li{@jit} decorator as a dictionary via the \\li{<<locals>>} keyword argument.\nEach of the desired datatypes must also be imported from Numba.\n\n\\begin{lstlisting}\n>>> from numba import int64, double\n\n>>> @jit(nopython=True, <<locals>>=dict(A=double[:,:], m=int64, n=int64,\n...                                 row_totals=double[:], total=double))\n... def row_sum_numba(A):           # 'A' is a 2-D array of doubles.\n...     m,n = A.shape               # 'm' and 'n' are both integers.\n...     row_totals = np.empty(m)    # 'row_totals' is a 1-D array of doubles.\n...     for i in range(m):\n...         total = 0               # 'total' is a double.\n...         for j in range(n):\n...             total += A[i,j]\n...         row_totals[i] = total\n...     return row_totals\n...\n\\end{lstlisting}\n\nWhile it sometimes results in a speed boost, there is a caveat to specifying the datatypes: \\li{row_sum_numba()} no longer accepts arrays that contain anything other than floats.\nWhen datatypes are not specified, Numba compiles a new version of the function each time the function is called with a different kind of input.\nEach compiled version is saved, so the function can still be used flexibly.\n\n\\begin{problem} % Compare times for Numba.\nThe following function calculates the $n$th power of an $m\\times m$ matrix $A$.\n\n\\begin{lstlisting}\ndef matrix_power(A, n):\n    \"\"\"Compute A^n, the n-th power of the matrix A.\"\"\"\n    product = A.copy()\n    temporary_array = np.empty_like(A[0])\n    m = A.shape[0]\n    for power in range(1, n):\n        for i in range(m):\n            for j in range(m):\n                total = 0\n                for k in range(m):\n                    total += product[i,k] * A[k,j]\n                temporary_array[j] = total\n            product[i] = temporary_array\n    return product\n\\end{lstlisting}\n\n\\begin{enumerate}\n\\item Write a Numba-enhanced version of \\li{matrix_power()} called \\li{matrix_power_numba()}.\n\\item Write a function that accepts an integer $n$.\nRun \\li{matrix_power_numba()} once with a small random input so it compiles.\nThen, for $m=2^2,2^3,\\ldots,2^7$,\n    \\begin{enumerate}\n        \\item Generate a random $m\\times m$ matrix $A$ with \\li{np.random.random()}.\n        \\item Time (separately) \\li{matrix_power()}, \\li{matrix_power_numba()}, and NumPy's \\\\ \\li{np.linalg.matrix_power()} on $A$ with the specified value of $n$.\n        \\\\(If you are unfamiliar with timing code inside of a function, see the \\\\ Additional Material section on timing code.)\n    \\end{enumerate}\nPlot the times against the size $m$ on a log-log plot (use \\li{plt.loglog()}).\n\\end{enumerate}\nWith $n=10$, the plot should show that the Numba and NumPy versions far outperform the pure Python implementation, with NumPy eventually becoming faster than Numba.\n% NumPy takes products of matrices by calling BLAS and LAPACK, which are heavily optimized linear algebra libraries written in C, assembly, and Fortran.\n\\end{problem}\n\n\\begin{warn}\nOptimizing code is an important skill, but it is also important to know when to refrain from optimization.\nThe best approach to coding is to write unit tests, implement a solution that works, test and time that solution, \\textbf{then} (and only then) optimize the solution with profiling techniques.\nAs always, the most important part of the process is choosing the correct algorithm to solve the problem.\nDon't waste time optimizing a poor algorithm.\n\\end{warn}\n\n\\newpage\n\n\\section*{Additional Material} % ==============================================\n\n\\subsection*{Other Timing Techniques} % ---------------------------------------\n\nThough \\li{<p<\\%time>p>} and \\li{<p<\\%timeit>p>} are convenient and work well, some problems require more control for measuring execution time.\nThe usual way of timing a code snippet by hand is via the \\li{time} module (which \\li{<p<\\%time>p>} uses).\nThe function \\li{time.time()} returns the number of seconds since the Epoch\\footnote{See \\url{https://en.wikipedia.org/wiki/Epoch_(reference_date)\\#Computing}.}; to time code, measure the number of seconds before the code runs, the number of seconds after the code runs, and take the difference.\n\n\\begin{lstlisting}\n>>> import time\n\n>>> start = time.time()             # Record the current time.\n>>> for i in range(int(1e8)):       # Execute some code.\n...     pass\n... end = time.time()               # Record the time again.\n... print(end - start)              # Take the difference.\n...\n4.20402193069458 # (seconds)\n\\end{lstlisting}\n\nThe \\li{timeit} module (which \\li{<p<\\%timeit>p>} uses) has tools for running code snippets several times.\nThe code is passed in as a string, as well as any setup code to be run before starting the clock.\n\n\\begin{lstlisting}\n>>> import timeit\n\n>>> timeit.timeit(\"for i in range(N): pass\", setup=\"N = int(1e6)\", number=200)\n4.884839255013503       # Total time in seconds to run the code 200 times.\n>>> _ / 200\n0.024424196275067516    # Average time in seconds.\n\\end{lstlisting}\n\nThe primary advantages of these techniques are the ability automate timing code and being able save the results.\nFor more documentation, see \\url{https://docs.python.org/3.6/library/time.html} and \\url{https://docs.python.org/3.6/library/timeit.html}.\n\n\\subsection*{Customizing the Profiler} % --------------------------------------\n\nThe output from \\li{<p<\\%prun>p>} is generally long, but it can be customized with the following options.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{l|l}\n    Option & Description \\\\ \\hline\n    \\li{-l <limit>} & Include a limited number of lines in the output.\\\\\n    \\li{-s <key>} & Sort the output by call count, cumulative time, function name, etc. \\\\\n    \\li{-T <filename>} & Save profile results to a file (results are still printed).\\\\\n\\end{tabular}\n\\end{table}\n\nFor example, \\li{<p<\\%prun>p> -l 3 -s ncalls -T path_profile.txt max_path()} generates a profile of \\li{max_path()} that lists the 3 functions with the most calls, then write the results to \\texttt{path\\_profile.txt}.\nSee  \\url{http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-prun} for more details.\n", "meta": {"hexsha": "63ac277cae071daac1a9937bf3d23b9b92b34fde", "size": 40578, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "acme-material/Labs/PythonEssentials/Profiling/Profiling.tex", "max_stars_repo_name": "DM561/dm561.github.io", "max_stars_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-13T13:22:41.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-13T13:22:41.000Z", "max_issues_repo_path": "acme-material/Labs/PythonEssentials/Profiling/Profiling.tex", "max_issues_repo_name": "DM561/dm561.github.io", "max_issues_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-10-18T19:57:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-31T19:00:36.000Z", "max_forks_repo_path": "acme-material/Labs/PythonEssentials/Profiling/Profiling.tex", "max_forks_repo_name": "DM561/dm561.github.io", "max_forks_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1352313167, "max_line_length": 357, "alphanum_fraction": 0.6634136724, "num_tokens": 11568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5117166195971441, "lm_q2_score": 0.8006919997179627, "lm_q1q2_score": 0.4097274034341533}}
{"text": "\\documentclass{beamer}\n\n\\usepackage{verbatim}\n\\usepackage{fancyvrb}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{booktabs}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{calc}\n\\usepackage{color}\n\\usepackage{multicol}\n\\usepackage{wrapfig}\n\\usepackage{natbib}\n\\usepackage[ruled,vlined]{algorithm2e}\n\\usepackage{animate}\n\\usepackage{mathtools}\n\\usepackage{listings}\n\n\\usepackage{cmbright}\n\\fontencoding{OT1}\\fontfamily{cmbr}\\selectfont %to load ot1cmbr.fd\n\\DeclareFontShape{OT1}{cmbr}{bx}{n}{% change bx definition\n<->cmbrbx10%\n}{}\n\\normalfont % back to normalfont\n\n% two col: two columns\n\\newenvironment{twocol}[4]{\n\\begin{columns}[c]\n\\column{#1\\textwidth}\n#3\n\\column{#2\\textwidth}\n#4\n\\end{columns}\n}\n\n\\makeatletter\n\\setbeamertemplate{theorem begin}\n{%\n\\begin{\\inserttheoremblockenv}\n  {}{\\usebeamerfont*{block title}\\usebeamercolor[fg]{block title}%\n  \\inserttheoremname\n  %\\inserttheoremnumber\n  \\ifx \\inserttheoremaddition \\empty \\else\\ (\\inserttheoremaddition)\\fi\n  \\inserttheorempunctuation}\n  \\normalfont\n  }\n  \\setbeamertemplate{theorem end}{\\end{\\inserttheoremblockenv}}\n\\makeatother\n\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\sd}{\\mathrm{sd}}\n\\newcommand{\\s}{\\mathrm{s}}\n\\newcommand{\\Corr}{\\mathrm{Corr}}\n\\newcommand{\\rank}{\\mathrm{rank}}\n\\newcommand{\\trace}{\\mathrm{trace}}\n\\newcommand{\\nullspace}{\\mathrm{null}}\n\\newcommand{\\myspan}{\\mathrm{span}}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\softmax}{softmax}\n\n\\definecolor{darkgreen}{rgb}{0,0.5,0}\n\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{exe}{Exercise}\n\\newtheorem{notation}{Notation}\n\\newtheorem{remark}{Remark}\n\n\\definecolor{darkgreen}{rgb}{0,0.5,0}\n\n\\title{Model Diagnostics}\n\\author{Zhenisbek Assylbekov}\n\\institute{Department of Mathematics}\n\\date{Regression Analysis}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\begin{frame}{Diagnostics we have already discussed}\n\\begin{itemize}\n\\item Residuals $e_i$ vs. \n\\begin{itemize}\n    \\item $i$ (independence)\n    \\item $x_1$, \\ldots , $x_k$ (linearity)\n    \\item $\\hat{Y}_i$ (linearity and homogeneity of variance)\n\\end{itemize} \n\\item\\pause Q-Q plot of $e_1$, \\ldots , $e_n$.\n\\item\\pause VIF$_j$ for $j = 1, \\ldots, k$.\n\\item\\pause Significance tests (Runs, Levene's, Shapiro-Wilk)\n\\item\\pause Now we'll discuss \n\\begin{itemize}\n    \\item added variable plots,\n    \\item leverages,\n    \\item DFFITS,\n    \\item Cook's distance.\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{The problem with marginal plots}\n\\begin{center}\n\\includegraphics[height=.4\\textheight]{plots/marginal.pdf}    \n\\end{center}\n\\pause No dependence b/w $Y$ and $x_j$ marginally, but significant association jointly:\n\\begin{footnotesize}\n\\pause\\begin{verbatim}\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept)  0.05083    0.07726   0.658    0.514    \nx1           0.95536    0.07651  12.487   <2e-16 ***\nx2           0.96312    0.07658  12.576   <2e-16 ***\n\\end{verbatim}\n\\end{footnotesize}\n\\end{frame}\n\n\\section{Added variable plots}\n\n\\begin{frame}{Problems with marginal plots}\n\\begin{small}\n\\begin{itemize}\n\\item Residuals $e_i$ versus a predictor values $x_i,j$ can show whether $x_j$ may need to be transformed or whether we should add a quadratic term $x_j^2$.\n\\item\\pause We can omit the predictor  from the model and plot the residuals versus the predictor to see if the predictor explains residual variability.\n\\item\\pause However these plots can also be misleading: \\pause e.g., we can have\n\\vspace{-5pt}\n\\begin{center}\n    \\includegraphics[height=.3\\textheight]{plots/res-xj.pdf}\n\\end{center}\nwhere $e(Y\\mid x_j)$ are residuals when we regress $Y$ on $x_j$ only.\n\\end{itemize}\n\\end{small}\n\\end{frame}\n\n\\begin{frame}[fragile]{Added variables plots}\n\\begin{itemize}\n    \\item The previous plots suggest that $x_2$ is not needed when $x_1$ is in the model, \\pause or that $x_1$ is not needed when $x_2$ is in the model.\n    \\item\\pause But we still have significance for both $x_1$ and $x_2$ when they are \\textit{simultaneously} in the model!\n    \\begin{footnotesize}\n    \\begin{verbatim}\n                Estimate Std. Error t value Pr(>|t|)    \n(Intercept)  0.05083    0.07726   0.658    0.514    \nx1           0.95536    0.07651  12.487   <2e-16 ***\nx2           0.96312    0.07658  12.576   <2e-16 ***\n    \\end{verbatim}\n    \\end{footnotesize}\n    \\item\\pause An \\textbf{added variable plot} tries to fix this problem.\n    \\item\\pause It answers the question: Does $x_j$ explain any \\textit{residual} variability once the rest of the predictors are in the model?\n\\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}{10.1 Added variable plots}\n\\begin{itemize}\n\\item Consider a pool of predictors $x_1 , \\ldots, x_k$. Let’s consider predictor $x_j$ where $j = 1, \\ldots, k$.\n\\item\\pause Regress $Y_i$ vs. all predictors except $x_j$, call the residuals $e_i(Y\\mid\\mathbf{x}_{-j})$.\n\\item\\pause Regress $x_j$ vs. all predictors except $x_j$, call the residuals $e_i(x_j\\mid\\mathbf{x}_{-j})$.\n\\item\\pause The added variable plot for $x_j$ is $e_i(Y\\mid\\mathbf{x}_{-j})$ vs. $e_i(x_j\\mid\\mathbf{x}_{-j})$.\n\\item\\pause If you fit a simple linear regression\n$$\ne_i(Y\\mid\\mathbf{x}_{-j}) = \\beta_j\\cdot e_i(x_j\\mid\\mathbf{x}_{-j})+\\epsilon_i\n$$\nthen the LSE $\\hat\\beta_j$ \\textit{is the same} as one would get from fitting the full model $Y_i = \\beta_0 + \\beta_1 x_{i1} + \\cdots + \\beta_k x_{ik} + \\epsilon_i$. \n\\item\\pause Gives an idea of the functional form of $x_j$: a transformation in $x_j$ should mimic the pattern seen in the plot. %; the methods of Section 3.9 apply.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{10.1 Added variables plots illustration}\nLet's go back to our synthetic example:\n\n\\vspace{-10pt}\n\n\\begin{center}\n\\includegraphics[height=.4\\textheight]{plots/marginal.pdf}\n\\end{center}\n\n\\pause \n\\begin{center}\n\\includegraphics[height=.4\\textheight]{plots/av_plots.pdf}\n\\end{center}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n\\frametitle{Salary data, first order terms only}\n\\begin{scriptsize}\n\\begin{verbatim}\n> head(salary_data)\n  salary age educ pol\n1     38  25    4   D\n2     45  27    4   R\n3     28  26    4   O\n4     55  39    4   D\n5     74  42    4   R\n6     43  41    4   O\n> m = lm(salary ~ ., data=salary_data)\n> summary(m)\n\nCoefficients:\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept)  17.0313     7.3459   2.318  0.03735 *  \nage           0.8983     0.1968   4.565  0.00053 ***\neduc          1.5039     1.1841   1.270  0.22632    \npolO        -16.5404     4.8807  -3.389  0.00484 ** \npolR          9.1587     4.8482   1.889  0.08139 .  \n---\n\nResidual standard error: 8.209 on 13 degrees of freedom\nMultiple R-squared:  0.8374,\tAdjusted R-squared:  0.7873 \n\\end{verbatim}\n\\end{scriptsize}\n\\end{frame}\n\n\\begin{frame}{Added variable plots}\n\\centerline{\\includegraphics[height=0.7\\textheight]{plots/salary_av.pdf}}\n\n\\pause Age effect is nonlinear; let's add a quadratic term.\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\frametitle{Salary data, quadratic effect in age}\n\\begin{verbatim}\n> m1 = lm(salary ~ . + I(age^2), data=salary_data)\n> summary(m1)\n\nCoefficients:\n              Estimate Std. Error t value Pr(>|t|)    \n(Intercept) -39.224169  16.810142  -2.333 0.037839 *  \nage           3.463723   0.740666   4.676 0.000535 ***\neduc          2.166475   0.883369   2.453 0.030453 *  \npolO        -15.455108   3.571147  -4.328 0.000983 ***\npolR         10.118144   3.544586   2.855 0.014500 *  \nI(age^2)     -0.028831   0.008166  -3.530 0.004143 ** \n---\n\nResidual standard error: 5.984 on 12 degrees of freedom\nMultiple R-squared:  0.9202,\tAdjusted R-squared:  0.887 \n\\end{verbatim}\n\\end{frame}\n\n\\begin{frame}{Added variables plots w/ quadratic age}\n\\centerline{\\includegraphics[width=.75\\textwidth]{plots/salary_av2.pdf}}\nEducation is now significant! \\pause The incorrect\nfunctional form for age was \\textit{masking} the\nimportance of education.\n\\end{frame}\n\n\\begin{frame}[fragile]\n\\frametitle{Salary data, quadratic effect in education}\n\\begin{footnotesize}\n\\begin{verbatim}\n> summary(m2)\n\nCall:\nlm(formula = salary ~ . + I(age^2) + I(educ^2), data = salary_data)\n\n              Estimate Std. Error t value Pr(>|t|)    \n(Intercept) -75.977348  18.262402  -4.160 0.001589 ** \nage           2.787032   0.626151   4.451 0.000977 ***\neduc         18.751324   5.739109   3.267 0.007501 ** \npolO        -13.976910   2.848879  -4.906 0.000467 ***\npolR          9.495127   2.790631   3.403 0.005903 ** \nI(age^2)     -0.018677   0.007298  -2.559 0.026558 *  \nI(educ^2)    -1.342341   0.461108  -2.911 0.014161 *  \n---\n\nResidual standard error: 4.697 on 11 degrees of freedom\nMultiple R-squared:  0.9549,\tAdjusted R-squared:  0.9304 \n\\end{verbatim}\n\\end{footnotesize}\n\\end{frame}\n\n\n\\begin{frame}{Added variable plots w/ quad. age and educ}\n\\begin{center}\n\\includegraphics[height=.85\\textheight]{plots/salary_av3.pdf}        \n\\end{center}\n\\end{frame}\n\n\\section{Outliers, leverages, DFFITs, Cook's distance}\n\n\\begin{frame}{Outliers}\n\\begin{itemize}\n\\item Outliers are data points which are ``far away'' from the bulk of data. \\pause Observations may be outlying \n\\begin{itemize}\n    \\item relative to predictors, i.e. $\\mathbf{x}_i$ relative to other $\\{\\mathbf{x}_j\\}_{j\\ne i}$\n    \\item\\pause relative to the model, i.e. $Y_i$ relative to $\\hat{Y}_i$.\n\\end{itemize} \n\\item\\pause \\textbf{Studentized deleted residuals} are designed to detect outlying $Y_i$ observations; \\textbf{leverages} detect outlying $\\mathbf{x}_i$ points.\n\\item\\pause Outliers have the potential to influence the fitted regression\nfunction:\n\\begin{itemize}\n\\item\\pause if the outlying points follow the modeling\nassumptions and are representative, they may \\textit{strengthen} inference and reduce error in predictions \n\\item\\pause if not, outlying values may skew inference a lot and yield\nmodels with poor predictive properties.\n\\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Outliers \\& influential points}\n\\begin{itemize}\n\\item Often outliers are flagged and deemed suspect as mistakes\nor observations not gathered from the same population as the other observations.\n\\item\\pause Outliers are sometimes of interest in their own right and may illustrate aspects of the dataset that require more careful study.\n\\item\\pause Although an observation may be flagged as an outlier, the\npoint \\textit{may or may not} affect the fitted regression function\nmore than other points.\n\\item\\pause A \\textbf{DFFIT} is a measure of influence that an individual point\n$(\\mathbf{x}_i, Y_i)$ has on the regression surface at $\\mathbf{x}_i$.\n\\item\\pause \\textbf{Cook's distance} is a consolidated measure of influence the point $(\\mathbf{x}_i, Y_i)$ has on the regression surface at all $n$ points $\\mathbf{x}_1, \\ldots, \\mathbf{x}_n$.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Variance of $\\hat{Y}_i$}\nRecall that \n\\begin{itemize}\n    \\item $\\hat{\\mathbf{Y}}=\\pause\\mathbf{X}\\hat{\\boldsymbol\\beta}$,\n    \\item\\pause $\\hat{\\boldsymbol\\beta}\\pause=(\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{X}^\\top\\mathbf{Y}$,\n    \\item\\pause $\\mathbf{Y}\\pause\\sim\\mathcal{N}_n(\\mathbf{X}\\boldsymbol\\beta,\\sigma^2\\mathbf{I}_n)$\n\\end{itemize} \nThus,\n\\begin{align*}\n\\onslide<7->{\\Cov[\\hat{\\mathbf{Y}}]}\\onslide<8->{&=\\Cov[\\mathbf{X}\\hat{\\boldsymbol\\beta}]}\\onslide<9->{=\\Cov[\\mathbf{X}(\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{X}^\\top\\mathbf{Y}]\\\\}\n\\onslide<10->{&=\\Cov[\\mathbf{HY}]=\\mathbf{H}\\Cov[\\mathbf{Y}]\\mathbf{H}^\\top=\\mathbf{H}\\sigma^2\\mathbf{IH}^\\top\\\\}\n\\onslide<11->{&=\\sigma^2\\mathbf{H}}\n\\end{align*}\n\\onslide<12->{$\\Rightarrow$\\,\\,\n$\\Var[\\hat{Y}_i]=\\sigma^2h_{ii}$, and its unbiased estimator is $\\text{MSE}\\cdot h_{ii}$.}\n\n\\end{frame}\n\n\n\\begin{frame}{10.2 Studentized deleted residuals}\n\\begin{itemize}\n\\item The \\textbf{standardized residuals}\n$$\nr_i=\\frac{Y_i-\\hat{Y}_i}{\\sqrt{\\text{MSE}(1-h_{ii})}}\n$$\nhave a constant variance of 1.\n\\item\\pause Typically, $|r_i|>2$ is considered ``large.''\n\\item\\pause $h_{ii}=\\mathbf{x}^\\top_i(\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{x}_i$ is called the $i^\\text{th}$ \\textbf{leverage value}.\n\\item\\pause A refinement of the standardized residual that has a recognizable distribution is the \\textbf{studentized deleted residual}\n$$\nt_i=\\frac{Y_i-\\hat{Y}_{i}}{\\sqrt{\\text{MSE}_{(i)}(1-h_{ii})}}\n$$\nwhere $\\text{MSE}_{i(i)}$ is obtained from the model when $i$-th example was removed from the data.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Studentized deleted residuals}\n\\begin{itemize}\n\\item In fact, no need to fit $n$ additional regressions, because there is relationship b/w MSE and MSE$_{(i)}$:\n$$\n(n-p)\\text{MSE}=(n-p-1)\\text{MSE}_{(i)}+\\frac{e_i^2}{1-h_{ii}}\n$$\n(prove it)\n\n\\item\\pause Studentized deleted residuals are distributed as\n$$\nt_i\\sim t_{n-p-1}.\n$$\n\\item\\pause Therefore, outlying $Y$-values may be flagged by using Bonferroni's adjustment and taking\n$$\n|t_i|>t_{1-\\alpha/(2n); n-p-1}\n$$\nas outlying.\n\\item\\pause Typically, in practice, one simply flags observations with $|t_i|>t_{1-\\alpha/2; n-p-1}$ as \\textit{possibly} outlying in consideration with other diagnostics.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{10.3 Leverage}\n\\begin{itemize}\n\\item The leverages $h_{ii}$ get larger the further the points $\\mathbf{x}_i$ are from the mean $\\bar{\\mathbf{x}} = \\frac1n\\sum_{i=1}^n\\mathbf{x}_i$, adjusted for ``how many'' other\npredictors are in the vicinity of $\\mathbf{x}_i$.\n\\item\\pause Use the fact that $\\mathbf{H} = \\mathbf{X}(\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{X}^\\top = \\mathbf{HH}$ to show $\\sum_{i=1}^n h_{ii} = p$ and $0 \\le h_{ii} \\le1$.\n\\item\\pause A large leverage $h_{ii}$ indicates that $\\mathbf{x}_i$ is far away from the other predictors $\\{\\mathbf{x}_j\\}_{j\\ne i}$ \\pause and that $\\mathbf{x}_i$ may influence the fitted value $\\hat{Y}_i$ more than other $x_j$'s will influence their respective fitted values. \\pause This is evident in the variance of the residual $\\Var[Y_i - \\hat{Y}_i] = \\sigma^2 \\sqrt{1 - h_{ii}}$. The larger $h_{ii}$ is, the smaller\n$\\Var[Y_i - \\hat{Y}_i]$ will be and hence the closer $\\hat{Y}_i$ will be to $Y_i$ on average.\n\\item\\pause The rule of thumb is that any leverage $h_{ii}$ that is larger than\ntwice the mean leverage $p/n$, i.e. $h_{ii} > 2p/n$, is flagged as\nhaving ``high'' leverage.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}[fragile]{Leverage}\n\\begin{itemize}\n\\item Note that the leverages $h_{ii}$ depend only on the $\\mathbf{x}_i$ and hence\nindicate which points might \\textit{potentially} be influential.\n\\item \\pause (p. 400) When making predictions $\\mathbf{x}_{n+1}$ at a point not in the\ndata set, we consider the measure of distance of this point from the points $\\mathbf{x}_1 , \\ldots, \\mathbf{x}_n$ given by $h_{n+1} = \\mathbf{x}_{n+1}(\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{x}_{n+1}$.\n\\item \\pause If $h_{n+1}$ is much larger than any of the $\\{h_{11}, \\ldots, h_{nn}\\}$ you may\nbe extrapolating far outside the general region of your data.\n\\item \\pause In \\texttt{R}, you can get leverages using \\verb|hatvalues| command.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{10.4 DFFITs}\n\\begin{itemize}\n\\item The $i^\\text{th}$ DFFIT, denoted DFFIT$_i$, is given by\n$$\n\\text{DFFIT}_i=\\frac{\\hat{Y}_i-\\hat{Y}_{i(i)}}{\\sqrt{\\text{MSE}_{(i)}h_{ii}}}=t_i\\sqrt{\\frac{h_{ii}}{1-h_{ii}}},\n$$\n\\pause where $\\hat{Y}_i$ is fitted value of regression surface (calculated using all $n$ observations) at $\\mathbf{x}_i$ and $\\hat{Y}_{i(i)}$ is fitted value of regression surface \\textit{omitting the point} $(\\mathbf{x}_i, Y_i)$ at the point $\\mathbf{x}_i$.\n\\item\\pause $\\text{DFFIT}_i$ is standardized distance between \\textit{fitted} regression surfaces \\textit{with} and \\textit{without} the point $(\\mathbf{x}_i, Y_i)$.\n\\item\\pause Rule of thumb that $\\text{DFFIT}_i$ is ``large'' when $|\\text{DFFIT}_i|>1$ for small to medium-sized data sets and $|\\text{DFFIT}_i|>2\\sqrt{p/n}$ for large data sets. \\pause We will often just note those $\\text{DFFIT}_i$'s that are considerable larger than the bulk of the $\\text{DFFIT}_i$'s.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{10.4 Cook's distance}\n\\begin{itemize}\n\\item The $i^\\text{th}$ Cook's distance, denoted $D_i$, is an aggregate measure of the influence of the $i^\\text{th}$ observation on all $n$ fitted values:\n$$\nD_i=\\frac{\\sum_{j=1}^n(\\hat{Y}_j - \\hat{Y}_{j(i)})^2}{p\\cdot\\text{MSE}}\n$$\n\\pause This is the sum of squared distances, at each $\\mathbf{x}_j$, between fitted regression surface calculated with all $n$ points and fitted regression surface calculated with the $i^\\text{th}$ case removed, standardized by $p\\cdot \\text{MSE}$.\n\\item \\pause Look for values of Cook's distance significantly larger than other values; these are cases that have disproportionate\ninfluence on the fitted regression surface as a whole.\n\\end{itemize}\n\\end{frame}\n\n\\section{Review of Diagnostics}\n\n\\begin{frame}{Review of diagnostics}\n\\begin{itemize}\n\\item \\structure{Variance inflation factors} VIF$_j$ tell you which predictors are highly correlated with other predictors. If you have one or more VIF$_j>10$, you \\text{may} want to eliminate some of the predictors.\n\\vspace{10pt}\n\n\\pause Multicollinearity affects the interpretability of the model, but does not indicate the model is ``bad'' in any way.\n\\vspace{10pt}\n\n\\pause An alternative approach that allows keeping correlated predictors is ridge regression (Chapter 11).\n\n\\item \\structure{Deleted residuals} $t_i \\sim t_{n-p-1}$, so you can formally define an outlier as being larger than $t_{1 - \\alpha/(2n), n-p-1}$.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Review of diagnostics}\n\\begin{itemize}\n\\item \\structure{Residual plots}. Plots of $e_i$ or $t_i$ vs. $\\hat{Y}_i$ and versus each $x_1, \\ldots, x_k$ help assess (a) correct functional form, (b) constant\nvariance, and (c) outlying observations. %If an anomaly is apparent in any of these plots I may look at an added variable plot. If the number of predictors is small I may look at every added variable plot. \nThey may also suggest a transformation for a predictor or two.\n\\begin{itemize}\n\\item\\pause Heteroscedasticy can be corrected by transforming $Y$, or else\nmodeling the variance directly (Chapter 11).\n\\item\\pause Constant variance but nonlinear patterns can be accommodated by introducing quadratic terms. \n\\end{itemize}\n\n\\pause\\structure{Added variable plots} help figure out functional form of predictors, and whether significance is being driven by one or two points only.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Review of diagnostics}\n\\begin{itemize}\n\\item \\textbf{DFFIT}$_i$ and \\textbf{Cook's distance} $D_i$ tell you which observations\n\\textit{influence} the fitted model the most. Sometimes one or two points can drive the significance of a predictor.\n\\item\\pause \\textbf{Leverages} tell you which points \\textit{can potentially} influence the fitted model. %Useful for finding ``hidden extrapolations'' via $h_{n+1}$.\n%\\item (pp.~404–405) DFBETA_{ij} tells you how much observation $i$ affects regression coefficient $j$. Useful to ``zoom in'' on where influential points are affecting the model. \n\\item\\pause A \\textbf{normal Q-Q plot} of the residuals will indicate  departures from normality.\n\\item\\pause A list of the studentized deleted residuals, leverages, and Cook's distances helps to determine outlying values that may\nbe transcription errors or data anomalies and also indicates those observations that affect the fitted regression surface as\na whole.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Standard diagnostic plots}\n\\begin{itemize}\n\\item $t_i$ vs. $h_i$. Which observations are outlying in $\\mathbf{x}$-direction, outlying in $Y$-direction, or both?\n\\item $D_i$ vs. $i$. Which observations grossly affect fit of regression surface?\n\\item $e_i$ vs. $\\hat{Y}_i$ and $t_i$ vs. $\\hat{Y}_i$. Constant variance \\& linearity.\n\\item $Y_i$ vs. $\\hat{Y}_i$; how well model predicts its own data. Better models have points close to line $y = x$.\n\\item Normal probability plot of the $e_1, \\ldots, e_n$.\n\\item Histogram of $e_1, \\ldots, e_n$.\n\\item Plots of $e_i$ vs. each predictor $x_1 , \\ldots, x_k$.\n\\item One more plot that prof. Hanson never looks at.\n\\end{itemize}\n\\end{frame}\n\n\\section{Example}\n\n\\begin{frame}{An example of diagnostics}\n\\centerline{\\includegraphics[height=.7\\textheight]{plots/bp-diag}}\n\\vspace{10pt}\nModel is $Y_i=\\beta_0+\\beta_1 x_{i1} + \\beta_2 x_{i2} + \\beta_{12} x_{i1} x_{i2} + \\epsilon_i$. One highly influential point \\& one poorly fit.\n\\end{frame}\n\n\\begin{frame}{Residual plots}\n\\centerline{\\includegraphics[scale=0.30]{plots/bp-res}}\n\\vspace{10pt}\n\nThese look pretty good, except for the one large residual.\n\\end{frame}\n\n\\begin{frame}{Arterial pressure data}\n\\includegraphics[scale=0.33]{plots/bp-cookd}\n\\vspace{10pt}\n\nObs. 7 has largest arterial pressure. Obs. 8 has relatively small arterial pressure.\n\\end{frame}\n\n\\begin{frame}{Dropping obs. 8 and obs. 7}\n\\includegraphics[scale=0.33]{plots/bp-two}\n\\vspace{10pt}\n\nHow do 7 and 8 affect the significance and/or magnitude of the effects?\n\\end{frame}\n\n\\end{document}", "meta": {"hexsha": "4fdcda7efc898048ffe05994ed70ccc01df8b7af", "size": 21086, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/10 Model diagnostics/main.tex", "max_stars_repo_name": "zh3nis/MATH440", "max_stars_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/10 Model diagnostics/main.tex", "max_issues_repo_name": "zh3nis/MATH440", "max_issues_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/10 Model diagnostics/main.tex", "max_forks_repo_name": "zh3nis/MATH440", "max_forks_repo_head_hexsha": "66e547d4ce4016e39d317b6ef043223eb0e15ed0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.7065637066, "max_line_length": 423, "alphanum_fraction": 0.7111353505, "num_tokens": 6937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.8006920092299292, "lm_q1q2_score": 0.4097273963768956}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#2}\n\\newcommand{\\hmwkDueDate}{Due on 20th September, 2018}\n\\newcommand{\\hmwkClass}{Advanced Quantum Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n\n\\textit{\\textbf{Acknowledgements} - I would like to thank Chandramouli Chowdhury and Junaid Bhat for discussions in this assignment.}\n\\begin{homeworkProblem}\nBefore we start looking at the the actual problem itself, let's consider a simpler problem - that of proving $ e^x e^{-x} = 1$. Lets Taylor expand the same and look at terms order by order,\n\\begin{align*}\ne^x e^{-x} &= \\qty(1 + x + \\dfrac{x^2 }{2!} + \\dfrac{x^3}{3!} + \\ldots)\\qty(1 - x + \\dfrac{x^2 }{2!} - \\dfrac{x^3}{3!} + \\ldots)\\\\\n&= 1 + (x -x) + \\qty(\\dfrac{x^2 }{2} + \\dfrac{x^2 }{2} - x^2) + \\qty(\\dfrac{x^3 }{6} -  \\dfrac{x^3 }{6} + \\dfrac{x^3}{2} - \\dfrac{x^3}{2} ) + \\ldots\n\\end{align*}\nWe note that terms cancel out order by order.\n\\begin{align*}\nU &= \\sum_n \\dfrac{(-i)^n}{n!} \\int_{0}^{t} dt_1 \\ldots \\int_{0}^{t} dt_n \\mathcal{T}[H(t_1)\\ldots H(t_2)]\\\\\n&= 1 - i \\int_0^t dt_1 H(t_1) - \\dfrac{1}{2} \\int_0^t \\int_0^t dt_1 dt_2 \\qty[\\theta(t_1 - t_2)H(t_1)H(t_2) + \\theta(t_2 - t_1)H(t_2)H(t_1)] + \\ldots\\\\\nU^\\dagger &= 1 + i \\int_0^t dt_1 H(t_1) - \\dfrac{1}{2} \\int_0^t \\int_0^t dt_1 dt_2 \\qty[\\theta(t_2 - t_1)H(t_1)H(t_2) + \\theta(t_1 - t_2)H(t_2)H(t_1)] + \\ldots\\\\\n\\therefore U^\\dagger U &= 1 + \\qty(- i \\int_0^t dt_1 H(t_1) + i \\int_0^t dt'_1 H(t'_1) ) + \\int_0^t \\int_0^t dt_1 dt_2 \\qty[H(t_1) H(t_2)]\\\\\n&\\qty(- \\dfrac{1}{2} \\int_0^t \\int_0^t dt_1 dt_2 \\qty[\\theta_{12}H(t_1)H(t_2) + \\theta_{21}H(t_2)H(t_1)] - \\dfrac{1}{2} \\int_0^t \\int_0^t dt'_1 dt'_2 \\qty[\\theta_{2'1'}H(t'_1)H(t'_2) + \\theta_{1'2'}H(t'_2)H(t'_1)] )\\\\&+ \\ldots\n%&+ \\dfrac{1}{4} \\int_0^t \\int_0^t \\int_0^t \\int_0^t dt_1 dt_2  dt'_1 dt'_2 \\qty[\\theta_{12}\\theta_{1'2'}H(t_1)H(t_2)H(t_1)H(t_2) + \\theta_{21}H(t_2)H(t_1)]\n\\end{align*}\nThe terms in the first parenthesis just cancel each other. As the primed variables are just dummies one can ignore the primes and write the terms in the second parenthesis in terms of $ t_1 $ and $ t_2 $. We can rewrite that particular term as follows (using the fact that $ \\theta_{12} + \\theta_{21} = 1 $),\n\\begin{align*}\n- \\dfrac{1}{2} \\int_0^t \\int_0^t dt_1 dt_2 \\qty[\\theta_{12}H(t_1)H(t_2) + \\theta_{21}H(t_2)H(t_1) + \\theta_{21}H(t_1)H(t_2) + \\theta_{12}H(t_2)H(t_1)]\\\\\n= - \\dfrac{1}{2} \\int_0^t \\int_0^t dt_1 dt_2 \\qty[H(t_1)H(t_2) + H(t_2)H(t_1)] = - \\int_0^t \\int_0^t dt_1 dt_2 \\qty[H(t_1)H(t_2)]\n\\end{align*}\nThis shows that the terms cancel. This will hold at higher orders too, albeit with more complicated $ \\theta $ functions.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}\n\tWe know that the energy eigenstates of the harmonic oscillator form a basis. Hence, the required coherent state $ \\ket{z} $ can be written in terms of these eigenstates as,\n\t\\begin{equation*}\n\t\\ket{z} = \\sum_{n=0}^{\\infty} c_n \\ket{n} = \\sum_{n=0}^{\\infty} c_n \\frac{(a^\\dagger)^n}{\\sqrt{n!}}\\ket{0}\n\t\\end{equation*}\n\tSubstituting this in the equation for coherent state $ a\\ket{z} = z \\ket{z} $,\n\t\\begin{align*}\n\t \\sum_{n=0}^{\\infty} c_n a \\ket{n} &=  \\sum_{n=0}^{\\infty} z c_n \\ket{n}\\\\\n\t \\sum_{n=1}^{\\infty} c_n \\sqrt{n} \\ket{n-1} &=  \\sum_{n=0}^{\\infty} z c_n \\ket{n}\\\\\n\t \\sum_{n=0}^{\\infty} c_{n+1} \\sqrt{n+1} \\ket{n} &=  \\sum_{n=0}^{\\infty} z c_n \\ket{n}\\\\\n\t \\therefore c_{n+1} \\sqrt{n+1} &= z c_n\n\t\\end{align*}\n\t\n\tWe have effectively derived a recursion relation for the coefficients $ c_n $. If we start off with $ c_n = \\alpha $,\n\t\\begin{equation*}\n\tc_1 = {z \\alpha} \\qq{,} c_2 = \\frac{z^2 \\alpha}{\\sqrt{2}} \\qq{,} c_3 = \\dfrac{z^3 \\alpha}{\\sqrt{3\\vdot 2}} \\qq{,} \\ldots \\qq{,} c_n = \\dfrac{z^n \\alpha}{\\sqrt{n!}}\n\t\\end{equation*}\n\tSo, our coherent state can now be written as,\n\t\\begin{align*}\n\t\\ket{z} &= \\alpha \\sum_{n=0}^{\\infty}  \\frac{(za^\\dagger)^n}{n!}\\ket{0}\\\\\n\t&= \\alpha e^{a^\\dagger z}\\ket{0}\n\t\\end{align*}\n\\end{homeworkProblem}\t\n\\begin{homeworkProblem}\n\tWe know that,\n\t\\begin{equation*}\n\t{x}(0) = \\frac{{a} + {a}^\\dagger}{\\sqrt{2m\\omega}} \\qq{,} {p}(0) = \\frac{\\sqrt{m\\omega} ({a} - {a}^\\dagger)}{\\sqrt{2}i} \\qq{,} x(t) = e^{iHt}x(0)e^{-iHt} \\qq{,} p(t) = e^{iHt}p(0)e^{-iHt}\n\t\\end{equation*}\n\tFrom this, we note the following,\n\t\\begin{align*}\n\t x(t)\\ket{0} &= e^{iHt}x(0)e^{-iHt}\\ket{0}\\\\\n\t &=  e^{-i\\omega t/2}e^{iHt}x(0)\\ket{0}\\\\\n\t &=  \\frac{e^{-i\\omega t/2}}{\\sqrt{2m\\omega}}e^{iHt}\\ket{1}\\\\\n\t x(t)\\ket{0} &=  \\frac{e^{i\\omega t}}{\\sqrt{2m\\omega}}\\ket{1} \\implies \\bra{0}x(t)=\\frac{e^{-i\\omega t}}{\\sqrt{2m\\omega}} \\bra{1}\n\t\\end{align*}\n\t\\begin{align*}\n\t\\qq{Similarly, }\t p(t)\\ket{0} &= e^{iHt}p(0)e^{-iHt}\\ket{0}\\\\\n\t&=  e^{-i\\omega t/2}e^{iHt}p(0)\\ket{0}\\\\\n\t&=  -\\frac{e^{-i\\omega t/2}\\sqrt{m\\omega}}{\\sqrt{2}i}e^{iHt}\\ket{1}\\\\\n\tp(t)\\ket{0} &=  -\\frac{e^{i\\omega t}\\sqrt{m\\omega}}{\\sqrt{2}i}\\ket{1} \\implies \\bra{0}p(t) =  \\frac{e^{-i\\omega t}\\sqrt{m\\omega}}{\\sqrt{2}i}\\bra{1} \n\t\\end{align*}\n\t\n\tNow consider the quantities to be calculated,\n\t\\begin{equation*}\n\tC_1(t) = \\ev{x(t)x(0)}{0} = \\frac{e^{-i\\omega t}}{\\sqrt{2m\\omega}} \\frac{1}{\\sqrt{2m\\omega}} = \\boxed{\\frac{e^{-i\\omega t}}{2m\\omega}}\n\t\\end{equation*}\n\t\\begin{equation*}\n\tC_2(t) = \\ev{x(t)p(0)}{0} - \\ev{p(0)x(t)}{0}= -\\dfrac{e^{-i\\omega t}}{2i} - \\dfrac{e^{i\\omega t}}{2i}= \\boxed{i \\cos \\omega t}\n\t\\end{equation*}\n\t\\begin{equation*}\n\tC_3(t) = \\ev{p(t)x(0)}{0} - \\ev{x(0)p(t)}{0}= \\dfrac{e^{-i\\omega t}}{2i} + \\dfrac{e^{i\\omega t}}{2i}= \\boxed{-i \\cos \\omega t}\n\t\\end{equation*}\n\\end{homeworkProblem}\n\n\n\\begin{homeworkProblem}\n\t\\textbf{Part (a)}\n\t\\begin{align*}\n\tZ(\\beta) = \\Tr e^{-\\beta H} &= \\sum_{n=0}^{\\infty} \\expval{e^{-\\beta H}}{n}\\\\\n\t&= \\sum_{n=0}^{\\infty} e^{-\\beta(n+\\frac{1}{2})\\omega}\\\\\n\t&= \\frac{e^{-\\beta \\omega /2}}{1-e^{-\\beta \\omega}} = \\dfrac{2}{\\sinh \\dfrac{\\beta \\omega}{2}}\n\t\\end{align*}\n\t\n\t\\textbf{Part (b)}\\\\\n\tGiven that,\n\t\\begin{equation*}\n\tx(\\tau) = \\sum_n x_n e^{\\frac{2\\pi i n \\tau}{\\beta}}\n\t\\end{equation*}\n\tAs we require $ x(\\tau) $ to be real, it follows from above that $ x_n = x_n^* $. Taking $ \\omega_n = \\frac{2\\pi n}{\\beta} $\n\t\\begin{equation*}\n\tS_E = \\int_{0}^{\\beta} d \\tau \\qty(\\frac{m\\dot{x}^2}{2} + \\frac{m\\omega^2 x^2}{2})\n\t\\end{equation*}\n\t\\begin{align*}\n\t&=  \\sum_{p,q} \\qty(-\\frac{m x_p x_q \\omega_p \\omega_q}{2} + \\frac{m\\omega^2 x_p x_q }{2}) \\int_{0}^{\\beta} e^{i (\\omega_q + \\omega_p)\\tau} d \\tau\\\\\n\t&=  \\sum_{p,q} \\qty(-\\frac{m x_p x_q \\omega_p \\omega_q}{2} + \\frac{m\\omega^2 x_p x_q }{2}) \\beta \\delta_{p,-q}\\\\\n\t&=  \\sum_{q} \\qty(-\\frac{m x_{-q} x_q \\omega_{-q} \\omega_q}{2} + \\frac{m\\omega^2 x_{-q} x_q }{2}) \\beta \\\\\n\t&=  \\frac{m}{2}\\sum_{q} \\beta\\qty(x_{q}^* x_q  \\omega_q^2 + \\omega^2 x_{q}^* x_q)\\\\\n\t-S_E&=  -\\frac{m\\beta}{2}\\sum_{q}x_{q}^* x_q   \\qty(\\omega_q^2 + \\omega^2 )\n\t\\end{align*}\n\tThe required path integral to be done is,\n\t\\begin{align*}\n\tZ(\\beta) &= N \\int \\mathcal{D}x \\exp - \\frac{m\\beta}{2}\\sum_{q}x_{q}^* x_q   \\qty(\\omega_q^2 + \\omega^2 ) \\qq{where $ N $ is some normalization}\\\\\n\t&= N \\int \\mathcal{D}x \\exp( - m\\beta \\sum_{q=1}^{\\infty} x_{q}^* x_q   \\qty(\\omega_q^2 + \\omega^2 ) - \\frac{m\\beta x_0^2\\omega^2}{2}) \\\\\n\t&= N \\int dx_0  \\exp(-\\frac{m\\beta x_0^2\\omega^2}{2}) \\cross \\prod_{q=1}^{\\infty} \\int d x_q d x_q^* \\exp -  m\\beta x_{q}^* x_q   \\qty(\\omega_q^2 + \\omega^2 ) \\\\\n\t&= N \\sqrt{\\frac{2\\pi}{m \\beta \\omega^2}} \\cross \\prod_{q=1}^\\infty \\frac{2\\pi}{m \\beta (\\omega_q^2 + \\omega^2 )}\\\\\n\t&= N \\sqrt{\\frac{2\\pi}{m \\beta \\omega^2}} \\cross \\prod_{q=1}^\\infty \\frac{2\\pi}{m \\beta \\dfrac{4 q^2 \\pi^2}{\\beta^2}\\qty(1 + \\qty(\\frac{\\beta \\omega}{2q\\pi})^2)}\\\\\n\t&= N \\sqrt{\\frac{2\\pi}{m \\beta \\omega^2}} \\cross \\dfrac{\\beta \\omega}{2 \\pi \\sinh \\dfrac{\\beta \\omega}{2}} \\cross \\prod_{q=1}^\\infty \\frac{\\beta}{2 \\pi m q^2} \\\\\n\t&= N \\sqrt{\\frac{\\beta}{2 \\pi m}}  \\cross \\prod_{q=1}^\\infty \\frac{\\beta}{2 \\pi m q^2} \\cross \\dfrac{1}{\\sinh \\dfrac{\\beta \\omega}{2}} \\\\\n\t&= N'  \\cross \\dfrac{1}{\\sinh \\dfrac{\\beta \\omega}{2}}\n\t\\end{align*}\n\tAs $ N' $ does not depend on $ \\omega $, we can drop it altogether for computation purposes. This gives us the required result.\n\t\n\\end{homeworkProblem}\n%\\pagebreak \t\n\n\\end{document}\n", "meta": {"hexsha": "e674dfece75034081f3b01b945d5407b63517cac", "size": 11336, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/qmech/assign_2/assign_2.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/qmech/assign_2/assign_2.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/qmech/assign_2/assign_2.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.9851851852, "max_line_length": 308, "alphanum_fraction": 0.6361150318, "num_tokens": 4849, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.8006919925839875, "lm_q1q2_score": 0.40972738785889085}}
{"text": "\\section{Cartoon of Algorithm}\r\n\\label{AlgCartoon}\r\n\r\nRefer to Fig. \\ref{fig:cartoon}.\r\n\r\n\\begin{figure}\r\n\\begin{center}\r\n\\scalebox{1}{\\includegraphics[width=1.0\\textwidth]{../AlgorithmFigure}}\r\n\\end{center}\r\n\\caption{A cartoon of the algorithm.  $a):$ The initial two models with approximately the same loss, $L_0$. $b):$ The interpolated loss curve, in red, and its global maximum, occuring at $t=t^*$. $c):$ The interpolated model $\\Theta(\\theta_i, \\theta_j, t^*)$ is added and labeled $\\theta_{i,j}$.  $d):$ Stochastic gradient descent is performed on the interpolated model until its loss is below $\\alpha L_0$. $e):$ New interpolated loss curves are calculated between the models, pairwise on a chain.  $f):$ As in step $c)$, a new model is inserted at the maxima of the interpolated loss curve between $\\theta_i$ and $\\theta_{i,j}$.  $g):$  As in step $d)$, gradient descent is performed until the model has low enough loss.}\r\n\\label{fig:cartoon}\r\n\\end{figure}\r\n\r\n\r\n\\section{Visualization of Connection}\r\n\\label{visualization}\r\n\r\n Because the weight matrices are anywhere from high to extremely high dimensional, for the purposes of visualization we projected the models on the connecting path into a three dimensionsal subspace.  Snapshots of the algorithm in progress for the quadratic regression task are indicated in Fig. \\ref{connfigs}.  This was done by vectorizing all of the weight matrices for all the beads for a given connecting path, and then performing principal component analysis to find the three highest weight projections for the collection of models that define the endpoints of segments for a connecting path---i.e., the $\\theta_i$ discussed in the algorithm.  We then projected the connecting string of models onto these three directions.  \r\n \r\n The color of the strings was chosen to be representative of the test loss under a log mapping, so that extremely high test loss mapped to red, whereas test loss near the threshold mapped to blue.  An animation of the connecting path can be seen on our \\href{github.com/danielfreeman11/convex-nets/blob/master/Writeup/Plots/quadratic.pathinterp.errorvis.gif}{Github page}.\r\n \r\n Finally, projections onto pairs of principal components are indicated by the black curves.\r\n \r\n\\begin{figure}\r\n\\centering\r\n\\includegraphics[width=.4\\textwidth]{../Plots/conn1}\r\n\\includegraphics[width=.4\\textwidth]{../Plots/conn2}\r\n\\includegraphics[width=.4\\textwidth]{../Plots/conn3}\r\n\\includegraphics[width=.4\\textwidth]{../Plots/conn4}\r\n\\caption{Snapshots of Dynamic String Sampling in action for the quadratic regression task.  The string's coordinates are its projections onto the three most important principal axes of the fully converged string.  (Top Left) One step into the algorithm, note the high loss between all of the vertices of the path. (Top Right) An intermediate step of the algorithm.  Portions of the string have converged, but there are still regions with high interpolated loss. (Bottom Left) Near the end of the algorithm.  Almost the entire string has converged to low loss.  (Bottom Right) The algorithm has finished.  A continuous path between the models has been found with low loss.} \r\n\\label{connfigs}\r\n\\end{figure}\r\n \r\n \r\n\r\n\r\n\\section{A Disconnection}\r\n\\label{sec:disconnect}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%\r\n\\subsection{A Disconnection}\r\n%%%%%%%%%%%%%%%%%%%%%%\r\n\\label{symdisc}\r\n\r\n As a sanity check for the algorithm, we also applied it to a problem for which we know that it is not possible to connect models of equivalent power by the arguments of section \\ref{disconnect}.  The input data is 3 points in $\\mathbb{R}^2$, and the task is to permute the datapoints, i.e. map $\\{x_1,x_2,x_3\\} \\to \\{x_2,x_3,x_1\\}$.  This map requires at least 12 parameters in general for the three linear maps which take $x_i\\to x_j$ for $i,j \\in \\{\\{1,2\\},\\{2,3\\},\\{3,1\\}\\}$.  Our archticture was a 2-3-2 fully connected neural network with a single relu nonlinearity after the hidden layer---a model which clearly has 12 free parameters by construction.  The two models we tried to connect were a single model, $\\theta$, and a copy of $\\theta$ with the first two neurons in the hidden layer permuted, $\\tilde{\\theta_{\\sigma}}$.  The algorithm fails to converge when initialized with these two models.  We provide a visualization of the string of models produced by the algorithm in Fig. \\ref{discfigs}.\r\n \r\n In general, a persistent high interpolated loss between two neighboring beads on the string of models could arise from either a slowly converging, connected pair of models or from a truly disconnected pair of models.  ``Proving'' a disconnection at the level of numerical experiments is intractable in general, but a collection of negative results---i.e., failures to converge---are highly suggestive of a true disconnection.\r\n \r\n\\begin{figure}\r\n\\centering\r\n\\includegraphics[width=.4\\textwidth]{../Plots/disc1}\r\n\\includegraphics[width=.4\\textwidth]{../Plots/disc2}\r\n\\includegraphics[width=.4\\textwidth]{../Plots/disc3}\r\n\\caption{These three figures are projections of the components of the 12-dimensional weight matrices which comprise the models on the string produced by the DSS algorithm.  The axes are the principal components of the weight matrices, and the colors indicate test error for the model.  For more details on the figure generation, see Appendix \\ref{visualization}. (Left) The string of models after 1 step.  Note the high error at all points except the middle and the endpoints.  (Middle) An intermediate stage of the algorithm.  Part of the string has converged, but a persistent high-error segment still exists.  (Right) Even after running for many steps, the error persists, and the algorithm does not converge.}\r\n\\label{discfigs}\r\n\\end{figure}", "meta": {"hexsha": "5ca47f8ce7de1f9603dd7b68f0c92af833ba6ef5", "size": 5735, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Writeup/iclr/visualization.tex", "max_stars_repo_name": "danielfreeman11/convex-nets", "max_stars_repo_head_hexsha": "252a8230845fb2076221113ac8cabfade5152bfb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-08-09T00:48:46.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-03T09:04:59.000Z", "max_issues_repo_path": "Writeup/iclr/visualization.tex", "max_issues_repo_name": "danielfreeman11/convex-nets", "max_issues_repo_head_hexsha": "252a8230845fb2076221113ac8cabfade5152bfb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Writeup/iclr/visualization.tex", "max_forks_repo_name": "danielfreeman11/convex-nets", "max_forks_repo_head_hexsha": "252a8230845fb2076221113ac8cabfade5152bfb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 102.4107142857, "max_line_length": 1008, "alphanum_fraction": 0.7595466434, "num_tokens": 1389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4096728174820859}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% =================================================================================================\n% create checkpoint file\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   import cdblib\n   checkpoint_file = 'tests/semantic/output/genGamma.json'\n   cdblib.create (checkpoint_file)\n   checkpoint = []\n\\end{cadabra}\n\\egroup\n\n% =================================================================================================\n\\section*{The generalised connections}\n\nThe generalised connections may be computed recursively using\n\\begin{align}\n   \\label{eq:GenGamma}\n\\Gamma^{a}{}_{b\\uc d} = \\Gamma^{a}{}_{(b\\uc,d)}\n                - (n+1) \\Gamma^{a}{}_{p(\\uc}\n                        \\Gamma^{p}{}_{bd)}\n\\end{align}\nwhere $\\uc$ contains $n>0$ indices. The sequence begins with the standard metric compatible connection\n\\begin{align}\n   \\Gamma^{d}_{ab} = \\frac{1}{2} g^{dc}\\left( g_{cb,a} + g_{ac,b} - g_{ab,c} \\right)\n\\end{align}\n\nHere we will use the results of {\\tt metric.tex} and {\\tt metric-inv.tex} to compute the metric connection\n$\\Gamma^{d}_{ab}$. But since the $g_{ab}$ and $g^{ab}$ provided by those codes are truncated at a\nparticular order in the curvatures (and thus are only approximations to the $g_{ab}$ and $g^{ab}$) similar\ntruncations will arise in the $\\Gamma^{a}{}_{b\\uc d}$.\n\nApproximations will be denoted by the addition of an overbar to an object. In this notation the metric\n$g$ can be written as\n\\begin{align}\n   g = {\\bar g} + \\BigO{\\eps^n}\n\\end{align}\nin which ${\\bar g}$ is the truncated polynomial approximation to $g$ and $\\BigO{\\eps^n}$ is the error term\n(containing terms no smaller than $\\eps^n$). The polynomial structure of ${\\bar g}$ can be expressed as\n\\begin{align}\n   \\gabBar = \\ngabBar{0}\n           + \\ngabBar{1}\n           + \\ngabBar{2}\n           + \\dots\n           + \\ngabBar{p}\n\\end{align}\nin which each terms like $\\overset{m}{\\bar g}$ contains only terms of order $m$. This notation will be applied\nto other quantities in particular the generalised connections.\n\nThe notation $\\BigO{\\eps^n}$ denotes terms in the curvatures that are of order $\\eps^n$. What does this actually mean?\nEach term in $R$ is of order $\\eps^2$ while each derivative of $R$ carries an extra power of $\\eps$.\nThus $R\\cdot R = \\BigO{\\eps^4}$, $R\\cdot R\\cdot\\nabla R = \\BigO{\\eps^7}$ and $R\\cdot R\\cdot\\nabla^2R = \\BigO{\\eps^8}$.\n\nWe will also adopt the convention that an object is said to be an $\\BigO{\\eps^{m}}$ approximation when the corresponding error term is $\\BigO{\\eps^{m+1}}$.\n\nConsider the $\\BigO{\\eps^{m}}$ approximation of the generalised connection, namely,\n\\begin{align}\n   \\GammaBar^{a}{}_{b\\ucn d}\n      = \\nGammaBar{0}^{a}{}_{b\\ucn d}\n      + \\nGammaBar{1}^{a}{}_{b\\ucn d}\n      + \\nGammaBar{2}^{a}{}_{b\\ucn d}\n      + \\dots\n      + \\nGammaBar{m}^{a}{}_{b\\ucn d}\n\\end{align}\nwhere $\\ucn$ denotes a set of indices such as $c_1c_2c_3\\dots c_n$.\n\nThe first thing to note is that\n\\begin{align}\n   0 = \\nGammaBar{1+n}^{a}{}_{(b\\ucn,d)}\n\\end{align}\n\nThere are two proofs of this claim. For the first proof, note (by inspection) that the order $\\BigO{\\eps^p}$\napproximation for $\\GammaBar^{a}{}_{b\\ucn d}$ is a polynomial in $x$ of degree $p-n-1$. Thus\n$\\nGammaBar{1+n}^{a}{}_{(b\\ucn,d)}$ is a polynomial in $x$ of degree\nzero, i.e., a constant. However, we know that all generalised connections vanish at the origin of the RNC frame.\nThus this constant must be zero. The second proof makes explicit use of the first (and second?) Bianchi identity,\nthat is $0=R_{a(bcd)}$. The term $\\nGammaBar{1+n}^{a}{}_{(b\\ucn,d)}$ will\nitself consist of a sum of terms built from combinations of $x$, $R$, $\\nabla R$ etc. The $x^{a}$ will always\nappear in a contraction with one of the indices on $R_{abcd}$ or one of its derivatives. Consider any one of\nthese terms, denoted by $A$, and assume for the moment that $1+n$ is an even number, say $1+n=2p$. The indices\n$(b\\ucn,d)$ must somehow be assigned to the factors that comprise $A$. Our aim is to show that at least one $R$\nfactor in $A$ will receive 3 of these indices and thus by the Bianchi identities will be zero. If there are too\nmany $R$ factors then the Bianchi identities will not come into play. So how many $R$ factors can we expect?\nSince $A$ is a term in an $\\BigO{\\eps^{(n+1)}}$ approximation there can be no more than $(n+1)/2=p$ Riemann\nfactors. There will be at least one $x$ term contracted with one of the $p$ Riemann factors. However, we have\n$n+2=2p+1$ indices to distribute amongst the $x$ term and $p$ Riemann factors. One of the indices is a derivative\nindex and will have nett effect of transferring that index from $x$ to one of the Riemann factors. The remaining\n$2p$ indices must be distributed amongst the $p$ Riemann factors. It is not possible to avoid assigning three\nindices to at least one of the Riemann factors. Thus, by the Bianchi identity, this $A$ term must vanish. Similar\narguments can be applied to the other cases where the $A$ terms consists of products of $R$ and its derivatives\nand in the case where $n+1$ is an odd number. The analysis always comes down to the distribution of the indices\n$(b\\ucn,d)$ amongst the factors of a typical $A$ term. In all cases the Bianchi identity will enter the play and\nforce $A$ to be zero.\n\nA corollary of the second proof is that for all $m<n+2$\n\\begin{align}\n   0 = \\nGammaBar{m}^{a}{}_{b\\ucn d}\n\\end{align}\nThe proof follows exactly that of the second proof given above.\n\nWe can use the above results to streamline the computation of the generalised connections.\nWe begin with the formal expression for the $\\BigO{\\eps^m}$ approximations\n\\begin{align}\n   \\Gamma^{a}{}_{bc}\n      &= \\nGammaBar{2}^{a}{}_{bc}\n       + \\nGammaBar{3}^{a}{}_{bc}\n       + \\nGammaBar{4}^{a}{}_{bc}\n       + \\dots\n       + \\nGammaBar{m}^{a}{}_{bc}\\\\\n   \\Gamma^{a}{}_{b\\uc}\n      &= \\nGammaBar{n+1}^{a}{}_{b\\uc}\n       + \\nGammaBar{n+2}^{a}{}_{b\\uc}\n       + \\nGammaBar{n+3}^{a}{}_{b\\uc}\n       + \\dots\n       + \\nGammaBar{m}^{a}{}_{b\\uc}\\\\\n   \\Gamma^{a}{}_{b\\uc d}\n      &= \\nGammaBar{n+2}^{a}{}_{b\\uc d}\n       + \\nGammaBar{n+3}^{a}{}_{b\\uc d}\n       + \\nGammaBar{n+4}^{a}{}_{b\\uc d}\n       + \\dots\n       + \\nGammaBar{m}^{a}{}_{b\\uc d}\\label{eq:GenGammaA}\n\\end{align}\nThese can be substituted into equation (\\ref{eq:GenGamma}) with the result\n\\def\\m{\\hskip 4pt}\n\\begin{align}\n   \\Gamma^{a}{}_{b\\uc d}\n      &= \\nGammaBar{n+1}^{a}{}_{(b\\uc,d)}\n       + \\nGammaBar{n+2}^{a}{}_{(b\\uc,d)}\n       + \\nGammaBar{n+3}^{a}{}_{(b\\uc,d)}\n       + \\dots\n       + \\nGammaBar{m}^{a}{}_{(b\\uc,d)}\n       -(n+1)\\left(\\m \\nGammaBar{n+1}^{a}{}_{p\\uc}\n                    + \\nGammaBar{n+2}^{a}{}_{p\\uc}\n                    + \\nGammaBar{n+3}^{a}{}_{p\\uc}\n                    + \\dots\n                    + \\nGammaBar{m}^{a}{}_{p\\uc}\\right)\n             \\left(   \\nGammaBar{2}^{p}{}_{bd}\n                    + \\nGammaBar{3}^{p}{}_{bd}\n                    + \\nGammaBar{4}^{p}{}_{bd}\n                    + \\dots\n                    + \\nGammaBar{m}^{p}{}_{bd}\\right)\\label{eq:GenGammaB}\n\\end{align}\nwhere it is understood that in expanding the pair of bracketed terms in the last result the terms should be\nsymmetrised over $b\\uc d$ and also truncated to terms of order $\\BigO{\\eps^m}$. Note that the first term\non the right hand side of this equation vanishes by way of the results described above.\n\nComparing the order $m$ terms in equation (\\ref{eq:GenGammaA}) and (\\ref{eq:GenGammaB}) leads to the\nfollowing equation\n\\begin{align}\n   \\nGammaBar{m}^{a}{}_{b\\uc d}\n   = \\nGammaBar{m}^{a}{}_{(b\\uc,d)}\n   - (n+1)\\left(\\m \\nGammaBar{m-2}^{a}{}_{p(\\uc}\n                   \\nGammaBar{  2}^{p}{}_{bd)}\n                  +\\nGammaBar{m-3}^{a}{}_{p(\\uc}\n                   \\nGammaBar{  3}^{p}{}_{bd)}\n                  +\\nGammaBar{m-4}^{a}{}_{p(\\uc}\n                   \\nGammaBar{  4}^{p}{}_{bd)}\n                  + \\dots\n                  + \\nGammaBar{  n+1}^{a}{}_{p(\\uc}\n                    \\nGammaBar{m-n-1}^{p}{}_{bd)}\n   \\right)\n   \\label{eq:GenGammaC}\n\\end{align}\nThis one equation is all that is needed to compute all of the\n$\\nGammaBar{p}^{a}{}_{b\\uc d}$ for $p=3,4,5,\\dots m$ given just\nthe $\\nGammaBar{p}^{a}{}_{bd}$ for $p=2,3,4,\\dots m$. For example,\nsuppose $m=5$ and suppose that we are given\n$\\nGammaBar{p}^{a}{}_{bd}$ for $p=2,3,4,5$. Then with $n=1$ we can\nuse equation (\\ref{eq:GenGammaC}) to compute in turn,\n$\\nGammaBar{p}^{a}{}_{bc_1d}$ for $p=3,4,5$. Then with $n=2$ we\ncompute\n$\\nGammaBar{p}^{a}{}_{bc_1c_2d}$ for $p=4,5$ and finally with $n=3$\nwe compute $\\nGammaBar{p}^{a}{}_{bc_1c_2c_3d}$ for $p=5$. There\nare no terms like\n$\\nGammaBar{p}^{a}{}_{bc_1c_2c_3c_4d}$ for $p\\le5$ due to the\ncorollary given earlier.\n\n\\clearpage\n\nThe explicit computations for $m=5$ are as follows.\n\nFor $n=1$,\n\\begin{align}\n   \\nGammaBar{3}^{a}{}_{bc_1d}\n   &=\n   \\nGammaBar{3}^{a}{}_{(bc_1,d)}\\\\\n   %-----------------------------------------------------------------------\n   \\nGammaBar{4}^{a}{}_{bc_1d}\n   &=\n   \\nGammaBar{4}^{a}{}_{(bc_1,d)}\n   - 2 \\nGammaBar{2}^{a}{}_{p(c_1}\n       \\nGammaBar{2}^{p}{}_{bd)}\\\\\n   %-----------------------------------------------------------------------\n   \\nGammaBar{5}^{a}{}_{bc_1d}\n   &=\n   \\nGammaBar{5}^{a}{}_{(bc_1,d)}\n   - 2 \\nGammaBar{3}^{a}{}_{p(c_1}\n       \\nGammaBar{2}^{p}{}_{bd)}\n   - 2 \\nGammaBar{2}^{a}{}_{p(c_1}\n       \\nGammaBar{3}^{p}{}_{bd)}\n\\end{align}\n\nFor $n=2$,\n\\begin{align}\n   \\nGammaBar{4}^{a}{}_{bc_1c_2d}\n   &=\n   \\nGammaBar{4}^{a}{}_{(bc_1c_2,d)}\\\\\n   %-----------------------------------------------------------------------\n   \\nGammaBar{5}^{a}{}_{bc_1c_2d}\n   &=\n   \\nGammaBar{5}^{a}{}_{(bc_1c_2,d)}\n   - 3 \\nGammaBar{2}^{a}{}_{p(c_1c_2}\n       \\nGammaBar{2}^{p}{}_{bd)}\n\\end{align}\n\nFor $n=3$,\n\\begin{align}\n   \\nGammaBar{5}^{a}{}_{bc_1c_2c_3d}\n   &=\n   \\nGammaBar{5}^{a}{}_{(bc_1c_2c_3,d)}\n\\end{align}\n\n\n\\clearpage\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,c1,c2,c3,c4,c5,w#}::Indices(position=independent).\n\n   D{#}::Derivative.\n   \\nabla{#}::Derivative.\n   \\partial{#}::PartialDerivative.\n\n   g_{a b}::Metric.\n   g^{a b}::InverseMetric.\n   g_{a}^{b}::KroneckerDelta.\n   g^{a}_{b}::KroneckerDelta.\n   \\delta^{a}_{b}::KroneckerDelta.\n   \\delta_{a}^{b}::KroneckerDelta.\n\n   R_{a b c d}::RiemannTensor.\n   R^{a}_{b c d}::RiemannTensor.\n   R_{a b c}^{d}::RiemannTensor.\n\n   \\Gamma^{a}_{b c}::TableauSymmetry(shape={2}, indices={1,2}).\n\n   x^{a}::Depends(D{#}).\n\n   g_{a b}::Depends(\\partial{#}).\n   R_{a b c d}::Depends(\\partial{#}).\n   R^{a}_{b c d}::Depends(\\partial{#}).\n   \\Gamma^{a}_{b c}::Depends(\\partial{#}).\n\n   R_{a b c d}::Depends(\\nabla{#}).\n   R^{a}_{b c d}::Depends(\\nabla{#}).\n\n   import cdblib\n\n   term0 = cdblib.get ('GammaRterm0','connection.json')\n   term1 = cdblib.get ('GammaRterm2','connection.json')\n   term2 = cdblib.get ('GammaRterm3','connection.json')\n   term3 = cdblib.get ('GammaRterm4','connection.json')\n   term4 = cdblib.get ('GammaRterm5','connection.json')\n\n   # LCB: these terms were not computed in connection.tex so set them to zero\n   #      maybe in the future I will compute down to term6.\n\n   term5 := 0.\n   term6 := 0.\n\n   # genGmn : m = eps order of Rabcd terms\n   #          n = number of c indices\n\n   # --------------------------------------------------------------------------\n   # rules for building the genGmn\n\n   # note: after applying each rule, must symmetrise over (b c1 c2 ... cn d)\n\n   # n = 0\n\n   genG20 := genG2^{a}_{b d}.\n   genG30 := genG3^{a}_{b d}.\n   genG40 := genG4^{a}_{b d}.\n   genG50 := genG5^{a}_{b d}.\n\n   defG20 := genG2^{d}_{a b} -> @(term1).\n   defG30 := genG3^{d}_{a b} -> @(term2).\n   defG40 := genG4^{d}_{a b} -> @(term3).\n   defG50 := genG5^{d}_{a b} -> @(term4).\n\n   # LCB: rncGamma in connection.json limited to \"term4\" (ie. to 4th order in x)\n   #      so can only compute genG3*, genG4* and genG5* (at this stage)\n   #      but it doesn't hurt to provide the definitions for genG6*, genG7* etc. we just won't use them (at this atage)\n\n   defG60 := genG6^{d}_{a b} -> @(term5).\n   defG70 := genG7^{d}_{a b} -> @(term6).\n\n   # n = 1\n\n   defG31 := genG3^{a}_{b c1 d} -> D_{d}{genG3^{a}_{b c1}}.\n\n   defG41 := genG4^{a}_{b c1 d} -> D_{d}{genG4^{a}_{b c1}}\n                                   - 2 genG2^{a}_{p c1} genG2^{p}_{b d}.\n\n   defG51 := genG5^{a}_{b c1 d} -> D_{d}{genG5^{a}_{b c1}}\n                                   - 2 genG3^{a}_{p c1} genG2^{p}_{b d}\n                                   - 2 genG2^{a}_{p c1} genG3^{p}_{b d}.\n\n   defG61 := genG6^{a}_{b c1 d} -> D_{d}{genG6^{a}_{b c1}}\n                                   - 2 genG4^{a}_{p c1} genG2^{p}_{b d}\n                                   - 2 genG3^{a}_{p c1} genG3^{p}_{b d}\n                                   - 2 genG3^{a}_{p c1} genG4^{p}_{b d}.\n\n   defG71 := genG7^{a}_{b c1 d} -> D_{d}{genG7^{a}_{b c1}}\n                                   - 2 genG5^{a}_{p c1} genG2^{p}_{b d}\n                                   - 2 genG4^{a}_{p c1} genG3^{p}_{b d}\n                                   - 2 genG3^{a}_{p c1} genG4^{p}_{b d}\n                                   - 2 genG2^{a}_{p c1} genG5^{p}_{b d}.\n\n   # n = 2\n\n   defG42 := genG4^{a}_{b c1 c2 d} -> D_{d}{genG4^{a}_{b c1 c2}}.\n\n   defG52 := genG5^{a}_{b c1 c2 d} -> D_{d}{genG5^{a}_{b c1 c2}}\n                                      - 3 genG3^{a}_{p c1 c2} genG2^{p}_{b d}.\n\n   defG62 := genG6^{a}_{b c1 c2 d} -> D_{d}{genG6^{a}_{b c1 c2}}\n                                      - 3 genG4^{a}_{p c1 c2} genG2^{p}_{b d}\n                                      - 3 genG3^{a}_{p c1 c2} genG3^{p}_{b d}.\n\n   defG72 := genG7^{a}_{b c1 c2 d} -> D_{d}{genG7^{a}_{b c1 c2}}\n                                      - 3 genG5^{a}_{p c1 c2} genG2^{p}_{b d}\n                                      - 3 genG4^{a}_{p c1 c2} genG3^{p}_{b d}\n                                      - 3 genG3^{a}_{p c1 c2} genG4^{p}_{b d}.\n\n   # n = 3\n\n   defG53 := genG5^{a}_{b c1 c2 c3 d} -> D_{d}{genG5^{a}_{b c1 c2 c3}}.\n\n   defG63 := genG6^{a}_{b c1 c2 c3 d} -> D_{d}{genG6^{a}_{b c1 c2 c3}}\n                                         - 4 genG3^{a}_{p c1 c2 c3} genG3^{p}_{b d}.\n\n   defG73 := genG7^{a}_{b c1 c2 c3 d} -> D_{d}{genG7^{a}_{b c1 c2 c3}}\n                                         - 4 genG4^{a}_{p c1 c2 c3} genG3^{p}_{b d}\n                                         - 4 genG3^{a}_{p c1 c2 c3} genG4^{p}_{b d}.\n\n   # n = 4\n\n   defG64 := genG6^{a}_{b c1 c2 c3 c4 d} -> D_{d}{genG6^{a}_{b c1 c2 c3 c4}}.\n\n   defG74 := genG7^{a}_{b c1 c2 c3 c4 d} -> D_{d}{genG7^{a}_{b c1 c2 c3 c4}}\n                                            - 5 genG5^{a}_{p c1 c2 c3 c4} genG2^{p}_{b d}.\n\n   # n = 5\n\n   defG75 := genG7^{a}_{b c1 c2 c3 c4 c5 d} -> D_{d}{genG7^{a}_{b c1 c2 c3 c4 c5}}.\n\n   # --------------------------------------------------------------------------\n   # build the genGmn\n\n   # ==========================================================================\n   # n = 1\n\n   genG31 := genG3^{a}_{b c1 d}.                              # cdb (genG31.000,genG31)\n   genG41 := genG4^{a}_{b c1 d}.                              # cdb (genG41.000,genG41)\n   genG51 := genG5^{a}_{b c1 d}.\n   # genG61 := genG6^{a}_{b c1 d}.\n   # genG71 := genG7^{a}_{b c1 d}.\n\n   # --------------------------------------------------------------------------\n   substitute     (genG20,defG20)                             # cdb (genG20.001,genG20)\n   substitute     (genG30,defG30)                             # cdb (genG30.001,genG30)\n   substitute     (genG40,defG40)                             # cdb (genG40.001,genG40)\n   substitute     (genG50,defG50)                             # cdb (genG50.001,genG50)\n\n   # --------------------------------------------------------------------------\n   substitute     (genG31,defG31)                             # cdb (genG31.001,genG31)\n   substitute     (genG31,defG30)                             # cdb (genG31.002,genG31)\n\n   distribute     (genG31)                                    # cdb (genG31.002,genG31)\n   unwrap         (genG31)                                    # cdb (genG31.003,genG31)\n   product_rule   (genG31)                                    # cdb (genG31.004,genG31)\n   distribute     (genG31)                                    # cdb (genG31.005,genG31)\n   substitute     (genG31,$D_{a}{x^b}->\\delta_{a}^{b}$)       # cdb (genG31.006,genG31)\n   eliminate_kronecker (genG31)                               # cdb (genG31.007,genG31)\n   sym            (genG31,$_{b}, _{c1}, _{d}$)\n   sort_product   (genG31)                                    # cdb (genG31.008,genG31)\n   rename_dummies (genG31)                                    # cdb (genG31.009,genG31)\n   canonicalise   (genG31)                                    # cdb (genG31.010,genG31)\n\n   # --------------------------------------------------------------------------\n   substitute     (genG41,defG41)                             # cdb (genG41.001,genG41)\n   substitute     (genG41,defG40)                             # cdb (genG41.002,genG41)\n   substitute     (genG41,defG20,repeat=True)                 # cdb (genG41.003,genG41)\n\n   distribute     (genG41)                                    # cdb (genG41.004,genG41)\n   unwrap         (genG41)                                    # cdb (genG41.005,genG41)\n   product_rule   (genG41)                                    # cdb (genG41.006,genG41)\n   distribute     (genG41)                                    # cdb (genG41.007,genG41)\n   substitute     (genG41,$D_{a}{x^b}->\\delta_{a}^{b}$)       # cdb (genG41.008,genG41)\n   eliminate_kronecker (genG41)                               # cdb (genG41.009,genG41)\n   sym            (genG41,$_{b}, _{c1}, _{d}$)\n   sort_product   (genG41)                                    # cdb (genG41.010,genG41)\n   rename_dummies (genG41)                                    # cdb (genG41.011,genG41)\n   canonicalise   (genG41)                                    # cdb (genG41.012,genG41)\n\n   # --------------------------------------------------------------------------\n   substitute     (genG51,defG51)\n   substitute     (genG51,defG50)\n   substitute     (genG51,defG30,repeat=True)\n   substitute     (genG51,defG20,repeat=True)\n\n   distribute     (genG51)\n   unwrap         (genG51)\n   product_rule   (genG51)\n   distribute     (genG51)\n   substitute     (genG51,$D_{a}{x^b}->\\delta_{a}^{b}$)\n   eliminate_kronecker (genG51)\n   sym            (genG51,$_{b}, _{c1}, _{d}$)\n   sort_product   (genG51)\n   rename_dummies (genG51)\n   canonicalise   (genG51)\n\n   # update the rules\n\n   defG31 := genG3^{a}_{b c1 d} -> @(genG31).\n   defG41 := genG4^{a}_{b c1 d} -> @(genG41).\n   defG51 := genG5^{a}_{b c1 d} -> @(genG51).\n\n   # ==========================================================================\n   # n = 2\n\n   genG42 := genG4^{a}_{b c1 c2 d}.                           # cdb (genG42.000,genG42)\n   genG52 := genG5^{a}_{b c1 c2 d}.\n   # genG62 := genG6^{a}_{b c1 c2 d}.\n   # genG72 := genG7^{a}_{b c1 c2 d}.\n\n   # --------------------------------------------------------------------------\n   substitute     (genG42,defG42)                             # cdb (genG42.001,genG42)\n   substitute     (genG42,defG41)                             # cdb (genG42.002,genG42)\n\n   distribute     (genG42)                                    # cdb (genG42.003,genG42)\n   unwrap         (genG42)                                    # cdb (genG42.004,genG42)\n   product_rule   (genG42)                                    # cdb (genG42.005,genG42)\n   distribute     (genG42)                                    # cdb (genG42.006,genG42)\n   substitute     (genG42,$D_{a}{x^b}->\\delta_{a}^{b}$)       # cdb (genG42.007,genG42)\n   eliminate_kronecker (genG42)                               # cdb (genG42.008,genG42)\n   sym            (genG42,$_{b}, _{c1}, _{c2}, _{d}$)\n   sort_product   (genG42)                                    # cdb (genG42.009,genG42)\n   rename_dummies (genG42)                                    # cdb (genG42.010,genG42)\n   canonicalise   (genG42)                                    # cdb (genG42.011,genG42)\n\n   # --------------------------------------------------------------------------\n   substitute     (genG52,defG52)\n   substitute     (genG52,defG51)\n   substitute     (genG52,defG31,repeat=True)\n   substitute     (genG52,defG20,repeat=True)\n\n   distribute     (genG52)\n   unwrap         (genG52)\n   product_rule   (genG52)\n   distribute     (genG52)\n   substitute     (genG52,$D_{a}{x^b}->\\delta_{a}^{b}$)\n   eliminate_kronecker (genG52)\n   sym            (genG52,$_{b}, _{c1}, _{c2}, _{d}$)\n   sort_product   (genG52)\n   rename_dummies (genG52)\n   canonicalise   (genG52)                                    # cdb (genG52.001,genG52)\n\n   # update the rules\n\n   defG42 := genG4^{a}_{b c1 c2 d} -> @(genG42).\n   defG52 := genG5^{a}_{b c1 c2 d} -> @(genG52).\n\n   # ==========================================================================\n   # n = 3\n\n   genG53 := genG5^{a}_{b c1 c2 c3 d}.\n   # genG63 := genG6^{a}_{b c1 c2 c3 d}.\n   # genG73 := genG7^{a}_{b c1 c2 c3 d}.\n\n   # --------------------------------------------------------------------------\n   substitute     (genG53,defG53)\n   substitute     (genG53,defG52)\n\n   distribute     (genG53)\n   unwrap         (genG53)\n   product_rule   (genG53)\n   distribute     (genG53)\n   substitute     (genG53,$D_{a}{x^b}->\\delta_{a}^{b}$)\n   eliminate_kronecker (genG53)\n   sym            (genG53,$_{b}, _{c1}, _{c2}, _{c3}, _{d}$)\n   sort_product   (genG53)\n   rename_dummies (genG53)\n   canonicalise   (genG53)                                    # cdb (genG53.001,genG53)\n\n   # update the rules\n\n   defG53 := genG5^{a}_{b c1 c2 c3 d} -> @(genG53).\n\n\\end{cadabra}\n\n\\clearpage\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{genG31.000} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.001} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.002} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.003} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.004} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.005} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.006} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.007} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.008} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.009} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG31.010} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{genG41.000} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.001} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.002} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.003} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.004} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.005} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.006} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.007} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.008} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.009} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG41.010} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG41.011} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG41.012} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{genG42.000} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.001} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.002} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.003} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.004} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.005} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG42.006} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG42.007} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG42.008} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG42.009} \\end{dmath*}\n   % \\begin{dmath*} \\cdb*{genG42.010} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{genG42.011} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   # note: keeping numbering as is (out of order) to ensure R appears before \\nabla R etc.\n   def product_sort (obj):\n       substitute (obj,$ A^{a}                            -> A001^{a}               $)\n       substitute (obj,$ x^{a}                            -> A002^{a}               $)\n       substitute (obj,$ g^{a b}                          -> A003^{a b}             $)\n       substitute (obj,$ \\nabla_{e f g h}{R_{a b c d}}    -> A008_{a b c d e f g h} $)\n       substitute (obj,$ \\nabla_{e f g}{R_{a b c d}}      -> A007_{a b c d e f g}   $)\n       substitute (obj,$ \\nabla_{e f}{R_{a b c d}}        -> A006_{a b c d e f}     $)\n       substitute (obj,$ \\nabla_{e}{R_{a b c d}}          -> A005_{a b c d e}       $)\n       substitute (obj,$ R_{a b c d}                      -> A004_{a b c d}         $)\n       sort_product   (obj)\n       rename_dummies (obj)\n       substitute (obj,$ A001^{a}                  -> A^{a}                         $)\n       substitute (obj,$ A002^{a}                  -> x^{a}                         $)\n       substitute (obj,$ A003^{a b}                -> g^{a b}                       $)\n       substitute (obj,$ A004_{a b c d}            -> R_{a b c d}                   $)\n       substitute (obj,$ A005_{a b c d e}          -> \\nabla_{e}{R_{a b c d}}       $)\n       substitute (obj,$ A006_{a b c d e f}        -> \\nabla_{e f}{R_{a b c d}}     $)\n       substitute (obj,$ A007_{a b c d e f g}      -> \\nabla_{e f g}{R_{a b c d}}   $)\n       substitute (obj,$ A008_{a b c d e f g h}    -> \\nabla_{e f g h}{R_{a b c d}} $)\n\n       return obj\n\n   # --------------------------------------------------------------------------\n   symG20 := @(genG20) A^{b} A^{d}.                           # cdb (symG20.100,symG20)\n\n   distribute            (symG20)                             # cdb (symG20.101,symG20)\n   symG20 = product_sort (symG20)                             # cdb (symG20.102,symG20)\n   rename_dummies        (symG20)                             # cdb (symG20.103,symG20)\n   canonicalise          (symG20)                             # cdb (symG20.104,symG20)\n\n   # --------------------------------------------------------------------------\n   symG30 := @(genG30) A^{b} A^{d}.                           # cdb (symG30.100,symG30)\n\n   distribute            (symG30)                             # cdb (symG30.101,symG30)\n   symG30 = product_sort (symG30)                             # cdb (symG30.102,symG30)\n   rename_dummies        (symG30)                             # cdb (symG30.103,symG30)\n   canonicalise          (symG30)                             # cdb (symG30.104,symG30)\n\n   # --------------------------------------------------------------------------\n   symG40 := @(genG40) A^{b} A^{d}.                           # cdb (symG40.100,symG40)\n\n   distribute            (symG40)                             # cdb (symG40.101,symG40)\n   symG40 = product_sort (symG40)                             # cdb (symG40.102,symG40)\n   rename_dummies        (symG40)                             # cdb (symG40.103,symG40)\n   canonicalise          (symG40)                             # cdb (symG40.104,symG40)\n\n   # --------------------------------------------------------------------------\n   symG50 := @(genG50) A^{b} A^{d}.                           # cdb (symG50.100,symG50)\n\n   distribute            (symG50)                             # cdb (symG50.101,symG50)\n   symG50 = product_sort (symG50)                             # cdb (symG50.102,symG50)\n   rename_dummies        (symG50)                             # cdb (symG50.103,symG50)\n   canonicalise          (symG50)                             # cdb (symG50.104,symG50)\n\n   # --------------------------------------------------------------------------\n   symG31 := @(genG31) A^{b} A^{c1} A^{d}.                    # cdb (symG31.100,symG31)\n\n   distribute            (symG31)                             # cdb (symG31.101,symG31)\n   symG31 = product_sort (symG31)                             # cdb (symG31.102,symG31)\n   rename_dummies        (symG31)                             # cdb (symG31.103,symG31)\n   canonicalise          (symG31)                             # cdb (symG31.104,symG31)\n\n   # --------------------------------------------------------------------------\n   symG41 := @(genG41) A^{b} A^{c1} A^{d}.                    # cdb (symG41.100,symG41)\n\n   distribute            (symG41)                             # cdb (symG41.101,symG41)\n   symG41 = product_sort (symG41)                             # cdb (symG41.102,symG41)\n   rename_dummies        (symG41)                             # cdb (symG41.103,symG41)\n   canonicalise          (symG41)                             # cdb (symG41.104,symG41)\n\n   # --------------------------------------------------------------------------\n   symG51 := @(genG51) A^{b} A^{c1} A^{d}.                    # cdb (symG51.100,symG51)\n\n   distribute            (symG51)                             # cdb (symG51.101,symG51)\n   symG51 = product_sort (symG51)                             # cdb (symG51.102,symG51)\n   rename_dummies        (symG51)                             # cdb (symG51.103,symG51)\n   canonicalise          (symG51)                             # cdb (symG51.104,symG51)\n\n   # --------------------------------------------------------------------------\n   symG42 := @(genG42) A^{b} A^{c1} A^{c2} A^{d}.             # cdb (symG42.100,symG42)\n\n   distribute            (symG42)                             # cdb (symG42.101,symG42)\n   symG42 = product_sort (symG42)                             # cdb (symG42.102,symG42)\n   rename_dummies        (symG42)                             # cdb (symG42.103,symG42)\n   canonicalise          (symG42)                             # cdb (symG42.104,symG42)\n\n   # --------------------------------------------------------------------------\n   symG52 := @(genG52) A^{b} A^{c1} A^{c2} A^{d}.             # cdb (symG52.100,symG52)\n\n   distribute            (symG52)                             # cdb (symG52.101,symG52)\n   symG52 = product_sort (symG52)                             # cdb (symG52.102,symG52)\n   rename_dummies        (symG52)                             # cdb (symG52.103,symG52)\n   canonicalise          (symG52)                             # cdb (symG52.104,symG52)\n\n   # --------------------------------------------------------------------------\n   symG53 := @(genG53) A^{b} A^{c1} A^{c2} A^{c3} A^{d}.      # cdb (symG53.100,symG53)\n\n   distribute            (symG53)                             # cdb (symG53.101,symG53)\n   symG53 = product_sort (symG53)                             # cdb (symG53.102,symG53)\n   rename_dummies        (symG53)                             # cdb (symG53.103,symG53)\n   canonicalise          (symG53)                             # cdb (symG53.104,symG53)\n\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{symG31.100} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG31.101} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG31.102} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG31.103} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG31.104} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{symG41.100} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG41.101} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG41.102} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG41.103} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG41.104} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{symG51.104} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{symG42.104} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{symG52.104} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{symG53.104} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   def reformat (obj,scale):\n       foo  = Ex(str(scale))\n       bah := @(foo) @(obj).\n       distribute (bah)\n       factor_out (bah,$A^{a?},x^{b?}$)\n       ans := @(bah) / @(foo).\n       return ans\n\n   fooG20 = reformat (symG20,3)\n   fooG30 = reformat (symG30,12)\n   fooG40 = reformat (symG40,360)\n   fooG50 = reformat (symG50,180)\n\n   fooG31 = reformat (symG31,2)\n   fooG41 = reformat (symG41,120)\n   fooG51 = reformat (symG51,180)\n\n   fooG42 = reformat (symG42,15)\n   fooG52 = reformat (symG52,90)\n\n   fooG53 = reformat (symG53,3)\n\n   genGamma0 := @(fooG20) + @(fooG30) + @(fooG40) + @(fooG50).  # cdb (genGamma0.000,genGamma0)\n   genGamma1 := @(fooG31) + @(fooG41) + @(fooG51).              # cdb (genGamma1.000,genGamma1)\n   genGamma2 := @(fooG42) + @(fooG52).                          # cdb (genGamma2.000,genGamma2)\n   genGamma3 := @(fooG53).                                      # cdb (genGamma3.000,genGamma3)\n\n   cdblib.create ('genGamma.json')\n\n   cdblib.put ('genGamma0',genGamma0,'genGamma.json')\n   cdblib.put ('genGamma1',genGamma1,'genGamma.json')\n   cdblib.put ('genGamma2',genGamma2,'genGamma.json')\n   cdblib.put ('genGamma3',genGamma3,'genGamma.json')\n\n   cdblib.put ('genGamma01',fooG20,'genGamma.json')\n   cdblib.put ('genGamma02',fooG30,'genGamma.json')\n   cdblib.put ('genGamma03',fooG40,'genGamma.json')\n   cdblib.put ('genGamma04',fooG50,'genGamma.json')\n\n   cdblib.put ('genGamma11',fooG31,'genGamma.json')\n   cdblib.put ('genGamma12',fooG41,'genGamma.json')\n   cdblib.put ('genGamma13',fooG51,'genGamma.json')\n\n   cdblib.put ('genGamma21',fooG42,'genGamma.json')\n   cdblib.put ('genGamma22',fooG52,'genGamma.json')\n\n   cdblib.put ('genGamma31',fooG53,'genGamma.json')\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The generalised connection in Riemann normal coordinates}\n\n\\begin{dgroup*}\n   \\begin{dmath*} A^b A^c \\Gamma^{a}_{b c}(x) = \\cdb{genGamma0.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d \\Gamma^{a}_{b c d}(x) = \\cdb{genGamma1.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d A^e \\Gamma^{a}_{b c d e}(x) = \\cdb{genGamma2.000} \\end{dmath*}\n   \\begin{dmath*} A^b A^c A^d A^e A^f \\Gamma^{a}_{b c d e f}(x) = \\cdb{genGamma3.000} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   scaledGamma0 := 360 @(genGamma0).  # cdb (scaledGamma0.001,scaledGamma0)\n   scaledGamma1 := 360 @(genGamma1).  # cdb (scaledGamma1.001,scaledGamma1)\n   scaledGamma2 :=  90 @(genGamma2).  # cdb (scaledGamma2.001,scaledGamma2)\n   scaledGamma3 :=   3 @(genGamma3).  # cdb (scaledGamma3.001,scaledGamma3)\n\n\\end{cadabra}\n\n\\clearpage\n\n% =================================================================================================\n\\section*{The generalised connection in Riemann normal coordinates}\n\nThis is the same as the previous page but with a small change in the format to avoid fractions.\n\n\\begin{dgroup*}\n   \\begin{dmath*} 360 A^b A^c \\Gamma^{a}_{b c}(x) = \\cdb{scaledGamma0.001} \\end{dmath*}\n   \\begin{dmath*} 360 A^b A^c A^d \\Gamma^{a}_{b c d}(x) = \\cdb{scaledGamma1.001} \\end{dmath*}\n   \\begin{dmath*}  90 A^b A^c A^d A^e \\Gamma^{a}_{b c d e}(x) = \\cdb{scaledGamma2.001} \\end{dmath*}\n   \\begin{dmath*}   3 A^b A^c A^d A^e A^f \\Gamma^{a}_{b c d e f}(x) = \\cdb{scaledGamma3.001} \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n% =================================================================================================\n% export selected objects, these will later be imported into a library\n% these are the objects that will appear in the paper\n\n\\begin{cadabra}\n   tmp0 := @(fooG20) + @(fooG30).\n   tmp1 := @(fooG31).\n\n   alt0 := @(genGamma0).\n   alt1 := @(genGamma1).\n   alt2 := @(genGamma2).\n   alt3 := @(genGamma3).\n\n   alt0scaled := @(scaledGamma0).\n   alt1scaled := @(scaledGamma1).\n   alt2scaled := @(scaledGamma2).\n   alt3scaled := @(scaledGamma3).\n\n   substitute (tmp0, $A^{a}->1$)\n   substitute (tmp1, $A^{a}->1$)\n\n   substitute (alt0, $A^{a}->1$)\n   substitute (alt1, $A^{a}->1$)\n   substitute (alt2, $A^{a}->1$)\n   substitute (alt3, $A^{a}->1$)\n\n   substitute (alt0scaled, $A^{a}->1$)\n   substitute (alt1scaled, $A^{a}->1$)\n   substitute (alt2scaled, $A^{a}->1$)\n   substitute (alt3scaled, $A^{a}->1$)\n\n   cdblib.create ('genGamma.export')\n\n   # 4th order gen gamma\n   cdblib.put ('gen_gamma_0_4th',tmp0,'genGamma.export')\n   cdblib.put ('gen_gamma_1_4th',tmp1,'genGamma.export')\n\n   # 6th order gen gamma\n   cdblib.put ('gen_gamma_0',alt0,'genGamma.export')\n   cdblib.put ('gen_gamma_1',alt1,'genGamma.export')\n   cdblib.put ('gen_gamma_2',alt2,'genGamma.export')\n   cdblib.put ('gen_gamma_3',alt3,'genGamma.export')\n\n   # 6th order gen gamma scaled\n   cdblib.put ('gen_gamma_0_scaled',alt0scaled,'genGamma.export')\n   cdblib.put ('gen_gamma_1_scaled',alt1scaled,'genGamma.export')\n   cdblib.put ('gen_gamma_2_scaled',alt2scaled,'genGamma.export')\n   cdblib.put ('gen_gamma_3_scaled',alt3scaled,'genGamma.export')\n\n   checkpoint.append (tmp0)\n   checkpoint.append (tmp1)\n\n   checkpoint.append (alt0)\n   checkpoint.append (alt1)\n   checkpoint.append (alt2)\n   checkpoint.append (alt3)\n\n   checkpoint.append (alt0scaled)\n   checkpoint.append (alt1scaled)\n   checkpoint.append (alt2scaled)\n   checkpoint.append (alt3scaled)\n\n\\end{cadabra}\n\n% =================================================================================================\n% export checkpoints in json format\n\n\\bgroup\n\\CdbSetup{action=hide}\n\\begin{cadabra}\n   for i in range( len(checkpoint) ):\n      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)\n\\end{cadabra}\n\\egroup\n\n\\end{document}\n", "meta": {"hexsha": "bffa387b00fc70358e5187bc0040321b6139f779", "size": 36941, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/genGamma.tex", "max_stars_repo_name": "leo-brewin/riemann-normal-coords", "max_stars_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T16:15:58.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T16:15:58.000Z", "max_issues_repo_path": "source/cadabra/genGamma.tex", "max_issues_repo_name": "leo-brewin/riemann-normal-coords", "max_issues_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/genGamma.tex", "max_forks_repo_name": "leo-brewin/riemann-normal-coords", "max_forks_repo_head_hexsha": "4e6546028229b6f43fcef1c0b83660cddc021716", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.1700913242, "max_line_length": 155, "alphanum_fraction": 0.5045071871, "num_tokens": 12569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4096728174820859}}
{"text": "\\newpage\\section{Problems}\n\n\n\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1291293p6832329}{IRAN 3rd Round 2016 P2}{E}{Let $ABC$ be an arbitrary triangle. Let $E,F$ be two points on $AB,AC$ respectively such that their distance to the midpoint of $BC$ is equal. Let $P$ be the second intersection of the triangles $ABC,AEF$ circumcircles . The tangents from $E,F$ to the circumcircle of $AEF$ intersect each other at $K$. Prove that : $\\angle KPA = 90$}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1434843p8120660}{IRAN 2nd Round 2016 P6}{E}{Let $ABC$ be a triangle and $X$ be a point on its circumcircle. $Q,P$ lie on a line $BC$ such that $XQ\\perp AC , XP\\perp AB$. Let $Y$ be the circumcenter of $\\triangle XQP$. Prove that $ABC$ is equilateral triangle if and if only $Y$ moves on a circle when $X$ varies on the circumcircle of $ABC$}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1460735p8471885}{AoPS}{E}{Consider $ABC$ with orthic triangle $A'B'C'$, let $AA'\\cap B'C' = E$ and $E'$ be reflection of $E$ wrt $BC$. Let $M$ be midpoint of $BC$ and $O$ be circumcenter of $E'B'C'$. Let $M'$ be projection of $O$ on $BC$ and $N$ be the intersection of a perpendicular to $B'C'$ through $E$ with $BC$. Prove that $MM' = 1/4MN$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h360730p1973873}{IRAN 3rd Round 2010 D3, P5}{M}{In a triangle $ABC$, $I$ is the incenter. $D$ is the reflection of $A$ to $I$. the incircle is tangent to $BC$ at point $E$. $DE$ cuts $IG$ at $P$ ($G$ is centroid). $M$ is the midpoint of $BC$. Prove that $AP||DM$ and $AP=2DM$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h429226p2428694}{IRAN 3rd Round 2011 G5}{M}{Given triangle $ABC$, $D$ is the foot of the external angle bisector of $A$, $I$ its incenter and $I_a$ its $A$-excenter. Perpendicular from $I$ to $DI_a$ intersects the circumcircle of triangle in $A'$. Define $B'$ and $C'$ similarly. Prove that $AA',BB'$ and $CC'$ are concurrent.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6t48f6h1519616_geometry}{AoPS3}{E}{$I$ is the incenter of $ABC$,  $PI,QI{\\perp}BC$, $PA,QA$ intersect $BC$ at $DE$. Prove: $IADE$ is on a circle.}\n\t\n\t\t\t\\fig{1}{AoPS3}{AoPS3}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6t48f6h1523774_nice_property}{AoPS4}{E}{Given a triangle $ABC$, the incircle $(I)$ touch $BC,CA,AB$ at $D,E,F$ respectively. Let $AA_1,BB_1,CC_1$ be $A,B,C-altitude$ respectively. Let $N$ be the orthocenter of the triangle $AEF$. Prove that $N$ is the incenter of $AB_1C_1$}\n\t\n\t\t\t\\fig{1}{AoPS4}{AoPS4}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1087613p4817114}{IRAN TST 2015 Day 2, P3}{M}{$ABCD$ is a circumscribed and inscribed quadrilateral. $O$ is the circumcenter of the quadrilateral. $E,\\ F$ and $S$ are the intersections of $AB,\\ CD$; $AD,\\ BC$ and $AC,\\ BD$ respectively. $E'$ and $F'$ are points on $AD$ and $AB$ such that $\\angle AEE'=\\angle E'ED$ and $\\angle AFF'=\\angle F'FB$. $X$ and $Y$ are points on $OE'$ and $OF'$ such that $\\frac{XA}{XD}=\\frac{EA}{ED}$ and $\\frac{YA}{YB}=\\frac{FA}{FB}$. $M$ is the midpoint of arc $BD$ of $(O)$ which contains $A$. Prove that the circumcircles of triangles $OXY$ and $OAM$ are coaxial with the circle with diameter $OS$.}\n\t\n\t\t\t\\fig{1}{ITST2015D3P3i}{Actual Prob}\n\t\t\t\\fig{1}{ITST2015D3P3ii}{Inverted}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1352164p7389108}{USA TST 2017 P2}{M}{Let $ABC$ be an acute scalene triangle with circumcenter $O$, and let $T$ be on line $BC$ such that $\\angle TAO = 90^{\\circ}$. The circle with diameter $\\overline{AT}$ intersects the circumcircle of $\\triangle BOC$ at two points $A_1$ and $A_2$, where $OA_1 < OA_2$. Points $B_1$, $B_2$, $C_1$, $C_2$ are defined analogously.\n\t\n\t\t\t\\begin{enumerate}\n\t\t\t\t\\item Prove that $\\overline{AA_1}$, $\\overline{BB_1}$, $\\overline{CC_1}$ are concurrent.\n\t\t\t\t\\item Prove that $\\overline{AA_2}$, $\\overline{BB_2}$, $\\overline{CC_2}$ are concurrent on the Euler line of triangle $ABC$.\n\t\t\t\\end{enumerate}}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6t48f6h1522766_tangent_circles}{AoPS2}{}{Let $ABC$ be a triangle with circumcenter $O$ and altitude $AH.$ $AO$ meets $BC$ at $M$ and meets the circle $(BOC)$ again at $N.$ $P$ is the midpoint of $MN.$ $K$ is the projection of $P$ on line $AH.$ Prove that the circle $(K,KH)$ is tangent to the circle $(BOC).$}\n\t\n\t\t\t\\fig{1}{AoPS2}{AoPS2}\n\t\n\t\t\t\\solu{Inversion all the way...}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h46718}{AoPS5}{}{Let $ABC$ be a triangle inscribed in $(O)$ and $P$ be a point. Call $P'$ be the isogonal conjugate point of $P$. Let $A'$ be the second intersection of $AP'$ and $(O)$. Denote by $M$ the intersection of $BC$ and $A'P$. Prove that $P'M \\parallel AP$.}\n\t\n\t\t\t\\fig{1}{AoPS5}{AoPS5}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h283185}{AoPS}{E}{$I$ is the incenter of a non-isosceles triangle $\\triangle ABC$. If the incircle touches $BC, CA, AB$ at $A_1, B_1, C_1$ respectively, prove that the circumcentres of the triangles $\\triangle AIA_1$, $\\triangle BIB_1$, $\\triangle CIC_1$ are collinear.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1501095p8898504}{AoPS}{M}{Given $\\triangle ABC$ and a point $P$ inside. $AP$ cuts $BC$ at $M.$ Let $M', A'$ be the reflection of $M, A$ in the perpendicular bisector of $BC.$ $A'P$ cuts the perpendicular bisector of $BC$ at $N.$ Let $Q$ be the isogonal conjugate of $P$ in triangle $ABC.$ Prove that $QM'\\parallel AN$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1301365p6934249}{IRAN 3rd Round 2016 G6}{E}{Given triangle $\\triangle ABC$ and let $D,E,F$ be the foot of angle bisectors of $A,B,C$ ,respectively. $M,N$ lie on $EF$ such that $AM=AN$. Let $H$ be the foot of $A$-altitude on $BC$.\\\\\n\t\tPoints $K,L$ lie on $EF$ such that triangles $\\triangle AKL, \\triangle HMN$ are correspondingly similar (with the given order of vertices's) such that $AK \\not\\parallel HM$ and $AK \\not\\parallel HN$. Show that: $DK=DL$.}\n\t\n\t\t\t\\fig{1}{IRAN3rd2016G6}{IRAN 3rd Round 2016 G6}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1438017p8160421}{Iran TST 2017 T3 P6}{H}{In triangle $ABC$ let $O$ and $H$ be the circumcenter and the orthocenter. The point $P$ is the reflection of $A$ with respect to $OH$. Assume that $P$ is not on the same side of $BC$ as $A$. Points $E,F$ lie on $AB,AC$ respectively such that $BE=PC \\ ,  CF=PB$. Let $K$ be the intersection point of $AP,OH$. Prove that $\\angle EKF = 90 ^{\\circ}$.}\n\t\n\t\t\\tr{Spiral Similarity (points on $AB, AC$ with some properties)}\n\t\n\t\t\t\\figdf{1}{ITST2017T3P6}{Iran TST 2017 T3 P6}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h360732p1973876}{IRAN 3rd Round 2010 D3, P6}{M}{In a triangle $ABC$, $\\angle C=45^{\\circ}$. $AD$ is the altitude of the triangle. $X$ is on $AD$ such that $\\angle XBC=90-\\angle B$ ($X$ is inside of the triangle). $AD$ and $CX$ cut the circumcircle of $ABC$ in $M$ and $N$ respectively. Ff the tangent to $\\odot ABC$ at $M$ cuts $AN$ at $P$, prove that $P, B$ and $O$ are collinear.} \n\t\n\t\t\\tr{Cross-Ratio}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h585433p3462669}{Iran TST 2014 T1P6}{M}{$I$ is the incenter of triangle $ABC$. perpendicular from $I$ to $AI$ meet $AB$ and $AC$ at ${B}'$ and ${C}'$ respectively. Suppose that ${B}''$ and ${C}''$ are points on half-line $BC$ and $CB$ such that $B{B}''=BA$ and $C{C}''=CA$. Suppose that the second intersection of circumcircles of $A{B}'{B}''$ and $A{C}'{C}''$ is $T$. Prove that the circumcenter of $AIT$ is on the $BC$.} \\tg{projective, inversion}\n\t\n\t\t\t\\solu{Too many collinearity, need to prove concurrency, what else can come into mind except projective approach.}\n\t\n\t\t\t\\solu{Too many incenter related things, $\\sqrt{bc}$-inversion :o}\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h582820p3444910}{APMO 2014 P5}{M}{Circles $\\omega$ and $\\Omega$ meet at points $A$ and $B$. Let $M$ be the midpoint of the arc $AB$ of circle $\\omega$ ($M$ lies inside $\\Omega$). A chord $MP$ of circle $\\omega$ intersects $\\Omega$ at $Q$ ($Q$ lies inside $\\omega$). Let $\\ell_P$ be the tangent line to $\\omega$ at $P$, and let $\\ell_Q$ be the tangent line to $\\Omega$ at $Q$. Prove that the circumcircle of the triangle formed by the lines $\\ell_P$, $\\ell_Q$ and $AB$ is tangent to $\\Omega$.}\n\t\n\t\t\t\\fig{1}{APMO2014P5}{APMO 2014 P5}\n\t\n\t\n\t\t\n\n\n\n\t\t\\prob{}{}{E}{Let $ABC$ be a triangle, $D, E, F$ are the feet of the altitudes, $DF\\cap BE\\equiv P, DE\\cap CF\\equiv Q$. Prove that the perpendicular from $A$ to $PQ$ goes through the reflection of $O$ on $BC$.}  \\tg{projective} \n\t\n\t\t\t\\solu{Projective approach.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1598147p9931685}{RMM 2018 P6}{H}{Fix a circle $\\Gamma$, a line $\\ell$ to tangent $\\Gamma$, and another circle $\\Omega$ disjoint from $\\ell$ such that $\\Gamma$ and $\\Omega$ lie on opposite sides of $\\ell$. The tangents to $\\Gamma$ from a variable point $X$ on $\\Omega$ meet $\\ell$ at $Y$ and $Z$. Prove that, as $X$ varies over $\\Omega$, the circumcircle of $XYZ$ is tangent to two fixed circles.} \\tg{inversion}\n\t\n\t\t\t\\solu{Too many circles, plus tangency, what else other than inversion? After the inversion the problem turns into a pretty obvious work-around problem.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1573301p9738624}{AoPS6}{H but Beautiful}{Let $O$ and $I$ be the circumcenter and incenter of $\\Delta ABC$. Draw circle $\\omega$ so that $B,C \\in \\omega$ and $\\omega$ touches $(I)$ internally at $P$. $AI$ intersects $BC$ at $X$. Tangent at $X$ to $(I)$ which is different from $BC$, intersects tangent at $P$ to $(I)$ at $S$. $SA \\cap (O)=T \\neq A$. Prove that $\\angle ATI=90^{\\circ}$}\n\t\n\t\n\t\t\t\\figdf{1}{AoPS6_1}{Solution 1}\n\t\t\t\\figdf{1}{AoPS6_2}{Solution 2}\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1618875_cute_radical_axis}{AoPS7}{E}{Let $ABC$ be a triangle with incenter $I$ and circumcircle $\\Gamma$. Let the line through $I$ perpendicular to $AI$ meet $AB$ at $E$ and $AC$ at $F$. Let the circumcircles of triangles $AIB$ and $AIC$ intersect the circumcircle of triangle $AEF$ $\\omega$ again at points $M$ and $N$, and let $\\omega$ intersect $\\Gamma$ again at $Q$. Prove that $AQ$, $MN$, and $BC$ are concurrent.}\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/q2h514889p2893347}{AoPS}{E}{Given a circle $ (O) $ with center $ O $ and $ A,B $ are $ 2 $ fixed points on $ (O) $. $ E $ lies on $ AB $. $ C,D $ are on $ (O) $ and $ CD $ pass through $ E $. $ P $ lies on the ray $ DA $, $ Q $ lies on the ray $ DB $ such that $ E $ is the midpoint of $ PQ $. Prove that the circle passing through $ C $ and touch $ PQ $ at $ E $ also pass through the midpoint of $ AB $}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h514252p2889096}{WenWuGuangHua Mathematics Workshop}{E}{$ O_B, O_C $ are the $ B $ and $ C $ mixtilinear centers respectively. $ (O_B) $ touches $ BC, AB $ at $ X_B, Y_B $ respectively, and $ X_BY_B\\cap O_BO_C $ at $ Z_B $. Define $ X_C, Y_C, Z_C $ similarly. Prove that if $ BZ_C\\cap CZ_B = T $, then $ AT $ is the $ A $-angle bisector.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h514371p2889823}{All Russia 1999 P9.3}{E}{A triangle $ABC$ is inscribed in a circle $S$. Let $A_0$ and $C_0$ be the midpoints of the arcs $BC$ and $AB$ on $S$, not containing the opposite vertex, respectively. The circle $S_1$ centered at $A_0$ is tangent to $BC$, and the circle $S_2$ centered at $C_0$ is tangent to $AB$. Prove that the incenter $I$ of $\\triangle ABC$ lies on a common tangent to $S_1$ and $S_2$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h514303p2889241}{All Russia 2000 P11.7}{E}{ A quadrilateral $ABCD$ is circumscribed about a circle $\\omega$. The lines $AB$ and $CD$ meet at $O$. A circle $\\omega_1$ is tangent to side $BC$ at $K$ and to the extensions of sides $AB$ and $CD$, and a circle $\\omega_2$ is tangent to side $AD$ at $L$ and to the extensions of sides $AB$ and $CD$. Suppose that points $O$, $K$, $L$ lie on a line. Prove that the midpoints of $BC$ and $AD$ and the center of $\\omega$ also lie on a line.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h514286p2889224}{All Russia 2000 P9.3}{E}{Let $O$ be the center of the circumcircle $\\omega$ of an acute-angle triangle $ABC$. A circle $\\omega_1$ with center $K$ passes through $A$, $O$, $C$ and intersects $AB$ at $M$ and $BC$ at $N$. Point $L$ is symmetric to $K$ with respect to line $NM$. Prove that $BL \\perp AC$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/q1h512017p2874889}{WenWuGuangHua Mathematics Workshop}{M}{\n\t\t\t\n\t\t\t\\begin{enumerate}\n\t\t\t\n\t\t\t\t\\item $ AD, BE, CF $ are concurrent cevians. Angle bisectors of $ \\angle ADB $ and $ \\angle AEB $ meet at $ C_0 $. Again the angle bisectors of $ \\angle ADC $ and $ \\angle AFC $ meet at $ B_0 $. And bisectors of $ \\angle BEC $ and $ \\angle BFC $ meet at $ A_0 $. Prove that $ AA_0, BB_0, CC_0 $ are concurrent.\n\t\t\t\n\t\t\t\t\\item Angle bisectors of $ \\angle AEB $ and $ \\angle AFC $ meet at $ D_0 $, of $ \\angle BFC $ and $ BDA $ meet at $ E_0 $, and of $ \\angle CEB $ and $ \\angle CDA $ meet at $ F_0 $. Prove that $ DD_0, EE_0, FF_0 $ are concurrent.\n\t\t\t\n\t\t\t\\end{enumerate}}\n\t\n\t\t\t\n\t\t\t\\solu{As this problem is purely made up with lines, we can do a projective transformation to simplify the problem. And as there are perpendicularity at $ D, E, F $, we make $ D, E, F $ the feet of the altitudes of $ \\triangle ABC $. Then the angle bisector properties get replaced by simpler properties wrt $ DEF $.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h359172}{WenWuGuangHua Mathematics Workshop}{E}{Generalization: Let $ AD, BE, CF $ be any cevians concurrent at $ T $. $ AD\\cap EF=A',\\ BE\\cap DF=B',\\ CF\\cap DE=C',\\ B'A'\\cap AC= X,\\ B'A'\\cap BC= Y,\\ C'X\\cap EF=Z $. Prove that $ T, Y, Z $ are collinear.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/q1h512618p2878013}{AoPS}{E}{On circumcircle of triangle $ABC$, $T$ and $K$ are midpoints of arcs $BC$ and $BAC$ respectively . And $E$ is foot of altitude from $C$ on $AB$ . Point $P$ is on extension of $AK$ such that $PE$ is perpendicular to $ET$ . Prove that $PC=CK$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c5t256599f5h1629606_geo_3_equals_freak_out}{USJMO 2018 P3}{E}{Let $ABCD$ be a quadrilateral inscribed in circle $\\omega$ with $\\overline{AC} \\perp \\overline{BD}$. Let $E$ and $F$ be the reflections of $D$ over lines $BA$ and $BC$, respectively, and let $P$ be the intersection of lines $BD$ and $EF$. Suppose that the circumcircle of $\\triangle EPD$ meets $\\omega$ at $D$ and $Q$, and the circumcircle of $\\triangle FPD$ meets $\\omega$ at $D$ and $R$. Show that $EQ = FR$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h181312p996629}{All Russia 2002 P11.6}{M}{The diagonals $AC$ and $BD$ of a cyclic quadrilateral $ABCD$ meet at $O$. The circumcircles of triangles $AOB$ and $COD$ intersect again at $K$. Point $L$ is such that the triangles $BLC$ and $AKD$ are similar and equally oriented. Prove that if the quadrilateral $BLCK$ is convex, then it has an incircle.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/q3h511494p2873290}{WenWuGuangHua Mathematics Workshop}{M}{Let $ O_B, O_C $ be the $ B, C $ mixtilinear excircles. $ O $ meet $ CA, CB $ at $ X_C, Y_C $ and $ O_B $ meet $ BA, BC $ at $ X_B, Y_B $. Let $ I_C $ be the $ C $-excircle. $ I_CY_B $ meet $ O_BO_C $ at $ T $. Prove that $ BT\\perp O_BO_C $}\n\t\n\t\t\t\\solu{From what we have to prove, we find two circles, from where we get another circle. This circle suggests that we try power of point. }\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1623012p10163453}{Iran TST 2018 T1P3}{M}{In triangle $ABC$ let $M$ be the midpoint of $BC$. Let $\\omega$ be a circle inside of $ABC$ and is tangent to $AB,AC$ at $E,F$, respectively. The tangents from $M$ to $\\omega$ meet $\\omega$ at $P,Q$ such that $P$ and $B$ lie on the same side of $AM$. Let $X \\equiv PM \\cap BF $ and $Y \\equiv QM \\cap CE $. If $2PM=BC$ prove that $XY$ is tangent to $\\omega$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1623417p10167655}{Iran TST 2018 T1P4}{E}{Let $ABC$ be a triangle ($\\angle A\\neq 90^\\circ$). $BE,CF$ are the altitudes of the triangle. The bisector of $\\angle A$ intersects $EF,BC$ at $M,N$. Let $P$ be a point such that $MP\\perp EF$ and $NP\\perp BC$. Prove that $AP$ passes through the midpoint of $BC$.}\n\t\n\t\t\t\\solu{:'3 kala para na  T\\_T }\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/6h1629942p10229160}{Iran TST 2018 T3P6}{H}{Consider quadrilateral $ ABCD $ inscribed in circle $ \\omega $. $ AC\\cap BD = P $. $ E, F $ lie on sides $ AB, CD $, respectively such that $ \\angle APE=\\angle DPF $. Circles $ \\omega_1, \\omega_2 $ are tangent to $ \\omega $ at $ X, Y $ respectively and also both tangent to the circumcircle of $ PEF $ at $ P $. Prove that: \\[\\frac{EX}{EY}=\\frac{FX}{FY}\\]}\n\t\n\t\t\t\\solu{fucking beautiful.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{}{ISL 2006 G6}{E}{Circles $ \\omega_1 $ and $ \\omega_2 $ with centres $ O_1 $ and $ O_2 $ are externally tangent at point $ D $ and internally tangent to a circle $ \\omega $ at points $ E $ and $ F $ respectively. Line $ t $ is the common tangent of $ \\omega_1 $ and $ \\omega_2 $ at $ D $. Let $ AB $ be the diameter of $ \\omega $ perpendicular to $ t $, so that $ A, E, O_1 $ are on the same side of $ t $. Prove that lines $ AO_1, BO_2, EF $ and $ t $ are concurrent.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{}{ISL 2006 G7}{E}{In a triangle $ ABC $, let $ M_a, M_b, M_c $ be the midpoints of the sides $ BC, CA, AB $, respectively, and $ T_a, T_b, T_c $ be the midpoints of the arcs $BC, CA, AB$ of the circumcircle of $ABC$, not containing the vertices's $A, B, C$, respectively. For $i \\in {a, b, c}$, let $w_i$ be the circle with $M_iT_i$ as diameter. Let $p_i$ be the common external common tangent to the circles $w_j$ and $w_k$ (for all ${i, j, k} = {a, b, c}$) such that $w_i$ lies on the opposite side of $p_i$ than $w_j$ and $w_k$ do. \n\t\t\n\t\tProve that the lines $p_a, p_b, p_c$ form a triangle similar to $ABC$ and find the ratio of similitude}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{}{ISL 2006 G9}{H}{Points $A_1, B_1, C_1$ are chosen on the sides $BC, CA, AB$ of a triangle $ABC$, respectively. The circumcircles of triangles $AB_1C_1,\\ BC_1A_1,\\ CA_1B_1$ intersect the circumcircle of triangle $ABC$ again at points $A_2, B_2, C_2$, respectively ($A_2 \\not= A, B_2 \\not= B, C_2 \\not= C$). Points $A_3, B_3, C_3$ are symmetric to $A_1, B_1, C_1$ with respect to the midpoints of the sides $BC, CA, AB$ respectively. Prove that the triangles $A_2B_2C_2$ and $A_3B_3C_3$ are similar.}\n\t\n\t\t\t\\solu{In this type of ``Miquel's Point and the intersections of the circumcircles'' related problems, it is useful to think about the second intersections of the lines joining the first intersections and the Miquel's Point with the main circle.}\n\t\n\t\t\t\\figdf{1}{ISL2006G9}{IMO Shortlist G9}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1423742p8012536}{Iran TST 2017 P5}{}{In triangle $ABC$, arbitrary points $P,Q$ lie on side $BC$ such that $BP=CQ$ and $P$ lies between $B,Q$. The circumcircle of triangle $APQ$ intersects sides $AB,AC$ at $E,F$ respectively. The point $T$ is the intersection of $EP,FQ$. Two lines passing through the midpoint of $BC$ and parallel to $AB$ and $AC$, intersect $EP$ and $FQ$ at points $X,Y$ respectively. Prove that the circumcircle of triangle $TXY$ and triangle $APQ$ are tangent to each other.}\n\n\n\n\n\n\t\t\\prob{}{}{E}{Let $ X $  be the touchpoint of the incircle with $ BC $ and let $ AX $ meet $ \\cdot ABC $ at $ D $. The tangents from $ D $ to the incircle meet $ \\cdot ABC $ at $ E, F $. Prove that the tangent to the circumcircle at $ A $, $ EF $ and $ BC $ are concurrent.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h546185p3160596}{ISL 2012 G8}{M}{Let $ABC$ be a triangle with circumcircle $\\omega$ and $\\ell$ a line without common points with $\\omega$. Denote by $P$ the foot of the perpendicular from the center of $\\omega$ to $\\ell$. The side-lines $BC,CA,AB$ intersect $\\ell$ at the points $X,Y,Z$ different from $P$. Prove that the circumcircles of the triangles $AXP$, $BYP$ and $CZP$ have a common point different from $P$ or are mutually tangent at $P$.}\n\t\n\t\t\t\\solu{Using Cross ratio and Desergaus's Involution Theorem.}\n\n\n\n\n\t\t\\prob{}{}{E}{Suppose an involution on a line $ l $ sending $ X, Y, Z $ to $ X', Y', Z' $. Let $ l_x, l_y, l_z $ be three lines passing through $ X, Y, Z $ respectively. And let $ X_0=l_y\\cap l_z,\\ Y_0=l_x\\cap l_z,\\ Z_0=l_x\\cap l_y $. Then $ X_0X', Y_0Y', Z_0Z' $ are concurrent.}\n\n\n\n\n\n\t\t\\prob{}{USAMO 2018 P5}{E}{In convex cyclic quadrilateral $ABCD$, we know that lines $AC$ and $BD$ intersect at $E$, lines $AB$ and $CD$ intersect at $F$, and lines $BC$ and $DA$ intersect at $G$. Suppose that the circumcircle of $\\triangle ABE$ intersects line $CB$ at $B$ and $P$, and the circumcircle of $\\triangle ADE$ intersects line $CD$ at $D$ and $Q$, where $C,B,P,G$ and $C,Q,D,F$ are collinear in that order. Prove that if lines $FP$ and $GQ$ intersect at $M$, then $\\angle MAC = 90^\\circ$.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1381506p7662154}{Japan MO 2017 P3}{E}{Let $ABC$ be an acute-angled triangle with the circumcenter $O$. Let $D,E$ and $F$ be the feet of the altitudes from $A,B$ and $C$, respectively, and let $M$ be the midpoint of $BC$. $AD$ and $EF$ meet at $X$, $AO$ and $BC$ meet at $Y$, and let $Z$ be the midpoint of $XY$. Prove that $A,Z,M$ are collinear.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17316p118667}{ISL 2002 G1}{E}{Let $B$ be a point on a circle $S_1$, and let $A$ be a point distinct from $B$ on the tangent at $B$ to $S_1$. Let $C$ be a point not on $S_1$ such that the line segment $AC$ meets $S_1$ at two distinct points. Let $S_2$ be the circle touching $AC$ at $C$ and touching $S_1$ at a point $D$ on the opposite side of $AC$ from $B$. Prove that the circumcenter of triangle $BCD$ lies on the circumcircle of triangle $ABC$.}\n\n\n\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17317p118668}{ISL 2002 G2}{M}{Let $ABC$ be a triangle for which there exists an interior point $F$ such that $\\angle AFB=\\angle BFC=\\angle CFA$. Let the lines $BF$ and $CF$ meet the sides $AC$ and $AB$ at $D$ and $E$ respectively. Prove that \\[ AB+AC\\geq4DE. \\]}\n\t\n\t\t\t\\solu{Pari nai.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17318p118672}{ISL 2002 G3}{E}{The circle $S$ has center $O$, and $BC$ is a diameter of $S$. Let $A$ be a point of $S$ such that $\\angle AOB<120{{}^\\circ}$. Let $D$ be the midpoint of the arc $AB$ which does not contain $C$. The line through $O$ parallel to $DA$ meets the line $AC$ at $I$. The perpendicular bisector of $OA$ meets $S$ at $E$ and at $F$. Prove that $I$ is the incenter of the triangle $CEF.$}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17319p118673}{ISL 2002 G4}{E}{Circles $S_1$ and $S_2$ intersect at points $P$ and $Q$. Distinct points $A_1$ and $B_1$ (not at $P$ or $Q$) are selected on $S_1$. The lines $A_1P$ and $B_1P$ meet $S_2$ again at $A_2$ and $B_2$ respectively, and the lines $A_1B_1$ and $A_2B_2$ meet at $C$. Prove that, as $A_1$ and $B_1$ vary, the circumcentres of triangles $A_1A_2C$ all lie on one fixed circle.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h17323p118682}{ISL 2002 G7}{E}{The incircle $ \\Omega$ of the acute-angled triangle $ ABC$ is tangent to its side $ BC$ at a point $ K$. Let $ AD$ be an altitude of triangle $ ABC$, and let $ M$ be the midpoint of the segment $ AD$. If $ N$ is the common point of the circle $ \\Omega$ and the line $ KM$ (distinct from $ K$), then prove that the incircle $ \\Omega$ and the circumcircle of triangle $ BCN$ are tangent to each other at the point $ N$.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1381506p7662154}{Japan MO 2017 P3}{E}{Let $ABC$ be an acute-angled triangle with the circumcenter $O$. Let $D,E$ and $F$ be the feet of the altitudes from $A,B$ and $C$, respectively, and let $M$ be the midpoint of $BC$. $AD$ and $EF$ meet at $X$, $AO$ and $BC$ meet at $Y$, and let $Z$ be the midpoint of $XY$. Prove that $A,Z,M$ are collinear.}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{}{India TST}{E}{$ ABC $ triangle, $ D, E, F $ touchpoints, $ M $ midpoint of $ BC $, $ K $ orthocenter of $ \\triangle AIC $, prove that $ MI \\perp KD $}\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h355790p1932935}{ISL 2009 G3}{E}{Let $ABC$ be a triangle. The incircle of $ABC$ touches the sides $AB$ and $AC$ at the points $Z$ and $Y$, respectively. Let $G$ be the point where the lines $BY$ and $CZ$ meet, and let $R$ and $S$ be points such that the two quadrilaterals $BCYR$ and $BCSZ$ are parallelogram. Prove that $GR=GS$.}\n\t\n\t\t\t\\solu{Point Circle, distance same means Power same wrt point circles.}\n\t\n\t\n\t\t\n\n\n\t\t\n\t\n\t\n\t\n\t\n\t\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1634974p10278638}{ARO 2018 P11.6}{E}{Three diagonals of a regular $n$-gon prism intersect at an interior point $O$. Show that $O$ is the center of the prism.\n\t\t\n\t\t(The diagonal of the prism is a segment joining two vertices's not lying on the same face of the prism.)}\n\t\n\t\n\t\n\t\n\t\t\\vspace{8mm}\n\t\n\t\t\n\n\n\t\n\n\n\t\t\\prob{https://artofproblemsolving.com/community/c6h488829p2739327}{ISL 2011 G4}{EM}{Let $ABC$ be an acute triangle with circumcircle $\\Omega$. Let $B_0$ be the midpoint of $AC$ and let $C_0$ be the midpoint of $AB$. Let $D$ be the foot of the altitude from $A$ and let $G$ be the centroid of the triangle $ABC$. Let $\\omega$ be a circle through $B_0$ and $C_0$ that is tangent to the circle $\\Omega$ at a point $X\\not= A$. Prove that the points $D,G$ and $X$ are collinear.}\n\t\n\t\t\t\\vspace{8mm}\n\t\n\t\n\n\n\n\t\t\\prob{}{}{Constructing a forth circle tangent}{Given 3 circle, construct another circle that is tangent to these three circles.}\n\t\n\t\t\t\\solu{A trick to remember: decreasing the radius's of some circles doesn't effect much.}\n\t\n\t\n\t\n\n\n\t\t\\prob{}{}{H}{Let $ ABCD $ be a convex quadrilateral, let $ AD\\cap BC = P $. Let $ O, O';\\ H, H' $ be the circumcentres and orthocenter of $ \\triangle PCD, \\triangle PAB $. $ \\odot DOC $ is tangent to $ \\odot AD'B $, if and only if $ \\odot DHC $ is tangent to $ \\odot AH'B $}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\\prob{https://artofproblemsolving.com/community/c6h1493342p8776187}{Iran MO 3rd round 2017 mid-terms Geometry P3}{M}{Let $ABC$ be an acute-angle triangle. Suppose that $M$ be the midpoint of $BC$ and $H$ be the orthocenter of $ABC$. Let $F\\equiv BH\\cap AC$ and $E\\equiv CH\\cap AB$. Suppose that $X$ be a point on $EF$ such that $\\angle XMH=\\angle HAM$ and $A,X$ are in the distinct side of $MH$. Prove that $AH$ bisects $MX$.}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n%todo: curvilinear incircle prob", "meta": {"hexsha": "9fcfa30b7ac7732a65a28cc1ad1a7b430be5e07a", "size": 26935, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geo/sec13_problems.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "geo/sec13_problems.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geo/sec13_problems.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 60.3923766816, "max_line_length": 682, "alphanum_fraction": 0.6777055875, "num_tokens": 9180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4096728136065648}}
{"text": "\\documentstyle[11pt,reduce]{article}\n\\title{A \\REDUCE{} package for Symmetry}\n\\date{}\n\\author{Karin Gatermann\\\\\n        Konrad-Zuse-Zentrum f\\\"ur Informationstechnik Berlin\\\\\n        Takustrasse\\ 7\\\\\n        D--14195 Berlin--Dahlem\\\\\n        Federal Republic of Germany\\\\\n\tE--mail: gatermann@zib.de}\n\\begin{document}\n\\maketitle\n\\index{SYMMETRY package}\n\nThis short note describes a package of \\REDUCE{} procedures\nthat compute symmetry-adapted bases and block diagonal forms\nof matrices which have the symmetry of a group.\nThe SYMMETRY package is the implementation\nof the theory of linear representations\nfor small finite groups such as the dihedral groups.\n\n\\section{Introduction}\n\nThe exploitation of symmetry is a very important principle in mathematics,\nphysics and engineering sciences.\nThe aim of the SYMMETRY package is to give an easy access to the\nunderlying theory of linear representations for small groups. For\nexample the\ndihedral groups $D_3,D_4,D_5,D_6$ are included.\nFor an introduction to the theory see {\\sc Serre} \\cite{Se77} or\n{\\sc Stiefel} and {\\sc F\\\"assler} \\cite{StFae79}.\nFor a given orthogonal (or unitarian) linear representation\n\\[\n\\vartheta : G\\longrightarrow GL(K^n), \\qquad K=R,C.\n\\]\nthe character $\\psi\\rightarrow K$, the\ncanonical decomposition or the bases of the isotypic\ncomponents are computed. A matrix $A$ having the symmetry of a linear\nrepresentation,e.g.\n\\[\n\\vartheta_t A = A \\vartheta_t \\quad \\forall \\, t\\in G,\n\\]\nis transformed to block diagonal form by a coordinate\ntransformation.\nThe dependence of the algorithm on the\nfield of real or complex numbers is controled by the switch {\\tt complex}.\nAn example for this is given in the testfile {\\em symmetry.tst}.\n\nAs the algorithm needs information concerning the irreducible representations\nthis information is stored for some groups (see the operators in Section 3).\nIt is assumed that only orthogonal (unitar) representations are given.\n\nThe package is loaded by\n\n{\\tt load symmetry;}\n\n\\section{Operators for linear representations}\n\nFirst the data structure for a linear representation has to be explained.\n{\\em representation} is a list consisting of the group identifier and\nequations which assign matrices to the generators of the group.\n\n{\\bf Example:}\n\\begin{verbatim}\n   rr:=mat((0,1,0,0),\n           (0,0,1,0),\n           (0,0,0,1),\n           (1,0,0,0));\n\n   sp:=mat((0,1,0,0),\n           (1,0,0,0),\n           (0,0,0,1),\n           (0,0,1,0));\n\n   representation:={D4,rD4=rr,sD4=sp};\n\\end{verbatim}\n\nFor orthogonal (unitarian) representations the following operators\nare available.\n\n{\\tt canonicaldecomposition(representation);}\n\nreturns an equation giving the canonical decomposition of the linear\nrepresentation.\n\n{\\tt character(representation);}\n\ncomputes the character of the linear representation. The result is a list\nof the group identifier and of lists consisting of a\nlist of group elements in one equivalence class and a real or complex number.\n\n{\\tt symmetrybasis(representation,nr);}\n\ncomputes the basis of the isotypic component corresponding to the irreducible\nrepresentation of type nr. If the nr-th irreducible representation is\nmultidimensional, the basis is symmetry adapted. The output is a matrix.\n\n{\\tt symmetrybasispart(representation,nr);}\n\nis similar as {\\tt symmetrybasis}, but for multidimensional\nirreducible representations only the first part of the\nsymmetry adapted basis is computed.\n\n{\\tt allsymmetrybases(representation);}\n\nis similar as {\\tt symmetrybasis} and {\\tt symmetrybasispart},\nbut the bases of all\nisotypic components are computed and thus a\ncomplete coordinate transformation is returned.\n\n{\\tt diagonalize(matrix,representation);}\n\nreturns the block diagonal form of matrix which has the symmetry\nof the given linear representation. Otherwise an error message occurs.\n\n{\\tt on complex;}\n\nOf course the property of irreducibility depends on the field $K$ of\nreal or complex numbers. This is why the algorithm depends on $K$.\nThe type of computation is set by the switch {\\em complex}.\n\n\\section{Display Operators}\n\nIn this section the operators are described which give access to the\nstored information for a group.\nFirst the operators for the abstract groups are given.\nThen it is described how to get the irreducible representations\nfor a group.\n\n{\\tt availablegroups();}\n\nreturns the list of all groups for which the information such as\nirreducible representations is stored. In the following {\\tt group}\nis always one of these group identifiers.\n\n{\\tt printgroup(group);}\n\nreturns the list of all group elements;\n\n{\\tt generators(group);}\n\nreturns a list of group elements which generates the group. For the\ndefinition of a linear representation matrices for these generators\nhave to be defined.\n\n{\\tt charactertable(group);}\n\nreturns a list of the characters corresponding to the irreducible\nrepresentations of this group.\n\n{\\tt charactern(group,nr);}\n\nreturns the character corresponding to the nr-th irreducible representation\nof this group as a list (see also {\\tt character}).\n\n{\\tt irreduciblereptable(group);}\n\nreturns the list of irreducible representations of the group.\n\n{\\tt irreduciblerepnr(group,nr);}\n\nreturns an irreducible representation of the group. The output\nis a list of the group identifier and equations\nassigning the representation matrices to group elements.\n\n\\section{Storing a new group}\n\nIf the user wants to do computations for a group for which\ninformation is not predefined,\nthe package SYMMETRY offers the possibility to supply information\nfor this group.\n\nFor this the following data structures are used.\n\n{\\bf elemlist} = list of identifiers.\n\n{\\bf relationlist}  = list of equations with identifiers and\noperators $@$ and $**$.\n\n{\\bf grouptable} = matrix with the (1,1)-entry grouptable.\n\n{\\bf filename} = \"myfilename.new\".\n\n\\vspace{2cm}\nThe following operators have to be used in this order.\n\n{\\tt setgenerators(group,elemlist,relationlist);}\n\n{\\bf Example:}\n\\begin{verbatim}\n   setgenerators(K4,{s1K4,s2K4},\n     {s1K4^2=id,s2K4^2=id,s1K4@s2K4=s2K4@s1K4});\n\\end{verbatim}\n\n{\\bf setelements(group,relationlist);}\n\nThe group elements except the neutral element\nare given as product of the defined\ngenerators. The neutral element is always called {\\tt id}.\n\n{\\bf Example:}\n\\begin{verbatim}\n   setelements(K4,\n        {s1K4=s1K4,s2K4=s2K4,rK4=s1K4@s2K4});\n\\end{verbatim}\n\n{\\bf setgrouptable(group,grouptable);}\n\ninstalls the group table.\n\n{\\bf Example:}\n\\begin{verbatim}\n   tab:=\n    mat((grouptable,     id,    s1K4, s2K4, rK4),\n        (id        ,     id,    s1K4, s2K4, rK4),\n        (s1K4      ,    s1K4,     id,  rK4,s2K4),\n        (s2K4      ,    s2K4,    rK4,   id,s1K4),\n        (rK4       ,     rK4,   s2K4, s1K4,  id));\n\n   setgrouptable(K4,tab);\n\\end{verbatim}\n\n{\\bf Rsetrepresentation(representation,type);}\n\nis used to define the real irreducible representations of the group.\nThe variable {\\tt type} is either {\\em realtype} or {\\em complextype}\nwhich indicates the type of the real irreducible representation.\n\n{\\bf Example:}\n\\begin{verbatim}\n   eins:=mat((1));\n   mineins:=mat((-1));\n   rep3:={K4,s1K4=eins,s2K4=mineins};\n   Rsetrepresentation(rep3,realtype);\n\\end{verbatim}\n\n{\\bf Csetrepresentation(representation);}\n\nThis defines the complex irreducible representations.\n\n{\\bf setavailable(group);}\n\nterminates the installation of the group203. It checks some properties of the\nirreducible representations and makes the group available for the\noperators in Sections 2 and 3.\n\n{\\bf storegroup(group,filename);}\n\nwrites the information concerning the group to the file with name\n{\\em filename}.\n\n{\\bf loadgroups(filename);}\n\nloads a user defined group from the file {\\em filename} into\nthe system.\n\n\\begin{thebibliography}{5}\n\n\\bibitem{JaKer81} G.\\ James, A.\\ Kerber: {\\it Representation Theory\nof the Symmetric Group.} Addison, Wesley (1981).\n\n\\bibitem{LuFal88} W.\\ Ludwig, C.\\ Falter: {\\it Symmetries in Physics.}\nSpringer, Berlin, Heidelberg, New York (1988).\n\n\\bibitem{Se77} J.--P.\\ Serre, {\\it Linear Representations of Finite\nGroups}. Springer, New~York (1977).\n\n\\bibitem{StFae79} E.\\  Stiefel, A.\\  F{\\\"a}ssler, {\\it Gruppentheoretische\nMethoden und ihre Anwendung}. Teubner, Stuttgart (1979).\n(English translation to appear by Birkh\\\"auser (1992)).\n\n\\end{thebibliography}\n\\end{document}\n", "meta": {"hexsha": "2e5005fe21e659d797f748b6b1540f43699f04d6", "size": 8302, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/symmetry/symmetry.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/symmetry/symmetry.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/symmetry/symmetry.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4102564103, "max_line_length": 77, "alphanum_fraction": 0.746928451, "num_tokens": 2140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123243, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4096728097310438}}
{"text": "%!TEX root = ./thesis.tex\n\\graphicspath{{./Figs/LiteratureReview/}}\n% Acronym\n\\nomtypeA{LES}{Large Eddy Simulations}\n% Neutral ABL\n\\nomtypeR{$S_\\epsilon$}{Source term in turbulent dissipation rate equation}{}\n\\nomtypeR{$S_k$}{Source term in turbulent kinetic energy equation}{}\n\n\\chapter{Literature Review}\n\\section{Neutral Atmospheric Boundary Layer modelling}\n\\subsection{Horizontally homogeneous boundary layer}\nThe important task before modelling flows in ABL is obtaining equilibrium ABL, i.e. zero stream-wise gradients of all variables. For neutral atmospheric boundary layer, \\textcite{Richards1993} proposed the appropriate boundary conditions of mean wind speed and turbulence quantities for the standard $k-\\epsilon$ model. These profiles were derived assuming constant shear stress with height and applied for surface layer of ABL. These were used to model ABL surface layer as horizontally homogeneous turbulent surface layer (HHTSL). However, HHTSL was hard to achieved mostly due to the ground boundary conditions \\cite{Yang2009}, which manifested in the decay of velocity profile due to a spike in the turbulent kinetic energy profile close to the ground. The consistency between wall boundary conditions, turbulence model with associated constants and also numerical schemes was shown to help to achieve HHTSL \\cite{Jonathon2012, Parente2011, Yan2016}. Under HHTSL, the governing equations can be simplified as:\n\\begin{equation} \\label{eq:Richards1993_eqns}\n\\begin{aligned}\n\\nu_t \\pdv{u(z)}{z} = \\frac{\\tau_w}{\\rho} = u_*^2 \\\\\n\\pdv{}{z} \\left(\\nu_t \\pdv{u(k)}{z}\\right) + S_k = 0\\\\\t \n\\pdv{}{z} \\left(\\frac{\\nu_t}{\\sigma_{\\epsilon}} \\pdv{\\epsilon}{z}\\right) (C_{1\\epsilon} - C_{2\\epsilon})\\frac{\\epsilon^2}{k} + S_\\epsilon = 0  \n\\end{aligned}\n\\end{equation}\n\nThe inlet boundary conditions proposed by \\textcite{Richards1993}, widely used in CFD study of atmospheric flow are:\n\\begin{equation} \\label{eq:Richards1993_inlet}\n\\begin{aligned}\nu(z) &= \\frac{u_{*}}{\\kappa }\\ln \\frac{z+z_0}{z_0}\\\\\nk &= \\frac{u_{*}^2}{\\sqrt{C_\\mu}}\\\\\t \n\\epsilon &= \\frac{u_{*}^3}{\\kappa (z + z_0)}  \n\\end{aligned}\n\\end{equation}\n\nThese profiles are assured a solution of Equation~(\\ref{eq:Richards1993_eqns}), if the model constant, turbulent Prandtl number of the dissipation rate $\\sigma_{\\epsilon}$, is modified as:\n\\begin{equation} \\label{eq:Richards1993_model_constrain}\n\\sigma_{\\epsilon} = \\frac{\\kappa^2 }{(C_{\\epsilon2}-C_{\\epsilon1}) \\sqrt C_\\mu}\n\\end{equation}\n\nInstead of altering model constants, \\textcite{Pontiggia2009} derived the $\\epsilon$ equation $z$-dependent source term from solution of Equation~(\\ref{eq:Richards1993_inlet}):\n\\begin{equation} \\label{eq:epsSourcePont}\nS_\\epsilon= \\frac{\\rho u_*^4}{(z+z_0)^2} \\left[ \\frac{(C_{\\epsilon 2}-C_{\\epsilon 1})\\sqrt{C_\\mu}}{\\kappa^2} - \\frac{1}{\\sigma_{\\epsilon}} \\right] - \\mu \\frac{\\rho u_*^3}{ 2 \\kappa(z+z_0)^3}\n\\end{equation}\nUnder turbulence case, molecular viscosity is negligible, therefore the second term is usually ignored.\n\nConstant inlet turbulence kinetic energy proposed by \\textcite{Richards1993} is subjected to many arguments. Since velocity field is limited affected by turbulence kinetic energy but the concentration field because if enhancing dispersion effect of turbulence. As noted by \\textcite{Parente2011}, decreasing $k$ with height was shown in many wind tunnel test. \\textcite{Yang2009} proposed new profile of $k$ and $\\epsilon$ for standard $k-\\epsilon$ model. $k$, $\\epsilon$ are the non-linear function of height as:\n\\begin{equation}\n\\begin{aligned}\nk &=\\frac{u_*^2}{C_\\mu^{1/2}}\\sqrt{C_1 \\ln\\left(\\frac{z+z_0}{z_0}\\right)+C_2}\\\\\n\\epsilon &=\\frac{u_*^3}{\\kappa (z+z_0)}\\sqrt{C_1 \\ln\\left(\\frac{z+z_0}{z_0}\\right)+C_2}\\\\\n\\end{aligned}\n\\end{equation} \n$C_1=-0.17$ and $C_2=1.62$ are constants fitted from their wind tunnel experiments. They also proposed modified standard model constants in Table~\\ref{tab:kEpsModifiedYang2009}.\n\\def\\rowWidth{0.06}\n\\begin{table}[htbp]\n\t\\caption{The modified $k-\\epsilon$ model constants by \\textcite{Yang2009}} \\label{tab:kEpsModifiedYang2009}\n\t\\centering\n\t\\begin{tabular}{p{\\rowWidth\\textwidth}p{\\rowWidth\\textwidth}p{\\rowWidth\\textwidth}p{\\rowWidth\\textwidth}p{\\rowWidth\\textwidth}}  \n\t\t\\toprule\n\t\t$C_{1\\epsilon}$\t& $C_{2\\epsilon}$ & $C_{\\mu}$ & $\\sigma_k$ & $\\sigma_\\epsilon$ \\\\\n\t\t\\midrule\n\t\t1.5 & 1.92 \t& 0.028 & 1.67 & 2.51\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\textcite{Parente2011} presented an elaborate procedure to ensure the consistency for arbitrary inlet profile of turbulent kinetic energy $k$. Instead of altering model constants as \\textcite{Yang2009}, the effect of non-constant $k$ on momentum and $\\epsilon$ equation can be characterised by deriving equation for $C_\\mu$:   \n\\begin{equation}\nC_\\mu(z) = \\frac{u_*^4}{k(z)^2}\n\\end{equation} \nSource terms are added to $k$ and $\\epsilon$ transport equations to ensure equilibrium condition:\n\\begin{equation}\n\\begin{aligned}\nS_k &= \\frac{\\rho u_* \\kappa}{\\sigma_k} \\pdv{}{z}\\left((z+z_0) \\pdv{k}{z}\\right)\\\\\nS_\\epsilon &= \\frac{\\rho u_*^4}{(z+z_0)^2} \\left[ \\frac{(C_{\\epsilon 2}-C_{\\epsilon 1})\\sqrt{C_\\mu}}{\\kappa^2} - \\frac{1}{\\sigma_{\\epsilon}} \\right]\\\\\n\\end{aligned}\n\\end{equation}\n\n\\textcite{Richards2011} revisited the problem of modelling the HHTSL by deriving the inlet profiles directly from the conservation and equilibrium equations. This allows various inlet profiles can be specified by varying the turbulence models constants. For standard $k-\\epsilon$ models, the inlet profiles of velocity and turbulence properties are the same as Equation~(\\ref{eq:Richards1993_inlet}). However they suggested to change the von Karman constant according to model constants as:\n\\begin{equation} \\label{eq:vonKarman_constrain}\n\\kappa_{k-\\epsilon} = \\sqrt{(C_{\\epsilon2}-C_{\\epsilon1}) \\sigma_{\\epsilon} \\sqrt C_\\mu}\n\\end{equation}\nUsing the standard $k-\\epsilon$ model constants (Table \\ref{tab:kEpsCons}), we can yield $\\kappa_{k-\\epsilon} = 0.433$. \n\n\\textcite{Hargreaves2007} had shown that zero gradient velocity at the top boundary resulted in a decay of velocity downstream, due to the extraction energy at wall due to wall shear stress. A driving shear stress, zero flux of turbulent kinetic energy and a flux of dissipation rate $\\epsilon$ are to be imposed at the upper boundary:  \n\\begin{equation}\\label{eq:RichardsTopBCs}\n\\begin{aligned}\n\\frac{\\dd u}{\\dd z}&= \\frac{u_*}{\\kappa z}\\\\\n\\frac{\\mu_t}{\\sigma_{\\epsilon}} \\frac{d \\epsilon}{dz} &= -\\frac{\\rho u_{*}^4}{\\sigma_{\\epsilon} z}\\\\\n\\end{aligned}\n\\end{equation}\n\nFor $k-\\omega$ models, the specific dissipation $\\omega$ is solved instead of dissipation rate $\\epsilon$. Profiles of $U$ and $k$ are the same, except the new effective von Karman constant is $\\kappa_{k-\\omega}=0.408$. Profiles for $\\omega$ has expression of:\n\\begin{equation} \\label{eq:hhtslOmeProfile}\n\\omega = \\frac{u_{*}}{C_{\\mu}^{1/2} \\kappa_{k-\\epsilon} z}\n\\end{equation}\n\nSimilarly to the $k-\\epsilon$ turbulence models, a flux of $\\omega$ should be imposed at top boundary:\n\\begin{equation}\n{\\mu_t} \\frac{d \\omega}{dz} = -\\frac{\\rho u_{*}^2}{C_{\\mu}^{1/2} z}\n\\end{equation}\n\nIn present of obstacles, \\textcite{Richards2011} had shown that eddy viscosity models like $k-\\epsilon$ or $k-\\omega$ resulted the over-prediction of stagnation pressures, while Reynolds stress model (RSM) \\cite{Gibson1978} was significantly reduced this issue. \n\n\\subsection{Boundary conditions}\nAt the outlet boundary, the flow is assumed fully developed and unidirectional. All flow variables are supposed to be constant in this boundary. The placement of this boundary, therefore, is very important. As the placement is so close to the source, significant errors can be made due to the propagation of the source to other boundaries. Otherwise, if the placement is so far, the computational time will increase dramatically.\n\nThe top and side of the computational domain are external boundaries representing the far fields of flow. If a constant pressure is applied in these boundaries, this may alter the inlet wind profile in case prescribed pressure is not matched with the boundary velocity \\cite{Luketa-Hanlin2007}. The zero gradient boundary condition, which set normal velocity to zero and all others variables are set equal to the inner values, or symmetry condition can be used at the top and side boundaries to reserve the wind profile and eliminate the effect of changing the inlet profiles. \n\nAt the wall boundary, two models usually applied for turbulence properties are Low Reynolds number (LRN) turbulence model \\cite{Jones1972} and high Re number (HRN) with wall function \\cite{Launder1974}. HRN models are usually less accurate, and also sensitive to the mesh resolution close to the wall. Adaptive wall functions were developed to overcome the restriction HRN, which is the first point above the wall to lie in the logarithmic layer \\cite{Kalitzin2005}. \\textcite{Backar2017} proposed a hybrid approach, so called numerical wall function, where wall adjacent cells are divided into sub-grid and governing equations are solved with appropriate boundary conditions in this sub-grid.\n\n\\section{Stratified Atmospheric Boundary Layer modelling}\nEither the Reynolds Averaged Navier–Stokes (RANS) equations or Large Eddy Simulations (LES) \\cite{Moeng1984,Saiki2000} are used for stratified atmospheric turbulence modelling. RANS turbulence models are still widely used in practical approach to overcome boundary conditions sensitivity and computational intensive of the LES. \n\nThermal stratification results from heat flux of the ground have significant effects to the buoyancy and ABL turbulence. For standard $k-\\epsilon$ model, the source term that accounts for gravity effects in $\\epsilon$ equation can be written as \\cite{Alinot2005}: \n\\begin{equation}\nS_{\\epsilon b} =  C_{\\epsilon 1}(1-C_{\\epsilon 3}) \\frac{\\epsilon}{k} G_b\n\\end{equation}\n$G_b$ is turbulent kinetic energy production source term due to buoyancy:\n\\begin{equation}\nG_b = \\beta g_i \\frac{\\mu_t}{\\sigma_T}  \\left( \\pdv{T}{x_i} - \\frac{g_i}{c_p} \\right) \n\\end{equation}\n\nFor stable stratified ABL, turbulent kinetic energy $k$ and dissipation rate $\\epsilon$ can be derived from Monin-Obukhov similarity theory profiles and solving the $k-\\epsilon$ equation \\cite{Luketa-Hanlin2007}. For the height $z \\le 0.1h_{ABL}$:\n\\begin{equation} \\label{eq:MO-turl-stab-surface}\n\\begin{aligned}\nk &= 6 u_{*}^2\\\\\t \n\\epsilon &= \\frac{u_{*}^3}{\\kappa z}\\left( 1.24 +4.3 \\frac{z}{L_{MO}} \\right)  \n\\end{aligned}\n\\end{equation}\n\nFor the height $z>0.1h_{ABL}$:\n\\begin{equation} \\label{eq:MO-turl-stab-above}\n\\begin{aligned}\nk &= 6 u_{*}^2 \\left( 1-\\frac{z}{h_{ABL}} \\right)^{1.75}\\\\\t \n\\epsilon &= \\frac{u_{*}^3}{\\kappa z}\\left( 1.24 +4.3 \\frac{z}{L_{MO}} \\right) \\left( 1-0.85\\frac{z}{h_{ABL}} \\right)^{1.5} \n\\end{aligned}\n\\end{equation}\n\nUnder unstable ABL, the heat flux from the ground and height of ABL play an important role in increasing the turbulence in the air flow. This vertical flow can be characterised using convective velocity scale Equation~(\\ref{eq:convective-scaling}). Turbulent kinetic energy $k$ and dissipation rate $\\epsilon$ under unstable ABL can be defined in Equation~(\\ref{eq:MO-turb-unstab-surface}) for $z \\le 0.1h_{ABL}$ and Equation~(\\ref{eq:MO-turb-unstab-above}) for $z > 0.1h_{ABL}$.\n\\begin{equation} \\label{eq:MO-turb-unstab-surface}\n\\begin{aligned}\nk &= 0.36 w_{*}^2 + 0.85 u_{*}^2 \\left( 1-3\\frac{z}{h_{ABL}} \\right)^{2/3}\\\\\t \n\\epsilon &= \\frac{u_{*}^3}{\\kappa z} \\left( 1 + 0.5 \\abs{\\frac{z}{L_{MO}}} ^{2/3} \\right)^{1.5} \n\\end{aligned}\n\\end{equation}\n\n\\begin{equation} \\label{eq:MO-turb-unstab-above}\n\\begin{aligned}\nk &=w_{*}^2 \\left[ 0.36 + 0.9\\left( \\frac{z}{h_{ABL}} \\right)^{2/3}\\left( 1-0.8\\frac{z}{h_{ABL}} \\right)^{2} \\right]\\\\\t \n\\epsilon &= \\frac{w_{*}^3}{h_{ABL}} \\left( 0.8-0.3\\frac{z}{h_{ABL}} \\right)\n\\end{aligned}\n\\end{equation}\n\nIn order to simulate atmospheric stratification effects, \\textcite{Alinot2005} changed model constants (Table~\\ref{tab:kEpsConsAlinot2005}) to achieve a better agreement with atmospheric profile from Monin-Obukhov theory.\n\\begin{table}[htbp]\n\t\\caption{The standard $k-\\epsilon$ model constants proposed by \\textcite{Alinot2005}} \\label{tab:kEpsConsAlinot2005}\n\t\\centering\n\t\\begin{tabular}{ccccc}  \n\t\t\\toprule\n\t\t$C_{1\\epsilon}$\t& $C_{2\\epsilon}$ & $C_{\\mu}$ & $\\sigma_k$ & $\\sigma_\\epsilon$ \\\\\n\t\t\\midrule\n\t\t1.176 & 1.92 & 0.0333 & 1 & 3.4 ($L_{MO} > 0$)\\\\\n\t\t&  &  & & -4.4 ($L_{MO} < 0$)\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\nEffects of atmospheric stratification on dense gas dispersion CFD simulations was addressed by \\textcite{Pontiggia2009a}. The consistency between Monin-Obhukov profiles with $k-\\epsilon$ model is obtained by addition of z-dependent source term $S_\\epsilon$ to the $\\epsilon$ transport equation. Under neutral atmospheric stability:\n\\begin{equation}\nS_\\epsilon(z) = \\frac{\\rho u_*^4}{z^2} \\left[ \\frac{(C_{\\epsilon 2}-C_{\\epsilon 1}) \\sqrt{C_\\mu}}{\\kappa^2} - \\frac{1}{\\sigma_{\\epsilon}}\\right] -\\mu \\frac{u_*^3}{2\\kappa z^3}\n\\end{equation}\nUnder stable condition:\n\\begin{equation} \\label{eq:stablePontiggiaEpsSource}\nS_\\epsilon(z) = \\frac{\\rho u_*^4}{z^2} \\left[ \\frac{(C_{\\epsilon 2}-C_{\\epsilon 1}) \\sqrt{C_\\mu}}{\\kappa^2} \\Phi_\\epsilon^2 \\sqrt \\frac{\\Phi_\\epsilon}{\\Phi_m} - \\frac{1}{\\sigma_\\epsilon}\\left( \\frac{2}{\\Phi_m} - \\frac{1}{\\Phi_m^2} + \\frac{T_*}{\\kappa T} \\right)\\right] -\\mu \\frac{u_*^3}{2\\kappa z^3}\n\\end{equation}\n\nIn case of cold dense gas dispersion, heat exchange of gas cloud and the ground surface is a significant heat transfer process. Forced heat convection model was used to find this heat flux \\cite{Nielsen1999}:\n\\begin{equation}\nq_s=h_{f} (T_s - T_f)\n\\end{equation}\n$h_f$ is the local heat transfer coefficient, $T_f$ is the fluid temperature.\n\\textcite{Kovalets2006} used mixed coefficients between force heat convection and natural convection.\n\nSeveral studies used CFD commercial software such as FLUENT; as well as open-source software such as OpenFOAM to simulate ABL layers. \\textcite{Hargreaves2007} have shown that applying at fixed variable fluxes at top boundary is difficult in general CFD software and usually replaced by zero gradient (no shear stress), however this will result a decaying boundary layer. They also highlighted different approaches of modelling near wall region can lead to significantly unexpected results especially when using general CFD software. Wall function applied for atmospheric flow is necessarily modified as the standard wall function is based on experiments of sand grain roughed pipe \\cite{Blocken2007} and wind engineering roughness length $z_0$ is far from similar to this kind of roughness. \\textcite{Pieterse2013} used STAR-CCM+ commercial code to simulate thermally stratified ABL with the standard $k-\\epsilon$ and SST $k-\\omega$ turbulence model.\n\n\\textcite{Flores2013a} used Detached Eddy Simulation (DES) technique, which incorporates RANS models in near wall region and LES model in the rest, to simulate atmospheric wind circulation in open pit. The simulation takes in to account effects of buoyancy, stratification and complex geometry. A quasi-compressible approximation (treating density as explicit variable) was applied to incorporate stratification effect. \\textcite{Riddle2004a} simulated neutrally stable atmospheric boundary layer with RSM turbulence model. \n\n\\section{CFD simulation of dense gas dispersion}\nValue of turbulent Schmidt number $Sc_t$ are shown to have significant effect on dense gas dispersion concentration. Using wind tunnel data, \\textcite{Mokhtarzadeh-Dehghan2012} reported that $Sc_t$ was related with flow thermal stability, which is increased from 0.5 to 2.3 for the flows with Richardson number from 0.1 to 16.\n\nSeveral studies in literature of atmospheric dense gas dispersion using CFD approach adopted commercial software such as ANSYS fluent \\cite{Gavelli2008,Zhang2015,Ikealumba2016,Meroney2012,Labovsky2011}, ANSYS CFX \\cite{Sklavounos2004}, FLACS \\cite{Hanna2004,Hansen2010a,Schleder2015} as well as open-source software such as OpenFOAM \\cite{Mack2013, Fiates2016,Fiates2016a}, FDS \\cite{Mouilleau2009,Ryder2004}. \\textcite{Hansen2010a} validated FLACS in all tests in model evaluation database of LNG vapour dispersion. These include both wind tunnel test as well as field tests.\n\nSeveral turbulence models were tested for dense gas dispersion problem. \\textcite{Mack2013} used standard $k-\\epsilon$ model with OpenFOAM solver \\bera{reactingFoam}, to simulate wind tunnel test case \\bera{DAT632}, which is the gravity driven flow of heavy gas in slope terrain. Different treatments of buoyancy term in $\\epsilon$ equation are investigated. It was shown that standard $k-\\epsilon$ is able to predict turbulence damping due to vertical negative density gradient. \\textcite{Gavelli2008} applied RSM model to account for directional effect of Reynold stress field (using standard $k-\\epsilon$ model as initial guess of turbulence) to simulate \\bera{Falcon1} field test. \\textcite{Gant2014} simulated \\ce{C02} field test with realizable $k-\\epsilon$ model. Different RANS models were also tested for dense gas flow over obstacle \\cite{Sklavounos2004}. \\textcite{Tauseef2011} used realizable $k-\\epsilon$ for modelling two Thorney Island test cases.\n\n\\section{Concluding remarks}\nFrom the investigation of literature, modifications of general CFD are required to successfully simulate the ABL turbulence. These was done intensively in commercial proprietary software. But little works were done in open-source code like OpenFOAM. The modification of general code should be done to successfully apply OpenFOAM in simulating ABL flows.  \n\nEnsuring accurate description of the ABL is an important task in any ABL flow study. This can be done by simulating the horizontally homogeneous ABL flow prior of dispersion study. Either the Reynolds Averaged Navier–Stokes (RANS) equations or Large Eddy Simulations (LES) are used for atmospheric turbulence modelling. RANS turbulence models are still widely used in practical approach to overcome boundary conditions sensitivity and computational intensive of the LES. Neutral and thermal stratified ABL should be taken into account to simulate ABL turbulence.\n\nTurbulent Schmidt number $Sc_t$ had significant effect on ABL dense gas dispersion concentration \\cite{Mokhtarzadeh-Dehghan2012}. Therefore, the solver should be able to take $Sc_t$ as input parameter. In case of LNG vapour dispersion, buoyancy effect and ground heat transfer are two important factors. LNG vapour density changes with its cloud temperature, therefore it behaves as dense gas in low temperature but as buoyant gas at higher temperature. The solver should take into account buoyancy effect in this situation.", "meta": {"hexsha": "4bb0da59bf89592eced427515f0233816822d362", "size": 18738, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LiteratureReview.tex", "max_stars_repo_name": "stevietran/phdThesis", "max_stars_repo_head_hexsha": "c6ccf59f7fa9b63d6af2ba1f9d48efddbf8980f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LiteratureReview.tex", "max_issues_repo_name": "stevietran/phdThesis", "max_issues_repo_head_hexsha": "c6ccf59f7fa9b63d6af2ba1f9d48efddbf8980f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LiteratureReview.tex", "max_forks_repo_name": "stevietran/phdThesis", "max_forks_repo_head_hexsha": "c6ccf59f7fa9b63d6af2ba1f9d48efddbf8980f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 95.6020408163, "max_line_length": 1013, "alphanum_fraction": 0.7620343687, "num_tokens": 5385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.40967280973104375}}
{"text": "\\section{Theoretical Background}\n\n\\subsection{Concept Embedding Analysis}\\label{sec:conceptanalysis}\n\nTo understand the process flow of an algorithm, it is of great value\nto have access to interpretable intermediate outputs.\n% This is not available for DNNs: Their intermediate output of layers,\n% the latent spaces, are high-dimensional, entangled, and non-semantic,\n% meaning semantic information is only indirectly embedded.\n% The latent spaces of DNNs---the output spaces of sets of neurons or of\n% complete layers---usually are far from interpretable.\n% Instead, they are high-dimensional, entangled, and non-semantic, since\n% features are automatically extracted from correlations in the data.\n% However, information about semantic concepts may still be embedded in\n% the latent space of a DNN.\nThe goal of concept embedding analysis is to answer \\emph{whether},\n\\emph{how well}, \\emph{how}, and with what\n\\emph{contribution to the reasoning}\ninformation about semantic concepts is embedded into the latent spaces\n(intermediate outputs) of DNNs, and to provide the result in an\nexplainable way.\nFocus currently lies on finding embeddings in either the complete\noutput of a layer (image-level concepts), or single pixels of an\nactivation map of a convolutional DNN (concept segmentation).\n% \n%%% whether\nTo answer the \\emph{whether}, one can try to find a decoder for the\ninformation about the concept of interest, the \\emph{concept embedding}.\nThis means, one is looking for a classifier on the latent space that\ncan predict the presence of the concept.\n% An example are the mini-1-hidden-layer neural networks used in\n% \\cite{fuchs_neural_2018}.\n% how well\nThe performance of the classifier provides a measure of \\emph{how well}\nthe concept is embedded.\n% \n%%% how\nFor an explainable answer of \\emph{how} a concept is embedded, the\ndecoder should be easily interpretable.\nOne constraint to this is introduced by the rich vector space\nstructure of the space of semantic concepts respectively word vector spaces\n\\cite{mikolov_linguistic_2013}:\nThe decoder map from latent to semantic space should preserve at least\na similarity measure.\nFor example, the encodings of \\enquote{cat} and \\enquote{dog} should\nbe quite similar, whereas that of a \\enquote{car} should be relatively\ndistant from the two.\nThe methods in literature can essentially be grouped by their choice\nof distance measure $\\langle -,-\\rangle$ used on the latent vector space.\nA concept embedding classifier $E_c$ predicting the presence of concept $c$\nin the latent space $L$ then is of the form\n% \\begin{gather*}\n%   \\SwapAboveDisplaySkip\n$E_c(v)=\\langle v_c,v\\rangle > t_c$\n% \\quad\\text{for~}\nfor $v\\in L$,\n% \\end{gather*}\nwhere $v_c\\in L$ is the concept vector of the embedding,\nand $t_c\\in \\R$.% is a threshold for binarizing.\n\nAutomated concept explanations \\cite{ghorbani_towards_2019} uses\n$L_2$ distance as similarity measure. They discover concepts in an\nunsupervised fashion by k-means clustering of the latent space\nrepresentations of input samples. The concept vectors of the\ndiscovered concepts are the cluster centers.\n% In \\cite{yeh_completeness-aware_2020}, an improvement of the clustering\n% by further semantic constraints was suggested.\n% The proposed approach in \\cite{gu_semantics_2019} also uses\n% clustering, but by cosine distance. Their method is supervised in that\n% they try to find a normalized concept vector for a concept given by\n% positive samples. An interesting finding was that the chosen\n% semantic concepts usually have a clearly dominant cluster in the\n% latent space.\n% For regularization, they binarize the entries in the latent space vectors to cluster.\n% \nIn TCAV~\\cite{kim_interpretability_2018} it is claimed that the\nmapping from semantic to latent space should be linear for best\ninterpretability. To achieve this, they suggest to use linear\nclassifiers as concept embeddings. This means they try to find a\nseparation hyperplane between the latent space representations of\npositive and negative samples of the concept.\nA normal vector of the hyperplane then is their concept vector,\nand the distance to the hyperplane\n% measured by the scalar product with the concept vector\nis used as distance measure.\nAs method to obtain the embedding they use support vector machines (SVMs).\nTCAV further investigated the contribution of concepts to given output\nclasses by sensitivity analysis.\nA very similar approach to TCAV, only instead relying on logistic\nregression, is followed by Net2Vec~\\cite{fong_net2vec_2018}.\n% They directly built upon Network Dissection~\\cite{bau_network_2017},\n% which tries to associate concepts to single filters in convolutional\n% DNNs (the unit vectors in the latent space of an activation map pixel).\n% Just as Network Dissection, Net2Vec\nAs a regularization, they add a filter-specific cut-off before the\nconcept embedding analysis to remove noisy small activations.\n% They apply a ReLU to the activation map of each filter with fixed\n% filter-specific threshold.\n% Other than TCAV, they constrain the hyperplane to run\n% through zero, \\idest assume $t_c=0$, which may lead to worse embedding\n% performance.\nThe advantage of Net2Vec over the SVMs in TCAV is that they can\nmore easily be used in a convolutional setting: They used a\n1$\\times$1-convolution to do a prediction of the concept for each\nactivation map pixel, providing a segmentation of the concept.\nThis was extended by \\cite{schwalbe_concept_2020}, who suggested to\nallow larger convolution windows\n% , essentially doing a simplified concept detection.\nto ensure that the receptive field of the window can cover\nthe complete concept. This avoids a focus on local patterns.\n% instead of \\forexample the concept shape.\n% They also investigated some improvements on the optimization\n% technique.\n% \nA measure that can be applied to concept vectors of the same layer\nregardless of the analysis method, is that of\n\\emph{completeness} suggested in \\cite{yeh_completeness-aware_2020}.\nThey try to measure, how much of the information relevant to the final\noutput of the DNN is covered by a chosen set of concepts vectors.\n% Their idea for measurement is as follows: If the layer output is\n% reduced to the linear sub-space spanned by the concept vectors, the\n% overall performance of the DNN should not drop significantly if the\n% set of concepts is complete.\n% This reduction was approximated by adding a bottleneck layer right\n% after the considered layer, where the unit vectors correspond to the\n% concepts.\n% The projection is defined by the concept vectors, the connection to\n% the succeeding layer is learned.\nThey also suggested a metric to compare the attribution of each\nconcept to the completeness score of a set of concepts.\n\n\n\n\\subsection{Inductive Logic Programming}\\label{sec:ilp}\n\nInductive Logic Programming (ILP)~\\cite{muggleton1991inductive} is a\nmachine learning technique that builds a logic theory over positive\nand negative examples ($E^+$, $E^-$). The examples consist of symbolic\nbackground knowledge (BK) in the form of first-order logic predicates,\n\\forexample \\ilprule{contains(Example, Part), isa(Part, nose)}. Here the\nupper case symbols are variables and the lower case symbol is a\nconstant. The given BK describes that example \\ilprule{Example}\ncontains a part \\ilprule{Part} which is a nose. Based on the examples,\na logic theory can be learned. The hypothesis language of this theory\nconsists of logic Horn clauses that contain predicates from the BK. We\nwrite the Horn clauses as implication rules,\n\\forexample\n\\ilprule{\n  \\begin{align*}\n    \\text{face(Example) :- }& \\text{contains(Example, Part), isa(Part, nose)}\\;.\n  \\end{align*}\n}\nFor this work we obey the syntactic rules of the Prolog\nprogramming language. The \\ilprule{:-} denotes the logic implication\n($\\leftarrow$). We call the part before the implication the\n\\emph{head} of a rule and the part after it the \\emph{body} or\n\\emph{preconditions} of a rule. \n\nWe use the framework Aleph~\\cite{srinivasan2001aleph}\nfor this work since it is a flexible and adaptive general purpose ILP\ntoolbox. Aleph's built in algorithm attempts to induce a logic theory\nfrom the given BK to cover as many positive examples $E^+$ as possible\nwhile avoiding covering the negative examples $E^-$. The general\nalgorithm of Aleph can be summarized as\nfollows~\\cite{srinivasan2001aleph}:\n\n\\begin{enumerate}\n\\item As long as positive examples exist, select one. Otherwise halt.\n\\item Construct the most-specific clause that entails the selected example and is within the language constraints.\n\\item Find a more general clause which is a subset of the current literals in the clause.\n\\item Remove examples covered by the current clause.\n\\item Repeat from step 1.\n\\end{enumerate}\n\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"concept_embeddings_and_ilp\"\n%%% End:", "meta": {"hexsha": "335b5edc130b63a5023fd4076884d558f8d505ee", "size": 8840, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper-tex/background.tex", "max_stars_repo_name": "lthamm/concept-embeddings-and-ilp", "max_stars_repo_head_hexsha": "27592c6424147a2fbb54d7daebc92cd72b3f4a0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-11-02T12:21:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-02T14:01:37.000Z", "max_issues_repo_path": "paper-tex/background.tex", "max_issues_repo_name": "lthamm/concept-embeddings-and-ilp", "max_issues_repo_head_hexsha": "27592c6424147a2fbb54d7daebc92cd72b3f4a0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-11-06T07:58:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-13T16:11:30.000Z", "max_forks_repo_path": "paper-tex/background.tex", "max_forks_repo_name": "lthamm/concept-embeddings-and-ilp", "max_forks_repo_head_hexsha": "27592c6424147a2fbb54d7daebc92cd72b3f4a0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-11-03T14:54:16.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-03T14:54:16.000Z", "avg_line_length": 49.1111111111, "max_line_length": 114, "alphanum_fraction": 0.7921945701, "num_tokens": 2083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.4096728097310437}}
{"text": "\\section{Problem Definition}\n\\label{sec:definition}\n\nLoosely speaking, the high-level objective in transient-detection is to locate intrinsicly(?)-varying objects in each recently shot image of the sky.\nMore formally and in the concept of this project, this objective can be defined as finding the mapping\n\\begin{equation}\n  \\label{eq:def1}\n  (I_t,I_s) \\longrightarrow S_t \n\\end{equation}\nwhere $I_s$ is the recently captured image, namely the \\emph{science image}. $I_t$ is the \\emph{template} or \\emph{reference} iamge, and $S_t$ is the set of \\emph{true transients} to be detected.\n\n\nHowever, this problem has traditionally been broken down into two subprolems, namely, \\emph{image differencing}\\footnote{or interchangeably, \\emph{difference imaging}} and \\emph{smart-thresholding}; the latter being the process of finding a threshold above which all the pixels in the diff image, $I_d$, will be seen as candidate transient sources:\n\\begin{equation}\n  \\label{eq:def2}\n  (I_t,I_s) \\xrightarrow{diff} I_d \\xrightarrow{threshold} S_t \n\\end{equation}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=.8\\textwidth]{material/diagram}\n  \\caption{Coarse illustration of information flow through the Alert Production (AP) pipeline. Paths in blue and green illustrate the ``traditional'' and ``modern'' approaches respectively.}\n  \\label{fig:diagram}\n\\end{figure}\n\n\nThe \\emph{thresholding} step has traditionally been implemented as a simple $5\\sigma$-thresholding, but other auxilliary approaches may wrap this stage to make it \\emph{smart}er -- figure~\\ref{fig:diagram}\n\n\n\\section{Learning-based Approaches}\n\\label{sec:learning}\nThe above process is prone to false positives (contamination) and false negatives (misses). Learning-based approaches come into play to mitigate this...\n\nIn the context built in the previous section, a learning based approach can be implemented in two broad ways:\n\\begin{itemize}\n\\item starting off $I_d$ -- a.k.a traditional real/bogus classification.\n\\item starting off $(I_t,I_s)$ -- a.k.a end-to-end, TransiNet-style.\n\\end{itemize}\n\n\\footnote{The term 'detection' in the field of computer vision can be translated to localization+classification in the astrophysics' terminology}\n\n\nPros and cons of the two approaches come in the following sections. However, the current decision is to implement and test the two in parallel. Therefore we shall attempt to bring the two implementations close to eachother -- ideally unified.\n\n\n\\subsection{Basic Real/Bogus Classifier}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=.6\\textwidth]{material/rb-classifier}\n  \\includegraphics[width=.6\\textwidth]{material/rb-classifier-mod}\n  \\caption{Classical Real/bogus classifier (top) and the modified 3D classifier (bottom)}\n  \\label{fig:rbdiagram}\n\\end{figure}\n\nInput-output definition of the problem:\n\\begin{itemize}\n  \\item input: cutouts from diff image ($I_d$) with the potential transient at the center\n  \\item output: reliability score for the potential transient\n\\end{itemize}\n\nAlthough the output of a classifier is categorical (i.e. a class label), we will be using the output before the last Softmax~\\footnote{TBD} layer, which can be intepretted as a probability.\n\n\\subsubsection{Drawbacks}\n\\begin{itemize}\n\\item has no access to the temporal~\\footnote{throughout this document the term ``temporal'' is used to represent the transition from a template/reference image to a science image. It has to do, but should not be confused with the ``real'' time axis!} behaviour of the source. This is by definition outsourced to the upstream image differencing module and hence there is no ``learned intelligence'' in processing the ``transient-ness'' of the candidate.\n\\item any ``miss'' (false negative) in the upstream modules is inherited and irrecoverable.\n\\item can only handle single object per cutout -- when there are multiple true transients, it \\emph{has to} ignore the others.\n\\end{itemize}\n\nThe first two drawbacks are a result of having separated the temporal processing (i.e. image differencing) from the final classification, whereas the last one has to do with how the problem and solution are defined based on cutouts.\n\n% \\paragraph{The case of ambiguous negatives}\n% As of now it is not quite clear what a ``negative'' is for training; in the broadest implementation it can be cutout that is not positive. But since the inputs to this module are the outputs of imdiff, one could only use ``bogus candidates'' as negatives, which is closer to what happens in practice, and may give better results.\n\n\n\\subsubsection{Benefits}\n\\label{sec:rb_benefits}\n\nAlthough as discussed this is just a sub-optimal learning-based approach to this problem, it still has the advantage of \\emph{interpretability}; the generated output might be too contamined with false alarms and (at the same time) missed true transients, but the process is fully transparent to the downstream users of the alerts and they have the possibility to develop their own post-processing blocks per need.\n\n\n\\subsubsection{What will be learned?}\nSince the temporal behaviour of the candidates fed to this module is assumed, it is foreseeable that the neural network will eventually learn a concept close to ``PSF-ness'', true to its title; real/bogus classification.\n\n\\subsubsection{Modified 3D Real/Bogus Classifier}\nIn this implementation the classifier has access to the template, science image pairs along with the diff image. This allows the network to make use of the temporal behavior of the source too.\nNote however that still the difference image has a key role in the process, as the images are cropped around the sources detected in the difference image.\n\n\\subsection{End-to-End Simultaneous Localization and Classification (~TransiNet)}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=.8\\textwidth]{material/transinet-teaser}\n  \\caption{End-to-end image differencing, localization and classification. The output has to be clean and complete \\emph{by definition} }\n  \\label{fig:transinet-teaser}\n\\end{figure}\n\n\\begin{itemize}\n  \\item input: a pair of science,template images: $(I_t,I_s)$\n  \\item output: $S_t$, set of true transients\n  \\item intermediate output: a ``score image'' where scores are assigned per-pixel\n\\end{itemize}\n\nBased on TransiNet~\\cite{transinet}. Does full detection (localization + classification) simultaneously -- along with any necessary implicit steps.\nSince the temporal and spatial behaviors are considered at the same time, the definition of the task of this module would be to find all the time-variable real astronomical sources -- corresponding to the high-level definition of the problem in \\ref{sec:definition}.\n\n\\subsection{The score}\nAs the task definition embraces a recognition according to spatial \\emph{and} temporal features simultaneously, the score needs to be defined carefully to capture both aspects.\n\nThere are multiple available options:\n\\begin{itemize}\n\\item simple binary classification -- the resulting score may not be quite informative\n\\item regression -- more difficult to define\n\\item multi-class classification -- difficult data annotation\n\\end{itemize}\n\nIf we go with regression... there are bogus detections, variables, ``appearing transients''\n\\begin{equation}\n  s=\\left| \\frac{A_2-A_1}{A_2+A_1} \\right|\n\\end{equation}\n\n\n\n\n\n% \\section{Notes from the template}\n\n% \\subsection{How to handle LSST standard references?} \n\n% The papers should cite standard LSST references\\footnote{See \\url{https://github.com/lsst-pst/LSSTreferences}}, \n% where appropriate. For the usage, please see below.  These examples all use the ADS handle, unless they are \n% project docs then the use the project handle like LSE-17.\n\n% All are on the lsst-texmf which you can get from \\url{http://lsst-texmf.lsst.io}\n\n\n% \\subsubsection{LSST System and Science}\n\n% The LSST system (brief overview of telescope, camera and data management subsystems),\n% science drivers and science forecasts are described in:\n\n% \\begin{itemize}\n% \\item LSST Science Requirements Document: \\cite{LPM-17}.\n% \\item LSST overview paper: \\cite{2008arXiv0805.2366I}.\n% \\item LSST Science Book: \\cite{abell2009lsst}.\n% \\end{itemize}\n% %------------------------------------------------------------------------------\n\n\n% \\subsubsection{Simulations}\n\n% The LSST simulations are described in a series of papers. Use of the LSST simulations should cite the LSST simulations overview paper \\cite{2014SPIE.9150E..14C} and the specific simulation tools used:\n\n% \\begin{itemize}\n% \\item LSST Catalogs (CatSim): \\cite{2014SPIE.9150E..14C}\n% \\item Feature-Based Scheduler: \\cite{2018arXiv181004815N}\n% \\item Operations Simulator (OpSim): Scheduler \\cite{2016SPIE.9910E..13D}, SOCS \\cite{2016SPIE.9911E..25R}\n% \\item Metrics Analysis Framework (MAF): \\cite{2014SPIE.9149E..0BJ}\n% \\item Image simulations (Phosim): \\cite{2015ApJS..218...14P}\n% \\item Sky brightness model: \\cite{2016SPIE.9910E..1AY}\n% \\item LSST Performance for NEO (or moving object) discovery: \\cite{2018Icar..303..181J}\n% \\end{itemize}\n% %------------------------------------------------------------------------------\n\n\n% \\subsubsection{Data Management}\n\n% LSST data management system and the data products are described in:\n\n% \\begin{itemize}\n%   \\item The LSST Data Management System: \\cite{2015arXiv151207914J}\n%   \\item Data Products Definition Document: \\cite{LSE-163}\n% \\end{itemize}\n%  %------------------------------------------------------------------------------\n\n\n% \\subsubsection{Camera}\n\n% \\begin{itemize}\n%    \\item Design and development of the LSST camera: \\cite{2010SPIE.7735E..0JK}\n% \\end{itemize}\n% %------------------------------------------------------------------------------\n\n\n% \\subsubsection{Telescope and Site}\n\n% \\begin{itemize}\n%    \\item Telescope and site overview and status in 2014:  \\cite{2014SPIE.9145E..1AG}\n% \\end{itemize}\n% %------------------------------------------------------------------------------\n\n% \\subsubsection{System Engineering}\n\n% \\begin{itemize}\n%    \\item LSST systems engineering: \\cite{2014SPIE.9150E..0MC}\n%    \\item System verification and validation: \\cite{2014SPIE.9150E..0NS}\n% \\end{itemize}\n% %\n\n\n", "meta": {"hexsha": "c700721ef0c35d3f7a0b17cdcd131d0f2d5f66e0", "size": 10149, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "body.tex", "max_stars_repo_name": "lsst-dm/dmtn-216", "max_stars_repo_head_hexsha": "7390a16c5774164df4c9cc802769be7319e1a895", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "body.tex", "max_issues_repo_name": "lsst-dm/dmtn-216", "max_issues_repo_head_hexsha": "7390a16c5774164df4c9cc802769be7319e1a895", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "body.tex", "max_forks_repo_name": "lsst-dm/dmtn-216", "max_forks_repo_head_hexsha": "7390a16c5774164df4c9cc802769be7319e1a895", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.2425742574, "max_line_length": 453, "alphanum_fraction": 0.742142083, "num_tokens": 2506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.523420348936324, "lm_q1q2_score": 0.40966147313980295}}
{"text": "\\documentclass[12pt,a4paper]{article}\n\\usepackage{algorithm, algpseudocode, amsmath, amssymb, csquotes, empheq, geometry, graphicx, hyperref, listings, multirow, physics, siunitx, subcaption, upgreek}\n\\usepackage[section]{placeins}\n\\usepackage[justification=centering]{caption}\n\n\\title{Computational Physics\\\\Problem Set 4}\n\\author{Saleh Shamloo Ahmadi\\\\Student Number: 98100872}\n\\date{October 22, 2021}\n\n\\hypersetup{colorlinks=true, urlcolor=cyan}\n\\newcommand{\\percfig}{../fig/percolation}\n\\newcommand{\\rwfig}{../fig/random-walk}\n\n\\begin{document}\n\t\\maketitle\n\t\\section{Percolation}\n\tNote: we simulate \\emph{site percolation}.\n\t\\subsection{Correlation Length}\n\tThe correlation length $\\xi$ is a measure of the radius of the maximum closed (non-infinite) cluster;\n\tThis shows the maximum length of interactions before phase transition occures and the lattice either becomes\n\thomogenous or clusters are broken off.\n\t\n\tIn our analysis, we use the maximum radius of gyration of closed clusters to measure the correlation length\n\t(any similar measure is valid).\n\n\tThe correlation length diverges (or peaks, for a finite lattice) at the critical probability $p_c$ of forming sites\n\tin the lattice; This is because at higher probabilities, percolation happens frequently and there are less clusters\n\tand at lower probabilites, clusters break off more at smaller length scales.\n\t\n\t\\newgeometry{left=0in, right=0in}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-10}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-20}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-40}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-80}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-160}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-full-320}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\t\\newgeometry{top=0.1in, bottom=0.1in, left=0in, right=0in}\n\t\\thispagestyle{empty}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-zoom-10}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-zoom-20}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-zoom-40}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-zoom-80}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{\\percfig/gyration-zoom-160}\n\t\\end{figure}\n\t\\restoregeometry\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\percfig/gyration-zoom-320}\n\t\\end{figure}\n\tClose to the critical probability $p_c$, the following relation holds:\n\t\\begin{equation}\n\t\t\\xi \\sim \\abs{p - p_c}^{-\\nu}\n\t\\end{equation}\n\t$\\nu$ is called the \\emph{critical exponent} for the correlation length $\\xi$. In finite lattices, because\n\tthe correlation length is bounded by the lattice length, this relation breaks down at probabilites very\n\tclose to $p_c$. We can find the valuse of $\\nu$ with two methods: direct calculation from finite lattices\n\tor extrapolation.\n\n\tIn direct calculation, we can use linear regression for the relation\n\t\\begin{equation}\n\t\t\\log{\\xi} = -\\nu\\log(p - p_c) + C.\n\t\\end{equation}\n\tThis is not especially accurate, because it is based on limited lattices that do not accurately represent unbounded\n\ttrends; The edges of these lattices cut off emerging clusters.\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\percfig/critical-exp}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\percfig/extrapolation}\n\t\\end{figure}\n\n\tThe extrapolation method is as follows. in finite lattices, the maximum correlation length is proportional to the\n\tlattice size, since the correlation length at $p_c$ is unbounded for infinite lattices, and is only bounded by the\n\tedges of the lattice in finite lattices. So, we can approximate the behavior of an infinite lattice by the relation\n\t\\begin{equation}\n\t\t\\abs{p_c(\\infty) - p_c(L)}^{-\\nu} = L,\n\t\\end{equation}\n\twhere $p_c(\\infty)$ is the infinite lattice's critical probablity and $L$ is the size of a finite lattice.\n\tExtrapolating $p_c(\\infty)$ and $\\nu$ with a non-linear curve fit, we get\n\t\\begin{equation}\n\t\tp_c(\\infty) = 0.5925 ,\\qquad \\nu = 1.346.\n\t\\end{equation}\n\tIt can be proved that the exact value of $\\nu$ is $4/3$ and larges simulations have shown that $p_c(\\infty)$ for\n\tsite percolation is $0.5927$, so the accuracy of the extrapolated values are quite good, considering the limited\n\tsample size.\n\t\n\t\\subsection{Fractal Dimension}\n\tThe percolation clusters exhibit fractal self-similar behavior. Using a simple depth-frist search algorithm,\n\twe can generate clusters in a lattice and calculate their size and radius of gyration to find their\n\tfractal dimension; If $s$ is the size of the cluster and $d_f$ is the fractal dimension\n\t\\begin{equation}\n\t\ts \\sim \\xi^{d_f},\n\t\\end{equation}\n\tso, by using linear regression for the relation\n\t\\begin{equation}\n\t\t\\log{s} = d_f\\log{\\xi} + C\n\t\\end{equation}\n\twe can calculate the fractal dimension $d_f$.\n\t\\newgeometry{top=0.5in, bottom=1.5in, left=0in, right=0in}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/fractal-vis-50}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.45\\linewidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=\\linewidth]{\\percfig/fractal-vis-65}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\t\\restoregeometry\n\t\\newgeometry{top=1in, bottom=1.5in}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\percfig/fractal-vis-55}\n\t\\end{figure}\n\t\\restoregeometry\n\t\\newgeometry{top=0.3in, bottom=0.3in, left=0in, right=0in}\n\t\\thispagestyle{empty}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\linewidth]{\\percfig/fractal-vis-59}\n\t\\end{figure}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\linewidth]{\\percfig/fractal-50}\n\t\\end{figure}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{\\percfig/fractal-55}\n\t\\end{figure}\n\t\\thispagestyle{empty}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\linewidth]{\\percfig/fractal-59}\n\t\\end{figure}\n\t\\restoregeometry\n\t\\section{1D Random Walk}\n\t\\subsection{Variance}\n\tWe can use the recurrence relation\n\t\\begin{equation}\n\t\tx(t) = x(t-\\tau) + al,\n\t\\end{equation}\n\twhere $a$ is $+1$ with probability $p$ and $-1$ with probability $q$, to find the variance.\n\tThe calculation is as follows:\n\t\\begin{align}\n\t\t\\expval{x^2(t)} &= \\expval{x^2(t-\\tau)} + 2l\\expval{ax(t-\\tau)} + \\expval{a^2}l^2 \\\\\n\t\t&= \\expval{x^2(t-\\tau)} + l^2 + 2l(p - q)\\expval{x(t-\\tau)} \\\\\n\t\t&= \\expval{x^2(t-\\tau)} + l^2 + 2l^2\\qty(\\frac{t}{\\tau}-1)(p - q)^2\n\t\\end{align}\n\t(Note that $a^2$ is always $1$, and since $a$ is dependant from $x$, $\\expval{ax} = \\expval{a}\\expval{x}$.\n\tAlso, I used $\\expval{x(t)} = \\frac{l}{\\tau}(p-q)t$, which has already been proven in the lecture notes) \\\\\n\tRepeating the recurrence relation until it reaches $x(0) = 0$\n\t\\begin{align}\n\t\t\\expval{x^2(t)} &= \\frac{tl^2}{\\tau} + \\frac{2l^2}{\\tau}(p - q)^2 \\sum_{n=1}^{t/\\tau - 1} n\\tau \\\\\n\t\t&= \\frac{tl^2}{\\tau}\\qty[1 + \\qty(\\frac{t}{\\tau} - 1)(p - q)^2].\n\t\\end{align}\n\tSubstituting into the variance,\n\t\\begin{align}\n\t\t\\sigma^2(t) &= \\expval{x^2(t)} - \\expval{x(t)}^2 \\\\\n\t\t&= \\frac{tl^2}{\\tau}\\qty[1 + \\qty(\\frac{t}{\\tau} - 1)(p - q)^2] - \\frac{t^2l^2}{\\tau^2}(p-q)^2 \\\\\n\t\t&= \\frac{tl^2}{\\tau}\\qty[1 - (p - q)^2].\n\t\\end{align}\n\tBut\n\t\\begin{equation}\n\t\tp+q = 1 \\implies (p+q)^2 = 1 \\implies p^2 + q^2 = 1 - 2pq,\n\t\\end{equation}\n\tand using this to simplify the expression\n\t\\begin{equation}\n\t\t\\sigma^2(t) = \\frac{tl^2}{\\tau}\\qty[1 - (p^2 + q^2) + 2pq] = \\frac{tl^2}{\\tau}\\qty[1 - 1 + 2pq + 2pq]\n\t\\end{equation}\n\t\\begin{empheq}[box=\\fbox]{equation}\n\t\t\\sigma^2(t) = \\frac{4l^2}{\\tau}pqt\n\t\\end{empheq}\n\t\\subsection{Simulation}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-50}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-60}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-70}\n\t\\end{figure}\n\t\\begin{figure}\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-80}\n\t\\end{figure}\n\t\\FloatBarrier\n\t\\subsection{Trapping (Absorbing) Boundary}\n\tIn the following figures, $L$ is the length of the \\enquote{path} i.e. the number of cells in the 1D grid.\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-trap-sim}\n\t\t\\caption{Averaged over 100000 walks}\n\t\\end{figure}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-trap-exp}\n\t\t\\caption{Calculated up to $t=100L$ where $t$ is the number of steps}\n\t\\end{figure}\n\t\\begin{figure}[htb!]\n\t\t\\centering\n\t\t\\includegraphics[width=\\linewidth]{\\rwfig/randomwalk-trap}\n\t\t\\caption{As you can see, the expected lifetime is nearly equal to the average lifetime in the simulations}\n\t\\end{figure}\n\\end{document}\n", "meta": {"hexsha": "a99dbd55c0fbf21cd9cfca01adccd6c7f685a773", "size": 9538, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ps4-percolation-random-walk/report/ps4-percolation-random-walk.tex", "max_stars_repo_name": "slhshamloo/comp-phys", "max_stars_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ps4-percolation-random-walk/report/ps4-percolation-random-walk.tex", "max_issues_repo_name": "slhshamloo/comp-phys", "max_issues_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ps4-percolation-random-walk/report/ps4-percolation-random-walk.tex", "max_forks_repo_name": "slhshamloo/comp-phys", "max_forks_repo_head_hexsha": "04d6759e0eb9d7e16e2781417d389bc15e22b01b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0, "max_line_length": 162, "alphanum_fraction": 0.7189138184, "num_tokens": 3290, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.409661470486359}}
{"text": "% ===> this file was generated automatically by noweave --- better not edit it\n\\section{Introduction}\n\nAs a convenience to users, we provide a mechanism for declaring\nnested coordinate systems.  This is particularly useful\nfor creating \\emph{substructures} or \\emph{subnets}.  Different\ninstances of a subnet may have the same relative placements\nof nodes, but at different translations and orientations.\n\n\n\\section{Interface}\n\nWe support nested coordinate systems via a \\emph{transformation stack}.\nThe entries in this stack data structures are all affine transformations that\ntake the current coordinate system to the global system.  New transformations\nare \\emph{composed} with the previous top-of-stack, so that if\n$T_0$ is the current transformation to global coordinates and a\ntransformation $S$ is pushed onto the stack, then $T_0 S$ will\nbe the new transformation from current to global coordinates.\n\nThe transformation $T = Ax + b$ is given by a table of twelve entries \nwhich represents the components of the matrix $[A; b]$ in column major \norder.  A vector $x$ is given by a table with coordinate entries at\nindices 1 to 3.  Note that the table can contain additional information\n(e.g. a node name).  Part of the reason the transformation functions\noverwrite the input vector table is so that entries besides those\nat indices 1 to 3 can be retained unchanged.\n\nThe functions provided by this module are\n\\begin{itemize}\n  \\item {\\Tt{}xform{\\_}push(T)\\nwendquote}: compose a transformation onto the stack\n  \\item {\\Tt{}xform{\\_}pop\\nwendquote}: pop a level off the transformation stack\n  \\item {\\Tt{}top{\\_}xform(x)\\nwendquote}: overwrite $x$ with $T_\\mathit{top} x$,\n        where $T_\\mathit{top}$ is the top transform on the stack\n  \\item {\\Tt{}xform{\\_}apply(T,\\ x)\\nwendquote}: overwrite $x$ with $Tx$.\n  \\item {\\Tt{}xform{\\_}applyA(t,\\ x)\\nwendquote}: overwrite $x$ with $A_T x$,\n        where $A_T$ is the linear part of the affine transform $T$.\n  \\item {\\Tt{}xform{\\_}compose(T,\\ S)\\nwendquote}: return $TS$\n  \\item {\\Tt{}xform{\\_}identity\\nwendquote}: return the identity transform\n  \\item {\\Tt{}xform{\\_}ox(r),\\ xform{\\_}oy(r),\\ xform{\\_}oz(r)\\nwendquote}:\n        return right-handed rotations about the coordinate axes\n  \\item {\\Tt{}xform{\\_}translate(z)\\nwendquote}: return a translation by the\n        vector $z$\n  \\item {\\Tt{}subnet(f)\\nwendquote}: return a function which creates a nested\n        coordinate system according to any {\\Tt{}ox\\nwendquote}, {\\Tt{}oy\\nwendquote},\n        and {\\Tt{}oz\\nwendquote} parameters, calls {\\Tt{}f\\nwendquote}, and then pops the\n        nested coordinate system.\n\\end{itemize}\n\n\n\\section{Implementation}\n\n\\nwfilename{xformstack.nw}\\nwbegincode{1}\\sublabel{NW4ZsHyK-4TVv9z-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-4TVv9z-1}}}\\moddef{xformstack.lua~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-4TVv9z-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\n\\LA{}data~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-3zsvuH-1}}\\RA{}\n\\LA{}functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}\\RA{}\n\\nwnotused{xformstack.lua}\\nwendcode{}\\nwbegindocs{2}\\nwdocspar\n\n\\subsection{The transform stack}\n\nThe size of the stack is maintained in the field $n$.\n\n\\nwenddocs{}\\nwbegincode{3}\\sublabel{NW4ZsHyK-3zsvuH-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-3zsvuH-1}}}\\moddef{data~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-3zsvuH-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwenddeflinemarkup\nxform_stack = \\{n = 0\\};\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{4}\\nwdocspar\n\nNote that we compose new transformations onto the stack, interpreting\nthe transformation argument as a transformation into the current coordinates\ninstead of a transformation into the global coordinates.\n\n\\nwenddocs{}\\nwbegincode{5}\\sublabel{NW4ZsHyK-nRuDO-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{\\relax}{NW4ZsHyK-nRuDO-2}\\nwenddeflinemarkup\nfunction xform_push(T)\n  local n = xform_stack.n + 1\n  if n == 1 then\n    xform_stack[n] = T\n  else\n    xform_stack[n] = xform_compose(xform_stack[n-1], T);\n  end\n  xform_stack.n = n;\nend\n\n\\nwalsodefined{\\\\{NW4ZsHyK-nRuDO-2}\\\\{NW4ZsHyK-nRuDO-3}\\\\{NW4ZsHyK-nRuDO-4}\\\\{NW4ZsHyK-nRuDO-5}\\\\{NW4ZsHyK-nRuDO-6}\\\\{NW4ZsHyK-nRuDO-7}\\\\{NW4ZsHyK-nRuDO-8}\\\\{NW4ZsHyK-nRuDO-9}\\\\{NW4ZsHyK-nRuDO-A}\\\\{NW4ZsHyK-nRuDO-B}\\\\{NW4ZsHyK-nRuDO-C}}\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{6}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{7}\\sublabel{NW4ZsHyK-nRuDO-2}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-2}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-1}{NW4ZsHyK-nRuDO-3}\\nwenddeflinemarkup\nfunction xform_pop()\n  xform_stack.n = xform_stack.n - 1\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{8}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{9}\\sublabel{NW4ZsHyK-nRuDO-3}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-3}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-2}{NW4ZsHyK-nRuDO-4}\\nwenddeflinemarkup\nfunction top_xform(x)\n  local n = xform_stack.n\n  if n > 0 then\n    return xform_apply(xform_stack[n], x)\n  else\n    return x\n  end\nend \n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{10}\\nwdocspar\n\n\\subsection{Transformation functions}\n\n\\nwenddocs{}\\nwbegincode{11}\\sublabel{NW4ZsHyK-nRuDO-4}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-4}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-3}{NW4ZsHyK-nRuDO-5}\\nwenddeflinemarkup\n-- Overwrite x with Tx\nfunction xform_apply(T, x)\n  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3] + T[10];\n  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3] + T[11];\n  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3] + T[12];\n  x[1] = y1;\n  x[2] = y2;\n  x[3] = y3;\n  return x;\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{12}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{13}\\sublabel{NW4ZsHyK-nRuDO-5}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-5}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-4}{NW4ZsHyK-nRuDO-6}\\nwenddeflinemarkup\n-- Overwrite x with A_T * x\nfunction xform_applyA(T, x)\n  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3]; \n  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3]; \n  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3];\n  x[1] = y1;\n  x[2] = y2;\n  x[3] = y3;\n  return x;\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{14}\\nwdocspar\n\nRecall that \n\\[\n  T(S(x)) = A_T (A_S x + b_S) + b_T = (A_T A_S) x + T(b_T)\n\\]\n\n\\nwenddocs{}\\nwbegincode{15}\\sublabel{NW4ZsHyK-nRuDO-6}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-6}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-5}{NW4ZsHyK-nRuDO-7}\\nwenddeflinemarkup\n-- Return TS\nfunction xform_compose(T, S)\n  local TS = \\{\\};\n  for k = 1,4 do\n    local base = 3*k-3;\n    TS[base+1] = T[1]*S[base+1] + T[4]*S[base+2] + T[7]*S[base+3];\n    TS[base+2] = T[2]*S[base+1] + T[5]*S[base+2] + T[8]*S[base+3];\n    TS[base+3] = T[3]*S[base+1] + T[6]*S[base+2] + T[9]*S[base+3];\n  end\n  TS[10] = TS[10] + T[10];\n  TS[11] = TS[11] + T[11];\n  TS[12] = TS[12] + T[12];\n  return TS;\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{16}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{17}\\sublabel{NW4ZsHyK-nRuDO-7}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-7}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-6}{NW4ZsHyK-nRuDO-8}\\nwenddeflinemarkup\n-- Return the identity\nfunction xform_identity()\n  return \\{ 1, 0, 0,\n           0, 1, 0,\n           0, 0, 1,\n           0, 0, 0 \\};\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{18}\\nwdocspar\n\nGetting right hand rotations correct is always a trick.\nImportant note -- remember that the transformation matrix is\ninterpreted as column-major, but is ``typographically'' row\nmajor.  So put on your transposing hat before reading the\nfollowing three functions.\n\n\\nwenddocs{}\\nwbegincode{19}\\sublabel{NW4ZsHyK-nRuDO-8}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-8}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-7}{NW4ZsHyK-nRuDO-9}\\nwenddeflinemarkup\n-- Return a rotation about the x axis\nfunction xform_ox(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ 1,   0,  0,\n           0,   c,  s,\n           0,  -s,  c,\n           0,   0,  0 \\}\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{20}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{21}\\sublabel{NW4ZsHyK-nRuDO-9}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-9}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-8}{NW4ZsHyK-nRuDO-A}\\nwenddeflinemarkup\n-- Return a rotation about the y axis\nfunction xform_oy(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ c,   0, -s,\n           0,   1,  0,\n           s,   0,  c,\n           0,   0,  0 \\}\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{22}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{23}\\sublabel{NW4ZsHyK-nRuDO-A}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-A}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-9}{NW4ZsHyK-nRuDO-B}\\nwenddeflinemarkup\n-- Return a rotation about the z axis\nfunction xform_oz(r)\n  local c = cos(r)\n  local s = sin(r)\n  return \\{ c,   s,  0,\n          -s,   c,  0,\n           0,   0,  1,\n           0,   0,  0 \\}\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{24}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{25}\\sublabel{NW4ZsHyK-nRuDO-B}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-B}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-A}{NW4ZsHyK-nRuDO-C}\\nwenddeflinemarkup\n-- Return a translation \nfunction xform_translate(z)\n  return \\{ 1,    0,    0,\n           0,    1,    0,\n           0,    0,    1,\n           z[1], z[2], z[3] \\}\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{26}\\nwdocspar\n\n\n\\subsection{{\\Tt{}node\\nwendquote} and {\\Tt{}subnetize\\nwendquote} functions}\n\nWe assume that node positions are expressed in the current coordinate\nsystem (at least, that's what we assume for most purposes).\nSo the {\\Tt{}nodex\\nwendquote} (``node transformed'') function transforms\nthe input coordinates from local to global, and them makes a node.\n\nWe still want to leave the option of expressing node coordinates\ndirectly in the global coordinate system, though.  For instance,\nwe may want to put a node halfway between two other nodes which\nhave already been transformed into global coordinates.  For this\nreason, we leave the {\\Tt{}node\\nwendquote} function alone.\n\n\\nwenddocs{}\\nwbegincode{27}\\sublabel{NW4ZsHyK-nRuDO-C}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-C}}}\\moddef{functions~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-nRuDO-1}}}\\plusendmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwprevnextdefs{NW4ZsHyK-nRuDO-B}{\\relax}\\nwenddeflinemarkup\nfunction nodex(p)\n  if p[1] then\n    top_xform(p)\n  end\n  return node(p)\nend\n\n\\nwused{\\\\{NW4ZsHyK-4TVv9z-1}}\\nwendcode{}\\nwbegindocs{28}\\nwdocspar\n\n\n\n\\subsection{Test code}\n\n\\nwenddocs{}\\nwbegincode{29}\\sublabel{NW4ZsHyK-pcrvx-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-pcrvx-1}}}\\moddef{xformtst.lua~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-pcrvx-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwenddeflinemarkup\nuse(\"xformstack.lua\")\n\n\\LA{}test transform constructors~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-1zasbh-1}}\\RA{}\n\\LA{}test composition~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-2X3VkV-1}}\\RA{}\n\\nwnotused{xformtst.lua}\\nwendcode{}\\nwbegindocs{30}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{31}\\sublabel{NW4ZsHyK-1zasbh-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-1zasbh-1}}}\\moddef{test transform constructors~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-1zasbh-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-pcrvx-1}}\\nwenddeflinemarkup\n-- First check out the basics\n\nrx45 = xform_ox(45)\nry45 = xform_oy(45)\nrz45 = xform_oz(45)\ntrans = xform_translate \\{1, 2, 3\\}\n\nx1 = xform_apply(rx45,  \\{1, 0, 0\\})\nx2 = xform_apply(ry45,  \\{1, 0, 0\\})\nx3 = xform_apply(rz45,  \\{1, 0, 0\\})\nx4 = xform_apply(trans, \\{1, 0, 0\\})\nx5 = xform_applyA(trans, \\{1, 0, 0\\})\n\nprint(\"Rotate e1 by rx45: \",     x1[1], x1[2], x1[3])\nprint(\"Rotate e1 by ry45: \",     x2[1], x2[2], x2[3])\nprint(\"Rotate e1 by rz45: \",     x3[1], x3[2], x3[3])\nprint(\"Translate e1 by 1,2,3: \", x4[1], x4[2], x4[3])\nprint(\"Apply A e1 by 1,2,3: \",   x5[1], x5[2], x5[3])\n\n\\nwused{\\\\{NW4ZsHyK-pcrvx-1}}\\nwendcode{}\\nwbegindocs{32}\\nwdocspar\n\n\\nwenddocs{}\\nwbegincode{33}\\sublabel{NW4ZsHyK-2X3VkV-1}\\nwmargintag{{\\nwtagstyle{}\\subpageref{NW4ZsHyK-2X3VkV-1}}}\\moddef{test composition~{\\nwtagstyle{}\\subpageref{NW4ZsHyK-2X3VkV-1}}}\\endmoddef\\nwstartdeflinemarkup\\nwusesondefline{\\\\{NW4ZsHyK-pcrvx-1}}\\nwenddeflinemarkup\n-- Now check out composition\n\nT = xform_compose(trans, rz45)\nx = xform_apply(T, \\{1, 0, 0\\})\n\nprint(\"Rotate then translate: \", x[1], x[2], x[3])\n\nundoT = xform_compose(xform_oz(-45), xform_translate\\{-1,-2,-3\\})\nxform_apply(undoT, x)\n\nprint(\"After undo operation: \", x[1], x[2], x[3])\n\n\\nwused{\\\\{NW4ZsHyK-pcrvx-1}}\\nwendcode{}\n\n\\nwixlogsorted{c}{{data}{NW4ZsHyK-3zsvuH-1}{\\nwixu{NW4ZsHyK-4TVv9z-1}\\nwixd{NW4ZsHyK-3zsvuH-1}}}%\n\\nwixlogsorted{c}{{functions}{NW4ZsHyK-nRuDO-1}{\\nwixu{NW4ZsHyK-4TVv9z-1}\\nwixd{NW4ZsHyK-nRuDO-1}\\nwixd{NW4ZsHyK-nRuDO-2}\\nwixd{NW4ZsHyK-nRuDO-3}\\nwixd{NW4ZsHyK-nRuDO-4}\\nwixd{NW4ZsHyK-nRuDO-5}\\nwixd{NW4ZsHyK-nRuDO-6}\\nwixd{NW4ZsHyK-nRuDO-7}\\nwixd{NW4ZsHyK-nRuDO-8}\\nwixd{NW4ZsHyK-nRuDO-9}\\nwixd{NW4ZsHyK-nRuDO-A}\\nwixd{NW4ZsHyK-nRuDO-B}\\nwixd{NW4ZsHyK-nRuDO-C}}}%\n\\nwixlogsorted{c}{{test composition}{NW4ZsHyK-2X3VkV-1}{\\nwixu{NW4ZsHyK-pcrvx-1}\\nwixd{NW4ZsHyK-2X3VkV-1}}}%\n\\nwixlogsorted{c}{{test transform constructors}{NW4ZsHyK-1zasbh-1}{\\nwixu{NW4ZsHyK-pcrvx-1}\\nwixd{NW4ZsHyK-1zasbh-1}}}%\n\\nwixlogsorted{c}{{xformstack.lua}{NW4ZsHyK-4TVv9z-1}{\\nwixd{NW4ZsHyK-4TVv9z-1}}}%\n\\nwixlogsorted{c}{{xformtst.lua}{NW4ZsHyK-pcrvx-1}{\\nwixd{NW4ZsHyK-pcrvx-1}}}%\n\\nwbegindocs{34}\\nwdocspar\n\n\\nwenddocs{}\n", "meta": {"hexsha": "ab76eca039636505807cec14a6d62deec97b405b", "size": 14955, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sugar31/src/tex/xformstack.tex", "max_stars_repo_name": "davidgarmire/sugar", "max_stars_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sugar31/src/tex/xformstack.tex", "max_issues_repo_name": "davidgarmire/sugar", "max_issues_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sugar31/src/tex/xformstack.tex", "max_forks_repo_name": "davidgarmire/sugar", "max_forks_repo_head_hexsha": "699534852cb37fd2225a8b4b0072ebca96504d23", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.1940789474, "max_line_length": 364, "alphanum_fraction": 0.7210297559, "num_tokens": 6306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.4095849288768239}}
{"text": "\\XtoCBlock{Int2Real}\r\n\\label{block:Int2Real}\r\n\\begin{figure}[H]\\includegraphics{Int2Real}\\end{figure} \r\n\r\n\\begin{XtoCtabular}{Inports}\r\nIn & Integer input\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\r\n\\begin{XtoCtabular}{Outports}\r\nOut & Real output\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\begin{XtoCtabular}{Mask Parameters}\r\nScale & Scaling factor from integer to real\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n\\subsubsection*{Description:}\r\nConversion block from integer (fixed point) datatypes to real (floating point) datatypes.\n\n  Out = In * Scale \r\n\n% include optional documentation file\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Int2Real_Info.tex}{\\vspace{1ex}}{}\r\n\r\n\\subsubsection*{Implementations:}\r\n\\begin{tabular}{l l}\r\n\\textbf{FiP8\\_Float32} & 8 Bit Fixed Point to 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{FiP16\\_Float32} & 16 Bit Fixed Point to 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{FiP32\\_Float32} & 32 Bit Fixed Point to 32 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{FiP8\\_Float64} & 8 Bit Fixed Point to 64 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{FiP16\\_Float64} & 16 Bit Fixed Point to 64 Bit Floating Point Implementation\\tabularnewline\r\n\\textbf{FiP32\\_Float64} & 32 Bit Fixed Point to 64 Bit Floating Point Implementation\\tabularnewline\r\n\\end{tabular}\r\n\r\n\\XtoCImplementation{FiP8\\_Float32}\r\n\\index{Block ID!192}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8\\_Float32 \\tabularnewline\r\n\\textbf{ID} & 192 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP8\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP8\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point to 32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     float32       Out;\r\n     float32       scale;\r\n} INT2REAL_FIP8_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP8_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16\\_Float32}\r\n\\index{Block ID!193}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16\\_Float32 \\tabularnewline\r\n\\textbf{ID} & 193 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP16\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP16\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point to 32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     float32       Out;\r\n     float32       scale;\r\n} INT2REAL_FIP16_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP16_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32\\_Float32}\r\n\\index{Block ID!194}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32\\_Float32 \\tabularnewline\r\n\\textbf{ID} & 194 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP32\\_Float32.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP32\\_Float32.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point to 32 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     float32       Out;\r\n     float32       scale;\r\n} INT2REAL_FIP32_FLOAT32;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP32_Float32.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP8\\_Float64}\r\n\\index{Block ID!195}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP8\\_Float64 \\tabularnewline\r\n\\textbf{ID} & 195 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP8\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP8\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n8 Bit Fixed Point to 64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int8          *In;\r\n     float64       Out;\r\n     float64       scale;\r\n} INT2REAL_FIP8_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP8_Float64.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP16\\_Float64}\r\n\\index{Block ID!196}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP16\\_Float64 \\tabularnewline\r\n\\textbf{ID} & 196 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP16\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP16\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n16 Bit Fixed Point to 64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int16         *In;\r\n     float64       Out;\r\n     float64       scale;\r\n} INT2REAL_FIP16_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP16_Float64.tex}{}{}\r\n\\fi\r\n\\XtoCImplementation{FiP32\\_Float64}\r\n\\index{Block ID!197}\r\n\\nopagebreak[0]\r\n% Implementation details\r\n\\begin{tabular}{l l}\r\n\\textbf{Name} & FiP32\\_Float64 \\tabularnewline\r\n\\textbf{ID} & 197 \\tabularnewline\r\n\\textbf{Revision} & 0.1 \\tabularnewline\r\n\\textbf{C filename} & Int2Real\\_FiP32\\_Float64.c \\tabularnewline\r\n\\textbf{H filename} & Int2Real\\_FiP32\\_Float64.h \\tabularnewline\r\n\\end{tabular}\r\n\\vspace{1ex}\r\n\r\n32 Bit Fixed Point to 64 Bit Floating Point Implementation\r\n\r\n\\begin{XtoCtabular}{Controller Parameters}\r\nscale & Scaling factor\\tabularnewline\r\n\\hline\r\n\\end{XtoCtabular}\r\n\r\n% Implementation data structure\r\n\\XtoCDataStruct{Data Structure:}\r\n\\begin{lstlisting}\r\ntypedef struct {\r\n     uint16        ID;\r\n     int32         *In;\r\n     float64       Out;\r\n     float64       scale;\r\n} INT2REAL_FIP32_FLOAT64;\r\n\\end{lstlisting}\r\n\r\n\\ifdefined \\AddTestReports\r\n\\InputIfFileExists{\\XcHomePath/Library/General/Doc/Test_Int2Real_FiP32_Float64.tex}{}{}\r\n\\fi\r\n", "meta": {"hexsha": "921712a63d379aef9e072a4383eb6cf18c209353", "size": 7117, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Library/General/Doc/Int2Real.tex", "max_stars_repo_name": "AlexisTM/X2C", "max_stars_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Library/General/Doc/Int2Real.tex", "max_issues_repo_name": "AlexisTM/X2C", "max_issues_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Library/General/Doc/Int2Real.tex", "max_forks_repo_name": "AlexisTM/X2C", "max_forks_repo_head_hexsha": "31f39b598afe271a7fd46ef1ee9e06c410b1120c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2880658436, "max_line_length": 100, "alphanum_fraction": 0.7350007025, "num_tokens": 2212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.409584924223436}}
{"text": "\\section*{Welcome to SnuggleTeX!}\n\n\\begin{itemize}\n  \\item This is an itemized list.\n\n  \\item This is some inline maths: $x^2+ y^2 = 1$\n\n  \\item Some block maths:\n        \\[ \\sum_{n=1}^\\infty \\frac{1}{n^2} = \\frac{\\pi^2}{6} \\]\n        (\\textbf{Note}: This currently doesn't display nicely in Firefox 3. Boo\\ldots)\n\n  \\item A $2\\times 2$ matrix created via a user-defined command:\n        \\newcommand{\\mat}[4]{\\left( \\begin{array}{cc} #1 & #2 \\\\ #3 & #4 \\end{array} \\right)}\n        \\[ A = \\mat{\\alpha}{\\beta}{\\gamma}{\\delta} \\]\n\n\\end{itemize}\n\nHere is an example of a SnuggleTeX error message. You can set it up to display the messages inline (as we have here) or report them in various other ways:\n\n\\doh\n", "meta": {"hexsha": "12306d2d099075f611097b4375bf047220f7838e", "size": 705, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "snuggletex-webapp/src/main/webapp/WEB-INF/full-latex-input-demo-default.tex", "max_stars_repo_name": "bsmith-n4/snuggletex", "max_stars_repo_head_hexsha": "f2464e26386ad70e51ee0c2b3eda544e21e7a4da", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "snuggletex-webapp/src/main/webapp/WEB-INF/full-latex-input-demo-default.tex", "max_issues_repo_name": "bsmith-n4/snuggletex", "max_issues_repo_head_hexsha": "f2464e26386ad70e51ee0c2b3eda544e21e7a4da", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "snuggletex-webapp/src/main/webapp/WEB-INF/full-latex-input-demo-default.tex", "max_forks_repo_name": "bsmith-n4/snuggletex", "max_forks_repo_head_hexsha": "f2464e26386ad70e51ee0c2b3eda544e21e7a4da", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-11T17:01:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-17T07:29:24.000Z", "avg_line_length": 33.5714285714, "max_line_length": 154, "alphanum_fraction": 0.6340425532, "num_tokens": 235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.40958491957004817}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n\\newcommand{\\Gr}{\\opname{Gr}}\n\n\n\\title{Math 217 -- Geometry and Physics -- Lec10}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{24}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{Universal vector bundles}\n\nLet's start with complex vector bundles. Recall the grassmannian\n\\begin{eqn}\n\\opname{Gr}(n,N) = \\set{V \\subseteq \\complexes^N | \\dim V = n},\n\\end{eqn}\nwhich has the property\n\\begin{eqn}\n\\begin{matrix}\n\\opname{Gr}(n,N) & \\subseteq & \\opname{Gr} (n,N+!) & \\subseteq \\dots \\\\\n(z_1, \\dots, z_N) & \\mapsto & (z_1, \\dots, z_N, 0) & \n\\end{matrix}\n\\end{eqn}\nThe ``infinite'' Grassmannian is denoted\n\\begin{eqn}\nBU(n) = \\opname{Gr}(n, \\infty)\n\\end{eqn}\nand has a universal subbundle $S \\rightarrow \\Gr(n,\\infty) = BU(n)$. Furthermore, we find that\n\\begin{align}\n\\opname{Vect}_n(M) &= \\set{ \\text{complex vector bundles on $M$} } \\\\\n\t& \\cong [M, BU(n)] = \\set{ \\text{homotopy classes of $f: M \\rightarrow BU(n)$} }.\n\\end{align}\nThen we have\n\\begin{eqn}\nH^*(BU(n), \\ints) \\cong \\ints[c_1, \\dots, c_n], \\quad \\text{where} \\quad c_i = c_i(S).\n\\end{eqn}\nWe also have \n\\begin{eqn}\nc_i(E) = f^* c_i (S) = f^* c_i.\n\\end{eqn}\n\nFor grassmannians on real vector bundles, we have the infinite grassmannian \n\\begin{eqn}\nBO(n) = \\Gr_\\reals (n, \\infty).\n\\end{eqn}\nThen\n\\begin{align}\n\\opname{Vect}_n (M) &\\cong [M, BO(n)] \\\\\nH^* (BO(n), \\irrats) &= \\irrats[p_1, \\dots, p_{\\lceil n/2 \\rceil}] \\\\\nH^*(BO(n), \\ints_2) &= \\ints[w_1, \\dots, w_n]\n\\end{align}\nwhere $P_j (E) = f^* p_j(S)$, $w_j(E) = f^* w_j(S)$, and $w_j = w_j(S)$ (Universal Stiefle-Whitney [?])\n\n[$O(n) \\rightarrow U(n)$, $BO(n) \\rightarrow BU(n)$, $H^*(BU(n), \\ints) \\rightarrow H^*(BO(n),\\ints)$, $p_j = (-1)^j c_{2j}$]\n\n\\subsection{Axioms of SW [Stiefle-Whitney?] classes} \nGiven real vector bundle $E$ over closed $M$, there exist $\\set{w_i(E)}$ in $H^*(M, \\ints_2)$ ($w_i \\in H^i(M, \\ints_2)$) such that\n\\begin{enumerate}\n\\item $w_0 = 1$,\n\\item $w_i (f^*E') = f^* w_i (E)$,\n\\item $w(E \\oplus E') = w(E) w(E')$,\n\\item $\\gamma_1$ (Universal [subdim?] bundle) $\\rightarrow \\RP^1$, where $w_1(\\gamma_1)$ the generator of $H^1(\\RP^1, \\ints_2)$.\n\\end{enumerate}\n\n\n\\subsubsection{stuff}\n\n[missed some stuff here]\n\nso we have \n\\begin{eqn}\nc_j = \\sigma_j(x_1, \\dots, x_n)\n\\end{eqn}\n\n\n\\subsubsection{stuff}\n\n[missed bit more here]\n\n\n\\subsection{Axioms for Chern classes}\n\nGiven complex vector bundle $E^n \\rightarrow M$,\n\\begin{enumerate}\n\\item $c_0(E) = 1$, $c_j(E) = 0$ for $j > n$.\n\\item $f^* c_j(E') = c_j (f^* E')$,\n\\item $c(E \\oplus E') = c(E) c(E')$,\n\\item $\\bigO(-1) = L \\rightarrow \\CP^\\infty$ and $c_1(L) = x$ is generator of $H^*(\\CP^\\infty, \\ints)$.\n\\end{enumerate}\n\nWe can write\n\\begin{eqn}\ni \\partial \\bar\\partial \\log(1 + \\abs{z}^2) = c_1 (\\bigO(-1)),\n\\end{eqn}\nwhere $\\bigO(-1) \\rightarrow \\CP^1$ (exercise). We find that\n\\begin{eqn}\n\\int_{\\CP^1} c_1 \\bigO(-1) = \\int_{z \\in \\complexes} i \\partial \\bar\\partial \\log(1 + \\abs{z}^2) = \\pm 1.\n\\end{eqn}\nWe have $\\pi^* c_j(E) = \\sigma_j (x_1, \\dots, x_n)$, where $x_j = c_1(L_j)$, where\n\\begin{eqn}\n\\pi^* : H^*(M) \\hookrightarrow H^*(F(E)).\n\\end{eqn}\nSo we have\n\\begin{eqn}\n\\CP^{n-1} \\hookrightarrow P(E) \\overset{\\pi}{\\rightarrow} M\n\\end{eqn}\nLet $t = -c_1(L)$, and note that \n\\begin{eqn}\n\\pi^* E \\cong \\underbrace{L}_{\\bigO(-1)} \\oplus \\underbrace{Q}_\\text{quotient bundle}.\n\\end{eqn}\nWriting out our expansion\n\\begin{eqn}\nc_t = \\det (tI + \\frac{i}{2\\pi} \\Omega) = t^n + c_1 t^{n-1} + \\dots + c_n,\n\\end{eqn}\nsince we have\n\\begin{eqn}\nc_t(\\pi^* E) = \\underbrace{c_t(L)}_{=0} c_t(Q),\n\\end{eqn}\nso that\n\\begin{eqn}\n0 = t^n + \\pi^* c_1(E) t^{n-1} + \\dots + \\pi^* c_n(E).\n\\end{eqn}\nSo we've found \\textit{Grothendieck's characterization of Chern classes},\n\\begin{eqn}\nH^*(P(E), \\irrats) = H^*(M) [x_E] \\Big/ \\set{x_E^n + \\pi^* c_1(E) x_E^{n-1} + \\dots + \\pi^* c_n(E) = 0}.\n\\end{eqn}\n\nThe most useful characteristic classes is probably Hirzebruch's:\n\n1. $L$-classes, $TM \\rightarrow M^{2n}$. We have\n\\begin{eqn}\nL(TM) = \\prod_{j=1}^n \\frac{x_j}{\\tanh x_j} = \\text{a symmetric function in $\\set{x_j^2}$}\n\\end{eqn}\nAs an exercise, for $n=2$, can show\n\\begin{eqn}\nL(TM)^\\text{top} = \\frac{x_1}{\\tanh x_1} \\frac{x_2}{\\tanh x_2} = \\frac{1}{3} P_1 (TM).\n\\end{eqn}\nThen $\\hat{A} (TM^4) = -\\frac{1}{24} P_1 (TM)$ \n\n2. The $\\hat{A}$-classes are given by\n\\begin{eqn}\n\\hat{A} (TM) = \\prod_{j=1}^n \\frac{x_j / 2}{\\sinh (x_j/2} = f(p_1, \\dots, p_n)\n\\end{eqn}\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "f9f5d15bf538fba35673a3c77a85fd2193b3e42f", "size": 4693, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geometry/lec10.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "geometry/lec10.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geometry/lec10.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5157232704, "max_line_length": 131, "alphanum_fraction": 0.623907948, "num_tokens": 1963, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526660244838, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.40949292696251777}}
{"text": "%&LaTeX\n\n\\section{The Matlab Lab, or How to Not Teach a Programming Language}\n\nLabs in this class will make liberal use of the Matlab numerical\nprogramming environment. Because this class assumes that you are an\nexperienced computer science student, you are expected to be able to\nlearn how to use computer tools, and how to program in new programming\nlanguages, pretty much on your own. So, the first thing you should do\nis check out the Matlab documentation built into the Matlab help\nsystem, or online at\n\\url{http://www.mathworks.com/help/matlab/index.html}. Of course, you\ncan always search online for Matlab tutorials and the like. We'll\ninclude a very brief overview of Matlab below, and then more detailed\ninformation about the code developed specifically for this class that\nyou will be using.\n\n\\subsection{Matlab in a (Very Small) Nutshell}\n\\label{sc:basic-matlab}\n\nThe Matlab GUI environment is very similar to IDEs that you are\nalready familiar with. As you might expect, there are some\nidiosyncrasies here and there, but nothing terribly unexpected. The\nmajor areas of difference are tools and panes that have to do with\nviewing variables (something in other IDEs that you'd only see when\ndebugging a program), the command pane, and figure windows that open\nto display graphs. The first two of these differences have to do with\nthe fact that Matlab is an interpreted language/programming\nenvironment. You primary area of interaction with the Matlab\ninterpreter will be through the command window, with variable\ninformation panes providing views of variables and their contents\nrelated to your interaction. It's interesting to note that, if you\nwant, you can run Matlab without the GUI, providing just a command\nline interface.\n\nInterpreted languages have their advantages and disadvantages.  One\nadvantage is that anything you can use as a line of code in a program\nyou can use immediately as a command on the command line. This lets\nyou test code interactively and then copy it into the script or\nfunction you're writing. Like any IDE, Matlab includes an editor with\nsyntax highlighting and debugger integration.\n\nThe disadvantage is the interpreted programs are slower. In Matlab, we\nget around this by using built-in functions that operate on entire\nvectors or arrays as single data objects. The core loops of the\nbuilt-in functions are compiled for speed. If you make good use of\nthose functions, Matlab code can often be as fast as completely\ncompiled code.\n\nHere are some things to try:\n\\begin{enumerate}\n\\item Immediate calculations and variables:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nradius = 5    % Comments start with \"%\"\ncircumference = 2 * pi * radius\narea = pi * radius^2\n\\end{lstlisting}\n\\item Complex numbers:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nsqrt(-1)\nx = 7 + 14j\nconj(x)       % complex conjugate\nabs(x)        % magnitude (e.g., for polar representation)\nangle(x)      % and angle for polar rep\nreal(x)\nimag(x)\n\\end{lstlisting}\n\n\\item Complex exponentials:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nexp(j * pi)\nexp(j * pi/2)\nexp(j * pi/4)\n\\end{lstlisting}\n\n\\item Vectors:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nv1 = [0 1 2 3]    % Four elements\nv2 = [0 : 2 : 10] % like a loop (start value : increment : end value)\nv3 = pi * [-0.5 -0.25 0 0.25 0.5] % All operations are vectorized\nexp(j * v3)\nmistake = v1 * v1     % a mistake; vector mult doesn't work this way\ndotproduct = v1 * v1' % transposing will work, if you want to do this\narrayprod = v1 .* v1  % element-by-element ops include: .+, .-, .*, ./\n\\end{lstlisting}\n\n\\item Simple plots (note that ``;'' suppresses outputting results to\n  the command window --- useful if that would generate massive amounts\n  of text, or just if you want things neat):\n\\label{it:simple-plots}\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nt = [0 : 0.01 : 2*pi];\nx = sin(t);\nplot(t, x);       % default plots points connected by lines in blue\nplot(t, x, 'r');  % change the line color\nplot(t, x, 'r.'); % change the plot style; zoom in to see individual points\nxlabel('t, ms');  % X axis label (all of your plots should have this)\nylabel('Mag');    % Y axis label (all of your plots should have this)\ntitle('Triangle');% Graph title (all of your plots should have this)\n\\end{lstlisting}\n\n\\end{enumerate}\n\nIf you take a sequence of commands and save them in a file with an\nextension of \\texttt{.m}, the result is a \\emph{script}. Assuming that the\nscript is saved in a directory in the MATLAB search path, you can then\nexecute the script by just typing its name (without the \\texttt{.m}),\njust as if it were a command. If you want your code to take\nparameters, return a return value, and have local variables, start\nyour code with a line like:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nfunction retval = funcname(parm1, parm2)\n\\end{lstlisting}\n\nYour code is now a function. MATLAB functions can take variable\nnumbers of arguments and even return variable numbers of return\nvalues, but that's getting beyond what we need right now.\n\n\\paragraph{Step 1.1} It's easy to create, concatenate, extract, and modify\nvectors or parts of vectors. Execute the following lines of Matlab\ncode and explain what each echoes out: \n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\na = ones(1,3)\nb = zeros(1,5)\nx = [b, a, [1:2:12]]\nx(7:end)\nlength(x)\nx(1:2:12)\n\\end{lstlisting}\n\nAlso, explain the difference between the square bracket notation\n\\verb|[1:2:12]| and the parenthetical notation \\verb|(1:2:12)|.\n\n\\paragraph{Step 1.2} Consider the result of the following assignment:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nx(7:11) = pi*(1:5)\n\\end{lstlisting}\n\nWrite a \\emph{single} statement that will replace the odd-indexed\nelements of \\texttt{x} with the constant -10 (i.e., \\texttt{x(1)},\n\\texttt{x(3)}, etc).\n\n\n\\paragraph{Step 1.3} One of the side benefits of learning Matlab is\nthat it trains you to think in terms of parallel operations --- an\nincreasingly important skill in a profession becoming dominated by\nmulti-core, GPU, and distributed computing. That doesn't mean you\ncan't write loops in Matlab; it's just that your code will be more\nconcise and efficient if you can avoid that. The efficiency arises\nfrom the fact that the vectorized Matlab commands are mostly compiled;\nwhile the loops you write are interpreted. Consider the following loop:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nfor k=0:7,\n   x(k+1) = cos(k*pi/4);\nend\nx\n\\end{lstlisting}\n\nWhy is \\verb|x| indexed by \\verb|k+1| rather than \\verb|k|? What\nhappens to the length of \\verb|x| for each iteration of the loop?\nRewrite this computation without using the loop (as in list\nitem~\\ref{it:simple-plots}). Besides the increase in efficiency from\navoiding an interpreted loop, what other major efficiency results from\nthis change?\n\n\\paragraph{Step 1.4} Consider the following code that plots a\nsinusoid:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nt = [0 : 0.01 : 1]; % time in seconds\nf = 5;              % freq in Hertz\nx = sin(2*pi*f*t);\nplot(t, x);\nxlabel('Time (sec)');\n\\end{lstlisting}\n\nUse the MATLAB editor to create a script file called\n\\texttt{firstsin.m}, verify that you've saved it in a directory in the\nMATLAB path (or add that directory to the path), and test its\nexecution by typing \\texttt{firstsin} at the MATLAB command\nprompt. Note that you can also do:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\ntype firstsin   % prints out contents of the script\nwhich firstsin  % shows directory (useful when your code shadows built-ins)\n\\end{lstlisting}\n\nIf you included documentation for this script (comments at the\nbeginning), the command \\verb|help firstsin| would also produce useful\noutput.\n\nAdd three lines of code to your script, so that it will plot a cosine\nusing the same axes as the sine (i.e., ``on top of the sine''). Use\nthe \\texttt{hold} function to add a plot of\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\n0.75*cos(2*pi*f*t)\n\\end{lstlisting}\nto the plot. So, your final graph will have two functions\nplotted. Save the plot using the MATLAB \\texttt{print} command as a\nPNG file named \\texttt{step14.png} by typing:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nprint -dpng step14\n\\end{lstlisting}\n\nYou should include all plots and code snippets in your lab report,\nfollowing the instructions in the report rubric.\n\n\n\\paragraph{Step 1.5} You can also use Matlab to generate sounds. A\npure tone is merely a sinusoid, which you already know how to\ngenerate. Let's generate one with a frequency of 3 kHz and a duration\nof 1 second:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nT = 1.0;\nf = 3000;\nfs = 8000;\nt = [0 : (1/fs) : T];\nx = sin(2*pi*f*t);\nsoundsc(x, fs)\n\\end{lstlisting}\n\nThe vector of numbers \\texttt{x} are converted into a sound waveform\nat a certain rate, \\verb|fs|, called the \\emph{sampling rate} (we will\nlearn a lot more about this in this class). In this case, the sampling\nrate was set to 8000 samples/second. What is the length of\nthe vector \\texttt{x}?\n\n\\paragraph{Step 1.6} Write a new function that performs the same task\nas the following function without using any loops. Use the idea in\nstep~1.3 and also consult the section on the \\verb|find| function,\nrelational operators, and vector logicals in the MATLAB documentation.\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\nfunction B = denegify(A)\n% DENEGIFY Replace negative elements of matrix with zeros\n% Usage:\n%    B = denegify(A)\n%\n[W,H] = size(A);\nfor i=1:W\n   for j=1:H\n      if A(i,j) < 0\n         B(i,j) = 0;\n      else\n         B(i,j) = A(i,j);\n      end\n   end\nend\n\\end{lstlisting}\n\n\n\n\\subsection{Trigonometric Functions and Complex Mathematics in Matlab}\n\n\n\\paragraph{Step 2.1} In this step, you are asked to complete a Matlab\nfunction to synthesize a waveform in the form of:\n\\begin{equation*}\nx(t) = \\sum_{k=1}^N a_k\\cos(2\\pi f t + \\phi_k)\n\\end{equation*}\nThis is a sum of cosines, all at the same frequency but with different\nphases and amplitudes.  Use the following function prototype to start you off:\n\\begin{lstlisting}[style=Matlab-editor,basicstyle=\\mlttfamily\\small]\n   function x = sumcos(f, phi, a, fs, dur)\n   % SUMCOS Synthesize a sum of cosine waves\n   % Usage:\n   %    x = sumcos(f, phi, a, fs, dur)\n   %        Returns sum of cosines at a single frequency f, sampling\n   %        rate fs, and duration dur, each with a phase phi and\n   %        amplitude a.\n   %    f = frequency (scalar)\n   %    phi = vector of phases\n   %    a = vector of amplitudes\n   %    fs = the sampling rate in Hz (scalar)\n   %    dur = total time duration of signal (scalar)\n\\end{lstlisting}\n\n\nInclude your code in your writeup. Additionally, include a plot of\n\\texttt{x = sumcos(20, [0 pi/4 pi/2 3*pi/2], [1 2 3 4], 200, 0.25);} versus\ntime.\n\nHint: the MATLAB \\verb|length| function is useful in determining the\nnumber of elements in a vector; the \\verb|size| function returns both\ndimensions of a vector or an array.\n\n\n\\paragraph{Step 2.2} Now, let's see how complex exponentials can\nsimplify things. Re-implement your \\texttt{sumcos} function using\ncomplex exponentials. Take advantage of the fact that multiplying a\ncomplex sinusoid $e^{j2\\pi f t}$ by the complex amplitude\n$a_ie^{j\\phi}$ will shift its phase and change its amplitude. Thus,\nyou should be able to create a \\emph{single} complex sinusoid at the\ngiven frequency \\texttt{f} and then multiply it by different \\texttt{a\n  * exp(j * phi)} to get multiple phase shifted cosines. Remember that\nwe want a real value to plot; the cosine is the real part of a complex\nsinusoid. Include your code in your writeup and provide a plot that\ndemonstrates that this function produces the same result as the\noriginal implementation.\n\n\n\\paragraph{Step 2.3} Generate four sinusoids with the following\namplitudes and phases:\n\\begin{align}\nx_1(t) &= 6 \\cos(2\\pi(10)t - 0.5\\pi) \\\\\nx_2(t) &= 3 \\cos(2\\pi(10)t + 0.25\\pi) \\\\\nx_3(t) &= 2 \\cos(2\\pi(10)t - 0.3\\pi) \\\\\nx_4(t) &= 8 \\cos(2\\pi(10)t + 0.9\\pi) \n\\end{align}\n\n\\begin{enumerate}\\renewcommand{\\theenumi}{\\alph{enumi}}\n\\item Make a single plot of all four signals together over a range of\n  $t$ that will generate approximately 3 cycles. Make sure the plot\n  includes negative time so that the phase at $t = 0$ can be\n  measured. In order to get a smooth plot make sure that your have at\n  least 20 samples per period of the wave. Include your plot in your\n  writeup.\n\n\\item Verify that the phase of all four signals is correct at $t = 0$,\n  and also verify that each one has the correct maximum amplitude. Use\n  \\verb|subplot(3,2,i)| to make a six-panel subplot that puts all of\n  these plots in the same figure, with space for two additional plots\n  at the bottom. Use the \\verb|xlabel|, \\verb|ylabel|, and\n  \\verb|title| functions so that the reader can figure out what the\n  plots mean; reinforce this with your report's figure caption. (You\n  should include the final figure, with all subplots, that results\n  from finishing all of the parts of this step.)\n\n\\item Create the sum sinusoid,\n  $x_5(t)=x_1(t)+x_2(t)+x_3(t)+x_4(t)$. Plot $x_5(t)$ over the same\n  range of time as used in the last plot. Include this as the lower\n  left panel in the plot by using \\verb|subplot(3,2,5)|.\n\n\\item Now do some complex arithmetic; create the complex amplitudes\n  corresponding to the sinusoids $x_i(t)$: $z_i = A_ie^{j\\phi_i}$,\n  $i=1,2,3,4,5$. Include a table in your report of the $z_i$ in polar\n  and rectangular form, showing $A_i$, $\\phi_i$, $\\Real\\{z_i\\}$, and\n  $\\Imag\\{z_i\\}$.\n\\end{enumerate}\n\n\n\\subsection{Representing Analog, Discrete, and Digital Signals}\n\nIn our class, we will need to manipulate analog signals (real-valued\nsignals that are functions of continuous time), discrete signals\n(real-valued signals that are functions of discrete time), and digital\nsignals (discrete-valued signals that are functions of discrete\ntime). No need to worry about the details or these; that will become\nclear later. The trickiest part of this is representing anything other\nthan digital signals on a digital computer, because you can't. So,\nwe'll need to employ two key elements of software design: information\nhiding and make-believe.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{lab1/AnalogSignal-help}\n\\end{center}\n\\caption{Example help screen for the \\texttt{AnalogSignal}\n  class. This example may be out-of-date; use the Matlab\n  \\texttt{doc AnalogSignal} command to get current\n  documentation.\\label{fg:analogsignal-help}}\n\\end{figure}\n\nInformation hiding is used in our implementation of analog signals. We\nmake use of the object-oriented programming aspects of Matlab to\ncreate an \\texttt{AnalogSignal} class. If you look up the\ndocumentation for \\texttt{AnalogSignal} (using\n\\verb|doc AnalogSignal|), you'll see something like\nfigure~\\ref{fg:analogsignal-help}. The key operations on these analog\nsignals are:\n\\begin{itemize}\n\\item Creating an analog signal (ex: \\texttt{a =\n    AnalogSignal('sawtooth', 2.0, 1.0, 10.0)}).\n\\item Scaling an analog signal (ex: \\texttt{b = a * 5})\n\\item Adding two analog signals (ex: \\texttt{c = a + b})\n\\item Subtracting two analog signals (ex: \\texttt{d = c - a})\n\\item Plotting an analog signal (ex: \\texttt{plot(d)})\n\\item Sampling an analog signal (ex: \\texttt{x = d.samplehold(0.1)})\n\\end{itemize}\n\nYou will get a lot more experience working with analog signals shortly\nin this class, so for the time being just play with this a bit.\n\n", "meta": {"hexsha": "d6de1034b0e91900b9f8bbe9ac657c852491b99f", "size": 15720, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Matlab Labs/lab1/lab1.tex", "max_stars_repo_name": "stiber/Signal-Computing", "max_stars_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-09-10T16:54:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T15:48:26.000Z", "max_issues_repo_path": "Matlab Labs/lab1/lab1.tex", "max_issues_repo_name": "stiber/Signal-Computing", "max_issues_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2015-08-18T18:16:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-29T17:19:16.000Z", "max_forks_repo_path": "Matlab Labs/lab1/lab1.tex", "max_forks_repo_name": "stiber/Signal-Computing", "max_forks_repo_head_hexsha": "cb5c7825e0cc80ca2ecd3e324fcf6231c320a721", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.2598425197, "max_line_length": 78, "alphanum_fraction": 0.7451653944, "num_tokens": 4366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.40949292676630594}}
{"text": "Role of BNN. List the parameters predicted $\\xi_{lens}$ and which of the $\\xi_{light}$ (source position, lens effective radius). Input, output. Build up to hierarchical inference. Focus on consistency between \\cite{hezaveh2017fast} and \\cite{wagnercarena2019double}.\n\n\\subsection{Training set generation}\nCite baobab paper in prep and link the GH. Say that we experimented with two different conditional PDFs, from which we sampled the macromodel parameters. One was where each parameter was sampled independently. Have a table like the TDLMC table? See \\ref{table:conditional_pdf}. Another was where the parameters followed empirical distributions.\n\nTraining set is samples from the interim prior...\n\n\\begin{table}\n\\label{table:conditional_pdf}\n\\centering\n\\caption{Parameter distribution}\\label{para_config}\n\\begin{tabular}{ l l}\n\\hline\nSimulating ingredient & model and parameter values \\\\\n\\hline\\hline  \nA): redshift \\\\\\hline \ndeflector redshift & $z_d \\in {\\rm Norm} (0.5\\pm0.2)$ \\\\ \nsource redshift & $z_s \\in {\\rm Norm} (2.0\\pm0.4)$ \\\\ \n \\hline\\hline\n% Rung1 and Rung2\\\\ \\hline \n\\\\B): deflector (image plane) \\\\\n\\hline\nlensing galaxy mass & elliptical power-law \\\\ \n\\hline \nSIS velocity dispersion & $v_d\\in {\\rm Norm} (250\\pm25)$ km/s \\\\ \nEinstein radius$^a$ &$R_{\\rm Ein} = 4\\pi v_d^2 \\frac{D_{ds}}{D_{s}}$ \\\\ \nmass slope & $s \\in {\\rm Norm} (2.0\\pm 0.1)$ \\\\ \nellipticity & $q \\in {\\rm Uni} (0.7 \\sim 1.0)$ \\\\ \nelliptical axis angle & $\\phi \\in {\\rm Uni} (0 \\sim \\pi) $ \\\\  \n\\hline \nlensing galaxy SB & \\sersic\\ profile \\\\ \n\\hline \ntotal magnitude$^{b}$ & $ mag \\in {\\rm Uni} (17.0 \\sim 19.0) $ magnitude \\\\\neffective radius & $R_{\\rm eff} = R_{\\rm Ein} * {\\rm Uni} (0.5 \\sim 1.0) $ \\\\ \n\\sersic\\ index & $n \\in {\\rm Uni} (2.0 \\sim 4.0) $\\\\\nellipticity & $q \\in {\\rm Uni} (0.7 \\sim 1.0)$ \\\\\nelliptical axis angle & $\\phi \\in {\\rm Uni} (0 \\sim \\pi) $ \\\\\n\\hline \\hline\n\n\\\\C): AGN (source plane) \\\\\n\\hline\nhost galaxy SB & realistic galaxy\\\\\n\\hline\ntotal magnitude & $ mag \\in {\\rm Uni} (22.5 \\sim 20.0) $ magnitude \\\\\neffective radius$^c$ & $R_{\\rm eff} \\in {\\rm Uni} (0\\farcs{}37, 0\\farcs{}45), $ {\\scriptsize $1.0<z_s<1.5$ \\par} \\\\\n&$R_{\\rm eff} \\in {\\rm Uni} (0\\farcs{}34, 0\\farcs{}42), $  {\\scriptsize $1.5<z_s<2.0$  \\par} \\\\\n&$R_{\\rm eff} \\in {\\rm Uni} (0\\farcs{}31, 0\\farcs{}35), $  {\\scriptsize $2.0<z_s<2.5$  \\par} \\\\\n&$R_{\\rm eff} \\in {\\rm Uni} (0\\farcs{}23, 0\\farcs{}33), $  {\\scriptsize $2.5<z_s<3.0$  \\par} \\\\\n\\hline\nactive nuclear light & scaled point source \\\\\n\\hline\nsource plane total flux & $f_{\\rm AGN} = f_{\\rm host} * {\\rm Uni} (0.8 \\sim 1.25) $ \\\\\n \\\\\\hline \\hline\nexternal shear \\\\\n\\hline\namplitudes & $ \\gamma\\ \\in {\\rm Uni} (0 \\sim 0.05) $ \\\\\nshear axis angle & $\\phi \\in {\\rm Uni} (0 \\sim \\pi) $ \\\\  \n\\hline\nexternal convergency \\\\\n\\hline\nexternal kappa$^d$ & $ \\kappa_{\\rm ext} \\in {\\rm Norm} (0 \\pm 0.025) $ \\\\\n\\hline\n\\hline\n\\end{tabular}\n  \\begin{tablenotes}\n \t \\footnotesize\n \t \\item Notes:- In Rung3, the non-parameterized deflector (i.e., lensing galaxy mass and surface brightness) are adopted. Thus, the B part in the table is not adoptable for this rung. The distribution of ``Norm\" means normal distribution and the ``Uni\" means uniform distribution.\n\t \\item ~~~~a: The scale of Einstein Radius by is in range [1$\\farcs$00, 1$\\farcs$20]. \n\t \\item ~~~~b: The flux value and the magnitude value are related by the equation: \\\\ $mag= -2.5 * log10(flux) + zp$, where $zp$ is the filter zeropoint in AB system. For filter WFC3/F160W, $zp = 25.9463$.\n\t \\item ~~~~c: The effective radius of the realistic galaxy is measured by the Galfit, by considering them as \\sersic\\ profile.\n\t \\item ~~~d: The value of $\\kappa_{\\rm ext}$ is randomly generated to calculate the time delay data. The information of this distribution is provided to the ``Good\" teams as a measurement data.\n  \\end{tablenotes}\n\\end{table}\n\n\\subsection{BNN posterior}\nWhat's the term to use for this? Cite \\cite{wagnercarena2019double} and say the form was double Gaussian.\n\n\\subsection{Posterior on $H_0$}\nTime delays, velocity dispersion are external data. Conditional PDF\nIntroduce training set are samples from the interim prior.\n\nWith importance sampling,\n\\begin{align}\n    &p(\\Omega | \\Delta t_{AB}, \\sigma_V, d_{HST}) \\\\\n    &\\propto p(\\Omega) \\prod_{k} \\int p(\\Delta t_{AB}^{(k)} | \\Omega, \\xi_{lens}^{(k)}, \\kappa_{ext}^{(k)})  \\nonumber \\\\\n    & \\quad \\times p(\\sigma_V^{(k)} | \\Omega, \\xi_{lens}^{(k)}, \\xi_{light}^{(k)}, \\kappa_{ext}^{(k)}, \\beta_{ani}^{(k)})  \\nonumber \\\\\n    & \\quad \\times p(\\xi_{lens}^{(k)}, \\xi_{light}^{(k)} | d_{HST}^{(k)}, \\Omega_i) \\times \\frac{p(\\xi_{lens}^{(k)}, \\xi_{light}^{(k)} | \\Omega)}{ p(\\xi_{lens}^{(k)}, \\xi_{light}^{(k)} | \\Omega_i)} \\nonumber \\\\\n    & \\quad \\times p(\\kappa_{ext}^{(k)}) p(\\beta_{ani}^{(k)}) \n    \\quad d \\left( \\xi_{lens}^{(k)}, \\xi_{light}^{(k)} \\right) d \\kappa_{ext}^{(k)} d \\beta_{ani}^{(k)} \\nonumber\n\\end{align}", "meta": {"hexsha": "b024d99445034b413ce8e7a4470e0915cb4ea959", "size": 4884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/methods.tex", "max_stars_repo_name": "jiwoncpark/h0rton_method_paper", "max_stars_repo_head_hexsha": "5db2778c8296d7bdae3689893a33beef04c777cd", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/methods.tex", "max_issues_repo_name": "jiwoncpark/h0rton_method_paper", "max_issues_repo_head_hexsha": "5db2778c8296d7bdae3689893a33beef04c777cd", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/methods.tex", "max_forks_repo_name": "jiwoncpark/h0rton_method_paper", "max_forks_repo_head_hexsha": "5db2778c8296d7bdae3689893a33beef04c777cd", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.2666666667, "max_line_length": 344, "alphanum_fraction": 0.6533579034, "num_tokens": 1750, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40949291989784803}}
{"text": "\\section{Conclusion}\n\\label{sec:conclusion}\n\nIn this paper, we studied the relationship between adversarial robustness, specifically considering robust overfitting \\cite{RiceICML2020}, and flatness of the robust loss (\\RCE) landscape \\wrt perturbations in the weight space. We introduced both average- and worst-case measures for flatness in \\RCE that are scale-invariant and allow comparison across models. Considering adversarial training (AT) and several popular variants, including TRADES \\cite{ZhangICML2019}, AT-AWP \\cite{WuNIPS2020} or AT with additional unlabeled examples \\cite{CarmonNIPS2019}, we show a \\textbf{clear relationship between adversarial robustness and flatness} in \\RCE. More robust methods predominantly find flatter minima. Vice versa, approaches known to improve flatness, \\eg, Entropy-SGD \\cite{ChaudhariICLR2017} or weight clipping \\cite{StutzMLSYS2021} can help AT become more robust, as well. Moreover, even simple regularization methods such as AutoAugment \\cite{CubukARXIV2018}, weight decay or label noise, are effective in increasing robustness by improving flatness. These observations also generalize to pre-trained models from RobustBench \\cite{CroceARXIV2020b}. ", "meta": {"hexsha": "7908a2ddbac5e008f7825db794d42514033a9790", "size": 1201, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/sec_conclusion.tex", "max_stars_repo_name": "davidstutz/iccv2021-robust-flatness", "max_stars_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-11-08T21:27:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-10T19:09:04.000Z", "max_issues_repo_path": "paper/sec_conclusion.tex", "max_issues_repo_name": "davidstutz/iccv2021-robust-flatness", "max_issues_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/sec_conclusion.tex", "max_forks_repo_name": "davidstutz/iccv2021-robust-flatness", "max_forks_repo_head_hexsha": "d63daf8fc0221d07d8cfc8b7a5bcdc213403a17b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 300.25, "max_line_length": 1156, "alphanum_fraction": 0.8226477935, "num_tokens": 298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40949291989784803}}
{"text": "The chapter addresses the problem of optimally controlling an industrial micro-grid featuring a large share of renewable energy and a high volatility of electricity prices. We consider a micro-grid as a localized group of energy sources, loads and storage components that can operate in two distinct modes: grid-connected mode and isolated mode. In grid-connected mode, the micro-grid system has the possibility to buy/sell energy from/to the macro-grid in order to meet the load demand. The challenge in connected mode is to reduce the total energy cost. In isolated mode, the micro-grid can function autonomously in the sense that enough energy can be generated in the grid to supply the loads. In this case the challenge is to meet the load demand and to balance the power flow between the components of the grid. In our setting, the grid is executed in mixed mode. In other words, the industrial micro-grid, we are considering, can switch from one mode to another.\n\n\\subsection{System Model}\n\\label{subsec:31}\n\n% For figures use\n%\n\\begin{figure}[b]\n%\\sidecaption\n% Use the relevant command for your figure-insertion program\n% to insert the figure file.\n% For example, with the graphicx style use\n\\includegraphics[scale=.65]{images/System_Model}\n%\n% If no graphics program available, insert a blank space i.e. use\n%\\picplace{5cm}{2cm} % Give the correct figure height and width in cm\n%\n\\caption{System Overview. Every grid-component is controlled by a reinforcement learning agent.}\n\\label{fig:system_model}       % Give a unique label\n\\end{figure}\n\nAs illustrated in Fig.\\ref{fig:system_model}, the micro-grid system consists of the following components: renewable energy sources such as photovoltaic systems, electricity loads representing production machines, regenerative energy consumers, energy storages systems such as batteries and auxiliary process loads for air compressors and cooling systems. The components share the same energy bus, enabling a transfer of electrical energy between the components. The proposed system model is equally applicable to ac and dc micro-grids and a simple formal description of the components can be described as follow:\n\\begin{itemize}\n\\item{\\textit{\\textbf{ Renewable energy sources}} are renewable energy generators such as photovoltaic systems or wind turbines. The power generated depends on environmental and weather factors such as solar radiation profile and wind speed. It is therefore not predictable. Energy generators are characterized by two operating states: $on$ and $off$. The generators are considered to be in the $off$-state when the electrical power generated by the energy sources is negligible for example because of weather conditions such as cloudy weather or nighttime. We assume that if the generators are not in $off$ state, then the power generated is constant and equal to the maximum electricity power that can be produced by the source. Therefore\n%\n\\begin{equation}\n P_G = \n \\begin{cases}\n      0 & \\text{if}\\ state=off \\\\\n      P_Gmax & \\text{otherwise}\n    \\end{cases} \\;\n\\end{equation}\n%\n } \n\\item{\\textit{\\textbf{Energy storage systems}}. In order to take full advantage of renewable energy sources, it is vital to have energy storage systems capable of handling variations in energy production. In our environment, we consider batteries or super-capacitor systems that consume a constant energy when charging and produce a constant energy when discharging. In addition, the operation of energy storage systems has to be carefully designed and controlled to protect them from damages that are: overcharging and overdischarging. Therefore, each storage system is also characterized by a maximum and minimum state-of-charge (SoC). The energy storage systems have three required states: $charging$, $discharging$ and $idle$. The electrical power consumed or released by the component highly depends on the current operational state and the component\\rq{s} state-of-charges.}\n \n \\item{\\textit{\\textbf{Energy loads}} represent production machines that consume energy in order to execute a production task. A production machine can have different operation states: $powered off$, $executing$, $stand by$, etc… Depending on the production task and the operation state, a production machine can follow a predefined or a characteristic load profile. For a fixed set of production tasks, the load profile of a machine can be measured and approximated. In our setting, we consider 3 basic load profile as illustrated in Fig. \\ref{fig:load_profile}. Any machine\\rq{s} load profile can be seen as a linear combination of this basic load profiles. In isolated mode, the micro-grid cannot guarantee continuous power supply to the load because it is often influenced by the unpredictable power generation. When the generated power is not able to drive the loads, the noncritical loads must shut down.}\n \n % For figures use\n%\n\\begin{figure}[h!]\n%\\sidecaption\n% Use the relevant command for your figure-insertion program\n% to insert the figure file.\n% For example, with the graphicx style use\n\\includegraphics[scale=.40]{images/load_profile}\n%\n% If no graphics program available, insert a blank space i.e. use\n%\\picplace{5cm}{2cm} % Give the correct figure height and width in cm\n%\n\\caption{Basic load profiles of the energy loads. In $execute$-state,  the electrical power consumed $P_i$ can be constant and equal to $P_{max}$ (a), increase linearly (b) or exponentially (c) to $P_{max}$.}\n\\label{fig:load_profile}       % Give a unique label\n\\end{figure}\n\n \n\\item{\\textit{\\textbf{Regenerative energy consumers}} are energy consumers with the exception that these consumers can recuperate energy for a small period of time (less than a minute). In this case we consider the load to be constant and negative. Fig. \\ref{fig:recuperative_load_profile} shows a typical load profile.}\n\n % For figures use\n%\n\\begin{figure}[h!]\n\\sidecaption\n% Use the relevant command for your figure-insertion program\n% to insert the figure file.\n% For example, with the graphicx style use\n\\includegraphics[scale=.40]{images/Recuperative_Energy_Load_Profile}\n%\n% If no graphics program available, insert a blank space i.e. use\n%\\picplace{5cm}{2cm} % Give the correct figure height and width in cm\n%\n\\caption{Basic load profiles of regenerative energy consumers. In $execute$-state,  the electrical power consumed $P_i$ can be negative for a short period of time.}\n\\label{fig:recuperative_load_profile}       % Give a unique label\n\\end{figure}\n\n\n\\item{\\textit{\\textbf{Auxiliary processes}} are energy consumer processes in the factory floor that do not execute a manufacturing task directly, but are required by the production task. These are for example compressors or cooling systems. Auxiliary processes have two required states: $off$ and $on$.}\n\n\\item{The \\textit{\\textbf{grid component}} represents the main grid and is responsible for buying/selling electricity from/to the main grid. It has three state: $buying$, $selling$, $idle$. If the grid agent is in $idle$-state or in $off$-state, the industrial micro-grid can be considered to be executed in isolated mode because there are no interaction with the main grid.}\n\\end{itemize}\n\n\\subsection{Problem Formulation}\\label{subsec:32}\nThe main objective is to minimize the total cost the energy bought from the main grid to achieve a high productivity while considering future energy prices and weather dependent renewable energy generators. Let $\\mathrm{M}$ denotes the set of components of the micro-grid (or controllable machine components), such that $M_i \\in \\mathrm{M}, \\forall i \\in [0, M-1]$  with $ M \\in \\mathbb{N}$. We assume that each component $M_i$ can take an energy state $s_{i,t}$ (i.e. “stopped”, “running”, “aborted”, “standby”, etc.) at the time step $t  \\in \\mathbb{N}$ and the dynamic power consumption $P_i^t$ of $M_i$ solely depends on the current state $s_{i,t}$ of the component and the current time step $t$: $P_i^t=P_i (t, s_{i,t})$. The total energy requested/sold from/to the main grid $E_i^t$ at time interval $\\triangle t$ over the complete time horizon $T \\in \\mathbb{N}$ is therefore the sum of the power consumed/generated of all components during the time horizon. Please notice that $P_i^t$ can also be negative in the case of renewable energy sources or regenerative energy consumers for example.\n\n%\n\\begin{equation}\nE_i =\\sum_{t=0}^{T-1}{ P_i^t \\cdot \\triangle t}, \\forall i \\in [0, M-1]\n\\end{equation}\n%\n\n If $\\lambda_t^- \\in \\mathbb{R}$ is the actual energy price and $\\lambda_t^\\sim \\in \\mathbb{R}$ the forecasted energy price at a time step $t$, the optimization problem can be formulated for the time horizon $T$ as follow:\n\n%\n\\begin{equation}\n\\label{eq:problem}\nminimize \\sum_{k=0}^{t}{ {\\lambda_t^-} \\cdot ({ \\sum_{i=0}^{M-1}{ P_i (k, s_{i,k}) \\cdot \\triangle t } })}+  \\sum_{l=t+1}^{T-1}{\\lambda_t^\\sim \\cdot ({ \\sum_{i=0}^{M-1}{ P_i (l, s_{i,l}) \\cdot \\triangle t  } }) }\n\\end{equation}\n\nIf $a_l (s_{i,l-1},s_{i,l})$ denotes the action of changing the state of the component $M_i$ at time $l$ from the state $s_(i,l-1)$ to the state $s_(i,l)$, the Eq. \\ref{eq:problem} can be rewritten as follow:\n\n\\begin{equation}\n\\label{eq:problem_reformulated}\nminimize \\sum_{k=0}^{t}{ {\\lambda_t^-} \\cdot ({ \\sum_{i=0}^{M-1}{ P_i (k, s_{i,k}) \\cdot \\triangle t } })}+  \\sum_{l=t+1}^{T-1}{\\lambda_t^\\sim \\cdot ({ \\sum_{i=0}^{M-1}{ P_i (l, a_l (s_{i,l-1},s_{i,l})) \\cdot \\triangle t  } }) }\n\\end{equation}\n\nSeveral constraints should be taken into consideration. One of them is the power balance between the energy demand of the micro-grid and the energy supply from the main grid:\n\n\\begin{equation}\n\\label{eq:constraint_energy_balance}\t\n\t\\sum_{i=0}^{M-1}{ E_i} \\leq E_{max}^\\sim,  \\forall i \\in [0, M-1]\n\\end{equation}\nwhere $E_i$ denotes the total energy demand of the micro-grid component $M_i$ over the time horizon $T$ and $E_{max}^\\sim$ the total available energy from the main grid.\n\nIn addition, the total energy consumption of the micro-grid at each time interval $t$ should satisfy the upper and lower bound given by the overall load profile and a tolerance interval. This constraint can be expressed as follows:\n\n\\begin{equation}\n\\label{eq:constraint_load_profile}\t\n\tL_{target}^\\sim - \\triangle L^\\sim \\leq {\\sum_{i=0}^{M-1}{ P_i (t, s_{i,t})} } \\leq L_{target}^\\sim + \\triangle L^\\sim\n\\end{equation} \nwith $L_{target}^\\sim$  being the target load at time step $t$, $\\triangle L^\\sim$  a symmetric tolerance around $L_{target}^\\sim$ and $ i \\in [0, M-1]$\n\nAs expressed above, solving the optimization problem is equivalent to compute at each time step the optimal state (by choosing the action $a_l (s_{i,l-1},s_{i,l})$ ) so that the resulting total energy cost of the micro-grid for a complete time horizon is globally minimized. If every component of the micro-grid is controlled by an agent, then the optimization problem is equivalent to finding a coordinated strategy for all the agents. In this case, the main challenge lies in the volatility of future energy prices and the direct dependence of future energy consumption from actual decisions. Furthermore, other constraints such as the the throughput, production time, the product quality, the production cost, etc. have to be considered.\n\n\\subsection{Markov Game Formulation}\nThe formulated optimization problem can be transformed into a reinforcement learning task, where each agent controlling a component of the grid has to learn a policy that maximizes a cumulative reward signal derived from the objective function and is conditioned by the constraints formulated in Eq. \\ref{eq:constraint_energy_balance} and Eq. \\ref{eq:constraint_load_profile}.\n\nIf we consider the global state of the environment as the aggregation of the observations of all agents, then the observed state of the environment solely depends on the actions of all the agents and the previously observed global state of the environment. In other words, no external factors besides the actions of all the agents will affect the dynamics of the environment. Under this assumption, the multi-agent reinforcement-learning task satisfies the Markov property and can be therefore formulated as a Markov decision process (MDP).\n\nIn this work, we consider a multi-agent extension of Markov decision processes called observable Markov games \\cite{Littman1994multiagent}. A Markov game for $N$ agents is defined by a set of states $\\mathrm{S}$ describing the possible configurations of all agents, a set of actions $\\mathrm{A}_1, \\mathrm{A}_2, \\ldots, \\mathrm{A}_N$ and a set of observations $\\mathrm{O}_1,\\mathrm{O}_2, \\ldots, \\mathrm{O}_N$ for each agent. To choose actions, each agent $i ( i= 1,2,\\ldots, N)$ uses a stochastic policy $\\pi_{\\theta_i} : \\mathrm{O}_i \\times \\mathrm{A}_i \\mapsto [0; 1]$, where $\\theta_i$ are the parameters of the policy. The policy produces the next state according to the state transition function $T : \\mathrm{S} \\times  \\mathrm{A}_1 \\times ...  \\times \\mathrm{A}_N \\mapsto \\mathrm{S}$. Each agent $i$ obtains rewards as a function of the state and agent’s action $r_i : \\mathrm{S} \\times \\mathrm{A}_i  \\mapsto \\mathbb{R}$, and receives a private observation correlated with the environment state $o_i : \\mathrm{S} \\mapsto \\mathrm{O}_i$. The initial states are determined by a distribution  : $\\mathrm{S} \\mapsto [0; 1]$. Each agent $i$ aims to maximize its own total expected return $R_i = \\sum_{t=0}^{T}{\\gamma^t \\cdot r_i^t}$ where $\\gamma^t$ is a discount factor at time step $t$ and $T$ is the time horizon. The \\textit{action-value function} is defined as $\\mathrm{Q}^{\\pi_i}(s_{i,t}, a_t^i)=\\mathbb{E}[\\mathrm{R}_i^t|s_{i,t},a_t^i]$, while the \\textit{state-value function} is defined as $\\mathrm{V}^{\\pi_i}(s_{i,t})=\\mathbb{E}[\\mathrm{R}_i|s_{i,t}]$. The\n\\textit{advantage function} $\\mathrm{A}^{\\pi_i}(s_{i,t}, a_t^i) = \\mathrm{Q}^{\\pi_i}(s_{i,t}, a_t^i) - \\mathrm{V}^{\\pi_i}(s_{i,t})$ describes whether taking action $a_t^i$ is better or worse for agent $i$ when in state $s_{i,t}$ than the average action of policy $\\pi_{\\theta_i}$.\n\nFor our micro-grid, we provide a uniform representation of the operational state of the grid components which is illustrated in Fig. \\ref{fig:state_chart}. The state space of every agent is represented by the operation state of the grid component it controls aggregated with the target load of the grid, the current  time step within  the production shift, the amount of production tasks to execute as well as the current energy price. Notice that we do not assume inter-dependencies between the production tasks. The action space of each agent is represented by all the actions that can change the operational state of a grid component (See Fig. \\ref{fig:state_chart}). The reward of each agent depends on the type of the grid component it controls and therefore is use case dependent. See Eq. \\ref{eq:total_reward} in section \\ref{subsec:42} for more details.\n\n % For figures use\n%\n\\begin{figure}[h!]\n%\\sidecaption\n% Use the relevant command for your figure-insertion program\n% to insert the figure file.\n% For example, with the graphicx style use\n\\includegraphics[scale=.40]{images/StateMachine_EFlex}\n%\n% If no graphics program available, insert a blank space i.e. use\n%\\picplace{5cm}{2cm} % Give the correct figure height and width in cm\n%\n\\caption{Uniform state representation of a grid component. Every component can be stopped, halted, suspended, powered up or aborted. Once the component reach the $execute$-state then it begins to execute a production task, to generate energy or to store/release energy.}\n\\label{fig:state_chart}       % Give a unique label\n\\end{figure}\n\n\n\n", "meta": {"hexsha": "3fe7f1fc597c7034b2931aae08a6e4ef5afda2bf", "size": 15629, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "author/system_model.tex", "max_stars_repo_name": "jupiterbak/Artificial-Intelligence-in-Industry-4.0", "max_stars_repo_head_hexsha": "7ddeb55de44c4e50b195edf7a75aa4afb99fcd9e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-09T11:05:49.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-09T11:05:49.000Z", "max_issues_repo_path": "author/system_model.tex", "max_issues_repo_name": "jupiterbak/Artificial-Intelligence-in-Industry-4.0", "max_issues_repo_head_hexsha": "7ddeb55de44c4e50b195edf7a75aa4afb99fcd9e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "author/system_model.tex", "max_forks_repo_name": "jupiterbak/Artificial-Intelligence-in-Industry-4.0", "max_forks_repo_head_hexsha": "7ddeb55de44c4e50b195edf7a75aa4afb99fcd9e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 104.1933333333, "max_line_length": 1567, "alphanum_fraction": 0.7621728837, "num_tokens": 3938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40949291989784803}}
{"text": "\\chapter*{Introduction}\n\\addcontentsline{toc}{chapter}{Introduction}\nNowadays, there are only a few aspects of everyday life that are not affected by modern technologies, and the rise of technologies like \\textit{Internet of Things} lowers this number even more. These technologies produce large amounts of data with temporal stamp, also recognized as time series. As the amount and speed, at which we are getting new data, are making it impossible to process and analyze them manually, we are in need for fast analytics tools for time series data.\n\nOur work focuses on methods for analyzing large datasets of long time series, demonstrating it on a power consumption dataset.  We are using the approach to transform the dataset into a spatial feature space representation. Using this representation, we prepare multiple visualizations for exploring the structures within the dataset and detailed views for examining time series details. To supply the analysis, we apply clustering and anomaly detection methods. This work is divided into four chapters.\n\nChapter 1 will discuss metrics used for time series, their complexity, advantages and disadvantages, and their application in practical analysis. Afterwards, it explores the representations of time series datasets in artificial feature space. Finally, it examines clustering and anomaly detection methods available for large datatasets.\n\nChapter 2 will discuss techniques for visual representation and analysis of time series datasets. Firstly, it analyzes the dimensionality reduction techniques for transforming the datasets into low-dimensional embeddings. Secondly, it goes through algorithms for downsampling time series with a specific focus on visual analysis.\n\nChapter 3 applies the methods from the first two chapters to analyze a large power consumption dataset, while introducing a novel approach for time series transformation.\n\nChapter 4 is a conclusion of our work, containing the discussion of the benefits and drawbacks of our novel approach about the novel approach for time series transformation, and possible future research directions in this field.", "meta": {"hexsha": "2773894b846a4885bcef55773d9c1c34021f55ec", "size": 2124, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapters/0_introduction.tex", "max_stars_repo_name": "H00N24/visual-analysis-of-big-time-series-datasets", "max_stars_repo_head_hexsha": "8c9c14ca5d16f5d9ef8b623c84f92fe62eee1f86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-07-30T04:07:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T07:28:44.000Z", "max_issues_repo_path": "thesis/chapters/0_introduction.tex", "max_issues_repo_name": "H00N24/visual-analysis-of-big-time-series-datasets", "max_issues_repo_head_hexsha": "8c9c14ca5d16f5d9ef8b623c84f92fe62eee1f86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapters/0_introduction.tex", "max_forks_repo_name": "H00N24/visual-analysis-of-big-time-series-datasets", "max_forks_repo_head_hexsha": "8c9c14ca5d16f5d9ef8b623c84f92fe62eee1f86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 163.3846153846, "max_line_length": 503, "alphanum_fraction": 0.8290960452, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.409492916463619}}
{"text": "\\subsection{part a}\n\\begin{itemize}\n    \\item $K=0.5$\n    \\begin{figure}[H]\n        \\caption{Nichols chart for $KG, (K=0.5)$}\n        \\centering\n        \\includegraphics[width=16cm]{../Figure/Q1/Q1_a/Q1_aK_0.5.png}\n    \\end{figure}\n    \\item $K=1$\n    \\begin{figure}[H]\n        \\caption{Nichols chart for $KG, (K=1)$}\n        \\centering\n        \\includegraphics[width=16cm]{../Figure/Q1/Q1_a/Q1_aK_1.png}\n    \\end{figure}\n    \\item $K=5$\n    \\begin{figure}[H]\n        \\caption{Nichols chart for $KG, (K=5)$}\n        \\centering\n        \\includegraphics[width=16cm]{../Figure/Q1/Q1_a/Q1_aK_5.png}\n    \\end{figure}\n\\end{itemize}\nPhase margin and gain margin are shown in above figures and all closed loop systems are unstable with $K$ form 1 to 5. In all of them phase margin is negetive.", "meta": {"hexsha": "5eb9f9e38d114b96eaa53239cc70040555ac0bb4", "size": 785, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW/HW IV/Report/Q1/Q1_a/Q1_a.tex", "max_stars_repo_name": "alibaniasad1999/Principle-Of-Controller-Design", "max_stars_repo_head_hexsha": "2a6285f627377a5e5edfb32c92e054ab213d311a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW/HW IV/Report/Q1/Q1_a/Q1_a.tex", "max_issues_repo_name": "alibaniasad1999/Principle-Of-Controller-Design", "max_issues_repo_head_hexsha": "2a6285f627377a5e5edfb32c92e054ab213d311a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW/HW IV/Report/Q1/Q1_a/Q1_a.tex", "max_forks_repo_name": "alibaniasad1999/Principle-Of-Controller-Design", "max_forks_repo_head_hexsha": "2a6285f627377a5e5edfb32c92e054ab213d311a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6818181818, "max_line_length": 159, "alphanum_fraction": 0.6229299363, "num_tokens": 270, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40949291302938995}}
{"text": "\\title{\\bf Stellar Evolution}\n\n\\section{Basics \\& Nomenclature}\n\nStars are formed from interstellar gas, through gravitational collapse\nwithin molecular clouds. A spectrum of objects are formed from below\nthe hydrogen burning limit of 0.08 $M_\\odot$ up to 100--200\n$M_\\odot$. Stars spend most of their lifetime on a {\\it main\nsequence}, burning hydrogen in their cores. Depending on their mass\nthey then proceed through a sequence of post-main sequence phases and\nleave remnants in the form of white dwarfs, neutron stars, or black\nholes (or in some cases no permanent remnant). In any system of stars,\ntheir history is encoded in their distribution of luminosities and\ncolors, which can be measured directly in resolved stellar populations\nor inferred from spectra and/or broad band imaging. Stellar evolution\nprocesses are responsible for most of the elements higher mass than\nhelium.\n\nThe {\\it stellar initial mass function}, or {\\it IMF}, defines the\nspectrum of initial masses of stars. This spectrum is difficult to\ndetermine observationally, because almost all systems we observe have\nbeen altered dynamically or by stellar evolution. For many decades,\nthe standard was the {\\it Salpeter IMF}:\n\\begin{equation}\n\\Phi(M) \\propto M^{-2.35}.\n\\end{equation}\nThis form leads to a large fraction of mass between $0.08$ and $0.5$\n$M_\\odot$. However, evidence from local systems implies that in many\ncases, the true IMF has a flatter slope at lower masses\n(\\citealt{bastian10a}. This difference is significant because low mass\nstars emit very little luminosity, so their presence is very difficult\nto directly detect, and therefore inferences of total mass in stars\ndepend strongly on the assumptions of how many low mass stars are in\nthe system.\n\nThe first and usually longest phase of stellar evolution is core\nhydrogen burning on the main sequence. The cores are typically\nmillions to billions of Kelvin and fully ionized. Hydrogen is burned\nto helium through two major processes, the {\\it p-p chain} at low\nmasses and the {\\it CNO cycle} at high masses ($M>2 M_\\odot$). Each\nprocess yields one ${}^4$He nucleus with a mass of 3.96$m_p$ from 4\nprotons; the one percent difference yields the energy for stellar\nluminosity. Numerous other nuclear processes are occurring\nsimultaneously that contribute to the luminosity (and to the neutrino\noutput). The nuclear processes depend on the tail of nuclei in the\nMaxwell-Boltzman distribution that are sufficiently high energy to\ntunnel through the Coulomb repulsion of the nuclei. They are therefore\nstrongly temperature sensitive.\n\nStellar structure is controlled by the following equations:\n\\begin{itemize}\n\\item Mass conservation:\n\\begin{equation}\n\\frac{{\\rm d}M}{{\\rm d}r} = 4 \\pi r^2 \\rho\n\\end{equation}\n\\item Energy conservation:\n\\begin{equation}\n\\frac{{\\rm d}L}{{\\rm d}r} = 4 \\pi r^2 \\rho \\epsilon\n\\end{equation}\n\\item Hydrostatics:\n\\begin{equation}\n\\frac{{\\rm d}P}{{\\rm d}r} = - \\frac{GM(r) \\rho}{r^2}\n\\end{equation}\n\\item Energy transport, which comes in the form of radiative transfer:\n\\begin{equation}\n\\frac{{\\rm d}T}{{\\rm d}r} = \\frac{L(r)\\kappa(r) \\rho(r)}{16\\pi r^2 c a T^3}\n\\end{equation}\nor in the form of convection.\n\\end{itemize}\n$\\kappa(r)$ is the opacity defined as the cross-section to absorption\nper unit mass (so is $1/\\rho l$, where $l$ is the mean free path of a\nphoton). Opacity is a critical parameter, as it strongly affects the\nstructure of the star, and therefore its size. The higher the\nmetallicity, the higher the opacity, the larger the star, and\ntherefore the lower the surface temperature at a given luminosity.\n\nThe most important contributions to opacity inside the bulk of the\nstar come from Thomson scattering, free-free absorption, and\nbound-free absorption. The latter two effects scale according to {\\it\nKramer's Law}, which scales as follows:\n\\begin{equation}\n\\kappa \\propto Z \\rho T^{-7/2}\n\\end{equation}\nThe scaling results from just the consideration of the effects of\nbrehstrahhlung on a Planck spectrum, and the density of free\nelectrons. Because of the temperature dependence, at high temperatures\n($T> 10^6$ K) Thomson scattering dominates, for which $\\kappa$ is\nconstant. There are two other major sources of opacity, bound-bound\nabsorption, which is subdominant over most of the star, and H$^{-}$\nabsorption, which is only possible in the outer layers.\n\nIn the exercises, we will show that these equations imply a scaling of\nluminosity with mass of approximately $L\\propto M^4$ and with surface\ntemperature of $L\\propto T_s^8$ on the main sequence.  The former\nrelationship implies that the stellar lifetimes on the main sequence\nscale as $M^{-3}$.\n\nAfter the main sequence, stellar evolution depends on the mass of the\nstar. At high luminosities (canonically above 8 $M_\\odot$), stars have\nshort main sequence lifetimes (10s of Myrs) and thereafter undergo a\nseries of nuclear burning phases in their cores: He, C, Si, and so\non. Each burning phase is shorter than the last.  Shell burning is\noccurring at the same time. Once Fe and Ni form in the core, energy\ncannot be further released, and the core collapses. The result in many\nand potentially all cases is a core-collapse supernova. The Fe and Ni\nproduced in the core is disintegrated in this process and most of that\nmass becomes part of the neutron star or black hole that forms at the\ncenter. However, the elements remaining from burning in the regions\noutside the core, which are rich in $\\alpha$ elements like O, Mg, and\nso on, can be returned to the interstellar medium.\n\nAt lower masses, stars instead start burning hydrogen in a shell\naround the inert helium core. This shell burning yields tremendous\nluminosity and also induces the outer layers of the stars to expand up\nto AU or greater size. The result is a red giant. The red giant\nevolves up the red giant branch, increasing in luminosity until the\ntip of the red giant branch. The color of the red giant branch is\nlargely set by the {\\it Hayashi limit}, which determines how low a\ntemperature the atmosphere can become and still satisfy energy\ntransport constraints. In the red giant phase, stellar winds can be\nactive.\n\nThe maximum luminosity at the tip of the red giant branch is set by\nthe onset of helium burning. For stellar masses of $M>2M_\\odot$, the\ncore is nondegenerate and expands, leading the envelope to contract\nand the star to become blue; some loops in the color-magnitude diagram\ncan occur. For lower stellar masses, there is a thermal runaway\nprocess called the {\\it helium flash} and the stellar structure\nreadjusts, with the stars ending up on the {\\it horizontal branch},\nwith a luminosity determined by the core mass (usually around 0.5\n$M_\\odot$) and the temperature determined by how much envelope was\nlost through winds.\n\nThe net result of stellar evolution is that at early times the stellar\npopulation is mostly on the main sequence and it is dominated by the\nbluest stars. At late times it is dominated by the red giants, which\nhave recently (within $\\sim$ a Gyr) left the main sequence.\n\nStars are normally classified according to their MK system: OBAFGKM,\nwhich is in order of decreasing temperature. Subclassifications exist\n(O1, O2, \\ldots, O9, B1, \\ldots). Hotter stars are referred to as\n``early type'' and cooler stars are referred to as ``late type.''\nThese classifications are according to their spectra and the ordering\nwas originally based on the spectral phenomenology, which is why the\ncurrent nomenclature appears somewhat random.\n\nBroadly speaking O and B stars have few lines, with He II lines in O\nstars, He I lines in B stars, and weak Balmer lines in both. A stars\nhave strong Balmer lines. Balmer lines become weaker again for later\ntype stars. In F and G stars, lines of other neutral atoms become\nimportant. Particularly in G stars the Ca II H and K lines (right\nbelow 4000 \\AA) appear. In G, K, and particularly M stars, molecular\nlines become important as molecules like CH, CN, and TiO become able\nto survive in the cooler atmospheres.\n\nIn galactic systems, the consequence of stellar evolution is that the\nstellar continuum of young systems is dominated by hot stars, yielding\na blue spectrum with few clues to metallicity, whereas the stellar\ncontinuum of old systems is dominated by cooler, old stars, with red\nspectra that depend on metallicity (due to variations in the\nabundances and their effects on the stellar opacity and therefore\ntemperature). \n\n\\section{Commentary}\n\nThe basic consequences of stellar evolution are well-established,\nparticularly on the main sequence. But the post-main sequence phases\nare not well-constrained in terms of (for example) the temperatures to\nexpect for horizontal branch stars and the numbers and temperatures of\nAGB stars (and how dust obscured they should be), among other\nuncertainties. Furthermore, the prediction of stellar atmosphere\nemission spectra for stars in a given phase and metallicity is not\nperfect, nor well constrained by data in all regimes. In addition,\nmany stars are in binary systems (perhaps the majority of high mass\nstars) and the extent to which this matters for the interpretation of\nstellar populations is not known.\n\n\\section{Key References}\n\n\\begin{itemize}\n  \\item {\\it Nucleosynthesis and Chemical Evolution of\n  Galaxies, \\citet{pagel09a}}; this textbook gives a good introduction\n  to the aspects of stellar evolution relevant to galaxies.\n\\end{itemize}\n\n\\section{Important numbers}\n\n\\begin{itemize}\n\\item $M_{\\odot} = 1.989 \\times 10^{30} {\\rm ~kg} $\n\\item $R_{\\odot} = 6.955 \\times 10^{8} {\\rm ~m} $\n\\item $T_{\\odot}{\\rm (surface)} = 5500 {\\rm ~K} $\n\\item $T_{\\odot}{\\rm (core)} = 1.5 \\times 10^7 {\\rm ~K} $\n\\item $L_{\\odot} = 3.828 \\times 10^{33} {\\rm ~erg} {\\rm ~s}^{-1}$\n\\end{itemize}\n\n\\section{Order-of-magnitude Exercises}\n\n\\begin{enumerate} \n\\item Argue why higher mass stars produce more of their energy through\n    the CNO cycle than lower mass stars do.\n\\item Detailed stellar evolution calculations predict a main sequence\n    lifetime for the Sun of 10 billion years. What fraction of the\n    total hydrogen in the Sun needs to be converted to helium to\n    provide this lifetime?\n\n\\begin{answer}[Author: Matthew Daunt]\nIf time in the main sequence is T, and the luminosity of the Sun is L,\nroughly the total energy spent is:\n\\begin{equation}\nE =  T L\n\\end{equation}\nAnd since this energy primarily comes from converting the hydrogen to\nhelium, with the loss of one percent mass,\n\\begin{eqnarray}\n(.01) m_c c^{2} & =&  T L \\cr\nm_c & =&  \\frac{T L}{.01 c^2}\n\\end{eqnarray}\nwhere $m_c$ is the mass converted in the reaction. For 10 Gyr and\n$L\\sim 4 \\times 10^{33}$ erg s$^{-1}$, a total of $1.3\\times 10^{32}$\ng of hydrogen is converted to helium. The mass of the Sun is $2\\times\n10^{33}$ g, of which 75\\%, or $1.5\\times 10^{33}$ g, is hydrogen at\nthe beginning of the process. Thus, about 10\\% of the hydrogen in the\nSun is converted to helium over its lifetime. Note that the helium ash\ncreated increases the mass fraction from 0.25 to around 0.35, but that\nash is in the core so not apparent in spectra, which reflect the\nstellar atmospheric abundances. It also will not be returned to the\ninterstellar medium, since in the Sun's later phases it will be\nburnt mostly into carbon and oxygen.\n\\end{answer}\n\n\\item Estimate the scaling relations between luminosity, mass, and\n    surface temperature on the main sequence from the equations of\n    stellar structure. Assume that the central temperature $T_c$ is\n    approximately constant (it is more like $T\\propto M^{-1/2}$ in\n    reality). Calculate the scaling separately for high mass stars,\n    assuming their opacity is dominated by Thomson scattering, and low\n    mass stars, assuming their opacity is dominated by Kramer's Law.\n\n\\begin{answer}\nUsing dimensional analysis, the energy transport equation implies the\nrelations: \n\\begin{eqnarray}\n\\frac{T_c}{R} &\\propto& \\frac{L \\rho}{R^2T_c^3} \\mathrm{\\quad high~mass}\\cr\n\\frac{T_c}{R} &\\propto& \\frac{L \\rho^2}{R^2T_c^{7.5}} \\mathrm{\\quad low~mass}\n\\end{eqnarray}\nand we can rearrange these:\n\\begin{eqnarray}\n  L &\\propto& \\frac{T_c^4 R}{\\rho} \\propto \\frac{T_c^4\n  R^4}{M} \\mathrm{\\quad high~mass} \\cr\n  L &\\propto& \\frac{T_c^{8.5} R}{\\rho^2} \\propto \\frac{T_c^{8.5}\n  R^7}{M^2} \\mathrm{\\quad low~mass}\n\\end{eqnarray}\nThe hydrostatic equation implies:\n\\begin{equation}\nP \\propto \\frac{M^2}{R^4}\n\\end{equation}\nand we can convert the ideal gas law ($P = nkT$) to:\n\\begin{equation}\nP \\propto \\frac{MT_C}{R^3}.\n\\end{equation}\nEquating the two expressions, balancing temperature and density\nagainst gravity leads to:\n\\begin{equation}\nT_c \\propto \\frac{M}{R}\n\\end{equation}\nor $M\\propto R$. Then plugging into the energy transport equation:\n\\begin{eqnarray}\n  L &\\propto& M^3 \\mathrm{\\quad high~mass} \\cr\n  L &\\propto& M^5 \\mathrm{\\quad low~mass}\n\\end{eqnarray}\nNow we can use the Stefan-Boltzmann law to relate the surface\ntemperature to the luminosity:\n\\begin{equation}\nL \\propto R^2 T_s^4\n\\end{equation}\nIf we just average the high and low mass exponents and assert\n$L\\propto M^4$, it is simple to show that\n\\begin{equation}\nL \\propto T_s^8,\n\\end{equation}\nexplaining the extremely strong dependence of luminosity on surface\ntemperature in the Hertzsprung-Russell diagram. Note that using $T_c$\nthat varies with mass changes these exponents somewhat but only\nweakly. Of course getting things right in detail requires detailed\nnumerical calculations.\n\\end{answer}\n\\end{enumerate} \n\n%\\section{Analytic Exercises}\n%\n%\\begin{enumerate}\n%\\end{enumerate}\n\n\\section{Numerics and Data Exercises}\n\n\\begin{enumerate}\n\\item Using Gaia, for a relatively nearby open cluster,\nplot the HR diagram around it (do not use the parallaxes --- just\nleave use the apparent magnitudes). Can you understand its published\nage based on what you see in the diagram? How can you determine what\nin the diagram is from background or foreground stars and what is from\nthe open cluster itself?\n\\item Using Gaia, for a relatively nearby globular cluster, do the\nsame.\n\\item Using Gaia and its high signal-to-noise ratio parallaxes,\nmake a plot of the HR diagram locally. What can you conclude about the\nstar formation history around us in the Milky Way.\n\\item Identify a luminous galaxy on the red sequence at low redshift\n(say $z<0.03$) from the SDSS spectroscopic survey. Then find a star\n(in a low reddening region) with similar $g-r$ colors that has a\nspectrum. Compare the spectra in the rest frame.\n\\end{enumerate}\n\n\\bibliographystyle{apj}\n\\bibliography{exex}  \n", "meta": {"hexsha": "3aea72589aabf66008d991b8ff686cfef19697bd", "size": 14501, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/stellar-evolution-text.tex", "max_stars_repo_name": "blanton144/exex", "max_stars_repo_head_hexsha": "b4d9d52b4fe8af761783f49b2c197a109d94cfdf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/stellar-evolution-text.tex", "max_issues_repo_name": "blanton144/exex", "max_issues_repo_head_hexsha": "b4d9d52b4fe8af761783f49b2c197a109d94cfdf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/stellar-evolution-text.tex", "max_forks_repo_name": "blanton144/exex", "max_forks_repo_head_hexsha": "b4d9d52b4fe8af761783f49b2c197a109d94cfdf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8892405063, "max_line_length": 77, "alphanum_fraction": 0.7682228812, "num_tokens": 3818, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4094552635889504}}
{"text": "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{esvect}\n\\usepackage{graphicx}\n\\usepackage{float}\n\n\n\\usepackage[a4paper]{geometry}\n\\newgeometry{left=2.5cm, right=2.5cm, bmargin=3.5cm}\n\n\\usepackage{enumitem}\n\\setlist{topsep=0pt, itemsep=0pt}\n\n\\parindent 0pt\n\\parskip 8pt\n%\\setlist[itemize]{noitemsep, topsep=0pt}\n%\\usepackage{multicol}\n\n\\usepackage{csquotes}\n\\usepackage{hyperref}\n\\title{Simulating the phototaxis response in C. Elegans}\n\\author{Clemens Hutter \\\\ chutter [at] uos.de}\n\n\n%\\setlist[itemize]{noitemsep, topsep=0pt}\n\n\\begin{document}\n\n\n\n\\maketitle\n\\begin{abstract}\nThe nematode C. elegans will move back once light is shown on its head. This behaviour know as phototaxis was quantified by Ward et al. \\cite{Ward2008}. They looked at the timing (onset and duration) of the backward movement after light stimuli of different intensity and wavelength are applied to the worm. With the final goal to replicate the timings for all nine different stimulus configurations tested in the paper I started out with the arbitrary specific case of 350 nm and an intensity of $-1.73 \\cdot log(\\frac{I}{I_O})$. \nIn this case the backwards movement starts roughly 1.7 seconds after stimulus onset and will last for about 7 seconds \\cite{Ward2008}.\n\\end{abstract}\n\n\\section{Methodology} % (fold)\n\\label{sec:methodolegy}\nI simulated the activity after the stimulus in a simplified neural network \\cite{Appiah} based on the C. elegans connectome and used an evolutionary algorithm to arrive at parameters that replicate the response timing in two target motor neurons. The full source code is available here: https://github.com/rauwuckl/CElegansPhototaxis\n\n\\subsection{Network} % (fold)\n\\label{sub:network}\n\t\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.5\\linewidth]{network}\n\t\\caption{Full inter neural connectivity for the sensory, interneuron and muscle neurons used in our phototaxis model.\n\tIV.}\n\t\\label{fig:network}\n\t\\end{figure}\n\nThe network (Figure \\ref{fig:network}) consists of 4 sensory neurons, 4 interneurons and 2 motor neurons \\cite{Appiah}. All of the neurons are modelled as Izhikevich quadratic integrate-and-fire spiking neural models \\cite{izi}. (with a = 0.02, b= 0.2, c= -65, d= 6). Additionally the 4 sensory neurons receive an additive input current related to surrounding light as \n\\[I_{light} = \\frac{|750- \\lambda| \\cdot (30+i)}{\\lambda}\\]\nwhere $\\lambda$ is the wavelength of light (in this case 350 nm) and $i$ is the intensity (here $10^{-1.73} \\cdot 20 = 0.37$) \\cite{Appiah}.\n\nChemical synapses are modelled as Instantaneous Rise and Single-Exponential Decay synapses:\n\\begin{align*}\n\t\\frac{dg}{dt} &= -\\frac{1}{\\tau}\\cdot g  \\\\\n\tI_{syn} &= w \\cdot g \\cdot (V_{reversal} - V_{post})\n\\end{align*}\nwhere g is the exponentially decaying conductivity which is set to 1 at each arriving presynaptic spike, $\\tau$ is a time constant fixed for all synapses, $w$ is a synaptic strength constant (different value for each synapse), $V_{reversal}$ is the reversal potential ( $-70 mV$ for inhibitory and $0 mV$ for excitatory synapses), $V_{post}$ is the current membrane potential in the postsynaptic neuron and $I_{syn}$ the synaptic current that will be added to the postsynaptic neuron ($g(t) = w \\cdot e ^ {-(t-t_0)/\\tau} $ is an equivalent formulation). If there are connections between 2 neurons going back and forth (eg. ASJ$\\rightarrow$ASK and ASK$\\rightarrow$ASJ) they are explicitly modelled as 2 synapses.  \n\nElectrical synapses are modelled symmetrical as \n\\[I_{syn} = w \\cdot(V_{pre} - V_{post})\\]\nwhere $w$ is again the strength for a given synapse and $V_{pre}/V_{post}$ the membrane potential in the presynaptic/postsynaptic neuron. \n\nThere are 27 chemical and 5 electrical connections (see arrows in Figure \\ref{fig:network}). Each of these connections is formed by different numbers of actual synapses (see numbers in the Figure \\ref{fig:network}). Since we are assuming a global value for $\\tau$ we can (for a given connection between two neurons) just add up all the synaptic currents into one combined synaptic model. The strength of theses `virtual' synapses (simply synapse from now on) will then be proportional to the number of actual synapses (numbers in Figure \\ref{fig:network}). i.e. we have only one `virtual' synapse instead of 12 actual synapses from ASH to AVD but the $w$ for this synapse will be 12 times stronger. \\\\\nTherefore our parameter space consists of 32 synaptic weights plus $\\tau$. These are represented in a 33-dimensional vector $\\vec{w}$ with all elements between 0 and 1. Each value of the parametervector is then mapped into a reasonable range for the corresponding  parameter:\n\\begin{align*}\n\tw^{syn}_i &= | \\vec{w}_i - 0.5 |  \\cdot N^{synapses}_i \\cdot 0.5\\\\ \n\tw^{electrical}_j &= (\\vec{w}_j \\cdot N^{synapses}_j) \\in [0;1] \\\\\n\t\\tau &= \\vec{w}_{33} \\cdot 19 + 0.1 \n\\end{align*}\nChemical synapses are set to excitatory for $\\vec{w}_i \\geq 0.5$ and inhibitory otherwise. Weights for electrical synapses are clipped such that they do not exceed [0:1]. \n\nThe network is implemented for the brian2 simulator in Python.\n\n% subsection network (end)\n\n\\subsection{Parameter finding with evolutionary algorithms} % (fold)\n\\label{sub:parmeter_finding_with_evolutionary_algorithms}\nI was looking for spike patterns in the motor neurons DA and VA that could plausibly cause backwards movement starting 1.7 seconds after stimulus onset and lasting for 7 seconds \\cite{Ward2008}. I argue that this would require them to start spiking before the start of the actual movement and to spike for approximately the same duration as the duration of the backward movement. Furthermore the spiking should be regular. The fitness function derived from these constrains is:\n\\begin{align*}\n differenceStart &= max((FirstSpike - StartResponse),0)^2\\\\\n differenceEnd &= max((LastSpike - EndResponse),0)^2\\\\\n differenceDuration &= ((LastSpike - FirstSpike) - DurationResponse)^2\\\\\n variance &= \\textrm{variance of interspike intervals} \\\\\n fitness &= - (20 \\cdot differeceStart + 20 \\cdot differenceEnd \\\\&+ 20 \\cdot differenceDuration + 25 \\cdot variance)\n\\end{align*}\nwhere the first two terms will only be non-zero if the spiking occurs after the response. The fitness is assessed for DA and VA independently in this way and then summed. \n\nThis fitness function is optimized by the following evolutionary algorithm (adapted from \\cite{Luke2013Metaheuristics}):\n\n\\begin{figure}[H]\n\\includegraphics[width=\\linewidth]{evolution}\n\\caption{Pseudocode for the evolutionary algorithm}\n\\end{figure}\n\n\\textbf{selectParent} draws 2 random individuals from the population with replacement and selects the fitter of the two. The \\textbf{mutate} function simply adds independent Gaussian noise to each element of $\\vec{w}$ ($\\sigma = 0.001$). The \\textbf{crossover} function performs \\textit{Intermediate (Line) Recombination} to produce two children based on two based on two parents:\n\n\\begin{figure}[H]\n\\includegraphics[width=\\linewidth]{lineRecombination}\n\\caption{Pseudocode for Intermidiate Recombination \\cite[p. 42]{Luke2013Metaheuristics}}\n\\end{figure}\n\nThe algorithm is implemented in Python and currently employs a multiprocess architecture to make full use of the strong PC available at the lab. To achieve this the entire population is divided into multiple subsets and the fitness in each subset is evaluated by a different job on a different CPU (Data Parallelism). For machines with only 1 or 2 cores a single threaded architecture might be faster. This can be easily changed in the source code.\n\n% subsection subsection_name (end)'\n\\section{Results} % (fold)\n\\label{sec:results}\nIf no noise is added to the membrane potential of the neurons a very good fit is quite easily achievable. But real neurons will undoubtedly be subject to some noise. In this case the quality of a given parameter set $\\vec{w}$ will vary considerably from run to run. So the fitness function for a given individual (parameter set) is extremely stochastic.\n\nFor this summery I left the evolution running for 82 generations, while evaluating the fitness for each individual at each generation 4 times and averaging over it to achieve a somewhat reliable value. \nThen I simulated the network for the fittest individual nine times to give a rough idea of the different activity patterns that arise. \n\n\\begin{itemize}\n\t\\item In the best case scenario the network very precisely replicated the response timing (Figure \\ref{fig:optimalRun}). \n\t\\item The most common outcome however can be seen in Figure \\ref{fig:noStop}. Here the network starts spiking but does not calm back down to rest within the simulation time of 10.5 seconds. \n\t\\item Also common is that the response will last exactly as long as the stimulus exiting the network (Figure \\ref{fig:imideateStop}).\n\\end{itemize}\n\n\n\\begin{figure}[H]\n\\includegraphics[width=\\linewidth]{perfect}\n\\caption{Trace of optimal run. (3 out of 9 runs with response durations of 7.0, 7.1 and 6.0 seconds)}\n\\label{fig:optimalRun}\n\\end{figure}\n\\begin{figure}[H]\n\\includegraphics[width=\\linewidth]{noStop}\n\\caption{Most common trace. Spiking does not stop. (5 out of 9 runs)}\n\\label{fig:noStop}\n\\end{figure}\n\\begin{figure}[H]\n\\includegraphics[width=\\linewidth]{imideateStop}\n\\caption{Spiking stops immediately. (1 out of 9 runs)}\n\\label{fig:imideateStop}\n\\end{figure}\n\n\\section{Discussion} % (fold)\n\\label{sec:discussion}\nI believe that the target response we are trying to achieve within the network is very unstable. The network has to get excited by external input which then is turned off after which the spiking response must not change. Then it has to stay excited for a set amount of time and after that it autonomously has to calm down without any change in input. \\\\\nThis I think happens once a short interval occurs in which all neurons in the highly recursive network are \\textit{`by chance'} in their refractory period. Then the self sustaining circle of excitation is stopped and the activity fades away. But as soon as we add even a little noise the exact spike times of all neurons will be shifted a little against each other. The interval of accidental silence can now occur at a completely different time (or not at all). Because of this intuition I figure that it is impossible to find parameters which are able to reproduce the behaviour reliable over multiple runs. \n\nAlso it is still unclear how higher activity in those two motorneurons actually relates to backward movement. \n\n\\small{Disclaimer: \\textit{What is referred to as neurons (DMA, AVA, etc.) in this paper are actually neuron classes.}}\n\n\\bibliographystyle{unsrt}%alternative alpha\n\\bibliography{bibliography}\n\n\\end{document}\n\n\n\n\n", "meta": {"hexsha": "121ace89215416709902de9a7926f31803b65d20", "size": 10703, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/doc.tex", "max_stars_repo_name": "rauwuckl/CElegansPhototaxis", "max_stars_repo_head_hexsha": "f9ce7fd47a2419a9f539ed8186d03d1dbdf90724", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/doc.tex", "max_issues_repo_name": "rauwuckl/CElegansPhototaxis", "max_issues_repo_head_hexsha": "f9ce7fd47a2419a9f539ed8186d03d1dbdf90724", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/doc.tex", "max_forks_repo_name": "rauwuckl/CElegansPhototaxis", "max_forks_repo_head_hexsha": "f9ce7fd47a2419a9f539ed8186d03d1dbdf90724", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.608974359, "max_line_length": 713, "alphanum_fraction": 0.7743623283, "num_tokens": 2755, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.40945526358895024}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{mathtools}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\M}{\\mathcal{M}}\n\\newcommand{\\degrees}{^{\\circ}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 74, Week 10}\n\\maketitle\n\n\\section{Mon Lec, 6c}\n$$z^{n-1}-1 = \\prod_{k=0}^{n-1}(z-\\omega_k)$$\nAs shown in class, the complex roots are evenly spaced across the unit circle, $2\\pi/n$ apart. So we have\n$$\\omega_k = e^{2\\pi i \\frac{k}{n}}$$\n\n\n\\section{Mon Lec, 6f}\n$$(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1) = (z^n+z^{n-1}+...+z^2+z)-(z^{n-1}+z^{n-2}+...+z+1)=z^n-1$$\nTherefore we can switch our statement to $\\frac{z^n-1}{z-1}$\n\\newline\nNow we subsitute our answer from the previous question in, and since $\\omega_0=1$, it cancels out with the first term.\n\\newline\nWe can factor the expression into\n$$\\prod_{k=1}^{n-1}(z-\\omega_k)$$\nwhere\n$$\\omega_k = e^{2\\pi i \\frac{k}{n}}$$\nEssentially the same as 6c but with $z=1$ removed.\n\n\n\\section{Mon Lec, 7b}\n\n\\subsection{6c}\nSum: $-\\frac{0}{1}=0$\n\\newline\nProduct: $(-1)^n\\frac{1}{1} = (-1)^n$\n\n\\subsection{6f}\nSum: $-\\frac{1}{1}=-1$\n\\newline\nProduct: $(-1)^n\\frac{0}{1} = 0$\n\\newpage\n\n\n\\section{Mon Dis, 1a}\n$$|A_0A1|...|A_0A_8|=\\prod_{k=0}^{8}|1-\\omega_k|=|\\prod_{k=0}^{8}(1-\\omega_k)|$$\nThe last equivalency is due the fact that multiplication of the modulus is equal to the modulus of the product.\n\\newline\nWe have proven above that $(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1)=z^n-1$, so consider\n$$\\frac{z^n-1}{z-1}=\\frac{(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1)}{z-1}=z^{n-1}+z^{n-2}+...+z^{2}+z+1$$\nNow using the roots of the polynomial we know that $z^9-1=(z-1)(z-\\omega)...(z-\\omega^8)$, in this case we have divided out $z-1$, so we have\n$$z^8+z^7+...+1=(z-\\omega)...(z-\\omega^8)$$\nLet $z=1$, and we have $9=(z-\\omega)...(z-\\omega^8)$, since $|9|=9$, we have shown that $|A_0A1|...|A_0A_8|=9$\n\n\n\\section{Mon Dis, 3f}\nLet $x=y-2$, so $x^3=y^3-6y^2+12y-8$. Now we plug $y$ back\n$$y^3-6y^2+12y-8 = -6(y-2)^2-12y+24-6$$\n$$y^3-6y^2+12y-8 = -6y^2+12y-6$$\n$$y^3 = 2$$\nNow since we know that $2^3=8$, we can directly solve:\n$y_1= \\sqrt[3]{2}, x_1=\\sqrt[3]{2}+2$\n\\newline\nThen we factor $(y^3)/(y-\\sqrt[3]{2})=y^2+\\sqrt[3]{2}y+\\sqrt[3]{4}$ Now we apply the quadratic formula to get\n$$y_2=\\frac{-1-\\sqrt3i}{\\sqrt[3]{2}}, y_3=\\frac{-1+\\sqrt3i}{\\sqrt[3]{2}}$$\nSo we have $x_2=\\frac{-1-\\sqrt3i}{\\sqrt[3]{2}}-2, x_3=\\frac{-1+\\sqrt3i}{\\sqrt[3]{2}}-2$\n\n\\end{document}\n", "meta": {"hexsha": "782034e05b1caa53a2345f4c07b7086c1034726a", "size": 2994, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week10/main.tex", "max_stars_repo_name": "TianshuangQiu/Math74-Homework", "max_stars_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week10/main.tex", "max_issues_repo_name": "TianshuangQiu/Math74-Homework", "max_issues_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week10/main.tex", "max_forks_repo_name": "TianshuangQiu/Math74-Homework", "max_forks_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4137931034, "max_line_length": 141, "alphanum_fraction": 0.6362725451, "num_tokens": 1302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.7879311931529758, "lm_q1q2_score": 0.4093470550741239}}
{"text": "\\newpage\n\\input{Title}\n\\section{Blocks and Community structure}\n\n\\begin{textbox}{Blocks and Communities: Definition}\nThe general idea of blocks and communities is that nodes of a network can be grouped together in homogeneous sets, based on the network topology. The problem of automatically discovering those groups is one of the most studied problem of network science, but also one of the most poorly defined.\n\n\\end{textbox}\n\n\\begin{textbox}{Block structure}\nThe general idea of the block structure is that the probability to observe an edge between two nodes is a function of the blocks they belong to. Usually, no assumption is made apriori about those probabilities: they can be high between nodes belonging to the same blocks or to different blocks, and can differ for each pair of block.\n\nThis definition thus defines a random graph model, related to the ER random model, known as the \\textbf{Stochastic block model}. \n\\end{textbox}\n\n\\begin{textbox}{Community structure}\nThe idea of having a network structured in \\textbf{communities} is defined as an analogy with communities in social networks. Communities are therefore defined (informally) as groups of nodes that are strongly connected between themselves (\\textbf{high internal density}) and more weakly connected to the rest of the network \\textbf{low external density}.\n\nThis definition however cannot be translated unambiguously into a mathematical formulation. The problem of \\textbf{community detection}, or community discovery, is therefore complicated to define.\n\\end{textbox}\n\n\\begin{textbox}{Partitions/Overlap}\nWe must differentiate two types of node grouping: \n\\begin{enumerate}\n    \\item A \\textbf{Partition} of a graph is a division of its nodes such as each of them belong to one and only one group.\n    \\item Overlapping communities/blocks allow, on the contrary, nodes belonging to several groups. Unless specified differently, they also allow nodes to belong to no group.\n\\end{enumerate}\nAlgorithms searching partitions are much more common than those searching for overlapping groups, due to the increased complexity of the later task. Overlapping community detection is, nevertheless, an active field of research.\n\\end{textbox}\n\n\\begin{textbox}{Definition}\n\\begin{tabular}{p{0.08\\textwidth}|p{0.8\\textwidth}}\\scriptsize\n\n$C$ & a \\textit{community partition}, or, more generally, a set of set of nodes \\\\\n$c_i$ & community $i$, a set of nodes \\\\\n\\end{tabular}\n\\end{textbox}\n\n\n\\begin{textbox}{Modularity}\nThe most famous quality function to measure the \\textit{quality} of partitions is called the \\textbf{Modularity}. Introduced in \\footcite{girvan2002community}, it is defined for a partition $C$ and a graph $G$ as the difference between the fraction of observed internal edges and the expected fraction of internal edges if $G$ were rewired according to a configuration model, i.e., preserving the degrees of nodes.\n\nMore formally, \n\\[\nQ=\\frac{1}{L}\\sum_{i=1}^{|C|}(L_{i}-\\frac{1}{2}K_i^2)\n\\]\nwith $L_{i}=L(H(c_i))$ the number of edges inside community $i$ and $K_i=\\sum_{u \\in c_i}k_u$ the sum of degrees of nodes in community $i$.\n\nThe original formulation of modularity, often found in the literature, is:\n\\[\nQ=\\frac{1}{2L}\\sum_{uv}\\left[ A_{uv}-\\frac{k_uk_v}{2L}\\right] \\delta(c_u,c_v)\n\\]\nwith $\\delta(c_u,c_v)$ the kronecker delta between communities, i.e., $\\delta(c_u,c_v)=1$ if nodes $u$ and $v$ belongs to the same community, 0 otherwise.\n\n\n\\end{textbox}\n\n\\begin{textbox}{Modularity: null model}\nThe modularity as expressed above compares the number of edges inside communities to the expected number of edges in a \\textbf{null model}, i.e., a randomized version of the graph. In the original version, this null model is the \\textbf{configuration model} (as easily recognized in the $\\frac{k_uk_v}{2L}$ of the original formula-.\n\nVariants of the modularity have been proposed using different null models \\footcite{jutla2011generalized}, for instance an ER null model, or a gravity model to take into account the effect of physical distance \\footcite{expert2011uncovering}\n\\end{textbox}\n\n\\begin{textbox}{Modularity: null model}\nThe modularity as expressed above compares the number of edges inside communities to the expected number of edges in a \\textbf{null model}, i.e., a randomized version of the graph. In the original version, this null model is the \\textbf{configuration model} (as easily recognized in the $\\frac{k_uk_v}{2L}$ of the original formula-.\n\nVariants of the modularity have been proposed using different null models \\footcite{jutla2011generalized}, for instance an ER null model, or a gravity model to take into account the effect of physical distance \\footcite{expert2011uncovering}\n\\end{textbox}\n\n\\begin{textbox}{Modularity: resolution limit}\nIt is important to remember that the Modularity is (only a) \\textbf{quality function}, not a definition of the quality of communities. An important drawback is known as the \\textbf{limit of resolution}\\footcite{fortunato2007resolution}. It says that partitions of maximal modularity are biased toward a particular \\textit{scale}, i.e., for a graph of a give size (\\#nodes, \\#edges), communities smaller or larger than a certain size cannot be found. The typical example of this limit is the clique-ring structure (set of cliques connected by a single edge), in which the expected partition is to have one community by clique, while the solution of highest modularity put several cliques in the same community, when we increase the number of cliques.\n\n\\includegraphics[width=0.7\\textwidth]{ringclique.png}\n\\end{textbox}\n\n\\begin{textbox}{Modularity and random networks}\nAnother well known limitation of a Modularity maximization approach is that it finds communities with high scores in random networks: since it is not \\textit{adjusted for chance}, random flucutations in a random network are mistaken for meaningful structure in the network.\n\\end{textbox}\n\n\\begin{textbox}{Multi-resolution Modularity}\nA simple solution has been proposed to the limit of resolution, consisting in adding a resolution parameter $\\lambda$ to \\textit{tune} the desired resolution\\cite{reichardt2006statistical}, i.e., $(L_{i}-\\frac{1}{2}K_i^2)$ becomes $(L_{i}-\\lambda \\frac{1}{2}K_i^2)$. It raises of shrink the expected number of edges inside communities. It requires, however, to choose a proper value for $\\lambda$, i.e., to choose arbitrarily a scale for communities.\n\\end{textbox}\n\n\\begin{textbox}{Modularity maximization: Girvan Newman}\nSeveral of the most popular community detection algorithms have as objective to discover the partition of highest modularity. This is a difficult problem, and thus existing approaches are based on heuristics. \n\nThe first method by Girvan and Newman \\footcite{girvan2002community} first build a dendromgram by iteratively removing edges of highest betweenness. It is called a \\textit{divise} approach: At the top of the dendrogram, there is a single community, then 2, 3, 4 etc., until each node is in its own community. Modularity is used as a criterium to \\textit{cut} the dendrogram. \n\n\\centering\n\\includegraphics[width=0.7\\textwidth]{dendrogram.jpg}\n\n\\end{textbox}\n\n\\begin{textbox}{Modularity maximization: Louvain method}\nThe Louvain method\\footcite{blondel2008fast} is certainly the most used method for community detection. Its objective is to optimize the modularity using a greedy, agglomerative approach, composed of two steps: \n\n\\textbf{Step 1}: Optimizing modularity at a hierarchical level\n\\begin{itemize}\n    \\item Each node starts in its own community\n    \\item Repeat until convergence:\n    \\begin{enumerate}\n        \\item \\textbf{FOR} each node, compute the gain in modularity of adding it to the community of each of its neighbors\n        \\item choose the decision that increase the most the modularity (the best decision can be to remain in the same community\n    \\end{enumerate}\n\\end{itemize}\n\n\\textbf{Step 2}: Global algorithm\n\\begin{itemize}\n    \\item Repeat until convergence:\n    \\begin{enumerate}\n        \\item Optimize modularity for the current hierarchical level\n        \\item Move to a higher hierarchical level by computing an \\textbf{induced network}: Each community becomes a node, the weight of the edge between nodes/communities $i$ and $j$ corresponds to the number of edges between nodes of $c_i$ and nodes of $c_j$.\n    \\end{enumerate}\n\\end{itemize}\n\nThe result of Louvain algorithm is therefore a \\textbf{hierarchy} of communities. \n\nThe main reason explaining the popularity of the Louvain method to this day is its\n   \\textbf{scalability}: The algorithm is very efficient in practice on real graphs, for several reasons: 1)It is a greedy approach,2) By checking only the interest of moving to neighbor's communities, it benefits from the sparsity of networks, 3)Modularity gains of a partition change can be computed locally, using its definition as a sum of independent values for each community.\n\n\\end{textbox}\n\n\n\\begin{textbox}{Infomap}\nInfomap\\cite{rosvall2008maps} is a method based on an objective function different from the Modularity. Its objective is to \\textbf{Minimize the description of an average random walk} in the network, i.e. maximize the \\textbf{compression} of the description of such a walk. More formally, the code length to minimize for partition $M$ is described as:\n\\[\nH(M)=qH(\\curvearrowright)+\\sum_i^Cp^iH(\\circlearrowright_i)\n\\]\nwith $q$ the probability for a move to be between modules,$H(\\curvearrowright)$ the information required to encode a move between modules, $p^i$ the probability for a move to be inside community $i$ and $H(\\circlearrowright_i)$ the information required to encode a move inside community $i$\n\nA greedy optimization algorithm, similar in nature to the one of Louvain, is then used to minimize this description length.\n\nCompared with Modularity, the main advantage of this approach is that it does not find communities in random networks. It is known also to suffer from a resolution limit, although not exactly similar to the one of Modularity.\n\\end{textbox}\n\n\\begin{textbox}{Stochastic Block Models (SBM)}\nA stochastic block model is a random graph model defined by:\n\\begin{itemize}\n\\item $k$: number of blocks \n    \\item $b$ a $n\\times 1$ vector such as $b_i$ describes the index of the block of node $i$.\n    \\item $E$ a $k\\times k$ \\textbf{stochastic block matrix}, such as $E_{ij}$ gives the number of edges between blocks $i$ and $j$ (or equivalently, the probability to observe an edge between any pair of nodes chosen with one node in each of the two blocks).\n\\end{itemize}\n\\end{textbox}\n\n\\begin{textbox}{SBM inference}\nThe objective of a community/block detection algorithm based on this principle is thus to perform \\textbf{SBM inference}, i.e., to find the parameters of the SBM that best explain the observed graph, usually in term of maximizing the likelihood. Said differently, we search --among a certain class of models-- the model that has the highest probability to generate the observed graph. Note that for an observed graph, for each partition in blocks $b$, there is a single block matrix $E$ that is relevant to consider, that can be found simply by counting the number of edges actually present between blocks in the graph.  \n\nMore formally, the objective is:\n\\[\nb:=\\argmax_{b} P(A|b)\n\\]\n\nNote that with this formulation, it is not possible to infer the number of clusters $k$, since the trivial solution in which each node belongs to its own block, with $E=A$ has a maximal probabity (1) to generate the observed graph. The desired number of clusters is thus a necessary parameter of SBM inference.\n\\end{textbox}\n\n\n\n\n\n\n\\begin{textbox}{SBM with inference of the number of blocks}\nRecently, new approaches\\footcite{peixoto2019bayesian} have been proposed to be able to infer also the number of blocks. They adopt an approach from Information Theory called the Minimum Description Length (MDL), whose principle is to find the description which reduces the total cost of describing a graph, by minimizing both 1)The quantity of information needed to encode the graph, knowing that it is generated by a given model, and 2)The quantity of information needed to encode the model itself. Intuitively, a model with few blocks requires little information to be described, contrary to a model with many blocks. But a model with many block is more \\textbf{constrained}, the graphs it generates are more \\textit{specific}, and therefore can be described at a lesser cost, knowing the model.\n\nMore formally, we can decompose the probability of observing a graph and a model as $P (A, k, e, b) = P (A|k, e, b)P (k|e, b)P (e|b)P (b)$ with the last three probability being \\textit{priors}.  Said differently, we can define the number of bits required to encode a model as $L = -log_2 P(k,b)$, the number of bits necessary to encode a graph knowing the model as $S = -log_2 P(A|k,b)$ and thus the total cost to minimize as $S+L$. The objective thus becomes:\n\\[\nb:=\\argmin_{b} - log_2 P(k,b) - log_2 P(A|k,b)\n\\]\n\n\\end{textbox}\n\n\n\n\n\n\\begin{textbox}{Variants of the SBM}\nGroup inference using SBM is a very active field of research, and many variants have been proposed, including degree-corrected, nested, Overlapping, Mixed membership SBM, etc.\n\nAn introduction to the state of the art can be found for instance in \\footcite{lee2019review}.\n\nA python library \\footnote{https://graph-tool.skewed.de} exists to apply recent methods to observed graphs.\n\\end{textbox}\n\n\n\n\\begin{textbox}{Evaluation of Community structures}\nSince there isn't a unique accepted definition of what are good communities, the evaluation of the quality of a partition or set of communities is not a trivial task. \n\nThere are two main approaches:\n\\begin{itemize}\n    \\item \\textbf{Internal evaluation} consists in using \\textit{quality functions} (e.g., Modularity) to give a score for a pair partition-graph\n    \\item \\textbf{External evaluation} consists in comparing a computer partition to a \\textbf{ground truth} reference partition.\n\\end{itemize}\n\\end{textbox}\n\n\\begin{textbox}{Internal Evaluation}\nSeveral quality functions exist to evaluation the quality of a community partition of a graph. They can therefore be understood as different \\textit{definitions} of communities. While some methods try directly to optimize one of those quality functions, some other methods are based on different principles (e.g., clique-based communities, consensus reaching based on game-theory, etc.). Quality functions can therefore be used a posteriori to assess the quality of communities they found. \n\nThe most popular are:\n\\begin{itemize}\n    \\item \\textbf{Modularity}\n    \\item \\textbf{Information compression}, as in Infomap or SBM\n    \\item \\textbf{Surprise} \\cite{aldecoa2013surprise} evaluates the departure of the observed partition from the expected distribution of nodes and links into communities given a null model, and is therefore related to modularity \n\\end{itemize}, Conductance, , cut-ratio, and Surprise.\n\nSome other quality functions are defined \\textbf{for individual communities}, although they can be combined to provide a global score. The most popular are\\footnote{leskovec2010empirical}:\n\\begin{itemize}\n    \\item \\textbf{Conductance}, the fraction of all stubs of nodes in the community that points outside of it\n    \\item \\textbf{ODF}, Out Degree Fraction, the average for every node of its fraction of neighbors inside the community\n    \\item \\textbf{Internal Transitivity}, the clustering coefficient inside the community\n    \\item \\textbf{Scaled density}, the ratio of the node density to the total graph density\n\\end{itemize}\n\n\n\\end{textbox}\n\n\\begin{textbox}{External Evaluation}\nPartitions obtained by a given method can be compared with a ground truth. This approach is used on real networks, with a ground truth coming from metadata (e.g., classes in a network of social interactions between students), and on synthetic networks, with communities known by construction.\n\nAlthough this is still discussed in the literature, it is mostly accepted that the evaluation on real networks using this approach is problematic\\footcite{peel2017ground}, because there is no guarantee that the labels used as ground truth are indeed related to the \\textbf{topological structure} of the network, which is what communities are about.\n\nMost popular methods for partitions comparisons are:\n\\begin{itemize}\n\\item \\textbf{NMI}, Normalized Mutual Information, and its adjusted for chance variant, \\textbf{AMI}.\n\\item \\textbf{ARI}, Adjusted Rand Index\n\\end{itemize}\nBut more generally, any method for cluster comparison can be used\\footcite{dao2020community}\n\\end{textbox}\n\n\n\\begin{textbox}{Overlapping communities}\nFor many types of networks, the real organization of networks is thought to be overlapping, i.e., each node can belong to several communities. Think of your personal social networks: some of your family members might also be part of a group of friends, or some of your friends from high school might also be part of your friends from university, which are otherwise distinct groups. \n\nDetecting overlapping clusters is considered harder than non-overlapping ones, for two reasons: the search space (number of possible solutions) is much larger (and even infinite), and defining what good communities are is even harder, since there isn't the natural limit for each edge to be either internal or external.\n\nA large number of methods have nevertheless been proposed\\footcite{xie2013overlapping}. Extensions of non-overlapping quality functions have been proposed, such as the overlapping Modularity \\footcite{nicosia2009extending}, or overlapping NMI \\footcite{mcdaid2011normalized}.\n\\end{textbox}\n\n\\begin{textbox}{Other meso-scale structures}\nBeyond the community structures we have alredy defined, other types of network structural organization have been proposed and studied. Some of the most widely known are:\n\\begin{itemize}\n    \\item \\textbf{Link communities}, in which communities are defined as \\textit{sets of links}. Searching for (non-overlapping) partitions of edges yield a structure in which nodes naturally belong to several groups, i.e., a community can correspond to \\textit{familial} edges, another to \\textit{professional} edges, etc. (\\cite{ahn2010link})\n    \\item \\textbf{Fuzzy communities}, in which nodes belong to (often several) communities with a certain probability or strength (\\cite{liu2010fuzzy})\n    \\item \\textbf{Core-Periphery structure}, already defined when we introduce the notion of \\textit{k-cores}\n    \\item \\textbf{Nestedness}, corresponding to a network with a hierarchical organization such as elements with few connections tends to be connected to a subset of the neighbors of a \\textit{parent} node. (\\cite{pawar2014plant})\n    \\item \\textbf{Spatial organization}, in which the probability of observing an edge between nodes depends on their distance. (\\cite{barthelemy2011spatial})\n\\end{itemize}\n\\end{textbox}", "meta": {"hexsha": "04e21c32867448e5c86ed1d4bb34547168858fd7", "size": 18930, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "latex_sources/old/comolds.tex", "max_stars_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_stars_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2022-01-26T06:33:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T23:25:49.000Z", "max_issues_repo_path": "latex_sources/old/comolds.tex", "max_issues_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_issues_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "latex_sources/old/comolds.tex", "max_forks_repo_name": "Yquetzal/NetworkScience_CheatSheets", "max_forks_repo_head_hexsha": "0e5e7680504599b1a88c0bb0043803c06e0e110b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.6396761134, "max_line_length": 798, "alphanum_fraction": 0.7830427892, "num_tokens": 4483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.787931185683219, "lm_q1q2_score": 0.40934705119342596}}
{"text": "% Created 2021-11-15 Mon 07:24\n% Intended LaTeX compiler: pdflatex\n\\documentclass[presentation,aspectratio=1610]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\DeclareMathOperator{\\shift}{q}\n\\DeclareMathOperator{\\diff}{p}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{\\today}\n\\title{Discretizing continuous-time controllers}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Discretizing continuous-time controllers},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.4.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\n\\section{Intro}\n\\label{sec:org9a2e388}\n\n\\section{Discretization}\n\\label{sec:orgee27423}\n\\begin{frame}[label={sec:orgd3c4ac1}]{Context}\n\\begin{itemize}\n\\item Controller \\(F(s)\\) obtained from a design in continuous time.\n\\end{itemize}\n\\pause\n\\begin{itemize}\n\\item Need discrete approxmation in order to implement on a computer\n\\end{itemize}\n\n\\begin{center}\n \\includegraphics[width=0.7\\linewidth]{../../figures/fig8-1.png}\\\\\n \\footnotesize Source: Åström \\& Wittenmark \n\\end{center}\n\\end{frame}\n\n\\section{Implementation}\n\\label{sec:orgdbdfb7b}\n\\begin{frame}[label={sec:org852548e}]{Stability for the disk drive arm}\n\\small \nCase \\(\\frac{h^2}{J} = 1\\). Suggested controller:\n\n\\begin{center}\n\\begin{tikzpicture}\n\\tikzset{node distance=2cm, \n    block/.style={rectangle, draw, minimum height=12mm, minimum width=14mm},\n    sumnode/.style={circle, draw, inner sep=2pt}        \n}\n\n  \\node[coordinate] (input) {};\n  \\node[block, right of=input] (TR) {$F_f(z) = 0.2K$};\n  \\node[sumnode, right of=TR, node distance=30mm] (sum) {\\tiny $\\sum$};\n  \\node[block,right of=sum, node distance=30mm] (plant) {$H(z) = \\frac{z+1}{2(z-1)^2}$};\n  %\\node[sumnode, right of=plant, node distance=30mm] (sumdist) {$\\sum$};\n  %\\node[coordinate, above of=sumdist, node distance=15mm] (dist) {};\n  %\\node[coordinate, right of=sumdist, node distance=15mm] (measure) {};\n  \\node[coordinate, right of=plant, node distance=30mm] (output) {};\n  \\node[coordinate, right of=plant, node distance=22mm] (measure) {};\n  %\\node[sumnode,below of=measure, node distance=25mm] (sumnoise) {$\\sum$};\n  %\\node[coordinate, right of=sumnoise, node distance=15mm] (noise) {};\n  \\node[block,below of=plant, node distance=20mm] (SR) {$F_b(z)=K\\frac{z-0.8}{z}$};\n  \\draw[->] (input) -- node[above, pos=0.2] {$y_{ref}(k)$} (TR);\n  \\draw[->] (TR) -- node[above] {$u_1(k)$} (sum);\n  \\draw[->] (sum) -- node[above] {$u(k)$} (plant);\n  \\draw[->] (plant) -- node[at end, above] {$y(k)$} (output);\n  \\draw[->] (measure) |- (SR);\n  \\draw[->] (SR) -| (sum) node[right, pos=0.8] {$u_2(k)$} node[left, pos=0.96] {$-$};\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\section{Preliminaries}\n\\label{sec:orga443f1b}\n\\begin{frame}[label={sec:orgdde3b0a}]{Preliminaries}\n\\end{frame}\n\n\n\\begin{frame}[label={sec:org3c5baf1}]{Z-transform of a shifted sequence}\n\\[ x(k) \\quad  \\overset{\\mathcal{Z}}{\\longleftrightarrow} \\quad X(z)= \\sum_{k=0}^{\\infty} x(k)z^{-k} \\] \n\\pause\n\\[ x(k+1) \\quad  \\overset{\\mathcal{Z}}{\\longleftrightarrow} \\quad zX(z) - zx(0)\\]\n\n\\pause\n\\begin{block}{Proof}\n\\begin{align*} \\ztrf{x(k+1)} &= \\sum_{k=0}^{\\infty} x(k+1)z^{-k} = \\sum_{n=1}^{\\infty} x(n)z^{-(n-1)}\\\\\n&=  \\sum_{n=1}^{\\infty} x(n)z^{-n}z = -zx(0) + z\\underbrace{\\sum_{n=0}^{\\infty} x(n)z^{-n}}_{X(z)}\\\\\n&= zX(z) - zx(0).\n\\end{align*}\n\\end{block}\n\\end{frame}\n\n\\begin{frame}[label={sec:org207d837}]{Discrete-time delay}\n\\[ x(k-1) \\quad  \\overset{\\mathcal{Z}}{\\longleftrightarrow} \\quad \\frac{1}{z}X(z))\\]\n\\end{frame}\n\n\n\\begin{frame}[label={sec:orge29d69a}]{Stability for the disk drive arm}\n\\small \nCase \\(\\frac{h^2}{J} = 1\\). Suggested controller:\n\n\\begin{center}\n\\begin{tikzpicture}\n\\tikzset{node distance=2cm, \n    block/.style={rectangle, draw, minimum height=12mm, minimum width=14mm},\n    sumnode/.style={circle, draw, inner sep=2pt}        \n}\n\n  \\node[coordinate] (input) {};\n  \\node[block, right of=input] (TR) {$F_f(z) = 0.2K$};\n  \\node[sumnode, right of=TR, node distance=30mm] (sum) {\\tiny $\\sum$};\n  \\node[block,right of=sum, node distance=30mm] (plant) {$H(z) = \\frac{z+1}{2(z-1)^2}$};\n  %\\node[sumnode, right of=plant, node distance=30mm] (sumdist) {$\\sum$};\n  %\\node[coordinate, above of=sumdist, node distance=15mm] (dist) {};\n  %\\node[coordinate, right of=sumdist, node distance=15mm] (measure) {};\n  \\node[coordinate, right of=plant, node distance=30mm] (output) {};\n  \\node[coordinate, right of=plant, node distance=22mm] (measure) {};\n  %\\node[sumnode,below of=measure, node distance=25mm] (sumnoise) {$\\sum$};\n  %\\node[coordinate, right of=sumnoise, node distance=15mm] (noise) {};\n  \\node[block,below of=plant, node distance=20mm] (SR) {$F_b(z)=K\\frac{z-0.8}{z}$};\n  \\draw[->] (input) -- node[above, pos=0.2] {$y_{ref}(k)$} (TR);\n  \\draw[->] (TR) -- node[above] {$u_1(k)$} (sum);\n  \\draw[->] (sum) -- node[above] {$u(k)$} (plant);\n  \\draw[->] (plant) -- node[at end, above] {$y(k)$} (output);\n  \\draw[->] (measure) |- (SR);\n  \\draw[->] (SR) -| (sum) node[right, pos=0.8] {$u_2(k)$} node[left, pos=0.96] {$-$};\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\n\n\n\\section{Warm-up: Differentiation}\n\\label{sec:orge452f6d}\n\n\\begin{frame}[label={sec:org21c3107}]{Differentiation}\n\\begin{center}\n\\includegraphics[width=0.5\\linewidth]{../../figures/block-simple-derivative}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:orgcb70291}]{Discrete-time differentiation}\n\\begin{columns}\n\\begin{column}{0.4\\columnwidth}\n\\vspace*{5mm}\n\n\\includegraphics[width=\\linewidth]{../../figures/block-simple-discrete-derivative-fwd-z}\n\n\\textcolor{white}{Space}\n\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/block-simple-discrete-derivative-z}\n\\end{center}\n\n\\alert{Activity} Write as difference equation \\[ y(kh) = \\] \n\\end{column}\n\\begin{column}{0.6\\columnwidth}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\n\\section{Implementing the}\n\\label{sec:org6dea8f3}\n\\section{Discretization}\n\\label{sec:org49d922d}\n\\begin{frame}[label={sec:org2985245}]{Discretization methods}\n\\begin{enumerate}\n\\item Forward difference. Substitute \n\\[ s = \\frac{z-1}{h} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{h}}. \\]\n\\item Backward difference. Substitute \n\\[ s = \\frac{z-1}{zh} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{z-1}{zh}}. \\]\n\\end{enumerate}\n\\end{frame}\n\\begin{frame}[label={sec:orge7a582c}]{Discretization methods, contd.}\n\\begin{enumerate}\n\\setcounter{enumi}{2}\n\\item Tustin's method (also known as the bilinear transform). Substitute\n\\[ s = \\frac{2}{h}\\frac{z-1}{z+1} \\] in \\(F(s)\\) to get\n\\[ F_d(z) = F(s')|_{s'=\\frac{2}{h}\\cdot \\frac{z-1}{z+1}}. \\]\n\\item Ramp invariance. This is similar to ZoH, which is step-invariant approximation. \nSince a unit ramp has z-transform \\(\\frac{zh}{(z-1)^2}\\) and Laplace-transform \\(1/s^2\\),  the discretization becomes\n\\[ F_d(z) = \\frac{(z-1)^2}{zh} \\ztrf{\\laplaceinv{\\frac{F(s)}{s^2}}}. \\]\n\\end{enumerate}\n\\end{frame}\n\n\\begin{frame}[label={sec:org4083e78}]{Frequency warping using Tustin's}\n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{../../figures/fig8_3.png}\n\\end{center}\nThe infinite positive imaginary axis in the s-plane is mapped to the finite-length upper half of the unit circle in the z-plane.\n\\end{frame}\n\\begin{frame}[label={sec:org76d75fe}]{Forward difference exercise}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/forward-diff-exercise}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label={sec:org2f76a46}]{Backward difference exercise}\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/backward-diff-exercise}\n\\end{center}\n\\end{frame}\n\\end{document}", "meta": {"hexsha": "e1cb74533a9eaa0e5da603943e4e7fbab90a7db9", "size": 7831, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "discrete-time-systems/slides/discretize-trf.tex", "max_stars_repo_name": "kjartan-at-tec/mr2025", "max_stars_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "discrete-time-systems/slides/discretize-trf.tex", "max_issues_repo_name": "kjartan-at-tec/mr2025", "max_issues_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "discrete-time-systems/slides/discretize-trf.tex", "max_forks_repo_name": "kjartan-at-tec/mr2025", "max_forks_repo_head_hexsha": "88c28aa76e84890c25d252167e5bbcd25318463e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8044444444, "max_line_length": 128, "alphanum_fraction": 0.6748818797, "num_tokens": 2840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.40928595769853765}}
{"text": "\\chapter{Gradual Typing Meets Dependent Types}\n\\label{chap:gradual-dependent}\n\n\\margintoc\n\nBefore diving into what \\kl{GCIC} is about, let me first say what it is not about.\nThe aim is not to put forth a unique design or solution,\nbut rather to explore the space of possibilities.\nNor is it about a concrete implementation of gradual \\kl{CIC} and an evaluation of its\napplicability; these are challenging perspectives of their own,\nwhich first require the theoretical landscape to be unveiled.\nRather, I believe that studying the gradualization of a full-blown dependent type theory\nlike \\kl{CIC} is in and of itself a valuable scientific endeavour,\nwhich is very likely to inform the gradual typing research community in its drive towards\nsupporting ever more challenging typing disciplines.\n\nThis being said, we can still highlight some practical motivating scenarios\nfor gradualizing \\kl{CIC},\nanticipating what could be achieved in a hypothetical gradual version of \\eg \\kl{Coq}.\n\n\\subsection{Smoother development with indexed types}\n  \\label{sec:indices}\n  \nDependent type systems such as \\kl{CIC}, which underpin languages and\nproof assistants such as \\kl{Coq},\n\\kl{Agda} and \\kl{Idris}, among others, are very powerful system to program in,\nbut at the same time extremely demanding.\nMixing programs and their specifications is attractive, but challenging.\n\nConsider the example of the vector type $\\Vect(A,n)$ as defined in \\cref{sec:tech-cic}.\nIn \\kl{Coq}, its definition is the following:\n\n\\begin{coqcode}\nInductive vec (A : Type) : ℕ -> Type :=\n| nil  : vec A 0\n| cons : A -> forall n : ℕ, vec A n -> vec A (S n).\n\\end{coqcode}\n\nIndexing the inductive type by its length allows us to define a \\emph{total}\n\\coqe{head} function, which can only be applied to non-empty vectors:\n\\begin{coqcode}\n  head : forall A n, vec A (S n) -> A\n\\end{coqcode}\n  \nDeveloping functions over such structures can be tricky. For instance, what type should the \\coqe{filter} function be given?\n\\begin{coqcode}\n  filter : forall A n (p : A -> 𝔹), vec A n -> vec A …\n\\end{coqcode}\nThe size of the resulting list depends on how many elements in the list actually match the given predicate \\coqe{p}!\nDealing with this level of intricate specification can (and does) scare programmers away from mixing programs and specifications. The truth is that many libraries, such as the Mathematical\nComponents library \\sidecite{Mahboubi2021},\ngive up on mixing programs and specifications even for simple structures such as these, which are instead dealt with as ML-like lists with extrinsically-established properties. This\ntells a lot about the current intricacies of dependently-typed programming.\n  \nInstead of avoiding the obstacle altogether, gradual dependent types provide a uniform and flexible mechanism to a tailored adoption of dependencies. For instance, one could give \\coqe{filter} the following gradual type, which makes use of the \\reintro{unknown term} $\\?$\nin an index position:\n\\begin{coqcode}\n  filter : forall A n (f : A -> 𝔹), vec A n -> vec A ?\n\\end{coqcode}\nThis imprecise type means that uses of \\coqe{filter} will be optimistically accepted by the type-checker, although subject to associated checks during reduction. For instance,\n\\begin{coqcode}\nhead ℕ ? (filter ℕ 4 even [ 0 ; 1 ; 2 ; 3 ])\n\\end{coqcode}\ntype-checks, and successfully evaluates to \\coqe{0}, while\n\\begin{coqcode}\nhead ℕ ? (filter ℕ 2 even [ 1 ; 3 ])\n\\end{coqcode}\ntype-checks but fails during reduction, upon the discovery that the assumption\nof non-emptiness of the argument to head is in fact incorrect.\n\n\\subsection{Defining general recursive functions}\n\\label{sec:rec}\n\nAnother challenge of working in \\kl{CIC} is to convince the type-checker that recursive\ndefinitions are well-founded.\nThis can either require tight syntactic restrictions, or sophisticated arguments involving\naccessibility predicates. At any given stage of a development,\none might not be in a position to follow any of these.\nIn such cases, a workaround is to adopt the “fuel” pattern, \\ie parametrize a function with\na clearly syntactically decreasing argument in order to please the termination checker,\nand to use an arbitrary initial fuel value.\nIn practice, one sometimes requires a simpler way to unplug termination checking,\nand for that purpose, many proof assistants support external commands or parameters to deactivate termination checking.%\n\\mintedstring{terminating}{{-# TERMINATING #-}}%\n\\sidenote{For instance \\mintinlinestring{agda}{terminating} in \\kl{Agda}\nor \\coqe{Unset Guard Checking} in \\kl{Coq}.}\n\nBecause the use of the \\reintro{unknown type} $\\?$\nallows the definition of fixed point combinators \\sidecite{Siek2006,Eremondi2019},\none can use this added expressiveness to bypass termination checking locally.\nThis just means that the external facilities provided by specific proof assistant implementations now become internalized in the language.\n\n\\subsection{Large elimination, gradually}\n\\label{sec:elim}\n\nOne of the argued benefit of dynamically-typed languages, which is accommodated by gradual typing, is the ability to define functions that can return values of different types depending on their inputs, such as the following:%\n\\sidenote{With \\coqe{?>} a boolean comparison operator.}\n\\begin{coqcode}\n  Definition foo n m := if (n ?> m) then m + 1 else m ?> 0.\n\\end{coqcode}\n\nIn a gradually-typed language, one can give such a function the type \\coqe{?},\nor even \\coqe{ℕ -> ℕ -> ?} in order to enforce proper argument types,\nand remain flexible in the treatment of the returned value.\nOf course, we know very well that in a dependently-typed language, using large elimination, we can simply give \\coqe{foo} the dependent type:\n\\begin{coqcode}\n  foo : forall (n m : ℕ), if (n ?> m) then ℕ else 𝔹\n\\end{coqcode}\n\nLifting the term-level comparison \\coqe{n ?> m} to the type level is extremely expressive, but hard to work with as well, both for the implementer of the function and its clients.\nIn a gradual, dependently-typed setting, one can explore the whole spectrum of type-level\nprecision for such a function, starting from the least precise to the most precise,\nfor instance:\n\\begin{coqcode}\n    foo : ?\n    foo : ℕ -> ℕ -> ?\n    foo : ℕ -> ℕ -> if ? then ℕ else ?\n    foo : forall (n m : ℕ), if (n ?> m) then ℕ else ?\n    foo : forall (n m : ℕ), if (n ?> m) then ℕ else 𝔹\n\\end{coqcode}\n\nAt each stage from top to bottom, there is less flexibility – but more guarantees! –\nfor both the implementer of \\coqe{foo} and its clients. The \\kl{gradual guarantee}%\n\\sidenote{One of the important properties we seek in our \\kl{GCIC}.}\nensures that if the function is actually faithful to the most precise type\nthen giving it any of the less precise types above does not introduce any new failure\n\\sidecite{Siek2015}.\n\n\\subsection{Gradually refining specifications}\n\\label{sec:specif}\n  \nLet us come back to the \\coqe{filter} function from the first example.\nIts fully-precise type requires appealing to a type-level function that counts the number of\nelements in the list satisfying the predicate\n– notice the dependency to the input vector \\coqe{v}:\n\\begin{coqcode}\n  filter : forall A n (p : A -> 𝔹) (v : vec A n),\n            vec A (count A n p v)\n\\end{coqcode}\n\nAnticipating the need for this function, a gradual specification could adopt the above\nsignature for \\coqe{filter} but leave \\coqe{count} unspecified:\n\\begin{coqcode}\nDefinition count A n (p : A -> 𝔹) (v: vec A n) : ℕ := ?.\n\\end{coqcode}\n\nThis situation does not affect the behaviour of the program compared to leaving the return type index unknown. More interestingly, one could immediately define the base case, which trivially specifies that there are no matching elements in an empty vector:\n\\begin{coqcode}\nDefinition count A n (p : A -> 𝔹) (v : vec A n) : ℕ :=\n  match v with\n  | nil _ _ => 0\n  | cons _ _ _ => ?\n  end.\n\\end{coqcode}\n\nThis slight increment in precision provides a little more static checking, for instance:\n\\coqe{head ℕ ? (filter ℕ 4 even [])}\ndoes not even type-check, instead of failing during reduction.\n\nAgain, the gradual guarantee ensures that such incremental refinements in precision towards the proper fully-precise version do not introduce spurious errors.\nNote that this is in stark contrast with the use of axioms – which will be discussed in more depth in \\cref{sec:axiom}. Indeed, replacing correct code with an axiom can simply break typing! For instance, with the following definitions:\n\\begin{coqcode}\nAxiom to_be_done : ℕ.\nDefinition count A n (p : A -> 𝔹) (v: vec A n) : ℕ :=\n  to_be_done.\n\\end{coqcode}\nthe definition of \\coqe{filter} does not type-check any more,\nas the axiom at the type-level is not convertible to any given value.\n\n\\subsection{Gradual programs or proofs?}\n\nWhen adapting the ideas of gradual typing to a dependent type theory, one might\nexpect to deal with programs rather than proofs.\nThis observation is however misleading: from the point of view of the Curry-Howard correspondence, proofs and programs are intrinsically related, so that gradualizing the latter begs for a gradualization of the former. The examples above illustrate mixed programs and specifications, which naturally also appeal to proofs: dealing with indexed types typically requires exhibiting equality proofs to rewrite terms.\nMoreover, there are settings in which one must consider computationally-relevant proofs, such as constructive algebra and analysis, homotopy type theory, etc. In such settings, using axioms to bypass unwanted proofs breaks reduction, and because typing requires reduction, the use of axioms can simply prevent typing, as illustrated in the last example.\n\n\\subsection{Fundamental trade-offs}\n\nBefore exposing a specific approach to gradualizing \\kl{CIC},\nthere is a need for a general analysis of the properties at stake and tensions\nthat arise when gradualizing a dependent type theory.\n\nThus, in what follows\nwe start by recalling the two cornerstones properties of progress and normalization,\nand explain the need to reconsider them carefully in a gradual setting\n(\\cref{sec:norm-canon-endang}).\nNext, we show why two obvious approaches based respectively on axioms (\\cref{sec:axiom}),\nand exceptions (\\cref{sec:extt}) are unsatisfying.\nWe then turn to the gradual approach, recalling its essential properties in the simply-typed\nsetting (\\cref{sec:grad-simple}),\nand revisiting them in the context of a dependent type theory (\\cref{sec:graduality}).\nThis finally leads us to establish a fundamental impossibility in the gradualization\nof \\kl{CIC}, which means that at least one of the desired properties has to be sacrificed (\\cref{sec:fire-triangle}).\nWith all set up, we can finally present our \\kl(typ){gradual},\n\\kl{dependently} typed system, \\kl{GCIC}, and its main characteristics\n(\\cref{sec:gcic-overview}).\n\n\\section{Safety and Normalization, Endangered}[Safety and Normalization]\n\\label{sec:norm-canon-endang}\n\n% As a well-behaved typed programming language, \\kl{CIC} enjoys\n% (type) \\intro{safety}%\n% %  \\sidenote{That we abbreviate as \\psafe in this part.}\n% – the combination of \\kl{progress} and \\kl{preservation} –,\n% meaning that well-typed closed terms cannot get stuck,\n% \\ie that normal, closed terms of a given type are exactly the \\kl{canonical forms} of that type.\n% %\n% % In \\kl{CIC}, a closed canonical form is a term whose typing derivation ends\n% % with an introduction rule, \\ie a $\\lambda$-abstraction for a function\n% % type, and a constructor for an inductive type.\n% %\n% % For instance, any closed term of type \\coqe{bool} is convertible (and\n% % reduces) to either \\coqe{true} or \\coqe{false}.\n% Note that a normal open term, on the contrary, must not be \\kl{canonical form}.\n% Instead, it can also be a \\kl{neutral form}.\n\n% As a logically consistent type theory, \\kl{CIC} also enjoys \\kl{normalization},\n% %(\\pnorm)\n% meaning that any term reduces to its (unique) normal form.\n% \\kl{Normalization}, together with \\kl{safety}, imply \\kl{canonicity}:\n% any closed term of a given type \\emph{must} reduce to a \\kl{canonical form} of that type.\n% %\n% When applied to the empty type $\\Empty$, canonicity ensures \\kl{logical consistency}:\n% because there is no canonical form for $\\Empty$, there is no\n% closed proof of $\\Empty$.\n% %\n% Note that \\kl{normalization} also has an important consequence in \\kl{CIC}. Indeed, in\n% this system, conversion---which coarsely means syntactic equality\n% up-to reduction---is used in the type-checking algorithm.\n\nIn the gradual setting, the two cornerstone properties of \\kl{CIC} exposed in\n\\cref{sec:tech-properties}, \\kl{safety}%\n\\sidenote{The combination of \\kl{progress} and \\kl{preservation}.}\nand \\kl{normalization}, must be considered with care.\n%\n\nFirst, any \\kl{closed term} can be ascribed the unknown type $\\?$\nand then any other type: for instance, $\\z \\ascop \\? \\ascop \\Bool$ is a\nwell-typed closed term of type $\\Bool$.%\n\\sidenote{\n  We write $\\intro*\\asc{a}{A}$ for a type \\intro{ascription}, used to “force” the term $a$ to inhabit type $A$. \n  We define it as syntactic sugar for $(\\l x:A.\\ x)\\ a$ \\cite{Siek2006},\n  so $\\z \\ascop \\? \\ascop \\Bool$ is $(\\z \\ascop \\?) \\ascop \\Bool$. In\n  other systems, it is taken as a primitive notion \\cite{Garcia2016}.}%\n\\margincite{Siek2006}%\n\\margincite{Garcia2016}\nHowever, such a term\ncannot possibly reduce to either $\\true$ or $\\false$, so some\nconcessions must be made with respect to \\kl{safety} – at the very least, the notion\nof canonical forms must be extended.\n%\n\n\\AP Second, \\kl{normalization} is endangered.\nThe quintessential example of non-termination in the untyped lambda calculus is the\nterm $\\Omega$, defined as $\\delta~\\delta$\nwhere $\\delta$ is $\\l x.\\ (x\\ x)$.\nIn the \\intro{simply-typed lambda calculus}%\n  \\sidenote{Hereafter abbreviated as \\intro{STLC}.},\nas in \\kl{CIC}, \\emph{self-applications} like $\\delta\\ \\delta$ and $x\\ x$ are ill-typed.\nHowever, when introducing gradual types, one usually expects to accommodate such idioms,\nand therefore in a standard gradually-typed calculus such as\n\\intro{GTLC}%\n\\sidenote{The gradual counterpart to \\kl{STLC}.}\n\\cite{Siek2006}, a variant of $\\Omega$ that uses\n$(\\l x : \\?.\\ x\\ x)$ as $\\delta$ is well-typed and diverges – \\ie reduces indefinitely.\nThe reason is that the domain type of $\\delta$, the \\kl{unknown type} $\\?$,\nis \\reintro(grad){consistent} with the type of $\\delta$ itself,\n$\\? \\to \\?$, meaning that we wish to optimistically accept the application as\nplausibly valid. But at runtime, nothing prevents reduction from going on forever.\nTherefore, if one aims at ensuring \\kl{normalization} in a gradual setting,\nsome care must be taken to restrict expressiveness.\n\n\\section{Non-Gradual Approaches}\n\n\\subsection{Axioms}\n\\label{sec:axiom}\n\nLet us first address the elephant in the room:\nwhy would one want to gradualize \\kl{CIC} instead of simply postulating\nan axiom for any term – be it a program or a proof – that one does not feel like providing (yet)?\n\n\\AP Indeed, we can augment \\kl{CIC} with a wildcard axiom $\\intro*\\axiom \\ty \\P A : \\uni.\\ A$.\nThe resulting system, called \\intro{CICax}, has an obvious practical benefit: we can use\n$\\axiom A$\n%\\sidenote{Hereafter written $\\axiom[A]$.}\nas a wildcard whenever we are\nasked to exhibit an inhabitant of some type $A$ and we do not (yet) want to.\nThis is exactly what admitted definitions are in \\kl{Coq}, for instance,\nand they do play an important practical role during any \\kl{Coq} development.\n\nHowever, we cannot use the axiom $\\axiom A$ in any meaningful way \\emph{at the\n  type level}.\n%\nFor instance, going back to the examples of \\cref{sec:indices},\none might be tempted to give to the \\coqe{filter} function on vectors the type\n\\begin{coqcode}\n  forall A n (p : A -> 𝔹), vec A n -> vec A (ax ℕ)\n\\end{coqcode}\n%\nin order to avoid the complications related to specifying the\nsize of the vector produced by \\coqe{filter}.\n%\nThe problem is that the term:\n\\begin{coqcode}\n  head ℕ (ax ℕ) (filter ℕ 4 even [ 0 ; 1 ; 2 ; 3 ])\n\\end{coqcode}\nis ill-typed since the type of the filtering expression, \\coqe{vec A (ax ℕ)},\nis not convertible to \\coqe{vec A (S (ax ℕ))}, as required by\n\\coqe{head ℕ (ax ℕ)} in its domain type.\n\nThus, the axiomatic approach is not useful for making dependently-typed programming\nany more pleasing.\n%\nThat is, using axioms goes in total opposition to the \\kl{gradual guarantee}\n– characteristic of gradual languages \\sidecite{Siek2015}~–\nwhen it comes to the smoothness of\nthe static-to-dynamic checking spectrum: given a well-typed term,\nmaking it “less precise” by using axioms for some sub-terms actually\nresults in programs that do not type-check or reduce any more.\n\n%\nBecause \\kl{CICax} amounts to working in \\kl{CIC}\nwith an initial context extended with $\\axiom$, this theory\nsatisfies \\kl{normalization} as much as \\kl{CIC}, so conversion remains decidable.\nHowever, \\kl{CICax} lacks a satisfying notion of \\kl{safety}, because \nthere is an \\emph{infinite} number of \\emph{stuck} terms\nthat inhabit any type \\coqe{A}.\n%\nFor instance, in $\\Bool$, we not only have the normal forms $\\true$,\n$\\false$, and $\\axiom \\Bool$, but also plenty of terms stuck on an\nelimination of $\\axiom$, such as $\\axiom (\\Nat \\to \\Bool)\\ 1$ or\n$\\ind{\\Nat}{\\axiom \\Nat}{P}{b_{\\z},b_{\\Sop}}$.\n\n\\subsection{Exceptions}\n\\label{sec:extt}\n\n\\sidetextcite{Pedrot2018} present the exceptional type theory \\intro{ExTT},\ndemonstrating that it is possible to extend a\ntype theory with a wildcard term while enjoying a satisfying notion of \\kl{safety},\nwhich coincides with that of programming languages with exceptions.\n\n\\kl{ExTT} is essentially \\kl{CICrai}, that is, it\nextends \\kl{CIC} with an exceptional term $\\intro*\\rai[A]$ that can inhabit any type $A$.\nBut instead of being treated as a computational black box like $\\axiom A$,\n$\\rai[A]$ is endowed with computational content\nemulating exceptions in programming languages, which propagate instead of being stuck.\n%\nFor instance, in \\kl{ExTT} the following conversion holds:\n\\[\\ind{\\Bool}{\\rai[\\Bool]}{\\Nat}{\\z,1} \\conv \\rai[\\Nat]\\]\n\n\\AP Notably, such exceptions are \\intro{call-by-name} exceptions, so one can only\ndiscriminate exceptions on positive types – \\ie inductive types –, not on negative\ntypes – \\ie function types. In particular, in \\kl{ExTT}, $\\rai[A \\to B]$ reduces to\n$\\l x : A.\\ \\rai[B]$.\nSo $\\rai[A]$ is a normal form of $A$ only if $A$ is a positive type.\n\n\\kl{ExTT} has a number of interesting properties. It is\n\\kl{normalizing} and \\kl{safe}, taking $\\rai[A]$\ninto account as usual in programming languages,\nwhere exceptions are possible outcomes of computation: the canonical forms\nof a positive type – \\eg $\\Bool$ – are either the\nconstructors of that type – \\eg $\\true$ and $\\false$ –, or\n$\\rai$ at that type – \\eg $\\rai[\\Bool]$.\n%\nAs a consequence, \\kl{ExTT} does not satisfy full \\kl{canonicity}, but\na weaker form of it. In particular, it enjoys\n(weak) \\kl{logical consistency}: any closed proof of $\\Empty$ is \\kl{convertible}\nto $\\rai[\\Empty]$, which is discriminable at $\\Empty$.\n%\nIt has been shown that we can still reason soundly in an\nexceptional type theory, either using a parametricity\nrequirement \\sidecite{Pedrot2018}, or, more flexibly, a\ndifferent universe hierarchies \\sidecite{Pedrot2019}.\n\nIt is also important to highlight that this weak form of \\kl{logical\nconsistency} is the \\emph{most} one can expect in\na theory with effects. Indeed, \\sidetextcite{Pedrot2020} have\nshown that it is not possible to define a type theory with full\ndependent elimination%\n\\sidenote{That is, a term former such as $\\indop$.}\nthat has observable effects – of which\nexceptions are a particular case – and at the same time validates\ntraditional \\kl{canonicity}.\n%\nSettling for less, as explained in \\cref{sec:axiom} for the axiomatic\napproach, leads to an infinite number of stuck terms, even in the\ncase of booleans, which contradicts the type safety criterion of gradual languages,\nwhich only allows for runtime type errors.\n\nUnfortunately, while \\kl{ExTT} solves the safety issue of the axiomatic approach, it still suffers from the same limitation as the axiomatic approach regarding type-level comparison.\nIndeed, even though we can use $\\rai$ to inhabit any type,\nwe cannot use it in any meaningful way at the type level.\nIn such a system, the following term is ill-typed\n\\begin{coqcode}\n  head ℕ (raise ℕ) (filter ℕ 4 even [ 0 ; 1 ; 2 ; 3 ])\n\\end{coqcode}\nas \\coqe{vec A (raise ℕ)} is still not convertible to\n\\coqe{vec A (S (raise ℕ))}.\nThe reason is that \\coqe{raise ℕ} behaves like an extra constructor of type \\coqe{ℕ}, so\nthat \\coqe{S (raise ℕ)} is itself a normal form,\nand normal forms with different head constructors\n– \\coqe{S} and \\coqe{raise} – are not convertible.\n\n\\section{Gradual Simple Types}\n\\label{sec:grad-simple}\n\nBefore going on with our exploration of the fundamental challenges in gradual dependent type\ntheory, let us go over some key concepts and expected properties,\nin the context of simple types.\n\n\\subsection{Static semantics}\n\n\\AP \\intro[gradual typing]{Gradually typed} languages introduce the\n\\reintro{unknown type}, written $\\?$,\nwhich is used to indicate the lack of static typing information \\sidecite{Siek2006}.\nOne can understand such an unknown type as an abstraction of the\nset of possible types that it stands for \\sidecite{Garcia2016}.\nThis interpretation provides a naive but natural understanding of the meaning of\npartially-specified types. For instance $\\Bool \\to \\?$ denotes the set of all function types\nwith $\\Bool$ as domain.\nGiven imprecise types, a gradual type system relaxes all type predicates and functions in order\nto optimistically account for occurrences of $\\?$.\nIn a simple type system, the main predicate on types is equality, whose relaxed counterpart is called \\intro(grad){consistency}%\n\\sidenote{Not to be confused with \\kl{logical consistency}!},\nusually written $\\cons$.\nFor instance, given a function $f$ of type $\\Bool \\to \\?$, the expression $(f\\ \\true) + 1$\nshould be well-typed. Indeed, $f$ could \\emph{plausibly} return a number,\ngiven that its codomain is $\\?$, which is \\kl(grad){consistent} with $\\Nat$.\n\nNote that there are other ways to consider imprecise types, for instance by restricting the\nunknown type to denote base types – in which case $\\?$ would not be \\kl(grad){consistent} with any\nfunction type –, or by only allowing imprecision in certain parts of the syntax of types,\nsuch as effects \\sidecite{BanadosSchwerter2016}, security labels\n\\sidecite{Fennell2013,Toro2018}, annotations \\sidecite{Thiemann2014},\nor only at the top-level \\sidecite{Bierman2010}.\nHere, we do not consider these specialized approaches, which have benefits and challenges\nof their own, and stick to the mainstream setting of gradual typing\nin which the unknown type is \\kl(grad){consistent} with any type and can occur\nanywhere in the syntax of types.\n\n\\subsection{Dynamic semantics}\n\nHaving optimistically relaxed typing based on \\kl(grad){consistency},\na gradual language must detect inconsistencies at runtime if it is to satisfy \\kl{safety},\nwhich therefore has to be formulated in a way that encompasses runtime errors.\n\n\\AP For instance, if the function $f$ above returns $\\false$,\nthen an \\kl{error} must be raised to avoid reducing to $\\false + 1$ – a closed stuck term,\ncorresponding to a violation of safety.\nThe traditional approach to do so is to avoid giving a direct reduction semantics to gradual\nprograms, and, instead, to elaborate them to an intermediate language with runtime \\kl{casts},\nin which casts between inconsistent types raise \\reintro{errors}%\n\\sidenote{We write those $\\err$.}\n\\sidecite{Siek2006}.\n\nIn such a language, the notion of \\kl{canonical form} used to phrase \\kl{progress} –~and,\nthus, \\kl{safety} – has to account for these newly introduced errors. Indeed, $\\err[A]$\nis now a valid \\kl{canonical form} at type $A$ – at least for some types such as $\\Bool$,\nsince, as we explained in \\cref{sec:extt},\n\\kl{call-by-name} errors are not normal forms of function types.\n\nAlternatively – and equivalently from a semantics point of view – one can define \\kl{reduction}\nof gradual programs directly on gradual typing derivations augmented with evidence about\nconsistency judgments, and report errors when transitivity of such judgments is\nunjustified \\sidecite{Garcia2016}.\nThere are many ways to realize each of these approaches,\nwhich vary in terms of efficiency and eagerness of checking \\sidecite{Herman2010,TobinHochstadt2008,Siek2010,Siek2009,Toro2020,BanadosSchwerter2021}.\n\n\\subsection{Conservativity}\n\\AP A first important property of a gradual language is that it is a\n\\reintro{conservative extension} of a related static typing discipline:\nthe gradual and static systems should coincide on static terms.\nThis property is hereafter called \\reintro{conservativity},\nwith respect to a given static system.\n%For instance, we write that \\GTLC satisfies \\pconst{\\STLC}.\nTechnically, \\sidetextcite{Siek2006} prove that typing and reduction of \\kl{GTLC} and\n\\kl{STLC} coincide on their common set of terms – \\ie those which are fully precise.\nAn important aspect of \\kl{conservativity} is that the type formation rules and typing\nrules themselves are also preserved, up to the presence of $\\?$ as a new type and the\nadequate lifting of predicates and functions \\sidecite{Garcia2016}.\nWhile this aspect is often left implicit, it ensures that the gradual type system does not\nbehave in ad hoc ways on imprecise terms.\n\nNote that, despite its many issues, \\kl{CICax} (\\cref{sec:axiom}) satisfies\n\\kl{conservativity} (with respect to \\kl{CIC}):\nall pure – \\ie axiom-free – \\kl{CIC} terms behave as they would in \\kl{CIC}.\nMore precisely, two \\kl{CIC} terms are convertible in \\kl{CICax}\nif and only if they are convertible in \\kl{CIC}.\nImportantly, this does not mean that \\kl{CICax} is a conservative extension of\n\\kl{CIC} \\emph{as a logic} – which it clearly is not!\n\n\\subsection{Gradual guarantees}\n\\AP The early accounts of gradual typing emphasized \\kl(grad){consistency} as the central idea.\nHowever, \\sidetextcite{Siek2015} observed that this characterization left too many\npossibilities for the impact of type information on program behaviour,\ncompared to what was originally intended \\sidecite{Siek2006}.\n%\nConsequently, they brought forth type \\intro{precision}%\n\\sidenote{Denoted $\\intro*\\pre$: $A \\pre B$ means that $A$ is more precise than $B$,\n\\ie that $A$ contains more static information than $B$.}\nas the key notion, from which consistency can be derived: two types $A$ and $B$\nare consistent if and only if there exists $T$ such that $T \\pre A$ and $T \\pre B$.\nThe \\kl{unknown type} $\\?$ is the most imprecise type of all,\n\\ie $T \\pre \\?$ for any $T$.\n%\nPrecision is a pre-order that can be used to capture the intended \\emph{monotonicity} of\nthe static-to-dynamic spectrum afforded by gradual typing.\nThe static and dynamic \\intro{gradual guarantees} respectively specify that typing\nand reduction should be \\emph{monotone with respect to precision}:\nlosing precision should not introduce new static or dynamic errors.\n%\nThese properties require precision to be extended from types to terms.\n\\textcite{Siek2015} present a natural extension that is purely syntactic:\na term is more precise than another if they are \\kl{α-equal}, except\nfor their type annotations, which can be more precise in the former.\n\n\\AP The \\kl{static gradual guarantee} (\\intro{SGG})\nensures that imprecision does not alter typeability.\n\n\\begin{minipage}{\\textwidth}\n\\begin{property}[\\intro{Static Gradual Guarantee}]\nIf $t \\pre u$ and $\\vdash t \\ty T$, then $\\vdash u \\ty U$\nfor some $U$ such that $T \\pre U$.\n\\end{property}  \n\\end{minipage}\n\n%\nThis \\kl{SGG} captures the intuition that “sprinkling $\\?$ over a term“\nmaintains its typeability. As such, the notion of \\kl{precision} $\\pre$ used to\nformulate the \\kl{SGG} is inherently syntactic,\nover as-yet-untyped terms: typeability is the \\emph{consequence} of the \\kl{SGG} theorem.\n\n\\AP The \\kl{dynamic gradual guarantee} (\\intro{DGG}) is the key result that\nlinks the syntactic notion of precision to reduction:\nif $t \\pre t'$ and $t$ reduces to some value $v$, then\n$t'$ reduces to some value $v'$ such that $v \\pre v'$;\nand if $t$ diverges, then so does $t'$.\nThis  entails that $t \\pre t'$ means that $t$ may \\kl{error} more than $t'$,\nbut otherwise they should behave the same.\n%\nInstead of the original formulation of the DGG by\n\\textcite{Siek2015}, \\sidetextcite{New2018} appeal to the\nsemantic notion of \\kl{observational error-approximation} to capture\nthe relation between two terms that are contextually equivalent, except\nthat one may fail more:%\n\\sidenote{\\kl{Observational error-approximation}\n  does not mention the case where $\\mathcal{C}[t]$\n  reduces to $\\true$ or $\\false$, but the quantification\n  over all contexts ensures that, in that case,\n  $\\mathcal{C}[t']$ must reduce to the same value.}\n\n\\begin{definition}[\\intro{Observational error-approximation}]\n\\label{def:obsapprox}\n  A term $\\Gamma \\vdash t \\ty T$ \\kl{observationally error-approximates}\n  a term $\\Gamma \\vdash t' \\ty T'$, noted $ t\n  \\intro*\\obsApprox t'$, if for all boolean-valued observation contexts\n  $\\mathcal{C} : (\\Gamma \\vdash T) \\Rightarrow (\\vdash \\Bool)$\n  closing over all free variables, either\n  \\begin{itemize}\n  \\item $\\mathcal{C}[t]$ and $\\mathcal{C}[t']$ both diverge; \n  \\item otherwise if $\\mathcal{C}[t'] \\red \\err[\\Bool]$, then $\\mathcal{C}[t] \\red \\err[\\Bool]$.\n  \\end{itemize}\n\n  Two terms $t$ and $t'$ are \\intro{observationally equivalent}, written $t \\intro*\\obsEquiv t'$,\n  if they are related by \\kl{observational error-approximation} in both directions.\n\\end{definition}\n\nUsing this semantic notion, the \\kl{DGG} simply states that term \nprecision implies \\kl{observational error-approximation}:\n\n\\begin{property}[\\intro{Dynamic Gradual Guarantee}]\nIf $t \\pre t'$ then $t \\obsApprox t'$.\n\\end{property}\n\nWhile often implicit, it is important to highlight that the \\kl{DGG} is relative to\nboth the notion of \\kl{precision} $\\pre$ and the notion of observations $\\obsApprox$.\nIndeed, it is possible to study alternative notions of precisions beyond the natural definition\nstated by \\sidetextcite{Siek2015}.\nFor instance, following the Abstracting Gradual Typing methodology \\sidecite{Garcia2016},\n\\kl{precision} follows from the definition of gradual types through a concretization to sets\nof static types. This opens the door to justifying alternative precisions,\n\\eg by considering that the unknown type only stands for specific static types, such as base types.\nAdditionally, variants of precision have been studied in more challenging typing disciplines where\nthe natural definition seems incompatible with the \\kl{DGG}, see \\eg \\sidetextcite{Igarashi2017}.\nAs we will soon see, it can also be necessary in certain situations to consider another notion of observations.\n\n\\subsection{Graduality}\n\nAs we have seen, the \\kl{DGG} is relative to a notion of \\kl{precision},\nbut what should this relation be?\nTo go beyond a syntactic axiomatic definition of \\kl{precision}, \\sidetextcite{New2018}\ncharacterize the good dynamic behaviour of a gradual language:\nthe runtime checking mechanism used to define it, such as casting,\nshould only perform type-checking, and not otherwise affect behaviour.\n\n\\AP Specifically, they mandate that precision gives rise\nto \\intro{embedding-projection pairs} (\\reintro{ep-pairs}):\nthe cast induced by two types related by precision forms an adjunction,\nwhich induces a retraction.\nIn particular, going to a less precise type and back is the identity:  \nfor any term $a$ of type $A$, and assuming $A \\pre B$,\n$\\asc{\\asc{a}{B}}{A}$%\n\\sidenote{Recall that $\\ascop$ is a type \\kl{ascription}.}\nshould be observationally equivalent to $a$.\nFor instance, $\\asc{\\asc{1}{\\?}}{\\Nat}$ should be equivalent to $1$. \nDually, when gaining precision, there is the potential for \\kl{errors}:\ngiven a term $b$ of type $B$, $\\asc{\\asc{b}{A}}{B}$ may fail. \nBy considering \\kl{error} as the most precise term, this can be stated as \n$\\asc{\\asc{b}{A}}{B} \\pre b$.\nFor instance, with the imprecise successor function $f$ of type $\\? \\to \\?$,\ndefined as $\\l n : \\?.\\ \\asc{\\S n}{\\?}$,\nwe have $\\asc{\\asc{f}{\\Nat \\to \\Bool}}{\\? \\to \\?} \\pre f$,\nbecause the ascribed function will fail when applied.\n\nTechnically, the adjunction part states that if we have $A \\pre B$, a term $a$ of type $A$,\nand a term $b$ of type $B$, then $a \\pre \\asc{b}{A}$ if and only if $\\asc{a}{B} \\pre b$.\n%\n\\AP The retraction part further states that $a$ is not only more \\kl{precise}\nthan $\\asc{\\asc{a}{B}}{A}$ – which is given by the unit of the adjunction –\nbut is \\reintro{equi-precise} to it – noted $t \\intro*\\equiprecise \\asc{\\asc{t}{B}}{A}$.\nBecause the \\kl{DGG} dictates that precision implies \\kl{observational error-approximation},\n\\kl{equi-precision} implies \\kl{observational equivalence},\nand so losing and recovering precision must produce a term that is \\kl{observationally\nequivalent} to the original one.\n\n% A couple of additional observations need to be made here, as they will play a major role in the development that follows.\nThese two approaches to characterizing gradual typing highlight\nthe need to distinguish\n\\emph{syntactic} from \\emph{semantic} notions of precision.\nIndeed, with the usual syntactic \\kl{precision} from \\sidetextcite{Siek2015},\none cannot derive the \\kl{ep-pair} property, in particular the \\kl{equi-precision} stated above.\nThis is why \\sidetextcite{New2018} introduce a semantic \\kl{precision},\ndefined on well-typed terms. This semantic \\kl{precision} serves\nas a proxy between syntactic \\kl{precision} and the desired\n\\kl{observational error-approximation}.\n%\nHowever, a type-based semantic \\kl{precision} cannot be used for the \\kl{SGG}.\nIndeed, this theorem%\n\\sidenote{Not addressed by \\textcite{New2018}.}\nrequires a notion of \\kl{precision} that \\emph{predates} typing:\nwell-typedness of the less precise term is the \\emph{consequence} of the theorem. \nTherefore, a full study of a gradual language that covers \\kl{SGG}, \\kl{DGG}, and\n\\kl{embedding-projection pairs} needs to consider both syntactic and semantic\nnotions of \\kl{precision}.\n\nNote also that the \\kl{embedding-projection} property does not\n\\textit{per se} imply the \\kl{DGG}: one could pick \\kl{precision} to be the universal relation,\nwhich trivially induces \\kl{ep-pairs}, but does not imply \\kl{observational error-approximation}.\nConversely, it appears that, in the simply-typed setting considered in prior work,\nthe \\kl{DGG} implies the \\kl{embedding-projection} property.\nIn fact, \\textcite{New2018} essentially advocate \\kl{ep-pairs} as an elegant and compositional\nproof technique to establish the \\kl{DGG}.\nBut as we uncover later on, it turns out that in certain settings – and in particular dependent types – the \\kl{embedding-projection} property imposes \\emph{more}\ndesirable constraints on the behaviour of casts than the \\kl{DGG} alone.\n\n\\AP In regard of these two remarks, in what follows we use the term \\intro{graduality}\nfor the \\kl{DGG} established with respect to a notion of \\kl{precision} which also\ninduces \\kl{embedding-projection pairs}.\n\n\\section{Graduality and Dependent Types}\n\\label{sec:graduality}\n\nExtending the gradual approach to a setting with full \\kl(typ){dependent} types\nrequires reconsidering several aspects.\n\n\\subsection{Newcomers: the unknown term and the error type}[Unknown term and error type]\n%\nIn the simply-typed setting, there is a clear stratification: $\\?$ is at the type level,\n$\\err$ is at the term level. Likewise, type \\kl{precision}, with $\\?$ as greatest element,\nis distinct from term \\kl{precision}, with $\\err$ as least element.\nIn the absence of a type/term syntactic distinction as in \\kl{CIC},\nthis stratification cannot be kept.\n\nBecause types permeate terms, $\\?$ is no longer only the \\kl{unknown} \\emph{type},\nbut it also acts as an “\\kl{unknown term}”.\nIn particular, this makes it possible to consider unknown indices for types,\nas in \\cref{sec:indices}.\nMore precisely, there is a family of \\kl{unknown terms} $\\?[A]$, indexed by their type $A$.\nThe traditional \\kl{unknown type} is just $\\?[\\uni]$, the \\kl{unknown} of the universe $\\uni$.\n\nDually, because terms permeate types, we also have the “\\kl{error} type”, $\\err[\\uni]$.\nWe have to deal with \\kl{errors} in types.\n\nFinally, \\kl{precision} must be unified as a single pre-order, with $\\?$ at the top\nand $\\err$ at the bottom.\nThe most imprecise term of all%\n\\sidenote{More exactly, there is one such term per universe.}\nis $\\?[\\?[\\uni]]$ – $\\?$ for short. At the bottom, $\\err[A]$\nis the most precise term of type $A$.\n\n\\subsection{Revisiting safety}\n\nThe notion of \\kl{canonical forms} used for \\kl{safety} needs to be extended not\nonly with errors as in the simply-typed setting, but also with \\kl{unknown terms}.\nIndeed, as there is an \\kl{unknown term} $\\?[A]$ inhabiting any type\n$A$, we have one new canonical form for each type $A$. In particular,\n$\\?[\\Bool]$ cannot possibly reduce to either $\\true$, $\\false$, or $\\err[\\Bool]$,\nbecause doing so would collapse the precision order.\n%\nTherefore, $\\?[\\Bool]$ should propagate computationally, exactly\nlike $\\rai[\\Bool]$ in \\cref{sec:extt} and $\\err[\\Bool]$.\n%\n\nThe difference between \\kl{errors} and \\kl{unknown terms} is not on their dynamic behaviour,\nbut rather on their static interpretation.\n%\nIn essence, the unknown term $\\?[A]$ is a dual form of exceptions: it\npropagates, but is optimistically comparable – \\ie \\kl(grad){consistent}\nwith – any other term of type $A$. Conversely, $\\err[A]$ should not be consistent\nwith any term of type $A$.\n%\nGoing back to the issues we identified with the axiomatic (\\cref{sec:axiom})\nand exceptional (\\cref{sec:extt}) approaches when dealing with type-level comparison,\nthe term\n\\begin{coqcode}\n  head ℕ (? ℕ) (filter ℕ 4 even [ 0 ; 1 ; 2 ; 3 ])\n\\end{coqcode}\nis now well-typed: since \\coqe{S (? ℕ)} is \\kl(grad){consistent} with \\coqe{? ℕ},\n\\coqe{vec A (? ℕ)} can be deemed \\kl(grad){consistent} with\n\\coqe{vec A (S (? ℕ))}.\nThis newly-brought flexibility is the key to support the different scenarios from the introduction.\n%\nSo let us now turn to the question of how to integrate \\kl(grad){consistency} in\na dependently-typed setting.\n\n\\subsection{Relaxing conversion}\n\nIn the simply-typed setting, \\kl(grad){consistency} is a relaxing of syntactic type equality\nto account for imprecision.\nIn a dependent type theory, there is a more powerful notion than syntactic equality to compare types, namely \\kl{conversion}.\nThe proper notion to relax in the gradual dependently-typed setting is therefore \\kl{conversion},\nnot syntactic equality.\n\n\\AP \\sidetextcite{Garcia2016} give a general framework for gradual typing that explains how to relax any type predicate to account for imprecision:\nfor a binary type predicate $P$, its \\intro{consistent lifting} $\\mathop{\\tilde{P}}(A,B)$ holds\nif there exist static types $A'$ and $B'$ in the denotation%\n\\sidenote{Concretization, in abstract interpretation parlance.}\nof $A$ and $B$, respectively, such that $\\mathop{P}(A',B')$.\nAs observed by \\sidecite{Castagna2019}, when applied to equality,\nthis defines \\kl(grad){consistency} as a unification problem.\nTherefore, the \\kl{consistent lifting} of \\kl{conversion} ought to be that two terms\n$t$ and $u$ are consistently convertible if they denote some static terms $t'$ and $u'$ such that $t' \\conv u'$. This is essentially \\kl{higher-order unification},\nwhich is an undecidable problem.\n\nIt is therefore necessary to adopt some approximation of this relation\nin order to be able to implement a gradual dependent type theory.\nThere lies an important challenge: because of the dependency of typing on \\kl{conversion},\nthe \\kl{static gradual guarantee} already demands monotonicity of the approximation\none chooses. But if this approximation is defined using reduction, this demand is\nvery close to that of the \\kl{dynamic gradual guarantee}.%\n\\sidenote{In a dependently-typed programming language with separate typing and execution phases, this demand is called the normalization gradual guarantee \\cite{Eremondi2019}.}%\n\\margincite{Eremondi2019}\nIn practice, this means that the \\kl{SGG} essentially depends on the \\kl{DGG}!\n\n\\subsection{Dealing with neutrals}\nPrevious work on gradual typing usually only considers reduction on \\kl{closed} terms in order to establish results about the dynamic semantic, such as the \\kl{DGG}.\n%\nBut in dependent type theory, conversion must operate on \\kl{open} terms,\nand in particular \\kl{neutral} terms such as $\\asc{\\asc{1}{X}}{\\Nat}$,\nwhere $X$ is a type variable, or $x + 1$ where $x$ is of type $\\Nat$ or $\\?[\\uni]$.\n%\nSuch \\kl{neutral} terms cannot reduce further, and can occur in both terms and types.\nDepending on the upcoming substitution, neutrals can fail, or not. For instance, in $\\asc{\\asc{1}{X}}{\\Nat}$, if $\\?[\\uni]$ is substituted for $X$, the term should reduce to $1$,\nbut it should fail if $\\Bool$ is substituted instead.\n\nImportantly, less precise variants of \\kl{neutrals} can reduce \\emph{more}.\nFor instance, $\\asc{\\asc{1}{\\?[\\uni]}}{\\Nat}$ and $\\?[\\Nat] + 1$ are respectively\nless precise than the neutrals above, but do evaluate further – respectively to $1$\nand to $\\?[\\Nat]$. This interaction between \\kl{neutrals}, \\kl{reduction}, and \\kl{precision}\nspices up the goal of establishing \\kl{DGG} and \\kl{graduality}.\nIn particular, this re-enforces the need to consider a semantic notion of \\kl{precision},\nbecause a too syntactic one is likely not to be stable by reduction:\n$\\asc{\\asc{1}{X}}{\\Nat} \\pre \\asc{\\asc{1}{\\?}}{\\Nat}$ is obvious syntactically,\nbut $\\asc{\\asc{1}{X}}{\\Nat} \\pre 1$ is not.\n\n\\subsection{Dynamic Gradual Guarantee \\vs graduality}[DGG \\vs graduality]\nIn a dependently-typed setting, it is possible to satisfy the \\kl{DGG} while not satisfying the \\kl{embedding-projection pairs} requirement of \\kl{graduality}.\n\nTo see why, consider a system in which any term of type $A$ that is not\nfully-precise immediately reduces to $\\?[A]$.\nThis system would satisfy \\kl{conservativity}, \\kl{safety}, \\kl{normalization}…\nand the \\kl{DGG}. Indeed, recall that the \\kl{DGG} only requires \\kl{reduction}\nto be monotone with respect to \\kl{precision}, so using the most imprecise term\n$\\?$ as a universal reduct is surely valid. This collapse of the \\kl{DGG}\nis impossible in the simply-typed setting because there is no \\kl{unknown term}:\nit is only possible when $\\?[A]$ exists \\emph{as a term}.\nIt is therefore possible to satisfy the \\kl{DGG} while being useless when\n\\emph{computing} with imprecise terms.\n\nOn the contrary, the degenerate system breaks the \\kl{embedding-projection} requirement of graduality stated by \\sidetextcite{New2018}.\nFor instance, $\\asc{\\asc{1}{\\?[\\uni]}}{\\Nat}$ would be convertible to $\\?[\\Nat]$,\nwhich is \\emph{not} \\kl{observationally equivalent} to $1$.\nTherefore, the \\kl{embedding-projection} requirement of graduality goes beyond the\n\\kl{DGG} in a way that is critical in a dependent type theory,\nwhere it captures both the smoothness of the static-to-dynamic checking spectrum,\nand the proper computational content of valid uses of imprecision.\n\n\\subsection{Observational refinement}\n\nLet us come back to the notion of \\kl{observational\nerror-approximation} used in the simply-typed setting to state the\n\\kl{DGG}.\n\\textcite{New2018} justify this notion because in\n”gradual typing we are not particularly interested in\nwhen one program diverges more than another, but rather when it\nproduces more type errors”.\n\n%\nThis point of view is adequate in the simply-typed setting because\nthe addition of ascriptions may only produce more type errors; in particular, \nadding ascriptions can never lead to divergence\nwhen the original term does not diverge itself.\n%\nThus, in that setting, the definition of \\kl{observational error-approximation}\nincludes equi-divergence.\n%\n\nThe situation in the dependent setting is however more\ncomplicated if the theory admits divergence.%\n\\sidenote{\n  There exist non-gradual dependently-typed programming languages that admit divergence, \\eg \\kl{Dependent Haskell} \\cite{Eisenberg2016} or\n  \\kl{Idris} \\cite{Brady2013}.\n  We will also present one such theory in this article. \n}%\n\\margincite{Eisenberg2016}%\n\\margincite{Brady2013}\nIn a gradual dependent type theory that admits divergence,\na diverging term is more precise than the\n\\kl{unknown term} $\\?$. Because the unknown term does not diverge, this\nbreaks the left-to-right implication of\nequi-divergence. Note that this argument does not rely on any specific definition of precision, \njust on the fact that the unknown is a term, and not just a type.\n\nAdditionally, an error at a diverging type $X$ may be ascribed to $\\?[\\uni]$,\nthen back to $X$. Evaluating this\nroundtrip requires evaluating $X$ itself, which makes the less\nprecise term diverge. This breaks the right-to-left implication of\nequi-divergence.\n\nTo summarize,\nthe way to understand these counterexamples is that \nin a dependent and non-terminating setting, \nthe motto of graduality ought to be adjusted: more precise programs produce\nmore type errors \\emph{or diverge more}. This leads to the following definition\nof \\kl{observational refinement}.\n\n\\begin{definition}[\\intro{Observational refinement}]\n\\label{def:obsref}\n  A term $\\Gamma \\vdash t \\ty A$ \\kl{observationally refines} a term\n  $\\Gamma \\vdash u \\ty A$, noted $\\intro* t \\obsRef u$, if for all boolean-valued observation context\n  $\\mathcal{C} \\ty (\\Gamma \\vdash A) \\Rightarrow (\\vdash \\Bool)$ closing over all\n  free variables, if $\\mathcal{C}[u] \\red \\err[\\Bool]$ or diverges,\n  then either $\\mathcal{C}[t] \\red \\err[\\Bool]$ or $\\mathcal{C}[t]$ diverges.\n\\end{definition}\n\nThe main difference with \\kl{observational error-approximation} is that\nin this definition, errors and divergence are collapsed.\nIn particular, equi-refinement does \\emph{not} imply \\kl{observational equivalence},\nbecause one term might diverge while the other reduces to an error.\nHappily, if the gradual dependent theory is strongly normalizing, both notions\n\\kl{observational error-approximation} $\\obsApprox$ and \\kl{observational refinement} $\\obsRef$\ncoincide.\n\n\\section{The Fire Triangle of Graduality}[Fire Triangle of Graduality]\n\\label{sec:fire-triangle}\n\nTo sum up, we have so far seen four important properties that can be expected from a\ngradual type theory:\n\\kl{safety}, \\kl{conservativity} with respect to a given static system, \\kl{graduality},\nand \\kl{normalization}. Any type theory ought to satisfy at least \\kl{safety}.\nUnfortunately, we now show that mixing the three other properties is impossible for \\kl{STLC},\nand \\textit{a fortiori} for \\kl{CIC}.\n\n\\subsection{Preliminary: regular reduction}\nTo derive this general impossibility result by relying only on the properties\nand without committing to a specific language or theory,\nwe need to assume that the reduction system used to decide conversion is \"regular\".\nThis means that it only looks at the \\kl(red){weak-head} normal forms of\nsub-terms for reduction rules,\nand does not magically shortcut reduction,\nfor instance based on the specific syntax of inner terms.\nAs an example, β-reduction is not allowed to look into the body of\nthe lambda term to decide how to proceed.\n\nThis property is satisfied in all actual systems we know of,\nbut formally stating it in full generality, in particular without devoting\nto a particular syntax, is beyond our current scope.\nFortunately, in the following, we rely only on a much weaker hypothesis,\nwhich is a slight strengthening of the retraction hypothesis of \\kl{embedding-projection pairs}.\nRecall that retraction says that when $A \\pre B$, any term $t$ of type $A$\nis equi-precise to $\\asc{\\asc{t}{B}}{A}$.\n\nWe additionally require that for any context $\\mathcal{C}$, if $\\mathcal{C}[t]$\nreduces at least $k$ steps, then $\\mathcal{C}[\\asc{\\asc{t}{B}}{A}]$ also reduces at\nleast $k$ steps.\nIntuitively, this means that the reduction of $\\mathcal{C}[\\asc{\\asc{t}{B}}{A}]$,\nwhile free to decide when to get rid of the embedding-to-$B$-projection-to-$A$,\ncannot use it to avoid reducing $t$.\nThis property is true in all gradual languages,\nwhere type information at runtime is used only as a monitor.\n\n\\subsection{Gradualizing \\kl(tit){STLC}}\nLet us first consider the case of \\kl{STLC}.\nWe show that $\\Omega$ is \\emph{necessarily} a well-typed, diverging term in any\ngradualization of \\kl{STLC} that satisfies the other properties.\n\n\\pagebreak\n\n\\begin{marginfigure}\n  \\includegraphics{Fire_triangle.pdf}\n  \\caption{The Fire Triangle of Graduality}\n\\end{marginfigure}\n\n\\begin{theorem}[\\reintro{Fire Triangle of Graduality} for \\kl{STLC}]\n  \\label{thm:triangle-STLC}\n\nSuppose a gradual type theory that satisfies both \\kl{conservativity} with respect to\n\\kl{STLC} and \\kl{graduality}. Then it cannot be \\kl{normalizing}.\n\n\\end{theorem}\n\n\\begin{proof}\n\n  We pose $\\Omega \\coloneqq \\delta\\ (\\asc{\\delta}{\\?})$ with\n  $\\delta \\coloneqq \\l x : \\?.\\ (\\asc{x}{\\? \\to \\?})~x$\n  and show that it must necessarily be a well-typed, diverging term.\n  %\n  Because the unknown type $\\?$ is consistent with any type (\\cref{sec:grad-simple}) and\n  $\\? \\to \\?$ is a valid type (by \\kl{conservativity}),\n  the self-applications in $\\Omega$ are well-typed,\n  $\\delta$ has type $\\? \\to \\?$, and $\\Omega$ has type $\\?$.\n  %\n  Now, we remark that $\\Omega = \\mathcal{C}[\\delta]$ with\n  $\\mathcal{C}[\\cdot] \\coloneqq [\\cdot]~(\\asc{\\delta}{\\?})$.\n  %\n\n  We show by induction on $k$ that $\\Omega$ reduces at least $k$\n  steps, the initial case being trivial.\n  %\n  Suppose that $\\Omega$ reduces at least $k$ steps.\n  % %\n  By maximality of $\\?$ with respect to precision, we have that\n  $\\? \\to \\? \\pre \\?$, so we can apply the strengthening of \\kl{graduality}\n  applied to $\\delta$, which tells us that\n  $\\mathcal{C}[\\asc{\\asc{\\delta}{\\?}}{\\?\\to\\?}]$\n  reduces at least $k$ steps, because $\\mathcal{C}[\\delta]$ reduces at least $k$ steps.\n  \n  But $\\Omega$ reduces in one step of β-reduction to\n  $\\mathcal{C}[\\asc{\\asc{\\delta}{\\?}}{\\?\\to\\?}]$.\n  So $\\Omega$ reduces at least $k+1$ steps.\n\n  This means that $\\Omega$ diverges, which is a violation of \\kl{normalization}.\n\\end{proof}\n\nThis result could be extended to all terms of the untyped lambda calculus, not only $\\Omega$,\nin order to obtain the embedding theorem of \\kl{GTLC} \\sidecite{Siek2015}.\nTherefore, the embedding theorem is not an independent property, but rather a consequence of \\kl{conservativity} and \\kl{graduality}. This is why we have not included it in\nour overview of the gradual approach in \\cref{sec:grad-simple}.\n\n\\subsection{Gradualizing \\kl(tit){CIC}}\nWe can now prove the same impossibility theorem for \\kl{CIC}, by reducing\nit to the case of \\kl{STLC}.\nIn general, this theorem can be proven for type theories others than \\kl{CIC},\nas soon as they faithfully embed \\kl{STLC}.\n\n\\begin{theorem}[\\intro{Fire Triangle of Graduality} for \\kl{CIC}]\n\\label{thm:triangle}\n\n  A gradual dependent type theory cannot simultaneously satisfy\n  \\kl{conservativity} with respect to \\kl{CIC}, \\kl{graduality} and \\kl{normalization}.\n\\end{theorem}\n\n\\begin{proof}\n  We show that a gradual dependent type theory satisfying \\kl{CIC} and \\kl{graduality}\n  must contain a diverging term, thus contravening \\kl{normalization}.\n  The typing rules of \\kl{CIC} contain the typing rules of \\kl{STLC},\n  using only one universe $\\uni[0]$,\n  and the notions of reduction coincide, so \\kl{CIC} embeds\n  \\kl{STLC}. This is a well-known result on \\kl{Pure Type Systems} \\sidecite{Barendregt1991}, of which \\kl{CCω} is one of many examples.\n  %\n  This means that \\kl{conservativity} with respect to \\kl{CIC} implies \\kl{conservativity}\n  with respect to \\kl{STLC}.\n\n  Additionally, \\kl{graduality} can be specialized to the simply-typed fragment of the theory,\n  by setting the unknown type $\\?$ to be $\\?[\\uni[0]]$.\n  We can then apply \\cref{thm:triangle-STLC},\n  and get a diverging well-typed term, finishing the proof.\n\\end{proof}\n\n\\subsection{The Fire Triangle in practice}\n\nIn non-dependent settings, all gradual languages where $\\?$ is universal\nadmit non-termination and therefore compromise \\kl{normalization}.\n\\sidetextcite{Garcia2020} discuss the possibility to gradualize \\kl{STLC}\nwithout admitting non-termination, for instance by considering that $\\?$ is not universal\nand denotes only base types%\n\\sidenote{In such a case, $\\? \\to \\? \\not \\pre \\?$,\n  so our argument involving $\\Omega$ is invalid.}.\nWithout sacrificing the universal unknown type, one could design a variant of \\kl{GTLC}\nthat uses some mechanism to detect divergence, such as termination contracts\n\\sidetextcite{Nguyen2019}. This would yield a language that certainly satisfies\n\\kl{normalization}, but it would break \\kl{graduality}. Indeed, because the contract system is\nnecessarily under-approximating in order to be sound – and actually imply \\kl{normalization} –,\nthere are effectively-terminating programs with imprecise variants that yield termination\ncontract errors.\n\n\\AP To date, the only related work that considers\nthe gradualization of full dependent types with\n$\\?$ as both a term and a type, is the work on \\intro{GDTL} \\sidecite{Eremondi2019}.\n\\kl{GDTL} is a programming language with a clear separation between the typing and execution \nphases, like \\kl{Idris} \\sidecite{Brady2013}.\n\\kl{GDTL} adopts a different strategy in each phase:\nfor typing, it uses \\intro{Approximate Normalization}, which always produces $\\?[A]$ as a result\nof going through imprecision and back. This implies that the system is \\kl{normalizing} – and thus that conversion is decidable –, but it breaks \\kl{graduality} for the same reason as the\ndegenerate system we discussed in \\cref{sec:graduality}%\n\\sidenote{The example uses a gain of precision from the unknown type to $\\Nat$,\n  so it behaves just the same in \\kl{GDTL}}.\nIn such a phased setting, the lack of computational content of Approximate Normalization is not\ncritical, because it only means that typing becomes overly optimistic.\nTo execute programs, \\kl{GDTL} relies on standard \\kl{GTLC}-like reduction semantics,\nwhich is computationally precise, but not \\kl{normalizing}.\n\n\\section{\\kl(tit){GCIC}: An Overview}\n\\label{sec:gcic-overview}\n\nGiven the \\kl{Fire Triangle of Graduality} (\\cref{thm:triangle}),\nwe know that gradualizing \\kl{CIC} implies making some compromise.\nInstead of focusing on one possible solution, we actually develop\na common parametrized framework, \\kl{GCIC}, where the parameters control\nwhich of the three properties – \\kl{normalization}, \\kl{graduality} and \\kl{conservativity} –\nis compromised. \nThis section gives an informal, non-technical overview of this system,\nhighlighting the main challenges and results.\n\n\\subsection{Three in one}\n\\label{sec:gcic:-3-1}\n\n\\paragraph{Two parameters…}\n\nTo explore the spectrum of possibilities opened by the \\kl{Fire Triangle of Graduality},\nwe develop a general approach to gradualizing \\kl{CIC}, and use it to define three theories, corresponding to different resolutions of the triangular tension between \\kl{normalization}, \\kl{graduality} and \\kl{conservativity} with respect to \\kl{CIC}.\n\nThe crux of our approach is to recognize that, while there is not much to vary within \\kl{STLC} itself to address the tension of the \\kl{Fire Triangle of Graduality},\nthere are several variants of \\kl{CIC} that can be considered by changing\nthe hierarchy of universes and its impact on typing –\nafter all, its core \\kl{CCω}\nis but a particular \\kl{Pure Type System} \\sidecite{Barendregt1991}.\nThus, we consider a parametrized version of a gradual \\kl{CIC}, called\n\\kl{GCIC}, with two parameters%\n\\sidenote{This system is precisely detailed in \\cref{fig:ccic-ty}}.\n\n\\AP The first parameter characterizes how the universe level of a Π-type is determined\nin typing rules: either as taking the \\emph{maximum} of the levels of the involved \ntypes – as in standard \\kl{CIC} – or as the \\emph{successor} of that maximum.\nThe latter option yields a variant of \\kl{CIC} that we call \\intro{CICs} – read “\\kl{CIC}-shift”.\n\\kl{CICs} is a subset of \\kl{CIC}, with a stricter constraint on universe levels.\nIn particular \\kl{CICs} loses the closure of universes under\ndependent functions that \\kl{CIC} enjoys.\nAs a consequence, some well-typed \\kl{CIC} terms are not well-typed in \\kl{CICs}.%\n\\sidenote{\n  A typical example of a well-typed \\kl{CIC} term that is ill typed in \\kl{CICs} is\n  $\\narrow \\ty \\Nat \\to \\uni$, where $\\narrow n$ is the type of functions that\n  accept $n$ arguments. Such dependent arities violate the universe constraint of \\kl{CICs}.}\n\nThe second parameter is the dynamic counterpart of the first parameter:\nits role is to control universe levels during the reduction of type casts between Π-types.\nWe only allow this reduction parameter to be loose – \\ie~using maximum –\nif the typing parameter is also loose. Indeed, letting the typing parameter be strict \n– \\ie using successor of the maximum – while the reduction parameter is loose\nbreaks subject reduction, and hence \\kl{safety}.\n\n\\paragraph{… and three meaningful theories.}\n\nBased on these parameters, we develop the following three variants of \\kl{GCIC},\nwhose properties are summarized in \\cref{fig:gcic-summary}\n% with pointers to the respective theorems\n– because \\kl{GCIC} is one common parametrized framework,\nwe are able to establish most properties for all variants at once.\n\n\\AP The first variant, \\intro{GCICP},\nis a theory that satisfies both \\kl{conservativity} with respect to \\kl{CIC}\nand \\kl{graduality}, but sacrifices \\kl{normalization}.\nThis theory is a rather direct application of the\nprinciples discussed in \\cref{sec:graduality} by extending \\kl{CIC}\nwith \\kl{errors} and \\kl{unknown terms}, and replacing \\kl{conversion} with\n\\kl(grad){consistency}. This results in a theory that is not normalizing.\n\n\\AP Next, \\intro{GCICs} satisfies both \\kl{normalization} and \\kl{graduality},\nand supports \\kl{conservativity}, but only with respect to \\kl{CICs}.\nThis theory uses the universe hierarchy at the \\emph{typing level} to detect and forbid\nthe potential non-termination induced by the use of \\kl(grad){consistency}\ninstead of \\kl{conversion}.\n\n\\AP Finally, \\intro{GCICT} satisfies both \\kl{conservativity} with respect to \\kl{CIC}\nand \\kl{normalization}, but does not fully validate \\kl{graduality}.\nThis theory uses the universe hierarchy at the \\emph{computational level} to detect\npotential divergence, eagerly raising errors.\nSuch runtime failures invalidate the \\kl{DGG} for some terms,\nand hence \\kl{graduality}, as well as the \\kl{SGG}, since in our dependent setting it depends\non the \\kl{DGG}.\n\n\\begin{figure*}[h]\n  \\begin{tabular}{ccccccc}\n   & \\kl{Safety} & \\kl{Normalization} & \\kl{Conservativity} wrt. & \\kl{Graduality} & \\kl{SGG} & \\kl{DGG} \\\\\n  \\kl{GCICP} \\rule{0pt}{4ex}\n    & {\\checksymbol {\\checksymbol ✓}} %\\footnotesize{(Th.~\\labelcref{thm:ccic-psafe})}\n    & {\\checksymbol ✗}\n    & \\kl{CIC} %\\footnotesize{(Th.~\\labelcref{thm:conservativity})}\n    & {\\checksymbol ✓} %\\footnotesize{(Th. ~\\labelcref{thm:GCICP-graduality})}\n    & {\\checksymbol ✓} %\\footnotesize{(Th.~\\labelcref{thm:static-graduality})}\n    & {\\checksymbol ✓} %\\footnotesize{(Th.~\\labelcref{thm:dgg})}\\\\\n  \\\\\n  \\kl{GCICs} \\rule{0pt}{4ex}\n    & {\\checksymbol ✓} %\\footnotesize{(idem)}\n    & {\\checksymbol ✓} %\\footnotesize{(Th.~\\labelcref{thm:ccic-pnorm} \\& \\labelcref{thm:discrete-model})}\n    & \\kl{CICs}  %\\footnotesize{(idem)}\n    & {\\checksymbol ✓} %\\footnotesize{(Th.~\\labelcref{thm:graduality-gcics})}\n    & {\\checksymbol ✓} %\\footnotesize{(idem)}\n    & {\\checksymbol ✓} %\\footnotesize{(Th.~\\labelcref{thm:dgg})}\\\\\n  \\\\\n  \\kl{GCICT} \\rule{0pt}{4ex}\n    & {\\checksymbol ✓} %\\footnotesize{(idem)}\n    & {\\checksymbol ✓} %\\footnotesize{(idem)}\n    & \\kl{CIC} %$\\mathsf{CIC}$\\phantom{$^{\\uparrow}$}    \\footnotesize{(idem)}\n    & {\\checksymbol ✗}  \n    & {\\checksymbol ✗}\n    & {\\checksymbol ✗}\\\\\n  \\end{tabular}\\\\\n  \n  \\caption{\\kl{GCIC} variants and their properties}\n  \\label{fig:gcic-summary}\n\\end{figure*}\n\n\\paragraph{Practical implications of \\kl{GCIC} variants.}\nRegarding our introductory examples, all three variants of \\kl{GCIC}\nsupport the exploration of the type-level precision spectrum.\nIn particular, we can define \\coqe{filter} by giving it the imprecise type\n\\begin{coqcode}\n  forall A n (p : A -> 𝔹), vec A n -> vec A (? ℕ)\n\\end{coqcode}\nin order to bypass the difficulty of precisely characterizing the size of the output vector.\nAny invalid optimistic assumption is detected during reduction and reported as an error.\n\nUnsurprisingly, the semantic differences between the three \\kl{GCIC} variants crisply manifest in the treatment of potential non-termination, more specifically, \\emph{self application}.\n%\nLet us come back to the term $\\Omega$\nused in the proof of~\\cref{thm:triangle}.\nIn all three variants, this term is well-typed. In \\kl{GCICP}, it\nreduces forever, as it would in the untyped lambda calculus:\n\\kl{GCICP} can embed the untyped lambda calculus, just as\n\\kl{GTLC} \\sidecite{Siek2015}. In \\kl{GCICT}, this term fails at runtime\nbecause of the strict universe check in the reduction of casts, which\nbreaks graduality because $\\?[\\uni[i]] \\to \\?[\\uni[i]] \\pre \\?[\\uni[i]]$\ntells us that the upcast-downcast coming from an \\kl{ep-pair} should not fail.\n%\nIn \\kl{GCICs}, $\\Omega$ fails in the same way as in \\kl{GCICT}, but this\ndoes not break graduality because of the shifted universe level on Π-types.\n%\nIndeed, a consequence of this stricter typing rule is that in \\kl{GCICs},\n$\\?[\\uni[i]] \\to \\?[\\uni[i]] \\pre \\?[\\uni[j]]$\nfor any $j > i$, but $\\?[\\uni[i]] \\to \\?[\\uni[i]] \\npre \\?[\\uni[j]]$.\nTherefore, the casts performed in $\\Omega$ do not come from an \\kl{ep-pair}\nany more, and can thus legitimately fail.\n%\nThis is described in full details in \\cref{sec:back-to-omega}.\n\nAnother scenario where the differences in semantics manifest is functions with\n\\emph{dependent arities}.\nFor instance, the well-known C function \\printf{} can be embedded in a well-typed fashion in\n\\kl{CIC}: it takes as first argument a format string and computes from it both\nthe type and \\emph{number} of later arguments.\nIn \\kl{GCICP} it can be gradualized as much as one wants, without surprises.\n%\nThis function, however, brings into light the limitation of \\kl{GCICs}:\nsince the format string can specify an arbitrary number of arguments,\nwe need as many $\\to$, and \\printf{} cannot be well-typed\nin a theory where universes are not closed under function types.\n%\nIn \\kl{GCICT}, \\printf{} is well-typed, but the same problem will appear dynamically\nwhen casting \\printf{} to $\\?$ and back to its original type: the result will be\na function that works only on format strings specifying no more arguments than\nthe universe level at which it has been typed.\n%\nNote that this constitutes an example of violation of graduality for\n\\kl{GCICT}, even of the dynamic gradual guarantee.\n\n\\paragraph{Which variant to pick?}\nAs explained in the introduction, the aim here is to shed light on the design space of gradual\ndependent type theories, not to advocate for one specific design.\n%\nThe appropriate choice indeed depends on the specific goals of the language designer,\nor perhaps more pertinently, on the specific goals of a given project,\nat a specific point in time.\nThe key characteristics of each variant are as follows.\n\n\\kl{GCICP} favours flexibility over decidability of type-checking. While this might appear\nheretical in the context of proof assistants, this choice has been embraced by practical languages such as \\kl{Dependent Haskell} \\sidecite{Eisenberg2016},\nwhere both divergence and runtime errors can happen at the type\nlevel. The pragmatic argument is simplicity: by letting programmers be responsible,\nthere is no need for termination checking techniques and other restrictions.\n\n\\kl{GCICs} is theoretically pleasing as it enjoys both normalization and graduality.\nIn practice, though, the fact that it is not conservative with respect to full \\kl{CIC}\nmeans that one would not be able to simply import existing libraries as soon as they\nfall outside the \\kl{CICs} subset.\nIn \\kl{GCICs}, the introduction of $\\?$ should be done with an appropriate understanding of\nuniverse levels. This might not be a problem for advanced programmers,\nbut would surely be harder to grasp for beginners.\n\nFinally, \\kl{GCICT} is normalizing and able to import existing libraries without restrictions,\nat the expense of some surprises on the graduality front.\nProgrammers would have to be willing to accept that they cannot just sprinkle $\\?$\nas they see fit without further consideration,\nas any dangerous usage of imprecision will be flagged during conversion.\n\nIn the same way that systems like \\kl{Coq}, \\kl{Agda} or \\kl{Idris} support\ndifferent ways to customize their semantics regarding termination,%\n\\sidenote{With the possibility to allow $\\uni : \\uni$, switch off termination checking,\nuse the partial/total compiler flags…}\nand of course, many programming languages implementations supporting some sort of customization%\n\\sidenote{GHC is a salient representative.}\none can imagine a flexible realization of \\kl{GCIC} that give users the control over the two\nparameters we identify in this work, and therefore lets them access all three \\kl{GCIC} variants.\n%\nConsidering the inherent tension captured by the \\kl{Fire Triangle of Graduality},\nsuch a pragmatic approach might be the most judicious choice,\nmaking it possible to gather experience and empirical evidence about\nthe pros and cons of each in a variety of concrete scenarios.\n\n\\subsection{Typing, conversion and bidirectional elaboration}\n\nAs explained in \\cref{sec:grad-simple},\nin a gradual language, whenever we reclaim precision, we might be wrong and need to fail in order to preserve \\kl{safety}.\n%\nIn a simply-typed setting, the standard approach is to define typing on a\ngradual source language, and then to translate terms via a type-directed elaboration\nto a target \\emph{cast calculus}, \\ie a language with explicit runtime type\nchecks.\nThis elaboration inserts casts, needed for a well-behaved reduction \\sidecite{Siek2006}.\nFor instance, in a call-by-value language, the upcast (loss of precision)\n$\\castrev{10}{\\Nat}{\\?}$ is considered a (tagged) value,\nand the downcast (gain of precision) $\\castrev{v}{\\?}{\\Nat}$ reduces successfully\nif $v$ is such a tagged natural number, or to an error otherwise.\n\n\\AP We follow a similar approach for \\kl{GCIC}, which is\nelaborated in a type-directed manner to a second calculus,\nnamed \\reintro{CastCIC} (\\cref{sec:cast-calculus}).\nThe interplay between typing and cast insertion is however more subtle in the\ncontext of a dependent type theory. Because typing needs computation, and\nreduction is only meaningful in the target language, \\kl{CastCIC} is used\n\\emph{as part of the elaboration} in order to compare types (\\cref{sec:elaboration}).\nThis means that \\kl{GCIC} has no typing on its own, independent of its\nelaboration to \\kl{CastCIC}.%\n\\sidenote{This is similar to what happens in practice in proof assistants such as \\kl{Coq}\n\\cite[Core language]{CoqManual}, where terms input by the user in the \\kl{Gallina} language\nare first elaborated in order to add implicit arguments, coercions, etc.\nThe computation steps required by conversion are\nperformed on the elaborated terms, never on the raw input syntax.}%\n\\margincite{CoqManual}\n\nIn order to satisfy \\kl{conservativity} with respect to \\kl{CIC}, ascriptions in \\kl{GCIC}\nare required to satisfy \\kl(grad){consistency}. For instance, $\\asc{\\asc{\\true}{\\?}}{\\Nat}$ is well-typed by \\kl(grad){consistency} – used twice –, but $\\asc{\\true}{\\Nat}$ is ill-typed.\nSuch ascriptions in \\kl{CastCIC} are realized by casts.\nFor instance $\\asc{\\asc{\\z}{\\?}}{\\Bool}$ in \\kl{GCIC} elaborates\n– up to desugaring and reduction – to\n$\\castrev{\\castrev{\\z}{\\Nat}{\\?[\\uni]}}{\\?[\\uni]}{\\Bool}$ in \\kl{CastCIC}.\nA major difference between ascriptions in \\kl{GCIC} and casts in \\kl{CastCIC} is\nthat casts are not required to satisfy \\kl(grad){consistency}: a cast between any\ntwo types is well-typed, although of course it might produce an\nerror.\n\nThis is where the bidirectional structure is crucial.\nFirst, it is required in order to tame the non-transitive \\kl(grad){consistency} relation.\nIndeed, in the previous example of $\\asc{\\true}{\\Nat}$, if one kept a free-standing rule like\n\\ruleref{rule:cic-conv} and simply replaced \\kl{conversion} by \\kl(grad){consistency}, one could\nuse the rule twice, through $\\?$, and the term would be well-typed.\nBut \\kl(grad){consistency} demands that only terms with explicitly-ascribed\nimprecision enjoy its flexibility.\nThis observation is standard in the gradual typing literature\n\\sidecite{Siek2006,Siek2007,Garcia2016}, but becomes even more crucial in the context of\ngradual dependent types \\sidecite{Eremondi2019}.\nMoreover, the bidirectional structure is very suited to the description of\na type-based elaboration, and directly translates to a deterministic typing/elaboration\nalgorithm for \\kl{GCIC}.\n\n\\subsection{Precisions and properties}\n\\label{sec:precision-graduality}\n\nAs explained earlier (\\cref{sec:graduality}), we need three different notions of\nprecision to deal with \\kl{SGG} and \\kl{graduality}.\n\n\\AP At the source level – \\kl{GCIC} –,\nwe introduce a notion of \\reintro{syntactic precision}, that captures the\nintuition of a more imprecise term as \"the same term with sub-terms and/or\ntype annotations replaced by $\\?$\", and is defined without any assumption of typing.\nIn \\kl{CastCIC}, we define a notion of \\reintro{structural precision},\nwhich is mostly syntactic except that, in order to account for cast insertion during elaboration, it tolerates precision-preserving casts.\nFor instance, $\\castrev{t}{A}{A}$ is related to $t$ by \\kl{structural precision}.\n\nArmed with these two notions of precision, we prove\n% We prove that \\GCIC satisfies static graduality.\\km{forward ref?}\n% However, because \\GCIC does not have a type system, we rather prove\n\\kl{elaboration graduality} (\\cref{thm:static-graduality}), which is\nthe equivalent of the \\kl{static gradual guarantee} in our setting:\nif a term $t$ of \\kl{GCIC} elaborates to a term $t'$ of \\kl{CastCIC},\nthen a term $u$ less syntactically precise than $t$ in \\kl{GCIC} elaborates to\na term $u'$ less structurally precise than $t'$ in \\kl{CCIC}.\n%\nBecause \\kl{DGG} is about the behaviour of terms during reduction,\nit is technically stated and proven for \\kl{CastCIC}.\nWe show in \\cref{sec:gcic-theorems} that \\kl{DGG} can be proven\nfor \\kl{CastCIC} – in its variants \\kl{CCICP} and \\kl{CCICs} – on \\kl{structural\nprecision}.\n\n\\AP However, as explained in \\cref{sec:grad-simple}, we cannot expect to prove \\kl{graduality}\nfor these \\kl{CastCIC} variants with respect to \\kl{structural precision} directly.\nIn order to overcome this problem, and to justify the design of \\kl{CastCIC},\nwe build two kinds of models for \\kl{CastCIC}. The first%\n\\sidenote{That we call the \\reintro{discrete model}.} is a syntactic model\n\\sidecite{Boulier2018} – akin to a program translation or a compilation phase –,\nand is used to justify the reduction rules and prove that they are terminating.\nThe second%\n\\sidenote{That we call the \\reintro{monotone model}}\nendows types with the structure of an ordered set, or poset. This makes it\npossible to reason about the semantic notion of \\reintro{propositional\nprecision} and prove that it gives rise to \\kl{embedding-projection pairs},\nthereby establishing \\kl{graduality}.\n%\n% The monotone model only works for a normalizing gradual type theory,\n% thus we then establish \\pgrad for \\CCICP using a variant of the\n% monotone model based on Scott's\n% model~\\cite{scott76} of the untyped $\\lambda$-calculus using $\\omega$-complete\n% partial orders (\\cref{sec:grad-non-term}).\nThese models are described in \\cref{sec:realizing-cast-calculus}.", "meta": {"hexsha": "1a315ac25a8bad7151cefdd4559813c8ea14b84a", "size": 71930, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/gradual-dependent.tex", "max_stars_repo_name": "MevenBertrand/PhD-Thesis", "max_stars_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Manuscript/gradual-dependent.tex", "max_issues_repo_name": "MevenBertrand/PhD-Thesis", "max_issues_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-22T14:04:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T18:26:29.000Z", "max_forks_repo_path": "Manuscript/gradual-dependent.tex", "max_forks_repo_name": "MevenBertrand/PhD-Thesis", "max_forks_repo_head_hexsha": "5bb9852b747bf0700d7c60b74dc64e11372478f8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.9205397301, "max_line_length": 413, "alphanum_fraction": 0.7559571806, "num_tokens": 19191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4092859536173254}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% Latex stylesheet for influence diagrams\n%\n% Version: 2021-01-11.3\n%\n% Copyright 2020 Tom Everitt\n%\n% Licensed under the Apache License, Version 2.0 (the \"License\");\n% you may not use this file except in compliance with the License.\n% You may obtain a copy of the License at\n%\n%     http://www.apache.org/licenses/LICENSE-2.0\n%\n% Unless required by applicable law or agreed to in writing, software\n% distributed under the License is distributed on an \"AS IS\" BASIS,\n% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n% See the License for the specific language governing permissions and\n% limitations under the License.\n\n\n\\documentclass{article}\n\\usepackage[decisionutilitycolor]{influence-diagrams}\n\\NewDocumentCommand\\voci{O{}D<>{1}m}{\\incentive{#3}{incentive, gray,#1}{#2}}\n\n\\begin{document}\n\n\n\\section{Simple Diagram}\n\n\\begin{influence-diagram}\n      \\node (A) [decision] {$A_1$};\n      \\node (X) [right = of A] {$X$};\n      \\node (U) [right = of X, utility] {$R_1$};\n\n      \\edge {A} {X};\n      \\edge {X} {U};\n\\end{influence-diagram}\n\n\n\\section{MDP}\n\n\n\\begin{influence-diagram}\n\n  \\node (S1) {$S_1$};\n  \\node (S2) [right = 2 of S1] {$S_2$};\n  \\node (S3) [right = 2 of S2] {$S_3$};\n\n  \\node (R1) [below = of S1, utility] {$R_1$};\n  \\node (R2) [below = of S2, utility] {$R_2$};\n  \\node (R3) [below = of S3, utility] {$R_3$};\n\n  \\node (A1) at ($(R1)!0.5!(R2)$) [decision] {$A_1$};\n  \\node (A2) at ($(R2)!0.5!(R3)$) [decision] {$A_2$};\n\n  \\node (thetaT) [above = of S1] {$\\Theta_T$};\n  \\node (thetaR) [below = of R1] {$\\Theta_R$};\n\n  \\edge {S1, thetaR} {R1};\n  \\edge {S2, thetaR} {R2};\n  \\edge {S3}         {R3};\n\n  \\edge {thetaT}         {S1};\n  \\edge {thetaT, A1, S1} {S2};\n  \\edge {thetaT, A2, S2} {S3};\n\n  \\edge[information] {S1, R1} {A1};\n  \\edge[information] {S2, R2} {A2};\n\n  \\path (thetaR) edge[->, bend right=10] (R3);\n\n  \\node (help) [minimum size=0mm, node distance=2mm, below left = of R1, draw=none] {};\n\n  \\draw[information]\n  (S1) edge[ in=135, out=-120] (help.center)\n  (help.center) edge[->, out=-45, in=-150] (A2);\n\n\\end{influence-diagram}\n\\vspace{1cm}\n\n\\begin{influence-diagram}\n  \\node (S1) {$S_1$};\n  \\node (S2) [right = 2 of S1] {$S_2$};\n  \\node (S3) [right = 2 of S2] {$S_3$};\n\n  \\node (R1) [below = of S1, utility] {$R_1$};\n  \\node (R2) [below = of S2, utility] {$R_2$};\n  \\node (R3) [below = of S3, utility] {$R_3$};\n\n  \\node (A1) at ($(R1)!0.5!(R2)$) [decision] {$A_1$};\n  \\node (A2) at ($(R2)!0.5!(R3)$) [decision] {$A_2$};\n\n  \\node (thetaT) [above = of S1] {$\\Theta_T$};\n  \\node (thetaR) [below = of R1] {$\\Theta_R$};\n\n  \\edge {S1, thetaR} {R1};\n  \\edge {S2, thetaR} {R2};\n  \\edge {S3}         {R3};\n\n  \\edge {thetaT}         {S1};\n  \\edge {thetaT, A1, S1} {S2};\n  \\edge {thetaT, A2, S2} {S3};\n\n  \\edge[information] {S1, R1} {A1};\n  \\edge[information] {S2, R2} {A2};\n\n  \\path (thetaR) edge[->, bend right=10] (R3);\n\n  \\node (help) [node distance=4mm, below left = of R1, phantom] {};\n\n  % This bent edge sticks an invisible control point out too far and messes\n  % with the bounding box so have the bounding box ignore it\n  \\begin{pgfinterruptboundingbox}\n    \\draw[information]\n    (S1) edge[in=135, out=-120]\n    % Bounding box helper\n    % Place at the bend point or wherever the line is furthest past the\n    % bounding box\n    % Must be manually positioned using pos=(fraction of path length)\n    % since the bend point is not necessary half way along the path.\n    node[phantom, pos=0.75] (bbhelper) {}\n    (help)\n    (help) edge[->, out=-45, in=-150] (A2);\n  \\end{pgfinterruptboundingbox}\n\n  % Place another node at the bbhelper; this time included by the bounding box\n  % Manually adjust minimum size to compensate for any slight misalignment\n  % with the bend point of the path and to fully include the path line width.\n  \\node[draw=none, minimum size=1pt, inner sep=0] at (bbhelper) {};\n\n\n  \\draw[black] (current bounding box.south west) rectangle (current bounding box.north east);\n\n\\end{influence-diagram}\n\n\\section{Legend}\n\n\\begin{influence-diagram}\n\n    \\cidlegend{\n      \\legendrow{}{chance node} \\\\\n      \\legendrow{decision}{decision node}\\\\\n      \\legendrow{utility}{utility node}\\\\\n      \\legendrow[causal]{draw=none}{causal link} \\\\\n      \\legendrow[information]{draw=none}{information link} \\\\\n      \\legendrow{value of information}{Value of Information}\\\\\n      \\legendrow{value of control}{Value of Control} \\\\\n      \\legendrow{response incentive}{Response Incentive}\\\\\n      \\legendrow{feasible control incentive}{Control Incentive}\\\\\n    }\n\n    \\path (causal.west) edge[->] (causal.east);\n    \\path (information.west) edge[->, information] (information.east);\n\n\\end{influence-diagram}\n\n\n\\section{Incentives}\n\n\\begin{influence-diagram}\n  \\node (S1) {$S_1$};\n\n  \\voi<1>{S1}\n  \\ri<2>{S1}\n  \\fci<3>{S1}\n  \\voc<4>{S1}\n\n  % newly defined\n  \\voci<5>{S1}\n\\end{influence-diagram}\n\n\\begin{influence-diagram}\n  %\\setcompactsize\n  \\node (A) [decision] {$A_1$};\n  \\node (X) [right = of A] {$X$};\n  \\node (U) [right = of X, utility] {$R_1$};\n\n  \\edge {A} {X};\n  \\edge {X} {U};\n\n  \\fci{X}\n  \\fci[rectangle]{A}\n  \\fci[diamond]<3>{U}\n\\end{influence-diagram}\n\n\n\\section{Multi-agent CIDs}\n\n% MACID\n\\begin{influence-diagram}\n\n  \\node (help) [draw=none] {};\n  \\node (P1) [above = of help, decision, player1] {$D_1$};\n  \\node (P2) [below = of help, decision, player2] {$D_2$};\n  \\node (U1) [right = of help, utility, player1] {$U_1$};\n  \\node (U2) [left = of help, utility, player2] {$U_2$};\n  \\node (C) at (U2|-P1) {$C$};\n\n  \\edge[information] {C} {P1};\n  \\edge[information] {P1} {P2};\n  \\edge {P1,P2} {U1};\n  \\edge {C,P1,P2} {U2};\n\\end{influence-diagram}\n% Relevance graph\n\\begin{influence-diagram}\n\n  \\node (D1) [relevanceb] {$D_1$};\n  \\node (D2) [below = of D1, relevanceb] {$D_2$};\n\n  \\path (D1) edge[->, bend right=15] (D2);\n  \\path (D2) edge[->, bend right=15] (D1);\n\n\\end{influence-diagram}\n\n\\section{Rectangular}\n\n\\begin{influence-diagram}\n  \\setrectangularnodes\n\n  \\node (R) [] {Race};\n  \\node (S) [below= of R] {High school};\n  \\node (E) [below= of S] {Education};\n  \\node (Gr) [below=of E] {Grade};\n  \\node (D) [right=of S,decision] {Predicted grade};\n  \\node (Ge) [above=of D] {Gender};\n  \\node (U) [utility] at (D|-Gr) {Accuracy};\n\n  \\edge {R} {S};\n  \\edge {S} {E};\n  \\edge[information] {S,Ge} {D};\n  \\edge {E} {Gr};\n  \\edge {D,Gr} {U};\n\n%  \\node [inner sep=4mm, fit = (E), feasible control incentive] {};\n\n  \\voi{S}\n  \\voi{E}\n  \\voi{Gr}\n  \\ri{R}\n  \\ri<2>{S}\n\\end{influence-diagram}\n\n\\section{Compact}\n\n\\begin{influence-diagram}\n  \\setcompactsize\n  \\node (A) [decision] {$A_1$};\n  \\node (X) [right = of A] {$X$};\n  \\node (U) [right = of X, utility] {$R_1$};\n\n  \\edge {A} {X};\n  \\edge {X} {U};\n\n  \\fci{X}\n  \\fci[rectangle]{A}\n  \\fci[diamond]<5>{U}\n\\end{influence-diagram}\n\n\n\\begin{influence-diagram}\n  \\setrectangularnodes\n  \\setcompactsize\n\n  \\node (R) [] {Race};\n  \\node (S) [below= of R] {High school};\n  \\node (E) [below= of S] {Education};\n  \\node (Gr) [below=of E] {Grade};\n  \\node (D) [right=of S,decision] {Predicted grade};\n  \\node (Ge) [above=of D] {Gender};\n  \\node (U) [utility] at (D|-Gr) {Accuracy};\n\n  \\edge {R} {S};\n  \\edge {S} {E};\n  \\edge[information] {S,Ge} {D};\n  \\edge {E} {Gr};\n  \\edge {D,Gr} {U};\n\n  \\voi{S}\n  \\voi{E}\n  \\voi{Gr}\n  \\ri{R}\n  \\ri<2>{S}\n\\end{influence-diagram}\n\n\n\\section{Putting it all together}\n\n\\begin{influence-diagram}\n\n  \\node (S1) {$S_1$};\n  \\node (S2) [right = 2 of S1] {$S_2$};\n  \\node (S3) [right = 2 of S2] {$S_3$};\n\n  \\node (R1) [below = of S1, utility] {$R_1$};\n  \\node (R2) [below = of S2, utility] {$R_2$};\n  \\node (R3) [below = of S3, utility] {$R_3$};\n\n  \\node (A1) at ($(R1)!0.5!(R2)$) [decision] {$A_1$};\n  \\node (A2) at ($(R2)!0.5!(R3)$) [decision] {$A_2$};\n\n  \\node (thetaR) [below = of R1] {$\\Theta_R$};\n\n  \\edge {S1, thetaR} {R1};\n  \\edge {S2, thetaR} {R2};\n  \\edge {S3}         {R3};\n\n  \\edge {A1, S1} {S2};\n  \\edge {A2, S2} {S3};\n\n  \\edge[information] {S1, R1} {A1};\n  \\edge[information] {S2, R2} {A2};\n\n  \\path (thetaR) edge[->, bend right=10] (R3);\n\n  \\node (help) [minimum size=0mm, node distance=2mm, below left = of R1, draw=none] {};\n\n  \\draw[information]\n  (S1) edge[ in=135, out=-120] (help.center)\n  (help.center) edge[->, out=-45, in=-150] (A2);\n\n  \\fci{S2}\n  \\fci{S3}\n  \\ri{thetaR}\n\n  \\cidlegend[right=of S3.north east, anchor=north west]{\n    \\legendrow{}{chance node} \\\\\n    \\legendrow{decision}{decision node}\\\\\n    \\legendrow{utility}{utility node}\\\\\n    \\legendrow[causal]{draw=none}{causal link} \\\\\n    \\legendrow[information]{draw=none}{information link} \\\\\n    \\legendrow{response incentive}{Response Incentive}\\\\\n    \\legendrow{feasible control incentive}{Control Incentive}\\\\\n  }\n\n  \\path (causal.west) edge[->] (causal.east);\n  \\path (information.west) edge[->, information] (information.east);\n\n\n\\end{influence-diagram}\n\n\n\\end{document}\n", "meta": {"hexsha": "8e9be9795b3678fc156c6c8173f6bef0d8458056", "size": 8858, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "examples.tex", "max_stars_repo_name": "djinnome/cid-latex", "max_stars_repo_head_hexsha": "1fa3fecf4d92d92683ab5d8f85398e3055f10f15", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples.tex", "max_issues_repo_name": "djinnome/cid-latex", "max_issues_repo_head_hexsha": "1fa3fecf4d92d92683ab5d8f85398e3055f10f15", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples.tex", "max_forks_repo_name": "djinnome/cid-latex", "max_forks_repo_head_hexsha": "1fa3fecf4d92d92683ab5d8f85398e3055f10f15", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.75, "max_line_length": 93, "alphanum_fraction": 0.6023933168, "num_tokens": 3347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4092859401460491}}
{"text": "\\documentclass[12pt]{article}\r\n\\usepackage[margin=1in]{geometry}\r\n\\usepackage[T1]{fontenc}\r\n\\usepackage[USenglish]{babel}\r\n\\usepackage[nodayofweek,level]{datetime}\r\n\\usepackage{amsfonts}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{tikz}\r\n\\usetikzlibrary{intersections,arrows.meta}\r\n\\usepackage{pgfplots}\r\n\\usepackage[scr]{rsfso}\r\n\\usepackage{array}\r\n\r\n\\usepackage{tikz,pgfplots}\r\n\r\n\\pgfplotsset{compat=1.10}\r\n\\usepgfplotslibrary{fillbetween}\r\n% Change due date below\r\n\\newcommand{\\dueDate}{\\formatdate{13}{10}{2017}}\r\n\r\n\\begin{document}\r\n\t\r\n%\\selectlanguage{USenglish}\t\r\n\r\n\\title{Homework: Week 2}\r\n\\author{Joseph Ismailyan}\r\n\\date{}\r\n\\maketitle\r\n\\begin{flushleft}\r\nMath 100 \\\\\r\nDue: \\dueDate \\\\ \r\nProfessor Boltje \\\\\r\nMWF 9:20a-10:25a\r\n\\end{flushleft}\r\n\r\n% Insert first section here\r\n% Minipage creates the columns\r\n\\begin{minipage}[t]{0.40\\textwidth}\r\n\\section*{Section 1.6}\r\n\r\n\\subsection*{6.}\r\n\\begin{tikzpicture}\r\n\\begin{axis}[\r\nxmin=-2, xmax=2,\r\nymin=-1, ymax=2,\r\naxis lines=center,\r\naxis on top=true,\r\ndomain=0:1,\r\nxlabel={$x$},\r\nylabel={$y$},\r\naxis line style={latex-latex}\r\n]\r\n\\addplot [\r\nname path=A,\r\ndomain=-1.4:1.4,\r\nsamples=100, \r\ncolor=black,\r\n%dashed,\r\n<->,\r\n] \r\n{x^2}\r\nnode [pos=0.85, below right]{$ y\\geq x^2 $};\r\n\\addplot [name path=B,opacity=0,domain=-1.4:1.4] {1.96};\r\n\\addplot[gray!50] fill between[of=A and B];\r\n\\end{axis}\r\n\\end{tikzpicture}\r\n\\bigskip\r\n\r\n\\end{minipage}\r\n% Creates verticle line\r\n\\hfill\\vline\\hfill\r\n\\begin{minipage}[t]{0.45\\textwidth}\r\n\r\n\r\n\r\n\\section*{Section 1.7}\r\n\r\n\\begin{tikzpicture}[fill=gray!50]\r\n% outline\r\n\\fill (-2,-2) rectangle (3,2);\r\n\\fill[white] (0,0) circle (1);\r\n\\fill[white] (1,0) circle (1);\r\n\\draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$}\r\n(1,0) circle (1) (1,1)  node [text=black,above] {$B$}\r\n(-2,-2) rectangle (3,2) node [text=black,above left] {$U$};\r\n\\node[anchor=south] at (current bounding box.north) {$ \\overline{A \\cup B}$};\r\n\\end{tikzpicture}\r\n\r\n\\bigskip\r\n\r\n\\begin{tikzpicture}[fill=gray!50]\r\n% outline\r\n\\fill (-2,-2) rectangle (3,2);\r\n\\fill[white] (0,0) circle (1);\r\n\\fill[white] (1,0) circle (1);\r\n\\draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$}\r\n(1,0) circle (1) (1,1)  node [text=black,above] {$B$}\r\n(-2,-2) rectangle (3,2) node [text=black,above left] {$U$};\r\n\\node[anchor=south] at (current bounding box.north) {$\\overline{A} \\cap \\overline{B}$};\r\n\\end{tikzpicture}\r\n\\\\\r\n\r\nAnswer: From the two diagrams above, we can see that the sets are equal.\r\n\\end{minipage}\r\n\\pagebreak\r\n\r\n\r\n\\begin{minipage}[t]{0.40\\textwidth}\r\n\t\\section*{Section 1.8}\r\n\\subsection*{6(a).}\r\nAnswer:\r\n$\\bigcup\\limits_{ i \\in \\mathbb{N}}[0,i+1]=[0,\\infty)$\r\n\r\n\r\n\\subsection*{6(b).}\r\nAnswer:\r\n$\\bigcap\\limits_{ i \\in \\mathbb{N}}[0,i+1]=[0,2]$\r\n\r\n\\section*{Section 2.1}\r\n\\subsection*{6.}\r\nQuestion: Some sets are finite.\r\n\\\\\\\\\r\nAnswer: It is statement because it can be proven definitely true or false.\r\n\r\n\r\n\\subsection*{14.}\r\nQuestion: Call me Ishmael.\r\n\\\\\\\\\r\nAnswer: It is a sentence because it isn't a mathematical expression. \r\n\r\n\\section*{Section 2.2}\r\n\\subsection*{8.}\r\nQuestion: At least one of the \r\nnumbers $ x $ and $ y $ equals $ 0 $.\r\n\\\\\r\n$ P: x $ is equal to 0.\\\\\r\n$ Q: x $ is equal to 0.\\\\\\\\\r\nAnswer: $ P\\lor Q $\r\n\r\n\\end{minipage}\r\n% Creates verticle line\r\n\\hfill\\vline\\hfill\r\n\\begin{minipage}[t]{0.45\\textwidth}\r\n\\section*{Section 2.3}\r\n\\subsection*{2.}\r\nProblem: Convert the following sentences to be in the form $ P \\implies Q $\r\n$ P: $ A function is differentiable.\\\\\r\n$ Q: $ A function is continuous.\\\\\\\\\r\nAnswer: $ P \\implies Q $\r\n\\section*{Section 2.4}\r\n\\subsection*{4.}\r\nProblem: Convert to the form \"$ P $ if and only if $ Q $\". \\\\\r\n$ P: a \\in \\mathbb{Q}$\\\\\r\n$ Q: 5a \\in \\mathbb{Q}$\\\\\\\\\r\nAnswer: $ P \\Leftrightarrow Q $\\\\\r\n$ a \\in \\mathbb{Q} $ if and only if $ 5a \\in \\mathbb{Q} $\r\n\r\n\\section*{Section 2.5}\r\n\\subsection*{4.}\r\nProblem: Write a truth table for the logical problem: \r\n$ \\sim (P \\lor Q) \\lor \\sim(P) $\\\\\r\n\\[\r\n\\begin{array}{c|c|c|c|c}\r\nP & Q &  \\sim(P \\lor Q) &  \\sim(P)  & \\sim(P \\lor Q) \\lor \\sim(P)\\\\\r\n\\hline\r\nT & T & F & F & F\\\\\r\nT & F & F & F & F\\\\\r\nF & T & F & T & T\\\\\r\nF & F & T & T & T\r\n\\end{array}\r\n\\]\r\n\r\n\r\n\\end{minipage}\r\n\\pagebreak\r\n\r\n\r\n\\begin{minipage}[t]{0.40\\textwidth}\r\n\\section*{Section 2.5 cont.}\r\n\\subsection*{8.}\r\nProblem: Write a truth table for the logical problem: \r\n$ P \\lor (Q \\lor \\sim R)$\\\\\r\n\\[\r\n\\begin{array}{c|c|c|c|c}\r\nP & Q & R &(Q \\lor \\sim R) & P \\lor (Q \\lor \\sim R)\\\\\r\n\\hline\r\nT & T & T & T & T\\\\\r\nT & T & F & T & T\\\\\r\nT & F & T & F & T\\\\\r\nT & F & F & T & T\\\\\r\nF & T & T & T & T\\\\\r\nF & T & F & T & T\\\\\r\nF & F & T & F & F\\\\\r\nF & F & F & T & T\r\n\\end{array}\r\n\\]\r\n\r\n\\subsection*{10.}\r\nProblem: Suppose the statement $ ((P \\land Q) \\lor R) \\implies (R \\lor S)$\\\\\r\nis false. Find the truth values of $ P,Q,R $ and $ S. $\\\\\\\\\r\nAsnwer: Suppose $ A $ and $ B $ are statements. The only way that $(A \\implies B)=False$ is if $ A=True $ and $ B=False $. Therefore $ ((P \\land Q) \\lor R)$ must be $ True $ and $ (R \\lor S) $ must be $ False $. For $ (R \\lor S) $ to be $ False $, both $ R $ and $ S $ must be $ False $. Since $ R $ is false, the statement $ (P \\land Q) \\lor R) $ relies on $ (P \\land Q) $ to be true so both $ P $ and $ Q $ must be true. In conclusion: \r\n$$\r\n\\begin{array}{c|c|c|c}\r\n\tP & Q & R & S\\\\\r\n\t\\hline\r\n\tT & T & F & F\\\\\r\n\\end{array}\r\n$$\r\n\r\n\\end{minipage}\r\n% Creates verticle line\r\n\\hfill\\vline\\hfill\r\n\\begin{minipage}[t]{0.45\\textwidth}\r\n\\section*{Section 2.6}\r\n\\subsection*{2.}\r\nProblem: Show that the following statements are logically equivalent.\\\\\r\n$ a $: $ P \\lor (Q \\land R) $\\\\\r\n$ b $: $ (P \\lor Q) \\land (P \\lor R) $ \\\\\r\n\\[\r\n\\begin{array}{c|c|c|c|c}\r\nP & Q & R &(Q \\land R) & P \\lor (Q \\land R)\\\\\r\n\\hline\r\nT & T & T & T & T\\\\\r\nT & T & F & F & T\\\\\r\nT & F & T & F & T\\\\\r\nT & F & F & F & T\\\\\r\nF & T & T & T & T\\\\\r\nF & T & F & F & F\\\\\r\nF & F & T & F & F\\\\\r\nF & F & F & F & F\r\n\\end{array}\r\n\\]\r\n\\[\r\n\\begin{array}{c|c|c|c|c|c}\r\nP & Q & R &(P \\lor Q) & (P \\lor R) & (P \\lor Q) \\land (P \\lor R)\\\\\r\n\\hline\r\nT & T & T & T & T & T\\\\\r\nT & T & F & T & T & T\\\\\r\nT & F & T & T & T & T\\\\\r\nT & F & F & T & T & T\\\\\r\nF & T & T & T & T & T\\\\\r\nF & T & F & T & F & F\\\\\r\nF & F & T & F & T & F\\\\\r\nF & F & F & F & F & F\r\n\\end{array}\r\n\\]\r\n\\subsection*{10.}\r\nDecide whether the following statements are logically equivalent:\\\\\r\n$ a.\\quad(P \\implies Q) \\lor R $\\\\\r\n$ b. \\sim((P \\land \\sim Q) \\land \\sim R) $\\\\\r\n$1) \\quad (P \\implies Q) \\lor R $ = $ (\\sim P \\lor Q) \\lor R$ \\\\by definition of implication\\\\\r\n$ 2) \\quad (\\sim P \\lor Q) \\lor R =  \\enspace \\sim((\\sim P \\lor Q) \\lor R)$\\\\\r\nby DeMorgan's Laws\\\\\r\n$ 3) \\sim((\\sim P \\lor Q) \\lor R) = \\sim(\\sim P \\lor Q) \\land \\sim R $\\\\\r\nby DeMorgan's Laws\\\\\r\n$ 4) \\sim(\\sim P \\lor Q) \\land \\sim R = (P \\land \\sim Q) \\land \\sim R$\\\\\r\nby DeMorgan's Laws\\\\\r\n$ 5)\\quad (P \\land \\sim Q) \\land \\sim R =\\\\ \\sim ((P \\land \\sim Q) \\land \\sim R) = b$\\\\\\\\\r\n$\\therefore a \\equiv b $, they're logically equivalent.\r\n\\end{minipage}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\\end{document}", "meta": {"hexsha": "7cf79a2b74bf57f5acf23167489e38e6041d95ce", "size": 6935, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW_Week_2.tex", "max_stars_repo_name": "joseph-ismailyan/Math-100", "max_stars_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW_Week_2.tex", "max_issues_repo_name": "joseph-ismailyan/Math-100", "max_issues_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW_Week_2.tex", "max_forks_repo_name": "joseph-ismailyan/Math-100", "max_forks_repo_head_hexsha": "78e0557e2f936ef63ae8e079d7f04925c58db888", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.5904059041, "max_line_length": 439, "alphanum_fraction": 0.5777937996, "num_tokens": 2707, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.4092506905967305}}
{"text": "\n\n\\subsection{Slidding ?}\nIt consists in finding $\\alpha >0$ and $R \\in \\partial K_{\\mu}$ such that $-\\alpha \\left(\\begin{array}{l} 0\\\\ R_T\\end{array}\\right)=MR+q$. That is :\n  \\begin{equation}\n\\label{eq_quartic1}\n\\left[\\begin{array}{c}\nM+ \\left(\\begin{array}{ccc} 0&0&0\\\\ 0&\\alpha&0 \\\\ 0&0&\\alpha \\end{array}\\right)\n\\end{array}\\right]R+q=0\n\\end{equation}\n\n  \\subsubsection{$R_T$ is on a conic}\n  The first line of the system~\\ref{eq_quartic1} and the $R \\in \\partial K_{\\mu}$ is the intersection between a plan and a cone in $\\mathbb{R}^3$, endeed:\n  \\begin{equation}\n\\label{eq_quartic2}\n\\begin{array}{l}\n \\mu R_N =  \\parallel R_T \\parallel  \\\\\n\\frac{M_{11}}{\\mu} \\parallel R_T \\parallel = -q_1-M_{12}R_{T1}-M_{13}R_{T2}\n\\end{array}\n\\end{equation}\nThat is:\n\\begin{equation}\n\\label{eq_quartic2}\n\\begin{array}{l}\n\\mu^2 R_N^2 =  (R_{T1}^2 +R_{T1}^2)  \\\\\n\\frac{M_{11}^2}{\\mu^2} (R_{T1}^2 +R_{T1}^2)=(-q_1-M_{12}R_{T1}-M_{13}R_{T2})^2\n\\end{array}\n\\end{equation}\nThat means that $R_T$ is contained in a conic,  focus and directrice are:\n\\begin{equation}\n\\label{eq_quartic3}\n\\begin{array}{l}\n\\mathcal{D} : q_1+M_{12}R_{T1}+M_{13}R_{T2} =0  \\\\\nfocus : \\mathcal{O}\\\\\n\\frac{M_{11}^2}{\\mu^2}  Dist(\\mathcal{O}, R_T) ^2=Dist(\\mathcal{D},R_T)^2 (M_{12}^2+M_{13}^2)\\\\\n\\frac{Dist(\\mathcal{O}, R_T)}{Dist(\\mathcal{D},R_T)}=\\frac{\\mu\\sqrt{(M_{12}^2+M_{13}^2)}}{M_{11} }=e\n\\end{array}\n\\end{equation}\nThe parametric equation is:\n\\begin{equation}\n\\label{eq_quartic4}\n\\begin{array}{l}\nR_{T1}=r cos(\\theta )\\\\\nR_{T2}=r sin(\\theta )\\\\\nr=\\frac{p}{1+ecos(\\theta - \\phi)}\n\\end{array}\n\\end{equation}\nWith $p$ an simple expression of $M_{11},M_{12},M_{13}$, and $\\phi$ a constant angle between $\\mathcal{D}$ and $(O,R_{T1})$\n\\subsubsection{The two last line of the system~\\ref{eq_quartic1}}\n\\begin{equation}\n\\label{eq_quartic5}\n\\frac{\\parallel R_T \\parallel}{\\mu} \\tilde M_{1.} +\\left(\\tilde M+\\left(\\begin{array}{cc} \\alpha&0 \\\\ 0&\\alpha \\end{array}\\right)\\right)R_T+\\tilde q=0\n\\end{equation}\n$\\tilde M$ is symetric, so it exists a unitary matrix $V$ such that $V \\tilde M V^T = \\left(\\begin{array}{cc} d_1&0 \\\\ 0&d_2 \\end{array}\\right)$.  One can get:\n\\begin{equation}\n\\label{eq_quartic6}\n\\frac{\\parallel R_T \\parallel}{\\mu} V \\tilde M_{1.} +V \\left(\\tilde M+\\left(\\begin{array}{cc} \\alpha&0 \\\\ 0&\\alpha \\end{array}\\right)\\right)V^TVR_T+V\\tilde q=0\n\\end{equation}\nRename:\n\\begin{equation}\n\\label{eq_quartic7}\n  \\frac{\\parallel \\bar R_T \\parallel}{\\mu} \\bar M_{1.} +\\left(\\begin{array}{cc} d_1+\\alpha&0 \\\\ 0&d_2+\\alpha \\end{array}\\right)\\overline R_T+\\bar q=0\n  \\end{equation}\nIn the plan, either $V$ is a rotation or a symetrie. So $ \\bar R_T=VR_T$ is a conic with the same focus and a rotated directrice, it means that it exists $\\phi_1$ such that :\n\n\\begin{equation}\n\\label{eq_quartic8}\n\\begin{array}{l}\n\\bar R_{T1}=r cos(\\theta )\\\\\n\\bar R_{T2}=r sin(\\theta )\\\\\nr=\\frac{p}{1+ecos(\\theta - \\phi_1)}\n\\end{array}\n\\end{equation}\nThe equation~\\ref{eq_quartic7} is :\n\\begin{equation}\n\\label{eq_quartic9}\n\\begin{array}{l}\n  (d_1+\\alpha)\\bar R_{T1}=-\\bar q_1+a_1 \\parallel R_T \\parallel\\\\\n(d_2+\\alpha)\\bar R_{T2}=-\\bar q_2+a_2 \\parallel R_T \\parallel\n\\end{array}\n\\end{equation}\nThe case ($\\bar R_{T1} = 0$ or  $\\bar R_{T2} = 0$) has to be examine. We try to eliminate $alpha$:\n\\begin{equation}\n\\label{eq_quartic10}\n  \\begin{array}{l}\n    d_1 \\bar R_{T1} \\bar R_{T2}+\\alpha \\bar R_{T1} \\bar R_{T2} =-\\bar q_1\\bar R_{T2}+a_1 \\bar R_{T2} \\parallel R_T \\parallel\\\\\nd_2 \\bar R_{T1} \\bar R_{T2}+\\alpha \\bar R_{T1} \\bar R_{T2} =-\\bar q_2\\bar R_{T1}+a_2 \\bar R_{T1} \\parallel R_T \\parallel\n\\end{array}\n\\end{equation}\nthat leads to:\n\\begin{equation}\n\\label{eq_quartic10}\n  (d_1-d_2) \\bar R_{T1} \\bar R_{T2}=-\\bar q_1\\bar R_{T2}+\\bar q_2\\bar R_{T1}+(a_1 \\bar R_{T2}-a_2 \\bar R_{T1}) \\parallel R_T \\parallel\\\\\n\\end{equation}\nThe parametric expression of $\\bar R_T$ leads to:\n\\begin{equation}\n\\label{eq_quartic11}\n\\begin{array}{l}\n  (d_1-d_2)r^2cos(\\theta )sin(\\theta )=-\\bar q_1rsin(\\theta )+\\bar q_2rcos(\\theta )+r(a_1 rsin(\\theta )-a_2 rcos(\\theta )) \\\\\n  \\textrm{ie:}(d_1-d_2)rcos(\\theta )sin(\\theta )=-\\bar q_1sin(\\theta )+\\bar q_2cos(\\theta )+r(a_1 sin(\\theta )-a_2 cos(\\theta ))\\\\\n  \\end{array}\n\\end{equation}\nwith the expression of r:\n\\begin{equation}\n\\label{eq_quartic12}\n\\begin{array}{l}\n(d_1-d_2)\\frac{p}{1+ecos(\\theta - \\phi_1)}cos(\\theta )sin(\\theta )=\\\\-\\bar q_1sin(\\theta )+\\bar q_2cos(\\theta )+\\frac{p}{1+ecos(\\theta - \\phi_1)}(a_1  sin(\\theta )-a_2 cos(\\theta ))\\\\\\\\\n\\textrm{ie:}(d_1-d_2)pcos(\\theta )sin(\\theta )=\\\\(1+ecos(\\theta - \\phi_1))(-\\bar q_1sin(\\theta )+\\bar q_2cos(\\theta ))+p(a_1  sin(\\theta )-a_2 cos(\\theta ))\\\\\\\\\n\\textrm{ie:}(d_1-d_2)pcos(\\theta )sin(\\theta )=\\\\(1+e(cos(\\theta)cos(\\phi_1)+sin(\\theta)sin(\\phi_1)))(-\\bar q_1sin(\\theta )+\\bar q_2cos(\\theta ))+p(a_1  sin(\\theta )-a_2 cos(\\theta ))\\\\\\\\\n\\textrm{ie:}(d_1-d_2)pcos(\\theta )sin(\\theta )+\\\\(1+ecos(\\theta)cos(\\phi_1)+esin(\\theta)sin(\\phi_1))(\\bar q_1sin(\\theta )-\\bar q_2cos(\\theta ))+p(-a_1  sin(\\theta )+a_2 cos(\\theta ))=0\n \\end{array}\n\\end{equation}\nrename :\n\\begin{equation}\n\\label{eq_quartic13}\n\\begin{array}{l}\nAcos(\\theta )^2+Bsin(\\theta)^2+Csin(\\theta )cos(\\theta )+Dsin(\\theta )+Ecos(\\theta )=0\n \\end{array}\n\\end{equation}\nwith\n\\begin{equation}\n\\label{eq_quartic12}\n\\begin{array}{l}\nA=- e\\bar q_2cos(\\phi_1)\\\\\nB=e \\bar q_1sin(\\phi_1)\\\\\nC=(d_1-d_2)p+ecos(\\phi_1)\\bar q_1-esin(\\phi_1)\\bar q_2\\\\\nD=\\bar q_1-pa_1\\\\\nE=-\\bar q_2+pa_2\\\\\n\\end{array}\n\\end{equation}\nrename :\nUsing the following set of unknown :\n\\begin{equation}\n\\label{eq_quartic14}\n\\begin{array}{l}\nt=tan(\\theta /2)\\\\\nsin(\\theta )=\\frac{2t}{1+t^2}\\\\\ncos(\\theta )=\\frac{1-t^2}{1+t^2}\n \\end{array}\n\\end{equation}\nleads to:\n\\begin{equation}\n\\label{eq_quartic13}\n\\begin{array}{l}\n  A\\frac{(1-t^2)^2}{1+t^2} +B\\frac{4t^2}{1+t^2}+ C\\frac{2t(1-t^2)}{1+t^2}+D2t+E(1-t^2)=0\\\\\n\\textrm{ie:}A(1-t^2)^2 + 4Bt^2+C2t(1-t^2)+2Dt(1+t^2)+E(1-t^2)(1+t^2)=0\\\\\\\\\n\\textrm{ie:}P_4=A-E\\qquad P_3=-2C+2D \\qquad P_2=4B-2A \\qquad P_1=2C+2D \\qquad P_0=A+E\n \\end{array}\n\\end{equation}\nFinally, we get 4 possible values for $R_T$, checking the sign of $\\alpha$ and $R_N$ selects the solutions.\n\n\\subsubsection{case $R_{T12}=0$}\nFrom~\\ref{eq_quartic9}, $R_{T1}$ leads to:\n\\begin{equation}\n\\label{eq_quartic14}\n\\begin{array}{l}\n  \\parallel R_T \\parallel=|\\bar R_{T2}|=\\frac{\\bar q_1}{a_1}\\\\\\\\\n  \\bar R_T=\\left(\\begin{array}{c} 0 \\\\ \\pm \\frac{\\bar q_1}{a_1} \\end{array}\\right)\n \\end{array}\n\\end{equation}\n\nFrom~\\ref{eq_quartic9}, $R_{T2}$ leads to:\n\\begin{equation}\n\\label{eq_quartic14}\n\\begin{array}{l}\n  \\parallel R_T \\parallel=|\\bar R_{T1}|=\\frac{\\bar q_2}{a_2}\\\\\\\\\n  \\bar R_T=\\left(\\begin{array}{c}  \\pm \\frac{\\bar q_2}{a_2} \\\\ 0 \\end{array}\\right)\n \\end{array}\n\\end{equation}\n\nFrom $\\bar R_T$, we have to check the coherence with the equation~\\ref{eq_quartic8}. If it is on the conic,  we compute R, and the sign condition of the equation~\\ref{eq_quartic1} must be check.\n", "meta": {"hexsha": "e0f121a0a7a316dcc007952e6fe444e2b6a0c8c2", "size": 6862, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/sphinx/devel_guide/notes/QuarticFormulation.tex", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "docs/sphinx/devel_guide/notes/QuarticFormulation.tex", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "docs/sphinx/devel_guide/notes/QuarticFormulation.tex", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 39.8953488372, "max_line_length": 194, "alphanum_fraction": 0.6587000874, "num_tokens": 3011, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.40925069059673047}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{natbib,unatbib}\n\\usepackage[nohide,twocolumn]{ulecnot}\n\n\\usepackage{bussproofs}\n\n\n\\pagestyle{fancy}\n\\lhead{COGS 502 -- Programming and Logic}\n\\chead{Predicate Logic}\n\\rhead{Updated \\it \\today}\n\\lfoot{Umut \\\"Ozge}\n\\cfoot{}\n\\rfoot{Page \\thepage/\\pageref{LastPage}}\n\\setlength{\\headheight}{13.6pt}\n\n\\usepackage{tikz-qtree}\n\n\\begin{document}\n\n\\section{Need for more expressive power}\n\n\\ezimeti{\n\\item Observe that propositional logic is not adequate to capture the following\nreasoning:\n\n\\item[] \\begin{quote}\n\t\tAll thoughts are brain processes.\\\\\n\t\tSome thoughts are self-destructive.\\\\\n\t\tTherefore, some brain processes are self-destructive.\n\t\t\\end{quote}\n\n\n\\item Logic, the art of formal reasoning, should be able to handle these types\nof inferences; because whether the inference goes true is entirely dependent on\nthe organization of words like \\emph{all}, \\emph{some} and the positioning of\nidentical expressions.\n\n\t\t\\begin{quote} All Frambulators are Cumulists.\\\\\n\t\tSome Frambulators are Sullberdian.\\\\\n\t\tTherefore, some Cumulists are Sullberdian.\n\t\t\\end{quote}\n\n\t\t\\begin{quote}\n\t\tAll $F$ are $C$.\\\\\n\t\tSome $F$ are $S$.\\\\\n\t\tTherefore, some $C$ are $S$.\n\t\t\\end{quote}\n}\n\n\\section{Variables, quantifiers, formulas}\n\\ezimeti{\n\\item We enrich our language by introducing the following: \n\\ezimeti{\n\\item[i.] A set of \\uterm{predicate symbols}, possibly with subscripts in order\nto not run out of symbols no matter how complicated our formulas can get. We use\nupper case Latin letters to designate predicate symbols.\n\n\\item[ii.] A set of \\uterm{variables}, again possibly with subscripts. We use lower\ncase Latin letters to designate variables.\n\n\\item[iii.] A set of \\uterm{quantifier symbols}, namely $\\{\\forall,\\exists\\}$.\n}\n\\item We will use upper and lower case Greek letters for variables over\npredicate symbols and variables, respectively.\n\n\\item Now we can define the well-formed formulas of our language:\n\n\\begin{udefinition}[Well-formed formulas of predicate logic]\n\\ezimeti{\n\\item[]\n\\item[i.] $\\Pi\\alpha_1,\\ldots,\\alpha_n$ is a wff iff $\\Pi$ is a predicate symbol\nand $\\alpha_1,\\ldots,\\alpha_n$ is a\nsequence of variables.\n\n\\item[ii.] ($\\phi \\land \\psi$) is a wff iff $\\phi$ and $\\psi$ are wff's;\\\\ likewise\nfor, $(\\phi \\lor \\psi)$, $(\\phi \\imp \\psi)$, and $(-\\phi)$.\n\n\\item[iii.] $\\forall\\alpha\\phi$ and $\\exists\\alpha\\phi$ are wff's iff $\\phi$\nis a wff and $\\alpha$ is a variable.\n}\n\\label{consdef}\n\\end{udefinition}\n\n\\begin{uexample} \nObserve how the formula in \\xref{constree} is constructed on the\nbasis of definition \\ref{consdef}.\n\n\\begin{align}\n\\label{constree}\n\\forall x((Sx\\lor Wx)\\imp \\exists y(Ky\\land Txy))\n\\end{align}\n\nthe tree on the right hand side is simplified by retaining only the\nstructure forming operations as node labels, namely connectives and `.' sign\nfor concatenation. Let us call it the \\uterm{construction tree} of the formula\nin \\xref{constree}.\n\n\n\\begin{center}\n\\Tree [.$\\forall x((Sx\\lor Wx)\\imp \\exists y(Ky\\land Txy))$ [.$((Sx\\lor Wx)\\imp\\exists y(Ky\\land Txy))$ \n\t\t[.$(Sx\\lor Wx)$ [.$Sx$ $S$ $x$ ] [.$Wx$ $W$ $x$ ]] \n\t\t[.$\\exists y(Ky\\land Txy)$ \n\t\t\t\t\t\t\t[.$(Ky\\land Txy)$ [.$Ky$ $K$ $y$ ] [.$Txy$ $T$ $x$\n\t\t\t\t\t\t\t$y$ ] ]  ] ] ]\n\\hspace{20pt}\n\\Tree [.$\\forall x$ [.$\\imp$ \n\t\t[.$\\lor$ [.$.$ $S$ $x$ ] [.$.$ $W$ $x$ ]] \n\t\t[.$\\exists y$ \n\t\t\t\t\t\t\t[.$\\land$ [.$.$ $K$ $y$ ] [.$.$ $T$ $x$\n\t\t\t\t\t\t\t$y$ ] ]  ] ] ]\n\\end{center}\n\\end{uexample}\n\n\n\n\n\\item To keep the number of parentheses manageable, we follow the following\nconvention:\n\\ezimeti{\n\\item[] negation ($-$) and quantifiers ($\\forall x$,$\\exists v$, etc.) bind most tightly;\n\\item[] then comes conjunction ($\\land$) and alternation ($\\lor$)\n\\item[] finally conditional ($\\imp$) binds least tightly.\n}\n}\n\n\\section{Occurrence, bondage, freedom, and substitution}\n\\ezimeti{\n\\item We call a \\uterm{quantifier}, the expression formed by concatenating a\nquantifier symbol and a variable. E.g.\\ $\\forall x$, $\\exists z$.\n\n\\item[] {\\bf Occurrence:}\n\n\\item An \\uterm{occurrence of a variable} in a formula is a leaf (terminal) node\nin the construction tree of that formula occupied by the variable. Question: how\nmany occurrences does the variable $x$ have in formula \\xref{constree}?\n\n\\item Similarly an \\uterm{occurrence of a quantifier} in a formula is a node in the\nconstruction tree occupied by the quantifier.\n\n\\item[] {\\bf Bondage versus freedom:}\n\n\\item An occurrence of a variable $\\alpha$ is \\uterm{bound} in a formula $\\phi$ by an\noccurrence of a quantifier $\\forall\\alpha$ (or $\\exists\\alpha$) if there exists a path from\n$\\alpha$ going up to $\\forall\\alpha$ (or $\\exists\\alpha$), and there exists no\nother occurrence of $\\forall\\alpha$ (or $\\exists\\alpha$) along the path.\n\n% \\begin{uexercise}\n% Mark the scopes of the quantifiers below:\n% \\end{uexercise}\n\n\\item An occurrence of a variable $\\alpha$ is \\uterm{free} in a formula $\\phi$\niff $\\alpha$ is not bound (by any quantifier) in $\\phi$.\n\n\\begin{uexercise}\nState which occurrences of variables are free and bound in the following\nformula:\n\n$$\n((\\exists x\\, Fx \\lor\\forall x\\, ((Gz \\land Hx) \\imp (\\exists z\\, Fz\\lor Hz)))\n\\imp \\exists z\\, (Fy \\lor Fz))\n$$\n\n\n\\end{uexercise}\n\n\\item A formula is \\uterm{closed} iff it has no free (occurrence of a) variable. \n\n\\item[] {\\bf Substitution:}\n\n\\item Given a formula $\\phi$, \n$$\\subs{\\phi}{\\beta}{\\alpha}$$ \nis the formula obtained by substituting the variable $\\beta$ to each and every\n\\emph{free} occurrence of variable $\\alpha$ in $\\phi$.\n\n\n\\item[] {\\bf Accidental bondage:}\n\n\\item When substituting a variable for another one in a formula, care should be\ntaken NOT to introduce bondages that wouldn't be there if the substitution had\nnot taken place.  \n\\item[] Take for instance the formula\n\n$$\\exists y\\, Lxy$$\n\nwith $L$ designating the binary predicate \\emph{loves}, which says there is some\nentity that $x$ -- whatever that is -- loves. Substituting $y$ for $x$ in this\nformula, namely $\\subs{(\\exists y\\, Lxy)}{y}{x}$, gives $\\exists y\\, Lyy$. This\nsays that there exists a self-loving entity. Something different and more\nspecific than our original formula. To avoid such situations we introduce the\nfollowing definition.\n\n\\item Variable $\\beta$ is \\uterm{free for} $\\alpha$ in formula $\\phi$ if no free\noccurrence of $\\alpha$ in $\\phi$ stands along a path descending from a\nquantifier $\\forall \\beta$  or $\\exists \\beta$.\n\n\\begin{uexercise}\nGive $\\subs{\\phi}{y}{x}$ for the following $\\phi$ and state whether $y$ is free\nfor $x$ in $\\phi$:\n\n\\begin{enumerate}\n\\item $\\forall z\\,(Px\\imp Qz)$\n\\item $Fx \\imp \\forall x\\, Fx$\n\\item $\\exists z\\,(\\forall x\\, Fx \\imp Hx)$\n\\item $\\forall y\\,Fzy\\imp \\exists y\\, Gxyz$\n\\end{enumerate}\n\\end{uexercise}\n\n\\begin{uexercise}\nExpress the following sentences in predicate logic:\n\\etaremune{\n\\item \nA sample was contaminated.\n\\item\nEverything ends.\n\\item\nEvery semester ends.\n\\item\nEvery student admires some movie.\n\\item\nIf an instructor fails, every student passes.\n\\item\nNo student failed.\n\\item Some humans love math, but not all who love math are humans.\n\\item People without friends are unhappy unless they love reading.\n}\n\\end{uexercise}\n}\n\n\\section{Natural deduction}\n\n\\ezimeti{\n\n\\item All the rules and techniques of natural deduction for propositional logic\nalso apply to predicate logic.\n\n\\item In addition to them, we introduce introduction and elimination rules for\nthe quantifiers.\\footnote{Note that we do not cover terms and identity,\ntherefore you may skip those parts in Huth\\&Ryan.}\n\n\n\\item[] {\\bf The universal quantifier:}\n\n\\item[] Elimination:\n\n\\begin{prooftree}\n\\AxiomC{$\\forall x\\, \\phi$}\n\\RightLabel{\\scriptsize{$\\forall x$ e}}\n\\UnaryInfC{\\subs{\\phi}{u}{x}}\n\\end{prooftree}\nprovided that $u$ is free for $x$ in $\\phi$.\n\n\n\n\\item[] Introduction:\n\\begin{prooftree}\n\\AxiomC{\\fbox{\\parbox{40pt}{\\flushleft{$u$}$$\\vdots$$\\centering{$\\subs{\\phi}{u}{x}$}}}}\n\\RightLabel{\\scriptsize{$\\forall x$ i}}\n\\UnaryInfC{$\\forall x\\, \\phi$}\n\\end{prooftree}\n\nThe logic of the rule is: if you can prove that a formula holds for an\n\\emph{arbitrary} individual, then it holds for every individual. In order to\nguarantee that $u$ is arbitrary, it is required that it is ``fresh'' in the\nsense that it does not occur anywhere outside of the box. \n\n\\item[] {\\bf The existential quantifier:}\n\n\\item[] Introduction:\n\n\\begin{prooftree}\n\\AxiomC{$\\subs{\\phi}{u}{x}$}\n\\RightLabel{\\scriptsize{$\\exists x$ i}}\n\\UnaryInfC{$\\exists x\\, \\phi$}\n\\end{prooftree}\n\nThe idea is that if a formula holds for an individual, then you can deduce that\nthere exists something that makes the formula hold.\n\n\\item[] Elimination:\n\n\\begin{prooftree}\n\\AxiomC{$\\exists x\\,\\phi$}\n\\AxiomC{\\fbox{\\parbox[b]{60pt}{\\flushleft{$u$}\\quad\\centering{$\\subs{\\phi}{u}{x}$}$$\\vdots$$\\centering{$\\chi$}}}}\n\\RightLabel{\\scriptsize{$\\exists x$ e}}\n\\BinaryInfC{$\\chi$}\n\\end{prooftree}\nprovided that $u$ is free for $x$ in $\\phi$ and $u$  is ``fresh'' -- it does not\noccur outside of the box.\n\n\nHere the logic is similar to $\\lor$-elimination. You know that $\\phi$ holds for\nat least one individual, but you do not know which. You assume an arbitrary\nindividual $u$ and that $\\phi$ holds for it. If this assumption leads you to $\\chi$,\nwhich does not include $u$, then you can deduce that $\\chi$ holds. \n\nLet's take a real-world example. Suppose you have 12 friends. You know that at\nleast one of them betrayed you. You sit and think about each, James, Andrew,\nMatthew, Judas, and others. You find out that \\emph{whichever} you pick as the\ntraitor, there is a reason that you are in trouble. As you know that at least one of them\n\\emph{did} betray you, you conclude that you are in trouble.  \n\n\\newpage\n\\begin{uexercise}\nProve the following:\n\\begin{enumerate}\n\\item $\\forall x\\,(Px \\imp Qx),\\,\\forall x\\,Px\\vdash\\, \\forall x\\, Qx$\n\\item $\\forall x\\, \\phi \\vdash\\, \\exists x\\, \\phi$\n\\item $\\forall x\\, (Px \\imp Qx),\\,\\exists x\\, Px \\vdash\\, \\exists x\\, Qx$  \n\\item $\\forall x\\, (Qx \\imp Rx),\\,\\exists x\\, (Px \\land Qx) \\vdash\\, \\exists x\\, (Px \\land Rx)$  \n\\item $\\exists x\\, Px,\\, \\forall x\\forall y\\,(Px\\imp Qy) \\vdash\\, \\forall y\\, Qy$\n\\item  $\\vdash\\,\\exists x\\, (Fx \\imp \\forall y\\, Fy)$\n\\end{enumerate}\n\\end{uexercise}\n}\n\n\n% \\renewcommand{\\bibsep}{0pt}\n% \\renewcommand{\\bibfont}{\\small}\n% \\bibliography{ozge}\n% \\bibliographystyle{natgig}\n\\end{document}\n\n\\section{Models and truth in a model}\n\\section{Validity and implication}\n\\section{Natural deduction} \n", "meta": {"hexsha": "b101cbf67beaad60151045af572ba7025cdac136", "size": 10387, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/02_cogs502-predicate-logic.tex", "max_stars_repo_name": "umutozge/cogs502", "max_stars_repo_head_hexsha": "9e71b58f61cfa42408a72febeadcf2ff726986fb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-10-15T17:01:09.000Z", "max_stars_repo_stars_event_max_datetime": "2017-10-15T17:01:09.000Z", "max_issues_repo_path": "notes/02_cogs502-predicate-logic.tex", "max_issues_repo_name": "umutozge/cogs502", "max_issues_repo_head_hexsha": "9e71b58f61cfa42408a72febeadcf2ff726986fb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/02_cogs502-predicate-logic.tex", "max_forks_repo_name": "umutozge/cogs502", "max_forks_repo_head_hexsha": "9e71b58f61cfa42408a72febeadcf2ff726986fb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.7645259939, "max_line_length": 113, "alphanum_fraction": 0.7042456917, "num_tokens": 3237, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.74316801430083, "lm_q1q2_score": 0.4091937825042358}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath, amssymb, latexsym}\n\\usepackage{neuralnetwork}\n\\usepackage{multicol}\n\n\\usepackage{pgfplots}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{tikz}\n\\usepackage{nicefrac}\n\\pgfplotsset{every axis legend/.append style={\nat={(0,0)},\nanchor=north east}}\n\\usetikzlibrary{shapes,positioning,intersections,quotes}\n\\usetikzlibrary{arrows.meta,\n                bending,\n                intersections,\n                quotes,\n                shapes.geometric}\n                \n\\definecolor{darkgreen}{rgb}{0.0, 0.6, 0.0}\n\\definecolor{darkred}{rgb}{0.7, 0.0, 0.0}\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\\title{Week 10}\n\\begin{document}\n\\pagenumbering{gobble}\n\\maketitle\n\\newpage\n\\pagenumbering{arabic}\n\n\\section*{Debugging a learning algorithm}\n\nImagine you've used regularized linear regression to forecast home prices:\n\n$$J(\\theta) = \\frac{1}{2m} [ \\sum_{i=1}^{m}(h_{\\theta}(x^{(i)} + y^{(i)})^2 + \\lambda \\sum_{j=1}^{m} \\theta_j^2] $$\n\n\\begin{itemize}\n  \\item Trained it.\n  \\item However, when tested on new data, it produces unacceptably high errors in its predictions.\n  \\item What should your next step be?\n        \\begin{itemize}\n          \\item Obtain additional training data.\n          \\item Try a smaller set of features.\n          \\item Consider getting more features.\n          \\item Add polynomial features.\n          \\item Change the value of $\\lambda$.\n        \\end{itemize}\n\n\\end{itemize}\n\n\\section*{Evaluating a hypothesis}\n\n\\begin{itemize}\n  \\item Split data into two portions: training set and test set.\n  \\item Learn parameters $\\theta$ from training data, minimizing $J(\\theta)$ using 70\\% of the training data.\n  \\item Compute the test error.\n\n        $$J_{test}(\\theta) = \\frac{1}{2m_{test}}  \\sum_{i=1}^{m_{test}}(h_{\\theta}(x^{(i)}_{test} + y^{(i)}_{test})^2$$\n\n\\end{itemize}\n\n\\section*{Model selection and training validation test sets}\n\n\\begin{itemize}\n  \\item How should a regularization parameter or polynomial degree be chosen?\n  \\item We've previously discussed the issue of overfitting.\n  \\item This is why, in general, training set error is a poor predictor of hypothesis accuracy for new data (generalization).\n  \\item Try to determine the degree of polynomial that will fit data.\n\n        1. $h_{\\theta}(x) = \\theta_0 + \\theta_1x$\n\n        2. $h_{\\theta}(x) = \\theta_0 + \\theta_1x + \\theta_2x^2$\n\n        3. $h_{\\theta}(x) = \\theta_0 + ... + \\theta_3x^3$\n\n        \\quad \\vdots\n\n        10. $h_{\\theta}(x) = \\theta_0 + ... + \\theta_{10}x^{10}$\n\n  \\item Introduce a new parameter d, which represents the degree of polynomial you want to use.\n  \\item Model 1 is minimized using training data, resulting in a parameter vector $\\theta^1$ (where d =1).\n  \\item Same goes for other models up to $n$.\n  \\item Using the previous formula, examine the test set error for each computed parameter $J_{test}(\\theta^k)$.\n  \\item Minimize cost function for each of the models as before.\n  \\item Test these hypothesis on the cross validation set to generate the cross validation error.\n  \\item Pick the hypothesis with the lowest cross validation error.\n\\end{itemize}\n\n~\\\\\nTraining error:\n$$J_{train}(\\theta) = \\frac{1}{2m}  \\sum_{i=1}^{m}(h_{\\theta}(x^{(i)} + y^{(i)})^2$$\n\n~\\\\\nCross Validation error:\n$$J_{cv}(\\theta) = \\frac{1}{2m_{cv}}  \\sum_{i=1}^{m_{cv}}(h_{\\theta}(x^{(i)}_{cv} + y^{(i)}_{cv})^2$$\n\n~\\\\\nTest error:\n$$J_{test}(\\theta) = \\frac{1}{2m_{test}}  \\sum_{i=1}^{m_{test}}(h_{\\theta}(x^{(i)}_{test} + y^{(i)}_{test})^2$$\n\n\\section*{Model selection and training validation test sets}\n\nBad results are generally the consequence of one of the following:\n\n\\begin{itemize}\n  \\item High bias - under fitting problem.\n  \\item High variance - over fitting problem.\n\\end{itemize}\n\n\\includegraphics[width=\\textwidth]{resources/diagnosis}\n\nNow plot\n\n\\begin{itemize}\n  \\item $x$ = degree of polynomial d\n  \\item $y$ = error for both training and cross validation (two lines)\n\\end{itemize}\n\n\\includegraphics[width=0.5\\textwidth]{resources/error_vs_d}\n\n\\begin{itemize}\n  \\item For the high bias case, we find both cross validation and training error are high\n  \\item For high variance, we find the cross validation error is high but training error is low\n\\end{itemize}\n\n\\section*{Regularization and bias/variance}\n\nLinear regression with regularization:\n\n$$h_{\\theta}(x) = \\theta_0 + \\theta_1x + \\theta_2x^2 + \\theta_3x^3 + \\theta_4x^4$$\n\n$$J(\\theta) = \\frac{1}{2m} [ \\sum_{i=1}^{m}(h_{\\theta}(x^{(i)} + y^{(i)})^2 + \\lambda \\sum_{j=1}^{m} \\theta_j^2]$$\n\nThe above equation describes the fitting of a high order polynomial with regularization (used to keep parameter values small).\n\n\\begin{enumerate}\n  \\item $\\lambda$ is large (high bias $->$ under fitting data)\n  \\item $\\lambda$ is intermediate (good)\n  \\item $\\lambda$ is small (high variance $->$ overfitting)\n\\end{enumerate}\n\n\\includegraphics[width=\\textwidth]{resources/lambda}\n\n\\begin{itemize}\n  \\item Have a set or range of values to use (for example from 0 to 15).\n  \\item For each $\\lambda_i$ minimize the cost function. Result is  $\\theta^{(i)}$.\n  \\item For each $\\theta^{(i)}$ measure average squared error on cross validation set.\n  \\item Pick the model which gives the lowest error.\n\\end{itemize}\n\n\\section*{Learning curves}\n\nPlot $J_{train}$ (average squared error on training set) and $J_{cv}$ (average squared error on cross validation set) against m (number of training examples).\n\n\\begin{itemize}\n  \\item  $J_{train}$ on smaller sample sizes is smaller (as less variance to accommodate).\n  \\item  As training set grows your hypothesis generalize better and $J_{cv}$ gets smaller.\n\\end{itemize}\n\n\\includegraphics[width=0.6\\textwidth]{resources/learning_curve}\n\n\\begin{itemize}\n  \\item  A small gap between training error and cross validation error might indicate high bias. Here, more data will not help.\n  \\item  A large gap between training error and cross validation error might indicate high variance. Here, more data will probably help.\n\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "f6055211e1353356f8692ecba81b45abeed05850", "size": 6088, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/week_10.tex", "max_stars_repo_name": "djeada/Stanford-Machine-Learning", "max_stars_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/week_10.tex", "max_issues_repo_name": "djeada/Stanford-Machine-Learning", "max_issues_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/week_10.tex", "max_forks_repo_name": "djeada/Stanford-Machine-Learning", "max_forks_repo_head_hexsha": "e6ef77939b7c581aebb5e9454669ad2dbb4f98f0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3953488372, "max_line_length": 158, "alphanum_fraction": 0.6959592641, "num_tokens": 1816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352403, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.409193779372189}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{setspace}\n\\usepackage{pxfonts}\n\\usepackage{graphicx}\n\\usepackage{geometry}\n\n\\geometry{letterpaper,left=.5in,right=.5in,top=1in,bottom=.75in,headsep=5pt,footskip=20pt}\n\n\\title{Lecture 3 -- Integrate-and-fire neuron model}\n\\author{Computational Neuroscience Summer Program}\n\\date{June, 2011}\n\n\\begin{document}\n\\maketitle\n\n\\paragraph{Motivation.}  This lecture builds on the simple model\nneuron that we developed in the last lacture by adding in action\npotentials (APs).  Rather than modeling the biophysical basis of the\nAP, in this model we manually cause the neuron to spike when its\nmembrane voltage reaches a threshold value.\n\n\\paragraph{Recap.}  Our working model is that neurons are like\ncapacitors connected to resistors -- the cell membrane stores charge,\nwhich can leak out through ion channels.  As developed in the last\nlecture, the equation we'll be using for all model neurons is:\n\\[\n\\tau_m\\frac{dV}{dt} = E - V + R_mI_e\n\\]\nAlso from the previous lecture, we can solve for $V(t)$ as follows:\n\\[\nV(t) = V_\\infty + (V(0) - V_\\infty) e^\\frac{-t}{\\tau_m}\n\\]\n\n\\paragraph{Running a simulation -- the ``integrate'' part of the\n  model.}  Running a simulation entails\ncomputing changes in the cell's membrane voltage for each iteration of the\nsimulation ($dt$ ms).  We can use the same equation as above, but\nreplace $V(t)$ with $V(t+dt)$ (i.e. the voltage in the next time step of\nthe simulation) and $V(0)$ (the starting voltage) with $V(t)$:\n\\[\nV(t+dt) = \\mathrm{(where~we~are~going)} +\n\\mathrm{(distance)}e^\\frac{-t}{\\tau_m} = V_\\infty + (V(t) -\nV_\\infty)e^\\frac{-t}{\\tau_m}\n\\]\nIn practice, these computations work best for small values of $dt$ (in most cases\nwe'll use $dt \\leq 0.1$ ms).\n\n\\paragraph{Running a simulation -- the ``fire'' part of the model.}\nNow the integrate-and-fire model is almost entirely in place.  The\nonly thing we need to add is the rule that when $V(t+dt) \\geq V_{thresh}$, simulate an action potential by \nsetting $V(t) = V_{peak}$ and $V(t+dt) = V_{reset}$.  $V_{thresh}$ is\ngenerally somewhere around -55 mV, $V_{peak}$ is around 40 mV, and\n$V_{reset}$ is around -80 mV.  In the next lectures we'll discuss the biophysical\nbasis of why the neuron depolarizes (increases its membrane voltage)\nsuddenly during the start of the action potential and why the membrane\nvoltage becomes hyperpolarized (decreased) after the action potential is fired.\n\n\n\\paragraph{Computing firing rate.}  This is straightforward.  We can\nsimply count up the number of spikes that were fired during the\nsimulation (i.e. times when $V \\geq V_{thresh}$ and divide by the\nlength of time we were simulating.\n\n\\paragraph{Analytic solution for firing rate.}  While the full integrate-and-fire\nsimulation is often useful (and is necessary if you want to model\nthings like spike timing), it turns out that there is an analytic\nmethod for computing the expected firing rate of the model, given a\nconstant external current $I_e$.  We start with the equation for\nfinding the membrane voltage at time $t$:\n\n\\[\nV(t) = V_\\infty + (V(0) - V_\\infty) e^\\frac{-t}{\\tau_m}\n\\]\nWe can then solve for $t$ as follows:\n\\[\nV(t) - V_\\infty = (V(0) - V_\\infty) e^\\frac{-t}{\\tau_m}\n\\]\n\n\\[\n\\frac{V(t) - V_\\infty}{(V(0) - V_\\infty)} = e^\\frac{-t}{\\tau_m}\n\\]\n\n\\[\nln(\\frac{V(t) - V_\\infty}{V(0) - V_\\infty}) = \\frac{-t}{\\tau_m}\n\\]\n\n\\[\n\\tau_mln(\\frac{V(t) - V_\\infty}{V(0) - V_\\infty}) = -t\n\\]\n\n\\[\nt = -\\tau_mln(\\frac{V(t) - V_\\infty}{V(0) - V_\\infty})\n\\]\nNow let's suppose our model neuron has just fired a spike in the\nprevious timestep of our simulation.  We start by setting $V(0) =\nV_{reset}$.  We next need to know how long it is until the neuron next\nfires a spike (the inter-spike interval, $t_{isi}$ -- or, in other\nwords, the time $t$ at which $V(t) = V_{thresh}$ after starting at\n$V(0) = V_{reset}$.  Plugging in the appropriate values, we can\ncompute $t_{isi}$ as follows:\n\n\\[\nt_{isi} = -\\tau_mln(\\frac{V_{thresh} - V_\\infty}{V_{reset} - V_\\infty})\n\\]\nRecall that $V_\\infty = E + R_mI_e$.  Thus\n\\[\nt_{isi} = -\\tau_mln(\\frac{V_{thresh} - (E + R_mI_e)}{V_{reset} - (E +\n  R_mI_e)}) = -\\tau_mln(\\frac{V_{thresh} - E - R_mI_e}{V_{reset} - E - R_mI_e})\n\\]\nThe firing rate ($r_{isi}$) is the inverse of the inter-spike interval:\n\\[\nr_{isi} = (-\\tau_mln(\\frac{V_{thresh} - E - R_mI_e}{V_{reset} - E - R_mI_e}))^{-1}\n\\]\n\n\\paragraph{Putting it all together.}  To run the simulation, start\nwith the basic model neuron equation:\n\\[\n\\tau_m\\frac{dV}{dt} = E - V + R_mI_e\n\\]\n\nNow solve for $dV$:\n\\[\n\\frac{dV}{dt} = \\frac{E - V + R_mI_e}{\\tau_m}\n\\]\n\\[\ndV = (\\frac{E - V + R_mI_e}{\\tau_m})dt\n\\]\nStart the simulation by setting $V(0) = E$.  With each timestep set $V(t+dt) = V(t) + dV$.\nYou'll need to re-compute $dV$ for each time-step given $V(t)$ and\n$I_e(t)$ for the appropriate time $t$.  Remember to include the rule for\nfiring a spike (and resetting) when $V > V_{thresh}$ -- otherwise the\nneuron won't fire spikes.\n\n\n\n\\paragraph{General MATLAB stuff.}\nSet up your environment:\n\\begin{verbatim}\nE = -70;        %mV\nc_m = 10;       %nF / mm^2\nr_m = 1;        %M ohm * mm^2\nA = 0.025;      %mm^2\nV_reset = -80;  %mV\nV_thresh = -55; %mV\nV_peak = 40;    %mV\n\ndt = 0.1;       %ms\nt = 1:dt:1000;  %ms\n\\end{verbatim}\nNow loop:\n\\begin{verbatim}\nV(1) = E;\nfor i = 2:length(t)\n  if V(i-1) > V_thresh\n    {fire a spike}\n  else\n    {compute dV}\n    V(i) = V(i-1) + dV;\nend\n\\end{verbatim}\nFor the problem set, you should write a function that runs the\nintegrate-and-fire model for a given set of parameters.  Your function\nshould at return the firing rate (computed numerically, not using the $r_{isi}$ equation).\nYou also might want to have it return the vector of $V$ over time,\ndepending on how you set up your code.\n\n\\end{document}\n\n\n", "meta": {"hexsha": "99f9ebdc5c3058e1b119fe8eb6f6998b98c22a10", "size": 5748, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple_lecture.tex", "max_stars_repo_name": "ContextLab/computational-neuroscience", "max_stars_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2018-01-22T21:51:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T20:44:42.000Z", "max_issues_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple_lecture.tex", "max_issues_repo_name": "ContextLab/computational-neuroscience", "max_issues_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-10-31T02:19:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-31T14:03:00.000Z", "max_forks_repo_path": "integrate_and_fire_simple/integrate_and_fire_simple_lecture.tex", "max_forks_repo_name": "ContextLab/computational-neuroscience", "max_forks_repo_head_hexsha": "b0a3812a46fe4387de2655a9072f8910a7f212f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-08-11T20:56:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-24T09:23:11.000Z", "avg_line_length": 33.8117647059, "max_line_length": 107, "alphanum_fraction": 0.6884133612, "num_tokens": 1900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.40913458262808716}}
{"text": "\\documentclass[12pt]{amsart}\n\n\n% PACKAGES\n\\usepackage{url}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\n% for underscores https://texfaq.org/FAQ-underscore\n\\usepackage{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage{textcomp}\n\\usepackage{lineno}\n\n\\usepackage[\nbookmarksopen,\nbookmarksdepth=2,\n%breaklinks=true\ncolorlinks=true,\nurlcolor=blue]{hyperref}\n\n% GLOBAL FORMATTING\n%\\linenumbers\n\\parindent=0pt\n\\parskip=0.5\\baselineskip\n\\raggedbottom\n\n% TITLE AUTHOR DATE\n\\title{An argument for controlled natural languages in mathematics}\n\n\\date{June 14, 2019}                                           % Activate to display a given date or no date\n\\author{Thomas Hales}\n\n% THEOREMS \n\\newtheorem{definition}{Definition}\n\\newtheorem{theorem}[definition]{Theorem}\n\\newtheorem{lemma}[definition]{Lemma}\n\\newtheorem{specification}[definition]{Specification}\n\n% COMMANDS\n\\renewcommand{\\iff}{\\leftrightarrow}\n\\newcommand{\\Prop}{\\text{\\tt Prop}}\n\\newcommand{\\Type}{\\text{\\tt Type}}\n\\newcommand{\\fld}{\\textasciicircum}\n\\newcommand{\\dequiv}{\\mathrel{:=}} %{\\mathrel{:\\equiv}}\n\\newcommand{\\Nat}{\\ensuremath{{\\mathbb N}}}\n\\newcommand{\\Real}{\\ensuremath{{\\mathbb R}}}\n\\newcommand{\\df}[1]{\\text{\\bf #1}}\n\\newcommand{\\h}[1]{\\text{#1}}\n\\newcommand{\\join}{\\lor}\n\\newcommand{\\Mid}{\\mathrel{\\|}}\n\\newcommand{\\comment}[1]{\\%- \\nobreak{#1}}\n\\renewcommand{\\~}{\\ }\n\\newcommand{\\ignore}[1]{}\n\\newcommand{\\remark}[1]{(#1)}\n\\renewcommand{\\_}{\\textunderscore}\n\\renewcommand\\labelitemi{-}\n\\renewcommand{\\qed}{\\ensuremath{\\square}}\n\n% ENVIRONMENTS\n\n% \\leavevmode\\par is to make remark work when it is the first item in a subsection.\n\\newenvironment{remark}\n{\\leavevmode\\par\\begin{tabular}{|p{13cm}}\\parskip=\\baselineskip{\\bf Remark.}}\n{\\end{tabular}}\n\n\\newenvironment{oblongo}{}{}\n\n\\newenvironment{prule}%\n               {\\begin{itemize}}%\n               {\\end{itemize}}\n\\newcommand{\\ptem}{\\item}\n\\newcommand{\\nt}[1]{{\\tt #1}}\n\\newcommand{\\rw}{$\\quad\\to\\quad$}\n\n\n\n% DOCUMENT\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\n\nAt the recent Big Proof 2 conference in\nEdinburgh,\\footnote{\\href{https://www.icms.org.uk/bigproof.php}{Big\n    Proofs, ICMS}} I realized that a case must be made for developing\na controlled natural language for mathematics.  There is little\nconsensus on this issue, and mathematicians and computer scientists\ntend to line up on opposite sides.  Some are outright dismissive of\nthe idea.  Little research is happening.  While making the case below\n(giving the mathematician's side), I'll also review and respond to\nsome of the computer scientists' objections.\n\nI thank Arnold Neumaier and Peter Koepke for many discussions and for\ngetting me interested in this topic.\n\n\\subsection{Controlled Natural Languages (CNL)}\\label{sub:CNL}\n\nBy controlled natural language for mathematics (CNL), we mean an\nartificial language for the communication of mathematics that is (1)\ndesigned in a deliberate and explicit way with precise\ncomputer-readable syntax and semantics, (2) based on a single natural\nlanguage (such as Chinese, Spanish, or English), and (3) broadly\nunderstood at least in an intuitive way by mathematically literate\nspeakers of the natural language.\n\nThe definition of controlled natural language is intended to exclude\ninvented languages such as Esperanto and Logjam that are not based on\na single natural language.  Programming languages are meant to be\nexcluded, but a case might be made for \\TeX\\ as the first broadly\nadopted controlled natural language for mathematics.\n\nPerhaps it is best to start with an example.  Here is a beautifully\ncrafted CNL text created by Peter Koepke and Steffen\nFrerix.\\footnote{\\href{http://aitp-conference.org/2019/aitp19-proceedings.pdf}{AITP\n    2019 proceedings}, page 84} It reproduces a theorem and proof in\nRudin's {\\it Principles of mathematical analysis} almost word for\nword. Their automated proof system is able to read and verify the\nproof.\n\n\\begin{theorem}[text in Naproche-SAD system]\n  If $x\\in \\Real$ and $y\\in\\Real$ and $x > 0$ then there is a positive\n  integer $n$ such that $n\\cdot x > y$.\n\\end{theorem}\n\n\\begin{proof}\n  Define $A=\\{n\\cdot x \\mid n\\ \\h{is a positive integer}\\}$. Assume the contrary.\n  Then $y$ is an upper bound of $A$.  Take a least upper bound $\\alpha$ of $A$.\n  $\\alpha- x < \\alpha$ and $\\alpha - x$ is not an upper bound of $A$.\n  Take an element $z$ of $A$ such that not $z \\le \\alpha - x$.  Take a positive\n  integer $m$ such that $z = m\\cdot x$. Then $\\alpha - x < m\\cdot x$ (by 15b).\n  \\[\n  \\alpha = (\\alpha -x) + x < (m\\cdot x) + x = (m+1)\\cdot x.\n  \\]\n  $(m+1)\\cdot x$ is an element of $A$. Contradiction.  Indeed $\\alpha$\n  is an upper bound of $A$.\n  \\end{proof}\n\nIn my view, this technology is undervalued.  I feel like a stock\nadvisor giving tips here, but I see it as an opportune time to invest\nheavily in CNLs.\n\n\\section{The argument}\n\nHere is an outline of the argument that I will develop in the\nparagraphs that follow.\n\n\\begin{enumerate}\n\\item Technology is still far from being able to make\na semantic reading of mathematics as it is currently written.\n\\begin{enumerate}\n\\item Machine learning techniques\n  (in particular, deep neural networks) are still far from\na semantic reading of mathematics.\n\\item Linguistic approaches are still far from a semantic reading of\nmathematics as it is currently written.\n\\end{enumerate}\n\\item Mathematicians are still far from the mass adoption\n  of proof assistants.\n  \\begin{enumerate}\n  \\item Adoption has been gradual.\n    \\item Structural reasons hinder the adoption of proof assistants.\n    \\end{enumerate}\n\\item There is value in bridging the gap between (1) and (2).\n\\item CNL technology works now and can help to bridge the gap.\n\\end{enumerate}\n\n\n\\subsection*{1. Technology is still far from making\na semantic reading of mathematics as it is currently written.}\n\nIn my view, the current champion is WolframAlpha, in its ability\nto answer natural language queries about mathematics.\n\n%% XX realign statements.\n\\subsubsection*{1a. Machine learning (neural networks) are still far from a semantic reading\nof mathematics}\n\nRecent advances in machine learning, such as AlphaZero, have been\nspectacular.  However, some experts point to major unsolved\ntechnological problems.\n\n%% XX Sz.\nI visited Christian Szegedy's group at Google in Mountain View and\nApril and attended their talks at AITP in Austria the same\nmonth.\\footnote{\\href{http://aitp-conference.org/2019/aitp19-proceedings.pdf}{AITP\n    2019 proceedings}, page 19\n  \\\\ \\href{https://ai.google/research/people/ChristianSzegedy}{Christian\n    Szegedy's research page}} They have ambitions to {\\it solve math}\n(to use their mind-boggling phrase) in the coming years.  Their\nambitions are inspiring, the resources and research methodologies at\nGoogle are grandiose, but I would not personally bet on their time\nframe.\n\nTheir current focus is to use deep neural networks to predict a\nsequence of tactics that will successfully lead to new formal proofs\nof lemmas.  These are all lemmas that have been previously formalized\nby John Harrison in his HOL Light libraries on real and complex\nanalysis.  As things stand now, other long-established technologies\n(such as hammers) have had similar success rates in formal proof\nrediscovery.  Thus far, Google is not ahead of the game, but they are\nprogressing quickly.\n\nDavid Saxton (at DeepMind) spoke at the Big Proof 2 conference in\nMay.\\footnote{\\href{https://arxiv.org/abs/1904.01557}{David Saxton et\n    al. ``Analysing Mathematical Reasoning Abilities of Neural\n    Models'' }} He described a new large machine-learning dataset of\nschool-level problems in areas such as arithmetic, algebra, and\ndifferential\ncalculus.\\footnote{\\href{https://github.com/deepmind/mathematics_dataset}{Github\n    mathematics dataset}} Currently the machine learning success rates\nare poor for many of these categories.  The dataset is meant to\nstimulate machine learning research on these topics.\n\nDeep neural networks have not been successful thus far in learning\nsimple algorithms.  In particular, deep neural networks cannot\ncurrently predict with much accuracy the answer to elementary sums of\nnatural numbers.  What is $437+156$?  Can a machine learn\nthe algorithm?  School-level math problems require more than parsing\nmathematical text.  Nevertheless, parsing of mathematical text remains\nan unsolved challenge. They write in the introduction to their recent\npaper:\n\n\\begin{quote}\n``One area where human intelligence still differs and excels compared\nto neural models is discrete compositional reasoning about objects and\nentities, that `algebraically generalize' (Marcus, 2003). Our ability\nto generalise within this domain is complex, multi-faceted, and\npatently different from the sorts of generalisations that permit us\nto, for example, translate new sentence of French into English.''\n\\end{quote}\n\nHere is an example of a challenging problem for machine learning from\ntheir paper.  What is $g(h(f(x)))$, where $f(x) = 2x + 3$, $g(x) = 7x\n- 4$, and $h(x) = -5x - 8$?''\n\nBased on their paper,\n%I seek a realistic\n%assessment of what technology will soon do.  My sense is that the\nit seems to me that semantic parsing of research level mathematics is\nstill years away.\n\n\\subsubsection*{1b.  Linguistic approaches are still far from a\n  semantic reading of mathematics as it is currently written.}\n\nThe most widely cited work here is Mohan Ganesalingam's thesis ``The\nlanguage of mathematics.''  The thesis uses Discourse Representation\nTheory from linguistics to analyze mathematical language.\nGanesalingam analyzes the language of mathematics as it is written in\nreal mathematical publications, in all of its organic complexity.\n\nThere is far too little research in this area.\nHere is his assessment.\\footnote{M. Ganesalingam, Principia conference}\n\n\n\\begin{quote}\nMathematics differs sufficiently from human languages that little\nlinguistic theory can be used directly; most of the material must be\nrebuilt and reconstructed. But linguistics, at the very least, gives\nus general ideas about how we can formally analyse language: it gives\nus a mindset and a starting place. Thus, in very broad terms, our work\nmay be regarded as `the application of linguistics to mathematical\nlanguage'. This is almost untrodden ground; the only linguist to\nanalyse mathematics, Aarne Ranta, notes that\n\\begin{quote}\n  Amazingly little use has been made of [mathematical language] in\n  linguistics; even the material presented below is just an\n  application of results obtained within the standard linguistic\n  fragment [...].  Ranta (1994)\n\\end{quote}\n\\end{quote}\n\nFurthermore,\n\n\\begin{quote}\n  We demonstrate that no linguistic techniques can remove the\n  ambiguity in mathematics. We instead borrow from mathematical logic\n  and computer science a notion called the `type' of an object\\ldots\n  %describing what kind of thing a mathematical object is and how it\n  %behaves,\n  and show that this carries enough information to resolve\n  ambiguity.  However, we show that if we penetrate deeply enough into\n  mathematical usage, we hit a startling and unprecedented problem. In\n  the language of mathematics, what an object is and how it behaves\n  can sometimes differ: numbers sometimes behave as if they were not\n  numbers, and objects that are provably not numbers sometimes behave\n  like numbers.\n\\end{quote}\n\nAs I understand, Mohan's work was mostly theoretical and\nalthough there were once plans to do so, it has not been\nimplemented in any available software.\n\n%In related work, Gowers has become interested in what might be called\n%``extreme human oriented automated mathematics.''\n\n\\subsection*{2. Mathematicians are still far from the mass adoption\nof  proof assistants}\n\n\\subsubsection*{2a. Adoption has been gradual}\nI have watched first-hand the gradual adoption of proof assistants by\nmathematicians.\n\nIn 2001 when I first took up formalization, I knew only a few\nmathematicians who were even aware of proof assistants (Dan Bernstein,\nCarlos Simpson, Doran Zeilberger, ...).  That was the year I moved to\nPittsburgh, and CMU already had a long tradition of formal proof in\namong logicians and computer scientists (Dana Scott, Peter Andrews,\nFrank Pfenning, Bob Harper, Jeremy Avigad, and so forth).\n\nIn 2008, Bill Casselman and I were guest editors of a special issue of\nthe Notices of the AMS on formal proof that helped to raise awareness among\nmathematicians.  This included a cover article by Georges Gonthier on\nthe formal proof of the four color theorem. (All the authors of this\nspecial issue were together again at the BigProof2 conference.)\n\nHomotopy type theory (HoTT) became widely known throug a special\nprogram at the Institute for Advanced study in 2012-2013, organized by\nV. Voevodsky, T. Coquand, and S. Awodey.  A popular book on HoTT\nresulted from that program.  Other programs followed, such as the IHP\nprogram on the semantics of proof and certified programs in 2014.\n\nMajor publishers in mathematics now publish on formal\nproofs.\n%\\footnote{See the articles by Avigad, Grayson, Pelayo, and\n%  Bourbaki reports}\nThere have been notable success stories (formalizations of the\nFeit-Thompson theorem and the Kepler conjecture).  Equally, there have\nbeen major industrial success stories (the CompCert verified compiler\nand the SeL4 microkernel verification).\n\nIn the last few years, several more mathematicians (or perhaps dozens\nif we include students) have become involved with Lean (but not\nhundreds or thousands).\n\nFormal proofs are now regular topics online in places such as\nreddit and mathoverflow.\n\nIn summary, the landscape has changed considerably in the last twenty\nyears, but it is still nowhere near mass adoption.\n\n%% XX.\n\\subsubsection*{2b. Structural reasons hinder the adoption of proof assistants}\nThere are reasons for lack of mass adoption.  The reason is\nnot (as some computer scientists might pretend) that mathematicians\nare too old or too computer-phobic to program.\n\nIf mathematicians are not widely adopting formalization, it is because\nthey have already sized up what formalization can do, and they realize\nthat no matter its long term potential, it has no immediate use to\nthem.  Homotopy type theory and related theories are closely watched\nby mathematicians even if not widely used.\n\nI realize that I am an exception in this regard, because I had a\nspecific real-world situation that was solved through formalization:\nthe referees were not completely able to certify the correctness of\nthe Kepler conjecture and eventually they reached a point of\nexhaustion.  It fell back on my shoulders to find an alternative way\nto certify a proof the Kepler conjecture.\n\nWiedijk has pinpointed the most important reason that proof assistants\nhave not caught on among mathematicians: in a proof assistant, the\nobvious ceases to be obvious.\n\nKevin Buzzard has spoken about his frustrations in trying to get Lean\nto accept basic facts that are obvious to every mathematician.  Why is\n$1\\ne 2$?  He has faced further frustrations in dealing with\nmathematically irrelevant distinctions made by proof assistants. For\nexample, different constructions of a localization of a ring can lead\nto canonically isomorphic (but unequal) objects, and it is no small\nmatter to get the proof assistant to treat them as the same object.\n\n\n\\subsection*{3. There is value in bridging the gap between (1) and (2).}\n\nI'll quote a few mathematicians.\\footnote{Quoted in Ursula Martin's\n  BigProof2 conference slides from the Breakthrough Prize interviews, 2014}\n%(Simon Donaldson, Maxim Kontsevich,\n%Jacob Lurie, Terence Tao, Richard Taylor: award of \\$3 million\n%Breakthrough Prizes, 2014)}\n\n\\begin{quote}\n  ``I would like to see a computer proof verification system with an\n  improved user interface, something that doesn't require 100 times as\n  much time as to write down the proof. Can we expect, say in 25\n  years, widespread adoption of computer verified proofs?'' -J. Lurie\n  \\end{quote}\n\n\\begin{quote}\n  ``I hope [we will eventually be able to verify every new paper by\n    machine.]. Perhaps at some point we will write our\n  papers... directly in some formal mathematics system.'' - T. Tao\n\\end{quote}\n\nTimothy Gowers was part of a panel discussion at BigProof1 conference in\n2017.\\footnote{\\href{https://www.newton.ac.uk/seminar/20170714143015301}{Gowers,\n    panel discussion, Big Proof, 2017} (minutes $15$--$26$, mp3)} He\nwent through a list of automation tools that he would find useful and\nanother list of tools that he would not find useful at all.  One dream\nwas to develop an automated assistant that would function at the level\nof a helpful graduate student.  The senior mathematician would suggest\nthe main lines of the proof, and the automated grad student would fill\nin the details.  He also suggested improved search for what is in the\nliterature, when you do not know the name of the theorem you are\nsearching for, or even whether it exists.  For this, full\nformalization is not needed.\n\nMichael Kohlhase and others in his group have advocated\n``flexiformal'' mathematics, as an interpolation between informal and\nformalized\nmathematics.\\footnote{\\href{https://d-nb.info/1141379643/34}{Iancu,\n    Thesis 2017, Flexiformal},\n  \\href{https://github.com/MathHubInfo/Documentation/wiki/FlexiForms}{Flexiforms}}\nThey are also developing technology to translate between different\nproof assistants (or formal languages), once the mathematics has been\nrepresented in one of them.\n\nThe Logipedia project also implements general methods to translate\nmathematics between formal languages. For this to happen, the\nmathematical content must first be represented in some formal way.\nThe two main technologies for this project are Logical Frameworks\n(Dedukti) and Reverse Mathematics.\n\nAn intended application of a large corpus of mathematics in a CNL\nwould be big data sets for machine learning projects.  Currently there\nis far too little data that aligns natural language mathematics with\nformal mathematics.\n\n\n%(Note the future tense!)\n%Gowers. Minute 15-26.\n%What is not useful.\n%Participant rather than observer Undergraduate level mathematics.\n%proof assistants are not proof assistants at all.\n%HoTT doesn't help additive combinatorics.\n%What might be useful.  A helpful graduate student. Currently beyond what we can do.\n%A reverse lookup. Is this known (without name of theorem). For this, don't need\n%properly formalized, just enough to be searchable.\n%A proof checker (for reading papers one-level down, or two-levels down), within reach.\n%Example, modularity of elliptic curves.\n%A library with fewer results (a human library carried in brains or in a building).\n%We decide quite carefully what to put in the library. Roughly, those statements\n%from which the other results are routine consequences.\n%Gowers: extreme human oriented automated mathematics. Eliminate all search, except human-style search.  For scalability: branching gives combinatorial explosion. For comprehensibility.  For benchmarks.\n\n% https://www.newton.ac.uk/seminar/20170714143015301 (around 15 minutes, mp3)\n% https://sms.cam.ac.uk/media/2525600?format=mp3&quality=high&fetch_type=dl\n\n% Ayers: semantic search engine for mathematics\n% https://www.ccimi.maths.cam.ac.uk/projects/create-semantic-search-engine-mathematical-literature/\n% \n\nMy dream is to someday have an automated referee for mathematical papers.\n\n\n\\subsection*{4.  CNL technology works and can help to bridge the gap.}\n\nI believe strongly in the eventual mechanization of large parts of\nmathematics.  According to a divide and conquer strategy for\naccomplishing this, we want to strike at the midpoint between current\nhuman practice and computer proof.  In my view, CNLs do that.  A\nmillion pages of this style of CNL is achievable.\n\n\\subsubsection*{4a. CNL has a long history}\n\nA brief history of the CNL {\\it Forthel (an acronym of FORmal THEory\n  Language)} is sketched in K. Vershinin's note.\\footnote{%\n  \\href{http://tertium.org/papers/ita-00.ps.gz}{Vershinin, ``ForTheL\n    -- the language of formal theories''}} Koepke told me that Forthel\n(that is, fortel') means trick in Russian and that this is an intended\npart of the acronym.\n%\\url{https://en.pons.com/translate/russian-english/фортель}\n%(фортель)\n\nResearch started with V. Glushkov in the 1960s.  A system of deduction\nwas part of the system from the beginning (even if my interest is\nprimarily in the language).  A description of the language first\nappeared in the Russian paper ``On a language for description of\nformal theories'' Teoretischeskaya kibernetika, N3, 1970.\n\nResearch continued with V. Bodnarchuk, K. Vershinin and his group\nthrough the late 1970s.  Most of the early development was based in\nKiev.\n\nThe language was required to have a formal syntax and semantics.  To\nallow for new definitions, ``the thesaurus of the language should be\nseparated from the grammar to be enrichable.  On the other hand the\nlanguage should be close to the natural language of mathematical\npublications.''\n\nThe development of the Forthel language development seems to have been\nintermittant.  Andri Paskevich's thesis in Paris gives a description\nof the language and deduction system as of the end of 2007.\n\nAfterwards, development (renamed as Naproche-SAD) shifted to Bonn with\nPeter Koepke and his master's student Steffan Frerix.  The current\nHaskell code is available on\ngithub.\\footnote{\\href{https://github.com/Naproche/Naproche-SAD}{Github,\n    Naproche-SAD}} In this document, I will refer to Forthel and\nNaproche-SAD as synonyms, although Forthel is the name of the\ncontrolled natural language, whereas Naproche-SAD includes a reasoning\nmodule connected to the E theorem prover.\n\nIn May 2019, Makarius Wenzel implemented a a mode of Isabelle/PIDE for\nNaproche-SAD.\\footnote{\\href{https://arxiv.org/pdf/1905.01735.pdf}{Wenzel,\n    arXiv paper, 2019}} It can be\ndownloaded.\\footnote{\\href{https://files.sketis.net/Isabelle_Naproche-20190418/}{Isabelle-Naproche\n    download}} This is currently the best way to interact with\n   Naproche-SAD.\n\n\\subsubsection*{4b. The Forthel language has an elegant design}\n\nThe text we produce is intentionally verbose and redundant.  The aim\nis to produce texts that can be read by mathematicians without any\nspecialized training in the formalization of mathematics.  We want\nmathematicians (say after reading a one page description of our\nconventions) to be able to read the texts.\n\nThe ability to understand a CNL is an entirely different matter than\nto write or speak a CNL.  The CNL might have invisible strict\ngrammatical rules that must be adhered to.  As Stephen Watt put it\nafter my BigProof2 lecture, there is a big difference between watching\na movie and directing a movie.\n\nOur main references are Paskevich's paper on Forthel {\\it (The syntax\n  and semantics of the ForTheL language, 2007)}, his thesis at Paris\nXII and the Naproche-SAD source code.\\footnote{See {\\it (M\\'ethodes de\n    formalisation des connaissances et des raisonnements\n    math\\'ematiques: aspects appliqu\\'es et th\\'eoriques, 2007)} and\n  \\href{https://github.com/Naproche}{github, Naproche-SAD}}.\n\nForthel achieves readability through a collection of tricks.  The\nlinguistics behind Forthel is actually quite elementary, and it\nis remarkable how English friendly it is with so little linguistics.\nOne trick is the generous use of stock phrases (or canned phrases)\nthat the user can supply.\n\nAnother trick is the use of free variants (synonyms), such as\n[set/sets], which declares that the words {\\it set} and {\\it sets} are\nfully interchangeable.  There are no grammatical notions of gender,\ncase, declension, conjugation, agreement, etc.  in Naproche.  The\nneeded forms are introduced as variants and the system does not care\nwhich are used.\n\nAnother trick is the use of filler words. These are words that are\nignored by Forthel.  For example, in many contexts indefinite and\ndefinite articles {\\it a, an, the} are disregarded.  They are there\nonly for human readability.\n\nThe Naproche-SAD parser is written in Haskell.  It is basically a\nsimplified knock-off of the Haskell parsec parser library.\n\nThe grammar is not context-free (CFG).  Thus, some parser generators\n(such as $LR(k)$ parsers) are not appropriate for our project.\n\nAlthough the grammar is extensible, we can still describe the language\nby a finite list of production rules in BNF format.  The collection of\nnonterminals cannot be changed.  However, some of the nonterminals are\ndesignated as {\\it primitive}.  Primitive nonterminals differ from\nordinary nonterminals in that new replacement rules can be added (by\nthe user) to a primitive nonterminal.  In this way, as mathematical\ntext progresses, the grammar can be enriched with new constructions\nand vocabulary.\n\n\n\\subsubsection*{4c.  Forthel language design principles\n  provide a template for future CNLs}\n\nThis is work in progress.  The point is that Forthel design is\nsufficiently generic that the language can be readily adapted to\nsupport back-end semantics of Lean's dialect of CiC.\n\nFor this project, we recommend using the Haskell parsec parser\nlibrary.  Parsec is written as a library of parser combinators, with\nlazy evaluation, in a continuation style, with state stored in a\nparser monad.\n\nIf Lean4 has sufficiently powerful parsing capabilities, we can\neventually port the project into Lean4.  By using Haskell for our\ninitial implementation, we make porting easier.\n\n\nActually, we combine two different parsing technologies: parsec style\ncombinators and a top-down-operator precedence parser.  The\ntop-down-operator precedence parser is used for purely symbolic\nformulas.  We describe below the rule used to extract sequences of\nsymbolic lexemes that are shipped to the top-down-operator precedence\nparser.  By including a top-down-operator precedence parser, we are\nable to add new symbolic notations with fine-grained levels of\nprecedence.\n\nWe expect the grammar to be ambiguous.  The parser should be capable\nof reporting ambiguous user input.\n\nIt seems to me that the biggest difficulty in writing a CNL for Lean\nwill be the ``last mile'' semantics of Lean.  By this, I mean the\nautomatic inserting the correct coercions and casts along equality to\nproduce a pre-expression that can be successfully elaborated and type\nchecked by Lean.  (I expect that automatically generated\npre-expressions will frequently be off by casts along equality.)\n\n\\section{Objections and counterarguments}\n\nAt the BigProofs2 conference, several researchers made the argument that\ncontrolled natural languages are a step backwards from precise\nprogramming languages.\n\n\\subsection{We should not abandon centuries of mathematical notational improvements}\n\nA sneering comparison was made between CNLs and the medieval practice\nof writing formulas and calculations out long-form in natural\nlanguage. Significant progress in mathematics can be attributed to\nimproved symbolic representations for formulas and calculations.  It\nwould be terrible to be forced in our language to write\n$\\pi/\\sqrt{18}$ as {\\it pi divided by the square root of eighteen}.\n\nI agree.  In fact, our controlled natural language is designed as a\nsuperset of Lean syntax.  Lean is both a language of mathematics and a\npure functional programming language similar to Haskell.  Our\naugmented syntax loses none of that.  We continue to write\n$\\pi/\\sqrt{18}$ as such.\n\nNobody advocates abandoning notations that mathematicians find useful.\nA fully developed CNL includes all the great notational inventions of\nhistory such as decimal, floating point and other number formats,\npolynomial notation, arithmetic operations, set notation, matrix and\nvector notation, equations, logical symbolism, calculus, etc.\n\nA CNL is also more than that, by providing precise\nsemantics for mathematics in natural language.\n\nKnuth, who has\nthought long and hard about mathematical notation, instructs that\nit is ``especially important'' not to use the symbols\n\\[\n\\therefore,\\ \\Rightarrow,\\ \\forall,\\ \\exists,\\ \\ni;\n\\]\n``replace them by the corresponding words.  (Except in works on logic,\nof course.)''\\footnote{Knuth, math writing, page 1. pdf page 3.}  The\nsymbols are less fluent than the corresponding words.  Knuth gives\nthis example of a bad writing style:\n\\[\n\\exists_{n_0\\in N_0} \\forall_{p\\in P}\\ p\\ge n_0 \\Rightarrow f(p)=0.\n\\]\n% page 5.\nAnother bad example from Knuth appears below in the section on examples.\n\n\\subsection{We should not return to COBOL}\n\nContinuing with the criticism of CNL, some argue that CNLs are an\nunpleasant step in the direction of COBOL.  Among the BigProof2 conference crowd,\nCOBOL evokes Dijkstra's assessment ``The use of COBOL cripples the\nmind; its teaching should, therefore, be regarded as a criminal\noffence.''  Still today, there is a strong distaste among some theoretical\ncomputer scientists (and principled programming language designers) of\ndesigns based on natural language.\n%http://www.cs.virginia.edu/~evans/cs655-S00/readings/ewd498.html\n% https://www.dw.com/en/fail-by-design-bankings-legacy-of-dark-code/a-43645522\n\nLike COBOL, a CNL is self-documenting, English-oriented, and more\nverbose than ordinary programming languages.  However, the features of\nCOBOL that really incite wrath have nothing to do with CNLs: the GOTO\nstatement, lack of modularity, no function calls, no type checking on\nsubroutine calls, no libraries, and so forth.\n% https://softwareengineering.stackexchange.com/questions/112911/why-the-scorn-for-cobol\n\n%\\subsection{It is all code}\n\n%Part of what seems to be driving the distaste of CNLs is that\n%even if they do not say so, they view all of mathematics\n%as ultimately just computer code (just as the entire\n%world to some is ultimately just computer code), both\n%in the software is eating the world sense, and in the\n%laws of physics as computational processes sense.\n\n\n%I agree entirely.  The last thing I want is for programmers\n%to expand precise computer code into a Medieval long-form.\n%My purpose is exactly in the opposite direction.  I want\n%a bridge that will move mathematicians from X.\n\n\\subsection{Lean is already readable}\n\nSome say that Lean is already readable and that a CNL is therefore\nwasted effort.\n\nI find the level of readability of Lean to be similar to that of Coq.\nIt is somewhat less readable than scripts in Mizar and\nIsabelle/HOL/Isar.\n\nFor those trained in Lean, the statements of definitions and theorems\nare readable, but most users find it necessary to jump incessantly\nfrom file to file within an environment such as VSCode (or emacs)\nbecause relevant context is spread through many files.\n\nGenerally, even those who write the scripts in Lean find it necessary\nto jump around in this manner to make sense of their own scripts.  It\nis wonderful to have tools that allow us to jump around, but when that\nbecomes the only possible mode of interaction, our thinking about\nmathematics becomes fragmented.  (I may be old-fashioned in this worry\nof fragmentation.)\n\nProofs in almost all proof assistants are unreadable (in any sort of\nlinear text-oriented fashion).  Lean is no exception.\n\nMy impression is that few mathematicians would be willing to\ninvest the necessary effort to read Lean scripts.\n\n\nHere are some samples of Lean code.\\footnote{\n\\href{https://github.com/sgouezel/mathlib/blob/manifold4/src/geometry/manifolds/manifold.lean}{Lean manifolds}\n  \\\\ \\href{https://github.com/leanprover-community/mathlib/blob/master/src/analysis/complex/polynomial.lean}{Lean Fundamental Theorem of Algebra}\n}\nI do not mean to single out the authors of these files for\nenhanced criticism.  The files are meant to be representative\nof Lean.\n\n% \n\nIn a CNL, there is no semantic penalty for writing the fundamental\ntheorem of algebra as follows.\n\nAssume that $f$ is a polynomial over ${\\mathbb C}$ of positive degree.\nThen there exists a complex number $z$ that is a root of $f$.\n\n\n\\subsection{Documentation should be generated from source code, not vice versa.}\n\nAnother argument is that we should generate natural language\ndocumentation from the formal text rather than the other way around.\nThere are many successful examples of this approach, such as Mizar to\n\\LaTeX\\ translation.\\footnote{\\href{https://link.springer.com/chapter/10.1007/978-3-319-96812-4_1}{XSL-Based\n    Translator of Mizar to LaTeX}} These are useful tools, and I have\nno criticism of this.\n\nThe direction of code generation depends on the purpose.  The source\nformat is generally speaking the cleanest representation.  A human\nwill be directly involved in writing the source format.  If the\nprimary purpose is formalization, then formal scripts should be the\nsource format from which others are generated.  (Subtle differences in\nrepresentation of mathematical concepts code can make a big difference\nin how painful the formal proofs are.)  If the primary purpose is\nmathematical communication, then human-oriented language should be the\nsource format.  (Humans can be easily annoyed by the stilted language\ngenerated from formal representations.)  Who should we ask for\ntolerance, the human or the computer?\n\nOther variations appear in practice.  In some projects there are two\nsource formats and semantics-preserving translation from one to the\nother.  For example, computer software can have a\nspecification from which executable code might be automatically extracted,\nbut for reasons of efficient execution it might be better to run an\noptimized hand-crafted version of the code that is verified to be\nequivalent to the extracted code.\n\nAnother approach was used in the Flyspeck project, which used an\nEnglish text as the blueprint for the formal proof scripts. Both the\nblueprint and proof scripts were written by humans, and the alignment\nbetween them was also a human effort.  I wish to avoid that\nlabor-heavy style in the formal abstracts project.\n\nI have some experience in automatic code generation.  In the proof of\nthe Kepler conjecture, the C++ code to rigorously test nonlinear\ninequalities by interval arithmetic was automatically generated from\nthe formal specification of the inequalities in HOL Light.\n\n\\subsection{The foundational back ends of  CNLs are too weak}\n\nThe Forthel language compiles down to first order logic.  The\nreasoning in the CNL example from Rudin in Section~\\ref{sub:CNL} is\nnot based on axiomatic reasoning using the axioms of Zermelo-Fraenkel\nset theory.  Rather, the authors made up their own system of axioms\nthat were designed to prove exactly what they wanted to prove. For\nthis reason, the example is really just a toy example that is\nfoundationally ungrounded.  (Yet it is a working technology\nthat makes us see what is concretely realizable.)\n\nNone of the successful proof assistants are based on first order\nlogic.  Most of the widely used proof assistants are based on some\nform of type theory (simple type theory or the calculus of inductive\nconstructions).  Proof assistants based on set theory (such as Mizar)\nadd a layer of soft typing on top of the set theory.\n\nI agree with this criticism.  I believe that a more powerful back end\nis needed for a CNL if it is to be widely adopted.  I propose the Lean\ntheorem prover as a back end. This will require some changes to the\ngrammar of the CNL.\n\n\\subsection{We already have too many proof assistants and incompatible\n  research directions.}\n\nAnother CNL will further fragment research on formalization.\n\nInteroperability is important.  It emerged as a notable\ntheme at the BigProofs2 conference.  I would hope that we can achieve\nsome interoperability with other projects such as Flexiformalized math\nand OMDoc, Logipedia and Dedukti, and the Lean theorem prover math\nlibraries.\n\nA long term project might be to design a CNL that is sufficiently\nuniversal to work with different proof assistants on the back end.\n\nIn fact, there is too little activity in the CNL space right now.  I\nhope that we can be compatible with Arnold Neumaier's group and Peter\nKoepke's.\n\n\\section{examples}\n\nThe examples in this section are hypothetical.  They are based on CNL\ngrammar rules that have not been programming into a computer.  They\nillustrate what we hope soon to obtain.  The changes to the existing\nproduction rules of Forthel are relatively minor.\n\n\\subsection{the Kepler conjecture as an example}\n\nHere is the formal statement of the Kepler conjecture\nas it appears in the HOL Light proof assistant.\n\n\\begin{verbatim}[VERSION 1]\n(!V. packing V\n            ==> (?c. !r. &1 <= r\n                ==> &(CARD(V INTER ball(vec 0,r))) <=\n                pi * r pow 3 / sqrt(&18) + c * r pow 2))\n\\end{verbatim}\n\nThere are several elements that hamper readability.\nIt is all in ascii, including unpleasant\nascii alternatives: $!$ for $\\forall$, $?$ for $\\exists$,\n$<=$ for $\\le$, $r\\ \\h{pow}\\ 3$ for $r^3$, $\\h{sqrt}$ for\n$\\sqrt{\\ }$, $\\h{pi}$ for $\\pi$,\n$\\h{INTER}$ for $\\cap$, and $==>$ for $\\Rightarrow$.\n\nReplacing the ascii, we obtain the Kepler conjecture in this\nslightly improved form:\n\n\\noindent [VERSION 2]\n\\begin{align*}\n(\\forall\\ V.&\\ \\h{packing}\\ V\n\\\\ \\Rightarrow& (\\exists\\ c.\\ \\forall\\ r.\\ \\&1 \\le r\n\\\\ &\\quad \\Rightarrow\n \\&(\\h{CARD}(V\\ \\cap\\ \\h{ball}(\\h{vec}\\ 0,r))) \\le\n\\\\&\\quad\\quad \\pi * r^3 / \\sqrt{(\\&18)} + c * r^2))\n\\end{align*}\n\nThis still looks like an ugly formula written by a novice.  A\nmathematician would understand that $\\sqrt{18}$ is a real number,\nwithout writing the unfamiliar operator $\\&$ that casts the natural number $18$\nto the real number.  It is more idiomatic so say {\\it for every\n  packing $V$} than the symbol-laden phrase\n$\\forall\\ V.\\ \\h{packing}\\ V\\Rightarrow\\ldots$, and so forth. Let's\ntry again. (In this final version, we are switching from\nsimple type theory as back-end\nsemantics to the calculus of inductive constructions.)\n\n\\noindent[VERSION 3]\n\nFor every packing $V$, there exists a real number $c$\nsuch that for all real numbers $r\\ge1$,\nthe number of points of $V$ in the open ball ${\\mathbf B}(0,r)$ is at most\n\\[\n\\frac{\\pi\\,* r^3}{\\sqrt{18}} + c\\,* r^2.\n\\]\n\\bigskip\n\nVersion 3 is by far the most readable of the three versions.\nThis is what a CNL looks like in practice.\nIt uses formulas where they are useful, but it\navoids the needless symbolism of version 2. \n\nVersion 3 is very close to the wording used for a general mathematical\naudience in the official publication on the formal proof of the Kepler\nconjecture.  Too much of the work of formalization consists of\ntaking mathematics in a readable form (version 3) and reformatting\nit in a barely readable form (version 1).  It simply is not true\nthat version 1 is in any sense superior to version 3.  A controlled\nnatural language makes version 3 every bit as formal as version 1.\nIt is easy to see why mathematicians would prefer version 3.\n\nVersion 3 has a consistent lexical structure, with\nnumeric constants\n\\[\n0,\\ 1,\\ 2,\\ 3,\\ 18\n\\]\nvariables (single letters)\n\\[\nV,\\ c,\\ r,\n\\]\nwords (including specially declared single letters)\n\\[\n\\h{for},\\ \\h{every},\\ \\h{there},\\ {\\mathbf B},\\  \\pi,\\ \\ldots\n\\]\ndelimiters\n\\[\n(\\ )\\ \n\\]\npunctuation\n\\[\n,\\ .\n\\]\nsymbols\n\\[\n\\ge,\\ *,\\ \\sqrt{\\phantom{e}},\\ /,\\ \\fld\n\\]\netc.  The lexemes are combined using production rules to give precise\nmeaning.\n\nFor example, the phrase {\\it for all real numbers $r\\ge1$, blah-blah}\nof version 3 follows a production rule for the symbolic statement\nnonterminal\n\\begin{prule}\n  \\ptem \\nt{symbolicStatement} \\rw for all \\nt{quantifierProp}, \\nt{symbolicStatemant}\n\\end{prule}\nIn turn, the subphrase {\\it real numbers $r\\ge1$} follows the\nproduction rule for the nonterminal \\nt{quantifierProp}.  In this\ninstance, syntax processing will recognize $r$ as the bound variable,\n{\\it real numbers $r$} as a type annotation $(r : \\Real)$, and\n$r\\ge 1$ as a subtyping predicate on $\\Real$.\n\nA controlled natural language differs from a natural language because\nthese production rules have been chosen by the language designer, and\nthe text must exactly conform to these rules.  A realistic\napproximation to mathematical English can be achieved by a few hundred\ncarefully crafted production rules.\n\n\n\\subsection{Knuth's exercise on technical writing}\n\nKnuth's course on writing math contains a useful exercise on technical\nwriting.\\footnote{\\href{http://tex.loria.fr/typographie/mathwriting.pdf}{Knuth's\n    writing course}}\n\nThe context for the exercise is the following.  We warn that what\nfollows is intentionally atrocious writing style.\n\n$N$ denotes the nonnegative integers, $N^n$ denotes the set of\n$n$-tuples of nonnegative integers, and $A_n = \\{(a_1,\\ldots,a_n)\\in\nN^n\\mid a_1 \\ge \\cdots a_n\\}.$ If $C,P\\subset N^n$, then $L(C,P)$ is\ndefined to be $\\{c + p_1 +\\cdots + p_m\\mid c\\in C, m\\ge\n0,\\ \\h{and}\\ p_j\\in P\\ \\h{for}\\ 1\\le j\\le m\\}.  $ We want to prove\nthat $L(C,P)\\subseteq A_n$ implies $C,P\\subseteq A_n$.\n\nThe exercise is to rewrite the following\nproof originally written by a sophomore.\n\\begin{align*}\n  \\\\ &L(C,P)\\subset A_n\n  \\\\ &C\\subset L\\Rightarrow C\\subset A_n\n  \\\\ &\\h{Spse}\\ p\\in P, p\\notin A_n\\Rightarrow p_i < p_j\\ \\h{for}\\ i < j\n  \\\\ &c+p\\in L \\subset A_n\n  \\\\ &\\therefore c_i+p_i\\ge c_j+p_j\\ \\h{but}\\ c_i\\ge c_j\\ge 0,\\ p_j\\ge p_i\\therefore (c_i-c_j)\\ge (p_j-p_i)\n  \\\\ &\\h{but}\\ \\exists\\ \\h{a constant}\\ k \\ni c + k p\\notin A_n\n  \\\\ &\\h{let}\\ k=(c_i-c_j)+1\\quad c+k p\\in L\\subset A_n\n  \\\\ &\\therefore c_i + k p_i \\ge c_j + k p_j \\Rightarrow (c_i-c_j)\\ge k(p_j-p_i)\n  \\\\ &\\Rightarrow k-1 \\ge k\\cdot m\\quad k,m\\ge 1\\quad \\h{Contradiction}\n  \\\\ &\\therefore p\\in A_n\n  \\\\ &L(C,P)\\subset A_n \\Rightarrow C, P\\subset A_n\\ \\h{and the}\n  \\\\ &\\h{lemma is true}.\n\\end{align*}\n\nWe will rewrite the proof in the style of a controlled natural\nlanguage (that in principle can be parsed directly into a sequence of\nstatements in Lean).  We do not claim that Lean can correctly\nreconstruct a proof from these statements (but that would\nbe an interesting research problem). Here goes.\n\n\\begin{lemma}\n  Assume $(i,\\ j,\\ n:\\Nat)$, $(P,\\ C:\\h{set over}\\ \\Nat^n)$.\n  Let \n  \\[\n  A(n):= \\{ a : \\Nat^n \\mid \\h{for all}\\ i \\le j,\\ a_i \\le a_j\\}.\n  \\]\n  Let $P^*$\n  denote the submonoid of $\\Nat^n$ generated by any $P$.\n  Let\n  \\[\n  C+P^* :=\n  \\{ c + b \\mid c \\in C,\\ b\\in P^*\\}.\n  \\]\n  Then for every $n$,\n  for all $C\\ne \\emptyset$ and \n  $C+P^*\\subseteq A(n)$, we have $C,P\\subseteq A(n)$.\n\\end{lemma}\n\n\\begin{proof}\n  We claim that $C\\subseteq A(n)$.\n  Indeed, for all $c\\in C$,\n  \\[\n  c = c + 0 \\in C+P^* \\subseteq A(n).\n  \\]\n  \n  Next, we claim that $P\\subseteq A(n)$.  Pick any $p\\in P$ and any\n  $i\\le j$.  Take $c \\in C\\ne\\emptyset$.  For all $(k:\\Nat)$, we have\n  $c + k\\cdot p\\in C+P^*\\subseteq A(n)$ and hence\n  \\[\n  c_i + k* p_i \\le c_j + k*p_j.\n  \\]\n  By the Archimedean property of $\\Nat$, we get $p_i\\le\n  p_j$.  Hence $p\\in A(n)$.\n\\end{proof}\n\nPeter Koepke has formalized this proof in Naproche-SAD (private communication).\n\nI want a million pages of mathematics written in this style of CNL and\ncompiled into Lean.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "bcafef702adeffb74ee3eb0505807ad92c2cb175", "size": 42866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/tex/argument_cnl.tex", "max_stars_repo_name": "HoanNguyen92/CNL-CIC", "max_stars_repo_head_hexsha": "b521d3393339e5dd3b7f5cd21ba81a758bd5c55c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2019-06-27T16:34:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-07T18:13:04.000Z", "max_issues_repo_path": "documentation/tex/argument_cnl.tex", "max_issues_repo_name": "HoanNguyen92/CNL-CIC", "max_issues_repo_head_hexsha": "b521d3393339e5dd3b7f5cd21ba81a758bd5c55c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2019-10-17T06:09:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-25T15:51:32.000Z", "max_forks_repo_path": "documentation/tex/argument_cnl.tex", "max_forks_repo_name": "HoanNguyen92/CNL-CIC", "max_forks_repo_head_hexsha": "b521d3393339e5dd3b7f5cd21ba81a758bd5c55c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2019-06-27T16:34:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-15T01:30:32.000Z", "avg_line_length": 42.4415841584, "max_line_length": 202, "alphanum_fraction": 0.7682778892, "num_tokens": 10924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032313, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.40913456884319194}}
{"text": "\n% ----------------------------------------------------------------\n% LaTeX Paper ****************************************************\n% ----------------------------------------------------------------\n\n\\documentclass[11pt]{article}\n\n\\parindent 0in\n\\parskip 1ex\n\n\\usepackage[margin=1in]{geometry}\n\\usepackage{amsmath,amsfonts,amsthm,latexsym,xspace}\n\\usepackage{graphicx}\n\\usepackage{psfrag}\n%\\usepackage{pdfsync}\n\n% ----------------------------------------------------------------\n\n\n\\vfuzz2pt % Don't report over-full v-boxes if over-edge is small\n\\hfuzz2pt % Don't report over-full h-boxes if over-edge is small\n\n% THEOREMS -------------------------------------------------------\n\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\theoremstyle{definition}\n\\newtheorem{defn}[thm]{Definition}\n\\theoremstyle{remark}\n\\newtheorem{rem}[thm]{Remark}\n% \\numberwithin{equation}{section}\n\n% MATH -----------------------------------------------------------\n\n\\newcommand{\\norm}[1]{\\left\\Vert#1\\right\\Vert}\n\\newcommand{\\abs}[1]{\\left\\vert#1\\right\\vert}\n\\newcommand{\\set}[1]{\\left\\{#1\\right\\}}\n\\newcommand{\\reals}{\\mathbb R}\n\\newcommand{\\eps}{\\varepsilon}\n\\newcommand{\\A}{\\mathcal{A}}\n\\newcommand{\\half}{\\tfrac{1}{2}}\n\\newcommand{\\e}{\\mathbf{E}}\n\\newcommand{\\M}{\\mathcal{M}}\n\\newcommand{\\C}{\\mathcal{C}}\n\\newcommand{\\CE}{\\mathcal{E}}\n\\newcommand{\\CG}{\\mathcal{G}}\n\\newcommand{\\CH}{\\mathcal{H}}\n\\newcommand{\\CI}{\\mathcal{I}}\n\\newcommand{\\CN}{\\mathcal{N}}\n\\newcommand{\\CV}{\\mathcal{V}}\n\\newcommand{\\binpower}[2]{#1\\rule{0in}{2.2ex}^{{\\binom{#2}{2}}}}\n\n% OTHER----------------------------------------------------------------\n\n\\makeatletter\n\\renewcommand{\\theenumi}{(\\roman{enumi})}\n\\renewcommand{\\labelenumi}{\\theenumi}\n\\renewcommand{\\theenumii}{(\\alph{enumii})}\n\\renewcommand{\\labelenumii}{\\theenumii}\n\\makeatother\n\\newcommand{\\hide}[1]{}  % replace {} by {#1} to reveal\n\n% ----------------------------------------------------------------\n\n\\title{Path Coupling Using Stopping Times and Counting\\\\Independent Sets\nand Colourings in Hypergraphs}\n\\author{Magnus Bordewich\\thanks{School of\nComputing, University of Leeds, Leeds LS2 9JT, UK. Email:\n\\texttt{\\{dyer,magnusb\\}@comp.leeds.ac.uk}.},\\ \\, Martin Dyer${}^*$ and Marek\nKarpinski\\thanks{Dept. of Computer Science, University of Bonn, 53117 Bonn,\nGermany. Email: \\texttt{marek@cs.uni-bonn.de}.}}\n\\date{April 2, 2005}\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\nWe analyse the mixing time of Markov chains using\npath coupling with stopping times. We apply this approach to two hypergraph\nproblems. We show that the Glauber dynamics for independent sets in a\nhypergraph mixes rapidly as long as the maximum degree $\\Delta$ of a vertex\nand the minimum size $m$ of an edge satisfy $m\\geq 2\\Delta+1$. We also show\nthat the Glauber dynamics for proper $q$-colourings of a hypergraph mixes\nrapidly if $m\\geq 4$ and $q > \\Delta$, and if $m=3$ and $q\\geq1.65\\Delta$.\nWe give related results on the hardness of exact and approximate counting\nfor both problems.\n\\end{abstract}\n\n\\section{Introduction}\n\nWe develop a  new approach to using stopping times in conjunction with path\ncoupling to bound the convergence of time of Markov chains. Our main\ninterest is in applying these results to randomised approximate counting.\nFor an introduction, see~\\cite{J03}. To illustrate our methods, we consider\napproximation of the numbers of independent sets and $q$-colourings in\nhypergraphs with upper-bounded degree, and lower-bounded edge size. These\nproblems in hypergraphs are of interest in their own right but, while\napproximate optimisation has received\nattention~\\cite{DRS02,DGKR03,HL98,KNS01}, there has been surprisingly\nlittle work on approximate counting.\n\nOur results are achieved by considering, in the path coupling setting, the\nstopping time at which the distance between two coupled chains first\nchanges.  The first application of stopping times to path coupling was by\nDyer, Goldberg, Greenhill, Jerrum and Mitzenmacher~\\cite{DGGJM01}. Their\nanalysis was later improved by Hayes and Vigoda~\\cite{HV04}, using a method\nclosely related to that developed in this paper. Theorem~\\ref{stopping},\nthe main technical result of the paper, shows that if the expected distance\nbetween the two chains has decreased at this stopping time, then the chain\nmixes rapidly. This also follows from~\\cite[Corollary~4]{HV04}.  However we\ngive a simpler proof than that of~\\cite{HV04}, and our\nTheorem~\\ref{stopping} will usually give a moderate improvement in the\nbound on mixing time in comparison with~\\cite[Corollary~4]{HV04}. See\nRemark~\\ref{rem20} below.\n\nThe problem of approximately counting independent sets in graphs has been\nwidely studied, see for example~\\cite{DFJ99,DG00a,LV99,M01,V01}, but the\nonly previous work on the approximate counting of independent sets in\n\\emph{hypergraphs} seems to that of Dyer and Greenhill~\\cite{DG00a}. They\nshowed rapid mixing to the uniform distribution of a simple Markov chain on\nindependent sets in a hypergraph with maximum degree 3 and maximum edge\nsize 3. However, this was the only interesting case resolved. Their results\nimply rapid mixing only for $m\\leq \\Delta/(\\Delta-2)$, which gives $m\\leq\n3$ when $\\Delta=3$ and $m\\leq 2$ when $\\Delta\\geq 4$. In\nTheorem~\\ref{indsets} we prove rapid mixing of the \\emph{Glauber dynamics}\nfor any hypergraph such that $m\\geq 2\\Delta+1$, where $m$ is the smallest\nedge size and $\\Delta$ is the maximum degree. This is a marked improvement\nfor large $m$. More generally, we consider the \\emph{hardcore distribution}\non independent sets with \\emph{fugacity} $\\lambda$. (See, for\nexample,~\\cite{DG00a,LV99,V01}.) In~\\cite{DG00a}, it is proved that rapid\nmixing occurs if $\\lambda\\leq m/((m-1)\\Delta-m)$. Here we improve this\nconsiderably for larger values of $m$, to $\\lambda\\leq (m-1)/2\\Delta$. We\nalso give proofs that computing the number of independent sets in\nhypergraphs is \\#P-complete except in trivial cases, and that there can be\nno approximation for the number of independent sets in a hypergraphs if the\nminimum edge size is at most logarithmic in $\\Delta$. It may be noted that\nour upper and lower bounds are exponentially different. We have no strong\nbelief that either is close to the threshold at which approximate counting\nis possible, if such a threshold exists.\n\nCounting $q$-colourings of hypergraphs was considered by Bubley~\\cite{B01},\nwho showed that the Glauber dynamics was rapidly mixing if $q\\geq 2\\Delta$,\ngeneralising a result of Jerrum~\\cite{J95} and Salas and Sokal~\\cite{SS97}\nfor graphs.  Much work has been done on improving this result for graph\ncolourings, see~\\cite{DFHV04} and its references, but little attention\nappears to have been given to the hypergraph case. Here we prove rapid\nmixing of Glauber dynamics for proper colourings of hypergraphs if  $m\\geq\n4$, $q>\\Delta$, and if $m=3$, $q\\geq1.65\\Delta$. For a precise statement of\nour result see Theorem~\\ref{colouring}. Again we give proofs that computing\nthe number of colourings in hypergraphs is \\#P-complete except in trivial\ncases, and that there can be no approximation for the number of colourings\nof hypergraphs if $q\\leq (1-1/m)\\Delta^{1/(m-1)}$. Again, there is a\nconsiderable discrepancy between the upper and lower bounds for large $m$.\n\nThe paper is organised as follows. Section~\\ref{sec:intuit} gives an\nintuitive motivation for the stopping time approach of the paper.\nSection~\\ref{sec:stopping} contains the full description and proof of\nTheorem~\\ref{stopping} for path coupling with stopping times. We apply this\nto hypergraph independent sets in Section~\\ref{sec:indsets}.\nSection~\\ref{sec:hard} contains the hardness proofs.\nSection~\\ref{sec:colour} contains analysis of the Glauber dynamics for\nhypergraph colouring. Finally, Section~\\ref{sec:hardcol} contains the\nhardness results for counting colourings in hypergraphs.\n\n\\subsection{Intuition}\\label{sec:intuit}\nLet $\\CH=(\\CV,\\CE)$ be a hypergraph of maximum degree $\\Delta$ and minimum\nedge size $m$. A subset $S\\subseteq \\CV$ of the vertices is\n\\emph{independent} if no edge is a subset of $S$. Let $\\Omega(\\CH)$ be the\nset of all independent sets of $\\CH$. Let $\\lambda$ be the \\emph{fugacity},\nwhich weights independent sets. (See~\\cite{DG00a}.) The most important case\nis $\\lambda=1$, which weights all independent sets equally and gives rise\nto the uniform distribution on all independent sets. We define the Markov\nchain $\\M(\\CH)$ with state space $\\Omega(\\CH)$ by the following transition\nprocess (\\emph{Glauber dynamics}). If the state of $\\M$ at time $t$ is\n$X_t$, the state at $t+1$ is determined by the following procedure.\n\\begin{enumerate}\n\\item Select a vertex $v\\in \\CV$ uniformly at random, \\item\n\\begin{enumerate}\n    \\item if $v\\in X_t$ let $X_{t+1}=X_t\\backslash \\{v\\}$ with probability\n    $1/(1+\\lambda)$,\n    \\item if $v\\not\\in X_t$ and $X_t \\cup \\{v\\} $ is independent, let\n    $X_{t+1}=X_t\\cup \\{v\\}$ with probability $\\lambda/(1+\\lambda)$,\n    \\item otherwise let $X_{t+1}=X_t$.\n\\end{enumerate}\n\\end{enumerate}\nThis chain is easily shown to be ergodic with stationary probability\nproportional to $\\lambda^{|I|}$ for each independent set $I\\subseteq \\CV$.\nIn particular, $\\lambda=1$ gives the uniform distribution. The natural\ncoupling for this chain is the ``identity'' coupling, the same transition\nis attempted in both copies of the chain. If we try to apply standard path\ncoupling to this chain, we immediately run into difficulties. Consider two\nchains $X_t$ and $Y_t$ such that $Y_t=X_t\\cup\\set{w}$, where $w\\notin X_t$\n(the \\emph{change vertex}) is of degree $\\Delta$. An edge $e\\in\\CE$ is\n\\emph{critical} in $Y_t$ if it has only one vertex $z\\in\\CV$ which is not\nin $Y_t$, and we call $z$ \\emph{critical for $e$}. If each of the edges\nthrough $w$ is critical for $Y_t$, then there are $\\Delta$ choices of $v$\nin the transition which can be added in $X_t$ but not in $Y_t$. Thus, if\n$\\lambda=1$, the change in the expected Hamming distance between $X_t$ and\n$Y_t$ after one step could be as high as $\\frac{\\Delta}{2n}-\\frac1n$. Thus\nwe obtain rapid mixing only in the case $\\Delta=2$. This case has some\nintrinsic interest, since the complement of an independent set corresponds,\nunder hypergraph duality, to an \\emph{edge cover}~\\cite{GJ79} in a graph.\nThus we may uniformly generate edge covers, but the scope for unmodified\npath coupling is obviously severely limited.\n\nThe insight on which this paper is based is as follows. Although in one\nstep it could be more likely that a \\emph{bad vertex} (increasing Hamming\ndistance) is chosen than a \\emph{good vertex} (decreasing Hamming\ndistance), it is even more likely that one of the other vertices in an edge\ncontaining $w$ is chosen and removed from the independent set. Once the\nedge has two unoccupied vertices other than $w$, then any vertex in that\nedge can be added in both chains. This observation enables us to show that,\nif $T$ is defined to be the stopping time at which the distance between\n$X_t$ and $Y_t$ first changes, the expected distance between $X_T$ and\n$Y_T$ will be less than 1. Theorem~\\ref{stopping} below shows that under\nthese circumstances path coupling can easily be adapted to prove rapid\nmixing.\n\nHaving established this general result, we use it to prove that $\\M(\\CH)$\nis rapidly mixing for hypergraphs with $m\\geq 2\\lambda\\Delta+1$. Note that,\nthough all the results in this paper will be proved for uniform hypergraphs\nof edge size $m$, they carry through trivially for hypergraphs of minimum\nedge size $m$.\n\n\\section{Path coupling using a stopping time}\\label{sec:stopping}\n\nFirst we prove the main result discussed above.\n\n\\begin{thm}\\label{stopping}\nLet $\\M$ be a Markov chain on state space $\\Omega$. Let $\\mathrm{d}$ be an integer\nvalued metric on $\\Omega\\times \\Omega$, and let $(X_t,Y_t)$ be a\npath coupling for $\\M$, where $S$ is the set of pairs of states $(X,Y)$ such that $\\mathrm{d}(X,Y)=1$.\nFor any initial states $(X_0,Y_0)\\in S$ \nlet $T$ be the stopping time given by the minimum $t$ such that\n$\\mathrm{d}(X_t,Y_t)\\neq1$. Suppose, for some $p>0$, that\n\\begin{enumerate}\n\\item $\\Pr(T=t\\, |\\, T\\geq t)\\geq p$, independently for each $t$,%\n\\item $\\e[\\mathrm{d}(X_T,Y_T)]\\leq \\alpha < 1$.\n\\end{enumerate}\nThen $\\M$ mixes rapidly. In particular the mixing time\n$\\tau(\\eps)$ of $\\M$ satisfies\n\\[\\tau(\\eps)\\ \\leq\\\n\\frac{1}{p}\\,\\frac{3}{1-\\alpha} \\ln (e\nD_2)\\ln\\Big(\\frac{2D_1}{\\eps(1-\\alpha)}\\Big),\\]%\nwhere $D_1=\\max\\{\\mathrm{d}(X,Y):X,Y\\in\\Omega\\}$ and\n$D_2=\\max\\{\\mathrm{d}(X_T,Y_T):X_0,Y_0\\in\\Omega,\\,\n\\mathrm{d}(X_0,Y_0)=1\\}$.\n\\end{thm}\n\n\\begin{proof}\nConsider the following game. In each round a gambler either wins \\pounds$\n1$, loses some amount \\pounds$(l-1)$ or continues to the next round. If he\nloses \\pounds$(l-1)$ in a game, he starts $l$ separate (but possibly\ndependent) games simultaneously in an effort to win back his money. If he\nhas several games going and loses one at a certain time, he starts $l$ more\ngames, while continuing with the others that did not conclude. We know that\nthe probability he finishes a game in a given step is at least $p$, and the\nexpected winnings in each game is at most $1-\\alpha$. The question is: does\nhis return have positive expectation at any fixed time\\,? We will show that\nit does. But first a justification for our interest in this game.\n\nEach game represents a single step on the path between two states\nof the coupled Markov chain. We start with $X_0$ and $Y_0$\ndiffering at a single vertex. The first game is won if the first\ntime the distance between the coupled chains changes is in\nconvergence. The game is lost if the distance increases to $l$. At\nthat point we consider the distance $l$ path $X_t$ to $Y_t$, and\nthe $l$ games played represent the $l$ steps in the path. Although\nthese games are clearly dependent, they each satisfy the\nconditions given. The gambler's return at time $t$ is one minus the\nlength of the path at time $t$, so a positive expected return\ncorresponds to an expected path length less than one. We will show that the expected path length is sufficiently small to ensure coupling.\n\nFirst note that the gambler's return at time $t$ is one minus the\nnumber of games active at time $t$. For the initial game we define\nthe \\emph{level} to be zero, for any other possible game we define\nthe level to be one greater than the level of the game whose loss\nprecipitated it. We define the random variables $M_k, l_{jk}$ and\n$I_{jk(t)}$ as follows. $M_k$ is the number of games at level $k$\nthat are played, $l_{jk},$ for $j=1\\ldots M_k$, is the number of\ngames in level $k+1$ which are started as a result of the outcome\nof game $j$ in level $k$, and $I_{jk}(t)$ is an indicator function\nwhich takes the value 1 if game $j$ in level $k$ is active at time\n$t$, and 0 otherwise. Let $N(t)$ be the number of games active at\ntime $t$. Then, by linearity of expectations,\n\\begin{equation}\n\\label{expsum} \\e[N(t)]=\\sum_{k=0}^\\infty \\e \\left[ \\sum_{j=1}^{M_k}\nI_{jk}(t)\\right].\n\\end{equation}\n\nWe will bound this sum in two parts, splitting it at a point $k=K$\nto be determined. For $k\\leq K$ we observe that $M_k\\leq D_2^k$.\nSince $\\Pr (I_{jk}(t)=1)$ is at most the probability that exactly\n$k-1$ games of a sequence are complete at time $t$, regardless of\noutcome, we have\n\\begin{align*}\n\\e \\left[ \\sum_{j=1}^{M_k} I_{jk}(t)\\right]\\ \\leq\\ D_2^k \\max_j\n\\e[I_{jk}(t)]\\ \\leq\\ D_2^k \\Pr(\\textrm{exactly $k-1$ games complete by time\n$t$}).\n\\end{align*}\nSo that\n\\begin{align}\n\\sum_{k=0}^K \\e \\left[ \\sum_{j=1}^{M_k} I_{jk}(t)\\right]&\\leq\\\n\\sum_{k=0}^K D_2^k \\Pr(\\textrm{exactly $k-1$ games complete by time $t$})\\notag \\\\\n&\\leq\\ {D_2}^K\\Pr(\\textrm{at most $K$ games complete by $t$}).\\label{front}\n\\end{align}\nOn the other hand, for $k>K$ we observe that\n\\begin{align*}\n\\e \\bigg[ \\sum_{j=1}^{M_k} I_{jk}(t)\\bigg]&\\leq\\ \\e[M_k]\\ =\\\n\\e_{M_{k-1}}\\big[\\e[M_k|M_{k-1}]\\big]\\ =\\\n\\e_{M_{k-1}}\\big[\\e[\\sum_{j=1}^{M_{k-1}}l_{jk-1}|M_{k-1}]\\big]\n\\end{align*}\nSince $\\e[l_{jk-1}]\\leq\\alpha$ for any starting conditions, we may\napply this bound even when conditioning on $M_{k-1}$. So\n\\begin{align}\n\\e \\left[ \\sum_{j=1}^{M_k} I_{jk}(t)\\right]\n%&\\leq\\ \\e[\\e[\\sum_{j=1}^{M_{k-1}}l_{jk-1}|M_{k-1}]]\\notag \\\\\n%&\\leq\\ \\e[\\e[\\sum_{j=1}^{M_{k-1}}\\alpha|M_{k-1}]]\\notag \\\\\n\\ \\leq\\ \\e[\\alpha M_{k-1}]\\ \\leq\\ \\alpha^k,\\label{tail}\n\\end{align}\nusing linearity of expectation, induction and $\\e[M_1]\\leq\\alpha$. Putting\n\\eqref{front} and \\eqref{tail} together we get\n\\begin{align} \\e[N(t)]&\\leq\\ {D_2}^K\\Pr(\\textrm{at most $K$ games complete by $t$})\n\\ +\\ \\sum_{k=K+1}^\\infty \\alpha^k\\notag \\\\\n&=\\ {D_2}^K\\Pr(\\textrm{at most $K$ games complete by $t$}) \\ +\\\n\\frac{\\alpha^{K+1}}{1-\\alpha}.\n\\end{align}\n\nWe now set $K =\\lfloor(\\ln \\alpha)^{-1}\\ln\n(\\frac{\\eps(1-\\alpha)}{2D_1})\\rfloor$, hence the final term is at most\n$\\eps/2D_1$. The probability that a game completes in any given step is at\nleast $p$. If we select a time $\\tau \\geq c/p$ for $c \\geq\nK+1\\geq 1$, then the probability that at most $K$ games are complete is\nclearly maximised by taking this probability to be exactly $p$ in all\ngames. Hence, by Chernoff's bound (see, for example,~\\cite[Theorem\n2.1]{JLR00}),\n\\begin{align*}\n\\e[N(\\tau)]&\\leq\\ {D_2}^K\\sum_{k=0}^{K}\n\\binom{\\tau}{k}p^k(1-p)^{\\tau-k}+\\frac{\\eps}{2D_1} \\\\\n&\\leq\\ e^{K\\ln D_2-\\frac{(c-K)^2}{2c}}+\\frac{\\eps}{2D_1} \\\\\n&\\leq\\ e^{K\\ln D_2+K-c/2}+\\frac{\\eps}{2D_1}.\n\\end{align*}\nChoosing $c=2K\\ln(eD_2) +2\\ln \\frac{2D_1}{\\eps}$, we obtain $ \\e[N(\\tau)] <\n\\frac{\\eps}{D_1} $, where $ \\tau =\\big\\lceil\n\\frac{3\\ln(eD_2)}{p(1-\\alpha)}\\ln\\big(\\frac{2D_1}{\\eps(1-\\alpha)}\\big)\\big\\rceil$.\n%\\[ \\tau\\leq \\frac{2}{p}\\ln\\frac{2D_1}{\\eps(1-\\alpha)}\\left(\\frac{\\ln(eD_2)}{|\\ln  \\alpha|}+1 \\right)+1 < \\frac{3\\ln(D_2)}{p(1-\\alpha)}\\ln\\frac{(2D_1)}{\\eps(1-\\alpha)}.\\]\n\nWe conclude that the gambler's expected return at time $\\tau$ is positive.\nMore importantly, for any initial states $X_0,Y_0\\in \\Omega$, the expected\ndistance at time $\\tau$ is at most $\\eps$ by linearity of expectations, and\nso the probability that the chain has not coupled is at most $\\eps$. The\nmixing time claimed now follows by standard arguments. See, for\nexample,~\\cite{J03}.\n\\end{proof}\n\n\\begin{rem}\\label{rem15}\nThe assumption that the stopping time occurs when the distance changes is\nnot essential. We clearly cannot dispense with assumption~(ii), or we\ncannot bound mixing time. Assumption~(i) may appear a restriction, but\nappears to be naturally satisfied in most applications. It seems more\nnatural than the assumption of bounded stopping time, used in~\\cite{HV04}.\nAssumption~(i) can easily be replaced by something weaker, for\nexample by allowing $p$ to vary with time rather than remain constant.\nProvided $p\\neq 0$ sufficiently often, a similar proof will be valid.\n\\end{rem}\n\n\\begin{rem}\\label{rem20}\nLet $\\gamma=1/(1-\\alpha)$. It seems likely that $D_2$ will be small in\ncomparison to $\\gamma$ in most applications, so we might suppose $D_2 <\n\\gamma < D_1$. The mixing time bound from Theorem~\\ref{stopping} can then\nbe written $O(p^{-1}\\gamma\\log D_2 \\log(D_1/\\eps) )$. We may compare this\nwith the bound which can be derived using~\\cite[Corollary~4]{HV04}. This\ncan be written in similar form as $O(p^{-1}\\gamma \\log\\gamma\\log( D_1/\\eps)\n)$. In such cases we obtain a reduction in the estimate of mixing time by a\nfactor $\\log\\gamma/\\log D_2$. In the applications below, for example, we\nhave $D_2=2$ and $\\gamma=\\Omega(\\Delta)$, so the improvement is\n$\\Omega(\\log \\Delta)$.\n\\end{rem}\n\n\\begin{rem}\nThe reason for our improvement on the result of~\\cite{HV04} is that the\nuse of an upper bound on the stopping time, as is done in~\\cite{HV04},\nwill usually underestimate the number of stopping times which occur\nin a long interval, and hence the mixing rate.\n\\end{rem}\n\n\\section{Hypergraph independent sets}\\label{sec:indsets}\n\nWe now use the approach of path coupling via stopping times to prove that\nthe chain discussed in Section~\\ref{sec:intuit} is rapidly mixing. The\nmetric used in path coupling analyses throughout the paper will be Hamming\ndistance between the coupled chains. We prove the following theorem.\n\n\\begin{thm}\\label{indsets}\nLet $\\lambda,\\Delta$ be fixed, and let $\\CH$ be a hypergraph such that\n$m\\geq 2\\lambda\\Delta+1$. Then the Markov chain $\\M(\\CH)$ has mixing time\n$O(n\\log n)$.\n\\end{thm}\nBefore commencing the proof itself, we analyse the stopping time\n$T$ for this problem.\n\n\n\\subsection{Edge Process}\\label{edge}\nLet $X_t$ and $Y_t$ be copies of $\\M$ which we wish to couple, with\n$Y_0=X_0\\cup\\set{w}$. Let $e$ be any edge containing $w$, with $m=|e|$. We\nconsider only the times at which some vertex in $e$ is chosen. The progress\nof the coupling on $e$ can then be modelled by the following ``game''. We\nwill call the number of unoccupied vertices in $e$ (excluding $w$)\n\\emph{units}. At a typical step of the game we have $k$ units, and we\neither win the game, win a unit, keep the same state or lose a unit. These\nevents happen with the following probabilities: we win the game with\nprobability $1/m$, win a unit with probability at least\n$(m-k-1)/(1+\\lambda)m$, lose a unit with probability at most $\\lambda\nk/(1+\\lambda)m$ and stay in the same state otherwise. If ever $k=0$, we are\nbankrupt and we lose the game. Winning the game models the ``good event''\nthat the vertex $v$ is chosen and the two chains couple. Losing the game\nmodels the ``bad event'' that the coupling increases the distance to 2. We\nwish to know the probability that the game ends in bankruptcy. We are most\ninterested in the case where $k=1$ initially, which models $e$ being\ncritical. Note that the value of $k$ in the process on hypergraph\nindependent sets dominates the value in our model, since we can always\ndelete (win in the game), but we may not be able to insert (lose in the\ngame) because the chosen vertex is critical in some other edge.\n\nLet $p_k$ denote the probability that a game is lost, given that\nwe start with $k$ units. We have the following system of\nsimultaneous equations.\n\\begin{align}\\label{p-eq1}\n    (m-1+2\\lambda)p_1 - (m-2)p_2\\ &=\\ \\lambda& \\notag\\\\\n   -k\\lambda p_{k-1}+(m-k+(k+1)\\lambda)p_k-(m-k-1)p_{k+1}\\ &=\\ 0& (k=2,3,\\ldots,m-1)\n\\end{align}\nAdding the equations in~(\\ref{p-eq1}) from the $k^\\textrm{th}$ onwards\ngives\n\\begin{align}\\label{p-eq2}\n    (m-1)p_1 + m\\lambda p_{m-1}\\ &=\\ \\lambda& \\notag\\\\\n   -k\\lambda p_{k-1}+(m-k)p_k+ m\\lambda p_{m-1}\\ &=\\ 0& (k=2,3,\\ldots,m-1).\n\\end{align}\nNow~(\\ref{p-eq2}) is equivalent to~(\\ref{p-eq1}), since we have\nsimply multiplied the coefficient matrix of~(\\ref{p-eq1}) by an\nupper triangular matrix with all entries 1. This transformation is\nclearly nonsingular. We will show by induction that~(\\ref{p-eq2}) has solution%\n\\begin{equation}\\label{p-eq3}\n    p_k=\\frac{\\lambda^k-\\sum_{i=1}^k \\binom{m}{i}p_{m-1}\\lambda^{k-i+1}}{\\binom{m-1}{k}}\n\\qquad(k=1,2,\\ldots,m-1).\n\\end{equation}%\nWhen $k=1$, the first equation in~(\\ref{p-eq2}) is clearly\nsatisfied by~(\\ref{p-eq3}).  Assume by induction\nthat~(\\ref{p-eq3}) is true for $p_{k-1}$, with $k\\geq 2$. Then\n\n\\begin{align*}\n    p_k\\ &=\\ \\frac{\\lambda k}{m-k}\\, p_{k-1}-\\frac{\\lambda m}{m-k}\\,p_{m-1}\\\\\n    &=\\ \\frac{\\lambda k}{m-k}\\, \\frac{\\lambda^{k-1}-\\sum_{i=1}^{k-1}\n    \\binom{m}{i}\\lambda^{k-i}p_{m-1}}{\\binom{m-1}{k-1}}-\\frac{\\lambda m}{m-k}\\,p_{m-1}\\\\\n    &=\\ \\frac{\\lambda^k-\\sum_{i=1}^{k-1} \\binom{m}{i}\\lambda^{k-i+1}p_{m-1}}{\\binom{m-1}{k}}\n    - \\frac{\\binom{m}{k}}{\\binom{m-1}{k}}\\,\\lambda p_{m-1}\\\\\n    &=\\ \\frac{\\lambda^k-\\sum_{i=1}^{k} \\binom{m}{i}\\lambda^{k-i+1}p_{m-1}}{\\binom{m-1}{k}},\n\\end{align*}\ncontinuing the induction. For consistency, we must clearly have\n\\begin{align}\n    p_{m-1}\\ &=\\ \\frac{\\lambda^{m-1}-\\sum_{i=1}^{m-1}\n    \\binom{m}{i}\\lambda^{m-i}p_{m-1}}{\\binom{m-1}{m-1}}\n    \\ =\\ \\lambda^{m-1}-\\big((1+\\lambda)^m-1-\\lambda^m\\big)p_{m-1},\\notag\\\\\n    \\textrm{i.e.}\\quad p_{m-1}\\ &=\\ \\frac{\\lambda^{m-1}}{(1+\\lambda)^m-\\lambda^m}.\\label{p-eq4}\n\\end{align}%\nUsing (\\ref{p-eq4}),~(\\ref{p-eq3}) can be rewritten\n\\begin{equation}\\label{p-eq5}\n    p_k\\ =\\ \\frac{1}{\\binom{m-1}{k}}\\bigg(\\lambda^k-\\frac{\\sum_{i=1}^k\n    \\binom{m}{i}\\lambda^{m+k-i}}{(1+\\lambda)^m-\\lambda^m}\\bigg)\n    = \\frac{\\sum_{i=k+1}^m \\binom{m}{i}\\lambda^{m+k-i}}\n    {\\big((1+\\lambda)^m-\\lambda^m\\big)\\binom{m-1}{k}}\n\\qquad(k=1,2,\\ldots,m-1).\n\\end{equation}%\nIn particular\n\\begin{equation}\\label{p-eq6}\np_1= \\frac{\\lambda}{m-1}\\left(1-\\frac{m\\lambda^{m-1}}\n{(1+\\lambda)^m-\\lambda^m}\\right).\n\\end{equation}\n\n\\subsection{The expected distance between $X_T$ and $Y_T$}\nThe stopping time for the pair of chains $X_t$ and $Y_t$ will be when the\ndistance between them changes, in other words either a good or bad event\noccurs. The probability that we observe the bad event on a particular edge\n$e$ with $w\\in e$ is at most $p_k$ as calculated above. Let $\\xi_t$ denote\nthe number of empty vertices in $e$ at time $t$ when the process is started\nwith $\\xi_0=k$. Now $\\xi_t$ can never reach 0 without first reaching $k-1$\nand, since the process is Markovian, it follows that\n\\[p_k= \\Pr(\\exists t\\, \\xi_t=0 | \\xi_0=k)\n= \\Pr(\\exists t\\,\\xi_t=0 | \\xi_{s}=k-1)\\Pr(\\exists s\\,\\xi_{s}=k-1 | \\xi_{0}=k)\n< p_{k-1}.\\]%\nSince $w$ is in at most $\\Delta$ edges, the probability that we observe the\nbad event on any edge is at most $\\Delta p_1$. The probability that the\nstopping time ends with the good event is therefore at least $1-\\Delta\np_1$.  The path coupling\ncalculation is then%\n\\[\\e[\\mathrm{d}(X_T,Y_T)]\\leq 2\\Delta p_1.\\]\nThis is required to be less than 1 in ordered to apply\nTheorem~\\ref{stopping}. If $m \\geq 2\\lambda\\Delta+1$, then by~(\\ref{p-eq6})\n\\[2\\Delta p_1=1-\\frac{(2\\lambda\\Delta+1)\\lambda^{2\\lambda\\Delta}}\n{(1+\\lambda)^{2\\lambda\\Delta+1}-\\lambda^{2\\lambda\\Delta+1}}.\\]\n\n\\begin{proof}[Proof of Theorem~\\ref{indsets}]\nThe above work puts us in a position to apply\nTheorem~\\ref{stopping}. Let $m\\geq 2\\lambda\\Delta+1$. Then for\n$\\M(\\CH)$ we have\n\\begin{enumerate}\n\\item $\\Pr(\\mathrm{d}(X_t,Y_t)\\neq1| \\mathrm{d}(X_{t-1},Y_{t-1})=1)\\geq\n\\frac{1}{n}$ for all $t$, and \\item $\\e[\\mathrm{d}(X_T,Y_T)]\\ <\\ 1\\, -\\,\n\\dfrac{(2\\lambda\\Delta+1)\\lambda^{2\\lambda\\Delta}}\n{(1+\\lambda)^{2\\lambda\\Delta+1}-\\lambda^{2\\lambda\\Delta+1}}.$\n\\end{enumerate}\nAlso for $\\M(\\CH)$ we have $D_1=n$ and $D_2=2$. Hence by\nTheorem~\\ref{stopping}, $\\M(\\CH)$ mixes in time\n \\[\\tau(\\eps)\\leq\n6n \\frac{(1+\\lambda)^{2\\lambda\\Delta+1}-\\lambda^{2\\lambda\\Delta+1}}\n{(2\\lambda\\Delta+1)\\lambda^{2\\lambda\\Delta}}\\ln\\Big(n\\eps^{-1}\\frac{(1+\\lambda)^{2\\lambda\\Delta+1}-\\lambda^{2\\lambda\\Delta+1}}\n{(2\\lambda\\Delta+1)\\lambda^{2\\lambda\\Delta}}\\Big).\\]\n\nThis is $O(n\\log n)$ for fixed $\\lambda,\\Delta$.\n\\end{proof}\n\\begin{rem}\nIn the most important case, $\\lambda=1$, we require $m\\geq\n2\\Delta+1$. This does not include the case $m=3$, $\\Delta=3$\nconsidered in~\\cite{DG00a}. We have attempted to improve the bound by employing the chain proposed by\nDyer and Greenhill in~\\cite[Section~4]{DG00a}. However, this gives only a\nmarginal improvement. For large $\\lambda\\Delta$, we obtain convergence for\n$m \\geq 2\\lambda\\Delta+\\tfrac{1}{2}+o(1)$. For $\\lambda=1$, this gives a\nbetter bound on mixing time for $m=2\\Delta+1$, with dependence on $\\Delta$\nsimilar to Remark~\\ref{rem05} below, but does not even achieve mixing for\n$m=2\\Delta$.\nWe omit the details in\norder to deal with the Glauber dynamics, and to simplify the\nanalysis.\n\\end{rem}\n\\begin{rem}\\label{rem05}\nThe terms in the running time which are exponential in\n$\\lambda,\\Delta$ would disappear if we instead took graphs for which\n$m\\geq 2\\lambda\\Delta+2$. In this case the running time would be\n\\[\\tau(\\eps)\\leq\n 6(2\\lambda\\Delta+1) n \\ln(n\\eps^{-1}(2\\lambda\\Delta+1))\\leq  12(2\\lambda\\Delta+1) n \\ln(n\\eps^{-1}).\\]\nFurthermore, if we took graphs such that\n$m>(2+\\delta)\\lambda\\Delta$, for some $\\delta>0$, then the running\ntime would no longer depend on $\\lambda,\\Delta$ at all, but would be\n$\\tau(\\eps)\\leq c_\\delta n \\ln (n\\eps^{-1})$ for some constant\n$c_\\delta$.\n\\end{rem}\n\\begin{rem}\\label{rem10}\nIt seems that path coupling cannot show anything better than $m$ linear in\n$\\lambda\\Delta$. Suppose the initial configuration has edges\n$\\{w,v_1,\\ldots,v_{m-2},x_i\\}$ for $i=1,\\ldots,\\Delta$, with\n$w,v_1,\\ldots,v_{m-2}\\in X_0$, $x_1,\\ldots,x_\\Delta\\not\\in X_0$ and $w$ the\nchange vertex. Consider the first step where any vertex changes state. Let\n$\\mu=(1+\\lambda)(m-1+\\Delta)$. The good event occurs with probability\n$(1+\\lambda)/\\mu$, insertion of a critical vertex with probability\n$\\lambda\\Delta/\\mu$, and deletion of a non-critical vertex with probability\n$(m-1)/\\mu$. We therefore need $(m-1)+(1+\\lambda)\\geq\\lambda\\Delta$, i.e.\n$m\\geq \\lambda(\\Delta-1)$, to show convergence by path coupling.\n\\end{rem}\n\\begin{rem}\nIt seems we could improve our bound $m\\geq 2\\lambda\\Delta+1$ for rapid\nmixing of the Glauber dynamics somewhat if we could analyse the process on\nall edges simultaneously. Examination of the extreme cases, where all edges\nadjacent to $w$ are otherwise independent, or where they are dependent\nexcept for one vertex (as in Remark~\\ref{rem10}), suggests that improvement\nto $(1+o(1))\\lambda\\Delta$ may be possible, where the $o(1)$ is relative to\n$\\lambda\\Delta$. However, the analysis in the general case seems difficult,\nsince edges can intersect arbitrarily.\n\\end{rem}\n\n% ----------------------------------------------------------------\n\\hide{%\n\\subsection{The Dyer-Greenhill chain}\n\nWe now consider the following chain, originally given in~\\cite{DG00a}.\n\\begin{enumerate}\n\\item choose $v\\in \\CV$ uniformly at random,%\n\\item\n\\begin{enumerate}\n      \\item if $v\\in X_t$  then let $X_{t+1}=X_t\\setminus\\set{v}$ with\n            probability $1/(1+\\lambda)$,\n      \\item if $v\\not\\in X_t$ and $v$ is not critical for any edge,\n            let $X_{t+1}=X_t\\cup\\set{v}$ with probability\n            $\\lambda/(1+\\lambda)$,\n      \\item if $v\\not\\in X_t$ and $v$ is critical in $X_t$ for a \\emph{unique}\n            edge $e$, choose $u\\in e\\setminus\\set{v}$ uniformly at random\n            and let $X_{t+1}= (X_t\\setminus\\set{u})\\cup\\set{v}$\n            with probability $(m-1)\\lambda/2m(1+\\lambda)$,\\label{extra}\n      \\item otherwise let $X_{t+1}=X_t$.\n\\end{enumerate}\n\\end{enumerate}\nObserve that this chain is identical to the Glauber dynamics except for the\nadditional \\emph{swap move}~\\ref{extra}. Consider the effect of this on the\nprocess of Section~\\ref{edge} on the edge $e$. The swap move may be viewed\nas an attempt to insert the critical vertex $v$. In the process we assume\nthat $v$ can always be inserted, so the bound remains valid if $v$ is not\ncritical for $e$. But the process ends when we (attempt to) insert a vertex\nwhich is critical for $e$, and the probability this occurs is at most\n$p_1$. Thus we need only analyse the event that we wish to insert $v$, it\nis critical for $e$ in $Y$, and it can be inserted in $X$.\n\\begin{enumerate}\n    \\item[(1)] If $v$ is not critical in $Y$ for any edge other than $e$,\n    we insert it in $X$, increasing Hamming distance by 1. We couple\n    this in $Y$ with the swap move. We will \\emph{decrease} Hamming\n    distance by 1 with probability $1/2m$, since we choose  $u=w$\n    in~\\ref{extra} with probability $1/(m-1)$.\n    \\item[(2)] If $v$ is not critical in $Y$ for exactly one edge other than\n    $e$, we will swap in $X$ and do nothing in $Y$ with probability $(m-1)/2m$,\n    increasing Hamming distance by 2.\n\\end{enumerate}\nIn case~(1), the expected increase in Hamming distance is\n$1\\times(1-1/2m)-1\\times 1/2m = (m-1)/m$. In case~(2), expected increase is\n$2\\times(m-1)/2m = (m-1)/m$. Thus, at the stopping time, we have the\nfollowing bound on the expected increase in Hamming distance.%\n\\[-(1-\\Delta p_1)+\\Delta p_1 \\frac{m-1}{m} = -1 + \\Delta p_1\n\\frac{2m-1}{m} = -1 +\n\\frac{(2m-1)\\lambda\\Delta}{m(m-1)}\\left(1-\\frac{m\\lambda^{m-1}}\n{(1+\\lambda)^m-\\lambda^m}\\right),\\]%\nwhich is only a marginal improvement. For large $\\lambda\\Delta$, we obtain\nconvergence for $m \\geq 2\\lambda\\Delta+\\tfrac{1}{2}+o(1)$. For $\\lambda=1$,\nthis gives a better bound on mixing time for $m=2\\Delta+1$, with dependence\non $\\Delta$ similar to Remark~\\ref{rem05}, but does not even achieve mixing\nfor $m=2\\Delta$.%\n}\n% ----------------------------------------------------------------\n\\section{Hardness results for independent sets}\\label{sec:hard}\nWe have established that  the number of independent sets of a hypergraph\ncan be approximated efficiently using the Markov Chain Monte Carlo\ntechnique for hypergraphs with edge size linear in $\\Delta$. We show next\nthat exact counting is unlikely to be possible, and that our approximation\nscheme cannot be extended to cover all hypergraphs with edge size\n$\\Omega(\\log\\Delta)$.\n\n\\subsection{\\#P-completeness}\\label{sec:hardnump}\nWe show that the exact counting problem is \\#P-Complete except in trivial\ncases.\n\\begin{thm}\\label{h-thm10}\nLet $\\CG(m,\\Delta)$ be the class of uniform hypergraphs with minimum edge\nsize $m\\geq 3$ and maximum degree $\\Delta$. Computing the number of independent\nsets of hypergraphs in $\\CG(m,\\Delta)$ is \\#P-complete if $\\Delta \\geq 2$.\nIf $\\Delta \\leq 1$, it is in P.\n\\end{thm}\n\\begin{proof}\nSince $m$ is the minimum edge size, we will assume $m\\geq 3$. The cases\n$\\Delta=0,1$ are trivially in P. As discussed in Section~\\ref{sec:intuit},\nindependent sets in a hypergraph with $\\Delta=2$ correspond to edge covers\nin a graph. Counting these is \\#P-complete, even for graphs with\narbitrarily large minimum degree. This is stated in~\\cite{BD97} but without\nproof, so we provide a proof in Appendix~\\ref{app1}. We now consider\n$\\Delta \\geq 3$. (The case $m=\\Delta=3$ is discussed in~\\cite{DG00a}.) Take\na graph $G=(V,E)$, and construct a hypergraph $\\CG=(\\CV,\\CE)$ by\n``extending'' each edge $e=\\set{v_1,v_2}\\in E$ to an edge\n$e^+=\\set{v_1,u^e_1,\\ldots, u^e_{m-2},v_2}\\in \\CE$. Observe that, for each\nindependent set $I$ of $G$ and edge $e\\in E$, there are $2^{m-2}-1$\nindependent assignments to $u^e_1,\\ldots, u^e_{m-2}$ if $v_1,v_2\\in I$ and\n$2^{m-2}$ otherwise. This is equivalent to evaluating the partition\nfunction of a \\emph{weighted $H$-colouring} problem~\\cite{BG04,DG00b} on\n$G$, with weight matrix\n\\[ A=\\begin{bmatrix} 2^{m-2} & 2^{m-2}\\\\ 2^{m-2} & 2^{m-2}-1 \\end{bmatrix}.\\]\nThe \\#P-completeness of $H$-colouring with this weight matrix follows\neither directly from \\cite{BG04} or indirectly from \\cite[Corollary\n3.2]{DG00b}. The degree bound $\\Delta=3$ follows from \\cite[Theorem\n5.1]{DG00b}, on noting that $A$ is nonsingular.\n\\end{proof}\n\\subsection{Approximation hardness}\nWe now show that unless NP\\/=\\/RP, there can be no \\emph{fpras}\nfor the number of independent sets of all hypergraphs with edge size\n$\\Omega(\\log\\Delta)$.\n\nLet $G=(V,E)$, with $|V|=n$, be a graph with maximum degree\n$\\Delta$ and $N_i$ independent sets of size $i$\n($i=0,2,\\ldots,n$). For $\\lambda>0$ let $Z_G(\\lambda)=\\sum_{i=0}^n\nN_i \\lambda^i$ define the \\emph{hard core partition function}. The\nfollowing is a combination of results in Luby and\nVigoda~\\cite{LV99} and Berman and Karpinski~\\cite{BK03}.\n\\begin{thm}\\label{h-thm20}\nIf $\\lambda > 694/\\Delta$, there is no \\emph{fpras} for\n$Z_G(\\lambda)$ unless NP\\/=\\/RP.\n\\end{thm}\n\\begin{proof}\nLet $\\eps$ be a constant such that the size of the largest\nindependent set in a graph of maximum degree 4 cannot be\napproximated to within a ratio $(1+\\eps)$ unless P\\,=\\,NP. Berman\nand Karpinski~\\cite{BK03} show that $\\eps\\geq 1/49$. Luby and\nVigoda~\\cite[Theorem~4]{LV99} prove the hardness of approximating\n$Z_G(\\lambda)$ if $\\lambda > c/\\Delta$ for any $c > 20\\ln\n2\\,(1+\\eps)/\\eps$.\\footnote{The expression in~\\cite{LV99} omits\nthe $\\ln 2$ term} Together, these two results give the theorem.\n\\end{proof}\nWe note that Theorem~\\ref{h-thm20} could probably be strengthened using the\napproach of~\\cite{DFJ99}. However, this has yet to be done.\n\\begin{thm}\\label{h-thm30}\nUnless NP\\/=\\/RP, there is no \\emph{fpras} for counting\nindependent sets in hypergraphs with maximum degree $\\Delta$ and\nminimum edge size $m< 2\\lg(1+\\Delta/694)-1=\\Omega(\\log\\Delta)$.\n\\end{thm}\n\\begin{proof}\nGiven a graph $G=(V,E)$ with maximum degree $\\Delta$, we construct\na hypergraph $\\CH=(\\CV,\\CE)$ as follows. Let $k=\\lceil m/2\\rceil$.\nFor each $v\\in V$, let $W_v=\\set{w_{v1},w_{v2},\\ldots,w_{vk}}$ and\n$\\CV=\\bigcup_{v\\in V} W_v$. For each edge $e=\\set{u,v}\\in E$, let\n$S_e=W_u\\cup W_v$, and let $\\CE=\\set{S_e:e\\in E}$. It is clear\nthat $\\CH$ has maximum vertex degree $\\Delta$ and every edge has\nsize $2k\\geq m$.\n\nAn independent set $\\CI$ in $\\CH$ corresponds to a unique\nindependent set $I$ in $G$ as follows. If $S_v\\subseteq \\CI$, then\n$v\\in I$, otherwise $v\\notin I$. Clearly $\\CI$ independent in\n$\\CH$ implies $I$ independent in $G$. Note that for each $v\\notin\nI$, there are $(2^k-1)$ possible subsets of $S_v$ which may be in\n$\\CI$. Thus, if $\\CN$ is the number of independent sets in $\\CH$,\n\\begin{equation*}%\\label{h-eq1}\n    \\CN=\\sum_{i=0}^n N_i(2^k-1)^{n-i}= (2^k-1)^n \\sum_{i=0}^n N_i(2^k-1)^{-i}\n    =(2^k-1)^n Z_G(1/(2^k-1)).\n\\end{equation*}\nThus approximating $\\CN$ is equivalent to approximating\n$Z_G(\\lambda)$ with $\\lambda=1/(2^k-1)$. But, by\nTheorem~\\ref{h-thm20}, this will be hard if $1/(2^k-1)>694/\\Delta$.\nThis gives $k<\\lg(1+\\Delta/694)$, which holds whenever\n$m<2\\lg(1+\\Delta/694)-1$.\n\\end{proof}\n\n% ----------------------------------------------------------------\n\\section{Hypergraph colouring}\\label{sec:colour}\nWe now consider Glauber dynamics on the set of proper colourings of a\nhypergraph. Again our hypergraph $\\CH$ will have maximum degree $\\Delta$,\nminimum edge size $m$, and we will have a set of $q$ colours. A colouring\nof the vertices of $\\CH$ is proper if no edge is monochromatic. Let\n$\\Omega'(\\CH)$ be the set of all proper $q$-colourings of $\\CH$. We define\nthe Markov chain $\\C(\\CH)$ with state space $\\Omega'(\\CH)$ by the following\ntransition process. If the state of $\\C$ at time $t$ is $X_t$, the state at\n$t+1$ is determined by\n\\begin{enumerate}\n\\item selecting a vertex $v\\in \\CV$ and a colour $k\\in\\{1,2,\\ldots,q\\}$\nuniformly at random, \\item let $X'_t$ be the colouring obtained by\nrecolouring $v$\ncolour $k$ \\item if $X'_t$ is a proper colouring let $X_{t+1}=X'_t$\\\\\notherwise let $X_{t+1}=X_t$.\n\\end{enumerate}\nThis chain is easily shown to be ergodic with the uniform\nstationary distribution. Again we will use Theorem~\\ref{stopping}\nto prove rapid mixing of this chain under certain conditions,\nhowever first we will examine the chain using standard path\ncoupling techniques.\n\n\\begin{thm}\\label{colsmge4}\nFor $m\\geq 4$, $q> \\Delta$, the Markov chain $\\C(\\CH)$ mixes in time\n$O(n\\log n)$.\n\\end{thm}\n\\begin{proof}\nSuppose that two copies of $\\C(\\CH)$, $X_0$ and $Y_0$ say, start at\ndistance one apart, i.e. they differ in only one vertex $w$. Suppose that\nthe number of colours available for recolouring $w$ is $q-k$, then the\nprobability of the two copies of the chain coupling in one step is\n$\\frac{q-k}{nq}$. The distance between the two chains can only increase (to\n2) if we select a vertex $v$ and recolour it with a colour that is\npermitted in one copy of the chain only. For this to happen, there must be\nan edge containing $v$ and $w$ such that the other vertices in this edge\nare all either red and we have chosen red for $v$, or blue and we have\nchosen blue for $v$. Hence there can be at most one vertex on each edge,\nand one colour for that vertex, such that the chains diverge if we select\nthat vertex and colour. Furthermore, for each of the $k$ unavailable\ncolours there must be an edge containing $w$ which, apart from $w$ itself,\nis monochromatic in the forbidden colour, so on these edges there are no\nvertices whose selection can cause the chains to diverge. Hence the\nprobability that the distance increases to 2 in one step is at most\n$\\frac{\\Delta-k}{nq}$. The path coupling calculation is therefore\n\\[ \\e[\\mathrm{d}(X_1,Y_1)]\\leq 1-\\frac{q-k}{nq}+\\frac{\\Delta-k}{nq}.\\]\nIf $q\\geq\\Delta+1$ then $\\e[\\mathrm{d}(X_1,Y_1)]\\leq 1-1/nq$, and therefore\nby the path coupling theorem the mixing time is\n\\[ \\tau(\\eps)\\leq nq \\ln (n \\eps^{-1}).\\vspace{-\\baselineskip}\\]\n\\end{proof}\n\nThis analysis leaves little room for improvement in the case $m\\geq 4$,\nindeed it is not clear whether the Markov chain described is even ergodic\nfor $q\\leq \\Delta$. The following simple construction does show that the\nchain is not in general ergodic if $q\\leq \\frac{\\Delta}{m}+1$. Let\n$q=\\frac{\\Delta }{m }+1$, and take a hypergraph $\\CH$ on $q(m-1)$ vertices.\nWe will group the vertices into $q$ groups $\\CV=\\CV_1,\\CV_2,\\ldots,\\CV_q$,\neach of size $m-1$. Then the edge set of $\\CH$ is $E=\\{\\{v\\}\\cup \\CV_j:v\\in\n\\CV, v\\not\\in \\CV_j\\}$. The degree of each vertex is\n$(q-1)+(q-1)(m-1)=\\Delta$. If we now colour each group $\\CV_j$ a different\ncolour, we obtain $q!$ distinct colourings, but for each of these the\nMarkov chain is frozen (no transition is valid).\n\nThe case $m=2$ is graph colouring and has been extensively studied. See,\nfor example,~\\cite{DFHV04}. This leaves the case $m=3$, hypergraphs with 3\nvertices in each edge. The standard path coupling argument, as in\nTheorem~\\ref{colsmge4}, only shows rapid mixing for $q\\geq 2\\Delta$, since\nthere may be two vertices in each edge that can be selected and lead to a\ndivergence of the two chains. This occurs if, of the two vertices in an\nedge which are not $w$, one is coloured red and the other blue. However, we\ncan do better using Theorem~\\ref{stopping}. We will need the following\ntechnical Lemma.\n\\begin{lem}\\label{dws}\nLet $ \\varphi(d)=1- d(1-e^{-(q-\\Delta+d)t/Mq})/(q-\\Delta+d)$. For\nall $t\\geq 0$ and all $d\\geq 1$, $\\varphi(d)\\geq\\varphi(1)^d$.\n\\end{lem}\n\\begin{proof}\nLet $\\kappa=q-\\Delta> 0$,\n$x=t/Mq\\geq 0$.\nWe wish to show that\\vspace{-1.5ex}%\n\\[ \\psi(x)= \\varphi(d)-\\varphi(1)^d=\n1- d(1-e^{-(\\kappa+d)x})/(\\kappa+d) - \\big(1-\n(1-e^{-(\\kappa+1)x})/(\\kappa+1)\\big)^d \\geq 0.\\]%\nSince $\\psi(0)=0$, it suffices to show that $\\psi(x)$ is\nincreasing for all $x \\geq 0$. But\n\\begin{align*}\n    \\psi'(x)\\ &=\\ -de^{-(\\kappa+d)x}+de^{-(\\kappa+1)x}\\big(1-\n    (1-e^{-(\\kappa+1)x})/(\\kappa+1)\\big)^{d-1}\\\\[1ex]\n    &=\\ de^{-(\\kappa+1)x}\\big(\\big(1-(1-e^{-(\\kappa+1)x})/(\\kappa+1)\\big)^{d-1}\n    -e^{-(d-1)x}\\big),\n\\end{align*}\nso it suffices to show $1-(1-e^{-(\\kappa+1)x})/(\\kappa+1) \\geq\ne^{-x}$. Let $\\zeta(x)=1-e^{-x}-(1-e^{-(\\kappa+1)x})/(\\kappa+1)$.\nThen $\\zeta(0)=0$, so we need only show that $\\zeta(x)$ is\nincreasing for all $x\\in(0,\\infty)$. But\n\\begin{equation*}\n    \\zeta'(x)\\ =\\ e^{-x}-e^{-(\\kappa+1)x}\n    =\\ e^{-x}(1-e^{-\\kappa x})\\ \\geq\\ 0,\n\\end{equation*}\nfor $x \\geq 0$.\n\\end{proof}\\vspace{0ex}\n\n\\begin{thm}\\label{colouring}\nThere exists $\\Delta_0$ such that, if $\\CH$ is a 3-uniform hypergraph with\nmaximum degree $\\Delta>\\Delta_0$ and $q \\geq 1.65 \\Delta$, the Markov chain\n$\\C(\\CH)$ mixes rapidly.\n\\end{thm}\n\n\\begin{proof}\nWe choose $\\Delta_0$ large enough that all the approximations below are\nvalid. We couple two copies of this chain using the identity coupling. Let\n$X$ and $Y$ be two copies of $\\C(\\CH)$ such that $X_0$ and $Y_0$ differ\nonly at a single vertex $w$. As before, we will examine the stopping time\n$T$ at which $\\mathrm{d}(X_T,Y_T)\\neq 1$ for the first time, and show that\n$\\e[\\mathrm{d}(X_T,Y_T)]< 1$. We assume that $w$ is coloured blue in $X_0$\nand red in $Y_0$. We will call any other colour \\emph{neutral}. Let\n$\\Gamma(w)$ denote the set of vertices of $\\CH$ that share an edge with\n$w$. We will only consider transitions in which either $w$ or a vertex in\n$\\Gamma(w)$ is selected, since any transition which involves any other\nvertex will not change the distance between $X$ and $Y$. Let\n$M=|\\Gamma(w)|+1$. We will first assume that none of the edges containing\n$w$ is otherwise monochromatic, and hence that all colours are available\nfor recolouring $w$. We will deal with other cases later. Let $S_t$ denote\nthe event that $T=t$ and $\\mathrm{d}(X_T,Y_T)=0$, which we will call\n\\emph{success}. The bad event we will call \\emph{failure}.\n\nThe probability that the two chains couple in any one step is\n$\\frac{q}{Mq}$. For each $v\\in \\Gamma(w)$, let $\\beta_{v,t}$ be an\nindicator variable which takes value 1 if $v$ is either red or blue after\n$t$ steps of the chain, and takes value 0 otherwise. We describe a choice\nof vertex $v\\in\\Gamma(w)$ and colour $c\\in \\{\\textrm{red,blue}\\}$ at step\n$t$ as `bad' if there is an edge containing $v$ and $w$ whose other vertex\nis currently coloured $c$, and let $B_t$ denote the number of bad choices\nat time $t$. The probability of failure in step $t$ is therefore\n$\\frac{B_t}{Mq}$. For each $v\\in \\Gamma(w)$ let $d_v$ be the number of\nedges which contain both $v$ and $w$. Then $B_t\\leq \\sum_{v\\in\\Gamma(w)}\nd_v\\beta_{v,t}$.  Now, using $\\approx$ to imply equality up to a factor\n$1+o_\\Delta(1)$,\n\n\\begin{align}\n \\Pr(S_t)&=\\ \\e\\bigg[\\prod_{j=0}^{t-1}\\left(1-\\frac{1}{M}-\\frac{B_t}{Mq}\\right)\n \\frac{1}{M}\\bigg]\\ \\\n \\approx\\  \\ \\frac{1}{M}\\e\\Big[e^{-\\sum_{j=0}^{t-1}(\\frac{1}{M}+\\frac{B_t}{Mq})}\\Big]\\notag\\\\[1ex]\n& \\geq\\ \\frac{1}{M}\\e\\Big[e^{-\\sum_{j=0}^{t-1}(\\frac{1}{M}+\\frac{\\sum_{w\\in\\Gamma(v)}\n d_w\\beta_{w,t}}{Mq})}\\Big]\\\n% &=\\ \\frac{e^{-t/M}}{M}e^{-\\sum_{w\\in\\Gamma(v)} \\frac{ d_w}{Mq}\\sum_{j=0}^{t-1}\\beta_{w,t}}\\\\\n =\\ \\frac{e^{-t/M}}{M}\\e\\Big[\\prod_{w\\in\\Gamma(v)}e^{- \\frac{\nd_w}{Mq}\\sum_{j=0}^{t-1}\\beta_{w,t}}\\Big].\\label{prs}\n\\end{align}\n\nWe will now study the properties of $\\beta_{v,t}$, with a view to analysing\n$\\e[e^{- \\frac{ d_v}{Mq}\\sum_{j=0}^{t-1}\\beta_{v,t}}]$. Note that the\nprobability has not coupled or diverged by time $40\\Delta$\nis at most%\n\\[(1-1/M)^{20\\Delta}\\leq (1-1/2\\Delta)^{40\\Delta} \\leq e^{-20}< 10^{-8},\\]\nso we consider times only up to $40\\Delta$. Let $t_v = \\max \\{t:t< 40\\Delta\n\\textrm{ and }\\beta_{v,t}=1\\}$. If $v$ starts out either red or blue, the\nprobability that it is recoloured to a neutral colour in each step is at\nleast $(q-\\Delta-2)/Mq$. Also, the probability that it becomes red or blue\nbefore time $40\\Delta$ is at most $80\\Delta/Mq$. Hence\n\\begin{align*}\n\\Pr(t_w > t ) &\\leq\\ \\left( 1- \\frac{q-\\Delta-2}{Mq}\\right)^t + \\frac {80\\Delta}{Mq}\\\\\n% &\\approx\\ \\left( 1- \\frac{q-\\Delta}{Mq}\\right)^t\\\\\n& \\approx\\ e^{-\\frac{q-\\Delta}{Mq}t},\n\\end{align*}\nsince the second term is $O(1/\\Delta)$ and small compared to the first,\nwhich is $\\Omega(1)$ for $t\\leq 40\\Delta$. Now we can bound\n$\\sum_{j=0}^{t-1}\\beta_{v,t}$ by the minimum of $t$ and $t_v$, an\nexponentially distributed random variable with parameter\n$\\frac{q-\\Delta}{Mq}$. We are in a position to bound $\\e[e^{- \\frac{\nd_v}{Mq}\\sum_{j=0}^{t-1}\\beta_{v,t}}]$ as follows.\n\\begin{align*}\n\\e[e^{- \\frac{ d_v}{Mq}\\sum_{j=0}^{t-1}\\beta_{v,t}}] & \\geq\n\\ \\sum_{j=0}^{t} \\Pr(t_v=j)e^{-\\frac{ d_v}{Mq}j} + \\Pr(t_v > t )\ne^{-\\frac{ d_v}{Mq}t}\\\\\n&\\approx \\ \\int_{0}^{t} \\frac{q-\\Delta}{Mq}e^{- \\frac{q-\\Delta}{Mq}x}\ne^{-\\frac{d_v}{Mq} x} dx + e^{- \\frac{q-\\Delta+d_v}{Mq}t}\\\\\n&=\\ 1- \\frac{d_v}{q-\\Delta+d_v}\\left(1-e^{-\\frac{q-\\Delta+d_v}{Mq}\nt}\\right).\n\\end{align*}\nInserting this into Equation~(\\ref{prs}), we get\n\\[\\e[\\Pr(S_t)]\\ \\geq\\ \\frac{e^{-t/M}}{M}\\prod_{v\\in\\Gamma(w)}\n\\left(1- \\frac{d_v}{q-\\Delta+d_v}\\left(1-e^{-\\frac{q-\\Delta+d_v}{Mq}\nt}\\right)\\right)=\\frac{e^{-t/M}}{M}\\prod_{v\\in \\Gamma(w)} \\varphi(d_v),\\]%\nwhere $ \\varphi(d)$ was defined in Lemma~\\ref{dws}. Since $\\Sigma_{v\\in \\Gamma(w)}d_v=2\\Delta$, Lemma~\\ref{dws} implies that for all $t\\geq 0$,\n\\[ \\prod_{v\\in \\Gamma(w)} \\varphi(d_v) \\geq\n\\varphi(1)^{2\\Delta}.\\]\nHence, for $t \\leq 40\\Delta$,\n\\begin{align*}\n\\e[\\Pr(S_t)]\\ &\\geq\\ \\frac{e^{-t/M}}{M} \\left(1- \\frac{1}{q-\\Delta+1}\\left(1-e^{-\\frac{q-\\Delta+1}{Mq} t}\\right)\\right)^{2\\Delta}\\\\\n&\\approx \\ \\frac{1}{M}\ne^{-\\frac{t}{M}-\\frac{2\\Delta}{q-\\Delta}(1-e^{-\\frac{q-\\Delta}{Mq}t})}.\n\\end{align*}\nFinally, noting that $\\Pr(\\mathrm{d}(X_T,Y_T)=0)=\\sum_{t=0}^{\\infty}\n\\Pr(S_t)$ by linearity of expectation, we have\n\\begin{align*}\n\\Pr(\\mathrm{d}(X_T,Y_T)=0)\\ &\\geq\\ \\int_0^{40\\Delta} \\frac{1}{M} e^{-\\frac{t}{M}-\\frac{2\\Delta}{q-\\Delta}(1-e^{-\\frac{q-\\Delta}{Mq}t})}dt\\\\\n&=\\ \\int_0^{\\frac{40 \\Delta}{M}}\ne^{-z-\\frac{2\\Delta}{q-\\Delta}(1-e^{-\\frac{q-\\Delta}{q}z})}dz\n\\end{align*}\nIf we now substitute $q=1.65 \\Delta$ and $M\\leq 2\\Delta$, we see\nthat\n\\[\\Pr(\\mathrm{d}(X_T,Y_T)=0)\\ \\geq\\ \\int_0^{20} e^{-z-3.077(1-e^{-0.3941z})}dz\\ >\\\n0.5003.\\] Since $\\mathrm{d}(X_T,Y_T)\\in \\{1,2\\}$, it follows that\n$\\e[\\mathrm{d}(X_T,Y_T)]< 0.9994$ and we can apply Theorem~\\ref{stopping}.\nThis yields the claimed result.\n\nWe have assumed that all colours are available for recolouring $w$ at every\nstep. This will not be the case if there is any edge $e$ adjacent to $w$\nfor which $e\\setminus\\{w\\}$ is monochromatic. Let us call such an edge\n\\emph{blocking}, and suppose there are $\\rho_t$ blocking edges at time $t$.\nNote that the failure cannot occur on a blocking edge. The total number\n$\\rho'$ of blocking edges created during time $40\\Delta$ is at\nmost $\\ln\\Delta$ since%\n\\[ \\Pr(\\rho' \\geq \\ln\\Delta)\\ \\leq\\\n\\binom{40\\Delta}{\\ln\\Delta}\\Big(\\frac{1}{q}\\Big)^{\\ln\\Delta}\\ \\leq\\\n\\Big(\\frac{40}{\\ln\\Delta}\\Big)^{\\ln\\Delta}\\ =\\ O\\Big(\\frac{1}{\\Delta^\\gamma}\\Big)\\]%\nfor every constant $\\gamma>0$. Since $\\ln\\Delta$ is negligible in\ncomparison with $q$ and $M$, these do not affect the probability estimates\nin the proof above. Thus we may assume that all blocking edges exist\ninitially. We may further assume these persist until termination, so\n$\\rho_t=\\rho_0=\\rho$ for all $t$. This can only decrease the probability of\nsuccess. We now observe that this is no worse in our analysis than taking\n$\\Delta'=\\Delta-\\rho$ and $q'=q-\\rho$. Let us formally define $M'=Mq/q'$.\nThen the conditional success probability is $(q-\\rho)/Mq=1/M'$, and the\nrecolouring probability at each step is at least\n$(q-\\Delta)/Mq=(q'-\\Delta')/M'q'$. The analysis now proceeds as before.\nSince $M'$ plays no part in the final condition, we finally require $q'\n\\geq 1.65\\Delta'$, i.e. $q \\geq 1.65\\Delta-0.65\\rho$. This is clearly a\nweaker condition than $q \\geq 1.65\\Delta$.\n\\end{proof}\n\\begin{rem}\nIf we let $\\beta=(q-\\Delta)/q$ then, as $\\Delta_0\\rightarrow\\infty$, the\nanalysis can be tightened slightly to work for $\\beta>\\beta^*$, where\n$\\beta^*$ is the root of the\nequation%\n\\[ \\int_0^{\\infty}\ne^{-z-\\frac{2(1-\\beta)}{\\beta}(1-e^{-\\beta z})}dz\\ =\\ \\tfrac{1}{2}.\\]%\nThe integral can be expanded, by parts integration, as an infinite series\nto give an alternative equation%\n\\[ \\sum_{i=0}^\\infty \\frac{(-2)^i(1-\\beta)^i}{\\prod_{j=0}^i(1+j\\beta)}\\\n=\\ \\tfrac{1}{2}.\\]%\nThis has root $\\beta^*=0.392729$, giving $q > 1.64671$.\n\\end{rem}\n\\begin{rem}\nA route to improving our bound on $q$ would be to consider the changes in\nthe numbers of colours available at each vertex of $\\Gamma(w)$ during the\nprocess. We make the pessimistic assumption that this is always $q-\\Delta$\nbut, while this could be true initially, we would expect more colours to\nbecome available later on. A proper analysis of this effect seems more\ndifficult, however, because $\\Theta(\\Delta^2)$ vertices are now involved,\nand the edges containing them may intersect.\n\\end{rem}\n\\section{Hardness results for colouring}\\label{sec:hardcol}\n\\subsection{\\#P-completeness}\nAgain we show that exact counting is \\#P-complete except in the few cases\nwhere it is clearly in P. Let $\\CG(m,\\Delta)$ be as in\nTheorem~\\ref{h-thm10}.\n\\begin{thm}\\label{h-thm40}\nComputing the number of $q$-colourings of hypergraphs in $\\CG(m,\\Delta)$ is\n\\#P-complete if $\\Delta,q > 1$. If $\\Delta \\leq 1$ or $q\\leq 1$ it is in P.\n\\end{thm}\n\\begin{proof}\nAgain we assume $m\\geq 3$. The cases $\\Delta\\leq 1$, $q\\leq 1$ are\ntrivially in P. The case $\\Delta=2$ corresponds to counting edge\n$q$-colourings of graphs in which no vertex is monochromatic. We call an\nedge colouring with no monochromatic vertex a \\emph{weak edge colouring}.\nCounting weak edge colourings is \\#P-complete for graphs of arbitrarily\nlarge minimum degree. We give a proof in Appendix~\\ref{app2}.\n\nFor $\\Delta \\geq 3$, $q\\geq 2$, we use the construction from the proof of\nTheorem~\\ref{h-thm10}. For each colouring $X:V\\rightarrow \\{1,2,\\ldots,q\\}$\nof $G$ and edge $e\\in E$, there are $q^{m-2}-1$ permitted colourings of\n$u^e_1,\\ldots, u^e_{m-2}$ if $X(v_1)=X(v_2)$ and $q^{m-2}$ otherwise. The\ncorresponding $H$-colouring problem has the following $q\\times q$ weight\nmatrix:\n\\[ A=\\begin{bmatrix} q^{m-2}-1 & q^{m-2} & \\cdots & q^{m-2}\\\\\nq^{m-2} & q^{m-2}-1& \\cdots& q^{m-2}\\\\\n\\vdots&\\ \\ \\ddots&&\\vdots\\\\\nq^{m-2} & q^{m-2}& \\cdots & q^{m-2}-1\\end{bmatrix}.\\]\nThe \\#P-completeness of $H$-colouring with this weight matrix, and\nthe bound $\\Delta=3$, follow as in Theorem~\\ref{h-thm10},\nsince $A$ is again nonsingular.\n\\end{proof}\n\\subsection{Hardness of Approximation}\nAgain let $\\CG(m,\\Delta)$ be as defined in Theorem~\\ref{h-thm10}. Our\nresult, Corollary~\\ref{h-cor10}, follows directly from the following\nNP-completeness proof.\n\\begin{thm}\\label{h-thm50}\nDetermining whether a hypergraph in $\\CG(m,\\Delta)$ has any $q$-colouring\nis NP-complete for any $m > 1$ and $2 < q \\leq(1-1/m)\\Delta^{1/(m-1)}$.\n\\end{thm}\n\\begin{proof}\n\nIf $m=2$, this is graph colouring, and the result follows\nfrom~\\cite[Theorem 1.4]{EHK98}. (See also~\\cite{MR01}.) For $m\\geq 3$, we\nuse the following reduction from graph colouring. Let $G=(V,E)$ be a graph\nwith degree $\\Delta_G$, and $2 < q \\leq 3\\Delta_G/4$. Without loss, we may assume\n$\\Delta_G= \\lceil 4q/3\\rceil$. Colouring $G$ with $q$ colours is\nNP-complete~\\cite{EHK98}. For each edge $e=\\set{v_1,v_2}\\in E$, let\n$S_i^e=\\set{u^e_{i1},u^e_{i2},\\ldots,u^e_{im}}$ $(i=1,2,\\ldots,q)$ and\n$\\CV_0^e=\\bigcup_{i=1}^q S_i^e$. Let $\\CE_0^e$ comprise all subsets of\n$\\CV_0^e$ of size $m$ other than $S_i^e$ $(i=1,2,\\ldots,q)$. We claim that\nany proper $q$-colouring of the hypergraph $\\CH_0^e=(\\CV_0^e,\\CE_0^e)$ must\nassign the same colour to all $u^e_{ij}\\in S_i^e$ $(j=1,2,\\ldots,m)$, and a\ndifferent colour for each $i=1,\\ldots,q$. The claim holds since there must\nbe some colour class of size at least $m$, since there are $q$ colours and\n$mq$ vertices. If there was a colour class of size greater than $m$, at\nleast one of its subsets of size $m$ would be a monochromatic edge. Thus\nthere must be exactly $q$ colour classes, each of size $m$. If these are\nnot the $S_i^e$ $(i=1,2,\\ldots,q)$, again there is a monochromatic subset\nof size $m$ which is an edge. Clearly, by symmetry, any assignment of the\n$q$ colours to the $q$ classes $S_i^e$ is permissible.\n\nLet $\\CV^e=\\CV_0^e\\cup\\set{v_1,v_2}$, and add the edges\n$\\set{v_1,u^e_{i2},\\ldots,u^e_{im}}$ $(i=1,\\ldots,\\lfloor q/2\\rfloor)$ and\n$\\set{v_2,u^e_{i2},\\ldots,u^e_{im}}$ $(i=\\lfloor q/2\\rfloor+1,\\ldots,q)$ to\n$\\CE_0^e$ to give $\\CE^e$. We claim that, in any proper $q$-colouring of\nthe hypergraph $\\CH^e=(\\CV^e,\\CE^e)$, $v_1$ and $v_2$ must receive\ndifferent colours. The claim holds since $v_1$ can have any colour\ndifferent from all $S_i^e$ $(i=1,2,\\ldots,\\lfloor q/2\\rfloor)$, and $v_2$\nany colour different from all $S_i^e$ $(i=\\lfloor q/2\\rfloor+1,\\ldots,q)$.\nBut these permitted colour sets for $v_1$ and $v_2$ are disjoint. Also,\ngiven any colours for $v_1$ and $v_2$, there are $\\lfloor q/2\\rfloor\\lceil\nq/2\\rceil(q-2)!>0$ colourings of $\\CH^e$. Thus we may use $\\CH^e$ to\nsimulate the edge $e\\in E$. Thus we set $\\CV= \\bigcup_{e\\in E}\\CV^e$,\n$\\CE=\\bigcup_{e\\in E}\\CE^e$ and consider the hypergraph $\\CH=(\\CV,\\CE)$.\nThen $\\CH$ is $q$-colourable if and only if $G$ is $q$-colourable.\n\nThe maximum degree in $\\CH$ of any $u_{ij}$ is $\\binom{mq}{m-1} \\geq\neq^{m-1}$. The degree in $\\CH$ of each $v\\in V$ is at most $\\Delta_G\\lceil\nq/2\\rceil \\leq (4q+2)(q+1)/6 < 2q^2$. Thus $\\Delta=\\binom{mq}{m-1}\\geq\n(mq/(m-1))^{m-1}$, and hence $q\\leq (1-1/m)\\Delta^{1/(m-1)}$.\n\\end{proof}\n\\begin{cor}\\label{h-cor10}\nUnless NP\\/=\\/RP, there is no \\emph{fpras} for counting $q$-colourings of a\nhypergraphs with maximum degree $\\Delta$ and minimum edge size $m$ if $2 <\nq\\leq (1-1/m)\\Delta^{1/(m-1)}$.\n\\end{cor}\n\\begin{proof}\nWe cannot tell if there is \\emph{any} colouring for $q$ in this range, so\nthere can be no \\emph{fpras}.\n\\end{proof}\n\\begin{rem}\nIt is clearly a weakness that our lower bound for approximate counting is\nbased entirely on an NP-completeness result. However, we note that the same\nsituation pertains for  graph colouring, which has been the subject of more\nintensive study.\n\\end{rem}\n\\section{Conclusions}\nWe have presented an approach to the analysis of path coupling with\nstopping times which improves on the method of~\\cite{HV04} in most\napplications. Our method may itself permit further development.\n\nWe apply the method to independent sets and $q$-colourings in hypergraphs\nwith maximum degree $\\Delta$ and minimum edge size $m$. In the case of\nindependent sets, there seems scope for improving the bound $m\\geq 2\\Delta\n+1$, but anything better than $m\\geq \\Delta+o(\\Delta)$ would seem to\nrequire new methods. For colourings, there is probably little improvement\npossible in our result $q >\\Delta$ for $m\\geq 4$, but many questions remain\nfor $m\\leq \\Delta$. For example, even the ergodicity of the Glauber (or any\nother) dynamics is not clearly established. For the most interesting case,\n$m=3$, the bound $q>1.65\\Delta$ (for large $\\Delta$) can almost certainly\nbe reduced, but substantial improvement may prove difficult.\n\nOur \\#P-completeness results seem best possible for both of the problems we\nconsider. On the other hand, our lower bounds for hardness of approximate\ncounting seem very weak in both cases, and are far from our upper bounds.\nThese lower bounds can probably be improved, but we have no plausible\nconjecture as to what may be the truth.\n\n\\section*{Acknowledgments}\n\nWe are grateful to Tom Hayes for commenting on an earlier draft of this paper,\nand to Mary Cryan for useful discussions at an early stage of this work.\n\n\\begin{thebibliography}{99}\n\n\\bibitem{BK03} P. Berman and M. Karpinski, Improved approximation lower bounds\non small occurrence optimization, \\emph{Electronic Colloquium on\nComputational Complexity} \\textbf{10} (2003), Technical Report\nTR03-008.\n\n\\bibitem{B01} R. Bubley,\n\\emph{Randomized algorithms: approximation, generation and counting},\nSpringer-Verlag, London, 2001.\n\n\\bibitem{BD97} R. Bubley and M. Dyer, Graph orientations with no sink\nand an approximation for a hard case of \\#SAT, in \\emph{Proc.\n8${}^\\textrm{th}$ Annual ACM-SIAM Symposium on Discrete Algorithms\n(SODA~1997)}, SIAM, 1997, pp.~248--257.\n\n\\bibitem{BDGJ99} R. Bubley, M. Dyer, C. Greenhill, and M. Jerrum, On approximately\ncounting colourings of small degree graphs, \\emph{SIAM Journal on Computing}\n\\textbf{29} (1999), 387--400.\n\n\\bibitem{BG04} A. Bulatov and M. Grohe,\nThe complexity of partition functions, in \\emph{Proc. 31st International Colloquium\non Automata, Languages and Programming (ICALP 2004)}, Springer, 2004,\npp.~294--306.\n\n\\bibitem{DGKR03}  I. Dinur, V. Guruswami, S. Khot and O. Regev,\nA new multilayered PCP and the hardness of hypergraph vertex cover, in\n\\emph{Proc. 35${}^\\textrm{th}$ ACM Symposium on Theory of Computing (STOC\n2003)}, ACM, 2003, pp. 595--601.\n\n\\bibitem{DRS02}   I. Dinur, O. Regev and C. Smyth,\nThe hardness of {3-uniform} hypergraph coloring, in \\emph{Proc.\n43${}^\\texttt{rd}$ Symposium on Foundations of Computer Science ({FOCS\n2002})}, IEEE, 2002, pp. 33--42\n\n\\bibitem{DFHV04} M. Dyer, A. Frieze, T. Hayes and E. Vigoda, Randomly\ncoloring constant degree graphs, in \\emph{Proc. 45${}^\\textrm{th}$ Annual\nIEEE Symposium on Foundations of Computer Science (FOCS 2004)}, IEEE, 2004,\npp.~582--589.\n\n\\bibitem{DFJ99} M. Dyer, A. Frieze and M. Jerrum, On counting independent\nsets in sparse graphs, \\emph{SIAM Journal on Computing} \\textbf{31} (2002),\n1527--1541.\n\n\\bibitem{DGGJM01} M. Dyer, L. Goldberg, C. Greenhill,\nM. Jerrum and M. Mitzenmacher, An extension of path coupling and its\napplication to the Glauber dynamics for graph colorings,  \\emph{SIAM\nJournal on Computing} \\textbf{30} (2001), 1962--1975.\n\n\\bibitem{DG98} M. Dyer and C. Greenhill, A more rapidly mixing Markov\nchains for graph colouring, \\emph{Random Structures and Algorithms}\n\\textbf{13} (1998), 210--217.\n\n\\bibitem{DG00a} M. Dyer and C. Greenhill, On Markov chains for independent\nsets, \\emph{Journal of Algorithms} \\textbf{35} (2000), 17--49.\n\n\\bibitem{DG00b} M. Dyer and C. Greenhill, The complexity of counting graph\nhomomorphisms, \\emph{Random Structures and Algorithms}, \\textbf{17} (2000), 260--289.\nSee also Corrigendum, \\emph{Random Structures and Algorithms} \\textbf{25} (2004), 346--352.\n\n\\bibitem{EHK98} T. Emden-Weinert, S. Hougardy and B. Kreuter,\nUniquely colourable graphs and the hardness of colouring graphs of large girth,\n\\emph{Combinatorics, Probability and Computing} \\textbf{7} (1998), 375--386.\n\n\\bibitem{GJ79} M. Garey and D. Johnson, \\emph{Computer and intractability},\nW. H. Freeman and Company, 1979.\n\n\\bibitem{G00} C. Greenhill, The complexity of counting colourings and\nindependent sets in sparse graphs and hypergraphs, \\emph{Computational Complexity}\n\\textbf{9} (2000), 52--73.\n\n\\bibitem{HV04}\nT. Hayes and E. Vigoda, Variable length path coupling, in \\emph{Proc.\n15${}^\\textrm{th}$ Annual ACM-SIAM Symposium on Discrete Algorithms (SODA\n2004)}, SIAM, 2004, pp.~103--110.\n\n\\bibitem{HL98} T. Hofmeister and H. Lefmann, Approximating maximum\nindependent sets in uniform hypergraphs, \\emph{Proc. 23${}^\\textrm{rd}$\nInternational Symposium on Mathematical Foundations of Computer Science\n(MFCS 1998)}, Lecture Notes in Computer Science \\textbf{1450}, Springer,\n1998, pp. 562--570.\n\n\\bibitem{JLR00} S. Janson, T. \\L uczak and A. Ruci\\'nski, \\emph{Random graphs},\nWiley-Interscience, New York, 2000.\n\n\\bibitem{J95} M. Jerrum, A very simple algorithm for estimating the number of\n$k$-colorings of a low-degree graph, \\emph{Random Structure and Algorithms}\n\\textbf{7} (1995), 157--165.\n\n\\bibitem{J03} M. Jerrum, \\emph{Counting, sampling and integrating: algorithms and\ncomplexity}, ETH Z\\\"urich Lectures in Mathematics, Birkh\\\"auser, Basel,\n2003.\n\n\\bibitem{KNS01} M. Krivelevich, R. Nathaniel and B. Sudakov,\nApproximating coloring and maximum independent sets in 3-uniform\nhypergraphs, in \\emph{Proc. 12${}^\\textrm{th}$ Annual ACM-SIAM Symposium on\nDiscrete Algorithms, (SODA~2001)}, SIAM, 2001, pp. 327--328.\n\n\\bibitem{LV99} M. Luby and E. Vigoda, Fast convergence of the Glauber dynamics\nfor sampling independent sets, \\emph{Random Structures and\nAlgorithms} \\textbf{15} (1999), 229--241.\n\n\\bibitem{M01} M. Molloy, Very rapidly mixing Markov chains for $2\\Delta$-coloring\nand for independent sets in a graph with maximum degree 4,\n\\emph{Random Structures and Algorithms} \\textbf{18} (2001),\n101--115.\n\n\\bibitem{MR01} M. Molloy and B. Reed, Colouring graphs when the\nnumber of colours is nearly the maximum degree, in \\emph{Proc.\n33${}^\\textrm{rd}$ Annual ACM Symposium on Theory of Computing (STOC\n2001)}, ACM, 2001, pp. 462--470.\n\n\\bibitem{SS97} J. Salas and A. Sokal, Absence of phase transition\nfor anti-ferromagnetic Potts models via the Dobrushin uniqueness theorem,\n\\emph{Journal of Statistical Physics} \\textbf{86} (1997), 551--579.\n\n\\bibitem{S04} N. Sloane, Sequence A006129,\n\\emph{The on-line encyclopedia of integer sequences},\n 2004. Published at\n\\texttt{http://www.research.att.com/$\\sim$njas/sequences/}.\n\n\\bibitem{V01} E. Vigoda, A note on the Glauber dynamics for sampling\nindependent sets, \\emph{The Electronic Journal of Combinatorics}\n\\textbf{8}, R8(1), 2001.\n\\end{thebibliography}\n\n\\appendix\n\n\\section*{Appendices}\n\n\\section{Edge cover is \\#P-complete}\n\\label{app1}\n\\begin{proof}\nWe prove this by reduction from counting independent sets, using methods\nsimilar to Bubley and Dyer~\\cite{BD97}, where this result was claimed\nwithout proof. Let $\\CG$ be a class of $3$-regular graphs for which\ncounting independent sets is \\#P-complete~\\cite[Theorem 3.1]{G00}. Let\n$G=(V,E)$, with $I_j(G)$ independent sets of size $j$ ($j=0,1,\\ldots,n$).\nForm $G'$ by subdividing each edge $e\\in E$ with a new vertex $u_e$. Let\n$U=\\set{u_e:e\\in E}$. Let $N_i(G')$ be the number of edge sets in $G'$\nwhich leave exactly $i$ vertices in $V$ uncovered, but no vertex in $U$. In\nparticular, $N_0(G')$ is the number of edge covers of $G'$, and we assume\nan oracle computing this quantity. Observe that the uncovered vertices in\n$G'$ must form an independent set in $G$. Then it follows, similarly\nto~\\cite{BD97}, that\n\\[ 2^{3(n-2j)}I_j(G)\\ =\\ \\sum_{i=j}^n \\binom{i}{j}N_i(G').\\]\nThus, if we can determine the $N_i(G')$, we can determine the number of\nindependent sets of all sizes in $G$. Let $N_{ij}(G')$ be the number of\nedge sets of $G'$ in which $i$ vertices in $V$ and $j$ in $U$ are\nuncovered ($i=0,\\ldots,n,\\,j=0,\\ldots,3n/2$). Then\n$N_{i}(G')=N_{i0}(G')$. We attach a copy $K_m^v$ of $K_m$ to each vertex\n$v\\in V$ and a copy $K_k^u$ of $K_k$ to each vertex $u\\in U$. Call the\nresulting graph $G_{mk}$.  Let $M_m$ be the number of edge covers of $K_m$,\nthen $M_{m-1}$ is the number of edge sets in $K_m$ which leave a fixed\nvertex uncovered. We can show by inclusion-exclusion that\n\\begin{equation*}\n    M_m\\ =\\ \\sum_{i=0}^{m}(-1)^i \\binom{m}{i}\n    \\binpower{2}{m-i}.\n\\end{equation*}\n(See~\\cite{S04}.) It is easy to show that that $M_m/M_{m-1}$ is a rapidly\nincreasing sequence (in fact $M_m/M_{m-1}\\approx 2^{m-1}$ for large $m$),\nand hence has a different value for every value of $m$. We have\n\\begin{align}\nN_{0}(G'_{mk})\\ &=\\ \\sum_{i=0}^n \\sum_{j=0}^{3n/2} M_m^{\\,i}\n(M_m+M_{m-1})^{n-i} M_k^{\\,j} (M_k+M_{k-1})^{3n/2-j}\nN_{ij}(G').\\label{app1-eq0}\\\\\n&=\\ M_m^{\\,n}M_k^{\\,3n/2}\\sum_{i=0}^n\n\\bigg(1+\\frac{M_{m-1}}{M_m}\\bigg)^{n-i}\\ \\sum_{j=0}^{3n/2}\n\\bigg(1+\\frac{M_{k-1}}{M_k}\\bigg)^{3n/2-j}N_{ij}(G').\\notag\n\\end{align}\nBy choosing any $(n+1)$ values of $m$ and any $(3n/2 +1)$ values of $k$, we\ncan determine all the $N_{ij}(G')$ by interpolation, and hence all the\n$N_i(G')$. From these, we can determine all the $I_j(G)$, and hence\n$\\sum_{j=1}^n I_j(G)$, the total number of independent sets in $G$.\n\nNote that the minimum degree of $G'_{mk}$, $\\min\\{m,k\\}-1$, can be made as\nlarge as we wish.\n\\end{proof}\n\\section{Weak edge colouring is \\#P-complete}\n\\label{app2}\n\\begin{proof}\nWe use the same notation and construction as in Appendix~\\ref{app1}. Now\n$\\CG$ is a class of $3$-regular graphs for which vertex $q$-colouring is\n\\#P-complete~\\cite[Theorem 2.2]{G00}. Let $N_i(G')$ denote the number of\nedge colourings of $G'$ with $i$ monochromatic vertices, so $N_0(G')$ is\nthe number of weak edge colourings of $G'$, and we assume an oracle for\nthis. Let $N_{ij}(G')$ be the number edge colourings of $G'$ in which $i$\nvertices in $V$ and $j$ in $U$ are monochromatic\n($i=0,\\ldots,n,\\,j=0,\\ldots,3n/2$). Now observe that $N_{n0}(G')$ is equal\nto the number of proper \\emph{vertex} $q$-colourings of $G$, $Q_q(G)$ say.\nIn every colouring counted in $N_{n0}(G')$, every vertex is monochromatic\nand adjacent vertices receive different colours. Again we attach a copy\n$K_m^v$ of $K_m$ to each vertex $v\\in V$, and a copy $K_k^u$ of $K_k$ to\neach vertex $u\\in U$, to give $G_{mk}$. Let $M_m$ be the number of weak\ncolourings of $K_m$, and $M'_m$ the number of edge colourings of $K_m$ with\na given monochromatic vertex. Now we have\n\\begin{equation*}\n    M_m\\ =\\ \\binpower{q}{m}+q\\sum_{i=1}^{m}(-1)^i \\binom{m}{i}\n    \\binpower{q}{m-i},\\qquad\n    M'_m\\ =\\ q\\sum_{i=0}^{m-1}(-1)^i \\binom{m-1}{i}\n    \\binpower{q}{m-i-1}.\n\\end{equation*}\nAgain the sequence $M_m/M'_m$ increases rapidly ($M_m/M'_m\\approx q^{m-2}$\nfor large $m$), and takes a different value for every $m$ when $q\\geq 2$.\nNow, as in (\\ref{app1-eq0}),\n\\begin{equation*}\nN_{0}(G'_{mk})\\ =\\ M_m^{\\,n}M_k^{\\,3n/2}\\sum_{i=0}^n\n\\bigg(1+\\frac{M'_m}{M_m}\\bigg)^{n-i}\\ \\sum_{j=0}^{3n/2}\n\\bigg(1+\\frac{M'_k}{M_k}\\bigg)^{3n/2-j}N_{ij}(G').\n\\end{equation*}\nHence, choosing $(n+1)$ values of $m$ and $(3n/2 +1)$ values of $k$, we can\ndetermine all the $N_{ij}(G')$ by interpolation. In particular, we can\ndetermine $N_{n0}(G')=Q_q(G)$.\n\nAgain the minimum degree of $G'_{mk}$, $\\min\\{m,k\\}-1$, can be made\narbitrarily large.\n\\end{proof}\n\\end{document}\n", "meta": {"hexsha": "e424b0cb4e49face0858a6990df421b28c1a3a08", "size": 67845, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "benchmark/src/test-data/0501/math0501081/math0501081.tex", "max_stars_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_stars_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-23T19:07:01.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-23T19:07:01.000Z", "max_issues_repo_path": "benchmark/src/test-data/0501/math0501081/math0501081.tex", "max_issues_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_issues_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/src/test-data/0501/math0501081/math0501081.tex", "max_forks_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_forks_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.5539513678, "max_line_length": 170, "alphanum_fraction": 0.6954528705, "num_tokens": 23129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.5851011542032313, "lm_q1q2_score": 0.4091345688431918}}
{"text": "\\documentclass[11pt]{article}\n\n\n\\usepackage[linesnumbered,ruled]{algorithm2e}\n\\SetKwRepeat{Do}{do}{while}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath,mathrsfs}\n\\usepackage{float}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\usepackage{caption}\n\\usepackage{listings}\n\\usepackage{url}\n\\usepackage{epstopdf}\n\\usepackage{subcaption}\n\\usepackage[left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}\n\\title{Assignment 2 Report}\n\\author{ Yue Hao, \\url{yhao3@gmu.edu}}\n\\date{}\n\n\\newcommand{\\lecture}[4]{\\handout{#1}{#2}{#3}{#4}{#1}}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{observation}[theorem]{Observation}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{fact}[theorem]{Fact}\n\\newtheorem{assumption}[theorem]{Assumption}\n\n% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.\n\\topmargin 0pt\n\\advance \\topmargin by -\\headheight\n\\advance \\topmargin by -\\headsep\n\\textheight 8.9in\n\\oddsidemargin 0pt\n\\evensidemargin \\oddsidemargin\n\\marginparwidth 0.5in\n\\textwidth 6.5in\n\n\\parindent 0in\n\\parskip 1.5ex\n%\\renewcommand{\\baselinestretch}{1.25}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Summary of the two methods}\n\nBoth methods use the same idea from paper \\cite{secord}, however there are few major differences which can be summarized in Table \\ref{tb:diff}.\n\\begin{table}[H]\n\\centering\n\\caption{Major Algorithmic Differences of the Two Methods}\n\\label{tb:diff}\n\\begin{tabular}{|c|c|c|}\n\\hline \n & Hedcuter & Voronoi \\\\ \n\\hline \nInitial Sites Distribution & Gaussian & Uniform \\\\ \n\\hline \nAlg. for Voronoi & Image Propagation& Fortune\\\\ \n \\hline \nCell Representation & Discretized Points & Polygon \\\\ \n\\hline \nMetric of Displacement & Manhattan & Euclidean \\\\ \n\\hline \nDisk Color & Cell Avg. Color & Controid Color \\\\ \n\\hline \nDisk Radius & Cell Avg. Intensity & Cell Max Intensity\\\\ \n\\hline\n\\end{tabular} \n\\end{table}\n\n\\subsection{hedcuter method}\n\\begin{enumerate}\n\n\\item Centroidal Voronoi Tessellation (CVT)\n\nThe algorithm for generating CVT is summerized in  Algorithm \\ref{alg:cvt_hed}.\n\nNote there is an option in Algorithm \\ref{alg:cvt_hed} Line 5, that the method can also use the maximum Manhattan distance as a metric for displacement besides the average.\n\nAlgorithm \\ref{alg:sp_hed} shows that hedcuter collect $n$ points that randomly spreaded w.r.t. the intensity of greyscale image  as initial sites.\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\SetKwFunction{Voronoi}{Voronoi}\n    \\SetKwFunction{Centroidal}{Centroidal}\n    \\SetKwFunction{SampleInitialPoints}{SampleInitialPoints}\n    \\Input{$I$: a grayscale image\\\\\n    $n$: the number of points to be collected\\\\\n    $d_t$: a user defined threshold for the average displacement}\n    \\Output{$C$: a collection of cells   representing the CVT\\\\\n    \twhere $c.s$ is the 2D coordinate of site of cell $c$ in $C$\\\\\n    \tand $c.P$ is a collection of 2D coordinates marking the coverage of the cell}\n    \t   $C = \\lbrace \\rbrace$\\\\\n    \t$P$ = \\SampleInitialPoints($I$,$n$)\\\\\n   \\Do{$d > d_t$} {\n   \t$V$ = \\Voronoi($I$,$P$)\\\\\n   \t$P_c$ =  \\Centroidal($I$,$V$)\\\\\n   \t$d =\\frac{\\sum_{p,p_c | p \\in P, p_c \\in P_c} {|p.x-p_c.x|+|p.y-p_c.y|}}{|P|} $\\\\\n   \t$P:=P_c$\n   }\n   \\For {$p\\in P$} {\n      $c.s = p $\\\\\n      $c.P = $ points in $V$ composing the cell that sited on $p$\\\\\n      $C= C\\cup  \\lbrace c \\rbrace$\n   }   \n      return $C$\n    \\caption{Centroidal\\_Voronoi\\_Tessellation($I$,$n$,$d_t$)}\n        \\label{alg:cvt_hed}\n\\end{algorithm}\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{$I$: a grayscale image w/ $I(p)$ being the intensity of pixel at $p$\\\\\n    $n$: the number of points to be collected}\n    \\Output{$P$: a set of 2D coordinates of collected points}\n    $P = \\lbrace \\rbrace $\\\\\n   \\While{$|P| < n$} {\n   \t$p$ = draw a coordinate uniformly random on image $I$ \\\\\n   \t$i$ = $I(p)$ \\\n   \t$g$ = draw a random variable following a Gaussian distribution \\\\\n   \t\\If{$i < g$} {\n   \t$P = P \\cup p$\n   \t}\n   }\n      return $P$\n    \\caption{ SampleInitialPoints($I$,$n$)}\n    \\label{alg:sp_hed}\n\\end{algorithm}\n\n\\item Computing Voronoi Diagram\n\nThe method uses a image wave propagtion algorithm to calculate voronoi diagram which is summerized in  Algorithm \\ref{alg:vor_hed}.\n\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\SetKwFunction{ColorDist}{ColorDist}\n    \\Input{$P$: a set of 2D coordinates\\\\\n    $I$: a grayscale image $I$ w/ $I(p)$ being the intensity pixel at $p$}\n    \\Output{$V$: a collection of cells representing the Voronoi Diagram,\\\\\n    and $v.P$ is a collection of 2D coordinates marking the coverage of the cell\n    }\n    $H = \\lbrace \\rbrace$ (a heap data structure holding the points) \\\\\n    $D = \\lbrace \\rbrace$ (an image sized contrainer) \\\\\n    $R = \\lbrace \\rbrace$ (an image sized contrainer) \\\\\n    \\For {$p_i \\in P$} {\n    put $p_i$ in heap $H$ according to \\ColorDist($I(p_i)$)\\\\\n    $D(p_i)$ = \\ColorDist($p_i$)\\\\\n    $R(p_i)$ = $i$\\\\\n    }\n    \\While {$H$ is not empty} {    \n    $p$ = draw a point from the back of the heap $H$\\\\\n    \\For{each point $p_n$  neighboring $p$} {\n    $d_n = D(p) + \\ColorDist(p_n)$ \\\\\n    \t\\If {$d_n < D(p)$ } {\n    \t$D(p_n) = d_n$\\\\\n    \t$R(p_n) = R(p)$\\\\\n    \tput $p_n$ in heap $H$ according to \\ColorDist($I(p_n)$)\n    \t}\n    }\n    }\n    \n    \\For {all points coordinates $p$ on image} {\n    put all the points with the same $R(p)$ in the same voronoi cell $v_{R(p)}.P \\in V$\n    }\n      return $V$\n    \\caption{Voronoi($I$,$P$)}\n    \\label{alg:vor_hed}\n\\end{algorithm}\n\n\\item Stippling\n\nFinally, hedcuter method uses Algorithm \\ref{alg:st_hed} to generate the stippling disks.\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{ $M$: an RGB color image  w/ $M(p)$ being the RGB color of pixel at $p$\\\\\n    $I$: a grayscale image $I$ w/ $I(p)$ being the intensity pixel at $p$\\\\\n    $C$: a collection of cells  representing the CVT\\\\\n    \twhere $c.s$ is the 2D coordinate of site of cell $c$ in $C$\\\\\n    \tand $c.P$ is a collection of 2D coordinates marking the coverage of the cell}\n    \\Output{$D$: a collection of disks of the Stipples\\\\\n    where $d.c$ is the 2D coordinates of the center of $d$ in $D$, \\\\\n     $d.rgb$ is the RGB color and $d.r$ is the radius\n    }\n    $D = \\lbrace \\rbrace $\\\\\n    \\For {$c \\in C$} {\n    $d.c = c.s$\\\\\n    $d.rgb =\\frac{\\sum_{p \\in c.P} {M(p)} } {|c.P|}$ \\\\\n    $i = \\frac{\\sum_{p \\in c.P} {I(p)} } {|c.P|}$ \\\\\n    $d.r = \\frac{100*r}{i+100}$ where $r$ is a default constant\\\\\n     $D = D \\cup \\lbrace d \\rbrace$\n    }\n      return $D$\n    \\caption{Create\\_Disks($M$,$I$,$C$)}\n    \\label{alg:st_hed}\n\\end{algorithm}\n\n\\end{enumerate}\n\n\\subsection{voronoi method}\n\n\\begin{enumerate}\n\n\\item Centroidal Voronoi Tessellation (CVT)\n\n\nThe algorithm for generating CVT is summerized in  Algorithm \\ref{alg:cvt_vor}, which is very similar  to the one in hedcuter methods, the only difference are the cell representation, methods to create initial samplings, and distance metric.\n\nAlgorithm \\ref{alg:sp_vor} shows that hedcuter collect $n$ points that randomly spreaded w.r.t. the intensity of greyscale image  as initial sites.\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\SetKwFunction{VoronoiFortune}{VoronoiFortune}\n    \\SetKwFunction{Centroidal}{Centroidal}\n    \\SetKwFunction{CreateInitialDistribution}{CreateInitialDistribution}\n    \\Input{$I$: a grayscale image\\\\\n    $n$: the number of points to be collected\\\\\n    $d_t$: a user defined threshold for the average displacement}\n    \\Output{$C$: a collection of cells   representing the CVT\\\\\n    \twhere $c.s$ is the 2D coordinate of site of cell $c$ in $C$\\\\\n    \tand $c.V$ is a collection of 2D coordinates marking the boundary of the cell\\\\\n    \tand $c.E$ is a collection of edges marking the  boundary of the cell}\n    \t     $C = \\lbrace \\rbrace$\\\\\n    \t$P$ = \\CreateInitialDistribution($I$,$n$)\\\\\n   \\Do{$d > d_t$} {\n   \t$V$ = \\VoronoiFortune($I$,$P$)\\\\\n   \t$P_c$ =  \\Centroidal($I$,$V$)\\\\\n   \t$d =\\frac{\\sum_{p,p_c | p \\in P, p_c \\in P_c} {\\sqrt{(p.x-p_c.x)^2+(p.y-p_c.y)^2}}}{|P|} $\\\\\n   \t$P:=P_c$\n   }\n   \\For {$p\\in P$} {\n      $c.s = p $\\\\\n      $c.V = $ points in $V$ bounding the cell that sited on $p$\\\\\n      $c.E = $ edges in $V$ bounding the cell that sited on $p$\\\\\n      $C= C\\cup  \\lbrace c \\rbrace$\n   }   \n      return $C$\n    \\caption{Centroidal\\_Voronoi\\_Tessellation($I$,$n$,$d_t$)}\n        \\label{alg:cvt_vor}\n\\end{algorithm}\n\n\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{$I$: a grayscale image w/ $I(p)$ being the intensity of pixel at $p$\\\\\n    $n$: the number of points to be collected}\n    \\Output{$P$: a set of 2D coordinates of collected points}\n    $P = \\lbrace \\rbrace $\\\\\n   \\While{$|P| < n$} {\n   \t$p$ = draw a coordinate uniformly random on image $I$ \\\\\n   \t$i$ = $I(p)$ \\\n   \t$g$ = draw a random variable uniformly random \\\\\n   \t\\If{$i < g$} {\n   \t$P = P \\cup p$\n   \t}\n   }\n      return $P$\n    \\caption{ CreateInitialDistribution($I$,$n$)}\n    \\label{alg:sp_vor}\n\\end{algorithm}\n\n\\item Computing Voronoi Diagram\n\nThis method uses the Fortune's algorithm which was fully discussed in lecture. For the sake of brevity, the pseudocode is neglected here.\n\n\\item Stippling\n\nThe stippling technique is very similar to hedcuter method, where only minor difference is the color of disk is solely determined on the controid's color (shown in Alg. \\ref{alg:st_vor} Line 4), slightly different handling of radius  (shown in Alg. \\ref{alg:st_vor} Line 6-7).\n\n\\begin{algorithm}[H]\n    \\SetKwInOut{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{ $M$: an RGB color image  w/ $M(p)$ being the RGB color of pixel at $p$\\\\\n    $I$: a grayscale image $I$ w/ $M(p)$ being the intensity pixel at $p$\\\\\n    $C$: a collection of cells   representing the CVT\\\\\n    \twhere $c.s$ is the 2D coordinate of site of cell $c$ in $C$\\\\\n    \tand $c.V$ is a collection of 2D coordinates marking the boundary of the cell\\\\\n    \tand $c.E$ is a collection of edges marking the  boundary of the cell}\n    \\Output{$D$: a collection of disks of the Stipples\\\\\n    where $d.c$ is the 2D coordinates of the center of $d$ in $D$, \\\\\n     $d.rgb$ is the RGB color and $d.r$ is the radius\n    }\n    $D = \\lbrace \\rbrace $\\\\\n    \\For {$c \\in C$} {\n    $d.c = c.s$\\\\\n    $d.rgb =M(c.s)$ \\\\\n    $P$ = sampling points in $c$\\\\\n    $i = \\sum_{p \\in P} {I(p)}$ \\\\\n    $d.r =r*\\frac{i}{max(i \\text{ for all } c \\in C)}$ where $r$ is a default constant\\\\\n     $D = D \\cup \\lbrace d \\rbrace$\n    }\n      return $D$\n    \\caption{Stippling($M$,$I$,$C$)}\n    \\label{alg:st_vor}\n\\end{algorithm}\n\n\\end{enumerate}\n\n\\section{Comparison of the two methods}\nUnless otherwise specified, all the output in this section are using the following settings for both methods in Table \\ref{tb:param}, these parameters are tunes for the purpose of unifying the output for both algorithms (shown in question 1), and used as baseline for comparison the output with various parameters/input adjusted in the remaining questions.\n\\begin{table}[H]\n\\centering\n\\caption{Baseline Parameters }\n\\label{tb:param}\n\\begin{tabular}{|c|c|c|}\n\\hline \n & Hedcuter & Voronoi \\\\ \n\\hline \nNum of points & 1000 & 1000 \\\\ \n\\hline \nThreshold of Displacement& 1.0 & 0.14\\\\ \n \\hline \nDefault Radius & 7 & 0,7 \\\\ \n\\hline \nColor & Black & Black \\\\ \n\\hline \nSub-pixels & 1 & 5 \\\\ \n\\hline \n\\end{tabular} \n\\end{table}\nFor the hedcuter, GPU is NOT used and max iteration is set to $\\infty$.\n\n\\begin{enumerate}\n\\item Do you get the same results by running the same program on the same image multiple times?\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/1-1.pdf}\n        \\caption{1st run}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/1-2.pdf}\n        \\caption{2nd run}\n    \\end{subfigure}\n    \\label{fig:1}\n    \\caption{Hedcuter}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/1-1.pdf}\n    \\caption{1st run}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/1-2.pdf}\n         \\caption{2nd run}\n    \\end{subfigure}\n    \\label{fig:2}\n      \\caption{Voronoi}\n\\end{figure}\n\nI do NOT get the same results running hedcuter on the same image, due the the randomness introduced when sampling the initial sites.\n\nI do get the same results running voronoi. Although the initial sites are also generated randomly, the random seed that  voronoi uses is \\textit{boost::mt19937}, which creates a  pseudo-random number generator. A numbers the random number produced will be the same every time the program is run.\n\n\n\\item If you vary the number of the disks in the output images, do these implementations produce the same distribution in the final image? If not, why?\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/2-1.pdf}\n         \\caption{500 disks}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/2-2.pdf}\n         \\caption{2000 disks}\n    \\end{subfigure}\n    \\label{fig:1}\n        \\caption{Hedcuter}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/2-1.pdf}\n \\caption{500 disks}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/2-2.pdf}\n \\caption{2000 disks}\n    \\end{subfigure}\n    \\caption{Voronoi}\n    \\label{fig:2}\n\\end{figure}\n\nThe disk distributions are different between hedcuter and voronoi, as  hedcuter biases on darker region based on a Gaussian distribution, while voronoi is more of an uniform distribution. Vary the number of disks does not affect the distribution among both algorithm themselves as the distribution of random sampling is independent of how many samples your use.\n\n\\item If you vary the number of the disks in the output images, is a method faster than the other?\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figs/time2.eps}\n    \\caption{Threshold: hedcuter = 1, voronoi = 0.5}\n    \\end{subfigure}\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figs/time.eps}\n         \\caption{Threshold: hedcuter = 1, voronoi  = 0.14 }\n    \\end{subfigure}\n    \\label{fig:2}\n      \\caption{Running time vs number of disks.}\n\\end{figure}\n\nNo method is strictly superior to the other in terms of running time. As it depends on other parameters besides the number of disks. However, both methods seem to require less time to converge for larger number of disks.\n\n\\item Does the size (number of pixels), image brightness or contrast of image increase or decrease their difference?\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-5.pdf}\n         \\caption{Large image size}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-6.pdf}\n         \\caption{Small image size}\n    \\end{subfigure}\n    \\label{fig:1}\n        \\caption{Hedcuter}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-5.pdf}\n \\caption{Large image size}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-6.pdf}\n \\caption{Small image size}\n    \\end{subfigure}\n    \\caption{Voronoi}\n    \\label{fig:2}\n\\end{figure}\n\nThe sizes of the images have great impact on the size of the radius of the disks generated using  hedcuter method, while  voronoi method is consistent  to the variance of image size. Because hedcuter calcuate the average intensity of the cell and this will impacted by the cell size, while voronoi uses the max intensity of the cell.\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-3.pdf}\n         \\caption{High Brightness}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-4.pdf}\n         \\caption{Low Brightness}\n    \\end{subfigure}\n    \\label{fig:1}\n        \\caption{Hedcuter}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-3.pdf}\n \\caption{High Brightness}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-4.pdf}\n \\caption{Low Brightness}\n    \\end{subfigure}\n    \\caption{Voronoi}\n    \\label{fig:2}\n\\end{figure}\n\nBoth methods are affected greatly by the brightness of the image, as the darker pixels prevail the image. However, the hedcuter seems maintain a better consistency due to the way it calculate the disk radius.\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-1.pdf}\n         \\caption{High Contrast}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/3-2.pdf}\n         \\caption{Low Contrast}\n    \\end{subfigure}\n    \\label{fig:1}\n        \\caption{Hedcuter}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-1.pdf}\n \\caption{High Contrast}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/3-2.pdf}\n \\caption{Low Contrast}\n    \\end{subfigure}\n    \\caption{Voronoi}\n    \\label{fig:2}\n\\end{figure}\n\nContrast is not a major factor that would increase of decrease the difference between the two methods.\n\n\\item Does the type of image (human vs. machine, natural vs. urban landscapes, photo vs. painting, etc) increase or decrease their difference?\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/4-1.pdf}\n         \\caption{Phoenix}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/4-2.pdf}\n         \\caption{Gradient}\n    \\end{subfigure}\n        \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/4-3.pdf}\n         \\caption{Erinking}\n    \\end{subfigure}\n        \\caption{Hedcuter}\n            \\label{fig:type_h}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/4-1.pdf}\n \\caption{Phoenix}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/4-2.pdf}\n \\caption{Gradient}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/4-3.pdf}\n \\caption{Erinking}\n    \\end{subfigure}\n    \\caption{Voronoi}\n    \\label{fig:type_v}\n\\end{figure}\n\nBased the observation on \\ref{fig:type_h} and \\ref{fig:type_v}, different subjects in the image does not have much effect on the performance of the two methods.\n\n\\item Are the outputs of these stippling methods different the hedcut images created by artists (e.g. those from the Wall Street Journal)?\n\n\\begin{figure}[H]\n    \\centering\n     \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../images/obama.png}\n \\caption{Photo}\n    \\end{subfigure}\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figs/wsj-obama.jpg}\n \\caption{WSJ artist stippling}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/5-1.pdf}\n \\caption{Hedcuter}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/voronoi/5-1.pdf}\n \\caption{Voronoi}\n    \\end{subfigure}\n    \\caption{Comparison of WSJ artist stippling vs outputs of these stippling methods.}\n    \\label{fig:art}\n\\end{figure}\n\nClearly, both methods cannot create a stippling on par with the human art work, especially the the distribution of dots. The artist will strengthen the edge of the object and the stippling shows better contrast. These are all based on the semantic understanding of the object. The computer generated is pure base on each independent pixels and has nothing to do with the semantics.\n\n\\end{enumerate}\n\n\\section{Improvement of hedcuter method}\n\n\\subsection*{Improvement 1: Weighted Coloring}\nThe ideas is the pixel the centroid has larger weight in  determining the color of the disk than the pixels around the boundary.\nI employed  the following weighted method to improve coloring in Algorithm \\ref{alg:st_hed} Line 4.\n$$d.rgb =\\frac{\\sum_{p \\in c.P} {\\xi_p \\cdot M(p)} } {\\sum{\\xi_p}}$$\nwhere \n\\begin{eqnarray*}\n\\xi_p\n\\begin{cases}\n1, & \\text{if } p = p_c\\cr \n\\frac{1}{ \\text{euclidean\\_dist}(p,p_c)  }, & \\text{otherwise} \\cr\n\\end{cases}\n\\end{eqnarray*}\ngiven $p_c$ is the centroid of the cell containing $p$.\n\n\\begin{figure}[H]\n    \\centering\n            \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../images/lenna.png}\n \\caption{Input image: Lenna}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/A-1.pdf}\n \\caption{Disk color based on cell average}\n    \\end{subfigure}\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/A-2.pdf}\n \\caption{Disk color based on  weighted cell average}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/A-3.png}\n \\caption{Difference of (b) and (c)}\n    \\end{subfigure}\n    \\caption{Comparison of color based on average cell color vs. weight average cell color. }\n    \\label{fig:color}\n\\end{figure}\n\nThe results are shown in Figure \\ref{fig:color}, depending on the monitor, the color enhancement might be hard to tell. The different area of the two output are shown in \\ref{fig:color} (d).\n\n\\subsection*{Improvement 2: Disk Radius Based on Cell Area}\nI employed  the following weighted method to improve coloring in Algorithm \\ref{alg:st_hed} Line 6.\n$$d.r =\\frac{ r\\cdot \\text{area}(c) } { \\max_{c \\in C}{(\\text{area}(c) )}}$$\n\nThe results are shown in Figure \\ref{fig:radius}\n\n\\begin{figure}[H]\n    \\centering\n        \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/B-1.pdf}\n \\caption{Disk radius based on intensity}\n    \\end{subfigure}\n    \\begin{subfigure}{0.4\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/B-2.pdf}\n \\caption{Disk radius based on cell area}\n    \\end{subfigure}\n    \\caption{Comparison of disk radius based on intensity vs. disk radius based on cell area}\n    \\label{fig:radius}\n\\end{figure}\n\n\n\n\\subsection*{Improvement 3: Stippling Reconstruction}\n\nThe idea is that we can obtain a stippling image created by artist, like the Wall Street Journal ones that are printed on a piece of paper, then we digitize it by extracting the stippling points $(x,y)$ locations from a scanned copy. If we reconstruct a existing stippling, we can recreate many things like re-coloring based on an existing art work. \n\nI implemented this functionality in the following step\n\\begin{enumerate}\n\\item collect all dark pixels in the scanned stippling (greyscale) image.\n\\item run a Density-based spatial clustering of applications with noise (DBSCAN)\\cite{ester} on the extracted pixels locations, so that in the original image many dark pixels from the same disk are joined into one site.\n\\item build a voronoi diagram on  the sites obtained in the previous step.\n\\end{enumerate}\n\nTo show the result, I reconstructed a black and white stippling image and recolored it based on the reconstruction and the original photo. The results are shown in Figure \\ref{fig:rec} It is very difficult to obtain the original photo of a artist created stippling, so I just use voronoi method to generate a stippling then printed it in a image.\n\n\\begin{figure}[H]\n    \\centering\n            \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../images/phoenix_small.png}\n \\caption{Input photo}\n    \\end{subfigure}\n        \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../images/phoenix_stipple_small.png}\n \\caption{Input stippling image of (a)}\n    \\end{subfigure}\n    \\begin{subfigure}{0.3\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{../results/hedcuter/C-1.pdf}\n \\caption{Output of reconstructed stippling}\n    \\end{subfigure}\n    \\caption{Stippling reconstruction}\n    \\label{fig:rec}\n\\end{figure}\n\n\\section{Known Bugs and Limitations}\n\nThe stippling reconstruction only works for small number of stippling points, mainly due to the computational complexity of the DBSCAN clustering algorithm.\n\n\\bibliographystyle{plain}\n\\begin{thebibliography}{9}\n\\bibitem{secord} \nAdrian Secord. 2002. Weighted Voronoi stippling. In Proceedings of the 2nd international symposium on Non-photorealistic animation and rendering (NPAR '02). ACM, New York, NY, USA, 37-43.\n\n\\bibitem{ester}\nMartin Ester, Hans-Peter Kriegel, Jörg Sander, and Xiaowei Xu. 1996. A density-based algorithm for discovering clusters a density-based algorithm for discovering clusters in large spatial databases with noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD'96), Evangelos Simoudis, Jiawei Han, and Usama Fayyad (Eds.). AAAI Press 226-231.\n\n\\end{thebibliography}\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "6eb52fa8f2983232a082bdba346b9340373ce812", "size": 27122, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/report.tex", "max_stars_repo_name": "Yue-Hao/CS633", "max_stars_repo_head_hexsha": "01a3587454eceaa228834a1e0b091a031d985e7c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report/report.tex", "max_issues_repo_name": "Yue-Hao/CS633", "max_issues_repo_head_hexsha": "01a3587454eceaa228834a1e0b091a031d985e7c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/report.tex", "max_forks_repo_name": "Yue-Hao/CS633", "max_forks_repo_head_hexsha": "01a3587454eceaa228834a1e0b091a031d985e7c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.8005427408, "max_line_length": 389, "alphanum_fraction": 0.6783791756, "num_tokens": 8185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.4091345688431918}}
{"text": "\\section{A Basic Translation of MAPF to ASP}\nWe are now ready to describe our compilation of sum-of-costs MAPF to ASP. As we have mentioned above, this is the first compilation to ASP that handles sum-of-costs. Besides that aspect of novelty, the basic compilation that we present here is similar in many aspects to \\citeauthor{ErdemKOS13}'s compilation \\shortcite{ErdemKOS13} to ASP, and, in some aspects simlar to the MAPF-to-SAT compilation of \\acite{Surynek14}. Below we are specific about these similarities.\n\nAs most compilations of planning problems into SAT/ASP, the makespan of the compilation is a parameter, which below we call $\\mathtt{T}$.\n%\\begin{itemize}\n%    \\item $a$ refers to an agent.\n%    \\item $x,y$ refers to a position in the grid.\n%    \\item $m$ indicates a move or action. Where $m \\in \\{up,down,left,right,wait\\}$.\n%\\end{itemize}\n\n\\subsubsection{Atoms}\nWe use the following atoms:\n\\begin{itemize}\n\\item $agent(a)$: to express that $A$ is an agent,\n\\item $goal(a,x,y)$: specifies that the goal cell for agent $a$ is $(x,y)$,\n\\item $obstacle(x,y)$: specifies that cell $(x,y)$ is an obstacle,\n\\item $at(a,x,y,t)$: specifies that agent $a$ is at $(x,y)$ at time $t$,\n\\item $exec(a,m,t)$: specifies that agent $a$ executes move $m$ at time $t$,\n\\item $at\\_goal(a,t)$: specifies that agent $a$ is at the goal at time $t$,\n\\item $time(t)$: $t$ is a time instant,\n\\item $move(m)$: $m$ is a move.\n\\end{itemize}\nFinally, we use atoms $rangeX(x)$ and $rangeY(y)$ to specify that $(X,Y)$ is within the limits of the grid.\n\n\\subsubsection{Instance Specification}\nTo specify a particular MAPF instance, we define facts for atoms of the form $agent(a)$, for each $a\\in A$, $obstacle(x,y)$ for each $(x,y)$ that is marked as an obstacle in the grid, $rangeX(x)$ for each $x\\in\\{1,\\ldots,w\\}$, where $w$ is the width of the grid, and $rangeY(y)$ for each $y\\in\\{1,\\ldots,h\\}$, where $h$ is the height of the grid. Additionally, we define the initial cells for each agent, adding one fact of the form $at(a,x_a,y_a,0)$ for each agent $a\\in \\mathcal{A}$, where $(x_a,y_a)=init(a)$. Furthermore, we add an atom of the form $time(t)$ for every $t\\in\\{1,\\dots,\\mathtt{T}\\}$. The number of rules needed to encode a MAPF instance is therefore in $\\Theta(|\\mathcal{A}| + \\mathtt{T} + |V|)$.\n\n\\subsubsection{Effects}\nTo encode the effects of the five actions, we use a single rule written as follows:\n\\begin{equation}\\small\\label{encoding:effectsone}\n\\begin{split}\nat(A,X,Y,T) \\leftarrow &exec(A,M,T-1),\\\\&at(A,X',Y',T-1), \\\\&delta(M,X',Y',X,Y).\n\\end{split}\n\\end{equation}\nwhich specifies that if agent $A$ is at position $(X',Y')$ in time instant $T-1$, then it will be in position $(X,Y)$ in time instant $T$ iff $(X,Y)$ and $(X',Y')$ satisfy predicate $delta$. Auxiliary predicate $delta$ is used to establish a relation between $(X,Y)$ and $(X',Y')$ given a certain move $M$ in the following way:\n\\begin{equation}\\small\\label{encoding:delta}\n\\begin{split}\n&delta(\\Right,X,Y,X+1,Y) \\leftarrow rangeX(X), rangeY(Y),\\\\\n&delta(\\Left,X,Y,X-1,Y) \\leftarrow rangeX(X), rangeY(Y),\\\\\n&delta(\\Up,X,Y,X,Y+1) \\leftarrow rangeX(X), rangeY(Y),\\\\\n&delta(\\Down,X,Y,X,Y-1) \\leftarrow rangeX(X), rangeY(Y),\\\\\n&delta(\\Wait,X,Y,X,Y) \\leftarrow rangeX(X),rangeY(Y).\n\\end{split}\n\\end{equation}\nA grounding time predicate $delta$ results in 5 rules per each position of the grid. This defines that the total number of grounded instances for rule \\eqref{encoding:effectsone} is proportional to the size of the grid, the number of agents and the number of time instants. The total number of instances for rules of the form \\eqref{encoding:effectsone} and \\eqref{encoding:delta} is in $\\Theta(|\\mathcal{A}|\\cdot |V| \\cdot \\mathtt{T})$.\n\n\\subsubsection{Parallel move execution}\nWe need to encode that each agent performs exactly one move at each time instant. To do this we write the following rule:\n\\begin{equation}\\small\\label{encoding:delta}\n\\begin{split}\n|\\{exec(A,M,T-1) : move(M) \\}| = 1 \\leftarrow &time(T),\\\\&agent(A).\n\\end{split}\n\\end{equation}\nUpon grounding the number of instances of this rule is in $\\Theta(|\\mathcal{A}|\\cdot \\mathtt{T})$.\n\\subsubsection{Legal positions}\nWe need to express that the agents move through the vertices in the graph; that is, they cannot exit the grid or visit an obstacle cell. We do so using the following three rules:\n\\begin{equation}\\label{encoding:legal}\\small\n    \\begin{split}\n&\\leftarrow at(A,X,Y,T), not\\: rangeX(X),\\\\\n&\\leftarrow at(A,X,Y,T), not\\: rangeY(Y),\\\\\n&\\leftarrow at(A,X,Y,T), obstacle(X,Y). %no hay robots encima de obstaculos\n    \\end{split}\n\\end{equation}\nThe total number of grounded rules for the rules of form \\eqref{encoding:legal} is in $\\Theta(|\\mathcal{A}| \\cdot |V| \\cdot \\mathtt{T})$, since it depends on the number of atoms of the form $at$, $obstacle$, $rangeX$, and $rangeY$.\n\n\\subsubsection{Vertex Conflicts}\nTo express that no agents can be at the same vertex we use the following constraint, which is similar to those used in the encodings to ASP by \\acite{ErdemKOS13,GebserOOS18} and \\acite{SurynekFSB16}.\n\\begin{equation}\\small\\label{encoding:vertexone}\n    \\leftarrow at(A,X,Y,T), at(A',X,Y,T)\n\\end{equation}\nThe number of instances for this rule \\eqref{encoding:vertexone} after grounding is $\\Theta(|\\mathcal{A}|^2 \\cdot |V| \\cdot \\mathtt{T})$. Note that this is the first rule so far whose instantiation is quadratic on the number of agents. This motivates the improvement we present later in the following section.\n\\subsubsection{Swap Conflicts}\nNo pair of agents can swap their positions. We express this avoiding horizontal and vertical swaps using the following constraints.\n\\begin{equation}\\small\\label{encoding:swapone}\n  \\begin{split}\n        \\leftarrow &at(A,X+1,Y,T-1), at(A',X,Y,T-1),\\\\\n        &at(A,X,Y,T), at(A',X+1,Y,T). \\text{\\% horizontal swap} \\\\\n        \\leftarrow &at(A,X,Y+1,T-1), at(A',X,Y,T-1),\\\\\n        &at(A,X,Y,T), at(A',X,Y+1,T). \\text{\\% vertical swap}\n  \\end{split}\n\\end{equation}\nThe number of ground rules for \\eqref{encoding:swapone} is in $\\Theta(|\\mathcal{A}|^2 \\cdot |V| \\cdot \\mathtt{T})$.\n\n\\subsubsection{Goal Achievement}\nWe specify with a constraint that no agent is away from its goal at time $\\mathtt{T}$:\n\\begin{equation}\\small\\label{encoding:goal}\n  \\begin{split}\n&at\\_goal(A,T) \\leftarrow at(A,X,Y,T), goal(A,X,Y),\\\\\n&\\leftarrow agent(A), not \\; at\\_goal(A,\\mathtt{T}).\n\\end{split}\n\\end{equation}\nThe number of instances for rules \\eqref{encoding:goal} is $\\Theta(\\mathcal{A} \\cdot |V| \\cdot \\mathtt{T})$.\n\\subsubsection{Size of Basic Encoding}\nAfter grounding, it follows that the size of the total encoding is in $\\Theta(|\\mathcal{A}|^2 \\cdot |V| \\cdot \\mathtt{T})$. That is, it is quadratic in the number of agents, linear in the size of the grid, and linear in the makespan parameter $\\mathtt{T}$.\n", "meta": {"hexsha": "d7a42d2bc742d2656c201077f39784027081a275", "size": 6812, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aaai20/first_comp.tex", "max_stars_repo_name": "rkoco/lp-mapf", "max_stars_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aaai20/first_comp.tex", "max_issues_repo_name": "rkoco/lp-mapf", "max_issues_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aaai20/first_comp.tex", "max_forks_repo_name": "rkoco/lp-mapf", "max_forks_repo_head_hexsha": "8ffa93bd33feb244ac2db7230ea3b9ff2deb7038", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.7052631579, "max_line_length": 715, "alphanum_fraction": 0.7083088667, "num_tokens": 2081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4091345615091136}}
{"text": "\\chapter{Collective Communication}\n\\label{chapter:coll}\n\n\n\\input{operations}\n\nWhen the nodes of a distributed-memory architecture collaborate\nto solve a given problem, inherently computation previously\nperformed on a single node is now distributed among the nodes,\nand communication is performed when data is shared, or contributions from\ndifferent nodes must be consolidated.\nCommunication operations that simultaneously involve a group of nodes\nare called {\\em collective communication} operations.\nIn our discussions, we will assume that the group includes all nodes.\n\\plapack makes heavy use of collective communication,\nso its efficient implementation is crucial to attaining \nscalable and high performance.\n\nThe most typically encountered collective communications, discussed\nin this section, fall into two categories:\n\\begin{itemize}\n\\item\n{\\bf Data redistribution operations:}\nbroadcast, scatter, gather, and allgather.\nThese operations move data between processors.\n\\item\n{\\bf Data consolidation operations:}\nreduce(-to-one), reduce-scatter, and allreduce.\nThese operations consolidate contributions from different processors\nby applying a reduction operation.\nWe will only consider reduction operations that are both commutative\nand associative.\n\\end{itemize}\nThe operations discussed are illustrated in Fig.~\\ref{fig:operations}.\nIn that figure, $ x $ indicates a vector of data of length $ n $.\nFor some operations, $ x $ is subdivided into subvectors\n$ x_i $, $ i = 0, \\cdots, p-1 $, where $ p $ equals the number of nodes.\nA superscript is used to indicate a vector that must be reduced\nwith other vectors from other nodes.  $ \\sum_{j} x^{(j)} $ indicates the\nresult of that reduction.\nThe summation sign is used because summation is the\nmost commonly encountered reduction operation.\n\nWe present these collective communications as pairs of\n{\\em dual} operation.  We will show later that an implementation\nof one of the dual operations can be transformed into that of the other dual\noperation by reversing the communication (and adding to or deleting\nreduction operations from the implementation).  These dual pairs are indicated\nby the groupings in Fig.~\\ref{fig:operations} (separated by the thick lines):\n{broadcast and reduce(-to-one)},\n{scatter and gather}, and\n{allgather and reduce-scatter}.\n{Allreduce} is the only operation that does not have a dual\n(or it can be viewed as its own dual).\n", "meta": {"hexsha": "d36191a2a744ae8b66878d47de3a281e92c03842", "size": 2412, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/libflame/old/30-coll.tex", "max_stars_repo_name": "haampie/libflame", "max_stars_repo_head_hexsha": "a6b27af9b7ef91ec2724b52c7c09b681379a3470", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 199, "max_stars_repo_stars_event_min_datetime": "2015-02-06T06:05:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T05:20:33.000Z", "max_issues_repo_path": "docs/libflame/old/30-coll.tex", "max_issues_repo_name": "haampie/libflame", "max_issues_repo_head_hexsha": "a6b27af9b7ef91ec2724b52c7c09b681379a3470", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 44, "max_issues_repo_issues_event_min_datetime": "2015-05-10T18:14:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-22T08:22:10.000Z", "max_forks_repo_path": "docs/libflame/old/30-coll.tex", "max_forks_repo_name": "haampie/libflame", "max_forks_repo_head_hexsha": "a6b27af9b7ef91ec2724b52c7c09b681379a3470", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-02-07T04:53:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T05:20:36.000Z", "avg_line_length": 43.8545454545, "max_line_length": 78, "alphanum_fraction": 0.7968490879, "num_tokens": 517, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011397337391, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4091345550582965}}
{"text": "\\documentclass[compress,9pt]{beamer} % TALK\n\n\\usepackage{pgfpages}\n\n%\\setbeameroption{hide notes} % solo muestra la presentación.\n%\\setbeameroption{show only notes} % solo muestras las notas.\n%\\setbeameroption{show notes on second screen=right} % presentación el doble de ancha que contiene las diapositivas y las notas. \n\n\n\\usepackage{tikz}   %TikZ is required for this to work.  Make sure this exists before the next line\n\n\\usepackage{tikz-3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation\n\n\\usetikzlibrary{babel}\n\n% tikz-3dplot-circleofsphere: To draw 3D spheres ----------\n\\usepackage{tikz-3dplot-circleofsphere} %requires tikz-3dplot-circleofsphere to be in same directory, or in your LaTeX installation\n\n\n\n\\begin{document}\n\t\n\t\\section{Physics: Newton's and Kepler's dynamics.}\n\t\\begin{frame}[fragile,label={frm:newtonGravit}]{Newton's law of universal gravitation}\n\t\t%requires tikz-3dplot-circleofsphere to be in same directory, or in your LaTeX installation\n\t\t% Figure: Universal gravity law\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t% Select a perspective\n\t\t\t\\tdplotsetmaincoords{75}{115}\n\t\t\t\\begin{tikzpicture}[scale=1,tdplot_main_coords,>=latex,line join=bevel]\n\t\t\t% Parameters ---------------------\n\t\t\t% Coordinates parameters\n\t\t\t\\pgfmathsetmacro{\\sizeCoordX}{5.2*.6}\n\t\t\t\\pgfmathsetmacro{\\sizeCoordY}{5.2*.6}\n\t\t\t\\pgfmathsetmacro{\\sizeCoordZ}{4.2*.6}\n\t\t\t\\coordinate (O) at (0,0,0);\n\t\t\t\n\t\t\t% m satellite position parameters\n\t\t\t\\pgfmathsetmacro{\\mx}{.7 * \\sizeCoordX}\n\t\t\t\\pgfmathsetmacro{\\my}{0.9 * \\sizeCoordY}\n\t\t\t\\pgfmathsetmacro{\\mz}{0.7 * \\sizeCoordZ}\n\t\t\t\n\t\t\t% It is very important to get redundant parenthesis\n\t\t\t% Radius = rho\n\t\t\t\\pgfmathsetmacro{\\mr}{sqrt{((\\mx)^2 + (\\my)^2 + (\\mz)^2)}}\n\t\t\t% theta = epsilon\n\t\t\t% \\pgfmathsetmacro{\\mEpsilon}{acos{ ( (\\mz)/(\\mr) ) }}\n\t\t\t\\pgfmathsetmacro{\\mEpsilon}{atan{(sqrt{((\\mx)^2 + (\\my)^2)}/(\\mz))}}\n\t\t\t% phi = alpha\n\t\t\t\\pgfmathsetmacro{\\mAlpha}{atan{((\\my) / (\\mx))}}\n\t\t\t% polar angle = beta\n\t\t\t\\pgfmathsetmacro{\\mBeta}{atan{((\\mz) / (sqrt{((\\mx)^2 + (\\my)^2)}))}}\n\t\t\t\n\t\t\t% Debug info\n\t\t\t% \\node [label={right:\\mr}] at (0, 0, -3) {mr};\n\t\t\t% \\node [label={right:\\mEpsilon}] at (0, 0, -4) {mEpsilon};\n\t\t\t% \\node [label={right:\\mAlpha}] at (0, 0, -5) {mAlpha};\n\t\t\t% \\node [label={right:\\mBeta}] at (0, 0, -6) {mBeta};\n\t\t\t\n\t\t\t% Little mass size\n\t\t\t\\pgfmathsetmacro{\\mSize}{15}\n\t\t\t\n\t\t\t% M Earth parameters\n\t\t\t\\pgfmathsetmacro{\\radiusXY}{.22 * \\sizeCoordX}\n\t\t\t\\pgfmathsetmacro{\\radiusZ}{.19 * \\sizeCoordX}\n\t\t\t\n\t\t\t% Fg parameters\n\t\t\t\\pgfmathsetmacro{\\FgX}{.3 * \\mx}\n\t\t\t\\pgfmathsetmacro{\\FgY}{.3 * \\my}\n\t\t\t\\pgfmathsetmacro{\\FgZ}{.3 * \\mz}\n\t\t\t\n\t\t\t% Figures ---------------------\n\t\t\t% Circle M Earth.\n\t\t\t\\begin{scope}\n\t\t\t\\filldraw[tdplot_screen_coords, gray!30] (0,0,0) circle (\\radiusXY);\n\t\t\t\\tdplotCsDrawLatCircle[gray]{\\radiusXY}{0}\n\t\t\t\\end{scope}\n\t\t\t%\\node [label={left:$M_\\oplus$}] at (0,-\\radiusXY,\\radiusZ) {};\n\t\t\t\\node [anchor=south east] {$M_\\oplus$};\n\t\t\t\n\t\t\t% Circle m satellite.\n\t\t\t\\node [draw, circle, fill=gray!30, minimum size = \\mSize, label=above:$m$] at (\\mx, \\my, \\mz) {};\n\t\t\t\n\t\t\t% Satellite trajectory\n\t\t\t\\tdplotCsDrawCircle[blue]{\\mr}{\\mAlpha}{-\\mBeta}{0}\n\t\t\t\\node [label={[blue]south east:Orbital plane}] at (0,\\my,\\mz) {};\n\t\t\t% Coordinates\n\t\t\t\\draw[thick,->] (O) -- (\\sizeCoordX,0,0) node[anchor=north east]{$x$};\n\t\t\t\\draw[thick,->] (O) -- (0,\\sizeCoordY,0) node[anchor=north west]{$y$};\n\t\t\t\\draw[thick,->] (O) -- (0,0,0.8\n\t\t\t7*\\sizeCoordZ) node[anchor=south]{$z$};\n\t\t\t\\draw[dashed] (O) -- (-0.7*\\sizeCoordX,0,0);\n\t\t\t\\draw[dashed] (O) -- (0,-0.7*\\sizeCoordY,0);\n\t\t\t% \\draw[dashed] (O) -- (0,0,-\\sizeCoordZ);\n\t\t\t\n\t\t\t% Satellite\n\t\t\t% r vector\n\t\t\t\\draw[-stealth,color=blue,very thick] (0,0,0) -- (\\mx,\\my,\\mz);\n\t\t\t\\node [label={[blue]left:$\\mathbf{r}$}] at (\\mx/2, \\my/2, \\mz/2) {};\n\t\t\t% r Projection\n\t\t\t\\draw[dotted] (0,0,0) -- (\\mx,\\my,0) --  (\\mx,\\my,\\mz);\n\t\t\t\\draw[dotted] (\\mx,0,0) -- (\\mx,\\my,0) node[anchor=north east]{Equatorial plane};\n\t\t\t\\draw[dotted] (\\mx,\\my,0) -- (0,\\my,0);\n\t\t\t\n\t\t\t% F_g vector\n\t\t\t\\draw[-stealth,color=blue,very thick] \n\t\t\t(\\FgX+\\mx, \\FgY+\\my, \\FgZ+\\mz) -- (\\mx, \\my, \\mz);\n\t\t\t% \\node [label={[shift={(\\mx+\\Fg/2, \\my+\\Fg/2, \\mz+\\Fg/2)}]$\\mathbf{F_g}$}] {};\n\t\t\t% \\node [label={[blue]right:$\\mathbf{F_g}$}] at (\\mx+\\FgX,\\my+\\FgY,\\mz+\\FgZ) {};\n\t\t\t\\node [label={[blue]$\\mathbf{F_g}$}] at (\\mx+\\FgX,\\my+\\FgY,\\mz+\\FgZ) {};\n\t\t\t\\end{tikzpicture}\n\t\t\t%\\caption{Newton's law of universal gravitation.} \\label{fig:NewtonLaw}\n\t\t\\end{figure}\n\t\t% Show equation\n\t\t\\begin{equation}\\label{eq:newton_gravity}\n\t\t\\text{Newton's law of universal gravitation: } \\mathbf{F_g} = -G\\frac{{M_\\oplus}{m}}{{r^2}}\\left(\\frac{\\mathbf{r}}{r}\\right)\n\t\t\\end{equation}\n\t\\end{frame}\n\t\n\t\n\t\\begin{frame}[fragile]{Kepler's second law}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t% Author: https://tex.stackexchange.com/questions/122122/best-way-to-illustrate-keplers-2nd-law-with-tikz\n\t\t\t% We define the orbit as a macro because we will use it twice, first for clipping and then\n\t\t\t% to actually draw the ellipse. This way we avoid inconsistencies.\n\t\t\t\\def\\orbit{(1.5,0) ellipse(2.5cm and 2cm)}\n\t\t\t\n\t\t\t\\begin{tikzpicture}\n\t\t\t\\fill (3,0) coordinate (O) circle (5pt) node[below left =7pt] {$M_\\oplus$};%\n\t\t\t\n\t\t\t\\coordinate (m1) at (0.90,2.30);\n\t\t\t\\coordinate (m2) at (0.65,1.90);\n\t\t\t\\coordinate (m3) at (3.5,-2.2);\n\t\t\t\\coordinate (m4) at (4.0,-0.4);\n\t\t\t% Show m\n\t\t\t\\fill (m2) circle (2pt) node[above left] {$m$};%\n\t\t\t\n\t\t\t% The gray shaded regions\n\t\t\t\\begin{scope}\n\t\t\t\\clip \\orbit;\n\t\t\t\\filldraw[fill=gray!40,opacity=0.5] (O) -- (m1) -- (m2) -- cycle;\n\t\t\t\\filldraw[fill=gray!40,opacity=0.5] (O) -- (m3) -- (m4) -- cycle;\n\t\t\t\\end{scope}\n\t\t\t\n\t\t\t% The ellipse\n\t\t\t\\draw \\orbit;\n\t\t\t% major and minor axis\n\t\t\t\\draw[dashed] (1.5,0) coordinate (M) --node[above]{$a$}  (-1.0,0);\n\t\t\t\\draw[dashed] (1.5,-2.0) -- (M) node[below left]{$b$};\n\t\t\t% true anomaly: nu\n\t\t\t\\draw[-stealth,blue] (3.5,0) arc (0:140:0.5)node[above right]{$\\nu$};\n\t\t\t\\draw[dotted] (3,0) -- (4,0);\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Kepler's second law.}%\\label{fig:Kepler2Law}\n\t\t\\end{figure}\n\t\\end{frame}\n\t\n\t% Orbital elements or Keplerian elements\n\t\\begin{frame}[fragile,label={frm:elipse+}]\n\t\t% \n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\def\\r{3.5}\n\t\t\t\\pgfmathsetmacro{\\inclination}{35}\n\t\t\t\\pgfmathsetmacro{\\nuSatellite}{55}\n\t\t\t\\pgfmathsetmacro{\\gammaAngle}{290}\n\t\t\t\n\t\t\t\\tdplotsetmaincoords{70}{165}\n\t\t\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\t\\onslide<1->{\n\t\t\t\t\\fill (0,0) coordinate (O) circle (5pt) node[left =7pt] {$M_\\oplus$};\n\t\t\t\t\n\t\t\t\t% Draw equatorial ellipse\n\t\t\t\t%\\tdplotdrawarc[thin]{(0,0,0)}{\\r}{-90}{205}{label={[xshift=-3.7cm, yshift=0.9cm]Equatorial plane}}{}\n\t\t\t\t%\\tdplotdrawarc[dotted]{(0,0,0)}{\\r}{205}{270}{}{}\n\t\t\t\t% Draw equatorial plane\n\t\t\t\t\\draw[] (0,-\\r,0) -- (\\r,-\\r,0)  node[below]{Equatorial plane} -- (\\r,\\r,0) -- (-\\r,\\r,0) -- (-\\r,-0.65*\\r,0);\n\t\t\t\t\\draw[dotted] (-\\r,-0.65*\\r,0) -- (-\\r,-\\r,0) -- (0,-\\r,0);\n\t\t\t\t\n\t\t\t\t% Draw ellipses intersection. Line of nodes\n\t\t\t\t\\draw[dashed] (0,-1.3*\\r,0) -- (0,1.3*\\r,0) node[right] {Line of nodes};\n\t\t\t\t% Draw gamma direction\n\t\t\t}\n\t\t\t\n\t\t\t\\onslide<2->{\n\t\t\t\t% Set gamma direction\n\t\t\t\t\\tdplotsetcoord{Pg}{1.3*\\r}{90}{\\gammaAngle}\n\t\t\t\t\\draw[->] (0,0,0) -- (Pg) node[anchor=east] {Direcc. de referencia $\\boldsymbol{\\gamma}$};\n\t\t\t}\n\t\t\t\\onslide<1->{\n\t\t\t\t% Create a new rotated system in the center\n\t\t\t\t\\tdplotsetrotatedcoords{0}{\\inclination}{90}\n\t\t\t\t\n\t\t\t\t% Draw orbital ellipse\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,thin,blue]{(0,0,0)}{\\r}{-125}{180}{label={[xshift=-5.7cm, yshift=-2.2cm]Orbital plane}}{}\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,dotted,blue]{(0,0,0)}{\\r}{180}{235}{}{}\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t% Define m position\n\t\t\t\t\\pgfmathsetmacro{\\omegaSatellite}{90}\n\t\t\t\t\\pgfmathsetmacro{\\xmRot}{\\r*cos(\\omegaSatellite+\\nuSatellite)}\n\t\t\t\t\\pgfmathsetmacro{\\ymRot}{\\r*sin(\\omegaSatellite+\\nuSatellite)}\n\t\t\t\t\\pgfmathsetmacro{\\zmRot}{0}\n\t\t\t\t% Draw a vector to m\n\t\t\t\t\\draw[tdplot_rotated_coords,thin,->,blue] (0,0,0) -- (\\xmRot,\\ymRot,\\zmRot);\n\t\t\t\t% Draw a mass\n\t\t\t\t\\filldraw[tdplot_rotated_coords, blue] (\\xmRot,\\ymRot,\\zmRot) circle (2pt) node[above left] {$m$};\n\t\t\t}\n\t\t\t\\onslide<5->{\n\t\t\t\t% Draw periapsis line\n\t\t\t\t\\draw[dashed,tdplot_rotated_coords,blue] (0,0,0) -- (0,\\r,0) node[anchor=south west] {Periapsis};\n\t\t\t}\n\t\t\t\\onslide<5->{\n\t\t\t\t% Draw omega angle\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,thick,-stealth,blue]{(0,0,0)}{0.4*\\r}{0}{\\omegaSatellite}{anchor=south west}{$\\omega$}\n\t\t\t\t% Draw nu angle\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,thick,-stealth,blue]{(0,0,0)}{0.4*\\r}{\\omegaSatellite}{\\omegaSatellite+\\nuSatellite}{anchor=south west}{$\\nu$}\n\t\t\t}\n\t\t\t\\onslide<3->{\n\t\t\t\t% Create rotated shifted system at (0,\\r,0)\n\t\t\t\t\\tdplotresetrotatedcoordsorigin\n\t\t\t\t\\tdplotsetrotatedcoords{0}{0}{180}\n\t\t\t\t% Draw \\Omega\n\t\t\t\t% Hidden part of the arc\n\t\t\t\t%% \\tdplotdrawarc[tdplot_rotated_coords,dashed,thick,brown]{(0,0,0)}{0.4*\\r}{0}{90}{anchor=south}{}%{$\\Omega$}\n\t\t\t\t% Visible part of the arc\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,thick,-stealth,brown]{(0,0,0)}{0.4*\\r}{\\gammaAngle-180}{270}{anchor=north east}{$\\Omega$}\n\t\t\t\t% Shift the rotated coordinates\n\t\t\t\t\\coordinate (Shift) at (0,\\r,0);\n\t\t\t\t\\tdplotsetrotatedcoordsorigin{(Shift)}\n\t\t\t\t% \\draw[thick,tdplot_rotated_coords,->,blue] (0,0,0) -- (.5,0,0) node[anchor=north west]{$x_2$};\n\t\t\t\t% \\draw[thick,tdplot_rotated_coords,->,blue] (0,0,0) -- (0,.5,0) node[anchor=north]{$y_2$};\n\t\t\t\t% \\draw[thick,tdplot_rotated_coords,->,blue] (0,0,0) -- (0,0,.5) node[anchor=south west]{$z_2$};\n\t\t\t}\n\t\t\t\\onslide<4->{\n\t\t\t\t% Draw inclination angle\n\t\t\t\t\\tdplotsetrotatedthetaplanecoords{0}\n\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,thick,-stealth,brown]{(Shift)}{0.3*\\r}{90}{90-\\inclination}{anchor=west}{$i$}\n\t\t\t}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Orbital elements or Keplerian elements}\\label{fig:elipseNodos2}\n\t\t\\end{figure}\t\n\t\\end{frame}\n\t\n\t\\section{Rotate a box around some axes.}\n\t\\begin{frame}{Rotate box around $X$ axis.}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\def\\r{3.5}\n\t\t\t\\pgfmathsetmacro{\\alphaNextBox}{90}\n\t\t\t\\pgfmathsetmacro{\\betaNextBox}{-55}\n\t\t\t\\pgfmathsetmacro{\\gammaNextBox}{-90}\n\t\t\t%%% \\pgfmathsetmacro{\\inclination}{70}\n\t\t\t\\pgfmathsetmacro{\\alphaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\betaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\gammaEuler}{47}\n\t\t\t\n\t\t\t\\tdplotsetmaincoords{70}{120}\n\t\t\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\t% Drawing XYZ coordinates system\n\t\t\t\\def \\lenX {1.0*\\r}\n\t\t\t\\def \\lenY {1.3*\\r}\n\t\t\t\\def \\lenZ {1.0*\\r}\n\t\t\t\\def \\boxX{.7*\\r}\n\t\t\t\\def \\boxY{.9*\\r}\n\t\t\t\\def \\boxZ{.2*\\r}\n\t\t\t% Calculate box corner length\n\t\t\t\\pgfmathsetmacro{\\boxCornerLen}{sqrt{((\\boxX)^2 + (\\boxY)^2 + (\\boxZ)^2)}}\n\t\t\t% Draw coordinate system\n\t\t\t\\draw[dashed] (0,0,0) -- (\\boxX,0,0);\n\t\t\t\\draw[->,thick] (\\boxX,0,0) -- (\\lenX,0,0) node[left] {$X$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\\draw[->,thick] (0,\\boxY,0) -- (0,\\lenY,0) node[anchor=north west] {$Y$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t\\draw[->,thick] (0,0,0.6*\\lenZ) -- (0,0,\\lenZ) node[anchor=south] {$Z$};\n\t\t\t% Draw gravity vector\n\t\t\t\\draw[-stealth,thin] (-0.8*\\r,1.1*\\r,0) -- (-0.8*\\r,1.1*\\r,-.3*\\r) node[anchor=south west] {$\\mathbf{g}$};\n\t\t\t\n\t\t\t% Drawing horizontal box:\n\t\t\t% Get corner polar coordinate\n\t\t\t\\tdplotgetpolarcoords{\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\tdplotsetcoord{Box}{\\boxCornerLen}{\\tdplotrestheta}{\\tdplotresphi}\n\t\t\t% Draw a box\n\t\t\t% \\draw[] (O) -- (Boxx);\n\t\t\t% \\draw[] (O) -- (Boxy);\n\t\t\t% \\draw[] (O) -- (Boxz);\n\t\t\t\\draw[] (Boxx) -- (Boxxy);\n\t\t\t\\draw[] (Boxy) -- (Boxxy);\n\t\t\t\\draw[] (Boxx) -- (Boxxz);\n\t\t\t\\draw[] (Boxz) -- (Boxxz);\n\t\t\t\\draw[] (Boxy) -- (Boxyz);\n\t\t\t\\draw[] (Boxz) -- (Boxyz);\n\t\t\t\\draw[] (Boxxy) -- (Box);\n\t\t\t\\draw[] (Boxxz) -- (Box);\n\t\t\t\\draw[] (Boxyz) -- (Box);\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center\n\t\t\t\\tdplotsetrotatedcoords{\\alphaEuler}{\\betaEuler}{\\gammaEuler}\n\t\t\t% Draw new coordinates system\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (1.4*\\boxX,0,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (1.4*\\boxX,0,0) -- (1.3*\\lenX,0,0) node[anchor=north east]{$E$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0.7*\\boxY,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0.7*\\boxY,0) -- (0,0.8*\\lenY,0) node[anchor=south west]{$\\mathbf{N}$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0,0.6*\\lenZ) -- (0,0,0.8*\\lenZ) node[anchor=north east]{$Z$};\n\t\t\t\\pause\n\t\t\t% Rotating box around X axis:\n\t\t\t% Create a new rotated system in the center.\n\t\t\t\\tdplotsetrotatedcoords{\\alphaNextBox}{\\betaNextBox}{\\gammaNextBox}\n\t\t\t% Draw a box in the  new coordinates system\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,0) -- (\\boxX,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,0) -- (0,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (0,\\boxY,0) -- (0,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,\\boxY,\\boxZ) -- (0,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,0,\\boxZ) -- (\\boxX,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,\\boxZ) -- (\\boxX,0,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,0) -- (\\boxX,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,\\boxZ) -- (\\boxX,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,\\boxZ) -- (0,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,\\boxZ) -- (\\boxX,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,0,\\boxZ) -- (0,0,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\n\t\t\t\\tdplotsetrotatedcoordsorigin{(Shift)}\n\t\t\t% Shift the rotated coordinates\n\t\t\t\\coordinate (Shift) at (\\boxX,0,0);\n\t\t\t% Draw rotation\n\t\t\t\\tdplotsetthetaplanecoords{90}\n\t\t\t% \\tdplotdrawarc[coordinate system, draw styles]{center}{r}{angle start}{angle end}{label options}{label}\n\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,gray,thick,dotted,<->]{(Shift)}{\\boxY}{90}{90+\\betaNextBox}{anchor=west}{} \n\t\t\t\n\t\t\t% Resets the origin of the rotated coordinate system back to the origin of the main coordinate system.\n\t\t\t%\\tdplotresetrotatedcoordsorigin\n\t\t\t\\coordinate (Shift) at (0,0,0);\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{figure}\n\t\\end{frame}\n\t\n\t\n\t\\begin{frame}[fragile]{Rotate box around $Y$ axis.}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\def\\r{3.5}\n\t\t\t\\pgfmathsetmacro{\\alphaNextBox}{0}%{90}\n\t\t\t\\pgfmathsetmacro{\\betaNextBox}{-50}%{-55}\n\t\t\t\\pgfmathsetmacro{\\gammaNextBox}{0}%{-90}\n\t\t\t%%% \\pgfmathsetmacro{\\inclination}{70}\n\t\t\t\\pgfmathsetmacro{\\alphaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\betaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\gammaEuler}{47}\n\t\t\t\n\t\t\t\\tdplotsetmaincoords{70}{120}\n\t\t\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\t% Drawing XYZ coordinates system\n\t\t\t\\def \\lenX {1.0*\\r}\n\t\t\t\\def \\lenY {1.3*\\r}\n\t\t\t\\def \\lenZ {1.0*\\r}\n\t\t\t\\def \\boxX{.7*\\r}\n\t\t\t\\def \\boxY{.9*\\r}\n\t\t\t\\def \\boxZ{.2*\\r}\n\t\t\t% Calculate box corner length\n\t\t\t\\pgfmathsetmacro{\\boxCornerLen}{sqrt{((\\boxX)^2 + (\\boxY)^2 + (\\boxZ)^2)}}\n\t\t\t% Draw coordinate system\n\t\t\t\\draw[dashed] (0,0,0) -- (\\boxX,0,0);\n\t\t\t\\draw[->,thick] (\\boxX,0,0) -- (\\lenX,0,0) node[left] {$X$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\\draw[->,thick] (0,\\boxY,0) -- (0,\\lenY,0) node[anchor=north west] {$Y$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t\\draw[->,thick] (0,0,0.6*\\lenZ) -- (0,0,\\lenZ) node[anchor=south] {$Z$};\n\t\t\t% Draw gravity vector\n\t\t\t\\draw[-stealth,thin] (-0.8*\\r,1.1*\\r,0) -- (-0.8*\\r,1.1*\\r,-.3*\\r) node[anchor=south west] {$\\mathbf{g}$};\n\t\t\t\n\t\t\t% Drawing horizontal box:\n\t\t\t% Get corner polar coordinate\n\t\t\t\\tdplotgetpolarcoords{\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\tdplotsetcoord{Box}{\\boxCornerLen}{\\tdplotrestheta}{\\tdplotresphi}\n\t\t\t% Draw a box\n\t\t\t% \\draw[] (O) -- (Boxx);\n\t\t\t% \\draw[] (O) -- (Boxy);\n\t\t\t% \\draw[] (O) -- (Boxz);\n\t\t\t\\draw[] (Boxx) -- (Boxxy);\n\t\t\t\\draw[] (Boxy) -- (Boxxy);\n\t\t\t\\draw[] (Boxx) -- (Boxxz);\n\t\t\t\\draw[] (Boxz) -- (Boxxz);\n\t\t\t\\draw[] (Boxy) -- (Boxyz);\n\t\t\t\\draw[] (Boxz) -- (Boxyz);\n\t\t\t\\draw[] (Boxxy) -- (Box);\n\t\t\t\\draw[] (Boxxz) -- (Box);\n\t\t\t\\draw[] (Boxyz) -- (Box);\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center\n\t\t\t\\tdplotsetrotatedcoords{\\alphaEuler}{\\betaEuler}{\\gammaEuler}\n\t\t\t% Draw new coordinates system\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (1.4*\\boxX,0,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (1.4*\\boxX,0,0) -- (1.3*\\lenX,0,0) node[anchor=north east]{$E$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0.7*\\boxY,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0.7*\\boxY,0) -- (0,0.8*\\lenY,0) node[anchor=south west]{$\\mathbf{N}$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0,0.6*\\lenZ) -- (0,0,0.8*\\lenZ) node[anchor=north east]{$Z$};\n\t\t\t\\pause\n\t\t\t% Rotating box around one new axis:\n\t\t\t% Create a new rotated system in the center.\n\t\t\t\\tdplotsetrotatedcoords{\\alphaNextBox}{\\betaNextBox}{\\gammaNextBox}\n\t\t\t% Draw a box in the  new coordinates system\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,0) -- (\\boxX,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,0) -- (0,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (0,\\boxY,0) -- (0,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,\\boxY,\\boxZ) -- (0,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,0,\\boxZ) -- (\\boxX,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,\\boxZ) -- (\\boxX,0,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,0) -- (\\boxX,0,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,\\boxZ) -- (\\boxX,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,\\boxZ) -- (0,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,\\boxZ) -- (\\boxX,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,dashed,gray] (0,0,\\boxZ) -- (0,0,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (0,0,0) -- (\\boxX,0,0);\n\t\t\t\n\t\t\t\\tdplotsetthetaplanecoords{0}\n\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,gray,thick,dotted,<->]{(0,0,0)}{\\boxX}{90}{90+\\betaNextBox}{anchor=west}{}\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\t%\\caption{Giros en torno al eje $X$ para comprobar el comportamiento distorsionado de la brújula.}\\label{fig:rollRotation}\n\t\t\\end{figure}\n\t\\end{frame}\n\t\n\t\\begin{frame}[fragile]{Rotate a box around $Z$ axis}\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\def\\r{3.5}\n\t\t\t\\pgfmathsetmacro{\\alphaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\betaEuler}{0}\n\t\t\t\\pgfmathsetmacro{\\gammaEuler}{47}\n\t\t\t\n\t\t\t\\pgfmathsetmacro{\\nuSatellite}{55}\n\t\t\t\\pgfmathsetmacro{\\gammaAngle}{290}\n\t\t\t\n\t\t\t%\\tdplotsetmaincoords{70}{155}\n\t\t\t\\tdplotsetmaincoords{70}{120}\n\t\t\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\t% Draw ENZ coordinates system\n\t\t\t\\def \\lenX {1.0*\\r}\n\t\t\t\\def \\lenY {1.3*\\r}\n\t\t\t\\def \\lenZ {0.5*\\r}\n\t\t\t\\def \\boxX{.7*\\r}\n\t\t\t\\def \\boxY{.9*\\r}\n\t\t\t\\def \\boxZ{.2*\\r}\n\t\t\t\n\t\t\t% Calculate box corner length\n\t\t\t\\pgfmathsetmacro{\\boxCornerLen}{sqrt{((\\boxX)^2 + (\\boxY)^2 + (\\boxZ)^2)}}\n\t\t\t% Draw coordinate system\n\t\t\t\\draw[dashed] (0,0,0) -- (\\boxX,0,0);\n\t\t\t\\draw[->,thick] (\\boxX,0,0) -- (\\lenX,0,0) node[left] {$E$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\\draw[->,thick] (0,\\boxY,0) -- (0,\\lenY,0) node[anchor=north west] {$\\mathbf{N}$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t\\draw[->,thick] (0,0,0.6*\\lenZ) -- (0,0,\\lenZ) node[anchor=south] {$Z$};\n\t\t\t% Draw gravity vector\n\t\t\t\\draw[-stealth,thin] (-0.8*\\r,1.1*\\r,0) -- (-0.8*\\r,1.1*\\r,-.3*\\r) node[anchor=south west] {$\\mathbf{g}$};\n\t\t\t\n\t\t\t% Drawing horizontal box:\n\t\t\t% Get corner polar coordinate\n\t\t\t\\tdplotgetpolarcoords{\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\tdplotsetcoord{Box}{\\boxCornerLen}{\\tdplotrestheta}{\\tdplotresphi}\n\t\t\t% Draw a box\n\t\t\t% \\draw[] (O) -- (Boxx);\n\t\t\t% \\draw[] (O) -- (Boxy);\n\t\t\t% \\draw[] (O) -- (Boxz);\n\t\t\t\\draw[] (Boxx) -- (Boxxy);\n\t\t\t\\draw[] (Boxy) -- (Boxxy);\n\t\t\t\\draw[] (Boxx) -- (Boxxz);\n\t\t\t\\draw[] (Boxz) -- (Boxxz);\n\t\t\t\\draw[] (Boxy) -- (Boxyz);\n\t\t\t\\draw[] (Boxz) -- (Boxyz);\n\t\t\t\\draw[] (Boxxy) -- (Box);\n\t\t\t\\draw[] (Boxxz) -- (Box);\n\t\t\t\\draw[] (Boxyz) -- (Box);\n\t\t\t\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center\n\t\t\t\\tdplotsetrotatedcoords{\\alphaEuler}{\\betaEuler}{\\gammaEuler}\n\t\t\t% Draw a box in the  new coordinates system\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,0) -- (\\boxX,\\boxY,0) -- (0,\\boxY,0) -- (0,\\boxY,\\boxZ) -- (0,0,\\boxZ) -- (\\boxX,0,\\boxZ) -- (\\boxX,0,0);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,0,\\boxZ) -- (\\boxX,\\boxY,\\boxZ) -- (0,\\boxY,\\boxZ);\n\t\t\t\\draw[tdplot_rotated_coords,gray] (\\boxX,\\boxY,\\boxZ) -- (\\boxX,\\boxY,0);\n\t\t\t% Draw new coordinates system\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) -- (\\boxX,0,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,gray] (\\boxX,0,0) -- (1.3*\\lenX,0,0) node[anchor=north east]{$X$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) -- (0,\\boxY,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,gray] (0,\\boxY,0) -- (0,1.3*\\lenY,0) node[anchor=south west]{$Y$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) -- (0,0,\\boxZ);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,gray] (0,0,\\boxZ) -- (0,0,0.8*\\lenZ) node[anchor=north west]{$Z$};\n\t\t\t% Draw rotation\n\t\t\t% \\tdplotdrawarc[coordinate system, draw styles]{center}{r}{angle start}{angle end}{label options}{label}\n\t\t\t\\tdplotdrawarc[thick,dotted,<->]{(0,0,0.5*\\lenZ)}{0.5*\\r}{-270}{0}{anchor=west}{}\n\t\t\t\\end{tikzpicture}\n\t\t\\end{figure}\n\t\\end{frame}\n\t\n\t\n\t\\begin{frame}[fragile]{Rotate a box aroud any axis}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\def\\r{3.5}\n\t\t\t\\pgfmathsetmacro{\\alphaNorth}{40}\n\t\t\t\\pgfmathsetmacro{\\betaNorth}{0}\n\t\t\t\\pgfmathsetmacro{\\gammaNorth}{0}\n\t\t\t\n\t\t\t\\pgfmathsetmacro{\\alphaNewAxis}{-35}\n\t\t\t\\pgfmathsetmacro{\\betaNewAxis}{0}\n\t\t\t\\pgfmathsetmacro{\\gammaNewAxis}{0}\n\t\t\t\n\t\t\t\\pgfmathsetmacro{\\alphaNextBox}{\\alphaNewAxis}\n\t\t\t\\pgfmathsetmacro{\\betaNextBox}{-40}\n\t\t\t\\pgfmathsetmacro{\\gammaNextBox}{0}\n\t\t\t%%% \\pgfmathsetmacro{\\inclination}{70}\n\t\t\t\n\t\t\t\\tdplotsetmaincoords{70}{160}\n\t\t\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\t% Drawing XYZ coordinates system\n\t\t\t\\def \\lenX {1.0*\\r}\n\t\t\t\\def \\lenY {1.3*\\r}\n\t\t\t\\def \\lenZ {1.0*\\r}\n\t\t\t\\def \\boxX{.7*\\r}\n\t\t\t\\def \\boxY{.9*\\r}\n\t\t\t\\def \\boxZ{.2*\\r}\n\t\t\t% Calculate box corner length\n\t\t\t\\pgfmathsetmacro{\\boxCornerLen}{sqrt{((\\boxX)^2 + (\\boxY)^2 + (\\boxZ)^2)}}\n\t\t\t% Draw coordinate system\n\t\t\t\\draw[dashed] (0,0,0) -- (\\boxX,0,0);\n\t\t\t\\draw[->,thick] (\\boxX,0,0) -- (\\lenX,0,0) node[left] {$X$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,\\boxY,0);\n\t\t\t\\draw[->,thick] (0,\\boxY,0) -- (0,\\lenY,0) node[anchor=north west] {$Y$};\n\t\t\t\\draw[dashed] (0,0,0) -- (0,0,0.6*\\lenZ);\n\t\t\t\\draw[->,thick] (0,0,0.6*\\lenZ) -- (0,0,\\lenZ) node[anchor=south] {$Z$};\n\t\t\t% Draw gravity vector\n\t\t\t\\draw[-stealth,thin] (-0.8*\\r,1.1*\\r,0) -- (-0.8*\\r,1.1*\\r,-.3*\\r) node[anchor=south west] {$\\mathbf{g}$};\n\t\t\t\n\t\t\t% Drawing horizontal box:\n\t\t\t% Get corner polar coordinate\n\t\t\t\\tdplotgetpolarcoords{\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\tdplotsetcoord{Box}{\\boxCornerLen}{\\tdplotrestheta}{\\tdplotresphi}\n\t\t\t% Draw a box\n\t\t\t% \\draw[] (O) -- (Boxx);\n\t\t\t% \\draw[] (O) -- (Boxy);\n\t\t\t% \\draw[] (O) -- (Boxz);\n\t\t\t\\draw[] (Boxx) -- (Boxxy);\n\t\t\t\\draw[] (Boxy) -- (Boxxy);\n\t\t\t\\draw[] (Boxx) -- (Boxxz);\n\t\t\t\\draw[] (Boxz) -- (Boxxz);\n\t\t\t\\draw[] (Boxy) -- (Boxyz);\n\t\t\t\\draw[] (Boxz) -- (Boxyz);\n\t\t\t\\draw[] (Boxxy) -- (Box);\n\t\t\t\\draw[] (Boxxz) -- (Box);\n\t\t\t\\draw[] (Boxyz) -- (Box);\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center for North direction\n\t\t\t\\tdplotsetrotatedcoords{\\alphaNorth}{\\betaNorth}{\\gammaNorth}\n\t\t\t% Draw new coordinates system\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (1.4*\\boxX,0,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (1.4*\\boxX,0,0) -- (1.3*\\lenX,0,0) node[anchor=north east]{$E$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0.3*\\boxY,0);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0.3*\\boxY,0) -- (0,0.8*\\lenY,0) node[anchor=south west]{$\\mathbf{N}$};\n\t\t\t% Hidden line\n\t\t\t\\draw[dashed,tdplot_rotated_coords,red] (0,0,0) -- (0,0,1.1*\\boxZ);\n\t\t\t% Visible line\n\t\t\t\\draw[thick,tdplot_rotated_coords,->,red] (0,0,1.1*\\boxZ) -- (0,0,0.8*\\lenZ) node[anchor=north east]{$Z$};\n\t\t\t\n\t\t\t\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center\n\t\t\t\\tdplotsetrotatedcoords{\\alphaNewAxis}{\\betaNewAxis}{\\gammaNewAxis}\n\t\t\t% Draw new coordinates system\n\t\t\t%\\draw[dashed,tdplot_rotated_coords,orange] (0,0,0) --  (1.3*\\lenX,0,0) node[anchor=north east]{$x$};\n\t\t\t\\draw[dashed,tdplot_rotated_coords,blue] (0,0,0) -- (0,1.6*\\lenY,0) node[anchor=north east]{Rotation axis};\n\t\t\t%\\draw[dashed,tdplot_rotated_coords,orange] (0,0,0) -- (0,0,1.3*\\lenZ) node[anchor=north east]{$z$};\n\t\t\t%\n\t\t\t% Calculate Box coordinates in rotated system {\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\tdplottransformmainrot{\\boxX}{0}{0}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXoox}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXooy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXooz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNewX00) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\\tdplottransformmainrot{0}{\\boxY}{0}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYox}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYoy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYoz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNew0Y0) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\\tdplottransformmainrot{0}{0}{\\boxZ}\n\t\t\t\\pgfmathsetmacro{\\BoxNewooZx}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewooZy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewooZz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNew00Z) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\n\t\t\t\\tdplottransformmainrot{\\boxX}{\\boxY}{0}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYox}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYoy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYoz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNewXY0) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\n\t\t\t\\tdplottransformmainrot{\\boxX}{0}{\\boxZ}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXoZx}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXoZy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXoZz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNewX0Z) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\\tdplottransformmainrot{0}{\\boxY}{\\boxZ}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYZx}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYZy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewoYZz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNew0YZ) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\\tdplottransformmainrot{\\boxX}{\\boxY}{\\boxZ}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYZx}{\\tdplotresx}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYZy}{\\tdplotresy}\n\t\t\t\\pgfmathsetmacro{\\BoxNewXYZz}{\\tdplotresz}\n\t\t\t%\\coordinate (BoxNewXYZ) at (\\tdplotresx,\\tdplotresy,\\tdplotresz);\n\t\t\t\n\t\t\t\\coordinate (0) at (0,0,0);\t\n\t\t\t\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (0) -- (\\BoxNewXoox,\\BoxNewXooy,\\BoxNewXooz) -- (\\BoxNewXYox,\\BoxNewXYoy,\\BoxNewXYoz) -- (\\BoxNewoYox,\\BoxNewoYoy,\\BoxNewoYoz) -- (0);\n\t\t\t%\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz) -- (\\BoxNewXoZx,\\BoxNewXoZy,\\BoxNewXoZz) -- (\\BoxNewXYZx,\\BoxNewXYZy,\\BoxNewXYZz) -- (\\BoxNewoYZx,\\BoxNewoYZy,\\BoxNewoYZz) -- (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz);\n\t\t\t%\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz) -- (0);\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (\\BoxNewXoZx,\\BoxNewXoZy,\\BoxNewXoZz) -- (\\BoxNewXoox,\\BoxNewXooy,\\BoxNewXooz);\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (\\BoxNewXYZx,\\BoxNewXYZy,\\BoxNewXYZz) -- (\\BoxNewXYox,\\BoxNewXYoy,\\BoxNewXYoz);\n\t\t\t%\\draw[tdplot_rotated_coords, orange] (\\BoxNewoYZx,\\BoxNewoYZy,\\BoxNewoYZz) -- (\\BoxNewoYox,\\BoxNewoYoy,\\BoxNewoYoz);\n\t\t\t\n\t\t\t\n\t\t\t%\\draw[tdplot_rotated_coords,green] (0) -- (BoxNewX00) -- (BoxNewXY0) -- (BoxNew0Y0) -- (0);\n\t\t\t%\\draw[tdplot_rotated_coords, green] (BoxNew00Z) -- (BoxNewX0Z) -- (BoxNewXYZ) -- (BoxNew0YZ) -- (BoxNew00Z);\n\t\t\t\n\t\t\t%%%\\foreach \\stepNumber in {1,2,3}\n\t\t\t\\foreach \\slideNumber in {4,5,6}\n\t\t\t%%%\\foreach \\betaNextBox in {-15,-30,-45}\n\t\t\t{\n\t\t\t\t\\pause\n\t\t\t\t%%%\\pgfmathsetmacro{\\betaNextBox}{(-15)*\\stepNumber}\n\t\t\t\t\\pgfmathsetmacro{\\betaNextBox}{(-15)*(\\slideNumber-3)}\n\t\t\t\t%%%\\pgfmathsetmacro{\\slideNumber}{3+\\stepNumber}\n\t\t\t\t\\only<\\slideNumber>{\n\t\t\t\t\t% Rotating box around one new axis:\n\t\t\t\t\t% Create a new rotated system in the center.\n\t\t\t\t\t\\tdplotsetrotatedcoords{\\alphaNextBox}{\\betaNextBox}{\\gammaNextBox}\n\t\t\t\t\t\n\t\t\t\t\t%\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) --  (1.3*\\lenX,0,0) node[anchor=north east]{$x$};\n\t\t\t\t\t%\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) -- (0,1.3*\\lenY,0) node[anchor=south east]{$y$};\n\t\t\t\t\t%\\draw[dashed,tdplot_rotated_coords,gray] (0,0,0) -- (0,0,1.3*\\lenZ) node[anchor=north east]{$z$};\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t% Draw a box in the  new coordinates system\n\t\t\t\t\t\\draw[dashed,tdplot_rotated_coords, gray] (0) -- (\\BoxNewXoox,\\BoxNewXooy,\\BoxNewXooz);\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewXoox,\\BoxNewXooy,\\BoxNewXooz) -- (\\BoxNewXYox,\\BoxNewXYoy,\\BoxNewXYoz) -- (\\BoxNewoYox,\\BoxNewoYoy,\\BoxNewoYoz);\n\t\t\t\t\t\\draw[dashed,tdplot_rotated_coords, gray] (\\BoxNewXYox,\\BoxNewXYoy,\\BoxNewXYoz) -- (\\BoxNewoYox,\\BoxNewoYoy,\\BoxNewoYoz) -- (0);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz) -- (\\BoxNewXoZx,\\BoxNewXoZy,\\BoxNewXoZz) -- (\\BoxNewXYZx,\\BoxNewXYZy,\\BoxNewXYZz) -- (\\BoxNewoYZx,\\BoxNewoYZy,\\BoxNewoYZz) -- (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz);\n\t\t\t\t\t\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewooZx,\\BoxNewooZy,\\BoxNewooZz) -- (0);\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewXoZx,\\BoxNewXoZy,\\BoxNewXoZz) -- (\\BoxNewXoox,\\BoxNewXooy,\\BoxNewXooz);\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewXYZx,\\BoxNewXYZy,\\BoxNewXYZz) -- (\\BoxNewXYox,\\BoxNewXYoy,\\BoxNewXYoz);\n\t\t\t\t\t\\draw[tdplot_rotated_coords, gray] (\\BoxNewoYZx,\\BoxNewoYZy,\\BoxNewoYZz) -- (\\BoxNewoYox,\\BoxNewoYoy,\\BoxNewoYoz);\n\t\t\t\t\t\n\t\t\t\t\t\\tdplotsetthetaplanecoords{0}\n\t\t\t\t\t\\tdplotdrawarc[tdplot_rotated_coords,gray,thick,dotted,<->]{(0,0,0)}{\\boxX}{90}{90+\\betaNextBox}{anchor=west}{}\n\t\t\t\t}\n\t\t\t} % end \\foreach\n\t\t\t\n\t\t\t\\end{tikzpicture}\n\t\t\\end{figure}\n\t\\end{frame}\n\t\n\t\\section{Area aproximation: Rectangles + Triangles }\n\t\\begin{frame}[fragile]{Area $\\approxeq$ Rectangles + Triangles}\n\t\t\\begin{figure}[h]\n\t\t\t\\centering\n\t\t\t\\pgfmathsetmacro{\\circleRadius}{4}\n\t\t\t\\resizebox{0.5\\textwidth}{!}{\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t% Draw X axis\n\t\t\t\t\\draw[thick,->] (0,0) -- (\\circleRadius+0.3,0) node[anchor=north west]{$t$};\n\t\t\t\t% Draw X axis labels\n\t\t\t\t\\foreach \\x in {0,...,\\circleRadius}\n\t\t\t\t{\n\t\t\t\t\t\\draw (\\x,0) -- (\\x,-3pt) node[anchor=north] {$t_\\x$};\n\t\t\t\t}\n\t\t\t\t% Draw Y axis\n\t\t\t\t\\draw[thick,->] (0,0) -- (0,\\circleRadius+0.3) node[anchor=south east]{$\\omega$};\n\t\t\t\t% Draw a quarter of circle\n\t\t\t\t\\draw[red,thick] (0,0\\circleRadius) arc[start angle=90, end angle=0, radius=\\circleRadius];\n\t\t\t\t% Draw trapeziums\n\t\t\t\t\\foreach \\thisX in {1,...,\\circleRadius}\n\t\t\t\t{\n\t\t\t\t\t% Calculate rectangle points\n\t\t\t\t\t\\pgfmathsetmacro{\\thisAngle}{acos((\\thisX)/\\circleRadius)}\n\t\t\t\t\t\\pgfmathsetmacro{\\thisY}{\\circleRadius*sin(\\thisAngle)}\n\t\t\t\t\t% Calculate triangle points\n\t\t\t\t\t\\pgfmathsetmacro{\\previousAngle}{acos((\\thisX-1)/\\circleRadius)}\n\t\t\t\t\t\\pgfmathsetmacro{\\previousY}{\\circleRadius*sin(\\previousAngle)}\n\t\t\t\t\t% Draw triangle\n\t\t\t\t\t\\draw[dashed, fill=blue!30] (\\thisX-1,\\previousY) -- (\\thisX-1,\\thisY) -- (\\thisX,\\thisY) -- cycle;\n\t\t\t\t\t% Draw rectangle\n\t\t\t\t\t\\draw[fill=gray!30] (\\thisX-1,0) rectangle (\\thisX,\\thisY);\n\t\t\t\t\t% draw y axis labels\n\t\t\t\t\t\\draw (0,\\thisY) -- (-3pt,\\thisY) node[anchor=east] {$\\omega_\\thisX$};\n\t\t\t\t}\n\t\t\t\t\\end{tikzpicture}\n\t\t\t}\n\t\t\\end{figure}\t\n\t\t\n\t\t\\begin{equation}\\label{eq:omega2phiTrapezIni}\n\t\t\\boldsymbol{\\theta}_k \\approx \\boldsymbol{\\theta}_{k-1} + (t_k - t_{k-1}) \\boldsymbol{\\omega}_{k-1} + \\frac{1}{2} (t_k - t_{k-1}) (\\boldsymbol{\\omega}_{k} - \\boldsymbol{\\omega}_{k-1}),\\quad k \\ge 1\n\t\t\\end{equation}\n\t\\end{frame}\n\t\n\t\\section{Magnetic Roll, Pitch and Yaw}\n\t\\begin{frame}[fragile]\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t% Select a perspective\n\t\t\t%\\tdplotsetmaincoords{65}{105}\n\t\t\t%\\tdplotsetmaincoords{65}{235}\n\t\t\t\\tdplotsetmaincoords{65}{205}\n\t\t\t\\begin{tikzpicture}[scale=1,tdplot_main_coords,>=latex,line join=bevel]\n\t\t\t% Parameters ---------------------\n\t\t\t% Coordinates parameters\t\n\t\t\t\\pgfmathsetmacro{\\sizeCoordX}{4.2}\n\t\t\t\\pgfmathsetmacro{\\sizeCoordY}{4.2}\n\t\t\t\\pgfmathsetmacro{\\sizeCoordZ}{4.2}\n\t\t\t\\coordinate (O) at (0,0,0);\n\t\t\t\n\t\t\t\n\t\t\t% Figures ---------------------\n\t\t\t% Coordinates\n\t\t\t\\draw[->] (O) -- (\\sizeCoordX,0,0) node[anchor=east]{$X$};\n\t\t\t\\draw[->] (O) -- (0,\\sizeCoordY,0) node[anchor=north]{$Y$};\n\t\t\t\\draw[->] (O) -- (0,0,\\sizeCoordZ) node[anchor=south]{$Z$};\n\t\t\t% \\draw[dashed] (O) -- (-0.7*\\sizeCoordX,0,0);\n\t\t\t% \\draw[dashed] (O) -- (0,-0.7*\\sizeCoordY,0);\n\t\t\t% \\draw[dashed] (O) -- (0,0,-\\sizeCoordZ);\n\t\t\t\\pause\n\t\t\t% Create a new rotated system in the center\n\t\t\t%\\tdplotsetrotatedcoords{45}{-60}{-30}\n\t\t\t\\tdplotsetrotatedcoords{65}{-40}{-30}\n\t\t\t\\draw[thick,tdplot_rotated_coords,->, color=darkgray] (0,0,0) -- (\\sizeCoordX,0,0) node[anchor=north east]{$\\mathbf{e_E}$};\n\t\t\t\\draw[very thick,tdplot_rotated_coords,->, color=darkgray] (0,0,0) -- (0,\\sizeCoordY,0) node[anchor=north]{$\\mathbf{e_N}$};\n\t\t\t\\draw[thick,tdplot_rotated_coords,->, color=darkgray] (0,0,0) -- (0,0,\\sizeCoordZ) node[anchor=south east]{$\\mathbf{e_Z}$};\n\t\t\t\n\t\t\t\\pause\n\t\t\t% Draw a box around East direction\n\t\t\t\\tdplottransformrotmain{\\sizeCoordX}{0}{0}\n\t\t\t% Draw box\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (\\tdplotresx,\\tdplotresy,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (\\tdplotresx,0,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (0,\\tdplotresy,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,0) -- (\\tdplotresx,0,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,0) -- (0,\\tdplotresy,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,0,\\tdplotresz) -- (0,0,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,0,\\tdplotresz) -- (\\tdplotresx,0,0);\n\t\t\t\\draw[dotted] (0,\\tdplotresy,\\tdplotresz) -- (0,0,\\tdplotresz);\n\t\t\t\\draw[dotted] (0,\\tdplotresy,\\tdplotresz) -- (0,\\tdplotresy,0);\n\t\t\t\\draw[dotted] (0,0,0) -- (\\tdplotresx,0,0);\n\t\t\t\n\t\t\t% Transforms a coordinate from the rotated coordinate frame to the main coordinate frame. Results at (\\tdplotresx,\\tdplotresy,\\tdplotresz)\n\t\t\t\\tdplottransformrotmain{0}{\\sizeCoordY}{0}\n\t\t\t% Draw North box\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (\\tdplotresx,\\tdplotresy,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (\\tdplotresx,0,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,\\tdplotresz) -- (0,\\tdplotresy,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,0) -- (\\tdplotresx,0,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,\\tdplotresy,0) -- (0,\\tdplotresy,0);\n\t\t\t\\draw[dotted] (\\tdplotresx,0,\\tdplotresz) -- (0,0,\\tdplotresz);\n\t\t\t\\draw[dotted] (\\tdplotresx,0,\\tdplotresz) -- (\\tdplotresx,0,0) node[anchor= north west]{$x_N$};\n\t\t\t\\draw[dotted] (0,\\tdplotresy,\\tdplotresz) -- (0,0,\\tdplotresz) node[anchor= south west]{$z_N$};\n\t\t\t\\draw[dotted] (0,\\tdplotresy,\\tdplotresz) -- (0,\\tdplotresy,0) node[anchor= south east]{$y_N$};\n\t\t\t\\draw[dotted] (0,0,0) -- (\\tdplotresx,0,0);\n\t\t\t\n\t\t\t% Draw arcs ---------------------------------\n\t\t\t%\n\t\t\t\\pause\n\t\t\t\\draw[dashed] (0,0,0) -- (0,\\tdplotresy,\\tdplotresz);\n\t\t\t% Calculate (0,y,z) polar coordinates\n\t\t\t\\tdplotgetpolarcoords{0.001}{\\tdplotresy}{\\tdplotresz}\n\t\t\t\\pgfmathsetmacro{\\radius}{sqrt{((\\tdplotresy)^2 + (\\tdplotresz)^2)}}\n\t\t\t%syntax: \\tdplotdrawarc[coordinate frame, draw options]{center point}{r}{angle start}{angle end}{label options}{label}\n\t\t\t\\tdplotsetthetaplanecoords{90}\n\t\t\t\\tdplotdrawarc[thick,tdplot_rotated_coords,thick,-stealth,blue]{(0,0,0)}{\\radius}{0}{\\tdplotrestheta}{anchor=north west}{$\\theta_{x}$}\n\t\t\t%\n\t\t\t\\pause\n\t\t\t\\draw[dashed] (0,0,0) -- (\\tdplotresx,0,\\tdplotresz);\n\t\t\t% Calculate (x,0,z) polar coordinates\n\t\t\t\\tdplotgetpolarcoords{\\tdplotresx}{0}{\\tdplotresz}\n\t\t\t\\pgfmathsetmacro{\\radius}{sqrt{((\\tdplotresx)^2 + (\\tdplotresz)^2)}}\n\t\t\t%syntax: \\tdplotdrawarc[coordinate frame, draw options]{center point}{r}{angle start}{angle end}{label options}{label}\n\t\t\t\\tdplotsetthetaplanecoords{180}\n\t\t\t\\tdplotdrawarc[thick,tdplot_rotated_coords,thick,-stealth,blue]{(0,0,0)}{\\radius}{90}{\\tdplotrestheta}{anchor=north west}{$\\theta_{y}$}\n\t\t\t%\n\t\t\t\\pause\n\t\t\t\\draw[dashed] (0,0,0) -- (\\tdplotresx,\\tdplotresy,0);\n\t\t\t% Calculate (x,y,0) polar coordinates\n\t\t\t\\tdplotgetpolarcoords{\\tdplotresx}{\\tdplotresy}{0}\n\t\t\t\\pgfmathsetmacro{\\radius}{sqrt{((\\tdplotresx)^2 + (\\tdplotresy)^2)}}\n\t\t\t%%%% %syntax: \\tdplotdrawarc[coordinate frame, draw options]{center point}{r}{angle start}{angle end}{label options}{label}\n\t\t\t\\tdplotsetthetaplanecoords{0}\n\t\t\t\\tdplotdrawarc[thick,thick,-stealth,blue]{(0,0,0)}{\\radius}{90}{\\tdplotresphi}{anchor=north west}{$\\theta_{z}$}\n\t\t\t\\end{tikzpicture}\n\t\t\\end{figure}\n\t\t\\pause\n\t\t\\onslide<7->{\n\t\t\t%\\begin{equation}\\label{eq:compass_b_rpy}\n\t\t\t\\begin{align}\n\t\t\t&\\textit{Roll}({\\mathbf{b}}): &\\quad \\theta_{x} =& \\arctan{({Y_N}/{Z_N})} - 90 ^{\\circ} \\\\\n\t\t\t&\\textit{Pitch}({\\mathbf{b}}): &\\quad \\theta_{y} =& \\arctan{({Z_N}/{-X_N})}\\\\\n\t\t\t&\\textit{Yaw}({\\mathbf{b}}): &\\quad \\theta_{z} =& \\arctan{({-X_N}/{Y_N})}\\label{eq:yawHoriz}\n\t\t\t\\end{align}\n\t\t\t%\\end{equation}\n\t\t}\t\n\t\\end{frame}\n\t\n\t\\begin{frame}[fragile]{}\n\t\t\\begin{figure}[H]\n\t\t\t%\\centering\n\t\t\t%\\resizebox{0.5\\textwidth}{!}{}\n\t\t\t\\begin{tikzpicture}\n\t\t\t\\def \\accX {3}\n\t\t\t\\def \\accY {2}\n\t\t\t\\def \\sigmaAccX {1}\n\t\t\t\\def \\sigmaAccY {1}\n\t\t\t\\def \\Xaxis {\\accX+\\sigmaAccX+0.7}\n\t\t\t\\def \\Yaxis {\\accY+\\sigmaAccY+0.7}\n\t\t\t%\n\t\t\t% Define angles\n\t\t\t% It is very important to get redundant parenthesis\n\t\t\t\\pgfmathsetmacro{\\bottomAngle}{atan(((\\accY-\\sigmaAccY)) / ((\\accX+\\sigmaAccX)))}\n\t\t\t\\pgfmathsetmacro{\\mediumAngle}{atan(((\\accY)) / ((\\accX)))}\n\t\t\t\\pgfmathsetmacro{\\upperAngle}{atan(((\\accY+\\sigmaAccY)) / ((\\accX-\\sigmaAccX)))}\n\t\t\t%\n\t\t\t% Draw coordinate system\n\t\t\t\\draw[thick,->](0,0) -- (\\Xaxis,0) node[right]{$X$};\n\t\t\t\\draw[thick,->](0,0) -- (0,\\Yaxis) node[above]{$Y$};\n\t\t\t%\n\t\t\t% Draw arrow medium position\n\t\t\t\\draw[thick,-stealth](0,0) -- (\\accX,\\accY) node[right]{$\\theta$};\n\t\t\t% Draw medium point\n\t\t\t\\draw[dashed] (\\accX,\\accY) -- (\\accX,0) node[below] {$x_k$};\n\t\t\t\\draw[dashed] (\\accX,\\accY) -- (0,\\accY) node[left] {$y_k$};\n\t\t\t% Draw angle\n\t\t\t\\def \\radiusMediumAngle {1.5}\n\t\t\t\\draw[thick,black] ([shift=(0:\\radiusMediumAngle)]0,0) arc (0:\\mediumAngle:\\radiusMediumAngle)node[below right]{$\\theta$};\n\t\t\t\\pause\n\t\t\t% Draw horizontal SD\n\t\t\t\\draw[dotted] (\\accX+\\sigmaAccX,\\accY-\\sigmaAccY) -- (\\accX+\\sigmaAccX,0) node[rotate=90,left]{$(x_k+\\sigma_x)$};\n\t\t\t\\node[rotate=90,left] at (\\accX-\\sigmaAccX,0) {$(x_k-\\sigma_x)$};\n\t\t\t\\pause\n\t\t\t% Draw vertical SD\n\t\t\t\\node[left] at (0,\\accY-\\sigmaAccY) {$(y_k-\\sigma_y)$};\n\t\t\t\\draw[dotted] (\\accX-\\sigmaAccX,\\accY+\\sigmaAccY) -- (0,\\accY+\\sigmaAccY) node[left]{$(y_k+\\sigma_y)$};\n\t\t\t\\pause\t\t\n\t\t\t% Draw arrow bottom position\n\t\t\t\\draw[-stealth,blue](0,0) -- (\\accX+\\sigmaAccX, \\accY-\\sigmaAccY) node[right]{$(\\theta-\\sigma_{\\theta -})$};\n\t\t\t% Angle. Syntax: (startingPointX,startingPointY) arc (startAngle:stopAngle:radius)\n\t\t\t% ([shift=(t:r)] x, y) is the proper starting point, where (x,y) is the center and (t:r) is the polar coordinate of starting point.\n\t\t\t\\def \\radiusBottomAngle {2.5}\n\t\t\t\\draw[thick,blue] ([shift=(\\bottomAngle:\\radiusBottomAngle)]0,0) arc (\\bottomAngle:\\mediumAngle:\\radiusBottomAngle)node[below right]{$\\sigma_{\\theta -}$};\n\t\t\t\\pause\n\t\t\t% Draw arrow upper position\n\t\t\t\\draw[-stealth,red](0,0) -- (\\accX-\\sigmaAccX, \\accY+\\sigmaAccY) node[right]{$(\\theta+\\sigma_{\\theta +})$};\n\t\t\t% Angle\n\t\t\t\\def \\radiusUpperAngle {2.6}\n\t\t\t\\draw[thick,red] ([shift=(\\mediumAngle:\\radiusUpperAngle)]0,0) arc (\\mediumAngle:\\upperAngle:\\radiusUpperAngle)node[right]{$\\sigma_{\\theta +}$};\n\t\t\t\\end{tikzpicture}\n\t\t\\end{figure}\n\t\t\\onslide<6->{\n\t\t\t\\begin{equation}\n\t\t\t(\\theta_z - \\sigma_{\\theta -}) = \\arctan \\frac{y_k-\\sigma_y}{x_k+\\sigma_x}\n\t\t\t,\\quad\n\t\t\t(\\theta_z + \\sigma_{\\theta +}) = \\arctan \\frac{y_k+\\sigma_y}{x_k-\\sigma_x}\n\t\t\t\\end{equation}}\n\t\t\\onslide<7->{\n\t\t\t\\begin{equation}\\label{eq:sigmaPlusMinus}\n\t\t\t\\sigma_k =(\\sigma_{\\theta +} + \\sigma_{\\theta -}) = \\arctan \\frac{y_k+\\sigma_y}{x_k-\\sigma_x} - \\arctan \\frac{y_k-\\sigma_y}{x_k+\\sigma_x}\n\t\t\t\\end{equation}\n\t\t}\n\t\\end{frame}\n\t\t\n\\end{document}", "meta": {"hexsha": "200156d70f05094055e817c86660143e4a9185ec", "size": 39911, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TFM_FiguresOverleaf.tex", "max_stars_repo_name": "ImJaviPerez/LatexFigures", "max_stars_repo_head_hexsha": "14fe3a47371217c23df28b8ca6637f7612843947", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-02T23:30:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-02T23:30:17.000Z", "max_issues_repo_path": "TFM_FiguresOverleaf.tex", "max_issues_repo_name": "ImJaviPerez/LatexFigures", "max_issues_repo_head_hexsha": "14fe3a47371217c23df28b8ca6637f7612843947", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TFM_FiguresOverleaf.tex", "max_forks_repo_name": "ImJaviPerez/LatexFigures", "max_forks_repo_head_hexsha": "14fe3a47371217c23df28b8ca6637f7612843947", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.954845815, "max_line_length": 243, "alphanum_fraction": 0.6348124577, "num_tokens": 16529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011397337391, "lm_q2_score": 0.6992544085240402, "lm_q1q2_score": 0.40913455139125754}}
{"text": "\\section{Figures that might be useful}\n\\begin{figure}[ht]\n    \\centering\n    \\begin{tikzpicture}[>=latex]\n        % the rectangle with vertical rules (Queue 1)\n        \\draw (0,0) -- ++(2cm,0) -- ++(0,-1.5cm) -- ++(-2cm,0);\n        \\foreach \\i in {1,...,4}\n        \\draw (2cm-\\i*10pt,0) -- +(0,-1.5cm);\n        \n        % the circle (Queue 1)\n        \\draw (2.75,-0.75cm) circle [radius=0.75cm];\n\n        % the rectangle with vertical rules (Queue 2)\n        \\draw (5,1.25) -- ++(2cm,0) -- ++(0,-1.5cm) -- ++(-2cm,0);\n        \\foreach \\i in {1,...,4}\n        \\draw (7cm-\\i*10pt,1.25) -- +(0,-1.5cm);\n\n        % the circle (Queue 2)\n        \\draw (7.75,0.5) circle [radius=0.75cm];\n\n        % the arrows and labels (Queue 1+2)\n        \\draw[-] (3.5,-0.75) -- +(20pt,0);\n        \\draw[<-] (0,-0.75) -- +(-50pt,0) node[left] {\\( \\lambda_2 \\)};\n        \\draw[->] (8.5,0.525) -- +(20pt,0);\n        \\node[align=center] at (1cm,-2cm) {Buffer \\\\ Area};\n        \\node[align=center] at (2.75cm,-2cm) {Dummy \\\\ Service};\n        \\node[align=center] at (6cm,-0.75cm) {Waiting \\\\ Area};\n        \\node[align=center] at (7.8cm,-0.75cm) {Treatment \\\\ };\n        \n        \\draw (4.2, 1.8) -- +(-169.5pt,0) node[left] {\\( \\lambda_1 \\)};\n        \\draw (4.2, 1.8) -- (4.2, -0.75);\n        \\draw[->] (4.2, 0.525) -- (5, 0.525);\n\n    \\end{tikzpicture}\n\\end{figure}\n\n\\begin{figure}[ht]\n    \\input{Miscellaneous/Useful_tikz/Example-with-python/main.tex}\n\\end{figure}\n\n\\newpage\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture}[-, node distance = 1cm, auto, every node/.style={scale=0.5}]\n\n        % Variables\n        \\tikzmath{\n            let \\altdist = 1.5cm;\n            let \\minsz = 1.5cm;\n        }\n\n        % First Line\n        \\node[state, minimum size=1.5cm] (zero) {(0,0)};\n        \\node[state, minimum size=1.5cm,  right=of zero] (one) {(0,1)};\n        \\node[draw=none, minimum size=1.5cm, right=of one] (two) {\\dots};\n        \\node[state, minimum size=1.5cm, right=of two] (three) {(0,T)};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of three] \n        (four) {(0,T+1)};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of four] \n        (five) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of five] \n        (six) {(0,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six] (seven) {\\dots};\n\n        % Second Line\n        \\node[state, minimum size=\\minsz, below=of three] (three_one) {(1,T)};\n        \\node[state, minimum size=\\minsz, below=of four] (four_one) {(1,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five] (five_one) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of five_one] \n        (six_one) {(1,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_one] (seven_one) {\\dots};\n\n        % Third Line\n        \\node[state, minimum size=\\minsz, below=of three_one] (three_two) {(2,T)};\n        \\node[state, minimum size=\\minsz, below=of four_one] (four_two) {(2,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five_one] (five_two) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of five_two] \n        (six_two) {(2,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_two] (seven_two) {\\dots};\n\n        % Fourth line\n        \\node[draw=none, minimum size=\\minsz, below=of three_two] (three_three) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, below=of four_two] (four_three) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, below=of five_two] (five_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of five_three] \n        (six_three) {\\vdots};\n\n        \\draw[every loop]\n            % First Horizontal Edges\n            (zero) edge[bend left] node {\\( \\Lambda \\)} (one)\n            (one) edge[bend left] node [above] {\\( \\mu \\)} (zero)\n            (one) edge[bend left] node {\\( \\Lambda \\)} (two)\n            (two) edge[bend left] node [above] {\\( 2 \\mu \\)} (one)\n            (two) edge[bend left] node {\\( \\Lambda \\)} (three)\n            (three) edge[bend left] node [above] {\\( T \\mu \\)} (two)\n            (three) edge[bend left] node {\\( \\lambda_1 \\)} (four)\n            (four) edge[bend left] node [above] {\\( (T+1) \\mu \\)} (three)\n            (four) edge[bend left] node {\\( \\lambda_1 \\)} (five)\n            (five) edge[bend left] node [above] {\\( (T+2) \\mu \\)} (four)\n            (five) edge[bend left] node {\\( \\lambda_1 \\)} (six)\n            (six) edge[bend left] node [above] {\\( C\\mu \\)} (five)\n            (six) edge[bend left] node {\\( \\lambda_1 \\)} (seven)\n            (seven) edge[bend left] node [above] {\\( C\\mu \\)} (six)\n\n            % Second Horizontal Edges\n            (three_one) edge[bend left] node {\\( \\lambda_1 \\)} (four_one)\n            (four_one) edge[bend left] node [above] {\\( (T+1) \\mu \\)} (three_one)\n            (four_one) edge[bend left] node {\\( \\lambda_1 \\)} (five_one)\n            (five_one) edge[bend left] node [above] {\\( (T+2) \\mu \\)} (four_one)\n            (five_one) edge[bend left] node {\\( \\lambda_1 \\)} (six_one)\n            (six_one) edge[bend left] node [above] {\\( C\\mu \\)} (five_one)\n            (six_one) edge[bend left] node {\\( \\lambda_1 \\)} (seven_one)\n            (seven_one) edge[bend left] node [above] {\\( C\\mu \\)} (six_one)\n\n            % Third Horizontal Edges\n            (three_two) edge[bend left] node {\\( \\lambda_1 \\)} (four_two)\n            (four_two) edge[bend left] node [above] {\\( (T+1) \\mu \\)} (three_two)\n            (four_two) edge[bend left] node {\\( \\lambda_1 \\)} (five_two)\n            (five_two) edge[bend left] node [above] {\\( (T+2) \\mu \\)} (four_two)\n            (five_two) edge[bend left] node {\\( \\lambda_1 \\)} (six_two)\n            (six_two) edge[bend left] node [above] {\\( C\\mu \\)} (five_two)\n            (six_two) edge[bend left] node {\\( \\lambda_1 \\)} (seven_two)\n            (seven_two) edge[bend left] node [above] {\\( C\\mu \\)} (six_two)\n\n            % First Vertical Edges\n            (three) edge[bend left] node {\\( \\lambda_2 \\)} (three_one)\n            (three_one) edge[bend left] node {\\( T \\mu \\)} (three)\n            (three_one) edge[bend left] node {\\( \\lambda_2 \\)} (three_two)\n            (three_two) edge[bend left] node {\\( T\\mu \\)} (three_one)\n            (three_two) edge[bend left] node {\\( \\lambda_2 \\)} (three_three)\n            (three_three) edge[bend left] node {\\( T\\mu \\)} (three_two)\n\n            % Second Vertical Edges\n            (four) edge node {\\( \\lambda_2 \\)} (four_one)\n            (four_one) edge node {\\( \\lambda_2 \\)} (four_two)\n            (four_two) edge node {\\( \\lambda_2 \\)} (four_three)\n\n            %Third Vertical Edges\n            (six) edge node {\\( \\lambda_2 \\)} (six_one)\n            (six_one) edge node {\\( \\lambda_2 \\)} (six_two)\n            (six_two) edge node {\\( \\lambda_2 \\)} (six_three)\n            ;       \n    \\end{tikzpicture}\n    \\caption{Markov chains} \n    \\label{Markov_2}\n\\end{figure}\n\n\\newpage\n\\begin{figure}[ht]\n    \\centering\n    \\begin{tikzpicture}[-, node distance = 1cm, auto, every node/.style={scale=0.4}]\n\n        % Variables\n        \\tikzmath{\n            let \\altdist = 1cm;\n            let \\minsz = 1.5cm;\n        }\n\n        % First Line\n        \\node[state, minimum size=1.5cm] (zero) {(0,0)};\n        \\node[state, minimum size=1.5cm,  right=of zero] (one) {(0,1)};\n        \\node[draw=none, minimum size=1.5cm, right=of one] (two) {\\dots};\n        \\node[state, minimum size=1.5cm, right=of two] (three) {(0,T)};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of three] \n        (four) {(0,T+1)};\n        \\node[draw=none, minimum size=\\minsz, right=of four] (five) {\\dots};\n        \\node[draw=none, minimum size=\\minsz, right=of five] (six) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, right=of six] (seven) {\\dots};\n        \\node[state, minimum size=\\minsz, right=of seven] (eight) {(0,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight] (nine) {\\dots};\n\n\n        % Second Line\n        \\node[state, minimum size=\\minsz, below=of three] (three_one) {(1,T)};\n        \\node[state, minimum size=\\minsz, below=of four] (four_one) {(1,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five] (five_one) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of five_one] \n        (six_one) {\\( (u_i, v_i) \\)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_one] (seven_one) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of seven_one] \n        (eight_one) {(1,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight_one] (nine_one) {\\dots};\n        \n\n        % Third Line\n        \\node[state, minimum size=\\minsz, below=of three_one] (three_two) {(2,T)};\n        \\node[state, minimum size=\\minsz, below=of four_one] (four_two) {(2,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five_one] (five_two) {\\dots};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of five_two] \n        (six_two) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, right=of six_two] (seven_two) {\\dots};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of seven_two] \n        (eight_two) {(2,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight_two] (nine_two) {\\dots};\n\n        % Fourth line\n        \\node[draw=none, minimum size=\\minsz, below=of three_two] (three_three) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, below=of four_two] (four_three) {\\vdots};\n        \\node[draw=none, minimum size=\\minsz, below=of five_two] (five_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of five_three] \n        (six_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of eight_two] \n        (eight_three) {\\vdots};\n\n\n        \\draw[every loop]\n            % First Horizontal Edges\n            (zero) edge[bend left] node {\\( \\Lambda \\)} (one)\n            (one) edge[bend left] node {\\( \\mu \\)} (zero)\n            (one) edge[bend left] node {\\( \\Lambda \\)} (two)\n            (two) edge[bend left] node {\\( 2 \\mu \\)} (one)\n            (two) edge[bend left] node {\\( \\Lambda \\)} (three)\n            (three) edge[bend left] node {\\( T \\mu \\)} (two)\n            (three) edge[bend left] node {\\( \\lambda_1 \\)} (four)\n            (four) edge[bend left] node {\\( (T+1) \\mu \\)} (three)\n            (four) edge[bend left] node {\\( \\lambda_1 \\)} (five)\n            (five) edge[bend left] node {\\( (T+2) \\mu \\)} (four)\n            % (five) edge[bend left] node {\\( \\lambda_1 \\)} (six)\n            % (six) edge[bend left] node [above] {\\( C\\mu \\)} (five)\n            % (six) edge[bend left] node {\\( \\lambda_1 \\)} (seven)\n            % (seven) edge[bend left] node [above] {\\( C\\mu \\)} (six)\n            (seven) edge[bend left] node {\\( \\lambda_1 \\)} (eight)\n            (eight) edge[bend left] node {\\( C\\mu \\)} (seven)\n            (eight) edge[bend left] node {\\( \\lambda_1 \\)} (nine)\n            (nine) edge[bend left] node {\\( C\\mu \\)} (eight)\n\n            % Second Horizontal Edges\n            (three_one) edge[bend left] node {\\(\\lambda_1\\)} (four_one)\n            (four_one) edge[bend left] node {\\( (T+1) \\mu \\)} (three_one)\n            (four_one) edge[bend left] node {\\( \\lambda_1 \\)} (five_one)\n            (five_one) edge[bend left] node {\\( (T+2) \\mu \\)} (four_one)\n            (five_one) edge[bend left] node {\\( \\lambda_1 \\)} (six_one)\n            (six_one) edge[bend left] node {\\( v_i\\mu \\)} (five_one)\n            (six_one) edge[bend left] node {\\( \\lambda_1 \\)} (seven_one)\n            (seven_one) edge[bend left] node {\\( (v_i+1)\\mu \\)} (six_one)\n            (seven_one) edge[bend left] node {\\( \\lambda_1 \\)} (eight_one)\n            (eight_one) edge[bend left] node {\\( C\\mu \\)} (seven_one)\n            (eight_one) edge[bend left] node {\\( \\lambda_1 \\)} (nine_one)\n            (nine_one) edge[bend left] node {\\( C\\mu \\)} (eight_one)\n\n            % Third Horizontal Edges\n            (three_two) edge[bend left] node {\\( \\lambda_1 \\)} (four_two)\n            (four_two) edge[bend left] node {\\( (T+1) \\mu \\)} (three_two)\n            (four_two) edge[bend left] node {\\( \\lambda_1 \\)} (five_two)\n            (five_two) edge[bend left] node {\\( (T+2) \\mu \\)} (four_two)\n            % (five_two) edge[bend left] node {\\( \\lambda_1 \\)} (six_two)\n            % (six_two) edge[bend left] node [above] {\\( C\\mu \\)} (five_two)\n            % (six_two) edge[bend left] node {\\( \\lambda_1 \\)} (seven_two)\n            % (seven_two) edge[bend left] node [above] {\\( C\\mu \\)} (six_two)\n            (seven_two) edge[bend left] node {\\( \\lambda_1 \\)} (eight_two)\n            (eight_two) edge[bend left] node {\\( C\\mu \\)} (seven_two)\n            (eight_two) edge[bend left] node {\\( \\lambda_1 \\)} (nine_two)\n            (nine_two) edge[bend left] node {\\( C\\mu \\)} (eight_two)\n\n            % First Vertical Edges\n            (three) edge[bend left] node {\\( \\lambda_2 \\)} (three_one)\n            (three_one) edge[bend left] node {\\( T \\mu \\)} (three)\n            (three_one) edge[bend left] node {\\( \\lambda_2 \\)} (three_two)\n            (three_two) edge[bend left] node {\\( T\\mu \\)} (three_one)\n            (three_two) edge[bend left] node {\\( \\lambda_2 \\)} (three_three)\n            (three_three) edge[bend left] node {\\( T\\mu \\)} (three_two)\n\n            % Second Vertical Edges\n            (four) edge node {\\( \\lambda_2 \\)} (four_one)\n            (four_one) edge node {\\( \\lambda_2 \\)} (four_two)\n            (four_two) edge node {\\( \\lambda_2 \\)} (four_three)\n\n            % Third Vertical Edges\n            (six) edge node {\\( \\lambda_2 \\)} (six_one)\n            (six_one) edge node {\\( \\lambda_2 \\)} (six_two)\n            % (six_two) edge node {\\( \\lambda_2 \\)} (six_three)\n\n            % Fourth Vertical Edges\n            (eight) edge node {\\( \\lambda_2 \\)} (eight_one)\n            (eight_one) edge node {\\( \\lambda_2 \\)} (eight_two)\n            (eight_two) edge node {\\( \\lambda_2 \\)} (eight_three)\n            ;       \n    \\end{tikzpicture}\n    \\caption{Markov chains} \n    \\label{Markov_3}\n\\end{figure}\n\n\\newpage\n\\begin{figure}[ht]\n    \\centering\n    \\begin{tikzpicture}[-, node distance = 0.9cm, auto, every node/.style={scale=0.5}]\n\n        % Variables\n        \\tikzmath{\n            let \\initdist = 0.5cm;\n            let \\altdist = 1.2cm;\n            let \\minsz = 1.6cm;\n            let \\leftOne = -0.8;\n            let \\rightOne = 2.2;\n            let \\upOne = 0.8;\n            let \\downOne = -2.2;\n            let \\leftTwo = 2.25;\n            let \\rightTwo = 14.2;\n            let \\upTwo = -2.35;\n            let \\downTwo = -8.8;\n        }\n\n        % % Rectangle for S1\n        % \\draw[ultra thin, dashed] (\\leftOne, \\downOne) -- (\\leftOne, \\upOne);\n        % \\draw[ultra thin, dashed] (\\leftOne, \\upOne) -- (\\rightOne, \\upOne);\n        % \\draw[ultra thin, dashed] (\\rightOne, \\upOne) -- node {\\Huge{\\( \\quad S_1 \\)}}(\\rightOne, \\downOne);\n        % \\draw[ultra thin, dashed] (\\rightOne, \\downOne) -- (\\leftOne, \\downOne);\n\n        % % Rectangle for S2\n        % \\draw[ultra thin, dashed] (\\leftTwo, \\downTwo) -- node {\\Huge{\\( S_2 \\quad \\)}}(\\leftTwo, \\upTwo);\n        % \\draw[ultra thin, dashed] (\\leftTwo, \\upTwo) -- (\\rightTwo, \\upTwo);\n        % \\draw[ultra thin, dashed] (\\rightTwo, \\upTwo) -- (\\rightTwo, \\downTwo);\n        % \\draw[ultra thin, dashed] (\\rightTwo, \\downTwo) -- (\\leftTwo, \\downTwo);\n\n        % First Line\n        \\node[state, minimum size=1.5cm] (zero) {(0,0)};\n        \\node[state, node distance = \\initdist, minimum size=\\minsz, below right=of zero] \n        (one) {(0,1)};\n        \\node[draw=none, node distance = \\initdist, minimum size=\\minsz, below right=of one] \n        (two) {\\textbf{\\( \\ddots \\)}};\n        \\node[state, node distance = \\initdist, minimum size=\\minsz, below right=of two] \n        (three) {(0,T)};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of three] \n        (four) {(0,T+1)};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of four] \n        (five) {\\textbf{\\dots}};\n        \\node[draw=none, minimum size=\\minsz, right=of five] (six) {\\textbf{\\vdots}};\n        \\node[draw=none, minimum size=\\minsz, right=of six] (seven) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of seven] (eight) {(0,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight] (nine) {\\textbf{\\dots}};\n\n\n        % Second Line\n        \\node[state, minimum size=\\minsz, below=of three] (three_one) {(1,T)};\n        \\node[state, minimum size=\\minsz, below=of four] (four_one) {(1,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five] (five_one) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of five_one] (six_one) {\\( (u_i, v_i) \\)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_one] (seven_one) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of seven_one] (eight_one) {(1,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight_one] (nine_one) {\\textbf{\\dots}};\n        \n\n        % Third Line\n        \\node[state, minimum size=\\minsz, below=of three_one] (three_two) {(2,T)};\n        \\node[state, minimum size=\\minsz, below=of four_one] (four_two) {(2,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five_one] (five_two) {\\textbf{\\dots}};\n        \\node[draw=none, minimum size=\\minsz, right=of five_two] (six_two) {\\textbf{\\vdots}};\n        \\node[draw=none, minimum size=\\minsz, right=of six_two] (seven_two) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of seven_two] (eight_two) {(2,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of eight_two] (nine_two) {\\textbf{\\dots}};\n\n        % Fourth line\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of three_two] \n        (three_three) {\\textbf{\\vdots}};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of four_two] \n        (four_three) {\\textbf{\\vdots}};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of five_two] \n        (five_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of six_two] \n        (six_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of eight_two] \n        (eight_three) {\\textbf{\\vdots}};\n\n\n        \\draw[every loop]\n            % First Horizontal Edges\n            (zero) edge[bend left] node {\\( \\Lambda \\)} (one)\n            (one) edge[bend left] node {\\( \\mu \\)} (zero)\n            (one) edge[bend left] node {\\( \\Lambda \\)} (two)\n            (two) edge[bend left] node {\\( 2 \\mu \\)} (one)\n            (two) edge[bend left] node {\\( \\Lambda \\)} (three)\n            (three) edge[bend left] node {\\( T \\mu \\)} (two)\n            (three) edge[bend left] node {\\( \\lambda_1 \\)} (four)\n            (four) edge[bend left] node {\\( (T+1) \\mu \\)} (three)\n            (four) edge[bend left] node {\\( \\lambda_1 \\)} (five)\n            (five) edge[bend left] node {\\( (T+2) \\mu \\)} (four)\n            % (five) edge[bend left] node {\\( \\lambda_1 \\)} (six)\n            % (six) edge[bend left] node [above] {\\( C\\mu \\)} (five)\n            % (six) edge[bend left] node {\\( \\lambda_1 \\)} (seven)\n            % (seven) edge[bend left] node [above] {\\( C\\mu \\)} (six)\n            (seven) edge[bend left] node {\\( \\lambda_1 \\)} (eight)\n            (eight) edge[bend left] node {\\( C\\mu \\)} (seven)\n            (eight) edge[bend left] node {\\( \\lambda_1 \\)} (nine)\n            (nine) edge[bend left] node {\\( C\\mu \\)} (eight)\n\n            % Second Horizontal Edges\n            (three_one) edge[bend left] node {\\( \\lambda_1 \\)} (four_one)\n            (four_one) edge[bend left] node {\\( (T+1) \\mu \\)} (three_one)\n            (four_one) edge[bend left] node {\\( \\lambda_1 \\)} (five_one)\n            (five_one) edge[bend left] node {\\( (T+2) \\mu \\)} (four_one)\n            (five_one) edge[bend left] node {\\( \\lambda_1 \\)} (six_one)\n            (six_one) edge[bend left] node {\\( v_i\\mu \\)} (five_one)\n            (six_one) edge[bend left] node {\\( \\lambda_1 \\)} (seven_one)\n            (seven_one) edge[bend left] node {\\( (v_i+1)\\mu \\)} (six_one)\n            (seven_one) edge[bend left] node {\\( \\lambda_1 \\)} (eight_one)\n            (eight_one) edge[bend left] node {\\( C\\mu \\)} (seven_one)\n            (eight_one) edge[bend left] node {\\( \\lambda_1 \\)} (nine_one)\n            (nine_one) edge[bend left] node {\\( C\\mu \\)} (eight_one)\n\n            % Third Horizontal Edges\n            (three_two) edge[bend left] node {\\( \\lambda_1 \\)} (four_two)\n            (four_two) edge[bend left] node [below] {\\( (T+1) \\mu \\)} (three_two)\n            (four_two) edge[bend left] node {\\( \\lambda_1 \\)} (five_two)\n            (five_two) edge[bend left] node {\\( (T+2) \\mu \\)} (four_two)\n            % (five_two) edge[bend left] node {\\( \\lambda_1 \\)} (six_two)\n            % (six_two) edge[bend left] node [above] {\\( C\\mu \\)} (five_two)\n            % (six_two) edge[bend left] node {\\( \\lambda_1 \\)} (seven_two)\n            % (seven_two) edge[bend left] node [above] {\\( C\\mu \\)} (six_two)\n            (seven_two) edge[bend left] node {\\( \\lambda_1 \\)} (eight_two)\n            (eight_two) edge[bend left] node {\\( C\\mu \\)} (seven_two)\n            (eight_two) edge[bend left] node {\\( \\lambda_1 \\)} (nine_two)\n            (nine_two) edge[bend left] node {\\( C\\mu \\)} (eight_two)\n\n            % First Vertical Edges\n            (three) edge[bend left] node {\\( \\lambda_2 \\)} (three_one)\n            (three_one) edge[bend left] node {\\( T \\mu \\)} (three)\n            (three_one) edge[bend left] node {\\( \\lambda_2 \\)} (three_two)\n            (three_two) edge[bend left] node {\\( T\\mu \\)} (three_one)\n            (three_two) edge[bend left] node {\\( \\lambda_2 \\)} (three_three)\n            (three_three) edge[bend left] node {\\( T\\mu \\)} (three_two)\n\n            % Second Vertical Edges\n            (four) edge node {\\( \\lambda_2 \\)} (four_one)\n            (four_one) edge node {\\( \\lambda_2 \\)} (four_two)\n            (four_two) edge node {\\( \\lambda_2 \\)} (four_three)\n\n            % Third Vertical Edges\n            (six) edge node {\\( \\lambda_2 \\)} (six_one)\n            (six_one) edge node {\\( \\lambda_2 \\)} (six_two)\n            % (six_two) edge node {\\( \\lambda_2 \\)} (six_three)\n\n            % Fourth Vertical Edges\n            (eight) edge node {\\( \\lambda_2 \\)} (eight_one)\n            (eight_one) edge node {\\( \\lambda_2 \\)} (eight_two)\n            (eight_two) edge node {\\( \\lambda_2 \\)} (eight_three)\n            ;       \n    \\end{tikzpicture}\n    \\caption{Markov chains} \n    \\label{Markov_4}\n\\end{figure}\n\n\n\\newpage\n\\begin{figure}[h!]\n    \\centering\n    \\begin{tikzpicture}[-, node distance = 0.9cm, auto, every node/.style={scale=0.7}]\n\n        % Markov chain variables\n        \\tikzmath{\n            let \\initdist = 0.5cm;\n            let \\altdist = 1.2cm;\n            let \\minsz = 1.6cm;\n        }\n\n        % S_1 and S_2 rectangles\n        \\tikzmath{\n            let \\leftOne = -0.8;\n            let \\rightOne = 2.7;\n            let \\upOne = 0.8;\n            let \\downOne = -2.7;\n            let \\leftTwo = 2.8;\n            let \\rightTwo = 13;\n            let \\upTwo = -2.95;\n            let \\downTwo = -16.4;\n        }\n\n        % General case variables\n        \\tikzmath{\n            let \\GCsmallx = 8.3;\n            let \\GCsmally = -9.5;\n            let \\GCbigx = 4.1;\n            let \\GCbigy = -11.8;\n        }\n\n        % % Rectangle for S1\n        % \\draw[ultra thin, dashed] (\\leftOne, \\downOne) -- (\\leftOne, \\upOne);\n        % \\draw[ultra thin, dashed] (\\leftOne, \\upOne) -- (\\rightOne, \\upOne);\n        % \\draw[ultra thin, dashed] (\\rightOne, \\upOne) -- node {\\Huge{\\( \\quad S_1 \\)}}(\\rightOne, \\downOne);\n        % \\draw[ultra thin, dashed] (\\rightOne, \\downOne) -- (\\leftOne, \\downOne);\n\n        % % Rectangle for S2\n        % \\draw[ultra thin, dashed] (\\leftTwo, \\downTwo) -- node {\\Huge{\\( S_2 \\quad \\)}}(\\leftTwo, \\upTwo);\n        % \\draw[ultra thin, dashed] (\\leftTwo, \\upTwo) -- (\\rightTwo, \\upTwo);\n        % \\draw[ultra thin, dashed] (\\rightTwo, \\upTwo) -- (\\rightTwo, \\downTwo);\n        % \\draw[ultra thin, dashed] (\\rightTwo, \\downTwo) -- (\\leftTwo, \\downTwo);\n\n        % Small square of general case\n        \\draw [thick] (\\GCsmallx, \\GCsmally) -- node {} (\\GCsmallx + 0.4, \\GCsmally);\n        \\draw [thick] (\\GCsmallx + 0.4, \\GCsmally) -- node {} (\\GCsmallx + 0.4, \n        \\GCsmally - 0.4);\n        \\draw [thick] (\\GCsmallx + 0.4, \\GCsmally - 0.4) -- node {} (\\GCsmallx, \n        \\GCsmally - 0.4);\n        \\draw [thick] (\\GCsmallx, \\GCsmally - 0.4) -- node {} (\\GCsmallx, \\GCsmally);\n\n\n        % Dashed lines to from small square to big one \n        \\draw [ultra thin] (\\GCsmallx, \\GCsmally) -- node {} (\\GCbigx, \\GCbigy);\n        \\draw [ultra thin] (\\GCsmallx + 0.4, \\GCsmally) -- node {} (\\GCbigx + 4, \n        \\GCbigy);\n        \\draw [ultra thin] (\\GCsmallx, \\GCsmally - 0.4) -- node {} (7, \\GCbigy);\n        \\draw [ultra thin] (\\GCsmallx + 0.4, \\GCsmally - 0.4) -- node {} (\\GCbigx + 4, \n        \\GCbigy - 4);\n        \n        % Big Square of general case\n        \\draw [ultra thick] (\\GCbigx, \\GCbigy) -- node {} (\\GCbigx + 4, \\GCbigy);\n        \\draw [ultra thick] (\\GCbigx + 4, \\GCbigy) -- node {} (\\GCbigx + 4, \\GCbigy - 4);\n        \\draw [ultra thick] (\\GCbigx + 4, \\GCbigy - 4) -- node {General Case} (\\GCbigx, \\GCbigy - 4);\n        \\draw [ultra thick] (\\GCbigx, \\GCbigy - 4) -- node {} (\\GCbigx, \\GCbigy);\n\n        % First Line\n        \\node[state, minimum size=1.5cm] (zero) {(0,0)};\n        \\node[state, node distance = \\initdist, minimum size=\\minsz, below right=of zero] \n        (one) {(0,1)};\n        \\node[draw=none, node distance = \\initdist, minimum size=\\minsz, below right=of one] \n        (two) {\\textbf{\\( \\ddots \\)}};\n        \\node[state, node distance = \\initdist, minimum size=\\minsz, below right=of two] \n        (three) {(0,T)};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, right=of three] \n        (four) {(0,T+1)};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of four] \n        (five) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of five] (six) {(0,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six] (seven) {\\textbf{\\dots}};\n\n        % Second Line\n        \\node[state, minimum size=\\minsz, below=of three] (three_one) {(1,T)};\n        \\node[state, minimum size=\\minsz, below=of four] (four_one) {(1,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five] (five_one) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of five_one] (six_one) {(1,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_one] (seven_one) {\\textbf{\\dots}};\n        \n        % Third Line\n        \\node[state, minimum size=\\minsz, below=of three_one] (three_two) {(2,T)};\n        \\node[state, minimum size=\\minsz, below=of four_one] (four_two) {(2,T+1)};\n        \\node[draw=none, minimum size=\\minsz, below=of five_one] (five_two) {\\textbf{\\dots}};\n        \\node[state, minimum size=\\minsz, right=of five_two] (six_two) {(2,C)};\n        \\node[draw=none, minimum size=\\minsz, right=of six_two] (seven_two) {\\textbf{\\dots}};\n\n        % Fourth line\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of three_two] \n        (three_three) {\\textbf{\\vdots}};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of four_two] \n        (four_three) {\\textbf{\\vdots}};\n        \\node[draw=none, node distance = 2cm, minimum size=\\minsz, below=of five_two] \n        (five_three) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of six_two] \n        (six_three) {\\textbf{\\vdots}};\n\n        % Fifth line\n        % \\node[state, node distance = \\altdist, minimum size=\\minsz, below=of five_three] (general_case_mid) {\\( (u_i, v_i) \\)};\n        \\node[draw=none, node distance = 0.3cm, minimum size=\\minsz, below=of four_three] \n        (general_case_up) {};\n        \\node[state, node distance = \\altdist, minimum size=\\minsz, below=of general_case_up] \n        (general_case_mid) {\\( (u_i, v_i) \\)};\n\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, below=of general_case_mid] \n        (general_case_down) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, left=of general_case_mid] \n        (general_case_left) {};\n        \\node[draw=none, node distance = \\altdist, minimum size=\\minsz, right=of general_case_mid] \n        (general_case_right) {};\n\n        \\draw[every loop]\n            % First Horizontal Edges\n            (zero) edge[bend left] node {\\( \\Lambda \\)} (one)\n            (one) edge[bend left] node {\\( \\mu \\)} (zero)\n            (one) edge[bend left] node {\\( \\Lambda \\)} (two)\n            (two) edge[bend left] node {\\( 2 \\mu \\)} (one)\n            (two) edge[bend left] node {\\( \\Lambda \\)} (three)\n            (three) edge[bend left] node {\\( T \\mu \\)} (two)\n            (three) edge[bend left] node {\\( \\lambda_1 \\)} (four)\n            (four) edge[bend left] node {\\( (T+1) \\mu \\)} (three)\n            (four) edge[bend left] node {\\( \\lambda_1 \\)} (five)\n            (five) edge[bend left] node {\\( (T+2) \\mu \\)} (four)\n            (five) edge[bend left] node {\\( \\lambda_1 \\)} (six)\n            (six) edge[bend left] node {\\( C\\mu \\)} (five)\n            (six) edge[bend left] node {\\( \\lambda_1 \\)} (seven)\n            (seven) edge[bend left] node {\\( C\\mu \\)} (six)\n\n            % Second Horizontal Edges\n            (three_one) edge[bend left] node {\\( \\lambda_1 \\)} (four_one)\n            (four_one) edge[bend left] node {\\( (T+1) \\mu \\)} (three_one)\n            (four_one) edge[bend left] node {\\( \\lambda_1 \\)} (five_one)\n            (five_one) edge[bend left] node {\\( (T+2) \\mu \\)} (four_one)\n            (five_one) edge[bend left] node {\\( \\lambda_1 \\)} (six_one)\n            (six_one) edge[bend left] node {\\( C\\mu \\)} (five_one)\n            (six_one) edge[bend left] node {\\( \\lambda_1 \\)} (seven_one)\n            (seven_one) edge[bend left] node {\\( C\\mu \\)} (six_one)\n\n            % Third Horizontal Edges\n            (three_two) edge[bend left] node {\\( \\lambda_1 \\)} (four_two)\n            (four_two) edge[bend left] node [below] {\\( (T+1) \\mu \\)} (three_two)\n            (four_two) edge[bend left] node {\\( \\lambda_1 \\)} (five_two)\n            (five_two) edge[bend left] node {\\( (T+2) \\mu \\)} (four_two)\n            (five_two) edge[bend left] node {\\( \\lambda_1 \\)} (six_two)\n            (six_two) edge[bend left] node {\\( C\\mu \\)} (five_two)\n            (six_two) edge[bend left] node {\\( \\lambda_1 \\)} (seven_two)\n            (seven_two) edge[bend left] node {\\( C\\mu \\)} (six_two)\n\n            % First Vertical Edges\n            (three) edge[bend left] node {\\( \\lambda_2 \\)} (three_one)\n            (three_one) edge[bend left] node {\\( T \\mu \\)} (three)\n            (three_one) edge[bend left] node {\\( \\lambda_2 \\)} (three_two)\n            (three_two) edge[bend left] node {\\( T\\mu \\)} (three_one)\n            (three_two) edge[bend left] node {\\( \\lambda_2 \\)} (three_three)\n            (three_three) edge[bend left] node {\\( T\\mu \\)} (three_two)\n\n            % Second Vertical Edges\n            (four) edge node {\\( \\lambda_2 \\)} (four_one)\n            (four_one) edge node {\\( \\lambda_2 \\)} (four_two)\n            (four_two) edge node {\\( \\lambda_2 \\)} (four_three)\n\n            % Fourth Vertical Edges\n            (six) edge node {\\( \\lambda_2 \\)} (six_one)\n            (six_one) edge node {\\( \\lambda_2 \\)} (six_two)\n            (six_two) edge node {\\( \\lambda_2 \\)} (six_three)\n\n            % General Case\n            (general_case_left) edge[bend left] node {\\( \\lambda_1 \\)} (general_case_mid)\n            (general_case_mid) edge[bend left] node {\\( v_i \\mu \\)} (general_case_left)\n            (general_case_right) edge[bend left] node {\\( (v_i +1) \\mu \\)} (general_case_mid)\n            (general_case_mid) edge[bend left] node {\\( \\lambda_1 \\)} (general_case_right)\n            % (five_three) edge node {\\( \\lambda_2 \\)} (general_case_mid)\n            (general_case_up) edge node {\\( \\lambda_2 \\)} (general_case_mid)\n            (general_case_mid) edge node {\\( \\lambda_2 \\)} (general_case_down)\n            ;\n    \\end{tikzpicture}\n    \\caption{Markov chain} \n    \\label{Markov_5}\n\\end{figure}\n\n", "meta": {"hexsha": "6ab65b05158aa22b2973545220108b454fb3b1f8", "size": 32514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/main/Miscellaneous/Useful_tikz/main.tex", "max_stars_repo_name": "11michalis11/AmbulanceDecisionGame", "max_stars_repo_head_hexsha": "45164ba51da0417297f715e41716cb91facc120f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/main/Miscellaneous/Useful_tikz/main.tex", "max_issues_repo_name": "11michalis11/AmbulanceDecisionGame", "max_issues_repo_head_hexsha": "45164ba51da0417297f715e41716cb91facc120f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2020-04-20T09:08:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T11:09:25.000Z", "max_forks_repo_path": "tex/main/Miscellaneous/Useful_tikz/main.tex", "max_forks_repo_name": "11michalis11/AmbulanceDecisionGame", "max_forks_repo_head_hexsha": "45164ba51da0417297f715e41716cb91facc120f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.4462025316, "max_line_length": 129, "alphanum_fraction": 0.5420741834, "num_tokens": 10489, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331319177488, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.40912298944612957}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{eqtns}\n\n\\begin{document}\n\n\\section*{PhysRevD.62.044034 equation (10)}\n\n\\begin{cadabra}\n   from shared import *\n   import cdblib\n\n   jsonfile = 'eqtn10.json'\n   cdblib.create (jsonfile)\n\n   DgijDt  = cdblib.get ('adm.DgijDt','adm.json')\n   DdetgDt = cdblib.get ('adm.DdetgDt','adm.json')\n\n   # --------------------------------------------------------------------------\n\n   phi   := \\phi -> (1/12) \\log(detg).\n   gdotK := g^{i j} K_{i j} -> trK.\n\n   # --------------------------------------------------------------------------\n   # d\\phi/dt\n\n   dotphi := \\partial_{t}{\\phi}.     # cdb (eq10.101,dotphi)\n\n   substitute (dotphi, phi)          # cdb (eq10.102,dotphi)\n   substitute (dotphi, dlog)         # cdb (eq10.103,dotphi)\n   substitute (dotphi, DdetgDt)      # cdb (eq10.104,dotphi)\n   substitute (dotphi, DgijDt)       # cdb (eq10.105,dotphi)\n   substitute (dotphi, gdotK)        # cdb (eq10.106,dotphi)\n   map_sympy  (dotphi, \"simplify\")   # cdb (eq10.107,dotphi)\n\n   DphiDt := \\partial_{t}{\\phi} -> @(dotphi).\n\n   cdblib.put ('DphiDt',DphiDt,jsonfile)\n\\end{cadabra}\n\n\\clearpage\n\n\\begin{dgroup*}[spread=5pt]\n   \\begin{dmath*}\n      \\cdb{eq10.101}\n         = \\Cdb*{eq10.102}\n         = \\Cdb*{eq10.103}\n         = \\Cdb*{eq10.104}\n         = \\Cdb*{eq10.105}\n         = \\Cdb*{eq10.106}\n         = \\Cdb*{eq10.107}\n   \\end{dmath*}\n\\end{dgroup*}\n\n\\clearpage\n\n\\begin{cadabra}\n   # --------------------------------------------------------------------------\n   # Check against prd62.\n\n   foo := @(dotphi).                                  # cdb(eq10.lcb,foo)\n   bah  = cdblib.get('prd62.eq10.rhs','prd62.json')   # cdb(eq10.prd,bah)\n\n   diff := @(foo) - @(bah).\n\n   diff = product_sort (diff)\n   rename_dummies (diff)\n   canonicalise   (diff)                              # cdb(eq10.chk,diff)\n\\end{cadabra}\n\n% \\clearpage\n\n\\begin{dgroup*}\n   \\begin{dmath*} \\cdb*{eq10.lcb} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{eq10.prd} \\end{dmath*}\n   \\begin{dmath*} \\cdb*{eq10.chk} \\end{dmath*}\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "858313f1a8246111c2c4b74166acf98a8a79be92", "size": 2046, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/eqtn10.tex", "max_stars_repo_name": "leo-brewin/adm-bssn-equations", "max_stars_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-13T18:47:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-13T18:47:34.000Z", "max_issues_repo_path": "source/eqtn10.tex", "max_issues_repo_name": "leo-brewin/adm-bssn-equations", "max_issues_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/eqtn10.tex", "max_forks_repo_name": "leo-brewin/adm-bssn-equations", "max_forks_repo_head_hexsha": "4fc58cb7db16b87851dfd33950d6540b5c81db50", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8987341772, "max_line_length": 79, "alphanum_fraction": 0.5034213099, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4089413334831328}}
{"text": "\\documentclass[]{article}\n\\usepackage{amsmath}\n\\usepackage{verbatim}\n\\usepackage{algorithmicx}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{tabls}\n\n%opening\n\\title{Estimation of the heat demand}\n\\author{Francesco Baldi}\n\n\\begin{document}\n\n\\maketitle\n\nAs the heat demand is not measured, it is necessary to determine it based on the available indirect measurements. \n\nThe heat demand and generation can be summarized according to the following equations:\n\\begin{eqnarray}\n\\dot{Q}_{gen} & = & \\dot{Q}_{EGB} + \\dot{Q}_{HTHR} + \\dot{Q}_{AB} \\\\\n\\dot{Q}_{dem} & = & \\dot{Q}_{HVAC,PH} + \\dot{Q}_{HVAC,RH} + \\dot{Q}_{HWH} + \\dot{Q}_{TH} + \\dot{Q}_{G} + \\dot{Q}_{OT} + \\dot{Q}_{HTH} + \\dot{Q}_{MSH} \\\\\n\\end{eqnarray}\n\n\\section{Heat balance parameter estimation}\n\nAs not enough information and measurements are available to determine the various components of the heat balance, in this paper we determined them by means of a parameter estimation procedure, using the daily boiler fuel consumption for the calibration of the parameters. The parameter estimation problem is hence written as a minimization problem:\n\\begin{eqnarray}\n\tmin &  \\left(\\frac{\\sum_i(y(\\textbf{p})-\\bar{y})^2}{\\sum_i \\bar{y}^2}\\right)^{0.5} \\\\\n\\end{eqnarray}\n\nwhere the vector $\\textbf{p}$ includes the calibration parameters that are part of the heat demand and generation estimation model that is explained in detail in the following sections. A list of the parameters $\\textbf{p}$ is shown in Table REF, together with the chosen upper and lower boundaries for the calibration procedure.\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{p{3cm}ccp{1.6cm}p{1.6cm}p{1.2cm}}\n\t\t\\hline \n\t\tParameter name & Symbol  & Unit & Lower Boundary & Higher Boundary & Optimal value \\\\ \n\t\t\\hline\n\t\tConstant HTHR heat demand\t & $\\dot{Q}_{k,HTHR}$ & kW & 0 & 1000 & 137 \\\\ \n\t\tConstant steam demand\t\t & $\\dot{Q}_{k,steam}$ & kW & 0 & 1000 & 177 \\\\\n\t\tWeight factor of the HVAC Re-heater & $f_{HVAC,RH}$ & - & 0.5 & 1 & 0.59 \\\\ \n\t\tWeight factor of the HVAC Pre-heater & $f_{HVAC,PH}$ & - & 0 & 1 & 0.98 \\\\ \n\t\tWeight factor of hot water heater & $f_{HWH}$ & - & 0.5 & 1 & 0.71 \\\\ \n\t\tWeight factor of the galley & $f_{G}$ & - & 0.5 & 1 & 0.55 \\\\ \n\t\tWeight factor of the other consumers & $f_{Other}$ & - & 0.5 & 1 & 0.27 \\\\ \n\t\tHTHR inlet temperature & $T_{HTHR,ER1,in}$ & K & 343 & 353 & 345 \\\\\n\t\tEffectiveness of the HTHR HEX & $\\epsilon_{HTHR} $ & - & 0.5 & 0.9 & 0.72 \\\\\n\t\tBoiler drum steam storage capacity & $Q_{ab,max}$ & MJ & 100 & 100000 & 5580 \\\\ \n\t\tBoiler heat rate & $\\dot{Q}_{ab,des}$ & kW & 2000 & 8000 & 2920 \\\\ \n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Parameters optimized in the parameter estimation for the heat balance}\n\t\\label{tab:ParameterEstimation} \n\\end{table}\n\n\n\n\\section{Heat demand}\n\nWe calculated the heat demand as the sum of the contributions of the elements listed in the ship's heat balance documentation. As no direct measurement of these quantities was available in the dataset, they had to be estimated based on the following assumptions:\n\\begin{table}\n\t\\centering\n\t{\\tablinesep=2ex\\tabcolsep=10pt\n\t\\begin{tabular}{p{2.8cm}l}\n\t\t\\hline \n\t\tHeat flow name & Equation \\\\\n\t\t\\hline\n\t\tHVAC Preheater & $\\dot{Q}_{HVAC,PH} = f_{HVAC,RH} \\dot{Q}_{HVAC,PH,des} \\dfrac{\\dot{W}_{HVAC}(t)}{\\dot{W}_{HVAC,max}} $ \\\\\n\t\tHVAC Reheater &\t$\\dot{Q}_{HVAC,RH} = f_{HVAC,PH} \\dot{Q}_{HVAC,PH,des} \\dfrac{T_{in} - T_{air,out}(t)}{T_{in} - T_{air,out,des}}$ \\\\\n\t\tHot water heater& $\\dot{Q}_{HWH} = f_{HWH} \\dot{Q}_{HWH,des} \\Phi_{HWH}(\\hat{t})$ \\\\\n\t\tGalley & $\\dot{Q}_{G} = f_{G} \\dot{Q}_{G,des} \\Phi_G(\\hat{t})$ \\\\\n\t\tLow temperature tank heating & $\\dot{Q}_{TH} = f_{TH} \\dot{Q}_{TH} \\dfrac{T_{T} - T_{air,out}(t)}{T_{T} -T_{air,out,des}}$ \\\\\n\t\tHFO tank heating & $\\dot{Q}_{HTH} = f_{HTH} \\dot{Q}_{HTH} \\dfrac{T_{HT} - T_{air,out}(t)}{T_{HT} - T_{air,out,des}}$ \\\\\n\t\tMachinery space heating & $\\dot{Q}_{MSH} = f_{MSH} \\dot{Q}_{MSH} \\dfrac{T_{MS} - T_{air,out}(t)}{T_{MS} - T_{air,out,des}}$ \\\\\n\t\tHFO heater & $\\dot{Q}_{HH} = \\dot{m}_{HFO}(t) c_{p,HFO} (T_{HFO,inj} - T_{HT})$ \\\\\n\t\t\\hline\n\t\\end{tabular}}\n\t\\caption{Summary of the heat demand contributions and their calculation}\n\t\\label{tab:HeatDemand}\n\\end{table}\n\nwhere all $f_i$ factors are treated as calibration parameters (see table \\ref{tab:ParameterEstimation}). The $\\Phi_G(\\hat{t})$ and $\\Phi_{HWH}(\\hat{t})$ functions represent the assumption made on the daily evolution of the heating demand from the galley and the hot water heater respectively. The daily evolutions of the demand are considered to be the same over the whole year of operations and are represented graphically in Figure REF.\n\n\n\n\\section{Heat generation}\n\n\\subsection{Exhaust gas boilers}\n\nThe heat recovered in the EGBs is the only contribution to the heat balance that is known with a reasonable certainty. The heat transferred from the exhaust gas to the steam ($\\dot{Q}_{EGB}$) is calculated according to equation \\ref{eq:egb}:\n\\begin{equation}\n\\dot{Q}_{EGB} = \\dot{m}_{eg} c_{p,eg} (T_{eg,EGB,in} - T_{eg,EGB,out})\n\\end{equation}\\label{eq:egb}\n\nwhere $T_{eg,EGB,out}$ and $T_{eg,EGB,in}$ are measured for all EGBs, $c_{p,eg}$ is calculated as a function of the exhaust gas composition and temperature, and $ \\dot{m}_{eg} $ is calculated based on the engine energy and mass balance as described in section REF and in the appendix REF\n\n\\subsection{High Temperature Heat Recovery}\n\nIt is known that the ship heating systems are designed for recovering energy from the high temperature cooling systems of all the ship's engines. However, measurements of this contribution and of other variables that could lead to its straight-forward identification are missing. In this work, we calculated the heat exchanged in the two HTHRs according to equation \\label{eqn:HTHR2},\n\n\\begin{eqnarray}\n\\dot{Q}_{HTHR} & = & \\dot{Q}_{HTHR,ER1} + \\dot{Q}_{HTHR,ER2} \\label{eqn:HTHR1} \\\\\n & = & \\sum_{i=ER1,ER2}{\\epsilon_{HTHR} * \\dot{m}_{min,HTHR,i} * c_{p,w} * (T_{HT,out,i} - T_{HRHT,i,in})} \\label{eqn:HTHR2}\n\\end{eqnarray}\n\nwhere the effectiveness of the heat exchanger $\\epsilon_{HTHR}$ is considered to be constant and its value is part of the parameter estimation problem (see table \\ref{tab:ParameterEstimation}). The HT water outlet temperature for each engine room is calculated based on the thermal balance of the engines, and the HR water at the HTHR inlet ($T_{HRHT,ER1,in}$) is considered as a calibration parameter. \n\n\\subsection{Auxiliary boilers}\n\nThe heat generated by the auxiliary boilers is calculated as to close the heat balance of the ship energy systems. The contribution of the boiler heat storage capacity is taken into account by a calibration parameter $Q_{ab,max}$ that determines the maximum heat deficit. This corresponds, in practice, to assuming that the boiler is started up when the steam pressure inside the boiler drops below a certain value, and stopped once the pressure has achieved its maximum operative value. The calculation can be represented as follows\n\n\n\t\\begin{algorithmic}[1]\n\t\t\\State{Calculate the heat balance with no contribution from oil fired boilers}\n\t\t\\While{$\\int{(\\dot{Q}_{HTHR}(t) + \\dot{Q}_{EGB}(t) - \\dot{Q}_{dem}(t)) dt} < - Q_{ab,max}$}\n\t\t\t\\State{Find $ t^* | \\int_{t_0}^{t^*}{(\\dot{Q}_{HTHR}(t) + \\dot{Q}_{EGB}(t) - \\dot{Q}_{dem}(t))dt} = 0 $}\n\t\t\t\\State{$\\dot{Q}_{ab}(t^*:t^*+\\frac{Q_{ab,max}}{\\dot{Q}_{ab,des}}) = \\dot{Q}_{ab,des}$}\n\t\t\\EndWhile\n\t\\end{algorithmic}\n\nwhere the calibration parameters are the heat storage capacity ($Q_{ab,max}$) and the fixed heat rate ($\\dot{Q}_{ab,des}$) of the auxiliary boilers (see table \\ref{tab:ParameterEstimation}).\n\n\n\n\n\n\\section{Parameter estimation and uncertainty quantification}\n\nThe results of the parameter estimation are represented graphically and quantitatively in Figure REF and Table REF. \n\n\n\nGiven the lack of input values for the estimation of the heat demand, the provided estimate based on the procedure described above should be integrated with an estimation of the uncertainty. \n\nIn this study, we base the estimation of the uncertainty on the production side, as it is the one that has the largest amount of information available. In these regards, the uncertainty can be reduced to the contribution of three elements: $U(\\dot{Q}_{EGB})$, $U(\\dot{Q}_{HTHR})$, $U(\\dot{Q}_{AB})$.\n\nThe uncertainty on the heat generated in the EGBs can be further subdivided based on its definition as a composition of the uncertainty of $T_{eg,EGB,in}$, $T_{eg,EGB,out}$, $\\dot{m}_{eg}$, and $c_{p,eg}$. In the case of $T_{eg,EGB,in}$ and $T_{eg,EGB,out}$, measured values are used, where the uncertainty is related to the sensors (K-type thermocouples) that can be as high as 4\\% [CIT]. The uncertainty on the $\\dot{m}_{eg}$ is related to the calculation assumptions as described in Appendix REF, and can be estimated of being up to 10\\%. The uncertainty of the $c_{p,eg}$ value, given that both composition and temperature are accounted for, should be within 5\\% of the reference value. These assumptions lead to the following estimation of the uncertainty:\n\\begin{equation}\n\\frac{\\delta \\dot{Q}_{gen}}{\\dot{Q}_{gen}} = \\sqrt{\\frac{\\delta \\dot{m}_{eg}^2}{\\dot{m}_{eg}^2} + \\frac{\\delta c_{p,eg}^2}{c_{p,eg}^2} + \\frac{\\delta T_{EGB,in}^2 + \\delta T_{EGB,out}^2}{(T_{EGB,in} - T_{EGB,out})^2}}\n\\end{equation}\n\nThat once typical values are assigned can be as high as 30\\%, where most of the variability is related to the temperature measurements (result obtained for $\\pm 20$ K uncertainty. The uncertainty is reduced to 20\\% if the measurement uncertainty on the temperature is reduced to  $\\pm 20$ K) \n\nThe uncertainty of the heat generated by the ABs can be reduced to the contribution of two elements: the uncertainty on $\\dot{m}_{fuel,AB}$ and that on $\\eta_{AB}$. The former will be at least as large as the calibration error (35\\%) and will be considered equal to 50\\% to be conservative and accounting also for errors in the aggregated boiler fuel measurements. In addition, the uncertainty on the efficiency can be considered to be around 10\\% based on the discrepancy between the considered sources and on the expected variability of the efficiency with load. Similarly to the previous case, the combination of these efficiencies lead to a total uncertainty of 51\\%, where the main contribution comes from the uncertainty of the model output compared to the actual fuel consumption.\n\nThe estimation of the uncertainty of $\\dot{Q}_{HTHR}$ can be based on \\ref{eqn:HTHR2} having assigned an acceptable variation of 20\\% to the effectiveness of the heat exchanger, 20\\% on the estimation of the reference mass flow, $\\pm 5$ K uncertainty on water temperature measurements and considering negligible the uncertainty on $c_{p,w}$, leading to a 145\\% uncertainty on this measurement. \n\n\n\\end{document}\n", "meta": {"hexsha": "c482c84435e87e74a183c3ba8bc5042a05ab20db", "size": 10761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/Other/HeatDemandMethodology.tex", "max_stars_repo_name": "francescobaldi86/Ecos2015PaperExtension", "max_stars_repo_head_hexsha": "486cbb770c5394938f08af3d880d1300d71dc753", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-09-05T10:58:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-21T07:28:36.000Z", "max_issues_repo_path": "Manuscript/Other/HeatDemandMethodology.tex", "max_issues_repo_name": "francescobaldi86/Ecos2015PaperExtension", "max_issues_repo_head_hexsha": "486cbb770c5394938f08af3d880d1300d71dc753", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manuscript/Other/HeatDemandMethodology.tex", "max_forks_repo_name": "francescobaldi86/Ecos2015PaperExtension", "max_forks_repo_head_hexsha": "486cbb770c5394938f08af3d880d1300d71dc753", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-03-14T19:30:37.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-10T10:07:43.000Z", "avg_line_length": 72.2214765101, "max_line_length": 787, "alphanum_fraction": 0.7197286498, "num_tokens": 3228, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802471698041, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4089413254121544}}
{"text": "%\n% Chapter 4\n%\n\n\\chapter{Monte Carlo event generation}\n\\label{event_sim}\n\n\\section{Introduction}\n\nAccurate simulations for signal and backgrounds are needed for searches for new physics. The primary collision and the decay processes in an event can be described by perturbative QFT. However, perturbative QCD (pQCD) cannot describe the QCD bound states. Therefore phenomenological models are needed to describe hadronization.\n\nEvent generators are used for generating simulated particle physics events. Event generators factorize the full process of the event simulation into individual tasks. MC methods are used for the probabilistic branching between these individual problems. MC methods are a class of computational algorithms that rely on repeated random sampling to have the same average behavior in simulation as in collision data. Event signature beyond SM particles can be generated to compare its signature to one of the generated background processes.\n\nGeneral-purpose Monte Carlo (GPMC) generators, like PYTHIA~\\cite{Sjostrand:2014zea}, provide fully exclusive simulations of high energy collisions. However, there are also event generators that are specialized in a certain aspect of the event simulation. Perturbative matrix elements for the scattering process are implemented in matrix element generators. Hadronic event generators simulate the initial and final state particle showers, hadronization, and soft hadron-hadron physics, including the initial state's composition and substructure. An overview of different steps in MC generation for \\pp collision events can be seen in Figure~\\ref{fig:simulation}.\n\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics[width=0.8\\textwidth]{plots/chapter4/simulation.png}\n  \\caption{MC simulation of an event in \\pp collisions.}\n  \\label{fig:simulation}\n\\end{figure}\n\n\n\\section{Monte Carlo simulation}\n\nThe primary hard interaction process and the decay of short-lived particles happen at short distance scales. The QCD and QED radiation at a time scale much below $\\frac{1}{\\Lambda}$, where $\\Lambda$ is a typical hadronic scale of a few hundred~\\MeV, are also happening at short distance scales. Soft and collinear safe inclusive observables, such as total decay widths or inclusive cross-sections, can be computed with pQCD theory for momentum scales much larger than this scale. The final state collinear splittings and soft emissions give rise to large logarithmically divergent corrections, which cancel against virtual corrections in the total cross-section. Initial state collinear singularities are factorized into parton distribution functions (PDFs). Therefore, the cross-section remains accurate up to higher-order corrections if interpreted as an inclusive cross-section. If this is not the case, then the QCD singularities can lead to a non-convergence of the fixed order expansion.\n\n\\textbf{Matrix element generator:} Matrix element generators generate the exact matrix elements for the production of the process. They also produce a certain number of additional partons for hard, large-angle emissions. The radiation of extra partons is not included at the tree level accuracy of the hard process. The radiation of an extra parton with tree level accuracy can be included to provide next-to-leading-order (NLO) corrections along with all NLO virtual corrections. The parton shower algorithms use as input the final state partons of the hard process and their phase space.\n\n\\textbf{Parton shower algorithm:} The parton shower algorithm is used for computing the cross-section for a generic hard process. Parton level events are transferred from a hard process generator to a shower generator, containing a list of particles and the used free parameters, using the Les Houches Event File standard~\\cite{Alwall:2006yp}. The kinematics of the basic process is first generated, followed by a sequence of independent shower splittings. The cross-section for the given final state is calculated by assigning a probability to each splitting vertex. Collinear emissions and soft gluon emissions at arbitrary angles are the two sources of infrared singularities in massless field theories like QCD. PYTHIA uses a $\\text{p}_{\\perp}$ ordered shower evolution for correctly describing both effects.\n\n\\textbf{Matching:} QCD color confinement restricts quarks and gluons from existing as isolated particles. The hadronization of a quark or a gluon gives rise to hadrons or their decay products. Jets are collimated bunches of these hadrons. The collinear/soft radiation of an appropriate (N + 1) parton final state, generated by a matrix element generator, can give rise to a (N + 1) jet event. A (N + 1) jet event can also be obtained from an N parton final state with hard, large-angle emission during shower evolution. A matching has to be done if different generators have been used to generate matrix elements and parton showers or extra partons generated by the hard process generator.\n\n\\textbf{Hadronization models:} The hadronization scale $\\text{Q}_{\\text{had}}$ is by construction equal to the infrared cut-off where the parton shower ends. Colored partons are transformed into a set of colorless hadrons by GPMCs. This happens at scales with low momentum transfers and at long distances, where non-perturbative effects become important. GPMCs use models that rely on the color flow information between partons as a starting point for hadronization.\n\n\\textbf{Soft hadron-hadron physics modeling :} Underlying-event is the additional activity beyond the basic process and its associated initial- and final-state radiation. The dominant part is coming from additional color exchanges between the beam remnants. Multiple parton-parton interactions (MPI) can produce two or more back-to-back jet pairs, with each pair having a small transverse momentum. Most MPI are soft, and they influence the color flow and the event's total scattered energy. This increases the particle multiplicity in the final state and affects the final state activity. Compared to events with no hard jets, the hard jets appear to sit on top of a higher ``pedestal'' of underlying activity. This comes from the impact parameter dependence since central collisions are more likely to contain at least one hard scattering due to the higher probability of interactions and is called the ``jet pedestal'' effect.\n\n\\textbf{Parameter Tuning:} The accuracy of the used models is very important for event simulation. The accuracy depends on the inclusiveness of the chosen observables and the sophistication of the simulation. The models can be improved by improving the theoretical calculations. The precision also depends on the constraints in the free parameters, and existing collision data constrains them and is referred to as generator tuning. MC generators are not tuned beyond the constraints in theoretical and experimental precision to avoid overfitting. The final state of the particles and their spectra are influenced by event modeling and generator tuning. Events generated with different generators or tunes can differ and might not describe the collision data in the entire phase space.\n\n\n\\section{Monte Carlo generators}\n\nPYTHIA has been developed for multi-particle production in \\pp collisions and simulation of jets. PYTHIA can generate hard subprocess, initial and final state parton showers, hadronization, decays, and the underlying-event. Many hard processes have been implemented for generating the matrix elements for final state and phase space calculation. PYTHIA can optimally generate $2 \\to 1$ and $2 \\to 2$ processes. Resonance decays with the resonance masses above the b quark system are implemented. Their branching fractions and partial width can be dynamically calculated as a function of their mass. If the spin information is available for resonance decays, it leads to angular correlations of the resonance decay products; otherwise, the resonance decays isotropically. GPMC generators like PYTHIA can simulate the full process. However, there are specialized generators that deal with a certain aspect of the event simulation.\n\n\\textbf{MadGraph:} MadGraph generates the matrix element with leading-order (LO) accuracy~\\cite{Alwall:2011uj}. MadGraph is a matrix element generator for processes that involve final states with a large number of jets, heavy flavor quarks, leptons, and missing energy. Events from new physics models that are renormalizable or from an effective field theory written in a Lagrangian can be generated. The full amplitude is split into gauge invariant sub-amplitudes. The matrix element contains the full spin correlation and Breit-Wigner effects but is not valid far from the mass peak.\n\n\\textbf{POWHEG:} POWHEG is a framework for implementing NLO matrix element calculations~\\cite{Alioli:2010xd}. It includes NLO virtual corrections and radiation of an extra parton in the matrix element. It needs the LO matrix elements and the finite part of the virtual corrections as input from which it finds all the singular regions. The singular regions are characterized by a final state parton becoming collinear or soft to either an initial state parton or a final state parton. The singular regions can be grouped according to their underlying LO diagram by replacing this parton pair with a single parton of appropriate flavor.\n\n\\textbf{aMC@NLO:} aMC@NLO implements all aspects of NLO computation and its matching with parton showers~\\cite{Frederix:2011ss, Alwall:2014hca}. NLO calculations can be achieved by combining one-loop matrix elements and tree-level matrix elements. Tree level computations are performed using MadGraph, and one-loop amplitudes are evaluated with MadLoop~\\cite{Hirschi:2011pa}. The matched samples which differ by their final state multiplicity can be merged using the FxFx merging scheme.\n\n\\textbf{MLM matching:} MLM matching scheme is a matching algorithm~\\cite{Mangano:2001xp, Mangano:2002ea} that matches partons from matrix element calculations to jets reconstructed after shower generation. Parton level events are required to have a separation greater than a minimum value $\\text{R}_{\\text{jj}} > \\text{R}_{\\text{min}}$ between them and at least a minimum transverse energy $\\text{E}^{\\text{min}}_{\\text{T}}$ for partons. The jet closest in $(\\eta, \\phi)$ to the hardest parton is selected, and both match if the distance is smaller than $\\text{R}_{\\text{min}}$. Once a match is found, the jet is removed, and matching is done with the next parton. If a match is not found, then the event is rejected. This is the case for collinear partons or soft partons, which do not lead to an independent jet or are too soft for jet reconstruction.\n\n\\textbf{FxFx merging:} FxFx merging scheme is an NLO merging procedure~\\cite{Frederix:2012ps}. There can be NLO accuracy for exclusive events with J light jets by the computation based on matrix elements that have J and (J + 1) partons. NLO mergings are more complicated than LO ones. This is because the matrix elements are considered twice, as Born contribution for processes with J partons and as the real emission contribution, infrared subtraction terms, and the one-loop contributions to processes with (J - 1) partons. Events are reweighted, and a certain amount of events might carry negative weights.\n\n\n\\section{Detector simulation}\n\nIn detector simulation, the interactions of particles with the detector material and the detector response are simulated. These events can then be reconstructed and analyzed. Geant4~\\cite{Agostinelli:2002hh} is used for detector simulation. It is a toolkit for simulating particles' passage through matter and for simulating particle interactions with matter across a very wide energy range. The user defines the detector geometry and materials. A large number of components with different shapes and materials can be included in the geometrical model. Sensitive elements can be defined, which record information in the form of hits. Hits are needed to simulate the detector responses called digitization. The detector's geometrical structure is divided into logical and physical volumes. Logical volumes contain the information of the material and the sensitive detector behavior. A mixture of different elements and isotopes can be used for the material. Physical volumes carry information about the spatial positioning or placement of the logical volumes.\n\nParticles can interact with the detector material or can decay while they are transported through the geometry. A model can be implemented by electromagnetic and hadronic processes in Geant4 depending on the energy or particle type. Geant4 can handle ionization described by energy loss and range tables, bremsstrahlung, pair production of electron-positrons from photons, photoelectric effect, pair conversion, annihilation, synchrotron, and transition radiation, scintillation, refraction, reflection, absorption, the Cherenkov effect, and many other processes. Particles with their basic properties, like mass, charge, and sensitive processes, can be defined. Particles are transported in steps, and they are tracked through materials and external electromagnetic fields. Event data is generated during simulation. First, events contain primary vertices and primary particles before processing an event. After processing, hits and digitizations generated by simulation are added. Trajectories of simulated particles can be added optionally for the recording of ``simulation truth.''\n\n\n\\section{Monte Carlo samples}\n\nMC simulated event samples are used to model signal and background contributions to all the analysis regions with several event generators. In all cases, parton showering, hadronization, and underlying-event properties are modeled using PYTHIA version 8.212. The PYTHIA parameters affecting the description of the underlying-event are set to the CUETP8M1 tune in 2016~\\cite{Khachatryan:2015pea}, except for the \\ttbar sample where the CP5 tune is used, which is also the tune in 2017 and 2018~\\cite{CMS:2018zub}. The NNPDF3.0 PDF set is used for all 2016 samples, and the NNPDF3.1 PDF set is used for the 2017 and 2018 samples~\\cite{Ball:2017nwa}.\n\nSimulation of interactions between particles and the CMS detector is based on Geant4. The same reconstruction algorithms used for data are applied to simulated samples as well. The Higgs bosons are produced in \\pp collisions predominantly by gluon gluon fusion (ggF)~\\cite{Georgi:1977gs}, but also by vector boson fusion (VBF)~\\cite{Cahn:1986zv}, and in association with a vector boson (W/Z)~\\cite{Glashow:1978ab}. The ggF, VBF, and associated production Higgs boson samples are generated with POWHEG generator in the implementation described in Ref.~\\cite{Heinrich:2017kxx, Buchalla:2018yce}. We only consider Higgs boson produced in ggF and VBF production mechanisms and do not use associated production Higgs boson samples for the signal.\n\nEmbedded samples are data samples with well-identified \\Zmm events from which muons are removed, and simulated tau leptons are embedded with the same kinematics as the replaced muons. These samples are employed for the data-driven estimation of the \\Ztt and some \\ttbar/Diboson/Single Top background. The MadGraph generator is used to simulate the $\\Zee/\\Pgm{}\\Pgm + \\text{jets}$ process along with the \\wjets background process. They are simulated at LO with MLM jet matching and merging schemes~\\cite{Alwall:2007fs}.\n\nDiboson production is simulated at NLO using aMC@NLO generator with FxFx jet matching and merging scheme. Top quark pair and single top quark production simulated samples are generated using POWHEG. Events have multiple \\pp interactions per bunch crossing (pileup) because of the high instantaneous luminosities attained during data-taking period. The effect is taken into account in simulated samples by generating concurrent minimum bias events. All simulated samples are weighted to match the pileup distribution observed in the data.\n", "meta": {"hexsha": "37940f4bf6805cdc1d0e360281ded79e2cd76e9d", "size": 15947, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapter4.tex", "max_stars_repo_name": "psiddire/nddiss", "max_stars_repo_head_hexsha": "9a7a4ae447331fb76b458374b9a3511298df309d", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chapter4.tex", "max_issues_repo_name": "psiddire/nddiss", "max_issues_repo_head_hexsha": "9a7a4ae447331fb76b458374b9a3511298df309d", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapter4.tex", "max_forks_repo_name": "psiddire/nddiss", "max_forks_repo_head_hexsha": "9a7a4ae447331fb76b458374b9a3511298df309d", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 221.4861111111, "max_line_length": 1085, "alphanum_fraction": 0.8153884743, "num_tokens": 3402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059462938815, "lm_q2_score": 0.5156199157230157, "lm_q1q2_score": 0.4089412211874738}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[english]{babel}\n \n \n\\title{First Document}\n\\author{Gubert Farnsworth}\n\\date{ }\n \n\\begin{document}\n \n\\maketitle\n \n\\tableofcontents\n \n\\part{First Part of this document}\n \n\n\\section{Introduction}\n \nThis is the first section.\n \n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{corollary}{Corollary}[theorem]\n\\newtheorem{lemma}[theorem]{Lemma}\n \n\\section{Introduction}\nTheorems can easily be defined\n \n\\begin{theorem}\nLet $f$ be a function whose derivative exists in every point, then $f$ is \na continuous function.\n\\end{theorem}\n \n\\begin{theorem}[Pythagorean theorem]\n\\label{pythagorean}\nThis is a theorema about right triangles and can be summarised in the next \nequation \n\\[ x^2 + y^2 = z^2 \\]\n\\end{theorem}\n \nAnd a consequence of theorem \\ref{pythagorean} is the statement in the next \ncorollary.\n \n\\begin{corollary}\nThere's no right rectangle whose sides measure 3cm, 4cm, and 6cm.\n\\end{corollary}\n \nYou can reference theorems such as \\ref{pythagorean} when a label is assigned.\n \n\\begin{lemma}\nGiven two line segments whose lengths are $a$ and $b$ respectively there is a \nreal number $r$ such that $b=ra$.\n\\end{lemma} \n\\section{Second Section}\n \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.  \nEtiam lobortis facilisissem.  Nullam nec mi et neque pharetra \nsollicitudin.  Praesent imperdiet mi necante...\n \n\\subsection{First Subsection}\nPraesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...\n \n\\section*{Unnumbered Section}\nLorem ipsum dolor sit amet, consectetuer adipiscing elit.  \nEtiam lobortis facilisissem\n\n\\section{Introduction}\n \nThis is the first section.\n \nLorem  ipsum  dolor  sit  amet,  consectetuer  adipiscing  \nelit.   Etiam  lobortisfacilisis sem.  Nullam nec mi et \nneque pharetra sollicitudin.  Praesent imperdietmi nec ante. \nDonec ullamcorper, felis non sodales...\n  \n\\section{Second Section}\n \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.  \nEtiam lobortis facilisissem.  Nullam nec mi et neque pharetra \nsollicitudin.  Praesent imperdiet mi necante...\n \n\\section{Third Section}\n \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.  \nEtiam lobortis facilisissem.  Nullam nec mi et neque pharetra \nsollicitudin.  Praesent imperdiet mi necante...\n\n\n\\end{document}\n", "meta": {"hexsha": "f848ecc37f12d5f9d5e6beba5b31e888b79703cf", "size": 2299, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "template/template.tex", "max_stars_repo_name": "JayD1/Tex-files", "max_stars_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "template/template.tex", "max_issues_repo_name": "JayD1/Tex-files", "max_issues_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "template/template.tex", "max_forks_repo_name": "JayD1/Tex-files", "max_forks_repo_head_hexsha": "b5ea41b81aa993ee00b61440847b9d64edc08e1a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2637362637, "max_line_length": 78, "alphanum_fraction": 0.7633753806, "num_tokens": 674, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.40873243238382295}}
{"text": "When source identification is performed following initial detection of a\ncontamination incident, it is likely that the identified set of\npossible injection locations is fairly large due to the limited\nmeasurement information available at the early stages of detection.\nAs time progresses, more measurements become available to help\ndecrease the number of possible injection locations. It is possible to\nobtain additional measurements in the form of grab samples from\noptimally selected locations that can help in quickly narrowing down\nthe set of likely incident locations when source inversion\ncalculations are performed again. The \\code{grabsample} subcommand can be used to\nidentify optimal grab sample locations \nthat are likely to provide the most information in narrowing down the \nlist of possible injection locations identified from\nthe \\code{inversion} subcommand.\n\nA flowchart representation of the \\code{grabsample} subcommand is\nshown in Figure \\ref{fig:grabsample_flowchart}. The required input\nfor the \\code{grabsample} subcommand includes a utility network model\nspecified with an EPANET 2.00.12 compatible input file (INP) and a list of\nlikely injection scenarios.\n%A flowchart representation of the \\code{grabsample} subcommand, used in conjunction with the \n%\\code{inversion} subcommand, is shown in Figure \\ref{fig:inversion_grabsample_flowchart}. \n\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[scale=0.75]{graphics/grabsample_flowchart.pdf}\n  \\caption{Grab sample flowchart.}\n  \\label{fig:grabsample_flowchart}\n\\end{figure}\n\n\\section{Grab Sample Formulations}\nThe \\code{grabsample} subcommand contains three different grab sampling formulations, \nthe distinguishability formulation and two probability-based formulations.\nThe probability functions will likely be faster for larger problems (linear scaling), while the distinguishability formulation scales quadratically with the number of contamination scenarios. \nThe following subsections provide brief descriptions of these formulations.\n\n\\subsection{Distinguishability Formulation}\n\\label{grabsample_formulation}\nConsidering two possible contamination incidents $i$ and $j$, if a\nparticular sample location is impacted by incident $i$, but not\nimpacted by incident $j$, then this sample location is able to\ndistinguish between the two incidents. The \\code{grabsample} subcommand\ncan be used to identify grab sample locations that maximize the number\nof pairwise distinguishable incidents in a list of possible\ncontamination incidents. The <output prefix>profile.tsg obtained\nfrom the \\code{inversion} subcommand contains a list of possible injection\nlocations. The data sets required by the optimization formulation\nbelow are obtained by simulating each possible incident using the\nEPANET 2.00.12 hydraulics model and either the EPANET 2.00.12 water quality model or the Merlion water quality model \\citep{Mann1},\nwhich can be selected using the merlion option in the scenario block of the configuration file.\n\nThe distinguishability problem formulation is:\n\\begin{align}\n\\textrm{maximize}\\qquad &\\sum_{(i,j) \\in PE} d_{ij}\\label{eqn.grabsample_obj}\\\\\n\\textrm{subject to} \\qquad &\\sum_{n \\in D_{ij}}s_n \\geq d_{ij} &&\\forall \\left( i,j \\right) \\in PE \\label{eqn.grabsample_cons1} \\\\\n&\\sum_{n \\in G}s_n \\leq S_{\\max} + \\left|F\\right|\\label{eqn.grabsample_cons2} \\\\\n&s_n \\in \\lbrace 0,1 \\rbrace &&\\forall \\; n \\in G \\label{eqn.grabsample_cons3}\\\\\n&s_n = 1 &&\\forall \\; n \\in F \\label{eqn.grabsample_cons5}\\\\\n&0 \\leq d_{ij} \\leq 1 &&\\forall \\left( i,j \\right) \\in PE \\label{eqn.grabsample_cons4}\n\\end{align}\n\nwhere $G$ is the set of all grab sample locations, $F$ is the set of\nfixed sensor locations and $PE$ is the pairwise set of all candidate\nincidents (i.e., possible contamination incidents). The variable $D_{ij}$ is\nthe set of sample locations that distinguish incident $i$ from\nincident $j$; $S_{max}$ is the maximum number of samples that can be\ntaken at the same time (i.e., number of sampling teams); $s_n$ is a\nbinary variable that is 1 if node $n$ is a good sample and is 0 otherwise; and\n$d_{ij}$ is a continuous variable that will be 1 if incident $i$ is\ndistinguishable from incident $j$ and is 0 otherwise.\n\nEquation \\ref{eqn.grabsample_obj} represents the mixed-integer programming (MIP) objective, which\nmaximizes the number of pairwise distinguishable incidents.\nEquation \\ref{eqn.grabsample_cons1} requires that at least one or more\nsample locations be selected for a distinguishable incident.\nEquation \\ref{eqn.grabsample_cons2} limits the number of selected\nlocations to be less than or equal to the number of sampling teams (specified by the user).\nEquation \\ref{eqn.grabsample_cons3} defines $s_n$ as a binary variable. \nEquation \\ref{eqn.grabsample_cons5} ensures that the fixed sensor\nlocations are always sampled since measurements from these fixed sensors \nare always available, which avoids double counting distinguished incidents. This formulation is the default formulation solved in the \\code{grabsample} subcommand.  \n\n\\subsection{Probability-based Formulations}\n\\label{probabilityFormulations}\nFrom a source inversion perspective, the contamination incident that agrees with the largest number of measurements is the contamination incident with the higher probability of occurrence. Similarly, all contamination incidents that disagree with many of the measurements have a low probability of occurrence. Following this idea, two optimization formulations were implemented in the \\code{grabsample} subcommand in order to determine optimal sampling locations that are intended to maximize the probability of identifying the true contamination incident (or minimizing the probability of incidents that did not occur).\n\n\\subsubsection{Maximization of expected number of scenarios that disagree with measurements}\n\nGiven a set of potential contamination incidents, a few scenarios will agree with all the measurements, while many more will disagree. For this reason, the formulations in this section aim to select locations that maximize the number of disagreements between incidents and measurements (quickly reduce the probabilities of the incidents that are not likely to be consistent with observations). The development of an MILP problem formulation that meets this goal is presented next.\n\n\\begin{align}\n%& \\underset{x, P_{s}^{\\textrm{miss}}, P_{s}^{\\textrm{match}}}{\\textrm{max}} \n\\textrm{maximize} \\qquad&\\;\\; \\sum_{s\\in S}P_{s}^{\\textrm{miss}} &  \\label{eqn.p1_obj}\\\\\n\\textrm{subject to} \\qquad &P_{s}^{\\textrm{miss}} = 1-P_{s}^{\\textrm{match}} & \\;\\forall \\; s \\in S \\label{eqn.p1_c1}\\\\\n&P_{s}^{\\textrm{match}} = \\exp(\\tilde{P}_{s}) & \\forall \\; s \\in S \\label{eqn.p1_c2}\\\\\n&\\tilde{P}_{s} = \\sum_{n\\in N} x_n \\ln(\\alpha_{s,n}) & \\forall \\; s \\in S \\label{eqn.p1_c3}\\\\\n&\\sum_{n\\in N} x_n \\le S_{\\textrm{max}} & \\label{eqn.p1_c4}\\\\\n&x_{n} \\in \\{0,1\\} & \\forall \\; n \\in N  \\label{eqn.p1_c5}\n\\end{align}\n\nHere $P_{s}^{\\textrm{miss}}$ is the probability that incident $s$ disagrees with the outcome of the measurements at the selected locations. $P_s^{\\textrm{match}}$ (complement of  $P_{s}^{\\textrm{miss}}$) is given by the product of the probabilities $\\alpha_{s,n}$ over all selected sampling locations,   \n\n\\begin{equation}\nP_s^{\\textrm{match}}= \\prod_{n\\in N} \\alpha_{s,n}^{x_n}\n\\end{equation}\n\nwhere $x_n$ is a binary variable that will be $1$ if location $n$ is selected for sampling, and is $0$ otherwise. In the formulation, this product is written in equations (\\ref{eqn.p1_c2}) and (\\ref{eqn.p1_c3}). The parameter $\\alpha_{s,n}$ is the probability that incident $s$ disagrees with the outcome of a measurement taken at location $n$\n\n\\begin{equation}\n\\alpha_{s,n} = \\left\\{ \\begin{array}{ll}\n         \\gamma_n & \\mathrm{if }\\ \\delta_{s,n} = 1;\\\\\n        1-\\gamma_n & \\mathrm{otherwise}.\\end{array} \\right. \n\\label{alphasn}\n\\end{equation}\n\nwhere $\\delta_{s,n}$ is a binary parameter that is $1$ if incident $s$ contaminates node $n$, and $0$ otherwise. The values of $\\delta_{s,n}$ are determined from the simulations pre-computed over the full potential incident set. The parameter $\\gamma_n$ is the probability that node $n$ is contaminated and can be computed from the probability of the contamination incidents\n\n\\begin{equation}\n\\gamma_n = \\sum_{s \\in S} \\delta_{s,n}\\beta_s,\n\\label{nodeprob}\n\\end{equation}\n\nHere $\\beta_s$ is the current estimate of the probability of contamination incident $s$. Finally, $S_{\\textrm{max}}$ is the maximum number of samples to be taken. The formulation as written is an MINLP because of Equation (\\ref{eqn.p1_c2}). However, it is easily made linear. Note that the equality in Equation (\\ref{eqn.p1_c2}) can be replaced with a lower bounding inequality. Since the objective function is maximizing $P_{s}^{\\textrm{miss}}$ (and pushing down on $P_{s}^{\\textrm{match}}$), this inequality will always be satisfied with equality at the solution. Note also that this new inequality is convex and can be replaced with a set of linear under-estimators.\n\nThis new MILP formulation, referred to as problem Probability1, is shown below, where $v_{i}$ are tangent\npoints selected for the linear under-estimators of the exponential term and $L$ is the set of indices corresponding to each of the linear under-estimators:\n\n\\begin{align}\n%& \\underset{x, P_{s}^{\\textrm{miss}}, P_{s}^{\\textrm{match}}}{\\textrm{max}}\n\\textrm{maximize}\\qquad & \\;\\; \\sum_{s\\in S}P_{s}^{\\textrm{miss}} &  \\label{eqn.p1_obj1}\\\\\n\\textrm{subject to}\\qquad &P_{s}^{\\textrm{miss}} = 1-P_{s}^{\\textrm{match}} & \\forall \\; s \\in S \\label{eqn.p1_c11}\\\\\n&P_{s}^{\\textrm{match}} \\geq \\exp(v_i) + \\exp(v_i) \\left( \\tilde{P}_{s} - v_i \\right) & \\forall \\; i \\in L, \\; s \\in S \\label{eqn.p1_c21} \\\\\n&\\tilde{P}_{s} =  \\sum_{n\\in N} x_n \\ln(\\alpha_{s,n}) & \\forall \\; s \\in S \\label{eqn.p1_c31}\\\\\n&\\sum_{n\\in N} x_n \\le S_{\\textrm{max}}  & \\label{eqn.p1_c41}\\\\\n&x_{n} \\in \\{0,1\\} & \\forall \\; n \\in N ,\\label{eqn.p1_c51}\n\\end{align}\n\n\\subsubsection{Maximization of scenario with least number of measurement disagreements}\n\nA third formulation is also presented that maximizes the worst-case number of mismatches (instead of the expected value). This formulation does not contain the exponential term and is already an MILP without the need for any linear under-estimators, which avoids numerical issues that can occur when too many numerically similar\nunder-estimators are added. This produces the max-min formulation shown below:\n\\begin{align*}\n\\textrm{maximize} \\qquad \\underset{s}{\\textrm{minimize}} \\qquad & P_{s}^{\\textrm{miss}} &  \\label{eqn.p2_bi_obj}\\\\\n\\textrm{subject to} \\qquad &P_{s}^{\\textrm{miss}} = 1-P_{s}^{\\textrm{match}} & \\forall \\; s \\in S \\label{eqn.p2_bi_c1}\\\\\n&P_{s}^{\\textrm{match}} = \\exp(\\tilde{P}_{s}) & \\forall \\; s \\in S \\label{eqn.p2_bi_c2}\\\\\n&\\tilde{P}_{s} =  \\sum_{n\\in N} x_n \\ln(\\alpha_{s,n}) & \\forall \\; s \\in S \\label{eqn.p2_bi_c3}\\\\\n&\\sum_{n\\in N} x_n \\le S_{\\textrm{max}}  & \\label{eqn.p2_bi_c4}\\\\\n&x_{n} \\in \\{0,1\\} & \\forall \\; n \\in N, \\label{eqn.p2_bi_c5}\\\n\\end{align*}\nRecognizing that \n\\[\n\\underset{s} \\argmin \\; P_{s}^{\\textrm{miss}} = \\underset{s}\\argmin \\;{-}P_{s}^{\\textrm{match}} \\label{eqn.p2_arg1}\\\\\n\\] \nand that \n\\[\n\\underset{x} \\argmin \\; {-}x = \\underset{x}\\argmin \\; {-}\\exp(x), \\label{eqn.p2_arg2}\\\\\n\\]\nthe prior bilevel optimization formulation is reformulated to a single level optimization formulation as, \n\n\\begin{align}\n\\textrm{maximize} \\qquad & \\;\\; q &  \\\\\n\\textrm{subject to} \\qquad & \\;\\;q \\leq -\\tilde{P}_{s} & \\label{eqn.p2_obj}\\\\\n&\\;\\; \\tilde{P}_{s} =  \\sum_{n\\in N} x_n \\ln(\\alpha_{s,n}) & \\forall \\; s \\in S \\label{eqn.p2_c1}\\\\\n&\\;\\; \\sum_{n\\in N} x_n \\le S_{\\textrm{max}}  & \\label{eqn.p2_c2}\\\\\n&\\;\\; x_{n} \\in \\{0,1\\} & \\forall \\; n \\in N, \\label{eqn.p2_c3}\n\\end{align}\n\nThis formulation is referred to as Probability2, where q is an auxiliary variable that\nsupports the max-min reformulation to a single level optimization problem.\n\n\\section{Grab Sample Solvers}\nThe \\code{grabsample} subcommand requires standard MIP solvers to\nidentify optimal grab sample locations. The solvers recognized by\nthe \\code{grabsample} subcommand are the same as those recognized\nby \\code{booster\\_mip} subcommand (See\nSection \\ref{booster_mip_solver} for more details).\n     \n\\section{\\code{grabsample} Subcommand}\n\nThe \\code{grabsample} subcommand is executed using the following\ncommand line:\n\\begin{unknownListing}\nwst grabsample <configfile>\n\\end{unknownListing}\nwhere \\code{configfile} is a WST configuration file in the YAML format. \n\nThe \\code{---help} option prints information about this subcommand:\n\\begin{unknownListing}\nwst grabsample --help\n\\end{unknownListing}\n\n\\subsection{Configuration File}\n\nThe \\code{grabsample} subcommand generates a template configuration\nfile using the following command line:\n\n\\begin{unknownListing}\nwst grabsample --template <configfile>\n\\end{unknownListing}\n\nThe \\code{grabsample} template configuration file is shown in\nFigure \\ref{fig:grabsample_template}. Brief descriptions of the\noptions are included in the template after the \\# sign.\n\n\\begin{figure}[H]\n  \\unknownInputListing{examples/grabsample_config.yml}{}{1}{46}\n  \\caption{The \\code{grabsample} configuration template file.}\n  \\label{fig:grabsample_template}\n\\end{figure}\n\nThe \\code{grabsample} subcommand requires information about likely scenarios, which is set in the scenario block.\nThese scenarios must be defined using a TSG file or by specifying the scenario location, type, \nstrength, start and stop times (see Section \\ref{sec:scenarios} for more information on defining scenarios).\nIn general, the TSG file created by the \\code{inversion} subcommand will be used to define likely scenarios.\nEither the EPANET option or the Merlion option can be used as the water quality model, although, the Merlion\nwater quality model is recommended for larger networks. \n\n\n\\subsection{Configuration Options}\n\nFull descriptions of the WST configuration options used by\nthe \\code{grabsample} subcommand are listed below.\n\\input{examples/grabsample_config}\n\n\\subsection{Subcommand Output}\nThe \\code{grabsample} subcommand creates a YAML file called <output prefix>grabsample\\_output.yml that contains\na list of node locations (EPANET node IDs) to \ntake manual grab samples, the objective function value (based on the particular formulation selected), \nthe run date and CPU time. \nThe log file named <output prefix>grabsample\\_output.log contains basic debugging information. \nA visualization YAML configuration file named <output prefix>grabsample\\_output\\_vis.yml is also created, and\nfollowing the execution of the \\code{grabsample} subcommand, \nthe \\code{visualization} subcommand is automatically run using this YAML file.\n\n\\section{Grab Sample Examples}\nTwo examples for the \\code{grabsample} subcommand are provided. The first example uses the distinguishability\nformulation, while the second uses the probability-based formulation, Probability1.\n\n\\subsection{Example 1}\nAn EPANET 2.00.12 network model (INP format) and a file containing a list of\npossible injection scenarios (e.g., a TSG file, which is generated by \nthe \\code{inversion} subcommand) are required to run the \\code{grabsample} subcommand. The\nconfiguration file for this example, grabsample\\_ex1.yml, is shown in\nFigure \\ref{fig:sampling_ex1}. The EPANET Example Network 3 input file,\nNet3.inp, is used for this example. \nThe \\code{grabsample} subcommand is typically used to identify sampling location \nafter the results of the source identification calculation give a large list of\ncandidate injection nodes. The time line of using the \\code{inversion} and \\code{grabsample}\nsubcommand sequentially is provided in Figure \\ref{fig:inversion_flowchart}.\nThe TSG file, Net3\\_gs\\_profile.tsg, which contains the possible contamination incidents, is created by the \\code{inversion} subcommand using the measurement data created by the  \\code{measuregen} executable (Executable Files Section \\ref{measuregenExecutable}). For this example, the \\code{measuregen} executable \nis used to simulate and obtain the measurements from a contaminant injection at node 251 at 24 hours.\nThe injection is detected at 30.5 hours by using a set of fixed sensor\nlocations defined in the Net3\\_fixed\\_sensors file.\nThe list of eight equally likely\ncontamination injection locations as listed in the TSG file, Net3\\_gs\\_profile.tsg, produced by the \\code{inversion} subcommand is used as input to the \n\\code{grabsample} subcommand along with the EPANET 2.00.12 network file. \nThe sample time is set to 1890\nminutes (31.5 hours), since it is assumed that it takes 60 minutes to\nperform source identification and obtain the manual grab samples (including travel time). \nThe maximum number of manual grab samples that can be taken is two.\n\n\\begin{figure}[H]\n  \\unknownInputListing{../../examples/grabsample_ex1.yml}{}{1}{32}\n  \\caption{The \\code{grabsample} configuration file for example 1.}\n  \\label{fig:sampling_ex1}\n\\end{figure}\n\nThe example can be executed using the following command:\n\\begin{unknownListing}\nwst grabsample grabsample_ex1.yml\n\\end{unknownListing}\n\nThe results are available in the {\\outputprefix}grabsample\\_output.yml, which\nis shown in Figure \\ref{fig:sampling_ex1_re}. The manual grab sample\nlocations identified are nodes 241 and 251. Twenty-three pairwise\nincidents will be distinguished after taking the samples at these\nlocations. To reiterate the configuration parameters, the sampling\ntime is 1890 minutes and the maximum number of sampling locations is\ntwo. The grab sample locations identified in Figure \\ref{fig:sampling_ex1_re} \nmight be one of several solutions that produce the same objective value. If \nmultiple grab sample locations provide the same ability to distinguish the \ncontamination source, the solver will randomly pick a solution. Thus, the solution \nidentified in Figure \\ref{fig:sampling_ex1_re} could be different for other users. \n\n\\begin{figure}[H]\n  \\unknownInputListing{examples/sampling/grabsample_ex1_output.yml}{}{1}{13}\n  \\caption{The \\code{grabsample} YAML output for example 1.}\n  \\label{fig:sampling_ex1_re}\n\\end{figure}\n\nNext, as shown in Figure \\ref{fig:inversion_flowchart}, the\nmeasurements from these selected grab sample locations (actual or\nsimulated using \\code{measuregen} executable) can be used to again\nperform source identification. Please refer to\nSection \\ref{chap:inversionCase} for a complete case study of how to\nuse the \\code{inversion} and \\code{grabsample} subcommands in tandem.\n \n\\subsection{Example 2}\n\nIn the second example, the probability-based formulation, Probability1, is used to select the optimal sampling locations, since the probability-based formulations are particularly efficient when the number of contamination scenarios is considerably large. The configuration file for this example, grabsample\\_ex2.yml, is shown in\nFigure \\ref{fig:sampling_ex2}. \n\n\\begin{figure}[H]\n  \\unknownInputListing{../../examples/grabsample_ex2.yml}{}{1}{28}\n  \\caption{The \\code{grabsample} configuration file for example 2.}\n  \\label{fig:sampling_ex2}\n\\end{figure}\n\nThe scenario information is provided with a list of pairs of INP-TSG files. This input allows the user to include different hydraulic and contamination in the set of potential scenarios. The list of potential scenarios used is shown in Figure \\ref{fig:gs_scenarios}. Ten different INP files with variations in the demand patterns are specified in the list to account for uncertainty in the hydraulics of the system. For simplicity a single TSG file is specified to provide information about the contamination scenarios. However, each entry in the list of scenarios could have a different TSG file.\n\n\\begin{figure}[!ht]\n  \\unknownInputListing{../../examples/Net3/grabsample/list_scenarios.dat}{}{1}{10}\n  \\caption{List of scenarios example 2.}\n  \\label{fig:gs_scenarios}\n\\end{figure}\n\nIn addition, a list of the currently available measurements is provided in a measurement file with columns labeled as ``location, time and measurement value.'' The measurements are used to compute the probability of the scenarios following a Bayesian approach. When no measurements are provided, the probability distribution of the scenarios is assumed to be uniform. The measurement file in this example is shown in Figure \\ref{fig:gs_measurements}\n\n\\begin{figure}[!ht]\n  \\unknownInputListing{../../examples/Net3/grabsample/MEAS.dat}{}{1}{3}\n  \\caption{List of measurements example 2.}\n  \\label{fig:gs_measurements}\n\\end{figure}\n\nThe example can be executed using the following command:\n\\begin{unknownListing}\nwst grabsample grabsample_ex2.yml\n\\end{unknownListing}\n\nThe results are available in the {\\outputprefix}grabsample\\_output.yml, which\nis shown in Figure \\ref{fig:sampling_ex2_re}.\n\n\\begin{figure}[H]\n  \\unknownInputListing{examples/sampling/gs_ex2_output.yml}{}{1}{13}\n  \\caption{The \\code{grabsample} YAML output for example 2.}\n  \\label{fig:sampling_ex2_re}\n\\end{figure}\n", "meta": {"hexsha": "4a4ab8c5e08e44393e4cccd1e6cce209374a9ca2", "size": 20929, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/wst/sampling.tex", "max_stars_repo_name": "USEPA/Water-Security-Toolkit", "max_stars_repo_head_hexsha": "6b6b68e0e1b3dcc8023b453ab48a64f7fd740feb", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-06-10T18:04:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-05T18:11:40.000Z", "max_issues_repo_path": "doc/wst/sampling.tex", "max_issues_repo_name": "USEPA/Water-Security-Toolkit", "max_issues_repo_head_hexsha": "6b6b68e0e1b3dcc8023b453ab48a64f7fd740feb", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/wst/sampling.tex", "max_forks_repo_name": "USEPA/Water-Security-Toolkit", "max_forks_repo_head_hexsha": "6b6b68e0e1b3dcc8023b453ab48a64f7fd740feb", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-09-24T19:04:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-05T18:11:43.000Z", "avg_line_length": 61.7374631268, "max_line_length": 669, "alphanum_fraction": 0.7701275742, "num_tokens": 5680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4087324291821003}}
{"text": "\\section{The Basic TSTL Test Tools}\n\nInstead of the fault-free stack, we can test a real-world program with real faults, such as the SymPy library for performing symbolic mathematics in Python \\cite{SymPy}.  The SymPy harness can be found in the TSTL github repository {\\tt examples/sympy} directory.\n\n{\\scriptsize\n\\begin{code}\n > tstl sympy.tstl\n > tstl\\_rt --swarm --noCover --full\n...\n UNCAUGHT EXCEPTION\n ERROR: (<type 'exceptions.RuntimeError'>,\n RuntimeError('maximum recursion depth exceeded',)\n...\n    return func(a, b)\n...\n SAVING TEST AS failure.67076.test\n...\n STOPPING TESTING DUE TO FAILED TEST\n 36.4984600544 TOTAL RUNTIME\n > wc -l failure.67076.test\n 72\n > head -n5 failure.67076.test\n self.p\\_v[3] = sympy.Symbol('j',positive=True) \n self.p\\_expr[0].evalf() \n self.p\\_expr[0] = self.p\\_expr[0] + self.p\\_expr[3] \n self.p\\_expr[3] = self.p\\_expr[3] + self.p\\_expr[1] \n self.p\\_expr[1] = self.p\\_expr[3] \\% self.p\\_expr[0] \n\n\\end{code}\n}\n\nWe have instructed the random tester to use swarm testing\n\\cite{ISSTA12} and not collect code coverage, in order to improve the\nchances of quickly finding a fault.  By default {\\tt tstl\\_rt} uses\ndelta-debugging to minimize tests before saving them, but we have\nalso instructed {\\tt tstl\\_rt} to simply save the original test case {\\tt\n  --full}.  The unreduced test (which causes Python to enter an\ninfinite recursion sequence) consists of 72 steps, saved in a\nnon-executable, technically (but not very) human-readable, textual\nformat (in an automatically generated file name, based on the process ID).  This is not a very useful test, so we want to reduce\nit:\n\n{\\scriptsize\n\\begin{code}\n > tstl\\_reduce failure.67076.test reduced.test --noNormalize\n STARTING WITH TEST OF LENGTH 72\n REDUCING...\n REDUCED IN 31.3780119419 SECONDS\n NEW LENGTH 7\n ALPHA CONVERTING...\n c0 = sympy.Integer(4)                            \\# STEP 0\n c1 = sympy.Integer(9)                            \\# STEP 1\n v0 = sympy.Symbol('k',positive=True)             \\# STEP 2\n expr0 = sympy.Rational(c1,c1)                    \\# STEP 3\n expr1 = sympy.Product(expr0,(v0,c0,c0))          \\# STEP 4\n expr2 = c1                                       \\# STEP 5\n expr3 = expr2 \\% expr1                            \\# STEP 6\n\\end{code}\n}\n\nThis test, reduced using standard delta-debugging \\cite{DD}, is\nshort.  Also, note that TSTL automatically alpha-converts the test so\nthat it uses variables to store intermediate values in a reasonable\nway (starting with {\\tt v0} rather than arbitrarily beginning with\n{\\tt v3}, for example).  However, the test is neither as short as possible nor, more\nimportantly, as simple as possible.  For debugging we may well wonder:\ndoes it matter that {\\tt c0} is 4 and {\\tt c1} is 9?  Is the use of\nthe variable {\\tt k} relevant?  If we want to know the answers, we can\nrun the reducer to \\emph{normalize} \\cite{OneTest} the test, in place\nof simply reducing it:\n\n{\\scriptsize\n\\begin{code}\n > tstl\\_reduce reduced.test normalized.test --noReduce\n STARTING WITH TEST OF LENGTH 7\n NORMALIZING...\n NORMALIZED IN 383.565114975 SECONDS\n NEW LENGTH 5\n c0 = sympy.Integer(1)                            \\# STEP 0\n v0 = sympy.Symbol('a')                           \\# STEP 1\n expr0 = c0                                       \\# STEP 2\n expr1 = sympy.Sum(expr0,(v0,c0,c0))              \\# STEP 3\n expr0 = expr0 \\% expr1                            \\# STEP 4\n\\end{code}\n}\n\nNotice that normalizing a test is much more expensive than simply\nreducing it, but the payoff is an even shorter and simpler\ntest\\footnote{For details on how much shorter and simpler, see the\n  conference paper on test case normalization and generalization\n  \\cite{OneTest}.  Note that normalization times are usually faster in\nthe current release than reported in that paper, due to the\nimplementation of a useful heuristic for reducing nearly 1-minimal\ntests suggested by David R. MacIver \\cite{MacIver}, the author of the Hypothesis tool.}.  By default, the TSTL random test generator\nreduces tests before saving them, and the standalone {\\tt\n  tstl\\_reduce} tool is used to normalize interesting tests.  Calling\n{\\tt tstl\\_rt} with the {\\tt --normalize} option avoids going through\nthe standalone tool.  Normalization here pays off by revealing that\nthe use of a {\\tt Rational} and exact numeric/symbol values are not\nrelevant.  \n\nNow that we have an extremely simple test, we can replay it in a\n``verbose'' mode to see more exactly what is happening during the test, as shown in\nFigure \\ref{fig:verbose}.  This shows the values, types, and changes\nin values of every pool variable involved in each step of the test\n(and would show the state of a reference implementation, if we were\nperforming automated differential testing).\n\n\\begin{figure}\n{\\scriptsize\n\\begin{code}\n > tstl\\_replay normalized.test --verbose\n STEP \\#0: ACTION: c0 = sympy.Integer(1) \n c0 = None : <type 'NoneType'>\n => c0 = 1 : <class 'sympy.core.numbers.One'>\n ==================================================\n STEP \\#1: ACTION: v0 = sympy.Symbol('a') \n v0 = None : <type 'NoneType'>\n => v0 = a : <class 'sympy.core.symbol.Symbol'>\n ==================================================\n STEP \\#2: ACTION: expr0 = c0 \n c0 = 1 : <class 'sympy.core.numbers.One'>\n expr0 = None : <type 'NoneType'>\n => expr0 = 1 : <class 'sympy.core.numbers.One'>\n ==================================================\n STEP \\#3: ACTION: expr1 = sympy.Sum(expr0,(v0,c0,c0)) \n c0 = 1 : <class 'sympy.core.numbers.One'>\n v0 = a : <class 'sympy.core.symbol.Symbol'>\n expr0 = 1 : <class 'sympy.core.numbers.One'>\n expr1 = None : <type 'NoneType'>\n => expr1 = Sum(1, (a, 1, 1)) : <class 'sympy.concrete.summations.Sum'>\n ==================================================\n STEP \\#4: ACTION: expr0 = expr0 \\% expr1 \n expr0 = 1 : <class 'sympy.core.numbers.One'>\n expr1 = Sum(1, (a, 1, 1)) : <class 'sympy.concrete.summations.Sum'>\n RAISED EXCEPTION: <type 'exceptions.RuntimeError'>\n   maximum recursion depth exceeded in cmp\n FAILED STEP\n (<type 'exceptions.RuntimeError'>,\n RuntimeError('maximum recursion depth exceeded in cmp',)\n ...\n\\end{code}\n}\n\\caption{Verbose replay of a TSTL test.}\n\\label{fig:verbose}\n\\end{figure}\n\nIn addition to replaying a single test, we can replay a number of\nsaved tests using the {\\tt tstl\\_regress} command, which takes as\ninput a list of all test files to run, and produces a coverage report\nin addition to the outcome of each test.  By default it stops on the\nfirst failing test, but can be directed to run all tests with {\\tt\n  --keepGoing}.  Regression runs can also generate an HTML coverage report using the\nfacilities of the {\\tt coverage.py} library \\cite{Coveragepy}.\n\nFinally, we can \\emph{generalize} the test, to see what\nalternative, similar tests also produce the same failure:\n\n{\\scriptsize\n\\begin{code}\n > tstl\\_generalize normalized.test\n GENERALIZING...\n \\#[\n c0 = sympy.Integer(1)                               \\# STEP 0\n \\#  or c0 = sympy.Integer(2) \n \\#   - c0 = sympy.Integer(10) \n v0 = sympy.Symbol('a')                              \\# STEP 1\n \\#  or v0 = sympy.Symbol('b') \n \\#   - v0 = sympy.Symbol('d') \n \\#  or v0 = sympy.Symbol('x') \n \\#   - v0 = sympy.Symbol('z') \n \\#  or v0 = sympy.Symbol('e',positive=True) \n \\#   - v0 = sympy.Symbol('l',positive=True) \n \\#  swaps with step 2\n \\#] (steps in [] can be in any order)\n expr0 = c0                                          \\# STEP 2\n \\#  or expr0 = sympy.Rational(c0,c0) \n \\#  or expr0 = sympy.pi \n \\#  or expr0 = sympy.E \n \\#  or expr0 = sympy.I \n \\#  swaps with step 1\n expr1 = sympy.Sum(expr0,(v0,c0,c0))                 \\# STEP 3\n \\#  or expr1 = sympy.Product(expr0,(v0,c0,c0)) \n expr0 = expr0 \\% expr1                               \\# STEP 4\n \\#  or expr2 = expr0 \\% expr1 \n \\#  or expr3 = expr0 \\% expr1 \n GENERALIZED IN 239.682291985 SECONDS\n\\end{code}\n}\n\nWith this information, the basic underlying structure\nof the fault is made clear:  using the modulo operator on a {\\tt Sum}\nor {\\tt Product} over an empty range (whether that range is $2 \\ldots 2$ or\n$\\pi \\ldots \\pi$, with any variable name allowed by our SymPy harness,\ncauses the failure.  The ordering of operations, other than to the\nextent required for data flow, is not important.\n\nNow that we understand the fault, we may want a non-TSTL test to run\nin a debugger to try out possible solutions.  Generating a standalone\nPython executable\ntest is easy:\n\n{\\scriptsize\n\\begin{code}\n > tstl\\_standalone normalized.test normalized.py\n\\end{code}\n}\n\nIn this example, reduction or normalization has always been with\nrespect to a failure.  However, simply by providing the {\\tt\n  --coverage} option to {\\tt tstl\\_reduce} or {\\tt tstl\\_generalize}\nthe same approaches can be applied to reduce tests by their code\ncoverage, a useful method for producing very efficient regression tests\n\\cite{icst2014,stvrcausereduce}.  Running {\\tt tstl\\_rt} with the {\\tt\n  --quickTests} option will also produce a suite of such\ncoverage-based reduced regression tests.\n\n\\section{Avoiding Slippage}\n\nTest slippage \\cite{PLDI13,slippage} is when a weak\nlabeling of failed tests (e.g., simply checking that a failing test\nstill causes some kind of uncaught exception) results in a test that\noriginally failed due to one fault being reduced to a test that fails\ndue to a different fault.\n\nThere is a need for flexibility in handling slippage and fault\nsignatures in general; with some programs, many exceptions may reveal\nthe same fault, with other programs even the same assertion on the\nsame line of code can be violated due to different underlying faults.\nTSTL therefore provides a few ways to avoid slippage, and also some ways to \nintentionally induce ``good'' slippage where a failing test is reduced \nto produce multiple tests that fail due to different faults \n\\cite{slippage}.  First, the random test generator and the reduction,\nand generalization tools all take the {\\tt --keepLast}\noption, which forces reduced tests to have the same final action as\nthe original test.  This is a heuristic for avoiding slippage\ndiscovered during file system testing at NASA \\cite{ICSEDiff}.\nSecond, the reducer and generalizer take a {\\tt --matchException}\nargument that forces reductions to fail due to the same type of\nexception (but not exact message); this is the default behavior for the random\ntester, where the user has more reason to be concerned about losing\nthe original fault since it is not stored in a file.\n\nWhile these methods are useful for producing more precise labels for\nfailure, they are not helpful in instances where precise labeling is\nimpossible, such as many differential testing settings \\cite{PLDI13}.\nFor these cases, and for using reduction as a mutation-based fuzzing\ntool to look for new faults, TSTL provides two more modes.  First,\nusing the {\\tt --multiple} option configures {\\tt tstl\\_reduce} to use\nthe {\\tt comb-block} algorithm \\cite{slippage} to attempt to produce\nas many reduced tests as possible, that are all as different as\npossible from each other.  The effort extended to consider\ncombinations of test components can be configured with the {\\tt\n  --recursive} and {\\tt --limit} options.  Second, the {\\tt --random}\nflag to the reducer causes the order of possible reductions to be\nrandomized, so that different runs of the reducer will produce\ndifferent reduced tests.\n\n\\section{API Access to Tool Functionality}\n\nIn addition to the command-line tools described here, TSTL also makes\nit easy to perform sophisticated test manipulations in code.  When a\nTSTL harness is compiled it produces an {\\tt sut} module providing an\nabstract interface for testing the SUT.  It is this interface that\n{\\tt tstl\\_rt}, {\\tt tstl\\_reduce}, and the other tools interact with,\nmaking test generation and manipulation independent of the SUT.\n\nThe interface includes {\\tt reduce}, {\\tt normalize} and {\\tt\n  generalize} methods for reduction and normalization that provide\nmany more parameters for fine-tuned control of the algorithms than are\nprovided by the command line tools.  These methods are all\nhigher-order functions, so the predicate for the algorithm to maintain\nas true can be an arbitrary function of a test.  The interface to the\nSUT also provides methods to return commonly used predicates, such as\nmatching the coverage of a test, or failing a property check.  Because\nTSTL's reduction implementations do not require their initial input to\nsatsify the predicate, this can be used for unusual applications.  For\nexample, if are testing an XML parser, have a long, high-coverage\ntest, and wish to modify it to produce an input that takes as long as\npossible to parse, we can define a function:\n\n{\\scriptsize\n\\begin{code}\ndef takesLonger(t):\n      global WCET, SUT\n      start = time.time()\n      SUT.replay(t)\n      elapsed = time.time() - start\n      if elapsed > WCET:\n         WCET = elapsed\n         return True\n      return False\n\\end{code}\n}\n\nand call {\\tt SUT.reduce(longTest,takeLonger)} after setting WCET to the\nruntime for the initial test.", "meta": {"hexsha": "018ddab84dda49ac334294317eb2f1e4478e8509", "size": 12998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "deprecated/papers/issta17tool/example.tex", "max_stars_repo_name": "15821361594/python-automated-test", "max_stars_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "deprecated/papers/issta17tool/example.tex", "max_issues_repo_name": "15821361594/python-automated-test", "max_issues_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "deprecated/papers/issta17tool/example.tex", "max_forks_repo_name": "15821361594/python-automated-test", "max_forks_repo_head_hexsha": "c77dda6abf616c9dfcd052762c5b07bf4368ddde", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.7643097643, "max_line_length": 263, "alphanum_fraction": 0.7022618864, "num_tokens": 3428, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.4085922216864736}}
{"text": "% !TEX root =main.tex\n\n\\section{C-TLP Security Proof}\\label{CR-TLP-Proof}\n \nIn this section, we present   the security proof of C-TLP scheme. We first prove that without solving $j\\text{\\small{-th}}$ puzzle, a solver cannot find the parameters  needed to solve the next puzzle, i.e. $(j+1)\\text{\\small{-th}}$   one. \n\n \n  \\begin{lemma}[Next Group Generator Privacy]\\label{lemma::Next-Generator-Privacy}  Let $k$ be a random key for a symmetric key encryption, and  $N$ be a  sufficiently large RSA modulus. Let  the security parameter be $\\lambda=|N|=|k|$.  In C-TLP, given puzzle vector: $\\vv{\\bm{o}}$ and public key: $pk$, an adversary $\\mathcal{A}=(\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$, defined in Section \\ref{Section::Multi-instance-Time-lock Puzzle-Definition},  cannot find the next group generator: \n$r_{\\scriptscriptstyle j+1}$, where $r_{\\scriptscriptstyle j+1} \\stackrel{\\scriptscriptstyle\\$}\\leftarrow \\mathbb{Z}^{\\scriptscriptstyle *}_{\\scriptscriptstyle N}$and $j\\geq1$, significantly smaller than   $T_{\\scriptscriptstyle j}=\\delta(j\\Delta)$, except with a negligible probability in the security parameter, $\\mu(\\lambda)$ \n  \\end{lemma}\n \\begin{proof}\nSince the next generator: $r_{\\scriptscriptstyle j+1}$, is: (a) encrypted along with the $j\\text{\\small{-th}}$ puzzle solution: $s_{\\scriptscriptstyle j}$, and (b)  picked uniformly at random from $\\mathbb{Z}^{\\scriptscriptstyle *}_{\\scriptscriptstyle N}$, for the adversary to find $r_{\\scriptscriptstyle j+1}$ without performing enough squaring, i.e. $T_{\\scriptscriptstyle j}$, it has to either (a) break the symmetric key scheme, decrypt the related ciphertext: $s_{\\scriptscriptstyle i}$ and extract the random value from it, or (b) correctly guess $r_{\\scriptscriptstyle j+1}$. In both cases, the probability of success is negligible in secure parameter $\\mu(\\lambda)$,  i.e. $2^{\\scriptscriptstyle -|k|}$ in the former case and $2^{\\scriptscriptstyle -|N|}$ in the latter one.  \n \\hfill\\(\\Box\\)\n  \\end{proof} \n%. But its  probability of success is $2^{\\scriptscriptstyle -|k|}$ that is negligible in the security parameter,  or  guess $r_{\\scriptscriptstyle j+1}$, that has the probability of success  at most $2^{\\scriptscriptstyle -|N|}$ which is negligible in $\\lambda$ as well.    %\\hfill\\(\\Box\\)\n %t \\end{proof} \n  \n In the following, we prove that the privacy of a solution in C-TLP scheme is preserved according to Definition \\ref{Def::Solution-Privacy}. \n \n \n \\begin{theorem} [C-TLP Solution Privacy]\\label{Solution-Privacy} Let $N$ be a  strong RSA modulus and $\\Delta$ be a time parameter. If the sequential squaring assumption holds,  factoring $N$ is a hard problem, $\\mathtt{H}(.)$ is a random oracle and the symmetric key encryption is  semantically secure, then  C-TLP encoding $z$ solutions is a privacy-preserving multi-instance time-lock puzzle w.r.t. Definition \\ref{Def::Solution-Privacy}.\n \\end{theorem}\n  \\begin{proof} In the following, we argue  for an adversary $\\mathcal{A}=(\\mathcal{A}_{\\scriptscriptstyle 1},\\mathcal{A}_{\\scriptscriptstyle 2})$, where $\\mathcal{A}_{\\scriptscriptstyle 1}$ runs in total time $O(poly(j\\Delta,\\lambda))$,  $\\mathcal{A}_{\\scriptscriptstyle 2}$ runs in  time $\\delta(j\\Delta)<j\\Delta$ using at most $\\pi(\\Delta)$ parallel processors, and  $j\\in [1,z]$,  (a) when $z=1$: to find $s_{\\scriptscriptstyle 1}$ earlier than $\\delta(\\Delta)$,  it has to  break the TLP scheme, and (b) when $z>1$: to find $s_{\\scriptscriptstyle j}$ earlier than $T_{\\scriptscriptstyle j}=\\delta(j\\Delta)$, it has to either find   at least one of the previous solutions earlier than it is supposed to (that ultimately requires breaking TLP scheme again), or find $j\\text{\\small{-th}}$ generator: $r_{\\scriptscriptstyle j}$, earlier. Also, we argue that the commitments: $h_{\\scriptscriptstyle j}$, are computationally hiding.   Specifically, when $z=1$, the security of C-TLP is reduced to the security of  the TLP and the scheme is secure as long as TLP is, as the two schemes would be identical. On the other hand, when $z>1$, the adversary has to either find $s_{\\scriptscriptstyle j}$ earlier than $T_{\\scriptscriptstyle j}$ as soon as the previous solution: $s_{\\scriptscriptstyle j-1}$ is found that requires either breaking the TLP scheme, or finding any generator $r_{\\scriptscriptstyle j}$  before $s_{\\scriptscriptstyle j-1}$ is extracted, when $j\\in [2,z]$. Nevertheless, the TLP scheme is secure (under RSA,  sequential squaring, and security of symmetric key encryption assumptions) according to  Theorem \\ref{theorem::R-LTP-Sec}, and also the probability of finding the next generator: $r_{\\scriptscriptstyle j}$ earlier than $T_{\\scriptscriptstyle j-1}$ is negligible, according to Lemma \\ref{lemma::Next-Generator-Privacy}. Moreover, for an adversary to find a solution earlier, it may also try to find a (partial information of) pre-image of the commitment: $h_{\\scriptscriptstyle j}$ before fully (or without) solving the puzzle. But, this is infeasible for a PPT adversary, given  output of a random oracle: $\\mathtt{H}(.)$. Thus, C-TLP is a privacy-preserving multi-instance time-lock puzzle scheme.  \\hfill\\(\\Box\\)\n  \\end{proof}\n \nNext, we prove that the validity of a solution in C-TLP scheme is preserved according to Definition \\ref{Def::Solution-Validity}. \n  \\begin{theorem} [C-TLP Solution Validity]\\label{Solution-Validity} Let $\\mathtt{H}(.)$ be a hash function modeled as a random oracle. Then, C-TLP preserves a solution validity w.r.t. Definition \\ref{Def::Solution-Validity}.  \n\\end{theorem}\n\\begin{proof}\n The proof  boils down to  the security (i.e. binding property) of the traditional hash-based commitment scheme. In particular, given an  opening pair, $\\ddot{p}:(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$ and the commitment $h_{\\scriptscriptstyle j}=\\mathtt{H}(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$, for an adversary to break the solution validity, it has to come up $(m'_{\\scriptscriptstyle j},d'_{\\scriptscriptstyle j})$, such that $\\mathtt{H}(m'_{\\scriptscriptstyle j},d'_{\\scriptscriptstyle j})=h_{\\scriptscriptstyle j}$, where $m_{\\scriptscriptstyle j}\\neq m'_{\\scriptscriptstyle j}$, i.e. finds a collision of $\\mathtt{H}(.)$. However, this is infeasible for a PPT adversary, as $\\mathtt{H}(.)$ is collision resistance, in the random oracle model. \n \\hfill\\(\\Box\\)\n\\end{proof}\n \n In the following, we restate the main theorem presented in Section \\ref{Section::C-TLP-protocol} and then prove it.  \n\n\\\n\n\\noindent\\textbf{Theorem \\ref{C-TLP-Sec} (C-TLP Security).} \\textit{C-TLP  is a secure multi-instance time-lock puzzle. }\n\n   \n \\begin{proof} According to Theorems \\ref{Solution-Privacy} and \\ref{Solution-Validity}, the privacy and validity of a solution in C-TLP are preserved, respectively.   So, w.r.t. Definition \\ref{def::C-TLP-security}, C-TLP is a secure multi-instance  time-lock puzzle.\n  \\hfill\\(\\Box\\)\n\\end{proof}\n", "meta": {"hexsha": "cd51c487c397a29f38160ef187930d0bfef9ef18", "size": 6936, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/FC/CR-TLP-proof.tex", "max_stars_repo_name": "AydinAbadi/CR-LP", "max_stars_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/FC/CR-TLP-proof.tex", "max_issues_repo_name": "AydinAbadi/CR-LP", "max_issues_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/FC/CR-TLP-proof.tex", "max_forks_repo_name": "AydinAbadi/CR-LP", "max_forks_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 157.6363636364, "max_line_length": 2241, "alphanum_fraction": 0.7365916955, "num_tokens": 1983, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4085922181823256}}
{"text": "\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage[super]{nth}\n\\title{Interface for Field Access}\n\\author{Dan Ibanez, SCOREC}\n\\date{May 15, 2014}\n\\begin{document}\n\\maketitle\n\n\\section{Goal}\n\nThis document aims to establish a consensus on\nbasic operations that should be made available\nby finite element toolkits for accessing finite\nelement field data attached to a mesh.\n\n\\section{Definitions}\n\nA finite element mesh $M$ represents a domain\n$\\Omega^h \\subset {\\mathbb R^D}$\ncomposed of entity domains $\\Omega_e$:\n\\[\\Omega^h = \\bigcup_{e\\in M} \\Omega_e\\]\n\nA finite element field $f : \\Omega^h \\to T$ is a piece-wise field\nfrom the mesh domain to some tensor space $T$, where\neach piece is $f_e : \\Omega_e \\to T$.\nThe entity domains have parametric, or parent, coordinate\nsystems and a map from parametric points $\\xi \\in {\\mathbb R^d}$\nto points in the entity domain $X_e(\\xi) \\in \\Omega_e$.\n\nThe value of a field at a point $x$ in an entity domain $\\Omega_e$\nis entirely defined by the corresponding parametric point $\\xi$\nand a set of tensor multipliers $\\bar{W}_e = \\{\\bar{W}_e^0,...,\\bar{W}_e^n\\}$\nwhich affect that entity:\n\\[x\\in \\Omega_e, x = X_e(\\xi), f(x) = f_e(\\xi,\\bar{W}_e)\\]\nFor example, in a linear tetrahedral mesh the set $\\bar{W}_e$ contains\nthe field values at the vertices of an entity.\n\nThe field multipliers are each associated with a unique mesh entity\nto allow sharing between entities.\nThe set of multiplier tensors associated with entity $e$ is denoted\n$W_e = \\{W_e^0,...,W_e^m\\}$.\nThe set of tensors which affect the field definition over an entity\nis composed of tensors associated to nearby entities, usually to\nentities in its closure:\n\\[\\bar{W}_e = \\bigcup_{a \\in \\bar{e}} W_a\\]\nTo reuse our example, in linear tetrahedral meshes multipliers are\nthe field values associated with vertices, and the multipliers\nwhich affect a tetrahedron are those associated to its vertices.\n\n\\section{Requirements}\n\nTo describe a field, two key pieces of information are needed:\n\\begin{enumerate}\n\\item The entity basis functions $f_e(\\xi,\\bar{W}_e)$ for all $e\\in M$.\n\\item The associated multipliers $W_e$ for all $e \\in M$\n\\end{enumerate}\nThe description of $f_e$ encompasses several smaller pieces of information:\n\\begin{enumerate}\n\\item The parent domain $\\Box_e$ such that $X_e(\\Box_e)=\\Omega_e$.\n\\item The how many multipliers are associated with each entity: $|W_e|$.\n\\item How to collect all affecting multipliers: $g(e) = \\bar{W}_e$.\n\\end{enumerate}\nDepending on the complexity of the field, much of this information\ncan be recorded {\\it a priori}.\nFor example, the description of $f_e$ may be just ``\\nth{2}-order Lagrange\"\nor ``Cubic B\\'ezier\".\nIn more complex cases such as variable-order fields, information\nsuch as $|W_e|$ and $g$ may have to be specified on a per-entity basis.\n\n\\section{Coordinates}\n\nNote that the coordinates are themselves a field $X_e : \\Box_e \\to \\Omega_e$,\nand should have equivalent availability of information.\nFor example, it should be possible to query the basis functions\nbeing used to define coordinates.\n\n\\section{Interface}\n\nWe will assume an adequate existing interface for topological\nmesh descriptions, so that operations such as iterating over\n$e \\in M$ and getting the entities $a \\in \\bar{e}$ are available\nand efficient.\n\nAt a high level, it should also be possible to query the set of fields\ndefined over a particular mesh.\nFields and entities should have identifying handles that can be efficiently\ninterpreted by the software.\n\nAt a minimum, just to preserve field data, it must be possible to access\ntensor multipliers associated with entities.\nThat is, for a given entity $e$, the count $n=|W_e|$ and values\n$W_e^i,1\\leq i\\leq n$ must be quickly accessible.\nOf course, prerequisite to retrieving $W_e^i$ is some agreement on the\nstorage format for tensor values.\nFor each $f : \\Omega^h \\to T$,\nthe storage format for $t\\in T$ should be accessible.\n\nTo preserve a complete description of the field, it should also be\npossible to query the exact basis functions $f_e$ being used for\neach entity, along with the closely associated procedure $g$ for\ncollecting the ordered set of tensor multipliers $\\bar{W}_e$ that \nare weighted by $f_e$ based on $\\xi$ to produce $f(x)$.\n\n\\end{document}\n", "meta": {"hexsha": "8d026b85cd610d909f54e8033a3466d741744f01", "size": 4283, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "apf/attach.tex", "max_stars_repo_name": "cwsmith/core", "max_stars_repo_head_hexsha": "840fbf6ec49a63aeaa3945f11ddb224f6055ac9f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 138, "max_stars_repo_stars_event_min_datetime": "2015-01-05T15:50:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-25T01:09:58.000Z", "max_issues_repo_path": "apf/attach.tex", "max_issues_repo_name": "cwsmith/core", "max_issues_repo_head_hexsha": "840fbf6ec49a63aeaa3945f11ddb224f6055ac9f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 337, "max_issues_repo_issues_event_min_datetime": "2015-08-07T18:24:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T14:39:03.000Z", "max_forks_repo_path": "apf/attach.tex", "max_forks_repo_name": "cwsmith/core", "max_forks_repo_head_hexsha": "840fbf6ec49a63aeaa3945f11ddb224f6055ac9f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 70, "max_forks_repo_forks_event_min_datetime": "2015-01-17T00:58:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-13T04:58:20.000Z", "avg_line_length": 40.0280373832, "max_line_length": 77, "alphanum_fraction": 0.7562456222, "num_tokens": 1147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.408551203523188}}
{"text": "\\documentclass[12pt,answers,addpoints]{exam}\n\n%============Macros==================%\n\\usepackage{amsmath,amsfonts,amssymb,amsthm}\n\\usepackage{qcircuit}\n\\usepackage[margin=1in]{geometry}\n%--------------Cosmetic----------------%\n\\usepackage{mathtools}\n\\usepackage{hyperref}\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    filecolor=magenta,      \n    urlcolor=cyan,\n}\n\\usepackage{fullpage}\n\\usepackage{microtype}\n\\usepackage{xspace}\n\\usepackage[svgnames]{xcolor}\n\\usepackage[sc]{mathpazo}\n\\usepackage{enumitem}\n\\setlist[enumerate]{itemsep=1pt,topsep=2pt}\n\\setlist[itemize]{itemsep=1pt,topsep=2pt}\n%-----defs and commands-----%\n\\def\\mG{[\\textbf{G}]\\xspace}\n\\def\\veps{\\varepsilon}\n\\def\\tr{\\mathrm{tr}}\n\\newcommand{\\bit}{\\{0,1\\}}\n\\newcommand{\\bra}[1]{\\langle #1 \\rvert}\n\\newcommand{\\ket}[1]{\\lvert #1 \\rangle}\n\\newcommand{\\kera}[1]{\\ket{#1}\\bra{#1}}\n\\newcommand{\\negl}{\\text{negl}}\n\\newcommand{\\complex}{\\mathbb{C}}\n\\newcommand{\\integer}{\\mathbb{Z}}\n\\newcommand{\\srd}[2]{\\textsf{SR}_{#1}^{#2}(X)}\n\\newcommand{\\corr}[1]{{\\color{blue}{#1}}}\n% \\input{../head}\n%----------Header--------------------%\n\n\\newcommand{\\classn}{CSCE 440/640 Quantum Algorithms}\n\\newcommand{\\classnabbr}{CSCE 440/640}\n\\newcommand{\\school}{Texas A\\&M U}\n\\newcommand{\\term}{Spring 2019}\n\\newcommand{\\examdate}{March 18, 2019}\n\\newcommand{\\duedate}{March 20, 2019, 11:59pm, AoE}\n\\newcommand{\\examnum}{Mid-term Exam}\n\\newcommand{\\studentname}{\\makebox[1.5in]{\\hrulefill}} % change it to your name\n\\pagestyle{head}\n\\firstpageheader{}{}{}\n\\runningheader{\\classnabbr}{\\examnum\\ - Page \\thepage\\ of\n  \\numpages}{\\term}\n\\vskip 1ex\n\\setlength{\\headsep}{10pt}\n\\runningheadrule\n\n%\\qzheader                       % execute quiz commands\n\n\\begin{document}\n\n\\noindent\n\\begin{tabular*}{\\textwidth}{l @{\\extracolsep{\\fill}} r\n    @{\\extracolsep{6pt}} r}\n  {\\Large\\textbf{\\examnum}} & \\Large{\\textbf{Name:}} & \\studentname\\\\\n  {\\term}, {\\classn} & &  {\\examdate}\\\\\n  \\school && Prof. Fang Song\n\\end{tabular*}\\\\\n\n\\rule[2ex]{\\textwidth}{1pt}\n\n\\subsection*{Instructions (please read carefully before start!)}\n\n\\begin{itemize}\n\\item This take-home exam contains \\numpages\\ pages (including this\n  cover page) and \\numquestions\\ questions. Total of points is\n  \\numpoints.\n\\item You will have till \\textbf{\\duedate}~(Anywhere on Earth) to\n  finish the exam. You must work on your own, and no collaboration or\n  help from any resources other than those made available in class\n  (lecture notes, recommended texts, homework problems, etc.)  is\n  permitted.\n\n\\item Email me your solutions in PDF before the deadline, either\n  scanned or typeset in \\LaTeX. Name your PDF and email subject as:\n  \\textbf{Lastname\\_Firstname\\_s19\\_mt}. If you choose to hand-write\n  and scan, \\emph{print out this exam sheet and write your solutions\n    on it}. Do your best to fit your answers into the space provided,\n  and attach extra papers only if necessary. If you typeset in \\LaTeX,\n  \\emph{use the provided TeX file}. No other formats are accepted.\n\n\\item Your work will be graded on correctness and clarity. Make sure\n  your hand writing is legible.\n\\item Don't forget to write your name on top (or update the\n  ``{\\textbackslash}studentname'' command in the TeX file)!\n\\end{itemize}\n\n\\begin{center}\n\\textbf{Grade Table} (for instructor use only)\\\\\n\\smallskip\n\\addpoints\n\\gradetable[v][questions]\n\\end{center}\n\n\\newpage\n\n\\begin{questions}\n  \\question \\emph{Short answers}. Answer the following, and briefly\n  justify your answer.\n  \\begin{parts}\n    \\part[0] (Sample problem) Is\n    $\\sqrt{i/3} \\ket{0} + \\sqrt{2/5}\\ket{1}$ a valid quantum state?\n\n    \\begin{solution}\n      Answer: No.\\\\\n      Justification: Because $|\\sqrt{i/3}|^2 + |\\sqrt{2/5}|^2 \\neq 1$.\n    \\end{solution}\n\n    \\part[5] Is $\\frac{1}{\\sqrt{2}}(\\ket{000} + \\ket{111})$ an\n    entangled state?\n\n    \\vskip 3cm \n    \\part[5] Quantum computers can solve NP-Complete problems in\n    polynomial time. Is this statement True/False/Unknown?\n\n   \\vskip 3cm % comment this line when typing your answer\n\n   \\part[5] Recall in the quantum superdense coding protocol, Alice\n   wants to send two classical bits to Bob by sending one\n   qubit. Suppose a third party (Eve) intercepts Alice's qubit on the\n   way. Can Eve infer anything about which of the four possible bit\n   strings 00, 01, 10, 11 Alice was trying to send?\n\n   \\vskip 4cm\n\n   \\part[5] What is the Quantum Fourier Transform $F_{2^4}$ on a\n   four-qubit state\n   $ \\frac{1}{4}\\ket{0000} + \\frac{i}{4}\\ket{0010} +\n   \\sqrt{\\frac{5}{8}}\\ket{1111}$?\n\n \\end{parts}\n  \\newpage\n  \\question (Quantum circuits)\n\n  \\begin{parts}\n    \\part[10] Suppose you have an unlimited supply of qubits in the state\n    $\\ket{\\psi} = \\alpha\\ket{0}+\\beta\\ket{1}$, and qubits in the state\n    $\\ket{0}$. Give quantum circuits and specify the inputs for\n    producing the following quantum states:\n\n    \\begin{enumerate}[label=\\roman*)]\n    \\item\n      $\\alpha^2\\ket{00} - \\alpha\\beta\\ket{01} + \\alpha\\beta\\ket{10} -\n      \\beta^2\\ket{11}$.\n\n      \\vskip 3cm \n    \\item $\\alpha\\ket{00} - \\beta\\ket{11}$.  \\vskip 3cm\n    \\end{enumerate}\n    \\part[20] For each pair of the circuits below, prove or disprove that\n    they are equivalent.\n\n    \\begin{enumerate}[label=\\roman*)]\n      \\item \n        \\[ \\Qcircuit @C=1em @R=.7em { & \\gate{H} & \\gate{X} &\n            \\gate{H}&\\qw & \\overset{?}{=} & & \\gate{Z}\n          & \\qw } \\] \\vskip 4cm\n      \\item\n        \\[ \\Qcircuit @C=1em @R=.7em {\n            & \\ctrl{2} & \\qw  &  & & \\gate{-Z}& \\qw \\\\\n            &&& \\overset{?}{=} & & &\\\\\n            & \\gate{Z} & \\qw &&&\\ctrl{-2}& \\qw} \n        \\]\n        \\newpage\n      \\item\n        \\[ \\Qcircuit @C=1em @R=.7em {\n            &  \\gate{H} & \\ctrl{2} & \\gate{H}& \\qw  &  & & \\targ & \\qw \\\\\n            &&&&& \\overset{?}{=} & & &\\\\\n            &\\gate{H} & \\targ & \\gate{H} & \\qw &&&\\ctrl{-2}& \\qw}\n        \\]\n        \\vskip 5cm\n      \\item Let $U,V$ be unitary, and $V^2 =U$. The left-hand-side is\n        $U$ controlled by two qubits $\\ket{a}\\ket{b}$ such that $U$ is\n        applied to the third qubit iff. $a = b = 1$.\n        \\[ \\Qcircuit @C=1em @R=.7em { & \\ctrl{2} & \\qw & & & \\qw &\n            \\ctrl{1}& \\qw & \\ctrl{1} &\n            \\ctrl{2} & \\qw \\\\\n            &\\ctrl{1}& \\qw & \\overset{?}{=} & &\\ctrl{1}& \\targ& \\ctrl{1}&\\targ &\\qw &\\qw\\\\\n            &\\gate{U} & \\qw & & &\\gate{V}&\\qw &\\gate{V^\\dagger}& \\qw\n            &\\gate{V} & \\qw }\n        \\]\n        \\vskip 5cm\n      \\end{enumerate}\n      \\part[5] Construct a CNOT gate from one controlled-Z gate and two\n      Hadamard gates.\n      \\newpage\n      \\part[5] (Phase estimation: alternative) Let $U$ be an $n$-qubit\n      unitary operator and $\\ket{\\psi}$ be an eigenvector with\n      $U\\ket{\\psi} = e^{i \\theta } \\ket{\\psi}$. Analyze the circuit\n      below and derive the probability that the measurement outcome is\n      $0$.\n\n      \\begin{figure}[h!]\\label{fig:ape}\n        \\centerline{\\Qcircuit @C=1em @R=.7em {\n            \\lstick{\\ket{0}}&  \\gate{H} & \\ctrl{1} & \\gate{H}& \\meter &\\cw  \\\\\n            \\lstick{\\ket{\\psi}} & \\qw & \\gate{U} &\\qw & \\qw & \\qw\n          }}\n        \\caption{Alternative phase estimation algorithm}\n      \\end{figure}\n\n      \\vskip 5cm\n      \\part (15 Bonus points) Continue from part (d). \n      \\begin{enumerate}[label=\\roman*)]\n      \\item How many times do we need to repeat the circuit in\n        Figure~\\ref{fig:ape} to get an estimate $\\tilde \\theta$ so\n        that $|\\theta - \\tilde \\theta | \\leq \\varepsilon$ with\n        probability at least $1 - \\delta$?  \\vskip 5cm\n      \\item Suppose you can replace $U$ by $U^k$ for an arbitrary\n        integer $k$ of your choice (still controlled by one\n        qubit). Show how to approximate $\\theta$.\n      \\end{enumerate}\n    \\end{parts}\n    \n  \n  \\newpage \n  \\question (Quantum algorithms and permutations) A bijection\n  $P: \\bit^m\\to \\bit^m $ is called a permutation on $\\bit^m$.\n\n  \\begin{parts}\n    \\part[5] How many permutations are there in total on $\\bit^m$?\n    \\vskip 3cm\n\n    \\part[6] Let $S$ be the set of all permutations on\n    $\\bit^m$. Consider a subset $\\{P_k\\}\\subseteq S$ which are indexed\n    by $n$-bit keys $k\\in \\bit^n$ for some $n \\leq m$. We are now\n    given $(x_1,\\ldots, x_t)$ and $(y_1,\\ldots, y_t)$ with the promise\n    that there is a \\emph{unique} $k^*\\in \\bit^n$ such that\n    $P_k(x_i) = y_i$ for all $i =1,\\ldots, t$. The goal is to identify\n    this key $k^*$.  Let us consider classical algorithms\n    first. Suppose we have access to an oracle\n    $O: (k,x)\\mapsto P_k(x)$. How many queries are sufficient to\n    determine $k^*$ in the worst case?  How many are necessary?\n    Justify your answer.\n\n      \\vfill\n\n      \n    \\part[14] Continue from above. Suppose $O$ can be queried in quantum\n      superposition, i.e., it is given as a black-box quantum circuit\n      implementing the unitary\n      \\[ U: \\ket{k}\\ket{x}\\ket{y} \\mapsto \\ket{k}\\ket{x}\\ket{y\\oplus\n          P_k(x)}, \\forall k\\in \\bit^n, x,y\\in \\bit^m \\, .\\]\n\n      \\begin{enumerate}[label=\\roman*)]\n      \n      \\item Show that one can implement another quantum oracle\n        \\[U': \\ket{k} \\ket{b} \\mapsto \\ket{k}\\ket{b\\oplus f(k)}\\, ,\\]\n        where $f:\\bit^n \\to \\bit$ is such that $f(k) = 1$ iff.\n        $P_k(x_i) = y_i$ for all $i = 1,\\ldots, t$. How many calls to\n        $U$ are needed to answer one query to $U'$?\n        \\newpage\n        \\begin{center}\n(Problem 3.c continued)\n        \\end{center}\n\n        \\vskip 8cm\n      \\item Give a quantum algorithm for finding $k^*$. Describe its\n        cost in terms of \\# of queries to $U$ and the circuit size.\n      \\end{enumerate}\n      \\vskip 6cm\n      \\part (15 Bonus points) Let $k_1,k_2\\in \\bit^n$ be two secret\n      strings and $\\pi: \\bit^n\\to \\bit^n$ be a permutation. Define\n      another permutation\\footnote{This is the Even-Mansour block\n        cipher.} $P_{k_1,k_2}: \\bit^n \\to \\bit^n$ as\n      \\[ P_{k_1,k_2}: x\\mapsto \\pi(x\\oplus k_1)\\oplus k_2 \\, .\\]\n\n      \\begin{enumerate}[label=\\roman*)]\n      \\item Define a function $f$ from $\\pi$ and $P_{k_1,k_2}$ such\n        that for all $x$, $f(x\\oplus k_1) = x$.\n        \\newpage\n      \\item Suppose $\\pi$ is sampled uniformly at random among all\n        permutations on $\\bit^n$. Given quantum oracles for $\\pi$ and\n        $P_{k_1,k_2}$, describe a quantum algorithm that recovers\n        $k_1,k_2$ efficiently. \n      \\end{enumerate}\n  \\end{parts}\n    \n\\end{questions}\n\\newpage\n\\begin{center}\nScrap paper -- no exam questions here.  \n\\end{center}\n\n\n\\end{document}\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: t\n%%% End: \n", "meta": {"hexsha": "f5dc007b553624079e35ae85241ababf03656e85", "size": 10535, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "teaching/s19_4640_qc/s19_qc_midterm.tex", "max_stars_repo_name": "fangsonghub/fangsonghub.github.io", "max_stars_repo_head_hexsha": "31a42b297a4644b307b97acd293d9111e567f5c1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "teaching/s19_4640_qc/s19_qc_midterm.tex", "max_issues_repo_name": "fangsonghub/fangsonghub.github.io", "max_issues_repo_head_hexsha": "31a42b297a4644b307b97acd293d9111e567f5c1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-05-06T23:19:12.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-06T23:19:12.000Z", "max_forks_repo_path": "teaching/s19_4640_qc/s19_qc_midterm.tex", "max_forks_repo_name": "fangsonghub/fangsonghub.github.io", "max_forks_repo_head_hexsha": "31a42b297a4644b307b97acd293d9111e567f5c1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3523489933, "max_line_length": 90, "alphanum_fraction": 0.6132890365, "num_tokens": 3521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7690802370707281, "lm_q1q2_score": 0.4085426308084814}}
{"text": "\\documentclass{llncs}\n\n\\pagestyle{plain}\n\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{bookmark}\n\\setcounter{tocdepth}{3}\n\n\\newcommand{\\G}{\\mathbb{G}}\n\\newcommand{\\F}{\\mathbb{F}}\n\\newcommand{\\hash}{\\mathcal{H}}\n\\newcommand{\\addr}{\\operatorname{addr}}\n\\newcommand{\\com}{\\operatorname{Com}}\n\\newcommand{\\dcom}{\\operatorname{DCom}}\n\n\n\\begin{document}\n\n\\title{Lelantus Spark: Secure and Flexible Private Transactions}\n\\author{Aram Jivanyan\\inst{1,2}\\thanks{Corresponding author: \\email{aram@firo.org}} \\and Aaron Feickert\\inst{3}}\n\\institute{Firo \\and Yerevan State University \\and Cypher Stack}\n\\maketitle\n\n\\begin{abstract}\n    We propose a modification to the Lelantus private transaction protocol to provide recipient privacy, improved security, and additional usability features.\n    Our decentralized anonymous payment (DAP) construction, Spark, enables non-interactive one-time addressing to hide recipient addresses in transactions.\n    The modified address format permits flexibility in transaction visibility.\n    Address owners can securely provide third parties with opt-in visibility into incoming transactions or all transactions associated to the address; this functionality allows for offloading chain scanning and balance computation without delegating spend authority.\n    It is also possible to delegate expensive proving operations without compromising spend authority when generating transactions.\n    Further, the design is compatible with straightforward linear multisignature operations to allow mutually non-trusting parties to cooperatively receive and generate transactions associated to a multisignature address.\n    We prove that Spark satisfies formal DAP security properties of balance, non-malleability, and ledger indistinguishability.\n\\end{abstract}\n\n\n\\section{Introduction}\n\nDistributed digital asset protocols have seen a wealth of research since the introduction of the Bitcoin transaction protocol, which enables transactions generating and consuming ledger-based outputs, and provides a limited but useful scripting capability.\nHowever, Bitcoin-type protocols have numerous drawbacks relating to privacy: a transaction reveals source addresses and amounts, and subsequent spends reveal destination addresses.\nFurther, data and metadata associated with transactions, like script contents, can provide undesired fingerprinting of transactions.\n\nMore recent research has focused on mitigating or removing these limitations, while permitting existing useful functionality like multisignature operations or opt-in third-party transaction viewing.\nDesigns in privacy-focused cryptocurrencies like Beam, Firo, Grin, Monero, and Zcash take different approaches toward this goal, with a variety of different tradeoffs.\nThe RingCT-based protocol currently used in Monero, for example, practically permits limited sender anonymity due to the space and time scaling of its underlying signature scheme \\cite{ringct,clsag}.\nThe Sprout and Sapling protocols supported by Zcash \\cite{zcash} (and their currently-deployed related updates) require trusted parameter generation to bootstrap their circuit-based proving systems, and interact with transparent Bitcoin-style outputs in ways that can leak information \\cite{zcash_sprout,zcash_sapling}.\nThe Mimblewimble-based construction used as the basis for Grin can leak graph information prior to a merging operation performed by miners \\cite{mw}.\nTo mitigate Mimblewimble's linkability issue, Beam has designed and implemented into its system an adaption of Lelantus for use with the Mimblewimble protocol which enables obfuscation of the transaction graph \\cite{LMW}.\nThe Lelantus protocol currently used in Firo does not provide recipient privacy; it supports only mints and signer-ambiguous spends of arbitrary amounts that interact with transparent Bitcoin-style outputs, which can leak information about recipient identity \\cite{lelantus}.\nSeraphis \\cite{seraphis} is a transaction protocol framework of similar design being developed concurrently.\n\nHere we introduce Spark, an iteration on the Lelantus protocol enabling trustless private transactions which supports sender, receiver and transaction amount privacy.\nTransactions in Spark, like those in Lelantus and Monero, use specified sender anonymity sets composed of previously-generated shielded outputs.\nA parallel proving system adapted from a construction by Groth and Bootle \\textit{et al.} \\cite{groth,bootle} (of independent interest and used in other modified forms in Lelantus\\cite{lelantus} and Triptych \\cite{triptych}) proves that a consumed output exists in the anonymity set; amounts are encrypted and hidden algebraically in Pedersen commitments, and a tag derived from a verifiable random function \\cite{dodis,omniring} prevents consuming the same output multiple times, which in the context of a transaction protocol would constitute a double-spend attempt.\n\nSpark transactions support efficient verification in batches, where range and spend proofs can take advantage of common proof elements and parameters to lower the marginal cost of verifying each proof in such a batch; when coupled with suitably-chosen sender anonymity sets, the verification time savings of batch verification can be significant.\n\nSpark enables additional useful functionality.\nThe use of a modified Chaum-Pedersen discrete logarithm proof, which asserts spend authority and correct tag construction, enables efficient signing and multisignature operations similar to those of \\cite{musig} where computationally-expensive proofs may be offloaded to more capable devices with limited trust requirements.\nThe protocol further adds two levels of opt-in visibility into transactions without delegating spend authority.\nIncoming view keys allow a designated third party to identify transactions containing outputs destined for an address, as well as the corresponding amounts and encrypted memo data.\nFull view keys allow a designated third party to additionally identify when received outputs are later spent (but without any recipient data), which enables balance auditing and further enhances accountability in threshold multisignature applications where this property is desired.\n\nAll constructions used in Spark require only public parameter generation, ensuring that no trusted parties are required to bootstrap the protocol or ensure soundness.\n\n\n\\section {Cryptographic Preliminaries}\n\nThroughout this paper, we use additive notation for group operations.\nLet $\\mathbb{N}$ be the set $\\{0,1,2,\\ldots\\}$ of non-negative integers.\n\n\n\\subsection{Pedersen Commitment Scheme}\n\nA homomorphic commitment scheme is a construction producing one-way algebraic representations of input values.\nThe Pedersen commitment scheme is a homomorphic commitment scheme that uses a particularly simple linear combination construction.\nLet $pp_{\\text{com}} = (\\G, \\F, G, H)$ be the public parameters for a Pedersen commitment scheme, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $G,H \\in \\G$ are uniformly-sampled independent generators.\nThe commitment scheme contains an algorithm $\\com: \\F^2 \\to \\G$, where $\\com(v,r) = vG + rH$ that is homomorphic in the sense that $$\\com(v_1,r_1) + \\com(v_2,r_2) = \\com(v_1 + v_2,r_1 + r_1)$$ for all such input values $v_1,v_2 \\in \\F$ and masks $r_1,r_2 \\in \\F$.\nFurther, the construction is perfectly hiding and computationally binding.\n\nThis definition extends naturally to a double-masked commitment scheme.\nLet $pp_{\\text{dcom}} = (\\G, \\F, F, G, H)$ be the public parameters for a double-masked Pedersen commitment scheme, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $F,G,H \\in \\G$ are uniformly-sampled independent generators.\nThe commitment scheme contains an algorithm $\\dcom: \\F^3 \\to \\G$, where $\\dcom(v,r,s) = vF + rG + sH$ that is homomorphic in the sense that $$\\dcom(v_1,r_1,s_1) + \\dcom(v_2,r_2,s_2) = \\dcom(v_1 + v_2,r_1 + r_2,s_1 + s_2)$$ for all such input values $v_1,v_2 \\in \\F$ and masks $r_1,r_2,s_1,s_2 \\in \\F$.\nFurther, the construction is perfectly hiding and computationally binding.\n\n\n\\subsection{Representation proving system}\n\nA representation proof is used to demonstrate knowledge of a discrete logarithm in zero knowledge.\nLet $pp_{\\text{rep}} = (\\G, \\F)$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problems is hard and $\\F$ is its scalar field.\n\nThe proving system itself is a tuple of algorithms $(\\text{RepProve},\\text{RepVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{rep}}, G, X \\in \\G ; x \\in \\F : X = xG \\right\\}$$\n\nThe well-known Schnorr proving system may be used for this purpose.\n\n\n\\subsection{Modified Chaum-Pedersen Proving System}\n\nA Chaum-Pedersen proof is used to demonstrate discrete logarithm equality in zero knowledge.\nHere we require a modification to the standard proving system that uses additional group generators.\nLet $pp_{\\text{chaum}} = (\\G, \\F, F, G, H, U)$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, and $F,G,H,U \\in \\G$ are uniformly-sampled independent generators.\n\nThe proving system is a tuple of algorithms $(\\text{ChaumProve},\\text{ChaumVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{chaum}}, S, T \\in \\G ; (x, y, z) \\in \\F : S = xF + yG + zH, U = xT + yG \\right\\}$$\n\nWe present an instantiation of such a proving system in Appendix \\ref{app:chaum}, along with security proofs.\n\n\n\\subsection{Parallel One-out-of-Many Proving System}\n\nWe require the use of a parallel one-out-of-many proving system that shows knowledge of openings of commitments to zero at the same index among two sets of group elements in zero knowledge.\nIn the context of the Spark protocol, this will be used to mask consumed coin serial number and value commitments for balance, ownership, and double-spend purposes.\nWe show how to produce such a proving system as a straightforward modification of a construction by Groth and Kohlweiss \\cite{groth} that was generalized by Bootle \\textit{et al.} \\cite{bootle}.\n\nLet $pp_{\\text{par}} = (\\G, \\F, n, m, pp_{\\text{com}})$ be the public parameters for such a construction, where $\\G$ is a prime-order group where the discrete logarithm problem is hard, $\\F$ is its scalar field, $n > 1$ and $m > 1$ are integer-valued size decomposition parameters, and $pp_{\\text{com}}$ are the public parameters for a Pedersen commitment (and matrix commitment) construction.\n\nThe proving system itself is a tuple of algorithms $(\\text{ParProve},\\text{ParVerify})$ for the following relation, where we let $N = n^m$:\n\\begin{multline*}\n\\left\\{ pp_{\\text{par}}, \\{S_i,V_i\\}_{i=0}^{N-1} \\subset \\G^2 ; l \\in \\mathbb{N}, (s,v) \\in \\F : \\right. \\\\\n\\left. 0 \\leq l < N, S_l = \\com(0,s), V_l = \\com(0,v) \\right\\}\n\\end{multline*}\n\nWe present an instantiation of such a proving system in Appendix \\ref{app:parallel}.\n\n\n\\subsection{Authenticated Encryption Scheme}\n\nWe require the use of an authenticated symmetric encryption with associated data (AEAD) scheme.\nIn the context of the Spark protocol, this construction is used to encrypt value and arbitrary memo data for use by the sender and recipient of a transaction.\n\nLet $pp_{\\text{sym}}$ be the public parameters for such a construction.\nThe construction itself is a tuple of algorithms $(\\text{AEADKeyGen},\\text{AEADEncrypt},\\text{AEADDecrypt})$.\nHere $\\text{AEADKeyGen}$ is a key derivation function that accepts as input an arbitrary string, and produces a key in the appropriate key space.\nThe algorithm $\\text{AEADEncrypt}$ accepts as input a key, associated data, and arbitrary message string, and produces ciphertext in the appropriate space.\nThe algorithm $\\text{AEADDecrypt}$ accepts as input a key, associated data, and ciphertext string, and produces a message in the appropriate space if authentication succeeds.\nFor the purposes of this protocol, we may assume the use of a fixed nonce, as keys are used uniquely with given associated data.\n\nAssume that such a construction is indistinguishable against chosen-plaintext attack (IND-CPA), indistinguishable against adaptive chosen-ciphertext attack (IND-CCA2), and key-private under chosen-ciphertext attacks (IK-CCA) in this context.\n\n\n\\subsection{Range Proving System}\n\nWe require the use of a zero-knowledge range proving system.\nA range proving system demonstrates that a commitment binds to a value within a specified range.\nIn the context of the Spark protocol, it avoids overflow that would otherwise fool the balance definition by effectively binding to invalid negative values.\nLet $pp_{\\text{rp}} = (\\G, \\F, v_{\\text{max}}, pp_{\\text{com}})$ be the relevant public parameters for such a construction, where $pp_{\\text{com}}$ are the public parameters for a Pedersen commitment construction.\n\nThe proving system itself is a tuple of algorithms $(\\text{RangeProve},\\text{RangeVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{rp}}, C \\in \\G ; (v, r) \\in \\F : 0 \\leq v \\leq v_{\\text{max}}, C = \\com(v,r) \\right\\}$$\n\nIn practice, an efficient instantiation like Bulletproofs \\cite{bp} or Bulletproofs+ \\cite{bp_plus} may be used to satisfy this requirement.\n\n\n\\section{Concepts and Algorithms}\n\nWe now define the main concepts and algorithms used in the Spark transaction protocol.\n\n\\textbf{Addresses}. Users generate addresses that enable transactions.\nAn address consists of a tuple $$(\\addr_{\\text{pk}}, \\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{\\text{sk}}).$$\nFor each address, $\\addr_{\\text{pk}}$ is the public address used for receiving funds, $\\addr_{\\text{in}}$ is an incoming view key used to identify received funds, $\\addr_{\\text{full}}$ is a full view key used to identify outgoing funds and conduct computationally-heavy proving operations, and $\\addr_{\\text{sk}}$ is the spend key used to generate transactions.\n\n\\textbf{Coins.} A coin encodes the abstract value which is transferred through the private transactions. Each coin is associated with:\n\\begin{itemize}\n\\item A (secret) serial number that uniquely defines the coin.\n\\item A serial number commitment.\n\\item An integer value for the coin.\n\\item An encrypted value intended for decryption by the recipient.\n\\item A value commitment.\n\\item A range proof for the value commitment, or a proof that a plaintext value is represented by the value commitment.\n\\item A memo with arbitrary recipient data.\n\\item An encrypted memo intended for decryption by the recipient.\n\\item A recovery key used by the recipient to identify the coin and decrypt private data.\n\\end{itemize}\nCoins additionally bind recipient addresses in an indistinguishable way; this may be useful for out-of-band payment proofs that require such binding.\n\n\\textbf{Private Transactions}. There are two types of private transactions in Spark:\n\\begin{itemize}\n    \\item $Mint$ transactions.\n    A $Mint$ transaction generates new coins of public value destined for a recipient public address in a confidential way, either through a consensus-enforced mining process, or by consuming transparent outputs from a non-Spark base layer.\n    In this transaction type, a representation proof is included to show that the minted coin is of the expected value.\n    A $Mint$ transaction creates transaction data $\\text{tx}_{\\text{mint}}$ for recording on a ledger.\n    \\item $Spend$ transactions.\n    A $Spend$ transaction consumes existing coins and generates new coins destined for one or more recipient public addresses in a confidential way.\n    In this transaction type, a representation proof is included to show that the hidden input and output values are equal.\n    A $Spend$ transaction creates transaction data $\\text{tx}_{\\text{spend}}$ for recording on a ledger.\n\\end{itemize}\n\n\\textbf{Tags.} Tags are used to prevent coins from being consumed in multiple transactions.\nWhen generating a $Spend$ transaction, the sender produces the tag for each consumed coin and includes it on the ledger.\nWhen verifying transactions are valid, it suffices to ensure that tags do not appear on the ledger in any previous transactions.\nTags are bound to validly-recoverable coins uniquely via the serial number commitment secret data, but cannot be associated to specific coins without the corresponding full view key.\n\n\\textbf{Algorithms}. Spark is a decentralized anonymous payment (DAP) system defined as the following polynomial-time algorithms:\n\\begin{itemize}\n\\item \\textbf{Setup}: This algorithm outputs all public parameters used by the protocol and its underlying components.\nThe setup process does not require any trusted parameter generation.\n\\item \\textbf{CreateAddress}: This algorithm outputs a public address, incoming view key, full view key, and spend key.\n\\item \\textbf{CreateCoin}: This algorithm takes as input a public address, coin value, and memo, and outputs a coin destined for the public address.\n\\item \\textbf{Mint:} This algorithm takes as input a public address, value, and (optionally) implementation-specific data relating to base-layer outputs, and outputs a mint transaction $\\text{tx}_{\\text{mint}}$.\n\\item \\textbf{Identify:} This algorithm takes as input a coin and an incoming view key, and outputs the coin value and memo.\n\\item \\textbf{Recover:} This algorithm takes as input a coin and a full view key, and outputs the coin value, memo, serial number, and tag.\n\\item \\textbf{Spend:} This algorithm takes as input a full view key, a spend key, a set of input coins (including coins used as a larger ambiguity set), the indexes of coins to be spent, the corresponding serial numbers and values, a fee value, and a set of output coins to be generated, and outputs a spend transaction $\\text{tx}_{\\text{spend}}$.\n\\item \\textbf{Verify:} This algorithm accepts either a mint transaction or a spend transaction, and outputs a bit to assess validity.\n\\end{itemize}\n\nWe provide detailed descriptions below, and show security of the resulting protocol in the appendixes.\n\n\n\\section{Algorithm Constructions}\n\nIn this section we provide detailed description of the DAP scheme algorithms.\n\n\n\\subsection{Setup}\n\nIn our setup the public parameters $pp$ are comprised of the corresponding public parameters of a Pedersen commitment (and matrix commitment) scheme, representation proving system, modified Chaum-Pedersen proving system, parallel one-out-of-many proving system, symmetric encryption scheme, and range proving system.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, size decomposition parameters $n > 1$ and $m > 1$, maximum value parameter $v_{\\text{max}}$\n\n\\textbf{Outputs:} Public parameters $pp$\n\n\\begin{enumerate}\n\\item Sample a prime-order group $\\G$ in which the discrete logarithm, decisional Diffie-Hellman, and computational Diffie-Hellman problems are hard.\nLet $\\F$ be the scalar field of $\\G$.\n\\item Sample $F,G,H,U \\in \\G$ uniformly at random.\nIn practice, these generators may be chosen using a suitable cryptographic hash function on public input.\n\\item Sample cryptographic hash functions $$\\hash_{\\text{ser}},\\hash_{\\text{val}},\\hash_{\\text{ser}'},\\hash_{\\text{val}'},\\hash_{\\text{bind}}: \\{0,1\\}^* \\to \\F$$ uniformly at random.\nIn practice, these hash functions may be chosen using domain separation of a single suitable cryptographic hash function.\n\\item Compute the public parameters $pp_{\\text{com}} = (\\G,\\F,G,H)$ of a Pedersen commitment scheme.\n\\item Compute the public parameters $pp_{\\text{dcom}} = (\\G,\\F,F,G,H)$ of a double-masked Pedersen commitment scheme.\n\\item Compute the public parameters $pp_{\\text{rep}} = (\\G,\\F)$ of a representation proving system.\n\\item Compute the public parameters $pp_{\\text{chaum}} = (\\G,\\F,F,G,H,U)$ of the modified Chaum-Pedersen proving system.\n\\item Compute the public parameters $pp_{\\text{par}} = (\\G,\\F,n,m,pp_{\\text{com}})$ of the parallel one-out-of-many proving system.\n\\item Compute the public parameters $pp_{\\text{sym}}$ of an authenticated symmetric encryption scheme.\n\\item Compute the public parameters $pp_{\\text{rp}} = (\\G,\\F,v_{\\text{max}},pp_{\\text{com}})$ of a range proving system.\n\\item Output all generated public parameters and hash functions as $pp$.\n\\end{enumerate}\n\n\n\\subsection{CreateAddress}\n\nWe describe the construction of all addresses and underlying key types used in the protocol.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$\n\n\\textbf{Outputs:} Address key tuple $(\\addr_{\\text{pk}}, \\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{sk})$\n\n\\begin{enumerate}\n\\item Sample $s_1, s_2, r \\in \\F$ uniformly at random, and let $D = \\dcom(0, r, 0)$.\n\\item Compute $Q_1 = \\dcom(s_1, 0, 0)$ and $Q_2 = \\dcom(s_2, r, 0)$.\n\\item Set $\\addr_{\\text{pk}} = (Q_1, Q_2)$.\n\\item Set $\\addr_{\\text{in}} = s_1$.\n\\item Set $\\addr_{\\text{full}} = (s_1, s_2, D)$.\n\\item Set $\\addr_{\\text{sk}} = (s_1, s_2, r)$.\n\\item Output the tuple $(\\addr_{\\text{pk}}, \\addr_{\\text{in}}, \\addr_{\\text{full}}, \\addr_{sk})$.\n\\end{enumerate}\n\n\n\\subsection{CreateCoin}\n\nThis algorithm generates a new coin destined for a given public address.\nNote that while this algorithm generates a serial number commitment, it cannot compute the underlying serial number.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, destination public address $\\addr_{\\text{pk}}$, value $v \\in [0, v_{\\text{max}})$, memo $m$, type bit $b$\n\n\\textbf{Outputs:} Coin public key $S$, recovery key $K$, value commitment $C$, value commitment range proof $\\Pi_{\\text{rp}}$ (if $b=0$), encrypted value $\\overline{v}$ (if $b=0$) or value $v$ (if $b=1$), encrypted memo $\\overline{m}$\n\n\\begin{enumerate}\n\\item Parse the recipient address $\\addr_{\\text{pk}} = (Q_1, Q_2)$.\n\\item Sample $k \\in \\F$.\n\\item Compute the recovery key $K = \\dcom(k, 0, 0)$.\n\\item Compute the serial number commitment $$S = \\dcom(\\hash_{\\text{ser}}(kQ_1,Q_1,Q_2), 0, 0) + Q_2.$$\n\\item Generate the value commitment $C = \\com(v, \\hash_{\\text{val}}(kQ_1))$.\n\\item If $b=0$, generate a range proof $$\\Pi_{\\text{rp}} = \\text{RangeProve}(pp_{\\text{rp}},C;(v,\\hash_{\\text{val}}(kQ_1))).$$\n\\item Generate a symmetric encryption key $k_{\\text{aead}} = \\text{AEADKeyGen}(kQ_1)$; encrypt the value $\\overline{v} = \\text{AEADEncrypt}(k_{\\text{aead}},\\texttt{val},v)$ (if $b=0$) and memo $\\overline{m} = \\text{AEADEncrypt}(k_{\\text{aead}},\\texttt{memo},m)$.\n\\item If $b=0$, output the tuple $(S, K, C, \\Pi_{\\text{rp}}, \\overline{v}, \\overline{m})$.\nOtherwise, output the tuple $(S, K, C, v, \\overline{m})$.\n\\end{enumerate}\nThe case $b=0$ represents a coin with hidden value being generated in a $\\text{Spend}$ transaction, while the case $b=0$ represents a coin with plaintext value being generated in a $\\text{Mint}$ transaction.\nNote that it is possible to securely aggregate range proofs within a transaction; this does not affect protocol security.\n\n\n\\subsection{Mint}\n\nThis algorithm generates new coins from either a consensus-determined mining process, or by consuming non-Spark outputs from a base layer with public value.\nNote that while such implementation-specific auxiliary data may be necessary for generating such a transaction and included, we do not specifically list this here.\nNotably, the coin value used in this algorithm is assumed to be the sum of all public input values as specified by the implementation.\n\n\\textbf{Inputs}: Security parameter $\\lambda$, public parameters $pp$, destination public address $\\addr_{\\text{pk}}$, coin value $v \\in [0, v_{\\text{max}})$, memo $m$\n\n\\textbf{Outputs}: Mint transaction $\\text{tx}_{\\text{mint}}$\n\n\\begin{enumerate}\n\\item Generate the new coin $\\text{CreateCoin}(\\addr_{\\text{pk}}, v, m, 1) \\to \\text{Coin} = (S, K, C, v, \\overline{m})$.\n\\item Generate a value representation proof on the value commitment: $$\\Pi_{\\text{bal}} = \\text{RepProve}(pp_{\\text{rep}},H,C - \\com(v,0); \\hash_{\\text{val}}(kQ_1))$$\n\\item Output the tuple $\\text{tx}_{\\text{mint}} = (\\text{Coin}, \\Pi_{\\text{bal}})$.\n\\end{enumerate}\n\n\n\\subsection{Identify}\n\nThis algorithm allows a recipient (or designated entity) to compute the value and memo from a coin destined for its public address.\nIt requires the incoming view key corresponding to the public address to do so.\nIf the coin is not destined for the public address, the algorithm returns failure.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, incoming view key $\\addr_{\\text{in}}$, public address $\\addr_{\\text{pk}}$, coin $\\text{Coin}$.\n\n\\textbf{Outputs:} Value $v$, memo $m$\n\n\\begin{enumerate}\n\\item Parse the incoming view key $\\addr_{\\text{in}} = s_1$ and public address $\\addr_{\\text{pk}} = (Q_1, Q_2)$.\n\\item Parse the serial number commitment $S$, value commitment $C$, recovery key $K$, encrypted value $\\overline{v}$ (if the coin is of type $b=0$) or value $v$ (if the coin is of type $b=1$), and encrypted memo $\\overline{m}$ from $\\text{Coin}$.\n\\item If $\\dcom(\\hash_{\\text{ser}}(s_1 K,Q_1,Q_2), 0, 0) + Q_2 \\neq S$, return failure.\n\\item Generate a symmetric encryption key $k_{\\text{aead}} = \\text{AEADKeyGen}(s_1 K)$; decrypt the value $v = \\text{AEADDecrypt}(k_{\\text{aead}},\\texttt{val},\\overline{v})$ (if $b=0$) and memo $m = \\text{AEADDecrypt}(k_{\\text{aead}},\\texttt{memo},\\overline{m})$.\n\\item If $\\com(v,\\hash_{\\text{val}}(s_1 K)) \\neq C$, return failure.\n\\item Output the tuple $(v, m)$.\n\\end{enumerate}\n\n\n\\subsection{Recover}\n\nThis algorithm allows a recipient (or designated entity) to compute the serial number, tag, value, and memo from a coin destined for its public address.\nIt requires the full view key corresponding to the public address to do so.\nIf the coin is not destined for the public address, the algorithm returns failure.\n\n\\textbf{Inputs:} Security parameter $\\lambda$, public parameters $pp$, full view key $\\addr_{\\text{full}}$, public address $\\addr_{\\text{pk}}$, coin $\\text{Coin}$.\n\n\\textbf{Outputs:} Coin serial number $s$, tag $T$, value $v$, memo $m$\n\n\\begin{enumerate}\n\\item Parse the full view key as $\\addr_{\\text{full}} = (s_1, s_2, D)$ and public address $\\addr_{\\text{pk}} = (Q_1, Q_2)$.\n\\item Parse the serial number commitment $S$, value commitment $C$, recovery key $K$, encrypted value $\\overline{v}$ (if the coin is of type $b=0$) or value $v$ (if the coin is of type $b=1$), and encrypted memo $\\overline{m}$ from $\\text{Coin}$.\n\\item If $\\dcom(\\hash_{\\text{ser}}(s_1 K,Q_1,Q_2), 0, 0) + Q_2 \\neq S$, return failure.\n\\item Generate a symmetric encryption key $k_{\\text{aead}} = \\text{AEADKeyGen}(s_1 K)$; decrypt the value $v = \\text{AEADDecrypt}(k_{\\text{aead}},\\texttt{val},\\overline{v})$ (if $b=1$) and memo $m = \\text{AEADDecrypt}(k_{\\text{aead}},\\texttt{memo},\\overline{m})$.\n\\item If $\\com(v,\\hash_{\\text{val}}(s_1 K)) \\neq C$, return failure.\n\\item Compute the serial number $$s = \\hash_{\\text{ser}}(s_1 K,Q_1,Q_2) + s_2$$ and tag $$T = (1/s)(U - D).$$\n\\item If $T$ has been constructed in any other valid recovery, return failure.\n\\item Output the tuple $(s, T, v, m)$.\n\\end{enumerate}\n\n\n\\subsection{Spend}\n\nThis algorithm allows a recipient to generate a transaction that consumes coins destined to its public address, and generates new coins destined for arbitrary public addresses.\nThe process is designed to be modular; in particular, only the full view key is required to generate the parallel one-out-of-many proof, which may be computationally expensive.\nThe use of spend keys is only required for the final Chaum-Pedersen proof step, which is of lower complexity.\n\nIt is assumed that the recipient has run the $\\text{Recover}$ algorithm on all coins that it wishes to consume in such a transaction.\n\n\\textbf{Inputs:}\n\\begin{itemize}\n    \\item Security parameter $\\lambda$ and public parameters $pp$\n    \\item A full view key $\\addr_{\\text{full}}$\n    \\item A spend key $\\addr_{\\text{sk}}$\n    \\item A set of $N$ input coins $\\text{InCoins}$ as part of a cover set\n    \\item For each $u \\in [0,w)$ coin to spend, the index in $\\text{InCoins}$, serial number, tag, value, and recovery key: $(l_u, s_u, T_u, v_u, K_u)$\n    \\item An integer fee value $f \\in [0,v_{\\text{max}})$\n    \\item A set of $t$ output coin public addresses, values, and memos: $$\\{\\addr_{\\text{pk},j}, v_j, m_j\\}_{j=0}^{t-1}$$\n\\end{itemize}\n\n\\textbf{Outputs:} Spend transaction $\\text{tx}_{\\text{spend}}$\n\n\\begin{enumerate}\n    \\item Parse the required full view key component as $\\addr_{\\text{full}} = D$.\n    \\item Parse the spend key $\\addr_{\\text{sk}} = (s_1, s_2, r)$.\n    \\item Parse the cover set serial number commitments and value commitments as $\\text{InCoins} = \\{(S_i, C_i)\\}_{i=0}^{N-1}$.\n    \\item For each $u \\in [0,w)$:\n    \\begin{enumerate}\n        \\item Compute the serial number commitment offset: $$S_u' = \\dcom(s_u, 0, -\\hash_{\\text{ser}'}(s_u, D)) + D$$\n        \\item Compute the value commitment offset: $$C_u' = \\com(v_u, \\hash_{\\text{val}'}(s_u, D))$$\n        \\item Generate a parallel one-out-of-many proof:\n        \\begin{multline*}\n        (\\Pi_{\\text{par}})_u = \\text{ParProve}(pp_{\\text{par}},\\{S_i - S_u', C_i - C_u'\\}_{i=0}^{N-1}; \\\\\n        (l_u, \\hash_{\\text{ser}'}(s_u, D), \\hash_{\\text{val}}(s_1 K_u) - \\hash_{\\text{val}'}(s_u, D)))\n        \\end{multline*}\n    \\end{enumerate}\n    \\item Generate a set $\\text{OutCoins} = \\{\\text{CreateCoin}(\\addr_{\\text{pk},j}, v_j, m_j, 0)\\}_{j=0}^{t-1}$ of output coins.\n    \\item Parse the output coin value commitments as $\\text{OutCoins} = \\{\\overline{C}_j\\}_{j=0}^{t-1}$, where each $\\overline{C}_j$ contains a recovery key preimage $k_j$ and destination address component $(Q_1)_j$.\n    \\item Generate a representation proof for balance assertion:\n    \\begin{multline*}\n    \\Pi_{\\text{bal}} = \\text{RepProve}\\left( pp_{\\text{rep}}, H, \\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0); \\right. \\\\\n    \\left. \\sum_{u=0}^{w-1} \\hash_{\\text{val}'}(s_u,D) - \\sum_{j=0}^{t-1} \\hash_{\\text{val}}(k_j(Q_1)_j) \\right)\n    \\end{multline*}\n    \\item Let $\\mu = \\hash_{\\text{bind}}( \\text{InCoins}, \\text{OutCoins}, f, \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )$.\n    \\item For each $u \\in [0,w)$, generate a modified Chaum-Pedersen proof, where we additionally bind $\\mu$ to the initial transcript: $$(\\Pi_{\\text{chaum}})_u = \\text{ChaumProve}(pp_{\\text{chaum}},S_u', T_u; (s_u, r, -\\hash_{\\text{ser}'}(s_u, D)))$$\n    \\item Output the tuple:\n    \\begin{multline*}\n    \\text{tx}_{\\text{spend}} = ( \\text{InCoins}, \\text{OutCoins}, f, \\\\\n    \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, (\\Pi_{\\text{chaum}})_u \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )\n    \\end{multline*}\n\\end{enumerate}\n\n\\begin{remark}\nWe note that it is possible to modify the balance proof to account for other input or output values not represented by coin value commitments, similarly to the handling of fees.\nThis observation can allow for the transfer of value into new coins without the use of a $\\text{Mint}$ transaction, or a transfer of value to a transparent base layer.\nSuch transfer functionality is likely to introduce practical risk that is not captured by the protocol security model, and warrants thorough analysis.\n\\end{remark}\n\n\n\\subsection{Verify}\n\nThis algorithm assesses the validity of a transaction.\n\n\\textbf{Inputs:} either a mint transaction $\\text{tx}_{\\text{mint}}$ or a spend transaction $\\text{tx}_{\\text{spend}}$\n\n\\textbf{Outputs:} a bit that represents the validity of the transaction\n\nIf the input transaction is a mint transaction:\n\\begin{enumerate}\n    \\item Parse the transaction $\\text{tx}_{\\text{mint}} = (\\text{Coin}, \\Pi_{\\text{bal}})$.\n    \\item Parse the coin value and value commitment as $\\text{Coin} = (v, C)$.\n    \\item Check that $v \\in [0,v_{\\text{max}})$, and output 0 if this fails.\n    \\item Check that $\\text{RepVerify}(pp_{\\text{rep}},\\Pi_{\\text{bal}},H,C - \\com(v,0))$, and output 0 if this fails.\n    \\item Output 1.\n\\end{enumerate}\n\nIf the input transaction is a spend transaction:\n\\begin{enumerate}\n    \\item Parse the transaction:\n    \\begin{multline*}\n    \\text{tx}_{\\text{spend}} = ( \\text{InCoins}, \\text{OutCoins}, f, \\\\\n    \\left\\{ S_u', C_u', T_u, (\\Pi_{\\text{par}})_u, (\\Pi_{\\text{chaum}})_u \\right\\}_{u=0}^{w-1}, \\Pi_{\\text{bal}} )\n    \\end{multline*}\n    \\item Parse the cover set serial number commitments and value commitments as $\\text{InCoins} = \\{(S_i, C_i)\\}_{i=0}^{N-1}$.\n    \\item Parse the output coin value commitments and range proofs as $\\text{OutCoins} = \\{ \\overline{C}_j, (\\Pi_{\\text{rp}})_j \\}_{j=0}^{t-1}$.\n    \\item For each $u \\in [0,w):$\n    \\begin{enumerate}\n        \\item Check that $T_u$ does not appear again in this transaction or in any previously-verified transaction, and output 0 if it does.\n        \\item Check that $\\text{ParVerify}(pp_{\\text{par}},(\\Pi_{\\text{par}})_u,\\{S_i - S_u',C_i - C_u'\\}_{i=0}^{N-1})$, and output 0 if this fails.\n        \\item Check that $\\text{ChaumVerify}(pp_{\\text{chaum}},(\\Pi_{\\text{chaum}})_u,S_u',T_u)$, and output 0 if this fails.\n    \\end{enumerate}\n    \\item For each $j \\in [0,t):$\n    \\begin{enumerate}\n        \\item Check that $\\text{RangeVerify}(pp_{\\text{rp}},(\\Pi_{\\text{rp}})_j,C)$, and output 0 if this fails.\n    \\end{enumerate}\n    \\item Check that $f \\in [0,v_{\\text{max}})$, and output 0 if this fails.\n    \\item Check that $$\\text{RepVerify}\\left( pp_{\\text{rep}}, \\Pi_{\\text{bal}}, H, \\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0) \\right)$$ and output 0 if this fails.\n    \\item Output 1.\n\\end{enumerate}\n\n\n\\section{Multisignature Operations}\n\nSpark addresses and transactions support efficient and secure multisignature operations, where a group of signers are required to authorize transactions.\nWe describe a method for signing groups to perform the $\\text{CreateAddress}$ and $\\text{Spend}$ algorithms to produce multisignature addresses and spend transactions indistinguishable from others.\n\nThroughout this section, suppose we have a group of $\\nu$ signers who wish to collaboratively produce an address or transaction.\nFurther, sample a cryptographic hash function $\\hash_{\\text{agg}}: \\{0,1\\}^* \\to \\F$ uniformly at random.\n\n\n\\subsection{CreateAddress}\n\n\\begin{enumerate}\n\\item Each player $\\alpha \\in [0,\\nu)$ chooses $s_{1,\\alpha}, s_{2,\\alpha}, r_\\alpha \\in \\F$ uniformly at random, and sets $D_\\alpha = \\dcom(0, r_\\alpha, 0)$.\nIt sends the the values $s_{1,\\alpha}, s_{2,\\alpha}, D_\\alpha$ to all players.\n\\item All players compute the aggregate incoming view key and full view key components:\n\\begin{align*}\ns_1 &= \\sum_{\\alpha=0}^{\\nu-1} \\hash_{\\text{agg}}\\left( \\{s_{1,\\beta}\\}_{\\beta=0}^{\\nu-1}, \\alpha \\right) s_{1,\\alpha} \\\\\ns_2 &= \\sum_{\\alpha=0}^{\\nu-1} \\hash_{\\text{agg}}\\left( \\{s_{2,\\beta}\\}_{\\beta=0}^{\\nu-1}, \\alpha \\right) s_{2,\\alpha} \\\\\nD &= \\sum_{\\alpha=0}^{\\nu-1} \\hash_{\\text{agg}}\\left( \\{D_\\beta\\}_{\\beta=0}^{\\nu-1}, \\alpha \\right) D_\\alpha\n\\end{align*}\n\\item All players compute the aggregate public address components:\n\\begin{align*}\nQ_1 &= \\dcom(s_1, 0, 0) \\\\\nQ_2 &= \\dcom(s_2, 0, 0) + D\n\\end{align*}\n\nNote that each player $\\alpha$ keeps its spend key share $r_\\alpha$ private.\n\\end{enumerate}\n\n\n\\subsection{Spend}\n\nBecause all players possess the aggregate full view key corresponding to the aggregate public address, any player can use it to construct all transaction components except modified Chaum-Pedersen proofs.\nWe describe now how the signers collaboratively produce such a proof to authorize the spending of a coin, with the following proof inputs (using our previous notation):\n$$\\{pp_{\\text{chaum}}, S_u', T_u; (s_u, r, -\\hash_{\\text{ser}'}(s_u, D))\\}$$\n\n\\begin{enumerate}\n\\item Each player $\\alpha \\in [0,\\nu)$ chooses $\\overline{r}_\\alpha, \\overline{s}_\\alpha, \\overline{t}_\\alpha \\in \\F$ uniformly at random.\nIt generates a commitment to the tuple $(\\overline{r}_\\alpha, \\overline{s}_\\alpha G, \\overline{t}_\\alpha)$ and sends it to all players.\n\\item Each player reveals its commitment opening to all players, verifies all players' openings, and aborts if any are invalid.\n\\item All players compute the initial proof terms:\n\\begin{align*}\nA_1 &= \\left( \\sum_{\\beta=0}^{\\nu-1} \\overline{r}_\\beta \\right) F + \\sum_{\\beta=0}^{\\nu-1} (\\overline{s}_\\alpha G) \\\\\nA_2 &= \\left( \\sum_{\\beta=0}^{\\nu-1} \\overline{r}_\\beta \\right) T_u + \\sum_{\\beta=0}^{\\nu-1} (\\overline{s}_\\alpha G) \\\\\nA_3 &= \\left( \\sum_{\\beta=0}^{\\nu-1} \\overline{t}_\\beta \\right) H\n\\end{align*}\nThey compute the challenge $c$ from the initial proof transcript.\n\\item Each player $\\alpha \\in [0,\\nu)$ computes the following:\n\\begin{align*}\nt_1 &= \\sum_{\\beta=0}^{\\nu-1} \\overline{r}_\\beta + cs_u \\\\\nt_{2,\\alpha} &= \\overline{s}_\\alpha + c\\hash_{\\text{agg}}\\left( \\{D_\\beta\\}_{\\beta=0}^{\\nu-1}, \\alpha \\right) r_\\alpha \\\\\nt_3 &= \\sum_{\\beta=0}^{\\nu-1} \\overline{t}_\\beta - c\\hash_{\\text{ser}'}(s_u, D)\n\\end{align*}\nIt sends $t_{2,\\alpha}$ to all players.\n\\item All players compute the final proof term: $$t_2 = \\sum_{\\beta=0}^{\\nu-1} t_{2,\\beta}$$\n\\end{enumerate}\n\n\n\\section{Applications of Key Structures}\n\nThe key structure in Spark permits flexible and useful functionality relating to transaction scanning and generation.\n\nThe incoming view key is used in $\\text{Identify}$ operations to determine when a coin is directed to the associated public address, and to determine the coin's value and associated memo data.\nThis permits two use cases of note.\nIn one case, blockchain scanning can be delegated to a device or service without delegating spend authority for identified coins.\nIn another case, wallet software in possession of a spend key can keep this key encrypted or otherwise securely stored during scanning operations, reducing key exposure risks.\n\nThe full view key is used in $\\text{Recover}$ operations to additionally compute the serial number and tag for coins directed to the associated public address.\nThese tags can be used to identify a transaction spending the coin.\nProviding this key to a third party permits identification of incoming transactions and detection of outgoing transactions, which additionally provides balance computation, without delegating spend authority.\nUsers like public charities may wish to permit public oversight of funds with this functionality.\nOther users may wish to provide this functionality to an auditor or accountant for bookkeeping purposes.\nIn the case where a public address is used in threshold multisignature operations, a cosigner may wish to know if or when another cohort of cosigners has produced a transaction spending funds from its address.\n\nFurther, the full view key is used in $\\text{Spend}$ to generate one-out-of-many proofs.\nSince the parallel one-out-of-many proof used in Spark can be computationally expensive, it may be unsuitable for generation by a computationally-limited device like a hardware wallet.\nProviding this key to a more powerful device enables easy generation of this proof (and other transaction components like range proofs), while ensuring that only the device holding the spend key can complete the transaction by generating the simple modified Chaum-Pedersen proofs.\n\n\n\\section{Efficiency}\n\nIt is instructive to examine the efficiency of $\\text{Spend}$ transactions in size, generation complexity, and verification complexity.\nIn addition to our previous notation for parameters, let $v_{\\text{max}} = 2^{64}$, so coin values and fees can be represented by $8$-byte unsigned integers.\nFurther, suppose coin memos are fixed at $M$ bytes in length, with a $16$-byte authentication tag; this is the case for the ChaCha20-Poly1305 authenticated symmetric encryption construction, for example \\cite{chachapoly}.\nTransaction size data for specific component instantiations is given in Table \\ref{table:size}, where we consider the size in terms of group elements, field elements, and other data.\nNote that we do not include input ambiguity set references in this data, as this depends on implementation-specific selection and representation criteria.\n\n\\begin{table}\n    \\caption{$\\text{Spend}$ transaction size by component}\n    \\label{table:size}\n    \\centering\n    \\begin{tabular}{|l|l|r|r|r|}\n        \\hline\n        \\textbf{Component} & \\textbf{Instantiation} & \\textbf{Size ($\\G$)} & \\textbf{Size ($\\F$)} & \\textbf{Size (bytes)} \\\\\n        \\hline\n        $f$ & & & & $8$ \\\\\n        $\\Pi_{\\text{rp}}$ & Bulletproofs+ & $2 \\lceil \\lg(64t) \\rceil + 3$ & $3$ & \\\\\n        $\\Pi_{\\text{bal}}$ & Schnorr & & $2$ & \\\\\n        \\hline\n        \\multicolumn{5}{|c|}{Input data ($w$ coins)} \\\\\n        \\hline\n        $(S',C')$ & & $2w$ & & \\\\\n        $\\Pi_{\\text{par}}$ & this paper & $(2m + 4)w$ & $[m(n-1) + 4]w$ & \\\\\n        $\\Pi_{\\text{chaum}}$ & this paper & $3w$ & $3w$ & \\\\\n        \\hline\n        \\multicolumn{5}{|c|}{Output data ($t$ coins)} \\\\\n        \\hline\n        $(S,K,C)$ & & $3t$ & & \\\\\n        $(\\overline{v},\\overline{m})$ & ChaCha20-Poly1305 & & & $(8 + M + 16)t$ \\\\\n        \\hline\n    \\end{tabular}\n\\end{table}\n\nTo evaluate the verification complexity of $\\text{Spend}$ transactions using these components, we observe that verification in constructions like the parallel one-out-of-many proving system in this paper, Bulletproof+ range proving system, Schnorr representation proving system, and modified Chaum-Pedersen proving system in this paper all reduce to single linear combination evaluations in $\\G$.\nBecause of this, proofs can be evaluated in batches if the verifier first weights each proof by a random value in $\\F$, such that distinct group elements need only appear once in the resulting weighted linear combination.\nNotably, techniques like that of \\cite{pippenger} can be used to reduce the complexity of such evaluations by up to a logarithmic factor.\nSuppose we wish to verify a batch of $B$ transactions, each of which spends $w$ coins and generates $t$ coins.\nTable \\ref{table:time} shows the verification batch complexity in terms of total distinct elements of $\\G$ that must be included in a linear combination evaluation.\n\n\\begin{table}\n    \\caption{$\\text{Spend}$ transaction batch verification complexity for $B$ transactions with $w$ spent coins and $t$ generated coins}\n    \\label{table:time}\n    \\centering\n    \\begin{tabular}{|l|r|}\n        \\hline\n        \\textbf{Component} & \\textbf{Complexity} \\\\\n        \\hline\n        Parallel one-out-of-many & $B[w(2m + 6) + 2m^m] + m^n + 1$ \\\\\n        Bulletproofs+ & $B(t + 2\\lg(64t) + 3) + 128T + 2$ \\\\\n        Modified Chaum-Pedersen & $B(5w) + 4$ \\\\\n        Schnorr & $B(w + t + 1) + 2$ \\\\\n        \\hline\n    \\end{tabular}\n\\end{table}\n\nWe further comment that the parallel one-out-of-many proving system presented in this paper may be further optimized in verification.\nBecause corresponding elements of the $\\{S_i\\}$ and $\\{V_i\\}$ input sets are weighted identically in the protocol verification equations, it may be more efficient (depending on implementation) to combine these elements with a sufficient weight prior to applying the proof-specific weighting identified above for batch verification.\nInitial tests using a variable-time curve library suggest significant reductions in verification time with this technique.\n\n\n\\section*{Acknowledgments}\n\nThe authors thank pseudonymous collaborator \\texttt{koe} for ongoing discussions during the development of this work.\nThe authors gratefully acknowledge Nikolas Kr\\\"{a}tzschmar for identifying an earlier protocol flaw relating to tag generation.\n\n\n\\bibliographystyle{splncs04}\n\\bibliography{main}\n\n\\appendix\n\n\n\\section{Modified Chaum-Pedersen Proving System}\n\\label{app:chaum}\n\nThe proving system is a tuple of algorithms $(\\text{ChaumProve},\\text{ChaumVerify})$ for the following relation:\n$$\\left\\{ pp_{\\text{chaum}}, S, T \\in \\G ; (x, y, z) \\in \\F : S = xF + yG + zH, U = xT + yG \\right\\}$$\n\nThe protocol proceeds as follows:\n\\begin{enumerate}\n    \\item The prover selects random $r,s,t \\in \\F$.\n    It computes $$(A_1, A_2, A_3) := (rF + sG, rT + sG, tH)$$ and sends these values to the verifier.\n    \\item The verifier selects a random challenge $c \\in \\F$ and sends it to the prover.\n    \\item The prover computes responses $$(t_1, t_2, t_3) := (r + cx, s + cy, t + cz)$$ and sends these values to the verifier.\n    \\item The verifier accepts the proof if and only if $$A_1 + A_3 + cS = t_1 F + t_2 G + t_3 H$$ and $$A_2 + cU = t_1 T + t_2 G.$$\n\\end{enumerate}\n\nWe now prove that the protocol is complete, special sound, and special honest-verifier zero knowledge.\n\n\\begin{proof}\nCompleteness of this protocol follows trivially by inspection.\n\nTo show the protocol is special honest-verifier zero knowledge, we construct a valid simulator producing transcripts identically distributed to those of valid proofs.\nThe simulator chooses a random challenge $c \\in \\F$, random scalar values $t_1, t_2, t_3 \\in \\F$, and a random value $A_1 \\in \\G$.\nIt sets $A_2 := t_1 T + t_2 H - cU$ and $A_3 := t_1 F + t_2 G + t_3 H - cS - A_1$.\nSuch a transcript will be accepted by an honest verifier.\nObserve that all transcript elements in a valid proof are independently distributed uniformly at random if the generators $F,G,H,U$ are independent, as are transcript elements produced by the simulator.\n\nTo show the protocol is special sound, consider two accepting transcripts with distinct challenge values $c \\neq c' \\in \\F$:\n$$(A_1, A_2, A_3, c, t_1, t_2, t_3)$$\nand\n$$(A_1, A_2, A_3, c', t'_1, t'_2, t'_3)$$\nThe first verification equation applied to the two transcripts implies that $$(c - c')S = (t_1 - t'_1)F + (t_2 - t'_2)G + (t_3 - t'_3)H,$$ so we extract the witness values $x := (t_1 - t'_1)/(c - c')$ and $y := (t_2 - t'_2)/(c - c')$ and $z := (t_3 - t'_3)/(c - c')$, or a nontrivial discrete logarithm relation between $F,G,H$ (a contradiction if these generators are independent).\nSimilarly, the second verification equation implies that $$(c - c')U = (t_1 - t'_1)T + (t_2 - t'_2)G,$$ yielding the same values for $x$ and $y$ as required.\n\nThis completes the proof.\n\\end{proof}\n\n\n\\section{Parallel One-out-of-Many Proving System}\n\\label{app:parallel}\n\nThe proving system itself is a tuple of algorithms $(\\text{ParProve},\\text{ParVerify})$ for the following relation, where we let $N = n^m$:\n\\begin{multline*}\n\\left\\{ pp_{\\text{par}}, \\{S_i,V_i\\}_{i=0}^{N-1} \\subset \\G^2 ; l \\in \\mathbb{N}, (s,v) \\in \\F : \\right. \\\\\n\\left. 0 \\leq l < N, S_l = \\com(0,s), V_l = \\com(0,v) \\right\\}\n\\end{multline*}\n\nThe protocol is shown in Figure \\ref{fig:groth}, where we use the notation of \\cite{lelantus}.\n\n\\begin{figure}\n\\centering\n\\begin{math}\n\\begin{array}{@{}l@{}c@{}l@{}}\n\\displaystyle \\text{ParProve}\\left(pp_{\\text{par}}, \\{S_i, V_i\\}_{i=0}^{N-1}; (l,s,v)\\right) && \\text{ParVerify}\\left(pp_{\\text{par}}, \\{S_i, V_i\\}_{i=0}^{N-1}\\right) \\\\\\\\\n\\text{Compute:} && \\text{Accept if and only if:}\\\\\nr_A, r_B, r_C, r_D, \\{a_{j,i}\\}_{j=0,i=1}^{m-1,n-1} \\gets_R \\F\\\\\n\\forall j \\in [0,m) \\\\\n\\qquad a_{j,0} = -\\sum _{i=1}^{n-1}a_{j,i}\\\\\\\\\nA \\equiv \\com(\\{a_{j,i}\\}_{j,i=0}^{m-1,n-1}, r_A) \\\\\nB \\equiv \\com(\\{\\sigma_{l_{j},i}\\}_{j,i=0}^{m-1,n-1}, r_B) \\\\\nC \\equiv \\\\ \\quad \\com(\\lbrace a_{j,i}(1-2\\sigma_{l_j,i})\\rbrace_{j,i=0}^{m-1,n-1}, r_C) \\\\\nD \\equiv \\com(\\{-a_{j,i}^2\\}_{j,i=0}^{m-1,n-1}, r_D) \\\\\\\\\n\\forall j \\in [0,m) &    \\\\\n\\qquad \\rho^S_j, \\rho^V_j \\gets_R \\F &\\\\\\\\\n\n\\qquad G^V_j \\equiv \\sum_{i=0}^{N-1}p_{i,j}V_i + \\com(0, \\rho^V_j )    &  A,B,C,D, & \\\\\n\\qquad G^S_j \\equiv \\sum_{i=0}^{N-1}p_{i,j}S_i + \\com(0, \\rho^S_j)& \\lbrace G^S_j, G^V_j \\rbrace_{j=0}^{m-1} \\\\\n\\qquad \\qquad \\text{(computing } p_{i,j}  & \\xrightarrow{\\qquad \\qquad \\qquad} & A, B, C, D, \\{G^S_j, G^V_j\\}_{j=0}^{m-1} \\in \\G \\\\\n\\qquad \\qquad \\text{ as in the orig. paper) } \\\\\n\n\n\\forall j \\in [0,m), i \\in [1,n) & \\xleftarrow{x \\gets \\lbrace 0,1 \\rbrace^\\lambda} &  \\\\\n\\qquad f_{j,i} \\equiv \\sigma_{l_{j}i}x + a_{j,i} &&  \\\\\nz_A = r_B x + r_A & \\\\\nz_C = r_C x + r_D & \\{f_{j,i}\\}_{j=0,i=1}^{m-1,n-1}\\\\\nz_S = sx^m -  \\sum_{j=0}^{m-1}\\rho^S_j x^j & z_A, z_C, z_S, z_V & \\lbrace f_{j,i}\\rbrace_{j,i =0,1}^{m-1,n-1} \\in \\F \\\\\nz_V = vx^m - \\sum_{j=0}^{m-1}\\rho^V_h x^j &\\xrightarrow{ \\qquad \\qquad } & z_A, z_C, z_V, z_R \\in \\F  \\\\\n\n&& \\forall j: f_{j,0} := x - \\sum_{i=0}^{n-1} f_{j,i} \\\\\\\\\n&& D+xC =  \\\\\n&& \\com( \\lbrace f_{j,i}(x - f_{j,i})\\rbrace_{j,i=0}^{m-1,n-1}; z_C) \\\\\n&& A+xB =  \\\\\n&& \\com( \\lbrace f_{j,i} \\rbrace_{j,i=0}^{m-1,n-1};z_A) \\\\\\\\\n&& \\sum_{i=0}^{N-1}\\overline{f}_i S_i - \\sum_{j=0}^{m-1} x^j G^S_j \\\\\n&& \\qquad \\qquad = \\com(0, z_S) \\\\\n& & \\sum_{i=0}^{N-1}\\overline{f}_i V_i - \\sum_{j=0}^{m-1} x^j G^V_j \\\\\n& & \\qquad \\qquad = \\com(0, z_V) \\\\\n&&  \\text{where } \\overline{f}_i \\equiv \\prod_{j=0}^{m-1} f_{j,i_j}\n\\end{array}\n\\end{math}\n\\caption{Parallel one-out-of-many protocol}\n\\label{fig:groth}\n\\end{figure}\n\nThis protocol is complete, special sound, and special honest-verifier zero knowledge; the proof is essentially the same as in the original construction, with only minor straightforward modifications.\n\n\n\\section{Payment System Security}\n \nZerocash \\cite{zerocash} established a robust security framework for decentralized anonymous payment (DAP) scheme security that captures a realistic threat model with powerful adversaries who are permitted to add malicious coins into transactions' input ambiguity sets, control the choice of transaction inputs, and produce arbitrary transactions to add to a ledger.\nHere we formally prove Spark's security within a related (but modified) security model; proofs follow somewhat similarly to that of \\cite{zerocash}.\n\nWe recall the security definition for a DAP scheme $$\\Pi = (\\text{Setup}, \\text{CreateAddress}, \\text{Mint}, \\text{Spend}, \\text{Recover}, \\text{Verify}),$$ which is secure if it satisfies definitions for ledger indistinguishability, transaction non-malleability, and balance security properties, which we define below.\n\nEach security property is formalized as a game between a polynomial-time adversary $\\mathcal{A}$ and a challenger $\\mathcal{C}$, where in each game the behavior of honest parties is simulated via an oracle $\\mathcal{O}^{DAP}$.\nThe oracle $\\mathcal{O}^{DAP}$ maintains a ledger $L$ of transactions and provides an interface for executing \\text{CreateAddress}, \\text{Mint}, and \\text{Spend} algorithm operations for honest parties.\nTo simulate behavior from honest parties, $\\mathcal{A}$ passes a query to $\\mathcal{C}$, which makes sanity checks and then proxies the queries to $\\mathcal{O}^{DAP}$, returning the responses to $\\mathcal{A}$ as needed.\nFor \\text{CreateAddress} queries, $\\mathcal{C}$ runs the \\text{CreateAddress} protocol algorithm and returns the public address $\\addr_{pk}$ to $\\mathcal{A}$.\nFor \\text{Mint} queries, the adversary specifies the value and destination public address for the transaction, and the resulting transaction is produced and returned by $\\mathcal{C}$ if valid.\nFor \\text{Spend} queries, the adversary specifies the input coins to be consumed, as well as the values and destination public addresses for the transaction, and the resulting transaction is produced (after $\\mathcal{C}$ recovers the consumed coins) and returned by $\\mathcal{C}$ if valid.\nThe oracle $\\mathcal{O}^{DAP}$ also provides an \\text{Insert} query that allows the adversary to insert arbitrary and potentially malicious $\\text{tx}_{\\text{mint}}$ or $\\text{tx}_{\\text{spend}}$ transactions to the ledger $L$, provided they are valid.\n\nFor each security property, we say the DAP satisfies the property if the adversary can win the corresponding game with only negligible probability.\n\n\\begin{remark}\nWe also require the DAP scheme to be complete, which implies that any unspent coin (with unique partial serial number commitment opening $(s,r,-)$ on the ledger can be spent.\nThis property means that if the coin appears on the ledger $L$ as an output of a transaction, but its corresponding tag is not revealed in any valid transaction, then a user in possession of the corresponding address spend key can generate a valid $\\text{Spend}$ transaction consuming it.\n\nNote that if the spend key holder cannot produce such a valid transaction, by construction the coin's tag must already appear in a previous valid transaction.\nSuch a previous valid transaction must have a modified Chaum-Pedersen proof that extracts, in part, the address's private spend key $r$, a contradiction since the adversary has only a negligible advantage in discrete logarithm extraction.\n\\end{remark}\n\n\n\\subsection{Balance}\n\nBalance requires that no bounded adversary $\\mathcal{A}$ can control more coins than are minted or spent to it.\nIt is formalized by a \\textbf{BAL} game.\nThe adversary $\\mathcal{A}$ adaptively interacts with $\\mathcal{C}$ and the oracle with queries, and at the end of the interaction outputs a set of coins $\\text{AdvCoins}$.\nLetting $\\text{ADDR}$ be set of all addresses of honest users generated by \\text{CreateAddress} queries, $\\mathcal{A}$ wins the game if\n$$v_{\\text{unspent}} + v_{\\mathcal{A} \\to \\text{ADDR}} > v_{\\text{mint}} + v_{\\text{ADDR} \\to \\mathcal{A}},$$\nwhich implies that the total value the adversary can spend or has spent already is greater than the value it has minted or received.\nHere:\n\\begin{itemize}\n    \\item $v_{\\text{unspent}}$ is the total value of unspent coins in $\\text{AdvCoins}$;\n    \\item $v_{\\text{mint}}$ is the total value minted by $\\mathcal{A}$ to itself through \\text{Mint} or \\text{Insert} queries;\n    \\item $v_{\\text{ADDR} \\xrightarrow{} \\mathcal{A}}$ is the total value of coins received by $\\mathcal{A}$ from addresses in \\text{ADDR}; and\n    \\item $v_{\\mathcal{A} \\xrightarrow{} \\text{ADDR}}$ is the total value of coins sent by the adversary to the addresses in \\text{ADDR}.\n\\end{itemize}\nWe say a DAP scheme $\\Pi$ is \\textbf{BAL}-secure if the adversary $\\mathcal{A}$ wins the game \\textbf{BAL} only with negligible probability:\n$$\\text{Pr}[\\text{\\textbf{BAL}}(\\Pi, \\mathcal{A}, \\lambda) = 1] \\leq \\text{negl}(\\lambda)$$\n\nAssume the challenger maintains an extra augmented ledger $(L, \\vec{a})$ where each $a_i$ contains secret data from transaction $\\text{tx}_i$ in $L$.\nIn that case where $\\text{tx}_i$ was produced by a query from $\\mathcal{A}$ to the challenger $\\mathcal{C}$, $a_i$ contains all secret data used by $\\mathcal{C}$ to produce the transaction.\nIf instead $\\text{tx}_i$ was produced by a direct $\\text{Insert}$ query from $\\mathcal{A}$, $a_i$ consists of all extracted witness data from proofs contained in the transaction.\nThe resulting augmented ledger $(L, \\vec{a})$ is balanced if the following conditions are true:\n\\begin{enumerate}\n    \\item\\label{cond:distinct} Each valid spend transaction $\\text{tx}_{\\text{spend},k}$ in $(L, \\vec{a})$ consumes distinct coins, and each consumed coin is the output of a valid $\\text{tx}_{\\text{mint},i}$ or $\\text{tx}_{\\text{spend},j}$ transaction for some $i < k$ or $j < k$.\n    This requirement implies that all transactions spend only valid coins, and that no coin is spent more than once within the same valid transaction.\n    \n    \\item\\label{cond:multiple} No two valid spend transactions in $(L, \\vec{a})$ consume the same coin.\n    This implies no coin is spent through two different transactions.\n    Together with the first requirement, this implies that each coin is spent at most once.\n    \n    \\item\\label{cond:value} For each $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ consuming input coins with value commitments $\\{C_u\\}_{u=0}^{w-1}$, for each $u \\in [0,w)$:\n    \\begin{itemize}\n        \\item If $C_u$ is the output of a valid \\text{Mint} transaction with augmented ledger witness $a'$, then the value of $C_u$ contained in $a'$ is the same as the corresponding value contained in $a$ for the value commitment offset $C_u'$.\n        \\item If $C_u$ is the output of a valid \\text{Spend} transaction with augmented ledger witness $a'$, then the value of $C_u$ contained in $a'$ is the same as the corresponding value contained in $a$ for the value commitment offset $C_u'$.\n    \\end{itemize}\n    This implies that values are maintained between transactions.\n    \n    \\item\\label{cond:balance} For each $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ with fee $f$ that consumes input coins with value commitment offsets $\\{C_u'\\}_{u=0}^{w-1}$ and generates coins with value commitments $\\{\\overline{C}_j\\}_{j=0}^{t-1}$, $a$ contains values $\\{v_u\\}_{u=0}^{w-1}$ and $\\{\\overline{v}_j\\}_{j=0}^{t-1}$ corresponding to the commitments such that the balance equation\n    $$\\sum_{u=0}^{w-1} v_u = \\sum_{j=0}^{t-1} \\overline{v}_j + f$$\n    holds.\n    For each $(\\text{tx}_{\\text{mint}}, a)$ in $(L, \\vec{a})$ with public value $v$ that generates a coin with value commitment $C$, $a$ contains a value $v'$ corresponding to the commitment such that $v = v'$.\n    This implies that values cannot be created arbitrarily.\n    \n    \\item\\label{cond:honest} For each $\\text{tx}_{\\text{spend}}$ in $(L, \\vec{a})$ inserted by $\\mathcal{A}$ through an \\text{Insert} query, each consumed coin in $\\text{tx}_{\\text{spend}}$ is not recoverable by any address in $\\text{ADDR}$.\n    This implies that the adversary cannot generate a transaction consuming coins it does not control.\n\\end{enumerate}\nIf these five conditions hold, then $\\mathcal{A}$ did not spend or control more money than was previously minted or spent to it, and the inequality\n$$v_{\\text{mint}} + v_{\\text{ADDR} \\to \\mathcal{A}} \\leq v_{\\text{unspent}} + v_{\\mathcal{A} \\to \\text{ADDR}}$$\nholds.\nWe now prove that Spark is \\textbf{BAL}-secure under this definition.\n\n\\begin{proof}\nBy way of contradiction, assume the adversary $\\mathcal{A}$ interacts with $\\mathcal{C}$ leading to a non-balanced augmented ledger $(L, \\vec{a})$ with non-negligible probability; then at least one of the five conditions described above is violated with non-negligible probability:\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:distinct}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition 1 is non-negligible.\nEach $\\text{tx}_{\\text{spend}}$ generated by a non-$\\text{Insert}$ oracle query satisfies this condition already, so there must exist a transaction $(\\text{tx}_{\\text{spend}}, a)$ in $(L, \\vec{a})$ inserted by $\\mathcal{A}$.\n\nSuppose there exist inputs $u_1,u_2 \\in [0,w)$ of $\\text{tx}_{\\text{spend}}$ that consume the same coin; that is, reveal the same partial opening $(s,r,-)$ of coin serial number commitments.\nValidity of the modified Chaum-Pedersen proofs $(\\Pi_{\\text{chaum}})_{u_1}$ and $(\\Pi_{\\text{chaum}})_{u_2}$ for these inputs gives extracted openings $S_{u_1}' = s_{u_1} F + r_{u_1} G + y_{u_1} H$ and $S_{u_2}' = s_{u_2} F + r_{u_2} G + y_{u_2} H$ and tag representations such that $U = s_{u_1} T_{u_1} + r_{u_1} G$ and $U = s_{u_2} T_{u_2} + r_{u_2} G$.\nBecause transaction validity implies $T_{u_1} \\neq T_{u_2}$, we must have $(s_{u_1},r_{u_1}) \\neq (s_{u_2},r_{u_2})$.\nValidity of the corresponding parallel one-out-of-many proofs $(\\Pi_{\\text{par}})_{u_1}$ and $(\\Pi_{\\text{par}})_{u_2}$ yields indices (corresponding to input set group elements $S_1$ and $S_2$) and discrete logarithm extractions such that $S_1 - S_{u_1}' = x_{u_1} H$ and $S_2 - S_{u_2}' = x_{u_2} H$.\nThis means\n$$S_1 = \\dcom(s_{u_1},r_{u_1},x_{u_1}+y_{u_1})$$\nand\n$$S_2 = \\dcom(s_{u_2},r_{u_2},x_{u_2}+y_{u_2})$$\nwhich contradicts the assumption of unique partial openings for consumed coin serial number commitments.\n\nThe second possibility for violation of the condition is that the transaction $\\text{tx}_{\\text{spend}}$ consumes a coin that is not generated in any previous valid transaction.\nValidity of the modified Chaum-Pedersen proof for such an input gives a tag representation $U = sT + rG$ and serial number commitment offset $S' = sF + rG + yH$.\nValidity of the parallel one-out-of-many proof for the input gives an index $l$ such that $S_l - S' = xH$, meaning $S_l = sF + rG + (x + y)H$ is an opening of this commitment.\nBecause transaction validity requires all input ambiguity set elements to be produced in previous valid transactions as valid commitments, the adversary knows an opening of such a commitment, which is a contradiction.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:multiple}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:multiple} is non-negligible.\nThis means the augmented ledger $(L, \\vec{a})$ contains two valid \\text{Spend} transactions consuming the same coin but producing distinct tags.\nSimilarly to the previous argument, this implies distinct openings of the coin serial number commitment, which is a contradiction.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:value}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:value} is non-negligible.\nLet $C$ be the value commitment of the coin consumed by an input of $\\text{tx}_{\\text{spend}}$ and generated in a previous transaction (of either type) in $(L, \\vec{a})$.\nSince the generating transaction is valid, we have an extracted opening $C = vG + aH$ from either the balance proof (in a \\text{Mint} transasction) or the range proof (in a \\text{Spend} transaction).\nValidity of the corresponding parallel one-out-of-many proof in $\\text{tx}_{\\text{spend}}$ gives an extracted discrete logarithm $C - C' = xH$, where $C'$ is the input's value commitment offset.\nBut this immediately gives $C' = vG + (a - x)H$, a contradiction since the commitment scheme is binding.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:balance}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:balance} is non-negligible.\nIf the augmented ledger $(L, \\vec{a})$ contains a \\text{Spend} transaction that violates the balance equation, this immediately implies a break in the commitment binding property since the corresponding balance proof $\\Pi_{\\text{bal}}$ is valid, which is a contradiction.\nIf instead the augmented ledger $(L, \\vec{a})$ contains a \\text{Mint} transaction that violates the balance requirement, this immediately implies a break in the commitment binding property since the corresponding balance proof $\\Pi_{\\text{bal}}$ is valid, again a contradiction.\n\n\\textbf{$\\mathcal{A}$ violates Condition \\ref{cond:honest}:} Suppose that the probability $\\mathcal{A}$ wins the game violating Condition \\ref{cond:honest} is non-negligible.\nThat is, $\\mathcal{A}$ produces a \\text{Spend} transaction $\\text{tx}_{\\text{spend}}$ by an \\text{Insert} question that is valid on the augmented ledger $(L, \\vec{a})$ and consumes a coin corresponding to a coin serial number commitment $S$ that can be recovered by a public address $(Q_1, Q_2) \\in \\text{ADDR}$.\n\nValidity of the Chaum-Pedersen proof corresponding to this input of $\\text{tx}_{\\text{spend}}$ yields an extracted representation $S' = s'F + r'G + yH$.\nValidity of the corresponding parallel one-of-many proof gives a serial number commitment $S$ and extraction such that $S - S' = xH$, so $S = s'F + r'G + (x + y)H$.\n\nNow let $(s_1,s_2,r)$ be the secret key corresponding to the address $(Q_1,Q_2)$.\nSince $\\text{tx}_{\\text{spend}}$ consumes a coin recoverable by this address, a serial number commitment for the recovered coin is\n\\begin{align*}\n\\overline{S} &= \\hash_{\\text{ser}}(s_1 K, Q_1, Q_2)F + Q_2 \\\\\n&= (\\hash_{\\text{ser}}(s_1 K, Q_1, Q_2) + s_2)F + rG\n\\end{align*}\nfor recovery key $K$.\n\nSince the commitment scheme is binding, we must therefore have $r' = r$, which is a contradiction since $\\mathcal{A}$ cannot extract this discrete logarithm from the public address.\n\nThis completes the proof.\n\\end{proof}\n\n\n\\subsection{Transaction Non-Malleability}\n\nThis property requires that no bounded adversary can substantively alter a valid transaction. \nIn particular, non-malleability prevents malicious adversaries from modifying honest users' transactions by altering data or redirecting the outputs of a valid transaction before the transaction is added to the ledger.\nSince non-malleability of \\text{Mint} transactions is offloaded to authorizations relating to consensus rules or base-layer operations, we need only consider the case of \\text{Spend} transactions.\n\nThis property is formalized by an experiment \\textbf{TR-NM}, in which a bounded adversary $\\mathcal{A}$ adaptively interacts with the oracle $\\mathcal{O}^{\\text{DAP}}$, and then outputs a spend transaction $\\text{tx}'$.\nIf we let $T$ denote the set of all transactions produced by \\text{Spend} queries to $\\mathcal{O}^{\\text{DAP}}$, and $L$ denote the final ledger, $\\mathcal{A}$ wins the game if there exists $\\text{tx} \\in T$ such that:\n\\begin{itemize}\n    \\item $\\text{tx}' \\neq \\text{tx}$; \n    \\item $\\text{tx}'$ reveals a tag also revealed by $\\text{tx}$; and\n    \\item both $\\text{tx}'$ and $\\text{tx}$ are valid transactions with respect to the ledger $L^{\\prime}$ containing all transactions preceding $\\text{tx}$ on $L$.\n\\end{itemize}\n\nWe say a DAP scheme $\\Pi$ is \\textbf{TR-NM}-secure if the adversary $\\mathcal{A}$ wins the game \\textbf{TR-NM} only with negligible probability:\n$$\\text{Pr}[\\text{\\textbf{TR-NM}}(\\Pi, \\mathcal{A}, \\lambda) = 1] \\leq \\text{negl}(\\lambda)$$\n\nLet $\\mathcal{T}$ be the set of all $\\text{tx}_{\\text{spend}}$ transactions generated by the $\\mathcal{O}^{DAP}$ in response to $\\text{Spend}$ queries.\nSince these transactions are generated by these oracle queries, $\\mathcal{A}$ does not learn any secret data used to produce these transactions.\n\n\\begin{proof}\nAssume that the adversary $\\mathcal{A}$ wins the game with non-negligible probability.\nThat is, $\\mathcal{A}$ produces a transaction $\\text{tx}'$ revealing a tag $T$ also revealed in a transaction $\\text{tx}$.\nWithout loss of generality, assume each transaction consumes a single coin.\n\nObserve that a valid \\text{Spend} binds all transaction elements except for modified Chaum-Pedersen proofs into each such proof via $\\hash_{\\text{bind}}$ and the proof transcripts.\nTherefore, in order to produce valid $\\text{tx}' \\neq \\text{tx}$, we consider two cases:\n\\begin{itemize}\n    \\item the modified Chaum-Pedersen proofs are identical, but $\\text{tx}'$ and $\\text{tx}$ differ in another element of the transaction structures; or\n    \\item the modified Chaum-Pedersen proof in $\\text{tx}'$ is distinct from the proof in $\\text{tx}$.\n\\end{itemize}\n\nIn the first case, at least one input to the binding hash $\\hash_{\\text{bind}}$ used to initialize the modified Chaum-Pedersen transcripts must differ between the proofs.\nBecause we model this hash function as a random oracle, the outputs differ except with negligible probability, a contradiction since the resulting proof structures must be identical.\n\nIn the second case, suppose that the modified Chaum-Pedersen proof $\\Pi_{\\text{chaum}}'$ contained in $\\text{tx}'$ yields extraction $(s',r',y')$, and that the proof $\\Pi_{\\text{chaum}}$ contained in $\\text{tx}$ yields $(s,r,y)$.\nSince the corresponding tags are identical, we must have $s' = s$ and $r' = r$.\nAny serial number commitment $S$ with a partial opening $(s,r,-)$ consumed in $\\text{tx}$ was generated such that $r$ is a spend key component of the controlling public address $(Q_1,Q_2)$.\nSince $\\mathcal{A}$ does not control this address, it cannot produce $r$ without extracting from $S$ or the $(Q_1,Q_2)$, which implies a non-negligible discrete logarithm advantage, a contradiction.\n\\end{proof}\n\n\n\\subsection{Ledger Indistinguishability}\n\nThis property implies that no bounded adversary $\\mathcal{A}$ received any information from the ledger except what is already publicly revealed, even if it can influence valid ledger operations by honest users.\n\nLedger indistinguishability is formalized through an experiment \\textbf{L-IND} between a bounded adversary $\\mathcal{A}$ and a challenger $\\mathcal{C}$, which terminates with a binary output $b^{\\prime}$ by $\\mathcal{A}$.\nAt the beginning of the experiment, $\\mathcal{C}$ samples $\\text{Setup}(1^\\lambda) \\to pp$ and sends the parameters to $\\mathcal{A}$; next it samples a random bit $b \\in \\lbrace 0,1 \\rbrace$ and initializes two separate DAP oracles $\\mathcal{O}_0^{DAP}$ and $\\mathcal{O}_1^{DAP}$, each with its own separate ledger and internal state.\nAt each consecutive step of the experiment:\n\\begin{enumerate}\n\\item $\\mathcal{C}$ provides $\\mathcal{A}$ two ledgers $(L_{\\text{left}} = L_b, L_{\\text{right}} = L_{1-b})$ where $L_b$ and $L_{1-b}$ are the current ledgers of the oracles $\\mathcal{O}_b^{DAP}$ and $\\mathcal{O}_{1-b}^{DAP}$ respectively. \n\\item $\\mathcal{A}$ sends to $\\mathcal{C}$ two queries $Q, Q^{\\prime}$ of the same type (one of \\text{CreateAddress}, \\text{Mint}, \\text{Spend}, \\text{Recover}, or \\text{Insert}). \n\\begin{itemize}\n    \\item If the query type is \\text{Insert} or \\text{Mint}, $\\mathcal{C}$ forwards $Q$ to $L_{b}$ and $Q^\\prime$ to $L_{1-b}$, permitting $\\mathcal{A}$ to insert its own transactions or mint new coins to $L_{\\text{left}}$ and $L_{\\text{right}}$.\n    \\item For all queries of type \\text{CreateAddress}, \\text{Spend}, or \\text{Recover}, $\\mathcal{C}$ first checks if the two queries $Q$ and $Q^\\prime$ are publicly consistent, and then forwards $Q$ to $\\mathcal{O}_0^{DAP}$ and $Q^\\prime$ to $\\mathcal{O}_1^{DAP}$.\n    It receives the two oracle answers $(a_0,a_1)$, but returns $(a_b,a_{1-b})$ to $\\mathcal{A}$.\n\\end{itemize}\n\\end{enumerate}\nAs the adversary does not know the bit $b$ and the mapping between $(L_{\\text{left}}, L_{\\text{right}})$ and $(L_0, L_1)$, it cannot learn weather it affects the behavior of honest parties on $(L_0, L_1)$ or on $(L_1, L_0)$.\nAt the end of the experiment, $\\mathcal{A}$ sends $\\mathcal{C}$ a bit $b^\\prime \\in \\lbrace 0,1 \\rbrace$.\nThe challenger outputs $\\mathcal{C}$ outputs 1 if $b = b^\\prime$, and 0 otherwise.\n\nWe require the queries $Q$ and $Q^\\prime$ be publicly consistent as follows: if the query type of $Q$ and $Q^\\prime$ is \\text{Recover}, they are publicly consistent by construction.\nIf the query type of $Q$ and $Q^\\prime$ is \\text{CreateAddress}, both oracles generate the same address.\nIf the query type of $Q$ and $Q^\\prime$ is \\text{Mint}, the minted values of both queries must be equal.\nIf the query type of $Q$ and $Q^\\prime$ is \\text{Spend}, then:\n\\begin{itemize}\n    \\item Both $Q$ and $Q^\\prime$ must be well-formed and valid, so the referenced input coins must have been generated in a previous transaction on the ledger and be unspent.\n    Further, the transaction must balance.\n    \\item The number of spent coins and output coins must be the same in $Q$ and $Q^\\prime$.\n    \\item If a consumed coin in $Q$ references a coin in $L_0$ posted by $\\mathcal{A}$ through an \\text{Insert} query, then the corresponding index in $Q^\\prime$ must also reference a coin in $L_1$ posted by $\\mathcal{A}$ through an \\text{Insert} query and the values of these two coins must be equal as well (and vice versa for $Q^\\prime$). \n    \\item If an output coin referenced by $Q$ does not reference a recipient address in the oracle \\text{ADDR} list (and therefore is controlled by $\\mathcal{A}$), then the corresponding value must equal that of the corresponding coin referenced by $Q$ at the same index (and vice versa for $Q^\\prime$).\n\\end{itemize}\n\nWe say a DAP scheme $\\Pi$ is $\\textbf{L-IND}$-secure if $\\mathcal{A}$ wins the game \\textbf{L-IND} only probability at most negligibly better than chance:\n$$\\text{Pr}[\\text{\\textbf{L-IND}}(\\Pi, \\mathcal{A}, \\lambda) = 1] - \\frac{1}{2} \\leq \\text{negl}(\\lambda)$$\n\n\\begin{proof}\nIn order to prove that $\\mathcal{A}$'s advantage in the \\textbf{L-IND} experiment is negligible, we first consider a simulation experiment $\\mathcal{D}^{\\text{sim}}$, in which $\\mathcal{A}$ interacts with $\\mathcal{C}$ as in the L-IND experiment, but with modifications.\n\n\\textbf{The simulation experiment $\\mathcal{D}^{\\text{sim}}$}: Since the parallel one-out-of-many, modified Chaum-Pedersen, representation, and range proving systems are all special honest-verifier zero knowledge, we can take advantage of the simulator for each.\nGiven input statements and verifier challenges, each proving system's simulator produces transcripts indistinguishable from honest proofs.\nAdditionally, we now define the behavior of the full simulator.\n\n\\textbf{The simulation.} The simulation $\\mathcal{D}^{\\text{sim}}$ works as follows.\nAs in the original experiment, $\\mathcal{C}$ samples the system parameters $\\text{Setup}(1^\\lambda) \\to pp$ and a random bit $b$, and initializes DAP oracles $\\mathcal{O}^{\\text{DAP}}_0$ and $\\mathcal{O}^{\\text{DAP}}_1$.\nThen $\\mathcal{D}^{\\text{sim}}$ proceeds in steps.\nAt each step, it provides $\\mathcal{A}$ with ledgers $L_{\\text{\\text{left}}} = L_{b}$ and $L_{\\text{\\text{right}}} = L_{1-b}$,after which $\\mathcal{A}$ sends two publicly-consistent queries $(Q, Q^\\prime)$ of the same type.\nRecall that the queries $Q$ and $Q^\\prime$ are consistent with respect to public data and information related to the addresses controlled by $\\mathcal{A}$.\nDepending on the query type, the challenger acts as follows:\n\\begin{itemize}\n    \\item Answering \\text{Recover} and \\text{Insert} queries: The challenger proceeds as in the original \\textbf{L-IND} experiment.\n    \\item Answering \\text{CreateAddress} queries: In this case the challenger replaces the public address components $Q_1$ and $Q_2$ with random strings of the appropriate lengths, producing $\\text{addr}_{pk}$ that is returned to $\\mathcal{A}$.\n    \\item Answering \\text{Mint} queries: The challenger does the following to answer $Q$ and $Q^\\prime$ separately:\n    \\begin{enumerate}\n        \\item If $\\mathcal{A}$ provided a public address $\\addr_{\\text{pk}}$ not generated by the challenger, it produces a coin using \\text{CreateCoin} as usual.\n        \\item Otherwise, it simulates coin generation:\n        \\begin{enumerate}\n            \\item Samples a recovery key $K$ uniformly at random.\n            \\item Samples a serial number commitment $S$ uniformly at random.\n            \\item Samples a value commitment $C$ uniformly at random.\n            \\item Samples a random input used to produce a symmetric encryption key $\\text{AEADKeyGen} \\to k_{\\text{enc}}$.\n            \\item Simulates the memo encryption by selecting random $\\widetilde{m}$ of the proper length, and encrypting it to produce $$\\text{AEADEncrypt}(k_{\\text{enc}},\\texttt{memo},\\widetilde{m}) \\to \\overline{m}.$$\n        \\end{enumerate}\n        \\item Simulates the balance proof $\\Pi_{\\text{bal}}$ on the statement $(C - \\com(v,0))$.\n        \\item Assembles the transaction and adds it to the ledger as appropriate.\n    \\end{enumerate}\n    \\item Answering \\text{Spend} queries: The challenger does the following to answer $Q$ and $Q^\\prime$ separately, where $w$ is the number of consumed coins and $t$ the number of generated coins specified by $\\mathcal{A}$ as part of its queries:\n    \\begin{enumerate}\n        \\item Parse the input cover set serial number commitments and value commitments as $\\text{InCoins} = \\{(S_i, C_i)\\}_{i=0}^{N-1}$.\n        \\item For each $u \\in [0,w)$, where $l_u$ represents the index of the consumed coin in $\\text{InCoins}$:\n        \\begin{enumerate}\n            \\item Samples a tag $T_u$ uniformly at random.\n            \\item Samples a serial number commitment offset $S_u'$ and value commitment offset $C_u'$ uniformly at random.\n            \\item Simulates a parallel one-out-of-many proof $(\\Pi_{\\text{par}})_u$ on the statement $(\\{S_i - S_u', C_i - C_u'\\}_{i=0}^{N-1})$.\n        \\end{enumerate}\n        \\item For each $j \\in [0,t)$:\n        \\begin{enumerate}\n            \\item If $\\mathcal{A}$ provided a public address $\\addr_{\\text{pk}}$ not generated by the challenger, it produces a coin using \\text{CreateCoin} as usual.\n            \\item Otherwise, it simulates coin generation:\n            \\begin{enumerate}\n                \\item Samples a recovery key $K_j$ uniformly at random.\n                \\item Samples a serial number commitment $S_j$ uniformly at random.\n                \\item Samples a value commitment $\\overline{C}_j$ uniformly at random.\n                \\item Samples a random input used to produce a symmetric encryption key $\\text{AEADKeyGen} \\to k_{\\text{enc}}$.\n                \\item Simulates the value encryption by selecting random $\\widetilde{v}$ of the proper length, and encrypting it to produce $$\\text{AEADEncrypt}(k_{\\text{enc}},\\texttt{val},\\widetilde{v}) \\to \\overline{v}_j.$$\n                \\item Simulates the memo encryption by selecting random $\\widetilde{m}$ of the proper length, and encrypting it to produce $$\\text{AEADEncrypt}(k_{\\text{enc}},\\texttt{memo},\\widetilde{m}) \\to \\overline{m}_j.$$\n                \\item Simulates a range proof $(\\Pi_{\\text{rp}})_j$ on the statement $(\\overline{C}_j)$.\n            \\end{enumerate}\n        \\end{enumerate}\n        \\item Simulates the balance proof $\\Pi_{\\text{bal}}$ on the statement $$\\left(\\sum_{u=0}^{w-1} C_u' - \\sum_{j=0}^{t-1} \\overline{C}_j - \\com(f,0)\\right).$$\n        \\item For each $u \\in [0,w)$, computes the binding hash $\\mu$ as defined and simulates a modified Chaum-Pedersen proof $(\\Pi_{\\text{chaum}})_u$ on the statement $(S_u', T_u)$.\n        \\item Assembles the transaction and adds it to the ledger as appropriate.\n    \\end{enumerate}\n\\end{itemize}\n\nFor experiments defined below, we define $\\text{Adv}^{\\mathcal{D}}$ as the advantage of $\\mathcal{A}$ in some experiment $\\mathcal{D}$ over the original $\\textbf{L-IND}$ game.\nBy definition, all answers sent to $\\mathcal{A}$ in $\\mathcal{D}^{\\text{sim}}$ are computed independently of the bit $b$, so $\\text{Adv}^{\\mathcal{D}^{\\text{sim}}} = 0$. We will prove that $\\mathcal{A}$'s advantage in the real L-IND experiment $\\mathcal{D}^{\\text{real}}$ is at most negligibly different than $\\mathcal{A}$'s advantage in $\\mathcal{D}^{\\text{sim}}$.\nTo show this, we construct intermediate experiments in which $\\mathcal{C}$ performs a specific modification of $\\mathcal{D}^{\\text{real}}$ against $\\mathcal{A}$.\n\n\\textbf{Experiment $\\mathcal{D}_1$}: This experiment modifies $\\mathcal{D}^{\\text{real}}$ by simulating all one-out-of-many proofs, range proofs, representation proofs, and modified Chaum-Pedersen proofs.\nAs all these protocols are special honest-verifier zero knowledge, the simulated proofs are indistinguishable from the real proofs generated in $\\mathcal{D}^{\\text{real}}$.\nHence $\\text{Adv}^{\\mathcal{D}_1} = 0$.\n\n\\textbf{Experiment $\\mathcal{D}_2$}: This experiment modifies $\\mathcal{D}_{1}$ by replacing all encrypted values and memos in transactions with challenger-generated recipient public addresses with encryptions of random values of appropriate lengths under keys chosen uniformly at random, and by replacing recovery keys with uniformly random values.\nSince the underlying authenticated symmetric encryption scheme is IND-CCA and IK-CCA secure and we assume the decisional Diffie-Hellman problem is hard, the adversarial advantage in distinguishing ledger output in the $\\mathcal{D}_2$ experiment is negligibly different from its advantage in the $\\mathcal{D}_{1}$ experiment.\nHence $\\lvert \\text{Adv}^{\\mathcal{D}_2} - \\text{Adv}^{\\mathcal{D}_1} \\rvert$ is negligible.\n\n\\textbf{Experiment $\\mathcal{D}^{\\text{sim}}$}: The $\\mathcal{D}^{\\text{sim}}$ experiment is formally defined above.\nIn particular, it differs from $\\mathcal{D}_{2}$ by replacing consumed coin tags, serial number commitment offset, and value commitment offsets with uniformly random values; and by replacing output coin serial number and value commitments with random values.\nIn previous experiments (including $\\mathcal{D}^{\\text{real}}$), tags are generated using a pseudorandom function \\cite{dodis}, and the other given values are generated as commitments with masks derived from hash functions modeled as independent random oracles, so the adversarial advantage in distinguishing ledger output in $\\mathcal{D}^{\\text{sim}}$ is negligibly different from its advantage in the $\\mathcal{D}_2$ experiment.\nHence $\\lvert \\text{Adv}^{\\mathcal{D}^{\\text{sim}}} - \\text{Adv}^{\\mathcal{D}_2} \\rvert$ is negligible.\n\nThis shows that the adversary has only negligible advantage in the real $\\textbf{L-IND}$ game over the simulation, where it can do no better than chance, which completes the proof.\n\\end{proof}\n\n\\end{document}\n", "meta": {"hexsha": "089c3eaadd6a7a5b48ecdb200b45b25e3930f0ff", "size": 80042, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "cypherstack/spark-paper", "max_stars_repo_head_hexsha": "4978c4741e1a9d5decd4bcc057df06bb2243009d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "cypherstack/spark-paper", "max_issues_repo_head_hexsha": "4978c4741e1a9d5decd4bcc057df06bb2243009d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "cypherstack/spark-paper", "max_forks_repo_head_hexsha": "4978c4741e1a9d5decd4bcc057df06bb2243009d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-14T20:40:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-14T20:40:45.000Z", "avg_line_length": 81.8425357873, "max_line_length": 568, "alphanum_fraction": 0.7251318058, "num_tokens": 22594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.40854262518534534}}
{"text": "\\lab{Data Structures I: Linked Lists}{Linked Lists}\n\\label{lab:Python_DataStructures}\n\n\\objective{Analyzing and manipulating data are essential skills in scientific computing.\nStoring, retrieving, and rearranging data take time.\nAs a dataset grows, so does the amount of time it takes to access and analyze it.\nTo write effecient algorithms involving large data sets, it is therefore essential to be able to design or choose the data structures that are most optimal for a particular problem.\nIn this lab we begin our study of data structures by constructing a generic linked list, then using it to implement a few common data structures.}\n\n\\section*{Introduction} % =====================================================\n\n\\emph{Data structures} are specialized objects for organizing data efficiently.\nThere are many kinds, each with specific strengths and weaknesses, and different applications require different structures for optimal performance.\nFor example, some data structures take a long time to build, but once built their data are quickly accessible.\nOthers are built quickly, but are not as efficiently accessible.\nThese strengths and weaknesses are determined by how the structure is implemented.\n\nPython has several built-in data structure classes, namely \\li{list}, \\li{set}, \\li{dict}, and \\li{tuple}.\nBeing able to use these structures is important, but selecting the correct data structure to begin with is often what makes or breaks a good program.\nIn this lab we create a structure that mimics the built-in list class, but that has a different underlying implementation.\nThus our class will be better than a plain Python list for some tasks, but worse for others.\n\n\\subsection*{Nodes} % ---------------------------------------------------------\n\nThink of data as several types of objects that need to be stored in a warehouse.\nA \\emph{node} is like a standard size box that can hold all the different types of objects.\nFor example, suppose a particular warehouse stores lamps of various sizes.\nRather than trying to carefully stack lamps of different shapes on top of each other, it is preferable to first put them in boxes of standard size.\nThen adding new boxes and retrieving stored ones becomes much easier.\nA \\emph{data structure} is like the warehouse, which specifies where and how the different boxes are stored.\n\nA node class is usually simple.\nThe data in the node is stored as an attribute.\nOther attributes may be added (or inherited) specific to a particular data structure.\n\n\\begin{problem} % Restricting data types of the Node class.\nConsider the following generic node class.\n\\begin{lstlisting}\nclass Node(object):\n    \"\"\"A basic node class for storing data.\"\"\"\n    def __init__(self, data):\n        \"\"\"Store 'data' in the 'value' attribute.\"\"\"\n        self.value = data\n\\end{lstlisting}\n\nModify the constructor so that it only accepts data of type \\li{int}, \\li{long}, \\li{float}, or \\li{str} (comparable types).\nIf another type of data is given, raise a \\li{TypeError} with an appropriate error message.\nModify the constructor docstring to document these restrictions.\n\\end{problem}\n\n\\begin{info}\nOften the data stored in a node is actually a \\emph{key} value.\nThe key might be a memory address, a dictionary key, or the index of an array where the true desired information resides.\nFor simplicity, in this and the following lab we store actual data in node objects, not references to data located elsewhere.\n\\end{info}\n\n\\section*{Linked Lists} % =====================================================\n\nA \\emph{linked list} is a data structure that chains nodes together.\nEvery linked list needs a reference to the first node in the chain, called the \\li{head}.\nA reference to the last node in the chain, called the \\li{tail}, is also often included.\nEach node instance in the list stores a piece of data, plus at least one reference to another node in the list.\n\nThe nodes of a \\emph{singly linked list} have a single reference to the next node in the list (see Figure \\ref{fig:singly_linked}), while the nodes of a \\emph{doubly linked list} have two references: one for the previous node, and one for the next node in the list (see Figure \\ref{fig:doubly_linked}).\nThis allows for a doubly linked list to be traversed in both directions, whereas a singly linked list can only be traversed in one direction.\n\n\\begin{lstlisting}\nclass LinkedListNode(Node):\n    \"\"\"A node class for doubly linked lists. Inherits from the 'Node' class.\n    Contains references to the next and previous nodes in the linked list.\n    \"\"\"\n    def __init__(self, data):\n        \"\"\"Store 'data' in the 'value' attribute and initialize\n        attributes for the next and previous nodes in the list.\n        \"\"\"\n        Node.__init__(self, data)       # Use inheritance to set self.value.\n        self.<<next>> = None\n        self.prev = None\n\\end{lstlisting}\n\n\\begin{figure} % Singly linked list.\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.5cm,thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.2cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {C};\n    \\node[main node] (4) [right of=3] {D};\n    \\node[draw = none, black!20!blue, node distance=1.5cm] [above left of=1](H) {Head};\n\\foreach \\r in {1, 2, 3, 4}{\n    \\node[rect node][right of=\\r, node distance = .36cm]{};}\n\\node[draw = none, node distance = 1.5cm] [right of=4]{};\n\\foreach \\s/\\t  in {1/2, 2/3, 3/4}{\\path[draw](\\s) edge[shorten <=.1cm](\\t);}\n    \\draw[black!20!blue] (H) edge (1.north);\n\\end{tikzpicture}\n\\caption{A singly linked list. Each node has a reference to the next node in the list. The head attribute is always assigned to the first node.}\n\\label{fig:singly_linked}\n\\end{figure}\n\n\\begin{figure} % Doubly linked list.\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.5cm, thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.9cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {C};\n    \\node[main node] (4) [right of=3] {D};\n    \\node[draw=none, node distance=.07cm] (1up) [above of=1] {};\n    \\node[draw=none, node distance=.07cm] (1dn) [below of=1] {};\n    \\node[draw=none, node distance=.07cm] (2up) [above of=2] {};\n    \\node[draw=none, node distance=.07cm] (2dn) [below of=2] {};\n    \\node[draw=none, node distance=.07cm] (3up) [above of=3] {};\n    \\node[draw=none, node distance=.07cm] (3dn) [below of=3] {};\n    \\node[draw=none, node distance=.07cm] (4up) [above of=4] {};\n    \\node[draw=none, node distance=.07cm] (4dn) [below of=4] {};\n    \\node[draw = none, black!20!blue, node distance = 1.5cm] [above right of=4] (T) {Tail};\n    \\node[draw = none, black!20!blue, node distance = 1.5cm] [above left of=1] (H) {Head};\n    \\node[rect node](1.5)[]{};\n    \\node[rect node](2.5)[right of=1.5]{};\n    \\node[rect node](3.5)[right of=2.5]{};\n    \\node[rect node](4.5)[right of=3.5]{};\n\\foreach \\s/\\t  in {1up/2up, 2dn/1dn, 2up/3up, 3dn/2dn, 3up/4up, 4dn/3dn}{\n        \\path[draw](\\s) edge[shorten <=.1cm, shorten >=.1cm](\\t);}\n    \\draw[black!20!blue] (H) edge (1.north);\n    \\draw[black!20!blue] (T) edge (4.north);\n\\end{tikzpicture}\n\\caption{A doubly linked list. Each node has a reference to the node before it and a reference to the node after it. In addition to the head attribute, this list has a tail attribute that is always assigned to the last node.}\n\\label{fig:doubly_linked}\n\\end{figure}\n\nNow we create a new class, \\li{LinkedList}, that will link \\li{LinkedListNode} instances together by modifying each node's \\li{<<next>>} and \\li{prev} attributes.\nThe list is empty initially, so we assign the \\li{head} and \\li{tail} attributes the placeholder value \\li{None}.\n\n%\\subsection*{append()}\n\nWe also need a method for adding data to the list.\nThe \\li{append()} makes a new node and adds it to the very end of the list.\nThere are two cases to consider: appending to an empty list, and appending to a nonempty list.\nSee Figure \\ref{fig:append}.\n\n\\begin{lstlisting}\nclass LinkedList(object):\n    \"\"\"Doubly linked list data structure class.\n\n    Attributes:\n        head (LinkedListNode): the first node in the list.\n        tail (LinkedListNode): the last node in the list.\n    \"\"\"\n    def __init__(self):\n        \"\"\"Initialize the 'head' and 'tail' attributes by setting\n        them to 'None', since the list is empty initially.\n        \"\"\"\n        self.head = None\n        self.tail = None\n\n    def append(self, data):\n        \"\"\"Append a new node containing 'data' to the end of the list.\"\"\"\n        # Create a new node to store the input data.\n        new_node = LinkedListNode(data)\n        if self.head is None:\n            # If the list is empty, assign the head and tail attributes to\n            # new_node, since it becomes the first and last node in the list.\n            self.head = new_node\n            self.tail = new_node\n        else:\n            # If the list is not empty, place new_node after the tail.\n            self.tail.<<next>> = new_node               # tail --> new_node\n            new_node.prev = self.tail               # tail <-- new_node\n            # Now the last node in the list is new_node, so reassign the tail.\n            self.tail = new_node\n\\end{lstlisting}\n\n\\begin{figure} % append().\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.6cm,thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.2cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {C};\n    \\node[main node] (5) [right of=3, node distance=3.5cm] {A};\n    \\node[main node] (6) [right of=5] {B};\n    \\node[main node] (7) [right of=6] {C};\n    \\node[draw=none, node distance=.07cm] (1up) [above of=1] {};\n    \\node[draw=none, node distance=.07cm] (1dn) [below of=1] {};\n    \\node[draw=none, node distance=.07cm] (2up) [above of=2] {};\n    \\node[draw=none, node distance=.07cm] (2dn) [below of=2] {};\n    \\node[draw=none, node distance=.07cm] (3up) [above of=3] {};\n    \\node[draw=none, node distance=.07cm] (3dn) [below of=3] {};\n    \\node[draw=none, node distance=.07cm] (5up) [above of=5] {};\n    \\node[draw=none, node distance=.07cm] (5dn) [below of=5] {};\n    \\node[draw=none, node distance=.07cm] (6up) [above of=6] {};\n    \\node[draw=none, node distance=.07cm] (6dn) [below of=6] {};\n    \\node[draw=none, node distance=.07cm] (7up) [above of=7] {};\n    \\node[draw=none, node distance=.07cm] (7dn) [below of=7] {};\n    \\node[draw=none, black!20!blue, node distance=1.5cm] [above left of=1](H1) {Head};\n    \\node[draw = none, black!20!blue, node distance=1.5cm] [above right of=2](T1) {Tail};\n    \\node[draw=none, black!20!blue, node distance=1.5cm] [above left of=5](H2) {Head};\n    \\node[draw = none, black!20!blue, node distance=1.5cm] [above right of=7](T2) {Tail};\n\\foreach \\r in {1, 2, 3, 5, 6, 7}{\n        \\node[rect node][right of=\\r, node distance = .36cm]{};\n        \\node[rect node][left  of=\\r, node distance = .36cm]{};}\n\\foreach \\s/\\t in {1up/2up, 2dn/1dn, 5up/6up, 6dn/5dn}{\n        \\path[draw](\\s) edge[shorten <=.1cm, shorten >=.1cm](\\t);}\n\\foreach \\s/\\t in {6up/7up, 7dn/6dn}{\n        \\path[draw](\\s) edge[red, shorten <=.1cm, shorten >=.1cm](\\t);}\n    \\draw[black!20!blue, shorten >=.1cm] (H1) edge (1.north);\n    \\draw[black!20!blue, shorten >=.1cm] (T1) edge (2.north);\n    \\draw[black!20!blue, shorten >=.1cm] (H2) edge (5.north);\n    \\draw[black!20!blue, shorten >=.1cm] (T2) edge (7.north);\n\\end{tikzpicture}\n\\caption{Appending a new node to the end of a nonempty doubly linked list. The red arrows are the new connections. Note that the \\li{tail} attribute is adjusted.}\n\\label{fig:append}\n\\end{figure}\n\n\\begin{warn} % Warning about 'is' vs '=='.\nThe \\li{is} comparison operator is \\textbf{not} the same as the \\li{==} comparison operator.\nWhile \\li{==} checks for numerical equality, \\li{is} evaluates whether or not two objects are at the same location in memory.\n\n\\begin{lstlisting}\n# This comparison evaluates to True since the numerical values are the same.\n>>> 7 == 7.0\nTrue\n\n# 7 is an int and 7.0 is a float, so they cannot be stored at the same\n# location in memory. Therefore 7 'is not' 7.0.\n>>> 7 is 7.0\nFalse\n\\end{lstlisting}\n\nFor numerical comparisons, always use \\li{==}.\nWhen comparing to built-in Python constants such as \\li{None}, \\li{True}, \\li{False}, or \\li{NotImplemented}, use \\li{is} instead.\n\\end{warn}\n\n\\subsection*{find()} % --------------------------------------------------------\n\nThe \\li{LinkedList} class only explicitly keeps track of the first and last nodes in the list via the \\li{head} and \\li{tail} attributes.\nTo access any other node, we must use each successive node's \\li{<<next>>} and \\li{prev} attributes.\n\n\\begin{lstlisting}\n>>> my_list = LinkedList()\n>>> my_list.append(2)\n>>> my_list.append(4)\n>>> my_list.append(6)\n\n# To access each value, we use the 'head' attribute of the LinkedList\n# and the 'next' and 'value' attributes of each node in the list.\n>>> my_list.head.value\n2\n>>> my_list.head.<<next>>.value\n4\n>>> my_list.head.<<next.next>>.value\n6\n>>> my_list.head.<<next.next>> is my_list.tail\nTrue\n>>> my_list.tail.prev.prev is my_list.head\nTrue\n\\end{lstlisting}\n\n% Problem 2: LinkedList.find()\n\\begin{problem}\nAdd a method called \\li{find(self, data)} to the \\li{LinkedList} class that\nreturns the first node in the list containing \\li{data} (return the actual \\li{LinkedListNode} object, not its \\li{value}).\nIf no such node exists, or if the list is empty, raise a \\li{ValueError} with an appropriate error message.\n\\\\\n(Hint: if \\li{current} is assigned to one of the nodes the list, what does the following line do?)\n\\begin{lstlisting}\ncurrent = current.<<next>>\n\\end{lstlisting}\n\\end{problem}\n\n\\subsection*{Magic Methods} % -------------------------------------------------\n\nEndowing data structures with magic methods makes it much easier to use it intuitively.\nConsider, for example, how a Python list responds to built-in functions like \\li{len()}. % and \\li{print()}. % TODO: Add this in for Python 3.\nAt the bare minimum, we should give our linked list the same functionality.\n\n\\begin{problem} % __len__() and __str__() for the LinkedList class.\nAdd magic methods to the \\li{LinkedList} class so it behaves more like the built-in Python list.\n\\begin{enumerate}\n\\item Write the \\li{__len__()} method so that the length of a \\li{LinkedList} instance is equal to the number of nodes in the list.\nTo accomplish this, consider adding an attribute that tracks the current size of the list.\nIt should be updated every time a node is successfully added or removed.\n\n\\item Write the \\li{__str__()} method so that when a \\li{LinkedList} instance is printed, its output matches that of a Python list.\nEntries are separated by a comma and one space, and strings are surrounded by single quotes.\nNote the difference between the string representations of the following lists:\n\n\\begin{lstlisting}\n>>> num_list = [1, 2, 3]\n>>> str_list = ['1', '2', '3']\n>>> print(num_list)\n[1, 2, 3]\n>>> print(str_list)\n<<['1', '2', '3']>>\n\\end{lstlisting}\n\\end{enumerate}\n\\end{problem}\n\n\\subsection*{remove()} % ------------------------------------------------------\n\nIn addition to adding new nodes to the end of a list, it is also useful to remove nodes and insert new nodes at specified locations.\nTo delete a node, all references to the node must be removed.\nThen Python will automatically delete the object, since there is no way for the user to access it.\nNa{\\\"i}vely, this might be done by finding the previous node to the one being removed, and setting its \\li{<<next>>} attribute to \\li{None}.\n\n\\begin{lstlisting}\nclass LinkedList(object):\n    # ...\n    def remove(self, data):\n        \"\"\"Attempt to remove the first node containing 'data'.\n        This method incorrectly removes additional nodes.\n        \"\"\"\n        # Find the target node and sever the links pointing to it.\n        target = self.find(data)\n        target.prev.<<next>> = None                     # -/-> target\n        target.<<next>>.prev = None                     # target <-/-\n\\end{lstlisting}\n\nRemoving all references to the target node will delete the node (see Figure \\ref{fig:remove_bad}).\nHowever, the nodes before and after the target node are no longer linked.\n\n\\begin{lstlisting}\n>>> my_list = LinkedList()\n>>> for i in xrange(10):\n...     my_list.append(i)\n...\n>>> print(my_list)\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n>>> my_list.remove(4)               # Removing a node improperly results in\n>>> print(my_list)                  # the rest of the chain being lost.\n[0, 1, 2, 3]                        # Should be [0, 1, 2, 3, 5, 6, 7, 8, 9].\n\\end{lstlisting}\n\n\\begin{figure}[H] % Incorrect remove().\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.5cm,thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.2cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {C};\n    \\node[main node] (4) [right of=3] {D};\n    \\node[main node] (5) [right of=4, node distance=2.6cm] {A};\n    \\node[main node] (6) [right of=5] {B};\n    \\node[main node] (7) [right of=6] {C};\n    \\node[main node] (8) [right of=7] {D};\n    \\node[draw=none, node distance=.07cm] (1up) [above of=1] {};\n    \\node[draw=none, node distance=.07cm] (1dn) [below of=1] {};\n    \\node[draw=none, node distance=.07cm] (2up) [above of=2] {};\n    \\node[draw=none, node distance=.07cm] (2dn) [below of=2] {};\n    \\node[draw=none, node distance=.07cm] (3up) [above of=3] {};\n    \\node[draw=none, node distance=.07cm] (3dn) [below of=3] {};\n    \\node[draw=none, node distance=.07cm] (4up) [above of=4] {};\n    \\node[draw=none, node distance=.07cm] (4dn) [below of=4] {};\n    \\node[draw=none, node distance=.07cm] (5up) [above of=5] {};\n    \\node[draw=none, node distance=.07cm] (5dn) [below of=5] {};\n    \\node[draw=none, node distance=.07cm] (6up) [above of=6] {};\n    \\node[draw=none, node distance=.07cm] (6dn) [below of=6] {};\n    \\node[draw=none, node distance=.07cm] (7up) [above of=7] {};\n    \\node[draw=none, node distance=.07cm] (7dn) [below of=7] {};\n    \\node[draw=none, node distance=.07cm] (8up) [above of=8] {};\n    \\node[draw=none, node distance=.07cm] (8dn) [below of=8] {};\n\\foreach \\r in {1, 2, 3, 4, 5, 6, 7, 8}{\n    \\node[rect node][right of=\\r, node distance = .36cm]{};\n    \\node[rect node][left of=\\r, node distance = .36cm]{};}\n\\foreach \\s/\\t in {1up/2up, 2dn/1dn, 2up/3up, 3dn/2dn, 3up/4up, 4dn/3dn, 5up/6up, 6dn/5dn, 7dn/6dn, 7up/8up}{\n        \\path[draw](\\s) edge[shorten <=.1cm, shorten >=.1cm](\\t);}\n    \\node[draw=none, node distance=1.5cm] [right of=8]{};  % Centralize\n\\end{tikzpicture}\n\\caption{Na{\\\"i}ve Removal for Doubly linked Lists. Deleting all references pointing to $C$ deletes the node, but it also separates nodes $A$ and $B$ from node $D$.}\n\\label{fig:remove_bad}\n\\end{figure}\n\nThis can be remedied by pointing the previous node's \\li{<<next>>} attribute to the node after the deleted node, and similarly changing that node's \\li{prev} attribute.\nThen there will be no reference to the removed node and it will be deleted, but the chain will still be connected.\n\n\\begin{figure}[H] % Correct remove().\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.5cm,thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.2cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {C};\n    \\node[main node] (4) [right of=3] {D};\n    \\node[main node] (5) [right of=4, node distance=2.6cm] {A};\n    \\node[main node] (6) [right of=5] {B};\n    \\node[main node] (7) [right of=6] {C};\n    \\node[main node] (8) [right of=7] {D};\n    \\node[draw=none, node distance=.07cm] (1up) [above of=1] {};\n    \\node[draw=none, node distance=.07cm] (1dn) [below of=1] {};\n    \\node[draw=none, node distance=.07cm] (2up) [above of=2] {};\n    \\node[draw=none, node distance=.07cm] (2dn) [below of=2] {};\n    \\node[draw=none, node distance=.07cm] (3up) [above of=3] {};\n    \\node[draw=none, node distance=.07cm] (3dn) [below of=3] {};\n    \\node[draw=none, node distance=.07cm] (4up) [above of=4] {};\n    \\node[draw=none, node distance=.07cm] (4dn) [below of=4] {};\n    \\node[draw=none, node distance=.07cm] (5up) [above of=5] {};\n    \\node[draw=none, node distance=.07cm] (5dn) [below of=5] {};\n    \\node[draw=none, node distance=.07cm] (6up) [above of=6] {};\n    \\node[draw=none, node distance=.07cm] (6dn) [below of=6] {};\n    \\node[draw=none, node distance=.07cm] (7up) [above of=7] {};\n    \\node[draw=none, node distance=.07cm] (7dn) [below of=7] {};\n    \\node[draw=none, node distance=.07cm] (8up) [above of=8] {};\n    \\node[draw=none, node distance=.07cm] (8dn) [below of=8] {};\n\\foreach \\r in {1, 2, 3, 4, 5, 6, 7, 8}{\n    \\node[rect node][right of=\\r, node distance = .36cm]{};\n    \\node[rect node][left of=\\r, node distance = .36cm]{};}\n\\foreach \\s/\\t in {1up/2up, 2dn/1dn, 2up/3up, 3dn/2dn, 3up/4up, 4dn/3dn, 5up/6up, 6dn/5dn, 7dn/6dn, 7up/8up}{\n        \\path[draw](\\s) edge[shorten <=.1cm, shorten >=.1cm](\\t);}\n    \\path[draw, shorten <=.2cm](6) edge[red, bend left] (8);\n    \\path[draw, shorten <=.2cm](8) edge[red, bend left] (6);\n    \\node[draw=none, node distance=1.5cm] [right of=8]{};  % Centralize\n\\end{tikzpicture}\n\\caption{Correct Removal for Doubly linked Lists. To avoid gaps in the chain, nodes $B$ and $D$ must be linked together.}\n\\label{fig:remove_good}\n\\end{figure}\n\n\\begin{problem} % LinkedList.remove().\nModify the \\li{remove()} method given above so that it correctly removes the first node in the list containing the specified data.\nAccount for the special cases of removing the first, last, or only node.\n\\end{problem}\n\n\\begin{warn} % Garbage collection warning.\nPython keeps track of the variables in use and automatically deletes a variable if there is no access to it.\nIn many other languages, leaving a reference to an object without explicitly deleting it could cause a serious memory leak.\nSee \\url{https://docs.python.org/2/library/gc.html} for more information on Python's auto-cleanup system.\n\\end{warn}\n\n\\subsection*{insert()} % ------------------------------------------------------\n\n\\begin{problem} % LinkedList.insert()\nAdd a method called \\li{insert(self, data, place)} to the \\li{LinkedList} class that inserts a new node containing \\li{data} immediately before the first node in the list containing \\li{place}.\nAccount for the special case of inserting before the first node.\n\nSee Figure \\ref{fig:insert} for an illustration.\nNote that since \\li{insert()} places a new node before an existing node, it is not possible to use \\li{insert()} to put a new node at the end of the list or in an empty list (use \\li{append()} instead).\n\\end{problem}\n\n\\begin{figure}[H] % insert().\n\\centering\n\\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=1.6cm,thick,main node/.style={rectangle,draw}, minimum size=.5cm]\n\\tikzset{rect node/.style={rectangle, draw, minimum height = .5cm, minimum width=.2cm}}\n    \\node[main node] (1) {A};\n    \\node[main node] (2) [right of=1] {B};\n    \\node[main node] (3) [right of=2] {D};\n    \\node[main node] (4) [below right of=2] {C};\n    \\node[main node] (5) [right of=3, node distance=3.5cm] {A};\n    \\node[main node] (6) [right of=5] {B};\n    \\node[main node] (7) [right of=6, node distance=2.2cm] {D};\n    \\node[main node] (8) [below right of=6] {C};\n    \\node[draw=none, node distance=.07cm] (1up) [above of=1] {};\n    \\node[draw=none, node distance=.07cm] (1dn) [below of=1] {};\n    \\node[draw=none, node distance=.07cm] (2up) [above of=2] {};\n    \\node[draw=none, node distance=.07cm] (2dn) [below of=2] {};\n    \\node[draw=none, node distance=.07cm] (3up) [above of=3] {};\n    \\node[draw=none, node distance=.07cm] (3dn) [below of=3] {};\n    \\node[draw=none, node distance=.07cm] (4up) [above of=4] {};\n    \\node[draw=none, node distance=.07cm] (4dn) [below of=4] {};\n    \\node[draw=none, node distance=.07cm] (5up) [above of=5] {};\n    \\node[draw=none, node distance=.07cm] (5dn) [below of=5] {};\n    \\node[draw=none, node distance=.07cm] (6up) [above of=6] {};\n    \\node[draw=none, node distance=.07cm] (6dn) [below of=6] {};\n    \\node[draw=none, node distance=.07cm] (7up) [above of=7] {};\n    \\node[draw=none, node distance=.07cm] (7dn) [below of=7] {};\n    \\node[draw=none, node distance=.07cm] (8up) [above of=8] {};\n    \\node[draw=none, node distance=.07cm] (8dn) [below of=8] {};\n    \\node[draw=none, black!20!blue, node distance=1.5cm] [above left of=1](H1) {Head};\n    \\node[draw = none, black!20!blue, node distance=1.5cm] [above right of=3](T1) {Tail};\n    \\node[draw=none, black!20!blue, node distance=1.5cm] [above left of=5](H2) {Head};\n    \\node[draw = none, black!20!blue, node distance=1.5cm] [above right of=7](T2) {Tail};\n\\foreach \\r in {1, 2, 3, 4, 5, 6, 7, 8}{\n        \\node[rect node][right of=\\r, node distance = .36cm]{};\n        \\node[rect node][left  of=\\r, node distance = .36cm]{};}\n\\foreach \\s/\\t in {1up/2up, 2dn/1dn, 2up/3up, 3dn/2dn, 5up/6up, 6dn/5dn}{\n        \\path[draw](\\s) edge[shorten <=.1cm, shorten >=.1cm](\\t);}\n\\foreach \\s/\\t in {6up/8up, 8dn/6dn, 8up/7up, 7dn/8dn}{\n        \\path[draw](\\s) edge[red, shorten <=.1cm, shorten >=.1cm](\\t);}\n    \\draw[black!20!blue, shorten >=.1cm] (H1) edge (1.north);\n    \\draw[black!20!blue, shorten >=.1cm] (T1) edge (3.north);\n    \\draw[black!20!blue, shorten >=.1cm] (H2) edge (5.north);\n    \\draw[black!20!blue, shorten >=.1cm] (T2) edge (7.north);\n    \\node[draw = none, node distance = 1.5cm] [right of=8]{};  % Centralize\n\\end{tikzpicture}\n\\caption{Insertion for Doubly linked Lists.}\n\\label{fig:insert}\n\\end{figure}\n\n\\begin{info} % Big-O rates for linked lists.\nThe temporal complexity for inserting to the beginning or end of a linked list is $O(1)$, but inserting anywhere else is $O(n)$, where $n$ is the number of nodes in the list.\nThis is quite slow compared other data structures.\nIn the next lab we turn our attention to \\emph{trees}, special kinds of linked lists that allow for much quicker sorting and data retrieval.\n\\end{info}\n\n\\section*{Restricted-Access Lists} % ==========================================\n\nIt is sometimes wise to restrict the user's access to the some of the data within a structure.\nThe three most common and basic restricted-access structures are \\emph{stacks}, \\emph{queues}, and \\emph{deques}.\nEach structure restricts the user's access differently, making them ideal for different situations.\n\n\\begin{itemize}\n\\item \\textbf{Stack}: \\emph{Last In, First Out} (LIFO).\nOnly the last item that was inserted can be accessed.\nA stack is like a pile of plates: the last plate put on the pile is (or should be) the first one to be taken off.\nStacks usually have two main methods: \\li{push()}, to insert new data, and \\li{pop()}, to remove and return the last piece of data inserted.\n\n\\item \\textbf{Queue} (pronounced ``cue''): \\emph{First In, First Out} (FIFO).\nNew nodes are added to the end of the queue, but an existing node can only be removed or accessed if it is at the front of the queue.\nA queue is like a line at the bank: the person at the front of the line is served next, while newcomers add themselves to the back of the line.\nQueues also usually have a \\li{push()} and a \\li{pop()} method, but \\li{push()} inserts data to the end of the queue while \\li{pop()} removes and returns the data at the front of the queue.\\footnote{\\li{push()} and \\li{pop()} for queues are sometimes called \\li{enqueue()} and \\li{dequeue()}, respectively)}\n\n\\item \\textbf{Deque} (pronounced ``deck''): a double-ended queue.\nData can be inserted or removed from either end, but data in the middle is inaccessible.\nA deque is like a deck of cards, where only the top and bottom cards are readily accessible.\nA deque has two methods for insertion and two for removal, usually called \\li{append()}, \\li{appendleft()}, \\li{pop()}, and \\li{popleft()}.\n\\end{itemize}\n\n\\begin{problem} % Deque class.\nWrite a \\li{Deque} class that inherits from the \\li{LinkedList} class.\n%\n\\begin{enumerate}\n\\item Use inheritance to implement the following methods:\n%\n\\begin{itemize}\n    \\item \\li{pop(self)}: Remove the last node in the list and return its data.\n    \\item \\li{popleft(self)}: Remove the first node in the list and return its data.\n    \\item \\li{appendleft(self, data)}: Insert a new node containing \\li{data} at the beginning of the list.\n\\end{itemize}\nThe \\li{LinkedList} class already implements the \\li{append()} method.\n\n\\item Override the \\li{remove()} method with the following:\n\n\\begin{lstlisting}\ndef remove(*args, **kwargs):\n    raise NotImplementedError(\"Use pop() or popleft() for removal\")\n\\end{lstlisting}\n\nThis effectively disables \\li{remove()} for the \\li{Deque} class, preventing the user from removing a node from the middle of the list.\n\n\\item Disable the \\li{insert()} method as well.\n\\end{enumerate}\n\\end{problem}\n\n\\newpage\n\n\\begin{info}\nThe \\li{*args} argument allows the \\li{remove()} method to receive any number of positional arguments without raising a \\li{TypeError}, and the \\li{**kwargs} argument allows it to receive any number of keyword arguments.\nThis is the most general form of a function signature.\n\\end{info}\n\nPython lists have \\li{append()} and \\li{pop()} methods, so they can be used as stacks.\nHowever, data access and removal from the front is much slower, as Python lists are not implemented as linked lists.\n\nThe \\li{collections} module in the standard library has a \\li{deque} object, implemented as a doubly linked list.\nThis is an excellent object to use in practice instead of a Python list when speed is of the essence and data only needs to be accessed from the ends of the list.\n\n\\begin{problem} % Reverse a file using a stack/deque.\nWrite a function that accepts the name of a file to be read and a file to write to.\nRead the first file, adding each line to the end of a deque.\nAfter reading the entire file, pop each entry off of the end of the deque one at a time, writing the result to a line of the second file.\n\nFor example, if the file to be read has the list of words on the left, the resulting file should have the list of words on the right.\n\n\\begin{lstlisting}\n<<My homework is too hard for me.         I am a mathematician.\nI do not believe that                   Programming is hard, but\nI can solve these problems              I can solve these problems\nProgramming is hard, but                I do not believe that\nI am a mathematician.                   My homework is too hard for me.\n\\end{lstlisting}\n\nYou may use a Python list, your \\li{Deque} class, or \\li{collections.deque} for the deque.\nTest your function on the file \\texttt{english.txt}, which contains a list of over 58,000 English words in alphabetical order.\n\\end{problem}\n\n\\newpage\n\n\\section*{Additional Material} % ==============================================\n\n\\subsection*{Improvements to the Linked List Class} % -------------------------\n\n\\begin{enumerate}\n\\item Add a keyword argument to the constructor so that if an iterable is input, each element of the iterable is immediately added to the list.\nThis makes it possible to cast an iterable as a \\li{LinkedList} the same way that an iterable can be cast as one of Python's standard data structures.\n\n\\begin{lstlisting}\n>>> my_list = [1, 2, 3, 4, 5]\n>>> my_linked_list = LinkedList(my_list)    # Cast my_list as a LinkedList.\n>>> print(my_linked_list)\n[1, 2, 3, 4, 5]\n\\end{lstlisting}\n\n\\item Add new methods:\n\\begin{itemize}\n\\item \\li{count()}: return the number of occurrences of a specified value.\n\\item \\li{reverse()}: reverse the ordering of the nodes (in place).\n\\item \\li{rotate()}: rotate the nodes a given number of steps to the right (in place).\n\\item \\li{sort()}: sort the nodes by their data (in place).\n\\end{itemize}\n\n\\item Implement more magic methods:\n\\begin{itemize}\n\\item \\li{__max__()}: return the greatest element.\n\\item \\li{__min__()}: return the least element.\n\\item \\li{__getitem__()} and \\li{__setitem__()}: enable standard bracket indexing.\n\\item \\li{__iter__()}: support \\li{for} loop iteration, the \\li{iter()} built-in function, and the \\li{in} statement.\n\\end{itemize}\n\\end{enumerate}\n\n\\subsection*{Other Linked List} % ---------------------------------------------\n\nThe \\li{LinkedList} class can also be used as the backbone for other data structures.\n%\n\\begin{enumerate}\n\\item A \\emph{sorted list} adds new nodes strategically so that the data is always kept in order.\nA \\li{SortedLinkedList} class that inherits from the \\li{LinkedList} class should have a method called \\li{add(self, data)} that inserts a new node containing \\li{data} before the first node in the list that has a \\li{value} that is greater or equal to \\li{data} (thereby preserving the ordering).\nOther methods for adding nodes should be disabled.\n\nA linked list is \\textbf{not} an ideal implementation for a sorted list (try sorting \\texttt{english.txt}).\n\n\\item In a \\emph{circular linked list}, the ``last'' node connects back to the ``first'' node.\nThus a reference to the tail is unnecessary.\n\\end{enumerate}\n", "meta": {"hexsha": "79fe6e012e42151154c3bf5ee736cc4d57bae62d", "size": 33523, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Vol2A/DataStructures1-LinkedLists/DS1.tex", "max_stars_repo_name": "joshualy/numerical_computing", "max_stars_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Vol2A/DataStructures1-LinkedLists/DS1.tex", "max_issues_repo_name": "joshualy/numerical_computing", "max_issues_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Vol2A/DataStructures1-LinkedLists/DS1.tex", "max_forks_repo_name": "joshualy/numerical_computing", "max_forks_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.808988764, "max_line_length": 307, "alphanum_fraction": 0.6738060436, "num_tokens": 10035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5350984434543458, "lm_q2_score": 0.7634837689358858, "lm_q1q2_score": 0.40853897636024983}}
{"text": "\\documentclass[letterpaper,10pt]{article}\n\\usepackage[margin=2cm]{geometry}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage[colorlinks]{hyperref}\n\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{0.3em}\n\n\\newcommand{\\panhline}{\\begin{center}\\rule{\\textwidth}{1pt}\\end{center}}\n\n\\title{\\textbf{Parametric Models: Prior Information, From Models to Answers}}\n\\author{Praddep Ravikumar (Instructor), HMW-Alexander (Noter)}\n\n\\begin{document}\n\n\\maketitle\n\n\\panhline\n\\href{../index.html}{Back to Index}\n\n\\panhline\n\\tableofcontents\n\n\\section*{Resources}\n\n\\begin{itemize}\n\t\\item \\href{../../Lectures/03_ParametricModels.pdf}{Lecture}\n\\end{itemize}\n\n\\panhline\n\n\\section{Bayesian Learning}\n\nGiven a prior knowledge to estimate the model.\n\nBayesian Learning:\n$$P(\\theta|\\mathcal{D}) = \\frac{P(\\mathcal{D}|\\theta)P(\\theta)}{P(\\mathcal{D})}$$\nor equivalently\n$$P(\\theta|\\mathcal{D}) \\propto P(\\mathcal{D}|\\theta)P(\\theta)$$\nLikelihood measures the fitness between data and parameters, Prior is the knowledge how possible the parameters to be.\n\n\\begin{itemize}\n\t\\item Prior information encoded as a distribution over possible values of parameter.\n\t\\item Using the Bayes rule to get an updated posterior distribution over parameters.\n\\end{itemize}\n\n\\subsection{Prior Distribution}\n\n\\subsubsection{Where to get}\n\n\\begin{itemize}\n\t\\item Represents expert knowledge (philosophical approach)\n\t\\item Simple posterior form (engineer's approach)\n\\end{itemize}\n\n\\subsubsection{Uniformative priors}\n\nSimple distribution. \n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=4cm]{./img/uniform.png}\n\\end{figure}\n\n\\subsubsection{Conjugate Priors}\n\n\\begin{itemize}\n\t\\item Closed-form representation of posterior\n\t\\item prior and posterior have the same algebraic form as a function of parameters\n\\end{itemize}\n\nBernoulli Example: (Binomial's conjugate prior is Beta distribution)\n\\begin{itemize}\n\t\\item Likelihood in Bernoulli model: $P(D|\\theta)=\\theta^{\\alpha_1}(1-\\theta)^{\\alpha_2}$\n\t\\item Prior is Beta distribution: $P(\\theta)=\\frac{\\theta^{\\beta_1-1}(1-\\theta)^{\\beta_2-1}}{B(\\beta_1,\\beta_2)} \\sim Beta(\\beta_1,\\beta_2)$\n\t\\item Posterior is also Beta distribution: $P(\\theta|D)\\sim Beta(\\beta_1+\\alpha_1,\\beta_2+\\alpha_2)$\n\\end{itemize}\n\nMultinomial example: (Multinomial's conjugate prior is Dirichelet distribution)\n\\begin{itemize}\n\t\\item Likelihood is Multinomial($\\theta=\\{\\theta_1,\\dots,\\theta_k\\}$), $P(D|\\theta)=\\prod_{i=1}^{k}\\theta_i^{\\alpha_i}$, $\\alpha_i\\in\\{0,1\\}$ is the data $D$, $\\sum_{i=1}^{k}\\theta_i =1$.\n\t\\item Prior is Dirichlet distribution: $P(\\theta)=\\frac{\\prod_{i=1}^{k}\\theta_i^{\\beta_i-1}}{B(\\beta_1,\\dots,\\beta_k)} \\sim Dirichlet(\\beta_1,\\dots,\\beta_k)$\n\t\\item Posterior is also dirichlet distribution: $P(\\theta|D) \\sim Dirichlet(\\beta_1+\\alpha_1,\\dots,\\beta_k+\\alpha_k)$\n\\end{itemize}\n\nAs we get more samples, effect of prior is \"washed out\"\n\n\\section{Maximum A Posteriori Estimation}\n\nChoose $\\theta$ that maximizes a posterior probability:\n$\\hat{\\theta}_{MAP}=\\arg\\max_\\theta{P(\\theta|D)}$\n\n\\begin{equation}\n\\begin{array}{rcl}\n\\hat{\\theta}_{MAP} & = & \\arg\\max_\\theta{P(\\theta|D)} \\\\\n\t\t\t\t   & = & \\arg\\max_\\theta{P(D|\\theta)P(\\theta)}\n\\end{array}\n\\end{equation}\n\nBernoulli example:\n\n\\begin{equation}\n\\begin{array}{rcl}\nP(\\theta|D) & \\sim & Beta(\\beta_1+\\alpha_1,\\beta_2+\\beta_2) \\\\\n\\hat{\\theta}_{MAP} & = & \\frac{\\alpha_1+\\beta_1-1}{\\alpha_1+\\beta_1+\\alpha_2+\\beta_2-2}\n\\end{array}\n\\end{equation}\n\n\\subsection{MLE vs. MAP}\n\n\\begin{itemize}\n\t\\item MLE: Choose value that maximizes the probability of observed data\n\t\\item MAP: Choose value that is mot probable given observed data and prior belief\n\t\\item When prior is a uniform distribution, MLE=MAP.\n\\end{itemize}\n\n\\subsection{MAP for Gaussian mean and variance}\n\nConjugate priors\n\\begin{itemize}\n\t\\item Gaussian prior: $$P(\\mu|\\eta,\\lambda)=\\frac{1}{\\lambda\\sqrt{2\\pi}}\\exp(-\\frac{(\\mu-\\eta)^2}{2\\lambda^2})=\\mathcal{N}(\\eta,\\lambda)$$\n\t\\item Variance: Wishart Distribution\\footnote{\\url{https://en.wikipedia.org/wiki/Wishart_distribution}}\n\\end{itemize}\n\nMAP for Gasussian Mean:\n\\begin{itemize}\n\t\\item $\\hat{\\mu}_{MLE}=\\frac{1}{n}\\sum_{i=1}^{n}x_i$\n\t\\item $\\hat{\\mu}_{MAP}=\\frac{\\frac{1}{\\sigma^2}\\sum_{i=1}^{n}x_i+\\frac{\\eta}{\\lambda^2}}{\\frac{n}{\\sigma^2}+\\frac{1}{\\lambda^2}}$\n\\end{itemize}\n\n\\section{Non-Bayesian Prior Information via Constraints}\n\n\\begin{itemize}\n\t\\item MLE: $$\\max_\\theta\\log P(D|\\theta)$$\n\t\\item Constrained MLE: $$\\max _\\theta\\log P(D|\\theta)~~s.t.~\\mathcal{R}(\\theta)\\leq C$$\n\t\\item When $\\mathcal{R}$ is convex, constrained MLE is equivalent to regularized MLE (lagrange multiplier\\footnote{\\url{http://www1.maths.leeds.ac.uk/~cajones/math2640/notes4.pdf}}): $$\\max_\\theta\\{\\log P(D|\\theta)+\\lambda\\mathcal{R}(\\theta)\\}$$\n\t\\item The MAP estimator can be seen to be a special case by simply setting: $$\\lambda\\mathcal{R}(\\theta)=\\log P(\\theta)$$\n\\end{itemize}\n\n\\end{document}\n\n\n\n", "meta": {"hexsha": "ece3985c5e9ff8134e9fb92d0d42ceaacbf8d98f", "size": 4923, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/03_ParametricModels/document.tex", "max_stars_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_stars_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-03-04T01:53:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-14T09:17:05.000Z", "max_issues_repo_path": "Notes/03_ParametricModels/document.tex", "max_issues_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_issues_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/03_ParametricModels/document.tex", "max_forks_repo_name": "MengwenHe-CMU/17S_10701_MachineLearning", "max_forks_repo_head_hexsha": "613a3087a57a206b83d79855cec359e04cb440f7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-10-20T15:07:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-20T15:07:29.000Z", "avg_line_length": 33.4897959184, "max_line_length": 246, "alphanum_fraction": 0.7227300427, "num_tokens": 1644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984434543458, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.4085389734805676}}
{"text": "%\r\n% @author   Shmish  \"shmish90@gmail.com\"\r\n% @legal    MIT     \"(c) Christopher Schmitt\"\r\n%\r\n\r\n\r\n\\documentclass{article}\r\n\r\n\r\n%\r\n% Document Imports\r\n%\r\n\r\n\\usepackage{fancyhdr}\r\n\\usepackage{extramarks}\r\n\\usepackage{amsmath}\r\n\\usepackage{amssymb}\r\n\\usepackage{amsthm}\r\n\\usepackage{amsfonts}\r\n\\usepackage{color}\r\n\r\n\r\n\r\n%\r\n% Document Configuation\r\n%\r\n\r\n\\newcommand{\\hwAuthor}{Christopher Schmitt}\r\n\\newcommand{\\hwSubject}{Math 218}\r\n\\newcommand{\\hwSection}{Section 81}\r\n\\newcommand{\\hwSemester}{Summer 2019}\r\n\\newcommand{\\hwAssignment}{Assignment 3}\r\n\r\n\r\n%\r\n% Document Enviornments\r\n%\r\n\r\n\\setlength{\\headheight}{65pt}\r\n\\pagestyle{fancy}\r\n\\lhead{\\hwAuthor}\r\n\\rhead{\r\n  \\hwSubject \\\\\r\n  \\hwSection \\\\\r\n  \\hwSemester \\\\\r\n  \\hwAssignment\r\n}\r\n\r\n\\newenvironment{problem}[1]{\r\n  \\nobreak\\section*{Problem #1}\r\n}{}\r\n\r\n\r\n%\r\n% Document Start\r\n%\r\n\r\n\\begin{document}\r\n  \\begin{problem}{1}\r\n    Let $R$ be the relation on the set $Q$ defined by:\r\n    \\begin{center}\r\n      $(a, b) \\in R \\text{ if and only if } |a - b| \\le 4$\r\n    \\end{center}\r\n    \r\n    $R$ is Reflexive.\r\n    \\begin{proof}\r\n      Let $a \\in Q$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          |a - a| & \\le 4\\\\\r\n          |0| & \\le 4\\\\\r\n          0 & \\le 4\\\\\r\n          (a, a) & \\in R\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Symmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in Q$, Suppose $(a, b) \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          |a - b| & \\le 4\\\\\r\n          |b - a| & \\le 4 \\text{ [Absolute value]}\\\\\r\n          (b, a) & \\in Q \r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Transitive.\r\n    \\begin{proof}\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          |10 - 6| \\le 4 & \\wedge |6 - 2| \\le 4\\\\\r\n          |10 - 2| & > 4\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Antisymmetric.\r\n    \\begin{proof}\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          |10 - 6| & \\le 4 \\\\\r\n          |6 - 10| & \\le 4\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n  \\end{problem}\r\n\r\n  \\begin{problem}{2}\r\n    Let $R$ be the relation on the set $R$ defined by:\r\n    \\begin{center}\r\n      $(a, b) \\in R \\text{ if and only if } 5a = b$\r\n    \\end{center}\r\n\r\n    $R$ is not Reflexive.\r\n    \\begin{proof}\r\n      Let $a \\in R$\r\n      \\begin{equation*}\r\n        5a \\neq a \\text{ [In General]}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Symmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          5(5) & = 25\\\\\r\n          5(25) & \\neq 5\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Transitive.\r\n    \\begin{proof}\r\n      Let $a, b, c \\in R$, Suppose $(a, b), (b, c) \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          5(1) & = 5\\\\\r\n          5(5) & = 25\\\\\r\n          5(1) & \\neq 25\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Antisymmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in R$, Suppose $(a, b), (b, a) \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          5(a) = b & \\wedge 5(b) = a\\\\\r\n          5(5(b)) & = b\\\\\r\n          25(b) & = b \\text{ iff $b = 0$}\\\\\r\n          5(5(a)) & = a\\\\\r\n          25(a) & = a \\text{ iff $a = 0$}\\\\\r\n        \\end{split}\r\n      \\end{equation*}\r\n      $a$ and $b$ must both the same if $(a, b), (b, a) \\in R$, so $R$ is Antisymmetric\r\n    \\end{proof}\r\n  \\end{problem}\r\n\r\n  \\begin{problem}{3}\r\n    Let R be the relation on the set Z defined by:\r\n    \\begin{center}\r\n      $(a, b) \\in \\text{ if and only if } ab \\ge 1$\r\n    \\end{center}\r\n\r\n    $R$ is not Reflexive.\r\n    \\begin{proof}\r\n      \\begin{equation*}\r\n        0(0) < 1\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Symmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in Z$, Suppose $(a, b) \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a(b) & \\ge 1\\\\\r\n          b(a) & \\ge 1\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Transitive.\r\n    \\begin{proof}\r\n      Let $a, b, c \\in Z$, Suppose $(a, b), (b, c) \\in  R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          ab \\ge 1 & \\wedge bc \\ge 1\\\\\r\n          (ab)(bc) & \\ge 1\\\\\r\n          acb^2 & \\ge 1\\\\\r\n          ac & \\ge b^{-2}\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Antisymmetric.\r\n    \\begin{proof}\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          1(2) & \\ge 1\\\\\r\n          2(1) & \\ge 1\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n  \\end{problem}\r\n\r\n  \\begin{problem}{4}\r\n    Let $R$ be the relation on the set $Z \\times Z$ defined by:\r\n    \\begin{center}\r\n      $((a, b),(c, d)) \\in R \\text{ if and only if } a + 2b \\le c + 2d$\r\n    \\end{center}\r\n\r\n    $R$ is Reflexive.\r\n    \\begin{proof}\r\n      Let $(a, b) \\in Z \\times Z$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a + 2(b) & \\le a + 2(b)\\\\\r\n          ((a, b), (a, b)) & \\in R\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is not Symmetric.\r\n    \\begin{proof}\r\n      Let $(a, b), (c, d) \\in Z \\times Z$, Suppose $((a, b), (c, d)) \\in R$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          0 + 2(0) & \\le 1 + 2(1)\\\\\r\n          0 & \\le 2\\\\\r\n          1 + 2(1) & > 0 + 2(0)\\\\\r\n          3 & > 0\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Transitive.\r\n    \\begin{proof}\r\n      Let $(a, b), (c, d), (e, f) \\in Z \\times Z$, Suppose $(a, b) R (c, d) \\wedge (c, d) R (e, f)$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a + 2(b) \\le c + 2(d) & \\wedge c + 2(d) \\le e + 2(f)\\\\\r\n          a + 2(b) & \\le e + 2(f) \r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $R$ is Antisymmetric.\r\n    \\begin{proof}\r\n      Let $(a, b), (c, d) \\in Z \\times Z$, Suppose $(a, b) R (c, d)$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a + 2(b) & \\le c + 2(d)\\\\\r\n          c + 2(d) & \\le a + 2(b)\\\\\r\n          a + 2(b) & = c + 2(b)\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n  \\end{problem}\r\n\r\n  \\begin{problem}{5}\r\n    Let $\\sim$ be the relation on the set $Z$ defined by:\r\n    \\begin{center}\r\n      $a \\sim b \\text{ if and only if } a = \\pm b$.\r\n    \\end{center}\r\n\r\n    $\\sim$ is Reflexive.\r\n    \\begin{proof}\r\n      Let $a \\in Z$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a & = \\pm a\\\\\r\n          a^2 & = (\\pm a)^2\\\\\r\n          a^2 & = a^2\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $\\sim$ is Symmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in Z$, Suppose $a \\sim b$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a & = \\pm b\\\\\r\n          a = b & \\vee a = -b\\\\\r\n          a = b & \\implies b = a\\\\\r\n          a = -b \\implies -b & = a \\implies b = -a\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $\\sim$ is Transitive.\r\n    \\begin{proof}\r\n      Let $a, b, c \\in Z$, Suppose $a \\sim b, b \\sim c$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          a & = \\pm b\\\\\r\n          a^2 & = (\\pm b)^2\\\\\r\n          a^2 & = b^2\\\\\r\n          b & = \\pm c\\\\\r\n          b^2 & = (\\pm c)^2\\\\\r\n          b^2 & = c^2\\\\\r\n          a^2 = & ~ b^2 = c^2\\\\\r\n          a^2 & = b^2\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    Find all the elements in the class $\\bar{7}$\r\n    \\begin{center}\r\n      $\\bar{7} = \\{7, -7\\}$\r\n    \\end{center}\r\n  \\end{problem}\r\n\r\n  \\begin{problem}{6}\r\n    Let $\\sim$ be the relation on the set $Z$ defined by:\r\n    \\begin{center}\r\n      $a \\sim b \\text{ if and only if } 8 \\text{ is a divisor of } 7a + b$\r\n    \\end{center}\r\n\r\n    $\\sim$ is Reflexive.\r\n    \\begin{proof}\r\n      Let $a \\in Z$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          8 & | 7(a) + a\\\\\r\n          8(k) = 7(a) & + a \\text{ where $K \\in \\mathbb Z$ }\\\\\r\n          8(k) & = 8(a)\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $\\sim$ is Symmetric.\r\n    \\begin{proof}\r\n      Let $a, b \\in Z$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          8 & | 7(a) + b\\\\\r\n          8(k) = 7(a) & + b \\text{, where $k \\in \\mathbb Z$}\\\\\r\n          -8(k) & = -7(a) - b\\\\\r\n          -8(k) + 8(a) + 8(b) & = -7(a) + 8(a) - b + 8(b)\\\\\r\n          8(-k + a + b) & = a + 7(b)\\\\\r\n          8(-k + a + b) & = 7(b) + a\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    $\\sim$ is Transitive.\r\n    \\begin{proof}\r\n      Let $a, b, c \\in Z$, Suppose $a \\sim b, b \\sim c$\r\n      \\begin{equation*}\r\n        \\begin{split}\r\n          8 | 7(a) + b & \\wedge 8 | 7(b) + c\\\\\r\n          8(k) = 7(a) + b & \\wedge 8(j) = 7(b) + c \\text{, where $k, j \\in \\mathbb Z$}\\\\\r\n          8(k) + 8(j) & = 7(a) + b + 7(b) + c\\\\\r\n          8(k) + 8(j) & = 7(a) + 8(b) + c\\\\\r\n          8(k) + 8(j) - 8(b) & = 7(a) + c\\\\\r\n          8(k + j - b) & = 7(a) + c\r\n        \\end{split}\r\n      \\end{equation*}\r\n    \\end{proof}\r\n\r\n    Find four elements in the equivalence class $\\bar{5}$\r\n    \\begin{center}\r\n      $\\bar{5} = \\{5, 13, 21, 29\\}$\r\n    \\end{center}\r\n  \\end{problem}\r\n\\end{document}\r\n", "meta": {"hexsha": "06fa45fd821ac71d73388dcc1e18060f86670809", "size": 9074, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Assignment_003.tex", "max_stars_repo_name": "shmishtopher/MATH-218", "max_stars_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Assignment_003.tex", "max_issues_repo_name": "shmishtopher/MATH-218", "max_issues_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Assignment_003.tex", "max_forks_repo_name": "shmishtopher/MATH-218", "max_forks_repo_head_hexsha": "877cdf2586d3e6f8be639b16e17715a9cbfc8715", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.2620320856, "max_line_length": 100, "alphanum_fraction": 0.4327749614, "num_tokens": 3370, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.4085389621598333}}
{"text": "% !TEX root =main.tex\n\n\n\n \n \\subsection{C-TLP Cost Analysis}\\label{TLP-cost-compare}\n \n In this section, we analyse  the communication and computation complexity of C-TLP. We consider a generic setting where the protocol deals with $z$ puzzles. \n\n  \\begin{table*}[!htbp]\n\\begin{center}\n\\caption{\\small Computation Cost}\\label{table::puzzle-com} \n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n   \\hline\n\\cellcolor[gray]{0.9}&\\cellcolor[gray]{0.9} &\n \\multicolumn{3}{c|}{\\cellcolor[gray]{0.9}\\scriptsize \\underline{ \\ \\ \\ \\  \\ \\ \\ \\ \\ Protocol Function \\ \\ \\ \\ \\ \\ \\ \\ \\ }}&\\cellcolor[gray]{0.9}\\\\\n\n\\cellcolor[gray]{0.9} \\multirow{-2}{*}{\\scriptsize Protocol}&\\cellcolor[gray]{0.9} \\multirow{-2}{*} {\\scriptsize Operation}&\\cellcolor[gray]{0.9}\\scriptsize$\\mathtt{GenPuz}$&\\cellcolor[gray]{0.9}\\scriptsize$\\mathtt{SolvPuz}$&\\cellcolor[gray]{0.9}\\scriptsize$\\mathtt{Verify}$&\\multirow{-2}{*} {\\cellcolor[gray]{0.9}\\scriptsize   Complexity} \\\\\n\\hline\n\\cellcolor[gray]{0.9} &\\multirow{3}{*}{\\rotatebox[origin=c]{0}{\\scriptsize }} \\cellcolor[gray]{0.9}\\scriptsize Exp.&\\scriptsize$z+1$&\\scriptsize$T z$ &$-$&\\multirow{4}{*}{\\rotatebox[origin=c]{0}{\\scriptsize $O(T  z)$}}\\\\\n     \\cline{2-5}  \n \\cellcolor[gray]{0.9}     &\\cellcolor[gray]{0.9}\\scriptsize Add. or Mul.&\\scriptsize$z$ &\\scriptsize$z$&$-$ & \\\\\n     \\cline{2-5} \n \\cellcolor[gray]{0.9}         &\\cellcolor[gray]{0.9}\\scriptsize Commitment&\\scriptsize$z$&$-$ &\\scriptsize$z$&\\\\\n     \\cline{2-5} \n\\cellcolor[gray]{0.9}   \\multirow{-4}{*}{\\rotatebox[origin=c]{0}{\\scriptsize  C-TLP }}     &\\cellcolor[gray]{0.9}\\scriptsize Sym. Enc&\\scriptsize$z$&\\scriptsize$z$ &$-$&\\\\\n\n \\hline\n\\end{tabular}\n\\end{center}\n\n\\end{table*}\n\n \\noindent\\textbf{\\textit{Computation Complexity}}. For a client to generate $z$ puzzles, in total: in step \\ref{call-RTLP-Setup}, it performs one exponentiation over $\\bmod \\phi(N)$. In step \\ref{call-RTLP-GenPuz}, it $z$ times calls $\\mathtt{TLP.GenPuZ}(.)$. This  in total involves $z$ symmetric key-based encryption,  $z$ modular exponentiations over $\\mathbb{Z}_{\\scriptscriptstyle N}$ and $z$ modular additions. Also, in  step \\ref{commit-} it performs $z$ invocations of a commitment scheme (to commit), i.e. if a hash-based commitment is used then it would involve $z$ invocations of a hash function, and if Pedersen commitment is used then it would involve $2 z$ exponentiations and $z$ multiplications, where  all operations, in the latter commitment,  are done  over a $\\bmod q$ for a large prime number: $q$, e.g. $|q|=1024$-bit. Thus, the overall computation complexity of the client   is $O(z)$. For the server to solve $z$ puzzles, it $z$ times calls $\\mathtt{TLP.SolvPuz}(.)$. This in total involves $Tz$ modular squaring over $\\mathbb{Z}_{\\scriptscriptstyle N}$, $z$ modular additions over $\\mathbb{Z}_{\\scriptscriptstyle N}$, and  $z$ symmetric key based decryption. The server's cost of proving, in step \\ref{prove-}, is very low, as it involves only parsing $z$ strings. Therefore, the server total computation complexity is $O(Tz)$. The verification cost, in step \\ref{verify-}, only involves $z$ invocation of commitment scheme (to verify  each opening) and it is \\emph{independent} of the RSA security parameters.  If the hash-based commitment is used, then it would involve $z$ invocations of a hash function,  if Pedersen commitment is utilised, then in total it would involve $2 z$ exponentiations and $z$ multiplications performed over $\\bmod q$. Thus, the  verification's complexity is $O(z)$. Table \\ref{table::puzzle-com} summarises the computation analysis results.\n\n\n\n \\begin{table*}[!htbp]\n\\begin{center}\n\\caption{\\small Communication Cost (in bit)}\\label{table::puzzle-communication}\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n   \\hline\n {\\cellcolor[gray]{0.9}\\scriptsize Protocol}&{\\cellcolor[gray]{0.9}\\scriptsize Model}&\n{\\cellcolor[gray]{0.9}\\scriptsize Client}&{\\cellcolor[gray]{0.9}\\scriptsize Server}&{\\cellcolor[gray]{0.9}\\scriptsize  Complexity}\\\\\n \\cline{3-4}\n\n\\hline\n \\cellcolor[gray]{0.9}  &\\cellcolor[gray]{0.9} \\multirow{2}{*}{\\rotatebox[origin=c]{0}}\\scriptsize Standard&\\scriptsize$3200 z$&\\scriptsize$1524 z$ &\\multirow{2}{*}{\\rotatebox[origin=c]{0}{\\scriptsize $O(z)$ }}\\\\\n     \\cline{2-4}  \n  \\multirow{-2}{*}{\\rotatebox[origin=c]{0}{\\cellcolor[gray]{0.9} \\scriptsize  C-TLP }}&\\cellcolor[gray]{0.9}\\scriptsize R.O.&\\scriptsize$2432  z$ &\\scriptsize$628  z$& \\\\\n   \n \\hline\n\\end{tabular}\n\\end{center}\n\\end{table*}\n\n \\noindent\\textbf{\\textit{Communication Complexity}}.  In step \\ref{Generate-Puzzle}, the client publishes two vectors: $\\vv{\\bm{o}}$ and $\\vv{\\bm{h}}$, with  $2 z$ and $z$ elements respectively.  Each element of $\\vv{\\bm{o}}$ is a pair $(o_{\\scriptscriptstyle j,1},o_{\\scriptscriptstyle j,2})$, where $o_{\\scriptscriptstyle j,1}$ is an output of symmetric key encryption, e.g.   $|o_{\\scriptscriptstyle j,1}|=128$-bit, and $o_{\\scriptscriptstyle j,2}$ is an element of $\\mathbb{Z}_{\\scriptscriptstyle N}$, e.g.  $|o_{\\scriptscriptstyle j,2}|=2048$-bit. Also, each element $h_{\\scriptscriptstyle j}$ of $\\vv{\\bm{h}}$ is either an output of a hash function, when a hash-based commitment is used, e.g.  $|h_{\\scriptscriptstyle j}|=256$-bit, or an element of $\\mathbb{F}_{\\scriptscriptstyle q}$ when Pedersen commitment is used, e.g.  $|h_{\\scriptscriptstyle j}|=1024$-bit. Therefore, its total bandwidth is about $2432 z$ bits when the former,  or $3200 z$ bits when the latter commitment scheme is utilised. Also, its   complexity is $O(z)$. Note,  in  C-TLP, when a server finds a solution, it does not broadcast anything, instead it moves on  to the next step:  $\\mathtt{Prove}(.)$. For the server to prove, in step \\ref{prove-},  in total,  it sends $z$ pairs $(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$ to the verifier, where $m_{\\scriptscriptstyle j}$  is an arbitrary message, e.g.  $|m_{\\scriptscriptstyle j}|=500$-bit, and  $d_{\\scriptscriptstyle j}$ is either a long enough random value, e.g. $|d_{\\scriptscriptstyle j}|=128$-bit, when the hash-based commitment is used, or an element of $\\mathbb{F}_{\\scriptscriptstyle q}$ when Pedersen scheme is used, e.g. $|d_{\\scriptscriptstyle j}|=1024$-bit. Therefore, its bandwidth is about either $628 z$ or $1524 z$ bits when the former or latter commitment scheme is used respectively. The solver's  communication complexity is $O(z)$. Table \\ref{table::puzzle-communication} summarises the communication analysis results.\n \n\n\n \n", "meta": {"hexsha": "629f54b941859937327408e8a132c9dbd172d047", "size": 6444, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/eprint-version/CR-TLP-cost.tex", "max_stars_repo_name": "AydinAbadi/CR-LP", "max_stars_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/eprint-version/CR-TLP-cost.tex", "max_issues_repo_name": "AydinAbadi/CR-LP", "max_issues_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/eprint-version/CR-TLP-cost.tex", "max_forks_repo_name": "AydinAbadi/CR-LP", "max_forks_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 103.935483871, "max_line_length": 1984, "alphanum_fraction": 0.7025139665, "num_tokens": 2140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4085284162294733}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{Fri Dec 13 2019}\n\nThere are two topics left: cosmology and gravitational waves. \nToday and Thursday we do cosmology. \n\n\\section{Cosmology}\n\nNow we introduce the Planck scale: the Compton wavelength is defined by  \n%\n\\begin{align}\n  \\lambda = \\frac{\\hbar c }{E}\n\\,,\n\\end{align}\n%\nwhile the Schwarzschild radius is of the order of \n%\n\\begin{align}\n  r_s \\sim \\frac{GM}{c^2} = \\frac{GE}{c^{4}}\n\\,.\n\\end{align}\n\nSo, we have a quantum gravity regime when \\(\\lambda < r_S\\): when the particle is so localized that it will form a BH by itself. We get: \n%\n\\begin{align}\n  \\frac{\\hbar c}{E} \\approx \\frac{GE}{c^{4}} \\implies\n  E \\approx \\sqrt{\\frac{\\hbar c^{5}}{G}} \\approx \\SI{1.96e9}{J} \\approx \\SI{1.22e19}{GeV}\n\\,.\n\\end{align}\n\nIn \\(c=1\\) units, this is also the Planck mass.\nIt is also useful to define the reduced Planck mass:\n%\n\\begin{align}\n  M_p = \\frac{E_p}{\\sqrt{8 \\pi }} = \\SI{2.43e18}{GeV}\n\\,.\n\\end{align}\n\nNatural units are ones in which \n\\begin{enumerate}\n    \\item \\(c=1\\): velocities are dimensionless: then the unit of length is equal to the unit of time; \n    \\item \\(\\hbar = 1\\): then angular momenta are also dimensionless: then length and time have the dimensions of \\(1/\\text{mass}\\) or \\(1/\\text{energy}\\). \n\\end{enumerate}\n\nIn natural units the Einstein equations look like: \n%\n\\begin{align}\n  G_{\\mu \\nu } = 8 \\pi G T_{\\mu \\nu }\n\\,,\n\\end{align}\n%\nbut \\(M_P = \\frac{1}{\\sqrt{8 \\pi G}}\\): therefore \\(8 \\pi G = 1 / M_P^2\\), so \n%\n\\begin{align}\n  G_{\\mu \\nu } = \\frac{1}{M_P^2} T_{\\mu \\nu }\n\\,.\n\\end{align}\n\nWe are going to discuss the Friedmann-Lemaître-Robertson-Walker metric, which describes a homogeneous and isotropic universe. \n\nHomogeneous means symmetry with respect to translations, isotropic means symmetry with respect to rotations. \n\nSomething which is \\emph{homogeneous but not isotropic} is, for example, the inside of a capacitor. Also, the surface of a cylinder can be an example. \n\nWe can have a space which is \\emph{isotropic but not homogeneous} only around one point, \\emph{global isotropy implies homogeneity}. \n\nWe will also require the condition that the universe be \\emph{spatially flat}. \nIf a triangle has angles \\(\\alpha , \\beta , \\gamma \\) then \\(\\sign ( \\alpha + \\beta +\\gamma -\\pi ) = k\\) is a constant along the space and it measures the curvature of the space. \n\nThe smaller the curvature (and the larger the length scale of the curvature) the more difficult it is to measure what \\(k\\) is. \n\nThe line element in this kind of space is particularly simple, since we can : \n%\n\\begin{align}\n  \\dd{s^2} = - \\dd{t^2} + a^2(t) \\dd{\\vec{x}^2}\n\\,.\n\\end{align}\n\nSince the metric is diagonal, the only nonvanishing Christoffel symbols are \\(\\Gamma^{0}_{ij}\\) and \\(\\Gamma^{i}_{0j}\\), and both must be proportional to \\(\\delta_{ij}\\). \nThese symbols are\n%\n\\begin{align}\n  \\Gamma^{0}_{ij} = \\frac{1}{2} g^{00} \\qty(-g_{ij,0}) = \\delta_{ij} a \\dot{a}\n\\,,\n\\end{align}\n%\nwhere \\(\\dot{a}\\) denotes the derivative of \\(a\\) with respect to coordinate time, while \n%\n\\begin{align}\n  \\Gamma^{i}_{0j} = \\frac{1}{2} g^{ik} \\qty(g_{jk,0}) = \\delta_{ij} a \\dot{a} \\times \\frac{1}{a^2} = \\delta_{ij} \\frac{\\dot{a}}{a}\n\\,.\n\\end{align}\n\nThe trace of the Christoffels are \\(\\Gamma^{0}_{ii} = 3a \\dot{a}\\), and \\(\\Gamma^{i}_{0i} = 3 \\dot{a} / a\\). We want to calculate \\(R_{00} \\), \\(R_{0i}\\) and \\(R_{ij}\\). \nWe have \\(R_{0i} = 0\\) since nothing on the indices depends on space. We also have \\(R_{ij} \\propto \\delta_{ij}\\), since all the Christoffels depend only on \\(\\delta_{ij}\\). \n\nWe have \n%\n\\begin{align}\n  R_{\\mu \\nu } = \\partial_{\\alpha} \\Gamma^{\\alpha }_{ \\mu \\nu } + \\Gamma^{\\lambda }_{\\mu \\nu } \\Gamma^{\\alpha }_{\\lambda \\alpha } - \\partial_{\\nu }\\Gamma^{\\alpha }_{\\mu \\alpha } - \\Gamma^{\\lambda }_{\\mu \\alpha } \\Gamma^{\\alpha }_{\\nu \\lambda }\n\\,.\n\\end{align}\n\nSpecializing to the \\(R_{00} \\) case: \n\\begin{align}\n    R_{0 0 } = \\partial_{\\alpha} \\Gamma^{\\alpha }_{ 0 0 } + \\Gamma^{\\lambda }_{0 0 } \\Gamma^{\\alpha }_{\\lambda \\alpha } - \\partial_{0 }\\Gamma^{\\alpha }_{0 \\alpha } - \\Gamma^{\\lambda }_{0 \\alpha } \\Gamma^{\\alpha }_{0 \\lambda }\n  \\,.\n\\end{align}\n\nThe \\(\\Gamma^{\\alpha }_{00}\\) must vanish. So we get \n%\n\\begin{subequations}\n\\begin{align}\n  R_{00} &= - \\partial_{0} \\Gamma^{i}_{0i} - \\Gamma^{i}_{0j} \\Gamma^{j}_{0i}  \\\\\n  &= - \\partial_{0} \\qty(\\frac{3 \\dot{a}}{a}) - \\frac{\\dot{a}}{a} \\delta_{ij} \\frac{\\dot{a}}{a} \\delta_{ij}  \\\\\n  &= - \\frac{3 \\ddot{a}}{a} + \\frac{3 \\dot{a}^2}{a^2} \n  - 3 \\frac{\\dot{a}^2}{a^2} = - 3 \\frac{\\ddot{a}}{a}\n\\,.\n\\end{align}\n\\end{subequations}\n\nOn the other hand we have \n%\n\\begin{subequations}\n\\begin{align}\nR_{i j } &= \\partial_{\\alpha} \\Gamma^{\\alpha }_{ i j } + \\Gamma^{\\lambda }_{i j } \\Gamma^{\\alpha }_{\\lambda \\alpha } - \\cancelto{}{\\partial_{j }\\Gamma^{\\alpha }_{i \\alpha }} - \\Gamma^{\\lambda }_{i \\alpha } \\Gamma^{\\alpha }_{j \\lambda }  \\\\\n&= \\partial_{0} \\Gamma^{0 }_{ i j } \n+ \\Gamma^{\\lambda }_{i j } \\Gamma^{\\alpha }_{\\lambda \\alpha }\n- \\Gamma^{\\lambda }_{i \\alpha } \\Gamma^{\\alpha }_{j \\lambda }\n\\\\\n&= \\qty(a \\ddot{a} - \\dot{a}^2)  \\delta_{ij}\n+ 3 a^2 \\delta_{ij} - \\dot{a}^2 \\delta_{ij} - \\dot{a}^2 \\delta_{ij}  \\\\\n&= a^2 \\delta_{ij} \\qty(\\frac{\\ddot{a}}{a} + 2 \\frac{\\dot{a}^2}{a^2})\n\\,.\n\\end{align}\n\\end{subequations}\n\nSo we have the whole of the Ricci tensor. \nThe scalar curvature is given by \n%\n\\begin{subequations}\n\\begin{align}\n  R &= g^{00} R_{00} + g^{ij} R_{ij}  \\\\\n  &= + 3 \\frac{\\ddot{a}}{a} + \\delta_{ij} \\frac{a^2}{a^2} \\delta_{ij}  \\qty( 2 \\frac{\\dot{a}^2}{a^2} + \\frac{\\dot{a}}{a})  \\\\\n  &= 6 \\frac{\\dot{a}^2}{a^2} + \\frac{6 \\ddot{a}}{a}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand we have \n%\n\\begin{align}\n  G_{00 } = R_{00} - R g_{00} = - 3\\frac{\\ddot{a}}{a}\n  + 3 \\frac{\\dot{a}^2}{a^2} + 3 \\frac{\\ddot{a}}{a} = \\frac{3 \\dot{a}^2}{a^2}\n\\,,\n\\end{align}\n%\nwhile \n%\n\\begin{subequations}\n\\begin{align}\n  G_{ij} &= R_{ij} - Rg_{ij} \\\\\n  &= a^2 \\delta_{ij} \\qty(\\frac{\\ddot{a}}{a} + 2 \\frac{\\dot{a}^2}{a^2}) - \\frac{3 \\dot{a}^2}{a^2} a^2  \\\\\n  &= a^2 \\delta_{ij} \\qty(- \\frac{\\dot{a}^2}{a^2} - \\frac{2 \\ddot{a}}{a})\n\\,.\n\\end{align}\n\\end{subequations}\n\nFor the SEM tensor we choose a perfect fluid: \\(T^{\\mu \\nu } = \\rho u^{\\mu } u^{\\nu }  + p h^{ \\mu \\nu }\\), where \\(h^{\\mu \\nu } = u^{ \\mu }  u^{\\nu } + g^{ \\mu \\nu }\\) is the projector on the space orthogonal to the velocity. \n\nWe know that, in the expression of \n%\n\\begin{align}\n  u^{\\mu } = \\qty(\\dv{t}{\\tau }, \\dv{\\vec{x}}{\\tau })^{\\top}\n\\,,\n\\end{align}\n%\nthe compontent \\(u^{0}\\) must be positive. We have \n%\n\\begin{align}\n  0 = G_{0i} = \\frac{T_{0i} }{M_P^2}\n\\,,\n\\end{align}\n%\nbut this means that \\(u^{i}\\) must be zero. \\emph{The cosmic fluid is at rest}. This means that we are selecting a special frame: the rest frame of the cosmic fluid, the rest frame of the CMB. \n\nWhen we look at the CMB we see a large dipolar contribution, due to the motion of the Earth with respect to the cosmic fluid. \nThe theory is globally Lorenz-invariant, however its realization is not. This means that \\(u^{0} = 1\\), since \\(g_{00} = -1\\). \n\nThis means that \\(h^{\\mu \\nu } = a^2 \\delta^{ij}\\) (informal, I mean that the only nonzero components are the spatial ones.)\n\nThen \\(T_{00} = \\rho \\), and \\(T_{ij} = a^2 \\delta_{ij} P\\). \n\nSo the EFE are: \n%\n\\begin{subequations}\n\\begin{align}\n  \\frac{3 \\dot{a}^2}{a^2} &= \\frac{\\rho }{M_P^2}  & \\text{00 equation}\\\\\n  - 2 \\frac{\\ddot{a}}{a} - \\frac{\\dot{a}^2}{a^2} &=\n  \\frac{P}{M_P^2} & \\text{ij equations}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere we factored out the \\(a^2 \\delta_{ij}\\) in the \\(ij\\) equations. \n``Just for fun'' we discuss the Bianchi identities: \\(\\nabla_{\\mu } G^{\\mu \\nu }=0\\). \nIf \\(\\nu =0\\) we have \n%\n\\begin{align}\n  \\partial_{\\mu } G^{\\mu 0} + \\Gamma^{\\mu }_{\\mu \\lambda } G^{\\lambda 0} + \\Gamma^{0}_{\\mu \\lambda } G^{\\mu \\lambda } = 0\n\\,,\n\\end{align}\n%\nbut simplifying the indices we get \n%\n\\begin{align}\n  \\partial_{0} G^{00} + \\Gamma^{i}_{i0} G^{00} + \\Gamma^{0}_{ij} G^{ij} =0\n\\,,\n\\end{align}\n%\nand substituting in the expressions we have we get \n%\n\\begin{subequations}\n\\begin{align}\n  &\\partial_{0} \\qty(\\frac{3 \\dot{a}^2}{a^2})\n  + \\frac{3 \\dot{a}}{a} \\frac{3 \\dot{a}^2}{a^2}\n  + a \\dot{a} \\delta_{ij} \\frac{1}{a^2} \\delta_{ij}\n  \\qty(- \\frac{2 \\ddot{a}}{a} - \\frac{\\dot{a}^2}{a^2}) \\\\\n  = & 6 \\frac{\\dot{a}}{a} \\qty(\\frac{\\ddot{a}}{a} - \\frac{\\dot{a}^2}{a^2})\n  + 9 \\frac{\\dot{a}^3}{a^3} - 6 \\frac{\\dot{a}}{a} \\frac{\\ddot{a}}{a} - 3 \\frac{\\ddot{a}^3}{a^3} = 0 \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhich confirms what we already knew. Verifying \\(\\nabla_{\\mu} G^{\\mu i } = 0\\) is easier:  \n%\n\\begin{align}\n    \\partial_{\\mu } G^{\\mu i} + \\Gamma^{\\mu }_{\\mu \\lambda } G^{\\lambda i} + \\Gamma^{i}_{\\mu \\lambda } G^{\\mu \\lambda } = 0\n\\,,\n\\end{align}\n%\nbecause all three of the terms vanish immediately. \n\nCorrespongingly, we have \\(\\nabla_{\\mu } T^{\\mu \\nu } =0 \\). \nThis is a local conservation law, not a global one generally since we do not have 4 Killing vectors. \nIf \\(\\nu =0\\) we have \n%\n\\begin{subequations}\n\\begin{align}\n  &\\partial_{\\mu } T^{\\mu 0} + \\Gamma^{\\mu }_{\\lambda \\lambda  } T^{\\lambda 0} + \\Gamma^{0}_{\\mu \\lambda } T^{\\mu \\lambda } = \\\\\n  =& \\partial_{0} T^{00} +\n  \\Gamma^{i}_{i0} T^{i0} + \\Gamma^{0}_{ij} T^{ij} \\\\\n  =& \\partial_{0} \\rho \n+ 3 \\frac{\\dot{a}}{a} \\rho + \\dot{a} a \\delta_{ij} \\frac{1}{a^2} \\delta_{ij} P \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhich means \n%\n\\begin{align}\n  \\dot{\\rho} + 3 \\frac{\\dot{a}}{a} ( \\rho +P) = 0\n\\,,\n\\end{align}\n%\nwhich we can add to the other equations. \n\nIt is easier to study the case \\(\\nu = i\\): we get \n%\n\\begin{align}\n    &\\partial_{\\mu } T^{\\mu i} + \\Gamma^{\\mu }_{\\lambda \\lambda  } T^{\\lambda i} + \\Gamma^{i}_{\\mu \\lambda } T^{\\mu \\lambda } = 0\n\\,,\n\\end{align}\n%\nsince all three terms vanish immediately. Since the conservation  equation \\(\\nabla_{\\mu } T^{\\mu 0}\\) comes from the Einstein equations, we should be able to derive it from the first two Friedmann equations: differentiating the 00 one we get \n%\n\\begin{align}\n  6 \\qty(\\frac{\\dot{a}}{a} - \\frac{\\dot{a}^2}{a^2}) = \\dot{\\rho} M_P^{-2} \n\\,,\n\\end{align}\n%\nwhile for the second one, multiplying by \\(3 \\dot{a} / a\\), we get \n%\n\\begin{align}\n  - 6 \\frac{\\dot{a}}{a} \\frac{\\ddot{a}}{a}\n  - 3 \\frac{\\dot{a}^3}{a^3} = \\frac{3 \\dot{a}}{a } P M_P^{-2}\n\\,.\n\\end{align}\n\nAdding them together we find \n%\n\\begin{align}\n  - 9 \\frac{\\dot{a}^3}{a^3} = M_P^{-2} \\qty( \\dot{\\rho} + 3 \\frac{\\dot{a}}{a }P )\n\\,,\n\\end{align}\n%\nand from the first FE we have \n%\n\\begin{align}\n  9 \\frac{\\dot{a}^3}{a^3} = 3 \\frac{\\dot{a}}{a} \\rho M_P^{-2}\n\\,,\n\\end{align}\n%\nso we get \n%\n\\begin{align}\n  \\dot{\\rho}\n + 3 \\frac{\\dot{a}}{a} \\qty(\\rho +P) = 0  \n\\,.\n\\end{align}\n\nSo, since the equations are not independent, we consider  only two of the three. It is convenient to use the first and the third since they have no second derivatives.  \n\nWhat sources do we put for the equations? First of all, commonly we do \\(w = P / \\rho \\), and sometimes we do \\(w = -1\\): this means \\(\\rho = \\const\\). \nThis corresponds to \\emph{vacuum energy}, associated with the space itself: it does not scale inversely with the volume. \n\nWe can have vacuum energy: ``vacuum'' just means we are in a minimum of the potential. Mexican hats and stuff. \n\nIn principle, the EFE can be modified in a simple way: \n%\n\\begin{align}\n  G_{\\mu \\nu } + \\Lambda g_{\\mu  \\nu } = \\frac{T_{\\mu \\nu }}{M_P^2}\n\\,,\n\\end{align}\n%\nsince the metric is covariantly constant. This can be interpreted as a \\emph{constant negative energy density}: It would look like \n%\n\\begin{align}\n  T_{\\mu \\nu } \\rightarrow T_{\\mu \\nu } + \\Lambda M_P^2 g_{\\mu \\nu }\n\\,.\n\\end{align}\n\nThen we have \n%\n\\begin{align}\n  G_{00} = \\frac{1}{M_P^2} \\qty(\\rho + \\Lambda M_P^2)\n\\,,\n\\end{align}\n%\nand \n%\n\\begin{align}\n  G_{ij} = \\frac{1}{M_P^2} \\qty(a^2 \\delta_{ij} p - \\Lambda M_P^2a^2 \\delta_{ij})\n\\,.\n\\end{align}\n\nSo, we have \n%\n\\begin{align}\n  \\frac{P_{\\Lambda }}{\\rho_{\\Lambda }} = w_{\\Lambda } = -1\n\\,.\n\\end{align}\n\nThis ratio between pressure and density is characteristic of a cosmological constant. \n\n\\end{document}", "meta": {"hexsha": "c0b25e1c63dc0c88f9c72fcbee73655b8d2fd8af", "size": 12024, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/13dec.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/13dec.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/13dec.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 33.5865921788, "max_line_length": 243, "alphanum_fraction": 0.6126081171, "num_tokens": 4637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4085284124467393}}
{"text": "\\chapter{Background}\n\n\\section{State of the Art}\n\n\\subsection{A very short history of Machine Learning}\n``You have to know the past to understand the present.'' - Carl Sagan\n\nThe early beginnings of Machine Learning come not after the first electronic \ncomputers or after the first computer programs, as many may believe so. The \nfundamentals of this field took shape centuries ago with the discovery of the \nso-called Conditional Probability theories. {\\bf Bayes Theorem}, named after Thomas \nBayes who first proposed a mathematical model for infering probabilities of \nconditioned events, and further developed by Pierre-Simon Laplace in his essay \n\\footnote{Théorie Analytique des Probabilités} in 1812, can be seen as one of the first models \nthat can ``learn'' from given data and predict events based on correlated past events.\nAnother old discovery that is the basis of today's regression models (e.g.: \nLinear Regression) is the ``least squares method'', credited to Carl Gauss, but \nfirst published by Adrien-Marie Legendre in 1805. This method was first applied in \nastronomy and allowed explorers to navigate oceans by aproximating the movement of \ncelestial bodies.\n\nLater on, in 1950, Alan Turing proposed in his paper\\footnote{Turing, A.M. (1950). \nComputing machinery and intelligence. Mind, 59, 433-460.} a {\\it learning machine} \nthat is able to learn and become intelligent and do well in the {\\bf Imitation Game} \n(now generally called the {\\bf Turing Test}). \n\nAfter this, the discovery of the Percetron and the {\\bf Neural Networks} around 1960s drew \nsome attention in the field, but their current limitations had put Machine Learning on an \nimpeding state for almost 10 years. It was only with the invention of the \nbackpropagation algorithm in 1974 by Paul Werbos and the demonstration of its \ngeneralization by Geoffrey Hinton in 1986, that allowed it to be applied in \nmulti-layered artificial neural networks. This also gave birth to a new sub-field \nof Machine Learning that today is called {\\bf Deep Learning.}\n\nAlong with the research in neural networks, some other models that were developed in that \nperiod are worth to mention. The most important ones are Support Vector Machines and kernels \n(models used for data classification and regression, that can be more time-efficient \nthan neural networks are and provide good performance from a data perspective) and Decision Trees. \nThe latter, in combination with Ensemble Methods helped researchers invent models like \n{\\bf Random Forests} and {\\bf Adaptive Boosting} that are now state-of-the-art \nalgorithms for tree models used for a lot of tasks.\n\n\\subsection{Current interests in the field}\n\nComing back to Deep Learning, which is today's main subject of interest of the \nMachine Learning community, it is a general approach that combines several state-of-the-art \nmodels of Machine Learning to solve problems such as image classification, AI for \ncomputer games, natural language, etc. Its constituents include neural networks with many \nhidden layers, convolutional networks, deep belief networks and recurrent networks. \nAlso, the Q-Learning algorithm\\footnote{Watkins, C.J.C.H. (1989). Learning from Delayed Rewards. \nPhD thesis, Cambridge University, Cambridge, England} and the Monte-Carlo search used \nin combination with convolutional networks allowed researchers to build semi-supervised \nlearning programs that could learn to play computer games by themselves\\footnote\n{https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf} or beat professional human players at \ngames, such as Go (Google AlphaGo's program first beat Lee Sedol in October 2015). \n\n\\subsection{Trends in educational learning}\n\nAll advances in the Machine Learning field also conducted in an incresing interest in \neducational learning and assessment. With the name of {\\bf Educational Data Mining}, \nthis newly emerging discipline deals with studying machine learning and data mining \nmodels in order to gain important knowledge about the structure of an educational \nsystem data (final grades, performance indicators, course drop-outs). Educational \ndata can be taken from schools and universities (the classical way and also, the way \nthat this thesis explores), online courses (such as MOOCs\\footnote{Massive Open \nOnline Courses}), or even collaborative learning.\n\nWith the use of Machine Learning techniques, student can better decide on what courses \nthey could take (based on past related grades), whether they have a chance or not to \npass an exam before taking it and what indicators are relevant to their final asessment. \nThe course department also benefits from the ``learned'' data because it helps them \nto better plan the structure of their courses, whether they are on-line or taken at \nthe university.\n\n\\section{Related Work}\n\nThis part of the chapter will focus on the work on other people about the study \non student performance prediction and analysis. Some of their research is similar \nto that of this thesis, and some others treat only related issues. \n\n(Mehdi Sajjadi et al., 2016)\\cite{bibl_1} did some work on approximating final grades \nof students in a course on algorithms. In the grading process they used the peer \ngrading method\\footnote{A process in which students grade work of other students \nbased on a given guideline}, and then applied Machine Learning (both supervised and \nusupervised) to aggregate those grades into a final grade. Their results were \nnot so good compared to the simple method of just using the mean of all peer grades \nper an assessment as the final grade. \n\n(Siddharth Reddy et al., 2015)\\cite{bibl_2} worked on developing a representational \nmodel of combined students and educational content (assessments and lessons). \nThis representation is actually a semantic space\\footnote{Semantic similarity \nbetween objects represented as a kind of ``metric'' in space} and it can be used \nto study the relation between course content and students. Several conclusions can \nbe drawn from these representations, such as: probability of passing an assessment \nor course and knowledge gained from completing a lesson. This article aimed mostly \nat MOOCs platforms, like Coursera, EdX and Khan Academy, and the model described \nwas tested on synthetic student data and also, on real data from Knewton.\nTheir model's results can be used to personalize the learning process of a course \nfor each student in order to maximize the educational performance. Also, this \nmodel successfully predicted assessment results.\n\n(Michael Wu, 2015)\\cite{bibl_2_1} wrote an interesting Master Thesis in which \ndescribes a Machine Learning Model that simulates MOOC data. Working with data \ngathered from EdX, the model once trained, can be able to synthesize student data.\nThe model was trained to learn about student types, habits and difficulty of course \nmaterials. One of the main results of the thesis was being able to classify \nstudents in 20 important clusters.\n\n(Saeed Hosseini Teshnizi and Sayyed Mohhamad Taghi Ayatollahi, 2015)\\cite{bibl_3} \ndid a comparasion between Logistic Regression and ANNs\\footnote{Artificial \nNeural Networks} on a dataset composed of 275 undergraduate students and 16 \nstudent characteristics (e.g.: age, gender, parent education, employment status, \nplace of residence, etc.) in order to predict academic failure. They concluded that \nthe neural network models had a better accuracy than Logistic Regression (84.3\\% \nversus 77.5\\%). They tested 9 ANNs from which the one with 15 neurons in the \nhidded layer provided the best results, so ANNs methods were appropiate to be used \nin their problem. \n\nOther references\\cite{bibl_4},\\cite{bibl_5},\\cite{bibl_6} also treat prediction \nof student academic performance mostly with neural networks and provide good \naccuracy with this model (the accuracy is also dependent of the structure of \nthe dataset, number of examples, number of characteristics and noise in the \ndata).\n\n(Emaan Abdul Majeed and Khurum Nazir Junejo)\\cite{bibl_7} had some great results \nusing Machine Learning models for predicting student's performance. They claim \nthat they were capable of predicting the final grade with an accuracy of 96\\%. \nWith a final number of 2500 student records and about 10 attributes for each \nrecord, they managed to predict the value of the final Grade attribute (which \nis a Class Variable that can have 6 values: A, B+, B, C+, C, Fail). \nFour classifier models were used in their study and we can see in Figure \n\\ref{fig.figure1}\\cite{bibl_7} their performance: \n\n\\insfigshw{figure1.png}%\n    {Classifiers accuracy}%\n    {Classifiers accuracy}%\n    {fig.figure1}{0.8}\n", "meta": {"hexsha": "54a0f5b5d616d4a23f23342c570ae67cdf5de816", "size": 8645, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chapter2.tex", "max_stars_repo_name": "c-m/Licenta", "max_stars_repo_head_hexsha": "176a8f6209a2f9cb882a505cb5136c3c06cad3cc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chapter2.tex", "max_issues_repo_name": "c-m/Licenta", "max_issues_repo_head_hexsha": "176a8f6209a2f9cb882a505cb5136c3c06cad3cc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chapter2.tex", "max_forks_repo_name": "c-m/Licenta", "max_forks_repo_head_hexsha": "176a8f6209a2f9cb882a505cb5136c3c06cad3cc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.6449275362, "max_line_length": 99, "alphanum_fraction": 0.796529786, "num_tokens": 1918, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.408520032416304}}
{"text": "%!TEX root = thesis.tex\n\n\\chapter{Deriving stellar parameters}\n\\label{cha:method}\n\\epigraph{The best way to learn is by doing. The only way to build a strong work ethic is getting\n          your hands dirty.}{Alex Spanos}\n\nThere are different methods for obtaining stellar atmospheric parameters. Here follows a short\ndescription of some of the most common methods, however the spectroscopic method will be explained\nin much greater detail later in this chapter.\n\n\n\\section{Photometry}\n\nPhotometry can be used in different ways to estimate the effective temperature. In this section two\nmethods will be mentioned; a colour calibration, and asteroseismology. There are other methods, e.g.\nSED fitting but this will not be discussed further.\n\n\\subsection{InfraRed Flux Method - IRFM}\n\\label{sec:irfm}\n\nThe InfraRed Flux Method (IRFM) was first described by \\citet{Blackwell1977}. From IRFM it is\npossible to measure the stellar radius and $T_\\mathrm{eff}$ with a measurement of the angular\ndiameter, $\\theta$, derived from infrared photometry. $T_\\mathrm{eff}$ is derived from the angular\ndiameter from the simple relation\n\\begin{align}\n  \\sigma T_\\mathrm{eff}^4 = \\frac{4\\mathcal{F}_E}{\\theta^2}, \\label{eq:irfm}\n\\end{align}\nwhere $\\mathcal{F}_E$ is the monochromatic flux measured at Earth, and $\\sigma$ is Boltzmann's\nconstant. The angular diameter is calculated from the following equation:\n\\begin{align}\n  \\theta = 2\\sqrt{\\mathcal{F}_E/\\mathcal{F}_S},\n\\end{align}\nwhere $\\mathcal{F}_S$ is the calculated monochromatic flux from the star. This flux is based on a\nmodel atmosphere with an effective temperature based on the spectral energy distribution (SED). The\ncalculated flux show a strong dependence on $T_\\mathrm{eff}$ in the visible, however this dependence\nis much weaker in the infrared. Hence a poor first estimation of $T_\\mathrm{eff}$ will lead to a\nreliable angular diameter. From this new angular diameter $T_\\mathrm{eff}$ can be re-derived, a new\nmodel atmosphere can be used with a new set of $\\mathcal{F}_S$ can be calculated. Iteratively the\nangular diameter and $T_\\mathrm{eff}$ can be calculated. If the distance $d$ is known of the star,\nthe stellar radius is $R_\\ast = \\frac{\\theta d}{2}$. The solar flux, both measured and calculated,\nfrom \\citet{Blackwell1977} are shown in \\fref{fig:IRFM}. Using the data provided the solar radius\nand $T_\\mathrm{eff}$ were derived using the equations above: $R=1.011R_\\odot$ and\n$T_\\mathrm{eff}=\\SI{5963}{K}$. This was simply done for each wavelength, and the results presented\nhere are just a simple average value.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{figures/IRFM.pdf}\n    \\caption{Measured and calculated flux from the Sun at infrared wavelengths. Data from Table 2 in\n             \\citet{Blackwell1977}. Mean solar radius from this data is $1.011R_\\odot$, and mean\n             solar $T_\\mathrm{eff}=\\SI{5963}{K}$ using \\eref{eq:irfm}.}\n    \\label{fig:IRFM}\n\\end{figure}\n\nThe main drawbacks of the IRFM is the model dependence, a drawback many methods share, and the need\nof high precision infrared photometry. For the model atmosphere a metallicity and surface gravity is\nassumed which has an effect on $\\mathcal{F}_S$, and hence on the final derived $T_\\mathrm{eff}$ and\n$R$. A more in-depth description of the IRFM can be see in e.g. \\citet[][section 4]{Casagrande2006}.\n\n\n\\subsection{\\texorpdfstring{$T_\\mathrm{eff}$}{Teff}-colour-\\texorpdfstring{$[\\ion{Fe}/\\ion{H}]$}{[Fe/H]} calibration}\n\nPhotometry can be used for deriving $T_\\mathrm{eff}$ using existing colour calibrations like that of\nfor example \\citet{Ramirez2005a} where adopted $T_\\mathrm{eff}$ and $[\\ion{Fe}/\\ion{H}]$ in\ncombination with colours $X$ such as $B-V$, $V-S$, etc. are used to fit a polynomial such that the\n$T_\\mathrm{eff}$ can easily be estimated with a simple relation:\n\\begin{align}\n  \\theta_\\mathrm{eff} = a_0+a_1 X+a_2 X^2+a_3X[\\ion{Fe}/\\ion{H}] + a_4[\\ion{Fe}/\\ion{H}] + a_5[\\ion{Fe}/\\ion{H}]^2, \\label{eq:irfm}\n\\end{align}\nwhere $\\theta_\\mathrm{eff}=5040/T_\\mathrm{eff}$. A polynomial fit was performed on the residuals in\norder to deal with spectroscopic features such as the Balmer lines, the Paschen jump, etc. This\npolynomial fit, $P(X, [\\ion{Fe}/\\ion{H}])$ is added to \\eref{eq:irfm} so the calibration finally\nreads:\n\\begin{align}\n  T_\\mathrm{eff} = \\frac{5040}{\\theta_\\mathrm{eff}} + P(X, [\\ion{Fe}/\\ion{H}]),\n\\end{align}\n\nAfter obtaining the coefficients ($a_i$) for different combinations of colours, it is trivial to\nobtain $T_\\mathrm{eff}$ if the metallicity and a colour is known of the star.\n\n\\subsection{Asteroseismology}\n\\label{sec:asteroseismology}\n\nAsteroseismology is the study of stellar pulsations. For main sequence stars (which will be the only\nfocus here), these pulsations propagate as sounds waves throughout a star, their origin and\namplitude is determined by the characteristics of the star. Hence the study of the pulsations, which\nare seen on the surface, will thus be a study of the stellar properties. In order to to study these\na time series is needed. This can both be radial velocities as it was used in the recent results\nfrom the SONG telescope \\citep{Grundahl2017}, or photometry like the numerous results from e.g. the\nspace telescopes \\emph{CoRoT} and \\emph{Kepler} \\citep[see\ne.g.][]{Christensen-Dalsgaard2010,Chaplin2011,Huber2014}. The analysis is identical for either time\nseries, however the amplitudes in the power spectrum will be different.\n\nAfter determining the frequencies of a range of pulsations from a power spectrum of the time series,\na pattern emerge at every $\\Delta\\nu$ (the so-called large frequency separation). A finer pattern\nalso occur described by $\\delta\\nu$. Last the frequency at maximum power is also measured from the\npower spectrum, $\\nu_\\mathrm{max}$. The frequency at maximum power is used to obtain $\\log g$ via\n\\begin{align}\n  \\nu_\\mathrm{max} &\\propto \\frac{g}{\\sqrt{T_\\mathrm{eff}}} \\\\\n                   &= \\frac{M/M_\\odot}{(R/R_\\odot)^2 \\sqrt{T_\\mathrm{eff}/5777}}\\; \\SI{3.05}{mHz},\\label{eq:scaling1}\n\\end{align}\nwhere $\\nu_{\\mathrm{max},\\odot}=\\SI{3.05}{mHz}$ is the frequency of maximum amplitude for the Sun. A\nsimilar equation exists for the determination of the stellar density:\n\\begin{align}\n  \\Delta\\nu = (M/M_\\odot)^{-1/2} (R/R_\\odot)^{-3/2}\\; \\SI{134.9}{\\micro\\hertz}.\n\\end{align}\nThese simple scaling relation are described in detail in \\citet{Kjeldsen1995} for main sequence\nstars. These two equations can be used together to determine the mass and radius of the star, often\nto a high precision. These scaling relations are applicable for stars which shows solar-like\noscillations, mostly found in main sequence FGK stars, but can also be found in red giant stars. The\nmass and radius for a range of $\\nu_\\mathrm{max}$ and $\\Delta\\nu$ can be seen in \\fref{fig:scaling},\nwhere $T_\\mathrm{eff}=\\SI{5777}{K}$. The star located at $\\{\\Delta\\nu=\\SI{134.9}{\\micro\nHz};\\;\\nu_\\mathrm{max}=\\SI{3.05}{mHz}\\}$ is the Sun.\n\nThe small frequency separation, $\\delta\\nu$, is sensitive to the sound-speed gradient in the core\nwhich in turn is sensitive to the composition. Thus the small frequency separation is a very\nimportant diagnostic for stellar evolution. An interesting case is that of \\citet{Bedding2011},\nwhere it was shown it is possible to distinguish between hydrogen- and helium-burning cores in red\ngiant stars.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{figures/scaling_relation.pdf}\n    \\caption{Mass and radius from asteroseismic scaling relation. The colour is the mass and radius\n             for the upper and lower panel, respectively. The location of the Sun is added for\n             reference.}\n    \\label{fig:scaling}\n\\end{figure}\n\nA drawback of asteroseismology is the dependence of $T_\\mathrm{eff}$ in \\eref{eq:scaling1} which has\nto be provided from another method. Ideally this will come from spectroscopy for which the\ndetermination of $T_\\mathrm{eff}$ is often reliable. This drawback is minor compared to the weak\nmodel dependence which is one of the strongest advantages of asteroseismology.\n\nFor both of the mentioned photometric methods to determine some atmospheric parameters a\ndisadvantage is the dependence on the knowledge of other atmospheric parameters which usually comes\nfrom spectroscopy (e.g. metallicity). However, as will be discussed in\n\\sref{sec:method_spectroscopy} $\\log g$ is often difficult to determine reliably and synergies are\nwelcomed between different methods.\n\n\\section{Spectroscopy}\n\\label{sec:method_spectroscopy}\n\nA spectrum can be analysed with a range of different methods. The method finally chosen depend on\nquality of the spectrum, i.e. high/low resolution and high/low S/N, the spectral type of the star,\nthe region that was observed, e.g. UV, optical, NIR, etc., some stellar properties, e.g.\nfast-rotator, activity, etc. In practise, no methods work for all cases, but sometime several\nmethods can be used for on case.\n\nSince this thesis is focused on FGKM stars, and mainly dwarfs, three methods will be described;\nsynthesis, spectral indices, and the EW method. The latter method will be described in a separate\nsection since this is the main method used for the analysis in this thesis.\n\n\n\n\\subsection{Synthesis}\n\\label{sec:synthesis}\n\nThe synthesis fitting method is a standard method for obtaining stellar atmospheric parameters from\na wide range of spectra, that is with different spectral resolution, spectral parameters such as\n$T_\\mathrm{eff}$, $\\log g$, $v\\sin i$ the projected rotational velocity, etc., and S/N  \\citep[see\ne.g.][]{Tsantaki2017}. The synthetic fitting method is in simple terms a comparison between the\nobserved spectrum and a synthetic spectrum, which is either calculated on the fly like Spectroscopy\nMade Easy (SME) \\citep{Valenti1996}, or using a pre-calculated grid like Starfish\n\\citep{Czekala2015}. By analysing the\n\\begin{align}\n  \\chi^2 = \\sum_i^N\\frac{(y_\\mathrm{obs,i}-y_\\mathrm{model,i})^2}{\\sigma_i},\n\\end{align}\nthe synthetic spectrum that best match the observed spectrum can be found. Here the $y_\\mathrm{obs}$\nis the observed spectrum, $y_\\mathrm{model}$ is the synthetic spectrum, and $\\sigma$ is the error on\nthe measurement.\n\nThe synthetic fitting can be done by utilising small windows around sensitive spectral features such\nas ionized lines or hydrogen lines for obtaining the surface gravity, iron lines for obtaining the\neffective temperature, a series of different atomic lines for obtaining the overall metallicity.\nThis approach is used by \\code{SME} and \\code{FASMA}\n\\citep[][respectively]{Valenti1996,Tsantaki2017} and is a compromise between fitting the entire\nspectral range and calculating the synthetic spectra on the fly which is time consuming. On the\nother hand the entire spectrum can be fitted if a pre-calculated grid of synthetic spectra are\navailable. By masking small windows, one can also exclude different features that are troublesome,\nthis can be telluric lines, bad reduction of the spectra, or real spectral features where there\ncurrently is poor atomic/molecular data such as the oscillator strength and thus it is not possible\nto reliably fit this feature.\n\nThis method is affected by the different approaches one can use, that is which atmosphere models are\nused (ATLAS, MARCS, etc.), atomic data and whether this has been calibrated, the radiative transfer\ncode in the case the synthetic spectra are calculated on the fly, and the minimization procedure\nchosen. With these things in mind it is important to stress the wide range spectra and spectral\nclasses this method works with.\n\nThe advantage of the synthetic fitting method over the curve-of-growth analysis (see\n\\sref{sec:parameters}) is that it allows for the analysis of lower resolution and with a higher\nrotational velocity, $v\\sin i$.\n\n\n\\subsection{The EW method and \\code{FASMA}}\n\\label{sec:parameters}\n\nThe EW method or curve-of-growth analysis is another standard method for obtaining stellar\natmospheric parameters from spectra as the synthetic fitting method (\\sref{sec:synthesis}). Since\nthis is the method used throughout this thesis it will be explained in detail. This analysis follow\na chain of tasks, each has been made automatic in the software ``Fast Analysis of Spectra Made\nAutomatically\" (\\code{FASMA}\\footnote{Greek for spectrum}) which was developed during this thesis\n\\citep{Andreasen2017a}. \\code{FASMA} is made of three \\code{drivers}:\n\\begin{enumerate}\n  \\item EW measurement driver\n  \\item Obtain stellar atmospheric parameters driver\n  \\item Abundance driver\n\\end{enumerate}\nAn additional driver is under development; a synthetic fitting driver \\citep{Tsantaki2017}.\n\\code{FASMA} has been made available to the community via a web application at\n\\url{http://www.iastro.pt/fasma/}.\n\n\n\\subsubsection{Ingredients}\n\n\\code{FASMA} is written in the Python programming language and glue together other software and\nmodel atmospheres necessary for obtaining stellar atmospheric parameters from high quality spectra.\nThese software and models are described in greater detail in the following sections. In short, the\ncurve-of-growth analysis require measured EWs where the latest version\\footnote{The latest version\ncan be found here: \\url{https://github.com/sousasag/ARES}} of \\code{ARES} is used\n\\citep{Sousa2015a}. These EWs are used to derive line abundances using model atmosphere like the\nATLAS9 \\citep{Kurucz1993}, MARCS models \\citep{Gustafson2008}, or PHOENIX models\\footnote{The\nPHOENIX models are currently not a part of \\code{FASMA}, however it is planned to implement these\nmodels with \\code{MOOG}.} \\citep{Husser2013} to mention the most popular for this analysis. Note that the\nPHOENIX models are relative new and not as widely used yet. In tandem with model atmospheres a\nradiative transfer code is also needed. \\code{FASMA} uses \\code{MOOG} \\citep{Sneden1973} for this.\nThe model atmosphere usually comes in a pre-calculated grid in the $\\{T_\\mathrm{eff},\\,\\log\ng,\\,[\\ion{Fe}/\\ion{H}]\\}$ parameter space. These are interpolated in order to access the requested\ncombination of parameters. Last, \\code{FASMA} consist of a minimization routine which looks for the\nbest matching parameters given a spectrum.\n\n\n\n\\subsubsection{Wrapper for \\code{ARES}}\n\\label{sec:measureEW}\n\nThere are two ways to measure the EW of an absorption line, ``manually'' or automatically. There are\nadvantages and disadvantages for both approaches: For the manual, an advantage is that we can\ninspect the lines and try to measure lines in different ways (which is useful if a absorption line\nis blended). We have more control over how blended lines are fitted, and which profiles are used.\nDisadvantages are that it is very time consuming, and it is prone to errors, as a measurement might\nchange drastically by the eyes measuring it. Even for the same person, the measurement can change.\nBy mentioning the advantages and disadvantages of the manual method, it should be clear that the\nadvantages and disadvantages of the automatic method is the opposite of those. Especially the time\nto measure the lines are orders of magnitudes faster, which is crucial when dealing with more than a\nhandful of spectra. However, most important is the fact that the EWs of the lines are measured\nconsistently throughout the entire spectral range, allowing a homogeneous analysis of the lines.\n\nWhen a line is measurement by hand (manually) it is in this thesis done using the \\code{splot}\ncommand in \\code{IRAF}. Here the deblending mode is used whenever necessary. It is often necessary\nto fit one spectral lines with several Gaussians, as neighbouring lines might contaminate the line\nof interest.\n\n\nThroughout this thesis line EWs are automatically measured with \\code{ARES}\n\\citep{Sousa2007,Sousa2015a}. When using \\code{ARES} it is important to use a correct value of the\n\\code{rejt} parameter. This parameter is used for placing the continuum level, and is thus directly\nrelated to the final measurement EW. It is difficult to get this parameter right, however the newest\nversion of \\code{ARES} has the option to analyse a few absorption free regions and measure the S/N.\nThe \\code{rejt} is then calculated as: \\begin{align*} \\mathtt{rejt} = 1 - \\frac{1}{\\mathrm{S/N}}.\n\\end{align*}\n\n\\code{ARES} is used via the first driver of \\code{FASMA}. All the options available for \\code{ARES}\ncan be accessed by \\code{FASMA}. The options are\n\\begin{itemize}\n  \\item Setting the spectral window, $\\lambda_\\mathrm{min}$ and $\\lambda_\\mathrm{max}$\n  \\item RV correction to be applied or a mask to measure the RV and automatic make this correction\n  \\item Minimum and maximum EW to be considered ($\\SI{5}{m\\angstrom}$ and $\\SI{150}{m\\angstrom}$\n        respectively by default)\n  \\item Minimum acceptable distance between two consecutive lines\n  \\item Smoothing applied with a \\code{boxcar} filter before measuring the EWs. This is only for\n        automatic line identification.\n\\end{itemize}\nAn in-depth description of these options can be found in\n\\citet{Sousa2007,Sousa2015a}.\n\nRarely \\code{ARES} crash when measuring an absorption line. The reason is not clear, however when\ndealing with a large amount of spectra, it is important that the analysis moves on. However, a\ncloser inspection usually reveal strange spectral features such as zero flux, sharp peaks in the\nspectra, etc. To deal with this problem, \\code{FASMA} finds the last line which \\code{ARES} tried to\nmeasure in the log file. This line is temporarily removed from the line list and \\code{ARES} is\nrestarted. The line list used for deriving parameters consists of numerous iron lines, thus removing\none line will have a negligible effect on the final derived parameters.\n\n\n\n\\subsubsection{Interpolation of atmosphere models}\n\\label{sec:interpolation}\n\n\\code{FASMA} has access to both ATLAS9 models by \\citet{Kurucz1993} and MARCS models by\n\\citet{Gustafson2008}, both are in a pre-calculated grid as described above. Let this grid be\ndescribed by $\\{T_\\mathrm{eff,g},\\, \\log g_g,\\, [\\ion{Fe}/\\ion{H}]_g\\}$, where subscript $g$ is one\nof the grid points. Such a grid can be seen in \\fref{fig:grid} for $[\\ion{Fe}/\\ion{H}]=0.00$ in the\n$T_\\mathrm{eff}$ range; \\SIrange{3000}{10000}{K}. For visualisation the location of the Sun is\nshown as well. The colour scale corresponds to the temperature in the first layer of each model\natmosphere, i.e. the uppermost layer. The requested value will be $\\{T_\\mathrm{eff,r},\\,\\log\ng_r,\\,[\\ion{Fe}/\\ion{H}]_r\\}$. The task is now to find the surrounding grid points in the parameter\nspace of the requested parameters. For $\\log g$ and $[\\ion{Fe}/\\ion{H}]$ two neighbouring grid point\nare used, and for $T_\\mathrm{eff}$ four surrounding grid point are used, in total\n$4\\times2\\times2=16$ model atmospheres for the interpolation. \\code{FASMA} use the four surrounding\ngrid points for $T_\\mathrm{eff}$ instead of two, since the model atmosphere changes most with\n$T_\\mathrm{eff}$. This is common in other interpolations as well \\citep[see e.g.][]{Valenti1996}.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{figures/model_atmosphere.pdf}\n    \\caption{Model atmosphere grid from \\citet{Kurucz1993} at $[\\ion{Fe}/\\ion{H}]=0.00$ between\n             \\SI{3000}{K} and \\SI{10000}{K}. The grid extends to higher $T_\\mathrm{eff}$, but these\n             are not considered in this thesis.}\n    \\label{fig:grid}\n\\end{figure}\n\nWhen the 16 model atmosphere have been located, the interpolation goes through each layer of the\nmodel atmosphere, where there typical are 72 layers, and each column of which there are six. The\ncolumns are described in \\sref{sec:atmospheremodels}. The interpolation are done using the\n\\code{griddata} function from \\code{SciPy}\\footnote{\\url{https://scipy.org/}}. The interpolation is\nlinear in the parameter space. After the interpolation, the result is saved to a file in the format\nexpected by \\code{MOOG}.\n\n\n\n\n\\subsubsection{Minimization}\n\\label{sec:minimization}\n\nWith the measured EWs for all the lines in the line list, we choose an atmosphere model to determine\nthe abundances. If there is no prior knowledge of the star it is common simply to choose an\natmosphere model with solar parameters as a starting point. Once the line abundances of all the iron\nlines has been determined, the linear correlation between the abundances and the reduced EWs (RW)\n$a_\\mathrm{RW}$, and the abundances and the excitation potential $a_\\mathrm{EP}$ is calculated. If\nthere is a correlation it means the model atmosphere used is wrong. Moreover, we also have to check\nif the mean abundance of \\ion{Fe}{I} and \\ion{Fe}{II} lines are equal, and last if mean abundance of\nthe \\ion{Fe}{I} lines is equal to the input $[\\ion{M}/\\ion{H}]$ of the atmosphere model\\footnote{We\nuse \\ion{Fe}{I} instead of \\ion{Fe}{II} lines for this, since they are more numerous.}. If one of\nthese four criteria does not pass, then the atmosphere model is wrong, and we have to search for a\nnew one. A common way to do this, is by combining the indicators into a scalar value:\n\\begin{align}\n  f(\\{T_\\mathrm{eff}, \\log g, [\\ion{Fe}/\\ion{H}], \\xi_\\mathrm{micro}\\}) &= \\sqrt{a_\\mathrm{EP}^2 + a_\\mathrm{RW}^2 + \\Delta\\ion{Fe}{}^2},\n\\end{align}\nwhere $a_\\mathrm{EP}$ is the correlation between abundances and excitation potential,\n$a_\\mathrm{RW}$ is the correlation between abundances and RW, and $\\Delta\\ion{Fe}{}$ is the\ndifference between the mean abundances of \\ion{Fe}{I} and \\ion{Fe}{II}. This scalar function can be\nminimized using standard minimization procedures as the simplex downhill among others. However,\nthere is another approach that takes into the account the information stored in these indicators.\nFor example, if $a_\\mathrm{EP}$ is positive it means $T_\\mathrm{eff}$ has to be increased by an\namount correlated by the numerical value of $a_\\mathrm{EP}$. In the same way, a non-zero\n$a_\\mathrm{RW}$ means $\\xi_\\mathrm{micro}$ has to be changed, and $\\Delta\\ion{Fe}{}$ is an indicator\nfor $\\log g$. In the end it is a vector function being minimized which are more difficult, however\nwe are not minimizing this using standard mathematical methods, but rather using the physical\nknowledge. This minimization is useless for anything else, but it is excellent for this. The vector\nfunction has the form:\n\\begin{align}\n    f(\\{T_\\mathrm{eff}, \\log g, [\\ion{Fe}/\\ion{H}], \\xi_\\mathrm{micro}\\}) = \\{a_\\mathrm{EP}, a_\\mathrm{RW}, \\Delta\\ion{Fe}, \\ion{Fe}{I}\\}.\n\\end{align}\n\nThe abundances of \\ion{Fe}{I} lines versus EP and RW are shown in \\fref{fig:eprw} for the planet\nhost star HATS-1. The three rows are for three different model atmospheres. From upper to lower:\n\\begin{itemize}\n  \\item Converged: $T_\\mathrm{eff}=\\SI{5959}{K}$,\n                   $\\log g=4.59$,\n                   $[\\ion{Fe}/\\ion{H}]=-0.04$, and\n                   $\\xi_\\mathrm{micro}=\\SI{1.05}{km/s}$.\n  \\item Converged with \\SI{0.5}{km/s} added to $\\xi_\\mathrm{micro}$.\n  \\item Converged with \\SI{500}{K} added to $T_\\mathrm{eff}$.\n\\end{itemize}\nLeft column show the abundances against the EP, and the right column is abundances against RW.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{figures/EP_RW_vs_abundance.pdf}\n    \\caption{The abundances of \\ion{Fe}{I} for the planet host star: HATS-1.\n             Upper plot: Converged parameters (see text for stellar parameters for this star).\n             Middle plot: Converged parameters with \\SI{0.5}{km/s} added to $\\xi_\\mathrm{micro}$.\n             Lower plot: Converged parameters with \\SI{500}{K} added to $T_\\mathrm{eff}$.}\n    \\label{fig:eprw}\n\\end{figure}\n\n\\paragraph{Option: outliers - }\n\nThe minimization with the different options is depicted in \\fref{fig:minimization}. In each\niteration where convergence is not reached, the input metallicity is changed to that of the average\noutput metallicity using the \\ion{Fe}{I} lines. \\code{FASMA} is able to set one or all of the four\natmospheric parameters to a fixed value, and when it reach convergence it checks if there are any\noutliers in the abundances. These outliers are likely to come from a bad measurement of the EW of\nthe given line. This can be due to line blending or a poor spectral reduction. These can be removed,\neither:\n\\begin{itemize}\n  \\item All outliers above $3\\sigma$ once; minimization routine is restarted after removal of\n        outliers.\n  \\item All outliers above $3\\sigma$ iteratively; minimization routine is restarted after removal of\n        outliers each time.\n  \\item One outlier above $3\\sigma$ (with the highest deviation) is removed iteratively;\n        minimization routine is restarted after removal of outliers each time.\n\\end{itemize}\nIt is optional to remove any outliers, but recommended.\n\nAll restarts of the minimization will start at the previous best found parameters. For the latter\ntwo where outliers are removed iteratively, this will continue until no outliers are present. An\noptical line list like the ones by \\citet{Sousa2008a,Tsantaki2013} have been tested thoroughly and\ndue to the large amount of lines it is safe to remove a larger amount of lines and still obtain\nreliable parameters, thus using the first option is common here. However, with a less tested line\nlist, like the one by \\citet{Andreasen2016} (and refined in \\citet{Andreasen2017b}), one should\nremove outliers more carefully, and it is recommended that one outlier is removed iteratively.\n\n\\paragraph{Option: fix $\\xi_\\mathrm{micro}$ - }\n\nSometimes the minimization can not reach convergence with all parameters free. The first approach to\nprogress is to fix $\\xi_\\mathrm{micro}$ to a value. This parameter is known to depend on the\nspectral type \\citep[see e.g.][and references therein]{Tsantaki2013}. This is also shown in\n\\fref{fig:vtRelation} for a sample of 583 stars analysed with \\code{FASMA}. \\code{FASMA} use one of\ntwo empirical relations to fix $\\xi_\\mathrm{micro}$ if this is close to either $0\\si{km/s}$ or\n$5\\si{km/s}$ and $|a_\\mathrm{RW}| > 0.050$ at the end of the minimization. The empirical relations\nare:\n\\begin{align}\n  \\xi_\\mathrm{micro} =\n  \\begin{cases}\n    6.935 \\cdot 10^{-4}\\; T_\\mathrm{teff} - 0.348 \\log g - 1.437     & \\text{For $\\log g \\ge 3.95$} \\\\\n    2.72 - 0.457 \\log g + 0.072 \\cdot [\\ion{Fe}/\\ion{H}]             & \\text{For $\\log g < 3.95$},\n  \\end{cases}\n\\end{align}\nwhere the first case is from \\citet{Tsantaki2013} and the latter case is from \\citet{Adibekyan2015}.\nIn this way $\\xi_\\mathrm{micro}$ is changed in each iteration according to one of these relations.\nThis option is called \\code{autofixvt} in \\fref{fig:minimization}.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{figures/vtRelation.pdf}\n    \\caption{$\\xi_\\mathrm{micro}$ dependence on $T_\\mathrm{eff}$ and $\\log g$ for a sample of 583\n             stars.}\n    \\label{fig:vtRelation}\n\\end{figure}\n\n\\paragraph{Option: Change line list - }\n\nAfter the minimization, it happens that the derived $T_\\mathrm{eff}$ is below \\SI{5200}{K}. At this\ntemperature it is well known that the line list by \\citet{Sousa2008a} does not work well. Some of\nthe lines start to be blended for lower $T_\\mathrm{eff}$, thus giving poor measurements of some EWs.\nThis is something that was corrected by \\citet{Tsantaki2013}, who created a subset of the previous\niron line list. This smaller line list are able to successfully derive $T_\\mathrm{eff}$ below\n\\SI{5200}{K}. Therefore, if the option \\code{teffrange} is on (which is highly recommended), the\nline list by \\citet{Sousa2008a} will simply be converted to the smaller line list by\n\\citet{Tsantaki2013} if $T_\\mathrm{eff}$ is below this threshold, and the minimization will be\nrestarted. This conversion happens after the convergence.\n\n\\paragraph{Option: Refine results - }\n\nLast there is an option, \\code{refine}. This apply more strict criteria for the indicators to reach\nconvergence, thus making the minimization less sensitive to the initial guess since it could\notherwise reach convergence from one ``side'' of the parameter space. The default criteria are:\n\\begin{align*}\n  a_\\mathrm{EP}     &= 0.001\\\\\n  a_\\mathrm{RW}     &= 0.003\\\\\n  \\Delta\\mathrm{Fe} &= 0.001.\n\\end{align*}\nThe criteria for $a_\\mathrm{RW}$ is not as strict as $a_\\mathrm{EP}$ since this indicator can change\nrapidly with small changes in $\\xi_\\mathrm{micro}$, thus a very strict criteria might never lead to\nconvergence. Convergence is reached once all of the above criteria are met, and the input and output\nmetallicity are identical. If one or more of the parameters are fixed, the corresponding criterion\nis simply set to 0 and effectively ignored, thus not changing the parameter.\n\n\\paragraph{Stepping in each iteration - }\n\nFor each iteration, the change to be applied for the atmospheric parameters are defined by adding\nthe following:\n\\begin{align}\n  T_\\mathrm{eff}     &: \\SI{2000}{K} \\cdot a_\\mathrm{EP}   \\\\\n  \\xi_\\mathrm{micro} &: \\SI{1.5}{km/s} \\cdot a_\\mathrm{RW} \\\\\n  \\log g             &: -\\Delta\\mathrm{Fe}\n\\end{align}\nto each parameter. Note again that metallicity is simply changed to the the output metallicity of\nthe previous iteration. These are empirical relations. Note that by changing e.g. $T_\\mathrm{eff}$\nnot only is $a_\\mathrm{EP}$ affected, but the other indicators as well as seen in \\fref{fig:eprw}.\nThis inter-dependency between the parameters is ignored by \\code{FASMA} as it is not a simple\nproblem to solve. The stepping presented above is chosen to rapidly reach convergence, without\ncausing problems for the inter-dependency. This minimization is thus build to apply a standard\nmethod, curve-of-growth analysis, using as few calls to the time consuming part, which is the\ncalculation of the abundances with \\code{MOOG}.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{figures/FASMA_minimization.pdf}\n    \\caption{Overview of the minimization for \\code{FASMA}. Credit: \\citet{Andreasen2017a}.}\n    \\label{fig:minimization}\n\\end{figure}\n\n\n\\subsubsection{Error estimate}\n\\label{sec:error_estimate}\n\nThe error estimate is based on the same method presented in \\citet{Neuforge1997}. The error on\n$\\xi_\\mathrm{micro}$ corresponds to the $1\\sigma$ statistical error on the slope of the linear\nregression between \\ion{Fe}{I} abundances and RW. The error on $T_\\mathrm{eff}$ is the statistical\nerror on the slope between \\ion{Fe}{I} abundances and EP as well as the uncertainty in\n$\\xi_\\mathrm{micro}$. The error for $[\\ion{Fe}/\\ion{H}]$ corresponds to the dispersion of the\n\\ion{Fe}{I} abundances as well as the uncertainties in $\\xi_\\mathrm{micro}$ and $T_\\mathrm{eff}$.\nThe error in $\\log g$ corresponds to the dispersion in the pressure sensitive \\ion{Fe}{II}\nabundances.\n\n\\subsubsection{Testing \\code{FASMA}}\n\\label{sec:fasma_test}\n\nParameters were derived for a 582 sample presented in \\citet{Sousa2011} with \\code{FASMA} as a test.\nThe results were compared with \\citet{Sousa2011} since the method is the one previously used in the\nPorto group, thus making a fair test.\n\n\\code{ARES} was used to measure the EWs. \\code{ARES} can give an estimate of the S/N by analysing\nthe continuum in certain intervals. For solar-type stars the following intervals work well:\n5764-5766 \\AA{}, 6047–6053 \\AA{}, and 6068–6076 \\AA{}. From the estimated S/N, \\code{ARES} can give\nan estimate on the very important \\code{rejt} parameters \\citep[see][for more information]{Sousa2015a}.\n\nAfter measuring the EWs with \\code{ARES}, \\code{FASMA} was used  to determine the stellar\natmospheric parameters. The results are presented in \\fref{fig:fasma_test} which shows\n$T_\\mathrm{eff}$, $\\log g$, $[\\ion{Fe}/\\ion{H}]$, and $\\xi_\\mathrm{micro}$ for \\code{FASMA} against\nthose of \\citet{Sousa2011}. The sample contains stars with $T_\\mathrm{eff}$ too cold for the line\nlist used. As described in \\sref{sec:minimization} the line list by \\citet{Sousa2008a} should be\nconverted to the line list presented in \\citet{Tsantaki2013}. However, since this line list was not\navailable when \\citet{Sousa2011} derived parameters, the \\code{teffrange} option was left off in\norder to make a fair comparison for \\code{FASMA}.\n\n\\begin{figure}[htpb!]\n    \\centering\n    \\includegraphics[width=1.0\\linewidth]{figures/FASMAtest.pdf}\n    \\caption{Stellar atmospheric parameters derived by \\code{FASMA} compared to the sample by\n             \\citet{Sousa2011}. The x-axis in all plots shows the results from \\code{FASMA}, while\n             the y-axis shows the parameters derived by \\citet{Sousa2011}.}\n    \\label{fig:fasma_test}\n\\end{figure}\n\n\nThe mean of the difference between parameters from \\citet{Sousa2011} and those by \\code{FASMA} are\npresented in \\tref{tab:FASMATest}. The comparison is very consistent, as expected, and the small\noffsets are within the errors except for metallicity. This can be due to different versions of\n\\code{MOOG}, measured line lists (i.e. using slightly different settings/version of ARES to measure\nthe EWs), interpolation of atmosphere grid, and minimization routine. Most likely the difference\nwill be due to the different \\code{rejt} parameters used in \\code{ARES}, which can alter the EWs\nsystematically and hence the metallicity. To test this hypothesis 20 randomly stars with different\n$T_\\mathrm{eff}$ were selected and the EWs directly from \\citet{Sousa2011} were used to derive\nparameters. The results are presented in the last column of \\tref{tab:FASMATest}. Note that the\n$\\log \\mathit{gf}$ values from the original line lists by \\citet{Sousa2011}, which used the\n\\code{MOOG} 2002 version, were not changed for the 2014 version of \\code{MOOG}. This might lead to\nsome errors as well. However, the offsets are very small and are compatible with the errors on\nparameters normally obtained from high-quality spectra.\n\n\\begin{table}[htb!]\n    \\caption{Difference in derived parameters by \\citet{Sousa2011} and \\code{FASMA}. The second\n             column is the mean difference with EWs measured by \\code{ARES} in \\code{FASMA}, while\n             the third column is the mean difference using 20 randomly stars with the exact same EWs\n             from \\citet{Sousa2011}.}\n    \\label{tab:FASMATest}\n    \\centering\n    \\begin{tabular}{lrr}\n      \\hline\\hline\n      Parameter             &  Mean difference         & Same line list        \\\\\n      \\hline\n      $T_\\mathrm{eff}$      &  $\\SI{16(36)}{K}$        & $\\SI{21(11)}{K}$      \\\\\n      $\\log g$              &  $\\SI{-0.04(7)}{dex}$    & $\\SI{-0.007(9)}{dex}$ \\\\\n      $[\\ion{Fe}/\\ion{H}]$  &  $\\SI{0.03(2)}{dex}$     & $\\SI{0.004(9)}{dex}$  \\\\\n      $\\xi_\\mathrm{micro}$  &  $\\SI{-0.04(14)}{km/s}$  & $\\SI{0.04(2)}{km/s}$  \\\\\n      \\hline\n    \\end{tabular}\n\\end{table}\n", "meta": {"hexsha": "8b30eab706f6214a7677a5a8ae1cc9778a88fbbb", "size": 34708, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "method.tex", "max_stars_repo_name": "DanielAndreasen/Thesis", "max_stars_repo_head_hexsha": "da18d41e48de5d34c8281ffd9e850dfd4fe37824", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-04-25T08:31:52.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-09T13:46:52.000Z", "max_issues_repo_path": "method.tex", "max_issues_repo_name": "DanielAndreasen/Thesis", "max_issues_repo_head_hexsha": "da18d41e48de5d34c8281ffd9e850dfd4fe37824", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "method.tex", "max_forks_repo_name": "DanielAndreasen/Thesis", "max_forks_repo_head_hexsha": "da18d41e48de5d34c8281ffd9e850dfd4fe37824", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.5390070922, "max_line_length": 138, "alphanum_fraction": 0.7536879106, "num_tokens": 9387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4085200256408369}}
{"text": "\\documentclass{article}\n\n\\usepackage[french]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\\usepackage{amsmath}\n\\usepackage{systeme}\n\\usepackage{float}\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage{color}\n\\usepackage{fancyhdr}\n\\usepackage{pdfpages}\n\\usepackage{layout}\n\\usepackage{multicol}\n\\usepackage{setspace}\n\\usepackage{csvsimple}\n\\usepackage[table]{xcolor}\n\\usepackage[colorlinks=true]{hyperref}\n\\usepackage{tikz, tkz-tab}\n\\usepackage[top=2cm,bottom=2cm,left=2cm,right=2cm]{geometry}\n\\usepackage{amsthm}\n\n\n\\usepackage{multicol}\n\n%%%%%%%%%%%%%%%% Lengths %%%%%%%%%%%%%%%%\n\\setlength{\\textwidth}{15.5cm}\n\\setlength{\\evensidemargin}{0.5cm}\n\\setlength{\\oddsidemargin}{0.5cm}\n\n%%%%%%%%%%%%%%%% Variables %%%%%%%%%%%%%%%%\n\\def\\project{4}\n\\def\\title{Non-linear systems of equations and the Newton-Raphson method}\n\\def\\group{3}\n\\def\\team{3}\n\\def\\manager{Lucas Guédon}\n\\def\\secretary{Salim Bekkari}\n\\def\\others{Mohammed Boudali, Imad Boudroua, Simon Bullot}\n\\singlespace\n\\begin{document}\n\n%%%%%%%%%%%%%%%% Header %%%%%%%%%%%%%%%%\n\\noindent\\begin{minipage}{0.98\\textwidth}\n  \\vskip 0mm\n  \\noindent\n  { \\begin{tabular}{p{6.5cm}}\n      {\\bfseries \\sffamily\n        Project \\project} \\\\ \n      {\\itshape \\title}\n    \\end{tabular}}\n  \\hfill \n  \\fbox{\\begin{tabular}{p{8.4cm}}\n      {~\\hfill \\bfseries \\sffamily Group \\group\\ - Team \\team\n        \\hfill~} \\\\[2mm] \n      Manager: \\manager \\\\\n      Secretary: \\secretary \\\\\n      Programmers: \\others\n    \\end{tabular}}\n  \\vskip 4mm ~\n\n  ~~~\\parbox{0.95\\textwidth}{\\small \\textit{Abstract~:} \\sffamily The aim of the project is to implement the Newton-Raphson method to solve non-linear systems of equations and apply it to problems.}\n  \\vskip 1mm ~\n\\end{minipage}\n\n%%%%%%%%%%%%%%%% Main part %%%%%%%%%%%%%%%%\n\n\\section{Newton-Raphson method}\n\\begin{flushright}\nBy Lucas Guédon\n\\end{flushright}\n\nThe goal of this section is to implement a solver of non-lineal systems of equations. The equations are in the form of $f(X) = 0$, where $f: R^n \\rightarrow R^m$ is differentiable. To achieve this, the Newton-Raphson method was used.\n\n\\subsection{Algorithm}\n\nGiven a starting point $U_n$, the objective is to find a point supposedly closer to a root than $U_n$. The new point $U_{n+1} = U_n + V$ is a good approximation of the root, so $f(U_{n+1}) \\approx 0$.\nThe Taylor expansion of $f$ around $U_n$ allowed us to find that $f(U_{n+1}) = f(U_n) + H(U_n) \\times V$, thus $H(U_n) \\times V = -f(U_n)$.\nThis linear system of equations could be solved using numpy.linalg.solve, but the latter was replaced with numpy.linalg.lstsq in order to avoid numerical problems related to singular matrices.\nThe process is repeated until $||f(U_n)|| < \\epsilon$ where $\\epsilon$ is the desired precision.\n\n\\subsection{Backtracking}\n\nIn some cases, the previously shown algorithm diverges, backtracking avoids this.\nThe function $\\Phi(U) = U^TU$ was added to evaluate the approximations.\nWhen computing $U_{n+1}$, if $\\Phi(U_n + V) < \\Phi(U_n)$ then $U_n + V$ is an approximation worse than $U_n$. In this case, V is multiplied by the value $step$, with $0 < step < 1$. This process is repeated until the approximation is better than $U_n$.\n\n\\subsection{Testing}\n\nIn order to test the algorithm, two simple test cases were created. The first finds one root of the second-degree polynomial $f(x) = x^2 - 2x + 1$ using our algorithm. The expected result is 1. The result given by the algorithm is $0.998$, which has a relative error of $0.002$.\n\nThe second case solves a system with multiple variables and equations:\n\\[\\begin{cases}\nx^2 + y = 0 \\\\\nx + 3y + 4 = 0\n\\end{cases}\\]\nThis system is represented by the function $f(x, y) = (x^2 + y, x + 3y + 4)$. The algorithm found the solution $x = 1.333, y = -1.778$.\n\\\\\nTo verify whether this is a correct solution, $f$ was applied to $x$ and $y$ : $f(x, y) = (1.930 \\times 10^{-12}, 4.441 \\times 10^{-16})$. The result was almost $(0, 0)$ so the root was correct.\n\nTo test the efficiency of backtracking, the algorithm was applied to the function $f(x) = x^3 - 2x^2 + 1$ with a starting point of $0.01$. This is a special edge case because f(0.01) is close to 1 and f'(0.01) is close to 0. During the first iteration, $V = \\frac{f(0.01)}{f'(0.01)}$ which means that $U_1$ moved away from the solution. This can be seen in figure 1.\n\n\\begin{figure}[!htb]\n    \\centering\n    \\includegraphics[width=0.5\\textwidth]{backtracking_testing.png}\n    \\caption{Comparison of the value of $\\Phi(U_n)$ with and without backtracking}\n\\end{figure}\n\n\\newpage\n\\section{Computation of the Lagrangian points}\n\n\\begin{flushright}\nBy Simon Bullot\n\\end{flushright}\n\nIn celestial mechanics, the Lagrangian points are points near two objects where a lighter object will remain at the same place relatively to the two other masses. The Newton-Raphson method is used to find these points.\n\n\\subsection{Forces implementation}\n\nFirst, a function which takes two parameters will return another function representing centrifugal, elastic or gravitational force. For instance, a function g will return the centrifugal force function corresponding to the parameters $k$ and $X_0$.\n\\[g:k,X_{0} \\mapsto f with f : X = (x,y) \\mapsto (k(x-x_{0}),k(y-y_{0}))\\]\n\n\nThen another function would return Jacobian matrix for any of the forces needed.\n\n\\subsection{Newton-Raphson method application}\n\nA third function will represent the sum of the forces by adding the desired gravitational and centrifugal forces. The same is done by another function for the matrix representing Jacobian forces sum matrix. Then the Newton-Raphson algorithm is used to find a point where forces are equal to zero. A point where sum forces are equal to zero will be an equilibrium point. In fact, due to Newton's first law, if an object does not have any velocity, and the forces acting on it are compensating themselves, then it will not move.\n\n\\subsection{Obtaining the Lagrangian points}\n\nBy running the Newton-Raphson algorithm with different $U_{0}$ points, different Lagrangian points can be found.\nFor instance, if those points are used :\n\\[U_0 = (0.5, 0), U_1 = (1.5, 0), U_2 = (-1.5, 0) \\]\nThe algorithm will respectively find these points:\n\\[L_0 = ( 0.85927766, 0 ), L_1 =  (1.15775715, 0 ), L_2 = (-0.99754112, 0 ).\\] \n\n\\newpage\n\\section{Electrostatic equilibrium}\n\\begin{flushright}\nBy Imad Boudroua and  Mohammed Boudali\n\\end{flushright}\n\nThe purpose of this section is to show the equilibrium position of N charges placed in an electrostatic field. The movement studied is limited between -1 and 1 on the real axis.\n\\subsection{Algorithm to compute the Jacobian matrix}\nThe first step is to  compute the derivative of total  electrostatic energy function:\n\\begin{equation}\n    E(x_1,..,x_N) = \\sum_{i=1}^{N} ( \\log(|x_i + 1| + \\log|x_i - 1| + \\frac{1}{2}\\sum_{\\substack{j=1 \\\\ j\\neq i}}^{N} \\log|x_i - x_j| )\n\\end{equation}\n    After derivation, the expression found is:\n\\begin{equation}\n\\frac{\\partial  E(x_1, ..,x_N)}{\\partial x_i}\n   = \\frac{1}{x_i - 1}\n      + \\frac{1}{x_i + 1}\n      + \\sum_{\\substack{j=1 \\\\ j\\neq i}}^{N}\\frac{1}{x_i - x_j}\n      \\end{equation}\nTherefore, the elements of Jacobian matrix: $(\\frac{\\partial \\nabla E_i}{\\partial x_j})_{_{i,j}}$ can be simplified to: \n\n\\vspace{5pt}\n\n\\[J_{i,j} = \\begin{cases} -\\frac{1}{(x_i - 1)^2} -\\frac{1}{(x_i + 1)^2} - \\sum_{\\substack{j=1 \\\\ j\\neq i}}^{N}\\frac{1}{(x_i - x_j)^2} &\\mbox{if } i\\neq j \\\\\n-\\frac{1}{(x_i - x_j)^2} & \\mbox{if }  i = j \\end{cases}\n\\]\n\n\n\\subsection{Application of Newton-Raphson method}\n    After using the Newton-Raphson method to solve the equation: $\\nabla E(x_1, ..,x_n) = 0$,  the variation of energy gradient was plotted (Figure 2):\n    \n    \n    \\begin{figure}[!htb]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{equilibrium.png}\n    \\caption{Electrostatic equilibrium with 10 charges}\n\\end{figure}\n\\vspace{1cm}\n\n\\newpage\nIn Figure 2, the curve converges to 0. This result proves that the system studied reached an electrostatic equilibrium. This property is more noticeable in Figure 3:\n\\vspace{1cm}\n\n    \\begin{figure}[!h]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{position_real_axis.png}\n    \\caption{Position of the charges on the real axis}\n\\end{figure}\n\n\n\\subsection{Comparison with the Legendre polynomial derivative roots }\nIn this section, the functions \\textbf{legder}, \\textbf{leg2poly} and \\textbf{poly1d} were used to draw the curve of Legendre polynomial. Equilibrium positions were plotted in the same figure in order to compare the results (Figure 4):\n\n \n    \\begin{figure}[!h]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{legendre_comparaison.png}\n    \\caption{Legendre polynomials and equilibrium positions}\n\\end{figure}\n\nThis figure shows that Legendre polynomial derivative roots coincide with the equilibrium positions.\n\\subsection{The nature of the extremum}\nThe results show that electrostatic equilibrium positions reached a critical point. To determine its nature, the curve in Figure 5 was drawn.\n    \\begin{figure}[!h]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{energy_position.png}\n    \\caption{Energy variation of one charge on  [-1;1]}\n\n\\end{figure}\n\\newpage\n   This curve is characterized by one global maximum reached in $x=0$.\n   \n\\section{Conclusion}\n\\begin{flushright}\nBy Simon Bullot, Imad Boudroua and Lucas Guédon\n\\end{flushright}\n\nThe Newton-Raphson method can be a useful and powerful tool especially with the problems encountered in this project. In those cases, the Jacobian matrix of each function can be easily calculated. This enables the use of this method which works in any dimension. Moreover, the convergence of the algorithm studied is quadratic because roots are non stationary points and do not have multiplicity greater than one.\n\n\\end{document}\n", "meta": {"hexsha": "f09af5baeb67c6d0672539e37420a2b39d432e7e", "size": 9855, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "rapport.tex", "max_stars_repo_name": "ImadProjects/Non-linear-systems-of-equations-Newton-Raphson-Method", "max_stars_repo_head_hexsha": "54a0082f0cee3797b98e840847fa11db3f117770", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "rapport.tex", "max_issues_repo_name": "ImadProjects/Non-linear-systems-of-equations-Newton-Raphson-Method", "max_issues_repo_head_hexsha": "54a0082f0cee3797b98e840847fa11db3f117770", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "rapport.tex", "max_forks_repo_name": "ImadProjects/Non-linear-systems-of-equations-Newton-Raphson-Method", "max_forks_repo_head_hexsha": "54a0082f0cee3797b98e840847fa11db3f117770", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.592760181, "max_line_length": 526, "alphanum_fraction": 0.7187214612, "num_tokens": 2907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166195971441, "lm_q2_score": 0.7981867705385762, "lm_q1q2_score": 0.40844543602716155}}
{"text": "  \n%% \\listfiles\n\\documentclass[apj]{emulateapj}\n%\\documentclass[preprint2,12pt]{emulateapj}\n%% \\usepackage{natbib}\n\\usepackage{graphicx}\n\\usepackage{epsfig}\n\\usepackage{amssymb,amsmath}\n\\usepackage{array}\n\\usepackage{threeparttable}\n\n\n\\doublespace\n\n%definitions\n\\newcommand{\\Msol}{${\\rm M_{\\sun}}$}\n\n\n%% Editing markup...\n\\usepackage{color}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% WARNING: This LaTeX block was generated automatically by authors.py\n% Do not change by hand: your changes will be lost.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n% --------------------- Ancillary information ---------------------\n\\shortauthors{SURP et al.}\n\\shorttitle{my short-title}\n\\slugcomment{Draft: \\today}\n\n\n\\begin{document}\n\n\\title{Assignment 2}\n %% ---------\n \n\\author{Yumna Arshad}\n%\\altaffiltext{1}{CITA, University of Toronto}\n \n\n\\section{Question 1}\n\n\\subsection{Method}\nTo solve this question, I first created a grid of points along the x and y axis of the complex plane domain (-2,2) x (-2,2) using nested for-loops. \nThen, I used a for loop to cycle through each point along the grid and iterate through the series at each position in the complex plane c. \nUsing a while loop I was able to track the iteration number of each diverging point and save that to a list.\nAs a result, each point had a corresponding iteration number associated with it; if that iteration number was equal to the given $#$ of required iterations then the point was added to a list associated with the key 'bound' in a dictionary (indicating the point remained bounded throughout all iterations), else the point was added to a list associated with the key 'diverge' in that same dictionary. \nA bounded point was defined as remaining within the given square domain, i.e absolute value of both the real part and imaginary part of value $z_i$ were less than 2, after all iterations. \nFinally, I plotted both a normal scatter plot with 2 different colors (one indicating diverging and another indicating bounded points) as well as a color map indicating the iteration number at which each diverging point left the domain. \n\n\\subsection{Analysis of Results}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=1.0\\columnwidth]{A2Q1_plot1_final.png}\n    \\caption{Plot of the bounded points shown in orange and diverging points shown in blue. The domain shown is 4x4 square domain of complex plane centered at 0.}\n    \\label{fig:Q1plot1}\n\\end{figure}\n\nThe results shown in Fig.\\ref{fig:Q1plot1} indicate the plot resembles that of a Mandelbrot set which is what we expect from the analysis of the iterated points in the plane.\nThe figure appears to be symmetric about the horizontal line y = 0 (x/real axis).\nIf we were to zoom into the edges of the image in the plot, we would see that the structure is repeating on smaller and smaller scales indicating that the boundary of this Mandelbrot set is a fractal curve.\n\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=1.0\\columnwidth]{A2Q1_plot2_final.png}\n    \\caption{Plot of diverging and bounded points using a color map to indicate iteration number at which diverging points become unbounded. The total number of iterations is 100.}\n    \\label{fig:Q1plot2}\n\\end{figure}\n\n\nThe color map equivalent of the plot in Fig.\\ref{fig:Q1plot1} is pictured in Fig.\\ref{fig:Q1plot2}. The colour bar indicates the iteration number at which each diverging points becomes diverging and leaves the given domain. \nWe see that the majority of diverging points diverge at very small number of iterations ($\\approx$ 2 iterations) while the points nearest the edges of the plot require the most iterations to become diverging. \nThe closer you get to the bounded points, the more iterations are required to cause diverging of points. \nIf the number of iterations in code were increased we would expect the edges of the plot to become more finely distinguished in terms of their physical structure and geometry. \n\n\n\n\n\\section{Question 2}\n\n\\subsection{Method}\nTo do this question I used the solve ivp method in scipy's integrate module to solve a set of 3 ODE's (the SIR model) which model the spread of disease in a population. \nThis involved defining a function that returns the right hand side of the 3 differential equations: $\\frac{dS}{dt}$, $\\frac{dI}{dt}$ and $\\frac{dR}{dt}$.\nUsing the initial values, the differential equations were numerically solved and plotted as a function of time for a given value of beta and gamma. \nFor the bonus part: I added a DE to model the death as: $\\frac{dD}{dt} = \\alpha I(t)$ and changed the equation for I(t) as follows: $\\frac{dI}{dt} = \\frac{\\beta}{N}SI - \\gamma I - \\alpha I$. \nNote: $\\beta$ = average number of contacts per person/day, $\\gamma$ = 1/D where D is $#$ of days an individual is infectious and $\\alpha$ = fraction of infected individuals that die.\n\n\n\\subsection{Analysis of Results}\n\nIn Fig.\\ref{fig:Q2plot1a}, Fig.\\ref{fig:Q2plot1b} and Fig.\\ref{fig:Q2plot1c} 3 plots for 3 different gamma and beta parameters are shown.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{A2Q2_plot1a.png}\n    \\caption{Plot indicating relative populations of: susceptible (S), infected (I) and recovered (R) individuals of a given population using SIR Model of disease spread and numerical integration. The figure shows results for a relatively high period of infectiousness and low contact rate.}\n    \\label{fig:Q2plot1a}\n\\end{figure}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{A2Q2_plot1b.PNG}\n    \\caption{Plot indicating relative populations of: susceptible (S), infected (I) and recovered (R) individuals of a given population using SIR Model of disease spread and numerical integration. The figure shows results for a relatively low period of infectiousness and high contact rate.}\n    \\label{fig:Q2plot1b}\n\\end{figure}\n \n\\vspace{5mm} %5mm vertical space\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.7\\columnwidth]{A2Q2_plot1c.PNG}\n    \\caption{Plot indicating relative populations of: susceptible (S), infected (I) and recovered (R) individuals of a given population using SIR Model of disease spread and numerical integration. The figure shows results for relatively high contact rate and long period of infectiousness contributing to an overall high infection rate.}\n    \\label{fig:Q2plot1c}\n\\end{figure}\nIn the first plot the number of infected people gets to a little over half the total population due to a relatively long period of infectiousness (20 days) but recovery rate is good since there is little contact between individuals. In the second plot the number of infected people only reaches 80-90 despite a higher contact rate because the period of infectiousness is very low (2 days). As a result, it doesn't take long for the disease to die out (only about 40 days). Finally, the 3rd plot shows the greatest spike in infected individuals, reaching a max of approx 900 individuals and a longer recovery rate because both the number of contacts and period of infectiousness are large. As such, it takes the disease almost 200 days to die out from the population.\n\n%\\vspace{5mm} %5mm vertical space\n\\newpage\nFor the bonus part, death is included in the model and the plot for given $\\beta, \\alpha and \\gamma$ parameters is shown in Fig.\\ref{fig:Q2plot2}.\nThe plot in Fig.\\ref{fig:Q2plot2} differs from the other plots in that the total population does not remain the same anymore due to death of infected people. For a contact rate of 1 person per day and a period of infectiousness of 8 days with mortality rate of 0.3 (i.e. 3/10 infected people die) the total population is reduced by about 600 individuals due to the disease with about 400 individuals remaining. \n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\columnwidth]{A2Q2_plot2.png}\n    \\caption{Plot indicating relative populations of: susceptible (S), infected (I), recovered (R) and deceased (D) individuals of a given population using SIRD Model of disease spread and numerical integration.}\n    \\label{fig:Q2plot2}\n\\end{figure}\n\n\n\\end{document}", "meta": {"hexsha": "0a028d17927172e69960a75b99921319f3776a72", "size": 8144, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment_2/main.tex", "max_stars_repo_name": "yumnaarshad/CTA200", "max_stars_repo_head_hexsha": "abc1ed35e39365d9344342abfe201586428c1cac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assignment_2/main.tex", "max_issues_repo_name": "yumnaarshad/CTA200", "max_issues_repo_head_hexsha": "abc1ed35e39365d9344342abfe201586428c1cac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment_2/main.tex", "max_forks_repo_name": "yumnaarshad/CTA200", "max_forks_repo_head_hexsha": "abc1ed35e39365d9344342abfe201586428c1cac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.4452554745, "max_line_length": 766, "alphanum_fraction": 0.7525785855, "num_tokens": 2000, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8104789155369047, "lm_q1q2_score": 0.4084053266227637}}
{"text": "\\documentclass[a4paper, fleqn, twoside, notitlepage]{scrartcl}\n\\input{settings}\n\n\\begin{document}\n\n\\maketitle\n\\vspace{-3em}\n\\tableofcontents\n\n\\vfill\n\\vspace{1em}\n\\noindent\nThis document describes the algorithms used for the fermionic action in the Hubbard model.\nThey are implemented by these classes:\n\\begin{itemize}\n\\item \\texttt{HubbardFermiMatrix[Dia|Exp]}\n\\item \\texttt{HubbardFermiAction<\\ldots>}\n\\end{itemize}\nand can be found int the following files:\n\\begin{itemize}\n\\item \\texttt{src/isle/cpp/action/hubbardFermiMatrix[Dia|Exp].[hpp|cpp]}\n\\item \\texttt{src/isle/cpp/action/hubbardFermiAction.[hpp|cpp]}\n\\end{itemize}\nFor usage information, see the source documentation of the classes.\\\\\n\n\\noindent\nThere are several different ways to formulate a field theory for the Hubbard Model.\nThis document covers two different discretizations of the fermion action, see Sections~\\ref{sec:dia_disc} and~\\ref{sec:exp_disc}.\nIn addition, the operators can be expressed in the particle/hole (labelled by $\\alpha=1$) or spin (labelled by $\\alpha=0$) basis.\nThe former gives an imaginary Hubbard-Stratonovich transformation and a contribution of auxiliary fields of $e^{\\i\\phi}$.\nThis is used in this documentation.\nA calculation in the spin basis yields $e^\\phi$.\nAll expressions for this basis can be obtained from the ones quoted here via a simple substitution.\n\n\\clearpage\n\\section{Definitions}\n\nThe fermionic action is\n\\begin{align}\n  S_\\text{ferm} &= - \\log \\det M(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}) M^T(-\\phi, \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}, -\\tilde{\\mu}) \\equiv - \\log \\det M_p M_h^T\\label{eq:ferm_action_v1}\\\\\n  &\\equiv - \\log \\det Q(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}}).\\label{eq:ferm_action_v2}\n\\end{align}\nwhere $\\phi$ is the auxiliary field that is integrated over. In general $\\sigma_{\\tilde{\\kappa}} = -1$ but for bipartite lattices, a particle-hole transformation can be used to get $\\sigma_{\\tilde{\\kappa}} = +1$. Subscripts $p$ and $h$ indicate matrices for particles and holes, respectively.\nThe parameters are\n\\begin{itemize}\n\\item $\\delta = \\beta / N_t$ and $\\beta$ the inverse temperature,\n\\item $\\tilde{\\kappa} = \\delta\\kappa$ and $\\kappa$ the hopping matrix,\n\\item $\\tilde{\\mu} = \\delta\\mu$ and $\\mu$ the chemical potential.\n\\end{itemize}\n\n\\subsection{Diagonal Discretization}\\label{sec:dia_disc}\n\nThe main discretization of the fermion action used in Isle puts the hopping matrix on the diagonal and approximates the exponential used in Section~\\ref{sec:exp_disc}.\nIn this case, the fermion matrix is\n\\begin{align}\n  {M(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x't';xt}\n  &= (1+\\tilde{\\mu})\\delta_{x'x}\\delta_{t't} - \\tilde{\\kappa}_{x'x}\\delta_{t't} - \\mathcal{B}_{t'} e^{\\i\\phi_{xt}}\\delta_{x'x}\\delta_{t'(t+1)}\\label{eq:def_m}\\\\\n  &\\equiv {K(\\tilde{\\kappa}, \\tilde{\\mu})}_{x'x}\\delta_{t't} - \\mathcal{B}_{t'}{F_{t'}(\\phi)}_{x'x}\\delta_{t'(t+1)}.\n\\end{align}\nwhere\n\\begin{align}\n  {K(\\tilde{\\kappa}, \\tilde{\\mu})}_{x'x} &= (1+\\tilde{\\mu})\\delta_{x'x} - \\tilde{\\kappa}_{x'x},\\\\\n  {F_{t'}(\\phi)}_{x'x} &= e^{\\i\\phi_{x(t'-1)}}\\delta_{x'x}.\n\\end{align}\nNote that the second $M$ in~\\eqref{eq:ferm_action_v1} can not be expressed as $M^*(\\phi)$ even for bipartite lattices and $\\mu=0$ because $\\phi$ is potentially complex valued.\nAnti-periodic boundary conditions are encoded by\n\\begin{align}\n  \\mathcal{B}_t =\n  \\begin{cases}\n    +1,\\quad 0 < t < N_t\\\\\n    -1,\\quad t = 0\n  \\end{cases}\n\\end{align}\nand periodicity in Kronecker deltas.\nIn time-major layout (time index is slowest) $M$ is a cyclic lower block bidiagonal matrix:\n\\begin{align}\n  M =\n  \\begin{pmatrix}\n    K    &      &        &        & F_0 \\\\\n    -F_1 & K    &        &        &     \\\\\n         & -F_2 & K      &        &     \\\\\n         &      & \\ddots & \\ddots &     \\\\\n         &      &        &-F_{N_t-1}&K   \\\\\n  \\end{pmatrix}.\\label{eq:ferm_mat_block_v1}\n\\end{align}\n\n\\noindent\nThe matrix $Q$ in eq.~\\eqref{eq:ferm_action_v2} is easy to calculate and can be expressed as\n\\begin{align}\n  {Q(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x't',xt}\n  &= {M(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x't',x''t''} {M^T(-\\phi, \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}, -\\tilde{\\mu})}_{x''t'',xt}\\\\\n  &= \\big[(1+\\tilde{\\mu})\\delta_{x'x''}\\delta_{t't''} - \\tilde{\\kappa}_{x'x''}\\delta_{t't''} - \\mathcal{B}_{t'}e^{\\i\\phi_{x''t''}}\\delta_{x'x''}\\delta_{t'(t''+1)}\\big] \\nonumber\\\\\n  &\\quad\\times \\big[(1-\\tilde{\\mu})\\delta_{x'' x}\\delta_{t'' t} - \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}_{x'' x'}\\delta_{t'' t} - \\mathcal{B}_{t}e^{-\\i\\phi_{x''t''}}\\delta_{x'' x}\\delta_{t(t''+1)}\\big]\\\\\n  &\\equiv \\delta_{t't}{(P)}_{x'x} + \\delta_{t'(t+1)}{(T^+_{t'})}_{x'x} + \\delta_{t(t'+1)}{(T^-_{t'})}_{x'x}\n\\end{align}\nwith\n\\begin{align}\n  {P(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= (2-\\tilde{\\mu}^2)\\delta_{x'x} - (\\sigma_{\\tilde{\\kappa}}(1+\\tilde{\\mu}) + (1-\\tilde{\\mu}))\\tilde{\\kappa}_{x'x} + \\sigma_{\\tilde{\\kappa}}{(\\tilde{\\kappa}^2)}_{x'x}\\\\\n  {T^+_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= \\mathcal{B}_{t'}e^{\\i\\phi_{x'(t'-1)}}[\\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}_{x'x} - (1-\\tilde{\\mu})\\delta_{x'x}]\\\\\n  {T^-_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= \\mathcal{B}_{t'+1}e^{-\\i\\phi_{xt'}}[\\tilde{\\kappa}_{x'x} - (1+\\tilde{\\mu})\\delta_{x'x}]\n\\end{align}\nIn time major layout (time is slowest running index) $Q$ assumes a cyclic block tridiagonal form:\n\\begin{align}\n  Q(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}}) =\n  \\begin{pmatrix}\n    P         & T^-_0 &       &         &           &              & T^+_0    \\\\\n    T^+_1     & P     & T^-_1 &         &           &              &          \\\\\n              & T^+_2 & P     & T^-_2   &           &              &          \\\\\n              &       & T^+_3 & P      & \\ddots         &              &          \\\\\n              &       &       & \\ddots     & \\ddots         & T^-_{N_t-3}    &          \\\\\n              &       &       &        & T^+_{N_t-2} & P            & T^-_{N_t-2}\\\\\n    T^-_{N_t-1} &       &       &        &           & T^+_{N_t-1}    & P\n  \\end{pmatrix}\n\\end{align}\n\n\\subsection{Exponential Discretization}\\label{sec:exp_disc}\n\nThe fermion matrix discussed in the previous section is an approximation of\n\\begin{align}\n  {\\hat{M}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x't';xt}\n  &\\equiv {\\hat{K}}_{x'x}\\delta_{t't} - \\mathcal{B}_{t'}{\\hat{F}_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x'x}\\delta_{t'(t+1)},\\label{eq:def_m_exp}\n\\end{align}\nwith\n\\begin{align}\n  {\\hat{K}}_{x'x} &\\equiv \\delta_{x'x}\\\\\n  {\\hat{F}_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x'x} &\\equiv {(e^{\\tilde{\\kappa}-\\tilde{\\mu}})}_{x'x} e^{\\i \\phi_{x(t'-1)}} = {(e^{\\tilde{\\kappa}-\\tilde{\\mu}} F_{t'}(\\phi) )}_{x'x}.\n\\end{align}\nAnd the combination\n\\begin{align}\n  {\\hat{Q}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x't',xt}\n  \\equiv \\delta_{t't}{(\\hat{P})}_{x'x} + \\delta_{t'(t+1)}{(\\hat{T}^+_{t'})}_{x'x} + \\delta_{t(t'+1)}{(\\hat{T}^-_{t'})}_{x'x}\n\\end{align}\nwith\n\\begin{align}\n  {\\hat{P}(\\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= \\delta_{x'x} + {(e^{\\tilde{\\kappa}-\\tilde{\\mu}} e^{\\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa} + \\tilde{\\mu}})}_{x'x}\\\\\n  {\\hat{T}^+_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= - \\mathcal{B}_{t'} {\\hat{F}_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu})}_{x'x} = - \\mathcal{B}_{t'} {(e^{+\\tilde{\\kappa}-\\tilde{\\mu}})}_{x'x} e^{\\i \\phi_{x(t'-1)}}\\\\\n  {\\hat{T}^-_{t'}(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}})}_{x'x} &= - \\mathcal{B}_{t'+1} {\\hat{F}^T_{t'+1}(-\\phi, \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}, -\\tilde{\\mu})}_{x'x} = - \\mathcal{B}_{t'+1} e^{-\\i \\phi_{x't'}} {(e^{\\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}+\\tilde{\\mu}})}_{x'x}\n\\end{align}\nSince both $\\hat{M}$ and $\\hat{Q}$ have the same block structure as $M$ and $Q$, most of the following derivations treat only the diagonal discretization from Section~\\ref{sec:dia_disc}.\nBased on those, results for the exponential discretization are derived where they differ.\n\n\n\\section{DIRECT\\_SINGLE}\\label{sec:direct_square}\n\nThis is the main version of the algorithm implemented in Isle.\nIt treats the fermion matrices for particles $M_p$ and holes $M_h$ separately and uses direct solves.\n\n\\subsection{LU-Decomposition}\\label{sec:lu_v1}\n\nIn order to calculate the determinant of $M$ and solve systems of equations, compute the LU-decomposition of $M$. This can be done analytically in terms of spacial matrices given the specific structure in equation~\\eqref{eq:ferm_mat_block_v1}.\nUse the following ansatz\\footnote{This is an adaptation of the algorithm presented in~\\cite{zivkovic:2013} and is a simplified version of the algorithm presented in~\\cref{sec:lu_decomposition_v2}}:\n\\begin{align}\n  L =\n  \\begin{pmatrix}\n    1   &     &    &        &        &\\\\\n    l_0 & 1   &    &        &        &\\\\\n        & l_1 & \\ddots &        &        &\\\\\n        &     & \\ddots & 1      &        &\\\\\n        &     &   & l_{n-3} & 1      &\\\\\n        &     &   &        & l_{n-2} & 1\n  \\end{pmatrix},\n  \\; U =\n  \\begin{pmatrix}\n    d_0 &     &      &   &        & v_0\\\\\n        & d_1 &     &    &        & v_1\\\\\n        &     & d_2 &    &        & \\vdots \\\\\n        &     &     & \\ddots &        & v_{n-3} \\\\\n        &     &     &    & d_{n-2} & v_{n-2} \\\\\n        &     &     &    &        & d_{n-1}\n  \\end{pmatrix}\n\\end{align}\nNote that each $l$, $d$, and $v$ is an $N_x \\times N_x$ matrix. Multiplying this out and comparing sides of the equation $M = LU$ leads to a set of recursive equations:\n\\begin{itemize}\n\\item $d_i = K$ for $0 \\le i \\le N_t-2$;\\hspace{2em} $d_{N_t-1} = K - l_{N_t-2}v_{N_t-2}$\n\\item $l_i d_i = -F_{i+1}$ for $0 \\le i \\le N_t-2$\n\\item $v_0 = F_0$;\\hspace{2em} $l_{i-1} v_{i-1} + v_i = 0$ for $1 \\le i \\le N_t-2$\n\\end{itemize}\n\n\\noindent\nUsing $d_i = K$ for $i < N_t-1$, we get\n\\begin{align}\n  l_i = - F_{i+1} K^{-1}\\label{eq:mlu_l}\n\\end{align}\nand from this\n\\begin{align}\n  v_i &= -l_{i-1}v_{i-1} = F_i K^{-1} v_{i-1} = F_i K^{-1} F_{i-1} K^{-1} v_{i-2}\\\\\n      &\\equiv K A_{0i}\\label{eq:mlu_v}\n\\end{align}\nwith\n\\begin{align}\n  A_{tt'} \\equiv K^{-1} F_{t'} K^{-1} F_{i-1} \\cdots K^{-1} F_t.\\label{eq:def_partial_A}\n\\end{align}\nFinally, we get the non trivial $d$:\n\\begin{align}\n  d_{N_t-1} = K + F_{N_t-1} K^{-1} K A_{0(n-2)} = K (1 + A),\n\\end{align}\nwhere $A$ without index is\n\\begin{align}\n  A &\\equiv K^{-1}F_{N_t-1}K^{-1} F_{N_t-2} \\cdots K^{-1}F_{1}K^{-1} F_{0}.\\label{eq:def_A}\n\\end{align}\n\n\\subsection{Action}\n\nGiven the LU-decomposition of the previous section, we can write\n\\begin{align}\n  \\det M = \\det L \\det U = (\\prod_{i=0}^{N_t-1}\\,1) (\\prod_{i=0}^{N_t-1}\\,d_i)\n\\end{align}\nRemultiplying the equations for the non-trivial $d$ gives\n\\begin{align}\n  d_{N_t-1} = K + F_{N_t-1}K^{-1} F_{N_t-2}K^{-1} \\cdots F_{1}K^{-1} F_{0}.\n\\end{align}\nHence the determinant is\n\\begin{align}\n  \\det M &= {(\\det\\,K)}^{N_t-1} \\det (K + F_{N_t-1}K^{-1} F_{N_t-2} \\cdots K^{-1}F_{1}K^{-1} F_{0})\\\\\n         &= {(\\det\\,K)}^{N_t} \\det(1 + K^{-1}F_{N_t-1}K^{-1} F_{N_t-2} \\cdots K^{-1}F_{1}K^{-1} F_{0}).\\label{eq:det_M_2}\n\\end{align}\nIt is possible to move the inverse to $F$ by factoring in one $K$ and factoring out one $F$ and iterating:\n\\begin{align}\n  \\det M &= {(\\det\\,K)}^{N_t-1} \\det F_{N_t-1} \\det(F_{N_t-1}^{-1} K + K^{-1} F_{N_t-2} \\cdots K^{-1}F_{1}K^{-1} F_{0})\\\\\n         &= {(\\det\\,K)}^{N_t-2} \\det (F_{N_t-1} F_{N_t-2}) \\det(F_{N_t-2}^{-1} K F_{N_t-1}^{-1} K + K^{-1} F_{N_t-3} \\cdots K^{-1} F_{0})\\\\\n         &= \\Big(\\prod_{t=0}^{N_t-1} \\det F_{t}\\Big) \\det(1 + F_0^{-1} K F_1^{-1} K \\cdots F_{N_t-2}^{-1} K F_{N_t-1}^{-1} K)\\\\\n         &= e^{\\i \\Phi} \\det(1 + A^{-1}),\\label{eq:det_M_1}\n\\end{align}\nwhere $\\Phi \\equiv \\sum_{x,t} \\phi_{x,t}$.\nApply the logarithm to~\\eqref{eq:det_M_1} to get the final result:\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    \\log \\det M &= \\i \\Phi  + \\log \\det (1 + A^{-1}),\\label{eq:det_M}\\\\\n    A^{-1} &\\equiv F_0^{-1}K F_1^{-1}K \\cdots F_{N_t-1}^{-1}K.\\label{eq:def_Ainv}\n  \\end{align}\n\\end{resultbox}\n\\noindent\nThe action~\\eqref{eq:ferm_action_v1} is the sum of contributions from particles and holes, i.e.\n\\begin{align}\n  S_\\text{ferm} = - \\log \\det (1 + A_p^{-1}) - \\log \\det (1 + A_h^{-1}).\n\\end{align}\nIn general those contributions are not related by a simple equation meaning that both need to be computed from scratch. Equation~\\eqref{eq:det_M_1} is the better choice here compared to~\\eqref{eq:det_M_2} because all individual matrices that contribute to the former are sparse.\\\\\n\n\\noindent\nThe result for the exponential discretization, Section~\\ref{sec:exp_disc}, can be obtained via the substitutions\n\\begin{align}\n  K &\\mapsto \\hat{K} = \\mathds{1}\\label{eq:exp_subs_K}\\\\\n  F_{t'} &\\mapsto \\hat{F}_{t'}\\label{eq:exp_subs_F}\n\\end{align}\nApplying them to~\\eqref{eq:det_M_2} gives\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    \\log \\det \\hat{M}_p &= \\log \\det (1 + \\hat{A}),\\label{eq:det_M_exp}\\\\\n    \\hat{A} &\\equiv \\hat{F}_{N_t-1} \\hat{F}_{N_t-2} \\cdots \\hat{F}_{1} \\hat{F}_{0}.\\label{eq:def_B}\n  \\end{align}\n\\end{resultbox}\n\n\\noindent\nNumerical experiments have shown that using equation~\\eqref{eq:det_M_exp} can be unstable for holes and large values of $\\beta$.\nFor this reason, the hole determinant should be calculated using the following, which is based on~\\eqref{eq:det_M_1} with appropriate substitutions for the exponential discretization:\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    \\log \\det \\hat{M}_h &= -\\i \\Phi  - N_t \\log \\det e^{-\\sigma_{\\tilde{\\kappa}}\\kappa-\\mu} + \\log \\det (1 + \\hat{A}^{-1}),\\label{eq:det_M_exp_h}\\\\\n    \\hat{A}^{-1} &\\equiv \\hat{F}_0^{-1} \\hat{F}_1^{-1} \\cdots \\hat{F}_{N_t-1}^{-1}\n  \\end{align}\n\\end{resultbox}\n\n\n\\subsection{Force}\n\nThe fermionic force at spacetime point $\\mu\\tau$ is given by\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} = -\\dpd{H_{\\text{ferm}}}{\\phi_{\\mu\\tau}} = -\\dpd{S_\\text{ferm}}{\\phi_{\\mu\\tau}} =  \\dpd{}{\\phi_{\\mu\\tau}} \\Big[\\log \\det M(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}) + \\log \\det M(-\\phi, \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}, -\\tilde{\\mu})\\Big].\n\\end{align}\n$\\dot{\\pi}$ is complex valued in general. For now we will ignore this fact and compute the force from the above equation.\nUsing~\\eqref{eq:det_M} and Jacobi's formula, the derivative can be expressed as\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} &= \\Tr \\Big[{(1+A_p^{-1})}^{-1}\\dpd{}{\\phi_{\\mu\\tau}}A_p^{-1} + {(1+A_h^{-1})}^{-1}\\dpd{}{\\phi_{\\mu\\tau}}A_h^{-1}\\Big],\\label{eq:force_v1}\\\\\n    A^{-1} &\\equiv F_0^{-1}K F_1^{-1}K \\cdots F_{N_t-1}^{-1}K\n  \\end{align}\n\\end{resultbox}\n\\noindent\nFor reference, write out $\\dot{\\pi}_{\\text{ferm}}$ explicitly. First, in order to improve readability denote partial products of $A^{-1}$ as\n\\begin{align}\n  A^{-1}_{tt'} \\equiv F_t^{-1}K \\cdots F_{t'}^{-1}K, \\qquad A^{-1}_{tt} \\equiv F_t^{-1}K\n\\end{align}\nwhich is the inverse of~\\eqref{eq:def_partial_A}.\nThe general case:\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} = -\\i {\\big(A^{-1}_{p,(\\tau+1)(N_t-1)} {(1+A_p^{-1})}^{-1} A^{-1}_{p,0\\tau}\\big)}_{\\mu\\mu} + \\i {\\big(A^{-1}_{h,(\\tau+1)(N_t-1)} {(1+A_h^{-1})}^{-1} A^{-1}_{h,0\\tau}\\big)}_{\\mu\\mu}\n\\end{align}\nElements near the boundary:\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu0} &= -\\i {\\big(A^{-1}_{p,1(N_t-1)} {(1+A_p^{-1})}^{-1} A^{-1}_{p,00}\\big)}_{\\mu\\mu} + \\i {\\big(A^{-1}_{h,1(N_t-1)} {(1+A_h^{-1})}^{-1} A^{-1}_{h,00}\\big)}_{\\mu\\mu}\\\\\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu(N_t-1)} &= -\\i {\\big(A^{-1}_{p} {(1+A_p^{-1})}^{-1}\\big)}_{\\mu\\mu} + \\i {\\big(A^{-1}_{h} {(1+A_h^{-1})}^{-1}\\big)}_{\\mu\\mu}\\\\\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu(N_t-2)} &= -\\i {\\big(A^{-1}_{p,(N_t-1)(N_t-1)} {(1+A_p^{-1})}^{-1} A^{-1}_{p,0(N_t-2)}\\big)}_{\\mu\\mu} \\nonumber\\\\\n                                 &\\quad + \\i {\\big(A^{-1}_{h,(N_t-1)(N_t-1)} {(1+A_h^{-1})}^{-1} A^{-1}_{h,0(N_t-2)}\\big)}_{\\mu\\mu}\n\\end{align}\nKeep in mind that $\\mu$ is \\emph{not} summed over, even when it appears twice in one term.\\\\\n\n\\noindent\nThe force in the exponential discretization can be calculated by applying the same substitutions as for the action itself, Eqs.~\\eqref{eq:exp_subs_K} and~\\eqref{eq:exp_subs_F}.\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    {(\\dot{\\hat{\\pi}}'_{\\text{ferm}})}_{\\mu\\tau} &= \\Tr \\Big[{(1+\\hat{A}_p^{-1})}^{-1}\\dpd{}{\\phi_{\\mu\\tau}}\\hat{A}_p^{-1} + {(1+\\hat{A}_h^{-1})}^{-1}\\dpd{}{\\phi_{\\mu\\tau}}\\hat{A}_h^{-1}\\Big],\\\\\n    \\hat{A}^{-1} &\\equiv \\hat{F}_0^{-1} \\hat{F}_1^{-1} \\cdots \\hat{F}_{N_t-1}^{-1}\n  \\end{align}\n\\end{resultbox}\n\\noindent\nThis form is essentially identical to~\\eqref{eq:force_v1} and thus the same algorithm can be used.\n\n\n\\subsection{Solver}\\label{sec:solver_v1}\n\nLinear systems of equations of the form\n\\begin{align}\n  M x = b\\label{eq:linear_system_v1}\n\\end{align}\ncan be solved using an LU-decomposition and forward-/back-substitution.\nIt is straight-forward to derive expressions for the result using the algorithm presented in Section~\\ref{sec:lu_v1}.\n\n\\paragraph{Diagonal Discretization}\nBegin by solving the auxiliary system $L y = b$:\n\\begin{align}\n  y_0 &= b_0\\label{eq:y0_v1}\\\\\n  y_i &= b_i + F_i K^{-1}y_{i-1} \\quad \\text{for} \\quad i > 0\\label{eq:recursion_y_v1}\n\\end{align}\nAnd then solve the original equations by solving $U x = y$:\n\\begin{align}\n  x_{N_t-1} &= {(1+A)}^{-1} K^{-1} y_{N_t-1}\\\\\n  x_i &= K^{-1} y_i - A_{0i}x_{N_t-1} \\quad \\text{for} \\quad i < N_t-1,\n\\end{align}\nwhere the definitions for $A$ and $A_{tt'}$ are given in~\\eqref{eq:def_A} and~\\eqref{eq:def_partial_A}, respectively.\n\n\\noindent\nThose equations, while formally a valid solution to equation~\\eqref{eq:linear_system_v1}, are sub optimal because they involve $K^{-1}$ which is dense.\nBoth for speed and numerical accuracy it is beneficial to modify those equations as follows.\nExpand the recursion~\\eqref{eq:recursion_y_v1} to get\n\\begin{align}\n  y_i &= b_i + (F_i K^{-1}) b_{i-1} + (F_{i} K^{-1} F_{i-1}K^{-1}) b_{i-2} + \\cdots + (F_i K^{-1} \\cdots F_1 K^{-1}) b_0\\\\\n      &= K A_{0i} \\big[(F_0^{-1} K F_1^{-1} K \\cdots F_i^{-1}) b_i + (F_0^{-1} K F_1^{-1} K \\cdots F_{i-1}^{-1}) b_{i-1} + \\cdots + (F_0^{-1}) b_0\\big]\\\\\n  &\\equiv K A_{0i} z_i.\n\\end{align}\nNow substitute this for $y$ in equations~\\eqref{eq:y0_v1} and~\\eqref{eq:recursion_y_v1} to get the relations\n\\begin{align}\n  z_0 &= F_0^{-1} b_0\\\\\n  z_i &= A_{0(i-1)}^{-1} F_i^{-1} b_i + z_{i-1} \\quad \\text{for} \\quad i > 0.\n\\end{align}\nFinally, the solution $x$ can be obtained as\n\\begin{align}\n  (1 + A^{-1}) x_{N_t-1} &= z_{N_t-1}\\\\\n  A_{0i}^{-1} x_i &= z_i - x_{N_t-1} \\quad \\text{for} \\quad i < N_t-1.\n\\end{align}\n$x$ can best be calculated by constructing $A_{0i}^{-1}$ and $A^{-1}$ and solving the equations using a standard dense solver in order to avoid calculating the numerically less stable $A_{0i}$.\nIn this form of the equations, $K^{-1}$ is no longer needed.\n\n\\paragraph{Exponential Discretization}\nThe equations for the exponential discretization can again be obtained via substitutions~\\eqref{eq:exp_subs_K} and~\\eqref{eq:exp_subs_F}.\nA solver based on the rearranged equations for the diagonal discretization was found to be more stable than based on the initial equations even though here $K \\equiv \\mathds{1}$.\nThe result is\n\\begin{align}\n  z_0 &= \\hat{F}_0^{-1} b_0\\\\\n  z_i &= \\hat{A}_{0i}^{-1} b_i + z_{i-1} \\quad \\text{for} \\quad i > 0\n\\end{align}\nand\n\\begin{align}\n  (1 + \\hat{A}^{-1}) x_{N_t-1} &= z_{N_t-1}\\\\\n  \\hat{A}_{0i}^{-1} x_i &= z_i - x_{N_t-1} \\quad \\text{for} \\quad i < N_t-1.\n\\end{align}\n\n\n\\clearpage\n\\section{DIRECT\\_SQUARE}\n\nThis version uses the combined matrix $Q = M(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}) M^T(-\\phi, \\sigma_{\\tilde{\\kappa}}\\tilde{\\kappa}, -\\tilde{\\mu})$ to treat particles and holes together.\nThis algorithm is implemented as well because it is more stable in the spin basis ($\\alpha=0$).\nIt is however much slower than DIRECT\\_SINGLE.\\@\n\n\\subsection{LU-Decomposition}\\label{sec:lu_decomposition_v2}\n\nThe determinant of $Q$ can be computed via an LU-decomposition using an ansatz similar to~\\cite{zivkovic:2013}.\n\\begin{align}\n  L =\n  \\begin{pmatrix}\n    1   &     &        &        &        &\\\\\n    l_0 & 1   &        &        &        &\\\\\n        & l_1 & \\ddots &        &        &\\\\\n        &     & \\ddots & 1      &        &\\\\\n        &     &        & l_{n-3} & 1      & \\\\\n    h_0 & h_1 & \\cdots  & h_{n-3} & l_{n-2} & 1\n  \\end{pmatrix},\n  \\; U =\n  \\begin{pmatrix}\n    d_0 & u_0 &        &        &        & v_0    \\\\\n        & d_1 & u_1    &        &        & v_1    \\\\\n        &     & d_2    & \\ddots &        & \\vdots \\\\\n        &     &        & \\ddots & u_{n-3} & v_{n-3} \\\\\n        &     &        &        & d_{n-2} & u_{n-2} \\\\\n        &     &        &        &        & d_{n-1}\n  \\end{pmatrix}\n\\end{align}\nNote that written like this, each component of $L$ and $U$ is an $N_x \\times N_x$ matrix, meaning they do not commute.\nIt is straight forward to derive an iteration procedure to calculate all elements of $L$ and $U$. Most of those relations can be read off immediately, the others can be proven using\nsimple induction.\\\\\n\n\\noindent\nCompute all except last $d, u, l$:\n\\begin{align}\n  \\begin{matrix}\n    d_0 = P                & u_0 = T^-_0 & l_0 = T^+_1 d_{0}^{-1} & \\\\\n    d_i = P - l_{i-1}u_{i-1} & u_i = T^-_i & l_i = T^+_{i+1} d_{i}^{-1} & \\forall i \\in [1, N_t-3] \\\\\n    d_{N_t-2} = P - l_{N_t-3} u_{N_t-3} & & &\n  \\end{matrix}\n\\end{align}\nAnd all $v, h$:\n\\begin{align}\n  \\begin{matrix}\n    v_0 = T^+_0           & h_0 = T^-_{N_t-1} d_0^{-1} & \\\\\n    v_i = - l_{i-1} v_{i-1} & h_i = - h_{i-1} u_{i-1} d_{i}^{-1} & \\forall i \\in [1, N_t-3]\n  \\end{matrix}\n\\end{align}\nFinally, compute the remaining blocks:\n\\begin{align}\n  u_{N_t-2} &= T^-_{N_t-2} - l_{N_t-3} v_{N_t-3}\\\\\n  l_{N_t-2} &= (T^+_{N_t-1} - h_{N_t-3} u_{N_t-3}) d_{N_t-2}^{-1}\\\\\n  d_{N_t-1} &= P - l_{N_t-2}u_{N_t-2} - \\sum_{i=0}^{N_t-3}\\, h_i v_i\n\\end{align}\n\n\\noindent\nEven though all $P$, $T^+$, and $T^-$ are sparse, the inversions of $d_i$ produce dense matrices in general meaning that this algorithm uses mostly dense algebra.\n\n\\subsection{Action}\n\nThe action is easy to evaluate once the LU-decomposition of $Q$ is known. It is (see~\\eqref{eq:ferm_action_v2})\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    S_\\text{ferm} = - \\log \\det Q = -\\log \\prod_{i=0}^{N_t-1} \\det (d_i) = -\\sum_{i=0}^{N_t-1}\\, \\log \\det (d_i)\n  \\end{align}\n\\end{resultbox}\n\\noindent\nSince the $d$'s are dense, a standard algorithm for computing $\\log\\det d_i$ can be used.\n\n\\subsection{Force}\n\nThe fermionic force at spacetime point $\\mu\\tau$ is given by\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} = -\\dpd{H_{\\text{ferm}}}{\\phi_{\\mu\\tau}} = -\\dpd{S_\\text{ferm}}{\\phi_{\\mu\\tau}} =  \\dpd{}{\\phi_{\\mu\\tau}} \\log \\det Q(\\phi, \\tilde{\\kappa}, \\tilde{\\mu}, \\sigma_{\\tilde{\\kappa}}).\n\\end{align}\n$\\dot{\\pi}$ is complex valued in general. For now we will ignore this fact and compute the force from the above equation.\nSince we have no closed form solution for $\\det Q$, we use Jacobi's formula to compute the derivative of $Q$:\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} = \\Tr Q^{-1} \\dpd{}{\\phi_{\\mu\\tau}} Q\n\\end{align}\nThe derivative acts only on $T^\\pm$, thus\n\\begin{align}\n  {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau}\n  &= Q^{-1}_{xt,x't'} \\dpd{}{\\phi_{\\mu\\tau}} Q_{x't',xt}\\\\\n  &= \\i Q^{-1}_{xt,x't'} \\big[\\delta_{t'(t+1)}\\delta_{\\tau(t'-1)}\\delta_{x'\\mu}  {(T^+_{t'})}_{x'x} - \\delta_{t(t'+1)}\\delta_{\\tau t}\\delta_{x\\mu} {(T^-_{t'})}_{x'x}\\big]\n\\end{align}\nand finally\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    {(\\dot{\\pi}_{\\text{ferm}})}_{\\mu\\tau} = \\i \\left[{(T^+_{\\tau+1})}_{\\mu x}Q^{-1}_{x\\tau,\\mu(\\tau+1)} - Q^{-1}_{\\mu(\\tau+1),x\\tau}{(T^-_\\tau)}_{x\\mu}\\right].\n  \\end{align}\n\\end{resultbox}\n\\noindent\nNote that $\\mu$ and $\\tau$ are \\emph{not} summed over even though they are repeated on the right hand sides.\\\\\n\n\\noindent\nThe internal structure of the $\\hat{T}^{\\pm}$ for the exponential discretization is different from $T^\\pm$ such that the derivative acts in a different way.\nHere, the force is\n\\begin{align}\n  {(\\dot{\\hat{\\pi}}_{\\text{ferm}})}_{\\mu\\tau} = \\i \\hat{Q}^{-1}_{xt,x't'} \\big[{(\\hat{T}^+_{\\tau+1})}_{x'x} \\delta_{x\\mu} \\delta_{t\\tau} \\delta_{t'(\\tau+1)} - {(\\hat{T}^-_\\tau)}_{x'x} \\delta_{x'\\mu} \\delta_{t'\\tau} \\delta_{t(t'+1)}\\big]\n\\end{align}\nAnd thus\n\\begin{resultbox}\n  \\vspace{-\\baselineskip}\n  \\begin{align}\n    {(\\dot{\\hat{\\pi}}_{\\text{ferm}})}_{\\mu\\tau} = \\i \\left[\\hat{Q}^{-1}_{\\mu\\tau,x'(\\tau+1)} {(\\hat{T}^+_{\\tau+1})}_{x'\\mu} - {(\\hat{T}^-_\\tau)}_{\\mu x} \\hat{Q}^{-1}_{x(\\tau+1),\\mu\\tau}\\right].\n  \\end{align}\n\\end{resultbox}\n\n\\subsection{Solver}\n\nA linear system of equations $Q x = b$ can be solved via an LU-decomposition and forward-/back-substitution.\n\n\\paragraph{Matrix-Vector Equation}\nSolve a system of equations for a single right hand side, i.e. $x$ and $b$ are vectors. Start by solving the auxiliary system $L y = b$:\n\\begin{align}\n  y_0 &= b_0\\\\\n  y_i &= b_i - l_{i-1} y_{i-1}\\quad \\text{for}\\quad i = 1, \\ldots,  N_t-2\\\\\n  y_{N_t-1} &= b_{N_t-1} - l_{N_t-2} y_{N_t-2} - \\textstyle\\sum_{j=0}^{N_t-3}\\, h_j y_j\n\\end{align}\nThen solve $Ux = y$:\n\\begin{align}\n  x_{N_t-1} &= d_{N_t-1}^{-1} y_{N_t-1}\\\\\n  x_{N_t-2} &= d_{N_t-2}^{-1} (y_{N_t-2} - u_{N_t-2} x_{N_t-1})\\\\\n  x_i &= d_i^{-1} (y_i - u_i x_{i+1} - v_i x_{N_t-1}) \\quad \\text{for} \\quad i = 0, \\ldots, N_t-3\n\\end{align}\n\n\\paragraph{Inversion}\nInvert $Q$ by solving $Q X = \\mathds{1}$ for $X \\equiv Q^{-1}$, where $\\mathds{1}$ is the $N_t N_x \\times N_t N_x$ unit matrix.\nStart by solving the auxiliary equation $L Y = \\mathds{1}$:\n\\begin{align}\n  y_{0j} &= \\delta_{0j}\\\\\n  y_{ij} &= \\begin{cases}\n    \\textstyle\\prod_{k=j}^{i-1} (-l_{k}) & \\mathrm{for}\\quad i > j\\\\\n    \\delta_{ij} & \\mathrm{for}\\quad i\\leq j\n  \\end{cases}, \\quad\\text{for}\\quad i = 1, \\ldots, N_t-2\\\\\n  y_{(N_t-1)j} &= \\delta_{(N_t-1)j} - \\textstyle\\sum_{k=j}^{N_t-3} h_{k} y_{kj} - l_{N_t-2} y_{(N_t-2)j}\n\\end{align}\nThen solve $U X = Y$:\n\\begin{align}\n  x_{(N_t-1)j} &= d_{N_t-1}^{-1}y_{(N_t-1)j}\\\\\n  x_{(N_t-2)j} &= d_{N_t-2}^{-1}(y_{(N_t-2)j} - u_{N_t-2}x_{(N_t-1)j})\\\\\n  x_{ij} &= d_{i}^{-1}(y_{ij} - u_{i}x_{(i+1)j} - v_{i}x_{(N_t-1)j}) \\quad\\text{for}\\quad i = 0, \\ldots, N_t-3\n\\end{align}\nLike in the LU-decomposition itself, those relations can be read off, or proven using simple induction.\nApart from the last row, the $y$'s are independent from each other while the $x$'s have to be computed iterating over rows from $N_t-1$ though 0. However, different columns never mix.\n\n\\clearpage\n\\bibliographystyle{unsrt}\n\\bibliography{references}\n\n\\end{document}", "meta": {"hexsha": "354e34a81a2ad4896f9e1f9cf58496e578aff5e3", "size": 26676, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/algorithm/hubbardFermiAction.tex", "max_stars_repo_name": "chelseajohn/isle", "max_stars_repo_head_hexsha": "f610b55a1e8b6d2584896eb649092b0524cc1f8c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-14T17:47:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T22:31:25.000Z", "max_issues_repo_path": "docs/algorithm/hubbardFermiAction.tex", "max_issues_repo_name": "chelseajohn/isle", "max_issues_repo_head_hexsha": "f610b55a1e8b6d2584896eb649092b0524cc1f8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2018-06-04T07:09:02.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-11T09:37:08.000Z", "max_forks_repo_path": "docs/algorithm/hubbardFermiAction.tex", "max_forks_repo_name": "chelseajohn/isle", "max_forks_repo_head_hexsha": "f610b55a1e8b6d2584896eb649092b0524cc1f8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-01-18T19:18:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-26T03:27:15.000Z", "avg_line_length": 50.5227272727, "max_line_length": 300, "alphanum_fraction": 0.5996026391, "num_tokens": 10610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4083829008752294}}
{"text": "\\documentclass{article}\n\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{placeins}\n\n\\usepackage[margin=1in]{geometry}\n\\usepackage{float}\n\n\n\\def\\hwtitle{Computational Physics HW4}\n\\def\\hwauthor{Ethan Rooney}\n\\def\\hwdate{2020-02-26}\n\n\\usepackage{fancyhdr}\n\\lhead{\\hwauthor}\n\\chead{\\hwtitle}\n\\rhead{\\hwdate}\n\\lfoot{\\hwauthor}\n\\cfoot{}\n\\rfoot{\\thepage}\n\\renewcommand{\\footrulewidth}{0.4pt}\n\\pagestyle{fancy}\n\n\\author{\\hwauthor}\n\\title{\\hwtitle}\n\\date{\\hwdate}\n\n\\begin{document}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\\section{Introduction}\n \nThis weeks homework is the continuation of Week 3. We are extending and generalizing from 2 body interactions to $n$-body systems. The math is essentially unchanged from last weeks assignment. We are utilizing the RK2 integrator, with more bodies.\n\n\\section{Results}\n\n\\subsection{Question 0}\n\nHere we check the validity of our generalized RK2 integrator with a 2 body problem. A \"earth-like\" object is put into motion 1 AU away from a \"sun-like\" object with the same velocity as the earth. We see a circular orbit. This is a good start.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p0.pdf}\n\t\\end{center}\n\t\\caption{Qualitative Check of the Integrator. An Earth-like object completes an orbit in 1 year.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\subsection{Question 1}\n\nWe continue the extension of last weeks work with a trial run of a 3-body system much like the one we find in our own solar system.\n\n\\subsubsection{Part 1}\n\nThe Moon's orbit is close enough to Earth's that the orbit of Earth is obscured.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1a.pdf}\n\t\\end{center}\n\t\\caption{3 Body system of Sun, Earth, and Moon.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nOver 8 Years the Moon slowly drifts towards, and away from the earth with a slight net movement away.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1b.pdf}\n\t\\end{center}\n\t\\caption{8 Years of the Moon's Orbit. The thick ring of blue is overlapping Sinusoidal orbits.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nWe can see the ebb and flow of the moons orbit clearly in the Graphic below. There is a gentle trend overall for the moon to drift away from the earth.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1c.pdf}\n\t\\end{center}\n\t\\caption{The Moon's orbit is perturbed by the Sun's gravity.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1d.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1e.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-1f.pdf}\n\t\\end{center}\n\t\\caption{Through the oscillations of the Moon's Orbit Kinetic energy is exchanged for Potential Energy, but Total Energy is conserved in this simulation.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\subsubsection{Part 2}\n\nWhat Happens if we change the parameters of the Earth Sun and Moon?\nBelow are similar plots, but instead of the actual values of the Sun, Earth and Moon, I plotted $M_1 = 1, M_2 = 10^{-2}, M_3 = 10^{-4}, r_{23} = 0,06$ AU. \n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2a.pdf}\n\t\\end{center}\n\t\\caption{With a more massive planet orbiting the Sun we see a noticeable drift of the system. Furthermore the initial conditions are such that the sun plays a larger roll in shaping the orbit of the Moon.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2b.pdf}\n\t\\end{center}\n\t\\caption{The Perturbations Caused by the Sun are much more Pronounced.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2c.pdf}\n\t\\end{center}\n\t\\caption{Interesting Harmonics Form in the Moon's orbit.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2d.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2e.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-2f.pdf}\n\t\\end{center}\n\t\\caption{Total Energy of the system is conserved.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\subsubsection{Part 3}\n\nPlotted for $M_1 = 1, M_2 = 10^{-2}, M_3 = 10^{-4}, r_{23} = 0,08$ AU. \n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3a.pdf}\n\t\\end{center}\n\t\\caption{The Moon is Pulled Free from the Earths Orbit, and Establishes a Planetary orbit.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3b.pdf}\n\t\\end{center}\n\t\\caption{The Moon Leaving Orbit from the Planet}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3c.pdf}\n\t\\end{center}\n\t\\caption{Moon Ejected from Orbiting the Planetary Body, but remains in the system.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3d.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3e.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-3f.pdf}\n\t\\end{center}\n\t\\caption{Exchange of Energy Types, Total Energy Conserved}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier  \n\n\\subsubsection{Part 4}\n\nPlotted for $M_1 = 1, M_2 = 10^{-1}, M_3 = 10^{-4}, r_{23} = 0.2$ AU. \n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4a.pdf}\n\t\\end{center}\n\t\\caption{Moon like object ejected from system.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nConsiderable drift is now occurring in the system, and the \"Moon\" is rapidly ejected from orbit.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4b.pdf}\n\t\\end{center}\n\t\\caption{The \"Moon\" Completes a few orbits before being Ejected from the system.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4c.pdf}\n\t\\end{center}\n\t\\caption{Bye Moon!}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4d.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4e.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p1-4f.pdf}\n\t\\end{center}\n\t\\caption{Energy of the system Dominated by they Sun/Earth interactions.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\n\\subsection{Question 2}\n\nPlotted for $M_1 = M_2 = M_3 = 1, x_1=(0,0), v_1 = (1,-1), x,2 = (1,0), v_2 = (0,6), x_3=(2,0), v_3=(0,6)$ \n\nBelow we see the motion of the 3 bodies relative to the center of mass for the system. It appears very chaotic.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p2-1a.pdf}\n\t\\end{center}\n\t\\caption{4 Body system Evolution over 10 years. Corrected for Center of Mass Motion}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nWith out correcting for the drift of the system, the net momentum of the system causes a drift in the positive x and negative y directions.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p2-1b.pdf}\n\t\\end{center}\n\t\\caption{Overall motion of system. Notice down and left trend.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nWe can see the ebb and flow of the moons orbit clearly in the Graphic below. There is a gentle trend overall for the moon to drift away from the earth.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p2-1c.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p2-1d.pdf}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p2-1e.pdf}\n\t\\end{center}\n\t\\caption{Energy Exchange Of 3 equal mass bodies in a system. Total Energy is conserved until $\\sim$9 year. This discontinuity occurs when 2 of the bodies had a near collision and where ejected. The System is no longer gravitationally bound.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nIn the images of energy above, when the bodies get very close, the rate of change of the position and velocity are high enough that the linear approximation over dt is no longer valid. The actual effects of these small separation vectors would most likely caused a collision of the bodies, or of a breakup of one or both of the bodies into smaller chunks. One possible solution is to add collision detection, and allow for a perfectly inelastic collision of the 2 bodies to form 1 large gravitationally bound body, or to implement a \"monitoring system\" that could dial up or down the time step for systems when 2 bodies get very close.\n\n\\subsection{Question 3}\nFor the $n$-body problem the compute resources required scales as $\\mathcal{O}(n^2)$. This is because for each body every other body has to be computed against it. To reduce steps you could compute the effects of $i$ on $j$ at the same time you compute the effects of $j$ on $i$ then you wouldn't need to loop over the full list every time, just loop through  $i>j$. But this doesn't change the  $\\mathcal{O}(n^2)$, it would just save some time in the looping. Alternatively, you could threshold each body, and then only compute the effects of nearby objects. To do this you would need to establish a hierarchy of bodies, for example you would compute the effects of the Sun on the Moon, but you could neglect the effects of the Moon on the Sun, while still computing the effect of the Moon on Earth. You could also compute the effects of the CoM on each object. So you would find the CoM for bodies that are relatively close to each other then use the CoM to compute the effects on bodies that are far enough away to treat a cluster of objects as one body.\n\n\\subsection{Bonus Question 4}\n\nSee the Picture below.\n\n\\begin{figure}[!htb]\n\t\\begin{center}\n\t\t\\includegraphics[width=0.6\\textwidth]{images/p4-1a.pdf}\n\t\\end{center}\n\t\\caption{4 Body system with 2 Sun sized objects and an Earth and Moon like Object. Near the end of the Simulation we see the Moon Ejected from the system.}\n\\label{fig:qual}\n\\end{figure}\n\\FloatBarrier\n\nHere we have created a binary star system with 2 one Sol mass objects. \n\nAround one of the Stars, a Earth/Moon system is put into orbit. The orbits of the Planet/Moon system is complicated immensely by the existence of the second star. Because of this the orbits they follow are highly irregular and eventually the Moon is ejected from the system when it ventures too close to its host planet.\n\nThe Dominant Forces are the 2 main stars, while the Planets gravity is subdominant on the moon.\n\n\n\\section{Conclusions}\n\nThis Project was rather neat. One tweak I made to the code was to ignore interactions between objects if the length of the separation vector was zero. This prevented a significant number of \\texttt{-nan} errors, this was especially useful when working with 2 body systems to suppress errors caused by nonexistent bodies that had mass of zero. \n\n\\end{document}\n", "meta": {"hexsha": "9dadd71c4b87a03d91e30946729326dcc8672c03", "size": 11070, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week4/report/rooney_week4.tex", "max_stars_repo_name": "ethanrooney/comphys", "max_stars_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week4/report/rooney_week4.tex", "max_issues_repo_name": "ethanrooney/comphys", "max_issues_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week4/report/rooney_week4.tex", "max_forks_repo_name": "ethanrooney/comphys", "max_forks_repo_head_hexsha": "62e393a554c311733bdf092becbe2a8675ba8a91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.2950819672, "max_line_length": 1057, "alphanum_fraction": 0.7531165312, "num_tokens": 3349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.7799928900257126, "lm_q1q2_score": 0.40826415066511024}}
{"text": "\n\\chapter{Normal forms}\\setcounter{ProbPart}{0}\n\n\\problempart\n\\label{pr.DNF}\nConsider the following sentences:\n\t\\begin{earg}\n\t\t\\item $(A \\eif \\enot B)$\n\t\t\\item $\\enot (A \\eiff B)$\n\t\t\\item $(\\enot A \\eor \\enot (A \\eand B))$\n\t\t\\item $(\\enot (A \\eif B ) \\eand (A \\eif C))$\n\t\t\\item $(\\enot (A \\eor B) \\eiff ((\\enot C \\eand \\enot A) \\eif \\enot B))$\n\t\t\\item $((\\enot (A \\eand \\enot B) \\eif C) \\eand \\enot (A \\eand D))$\n\t\\end{earg}\nFor each sentence, find an equivalent sentence in DNF and one in CNF.\n\\myanswer{We give a solution for (2). The truth table for $\\enot (A \\eiff B)$ is:\n\\begin{center}\n\\begin{tabular}{c c | l}\n$A$ & $B$ & $\\enot (A \\eiff B)$\\\\\n\\hline\nT & T & F \\\\\nT & F & T \\\\\nF & T & T \\\\\nF & F & F \\\\\n\\end{tabular}\n\\end{center}\nA sentence in DNF can be read off from lines 2 and 3:\n\\[(A \\eand \\enot B) \\eor (\\enot A \\eand B)\\]\nand one in CNF from lines 1 and~4:\n\\[(\\enot A \\eor \\enot B) \\eand (A \\eor B).\\]}\n\n\\stepcounter{chapter} % Functional completeness\n\n\\chapter{Proving equivalences}\\setcounter{ProbPart}{0}\n\n\\problempart\n\\label{pr.DNF2}\nConsider the following sentences:\n\\begin{earg}\n\t\\item $(A \\eif \\enot B)$\n\t\\item $\\enot (A \\eiff B)$\n\t\\item $(\\enot A \\eor \\enot (A \\eand B))$\n\t\\item $(\\enot (A \\eif B ) \\eand (A \\eif C))$\n\t\\item $(\\enot (A \\eor B) \\eiff ((\\enot C \\eand \\enot A) \\eif \\enot B))$\n\t\\item $((\\enot (A \\eand \\enot B) \\eif C) \\eand \\enot (A \\eand D))$\n\\end{earg}\nFor each sentence, find an equivalent sentence in DNF and one inCNF by giving a chain of equivalences. Use (Id), (Absorp), and (Simp) to simplify your sentences as much as possible.\n\\myanswer{We give a solution for (2). Removing `$\\eiff$' and pushing negations inward is common to both:\n\\begin{align*}\n\t& \\enot (A \\eiff B)\\\\\n\t& \\enot((A \\eif B) \\eand (B \\eif A)) && \\text{Bicond}\\\\\n\t& \\enot((\\enot A \\eor B) \\eand (B \\eif A)) && \\text{Cond}\\\\\n\t& \\enot((\\enot A \\eor B) \\eand (\\enot B \\eor A)) && \\text{Cond}\\\\\n\t& \\enot(\\enot A \\eor B) \\eor \\enot(\\enot B \\eor A) && \\text{DeM}\\\\\n\t& (\\enot\\enot A \\eand \\enot B) \\eor (\\enot\\enot B \\eand \\enot A) && \\text{DeM}\\\\\n\t& (A \\eand \\enot B) \\eor (\\enot\\enot B \\eand \\enot A) && \\text{DN}\\\\\n\t& (A \\eand \\enot B) \\eor (B \\eand \\enot A) && \\text{DN}\n\\intertext{The result is now in DNF. To obtain a CNF, we keep going, using (Comm) and (Dist):}\n& ((A \\eand \\enot B) \\eor B) \\eand ((A \\eand \\enot B) \\eor \\enot A) && \\text{Dist}\\\\\n& (B \\eor (A \\eand \\enot B)) \\eand ((A \\eand \\enot B) \\eor \\enot A) && \\text{Comm}\\\\\n& ((B \\eor A) \\eand (B \\eor \\enot B)) \\eand ((A \\eand \\enot B) \\eor \\enot A) && \\text{Dist}\\\\\n& ((B \\eor A) \\eand (B \\eor \\enot B)) \\eand (\\enot A \\eor (A \\eand \\enot B)) && \\text{Comm}\\\\\n& ((B \\eor A) \\eand (B \\eor \\enot B)) \\eand ((\\enot A \\eor A) \\eand (\\enot A \\eor \\enot B)) && \\text{Dist}\\\\\n\\intertext{The result can be simplified using (Simp):}\n& (B \\eor A) \\eand ((\\enot A \\eor A) \\eand (\\enot A \\eor \\enot B)) && \\text{Simp}\\\\\n& (B \\eor A) \\eand (\\enot A \\eor \\enot B) && \\text{Simp}\n\\end{align*}}\n\n\\stepcounter{chapter} % Soundness", "meta": {"hexsha": "371a232908714a90070e9805a166e9fd9682fcd8", "size": 2985, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "solutions/forallx-sol-metatheory.tex", "max_stars_repo_name": "yossirise/forallx-yyc", "max_stars_repo_head_hexsha": "10a6ef36965b84c3783db5e0ad4f8bb2756ecfcf", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2016-10-19T16:43:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:50:40.000Z", "max_issues_repo_path": "solutions/forallx-sol-metatheory.tex", "max_issues_repo_name": "yossirise/forallx-yyc", "max_issues_repo_head_hexsha": "10a6ef36965b84c3783db5e0ad4f8bb2756ecfcf", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 48, "max_issues_repo_issues_event_min_datetime": "2016-10-19T17:26:49.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-06T22:11:07.000Z", "max_forks_repo_path": "solutions/forallx-sol-metatheory.tex", "max_forks_repo_name": "yossirise/forallx-yyc", "max_forks_repo_head_hexsha": "10a6ef36965b84c3783db5e0ad4f8bb2756ecfcf", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2016-10-19T16:44:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-19T10:18:14.000Z", "avg_line_length": 43.2608695652, "max_line_length": 181, "alphanum_fraction": 0.5949748744, "num_tokens": 1293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5428632683808533, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.40824000365474106}}
{"text": "\\chapter{Lecture 30 Jun 13th 2018}%\n\\label{chp:lecture_30_jun_13th_2018}\n% chapter lecture_30_jun_13th_2018\n\n\\section{Polynomial Ring (Continued 3)}%\n\\label{sec:polynomial_ring_continued_3}\n% section polynomial_ring_continued_3\n\n\\subsection{Quotient Rings of Polynomials (Continued)}%\n\\label{sub:quotient_rings_of_polynomials_continued}\n% subsection quotient_rings_of_polynomials_continued\n\nLet $A$ be a non-zero ideal in $F[x]$. By \\cref{propo:ideals_of_f_x_are_principal_ideals}, we know that $A$ is a principal ideal\\index{Principal Ideal} and can be written as $A = \\lra{h(x)}$, for a unique polynomial $h(x) \\in F[x]$.\n\nSuppose that $\\deg h = m \\geq 1$. Consider the quotient ring $R = \\faktor{F[x]}{A}$, and so we have\n\\begin{equation*}\n  R = \\left\\{ \\bar{f(x)} : f(x) + A, f(x) \\in F[x] \\right\\}.\n\\end{equation*}\nWrite $t = \\bar{x} = x + A$. Then by the \\hlnoteb{Division Algorithm}\\sidenote{This entire part until Proposition 89 might need to be rewritten since I am a little lost as to some of the details regarding the discussion.}, we have\n\\begin{equation*}\n  R = \\{ \\bar{a_0} + \\bar{a_1} t + \\hdots + \\bar{a_{m - 1}} t^{m - 1} : a_i \\in F \\}.\n\\end{equation*}\nThe map $\\theta : F \\to R$, given by $a \\mapsto \\bar{a}$, is an injective homomorphism, since $\\theta$ is not a zero map and $\\ker \\theta$ is an ideal of $F$ \\sidenote{Note that a field $F$ has only 2 ideals: $\\{0\\}$ and $F$ itself. Since $\\ker \\theta \\neq F$, we have that $\\ker \\theta = \\{0\\}$ and so $\\theta$ is injective.}. Since we have $F \\cong \\theta(F)$ by the \\hyperref[thm:first_isomorphism_theorem_for_rings]{First Isomorphism Theorem for Rings}, by identifying $F$ with $\\theta(F)$, we can write\n\\begin{equation*}\n  R = \\{ a_0 + a_1 t + \\hdots a_{m - 1} t^{m - 1} : a_i \\in F \\}.\n\\end{equation*}\n\nIt is clear that, in $R$, we have\n\\begin{gather*}\n  a_0 + a_1 t + \\hdots + a_{m - 1} t^{m - 1} = b_0 + b_1 t + \\hdots + b_{m - 1} t^{m - 1} \\\\\n  \\iff \\\\\n  \\forall i \\in \\mathbb{Z} \\enspace 0 \\leq i \\leq m - 1 \\quad a_i = b_i\n\\end{gather*}\n\nFinally, in the ring $R$, we have $h(t) = 0$.\n\nThe following proposition follows from the above discussion.\n\n\\begin{propo}\n\\label{propo:remainder_ring}\nLet $F$ be a field and let $h(x), f(x) \\in F[x]$ be monic with $( \\deg h, \\, \\deg f \\geq 1 )$. Then the quotient ring $R = F[x] / A$ is given by\n\\begin{equation*}\n  R = \\{ a_0 + a_1 t + \\hdots + a_{m - 1} t^{m - 1} : a_i \\in F, \\, h(t) = 0 \\}\n\\end{equation*}\nin which each element of $R$ can be uniquely represented in the above form.\n\\end{propo}\n\n\\begin{note}\n  In $\\mathbb{Z}$, we have that $\\mathbb{Z} / \\lra{n} = \\mathbb{Z}_n = \\{ [0], [1], ..., [n-1] \\}$ which is analogous to our statement in \\cref{propo:remainder_ring} for the case of integers.\n\\end{note}\n\n\\begin{eg}\n  Consider $\\mathbb{R}[x]$ and let $h(x) = x^2 + 1 \\in \\mathbb{R}[x]$. Then\n  \\begin{equation*}\n    \\mathbb{R}[x] = \\{a + bt : a, b \\in \\mathbb{R}, \\, t^2 + 1 = 0 \\} \\cong \\{ a + bi : a, b \\in \\mathbb{R}, \\, i^2 = -1 \\} = \\mathbb{C}\n  \\end{equation*}\n\\end{eg}\n\n\\begin{note}\n  Recall that $\\mathbb{Z}_n$ is a field (or an integral domain) if and only if $n$ is prime.\n\\end{note}\n\n\\begin{propo}\n\\label{propo:principal_ideals_of_polyms_as_fields}\n  Let $F$ be a field nad $h(x) \\in F[x]$ be a monic polynomial with $\\deg h \\geq 1$. TFAE:\n  \\begin{enumerate}\n    \\item $F[x] \\big/ \\lra{h(x)}$ is a field;\n    \\item $F[x] \\big/ \\lra{h(x)}$ is an integral domain;\n    \\item $h(x)$ is irreducible in $F[x]$.\n  \\end{enumerate}\n\\end{propo}\n\n\\begin{proof}\n  $(1) \\implies (2)$ since a field is an integral domain (see \\cref{propo:fields_are_integral_domains}).\n\n  \\noindent $(2) \\implies (3)$: Write $A = \\lra{h(x)}$, If $h(x) = f(x) g(x)$ for $f(x), \\, g(x) \\in F[x]$, then\n  \\begin{align*}\n    [ f(x) + A ] [ g(x) + A ] &= f(x) g(x) + A \\quad \\because A \\text{ is an ideal } \\\\\n                              &= h(x) + A = 0 \\in F[x] \\big/ A.\n  \\end{align*}\n  Then by $(2)$, either $f(x) + A = 0$ or $g(x) + A = 0$, i.e. either $f(x) \\in A$ or $g(x) \\in A$. But if $f(x) \\in A = \\lra{h(x)}$, then $f(x) = q(x) h(x)$ for some $q(x) \\in F[x]$. Then $h(x) = f(x) g(x) = q(x) h(x) g(x)$, which then implies that $0 = h(x) [ 1 - q(x) g(x) ] \\implies q(x) g(x) = 1$ since $F[x]$ is an integral domain. Then we have that $\\deg g = 0$. Similarly, if $g(x) \\in A$, then we have $\\deg f = 0$. Therefore, $h(x)$ is irreducible in $F[x]$ by definition.\n\n  \\noindent $(3) \\implies (1)$: Note that $F[x] \\big/ \\lra{h(x)}$ is a commutative ring. To show that it is a field, it suffices to show that every non-zero element of $F[x] \\big/ \\lra{h(x)}$ has an inverse. Let $f(x) + A \\neq 0 \\in F[x] \\big/ \\lra{h(x)}$ with $f(x) \\in F[x]$. Then $f(x) \\notin A$, and so $h(x) \\not| \\, f(x)$. Since $h(x)$ is irreducible by $(3)$, we have that\n  \\begin{equation*}\n    d(x) = \\gcd[ f(x), h(x) ] = 1.\n  \\end{equation*}\n  Then by \\cref{propo:properties_of_the_greatest_common_divisor}, $\\exists u(x), v(x) \\in F[x]$ such that\n  \\begin{equation*}\n    1 = u(x) h(x) + v(x) f(x).\n  \\end{equation*}\n  Since $h(x) u(x) \\in A$, we have that\n  \\begin{equation*}\n    [v(x) + A] [f(x) + A] = 1 + A.\n  \\end{equation*}\n  It follows that $f(x) + A$ has an inverse in $F[x] \\big/ \\lra{h(x)}$ and thus $F[x] \\big/ \\lra{h(x)}$ is a field. \\qed\n\\end{proof}\n\n% subsection quotient_rings_of_polynomials_continued (end)\n\n% section polynomial_ring_continued_3 (end)\n\n\\section{Factorizations in Integral Domains}%\n\\label{sec:factorizations_in_integral_domains}\n% section factorizations_in_integral_domains\n\n\\subsection{Irreducibles and Primes}%\n\\label{sub:irreducibles_and_primes}\n% subsection irreducibles_and_primes\n\nWe have discussed much about the similarities between $\\mathbb{Z}$ and $F[x]$, and in this chapter, we wish to abstract these similarties and study them in a more general manner to see if other sets that share the same kind of properties. For example, if a set has a \\hlnoteb{unique factorization} for elements and the \\hlnoteb{principal ideal} being the only ideal of the set, then do we still see the same analogy playing out?\n\n\\begin{defn}[Division]\\index{Division}\n\\label{defn:division}\n  Let $R$ be an integral domain and $a, \\, b \\in R$. We say that $a \\, | \\, b$ if $b = ca$ for some $c \\in R$.\n\\end{defn}\n\n\\begin{note}\n  Recall that in $\\mathbb{Z}$, if $n \\, | \\, m$ and $m \\, | \\, n$, then $n = \\pm m$, and the ideal generated by them are the same, i.e. $\\lra{n} = \\lra{m}$.\n\n  Similarly so in $F[x]$< if $f(x) \\, | \\, g(x)$ and $g(x) \\, | \\, f(x)$, then $f(x) = cg(x)$ for some $x \\in F[x]^* = F^*$, and $\\lra{f(x)} = \\lra{g(x)}$.\n\\end{note}\n\n\\begin{propo}[Division in an Integral Domain]\n\\label{propo:division_in_an_integral_domain}\nLet $R$ be an integral domain. Then $\\forall a, b \\in R$, TFAE:\\marginnote{This should be an easy exercise.\n\\begin{ex}\n  Prove \\cref{propo:division_in_an_integral_domain}.\n\\end{ex}\n}\n  \\begin{enumerate}\n    \\item $a \\, | \\, b$ and $b \\, | \\, a$;\n    \\item $a = ub$ for some unit $u \\in R$;\n    \\item $\\lra{a} = \\lra{b}$.\n  \\end{enumerate}\n\\end{propo}\n\n\\begin{defn}[Association]\\index{Association}\n\\label{defn:association}\n  Let $R$ be an integral domain. $\\forall a, b \\in R$, we say that $a$ is \\hldefn{associated to} $b$, denoted by $a \\sim b$, if $a \\, | \\, b$ and $b \\, | \\, a$.\n\\end{defn}\n\n\\begin{note}\n  By \\cref{propo:division_in_an_integral_domain}, we have that $a \\sim a$ for any $a \\in R$.\n\n  \\noindent Also, $a \\sim b \\iff b \\sim a$.\n\n  \\noindent We also have $a \\sim b \\, \\land \\, b \\sim c \\implies a \\sim c$.\n  \n  In other words, $\\sim$ is an equivalence relation\\index{Equivalence Relation} in $R$. Also, it can be shown that\\sidenote{More exercise is always good.\n  \\begin{ex}\n    Prove that the two statements following this is true.\n  \\end{ex}\n  }\n  \\begin{enumerate}\n    \\item $a \\sim a' \\, \\land \\, b \\sim b' \\implies ab \\sim a' b'$.\n    \\item $a \\sim a' \\, \\land \\, b \\sim b' \\implies ( a \\, | \\, b \\iff b \\, | \\, a )$\n  \\end{enumerate}\n\\end{note}\n\n\\begin{eg}\n  Let $R = \\mathbb{Z}[\\sqrt{3}] = \\{ m + n \\sqrt{3} : m, n \\in \\mathbb{Z} \\}$. Note that this is an integral domain\\sidenote{For $(a + b\\sqrt{3}), \\, (c + d\\sqrt{3}) \\in R$ such that\n  \\begin{equation*}\n    (a + b \\sqrt{3})(c + d \\sqrt{3}) = 0\n  \\end{equation*}\n  we would have that\n  \\begin{gather*}\n    (a + b\\sqrt{3})(a - b \\sqrt{3})(c + d\\sqrt{3})(c - d\\sqrt{3}) = 0 \\\\\n    ( a^2 - 3b^2 )( c^2 - 3d^2 ) = 0.\n  \\end{gather*}\n  Since $\\mathbb{Z}$ is an integral domain, suppose $a^2 - 3b^2 = 0$. If $b = 0$, then $a = 0$ and we are done. If $b \\neq 0$, then we have $3 = \\left( \\frac{a}{b} \\right)^2$, and we notice that $\\sqrt{3}$ is irrational. Thus it can only be that $b = 0$. Therefore, $a + b\\sqrt{3} = 0$, implying that there are no zero divisors in $R = \\mathbb{Z}[\\sqrt{3}]$.\n  }. Observe that\n  \\begin{equation*}\n    (2 + \\sqrt{3})(2 - \\sqrt{3}) = 1 \\implies 2 + \\sqrt{3} \\text{ is a unit in } R.\n  \\end{equation*}\n  Then we would have\n  \\begin{equation*}\n    3 + 2 \\sqrt{3} = (2 + \\sqrt{3}) \\sqrt{3}\n  \\end{equation*}\n  and so by \\cref{propo:division_in_an_integral_domain}, we have\n  \\begin{equation*}\n    3 + 2 \\sqrt{3} \\sim \\sqrt{3} \\in \\mathbb{Z}[\\sqrt{3}].\n  \\end{equation*}\n\\end{eg}\n\n% subsection irreducibles_and_primes (end)\n\n% section factorizations_in_integral_domains (end)\n\n% chapter lecture_30_jun_13th_2018 (end)\n", "meta": {"hexsha": "4d13368acd4549f333e8a860aaff97c8f26b99ed", "size": 9277, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PMATH347S18/lectures/lec30.tex", "max_stars_repo_name": "japorized/TeX_notes", "max_stars_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-09-28T21:23:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-21T01:41:27.000Z", "max_issues_repo_path": "PMATH347S18/lectures/lec30.tex", "max_issues_repo_name": "japorized/TeX_notes", "max_issues_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-29T17:58:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-29T17:58:51.000Z", "max_forks_repo_path": "PMATH347S18/lectures/lec30.tex", "max_forks_repo_name": "japorized/TeX_notes", "max_forks_repo_head_hexsha": "5814c8682addc5dd6f9a323758f87e4c4ca57b8e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2017-09-27T20:55:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-27T20:55:58.000Z", "avg_line_length": 48.8263157895, "max_line_length": 507, "alphanum_fraction": 0.6206747871, "num_tokens": 3572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.4081697454326069}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 21, Section 4.5: 2, 6, 11, 14}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{2. A)}\n$R_1$ is symmetric\n\\subsection*{2. B)}\n$R_2$ is symmetric\n\\subsection*{2. C)}\n$R_3$ is not symmetric\n\\subsection*{6.}\n\\{\\{ACBD, CBDA, BDAC, DACB\\}, \\{ADBC, DBCA, BCAD, CADB\\}, \\{ABCD,BCDA,CDAB,DABC\\},\\{ADCB, DCBA, CBAD, BADC\\},\\{ABDC,BDCA,DCAB,CABD\\}, \\{ACDB, CDBA, DBAC, BACD\\}\\}\n\n\\subsection*{11. A)}\nLet $a \\in \\mathds{Z} $ since $a - a = 0$ and a is divisible by $n$, $(a,a) \\in \\mathds{R}$. This means R is reflexive. \n\\subsection*{11. B)}\nLet $a, b \\in \\mathds{Z}$ so that $(a,b) \\in \\mathds{R}$. Since $a - b$ is divisible by $n$, which in turn means that $a - b= kn$ and $b-a= -kn$. Since $-k$ is an integer it means that $b -a$ is divisible by $n$, which means that R is symmetric. \n\\subsection*{11. C)}\n\\subsection*{11. D)}\n\n\\subsection*{14. A)}\n\\{(1,1),(2,2),(3,3),(3,2),(1,3),(1,2)\\}\n\\subsection*{14. B)}\n\\{(1,1),(2,2),(3,3),(3,2),(1,3),(3,1),(2,3)\\}\n\\subsection*{14. C)}\n\\{(1,1),(1,2),(2,1),(2,2)\\}\n\n\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "230355018b8bbce9b326aa8d3ea41292e475a8c5", "size": 1424, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DiscreteMath/Homework21.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DiscreteMath/Homework21.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DiscreteMath/Homework21.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9215686275, "max_line_length": 246, "alphanum_fraction": 0.6179775281, "num_tokens": 630, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.7310585903489892, "lm_q1q2_score": 0.40816974543260687}}
{"text": "% Custom environments\n\n\\theoremstyle{plain}\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem*{theorem*}{Theorem}\n\\newtheorem{lemma}{Lemma}[section]\n\\newtheorem*{lemma*}{Lemma}\n\\newtheorem{prop}{Proposition}[section]\n\\newtheorem{cor}{Corollary}[section]\n\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}\n\\newtheorem{remark}{Remark}\n%\\newtheorem{think}{Gedankenexperiment}\n%\\newtheorem*{think}{Think about it \\faLightbulbO}\n\n\\newtheorem{example}{Example}\n\n\\newenvironment{think}\n\t{\n\t\t\\bigskip\n\t\t\\begin{tcolorbox}\n\t\t\\paragraph{Think about it.}\n\t}{\n\t\t\\end{tcolorbox}\n}\n\n\\newenvironment{extra}\n{\n\t\\bigskip\n\t\\begin{tcolorbox}\n\t\t\\paragraph{Extra Information.}\n\t}{\n\t\\end{tcolorbox}\n}\n\n\n\n% Custom commands\n\n\\newcommand{\\naive}{na\\\"{\\i}ve }\n\\newcommand{\\Naive}{Na\\\"{\\i}ve }\n\\newcommand{\\andor}{and\\textbackslash or }\n\\newcommand{\\erdos}{Erd\\H{o}s }\n\\newcommand{\\renyi}{R\\`enyi }\n\n\n\\newcommand{\\al}{\\alpha}\n\\newcommand{\\be}{\\beta}\n\\newcommand{\\si}{\\sigma}\n\n\\newcommand{\\set}[1]{\\{ #1 \\}} % A set\n\\newcommand{\\setII}[1]{\\left\\{ #1 \\right\\}} % A set\n\\newcommand{\\rv}[1]{\\mathbf{#1}} % A random variable\n\\newcommand{\\x}{\\rv x} % The random variable x \n\\newcommand{\\y}{\\rv y} % The random variable x \n\\newcommand{\\U}{\\rv u} % The random variable x \n\\newcommand{\\T}{\\rv t} % The random variable x \n\\newcommand{\\X}{\\rv X} % The random variable x \n\\newcommand{\\Y}{\\rv Y} % The random variable y\n\\newcommand{\\expect}[1]{\\mathbf{E}\\left[ #1 \\right]} % The expectation operator\n\\newcommand{\\expectg}[2]{\\mathbf{E}_{\\rv{#1}}\\left[ \\rv{#2} \\right]} % An expectation w.r.t. a particular random variable.\n\\newcommand{\\expectn}[1]{\\mathbb{E}\\left[#1\\right]} % The empirical expectation\n\\newcommand{\\cov}[1]{\\mathbf{Cov} \\left[ #1 \\right]} % The expectation operator\n\\newcommand{\\var}[1]{\\mathop{Var} \\left[ #1 \\right]} % The expectation operator\n\\newcommand{\\covn}[1]{\\mathbb{Cov} \\left[ #1 \\right]} % The expectation operator\n\\newcommand{\\gauss}[1]{\\mathcal{N}\\left(#1\\right)} % The gaussian distribution\n\\newcommand{\\cdf}[2]{F_{#1} (#2)} % The CDF function\n\\newcommand{\\survive}[2]{S_{#1} (#2)} % The survival function\n\\newcommand{\\surviven}[2]{\\hat{S}_{#1} (#2)} % The survival function\n\\newcommand{\\hazard}[2]{h_{#1} (#2)} % The survival function\n\\newcommand{\\hazardn}[2]{\\hat{h}_{#1} (#2)} % The survival function\n\\newcommand{\\cuhazard}[2]{H_{#1} (#2)} % The survival function\n\\newcommand{\\cdfn}[2]{\\mathbb{F}_{#1}(#2)} % The empirical CDF function\n\\newcommand{\\icdf}[2]{F_\\rv{#1}^{-1} (#2)} % The invecrse CDF function\n\\newcommand{\\icdfn}[2]{\\mathbb{F}^{-1}_{#1}(#2)} % The inverse empirical CDF function\n\\newcommand{\\pdf}[2]{p_{#1} (#2)} % The CDF function\n\\newcommand{\\prob}[1]{P\\left( #1 \\right)} % the probability of an event\n\\newcommand{\\dist}{P} % The proabaiblity distribution\n\\newcommand{\\density}{p}\n\\newcommand{\\entropy}{H} % entropy\n\\newcommand{\\mutual}[2]{I\\left(#1;#2\\right)} % mutual information\n\n\\newcommand{\\estim}[1]{\\widehat{#1}} % An estimator\n\\newcommand{\\estimII}[1]{\\tilde{#1}} % Some other estimator\n\n\\newcommand{\\norm}[1]{\\Vert #1 \\Vert} % The norm operator\n\\newcommand{\\normII}[1]{\\norm{#1}_2} % The norm operator\n\\newcommand{\\normI}[1]{\\norm{#1}_1} % The norm operator\n\\newcommand{\\normF}[1]{\\norm{#1}_{Frob}} % The Frobenius matrix norm\n\\newcommand{\\ones}{\\textbf{1}} % Vector of ones.\n\\newcommand{\\lik}{\\mathcal{L}} % The likelihood function\n\\newcommand{\\loglik}{L} % The log likelihood function\n\\newcommand{\\loss}{l} % A loss function\n\\newcommand{\\lossII}{\\prescript{}{2}{l}} % A loss function\n\\newcommand{\\risk}{R} % The risk function\n\\newcommand{\\riskn}{\\mathbb{R}} % The empirical risk\n\\newcommand{\\riskII}{\\prescript{}{2}{R}} % The empirical risk\n\\newcommand{\\risknII}{\\prescript{}{2}{\\mathbb{R}} } % The empirical risk\n\\newcommand{\\noisen}{\\mathbb{G}} % The empirical noise process\n\\newcommand{\\deriv}[2]{\\frac{\\partial #1}{\\partial #2}} % A derivative\n\\newcommand{\\argmin}[2]{\\textstyle{\\mathop{argmin}_{#1}}\\set{#2}} % The argmin operator\n\\newcommand{\\argmax}[2]{\\textstyle{\\mathop{argmax}_{#1}}\\set{#2}} % The argmin operator\n\\newcommand{\\hyp}{f} % A hypothesis\n\\newcommand{\\hypclass}{\\mathcal{F}} % A hypothesis class\n\\newcommand{\\hilbert}{\\mathcal{H}}\n\\newcommand{\\rkhs}{\\hilbert_\\kernel} % A hypothesis class\n\\newcommand{\\normrkhs}[1]{\\norm{#1}_{\\rkhs}} % the RKHS function norm\n\n\n\\newcommand{\\plane}{\\mathbb{L}} % A hypoerplane\n\\newcommand{\\categories}{\\mathcal{G}} % The categories set.\n\\newcommand{\\positive}[1]{\\left[ #1 \\right]_+} % The positive part function\n\\newcommand{\\kernel}{\\mathcal{K}} % A kernel function\n\\newcommand{\\featureS}{\\mathcal{X}} % The feature space\n\\newcommand{\\outcomeS}{\\mathcal{Y}} % The feature space\n\\newcommand{\\indicator}[1]{I_{\\set{#1}}} % The indicator function.\n\\newcommand{\\reals}{\\mathbb{R}} % the set of real numbers\n\n\n\n\\newcommand{\\latent}{\\rv{s}} % latent variables matrix\n\\newcommand{\\latentn}{S} % latent variables matrix\n\\newcommand{\\loadings}{A} % factor loadings matrix\n\\newcommand{\\rotation}{R}  % rotation matrix\n\\newcommand{\\similaritys}{\\mathfrak{S}} % a similarity graph\n\\newcommand{\\similarity}{s} % A similarity measure.\n\\newcommand{\\dissimilarity}{d} % A dissimilarity measure.\n\\newcommand{\\dissimilaritys}{\\mathfrak{D}} % a dissimilarity graph\n\\newcommand{\\scalar}[2]{\\left< #1,#2 \\right>} % a scalar product\n\n\n\n\\newcommand{\\manifold}{\\mathcal{M}} % A manifold.\n\\newcommand{\\project}{\\hookrightarrow} % The orthogonal projection operator.\n\\newcommand{\\projectMat}{H} % A projection matrix.\n\\newcommand{\\rank}{q} % A subspace rank.\n\\newcommand{\\dimy}{K} % The dimension of the output.\n\\newcommand{\\encode}{E} % a linear encoding matrix\n\\newcommand{\\decode}{D} % a linear decoding matrix\n\\DeclareMathOperator{\\Tr}{Tr}\n\\newcommand{\\ensembleSize}{M} % Size of a hypothesis ensemble.\n\\newcommand{\\ensembleInd}{m} % Index of a hypothesis in an ensemble.\n\n\n\\newcommand{\\sample}{\\mathcal{S}} % A data sample.\n\\newcommand{\\test}{\\risk(\\hyp)} % The test error (risk)\n\\newcommand{\\train}{\\riskn(\\hyp)} % The train error (empirical risk)\n\\newcommand{\\insample}{\\bar{\\risk}(\\hyp)} % The in-sample test error.\n\\newcommand{\\EPE}{\\risk(\\hat{\\hyp}_n)} % The out-of-sample test error.\n\\newcommand{\\folds}{K} % Cross validation folds \n\\newcommand{\\fold}{k} % Index of a fold\n\\newcommand{\\bootstraps}{B} % Bootstrap samples\n\\newcommand{\\bootstrap}{{b^*}} % Index of a bootstrap replication\n\n\n\\newcommand{\\rankings}{\\mathcal{R}} % Rankings, for colaborative filtering.\n\\newcommand{\\ranking}{\\mathcal{R}} % Rankings, for colaborative filtering.\n\\newcommand{\\KL}[2]{D_{KL}\\left(#1 \\Vert #2 \\right)}\n\\newcommand{\\ortho}{\\mathbb{O}} % space of orthogonal matrices\n\n\\newcommand{\\id}[6]{\n\t\\begin{tabular}{|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}\n\t\\hline Task & Type & Input & Output & Concept & Remark \\\\ \n\t\\hline \n\t\\hline #1 & #2 & #3 & #4 & #5 & #6 \\\\ \n\t\\hline \n\t\\end{tabular} \n\t\\newline\n\t\\newline\n}\n\n\\newcommand{\\union}{\\cup}\n\\newcommand{\\intersect}{\\cap}\n\\newcommand{\\supp}[1]{\\mathop{support}(#1)}\n\\newcommand{\\conf}[2]{\\mathop{confidence}(#1 \\Rightarrow #2)}\n\\newcommand{\\lift}[2]{\\mathop{lift}(#1 \\Rightarrow #2)}\n\\newcommand{\\convic}[2]{\\mathop{conviction}(#1 \\Rightarrow #2)}\n\n\n\\newcommand{\\machine}[1]{\\estim{\\theta}_n^{(#1)}}\n\\newcommand{\\minimizer}{\\theta^*}\n\\newcommand{\\generative}{\\theta_0}\n\\newcommand{\\parallelized}{\\bar{\\theta}_{N,m}}\n\\newcommand{\\parallelizedII}{\\mathring{\\theta}_{N,m}}\n\\newcommand{\\parallelizedIII}{\\prescript{}{2}{\\widehat{\\theta}}_{N,m}}\n\\newcommand{\\centralized}{\\estim{\\theta}_N}\n\\newcommand{\\parallelKL}{\\estim{\\theta}_{KL}}\n\\newcommand{\\penalize}{J}\n\\newcommand{\\bigO}{\\mathcal{O}}\n\\newcommand{\\bigOprob}{\\mathcal{O}_P}\n\\newcommand{\\smallO}{o}\n\\newcommand{\\smallOprob}{o_P}\n\n\\newcommand{\\citeJR}[1]{\\citeauthor{#1} \\citep{#1}}\n\\newcommand{\\citeJRfull}[1]{\\citeauthor*{#1} \\citep{#1}}\n\\newcommand{\\error}{\\mathcal{E}}\n\n\\newcommand{\\M}{$M$}\n\\newcommand{\\MII}{$\\prescript{}{2}{M}$}\n\n\\newcommand{\\biasSecond}[1]{B_2(#1)}\n\\newcommand{\\MSESecond}[1]{M_2(#1)}\n\n\\newcommand{\\rate}{r}\n\n\\newcommand{\\emptyfigure}[1]{\\missingfigure[figwidth=6cm]{#1}}\n\n\n% % Time line\n%\\usepackage[paperwidth=210mm,%\n%    paperheight=297mm,%\n%    tmargin=7.5mm,%\n%    rmargin=7.5mm,%\n%    bmargin=7.5mm,%\n%    lmargin=7.5mm,\n%    vscale=1,%\n%    hscale=1]{geometry}\n%\n%\\usepackage[utf8]{inputenc}\n%\\usepackage[T1]{fontenc}\n\n\\usepackage{tikz}\n\\usetikzlibrary{arrows, calc, decorations.markings, positioning}\n\n\n\\makeatletter\n\\newenvironment{timeline}[6]{%\n    % #1 is startyear\n    % #2 is tlendyear\n    % #3 is yearcolumnwidth\n    % #4 is rulecolumnwidth\n    % #5 is entrycolumnwidth\n    % #6 is timelineheight\n\n    \\newcommand{\\startyear}{#1}\n    \\newcommand{\\tlendyear}{#2}\n\n    \\newcommand{\\yearcolumnwidth}{#3}\n    \\newcommand{\\rulecolumnwidth}{#4}\n    \\newcommand{\\entrycolumnwidth}{#5}\n    \\newcommand{\\timelineheight}{#6}\n\n    \\newcommand{\\templength}{}\n\n    \\newcommand{\\entrycounter}{0}\n\n    % http://tex.stackexchange.com/questions/85528/checking-whether-or-not-a-node-has-been-previously-defined\n    % http://tex.stackexchange.com/questions/37709/how-can-i-know-if-a-node-is-already-defined\n    \\long\\def\\ifnodedefined##1##2##3{%\n        \\@ifundefined{pgf@sh@ns@##1}{##3}{##2}%\n    }\n\n    \\newcommand{\\ifnodeundefined}[2]{%\n        \\ifnodedefined{##1}{}{##2}\n    }\n\n    \\newcommand{\\drawtimeline}{%\n        \\draw[timelinerule] (\\yearcolumnwidth+5pt, 0pt) -- (\\yearcolumnwidth+5pt, -\\timelineheight);\n        \\draw (\\yearcolumnwidth+0pt, -10pt) -- (\\yearcolumnwidth+10pt, -10pt);\n        \\draw (\\yearcolumnwidth+0pt, -\\timelineheight+15pt) -- (\\yearcolumnwidth+10pt, -\\timelineheight+15pt);\n\n        \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(\\startyear, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n        \\node[year] (year-\\startyear) at (\\yearcolumnwidth, \\templength) {\\startyear};\n\n        \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(\\tlendyear, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n        \\node[year] (year-\\tlendyear) at (\\yearcolumnwidth, \\templength) {\\tlendyear};\n    }\n\n    \\newcommand{\\entry}[2]{%\n        % #1 is the year\n        % #2 is the entry text\n\n        \\pgfmathtruncatemacro{\\lastentrycount}{\\entrycounter}\n        \\pgfmathtruncatemacro{\\entrycounter}{\\entrycounter + 1}\n\n        \\ifdim \\lastentrycount pt > 0 pt%\n            \\node[entry] (entry-\\entrycounter) [below of=entry-\\lastentrycount] {##2};\n        \\else%\n            \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(\\startyear, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n            \\node[entry] (entry-\\entrycounter) at (\\yearcolumnwidth+\\rulecolumnwidth+10pt, \\templength) {##2};\n        \\fi\n\n        \\ifnodeundefined{year-##1}{%\n            \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(##1, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n            \\draw (\\yearcolumnwidth+2.5pt, \\templength) -- (\\yearcolumnwidth+7.5pt, \\templength);\n            \\node[year] (year-##1) at (\\yearcolumnwidth, \\templength) {##1};\n        }\n\n        \\draw ($(year-##1.east)+(2.5pt, 0pt)$) -- ($(year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\\entrycounter.west)-(5pt,0)$) -- (entry-\\entrycounter.west);\n    }\n\n    \\newcommand{\\plainentry}[2]{% plainentry won't print date in the timeline\n        % #1 is the year\n        % #2 is the entry text\n\n        \\pgfmathtruncatemacro{\\lastentrycount}{\\entrycounter}\n        \\pgfmathtruncatemacro{\\entrycounter}{\\entrycounter + 1}\n\n        \\ifdim \\lastentrycount pt > 0 pt%\n            \\node[entry] (entry-\\entrycounter) [below of=entry-\\lastentrycount] {##2};\n        \\else%\n            \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(\\startyear, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n            \\node[entry] (entry-\\entrycounter) at (\\yearcolumnwidth+\\rulecolumnwidth+10pt, \\templength) {##2};\n        \\fi\n\n        \\ifnodeundefined{invisible-year-##1}{%\n            \\pgfmathsetlengthmacro{\\templength}{neg(add(multiply(subtract(##1, \\startyear), divide(subtract(\\timelineheight, 25), subtract(\\tlendyear, \\startyear))), 10))}\n            \\draw (\\yearcolumnwidth+2.5pt, \\templength) -- (\\yearcolumnwidth+7.5pt, \\templength);\n            \\node[year] (invisible-year-##1) at (\\yearcolumnwidth, \\templength) {};\n        }\n\n        \\draw ($(invisible-year-##1.east)+(2.5pt, 0pt)$) -- ($(invisible-year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\\entrycounter.west)-(5pt,0)$) -- (entry-\\entrycounter.west);\n    }\n\n    \\begin{tikzpicture}\n        \\tikzstyle{entry} = [%\n            align=left,%\n            text width=\\entrycolumnwidth,%\n            node distance=10mm,%\n            anchor=west]\n        \\tikzstyle{year} = [anchor=east]\n        \\tikzstyle{timelinerule} = [%\n            draw,%\n            decoration={markings, mark=at position 1 with {\\arrow[scale=1.5]{latex'}}},%\n            postaction={decorate},%\n            shorten >=0.4pt]\n\n        \\drawtimeline\n}\n{\n    \\end{tikzpicture}\n    \\let\\startyear\\@undefined\n    \\let\\tlendyear\\@undefined\n    \\let\\yearcolumnwidth\\@undefined\n    \\let\\rulecolumnwidth\\@undefined\n    \\let\\entrycolumnwidth\\@undefined\n    \\let\\timelineheight\\@undefined\n    \\let\\entrycounter\\@undefined\n    \\let\\ifnodedefined\\@undefined\n    \\let\\ifnodeundefined\\@undefined\n    \\let\\drawtimeline\\@undefined\n    \\let\\entry\\@undefined\n}\n\\makeatother\n% % % % %\n\n\\newcommand{\\R}{\\textnormal{\\sffamily\\bfseries R }}\n\n% Process capability notation\n\\newcommand{\\targetValue}{T}% target value\n\\newcommand{\\cp}{C_p}% c_p\n\\newcommand{\\cpHat}{\\hat{C}_p}% c_p\n\\newcommand{\\ctqExpect}{\\mu}\n\\newcommand{\\pnc}{p_{NC}}\n\\newcommand{\\cpu}{C_{pu}}\n\\newcommand{\\cpl}{C_{pl}}\n\\newcommand{\\cpk}{C_{pk}}\n\\newcommand{\\cpkHat}{\\hat{C}_{pk}}\n\\newcommand{\\cpm}{C_{pm}}\n\\newcommand{\\cpmHat}{\\hat{C}_{pm}}\n\\newcommand{\\cpq}{C_p(q)}\n\\newcommand{\\pp}{P_{p}}\n\\newcommand{\\ppk}{P_{pk}}\n\n\\newcommand{\\barxChart}{$\\bar{x}$-chart}\n\\newcommand{\\sigmabar}{\\sigma_{\\bar{x}}}\n\\newcommand{\\aka}{{a.k.a.\\ }}\n\\newcommand{\\Aka}{{A.k.a.\\ }}\n\\newcommand{\\rcode}[1]{\\texttt{#1}}\n\\newcommand{\\arm}{L}\n\n\\newcommand{\\tsq}{$T^2$ }\n\\newcommand{\\struct}{\\Phi}\n\\newcommand{\\exppdf}[2]{#1 e^{-#1 #2}}\n\\newcommand{\\expcdf}[2]{e^{-#1 #2}}\n\n\\newcommand{\\conv}{\\ast}\n\\newcommand{\\range}[1]{Range(#1)}\n\n\\newcommand{\\dif}{\\mathrm{d}}", "meta": {"hexsha": "3833365c9cf6cf3bf0c383a5d529e2bb4098b9b1", "size": 14425, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Class_notes/commands.tex", "max_stars_repo_name": "johnros/qualityEngineering", "max_stars_repo_head_hexsha": "4a1c0959672fb5c5a6e59829e543c95beb4e5b44", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Class_notes/commands.tex", "max_issues_repo_name": "johnros/qualityEngineering", "max_issues_repo_head_hexsha": "4a1c0959672fb5c5a6e59829e543c95beb4e5b44", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Class_notes/commands.tex", "max_forks_repo_name": "johnros/qualityEngineering", "max_forks_repo_head_hexsha": "4a1c0959672fb5c5a6e59829e543c95beb4e5b44", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7617801047, "max_line_length": 178, "alphanum_fraction": 0.6696707106, "num_tokens": 4844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.7310585903489892, "lm_q1q2_score": 0.40816974543260687}}
{"text": "\\section{Simulation extractability of $\\plonk$, omitted proofs}\n\\label{sec:plonkse_proofs}\n\n\n%\\oursubsub{Proof of \\cref{lem:plonkprot_ur}}\n\n\\begin{lemma}[\\cref{lem:plonkprot_ur} restated]\n\t\\label{lem:app:plonkprot_ur}\n\tLet $\\PCOMp$ be a polynomial commitment that is $\\epsbind(\\secpar)$-binding and has unique opening property with loss $\\epsop (\\secpar)$, let $(\\noofc + 5, 1)$-$\\udlog$ problem be $\\epsudlog (\\secpar)$ hard. Then $\\plonkprotfs$ is $\\ur{3}$ against algebraic adversaries, who makes up to $q$ random oracle queries, with security loss $8  \\cdot \\epsbinding (\\secpar) + \\epsudlog (\\secpar) + 2 \\infrac{q}{p}$.\n\\end{lemma}\n\n\\begin{proof}\n    Let $\\adv$ be an algebraic adversary tasked to break the $\\ur{3}$-ness of\n      $\\plonkprotfs$. We show that the first three prover's messages determine, along with \tthe verifiers challenges, the rest of it. We denote by $\\zkproof^0$ and $\\zkproof^1$ the two proofs that the adversary outputs. To distinguish polynomials and commitments which an honest prover would send in the proof from the polynomials and commitments computed by the adversary we write the latter using indices $0$ and $1$ (two indices as we have two transcripts), e.g.~to describe the quotient polynomial provided by the adversary we write $\\p{t}^0$ and $\\p{t}^1$ instead of $\\p{t}$ as in the description of the protocol.\n  \n    We note that since the unique response property requires from $\\zkproof^{0}$ and $\\zkproof^{1}$ that the first place they possibly differ is the $4$-th prover's message, then the challenge $\\chz$, that is picked by the adversary after the $3$-rd message is the same in both transcripts. This challenge determines the evaluation point of polynomials $\\p{a}(X), \\p{b}(X), \\p{c}(X), \\p{t}(X), \\p{z}(X)$ which commitments are already sent.\n  \n    In its fourth message, the prover provides evaluations of the aforementioned polynomials, along with evaluations of publicly known polynomials $\n    \\p{S_{\\sigma 1}} (\\chz), \\p{S_{\\sigma 2}} (\\chz)$, and evaluation of a linearization polynomial $\\p{r}(\\chz)$.\n\n    Note that the adversary can output two accepting proofs that differ on their fourth message only if it either manages to break evaluation binding of one of the opening, or provides an incorrect opening which is accepted due to a batching error. Since the commitment scheme is evaluation binding with security loss $\\epsbinding (\\secpar)$, %and the batched verification equation accepts an incorrect opening with probability at most $\\infrac{q}{p}$, cf.~\\cite{EPRINT:GabWilCio19}, \n\tthe adversary can make $\\zkproof^{0}$ and $\\zkproof^{1}$ differ on the fourth message with the same probability. % at most $8  \\cdot \\epsbinding (\\secpar) + \\infrac{q}{p}$. \n  \n    Next, assume that the transcripts are the same up to the fourth message, but differ at the fifth. In that message, the adversary provides openings of the evaluations. Since the unique opening property, the adversary can open the valid evaluation of a polynomial to two different values with probability at most $\\epsop (\\secpar)$. (We note that for the KZG polynomial commitment scheme, as used in \\cite{EPRINT:GabWilCio19}, $\\epsop (\\secpar) \\leq \\epsudlog (\\secpar) + \\infrac{q}{p}$, cf.~\\cref{lem:pcomp_op}.)\n    % , which is upper-bounded by $\\epsudlog (\\secpar) + \\infrac{q}{p}$, cf.~\\cref{lem:pcomp_op}.\n  \n    By the union bound, the adversary is able to break the unique response property with probability upper bounded by $\\epsbinding (\\secpar) + \\epsop (\\secpar)$.\n    \\qed\n    \\end{proof}\n\n%\\oursubsub{Proof of \\cref{lem:plonkprot_ss}}\n\n\\begin{lemma}[\\cref{lem:plonkprot_ss} restated]\n\t\\label{lem:app:plonkprot_ss}\n\t$\\plonkprotfs$ is $(3, 3 \\noofc + 6)$-rewinding-based knowledge sound against algebraic adversaries who make up to $q$ random oracle queries with security loss \n\t\\[\n\t\\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)}{1 - \\frac{3 \\noofc + 5}{p}}\\right) + (3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)\\,,\n\t\\]\n\n\tHere $\\accProb$ is a probability that the adversary outputs an accepting proof, and $\\epsudlog(\\secpar)$ is security of $(\\numberofconstrains + 5, 1)$-$\\udlog$.\n\\end{lemma}\n\n\\begin{proof}\n\tLet $\\adv^{\\ro, \\initU}(\\secparam; r)$ be the adversary who outputs $(\\inp, \\zkproof)$ such that $\\plonkprotfs.\\verifier$ accepts the proof. Let $\\tdv$ be a tree-building algorithm of \\cref{lem:attema} that outputs a tree $\\tree$, and let $\\extcss$ be an extractor that given the tree output by $\\tdv$ reveals the witness for $\\inp$. The main idea of the proof is to show that an adversary who breaks rewinding-based knowledge soundness can be used to break a $\\udlog$-problem instance. The proof goes by game hops. Note that since the tree branches after $\\adv$'s $3$-rd message, the instance $\\inp$, commitments $\\gone{\\p{a} (\\chi), \\p{b} (\\chi), \\p{c} (\\chi), \\p{z} (\\chi), \\p{t_{lo}} (\\chi), \\p{t_{mid}} (\\chi), \\p{t_{hi}} (\\chi)}$, and challenges $\\alpha, \\beta, \\gamma$ are the same in all the transcripts. Also, the tree branches after the third adversary's message where the challenge $\\chz$ is presented, thus tree $\\tree$ is built using different values of $\\chz$.\tWe consider the following games.\n\n  \\ncase{Game 0} %\n  In this game the adversary wins if it outputs a valid instance--proof pair $(\\inp, \\zkproof)$, and the extractor $\\extcss$ does not manage to output a witness $\\wit$ such that $\\REL (\\inp, \\wit)$ holds.\n\n  \\ncase{Game 1} %\n  In this game the environment aborts the game if the tree building algorithm $\\tdv$ fails in building a tree of accepting transcripts $\\tree$. \n\n  \\ncase{Game 0 to Game 1} %\n  By \\cref{lem:attema} probability that Game 1 is aborted, while Game 0 is not, is at most \n  %\\hamid{2.5}{Should this not be \"1 minus the following\"?}\n  \\[\n    1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)} {1 - \\frac{3 \\noofc + 5}{p}} \\,.\n  \\]\n\n  \\ncase{Game 2} %\n  In this game the environment additionally aborts if at least one of its proofs in $\\tree$ is not accepting by an ideal verifier.\n\n  \\ncase{Game 1 to Game 2} % \n  As usual, we show a reduction that breaks an instance of a $\\udlog$ assumption when Game 2 is aborted, while Game 1 is not.\n\n  Let $\\rdvudlog$ be a reduction that gets as input an $(\\noofc + 5, 1)$-$\\udlog$ instance $\\gone{1, \\ldots, \\chi^{\\noofc + 5}}, \\gtwo{\\chi}$. Then it can update the instance to another one $\\gone{1, \\ldots, {\\chi'}^{\\noofc + 5}}, \\gtwo{\\chi'}$. Eventually, the reduction outputs $\\chi'$.\n\t%\n\tThe reduction $\\rdvudlog$ proceeds as follows.\n\tFirst, it builds $\\adv$'s SRS $\\srs$ using the input $\\udlog$ instance. Then it processes the adversary's update query by adding it to the list $\\Qsrs$ and passing it to its own update oracle getting instance $\\gone{1, \\ldots, {\\chi'}^{\\noofc + 5}}, \\gtwo{\\chi'}$. The updated SRS $\\srs'$ is then computed and given to $\\adv$. $\\rdvdulog$ also takes care of the random oracle queries made by $\\adv$. It picks their answers honestly and write them in $\\Qro$. The reduction then starts $\\tdv(\\srs, \\adv, r, \\Qro, \\Qsrs)$.\n\t\n  Let $(1, \\tree)$ be the output returned by $\\tdv$. Let $\\inp$ be a relation proven in $\\tree$.  Consider a transcript $\\zkproof \\in \\tree$ such that $\\vereq_{\\inp, \\zkproof}(X) \\neq 0$, but $\\vereq_{\\inp, \\zkproof}(\\chi') = 0$. Since $\\adv$ is algebraic, all group elements included in $\\tree$ are extended by their representation as a combination of the input $\\GRP_1$-elements. Hence, all coefficients of the verification equation polynomial $\\vereq_{\\inp, \\zkproof}(X)$ are known. \n  Eventually, the reduction finds $\\vereq_{\\inp, \\zkproof}(X)$ zero points and returns $\\chi'$ which is one of them.\n    \n  Hence, the probability that the adversary wins in Game 2 but does not win in Game 1 is upper-bounded by $(3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)$.\n\n  \\ncase{Conclusion}\n\n  Note that the adversary can win in Game 2 only if $\\tdv$ manages to produce a tree of accepting transcripts $\\tree$, such that each of the transcripts in $\\tree$ is accepting by an ideal verifier. Note that since $\\tdv$ produces $(3 \\noofc + 6)$ accepting transcripts for different challenges $\\chz$, it obtains the same number of different evaluations of polynomials $\\p{a} (X), \\p{b} (X), \\p{c} (X), \\p{z} (X), \\p{t} (X)$. Since all the transcripts are accepting by an idealized verifier, the equality between polynomial $\\p{t} (X)$ and combination of polynomials $\\p{a} (X), \\p{b} (X), \\p{c} (X), \\p{z} (X)$ defined in prover's $3$-rd message description holds. Hence, $\\p{a} (X), \\p{b} (X), \\p{c} (X)$ encodes the valid witness for the proven statement. $\\extcss$ can recreate polynomials' coefficients by interpolation and reveal the witness given $(3 \\noofc + 6)$ evaluations. \n  % Thus, the probability that extraction fails in that case is upper-bounded by $(3 \\noofc + 6) \\cdot \\epsid(\\secpar)$.\n\n\n  Hence, the probability that the adversary wins in Game 0 is upper-bounded by \n  \\[\n    \\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)}{1 - \\frac{3 \\noofc + 5}{p}}\\right) + (3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)\\,. \n  \\]\n  \\qed\n \\end{proof}\n\n%\\oursubsub{Proof of \\cref{lem:plonk_tlzk}}\n\\begin{lemma}[\\cref{lem:plonk_tlzk} restated]\n\t\\label{lem:app:plonk_tlzk}\n\t$\\plonkprotfs$ is 3-programmable trapdoor-less zero-knowledge.\n\\end{lemma}\n\n\\begin{proof}\n    As noted in \\cref{def:upd-scheme}, subvertible zero-knowledge implies updatable zero-knowledge. Hence, here we show that Plonk is TLZK even against adversaries who picks\n    the SRS on its own.\n  \n  The adversary $\\adv(\\secparam)$ picks an SRS $\\srs$ and instance--witness pair\n  $(\\inp, \\wit)$ and gets a proof $\\zkproof$ simulated by the simulator\n  $\\simulator$ which proceeds as follows.\n  \n  For its $1$-st message the simulator  picks randomly both the randomizers $b_1, \\ldots, b_6$ and\n  sets $\\wit_i = 0$ for $i \\in \\range{1}{3\\noofc}$. Then $\\simulator$\n  outputs $\\gone{\\p{a}(\\chi), \\p{b}(\\chi), \\p{c}(\\chi)}$. For the first\n  challenge, the simulator picks permutation argument challenges $\\beta, \\gamma$\n  randomly.\n  \n  For its $2$-nd message, the simulator computes $\\p{z}(X)$ from\n  the newly picked randomizers $b_7, b_8, b_9$ and coefficients of polynomials\n  $\\p{a}(X), \\p{b}(X), \\p{c}(X)$. Then it evaluates $\\p{z}(X)$ honestly and outputs\n  $\\gone{\\p{z}(\\chi)}$. Challenge $\\alpha$ that should be sent by the verifier\n  after the simulator's $2$ message is picked by the simulator at random.\n  \n  In its $3$-rd message the simulator starts by picking at random a challenge $\\chz$, which\n  in the real proof comes as a challenge from the verifier sent \\emph{after} the prover\n  sends its $3$-rd message. Then $\\simulator$ computes evaluations\n  \\(\\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma\n      2}}(\\chz), \\pubinppoly(\\chz), \\lag_1(\\chz), \\p{Z_H}(\\chz),\\allowbreak\n  \\p{z}(\\chz\\omega)\\) and computes $\\p{t}(X)$ honestly. Since for a random\n  $\\p{a}(X), \\p{b}(X), \\p{c}(X), \\p{z}(X)$ the constraint system is (with\n  overwhelming probability) not satisfied and the constraints-related polynomials\n  are not divisible by $\\p{Z_H}(X)$, hence $\\p{t}(X)$ is a rational function\n  rather than a polynomial. Then, the simulator evaluates $\\p{t}(X)$ at $\\chz$ and\n  picks randomly a degree-$(3 \\noofc + 15)$ polynomial $\\p{\\tilde{t}}(X)$ such that\n  $\\p{t}(\\chz) = \\p{\\tilde{t}}(\\chz)$ and publishes a commitment\n  $\\gone{\\p{\\tilde{t}_{lo}}(\\chi), \\p{\\tilde{t}_{mid}}(\\chi),\n    \\p{\\tilde{t}_{hi}}(\\chi)}$. After that the simulator outputs $\\chz$ as a\n  challenge.\n  \n  For the next message, the simulator computes polynomial $\\p{r}(X)$ as an honest\n  prover would, cf.~\\cref{sec:plonk_explained} and evaluates $\\p{r}(X)$ at $\\chz$.\n  \n  The rest of the evaluations are already computed, thus $\\simulator$ simply outputs\n  \\( \\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma\n      2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega)\\,.  \\) After that it picks randomly\n  the challenge $v$, and prepares the the last message as an honest prover\n  would. Eventually, $\\simulator$ and outputs the final challenge, $u$, by picking it\n  at random as well.\n  \n  We argue about zero-knowledge as usual. The property holds since the polynomials that has witness elements at their coefficients are randomized by at least two randomizers and are evaluated at at most two points; and the simulator computes all polynomials as an honest prover would.\n  \\qed\n  \\end{proof}\n  ", "meta": {"hexsha": "45e94de326148234123f25dff511de009824689b", "size": 12504, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SCN2022/non-malleability-of-pfs-proofs.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SCN2022/non-malleability-of-pfs-proofs.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SCN2022/non-malleability-of-pfs-proofs.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.4405594406, "max_line_length": 1008, "alphanum_fraction": 0.6969769674, "num_tokens": 3901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4081697323465561}}
{"text": "%This is test for LaTeX syntax\n\\documentclass[a4paper,12pt]{article}\n\\begin{document}\n\n%Title\n\\title{My First Document}\n\\author{My Name}\n\\date{\\today}\n\\maketitle\n\n%Sections\n\\section{Introduction}\nThis is the introduction.\n\n%Labelling\nReferring to section \\ref{sec1} on page \\pageref{sec1}\n\n%Table of Contents\n\\pagenumbering{roman}\n\\tableofcontents\n\\newpage\n\\pagenumbering{arabic}\n\n%Font Effects\n\\textit{words in italics}\n\\textsl{words slanted}\n\\textsc{words in smallcaps}\n\\textbf{words in bold}\n\\texttt{words in teletype}\n\\textsf{sans serif words}\n\\textrm{roman words}\n\\underline{underlined words}\n\n%Coloured Text\n{\\color{colour_name}text}\n\n%Font Sizes\n{\\tiny tiny words}\n{\\scriptsize scriptsize words}\n{\\footnotesize footnotesize words}\n{\\small small words}\n{\\normalsize normalsize words}\n{\\large large words}\n{\\Large Large words}\n{\\LARGE LARGE words}\n{\\huge huge words}\n\n%Lists\n\\begin{itemize}\n\\item[-] First thing\n\\item[+] Second thing\n\\begin{itemize}\n\\item[Fish] A sub-thing\n\\item[Plants] Another sub-thing\n\\end{itemize}\n\\item[Q] Third thing\n\\end{itemize}\n\n%Tables\n\\begin{tabular}{|l|l|}\nApples & Green \\\\\nStrawberries & Red \\\\\nOranges & Orange \\\\\n\\end{tabular}\n\n%Figures\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=1\\textwidth]{image}\n\\caption{Here is image}\n\\label{image}\n\\end{figure}\n\n%Mathematical\n$\\sin(x)$\n$$\\sin(x)$$\n\\[\\sin(x)\\]\n\\(\\sin(x)\\)\n\n\\begin{equation}1+2=3\\end{equation}\n\\begin{eqnarray}\n  a & = & b + c \\\\\n    & = & y - z\n\\end{eqnarray}\n$\\alpha$ = α\n$\\beta$ = β\n$\\delta, \\Delta$ = δ, ∆\n$\\theta, \\Theta$ = θ, Θ\n\n%Comments\n\\begin{comment}\nThis is a comment.\n\\end{comment}\n\n%Lstlistings|Minted\n\\lstdefinelanguage{JavaScript}{\n    morestring=[b]`\n}\n\n\\lstset{language=JavaScript}\n\\begin{lstlisting}\n    let x = `this is a ${string}`\n\\end{lstlisting}\n\n\\begin{minted}{python}\nimport numpy as np\n \ndef incmatrix(genl1,genl2):\n    m = len(genl1)\n    n = len(genl2)\n    M = None #to become the incidence matrix\n    VT = np.zeros((n*m,1), int)  #dummy variable\n \n    #compute the bitwise xor matrix\n    M1 = bitxormatrix(genl1)\n    M2 = np.triu(bitxormatrix(genl2),1) \n \n    for i in range(m-1):\n        for j in range(i+1, m):\n            [r,c] = np.where(M2 == M1[i,j])\n            for k in range(len(r)):\n                VT[(i)*n + r[k]] = 1\n                VT[(i)*n + c[k]] = 1\n                VT[(j)*n + r[k]] = 1\n                VT[(j)*n + c[k]] = 1\n \n                if M is None:\n                    M = np.copy(VT)\n                else:\n                    M = np.concatenate((M, VT), 1)\n \n                VT = np.zeros((n*m,1), int)\n \n    return M\n\\end{minted}\n\n\\begin{VerbatimOut}{ex-scala-logstage.tmp}\n    class ExampleService(log: IzLogger) {\n      val justAnArg = \"example\"\n      val justAList = List[Any](10, \"green\", \"bottles\")\n      val msec = Random.nextInt(1000)\n      log.trace(s\"Argument: $justAnArg, another arg: $justAList\")\n      log.info(s\"Expr: ${Random.nextInt() -> \"number\"}\")\n      log.warn(s\"Hidden: ${Random.nextInt() -> \"number\" -> null}\")\n      val ctxLog = log(\"userId\" -> \"user@google.com\"\n        , \"company\" -> \"acme\")\n      ctxLog.info(s\"Processing time: $msec\")\n    }\n\\end{VerbatimOut}\n\n\\end{document}\n\\documentclass{article}", "meta": {"hexsha": "0aa401990f38f3393005ffd0761e1f3941ff20f6", "size": 3181, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tests/text.tex", "max_stars_repo_name": "schoolknight/vscode-LaTeX-academic", "max_stars_repo_head_hexsha": "cdceefbb4a8fdfafa7a609a5dfc88cb76788a82a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/text.tex", "max_issues_repo_name": "schoolknight/vscode-LaTeX-academic", "max_issues_repo_head_hexsha": "cdceefbb4a8fdfafa7a609a5dfc88cb76788a82a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/text.tex", "max_forks_repo_name": "schoolknight/vscode-LaTeX-academic", "max_forks_repo_head_hexsha": "cdceefbb4a8fdfafa7a609a5dfc88cb76788a82a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.9276315789, "max_line_length": 66, "alphanum_fraction": 0.6249607042, "num_tokens": 1036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.40811576254774273}}
{"text": "\\chapter*{Resonators}\n<<<<<<< HEAD\nThough the physical models described in the previous part are also considered resonators, they are \\textit{ideal} cases. In other words, you would not be able to find these ``in the wild'' as they do not includes effects such as losses or frequency dispersion. \n\nThis part presents the different resonators used over the course of the project and is structured as follows: Chapter \\ref{ch:stiffString} introduces the stiff string, a model which has been used a lot over the course of this project, Chapter \\ref{ch:brass} talks about brass instruments, or more generally, 1D systems of varying geometry along their spatial dimension. Finally, Chapter \\ref{ch:2Dsyst} will introduces 2D systems which, in this project, have been used to simulate (simplified) instrument bodies.\n=======\nAlthough the physical models described in the previous part -- the simple mass-spring system and the 1D wave equation -- are also considered resonators, they are \\textit{ideal} cases. In other words, these can not be found in the real world as effects such as losses or frequency dispersion are not included. \n\nThis part presents the different resonators used over the course of the project that better include these non-ideal physical processes and is structured as follows: Chapter \\ref{ch:stiffString} introduces the stiff string, an extension of the 1D wave equation, % and is the single most-used model in this project. \nChapter \\ref{ch:brass} introduces acoustic tubes, used to model brass instruments, and finally, Chapter \\ref{ch:2Dsyst} introduces 2D systems which, in this project, have been used to simulate (simplified) instrument bodies. The analysis techniques introduced in the previous part will be applied to all models and described in detail. \n>>>>>>> master\n", "meta": {"hexsha": "3290bc12533ec3e3c77e7014b22ca5917704a6e0", "size": 1797, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "aauPhdCollectionThesis/resonators/introduction.tex", "max_stars_repo_name": "SilvinWillemsen/phdThesis", "max_stars_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aauPhdCollectionThesis/resonators/introduction.tex", "max_issues_repo_name": "SilvinWillemsen/phdThesis", "max_issues_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aauPhdCollectionThesis/resonators/introduction.tex", "max_forks_repo_name": "SilvinWillemsen/phdThesis", "max_forks_repo_head_hexsha": "b0a59790e12d0c308a065958c6dc47c8763d8c34", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 149.75, "max_line_length": 512, "alphanum_fraction": 0.7907623817, "num_tokens": 395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4081157586041334}}
{"text": "% Part: first-order-logic\n% Chapter: sequent-calculus\n% Section: propositional-rules\n\n\\documentclass[../../../include/open-logic-section]{subfiles}\n\n\\begin{document}\n\n\\olfileid{mvl}{seq}{prl}\n\n\\olsection{Propositional Rules for Selected Logics}\n\nThe inference rules for a connective in an $n$-sided sequent calculus\nonly depend on the characteristic truth function for the connective.\nThus, if some connective is defined by the same truth function in\ndifferent logics, these $n$-sided sequent rules for the connective are\nthe same in those logics.\n\n\\subsection{Rules for $\\lnot$}\n\nThe following rules for $\\lnot$ apply to \\L ukasiewicz and Kleene\nlogics, and their variants.\n\n\\begin{defish}\n  \\begin{center}\n\\AxiomC{$ \\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A $}\n\\RightLabel{\\iR{\\lnot}{\\False}}\n\\UnaryInfC{$ \\lnot !A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n\\DisplayProof\n\\\\[2ex]\n\\AxiomC{$ \\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta $}\n\\RightLabel{\\iR{\\lnot}{\\Undef}}\n\\UnaryInfC{$\\Gamma \\nSequent \\lnot !A, \\Pi \\nSequent \\Delta$}\n\\DisplayProof\n\\\\[2ex]\n\\AxiomC{$!A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n\\RightLabel{\\iR{\\lnot}{\\True}}\n\\UnaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta,  \\lnot !A$}\n\\DisplayProof\n  \\end{center}\n\\end{defish}\n\nThe following rules for $\\lnot$ apply to G\\\"odel logic.\n\n\\begin{defish}\n\\AxiomC{$ \\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta, !A $}\n\\RightLabel{\\iR{\\lnot}{\\False}[\\LogGod]}\n\\UnaryInfC{$ \\lnot !A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n\\DisplayProof\n\\hfill\n\\AxiomC{$!A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n\\RightLabel{\\iR{\\lnot}{\\True}[\\LogGod]}\n\\UnaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta,  \\lnot !A$}\n\\DisplayProof\n\\hfill\n\\end{defish}\n\n(In G\\\"odel logic, $\\lnot !A$ can never take the value~$\\Undef$, so\nthere is no rule for the middle position.)\n\n\\subsection{Rules for $\\land$}\n\nThese are the rules for $\\land$ in \\L ukasiewicz, strong Kleene, and\nG\\\"odel logic.\n\n\\begin{defish}\n\\begin{center}\n  \\AxiomC{$!A, !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR{\\land}{\\False}$}\n  \\UnaryInfC{$!A \\land !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n\\\\[2ex]\n  \\AxiomC{$\\Gamma \\nSequent !A, \\Pi \\nSequent !A, \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent !B, \\Pi \\nSequent !B, \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent !A, !B, \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\land\\Undef$}\n  \\TrinaryInfC{$\\Gamma \\nSequent !A \\land !B, \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n  \\\\[2ex]  \n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A$}\n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !B$}\n  \\RightLabel{$\\iR\\land\\True$}\n  \\BinaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A \\land !B$}\n  \\DisplayProof\n\\end{center}\n\\end{defish}\n\n\\subsection{Rules for $\\lor$}\n\nThese are the rules for $\\lor$ in \\L ukasiewicz, strong Kleene, and\nG\\\"odel logic.\n\n\\begin{defish}\n\\begin{center}\n \\AxiomC{$!A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$!B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\lor\\False$}\n  \\BinaryInfC{$!A \\lor !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n\\\\[2ex]\n  \\AxiomC{$!A, \\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$!B, \\Gamma \\nSequent !B, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent !A, !B, \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\lor\\Undef$}\n  \\TrinaryInfC{$\\Gamma \\nSequent !A \\lor !B, \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n  \\\\[2ex]  \n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A, !B$}\n  \\RightLabel{$\\iR\\lor\\True$}\n  \\UnaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A \\lor !B$}\n  \\DisplayProof\n\\end{center}\n\\end{defish}\n\n\\subsection{Rules for $\\lif$}\n\nThese are the rules for $\\lif$ in \\L ukasiewicz logic.\n\n\\begin{defish}\n\\begin{center}\n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A$}\n  \\AxiomC{$!B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\lif\\False[\\LogLuk[3]]$}\n  \\BinaryInfC{$!A \\lif !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n  \\\\[2ex]\n  \\AxiomC{$\\Gamma \\nSequent !A, !B, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$!B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A$}\n  \\RightLabel{$\\iR\\lif\\Undef[\\LogLuk[3]]$}\n  \\BinaryInfC{$\\Gamma \\nSequent !A \\lif !B, \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n\\\\[2ex]\n  \\AxiomC{$!A, \\Gamma \\nSequent !B, \\Pi \\nSequent \\Delta, !B$}\n  \\AxiomC{$!A, \\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta, !B$}\n  \\RightLabel{$\\iR{\\lif}{\\True}[\\LogLuk[3]]$}\n  \\BinaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A \\lif !B$}\n  \\DisplayProof\n\\end{center}\n\\end{defish}\n\nThese are the rules for $\\lif$ in strong Kleene logic.\n\n\\begin{defish}\n\\begin{center}\n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A$}\n  \\AxiomC{$!B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\lif\\False[\\LogKs]$}\n  \\BinaryInfC{$!A \\lif !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n  \\\\[2ex]\n  \\AxiomC{$!B, \\Gamma \\nSequent !B, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent !A, !B, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta, !A$}\n  \\RightLabel{$\\iR\\lif\\Undef[\\LogKs]$}\n  \\TrinaryInfC{$\\Gamma \\nSequent !A \\lif !B, \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n\\\\[2ex]\n  \\AxiomC{$!A, \\Gamma \\nSequent \\Pi \\nSequent \\Delta, !B$}\n  \\RightLabel{$\\iR{\\lif}{\\True}[\\LogKs]$}\n  \\UnaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A \\lif !B$}\n  \\DisplayProof\n\\end{center}\n\\end{defish}\n\nThese are the rules for $\\lif$ in G\\\"odel logic.\n\n\\begin{defish}\n\\begin{center}\n  \\AxiomC{$\\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta, !A$}\n  \\AxiomC{$!B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\RightLabel{$\\iR\\lif\\False[\\LogGod[3]]$}\n  \\BinaryInfC{$!A \\lif !B, \\Gamma \\nSequent \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n  \\\\[2ex]\n  \\AxiomC{$\\Gamma \\nSequent !B, \\Pi \\nSequent \\Delta$}\n  \\AxiomC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A$}\n  \\RightLabel{$\\iR\\lif\\Undef[\\LogGod[3]]$}\n  \\BinaryInfC{$\\Gamma \\nSequent !A \\lif !B, \\Pi \\nSequent \\Delta$}\n  \\DisplayProof\n\\\\[2ex]\n  \\AxiomC{$!A, \\Gamma \\nSequent !B, \\Pi \\nSequent \\Delta, !B$}\n  \\AxiomC{$!A, \\Gamma \\nSequent !A, \\Pi \\nSequent \\Delta, !B$}\n  \\RightLabel{$\\iR{\\lif}{\\True}[\\LogGod[3]]$}\n  \\BinaryInfC{$\\Gamma \\nSequent \\Pi \\nSequent \\Delta, !A \\lif !B$}\n  \\DisplayProof\n\\end{center}\n\\end{defish}\n\n\n\\begin{sidewaysfigure}\n  \\begin{center}  \n  \\AxiomC{$A \\nSequent A \\nSequent A$}\n  \\RightLabel{\\iR \\Weakening \\True}\n  \\UnaryInfC{$A \\nSequent A \\nSequent B, A$}\n  \\RightLabel{\\iR \\Weakening \\Undef}\n  \\UnaryInfC{$A \\nSequent B, A \\nSequent B, A$}\n  \\RightLabel{\\iR \\Weakening \\Undef}\n  \\UnaryInfC{$A \\nSequent A, B, A \\nSequent B, A$}\n  \\AxiomC{$A \\nSequent A \\nSequent A$}\n  \\RightLabel{\\iR \\Weakening \\True}\n  \\UnaryInfC{$A \\nSequent A \\nSequent A, A$}\n  \\RightLabel{\\iR \\Weakening \\True}\n  \\UnaryInfC{$A \\nSequent A \\nSequent B, A, A$}\n  \\RightLabel{\\iR \\Weakening \\False}\n  \\UnaryInfC{$B, A \\nSequent A \\nSequent B, A, A$}\n  \\RightLabel{$\\iR\\lif\\Undef$}\n  \\BinaryInfC{$A \\nSequent A \\lif B, A \\nSequent B, A$}\n  \\AxiomC{$B \\nSequent B \\nSequent B$}\n  \\RightLabel{\\iR \\Weakening \\Undef}\n  \\UnaryInfC{$B \\nSequent A, B \\nSequent B$}\n  \\RightLabel{\\iR \\Exchange \\Undef}\n  \\UnaryInfC{$B \\nSequent B, A \\nSequent B$}\n  \\RightLabel{\\iR \\Weakening \\Undef}\n  \\UnaryInfC{$B \\nSequent A, B, A \\nSequent B$}\n  \\RightLabel{\\iR \\Weakening \\False}\n  \\UnaryInfC{$A, B \\nSequent A, B, A \\nSequent B$}\n  \\RightLabel{\\iR \\Exchange \\False}\n  \\UnaryInfC{$B, A \\nSequent A, B, A \\nSequent B$}\n  \\AxiomC{$A \\nSequent A \\nSequent A$}\n  \\RightLabel{\\iR \\Weakening \\True}\n  \\UnaryInfC{$A \\nSequent A \\nSequent B, A$}\n  \\RightLabel{\\iR \\Weakening \\False}\n  \\UnaryInfC{$B, A \\nSequent A \\nSequent B, A$}\n  \\RightLabel{\\iR \\Weakening \\False}\n  \\UnaryInfC{$B, B, A \\nSequent A \\nSequent B, A$}\n  \\RightLabel{$\\iR\\lif\\Undef$}\n  \\BinaryInfC{$B, A \\nSequent A \\lif B, A \\nSequent B$}\n  \\RightLabel{$\\iR\\lif\\False$}\n  \\BinaryInfC{$A \\lif B, A \\nSequent A \\lif B, A \\nSequent B$}\n  \\DisplayProof\n  \\end{center}\n  \\caption{Example !!{derivation} in~$\\LogLuk[3]$}\n\\end{sidewaysfigure}\n\n\\end{document}\n", "meta": {"hexsha": "5d56fe91c948eabe1b53b4afdcf2c84c0e2dce31", "size": 7938, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/many-valued-logic/sequent-calculus/propositional-rules.tex", "max_stars_repo_name": "jzc/OpenLogic", "max_stars_repo_head_hexsha": "5948483c1d08c25664dc12ac8350e9ae34986b31", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 754, "max_stars_repo_stars_event_min_datetime": "2015-01-13T20:57:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:18:26.000Z", "max_issues_repo_path": "content/many-valued-logic/sequent-calculus/propositional-rules.tex", "max_issues_repo_name": "jzc/OpenLogic", "max_issues_repo_head_hexsha": "5948483c1d08c25664dc12ac8350e9ae34986b31", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 229, "max_issues_repo_issues_event_min_datetime": "2015-01-12T23:00:15.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T19:14:08.000Z", "max_forks_repo_path": "content/many-valued-logic/sequent-calculus/propositional-rules.tex", "max_forks_repo_name": "jzc/OpenLogic", "max_forks_repo_head_hexsha": "5948483c1d08c25664dc12ac8350e9ae34986b31", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 241, "max_forks_repo_forks_event_min_datetime": "2015-02-28T22:05:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T18:47:05.000Z", "avg_line_length": 33.6355932203, "max_line_length": 70, "alphanum_fraction": 0.6579743008, "num_tokens": 3365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4081157586041334}}
{"text": "\\ignore{\n\\documentstyle[11pt]{report}\n\\textwidth 13.7cm\n\\textheight 21.5cm\n\\newcommand{\\myimp}{\\verb+ :- +}\n\\newcommand{\\ignore}[1]{}\n\\def\\definitionname{Definition}\n\n\\makeindex\n\\begin{document}\n\n}\n\\chapter{\\label{chapter:predicates}Predicates and Functions}\nIn Picat, predicates\\index{predicate} and functions\\index{function} are defined with pattern-matching rules. Picat has two types of rules: the \\emph{non-backtrackable} rule\\index{non-backtrackable rule} \n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> \\> $Head, Cond\\ $\\verb+=>+$\\ Body$. \n\\end{tabbing}\nand the \\emph{backtrackable} rule\\index{backtrackable rule} \n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> \\> $Head, Cond\\ $\\verb+?=>+$\\ Body$. \n\\end{tabbing}\nEach rule is terminated by a dot (\\verb+.+) followed by a white space. \n\n\\section{Predicates}\nA \\emph{predicate}\\index{predicate} defines a relation, and can have zero, one, or multiple answers. Within a predicate\\index{predicate}, the $Head$ is a \\emph{pattern} in the form $p(t_1,\\ldots,t_n)$, where $p$ is called the predicate\\index{predicate} \\emph{name}, and $n$ is called the \\emph{arity}\\index{arity}. When $n=0$, the parentheses can be omitted. The condition $Cond$, which is an optional goal\\index{goal}, specifies a condition under which the rule is applicable. $Cond$ cannot succeed more than once. The compiler converts $Cond$ to \\texttt{once $Cond$}\\index{\\texttt{once}} if would otherwise be possible for $Cond$ to succeed more than once.\n\nFor a call $C$, if $C$ matches the pattern $p(t_1,\\ldots,t_n)$ and $Cond$ is true, then the rule is said to be \\emph{applicable} to $C$. When applying a rule to call $C$, Picat rewrites $C$ into $Body$. If the used rule is non-backtrackable\\index{non-backtrackable rule}, then the rewriting is a commitment, and the program can never backtrack to $C$. However, if the used rule is backtrackable\\index{backtrackable rule}, then the program will backtrack to $C$ once $Body$ fails, meaning that $Body$ will be rewritten back to $C$, and the next applicable rule will be tried on $C$. \n\nA predicate\\index{predicate} is said to be \\emph{deterministic} if it is defined with non-backtrackable rules\\index{non-backtrackable rule} only, \\emph{non-deterministic} if at least one of its rules is backtrackable\\index{backtrackable rule}, and \\emph{globally deterministic} if it is deterministic and all of the predicates\\index{predicate} in the bodies of the predicate's\\index{predicate} rules are also globally deterministic. A deterministic predicate\\index{predicate} that is not globally deterministic can still have more than one answer. \n\n\\subsection*{Example}\n\\begin{verbatim}\n    append(Xs,Ys,Zs) ?=> Xs=[], Ys=Zs.\n    append(Xs,Ys,Zs) => Xs=[X|XsR], append(XsR,Ys,Zs).\n\n    min_max([H],Min,Max) => Min=H, Max=H.\n    min_max([H|T],Min,Max) => \n        min_max(T,MinT,MaxT), \n        Min=min(MinT,H),\n        Max=max(MaxT,H).\n\\end{verbatim}\nThe predicate \\texttt{append(Xs,Ys,Zs)}\\index{\\texttt{append/3}} is true if the concatenation of \\texttt{Xs} and \\texttt{Ys} is \\texttt{Zs}. It defines a relation among the three arguments, and does not assume directionality of any of the arguments. For example, this predicate can be used to concatenate two lists, as in the call \n\\begin{verbatim}\n    append([a,b],[c,d],L)\n\\end{verbatim}\nthis predicate can also be used to split a list nondeterministically into two sublists, as in the call \\texttt{append(L1,L2,[a,b,c,d])}\\index{\\texttt{append/3}}; this predicate can even be called with three free variables, as in the call \\texttt{append(L1,L2,L3)}\\index{\\texttt{append/3}}. \n\nThe predicate \\texttt{min\\_max(L,Min,Max)} returns two answers through its arguments.  It binds \\texttt{Min} to the minimum of list \\texttt{L}, and binds \\texttt{Max} to the maximum of list \\texttt{L}. This predicate does not backtrack. Note that a call fails if the first argument is not a list. Also note that this predicate consumes linear space. A tail-recursive\\index{tail recursion} version of this predicate that consumes constant space will be given below.\n\n\n\\section{Functions}\nA \\emph{function}\\index{function} is a special kind of a predicate\\index{predicate} that always succeeds with \\emph{one} answer. Within a function\\index{function}, the $Head$ is an equation $p(t_1,\\ldots, t_n)$\\verb+=+$X$, where $p$ is called the function\\index{function} \\emph{name}, and $X$ is an \\emph{expression} that gives the return value. Functions\\index{function} are defined with non-backtrackable rules\\index{non-backtrackable rule} only.  \n\nFor a call $C$, if $C$ matches the pattern $p(t_1,\\ldots,t_n)$ and $Cond$ is true, then the rule is said to be \\emph{applicable} to $C$. When applying a rule to call $C$, Picat rewrites the equation $C$\\verb+=+$X'$ into \\texttt{($Body$, $X'$=$X$)}, where $X'$ is a newly introduced variable that holds the return value of $C$. \n\nPicat allows inclusion of \\emph{function facts}\\index{function fact} in the form {\\tt $p$($t_1$,$\\ldots$,$t_n$)\\verb+=+$Exp$} in function\\index{function} definitions. The function fact\\index{function fact} {\\tt $p$($t_1$,$\\ldots$,$t_n$)\\verb+=+$Exp$} is shorthand for the rule:\n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> {\\tt $p$($t_1$,$\\ldots$,$t_n$)\\verb+=+$X$ \\verb+=>+ $X\\verb+=+Exp$.}\n\\end{tabbing}\nwhere $X$ is a new variable.\n \nAlthough all functions\\index{function} can be defined as predicates\\index{predicate}, it is preferable to define them as functions\\index{function} for two reasons.  Firstly, functions\\index{function} often lead to more compact expressions than predicates\\index{predicate}, because arguments of function\\index{function} calls can be other function\\index{function} calls.  Secondly, functions\\index{function} are easier to debug than predicates\\index{predicate}, because functions\\index{function} never fail and never return more than one answer. \n\n\\subsection*{Example}\n\\begin{verbatim}\n    qequation(A,B,C) = (R1,R2), \n        D = B*B-4*A*C, \n        D >= 0 \n    => \n        NTwoC = -2*C,\n        R1 = NTwoC/(B+sqrt(D)),\n        R2 = NTwoC/(B-sqrt(D)).\n\n    rev([]) = [].\n    rev([X|Xs]) = rev(Xs)++[X].\n\\end{verbatim}\nThe function \\texttt{qequation(A,B,C)} returns the pair of roots of \\texttt{A*X$^2$+B*X+C=0}. If the discriminant \\texttt{B*B-4*A*C} is negative, then an exception will be thrown. \n\nThe function \\texttt{rev(L)} returns the reversed list of \\texttt{L}. Note that the function \\texttt{rev(L)} takes quadratic time and space in the length of \\texttt{L}. A tail-recursive\\index{tail recursion} version that consumes linear time and space will be given below.\n\n\\section{Patterns and Pattern-Matching}\nThe pattern $p(t_1,\\ldots,t_n)$ in the head of a rule takes the same form as a structure. Function\\index{function} calls are not allowed in patterns. Also, patterns cannot contain index notations, dot notations, ranges, array comprehensions, or list comprehensions. Pattern matching is used to decide whether a rule is applicable to a call. For a pattern $P$ and a term $T$, term $T$ matches pattern $P$ if $P$ is identical to $T$, or if $P$ can be made identical to $T$ by instantiating $P$'s variables. Note that variables in the term do not get instantiated after the pattern matching. If term $T$ is more general than pattern $P$, then the pattern matching can never succeed.\n\nUnlike calls in many committed-choice languages, calls in Picat are never suspended if they are more general than the head patterns of the rules. A predicate\\index{predicate} call fails if it does not match the head pattern of any of the rules in the predicate\\index{predicate}. A function\\index{function} call throws an exception if it does not match the head pattern of any of the rules in the function\\index{function}. For example, for the function call \\texttt{rev(L)}, where \\texttt{L} is a variable, Picat will throw the following exception:\n\n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> \\> \\texttt{unresolved\\_function\\_call(rev(L))}.\n\\end{tabbing}\n\nA pattern can contain \\emph{as-patterns}\\index{as-pattern} in the form \\texttt{$V$@$Pattern$}, where $V$ is a new variable in the rule, and $Pattern$ is a non-variable term. The as-pattern\\index{as-pattern} \\texttt{$V$@$Pattern$} is the same as \\texttt{$Pattern$} in pattern matching, but after pattern matching succeeds, $V$ is made to reference the term that matched $Pattern$. As-patterns\\index{as-pattern} can avoid re-constructing existing terms.\n\n\\subsection*{Example}\n\\begin{verbatim}\n    merge([],Ys) = Ys.\n    merge(Xs,[]) = Xs.\n    merge([X|Xs],Ys@[Y|_]) = [X|Zs], X<Y => Zs=merge(Xs,Ys). \n    merge(Xs,[Y|Ys]) = [Y|merge(Xs,Ys)].\n\\end{verbatim}\nIn the third rule, the as-pattern\\index{as-pattern} \\texttt{Ys@[Y|\\_]} binds two variables: \\texttt{Ys} references the second argument, and \\texttt{Y} references the car\\index{car} of the argument. The rule can be rewritten as follows without using any as-pattern\\index{as-pattern}:\n\\begin{verbatim}\n    merge([X|Xs],[Y|Ys]) = [X|Zs], X<Y => Zs=merge(Xs,[Y|Ys]). \n\\end{verbatim}\nNevertheless, this version is less efficient, because the cons\\index{cons} \\texttt{[Y|Ys]} needs to be re-constructed.\n\n\\section{Goals}\nIn a rule, both the condition and the body are \\emph{goals}\\index{goal}. Queries that the users give to the interpreter are also goals\\index{goal}. A goal\\index{goal} can take one of the following forms:\n\\begin{itemize}\n\\item \\texttt{true}\\index{\\texttt{true}}: This goal\\index{goal} is always true.\n\\item \\texttt{fail}\\index{\\texttt{fail}}: This goal\\index{goal} is always false. When \\texttt{fail}\\index{\\texttt{fail}} occurs in a condition, the condition is false, and the rule is never applicable. When \\texttt{fail}\\index{\\texttt{fail}} occurs in a body, it causes execution to backtrack.\n\\item \\texttt{false}\\index{\\texttt{false}}: This goal is the same as \\texttt{fail}.\n\\item $p(t_1, \\ldots, t_n)$: This goal\\index{goal} is a predicate call. The arguments $t_1, \\ldots, t_n$ are evaluated in the given order, and the resulting call is resolved using the rules in the predicate $p/n$. If the call succeeds, then variables in the call may get instantiated. Many built-in predicates\\index{predicate} are written in infix notation. For example, \\texttt{X=Y} is the same as \\texttt{'='(X,Y)}.\n\\item \\texttt{$P$, $Q$}: This goal\\index{goal} is a conjunction of goal\\index{goal} $P$ and goal\\index{goal} $Q$. It is resolved by first resolving $P$, and then resolving $Q$. The goal\\index{goal} is true if both $P$ and $Q$ are true. Note that the order is important: ($P$, $Q$) is in general not the same as ($Q$, $P$).\n\\item \\texttt{$P$ $\\&\\&$ $Q$}: This is the same as \\texttt{($P$, $Q$)}. \n\\item \\texttt{$P$; $Q$}: This goal\\index{goal} is a disjunction of goal\\index{goal} $P$ and goal\\index{goal} $Q$. It is resolved by first resolving $P$. If $P$ is true, then the disjunction is true. If $P$ is false, then $Q$ is resolved. The disjunction is true if $Q$ is true. The disjunction is false if both $P$ and $Q$ are false. Note that a disjunction can succeed more than once. Note also that the order is important: ($P$; $Q$) is generally not the same as ($Q$; $P$).\n\\item \\texttt{$P$ $|$$|$ $Q$}: This is the same as \\texttt{($P$; $Q$)}.\n\\item \\texttt{not $P$}\\index{\\texttt{not}}: This goal\\index{goal} is the negation of $P$. It is false if $P$ is true, and true if $P$ is false.  Note a negation goal\\index{goal} can never succeed more than once.  Also note that no variables can get instantiated, no matter whether the goal\\index{goal} is true or false.\n\\item \\texttt{once $P$}\\index{\\texttt{once}}: This goal\\index{goal} is the same as $P$, but can never succeed more than once.\n\\item \\texttt{repeat}\\index{\\texttt{repeat/0}}: This predicate is defined as follows:\n\\begin{verbatim}\n    repeat ?=> true.\n    repeat => repeat.\n\\end{verbatim}\nThe \\texttt{repeat}\\index{\\texttt{repeat/0}} predicate is often used to describe failure-driven loops\\index{failure-driven loop}. For example, the query \n\\begin{verbatim}\n      repeat,writeln(a),fail\n\\end{verbatim} \nrepeatedly outputs \\texttt{'a'} until \\texttt{ctrl-c} is typed.\n\\item \\texttt{if-then}\\index{if statement}: An if-then statement takes the form \n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> \\texttt{if $Cond_1$ then} \\\\\n\\> \\> $Goal_1$ \\\\\n\\> \\texttt{elseif $Cond_2$ then} \\\\\n\\> \\> $Goal_2$ \\\\\n\\> \\> $\\vdots$ \\\\\n\\> \\texttt{elseif $Cond_{n}$ then} \\\\\n\\> \\> $Goal_{n}$ \\\\\n\\> \\texttt{else} \\\\\n\\> \\> $Goal_{else}$ \\\\\n\\> \\texttt{end}\n\\end{tabbing}\nwhere the \\texttt{elseif} and \\texttt{else} clauses are optional. If the \\texttt{else} clause is missing, then the else goal\\index{goal} is assumed to be \\texttt{true}. For the if-then statement, Picat finds the first condition $Cond_i$ that is true. If such a condition is found, then the truth value of the if-then statement is the same as $Goal_i$. If none of the conditions is true, then the truth value of the if-then statement is the same as $Goal_{else}$. Note that no condition can succeed more than once. \n\\ignore{\n\\item \\texttt{try-catch}\\index{\\texttt{try}}: A \\texttt{try-catch}\\index{\\texttt{try}} statement specifies a goal\\index{goal} to try, the exceptions that need to be handled when they occur during the execution of the goal\\index{goal}, and a clean-up goal\\index{goal} that is executed no matter whether the goal\\index{goal} succeeds, fails, or is terminated by an exception. The detailed syntax and semantics of the \\texttt{try-catch}\\index{\\texttt{try}} statement will be given in Chapter \\ref{chapter:exception} on Exceptions.\n}\n\\item \\texttt{throw $Exception$}\\index{\\texttt{throw}}: This predicate throws the term $Exception$. This predicate will be detailed in Chapter \\ref{chapter:exception} on Exceptions.\n\\item Loops: Picat has three types of loop statements: foreach, while, and do-while.  A loop statement is true if and only if every iteration of the loop is true. The details of loops are given in Chapter \\ref{chapter:loops}.\n\\end{itemize}\n\n\\section{Predicate Facts}\nFor an extensional relation that contains a large number of tuples, it is tedious to define such a relation as a predicate\\index{predicate} with pattern-matching rules. It is worse if the relation has multiple keys. In order to facilitate the definition of extensional relations, Picat allows the inclusion of \\emph{predicate facts}\\index{predicate fact} in the form \\texttt{$p$($t_1$,$\\ldots$,$t_n$)} in predicate\\index{predicate} definitions. Facts and rules cannot co-exist in predicate definitions and facts must be ground. A predicate\\index{predicate} definition that consists of facts can be preceded by an \\emph{index declaration}\\index{index declaration} in the form \n\\begin{tabbing}\naa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\= aaa \\kill\n\\> \\texttt{index ($M_{11},M_{12},\\ldots,M_{1n}$) $\\ldots$ ($M_{m1},M_{m2},\\ldots,M_{mn}$)}\\index{\\texttt{index}} \n\\end{tabbing}\nwhere each $M_{ij}$ is either $+$ (meaning indexed) or $-$ (meaning not indexed). If no index declaration is given, then Picat assumes that no arguments are indexed. Facts are translated into pattern-matching rules before they are compiled. \n\n\\subsection*{Example}\n\\begin{verbatim}\n    index (+,-) (-,+)\n    edge(a,b).\n    edge(a,c).\n    edge(b,c).\n    edge(c,b).\n\\end{verbatim}\nThe predicate \\texttt{edge} is translated into the following rules:\n\\begin{verbatim}\n    edge(a,Y) ?=> Y=b.\n    edge(a,Y) =>  Y=c.\n    edge(b,Y) =>  Y=c.\n    edge(c,Y) =>  Y=b.\n    edge(X,b) ?=> X=a.\n    edge(X,c) ?=> X=a.\n    edge(X,c) =>  X=b.\n    edge(X,b) =>  X=c.\n\\end{verbatim}\n\n\\section{Tail Recursion}\nA rule is said to be \\emph{tail-recursive}\\index{tail recursion} if the last call of the body is the same predicate\\index{predicate} as the head. The \\emph{last-call optimization}\\index{last-call optimization} enables last calls to reuse the stack frame of the head predicate\\index{predicate} if the frame is not protected by any choice points. This optimization is especially effective for tail recursion\\index{tail recursion}, because it converts recursion into iteration. Tail recursion\\index{tail recursion} runs faster and consumes less memory than non-tail recursion.\n\nThe trick to convert a predicate\\index{predicate} (or a function\\index{function}) into tail recursion\\index{tail recursion} is to define a helper that uses an \\emph{accumulator}\\index{accumulator} parameter to accumulate\\index{accumulator} the result. When the base case is reached, the accumulator\\index{accumulator} is returned. At each iteration, the accumulator\\index{accumulator} is updated. Initially, the original predicate\\index{predicate} (or function\\index{function}) calls the helper with an initial value for the accumulator\\index{accumulator} parameter.\n\n\n\\subsection*{Example}\n\\begin{verbatim}\n    min_max([H|T],Min,Max) => \n        min_max_helper([H|T],H,Min,H,Max).\n\n    min_max_helper([],CMin,Min,CMax,Max) => Min=CMin, Max=CMax.\n    min_max_helper([H|T],CMin,Min,CMax,Max) => \n        min_max_helper(T,min(CMin,H),Min,max(CMax,H),Max).\n\n    rev([]) = [].\n    rev([X|Xs]) = rev_helper(Xs,[X]).\n\n    rev_helper([],R) = R.\n    rev_helper([X|Xs],R) = rev_helper(Xs,[X|R]).\n\\end{verbatim}\nIn the helper predicate \\texttt{min\\_max\\_helper(L,CMin,Min,CMax,Max)}, \\texttt{CMin} and \\texttt{CMax} are accumulators\\index{accumulator}: \\texttt{CMin} is the current minimum value, and \\texttt{CMax} is the current maximum value. When \\texttt{L} is empty, the accumulators\\index{accumulator} are returned by the unification calls \\texttt{Min=CMin} and \\texttt{Max=CMax}. When \\texttt{L} is a cons\\index{cons} \\texttt{[H|T]}, the accumulators\\index{accumulator} are updated: \\texttt{CMin} changes to \\texttt{min(CMin,H)}\\index{\\texttt{min/2}}, and \\texttt{CMax} changes to \\texttt{max(CMax,H)}\\index{\\texttt{max/2}}. The helper function \\texttt{rev\\_helper(L,R)} follows the same idea: it uses an accumulator\\index{accumulator} list to hold, in reverse order, the elements that have been scanned. When \\texttt{L} is empty, the accumulator\\index{accumulator} is returned. When \\texttt{L} is the cons\\index{cons} \\texttt{[X|Xs]}, the accumulator\\index{accumulator} \\texttt{R} changes to \\texttt{[X|R]}.\n\\ignore{\n\\end{document}\n}\n\n\n", "meta": {"hexsha": "fe4604a74e686c979fefbe145910d3025b817ce6", "size": 18219, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/predfunc.tex", "max_stars_repo_name": "ponyatov/pycat", "max_stars_repo_head_hexsha": "b02baacfd519cc1f95b42cdce0d96078910e50c0", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-02T01:10:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-08T18:13:13.000Z", "max_issues_repo_path": "src/doc/predfunc.tex", "max_issues_repo_name": "ponyatov/pycat", "max_issues_repo_head_hexsha": "b02baacfd519cc1f95b42cdce0d96078910e50c0", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-24T17:55:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-23T20:29:31.000Z", "max_forks_repo_path": "src/doc/predfunc.tex", "max_forks_repo_name": "ponyatov/pycat", "max_forks_repo_head_hexsha": "b02baacfd519cc1f95b42cdce0d96078910e50c0", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-08T17:56:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-08T17:56:16.000Z", "avg_line_length": 87.1722488038, "max_line_length": 1002, "alphanum_fraction": 0.722048411, "num_tokens": 5365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4081157529131489}}
{"text": "\\documentstyle{article}\n\n\\newcommand{\\refitem}[1]{%\n  \\begin{list}%\n        {}%\n        {\\setlength{\\leftmargin}{.25in}\\setlength{\\itemindent}{-.25in}}\n  \\item #1%\n  \\end{list}}\n\n\\setlength{\\textwidth}{6in}\n\\setlength{\\textheight}{8.75in}\n\\setlength{\\topmargin}{-0.25in}\n\\setlength{\\oddsidemargin}{0.25in}\n\n% This command enables hyphenation if \\tt mode by changed \\hyphencharacter\n% in the 10 point typewriter font. To work in other point sizes it would\n% have to be redefined. It may be Bator to just make the change globally \n% and have it apply to anything that is set in \\tt mode\n\\newcommand{\\dcode}[1]{{\\tt #1}}\n\n\\newcommand{\\param}[1]{$\\langle${\\em #1\\/}$\\rangle$}\n\\newcommand{\\protoimage}[1]{\\begin{picture}(100,20)\\put(0,0){\\makebox(100,20){\\tt #1}}\\put(50,10){\\oval(100,20)}\\end{picture}}\n\\newcommand{\\wprotoimage}[1]{\\begin{picture}(120,20)\\put(0,0){\\makebox(120,20){\\tt #1}}\\put(60,10){\\oval(120,20)}\\end{picture}}\n\n\\title{Generalized Linear Models in Lisp-Stat}\n\\author{Luke Tierney}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\nThis note outlines a simple system for fitting generalized linear\nmodels in Lisp-Stat. Three standard models are implemented:\n\\begin{itemize}\n\\item Poisson regression models\n\\item Binomial regression models\n\\item Gamma regression models\n\\end{itemize}\nThe model prototypes inherit from the linear regression model\nprototype. By default, each model uses the canonical link for its\nerror structure, but alternate link structures can be specified.\n\nThe next section outlines the basic use of the generalized linear\nmodel objects. The third section describes a few functions for\nhandling categorical independent variables. The fourth section gives\nfurther details on the structure of the model prototypes, and\ndescribes how to define new models and link structures. The final\nsection illustrates several ways of fitting more specialized models,\nusing the Bradley-Terry model as an example.\n\n\\section{Basic Use of the Model Objects}\nThree functions are available for constructing generalized linear\nmodel objects.  These functions are called as\n\\begin{flushleft}\\tt\n(poissonreg-model \\param{x} \\param{y} [\\param{keyword arguments ...}])\\\\\n(binomialreg-model \\param{x} \\param{y} \\param{n} [\\param{keyword arguments ...}])\\\\\n(gammareg-model \\param{x} \\param{y} \\param{keyword arguments ...})\n\\end{flushleft}\nThe \\param{x} and \\param{y} arguments are as for the\n\\dcode{regression-model} function. The sample size parameter \\param{n}\nfor binomial models can be either an integer or a sequence of integers\nthe same length as the response vector. All optional keyword\narguments accepted by the \\dcode{regression-model} function are\naccepted by these functions as well. Four additional keywords are\navailable:\n\\dcode{:link}, \\dcode{:offset}, \\dcode{:verbose}, and \\dcode{:pweights}.\nThe keyword \\dcode{:link} can be used to specify an alternate link\nstructure. Available link structures include\n\\begin{center}\n\\begin{tabular}{llll}\n\\tt identity-link & \\tt log-link    & \\tt inverse-link & \\tt sqrt-link\\\\\n\\tt logit-link    & \\tt probit-link & \\tt cloglog-link\n\\end{tabular}\n\\end{center}\nBy default, each model uses its canonical link structure.  The\n\\dcode{:offset} keyword can be used to provide an offset value, and\nthe keyword \\dcode{:verbose} can be given the value \\dcode{nil} to\nsuppress printing of iteration information. A prior weight vector\nshould be specified with the \\dcode{:pweights} keyword rather than the\n\\dcode{:weights} keyword.\n\nAs an example, we can examine a data set that records the number of\nmonths prior to an interview when individuals remember a stressful\nevent (originally from Haberman, \\cite[p. 2]{JKL}):\n\\begin{verbatim}\n> (def months-before (iseq 1 18))\nMONTHS-BEFORE\n> (def event-counts '(15 11 14 17 5 11 10 4 8 10 7 9 11 3 6 1 1 4))\nEVENTS-RECALLED\n\\end{verbatim}\nThe data are multinomial, and we can fit a log-linear Poisson model to\nsee if there is any time trend:\n\\begin{verbatim}\n> (def m (poissonreg-model months-before event-counts))\nIteration 1: deviance = 26.3164\nIteration 2: deviance = 24.5804\nIteration 3: deviance = 24.5704\nIteration 4: deviance = 24.5704\n\nWeighted Least Squares Estimates:\n\nConstant                  2.80316   (0.148162)\nVariable 0             -0.0837691   (0.0167996)\n\nScale taken as:                 1\nDeviance:                 24.5704\nNumber of cases:               18\nDegrees of freedom:            16\n\\end{verbatim}\n\nResiduals for the fit can be obtained using the \\dcode{:residuals}\nmessage:\n\\begin{verbatim}\n> (send m :residuals)\n(-0.0439191 -0.790305 ...)\n\\end{verbatim}\nA residual plot can be obtained using\n\\begin{verbatim}\n(send m :plot-residuals)\n\\end{verbatim}\nThe \\dcode{:fit-values} message returns $X\\beta$, the linear predictor\nwithout any offset. The \\dcode{:fit-means} message returns fitted mean\nresponse values. Thus the expression\n\\begin{verbatim}\n(let ((p (plot-points months-before event-counts)))\n  (send p :add-lines months-before (send m :fit-means)))\n\\end{verbatim}\nconstructs a plot of raw counts and fitted means against time.\n\nTo illustrate fitting binomial models, we can use the leukemia survival\ndata of Feigl and Zelen \\cite[Section 2.8.3]{LS} with the survival\ntime converted to a one-year survival indicator:\n\\begin{verbatim}\n> (def surv-1 (if-else (> times-pos 52) 1 0))\nSURV-1\n> surv-1\n(1 1 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1)\n\\end{verbatim}\nThe dependent variable is the base 10 logarithm of the white blood\ncell counts divided by 10,000:\n\\begin{verbatim}\n> transformed-wbc-pos\n(-1.46968 -2.59027 -0.84397 -1.34707 -0.510826 0.0487902 0 0.530628 -0.616186\n -0.356675 -0.0618754 1.16315 1.25276 2.30259 2.30259 1.64866 2.30259)\n\\end{verbatim}\nA binomial model for these data can be constructed by\n\\begin{verbatim}\n> (def lk (binomialreg-model transformed-wbc-pos surv-1 1))\nIteration 1: deviance = 18.2935\nIteration 2: deviance = 18.0789\nIteration 3: deviance = 18.0761\nIteration 4: deviance = 18.0761\n\nWeighted Least Squares Estimates:\n\nConstant                 0.372897   (0.590934)\nVariable 0              -0.985803   (0.508426)\n\nScale taken as:                 1\nDeviance:                 18.0761\nNumber of cases:               17\nDegrees of freedom:            15\n\\end{verbatim}\nThis model uses the logit link, the canonical link for the binomial\ndistribution. As an alternative, the expression\n\\begin{verbatim}\n(binomialreg-model transformed-wbc-pos surv-1 1 :link probit-link)\n\\end{verbatim}\nreturns a model using a probit link.\n\nThe \\dcode{:cooks-distances} message helps to highlight the last\nobservation for possible further examination:\n\\begin{verbatim}\n> (send lk :cooks-distances)\n(0.0142046 0.00403243 0.021907 0.0157153 0.149394 0.0359723 0.0346383\n 0.0450994 0.174799 0.0279114 0.0331333 0.0347883 0.033664 0.0170441 \n 0.0170441 0.0280411 0.757332)\n\\end{verbatim}\nThis observation also stands out in the plot produced by\n\\begin{verbatim}\n(send lk :plot-bayes-residuals)\n\\end{verbatim}\n\n\\section{Tools for Categorical Variables}\nFour functions are provided to help construct indicator vectors for\ncategorical variables. As an illustration, a data set used by Bishop,\nFienberg, and Holland examines the relationship between occupational\nclassifications of fathers and sons. The classes are\n\\begin{center}\n\\begin{tabular}{|c|l|}\n\\hline\nLabel & Description\\\\\n\\hline\nA     & Professional, High Administrative\\\\\nS     & Managerial, Executive, High Supervisory\\\\\nI     & Low Inspectional, Supervisory\\\\\nN     & Routine Nonmanual, Skilled Manual\\\\\nU     & Semi- and Unskilled Manual\\\\\n\\hline\n\\end{tabular}\n\\end{center}\nThe counts are given by\n\\begin{center}\n\\begin{tabular}{|c|rrrrr|}\n\\hline\n       & \\multicolumn{5}{c|}{Son}\\\\\n\\hline\nFather &  A &   S &   I &   N &   U \\\\\n\\hline\n A     & 50 &  45 &   8 &  18 &   8 \\\\\n S     & 28 & 174 &  84 & 154 &  55 \\\\\n I     & 11 &  78 & 110 & 223 &  96 \\\\\n N     & 14 & 150 & 185 & 714 & 447 \\\\\n U     &  3 &  42 &  72 & 320 & 411 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\nWe can set up the occupation codes as\n\\begin{verbatim}\n(def occupation '(a s i n u))\n\\end{verbatim}\nand construct the son's and father's code vectors for entering the\ndata row by row as\n\\begin{verbatim}\n(def son (repeat occupation 5))\n(def father (repeat occupation (repeat 5 5)))\n\\end{verbatim}\nThe counts can then be entered as\n\\begin{verbatim}\n(def counts '(50  45   8  18   8 \n              28 174  84 154  55 \n              11  78 110 223  96\n              14 150 185 714 447\n               3  42  72 320 411))\n\\end{verbatim}\n\nTo fit an additive log-linear model, we need to construct level\nindicators.  This can be done using the function \\dcode{indicators}:\n\\begin{verbatim}\n> (indicators son)\n((0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0)\n (0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0)\n (0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0)\n (0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1))\n\\end{verbatim}\nThe result is a list of indicator variables for the second through the fifth\nlevels of the variable \\dcode{son}. By default, the first level is dropped.\nTo obtain indicators for all five levels, we can supply the \\dcode{:drop-first}\nkeyword with value \\dcode{nil}:\n\\begin{verbatim}\n> (indicators son :drop-first nil)\n((1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0)\n (0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0)\n (0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0)\n (0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0)\n (0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1))\n\\end{verbatim}\n\nTo produce a readable summary of the fit, we also need some labels:\n\\begin{verbatim}\n> (level-names son :prefix 'son)\n(\"SON(S)\" \"SON(I)\" \"SON(N)\" \"SON(U)\")\n\\end{verbatim}\nBy default, this function also drops the first level. This can again be\nchanged by supplying the \\dcode{:drop-first} keyword argument as\n\\dcode{nil}:\n\\begin{verbatim}\n> (level-names son :prefix 'son :drop-first nil)\n(\"SON(A)\" \"SON(S)\" \"SON(I)\" \"SON(N)\" \"SON(U)\")\n\\end{verbatim}\nThe value of the \\dcode{:prefix} keyword can be any Lisp expression.\nFor example, instead of the symbol \\dcode{son} we can use the string\n\\dcode{\"Son\"}:\n\\begin{verbatim}\n> (level-names son :prefix \"Son\")\n(\"Son(S)\" \"Son(I)\" \"Son(N)\" \"Son(U)\")\n\\end{verbatim}\n\nUsing indicator variables and level labels, we can now fit an additive\nmodel as\n\\begin{verbatim}\n> (def mob-add\n       (poissonreg-model\n        (append (indicators son) (indicators father)) counts\n        :predictor-names (append (level-names son :prefix 'son)\n                                 (level-names father :prefix 'father))))\n\nIteration 1: deviance = 1007.97\nIteration 2: deviance = 807.484\nIteration 3: deviance = 792.389\nIteration 4: deviance = 792.19\nIteration 5: deviance = 792.19\n\nWeighted Least Squares Estimates:\n\nConstant                  1.36273   (0.130001)\nSON(S)                    1.52892   (0.10714)\nSON(I)                    1.46561   (0.107762)\nSON(N)                    2.60129   (0.100667)\nSON(U)                    2.26117   (0.102065)\nFATHER(S)                 1.34475   (0.0988541)\nFATHER(I)                 1.39016   (0.0983994)\nFATHER(N)                 2.46005   (0.0917289)\nFATHER(U)                 1.88307   (0.0945049)\n\nScale taken as:                 1\nDeviance:                  792.19\nNumber of cases:               25\nDegrees of freedom:            16\n\\end{verbatim}\nExamining the residuals using  \n\\begin{verbatim}\n(send mob-add :plot-residuals)\n\\end{verbatim}\nshows that the first cell is an outlier -- the model does not fit this\ncell well.\n\nTo fit a saturated model to these data, we need the cross products of\nthe indicator variables and also a corresponding set of labels. The\nindicators are produced with the \\dcode{cross-terms} function\n\\begin{verbatim}\n> (cross-terms (indicators son) (indicators father))\n((0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)\n (0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0)\n ...)\n\\end{verbatim}\nand the names with the \\dcode{cross-names} function:\n\\begin{verbatim}\n> (cross-names (level-names son :prefix 'son)\n               (level-names father :prefix 'father))\n(\"SON(S).FATHER(S)\" \"SON(S).FATHER(I)\" ...)\n\\end{verbatim}\nThe saturated model can now be fit by\n\\begin{verbatim}\n> (let ((s (indicators son))\n        (f (indicators father))\n        (sn (level-names son :prefix 'son))\n        (fn (level-names father :prefix 'father)))\n    (def mob-sat\n         (poissonreg-model (append s f (cross-terms s f)) counts \n                           :predictor-names\n                           (append sn fn (cross-names sn fn)))))\n\nIteration 1: deviance = 5.06262e-14\nIteration 2: deviance = 2.44249e-15\n\nWeighted Least Squares Estimates:\n\nConstant                  3.91202   (0.141421)\nSON(S)                  -0.105361   (0.20548)\nSON(I)                   -1.83258   (0.380789)\nSON(N)                   -1.02165   (0.274874)\nSON(U)                   -1.83258   (0.380789)\nFATHER(S)               -0.579818   (0.236039)\nFATHER(I)                -1.51413   (0.33303)\nFATHER(N)                -1.27297   (0.302372)\nFATHER(U)                -2.81341   (0.594418)\nSON(S).FATHER(S)          1.93221   (0.289281)\nSON(S).FATHER(I)          2.06417   (0.382036)\nSON(S).FATHER(N)          2.47694   (0.346868)\nSON(S).FATHER(U)          2.74442   (0.631953)\nSON(I).FATHER(S)          2.93119   (0.438884)\nSON(I).FATHER(I)          4.13517   (0.494975)\nSON(I).FATHER(N)          4.41388   (0.470993)\nSON(I).FATHER(U)          5.01064   (0.701586)\nSON(N).FATHER(S)           2.7264   (0.343167)\nSON(N).FATHER(I)          4.03093   (0.41346)\nSON(N).FATHER(N)          4.95348   (0.385207)\nSON(N).FATHER(U)          5.69136   (0.641883)\nSON(U).FATHER(S)          2.50771   (0.445978)\nSON(U).FATHER(I)          3.99903   (0.496312)\nSON(U).FATHER(N)          5.29608   (0.467617)\nSON(U).FATHER(U)          6.75256   (0.693373)\n\nScale taken as:                 1\nDeviance:              3.37508e-14\nNumber of cases:               25\nDegrees of freedom:             0\n\\end{verbatim}\n\n\\section{Structure of the Generalized Linear Model System}\n\\subsection{Model Prototypes}\nThe model objects are organized into several prototypes, with the\ngeneral prototype \\dcode{glim-proto} inheriting from\n\\dcode{regression-model-proto}, the prototype for normal linear\nregression models. The inheritance tree is shown in Figure\n\\ref{GLIMTree}.\n\\begin{figure}\n\\begin{center}\n\\begin{picture}(400,160)\n\\put(140,140){\\wprotoimage{regression-model-proto}}\n\\put(150,70){\\protoimage{glim-proto}}\n\\put(0,0){\\protoimage{poissonreg-proto}}\n\\put(150,0){\\protoimage{binomialreg-proto}}\n\\put(300,0){\\protoimage{gammareg-proto}}\n\\put(200,140){\\line(0,-1){50}}\n\\put(200,70){\\line(-3,-1){150}}\n\\put(200,70){\\line(3,-1){150}}\n\\put(200,70){\\line(0,-1){50}}\n\\end{picture}\n\\end{center}\n\\caption{Hierarchy of generalized linear model prototypes.}\n\\label{GLIMTree}\n\\end{figure}\nThis inheritance captures the reasoning by analogy to the linear case\nthat is the basis for many ideas in the analysis of generalized linear\nmodels. The fitting strategy uses iteratively reweighted least squares\nby changing the weight vector in the model and repeatedly calling the\nlinear regression \\dcode{:compute} method.\n\nConvergence of the iterations is determined by comparing the relative\nchange in the coefficients and the change in the deviance to cutoff\nvalues. The iteration terminates if either change falls below the\ncorresponding cutoffs. The cutoffs are set and retrieved by the\n\\dcode{:epsilon} and \\dcode{:epsilon-dev} methods. The default values\nare given by\n\\begin{verbatim}\n> (send glim-proto :epsilon)\n1e-06\n> (send glim-proto :epsilon-dev)\n0.001\n\\end{verbatim}\nA limit is also imposed on the number of iterations. The limit can be set\nand retrieved by the \\dcode{:count-limit} message. The default value\nis given by\n\\begin{verbatim}\n> (send glim-proto :count-limit)\n30\n\\end{verbatim}\n\nThe analogy captured in the inheritance of the \\dcode{glim-proto}\nprototype from the normal linear regression prototype is based\nprimarily on the computational process, not the modeling process. As a\nresult, several accessor methods inherited from the linear regression\nobject refer to analogous components of the computational process,\nrather than analogous components of the model. Two examples are the\nmessages \\dcode{:weights} and \\dcode{:y}. The weight vector in the\nobject returned by \\dcode{:weights} is the final set of weights\nobtained in the fit; prior weights can be set and retrieved with the\n\\dcode{:pweights} message. The value returned by the \\dcode{:y}\nmessage is the artificial dependent variable\n\\begin{displaymath}\nz = \\eta + (y - \\mu) \\frac{d\\eta}{d\\mu}\n\\end{displaymath}\nconstructed in the iteration; the actual dependent variable can be\nobtained and changed with the \\dcode{:yvar} message.\n\nThe message \\dcode{:eta} returns the current linear predictor values,\nincluding any offset. The \\dcode{:offset} message sets and retrieves\nthe offset value. For binomial models, the \\dcode{:trials} message\nsets and retrieves the number of trials for each observation.\n\nThe scale factor is set and retrieved with the \\dcode{:scale} message.\nSome models permit the estimation of a scale parameter. For these\nmodels, the fitting system uses the \\dcode{:fit-scale} message to\nobtain a new scale value. The message \\dcode{:estimate-scale}\ndetermines and sets whether the scale parameter is to be estimated or\nnot.\n\nDeviances of individual observations, the total deviance, and the mean\ndeviance are returned by the messages \\dcode{:deviances},\n\\dcode{:deviance} and \\dcode{:mean-deviance}, respectively. The\n\\dcode{:deviance} and \\dcode{:mean-deviance} methods adjusts for\nomitted observations, and the denominator for the mean deviance is\nadjusted for the degrees of freedom available.\n\nMost inherited methods for residuals, standard errors, etc., should\nmake sense at least as approximations. For example, residuals returned\nby the inherited \\dcode{:residuals} message correspond to the Pearson\nresiduals for generalized linear models. Other forms of residuals are\nreturned by the messages\n\\begin{center}\n\\begin{tabular}{lll}\n\\tt :chi-residuals & \\tt :deviance-residuals & \\tt :g2-residuals\\\\\n\\tt :raw-residuals & \\tt :standardized-chi-residuals & \\tt :standardized-deviance-residuals.\n\\end{tabular}\n\\end{center}\n\n\\subsection{Error Structures}\nThe error structure of a generalized linear model affects four methods\nand two slots The methods are called as\n\\begin{flushleft}\\tt\n(send \\param{m} :initial-means)\\\\\n(send \\param{m} :fit-variances \\param{mu})\\\\\n(send \\param{m} :fit-deviances  \\param{mu})\\\\\n(send \\param{m} :fit-scale)\n\\end{flushleft}\nThe \\dcode{:initial-means} method should return an initial estimate of\nthe means for the iterative search. The default method simply returns\nthe dependent variable, but for some models this may need to be\nadjusted to move the initial estimate away from a boundary. For\nexample, the method for the Poisson regression model can be defined as\n\\begin{verbatim}\n(defmeth poissonreg-proto :initial-means () (pmax (send self :yvar) 0.5))\n\\end{verbatim}\nwhich insures that initial mean estimates are at least 0.5.\n\nThe \\dcode{:fit-variances} \\dcode{:fit-deviances} methods return the\nvalues on the variance and deviance functions for a specified vector\nof means. For the Poisson regression model, these methods can be\ndefined as\n\\begin{verbatim}\n(defmeth poissonreg-proto :fit-variances (mu) mu)\n\\end{verbatim}\nand\n\\begin{verbatim}\n(defmeth poissonreg-proto :fit-deviances (mu)\n  (flet ((log+ (x) (log (if-else (< 0 x) x 1))))\n    (let* ((y (send self :yvar))\n           (raw-dev (* 2 (- (* y (log+ (/ y mu))) (- y mu))))\n           (pw (send self :pweights)))\n      (if pw (* pw raw-dev) raw-dev))))\n\\end{verbatim}\nThe local function \\dcode{log+} is used to avoid taking the logarithm\nof zero.\n\nThe final message, \\dcode{:fit-scale}, is only used by the\n\\dcode{:display} method. The default method returns the mean deviance.\n\nThe two slots related to the error structure are\n\\dcode{estimate-scale} and \\dcode{link}. If the value of the\n\\dcode{estimate-scale} slot is not \\dcode{nil}, then a scale estimate\nis computed and printed by the \\dcode{:dislay} method. The\n\\dcode{link} slot holds the link object used by the model. The Poisson\nmodel does not have a scale parameter, and the canonical link is the\nlogit link. These defaults can be set by the expressions\n\\begin{verbatim}\n(send poissonreg-proto :estimate-scale nil)\n(send poissonreg-proto :link log-link)\n\\end{verbatim}\n\nThe \\dcode{glim-proto} prototype itself uses normal errors and an\nidentity link. Other error structures can be implemented by\nconstructing a new prototype and defining appropriate methods and\ndefault slot values.\n\n\\subsection{Link Structures}\nThe link function $g$ for a generalized linear model relates the\nlinear predictor $\\eta$ to the mean response $\\mu$ by\n\\begin{displaymath}\n\\eta = g(\\mu).\n\\end{displaymath}\nLinks are implemented as objects.\nTable \\ref{Links} lists the pre-defined link functions, along with\nthe expressions used to return link objects.\n\\begin{table}\n\\caption{Link Functions and Expression for Obtaining Link Objects}\n\\label{Links}\n\\begin{center}\n\\begin{tabular}{lccl}\n\\hline\nLink & Formula & Domain & Expression\\\\\n\\hline\nIdentity    & $\\mu$      & $(-\\infty, \\infty)$ & \\tt identity-link \\\\\nLogarithm   & $\\log \\mu$ & $(0, \\infty)$     & \\tt log-link\\\\\nInverse     & $ 1/\\mu$   & $(0, \\infty)$ & \\tt inverse-link\\\\\nSquare Root & $\\sqrt{\\mu}$ & $(0, \\infty)$ & \\tt sqrt-link\\\\\nLogit       & $\\log\\frac{\\mu}{1-\\mu}$ & $[0,1]$ & \\tt logit-link\\\\\nProbit      & $\\Phi^{-1}(\\mu)$ & $[0,1]$ & \\tt probit-link\\\\\nCompl. log-log & $\\log(-\\log(1-\\mu))$ & $[0,1]$ & \\tt cloglog-link\\\\\nPower       & $\\mu^{k}$ & $(0, \\infty)$ & \\tt (send power-link-proto :new \\param{k})\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\nWith one exception, the pre-defined links require no parameters.\nThese link objects can therefore be shared among models. The exception\nis the power link. Links for binomial models are defined for $n = 1$\ntrials and assume $0 < \\mu < 1$.\n\nLink objects inherit from the \\dcode{glim-link-proto} prototype.  The\n\\dcode{log-link} object, for example, is constructed by\n\\begin{verbatim}\n(defproto log-link () () glim-link-proto)\n\\end{verbatim}\nSince this prototype can be used directly in model objects, the\nconvention of having prototype names end in \\dcode{-proto} is not\nused. The \\dcode{glim-link-proto} prototype provides a \\dcode{:print}\nmethod that should work for most link functions. The \\dcode{log-link}\nobject prints as\n\\begin{verbatim}\n> log-link\n#<Glim Link Object: LOG-LINK>\n\\end{verbatim}\n\nThe \\dcode{glim-proto} computing methods assume that a link object\nresponds to three messages:\n\\begin{flushleft}\\tt\n(send \\param{link} :eta \\param{mu})\\\\\n(send \\param{link} :means \\param{eta})\\\\\n(send \\param{link} :derivs \\param{mu})\n\\end{flushleft}\nThe \\dcode{:eta} method returns a sequence of linear predictor values\nfor a particular mean sequence. The \\dcode{:means} method is the\ninverse of \\dcode{:eta}: it returns mean values for specified values\nof the linear predictor. The \\dcode{:derivs} method returns the values of\n\\begin{displaymath}\n\\frac{d\\eta}{d\\mu}\n\\end{displaymath}\nat the specified mean values. As an example, for the \\dcode{log-link}\nobject these three methods are defined as\n\\begin{verbatim}\n(defmeth log-link :eta (mu) (log mu))\n(defmeth log-link :means (eta) (exp eta))\n(defmeth log-link :derivs (mu) (/ mu))\n\\end{verbatim}\n\nAlternative link structures can be constructed by setting up a new\nprototype and defining appropriate \\dcode{:eta}, \\dcode{:means}, and\n\\dcode{:derivs} methods. Parametric link families can be implemented by\nproviding one or more slots for holding the parameters. The power link\nis an example of a parametric link family. The power link prototype\nis defined as\n\\begin{verbatim}\n(defproto power-link-proto '(power) () glim-link-proto)\n\\end{verbatim}\nThe slot \\dcode{power} holds the power exponent. An accessor method\nis defined by\n\\begin{verbatim}\n(defmeth power-link-proto :power () (slot-value 'power))\n\\end{verbatim}\nand the \\dcode{:isnew} initialization method is defined to require a\npower argument:\n\\begin{verbatim}\n(defmeth power-link-proto :isnew (power) (setf (slot-value 'power) power))\n\\end{verbatim}\nThus a power link for a particular exponent, say the exponent 2, can\nbe constructed using the expression\n\\begin{verbatim}\n(send power-link-proto :new 2)\n\\end{verbatim}\n\nTo complete the power link prototype, we need to define the three\nrequired methods. They are defined as\n\\begin{verbatim}\n(defmeth power-link-proto :eta (mu) (^ mu (send self :power)))\n\\end{verbatim}\n\\begin{verbatim}\n(defmeth power-link-proto :means (eta) (^ eta (/ (slot-value 'power))))\n\\end{verbatim}\nand\n\\begin{verbatim}\n(defmeth power-link-proto :derivs (mu)\n  (let ((p (slot-value 'power)))\n    (* p (^ mu (- p 1)))))\n\\end{verbatim}\nThe definition of the \\dcode{:means} method could be improved to allow\nnegative arguments when the power is an odd integer. Finally, the\n\\dcode{:print} method is redefined to reflect the value of the\nexponent:\n\\begin{verbatim}\n(defmeth power-link-proto :print (&optional (stream t))\n  (format stream ``#<Glim Link Object: Power Link (~s)>'' (send self :power)))\n\\end{verbatim}\nThus a square link prints as\n\\begin{verbatim}\n> (send power-link-proto :new 2)\n#<Glim Link Object: Power Link (2)>\n\\end{verbatim}\n\n\\section{Fitting a Bradley-Terry Model}\nMany models used in categorical data analysis can be viewed as\nspecial cases of generalized linear models. One example is the\nBradley-Terry model for paired comparisons. The Bradley-Terry model\ndeals with a situation in which $n$ individuals or items are compared\nto one another in paired contests.  The model assumes there are\npositive quantities $\\pi_{1}, \\ldots, \\pi_{n}$, which can be assumed\nto sum to one, such that\n\\begin{displaymath}\nP\\{\\mbox{$i$ beats $j$}\\} = \\frac{\\pi_{i}}{\\pi_{i} + \\pi_{j}}.\n\\end{displaymath}\nIf the competitions are assumed to be mutually independent, then the\nprobability $p_{ij} = P\\{\\mbox{$i$ beats $j$}\\}$ satisfies the logit\nmodel\n\\begin{displaymath}\n\\log\\frac{p_{ij}}{1-p_{ij}} = \\phi_{i} - \\phi_{j}\n\\end{displaymath}\nwith $\\phi_{i} = \\log \\pi_{i}$. This model can be fit to a particular\nset of data by setting up an appropriate design matrix and response\nvector for a binomial regression model. For a single data set this can\nbe done from scratch. Alternatively, it is possible to construct\nfunctions or prototypes that allow the data to be specified in a more\nconvenient form. Furthermore, there are certain specific questions\nthat can be asked for a Bradley-Terry model, such as what is the\nestimated value of $P\\{\\mbox{$i$ beats $j$}\\}$? In the object-oriented\nframework, it is very natural to attach methods for answering such\nquestions to individual models or to a model prototype.\n\nTo illustrate these ideas, we can fit a Bradley-Terry model to the\nresults for the eastern division of the American league for the 1987\nbaseball season \\cite{Agresti}. Table \\ref{WinsLosses} gives the results\nof the games within this division.\n\\begin{table}\n\\caption{Results of 1987 Season for American League Baseball Teams}\n\\label{WinsLosses}\n\\begin{center}\n\\begin{tabular}{lccccccc}\n\\hline\nWinning & \\multicolumn{7}{c}{Losing Team}\\\\\n\\cline{2-8}\nTeam & Milwaukee & Detroit & Toronto & New York & Boston &\nCleveland & Baltimore\\\\\n\\hline\nMilwaukee & -  & 7  & 9  & 7  &  7  & 9 & 11\\\\\nDetroit   & 6  & -  & 7  & 5  & 11  & 9 &  9\\\\\nToronto   & 4  & 6  & -  & 7  &  7  & 8 & 12\\\\\nNew York  & 6  & 8  & 6  & -  &  6  & 7 & 10\\\\\nBoston    & 6  & 2  & 6  & 7  &  -  & 7 & 12\\\\\nCleveland & 4  & 4  & 5  & 6  &  6  & - &  6\\\\\nBaltimore & 2  & 4  & 1  & 3  &  1  & 7 &  -\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\nThe simplest way to enter this data is as a list, working through the\ntable one row at a time:\n\\begin{verbatim}\n(def wins-losses '( -  7  9  7  7  9 11\n                    6  -  7  5 11  9  9\n                    4  6  -  7  7  8 12\n                    6  8  6  -  6  7 10\n                    6  2  6  7  -  7 12\n                    4  4  5  6  6  -  6\n                    2  4  1  3  1  7  -))\n\\end{verbatim}\nThe choice of the symbol \\dcode{-} for the diagonal entries is\narbitrary; any other Lisp item could be used. The team names will also\nbe useful as labels:\n\\begin{verbatim}\n(def teams '(\"Milwaukee\" \"Detroit\" \"Toronto\" \"New York\"\n             \"Boston\" \"Cleveland\" \"Baltimore\"))\n\\end{verbatim}\n\nTo set up a model, we need to extract the wins and losses from the\n\\dcode{wins-losses} list. The expression\n\\begin{verbatim}\n(let ((i (iseq 1 6)))\n  (def low-i (apply #'append (+ (* 7 i) (mapcar #'iseq i)))))\n\\end{verbatim}\nconstructs a list of the indices of the elements in the lower\ntriangle:\n\\begin{verbatim}\n> low-i\n(7 14 15 21 22 23 28 29 30 31 35 36 37 38 39 42 43 44 45 46 47)\n\\end{verbatim}\nThe wins can now be extracted from the \\dcode{wins-losses} list using\n\\begin{verbatim}\n> (select wins-losses low-i)\n(6 4 6 6 8 6 6 2 6 7 4 4 5 6 6 2 4 1 3 1 7)\n\\end{verbatim}\nSince we need to extract the lower triangle from a number of lists, we\ncan define a function to do this as\n\\begin{verbatim}\n(defun lower (x) (select x low-i))\n\\end{verbatim}\nUsing this function, we can calculate the wins and save them in a\nvariable \\dcode{wins}:\n\\begin{verbatim}\n(def wins (lower wins-losses))\n\\end{verbatim}\n\nTo extract the losses, we need to form the list of the entries for the\ntranspose of our table.  The function \\dcode{split-list} can be used\nto return a list of lists of the contents of the rows of the original\ntable.  The \\dcode{transpose} function transposes this list of lists,\nand the \\dcode{append} function can be applied to the result to\ncombine the lists of lists for the transpose into a single list:\n\\begin{verbatim}\n(def losses-wins (apply #'append (transpose (split-list wins-losses 7))))\n\\end{verbatim}\nThe losses are then obtained by\n\\begin{verbatim}\n(def losses (lower losses-wins))\n\\end{verbatim}\nEither \\dcode{wins} or \\dcode{losses} can be used as the response for\na binomial model, with the trials given by\n\\begin{verbatim}\n(+ wins losses)\n\\end{verbatim}\n\nWhen fitting the Bradley-Terry model as a binomial regression model\nwith a logit link, the model has no intercept and the columns of the\ndesign matrix are the differences of the row and column indicators for\nthe table of results.  Since the rows of this matrix sum to zero if\nall row and column levels are used, we can delete one of the levels,\nsay the first one. Lists of row and column indicators are set up by\nthe expressions\n\\begin{verbatim}\n(def rows (mapcar #'lower (indicators (repeat (iseq 7) (repeat 7 7)))))\n(def cols (mapcar #'lower (indicators (repeat (iseq 7) 7))))\n\\end{verbatim}\nThe function \\dcode{indicators} drops the first level in constructing\nits indicators. The function \\dcode{mapcar} applies \\dcode{lower} to\neach element of the indicators list and returns a list of the results.\nUsing these two variables, the expression\n\\begin{verbatim}\n(- rows cols)\n\\end{verbatim}\nconstructs a list of the columns of the design matrix.\n\nWe can now construct a model object for this data set:\n\\begin{verbatim}\n> (def wl (binomialreg-model (- rows cols)\n                             wins\n                             (+ wins losses)\n                             :intercept nil\n                             :predictor-names (rest teams)))\nIteration 1: deviance = 16.1873\nIteration 2: deviance = 15.7371\n\nWeighted Least Squares Estimates:\n\nDetroit                 -0.144948   (0.311056)\nToronto                 -0.286871   (0.310207)\nNew York                -0.333738   (0.310126)\nBoston                  -0.473658   (0.310452)\nCleveland               -0.897502   (0.316504)\nBaltimore                -1.58134   (0.342819)\n\nScale taken as:                 1\nDeviance:                 15.7365\nNumber of cases:               21\nDegrees of freedom:            15\n\\end{verbatim}\n\nTo fit to a Bradley-Terry model to other data sets, we can repeat this\nprocess.  As an alternative, we can incorporate the steps used here\ninto a function:\n\\begin{verbatim}\n(defun bradley-terry-model (counts &key labels)\n  (let* ((n (round (sqrt (length counts))))\n         (i (iseq 1 (- n 1)))\n         (low-i (apply #'append (+ (* n i) (mapcar #'iseq i))))\n         (p-names (if labels\n                      (rest labels) \n                      (level-names (iseq n) :prefix \"Choice\"))))\n    (labels ((tr (x)\n               (apply #'append (transpose (split-list (coerce x 'list) n))))\n             (lower (x) (select x low-i))\n             (low-indicators (x) (mapcar #'lower (indicators x))))\n      (let ((wins (lower counts))\n            (losses (lower (tr counts)))\n            (rows (low-indicators (repeat (iseq n) (repeat n n))))\n            (cols (low-indicators (repeat (iseq n) n))))\n        (binomialreg-model (- rows cols)\n                           wins \n                           (+ wins losses)\n                           :intercept nil\n                           :predictor-names p-names)))))\n\\end{verbatim}\nThis function defines the function \\dcode{lower} as a local function.\nThe local function \\dcode{tr} calculates the list of the elements in\nthe transposed table, and the function \\dcode{low-indicators} produces\nindicators for the lower triangular portion of a categorical variable.\nThe \\dcode{bradley-terry-model} function allows the labels for the\ncontestants to be specified as a keyword argument. If this argument is\nomitted, reasonable default labels are constructed. Using this\nfunction, we can construct our model object as\n\\begin{verbatim}\n(def wl (bradley-terry-model wins-losses :labels teams))\n\\end{verbatim}\n\nThe definition of this function could be improved to allow some of the\nkeyword arguments accepted by \\dcode{binomialreg-model}.\n\nUsing the fit model object, we can estimate the probability of Boston\n$(i = 4)$ defeating New York $(j = 3)$:\n\\begin{verbatim}\n> (let* ((phi (cons 0 (send wl :coef-estimates)))\n         (exp-logit (exp (- (select phi 3) (select phi 4)))))\n    (/ exp-logit (+ 1 exp-logit)))\n0.534923\n\\end{verbatim}\nTo be able to easily calculate such an estimate for any pairing, we can\ngive our model object a method for the \\dcode{:success-prob} message\nthat takes two indices as arguments:\n\\begin{verbatim}\n(defmeth wl :success-prob (i j)\n  (let* ((phi (cons 0 (send self :coef-estimates)))\n         (exp-logit (exp (- (select phi i) (select phi j)))))\n    (/ exp-logit (+ 1 exp-logit))))\n\\end{verbatim}\nThen\n\\begin{verbatim}\n> (send wl :success-prob 4 3)\n0.465077\n\\end{verbatim}\n\nIf we want this method to be available for other data sets, we can\nconstruct a Bradley-Terry model prototype by\n\\begin{verbatim}\n(defproto bradley-terry-proto () () binomialreg-proto)\n\\end{verbatim}\nand add the \\dcode{:success-prob} method to this prototype:\n\\begin{verbatim}\n(defmeth bradley-terry-proto :success-prob (i j)\n  (let* ((phi (cons 0 (send self :coef-estimates)))\n         (exp-logit (exp (- (select phi i) (select phi j)))))\n    (/ exp-logit (+ 1 exp-logit))))\n\\end{verbatim}\nIf we modify the \\dcode{bradley-terry-model} function to use this prototype\nby defining the function as\n\\begin{verbatim}\n(defun bradley-terry-model (counts &key labels)\n  (let* ((n (round (sqrt (length counts))))\n         (i (iseq 1 (- n 1)))\n         (low-i (apply #'append (+ (* n i) (mapcar #'iseq i))))\n         (p-names (if labels\n                      (rest labels) \n                      (level-names (iseq n) :prefix \"Choice\"))))\n    (labels ((tr (x)\n               (apply #'append (transpose (split-list (coerce x 'list) n))))\n             (lower (x) (select x low-i))\n             (low-indicators (x) (mapcar #'lower (indicators x))))\n      (let ((wins (lower counts))\n            (losses (lower (tr counts)))\n            (rows (low-indicators (repeat (iseq n) (repeat n n))))\n            (cols (low-indicators (repeat (iseq n) n))))\n        (send bradley-terry-proto :new\n              :x (- rows cols)\n              :y wins\n              :trials (+ wins losses)\n              :intercept nil\n              :predictor-names p-names)))))\n\\end{verbatim}\nthen the \\dcode{:success-prob} metod is available immediately for a\nmodel constructed using this function:\n\\begin{verbatim}\n> (def wl (bradley-terry-model wins-losses :labels teams))\nIteration 1: deviance = 16.1873\nIteration 2: deviance = 15.7371\n...\n> (send wl :success-prob 4 3)\n0.465077\n\\end{verbatim}\n\nThe \\dcode{:success-prob} method can be improved in a number of ways.\nAs one example, we might want to be able to obtain standard errors in\naddition to estimates. A convenient way to provide for this\npossibility is to have our method take an optional argument. If this\nargument is \\dcode{nil}, the default, then the method just returns the\nestimate. If the argument is not \\dcode{nil}, then the method returns\na list of the estimate and its standard error. \n\nTo calculate the standard error, it is easier to start with the logit\nof the probability, since the logit is a linear function of the model\ncoefficients. The method defined as\n\\begin{verbatim}\n(defmeth bradley-terry-proto :success-logit (i j &optional stdev)\n  (let ((coefs (send self :coef-estimates)))\n    (flet ((lincomb (i j)\n             (let ((v (repeat 0 (length coefs))))\n               (if (/= 0 i) (setf (select v (- i 1)) 1))\n               (if (/= 0 j) (setf (select v (- j 1)) -1))\n               v)))\n      (let* ((v (lincomb i j))\n             (logit (inner-product v coefs))\n             (var (if stdev (matmult v (send self :xtxinv) v))))\n        (if stdev (list logit (sqrt var)) logit)))))\n\\end{verbatim}\nreturns the estimate or a list of the estimate and approximate\nstandard error of the logit:\n\\begin{verbatim}\n> (send wl :success-logit 4 3)\n-0.13992\n> (send wl :success-logit 4 3 t)\n(-0.13992 0.305583)\n\\end{verbatim}\nThe logit is calculated as a linear combination of the coefficients; a\nlist representing the linear combination vector is constructed by the\nlocal function \\dcode{lincomb}.\n\nStandard errors for success probabilities can be computed form the\nresults of \\dcode{:success-logit} using the delta method:\n\\begin{verbatim}\n(defmeth bradley-terry-proto :success-prob (i j &optional stdev)\n  (let* ((success-logit (send self :success-logit i j stdev))\n         (exp-logit (exp (if stdev (first success-logit) success-logit)))\n         (p (/ exp-logit (+ 1 exp-logit)))\n         (s (if stdev (* p (- 1 p) (second success-logit)))))\n    (if stdev (list p s) p)))\n\\end{verbatim}\nFor our example, the results are\n\\begin{verbatim}\n> (send wl :success-prob 4 3)\n0.465077\n> (send wl :success-prob 4 3 t)\n(0.465077 0.0760231)\n\\end{verbatim}\n\nThese methods can be improved further by allowing them to accept\nsequences of indices instead of only individual indices.\n\n\\section*{Acknowledgements}\nI would like to thank Sandy Weisberg for many helpful comments and\nsuggestions, and for providing the code for the glim residuals\nmethods.\n\n%\\section*{Notes}\n%On the DECstations you can load the generalized linear model\n%prototypes with the expression\n%\\begin{verbatim}\n%(load-example \"glim\")\n%\\end{verbatim}\n%This code seems to work reasonably on the examples I have tried, but\n%it is not yet thoroughly debugged.\n\n\\begin{thebibliography}{99}\n\\bibitem{Agresti}\n{\\sc Agresti, A.} (1990), {\\em Categorical Data Analysis}, New York,\nNY: Wiley.\n\n\\bibitem{JKL}\n{\\sc Lindsey, J. K.} (1989), {\\em The Analysis of Categorical Data\nUsing GLIM}, Springer Lecture Notes in Statistics No.  56, New York,\nNY: Springer.\n\n\\bibitem{GLIM}\n{\\sc McCullagh, P. and Nelder, J. A.} (1989), {\\em Generalized Linear\nModels}, second edition, London: Chapman and Hall.\n\n\\bibitem{LS}\n{\\sc Tierney, L.} (1990), {\\em Lisp-Stat: An Object-Oriented\nEnvironment for Statistical Computing and Dynamic Graphics}, New York,\nNY: Wiley.\n\\end{thebibliography}\n\\end{document}\n\n\n\n\n\\begin{table}\n\\caption{Wins/Losses by Home and Away Team, 1987}\n\\begin{tabular}{lccccccc}\n\\hline\nHome & \\multicolumn{7}{c}{Away Team}\\\\\n\\cline{2-8}\nTeam & Milwaukee & Detroit & Toronto & New York & Boston &\nCleveland & Baltimore\\\\\n\\hline\nMilwaukee &  -  & 4-3 & 4-2 & 4-3 & 6-1 & 4-2 & 6-0\\\\\nDetroit   & 3-3 &  -  & 4-2 & 4-3 & 6-0 & 6-1 & 4-3\\\\\nToronto   & 2-5 & 4-3 &  -  & 2-4 & 4-3 & 4-2 & 6-0\\\\\nNew York  & 3-3 & 5-1 & 2-5 &  -  & 4-3 & 4-2 & 6-1\\\\\nBoston    & 5-1 & 2-5 & 3-3 & 4-2 &  -  & 5-2 & 6-0\\\\\nCleveland & 2-5 & 3-3 & 3-4 & 4-3 & 4-2 & -   & 2-4\\\\\nBaltimore & 2-5 & 1-5 & 1-6 & 2-4 & 1-6 & 3-4 &  - \\\\\n\\hline\n\\end{tabular}\n\\end{table}\n", "meta": {"hexsha": "963bad23af4adc4bef17bd0308097f4719b610d9", "size": 40446, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/glim.tex", "max_stars_repo_name": "jhbadger/xlispstat", "max_stars_repo_head_hexsha": "f1bea6053df658ee48612bf1f63c35de99e2c649", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2016-02-05T15:53:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T11:23:03.000Z", "max_issues_repo_path": "doc/glim.tex", "max_issues_repo_name": "jhbadger/xlispstat", "max_issues_repo_head_hexsha": "f1bea6053df658ee48612bf1f63c35de99e2c649", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/glim.tex", "max_forks_repo_name": "jhbadger/xlispstat", "max_forks_repo_head_hexsha": "f1bea6053df658ee48612bf1f63c35de99e2c649", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2017-04-10T04:32:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T20:06:53.000Z", "avg_line_length": 38.4102564103, "max_line_length": 127, "alphanum_fraction": 0.6859516392, "num_tokens": 12318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.408115746773305}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\t\n\\subsection{Adaptive wavenumber filtering}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nAdaptive wavenumber filtering is a well-established method for processing of images of propagating elastic waves.\nThe method has proved to be useful for crack size estimation~\\cite{Kudela2015}, impact induced damage assessment~\\cite{Kudela2018},  delamination and disbonding detection and localisation~\\cite{Radzienski2019a}.  \nIt is used here as a reference point for comparison purposes against proposed strategies based on FCN.\n\nThe method involves steps such as 2D Fourier Transform, wavenumber filtering, inverse Fourier Transform and RMS.\nIt can be used as an automated tool for producing damage maps which are easy in interpretation.\nHowever, it still requires setting a threshold for the filter mask and quantisation threshold useful for damage size estimation.\nThese thresholds can be estimated empirically and even certain rigid range of thresholds will lead to satisfactory results.\nNevertheless, it is not a fully automatic process.\nFCN based approach seems to have an advantage in this regard.\nOn the other hand, FCN would also need some prior inductive bias from the domain knowledge such as pre-processing parameters, supervision into assigned class, and the most important one: assumption that pixels of processed images can be categorized as damaged and undamaged.\nMoreover, the training of FCN requires tuning of many hyperparameters such as  learning rate, momentum, choice of optimizer, dropout rate, batch size, etc. \nBut this process must be completed only once.", "meta": {"hexsha": "4603fbfc41ed1fc14791ada5906a88fd73ec9fd5", "size": 1635, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/journal_papers/Paper_final/Adaptive_wavenumber_filtering_R1.tex", "max_stars_repo_name": "IFFM-PAS-MISD/aidd", "max_stars_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-03T05:36:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:36:07.000Z", "max_issues_repo_path": "reports/journal_papers/Paper_final/Adaptive_wavenumber_filtering_R1.tex", "max_issues_repo_name": "IFFM-PAS-MISD/aidd", "max_issues_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/journal_papers/Paper_final/Adaptive_wavenumber_filtering_R1.tex", "max_forks_repo_name": "IFFM-PAS-MISD/aidd", "max_forks_repo_head_hexsha": "9fb0ad6d5e6d94531c34778a66127e5913a3830c", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.1764705882, "max_line_length": 274, "alphanum_fraction": 0.770030581, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.40810477641048365}}
{"text": "\\section{A New Model}\n\n\\subsection{Definitions}\n\nTo overcome the limitations of classical models, which focus on the \nequilibrium status that will take a long time to reach, this paper propose a\nnew model that enables effective simulation on early-stages of a system using \nrejuvenation.  The new model works as the follows. It is initialised to a \nworking state and its {\\it software rejuvenate schedule} is set to time $T$.  \nThe failure rate during the working period is a function of the elapsed working \ntime $t$.  A failed system takes $t_f$ time to repair.  At the end of a repair \nprocess or after working for $T$ time, the system enters to the rejuvenation \nprocess for $t_r$ time before being set to the initial working state.  Figure \n\\ref{model_new} gives the transition digram for the new Model, which consists \nof  the following 3 {\\it categories} of states:\n\n\\begin{itemize}\n \\item {\\tt W($\\tau$), $0 \\leq \\tau < T$} the state that the system has running \nwithout failure for $\\tau$ time;\n \\item {\\tt R($\\tau$), $0 \\leq \\tau < t_r$} the state that the system has \nentered \nthe rejuvenation process for $\\tau$ time.\n \\item {\\tt F($\\tau$), $0 \\leq \\tau < t_f$} the state that the system has \nfailed \nfor $\\tau$ time, during which period no rejuvenation process has been invoked, \nbut other repair processes, such as data restore, maybe performed.\n\\end{itemize}\n\nFor the convince of later discussions, this paper index possible state $x_i$ as \nfollows:\n\n\\begin{defn}\n\\[ x_i = \\left\\{ \n  \\begin{array}{l l}\n    W(i)    &   0 \\leq i < T \\\\\n    R(i-T) &   T \\leq i < T+t_r \\\\ \n    F(i-T-t_r) &   T+t_r \\leq i < T+t_r+t_f \\\\     \n  \\end{array} \\right.\\]\n\\end{defn}\n\nLet $X_t$ be the state of the system at time $t \\geq 0$, then the process $X = \n(X_t, t \\geq 0)$ is a stochastic process.  If time is a discrete value in the \nmodel, the process has discrete time and discrete state space.  \nIf time is a  continuous value in the model, the process has \ncontinuous time and continuous state space.  \n\n\n\n\n\\begin{figure}\n  \\label{model_new}\n  \\centering       \n  \\includegraphics[scale=0.5]{model.png}\n  \\caption{New Model}\n\\end{figure}\n\n\n\\subsection{Cast Continues State Space to Discrete State Space}\n\nAs Section \\ref{discrete_model} will show, a standard Markov Chain can be \ndefined if time is treated as a discrete value.  Section \n\\ref{discrete_simulation} will give the simulation process corresponding to \nthe Markov Chain.  Although a general Markov process can be defined similarly \nfor the case where time is a continuous value, unfortunately, the general \nMarkov process does not have a precise simulation method.  Therefore, this \npaper converts the continuous case to an approximate discrete case, where a \nsimulation method can be applied.  \n\nTo convert a model with continuous state space to one with discrete state space,\na new time unit, $\\Delta t >  0$, is picked such that \n$T/\\Delta t$, $t_r/\\Delta t$, and $t_f/\\Delta t$ are integers.  Let $pdf$ be \nthe failure density function in the continues model, then the failure massive \nfunction at $T+\\Delta t$ in the discrete model is \n\n\\begin{equation}\npmf(T+\\Delta t) =  \\int_{T}^{T+\\Delta t} pdf(t) dt\n\\end{equation}\n\nFinally, times $t$ in the continuous model can be converted to $t/\\Delta t$ in \nthe new discrete model.\n\n\\begin{comment}\n\\subsubsection{The Transaction Probability Density}\n\nLet $p_{ij}$ be the probability of moving from $X_i$ to $X_j$ and $0 \\le j-i \n\\le \nmin\\{T, t_r, t_f\\}$.  \nWe have:\n\n\\begin{equation}\np_{ij} = \n\\begin{cases} \n\\frac{R(k+j-i)}{R(k)}    &  if\\ x_i = W(k), \\\\ &\\hspace{12pt}  x_j = W(k+j-i), \n\\\\ &\\hspace{12pt}  0\\leq k <T+i-j; \\\\\n\n\\frac{R(T)}{ R(k)}     &  if\\ x_i = W(k),   x_j = F(l), \\\\ &\\hspace{12pt}  \n0\\leq \nk < T, 0 \\leq l < j-i; \\\\ \n\n\\frac{R(T)}{R(k)}     &   if\\ x_i = W(T-k),   x_j = R(k),\\\\ &\\hspace{12pt}   0 \n\\leq k < j-i; \\\\\n\n\\int_{0}^{w} f(x)dx     &  if\\ x_i = R(k),   x_j = F(l), \\\\ &\\hspace{12pt}  \n0\\leq k < t_r, 0 \\leq l < t_f; \\\\ &\\hspace{12pt}  w = (j-i)-(t_r-k)-(t_f-l) \\\\\n\n1     &  if\\ x_i = R(k),  x_j = R(k+j-i),\\\\ &\\hspace{12pt}   0\\leq k <t_r+i-j, \n\\\\\n       &  or\\ x_i = F(k),   x_j = F(k+j-i),\\\\ &\\hspace{12pt}   0\\leq k \n<t_f+i-j, \n\\\\     \n       &  or\\ x_i = F(t_f-k),   x_j = R(k),\\\\ &\\hspace{12pt}   0 \\leq k < t_r, \n\\\\      \n       &   or\\ if\\ x_i = R(t_r-k), \\\\ &\\hspace{12pt}  x_j = W(k),   0 \\leq k < \nT; \\\\       \n0     &   otherwise\n\\end{cases}\n\\end{equation}\n\\hspace{90pt} where $0 \\le j-i \\le min{T, t_r, t_f}$\n\\end{comment}\n\n\n\\subsection{Discrete Model as a Markov Chain}\n\\label{discrete_model}\n\n\\subsubsection{Probability Mass Function and Failure Rate}\n\nLet $f(t)$ be the probability mass function (pmf) which represents the \nprobability that, without software rejuvenation, the system will fail when \nbeing running for exactly $t$.  We can derive its reliability function ($R(t)$) \nand the failure rate function ($\\lambda(t)$) as follows:\n\n\\begin{subequations}\n\\begin{align}\nR(t) & = 1- \\sum \\limits_{i=1}^{t-1} f(t) & t > 0 \\label{discrete_reliability}\\\\\n\\lambda(t) & = f(t)/R(t)  & t>0 \\label{discrete_failure_rate}\n\\end{align}\n\\end{subequations}\n\nIntuitively, $R(t)$ is the probability that the system can survive for as least \n$t$ time and $\\lambda(t)$ is the probability that the system, which has \nsurvived for time $t$, fails at the next moment.\n\n\\subsubsection{The Transaction Matrix}\n\nWe define the transaction matrix $P$ whose $(i,j)$th element is the probability \nof moving from $x_i$ to $x_j$ in exactly {\\it one} unit of time,  we have:\n\n\\begin{equation*}\np_{ij} = \n\\begin{cases} \n1 - \\lambda(k) & if\\ x_i = W(k), x_j = W(k+1),\\\\ &\\hspace{12pt}  0\\leq k <T-1; \n\\\\\n\\lambda(k)     & if\\ x_i = W(k), x_j = F(0),\\\\ &\\hspace{12pt}  0\\leq k <T-1,  \\\\\n1              & if\\ x_i = W(T-1), x_j = R(0), \\\\\n               & or\\ x_i = R(k), x_j = R(k+1),\\\\ &\\hspace{12pt}  0\\leq k < \nt_r-1, \\\\\n               & or\\ x_i = R(t_r), x_j = W(0), \\\\\n               & or\\ x_i = F(k), x_j = F(k+1),\\\\ &\\hspace{12pt}  0\\leq k <t_f-1, \n\\\\\n               & or\\ x_i = F(t_f), x_j = R(0); \\\\\n0              & otherwise\n\\end{cases}\n\\end{equation*}\n\nIt is easy to verify that $P$ satisfies the following two properties of {\\it stochastic matrix}:\n\\begin{enumerate}[\\itshape a\\upshape)]\n\\item $p_{ij} \\ge 0$, and\n\\item $\\sum \\limits_{i} p_{ij} = 1$.\n\\end{enumerate}\n\n\n\n\\subsubsection{Simulation}\n\\label{discrete_simulation}\n\nLet $\\mu_t$ be a row vector of probabilities so that $\\mu_t(i)$ represents the \nprobability that the system is at state $x_i$ at time $t$, we can inductively \nsimulate $\\mu_t$ as the follows:\n\n\\begin{subequations}\n\\label{discrete_simulation_mu}\n\\begin{align}\n\\mu_0 & =  \\begin{cases}  \\mu_0(0) = 1 & \\\\\n    \\mu_0(i) = 0 & 0 < i < T+t_r+t_f -1\n\\end{cases}  \\label{mu_0}\\\\\n\\mu_t & = \\mu_0 P  &  \\label{mu_t}\n\\end{align}\n\\end{subequations}\nParticularly, a row vector $\\pi$ is called a stationary distribution if $\\pi = \n\\pi P$.\n\nOn the other hand, the Chapman-Kolmogorov Equation states the follows:\n\n\\begin{equation}\n\\label{discrete_CK}\np_{ij}(m+n) = \\sum \\limits_k p_{ik}(m)p_{kj}(n)\n\\end{equation}\n\nwhere $p_{ij}(n)$ is the probability that the system moves from state $X_i$\nto state $X_j$ with in exactly $n$ steps.  \n\nA nice corollary of Equation \\ref{discrete_CK} is:\n\\begin{equation}\n\\label{discrete_CK_corollary}\nP_n = P^n\n\\end{equation}\nwhere $P_n$ is the transaction matrix whose $(i,j)$th element is the probability \nof moving from $x_i$ to $x_j$ in exactly $n$ unit of time.\n\nFrom either Equation \\ref{discrete_simulation_mu} or Equation \n\\ref{discrete_CK_corollary}, we have\n\\begin{equation}\n\\label{discrete_CK_corollary}\n\\mu_t = \\mu_0 P^t\n\\end{equation}\na standard property of (time-homogeneous) Markov Chain.\n\n\n\n\\subsubsection{Utility Analysis}\n\nBorrowed from economics, the notion of utility function is used to unifies\ndowntime cost analysis, availability analysis, and other variants in literature.\n\nLet $u(i)$ be {\\it utility function} that returns a real value if the system stays\nat state $x_i$ for one unit of time, the $expected$ utility gained at time $t$,\nand the $total$ utility gained until time $t$ are Equation \\ref{discrete_utility_t}\nand Equation \\ref{discrete_utility_T} respectively.\n\n\\begin{subequations}\n\\label{discrete_utility}\n\\begin{align}\nu_t  & =   \\sum \\limits_{i=0}^{T+t_r+t_f-1} u(i)\\mu_t(i)  \\label{discrete_utility_t}\\\\\nU_t  & =  F_{i=0}^{t} u_i  \\label{discrete_utility_T}\n\\end{align}\n\\end{subequations}\nwhere $F$ is an accumulating function.\n\n\n\\newpage\nCASE I: Availability Analysis\n\nThe utility function for availability analysis can be defined as:\n\n\\begin{equation}\n\\label{discrete_availability_utiliy}\nu(i) =  \\begin{cases}  1 & 0 \\leq i < T \\\\\n                       0 & T \\leq i < T+t_r+t_f -1\n\\end{cases}\n\\end{equation}\n\n\nThe target of \\citep{dohi2000statistical} is finding a value $T$ so that\n$a = \\sum \\limits_{i=0}^{T+t_r+t_f-1} u(i)\\pi(i) $ has a maximum value.\nNotice that, the changes of systems availability before the Markov model \nreaches its steady-state $\\pi$ is ignored in \\citep{dohi2000statistical}.\n\nFor a safety crucial system expected to run $t$ time, users may want to use the \nfollowing objective function instead.\n\n\\begin{equation}\n\\label{discrete_availability_minimum}\nA_{min}(t) = \\min_{i=0}^t u_i\n\\end{equation} \n\nThe average availability of a system during its first $t$ time is:\n\n\\begin{equation}\n\\label{discrete_availability_average}\n\\bar{A}(t) = \\frac{1}{ t }\\sum \\limits_{i=0}^{t} u_i\n\\end{equation}\n\nIf the system can reaches its steady-state $\\pi$, one may expect that \n\\begin{equation}\n  \\lim_{t\\rightarrow \\infty}{\\bar{A}(t)} = a\n\\end{equation}\n\nCASE II: Downtime Cost Analysis\n\nAs in \\citep{huang1995software}, let $c_f$ and $c_r$ be the unit cost \nof the system in state $F$ and $R$ respectively, we have:\n\n\\begin{equation}\n\\label{discrete_downtime_utiliy}\nu(i) =  \\begin{cases}   0 & 0 \\leq i < T \\\\\n                       -c_r & T \\leq i < T + t_r \\\\\n                       -c_f & T + t_r \\leq i < T + t_r + t_f\n        \\end{cases}\n\\end{equation}\n\nThe target of \\citep{huang1995software} is finding a value $T$ so that\n$c = \\sum \\limits_{i=0}^{T+t_r+t_f-1} u(i)\\pi(i) $ has a maximum value.\nNotice that, the changes of systems availability before the Markov model \nreaches its steady-state $\\pi$ is ignored in \\citep{dohi2000statistical}.\nActually, the expected total cost of running the system for $L$ time is:\n\\begin{equation}\n\\label{discrete_availability_total}\nC(L) = \\sum \\limits_{t=0}^{L} u_t\n\\end{equation}\n\nOnly when the system can reaches its steady-state $\\pi$, , one may expect \nthat \n\\begin{equation}\n  \\lim_{L\\rightarrow \\infty}{C(L)} = cL\n\\end{equation}\n\n\\newpage\n\nCASE III: Benefit Analysis\n\nThe utility function in CASE I returns non-negative value while the utility \nfunction in CASE II returns non-positive value.  In reality, a software \napplication gains revenue when it runs and cost resources to restart it when it \nis down.\n\nNow consider an international Voice over Internet Protocol (VoIP) service \nprovider, who implements a few independent front-end applications, each of \nwhich has the following utility function, where the unit of time is hour:\n\n\\begin{equation}\n\\label{discrete_benifit_utiliy}\nu(i) =  \\begin{cases}     r & 0 \\leq i < T \\\\\n                       -c_r & T \\leq i < T + t_r \\\\\n                       -c_f & T + t_r \\leq i < T + t_r + t_f\n        \\end{cases}\n\\end{equation}\n\nThe goal is set a proper rejuvenation schedule $T$ to maximize the total \nutility gained during the expect service time $L$ defined as: \n\\begin{equation}\n\\label{discrete_benifi_total}\nU(L) = \\sum \\limits_{t=0}^{L} u_t = \\sum \\limits_{t=0}^{L}  \\sum \n\\limits_{i=0}^{T+t_r+t_f-1} u(i)\\mu_t(i)\n\\end{equation}\n\n\n\\subsection{Reflection on Markov Processes}\n\nThe model in \\citep{huang1995software} has its root in Continuous Time Markov \nChain.  The model in \\citep{dohi2000statistical} is a Continuous Time \nSemi-Markov Chain. Our model is a devised Discrete Time Markov Chain (DTMC) or \na General Markov Process.\n\nThe General Markov Process is a precise model for software rejuvenation, but it \nmay not have an analysitcal form for the simulation purpose.  Our devised \nDTMC adds a time parameter to standard DTMC, result in a special form of CTMC \nand SMC.\n\nThe problem of our devised DTMC is the expanded state space. Recall that the \nsimulation process, $\\mu_t = \\mu_{t-1} P$, computes the product of a $1 \\times \nn$ matrix and a $n \\times n$ matrix, where $n$ is the number of states in the \nmodel.  It appears that the computational cost of the simulation \nprocess of the devised DTMC is impractical in a general case where $n$ is a \nlarge number.\n\nFortunately, the devised DTMC is an acceptable model for the software \nrejuvenation problem discussed in this paper for two reasons.  Firstly, \nnon-zero values in the state transition matrix are sparsely distributed, and \ntherefore matrix multiplication does not necessary require a long time to \ncompute.   Secondly, similar to the process of reducing a continuous model to a \ndiscrete model, the state space of a descrete model can be further reduced for \nachieving better performance, with the cost of sacrifying accuracy.", "meta": {"hexsha": "529a7bf2a00137b1be8de512ab4018cf567148b2", "size": 13146, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "s1024484/Paper/Rejuvenation/newmodel.tex", "max_stars_repo_name": "Jiansen/TAkka", "max_stars_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-09-11T14:35:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T06:36:09.000Z", "max_issues_repo_path": "s1024484/Paper/Rejuvenation/newmodel.tex", "max_issues_repo_name": "Jiansen/TAkka", "max_issues_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "s1024484/Paper/Rejuvenation/newmodel.tex", "max_forks_repo_name": "Jiansen/TAkka", "max_forks_repo_head_hexsha": "d2410190552aeea65c1da5f0ae05f08ba1f4d102", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3149171271, "max_line_length": 96, "alphanum_fraction": 0.6868248897, "num_tokens": 4150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398982, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4081047675812797}}
{"text": "\\subsection{Quantitative}\n\\label{subsec:experiments-quantitative}\n\n\\begin{figure*}\n\t\\centering\n\t\\vspace{-12px}\n\t\\input{plots/quantitative-bsds500-avg-min-max}\\\\[-4px]\n   \t\\input{plots/quantitative-bsds500-std}\\\\[-8px]\n   \t\\input{plots/quantitative-bsds500-k}\\\\[-4px]\n    \\caption{Quantitative experiments on the \\BSDS dataset; remember that \\K denotes the number of generated superpixels.\n    \\Rec (higher is better) and \\UE (lower is better) give a concise overview of the performance with respect to ground\n    truth. In contrast, \\EV (higher is better) gives a ground truth independent view on performance.\n    While top-performers as well as poorly performing algorithms are easily\n    identified, we provide more find-grained experimental results by considering\n    $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$. These statistics additionally can be used\n    to quantity the stability of superpixel algorithms. In particular, stable\n\talgorithms are expected to exhibit monotonically improving $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$.\n\tThe corresponding $\\text{std }\\Rec$, $\\text{std }\\UE$ and $\\text{std }\\EV$ as\n\twell as $\\max\\K$ and $\\text{std }\\K$ help to identify stable algorithms.\n\t\\textbf{Best viewed in color.}}\n    \\label{fig:experiments-quantitative-bsds500}\n\t\\vskip 12px\n\t\\input{legends/full}\n\\end{figure*}\n\\begin{figure*}\n\t\\centering\n\t\\vspace{-12px}\n\t\\input{plots/quantitative-nyuv2-avg-min-max}\\\\[-4px]\n\t\\input{plots/quantitative-nyuv2-std}\\\\[-8px]\n\t\\input{plots/quantitative-nyuv2-k}\\\\[-4px]\n\t\\caption{Quantitative results on the \\NYU dataset; remember that \\K denotes the number of generated superpixels.\n    The presented experimental results complement the discussion in Figure \\ref{fig:experiments-quantitative-bsds500}\n    and show that most observations can be confirmed across datasets. Furthermore,\n    \\DASP and \\VCCS show inferior performance suggesting that depth information does\n    not necessarily improve performance.\n\t\\textbf{Best viewed in color.}}\n\t\\label{fig:experiments-quantitative-nyuv2}\n\t\\vskip 12px\n\t\\input{legends/full+depth}\n\\end{figure*}\n\nPerformance is determined by \\Rec, \\UE and \\EV. In contrast to most authors,\nwe will look beyond metric averages. In particular, we consider the\nminimum/maximum as well as the standard deviation to get an impression of the behavior of superpixel algorithms.\nFurthermore, this allows us to quantify the stability of superpixel algorithms as\nalso considered by Neubert and Protzel in~\\cite{NeubertProtzel:2013}.\n\n\\Rec and \\UE offer a ground truth dependent overview to assess the performance of\nsuperpixel algorithms. We consider\nFigures \\ref{subfig:experiments-quantitative-bsds500-rec.mean_min} and \\ref{subfig:experiments-quantitative-bsds500-ue_np.mean_max},\nshowing \\Rec and \\UE on the \\BSDS dataset. With respect to \\Rec, we can easily identify top performing\nalgorithms, such as \\ETPSr and \\SEEDSr, as well as low performing algorithms,\nsuch as \\FHr, \\QSr and \\PFr. However, the remaining algorithms lie closely together\nin between these two extremes, showing (apart from some exceptions) similar performance\nespecially for large~\\K. Still, some algorithms perform consistently better than others,\nas for example \\ERGCr, \\SLICr, \\ERSr and \\CRSr. For \\UE, low performing algorithms,\nsuch as \\PFr or \\QSr, are still easily identified while the remaining algorithms\ntend to lie more closely together. Nevertheless, we can identify algorithms consistently\ndemonstrating good performance, such as \\ERGCr, \\ETPSr, \\CRSr, \\SLICr and \\ERSr.\nOn the \\NYU dataset, considering Figures \\ref{subfig:experiments-quantitative-nyuv2-rec.mean[0]} and \\ref{subfig:experiments-quantitative-nyuv2-ue_np.mean[0]},\nthese observations can be confirmed except for minor differences as for example the\nexcellent performance of \\ERS regarding \\UE or the better performance of \\QS regarding \\UE.\nOverall, \\Rec and \\UE provide a quick overview of superpixel algorithm performance\nbut might not be sufficient to reliably discriminate superpixel algorithms.\n\nIn contrast to \\Rec and \\UE, \\EV offers a ground truth independent assessment of superpixel algorithms.\nConsidering Figure \\ref{subfig:experiments-quantitative-bsds500-ev.mean_min}, showing \\EV on the \\BSDS dataset,\nwe observe that algorithms are dragged apart and even for large \\K\nsignificantly different \\EV values are attained. This suggests, that considering\nground truth independent metrics may be beneficial for comparison. However, \\EV\ncannot replace \\Rec or \\UE, as we can observe when comparing to\nFigures \\ref{subfig:experiments-quantitative-bsds500-rec.mean_min} and \\ref{subfig:experiments-quantitative-bsds500-ue_np.mean_max},\nshowing \\Rec and \\UE on the \\BSDS dataset; in particular\n\\QSr, \\FHr and \\CISr are performing significantly better with respect to \\EV than regarding \\Rec and \\UE.\nThis suggests that \\EV may be used to identify poorly performing algorithms, such as \\TPSr, \\PFr, \\PBr or \\NCr.\nOn the other hand, \\EV is not necessarily suited to identify well-performing algorithms\ndue to the lack of underlying ground truth.\nOverall, \\EV is suitable to complement the view provided by \\Rec and \\UE,\nhowever, should not be considered in isolation.\n\nThe stability of superpixel algorithms can be quantified by $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$ considering the behavior for increasing \\K.\nWe consider Figures \\ref{subfig:experiments-quantitative-bsds500-rec.min_min}, \\ref{subfig:experiments-quantitative-bsds500-ue_np.max_max}\nand \\ref{subfig:experiments-quantitative-bsds500-ev.min_min},\nshowing $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$ on the \\BSDS dataset. We define the stability of superpixel algorithms\nas follows: an algorithm is considered stable if performance monotonically increases with \\K\n(\\ie monotonically increasing \\Rec and \\EV and monotonically decreasing \\UE).\nFurthermore, these experiments can be interpreted as empirical bounds on the performance.\nFor example algorithms such as \\ETPSr, \\ERGCr, \\ERSr, \\CRSr and \\SLICr can be considered stable and provide good bounds.\nIn contrast, algorithms such as \\EAMSr, \\FHr, \\VCr or \\POISEr are punished by\nconsidering $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$ and cannot be described as stable.\nEspecially oversegmentation algorithms show poor stability. Most strikingly,\n\\EAMS seems to perform especially poorly on at least one image from the \\BSDS dataset.\nOverall, we find that $\\min\\Rec$, $\\max\\UE$ and $\\min\\EV$ appropriately reflect\nthe stability of superpixel algorithms.\n\nThe minimum/maximum of \\Rec, \\UE and \\EV captures lower/upper bounds on performance.\nIn contrast, the corresponding standard deviation can be thought of as the expected\ndeviation from the average performance.\nWe consider Figures \\ref{subfig:appendix-experiments-bsds500-rec.std[0]},\n\\ref{subfig:appendix-experiments-bsds500-ue_np.std[0]} and \\ref{subfig:appendix-experiments-bsds500-ev.std[0]}\nshowing the standard deviation of \\Rec, \\UE and \\EV on the \\BSDS dataset.\nWe can observe that in many cases good performing algorithms such as \\ETPS, \\CRS, \\SLIC or \\ERS\nalso demonstrate low standard deviation. Oversegmentation algorithms, on the other hand, show higher standard deviation\n-- together with algorithms such as \\PF, \\TPS, \\VC, \\CIS and \\SEAW.\nIn this sense, stable algorithms can also be identified by low and monotonically decreasing standard deviation.\n\nThe variation in the number of generated superpixels is an important aspect\nfor many superpixel algorithms. In particular, high standard deviation in the number of generated superpixels can be related to\npoor performance regarding \\Rec, \\UE and \\EV. We find that superpixel algorithms ensuring that\nthe desired number of superpixels is met within appropriate bounds are preferrable. We consider\nFigures \\ref{subfig:experiments-quantitative-bsds500-sp.max[0]} and \\ref{subfig:experiments-quantitative-bsds500-sp.std[0]},\nshowing $\\max\\K$ and $\\text{std }\\K$ for $\\K \\approx 400$ on the \\BSDS dataset. Even after enforcing connectivity\nas described in Section \\ref{subsec:parameter-optimization-connectivity}, we observe\nthat several implementations are not always able to meet the desired number of superpixels\nwithin acceptable bounds. Among these algorithms are \\QSr, \\VCr, \\FHr, \\CISr and \\LSCr.\nExcept for the latter case, this can be related to poor performance with respect\nto \\Rec, \\UE and~\\EV. Conversely, considering algorithms such as \\ETPSr, \\ERGCr or \\ERSr\nwhich guarantee that the desired number of superpixels is met exactly, this can be\nrelated to good performance regarding these metrics. To draw similar conclusions\nfor algorithms utilizing depth information, \\ie \\DASP and \\VCCS,\nthe reader is encouraged to consider\nFigures \\ref{subfig:experiments-quantitative-nyuv2-sp.max[0]} and \\ref{subfig:experiments-quantitative-nyuv2-sp.std[0]},\nshowing $\\max\\K$ and $\\text{std }\\K$ for $\\K\\approx 400$ on the \\NYU dataset.\nWe can conclude that superpixel algorithms with low standard deviation in the number\nof generated superpixels are showing better performance in many cases.\n\nFinally, we discuss the proposed metrics \\ARec, \\AUE and \\AEV (computed as the area\nbelow the $\\MR = (1 - \\Rec)$, \\UE and $\\UEV = (1 - \\EV)$ curves within the interval $[\\K_{\\min}, \\K_{\\max}] = [200,5200]$, \\ie lower is better).\nWe find that these metrics appropriately reflect and summarize the performance of superpixel\nalgorithms independent of \\K. As can be seen in Figure \\ref{subfig:experiments-quantitative-bsds500-average},\nshowing \\ref{plot:experiments-quantitative-bsds500-average-rec} \\ARec, \\ref{plot:experiments-quantitative-bsds500-average-ue_np}\n\\AUE and \\ref{plot:experiments-quantitative-bsds500-average-ev} \\AEV on the \\BSDS dataset, most of the\nprevious observations can be confirmed. For example, we exemplarily consider \\SEEDSr\nand observe low \\ARec and \\AEV which is confirmed by\nFigures \\ref{subfig:experiments-quantitative-bsds500-rec.mean_min} and \\ref{subfig:experiments-quantitative-bsds500-ev.mean_min},\nshowing \\Rec and \\EV on the \\BSDS dataset, where \\SEEDSr consistently outperforms all algorithms except for \\ETPSr.\nHowever, we can also observe higher \\AUE compared to algorithms such as\n\\ETPSr, \\ERSr or \\CRSr wich is also consistent with Figure \\ref{subfig:experiments-quantitative-bsds500-ue_np.mean_max},\nshowing \\UE on the \\BSDS dataset. We conclude, that \\ARec, \\AUE and \\AEV give an easy-to-understand summary of algorithm performance.\nFurthermore, \\ARec, \\AUE and \\AEV can be used to rank the different\nalgorithms according to the corresponding metrics; we will follow up on this idea in Section \\ref{subsec:experiments-ranking}.\n\nThe observed \\ARec, \\AUE and \\AEV also properly reflect the difficulty of the different datasets. We\nconsider Figure \\ref{fig:experiments-quantitative-avg} showing \\ref{plot:experiments-quantitative-bsds500-average-rec} \\ARec,\n\\ref{plot:experiments-quantitative-bsds500-average-ue_np} \\AUE and \\ref{plot:experiments-quantitative-bsds500-average-ev}  \\AEV for all five datasets.\nConcentrating on \\SEEDS and \\ETPS, we see that the relative\nperformance (\\ie the performance of \\SEEDS compared to \\ETPS) is consistent across\ndatasets; \\SEEDS usually showing higher \\AUE while \\ARec and \\AEV are usually similar.\nTherefore, we observe that these metrics can be used to characterize\nthe difficulty and ground truth of the datasets. For example, considering\nthe \\Fash dataset, we observe very high \\AEV compared\nto the other datasets, while \\ARec and \\AUE are usually very low. This can be\nexplained by the ground truth shown in Figure~\\ref{subfig:datasets-fash},\n\\ie the ground truth is limited to the foreground (in the case of Figure \\ref{subfig:datasets-fash}, the woman),\nleaving even complicated background unannotated. Similar arguments can be developed\nfor the consistently lower \\ARec, \\AUE and \\AEV for the \\NYU and \\SUNRGBD datasets compared to the \\BSDS dataset.\nFor the \\SBD dataset, lower \\ARec, \\AUE and \\AEV can also be explained by the smaller average image size.\n\nIn conclusion, \\ARec, \\AUE and \\AEV accurately reflect the performance of superpixel\nalgorithms and can be used to judge datasets. Across the different datasets, path-based\nand density-based algorithms perform poorly, while the remaining classes show mixed\nperformance. However, some iterative energy optimization, clustering-based and\ngraph-based algorithms such as \\ETPS, \\SEEDS, \\CRS, \\ERS and \\SLIC show favorable performance.\n\n\\begin{figure*}\n\t\\centering\n\t\\input{plots/quantitative-bsds500-avg}\\\\\n\t\\input{plots/quantitative-nyuv2-avg}\\\\\n\t\\input{plots/quantitative-sbd-avg}\\\\\n\t\\input{plots/quantitative-sunrgbd-avg}\\\\\n\t\\input{plots/quantitative-fash-avg}\n\t\\caption{\\ARec, \\AUE and \\AEV (lower is better) on the used datasets.\n    We find that \\ARec, \\AUE and \\AEV appropriately\n    summarize performance independent of the number of generated superpixels. Plausible\n    examples to consider are top-performing algorithms such as \\ETPS, \\ERS, \\SLIC or \\CRS\n    as well as poorly performing ones such as \\QS and~\\PF.\n\t\\textbf{Best viewed in color.}}\n\t\\label{fig:experiments-quantitative-avg}\n\\end{figure*}\n\n\\subsubsection{Depth}\n\nDepth information does not necessarily improve performance regarding \\Rec, \\UE and \\EV.\nWe consider Figures \\ref{subfig:experiments-quantitative-nyuv2-rec.mean[0]},\n\\ref{subfig:experiments-quantitative-nyuv2-ue_np.mean[0]} and \\ref{subfig:experiments-quantitative-nyuv2-ev.mean[0]}\npresenting \\Rec, \\UE and \\EV on the \\NYU dataset. In particular, we consider \\DASPr and \\VCCSr.\nWe observe, that \\DASPr consistently outperforms \\VCCSr.\nTherefore, we consider the performance of \\DASPr and investigate whether depth information\nimproves performance. Note that \\DASPr performs similar to \\SLICr, exhibiting slightly\nworse \\Rec and slightly better \\UE and \\EV for large \\K. However, \\DASPr does not\nclearly outperform \\SLICr. As indicated in Section \\ref{sec:algorithms}, \\DASP and \\SLIC are\nboth clustering-based algorithms. In particular, both algorithms are based on $k$-means\nusing color and spatial information and \\DASPr additionally utilizes depth information.\nThis suggests that the clustering approach\ndoes not benefit from depth information. We note that a similar line of thought can be\napplied to \\VCCS except that \\VCCS directly operates within a point cloud, rendering the\ncomparison problematic. Still we conclude that depth information used in the form of\n\\DASP does not improve performance. This might be in contrast to\nexperiments with different superpixel algorithms, \\eg a \\SLIC variant using depth information\nas in \\cite{ZhangKanSchwingUrtasun:2013}. We suspect that regarding the used metrics, the number of superpixels ($\\K = 200$)\nand the used superpixel algorithm, the effect of depth information might be more pronounced \nin the experiments presented in \\cite{ZhangKanSchwingUrtasun:2013} compared to ours.\nFurthermore, it should be noted that our evaluation is carried out in the 2D image plane, \nwhich does not directly reflect the segmentation of point clouds.\n%We further note that evaluation is carried out in the 2D image plane only.\n", "meta": {"hexsha": "7d5316eca8b747552e9adf69555873616b071942", "size": 15056, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/experiments/quantitative.tex", "max_stars_repo_name": "davidstutz/cviu2018-superpixels", "max_stars_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/experiments/quantitative.tex", "max_issues_repo_name": "davidstutz/cviu2018-superpixels", "max_issues_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/experiments/quantitative.tex", "max_forks_repo_name": "davidstutz/cviu2018-superpixels", "max_forks_repo_head_hexsha": "83e0db95cff91fee26ea04d5ecdb221d441e940b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.0873786408, "max_line_length": 159, "alphanum_fraction": 0.7877258236, "num_tokens": 3913, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.40810475883976843}}
{"text": "\\section{Selection Method}\nTournament selection \\cite{miller1995genetic} was used as the selection method for all genetic operators. This entails selecting \\emph{T} individuals entirely at random from the existing population. Then, from this set of individuals (ie. the \\emph{tournament}) the fittest individual is selected. After some initial test runs the size, \\emph{T}, of the tournament used was 16. On average, this tournament size produced the best balance between genetic diversity and convergence. In the cases where genetic operators required more than one individual from the existing population, the tournament selection method was simply reapplied to select each individual.", "meta": {"hexsha": "2fcc89953dbb7599c308a960c07499cba6e61ed2", "size": 687, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/report/04_selection_method/selection_method.tex", "max_stars_repo_name": "marcus-bornman/cos_790_assignment_3", "max_stars_repo_head_hexsha": "662fb0a2ec1b442ac702f195584aa9b913eae7c6", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/report/04_selection_method/selection_method.tex", "max_issues_repo_name": "marcus-bornman/cos_790_assignment_3", "max_issues_repo_head_hexsha": "662fb0a2ec1b442ac702f195584aa9b913eae7c6", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/report/04_selection_method/selection_method.tex", "max_forks_repo_name": "marcus-bornman/cos_790_assignment_3", "max_forks_repo_head_hexsha": "662fb0a2ec1b442ac702f195584aa9b913eae7c6", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 343.5, "max_line_length": 660, "alphanum_fraction": 0.8209606987, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4081047587520756}}
{"text": "\\chapter{Simple Machines}\n\\label{chap:compound}\n\nIn this chapter, we build and verify simple machines using the primitive machines from Chapter~\\ref{chap:basic}, the operators developed in\nChapter~\\ref{chap:combining}, and the tapes-lift from Chapter~\\ref{chap:lifting}.  The machines in this chapter will be useful in the next chapter.\nWe do not use the alphabet-lift yet.  First we show how we prove correctness and termination of machines from now on.\n\nWhen we prove $M \\Realise R$ for a machine $M$ and its correctness relation $R$, we first find a relation $R'$ that $M$ realises.  We derive this\nrelation by applying the correctness lemmas of the control-flow operators, lifts, and concrete machines.  This process is mechanical and does in\ngeneral not depend on arbitrary choices (with a few exceptions).  The derived relation respects the ``structure'' of the machine.  For example, the\nrelation of a sequential composition is the relational composition of two relations.  Using the monotonicity Lemma~\\ref{lem:Realise_monotone}, it\nremains to show $R' \\subseteq R$.  Because the structure of $R'$ respects the structure of $M$, the proof of the inclusion also follows its structure.\nFor example, the relation for a conditional is $(R_1 \\at \\true \\circ R_2) \\cup (R_1 \\at \\false \\circ R_3)$.  From that it follows that we do a\ncase-distinction for both branches in the proof.  Note that we do not have to reason about machine states at all, because the correctness relations\nare only relations between tapes and labels.\n\n% So the main part of the proof is showing the inclusion.  The ``canonical relation'' of Section~\\ref{sec:canonical} is for that reason not suited for\n% the choice of $R'$.\n\nWhen $M$ always terminates in constant time $k$, we show $M \\RealiseIn{k} R$ instead.  Using the monotonicity Lemma~\\ref{lem:RealiseIn_monotone}, we\ncan prove correctness and constant time at once.  For non-constant running time, we show $M \\TerminatesIn T$ for a running time relation~$T$.  For\nthat, we use the dual approach and apply the anti-monotonicity Lemma~\\ref{lem:TerminatesIn_monotone}.\n\n\n\\section{$\\Nop$}\n\\label{sec:Nop}\n\\setCoqFilename{ProgrammingTuringMachines.TM.Compound.Multi}%\n\n\nUsing the tapes-lift (Definition~\\ref{def:LiftTapes}) and $\\MS{Null}$ (Definition~\\ref{def:Null}), it is easy to define an $n$-tape machine\n$\\Nop : \\TM_\\Sigma^n$ that does nothing.  Asperti and Ricciotti~\\cite{asperti2015} define this machine directly:\n\\begin{definition}[$\\Nop$][Nop]\n  $\\Nop \\defop \\LiftTapes{\\MS{Null}}{\\nil}$.\n\\end{definition}\nNote that because $\\MS{Null}$ is a 0-tape machine, and $\\Nop$ is supposed to be an $n$-tape machine, the index-vector must be the vector\n$\\nil : \\Fin_n^0$.\n\n\\begin{lemma}[Correctness of $\\Nop$][Nop_Sem]\n  \\label{lem:Nop_Sem}\n  $\\Nop \\RealiseIn0 NopRel$ with $NopRel := \\lambda t~t'.~t'=t$.\n\\end{lemma}\n\\begin{proof}\n  We apply the monotonicity Lemma~\\ref{lem:RealiseIn_monotone} of $\\RealiseIn\\cdot$, the correctness Lemma~\\ref{lem:Null_Sem} of $\\MS{Null}$, and the\n  correctness Lemma~\\ref{lem:LiftTapes_Realise} of the tapes-lift.  It remains to show:\n  \\[\n    \\left( \\lambda t~t'.~ NullRel~t~t' \\land \\left(\\forall i:\\Fin_n.~i \\notin \\nil \\rightarrow t'[i] = t[i] \\right)\\right)\n    \\subseteq NopRel\n  \\]\n  Let $t,t' : \\Tape_\\Sigma^n$.  To show the equality $t'=t$ we show $t'[i]=t[i]$ for all $i:\\Fin_n$.  This follows with the equality part of the\n  relation $\\LiftTapes{NullRel}{\\nil}$, since $i \\notin \\nil$.\n\\end{proof}\n\nNote that the correctness relation of $\\Nop$ can also be expressed using the identity relation $Id$:\n\\[\n  NopRel \\equiv Id.\n\\]\nWe have the convention to define relations of concrete machines in $\\lambda$-notation, i.e.\\ not using relational operators.  Also note that the tape\n$t'$ is, per convention, always on the left side of the equality.  These conventions make rewriting of tapes uniform; therefore, rewriting of tapes\ncan be automated in Coq.\n\n\\section{$\\MS{WriteString}$}\n\\label{sec:WriteString}\n\\setCoqFilename{ProgrammingTuringMachines.TM.Compound.WriteString}%\n\nThe machine $\\MS{WriteString}~d~str$ writes a fixed string $str:\\List(\\Sigma)$ in the direction $d$.  It is defined by recursion over the string:\n\\begin{definition}[$\\MS{WriteString}$][WriteString]\n  \\begin{alignat*}{3}\n    &\\MS{WriteString}~d~&&(\\nil)         &~:=~& \\Nop \\\\\n    &\\MS{WriteString}~d~&&(s \\cons \\nil) &~:=~& \\MS{Write}~s \\\\\n    &\\MS{WriteString}~d~&&(s \\cons str') &~:=~& \\MS{WriteMove}~s~d \\Seq \\MS{WriteString}~d~str'.\n  \\end{alignat*}\n\\end{definition}\n\nNote that this is our only machine we define per recursion.  The way we prove correctness in constant time (depending on the length of $str$) is still\nthe same.\n\nThe machine writes all symbols of the string $str$ to the tape and moves in the tape in direction $d$ after each (but the last) symbol.  When it\nterminates, the head of the tape is under the last written symbol, which is the last symbol of $str$.  It terminates in constant time, after\n$2\\cdot\\length{str}-1$ steps.\n\nThe derived relation for $\\MS{WriteString}$ is also defined per recursion over the string:\n\\begin{lemma}[][WriteString_fix_Sem]\n  $\\MS{WriteString}~d~str \\RealiseIn{2 \\cdot \\length{str} - 1} R'~d~str$ with\n  \\begin{alignat*}{3}\n    &\\MS{R'}~d~&&(\\nil        ) &~:=~& NopRel \\\\\n    &\\MS{R'}~d~&&(s \\cons \\nil) &~:=~& DoActRel(\\Some{s}, \\MS{N}) \\\\\n    &\\MS{R'}~d~&&(s \\cons str') &~:=~& DoActRel(\\Some{s}, d) \\circ \\MS{R'}~d~str'.\n  \\end{alignat*}\n\\end{lemma}\n\\begin{proof}\n  By induction on $str:\\List(\\Sigma)$, using the monotonicity Lemma~\\ref{lem:RealiseIn_monotone}, the correctness of $\\Nop$ (Lemma~\\ref{lem:Nop_Sem}),\n  the correctness of $\\MS{Write}$ and $\\MS{WriteMove}$ (which are defined using $\\MS{DoAct}$; Lemma~\\ref{lem:DoAct_Sem}), and correctness of\n  sequential composition for constant time (Lemma~\\ref{lem:Seq_RealiseIn}).\n\\end{proof}\n\nWe define the actual relation of $\\MS{WriteString}$ in terms of a function on tapes that is also defined by recursion over $str$:\n\\begin{lemma}[Correctness of $\\MS{WriteString}$][WriteString_Sem]\n  \\label{lem:WriteString_Sem}\n  Let $d:\\Move$ and $str:\\List(\\Sigma)$.\n  \\[ \\MS{WriteString}~d~str \\RealiseIn{2\\cdot\\length{str}-1} WriteStringRel~d~str \\]\n  with\n  $WriteStringRel~d~str := \\lambda t~t'.~t' = writeStringFun~d~t~str$ and\n  \\begin{alignat*}{3}\n    &writeStringFun~d~t~&&(\\nil        ) &~:=~& t \\\\\n    &writeStringFun~d~t~&&(s \\cons \\nil) &~:=~& \\MS{wr}~t~(\\Some{s}) \\\\\n    &writeStringFun~d~t~&&(s \\cons str') &~:=~& writeStringFun~d~\\bigl(\\MS{doAct}~t~(\\Some{s}, d)\\bigr)~str'\n  \\end{alignat*}\n\\end{lemma}\n\\begin{proof}\n  We apply the monotonicity Lemma~\\ref{lem:RealiseIn_monotone} and have to show:\n  \\[\n    R'~d~str \\subseteq WriteStringRel~d~str\n  \\]\n  This can be shown by induction on $str$.\n\\end{proof}\n\nNote that we could as well use the $\\MS{Mirror}$ operator instead of parametrising the machine $\\MS{WritingString}$ over the direction.  In this\nparticular example the parametrising approach seems to be easier.\n\n\\section{$\\MS{MovePar}$}\n\\label{sec:MovePar}\n\\setCoqFilename{ProgrammingTuringMachines.TM.Compound.Multi}%\n\nThe two-tape machine $\\MS{MovePar}~d_0~d_1$ combines two $\\MS{Move}$ machines.  It first moves the $0$th tape in direction $d_0$ and after that the\n$1$st tape in direction $d_1$.\\footnote{To avoid confusion with zero-based indices used throughout this thesis, we write ``the $0$th or $1$st tape'',\n  instead of ``the first or second tape.''}\n\\begin{definition}[$\\MS{MovePar}$][MovePar]\n  \\label{def:MovePar}\n  $\\MS{MovePar}~d_0~d_1 \\defop \\LiftTapes{(\\MS{Move}~d_0)}{\\Vector{0}} \\Seq \\LiftTapes{(\\MS{Move}~d_1)}{\\Vector{1}}$.\n\\end{definition}\n\\begin{lemma}[Correctness of $\\MS{MovePar}$][MovePar_Sem]\n  \\label{lem:MovePar_Sem}\n  $\\MS{MovePar}~d_0~d_1 \\RealiseIn3 MoveParRel~d_0~d_1$ with\n  \\[\n    MoveParRel~d_0~d_1 := \\lambda t~t'.~t'[0]=\\MS{mv}~d_0~t[0] ~\\land~ t'[1]=\\MS{mv}~d_1~t[1]\n  \\]\n\\end{lemma}\n\\begin{proof}\n  We have to show:\n  \\[\n    \\LiftTapes{(DoActRel(\\None,d_0))}{\\Vector{0}} \\circ\n    \\LiftTapes{(DoActRel(\\None,d_1))}{\\Vector{1}} \\subseteq\n    MovePairRel~d_0~d_1\n  \\]\n  We assume tape vectors $t, t', t'' : \\Tape_\\Sigma^2$, such that $(\\LiftTapes{(DoActRel(\\None,d_0))}{\\Vector{0}})~t~t'$ and \\\\\n  $(\\LiftTapes{(DoActRel(\\None,d_1))}{\\Vector{1}})~t'~t''$.  We have to show $t''[0]=\\MS{mv}~d_0~t[0]$ and $t''[1]=\\MS{mv}~d_1~t[1]$.  By definition,\n  we know $t'[0]=\\MS{mv}~d_0~t[0]$ and $t'[1]=t[1]$ (because $1 \\notin \\Vector{0}$).  We also know $t''[1]=\\MS{mv}~d_1~t'[1]$ and $t''[0]=t'[0]$\n  (because $0 \\notin \\Vector{1}$).  The goal follows trivially.\n\\end{proof}\nNote that this kind of proof is very mechanical: We only need to unfold the relations and rewrite tapes.  Indeed, these steps are automated in Coq.\nThus, we also do not present more proofs of this kind on paper.\n\n\\section{$\\MS{CopySymbols}$}\n\\label{sec:CopySymbols}\n\\setCoqFilename{ProgrammingTuringMachines.TM.Compound.CopySymbols}%\n\nThe machine $\\MS{CopySymbols}~h : \\TM_\\Sigma^2$, where $h:\\Sigma\\to\\Bool$, is a compound machine involving a $\\While$-loop.  It reads a symbol on tape\n$0$, writes it to tape $1$, and moves both tapes to right, until the read symbol satisfies $h$.  If there was no current symbol on tape $0$, it also\nterminates.\n\nWe first define the machine for the step.  Since we want to apply the $\\While$ operator on the step machine, it must be labelled over\n$\\Option(\\Unit)$.  $\\Some\\unit$ means to break out of the loop and $\\None$ means to repeat the loop.\n\\begin{definition}[$\\MS{CopySymbolsStep}$][CopySymbols_Step]\n  \\label{CopySymbols_Step}\n\\begin{lstlisting}[style=semicoqstyle]\n$\\MS{CopySymbolsStep}~h :=$\n  Switch$(\\LiftTapes{\\MS{Read}}{\\Vector{0}})$\n       $(\\lambda (s:\\Option(\\Sigma)).$\n          $\\MS{match}~s$\n          [$\\Some{x}$=>\n            $\\MS{if}~h(x)$\n            $\\pthen$ $\\Return{\\bigl(\\LiftTapes{(\\MS{Write}~x)}{\\Vector{1}}\\bigr)}{\\Some\\unit}$ \n            $\\pelse$ $\\Return{\\bigl(\\LiftTapes{(\\MS{Write}~x)}{\\Vector{1}} \\Seq \\MS{MovePar}~\\MS{R}~\\MS{R}\\bigr)}{\\None}$ \n          |$\\None$ => $\\Return{\\Nop}{\\Some\\unit}$ \n          ])\n\\end{lstlisting}\n\\end{definition}\n\nNote that ``$\\MS{match}~[~\\cdots~]$'' denotes pattern matching our type theory.\n\n\\begin{lemma}[Correctness of $\\MS{CopySymbolsStep}$][CopySymbols_Step_Sem]\n  \\label{lem:CopySymbols_Step_Sem}\n  ~\n  \\[\n    \\MS{CopySymbolsStep} \\RealiseIn{7} CopySymbolsStepRel\n  \\]\n  with\n  \\small\n  \\begin{align*}\n    &CopySymbolsStepRel := \\lambda t~(l, t').~\\\\\n    &\\quad\\begin{cases}\n      t'[0] = t[0]           \\land t'[1]=\\MS{wr}~t[1]~\\Some{x}              \\land l=\\Some\\unit & \\MS{current}~t[0]=\\Some{x} \\land       h(x) \\\\\n      t'[0] = \\MS{mv}~\\MS{R}~t[0] \\land t'[1]=\\MS{doAct}~t[1]~(\\Some{x}, \\MS{R}) \\land l=\\None & \\MS{current}~t[0]=\\Some{x} \\land \\lnot h(x) \\\\\n      t' = t \\land l=\\Some\\unit                                                                & \\text{else}\n    \\end{cases}\n  \\end{align*}\n\\end{lemma}\n\\begin{proof}\n  Mechanical, with case-analysis over $\\MS{current}~t[0]$.\n\\end{proof}\n\nWe define $\\MS{CopySymbol}$ by applying the $\\While$ operator to $\\MS{CopySymbolsStep}$:\n\\begin{definition}[$\\MS{CopySymbols}$][CopySymbols]\n  \\label{def:CopySymbols}\n  $\\MS{CopySymbols}~h := \\While(\\MS{CopySymbolsStep}~h)$.\n\\end{definition}\n\nThe correctness of $\\MS{CopySymbols}$ can be expressed using a recursive function on tapes:\n\\begin{lemma}[Correctness of $\\MS{CopySymbols}$][CopySymbols_Realise]\n  \\label{lem:CopySymbols_Realise}\n  $\\MS{CopySymbols}~h \\Realise CopySymbolsRel~h$\n  with $CopySymbolsRel~h := \\lambda t~t'.~t' = copySymbolsFun~h~t$ and\n  {\n    \\small\n    \\begin{align*}\n      &copySymbolsFun~h~t :=\\\\\n      &\\quad\\begin{cases}\n        \\Vector{t[0];~ \\MS{wr}~t[1]~\\Some{x}}                                         & \\MS{current}~t[0]=\\Some{x} \\land h(x) \\\\\n        copySymbolsFun~h~\\Vector{\\MS{mv}~R~t[0];~ \\MS{doAct}~t[1]~(\\Some{x}, \\MS{R})} & \\MS{current}~t[0]=\\Some{x} \\land \\lnot h(x) \\\\\n        t                                                                             & \\MS{current}~t[0]=\\None\n      \\end{cases}\n    \\end{align*}\n  }\n  Note that the function $copySymbolsFun$ is not structural recursive.  It terminates because tapes have only finitely many symbols.\n\\end{lemma}\n\\begin{proof}\n  To show: $WhileRel~CopySymbolsStepRel \\subseteq CopySymbolsRel$.  By $\\While$-induction (Lemma~\\ref{lem:WhileInduction}).\n\\end{proof}\n\nWe observe that the running time of $\\MS{CopySymbols}$ only depends on the $0$th tape.  Therefore, we define a function\n$copySymbolsSteps : \\Tape_\\Sigma \\to \\Nat$ that overestimates the number of steps needed for the loop, depending on the $0$th tape.  Note that\n$\\While$ requires one additional step for each repeat of the loop.\n\\begin{lemma}[Running time of $\\MS{CopySymbols}$][CopySymbols_Terminates]\n  $\\MS{CopySymbols} \\TerminatesIn CopySymbolsT$ with \\\\\n  $CopySymbolsT := \\lambda t~k.~copySymbolsSteps(t) \\leq k$ and\n  \\begin{align*}\n    &copySymbolsSteps (t) := \\\\\n    &\\quad\\begin{cases}\n      8 + copySymbolsSteps(\\MS{mv}~\\MS{R}~t) & \\MS{current}~t=\\Some{x} \\land \\lnot h(x) \\\\\n      8                                      & \\text{otherwise}\n    \\end{cases}\n  \\end{align*}\n\\end{lemma}\n\\begin{proof}\n  We have to show $CopySymbolsT \\subseteq WhileT~CopySymbolsStepRel~(\\lambda \\_~k.~7 \\leq k)$, using the co-induction\n  Lemma~\\ref{lem:WhileCoInduction}.  Let $copySymbolsSteps~t[0] \\leq k$.  We choose $k_1 := 7$.  We have two cases.\n  \\begin{enumerate}\n  \\item We assume $CopySymbolsStepRel~t~(\\Some\\unit, t')$.  Therefore, we know that either $\\MS{current}~t[0]=\\Some{x}$ with $h(x)=\\true$, or\n    $\\MS{current}~t[0]=\\None$.  In both cases, we have $copySymbolsSteps~t[0] = 8$.  Thus, we have:\n    $$k_1 \\leq copySymbolsSteps~t[0] = 8 \\leq k$$\n  \\item We assume $CopySymbolsStepRel~t~(\\None, t')$.  Therefore, we have $\\MS{current}~t[0]=\\Some{x}$ with $h(x)=\\false$, and\n    $t'[0]=\\MS{mv}~\\MS{R}~t[0]$.  Then, we have:\n    % \\[ ... \\] doesn't work here. $$ ... $$ doesn't place \\qed at the right spot.\n    \\begin{equation*}\n      1+k_1+copySymbolsSteps~t'[0] = copySymbolsSteps~t[0] \\leq k\n    \\end{equation*}\n  \\end{enumerate}\n\\end{proof}\n% Note that we see in the proof that we could replace the $8$s in the non-recursive parts of the running time functions with $7$s.\n\nUsing the $\\MS{Mirror}$ operator, we can define a machine $\\MS{CopySymbolsL}$ that copies and goes to the left instead.  We also have to ``mirror''\nthe correctness relations and their respective functions.  We do not repeat the definitions here.\n\\begin{definition}[$\\MS{CopySymbolsL}$][CopySymbols_L]\n  $\\MS{CopySymbolsL}~h := \\MS{Mirror}(\\MS{CopySymbols}~h).$\n\\end{definition}\n\n\\section{$\\MS{MoveToSymbol}$}\n\\label{sec:MoveToSymbol}\n\\setCoqFilename{ProgrammingTuringMachines.TM.Compound.MoveToSymbol}%\n\n\\enlargethispage{0.5cm}\n\nWe can define a machine $\\MS{MoveToSymbol}~h~f : \\TM_\\Sigma^1$, where $h:\\Sigma\\to\\Bool$ and $f:\\Sigma\\to\\Sigma$.  This machine behaves similar as\n$\\MS{CopySymbols}~h$.  Instead of copying the symbols from one tape to another tape, it ``translates'' the symbols it reads, until it reads a symbol\nthat satisfies the boolean predicate $h$.  We leave out the correctness and running time statements, as they can be derived from the statements about\n$\\MS{CopySymbols}$ above.\n\n\\begin{definition}[$\\MS{MoveToSymbol}$][MoveToSymbol]\n  ~\n\\begin{lstlisting}[style=semicoqstyle]\n$\\MS{MoveToSymbolStep}~h~f :=$\n  Switch$(\\MS{Read})$\n       $(\\lambda (s:\\Option(\\Sigma)).~\\MS{match}~s$\n          [$\\Some{x}$=> \n            if $h(x)$\n            $\\pthen$ $\\Return{\\bigl(\\MS{Write}~(f~x)       \\bigr)}{\\Some\\unit}$ \n            $\\pelse$ $\\Return{\\bigl(\\MS{WriteMove}~(f~x)~R \\bigr)}{\\None}$ \n          |$\\None$ => $\\Return{\\Nop}{\\Some\\unit}$ \n          ])\n\\end{lstlisting}\n  \\begin{align*}\n    \\MS{MoveToSymbol }~h~f &:= \\While(\\MS{MoveToSymbolStep}~h~f) \\\\\n    \\MS{MoveToSymbolL}~h~f &:= \\MS{Mirror}(\\MS{MoveToSymbol}~h~f)\n  \\end{align*}\n\\end{definition}\n\n\n\n%%% Local Variables:\n%%% TeX-master: \"thesis\"\n%%% End:", "meta": {"hexsha": "7c2155d86f03ce3b17df96564429793cc92f61c2", "size": 15968, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/thesis/Compound.tex", "max_stars_repo_name": "mwuttke97/CoqTM", "max_stars_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-08-30T14:58:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-27T15:44:28.000Z", "max_issues_repo_path": "tex/thesis/Compound.tex", "max_issues_repo_name": "mwuttke97/CoqTM", "max_issues_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-10T09:16:49.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-10T09:16:49.000Z", "max_forks_repo_path": "tex/thesis/Compound.tex", "max_forks_repo_name": "mwuttke97/CoqTM", "max_forks_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-04-09T19:01:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T15:39:53.000Z", "avg_line_length": 53.049833887, "max_line_length": 150, "alphanum_fraction": 0.6699023046, "num_tokens": 5332, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4081047587520756}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsection{Polarization of synchrotron radiation}\n\n\\marginpar{Saturday\\\\ 2020-8-29, \\\\ compiled \\\\ \\today}\n\nMeasuring polarization is in general difficult, but still it is important to be able to provide an estimate of how much radiation is actually polarized. \n\nIn order to describe synchrotron radiation we will need some reference unit vectors. Let us define \\(\\vec{\\epsilon}_{\\perp}\\) and \\(\\vec{\\epsilon}_{\\parallel}\\) such that, given the observation direction \\(\\vec{n}\\) and the magnetic field \\(\\vec{B}\\), \\(\\vec{\\epsilon}_\\perp\\) is perpendicular to both, while \\(\\vec{\\epsilon}_\\parallel\\) is perpendicular to \\(\\vec{n}\\) only, while being in the plane defined by \\(\\vec{n}\\) and \\(\\vec{B}\\). \n\nThese two unit vectors define a basis for the radiation seen in the direction \\(\\vec{n}\\), since as we recall the polarization of electromagnetic radiation is always transverse. \n\nIt can be shown that the power spectrum emitted in each polarization is given by \n%\n\\begin{align}\n\\eval{\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\omega }}}_{\\perp} &= \\frac{\\sqrt{3} q^3 B \\sin \\alpha }{4 \\pi m c^2} \\qty(F + G) \\\\\n\\eval{\\frac{ \\dd{w}}{ \\dd{t} \\dd{\\omega }}}_{\\parallel} &= \\frac{\\sqrt{3} q^3 B \\sin \\alpha }{4 \\pi m c^2} \\qty(F - G)\n\\,,\n\\end{align}\n%\nwhere \\(F\\) is the function of \\(\\omega / \\omega _c\\) we defined earlier, \n%\n\\begin{align}\nF \\qty(\\frac{\\omega }{\\omega _c}) = \\frac{\\omega}{\\omega _c} \\int_{\\omega / \\omega _c}^{\\infty } K_{5/3} (z) \\dd{z} \n\\,,\n\\end{align}\n%\nwhile the new function \\(G\\) is defined by \n%\n\\begin{align}\nG \\qty(\\frac{\\omega }{\\omega _c}) = \\frac{\\omega}{\\omega _c} K_{2/3} \\qty( \\frac{\\omega}{\\omega _c})\n\\,.\n\\end{align}\n\nThe total emitted power per unit frequency is given by the sum of the two contributions in each polarization; so the terms containing \\(G\\) simplify, and we are left with the \\(F\\) term only, the result we found earlier. \n\nThe polarization fraction at each frequency for a single electron will be given by \n%\n\\begin{align}\n\\Pi (\\omega ) \n= \\frac{P_\\perp (\\omega ) - P_\\parallel (\\omega )}{P_\\perp (\\omega ) + P_\\parallel (\\omega )}\n= \\frac{G( \\omega / \\omega _c) }{F(\\omega / \\omega _c)}\n\\,,\n\\end{align}\n%\nwhile the polarization fraction for a whole family of electrons whose energies are distributed according to a powerlaw will be given by the ratio of the integrals of \\(G\\) and \\(F\\) weighted by the electron distributions:  \n%\n\\begin{align}\n\\Pi &= \\frac{\\int_0^{\\infty } G (\\omega / \\omega _c) \\gamma^{-P} \\dd{\\gamma }}{\\int_0^{\\infty } F(\\omega  / \\omega _c) \\gamma^{-P} \\dd{\\gamma }}  \\\\\n&= \\frac{\\int_0^{\\infty } G (x) \\gamma^{-P} \\dd{\\gamma }}{\\int_0^{\\infty } F(x) \\gamma^{-P} \\dd{\\gamma }}\n\\,,\n\\end{align}\n%\nwhere we must be careful, since \\(x\\) is a function of \\(\\gamma \\) in the integral. Specifically, \\(x = \\omega / \\omega _c \\sim 1/ \\gamma^2\\), so \\(\\gamma \\sim x^{-1/2}\\), therefore \\(\\dd{\\gamma } \\propto -1/2 x^{-3/2} \\dd{x}\\). This yields, up to multiplicative factors which cancel out in the ratio: \n%\n\\begin{align}\n\\Pi = \\frac{\\int_0^{\\infty } G(x) x^{(P-3) / 2} \\dd{x}}{\\int_0^{\\infty } F(x) x^{(P-3) / 2} \\dd{x}}\n\\,.\n\\end{align}\n\nThese integrals of special functions are evaluated in the literature, we have general explicit expressions for expressions like \\(\\int x^{\\mu } F(x) \\dd{x}\\) and similarly for \\(G\\).\n\nSubstituting these in, we find \n%\n\\begin{align}\n\\Pi = \\frac{1 + P}{P + 7/3}\n\\,.\n\\end{align}\n\nThis is always \\(<1\\) as it should be, however with very steep powerlaws (high \\(P\\)) we can reach values of \\(\\Pi \\) which are arbitrarily close to 1.\n\nIf, on the other hand, we are only considering one electron, we can compute the \\emph{frequency-integrated} polarization fraction \n%\n\\begin{align}\n\\Pi \n= \\frac{\\int_0^{\\infty } G(x) \\dd{\\omega }}{\\int_0^{\\infty } F(x) \\dd{\\omega }}\n= \\frac{\\int_0^{\\infty } G(x) \\dd{x}}{\\int_0^{\\infty } F(x) \\dd{x }}\n\\,,\n\\end{align}\n%\nwhich coincides with the polarization fraction from a population of electrons if we take \\(P = 3\\). Therefore, we find \\(\\Pi = (1+3) / (3 + 7/3) = 3/4\\). \n\n\\section{Einstein coefficients}\n\nIn order to understand what the absorption from synchrotron radiation looks like we need to take a step back and consider the Einstein coefficients. \n\nLet us reconsider Kirkhoff's law: if emitters and absorbers are in thermal equilibrium, then the following relation holds: \n%\n\\begin{align}\nj_\\nu = \\alpha _\\nu B_\\nu \n\\,.\n\\end{align}\n\nThis law holds at the macroscopic level: however, the process giving rise to it have a microscopic origin, so we should be able to give a microscopic version of this law. \n\nLet us consider an atom with two energy levels, at \\(E\\) and \\(E + h \\nu_0\\) respectively. \nIn the population these will have a different statistical weight: let us call these weights \\(g_1 \\) and \\(g_2 \\). \n\nEinstein identified the three main processes which can occur when such an atom interacts with radiation: \n\\begin{enumerate}\n    \\item spontaneous emission, where the system starts off in the higher energy level and decays to the lower one, emitting a photon of energy \\(h \\nu_0 \\). This can happen regardless of the presence of an external radiation field. \n    The Einstein \\(A\\) coefficient describes this: \\(A_{21} \\) is the transition probability per unit time connected to this process. \n    \\item Absorption, where the atom starts off in the lower energy state and absorbs a photon of energy \\(h \\nu_0 \\), going to the higher energy level.\n    It should be stressed that the absorption is not actually monochromatic; because of several effects it is described by a distribution \\(\\phi (\\nu )\\) which is sharply peaked around \\(\\nu_0\\), and which is normalized so that \\(\\int \\phi (\\nu ) \\dd{\\nu } = 1\\). \n    Then, the absorption probability per unit time is given by \n    %\n    \\begin{align}\n    B_{12} \\int_0^{\\infty } J_\\nu \\phi (\\nu ) \\dd{\\nu }\n    \\,,\n    \\end{align}\n    %\n    where \\(J_\\nu \\) is the mean intensity of the external radiation field. \n    \\item Stimulated emission, which is a consequence of the quantum nature of light. Planck's law only holds if this is included. This corresponds to the fact that the emission probability is enhanced by the presence of a radiation field. This is similar to how absorption occurs, in that the transition probability per unit time is \n    %\n    \\begin{align}\n    B_{21} \\int_0^{\\infty } J_\\nu \\phi (\\nu ) \\dd{\\nu }\n    \\,.\n    \\end{align}    \n\\end{enumerate}\n\nLet us consider a system of many two-level atoms, whose number density is \\(n\\). Some of them will be in level 1 and some will be in level 2; let us call the corresponding number densities \\(n_1 \\) and \\(n_2 \\).\n\nIf we are in thermodynamic equilibrium, then the transition rate from 1 to 2 must equal that from 2 to 1. This can be written as \n%\n\\begin{align}\n\\underbrace{n_1 B_{12} \\overline{J}}_{\\text{absorption}} &= \\underbrace{n_2 A_{21}}_{\\text{emission}} + \\underbrace{n_2 B_{21} \\overline{J}}_{\\text{stimulated emission}}  \\\\\n\\overline{J} &= \\int_0^{\\infty } J_\\nu \\phi (\\nu ) \\dd{\\nu }\n\\,.\n\\end{align}\n\nWe can solve this equation for \\(\\overline{J}\\): it comes out to be \n%\n\\begin{align}\n\\overline{J} = \\frac{A_{21} / B_{21} }{ (n_1 / n_2 ) (B_{12} / B_{21} ) - 1}\n\\,.\n\\end{align}\n\nSince we know that the system is in thermodynamic equilibrium, we can also write that the ratio of the number densities of the two populations will be \n%\n\\begin{align}\n\\frac{n_1}{n_2 } = \\frac{g_1  \\exp( - E / k_B T)}{g_2 \\exp(- E / k_B T - h \\nu_0 / k_B T)} = \\frac{g_1}{g_2 } \\exp( \\frac{h \\nu_0}{k_B T})\n\\,.\n\\end{align}\n\nInserting this in the previous relation we find \n%\n\\begin{align}\n\\overline{J} = \\frac{A_{12} / B_{21} }{(g_1 B_{12} /  g_2 B_{21} ) \\exp(h \\nu_0 / k_B T) - 1 }\n\\,.\n\\end{align}\n\nAlso, we know that the mean intensity \\(J_\\nu \\) will be equal to the Planck function \\(B_\\nu \\). The Planckian is quite slowly varying while \\(\\phi (\\nu )\\) is very peaked around \\(\\nu_0 \\): therefore, it is safe to say that \n%\n\\begin{align}\n\\overline{J} = \\int_0^{\\infty } B_\\nu \\phi (\\nu ) \\dd{\\nu } \\approx B_{\\nu_0 }\n\\,,\n\\end{align}\n%\nsince \\(\\phi (\\nu )\\) is normalized. Equating this to the expression we found above, we get \n%\n\\begin{align}\n\\overline{J} =  B_{\\nu_0 } = \\frac{2 h \\nu^3}{c^2} \\frac{1}{\\exp( \\frac{h \\nu_0 }{k_B T }) - 1} &= \\frac{A_{12} / B_{21} }{(g_1 B_{12} /  g_2 B_{21} ) \\exp(h \\nu_0 / k_B T) - 1 }\n\\,.\n\\end{align}\n\nThis must hold for any temperature \\(T\\), so we can identify the terms in the two similar expressions: this tells us that \n%\n\\begin{align}\n\\frac{g_1 B_{12} }{g_2 B_{21} } = 1 \n\\qquad \\text{and} \\qquad\n\\frac{2 h \\nu^3}{c^2} = \\frac{A_{12} }{B_{21} }\n\\,.\n\\end{align}\n\nThese are called the \\textbf{detailed balance relations}. They must be satisfied even if the system is outside of thermal equilibrium, since the temperature \\(T\\) does not appear in them. \n\n\\todo[inline]{What? How? Why? We used the hypothesis of thermal equilibrium a lot\\dots}\n\n\\subsubsection{The emission and absorption coefficients}\n\nLet us assume that radiation which is emitted in the transition \\(2 \\to 1\\) has the same frequency as the radiation which is absorbed in the transition \\(1 \\to 2\\), so that both processes are be characterized by the function \\(\\phi (\\nu )\\), like we assumed before. \n\nWith this, we can express the energy emitted per unit volume, solid angle, frequency and time as \n%\n\\begin{align}\nj_\\nu \\dd{V} \\dd{t} \\dd{\\Omega } \\dd{\\nu } &= \\frac{h \\nu_0}{4 \\pi } \\phi (\\nu ) n_2 A_{21} \\dd{\\Omega } \\dd{V} \\dd{t} \\dd{\\nu }  \\\\ \nj_\\nu &= \\frac{h \\nu_0}{4 \\pi } \\phi (\\nu ) n_2 A_{21}  \n\\,.\n\\end{align}\n\nFor absorption, we can apply a similar line of reasoning: \nthe energy absorbed per unit volume and time is \n%\n\\begin{align}\n\\dd{w}_\\nu = \n\\dd{V} \\dd{t} h \\nu_0 n_1 B_{12} \\frac{1}{4 \\pi } \\int \\dd{\\Omega } \\dd{\\nu } I_\\nu \\phi (\\nu )\n\\,,\n\\end{align}\n%\nwhich we can specify to the energy taken out of the beam in the specific frequency and solid angle unit range by removing the integral. \nIf we write the volume element as \\(\\dd{V} = \\dd{A} \\dd{s}\\), where \\(\\dd{s}\\) is the distance travelled along the path of the radiation, and if we remember the radiative absorption law \\(\\dd{I_\\nu } = - \\alpha _\\nu I_\\nu \\dd{s}\\), we can write \n%\n\\begin{align}\n- \\dd{I_\\nu } = -\\frac{ \\dd{w}_\\nu }{ \\dd{A} \\dd{t} \\dd{\\Omega } \\dd{\\nu }}\n&= \\underbrace{h \\nu_0 n_1 \\frac{B_{12}}{4 \\pi } \\phi(\\nu )}_{\\alpha _\\nu } I_\\nu  \\dd{s} \\\\ \n\\alpha_\\nu &= \\frac{h \\nu_0  }{4 \\pi } n_1 B_{12} \\phi (\\nu )\n\\,.\n\\end{align}\n\nWe could also write \\(h \\nu\\) instead of \\(h \\nu_0\\) if we were to approximate \\(\\phi (\\nu )\\)  as a delta function \\(\\phi (\\nu ) = \\delta (\\nu - \\nu_0 )\\).\n\nNow, since stimulated emission depends on \\(\\overline{J}\\), it is convenient to treat it as a kind of ``negative absorption'': with the same steps as before we find that its coefficient is \n%\n\\begin{align}\n\\alpha_\\nu^{(s)} = - \\frac{h \\nu_0 }{4 \\pi } n_2 B_{21} \\phi (\\nu ) \n\\,.\n\\end{align}\n\nThe total absorption coefficient will then be the sum of these: \n%\n\\begin{align}\n\\alpha _\\nu = \\frac{h \\nu_0 }{4 \\pi } \\phi (\\nu ) \\qty(n_1 B_{12} - n_2 B_{21} )\n\\,.\n\\end{align}\n\nIn general, when we talk about absorption we always mean absorption minus stimulated emission. \n\n\\end{document}", "meta": {"hexsha": "d2476cb3a187d32d65c2f45885b7b557389999cb", "size": 11198, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/radiative_processes/may06.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/radiative_processes/may06.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/radiative_processes/may06.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 48.8995633188, "max_line_length": 441, "alphanum_fraction": 0.6695838543, "num_tokens": 3616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4081047587520756}}
{"text": "%!TEX root = ../Main.tex\nIn this section, the basics of the tight-binding approximation for electron transport will be explained. This motivates the use of numerical routines using NumPy.\n\\subsection{Ballistic quantum transport}\nAs graphene is a two dimensional material that consists of carbon atoms arranged in a hexagonal pattern. Features in such a material can approach nano meter and sub nano meter scales. Because of the small scale the electrical properties of the material is vastly different from normal materials. Usually when describing the electrical properties of a material, drift-diffusion current models are used. They describe electric charges per area and current per area. This is usually a good description in systems where electron-electron and electron-atom scattering frequently occurs. The distance an electron travels before such an event is called its \\textit{mean free path}. However, in small systems as those of NPG-devices, the mean free path can be longer than the system itself. Experiments have shown that electrons can move ballistically in graphene\\cite{mayorov_micrometer-scale_2011,baringhaus_exceptional_2014}, that is, without phonon scattering and even at room temperature. Therefore, we model electron transport in NPG using the \\textit{ballistic model}. In this model the electrons move through the material as waves. The fact that the electrons moves as waves will prove important later on because it gives rise to \\textit{Quantum Interference} which can be exploited as a tool when engineering graphene-based devices\\cite{markussen_relation_2010}. Furthermore the model looks at only one electron at a time in the presence of an electron gas. The ballistic model has been used with big success for regular graphene and it seems that it also gives a good approximation for NPGs.\n\\subsection{\\mathinhead{\\pi}{\\pi}-orbitals and \\mathinhead{\\pi}{\\pi}-electrons}\nWhen modelling the electron transport in graphene one needs to address the orbital structure of carbon lattices. The orbital structure is exactly what motivate the use of tight-binding approximation and Green's functions. The two concepts of tight-binding approximation and Green's functions will be elaborated further in the coming sections.\nIn its basic form graphene can be divided into rings of carbon atoms as shown in \\cref{ring}. In the (\\(x,y\\))-plane the carbon atoms are bound in \\(sp^2\\) orbitals as shown in \\cref{sp2}.\n\\begin{figure}[ht]\n\t\\centering\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\begin{tikzpicture}\n\t\t\t\\chemfig{C*6(-C-C-C-C-C-)}\n\t\t\\end{tikzpicture}\n\t\t\\caption{Graphene lattices consists of hexagonal arrangements of carbon atoms.}\\label{ring}\n\t\\end{subfigure}\n\t~\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering\n\t\t\\resizebox{\\textwidth}{!}{\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\node (x) at (-1,-3) {x};\n\t\t\t\t\\node (y) at (-2,-2) {y};\n\t\t\t\t\\draw[->] (-2,-3) -- (x);\n\t\t\t\t\\draw[->] (-2,-3) -- (y);\n\t\t\t\t\\satom[name=C, color=blue, pos={(0,0)}]{\n\t\t\t\t\tblue/60/north east/2/1,\n\t\t\t\t\tblue/180/west/1,\n\t\t\t\t\tblue/300/south east/2/1\n\t\t\t\t}\n\t\t\t\t\\satom[name=C, color=blue, pos={(1,1.4)}]{\n\t\t\t\t\tblue/0/east/2/1,\n\t\t\t\t\tblue/120/north west/1,\n\t\t\t\t\tblue/240/south west/2/1\n\t\t\t\t}\n\t\t\t\t\\satom[name=C, color=blue, pos={(2.74,1.4)}]{\n\t\t\t\t\tblue/60/north east/1,\n\t\t\t\t\tblue/180/west/2/1,\n\t\t\t\t\tblue/300/south east/2/1\n\t\t\t\t}\n\t\t\t\t\\satom[name=C, color=blue, pos={(3.74,0)}]{\n\t\t\t\t\tblue/0/east/1,\n\t\t\t\t\tblue/120/north west/2/1,\n\t\t\t\t\tblue/240/south west/2/1\n\t\t\t\t}\n\t\t\t\t\\satom[name=C, color=blue, pos={(2.74,-1.4)}]{\n\t\t\t\t\tblue/60/north east/2/1,\n\t\t\t\t\tblue/180/west/2/1,\n\t\t\t\t\tblue/300/south east/1\n\t\t\t\t}\n\t\t\t\t\\satom[name=C, color=blue, pos={(1,-1.4)}]{\n\t\t\t\t\tblue/0/east/2/1,\n\t\t\t\t\tblue/120/north west/2/1,\n\t\t\t\t\tblue/240/south west/1\n\t\t\t\t}\n\t\t\t\\end{tikzpicture}}\n\t\t\\caption{Carbon atoms in a hexagonal lattice are \\(sp^2\\) hybridised in the (\\(x,y\\))-plane.}\\label{sp2}\n\t\\end{subfigure}\n\t\\caption{Benzene ring and its \\(sp^2\\) hybridised orbitals.}\\label{Benz}\n\\end{figure}\nThis hybridisation lock all but one valence electron for the carbon atoms. These electrons exists in a p-orbital in the \\(z\\)-direction.\n\\cref{p} shows the valence orbitals of carbon.\n\\begin{figure}[ht]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\orbital[pos = {(0,3)}] {s}\n\t\t\\node[above] at (0,4) {s};\n\t\t\\orbital[pos = {(2,3)}]{px}\n\t\t\\node[above] at (2,4) {p$_x$};\n\t\t\\orbital[pos = {(4,3)}]{py}\n\t\t\\node[above] at (4,4) {p$_y$};\n\t\t\\orbital[pos = {(6,3)}]{pz}\n\t\t\\node[above] at (6,4) {p$_z$};\n\t\\end{tikzpicture}\n\t\\caption{The valence orbitals of carbon.}\n\t\\label{p}\n\\end{figure}\nThe last electron in the p\\(_z\\) orbital does not mix with the tightly bound s, p\\(_x\\) and p\\(_y\\) electrons and moves freely. Thus these electrons have higher energies compared to the \\(sp^2\\) electrons and occupy states at the Fermi level. These electrons dominates transport in the graphene lattice. The p\\(_z\\) orbital is also known as the \\(\\pi\\)-orbital and as such the electron lying there is called a \\(\\pi\\)-electron. Through a carbon lattice the \\(\\pi\\)-electrons will travel through \\(\\pi\\)-orbitals. For a benzene ring the \\(\\pi\\)-electrons at the highest occupied molecular state will travel through the \\(\\pi\\)-orbitals switching sign as they travel as shown in \\cref{sign}.\n\\begin{figure}[ht]\n\t\\centering\n\t\\pgfdeclarelayer{background}\n\t\\pgfdeclarelayer{middle}\n\t\\pgfdeclarelayer{foreground}\n\t\\pgfsetlayers{background,middle,main,foreground}\n\t\\begin{tikzpicture}\n\t\t\\begin{pgfonlayer}{background}\n\t\t\t\\orbital[pos = {(6,6)}]{-pz}\n\t\t\t\\node[above] at (6,7) {-p$_\\pi$};\n\t\t\t\\orbital[pos = {(4,6)}]{pz}\n\t\t\t\\node[above] at (4,7) {p$_\\pi$};\n\t\t\t\\draw[dashed, very thick] (6,6) -- (4,6);\n\t\t\t\\draw[dashed, very thick] (7,4.73) -- (6,6);\n\t\t\t\\draw[dashed, very thick] (4,6) -- (3,4.73);\n\t\t\\end{pgfonlayer}\n\t\t\\orbital[pos = {(7,4.73)}]{pz}\n\t\t\\node[above] at (7,5.73) {p$_\\pi$};\n\t\t\\orbital[pos = {(3,4.73)}]{-pz}\n\t\t\\node[above] at (3,5.73) {-p$_\\pi$};\n\t\t\\begin{pgfonlayer}{foreground}\n\t\t\t\\orbital[pos = {(4,3.46)}]{pz}\n\t\t\t\\node[above] at (4,4.46) {p$_\\pi$};\n\t\t\t\\orbital[pos = {(6,3.46)}]{-pz}\n\t\t\t\\node[above] at (6,4.46) {-p$_\\pi$};\n\t\t\t\\draw[dashed, very thick] (4,3.46) -- (6,3.46);\n\t\t\\end{pgfonlayer}\n\t\t\\draw[dashed, very thick] (6,3.46) -- (7,4.73);\n\t\t\\draw[dashed, very thick] (3,4.73) -- (4,3.46);\n\t\\end{tikzpicture}\n\t\\caption{When jumping from one carbon atom to another, the \\(\\pi\\)-electron goes between p\\(_\\pi\\)-orbitals. Such a jump is described by two matrix elements in the system's Hamiltonian.}\n\t\\label{sign}\n\\end{figure}\n\\subsection{Tight-binding}\\label{tbtheory}\nNow that the transport carrying electrons are defined the next step is describing the transport itself. For this purpose we employ the \\textit{tight-binding} approximation. In this approximation the electrons are considered being tightly bound to the atoms. Contrary to a free electron gas approximation, the electrons does not spend time in between orbitals, but jump from orbital in atom \\(a\\) to orbital in atom \\(b\\). The Hamiltonian is represented as a matrix of hopping elements for a collection of neighbouring atomic orbitals, i.e. molecular orbitals, as well as the energy contained within each orbital (which will be addressed later on). This can be done by describing the orbitals as a Linear Combination of Atomic Orbitals (LCAO). The solution to the Schrödinger equation is then:\n\\begin{align}\n\t\\Psi_{\\mathrm{MO}} = \\sum_{\\alpha,R}c_{\\alpha,R}\\phi_{\\alpha}(R)\n\\end{align}\nwhere \\(\\phi_{\\alpha}(R)\\) is an atomic orbital at position \\(R\\), with \\(\\alpha\\) denoting the valence of the orbital (\\(2s,2p_x,2p_y,2p_z\\)). In electron transport the states close to the Fermi level is of interest. These are namely the highest occupied molecular orbitals (HOMO), or the lowest unoccupied molecular orbitals (LUMO). As stated earlier only the \\(\\pi\\)-electrons is then of interest.\nThe electrons' motion can be described with the hopping matrix of elements:\n\\begin{align}\n\tV_{pp\\pi} = \\bra{\\phi_{\\pi}(m)}\\hat{H}\\ket{\\phi_{\\pi}(n)}\\label{V}\n\\end{align}\nPhysically this means that there is a potential \\(\\pqty{V_{pp\\pi}}\\) between the \\(\\pi\\) orbitals of neighbouring atoms \\(i\\) and \\(j\\). In our tight-binding approximation we consider only hop between nearest neighbours. Furthermore we do not take account for out of plane carbon atoms. The element\n\\begin{align}\n\t\\epsilon_0 = \\bra{\\phi_{\\pi}(i)}\\hat{H}\\ket{\\phi_{\\pi}(i)}\n\\end{align}\nis the average energy of the electron on atom \\(i\\) and, it is common to define the hopping energy relative to this, i.e. \\(\\epsilon_0 = 0\\).\nIf the atoms or their environment differs, so does the on-site potential.\\newline\n\\cref{benzex} contains an illuminating example of how the tight-binding approximation can be used to describe the benzene molecule.\n", "meta": {"hexsha": "27d16319497a37822e8142d4bbf80364978d8f98", "size": 8692, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/Theory.tex", "max_stars_repo_name": "rwiuff/QuantumTransport", "max_stars_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-25T14:05:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-25T14:05:45.000Z", "max_issues_repo_path": "sections/Theory.tex", "max_issues_repo_name": "rwiuff/QuantumTransport", "max_issues_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-31T03:17:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-31T03:17:38.000Z", "max_forks_repo_path": "sections/Theory.tex", "max_forks_repo_name": "rwiuff/QuantumTransport", "max_forks_repo_head_hexsha": "5367ca2130b7cf82fefd4e2e7c1565e25ba68093", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-27T10:27:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-17T10:18:18.000Z", "avg_line_length": 67.90625, "max_line_length": 1593, "alphanum_fraction": 0.7132995858, "num_tokens": 2687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.40805881213691275}}
{"text": "\\subsection{Example \\#5: single time series analysis with interventions}\n\\label{S:Example_DISP_intervention}\n\\subsubsection{Data description}\nThis case is based on Example \\#1 (see \\ref{S:Example_DISP}) where we removed some part of the data and introduce discrete shifts into it. This example illustrates what typically happens a sensor fails; when a sensor fails, the data start to be missing (i.e. \\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!NaN!) and it often takes from several weeks to several months before the sensor is replaced. When the sensor is replaced, it is in most cases re-initialized at a different initial value than the previous sensor which lead to a discrete shift in the time series, as depicted in Figure~\\ref{fig:DataSummary1}. Here in addition to the components employed for Example \\#1, we also employ a Local intervention in order to estimate the magnitude of the corrections require to eliminate the discrete shifts created by sensor replacement.\n\nNote that again, in this example, we choose to resample the original data in order to have a timesteps of 6h instead of 1h. \n\n\\begin{figure*}[h]\n\\centering\n\\begin{subfigure}{\\linewidth}\n\\includegraphics[width=0.95\\linewidth]{./docfigs/Example_DISP_INTERVENTION/ALL_AMPLITUDES.pdf}\n\\caption{Amplitude}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/ALL_TIMESTEPS.pdf} \n\\caption{Timestep}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/AVAILABILITY.pdf}\n\\caption{Availability}\n\\end{subfigure}\n\\caption{Raw data in the example \\#1 where the reference timestep is 1h.}\n\\label{fig:DataSummary1}\n\\end{figure*}\n\n\n\\subsubsection{Model description}\n\\label{SS:ModelConstructionExample1}\nThe model includes one model class, and the hidden states variables are \n\\begin{gather*}\n\\textbf{x}=[x^{\\mathtt{LL}}, x^{\\mathtt{P1}\\text{,yearly}}, x^{\\mathtt{P2}\\text{,yearly}}, x^{\\mathtt{P1}\\text{,daily}}, x^{\\mathtt{P2}\\text{,daily}}, x^{\\mathtt{AR}}, x^{\\mathtt{LI}}].\n\\end{gather*}\nWhen using a Level intervention component, the user must provide discrete timestamps where it is required to estimate the magnitude of a discrete shift in the dataset (see \\S\\ref{SSS:LI}). A user can do so by specifying in the configuration file \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!data.interventions=[t_{1}, t_{2}, ... , t_{n}]!}. The configuration file for this problem is presented in the Listing \\ref{LST:CFGFileExampleInt} where the timestamps where the shift occur are \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!data.interventions=[735929.875, 736099.875];!}. \n\n\\begin{lstlisting}[linewidth=\\linewidth, style=Matlab-editor,  basicstyle = \\mlttfamily \\tiny, backgroundcolor = \\color{matlab-yellow}, caption = {Configuration file for the example \\#5}, label=LST:CFGFileExampleInt, captionpos=b, float=h!]\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% A - Project name\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nmisc.ProjectName='Example_DISP_INTERVENTION';\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% B - Data\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\ndat=load('DATA_Example_DISP_INTERVENTION.mat'); \ndata.values=dat.values;\ndata.timestamps=dat.timestamps;\ndata.labels={'DISP'};\ndata.interventions=[735929.875, 736099.875];\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% C - Model structure \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Components reference numbers\n% 11: Local level\n% 12: Local trend\n% 13: Local acceleration\n% 21: Local level compatible with local trend\n% 22: Local level compatible with local acceleration\n% 23: Local trend compatible with local acceleration\n% 31: Periodic\n% 41: Autoregressive\n% 51: Kernel regression\n% 61: Level Intervention\n\n% Model components\nmodel.components.block{1}={[11 31 31 41 61 ] };\n \n% Model inter-components dependence | {[components form dataset_i depends on components from  dataset_j]_i,[...]}\nmodel.components.ic={[ ] };\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% D - Model parameters \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nmodel.param_properties={\n     % #1           #2             #3      #4    #5               #6           #7       #8              #9              #10\n     % Param name   Block name     Model   Obs   Bound            Prior        Mean     Std             Values          Ref\n     '\\sigma_w',   'LL',           '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            0,              1      %#1   \n     'p',          'PD1',          '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            365.2422,       2      %#2   \n     '\\sigma_w',   'PD1',          '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            0,              3      %#3   \n     'p',          'PD2',          '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            1,              4      %#4   \n     '\\sigma_w',   'PD2',          '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            0,              5      %#5   \n     '\\phi',       'AR',           '1',   '1',   [0  1      ],    'N/A',       NaN,     NaN,            0.90399,        6      %#6   \n     '\\sigma_w',   'AR',           '1',   '1',   [0  Inf    ],    'N/A',       NaN,     NaN,            0.035428,       7      %#7   \n     '\\mu_b',      'LI',           '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            0,              8      %#8   \n     '\\sigma_b',   'LI',           '1',   '1',   [NaN  NaN  ],    'N/A',       NaN,     NaN,            0.16276,        9      %#9   \n     '\\sigma_v',   '',             '1',   '1',   [0  Inf    ],    'N/A',       NaN,     NaN,            6.193e-06,      10     %#10  \n};\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% E - Initial states values \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Initial hidden states mean for model 1:\nmodel.initX{ 1 }=[\t25.9  \t-0.194\t-0.01 \t-0.00411\t0.0551\t-0.0127\t0     ]';\n% Initial hidden states variance for model 1: \nmodel.initV{ 1 }=diag([ \t8.26E-05\t0.000143\t0.000106\t4.86E-07\t4.86E-07\t0.00167\t1E-20  ]);\n% Initial probability for model 1\nmodel.initS{1}=[1     ];\n\n\\end{lstlisting}\n\nThe model parameters associated with this model are\n\\begin{gather*}\n\\bm\\theta=[\\sigma_{w}^{\\mathtt{LL}}, p^{\\mathtt{P}, \\text{yearly}}, \\sigma_{w}^{\\mathtt{P}, \\text{yearly}} , p^{\\mathtt{P}, \\text{daily}}, \\sigma_{w}^{\\mathtt{P}, \\text{daily}}, \\phi^{\\mathtt{AR}}, \\sigma_{w}^{\\mathtt{AR}}, \\mu_{b}^{\\mathtt{LI}}, \\sigma_{b}^{\\mathtt{LI}}, \\sigma_{v}].\n\\end{gather*}\nThe optimized model parameters values computed using the Newton-Raphson algorithm (see~\\ref{SS:THModelParameterEstimation}) with a training period of 180 days  are\n\\begin{gather*}\n\\bm\\theta^{\\text{*}}=[0, 365.2422, 0, 1, 0, 0.903, 0.035, 0, 0.16 6.19\\times10^{-6} ].\n\\end{gather*}\nThe estimated initial hidden states mean and covariance values are \n\\begin{align*}\n\\bm \\mu^{*}_{0} & = [\t25.9,-0.194,-0.01\t,-0.004,0.055,-0.013,0]^{\\intercal}, \\text{and} \\\\\n\\bm\\Sigma^{*}_{0} & = \\text{diag}([8.26\\times10^{-5},\t1.4\\times10^{-4},\t1.1\\times10^{-4},\t4.86\\times10^{-7},\t4.86\\times10^{-7},\t1.67\\times10^{-3}  1E-20 ]).\n \\end{align*}\nThe hidden states computed using the estimated model parameters and initial hidden states are presented in Figure~\\ref{fig:Example_DISP_INTERVENTIONOptimizedOptimizedExample1}. You can see in Figure \\ref{fig:Example_DISP_INTERVENTIONOptimizedOptimizedExample1}b that the level remains constant throughout the entire time series despite the jumps. This is because the discrete shift are estimated by the Level intervention component displayed in Figure \\ref{fig:Example_DISP_INTERVENTIONOptimizedOptimizedExample1}e. \n\n\n\\subsubsection{Run the example from the pre-existing configuration file}\n\\label{SS:LoadConfigFileEx1}\nThere is a configuration file CFG\\_Example\\_DISP\\_INTERVENTION\\_optim.m which is located in the ``config\\_files'' folder of the OpenBDLM package.\nCFG\\_Example\\_DISP\\_INTERVENTION\\_optim.m contains the optimized model parameters and estimated initial hidden states values (see Listing \\ref{LST:CFGFileExampleInt}).\nThere is also a data file DATA\\_Example\\_DISP\\_INTERVENTION\\_optim.mat that is located in the ``data/mat'' subfolder.\nTherefore, it is possible to run the example \\#1 by following the steps below while interacting with the \\MATLAB{} command line:\n\\begin{enumerate}\n\\item Start OpenBDLM. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!OpenBDLM_main('CFG_Example_DISP_INTERVENTION_optim.m');!}.\n\\item Access hidden states estimation menu. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!3!}.\n\\item Run the Kalman smoother to estimate the hidden states. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!1!}.\n\\item Save and quit. Type \\colorbox{light-gray}{\\lstinline[basicstyle = \\mlttfamily \\small, backgroundcolor = \\color{light-gray}]!Q!}.\n\\end{enumerate}\n\n\n\n\\begin{figure*}[h!]\n\\begin{center}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/DISP_ObservedPredicted.pdf} \n\\caption{Observed and estimated displacement data}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/DISP_LL_1.pdf}\n\\caption{Estimated displacement local level component.}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/DISP_S1_2.pdf} \n\\caption{Estimated displacement yearly periodic component (first hidden state)}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/DISP_AR_6.pdf} \n\\caption{Estimated displacement autoregressive component}\n\\end{subfigure}\n\\begin{subfigure}{\\linewidth}\n\\centering\n\\includegraphics[width=0.9\\linewidth]{./docfigs/Example_DISP_INTERVENTION/DISP_LI_7.pdf}\n\\caption{Estimated displacement daily periodic component (first hidden state)}\n\\end{subfigure}\n\\caption{Estimated results using OpenBDLM with the optimized model parameters and estimated initial hidden states. The hidden states are estimated from the data presented in Figure~\\ref{fig:DataSummary1}a. The solid line and shaded area represent the mean and standard deviation of the estimated hidden states.}\n\\label{fig:Example_DISP_INTERVENTIONOptimizedOptimizedExample1}\n\\end{center}\n\\end{figure*}\n\n\n\n", "meta": {"hexsha": "5cc3439362806b4d62d99f7a679f6d6e54b1d017", "size": 11045, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pdf_doc/section/OpenBDLMExampleSingleTimeSeries_intervention.tex", "max_stars_repo_name": "CivML-PolyMtl/OpenBDLM", "max_stars_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-19T23:42:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T17:32:11.000Z", "max_issues_repo_path": "doc/pdf_doc/section/OpenBDLMExampleSingleTimeSeries_intervention.tex", "max_issues_repo_name": "bhargobdeka/OpenBDLM", "max_issues_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pdf_doc/section/OpenBDLMExampleSingleTimeSeries_intervention.tex", "max_forks_repo_name": "bhargobdeka/OpenBDLM", "max_forks_repo_head_hexsha": "af395cea6d394b0d1fb91ce76ddda9d97c02318f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-10-18T07:18:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T02:26:06.000Z", "avg_line_length": 67.3475609756, "max_line_length": 871, "alphanum_fraction": 0.6354911725, "num_tokens": 3079, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341027751814, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.40805880348368473}}
{"text": "%!TEX root = ../thesis.tex\n% ******************************* Thesis Appendix A ****************************\n\n\\ifpdf\n    \\graphicspath{{Appendix1/Figs/Raster/}{Appendix1/Figs/PDF/}{Appendix1/Figs/}}\n\\else\n    \\graphicspath{{Appendix1/Figs/Vector/}{Appendix1/Figs/}}\n\\fi\n\n\\chapter{Methods}\n\\section{Measuring focal length of scan lens}\\label{appendix:scanlens}\n\nThe focal length of the scan lens was initially unknown but its position for collimation was, and so a reasonable assumption of its focal length was possible.\nTo compound certainty the focal length was found experimentally.\nTo accurately measure the focal length of an unknown lens the focal length of a lens of known focal length is needed to collimate the light.\nIn this experiment the tube lens of focal length \\SI{200}{\\milli\\meter} was used.\nBy measuring the width of a laser beam prior ($w_{before}$) to and after ($w_{after}$) the collimating lens pair, the magnification is calculated very accurately and the unknown focal length is found by:\n\n\\begin{align}\n\tM=\\frac{f_2}{f_1}=\\frac{w_{before}}{w_{after}}  \\rightarrow \\frac{f_2}{M} =f_{1}\n\\end{align}\n\nTo measure a beam width very accurately a straight sharp edge is placed in the beam path and slowly iterated through, the resultant beam power is then measured using a power meter.\nTo ensure there is no beam cropping on the power meter another lens was used to focus the intensity correctly, the same lens and its position was used in each measurement to keep with consistency.\nThe beam power was measured and plotted which produces an integrated Gaussian profile (see \\eqref{eq:guass_prop}) otherwise known as an error function.\nMathematically this is described by equation~\\eqref{eq:knife}.\n\n\\begin{align}\n\tI(x,y) &= I_0 e^{\\frac{-2x^2}{w_x^2}}e^{\\frac{-2y^2}{w_y^2}}\\label{eq:guass_prop}\\\\\\nonumber\n\tP_{TOT} &= I_0 \\int_{\\infty}^{\\infty}e^{\\frac{-2x^2}{w_x^2}} dx \\int_{\\infty}^{\\infty}e^{\\frac{-2y^2}{w_y^2}} dy\\\\\\nonumber\n\tP(X) &= P_{TOT} - \\int_{\\infty}^{X}e^{\\frac{-2x^2}{w_x^2}} dx I_0 \\int_{\\infty}^{\\infty}e^{\\frac{-2x^2}{w_x^2}} \\\\\\nonumber\n\t&= \\frac{P_{TOT}}{2} - \\sqrt{\\frac{\\pi}{2}} I_0 \\omega_y \\int_{\\infty}^{X}e^{\\frac{-2x^2}{w_x^2}}\\\\\n\t& = \\frac{P_{TOT}}{2} \\left[1 - erf\\left(\\frac{\\sqrt{2}X}{\\omega_x}\\right) \\right] \\label{eq:knife}\n\\end{align}\n\nFitting of this curve was implemented using MatLAB's curve fitting package which utilises the method of least squares fitting, see Figure \\ref{fig:laser_width}.\nThe fit result produced values of laser beam width as $w_{before} = \\SI{3.76\\pm0.04}{\\milli\\meter}$ and $w_{after} = \\SI{0.71\\pm0.1}{\\milli\\meter}$.\n% The value of $w_{after}$ was supplied in Table \\ref{table:laser} however, for posterity is was remeasured locally in case the value had changed or was incorrect.\nThis gives a magnification $M$ of \\SI{5.37 \\pm 0.1}{} therefore the focal length of the scan lens is \\SI{37.3\\pm0.1}{\\milli\\meter}.\nThis also showed that the fill of the \\SI{12}{\\milli\\meter} back aperture was \\SI{3.76\\pm0.04}{\\milli\\meter} hence the NA of the \\num{0.3} objective used would be \\SI{\\approx 0.094}{}.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.7\\linewidth]{./laser_width}\n\\caption[Laser Width Fitting]{Plot showing the fitting of two error functions based on the knife edge translation through a laser beam propagation, producing laser beam widths of $w_{after} = \\SI{0.71\\pm0.1}{\\milli\\meter}$ and $w_{before} = \\SI{3.76\\pm0.04}{\\milli\\meter}$}\n\\label{fig:laser_width}\n\\end{figure}\n\n% \\section{System alignments protocol}\n\n%Stationary back apeture.\n\\chapter{Useful derivations}\n\\section{Convolution theorem}\\label{appendix:convolution_theorem}\n\nConvolution is a mathematical operation between two functions, say $g(t)$ and $f(t)$, with the resultant function being an expression of the overlap of $g$ as it is shifted over $f$ \\cite{bracewellFourierAnalysisImaging2004}. Mathematically it can be expressed as an integral over a finite range $\\tau$:\n\\begin{equation}\n[f(*g](t) = \\int_{-\\infty}^{\\infty} f(\\tau) g(t-\\tau)d\\tau\n\\end{equation}\n\nIf a Fourier transform is then applied to the convolution of two functions:\n\\begin{align}\n\\mathcal{F}([f*g](t)) &= \\int_{-\\infty}^{\\infty} \\left[{\\int_{-\\infty}^{\\infty} f(\\tau)} g(t-\\tau)d\\tau\\right] e^{-i2 \\pi kt} dt \\\\\n\\text{and then reverse}&\\text{ the order:}\\nonumber\\\\\n\\mathcal{F}([f*g](t)) &= \\int_{-\\infty}^{\\infty}f(\\tau) \\left[{\\int_{-\\infty}^{\\infty} } g(t-\\tau) e^{-i2 \\pi kt} dt\\right]   d\\tau\n\\\\\n\\text{From the shift theorem}& \\text{ seen in equation \\eqref{shift_ivariance}:} \\nonumber\n\\\\\n\\left[{\\int_{-\\infty}^{\\infty} } g(t-\\tau) e^{-i2 \\pi kt} dt\\right] &= \\mathcal{F}(g(t-\\tau)) = \\mathcal{F}(g(t)) e^{-i2 \\pi k \\tau}\\\\\n\\implies \\mathcal{F}([f*g](t)) &= \\mathcal{F}(g(t)) \\int_{-\\infty}^{\\infty}f(\\tau) e^{-i2 \\pi k \\tau}    d\\tau\n\\\\&= \\mathcal{F}(g(t)) \\mathcal{F}(f(\\tau)) \\label{convolv}\n\\end{align}\n\nShowing that \\textbf{Convolution} in real space is \\textbf{Multiplication} is Fourier space.\n\n\n\\section{Fourier transform}\n\nAny continuous function can be decomposed into a linear summation of harmonic weighted sinusoidal functions. A Fourier transform is a mechanism by which the weightings of this series can be derived. Fourier space uses this transform to represent a function or a signal in frequency space (sometimes known as $k$-space or reciprocal space); it can be seen as a coordinate change from $x$ to $k$ denoted mathematically as~\\cite{bloomfieldFourierAnalysisTime2000}:\n\\begin{equation}\nF(k) \\equiv\\mathcal{F}  \\{f(x)\\} \\equiv \\int_{-\\infty}^{\\infty}f(x) e^{-i2 \\pi kx} dx \\label{fourier trans}\n\\end{equation}\n\nThis process is also reversible by:\n\n\\begin{equation}\nf(x) \\equiv\\mathcal{F}^{-1}  \\{F(k)\\} \\equiv \\frac{1}{2 \\pi} \\int_{-\\infty}^{\\infty}F(k) e^{-i2 \\pi kx} dk\n\\end{equation}\n\n\nFourier transforms have a valuable property in that a shift in real space becomes a complex phase term in $k$ space. This is shown by substituting $x = x-a$ and $dx = dx$ into \\eqref{fourier trans}:\n\\begin{align}\nF(k') &=  \\int_{-\\infty}^{\\infty}f(x) e^{-i2 \\pi k(x-a)} dx \\nonumber\\\\\n&=  e^{-i2 \\pi ka} \\underbrace{\\int_{-\\infty}^{\\infty}f(x) e^{-i2 \\pi kx}dx}_{F(k)}   \\label{shift_ivariance}\n\\end{align}\n\nHence the additional real space shift only adds a multiplicative factor to the final Fourier transform. This is known as the Shift theorem.\n\n\\section{Huygens wavelet theory}\n\nDiffraction is the spreading of light rays after an interaction with an object. Coincident light waves may interfere when diffracted such that the superposition of their resultant waves is constructive or destructive dependent on their relative phase difference. Light incident on an aperture $A(x,y)$ in the plane $S$ can be assumed to be of a plane wave nature. When passing through the aperture, light can then be modelled as being a series of $dS$ spaced point sources that radiate spherical wavefronts under Huygens' principle:\n\n\\begin{quote}\n``Every point on a propagating wavefront serves as the source of secondary spherical wavelets, such that the wavefront at some later time is the envelope of these wavelets.''~\\cite{goodmanIntroductionFourierOptics1996}\n\\end{quote}\n\n%\n% \\begin{figure}\n% \\centering\n% \\includegraphics[width=0.7\\linewidth]{./Diagrams/coordsys}\n% \\caption{Diagram depicting the coordinate system discussed Section \\ref{diffraction}.}\n% \\label{fig:coordsys}\n% \\end{figure}\n\nThe superposition and hence summation of these emitting wavelets when only travelling forward ($+z$ direction) and contained in a cone of small angles from the optical axis can be evaluated in terms of $dE$, the change in the field at some point in front of the aperture. The change in field goes with $\\frac{1}{r}$ where $r$ represents the distance to an arbitrary point and for a real wave can be expressed as:\n\n\\begin{equation}\ndE = \\frac{A(x,y)dS}{r} cos(\\omega t -kr)\n\\end{equation}\n\nUsing the coordinates $\\alpha,\\beta$ to represent the two dimensional plane of the projection of the light passing through the aperture $A(x,y)$ then $r$ and $R$ can be written as:\n\\begin{align}\nR^2 &= \\alpha ^2 + \\beta ^ 2+ z^2  \\\\\nr^2 &= (\\alpha - x)^2 + (\\beta - y)^2 + z^2\n\\end{align}\nWhere $R$ represents the distance from the optical centre of the aperture to the arbitrary point at $\\alpha,\\beta$, which can be rewritten as:\n\n\\begin{equation}\nr = R \\sqrt{1 - \\frac{2 \\alpha x + 2 \\beta y}{R^2} + \\frac{x^2 + y^2}{R^2}}  \\label{r = R}\n\\end{equation}\n\nWhich can be approximated using a binomial expansion to:\n\n\\begin{equation}\nr = R - \\frac{(\\alpha x + \\beta y)}{R}\n\\end{equation}\n\nProvided the cone of angles is small, then $r \\approx R$ and when only considering the case where $R^2 >> x^2 + y^2$ equation \\eqref{r = R} tends to:\n\\begin{equation}\ndE = \\frac{A(x,y)}{R} e^{i \\omega t - kr} e^{ik \\left(\\frac{\\alpha x + \\beta y}{R}\\right)} dxdy\n\\end{equation}\n\nIntegrating across the entire aperture (wavefronts are entirely rejected elsewhere):\n\n\n\\begin{align}\nE(\\alpha,\\beta) &= \\frac{e^{i \\omega t - kr}}{R} \\int\\int_{A}^{} A(x,y) e^{ik \\left(\\frac{\\alpha x + \\beta y}{R}\\right)} dxdy\n\\\\  \\text{After a normalised } &\\text{coordinate switch:} \\nonumber \\\\\nu &= \\frac{k \\alpha}{2 \\pi R}  \\text{ and }   v = \\frac{k \\beta}{2 \\pi R}\n\\\\ E(u,v)&=\\frac{e^{i \\omega t - kr}}{R} \\int\\int_{A}^{} A(x,y) e^{i2 \\pi k \\left(ux + vy\\right)} dxdy\n\\end{align}\n\nThis form is well known and defined as a Fourier transform (with a weighting term) and hence the far field diffraction pattern of an aperture is the Fourier transform of that aperture~\\cite{goodmanIntroductionFourierOptics1996}.\n\n\\section{Bragg conditons}\n\n%Bragg conditions\nProof of Abbe limit from diffraction theory:\n\n\\begin{align}\n    \\intertext{We define the separation of two diffractive orders through an aperture}\n    d \\sin \\alpha_n = n \\lambda \\\\\n    \\intertext{We then use the equation of a lens}\n    \\sin\\alpha_n = \\frac{p_n}{f} \\\\\n    p_n = \\frac{n\\lambda f}{d} \\\\\n    \\intertext{In the extreme of the limit of resolution, \\(p_n\\) becomes unity}\n    d \\le = \\frac{\\lambda}{\\sin\\alpha_{\\text{max}}} \\\\\n    \\intertext{We rearrange to show the classic Abbe limit:}\n    d \\le = \\frac{\\lambda_0}{n\\sin\\alpha_{\\text{max}}} = \\frac{2\\lambda_0}{NA}\n\\end{align}\n\n\n\\section{Fourier slice theorem}\\label{appendix:fourierslice}\nFrom~\\cite{kakPrinciplesComputerizedTomographic2001}:\n\n\\begin{quotation}\n``We derive the Fourier Slice Theorem by taking the one-dimensional Fourier transform of a parallel projection and noting that it is equal to a slice of the two-dimensional Fourier transform of the original object.\nIt follows that given the projection data, it should then be possible to estimate the object by simply performing a two-dimensional inverse Fourier transform.\nWe start by defining the two-dimensional Fourier transform of the object function as\n\n\\begin{align}\n  F(u,v) = \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} f(x, y)e^{-i2\\pi(ux+uy)}dx dy.\n  \\intertext{ Likewise define a projection at an angle  \\(\\theta \\), \\(P_{\\theta}(t)\\), and its Fourier transform by}\nS_{\\theta}(w) =  \\int_{-\\infty}^{\\infty} P_\\theta9t) e^{-i2\\pi w t} dt\n\\end{align}\n\\begin{align}\n\\intertext{The simplest example of the Fourier Slice Theorem is given for a projection at \\(\\theta = 0\\).\nFirst, consider the Fourier transform of the object along\nthe line in the frequency domain given by u = 0.\nThe Fourier transform integral now simplifies to}\nF(u,0) = \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} f(x, y)e^{-i2\\pi(ux)}dx dy.\n\\intertext{ but because the phase factor is no longer dependent on y we can split the integral into two parts,}\nF(u,0) =  \\int_{-\\infty}^{\\infty} \\left[  \\int_{-\\infty}^{\\infty} f(x,y,) dy \\right] e^{-i2\\pi(ux)} dx \\label{eq:f(u,0)}\n\\intertext{ From the definition of a parallel projection, the reader will recognise the term in brackets as the equation for a projection along lines of constant \\(x\\) or}\nP_{\\theta = 0} (x) = \\int_{-\\infty}^{\\infty} f(x,y) dy\n\\intertext{Substituting this in \\eqref{eq:f(u,0)} we find:}\nF(u,0) =  \\int_{-\\infty}^{\\infty} P_{\\theta = 0} (x) e^{-i2\\pi(ux)} dx\n\\intertext{ The right-hand side of this equation represents the one-dimensional Fourier transform of the projection \\(P_{\\theta = 0}\\);\nthus we have the following relationship between the vertical projection and the 2-D transform of the object function:}\nF(u,0) = S_{\\theta=0}(u)\n\\end{align}\n\n\\begin{quotation}\n  ``The Fourier transform of a parallel projection of an image \\(f(x, y)\\) taken at angle \\(\\theta \\) gives a slice of the two-dimensional transform, \\(F(u, v)\\), subtending an angle \\(\\theta \\) with the \\(u\\)-axis.''\n\\end{quotation}\n''\n\\end{quotation}\n\n\\chapter{Particle tracking}\n\\section{Failed quantifications of motion induced error}\n\nIntroduced in Section~\\ref{sec:spt_maths}, attempts at quantify the error seen due to motion blur that failed.\n\n\\subsection{Cross correlation}\n\\begin{align*}\n  \\intertext{To analytically compare the expected and real results, the respective functions were cross-correlated using the analytical function:}\n%\\text{Cross correlation} =\n(f \\star g)(t)\\ \\stackrel{\\mathrm{def}}{=} \\int_{-\\infty}^{\\infty} &f(x)^* g(x+t) \\mathop{dx}\n\\end{align*}\n\\begin{align*}\n\\intertext{The integral of the result across all space gives a single value signifying the quality of correlation between the two functions:}\n\\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} &f(t)^* g(x+t) \\mathop{dx}\\mathop{dt}\n\\intertext{This value will reach unity when $f(x) = g(x)$}\n\\end{align*}\n\\begin{align*}\n\\intertext{The expected PSF was given the additional $t$ parameter as it was more likely that this integral would solve, though, this only solves across all space for unnormalised PSFs:}\n\\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} &\\text{PSF}_{\\text{Reality}} (x)^* \\text{PSF}_{\\text{Expected}} (x+t) \\mathop{dx}\\mathop{dt} \\\\\n=& \\frac{\\pi  c (a L+L_{\\text{end}})^2}{a L_{\\text{end}} L \\sqrt{\\frac{L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}}} +\\frac{2 \\pi  c^2 (a L+L_{\\text{end}})^2}{L_{\\text{end}}^2}\\\\\n+&\\frac{\\pi  c L_{\\text{end}}}{a L \\sqrt{\\frac{L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}}}-\\frac{2 \\pi  L_{\\text{end}}}{a \\sqrt{\\frac{1}{c^2}} L \\sqrt{\\frac{L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}}}\\\\\n+&\\frac{2 \\pi  c^2 (a L+L_{\\text{end}})^2}{a L_{\\text{end}} L}\n\\end{align*}\n\\begin{align*}\n  \\intertext{By correlating the normalised functions across a small window $u$ an analytical solution was produced.}\n\\int_{-u}^{ u}\\int_{-\\infty}^{\\infty} \\hat{\\text{PSF}}_{\\text{Reality}} (x)^* \\hat{\\text{PSF}}_{\\text{Expected}} (x+t) \\mathop{dx}\\mathop{dt}\n\\end{align*}\n\\begin{align*}\n&=-\\frac{(a L+L_{\\text{end}})}{\\sqrt{2 \\pi } a L_{\\text{end}} L}\\sqrt{\\frac{L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}}\\left(L_{\\text{end}} u \\left(\\text{Ei}\\left(-\\frac{L_{\\text{end}}^2 u^2}{2 c^2 (L_{\\text{end}}+a L)^2}\\right)+\\Gamma \\left(0,\\frac{u^2}{2 c^2}\\right)\\right)\\right.\\\\\n&-\\frac{\\sqrt{2 \\pi (-c)} (a L+L_{\\text{end}}) \\left(\\text{Erf} \\left(\\frac{L_{\\text{end}} u}{\\sqrt{2} (a c L+c L_{\\text{end}})}\\right)\\right)}{\\sqrt{2 \\pi } a L_{\\text{end}} L}-\\frac{\\sqrt{2 \\pi } L_{\\text{end}} \\left| c\\right|  \\text{Erf} \\left(\\frac{u}{\\sqrt{2} \\left| c\\right| } \\right)}{\\sqrt{2 \\pi } a L_{\\text{end}} L}\n\\end{align*}\n\n\\begin{figure}\n  \\centering\n  \\includegraphics{./mathematica/correlation_analysis}\n  \\caption{}\n  \\label{fig:correlation_analysis}\n\\end{figure}\n\n\\subsection{Full width half maximum}\n\nThe correlation of two signals is not an absolute error which can be used to make predictions about real-world systems. So, the Full Width at Half Maximum of each of the two signals was considered as this property, in Gaussian-like functions, should provide an analogue for $\\sigma(z)$ which may be compared absolutely.\n\\begin{align*}\n\\text{PSF}(x,...) &- \\lim_{x\\to0} \\frac{\\text{PSF}(x,...)}{2} = 0 \\\\\n\\implies \\text{FWHM}_{\\text{Expected}} &= 2x \\\\\n&= \\left|-\\frac{\\sqrt{2} c \\sqrt{\\ln{2} +2 i \\pi  n} (a L+L_{\\text{end}})}{L_{\\text{end}}}\\right|,n\\in \\mathbb{Z}\n%\\text{FWHM}_{\\text{Expected}} &= \\frac{2 \\sqrt{3}}{\\sqrt{\\frac{a^2 L^2}{c^2 (a L+L_{\\text{end}})^2}+\\frac{3 L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}+\\frac{3 a L_{\\text{end}} L}{c^2 (a L+L_{\\text{end}})^2}}}\n\\end{align*}\n\\begin{align*}\n\\text{PSF}_{\\text{Reality}}(x,...) - \\lim_{x\\to0} \\frac{\\text{PSF}_{\\text{Reality}}(x,...)}{2} = 0 \\\\\n\\intertext{This equation does not solve for $x$ so a Maclaurin expansion was used:}\n= -\\frac{L_{\\text{end}} x^2}{4 \\left(c^2 (a L+L_{\\text{end}})\\right)}+\\frac{x^4 \\left(a^2 L_{\\text{end}} L^2+3 a L_{\\text{end}}^2 L+3 L_{\\text{end}}^3\\right)}{48 c^4 (a L+L_{\\text{end}})^3}+O\\left(x^5\\right)\n\\end{align*}\n\\begin{align*}\n\\implies \\text{FWHM}_{\\text{Reality}} &= \\frac{2 \\sqrt{3}}{\\sqrt{\\frac{a^2 L^2}{c^2 (a L+L_{\\text{end}})^2}+\\frac{3 L_{\\text{end}}^2}{c^2 (a L+L_{\\text{end}})^2}+\\frac{3 a L_{\\text{end}} L}{c^2 (a L+L_{\\text{end}})^2}}}\\\\\n\\text{FWHM}_\\text{Error} &= 2\\frac{\\text{PSF}_{\\text{Expected}} - \\text{PSF}_{\\text{Reality}}}{\\text{PSF}_{\\text{Expected}} + \\text{PSF}_{\\text{Reality}}}\\\\\n& = 2\\frac{\\sqrt{\\ln{2}} \\sqrt{a^2 L^2+3 a L_{\\text{end}} L+3 L_{\\text{end}}^2}-\\sqrt{3} L_{\\text{end}}}{\\sqrt{\\ln{2}} \\sqrt{a^2 L^2+3 a L_{\\text{end}} L+3 L_{\\text{end}}^2}+\\sqrt{3} L_{\\text{end}}}\n\\end{align*}\n\nWhen $L\\to0$ this result of $\\text{FWHM}_\\text{Error}$ can be below zero, which would suggest that the result is not an accurate measure of the true error.\nThis is likely due to the process requiring a series expansion, at $x=0$; as the series expansion is only an approximation of the target function.\nSince attaining error from the FWHM fails for small values of $L$ an analysis using area was considered.\n\n\\section{Magnetic tweezer alternate proof}\\label{appendix:tweezertheory}\n\n%The parameters from \\eqref{eq:modelfitting} need to be reviewed and amended if one intends to link them to experimental data as one applies a known force and looks at the displacement of the bead from its initial position and not to stress and strain.\n\nA bead moving through a viscous fluid can be described by Stokes' law \\(F = 6 \\pi \\eta' r \\nu \\), where \\(r\\) is the radius of the bead and \\(\\nu \\) is the critical velocity of the bead.\nStokes' law may be written as:\n\n\\begin{align}\n F &= 6 \\pi \\eta' r \\frac{dx}{dt} \\\\\n \\implies \\frac{F}{\\pi r^2} &= 6 \\eta' \\frac{d}{dt}\\frac{x}{r} \\\\\n \\implies \\sigma &= 6 \\eta' \\frac{\\epsilon}{dt}\n \\intertext{Giving the equation of a dash-pot}\n \\dot{\\epsilon} = \\frac{\\sigma}{\\eta}\n\\end{align}\n\nTo model the elastic spring, the elastic response of the tissue due to the bead displacement is approximated by the Thomson's solution of a point force in an infinite isotropic medium~\\cite{l.d.landaue.m.lifshitzTheoryElasticity1970}.\nThe displacement (\\(\\mathbf{u}\\)) in cylindrical coordinates (\\((p,z)\\)) for a point force (\\(F_z\\)) located at the origin and directed along the (\\(z\\)) axis is given by:\n\n\\begin{align}\n \\mathbf{u} = \\frac{F_z}{4 \\pi \\mu r }\\left[ \\frac{pz}{4(1-v)r^2} \\mathbf{\\hat{p}}+\\left(1- \\frac{p^2}{4(1-v)r^2}\\right)\\mathbf{\\hat{z}}\\right]\\label{eq:thomsons}\n\\end{align}\n\nWhere \\(\\mathbf{\\hat{p}}\\) and \\(\\mathbf{\\hat{z}}\\) are unit vectors, \\(\\mu \\) is the shear modulus (deformation at constant volume) and \\(\\nu \\) is Poisson's ratio (a negative ratio of transverse to axial strain of a specimen, under an axial force).\nAs only forces in the \\(\\mathbf{\\hat{z}}\\) direction are being considering, Equation~\\eqref{eq:thomsons} becomes:\n\n\\begin{align}\n u_z &= \\frac{F_z}{4 \\pi \\mu r }\\left[\\left(1- \\frac{p^2}{4(1-v)r^2}\\right)\\right]\n \\intertext{Evaluating the displacement only on the \\(z\\) axis where \\(p=0\\), reduces this to:}\n \\nabla z &= \\frac{F_z}{4\\pi \\mu r}\n \\intertext{In the close proximity to the bead of radius \\(r_{\\text{bead}} \\), the displacement is given by:}\n \\frac{\\nabla z}{r_{\\text{bead}}} = \\frac{1}{4 \\mu} \\frac{F_z}{\\pi r_{\\text{bead}}^2} & \\implies \\epsilon = \\frac{1}{4\\mu} \\sigma\n\\end{align}\nWhich is equivalent to~\\eqref{eq:linearspring} when substituting \\(E \\) with \\(4\\mu \\).\n", "meta": {"hexsha": "e0a47559a696288c5f232eca059aaedd75e19880", "size": 19911, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Appendix1/appendix1.tex", "max_stars_repo_name": "ctr26/thesis", "max_stars_repo_head_hexsha": "c5c62a7994421f38bb6b4b1a9490fb80749ecedb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Appendix1/appendix1.tex", "max_issues_repo_name": "ctr26/thesis", "max_issues_repo_head_hexsha": "c5c62a7994421f38bb6b4b1a9490fb80749ecedb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Appendix1/appendix1.tex", "max_forks_repo_name": "ctr26/thesis", "max_forks_repo_head_hexsha": "c5c62a7994421f38bb6b4b1a9490fb80749ecedb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.4967105263, "max_line_length": 532, "alphanum_fraction": 0.6931846718, "num_tokens": 6682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.7853085808877581, "lm_q1q2_score": 0.4079845520831302}}
{"text": "\\section{Cascade Classification}\n\n\\ifCPy\n\n\\subsection{Haar Feature-based Cascade Classifier for Object Detection}\n\nThe object detector described below has been initially proposed by Paul Viola\n\\cvCPyCross{Viola01}\nand improved by Rainer Lienhart\n\\cvCPyCross{Lienhart02}\n. First, a classifier (namely a \\emph{cascade of boosted classifiers working with haar-like features}) is trained with a few hundred sample views of a particular object (i.e., a face or a car), called positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary images of the same size.\n\nAfter a classifier is trained, it can be applied to a region of interest\n(of the same size as used during the training) in an input image. The\nclassifier outputs a \"1\" if the region is likely to show the object\n(i.e., face/car), and \"0\" otherwise. To search for the object in the\nwhole image one can move the search window across the image and check\nevery location using the classifier. The classifier is designed so that\nit can be easily \"resized\" in order to be able to find the objects of\ninterest at different sizes, which is more efficient than resizing the\nimage itself. So, to find an object of an unknown size in the image the\nscan procedure should be done several times at different scales.\n\nThe word \"cascade\" in the classifier name means that the resultant\nclassifier consists of several simpler classifiers (\\emph{stages}) that\nare applied subsequently to a region of interest until at some stage the\ncandidate is rejected or all the stages are passed. The word \"boosted\"\nmeans that the classifiers at every stage of the cascade are complex\nthemselves and they are built out of basic classifiers using one of four\ndifferent \\texttt{boosting} techniques (weighted voting). Currently\nDiscrete Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are\nsupported. The basic classifiers are decision-tree classifiers with at\nleast 2 leaves. Haar-like features are the input to the basic classifers,\nand are calculated as described below. The current algorithm uses the\nfollowing Haar-like features:\n\n\\includegraphics[width=0.5\\textwidth]{pics/haarfeatures.png}\n\nThe feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within the region of interest and the scale (this scale is not the same as the scale used at the detection stage, though these two scales are multiplied). For example, in the case of the third line feature (2c) the response is calculated as the difference between the sum of image pixels under the rectangle covering the whole feature (including the two white stripes and the black stripe in the middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to compensate for the differences in the size of areas. The sums of pixel values over a rectangular regions are calculated rapidly using integral images (see below and the \\cvCPyCross{Integral} description).\n\n\\ifPy\nA simple demonstration of face detection, which draws a rectangle around each detected face:\n\n\\begin{lstlisting}\n\nhc = cv.Load(\"haarcascade_frontalface_default.xml\")\nimg = cv.LoadImage(\"faces.jpg\", 0)\nfaces = cv.HaarDetectObjects(img, hc, cv.CreateMemStorage())\nfor (x,y,w,h),n in faces:\n    cv.Rectangle(img, (x,y), (x+w,y+h), 255)\ncv.SaveImage(\"faces_detected.jpg\", img)\n\n\\end{lstlisting}\n\n\\fi\n\n\\ifC\nTo see the object detector at work, have a look at the HaarFaceDetect demo.\n\nThe following reference is for the detection part only. There\nis a separate application called \\texttt{haartraining} that can\ntrain a cascade of boosted classifiers from a set of samples. See\n\\texttt{opencv/apps/haartraining} for details.\n\n\\cvclass{CvHaarFeature, CvHaarClassifier, CvHaarStageClassifier, CvHaarClassifierCascade}\n\\label{CvHaarFeature}\n\\label{CvHaarClassifier}\n\\label{CvHaarStageClassifier}\n\\label{CvHaarClassifierCascade}\n\nBoosted Haar classifier structures.\n\n\\begin{lstlisting}\n#define CV_HAAR_FEATURE_MAX  3\n\n/* a haar feature consists of 2-3 rectangles with appropriate weights */\ntypedef struct CvHaarFeature\n{\n    int  tilted;  /* 0 means up-right feature, 1 means 45--rotated feature */\n\n    /* 2-3 rectangles with weights of opposite signs and\n       with absolute values inversely proportional to the areas of the \n       rectangles.  If rect[2].weight !=0, then\n       the feature consists of 3 rectangles, otherwise it consists of 2 */\n    struct\n    {\n        CvRect r;\n        float weight;\n    } rect[CV_HAAR_FEATURE_MAX];\n}\nCvHaarFeature;\n\n/* a single tree classifier (stump in the simplest case) that returns the \n   response for the feature at the particular image location (i.e. pixel \n   sum over subrectangles of the window) and gives out a value depending \n   on the response */\ntypedef struct CvHaarClassifier\n{\n    int count;  /* number of nodes in the decision tree */\n\n    /* these are \"parallel\" arrays. Every index \\texttt{i}\n       corresponds to a node of the decision tree (root has 0-th index).\n\n       left[i] - index of the left child (or negated index if the \n         left child is a leaf)\n       right[i] - index of the right child (or negated index if the \n          right child is a leaf)\n       threshold[i] - branch threshold. if feature responce is <= threshold, \n                    left branch is chosen, otherwise right branch is chosen.\n       alpha[i] - output value correponding to the leaf. */\n    CvHaarFeature* haar_feature;\n    float* threshold;\n    int* left;\n    int* right;\n    float* alpha;\n}\nCvHaarClassifier;\n\n/* a boosted battery of classifiers(=stage classifier):\n   the stage classifier returns 1\n   if the sum of the classifiers responses\n   is greater than \\texttt{threshold} and 0 otherwise */\ntypedef struct CvHaarStageClassifier\n{\n    int  count;  /* number of classifiers in the battery */\n    float threshold; /* threshold for the boosted classifier */\n    CvHaarClassifier* classifier; /* array of classifiers */\n\n    /* these fields are used for organizing trees of stage classifiers,\n       rather than just stright cascades */\n    int next;\n    int child;\n    int parent;\n}\nCvHaarStageClassifier;\n\ntypedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade;\n\n/* cascade or tree of stage classifiers */\ntypedef struct CvHaarClassifierCascade\n{\n    int  flags; /* signature */\n    int  count; /* number of stages */\n    CvSize orig_window_size; /* original object size (the cascade is \n                            trained for) */\n\n    /* these two parameters are set by cvSetImagesForHaarClassifierCascade */\n    CvSize real_window_size; /* current object size */\n    double scale; /* current scale */\n    CvHaarStageClassifier* stage_classifier; /* array of stage classifiers */\n    CvHidHaarClassifierCascade* hid_cascade; /* hidden optimized \n                        representation of the \n                        cascade, created by \n                cvSetImagesForHaarClassifierCascade */\n}\nCvHaarClassifierCascade;\n\\end{lstlisting}\n\nAll the structures are used for representing a cascaded of boosted Haar classifiers. The cascade has the following hierarchical structure:\n\n\\begin{verbatim}\n    Cascade:\n        Stage,,1,,:\n            Classifier,,11,,:\n                Feature,,11,,\n            Classifier,,12,,:\n                Feature,,12,,\n            ...\n        Stage,,2,,:\n            Classifier,,21,,:\n                Feature,,21,,\n            ...\n        ...\n\\end{verbatim}\n\nThe whole hierarchy can be constructed manually or loaded from a file or an embedded base using the function \\cvCPyCross{LoadHaarClassifierCascade}.\n\n\\cvCPyFunc{LoadHaarClassifierCascade}\nLoads a trained cascade classifier from a file or the classifier database embedded in OpenCV.\n\n\\cvdefC{\nCvHaarClassifierCascade* cvLoadHaarClassifierCascade( \\par const char* directory,\\par CvSize orig\\_window\\_size );\n}\n\n\\begin{description}\n\\cvarg{directory}{Name of the directory containing the description of a trained cascade classifier}\n\\cvarg{orig\\_window\\_size}{Original size of the objects the cascade has been trained on. Note that it is not stored in the cascade and therefore must be specified separately}\n\\end{description}\n\nThe function loads a trained cascade\nof haar classifiers from a file or the classifier database embedded in\nOpenCV. The base can be trained using the \\texttt{haartraining} application\n(see opencv/apps/haartraining for details).\n\n\\textbf{The function is obsolete}. Nowadays object detection classifiers are stored in XML or YAML files, rather than in directories. To load a cascade from a file, use the \\cvCPyCross{Load} function.\n\n\\fi\n\n\\cvCPyFunc{HaarDetectObjects}\nDetects objects in the image.\n\n\\ifC\n\\begin{lstlisting}\ntypedef struct CvAvgComp\n{\n    CvRect rect; /* bounding rectangle for the object (average rectangle of a group) */\n    int neighbors; /* number of neighbor rectangles in the group */\n}\nCvAvgComp;\n\\end{lstlisting}\n\\fi\n\n\\cvdefC{\nCvSeq* cvHaarDetectObjects( \\par const CvArr* image,\\par CvHaarClassifierCascade* cascade,\\par CvMemStorage* storage,\\par double scaleFactor=1.1,\\par int minNeighbors=3,\\par int flags=0,\\par CvSize minSize=cvSize(0, 0),\\par CvSize maxSize=cvSize(0,0) );\n}\\cvdefPy{HaarDetectObjects(image,cascade,storage,scaleFactor=1.1,minNeighbors=3,flags=0,minSize=(0,0))-> detected\\_objects}\n\n\\begin{description}\n\\cvarg{image}{Image to detect objects in}\n\\cvarg{cascade}{Haar classifier cascade in internal representation}\n\\cvarg{storage}{Memory storage to store the resultant sequence of the object candidate rectangles}\n\\cvarg{scaleFactor}{The factor by which the search window is scaled between the subsequent scans, 1.1 means increasing window by 10\\% }\n\\cvarg{minNeighbors}{Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than \\texttt{min\\_neighbors}-1 are rejected. If \\texttt{minNeighbors} is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure}\n\\cvarg{flags}{Mode of operation. Currently the only flag that may be specified is \\texttt{CV\\_HAAR\\_DO\\_CANNY\\_PRUNING}. If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing}\n\\cvarg{minSize}{Minimum window size. By default, it is set to the size of samples the classifier has been trained on ($\\sim 20\\times 20$ for face detection)}\n\\cvarg{maxSize}{Maximum window size to use. By default, it is set to the size of the image.}\n\\end{description}\n\nThe function finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles. The function scans the image several times at different scales (see \\cvCPyCross{SetImagesForHaarClassifierCascade}). Each time it considers overlapping regions in the image and applies the classifiers to the regions using \\cvCPyCross{RunHaarClassifierCascade}. It may also apply some heuristics to reduce number of analyzed regions, such as Canny prunning. After it has proceeded and collected the candidate rectangles (regions that passed the classifier cascade), it groups them and returns a sequence of average rectangles for each large enough group. The default parameters (\\texttt{scale\\_factor} =1.1, \\texttt{min\\_neighbors} =3, \\texttt{flags} =0) are tuned for accurate yet slow object detection. For a faster operation on real video images the settings are: \\texttt{scale\\_factor} =1.2, \\texttt{min\\_neighbors} =2, \\texttt{flags} =\\texttt{CV\\_HAAR\\_DO\\_CANNY\\_PRUNING}, \\texttt{min\\_size} =\\textit{minimum possible face size} (for example, $\\sim$ 1/4 to 1/16 of the image area in the case of video conferencing).\n\n\\ifPy\nThe function returns a list of tuples, \\texttt{(rect, neighbors)}, where rect is a \\cross{CvRect} specifying the object's extents\nand neighbors is a number of neighbors.\n\n\\begin{lstlisting}\n>>> import cv\n>>> image = cv.LoadImageM(\"lena.jpg\", cv.CV_LOAD_IMAGE_GRAYSCALE)\n>>> cascade = cv.Load(\"../../data/haarcascades/haarcascade_frontalface_alt.xml\")\n>>> print cv.HaarDetectObjects(image, cascade, cv.CreateMemStorage(0), 1.2, 2, 0, (20, 20))\n[((217, 203, 169, 169), 24)]\n\\end{lstlisting}\n\\fi\n\n\\ifC\n% ===== Example. Using cascade of Haar classifiers to find objects (e.g. faces). =====\n\\begin{lstlisting}\n#include \"cv.h\"\n#include \"highgui.h\"\n\nCvHaarClassifierCascade* load_object_detector( const char* cascade_path )\n{\n    return (CvHaarClassifierCascade*)cvLoad( cascade_path );\n}\n\nvoid detect_and_draw_objects( IplImage* image,\n                              CvHaarClassifierCascade* cascade,\n                              int do_pyramids )\n{\n    IplImage* small_image = image;\n    CvMemStorage* storage = cvCreateMemStorage(0);\n    CvSeq* faces;\n    int i, scale = 1;\n\n    /* if the flag is specified, down-scale the input image to get a\n       performance boost w/o loosing quality (perhaps) */\n    if( do_pyramids )\n    {\n        small_image = cvCreateImage( cvSize(image->width/2,image->height/2), IPL_DEPTH_8U, 3 );\n        cvPyrDown( image, small_image, CV_GAUSSIAN_5x5 );\n        scale = 2;\n    }\n\n    /* use the fastest variant */\n    faces = cvHaarDetectObjects( small_image, cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING );\n\n    /* draw all the rectangles */\n    for( i = 0; i < faces->total; i++ )\n    {\n        /* extract the rectanlges only */\n        CvRect face_rect = *(CvRect*)cvGetSeqElem( faces, i );\n        cvRectangle( image, cvPoint(face_rect.x*scale,face_rect.y*scale),\n                     cvPoint((face_rect.x+face_rect.width)*scale,\n                             (face_rect.y+face_rect.height)*scale),\n                     CV_RGB(255,0,0), 3 );\n    }\n\n    if( small_image != image )\n        cvReleaseImage( &small_image );\n    cvReleaseMemStorage( &storage );\n}\n\n/* takes image filename and cascade path from the command line */\nint main( int argc, char** argv )\n{\n    IplImage* image;\n    if( argc==3 && (image = cvLoadImage( argv[1], 1 )) != 0 )\n    {\n        CvHaarClassifierCascade* cascade = load_object_detector(argv[2]);\n        detect_and_draw_objects( image, cascade, 1 );\n        cvNamedWindow( \"test\", 0 );\n        cvShowImage( \"test\", image );\n        cvWaitKey(0);\n        cvReleaseHaarClassifierCascade( &cascade );\n        cvReleaseImage( &image );\n    }\n\n    return 0;\n}\n\\end{lstlisting}\n\n\n\\cvCPyFunc{SetImagesForHaarClassifierCascade}\nAssigns images to the hidden cascade.\n\n\\cvdefC{\nvoid cvSetImagesForHaarClassifierCascade( \\par CvHaarClassifierCascade* cascade,\\par const CvArr* sum,\\par const CvArr* sqsum,\\par const CvArr* tilted\\_sum,\\par double scale );\n}\n\n\\begin{description}\n\\cvarg{cascade}{Hidden Haar classifier cascade, created by \\cvCPyCross{CreateHidHaarClassifierCascade}}\n\\cvarg{sum}{Integral (sum) single-channel image of 32-bit integer format. This image as well as the two subsequent images are used for fast feature evaluation and brightness/contrast normalization. They all can be retrieved from input 8-bit or floating point single-channel image using the function \\cvCPyCross{Integral}}\n\\cvarg{sqsum}{Square sum single-channel image of 64-bit floating-point format}\n\\cvarg{tilted\\_sum}{Tilted sum single-channel image of 32-bit integer format}\n\\cvarg{scale}{Window scale for the cascade. If \\texttt{scale} =1, the original window size is used (objects of that size are searched) - the same size as specified in \\cvCPyCross{LoadHaarClassifierCascade} (24x24 in the case of \\texttt{default\\_face\\_cascade}), if \\texttt{scale} =2, a two times larger window is used (48x48 in the case of default face cascade). While this will speed-up search about four times, faces smaller than 48x48 cannot be detected}\n\\end{description}\n\nThe function assigns images and/or window scale to the hidden classifier cascade. If image pointers are NULL, the previously set images are used further (i.e. NULLs mean \"do not change images\"). Scale parameter has no such a \"protection\" value, but the previous value can be retrieved by the \\cvCPyCross{GetHaarClassifierCascadeScale} function and reused again. The function is used to prepare cascade for detecting object of the particular size in the particular image. The function is called internally by \\cvCPyCross{HaarDetectObjects}, but it can be called by the user if they are using the lower-level function \\cvCPyCross{RunHaarClassifierCascade}.\n\n\\cvCPyFunc{ReleaseHaarClassifierCascade}\nReleases the haar classifier cascade.\n\n\\cvdefC{\nvoid cvReleaseHaarClassifierCascade( \\par CvHaarClassifierCascade** cascade );\n}\n\n\\begin{description}\n\\cvarg{cascade}{Double pointer to the released cascade. The pointer is cleared by the function}\n\\end{description}\n\nThe function deallocates the cascade that has been created manually or loaded using \\cvCPyCross{LoadHaarClassifierCascade} or \\cvCPyCross{Load}.\n\n\\cvCPyFunc{RunHaarClassifierCascade}\nRuns a cascade of boosted classifiers at the given image location.\n\n\\cvdefC{\nint cvRunHaarClassifierCascade( \\par CvHaarClassifierCascade* cascade,\\par CvPoint pt,\\par int start\\_stage=0 );\n}\n\n\\begin{description}\n\\cvarg{cascade}{Haar classifier cascade}\n\\cvarg{pt}{Top-left corner of the analyzed region. Size of the region is a original window size scaled by the currenly set scale. The current window size may be retrieved using the \\cvCPyCross{GetHaarClassifierCascadeWindowSize} function}\n\\cvarg{start\\_stage}{Initial zero-based index of the cascade stage to start from. The function assumes that all the previous stages are passed. This feature is used internally by \\cvCPyCross{HaarDetectObjects} for better processor cache utilization}\n\\end{description}\n\nThe function runs the Haar classifier\ncascade at a single image location. Before using this function the\nintegral images and the appropriate scale (window size) should be set\nusing \\cvCPyCross{SetImagesForHaarClassifierCascade}. The function returns\na positive value if the analyzed rectangle passed all the classifier stages\n(it is a candidate) and a zero or negative value otherwise.\n\n\\fi\n\n\\fi\n\n\\ifCpp\n\n\\cvclass{FeatureEvaluator}\nBase class for computing feature values in cascade classifiers.\n\n\\begin{lstlisting}\nclass CV_EXPORTS FeatureEvaluator\n{\npublic:    \n    enum { HAAR = 0, LBP = 1 }; // supported feature types \n    virtual ~FeatureEvaluator(); // destructor\n    virtual bool read(const FileNode& node);\n    virtual Ptr<FeatureEvaluator> clone() const;\n    virtual int getFeatureType() const;\n    \n    virtual bool setImage(const Mat& img, Size origWinSize);\n    virtual bool setWindow(Point p);\n\n    virtual double calcOrd(int featureIdx) const;\n    virtual int calcCat(int featureIdx) const;\n\n    static Ptr<FeatureEvaluator> create(int type);\n};\n\\end{lstlisting}\n\n\\cvCppFunc{FeatureEvaluator::read}\nReads parameters of the features from a FileStorage node.\n\n\\cvdefCpp{\nbool FeatureEvaluator::read(const FileNode\\& node);\n}\n\n\\begin{description}\n\\cvarg{node}{File node from which the feature parameters are read.}\n\\end{description}\n\n\\cvCppFunc{FeatureEvaluator::clone}\nReturns a full copy of the feature evaluator.\n\n\\cvdefCpp{\nPtr<FeatureEvaluator> FeatureEvaluator::clone() const;\n}\n\n\\cvCppFunc{FeatureEvaluator::getFeatureType}\nReturns the feature type (HAAR or LBP for now).\n\n\\cvdefCpp{\nint FeatureEvaluator::getFeatureType() const;\n}\n\n\\cvCppFunc{FeatureEvaluator::setImage}\nSets the image in which to compute the features.\n\n\\cvdefCpp{\nbool FeatureEvaluator::setImage(const Mat\\& img, Size origWinSize);\n}\n\n\\begin{description}\n\\cvarg{img}{Matrix of type  \\texttt{CV\\_8UC1} containing the image in which to compute the features.}\n\\cvarg{origWinSize}{Size of training images.}\n\\end{description}\n\n\\cvCppFunc{FeatureEvaluator::setWindow}\nSets window in the current image in which the features will be computed (called by \\cvCppCross{CascadeClassifier::runAt}).\n\n\\cvdefCpp{\nbool FeatureEvaluator::setWindow(Point p); \n}\n\n\\begin{description}\n\\cvarg{p}{The upper left point of window in which the features will be computed. Size of the window is equal to size of training images.}\n\\end{description}\n\n\\cvCppFunc{FeatureEvaluator::calcOrd}\nComputes value of an ordered (numerical) feature.\n\n\\cvdefCpp{\ndouble FeatureEvaluator::calcOrd(int featureIdx) const;\n}\n\n\\begin{description}\n\\cvarg{featureIdx}{Index of feature whose value will be computed.}\n\\end{description}\nReturns computed value of ordered feature.\n\n\\cvCppFunc{FeatureEvaluator::calcCat}\nComputes value of a categorical feature.\n\n\\cvdefCpp{\nint FeatureEvaluator::calcCat(int featureIdx) const;\n}\n\n\\begin{description}\n\\cvarg{featureIdx}{Index of feature whose value will be computed.}\n\\end{description}\nReturns computed label of categorical feature, i.e. value from [0,... (number of categories - 1)].\n\n\\cvCppFunc{FeatureEvaluator::create}\nConstructs feature evaluator.\n\n\\cvdefCpp{\nstatic Ptr<FeatureEvaluator> FeatureEvaluator::create(int type);\n}\n\n\\begin{description}\n\\cvarg{type}{Type of features evaluated by cascade (HAAR or LBP for now).}\n\\end{description}\n\n\\cvclass{CascadeClassifier}\nThe cascade classifier class for object detection.\n\n\\begin{lstlisting}\nclass CascadeClassifier\n{\npublic:\n\t// structure for storing tree node\n    struct CV_EXPORTS DTreeNode \n    {\n        int featureIdx; // feature index on which is a split\n        float threshold; // split threshold of ordered features only\n        int left; // left child index in the tree nodes array\n        int right; // right child index in the tree nodes array\n    };\n    \n    // structure for storing desision tree\n    struct CV_EXPORTS DTree \n    {\n        int nodeCount; // nodes count\n    };\n    \n    // structure for storing cascade stage (BOOST only for now)\n    struct CV_EXPORTS Stage\n    {\n        int first; // first tree index in tree array\n        int ntrees; // number of trees\n        float threshold; // treshold of stage sum\n    };\n    \n    enum { BOOST = 0 }; // supported stage types\n    \n    // mode of detection (see parameter flags in function HaarDetectObjects)\n    enum { DO_CANNY_PRUNING = CV_HAAR_DO_CANNY_PRUNING,\n           SCALE_IMAGE = CV_HAAR_SCALE_IMAGE,\n           FIND_BIGGEST_OBJECT = CV_HAAR_FIND_BIGGEST_OBJECT,\n           DO_ROUGH_SEARCH = CV_HAAR_DO_ROUGH_SEARCH }; \n\n    CascadeClassifier(); // default constructor\n    CascadeClassifier(const string& filename);\n    ~CascadeClassifier(); // destructor\n    \n    bool empty() const;\n    bool load(const string& filename);\n    bool read(const FileNode& node);\n\n    void detectMultiScale( const Mat& image, vector<Rect>& objects, \n                           double scaleFactor=1.1, int minNeighbors=3, \n\t\t\t\t\t\t   int flags=0, Size minSize=Size());\n    \n    bool setImage( Ptr<FeatureEvaluator>&, const Mat& );\n    int runAt( Ptr<FeatureEvaluator>&, Point );\n\n    bool is_stump_based; // true, if the trees are stumps\n\n    int stageType; // stage type (BOOST only for now)\n    int featureType; // feature type (HAAR or LBP for now)\n    int ncategories; // number of categories (for categorical features only) \n    Size origWinSize; // size of training images\n    \n    vector<Stage> stages; // vector of stages (BOOST for now)\n    vector<DTree> classifiers; // vector of decision trees\n    vector<DTreeNode> nodes; // vector of tree nodes\n    vector<float> leaves; // vector of leaf values\n    vector<int> subsets; // subsets of split by categorical feature\n\n    Ptr<FeatureEvaluator> feval; // pointer to feature evaluator\n    Ptr<CvHaarClassifierCascade> oldCascade; // pointer to old cascade\n};\n\\end{lstlisting}\n\n\\cvCppFunc{CascadeClassifier::CascadeClassifier}\nLoads the classifier from file.\n\n\\cvdefCpp{\nCascadeClassifier::CascadeClassifier(const string\\& filename);\n}\n\n\\begin{description}\n\\cvarg{filename}{Name of file from which classifier will be load.}\n\\end{description}\n\n\\cvCppFunc{CascadeClassifier::empty}\nChecks if the classifier has been loaded or not.\n\n\\cvdefCpp{\nbool CascadeClassifier::empty() const;\n}\n\n\\cvCppFunc{CascadeClassifier::load}\nLoads the classifier from file. The previous content is destroyed.\n\n\\cvdefCpp{\nbool CascadeClassifier::load(const string\\& filename);\n}\n\n\\begin{description}\n\\cvarg{filename}{Name of file from which classifier will be load. File may contain as old haar classifier (trained by haartraining application) or new cascade classifier (trained traincascade application).}\n\\end{description}\n\n\\cvCppFunc{CascadeClassifier::read}\nReads the classifier from a FileStorage node. File may contain a new cascade classifier (trained traincascade application) only.\n\n\\cvdefCpp{\nbool CascadeClassifier::read(const FileNode\\& node);\n}\n\n\\cvCppFunc{CascadeClassifier::detectMultiScale}\nDetects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.\n\n\\cvdefCpp{\nvoid CascadeClassifier::detectMultiScale( const Mat\\& image,\n                           vector<Rect>\\& objects,\n                           double scaleFactor=1.1,\n                           int minNeighbors=3, int flags=0,\n                           Size minSize=Size());\n}\n\n\\begin{description}\n\\cvarg{image}{Matrix of type  \\texttt{CV\\_8U} containing the image in which to detect objects.}\n\\cvarg{objects}{Vector of rectangles such that each rectangle contains the detected object.}\n\\cvarg{scaleFactor}{Specifies how much the image size is reduced at each image scale.}\n\\cvarg{minNeighbors}{Speficifes how many neighbors should each candiate rectangle have to retain it.}\n\\cvarg{flags}{This parameter is not used for new cascade and have the same meaning for old cascade as in function cvHaarDetectObjects.}\n\\cvarg{minSize}{The minimum possible object size. Objects smaller than that are ignored.}\n\\end{description}\n\n\\cvCppFunc{CascadeClassifier::setImage}\nSets the image for detection (called by detectMultiScale at each image level).\n\n\\cvdefCpp{\nbool CascadeClassifier::setImage( Ptr<FeatureEvaluator>\\& feval, const Mat\\& image );\n}\n\n\\begin{description}\n\\cvarg{feval}{Pointer to feature evaluator which is used for computing features.}\n\\cvarg{image}{Matrix of type  \\texttt{CV\\_8UC1} containing the image in which to compute the features.}\n\\end{description}\n\n\\cvCppFunc{CascadeClassifier::runAt}\nRuns the detector at the specified point (the image that the detector is working with should be set by setImage).\n\n\\cvdefCpp{\nint CascadeClassifier::runAt( Ptr<FeatureEvaluator>\\& feval, Point pt );\n}\n\n\\begin{description}\n\\cvarg{feval}{Feature evaluator which is used for computing features.}\n\\cvarg{pt}{The upper left point of window in which the features will be computed. Size of the window is equal to size of training images.}\n\\end{description}\nReturns:\n1 - if cascade classifier detects object in the given location.\n-si - otherwise. si is an index of stage which first predicted that given window is a background image.\n\n\\cvCppFunc{groupRectangles}\nGroups the object candidate rectangles\n\n\\cvdefCpp{void groupRectangles(vector<Rect>\\& rectList,\\par\n                     int groupThreshold, double eps=0.2);}\n\\begin{description}\n\\cvarg{rectList}{The input/output vector of rectangles. On output there will be retained and grouped rectangles}\n\\cvarg{groupThreshold}{The minimum possible number of rectangles, minus 1, in a group of rectangles to retain it.}\n\\cvarg{eps}{The relative difference between sides of the rectangles to merge them into a group}\n\\end{description}\n\nThe function is a wrapper for a generic function \\cvCppCross{partition}. It clusters all the input rectangles using the rectangle equivalence criteria, that combines rectangles that have similar sizes and similar locations (the similarity is defined by \\texttt{eps}). When \\texttt{eps=0}, no clustering is done at all. If $\\texttt{eps}\\rightarrow +\\inf$, all the rectangles will be put in one cluster. Then, the small clusters, containing less than or equal to \\texttt{groupThreshold} rectangles, will be rejected. In each other cluster the average rectangle will be computed and put into the output rectangle list.  \n\\fi\n", "meta": {"hexsha": "2698694cc2eb5c2c40453f90c70a515bc876e54a", "size": 28075, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "to/lang/OpenCV-2.2.0/doc/objdetect.tex", "max_stars_repo_name": "eirTony/INDI1", "max_stars_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "to/lang/OpenCV-2.2.0/doc/objdetect.tex", "max_issues_repo_name": "eirTony/INDI1", "max_issues_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2016-11-24T10:46:39.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-10T07:24:15.000Z", "max_forks_repo_path": "to/lang/OpenCV-2.2.0/doc/objdetect.tex", "max_forks_repo_name": "eirTony/INDI1", "max_forks_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.8671875, "max_line_length": 1201, "alphanum_fraction": 0.7479252004, "num_tokens": 6756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.40796686388673525}}
{"text": "\\documentclass[a4paper,10pt,hidelinks]{article}\n\n\\usepackage[margin=2cm]{geometry}\n\n\\usepackage{tikz}\n\\usepackage{hyperref}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\usepackage{listings}\n\\lstset{\n\tnumbers=left,\n\tbreaklines=true,\n\ttabsize=4\n}\n\n\\newcommand{\\algorithmautorefname}{Algorithm}\n\n%opening\n\\title{Practical Assignment 2\\\\\nSocial Network Analysis}\n\\author{Bert Peters\\\\\ns1147919}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Clustering Coefficient}\n\n\\begin{enumerate}\n\t\\item A tree, by definition, has no loops, and therefore has a clustering coefficient of 0. Another example is a bipartite graph. This type of graph can only have cycles of at least length 4. This is because it is impossible for two edges in the same partition to have a connection. Cycles of length 4 do not contribute to the clustering coefficient, because that only counts the number of triangles, i.e. the number of cycles of length 3.\n\n\t\\item There are several possible such graphs. One of them is shown in \\autoref{fig:graph-no-clustering}.\n\n\t\\item Contructing an unclustered graph is trivial for when $m \\leq n$, because we can construct a circle graph of size $n$ and remove edges to arrive at the desired number of edges. The algorithm is shown in \\autoref{algo:algo-no-clustering} and runs in $O(m)$.\n\n\t\tThe algorithm works by adding repeatedly connecting each node $v_i$ to another node $v_{i + \\delta}$. This delta is increased over iterations, and is given by $\\delta = 3^s$ where $s$ is the current iteration number, starting at 1. This ensures that we do not create new loops shorter than 4, which is what we need in order to prevent clustering.\n\\end{enumerate}\n\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}[every node/.style={draw=black,thick,circle}]\n\t\t\\node (A) at (0,4){A};\n\t\t\\node (B) at (-2,2){B};\n\t\t\\node (C) at (0,2){C};\n\t\t\\node (D) at (2,2){D};\n\t\t\\node (E) at (-2,0){E};\n\t\t\\node (F) at (0,0){F};\n\t\t\\node (G) at (2,0){G};\n\t\t\\node (H) at (-2,-2){H};\n\t\t\\node (I) at (0,-2){I};\n\t\t\\node (J) at (2,-2){J};\n\n\t\t\\draw (A) -- (C);\n\t\t\\draw (B) -- (C);\n\t\t\\draw (C) -- (D);\n\t\t\\draw (B) -- (E);\n\t\t\\draw (C) -- (F);\n\t\t\\draw (E) -- (F);\n\t\t\\draw (D) -- (G);\n\t\t\\draw (F) -- (G);\n\t\t\\draw (E) -- (H);\n\t\t\\draw (H) -- (I);\n\t\t\\draw (F) -- (I);\n\t\t\\draw (I) -- (J);\n\t\t\\draw (G) -- (J);\n\n\t\t\\draw (B) -- (G);\n\t\t\\draw (D) -- (E);\n\n\t\t\\draw (E) -- (J);\n\t\t\\draw (G) -- (H);\n\n\t\\end{tikzpicture}\n\t\\caption{An undirected graph with 10 nodes, 15 edges, and a clustering coefficient of 0.}\n\t\\label{fig:graph-no-clustering}\n\\end{figure}\n\n\\begin{algorithm}\n\t\\caption{Constructing a graph with no clustering.}\n\t\\label{algo:algo-no-clustering}\n\n\t\\begin{algorithmic}\n\t\t\\State $E \\gets \\emptyset$\n\t\t\\State $s \\gets 1$\n\t\t\\While{$|E| < m \\land 3^s < n$}\n\t\t\\For{$v_i \\in V \\land |E| < m$}\n\t\t\\State $E \\gets E \\cup \\{\\{v_i, v_{i + 3^s \\text{ mod } n} \\}\\}$\n\t\t\\EndFor\n\t\t\\State $s \\gets s + 1$\n\t\t\\EndWhile\n\t\\end{algorithmic}\n\n\\end{algorithm}\n\n\\section{Densest Subgraph}\n\nWe start by computing the average degree and the current density. For a graph with a given $n, m$ this is easy, because the average degree is $\\frac{2m}{n}$ and the density is half of that. We run our algortihm, by iteratively removing the nodes with a degree lower than the average degree from our $V$ and $E$, and repeat the process until we cannot delete nodes anymore.\n\nUsing the above algorithm, we arrive at the results as shown in \\autoref{tab:densest-subgraph}. We see that after iteration 1, we already find our maximum, with a density of 1.5. After that, we still delete nodes twice, until we arrive at a graph with two nodes and cannot delete nodes any more.\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{r || l | r | r}\n\t\tIteration & Subgraph & Density & Avg. degree\\\\\n\t\t\\hline\n\t\t0   & $\\{A B C D E F H I J K L\\}$ & $\\frac{16}{11} \\approx 1.45 $ & $\\frac{32}{11} \\approx 2.9 $ \\\\\n\t\t1   & $\\{A B E F J K\\}$ & $ \\frac{9}{6} = 1.5 $ & $ \\frac{18}{6} = 3 $ \\\\\n\t\t2   & $\\{B E F J\\}$ & $\\frac{5}{4} = 1.25$ & $\\frac{10}{4} = 2.5$ \\\\\n\t\t3   & $\\{E F\\}$ & $\\frac{1}{2} = 0.5$ & $\\frac{2}{2} = 1$\n\t\\end{tabular}\n\t\\caption{Using the greedy algorithm to find the densest subgraph.}\n\t\\label{tab:densest-subgraph}\n\\end{table}\n\n\\section{Twitter Network Extraction}\n\n\\subsection{Parsing the tweets}\n\nWe parse the tweets using a python script in \\autoref{lst:preprocess}. It takes a list of files as arguments from the command line or data from the standard input. First, it splits the string twice on the first occurrence of a tab. It attempts to parse mentions out of a tweet using a regular expression. The expression used is a non-word character\\footnote{A word character is defined as either an ascii letter character (upper case and lower case), a digit, or an underscore character (`\\texttt{\\_}'). Everything else, including the `\\texttt{\\^}' (start of string) and `\\texttt{\\$}' (end of string) metacharacters is considered a non-word character.}, followed by an `\\texttt{@}', followed by $[1, 15]$ word characters\\footnote{The specification of what is a valid twitter username can be found at \\url{https://support.twitter.com/articles/101299}}, followed by by a non-word character. Requiring a non-word character before the mention filters out email addresses, which occur frequently in the dataset. The resulting usernames are put in lowercase, because twitter usernames are case-insensitive.\n\nThe script determines a mapping from usernames to integers, because this is more convenient to handle programmatically in the analysis. It outputs a Gephi-edgelist compatible list of mentions to the standard output, and a Gephi-nodelist compatible username mapping to the standard error.\n\nThere are still a number of things that the parser does wrong. The most prevalent error happens when users have no separator (either white space or punctuation) between a mention and the following text. In this case, it is impossible to determine where the username ends and the tweet continues. This can only be solved when you know all usernames in your dataset.\n\nThis problems described above can, however, be solved by using the twitter api. It provides any mentions included in a message as meta data, removing the need for complicated parsers. Implementing this is outside the scope of this assignment.\n\n\\subsection{Dataset statistics}\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{l || r | r | c | r | r | c | r}\n\t\t\\multicolumn{1}{c ||}{Dataset} & \\multicolumn{1}{c |}{$|V|$} & \\multicolumn{1}{c |}{$|E|$} & $D$ & \\multicolumn{1}{c |}{$|V_{giant}|$} & \\multicolumn{1}{c |}{$|E_{giant}|$} & $D_{giant}$ & Diameter\\\\\n\t\t\\hline\n\t\t\\texttt{twitter-small} & 47568 & 53449 & $2.4 \\cdot 10^{-5}$ & 32351 & 44135 & $4.2 \\cdot 10^{-5}$ & 21 \\\\\n\t\t\\texttt{twitter-larger} & 398388 & 691080 & $4.4 \\cdot 10^{-6}$ & 328358 & 648832 & $6.0 \\cdot 10^{-6}$ & 23 \\\\\n\t\t\\texttt{twitter} & 8663906 & 57959449 & $7.7 \\cdot  10^{-7}$ & 8402847 & 57813254 & $8.2 \\cdot 10^{-7}$ & ?\n\t\\end{tabular}\n\t\\caption{Dataset statistics}\n\t\\label{tab:dataset-stats}\n\\end{table}\n\nWe consider the graph as an undirected graph. We use our parser program to get some statistics about our dataset. The results are shown in \\autoref{tab:dataset-stats}. For the degree distribution, we reuse the python script from the previous assignment. This gives us the distribution as shown in \\autoref{fig:graph-no-clustering}.\n\nEdges occurring multiple times are counted towards node degrees, but not towards the number of edges. In other words, the equation $\\sum\\limits_{v_i} k(v_i) = 2|V|$ does not hold.\n\nFor density, we take the measure $D = \\frac{|V|}{|E|(|E| - 1)}$. Since, in a social network, the average degree does not depend on the number of nodes in the network, we we expect the density to drop linearly with the number of nodes. This is because $\\lim_{n \\rightarrow \\infty} \\frac{cn}{n (n - 1)} = \\frac{1}{n}$. Furthermore, there should be a slightly lower  density in the entire network and that in the giant component. This is because the network contains a lot of isolated nodes, i.e. people that have tweeted, but not mentioned, and who have not been mentioned.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[scale=0.8]{degree-distributions.pdf}\n\t\\caption{Degree distribution for all datasets.}\n\t\\label{fig:degree-distributions}\n\\end{figure}\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[scale=0.8]{distance-distribution}\n\t\\caption{Approximate distance distributions for all datasets. Bars are relative within one dataset.}\n\t\\label{fig:distance-distributions}\n\\end{figure}\n\nIt is infeasible to compute the exact distance distribution for all networks, as this requires computing $\\frac{1}{2} n (n-1)$ distances. To do so would require $O(nm)$ time, to perform $n$ breadth first searches. Instead, we use an approximation. For this, we perform 100 breadth first searches and count how often each distance occurs. We then normalize by dividing by the total number of paths found, and arrive at the distribution as shown in \\autoref{fig:distance-distributions}.\n\n\\subsection{Top Twitter users}\nTo compute the top 20 twitter users in our dataset, we consider the following centrality measures:\n\n\\begin{description}\n\t\\item[Degree centrality] which is simply the degree of the node. For this experiment, we use the the out degree of a node for this. We then sort the nodes in descending order. We define it as $DC(u) = \\max(\\forall v \\in V : k^\\rightarrow(v))$.\n\n\t\\item[Eccentricity centrality] which is the longest shortest path starting from a node. The idea is, that if your eccentricity is low, you are fairly central. It is defined as $EC(u) = \\max(\\forall v \\in V : d(u, v))$.\n\n\t\\item[Closeness centrality] which is somewhat related to the eccentricity centrality, but is slightly different, because we take the average path length rather than the total path length. This gives us $CC(u) = \\frac{\\sum_{v \\neq u \\in V}}{|V| - 1}$.\n\\end{description}\n\nWe then apply these measures to the \\texttt{twitter-small} dataset. The results are shown in \\autoref{tab:small-top-users}. For eccentricity, there are quite a few nodes with the same value.\\footnote{This can be easily seen by observing that the $\\forall u \\in V: ecc(u) \\leq \\text{diameter}(G) \\land ecc(u) \\in \\mathbb{N}$ by definition. This means that we do not have a lot of distinct values the eccentricity can take.} In this case, we use degree as a tie-breaker.\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{l || l | l | l}\n\t\t& \\multicolumn{1}{c |}{$DC$} & \\multicolumn{1}{c |}{$EC$} & \\multicolumn{1}{c}{$CC$} \\\\\n\t\t\\hline\n\t\t1 & theiphoneblog & mashable & theiphoneblog \\\\\n\t\t2 & ryanbarr & theiphoneblog & mashable\\\\\n\t\t3 & mashable & ryanbar & tweetmeme\\\\\n\t\t4 & scottbourne & scottbourne & iphone\\_dev\\\\\n\t\t5 & scancafe & scancafe & tweetdeck\\\\\n\t\t6 & squarespace & squarespace & allthingsiphone \\\\\n\t\t7 & tweetmeme & tweetmeme & techcrunch \\\\\n\t\t8 & iphone\\_dev & iphone\\_dev & squarespace \\\\\n\t\t9 & tweetdeck & tweetdeck & kevinrose\\\\\n\t\t10 & kevinrose & kevinrose & randomslagathor \\\\\n\t\t11 & tomtom & techcrunch & musclenerd \\\\\n\t\t12 & techcrunch & engadget & engadget \\\\\n\t\t13 & patrickaltoft & iphoneincanada & scottbourne \\\\\n\t\t14 & iphoneincanada & tuaw & tuaw \\\\\n\t\t15 & quickpwn & guykawasaki & scancafe \\\\\n\t\t16 & engadget & musclenerd & iphoneincanada \\\\\n\t\t17 & tinteract &  chrispirillo & razorianfly \\\\\n\t\t18 & tuaw & parislemon & djsakebomb \\\\\n\t\t19 & guardiantech & trackle & reneritchie \\\\\n\t\t20 & igncom & johnbiggs & tmitechnews\n\t\\end{tabular}\n\t\\caption{Top 20 users in \\texttt{twitter-small} according to different measures.}\n\t\\label{tab:small-top-users}\n\\end{table}\n\nWe can not easily and objectively compare these rankings on quality, but we can numerically compare how different they are. We do this by counting inversions. This can be done in $O(l^2)$, with $l$ the number of items in our list. This is fairly doable for a top 20. Also, we have to account for nodes that are in one, but not in the other list. For this, we count it as an inversion against everything else, which means it has $l$ inversions.\n\nWhen we take a look at the resulting top-users in \\autoref{tab:small-top-users}, we can see that all three centrality measures are somewhat in agreement over the top users. This is not unexpected, as all three measures used for determining the rankings are somewhat correlated. For example, having a low eccentricity helps to get a lower closeness, and your closeness is very much influenced by your own outdegree.\n\n\\subsection{Community detection}\nWe attempt to detect the communities using Gephi. Ideally, we are looking for about 12 communities, as a lower amount would provide very little information and a higher amount would not be visually interprable. When setting the resolution to 1.0, we get thousands of communities. When we set it to 10.0, we find only 4 communities. Halfway in between at 5.0 we find 14 communities, which can be roughly interpreted as some subject on which users tweet.\n\n\\subsection{Visualisation}\nTo visualise the giant component of the \\texttt{twitter-small} network, we use Gephi. Using the community detection described in the previous section, we color the nodes. Furthermore, we scale the nodes according to their betweenness centrality. The resulting network can be seen in \\autoref{fig:visualisation}. While improving upon this visualisation, Gephi gave up, so I gave up on visualising.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[scale=0.8]{visualisation.pdf}\n\t\\caption{Visualisation of the \\texttt{twitter-small} network. Colors are according to communities, and node size is proportional to betweenness centrality.}\n\t\\label{fig:visualisation}\n\\end{figure}\n\n\\subsection{Analysing the \\texttt{twitter-larger} dataset}\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{l || l | l | l}\n\t\t& \\multicolumn{1}{c |}{$DC$} & \\multicolumn{1}{c |}{$EC$} & \\multicolumn{1}{c}{$CC$} \\\\\n\t\t\\hline\n\t\t1 & uberguineapig & uberguineapig & uberguineapig \\\\\n\t\t2 & mobil\\_tipps & mobil\\_tipps & mashable\\\\\n\t\t3 & dloblack & iphone\\_mob & iphone\\_mob \\\\\n\t\t4 & iphonedevnews & muenchner\\_kindl & techcrunch \\\\\n\t\t5 & iphone\\_nikki & iphone\\_jedi & tweetmeme \\\\\n\t\t6 & macandiphone & maclounge & startonlinetwit \\\\\n\t\t7 & riggledo & botiphone & razorianfly \\\\\n\t\t8 & muenchner\\_kindl & savvybanana & sebastianpage \\\\\n\t\t9 & danlaforce & ezf\\_executives & tuaw \\\\\n\t\t10 & iphone\\_jedi & kaisersoeze & muenchner\\_kindl \\\\\n\t\t11 & tm\\_iphone & tommytrc & dudeman718 \\\\\n\t\t12 & allthingsiphone & magicbaseball1 & tm\\_iphone \\\\\n\t\t13 & inflight\\_wifi & flipbooks & topiphone \\\\\n\t\t14 & ipodtouchroom & jwforson & krapps \\\\\n\t\t15 & esteves08 & the\\_borg & mayhemstudios \\\\\n\t\t16 & supsappel & bildarchiv & kaisersoeze \\\\\n\t\t17 & iphone3gupdates & shellykramer & theiphoneblog \\\\\n\t\t18 & tramain360 & randomslagathor & bradgal \\\\\n\t\t19 & csrandom & appgirlreviews & scobleizer \\\\\n\t\t20 & locaconpistolas & earthxplorer & tm\\_technology\n\t\\end{tabular}\n\t\\caption{Top 20 users in \\texttt{twitter-larger} according to different measures.}\n\t\\label{tab:larger-top-users}\n\\end{table}\n\nSince we use our own parser (see appendices) we can quite easily run the statistics on the \\texttt{twitter-larger} dataset. The results are incorporated in \\autoref{tab:dataset-stats}, \\autoref{fig:degree-distributions}, and \\autoref{fig:distance-distributions}. Furthermore, we can compute the eccentricity for every node exactly using the algorithm by F.W. Takes et al. and arrive at the eccentricity for each node in approximately 17,000 breadth first searches. This is about 20 times faster than the naive approach.\n\nThe closeness centrality is a bit more challenging to compute. Instead, we approximate it by sampling the distance between 10,000 randomly selected nodes and everything else, and averaging those results.\\footnote{While this method is a lot of work, it is doable in about an hour, while doing the entire computation would take slightly over a day.} As a slight bonus, calculating the eccentricities also gives us the diameter of the network, which is shown in \\autoref{tab:dataset-stats}. What is interesting, is that the diameter of \\texttt{twitter-larger} is only slightly greater than the diameter of \\texttt{twitter-small}, despite the former being about ten times smaller than the latter. This is a property often observed in social networks.\n\n\\subsection{Bonus: Analysing the complete \\texttt{twitter} dataset}\nOur \\texttt{C++} code is efficient enough to compute the dataset statistics in reasonable time while only needing 6 GiB of memory.\\footnote{The system used had an Intel i7 CPU running at 3.4 GHz and 16 GiB of memory, but only a single thread and 6 GiB of memory was used.} The data is shown in \\autoref{tab:dataset-stats}, \\autoref{fig:degree-distributions}, and \\autoref{fig:distance-distributions}. We used the same approximation of the distance distribution that we used for the other datasets, which took about 40 minutes to compute.\n\nWe can also still sample the network \n\nComputing all eccentricities however was more challenging. At the time of writing, we have spent over 21 hours of computation doing a total of 2,872 breadth first searches, with 1,302,102 eccentricities not yet known. This gives us an average of one BFS every 26 seconds. This, along with the observation that we find at least one eccentricity per search, gives us an upper bound of 391 days for the remaining computation. I therefore do not except a result to this. While I have observed a speed up of over 100 using the algorithm, I still do not expect to see a result before the deadline. Mostly because the system will be rebooted Sunday at 03:00, losing all my progress.\n\nIt could still be possible to compute the rankings, as the eccentricity bounds for most low eccentricity nodes become tight very quickly, and for other nodes the bounds are at least very close. Doing so is outside the scope of this project however.\n\n\\pagebreak\n\n\\appendix\n\n\\section{preprocess.py}\n\\label{lst:preprocess}\n\\lstinputlisting[language=python]{preprocess.py}\n\\pagebreak\n\n\\section{Makefile}\n\\lstinputlisting[language=make]{Makefile}\n\\pagebreak\n\n\\section{parser.cpp}\n\n\\lstinputlisting[language=c++]{parser.cpp}\n\n\\pagebreak\n\n\\section{TwitterGraph.hpp}\n\n\\lstinputlisting[language=c++]{TwitterGraph.hpp}\n\n\\pagebreak\n\n\\section{TwitterGraph.cpp}\n\n\\lstinputlisting[language=c++]{TwitterGraph.cpp}\n\n\\pagebreak\n\n\\section{eccentricity.cpp}\nThis file contains the method used to compute the eccentricity of all nodes and the diameter of the network. It is adapted from the presentation \\emph{Determining the Diameter of Small World Networks} by F.W. Takes and W.A. Kosters. The original presentation containing the algorithm can be found at \\url{http://liacs.leidenuniv.nl/~takesfw/SNACS/diameter.pdf}.\n\n\\lstinputlisting[language=c++]{eccentricity.cpp}\n\n\\pagebreak\n\n\\section{closeness.cpp}\n\nThis file contains the method used to approximate the closeness of a particular node.\n\n\\lstinputlisting[language=c++]{closeness.cpp}\n\\end{document}\n", "meta": {"hexsha": "1f8106ee2effa57d1a8279e09465c5763af26706", "size": 18896, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment2/report.tex", "max_stars_repo_name": "bertptrs/uni-snacs", "max_stars_repo_head_hexsha": "07b99185781de2e956989c2ebd26e03d3e798d2e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment2/report.tex", "max_issues_repo_name": "bertptrs/uni-snacs", "max_issues_repo_head_hexsha": "07b99185781de2e956989c2ebd26e03d3e798d2e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment2/report.tex", "max_forks_repo_name": "bertptrs/uni-snacs", "max_forks_repo_head_hexsha": "07b99185781de2e956989c2ebd26e03d3e798d2e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.7974683544, "max_line_length": 1100, "alphanum_fraction": 0.7336473328, "num_tokens": 5433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381667555714, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.40794266210813046}}
{"text": "\\chapter{The Formal Specification}\r\n\r\n\r\n\\section{Methodology}\r\nThe computer has been formally specified at the architectural level.\r\n The specification methodology used was {\\bf Lambda} \\cite{ahl:lambda}.\r\nDesigned especially \r\n for hardware specification, it is implemented as an ML \r\nbased system upon the Sun workstations. \r\nA semi-automated theorem prover  forms the \r\ncore of Lambda, which enables properties of specifications to be \r\nexamined, and reifications to be verified.\r\n\r\nThe system is designed to synthesise a working design from a \r\nbehavioural specification, by reifying the design until it \r\ndescribes individual components ---{\\em forward synthesis}.\r\n In such a way the correctness of a design \r\ncan be guaranteed without performing a verification. \r\nWritten in the language ML it has a similar syntax, but with extensions to the language.\r\nThis enables part of a specification to be executed as  ML functions,\r\nallowing the hardware's  properties to be simulated in software.\r\n\r\nThe  Lambda specification language is more powerful than an \r\nexecutable programming language. Rather than describing a function \r\nor procedure to convert from the input to the output, one just specifies  preconditions and\r\npostconditions. \r\n\r\n{\\samepage\r\nFor example, the function:-\r\n{\\tt\r\n\\begin{verbatim}\r\n        fun square_root (x:Natural) = iota y. y*y==x;\r\n\\end{verbatim}\r\n}\r\n\r\ndescribes the square root function in Lambda but not ML.\r\n}\r\nTiming constraints can also be included into {\\em rewrite rules}\r\n{\\tt\r\n\\begin{verbatim}\r\n        val sqrt_unit#(x,y)=\r\n                forall t.\r\n                     y (t+100) == square_root (x t);\r\n\\end{verbatim}\t\t\t\r\n}\r\nThis describes a combinatorial square root unit which outputs at time\r\nt+100 the square root of the input at time t.\r\n\r\nFunctional units can  be joined together by use of common variable bindings\r\n{\\tt\r\n\\begin{verbatim}\r\n        val double_sqrt_unit#(x,z)=\r\n              sqrt_unit(x,y) /\\ sqrt_unit(y,z);\t\t\r\n\\end{verbatim}\r\n}\r\nSuch functions, along with the definition of the types of the variables of X,Y and Z, can be parsed by  Lambda to produce an environment of rules.\r\nThese rules can be used to prove hypotheses, such as that the time for a double\\_sqrt\\_unit to evaluate an expression would take 200 units of time.\r\n\r\n\r\nThis system allows someone to specify any component  or module as a collection of related inputs and outputs.\r\nA number of components can  be linked together to form a larger module,\r\nor a complete design.\r\n\t\r\n%\\newpage\r\nUnfortunately, none of  the components I used had  \r\nbeen formally specified. While I  produced some specifications based on the informal specifications in the databooks their correctness  can never be guaranteed. \r\n\r\n\r\nSpecification from scratch is an extremely slow process, and I was not able to describe the whole computer in this depth in the time available.\r\n I  described the operation of the computer at a very high level, and then  expanded the description of the ALU to a greater depth.\r\n\r\n\\section {First Specification} \r\n\r\nMy first specification was based upon an example specification of a simple computer in the Lambda Manual.\r\nIt was written in a early version of Lambda, which had a syntax more complex than that of ML.\r\nFirst it was necessary to specify the types of data which the computer dealt with. \r\nAbstract datatypes of 15 and 32 bit integers were defined without giving their internal structure.\r\nAllowable \r\noperations ---comparison and addition for 15 bit numbers, all ALU \r\noperations for 32 bit numbers--- were stated as existing and being \r\ntotal. Their exact functions were not given.\r\n Random Access Memory \r\nwas then defined as a function of 15 bit addresses to  32 bit data words. \r\n\r\nThe computer can at any moment in time  be described by  the contents of every  register\r\nand  memory location.\r\n As an instruction is executed this state   changes,\r\nunless it is halted or in an infinite loop.\r\n\r\nThe state of the \r\ncomputer was described as a tuple of\r\n\\begin{verbatim}\r\n        <memory, execution unit state, alu state> \r\n\\end{verbatim}\r\nwhere the execution unit state was \r\n\\begin{verbatim}\r\n        <PC,X,Y,skip,halt>\r\n\\end{verbatim}\r\n    and the\r\nALU state was\r\n\\begin{verbatim}\r\n        <ACC,z,n,v,c>\r\n\\end{verbatim}\r\n \r\n\r\n The operation of the whole machine was  given as a transition from \r\nstate to state. \r\nEach transition was caused by the  execution of\r\n a single instruction.\r\nThe most complex part of this specification was the description of the read and write operations.\r\nThis was because of the memory mapping of registers.\r\nThe read function was supplied with the computer state and a 15 bit address to return a 32 bit integer. \r\nA separate function was used to validate the address prior to the read access.\r\nThe write function took as parameters a  state, an address and a new value, returning a new state. This allowed both registers and RAM to be updated.\r\n\r\nThe transition from one state to another during instruction execution was described by a function which  fetched the next instruction, and incremented the PC.\r\nIt then calculated the source  address and moved its contents to the  destination address.  \r\nIf the halt flag was set this function did nothing. \r\nBefore each read the address was validated ---any illegal access terminated the function and set the halt flag.\r\nIf the skip flag was set the program counter was merely incremented and the flag cleared; no instruction was executed.\r\n\r\nThis does actually resemble the actual process of instruction fetch\r\nand execute, except that the halt and skip flags do not actually\r\nexist. \r\nSkipping is performed by hard-wired logic, and the halt state is merely another state within the control unit's Moore Machine.\r\nThese differences are invisible to the user. \r\nAt this level the operation of the computer is being described, even if it differs slightly from the actual implementation.\r\n\r\n\r\n\\section{Second Specification}\r\n\r\nBy Christmas a new version of Lambda was available, with a syntax more  similar to ML. The design of the Ultimate RISC had become clearer, partly through the initial specification, but also as I  designed the ALU.\r\n\r\nI therefore upgraded the specification to support both the new notation and to be consistent with the revised design.\r\n\r\nThis was done by first expanding the 15-bit and 32-bit integer abstract data types to  boolean tuples, with functions for conversion between these representations and that of natural numbers.\r\n\r\nI then wrote all the operations performed by a 74381 ALU IC as \r\nfunctions acting upon boolean four-tuples. A general function was \r\nwritten to apply the operation selected by the control lines.\r\n The production of carry signals from the 74182 carry lookahead generators were \r\nalso specified. \r\nIn both cases the specifications were based upon  \r\ndata sheets from TI and AMD. \r\nIt was then possible to describe the ALU components by relating outputs as \r\nthe result of the functions applied upon the inputs of a previous time \r\n---the temporal difference being the propagation delay of the device.\r\n\r\nThe logic equations of the PALS were all specified likewise, enabling the \r\nentire combinatorial portion of the ALU to be accurately described.\r\n\r\nThe remainder of the specification was derived from the first  specification of the Ultimate RISC. \r\n \r\nI did not go about proving the two specifications were identical.  \r\nNor did I \r\n try to prove properties of the new specification, such as\r\nthe non-folding of \r\nRAM addresses and the persistence of data within. \r\n Given estimates of \r\nthe time to verify the correctness of specifications of other computers, \r\nthere would have been no possibility of both verifying the specifications and \r\nattempting to build anything.\r\nThe verification would probably  form a complete project, \r\nrequiring someone far more experienced in machine assisted proofs than myself.\r\nInstead I  produced a simulation, by modifying the specification  to  execute in ML.\r\n\r\n To enable my \r\nspecification to be executed I had to remove all instances of \r\npostconditions and timing constraints. \r\nThe other problem was `feedback'.\r\nThe 74381 units produce signals which are \r\npassed to the carry generators. These then  return a carry signals to be evaluated with the earlier inputs. \r\nThese were simulated by iterations of the functions.\r\n\r\nI also wrote a `monitor' for the simplified specification which provided a \r\nfront end for the simulation with facilities such as memory read/write, \r\ninstruction assembly and dissassembly, register manipulation and \r\nprogram execution. \r\n\r\nThere were  subtle differences between ML and Lambda. Notably ML's integers were more restricted than Lambda's type Natural.\r\n Both the Edinburgh SML and the faster New Jersey ML had only 32 bit signed integers, rendering conversion between these numbers and 32 bit boolean tuples difficult.\r\nThe specification only executed satisfactorily in PolyML,\r\nwhich was   prone to unannounced field upgrades, so that functions   available in February did not work in April.\r\n\r\n\r\n\r\n\\section{Summary}\r\n\r\nOverall the specification and simulation comprise \r\n 1400 lines, and are somewhat more difficult to understand at a \r\nglance than P-CAD circuit diagrams. Much of the code is devoted to \r\nmathematical and component definitions. For the success of hardware \r\nspecification languages I believe it will be necessary to produce \r\nlibraries of verified maths functions, components  and standard cells.\r\n\r\n It is not a complete specification of the hardware of the \r\n Ultimate RISC.\r\n For this the computer must be described as a collection \r\nof units, communicating via control signals and synchronised by a \r\nclock. \r\nThe time delays of all operations must be specified, along \r\nwith the ability of the host to control the clock and write to \r\nregisters. \r\n\r\nThe simulation has been used to test the operation of the ALU, \r\nespecially the programming of the PALS,  uncovering a couple \r\nof mistakes which could have proved  costly.\r\nIt also demonstrated that the carry flag had to be set prior to a subtraction,  a fact the compiler writer needed. \r\n\r\nWhile I have not performed any proofs, specifying the computer was a valuable exercise. \r\n Describing the machine at a high level, I was forced to consider many details which any other method of description would ignore;\r\n this clarified the hardware implementation. \r\n\r\nThe specification of an existing design did seem easier than the forward synthesis method for which Lambda aims to provide. \r\nForward synthesis should reduce the number of proofs required, and thus increase the speed of designing with formal methods.\r\n\r\nEven without the verification between levels, a specification which describes the computer is of use  describing the system to a software developer. \r\nFor this to be the case the software designers  need to be able to understand the notation. \r\nThis is an argument in favour of using a more widely known notation such as {\\bf Z}, which seems to be primarily for software development. \r\nIf programs were specified in the same notation as the hardware  the two would be able to be integrated in order to prove facts about the combined system.\r\n\r\nIdeally the specification should have been continued till every component was specified along with the interconnections.\r\nA netlist could have been extracted and sent to the BEPI machine for automated wiring, and the PAL and EPLD programs also generated.\r\nIf these processes could be at least partially automated, then the Lambda system could form the core of an an automated design and manufacture system.\r\nWithout such a system,   manual intervention ---whether P-Cad design or wire-wrapping--- introduces elements of risk. For the full benefit of formal methods the implementation must match the specification.\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "635231478d62628b29007832544a9ff336943a28", "size": 11842, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "papers/urisc/specification.tex", "max_stars_repo_name": "steveloughran/formality", "max_stars_repo_head_hexsha": "adb784eff346bfd9ac13db9589fbf233a41e7f16", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-02-03T22:45:45.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-11T08:00:28.000Z", "max_issues_repo_path": "papers/urisc/specification.tex", "max_issues_repo_name": "steveloughran/formality", "max_issues_repo_head_hexsha": "adb784eff346bfd9ac13db9589fbf233a41e7f16", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-06-29T15:52:11.000Z", "max_issues_repo_issues_event_max_datetime": "2015-06-30T18:38:04.000Z", "max_forks_repo_path": "papers/urisc/specification.tex", "max_forks_repo_name": "steveloughran/formality", "max_forks_repo_head_hexsha": "adb784eff346bfd9ac13db9589fbf233a41e7f16", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-05-08T14:23:34.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-11T08:00:30.000Z", "avg_line_length": 51.0431034483, "max_line_length": 214, "alphanum_fraction": 0.7752068907, "num_tokens": 2373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4079426541732935}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Copyright (c) 2003-2018 by The University of Queensland\n% http://www.uq.edu.au\n%\n% Primary Business: Queensland, Australia\n% Licensed under the Apache License, version 2.0\n% http://www.apache.org/licenses/LICENSE-2.0\n%\n% Development until 2012 by Earth Systems Science Computational Center (ESSCC)\n% Development 2012-2013 by School of Earth Sciences\n% Development from 2014 by Centre for Geoscience Computing (GeoComp)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Fault System}\n\\label{Fault System}\nThe \\class{FaultSystem} class provides an easy-to-use interface to handle 2D\nand 3D fault systems\\index{faults} as used for instance in simulating fault\nruptures. The main purpose of the class is to provide a parameterization of\nan individual fault in the system of faults.\nIn case of a 2D fault the fault is parameterized by a single value $w_{0}$ and\nin the case of a 3D fault two parameters $w_{0}$ and $w_{1}$ are used.\nThis parameterization can be used to impose data (e.g. a slip distribution)\nonto the fault. It can also be a useful tool to visualize or analyze the\nresults on the fault if the fault is not straight. \n\n\\begin{figure}\n\\centering\n\\includegraphics{FaultSystem2D}\n\\caption{\\label{FAULTSYSTEM2D}Two dimensional fault system with one fault\nnamed `t` in the $(x_{0},x_{1})$ space and its parameterization in the\n$w_{0}$ space. The fault has three segments.}\n\\end{figure}\n\nA fault $t$ in the fault system is represented by a starting point $V^{t0}$\nand series of directions, called strikes\\index{strike}, and the lengths $(l^{ti})$.\nThe strike of segment $i$ is defined by the angle $\\sigma^{ti}$ between the\n$x_{0}$-axis and the direction of the fault, see Figure~\\ref{FAULTSYSTEM2D}.\nThe length and strike defines the polyline $(V^{ti})$ of the fault by\n\\begin{equation}\nV^{ti} = V^{t(i-1)} + \nl^{ti} \\cdot  S^{ti}\n\\mbox{ with }\nS^{ti} =\n\\left[\n\\begin{array}{c}\n cos(\\sigma^{ti})  \\\\\n sin(\\sigma^{ti}) \\\\\n 0 \n\\end{array}\n\\right]\n\\label{eq:fault 00}\n\\end{equation}\nIn the 3D case each fault segment $i$ has an additional dip\\index{dip}\n$\\theta^{ti}$ and at each vertex $i$ a depth $\\delta^{ti}$ is given.\nThe fault segment normal $n^{ti}$ is given by\n\\begin{equation}\nn^{ti} = \n\\left[\n\\begin{array}{c}\n -sin(\\theta^{ti}) \\cdot S^{ti}_{1} \\\\\n sin(\\theta^{ti}) \\cdot S^{ti}_{0} \\\\\n cos(\\theta^{ti}) \n\\end{array}\n\\right]\n\\label{eq:fault 0}\n\\end{equation}\nAt each vertex we define a depth vector $d^{ti}$ defined as the intersect of\nthe fault planes of segment $(i-1)$ and $i$ where for the first segment and\nlast segment the vector orthogonal to strike vector $S^{ti}$\\index{strike}\nand the segment normal $n^{ti}$ is used. The direction $\\tilde{d}^{ti}$ of the\ndepth vector is given as\n\\begin{equation}\n\\tilde{d}^{ti} = n^{ti} \\times n^{t(i-1)}\n\\label{eq:fault b}\n\\end{equation}\nIf $\\tilde{d}^{ti}$ is zero the strike vectors $L^{t(i-1)}$ and $L^{ti}$ are\ncollinear and we can set $\\tilde{d}^{ti} = l^{ti} \\times n^{ti}$.\nIf the two fault segments are almost orthogonal $\\tilde{d}^{ti}$ is pointing\nin the direction of $L^{t(i-1)}$ and $L^{ti}$. In this case no depth can be\ndefined. So we will reject a fault system if\n\\begin{equation}\nmin(\\| \\tilde{d}^{ti}  \\times  L^{t(i-1)} \\|,\\| \\tilde{d}^{ti}  \\times  L^{ti} \\|) \n\\le 0.1 \\cdot \\| \\tilde{d}^{ti} | \n\\label{eq:fault c}\n\\end{equation}\nwhich corresponds to an angle of less than $10^o$ between the depth vector and\nthe strike. We then set\n\\begin{equation}\nd^{ti}=\\delta^{ti} \\cdot \\frac{\\tilde{d}^{ti}}{\\|\\tilde{d}^{ti}\\|}\n\\label{eq:fault d}\n\\end{equation}\nWe can then define the polyline $(v^{ti})$ for the bottom of the fault as\n\\begin{equation}\nv^{ti}= V^{ti}+d^{ti}\n\\label{eq:fault e}\n\\end{equation}\nIn order to simplify working on a fault $t$ in a fault system a\nparameterization $P^t: (w_{0},w_{1}) \\rightarrow (x_{0},x_{1},x_{2})$ over a\nrectangular domain is introduced such that\n\\begin{equation}\n0\\le w_{0} \\le w^t_{0 max} \\mbox{ and }  -w^t_{1max}\\le w_{1} \\le 0\n\\label{eq:fault 1}\n\\end{equation}\nwith positive numbers $w^t_{0 max}$ and $w^t_{1 max}$. Typically one chooses\n$w^t_{0 max}$ to be the unrolled length of the fault and $w^t_{1 max}$ to be\nthe mean value of segment depth. Moreover we have\n\\begin{equation}\nP^t(W^{ti})=V^{ti}\\mbox{ and } P^t(w^{ti})=v^{ti}\\\n\\label{eq:fault 2}\n\\end{equation}\nwhere\n\\begin{equation}\nW^{ti}=(\\Omega^{ti},0) \\mbox{ and } w^{ti}=(\\Omega^{ti},-w^t_{1 max})\n\\label{eq:fault 3}\n\\end{equation}\nand $\\Omega^{ti}$ is the unrolled distance of $W^{ti}$ from $W^{t0}$, i.e.\n$l^{ti}=\\Omega^{t(i+1)}-\\Omega^{ti}$. In the 2D case $w^t_{1 max}$ is set to\nzero and therefore the second component is dropped, see Figure~\\ref{FAULTSYSTEM2D}.\n\nIn the 2D case the parameterization $P^t$ is constructed as follows:\nThe line connecting $V^{t(i-1)}$ and $V^{ti}$ is given by\n\\begin{equation}\nx=V^{ti} + s  \\cdot  ( V^{t(i+1)}- V^{ti} )\n\\label{eq:2D line 1}\n\\end{equation}\nwhere $s$ is between $0$ and $1$. The point $x$ is on $i$-th fault segment if\nand only if such an $s$ exists. Assuming $x$ is on the fault it can be\ncalculated as\n\\begin{equation}\ns = \\frac{ (x- V^{ti})^t \\cdot (V^{t(i+1)}- V^{ti}) }{ \\|V^{t(i+1)}- V^{ti}\\|^2} \n\\label{eq:2D line 1b}\n\\end{equation}\nWe then can set\n\\begin{equation}\nw_{0}=\\Omega^{ti}+s \\cdot (\\Omega^{ti}-\\Omega^{t(i-1)})\n\\label{eq:2D line 2}\n\\end{equation}\nto get $P^t(w_{0})=x$.\nIt remains the question if the given $x$ is actually on the segment $i$ of\nfault $t$. To test this $s$ is restricted between $0$ and $1$ (so if $s<0$, $s$\nis set to $0$ and if $s>1$, $s$ is set to $1$) and then we check the residual\nof \\eqn{eq:2D line 1}, i.e. $x$ has been accepted to be in the segment if\n\\begin{equation}\n\\|x-V^{ti} - s \\cdot (V^{t(i+1)}- V^{ti}) \\| \\le tol \\cdot  \nmax(l^{ti}, \\|x-V^{ti} \\|) \n\\label{eq:2D line 3}\n\\end{equation}\nwhere $tol$ is a given tolerance.\n\nIn the 3D case the situation is a bit more complicated: we split the fault\nsegment across the diagonal $V^{ti}$-$v^{t(i+1)}$ to produce two triangles.\nIn the upper triangle we use the parameterization \n\\begin{equation}\nx= V^{ti} + s \\cdot (V^{t(i+1)}-V^{ti})  + r \\cdot (v^{t(i+1)}-V^{t(i+1)})\n\\mbox{ with } r \\le s; \n\\label{eq:2D line 4}\n\\end{equation}\nwhile in the lower triangle we use\n\\begin{equation}\nx= V^{ti} +  s \\cdot (v^{t(i+1)}-v^{ti}) + r \\cdot (v^{ti}-V^{ti})\n\\mbox{ with } s \\le r; \n\\label{eq:2D line 4b}\n\\end{equation}\nwhere $0\\le s,r \\le 1$. Both equations are solved in the least-squares sense\ne.g. using the Moore-Penrose pseudo-inverse for the coefficient matrices.\nThe resulting $s$ and $r$ are then restricted to the unit square. Similar to\nthe 2D case (see \\eqn{eq:2D line 3}) we identify $x$ to be in the upper\ntriangle of the segment if\n\\begin{equation}\n\\|x- V^{ti} - s \\cdot (V^{t(i+1)}-V^{ti})  - r \\cdot (v^{t(i+1)}-V^{t(i+1)}) \\|\n\\le tol \\cdot  max(\\|x-V^{ti} \\|,\\|v^{t(i+1)}-V^{t(i)})\\|) \n\\label{eq:2D line 4c}\n\\end{equation}\nand in the lower part\n\\begin{equation}\n\\|x-V^{ti} -  s \\cdot (v^{t(i+1)}-v^{ti}) - r \\cdot (v^{ti}-V^{ti}) \\|\n\\le tol \\cdot  max(\\|x-V^{ti} \\|,\\|v^{t(i+1)}-V^{t(i)})\\|)  \n\\label{eq:2D line 4d}\n\\end{equation}\nafter the restriction of $(s,t)$ to the unit square.\nNote that $\\|v^{t(i+1)}-V^{t(i)})\\|$ is the length of the diagonal of the\nfault segment. For those $x$ which have been located in the $i$-th segment we\nthen set\n\\begin{equation}\nw_{0}=\\Omega^{ti}+s \\cdot (\\Omega^{ti}-\\Omega^{t(i-1)})\n\\mbox{ and }\nw_{1}=w^t_{1max} (r-1) \n\\label{eq:2D line 5}\n\\end{equation}\n\n\\subsection{Functions}\n\n\\begin{classdesc}{FaultSystem}{\\optional{dim =3}}\ncreates a fault system in the \\var{dim} dimensional space.\n\\end{classdesc}\n\n\\begin{methoddesc}[FaultSystem]{getMediumDepth}{tag}\nreturns the medium depth of fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getTags}{}\nreturns a list of the tags used by the fault system.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getStart}{tag}\nreturns the starting point of fault \\var{tag} as a \\numpyNDA object.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getDim}{}\nreturns the spatial dimension.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getDepths}{tag}\nreturns the list of the depths of the segments in fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getTopPolyline}{tag}\nreturns the polyline used to describe the fault tagged by \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getStrikes}{tag}\nreturns the list of strikes $\\sigma^{ti}$ of the segments in fault\n$t=$\\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getStrikeVectors}{tag}\nreturns the strike vectors $S^{ti}$ of fault $t=$\\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getLengths}{tag}\nreturns the lengths $l^{ti}$ of the segments in fault $t=$\\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getTotalLength}{tag}\nreturns the total unrolled length of fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getDips}{tag}\nreturns the list of the dips of the segments in fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getBottomPolyline}{tag}\nreturns the list of the vertices defining the bottom of the fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getSegmentNormals}{tag}\nreturns the list of the normals of the segments in fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getDepthVectors}{tag}\nreturns the list of the depth vectors $d^{ti}$ for fault $t=$\\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getDepths}{tag}\nreturns the list of the depths of the segments in fault \\var{tag}.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getW0Range}{tag}\nreturns the range of the parameterization in $w_{0}$.\nFor tag $t$ this is the pair $(\\Omega^{t0},\\Omega^{tn})$ where $n$ is the\nnumber of segments in the fault.\nIn most cases one has $(\\Omega^{t0},\\Omega^{tn})=(0,w^t_{0 max})$.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getW1Range}{tag}\nreturns the range of the parameterization in  $w_{1}$.\nFor tag $t$ this is the pair $(-w^t_{1max},0)$.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getW0Offsets}{tag}\nreturns the offsets for the parameterization of fault \\var{tag}.\nFor tag \\var{tag}=$t$ this is the list $[\\Omega^{ti}]$.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getCenterOnSurface}{}\nreturns the center point of the fault system at the surfaces.\nIn 3D the calculation of the center is considering the top edge of the faults\nand projects the edge to the surface (the $x_{2}$ component is assumed to be\n0). An \\numpyNDA object is returned.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getOrientationOnSurface}{}\nreturns the orientation of the fault system in RAD on the surface\n($x_{2}=0$ plane) around the fault system center.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{transform}{\\optional{rot=0, \\optional{shift=numpy.zeros((3,)}}}\napplies a shift \\var{shift} and a consecutive rotation in the $x_{2}=0$ plane.\n\\var{rot} is a float number and \\var{shift} an \\numpyNDA object.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getMaxValue}{f\\optional{, tol=1.e-8}}\nreturns the tag of the fault where \\var{f} takes the maximum value and a\n\\class{Locator} object which can be used to collect values from \\Data objects\nat the location where the maximum is taken, e.g.\n\\begin{python}\n       fs=FaultSystem()\n       f=Scalar(..)\n       t, loc=fs.getMaxValue(f)\n       print(\"maximum value of f on the fault %s is %s at location %s.\"%(t, \\\n             loc(f), loc.getX()))\n\\end{python}\n\\var{f} must be a \\Scalar. When the maximum is calculated only\n\\DataSamplePoints are considered which are on a fault in the fault system in\nthe sense of condition~\\ref{eq:2D line 3} or \\ref{eq:2D line 4d}, respectively.\nIn the case no \\DataSamplePoints are found the returned tag is \\var{None} and\nthe maximum value as well as the location of the maximum value are undefined.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getMinValue}{f\\optional{, tol=1.e-8}}\nreturns the tag of the fault where \\var{f} takes the minimum value and a\n\\class{Locator} object which can be used to collect values from \\Data objects\nat the location where the minimum is taken, e.g.\n\\begin{python}\n  fs=FaultSystem()\n  f=Scalar(..)\n  t, loc=fs.getMinValue(f)\n  print(\"minimum value of f on the fault %s is %s at location.\"%\\\n      (t,loc(f),loc.getX()))\n\\end{python}\n\\var{f} must be a \\Scalar. When the minimum is calculated only\n\\DataSamplePoints are considered which are on a fault in the fault system in\nthe sense of condition~\\ref{eq:2D line 3} or \\ref{eq:2D line 4d}, respectively.\nIn the case no \\DataSamplePoints are found the returned tag is \\var{None} and\nthe minimum value as well as the location of the minimum value are undefined.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getParametrization}{x,tag \\optional{\\optional{, tol=1.e-8}, outsider=None}}\nreturns the argument $w$ of the parameterization $P^t$ for \\var{tag}=$t$ to\nprovide \\var{x} together with a mask indicating where the given location if on\na fault in the fault system by the value $1$ (otherwise the value is set to $0$).\n\\var{x} needs to be a \\Vector or \\numpyNDA object.\n\\var{tol} defines the tolerance to decide if given \\DataSamplePoints are on\nfault \\var{tag}. The value \\var{outside} is the value used as a replacement\nvalue for $w$ where the corresponding value in \\var{x} is not on a fault.\nIf \\var{outside} is not present an appropriate value is used.\n\\end{methoddesc}\n \n\\begin{methoddesc}[FaultSystem]{getSideAndDistance}{x,tag}\nreturns the side and the distance at locations \\var{x} from the fault \\var{tag}.\n\\var{x} needs to be a \\Vector or \\numpyNDA object.\nPositive values for side means that the corresponding location is to the right\nof the fault, a negative value means that the corresponding location is\nto the left of the fault. The value zero means that the side is undefined.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{getFaultSegments}{tag}\nreturns the polylines used to describe fault \\var{tag}. For \\var{tag}=$t$ this\nis the list of the vertices $[V^{ti}]$ for the 2D and the pair of lists of the\ntop vertices $[V^{ti}]$ and the bottom vertices $[v^{ti}]$ in 3D.\nNote that the coordinates are represented as \\numpyNDA objects.\n\\end{methoddesc}\n\n\\begin{methoddesc}[FaultSystem]{addFault}{\nstrikes\\optional{,\nls\\optional{,\nV0=[0.,0.,0.]\\optional{,\ntag=None\\optional{,\ndips=None\\optional{,\ndepths= None\\optional{,\nw0_offsets=None\\optional{,\nw1_max=None}}}}}}}}\nadds the fault \\var{tag} to the fault system.\n\\var{V0} defines the start point of fault named $t=$\\var{tag}.\nThe polyline defining the fault segments on the surface are set by the strike\nangles \\var{strikes} (=$\\sigma^{ti}$, north = $\\pi/2$, the orientation is\ncounterclockwise.) and the length \\var{ls} (=$l^{ti}$).\nIn the 3D case one also needs to define the dip angles \\var{dips}\n(=$\\delta^{ti}$, vertical=$0$, right-hand rule applies.) and the depth\n\\var{depths} for each segment.\n\\var{w1_max} defines the range of $w_{1}$.\nIf not present the mean value over the depth of all segment edges in the fault\nis used.\n\\var{w0_offsets} sets the offsets $\\Omega^{ti}$. If not present it is chosen\nsuch that $\\Omega^{ti}-\\Omega^{t(i-1)}$ is the length of the $i$-th segment.\nIn some cases, e.g. when kinks in the fault are relevant, it can be useful\nto explicitly specify the offsets in order to simplify the assignment of values.\n\\end{methoddesc}\n\n\\subsection{Example}\nSee \\Sec{Slip CHAP}.\n\n", "meta": {"hexsha": "5f6c251203d9600d834bb4e77721eb441eb5481f", "size": 15531, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/user/faultsystem.tex", "max_stars_repo_name": "markendr/esys-escript.github.io", "max_stars_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/user/faultsystem.tex", "max_issues_repo_name": "markendr/esys-escript.github.io", "max_issues_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-14T03:07:43.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T03:07:43.000Z", "max_forks_repo_path": "doc/user/faultsystem.tex", "max_forks_repo_name": "markendr/esys-escript.github.io", "max_forks_repo_head_hexsha": "0023eab09cd71f830ab098cb3a468e6139191e8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3402597403, "max_line_length": 107, "alphanum_fraction": 0.6991178932, "num_tokens": 4976, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4079426541732935}}
{"text": "\\chapterimage{head2.png} % Chapter heading image\n\\chapter{Bayesian Inference Framework 3}\n\\section{Four spaces}\n\\begin{center}\n    \\includegraphics[scale=0.4]{ch8/fourspaces.pdf}   \n\\end{center}\n\n\\section{Photon Operator and Time Evolution}\n\\begin{definition}[Cartesian Space: Single Photon]\nGiven $p(x_1)$, and if we observe $y_1$\n\\begin{center}\n    \\includegraphics[scale=0.7]{ch8/singlephoton_x.pdf}   \n\\end{center}\nActually, $p(y_1|x_1)$ is a matrix\n\\begin{equation}\n    p(y_1(j)|x_1(i)) = \n    \\begin{bmatrix}\n    p(y_1(1)|x_1(1)) & p(y_1(2)|x_1(1)) & \\cdots & p(y_1(N)|x_1(1)) \\\\\n    p(y_1(1)|x_1(2)) & p(y_1(2)|x_1(2)) & \\cdots & p(y_1(N)|x_1(2)) \\\\\n    \\vdots & \\vdots & \\cdots & \\vdots \\\\\n    p(y_1(1)|x_1(N)) & p(y_1(2)|x_1(N)) & \\cdots & p(y_1(N)|x_1(N))\n    \\end{bmatrix}\n\\end{equation}\n\\begin{center}\n    \\includegraphics[scale=0.4]{ch8/single_photon_x_2.pdf}   \n\\end{center}\n\\end{definition}\n\n\\begin{definition}[Build Photon Matrix $\\left<\\psi_i|\\textbf{y}|\\psi_j\\right>$]\n\\begin{center}\n    \\includegraphics[scale=0.4]{ch8/build_photon_mat.pdf}   \n\\end{center}\n\\end{definition}\n\n\\begin{definition}[Eigenspace $\\rho$: Single Photon]\nWe can express $\\rho(x_1)$ as the linear combination of eigenfunctions, which fully determined by $p_{\\rm{eq}}(x)$\n\\begin{equation}\n    \\rho(x_1) = \\sum_{k=1}^{N_v} a_k \\psi_{k}(x)\n\\end{equation}\nTherefore, in eigenspace, we have a vector:\n\\begin{equation}\n    \\left< \\rho_1 \\right| = \\begin{bmatrix}\n        a_1 & a_2 & \\cdots & a_{N_v}\n    \\end{bmatrix}\n\\end{equation}\nNote that $a_1=\\pm 1$ because\n\\begin{equation}\n    a_1 = \\int \\rho(x_1)\\psi_1(x_1)dx_1 = \\int \\frac{p(x_1)}{\\rho_{\\text{eq}}(x_1)}\\psi_1(x_1) dx_1 = \\pm \\int p(x_1) dx_1 = \\pm 1\n\\end{equation}\n\\begin{center}\n    \\includegraphics[scale=0.7]{ch8/singlephoton_s.pdf}   \n\\end{center}\nNote that\n\\begin{align}\n    p(y_1) &= \\left< \\rho_1|\\textbf{y}_1|\\psi_1 \\right> = \\int \\frac{p(x_1,y_1)}{\\rho_{\\text{eq}}(x_1)} \\psi_1(x_1) dx_1 \\\\\n    \\left<\\hat{\\alpha}_1|\\psi_1\\right> &= \\int \\frac{p(x_1|y_1)}{\\rho_{\\text{eq}}(x_1)} \\psi_1(x_1) dx_1 = \\pm 1\n\\end{align}\n\\begin{center}\n    \\includegraphics[scale=0.35]{ch8/rho_y1.pdf}   \n\\end{center}\n\\end{definition}\n\n\\begin{definition}[Cartesian: Time Evolution]\n\\begin{align}\n    \\frac{p(x_1, x_2, y_1)}{\\rho_{\\text{eq}}(x)} &= \\rho(x_1, x_2, y_1) = \\sum_{k=1}^{N_v} \\left< \\alpha_1|\\psi_k \\right> e^{-D \\lambda'_k \\Delta t} \\psi_k(x_2) \\\\\n    \\frac{p(x_2 | x_1, y_1)}{\\rho_{\\text{eq}}(x)} &= \\rho(x_2 | x_1, y_1) = \\sum_{k=1}^{N_v} \\left< \\hat{\\alpha}_1|\\psi_k \\right> e^{-D \\lambda'_k \\Delta t} \\psi_k(x_2)\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[Eigenspace: Time Evolution]\nThen, we see the time propagation\n\\begin{center}\n    \\includegraphics[scale=0.7]{ch8/time_evolution_graphical.pdf}   \n\\end{center}\n\\begin{center}\n    \\includegraphics[scale=0.45]{ch8/alpha_hat_s1_edt.pdf}   \n\\end{center}\n\\end{definition}\n\n\\section{Forward Algorithm}\n\\begin{definition}[$\\alpha(x_1)$]\n\\begin{align}\n    \\alpha(x_1) &= p(x_1,y_1) \\\\\n    \\frac{\\alpha(x_1)}{\\rho_{\\text{eq}}(x)} &= \\left< \\alpha_1 | x \\right> =  \\left< \\rho_1 | \\textbf{y}_1 | x \\right>\\\\\n    \\hat{\\alpha}(x_1) &= p(x_1 | y_1) \\\\\n    \\frac{\\hat{\\alpha}(x_1)}{\\rho_{\\text{eq}}(x)} &= \\left< \\hat{\\alpha}_1 | x \\right>\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[$\\alpha(x_t)$]\n\\begin{align}\n    \\alpha(x_t) &= p(x_t,y_1,...,y_t) \\\\\n    \\frac{\\alpha(x_t)}{\\rho_{\\text{eq}}(x)} &= \\left< \\alpha_t | x \\right> =  \\left< \\alpha_{t-1} | e^{-\\textbf{H}\\Delta t}\\textbf{y}_t | x \\right>\\\\\n    \\hat{\\alpha}(x_t) &= p(x_t | y_1,...,y_t) \\\\\n    \\frac{\\hat{\\alpha}(x_t)}{\\rho_{\\text{eq}}(x)} &= \\left< \\hat{\\alpha}_t | x \\right>\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[Normalized Constant: $p(y_1)$]\n\\begin{align}\n    p(y_1) &= \\left<\\alpha_1|\\psi_1\\right> \\\\\n    \\left< \\hat{\\alpha}_1 \\right| &= \\frac{\\left< \\alpha_1 \\right|}{\\left<\\alpha_1|\\psi_1\\right>}\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[Normalized Constant: $p(y_t|y_1,...,y_{t-1})$]\n\\begin{equation}\n    \\left< \\hat{\\alpha}_{t-1} | e^{-\\textbf{H}\\Delta t}\\textbf{y}_t | \\psi_1 \\right> = \\int \\frac{p(x_t,y_t|y_1,...,y_{t-1})}{\\rho_{\\text{eq}}(x_t)} \\psi_1(x_t) dx_t = p(y_t|y_1,...,y_{t-1})\n\\end{equation}\nso\n\\begin{equation}\n        \\left< \\hat{\\alpha}_t \\right| = \\frac{\\left< \\hat{\\alpha}_{t-1} \\right| e^{-\\textbf{H}\\Delta t}\\textbf{y}_t }{\\left< \\hat{\\alpha}_{t-1} | e^{-\\textbf{H}\\Delta t}\\textbf{y}_t | \\psi_1 \\right>}\n\\end{equation}\n\\end{definition}\n\n\\section{Backward Algorithm}\n\\begin{definition}[Posterior probability $\\gamma(x_t)$]\n\\begin{equation}\n    \\gamma(x_t) = p(x_t|\\textbf{Y}) = \\left< \\hat{\\alpha}_{\\tau} |x\\right> \\left<x|\\hat{\\beta}_{\\tau}\\right>\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}[Posterior probability in Eigenspace]\n\\begin{equation}\n    \\left< \\gamma_t | \\psi_i \\right> = \\left< \\hat{\\alpha}_{\\tau} |\\psi_i \\right> \\left< \\psi_i|\\hat{\\beta}_{\\tau}\\right>\n\\end{equation}\nand \n\\begin{equation}\n    \\int \\gamma(x_t) dx_t = \\sum_i \\left< \\gamma_t | \\psi_i \\right> = \\sum_i \\left< \\hat{\\alpha}_{\\tau} |\\psi_i \\right> \\left< \\psi_i|\\hat{\\beta}_{\\tau}\\right> = \\left< \\hat{\\alpha}_{\\tau} | \\hat{\\beta}_{\\tau}\\right>\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}[$\\beta(x_{\\tau})$]\nWe need a starting condition for the $\\beta$-recursion, and because the posterior probability\n\\begin{equation}\n    p(x_{\\tau}|\\textbf{Y}) = \\frac{\\left< \\alpha_{\\tau} |x\\right> \\left<x|\\beta_{\\tau}\\right>}{p(\\textbf{Y})} = \\frac{\\frac{\\alpha(x_{\\tau})}{\\rho_{\\text{eq}}(x)} \\left<x|\\beta_{\\tau}\\right>}{p(\\textbf{Y})} = \\frac{\\alpha(x_{\\tau})}{p(\\textbf{Y})}\n\\end{equation}\nwhere $\\alpha(x_{\\tau})=p(x_{\\tau},y_1,...,y_{\\tau})$. Therefore, $\\left<x|\\beta_{\\tau}\\right>$ can be naturally defined by \n\\begin{equation}\n    \\left<x|\\beta_{\\tau}\\right> = \\rho_{\\text{eq}}(x) = \\psi_1(x)\n\\end{equation}\nso \n\\begin{equation}\n    \\left| \\beta_{\\tau}\\right> = \\left| \\psi_{1}\\right>\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}[$\\beta(x_t)$]\n\\begin{align}\n    \\beta(x_t) &= p(y_{t+1},...,y_{\\tau}|x_t) \\\\\n    \\left| \\beta_t \\right> &= e^{-\\textbf{H}\\Delta t} \\textbf{y}_{t+1} \\left| \\beta_{t+1} \\right> \\\\\n    \\left| \\hat{\\beta}_t \\right> &= \\frac{e^{-\\textbf{H}\\Delta t} \\textbf{y}_{t+1} \\left| \\hat{\\beta}_{t+1} \\right>}{p(y_{t+1}|y_1,...,y_t)} \\\\\n    \\left| \\hat{\\beta}_t \\right> &= \\frac{\\left| \\beta_t \\right>}{p(y_{t+1},...,y_{\\tau}|y_1,...,y_{t})}\n\\end{align}\n\\end{definition}\n\n\\section{Likelihood Function}\n\\begin{definition}[$p(Y(t))$]\n\\begin{equation}\n    p(Y(t)) = p(y_1,...,y_{\\tau}) = \\left<\\alpha_{\\tau} | \\beta_{\\tau} \\right> =  \\left<\\alpha_{\\tau} | \\psi_{1} \\right>\n\\end{equation}\nBecause\n\\begin{align*}\n    \\left<\\alpha_{\\tau} | x \\right> &= \\frac{p(x_{\\tau}, y_1,...,y_{\\tau})}{\\rho_{\\text{eq}}(x)} \\\\\n    \\left<\\alpha_{\\tau} | \\psi_{1} \\right> &= \\int \\frac{p(x_{\\tau}, y_1,...,y_{\\tau})}{\\rho_{\\text{eq}}(x_{\\tau})} \\psi_1(x_{\\tau})dx_{\\tau} = p(y_1,...,y_{\\tau})\n\\end{align*}\nTherefore, we also can write \n\\begin{equation}\n    P(Y(t) ; \\theta) = \\mathcal{L}[\\theta]= \\langle \\alpha_{1} |e^{-\\textbf{H}\\Delta t}\\textbf{y}_2 e^{-\\textbf{H}\\Delta t} \\textbf{y}_3 \\ldots e^{-\\textbf{H}\\Delta t}\\textbf{y}_{\\tau} | \\beta_{\\tau} \\rangle.\n\\end{equation}\n\\end{definition}\n\n\\section{Complete Likelihood Function}\n\\begin{definition}[Complete Likelihood Function]\nThe complete likelihood function is \n\\begin{equation}\n    p(y_1,\\cdots,y_{\\tau},x_1,\\cdots,x_{\\tau}) = p(Y(t),X(t)) = p(x_1)\\left[\\prod_{t=2}^{\\tau}p(x_t|x_{t-1})\\right]\\prod_{t=1}^{\\tau}p(y_t|x_t)\n\\end{equation}\nIn bra-ket form:\n\\begin{align}\n    p(Y,X) &= \\left< \\rho_{1} | x_1 \\right> \\left< x_1 | \\textbf{y}_1 | y_1 \\right> \\left< x_1 | e^{-\\textbf{H}\\Delta t} | x_2 \\right>  \\left< x_2 | \\textbf{y}_2 | y_2 \\right> \\left< x_2 | e^{-\\textbf{H}\\Delta t} | x_3 \\right>  \\cdots \\left<x_\\tau|\\beta_{\\tau}\\right> \\\\\n    &= \\left< \\rho_{1} | x_1 \\right> \\left< x_1 | \\textbf{y}_1 | x_1 \\right> \\left< x_1 | e^{-\\textbf{H}\\Delta t} | x_2 \\right>  \\left< x_2 | \\textbf{y}_2 | x_2 \\right> \\left< x_2 | e^{-\\textbf{H}\\Delta t} | x_3 \\right>  \\cdots \\left<x_\\tau|\\beta_{\\tau}\\right>\\\\\n    &= \\left< \\rho_{1} | x_1 \\right>  \\left< x_1 | \\textbf{y}_1 | x_1 \\right> \\left( \\prod_{t=1}^{\\tau-1} \\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right> \\left< x_{t+1} | \\textbf{y}_{t+1} | x_{t+1} \\right> \\right) \\left<x_\\tau|\\beta_{\\tau}\\right>\n\\end{align}\nNote that $\\left< \\rho_{1} | x_1 \\right> = \\frac{p(x_1)}{\\rho_{\\text{eq}}(x)}$ and $\\left<x_\\tau|\\beta_{\\tau}\\right>  = \\rho_{\\text{eq}}(x)$, so $\\rho_{\\text{eq}}(x)$ will cancel out by itself.\n\\begin{center}\n    \\includegraphics[scale=0.8]{ch9/hmm_graphical_xspace.pdf}   \n\\end{center}\nThe same form in the eigenspace is \n\\begin{equation}\n    p(Y,X) = \\left< \\rho_{1} | \\psi_{i_1} \\right> \\left< \\psi_{i_1} | \\textbf{y}_1 | \\psi_{j_1} \\right> \\left( \\prod_{t=1}^{\\tau-1} \\left< \\psi_{j_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{i_{t+1}} \\right> \\left< \\psi_{i_{t+1}} | \\textbf{y}_{t+1} | \\psi_{j_{t+1}} \\right> \\right) \\left<\\psi_{j_{\\tau}}|\\beta_{\\tau}\\right>\n\\end{equation}\nand the shorthand notation for $p(Y,X)$ is \n\\begin{equation}\n    p(Y,X) = \\prod_{\\tau} \\left<|\\right>\n\\end{equation}\nFurthermore,\n\\begin{align}\n    p(Y(t)) &= \\int  p(Y(t),X(t)) \\mathcal{D}X \\\\\n    &= \\sum_{\\{i_t\\}}\\sum_{\\{j_t\\}} p(Y(t),X(t))\n\\end{align}\nwe convert the path integral to a tractable summations. \n\\end{definition}\n\n\\begin{definition}[$p(X(t)|Y(t))$]\n\\begin{equation}\n    p(X(t)|Y(t)) = \\frac{p(X(t),Y(t))}{p(Y(t))} = \\frac{\\prod^k_{\\tau} \\langle |\\rangle}{\\mathcal{L}^k}\n\\end{equation}\nThe expectation over the latent trajectory \n\\begin{align}\n    \\mathbb{E}^k_{X|Y}[\\cdot] \\equiv \\sum_{\\substack{\\{i_t\\}}} \\sum_{\\substack{\\{j_t\\}}} \\frac{\\prod^k_{\\tau} \\langle |\\rangle}{\\mathcal{L}^k}\\cdot.\n\\end{align}\n        \n\\end{definition}\n\n\\begin{definition}[Complete Log-likelihood Function]\n\\begin{equation}\n    \\ln{p(Y(t),X(t))} = \\ln{p(x_1)} + \\sum_{t=2}^{\\tau} \\ln{p(x_t|x_{t-1})} + \\sum_{t=1}^{\\tau} \\ln{p(y_t|x_t)}\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}[Q: First Part]\n\\begin{align*}\n    Q &= \\int  p(X(t)|Y(t)) \\ln{p(Y(t),X(t))} \\mathcal{D}X \\\\\n    &= \\int p(X(t)|Y(t)) \\ln{p(x_1)} \\mathcal{D}X + \\sum_{t=1}^{\\tau-1} \\int p(X(t)|Y(t)) \\ln{p(x_{t+1}|x_{t})} \\mathcal{D}X \\\\\n    &+ \\sum_{t=1}^{\\tau} \\int p(X(t)|Y(t)) \\ln{p(y_t|x_t)} \\mathcal{D}X \n\\end{align*}\nBecause \n\\begin{equation}\n    P(X,Y) = \\left< \\rho_{1} | x_1 \\right> \\left< x_1 | \\textbf{y}_1 | x_1 \\right> \\left< x_1 | e^{-\\textbf{H}\\Delta t} | x_2 \\right>  \\left< x_2 | \\textbf{y}_2 | x_2 \\right> \\left< x_2 | e^{-\\textbf{H}\\Delta t} | x_3 \\right>  \\cdots \\left<x_\\tau|\\beta_{\\tau}\\right>\n\\end{equation}\nso\n\\begin{equation}\n    \\ln{P(X,Y)} = \\ln{\\left< \\rho_{1} | x_1 \\right>} + \\sum_{t=1}^{\\tau-1} \\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>} + \\sum_{t=1}^{\\tau} \\left< x_t | \\textbf{y}_t | x_t \\right>\n\\end{equation}\nTherefore, we only need to consider $\\sum_{t=1}^{\\tau-1} \\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>}$\n\\begin{align}\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>}] &= \\int p(x_1,...,x_t,x_{t+1},...,x_{\\tau}|Y)\\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>} \\mathcal{D}X \\\\\n    & =\\int \\int p(x_t,x_{t+1}|Y)  \\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>} dx_t dx_{t+1}\n\\end{align}\nwhere we do the marginalization\n\\begin{equation}\n    \\int p(x_1,...,x_t,x_{t+1},...,x_{\\tau}|Y) \\mathcal{D}X  = \\int\\int p(x_t,x_{t+1}|Y) dx_t dx_{t+1}\n\\end{equation}\n\\end{definition}\n\n\\begin{definition}[Expectation in eigenspace]\n\\begin{align*}\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>}] &= \\int \\int p(x_t,x_{t+1}|Y)  \\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>} dx_t dx_{t+1}\n\\end{align*}\n\\begin{align}\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{i_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] &= \\sum_{\\{i_t, j_t\\}} p(\\psi_{i_t},\\psi_{j_{t+1}}|Y)  \\ln{\\left< \\psi_{i_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}}\\right>} \\\\\n    &= \\sum_{\\{i_t, j_t\\}} p(\\psi_{i_t},\\psi_{j_{t+1}}|Y) \\ln{ \\left( e^{-D_j \\lambda'_j \\Delta t} \\left< \\psi_{i_t} |\\psi_{j_{t+1}} \\right>\\right)}\n\\end{align}\nIf $i \\neq j$,\n\\begin{align*}\n    \\left< \\psi_{i_t} |\\psi_{j_{t+1}}\\right> &= 0 \\\\\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{i_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] &= \\sum_{\\{i_t, j_t\\}} p(\\psi_{i_t},\\psi_{j_{t+1}}|Y) \\ln{0} = -\\infty\n\\end{align*}\nIf $i=j=1$\n\\begin{align*}\n    \\left< \\psi_{1_t} |\\psi_{1_{t+1}}\\right> &= 1 \\\\\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{1_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{1_{t+1}} \\right>}] &= p(\\psi_{1_t},\\psi_{1_{t+1}}|Y) \\ln{1} = 0\n\\end{align*}\nIf $i=j\\neq 1$\n\\begin{align*}\n    \\left< \\psi_{j_t} |\\psi_{j_{t+1}}\\right> &= 1 \\\\\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{j_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] &= p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{e^{-D_j \\lambda'_j \\Delta t}} \\\\\n    &= p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{A_{j}}\n\\end{align*}\n\\end{definition}\n\n\\begin{definition}[$\\xi(x_t,x_{t+1})$]\n\\begin{equation}\n    \\xi(x_t,x_{t+1}) = p(x_t, x_{t+1} | Y) = \\frac{p(x_t,x_{t+1},Y)}{p(Y)}\n\\end{equation}\nwhere\n\\begin{align*}\n    p(x_t,x_{t+1},Y) &= p(x_t, y_1,...,y_t) p(x_{t+1}|x_t) p(y_{t+1}|x_{t+1}) p(y_{t+2},...,y_{\\tau}|x_{t+1}) \\\\\n    &= \\left< \\alpha_t | x_t \\right> \\left<x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right> \\left< x_{t+1} | \\textbf{y}_{t+1}| x_{t+1} \\right> \\left< x_{t+1} | \\beta_{t+1} \\right>\n\\end{align*}\nand\n\\begin{align*}\n    p(\\psi_{i_t},\\psi_{j_{t+1}},Y) &= \\left< \\alpha_t | \\psi_{i_t} \\right> \\left< \\psi_{i_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}}| \\textbf{y}_{t+1}| \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}} | \\beta_{t+1} \\right> \\\\\n    &= e^{-D_j \\lambda'_j \\Delta t} \\left< \\alpha_t | \\psi_{i_t} \\right> \\left< \\psi_{i_t} | \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}}| \\textbf{y}_{t+1}| \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}} | \\beta_{t+1} \\right>\n\\end{align*}\nIf $i \\neq j$\n\\begin{align*}\n    p(\\psi_{i_t},\\psi_{j_{t+1}},Y) = 0\n\\end{align*}\nIf $i=j$\n\\begin{align*}\n    p(\\psi_{j_t},\\psi_{j_{t+1}},Y) &= e^{-D_j \\lambda'_j \\Delta t} \\left< \\alpha_t | \\psi_{j_t} \\right> \\left< \\psi_{j_t} | \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}}| \\textbf{y}_{t+1}| \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}} | \\beta_{t+1} \\right> \\\\\n    &= e^{-D_j \\lambda'_j \\Delta t} \\left< \\alpha_t | \\psi_{j_t} \\right> \\left< \\psi_{j_{t+1}}| \\textbf{y}_{t+1}| \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}} | \\beta_{t+1} \\right> \n\\end{align*}\nBecause\n\\begin{align*}\n    \\left<\\hat{\\alpha}\\right| &= \\frac{\\left< \\alpha_t \\right|}{p(y_1,...,y_t)}\\\\\n    \\left | \\hat{\\beta}_{t+1} \\right> &= \\frac{\\left | \\beta_{t+1} \\right>}{p(y_{t+2},y_{t+3},...,y_{\\tau}|y_1,...,y_{t+1})} \\\\\n    c_{t+1} &= p(y_{t+1}|y_1,...,y_{t})\n\\end{align*}\nso\n\\begin{align}\n    p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) &=  \\frac{p(\\psi_{j_t},\\psi_{j_{t+1}},Y)}{p(Y)} \\\\\n    &= \\frac{e^{-D_j \\lambda'_j \\Delta t} \\left< \\hat{\\alpha}_t | \\psi_{j_t} \\right> \\left< \\psi_{j_{t+1}}| \\textbf{y}_{t+1}| \\psi_{j_{t+1}} \\right> \\left< \\psi_{j_{t+1}} | \\hat{\\beta}_{t+1} \\right>}{c_{t+1}}\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[Q: Second Part]\n\\begin{equation}\n    Q = \\mathbb{E}_{X|Y}[\\ln{\\left< \\rho_{1} | x_1 \\right>}] + \\sum_{t=1}^{\\tau-1} \\mathbb{E}_{X|Y}[\\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>}] + \\sum_{t=1}^{\\tau} \\mathbb{E}_{X|Y}[\\left< x_t | \\textbf{y}_t | x_t \\right>]\n\\end{equation}\nbecause $p_{\\text{eq}}(x)$ and $D$ are buried in $e^{-\\textbf{H}\\Delta t}$, we only care about \n\\begin{align*}\n    \\sum_{t=1}^{\\tau-1} \\mathbb{E}_{X|Y}[\\ln{\\left< x_t | e^{-\\textbf{H}\\Delta t} | x_{t+1} \\right>}]\n\\end{align*}\nRecall that\n\\begin{equation}\n    \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{j_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] = p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{A_{j}}\n\\end{equation}\nso\n\\begin{align}\n    \\tilde{Q} &= \\sum_{t=1}^{\\tau-1} \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{j_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] = \\sum_{t=1}^{\\tau-1} \\mathbb{E}^k_{X|Y}[\\ln{A_j}] = \\sum_{t=1}^{\\tau-1} p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{A_{j}}\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[No analytical form for updating $D$: Part 1]\nThere three forms of \n\\begin{align*}\n    Q = \\int  p(X(t)|Y(t)) \\ln{p(Y(t),X(t))} \\mathcal{D}X\n\\end{align*}\nin this framework. The first is \n\\begin{equation}\n    \\tilde{Q} = \\sum_{t=1}^{\\tau-1} \\mathbb{E}^k_{X|Y}[\\ln{\\left< \\psi_{j_t} | e^{-\\textbf{H}\\Delta t} | \\psi_{j_{t+1}} \\right>}] = \\sum_{t=1}^{\\tau-1} p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{e^{-D_j \\lambda'_j \\Delta t}}\n\\end{equation}\nIf we take derivative of $\\tilde{Q}$ with respect to $D_j$, we get \n\\begin{equation}\n    \\frac{d\\tilde{Q}}{d D_j} = -\\sum_{t=1}^{\\tau-1} p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\lambda'_j \\Delta t\n\\end{equation}\nWe can not find $D_{\\text{max}}$ which make $\\frac{d\\tilde{Q}}{d D_j}=0$ through the above equation.\n\\end{definition}\n\n\\begin{definition}[No analytical form for updating $D$: Part 2]\nThe second is\n\\begin{equation}    \n    \\tilde{Q} = \\sum_{t=1}^{\\tau-1} p(\\psi_{j_t},\\psi_{j_{t+1}}|Y) \\ln{A_{j}}\n\\end{equation}\nThe matrix $A$ is \n\\begin{equation}\n    A = \\begin{bmatrix}\n        1 & 0 & \\cdots & 0 \\\\\n        0 & e^{-D_2\\lambda'_2 \\Delta t} & \\cdots & 0 \\\\\n        \\vdots & \\vdots & \\cdots & \\vdots \\\\\n        0 & 0 & \\cdots & e^{-D_{N_v}\\lambda'_{N_v} \\Delta t}\n    \\end{bmatrix}\n\\end{equation}\nActually, we have no constraint for $A_j$ like the conventional stochastic matrix. Therefore, we can not find $D_{\\text{max}}$ through the method of Lagrange multipliers.\n\\end{definition}\n\n\\begin{definition}[No analytical form for updating $D$: Part 3]\nThe third is JPCB paper's form\n\\begin{equation}\n    \\tilde{Q} = \\sum_{t=1}^{\\tau-1} \\ln{\\left< \\hat{\\alpha}_t | e^{-\\textbf{H}\\Delta t} \\textbf{y}_{t+1} | \\hat{\\beta}_{t+1} \\right>} - \\sum_{t=1}^{\\tau-1}\\ln{c_{t+1}}\n\\end{equation}\nBecause\n\\begin{align*}\n    \\left< \\hat{\\alpha}_t | e^{-\\textbf{H}\\Delta t} \\textbf{y}_{t+1} | \\hat{\\beta}_{t+1} \\right> &= \\sum_{i,j,k} \\left< \\hat{\\alpha}_t \\right| \\psi_i \\left> \\right<\\psi_i| e^{-\\textbf{H}\\Delta t} | \\psi_j \\left> \\right<\\psi_j| \\textbf{y}_{t+1} | \\psi_k \\left> \\right<\\psi_k \\left| \\hat{\\beta}_{t+1} \\right> \\\\\n    &= \\sum_{i,j,k} e^{-D_j \\lambda_j\\Delta t} \\left< \\hat{\\alpha}_t \\right| \\psi_i \\left> \\right<\\psi_i | \\psi_j \\left> \\right<\\psi_j| \\textbf{y}_{t+1} | \\psi_k \\left> \\right<\\psi_k \\left| \\hat{\\beta}_{t+1} \\right> \\\\\n    &= \\sum_{j,k} e^{-D_j \\lambda_j\\Delta t} \\left< \\hat{\\alpha}_t \\right| \\psi_j \\left> \\right<\\psi_j | \\psi_j \\left> \\right<\\psi_j| \\textbf{y}_{t+1} | \\psi_k \\left> \\right<\\psi_k \\left| \\hat{\\beta}_{t+1} \\right> \\\\\n    &= \\sum_{j,k} e^{-D_j \\lambda_j\\Delta t} \\left< \\hat{\\alpha}_t \\right| \\psi_j \\left> \\right<\\psi_j| \\textbf{y}_{t+1} | \\psi_k \\left> \\right<\\psi_k \\left| \\hat{\\beta}_{t+1} \\right>\n\\end{align*}\nso\n\\begin{equation}\n    \\frac{d\\tilde{Q}}{d D_j} = \\sum_{t=1}^{\\tau-1} \\lambda_j\\Delta t \\sum_{j,k}  \\left< \\hat{\\alpha}_t \\right| \\psi_j \\left> \\right<\\psi_j| \\textbf{y}_{t+1} | \\psi_k \\left> \\right<\\psi_k \\left| \\hat{\\beta}_{t+1} \\right>\n\\end{equation}\nWe can not find $D_{\\text{max}}$ which make $\\frac{d\\tilde{Q}}{d D_j}=0$ through the above equation.\n\\end{definition}\n\n\\section{EM-peq}\n\\begin{center}\n    \\includegraphics[scale=0.45]{ch8/em_newscheme.pdf}   \n\\end{center}\n\\begin{center}\n    \\includegraphics[scale=0.45]{ch9/first_peq_em.pdf}   \n\\end{center}\n\n\\section{Kevin's Document}\n\\begin{definition}[Alpha-Beta]\n\\begin{align}\n    p_{\\theta}(x_t|\\textbf{y})&=\\frac{P_{\\theta}(\\textbf{y}_{[0,t]}|x_t)P_{\\theta}(\\textbf{y}_{(t,T]}|x_t)}{P_{\\theta}(\\textbf{y})}p_{\\theta}^{\\text{eq}}(x_t) \\\\\n    \\alpha_{\\theta}(x_t) &= P_{\\theta}(\\textbf{y}_{[0,t]}|x_t) \\sqrt{p_{\\theta}^{\\text{eq}}(x_t)} \\\\\n    \\beta_{\\theta}(x_t) &= P_{\\theta}(\\textbf{y}_{(t,T]}|x_t) \\sqrt{p_{\\theta}^{\\text{eq}}(x_t)} \n\\end{align}    \n\\end{definition}\n\n\\begin{definition}[Likelihood Path Integral]\n\\begin{align}\n    \\alpha_{\\theta}(x_t) &= \\left<X_t|x_t\\right> \\\\\n    \\beta_{\\theta}(x_t) &= \\left<x_t|X_t\\right> \\\\\n    P_{\\theta}(\\textbf{y}) &= L_{\\theta}(\\textbf{y})= \\langle X_{t_0} |\\textbf{y}_0 e^{-\\textbf{H}\\Delta t}\\textbf{y}_1 e^{-\\textbf{H}\\Delta t} \\textbf{y}_2 \\ldots e^{-\\textbf{H}\\Delta t}\\textbf{y}_{T}  | X_{t_T} \\rangle \\\\\n    l_{\\theta}(\\textbf{y}) &= \\ln{(L_{\\theta}(\\textbf{y}))} \\\\\n    \\frac{\\delta l_{\\theta}(\\textbf{y})}{\\delta F(x)} &= \\frac{1}{L_{\\theta}}\\int_0^{T} dt \\frac{\\delta \\langle X_{t} | \\textbf{H}| X_{t}\\rangle}{\\delta F(x)}\n\\end{align}\n\\end{definition}\n\n\\begin{definition}[Likelihood]\n\\begin{equation}\n    P_{\\theta}(\\textbf{y}) = L_{\\theta}(\\textbf{y})= \\langle X_{t_0} |\\textbf{y}_0 e^{-\\textbf{H}\\Delta t}\\textbf{y}_1 e^{-\\textbf{H}\\Delta t} \\textbf{y}_2 \\ldots e^{-\\textbf{H}\\Delta t}\\textbf{y}_{T}  | X_{t_T} \\rangle\n\\end{equation}\n    \n\\end{definition}\n", "meta": {"hexsha": "af57ebea17c1c8500c2ea069c4b7cc8aa2b13551", "size": 20828, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/chapter9.tex", "max_stars_repo_name": "yizaochen/em_theory", "max_stars_repo_head_hexsha": "a9260f17ff59d7a265dd9e629607376b8d909ae6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/chapter9.tex", "max_issues_repo_name": "yizaochen/em_theory", "max_issues_repo_head_hexsha": "a9260f17ff59d7a265dd9e629607376b8d909ae6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/chapter9.tex", "max_forks_repo_name": "yizaochen/em_theory", "max_forks_repo_head_hexsha": "a9260f17ff59d7a265dd9e629607376b8d909ae6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.5533980583, "max_line_length": 316, "alphanum_fraction": 0.5953524102, "num_tokens": 9257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4078893353815221}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{graphicx}\n\\usepackage{courier}\n\\usepackage{underscore}\n\n\\title{Turing Machine Definitions}\n\\author{Adam Yedidia}\n\n\\begin{document}\n    \n\\maketitle\n\nThis document explains the formal definitions of Turing Machines as generated by this project. Note that most of this document also appears in \\emph{A Relatively Small Turing Machine Whose Behavior Is Independent of Set Theory}, which can be found at: \\\\ \\\\\n\\texttt{parsimony/tex/busybeaver/busybeaver.pdf}\n\n\\section{2-Symbol Turing Machines}\n\nThis section explores how the 2-symbol Turing machines that are generated by this project are defined.\n\nThere are many slightly different definitions of Turing machines. \\ For example, some definitions allow the machine to have multiple tapes; others only allow it to have one; some allow an arbitrarily large alphabet, while others allow only two symbols, and so on. \\ In most research regarding Turing machines, mathematicians don't concern themselves with which of these models to use, because any one can simulate the others (usually efficiently). \\ However, because this work is concerned with upper-bounding the exact number of states required to perform certain tasks, it's important to define the model precisely. \\ The model we choose here is traditional for the Busy Beaver function.\n\nFormally, a $k$-state Turing machine is a 7-tuple $M = (Q, \\Gamma, b, \\Sigma, \\delta, q_0, F)$, where: \\\\ \\\\\n$Q$ is the set of $k$ \\emph{states} $\\{q_0, q_1, \\dots, q_{k-2}, q_{k-1}\\}$ \\\\\n$\\Gamma = \\{a, b\\}$ is the set of \\emph{tape alphabet symbols} \\\\\n\\texttt{a} is the \\emph{blank symbol} \\\\\n$\\Sigma = \\empty$ is the set of \\emph{input symbols} \\\\\\\n$\\delta = Q \\times \\Gamma \\rightarrow (Q \\cup F) \\times \\Gamma \\times \\{L, R\\}$ is the \\emph{transition function} \\\\\n$q_0$ is the \\emph{start state} \\\\\n$F = \\{\\textrm{HALT}, \\textrm{ERROR}\\}$ is the set of \\emph{halting transitions}. \\\\\n\nA Turing machine's \\emph{states} make up the Turing machine's easily-accessible, finite memory. \\ The Turing machine's state is initialized to $q_0$.\n\nThe \\emph{tape alphabet symbols} correspond to the symbols that can be written on the Turing machine's infinite tape.\n\nIn this work, all Turing machines are run on the all-\\texttt{a} input.\n\nThe \\emph{transition function} encodes the Turing machine's behavior. \\ It takes two inputs: the current state of the Turing machine (an element of $Q$) and the symbol read off the tape (an element of $\\Gamma$). \\ It outputs three instructions: what state to enter (an element of $Q$), what symbol to write onto the tape (an element of $\\Gamma$) and what direction to move the head in (an element of $\\{L, R\\}$). \\ A transition function specifies the entire behavior of the Turing machine in all cases.\n\nThe \\emph{start state} is the state that the Turing machine is in at initialization.\n\nA \\emph{halting transition} is a transition that causes the Turing machine to halt. \n\n\\section{4-Symbol Turing Machines}\n\nThis section explores how the 4-symbol Turing machines that are generated by this project are defined.\n\na $k$-state, 4-symbol Turing machine is a 7-tuple $M = (Q, \\Gamma, b, \\Sigma, \\delta, q_0, F)$, where: \\\\ \\\\\n$Q$ is the set of $k$ \\emph{states} $\\{q_0, q_1, \\dots, q_{k-2}, q_{k-1}\\}$ \\\\\n$\\Gamma = \\{\\texttt{_}, \\texttt{1}, \\texttt{H}, \\texttt{E}\\}$ is the set of \\emph{tape alphabet symbols} \\\\\n\\texttt{_} is the \\emph{blank symbol} \\\\\n$\\Sigma = \\empty$ is the set of \\emph{input symbols} \\\\\\\n$\\delta = Q \\times \\Gamma \\rightarrow (Q \\cup F) \\times \\Gamma \\times \\{L, -, R\\}$ is the \\emph{transition function} \\\\\n$q_0$ is the \\emph{start state} \\\\\n$F = \\{\\textrm{HALT}, \\textrm{ERROR}\\}$ is the set of \\emph{halting transitions}. \\\\\n\n\\end{document}", "meta": {"hexsha": "4e374f74b4e1c8e0aa90708a22ece1acc6a67a85", "size": 3727, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/docs/tm_def.tex", "max_stars_repo_name": "ricsonc/parsimony", "max_stars_repo_head_hexsha": "37cbead5421f546b2f687c1a916fc50ad21f417d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/docs/tm_def.tex", "max_issues_repo_name": "ricsonc/parsimony", "max_issues_repo_head_hexsha": "37cbead5421f546b2f687c1a916fc50ad21f417d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/docs/tm_def.tex", "max_forks_repo_name": "ricsonc/parsimony", "max_forks_repo_head_hexsha": "37cbead5421f546b2f687c1a916fc50ad21f417d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.3859649123, "max_line_length": 689, "alphanum_fraction": 0.7252481889, "num_tokens": 1046, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4078893316452628}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 9, Section 2.4: 4(b), 6, 7, 16 }\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Induction Murdering Time.}\n\\subsection*{4. B)}\nFor $n=1$ , it is given that $n^3-n=0 $ is divisible by 3. Let it be true for $n=k$. \nSo $k^3-k$ is divisible by $3k$. Let us check that it is also divisible for $n=k+1$.\\\n\\begin{align*} \n\\\\&= (k+1)^3-(k+1)\n\\\\  &= k^3+3k^2+3k+1-k-1\n\\\\ &=(k^3-k) + 3k(k+1)\\\\\n\\end{align*}\nFirst factor is divisible by 3k. Second factor is multiple of 3 hence, divisible by 3. By induction it is true.\n\\subsection*{6.}\nThis proof will be mostly mathematical. However, for the first part of it, let us try some examples. Suppose that $n = 2$. It then follows that:\\\\\n\\begin{align*} \n\\\\&= 2^6 - 1\n\\\\  &= 63\\\\\n\\end{align*}\n63 isn't prime. Let us supposed that $2^{3n} - 1$ isn't prime all the way through m + 1. \n\\begin{align*} \n\\\\ & =  2^{3(m+1)} - 1\n\\\\&= 2^3 \\times 2^{3n} - 1\n\\\\&= 7 \\times 2^{3n} +  2^{3(n)} - 1\n\\\\&= 7 \\times 2^{3n} +  2^{3n} - 1\\\\\n\\end{align*}\nNow before I continue, I'd just like to note that $a^n - 1 = (a - 1)(a^{n-1} + a^{n-2} + .. + 1)$. As such, it follows that;\n\\begin{align*} \n\\\\2{3(n+1)}  &= 7 \\times 2^{3n} + (2^3 -1)((2^3)^{n-1} + (n^3)^{n-2} + ... + 1)\n\\\\&= 7 \\times (2^{3n} + (2^3)^{n-1} + (2^3)^{n-2} + ... + 1)\\\\\n\\end{align*}\nThe math above shows that since $2^{3(n+1)}$ is a composite number, so it follows that  $2^{3n} - 1$ is a composite number for all $n \\geq 2$ because $n + 1$ is equal to any integer. \n\\subsection*{7.}\nThe recurrence can be rewritten as\\\\\r$p_n − p_n−1 = p_{n−1} + p_{n−2}$\\\\\nThis can also be written as\r$(p_{n+1} − p_n)^2 − 2p_{n}{^2} = (−1)^n$\\\\\nLet S(n) be the statement given by the previous equation. Let me no show that they are both true. Now assume that the first equation, the second and so on to S(m − 1) have all been validated. Now, continuing, we'll set the left side of the equation equal to \n$−p^2_m + 2p_m p_m −1 + p^2_{m−1}$ Factoring out a 1 and completing the square, we get\\\\\n$-(p_m -p_{m-1})^2$\n\\subsection*{16.}\nSuppose that $n ≥ 28$ and $n = 8a + 5b$\\\\\rfor some nonnegative integers $a$ and $b$. \\\\\n\\\\ If $a = 1$ then since $n \\geq 28$, we must have $5b  \\geq 20$, so that $b  \\geq 4$. In this case we may replace 3 of the 5 cent stamps with 2 of the 8 cent stamps to get $n+1 = 8(a+2)+5(b−3)$.\nIf $a = 2$, then since $n \\geq 28$, we must have $5b \\geq 12$, and since $b$ is an integer, then $b \\geq 3$. Again, in this case, we may replace 3 of the 5 cent stamps with 2 of the 8 cents stamps to get $n+1 = 8(a+2)+5(b−3)$.\r If $a \\geq 3$, then we may replace 3 of the 8 cent stamps with 5 of the 5 cent stamps to get $n+1 = 8(a−3)+5(b+5)$.\rThus in all cases, we may write $n + 1 = 8a′ + 5b′$ for some nonnegative integers $a′$ and$ b′$.\rTherefore, by the principle of mathematical induction, for any integer $n \\geq  = 28$, we can use a combination of 5 cent and 8 cent stamps to obtain n cents in postage.\\\\ Take that induction. \n\\end{document}", "meta": {"hexsha": "3c8d059a83723d351a25ad26a3cff549534d03c4", "size": 3315, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DiscreteMath/Homework9.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DiscreteMath/Homework9.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DiscreteMath/Homework9.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.25, "max_line_length": 634, "alphanum_fraction": 0.6286576169, "num_tokens": 1358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.4078611804757403}}
{"text": "\\documentclass{report}\n\\input{preamble}\n\n\\begin{document}\n\n\\thispagestyle{FirstPage}\n\\begin{center}\n\\textbf{\\large Notes}\n\\end{center}\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOPIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{Solutions to the point reactor kinetics equations} \n\n\\subsection*{The inhour equation}\n\nThe point reactor kinetics equations (PRKEs) are given by the following equations for the rate of change of both power, $P(t)$ and concentration of delayed neutron precursor group $j$, $C_j(t)$:\n\\begin{align*}\n\\frac{dP(t)}{dt}\t&= \\frac{\\rho_0 - \\beta}{\\Lambda} P(t) + \\sum_{j=1}^6 \\lambda_j C_j(t) \\\\\n\\frac{dC_j(t)}{dt}\t&= \\frac{\\beta_j}{\\Lambda} P(t) - \\lambda_j C_j(t) , \\qquad j= 1,2,3,...,6 \n\\end{align*}\nWe assume here that we are using the conventional 6 delayed neutron precursor groups, each with delayed neutron fraction $\\beta_j$, average decay constant $\\lambda_j$, a mean generation time $\\Lambda \\equiv \\frac{\\ell}{k}$, and constant reactivity insertion $\\rho_0$.\n\nWe had previously determined that the solutions of these equations are of the general form \n$$ P(t) = Pe^{st} \\quad\\text{and}\\quad C_j(t) = C_je^{st} ,$$\nwhere $P$ and $C_j$ are constant coefficients, and $s$ is also a constant related to the time-dependent nature of the system. Note that since we have mutliple differential equations there will be an equivalent number of possible solutions. For the 6 group case there are 7 equations---1 power equation and 6 precursor equations. The complete solution will therefore be a combination (superposition) of all 7 possible solutions.\n$$ P(t) = \\sum_{i=1}^7 P_i \\, e^{s_i t} $$\nFrequently, reactor operators are interested in knowing what the effect would be of introducing something into the system that would change how the neutron population (or power production) evolves over time. For example, inserting a control rod or adding a soluble absorber to the moderator would constitute a reactivity adjustment of this type. If we decide not to solve for the constant coefficients for power and precursor group concentration, $P$ and $C_j$, we can instead make some simplifications to learn about the reactor's behavior over time for some arbitary reactivity insertion. We will solve for this reactivity, $\\rho_0$. \n\nFirst, we start by plugging the general form of the solutions back into the original PRKEs, taking the derivative on the left side of each equation, and dividing out the factor of $e^{st}$ from every term gives the following:\n\\begin{align*}\nsP\t&= \\frac{\\rho_0 - \\beta}{\\Lambda} P + \\sum_{j=1}^6 \\lambda_j C_j \\\\\nsC_j\t&= \\frac{\\beta_j}{\\Lambda} P - \\lambda_j C_j , \\qquad j= 1,2,3,...,6\n\\end{align*}\nThen, we take the second of these equations and solve for $C_j$ in terms of $P$,\n$$ C_j = \\frac{\\beta_j}{\\Lambda(s+\\lambda_j)}P ,$$\nand substitute this expression back into the first of these equations to eliminate the $C_j$ term altogether.\n$$ sP = \\frac{\\rho_0 - \\beta}{\\Lambda} P + \\sum_{j=1}^6 \\frac{\\beta_j \\lambda_j}{\\Lambda(s+\\lambda_j)}P $$ \nAt this point, we can eliminate $P$ by dividing it out of both sides of the equation, as well as factor out $\\frac{1}{\\Lambda}$ from all of the terms.\n$$ s = \\frac{1}{\\Lambda}\\left(\\rho_0 - \\beta + \\sum_{j=1}^6 \\frac{\\beta_j \\lambda_j}{(s+\\lambda_j)}\\right) $$ \nWe note that $\\beta = \\sum_{j=1}^6 \\beta_j$ and we can move the $\\beta$ term into the summation as\n$$ s = \\frac{1}{\\Lambda}\\left(\\rho_0 + \\sum_{j=1}^6 \\frac{\\beta_j \\lambda_j}{(s+\\lambda_j)}-\\beta_j\\right) $$ \nor more simply\n$$ s = \\frac{1}{\\Lambda}\\left(\\rho_0 - \\sum_{j=1}^6 \\frac{\\beta_j s}{(s+\\lambda_j)}\\right) .$$ \nHere it is important to recall that $\\Lambda \\equiv \\frac{\\ell}{k}$, and $\\rho_0 = \\frac{k-1}{k}$. Since both terms are dependent on $k$ and our final goal is to solve for $\\rho_0$, we will eliminate $\\Lambda$. Manipulation of the reactivity formula leads us to the expression\n$$ k = \\frac{1}{1-\\rho_0} $$\nand so using this in our formula for the mean generation time gives\n$$ \\Lambda = \\ell(1-\\rho_0) $$\nWe substitute this in for $\\Lambda$ in our equation for $s$ to get\n$$ s = \\frac{1}{\\ell(1-\\rho_0)}\\left(\\rho_0 - \\sum_{j=1}^6 \\frac{\\beta_j s}{(s+\\lambda_j)}\\right) .$$\nFinally, we solve algebraically for $\\rho_0$ to get the \\textbf{inhour equation}:\n$$ \\rho_0 = \\frac{s\\ell}{s\\ell + 1} + \\frac{1}{s\\ell + 1}\\sum_{j=1}^6 \\frac{\\beta_j s}{(s+\\lambda_j)} .$$ \n\nWhen this equation is plotted, we can see that there are 7 possible solutions ($s_1$, $s_2$, $s_3$, ... $s_7$) for any value of $\\rho_0$. There are also 7 vertical asymptotes, each corresponding to a value of $s$ for which the denominator of any term in the 6-group inhour equation goes to zero (at $s=-\\frac{1}{\\ell}$ and $s=-\\lambda_j$ for all $j$).\n%\\includegraphic[width=10cm]{inhour-6group.jpg}\n\nIf we only had 1 delayed neutron group rather than 6, our equation would be \n$$ \\rho_0 = \\frac{s\\ell}{s\\ell + 1} + \\frac{1}{s\\ell + 1}\\frac{\\beta_j s}{(s+\\lambda)} .$$ \nThere would now only be two possible solutions ($s_1$ and $s_2$) and two vertical asymptotes (at $s=-\\frac{1}{\\ell}$ and $s=-\\lambda$).\n%\\includegraphic[width=10cm]{inhour-1group.jpg}\n\n\n\n\\end{document}\n\n", "meta": {"hexsha": "363f8368bad52b6023eaa9cf57df637cbbb26389", "size": 5123, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/drafts/disc10_notes-inhour.tex", "max_stars_repo_name": "mitchnegus/NE150-discussion", "max_stars_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/drafts/disc10_notes-inhour.tex", "max_issues_repo_name": "mitchnegus/NE150-discussion", "max_issues_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/drafts/disc10_notes-inhour.tex", "max_forks_repo_name": "mitchnegus/NE150-discussion", "max_forks_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.3382352941, "max_line_length": 636, "alphanum_fraction": 0.6988092914, "num_tokens": 1570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241911813151, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.40782903781104823}}
{"text": "Figure \\ref{fig:cooperation_M} shows cooperation levels achieved after $N=200$ iterations [i.e., $200 \\times 49^2 = 480200$ Monte Carlo Steps (MCS)] for migration Moore's distances $M = \\{1,3,5,7,9,11,13 \\}$, as a function of the grid density $d$ and the probability of property violation $s$. At initialization ($i=0$), there is a $50\\%$ chance that a player will be a cooperation (resp. defector). For all $M$, the cooperation exhibits a sharp drop for $d>d^*$  and $s > s^*$ with $(d^*,s^*)$ being a function of $M$. High levels of cooperation ($c > 0.8$) can be sustained for any migration range $M$ (note that for $0.02 < s < 0.05$, the cooperation level drops already to $c \\approx 0.9$ for all $M$). However, the less migration capabilities (i.e., $M$ small), the more restrictive the space defined by $(d^*,s^*)$ and hence, the more sensitive the game to property violations (as shown on Figure  \\ref{fig:cooperation_M}).\\\\\n\nFor high grid density ($d>0.9$), cooperation cannot be sustained for any level of migration $M>0$, even with low property violation ($s > 0$). Note that in the limit $d=1$, property violation reduces to swapping sites, since the only available site in the Moore area for the expelled player is the site left by the property violator.\\\\\n\n\\subsection*{Phase Transitions}\nThe smaller $M$, the sharper the transition between sustained cooperation and $c=0$: The probability to witness a given level of cooperation $c > 0$ (after $N=200$ iterations) decreases steadily (faster as $M \\rightarrow 1$), until a point of abrupt break beyond which cooperation can no longer not strive (see Figure \\ref{fig:phase_transition} for $0.4 < d < 0.6$). For $M \\leqslant 5$, we observe a sharp phase transition from a high cooperation level $c \\gtrsim 0.6$ to no cooperation left ($c=0$). For $M \\geqslant 7$, we observe 3 possible states: high cooperation level $c \\gtrapprox 0.6$ for property violation $s \\lessapprox 0.4$ small, moderate cooperation $ 0.35 \\lessapprox s  \\lessapprox 0.5 $, and no cooperation.\\\\\n \nThese possible states and their stability are best represented (c.f., Figure \\ref{fig:tseries}) from the cooperation time series for values $(M,d^*,s^*)$ with $M = \\{ 5,7,11,13 \\}$. For $M=5$, the intermediary state is not sustainable, and it seems that if a certain level of cooperation $c > 0.5$ cannot be achieved quickly cooperation ultimately disappears. For $M = \\{7,11\\}$ , an intermediary state appears with simulations displaying quasi-stationarity of cooperation $0.35 < c < 0.55$. Yet the stationary of this intermediary state may be broken after an arbitrary number of iterations (see e.g., simulation 12 for $M=7$, which drops after 170 iterations, or simulation 3 for $M=11$, which drops after 140 iterations). {\\bf It also looks like that for $M=7$, the state of high cooperation is reached quickly and at high level, but this may be a pure selection bias}. For $M=13$ and for $s^* = 0.67(2)$, the intermediary state is stable (no deviation after an arbitrary number of iterations is observed), and the percentage of cooperators remains consistently below 0.5 (more precisely XX on average, standard deviation = XX). In other words, for a large enough migration range, cooperation can be sustained at rather high levels of property violation (e.g., $M=13, s^* = 0.67\\pm0.2$), although cooperators are in minority.\\\\\n\n\\subsection*{Typical Spatial Configurations}\n\n{\\bf [Here we show typical spatial configurations]}\n\n\\begin{itemize}\n  \\item rapid extinction of cooperators in presence of $s > s^*$.\n  \\item well sustained cooperation in presence of property violators, yet with sufficiently high mobility $M$ and low enough grid density $d$ $\\rightarrow$ $M=11$.\n  \\item cooperation at quasi-stationarity with level consistently below $0.5$ (e.g., $M=13$).\n\\end{itemize}\n\n\\subsection*{Case Study of Sudden Drops Cooperation Drops}\n\n{\\bf [Here, we study the 2 sudden changes of regime mentioned above] }", "meta": {"hexsha": "6caab0d03ff6486ff57666f474368ee6b40da11c", "size": 3949, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/sections/results_chunks.tex", "max_stars_repo_name": "wazaahhh/pgames", "max_stars_repo_head_hexsha": "acf6fbb86d689ee307b6b2f807bc29fb6a818535", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "manuscript/sections/results_chunks.tex", "max_issues_repo_name": "wazaahhh/pgames", "max_issues_repo_head_hexsha": "acf6fbb86d689ee307b6b2f807bc29fb6a818535", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2015-11-06T18:21:13.000Z", "max_issues_repo_issues_event_max_datetime": "2015-11-06T20:28:50.000Z", "max_forks_repo_path": "manuscript/sections/results_chunks.tex", "max_forks_repo_name": "wazaahhh/pgames", "max_forks_repo_head_hexsha": "acf6fbb86d689ee307b6b2f807bc29fb6a818535", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-01T15:55:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T15:55:10.000Z", "avg_line_length": 179.5, "max_line_length": 1330, "alphanum_fraction": 0.7379083312, "num_tokens": 1065, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.40782903719772784}}
{"text": "\\chapter{Causality}\n\n\\begin{multicols}{2}[\\subsubsection*{Contents of this chapter}]\n   \\printcontents{}{1}{\\setcounter{tocdepth}{2}}\n\\end{multicols}\n\n\\section{Generalized Random Forests}\nNotes on \\citeasnoun{athey2016generalized}. Like most regression techniques, random forests are normally used to estimate the conditional mean of some data generating distribution, i.e. $\\mu(x) = \\mathbb{E}\\left[Y|X=x \\right]$. Athey, Tibshirani and Wager proposed generalized random forests, which estimate, more generally, some quantity $\\theta(x)$. The main aim, and the reason why I am grouping this method under ``causality\", is the estimation of heterogenous treatment effects. \n\n", "meta": {"hexsha": "24de578612935eb8596da9355a6999e3d1e9af00", "size": 674, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/causality.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/causality.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/causality.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.4, "max_line_length": 484, "alphanum_fraction": 0.7744807122, "num_tokens": 174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6261241632752915, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.40782901963432394}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{matlab-prettifier}\n\\usepackage{graphicx}\n\\usepackage[export]{adjustbox}\n%\n% Basic Document Settings\n%\n\\lstMakeShortInline[style=Matlab-editor]\"\n\n\\topmargin=-1in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{AMATH 482 Homework 2: G\\'abor transforms}\n\\newcommand{\\hmwkDueDate}{January 25, 2019}\n\\newcommand{\\hmwkClassInstructor}{Professor Nathan Kutz}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Skyler Hallinan}}\n\n%\n% Title Page\n%\n\n\\title{\n    \\textmd{\\textbf{\\text{ } \\hmwkTitle}}\\\\\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\section*{\\fontsize{19}{15}\\selectfont Abstract}\n\tWe started with data (music) in the time domain. Using the Gabor transform, we were able to translate this data into the time and frequency domain, creating a spectogram that allows us to visualize frequencies at specific points in time. We experimented with the different parameters used in the transform, and used it to transform to differentiate between the music of a piano and a recorder.\n\\section*{\\fontsize{19}{15}\\selectfont Introduction and Overview}\n\tIn data such as music, we often collect it in in the time domain - Although we can tell when things happen, it is hard to tell what is going on in terms of frequencies. The Fourier Transform is a solution lets us transport this data into the frequency domain. However, with this transformed data, we now know what frequencies occur, but we have do not now when they occur in time. The Gabor transform allows us to take small chunks of data across our time domain, which are isolated by multiplying a filter around, then taking the Fourier transform of this data. Combining this frequency data across the small chunks of time allows us to have both a time and frequency visualization of data: We are now able to see what frequencies dominate at each small time interval. \\\\ \\\\\n\tIn this project, we will first look at the effects of changing specific paramaters of the Gabor transform, like sampling rate, as well as window size (how much of the entire domain it captures at each timepoint). In addition, we will experiment with other filters other than the standardly used Gaussian one. Finally, we will look at data taken from a recorder and piano, remove the overtones, and then reproduce the music score, and note the differences between the two instruments.\n\\section*{\\fontsize{19}{15}\\selectfont Theoretical Background}\n\tWe have seen that the fourier transform is an integral transform that decomposes a time defined function into its frequency components, and is defined by\n\t\\begin{equation} \\label{eq:2a}\n\t\tF(k) = \\frac{1}{\\sqrt2\\pi} \\int_{-\\infty}^{\\infty} e^{-ikx} f(x) dx\n\t\\end{equation}\n\t\t\\begin{equation} \\label{eq:2b}\n\t\tf(x) = \\frac{1}{\\sqrt2\\pi} \\int_{-\\infty}^{\\infty} e^{ikx} F(k) dk\n\t\\end{equation}\n\tThe fast fourier transform, which is accessible in things like MATLAB, assumes that the user is working on a $2\\pi$ periodic domain. \"fftshift\" must be used on the transformed data to undo the shifts naturally incurred by the fast fourier transform algorithm. \\\\ \\\\\nA downside to the fourier transform is that in changing the domain to the frequency domain, it completely removes all time data from the equation. There is no way to visualize what is going on in terms of a time scale. G\\'abor resolved this issue. \\\\\nThe Gabor transform is defined by $\\mathcal { G } [ f ] ( t , \\omega ) = \\tilde { f } _ { g } ( t , \\omega ) = \\int _ { - \\infty } ^ { \\infty } f ( \\tau ) \\overline { g } ( \\tau - t ) e ^ { - i \\omega \\tau } d \\tau = \\left( f , \\overline { g } _ { t , \\omega } \\right)$. We see that this GAabor function localizes signal with the fourier transform over specific small windows of time. The $\\tau$ paramater is able to slide the window across the entire domain, resulting in a capturing of both time and frequency domain. Because of the nature of this transform, it is also called the short time fourier transform. \\\\ \\\\\nThere are limitations to this method: It is not possible to have perfect resolution in both the frequency and the time domain; increasing time resolution decreases frequency resolution and vice versa. Just like the Heisenberg Uncertainty Principle, it is impossible to know both of these things at the same time. However, one can adjust the parameters of the transform in order to get more data towards one direction or the other. \\\\ \\\\\nWavelets are used in these transforms to highlight specific parts of the signal. Wavelets like the Gaussian and the Mexican Hat wavelet are shifted across the time domain and multiplied by the data so that specific fourier transform information can be taken, and then plotted later.\n\\section*{\\fontsize{19}{15}\\selectfont Algorithm Implementation and Development}\n\\textbf{Part One} \\\\\nWe first found the length of our data and the number of time points at which it occurred, then created a vector of time. \nIn addition, we rescaled our wavenumbers $k$ by $\\frac{2\\pi}{L}$ as the fast fourier transform assumes $2\\pi$ periodic signals. We then defined a vector \"tslide\" which corresponded to the length of time of the recording of music, in 0.1 s increments. \\\\ \\\\\nWe then used a for loop to iterate through the length of \"tslide\", creating and adjusting a Gaussian filter so that it was centered around \"t-tslide\" the entire time. We multiplied this filter by our data, then took the fast fourier transform of it. Finally, we entered it back into our spectogram array after taking the absolute value of the \"fftshift\" of this. We repeated this with larger and smaller increments in our \"tslide\", different filters (Mexican Hat and Step function), and with different widths of our Gaussian filter. Finally, we used \"pcolor\" to visualize our G\\'abor Transforms in the form of spectograms. We had to divide by $2pi$ to get accurate frequency information since we multiplied by $2pi$ in our original wavenumbers. \\\\ \\\\\n\\textbf{Part Two} \\\\\nWe repeated the same initial data preparation used for part one: Defining the length of the data, creating our \"tslide\" variable, and rescaling our wavenumbers. We did the same loop to fill our spectogram with data, using a Gaussian filter with a sigma value of -100. We then used $pcolor$ to plot the side by side spectograms, once again dividing by $2pi$ to get accurate frequency values. \\\\ \\\\\nWe also did some more work in the same G\\'abor transform loop to generate the music scores. In order to remove overtones from the data, we found the index of the max value of the fourier transform at a certain time. The max value indicated that this particular frequency is the strongest at this time point, so we could effectively extract the corect frequency while removing some overtone noise. We did this by using the \"max\" command during the G\\'abor transform loop, then plugging this index into \"ks\". We then, once again, divided by $2pi$ to get our frequency numbers.\n\\begin{figure}[H]\n\\begin{center}\n\\includegraphics[width = 10cm]{normal}\n\\caption{\\label{fig:scaled_diss} (left) Spectogram of normally made data}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width = 8cm]{undersampling}\n\\includegraphics[width = 8cm]{oversampling}\n\\caption{\\label{fig:scaled_diss} (left) Spectogram of Undersampled Data}\n\\caption{\\label{fig:scaled_diss} (right) Spectogram of Oversampled Data}\n\\end{center}\n\\end{figure}\n\n\\section*{\\fontsize{19}{15}\\selectfont Computational Results}\n\t\\textbf{Part One} \\\\\n\tWe were able to find a balance of the correct level of accuracy in the time and frequency domain by using a value of -100 for our sigma in our Gaussian filter. We first generated a spectogram of our data using this accurate filter, as well as a reasonable sampling amount (100). We then compared it to our undersampled and oversampled data. We see that in when we undersample, the quality of the data dramatically dips, and we are left with an incoherent spectogram, both in the time and the frequency domain. Oversampling, on the other hand, produces a slightly clearer spectogram. Although this may sound good in principle, the benefits of oversampling were minimal - the spectograms of the normally sampled and oversampled data looked almost identical - the negatives were that run time severely increased because we were introducing so much more data.\\\\ \\\\\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width = 8cm]{shannon}\n\\includegraphics[width = 8cm]{mxhat}\n\\caption{\\label{fig:scaled_diss} (left) Spectogram of Shannon Filtered Data}\n\\caption{\\label{fig:scaled_diss} (right) Spectogram of Mexican Hat Filtered Data}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width = 8cm]{largewindow}\n\\includegraphics[width = 8cm]{smallwindow}\n\\caption{\\label{fig:scaled_diss} (left) Spectogram of Large Window Filtered Data}\n\\caption{\\label{fig:scaled_diss} (right) Spectogram of Small Window Filtered Data}\n\\end{center}\n\\end{figure}\nWe see that when we decreased the window, we got very precise measurements in the frequency domain. This is because we were essentially taking the fourier transform of a huge area, which will give us lots of information about the frequency, but not the time data. The convserse was true for a large window; We were able to see lots of information in the time domain, but because our window size was so small, we couldn't get as precise frequency measurements. \\\\ \\\\\nThe Mexican Hat function and Step function (Shannon) performed similarly to the Gaussian filter. We see in the spectograms that although they are similar to eachother, while the Shannon filtered data seems to have a bit more accuracy in the frequency domain at the sacrifice of less resolution in the time domain. The time domain is more continuous for the Mexican Hat filtered data, but there is less resolution in the frequency domain. However, these are both useful filters like the Gaussian filter. In both of these, we used a sigma value of 0.05, which changed the width of the filter. We also observed the same window size and undersampling/oversampling effects with these filters.\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width = 16cm]{pianorecorder}\n\\caption{\\label{fig:scaled_diss} (right) Piano and Recorder Spectogram}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width = 8cm]{piano}\n\\includegraphics[width = 8cm]{recorder}\n\\caption{\\label{fig:scaled_diss} (left) Piano Score}\n\\caption{\\label{fig:scaled_diss} (right) Recorder Score}\n\\end{center}\n\\end{figure}\n\\textbf{Part Two} \\\\\nWe were able to determine the score of the music from the piano data, after filtering out overtones, and see that they follow the same general pattern, but are at different frequencies. From the spectograms of the data between the recorder and the piano, we see that there seem to be more overtones and undertones on the piano than there are in a recorder. In the case of the piano, we see that outside of the brightly colored frequency areas, there are lots of residual frequencies above and below it. In recorders, we see that most of the other frequencies seem to be below the note. \n\n\\section*{\\fontsize{19}{15}\\selectfont Summary and Conclusions}\nWe started with music data purely in the time domain. In order to visualize this data in the time and frequency domain, we employed the Ga\\'bor transform, which allowed us to create spectograms to visualize the data. We were able to see how changing parameters in the filter, as well as changing the filter itself, affected the transformation. Finally, from music data from a piano and a recorder, we took the G\\'abor transform and filtered out overtones in order to reproduce the score.\n\\section*{\\fontsize{19}{15}\\selectfont Appendix A}\n\\subsection*{MATLAB functions used and implementation}\n\"abs(X)\" : Returns the absolute value of every element in X, or complex magnitude if the element is complex. We used this function to normalize the data before plotting our spectogram.\\\\ \\\\\n\"fft(X)\" : Performs a fast fourier transform on \"X\", a 2-D array. We used this fourier transform the filter multiplied by the data at each of our time points.\\\\ \\\\\n\"fftshift(X)\" : Rearranges the contents of \"X\" by placing the zero-frequency component to the center of the array. If \"X\" is a vector, shifts the left and right halves of \"X\", while if \"X\" is a matrix, the $I$ and $III$ quadrants are switched, as well as the $II$ and $IV$ quadrants. We used this to change our transformed data and our axes for proper visualization.  \\\\ \\\\\n\"linspace(x1,x2,n)\" : Creates a vector of \"n\" evenly spaced points from \"x1\" to \"x2\". We used this to create our linearly spaced data.  \\\\ \\\\\n\"[M,I] = max(A)\" : Returns the maximum value \"M\" and the index \"I\"  of the matrix. We used this in part 2 to filter out the overtones by determining the index of the max value of a fourier transform of a time slice.\n\\pagebreak\n\\section*{\\fontsize{19}{15}\\selectfont Appendix B}\n\\subsection*{MATLAB code}\n\\begin{lstlisting}[style=Matlab-editor]\n%Part One\nclear all; close all; clc;\nclear all; close all; clc;\n\nload handel\nv = y'/2;\nv(end) = [];\nvt = fft(v);\n\n%My code\nL = 9; n = length(v);\nt2 = linspace(0, L, n+1); t= t2(1:n);\nk = (2*pi/L) * [0:n/2-1 -n/2:-1]; ks = fftshift(k);   \n\nsubplot(2,1,1)\nplot(t,v);\nxlabel('Time [sec]');\nylabel('Amplitude');\ntitle('Signal of Interest, v(n)');\n\nsubplot(2,1,2)\nplot(ks, abs(fftshift(vt)));\n\n\n%Gaussian Window\ntslide= 0:0.1:9;\nspc = [];\nspcsmallwindow = [];\nspclargewindow = [];\nspcmxhat = [];\nspcshn = [];\n\nfigure(2)\nfor j=1:length(tslide)\n    g = exp(-100*(t-tslide(j)).^2);\n    gsm = exp(-1*(t-tslide(j)).^2);\n    glg = exp(-1000*(t-tslide(j)).^2);\n    \n    omega = 0.05;\n    mxhat = (2/ (sqrt(3*omega) * pi^(0.25))).* (1-((t-tslide(j))/omega).^2) .* exp(-((t-tslide(j)).^2)/(2 * omega^2));\n    \n    sig = 0.05;\n    shn = abs(t-tslide(j)) <= sig/2;\n    \n    vg = g.*v;\n    vgt = fft(vg);\n    \n    vgsm = gsm.*v;\n    vgsmt =fft(vgsm);\n    \n    vglg = glg.*v;\n    vglgt =fft(vglg);\n    \n    vmx = mxhat.*v;\n    vmxt = fft(vmx);\n    \n    vshn = shn.*v;\n    vshnt = fft(vshn);\n    \n%     subplot(2,1,1)\n%     plot(t,v,'k-', t, mxhat, 'Linewidth', 2);\n%     axis([0 9 -0.5 1])\n%     \n%     subplot(2,1,2)\n%     plot(t,vg, 'Linewidth', 2);\n%     axis([0 9 -0.4 0.4])\n%     \n    spc = [spc; abs(fftshift(vgt))];\n    spcsmallwindow = [spcsmallwindow; abs(fftshift(vgsmt))];\n    spclargewindow = [spclargewindow; abs(fftshift(vglgt))];\n    spcmxhat = [spcmxhat; abs(fftshift(vmxt))];\n    spcshn = [spcshn; abs(fftshift(vshnt))];\n    pause(0.00001);\nend\n\ntslideover = 0:0.01:9;\nspcover = []\nfor j=1:length(tslideover)\n    g = exp(-200*(t-tslideover(j)).^2);\n    vg = g.*v;\n    vgt = fft(vg);\n    \n    spcover = [spcover; abs(fftshift(vgt))];\n    pause(0.00001);\nend\n\ntslideunder = 0:1:9;\nspcunder = []\nfor j=1:length(tslideunder)\n    g = exp(-200*(t-tslideunder(j)).^2);\n    vg = g.*v;\n    vgt = fft(vg);\n    \n    spcunder = [spcunder; abs(fftshift(vgt))];\n    pause(0.00001);\nend\n\nfigure;\n%frequency here?\npcolor(tslide,ks./(2*pi),spc.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Normal sampling, normal window\");\n\nfigure;\npcolor(tslide,ks./(2*pi),spcsmallwindow.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Normal sampling, small window\");\n\nfigure;\npcolor(tslide,ks./(2*pi),spclargewindow.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Normal sampling, large window\");\n\nfigure;\npcolor(tslide,ks./(2*pi),spcmxhat.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Mexican Hat, omega = 0.05\");\n\nfigure;\npcolor(tslide,ks./(2*pi),spcshn.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Step Function (Shannon), sigma = 0.05\");\n\nfigure;\npcolor(tslideover,ks./(2*pi),spcover.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Oversampling\");\n\nfigure;\npcolor(tslideunder,ks./(2*pi),spcunder.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Undersampling\");\n\n%Part Two\nclose all; clear all; clc;\n\npia=(audioread('music1.wav')).'; \n% plot((1:length(pia))/Fs,pia);\n% xlabel('Time [sec]'); ylabel('Amplitude');\n% title('Mary had a little lamb (piano)'); drawnow\n\nLpia=16;  % record time in seconds%\nn = length(pia);\nFspia=length(pia)/Lpia;\nt2 = linspace(0, Lpia, n+1); tpia= t2(1:n);\nkpia = (2*pi/Lpia) * [0:n/2-1 -n/2:-1]; kspia = fftshift(kpia); \ntslidepia = 0:0.2:16;\n\nspcpia = [];\npianotes = [];\nfor j=1:length(tslidepia)\n    g = exp(-100*(tpia-tslidepia(j)).^2);\n    \n    vgpia = g.*pia;\n    vgpiat = fft(vgpia);\n    [M,I] = max(vgpiat);\n    \n    pianotes = [pianotes; abs(kpia(I))/(2*pi)];\n    spcpia = [spcpia; abs(fftshift(vgpiat))];\nend\n\n%figure(2)\nrec=(audioread('music2.wav')).'; \n% plot((1:length(rec))/Fs,rec);\n% xlabel('Time [sec]'); ylabel('Amplitude');\n% title('Mary had a little lamb (recorder)');\n\nLrec=14;  % record time in seconds\nFsrec=length(rec)/Lrec;\nn = length(rec);\nt2 = linspace(0, Lrec, n+1); trec= t2(1:n);\nkrec = (2*pi/Lpia) * [0:n/2-1 -n/2:-1]; ksrec = fftshift(krec); \ntsliderec = 0:0.2:16;\n\nspcrec = [];\nrecnotes = [];\nfor j=1:length(tsliderec)\n    g = exp(-100*(trec-tsliderec(j)).^2);\n    \n    vgrec = g.*rec;\n    vgrect = fft(vgrec);\n    \n    [M,I] = max(vgrect);\n    recnotes = [recnotes; abs(krec(I))/(2*pi)];\n    \n    spcrec = [spcrec; abs(fftshift(vgrect))];\nend\n\n% figure;\n% \nsubplot(2,1,1)\npcolor(tslidepia,(kspia/(2*pi)),spcpia.'), shading interp\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Piano\");\nylim([0 400])\nsubplot(2,1,2)\npcolor(tsliderec,ksrec/(2*pi),spcrec.'), shading interp, colormap(hot)\nxlabel(\"Time (s)\");ylabel(\"Frequency (Hz)\"); title(\"Recorder\");\nylim([600 1000])\n\nplot(tslidepia,pianotes,'o','MarkerFaceColor', 'b');\nyticks([246.9417,261.6256,277.1826,293.6648,311.127,329.6276,349.2282]);\nyticklabels({'B3','C4','C#4','D4','E4','F4'});\nylim([246 350])\ntitle(\"Score for Piano Music (~250-350Hz\");\nxlabel(\"Time (s)\"); ylabel(\"Notes corresponding to frequency (Hz)\");\n\nplot(tsliderec,recnotes,'o', 'MarkerFaceColor', 'b')\nyticks([698.4565,739.9888,783.9909,830.6094,880,932.3275]);\nyticklabels({'F5','F#5','G5','G#5','A5','A#5'});\nylim([680 950])\ntitle(\"Score for Recorder Music (~680-950Hz)\");\nxlabel(\"Time (s)\"); ylabel(\"Notes corresponding to frequency (Hz)\");\n\\end{lstlisting}\n\n\\end{document}\n", "meta": {"hexsha": "1ce67d849b2690f515631cb585c0d581b7c47ed4", "size": 18868, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW2/HW2.tex", "max_stars_repo_name": "shallinan1/AMATH-482", "max_stars_repo_head_hexsha": "3ce6b7df17fa4c66d93e13a0cfe119d4551b45d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW2/HW2.tex", "max_issues_repo_name": "shallinan1/AMATH-482", "max_issues_repo_head_hexsha": "3ce6b7df17fa4c66d93e13a0cfe119d4551b45d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW2/HW2.tex", "max_forks_repo_name": "shallinan1/AMATH-482", "max_forks_repo_head_hexsha": "3ce6b7df17fa4c66d93e13a0cfe119d4551b45d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.1327913279, "max_line_length": 861, "alphanum_fraction": 0.7229701081, "num_tokens": 5393, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.40768626088252297}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{tabularx}\n\\usepackage{multicol}\n\\usepackage{algpseudocode}\n\\usepackage{algorithm}\n\n% Geometry \n\\usepackage{geometry}\n\\geometry{letterpaper, left=15mm, top=20mm, right=15mm, bottom=20mm}\n\n% Fancy Header\n\\usepackage{fancyhdr}\n\\renewcommand{\\footrulewidth}{0.4pt}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\chead{CSC 360 - Analysis of Algorithms}\n\\lfoot{CALU Fall 2021}\n\\rfoot{RDK}\n\n% Add vertical spacing to tables\n\\renewcommand{\\arraystretch}{1.4}\n\n% Macros\n\\newcommand{\\definition}[1]{\\underline{\\textbf{#1}}}\n\n\\newenvironment{rcases}\n  {\\left.\\begin{aligned}}\n  {\\end{aligned}\\right\\rbrace}\n\n% Begin Document\n\\begin{document}\n\n\n\\section*{Notes Week 6}\n\n\\begin{itemize}\n\n    \\item Read Chapters 22, Chapter 9 for Week 7\n\n\\end{itemize}\n\n\n\\subsection*{Rules for Big O Notation (Upper Bounds)}\n\n\\begin{itemize}\n\n    \\item \\textbf{Transitivity}: If $f = O(g)$ and $g = O(h)$ then $f = O(h)$\n\n    \\item \\textbf{Sums}: If $f_1 = O(g_1)$ and $f_2 = O(g_2)$ then $f_1(n) + f_2(n) = O( max(f, g) )$\n    \n    \\item \\textbf{Products}: If $f_1 = O(g_1)$ and $f_2 = O(g_2)$ then $f_1 \\times f_2 = O(g_1 \\times g_2)$\n\n    \\item If the largest term is a polynomial of degree $k$, then the whole thing is $\\Theta(n^k)$\n\n    \\item $log^kn = O(n) \\rightarrow$ a log raised to any constant power is still just $O(n)$\n\n    \\item $\\lim{n\\to\\infty} \\frac{f(n)}{g(n)} \\rightarrow$ If the limit is:\n    \\begin{itemize}\n        \\item \\textbf{0} $\\rightarrow f=o(g) \\rightarrow g(n) > f(n) \\rightarrow g$ dominates $f$\n        \\item \\textbf{$c \\neq 0$} $\\rightarrow f = \\Theta(g(n)) \\rightarrow g(n) = \\Theta(f(n))$\n        \\item \\textbf{$\\infty$} $\\rightarrow g(n) = o(f(n))$\n    \\end{itemize}\n\n    \\item Example: $f(n) = \\frac{n}{log(n), g(n) = n^{\\frac{1}{2}}log^2n}$\n\n\\end{itemize}\n\n\n\\subsection*{Rules for Big $\\Omega$ Notation (Lower Bounding)}\n\n\\begin{itemize}\n\n    \\item \\textbf{Comparison-based Solution} $\\omega(nlogn) \\rightarrow$ it's been proven that comparison-based sorting cannot be faster\n    \n    \\item Some problems are $\\Omega(2^n) \\rightarrow$ Super slow\n\n\\end{itemize}\n\n\n\\subsection*{Quick Maths}\n\n\\begin{itemize}\n\n    \\item $b^{log_ba} = a$\n\n    \\item $a^{log_bn} = n^{log_ba}$\n\n    \\item Any exponential function dominates any polynomial\n    \\begin{itemize}\n        \\item Exponential function $\\rightarrow 2^n \\rightarrow$ variable in the exponent\n        \\item Polynomial function $\\rightarrow n^{234} \\rightarrow$ exponent is a constant\n    \\end{itemize}\n\n    \\item $\\sum(ca_k + b_k) = c\\sum(a_k) + \\sum(b_k)$\n\n\\end{itemize}\n\n\n\\section*{Recurrences - Recurrence Relations}\n\n\\begin{itemize}\n\n    \\item A \\definition{Recurrence} is used when dealing with recursion. \n    \n    \\item Merge Sort: \\\\\n    \n    \\begin{tabular}{l c c}\n        \\textbf{Case} & \\textbf{Formula} & \\textbf{Big O} \\\\\n        base case & $T(n) = \\Theta(1)$ & $\\Theta(1)$ \\\\\n        not base case & $2T(\\frac{n}{2}) + \\Theta(n)$ & ? \n    \\end{tabular}\n\n    \\item How does $2T(\\frac{n}{2})$ explain the recurrence of merge sort?\n    \\begin{itemize}\n        \\item Each division splits the array in half\n        \\item There are two pieces in each call, one for each half\n        \\item So the array is split in half, and each is operated on recursively\n    \\end{itemize}\n\n    \\item So what is the $O($merge-sort$)$ \n    \\begin{itemize}\n\n        \\item $T(n) = 2T(\\frac{n}{2}) + n \\rightarrow$ Merge Sort Recurrence\n        \\item Solve using iteration method: ``Unfold the recurrence''\n        \\begin{enumerate}\n\n            \\item If there's a constant, write out that constant with square brackets empty to indicate something needs done\n            \\begin{equation}\n                2[\\ \\ \\ ] + n\n            \\end{equation}\n\n            \\item Plug the $\\frac{n}{2}$ back into the original\n            \\begin{equation}\n                2[ 2T(\\frac{n}{4}) + \\frac{n}{2} ] + n\n            \\end{equation}\n\n            \\item Multiply it out\n            \\begin{equation*}\n                4T(\\frac{n}{4}) + 2n\n            \\end{equation*}\n\n            \\item Take the previous iteration (2) and repeat\n            \\begin{equation}\n                4[ 2T(\\frac{n}{8}) + \\frac{n}{4} ] + 2n\n            \\end{equation}\n\n            \\item Simplify\n            \\begin{equation*}\n                8T(\\frac{n}{8}) + 3n\n            \\end{equation*}\n\n            \\item Repeat the process until you can spot the general case. The next iteration would be\n            \\begin{equation}\n                16T(\\frac{n}{16}) + 4n\n            \\end{equation}\n\n            \\item Write down the general case in terms of $k$\n            \\begin{equation*}\n                2^k(\\frac{n}{2^k}) + kn\n            \\end{equation*}\n\n            \\item How many times does the recurrence occur? $k = log_2n$\n\n            \\item Plug in k\n            \\begin{equation*}\n                2^{log_2n} T(\\frac{n}{2^{log_2n}}) + nlog_2n\n            \\end{equation*}\n\n            \\item Simplify\n            \\begin{equation*}\n                n T(1) + nlog_2n = O(nlog_2n)\n            \\end{equation*}\n\n        \\end{enumerate}\n\n    \\end{itemize}\n\n\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "0a95d8660d57e58a7061e29fa69443262715d41c", "size": 5150, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/Week 6/notes.tex", "max_stars_repo_name": "Bkrenz/calu-csc360", "max_stars_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Notes/Week 6/notes.tex", "max_issues_repo_name": "Bkrenz/calu-csc360", "max_issues_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/Week 6/notes.tex", "max_forks_repo_name": "Bkrenz/calu-csc360", "max_forks_repo_head_hexsha": "8600fb644e145cca27e10b084e9ddf62fbc84f4e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1420765027, "max_line_length": 136, "alphanum_fraction": 0.5908737864, "num_tokens": 1614, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.40768625742492526}}
{"text": "\\documentclass{article}\n%\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage{tabu}\n\\usepackage{longtable}\n\\usepackage{mathrsfs}\n\\usepackage{enumerate}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{fancyhdr}\n\\pagestyle{fancy}\n\\lhead{Final 04}\n\\rhead{Jon Allen}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\\newcommand{\\degree}{\\ensuremath{^\\circ}}\n\n\\begin{document}\n\\subsubsection*{PDE C.}\n\\begin{align*}\n  \\text{PDE.}&&\\frac{\\partial u}{\\partial t}&=\\frac{\\partial^2u}{\\partial x^2}&&\\text{for}&0&<x<\\infty,&0&<t<\\infty\\\\\n  \\text{BC.}&&\\frac{\\partial u}{\\partial x}(0,t)&=u(0,t)-\\frac{1}{\\sqrt{\\pi t}}&&\\text{for}&&&0&<t<\\infty\\\\\n  \\text{IC.}&&u(x,0)&=0&&\\text{for}&0&<x<\\infty\n\\end{align*}\n\nSolve PDE C completely by a Laplace transform with respect to $t$. Use the BC as stated -- do not transform to homogeneous BC. (The necessary inverse Laplace transform is not in the textbook table but is on the handout list of transforms.)\n\n\\begin{align*}\n  sU(x)-0&=\\frac{\\mathrm{d}^2U}{\\mathrm{d}x^2}(x)\\\\\n  \\frac{\\mathrm{d}U}{\\mathrm{d}x}(0)&=U(0)-\\mathcal{L}\\left\\{\\frac{1}{\\sqrt{\\pi t}}\\right\\}\\\\\n  &=U(0)-\\frac{1}{\\sqrt{s}}\\qquad\\text{used computer}\\\\\n  0&=\\frac{\\mathrm{d}^2U}{\\mathrm{d}x^2}(x)-sU(x)\\\\\n  0&=r^2+0r-s\\\\\n  r&=\\frac{\\pm\\sqrt{4s}}{2}=\\pm\\sqrt{s}\\\\\n  U(x)&=c_1e^{x\\sqrt{s}}+c_2e^{-x\\sqrt{s}}\\\\\n  U'(x)&=c_1\\sqrt{s}e^{x\\sqrt{s}}-c_2\\sqrt{s}e^{-x\\sqrt{s}}\\\\\n  U'(0)&=c_1\\sqrt{s}-c_2\\sqrt{s}=c_1+c_2-\\frac{1}{\\sqrt{s}}\\\\\n  c_1\\sqrt{s}-c_1&=c_2+c_2\\sqrt{s}-\\frac{1}{\\sqrt{s}}\\\\\n  \\intertext{used computer to help find convenient values}\n  c_1(\\sqrt{s}-1)&=\\frac{1}{s+\\sqrt{s}}+\\frac{\\sqrt{s}}{s+\\sqrt{s}}-\\frac{1}{\\sqrt{s}}\\\\\n  c_1(\\sqrt{s}-1)&=\\frac{\\sqrt{s}+s}{\\sqrt{s}(s+\\sqrt{s})}-\\frac{s+\\sqrt{s}}{\\sqrt{s}(s+\\sqrt{s})}\\\\\n  c_1=0\\\\\n  c_2&=\\frac{1}{s+\\sqrt{s}}\\\\\n  U(x)&=\\frac{1}{s+\\sqrt{s}}e^{-x\\sqrt{s}}\\\\\n  \\intertext{from handout}\n  u(x,t)&=e^{x+t}\\text{erfc}\\left(\\sqrt{t}+\\frac{x}{2\\sqrt{t}}\\right)\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "f821c8162a59199a1bdacdc6154ceda640e3b75f", "size": 2057, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "partial differential equations/pde-final-04.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "partial differential equations/pde-final-04.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "partial differential equations/pde-final-04.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8113207547, "max_line_length": 239, "alphanum_fraction": 0.6324744774, "num_tokens": 902, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6548947425132314, "lm_q1q2_score": 0.4076453526057122}}
{"text": "\\chapter{Introduction}\n\\label{chap:intro}\n\n\nAlthough Turing machines are a simple (but not quite simplistic) model of computation, there are not many \\textit{rigorous} proofs about Turing\nmachines in the literature.  We think that the following points are reasons for that.  First, their semantics is \\textit{unstructured}: from each\nstate of the machine, the execution can proceed in every other state, similar to the infamous \\textit{goto} statement~\\cite{dijkstra2002go}.  But even\nworse, Turing machines are not \\textit{compositional}.  Sequential composition or loops of Turing machines are not \\textit{per~se} available.  Even\nthe formal specification of machines is a burden, because complex machines may have a huge number of internal states.  Last but not least, they are\n\\textit{low-level}, because the operation on tapes are primitive: read a symbol from the tape, write a symbol to the tape, or move the (read/write)\nhead in a direction.\n\nFor the above reasons, textbooks like Boolos et~al.~\\cite{boolos2007computability} leave out detailed proofs of correctness.  They also often only\ngive an informal description of machines, which obviously makes formal reasoning impossible.  Even if they define the whole machine, they leave out\nformal specifications of invariants to figure out for the reader.  To establish that a function is Turing computable, authors often give an informal\ndescription of the algorithm and conclude, using the \\textit{Church-Turing thesis}, that the function is Turing-computable. Or they switch to another\nabstract machine model, but define the compilation function between the models of computation only informally.\n\nIn this thesis, we aim to define, specify, and formally verify Turing machines in a framework built in the theorem prover Coq~\\cite{Coq}.  First of\nall, we address the problems above.  Instead of defining machines in terms of transition tables, we compose machines using functions of Coq's\ndependent type theory -- the \\textit{Calculus of (Co)Inductive Constructions} (also known as CIC).  For example, we define a function that builds the\nsequential composition of two machines.  To eliminate the need to reason about concrete machine states, we give all states a label (e.g.\\ $\\true$ or\n$\\false$) and only have to reason about these labels.  The number of labels is always reasonable small, compared to the potential huge amount of\nstates.  We address the problem that machines are low-level, by introducing abstractions, so that we can define Turing machines that directly\nmanipulate values of arbitrary encodable types.  This gives the advantages of register machines, but we are not restricted to natural numbers.\n\nThere are many variants of Turing machines.  All variants can be shown to be computationally equivalent.  In this thesis, we choose multi-tape Turing\nmachines with arbitrary finite alphabets.  Our plan is that each tape should contain a value.  We choose a finite model of tapes.  This means that\neach tape has only finitely (but arbitrarily) many symbols.\n\n\n\\section{Contributions}\n\\label{sec:contributions}\n\nWe formalise a variant of deterministic multi-tape Turing machines in the interactive theorem prover Coq.  We build a framework for programming and\nformally verifying correctness and time complexity of Turing machines.  Our framework extends the framework by Asperti and\nRicciotti~\\cite{asperti2015} in the interactive theorem prover Matita~\\cite{asperti2011matita}.  Compared to their framework, we eliminate the need to\nreason about concrete machine states and introduce more general control-flow operators.  We increase the level of programming abstraction and make it\npossible that Turing machines can directly manipulate values of arbitrary encodable types.  We show that our framework is strong enough to implement\nand verify a Turing machine that simulates a two-stack machine for a variant of the $\\lambda$-calculus.  We formally prove that the halting problem of\nthis abstract machine reduces to the halting problem of multi-tape Turing machines.  Thereby, this work is the last step to formally prove that\nmulti-tape Turing machines can simulate the $\\lambda$-calculus.\n\n\\section{Related Work}\n\\label{sec:relatedwork}\n\nAsperti and Ricciotti~\\cite{asperti2012} formalise single-tape Turing machines over arbitrary finite alphabets in the interactive theorem prover\nMatita.  Matita uses the same constructive type theoretic foundation as Coq.  In~\\cite{asperti2015}, they formalise multi-tape Turing machines in\nMatita.  They introduce the notion of \\textit{realisation} for specifying the semantics of concrete Turing machines.  They define and verify a\nuniversal Turing machine and also formalise the reduction from multi-tape Turing machines to single-tape Turing machines.  Furthermore, they propose\nthe formalisation of Turing machines as a benchmark for comparing proof assistants.\n\nXu, Zhang, and Urban~\\cite{xu2013} formalise single-tape Turing machines over a binary alphabet in Isabelle/HOL.  They follow the textbook of Boolos\net~al.~\\cite{boolos2007computability} and use Hoare-logic to specify the semantics of concrete Turing machines.  They implement formally verified\ntranslation functions from \\textit{abacus programs} and \\textit{partial recursive functions} to Turing machines and prove the undecidability of the\nhalting problem of Turing machines.\n\nCiaffaglione et~al.~\\cite{ciaffaglione2016} define tapes of Turing machines as infinite streams.  They verify Turing machines using induction and\nco-induction and also show the undecidability of the halting problem in Coq.\n\nForster, Heiter, and Smolka~\\cite{forster2018verification} formally reduce the halting problem of single-tape Turing machines to the \\textit{Post\n  correspondence problem} (PCP) in Coq.  They use the same definition of Turing machines as we use, but restricted to one tape.  This definition of\nsingle-tape Turing machines was originally presented in~\\cite{asperti2012}.\n\nThere are other mechanisations of abstract machine models.  For example, Forster and Smolka~\\cite{forster2017weak} formalise the theory of computation\nin Coq, based on the language~$L$, which is also known as the (weak) call-by-value $\\lambda$-calculus.  Norrish~\\cite{norrish2011mechanised}\nformalises computability theory in HOL4.  He considers a variant of the $\\lambda$-calculus and recursive functions, and show that both models of\ncomputation are computationally equivalent.  Kunze et~al.~\\cite{KunzeEtAl:2018:Formal} formalise reductions from the programming language $L$ to\nseveral stack-machines.  The stack-machine for that we build a simulator is a variant of a machine of this paper.\n\n\n\n\\section{Outline}\n\\label{sec:outline}\n\nIn Chapter~\\ref{chap:definitions}, we define the notion of multi-tape Turing machines.  We also introduce means to specify the semantics of concrete\nmachines.  In Chapter~\\ref{chap:basic}, we define primitive machines, on which all our machines are based.  In Chapter~\\ref{chap:combining}, we define\ncontrol-flow operators.  In Chapter~\\ref{chap:lifting}, we show how to combine machines with different alphabets and numbers of tapes.  We build\nsimple machines in Chapter~\\ref{chap:compound}.  In Chapter~\\ref{chap:programming}, we introduce abstractions that enable the programmer to directly\nmanipulate values, and we show complex case-studies.  In Chapter~\\ref{chap:heap}, we develop our final case-study where we implement and verify a\nTuring machine that simulates a two-stack machine for $L$ and show that the halting problem of this machine reduces to the halting problem of\nmulti-tape Turing machines.  We conclude and discuss possible future work in Chapter~\\ref{chap:conclusion}.  In the appendix, we present pearls of the\nCoq development of this thesis.\n\nThroughout the thesis, we use mathematical notation, the reader is not required to be expert in type theory.  In the PDF version of this thesis, all\ndefinitions and lemmas are hyperlinked to the documented online source code of the Coq implementation.  The source code is tested to compile with Coq\nversions 8.7 and 8.8.  The home page of this thesis contains the PDF version, the source code, and online documentation:\n\\begin{center}\n  \\url\\homepage\n\\end{center}\n\n%%% Local Variables:\n%%% TeX-master: \"thesis\"\n%%% End:\n", "meta": {"hexsha": "aa4e8197d0dc3f69affcb19028f8743498ad3a0b", "size": 8283, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/thesis/Introduction.tex", "max_stars_repo_name": "mwuttke97/CoqTM", "max_stars_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-08-30T14:58:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-27T15:44:28.000Z", "max_issues_repo_path": "tex/thesis/Introduction.tex", "max_issues_repo_name": "mwuttke97/CoqTM", "max_issues_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-10T09:16:49.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-10T09:16:49.000Z", "max_forks_repo_path": "tex/thesis/Introduction.tex", "max_forks_repo_name": "mwuttke97/CoqTM", "max_forks_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-04-09T19:01:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T15:39:53.000Z", "avg_line_length": 87.1894736842, "max_line_length": 150, "alphanum_fraction": 0.8039357721, "num_tokens": 1934, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4076453434323969}}
{"text": "\\documentclass{report}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{listings}\n\\begin{document}\n\\section{GDA}\n\\subsection{Abstract}\nIn this chapter, we will learn an algorithm of linear classification - soft output - probability generation model: GDA (Gaussian Discriminant Analysis).\n\\subsection{Idea}\nIn the last chapter, the logistic regression algorithm we learned belongs to probability discriminant model, so the difference between the discriminant model and the generation model is:\n\\begin{itemize}\n\t\\item the discriminant model is used to model the probability $p(y|x)$ directly to obtain its truly probability value.\n\t\\item the generation model is used to model the joint distribution $(x,y)$ via converting $p(y|x)$ to $p(x|y)p(y)$ according to bayes theorem: $p(y|x)=\\frac{p(x|y)p(y)}{p(x)}$. Since $p(x)$ has nothing to do with $y$, it can be omitted. So, finally we get:$$\np(y|x)\\propto p(x|y)p(y)=p(x;y)\n$$\n\\end{itemize}\nwhen we are to predict any samples, we just need to compare $p(y=0|x)$ and $p(y=1|x)$.\n\\subsection{Algorithm}\nFirstly, let's make some assumption about the model:\n$$\ny\\in \\{0,1\\}\\quad y\\sim Bernuolli(\\phi)\\quad p(y)=\\phi^y(1-\\phi)^{1-y}\\\\\\left \\{\\begin{aligned}x|y=1 \\quad \\sim \\quad N(\\mu_1,\\Sigma)\\\\x|y=0 \\quad \\sim \\quad N(\\mu_2,\\Sigma)\\end{aligned}\\right.\n$$\n$$\n\\Longrightarrow p(x|y)=N(\\mu_1,\\Sigma)^yN(\\mu_2,\\Sigma)^{1-y}\n$$\nso all the parameters $\\theta$ of the model are:\n$$\n\\theta=(\\phi, \\mu_1, \\mu_2, \\Sigma)\n$$\nThen given the loss function of the model:\n$$\n\\begin{aligned}\nJ(\\theta)=log(p(Y|X))&=log(\\prod_{i=1}^n p(y_i|x_i))\\\\\n&=\\sum_{i=1}^n log(p(y_i|x_i))\\\\\n\\end{aligned}\n$$\nso:\n$$\n\\begin{aligned}\n\\hat{\\theta}=argmax(J(\\theta))&=argmax(\\sum_{i=1}^nlog(\\frac{p(x_i|y_i)p(y_i)}{p(x_i)}))\\\\\n&=argmax(\\sum_{i=1}^n log(p(x_i|y_i)p(y_i)))\\\\\n&=argmax(\\sum_{i=1}^n y_i\\ log(N(\\mu_1,\\Sigma))+(1-y_i)\\ log(N(\\mu_2,\\Sigma))+log(\\phi^{y_i} (1-\\phi)^{1-y_i}))\n\\end{aligned}\n$$\n\\subsubsection{Solve $\\phi$}\ndifferentiate $\\phi$:\n$$\n\\sum_{i=1}^{N} \\frac{y_{i}}{\\phi}+\\frac{y_{i}-1}{1-\\phi}=0\n\\Longrightarrow \\phi=\\frac{\\sum_{i=1}^{N} y_{i}}{N}=\\frac{N_{1}}{N}\n$$\nIn the formula, $N,N_1,N_2$ denote the number of all samples, positive samples, negative samples.\n\\subsubsection{Solve $\\mu$}\nmake some derivations based on $J(\\theta)$:\n$$\n\\begin{aligned} \\hat{\\mu_{1}} \n&=\\underset{\\mu_{1}}{argmax} \\sum_{i=1}^{N} y_{i} \\log N\\left(\\mu_{1}, \\Sigma\\right) \\\\\n&=\\underset{\\mu_1}{argmax} \\sum_{i=1}^{N} y_i \\log (\\frac{1}{(2\\pi)^{\\frac{p}{2}}|\\Sigma|^{\\frac{1}{2}}}exp(-\\frac{1}{2}(x_i-\\mu_1)^T(\\Sigma)^{-1}(x_i-\\mu_1)))\\\\\n&=\\underset{\\mu_{1}}{argmin} \\sum_{i=1}^{N} y_{i}\\left(x_{i}-\\mu_{1}\\right)^{T} \\Sigma^{-1}\\left(x_{i}-\\mu_{1}\\right)\n\\end{aligned}\n$$\nIn the above derivations, we quote the probability density function of multivariate Gaussian distribution:\n$$\np(x)=\\frac{1}{(2\\pi)^{\\frac{p}{2}}|\\Sigma|^{\\frac{1}{2}}}exp(-\\frac{1}{2}(x_i-\\mu_1)^T(\\Sigma)^{-1}(x_i-\\mu_1))\n$$\nIn the function, $p$ denote the number of random variables. Readers can multiply the probability density function of univariate Gaussian distribution, and derive the multivariate formula with the knowledge of linear algebra.\\\\\nthen differentiate the formula:\n$$\n\\frac{\\partial \\Delta}{\\partial \\mu_1}=\\sum_{i=1}^N -2y_i (\\Sigma)^{-1}(x_i-\\mu_1)=0\\\\\n\\Longrightarrow \\mu_{1}=\\frac{\\sum_{i=1}^{N} y_{i} x_{i}}{\\sum_{i=1}^{N} y_{i}}=\\frac{\\sum_{i=1}^{N} y_{i} x_{i}}{N_{1}}\n$$\nSince the positive samples and the negative samples are symmetrical, therefore:\n$$\n\\mu_{2}=\\frac{\\sum_{i=1}^{N}\\left(1-y_{i}\\right) x_{i}}{N_{2}}\n$$\n\\subsubsection{Solve $\\Sigma$}\nobserve the first two terms of the formula:\n$$\n\\hat{\\theta}=argmax(\\sum_{i=1}^n y_i\\ log(N(\\mu_1,\\Sigma))+(1-y_i)\\ log(N(\\mu_2,\\Sigma))+log(\\phi^{y_i} (1-\\phi)^{1-y_i}))\n$$\nWe note that when $y=0$, the first term equals to $0$; when $y=1$, the second term equals to $0$.\\\\\nthus the formula can be updated to:\n$$\n\\begin{aligned}\n\\hat{\\theta}\n&=argmax(\\sum_{(x_i,y_i)\\in C_1} \\ log(N(\\mu_1,\\Sigma))+\\sum_{(x_i,y_i)\\in C_2}\\ log(N(\\mu_2,\\Sigma)))\\\\\n&=argmax(\\sum_{(x_i,y_i)\\in C_1} -\\frac{1}{2}\\log|\\Sigma|-\\frac{1}{2}(x_i-\\mu_1)^T(\\Sigma)^{-1}(x_i-\\mu_1)\\ +\\\\\n&\\sum_{(x_i,y_i)\\in C_2} -\\frac{1}{2}|\\Sigma|-\\frac{1}{2}(x_i-\\mu_2)^T(\\Sigma)^{-1}(x_i-\\mu_2))\n\\end{aligned}\n$$\nNote the shape of $(x_i-\\mu)^T(\\Sigma)^{-1}(x_i-\\mu)$ : $(1,p)* (p,p) * (p,1)=(1,1)$, therefore, the trace(tr) operation can be applied to it, and it can be regarded as a matrix. Within the trace, the order of matrices can be exchanged at will.\n$$\n\\begin{aligned}\n\\hat{\\theta}\n&=argmax(-\\frac{N}{2}\\log|\\Sigma|-\\frac{1}{2}tr(\\sum_{(x_i,y_i)\\in C_1}(x_i-\\mu_1)^T(\\Sigma)^{-1}(x_i-\\mu_1))\\\\\n&-\\frac{1}{2}tr(\\sum_{(x_i,y_i)\\in C_2}(x_i-\\mu_2)^T(\\Sigma)^{-1}(x_i-\\mu_2)))\\\\\n&=argmax(-\\frac{N}{2}\\log|\\Sigma|-\\frac{1}{2}tr(\\sum_{(x_i,y_i)\\in C_1}(x_i-\\mu_1)^T(x_i-\\mu_1)(\\Sigma)^{-1})\\\\\n&-\\frac{1}{2}tr(\\sum_{(x_i,y_i)\\in C_2}(x_i-\\mu_2)^T(x_i-\\mu_2)(\\Sigma)^{-1}))\\\\\n&=argmax(-\\frac{N}{2}\\log|\\Sigma|-\\frac{1}{2}tr(N_1 S_1(\\Sigma)^{-1})\n-\\frac{1}{2}tr(N_2 S_2(\\Sigma)^{-1}))\\\\\n\\end{aligned}\n$$\nIn the formula, $S$ denote the co-variance matrix.\\\\\ndifferentiate the formula:\n$$\n\\frac{\\partial \\Delta}{\\partial \\Sigma}=-\\frac{1}{2}(N \\frac{1}{|\\Sigma|}|\\Sigma|(\\Sigma)^{-1}-N_1S_1(\\Sigma)^{-2}-N_2S_2(\\Sigma)^{-2})=0\n$$\nthen we obtain the $\\hat{\\Sigma}$: \n$$\nN \\Sigma^{-1}-N_{1} S_{1}^{T} \\Sigma^{-2}-N_{2} S_{2}^{T} \\Sigma^{-2}=0\\\\\n\\Longrightarrow \\hat{\\Sigma}=\\frac{N_{1} S_{1}+N_{2} S_{2}}{N}\n$$\nFinally, when we are to predict any samples, we just need to compare $p(x|y=0)p(y=0)$ and $p(x|y=1)p(y=1)$.\n\\subsection{Implement}\n\\begin{lstlisting}[language={python}]\nimport numpy as np\nimport os\nos.chdir(\"../\")\nfrom models.linear_models import GDA\n\nn1 = 1000\nn_test = 100\nx = np.linspace(0, 10, n1 + n_test)\nw1, w2 = 0.3, 0.5\nb1, b2 = 0.1, 0.2\nx1 = x[:n1]\nx_test = x[n1:]\nv1 = x1 * w1 + b1\nv2 = x1 * w2 + b2\ncla_1 = np.c_[x1, v1]\ncla_2 = np.c_[x1, v2]\nl1 = np.ones(shape=(cla_1.shape[0], 1))\nl2 = np.zeros(shape=(cla_2.shape[0], 1))\ntrain_data = np.r_[cla_1, cla_2]\ntrain_label = np.r_[l1, l2]\n\nv_test = x_test * w2 + b2\ndata_test = np.c_[x_test, v_test]\n\nmodel = GDA()\nmodel.fit(train_data, train_label)\nprint(model.get_params())\nprint(\"accuary:\", model.evaluate(data_test, 0))\n\\end{lstlisting}\n\\end{document}", "meta": {"hexsha": "7f85845f4ff7f82d1243e95d99b0ec0c928e05db", "size": 6250, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "EN-TeX_files/LinearClassification/09_linear_classification_gda.tex", "max_stars_repo_name": "btobab/Machine-Learning-notes", "max_stars_repo_head_hexsha": "bc064bd2fe3817444bb8850340ac1177f5fd71c4", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-08-28T18:47:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T07:36:27.000Z", "max_issues_repo_path": "EN-TeX_files/LinearClassification/09_linear_classification_gda.tex", "max_issues_repo_name": "btobab/Machine-Learning-notes", "max_issues_repo_head_hexsha": "bc064bd2fe3817444bb8850340ac1177f5fd71c4", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EN-TeX_files/LinearClassification/09_linear_classification_gda.tex", "max_forks_repo_name": "btobab/Machine-Learning-notes", "max_forks_repo_head_hexsha": "bc064bd2fe3817444bb8850340ac1177f5fd71c4", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-28T18:47:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-28T18:47:22.000Z", "avg_line_length": 43.4027777778, "max_line_length": 259, "alphanum_fraction": 0.64672, "num_tokens": 2503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4076453392397897}}
{"text": "\\documentclass[../PHYS306Notes.tex]{subfiles}\n\n\\begin{document}\n\\section{Lecture 27}\n\\subsection{Lecture Notes - Scattering Theory}\n\\subsubsection{Motivation}\nScattering Theory is very useful for probing information on atomic scales, in condensed matter/nuclear/atomic physics. A familiar example is Rutherford scattering:\n\\begin{center}\n    \\includegraphics[scale=0.5]{Lecture-27/l27-img1.png}\n    \\includegraphics[scale=0.5]{Lecture-27/l27-img2.png}\n\\end{center}\nWhere $\\alpha$ particles (Helium nuclei) were scattered off of gold atoms, and large deflections were observed.\n\n\\subsubsection{Fundamental parameters}\nThere are a couple quantities that are of relevance to consider. First, we have the impact parameter $b$, which is the perpendicular distance from the incoming trajectory to the parallel axis through the center of the target. Then, we have the scattering angle $\\theta$, which is the angle between the initial and final velocities. The simplest possible interaction is the hard-sphere interaction:\n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-27/l27-img3.png}\n\\end{center}\nNow, lets consider a beam of area $A$ passing through a target of length $L$ and number density of particles $n$. Assume the target is larger in the cross sectional area than in the beam. What is the total number of target particles in the beam?\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-27/l27-img4.png}\n\\end{center}\n\\begin{s}\nSince $n$ gives the volume number density, we have that $AL$ gives the volume of the beam in the target and hence the total number of target particles is given by $nAL$.\n\\end{s}\nNext, the \\textbf{cross-section} $\\sigma$ is defined as the effective area of target for interacting with the particle. For hard spheres of radius $R$, we have that $\\sigma = \\pi R^2$ (the cross-sectional area of a circle). \n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-27/l27-img5.png}\n\\end{center}\nNow, given this cross section $\\sigma$ of a single target particle, what is the probability that any one projectile makes a hit (assume the same scenario above with the beam of area $A$, the target of length $L$?)\n\\begin{s}\nBy dimensional analysis, since probability is dimensionless, since $n$ has units of inverse volume, then $L$ has units of length and $\\sigma$ has units of area and hence this works out. This makes sense as the probability should scale with the cross-sectional area of a target particle, the length of the target, and the number density of the target. A way to see that the area $A$ of the beam drops out to see is that:\n\\[P(\\text{hit}) = \\frac{\\text{Area of all targets}}{A} = \\frac{n\\sigma A L}{A} = n\\sigma L\\]\n\\end{s}\nGiven the beam has an incident rate $R_{inc}$ of incoming particles per unit time, what is the scattered rate (number of scattered particles per unit time?)\n\\begin{s}\nThe rate would just be $R_{inc}\\sigma n L$, just multiply the scattering probability by the incoming rate.\n\\end{s}\n\n\\subsubsection{Example: Scattering Neutrons on Aluminum Foil}\nTake $N_{\\text{inc}} = 10000$. the alumnimum foil has thickness of $0.1\\text{mm}$. For neutrons, we have that $\\sigma = 1.5 \\cdot 10^{-28}\\text{m}^2$. Since this is such a common unit in nuclear physics, this is often denoted with a new unit, the \\textit{barn} ($1 \\text{barn} = 1\\times 10^{-28}\\text{m}^2$; i.e. $\\sigma = 1.5\\text{barns}$. For alumnimum, we have mass density $\\rho_{Al} = 2.7\\times 10^3 \\text{kg/m}^3$ and we know that $m_{Al} = 27u$. Hence, the scattered number of particles is given by:\n\\[N_{\\text{scatter}} = N_{\\text{inc}}\\frac{\\rho_{\\text{Al}}}{m_{Al}}L\\sigma = 9\\]\n\n\n\\subsubsection{Example: Scattering of Two Hard Spheres}\nIn this case, we have effective scattering area of $\\pi(R_1 + R_2)^2$.\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-27/l27-img6.png}\n\\end{center}\n\n\\subsubsection{Example: Mean free path of air molecule}\nAir molecules can be approximated as hard spheres with $R = 0.15\\text{nm}$. Define the quantity \\textbf{mean free path} $\\lambda$ as the average distance between two collisions. For sigma, we take (from the formula above):\n\\[\\sigma = \\pi(2R)^2 = 4\\pi R^2\\]\nWe have number density:\n\\[n = \\frac{N}{V}\\]\nThe probability of a collision when travelling a distance $dx$ is given by:\n\\[P(\\text{coll in dx}) = n\\sigma dx\\]\nHence the probability of having a first collision in $x$ and $x + dx$ as:\n\\[P(\\text{first coll between in x and x + dx}) = P(\\text{no coll in x})\\cdot n \\sigma dx\\]\nWe can write this in another way as:\n\\[P(\\text{first coll between in x and x + dx}) = P(\\text{no coll in x}) - P(\\text{no coll in x + dx})\\]\nTurning this small $dx$ into a differential, we have:\n\\[P(\\text{first coll between in x and x + dx}) = -\\dod{}{x}P(\\text{no coll in x})\\]\nWe call $P(\\text{no coll in x})$ as $P(x)$ for notations. Setting the two expressions equal to each other, we have:\n\\[\\dod{}{x}P(x) = -\\frac{N\\sigma}{V}P(x)\\]\nThis has solution:\n\\[P(x) = \\exp(-\\frac{N\\sigma}{V}x)\\]\nThen the mean free path can be calculated as the average value of x given this probaility distribution:\n\\[\\lambda = \\avg{x} = \\int_{0}^{\\infty}xP(x)dx = \\int_0^\\infty xn\\sigma \\exp(-\\frac{N\\sigma}{V}x)\\]\nNote that the $n\\sigma$ is there as a normalization factor for the distribution. Taking this integral, we have:\n\\[\\lambda = \\frac{1}{n\\sigma}\\]\nThis makes sense intuitively; the larger the cross section and the larger the number density, the smaller the mean free path between collisions. Dimensionally, this also has units of length, which is good! At STP, we can calculate what this would be numerically:\n\\[\\lambda = \\frac{V_a}{N_a(4\\pi R^2)} \\approx 130\\text{nm}\\]\n\n\\subsubsection{Solid Angle}\n\\begin{center}\n    \\includegraphics[scale=0.5]{Lecture-27/l27-img7.png}\n\\end{center}\nWe are familiar with the normal angle, $\\Delta \\theta = \\frac{s}{r}$, the ratio of the arc length to the radius. Generalizing this to 3D, we have the solid angle, $\\Delta \\Omega = \\frac{A}{r^2}$ where $A$ is the \"arc area\" and $r$ the radius. For a cone with polar angles $\\theta, \\theta + d\\theta$, $\\phi, \\phi + d\\phi$. The expression is therefore given by:\n\\[d\\Omega = \\sin\\theta d\\theta d\\phi\\]\nWhat is the integral of the solid angle increment $d\\Omega$ over all possible solid angles (over the surface of a sphere?)\n\\begin{s}\n$\\int d\\Omega = 4\\pi$ (surface area of unit sphere). We could actually do the integral, or we could just recognize that the surface area of a sphere is given as $4\\pi r^2$ and divide this by $r^2$. \n\\end{s}\n\n\\subsubsection{Differential Cross Section}\nTypical scenario is we have that a detector covers some portion of a sphere around our target.\n\\begin{center}\n    \\includegraphics[scale=0.8]{Lecture-27/l27-img8.png}\n\\end{center}\nWe must have that:\n\\[N_{\\text{scatter}}(\\text{into d$\\Omega$}) = N_{inc}n_{target}d\\sigma(\\text{into d$\\Omega$}) = N_{inc}n_{target}\\left(\\dod{\\sigma}{\\Omega}(\\theta, \\phi)\\right)d\\Omega\\]\nThe term $\\od{\\sigma}{\\Omega}(\\theta, \\phi)$ is the differential cross section. This can be measured in experiment, or predicted in theory. We can also obtain the total cross section, which is the integral over all differnetial cross sections.\n\\[\\sigma_{tot} = \\int \\dod{\\sigma}{\\Omega}(\\theta, \\phi) d\\Omega = \\int_0^\\pi \\sin\\theta d\\theta \\int\n_0^{2\\pi}d\\phi\\dod{\\sigma}{\\Omega}\\]\nFor a beam with area $A$ and total number of particles $N$, what is the total number of particles $dN$ that passes through the segment between $b$ and $b + db$ and $\\phi$ and $\\phi + d\\phi$?\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-27/l27-img9.png}\n\\end{center}\n\\begin{s}\nWe know that the area of the segment is given by $b dbd\\phi$, and then dividing this by the total area $A$ we get the fraction of particles that would hit that area. Hence, $dN = \\frac{N}{A}bdbd\\phi$.\n\\end{s}\nNote that for the case with axial symmetry, we have:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-27/l27-img10.png}\n\\end{center}\nBut we will continue this discussion next day.\n\\end{document}", "meta": {"hexsha": "21245d76e557071c6e3eba47e8c05224522fa237", "size": 7969, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-27/Lecture-Notes-27.tex", "max_stars_repo_name": "RioWeil/PHYS306-notes", "max_stars_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture-27/Lecture-Notes-27.tex", "max_issues_repo_name": "RioWeil/PHYS306-notes", "max_issues_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture-27/Lecture-Notes-27.tex", "max_forks_repo_name": "RioWeil/PHYS306-notes", "max_forks_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.787037037, "max_line_length": 506, "alphanum_fraction": 0.7259380098, "num_tokens": 2341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.40764533006647413}}
{"text": "\\chapter{Viscoelastic Predictions}\n%The ultrasound method \\cite{Foiret2014} enables the simultaneous measurement of cortical thickness and tissue elastic properties where previous techniques such as DXA (the \\textit{de facto} method) could archieve.\nAs explained before, factors of risk fracture such as thickness, porosity and particular quality elements of the extracellular matrix, define the bone quality assessed by DXA techniques and BMD values. The QUS method proposed by \\textit{Minonzio and Foiret et al.} \\cite{Foiret2014}, \\cite{Minonzio2018} of axial transmission technique simulated in the chapter before, is based on recording from the guided-wave propagation over the media, where damping factors naturally affect the signal. This relates to a viscoelastic behavior of the cortical bone arising mainly from the presence of collagen fibers, specifically treated with Resonant Ultrasound Spectroscopy (RUS) techniques. Thus, it becomes natural to study the correspondence between such damping elements and their preponderance on the resulting homogenized coefficients by the two-scale homogenization theory.\n\nDescribing the damping effects on cortical bone is not new, \\textit{Bernard} \\textit{et al. }\\cite{Bernard2015} studied a viscoelastic-type behavior on a frequency domain, in which he modelled the elastic tensor $C^*_{ij}$ with damping effect described by the formulas:\n\\begin{equation*}\nC^*_{ij} = C_{ij} + i C_{ij}^{'} = C_{ij} (1+ iQ_{ij}^{-1}) \\quad i,j = 1,\\dots, 6\n\\end{equation*}\nwhere the $Q^{-1}_{ij}$ are defined as ratios of the imaginary part ($C_{ij}'$) to the real part ($C_{ij}$), denoting the so-called quality factors.\n\nIn this section, I shall reformulate such quality factors following the two-scale homogenization formalism, recovering the homogenized coefficients in the elastic case at different porosity levels and particularly obtaining prediction for the quality factors at some interval. Using up-to-date references, such coefficients are yet to be validated since there isn't enough experimental literature to confirm nor further validate the predictions.\n\n\\section{Formalization of Q-factors}\nThe quality factors $Q_{ij}$ proposed by \\textit{Bernard} in experimental fashion, provide an interesting formalization of the ratio between the real and imaginary constitutive coefficients of a full viscoelastic mechanical description of the bone, moreover it gives us a comparison using the existent literature and experimental results.\n\nIn the following, it is described the so-called Q-factors by means of the two-scale homogenization theory, derived from a \\textit{Kelvin-Voigt} viscoelastic formulation of bone in frequency domain. More specifically, the mechanical behavior of bone is assumed as a multiphase viscoelastic material composed of two-phases, defined by a square cell unit on $\\mathbf{R}^2$ with circular inclusion in the form $\\mathbf{Y} = \\mathbf{Y}_{m} \\cup \\mathbf{Y}_{f}$ being each the matrix and fluid parts respectively.\nFor the bone matrix, we associate an elastic behavior defined by the elastic coefficients:\n\\begin{equation*}\n    C_{ijkl}(\\mathbf{y}) = C_{ijkl}^m \\mathbb{I}_{\\mathbf{Y}_m}(\\mathbf{y}) + C_{ijkl}^f \\mathbb{I}_{\\mathbf{Y}_f}(\\mathbf{y})\n\\end{equation*}\nwhile the porosity is modeled with a viscous contribution, associated to coefficients in the form:\n\\begin{equation*}\n    D_{ijkl}(\\mathbf{y}) =  D_{ijkl}^m \\mathbb{I}_{\\mathbf{Y}_m}(\\mathbf{y}) + D_{ijkl}^f \\mathbb{I}_{\\mathbf{Y}_f}(\\mathbf{y}).\n\\end{equation*}\nMoreover, the relations between both behaviors are expressed with attenuation specified by parameters $\\alpha^{(m)}, \\alpha^{(f)} >0$ associated to the bone matrix and mesostructure respectively. Explicitly, it is assumed:\n\\begin{equation*}\n    D_{ijkl}^m(\\mathbf{y}) = \\alpha^{m} C_{ijkl}^m(\\mathbf{y}) , \\quad D_{ijkl}^f (\\mathbf{y}) = \\alpha^{f} C_{ijkl}^f(\\mathbf{y})\n\\end{equation*}\n\n\n\\begin{rem}\nBy assuming this kind of relation, the objective is to obtain a viscoelastic model in which the viscous part is modelled by a linear attenuation of the elastic one, so that the overall behavior is of transverse isotropic type defined by pair of parameters $(\\alpha^m, \\alpha^f)$ that mimic closely the experimental behavior of cortical bone.\n\\end{rem}\n\n\\subsection{Workflow Description}\nGiven the requirements of a viscous-like behavior, in time domain is considered a model of \\textit{Kelvin-Voigt} type with mixed boundary conditions, described in the form:\n\\begin{equation*}\n    \\left \\{\n    \\begin{array}{cc}\n        \\rho^{\\epsilon}\\partial_{tt}u^{\\epsilon} - \\nabla \\cdot \\sigma(u^{\\epsilon}, \\partial_t u^{\\epsilon}) = \\mathbf{0} & \\text{ in } (0,T) \\times \\Omega\\\\\n        \\sigma^{\\epsilon}(u^{\\epsilon},\\partial_t u^{\\epsilon})  = \\mathbf{C}:\\mathbf{e}(u^{\\epsilon}) + \\mathbf{D}:\\mathbf{e}(\\partial_t u^{\\epsilon}) & \\text{ in } (0,T) \\times \\Omega\\\\\n        \\sigma^{\\epsilon}(u^{\\epsilon}, \\partial_t u^{\\epsilon})\\cdot n = \\mathbf{F} & \\text{ on } (0,T) \\times \\Gamma_N\\\\ \n        u^{\\epsilon} = \\mathbf{0} & \\text{ on } (0,T) \\times \\Gamma_D\n    \\end{array}\n    \\right .\n    \\label{ViscoElasticModel}\n\\end{equation*}\n\\begin{rem}\nIn the above and the next developments, we assume resting initial conditions, i.e., $\\partial_t u^{\\epsilon} = u^{\\epsilon} = \\mathbf{0}$ at $t = 0$, not written explicitly in the models and further deductions.\n\\end{rem}\nExistence results can be derived similarly to the elastic case proposed before, by applying spectral decomposition on both: the elastic and viscoelastic operators. Similar mathematical description of viscous models are given by \\cite{Abdessamad2009}, \\cite{Boughammoura2013} on homogeneous \\textit{Dirichlet} boundary condition cases.\n\nThe interest is regarded to the frequency-domain, thus applying \\textit{Fourier} transform defined at frequency $\\omega \\in \\mathbb{R}$ by assuming $u^{\\epsilon}(t,\\mathbf{x}) = \\hat{u}^{\\epsilon}(\\mathbf{x}) e^{i\\omega t}$ it follows the redefined problem in Fourier domain:\n\\begin{equation*}\n    \\left \\{\n    \\begin{array}{cc}\n        -\\omega^2 \\rho^{\\epsilon} \\hat{u}^{\\epsilon} - \\nabla \\cdot \\hat{\\sigma}_{\\epsilon,\\omega}(\\hat{u}^{\\epsilon}) = \\mathbf{0} & \\text{ in } \\Omega  \\\\\n        \\hat{\\sigma}^{\\epsilon} (\\hat{u}^{\\epsilon}) = (\\mathbf{C} + i\\omega \\mathbf{D}):\\mathbf{e}(\\hat{u}^{\\epsilon}) & \\text{ in } \\Omega \\\\\n        \\hat{\\sigma}^{\\epsilon} (\\hat{u}^{\\epsilon}) \\cdot n = \\hat{\\mathbf{F}}(\\omega) & \\text{ on } \\Gamma_N \\\\\n        \\hat{u}^{\\epsilon} = \\mathbf{0} & \\text{ on } \\Gamma_D\n    \\end{array}\n    \\right .\n\\end{equation*}\nsuch that at $\\omega = 0$ we have $\\hat{u}^{\\epsilon}=\\mathbf{0}$ at $\\Omega$. In particular, for easiness of exposure, it has been omitted dependencies on the frequency for the multiscale solution $u^{\\epsilon}$.\\\\\nNow, by the homogenization heuristic using the two-scale asymptotic method, it follows the effective (macroscopic) model defined at frequency $\\omega$ in the form:\n\\begin{equation*}\n    \\left \\{\n    \\begin{array}{cc}\n        -\\omega^2 \\rho^{0} \\hat{u}^0 - \\nabla \\cdot \\hat{\\sigma}^0(\\hat{u}^0)  = \\mathbf{0} & \\text{ in } \\Omega \\\\\n        \\hat{\\sigma}^{0} (\\hat{u}^0)  = (\\mathbf{C} + i\\omega \\mathbf{D})^{hom}:\\mathbf{e}(\\hat{u}^0) & \\text{ in } \\Omega \\\\\n        \\hat{\\sigma}^{0} (\\hat{u}^0) \\cdot n = \\hat{\\mathbf{F}}(\\omega) & \\text{ on } \\Gamma_N \\\\\n        \\hat{u}^0 = \\mathbf{0} & \\text{ on } \\Gamma_D\n    \\end{array}\n    \\right .\n\\end{equation*}\n\nIn particular, the homogenized coefficients are defined by the cell problem solutions $\\mathbf{N}^{rs} \\in \\mathbf{H}^1_{0}(\\mathbf{Y}, \\mathbb{C})$, described for each $r,s \\in \\{1,2,3\\}$ in the form\n\\begin{equation*}\n    \\left \\{\n    \\begin{array}{cc}\n         \\partial_{y_j} \\big[ \\big( C_{ijkl} + i\\omega D_{ijkl} \\big) \\mathbf{e}_{kl}(\\mathbf{N}^{rs}) \\big] &= - \\partial_{y_j} \\big[ C_{ijkl} + i\\omega D_{ijkl} \\big] \\quad \\forall y \\in \\mathbf{Y} \\\\\n        \\big \\langle \\mathbf{N}^{rs} \\big \\rangle_{\\mathbf{Y}}  = \\mathbf{0} & \n    \\end{array}\n    \\right.\n\\end{equation*}\nSince the cell problems must be valid for each $\\omega \\in \\mathbb{R}$ and for each $\\mathbf{y} \\in \\mathbf{Y}$, a natural procedure would be to decouple the cell PDE problems thus being able the define viscosity-elasticity ratios, i.e. an expression to the so-called Q-factors.\n\nThe decoupling is then defined by considering the separation between real and imaginary parts associated to the cell solutions, i.e., by considering the following decomposition\n\\begin{equation*}\n    \\mathbf{N}^{rs}(\\mathbf{y}) = \\mathbf{N}_R^{rs}(\\mathbf{y}) + i\\mathbf{N}_I^{rs}(\\mathbf{y})\n\\end{equation*}\nbeing now the vectors functions $\\mathbf{N}_R^{rs}, \\mathbf{N}_I^{rs}$ in $\\mathbf{H}^1_{0}(\\mathbf{Y},\\mathbb{R})$ solving the following PDE coupled system for each real and imaginary solution parts in the form:\n\\begin{equation*}\n    \\left \\{\n    \\begin{array}{cc}\n        \\partial_{y_j} \\big[ C_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}_R) -\\omega D_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}_I) \\big] = - \\partial_{y_j} \\big[ C_{ijrs} \\big] & \\forall \\mathbf{y} \\in \\mathbf{Y} \\\\\n        \\partial_{y_j} \\big[ C_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}_I) +\\omega D_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}_R) \\big] = - \\partial_{y_j} \\big[ \\omega D_{ijrs} \\big] & \\forall \\mathbf{y} \\in \\mathbf{Y} \\\\\n        \\big \\langle \\mathbf{N}^{rs}_R \\big \\rangle_{\\mathbf{Y}}= \\mathbf{0} \\quad \\big \\langle \\mathbf{N}^{rs}_I \\big \\rangle_{\\mathbf{Y}} = \\mathbf{0}.  &\n    \\end{array}\n    \\right.\n\\end{equation*}\n\\begin{rem}\nNote that for the above cell problems, the existence and uniqueness of a weak solution is guaranteed since the problem can be rewritten as a fully elliptic operator, being the solution unique by applying a normalization condition of mean equal $\\mathbf{0}$ type.\n\\end{rem}\nWith the solution to the cell problem, we can then define the homogenized coefficients associated to the elastic and viscous part by recalling first:\n\\begin{equation*}\n    \\hat{\\sigma}_{ij}^0 (\\hat{u}^0,\\omega) = R_{ijkl}^{hom} (\\omega) \\mathbf{e}_{kl}(\\hat{u}^0)\n\\end{equation*}\nbeing the homogenized tensor\n\\begin{equation*}\n    R^{hom}_{ijrs}= \\big \\langle  C_{ijrs} + i\\omega D_{ijrs} + \\big( C_{ijkl} + i \\omega D_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}) \\big) \\big \\rangle  \n\\end{equation*}\nso that, using the decomposition of $N^{rs}$ it follows the full homogenized expression, described in (\\ref{ViscoElasticDecom}) decomposed in real and imaginary parts characterizing the elastic and viscous contribution respectively.\n\\begin{equation}\n    \\begin{aligned}\n        R^{hom}_{ijrs} &= \\big \\langle C_{ijrs} + \\big( C_{ijkl}\\mathbf{e}_{kl}( \\mathbf{N}^{rs}_R) -\\omega D_{ijkl}\\mathbf{e}_{kl}(\\mathbf{N}^{rs}_I) \\big) \\big \\rangle \\\\\n        & \\, + i \\big \\langle \\omega D_{ijrs} + \\big( C_{ijkl} \\mathbf{e}_{kl}(\\mathbf{N}^{rs}_I) + \\omega D_{ijkl}\\mathbf{e}_{kl}(\\mathbf{N}^{rs}_R) \\big) \\big \\rangle \\\\\n        & := C^{hom}_{ijrs} + \\mathbf{i} \\omega D^{hom}_{ijrs}\n    \\end{aligned}\n    \\label{ViscoElasticDecom}\n\\end{equation}\n\nIn particular, the definition of $Q_{ij}$ factors can be directly rewritten terms of a homogenized formulation, defined directly on the tensor coefficients described by (\\ref{Qfactor-Def}). In particular, given the deduction done, the definition of such quality-factors becomes dependent on the frequency which derives from the multiscale \\textit{Kelvin-Voigt} mechanical model assumed.\n\\begin{equation}\n    \\label{Qfactor-Def}\n    Q_{ijrs}^{-1}(\\omega) := \\frac{D^{hom}_{ijrs}(\\omega)}{ C^{hom}_{ijrs}(\\omega)}\n\\end{equation}\n\n\n\\subsection{Nonlinear Decomposition}\n\nAn aspect that must be taken into account is the nonlinear effect added from the asymptotic assumption on the solution, expressed in the term $\\mathbf{N}^{rs}$ at the homogenized coefficients definition that can be explicitly stated from (\\ref{Qfactor-Def}).\nIt is possible to account for that effect by taking a decomposition on the linear part associated to the mean over the coefficient itself and the nonlinear effect produced from the solutions to the cell problems, i.e., from (\\ref{Qfactor-Def}) the decomposition in their linear and nonlinear effects is obtained as:\n\\begin{equation}\n    \\label{Expansion-Qfactor}\n        Q_{ijrs}^{-1} =  \\frac{D_{hom}^{(0)}}{C_{hom}^{(0)}} + \\frac{1}{C^{(0)}_{hom}\\left( C^{(0)}_{hom} + C^{(1)}_{hom} \\right)} \\big[C^{(0)}_{hom} \\big( D^{(0)}_{hom} + D^{(1)}_{hom}\\big) - D^{(0)}_{hom}\\big( C^{(0)}_{hom} + C^{(1)}_{hom} \\big) \\big]\n\\end{equation}\nwhere the notation for the linear terms in $p \\in [0,1]$ (porosity) in given by:\n\\begin{equation*}\n    C^{(0)}_{hom} = \\langle C_{ijrs} \\rangle_{\\mathbf{Y}} \\quad  D^{(0)}_{hom} = \\langle D_{ijrs} \\rangle_{\\mathbf{Y}}\n\\end{equation*}\nand the nonlinear terms with respect to $p \\in [0,1]$ associated to the solutions $N^{rs}$ is given by:\n\\begin{equation*}\n    \\begin{array}{cc}\n        C^{(1)}_{hom} =& \\langle C_{ijkl}\\mathbf{e}_{kl}(N^{rs}_R) - \\omega D_{ijkl}\\mathbf{e}_{kl}(N^{rs}_I) \\rangle_{\\mathbf{Y}} \\\\\n        D^{(1)}_{hom} =& \\langle \\omega^{-1} C_{ijkl}\\mathbf{e}_{kl}(N^{rs}_I) + D_{ijkl}\\mathbf{e}_{kl}(N^{rs}_R) \\rangle_{\\mathbf{Y}} \n    \\end{array}\n\\end{equation*}\n\n\n\n\n\\section{Predictions}\n\nThe explicit dependency on the frequency $\\omega$, requires us to consider the frequency range in which the experimental setting take place. In this sense, after adjusting regards experimental data range, viscous factors with transverse isotropic behavior of the type are assumed in the form:\n\\begin{equation*}\n    D^m_{ijkl} (\\mathbf{y}) = 5\\times10^{-2} C^{m}_{ijkl}(\\mathbf{y}), \\quad D^f_{ijkl}(\\mathbf{y}) = 1 \\times 10^{-3} C^{f}_{ijkl}(\\mathbf{y})\n\\end{equation*}\n\nUnder such considerations, the figure (\\ref{BernardPredictionHomCoeffs}) contains the prediction for the homogenized elastic coefficients and Q-factors associated to a fixed frequency $\\omega = 0,5 \\, [Mhz]$. It describes the behavior as function of density in the clinical range of interest. The main quality factors describing the axial-related behavior shows predictions comparable to up-to-date literature \\cite{Bernard2015}. Moreover, homogenized elasticity coefficients are recovered with predictions regarding results obtained in fully elastic models \\cite{Parnell2008}, therefore describing a generalization.\nIn particular, shear-like $C_{55}^{hom}, C_{66}^{hom}$ coefficients describe experimentally measured values validating the simulated model.\n\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{images/Qfactors/CellProb_QfactorCircular5E-2_Relations.pdf}\n\t\\caption{Predicted behavior for the viscoelastic model. It is shown on the left figure the predicted quality factors for a \\textit{Kelvin-Voigt} model; the center figure a prediction of homogenized coefficient ratios, and on the right figure some homogenized shear ratios with behavior as in \\cite{Bernard2015}.}\n\t\\label{BernardPredictionHomCoeffs}\n\\end{figure} \n\nNevertheless, figure (\\ref{BernardPredictionHomCoeffs}) cannot be used to account for the nonlinearity effects which might not be preponderant on the definition of the quality factors. In this setting, the decomposition (\\ref{Expansion-Qfactor}) can be used to describe characteristic behavior regarding the linear and nonlinear contribution and therefore, answering the question of dependency on preponderant linear behavior.  In this sense, figure (\\ref{QfactorDecomposition}) shows a clear\ndirection-dependent strong non-linear preponderance on the overall behavior for the three cases, implying full cell-problem interactions to describe each factors. In particular, becoming the cell-problems the most relevant effect that describes the mechanical behavior.\n\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{images/Qfactors/PlotsVisc_Circular2DPart50EPS5-2_Ome5.pdf}\n\t\\caption{The effects from cell-problem solutions is shown for some representative quality factors accounting the linear and non-linear contributions over the range of biomedical interest.}\n\t\\label{QfactorDecomposition}\n\\end{figure} \n\nFinally, a relevant dependency that must be taken into account from the Q-factors definition (\\ref{Qfactor-Def}) is related to the frequency dependency. From the experimental setting proposed by \\cite{Bernard2015}, such dependency is not taken into account on the viscoelastic operator nor in the quality-factor. \nIn this direction, figure (\\ref{BernardPrediction-Freq}) describes the obtained factors for different frequency values. It shows a clear independent behavior at each frequency being used, therefore expressing the assumption proposed by \\textit{Bernard et. al. (2015)} \\cite{Bernard2015} in which given the frequency range under consideration, the overall behavior of the Q-factors remains the same, i.e., equal ratio of elastic and viscous part at each frequency\n\\begin{figure}[!h]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{images/Qfactors/QfactorsFreqsEPS5-2.pdf}\n\t\\caption{Predicted behavior for the viscoelastic model. It is shown in the left figure the predicted quality factors for a \\textit{Kelvin-Voigt} model; the center figure a prediction of homogenized coefficient ratios, and in the right figure some homogenized shear ratios behaves as in \\cite{Bernard2015} }\n\t\\label{BernardPrediction-Freq}\n\\end{figure}.\n\n\n\n\n\n\n", "meta": {"hexsha": "d6d1a19f3865e73d5faa0ac40b00e3fce00a145f", "size": 17274, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Qfactor.tex", "max_stars_repo_name": "Reidmen/Master-Thesis-2018", "max_stars_repo_head_hexsha": "4cefa410208dfced927616ba8e2b62c4b6557281", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Qfactor.tex", "max_issues_repo_name": "Reidmen/Master-Thesis-2018", "max_issues_repo_head_hexsha": "4cefa410208dfced927616ba8e2b62c4b6557281", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Qfactor.tex", "max_forks_repo_name": "Reidmen/Master-Thesis-2018", "max_forks_repo_head_hexsha": "4cefa410208dfced927616ba8e2b62c4b6557281", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.0412371134, "max_line_length": 870, "alphanum_fraction": 0.723341438, "num_tokens": 5093, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.40763515689753793}}
{"text": "%% ------------------------------------------------------------------------- %%\n\\chapter{Correlation rules and proposed extension}\n\\label{cap:proposed-solution}\n\n\\noindent A state of the art skin detection method has been recently developed by~\\cite{brancati:17}. In this chapter, we review the method and extend it\\footnote{All the implementations can be found at \\url{https://bitbucket.org/rodrigoadfaria/skin-detector/}.} adding more rules to enforce the constraints and seeking for a better accuracy in terms of false positive rate without hurting the performance of the original method.\n\n\n%% ------------------------------------------------------------------------- %%\n\\section{Correlation rules on YCrYCb colormap}\n\\label{sec:correlation_rules_ycrycb}\nThe pixels of human skin have a very particular color. They fall into a restricted range of hues and they are not deeply saturated. This phenomenon is due the appearance of skin: formed by a combination of blood (red) and melanin (brown, yellow), which leads the human skin color to be clustered within a small area in the color space~\\citep{fleck:96}.\n\nAlthough this cluster can be seen in different color spaces, authors often use those where it is possible to split the chrominance from the luminance information. YCbCr is one of these color spaces. \\citet{chai:99}~firstly observed this cluster within this particular color space (see Fig.~\\ref{fig:dataset_sfa_ycbcr}). Based on a given set of training images, they~\\citep{chai:99} built a skin color map using a histogram approach. In this map, the Cr and Cb distributions of skin color fall into the ranges [133, 173] and [77, 127], respectively, regardless the skin color variation in different races (see Fig.~\\ref{fig:dataset_sfa_ycbcr_hist}).\n\n\\begin{figure}[!ht]\n    \\centering\n    \\begin{minipage}{0.485\\textwidth}\n        \\includegraphics[width=\\textwidth]{sfa/sfa_ycbcr}\n    \\end{minipage}\n    ~ % space\n    \\begin{minipage}{0.485\\textwidth}\n        \\includegraphics[width=\\textwidth]{sfa/sfa_ycbcr_skin_only}\n    \\end{minipage}\n    \\caption[3-dimensional view of the YCbCr channels of some image patches of the SFA dataset]{3-dimensional view of the YCbCr channels of some image patches of the SFA dataset. We used the patches with skin samples of size $15 \\times 15$. The blue points are skin samples and the green ones are non-skin. On the right (skin samples only), we can clearly see a narrow and thin cluster. Source: adapted from~\\citet{chai:99}.}\n    \\label{fig:dataset_sfa_ycbcr}\n\\end{figure}\n\n\\begin{figure}[!ht]\n    \\centering\n    \\begin{minipage}{0.485\\textwidth}\n        \\includegraphics[width=\\textwidth]{sfa/sfa_cb_histogram}\n    \\end{minipage}\n    ~ % space\n    \\begin{minipage}{0.485\\textwidth}\n        \\includegraphics[width=\\textwidth]{sfa/sfa_cr_histogram}\n    \\end{minipage}\n    \\caption[Histogram of Cb and Cr channels of some image patches of the SFA dataset]{Histogram of Cb and Cr channels of some image patches of the SFA dataset. We used the patches skin samples of size $15 \\times 15$. Clearly, the samples (pixels) fall into the intervals observed by~\\citet{chai:99}. Source: adapted from~\\citet{chai:99}.}\n    \\label{fig:dataset_sfa_ycbcr_hist}\n\\end{figure}\n\nTherefore, a very simple and practical approach to detect human skin pixels would be to create a set of rules, based in those ranges, that identify the presence of chrominance (Cr, Cb) values who fit into the rules. In fact, this was the approach used by~\\citet{chai:99}.\n\nAnother important finding regarding the skin color clusters in the YCbCr color space is their behavior when looking for the compositions of YCb and YCr separately. In other words, where rely this distribution into the YCb and YCr subspaces. In Figure~\\ref{fig:obama_trapezoids}, we can see the distribution (clusters) for an image of the Pratheepan dataset. We can clearly see their shapes as taking a trapezoidal form~\\citep{hsu:02}.\n\nIn fact, the skin color pixels distribution in the YCb and YCr subspaces is a pattern. However, this trapezoidal shape and size will change according to many factors. \\citet{brancati:17} observed that change and identified that they are caused mainly due illumination conditions (i.e. the lighting of the scene when the image was acquired influences the size, height, and position of these trapezoidal shape). Moreover, they~\\citep{brancati:17} observed a proportional behavior of the chrominance components (Cr, Cb) that could be fitted into a model for skin pixels detection. We will explain in details how this model has been created in Section~\\ref{sec:original_method}.\n\n\\begin{figure*}[!htb]\n    \\centering\n    \\begin{subfigure}[t]{0.48\\textwidth}\n        \\includegraphics[width=\\textwidth]{pra/ori/obama}\n        \\caption{}\n    \\end{subfigure}\n    \\begin{subfigure}[t]{0.48\\textwidth}\n        \\includegraphics[width=\\textwidth]{pra/gtc/obama}\n        \\caption{}\n    \\end{subfigure}\n    \\begin{subfigure}[t]{0.88\\textwidth}\n        \\includegraphics[width=\\textwidth]{image_trap_plot}\n        \\caption{}\n    \\end{subfigure}\n\n    \\caption[Skin pixels distribution in the YCr and YCb subspaces of a sample image]{Skin pixels distribution in the YCr and YCb subspaces of a sample image. Each image is, respectively, (a) sample image from Pratheepan (b) ground truth (c) skin pixels distribution in YCr (orange) and YCb (blue) subspaces. We can clearly see a trapezoidal shape of the pixels distribution. These trapezoids are inversely positioned reflecting the proportional behavior of the chrominance components (Cr, Cb). Source: adapted from~\\citet{brancati:17}.}\n    \\label{fig:obama_trapezoids}\n\\end{figure*}\n\n%% ------------------------------------------------------------------------- %%\n\\section{Original method}\n\\label{sec:original_method}\nIn order to describe the proposed extensions, we will first present the original method that is based on the definition of image-specific trapezoids, named $T_{YCb}$ and $T_{YCr}$, in the \\textit{YCb} and \\textit{YCr} subspaces, respectively. The trapezoids are essential to verify a relationship between the chrominance components $Cb$ and $Cr$ in these subspaces~\\citep{brancati:17}.\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{trapezoids}\n    \\caption[Graphical representation of the trapezoids as well as their parameters]{Graphical representation of the trapezoids as well as the parameters $Y_{min} = 0$, $Y_{max} = 255$, $Y_{0}$, $Y_{1}$, $Y_{2}$, $Y_{3}$, $Cr_{min}$, $Cr_{max}$, $Cb_{min}$, $Cb_{max}$, $h_{Cr}$, $h_{Cb}$, $H_{Cr}(P_Y)$, $H_{Cb}(P_Y)$. Source: adapted from~\\citep{brancati:17}.}\n    \\label{fig:trapezoids}\n\\end{figure}\n\nTo show the correlations, Brancati et. al. present the YCbCr space as a 2D graph where the $Y$ is presented in the abscissa and the $Cr$ and $Cb$ components is in the ordinate (see Fig.~\\ref{fig:trapezoids}). The base of the trapezoids $T_{YCr}$ and $T_{YCb}$ are given by the coordinates $(Y_{min}, Cr_{min})$ and $(Y_{min}, Cb_{max})$ in the $YCr$ and $YCb$ , respectively~\\citep{brancati:17}. The values $Cr_{min}$ = 133, $Cb_{max}$ = 128 were selected according to~\\citet{chai:99} where a skin color map was designed using a histogram approach based on a given set of training images. Chai and Ngan observed that the Cr and Cb distributions of skin color fall in the ranges [133, 173] and [77, 127], respectively, regardless of the skin color variation in different races (see details in Section~\\ref{sec:correlation_rules_ycrycb}).\n\nThe $Cr_{max}$ parameter is calculated dynamically, taking into account the histogram of the pixels with $Cr$ values in the range $[Cr_{min}, 183]$, looking for the maximum value of $Cr$ associated with at least 0.1\\% \\footnote{In \\citet{brancati:17} this rate is reported to be equal to 10\\%. However, in the distributed source code we found the value 0.1\\%, that we are using in the experiments.} of pixels in the image. The same applies to $Cb_{min}$, taking the histogram with $Cb$ values in the range $[77, Cb_{max}]$. $Y_0$ and $Y_1$ (shorter base of the upper trapezoid) are, respectively, the 5${th}$ and 95$th$ percentile of the luminance values associated with the pixels of the image with $Cr = Cr_{max}$~\\citep{brancati:17}. A similar procedure is used to find the values of the shorter base of the other trapezoid, $Y_2$ and $Y_3$ (see Fig.~\\ref{fig:crmax_computation} for an example).\n\n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.7\\textwidth]{crmax_computation}\n    \\caption[Computation of $Cr_{max}$ based on $Cr$ values histogram of a 724 x 526 image]{Computation of $Cr_{max} = 162$ based on $Cr$ values histogram of a 724 x 526 image. Source: adapted from~\\citep{brancati:17}.}\n    \\label{fig:crmax_computation}\n\\end{figure}\n\nThe correlation rules' parameters between the chrominance components $P_{Cr}$ and $P_{Cb}$ of a pixel $P$ are specified as~\\citep{brancati:17}:\n\\begin{itemize}\n    \\item the minimum difference between the values $P_{Cr}$ and $P_{Cb}$, denoted $I_P$;\n    \\item an estimated value of $P_{Cb}$, namely $P_{Cb_s}$;\n    \\item the maximum distance between the points $(P_Y, P_{Cb})$ and $(P_Y, P_{Cb_s})$, denoted $J_P$.\n\\end{itemize}\n\nTherefore, to determine if $P$ is skin, the following correlation rules, expressed in terms of equations, must hold~\\citep{brancati:17}:\n\\begin{equation}\n    P_{Cr} - P_{Cb} \\geq I_P\n\\label{condition_c0}\n\\end{equation}\n\\begin{equation}\n   |P_{Cb} - P_{Cb_s}| \\leq J_P\n\\label{condition_c1}\n\\end{equation}\n\nThe estimated value $P_{Cb_{s}}$ is given by \\footnote{$dP_{Cb_{s}}$ is the distance between the points $(P_Y, P_{Cb_{s}})$ and $(P_Y, Cb_{max})$ in the $YCb$ subspace, calculated on the basis of $dP_{Cr}$, observing the proportional behavior of the components. $\\alpha$ is the rate between the normalized heights of the trapezoids in relation to the $P_Y$ value~\\citep{brancati:17}.}:\n\\begin{equation}\n    P_{Cb_s} = Cb_{max} - dP_{Cb_s}\n\\end{equation}\nwhere \\footnote{$dP_{Cr}$ is the distance between $(P_Y, P_{Cr})$ and $(P_Y, Cr_{min})$ points in the $YCr$ subspace~\\citep{brancati:17}.}:\n\\begin{align}\n    dP_{Cb_s} &= \\alpha \\cdot dP_{Cr}\n    \\\\\n    dP_{Cr} &= P_{Cr} - Cr_{min}\n\\end{align}\n\nThe coordinates of the other sides of the trapezoids are given by $[P_Y, H_{Cr}(P_Y)]$ and $[P_Y, H_{Cb}(P_Y)]$, such that~\\citep{brancati:17}:\n\\begin{align}\n  H_{Cr}(Y) &=  \\begin{cases}\n                Cr_{min} + h_{Cr}\\big(\\frac{Y - Y_{min}}{Y_0 - Y_{min}}\\big) & Y \\in [Y_{min},\\ Y_0] \\\\\n                Cr_{max} & Y \\in [Y_0,\\ Y_1] \\\\\n                Cr_{min} + h_{Cr}\\big(\\frac{Y - Y_{max}}{Y_1 - Y_{max}}\\big) & Y \\in [Y_1,\\ Y_{max}]\n              \\end{cases}\n\\\\\n  H_{Cb}(Y) &=  \\begin{cases}\n                Cb_{min} + h_{Cb}\\big(\\frac{Y - Y_2}{Y_{min} - Y_2}\\big) & Y \\in [Y_{min},\\ Y_2] \\\\\n                Cb_{min} & Y \\in [Y_2,\\ Y_3] \\\\\n                Cb_{min} + h_{Cb}\\big(\\frac{Y - Y_3}{Y_{max} - Y_3}\\big) & Y \\in [Y_3,\\ Y_{max}]\n              \\end{cases}\n\\end{align}\n\n\\noindent where $h_{Cr} = Cr_{max} - Cr_{min}$ and $h_{Cb} = Cb_{max} - Cb_{min}$, which are the heights of $T_{YCr}$ and $T_{YCb}$, respectively.\n\nThe computation of those points are useful for the calculation of $\\alpha$. We first compute the distances $\\Delta_{Cr}(P_Y)$ and $\\Delta_{Cb}(P_Y)$ between the points $(P_Y, H_{Cr}(P_Y))$, $(P_Y, H_{Cb}(P_Y))$ and the base of the trapezoids~\\citep{brancati:17}:\n\\begin{align}\n    \\Delta_{Cr}(P_Y) &= H_{Cr}(P_Y) - Cr_{min} \\\\\n    \\Delta_{Cb}(P_Y) &= Cb_{max} - H_{Cb}(P_Y)\n\\end{align}\n\nNext, the distances are normalized with respect to the difference in size of the trapezoids \\citep{brancati:17}:\n\\begin{align}\n  \\Delta^{'}_{Cr}(P_Y) &=  \\begin{cases}\n                \\Delta_{Cr}(P_Y) \\cdot \\frac{A_{T_{YCb}}} {A_{T_{YCr}}} &\\quad \\text{if}\\ A_{T_{YCr}} \\geq A_{T_{YCb}} \\\\\n                \\Delta_{Cr}(P_Y) &\\quad \\text{otherwise}\n              \\end{cases}\n\\\\\n  \\Delta^{'}_{Cb}(P_Y) &=  \\begin{cases}\n                \\Delta_{Cb}(P_Y) &\\quad \\text{if}\\ A_{T_{YCr}} \\geq A_{T_{YCb}} \\\\\n                \\Delta_{Cb}(P_Y) \\cdot \\frac{A_{T_{YCr}}} {A_{T_{YCb}}} &\\quad \\text{otherwise}\n              \\end{cases}\n\\end{align}\nwhere $A_{T_{YCr}}$ and $A_{T_{YCb}}$ are the areas of trapezoid ${T_{YCr}}$ and ${T_{YCb}}$, respectively.\n\nThen, the value of $\\alpha$ is given by~\\citep{brancati:17}:\n\\begin{equation}\n    \\alpha = \\frac{\\Delta^{'}_{Cb}(P_Y)} {\\Delta^{'}_{Cr}(P_Y)}\n\\end{equation}\n\nFinally, $I_P$ \\footnote{There is a difference between the source code and the equation that defines $I_P$ in~\\citet{brancati:17}. Basically, part of the equation must be taken its absolute value, which we have fixed here.} and $J_P$ are given by~\\citep{brancati:17}:\n\\begin{equation}\n    I_P = sf \\cdot |(\\Delta^{'}_{Cr}(P_Y) - dP_{Cr}) + (\\Delta^{'}_{Cb}(P_Y) - dP_{Cb_s})|\n    \\label{eq:ip}\n\\end{equation}\n\\begin{equation}\n    J_P = dP_{Cb_s} \\cdot \\frac{dP_{Cb_s} + dP_{Cr}} {\\Delta^{'}_{Cb}(P_Y) + \\Delta^{'}_{Cr}(P_Y)}\n    \\label{eq:jp}\n\\end{equation}\nwhere:\n\\begin{equation}\n    sf = \\frac{min( (Y_1 - Y_0), (Y_3 - Y_2) )} {max( (Y_1 - Y_0), (Y_3 - Y_2) )}\n\\end{equation}\n% Acho que um gráfico mostrando um ponto, ou alguns pontos, no trapézio superior e o respectivo ponto no trapézio inferior seria muito didático. \n\n%% ------------------------------------------------------------------------- %%\n\\section{Complementary method}\n\\label{sec:proposed_method}\nThe hypothesis assumed in the original method is based on rules that an estimated value of the point $P_{Cb}$, namely $P_{Cb_s}$, must hold in order for the correlation to be valid. On the basis of the proportional behavior of the chrominance components, we will rewrite the correlation rules with respect to the $P_{Cr}$ point.\n\nThus, we have to refactor the correlation rules' parameters to put them in terms of the estimated value of $P_{Cr}$, that we denote as $P_{Cr_s}$ \\footnote{$dP_{Cr_s}$ is the distance between the points $(P_Y, P_{Cr_s})$ and $(P_Y, Cr_{min})$ in the $YCr$ subspace, calculated on the basis of $dP_{Cb}$, observing the proportional behavior of the components. $\\alpha$ is the rate between the normalized heights of the trapezoids in relation to the $P_Y$ value.}:\n\\begin{equation}\n    P_{Cr_s} = dP_{Cr_s} + Cr_{min}\n\\end{equation}\nwhere \\footnote{$dP_{Cb}$ is the distance between $(P_Y, P_{Cb})$ and $(P_Y, Cb_{max})$ points in the $YCb$ subspace.}:\n\\begin{equation}\n    dP_{Cr_s} = \\alpha \\cdot dP_{Cb}\n\\end{equation}\n\\begin{equation}\n    dP_{Cb}   = Cb_{max} - P_{Cb}\n\\end{equation}\n\nNext, the constraints given by $I_P$ and $J_P$ in the Eq. \\ref{eq:ip} and \\ref{eq:jp} respectively, can be redefined as:\n\\begin{equation}\n    I^{'}_P = sf \\cdot |(\\Delta^{'}_{Cr}(P_Y) - dP_{Cr_s}) + (\\Delta^{'}_{Cb}(P_Y) - dP_{Cb})|\n\\end{equation}\n\\begin{equation}\n    J^{'}_P = dP_{Cr_s} \\cdot \\frac{dP_{Cb} + dP_{Cr_s}} {\\Delta^{'}_{Cb}(P_Y) + \\Delta^{'}_{Cr}(P_Y)}\n\\end{equation}\n\nTherefore, to determine if the pixel $P$ is skin, we have to modify the correlations rules given by Eq. \\ref{condition_c0} and \\ref{condition_c1}:\n\\begin{equation}\n    P_{Cr} - P_{Cb} \\geq I^{'}_P\n\\label{condition_c00}\n\\end{equation}\n\\begin{equation}\n   |P_{Cr} - P_{Cr_s}| \\leq J^{'}_P\n\\label{condition_c11}\n\\end{equation}\n\nDoing this simple extension, we need now to apply the method to the same sets of images to evaluate, in fact, the proportional behavior of the chrominance components. More than that, we can combine all these constraints, given by the pair equations \\ref{condition_c0} and \\ref{condition_c1}, \\ref{condition_c00} and \\ref{condition_c11}, to reinforce the firstly defined hypothesis.\n\n\n\\begin{figure}[!htp]\n    \\centering\n    \\includegraphics[width=0.25\\textwidth]{pixel_neighborhood}\n    \\caption[Neighbors evaluation with respect to a pixel $P$]{Neighbors evaluation with respect to $P$. If the image is scanned in raster order, $N_8^-(P)$ is the set of points that can be reached before $P$ in an 8-\\textit{neighbors} window. In other words, $N_8^-(P)$ are the blue points which we already have evaluated. Source: proposed by the author.}\n    \\label{fig:pixel_neighborhood}\n\\end{figure}\n\n\n%% ------------------------------------------------------------------------- %%\n\\section{Neighborhood extended method}\n\\label{sec:neighborhood_extended_method}\nBoth methods presented in Sections~\\ref{sec:original_method} and \\ref{sec:proposed_method} can be applied to detect skin pixels, either separated or combined (i.e. the four equations of the correlation rules of each method -- original and complementary -- must hold). However, skin pixels do not usually appear isolated and we could improve the method using some of the already processed neighbors of a pixel $P$, in order to decide if $P$ represents human skin, or not.\n\nTo do that, let $N_8^-(P)$ be the 8-\\textit{neighbors} of $P$ that can be reached before $P$ when scanning the image in raster order~\\citep{rosenfeld:66}. We can see this idea graphically represented by the blue points in Figure~\\ref{fig:pixel_neighborhood}.\n\nThus, we classify $P$ as skin in the following manner: if the constraints given by the pair of equations \\ref{condition_c0} and \\ref{condition_c1}, as well as \\ref{condition_c00} and \\ref{condition_c11} hold, then $P$ is classified as skin. When only one of the conditions is satisfied, then we check the decision in $N_8^-(P)$. If three or more pixels are skin, then $P$ will also be classified as a skin pixel. Figure~\\ref{fig:n8-flowchart} shows a flowchart of the aforementioned procedure described.\n\n\\begin{figure}[ht]\n    \\centering\n\n    % Define block styles\n    \\tikzstyle{decision} = [diamond, draw, fill=blue!20,\n        text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]\n    \\tikzstyle{block} = [rectangle, draw, fill=blue!20,\n        text width=5em, text centered, rounded corners, minimum height=4em]\n    \\tikzstyle{line} = [draw, -latex']\n    \\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,\n        minimum height=2em]\n\n    \\begin{tikzpicture}[node distance = 3cm, auto]\n        % Place nodes\n        \\node [block] (pcrs) {calculate \\ref{condition_c00} and \\ref{condition_c11} rules};\n        \\node [block, left of=pcrs] (pcbs) {calculate \\ref{condition_c0} and \\ref{condition_c1} rules};\n        \\node [decision, below of=pcrs] (bothtrue) {both true?};\n        \\node [block, right of=bothtrue, node distance=4cm, fill=gray!20] (isskin) {$P$ is skin};\n        \\node [decision, below of=bothtrue] (bothfalse) {both false?};\n        \\node [block, right of=bothfalse, node distance=4cm, fill=gray!20] (noskin) {$P$ is non skin};\n        \\node [decision, right of=noskin, node distance=4cm] (n8decision) {skin pixels $\\geq 3$};\n        \\node [block, below of=n8decision, node distance=3cm] (n8) {check decision in $N_8^-(P)$};\n        % Draw edges\n        \\path [line] (pcrs) -- (bothtrue);\n        \\path [line] (bothtrue) -- node {no} (bothfalse);\n        \\path [line] (bothfalse) -- node {yes} (noskin);\n        \\path [line] (bothfalse) |- node [near start] {no} (n8);\n        \\path [line] (bothtrue) -- node {yes}  (isskin);\n        \\path [line] (n8) -- (n8decision);\n        \\path [line] (n8decision) |- node [near start] {yes} (isskin);\n        \\path [line] (n8decision) -- node [near start] {no} (noskin);\n        \\path [line] (pcbs) |- (bothtrue);\n    \\end{tikzpicture}\n\n    \\caption[Flowchart of our proposed neighbors method]{Flowchart of our proposed neighbors method. In \\textbf{both false} decision, the \\textbf{no} path means that one of the rules is true and we are in doubt if $P$ is skin or not -- here is where the neighbors are used to find out the label of $P$. Source: proposed by the author.}\n    \\label{fig:n8-flowchart}\n\\end{figure}\n\n\n%% ------------------------------------------------------------------------- %%\n\\section{Heuristics to fix neighborhood extended method}\n\\label{sec:sup_neighborhood_operations}\nThe neighborhood extended method presented in Section~\\ref{sec:neighborhood_extended_method} will end up with an undesired behavior on the output images that we called \\textit{diagonal effect} (see Fig.~\\ref{fig:diagonal_effect}). In addition, besides being visually undesirable, the \\textit{diagonal effect} phenomenon causes us to have an increase in the false positive rate. This is caused due to the shape of the window being used. Once we look only for the four already visited pixels of the 8-\\textit{neighbors} window, the operation is so based in a non-symmetrical mask. Ideally, we could use another neighborhood strategy and look for all the eight neighbors of the pixel $P$ being evaluated. However, this particular implementation can add extra computational time and affect the performance of the method. \n\nTherefore, we created an adaptation of the neighborhood method shown in Section~\\ref{sec:neighborhood_extended_method}. In this version, we scan the image, with a size of $W \\times H$, in the raster order, and apply the original and the extended complementary correlation rules for every single pixel. We keep both results in a matrix of the same size ($W \\times H$) of the input image. For each coordinate of this output matrix, we will have a two-position vector with the result of the original and complementary rules answer for this pixel. Next, we read each position of this output matrix and we apply an 8-\\textit{neighbors} operations in four different implementations, looking for the majority (five at least) neighbors:\n\n\\begin{enumerate}[label={(\\arabic*)}]\n    \\item we look in the correlation rules answer performing an AND. In other words, if both original and complementary correlation rules are saying this pixel is skin, then we classify it as skin;\n    \\item we look in the correlation rules answer performing an OR. In other words, if one of the correlation rules (original or complementary) is saying this pixel is skin, then we classify it as skin;\n    \\item we look in the neighbors only querying the original ($P_{Cb_s}$) correlation rules;\n    \\item we look in the neighbors only querying the complementary ($P_{Cr_s}$) correlation rules.\n\\end{enumerate}\n\nOf course, this variation will add some additional computational cost once we will scan the image one more time. This implementation can be enhanced, but the idea here is to only explore better the connectivity of the 8-\\textit{neighbors} window and check, on the basis of a symmetric mask window, if the \\textit{diagonal effect} is gone as well as the measures are improved. Some experiments can be seen further in Section~\\ref{sec:sno_experiments}.\n\n\\begin{figure*}[!htb]\n    \\centering\n    \\begin{subfigure}[t]{0.18\\textwidth}\n        \\includegraphics[width=2.6cm]{sfa/ori/img14}\n        \\includegraphics[width=2.6cm]{pra/ori/chenhao0017me9}\n        \\includegraphics[width=2.6cm]{hgr/ori/N_P_hgr1_id04_5}\n        \\includegraphics[width=2.6cm]{cpq/ori/1923132}\n        \\includegraphics[width=2.6cm]{cpq/ori/2226882}\n        \\caption{}\n    \\end{subfigure}\n    \\begin{subfigure}[t]{0.18\\textwidth}\n        \\includegraphics[width=2.6cm]{sfa/gt/img14}\n        \\includegraphics[width=2.6cm]{pra/gt/chenhao0017me9}\n        \\includegraphics[width=2.6cm]{hgr/gt/N_P_hgr1_id04_5}\n        \\includegraphics[width=2.6cm]{cpq/gt/1923132}\n        \\includegraphics[width=2.6cm]{cpq/gt/2226882}\n        \\caption{}\n    \\end{subfigure}\n    \\begin{subfigure}[t]{0.18\\textwidth}\n        \\includegraphics[width=2.6cm]{sfa/cmb/img14}\n        \\includegraphics[width=2.6cm]{pra/cmb/chenhao0017me9}\n        \\includegraphics[width=2.6cm]{hgr/cmb/N_P_hgr1_id04_5}\n        \\includegraphics[width=2.6cm]{cpq/cmb/1923132}\n        \\includegraphics[width=2.6cm]{cpq/cmb/2226882}\n        \\caption{}\n    \\end{subfigure}\n    \\begin{subfigure}[t]{0.18\\textwidth}\n        \\includegraphics[width=2.6cm]{sfa/ngh/dgn/img14}\n        \\includegraphics[width=2.6cm]{pra/ngh/dgn/chenhao0017me9}\n        \\includegraphics[width=2.6cm]{hgr/ngh/dgn/N_P_hgr1_id04_5}\n        \\includegraphics[width=2.6cm]{cpq/ngh/dgn/1923132}\n        \\includegraphics[width=2.6cm]{cpq/ngh/dgn/2226882}\n        \\caption{}\n    \\end{subfigure}\n\n    \\caption[Image samples with the diagonal effect after the neighbors method segmentation]{Image samples with the diagonal effect after the neighbors method segmentation. Each image is from (top-down) SFA, Pratheepan, HGR, and Compaq (latest two) datasets, respectively, where: (a) original image (b) ground truth (c) combined method (f) neighbors method. Independently of the classification accuracy, we can clearly see the diagonal effect present in the output of the neighbors method segmentation in comparison with combined. Besides being a visually undesirable effect, this phenomenon causes us to have an increase in the false positive rate.}\n    \\label{fig:diagonal_effect}\n\\end{figure*}", "meta": {"hexsha": "bb6d4de664028d9ac3b98e54994bcda3f0bdfb6c", "size": 24734, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cap-proposed-solution.tex", "max_stars_repo_name": "rodrigoadfaria/master-dissertation", "max_stars_repo_head_hexsha": "771fbd5005b71484319496f9c481dc843513ce9d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-22T19:07:16.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T19:07:16.000Z", "max_issues_repo_path": "cap-proposed-solution.tex", "max_issues_repo_name": "rodrigoadfaria/master-dissertation", "max_issues_repo_head_hexsha": "771fbd5005b71484319496f9c481dc843513ce9d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cap-proposed-solution.tex", "max_forks_repo_name": "rodrigoadfaria/master-dissertation", "max_forks_repo_head_hexsha": "771fbd5005b71484319496f9c481dc843513ce9d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 77.0529595016, "max_line_length": 898, "alphanum_fraction": 0.7003315275, "num_tokens": 7325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.40763515491927277}}
{"text": "\\documentclass{tufte-handout}\n\n%\\geometry{showframe}% for debugging purposes -- displays the margins\n\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amsthm}\n\\usepackage{stmaryrd}\n\\usepackage{graphicx}\n\\usepackage{setspace}\n\\usepackage{fancyhdr}\n\\usepackage[makeroom]{cancel}\n\\usepackage{booktabs}\n\\usepackage{units}\n\\usepackage{fancyvrb}\n\\fvset{fontsize=\\normalsize}\n\n% \\pagestyle{fancyplain}\n\n\\DeclareMathAlphabet{\\mathpzc}{OT1}{pzc}{m}{it}\n\n%% Autoscaled figures\n\\newcommand{\\incfig}{\\centering\\includegraphics}\n\\setkeys{Gin}{width=0.9\\linewidth,keepaspectratio}\n\n%% Commonly used macros\n\\newcommand{\\eqr}[1]{Eq.\\thinspace(#1)}\n\\newcommand{\\pfrac}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\pfracc}[2]{\\frac{\\partial^2 #1}{\\partial #2^2}}\n\\newcommand{\\pfraca}[1]{\\frac{\\partial}{\\partial #1}}\n\\newcommand{\\pfracb}[2]{\\partial #1/\\partial #2}\n\\newcommand{\\pfracbb}[2]{\\partial^2 #1/\\partial #2^2}\n\\newcommand{\\spfrac}[2]{{\\partial_{#1}} {#2}}\n\\newcommand{\\mvec}[1]{\\mathbf{#1}}\n\\newcommand{\\gvec}[1]{\\boldsymbol{#1}}\n\\newcommand{\\script}[1]{\\mathpzc{#1}}\n\\newcommand{\\eep}{\\mvec{e}_\\phi}\n\\newcommand{\\eer}{\\mvec{e}_r}\n\\newcommand{\\eez}{\\mvec{e}_z}\n\\newcommand{\\iprod}[2]{\\langle{#1}\\rangle_{#2}}\n\n%\\newcommand{\\gcs}{\\nabla_{\\mvec{x}}}\n\\newcommand{\\gcs}{\\nabla}\n\\newcommand{\\gvs}{\\nabla_{\\mvec{v}}}\n\\newcommand{\\gps}{\\nabla_{\\mvec{z}}}\n\\newcommand{\\dtv}{\\thinspace d^3\\mvec{v}}\n\\newcommand{\\dtx}{\\thinspace d^3\\mvec{x}}\n\n\\newtheorem{proposition}{Proposition}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{remark}{Remark}\n\n\\newcommand{\\nts}[1]{{\\color{blue} {#1}}}\n\n%Make the items smaller\n\\newcommand{\\cramplist}{\n\t\\setlength{\\itemsep}{0in}\n\t\\setlength{\\partopsep}{0in}\n\t\\setlength{\\topsep}{0in}}\n\\newcommand{\\cramp}{\\setlength{\\parskip}{.5\\parskip}}\n\\newcommand{\\zapspace}{\\topsep=0pt\\partopsep=0pt\\itemsep=0pt\\parskip=0pt}\n\n\\title{Premiminary results from fluid simulations of Vapor Box divertor}\n%\\author{Ammar H. Hakim}%\n\\date{\\today}%\n\n\\begin{document}\n\\maketitle\n\n\\begin{abstract}\n  \\noindent Some \\emph{very} preliminary results from invicid Euler\n  simulations of vapor box divertor concept are presented.\n\\end{abstract}\n\n\\section{Notes on boundary conditions}\n\nAt present, the boundary conditions are applied using ``ghost\ncells''. I.e. the vapor quantities in the cell just outside the domain\nare held fixed to the values computed from the evaporation formula\nwhich depends on the wall temperature\\footnote{P. Browning and\n  P.E. Potter, ``AN ASSESSMENT OF THE EXPERIMENTALLY DETERMINED VAPOUR\n  PRESSURES OF THE LIQUID ALKALI METALS'', in the \\emph{Handbook of\n    Thermodynamic and Transport Properties of Alkali Metals},\n  R.W. Ohse, Ed., 1985}. In the code, this is implemented as:\n\\begin{verbatim}\nfunction vaporPressure(Twall)\n   return math.exp(26.89-18880/Twall-0.4942*math.log(Twall))\nend\n\\end{verbatim}\nOnce pressure is determined, the number density is computed assuming\nthat the evaporated vapor is at the same temperature as the wall\n% \\footnote{It is possible that these BCs are not quite correct. We have\n%   computed fluxes based on drifting Maxwellians also, but these are\n%   harder to implement. Eventually, I plan to use the flux BCs (rather\n%   than the current ghost BCs) exclusively.}.\n\n\\section{Notes on equations and solver}\n\nWe are solving the standard invicid Navier-Stokes equations (Euler\nequations). These are written in conservation law form (in 1D)\n\\begin{align}\n  \\frac{\\partial}{\\partial{t}}\n  \\left[\n    \\begin{matrix}\n      \\rho \\\\\n      \\rho u \\\\\n      \\rho v \\\\\n      \\rho w \\\\\n      E\n    \\end{matrix}\n  \\right]\n  +\n  \\frac{\\partial}{\\partial{x}}\n  \\left[\n    \\begin{matrix}\n      \\rho u \\\\\n      \\rho u^2 + p \\\\\n      \\rho uv \\\\\n      \\rho uw \\\\\n      (E+p)u\n    \\end{matrix}\n  \\right]\n  =\n  0\n\\end{align}\nExtension to higher dimensions is obvious. Here\n\\begin{align}\n  E = \\rho \\varepsilon + \\frac{1}{2}\\rho q^2  \n\\end{align}\nis the total energy and $\\varepsilon$ is the internal energy of the\nfluid and $q^2=u^2 + v^2 + w^2$. The pressure is given by an equation\nof state (EOS) $p=p(\\varepsilon, \\rho)$. For an ideal gas the EOS is\n$p = (\\gamma-1)\\rho \\varepsilon$. The specific enthalpy is defined as\n$h = (E+p)/\\rho$, and is used in constructing numerical fluxes at cell\ninterfaces\\footnote{For details on this please see\n  \\url{http://ammar-hakim.org/sj/euler-eigensystem.html}}. I am using\nideal gas EOS for now, but this could be replaced later if\nneeded\\footnote{If we expect a mixture of atomic/diatomic Lithium we\n  may want to generate EOS tables and use them instead.}.\n\nTo solve these equations I am using a robust, second-order,\nshock-capturing finite-volume scheme, which has been benchmarked very\ncarefully on dozens of difficult problems.\\footnote{See\n  \\url{http://ammar-hakim.org/sj/je/je2/je2-euler-shock.html} for 1D\n  shock tests,\n  \\url{http://ammar-hakim.org/sj/je/je22/je22-euler-2d.html} for 2D\n  tests and \\url{http://ammar-hakim.org/sj/je/je23/je23-euler-3d.html}\n  for 3D tests.}.\n\n\n% \\section{Chain of two boxes}\n\n% To get some insight into the flow I have setup a chain of 2\n% boxes. Each box is $0.4\\times 0.4$~m and the slot connecting them is\n% $10$~cm wide, with a $10$~cm length. The left box walls are held to a\n% fixed temperature of $950^o$~C and the right box to $300^o$~C. Note\n% that baffles are held to the same temperature as the wall. The\n% simulation is run to steady-state. Profiles along the centerline of\n% the vapor box are shown below.\n% \\begin{figure}[ht]%\n%   \\setkeys{Gin}{width=0.3\\linewidth,keepaspectratio}\n%   \\incfig{s3-two-box-chain-mach.png}\n%   \\incfig{s3-two-box-chain-numDensity.png}\n%   \\incfig{s3-two-box-chain-temperature.png}\n%   \\caption{Mach number, number density and temperature along\n%     centerline from a two-box chain.}\n% \\end{figure}\n\n% The 2D colorplots of these quantities are shown below\n% \\begin{figure}[ht]%\n%   \\setkeys{Gin}{width=0.5\\linewidth,keepaspectratio}\n%   \\incfig{s3-two-box-chain_mach_00010.png}\n%   \\incfig{s3-two-box-chain_numDensity_00010.png}\n%   \\incfig{s3-two-box-chain_temp_00010.png}\n%   \\caption{Mach number (top), number density (middle) and temperature\n%     (bottom) from a two-box chain simulation.}\n% \\end{figure}\n\n\\section{Chain of five boxes: Lithium covered baffles}\n\nI ran a five-box chain simulation to steady state. Each box is\n$0.4\\times 0.4$~m and the slot connecting them is $10$~cm wide, with a\n$10$~cm length. Each box walls (including baffles) are held at a fixed\ntemperature, as specified in Rob's paper. The simulation is run to\nsteady-state. Profiles of various quantities are shown below.\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s6-four-box-chain-ln-numDensity.png}\n  \\caption{Number density from a five-box chain, with Lithium\n    covered baffles. See {\\tt vapor\\-box/s6} for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s6-four-box-chain-temperature.png}\n  \\caption{Temperature from a five-box chain, with Lithium covered\n    baffles. Note the temperature drops below the condensation point,\n    and hence the Lithium would form droplets and even Lithium\n    ``snow''. A true snow-flake divertor! However, the incoming heat\n    flux along the LCFS from the tokamak will probably prevent the\n    temperature dropping so much. It remains to be seen. See {\\tt\n      vapor\\-box/s6} for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s6-four-box-chain-xvel.png}\n  \\caption{X velocity from a five-box chain, with Lithium covered\n    baffles. The flow velocity increases rapidly, however, consistent\n    with flow into vacuum, asymptotes to a maximum value, which can be\n    determined from conservation of enthalpy along streamlines. See\n    {\\tt vapor\\-box/s6} for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s6-four-box-chain-mach.png}\n  \\caption{Mach number from a five-box chain, with Lithium covered\n    baffles. For $x>1$ the Mach number increases linearly (consistent\n    with flow into vacuum) as the temperature drops rapidly, even\n    though the flow velocity reaches a maximum value as shown in the\n    above figure. See {\\tt vapor\\-box/s6} for input file.}\n\\end{figure}\n\n\\section{Chain of five boxes: Equilibriated (reflecting) baffles}\n\nI ran a five-box chain simulation to steady state. Each box is\n$0.4\\times 0.4$~m and the slot connecting them is $10$~cm wide, with a\n$10$~cm length. Each box wall is held at a fixed temperature, as\nspecified in Rob's paper. The baffles are assumed to be in equilibrium\nwith the vapor impinging on them, and are hence treated as perfect\nreflectors\\footnote{The flux in the normal direction on the baffles is\n  set to zero, and the fluid is allowed to slip tangentially,\n  consistent with the invicid approximation.}. The simulation is run to\nsteady-state. Profiles of various quantities are shown below.\n\nThe key difference between the Lithium covered and equilibrated\nbaffles cases is the formation of a standing shock just behind each\nbaffle. This happens as the vapor reflects off the baffles, increasing\nback-pressure and eventually forming a standing shock a few\ncentimeters behind each baffle.\n\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s7-four-box-chain-ln-numDensity.png}\n  \\caption{Number density from a five-box chain, reflecting baffle\n    case. See {\\tt vapor\\-box/s7} for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s7-four-box-chain-temperature.png}\n  \\caption{Temperature from a five-box chain, reflecting baffle\n    case. Note the temperature drops below the condensation point, and\n    hence the Lithium would form droplets and even Lithium ``snow''. A\n    true snow-flake divertor! However, the incoming heat flux along\n    the LCFS from the tokamak will probably prevent the temperature\n    dropping so much. It remains to be seen. See {\\tt vapor\\-box/s7}\n    for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s7-four-box-chain-xvel.png}\n  \\caption{X velocity from a five-box chain, reflecting baffle\n    case. The flow velocity increases rapidly, however, consistent\n    with flow into vacuum, asymptotes to a maximum value, which can be\n    determined from conservation of enthalpy along streamlines. See\n    {\\tt vapor\\-box/s7} for input file.}\n\\end{figure}\n\\begin{figure}[ht]%\n  \\setkeys{Gin}{width=0.75\\linewidth,keepaspectratio}\n  \\incfig{s7-four-box-chain-mach.png}\n  \\caption{Mach number from a five-box chain, reflecting baffle\n    case. For $x>1$ the Mach number increases linearly (consistent\n    with flow into vacuum) as the temperature drops rapidly, even\n    though the flow velocity reaches a maximum value as shown in the\n    above figure. See {\\tt vapor\\-box/s7} for input file.}\n\\end{figure}\n\n\n\\end{document}", "meta": {"hexsha": "d33ed2ccfb8eaeaf9b6faf3d252fd4bf0dce52f7", "size": 10983, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sims-2/vapor-box/reps/vap-box-reps.tex", "max_stars_repo_name": "ammarhakim/ammar-simjournal", "max_stars_repo_head_hexsha": "85b64ddc9556f01a4fab37977864a7d878eac637", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-19T16:21:13.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-19T16:21:13.000Z", "max_issues_repo_path": "sims-2/vapor-box/reps/vap-box-reps.tex", "max_issues_repo_name": "ammarhakim/ammar-simjournal", "max_issues_repo_head_hexsha": "85b64ddc9556f01a4fab37977864a7d878eac637", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sims-2/vapor-box/reps/vap-box-reps.tex", "max_forks_repo_name": "ammarhakim/ammar-simjournal", "max_forks_repo_head_hexsha": "85b64ddc9556f01a4fab37977864a7d878eac637", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-08T06:23:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-08T07:06:50.000Z", "avg_line_length": 39.6498194946, "max_line_length": 73, "alphanum_fraction": 0.7332240736, "num_tokens": 3319, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.40763514910255944}}
{"text": "\\documentclass{article}\n%\\usepackage{fullpage}\n%\\usepackage{nopageno} \n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{tikz}\n\\usetikzlibrary{shapes.geometric, calc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage[normalem]{ulem}\n\\usepackage{fancyhdr}\n\\usepackage{cancel}\n\\usepackage{enumerate}\n%\\renewcommand\\headheight{12pt}\n\\pagestyle{fancy}\n\\lhead{April 30, 2014}\n\\rhead{Jon Allen}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\nPart 1 (7 points): Due in class Wednesday, April 30.\n\nChapter 8: \\#11, 12 (do three parts), 15, 16, 22(b), 26 (do two parts), 27, 28, 30, (Grad: 29)\n\n(Hint for \\#28: Use the 'more formal' definition of conjugate given in the book right before the example on p. 293.)\n\n\n\\begin{enumerate}\n  \\setcounter{enumi}{10}\n  \\item\n  Compute the Stirling numbers of the second kind $S(8,k),\\;(k=0,1,\\dots,8)$.\n  \\begin{align*}\n    S(8,0)&=0&S(8,8)&=1\\\\\n    \\intertext{Cheating with figure 8.2 on page 284 to get $S(7,k)$}\n    S(8,1)&=S(7,1)+S(7,0)=1&S(8,2)&=2S(7,2)+S(7,1)=127\\\\\n    S(8,3)&=3S(7,3)+S(7,2)=966&S(8,4)&=4S(7,4)+S(7,3)=1701\\\\\n    S(8,5)&=5S(7,5)+S(7,4)=1050&S(8,6)&=6S(7,6)+S(7,5)=266\\\\\n    S(8,7)&=7S(7,7)+S(7,6)=28\n  \\end{align*}\n  \\item\n  (do three parts)\n\n  Prove that the Stirling numbers of the second kind satisfy the following relations:\n  \\begin{enumerate}\n    \\item\n    $S(n,1)=1,\\;(n\\ge1)$\n    \\subsubsection*{proof}\n    We take as given that $S(n,0)=S(1,0)=0$ and $S(1,1)=1$ (equations 8.16 and 8.17 in the text). Now lets assume that $S(n-1,1)=1$\n    \\begin{align*}\n      S(n,1)&=1\\cdot S(n-1,1)+S(n-1,0)=1+0=1\n    \\end{align*}\n    And induction says we win $\\Box$\n    \\item\n    $S(n,2)=2^{n-1}-1,\\;(n\\ge2)$\n    \\subsubsection*{proof}\n    We wish count the ways of putting $n\\ge2$ elements into 2 indistinguishable boxes such that no box is empty. We can put our n elements into two distinguishable boxes in $2^n$ ways (2 choices for each element, n times). Now we subtract the cases where the first box is empty and where the second box is empty. and we have $2^n-2$ ways to put the elements into distinguishable boxes. If we have two colors to paint these boxes, we can do so in $2!=2$ ways. So dividing by the ways of distinguishing the boxes we have $\\frac{2n-2}{2}=2^{n-1}-1$ which is the result we want. $\\Box$\n    \\item\n    $S(n,n-1)=\\binom{n}{2},\\;(n\\ge1)$\n    \\subsubsection*{proof}\n    We wish to count the number of ways of putting $n\\ge1$ elements into $n-1$ indistinguishable boxes such that no box is empty. From the pigeonhole principle we know that at least one box has more than one element. If now take one element from every box we have $n-(n-1)=1$ element left. So one box has the one element left plus the one element we removed for two elements altogether. So we see we must put the $n$ elements into the boxes so 2 elements share a box and all the others are in boxes by themselves. So if we wish to count the ways to put the elements in boxes, we could simply count the number of ways to choose the two elements that share a box. And of course if we have $n$ elements we can choose two of them in $\\binom{n}{2}$ ways. Notice that $\\binom{1}{2}=0=S(1,0)$ so this result also works for the special case where where this proof makes no sense because we only have one element. $\\Box$\n%    \\item\n%    $S(n,n-2)=\\binom{n}{3}+3\\binom{n}{4},\\;(n\\ge2)$\n  \\end{enumerate}\n  \\setcounter{enumi}{14}\n  \\item\n  The number of partitions of a set of $n$ elements into $k$ distinguishable boxes (some of which may be empty) is $k^n$. By counting in a different way, prove that\n  \\[k^n=\\binom{k}{1}1!S(n,1)+\\binom{k}{2}2!S(n,2)+\\dots+\\binom{k}{n}n!S(n,n).\\]\n  (if $k>n$, define $S(n,k)$ to be 0.)\n  \\subsubsection*{proof}\n  Imagine we have $n$ elements that we want to put into $k$ boxes in such a way that $i\\ge1$ boxes have things in them, and the rest are empty. Then we can put these elements into $i$ indistinguishable boxes in $S(n,i)$ ways. Now we distinguish the boxes by ``painting'' them in $i$ ``colors'' which we can do $i!$ ways. So we can put the elements into $i$ distinguishable nonempty boxes in $i!S(n,i)$ ways. Now we can pick the boxes that have elements in them from the $k$ boxes in $\\binom{k}{i}$ ways, for a total of $\\binom{k}{i}i!S(n,i)$ ways to fill $i$ of $k$ distinguisheable boxes with $n$ objects. To find the total number of ways to distribute the $n$ objects we sum the ways to distribute the objects with all possible values of $i$. This must be $k^n$ and so we have our result\n  \\begin{align*}\n    k^n&=\\sum\\limits_{i=1}^k{\\binom{k}{i}i!S(n,i)}\n  \\end{align*}\n  $\\Box$\n  \\item\n  Compute the Bell number $B_8$. (Cf. Exercise 11.)\n  \\begin{align*}\n    B_p&=S(p,0)+S(p,1)+\\dots+S(p,p)\\\\\n    B_8&=S(8,0)+S(8,1)+\\dots+S(8,8)\\\\\n    &=0+1+127+966+1701+1050+266+28+1\\\\\n    &=4140\n  \\end{align*}\n  \\setcounter{enumi}{21}\n  \\item\n  \\begin{enumerate}\n    \\setcounter{enumii}{1}\n    \\item\n    Calculate the partition number $p_7$ and construct the diagram of the set $\\mathcal{P}_7$, partially orderedby majorization\n    \\begin{align*}\n      \\begin{matrix}\n      &7^1\\\\\n      &\\downarrow\\\\\n      &6^11^1\\\\\n      &\\downarrow\\\\\n      &5^12^1\\\\\n      \\downarrow&&\\downarrow\\\\\n      5^11^2&&4^13^1\\\\\n      &\\downarrow\\\\\n      &4^12^11^1\\\\\n      \\downarrow&&\\downarrow\\\\\n      4^11^3&&3^21^1\\\\\n      \\downarrow&&\\downarrow\\\\\n      \\downarrow&&3^12^2\\\\\n      \\to&\\to\\leftarrow&\\leftarrow\\\\\n      &\\downarrow\\\\\n      &\\leftarrow\\to&\\\\\n      \\downarrow&&\\downarrow\\\\\n      3^12^11^2&&2^31^1\\\\\n      \\downarrow&&\\downarrow\\\\\n      3^11^4&&\\downarrow\\\\\n      \\to&\\to\\leftarrow&\\leftarrow\\\\\n      &\\downarrow\\\\\n      &2^21^3\\\\\n      &\\downarrow\\\\\n      &2^11^5\\\\\n      &\\downarrow\\\\\n      &1^7\n      \\end{matrix}\n    \\end{align*}\n    And of course $p_7=15$\n  \\end{enumerate}\n  \\setcounter{enumi}{25}\n  \\item\n  (do two parts)\n  \n  Determine the conjugate of each of the following partitions\n  \\begin{enumerate}\n    \\item\n    $12=5+4+2+1$\n\n    We observe that $\\{5,4,2,1\\}$ has 4 elements. This is the length of our first row. The last element is size 1, so there will be one of those. The difference between the last two elements is 1, so we have one row of 3 next. The difference between 4 and 2 is 2, so we have 2 rows of 2. And 5-4 makes the last row have only one element. The other answers are obtained similarly.\n\n    $12=4+3+2+2+1$\n    \\item\n    $15=6+4+3+1+1$\n\n    $15=5+3+3+2+1+1$\n    \\item\n    $20=6+6+4+4$\n    \n    $20=4+4+4+4+2+2$\n    \\item\n    $21=6+5+4+3+2+1$\n\n    $21=6+5+4+3+2+1$\n    \\item\n    $29=8+6+6+4+3+2$\n\n    $29=6+6+5+4+3+3+1+1$\n  \\end{enumerate}\n  \\item\n  For each integer $n>2$, determine a self-conjugate partition of $n$ that has at least two parts\n\n  If $n$ is odd, then make one row of length $\\frac{n+1}{2}$ and $\\frac{n-1}{2}$ rows of length 1. If $n$ is even then make a row of $\\frac{n}{2}$, a row of 2, and $\\frac{n-4}{2}$ rows of length 1.\n  \\item\n  Prove that conjugation reverses the order of majorization; that is, if $\\lambda$ and $\\mu$ are partitions of $n$ and $\\lambda$ is majorized by $\\mu$, then $\\mu^*$ is majorized by $\\lambda^*$.\n  \\subsubsection*{proof}\n  Let us define the notation $\\lambda_k, \\mu_k, {\\lambda_k}^*,{\\mu_k}^*$ as the size of the $k$th row of the $\\lambda,\\mu,\\lambda^*,\\mu*$ partitions. Because $\\lambda$ majorizes $\\mu$ we know two important things.\n  \\begin{align*}\n    \\lambda_1&\\ge\\mu_1\\\\\n    \\sum\\limits_{i=1}^k{\\lambda_i}&\\ge\\sum\\limits_{i=1}^k{\\mu_i}\n  \\end{align*}\n  Where $k$ is the number of partitions of $\\lambda$ or $\\mu$, whichever has fewer partitions. But of course we know that because these are partitions of $n$ the the sum of the partition sizes of the partition with less partitions must be $n$. So we see that\n  \\begin{align*}\n    n=\\sum\\limits_{i=1}^k{\\lambda_i}&\\ge\\sum\\limits_{i=1}^k{\\mu_i}\\\\\n    n=\\sum\\limits_{i=1}^k{\\lambda_i}&=\\sum\\limits_{i=1}^k{\\mu_i}+\\sum\\limits_{i=1}^l{\\mu_i}\n  \\end{align*}\n  And so $k$ is the number of partitions of $\\lambda$ while $k+l$ is the number of partitions of $\\mu$ where $k\\ge{k+l}$.\n\n  Now when we conjugate these partitions we see that because $k$ is the number of rows of $\\lambda$, ${\\lambda_1}^*=k$. Similarly ${\\mu_1}^*=k+l$. Now because $k\\le{k+1}$ we know that ${\\lambda_1}^*\\le{\\mu_1}^*$\n\n  Now we strip one element from each row of our partitions. This is effectively removing ${\\lambda_1}^*$ and ${\\mu_1}^*$. Now because the partial sums of $\\lambda_i$ are more than the partial sums of $\\mu_i$ we know that we have a new set of partial sums that fit the same rule.\n  We can repeat this until we run out of element, building our conjugates and the partial sum inequality will always hold. Now because the amount we have taken from our original partition and have put into our conjugate partition sums to n, and we start with the opposite inequality for our conjugate partitions (${\\lambda_1}^*\\le{\\mu_1}^*)$ we know that as long as the inequality holds for the partial sum of the original partition, the opposite inequality will hold for the partial sums of the conjugate partitions. $\\Box$\n\n%  Now if we strip off an element from each of the partitions, then we are left with the following for all $k\\ge1$.\n%  \\begin{align*}\n%    \\sum\\limits_{i=1}^k{\\lambda_i}&\\ge\\sum\\limits_{i=1}^k{\\mu_i}\\\\\n%    \\sum\\limits_{i=1}^k{\\lambda_i-1}&\\ge\\sum\\limits_{i=1}^k{\\mu_i-1}\n%  \\end{align*}\n%  We have just stripped off the first row of our conjugated partitions. We have created some new groups of subsets (not really technically partitions anymore). Lets call these new groups $\\lambda^+,\\mu^+$. Notice that $\\mu+$ is majorized by $\\lambda+$. Now from the logic we just went over we can say that the first row of the conjugate of $\\lambda+$ is shorter than the first row of the conjugate of $\\mu^+$ and by extension ${\\lambda_2}^*\\le{\\mu_2}^*$.\n%  If we follow this process out until we run out of rows/columns, we can see that it will always be true that ${\\lambda_k}^*\\le{\\mu_k}^*$ and so $\\lambda^*$ is majorized by $\\mu^*$\n  \\setcounter{enumi}{29}\n  \\item\n  Prove that the partition function satisfies\n  \\[p_n>p_{n-1}\\;(n\\ge2).\\]\n  \\subsubsection*{proof}\n  If we take the $p_{n-1}$ partitions of $n-1$ and add a single element partition to it, then we have $p_{n-1}$ partitions of $n$. Also note that $n^1$ is not a partition of $n-1$ but is a partition of $n$. So we have $p_n\\ge {p_{n-1}+1}>p_{n-1}$ and our simple proof. $\\Box$\n  \\setcounter{enumi}{28}\n  \\item (grad)\n\\end{enumerate}\n\\end{document}\n", "meta": {"hexsha": "58c368f900cf1c8c05b9696e6d6c0ae06f16fbfa", "size": 10449, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combinatorics/combinatorics-hw-2014-04-30.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "combinatorics/combinatorics-hw-2014-04-30.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combinatorics/combinatorics-hw-2014-04-30.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.1398963731, "max_line_length": 911, "alphanum_fraction": 0.6627428462, "num_tokens": 3649, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883449573376, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.40763513549086744}}
{"text": "\\documentclass[12pt, letterpaper]{article}\n\\include{eu}\n\n\\begin{document}\n\n\\section*{\\textsl{Einstein's Universe} Problem Set 4}\n\nThis problem set is not to be handed in for credit. But it is due\nbefore \\textbf{Tuesday November 9}, when some of these problems\nwill appear in part, near-verbatim, on Term Exam 4.\n\n\\begin{problem}\nThe energy $E$ of a particle of mass $m$ moving\nat speed $v$ is given by:\n\\begin{equation}\\label{eq:energy}\nE = \\gamma\\,m\\,c^2\n\\end{equation}\n\\begin{equation}\n\\gamma = \\frac{1}{\\sqrt{1 - v^2/c^2}}\n\\end{equation}\nThis means that if something is at rest, its energy is $m\\,c^2$.\nWe can define a \\emph{kinetic energy} to be the difference\nbetween the total energy of an object given by\nequation~(\\ref{eq:energy}) and the rest energy $m\\,c^2$.\n\nWhat would be the kinetic energy of a baseball moving at 80~percent of the\nspeed of light? Give your answer in joules but also in tons of TNT\nequivalent. For context, the worst nuclear weapons are measured in\nmegatons.\n\nDo you think we could ever accelerate a baseball to this speed?\n\\end{problem}\n\n%% \\begin{problem}\n%% As we said in lecture, if you heat something up, it becomes more\n%% massive! Imagine you took 1\\,kg of water and heated it up by 50~deg~C.\n%% By how much would its mass increase because of this heating?\n%% You might have to look up the heat capacity of water.\n%% \\end{problem}\n\n\\begin{problem}\n  HOGG: FOR NEXT YEAR: SAY MORE ABOUT UNITS.\n\n  HOGG: FOR NEXT YEAR: TONNES is TONNES OF CO2 not TONNES OF C.\n\nA typical American has a carbon footprint of 40-ish tonnes per year.\nIf somehow, magically, all of that fossil-fuel consumption could be\nconverted to nuclear fission energy, how much nuclear reactor fuel\nwould you need to use?\n\n\\textsl{(a)}~To perform this calculation, look up the energy you\nget for every carbon triple bond you use up (use that for the carbon\nmass-to-energy conversion, assming you release one carbon atom for\nevery triple bond broken). Also look up the fission energy\nper uranium atom, and the fusion energy you would get if you could fuse\nhydrogen to iron.\n\nNote that the energies will have slightly different units: The chemical\nenergy will be joules or eV per bond, the fission energy will be joules\nor MeV per atom, and the fusion energy will be joules or MeV per nucleon.\n\n\\textsl{(b)}~Now, using what you looked up, compute how much energy\ncorresponds to 40~tonnes of carbon, assuming that you started with one\ncarbon triple bond per carbon atom (a very optimistic assumption!).\nGive your answer in joules. You will have to use the fact that a mole of\ncarbon atoms is 12~g.\n\n\\textsl{(c)}~Now compute how much uranium you would need to fission to\nget the same amount of energy. You will have to use the molar mass of\nUranium here.\nThat is, if an American converts 40 tonnes of carbon fossil-fuel usage\nper year over to uranium fission reactor nuclear energy, how much\nuranium would that person use per year? Give your answer in kg.\n\n\\textsl{(d)}~Now consider nuclear \\emph{fusion}: \nHow much fusion fuel would each American need each year? Give your answer\nin kg. And note that this could be derived directly from water, in principle!\n\nI'm only looking for rough answers here.\n\\end{problem}\n\n\\begin{problem}\nA box of mass $M$ sits on the floor of an elevator at rest. Gravity\n(which has a strength set by the local acceleration due to gravity\n$g$) pulls the box and the floor pushes the box. The \\emph{net} or\ntotal force on the box is zero. What is the force on the box from the\nfloor? Give both the magnitude and the direction.\n\nNow imagine that the elevator is accelerating upwards at acceleration $a$.\nNow the two forces on the box don't balance! Because, after all, the box\nis accelerating upwards. What is the force on the box from the floor in this\ncase?\n\nNow imagine that the elevator is accelerating downwards at acceleration $a$.\nSame question.\n\nNow imagine that the elevator is accelerating downwards at acceleration $a = g$.\nSame question. Look up the ``vomit comet'' and tell me what this problem has to\ndo with that airplane.\n\\end{problem}\n\n\\end{document}\n", "meta": {"hexsha": "8904c07f745261fc8612bc92e64f9caaf92bc3a4", "size": 4091, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/ps4.tex", "max_stars_repo_name": "davidwhogg/EinsteinsUniverse", "max_stars_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/ps4.tex", "max_issues_repo_name": "davidwhogg/EinsteinsUniverse", "max_issues_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-08-24T19:50:27.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-30T01:39:39.000Z", "max_forks_repo_path": "tex/ps4.tex", "max_forks_repo_name": "davidwhogg/EinsteinsUniverse", "max_forks_repo_head_hexsha": "91babed322a5985a45ec827c030564cacbd49354", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.7184466019, "max_line_length": 80, "alphanum_fraction": 0.7624052799, "num_tokens": 1071, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.7905303162021596, "lm_q1q2_score": 0.4076131750166465}}
{"text": "\\graphicspath{{Ch6_2021_neurips/figs/}}\n\n\\chapter{{Parameter Prediction for Unseen Deep Architectures}\\label{ch:neurips2021}}\n\n\\input{Ch6_2021_neurips/prolog}\n\n\\section{Introduction}\n\nConsider the problem of training deep neural networks on large annotated datasets, \nsuch as ImageNet~\\citep{russakovsky2015imagenet}. This problem can be formalized as finding optimal parameters for a given neural network $a$, parameterized by $\\w$, w.r.t. a loss function $\\loss$ on the dataset $\\domain=\\{(\\bx_i, y_i)\\}_{i=1}^N$ of inputs $\\bx_i$ and targets $y_i$:\\looseness-1\n%\n\\begin{equation}\n\\label{eq:optim1b}\n\\underset{\\w}{\\text{arg\\,min }}\\sum\\nolimits_{i=1}^N \\loss(f(\\bx_i; \\f, \\w), y_i),\n\\end{equation}\n%\nwhere $f(\\bx_i; a, \\w)$ represents a forward pass.\n\\eqref{eq:optim1b} is usually minimized by iterative optimization algorithms -- e.g. SGD~\\citep{ruder2016overview} and Adam~\\citep{kingma2014adam}\n-- that converge to performant parameters $\\w_p$ of the architecture $\\f$. Despite the progress in improving the training speed and convergence~\\citep{huang2016deep,brock2017freezeout,choi2019faster,ioffe2015batch}, obtaining $\\w_p$ remains a bottleneck in large-scale machine learning pipelines. For example, training a ResNet-50~\\citep{he2016deep} on ImageNet can take many GPU hours~\\citep{nvidia}. With the ever growing size of networks~\\citep{brown2020language} and necessity of training the networks repeatedly (e.g.~for hyperparameter or architecture search), the classical process of obtaining $\\w_p$ is becoming computationally unsustainable~\\citep{strubell2019energy,cai2019onceforall,thompson2020computational}. \n\n\\textbf{A new parameter prediction task.}\nWhen optimizing the parameters for a \\textit{new} architecture $\\f$, typical optimizers disregard past experience gained by optimizing other nets. However, leveraging this past experience can be the key to reduce the reliance on iterative optimization and, hence the high computational demands.\nTo progress in that direction, we propose a new task where iterative optimization is replaced with a \\textit{single forward pass} of a hypernetwork~\\citep{ha2016hypernetworks} $H_\\domain$.\nTo tackle the task, $H_\\domain$ is expected to leverage the knowledge of how to optimize \\textit{other}\tnetworks $\\nets$.\nFormally, the task is to predict the parameters of an \\textit{unseen} architecture $\\f \\notin \\nets$ using $H_\\domain$, parameterized by $\\theta_p$: $\\hat{\\w}_p=H_{\\domain}(\\f; \\theta_p)$.\nThe task is constrained to a dataset $\\domain$, so $\\hat{\\w}_p$ are the predicted parameters for which the test set performance of $f(\\bx; \\f, \\hat{\\w}_p)$ is similar to the one of $f(\\bx; \\f, \\w_p)$.\nFor example, we consider CIFAR-10~\\citep{krizhevsky2009learning} and ImageNet image classification datasets $\\domain$, where the test set performance is classification accuracy on test images.\\looseness-1\n\n\\textbf{Approaching our task.}\nA straightforward approach to expose $H_\\domain$ to the knowledge of how to optimize other networks is to train it on a large training set of $\\{(a_i, \\w_{p,i})\\}$ pairs, however, that is prohibitive\\footnote{Training a single network $a_i$ can take several GPU days and thousands of trained networks may be required.\\looseness-1}. Instead, we follow the bi-level optimization paradigm common in meta-learning~\\citep{hospedales2020meta,andrychowicz2016learning,ravi2016optimization}, but rather than iterating over $M$ tasks, we iterate over $M$ training architectures $\\nets=\\{a_i\\}_{i=1}^M$:\\looseness-1\n%\n\\begin{equation}\n\\label{eq:solution}\n\\underset{\\theta}{\\text{arg\\,min }} \\sum\\nolimits_{j=1}^N \\sum\\nolimits_{i=1}^{M}\\loss\\Big(f\\Big( \\bx_j; a_i,  H_\\domain(a_i;{\\theta})\\Big), y_j\\Big).\n\\end{equation}\n\nBy optimizing \\eqref{eq:solution}, the hypernetwork $H_{\\domain}$ gradually gains knowledge of how to predict performant parameters for training architectures. It can then leverage this knowledge at test time -- when predicting parameters for \\textit{unseen} architectures. \nTo approach the problem in \\eqref{eq:solution}, we need to design the network space $\\nets$ and $H_{\\domain}$.\nFor $\\nets$, we rely on the previous design spaces for neural architectures~\\citep{liu2018darts} that we extend\nin two ways: the ability to sample distinct architectures and an expanded design space that includes diverse architectures, such as ResNets and Visual Transformers~\\citep{dosovitskiy2020image}. \nSuch architectures can be fully described in the form of computational graphs (\\fig{\\ref{fig:ghn_overview}}). So, to design the hypernetwork $H_{\\domain}$, we rely on recent advances in machine learning on graph-structured data~\\citep{kipf2016semi,velickovic2017graph,dwivedi2020benchmarking,zhang2018graph}.\nIn particular, we build on the Graph HyperNetworks method (GHNs)~\\citep{zhang2018graph} that also optimizes \\eqref{eq:solution}. However, GHNs do not aim to predict large-scale performant parameters as we do in this work, which motivates us to improve on their approach.\\looseness-1\n\nBy designing our diverse space $\\nets$ and improving on GHNs, we boost the accuracy achieved by the predicted parameters on \\textit{unseen} architectures to 77\\% (top-1) and 48\\% (top-5) on CIFAR-10~\\citep{krizhevsky2009learning} and ImageNet~\\citep{russakovsky2015imagenet}, respectively. Surprisingly, our GHN shows good out-of-distribution generalization and predicts good \\params for architectures that are much larger and deeper compared to the ones seen in training. For example, we can predict all 24 million parameters of ResNet-50 in less than a second either on a GPU or CPU achieving $\\sim$60\\% on CIFAR-10 without any gradient updates (Fig~\\ref{fig:ghn_overview}, (b)).\\looseness-1\n\nOverall, our framework and results pave the road toward a new and significantly more efficient paradigm for training networks.\nOur \\textbf{contributions} are as follows: (\\textbf{a}) we introduce the novel task of predicting performant \\params for diverse feedforward neural networks with a single hypernetwork forward pass;\n(\\textbf{b}) we introduce \\dataset~-- a standardized benchmark with in-distribution and out-of-distribution architectures to track progress on the task (\\S~\\ref{sec:dataset}); (\\textbf{c}) we define several baselines and propose a GHN model (\\S~\\ref{sec:ghn_model}) that performs surprisingly well on CIFAR-10 and ImageNet (\\S~\\ref{sec:our_task}); (\\textbf{d}) we show that our model learns a strong representation of neural network architectures (\\S~\\ref{sec:prop_pred}), and our model is useful for initializing neural networks (\\S~\\ref{sec:finetune}).\nOur \\dataset dataset, trained GHNs and code is available at \\textcolor{violet}{\\url{https://github.com/facebookresearch/ppuda}}.\n\n\\begin{figure}[tbhp]\n\t\\centering\n\t\\small \n\t\\setlength{\\tabcolsep}{2pt}\n\t\\vspace{-7pt}\n\t\\begin{tabular}{cc}\n\t\t\\multirow{2}{*}{\\includegraphics[width=0.75\\textwidth,align=c,trim={0 0 0 0}, clip]{overview_ghn2.pdf}} & \\parbox{3cm}{\\vspace{10pt} \\scriptsize \\centering Example of evaluating on an unseen architecture $a \\notin \\nets$ (ResNet-50)}\\\\\n\t\t& \\includegraphics[width=0.22\\textwidth,align=c,trim={0 0 0 0}, clip]{resnet_fig1.pdf} \\vspace{5pt}\\\\\n\t\t(a) & (b) \\\\\n\t\\end{tabular}\n\t\\vspace{-5pt}\n\t\\caption{\\small \\textbf{(a)} Overview of our GHN model (\\S~\\ref{sec:ghn_model}) trained by backpropagation through the predicted parameters ($\\hat{\\w}_p$) on a given image dataset and our \\dataset dataset of architectures. Colored captions show our key improvements to vanilla GHNs (\\S~\\ref{sec:bg_ghn}). The red one is used only during training GHNs, while the blue ones are used both at training and testing time. The computational graph of $a_1$ is visualized as described in Table~\\ref{tab:graphs}. \\textbf{(b)} Comparing classification accuracies when all the parameters of a ResNet-50 are predicted by GHNs versus when its parameters are trained with SGD (see full results in \\S~\\ref{sec:ghn_exper}).\n\t}\n\t\\label{fig:ghn_overview}\n\t\\vspace{-15pt}\n\\end{figure}\n\n\\section{Background\\label{sec:problem}}\n\nWe start by providing a brief background about the network design spaces leveraged in the creation of our \\dataset dataset of neural architectures described in \\S~\\ref{sec:dataset}. We then cover elements of graph hypernetworks that we leverage when designing our specific GHN $H_\\domain$ in \\S~\\ref{sec:ghn_model}.\n\n\\subsection{Network design space of DARTS\\label{sec:bg_darts}}\n\nDARTS~\\citep{liu2018darts} is a differentiable NAS framework. For image classification tasks such as those considered in this work, its networks are defined by four types of building blocks: \\emph{stems}, \\emph{normal cells},  \\emph{reduction cells}, and \\emph{classification heads}. Stems are fixed blocks of convolutional operations that process input images. \nThe normal and reduction cells are the main blocks of architectures and are composed of: \n3$\\PLH$3 and 5$\\PLH$5 separable convolutions,\n3$\\PLH$3 and 5$\\PLH$5 dilated separable convolutions, \n3$\\PLH$3 max pooling,  3$\\PLH$3 average pooling, identity and zero (to indicate the absence of connectivity between two operations). Finally, the classification head defines the network output and is built with a global pooling followed by a single fully connected layer.\n\nTypically, DARTS networks have one stem block, 14-20 cells, and one classification head, altogether forming a deep computational graph. The reduction cells, placed only at 1/3 and 2/3 of the total depth, decrease the spatial resolution and increase the channel dimensionality by a factor of 2. Summation and concatenation are used to aggregate outputs from multiple operations within each cell. To make the channel dimensionalities match, 1$\\PLH$1 convolutions are used as needed. All convolutional operations use the ReLU-Conv-Batch Norm (BN)~\\citep{ioffe2015batch} order. Overall, DARTS enables defining strong architectures that combine many principles of manual~\\citep{simonyan2014very,he2016deep,xie2017aggregated,huang2017densely} and automatic~\\citep{zhang2018graph,zoph2016neural,zoph2018learning,liu2018progressive,real2019regularized,chen2019progressive,howard2019searching} design of neural architectures. While DARTS learns the optimal task-specific cells, the framework can be modified to permit sampling randomly-structured cells. We leverage this possibility for the \\dataset construction in \\S~\\ref{sec:dataset}.\n%Please see \\S~\\ref{apdx:darts_bg} for further details on DARTS.\n\\looseness-1\n\n\n\\subsection{Graph hypernetwork: \\ghnbase\\label{sec:bg_ghn}}\n\n\\paragraph{Representation of architectures.} GHNs~\\citep{zhang2018graph} directly operate on the computational graph of a neural architecture $\\f$. Specifically, $\\f$ is a directed acyclic graph (DAG), where nodes $V =\\{v_i\\}_{i=1}^{|V|}$ are operations (e.g. convolutions, fully-connected layers, summations, etc.) and their connectivity is described by a binary adjacency matrix $\\mathbf{A}\\in \\{0,1\\}^{|V|\\times |V|}$. Nodes are further characterized by a matrix of initial node features $\\mathbf{H}^{0}=[\\h_1^{0}, \\h_2^{0}, ..., \\h_{|V|}^{0}]$, where each $\\h_v^{0}$ is a one-hot vector representing the operation performed by the node. \nWe also use such a one-hot representation for $\\mathbf{H}^{0}$, but in addition encode the shape of parameters associated with nodes.\n%as described in detail in \\S~\\ref{apdx:ghn_1}.\\looseness-1\n\n\\paragraph{Design of the graph hypernetwork.} In~\\citep{zhang2018graph}, the graph hypernetwork $H_\\domain$ consists of three key modules. The first module takes the input node features $\\mathbf{H}^{0}$ and transforms them into $d$-dimensional node features $\\mathbf{H}^{1} \\in \\mathbb{R}^{|V| \\times d}$ through an embedding layer. The second module takes $\\mathbf{H}^{1}$ together with $\\mathbf{A}$ and feeds them into a specific variant of the gated graph neural network (GatedGNN)~\\citep{li2015gated}. In particular, their GatedGNN mimics the canonical order $\\pi$ of node execution in the forward (fw) and backward (bw) passes through a computational graph.\nTo do so, it sequentially traverses the graph and performs iterative message passing operations and node feature updates as follows: \n%\n\\begin{align}\n\\label{eq:ghn_prop}\n\\forall t \\in [1,...,T]:  \\Big[ \\forall \\pi \\in [\\text{fw},\\text{bw}]: \\Big( \\forall v \\in \\pi: \\mathbf{m}^t_v = \\sum\\limits_{u \\in \\neigh_{v}^{\\pi}} \\text{MLP}(\\mathbf{h}^{t}_u), \\ \\ \\mathbf{\\mathbf{h}}^{t}_v = \\text{GRU}(\\mathbf{h}_v^t, \\mathbf{m}_v^t) \\Big) \\Big],\n\\end{align}\n%   \nwhere $T$ denotes the total number of forward-backward passes; $\\mathbf{h}_v^t$ corresponds to the features of node $v$ in the $t$-th graph traversal; $\\text{MLP}(\\cdot)$ is a multi-layer perceptron; and $\\text{GRU}(\\cdot)$ is the update function of the Gated Recurrent Unit~\\citep{cho2014learning}. In the forward propagation ($\\pi=\\text{fw}$), $\\neigh_v^{\\pi}$ corresponds to the incoming neighbors of the node defined by $\\mathbf{A}$, then in the backward propagation ($\\pi=\\text{bw}$) it similarly corresponds to the outgoing neighbors of the node. The last module uses the GatedGNN output hidden states $\\mathbf{h}_v^T$ to condition a decoder that produces the parameters $\\hat{\\w}_{p}^{v}$ (e.g. convolutional weights) associated with each node. \nIn practice, to handle different parameter dimensionalities per operation type, the output of the hypernetwork is reshaped and sliced according to the shape of parameters in each node. We refer to the model described above as \\ghnbase~(\\fig{\\ref{fig:ghn_overview}}). Further subtleties of implementing this model in the context of our task can be found in our source code.\n% discussed in \\S~\\ref{apdx:ghn_1}.\n\n\\paragraph{How do graph hypernetworks learn?}\n\nIt may be not obvious why GHNs allow us to optimize such a difficult objective of learning to predict performant parameters \\eqref{eq:solution}. In particular, perhaps the most surprising working principle behind training GHNs is that we sample a new architecture for each training iteration. \nThis comes as a striking contrast to training a standard machine learning objective \\eqref{eq:optim1b} that requires thousands or millions optimization steps just for a single architecture.\nHow is it possible that GHNs learn from just a single optimization step on each architecture?\n\nThere is no clear answer to this question in the literature so far. To provide a high-level answer we can draw an analogy between the \\textit{distribution of images} used to train a neural network in~\\eqref{eq:optim1b} and the \\textit{distribution of architectures} used to train GHNs in~\\eqref{eq:solution}. In \\eqref{eq:optim1b}, when we train the parameters of a single network using SGD, we sample new images for each training iteration. While we can run optimization for the same images for more than one iteration, this is considered to be poor practice that will likely lead to overfitting. \nSo typically we sample new images for each training iteration, however it is critical that at each iteration the images are drawn from the same distribution. This way the neural network gradually captures the regularities in the distribution of images to make better predictions in the subsequent steps. If we sample drastically different images for each training iteration (\\eg natural images in the first iteration, medical images in the second iteration, then some binary QR codes, etc.), then \\eqref{eq:optim1b} would be hard or impossible to optimize.\nThe same principle may be the key to enable training GHNs.\nAt each training iteration, a GHN slightly improves its parameters (by gradient descent) w.r.t. a single architecture sampled from some distribution.\nIf there are regularities in this distribution and the GHN can capture them, then the improvements of GHN parameters in the previous steps can result in improvements for the new architectures in the next steps as long as all the architectures are sampled from the same distribution. In terms of gradient descent, the direction of parameter updates of the GHN computed for a single architecture can be useful for the entire distribution of architectures. By following this direction using gradient descent, the GHN can gradually improve over time on the entire distribution.\nThese improvements depend heavily on the shape of the training distribution. We need to make sure that this distribution has strong regularities to enable training of GHNs, but at the same time has diverse enough samples to enable generalization (prediction of performant parameter for unseen architectures). The design of such a distribution is described in the next section.\n\n\n%Instead of observing the same image repeatedly, we generally aim to observe more diverse images to improve generalization.\n\n\\vspace{-5pt}\n\\section{DeepNets-1M\\label{sec:dataset}}\n\\vspace{-5pt}\n\nThe network design space of DARTS is limited by the number of unique operations that compose cells, and the low variety of stems and classification heads. Thus, many architectures are not realizable within this design space, including: VGG~\\citep{simonyan2014very}, ResNets~\\citep{he2016deep}, MobileNet~\\citep{howard2019searching} or more recent ones such as Visual Transformer (ViT)~\\citep{dosovitskiy2020image} and Normalization-free networks~\\citep{brock2021characterizing,brock2021high}.\nFurthermore, DARTS does not define a procedure to sample random architectures.\t\nBy addressing these two limitations we aim to expose our hypernetwork to diverse training architectures and permit its evaluation on common architectures, such as ResNet-50. We hypothesize that increased training diversity can improve hypernetworks' generalization to unseen architectures making it more competitive to iterative optimizers.\\looseness-1\n\n\\textbf{Extending the network design space.} We extend the set of possible operations with non-separable 2D convolutions\\footnote{Non-separable convolutions have weights of e.g. shape 3$\\PLH$3$\\PLH$512$\\PLH$512 as in ResNet-50. NAS works, such as DARTS and GHN, avoid such convolutions, since the separable ones~\\citep{sifre2014rigid} are more efficient. Non-separable convolutions are nevertheless common in practice and can often boost the downstream performance.}, Squeeze\\&Excite (SE\\footnote{SE is common in many efficient networks~\\citep{howard2017mobilenets,cai2019onceforall}.})~\\citep{hu2018squeeze} and Transformer-based operations~\\citep{vaswani2017attention,dosovitskiy2020image}: multihead self-attention (MSA), positional encoding and layer norm (LN)~\\citep{ba2016layer}. \nEach node (operation) in our graphs has two attributes: \\emph{primitive type} (e.g. convolution) and \\emph{shape} (e.g. 3$\\PLH$3$\\PLH$512$\\PLH$512). Overall, our extended set consists of 15 primitive types (Table~\\ref{tab:graphs}).\nWe also extend the diversity of the generated architectures by introducing VGG-style classification heads and ViT stems. \nFinally, to further increase architectural diversity, we allow the operations to not include batch norm (BN)~\\citep{ioffe2015batch} and permit networks without channel width expansion (e.g. as in~\\citep{dosovitskiy2020image}).\\looseness-1\n\n\\textbf{Architecture generation process.} We generate different subsets of architectures (see the description of each subset in the next two paragraphs and in Table~\\ref{tab:graphs}). For each subset depending on its purpose, we predefine a range of possible model depths (number of cells), widths and number of nodes per cell. Then, we sample a stem, a normal and reduction cell and a classification head. The internal structure of the normal and reduction cells is defined by uniformly sampling from all available operations. \nDue to a diverse design space it is extremely unlikely to sample the same architecture multiple times, but we ran a sanity check using the Hungarian algorithm~\\citep{kuhn1955hungarian} to confirm that.\n%(see Figure~\\ref{fig:vis_stats} in \\S~\\ref{apdx:stats} for details).\\looseness-1\n\n\\begin{table}[t!]\n\t\\centering\n\t\\vspace{-10pt}\n\t\\caption{\\small Examples of computational graphs (visualized using NetworkX~\\citep{hagberg2008exploring}) in each split and their key statistics, to which we add the average degree and average shortest path length often used to measure local and global graph properties respectively~\\citep{barrat2004architecture,you2020graph}. In the visualized graphs, a node is one of the 15 primitives coded with markers shown at the bottom, where they are sorted by the frequency in the training set. For visualization purposes, a blue triangle marker differentiates a 1$\\PLH$1 convolution (equivalent to a fully-connected layer over channels) from other convolutions, but its primitive type is still just convolution. \\textsuperscript{*}Computed based on CIFAR-10.\\looseness-1\t\t\t\n\t}\n\t\\vspace{-5pt}\n\t\\label{tab:graphs}\n\t\\tiny\n\t\\newcommand{\\width}{0.135\\textwidth}\n\t\\setlength{\\tabcolsep}{0pt}\n\t\\begin{tabular}{p{1.7cm}ccp{0.2cm}ccccc}\n\t\t\\toprule\n\t\t& \\multicolumn{2}{c}{{\\small \\textbf{\\textsc{In-Distribution}}}} & &\n\t\t\\multicolumn{5}{c}{{\\small \\textbf{\\textsc{Out-of-Distribution}}}}\n\t\t\\Bstrut\\Tstrut\\\\\n\t\t\\cline{2-3}\\cline{5-9} \\\\[-2ex]\n\t\t& \\multicolumn{2}{c}{{\\includegraphics[width=\\width,align=c,trim={3cm 3cm 3cm 3cm},clip]{dag_train_5.pdf}}} & & {\\includegraphics[width=\\width,align=c,trim={2.3cm 3cm 2.3cm 3cm},clip]{dag_test_0.pdf}} & \n\t\t{\\includegraphics[width=\\width,align=c,trim={2.3cm 3cm 2.3cm 3cm},clip]{dag_ood_deep36_0.pdf}} & \n\t\t\\includegraphics[width=\\width,align=c,trim={2.3cm 3cm 2.3cm 3cm},clip]{dag_ood_conn_0.pdf} & \n\t\t{\\includegraphics[width=\\width,align=c,trim={2.3cm 3cm 2.3cm 3cm},clip]{dag_ood_nobn_0.pdf}} & \n\t\t{\\includegraphics[width=\\width,align=c,trim={2.3cm 3cm 2.3cm 3cm},clip]{dag_resnet_50.pdf}} \n\t\t\\vspace{0pt}\\Bstrut\\\\\n\t\t& {\\small \\textbf{\\iidtrain}} & {\\small \\textbf{\\iidval/\\iidtest}} & & {\\small \\textbf{\\wide}} & {\\small \\textbf{\\deep}} & {\\small \\textbf{\\dense}} & {\\small \\textbf{\\bnfree}} & \\scriptsize \\textbf{\\textsc{ResNet/ViT}} \\Bstrut\\Tstrut\\\\\n\t\t\\cline{2-3}\\cline{5-9}\n\t\t\\#graphs & $10^6$ & 500/500 & & 100 & 100 & 100 & 100 & 1/1\\Tstrut\\\\\n\t\t\\#cells & 4-18 & 4-18 &  & 4-18 & \\textbf{10-36} & 4-18 & 4-18 & 16/12 \\\\\n\t\t\\#channels & 16-128 & 32-128 & &  \\textbf{128-1216} & 32-208 & 32-240 & 32-336 & 64/128 \\\\\n\t\t\\#nodes ($|V|$) & 21-827 & 33-579 &  & 33-579 & \\textbf{74-1017} & \\textbf{57-993} & 33-503 & 161/114\\\\\n\t\t\\% w/o BN & 3.5\\% & 4.1\\% &  & 4.1\\% & 2.0\\% & 5.0\\% & \\textbf{100\\%} & 0\\%/\\textbf{100\\%} \\\\\n\t\t\\#params(M)* & 0.01-3.1 & 2.5-35 & & \\textbf{39-101} & 2.5-15.3 & 2.5-8.8 & 2.5-7.7 & \\textbf{23.5}/1.0 \\\\\n\t\t\n\t\tavg degree & 2.3\\std{0.1} & 2.3\\std{0.1}  & & 2.3\\std{0.1} & 2.3\\std{0.1} & \\textbf{2.4}\\std{0.1} & \\textbf{2.4}\\std{0.1} & 2.2/2.3\\\\\n\t\t\n\t\tavg path & 14.5\\std{4.8} & 14.5\\std{4.9}  & & 14.7\\std{4.9} & \\textbf{26.2}\\std{9.3} & 15.1\\std{4.1} & 10.0\\std{2.8} & 11.2/10.7\\\\\t\t\t\n\t\\end{tabular}\n\t\\newcommand{\\primwidth}{0.02\\textwidth}\n\t\\newcolumntype{x}{>{\\centering\\arraybackslash\\hspace{0pt}}p{0.7cm}}\n\t\\setlength{\\tabcolsep}{2pt}\n\t\\begin{tabular}{lxxxxxxxxxxxxxxx}\n\t\t\\toprule\n\t\tmarker & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_conv.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_bn.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_sum.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_fc-b.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_sep_conv.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_concat.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_dil_conv.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_ln.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_max_pool.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_avg_pool.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_msa.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_cse.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_input.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_glob_avg.png} & \\includegraphics[width=\\primwidth,align=c,trim={0.2cm 0.2cm 0.2cm 0.2cm},clip]{primitive_pos_enc.png}\\Tstrut\\\\\n\t\t\n\t\tprimitive & conv & BN & sum & bias & group conv & concat & \\tiny dilat. gr. conv & LN & max pool & avg pool & MSA & SE & input & glob avg & pos enc \\\\\n\t\tfraction in \\iidtrain (\\%) & 36.3 & 25.5 & 11.1 & 6.5 & 5.1 & 3.8 & 2.5 & 2.5 & 1.8 & 1.7 & 1.2 & 1.0 & 0.5 & 0.5 & 0.2 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\textbf{In-distribution (\\iid) architectures.} We generate a training set of $|\\nets|=10^{6}$ architectures and validation/test sets of 500/500 architectures that follow the same generation rules and are considered to be \\iid samples. \nHowever, training on large architectures can be prohibitive, e.g.~in terms of GPU memory. Thus, in the training set we allow the number of channels and, hence the total number of parameters, to be stochastically defined given computational resources. For example, to train our models we upper bound the number of parameters in the training architectures to around 3M by sampling fewer channels if necessary. In the evaluation sets, the number of channels is fixed. Therefore, this pre-processing step prior to training results in some distribution shift between the training and the validation/test sets. However, the shift is not imposed by our dataset.\\looseness-1\n\n\\textbf{Out-of-distribution (\\ood) architectures.}\nWe generate five \\ood test sets that follow different generation rules.\nIn particular, we define \\wide and \\deep sets that are of interest due the stronger downstream performance of such nets in large-scale tasks~\\citep{golubeva2020wider,zagoruyko2016wide,brown2020language}. These nets are often more challenging to train for fundamental~\\citep{nguyen2017loss,srivastava2015training} or computational~\\citep{hooker2020hardware} reasons, so predicting their parameters might ease their subsequent optimization.\nWe also define the \\dense set, since networks with many operations per cell and complex connectivity are underexplored in the literature despite their potential~\\citep{huang2017densely}.\nNext, we define the \\bnfree set that is of interest due to BN's potential negative side-effects~\\citep{galloway2019batch,hendrycks2019benchmarking} and the difficulty or unnecessity of using it in some cases~\\citep{wu2018group,qiao2019micro,zhang2019fixup,brock2021characterizing,brock2021high}. \nWe finally add the \\textsc{ResNet/ViT} set with two predefined image classification architectures: commonly-used ResNet-50~\\citep{he2016deep} and a smaller 12-layer version of the Visual Transformer (ViT)~\\citep{dosovitskiy2020image} that has recently received a lot of attention in the vision community.\n%Please see \\S~\\ref{apdx:darts_bg} and \\S~\\ref{apdx:stats} for further details and statistics of our \\dataset dataset.\n\t\n%\\vspace{-5pt}\n\\section{Improved graph hypernetworks: \\ghnours\\label{sec:ghn_model}}\n%\\vspace{-5pt}\n\nIn this section, we introduce our three key improvements to the baseline \\ghnbase~described in \\S~\\ref{sec:bg_ghn} (\\fig{\\ref{fig:ghn_overview}}).\nThese components are essential to predict stronger parameters on our task. For the empirical validation of the effectiveness of these components see ablation studies in \\S~\\ref{sec:our_task}.\\looseness-1\n%and \\S~\\ref{apdx:ablations}.\n\n%\\vspace{-3pt}\n\\subsection{Differentiable normalization of predicted parameters\\label{sec:renorm}}\n%\\vspace{-5pt}\n\n\nWhen training the parameters of a given network from scratch using iterative optimization methods, the initialization of parameters is crucial. A common approach is to use He~\\citep{he2015delving} or Glorot~\\citep{glorot2010understanding} initialization to stabilize the variance of activations across layers of the network.\n\\citet{chang2019principled} showed that when the \\params of the network are instead predicted by a hypernetwork, the activations in the network tend to explode or vanish.\nTo address the issue of unstable network activations especially for the case of predicting \\params of diverse architectures, we apply \\emph{operation-dependent normalizations} (Table~\\ref{tab:norm}).\nWe normalize convolutional and fully-connected weights by following the \\emph{fan-in} scheme of~\\citep{he2015delving}:\n%(see the comparison to \\emph{fan-out} in \\S~\\ref{apdx:ablations})\n$\\hat{\\w}_{p}^{v}\\sqrt{{\\beta}/{(C_{in}\\mathcal{HW})}}$, where $C_{in},\\mathcal{H,W}$ are the number of input channels and spatial dimensions of weights $\\hat{\\w}_{p}^{v}$, respectively; and $\\beta$ is a nonlinearity specific constant following the analysis in~\\citep{he2015delving}.\nThe parameters of normalization layers such as BN and LN, as well as biases typically initialized with constants, are normalized by applying a squashing function with temperature $T$ to imitate the empirical distributions of models trained with SGD (see Table~\\ref{tab:norm}).\t\nThese are differentiable normalizations, so that they are applied at training (and testing) time.\n%Further analysis of our normalization and its stabilizing effect on activations is presented in \\S~\\ref{apdx:renorm}.\\looseness-1\n\n\\begin{table}[htbp]%{r}{6cm}\n\t\\centering\n\t%\\vspace{-5pt}\n\t\\footnotesize\n\t\\caption{\\small Parameter normalizations.}%\\looseness-1}\n\t\\vspace{-5pt}\n\t%\\setlength{\\tabcolsep}{8pt}\n\t\\label{tab:norm}\n\t\\begin{tabular}{l|l}\n\t\t\\toprule\n\t\tType of node $v$ & Normalization\\Tstrut\\Bstrut\\\\\n\t\t\\midrule \n\t\tConvolutional/fully-connected &  \\(\\displaystyle \\hat{\\w}_{p}^{v}\\sqrt{{\\beta}/{(C_{in}\\mathcal{HW})}}  \\)\\Tstrut\\\\\n\t\tNormalization weights & \\(\\displaystyle 2 \\times\n\t\t\\text{sigmoid}(\\hat{\\w}_{p}^{v}/T) \\) \\\\\n\t\tBiases & \\(\\displaystyle \\text{ tanh}(\\hat{\\w}_{p}^{v} / T) \\) \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t%\\vspace{-3pt}\n\\end{table}\n\n%\\vspace{-3pt}\n\\subsection{Enhancing long-range message propagation\\label{sec:sp_edges}}\n%\\vspace{-5pt}\n\nComputational graphs often take the form of long chains (Table~\\ref{tab:graphs}) with only a few incoming/outcoming edges per node. This structure might hinder long-range propagation of information between nodes~\\citep{alon2020bottleneck}.\t\nDifferent approaches to alleviate the long-range propagation problem exist~\\citep{el1996hierarchical,liu2020non,pei2020geom}, including stacking GHNs in~\\citep{zhang2018graph}.\nInstead we adopt simple graph-based heuristics in line with recent works~\\citep{you2019position,yang2021spagan}. In particular, we add \\emph{virtual edges} between two nodes $v$ and $u$ and weight them based on the shortest path $s_{vu}$ between them (\\fig{\\ref{fig:long_range}}). To avoid interference with the \\emph{real} edges in the computational graph, we introduce a separate MLP\\textsubscript{sp} to transform the features of the nodes connected through these virtual edges, and redefine the message passing of \\eqref{eq:ghn_prop} as:\\looseness-1\n%\n%\\setlength{\\belowdisplayskip}{1pt}\n%\\setlength{\\abovedisplayskip}{1pt}\n\\begin{equation}\n\\label{eq:ghn_sp}\n\\mathbf{m}_v^t = \\sum\\nolimits_{u \\in \\neigh_v^{\\pi}} \\text{MLP}(\\mathbf{h}_u^t) + \\sum\\nolimits_{u \\in \\neigh_{v}^{(\\text{sp})}} \\frac{1}{s_{vu}} \\text{MLP}_{\\text{sp}}(\\mathbf{h}_u^t),\n\\end{equation}\n%\n\\noindent where $\\neigh_{v}^{(sp)}$ are neighbors satisfying $1 < s_{vu} \\leq s^{(\\max)}$, and $s^{(\\max)}$ is a hyperparameter.\nTo maintain the same number of trainable parameters as in \\ghnbase, we decrease MLPs' sizes appropriately.\\looseness-1 \n%Despite its simplicity, this approach is effective (see the comparison to stacking GHNs in \\S~\\ref{apdx:ablations}).\n\n\\begin{figure}[htbp]\n\\centering\n%\\vspace{-25pt}\n%\\small\n\\includegraphics[width=0.25\\textwidth,align=c,trim={2.8cm 3cm 2.7cm 3cm}, clip]{dag_resnet_3_sp.png} \n\\vspace{-5pt}\n\\caption{\\small Virtual edges (in green) allow for better capture of global context.}\\label{fig:long_range}\n%\\vspace{-25pt}\n\\end{figure}\n\n%\\vspace{-2pt}\n\\subsection{Meta-batching architectures during training\\label{sec:meta_batch}}\n%\\vspace{-3pt}\n\n\\ghnbase~updates its parameters $\\theta$ based on a single architecture sampled for each batch of images \\eqref{eq:solution}.\nIn vanilla SGD training, larger batches of images often speed up convergence by reducing gradient noise and improve model's performance~\\citep{radiuk2017impact}. Therefore, we define a meta-batch $b_m$ as the number of architectures sampled per batch of images. Both the parameter prediction and the forward/backward passes through the architectures in a meta-batch can be done in parallel. We then average the gradients across $b_m$ to update the parameters $\\theta$ of $H_\\domain$: $\\nabla_\\theta \\loss = 1/{b_m} \\sum_{i=1}^{b_m} \\nabla_\\theta \\loss_i$. \n%Further analysis of the meta-batching effect on the training loss and convergence speed is presented in \\S~\\ref{apdx:meta}.\\looseness-1\t\n\n%\\vspace{-3pt}\n\\section{Experiments\\label{sec:ghn_exper}}\n%\\vspace{-5pt}\n\nWe focus the evaluation of \\ghnours~on our parameter prediction task (\\S~\\ref{sec:our_task}). In addition, we show beneficial side-effects of i) learning a stronger neural architecture representation using \\ghnours in analyzing networks (\\S~\\ref{sec:prop_pred}) and ii) predicting parameters for fine-tuning (\\S~\\ref{sec:finetune}). \n%We provide further experimental and implementation details, as well as more results supporting our arguments in \\S~\\ref{apdx:exper}. \n\n\\textbf{Datasets.} We use the \\dataset dataset of architectures (\\S~\\ref{sec:dataset}) as well as two image classification datasets  $\\domain_1$ (CIFAR-10~\\citep{krizhevsky2009learning}) and $\\domain_2$ (ImageNet~\\citep{russakovsky2015imagenet}). CIFAR-10 consists of 50k training and 10k test images of size 32$\\PLH$32$\\PLH$3 and 10 object categories.\nImageNet is a larger scale dataset with 1.28M training and 50k test images of variable size and 1000 fine-grained object categories. We resize ImageNet images to 224$\\PLH$224$\\PLH$3 following~\\citep{liu2018darts,zhang2018graph}. We use 5k/50k training images as a validation set in CIFAR-10/ImageNet and 500 validation architectures of \\dataset for hyperparameter tuning.\\looseness-1\n\n\\textbf{Baselines.} Our baselines include \\ghnbase and a simple MLP that only has access to operations, but not to the connections between them.\nThis MLP baseline is obtained by replacing the GatedGNN with an MLP in our \\ghnours.\nSince GHNs were originally introduced for small architectures of $\\sim50$ nodes and only trained on CIFAR-10, we reimplement\\footnote{While source code for GHNs~\\citep{zhang2018graph} is unavailable, we appreciate the authors' help in implementing some steps.\\looseness=-1} them and scale them up by introducing minor modifications to their decoder that enable their training on ImageNet and on larger architectures of up to 1000 nodes.\n%(see \\S~\\ref{apdx:ghn_1} for details). \nWe use the same hyperparameters to train the baselines and \\ghnours.\\looseness-1\n\n\\textbf{Iterative optimizers.}\nIn the parameter prediction experiments, we also compare our model to standard optimization methods: SGD and Adam~\\citep{kingma2014adam}.\nWe use off-the-shelf hyperparameters common in the literature~\\citep{zhang2018graph,liu2018darts,chen2019progressive,yang2020cars,he2020milenas,li2020sgas}. On CIFAR-10, we train evaluation architectures with SGD/Adam, initial learning rate $\\eta=0.025$ / $\\eta=0.001$, batch size $b=96$ and up to 50 epochs. With Adam, we train only 300 evaluation architectures as a rough estimation of an average performance.\nOn ImageNet, we train them with SGD, $\\eta=0.1$ and $b=128$,\nand, for computational reasons (given 1402 evaluation architectures in total), we limit training with SGD to 1 epoch.\nWe have also considered meta-optimizers, such as~\\citep{andrychowicz2016learning,ravi2016optimization}. However, we were unable to scale them to diverse and large architectures of our \\dataset, since their LSTM requires a separate hidden state for every trainable parameter in the architecture. The scalable variants exist~\\citep{wichrowska2017learned,metz2020tasks}, but are hard to reproduce without open source code.\\looseness-1\n\n\\textbf{Additional experimental details.}\nWe follow~\\citep{zhang2018graph} and train GHNs with Adam, $\\eta=0.001$ and batch size of 64 images for CIFAR-10 and 256 for ImageNet. We train for up to 300 epochs, except for one experiment in the ablation studies,\nwhere we train one GHN with $b_m = 1$ eight times longer, i.e. for 2400 epochs.\nAll GHNs in our experiments use $T=1$ propagation \\eqref{eq:ghn_prop}, as we found the original $T=5$ of~\\citep{zhang2018graph} to be inefficient and it did not improve the accuracies in our task.\n\\ghnours~uses $s^{(\\max)}=50$ and $b_m=8$ and additionally uses LN that slightly further improves results.\n%(see these ablations in \\S~\\ref{apdx:ablations}). \nModel selection is performed on the validation sets, but the results in our paper are reported on the test sets to enable their direct comparison.\\looseness-1\n\n%\\vspace{-2pt}\n\\subsection{Parameter prediction\\label{sec:our_task}}\n%\\vspace{-2pt}\n\n\n\\textbf{Experimental setup.} We trained our \\ghnours and baselines on the training architectures and training images, i.e.~a separate model is trained for CIFAR-10 and ImageNet. According to our \\dataset benchmark, we assess whether these models can generalize to unseen in-distribution (ID) and out-of-distribution (OOD) test architectures from our \\dataset. We measure this generalization by predicting \\params for the test architectures and computing their classification accuracies on the test images of CIFAR-10 (Table~\\ref{tab:bench_c10}) and ImageNet (Table~\\ref{tab:bench_imagenet}). The evaluation architectures with batch norm (BN) have running statistics, which are not learned by gradient descent~\\citep{ioffe2015batch}, and hence are not predicted by our GHNs. To alleviate that, we follow~\\citep{zhang2018graph} and evaluate the networks with BN by computing per batch statistics with batch size of 64 images.%This is further discussed in \\S~\\ref{apdx:details}.\\looseness-1\n\n\n\\begin{table}[b!]\n\t\\centering\n\t%\\vspace{-10pt}\n\t\\caption{\\small CIFAR-10 results of predicted parameters for unseen ID and OOD architectures of \\dataset. Mean (\\sem{}standard error of the mean) accuracies are reported (random chance $\\approx$10\\%). $^\\dagger$The number of parameter updates.\\looseness-1}\n\t\\label{tab:bench_c10}\n\t\\vspace{-5pt}\n\t\\footnotesize\n\t\\centering\n\t\\setlength{\\tabcolsep}{3.5pt}\n\t\\begin{tabular}{llp{0.1cm}llp{0.5cm}llllc}\n\t\t\\toprule\n\t\t\n\t\t\\textbf{\\textsc{Method}} & \\textbf{\\#upd}$^\\dagger$ & &\n\t\t\\multicolumn{2}{c}{\\textbf{\\textsc{\\iid-test}}} &\n\t\t& \n\t\t\\multicolumn{5}{c}{\\textbf{\\textsc{OOD-test}}} \\\\\n\t\t\n\t\t& & & \\multicolumn{1}{c}{avg} & max & & \\wide & \\deep & \\dense & \\bnfree & \\scriptsize \\textsc{ResNet/ViT} \\\\ \n\t\t\\cline{1-2}\\cline{4-5}\\cline{7-11}\n\t\t\n\t\tMLP & 1 & & 42.2\\sem{0.6} & 60.2 & & 22.3\\sem{0.9} & 37.9\\sem{1.2} & 44.8\\sem{1.1} & 23.9\\sem{0.7} & 17.7/10.0 \\Tstrut \\\\\n\t\t\n\t\t\\ghnbase & 1 & & 51.4\\sem{0.4} & 59.9 &  & 43.1\\sem{1.7} & 48.3\\sem{0.8} & 51.8\\sem{0.9} & 13.7\\sem{0.3} & 19.2/\\textbf{18.2} \\\\\n\t\t\n\t\t\\ghnours & 1 & & \\textbf{66.9}\\sem{0.3} & \\textbf{77.1} & & \\textbf{64.0}\\sem{1.1} & \\textbf{60.5}\\sem{1.2} & \\textbf{65.8}\\sem{0.7} & \\textbf{36.8}\\sem{1.5} & \\textbf{58.6}/11.4 \\\\\n\t\t\n\t\t\\hline\\hline\n\t\t\n\t\t\\multicolumn{10}{l}{\\textbf{Iterative optimizers (all architectures are \\iid in this case)}} \\Tstrut \\\\\n\t\t\n\t\tSGD (1 epoch) & \\scriptsize $0.5 \\PLH 10^3$ & & 46.1\\sem{0.4} & 66.5 & & 47.2\\sem{1.1} & 34.2\\sem{1.1} & 45.3\\sem{0.7} & 18.0\\sem{1.1} & 61.8/34.5 \\\\\n\t\t\n\t\tSGD (5 epochs) & \\scriptsize $2.5\\PLH 10^3$ & & 69.2\\sem{0.4} & 82.4 & & 71.2\\sem{0.3} & 56.7\\sem{1.6} & 67.8\\sem{0.9} & 29.0\\sem{2.0} & 78.2/52.5\\\\\n\n\t\tSGD (50 epochs) & \\scriptsize $25\\PLH 10^3$ & & 88.5\\sem{0.3} & 93.1 & & 88.9\\sem{1.2} & 84.5\\sem{1.2} & 87.3\\sem{0.8} & 45.6\\sem{3.6} & 93.5/75.7 \\\\\n\t\t\n\t\tAdam (50 epochs) & \\scriptsize $25\\PLH 10^3$ & & 84.0\\sem{0.8} & 89.5 & & 82.0\\sem{1.6} & 76.2\\sem{2.6} & 84.8\\sem{0.4} & 38.8\\sem{4.8} & 91.5/79.4 \\\\\n\t\t\n\t\t\\bottomrule\n\t\\end{tabular}\n\t%\\vspace{-5pt}\n\\end{table}\n\n\\begin{table}[b!]\n\t\\centering\n\t%\\vspace{-5pt}\n\t\\caption{\\small ImageNet results on \\dataset.\n\t\tMean (\\sem{}standard error of the mean) top-5 accuracies are reported (random chance $\\approx$0.5\\%).\n\t\t$^*$Estimated on ResNet-50 with batch size 128.\n\t}\n\t\\label{tab:bench_imagenet}\n\t\\vspace{-5pt}\n\t\\footnotesize\n\t\\centering\n\t\\setlength{\\tabcolsep}{1.0pt}\n\t\\begin{tabular}{llccllp{0.1cm}llllc}\n\t\t\\toprule\n\t\t\n\t\t\\textbf{\\textsc{Method}} & \\textbf{\\#upd} & \\scriptsize \\textbf{GPU sec.} & \\scriptsize \\textbf{CPU sec.} & \\multicolumn{2}{c}{\\textbf{\\textsc{\\iid-test}}} &\n\t\t& \n\t\t\\multicolumn{5}{c}{\\textbf{\\textsc{OOD-test}}} \\\\\n\t\t\n\t\t& & \\multicolumn{1}{c}{avg} & \\multicolumn{1}{c}{avg} & \\multicolumn{1}{c}{avg} & max & & \\wide & \\deep & \\dense & \\bnfree & \\scriptsize \\textsc{ResNet/ViT} \\\\\n\t\t\\cline{1-4}\\cline{5-6}\\cline{8-12}\n\t\t\n\t\t\\ghnbase & \\scriptsize 1 & \\scriptsize 0.3 & \\scriptsize 0.5 & 17.2\\sem{0.4} & 32.1 &  & 15.8\\sem{0.9} & 15.9\\sem{0.8} & 15.1\\sem{0.7} & 0.5\\sem{0.0} & \\textbf{6.9}/0.9 \\Tstrut\\\\ \n\t\t\n\t\t\\ghnours & \\scriptsize 1 & \\scriptsize 0.3 & \\scriptsize 0.7 & \\textbf{27.2}\\sem{0.6} & \\textbf{48.3} & & \\textbf{19.4}\\sem{1.4} & \\textbf{24.7}\\sem{1.4} & \\textbf{26.4}\\sem{1.2} & \\textbf{7.2}\\sem{0.6} & 5.3/\\textbf{4.4} \\Bstrut\\\\\n\t\t\n\t\t\\hline\\hline\n\t\t\n\t\t\\multicolumn{10}{l}{\\textbf{Iterative optimizers (all architectures are \\iid in this case)}} \\Tstrut \\\\\n\t\t\n\t\tSGD (1 step) & \\scriptsize 1 & \\scriptsize 0.4 & \\scriptsize 6.0 & 0.5\\sem{0.0} & 0.7 & & 0.5\\sem{0.0} & 0.5\\sem{0.0} & 0.5\\sem{0.0} & 0.5\\sem{0.0} & 0.5/0.5\\\\ \n\t\tSGD (5000 steps) & \\scriptsize $5$k & \\scriptsize $2\\PLH 10^{3}$ & \\scriptsize $3\\PLH 10^{4}$ & 25.6\\sem{0.3} & 50.7 & & 26.2\\std{1.4} & 13.2\\sem{1.1} & 25.4\\sem{1.1} & 4.8\\sem{0.8} & 34.8/24.3 \\\\\n\t\tSGD (10000 steps) & \\scriptsize $10$k & \\scriptsize $4\\PLH 10^{3}$ & \\scriptsize $6\\PLH 10^{4}$ & 37.7\\sem{0.6} & 62.0 & & 38.7\\sem{1.6} & 22.1\\sem{1.4} & 36.3\\sem{1.2} & 8.0\\sem{1.2} & 49.0/33.4 \\\\\n\t\tSGD (100 epochs) & \\scriptsize $1000$k & \\scriptsize $6\\PLH 10^{5*}$ & \\scriptsize $6\\PLH 10^{7*}$ & $-$ &  & & $-$ & $-$ & $-$ & $-$ & 92.9/72.2 \\\\\n\t\t\n\t\t\\bottomrule\n\t\\end{tabular}\n\t%\\vspace{-2pt}\n\\end{table}\n\n\\textbf{Results.}\nDespite \\ghnours never observed the test architectures, \\ghnours predicts good parameters for them making the test networks perform surprisingly well on both image datasets (Tables~\\ref{tab:bench_c10} and~\\ref{tab:bench_imagenet}). Our results are especially strong on CIFAR-10, where some architectures with predicted parameters achieve up to 77.1\\%, while the best accuracy of training with SGD for 50 epochs is around 15\\% more. We even show good results on ImageNet, where for some architectures we achieve a top-5 accuracy of up to 48.3\\%. While these results are low for direct downstream applications, they are remarkable for three main reasons. First, to train GHNs by optimizing \\eqref{eq:solution}, we do not rely on the prohibitively expensive procedure of training the architectures $\\nets$ by SGD. Second, GHNs rely on a single forward pass to predict all parameters. Third, these results are obtained for unseen architectures, including the OOD ones. Even in the case of severe distribution shifts (e.g.~ResNet-50\\footnote{Large architectures with bottleneck layers such as ResNet-50 do not appear during training.}) and underrepresented networks (e.g. ViT\\footnote{Architectures such as ViT do not include BN and, except for the first layer, convolutions -- the two most frequent operations in the training set.}), our model still predicts \\params that perform better than random ones. On CIFAR-10, generalization of \\ghnours is particularly strong with a 58.6\\% accuracy on ResNet-50.\t\n\n\nOn both image datasets, our \\ghnours significantly outperforms \\ghnbase on all test subsets of \\dataset with more than a 20\\% absolute gain in certain cases, e.g.~36.8\\% vs 13.7\\% on the \\bnfree networks (Table~\\ref{tab:bench_c10}). Exploiting the structure of computational graphs is a critical property of GHNs with the accuracy dropping from 66.9\\% to 42.2\\% on \\iid (and even more on \\ood) architectures when we replace the GatedGNN of \\ghnours~with an MLP.\nCompared to iterative optimization methods, \\ghnours predicts parameters achieving an accuracy similar to $\\sim$2500 and $\\sim$5000 iterations of SGD on CIFAR-10 and ImageNet respectively.\nIn contrast, \\ghnbase performs similarly to only $\\sim$500 and $\\sim$2000 (not shown in Table~\\ref{tab:bench_imagenet}) iterations respectively. \nComparing SGD to Adam, the latter performs worse in general except for the ViT architectures similar to~\\citep{zhang2019adam,dosovitskiy2020image}.\\looseness-1\n\n\n\\begin{figure}\n\t\\centering\n\t%\\vspace{10pt}\n\t{\\includegraphics[width=0.7\\textwidth,trim={0.5cm 0.5cm 5.5cm 0.5cm},clip,align=c]{acc_vs_archs_b64.pdf}}\n\t\\vspace{-5pt}\n\t\\caption{\\small \\hspace{5pt}\\ghnours~with meta batch $b_m = 8$ versus $b_m = 1$ for different numbers of training architectures on CIFAR-10.}\n\t\\label{fig:acc_arch}\n\\end{figure}\n\n\\begin{table}%[]\n\\caption{\\small Ablating \\ghnours on CIFAR-10. An average rank of the model is computed across all \\iid and \\ood test architectures.}\n\\label{tab:ablations}\n\\vspace{-3pt}\n\\centering\n\\footnotesize\n\\setlength{\\tabcolsep}{5pt}\n\\begin{tabular}{lcc|c}\n\t\\toprule\n\t\\textbf{\\textsc{Model}} & \\multicolumn{1}{c}{\\textbf{\\textsc{\\iid-test}}} & \\multicolumn{1}{c|}{\\textbf{\\textsc{OOD-test}}} & \\textbf{\\textsc{Avg. rank}}\\Tstrut\\Bstrut\\\\ \n\t\\midrule\n\t\n\t\\ghnours & \\textbf{66.9}\\sem{0.3} & \\textbf{56.8}\\sem{0.8} & \\textbf{1.9}\\Tstrut\\Bstrut\\\\\n\t\\hline \n\t\n\t1000 training architectures & 65.1\\sem{0.5} & 52.5\\sem{1.0} & 2.6\\Tstrut\\\\\n\t\n\tNo normalization (\\S~\\ref{sec:renorm}) & 62.6\\sem{0.6} & 47.1\\sem{1.2} & 3.9\\\\\n\t\n\tNo virtual edges (\\S~\\ref{sec:sp_edges}) & 61.5\\sem{0.4} & 53.9\\sem{0.6} & 4.1\\\\\n\t\n\tNo meta-batch ($b_m=1$, \\S~\\ref{sec:meta_batch}) & 54.3\\sem{0.3} & 47.5\\sem{0.6} & 5.5 \\\\\n\t\n\t$b_m=1$, train 8$\\PLH$ longer & 62.4\\sem{0.5} & 51.9\\sem{1.0} & 3.7\\\\\n\t\n\tNo GatedGNN (MLP) & 42.2\\sem{0.6} & 32.2\\sem{0.7} & 7.4 \\\\\n\t\n\t\\hline\n\t\n\t\\ghnbase & 51.4\\sem{0.4} & 39.2\\sem{0.9} & 6.8\\Tstrut\\\\\n\t\n\t\\bottomrule\n\\end{tabular}\n\\end{table}\n\n\nTo report speeds on ImageNet in Table~\\ref{tab:bench_imagenet}, we use a dedicated machine with a single NVIDIA V100-32GB and Intel Xeon CPU E5-1620 v4@ 3.50GHz. So for SGD these numbers can be reduced by using faster computing infrastructure and more optimal hyperparameters~\\citep{goyal2017accurate}.\nUsing our setup, SGD requires on average $10^4 \\PLH$ more time on a GPU ($10^5 \\PLH$ on a CPU) to obtain \\params that yield performance similar to \\ghnours.\nAs a concrete example, AlexNet~\\citep{krizhevsky2012imagenet} requires around 50 GPU hours (on our setup) to achieve a 81.8\\% top-5 accuracy, while on some architectures we achieve $\\geq$48.0\\% in just 0.3 GPU seconds.\\looseness-1\n\n\n\nAblations (Table~\\ref{tab:ablations}) show that all three components proposed in \\S~\\ref{sec:ghn_model} are important. Normalization is particularly important for OOD generalization with the largest drops on the \\wide and \\bnfree networks. %(see \\S~\\ref{apdx:ablations}). \nUsing meta-batching ($b_m = 8$) is also essential and helps stabilize training and accelerate convergence. %(see \\S~\\ref{apdx:ghn_2}).\nWe also confirm that the performance gap between $b_m = 1$ and $b_m = 8$ is not primarily due to the observation of more architectures, since the ablated \\ghnours with $b_m = 1$ trained eight times longer is still inferior.\nThe gap between $b_m = 8$ and $b_m = 1$ becomes pronounced with \\emph{at least} 1k training architectures (\\fig{\\ref{fig:acc_arch}}).\nWhen training with fewer architectures (e.g.~100), the GHN with meta-batching starts to overfit to the training architectures.\nGiven our challenging setup with unseen evaluation architectures, it is surprising that using 1k training architectures already gives strong results. However, OOD generalization degrades in this case compared to using all 1M architectures, especially on the \\bnfree networks. %(see \\S~\\ref{apdx:ghn_2}).\nWhen training GHNs on just a few architectures, the training accuracy soars to the level of training them with SGD. With more architectures, it generally decreases indicating classic overfitting and underfitting cases.\\looseness-1\n\n\n%\\vspace{-2pt}\n\\subsection{Property prediction\\label{sec:prop_pred}}\n%\\vspace{-3pt}\n\nRepresenting computational graphs of neural architectures is a challenging problem~\\citep{li2020neural,wen2019neural,jin2019auto,kriege2020survey,makarov2021survey}.\nWe verify if GHNs are capable of doing that out-of-the-box in the property prediction experiments. %We also experiment with architecture comparison in \\S~\\ref{apdx:graph_compare}. \nOur hypothesis is that by better solving our parameter prediction task, GHNs should also better solve graph representation tasks.\n\n\\textbf{Experimental setup.}\nWe predict the properties of architectures given their graph embeddings obtained by averaging node features\\footnote{A fixed size graph embedding for the architecture $\\f$ can be computed by averaging the output node features: $\\mathbf{h}_{a}=\\frac{1}{|V|} \\sum_{v \\in V} \\mathbf{h}_v^T$, where $\\mathbf{h}_a \\in \\mathbb{R}^d$ and $d$ is the dimensionality of node features.\n}.\nWe consider four such properties: %(see \\S~\\ref{apdx:prop} for details):\n%\\vspace{-5pt}\n\\begin{itemize}%[leftmargin=5mm]\n\t\\setlength\\itemsep{0em}\n\t\\item Accuracy on the ``clean'' (original) validation set of images;\n\t\\item Accuracy on a corrupted set (obtained by adding the Gaussian noise to images following~\\citep{hendrycks2019benchmarking});\n\t\\item Inference speed (latency or GPU seconds per a batch of images);\\looseness-1\n\t\\item Convergence speed (the number of SGD iterations to achieve a certain training accuracy).\\looseness-1\n\\end{itemize}\n\\vspace{-3pt}\n\nEstimating these properties accurately can have direct practical benefits. Clean and corrupted accuracies can be used to search for the best performing architectures (e.g. for the NAS task); inference speed can be used to choose the fastest network, so by estimating these properties we can trade-off accurate, robust and fast networks~\\citep{cai2019onceforall}. Convergence speed can be used to find networks that are easier to optimize.\nThese properties correlate poorly with each other and between CIFAR-10 and ImageNet, \n%(\\S~\\ref{apdx:prop}), \nso they require the model to capture different regularities of graphs. \nWhile specialized methods to estimate some of these properties exist, often as a NAS task~\\citep{wen2020neural,lukasik2020neural,baker2017accelerating,liu2018progressive,li2020neural}, our GHNs provide a generic representation that can be easily used for many such properties.\nFor each property, we train a simple regression model using graph embeddings and ground truth property values. We use 500 validation architectures of \\dataset for training the regression model and tuning its hyperparameters.\n%(see \\S~\\ref{apdx:prop} for details).\nWe then use 500 testing architectures of \\dataset to measure Kendall's Tau rank correlation between the predicted and ground truth property values similar to~\\citep{wen2020neural}.\\looseness-1\n\n\\textbf{Additional baseline.} \nWe compare to the Neural Predictor (NeuPred)~\\citep{wen2020neural}. NeuPred is based on directed graph convolution and is developed for accuracy prediction achieving strong NAS results. We train a separate such NeuPred for each property from scratch following their hyperparameters. \n\n\n\\begin{figure}%{r}{7cm}\n\t%\\vspace{-15pt}\n\t\\begin{center}\n\t\t{\\includegraphics[align=c,width=0.8\\textwidth]{property_prediction_hist.pdf}}\n\t\\end{center}\t\t\n\t\\vspace{-15pt}\n\t\\caption{\\small Property prediction of neural networks in terms of correlation (higher is better). Error bars denote the standard deviation across 5 runs.}\\label{fig:properties}\n\t%\\vspace{-5pt}\n\\end{figure}\n\n\\textbf{Results.}\n\\ghnours consistently outperforms the \\ghnbase and MLP baselines as well as NeuPred (\\fig{\\ref{fig:properties}}). We also verify if higher correlations translate to downstream gains. For example, on CIFAR-10 by choosing the most accurate architecture according to the regression model and training it from scratch following~\\citep{liu2018darts,zhang2018graph}, we obtained a 97.26\\%(\\std{0.09}) accuracy, which is competitive with leading NAS approaches, e.g.~\\citep{liu2018darts,zhang2018graph,chen2019progressive,yang2020cars,he2020milenas,li2020sgas}. In contrast, the network chosen by the regression model trained on the \\ghnbase~embeddings achieves 95.90\\%(\\std{0.08}).\\looseness-1\n\n\n\n%\\vspace{-3pt}\n\n%\\vspace{-2pt}\n\\subsection{Fine-tuning predicted parameters\\label{sec:finetune}}\n%\\vspace{-2pt}\n\nNeural networks trained on ImageNet and other large datasets have proven useful in diverse visual tasks in the transfer learning setup~\\citep{kornblith2019better,huh2016makes,neyshabur2020being,raghu2019transfusion,zhai2019large,dosovitskiy2020image}. \nTherefore, we explore how predicting parameters on ImageNet with GHNs compares to pretraining them on ImageNet with SGD in such a setup. \nWe consider low-data tasks as they often benefit more from transfer learning~\\citep{raghu2019transfusion,zhai2019large}.\n\n\\textbf{Experimental setup.}\nWe perform two transfer-learning experiments. The first experiment is fine-tuning the predicted parameters on 1,000 training samples (100 labels per class) of CIFAR-10. \nWe fine-tune ResNet-50, Visual Transformer (ViT) and a 14-cell architecture based on the DARTS best cell~\\citep{liu2018darts}. The hyperparameters of fine-tuning (initial learning rate and weight decay) are tuned on 200 validation samples held-out of the 1,000 training samples. The number of epochs is fixed to 50 as in \\S~\\ref{sec:our_task} for simplicity.\nIn the second experiment, we fine-tune the predicted parameters on the object detection task. We closely follow the experimental protocol and hyperparameters from~\\citep{pytorchdetection} and train the networks on the Penn-Fudan dataset~\\citep{wang2007object}. The dataset contains only 170 images and the task is to detect pedestrians. Therefore this task is also well suited for transfer learning. Following \\citep{pytorchdetection}, we replace the backbone of a Faster R-CNN with one of the three architectures.\nTo perform transfer learning with GHNs, in both experiments we predict the parameters of a given architecture using GHNs trained on ImageNet. \nWe then replace the ImageNet classification layer with the target task-specific layers and fine-tune the entire network on the target task.\nWe compare the results of GHNs to He's initialization~\\citep{he2015delving} and the initialization based on pretraining the parameters on ImageNet with SGD.\\looseness-1\n\n\n\\begin{table}[htbp]\n\t%\\vspace{-5pt}\n\t\\centering\n\t\\tiny\n\t\\caption{\\small CIFAR-10 test set accuracies and Penn-Fudan object detection average precision (at IoU=0.50) after fine-tuning the networks using SGD initialized with different methods. Average results and standard deviations for 3 runs with different random seeds are shown. For each architecture, similar GHN-2-based and ImageNet-based results are bolded.\\textsuperscript{*}Estimated on ResNet-50.}\n\t\\label{tab:finetune}\n\t\\vspace{-3pt}\n\t\\setlength{\\tabcolsep}{4pt}\n\t\\begin{tabular}{lcccc|ccc}\n\t\t\\toprule\n\t\t\n\t\t\\multirow{2}{*}{\\textbf{\\textsc{\\parbox{2cm}{Initialization Method}}}} & \\multirow{2}{*}{\\textbf{{\\parbox{0.9cm}{GPU sec. to init.\\textsuperscript{*}}}}} & \\multicolumn{3}{c|}{\\textbf{\\textsc{100-Shot Cifar-10}}} &\n\t\t\\multicolumn{3}{c}{\\textbf{\\textsc{Penn-Fudan Object Detection}}}\\Tstrut\\Bstrut\\\\\n\t\t\n\t\t\\cline{3-5}\\cline{6-8}\n\t\t\n\t\t& & {\\textsc{ResNet-50}} & {\\textsc{ViT}} & {\\textsc{Darts}} & {\\textsc{ResNet-50}} & {\\textsc{ViT}} & {\\textsc{Darts}}\\Tstrut\\Bstrut\\\\\n\t\t\n\t\t\\midrule\n\t\t\n\t\tHe's \\citep{he2015delving} & 0.003 & 41.0\\sem{0.4} & 33.2\\sem{0.3} &\t45.4\\sem{0.4} & 0.197\\sem{0.042} & 0.144\\sem{0.010} &\t0.486\\sem{0.035}\\Tstrut\\\\\n\t\t\n\t\tGHN-1 (trained on ImageNet) & 0.6 &\t46.6\\sem{0.0} &\t23.3\\sem{0.1} & 49.2\\sem{0.1} & 0.433\\sem{0.013} &\t0.0\\sem{0.0} & 0.468\\sem{0.024} \\\\\n\t\t\n\t\tGHN-2 (trained on ImageNet) & 0.7 & \\textbf{56.4}\\sem{0.1} & \\textbf{41.4}\\sem{0.6} & \\textbf{60.7}\\sem{0.3} & \\textbf{0.560}\\sem{0.019} & \\textbf{0.436}\\sem{0.032} &\t\\textbf{0.785}\\sem{0.032} \\\\\n\t\t\n\t\t\\midrule\n\t\t\n\t\tImageNet (1k pretraining steps) & $6\\PLH 10^{2}$ & 45.4\\sem{0.3} &\t\\textbf{44.3}\\sem{0.1} & \\textbf{62.4}\\sem{0.3} & 0.302\\sem{0.022} & 0.182\\sem{0.046} &\t\\textbf{0.814}\\sem{0.033}\\Tstrut\\\\\n\t\t\n\t\tImageNet (2.5k pretraining steps) & $1.5\\PLH 10^{3}$ &\t\\textbf{55.4}\\sem{0.2} &\t50.4\\sem{0.3} &\t70.4\\sem{0.2} & \\textbf{0.571}\\sem{0.056} &\t0.322\\sem{0.073} &\t0.823\\sem{0.022}\\\\\n\t\t\n\t\tImageNet (5 pretraining epochs) & $3\\PLH 10^{4}$ & 84.6\\sem{0.2} & 70.2\\sem{0.5} &\t83.9\\sem{0.1} & 0.723\\sem{0.045} &\t{0.391}\\sem{0.024} &\t0.827\\sem{0.053} \\\\\n\t\t\n\t\tImageNet (final epoch) & $6\\PLH 10^{5}$ &\t89.2\\sem{0.2} &\t74.5\\sem{0.2} &\t85.6\\sem{0.2} & 0.876\\sem{0.011} &\t\\textbf{0.468}\\sem{0.023} &\t0.881\\sem{0.023}\\\\\n\t\t\n\t\t\\bottomrule\n\t\\end{tabular}\n\t%\\vspace{-5pt}\n\\end{table}\n\n\\textbf{Results.} The CIFAR-10 image classification results of fine-tuning the parameters predicted by our GHN-2 are $\\geq$10 percentage points better (in absolute terms) than fine-tuning the parameters predicted by GHN-1 or training the parameters initialized using He's method (Table~\\ref{tab:finetune}).\nSimilarly, the object detection results of GHN-2-based initialization are consistently better than both GHN-1 and He's initializations. The GHN-2 results are a factor of 1.5-3 improvement over He's for all the three architectures. Overall, the two experiments clearly demonstrate the practical value of predicting parameters using our GHN-2.\nUsing GHN-1 for initialization provides relatively small gains or hurts convergence (for ViT).\nCompared to pretraining on ImageNet with SGD, initialization using GHN-2 leads to performance similar to 1k-2.5k steps of pretraining on ImageNet depending on the architecture in the case of CIFAR-10. In the case of Penn-Fudan, GHN-2's performance is similar to $\\geq$1k steps of pretraining with SGD. In both experiments, pretraining on ImageNet for just 5 epochs provides strong transfer learning performance and the final ImageNet checkpoints are only slightly better, which aligns with previous works~\\citep{neyshabur2020being}. \nTherefore, further improvements in the parameter prediction models appear promising.\\looseness-1\n\n\n%\\vspace{-10pt}\n\\section{Related work\\label{sec:ghn_related}}\n%\\vspace{-10pt}\n\nOur proposed parameter prediction task,  objective in \\eqref{eq:solution}  and improved GHN are related to a wide range of machine learning frameworks, in particular meta-learning and neural architecture search (NAS). Meta-learning is a general framework~\\citep{hospedales2020meta,schmidhubermetalearning} that includes meta-optimizers and meta-models, among others. Related NAS works include differentiable~\\citep{liu2018darts} and one-shot methods~\\citep{cai2019onceforall}. \n%See additional related work in \\S~\\ref{apdx:related_work}.\\looseness-1\n\n\\textbf{Meta-optimizers.} Meta-optimizers~\\citep{andrychowicz2016learning,ravi2016optimization,metz2020tasks,kirsch2020meta,gomes2021meta} define a problem similar to our task, but where $H_\\domain$ is an RNN-based model predicting the gradients $\\nabla \\w$, mimicking the behavior of iterative optimizers. Therefore, the objective of meta-optimizers may be phrased as \\emph{learning to optimize} as opposed to our \\emph{learning to predict} \\params.\nSuch meta-optimizers can have their own hyperparameters that need to be tuned for a given architecture $\\f$ and need to be run expensively (on the GPU) for many iterations following \\eqref{eq:optim1b}.\\looseness-1\n\n\n\\textbf{Meta-models.} Meta-models include methods based on MAML~\\citep{finn2017model}, ProtoNets~\\citep{snell2017prototypical} and auxiliary nets predicting task-specific parameters~\\citep{romero2016diet,requeima2019fast,li2019lgm,bertinetto2016learning}. These methods are tied to a particular architecture and need to be trained from scratch if it is changed.\nSeveral recent methods attempt to relax the choice of architecture in meta-learning. T-NAS~\\citep{lian2020towards} combines MAML with DARTS~\\citep{liu2018darts} to learn both the optimal architecture and its parameters for a given task. However, the best network, $\\f$, needs to be trained using MAML from scratch. Meta-NAS~\\citep{elsken2020meta} takes a step further and only requires fine-tuning of $\\f$ on a given task. However, the $\\f$ is obtained from a single meta-architecture and so its choice is limited, preventing parameter prediction for arbitrary $\\f$. CATCH~\\citep{chen2020catch} follows a similar idea, but uses reinforcement learning to quickly search for the best $\\f$ on the specific task.\nOverall meta-learning mainly aims at generalization \\textit{across tasks}, often motivated by the few-shot learning problem. In contrast, our parameter prediction problem assumes a single task (here an image dataset), but aims at generalization \\textit{across architectures} $\\f$ with the ability to predict parameters in a single forward pass.\\looseness-1\n\n\n\\textbf{One-shot NAS.} One-shot NAS aims to learn a single ``supernet''~\\citep{yu2020bignas,cai2019onceforall,he2021automl} that can be used to estimate the performance of smaller nets (subnets) obtained by some kind of pruning the supernet, followed by training the best chosen $\\f$ from scratch with SGD.\nRecent models, in particular BigNAS~\\citep{cai2019onceforall} and OnceForAll (OFA)~\\citep{yu2020bignas}, eliminate the need to train subnets. However, the fundamental limitation of one-shot NAS is poor scaling with the number of possible computational operations~\\citep{zhang2018graph}. This limits the diversity of architectures for which \\params can be obtained. For example, all subnets in OFA are based on MobileNet-v3~\\citep{howard2019searching}, which does not allow to solve our more general parameter prediction task.\nTo mitigate this, SMASH~\\citep{brock2017smash} proposed to predict some of the \\params using hypernetworks~\\citep{ha2016hypernetworks} by encoding architectures as a 3D tensor.\nGraph HyperNetworks (GHNs)~\\citep{zhang2018graph} further generalized this approach to ``arbitrary'' computational graphs (DAGs), which allowed them to improve NAS results.\nGHNs focused on obtaining reliable subnetwork rankings for NAS and did not aim to predict large-scale performant parameters.\nWe show that the vanilla GHNs perform poorly on\nour parameter prediction task mainly due to the inappropriate scale of predicted parameters, lack of long-range interactions in the graphs, gradient noise and slow convergence when optimizing \\eqref{eq:solution}.\nConventionally to NAS, GHNs were also trained in a quite constrained architecture space~\\citep{bender2018understanding}. We expand the architecture space adopting GHNs for a more general problem.\\looseness-1\n\nOur work is also loosely related to other parameter prediction methods~\\citep{Denil2013-la,bertinetto2016learning,ratzlaff2019hypergan}, analysis of graph structure of neural networks~\\citep{you2020graph}, knowledge distillation from multiple teachers~\\citep{liu2019knowledge}, compression methods~\\citep{cheng2017survey} and optimization-based initialization~\\citep{dauphin2019metainit,zhu2021gradinit,das2021data}. \\citet{Denil2013-la} train a model that can predict a fraction of network parameters given other parameters requiring to retrain the model for each new architecture.\n\\citet{bertinetto2016learning} train a model that predicts parameters given a new few-shot task similarly to~\\citep{ravi2016optimization,requeima2019fast}, and the model is also tied to a particular architecture.\nThe HyperGAN~\\citep{ratzlaff2019hypergan} allows to generate an ensemble of trained parameters in a computationally efficient way, but as the aforementioned works is constrained to a particular architecture.\nFinally, MetaInit~\\citep{dauphin2019metainit}, GradInit~\\citep{zhu2021gradinit} and Sylvester-based initialization~\\citep{das2021data} can initialize arbitrary networks by carefully optimizing their initial parameters, but due to the optimization loop they are generally more computationally expensive compared to predicting parameters using GHNs.\nOverall, these prior works did not formulate the task nor proposed the methods of predicting performant \\params for diverse and large-scale architectures as ours.\\looseness-1\n\nFinally, the construction of our \\dataset is related to the works on network design spaces. Generating arbitrary architectures using a graph generative model, e.g.~\\citep{yu2019dag,guo2020systematic,you2020graph}, can be one way to create the training dataset $\\nets$. Instead, we leverage and extend an existing DARTS framework~\\citep{liu2018darts} specializing on neural architectures to generate $\\nets$. \nMore recent works~\\citep{radosavovic2020designing} or other domains~\\citep{you2020design} can be considered in future work.\n\n\n%\\vspace{-5pt}\n\\section{Conclusion}\n%\\vspace{-10pt}\nWe propose a novel framework and benchmark to learn and evaluate neural parameter prediction models. Our model (\\ghnours) is able to predict \\params for very diverse and large-scale architectures in a single forward pass in a fraction of a second. The networks with predicted \\params yield surprisingly high image classification accuracy given the extremely challenging nature of our parameter prediction task. However, the accuracy is still far from networks trained with handcrafted optimization methods. Bridging the gap is a promising future direction. As a beneficial side-effect, \\ghnours learns a strong representation of neural architectures as evidenced by our property prediction evaluation. Finally, parameters predicted using \\ghnours trained on ImageNet benefit transfer learning in the low-data regime. This motivates further research towards solving our task.\\looseness-1\n", "meta": {"hexsha": "093a8551df2886d3abfb683df5ae78f70409b558", "size": 66224, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch6_2021_neurips/main.tex", "max_stars_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_stars_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ch6_2021_neurips/main.tex", "max_issues_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_issues_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch6_2021_neurips/main.tex", "max_forks_repo_name": "uoguelph-mlrg/phdthesis_boris", "max_forks_repo_head_hexsha": "bf8f9e040e664356af31a2d2e4f9122bb33d0196", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.1282051282, "max_line_length": 1551, "alphanum_fraction": 0.7626540227, "num_tokens": 19923, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.40758758239341314}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n\n\\title{Math 217 -- Geometry and Physics -- Lec01}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{03}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{Introduction}\n\n\n\\subsection{Books for reference}\n\n\\begin{enumerate}\n\\item T. Frankel -- The Geometry of Physics\n\\item Bott, Tu -- Differential Forms in Algebraic Topology\n\\item Lawson, Michelson -- Spin Geometry\n\\item J. Roe -- Elliptic Operators, Topology, and Asymptotic Methods\n\\item Berline, Getzler, Vergne -- Heat Kernel \\& Dirac operators\n\\end{enumerate}\n\n\n\\subsection{History}\n\n\\begin{equation}\n\\begin{matrix}\n\\int_M & \\text{geometry} & \\neq & \\text{Topological} \\\\\n& \\varepsilon(TM) & \\qquad & \\chi(M) \\notag\n\\end{matrix}\n\\end{equation}\n\n\\begin{enumerate}\n\\item Chern, 1946: Gauss-Bonnet theorem.\n\\item Hodge Theory (Analysis of elliptic PDEs)\n\\item Hirzebruch, 1950: Riemann-Roch Signature (Algebraic geometry, topology)\n\\item Grothendieck (GRR), 1958-59: K-theory\n\\item Atiyah-Hirzebruch: topological K-theory, topological Riemann-Roch\n\\item Atiyah-Singer: index formula, Dirac operator ($\\hat{A}(M) = \\operatorname{Ind} D$)\n\\item Mckean-Singer formula: heat-Kernel of elliptic operators\n\\item Atiyah-Boti-Patodi, 1978\n\\item Witten, Alveraz, Gaume, 1980: Heat kernel proof (Getzler), QFT (adiabatic limit)\n\\item Applications\n\\end{enumerate}\n\n\n\\section{Manifolds}\n\n\\subsection{Basics}\n\nDenote the \\textbf{manifold} $M = \\cup_{i \\in I} U_i$ with \\textbf{coordinate maps} $\\varphi_i: U_i \\rightarrow \\R^n$ which are homeomorphisms / coordinate covers. Recall that a manifold is a topological space (Hausdorff) and locally Euclidean. \n\\begin{equation}\n\\text{(insert canonical diagram of coordinate maps)}%. see e.g. https://commons.wikimedia.org/wiki/File:Two\\_coordinate\\_charts\\_on\\_a\\_manifold.svg)}\n\\end{equation}\nIf all the $\\varphi_j \\circ \\varphi_i^{-1} \\in C^\\infty$, then it is a \\textbf{smooth manifold}. \n\n\n\\subsection{Examples}\n\n\\begin{example}\nThe circle $M = S^1 = \\set{ (x,y)\\in \\R^2 : x^2 + y^2 = 1 }$\n\\begin{equation}\n\\text{(insert diagram of $S^1$ with four charts)}\n\\end{equation}\nwith charts\n\\begin{align}\nU_1 &= \\set{ x>0 } \\overset{\\varphi_1}{\\longrightarrow} \\R^1, \\qquad \\varphi_1(p) = y, \\\\\nU_2 &= \\set{ y>0 } \\overset{\\varphi_2}{\\longrightarrow} \\R^1, \\qquad \\varphi_2(p) = x, \\\\\nU_3 &= \\set{ x<0 } \\overset{\\varphi_3}{\\longrightarrow} \\R^1, \\qquad \\varphi_3(p) = y, \\\\\nU_4 &= \\set{ y<0 } \\overset{\\varphi_4}{\\longrightarrow} \\R^1, \\qquad \\varphi_4(p) = x.\n\\end{align}\nOn $U_1 \\cap U_2$, we have the coordinate change $y = \\sqrt{1-x^2}$, $x = \\sqrt{1-y^2}$.\n\\end{example}\n\n\\begin{example}\nThe 2-sphere $S^2 = \\set{ (x,y,z) \\in \\R^3 : x^2 + y^2 + z^2 = 1 }$\n\\begin{equation}\n\\text{(insert diagram of $S^2$)}\n\\end{equation}\nwith charts\n\\begin{align}\nU_+ &= \\set{ z \\neq -1 } \\overset{\\varphi_+}{\\longrightarrow} \\R^2 \\\\\nU_- &= \\set{ z \\neq 1 } \\overset{\\varphi_-}{\\longrightarrow} \\R^2\n\\end{align}\n\\begin{align}\n\\varphi_+(x,y,z) &= (\\frac{x}{1+z}, \\frac{y}{1+z}) \\\\\n\\varphi_-(x,y,z) &= (\\frac{x}{1-z}, \\frac{y}{1-z}).\n\\end{align}\nThe inverse of the coordinate maps can be written\n\\begin{align}\n\\varphi_+^{-1} : \\R^2 &\\longrightarrow U_+ \\\\\n\t(x_1, x_2) &\\mapsto (\\frac{2x_1}{1+\\rho^2}, \\frac{2x_2}{1+\\rho^2}, \\frac{1-\\rho^2}{1+\\rho^2}) \n\\end{align}\n\\begin{align}\n\\varphi_-^{-1} : \\R^2 &\\longrightarrow U_- \\\\\n\t(x_1, x_2) &\\mapsto (\\frac{2x_1}{1+\\rho^2}, \\frac{2x_2}{1+\\rho^2}, \\frac{\\rho^2-1}{1+\\rho^2}) \n\\end{align}\nwhere $\\rho^2 = x^2 + y^2$. Then\n\\begin{align}\n\\varphi_- \\circ \\varphi_+^{-1} : \\varphi_+(U_+ \\cap U_-) &\\rightarrow \\varphi_-(U_+ \\cap U_p) \\\\\n\t(x_1, x_2) &\\mapsto (x_1 / \\rho, x_2 / \\rho)\n\\end{align}\n\\end{example}\n\n\\begin{example}\nThe real projective space $\\RP^n = (\\R^{n+1} - \\set{ 0 }) / \\R^* = S^n / \\Z_2$, i.e. $(x_0, \\dots, x_n) \\sim (\\lambda x_0, \\dots, \\lambda x_n)$, $\\lambda \\in \\R^*$\n\\end{example}\n\n\\begin{example}\nThe complex projective space $\\CP^n = (\\C^{n+1} - \\set{ 0 }) / \\C^* = S^{2n+1} / S^1$, i.e. $z_0, \\dots, z_n) \\sim (\\lambda z_0, \\dots, \\lambda z_n)$, $\\lambda \\in \\C^*$, say with charts: $U_i = \\set{ z_i \\neq 0 }$,\n\\begin{align}\n\\varphi_i : U_i &\\longrightarrow \\C^n \\\\\n\t(z_0, \\dots, z_n) &\\mapsto (z_0/z_i, \\dots, z_n/z_i)\n\\end{align}\nFor example, $\\CP^1 \\cong S^2$.\n\\end{example}\n\n%(more stuff on $\\CP^n$ missing here? (got more from Yeou))\n\n\n\\subsection{More on manifolds}\n\nDenote a \\textbf{tangent bundle} $TM = \\cup_{x \\in M} T_x M$ with \\textbf{canonical map} $\\pi: TM \\rightarrow M$. $TM$ has a manifold structure.\n\n$f: M \\rightarrow N$ is a \\textbf{smooth map} if $f \\circ \\varphi_i^{-1}$ is smooth for all $i$. If $f$ is smooth, then define the differential or pushforward $df = f_* : TM \\rightarrow TN$ such that for all $x \\in M$, \n\\begin{equation}\n\\begin{matrix}\nf_*(x) & : & T_x M & \\longrightarrow & T_{f(x)}M \\\\\n&&\tv & \\mapsto & f_*(v) = \\frac{d}{dt} f(\\alpha(t)) \\Big|_{t=0}\n\\end{matrix}\n\\end{equation}\nwhere $\\alpha : (-\\epsilon, \\epsilon) \\rightarrow M$, $\\alpha(0) = x$, and $\\alpha'(0) = v$. \n\nWe define a \\textbf{smooth section} as a map $X : M \\rightarrow TM$ such that $\\pi \\circ X = \\operatorname{id}_M$. For example, a vector field on $M$ is a standard example of a smooth section. \n\n%(missed board on lie brackets here (got more from Yeou))\n\nUsing coordinates on chart $U$, $X = \\sum_{i=1}^n a_i \\pd{}{x_i}$ for all $f \\in C^\\infty(M)$ such that $f : M \\rightarrow \\R$. Then $\\mathcal{L}_X f = X(f) = f_*(X)$.\n\nWe define the \\textbf{Lie bracket} $[X,Y]f = X(Yf) - Y(Xf)$. Note Antisymmetric, Jacobi [???]\n\n\nGiven a vector field $X$, let $\\varphi : (a_x, b_x) \\rightarrow M$ be a curve s.t. $\\varphi(0) = x$, $\\pd{\\varphi}{t} = X \\circ \\varphi$ on $(a_x, b_x)$ maximal interval\n\nIf $(a_x, b_x) = (-\\infty, \\infty) = \\R$, $\\varphi$ or $X$ is complete\n\n%(more on a board here on vector field? (got more from Yeou))\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "d3a790d6021f24229d5778ac9887cb50237c7579", "size": 6115, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geometry/lec01.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "geometry/lec01.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geometry/lec01.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2865853659, "max_line_length": 245, "alphanum_fraction": 0.6569092396, "num_tokens": 2294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.40758757570288345}}
{"text": "% This is samplepaper.tex, a sample chapter demonstrating the\n% LLNCS macro package for Springer Computer Science proceedings;\n% Version 2.20 of 2017/10/04\n%\n\\documentclass[runningheads]{llncs}\n%\n\\usepackage[top=5cm, bottom=5.6cm, left=4.5cm, right=4.2cm]{geometry}\n\\usepackage{graphicx}\n\\usepackage{array}\n\\newcolumntype{P}[1]{>{\\centering\\arraybackslash}p{#1}}\n% Used for displaying a sample figure. If possible, figure files should\n% be included in EPS format.\n%\n% If you use the hyperref package, please uncomment the following line\n% to display URLs in blue roman font according to Springer's eBook style:\n% \\renewcommand\\UrlFont{\\color{blue}\\rmfamily}\n\n\\makeatletter\n\\renewcommand\\paragraph{\\@startsection{paragraph}{4}{\\z@}%\n                                    {3.25ex \\@plus1ex \\@minus.2ex}%\n                                    {-1em}%\n                                    {\\normalfont\\normalsize\\bfseries}}\n\\makeatother\n% my packages and commands\n\\graphicspath{{figs/}}\n%% The amsthm package provides extended theorem environments\n%\\usepackage{amsthm}\n%\\usepackage[numbers,sort&compress]{natbib}\n\\usepackage{booktabs} % for nice tables\n\\usepackage{xcolor}\n\\usepackage{subcaption} % for subfigures\n\\usepackage[colorlinks=true,citecolor=blue]{hyperref}\n\\newcommand{\\ud}{\\mathrm{d}}\n\\renewcommand{\\vec}[1]{\\mathbf{#1}}\n\\newcommand{\\veca}[2]{\\mathbf{#1}{#2}}\n\\newcommand{\\bm}[1]{\\mathbf{#1}}\n\\newcommand{\\etal}{et al.}\n\\begin{document}\n%\n\\title{Vectorization of the code for guided wave propagation problems}\n%\n\\titlerunning{Vectorization of the code for GW propagation problems}\n% If the paper title is too long for the running head, you can set\n% an abbreviated paper title here\n%\n\\author{Pawel Kudela\\inst{}\\orcidID{0000-0002-5130-6443}  \\and \nPiotr Fiborek\\inst{}\\orcidID{[0000-0002-5030-3312} \n}\n%\n\\authorrunning{P. Kudela and P. Fiborek}\n% First names are abbreviated in the running head.\n% If there are more than two authors, 'et al.' is used.\n%\n\\institute{Institute of Fluid-Flow Machinery, Polish Academy of Sciences, 80-231 Gdansk, Poland\n\\email{pk@imp.gda.pl}}\n\n%\n\\maketitle              % typeset the header of the contribution\n%\n%\\begin{abstract}\n\\paragraph{Abstract.}\nVectorization of the code for simulation of guided wave propagation problems based on the spectral element method is presented. \nIn the code, flat shell spectral elements are utilized for spatial domain representation.\nThe implementation is realised by using Matlab Parallel Computing Toolbox and optimized for Graphics Processing Unit (GPU) computation. \nIn this way, considerable computation speed-up can be achieved in comparison to computation on conventional processors. \nThe implementation includes an interpolation of wave-field on a uniform grid. \nThe method was tested on experimental full wave-field data measured by scanning laser Doppler vibrometer. \nGood agreement between numerical and experimental results was achieved. \nDue to relatively short computation time, large data sets can be generated by using the proposed implementation. \nThe large data sets are especially useful for deep neural network training or other soft computing methods opening up new possibilities in health monitoring of metallic and composite structures.\n\n\\keywords{Spectral Element Method \\and Guided Waves \\and Code Vectorization \\and GPU computation.}\n%\\end{abstract}\n%\n\\\\[2em]\n%\n\\section{Introduction}\nThe motivation of this work was the need for the development of large data set to be used for Machine Learning purposes. \nIt consists of 475 examples of various delamination sizes and locations in a composite plate of dimensions 500 \\(\\times\\) 500 mm.\nFor each example simulation of guided wave propagation and interaction with delamination for selected excitation signal is needed.\n \nGuided wave propagation problems are computationally demanding.\nUsually, a very dense mesh is necessary to model short wavelengths (at least five nodes per wavelength are required to represent the shape of wave).\nTo date, there is no commercial software available which could be used for efficient wave propagation simulation. \nThis fact is confirmed by studies conducted by Leckey \\etal~\\cite{Leckey2018}. \nThey investigated four numerical simulation tools: custom implementation of the 3D Elastodynamic Finite Integration Technique (EFIT) \\cite{Schubert1998} along with three widely used commercial finite element codes: COMSOL, ABAQUS, and ANSYS. \nThe investigated example was related to the interaction of propagating Lamb waves with delaminations in cross-ply laminates. \nThe laminate was modelled by a fine mesh of 3D solid elements. \nThe numerical results were compared with experiments in terms of the wave-field showing quite good agreement in case of COMSOL, ABAQUS Implicit and ANSYS implicit. \nUnfortunately, despite the simulations were performed on a workstation equipped with 16 cores, the efficiency of each investigated methods is so low that it is prohibitive to perform any parametric study or generate large data sets (the shortest simulation run time was for the case of COMSOL i.e. 19.5~hours followed by ABAQUS implicit i.e. 40~hours).\n\nThe guided wave propagation modelling problem has been tackled by using various methods over the past few decades. \nThe following methods can be included: analytic methods~\\cite{Giurgiutiu2014}, semi--analytic methods~\\cite{Bartoli2006,Gravenkamp2014},  analytical and higher order finite element hybrid approach for 2D analysis~\\cite{Vivar-Perez2014}, the frequency domain spectral finite element method~\\cite{Doyle1989,RoyMahapatra2003},  the wavelet spectral finite element~\\cite{Mitra2008,Yang2016}, the time domain spectral element method~\\cite{Lonkar2013,Ostachowicz2012,Schulte2010}, the spectral cell method~\\cite{Duczek2014} and  the Local Interaction Simulation Approach~\\cite{Kijanka2013}.\nSome of these methods have been recently implemented for the use on Graphics Processing Units (GPU) in order to decrease computation time ~\\cite{Kijanka2013,Kudela2016,Mossaiby2019,Shen2017}.\nThe advantage of such approach is staggering computation speedup in comparison to the use of CPU.\n\nThe method presented in this paper for solving guided wave propagation problems combines the high order time domain spectral element method (SEM) with the Compute Unified Device Architecture (CUDA),  through Matlab Parallel Computing Toolbox. \nThe presented concept of parallel implementation of SEM is similar to the parallel implementation developed previously~\\cite{Kudela2016} but it is applied to flat shell spectral elements instead of 3D solid elements. \nTherefore, the computation can be performed faster than in case of utilisation of 3D solid spectral elements. \n\n\\section{Code vectorization concept}\nIn classic finite element approach elemental matrices are assembled to form equation of motion:\n\\begin{equation}\n\\bm{M} \\vec{\\ddot{U}} + \\bm{C} \\vec{\\dot{U}} + \\bm{K} \\vec{U} = \\vec{F}, \\label{eq:motion}\n\\end{equation}  \nwhere \\( \\bm{M} \\) is the global mass (inertia) matrix, \\( \\bm{K} \\) is the global stiffness matrix,  \\(\\bm{C} \\) is the global damping matrix, \\(\\vec{U}\\) is the vector of global degrees of freedom and~\\(\\vec{F}\\) is the vector of the time-dependent excitation (in this particular case the vector of equivalent piezoelectric forces). \nThe most efficient way to solve the (\\ref{eq:motion}) is by using explicit integration scheme. \nAssuming the central difference method:\n\\begin{equation}\n\\ddot{\\vec{U}}\\simeq \\frac{1}{\\Delta t^2} \\left(\\vec{u}_{t+\\Delta t} - 2\\,\\vec{u}_t + \\vec{u}_{t-\\Delta t}\\right), \\label{eq:central_scheme}\n\\end{equation}\n\\begin{equation}\n\\dot{\\vec{U}}\\simeq \\frac{\\vec{u}_{t+\\Delta t} -\\vec{u}_{t-\\Delta t}}{2 \\Delta t}\n\\label{eq:first_derivative_scheme}\n\\end{equation}\nand substituting (\\ref{eq:central_scheme})-(\\ref{eq:first_derivative_scheme}) into (\\ref{eq:motion}) leads to:\n\\begin{equation}\n\t\\underbrace{\\left(\\frac{1}{\\Delta t^2} \\,\\bm{M} + \\frac{1}{2 \\Delta t} \\bm{C}\\right)}_{\\vec{M}_0} \\vec{u}_{t+\\Delta t} = \\vec{F}_t - \\underbrace{\\left(\\bm{K} \\vec{u}_t\\right)}_{\\vec{F}^i} + \\underbrace{\\left(\\frac{2}{\\Delta t^2} \\,\\bm{M} \\right)}_{\\vec{M}_1}\\vec{u}_t \n\t+ \\underbrace{\\left(- \\frac{1}{\\Delta t^2} \\,\\bm{M} + \\frac{1}{2 \\Delta t} \\bm{C}\\right)}_{\\vec{M}_2} \\vec{u}_{t-\\Delta t}.\n\\label{eq:explicit_integration}\n\\end{equation}\n\nIt should be underlined that due to the orthogonality of shape functions and application of the Gauss-Lobatto-Legendre (GLL) integration rule the mass matrix is diagonal. \nIt has been shown that for the Lamb wave attenuation modelling it is possible to assume that the damping matrix is proportional to mass matrix~\\cite{Wandowski2017}. In such case calculation of displacements at the time step \\(t + \\Delta t\\) is straightforward and does not require costly matrix inversion. \nHowever, the term \\(\\vec{F}^i=\\bm{K}\\vec{u}_t\\) related to internal forces at the time step \\(t\\) is still computationally intensive. \nMoreover, assembly of the stiffness matrix is troublesome because it requires a lot of memory and limits the size of wave propagation problems which can be simulated. \nIn order to alleviate these deficiencies, a parallel code is proposed in which assembly is performed at the internal force vector level without the necessity of stiffness matrix assembly. \nThe proposed approach is very similar to the parallel implementation given in~\\cite{Kudela2016}. \n\nThe current method differs in the calculation of elemental forces which depend on the contribution of the extensional stiffness, the flexural stiffness, bending-stretching coupling,  twisting-stretching along with bending-shearing coupling, stre\\-tching-shearing coupling and bending-twisting coupling instead of the matrix of elastic constants assigned to each layer of a composite laminate. \nHence, the proposed method is more suitable for wave propagation modelling in multilayer composite laminates because it leads to a much lower number of degrees of freedom. \n\nEssentially, the term \\(\\bm{K}\\vec{u}_t\\) is expanded for each element by using sparse matrices of shape function derivatives \\(\\bm{N}_{\\xi}^e,\\,\\bm{N}_{\\eta}^e\\), components of the inverse of Jacobian matrix \\((\\vec{J}^{-1})_{ij}^e\\), elastic constants \\(\\vec{Q}_{ij}^e\\) integrated over the thickness, integration weights \\(\\vec{W}^e\\) and nodal displacement vector at the element level \\(\\hat{\\vec{u}}_0^{e} \\). \nThese matrices and vectors are combined together in the form corresponding to disjoint spectral elements as:\n\\begin{equation}\n\\bm{N},_{\\xi} = \\left[\n\\begin{array}{cccc}  \n\\bm{N},_{\\xi}^{e=1} & 0 & \\ldots & 0\\\\[2pt]\n0& \\bm{N},_{\\xi}^{e=2}  & \\ldots& 0\\\\[2pt]\n\\vdots&\\vdots&\\ddots&0\\\\[2pt]\n0& 0 &0&\\bm{N},_{\\xi}^{e=n}\\\\[2pt]\n\\end{array}\\right],\\quad\n\\vec{U}_x = \\left[\n\\begin{array}{c}  \n\\hat{\\vec{u}}_0^{e=1}  \\\\[2pt]\n\\hat{\\vec{u}}_0^{e=2} \\\\[2pt]\n\\vdots\\\\[2pt]\n\\hat{\\vec{u}}_0^{e=n}\\\\[2pt]\n\\end{array}\\right].\n\\end{equation}\nTherefore, at the final step, it is necessary to assemble the global force vector. \nIt can be performed according to mesh colouring algorithm proposed in~\\cite{Kudela2016}. \nThe algorithm uniformly divides the nodes of spectral elements within the whole mesh into 12 sets. \nThe sets are of the same size so the computation can be perfectly balanced between workers or resources can be uniformly divided within one graphics card.\nThe 36-node spectral elements are used in the current approach. It guarantees that the mesh can be divided into 12 equal sets because the result of operation \\(36/12=3\\) is integer.\n\nOnce internal forces \\(\\vec{F}^i\\) are calculated and substituted into (\\ref{eq:explicit_integration}), the displacements at time step \\(t+\\Delta t\\) can be explicitly obtained from a perfectly vectorized code:\n\\begin{equation}\n\\vec{u}_{t+\\Delta t}=1./\\vec{M}_0\\, .*\\left(\\vec{F}_t - \\vec{F}^i +\\vec{M}_1 \\, .* \\vec{u}_t +\\vec{M}_2 \\, .* \\vec{u}_{t-\\Delta t}\\right),\n\\label{eq:vectorized_motion}\n\\end{equation} \nin which terms \\(\\vec{M}_0\\), \\(\\vec{M}_1\\) and \\(\\vec{M}_2\\) are stored as vectors and \\(./\\) is element-wise division  and \\(.*\\) denotes element-wise operation known as Hadamard product (the same symbol for element-wise operation is used in Matlab). \nIn particular, all components in (\\ref{eq:vectorized_motion}) are implemented in Matlab Parallel Computing Toolbox as \\verb|gpuArray|. \nIn this way, the implementation is simple whereas CUDA GPU computation is transparent to the user. \n\nDepending on the size of the problem,  calculations are about 5--12 times faster on GPU than on a single CPU.\n\n\\section{Results}\nThe numerical results were validated by experimental wave-field data acquired by scanning laser Doppler vibrometer.\nThe investigated specimen was made out of unidirectional CFRP laminate with an orientation angle of reinforcing fibres 90\\(^{\\circ}\\).\nMaterial properties of single-layer CFRP laminate are given in Tab.~\\ref{tab:mat_prop}.\nThe mass density was 1574.1 kg/m\\textsuperscript{3}.\nThe dimensions of the specimen were 1200\\(\\times\\)1200 mm and the thickness was 2.85 mm.\nA piezoelectric transducer of diameter 10 mm was placed at the centre of the plate. \nThree excitation frequencies were considered 16.5 kHz, 50 kHz and 100 kHz.\nThe signal had a form of sinusoid modulated by Hann window (5 cycles).\nThe measurements were taken on a lower left quarter of the composite laminate on the opposite side with respect to the piezoelectric transducer.\nMeasurements were acquired at a regular grid of 491\\(\\times\\)491 points.\n\nNumerical simulations were carried out with the same parameters as in the experiment.\nThe wave-field data at a quarter of the plate was interpolated on a regular grid of points of the same size as in the experimental data.\n\nIt should be added that damping was not included in the numerical simulations.\n\\begin{table}[h!]\n\t\t\\renewcommand{\\arraystretch}{1.3}\n\t\\caption{Material properties of the investigated unidirectional CFRP laminate; Units: GPa.}\n\t\\begin{center}\n\t\t\t\\begin{tabular}{cccccc} \n\t\t\t%\\hline\n\t\t\t\\toprule\n\t\t\t$Q_{11}$ & $Q_{12}$  & $Q_{22}$ & $Q_{44}$ & $Q_{55}$ & $Q_{66}$\\\\\n\t\t\t% \\cmidrule(lr){1-3} \\cmidrule(lr){4-6} \\cmidrule(lr){7-7}\n\t\t\t%\\hline\n\t\t\t\\midrule\n\t\t\t120& 5.6& 12.7 & 3.1 & 5.3 & 4.5\\\\\n\t\t\t%\\hline \n\t\t\t\\bottomrule \n\t\t\\end{tabular} \n\t\\end{center}\n\t\t\\label{tab:mat_prop}\n\\end{table}\n\nComparative results are presented in Figs.~\\ref{fig:wavefield16_5}--\\ref{fig:wavefield100}.\nIt can be seen that qualitative agreement between numerical and experimental wave-fields is very good especially for A0 mode which has the greatest amplitude.\n\nIn experimental wave-fields at 50 kHz additional low-amplitude waves can be observed which correspond to the faster S0 mode (see Fig.~\\ref{fig:wavefield50a}).\nUnfortunately, S0 mode is not visible in numerical simulations. \nHowever, this problem can be alleviated by tuning in-plane and out-of-plane damping matrix components.\n\nWhen 100 kHz excitation signals are applied, more guided wave modes can be observed in experimental signals (Figs.~\\ref{fig:wavefield100b},~\\ref{fig:wavefield100d},~\\ref{fig:wavefield100f}).\nThe model is not able to properly simulate higher guided wave modes because it is based on the first-order shear deformation theory. \nIt has not enough degrees of freedom per node in order to properly model through-thickness guided wave behaviour at higher frequencies.\n\\begin{figure} [h!]\n\t\\centering\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure1a.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield16_5a}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure1b.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield16_5b}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure1c.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield16_5c}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure1d.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield16_5d}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure1e.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield16_5e}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure1f.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield16_5f}\n\t\\end{subfigure}\n\t\\caption{Wave-field of propagating guided waves for the excitation frequency \\textbf{16.5 kHz} at the time instances:  0.25 (a)-(b), 0.5 (c)-(d) and 0.75 (e)-(f) ms. }\n\t\\label{fig:wavefield16_5}\n\\end{figure}\n\\begin{figure} [h!]\n\t\\centering\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure2a.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield50a}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure2b.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield50b}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure2c.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield50c}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure2d.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield50d}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure2e.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield50e}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure2f.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield50f}\n\t\\end{subfigure}\n\t\\caption{Wave-field of propagating guided waves for the excitation frequency \\textbf{50 kHz} at the time instances:  0.25 (a)-(b), 0.5 (c)-(d) and 0.75 (e)-(f) ms. }\n\t\\label{fig:wavefield50}\n\\end{figure}\n\\begin{figure} [h!]\n\t\\centering\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure3a.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield100a}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure3b.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield100b}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics[]{figure3c.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield100c}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure3d.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield100d}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure3e.png}\n\t\t\\caption{Numerical}\n\t\t\\label{fig:wavefield100e}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.49\\textwidth}\n\t\t\\centering\n\t\t\\includegraphics{figure3f.png}\n\t\t\\caption{Experimental}\n\t\t\\label{fig:wavefield100f}\n\t\\end{subfigure}\n\t\\caption{Wave-field of propagating guided waves for the excitation frequency \\textbf{100 kHz} at the time instances:  0.2 (a)-(b), 0.3 (c)-(d) and 0.4 (e)-(f) ms. }\n\t\\label{fig:wavefield100}\n\\end{figure}\n\\clearpage\n\\section{Conclusions}\nA novel vectorized code for guided wave propagation problems was developed.\nIt is based on the time domain spectral element method in which flat shell elements are utilized.\nThe proposed code is implemented for the use on GPU which results in 5-12 times computation speed-up in comparison to computations on CPU.\n\nQualitative results in terms of full wave-filed data are satisfactory.\nThe model is limited to the modelling of fundamental guided wave modes.\nTherefore, discrepancies between numerical and experimental results at higher frequencies are expected. \n\nFurther studies are needed in relation to the optimisation of damping parameters and quantitative estimation of differences between numerical and experimental signals.\n\n\\section*{Acknowledgements}\nThe research was funded by the Polish National Science Center under grant agreement no 2018/31/B/ST8/00454. \nP. Kudela would like to acknowledge the Polish National Agency for Academic Exchange for the support in the frame of the Bekker Programme (PPN/BEK/2018/1/00014/DEC/1). \nAuthors are also grateful to Task-CI for allowing the use of Matlab and Parallel Computing Toolbox licences. \n%\n% ---- Bibliography ----\n%\n% BibTeX users should specify bibliography style 'splncs04'.\n% References will then be sorted and formatted in the correct style.\n%\n \\bibliographystyle{splncs04}\n \\bibliography{EWSHM2020-code-vectorization}\n%\n\n\\end{document}\n", "meta": {"hexsha": "64d2d3f0b01222e79e6b1eadd545c624a35e14ec", "size": 20229, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/conference_papers/EWSHM2020_code_vectorization/EWSHM2020_code_vectorization.tex", "max_stars_repo_name": "pawelkudela/ma-shm", "max_stars_repo_head_hexsha": "b0403ba4e98e7d8176cbce00a6102b7deef82629", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-03T05:39:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T05:39:06.000Z", "max_issues_repo_path": "reports/conference_papers/EWSHM2020_code_vectorization/EWSHM2020_code_vectorization.tex", "max_issues_repo_name": "pawelkudela/ma-shm", "max_issues_repo_head_hexsha": "b0403ba4e98e7d8176cbce00a6102b7deef82629", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/conference_papers/EWSHM2020_code_vectorization/EWSHM2020_code_vectorization.tex", "max_forks_repo_name": "pawelkudela/ma-shm", "max_forks_repo_head_hexsha": "b0403ba4e98e7d8176cbce00a6102b7deef82629", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.7272727273, "max_line_length": 584, "alphanum_fraction": 0.7583172673, "num_tokens": 5743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4075875752457212}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{tikz}\n\\usepackage{array}\n\n\n\n\\title{Chapter 11\\\\Complex Variable Theory}\n\\author{solutions by Hikari}\n\\date{September 2021}\n\n\\begin{document}\n\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\del}{\\boldsymbol{\\nabla}}\n\n%dashint\n\\def\\Xint#1{\\mathchoice\n   {\\XXint\\displaystyle\\textstyle{#1}}%\n   {\\XXint\\textstyle\\scriptstyle{#1}}%\n   {\\XXint\\scriptstyle\\scriptscriptstyle{#1}}%\n   {\\XXint\\scriptscriptstyle\\scriptscriptstyle{#1}}%\n   \\!\\int}\n\\def\\XXint#1#2#3{{\\setbox0=\\hbox{$#1{#2#3}{\\int}$}\n     \\vcenter{\\hbox{$#2#3$}}\\kern-.5\\wd0}}\n\\def\\ddashint{\\Xint{\\;\\,-}}\n\\def\\dashint{\\Xint-}\n\n\n\\maketitle\n\n\\section*{11.2 Cauchy-Riemann Conditions}\n\n\\paragraph{11.2.1}\n\\[\n\\pdv{u}{x}=1\\neq\\pdv{v}{y}=0\n\\]\nso it is not analytic.\n\n\\paragraph{11.2.2}\nThe real and imaginary parts of analytic functions satisfy Laplace's equation, and it has been shown in Section 9.5 that functions satisfying Laplace's equation cannot have a maximum or minimum within the bounded region.\n\n\\paragraph{11.2.3}\n(a)\n\\begin{align*}\n    \\pdv{u}{x} & =\\pdv{v}{y}=3x^2-3y^2\\\\\n    -\\pdv{u}{y} & =\\pdv{v}{x}=6xy\n\\end{align*}\n\\[\nv(x,y)=3x^2y-y^3\n\\]\n\\[\nw(z)=x^3-3xy^2+i(3x^2y-y^3)=(x+iy)^3=z^3\n\\]\n\n(b)\n\\begin{align*}\n    & \\pdv{u}{x}=\\pdv{v}{y}=-e^{-y}\\sin x\\\\\n    & \\pdv{u}{y}=-\\pdv{v}{x}=-e^{-y}\\cos x\n\\end{align*}\n\\[\nu(x,y)=e^{-y}\\cos x\n\\]\n\\[\nw(z)=e^{-y}\\cos x+ie^{-y}\\sin x=e^{i(x+iy)}=e^{iz}\n\\]\n\n\\paragraph{11.2.4}\n$w_1$ analytic:\n\\[\n\\pdv{u}{x}=\\pdv{v}{y}\\qquad \\pdv{u}{y}=-\\pdv{v}{x}\n\\]\n$w_1^*$ analytic:\n\\[\n\\pdv{u}{x}=-\\pdv{v}{y}\\qquad \\pdv{u}{y}=\\pdv{v}{x}\n\\]\nso \n\\[\n\\pdv{u}{x}=\\pdv{u}{y}=\\pdv{v}{x}=\\pdv{v}{y}=0\n\\]\nwhich means $u(x,y)$ and $v(x,y)$ are constants.\n\n\\paragraph{11.2.5}\n\\[\nf(z)=\\frac{1}{x+iy}=\\frac{x}{x^2+y^2}-i\\frac{y}{x^2+y^2}\n\\]\n\\begin{align*}\n    & \\pdv{u}{x}=\\frac{-x^2+y^2}{(x^2+y^2)^2}=\\pdv{v}{y}\\\\\n    & \\pdv{u}{y}=\\frac{-2xy}{(x^2+y^2)^2}=-\\pdv{v}{x}\n\\end{align*}\nso $f(z)$ is analytic (except $z=0$).\n\n\\paragraph{11.2.6}\n\\[\nf'(z)=\\frac{(\\pdv{u}{x}+i\\pdv{v}{x})adx+(\\pdv{u}{y}+i\\pdv{v}{y})bdy}{a\\,dx+ib\\,dy}\n\\]\n\\[\n=\\frac{(\\pdv{u}{x}+i\\pdv{v}{x})adx+(-\\pdv{v}{x}+i\\pdv{u}{x})bdy}{a\\,dx+ib\\,dy}\n\\]\n\\[\n=\\frac{(\\pdv{u}{x}+i\\pdv{v}{x})adx+(\\pdv{u}{x}+i\\pdv{v}{x})ibdy}{a\\,dx+ib\\,dy}\n\\]\n\\[\n=\\pdv{u}{x}+i\\pdv{v}{x}\n\\]\n\n\\paragraph{11.2.7}\n\\begin{align*}\n    & \\delta z=e^{i\\theta}\\delta r+ire^{i\\theta}\\delta\\theta\\\\\n    & \\delta f=e^{i\\Theta}\\delta R+iRe^{i\\Theta}d\\Theta\n\\end{align*}\n\\begin{align*}\n    & \\lim_{\\delta z\\to0}\\frac{\\delta f}{\\delta z}=\\lim_{\\delta r\\to0}\\left(\\frac{e^{i\\Theta}\\delta R}{e^{i\\theta}\\delta r}+\\frac{iRe^{i\\Theta}\\delta\\Theta}{e^{i\\theta}\\delta r} \\right)=e^{i(\\Theta-\\theta)}\\pdv{R}{r}+iRe^{i(\\Theta-\\theta)}\\pdv{\\Theta}{r}\\\\[3pt] \n    & \\lim_{\\delta z\\to0}\\pdv{f}{z}=\\lim_{\\delta\\theta\\to0}\\left(\\frac{e^{i\\Theta}\\delta R}{ire^{i\\theta}\\delta\\theta}+\\frac{iRe^{i\\Theta}\\delta\\Theta}{ire^{i\\theta}\\delta\\theta} \\right)=-i\\frac{e^{i(\\Theta-\\theta)}}{r}\\pdv{R}{\\theta}+\\frac{Re^{i(\\Theta-\\theta)}}{r}\\pdv{\\Theta}{\\theta}\n\\end{align*}\nEquating the real and imaginary parts, we have \n\\[\n\\pdv{R}{r}=\\frac{R}{r}\\pdv{\\Theta}{\\theta}\n\\]\n\\[\n\\frac{1}{r}\\pdv{R}{\\theta}=-R\\pdv{\\Theta}{r}\n\\]\n\n\\paragraph{11.2.8}\nFrom Exercise 11.2.7, we have\n\\begin{align*}\n    & \\pdv{^2R}{r\\partial\\theta}=\\pdv{}{\\theta}\\left(\\frac{R}{r}\\pdv{\\Theta}{\\theta}\\right)=\\frac{1}{r}\\pdv{R}{\\theta}\\pdv{\\Theta}{\\theta}+\\frac{R}{r}\\pdv{^2\\Theta}{\\theta^2}=-R\\pdv{\\Theta}{r}\\pdv{\\Theta}{\\theta}+\\frac{R}{r}\\pdv{^2\\Theta}{\\theta^2}\\\\\n    & \\pdv{^2R}{r\\partial\\theta}=\\pdv{}{r}\\left(-rR\\pdv{\\Theta}{r}\\right)=-R\\pdv{\\Theta}{r}-r\\pdv{R}{r}\\pdv{\\Theta}{r}-rR\\pdv{^2\\Theta}{r^2}=-R\\pdv{\\Theta}{r}-R\\pdv{\\Theta}{\\theta}\\pdv{\\Theta}{r}-rR\\pdv{^2\\Theta}{r^2}\n\\end{align*}\nEquate the two equations and divide by $rR$, we have\n\\[\n\\pdv{^2\\Theta}{r^2}+\\frac{1}{r}\\pdv{\\Theta}{r}+\\frac{1}{r^2}\\pdv{^2\\Theta}{\\theta^2}=0\n\\]\n\n\\paragraph{11.2.9}\n(a)\n$\nf'(z)=\\frac{\\cos z}{z}-\\frac{\\sin z}{z^2}\n$,\\;\n$f(z)$ is analytic at every finite $z$.\n\\medskip\n\n(b)\n$\nf'(z)=\\frac{-2z}{(z^2+1)^2}\n$,\\;\n$f(z)$ is analytic at every finite $z$ except $z=\\pm i$.\n\\medskip\n\n(c)\n$\nf'(z)=\\frac{-(2z+1)}{z^2(z+1)^2}\n$,\\;\n$f(z)$ is analytic at every finite $z$ except $z=0,1$.\n\\medskip\n\n(d)\n$\nf'(z)=\\frac{e^{-\\frac{1}{z}}}{z^2}\n$,\\;\n$f(z)$ is analytic at every finite $z$ except $z=0$.\n\\medskip\n\n(e)\n$\nf'(z)=2z-3\n$,\\;\n$f(z)$ is analytic at every finite $z$.\n\\medskip\n\n(f)\n$\nf'(z)=\\sec^2(z)\n$,\\;\n$f(z)$ is analytic at every finite $z$ except $z=(n+\\frac{1}{2})\\pi$, $n$ is any integer.\n\\medskip\n\n(g)\n$\nf'(z)=\\mathrm{sech}^2(z)\n$,\\;\n$f(z)$ is analytic at every finite $z$ except $z=(n+\\frac{1}{2})i\\pi$, $n$ is any integer.\n\n\\paragraph{11.2.10}\n(a) $f(z)$ has a derivative at all finite $z$ except $z=0$. (It is a branch point, see section 11.6)\n\\medskip\n\n(b) $f(z)$ has a derivative at all finite $z$ except $z=0$.\n\\medskip\n\n(c) $\\tan^{-1}(z)=\\frac{i}{2}\\ln\\left(\\frac{i+z}{i-z}\\right)$, so $f(z)$ has a derivative at all finite $z$ except $\\pm i$.\n\\medskip\n\n(d) $\\tanh^{-1}(z)=\\frac{1}{2}\\ln\\left(\\frac{1+z}{1-z}\\right)$, so $f(z)$ has a derivative at all finite $f(z)$ except $z=\\pm1$.\n\n\\paragraph{11.2.11}\n(a)\n\\[\n\\frac{df}{dz}=\\pdv{u}{x}+i\\pdv{v}{x}=\\pdv{u}{x}-i\\pdv{u}{y}=V_x-iV_y\n\\]\n\n(b) \n\\[\n\\del\\cdot\\V{V}=\\pdv{V_x}{x}+\\pdv{V_y}{y}=\\pdv{^2u}{x^2}+\\pdv{^2u}{y^2}=0\n\\]\n\n(c)\n\\[\n\\del\\times\\V{V}=\\pdv{V_y}{x}-\\pdv{V_x}{y}=\\pdv{^2u}{x\\partial y}-\\pdv{^2u}{y\\partial x}=0\n\\]\n\n\\paragraph{11.2.12}\nDo the coordinate transformation $f(x,y)=f(z,z^*)$ and use the chain rule:\n\\[\n\\pdv{f}{z^*}=\\pdv{f}{x}\\pdv{x}{z^*}+\\pdv{f}{y}\\pdv{y}{z^*}\\]\n\\[\n=\\left(\\pdv{u}{x}+i\\pdv{v}{x}\\right)\\frac{1}{2}+\\left(\\pdv{u}{y}+i\\pdv{v}{y}\\right)\\frac{-1}{2i}\n\\]\n\\[\n=\\left(\\pdv{u}{x}+i\\pdv{v}{x}\\right)\\frac{1}{2}+\\left(-\\pdv{v}{x}+i\\pdv{u}{x}\\right)\\frac{i}{2}=0\n\\]\nSo the analytic function $f$ is a function of $z$ only.\n\n\\section*{11.3 Cauchy’s Integral Theorem}\n\n\\paragraph{11.3.1}\n\\[\n\\int\\displaylimits_{z_1}^{z_2}f(z)\\,dz=\\int\\displaylimits_{x_1,y_1}^{x_2,y_2}[u+iv][dx+i\\,dy]=-\\int\\displaylimits_{x_2,y_2}^{x_1,y_1}[u+iv][dx+i\\,dy]=-\\int\\displaylimits_{z_2}^{z_1}f(z)\\,dz\n\\]\n\n\\paragraph{11.3.2}\nAs the infinite version of $\\big|\\sum_k a_k\\big|\\leq\\sum_k|a_k|$, we have\n\\[\n\\bigg|\\int\\displaylimits_Cf(z)\\,dz\\bigg|\\leq\\int\\displaylimits_C|f(z)\\,dz|=\\int\\displaylimits_C|f(z)||dz|\\leq\\int\\displaylimits_C|f|_{max}\\,ds=|f|_{max}\\cdot L\n\\]\n\n\\paragraph{11.3.3}\n(a) The path is described by $z=x+i(-7x+25)$ where $x$ ranges from $3$ to $4$. Substituting, the integral becomes\n\\[\n\\int_3^4\\big[-192x^2+1379x-2425+i(-56x^2+197x) \\big][dx-7i\\,dx]=\\frac{76-707i}{3}\n\\]\n\n(b) The path is described by $z=5e^{i\\theta}$ where $\\theta$ ranges from $\\theta_1$ to $\\theta_2$, with $e^{i\\theta_1}=\\frac{3+4i}{5}$,\\; $e^{i\\theta_2}=\\frac{4-3i}{5}$. Substituting, the integral becomes\n\\[\n\\int_{\\theta_1}^{\\theta_2}\\left(100e^{2i\\theta}-15ie^{i\\theta} \\right)5ie^{i\\theta}d\\theta\n=\\left[\\frac{500}{3}e^{3i\\theta}-\\frac{75}{2}ie^{2i\\theta} \\right]_{\\theta_1}^{\\theta_2}\n=\\frac{76-707i}{3}\n\\]\n\n\\paragraph{11.3.4}\n$\\cos 2\\zeta$ is analytic in the whole space, so integral is independent of path. \n\\[\nF(\\pi i)=\\int\\displaylimits_{\\pi(1+i)}^{\\pi i}\\cos2\\zeta\\,d\\zeta=\\frac{\\sin2\\zeta}{2}\\Big|_{\\pi(1+i)}^{\\pi i}=\\frac{\\sin2\\pi i}{2}-\\frac{\\sin2\\pi i\\cos 2\\pi+\\cos 2\\pi i\\sin 2\\pi}{2}=0\n\\]\n\n\\paragraph{11.3.5}\n(a) \nThe path is $z=x+iy=e^{i\\theta}$ where $\\theta$ ranges from $0$ to $-2\\theta$, so the integral becomes\n\\[\n\\int_0^{-2\\pi}(\\cos^2\\theta-i\\sin^2\\theta)ie^{i\\theta}d\\theta=0\n\\]\n\n(b) \n\\begin{alignat*}{2}\n    & (-1,-1)\\rightarrow(1,-1):\\quad && \\int_{-1}^1(x^2-i)dx=\\frac{2}{3}-2i\\\\\n    & (1,-1)\\rightarrow(1,1):\\quad && \\int_{-1}^1(1-iy^2)i\\,dy=\\frac{2}{3}+2i\\\\\n    & (1,1)\\rightarrow(-1,1):\\quad && \\int_{1}^{-1}(x^2-i)dx=-\\frac{2}{3}+2i\\\\\n    & (-1,1)\\rightarrow(-1,-1):\\quad && \\int_{1}^{-1}(1-iy^2)i\\,dy=-\\frac{2}{3}-2i\n\\end{alignat*}\nso the sum\n\\[\n\\oint\\displaylimits_C(x^2-iy^2)dz=0\n\\]\nThe two results are identical because of the symmetry, not because of the analyticity.\n\n\\paragraph{11.3.6}\n\\[\n\\int\\displaylimits_{C_1}z^*\\,dz=\\int_0^1x\\,dx+\\int_0^1(1-iy)idy=\\frac{1}{2}+i+\\frac{1}{2}=1+i\n\\]\n\\[\n\\int\\displaylimits_{C_2}z^*\\,dz=\\int_0^1(-iy)idy+\\int_0^1(x-i)dx=\\frac{1}{2}+\\frac{1}{2}-i=1-i\n\\]\n\n\\paragraph{11.3.7}\n\\[\n\\oint\\displaylimits\\frac{dz}{z^2+z}=\\oint\\displaylimits_C\\frac{1}{z}dz-\\oint\\displaylimits_C\\frac{1}{z+1}dz=2\\pi i-2\\pi i=0\n\\]\nwhere we use Equation 11.29.\n\n\\section*{11.4 Cauchy’s Integral Formula}\n\n\\paragraph{11.4.1}\n\\begin{alignat*}{3}\n    & m\\neq n:\\qquad && m-n-1\\neq-1,\\qquad && \\frac{1}{2\\pi i}\\oint z^{m-n-1}dz=\\frac{1}{2\\pi i}\\cdot0=0\\\\\n    & m=n:\\qquad && m-n-1=-1,\\qquad && \\frac{1}{2\\pi i}\\oint z^{m-n-1}dz=\\frac{1}{2\\pi i}\\cdot2\\pi i=1\n\\end{alignat*}\n\n\\paragraph{11.4.2}\n\\[\n\\oint\\frac{dz}{z^2-1}=\\oint\\frac{dz}{(z-1)(z+1)}=2\\pi i\\cdot\\frac{1}{1+1}=\\pi i\n\\]\n\n\\paragraph{11.4.3}\nBy Equation 11.32,\n\\[\n\\oint\\displaylimits_C\\frac{f(z)}{(z-z_0)^2}dz=2\\pi if'(z_0)=\\oint\\displaylimits_C\\frac{f'(z)}{z-z_0}dz\n\\]\nbecause $f'(z)$ is also analytic.\n\n\\paragraph{11.4.4}\nThe equation holds for $n=0$:\n\\[\nf(z_0)=\\frac{1}{2\\pi i}\\oint\\displaylimits_C\\frac{f(z)}{z-z_0}dz\n\\]\nIf the equation holds for $n=k\\geq0$:\n\\[\nf^{(k)}(z_0)=\\frac{k!}{2\\pi i}\\oint\\frac{f(z)}{(z-z_0)^{k+1}}dz\n\\]\nDifferentiating with respect to $z_0$:\n\\[\nf^{(k+1)}(z_0)=\\frac{k!}{2\\pi i}(k+1)\\oint\\frac{f(z)}{(z-z_0)^{k+2}}dz=\\frac{(k+1)!}{2\\pi i}\\oint\\frac{f(z)}{(z-z_0)^{k+2}}dz\n\\]\nwhich means the equation also holds for $n=k+1$. The proof follows by induction.  \n\n\\paragraph{11.4.5}\n(The problem should be $|f(z)|\\geq M$ in order to be in accordance with the hint and (b), while to prove that we still need to prove the case of $|f(z)|\\leq M$ first)\n\\medskip\n\n(a)\nWe first prove if $|f(z)|\\leq M$ on $C$, then $|f(z)|\\leq M$ for all points within $C$. It is obvious because for every $z_0$ within $C$,\n\\[\n|f(z_0)|=\\frac{1}{2\\pi}\\bigg|\\oint\\displaylimits_{|z-z_0|=r}\\frac{f(z)}{z-z_0}dz \\bigg|\\leq\\frac{1}{2\\pi}\\frac{M'}{r}\\cdot2\\pi r=M'\n\\]\nwhere $M'$ is the maximum of $|f(z)|$ on the circle $|z-z_0|=r$, so $|f(z_0)|$ cannot be maximum, which means the maximum is always on the boundary, which is $M$.\n\nTo prove the case of $|f(z)|\\geq M$, note that $w(z)=\\frac{1}{f(z)}$ is also analytic because $f(z)\\neq0$, so $|w(z)|\\leq\\frac{1}{M}$ on $C$ implies $|w(z)|\\leq\\frac{1}{M}$ for all points within $C$, so $|f(z)|=\\frac{1}{|w(z)|}\\geq M$ for all points within $C$.\n\n(b)\nSimply take $f(z)=z$ and the contour $|z|=1$, then $|f(0)|=0$ but $|f(z)|=1>0$ over the entire contour.\n\n\n\\paragraph{11.4.6}\n\\[\n\\oint\\displaylimits_C\\frac{e^{iz}}{z^3}dz=2\\pi i\\cdot\\frac{1}{2!}\\frac{d^2(e^{iz})}{dz^2}\\bigg|_{z=0}=-\\pi i\n\\]\n\n\\paragraph{11.4.7}\n\\[\n\\oint\\displaylimits_C\\frac{\\sin^2z-z^2}{(z-a)^3}dz=2\\pi i\\cdot\\frac{1}{2!}\\frac{d^2(\\sin^2z-z^2)}{dz^2}\\bigg|_{z=a}=2\\pi i\\big[\\cos(2a)-1 \\big]\n\\]\n\n\\paragraph{11.4.8}\n\\[\n\\oint\\displaylimits_C\\frac{dz}{z(2z+1)}=\\oint\\displaylimits_C\\frac{1}{z}dz-\\oint\\displaylimits_C\\frac{2}{2z+1}dz=2\\pi i-2\\pi i=0\n\\]\n\n\\paragraph{11.4.9}\n\\[\n\\oint\\displaylimits_C\\frac{f(z)}{z(2z+1)^2}dz=\\oint\\displaylimits_C\\frac{f(z)}{z}dz-2\\oint\\displaylimits_C\\frac{f(z)}{2z+1}dz-2\\oint\\displaylimits_C\\frac{f(z)}{(2z+1)^2}dz\n\\]\n\\[\n=2\\pi if(0)-2(2\\pi i)\\frac{f(-\\frac{1}{2})}{2}-2(2\\pi i)\\frac{f'(-\\frac{1}{2})}{4}\n\\]\n\\[\n=2\\pi if(0)-2\\pi if(-\\frac{1}{2})-\\pi if'(-\\frac{1}{2})\n\\]\n\n\\section*{11.5 Laurent Expansion}\n\n\\paragraph{11.5.1}\n\\[\n\\ln(1+z)=\\sum_{n=0}^\\infty\\frac{z^n}{n!}\\left[\\frac{d^n\\big[\\ln(1+z)\\big]}{dz^n}\\right]_{z=0}=\\sum_{n=1}^\\infty\\frac{z^n}{n!}\\frac{(-1)^{n-1}(n-1)!}{(1+0)^n}=\\sum_{n=0}^\\infty(-1)^{n-1}\\frac{z^n}{n}\n\\]\n\n\\paragraph{11.5.2}\n\\[\n(1+z)^m=\\sum_{n=0}^\\infty\\frac{z^n}{n!}\\left[\\frac{d^n\\left[(1+z)^m\\right]}{dz^n} \\right]_{z=0}=\\sum_{n=0}^\\infty\\frac{z^n}{n!}\\frac{m!}{(m-n)!}=\\sum_{n=0}^\\infty\\binom{m}{n}z^n\n\\]\n$z=-1$ is the nearest singular point if $m$ is negative or non-integer, so $|z|=1$ is the circle of convergence.\n \n\\paragraph{11.5.3}\n$f(0)=0$ means that $f(z)=zg(z)$ where $g(z)$ is analytic, so $\\frac{f(z)}{z}$ is analytic in $|z|\\leq1$. The maximum modulus of an analytic function can only be on the boundary (Exercise 11.4.5), so \n\\[\n\\left|\\frac{f(z)}{z}\\right|\\leq\\left|\\frac{f(1)}{1}\\right|<1\n\\]\nwhich means $|f(z)|<|z|$ for $|z|\\leq1$.\n\\medskip\n\n(\nOr follow the hint, for every $|z_0|<1$,\n\\[\n\\left|\\frac{f(z_0)}{z_0}\\right|^n=\\frac{1}{2\\pi}\\left|\\oint_{|z|=1}\\left(\\frac{f(z)}{z} \\right)^n\\frac{1}{z-z_0}dz \\right|\\leq\\frac{1}{2\\pi}\\oint_{|z|=1}\\frac{|f(z)|^n}{|z|^n|z-z_0|}|dz|<\\frac{1}{2\\pi}\\frac{2\\pi}{|1-z_0|}=\\frac{1}{|1-z_0|}\n\\]\n\\[\n\\left|\\frac{f(z_0)}{z_0}\\right|<\\left(\\frac{1}{|1-z_0|}\\right)^{\\frac{1}{n}}\n\\]\nwhich holds for every positive $n$. Let $n\\to\\infty$, then we have $\\left|\\frac{f(z_0)}{z_0}\\right|<1$ )\n    \n\\paragraph{11.5.4}\nIf $f(z)$ is an analytic function and $f(x)=f^*(x)$, then by taking the derivative along the real line, we have\n\\[\nf'(x)=\\lim_{h\\to0}\\frac{f(x+h)-f(x)}{h}=\\lim_{h\\to0}\\frac{f^*(x+h)-f^*(x)}{h^*}=\\left[f'(x)\\right]^*\n\\]\nRepeating the process, we have $f^{(n)}(x)=\\left[f^{(n)}(x)\\right]^*$ for all $n$. If $f(z)=\\sum_{n=0}^\\infty a_nz^n$, then\n\\[\nf(0)=a_0=f^*(0)=a_0^*\n\\]\n\\[\nf'(0)=a_1=\\left[f'(0)\\right]^*=a_1^*\n\\]\n\\[\n\\vdots\n\\]\nwhich means all the coefficients are are real.\n\\medskip\n\nBack to the problem, we have\n\\[\nz^N f(z)=\\sum_{m=0}^\\infty a_mz^m\n\\]\n\\[\n\\oint\\displaylimits_C  z^Nf(z)dz=0\n\\]\nwhich implies $z^Nf(z)$ is analytic by Morera’s theorem. And also $x^Nf(x)=\\left[x^Nf(x)\\right]^*$, so by the above results, we knows that all the coefficients are real.\n\n\\paragraph{11.5.5}\n\\[\na_n=\\frac{1}{2\\pi i}\\oint\\displaylimits_C\\frac{f(z)dz}{(z-z_0)^{n+1}}=b_n\n\\]\n\n\\paragraph{11.5.6}\n\\[\n\\frac{e^z}{z^2}=\\frac{1}{z^2}\\sum_{n=0}^\\infty\\frac{z^n}{n!}=\\frac{1}{z^2}+\\frac{1}{z}+\\sum_{n=0}^\\infty\\frac{z^n}{(n+2)!}\n\\]\n\n\\paragraph{11.5.7}\n\\[\n\\frac{ze^z}{z-1}=\\frac{(t+1)e^{t+1}}{t}\\]\n\\[\n=e\\left[\\sum_{n=0}^\\infty\\frac{t^n}{n!}+\\frac{1}{t}+\\sum_{n=0}^\\infty\\frac{t^n}{(n+1)!} \\right]\n\\]\n\\[\n=e\\left[\\frac{1}{t}+\\sum_{n=0}^\\infty\\frac{(n+2)}{(n+1)!}t^n \\right]\n\\]\n\\[\n=\\frac{e}{z-1}+\\sum_{n=0}^\\infty\\frac{e(n+2)}{(n+1)!}(z-1)^n\n\\]\n\n\\paragraph{11.5.8}\n\\[\n(z-1)e^{\\frac{1}{z}}=z\\sum_{n=0}^\\infty\\frac{1}{n!z^n}-\\sum_{n=0}^\\infty\\frac{1}{n!z^n}\n\\]\n\\[\n=z+\\sum_{n=0}^\\infty\\frac{1}{(n+1)!}z^{-n}-\\sum_{n=0}^\\infty\\frac{1}{n!}z^{-n}\n\\]\n\\[\n=z+\\sum_{n=0}^\\infty\\frac{-n}{(n+1)!}z^{-n}\n\\]\n\n\\section*{11.6 Singularities}\n\n\\paragraph{11.6.1}\n$z=\\frac{1}{\\ln z_0}$ satisfies the equation $e^{1/z}=z_0$ and is therefore a solution. There are infinite number of values of $\\ln z_0$, so there are infinite number of solutions\n\n\\paragraph{11.6.2}\nLet $z-1=\\rho e^{i\\varphi}$, $z+1=re^{i\\theta}$, then\n\\[\nw(z)=r^{\\frac{1}{2}}\\rho^{\\frac{1}{2}}e^{\\frac{i(\\theta+\\varphi)}{2}}\n\\]\nThe phase angle is shown in the below table:\n\\begin{center}\n    \\begin{tikzpicture}\n    \\draw[black, ultra thin] (-3,0) -- (3,0) ; \n    \\draw[black, ultra thin] (0,-1) -- (0,1) ;\n    \\draw[black, very thick] (-1,0) -- (-3,0) ;\n    \\draw[black, very thick] (1,0) -- (3,0) ;\n    \\filldraw[black] (-1,0) circle (1.2pt) node[anchor=north] {\\scriptsize $-1$} ;\n    \\filldraw[black] (1,0) circle (1.2pt) node[anchor=north] {\\scriptsize $1$} ;\n    \\filldraw[black] (2,0.1) circle (0.8pt) node[anchor=south] {\\scriptsize $A$} ;\n    \\filldraw[black] (0,0) circle (1.2pt) node[anchor=south west] {\\scriptsize $O$} ;\n    \\filldraw[black] (-2,0.1) circle (0.8pt) node[anchor=south] {\\scriptsize $C$} ;\n    \\filldraw[black] (-2,-0.1) circle (0.8pt) node[anchor=north] {\\scriptsize $D$} ;\n    \\filldraw[black] (2,-0.1) circle (0.8pt) node[anchor=north] {\\scriptsize $B$} ;\n    \\end{tikzpicture} \n\\end{center}\n\\begin{center}\n    \\begin{tabular}{>{\\centering\\arraybackslash}p{1.5cm} >{\\centering\\arraybackslash}p{1.5cm} >{\\centering\\arraybackslash}p{1.5cm} >{\\centering\\arraybackslash}p{1.5cm}}\n    \\hline\n    Point & $\\theta$ & $\\varphi$ & $(\\theta+\\varphi)/2$ \\\\\n    \\hline\n    $A$ & $0$ & $0$ & $0$\\\\\n    $B$ & $0$ & $2\\pi$ & $\\pi$ \\\\\n    $C$ & $\\pi$ & $\\pi$ & $\\pi$ \\\\\n    $D$ & $-\\pi$ & $\\pi$ & $0$ \\\\\n    $O$ & $\\pi$ & $0$ & $\\pi/2$\n    \\end{tabular}\n\\end{center}\nwhich is obvious that the function is single-valued.\n\n\\paragraph{11.6.3}\n\\[\n\\frac{f_1(z)}{f_2(z)}=\n\\frac{\\sum_{n=0}^\\infty\\frac{f_1^{(n)}(z_0)}{n!}(z-z_0)^n}{\\sum_{n=0}^\\infty\\frac{f_2^{(n)}(z_0)}{n!}(z-z_0)^n}=\\frac{f_1(z_0)+\\cdots}{f_2'(z_0)(z-z_0)+\\cdots}\n\\]\nbecause $f_2(z_0)=0$. So\n\\[\na_{-1}=\\lim_{z\\to z_0}(z-z_0)\\frac{f_1(z)}{f_2(z)}=\\lim_{z\\to z_0}\\frac{f_1(z_0)+\\cdots}{f_2'(z_0)+\\cdots}=\\frac{f_1(z_0)}{f_2'(z_0)}\n\\]\n\n\\paragraph{11.6.4}\nLet the case in Example 11.6.4 be the first case, and the case in Exercise 11.6.2 be the second case. Then the phase angles and the function values in the four quadrants have the relation as below:\n\\begin{center}\n    \\begin{tikzpicture}\n        \\draw[black, thin] (-3,0) -- (3,0) ;\n        \\draw[black, thin] (0,-2) -- (0,2) ;\n        \\node[align=center] at (1.5,1) {$\\theta_1=\\theta_2$\\\\$\\varphi_1=\\varphi_2$\\\\$f_1(z)=f_2(z)$} ;\n        \\node[align=center] at (-1.5,1) {$\\theta_1=\\theta_2$\\\\$\\varphi_1=\\varphi_2$\\\\$f_1(z)=f_2(z)$} ;\n        \\node[align=center] at (-1.5,-1) {$\\theta_1=\\theta_2+2\\pi$\\\\$\\varphi_1=\\varphi_2$\\\\$f_1(z)=-f_2(z)$} ;\n        \\node[align=center] at (1.5,-1) {$\\theta_1=\\theta_2$\\\\$\\varphi_1=\\varphi_2-2\\pi$\\\\$f_1(z)=-f_2(z)$} ;\n    \\end{tikzpicture}\n\\end{center}\nSo the two cases have the same values in the upper half-plane, and with opposite signs in the lower half-plane.\n\n\\paragraph{11.6.5}\n\\begin{center}\n    \\begin{tabular}{>{\\centering\\arraybackslash}p{1.5cm} >{\\centering\\arraybackslash}p{2cm} >{\\centering\\arraybackslash}p{1.5cm}}\n    \\hline\n    Point & Type & Order \\\\\n    \\hline\n    $0$ & branch point & $12$ \\\\\n    $2$ & branch point & $2$ \\\\\n    $3$ & pole & $3$  \\\\\n    $\\infty$ & branch point & $12$ \n    \\end{tabular}\n\\end{center}\nwhere $12$ comes from the least common multiple of $3$ and $4$, and the property at infinity is identified by substituting $z=t^{-1}$:\n\\[\nt^{\\frac{1}{3}}+t^{\\frac{1}{4}}(1-3t)^{-3}\\,t^{3}+(1-2t)^{\\frac{1}{2}}\\,t^{-\\frac{1}{2}}\n\\]\n\n\\paragraph{11.6.6}\n\\[\nF(z)=\\ln(z+i)+\\ln(z-i)\n\\]\n\\[\nF(i,-2)-F(0,0)=\\ln(2\\sqrt{2}e^{i\\frac{\\pi}{4}})+\\ln(2e^{-i\\frac{\\pi}{2}})=\\ln(4\\sqrt{2})-i\\frac{\\pi}{4}\n\\]\nso\n\\[\nF(i,-2)=\\ln(4\\sqrt{2})-\\frac{9i\\pi}{4}\n\\]\n\n\\paragraph{11.6.7}\n\\[\n-1=e^{(1+2n)i\\pi}\n\\]\n\\[\n\\ln(-1)=(1+2n)i\\pi\n\\]\nwhere $n$ is an integer.\n\n\\paragraph{11.6.8}\nAt $z=0$, \n\\[\n\\sum_{n=0}^\\infty\\binom{m}{n}z^n=1\n\\]\nso the function $f(z)=(1+z)^m$ must take the branch in which $f(0)=1$. An appropriate branch cut is from $(-1,0)$ to $(-\\infty,0)$, while all the branch cuts starting from $(-1,0)$ and lying in the left side of $x=-1$ are valid. If $|z|\\geq1$, then it will contain a part of the branch cut and therefore result in discontinuity, while the expansion contains no discontinuity, so the domain must be restricted to $|z|<1$.\n\n\\paragraph{11.6.9}\nIf the branch of $f(z)=(1+z)^m$ at $z=0$ has the value\n\\[\n\\left[f(0)\\right]_{branch\\,N}=e^{m\\cdot 2N\\pi i}\n\\]\nwhere $N$ is an integer, then at every point in the plane,\n\\[\n\\frac{\\left[f(z)\\right]_{branch\\,N}}{\\left[f(z)\\right]_{branch\\,0}}=e^{2mN\\pi i}\n\\]\nso the expansion becomes\n\\[\n\\left[(1+z)^m\\right]_{branch\\,N}=\\sum_{z=0}^\\infty e^{2mN\\pi i}\\binom{m}{n}z^n\n\\]\n\n\\paragraph{11.6.10}\n(a)\n\\[\nf(z)=\\frac{1}{z-1}-\\frac{1}{z}=\\frac{1}{z-1}-\\frac{1}{1+(z-1)}\\]\n\\[=\\frac{1}{z-1}-\\sum_{n=0}^\\infty(-1)^n(z-1)^n=\\sum_{n=-1}^\\infty(-1)^{n+1}(z-1)^n\n\\]\nThe expansion holds in the range $0<|z-1|<1$.\n\\medskip\n\n(b)\n\\[\nf(z)=\\frac{1}{z-1}-\\frac{1}{z}=\\frac{1}{z-1}-\\frac{1}{(z-1)}\\frac{1}{1+(z-1)^{-1}}\\]\n\\[=\\frac{1}{z-1}-\\frac{1}{z-1}\\sum_{n=0}^\\infty(-1)^n(z-1)^{-n}=\\sum_{n=2}^\\infty(-1)^n(z-1)^{-n}\n\\]\nThe expansion holds in the range $|z-1|>1$.\n\n\\paragraph{11.6.11}\n(a) For $z=0$, \n\\[\nf_1(z)=\\int_0^\\infty dt=\\infty\n\\]\nFor $z\\neq0$,\n\\[\nf_1(z)=\\int_0^\\infty e^{-zt}dt=\\left[\\frac{e^{-zt}}{-z} \\right]_0^\\infty=\\frac{\\left[e^{-zt}\\right]_{t=\\infty}-1}{-z}\n\\]\nand note that\n\\[\n\\left[e^{-zt}\\right]_{t=\\infty}=\n\\begin{cases}\n0,\\qquad & \\mathfrak{Re}(z)>0\\\\\n\\infty,\\qquad & \\mathfrak{Re}(z)<0\n\\end{cases}\n\\]\nso the integral exists only for $\\mathfrak{Re}(z)>0$.\n\\medskip\n\n(b) For $\\mathfrak{Re}(z)>0$,\n\\[\nf_1(z)=\\frac{0-1}{-z}=\\frac{1}{z}\n\\]\n\n(c)\n\\[\n\\frac{1}{z}=\\frac{1}{-i+(z+i)}=\\frac{1}{(-i)}\\frac{1}{1+i(z+i)}\n\\]\n\\[\n=i\\sum_{n=0}^\\infty(-1)^n\\,i^n(z+i)^n\\]\n\\[=i\\sum_{n=0}^\\infty i^{-n}(z+i)^n\n\\]\nThe expansion is valid in $|z+i|<1$.\n\n\\section*{11.7 Calculus of Residues}\n\n\\paragraph{11.7.1 }\n(a)\n\\begin{alignat*}{3}\n    & z=ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to ia}\\frac{(z-ia)}{z^2+a^2}=\\lim_{z\\to ia}\\frac{1}{z+ia}=\\frac{1}{2ia}\\\\\n    & z=-ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to -ia}\\frac{(z+ia)}{z^2+a^2}=\\lim_{z\\to -ia}\\frac{1}{z-ia}=-\\frac{1}{2ia}\\\\\n\\end{alignat*}\n\n(b)\n\\begin{alignat*}{3}\n    & z=ia:\\qquad && \\textit{second-order pole,}\\qquad && a_{-1}=\\lim_{z\\to ia}\\left[\\frac{d}{dz}\\frac{(z-ia)^2}{(z^2+a^2)^2} \\right]=\\lim_{z\\to ia}\\left[\\frac{-2}{(z+ia)^3} \\right]=\\frac{1}{4ia^3}\\\\\n    & z=-ia:\\qquad && \\textit{second-order pole,}\\qquad && a_{-1}=\\lim_{z\\to -ia}\\left[\\frac{d}{dz}\\frac{(z+ia)^2}{(z^2+a^2)^2} \\right]=\\lim_{z\\to -ia}\\left[\\frac{-2}{(z-ia)^3} \\right]=-\\frac{1}{4ia^3}\n\\end{alignat*}\n\n(c)\n\\begin{alignat*}{3}\n    & z=ia:\\qquad && \\textit{second-order pole,}\\qquad && a_{-1}=\\lim_{z\\to ia}\\left[\\frac{d}{dz}\\frac{z^2(z-ia)^2}{(z^2+a^2)^2} \\right]=\\lim_{z\\to ia}\\frac{-2}{(1+\\frac{ia}{z})^3}\\frac{-ia}{z^2}=\\frac{1}{4ia}\\\\\n    & z=-ia:\\qquad && \\textit{second-order pole,}\\qquad && a_{-1}=\\lim_{z\\to -ia}\\left[\\frac{d}{dz}\\frac{z^2(z+ia)^2}{(z^2+a^2)^2} \\right]=\\lim_{z\\to -ia}\\frac{-2}{(1-\\frac{ia}{z})^3}\\frac{ia}{z^2}=-\\frac{1}{4ia}\n\\end{alignat*}\n\n(d)\n\\begin{alignat*}{3}\n    & z=0:\\qquad && \\textit{essential singularity,}\\qquad && a_{-1}=\\frac{\\sinh(\\frac{1}{a})}{a} \\\\\n    & z=ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to ia}\\frac{(z-ia)\\sin\\frac{1}{z}}{z^2+a^2}=\\lim_{z\\to ia}\\frac{\\sin\\frac{1}{z}}{z+ia}=\\frac{-\\sinh(\\frac{1}{a})}{2a}\\\\\n    & z=-ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to -ia}\\frac{(z+ia)\\sin\\frac{1}{z}}{z^2+a^2}=\\lim_{z\\to -ia}\\frac{\\sin\\frac{1}{z}}{z-ia}=\\frac{-\\sinh(\\frac{1}{a})}{2a}\n\\end{alignat*}\n\nThe residue at $z=0$ is obtained from the expansion:\n\\[\n\\frac{\\sin(\\frac{1}{z})}{z^2+a^2}=\\left(\\frac{1}{z}-\\frac{1}{3!z^3}+\\frac{1}{5!z^5}-\\cdots \\right)\\frac{1}{a^2}\\left(1-\\frac{z^2}{a^2}+\\frac{z^4}{a^4}-\\cdots \\right)\n\\]\n\nThe coefficient of $\\frac{1}{z}$ is \n\\[\na_{-1}=\\frac{1}{a}\\left(\\frac{1}{a}+\\frac{1}{3!a^3}+\\frac{1}{5!a^5}+\\cdots \\right)=\\frac{\\sinh(\\frac{1}{a})}{a}\n\\]\n\nNote that the sum of all the residues is zero, which confirms our answer.\n\\medskip\n\n(e)\n\\begin{alignat*}{3}\n    & z=ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to ia}\\frac{(z-ia)ze^{iz}}{z^2+a^2}=\\lim_{z\\to ia}\\frac{ze^{iz}}{z+ia}=\\frac{e^{-a}}{2}\\\\\n    & z=-ia:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to -ia}\\frac{(z+ia)ze^{iz}}{z^2+a^2}=\\lim_{z\\to -ia}\\frac{ze^{iz}}{z-ia}=\\frac{e^{a}}{2}\\\\\n    & z=\\infty:\\qquad && \\textit{essential singularity,}\\qquad && a_{-1}=-\\cosh a\n\\end{alignat*}\n\nThe residue at $z=\\infty$ is obtained by substituting $z=\\frac{1}{w}$,\\; $f(z)=g(w)$ and note that\n\\[\n\\oint\\displaylimits_Cf(z)dz=\\oint\\displaylimits_C-g(w)\\frac{dw}{w^2}\n\\]\n\nso the residue of $f(z)$ at $\\infty$ is the residue of $-\\frac{g(w)}{w^2}$ at $0$. From the expansion,\n\\[\n-\\frac{g(w)}{w^2}=\n-\\frac{1}{w^2}\\frac{\\frac{1}{w}e^{i\\frac{1}{w}}}{\\frac{1}{w^2}+a^2}=-\\frac{1}{w}\\left(1+\\frac{i}{w}+\\frac{-1}{2!w^2}+\\frac{-i}{3!w^3}+\\cdots \\right)\\left(1-a^2w^2+a^4w^4-\\cdots \\right)\n\\]\n\nThe coefficient of $\\frac{1}{w}$ is \n\\[\na_{-1}=-\\left(1+\\frac{a^2}{2!}+\\frac{a^4}{4!}+\\cdots \\right)=-\\cosh a\n\\]\n\nNote that the sum of all the residues is zero, which confirms our answer.\n\\medskip\n\n(f)\n\\begin{alignat*}{3}\n    & z=a:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to a}\\frac{(z-a)ze^{iz}}{z^2-a^2}=\\lim_{z\\to a}\\frac{ze^{iz}}{z+a}=\\frac{e^{ia}}{2}\\\\\n    & z=-a:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to -a}\\frac{(z+a)ze^{iz}}{z^2-a^2}=\\lim_{z\\to -a}\\frac{ze^{iz}}{z-a}=\\frac{e^{-ia}}{2}\\\\\n    & z=\\infty:\\qquad && \\textit{essential singularity,}\\qquad && a_{-1}=-\\cos a\n\\end{alignat*}\n\nThe residue at $\\infty$ is obtained from the expansion:\n\\[\n-\\frac{g(w)}{w^2}=\n-\\frac{1}{w^2}\\frac{\\frac{1}{w}e^{i\\frac{1}{w}}}{\\frac{1}{w^2}-a^2}=-\\frac{1}{w}\\left(1+\\frac{i}{w}+\\frac{-1}{2!w^2}+\\frac{-i}{3!w^3}+\\cdots \\right)\\left(1+a^2w^2+a^4w^4+\\cdots \\right)\n\\]\n\nThe coefficient of $\\frac{1}{w}$ is \n\\[\na_{-1}=-\\left(1-\\frac{a^2}{2!}+\\frac{a^4}{4!}-\\cdots \\right)=-\\cos a\n\\]\n\nNote that the sum of all the residues is zero, which confirms our answer.\n\\medskip\n\n(g)\n\\begin{alignat*}{3}\n    & z=a:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to a}\\frac{(z-a)e^{iz}}{z^2-a^2}=\\lim_{z\\to a}\\frac{e^{iz}}{z+a}=\\frac{e^{ia}}{2a}\\\\\n    & z=-a:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to -a}\\frac{(z+a)e^{iz}}{z^2-a^2}=\\lim_{z\\to -a}\\frac{e^{iz}}{z-a}=-\\frac{e^{-ia}}{2a}\\\\\n    & z=\\infty:\\qquad && \\textit{essential singularity,}\\qquad && a_{-1}=-\\frac{i\\sin a}{a}\n\\end{alignat*}\n\nThe residue at $\\infty$ is obtained from the expansion:\n\\[\n-\\frac{g(w)}{w^2}=\n-\\frac{1}{w^2}\\frac{e^{i\\frac{1}{w}}}{\\frac{1}{w^2}-a^2}=-\\left(1+\\frac{i}{w}+\\frac{-1}{2!w^2}+\\frac{-i}{3!w^3}+\\cdots \\right)\\left(1+a^2w^2+a^4w^4+\\cdots \\right)\n\\]\n\nThe coefficient of $\\frac{1}{w}$ is \n\\[\na_{-1}=-\\frac{i}{a}\\left(a-\\frac{a^3}{3!}+\\frac{a^5}{5!}-\\cdots \\right)=-\\frac{i\\sin a}{a}\n\\]\n\nNote that the sum of all the residues is zero, which confirms our answer.\n\\medskip\n\n(h)\n\\begin{alignat*}{3}\n    & z=-1:\\qquad && \\textit{simple pole,}\\qquad && a_{-1}=\\lim_{z\\to-1}\\frac{(z+1)z^{-k}}{z+1}=(-1)^{-k}\\\\\n    & z=0:\\qquad && \\textit{branch point,} && \n\\end{alignat*}\n\n\\paragraph{11.7.2}\n\\begin{alignat*}{2}\n    & z=0:\\qquad && \\frac{\\pi\\cot\\pi z}{z(z+1)}=\\frac{\\pi\\frac{\\cos\\pi z}{\\sin\\pi z}}{z(z+1)}=\\pi\\frac{1-\\frac{(\\pi z)^2}{2!}+\\cdots}{\\pi z-\\frac{(\\pi z)^3}{3!}+\\cdots}\\cdot\\frac{1-z+z^2-\\cdots}{z}=\\frac{1}{z^2}-\\frac{1}{z}+\\sum_{n=0}^\\infty a_nz^n\\\\\n    & z=1:\\qquad && \\frac{\\pi\\cot\\pi z}{z(z+1)}=\\frac{\\pi\\cot\\pi t}{(t-1)t}=\\pi\\frac{1-\\frac{(\\pi t)^2}{2!}+\\cdots}{\\pi t-\\frac{(\\pi t)^3}{3!}+\\cdots}\\cdot\\frac{-(1+t+t^2+\\cdots)}{t}=-\\frac{1}{t^2}-\\frac{1}{t}+\\sum_{n=0}^\\infty b_n t^n\n\\end{alignat*}\nwhere we substitute $t$ for $z+1$ in the second equation, so both the residues at $z=0$ and $z=-1$ are  equals to $-1$.\n\n\\paragraph{11.7.3}\n\\[\n\\dashint_{-\\infty}^x\\frac{e^t}{t}dt=\n\\lim_{\\delta\\to0}\\left[\\int_{-\\infty}^{-\\delta}\\frac{e^t}{t}dt+\\int_{\\delta}^x\\frac{e^t}{t}dt \\right]\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[-\\int_{\\delta}^{\\infty}\\frac{e^{-t}}{t}dt+\\int_{\\delta}^x\\frac{e^t}{t}dt\n \\right]\\]\n\\[ =\\lim_{\\delta\\to0}\\left[\\int_{\\delta}^x\\frac{e^t-e^{-t}}{t}dt+\\int_x^\\infty\\frac{e^{-t}}{t}dt \\right]\n\\]\nwhere the first integral exists because $\\frac{e^t-e^{-t}}{t}$ is finite as  $t\\to0$, and the second integral exists because $\\int_x^\\infty e^{-t}dt$ is finite.\n\n\n\n\\paragraph{11.7.4}\n\\[\n\\dashint_0^\\infty\\frac{x^{-p}}{x-1}dx=\\lim_{\\delta\\to0}\\left[\\int_0^{1-\\delta}\\frac{x^{-p}}{x-1}dx+\\int_{1+\\delta}^\\infty\\frac{x^{-p}}{x-1}dx \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[-\\int_0^{1-\\delta}x^{-p}\\sum_{n=0}^\\infty x^ndx+\\int_{1+\\delta}^\\infty x^{-p}x^{-1}\\sum_{n=0}^\\infty x^{-n}dx \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[-\\sum_{n=0}^\\infty\\frac{(1-\\delta)^{-p+n+1}}{-p+n+1}+\\sum_{n=0}^\\infty\\frac{-(1+\\delta)^{-p-n}}{-p-n} \\right]\n\\]\n\\[\n=\\sum_{n=0}^\\infty\\frac{1}{p-n-1}+\\sum_{n=0}^\\infty\\frac{1}{p+n}\n\\]\n\\[\n=\\frac{1}{p}+\\sum_{n=1}^\\infty\\frac{2p}{p^2-n^2}=\\pi\\cot \\pi p\n\\]\nwhere we use Equation 11.81 in the last equation:\n\\[\n\\cot \\pi p=\\frac{1}{\\pi p}+2\\pi p\\sum_{n=1}^\\infty\\frac{1}{\\pi^2p^2-\\pi^2n^2}=\\frac{1}{\\pi}\\left(\\frac{1}{p}+\\sum_{n=1}^\\infty\\frac{2p}{p^2-n^2} \\right)\n\\]\n\n\\paragraph{11.7.5}\nThe conditions for Equation 1.88 to hold is that $f(z)$ being an entire function, and $\\frac{f'(z)}{f(z)}$ being analytic at $z=0$. If $f(z)=\\sin x$, then $\\left[\\frac{f'(z)}{f(z)}\\right]_{z\\to0}=\\left[\\frac{\\cos z}{\\sin z}\\right]_{z\\to0}=\\infty$, which does not meet the second condition. If $f(z)=\\frac{\\sin z}{z}$, then $\\left[\\frac{\\sin z}{z}\\right]_{z\\to0}=1$, so $f(z)$ is an entire function, and \\[\n\\lim_{z\\to0}\\frac{f'(z)}{f(z)}=\\lim_{z\\to0}\\frac{\\frac{\\cos z}{z}-\\frac{\\sin z}{z^2}}{\\frac{\\sin z}{z}}=\\lim_{z\\to0}\\frac{(\\frac{1}{z}-\\frac{z}{2!}+\\cdots)-(\\frac{1}{z}-\\frac{z}{3!}+\\cdots)}{1-\\frac{z^2}{3!}+\\cdots}=\\lim_{z\\to0}\\frac{-\\frac{1}{6}z+\\cdots}{1+\\cdots}=0\n\\]\nso $\\frac{f'(z)}{f(z)}$ is analytic at $0$. Then we can use Equation 11.88, and note that the zeros of $f(z)$ is $z_n=n\\pi$ for all positive and negative integers except for $0$:\n\\[\n\\frac{\\sin z}{z}=1\\cdot e^{0}\\cdot \\prod_{\\substack{n=-\\infty\\\\n\\neq0}}^\\infty\\left(1-\\frac{z}{n\\pi}\\right)e^{\\frac{z}{n\\pi}}\\]\n\\[=\\prod_{n=1}^\\infty\\left(1-\\frac{z}{n\\pi}\\right)e^{\\frac{z}{n\\pi}}\\left(1+\\frac{z}{n\\pi}\\right)e^{-\\frac{z}{n\\pi}}\n\\]\n\\[\n=\\prod_{n=1}^\\infty\\left(1-\\frac{z^2}{n^2\\pi^2}\\right)\n\\]\nso\n\\[\n\\sin z=z\\prod_{n=1}^\\infty\\left(1-\\frac{z^2}{n^2\\pi^2}\\right)\n\\]\n\n\\paragraph{11.7.6}\nFor a polynomial $\\sum_{k=1}^n a_kz^k$, let $f(z)=a_nz^n$, and $g(z)=\\sum_{k=1}^{n-1}a_kz^k$. On the contour of radius $R$ which is sufficiently large, we have $|f(z)|>|g(z)|$, so by Rouché’s theorem, the polynomial which is $f(z)+g(z)$, has the same number of zeros with $f(z)$, which is $n$. \n\n\\paragraph{11.7.7}\nFirst consider the contour $|z|=1$, and let $f(z)=10$, $g(z)=z^6-4z^3$ (more precisely the radius should be $\\lim_{\\delta\\to0^+}(1-\\delta)$ to eliminate the zero on $|z|=1$). Because $|f(z)|>|g(z)|$ on $|z|=1$, by Rouché’s theorem, $z^6-4z^3+10=f(z)+g(z)$ has the same number of zeros with $f(z)$, which is no zero.\n\nThen consider the contour $|z|=2$, and let $f(z)=z^6$, $g(z)=-4z^3+10$. Because $|f(z)|>|g(z)|$ on $|z|=2$, by Rouché’s theorem, $z^6-4z^3+10=f(z)+g(z)$ has the same number of zeros with $f(z)$, which is six zeros. By the fundamental theorem of algebra, $z^6-4z^3+10$ has six zeros, so all the zeros lie between $|z|=1$ and $|z|=2$.\n\n\\paragraph{11.7.8}\n$\\sec(0)=1$, so the Mittag-Leffler’s theorem is applicable. The poles of $\\sec z$ are $z_n=\\pm\\frac{(2n+1)\\pi}{2}$, $n$ is integer from $0$ to $\\infty$. The residues are:\n\\[\nb_n=\\lim_{z\\to\\pm\\frac{(2n+1)\\pi}{2}}\\frac{z\\mp\\frac{(2n+1)\\pi}{2}}{\\cos z}=\\frac{1}{-\\sin z}\\Big|_{z=\\pm\\frac{(2n+1)\\pi}{2}}=\\mp(-1)^n\n\\]\nso\n\\[\n\\sec z=1-\\sum_{n=0}^\\infty(-1)^n\\left(\\frac{1}{z-\\frac{(2n+1)\\pi}{2}}+\\frac{1}{\\frac{(2n+1)\\pi}{2}} \\right)+\\sum_{n=0}^\\infty(-1)^n\\left(\\frac{1}{z+\\frac{(2n+1)\\pi}{2}}+\\frac{1}{-\\frac{(2n+1)\\pi}{2}} \\right)\n\\]\n\\[\n=\\sum_{n=0}^\\infty(-1)^n\\frac{(2n+1)\\pi}{\\left(\\frac{2n+1}{2}\\right)^2\\pi^2-z^2}+1-\\frac{4}{\\pi}\\sum_{n=0}^\\infty(-1)^n\\frac{1}{2n+1}\n\\]\n\\[\n=\\pi\\left(\\frac{1}{(\\frac{\\pi}{2})^2-z^2}-\\frac{3}{(\\frac{3\\pi}{2})^2-z^2}+\\frac{5}{(\\frac{5\\pi}{2})^2-z^2}-\\cdots \\right)\n\\]\nNote that \n\\[\n1-\\frac{4}{\\pi}\\sum_{n=0}^\\infty(-1)^n\\frac{1}{2n+1}=1-\\frac{4}{\\pi}\\cdot\\frac{\\pi}{4}=0\n\\]\nfrom the results of Exercise 1.3.2.\n\\medskip\n\nLet $f(z)=\\csc z-\\frac{1}{z}$, then\n\\[\n\\lim_{z\\to0}f(z)=\\lim_{z\\to0}\\left[\\frac{1}{z}+\\frac{z}{3!}+\\cdots-\\frac{1}{z} \\right]=0\n\\]\nso $f(z)$ is analytic at $z=0$. The poles of $f(z)$ are $z_n=\\pm n\\pi$, where $n\\neq0$. The residues are:\n\\[\nb_n=\\lim_{z\\to\\pm n\\pi}\\frac{z\\mp n\\pi}{\\sin z}=\\lim_{z\\to\\pm n\\pi}\\frac{1}{\\cos z}=(-1)^n\n\\]\nso\n\\[\n\\csc z-\\frac{1}{z}=\\sum_{n=1}^\\infty(-1)^n\\left(\\frac{1}{z-n\\pi}+\\frac{1}{n\\pi} \\right)+\\sum_{n=1}^\\infty(-1)^n\\left(\\frac{1}{z+n\\pi}+\\frac{1}{-n\\pi} \\right)\n\\]\n\\[\n=\\sum_{n=1}^\\infty(-1)^n\\frac{2z}{z^2-n^2\\pi^2}\n\\]\nso\n\\[\n\\csc z=\\frac{1}{z}+\\sum_{n=1}^\\infty(-1)^n\\frac{2z}{z^2-n^2\\pi^2}\n\\]\n\\[\n=\\frac{1}{z}-2z\\left(\\frac{1}{z^2-\\pi^2}-\\frac{1}{z^2-(2\\pi)^2}+\\frac{1}{z^2-(3\\pi)^2}-\\cdots \\right)\n\\]\n\n\\paragraph{11.7.9}\n$f(z)=(z-1)(z-2)z^{-1}$, so it has two zeros at $1,2$, and a simple pole at $0$. Differentiate, \n\\[\nf'(z)=(z-2)z^{-1}+(z-1)z^{-1}-(z-1)(z-2)z^{-2}\n\\]\n\\[\n\\frac{f'(z)}{f(z)}=\\frac{1}{z-1}+\\frac{1}{z-2}-\\frac{1}{z}\n\\]\nso it is clear that if a contour $C$ encircle $N_f$ zeros and $P_f$ poles (the multiplicity and order of all the zeros and poles are $1$), then\n\\[\n\\oint\\displaylimits_C\\frac{f'(z)}{f(z)}dz=2\\pi i(N_f-P_f)\n\\]\n\n\\paragraph{11.7.10}\nLet $z=e^{i\\theta}$, then $dz=e^{i\\theta}d\\theta$, and\n\\[\n\\int\\displaylimits_{\\substack{|z|=1\\\\semicircle}}z^{-2}dz=\\int\\displaylimits_0^\\pi e^{-2i\\theta}e^{i\\theta}d\\theta=\\left[ie^{-i\\theta} \\right]_0^\\pi=-2i\n\\]\nbut\n\\[\n\\oint\\displaylimits_{|z|=1}z^{-2}dz=0\n\\]\nso the equation does not necessary hold for poles of higher order.\n\n\\paragraph{11.7.11}\n(a)\n\\[\n\\lim_{\\delta\\to0}\\left[\\int_{-\\infty}^{x_0-\\delta}\\frac{a_{-3}}{(x-x_0)^3}dx+\\int_{x_0+\\delta}^\\infty\\frac{a_{-3}}{(x-x_0)^3}dx \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[\\frac{a_{-3}}{-2(x-x_0)^2}\\Big|_{-\\infty}^{x_0-\\delta}+\\frac{a_{-3}}{-2(x-x_0)^2}\\Big|_{x_0+\\delta}^\\infty \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[\\frac{a_{-3}}{-2\\delta^2}-\\frac{a_{-3}}{-2\\delta^2}\\right]=0\n\\]\nso the integration of $\\frac{a_{-3}}{(x-x_0)^3}$ is cancelled out.\n\\[\n\\lim_{\\delta\\to0}\\left[\\int_{-\\infty}^{x_0-\\delta}\\frac{a_{-1}}{x-x_0}dx+\\int_{x_0+\\delta}^\\infty\\frac{a_{-1}}{x-x_0}dx \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[a_{-1}\\ln(x-x_0)\\Big|_{-\\infty}^{x_0-\\delta}+a_{-1}\\ln(x-x_0)\\Big|_{x_0+\\delta}^\\infty \\right]\n\\]\n\\[\n=\\lim_{\\delta\\to0}\\left[a_{-1}\\ln\\frac{-\\delta\\cdot\\infty}{-\\infty\\cdot\\delta} \\right]=0\n\\]\nso the integration of $\\frac{a_{-1}}{x-x_0}$ is cancelled out. $g(z)$ is analytic along the whole real axis, so the Cauchy principle value is finite.\n\\medskip\n\n(b)\nLet $z-z_0=re^{i\\theta}$, $dz=ire^{i\\theta}d\\theta$, then\n\\[\nI_{over}=\\int_\\pi^0\\left[\\frac{a_{-3}}{r^3e^{3i\\theta}}+\\frac{a_{-1}}{re^{i\\theta}}+a_0+\\cdots \\right]ire^{i\\theta}d\\theta\n\\]\n\\[\n=\\int_\\pi^0\\left(\\frac{ia_{-3}}{r^2e^{2i\\theta}}+ia_{-1}+ire^{i\\theta}a_0+\\cdots \\right)d\\theta\n\\]\n\\[\n=\\left[\\frac{a_{-3}}{-2r^2}e^{-2i\\theta}+ia_{-1}\\theta+re^{i\\theta}a_0+\\cdots \\right]_\\pi^0\n\\]\n\\[\n=-i\\pi a_{-1},\\qquad\\textit{when $r\\to0$}\n\\]\nsimilarly,\n\\[\nI_{under}=\\left[\\frac{a_{-3}}{-2r^2}e^{-2i\\theta}+ia_{-1}\\theta+re^{i\\theta}a_0+\\cdots \\right]_\\pi^{2\\pi}\n\\]\n\\[\n=i\\pi a_{-1},\\qquad\\textit{when $r\\to0$}\n\\]\n\n\\paragraph{11.7.12}\n(The problem requires techniques from the next section, especially Equation 11.102)\n\\medskip\n\n(a) (The integral should be a normal integral, not a Cauchy principle value.) The function $\\frac{e^{izs}}{z-i\\varepsilon}$ has a simple pole at $z=i\\varepsilon$ with residue $e^{-\\varepsilon s}$. For $\\varepsilon\\to0^+$, the pole is in the upper half-plane, and the residue is $\\lim_{\\varepsilon\\to0}e^{-\\varepsilon s}=1$.\n\nFor $s<0$, let the contour be a semicircle in the lower half-plane, with the radius $R\\to\\infty$. Then\n\\[\n\\oint\\displaylimits_C\\frac{e^{izs}}{z-i\\varepsilon}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx+\\int\\displaylimits_{C_R}\\frac{e^{izs}}{z-i\\varepsilon}dz=0\n\\]\nBecause $\\lim_{|z|\\to\\infty}\\frac{e^{izs}}{z-i\\varepsilon}=0$ in the lower half-plane, so $\\int_{C_R}\\frac{e^{izs}}{z-i\\varepsilon}dz=0$ by Equation 11.102. Therefore, \n\\[\n\\int_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx=0\n\\]\nand \n\\[\nu(s)=\\frac{1}{2\\pi i}\\int_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx=0,\\qquad\\textit{for $s<0$}\n\\]\n\nFor $s>0$, let the contour be a semicircle in the upper half-plane, with the radius $R\\to\\infty$. Then\n\\[\n\\oint\\displaylimits_C\\frac{e^{izs}}{z-i\\varepsilon}dz=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx+\\int\\displaylimits_{C_R}\\frac{e^{izs}}{z-i\\varepsilon}dz=2\\pi i\n\\]\nBecause $\\lim_{|z|\\to\\infty}\\frac{e^{izs}}{z-i\\varepsilon}=0$ in the upper half-plane, so $\\int_{C_R}\\frac{e^{izs}}{z-i\\varepsilon}dz=0$ by Equation 11.102. Therefore,\n\\[\n\\int_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx=2\\pi i\n\\]\nand\n\\[\nu(s)=\\frac{1}{2\\pi i}\\int_{-\\infty}^\\infty\\frac{e^{ixs}}{x-i\\varepsilon}dx=1\\qquad\\textit{for $s>0$}\n\\]\n\n(b)\nThe function $\\frac{e^{izs}}{z}$ has a simple pole at $z=0$ with residue $1$.\nFor $s<0$, let the contour be a semicircle in the lower half-plane with radius $R\\to\\infty$, and circumvent $z=0$ by another semicircle with radius $r\\to0$. Then\n\\[\n\\oint\\displaylimits_C\\frac{e^{izs}}{z}dz=\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx+\\int\\displaylimits_{C_r}\\frac{e^{izs}}{z}dz+\\int\\displaylimits_{C_R}\\frac{e^{izs}}{z}dz=0\n\\]\nBecause $\\lim_{|z|\\to\\infty}\\frac{e^{izs}}{z}=0$ in the lower half-plane, so $\\int_{C_R}\\frac{e^{izs}}{z}dz=0$ by Equation 11.102. Because $\\frac{e^{izs}}{z}$ has a simple pole at $z=0$ with residue $1$, so $\\int_{C_r}\\frac{e^{izs}}{z}dz=\\pi i$ by Equation 11.76. Therefore,\n\\[\n\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx=-\\pi i\n\\]\nand\n\\[\nu(s)=\\frac{1}{2}+\\frac{1}{2\\pi i}\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx=0\\qquad\\textit{for $s<0$}\n\\]\n\nFor $s>0$, let the contour be a semicircle in the upper half-plane with radius $R\\to\\infty$, and circumvent $z=0$ by another semicircle with radius $r\\to0$. Then\n\\[\n\\oint\\displaylimits_C\\frac{e^{izs}}{z}dz=\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx+\\int\\displaylimits_{C_r}\\frac{e^{izs}}{z}dz+\\int\\displaylimits_{C_R}\\frac{e^{izs}}{z}dz=0\n\\]\nBecause $\\lim_{|z|\\to\\infty}\\frac{e^{izs}}{z}=0$ in the upper half-plane, so $\\int_{C_R}\\frac{e^{izs}}{z}dz=0$ by Equation 11.102. Because $\\frac{e^{izs}}{z}$ has a simple pole at $z=0$ with residue $1$, so $\\int_{C_r}\\frac{e^{izs}}{z}dz=-\\pi i$ by Equation 11.75. Therefore,\n\\[\n\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx=\\pi i\n\\]\nand\n\\[\nu(s)=\\frac{1}{2}+\\frac{1}{2\\pi i}\\dashint_{-\\infty}^\\infty\\frac{e^{ixs}}{x}dx=1\\qquad\\textit{for $s>0$}\n\\]\n\n\\section*{11.8 Evaluation of Definite Integrals}\n\n\\paragraph{11.8.1}\nLet $z=e^{i\\theta}$, then $dz=ie^{i\\theta}d\\theta=izd\\theta$. and\n\\[\n\\int\\displaylimits_{0}^{2\\pi}\\frac{d\\theta}{a+b\\cos\\theta}=\\oint\\displaylimits_{|z|=1}\\frac{-iz^{-1}dz}{a+b\\cdot\\frac{z+z^{-1}}{2}}=\\frac{-2i}{b}\\oint\\displaylimits_{|z|=1}\\frac{dz}{z^2+\\frac{2a}{b}z+1}=\\frac{-2i}{b}\\oint\\displaylimits_{|z|=1}\\frac{dz}{(z-\\alpha)(z-\\beta)}\n\\]\nNote that $\\alpha\\beta=1$ and $\\alpha\\neq\\beta$, so only one of the roots is in the unit circle, without loss of generality let it be $\\alpha$. Then the residue at $z=\\alpha$ is\n\\[\nresidue=\\frac{1}{\\alpha-\\beta}=\\frac{1}{\\sqrt{(\\alpha+\\beta)^2-4\\alpha\\beta}}=\\frac{1}{\\sqrt{(-\\frac{2a}{b})^2-4}}=\\frac{b}{2\\sqrt{a^2-b^2}}\n\\]\nSo the integral is\n\\[\nI=\\frac{-2i}{b}\\cdot2\\pi i\\cdot\\frac{b}{2\\sqrt{a^2-b^2}}=\\frac{2\\pi}{\\sqrt{a^2-b^2}}\n\\]\nNote that replacing $b$ with $-b$ will not change the result.\n\\medskip\n\nFor the case of $\\sin\\theta$, let $\\theta=\\theta'+\\frac{\\pi}{2}$, then $d\\theta=d\\theta'$, and $\\sin\\theta=\\cos\\theta'$, so\n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{d\\theta}{a+b\\sin\\theta}=\\int\\displaylimits_{-\\frac{\\pi}{2}}^{\\frac{3\\pi}{2}}\\frac{d\\theta'}{a+b\\cos\\theta'}=\\int\\displaylimits_{0}^{2\\pi}\\frac{d\\theta'}{a+b\\cos\\theta'}=\\frac{2\\pi}{\\sqrt{a^2-b^2}}\n\\]\nNote that because $\\cos\\theta$ is periodic, the integral will not change as long at the range of integration is $2\\pi$.\n\\smallskip\n\nIf $|b|>|a|$, then there will be a singularity at $\\theta=\\cos^{-1}\\pm\\frac{a}{b}$ or $\\theta=\\sin^{-1}\\pm\\frac{a}{b}$, and therefore the integral does not exists.\n\n\\paragraph{11.8.2}\nFrom Exercise 11.8.1, \n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{d\\theta}{a+\\cos\\theta}=\\frac{2\\pi}{(a^2-1)^{\\frac{1}{2}}}\n\\]\nDifferentiate with respect to $a$, we have\n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{-d\\theta}{(a+\\cos\\theta)^2}=\\frac{-2\\pi a}{(a^2-1)^{\\frac{3}{2}}}\n\\]\nso\n\\[\n\\int\\displaylimits_0^{\\pi}\\frac{d\\theta}{(a+\\cos\\theta)^2}=\\frac{1}{2}\\cdot\\int\\displaylimits_0^{2\\pi}\\frac{d\\theta}{(a+\\cos\\theta)^2}=\\frac{\\pi a}{(a^2-1)^{\\frac{3}{2}}}\n\\]\n\n\\paragraph{11.8.3}\nFor $|t|<1$, we have $1+t^2>|2t|$, so we can use the results from Exercise 11.8.1:\n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{d\\theta}{(1+t^2)-2t\\cos\\theta}=\\frac{2\\pi}{\\sqrt{(1+t^2)^2-(2t)^2}}=\\frac{2\\pi}{1-t^2}\n\\]\nFor $|t|>1$, we still have $1+t^2>|2t|$, but the integral becomes\n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{d\\theta}{(1+t^2)-2t\\cos\\theta}=\\frac{2\\pi}{\\sqrt{(1+t^2)^2-(2t)^2}}=\\frac{2\\pi}{t^2-1}\n\\]\nFor $|t|=1$, there will be a singularity at $\\theta=0$ or $\\theta=\\pi$, and therefore the integral does not exists.\n\n\\paragraph{11.8.4}\nLet $z=e^{i\\theta}$, then\n\\[\n\\int\\displaylimits_0^{2\\pi}\\frac{\\cos3\\theta\\,d\\theta}{5-4\\cos\\theta}=\\oint\\displaylimits_{|z|=1}\\frac{\\frac{z^3+z^{-3}}{2}\\cdot(-iz^{-1}dz)}{5-4\\frac{z+z^{-1}}{2}}=\\frac{i}{2}\\oint\\displaylimits_{|z|=1}\\frac{(z^6+1)}{z^3(2z-1)(z-2)}dz\n\\]\nThe function has a third pole at $z=0$ and a simple pole at $z=\\frac{1}{2}$ in the unit circle. The residue of $z=0$ is easier to obtained from the expansion:\n\\[\n\\frac{(1+z^6)(1+2z+4z^2+\\cdots)(1+\\frac{z}{2}+\\frac{z^2}{4}+\\cdots)}{2z^3}=\\frac{1}{2}z^{-3}+\\frac{5}{4}z^{-2}+\\frac{21}{8}z^{-1}+\\cdots\n\\]\nso\n\\[\nresidue_{z=0}=\\frac{21}{8}\n\\]\nThe residue at $z=\\frac{1}{2}$ is\n\\[\nresidue_{z=\\frac{1}{2}}=\\frac{\\frac{1}{64}+1}{\\frac{1}{8}\\cdot2\\cdot(\\frac{1}{2}-2)}=-\\frac{65}{24}\n\\]\nso the integral is\n\\[\nI=\\frac{i}{2}\\cdot2\\pi i\\cdot(\\frac{21}{8}-\\frac{65}{24})=\\frac{\\pi}{12}\n\\]\n\n\\paragraph{11.8.5}\n\\[\n\\int\\displaylimits_0^\\pi\\cos^{2n}\\theta\\,d\\theta=\\frac{1}{2}\\int\\displaylimits_0^{2\\pi}\\cos^{2n}\\theta\\,d\\theta\n\\]\n\\[\n=\\frac{1}{2}\\oint\\displaylimits_{|z|=1}\\left(\\frac{z+z^{-1}}{2} \\right)^{2n}\\cdot(-iz^{-1}dz)\n\\]\n\\[\n=\\frac{-i}{2}\\oint\\displaylimits_{|z|=1}\\frac{z^{-1}dz}{2^{2n}}\\sum_{k=0}^{2n}\\binom{2n}{k}z^{2n-2k}\n\\]\n\\[\n=\\frac{-i}{2}\\oint\\displaylimits_{|z|=1}\\left[\\frac{1}{2^{2n}}\\binom{2n}{n}z^{-1}+\\sum_{k\\neq-1}a_kz^k \\right]dz\n\\]\n\\[\n=\\frac{-i}{2}\\cdot2\\pi i\\cdot\\frac{1}{2^{2n}}\\cdot\\frac{(2n)!}{n!\\cdot n!}\n\\]\n\\[\n=\\pi\\frac{(2n)!}{2^{2n}(n!)^2}=\\pi\\frac{(2n-1)!!}{(2n)!!}\n\\]\n\n\\paragraph{11.8.6}\n\\[\n\\left(1-e^{\\frac{2\\pi i}{3}}\\right)I-\\frac{2\\pi i}{3}e^{\\frac{2\\pi i}{3}}\\left(\\frac{2\\pi}{3\\sqrt{3}}\\right)=(2\\pi i)\\left(\\frac{\\pi i}{9}\\right)e^{-\\frac{2\\pi i}{3}}\n\\]\n\\[\n\\left(1+\\frac{1}{2}-\\frac{\\sqrt{3}i}{2}\\right)I=\\frac{4\\pi^2i}{9\\sqrt{3}}\\left(-\\frac{1}{2}+\\frac{\\sqrt{3}i}{2}\\right)-\\frac{2\\pi^2}{9}\\left(-\\frac{1}{2}-\\frac{\\sqrt{3}i}{2}\\right)\n\\]\n\\[\n\\left(\\frac{3}{2}-\\frac{\\sqrt{3}i}{2}\\right)I=-\\frac{\\pi^2}{9}+\\frac{\\sqrt{3}\\pi^2i}{27}\n\\]\n\\[\n\\sqrt{3}e^{-\\frac{\\pi i}{6}}I=\\frac{2\\sqrt{3}\\pi^2}{27}e^{\\frac{5\\pi i}{6}}\n\\]\n\\[\nI=-\\frac{2\\pi^2}{27}\n\\]\n\n\\paragraph{11.8.7}\nThe integral on small circle vanishes because\n\\[\n\\lim_{r\\to0}\\int_{C_r}\\frac{z^pdz}{z^2+1}=\n\\lim_{r\\to0}\\int_{2\\pi}^0\\frac{r^pe^{ip\\theta}(ire^{i\\theta }d\\theta)}{r^2e^{2i\\theta}+1}=\\lim_{r\\to0}\\int_{2\\pi}^0 r^{1+p}\\frac{ie^{i(p+1)\\theta}}{1+r^2e^{2i\\theta}}d\\theta=0\n\\]\nThe integral on large circle vanishes because\n\\[\n\\lim\\displaylimits_{|z|\\to\\infty}z\\cdot\\frac{z^p}{z^2+1}=\\lim_{|z|\\to\\infty }z^{p-1}=\\lim_{|z|\\to\\infty}\\frac{1}{z^{1-p}}=0\n\\]\nso from Equation 11.96,\n\\[\n\\lim_{R\\to\\infty}\\int_{C_R}\\frac{z^pdz}{z^2+1}=0\n\\]\nSimplifying Equation 11.115:\n\\[\n\\left(1-e^{2p\\pi i}\\right)I=(2\\pi i)\\frac{1}{2i}\\left(e^{\\frac{p\\pi i}{2}}-e^{\\frac{3p\\pi i}{2}} \\right)\n\\]\n\\[\n\\left(e^{-p\\pi i}-e^{p\\pi i} \\right)I=\\pi\\left(e^{-\\frac{p\\pi i}{2}-}e^{\\frac{p\\pi i}{2}} \\right)\n\\]\n\\[\nI=\\frac{\\pi\\cdot(-2i)\\sin(\\frac{p\\pi}{2})}{(-2i)\\sin(p\\pi)}=\\frac{\\pi\\sin(\\frac{p\\pi}{2})}{\\sin(p\\pi)}=\\frac{\\pi}{2\\cos(\\frac{p\\pi}{2})}\n\\]\n\n\\paragraph{11.8.8}\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos bx-\\cos ax}{x^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{(e^{ibx}+e^{-ibx})-(e^{iax}-e^{-iax})}{2x^2}dx=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ibx}-e^{iax}}{2x^2}dx+\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ibx}-e^{-iax}}{2x^2}dx\n\\]\nFor the first integral, the function has a simple pole at $z=0$ with residue\n\\[\n\\lim_{z\\to0}z\\cdot\\frac{e^{ibz}-e^{iaz}}{2z^2}=\\lim_{z\\to0}\\frac{ib\\,e^{ibz}-ia\\,e^{iaz}}{2}=\\frac{i(b-a)}{2}\n\\]\nand Equation 11.102 is applicable because the function vanishes when $|z|\\to\\infty$. Take the contour to be the semicircle with $R\\to\\infty$ in the upper half-plane, then\n\\[\n\\oint\\frac{e^{ibz}-e^{iaz}}{2z^2}dz=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ibx}-e^{iax}}{2x^2}dx+\\int\\displaylimits_{C_r}\\frac{e^{ibz}-e^{iaz}}{2z^2}dz+\\int\\displaylimits_{C_R}\\frac{e^{ibz}-e^{iaz}}{2z^2}dz\n\\]\n\\[\n=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ibx}-e^{iax}}{2x^2}dx-\\frac{2\\pi i}{2}\\cdot\\frac{i(b-a)}{2}+0=0\n\\]\nso\n\\[\n\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ibx}-e^{iax}}{2x^2}dx=\\frac{\\pi(a-b)}{2}\n\\]\nSimilarly, for the second integral, the function has a simple pole at $z=0$ with residue\n\\[\n\\lim_{z\\to0}z\\cdot\\frac{e^{-ibz}-e^{-iaz}}{2z^2}=\\lim_{z\\to0}\\frac{-ib\\,e^{-ibz}+ia\\,e^{-iaz}}{2}=\\frac{i(a-b)}{2}\n\\]\nand the lower half-plane version of Equation 11.102 is applicable because the function vanishes when $|z|\\to\\infty$. Take the contour to be the semicircle with $R\\to\\infty$ in the lower half-plane, then\n\\[\n\\oint\\frac{e^{-ibz}-e^{-iaz}}{2z^2}dz=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ibx}-e^{-iax}}{2x^2}dx+\\int\\displaylimits_{C_r}\\frac{e^{-ibz}-e^{-iaz}}{2z^2}dz+\\int\\displaylimits_{C_R}\\frac{e^{-ibz}-e^{-iaz}}{2z^2}dz\n\\]\n\\[\n=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ibx}-e^{-iax}}{2x^2}dx+\\frac{2\\pi i}{2}\\cdot\\frac{i(a-b)}{2}+0=0\n\\]\nso\n\\[\n\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ibx}-e^{-iax}}{2x^2}dx=\\frac{\\pi(a-b)}{2}\n\\]\nTherefore, \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos bx-\\cos ax}{x^2}dx=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ibx}-e^{iax}}{2x^2}dx+\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ibx}-e^{-iax}}{2x^2}dx=\\pi(a-b)\n\\]\n\n\\paragraph{11.8.9}\n(The answer should be $\\pi$, not $\\frac{\\pi}{2}$)\n\nUsing the results from Exercise 11.8.8 with $b=0$ and $a=2$, we have\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\sin^2x}{x^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{1-\\cos2x}{2x^2}dx=\\frac{1}{2}\\cdot\\pi(2-0)=\\pi\n\\]\n\n\\paragraph{11.8.10}\n\\[\n\\int\\displaylimits_0^\\infty\\frac{x\\sin x}{x^2+1}dx=\\int\\displaylimits_0^\\infty\\frac{x(e^{ix}-e^{-ix})}{(x^2+1)2i}dx=\\int\\displaylimits_0^\\infty\\frac{xe^{ix}}{2i(x^2+1)}dx-\\int\\displaylimits_0^{-\\infty}\\frac{xe^{ix}}{2i(x^2+1)}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+1)}dx\n\\]\nThe function has simple poles at $z=i,-i$, and the residue at $z=i$ is\n\\[\n\\lim_{z\\to i}\\frac{xe^{ix}}{2i(x+i)}=\\frac{1}{4ie}\n\\]\nand Equation 11.102 is applicable because the function vanishes when $|z|\\to\\infty$. Take the contour to be the semicircle with $R\\to\\infty$ in the upper half-plane, then\n\\[\n\\oint\\frac{ze^{iz}}{2i(z^2+1)}dz=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+1)}dx+0=2\\pi i\\cdot\\frac{1}{4ie}\n\\]\nso\n\\[\n\\int\\displaylimits_0^\\infty\\frac{x\\sin x}{x^2+1}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+1)}dx=\\frac{\\pi}{2e}\n\\]\n\n\\paragraph{11.8.11}\nUsing the results from Exercise 11.8.8 with $b=0$ and $a=t$, we have\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{2(1-\\cos\\omega t)}{\\omega^2}d\\omega=2\\cdot\\pi(t-0)=2\\pi t\n\\]\n\n\\paragraph{11.8.12}\n(a)\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x}{x^2+a^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}+e^{-ix}}{2(x^2+a^2)}=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{2(x^2+a^2)}dx+\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ix}}{2(x^2+a^2)}dx\n\\]\nThe function in the first integral has the residue $\\frac{e^{-a}}{4ia}$. Take the contour to be the semicircle in the upper half-plane and use Equation 11.102, we have\n\\[\n\\oint\\frac{e^{iz}}{2(z^2+a^2)}dz=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{2(x^2+a^2)}dx+0=2\\pi i\\cdot\\frac{e^{-a}}{4ia}=\\frac{\\pi e^{-a}}{2a}\n\\]\nThe function in the second integral has the residue $\\frac{e^{-a}}{-4ia}$. Take the contour to be the semicircle in the lower half-plane and use Equation 11.102, we have\n\\[\n\\oint\\frac{e^{-iz}}{2(z^2+a^2)}dz=-\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ix}}{2(x^2+a^2)}dx+0=2\\pi i\\cdot\\frac{e^{-a}}{-4ia}=-\\frac{\\pi e^{-a}}{2a}\n\\]\nso\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos x}{x^2+a^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{2(x^2+a^2)}dx+\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{-ix}}{2(x^2+a^2)}dx=\\frac{\\pi}{a}e^{-a}\n\\]\nIf $\\cos x$ is replaced by $\\cos kx$:\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos kx}{x^2+a^2}dx=k\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cos kx}{(kx)^2+(ka)^2}d(kx)=k\\cdot\\frac{\\pi}{ka}e^{-ka}=\\frac{\\pi}{a}e^{-a}\n\\]\n\n(b)\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{x\\sin x}{x^2+a^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{x(e^{ix}-e^{-ix})}{2i(x^2+a^2)}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+a^2)}dx-\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{-ix}}{2i(x^2+a^2)}dx\n\\]\nThe function in the first integral has the residue $\\frac{e^{-a}}{4i}$. Take the contour to be the semicircle in the upper half-plane and use Equation 11.102, we have\n\\[\n\\oint\\frac{ze^{iz}}{2i(z^2+a^2)}dz=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+a^2)}dx+0=2\\pi i\\cdot\\frac{e^{-a}}{4i}=\\frac{\\pi e^{-a}}{2}\n\\]\nThe function in the second integral has the residue $\\frac{e^{-a}}{4i}$. Take the contour to be the semicircle in the lower half-plane and use Equation 11.102, we have\n\\[\n\\oint\\frac{ze^{-iz}}{2i(z^2+a^2)}dz=-\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{-ix}}{2i(x^2+a^2)}dx+0=2\\pi i\\cdot\\frac{e^{-a}}{4i}=\\frac{\\pi e^{-a}}{2}\n\\]\nso\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{x\\sin x}{x^2+a^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{ix}}{2i(x^2+a^2)}dx-\\int\\displaylimits_{-\\infty}^\\infty\\frac{xe^{-ix}}{2i(x^2+a^2)}dx=\\pi e^{-a}\n\\]\nIf $\\sin x$ is replaced by $\\sin kx$:\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{x\\sin kx}{x^2+a^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{(kx)\\sin(kx)}{(kx)^2+(ka)^2}d(kx)=\\pi e^{-ka}\n\\]\n\n\\paragraph{11.8.13}\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x}{x}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}-e^{-ix}}{2ix}dx=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{ix}dx\n\\]\nThe function has a simple pole at $z=0$ with residue\n\\[\n\\lim_{z\\to0}z\\cdot\\frac{e^{iz}}{iz}=\\frac{1}{i}\n\\]\nIntegrate along the given contour and note that the segments at $R\\to\\infty$ have no contribution:\n\\[\n\\oint\\frac{e^{iz}}{iz}dz=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{ix}dx-\\frac{2\\pi i}{2}\\cdot\\frac{1}{i}=0\n\\]\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\sin x}{x}dx=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{ix}}{ix}dx=\\pi\n\\]\n\n\\paragraph{11.8.14}\n\\[\nI=\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\sin t}{t}e^{ipt}dt=\\int\\displaylimits_{-\\infty}^\\infty\\frac{e^{it}-e^{-it}}{2it}e^{ipt}dt=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{i(p+1)t}}{2it}dt-\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{i(p-1)t}}{2it}dt\n\\]\nFor $|p|>1$,\\; $p+1$ and $p-1$ have the same sign, so\n\\[\nI=\\pm(\\pi i\\cdot\\frac{1}{2i}-\\pi i\\cdot\\frac{1}{2i})=0\n\\]\nFor $|p|<1$,\\; $p+1>0$ and $p-1<0$, so\n\\[\nI=\\pi i\\cdot\\frac{1}{2i}-(-\\pi i)\\cdot\\frac{1}{2i}=\\pi\n\\]\nFor $p=1$, \n\\[\nI=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{2it}}{2it}dt-\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{1}{2it}dt=\\frac{\\pi}{2}-0=\\frac{\\pi}{2}\n\\]\nFor $p=-1$,\n\\[\nI=\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{1}{2it}dt-\\ddashint\\displaylimits_{-\\infty}^\\infty\\frac{e^{-2it}}{2it}dt=0-(-\\frac{\\pi}{2})=\\frac{\\pi}{2}\n\\]\n\n\\paragraph{11.8.15}\nThe function $\\frac{1}{(z^2+a^2)^2}$ has two poles at $z=\\pm ia$, with the residue at $z=ia$ being\n\\[\n\\lim_{z\\to ia}\\left[\\frac{d}{dz}\\left((z-ia)^2\\cdot\\frac{1}{(z^2+a^2)^2} \\right) \\right]=\\frac{1}{4ia^3}\n\\]\nso\n\\[\n\\int\\displaylimits_{0}^\\infty\\frac{dx}{(x^2+a^2)^2}=\\frac{1}{2}\\int\\displaylimits_{-\\infty}^\\infty\\frac{dx}{(x^2+a^2)^2}=\\frac{1}{2}\\cdot2\\pi i\\cdot\\frac{1}{4ia^3}=\\frac{\\pi}{4a^3}\n\\]\nwhere the contour is the semicircle in the upper half-plane with $R\\to\\infty$.\n\n\\paragraph{11.8.16}\nThe function $\\frac{z^2}{1+z^4}$ has four poles at $e^{\\frac{\\pi i}{4}}, e^{\\frac{3\\pi i}{4}}, e^{\\frac{5\\pi i}{4}}, e^{\\frac{7\\pi i}{4}}$, and the residues of the first two poles are\n\\begin{alignat*}{2}\n& e^{\\frac{\\pi i}{4}}:\\quad && \\lim_{z\\to e^{\\frac{\\pi i}{4}}}(z-e^{\\frac{\\pi i}{4}})\\cdot\\frac{z^2}{1+z^4}=\\frac{e^{\\frac{\\pi i}{2}}}{4e^{\\frac{3\\pi i}{4}}}=\\frac{\\sqrt{2}(1-i)}{8}\\\\\n& e^{\\frac{3\\pi i}{4}}:\\quad && \\lim_{z\\to e^{\\frac{3\\pi i}{4}}}(z-e^{\\frac{3\\pi i}{4}})\\cdot\\frac{z^2}{1+z^4}=\\frac{e^{\\frac{6\\pi i}{4}}}{4e^{\\frac{\\pi i}{4}}}=\\frac{\\sqrt{2}(-1-i)}{8}\n\\end{alignat*}\nTake the contour to be the semicircle in the upper half-plane with $R\\to\\infty$, we have\n\\[\nI=2\\pi i\\left(\\frac{\\sqrt{2}(1-i)}{8}+\\frac{\\sqrt{2}(-1-i)}{8} \\right)=\\frac{\\pi}{\\sqrt{2}}\n\\]\n\n\\paragraph{11.8.17}\nThe function has a branch point at $z=0$, and two simple poles at $z=\\pm i$ with residues\n\\begin{alignat*}{3}\n    & i:\\qquad && \\lim_{z\\to i}(z-i)\\cdot\\frac{z^p\\ln z}{z^2+1}=\\frac{\\pi e^{\\frac{p\\pi i}{2}}}{4}\\\\\n    - & i:\\qquad && \\lim_{z\\to-i}(z+i)\\cdot\\frac{z^p\\ln z}{z^2+1}=-\\frac{3\\pi e^{\\frac{3p\\pi i}{2}}}{4}\n\\end{alignat*}\nTake the contour to be that in Figure 11.26. The integral on the circle of $R\\to\\infty$ vanishes, and the integral on the circle of $r\\to0$ also vanishes because\n\\[\n\\lim_{r\\to0}\\int_{C_r}\\frac{z^p\\ln z}{z^2+1}dz=\\lim_{r\\to0}\\int_{2\\pi}^{0}\\frac{r^pe^{ip\\theta}(\\ln r+i\\theta)}{r^2e^{2i\\theta}+1}(ire^{i\\theta}d\\theta)=\\lim_{r\\to0}\\int_{2\\pi}^0(r^{1+p}\\ln r+r^{1+p}i\\theta)\\frac{ie^{i(p+1)\\theta}}{1+r^2e^{2i\\theta}}d\\theta=0\n\\]\nas $r^{1+p}\\ln r\\to0$ and $r^{1+p}\\to0$. Let the integral on segment $A$ be $I$, then the integral on segment $B$ is\n\\[\n\\int\\displaylimits_{\\infty}^0\\frac{r^pe^{2p\\pi i}(\\ln r+2\\pi i)}{r^2+1}dr\n=-e^{2p\\pi i}\\int\\displaylimits_0^\\infty\\frac{r^p\\ln r}{r^2+1}dr-2\\pi i\\,e^{2p\\pi i}\\int_0^\\infty\\frac{r^p}{r^2+1}dr\n\\]\n\\[=-e^{2p\\pi i}I-2\\pi i\\,e^{2p\\pi i}\\cdot\\frac{\\pi(e^{\\frac{p\\pi i}{2}}-e^{\\frac{3p\\pi i}{2}})}{1-e^{2p\\pi i}}\n\\]\nwhere we use Equation 11.115 in Example 11.8.8 to obtain the second integral. Using the residue theorem, we have\n\\[\n(1-e^{2p\\pi i})I-2\\pi i\\,e^{2p\\pi i}\\cdot\\frac{\\pi(e^{\\frac{p\\pi i}{2}}-e^{\\frac{3p\\pi i}{2}})}{1-e^{2p\\pi i}}=2\\pi i\\,(\\frac{\\pi e^{\\frac{p\\pi i}{2}}}{4}-\\frac{3\\pi e^{\\frac{3p\\pi i}{2}}}{4})\n\\]\n\\[\n(e^{-p\\pi i}-e^{p\\pi i})I=2\\pi^2i\\left[\\frac{e^{p\\pi i}(e^{-\\frac{p\\pi i}{2}}-e^{\\frac{p\\pi i}{2}})}{e^{-p\\pi i}-e^{p\\pi i}}+\\frac{e^{-\\frac{p\\pi i}{2}}-3e^{\\frac{p\\pi i}{2}}}{4} \\right]\n\\]\n\\[\n(e^{-p\\pi i}-e^{p\\pi i})I=2\\pi^2i\\cdot\\frac{e^{-\\frac{3p\\pi i}{2}}-3e^{-\\frac{p\\pi i}{2}}+3e^{\\frac{p\\pi i}{2}}-e^{\\frac{3p\\pi i}{2}}}{4(e^{-p\\pi i}-e^{p\\pi i})}\n\\]\n\\[\n(e^{-p\\pi i}-e^{p\\pi i})I=\\frac{\\pi^2i(e^{-\\frac{p\\pi i}{2}}-e^{\\frac{p\\pi i}{2}})^3}{2(e^{-p\\pi i}-e^{p\\pi i})}\n\\]\n\\[\nI=\\frac{\\pi^2i(e^{-\\frac{p\\pi i}{2}}-e^{\\frac{p\\pi i}{2}})^3}{2(e^{-\\frac{p\\pi i}{2}}+e^{\\frac{p\\pi i}{2}})^2(e^{-\\frac{p\\pi i}{2}}-e^{\\frac{p\\pi i}{2}})^2}=\\frac{\\pi^2i(e^{-\\frac{p\\pi i}{2}}-e^{\\frac{p\\pi i}{2}})}{2(e^{-\\frac{p\\pi i}{2}}+e^{\\frac{p\\pi i}{2}})^2}\n\\]\n\\[\n=\\frac{\\pi^2 i(-2i)\\sin(\\frac{p\\pi}{2})}{2\\cdot4\\cos^2(\\frac{p\\pi}{2})}=\\frac{\\pi^2}{4}\\frac{\\sin(\\frac{p\\pi}{2})}{\\cos^2(\\frac{p\\pi}{2})}\n\\]\n\n\\paragraph{11.8.18}\n(a)\n\\[\n\\int\\displaylimits_0^\\infty\\frac{(\\ln x)^2}{1+x^2}dx=\\int\\displaylimits_0^1\\frac{(\\ln x)^2}{1+x^2}dx+\\int\\displaylimits_1^\\infty\\frac{(\\ln x)^2}{1+x^2}dx\n\\]\nBy the substitution $x=\\frac{1}{t}$, the first integral becomes\n\\[\n\\int\\displaylimits_0^1\\frac{(\\ln x)^2}{1+x^2}dx=\\int\\displaylimits_{\\infty}^1\\frac{(-\\ln t)^2}{1+t^{-2}}(-t^{-2}dt)=\\int_1^\\infty\\frac{(\\ln t)^2}{1+t^2}dt\n\\]\nwhich is the same with the second integral. By another substitution $x=e^t$, we have\n\\[\n\\int\\displaylimits_1^\\infty\\frac{(\\ln x)^2}{1+x^2}dx\n=\\int\\displaylimits_0^\\infty\\frac{t^2e^t}{1+e^{2t}}dt=\\int\\displaylimits_0^\\infty\\frac{t^2e^{-t}}{1+e^{-2t}}dt\n\\]\n\\[\n=\\int\\displaylimits_0^\\infty\\left(\\sum_{n=0}^\\infty(-1)^n\\,t^2\\, e^{-(2n+1)t} \\right)dt\n\\]\n\\[\n=\\sum_{n=0}^\\infty(-1)^n\\int\\displaylimits_0^\\infty t^2\\,e^{-(2n+1)t}dt\n\\]\n\\[\n=\\sum_{n=0}^\\infty(-1)^n\\left[\\frac{2e^{-(2n+1)t}}{-(2n+1)^3} \\right]_0^\\infty\n\\]\n\\[\n=2\\sum_{n=0}^\\infty(-1)^n(2n+1)^{-3}\n\\]\nso\n\\[\n\\int\\displaylimits_0^\\infty\\frac{(\\ln x)^2}{1+x^2}dx=2\\int\\displaylimits_1^\\infty\\frac{(\\ln x)^2}{1+x^2}dx=4\\sum_{n=0}^\\infty(-1)^n(2n+1)^{-3}\n\\]\n\n(b)\nBy the substitution $x=e^t$, we have\n\\[\nI=\\int\\displaylimits_0^\\infty\\frac{(\\ln x)^2}{1+x^2}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{1+e^{2t}}\\cdot e^t dt=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{e^t+e^{-t}}dt\n\\]\nThe function has poles at $z=(n+\\frac{1}{2})i\\pi$, and the pole at $z=\\frac{i\\pi}{2}$ is\n\\[\n\\lim_{z\\to\\frac{i\\pi}{2}}(z-\\frac{i\\pi}{2})\\cdot\\frac{z^2e^z}{1+e^{2z}}=\\lim_{z\\to\\frac{i\\pi}{2}}\\frac{z^2e^z}{2e^{2z}}=\\frac{\\pi^2i}{8}\n\\]\nTake the contour to be that in Figure 11.29. Integral on the two vertical segments vanish as $R\\to\\infty$, and integral on the segment at $x+i\\pi$ is\n\\[\n\\int\\displaylimits_{\\infty}^{-\\infty}\\frac{(t+i\\pi)^2}{e^{t+i\\pi}+e^{-t-i\\pi}}dt=\\int\\displaylimits_{-\\infty}^\\infty\\frac{(t+i\\pi)^2}{e^t+e^{-t}}\\]\n\\[=\\int\\displaylimits_{-\\infty}^\\infty\\frac{t^2}{e^t+e^{-t}}dt+\\int\\displaylimits_{-\\infty}^\\infty\\frac{2i\\pi t}{e^t+e^{-t}}dt+\\int\\displaylimits_{-\\infty}^\\infty\\frac{-\\pi^2}{e^t+e^{-t}}dt\n\\]\nThe first integral is $I$, the second integral vanishes as it is an odd function, and the third integral is\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{-\\pi^2}{e^t+e^{-t}}dt=\\int\\displaylimits_0^\\infty\\frac{-\\pi^2}{x^2+1}dx=-\\pi^2\\Big[\\tan^{-1}x\\Big]_0^\\infty=-\\frac{\\pi^3}{2}\n\\]\nUsing the residue theorem, we have\n\\[\nI+I-\\frac{\\pi^3}{2}=2\\pi i\\cdot\\frac{\\pi^2i}{8}\n\\]\n\\[\nI=\\frac{\\pi^3}{8}\n\\]\n\n\\paragraph{11.8.19}\n\\[\n\\int\\displaylimits_0^\\infty\\frac{\\ln(1+x^2)}{1+x^2}dx=\\frac{1}{2}\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\ln(1+x^2)}{1+x^2}dx=\\frac{1}{2}\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\ln(x+i)}{1+x^2}dx+\\frac{1}{2}\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\ln(x-i)}{1+x^2}dx\n\\]\nFor the first integral, there is a branch point at $z=-i$, so choose the contour to be the semicircle in the upper half-plane, and note that the residue at $z=i$ is\n\\[\n\\lim_{z\\to i}(z-i)\\cdot\\frac{\\ln(z+i)}{z^2+1}=\\frac{\\ln 2}{2i}+\\frac{\\pi}{4}\n\\]\nso the integral is \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\ln(x+i)}{1+x^2}dx=2\\pi i\\left(\\frac{\\ln 2}{2i}+\\frac{\\pi}{4}\\right)=\\pi\\ln2+\\frac{\\pi^2 i}{2}\n\\]\nFor the second integral, there is a branch point at $z=i$, so choose the contour to be the semicircle in the lower half-plane, and note that the residue at $z=-i$ is\n\\[\n\\lim_{z\\to -i}(z+i)\\cdot\\frac{\\ln(z-i)}{z^2+1}=-\\frac{\\ln 2}{2i}+\\frac{\\pi}{4}\n\\]\nso the integral is \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\ln(x-i)}{1+x^2}dx=-2\\pi i\\left(\\frac{-\\ln 2}{2i}+\\frac{\\pi}{4}\\right)=\\pi\\ln2-\\frac{\\pi^2 i}{2}\n\\]\nTherefore,\n\\[\n\\int\\displaylimits_0^\\infty\\frac{\\ln(1+x^2)}{1+x^2}dx=\\frac{1}{2}\\left(\\pi\\ln2+\\frac{\\pi^2 i}{2}\\right)+\\frac{1}{2}\\left(\\pi\\ln2-\\frac{\\pi^2 i}{2}\\right)=\\pi\\ln 2\n\\]\n\n\\paragraph{11.8.20}\nThe function has a second pole at $z=-1$ with residue\n\\[\n\\lim_{z\\to-1}\\frac{d}{dz}\\left[(z+1)^2\\cdot\\frac{z^a}{(z+1)^2} \\right]=a(-1)^{a-1}=-a\\,e^{\\pi ai}\n\\]\nUse the contour shown in Figure 11.26. The integral on the circle $R\\to\\infty$ and the circle $r\\to0$ vanish, and the integral below the x-axis is\n\\[\n\\int\\displaylimits_{\\infty}^0\\frac{r^ae^{2\\pi ai}}{(re^{2\\pi i}+1)^2}dr=-e^{2\\pi ai}\\int\\displaylimits_{0}^\\infty\\frac{r^a}{(r+1)^2}dr\n\\]\nUsing the residue theorem,\n\\[\n(1-e^{2\\pi ai})\\int\\displaylimits_{0}^\\infty\\frac{r^a}{(r+1)^2}dr=2\\pi i(-ae^{\\pi ai})\n\\]\n\\[\n\\int\\displaylimits_0^\\infty\\frac{r^a}{(r+1)^2}dr=\\frac{2\\pi ai\\,e^{\\pi ai}}{e^{2\\pi ai}-1}=\\frac{2\\pi ai}{2i\\sin\\pi a}=\\frac{\\pi a}{\\sin\\pi a}\n\\]\n\n\\paragraph{11.8.21}\nSolving the roots of the denominator which are the poles, we have\n\\[\nz^2=\\frac{2\\cos2\\theta\\pm(4\\cos^22\\theta-4)^{\\frac{1}{2}}}{2}=e^{2i\\theta},e^{-2i\\theta}\n\\]\n\\[\nz=e^{i\\theta},-e^{i\\theta},e^{-i\\theta},-e^{-i\\theta}\n\\]\nIf $e^{i\\theta}$ is in the upper half-plane, then so does $-e^{-i\\theta}$, and their residues are\n\\begin{alignat*}{3}\n    & e^{i\\theta}:\\qquad && \\lim_{z\\to e^{i\\theta}}\\frac{z^2}{(z+e^{i\\theta})(z-e^{-i\\theta})(z+e^{-i\\theta})}=\\frac{e^{i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}\\\\\n    - & e^{-i\\theta}:\\qquad && \\lim_{z\\to -e^{-i\\theta}}\\frac{z^2}{(z-e^{i\\theta})(z+e^{i\\theta})(z-e^{-i\\theta})}=\\frac{e^{-i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}\n\\end{alignat*}\nTake the contour to be the semicircle in the upper half-plane, and use the residue theorem: \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{x^2dx}{x^4-2x^2\\cos2\\theta+1}=2\\pi i\\cdot\\frac{e^{i\\theta}+e^{-i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}=\\frac{\\pi i}{e^{i\\theta}-e^{-i\\theta}}=\\frac{\\pi}{2\\sin\\theta}=\\frac{\\pi}{2^{\\frac{1}{2}}(1-\\cos2\\theta)^{\\frac{1}{2}}}\n\\]\nIf $e^{i\\theta}$ and $-e^{-i\\theta}$ are in the lower half-plane, there will be a negative sign in the result, while the equation still holds because $(1-\\cos2\\theta)^{\\frac{1}{2}}$ can have either a positive or negative sign.\n\n\\paragraph{11.8.22}\nThe function has poles at the roots of the denominator, which is $z=e^{\\frac{\\pi i}{n}+k\\frac{2\\pi i}{n}}$ where $k$ is an integer, and the residue at $z=e^{\\frac{\\pi i}{n}}$ is\n\\[\n\\lim_{z\\to e^{\\frac{\\pi i}{n}}}(z-e^{\\frac{\\pi i}{n}})\\cdot\\frac{1}{1+z^n}=\\lim_{z\\to e^{\\frac{\\pi i}{n}}}\\frac{1}{nz^{n-1}}=\\frac{-e^{\\frac{\\pi i}{n}}}{n}\n\\]\nTake the contour to be that in Figure 11.30, and use the residue theorem:\n\\[\n(1-e^{\\frac{2\\pi i}{n}})\\int\\displaylimits_{0}^\\infty\\frac{dr}{1+r^n}=2\\pi i\\cdot\\frac{-e^{\\frac{\\pi i}{n}}}{n}\n\\]\n\\[\n\\int\\displaylimits_0^\\infty\\frac{dr}{1+r^n}=\\frac{2\\pi i}{n(e^{\\frac{\\pi i}{n}}-e^{\\frac{-\\pi i}{n}})}=\\frac{\\frac{\\pi}{n}}{\\sin(\\frac{\\pi}{n})}\n\\]\n\n\\paragraph{11.8.23}\n(a) As in Exercise 11.8.21, solving for $z$, we have\n\\[\nz^2=\\frac{2\\cos2\\theta\\pm(4\\cos^22\\theta-4)^{\\frac{1}{2}}}{2}=e^{2i\\theta},e^{-2i\\theta}\n\\]\n\\[\nz=e^{i\\theta},-e^{i\\theta},e^{-i\\theta},-e^{-i\\theta}\n\\]\n\n(b)\nIf $e^{i\\theta}$ is in the upper half-plane, then so does $-e^{-i\\theta}$, and their residues are\n\\begin{alignat*}{3}\n    & e^{i\\theta}:\\qquad && \\lim_{z\\to e^{i\\theta}}\\frac{1}{(z+e^{i\\theta})(z-e^{-i\\theta})(z+e^{-i\\theta})}=\\frac{e^{-i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}\\\\\n    - & e^{-i\\theta}:\\qquad && \\lim_{z\\to -e^{-i\\theta}}\\frac{1}{(z-e^{i\\theta})(z+e^{i\\theta})(z-e^{-i\\theta})}=\\frac{e^{i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}\n\\end{alignat*}\nTake the contour to be the semicircle in the upper half-plane, and use the residue theorem: \n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{dx}{x^4-2x^2\\cos2\\theta+1}=2\\pi i\\cdot\\frac{e^{-i\\theta}+e^{i\\theta}}{2(e^{2i\\theta}-e^{-2i\\theta})}=\\frac{\\pi i}{e^{i\\theta}-e^{-i\\theta}}=\\frac{\\pi}{2\\sin\\theta}=\\frac{\\pi}{2^{\\frac{1}{2}}(1-\\cos2\\theta)^{\\frac{1}{2}}}\n\\]\n\n\\paragraph{11.8.24}\nThe function has a simple pole at $z=-1$ with residue\n\\[\n\\lim_{z\\to-1}(z+1)\\cdot\\frac{z^{-a}}{z+1}=(-1)^{-a}=e^{-\\pi ai}\n\\]\nUse the contour shown in Figure 11.26. The integral on the circle $R\\to\\infty$ and the circle $r\\to0$ vanish, and the integral below the x-axis is\n\\[\n\\int\\displaylimits_{\\infty}^0\\frac{r^{-a}e^{-2\\pi ai}}{re^{2\\pi i}+1}dr=-e^{-2\\pi ai}\\int\\displaylimits_{0}^\\infty\\frac{r^{-a}}{r+1}dr\n\\]\nUsing the residue theorem,\n\\[\n(1-e^{-2\\pi ai})\\int\\displaylimits_{0}^\\infty\\frac{r^{-a}}{r+1}dr=2\\pi i(e^{-\\pi ai})\n\\]\n\\[\n\\int\\displaylimits_0^\\infty\\frac{r^{-a}}{r+1}dr=\\frac{2\\pi i}{e^{\\pi ai}-e^{-\\pi ai}}=\\frac{\\pi a}{\\sin\\pi a}\n\\]\n\n\\paragraph{11.8.25}\nThe function has poles at $z=\\frac{\\pi i}{2}+n\\pi i$, and the residue at $z=\\frac{\\pi i}{2}$ is\n\\[\n\\lim_{z\\to\\frac{\\pi i}{2}}(z-\\frac{\\pi i}{2})\\cdot\\frac{\\cosh bx}{\\cosh x}=\\lim_{z\\to\\frac{\\pi i}{2}}\\frac{\\cosh bx}{\\sinh x}=\\frac{\\cosh(\\frac{\\pi b}{2})}{i}\n\\]\nTake the contour to be that in Figure 11.29. Integral on the two vertical segments vanishes as $R\\to\\infty$ and  $|b|<1$. Integral on the lower horizontal segment is\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cosh bx}{\\cosh x}dx=2\\int\\displaylimits_{0}^\\infty\\frac{\\cosh bx}{\\cosh x}dx=2I\n\\]\nIntegral on the upper horizontal segment is\n\\[\n\\int\\displaylimits_{\\infty}^{-\\infty}\\frac{\\cosh(bx+i\\pi b)}{\\cosh(x+i\\pi)}dx=\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\cosh bx\\cdot\\cos\\pi b}{\\cosh x}dx+\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\sinh bx\\cdot i\\sin\\pi b}{\\cosh x}dx=\\cos\\pi b\\cdot2I\n\\]\nNote that the second integral vanishes because it is an odd function. Using the residue theorem:\n\\[\n(2+2\\cos\\pi b)I=2\\pi i\\cdot\\frac{\\cos(\\frac{\\pi b}{2})}{i}\n\\]\n\\[\nI=\\frac{\\pi\\cos(\\frac{\\pi b}{2})}{1+\\cos\\pi b}=\\frac{\\pi}{2\\cos(\\frac{\\pi b}{2})}\n\\]\n\n\\paragraph{11.8.26}\nIntegrate the function $e^{-z^2}$ around the contour in Figure 11.30, and note that there are no singularity in it:\n\\[\n\\oint e^{-z^2}dz=\\int\\displaylimits_0^\\infty e^{-r^2}dr+\\int\\displaylimits_{C_R}e^{-z^2}dz+\\int\\displaylimits_\\infty^0 e^{-r^2i}e^{\\frac{i\\pi}{4}}dr\n\\]\n\\[\n=\\frac{\\sqrt{\\pi}}{2}+0-\\frac{1+i}{\\sqrt{2}}\\cdot\\int\\displaylimits_0^\\infty\\cos(r^2)dr+\\frac{1+i}{\\sqrt{2}}\\cdot i\\int\\displaylimits_{0}^\\infty\\sin(r^2)dr=0\n\\]\nThe first integral is the Gaussian integral, the second integral vanishes as $R\\to\\infty$, and the third integral is split by $e^{-ir^2}=\\cos(r^2)-i\\sin(r^2)$. Equating the real and imaginary parts, we have\n\\begin{align*}\n    & \\frac{1}{\\sqrt{2}}\\int\\displaylimits_0^\\infty\\cos(r^2)dr+\\frac{1}{\\sqrt{2}}\\int\\displaylimits_0^\\infty\\sin(r^2)dr=\\frac{\\sqrt{\\pi}}{2}\\\\\n    & \\frac{1}{\\sqrt{2}}\\int\\displaylimits_0^\\infty\\cos(r^2)dr-\\frac{1}{\\sqrt{2}}\\int\\displaylimits_0^\\infty\\sin(r^2)dr=0\n\\end{align*}\nSolving the equations, we have\n\\[\n\\int\\displaylimits_0^\\infty\\cos(r^2)dr=\\int\\displaylimits_0^\\infty\\sin(r^2)dr=\\frac{\\sqrt{\\pi}}{2\\sqrt{2}}\n\\]\n\n\\paragraph{11.8.27}\nThe function has two branch points at $0$ and $1$:\n\\[\n\\int_0^1\\frac{1}{(x^2-x^3)^{\\frac{1}{3}}}dx=\\int_0^1\\frac{1}{x^{\\frac{2}{3}}(1-x)^{\\frac{1}{3}}}dx\n\\]\nIntegrate along the contour in Figure 11.31. Integrals on the two small circles vanish because\n\\[\n\\lim_{r\\to0}\\int\\displaylimits_{2\\pi}^0\\frac{ire^{i\\theta}d\\theta}{r^{\\frac{2}{3}}e^{\\frac{2i\\theta}{3}}(1-re^{i\\theta})^\\frac{1}{3}}=\\lim_{r\\to0}\\int\\displaylimits_{2\\pi}^0ir^{\\frac{1}{3}}e^{\\frac{i\\theta}{3}}d\\theta=0\n\\]\n\\[\n\\lim_{r\\to0}\\int\\displaylimits_0^{-2\\pi}\\frac{-ire^{i\\theta}d\\theta}{(1-re^{i\\theta})^{\\frac{2}{3}}r^{\\frac{1}{3}}e^{\\frac{i\\theta}{3}}}=\\lim_{r\\to0}\\int\\displaylimits_0^{-2\\pi}-ir^{\\frac{2}{3}}e^{\\frac{2i\\theta}{3}}d\\theta=0\n\\]\nIntegral above the real axis is what we want, and integral below the real axis is\n\\[\n\\int\\displaylimits_1^0\\frac{1}{x^{\\frac{2}{3}}(1-x)^{\\frac{1}{3}}e^{\\frac{-2\\pi i}{3}}}=-e^{\\frac{2\\pi i}{3}}\\int\\displaylimits_0^1\\frac{1}{x^{\\frac{2}{3}}(1-x)^{\\frac{1}{3}}}dx\n\\]\nNote that the angle relative to $z=0$ does not change, but there is a factor of $e^{-2\\pi i}$ multiplied in the angle relative to $z=1$. \nIntegral along the big circle is\n\\[\n\\lim_{R\\to\\infty}\\int\\displaylimits_0^{2\\pi}\\frac{iRe^{i\\theta}d\\theta}{(R^2e^{2i\\theta}-R^3e^{3i\\theta})^{\\frac{1}{3}}}=\\lim_{R\\to\\infty}\\int\\displaylimits_0^{2\\pi}\\frac{id\\theta}{(-1)^{\\frac{1}{3}}}=2\\pi i\\,e^{\\frac{\\pi i}{3}}\n\\]\nThere are no singularity between the two contours, so using the residue theorem:\n\\[\n(1-e^{\\frac{2\\pi i}{3}})\\int\\displaylimits_0^1\\frac{1}{x^{\\frac{2}{3}}(1-x)^{\\frac{1}{3}}}dx+2\\pi i\\,e^{\\frac{\\pi i}{3}}=0\n\\]\n\\[\n\\int\\displaylimits_0^1\\frac{1}{x^{\\frac{2}{3}}(1-x)^{\\frac{1}{3}}}dx=\\frac{-2\\pi i\\,e^{\\frac{\\pi i}{3}}}{1-e^{\\frac{2\\pi i}{3}}}=\\frac{2\\pi i}{e^{\\frac{\\pi i}{3}}-e^{-\\frac{\\pi i}{3}}}=\\frac{2\\pi}{\\sqrt{3}}\n\\]\n\n\\paragraph{11.8.28}\nThe function has two simple poles at $\\pm ib$, with the residue at $z=ib$ being\n\\[\n\\lim_{z\\to ib}(z-ib)\\cdot\\frac{\\tan^{-1}az}{z(z^2+b^2)}=\\frac{i}{4b^2}\\ln\\left(\\frac{1-ab}{1+ab} \\right)\n\\]\nIt also has two branch point at $z=\\pm\\frac{i}{a}$, which is obvous if we write $\\tan^{-1}az$ in the form\n\\[\n\\tan^{-1}az=-\\frac{i}{2}\\ln(i-az)+\\frac{i}{2}\\ln(i+az)\n\\]\nThere is no singularity at $z=0$ because\n\\[\n\\lim_{z\\to0}\\frac{\\tan^{-1}az}{z(z^2+b^2)}=\\lim_{z\\to0}\\frac{\\frac{a}{1+a^2z^2}}{z^2+b^2}=\\frac{a}{b^2}\n\\]\nIntegrate along the contour in Figure 11.32. Integral on the big semicircle vanish, and integral on $B$ and $B'$ can be obtained by substituting $z=iy$, and note that the term $\\ln(i-az)$ of $B'$ has a factor $e^{-2\\pi i}$ because $z=\\frac{i}{a}$ is a branch point:\n\\[\n\\int\\displaylimits_{\\infty}^{\\frac{1}{a}}\\frac{\\frac{i}{2}\\ln\\left(\\frac{i+iay}{i-iay}\\right)}{iy(-y^2+b^2)}(idy)+\\int\\displaylimits_{\\frac{1}{a}}^\\infty\\frac{\\frac{i}{2}\\ln\\left(\\frac{i+iay}{(i-iay)e^{-2\\pi i}} \\right)}{iy(-y^2+b^2)}(idy)=\\int\\displaylimits_{\\frac{1}{a}}^\\infty\\frac{\\pi}{y(y^2-b^2)}dy=\\frac{-\\pi}{2b^2}\\ln(1-a^2b^2)\n\\]\nUsing the residue theorem:\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\tan^{-1}ax\\,dx}{x(x^2+b^2)}-\\frac{\\pi}{2b^2}\\ln(1-a^2b^2)=2\\pi i\\cdot\\frac{i}{4b^2}\\ln\\left(\\frac{1-ab}{1+ab} \\right)\n\\]\n\\[\n\\int\\displaylimits_{-\\infty}^\\infty\\frac{\\tan^{-1}ax\\,dx}{x(x^2+b^2)}=\\frac{\\pi}{b^2}\\ln(1+ab)\n\\]\n\n\\section*{11.9 Evaluation of Sums}\n\\paragraph{11.9.1}\n\\[\nf(z)=f(z_0)+\\sum_{n=1}^\\infty a_nz^n\n\\]\n\\[\ng(z)=\\frac{b_0}{z}+\\sum_{n=0}^\\infty a'_nz^n\n\\]\n\\[\nf(z)g(z)=\\frac{f(z_0)b_0}{z}+\\sum_{n=0}^\\infty a''_nz^n\n\\]\nso $f(z)g(z)$ has a simple pole at $z=z_0$ with residue $f(z_0)b_0$.\n\n\\paragraph{11.9.2}\n\\[\n\\lim_{|z|\\to\\infty}|\\cot z|=\\lim_{|z|\\to\\infty}\\left|\\frac{e^{iz}+e^{-iz}}{e^{iz}-e^{-iz}} \\right|=1\\qquad \\textit{if $z\\neq n\\pi$}\n\\]\n\n\\paragraph{11.9.3}\n\\[\nS=-\\sum_{n=1}^\\infty(-1)^n\\frac{1}{(2n-1)^3}=-\\frac{1}{2}\\sum_{n=-\\infty}^\\infty(-1)^n\\frac{1}{(2n-1)^3}\n\\]\nConsider the function $\\frac{\\pi\\csc\\pi z}{(2z-1)^3}$. It has simple poles at $z=n$ with residues\n\\[\n\\lim_{z\\to n}\\frac{(z-n)\\pi}{\\sin\\pi z}\\cdot\\frac{1}{(2z-1)^3}=(-1)^n\\frac{1}{(2n-1)^3}\n\\]\nIt also has a third pole at $z=\\frac{1}{2}$ with residue\n\\[\n\\lim_{z\\to\\frac{1}{2}}\\frac{1}{2!}\\frac{d^2}{dz^2}\\left[(z-\\frac{1}{2})^3\\cdot\\frac{\\pi\\csc\\pi z}{(2z-1)^3} \\right]=\\frac{\\pi^3}{16}\n\\]\nUsing the residue theorem, we have\n\\[\n\\sum_{n=-\\infty}^\\infty(-1)^n\\frac{1}{(2n-1)^3}+\\frac{\\pi^3}{16}=0\n\\]\n\\[\nS=-\\frac{1}{2}\\sum_{n=-\\infty}^\\infty(-1)^n\\frac{1}{(2n-1)^3}=\\frac{\\pi^3}{32}\n\\]\n\n\\paragraph{11.9.4}\nConsider the function $\\frac{\\pi\\cot\\pi z}{z()z+2}$. It has simple poles at integers $z=n$ except $0,-2$ with residues\n\\[\n\\lim_{z\\to n}(z-n)\\cdot\\frac{\\pi\\cot\\pi z}{z(z+2)}=\\frac{1}{n(n+2)}\n\\]\nIt has second poles at $z=0,-2$ with residues that can be obtained by expansions:\n\\begin{alignat*}{3}\n    & z=0:\\qquad && \\frac{\\pi\\cot\\pi z}{z(z+2)}=\\frac{\\pi}{2z}\\left[\\frac{1}{\\pi z}+O(z) \\right]\\left[1-\\frac{z}{2}+O(z^2) \\right]=\\frac{1}{2z^2}-\\frac{1}{4z}+\\cdots\\quad &&\\rightarrow \\textit{residue=$-\\frac{1}{4}$}\\\\\n    & z=-2:\\qquad && \\frac{\\pi\\cot\\pi z'}{(z'-2)z'}=-\\frac{\\pi}{2z'}\\left[\\frac{1}{\\pi z'}+O(z') \\right]\\left[1+\\frac{z'}{2}+O(z'^2) \\right]=-\\frac{1}{2z'^2}-\\frac{1}{4z'}+\\cdots\\quad &&\\rightarrow \\textit{residue=$-\\frac{1}{4}$}\n\\end{alignat*}\nUsing the residue theorem, we have\n\\[\n\\sum_{n=1}^\\infty\\frac{1}{n(n+2)}-\\frac{1}{4}+\\frac{1}{-1(-1+2)}-\\frac{1}{4}+\\sum_{n=-\\infty}^{-3}\\frac{1}{n(n+2)}=0\n\\]\nand note that the first and last term are equal, we have\n\\[\n\\sum_{n=1}^\\infty\\frac{1}{n(n+2)}=\\frac{3}{4}\n\\]\n\n\\paragraph{11.9.5}\nConsider the function $\\frac{\\pi\\csc\\pi z}{(z+a)^2}$. It has simple poles at $z=n$ with residues\n\\[\n\\lim_{z\\to n}(z-n)\\cdot\\frac{\\pi\\csc\\pi z}{(z+a)^2}=\\frac{(-1)^n}{(n+a)^2}\n\\]\nIt also has a second pole at $z=-a$ with residue\n\\[\n\\lim_{z\\to-a}\\frac{d}{dz}\\left[(z+a)^2\\cdot\\frac{\\pi\\csc\\pi z}{(z+a)^2} \\right]=\\frac{-\\pi^2\\cos\\pi a}{\\sin^2\\pi a}\n\\]\nUsing the residue theorem, we have\n\\[\n\\sum_{n=-\\infty}^\\infty\\frac{(-1)^n}{(n+a)^2}-\\frac{\\pi^2\\cos\\pi a}{\\sin^2\\pi a}=0\n\\]\n\\[\n\\sum_{n=-\\infty}^\\infty\\frac{(-1)^n}{(n+a)^2}=\\frac{\\pi^2\\cos\\pi a}{\\sin^2\\pi a}\n\\]\n\n\\paragraph{11.9.6}\n(a) Consider the function $\\frac{\\pi\\cot\\pi z}{(2z+1)^2}$. It has simple poles at $z=n$ with residues\n\\[\n\\lim_{z-n}\\cdot\\frac{\\pi\\cot\\pi z}{(2z+1)^2}=\\frac{1}{(2n+1)^2}\n\\]\nIt also has a second pole at $z=-\\frac{1}{2}$ with residue\n\\[\n\\lim_{z\\to-\\frac{1}{2}}\\frac{d}{dz}\\left[(z+\\frac{1}{2})^2\\cdot\\frac{\\pi\\cot\\pi z}{(2z+1)^2} \\right]=-\\frac{\\pi^2}{4}\n\\]\nUsing the residue theorem, we have\n\\[\n\\sum_{n=-\\infty}^\\infty\\frac{1}{(2n+1)^2}-\\frac{\\pi^2}{4}=0\n\\]\n\\[\n\\sum_{n=0}^\\infty\\frac{1}{(2n+1)^2}=\\frac{1}{2}\\sum_{n-\\infty}^\\infty\\frac{1}{(2n+1)^2}=\\frac{\\pi^2}{8}\n\\]\n\n(b)\n\\[\n\\sum_{n=0}^\\infty\\frac{1}{(2n+1)^2}=\\frac{1}{1^2}+\\frac{1}{3^2}+\\frac{1}{5^2}+\\cdots\n\\]\n\\[\n=(\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\cdots)-(\\frac{1}{2^2}+\\frac{1}{4^2}+\\frac{1}{6^2}+\\cdots)\n\\]\n\\[\n=\\zeta(2)-\\frac{1}{2^2}\\zeta(2)=\\frac{3}{4}\\cdot\\frac{\\pi^2}{6}=\\frac{\\pi^2}{8}\n\\]\n\n\\paragraph{11.9.7}\n\\[\nS=\\sum_{n=0}^\\infty\\frac{(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}=\\frac{1}{2}\\sum_{n=-\\infty}^\\infty\\frac{(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}\n\\]\nConsider the function $\\frac{\\pi\\sec\\pi z}{2z\\cosh\\pi z}$. Is has a simple pole at $z=0$ with residue\n\\[\n\\lim_{z\\to0}z\\cdot\\frac{\\pi\\sec\\pi z}{2z\\cosh\\pi z}=\\frac{\\pi}{2}\n\\]\nIt also has simple poles at $z=n+\\frac{1}{2}$ with residues \n\\[\n\\lim_{z\\to n+\\frac{1}{2}}(z-n-\\frac{1}{2})\\cdot\\frac{\\pi\\sec\\pi z}{2z\\cosh\\pi z}=\\frac{-(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}\n\\]\nIt also has simple poles at $z=(n+\\frac{1}{2})i$ with residues \n\\[\n\\lim_{z\\to(n+\\frac{1}{2})i}(z-ni-\\frac{i}{2})\\cdot\\frac{\\pi\\sec\\pi z}{2z\\cosh\\pi z}=\\lim_{z\\to(n+\\frac{1}{2})i}\\frac{\\pi\\sec\\pi z}{2\\pi z\\sinh\\pi z}=\\frac{-(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}\n\\]\nUsing the residue theorem, we have\n\\[\n\\sum_{n=-\\infty}^\\infty\\frac{-(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}+\\sum_{n=-\\infty}^\\infty\\frac{-(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}+\\frac{\\pi}{2}=0\n\\]\n\\[\nS=\\frac{1}{2}\\sum_{n=-\\infty}^\\infty\\frac{(-1)^n}{2(n+\\frac{1}{2})\\cosh\\pi(n+\\frac{1}{2})}=\\frac{\\pi}{8}\n\\]\n\n\\paragraph{11.9.8}\nConsider the function $\\frac{\\pi\\csc\\pi z\\sin\\varphi z}{z^3}$. It has simple poles at $z=n$ except $0$ with residues\n\\[\n\\lim_{z\\to n}(z-n)\\cdot\\frac{\\pi\\csc\\pi z\\sin\\varphi z}{z^3}=(-1)^n\\frac{\\sin n\\varphi}{n^3}\n\\]\nIt has a third pole at $z=0$ whose residue can be obtained by expansion:\n\\[\n\\frac{\\pi\\csc\\pi z\\sin\\varphi z}{z^3}=\\frac{\\pi}{z^3}\\frac{\\varphi z(1-\\frac{\\varphi^2z^2}{3!}+\\cdots)}{\\pi z(1-\\frac{\\pi^2z^2}{3!}+\\cdots)}\n\\]\n\\[\n=\\frac{\\pi}{z^3}\\frac{\\varphi}{\\pi}(1-\\frac{\\varphi^2z^2}{6}+\\cdots)(1+\\frac{\\pi^2z^2}{6}+\\cdots)\n\\]\n\\[\n=\\frac{\\varphi}{z^3}+\\frac{\\varphi(\\pi^2-\\varphi^2)}{6z}+\\cdots\n\\]\nso the residue is $\\frac{\\varphi(\\pi^2-\\varphi^2)}{6}$. Using the residue theorem, we have\n\\[\n\\sum_{n=1}^\\infty(-1)^n\\frac{\\sin n\\varphi}{n^3}+\\frac{\\varphi(\\pi^2-\\varphi^2)}{6}+\\sum_{n=-\\infty}^{-1}(-1)^n\\frac{\\sin n\\varphi}{n^3}=0\n\\]\nand note that the first and last term are equal, so\n\\[\n\\sum_{n=1}^\\infty(-1)^n\\frac{\\sin n\\varphi}{n^3}=\\frac{\\varphi(\\varphi^2-\\pi^2)}{12}\n\\]\n\n\\section*{11.10 Miscellaneous Topics}\n\\paragraph{11.10.1}\n\\[\nf^*(z)=u(x,y)-iv(x,y)=f(z^*)=u(x,-y)+iv(x,-y)\n\\]\nEquating the real and imaginary parts, we have\n\\[\nu(x,y)=u(x,-y)\n\\]\nwhich means $u$ is an even function of $y$, and\n\\[\nv(x,y)=-v(x,-y)\n\\]\nwhich means $v$ is an odd function of $y$.\n\n\\paragraph{11.10.2}\nLet $f(z)=\\sum_{n=-\\infty}^\\infty a_nz^n$ where $a_n$ are real, then\n\\[\nf^*(z)=\\sum_{n=-\\infty}^\\infty(a_nz^n)^*=\\sum_{n=-\\infty}^\\infty a_n(z^*)^n=f(z^*)\n\\]\nIf $f(z)=z^n$,\n\\[\nf^*(z)=(z^n)^*=(z^*)^n=f(z^*)\n\\]\nIf $f(z)=\\sin z=\\sin(x+iy)=\\sin x\\cosh y+i\\cos x\\sinh y$,\n\\[\nf^*(z)=\\sin x\\cosh y-i\\cos x\\sinh y\\]\n\\[=\\sin x\\cosh(-y)+i\\cos x\\sinh(-y)=f(z^*)\n\\]\nIf $f(z)=iz$,\n\\[\nf^*(z)=-iz^*\\neq iz^*=f(z^*)\n\\]\n\n\\paragraph{11.10.3}\n(a) $f(z)$ is analytic, so it can be expanded as\n\\[\nf(z)=\\sum_{n=0}^\\infty(z-x_0)^n\\frac{f^{(n)}(x_0)}{n!}\n\\]\nWhen $z$ is real, $(z-x_0)^n$ is real, but $f(z)$ is imaginary, so $\\frac{f^{(n)}(x_0)}{n!}$ is also imaginary, which means $\\left[\\frac{f^{(n)}(x_0)}{n!}\\right]^*=-\\frac{f^{(n)}(x_0)}{n!}$. Therefore,\n\\[\nf(z^*)=\\sum_{n=0}^\\infty(z^*-x_0)^n\\frac{f^{(n)}(x_0)}{n!}=-\\sum_{n=0}^\\infty\\left[(z-x_0)^n\\frac{f^{(n)}(x_0)}{n!} \\right]^*=-\\left[f(z)\\right]^*\n\\]\n\n(b)\n\\[\nf(z)=i(x+iy)=-y+ix\n\\]\n\\[\nf(z^*)=i(x-iy)=y+ix\n\\]\n\\[\nf^*(z)=-i(x-iy)=-y-ix\n\\]\nso $f(z^*)=-f^*(z)$.\n\n\\paragraph{11.10.4}\n(a)\nA circle centered at the origin has the form\n\\[\nz=x+iy,\\qquad x^2+y^2=r^2\n\\]\nWhen transformed, it becomes\n\\[\nw_1(z)=x+iy+\\frac{1}{x+iy}\n\\]\n\\[\n=x(1+\\frac{1}{r^2})+iy(1-\\frac{1}{r^2})\n\\]\n\\[\n=u+iv\n\\]\nso $u=x(1+\\frac{1}{r^2}),\\;v=y(1-\\frac{1}{r^2})$, and\n\\[\n\\frac{u^2}{r^2(1+\\frac{1}{r^2})^2}+\\frac{v^2}{r^2(1-\\frac{1}{r^2})^2}=\\frac{x^2}{r^2}+\\frac{y^2}{r^2}=1\n\\]\nIf $r^2>1$, it is an ellipse. If $r^2<1$, it is a hyperbola. If $r^2=1$, it is a straight line, which is the $u-axis$.\n\\medskip\n\n(b)\n\\[\nw_2(z)=x+iy-\\frac{1}{x+iy}\n\\]\n\\[\n=x(1-\\frac{1}{r^2})+iy(1+\\frac{1}{r^2})\n\\]\n\\[\n=u+iv\n\\]\nso $u=x(1-\\frac{1}{r^2}),\\;v=y(1+\\frac{1}{r^2})$, and\n\\[\n\\frac{u^2}{r^2(1-\\frac{1}{r^2})^2}+\\frac{v^2}{r^2(1+\\frac{1}{r^2})^2}=\\frac{x^2}{r^2}+\\frac{y^2}{r^2}=1\n\\]\nIf $r^2>1$, it is an ellipse. If $r^2<1$, it is a hyperbola. If $r^2=1$, it is a straight line, which is the $v-axis$.\n\n\\paragraph{11.10.5}\n(a)\n\\[\n|w|=\\left|\\frac{z-1}{z+1} \\right|<1\n\\]\n\\[\n|z-1|<|z+1|\n\\]\nwhich is the right half-plane of $z$-plane ($x>0$).\n\\medskip\n\n(b)\n\\[\n|w|=\\left|\\frac{z-i}{z+i} \\right|<1\n\\]\n\\[\n|z-i|<|z+i|\n\\]\nwhich is the upper half-plane of $z$-plane ($y>0$).\n\n\\paragraph{11.10.6}\n(a)\n\\[\nz=\\frac{1}{w}=\\frac{u}{u^2+v^2}+i\\frac{-v}{u^2+v^2}=x+iy\n\\]\nso $x=\\frac{u}{u^2+v^2},\\;y=\\frac{-v}{u^2+v^2}$. Substituting it into $(x-a)^2+(y-b)^2=r^2$, we have\n\\[\n\\left(\\frac{u}{u^2+v^2}-a \\right)^2+\\left(\\frac{-v}{u^2+v^2}-b \\right)^2=r^2\n\\]\n\\[\n(r^2-a^2-b^2)u^2+(r^2-a^2-b^2)v^2+2au-2bv-1=0\n\\]\n\\[\n\\left(u+\\frac{a}{r^2-a^2-b^2} \\right)^2+\\left(v-\\frac{b}{r^2-a^2-b^2} \\right)^2=\\left(\\frac{r}{r^2-a^2-b^2}\\right)^2\n\\]\nSo\n\\[\nA=\\frac{-a}{r^2-a^2-b^2}\\qquad B=\\frac{b}{r^2-a^2-b^2}\\qquad R=\\frac{r}{r^2-a^2-b^2}\n\\]\n\\medskip\n\n(b)\nThe center of circle in $z$ plane is transformed to\n\\[\nC_z=a+ib\\rightarrow C_{z'}=\\frac{a}{a^2+b^2}+i\\frac{-b}{a^2+b^2}\n\\]\nwhich is different from the center of circle in $w$ plane, which is\n\\[\nC_w=\\frac{-a}{r^2-a^2-b^2}+i\\frac{b}{r^2-a^2-b^2}\n\\]\n\n\\paragraph{11.10.7}\nIf two curves pass through point $z_0$ in the direction $dz_1=e^{i\\theta_1}ds_1$ and $dz_2=e^{i\\theta_2}ds_2$ in the $z$ plane, then after mapping they pass through point $f(z_0)$ in the direction $dw_1=f'(z_0)e^{i\\theta_1}ds_1$ and $dw_2=f'(z_0)e^{i\\theta_2}ds_2$ in $w$ plane. So\n\\[\n\\frac{dz_1}{dz_2}=e^{i(\\theta_1-\\theta_2)}\\frac{ds_1}{ds_2}=\\frac{dw_1}{dw_2}\n\\]\n\\[\n\\theta_z=\\arg\\left(\\frac{dz_1}{dz_2}\\right)=\\arg\\left(\\frac{dw_1}{dw_2}\\right)=\\theta_w\n\\]\nwhich means the angle at which two curves intersect does not change after mapping.\n\n\\end{document}\n", "meta": {"hexsha": "46c5731f6dd1fb830944e572e5382a9acd8d36aa", "size": 78055, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 11/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 11/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 11/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8878994238, "max_line_length": 420, "alphanum_fraction": 0.6004612132, "num_tokens": 36606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.40758756498134596}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno} \n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{February 3, 2014}\n\\maketitle\n\\subsection*{homework 2 number 36}\npick 0,1,2,\\dots,$n_i$ things of type $i$. $(n_1+1)(n_2+1)\\cdots(n_k+1)$\n\\subsection*{homework 3 number 47}\n$\\pi_n$ is the set of partitions of $\\{1,\\dots,n\\}$ into nonempty subsets. $1|25|34$. Top is $1234$ bottom is $1|2|3|4$ $1|2|3|4\\to 12|3|4$. $123|45$ and $1|25|34$ are incomparable.\n\n\\section*{go}\n\\begin{align*}\n  {s_i}^2&=1\\\\\n  s_is_j&=s_js_i \\qquad |i-j|>1\\\\\n  s_is_{i+1}s_i&=s_{i+1}s_is_{i+1}\n\\end{align*}\n\n$314624\\to s_2\\to 215634\\to 125634\\to124635\\to124536\\to123546\\to123456$\n\n$s_4s_5s_3s_4s_1s_2$\n\n$s_4s_3s_1s_2s_5s_4$\n\nthese are called \"reduced words for 315624\"\n\nalso try to bring to $123456$ byswapping \\#'s in adjacent positions.\nHow many ways can we make a permutation? infinite. How many ways to make reduced words for a permutation? this is hard.\n\n\\subsection*{Theorem of Stanley}\nThe number of reduced words for (the longest permutation) $n,n-1,n-2,\\cdots,3,2,1$ equals the number of standard Young tableaux of shape (half grid with sides of $n-1$, makes a kind of right triangle). Fill with integers $\\{1,\\dots,\\text{\\# boxes}\\}$\n\\subsubsection*{note}\nthere exists a nice counting formula for the standard young tableux called the hook length formula.\n\n\\subsubsection*{note to self}\ndefinition of determinant here. put it down!\n\n\\subsection*{4.3 generating combinations (subsets)}\nhow do we represent subsets of $\\{x_{n-1},x_{n-2}\\dots,x_1,x_0\\}$?\n\\# subsets is $2^n$. each $x_i$ is either therrre or not there so we can represent subsets with lenght $n$ binary strings.\n\\subsection*{example}\n$x=\\{x_7,\\dots,x_1,x_0\\}->01010110$. What number is this in binary? $2+4+16+64=86$\n\nso we can generate subsets or combinations lexicographically:\n\\subsubsection*{example}\ngenerate all subsets of $x_1,x_2,x_3$.\n\n$\\{\\}=000$ and to $001=1=\\{x_0\\},010=2=\\{x_1\\},011=3=\\{x_0,x_1\\},100=4,101=5,110=6,111=7$\n\nnote that this is not ideal if you want to minimize change from one item to the next. notice how from $3\\to4$ everything changes.\n\n\\subsubsection*{definition}\na \\emph{gray code} is a sequence of subsets such that the change when you move from one subset to the next is minimal.\n\n\\begin{align*}\n  0&1-&-1&1\\\\\n  &|&&|\\\\\n  0&0-&-0&1\n\\end{align*}\nnotice that walking along the square is a gray code.\n\\end{document}\n", "meta": {"hexsha": "d437b59b6958aa5580f14582861d4484b6812ca1", "size": 2514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "combinatorics/combinatorics-notes-2014-02-03.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "combinatorics/combinatorics-notes-2014-02-03.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "combinatorics/combinatorics-notes-2014-02-03.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4347826087, "max_line_length": 250, "alphanum_fraction": 0.7195704057, "num_tokens": 900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.40754544775835333}}
{"text": "\\section{Payout \\& Risk Management}\n\n\\subsection*{Modigliani-Miller on payout}\n\nMM Payout Policy Irrelevance: In a financial market with no imperfections,\nholding fixed its investment policy (hence its free cash flow), a firm's payout\npolicy is irrelevant and does not affect its initial share price.\n\nPaying dividends is a zero NPV transaction. Firm value before dividend = Firm value dividend + Dividend.\n\n\n\\subsection*{Hedging basics}\n\nLet $V_{original}$: Value of the original position (unhedged), \\\\\n$V_{hedging}$ - Value of the hedging position, \\\\\n$V_{net}$ -  Value of the hedged position.\nThen, \\\\\n$V_{net} = V_{original} + (\\text{hedge ratio}) \\times V_{hedging} $\n\nThe hedge is perfect if: 1. $V_{original}$ and $V_{hedging}$ are perfectly correlated, and 2. Hedge ratio is appropriately chosen.\nOtherwise, the hedging is imperfect.\n\n\n\\subsection*{Managing interest rate risk}\n\n\n\\begin{center}\n\t\\begin{tabular}{ |c|c|c|c| } \n\t\t\\hline\n\t\tBond & Price & Dur & ModDur \\\\ \n\t\t\\hline\n\t\tA & $B_A$ & $D_A$ &  $MD_A$ \\\\ \n\t\tB & $B_B$ & $D_B$ &  $MD_B$ \\\\ \n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\n\n$V_P=V_A+V_B = n_AB_A + n_B B_B$ \\\\\n$MD_P = \\frac{V_A}{V_A+V_B} MD_A + \\frac{V_B}{V_A+V_B}MD_B$ \\\\\n\n$\\delta$ is the hedge ratio if bond A is used to hedge bond B  $MD_B-\\delta MD_A=0$, then  $\\delta = \\frac{MD_B}{MD_A}$\n\n\n\\section{From FMF I}\n\n\\subsection*{Arbitrage Pricing}\n\nExample for three assets: riskless bonds pays \\$100 in each state currently traded at $B1_0$, stock 1 pays off $[S1_1, S1_2, S1_3]$ and currently traded at $S1_0$, \nstock 2 pays off $[S2_1, S2_2, S2_3]$ and currently traded at $S2_0$:\n$$\n\\begin{pmatrix}\n\t100 & 100 & 100   \\\\\n\tS1_1 & S1_2 & S1_3 \\\\\n\tS2_1 & S2_2 & S3_3 \\\\\t\t\t\t\t\t\t\n\\end{pmatrix} \\cdot \n\\begin{pmatrix}\n\t\\phi_1 \\\\\n\t\\phi_2 \\\\\n\t\\phi_3 \\\\\t\t\t\t\t\t\t\t\n\\end{pmatrix}\t\n=\n\\begin{pmatrix}\n\tB1_0\\\\\n\tS1_0 \\\\\n\tS2_0 \\\\\t\t\t\t\t\t\t\t\n\\end{pmatrix}\n$$ \nsolve system to find state prices $\\phi_1$, $\\phi_2$, $\\phi_3$.\t\n\n\\subsection*{Interest Rate Risk measures}\n{\\bf Modified Duration (MD) for discount bond $ B_t=\\frac{1}{(1+y)^t} $ } $ MD(B_t) = -\\frac{1}{B_t}\\frac{dB_t}{dy} = \\frac{t}{1+y}$  \\\\\n{\\bf Macaulay Duration} is the weighted average term to maturity  $ D = \\sum_{t=1}^{T} \\left(   \\frac{PV(CF_T)}{B}  t \\right)  =   \\frac{1}{B}\\sum_{t=1}^{T} \\left(  \\frac{CF_t}{(1+y)^t} t \\right)  $ \\\\\n{\\bf Modified Duration} measures bond's interest rate risk by its relative price change with respect\nto a unit change in yield (with a negative sign):  $ MD =  -\\frac{1}{B}\\frac{dB}{dy}  = \\frac{D}{1+y}  $ \\\\\n{\\bf Convexity (CX)} measure the curvature of the bond price as function of the yield:  $ CX =  \\frac{1}{2}\\frac{1}{B}\\frac{d^2B}{dy^2}  $ \\\\\n$ CX = \\frac{1}{2} \\frac{1}{P} \\frac{1}{(1+y)^2} \\sum_{t=1}^{T} \\frac{t (t+1) CF_t}{(1+t)^t} =  \\frac{1}{2} \\frac{1}{P} \\frac{1}{(1+y)^2} \\sum_{t=1}^{T} PV(CF_t) t (t+1)  $ \\\\\n{\\bf Taylor series approximation of bond price changes}  $ \\Delta B \\approx  B \\left(  -MD  \\cdot \\Delta y + CX \\cdot ( \\Delta y)^2 \\right)    $ \\\\\n\n\n\n\n\\subsection*{Growth Opportunities and Stock Valuation}\n\n\\begin{itemize}\n\t\\item {\\bf P/E and PVGO:} $ P_0 = \\frac{EPS_1}{r} + PVGO $\n\t\\item {\\bf if $PVGO=0$:} $ P/E = \\frac{1}{r}  $\n\t\\item {\\bf if $PVGO>0$:} $ P/E = \\frac{1}{r} + \\frac{PVGO}{EPS_2} > \\frac{1}{r} $\n\\end{itemize}\nInvestment and Growth\n\\begin{itemize}\n\t\\item {plow-back ratio} $b_t = 1-payout = 1-\\frac{DIV}{EPS}$\n\t\\item {\\bf Investments:} $ I_t = EPS_t \\cdot b_t $\n\t\\item {\\bf Next year earnings} $ EPS_{t+1} = EPS_t +ROI_t \\cdot I_t $\n\t\\item {\\bf Next year book value:} $ BVPS_{t+1} = BVPS_t + I_{t+1} $\n\t\\item {\\bf Dividends:} $ D_t = EPS_t (1-b_t) $\n\t\\item {\\bf Growh rate:} $g = b \\cdot ROI$\n\t\\item  $V_{0,no inv t>0}=E_1/r$ , $NPV_1 = -E_1 + \\frac{E_2-E_1}{r}$ ,  $V_0 = V_{0,no inv t>0}+\\frac{NPV_1}{1+r}$\t\t\n\\end{itemize}\n\n\n\\subsection*{NPV Rule}\n$NPV = CF_0 + \\frac{CF_1}{1+r_1}+\\frac{CF_2}{(1+r_2)^2} + \\cdots + \\frac{CF_T}{(1+r_T)^T} $\n\n\t$CF = (1-\\tau) (OperatingProfits) - CapEx + \\tau \\cdot Depreciation -\\Delta WC $\\\\\n\t$WC = Inventory + A/R - A/P$, $A/R : \\text{Accounts Receivable}$, $A/P : \\text{Accounts Payable}$\n\t\n\t", "meta": {"hexsha": "0e06cfdb22a8fed8ddc622be40a8efd7ba730895", "size": 4086, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "15.415.2x/assets/week_20.tex", "max_stars_repo_name": "j053g/cheatsheets", "max_stars_repo_head_hexsha": "22f7a84879c04d44de40467ddcc0f6e551b812c7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-12-14T08:49:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T17:26:15.000Z", "max_issues_repo_path": "15.415.2x/assets/week_20.tex", "max_issues_repo_name": "j053g/cheatsheets", "max_issues_repo_head_hexsha": "22f7a84879c04d44de40467ddcc0f6e551b812c7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "15.415.2x/assets/week_20.tex", "max_forks_repo_name": "j053g/cheatsheets", "max_forks_repo_head_hexsha": "22f7a84879c04d44de40467ddcc0f6e551b812c7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1869158879, "max_line_length": 201, "alphanum_fraction": 0.6287322565, "num_tokens": 1599, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.40750504213988825}}
{"text": "\\section{Introduction}\nThe LIGO project uses laser interferometry to measure gravitational waves (GWs).\nLIGO interferometers transduce their relative arm length differences caused by GWs to a signal composed of optical power, known as DARM.\nDue to the amplitude scales of astrophysical GWs, The LIGO detectors have to operate at a very high sensitivity; the spectral density of a measurable length difference is as low as $2\\times 10^{-20}~\\mathrm{m}/\\sqrt{\\mathrm{Hz}}$ at 100 Hz.\nThe design of earthbound LIGO is thus heavily focused on the filtering and isolation of environmental noise.\n\nTo help identify and characterize environment-based noise, the LIGO detector has a Physical Environment Monitoring (PEM) system, a diverse array of environmental sensors positioned all over the facility\\cite{aepaper}.\nThis is used for a multitude of purposes, including the data quality report (DQR) used for time segment vetoing, based on direct coherence of PEM channels to DARM.\nSupplementing coincidence analysis between the two detectors, DQR prevents GW-like noise transients from being falsely categorized as events.\nThus, detector livetime can be increased by figuring out how to decouple environmental noise from DARM.\nDirectly coupling noise, found by basic coherence, has been already addressed, but the complexity of the detector causes many noise sources to up- or down-convert.\nThese require some more careful statistical correlation to identify, and are sometimes not well understood.\n\\begin{figure}\n\\includegraphics[width=\\textwidth]{assets/llopem.png}\n\\caption{Schematic PEM map at the LIGO Livingston Observatory (L1). Shaded areas are in vacuum.}\n\\end{figure}\n\\begin{figure}\n  \\begin{minipage}[c]{0.67\\textwidth}\n  \\begin{tabular}{c}\n  \\includegraphics[width=\\textwidth]{assets/L1-LOCKED_216737_RANGE-1240272018-86400.png}   \\\\  \\includegraphics[width=\\textwidth]{assets/L1-LOCKED_216737_RANGE-1240358418-86400.png}\n  \\end{tabular}\n  \\end{minipage}\\hfill\n  \\begin{minipage}[t]{0.3\\textwidth}\n    \\caption{Detector range at L1 seems to consistently reduce during the day ($\\sim$6am-5pm CST). For large BBH in these plots, the reduction is about 300 Mpc. The source of this has been pinpointed to the Y end station, but the mechanism isn't fully clear.}\n  \\end{minipage}\n\\end{figure}\n\nSeparating noise sources out of a signal can be considered a clustering problem in a space covering different frequency bands in which noise appears.\nA previous LIGO SURF student has evaluated several data clustering algorithms with respect to their ability to properly sort out frequency elements of seismometer signals caused by specific earthquake events\\cite{roxana}.\nBoth the $k$-means algorithm, which aims to make clusters with low standard deviation, and the DBSCAN algorithm, which minimizes overall inter-point distance in clusters, were evaluated using multiple methods, including the Calinsky-Harabaz  index and direct comparison to earthquake times via time labeling of points, ultimately showing poor earthquake identification.\nA long short-term memory (LSTM) recurrent neural network (RNN) seemed to work much better, but due to small input sample size, this solution may have been be plagued by over-fitting.\nThus, it is imperative that a more robust frequency clustering mechanism be designed for the PEM system.\n\n\\section{Objectives}\n% What do you aim to accomplish in your project? What will you measure, and under what conditions; or, what will you calculate, model, or simulate; or what will you design, and what are the requirements; or what will you build or test? What is your starting point? What are your initial assumptions or conditions? What will be the result or product of a successful outcome for your project? What are the criteria for project completion or for success? (In other words, how will you know when you have accomplished what you set out to do?)\n\\begin{itemize}\n\\item\nAs a primary goal, \\textbf{algorithms or clustering approaches which correctly identify known noise events need to be found}.\nAs every algorithm has inbuilt assumptions about the dataset it is applied to, the results of an algorithm performance test on labeled data will yield information about the structure of the data.\nThe general temporal non-stationarity of the DARM noise will need to be accounted for by varying testing time windows.\n\\item\nThe secondary goal is to \\textbf{create a clustering approach to discover previously unknown noise correlations and possibly sources}.\nThis is where the ``detector characterization tool'' that this project aims to advance will be functional---revealing new noise coupling pathways will help identify ways to improve the detector sensitivity.\n\\end{itemize}\n\n\\section{Approach}\n% Specifically, how will you reach your objective or produce your desired final product? What are the principal steps or milestones along the path? How long will each take? What steps promise to be the most difficult, and how will you overcome the difficulties? What equipment or other resources will you need? Which of these are inherited, and which will you have to make or procure? With what other people or groups will you be collaborating? Will completion of your project depend on results from other people in related projects? (That question may be especially pertinent for team projects.)\n\nInitially, a program will be written to take the spectral power of any PEM channel, in the form of band-limited RMS (BLRMS), likely using established methods like looping through a smoothed spectogram of the channel\\cite{vajente}.\n\nTo reach the first objective, a modular \\texttt{python} testing suite will be written to probe the structure of the multidimensional frequency-domain sensor data.\nThis will strategically implement \\texttt{scikit-learn} clustering algorithms and classifiers with different optimal regimes of function or working assumptions and evaluate them using point labeling. \nThis will require, additionally to researching clustering or unsupervised classification algorithms, thinking of as many variables which may affect the data structure (such as looking at different time windows) and intelligently testing them. \nOptimizations will need to be considered so that run times are reasonable.\n\nThe program tackling the second objective will use working clustering approaches identified in the first objective to find new noise correlations.\nIn the event that no individual algorithm or technique outperforms the rest for all types of sensory data, the final program will use the modular programming environment created for the testing suite to match techniques to the regimes that they work in.\nThe structure of the input data as determined by the first objective, including the dimensionality probed by the extra variables, may lend itself to additional algorithms that can be used to combine the target regimes.\nTo this end, extra algorithm research will be conducted with specific consideration of the solved structure.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../proposal\"\n%%% End:\n", "meta": {"hexsha": "c7c5fe6b487f80cd5bd389472b555b829ec55988", "size": 7050, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/include/motivation.tex", "max_stars_repo_name": "bernhardtj/DetectorChar", "max_stars_repo_head_hexsha": "be9fffc0a56c9c8848c67917a839d743a0380ce2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/include/motivation.tex", "max_issues_repo_name": "bernhardtj/DetectorChar", "max_issues_repo_head_hexsha": "be9fffc0a56c9c8848c67917a839d743a0380ce2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/include/motivation.tex", "max_forks_repo_name": "bernhardtj/DetectorChar", "max_forks_repo_head_hexsha": "be9fffc0a56c9c8848c67917a839d743a0380ce2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 108.4615384615, "max_line_length": 596, "alphanum_fraction": 0.8083687943, "num_tokens": 1480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5621765008857982, "lm_q1q2_score": 0.4075050354572095}}
{"text": "\n\\chapter{Funcoids are filters}\\label{fcd-filters}\n\nThe motto of this chapter is: ``Funcoids are filters on a (boolean) lattice.''\n\n\n\\section{Rearrangement of collections of sets}\n\nLet $Q$ be a set of sets.\n\nLet $\\equiv$ be the relation on $\\bigcup Q$ defined by the formula\n\\[\na\\equiv b\\Leftrightarrow\\forall X\\in Q:(a\\in X\\Leftrightarrow b\\in X).\n\\]\n\n\\begin{prop}\n$\\equiv$ is an equivalence relation on $\\bigcup Q$.\\end{prop}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{Reflexivity}] Obvious.\n\\item [{Symmetry}] Obvious.\n\\item [{Transitivity}] Let $a\\equiv b\\wedge b\\equiv c$. Then $a\\in X\\Leftrightarrow b\\in X\\Leftrightarrow c\\in X$\nfor every $X\\in Q$. Thus $a\\equiv c$.\n\\end{description}\n\\end{proof}\n\\begin{defn}\n\\emph{Rearrangement} $\\mathfrak{R}(Q)$ of $Q$ is the set of equivalence\nclasses of $\\bigcup Q$ for $\\equiv$.\\end{defn}\n\\begin{obvious}\n$\\bigcup\\mathfrak{R}(Q)=\\bigcup Q$.\n\\end{obvious}\n\n\\begin{obvious}\n$\\emptyset\\notin\\mathfrak{R}(Q)$.\\end{obvious}\n\\begin{lem}\n$\\card\\mathfrak{R}(Q)\\leq2^{\\card Q}$.\\end{lem}\n\\begin{proof}\nHaving an equivalence class $C$, we can find the set $f\\in\\subsets Q$\nof all $X\\in Q$ such that $a\\in X$, for every $a\\in C$. \n\\[\nb\\equiv a\\Leftrightarrow\\forall X\\in Q:(a\\in X\\Leftrightarrow b\\in X)\\Leftrightarrow\\forall X\\in Q:(X\\in f\\Leftrightarrow b\\in X).\n\\]\nSo $C=\\setcond{b\\in\\bigcup Q}{b\\equiv a}$ can be restored knowing\n$f$. Consequently there are no more than $\\card\\subsets Q=2^{\\card Q}$\nclasses.\\end{proof}\n\\begin{cor}\nIf $Q$ is finite, then $\\mathfrak{R}(Q)$ is finite.\\end{cor}\n\\begin{prop}\nIf $X\\in Q$, $Y\\in\\mathfrak{R}(Q)$ then $X\\cap Y\\neq\\emptyset\\Leftrightarrow Y\\subseteq X$.\\end{prop}\n\\begin{proof}\nLet $X\\cap Y\\neq\\emptyset$ and $x\\in X\\cap Y$. Then \n\\[\ny\\in Y\\Leftrightarrow x\\equiv y\\Leftrightarrow\\forall X'\\in Q:(x\\in X'\\Leftrightarrow y\\in X')\\Rightarrow(x\\in X\\Leftrightarrow y\\in X)\\Leftrightarrow y\\in X\n\\]\n for every $y$. Thus $Y\\subseteq X$.\n\n$Y\\subseteq X\\Rightarrow X\\cap Y\\neq\\emptyset$ because $Y\\neq\\emptyset$.\\end{proof}\n\\begin{prop}\nIf $\\emptyset\\neq X\\in Q$ then there exists $Y\\in\\mathfrak{R}(Q)$\nsuch that $Y\\subseteq X\\wedge X\\cap Y\\neq\\emptyset$.\\end{prop}\n\\begin{proof}\nLet $a\\in X$. Then \n\\begin{multline*}\n[a]=\\setcond{b\\in\\bigcup Q}{\\forall X'\\in Q:(a\\in X'\\Leftrightarrow b\\in X')}\\subseteq\\\\\n\\setcond{b\\in\\bigcup Q}{a\\in X\\Leftrightarrow b\\in X} = \\setcond{b\\in\\bigcup Q}{b\\in X}=X.\n\\end{multline*}\nBut $[a]\\in\\mathfrak{R}(Q)$.\n\n$X\\cap Y\\neq\\emptyset$ follows from $Y\\subseteq X$ by the previous\nproposition.\\end{proof}\n\\begin{prop}\nIf $X\\in Q$ then $X=\\bigcup(\\mathfrak{R}(Q)\\cap\\subsets X)$.\\end{prop}\n\\begin{proof}\n$\\bigcup(\\mathfrak{R}(Q)\\cap\\subsets X)\\subseteq X$ is obvious.\n\nLet $x\\in X$. Then there is $Y\\in\\mathfrak{R}(Q)$ such that $x\\in Y$.\nWe have $Y\\subseteq X$ that is $Y\\in\\subsets X$ by a proposition\nabove. So $x\\in Y$ where $Y\\in\\mathfrak{R}(Q)\\cap\\subsets X$ and\nthus $x\\in\\bigcup(\\mathfrak{R}(Q)\\cap\\subsets X)$. We have $X\\subseteq\\bigcup(\\mathfrak{R}(Q)\\cap\\subsets X)$.\n\\end{proof}\n\n\\section{Finite unions of Cartesian products}\n\nLet $A$, $B$ be sets.\n\nI will denote $\\overline{X}=A\\setminus X$.\n\nLet denote $\\Gamma(A,B)$ the set of all finite unions $X_{0}\\times Y_{0}\\cup\\ldots\\cup X_{n-1}\\times Y_{n-1}$\nof Cartesian products, \\ where $n\\in\\mathbb{N}$ and $X_{i}\\in\\subsets A$,\n$Y_{i}\\in\\subsets B$ for every $i=0,\\ldots,n-1$.\n\\begin{prop}\nThe following sets are pairwise equal:\n\\begin{enumerate}\n\\item \\label{gamma-gamma}$\\Gamma(A,B)$;\n\\item \\label{gamma-YX}the set of all sets of the form $\\bigcup_{X\\in S}(X\\times Y_{X})$\nwhere $S$ are finite collections on $A$ and $Y_{X}\\in\\subsets B$\nfor every $X\\in S$;\n\\item \\label{gamma-YXpart}the set of all sets of the form $\\bigcup_{X\\in S}(X\\times Y_{X})$\nwhere $S$ are finite partitions of $A$ and $Y_{X}\\in\\subsets B$\nfor every $X\\in S$;\n\\item \\label{gamma-sigma}the set of all finite unions $\\bigcup_{(X,Y)\\in\\sigma}(X\\times Y)$\nwhere $\\sigma$ is a relation between a partition of $A$ and a partition\nof $B$ (that is $\\dom\\sigma$ is a partition of $A$ and $\\im\\sigma$\nis a partition of $B$).\n\\item \\label{gamma-lineX}the set of all finite intersections $\\bigcap_{i=0,\\ldots,n-1}\\left(X_{i}\\times Y_{i}\\cup\\overline{X_{i}}\\times B\\right)$\nwhere $n\\in\\mathbb{N}$ and $X_{i}\\in\\subsets A$, $Y_{i}\\in\\subsets B$\nfor every $i=0,\\ldots,n-1$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\n~\n\\begin{description}\n\\item [{\\ref{gamma-gamma}$\\supseteq$\\ref{gamma-YX},~\\ref{gamma-YX}$\\supseteq$\\ref{gamma-YXpart}}] Obvious.\n\\item [{\\ref{gamma-gamma}$\\subseteq$\\ref{gamma-YX}}] Let $Q\\in\\Gamma(A,B)$.\nThen $Q=X_{0}\\times Y_{0}\\cup\\ldots\\cup X_{n-1}\\times Y_{n-1}$. Denote\n$S=\\{X_{0},\\ldots,X_{n-1}\\}$. We have $Q=\\bigcup_{X'\\in S}\\left(X'\\times\\bigcup_{i=0,\\dots,n-1}\\setcond{Y_{i}}{X_{i}=X'}\\right)\\in\\text{\\ref{gamma-YX}}$.\n\\item [{\\ref{gamma-YX}$\\subseteq$\\ref{gamma-YXpart}}] Let $Q=\\bigcup_{X\\in S}(X\\times Y_{X})$\nwhere $S$ is a finite collection on $A$ and $Y_{X}\\in\\subsets B$\nfor every $X\\in S$. Let \n\\[\nP=\\bigcup_{X'\\in\\mathfrak{R}(S)}\\left(X'\\times\\bigcup_{X\\in S}\\setcond{Y_{X}}{\\exists X\\in S:X'\\subseteq X}\\right).\n\\]\nTo finish the proof let's show $P=Q$.\n\n\n$\\langle P\\rangle^{\\ast}\\{x\\}=\\bigcup_{X\\in S}\\setcond{Y_{X}}{\\exists X\\in S:X'\\subseteq X}$\nwhere $x\\in X'$.\n\n\nThus $\\langle P\\rangle^{\\ast}\\{x\\}=\\bigcup\\setcond{Y_{X}}{\\exists X\\in S:x\\in X}=\\langle Q\\rangle^{\\ast}\\{x\\}$.\nSo $P=Q$.\n\n\\item [{\\ref{gamma-sigma}$\\subseteq$\\ref{gamma-YXpart}}] $\\bigcup_{(X,Y)\\in\\sigma}(X\\times Y)=\\bigcup_{X\\in\\dom\\sigma}\\left(X\\times\\bigcup\\setcond{Y\\in\\subsets B}{(X,Y)\\in\\sigma}\\right)\\in\\text{\\text{\\ref{gamma-YXpart}}}$.\n\\item [{\\ref{gamma-YXpart}$\\subseteq$\\ref{gamma-sigma}}] \n\\begin{multline*}\n\\bigcup_{X\\in S}(X\\times Y_{X})=\\bigcup_{X\\in S}\\left(X\\times\\bigcup\\left(\\mathfrak{R}\\left(\\setcond{Y_{X}}{X\\in S}\\right)\\cap\\subsets Y_{X}\\right)\\right)=\\\\\n\\bigcup_{X\\in S}\\left(X\\times\\bigcup\\setcond{Y'\\in\\mathfrak{R}\\left(\\setcond{Y_{X}}{X\\in S}\\right)}{Y'\\subseteq Y_{X}}\\right)=\\\\\n\\bigcup_{X\\in S}\\left(X\\times\\bigcup\\setcond{Y'\\in\\mathfrak{R}\\left(\\setcond{Y_{X}}{X\\in S}\\right)}{(X,Y')\\in\\sigma}\\right)=\\bigcup_{(X,Y)\\in\\sigma}(X\\times Y)\n\\end{multline*}\n where $\\sigma$ is a relation between $S$ and $\\mathfrak{R}\\left(\\setcond{Y_{X}}{X\\in S}\\right)$,\nand $(X,Y')\\in\\sigma\\Leftrightarrow Y'\\subseteq Y_{X}$.\n\\item [{\\ref{gamma-lineX}$\\subseteq$\\ref{gamma-gamma}}] Obvious.\n\\item [{\\ref{gamma-YXpart}$\\subseteq$\\ref{gamma-lineX}}] Let $Q=\\bigcup_{X\\in S}(X\\times Y_{X})=\\bigcup_{i=0,\\ldots,n-1}(X_{i}\\times Y_{i})$\nfor a partition $S=\\{X_{0},\\ldots,X_{n-1}\\}$ of $A$. Then $Q=\\bigcap_{i=0,\\ldots,n-1}\\left(X_{i}\\times Y_{i}\\cup\\overline{X_{i}}\\times B\\right)$.\n\\end{description}\n\\end{proof}\n\\begin{xca}\nFormulate the duals of these sets.\\end{xca}\n\\begin{prop}\n$\\Gamma(A,B)$ is a boolean lattice, a sublattice of the lattice $\\subsets(A\\times B)$.\\end{prop}\n\\begin{proof}\nThat it's a sublattice is obvious. That it has complement, is also\nobvious. Distributivity follows from distributivity of $\\subsets(A\\times B)$.\n\\end{proof}\n\n\\section{Before the diagram}\n\nNext we will prove the below theorem \\ref{fcd-diagram} (the theorem\nwith a diagram). First we will present parts of this theorem as several\nlemmas, and then then state a statement about the diagram which concisely\nsummarizes the lemmas (and their easy consequences).\n\nBelow for simplicity we will equate reloids with their graphs (that\nis with filters on binary cartesian products).\n\\begin{obvious}\n$\\up^{\\Gamma(\\Src f,\\Dst f)}f=(\\up f)\\cap\\Gamma$ for every reloid\n$f$.\\end{obvious}\n\\begin{conjecture}\n$\\upuparrows^{\\mathfrak{F}(\\mathfrak{B})}\\up^{\\mathfrak{A}}\\mathcal{X}$\nis not a filter for some filter $\\mathcal{X}\\in\\mathfrak{F}\\Gamma(A,B)$\nfor some sets $A$, $B$.\\end{conjecture}\n\\begin{rem}\nAbout this conjecture see also: \n\\begin{itemize}\n\\item \\href{http://goo.gl/DHyuuU}{http://goo.gl/DHyuuU}\n\\item \\href{http://goo.gl/4a6wY6}{http://goo.gl/4a6wY6}\n\\end{itemize}\n\\end{rem}\n\\begin{lem}\n\\label{faf-bij}Let $A$, $B$ be sets. The following are mutually\ninverse order isomorphisms between $\\mathfrak{F}\\Gamma(A,B)$ and\n$\\mathsf{FCD}(A,B)$:\n\\begin{enumerate}\n\\item $\\mathcal{A}\\mapsto\\bigsqcap^{\\mathsf{FCD}}\\up\\mathcal{A}$;\n\\item $f\\mapsto\\up^{\\Gamma(A,B)}f$.\n\\end{enumerate}\n\\end{lem}\n\\begin{proof}\nLet's prove that $\\up^{\\Gamma(A,B)}f$ is a filter for every funcoid\n$f$. We need to prove that $P\\cap Q\\in\\up f$ whenever \n\\[\nP=\\bigcap_{i=0,\\ldots,n-1}\\left(X_{i}\\times Y_{i}\\cup\\overline{X_{i}}\\times B\\right)\\quad\\text{and}\\quad Q=\\bigcap_{j=0,\\ldots,m-1}\\left(X'_{j}\\times Y'_{j}\\cup\\overline{X'_{j}}\\times B\\right).\n\\]\nThis follows from $P\\in\\up f\\Leftrightarrow\\forall i\\in0,\\ldots,n-1:\\supfun fX_{i}\\subseteq Y_{i}$\nand likewise for $Q$, so having $\\supfun f(X_{i}\\cap X'_{j})\\subseteq Y_{i}\\cap Y'_{j}$\nfor every $i=0,\\ldots,n-1$ and $j=0,\\ldots,m-1$. From this it follows\n\\[\n((X_{i}\\cap X'_{j})\\times(Y_{i}\\cap Y'_{j}))\\cup\\left(\\overline{X_{i}\\cap X'_{j}}\\times B\\right)\\supseteq f\n\\]\nand thus $P\\cap Q\\in\\up f$.\n\nLet $\\mathcal{A}$, $\\mathcal{B}$ be filters on $\\Gamma$. Let $\\bigsqcap^{\\mathsf{FCD}}\\up\\mathcal{A}=\\bigsqcap^{\\mathsf{FCD}}\\up\\mathcal{B}$.\nWe need to prove $\\mathcal{A}=\\mathcal{B}$. (The rest follows from\nproof of the lemma~\\ref{fcd-rep}). We have:\n\\begin{align*}\n\\mathcal{A}=\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B\\in\\up\\mathcal{A}}{X\\in\\subsets A,Y\\in\\subsets B} & =\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\exists P\\in\\up\\mathcal{A}:P\\subseteq X\\times Y\\cup\\overline{X}\\times B} & =\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\exists P\\in\\up\\mathcal{A}:\\rsupfun PX\\subseteq Y} & =\\text{(*)}\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\bigsqcap\\setcond{\\rsupfun PX}{X\\in\\up\\mathcal{A}}\\sqsubseteq Y} & =\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\bigsqcap\\setcond{\\rsupfun PX}{X\\in\\up\\bigsqcap^{\\mathsf{RLD}}\\up\\mathcal{A}}\\sqsubseteq Y} & =\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\left\\langle \\tofcd\\bigsqcap^{\\mathsf{RLD}}\\up\\mathcal{A}\\right\\rangle X\\sqsubseteq Y} & =\\text{(**)}\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\left\\langle \\bigsqcap^{\\mathsf{FCD}}\\up\\bigsqcap^{\\mathsf{RLD}}\\up\\mathcal{A}\\right\\rangle X\\sqsubseteq Y} & =\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\left\\langle \\bigsqcap^{\\mathsf{FCD}}\\up\\mathcal{A}\\right\\rangle X\\sqsubseteq Y}.\n\\end{align*}\n\n\n({*}) by properties of generalized filter bases, because $\\setcond{\\rsupfun PX}{P\\in\\up\\mathcal{A}}$\nis a filter base.\n\n({*}{*}) by theorem \\ref{fcd-as-meet}.\n\nSimilarly \n\\[\n\\mathcal{B}=\\bigsqcap^{\\mathsf{FCD}}\\setcond{X\\times Y\\cup\\overline{X}\\times B}{X\\in\\subsets A,Y\\in\\subsets B,\\left\\langle \\bigsqcap^{\\mathsf{FCD}}\\up\\mathcal{B}\\right\\rangle X\\sqsubseteq Y}.\n\\]\nThus $\\mathcal{A}=\\mathcal{B}$.\\end{proof}\n\\begin{prop}\n$g\\circ f\\in\\Gamma(A,C)$ if $f\\in\\Gamma(A,B)$ and $g\\in\\Gamma(B,C)$\nfor some sets $A$, $B$, $C$.\\end{prop}\n\\begin{proof}\nBecause composition of Cartesian products is a Cartesian product.\\end{proof}\n\\begin{defn}\n$g\\circ f=\\bigsqcap^{\\mathfrak{F}\\Gamma(A,C)}\\setcond{G\\circ F}{F\\in\\up f,G\\in\\up g}$\nfor $f\\in\\mathfrak{F}\\Gamma(A,B)$ and $g\\in\\mathfrak{F}\\Gamma(B,C)$\n(for every sets $A$, $B$, $C$).\n\\end{defn}\nWe define $f^{-1}$ for $f\\in\\mathfrak{F}\\Gamma(A,B)$ similarly to\n$f^{-1}$ for reloids and similarly derive the formulas:\n\\begin{enumerate}\n\\item $(f^{-1})^{-1}=f$;\n\\item $(g\\circ f)^{-1}=f^{-1}\\circ g^{-1}$.\n\\end{enumerate}\n\n\\section{Associativity over composition}\n\\begin{lem}\n\\label{uparr-gamma-comp}$\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,C)}(g\\circ f)=\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}\\right)$\nfor every $f\\in\\mathfrak{F}(\\Gamma(A,B))$, $g\\in\\mathfrak{F}(\\Gamma(B,C))$\n(for every sets $A$, $B$, $C$).\\end{lem}\n\\begin{proof}\nIf $K\\in\\up\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,C)}(g\\circ f)$ then\n$K\\supseteq G\\circ F$ for some $F\\in f$, $G\\in g$. But $F\\in\\up^{\\Gamma(A,B)}f$,\nthus \n\\[\nF\\in\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,B)}f\n\\]\nand similarly \n\\[\nG\\in\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}g.\n\\]\nSo we have \n\\[\nK\\supseteq G\\circ F\\in\\up\\left(\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,B)}f\\right)\\right).\n\\]\nLet now \n\\[\nK\\in\\up\\left(\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,B)}f\\right)\\right).\n\\]\nThen there exist $F\\in\\up\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,B)}f$\nand $G\\in\\up\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(B,C)}g$ such that\n$K\\supseteq G\\circ F$. By properties of generalized filter bases\nwe can take $F\\in\\up^{\\Gamma(A,B)}f$ and $G\\in\\up^{\\Gamma(B,C)}g$.\nThus $K\\in\\up^{\\Gamma(A,C)}(g\\circ f)$ and so $K\\in\\up\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(A,C)}(g\\circ f)$.\\end{proof}\n\\begin{lem}\n$\\torldin X=X$ for $X\\in\\Gamma(A,B)$.\\end{lem}\n\\begin{proof}\n$X=X_{0}\\times Y_{0}\\cup\\ldots\\cup X_{n}\\times Y_{n}=(X_{0}\\times^{\\mathsf{FCD}}Y_{0})\\sqcup^{\\mathsf{FCD}}\\ldots\\sqcup^{\\mathsf{FCD}}(X_{n}\\times^{\\mathsf{FCD}}Y_{n})$.\n\\begin{multline*}\n\\torldin X=\\\\\n\\torldin(X_{0}\\times^{\\mathsf{FCD}}Y_{0})\\sqcup^{\\mathsf{RLD}}\\ldots\\sqcup^{\\mathsf{RLD}}\\torldin(X_{n}\\times^{\\mathsf{FCD}}Y)=\\\\\n(X_{0}\\times^{\\mathsf{RLD}}Y_{0})\\sqcup^{\\mathsf{RLD}}\\ldots\\sqcup^{\\mathsf{RLD}}(X_{n}\\times^{\\mathsf{RLD}}Y_{n})=\\\\\nX_{0}\\times Y_{0}\\cup\\ldots\\cup X_{n}\\times Y_{n}=X.\n\\end{multline*}\n\\end{proof}\n\\begin{lem}\n\\label{rld-in-fcd-meet}$\\bigsqcap^{\\mathsf{RLD}} f=\\torldin\\bigsqcap^{\\mathsf{FCD}} f$\nfor every filter $f\\in\\mathfrak{F}\\Gamma(A,B)$.\\end{lem}\n\\begin{proof}\n~\n\\[\n\\torldin\\bigsqcap^{\\mathsf{FCD}} f=\\bigsqcap^{\\mathsf{RLD}}\\rsupfun{\\torldin} f=\n\\text{(by the previous lemma)}=\\bigsqcap^{\\mathsf{RLD}} f.\n\\]\n\\end{proof}\n\\begin{lem}\n\\label{rld-gamma-bij}~\n\\begin{enumerate}\n\\item \\label{rld-gamma-bij-mu}$f\\mapsto\\bigsqcap^{\\mathsf{RLD}}\\up f$\nand $\\mathcal{A}\\mapsto\\Gamma(A,B)\\cap\\up\\mathcal{A}$ are mutually\ninverse bijections between $\\mathfrak{F}\\Gamma(A,B)$ and a subset\nof reloids.\n\\item \\label{rld-gamma-bij-comp}These bijections preserve composition.\n\\end{enumerate}\n\\end{lem}\n\\begin{proof}\n~\n\\begin{widedisorder}\n\\item [{\\ref{rld-gamma-bij-mu}}] That they are mutually inverse bijections\nis obvious.\n\\item [{\\ref{rld-gamma-bij-comp}}] ~\n\\begin{multline*}\n\\left(\\bigsqcap^{\\mathsf{RLD}}\\up g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{RLD}}\\up f\\right)=\\bigsqcap^{\\mathsf{RLD}}\\setcond{G\\circ F}{F\\in\\bigsqcap^{\\mathsf{RLD}}f,G\\in\\bigsqcap^{\\mathsf{RLD}}g}=\\\\\n\\bigsqcap^{\\mathsf{RLD}}\\setcond{G\\circ F}{F\\in f,G\\in g}=\\bigsqcap^{\\mathsf{RLD}}\\bigsqcap^{\\mathfrak{F}\\Gamma(\\Src f,\\Dst g)}\\setcond{G\\circ F}{F\\in f,G\\in g}=\\bigsqcap^{\\mathsf{RLD}}(g\\circ f).\n\\end{multline*}\nSo $\\bigsqcap^{\\mathsf{RLD}}$ preserves composition. That $\\mathcal{A}\\mapsto\\Gamma(A,B)\\cap\\up\\mathcal{A}$\npreserves composition follows from properties of bijections.\n\\end{widedisorder}\n\\end{proof}\n\\begin{lem}\nLet $A$, $B$, $C$ be sets.\n\\begin{enumerate}\n\\item $\\left(\\bigsqcap^{\\mathsf{FCD}}\\up g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{FCD}}\\up f\\right)=\\bigsqcap^{\\mathsf{FCD}}\\up(g\\circ f)$\nfor every $f\\in\\mathfrak{F}\\Gamma(A,B)$, $g\\in\\mathfrak{F}\\Gamma(B,C)$;\n\\item $(\\up^{\\Gamma(B,C)}g)\\circ(\\up^{\\Gamma(A,B)}f)=\\up^{\\Gamma(A,B)}(g\\circ f)$\nfor every funcoids $f\\in\\mathsf{FCD}(A,B)$ and $g\\in\\mathsf{FCD}(B:C)$.\n\\end{enumerate}\n\\end{lem}\n\\begin{proof}\nIt's enough to prove only the first formula, because of the bijection\nfrom lemma~\\ref{faf-bij}.\n\nReally: \n\\begin{multline*}\n\\bigsqcap^{\\mathsf{FCD}}\\up(g\\circ f)=\\bigsqcap^{\\mathsf{FCD}}\\up\\bigsqcap^{\\mathsf{RLD}}\\up(g\\circ f)=\\\\\n\\bigsqcap^{\\mathsf{FCD}}\\up\\left(\\bigsqcap^{\\mathsf{RLD}}\\up g\\circ\\bigsqcap^{\\mathsf{RLD}}\\up f\\right)=\\tofcd\\left(\\bigsqcap^{\\mathsf{RLD}}\\up g\\circ\\bigsqcap^{\\mathsf{RLD}}\\up f\\right)=\\\\\n\\left(\\tofcd\\bigsqcap^{\\mathsf{RLD}}\\up g\\right)\\circ\\left(\\tofcd\\bigsqcap^{\\mathsf{RLD}}\\up f\\right)=\\\\\n\\left(\\bigsqcap^{\\mathsf{FCD}}\\up\\bigsqcap^{\\mathsf{RLD}}\\up g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{FCD}}\\up\\bigsqcap^{\\mathsf{RLD}}\\up f\\right)=\\\\\n\\left(\\bigsqcap^{\\mathsf{FCD}}\\up g\\right)\\circ\\left(\\bigsqcap^{\\mathsf{FCD}}\\up f\\right).\n\\end{multline*}\n\\end{proof}\n\\begin{cor}\n$(h\\circ g)\\circ f=h\\circ(g\\circ f)$ for every $f\\in\\mathfrak{F}(\\Gamma(A,B))$,\n$g\\in\\mathfrak{F}\\Gamma(B,C)$, $h\\in\\mathfrak{F}\\Gamma(C,D)$ for\nevery sets $A$, $B$, $C$, $D$.\\end{cor}\n\\begin{lem}\n$\\Gamma(A,B)\\cap\\GR f$ is a filter on the lattice $\\Gamma(A,B)$\nfor every reloid $f\\in\\mathsf{RLD}(A,B)$.\\end{lem}\n\\begin{proof}\nThat it is an upper set, is obvious. If $A,B\\in\\Gamma(A,B)\\cap\\GR f$\nthen $A,B\\in\\Gamma(A,B)$ and $A,B\\in\\GR f$. Thus $A\\cap B\\in\\Gamma(A,B)\\cap\\GR f$.\\end{proof}\n\\begin{prop}\nIf $Y\\in\\up\\supfun f\\mathcal{X}$ for a funcoid $f$ then there exists\n$A\\in\\up\\mathcal{X}$ such that $Y\\in\\up\\langle f\\rangle A$.\\end{prop}\n\\begin{proof}\n$Y\\in\\up\\bigsqcap_{A\\in\\up a}^{\\mathscr{F}}\\supfun fA$. So by properties\nof generalized filter bases, there exists $A\\in\\up a$ such that $Y\\in\\up\\supfun fA$.\\end{proof}\n\\begin{lem}\n$\\tofcd f=\\bigsqcap^{\\mathsf{FCD}}(\\Gamma(A,B)\\cap\\GR f)$ for every\nreloid $f\\in\\mathsf{RLD}(A,B)$.\\end{lem}\n\\begin{proof}\nLet $a$ be an an atomic filter object. We need to prove \n\\[\n\\supfun{\\tofcd f}a=\\supfun{\\bigsqcap^{\\mathsf{FCD}}(\\Gamma(A,B)\\cap\\GR f)}a\n\\]\nthat is \n\\[\n\\supfun{\\bigsqcap^{\\mathsf{FCD}}\\up f}a=\\supfun{\\bigsqcap^{\\mathsf{FCD}}(\\Gamma(A,B)\\cap\\GR f)}a\n\\]\nthat is \n\\[\n\\bigsqcap_{F\\in\\up f}^{\\mathscr{F}}\\supfun Fa=\\bigsqcap_{F\\in\\Gamma(A,B)\\cap\\up f}^{\\mathscr{F}}\\supfun Fa.\n\\]\nFor this it's enough to prove that $Y\\in\\up\\supfun Fa$ for some $F\\in\\up f$\nimplies $Y\\in\\up\\supfun{F'}a$ for some $F'\\in\\Gamma(A,B)\\cap\\GR f$.\n\nLet $Y\\in\\up\\supfun Fa$. Then (proposition above) there exists $A\\in\\up a$\nsuch that $Y\\in\\up\\supfun FA$.\n\n$Y\\in\\up\\supfun{A\\times^{\\mathsf{FCD}}Y\\sqcup\\overline{A}\\times^{\\mathsf{FCD}}\\top}a$;\n$\\supfun{A\\times^{\\mathsf{FCD}}Y\\sqcup\\overline{A}\\times^{\\mathsf{FCD}}\\top}\\mathcal{X}=Y\\in\\up\\supfun F\\mathcal{X}$\nif $\\bot\\neq\\mathcal{X}\\sqsubseteq A$ and $\\supfun{A\\times^{\\mathsf{FCD}}Y\\sqcup\\overline{A}\\times^{\\mathsf{FCD}}\\top}\\mathcal{X}=\\top\\in\\up\\langle F\\rangle\\mathcal{X}$\nif $\\mathcal{X}\\nsqsubseteq A$.\n\nThus $A\\times^{\\mathsf{FCD}}Y\\sqcup\\overline{A}\\times^{\\mathsf{FCD}}\\top\\sqsupseteq F$.\nSo $A\\times^{\\mathsf{FCD}}Y\\sqcup\\overline{A}\\times^{\\mathsf{FCD}}\\top$\nis the sought for~$F'$.\n\\end{proof}\n\n\\section{The diagram}\n\\begin{thm}\n\\label{fcd-diagram}The diagram at the figure~\\ref{gamma-dia} is\na commutative diagram (in category $\\mathbf{Set}$), every arrow in\nthis diagram is an isomorphism. Every cycle in this diagram is an\nidentity (therefore ``parallel'' arrows are mutually inverse). The\narrows preserve order, composition, and reversal ($f\\mapsto f^{-1}$).\n\n\\begin{figure}[ht]\n\\begin{tikzcd}[row sep=3cm, column sep=0.9cm]\n& \\text{funcoids}\n\\arrow[rd, shift left, \"\\up^\\Gamma\"]\n\\arrow[ld, shift left, \"\\torldin\"] \\\\\n\\text{funcoidal reloids}\n\\arrow[ru, shift left, \"\\tofcd\"]\n\\arrow[rr, shift left, \"f\\mapsto f\\cap\\Gamma\"]\n& & \\text{filters on $\\Gamma$}\n\\arrow[lu, shift left, \"\\bigsqcap^{\\mathsf{FCD}}\"]\n\\arrow[ll, shift left, \"\\bigsqcap^{\\mathsf{RLD}}\"]\n\\end{tikzcd}\n\\caption{\\label{gamma-dia}}\n\\end{figure}\n\\end{thm}\n\\begin{proof}\nFirst we need to show that $\\bigsqcap^{\\mathsf{RLD}}f$ is a funcoidal\nreloid. But it follows from lemma~\\ref{rld-in-fcd-meet}.\n\nNext, we need to show that all morphisms depicted on the diagram are\nbijections and the depicted ``opposite'' morphisms are mutually\ninverse.\n\nThat $\\tofcd$ and $\\torldin$ are mutually inverse was proved above\nin the book.\n\nThat $\\bigsqcap^{\\mathsf{RLD}}$ and $f\\mapsto f\\cap\\Gamma$ are mutually\ninverse was proved above.\n\nThat $\\bigsqcap^{\\mathsf{FCD}}$ and $\\up^{\\Gamma}$ are mutually\ninverse was proved above.\n\nThat the morphisms preserve order and composition was proved above.\nThat they preserve reversal is obvious.\n\nSo it remains to apply lemma~\\ref{three-loop-lem} (taking into account\nlemma~\\ref{rld-in-fcd-meet}).\n\\end{proof}\n\nAnother proof that $\\tofcd\\torldin f=f$ for every funcoid $f$:\n\\begin{proof}\nFor every filter $\\mathcal{X}\\in\\mathscr{F}(\\Src f)$ we have $\\langle\\tofcd\\torldin f\\rangle\\mathcal{X}=\\bigsqcap_{F\\in\\up\\torldin f}^{\\mathscr{F}}\\supfun F\\mathcal{X}=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}$.\n\nObviously $\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}\\sqsupseteq\\supfun f\\mathcal{X}$.\nSo $\\tofcd\\torldin f\\sqsupseteq f$.\n\nLet $Y\\in\\up\\supfun f\\mathcal{X}$. Then (proposition above) there\nexists $A\\in\\up\\mathcal{X}$ such that $Y\\in\\up\\langle f\\rangle A$.\n\nThus $A\\times Y\\sqcup\\overline{A}\\times\\top\\in\\up f$. So $\\supfun{\\tofcd\\torldin f}\\mathcal{X}=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}\\sqsubseteq\\supfun{A\\times Y\\sqcup\\overline{A}\\times\\top}\\mathcal{X}=Y$.\nSo $Y\\in\\up\\supfun{\\tofcd\\torldin f}\\mathcal{X}$ that\nis $\\supfun f\\mathcal{X}\\sqsupseteq\\supfun{\\tofcd\\torldin f}\\mathcal{X}$\nthat is $f\\sqsupseteq\\tofcd\\torldin f$.\\end{proof}\n\n\\section{Some additional properties}\n\\begin{prop}\nFor every funcoid $f\\in\\mathsf{FCD}(A,B)$ (for sets $A$, $B$):\n\\begin{enumerate}\n\\item $\\dom f=\\bigsqcap^{\\mathscr{F}(A)}\\langle\\dom\\rangle^{\\ast}\\up^{\\Gamma(A,B)}f$;\n\\item $\\im f=\\bigsqcap^{\\mathscr{F}(B)}\\langle\\im\\rangle^{\\ast}\\up^{\\Gamma(A,B)}f$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\nTake $\\setcond{X\\times Y}{X\\in\\subsets A,Y\\in\\subsets B,X\\times Y\\supseteq f}\\subseteq\\up^{\\Gamma(A,B)}f$.\nI leave the rest reasoning as an exercise.\\end{proof}\n\\begin{thm}\nFor every reloid $f$ and $\\mathcal{X}\\in\\mathscr{F}(\\Src f)$, $\\mathcal{Y}\\in\\mathscr{F}(\\Dst f)$:\n\\begin{enumerate}\n\\item \\label{fcd-up-g-rel}$\\mathcal{X}\\mathrel{[\\tofcd f]}\\mathcal{Y}\\Leftrightarrow\\forall F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f:\\mathcal{X}\\suprel F\\mathcal{Y}$;\n\\item \\label{fcd-up-g-fcd}$\\langle\\tofcd f\\rangle\\mathcal{X}=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\n~\n\\begin{widedisorder}\n\\item [{\\ref{fcd-up-g-rel}}] ~\n\\begin{multline*}\n\\forall F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f:\\mathcal{X}\\suprel F\\mathcal{Y}\\Leftrightarrow\\\\\n\\forall F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f:(\\mathcal{X}\\times^{\\mathsf{FCD}}\\mathcal{Y})\\sqcap F\\ne\\bot\\Leftrightarrow\\text{(*)}\\\\\n(\\mathcal{X}\\times^{\\mathsf{FCD}}\\mathcal{Y})\\sqcap \\bigsqcap^{\\mathsf{FCD}}\\up^{\\Gamma(\\Src f,\\Dst f)}f\\ne\\bot\\Leftrightarrow\\\\\n\\mathcal{X}\\suprel{\\bigsqcap^{\\mathsf{FCD}}\\up^{\\Gamma(\\Src f,\\Dst f)}f}\\mathcal{Y}\\Leftrightarrow\\mathcal{X}\\suprel{\\tofcd f}\\mathcal{Y}.\n\\end{multline*}\n\n\n\n({*}) by properties of generalized filter bases, taking into account\nthat funcoids are isomorphic to filters.\n\n\\item [{\\ref{fcd-up-g-fcd}}] $\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun Fa=\\left\\langle \\bigsqcap^{\\mathsf{FCD}}\\up^{\\Gamma(\\Src f,\\Dst f)}f\\right\\rangle a=\\supfun{\\tofcd f}a$\nfor every ultrafilter $a$.\n\n\nIt remains to prove that the function \n\\[\n\\varphi=\\lambda\\mathcal{X}\\in\\mathscr{F}(\\Src f):\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}\n\\]\nis a component of a funcoid (from what follows that $\\varphi=\\supfun{\\tofcd f}$).\nTo prove this, it's enough to show that it preserves finite joins\nand filtered meets.\n\n\n$\\varphi\\bot=\\bot$ is obvious. $\\varphi(\\mathcal{I}\\sqcup\\mathcal{J})=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}(\\supfun F\\mathcal{I}\\sqcup\\supfun F\\mathcal{J})=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{I}\\sqcup\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{J}=\\varphi\\mathcal{I}\\sqcup\\varphi\\mathcal{J}$.\nIf $S$ is a generalized filter base of $\\Src f$, then \n\\begin{multline*}\n\\varphi\\bigsqcap^{\\mathscr{F}}S=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\bigsqcap^{\\mathscr{F}}S=\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\bigsqcap^{\\mathscr{F}}\\rsupfun{\\supfun F}S=\\\\\n\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\bigsqcap_{\\mathcal{X}\\in S}^{\\mathscr{F}}\\supfun F\\mathcal{X}=\\bigsqcap_{\\mathcal{X}\\in S}^{\\mathscr{F}}\\bigsqcap_{F\\in\\up^{\\Gamma(\\Src f,\\Dst f)}f}^{\\mathscr{F}}\\supfun F\\mathcal{X}=\\bigsqcap_{\\mathcal{X}\\in S}^{\\mathscr{F}}\\varphi\\mathcal{X}=\\bigsqcap^{\\mathscr{F}}\\rsupfun{\\varphi}S.\n\\end{multline*}\n\n\n\nSo $\\varphi$ is a component of a funcoid.\n\n\\end{widedisorder}\n\\end{proof}\n\\begin{defn}\n$\\boxbox f=\\bigsqcap^{\\mathsf{RLD}}\\up^{\\Gamma(\\Src f,\\Dst f)}f$\nfor reloid $f$.\\end{defn}\n\\begin{conjecture}\n$\\boxbox f=\\torldin \\tofcd f$ for every reloid $f$.\n\\end{conjecture}\n\\begin{obvious}\n$\\boxbox f\\sqsupseteq f$ for every reloid $f$.\\end{obvious}\n\\begin{example}\n$\\torldin f\\neq\\boxbox\\torldout f$ for some funcoid\n$f$.\\end{example}\n\\begin{proof}\nTake $f=\\id_{\\Omega(\\mathbb{N})}^{\\mathsf{FCD}}$. Then, as it was\nshown above, $\\torldout f=\\bot$ and thus $\\boxbox\\torldout f=\\bot$.\nBut $\\torldin f\\sqsupseteq\\torldin f\\neq\\bot$. So $\\torldin f\\neq\\boxbox\\torldout f$.\\end{proof}\nAnother proof of the theorem ``$\\dom\\torldin f=\\dom f$ and $\\im\\torldin f=\\im f$\nfor every funcoid $f$.'':\n\\begin{proof}\nWe have for every filter $\\mathcal{X}\\in\\mathscr{F}(\\Src f)$:\n\\begin{multline*}\n\\mathcal{X}\\sqsupseteq\\dom\\torldin f\\Leftrightarrow\\mathcal{X}\\times^{\\mathsf{RLD}}\\top\\sqsupseteq\\torldin f\\Leftrightarrow\\\\\n\\forall a\\in\\mathscr{F}(\\Src f),b\\in\\mathscr{F}(\\Dst f):(a\\times^{\\mathsf{FCD}}b\\sqsubseteq f\\Rightarrow a\\times^{\\mathsf{RLD}}b\\sqsubseteq\\mathcal{X}\\times^{\\mathsf{RLD}}\\top)\\Leftrightarrow\\\\\n\\forall a\\in\\mathscr{F}(\\Src f),b\\in\\mathscr{F}(\\Dst f):(a\\times^{\\mathsf{FCD}}b\\sqsubseteq f\\Rightarrow a\\sqsubseteq\\mathcal{X})\n\\end{multline*}\nand \n\\begin{multline*}\n\\mathcal{X}\\sqsupseteq\\dom f\\Leftrightarrow\\mathcal{X}\\times^{\\mathsf{FCD}}\\top\\sqsupseteq f\\Leftrightarrow\\\\\n\\forall a\\in\\mathscr{F}(\\Src f),b\\in\\mathscr{F}(\\Dst f):(a\\times^{\\mathsf{FCD}}b\\sqsubseteq f\\Rightarrow a\\times^{\\mathsf{FCD}}b\\sqsubseteq\\mathcal{X}\\times^{\\mathsf{FCD}}\\top)\\Leftrightarrow\\\\\n\\forall a\\in\\mathscr{F}(\\Src f),b\\in\\mathscr{F}(\\Dst f):(a\\times^{\\mathsf{FCD}}b\\sqsubseteq f\\Rightarrow a\\sqsubseteq\\mathcal{X}).\n\\end{multline*}\n\n\nThus $\\dom\\torldin f=\\dom f$. The rest follows from symmetry.\\end{proof}\n\nAnother proof that\n$\\dom\\torldin f=\\dom f$ and $\\im\\torldin f=\\im f$ for every funcoid $f$:\n\\begin{proof}\n$\\dom\\torldin f\\sqsupseteq\\dom f$ and $\\im\\torldin f\\sqsupseteq\\im f$\nbecause $\\torldin f\\sqsupseteq\\torldin$ and $\\dom\\torldin f=\\dom f$\nand $\\im\\torldin f=\\im f$.\n\nIt remains to prove (as the rest follows from symmetry) that $\\dom\\torldin f\\sqsubseteq\\dom f$.\n\nReally, \n\\begin{multline*}\n\\dom\\torldin f\\sqsubseteq\\bigsqcap^{\\mathscr{F}}\\setcond{X\\in\\up\\dom f}{X\\times\\top\\in\\up f}=\\\\\n\\bigsqcap^{\\mathscr{F}}\\setcond{X\\in\\up\\dom f}{X\\in\\up\\dom f}=\\bigsqcap^{\\mathscr{F}}\\up\\dom f=\\dom f.\n\\end{multline*}\n\\end{proof}\n\n\\section{More on properties of funcoids}\n\\begin{prop}\n$\\Gamma(A,B)$ is the center of lattice $\\mathsf{FCD}(A,B)$.\\end{prop}\n\\begin{proof}\nTheorem~\\ref{pow-filt-central}.\\end{proof}\n\\begin{prop}\n$\\up^{\\Gamma(A,B)}(\\mathcal{A}\\times^{\\mathsf{FCD}}\\mathcal{B})$\nis defined by the filter base $\\setcond{A\\times B}{A\\in\\up\\mathcal{A},B\\in\\up\\mathcal{B}}$\non the lattice $\\Gamma(A,B)$.\\end{prop}\n\\begin{proof}\nIt follows from the fact that $\\mathcal{A}\\times^{\\mathsf{FCD}}\\mathcal{B}=\\bigsqcap^{\\mathsf{FCD}}\\setcond{A\\times B}{A\\in\\up\\mathcal{A},B\\in\\up\\mathcal{B}}$.\\end{proof}\n\\begin{prop}\n$\\up^{\\Gamma(A,B)}(\\mathcal{A}\\times^{\\mathsf{FCD}}\\mathcal{B})=\\mathfrak{F}(\\Gamma(A,B))\\cap\\up(\\mathcal{A}\\times^{\\mathsf{RLD}}\\mathcal{B})$.\\end{prop}\n\\begin{proof}\nIt follows from the fact that $\\mathcal{A}\\times^{\\mathsf{FCD}}\\mathcal{B}=\\bigsqcap^{\\mathsf{FCD}}\\setcond{A\\times B}{A\\in\\up\\mathcal{A},B\\in\\up\\mathcal{B}}$.\\end{proof}\n\\begin{prop}\nFor every $f\\in\\mathfrak{F}(\\Gamma(A,B))$:\n\\begin{enumerate}\n\\item \\label{gamma-ff}$f\\circ f$ is defined by the filter base $\\setcond{F\\circ F}{F\\in\\up f}$\n(if $A=B$);\n\\item \\label{gamma-f1f}$f^{-1}\\circ f$ is defined by the filter base $\\setcond{F^{-1}\\circ F}{F\\in\\up f}$;\n\\item \\label{gamma-ff1}$f\\circ f^{-1}$ is defined by the filter base $\\setcond{F\\circ F^{-1}}{F\\in\\up f}$.\n\\end{enumerate}\n\\end{prop}\n\\begin{proof}\nI will prove only \\ref{gamma-ff} and \\ref{gamma-f1f} because \\ref{gamma-ff1}\nis analogous to~\\ref{gamma-f1f}.\n\\begin{widedisorder}\n\\item [{\\ref{gamma-ff}}] It's enough to show that $\\forall F,G\\in\\up f\\exists H\\in\\up f:H\\circ H\\sqsubseteq G\\circ F$.\nTo prove it take $H=F\\sqcap G$.\n\\item [{\\ref{gamma-f1f}}] It's enough to show that $\\forall F,G\\in\\up f\\exists H\\in\\up f:H^{-1}\\circ H\\sqsubseteq G^{-1}\\circ F$.\nTo prove it take $H=F\\sqcap G$. Then $H^{-1}\\circ H=(F\\sqcap G)^{-1}\\circ(F\\sqcap G)\\sqsubseteq G^{-1}\\circ F$.\n\\end{widedisorder}\n\\end{proof}\n\\begin{thm}\nFor every sets $A$, $B$, $C$ if $g,h\\in\\mathfrak{F}\\Gamma(A,B)$\nthen\n\\begin{enumerate}\n\\item $f\\circ(g\\sqcup h)=f\\circ g\\sqcup f\\circ h$;\n\\item $(g\\sqcup h)\\circ f=g\\circ f\\sqcup h\\circ f$.\n\\end{enumerate}\n\\end{thm}\n\\begin{proof}\nIt follows from the order isomorphism above, which preserves composition.\\end{proof}\n\\begin{thm}\n$f\\cap g=f\\sqcap^{\\mathsf{FCD}}g$ if $f,g\\in\\Gamma(A,B)$.\\end{thm}\n\\begin{proof}\nLet $f=X_{0}\\times Y_{0}\\cup\\ldots\\cup X_{n}\\times Y_{n}$ and $g=X'_{0}\\times Y'_{0}\\cup\\ldots\\cup X'_{m}\\times Y'_{m}$.\n\nThen \n\\begin{multline*}\nf\\cap g=\\bigcup_{i=0,\\ldots,n,j=0,\\ldots,m}((X_{i}\\times Y_{i})\\cap(X'_{j}\\times Y'_{j}))=\\\\\n\\bigcup_{i=0,\\ldots,n,j=0,\\ldots,m}((X_{i}\\cap X'_{j})\\times(Y_{i}\\cap Y'_{j})).\n\\end{multline*}\n\n\nBut $f=X_{0}\\times Y_{0}\\sqcup^{\\mathsf{FCD}}\\ldots\\sqcup^{\\mathsf{FCD}}X_{n}\\times Y_{n}$\nand $g=X'_{0}\\times Y'_{0}\\sqcup^{\\mathsf{FCD}}\\ldots\\sqcup^{\\mathsf{FCD}}X'_{m}\\times Y'_{m}$;\n\n\\begin{multline*}\nf\\sqcap^{\\mathsf{FCD}}g=\\bigsqcup_{i=0,\\ldots,n,j=0,\\ldots,m}((X_{i}\\times Y_{i})\\sqcap^{\\mathsf{FCD}}(X'_{j}\\times Y'_{j}))=\\\\\n\\bigsqcup_{i=0,\\ldots,n,j=0,\\ldots,m}((X_{i}\\sqcap X'_{j})\\times^{\\mathsf{FCD}}(Y_{i}\\sqcap Y'_{j})).\n\\end{multline*}\n\n\\begin{cor}\nIf $X$ and $Y$ are finite binary relations, then\n\\begin{enumerate}\n  \\item $X \\sqcap^{\\mathsf{FCD}} Y = X \\sqcap Y$;\n  \\item $(\\top \\setminus X) \\sqcap^{\\mathsf{FCD}} (\\top \\setminus Y) =\n  (\\top \\setminus X) \\sqcap (\\top \\setminus Y)$;\n  \\item $X \\sqcap^{\\mathsf{FCD}} (\\top \\setminus Y) = X \\sqcap (\\top\n  \\setminus Y)$.\n\\end{enumerate}\n\\end{cor}\n\nNow it's obvious that $f\\cap g=f\\sqcap^{\\mathsf{FCD}}g$.\\end{proof}\n\\begin{thm}\nThe set of funcoids (from a given set~$A$ to a given set~$B$)\nis with separable core.\\end{thm}\n\\begin{proof}\nLet $f,g\\in\\mathsf{FCD}(A,B)$ (for some sets~$A$,$B$).\n\nBecause filters on distributive lattices are with separable core,\nthere exist $F,G\\in\\Gamma(A,B)$ such that $F\\cap G=\\emptyset$. Then\nby the previous theorem $F\\sqcap^{\\mathsf{FCD}}G=\\bot$.\\end{proof}\n\\begin{thm}\nThe coatoms of funcoids from a set~$A$ to a set~$B$ are exactly\n$(A\\times B)\\setminus(\\{x\\}\\times\\{y\\})$ for $x\\in A$, $y\\in B$.\\end{thm}\n\\begin{proof}\nThat coatoms of $\\Gamma(A,B)$\nare exactly $(A\\times B)\\setminus(\\{x\\}\\times\\{y\\})$ for $x\\in A$,\n$y\\in B$, is obvious. To show that coatoms of funcoids are the same,\nit remains to apply proposition~\\ref{coat}.\\end{proof}\n\\begin{thm}\nThe set of funcoids (for given~$A$ and~$B$) is coatomic.\\end{thm}\n\\begin{proof}\nProposition~\\ref{coat-ic}.\\end{proof}\n\\begin{xca}\nProve that in general funcoids are not coatomistic.\\end{xca}\n\n\\section{Funcoid bases}\n\nThis section will present mainly a counter-example against a statement you have not thought about anyway.\n\n\\begin{lem}\nIf $S$ is an upper set of principal funcoids, then\n$\\bigsqcap^{\\mathsf{FCD}} (S\\cap\\Gamma)=\\bigsqcap^{\\mathsf{FCD}} S$.\n\\end{lem}\n\n\\begin{proof}\n  $\\bigsqcap^{\\mathsf{FCD}} (S\\cap\\Gamma) \\sqsupseteq \\bigsqcap^{\\mathsf{FCD}} S$ is obvious.\n  \n  $\\bigsqcap^{\\mathsf{FCD}} S = \\bigsqcap^{\\mathsf{FCD}} \\bigsqcap^{\\mathsf{FCD}}_{K\\in S} T_K \\sqsupseteq \\bigsqcap^{\\mathsf{FCD}} (S\\cap\\Gamma)$.\n  where $T_K\\in\\subsets (S\\cap\\Gamma)$.\n  So $\\bigsqcap^{\\mathsf{FCD}} (S\\cap\\Gamma) = \\bigsqcap^{\\mathsf{FCD}} S$.\n\\end{proof}\n\n\\begin{thm}\n  If $S$ is a filter base on the set of binary relations then $S$ is a base of\n  $\\bigsqcap^{\\mathsf{FCD}} S$.\n\\end{thm}\n\nFirst prove a special case of our theorem to get the idea:\n\n\\begin{example}\n  Take the filter base $S = \\setcond{\n  \\setcond{ (x, y) }{ | x - y | < \\varepsilon }}{ \\varepsilon > 0 }$ and $K = \\setcond{ (x, y) }{\n  | x - y | < \\exp x }$ where $x$ and $y$ range real\n  numbers. Then $K \\notin \\up \\bigsqcap^{\\mathsf{FCD}} S$.\n\\end{example}\n\n\\begin{proof}\n  Take a nontrivial ultrafilter $x$ on $\\mathbb{R}$. We can for simplicity\n  assume $x \\sqsubseteq \\mathbb{Z}$.\n  \n  \\[ \\supfun{\\bigsqcap^{\\mathsf{FCD}} S} x =\n  \\bigsqcap^{\\mathscr{F}}_{L \\in S} \\supfun{L} x =\n  \\bigsqcap^{\\mathscr{F}}_{L \\in S, X \\in \\up x} \\rsupfun{L} X =\n  \\bigsqcap^{\\mathscr{F}}_{\\varepsilon > 0, X \\in \\up\n  x} \\bigsqcup_{\\alpha \\in X} \\mathopen] \\alpha - \\varepsilon ; \\alpha + \\varepsilon \\mathclose[. \\]\n  \n  $\\supfun{K} x = \\bigsqcap^{\\mathscr{F}}_{X \\in \\up x} \\rsupfun{K} X =\n  \\bigsqcap^{\\mathscr{F}}_{X \\in \\up x}\n  \\bigsqcup_{\\alpha \\in X}\\mathopen] \\alpha - \\exp \\alpha ; \\alpha + \\exp \\alpha \\mathclose[$.\n  \n  Suppose for the contrary that $\\supfun{K} x \\sqsupseteq \\supfun{\n  \\bigsqcap^{\\mathsf{FCD}} S } x$.\n  \n  Then\n  \n  $\\bigsqcup_{\\alpha \\in X} \\mathopen] \\alpha - \\exp \\alpha ; \\alpha + \\exp \\alpha \\mathclose[\n  \\sqsupseteq \\bigsqcap^{\\mathscr{F}}_{\\varepsilon > 0, X \\in \\up x}\n  \\bigsqcup_{\\alpha \\in X} \\mathopen] \\alpha - \\varepsilon ; \\alpha + \\varepsilon \\mathclose[$ for\n  every $X \\in \\up x$;\n  \n  thus by properties of generalized filter bases ($\\setcond{ \\bigsqcup_{\\alpha\n  \\in X} \\mathopen] \\alpha - \\varepsilon ; \\alpha + \\varepsilon \\mathclose[ }{\n  \\varepsilon > 0 }$ is a filter base and even a chain)\n  \n  $\\bigsqcup_{\\alpha \\in X} \\mathopen] \\alpha - \\exp \\alpha ; \\alpha + \\exp \\alpha \\mathclose[\n  \\sqsupseteq \\bigsqcap^{\\mathscr{F}}_{X \\in \\up x} \\bigsqcup_{\\alpha\n  \\in X} \\mathopen] \\alpha - \\varepsilon ; \\alpha + \\varepsilon \\mathclose[$ for some $\\varepsilon\n  > 0$ and thus\n  by properties of generalized filter bases ($\\setcond{ \\bigsqcup_{\\alpha \\in\n  X} \\mathopen] \\alpha - \\varepsilon ; \\alpha + \\varepsilon \\mathclose[ }{\n  X \\in \\up x }$ is a filter base) for some $X' \\in \\up x$\n  \n  \\[ \\bigsqcup_{\\alpha \\in X} \\mathopen] \\alpha - \\exp \\alpha ; \\alpha + \\exp \\alpha \\mathclose[\n  \\sqsupseteq \\bigsqcup_{\\alpha \\in X'} \\mathopen] \\alpha - \\varepsilon ; \\alpha +\n  \\varepsilon \\mathclose[ \\]\n  what is impossible by the fact that $\\exp \\alpha$ goes infinitely small as\n  $\\alpha \\rightarrow - \\infty$ and the fact that we can take $X =\\mathbb{Z}$\n  for some $x$.\n\\end{proof}\n\nNow prove the general case:\n\n\\begin{proof}\n  Suppose that $K \\in \\up \\bigsqcap^{\\mathsf{FCD}} S$ and thus\n  $\\supfun{K} x \\sqsupseteq \\supfun{\n  \\bigsqcap^{\\mathsf{FCD}} S } x$.\n  We need to prove that there is some~$L\\in S$ such that $K\\sqsupseteq L$.\n  \n  Take an ultrafilter $x$.\n  \n  $\\supfun{\\bigsqcap^{\\mathsf{FCD}} S} x =\n  \\bigsqcap^{\\mathscr{F}}_{L \\in S} \\supfun{L} x =\n  \\bigsqcap^{\\mathscr{F}}_{L \\in S, X \\in \\up x} \\rsupfun{L} X$.\n  \n  $\\supfun{K} x = \\bigsqcap^{\\mathscr{F}}_{X \\in \\up x} \\rsupfun{K}X$.\n  \n  Then\n  $\\rsupfun{K} X \\sqsupseteq \\bigsqcap^{\\mathscr{F}}_{L \\in S, X\n  \\in \\up x} \\rsupfun{L} X$ for every $X \\in \\up x$;\n  thus by properties of generalized filter bases ($\\setcond{ \\rsupfun{L}X\n  }{ L \\in S }$ is a filter base);\n  \n  $\\rsupfun{K} X \\sqsupseteq \\bigsqcap^{\\mathscr{F}}_{X \\in\n  \\up x} \\rsupfun{L} X$ for some $L \\in S$ and thus\n  by properties of generalized filter bases ($\\setcond{ \\rsupfun{L}\n  X }{ X \\in \\up x }$ is a filter base) for some $X' \\in \\up x$\n  \n  $\\rsupfun{K} X \\sqsupseteq \\rsupfun{L} X'\n  \\sqsupseteq \\supfun{L} x$.\n  \n  So $\\supfun{K} x \\sqsupseteq \\supfun{L} x$ because this\n  equality holds for every $X \\in \\up x$. Therefore $K \\sqsupseteq L$.\n\\end{proof}\n\n\\begin{example}\nA base of a funcoid which is not a filter base.\n\\end{example}\n\n\\begin{proof}\nConsider $f=\\id^{\\mathsf{FCD}}_{\\Omega}$. We know that $\\up f$ is not a\nfilter base. But it is a base of a funcoid.\n\\end{proof}\n\n\\begin{xca}\nProve that a set $S$ is a filter (on some set) iff\n\\[ \\forall X_0,\\dots,X_n\\in S:\\up(X_0\\sqcap\\dots\\sqcap X_n)\\subseteq S \\]\nfor every natural~$n$.\n\\end{xca}\n\nA similar statement does \\emph{not} hold for funcoids:\n\n\\begin{example}\nFor a set $S$ of binary relations\n\\[ \\forall X_0,\\dots,X_n\\in S:\\up(X_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} X_n)\\subseteq S \\]\ndoes not imply that there exists funcoid~$f$ such that $S=\\up f$.\n\\end{example}\n\n\\begin{proof}\nTake $S_0 = \\up 1^{\\mathsf{FCD}}$ (where $1^{\\mathsf{FCD}}$ is the identity funcoid on any infinite set)\nand $S_1 = \\bigcup_{F\\in S_0} \\setcond{\\up G}{G\\in\\up^{\\Gamma} F}$ (that is\n$S_1 = \\bigcup_{F\\in\\up^{\\Gamma} 1^{\\mathsf{FCD}}}\\up F$).\n\nBoth $S_0$ and $S_1$ are upper sets. $S_0\\ne S_1$ because $1^{\\mathsf{FCD}}\\in S_0$ and $1^{\\mathsf{FCD}}\\notin S_1$.\n\nThe formula in the example works for $S=S_0$ because $X_0,\\dots,X_n\\in \\up 1^{\\mathsf{FCD}}$. It also holds for $S=S_1$ by the\nfollowing reason:\n\nSuppose $X_0,\\dots,X_n\\in S_1$. Then $X_i\\sqsupseteq F_i$ where $F_i\\in S_0$.\nConsequently (take into account that $\\Gamma$ is a sublattice of $\\mathsf{FCD}$)\n$X_0,\\dots,X_n \\sqsupseteq F_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} F_n$ and so\n$X_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} X_n=\nX_0\\sqcap\\dots\\sqcap X_n \\sqsupseteq F_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} F_n \\sqsupseteq 1^{\\mathsf{FCD}}$.\nThus $X_0\\sqcap\\dots\\sqcap X_n \\in \\up^{\\Gamma} 1^{\\mathsf{FCD}} \\subseteq S_1$;\n$\\up(X_0\\sqcap\\dots\\sqcap X_n)\\subseteq S_1$ as $S_1$ is an upper set.\n\nTo finish the proof suppose for the contrary that $\\up f_0=S_0$ and $\\up f_1=S_1$ for some funcoids~$f_0$ and~$f_1$.\nIn this case $f_0=\\bigsqcap^{\\mathsf{FCD}} S_0 = 1^{\\mathsf{FCD}} = \\bigsqcap^{\\mathsf{FCD}} \\up^{\\Gamma} 1^{\\mathsf{FCD}} =\n\\bigsqcap^{\\mathsf{FCD}} S_1 = f_1$ and thus $S_0=S_1$, contradiction.\n\\end{proof}\n\n\\begin{prop}\nFor a set $S$ of binary relations\n\\[ \\forall X_0,\\dots,X_n\\in S:\\up(X_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} X_n)\\subseteq S \\]\ndoes not imply that~$S$ is a funcoid base.\n\\end{prop}\n\n\\begin{proof}\nSuppose for the contrary that it does imply. Then, because~$S$ is an upper set (as follows from the condition,\ntaking $n=0$), it implies that~$S=\\up f$ for a funcoid~$f$, what contradicts to the above example.\n\\end{proof}\n\n\\begin{conjecture}\n  Let $\\forall X,Y\\in S:\\up(X\\sqcap^{\\mathsf{FCD}} Y)\\subseteq S$.\n  \n  Then\n  \\[ \\forall X_0,\\dots,X_n\\in S:\\up(X_0\\sqcap^{\\mathsf{FCD}}\\dots\\sqcap^{\\mathsf{FCD}} X_n)\\subseteq S. \\]\n\\end{conjecture}\n\n\\begin{xca}\n$\\up (f_0 \\sqcap^{\\mathsf{FCD}} \\ldots\n\\sqcap^{\\mathsf{FCD}} f_n) \\subseteq \\setcond{ F_0 \\sqcap \\ldots \\sqcap\nF_n }{ F_0 \\in \\up f_0 \\wedge \\ldots \\wedge F_n \\in \\up f_n }$ for every funcoids~$f_0$, \\dots, $f_n$ ($n\\in\\mathbb{N}$).\n\\end{xca}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Some (example) values}\n\nI will do some calculations of particular funcoids and reloids.\n\nFirst note that $\\sqcap^{\\mathsf{FCD}}$ can be decomposed (see below for a short easy proof):\n\\[ f \\sqcap^{\\mathsf{FCD}} g = \\tofcd ((\\torldin f \\sqcap \\torldin g). \\]\n\nThe above is a more understandable decomposition of the operation~$\\sqcap^{\\mathsf{FCD}}$\nwhich behaves in strange way, mapping meet of two binary relations into a funcoid which\nis not a binary relation ($1^{\\mathsf{FCD}} \\sqcap^{\\mathsf{FCD}} (\\top \\setminus 1^{\\mathsf{FCD}}) =\n1^{\\mathsf{FCD}}_{\\Omega}$).\n\nThe last formula is easy to prove (and proved above in the book) but the result is counter-intuitive.\n\nMore generally:\n\\[ \\bigsqcap^{\\mathsf{FCD}} S = \\tofcd \\bigsqcap^{\\mathsf{RLD}} \\rsupfun{\\torldin} S. \\]\n\nThe above formulas follow from the fact that~$\\tofcd$ is an upper adjoint\nand that $\\tofcd\\torldin f=f$ for every funcoid $f$.\n\nLet $\\mathsf{FCD}$ denote funcoids on a set $U$.\n\nConsider a special case of the above formulas:\n\\begin{equation}\\label{fcd-meet-spec}\n1^{\\mathsf{FCD}} \\sqcap^{\\mathsf{FCD}} (\\top \\setminus 1^{\\mathsf{FCD}}) =\n\\tofcd (\\torldin 1^{\\mathsf{FCD}} \\sqcap \\torldin (\\top \\setminus 1^{\\mathsf{FCD}})).\n\\end{equation}\n\nWe want to calculate terms of the formula~\\eqref{fcd-meet-spec} and more generally do some\n(probably useless) calculations for particular funcoids and reloids related to the above formula.\n\nThe left side is already calculated. The term~$\\torldin 1^{\\mathsf{FCD}}$ which I call\n``thick equality'' above is well understood. Let's compute $\\torldin (\\top \\setminus 1^{\\mathsf{FCD}})$.\n\n\\begin{prop}\n$\\torldin (\\top \\setminus 1^{\\mathsf{FCD}}) = \\top \\setminus 1^{\\mathsf{FCD}}$.\n\\end{prop}\n\n\\begin{proof}\nConsider funcoids on a set $U$. For any filters~$x$ and~$y$ (or without loss of generality ultrafilters~$x$ and~$y$) we have:\n\n\\begin{multline*}\nx \\times^{\\mathsf{FCD}} y \\sqsubseteq \\top \\setminus\n1^{\\mathsf{FCD}} \\Leftrightarrow \\\\ \\text{(theorem 574 and the fact that\nfuncoids are filters)} \\Leftrightarrow \\\\ x \\times^{\\mathsf{FCD}} y \\asymp\n1^{\\mathsf{FCD}} \\Leftrightarrow \\neg \\left( x\n\\mathrel{[1^{\\mathsf{FCD}}]} y \\right) \\Leftrightarrow x \\asymp y\n\\Rightarrow \\\\ \\exists X \\in \\up x, Y \\in \\up y : X \\asymp Y.\n\\end{multline*}\n\nThus $\\torldin (\\top \\setminus\n1^{\\mathsf{FCD}}) = \\bigsqcup \\setcond{ X \\times Y}\n{X, Y \\in \\mathscr{T} U, X \\asymp Y } = \\top \\setminus\n1^{\\mathsf{FCD}}$.\n\\end{proof}\n\nSo, we have:\n\n\\[\n1^{\\mathsf{FCD}}_{\\Omega} =\n1^{\\mathsf{FCD}} \\sqcap^{\\mathsf{FCD}} (\\top \\setminus 1^{\\mathsf{FCD}}) =\n\\torldin 1^{\\mathsf{FCD}} \\sqcap^{\\mathsf{FCD}} (\\top \\setminus 1^{\\mathsf{FCD}}).\n\\]\n\n\\begin{prop}\\label{cj-rldin-diag}\n  If $X_0 \\sqcup \\ldots \\sqcup X_n = \\top$ then $(X_0 \\times X_0) \\sqcup\n  \\ldots \\sqcup (X_n \\times X_n) \\in \\up\n  \\torldin 1^{\\mathsf{FCD}}$.\n\\end{prop}\n\n\\begin{proof}\n  It's enough to prove $(X_0 \\times X_0) \\sqcup \\ldots \\sqcup (X_n \\times X_n)\n  \\in \\up (x \\times x)$ for every ultrafilter~$x$, what follows from the\n  fact that $x \\sqsubseteq X_i$ for some~$i$ and thus $x \\times x \\sqsubseteq\n  X_i \\times X_i$.\n\\end{proof}\n\n\\begin{prop}\n  For finite tuples $X$, $Y$ of typed sets\n  \\[ (X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n) \\sqsupseteq 1\n     \\Leftrightarrow (X_0 \\sqcap Y_0) \\sqcup \\ldots \\sqcup (X_n \\sqcap Y_n) =\n     \\top . \\]\n\\end{prop}\n\n\\begin{proof}\n\\begin{multline*}\n  (X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n) \\sqsupseteq 1\n  \\Leftrightarrow \\\\ ((X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n))\n  \\sqcap 1 = 1 \\Leftrightarrow \\\\ ((X_0 \\times Y_0) \\sqcap 1) \\sqcup \\ldots\n  \\sqcup ((X_n \\times Y_n) \\sqcap 1) = 1 \\Leftrightarrow \\\\ \\id_{X_0 \\sqcap\n  Y_0} \\sqcup \\ldots \\sqcup \\id_{X_n \\sqcap Y_n} = 1 \\Leftrightarrow \\\\\n  \\id_{(X_0 \\sqcap Y_0) \\sqcup \\ldots \\sqcup (X_n \\sqcap Y_n)} = 1\n  \\Leftrightarrow \\\\ (X_0 \\sqcap Y_0) \\sqcup \\ldots \\sqcup (X_n \\sqcap Y_n) =\n  \\top.\n\\end{multline*}\n\\end{proof}\n\n\\begin{cor}\n  ~\n  \\[ \\up^{\\Gamma} 1 = \\setcond{ (X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n\n     \\times Y_n) }{ n \\in \\mathbb{N}, \\forall i \\in\n     n : X_i, Y_i \\in \\mathscr{T} U, (X_0 \\sqcap Y_0) \\sqcup \\ldots \\sqcup\n     (X_n \\sqcap Y_n) = \\top } . \\]\n\\end{cor}\n\n\\begin{cor}\n  The predicate\n  $(X_0 \\sqcap Y_0) \\sqcup \\ldots \\sqcup (X_n \\sqcap Y_n) = \\top$ for an\n  element $(X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n)$ of $\\Gamma$\n  does not depend on its representation $(X_0 \\times Y_0) \\sqcup \\ldots \\sqcup\n  (X_n \\times Y_n)$.\n\\end{cor}\n\n\\begin{prop}\n  ~\n  \\[ \\up^{\\Gamma} 1 = \\bigcup \\setcond{ \\up^{\\Gamma} ((X_0 \\times\n     X_0) \\sqcup \\ldots \\sqcup (X_n \\times X_n)) }{ n\n     \\in \\mathbb{N}, \\forall i \\in n : X_i \\in \\mathscr{T} U, X_0 \\sqcup\n     \\ldots \\sqcup X_n = \\top } . \\]\n\\end{prop}\n\n\\begin{proof}\n  If $(X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n) \\in\n  \\up^{\\Gamma} 1$ then we have\n\\begin{multline*}\n  (X_0 \\times Y_0) \\sqcup \\ldots \\sqcup (X_n \\times Y_n) \\sqsupseteq \\\\ ((X_0\n     \\sqcap Y_0) \\times (X_0 \\sqcap Y_0)) \\sqcup \\ldots \\sqcup ((X_n \\sqcap\n     Y_n) \\times (X_n \\sqcap Y_n)) \\in \\up^{\\Gamma} 1.\n\\end{multline*}\n  Thus\n  \\[ \\up^{\\Gamma} 1 \\subseteq \\bigcup \\setcond{ \\up^{\\Gamma} ((X_0\n     \\times X_0) \\sqcup \\ldots \\sqcup (X_n \\times X_n)) }{\n     \\hspace{1em} n \\in \\mathbb{N}, \\forall i \\in n : X_i \\in \\mathscr{T} U,\n     X_0 \\sqcup \\ldots \\sqcup X_n = \\top } . \\]\n  The reverse inclusion is obvious.\n\\end{proof}\n\n\\begin{prop}\n  ~\n  \\[ \\torldin 1^{\\mathsf{FCD}} =\n     \\bigsqcap^{\\mathsf{RLD}} \\setcond{ (X_0 \\times X_0) \\sqcup \\ldots\n     \\sqcup (X_n \\times X_n) }{ n \\in \\mathbb{N},\n     \\forall i \\in n : X_i \\in \\mathscr{T} U, X_0 \\sqcup \\ldots \\sqcup X_n =\n     \\top } . \\]\n\\end{prop}\n\n\\begin{proof}\n  By the diagram we have $\\torldin\n  1^{\\mathsf{FCD}} = \\bigsqcap^{\\mathsf{RLD}} \\up^{\\Gamma} 1$. So it follows from the previous proposition.\n\\end{proof}\n\n\\begin{prop}\n  $\\up^{\\Gamma} \\torldin 1^{\\mathsf{FCD}} = \\up^{\\Gamma} 1$.\n\\end{prop}\n\n\\begin{proof}\n  If $K \\in \\up^{\\Gamma} 1$ then $K \\in \\up^{\\Gamma} ((X_0 \\times\n  X_0) \\sqcup \\ldots \\sqcup (X_n \\times X_n))$ and thus $K \\in\n  \\up^{\\Gamma}  \\torldin\n  1^{\\mathsf{FCD}}$ (see proposition~\\ref{cj-rldin-diag}). Thus $\\up^{\\Gamma}\n  1 \\subseteq \\up^{\\Gamma}  \\torldin\n  1^{\\mathsf{FCD}}$. But $\\up^{\\Gamma} \n  \\torldin 1^{\\mathsf{FCD}} \\subseteq\n  \\up^{\\Gamma} 1$ is obvious.\n\\end{proof}\n", "meta": {"hexsha": "3b525529e69cb6e1414041386f02b43bf285896e", "size": 45569, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-funcoids-are-filters.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-funcoids-are-filters.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-funcoids-are-filters.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.2522343595, "max_line_length": 384, "alphanum_fraction": 0.6689854945, "num_tokens": 18930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.4075050354572094}}
{"text": "\\subsubsection{\\stid{3.14} ALExa}\r\n\r\n\r\n\\paragraph{Overview}\r\n\r\nThe ALExa project ({\\sl Accelerated Libraries for Exascale}) focuses on\r\npreparing the ArborX, DTK, Tasmanian, and ForTrilinos libraries for exascale\r\nplatforms and integrating these libraries into ECP applications.\r\nThese libraries deliver capabilities identified as needs of ECP applications:\r\n%\r\n(1) the ability the perform performance portable spatial searches between\r\narbitrary sets of distributed geometric objects (ArborX);\r\n%\r\n(2) the ability to transfer computed\r\nsolutions between grids with differing layouts on parallel accelerated\r\narchitectures, enabling multiphysics projects to seamlessly combine results\r\nfrom different computational grids to perform their required simulations\r\n(DTK); and\r\n%\r\n(3) the ability to construct fast and memory efficient surrogates to\r\nlarge-scale engineering models with multiple inputs and many outputs,\r\nenabling uncertainty quantification (both forward and inverse) as well as\r\noptimization and efficient multi-physics simulations in projects such as\r\nExaStar (Tasmanian); and\r\n%\r\n(4) the ability to automatically interface Fortran-based codes to existing\r\nlarge and complex C/C++ solftware libraries, such as Trilinos advanced solvers\r\nthat can utilize next-generation platforms.\r\n\r\n\r\nThese capabilities are being developed through ongoing interactions with our\r\nECP application project collaborators to ensure they will satisfy requirements\r\nof these customers.  The libraries in turn take advantage of other ECP/SW\r\ncapabilities currently in development, including Trilinos,\r\nKokkos, and SLATE.  The final outcome of the ECP project will be a set of\r\nlibraries deployed to facilities and also made broadly available as part of\r\nthe xSDK4ECP project.\r\n\r\n\r\n{\\bf ArborX}\r\n\r\n{\\it Purpose:} ArborX is an open-source library designed to provide\r\nperformance portable algorithms for geometric search.\r\n\r\n{\\it Significance:} General geometric search capabilities are needed in a wide\r\nvariety of applications, including the generation of neighbor lists in\r\nparticle-based applications (e.g., molecular dynamics or general N-body\r\ndynamics simulations), density-based clustering analysis (e.g., halo finding\r\nor DBSCAN in cosmology) and mesh-mesh interactions such as contact in\r\ncomputational mechanics and solution transfer in multiphysics simulations.\r\n\r\n{\\it Performance portable search capabilities:} Shared memory and GPU\r\nimplementations of spatial tree construction; shared memory and GPU\r\nimplementations of various spatial tree queries; MPI front-end for\r\ncoordinating distributed spatial searches between sets of geometric objects\r\nwith different decompositions; communication plan generation based on spatial\r\nsearch results; density-based clustering algorithms (DBSCAN).\r\n\r\n{\\it URL:} https://github.com/arborx/ArborX\r\n\r\n{\\bf DTK} (Data Transfer Kit)\r\n\r\n{\\it Purpose:} Transfers computed solutions between grids with differing\r\nlayouts on parallel accelerated architectures.\r\n\r\n{\\it Significance:} Coupled applications frequently have different grids with\r\ndifferent parallel distributions; DTK is able to transfer solution values\r\nbetween these grids efficiently and accurately.\r\n\r\n{\\it Mesh and mesh-free interpolation capabilities:} multivariate data\r\ninterpolation between point clouds and grids; compactly supported radial basis\r\nfunctions; nearest-neighbor and moving least square implementations; support\r\nfor standard finite-element shape functions and user-defined interpolants;\r\ncommon applications include conjugate heat transfer, fluid structure\r\ninteraction, and mesh deformation.\r\n\r\n{\\it URL:} https://github.com/ORNL-CEES/DataTransferKit\r\n\r\n\r\n{\\bf Tasmanian} (Toolkit for Adaptive Stochastic Modeling and Non-Intrusive\r\nApproximation)\r\n\r\n{\\it Purpose:} Constructs efficient surrogate models for high-dimensional\r\nproblems and performs parameter calibration and optimization geared towards\r\napplications in uncertainty quantification (UQ).\r\n\r\n{\\it Significance:} UQ pertains to the statistical properties of the output\r\nfrom a complex model with respect to variability in multiple model inputs;\r\nlarge number of simulations are required to compute reliable statistics which\r\nis prohibitive when dealing with computationally expensive engineering\r\nmodels. A surrogate model is constructed from a moderate set of simulations\r\nusing carefully chosen input values; analysis can then be performed on the\r\nefficient surrogate.\r\n\r\n{\\it Sparse grids capabilities:} surrogate modeling and design of experiments\r\n(adaptive multi-dimensional interpolation); reduced (lossy) representation of\r\ntabulated scientific data; high dimensional numerical quadrature; data mining\r\nand manifold learning.\r\n\r\n{\\it DiffeRential Evolution Adaptive Metropolis (DREAM) capabilities:}\r\nBayesian inference; parameter estimation/calibration; model validation.\r\nglobal optimization and optimization under uncertainty.\r\n\r\n{\\it URL:} http://tasmanian.ornl.gov\r\n\r\n\r\n{\\bf ForTrilinos} (Fortran Trilinos)\r\n\r\n{\\it Purpose:}\r\nForTrilinos provides a seamless pathway for large and complex Fortran-based\r\ncodes to access Trilinos without C/C++ interface code. This access includes\r\nFortran versions of Kokkos abstractions for code execution and data management.\r\nTo provide this functionality, this project developed a Fortran-targeted\r\nextension to the SWIG (Simplified Wrapper and Interface Generator) tool.\r\nApplied to Trilinos, it generates object-oriented Fortran 2003 interface code\r\nthat closely mirrors the Trilinos C++ API.\r\n\r\n{\\it Significance:}\r\nThe Exascale Computing Project (ECP) requires the successful transformation and\r\nporting of many Fortran application codes in preparation for ECP platforms. A\r\nsignificant number of these codes rely upon the scalable solution of linear and\r\nnonlinear equations. The Trilinos Project contains a large and growing\r\ncollection of solver capabilities that can utilize next-generation platforms, in\r\nparticular scalable multicore, manycore, accelerator and heterogeneous systems.\r\nSince Trilinos is written primarily in C++, its capabilities are not available\r\nto other programming languages. ForTrilinos bridges the gap between the\r\nneeds of Fortran app developers and the capabilities of Trilinos. Furthermore,\r\nthe technology used to generate the Fortran--C++ bindings in ForTrilinos is\r\ncapable of exposing any number of C++ libraries to Fortran exascale app\r\ndevelopers.\r\n\r\n\r\n{\\it SWIG capabilities:}\r\nForTrilinos provides an inversion of control functionality that enables custom\r\nextensions of the Trilinos solvers implemented in downstream Fortran apps.\r\nAlthough this capability is not yet comprehensive, the goal of this project is\r\nto provide functional and extensible access Trilinos on next-generation\r\ncomputing systems. Several examples of ForTrilinos are being demonstrated within\r\nFortran-based ECP codes to help them meet simulation goals and illustrate the\r\ntechnology to other Fortran-based ECP codes. Additionally, the SWIG technology\r\nunderpinning ForTrilinos is being applied to other C++-based ECP ST subprojects\r\nto expose their capabilities to Fortran apps.\r\n\r\n{\\it URL:} https://github.com/trilinos/ForTrilinos\r\n\r\n\\paragraph{Key Challenges}\r\n\r\n\\indent\r\n\r\n{\\bf ArborX:} Search procedures to locate neighboring points, mesh cells, or\r\nother geometric objects require tree search methods difficult to optimize on\r\nmodern accelerated architectures due to vector lane or thread divergence. A\r\nflexible interface for calling user kernels on a positive match as well as\r\nmodifying traversal algorithms in a task-specific manner are crucial to\r\nachieving the best performance.\r\n\r\n{\\bf DTK:} General data transfer between grids of unrelated applications\r\nrequires many-to-many communication which is increasingly challenging as\r\ncommunication to computation ratios are decreasing on successive HPC systems.\r\nMaintaining high accuracy for the transfer requires careful attention to the\r\nmathematical properties of the interpolation methods and is highly\r\napplication-specific.\r\n\r\n{\\bf Tasmanian:} Extracting statistical information from a Tasmanian surrogate\r\n(or using the surrogate in a multi-physics simulation) requires the collection\r\nof a large number of samples, which is not feasible without GPU acceleration.\r\nThe GPU accelerated surrogate evaluations require both custom kernels\r\ncorresponding to the different types of basis functions as well as both\r\nsparse and dense linear algebra methods (BLAS level 2 and 3).\r\nPorting the capabilities and optimizing the performance across different\r\ndivergent architectures is challenging.\r\n\r\n{\\bf ForTrilinos:}\r\nDeveloping the interfaces to the C++ libraries that provide access to\r\ncutting-edge research, such as Trilinos,  is of significant benefit to Fortran\r\ncommunity. However, such interfaces must be well documented, sustainable and\r\nextensible, which would require significant amount of resources and investment.\r\nThis is further complicated by the requirements to support heterogeneous\r\nplatforms (e.g., GPUs) and inversion-of-control functionality. The manual\r\napproach to such interfaces has been shown to be unsustainable as it requires\r\ninterface developers to have in-depth expertise in  multiple languages and the\r\npeculiarities in their interaction on top of the time commitment to update the\r\ninterfaces with changes in the library.\r\n\r\nForTrilinos addresses both the issue of reducing interface generation cost\r\nthrough investment in tool configuration and usage to make the process as\r\nautomatic as possible, and the issue of providing the full-featured interface to\r\nTrilinos library, including access to manycore, accelerator and heterogeneous\r\nsolver capabilities in Trilinos.\r\n\r\n\r\n\\paragraph{Solution Strategy}\r\n\r\n\\nobreak\r\n\r\n\r\n\\indent\r\n\r\n{\\bf ArborX:} ArborX builds on a MPI+Kokkos programming model to deploy to all\r\nDOE HPC architectures. Extensive performance engineering has yielded\r\nimplementations that are both as performant in serial as state-of-the-art\r\nlibraries while also expanding on the capability provided by other libraries by\r\ndemonstrating thread scalability on both GPU and multi-core CPU architectures.\r\nWorking with both synthetic as well as real data from applications (e.g., HACC)\r\nensures wide performance testing coverage.\r\n\r\n{\\bf DTK:} State-of-the-art, mathematically rigorous methods are used in DTK\r\nto preserve accuracy of interpolated solutions.  Algorithms are implemented in\r\na C++ code base with extensive unit testing on multiple platforms.  Trilinos\r\npackages are used to support interpolation methods.  Kokkos is used to achieve\r\nperformance portability across accelerated platforms.\r\n\r\n{\\bf Tasmanian:} The C++ kernels within Tasmanian (currently tuned for Nvidia\r\nVolta architecture) are templated exposing numerous performance tweaks and\r\ntuning parameters that can be adjusted to perform well on a corresponding AMD\r\nsystem.\r\nThe kernels also need to be ported to DPC++/SYCL to allow for the utilization\r\nof Intel GPUs. Tasmanian requires a general GPU-BLAS interface that can\r\nutilize any of the accelerated backends, e.g., cuBlas, rocBlas, MKL and MAGMA.\r\n\r\n{\\bf ForTrilinos:}\r\nForTrilinos defines several SWIG-Fortran modules that generate Fortran-2003\r\ninterfaces to C++ Trilinos solver classes. ForTrilinos provides a\r\n``high-level'' interface for applications to access nonlinear and eigenvalue\r\nsolvers in addition to low-level Trilinos classes.\r\n\r\n%----------------------------------------\r\n\r\n\\paragraph{Recent Progress}\r\n\r\n\\indent\r\n\r\n{\\bf ArborX:} Collaboration with partner application ExaSky (WBS 2.2.3.02)\r\nresulted in significant advances for the in-situ density-based clustering\r\nalgorithm (halo finding) using Nvidia GPUs.\r\n\r\n\\begin{figure}[htb]\r\n        \\centering \\includegraphics[width=4.0in]{projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/arborx_hacc_progress.png} \\caption{\\label{fig:arborx-hacc}\r\n        ArborX progress on halo finding algorithm on Nvidia Volta. The baseline\r\n        is a serial implementation of CosmoTools. Numbers indicate speedup\r\n        compared to the baseline. The solid lines show improvements that were\r\n        already merged. Dashed lines show improvements that are in active\r\n        development. }\r\n\\end{figure}\r\n\r\n{\\bf DTK:} DTK's build system has been rewritten. DTK now depends on Trilinos\r\ninstead of being built as an external package. DTK is now a separate package in\r\nspack. In the future this will allow a decoupling between Trilinos version and\r\nDTK version. A new spline interpolation method has been added.\r\n\r\n{\\bf Tasmanian:} Work with partner application ExaStar (2.2.3.01) created a\r\nreduced representation of neutrino opacities used by the Thornado simulation\r\nsoftware. The classical representation uses dense tables that do not fit in\r\nGPU memory and lead to unnecessary and expensive data movement for each time-step.\r\nThe reduced representation by Tasmanian preserved the accuracy of the simulations\r\nand dramatically reduces the memory footprint by removing redundancies\r\nand exploiting smoothness in the data.\r\n\r\n\\begin{figure}[htb]\r\n        \\centering\r\n        \\includegraphics[width=2.5in]{projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/tasmanian_exastar}\r\n\\caption{\\label{fig:tasmanian-exastar}\r\n\t\tThe resulting neutrino and antineutrino distributions in a deleptonization\r\n\t\twave simulation using sparse grid opacities, which require only 6\\% of\r\n\t\tthe memory used in the dense approach, with relative $L^2$ error less than 1\\%.}\r\n\\end{figure}\r\n\r\n{\\bf ForTrilinos:}\r\nAs with DTK, ForTrilinos now has an independent build system with Trilinos as a\r\ndependency. This improves robustness of the build and makes ForTrilinos\r\navailable to app developers even if a system installation of Trilinos does not\r\nenable Fortran. ForTrilinos is now independently available through the Spack\r\npackage manager. New ST libraries including Tasmanian have been wrapped with the\r\nSWIG-Fortran utility.\r\n\r\n%----------------------------------------\r\n\r\n\\paragraph{Next Steps}\r\n\r\n\\indent\r\n\r\n{\\bf ArborX:} Incorporate non axis-aligned bounding volumes to accommodate\r\nstretched inclined geometries such as those coming from wind turbine\r\nsimulations from ExaWind (WBS 2.2.2.01). Further improve performance of\r\ndensity-based algorithms.\r\n\r\n{\\bf DTK:} Continue performance engineering campaign and deploy in a variety of\r\napplications.\r\n\r\n{\\bf Tasmanian:} Port the surrogate evaluation kernels to AMD and Intel\r\nGPUs and optimize the performance on the next generation architectures\r\n(including next generation Nvidia GPUs).\r\n\r\n{\\bf ForTrilinos:} Extend ForTrilinos native Fortran interface documentation and\r\nprioritize Fortran app customer needs. Integrate SWIG into ECP ST projects that\r\ndesire Fortran interfaces.\r\n\r\n%----------------------------------------\r\n", "meta": {"hexsha": "1300ff27481cddd57435fc5226ec204a0ce3202e", "size": 14805, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_stars_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_stars_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_issues_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_issues_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projects/2.3.3-MathLibs/2.3.3.14-ALExa-ForTrilinos/2.3.3.14-ALExa.tex", "max_forks_repo_name": "klondikemike/ECP-ST-CAR-PUBLIC", "max_forks_repo_head_hexsha": "a6840615223d1f1ce240dba38d0b2821925c270d", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5150501672, "max_line_length": 159, "alphanum_fraction": 0.7956095914, "num_tokens": 3086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4075050354572094}}
{"text": "\\documentclass[landscape,twocolumn,letterpaper,9pt,reqno]{article}\\usepackage[]{graphicx}\\usepackage[]{color}\n%% maxwidth is the original width if it is less than linewidth\n%% otherwise use linewidth (to make sure the graphics do not exceed the margin)\n\\makeatletter\n\\def\\maxwidth{ %\n  \\ifdim\\Gin@nat@width>\\linewidth\n    \\linewidth\n  \\else\n    \\Gin@nat@width\n  \\fi\n}\n\\makeatother\n\n\\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}\n\\newcommand{\\hlnum}[1]{\\textcolor[rgb]{0.686,0.059,0.569}{#1}}%\n\\newcommand{\\hlstr}[1]{\\textcolor[rgb]{0.192,0.494,0.8}{#1}}%\n\\newcommand{\\hlcom}[1]{\\textcolor[rgb]{0.678,0.584,0.686}{\\textit{#1}}}%\n\\newcommand{\\hlopt}[1]{\\textcolor[rgb]{0,0,0}{#1}}%\n\\newcommand{\\hlstd}[1]{\\textcolor[rgb]{0.345,0.345,0.345}{#1}}%\n\\newcommand{\\hlkwa}[1]{\\textcolor[rgb]{0.161,0.373,0.58}{\\textbf{#1}}}%\n\\newcommand{\\hlkwb}[1]{\\textcolor[rgb]{0.69,0.353,0.396}{#1}}%\n\\newcommand{\\hlkwc}[1]{\\textcolor[rgb]{0.333,0.667,0.333}{#1}}%\n\\newcommand{\\hlkwd}[1]{\\textcolor[rgb]{0.737,0.353,0.396}{\\textbf{#1}}}%\n\\let\\hlipl\\hlkwb\n\n\\usepackage{framed}\n\\makeatletter\n\\newenvironment{kframe}{%\n \\def\\at@end@of@kframe{}%\n \\ifinner\\ifhmode%\n  \\def\\at@end@of@kframe{\\end{minipage}}%\n  \\begin{minipage}{\\columnwidth}%\n \\fi\\fi%\n \\def\\FrameCommand##1{\\hskip\\@totalleftmargin \\hskip-\\fboxsep\n \\colorbox{shadecolor}{##1}\\hskip-\\fboxsep\n     % There is no \\\\@totalrightmargin, so:\n     \\hskip-\\linewidth \\hskip-\\@totalleftmargin \\hskip\\columnwidth}%\n \\MakeFramed {\\advance\\hsize-\\width\n   \\@totalleftmargin\\z@ \\linewidth\\hsize\n   \\@setminipage}}%\n {\\par\\unskip\\endMakeFramed%\n \\at@end@of@kframe}\n\\makeatother\n\n\\definecolor{shadecolor}{rgb}{.97, .97, .97}\n\\definecolor{messagecolor}{rgb}{0, 0, 0}\n\\definecolor{warningcolor}{rgb}{1, 0, 1}\n\\definecolor{errorcolor}{rgb}{1, 0, 0}\n\\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX\n\n\\usepackage{alltt}\n\n\\usepackage{lscape,fancyhdr}\n\n\\usepackage{hyperref}\n\n\\pagestyle{fancy}\n\n\\usepackage{amsmath,epsfig,subfigure,amsthm,amsfonts,epsf,psfrag,rotating,setspace,bm}\n\n\\usepackage{verbatim,color} % Allow text colors}\n\n\\setlength{\\oddsidemargin}{-0.4in}\t\t% default=0in\n\\setlength\\evensidemargin{-0.4in}\n\n\\setlength{\\textwidth}{9.8in}\t\t% default=9in\n\n\\setlength{\\columnsep}{0.5in}\t\t% default=10pt\n\n\\setlength{\\columnseprule}{0pt}\t\t% default=0pt (no line)\n\n\n\\setlength{\\textheight}{7.0in}\t\t% default=5.15in\n\n\\setlength{\\topmargin}{-0.75in}\t\t% default=0.20in\n\n\\setlength{\\headsep}{0.25in}\t\t% default=0.35in\n\n\\setlength{\\parskip}{1.2ex}\n\n\\setlength{\\parindent}{0mm}\n\n\\lhead{Course EPIB607: Regression handout 002}\n\\rhead{jh,sb \\ \\ \\ v. 2018.11.08}\n\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}\n\\begin{document}\n\n\n\n\n\\section{Mean depth of the ocean}\n\n\n\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{alltt}\n\\hlkwd{head}\\hlstd{(depths)}\n\\end{alltt}\n\\begin{verbatim}\n##           X        lon       lat  alt water South\n## 41995 41995  -87.21236 59.290367  190     1     0\n## 11151 11151 -122.33034  5.554558 4167     1     0\n## 43640 43640 -148.54790 36.237464 5447     1     0\n## 8615   8615  -24.92364 21.625967 5063     1     0\n## 8126   8126  177.18458 13.880370 5634     1     0\n## 16548 16548   48.88215  3.229250 3691     1     0\n\\end{verbatim}\n\\begin{alltt}\n\\hlkwd{dim}\\hlstd{(depths)}\n\\end{alltt}\n\\begin{verbatim}\n## [1] 400   6\n\\end{verbatim}\n\\begin{alltt}\n\\hlstd{fit} \\hlkwb{<-} \\hlkwd{lm}\\hlstd{(alt} \\hlopt{~} \\hlnum{1}\\hlstd{,} \\hlkwc{data} \\hlstd{= depths)}\n\\hlkwd{summary}\\hlstd{(fit)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## Call:\n## lm(formula = alt ~ 1, data = depths)\n## \n## Residuals:\n##     Min      1Q  Median      3Q     Max \n## -3681.5  -584.8   405.5  1197.2  2827.5 \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)    \n## (Intercept)  3683.52      78.71    46.8   <2e-16 ***\n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## Residual standard error: 1574 on 399 degrees of freedom\n\\end{verbatim}\n\n\\end{knitrout}\n\t\n\n\\clearpage\n\t\n\\section{Mean depth of the ocean in northern and southern hemisphere}\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\n{\\centering \\includegraphics[width=1\\linewidth]{figure/unnamed-chunk-3-1} \n\n}\n\n\n\n\\end{knitrout}\n\n\n\\begin{knitrout}\\footnotesize\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{alltt}\n\\hlstd{fit} \\hlkwb{<-} \\hlkwd{lm}\\hlstd{(alt} \\hlopt{~} \\hlstd{South,} \\hlkwc{data} \\hlstd{= depths)}\n\\hlkwd{summary}\\hlstd{(fit)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## Call:\n## lm(formula = alt ~ South, data = depths)\n## \n## Residuals:\n##     Min      1Q  Median      3Q     Max \n## -3722.0  -608.5   401.5  1200.4  2867.9 \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)    \n## (Intercept)  3643.08     111.42  32.698   <2e-16 ***\n## South          80.88     157.56   0.513    0.608    \n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## Residual standard error: 1576 on 398 degrees of freedom\n## Multiple R-squared:  0.0006617,\tAdjusted R-squared:  -0.001849 \n## F-statistic: 0.2635 on 1 and 398 DF,  p-value: 0.608\n\\end{verbatim}\n\\begin{alltt}\n\\hlkwd{t.test}\\hlstd{(alt} \\hlopt{~} \\hlstd{South,} \\hlkwc{data} \\hlstd{= depths,} \\hlkwc{var.equal} \\hlstd{=} \\hlnum{TRUE}\\hlstd{)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## \tTwo Sample t-test\n## \n## data:  alt by South\n## t = -0.51334, df = 398, p-value = 0.608\n## alternative hypothesis: true difference in means is not equal to 0\n## 95 percent confidence interval:\n##  -390.6487  228.8787\n## sample estimates:\n## mean in group 0 mean in group 1 \n##        3643.080        3723.965\n\\end{verbatim}\n\n\\end{knitrout}\n\n\\clearpage\n\n\\section{Ratio depth of the ocean in northern and southern hemisphere}\n\n\\begin{knitrout}\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{alltt}\n\\hlcom{# note: we are now using glm}\n\\hlstd{fit} \\hlkwb{<-} \\hlkwd{glm}\\hlstd{(alt} \\hlopt{~} \\hlstd{South,} \\hlkwc{data} \\hlstd{= depths,} \\hlkwc{family} \\hlstd{=} \\hlkwd{gaussian}\\hlstd{(}\\hlkwc{link}\\hlstd{=log))}\n\\hlkwd{summary}\\hlstd{(fit)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## Call:\n## glm(formula = alt ~ South, family = gaussian(link = log), data = depths)\n## \n## Deviance Residuals: \n##     Min       1Q   Median       3Q      Max  \n## -3722.0   -608.5    401.5   1200.4   2867.9  \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)    \n## (Intercept)  8.20058    0.03058 268.144   <2e-16 ***\n## South        0.02196    0.04278   0.513    0.608    \n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## (Dispersion parameter for gaussian family taken to be 2482673)\n## \n##     Null deviance: 988758010  on 399  degrees of freedom\n## Residual deviance: 988103771  on 398  degrees of freedom\n## AIC: 7029.1\n## \n## Number of Fisher Scoring iterations: 5\n\\end{verbatim}\n\n\\end{knitrout}\n\n\n\\clearpage\n\n\n\\section{Student drinking}\n\n\n\n\\begin{knitrout}\\footnotesize\n\\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\\color{fgcolor}\n\\begin{alltt}\n\\hlstd{fit} \\hlkwb{<-} \\hlkwd{lm}\\hlstd{(drinks} \\hlopt{~} \\hlstd{gender,} \\hlkwc{data} \\hlstd{= drinks)}\n\\hlkwd{summary}\\hlstd{(fit)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## Call:\n## lm(formula = drinks ~ gender, data = drinks)\n## \n## Residuals:\n##     Min      1Q  Median      3Q     Max \n## -5.5185 -1.7947 -0.2947  1.4815  9.4815 \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)    \n## (Intercept)   4.2947     0.2837  15.138  < 2e-16 ***\n## gender        2.2238     0.4182   5.318  3.2e-07 ***\n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## Residual standard error: 2.765 on 174 degrees of freedom\n## Multiple R-squared:  0.1398,\tAdjusted R-squared:  0.1348 \n## F-statistic: 28.28 on 1 and 174 DF,  p-value: 3.197e-07\n\\end{verbatim}\n\\begin{alltt}\n\\hlstd{fit} \\hlkwb{<-} \\hlkwd{glm}\\hlstd{(drinks} \\hlopt{~} \\hlstd{gender,} \\hlkwc{data} \\hlstd{= drinks,} \\hlkwc{family} \\hlstd{=} \\hlkwd{gaussian}\\hlstd{(}\\hlkwc{link}\\hlstd{=log))}\n\\hlkwd{summary}\\hlstd{(fit)}\n\\end{alltt}\n\\begin{verbatim}\n## \n## Call:\n## glm(formula = drinks ~ gender, family = gaussian(link = log), \n##     data = drinks)\n## \n## Deviance Residuals: \n##     Min       1Q   Median       3Q      Max  \n## -5.5185  -1.7947  -0.2947   1.4815   9.4815  \n## \n## Coefficients:\n##             Estimate Std. Error t value Pr(>|t|)    \n## (Intercept)  1.45739    0.06606  22.062  < 2e-16 ***\n## gender       0.41726    0.08115   5.142 7.27e-07 ***\n## ---\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n## \n## (Dispersion parameter for gaussian family taken to be 7.646385)\n## \n##     Null deviance: 1546.7  on 175  degrees of freedom\n## Residual deviance: 1330.5  on 174  degrees of freedom\n## AIC: 861.48\n## \n## Number of Fisher Scoring iterations: 5\n\\end{verbatim}\n\n\\end{knitrout}\n\n\n\n\n\n\n\n\n\n\t\n\t\n\\end{document}\t\n", "meta": {"hexsha": "aa6a734d2a8e23f3e77d223288879fef6860c2c8", "size": 8900, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/regression/handouts/EPIB607_handout_002.tex", "max_stars_repo_name": "ly129/EPIB607", "max_stars_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/regression/handouts/EPIB607_handout_002.tex", "max_issues_repo_name": "ly129/EPIB607", "max_issues_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/regression/handouts/EPIB607_handout_002.tex", "max_forks_repo_name": "ly129/EPIB607", "max_forks_repo_head_hexsha": "ac2f917bc064f8028a875766af847114cd306396", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-25T21:19:06.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-25T21:19:06.000Z", "avg_line_length": 28.0757097792, "max_line_length": 183, "alphanum_fraction": 0.6313483146, "num_tokens": 3636, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.40750503211587}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\chapter{Reheating}\n\n\\section{Radiation from the inflaton}\n\n\\marginpar{Monday\\\\ 2020-11-16, \\\\ compiled \\\\ \\today}\n\nThis is what happens in the transition between the inflationary phase and the usual radiation-dominated epoch. \n\nWe will give a simplified treatment, which however captures the main characteristics of the model.\n\nConsider the typical inflationary potential: flat at \\(\\varphi \\sim 0\\), sloping down towards a minimum. At \\(\\varphi \\sim \\varphi _f\\) the field starts ``falling down'' towards the minimum quickly.\nThe condition is \\(V''(\\varphi ) \\gtrsim H^2\\), meaning that \\(\\eta _V \\gtrsim 1\\), which also implies that quickly we will find \\(\\epsilon \\gtrsim 1\\). \n\nWhen the field falls down it will \\textbf{oscillate}, however its oscillations will be damped.\nThis is due to two factors: the expansion of the universe and the coupling of the field to other particles. \n\nThe damped oscillations are described by a coupled Klein-Gordon equation: \n%\n\\begin{align}\n\\ddot{\\varphi} + 3 H \\dot{\\varphi} + \\Gamma _\\varphi \\dot{\\varphi} = - V' (\\varphi )\n\\,,\n\\end{align}\n%\nwhere \\(\\Gamma _\\varphi \\) is the \\textbf{decay rate} of the inflaton field into other kinds of particles. \nThis has the same form as the expansion term: it is a damping term as well.\n\nThe energy density of the scalar field can be differentiated:\n%\n\\begin{align}\n\\rho _\\varphi &= \\frac{1}{2} \\dot{\\varphi}^2 + V(\\varphi )  \\label{eq:scalar-field-energy-density}\\\\\n\\dot{\\rho}_\\varphi &= \\dot{\\varphi} \\ddot{\\varphi} + V' (\\varphi ) \\dot{\\varphi}\n\\,,\n\\end{align}\n%\ninto which we can substitute into the KG equation to get\n%\n\\begin{align}\n\\dot{\\rho}_\\varphi + (3 H + \\Gamma _\\varphi ) \\dot{\\varphi}^2 = 0\n\\,.\n\\end{align}\n\nThe timescale of the oscillations of \\(\\varphi \\) will be much smaller than \\(H^{-1}\\), the timescale of the expansion of the universe. \n\nOscillations at \\(\\varphi = \\sigma \\) will have a frequency \\(\\omega^2 = V''(\\sigma )\\), which is also the effective mass of the inflaton there, \\(m^2_\\varphi (\\sigma )\\). \n\nSince \\(\\omega^2 \\gg H^2\\) (this is true since \\(\\eta _V \\gg 1\\)) we can take averages over a period of the relevant quantities: \n%\n\\begin{align}\n\\expval{\\dot{\\varphi}^2} _{\\text{period}} = \\rho _\\varphi \n\\,,\n\\end{align}\n%\nsince in general \\(\\expval{\\dot{\\varphi}^2 / 2} = \\expval{V}\\) by the virial theorem: therefore, substituting into \\eqref{eq:scalar-field-energy-density} we get \\(\\expval{\\dot{\\varphi}^2} = \\rho _\\varphi \\). \nThen our equation becomes \n%\n\\begin{align}\n\\dot{\\rho}_\\varphi + 3 H \\rho _\\varphi =  - \\Gamma _\\varphi \\rho _\\varphi \n\\,,\n\\end{align}\n%\nwhich, neglecting \\(\\Gamma _\\varphi \\), looks like the continuity equation for nonrelativistic matter, which yields \\(\\rho _\\varphi \\propto a^{-3}\\). \nThis is expected: we have used the fact that \\(m^2_\\varphi (\\sigma ) \\gg H^2\\), which is saying that the scalar field is very massive. \n\nIn the spirit of keeping things simple, we will use a toy model and assume that all the decay products of \\(\\varphi \\) are relativistic, whose continuity equation is \n%\n\\begin{align}\n\\dot{\\rho} _R + 4 H \\rho _R = + \\Gamma _\\varphi  \\rho _\\varphi \n\\,,\n\\end{align}\n%\nby conservation of energy. This equation comes from \\(\\nabla_\\nu T^{\\mu \\nu } = 0\\). \nGravity will then be described by the first Friedmann equation: \n%\n\\begin{align}\nH^2 = \\frac{8 \\pi G}{3} \\qty(\\rho _\\varphi + \\rho _R)\n\\,.\n\\end{align}\n\nWe have a simple and exact solution: \n%\n\\begin{align}\n\\rho _\\varphi = M^{4} \\qty(\\frac{a}{a _{\\text{osc}}})^{-3} \\exp(- \\Gamma _\\varphi \\qty(t - t _{\\text{osc}}))\n\\marginnote{See \\cite[eq. 8.30]{kolbEarlyUniverse1994}.}\n\\,,\n\\end{align}\n%\nwhere \\(t _{\\text{osc}}\\) and \\(a _{\\text{osc}}\\) correspond to the time at which oscillations start, and \\(M^{4} = \\rho _\\varphi ( t _{\\text{osc}})\\).\nAs a first approximation, this is the height of the potential the field is ``falling from'': \\(M^{4} \\sim V(\\varphi = 0)\\). \n\nLet us consider the evolution up to the time \\(t \\approx \\Gamma _\\varphi^{-1}\\). Then, the decay will not have been very efficient yet, and the universe will still be nonrelativistic matter (\\(\\varphi \\)) dominated, so we will have \\(a \\propto t^{2/3}\\).\n\nThe time of the start of oscillation will be \n%\n\\begin{align}\nt _{\\text{osc}} \\approx H^{-1} = \\frac{M_P}{M^2}\n\\,,\n\\end{align}\n%\nsince at the start of oscillations\n%\n\\begin{align}\nH^2 \\approx \\frac{8 \\pi G}{3} M^{4} \\approx \\frac{M^2}{M_P}\n\\,.\n\\end{align}\n\nSo, \n%\n\\begin{align}\n\\dot{\\rho}_R + 4 H \\rho _R &= \\Gamma _\\varphi M^4  \\qty( \\frac{a}{a _{\\text{osc}}})^{-3} \\\\\n\\dot{\\rho}_R + \\frac{8}{3} \\frac{\\rho _R}{t} &=\n\\Gamma _\\varphi M^{4} \\qty( \\frac{t}{t _{\\text{osc}}})^{-2} \n\\,,\n\\end{align}\n%\nsince \\(a \\propto t^{2/3}\\) (we are in a matter-like dominated phase), therefore \\(H = (2/3) t^{-1}\\).\nWith a powerlaw ansatz \\(\\rho _R = B t^{\\alpha }\\) we get \n%\n\\begin{align}\n\\alpha t^{\\alpha -1} + \\frac{8}{3} \\frac{t^{\\alpha }}{t} = \\frac{\\Gamma _\\varphi }{B} M^{4} \\qty(\\frac{t}{ t _{\\text{osc}}})^{-2}\n\\,,\n\\end{align}\n%\nthe homogeneous solution is given by \\(\\alpha = - 8 /3\\), while the particular has \\(\\alpha = -1\\). \n\nThe initial condition we set is \\(\\rho _R (t _{\\text{osc}}) = 0\\), since before reheating inflation was taking place, diluting the energy density of radiation. \nThis yields, in the pre-radiation-domination epoch:\n%\n\\begin{align}\n\\rho _R \\approx \\Gamma _\\varphi M_P^2 \\frac{9}{40 \\pi } \\frac{1}{t} \\qty[ 1 - \\qty( \\frac{t}{t _{\\text{osc}}})^{-5/3}]\n\\,.\n\\end{align}\n\n\\todo[inline]{Where does the \\(\\pi \\) come from?}\n\n% \\todo[inline]{So, we are basically approximating the decaying exponential with a constant function for a small region of time, and then 0?}\n\nStarting from this solution, and using \\(a \\propto t^{2/3}\\), we find \n%\n\\begin{align}\n\\rho _R = \\frac{\\num{.4}}{\\pi^{1/2}} \\Gamma _\\varphi M_P M^2 \\qty(\\frac{a}{a _{\\text{osc}}})^{-3/2} \\qty[1 - \\qty(\\frac{a}{a _{\\text{osc}}})^{- 5/2}]\n\\,.\n\\end{align}\n\nThe maximum energy density of radiation will be roughly given by \\(\\rho _R^{\\text{max}} \\approx \\Gamma _\\varphi M_P M^2\\). \n\\marginnote{The \\(a\\)-dependent part has a maximum value of roughly \\num{.35}.}\n\nThe radiation energy density will be given by \\(\\rho _R = \\frac{\\pi^2}{30} g_* T^{4}\\), so the maximum temperature will be \n%\n\\begin{align}\nT^{\\text{max}} = g_*^{-1/4} \\rho _R^{\\text{max}, 1/4} \\sim g_*^{-1/4} \\qty(\\Gamma _\\varphi M_P M^2)^{1/4}\n\\,.\n\\end{align}\n\nIn the reheating phase the energy density scales like \\(\\rho _R \\propto a^{- 3/2}\\): it is \\emph{decreasing}, but much \\emph{slower} than the usual \\(\\rho _R \\propto a^{-4}\\). \n\nLet us also discuss the entropy: \n%\n\\begin{align}\n^*S = s a^3 &&\ns = \\frac{2 \\pi^2}{45} g_{*s} T^3\n\\,,\n\\end{align}\n%\nso, since \\(\\rho _R \\propto a^{-3/2}\\) and \\(\\rho _R \\propto T^{4}\\) we have \\(s \\propto \\rho _R^{3/4} \\propto a^{- 9/8}\\), therefore\n%\n\\begin{align}\nS \\propto a^3 a^{-9/8} = a^{15/8}\n\\,.\n\\end{align}\n\nIt makes sense that this is increasing. \n\nWhat is the \\emph{reheating temperature}? We want to match the inflationary solution and the radiation-dominated solution. \n\nSince we are in the radiation-dominated phase, we have \\(a \\propto t^{1/2}\\): so\n%\n\\begin{align}\nH^2 = \\frac{8 \\pi G}{3} \\rho _R = \\frac{8 \\pi }{3} \\frac{1}{M_P^2} \\frac{\\pi^2}{30} g_* T^{4} = \\frac{1}{4t^2}\n\\,.\n\\end{align}\n\nThe reheating temperature can be computed as the temperature at \\(T_{RH} = T (t \\approx \\Gamma _\\varphi^{-1})\\). \nPlugging this in, we get \n%\n\\begin{align} \\label{eq:reheating-temperature}\nT_{RH} \\approx \\num{.55} g_*^{-1/4} \\sqrt{\\Gamma _\\varphi M_P}\n\\,.\n\\end{align}\n\nWhat is interesting to note here is that there is no memory of the energy scale \\(M\\), the vacuum energy scale of inflation. \n\\todo[inline]{Add comment about the redshift of the inflaton's energy}\n\nOnly if \\(\\Gamma _\\varphi \\gg H _{\\text{osc}}\\) we would have had \\(T_{RH} \\sim M\\); in that case the reheating would have been \\SI{100}{\\percent} efficient, the harmonic oscillator would have been overdamped. \n\nNote that the maximum temperature reached in the reheating phase is different from the reheating temperature. \n\nSee \\cite[fig.\\ 8.3]{kolbEarlyUniverse1994}. \n\n\\section{Boltzmann equation applications}\n\nA usual rule of thumb is given in terms of the interaction rate \\(\\Gamma = n \\sigma \\abs{v}\\): if \\(\\Gamma \\gtrsim H\\) thermal equilibrium can be established, while if \\(\\Gamma < H\\) interactions become inefficient. \n\nIf, roughly speaking, \\(T \\propto a^{-1}\\), then \\(\\dot{T} / T = - H\\). \n\nWhen \\(\\Gamma \\sim H\\), we need the Boltzmann equation in order to find out what exactly is going on. \nLet us give two examples. \n\n\\(2 \\leftrightarrow 2\\) scattering between relativistic particles may be mediated by a massless boson, such as the photon, or by a massive boson, such as the \\(W^{\\pm}\\) or \\(Z^{0}\\) boson. \n\nIn the first (massless boson) case, we have \n%\n\\begin{align}\n\\sigma \\sim \\frac{\\alpha^2}{T^2} && \\alpha = \\frac{g^2}{4 \\pi }\n\\,,\n\\end{align}\n%\nwhile in the second (massive boson) case we have \n%\n\\begin{align}\n\\sigma \\sim G_X^2 T^2 && G_X = \\frac{\\alpha }{m_X^2}\n\\,.\n\\end{align}\n\nRoughly speaking, \n%\n\\begin{align}\n\\sigma \\sim \\alpha^2\\abs{\\text{propagator}}^2 \\frac{q^{4}}{E^2}\n\\,,\n\\end{align}\n%\nwhere \\(q\\) is the spatial momentum of the interacting particles, while \\(E\\) is the center of mass energy, so for relativistic particles \\(q^{4}/ E^2 \\sim E^2 \\sim T^2\\).\n\nIn the massless boson case, the propagator looks like \n%\n\\begin{align}\n\\text{propagator} \\sim \\frac{-i g_{\\mu \\nu }}{p^2}\n\\,,\n\\end{align}\n%\nwhere \\(p^2 =(q_1 + q_2 )^2\\). \nThen, the cross-section looks like \\(\\sigma \\sim \\alpha^2 / T^2\\) typically. \n\nIn the massive boson case, we have \n%\n\\begin{align}\n\\text{propagator} \\sim \\frac{- i g_{\\mu \\nu } + p_{\\mu } p_{\\nu } / m_X^2}{p^2-  m_X^2}\n\\,,\n\\end{align}\n%\nso \\(\\sigma \\sim \\alpha^2 T^2 / m_X^{4}\\). \n\nIn the massless boson case, then, \n%\n\\begin{align}\n\\Gamma = n \\sigma \\abs{v} \\approx n \\sigma \n\\,,\n\\end{align}\n%\nso if \\(n \\sim T^3\\) (which is the case if we have radiation domination and equilibrium) we get \\(\\Gamma = \\alpha^2 T\\). We want to know when this will be larger than \\(H\\), using the fact that \n%\n\\begin{align}\nH \\sim \\frac{T^2}{M_P} && H^2 = \\frac{8 \\pi G}{3} \\underbrace{\\rho _R}_{\\propto T^{4}}\n\\,,\n\\end{align}\n%\nso \\(\\Gamma \\gtrsim H\\) when \\(T < \\alpha^2 M_P \\sim \\SI{e15}{GeV}\\). \n\nFor the massive gauge boson, at temperatures \\(T \\ll m_X\\) we get \\(\\Gamma \\gtrsim H\\) when \n%\n\\begin{align}\\label{eq:massive-gauge-boson-cross-section}\n\\Gamma = G_X^2 T^{5} &\\gtrsim \\frac{T^2}{M_P}  \\\\\nT &\\gtrsim G_X^{-2/3} M_P^{-1/3}\n\\,.\n\\end{align}\n\nWith normalization reflecting the case of weak interactions, and using \\(G_X \\sim \\alpha / m_X^2\\), we find \n%\n\\begin{align}\nT \\gtrsim \\qty(\\frac{m_X}{\\SI{100}{GeV}})^{4/3} \\SI{1}{MeV}\n\\,,\n\\end{align}\n%\nwhich can be used to figure out when neutrinos decouple. \n\n\\end{document}\n", "meta": {"hexsha": "c53a450f4740a9a619764835c4f25adaa026eb8f", "size": 10841, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_third_semester/early_universe/nov16.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_third_semester/early_universe/nov16.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_third_semester/early_universe/nov16.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 37.5121107266, "max_line_length": 254, "alphanum_fraction": 0.6630384651, "num_tokens": 3751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804478040617, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.40741587583958927}}
{"text": "\\subsection{Choice of spectrograph parameters}\n\nAs a spectrograph, we decided on Horiba iHR550 Imaging Spectrometer with\naperture f/6.4, focal length 550 mm, magnification 1.1, and triple-grating\nturret, so we needed to select three gratings with the best parameters for our\npurpose.\nOne grating position we reserved for fluorescence measurements with 300 gr/mm,\nbut gratings for the other two positions needed to be selected based on the\nrequired spectral range and dispersion.\nWe neglected all the nonlinearities of dispersion dependence on wavelength\nfor spectral range estimation and used dispersions from spectrograph sale\nmaterials shown in\n\\tabref{spectrograph_selection:dispersion_spec}\nfor available gratings.\n\n\\begin{table}\n\t\\centering\n\t\\input{results_and_discussion/assets/spectrograph_dispersion_spec}\n\t\\caption[%\n\t\tGrating dispersion specifications taken from Horiba iHR550\n\t\tspecification document.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tGrating dispersion specifications taken from Horiba iHR550\n\t\t\tspecification document.%\n\t\t}\n\t\tThe linear dispersion\n\t\t$\\frac{\\text{d}\\lambda}{\\text{d}x}$ defines how a spectral interval is\n\t\tspread across the focal field.\n\t}\n\t\\label{\\tablabel{spectrograph_selection:dispersion_spec}}\n\\end{table}\n\nThen we used the Raman wavenumber $\\tilde{\\nu}$ calculation equation from\nthe laser excitation wavelength in the air $\\lambda_\\text{e}$ and Stokes Raman\nsignal wavelength $\\lambda_\\text{R}$\n\\begin{equation}\n\t\\tilde{\\nu} = \\frac{1}{\\lambda_\\text{e}} - \\frac{1}{\\lambda_\\text{R}}\n\t\\label{\\eqnlabel{spectrograph_selection:nu}}\n\\end{equation}\nto calculate the maximal measured wavenumber $\\tilde{\\nu}_2$ from the\n$\\tilde{\\nu}_1 = 200$\\,\\icm{} for all the available excitation wavelengths\nfrom our Ar\\textsuperscript{+} ion frequency-doubled laser according to formula\n\\begin{equation}\n\t\\tilde{\\nu}_2 = \\lambda_\\text{e}^{-1}\n\t\t- \\left(\\frac{1}{\\lambda_\\text{e}^{-1} - \\tilde{\\nu}_1}\n\t\t\t+ w\\frac{\\text{d}\\lambda}{\\text{d}x}\\right)^{-1},\n\t\\label{\\eqnlabel{spectrograph_selection:spectral_range_max_est}}\n\\end{equation}\nwhere $w$ denotes the width of a CCD camera and\n$\\frac{\\text{d}\\lambda}{\\text{d}x}$\ngrating linear dispersion, which defines the extent to which a spectral\ninterval is spread out across the focal field.\nWe also calculated minimal measured wavenumber $\\tilde{\\nu}_1$ from the maximal\n$\\tilde{\\nu}_2 = 4000$\\,\\icm{} using the formula\n\\begin{equation}\n\t\\tilde{\\nu}_1 = \\lambda_\\text{e}^{-1}\n\t\t- \\left(\\frac{1}{\\lambda_\\text{e}^{-1} - \\tilde{\\nu}_2}\n\t\t\t- w\\frac{\\text{d}\\lambda}{\\text{d}x}\\right)^{-1}.\n\t\\label{\\eqnlabel{spectrograph_selection:spectral_range_min_est}}\n\\end{equation}\n\nThe average wavenumber dispersion per pixel can be calculated from these\nvalues as\n\\begin{equation}\n\t\\bar{d} = \\frac{\\tilde{\\nu}_2 - \\tilde{\\nu}_1}{N_w},\n\t\\label{\\eqnlabel{spectrograph_selection:dispersion_est}}\n\\end{equation}\nwhere $N_w = 2048$ is number of camera width pixels.\nThe results based on the dispersion data specified by the vendor can be seen in\n\\tabref{spectrograph_selection:dispersion_est}.\n\n\\begin{table}\n\t\\centering\n\t\\input{results_and_discussion/assets/spectrograph_dispersion_est}\n\t\\caption[%\n\t\tEstimated Raman-shift ranges that can be captured by CCD detector\n\t\tfor particular available excitation wavelengths.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tEstimated Raman-shift ranges that can be captured by CCD detector\n\t\t\tfor particular available excitation wavelengths.%\n\t\t}\n\t\tGratings are denoted by the number of grooves per mm, $\\tilde{\\nu}_1$ and\n\t\t$\\tilde{\\nu}_2$ are the lowest and highest detected frequencies in \\icm{}\n\t\tcalculated according to\n\t\t\\cref{%\n\t\t\t\\eqnlabel{spectrograph_selection:spectral_range_max_est},%\n\t\t\t\\eqnlabel{spectrograph_selection:spectral_range_min_est}%\n\t\t},\n\t\trespectively. The $\\bar{d}$ denotes average dispersion in \\icm/px\n\t\tcalculated from\n\t\t\\eqnref{spectrograph_selection:dispersion_est}.\n\t}\n\t\\label{\\tablabel{spectrograph_selection:dispersion_est}}\n\\end{table}\n\nWe can see that if we want to cover the full Raman vibration range from the\nlow-frequency vibrations of 200\\,\\icm{} to valence hydrogen stretching\nvibrations of 4000\\,\\icm{} at all possible excitation wavelengths, we need to\nselect grating with 1200\\,gr/mm.\nFor the Raman fingerprint region below 1800\\,\\icm{}, we must choose the\ngrating with 2400\\,gr/mm.\n\nSo, finally, we chose grating with 300\\,gr/mm for possible fluorescence\nmeasurements 1200\\,gr/mm for the measurement of the full range, including\nvalence hydrogen stretching vibrations at higher wavelengths (e.g., 257\\,nm\nexcitation), and 2400\\,gr/mm for the Raman fingerprint region measurements.\n\nAfter the gratings were installed, the predictions from spectrograph vendor\nsale materials were evaluated on actual experiment and with the help of\ndiffraction grating theory and spectrograph and CCD camera specifications.\nThe values in the table were adjusted for possible future evaluation of the\nextension of our experimental capabilities.\nWe measured spectra of Pt lamp for different positions of spectrograph and\ncalibrated the spectra to themselves\n(\\cref{wavenumber_calibration}).\nThen the lower ($\\lambda_1$) and upper ($\\lambda_2$) bound wavelengths from\neach spectrum were taken, and dependences of the measured range\n($\\Delta\\lambda = \\lambda_2 - \\lambda_1$)\non these bounds were investigated.\n\nThe diffraction of light on the grating follows the grating equation\n\\begin{equation}\n\ta(\\sin\\alpha_\\text{i} + \\sin\\alpha_m) = m\\lambda,\n\t\\label{\\eqnlabel{spectrograph_selection:grating_equation}}\n\\end{equation}\nwhere $\\alpha_\\text{i}$ is the incident light angle,\n\t$\\alpha_m$ is diffraction angle to the $m$-th diffraction order,\n\t$\\lambda$ is diffracted light wavelength,\n\tand $a$ is grating constant.\nThe directions of the angles $\\alpha$ can be seen in\n\\figref{spectrograph_selection:configuration_schema}.\n\n\\begin{figure}\n\t\\centering\n\t\\input{results_and_discussion/assets/spectrograph_configuration}\n\t\\caption[%\n\t\tSpectrograph configuration schema.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tSpectrograph configuration schema.%\n\t\t}\n\t}\n\t\\label{\\figlabel{spectrograph_selection:configuration_schema}}\n\\end{figure}\n\nThe grating constant can be calculated from the number of grooves per mm\n$N_\\text{gr}$ as\n\\begin{equation*}\n\ta = \\frac{1}{N_\\text{gr}}.\n\\end{equation*}\n\nWe can also derive the angular dispersion\n$\\frac{\\text{d}\\alpha_m}{\\text{d}\\lambda}$\nof the grating from\n\\eqnref{spectrograph_selection:grating_equation}\nfor the fixed incident light angle $\\alpha_\\text{i}$ as\n\n\\begin{equation}\n\t\\frac{\\text{d}\\alpha_m}{\\text{d}\\lambda} = \\frac{m}{a\\cos\\alpha_m}.\n\t\\label{\\eqnlabel{spectrograph_selection:angular_dispersion}}\n\\end{equation}\n\nThe selected spectrograph uses the Czerny-Turner configuration in which the\ndiffracted light is focused onto the detector plane by the focussing mirror\nwith effective focal length $f$, which converts angular dispersion to\ndispersion on the detector plane with coordinate $x$ as\n\\begin{equation*}\n\t\\frac{\\text{d}x}{\\text{d}\\lambda} =\n\t\tf\\frac{\\text{d}\\alpha_m}{\\text{d}\\lambda}\n\\end{equation*}\nand inverting the equation and using\n\\eqnref{spectrograph_selection:angular_dispersion}\nwe get linear dispersion\n\\begin{equation}\n\t\\frac{\\text{d}\\lambda}{\\text{d}x} = \\frac{a\\cos\\alpha_m}{fm}.\n\t\\label{\\eqnlabel{spectrograph_selection:linear_dispersion}}\n\\end{equation}\n\nWe can see that linear dispersion for a fixed grating position is independent\nof the light wavelength but, for a typical spectrograph, the angle between the\nincident and diffracted light $\\varphi$, called \\emph{Ebert angle}, is fixed by\nthe spectrograph geometry and the diffracted light wavelength is selected by\nrotation of diffraction grating by angle $\\vartheta_m$.\nSo, it is helpful to transform\n\\eqnref{spectrograph_selection:grating_equation}\nto these variables.\nFollowing the direction of angles denoted in\n\\figref{spectrograph_selection:configuration_schema},\nwe can derive\n\\begin{equation}\n\t\\alpha_\\text{i} = \\vartheta_m - \\frac{\\varphi}{2}\\ ,\n\t\\alpha_m = \\vartheta_m + \\frac{\\varphi}{2}\n\t\\label{\\eqnlabel{spectrograph_selection:ebert_transformation}}\n\\end{equation}\nand put that into\n\\eqnref{spectrograph_selection:grating_equation},\nand using the goniometric formula for summation of two sine functions, we get\n\\begin{equation}\n\t2a\\sin\\vartheta_m\\cos\\frac{\\varphi}{2} = m\\lambda.\n\t\\label{\\eqnlabel{spectrograph_selection:grating_equation_ebert}}\n\\end{equation}\n\nAs we previously said, for a typical spectrograph, we usually do not know\ndiffraction angle $\\alpha_m$ but rather the Ebert angle $\\phi$, and we can\nmeasure the diffracted light wavelength $\\lambda$ by comparison to the source\nof light with known wavelength so using\n\\eqnref{spectrograph_selection:grating_equation_ebert},\nwe can calculate grating rotation angle\n\\begin{equation}\n\t\\vartheta_m = \\text{arcsin}\\left(\n\t\t\\frac{m\\lambda}{2a\\cos\\frac{\\varphi}{2}}\\right)\n\t\\label{\\eqnlabel{spectrograph_selection:grating_rotation_angle}}\n\\end{equation}\nwhich can be used in combination with\n\\cref{%\n\t\\eqnlabel{spectrograph_selection:ebert_transformation},%\n\t\\eqnlabel{spectrograph_selection:linear_dispersion}%\n}\nfor linear dispersion calculation.\n\nAll the parameters for the linear dispersion calculation can be retrieved from\nthe spectrograph documentation and are summarized in\n\\tabref{spectrograph_selection:dispersion_params}.\n\n\\begin{table}\n\t\\centering\n\t\\input{results_and_discussion/assets/dispersion_params}\n\t\\caption[%\n\t\tSpectrograph and CCD parameters for dispersion calculation.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tSpectrograph and CCD parameters for dispersion calculation.%\n\t\t}\n\t\tAll the values are taken from the spectrograph and CCD specification\n\t\tdocuments.\n\t}\n\t\\label{\\tablabel{spectrograph_selection:dispersion_params}}\n\\end{table}\n\nWe cannot measure linear dispersion directly, but we can measure it, for\nexample, from the spectral range captured by the used CCD camera\n\\begin{equation*}\n\t\\Delta\\lambda = \\lambda_2 - \\lambda_1\n\\end{equation*}\ndivided by the length of the CCD camera $l_\\text{CCD}$, because in the first\napproximation of\n\\eqnref{spectrograph_selection:linear_dispersion},\nthe linear dispersion is not dependent on the diffracted light wavelength.\nSo, we can relate the experimentally measured spectral range to the dispersion\nby equation\n\\begin{equation}\n\t\\Delta\\lambda = l_\\text{CCD}\\frac{\\text{d}\\lambda}{\\text{d}x}.\n\t\\label{\\eqnlabel{spectrograph_selection:measured_range}}\n\\end{equation}\n\nThe last unknown in this equation is the wavelength $\\lambda$ for the Ebert\nangle $\\varphi$, but we can calculate it in the linear dispersion approximation\nas the center of the measured spectral range\n\\begin{equation*}\n\t\\lambda = \\frac{\\lambda_1 + \\lambda_2}{2}.\n\\end{equation*}\n\nAs we want to compare the theoretical and experimental values, the least\nprecise parameter from the description of the instrument was the camera size,\nso we fitted\n\\eqnref{spectrograph_selection:measured_range}\nto the measured ranges with the camera length $l_\\text{CCD}$ as a parameter for\ngrating with 1200 and 2400\\,gr/mm, the results can be seen in\n\\tabref{spectrograph_selection:detector_length_fits}\nand dependences of the spectral ranges on wavelength are plotted in\n\\figref{spectrograph_selection:dispersion_range}.\nIt can be seen from\n\\tabref{spectrograph_selection:detector_length_fits}\nthat the detector length estimation difference between grating\nwith 1200\\,gr/mm and 2400\\,gr/mm is slightly larger than the estimated\nstandard deviations.\nIt can be attributed to the slight inaccuracy in the used Ebert angle, but the\ndifference is so small that we decided not to pursue its\nfurther refinement by a more complicated nonlinear fit.\n\n\\begin{table}\n\t\\centering\n\t\\input{results_and_discussion/assets/detector_length_fits}\n\t\\caption[%\n\t\tResults of fits of dispersion in dependence on a wavelength with\n\t\tdetector length as a parameter for different gratings.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tResults of fits of dispersion in dependence on a wavelength with\n\t\t\tdetector length as a parameter for different gratings.%\n\t\t}\n\t}\n\t\\label{\\tablabel{spectrograph_selection:detector_length_fits}}\n\\end{table}\n\n\\begin{figure}\n\t\\centering\n\t\\begin{subfigure}[b]{1\\textwidth}\n\t\t\\centering\n\t\t\\input{results_and_discussion/assets/spectrograph_dispersion_meas/%\nbounds_1200_range}\n\t\t\\caption{The grating with 1200\\,gr/mm.}\n\t\t\\label{\\figlabel{spectrograph_selection:dipsersion_range_1200}}\n\t\\end{subfigure}\n\t\\\\\n\t\\begin{subfigure}[b]{1\\textwidth}\n\t\t\\centering\n\t\t\\input{results_and_discussion/assets/spectrograph_dispersion_meas/%\nbounds_2400_range}\n\t\t\\caption{The grating with 2400\\,gr/mm.}\n\t\t\\label{\\figlabel{spectrograph_selection:dipsersion_range_2400}}\n\t\\end{subfigure}\n\t\\caption[%\n\t\tPlots of spectral ranges captured by the detector in dependence on\n\t\tthe central detected wavelength for different gratings.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tPlots of spectral ranges captured by the detector in dependence on\n\t\t\tthe central detected wavelength $\\lambda$ for different gratings.%\n\t\t}\n\t\tSolid lines represent theoretical curves following\n\t\t\\eqnref{spectrograph_selection:measured_range}\n\t\twith parameters from\n\t\t\\tabref{spectrograph_selection:dispersion_params}\n\t\tbut for the length of CCD chip $l_\\text{CCD}$ which is the average of\n\t\testimates from fits summarized in\n\t\t\\tabref{spectrograph_selection:detector_length_fits}.\n\t}\n\t\\label{\\figlabel{spectrograph_selection:dispersion_range}}\n\\end{figure}\n\nWe want to calculate the similar table to\n\\tabref{spectrograph_selection:dispersion_est}\nnow.\nFor that purpose, we need to estimate the $\\lambda_2$ if we know $\\lambda_1$ or\nvice versa.\nWe can use the grating equation\n(\\eqnref{spectrograph_selection:grating_equation})\nusing\n\\cref{%\n\t\\eqnlabel{spectrograph_selection:ebert_transformation},%\n\t\\eqnlabel{spectrograph_selection:grating_rotation_angle}%\n}\nwith Ebert angle $\\phi$ modified by view angle of detector length\n$\\beta$ for the rays pointing to the detector edges instead of the center\n\\begin{align}\n\t\\begin{split}\n\t\t\\varphi_1 = \\varphi - \\beta / 2    &= 11.606^\\circ, \\\\\n\t\t\\varphi_2 = \\varphi + \\beta / 2    &= 14.386^\\circ, \\\\\n\t\t\\beta     = \\frac{l_\\text{CCD}}{f} &=  2.781^\\circ,\n\t\\end{split}\n\t\\label{\\eqnlabel{spectrograph_selection:modified_ebert_angles}}\n\\end{align}\nwhere $\\varphi_1$ and $\\varphi_2$ stay for Ebert angles to the beginning and\nend of the detector respectively.\nThe results are summarized in\n\\tabref{spectrograph_selection:dispersion_meas}.\n\n\\begin{table}\n\t\\centering\n\t\\input{results_and_discussion/assets/spectrograph_dispersion_meas}\n\t\\caption[%\n\t\tSpectrograph dispersion estimation.%\n\t]{%\n\t\t\\captiontitle{%\n\t\t\tSpectrograph dispersion estimation.%\n\t\t}\n\t\tThese are the same values as in\n\t\t\\tabref{spectrograph_selection:dispersion_est}\n\t\tbut are now calculated from\n\t\t\\cref{%\n\t\t\t\\eqnlabel{spectrograph_selection:grating_equation},%\n\t\t\t\\eqnlabel{spectrograph_selection:ebert_transformation},%\n\t\t\t\\eqnlabel{spectrograph_selection:grating_rotation_angle},%\n\t\t\t\\eqnlabel{spectrograph_selection:nu}%\n\t\t},\n\t\twith Ebert angle values calculated in\n\t\t\\eqnref{spectrograph_selection:modified_ebert_angles}.\n\t\tGratings are denoted by the number of grooves per mm; $\\tilde{\\nu}_1$ and\n\t\t$\\tilde{\\nu}_2$ are the lowest and highest detected frequencies in \\icm.\n\t\tThe $\\bar{d}$ denotes average dispersion in \\icm/px calculated from\n\t\t\\eqnref{spectrograph_selection:dispersion_est}.\n\t}\n\t\\label{\\tablabel{spectrograph_selection:dispersion_meas}}\n\\end{table}\n\nThese results from\n\\tabref{spectrograph_selection:dispersion_meas}\nshow that the real ranges are significantly higher than the values\nestimated from the spectrograph sale materials\n(\\tabref{spectrograph_selection:dispersion_est}),\nespecially for the gratings with higher groove densities.\nIt can be seen from these results that the 3600\\,gr/mm grating would be more\nsuitable for the Raman fingerprint region than the 2400\\,gr/mm one.\n", "meta": {"hexsha": "b689a575ba5930ee00e070b7eb5746cd6613b409", "size": 15798, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/results_and_discussion/spectrograph_selection.tex", "max_stars_repo_name": "lumik/phd_thesis", "max_stars_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/results_and_discussion/spectrograph_selection.tex", "max_issues_repo_name": "lumik/phd_thesis", "max_issues_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 41, "max_issues_repo_issues_event_min_datetime": "2019-08-13T12:27:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T03:00:58.000Z", "max_forks_repo_path": "src/results_and_discussion/spectrograph_selection.tex", "max_forks_repo_name": "lumik/phd_thesis", "max_forks_repo_head_hexsha": "3b29f24732d49b64c627aeb8f6585f042cd59c4e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.7934508816, "max_line_length": 79, "alphanum_fraction": 0.7825041144, "num_tokens": 4451, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4074158748770475}}
{"text": "\\documentclass[onecolumn,english,aps,pra]{revtex4}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{epstopdf}\n\\usepackage{bm}\n\\usepackage{braket}\n\\usepackage{color}\n\\usepackage{rotating,booktabs}\n\\usepackage{array}\n\n\n\\begin{document}\n\\title{Two hard-core anyons in harmonic trap}\n%\\author{Li Yang$^1$, and Han Pu$^{1,2}$}\n\n%\\affiliation{$^{1}$Department of Physics and Astronomy, and Rice Center for Quantum Materials,\n%Rice University, Houston, TX 77251, USA \\\\\n%$^2$Center for Cold Atom Physics, Chinese Academy of Sciences, Wuhan 430071, P. R. China}\n\n\\maketitle\n \n\\section{general formulation}\nA two spinless particle in 1D are described by the two-body wavefunction $\\Psi(x_1,x_2)=\\langle x_1,x_2|\\Psi \\rangle$. The reduced one-body density operator is \\[ \\hat{\\rho}_1 = \\int dx_2\\, \\langle x_2| \\Psi \\rangle \\langle \\Psi |x_2 \\rangle = \\int dx_1 \\int dx'_1 \\int dx_2\\, |x'_1\\rangle \\langle x'_1| \\langle x_2| \\Psi \\rangle \\langle \\Psi |x_2 \\rangle  |x_1\\rangle \\langle x_1| = \\int dx_1 \\int dx'_1 \\, |x'_1\\rangle \\rho(x_1,x_1') \\langle x_1|   \\]  where the one-body density matrix (OBDM) is defined as:\n\\[ \\rho(x,x')= \\langle x'|\\hat{\\rho}_1| x \\rangle = \\int dx_2 \\, \\Psi^*(x,x_2) \\Psi(x',x_2) \\]\nThe real space and momentum space density profiles can be easily obtained from OBDM as\n\\begin{eqnarray}\n\tn(x) &=& N \\langle x| \\hat{\\rho}_1 |x \\rangle = N \\rho(x,x) = N \\int dx_2 \\, \\Psi^*(x,x_2) \\Psi(x,x_2) = N \\int dx_2 \\, |\\Psi(x,x_2)|^2   \\\\\n\tn(p) &=& N \\langle p| \\hat{\\rho}_1 |p \\rangle =\\frac{N}{2\\pi} \\int dx \\int dx' \\,e^{ip(x-x')}\\, \\rho(x,x')\n\t\\end{eqnarray}\nwith $N=2$. Furthermore, given a single-particle state $\\varphi(x)$, the probability to find the particle in this state is \\[  P_\\varphi = \\langle \\varphi| \\hat{\\rho}_1 |\\varphi \\rangle= \\int dx \\int dx' \\,\\varphi(x) \\varphi^*(x') \\rho(x,x') \\] \t\n\nWe will focus on the ground state of such a two-particle system in a harmonic trap with hardcore interaction. The Hamiltonian of the system reads:\n\\[ H =H_0+H_{\\rm int}= -\\frac{\\hbar^2}{2m} \\left( \\partial_1^2 + \\partial_2^2 \\right) + \\frac{1}{2} m\\omega^2 (x_1^2+x_2^2) + g\\delta(x_1-x_2)  \\] where the interaction strength takes the limit $g \\longrightarrow \\infty$.\n\n\\section{free fermions in harmonic trap}\nNow consider two free fermions in a harmonic trap, whose single-particle eigenstates are labeled as $\\varphi_i(x)$ where $i =0,$ 1, 2, ..., and satisfy the orthonormal condition $ \\int dx \\, \\varphi_i^*(x) \\varphi_j(x) = \\delta_{ij}$. The ground state wavefunction of the two-fermion system is given by \\[ \\Psi_F(x_1,x_2) = \\frac{1}{\\sqrt{2}} \\,\\left[ \\varphi_0(x_1) \\varphi_1(x_2) -\\varphi_0(x_2) \\varphi_1(x_1) \\right]  \\]\nUsing the expression above, one can readily find the following:\n\\begin{eqnarray}\n\\rho_F(x,x') &=& \\frac{1}{2} \\left[ \\varphi_0^*(x) \\varphi_0(x') +  \\varphi_1^*(x) \\varphi_1(x') \\right] \\\\\nn_F(x) &=& |\\varphi_0(x)|^2 + |\\varphi_1(x)|^2 \\\\\nn_F(p) &=& |\\tilde{\\varphi}_0(p)|^2 + |\\tilde{\\varphi}_1(p)|^2 \n\\end{eqnarray}\nwhere \\[ \\tilde{\\varphi}_i(p) = \\frac{1}{\\sqrt{2\\pi}} \\int dx \\, e^{-ipx}\\,\\varphi_i(x) \\] is the single-particle momentum space wavefunction.\n\nFinally, the probability of finding the particle in the $i^{\\rm th}$ harmonic oscillator eigenstate $\\varphi_i(x)$ is given by \\[ P_0=P_1=1/2\\,,\\;\\;\\;P_{i\\neq 0,1}=0 \\]\nThe corresponding reduced density operator can be written as \n\\[ \\hat{\\rho}_F = \\frac{1}{2} \\left( |\\varphi_0 \\rangle \\langle \\varphi_0| + |\\varphi_1 \\rangle \\langle \\varphi_1| \\right) \\] with the associated von Neumann entropy \\[ S = {\\rm Tr}[-\\hat{\\rho}_F \\ln \\hat{\\rho}_F ] =\\ln 2 \\]\n\n\\section{hardcore anyons in harmonic trap}\nNow consider two hardcore anyons in a harmonic trap. Using the anyon-Fermi mapping, the corresponding wavefunction of the anyons is given by \n\\[ \\Psi_\\kappa (x_1,x_2) = A_\\kappa(x_2-x_1) \\,\\Psi_F(x_1,x_2) \\]\nwhere $\\kappa$ is the anyon statistical parameter and \n\\[ A_\\kappa (x_2-x_1) = e^{i\\pi (1-\\kappa) \\theta(x_2-x_1)}= \\left\\{ \\begin{array}{ll} e^{i\\pi(1-\\kappa)}\\,, & x_2>x_1 \\\\ 1 \\,, & x_2 <x_1 \\end{array}  \\right.  \\] where $\\theta(x_2-x_1)$ is the Heaviside step function.\nThe anyon wavefunction satisfies the following exchange properties:\n\\[ \\Psi_\\kappa(x_1,x_2) = e^{i\\pi \\kappa \\epsilon(x_1-x_2)} \\,\\Psi_\\kappa(x_2,x_1) \\]\nwhere \\[ \\epsilon(x) =  \\left\\{  \\begin{array}{cl} 1\\,, & x>0 \\\\ 0 \\,, & x=0 \\\\ -1\\,, & x<0 \\end{array} \\right.\\]\nTwo special cases are: (1) For $\\kappa=0$, $ A_\\kappa (x_2-x_1) = {\\rm sgn}(x_1-x_2)$, and the anyons correspond to hardcore bosons; (2) for $\\kappa=1$, $A_\\kappa (x_2-x_1) = 1$, and the anyons correspond to hardcore, i.e., free, fermions. Note that $A_\\kappa = A^{\\kappa+2}$, hence we can restrict the values of $\\kappa$ to be $\\kappa \\in [0, 2)$. \n\nSince $|\\Psi_\\kappa| = |\\Psi_F|$ independent of $\\kappa$, the real space density profile $n(x)$ is independent of $\\kappa$. In other words, all hardcore anyons have the same real space density profile independent of their statistical parameter.\n\nFrom the two-body wave function for two hard-core anyons in a harmonic trap, the OBDM can be calculated using the formula given in the first section combined with the anyon-fermi mapping:\n\\begin{align*}\n\\rho_\\kappa(x,x')= \\langle x'|\\hat{\\rho}_1| x \\rangle &= \\int dx_2 \\, \\Psi_{\\kappa}^*(x,x_2) \\Psi_\\kappa(x',x_2)\\\\\n& = \\int dx_2 \\,  e^{-i\\pi (1-\\kappa) \\theta(x - x_2)} e^{i\\pi (1-\\kappa) \\theta(x' - x_2)} \\Psi_{F}^*(x,x_2) \\Psi_{F}(x',x_2)\\\\\n& = \\rho_{F}(x,x') + \\epsilon(x' - x)(e^{\\epsilon(x' - x) i\\pi (1-\\kappa)} - 1)\\int_{x}^{x'} dx_2 \\, \\Psi_{F}^*(x,x_2) \\Psi_{F}(x',x_2)\n\\end{align*}\n\nThe latter integral can be calculated ``analytically\" using the error function. \n\nUsing the projection formula given in the first section, the anyon OBDM can be used to numerically calculate the anyon's projection values. For one of the fermions in the two-body ground state, the probability of finding the particle in either the ground state or the first excited state was $P_{0} = P_{1} = \\frac{1}{2}$ and all other projections were 0. An anyon in the two-body ground state can be found in any of the excited states (assuming $\\kappa \\neq 1$), however, with diminishing probability for excited states with more energy. \n\nFor instance, if two hard-core bosons are in the two-body ground state of a harmonic trap, then the probability of finding one of those particles in the $\\phi_0$ state is .718, the probability for the $\\phi_1$ state is .1667, and so on, as is illustrated in the top left plot of Fig. \\ref{fig:projections} ($\\kappa = 0$).\n\\begin{figure}[h]\n\t\\includegraphics[scale=.5]{\"../Plots/Anyon Projection Values\"}\n\t\\caption{Projections}\n\t\\label{fig:projections}\n\\end{figure}\n\\begin{figure}[h]\n\\includegraphics[scale=.5]{\"../Plots/Momentum\"}\n\\caption{Momentum Distribution}\n\\label{fig:momentum}\n\\end{figure}\n\nThe OBDM can also be used to numerically find the momentum distribution of an anyon for various values of $\\kappa$ (see Fig. \\ref{fig:momentum}). The y-axis indicates the probability of finding the anyon with a particular momentum. Only the hard-core boson case ($\\kappa = 0, 2$) and the fermion case ($\\kappa = 1$) have momentum distributions that are symmetric about $p = 0$.\n\nThe von Neumann entropy can be determined from the OBDM by transforming from the position basis to the harmonic potential eigenbasis. The resulting matrix will be infinite in size, but for the purposes of calculations only the first five terms in each dimension need to be considered -- projections after $P_5$ are on the order of $10^{-3}$ and are thus negligible. If $\\lambda_1, \\lambda_2,\\ldots$ are the eigenvalues of this matrix, the von Neumann entropy is given by\n\\[ S =  -\\sum_i^\\infty \\lambda_i \\log(\\lambda_i) \\]\nThus, the von Neumann entropy for hard-core anyons in the two-body ground state of the harmonic oscillator are given in Fig. \\ref{fig:entropy} for various values of $\\kappa$. The fermion case ($\\kappa = 1$) obtains the analytic result $S = \\log(2) = 0.6931$. \n\n\\begin{figure}[h]\n\\includegraphics[scale=.5]{\"../Plots/EntropyPlot\"}\n\\caption{Plot of von Neumann Entropy $(S)$}\n\\label{fig:entropy}\n\\end{figure}\n\nEvidently, the entropy is greatest for $\\kappa$ near 1 but not 1 and obtains its minimum value for hard-core bosons ($\\kappa = 0$). It is also reassuring that the von Neumann entropy is symmetric about $\\kappa = 1$, so $S_{\\kappa = 1/2} = S_{\\kappa = 3/2}$ and so on.\n\nA. Minguzzi et al.\\footnotemark\\,claim that for large $p$ the momentum distribution $n(p)$ of hardcore bosons decays like $1/p^4$. \n\\footnotetext{A. Minguzzi, P. Vignolo, and M. Tosi, Physics Letters A \\textbf{294}, 222 (2002).}\nI have attempted to reproduce this calculation below in Section IV. Their analytic result is that\n\\[ \\lim_{p \\rightarrow \\infty} n(p) = 2\\sqrt{\\frac{2}{\\pi }} \\frac{(\\hbar m \\omega)^{3/2}}{p^4}  \\]\nIn fig. \\ref{fig:tails} I have plotted on a log-log scale the anyonic momentum distribution $n_\\kappa (p)$ for various $\\kappa$. The orange line depicts the value $\\log(n_\\kappa(p))$ for $p \\in [-25, -2] \\cup [2,25]$. The blue line is the log-log plot of $1/p^4$. These plots confirm that hardcore bosons as well as anyons follow a $1/p^4$ momentum distribution decay. Even though anyons do not have a symmetric momentum distribution for $\\kappa \\in (0,1) \\cup (1,2)$ (see fig. \\ref{fig:momentum}), it is still true that the anyonic momentum tails follow a $1/p^4$ decay, regardless of the sign of $p$ (see fig. \\ref{fig:tails}).\n\nHowever, these numerical results are not in complete accord with the analytic coefficient presented by Minguzzi et al. For instance, if $N(p)$ is the numerically calculated value for the momentum distribution at momentum $p$, then\n\\[ N(p) = \\dfrac{C}{p^4} \\]\nshould hold for some constant $C$ assuming $p$ is sufficiently large. This constant, therefore, can be approximated at each point as $C = N(p) * p^4$. If $N(p)$ has been calculated at values $\\{ p_{1},p_{2}, \\ldots, p_{k} \\}$, then $C \\approx \\text{Mean}(N(p_{1}) * p_{1}^4, N(p_{2}) * p_{2}^4, \\ldots, N(p_{k}) * p_{k}^4) $. Using this fact, one can infer from the data above that $C \\approx 0.513959 $. \n\nIf the $\\frac{1}{2\\pi}$ prefactor is included in Minguzzi's coefficient, my numerical results should be in agreement with Minguzzi's coefficient, yet they still differ by a factor of 2. According to Minguzzi's paper, when the prefactor is included we have $C = \\frac{1}{\\pi} \\sqrt{\\frac{2}{\\pi}} \\approx 0.253974\\ldots$, which is about half what I calculated from my numerical data.\n\n\\section{momentum tail coefficient for hcb}\n\nIn the following section, I will try to reproduce the result from Minguzzi's paper that \n\\[ \\lim_{p \\rightarrow \\infty} n(p) = 2\\sqrt{\\frac{2}{\\pi }} \\frac{(\\hbar m \\omega)^{3/2}}{p^4}  \\]\n\n\\begin{center}\n\\begin{figure}[h]\n\t\\includegraphics[scale=.45]{\"../Plots/FullMomentumTails\"}\n\t\\caption{Momentum Tails for Anyons}\n\t\\label{fig:tails}\n\\end{figure}\n\\end{center}\n\nRecall that two body ground state for two fermions in a harmonic trap is\n\\[ \\Psi_F(x_1,x_2) = \\frac{1}{\\sqrt{2}} \\,\\left[ \\varphi_0(x_1) \\varphi_1(x_2) -\\varphi_0(x_2) \\varphi_1(x_1) \\right]  \\]\n\\[ \\varphi_{n}(x) = \\dfrac{1}{\\pi^{1/4} \\sqrt{\\alpha 2^n n!}} H_{n}(x/\\alpha) e^{-\\frac{1}{2}(x/\\alpha)^2} \\]\nwhere $\\alpha = \\sqrt{\\frac{\\hbar}{m \\omega}}$. Simplifying, \n\\[ \\Psi_{F}(x_{1},x_{2}) = \\dfrac{1}{\\sqrt{\\pi} \\alpha^2} e^{-\\frac{1}{2\\alpha^2} (x_{1}^2 + x_{2}^2)} (x_{2} - x_{1}) \\]\nBy the Bose-Fermi mapping, the two-body ground state for two hard-core bosons must be \n\\[ \\Psi_{B}(x_{1},x_{2}) = \\dfrac{1}{\\sqrt{\\pi} \\alpha^2} e^{-\\frac{1}{2\\alpha^2} (x_{1}^2 + x_{2}^2)} |x_{2} - x_{1}|  \\]\nThe one-body density matrix is then\n\\begin{align*}\n\\rho_{B}(x, x') &= \\int_{-\\infty}^{\\infty} \\Psi_{B}^{*}(x ,x_{2}) \\Psi_{B}(x' ,x_{2}) dx_{2}\\\\\n& = \\dfrac{1}{\\alpha^4 \\pi} e^{-\\frac{1}{2\\alpha^2} (x^2 + x'^2)} \\int_{-\\infty}^{\\infty} e^{-x_{2}^{2}/\\alpha^2} |x_{2} - x| |x_{2} - x'| dx_{2}\n\\end{align*}\nLet $Q_{2} = x_{2}/\\alpha$, $Q = x/\\alpha$, and $Q' = x'/\\alpha$ to obtain\n\\begin{equation}\n\\rho_{B}(x, x') = \\dfrac{1}{\\alpha \\pi} e^{-\\frac{1}{2} (Q^2 + Q'^2)} \\int_{-\\infty}^{\\infty} e^{-Q_{2}^{2}} |Q_{2} - Q| |Q_{2} - Q'| dQ_{2}\n\\end{equation}\nPlease note that I have only scaled $Q_{2}$ via u-substitution. The other variables have just been rewritten to simplify the expression. I am not scaling the length. Variables $Q$ and $Q'$ are just shorthand for $ x/\\alpha$ and $x'/\\alpha$ respectively.\n\nThe momentum distribution is\n\\begin{align*}\nn_{B}(p) &= \\dfrac{N}{2 \\pi \\hbar} \\int_{-\\infty}^{\\infty} dx \\int_{-\\infty}^{\\infty} dx' e^{i \\frac{p}{\\hbar} (x - x')} \\rho_{B}(x,x')\\\\\n& = \\dfrac{N}{2 \\alpha \\pi^2 \\hbar} \\int_{-\\infty}^{\\infty} \\alpha dQ \\int_{-\\infty}^{\\infty} \\alpha dQ' e^{i \\alpha \\frac{p}{\\hbar} (Q - Q')}  e^{-\\frac{1}{2} (Q^2 + Q'^2)} \\int_{-\\infty}^{\\infty} e^{-Q_{2}^{2}} |Q_{2} - Q| |Q_{2} - Q'| dQ_{2}\\\\\n& = \\dfrac{N\\alpha }{2 \\pi^2 \\hbar} \\int_{-\\infty}^{\\infty} dQ \\int_{-\\infty}^{\\infty} dQ' e^{i \\alpha \\frac{p}{\\hbar} (Q - Q')}  e^{-\\frac{1}{2} (Q^2 + Q'^2)} \\int_{-\\infty}^{\\infty} e^{-Q_{2}^{2}} |Q_{2} - Q| |Q_{2} - Q'| dQ_{2}\\\\\n& =  \\dfrac{N\\alpha }{2 \\pi^2 \\hbar} \\int_{-\\infty}^{\\infty}  dQ_{2} e^{-Q_{2}^2} \\int_{-\\infty}^{\\infty} dQ  e^{i \\alpha \\frac{p}{\\hbar} Q} e^{-\\frac{1}{2}Q^2} |Q_{2} - Q|  \\int_{-\\infty}^{\\infty} dQ'  e^{-i \\alpha \\frac{p}{\\hbar} Q'} e^{-\\frac{1}{2}Q'^2} |Q_{2} - Q'| \\\\\n& = \\dfrac{N\\alpha }{2 \\pi^2 \\hbar} \\int_{-\\infty}^{\\infty}  dQ_{2} e^{-Q_{2}^2} \\left| \\int_{-\\infty}^{\\infty} dQ  e^{i \\alpha \\frac{p}{\\hbar} Q} e^{-\\frac{1}{2}Q^2} |Q_{2} - Q| \\right|^2\n\\end{align*}\n\nThe integral over $Q$ can be evaluated asymptotically as\n\n\\begin{equation}\n\\int_{-\\infty}^{\\infty} dQ  e^{i \\alpha \\frac{p}{\\hbar} Q} e^{-\\frac{1}{2}Q^2} |Q_{2} - Q| = \\dfrac{-2 \\hbar ^2 e^{-\\frac{1}{2} Q_{2}^2}}{\\alpha^2 p^2}\n\\end{equation}\n\nfor large p. Thus,\n\\begin{align}\n\\lim_{p \\rightarrow \\infty} n_{B}(p) & = \n\\dfrac{2}{\\pi} \\sqrt{\\dfrac{2}{\\pi}} \\dfrac{(\\hbar m \\omega)^{3/2}}{p^4}\n\\end{align}\n%\nfrom which we can infer that the Tan contact for two harmonically trapped hard-core bosons is\n\\[ \nC_{B}= \\dfrac{2}{\\pi} \\sqrt{\\dfrac{2}{\\pi}}\n\\]\nThis is consistent with the ground state energy of two bosons in the TG ($g \\rightarrow \\infty$) limit, which reads\n\\[ \nE_{B} = E_{0} - 2 \\sqrt{\\dfrac{2}{\\pi}}\\dfrac{1}{g}\n\\]\nand from the adiabatic sweep theorem, we have (see Eur. Phys. J. Special Topics \\textbf{226}, 1583 (2017))\n\\[\n\\dfrac{dE_{B}}{d(1/g)} = -2\\sqrt{\\dfrac{2}{\\pi}} = - \\pi C_{B}\n\\]\n\n\\section{momentum tail coefficient for hca}\n\nTo find the momentum tail coefficient for hard-core anyons, the calculation is very similar to the calculation for hard-core bosons. I will give the derivation for the result\n\n\\[\n\\lim_{p \\rightarrow \\infty} n_\\kappa(p) = \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) \\dfrac{2}{\\pi} \\sqrt{\\dfrac{2}{\\pi}} \\dfrac{(\\hbar m \\omega)^{3/2}}{p^4}\n\\]\nwhere the $\\kappa$ subscript denotes the anyon parameter of the anyon two-body system. \n\nLike before the fermion and hard-core anyon wavefunctions are\n\n\\[ \\Psi_{B}(x_{1},x_{2}) = \\dfrac{1}{\\sqrt{\\pi} \\alpha^2} e^{-\\frac{1}{2\\alpha^2} (x_{1}^2 + x_{2}^2)} |x_{2} - x_{1}| \\]\n\\[ \\Psi_\\kappa(x_{1},x_{2}) = e^{-i \\frac{\\pi \\kappa}{2}  \\epsilon(x_{2} - x_{1})} \\Psi_{B}(x_{1},x_{2})   \\]\n\nwhere the second relation holds up to a constant phase factor and follows from the anyon-fermi mapping in Section III of this note. So the anyon momentum distribution is\n\n\\begin{align*}\nn_\\kappa (p) & = \\dfrac{N}{2 \\pi \\hbar} \\int_{-\\infty}^{\\infty} dx \\int_{-\\infty}^{\\infty} dx' e^{i \\frac{p}{\\hbar} (x - x')} \\rho_\\kappa(x,x')\\\\\n& =  \\dfrac{N}{2 \\pi \\hbar} \\int_{-\\infty}^{\\infty} dx_{2} \n\\left|\\int_{-\\infty}^{\\infty} dx  e^{i \\frac{p}{\\hbar} x} \\Psi_\\kappa^*(x,x_{2}) \\right|^2\n\\end{align*}\n\nConsider the integral\n\\begin{align*}\n\\int_{-\\infty}^{\\infty} dx \\, e^{i \\frac{p}{\\hbar} x} \\Psi_\\kappa^*(x_{1},x_{2}) & = \n\\int_{-\\infty}^{\\infty} dx \\, e^{i \\frac{p}{\\hbar} x}  e^{i \\frac{\\pi \\kappa}{2}  \\epsilon(x_{2} - x)} \\Psi_{B}^*(x, x_{2})\\\\\n& = \\int_{-\\infty}^{\\infty} dx \\, e^{i \\frac{p}{\\hbar} x} \\left( \\cos\\left(\\frac{\\pi \\kappa}{2}\\right) + i \\epsilon(x_{2} - x) \\sin\\left(\\frac{\\pi \\kappa}{2} \\right) \\right) \\Psi_{B}^*(x, x_{2})\n\\end{align*}\nBecause $\\epsilon(x_{2} - x)\\Psi_{B}^*(x, x_{2}) = \\Psi_{F}(x, x_{2}) $, in the $p \\rightarrow \\infty$ limit, the $\\sin$ term above results in an exponentially decaying term, which means it can be neglected because the $\\cos$ term results in a power law $1/p^4$ decay. Thus,\n\n\\begin{align*}\n\\lim_{p \\rightarrow \\infty} \\left[ \\int_{-\\infty}^{\\infty} dx  e^{i \\frac{p}{\\hbar} x} \\Psi_\\kappa^*(x_{1},x_{2}) \\right] & =  \n\\cos\\left(\\frac{\\pi \\kappa}{2}\\right) \\int_{-\\infty}^{\\infty} dx  e^{i \\frac{p}{\\hbar} x} \\Psi_{B}^*(x, x_{2})\\\\\n& = -\\cos\\left(\\frac{\\pi \\kappa}{2}\\right) \\dfrac{2 \\hbar^2 e^{-(x_{2}/\\alpha)^{2}}}{\\sqrt{\\pi}\\alpha^2 p^2}\n\\end{align*}\nwhere the last equality comes from the integrals evaluated in the previous section and $Q_{2}$ is shorthand for $x_{2}/\\alpha$. So,\n\\begin{align*}\n\\lim_{p \\rightarrow \\infty} n_\\kappa (p) & = \\dfrac{2 N \\hbar^3}{\\alpha^4 \\pi^2 p^4} \n\\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right)  \\int_{-\\infty}^{\\infty} dx_{2}  e^{-2(x_{2}/\\alpha)^{2}}\\\\\n& = \\dfrac{2}{\\pi} \\sqrt{\\dfrac{2}{\\pi}} \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) \\dfrac{(\\hbar m \\omega)^{3/2}}{p^4}\n\\end{align*}\n\nNumerical simulation can confirm the analytic results I have just cited. We can infer the anyon momentum tail coefficient from numerical values for $n_{\\kappa}(p)$.  The plot in fig. \\ref{fig:AnyonCoeff} compares the analytic and numerical calculation for the tail coefficient divided by $ \\frac{2}{\\pi} \\sqrt{\\frac{2}{\\pi}}$ (should just be $\\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right)$). This confirms the calculations from Sections IV and V.\n\nIf we define the momentum tail coefficient as the Tan contact, then\n\\[\nC_{\\kappa} = \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) C_{B}\n\\]\nwhich is consistent with the result obtained in Eur. Phys. J. D \\textbf{71}, 135 (2017). Note that in that paper, the anyon statistical parameter $\\chi$ is equal to $(1 - \\kappa)$ in our notation.\n\nAn anyon gas with interaction strength $g$ has the same energy as a bosonic gas with interaction strength $g' = \\frac{g}{\\cos\\left(\\frac{\\pi \\kappa}{2}\\right)}$. Therefore, in the large $g$ limit, the two harmonically trapped anyons should have energy\n\\[\nE_{\\kappa} = E_{0} - 2\\sqrt{\\dfrac{2}{\\pi}} \\frac{1}{g'} \n= E_{0} - 2\\sqrt{\\dfrac{2}{\\pi}} \\frac{\\cos\\left(\\frac{\\pi \\kappa}{2}\\right)}{g}\n\\]\nTherefore, it seems that the adiabatic sweep theorem for anyon gas should read\n\\[\n\\frac{dE_{\\kappa}}{d(1/g)} = - 2 \\cos\\left(\\frac{\\pi \\kappa}{2}\\right) \\sqrt{\\frac{2}{\\pi}} = -\\pi C_{\\kappa} / \\cos\\left(\\frac{\\pi \\kappa}{2}\\right)\n\\]\n\n\\begin{center}\n\\begin{figure}[h]\n\t\\includegraphics[scale=.5]{\"../Plots/AnyonCoeff\"}\n\t\\caption{Anyon momentum tail coefficient plotted as a function of $\\kappa$}\n\t\\label{fig:AnyonCoeff}\n\\end{figure}\n\\end{center}\n\n\\section{Time Evolution of Momentum Tail for expanding hca}\n\nLet's consider the case where two hard-core anyons in the ground state of a harmonic trap are released suddenly. That is, the trap frequency $\\omega$ changes suddenly from $\\omega_{0}$ to 0. The time evolution of a particle in a harmonic trap with a time dependent trap frequency can be found analytically. \n\nLet the potential $V(x) = \\frac{1}{2} m \\omega^2(t) x^2$ where $\\omega(t) = \\omega_0$ for $t < 0$ and let $\\phi_j(x; 0)$ be the $j^{th}$ excited state solution for the static case with trap frequency $\\omega_0$. If $\\phi_j(x; t)$ is the solution for the time dependent case, then \n\\[\n\\phi_j(x; t) = \\frac{1}{\\sqrt{b}}\\phi_j(x/b; 0) e^{i (\\frac{x^2}{2} \\frac{\\dot{b}}{b} - E_j \\tau (t) ) }\n\\]\n\nwhere $b(t)$ and $\\tau(t)$ are determined by \n\n\\begin{align*}\n\\ddot{b} + \\omega^2(t) b = b^{-3}\\\\\n\\tau(t) = \\int^{t}_{0}dt' \\, b^{-2}(t')\n\\end{align*}\n\nIn the sudden expansion case where $\\omega(t) = \\omega_0$ for $t < 0$ and $\\omega(t) = 0$ for $t > 0$, solving these equations with the initial conditions that $b(0) = 1$ and $b'(0) = 0$ gives\n\\begin{eqnarray}\nb(t) = \\sqrt{1 + t^2}\\\\\n\\tau(t) = \\arctan(t)\n\\end{eqnarray}\n\nThese equations can be used to obtain time dependent expressions for the anyonic wavefunction, one-body density matrix, and momentum distribution.\n\n\\begin{align*}\n\\Psi_{\\kappa}(x_{1}, x_{2}; t) & = \n\\frac{1}{b} \\Psi_{\\kappa}(\\frac{x_{1}}{b}, \\frac{x_{2}}{b}; 0)\n\\exp \\left[ \\frac{i \\dot{b}}{2 b} (x_{1}^2 + x_{2}^2) - i \\tau(t) (E_0 + E_1) \\right]\\\\\n\\rho_{\\kappa}(x, x'; t) & = \\frac{1}{b} \\rho_{\\kappa}(\\frac{x}{b}, \\frac{x'}{b}; 0)\n\\exp \\left[ \\frac{i \\dot{b}}{2 b} (x'^2 - x^2) \\right]\\\\\nn_{\\kappa}(p ; t) & = \\dfrac{N}{2\\pi b} \\int dx \\int dx' \n\\rho_{\\kappa}(\\frac{x}{b}, \\frac{x'}{b}; 0)\n\\exp \\left[ip(x - x') +\t \\frac{i \\dot{b}}{2 b} (x'^2 - x^2) \\right]\n\\end{align*}\nwhere\n\\begin{align*}\n\\Psi_{\\kappa}(x_{1}, x_{2}; 0) & = \ne^{i \\pi (1 - \\kappa) \\theta(x_{2} - x_{1})} \\Psi_{F}(x_{1}, x_{2}; 0)\\\\\n\\rho_{\\kappa}(x, x'; 0) & = \\int dx_2 \\, \\Psi_{\\kappa}^*(x,x_2; 0) \\Psi_\\kappa(x',x_2; 0)\n\\end{align*}\n\n\\begin{center}\n\\begin{figure}[h!]\n\t\\includegraphics[scale=.43]{\"../Plots/MomDistExpandingPair\"}\n\t\\caption{Fermionization of HCB (left) and HCA (right $\\kappa = \\frac{1}{2}$) -- dashed red line corresponds to the fermion distribution}\n\t\\label{fig:HCBFermionizationPair}\n\\end{figure}\n\\end{center}\n\nMinguzzi et al. (Phys. Rev. Lett. 94, 240404) show using the stationary phase method that as $t \\rightarrow \\infty$ the momentum distribution of hard-core bosons approaches the fermion momentum distribution. Their numerical calculations also confirm this. I have performed numerical calculation to reproduce this fermionization for two hard-core bosons. These numerical results are depicted in fig. \\ref{fig:HCBFermionizationPair}. \n\nUsing numerical simulation, I also confirmed that two expanding hard-core anyons will experience the same fermionization in their momentum distribution. These results are also in fig. \\ref{fig:HCBFermionizationPair} in the plot on the right.\n\nTo calculate the time evolution of the momentum tail coefficient, we start by simplifying the expression for the momentum distribution to obtain\n\\begin{align*}\nn_{\\kappa}(p ; t) & = \\dfrac{N b}{2\\pi} \\int du \\int dv \n\\rho_{\\kappa}(u, v; 0)\n\\exp \\left[ibp(u - v) +\t \\frac{i \\dot{b}b}{2 } (v^2 - u^2) \\right]\\\\\n& = \\dfrac{N b}{2\\pi} \\int dx_{2} \\left| \\int dx \\, e^{ibpx} \\Psi_{\\kappa}(x, x_{2}; 0) e^{\\frac{i \\dot{b}b}{2} x^2}\\right|^2\n\\end{align*}\n%\nEvaluating the integral in the modulus square we obtain\n%\n\\begin{align*}\n\\int dx \\, e^{ibpx} \\Psi_{\\kappa}(x, x_{2}; 0) e^{\\frac{i \\dot{b}b}{2} x^2} \n= \\cos\\left(\\frac{\\pi \\kappa}{2}\\right) \n\\frac{1}{\\sqrt{\\pi}} e^{- x_{2}^2} \\frac{-2}{b^2 p^2} e^{i \\delta} \n\\text{\tas } p \\rightarrow \\infty \n\\end{align*}\nwhere $\\delta$ is a constant phase shift that will be eliminated by the modulus square and can therefore be ignored. Thus,\n\\[\n\\lim_{p \\rightarrow \\infty} n_{\\kappa}(p ; t) = \n\\frac{4N}{2 \\pi^2 b^3 p^4} \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) \\sqrt{\\frac{\\pi}{2}}\n= \\frac{2}{\\pi} \\sqrt{\\frac{2}{\\pi}} \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) \\frac{1}{b^3 p^4}\n\\]\n\\begin{equation}\n\\lim_{p \\rightarrow \\infty} n_{\\kappa}(p ; t) = \n\\frac{2}{\\pi} \\sqrt{\\frac{2}{\\pi}} \\cos^2\\left(\\frac{\\pi \\kappa}{2}\\right) \\frac{1}{b^3 p^4}\n\\label{MomentumTail}\n\\end{equation}\n\nI made two numerical calculations of the time evolution of the momentum tail coefficient for $\\kappa = 0$ and $\\kappa = \\frac{1}{2}$. Both numerical calculations were in agreement with the analytic prediction given in equation 11. Plots of the time evolution are depicted in fig. \\ref{fig:HCATimeDepPair}\n%\n\\begin{center}\n\\begin{figure}[h]\n\t\\includegraphics[scale=.44]{\"../Plots/MomTailCoeffTimeDepRow\"}\n\t\\caption{Time evolution of momentum tail coefficient for $\\kappa = 0$ (left) and similarly for $\\kappa = 1/2$ (right)} \n\t\\label{fig:HCATimeDepPair}\n\\end{figure}\n\\end{center}\n%\n\\section{Time Evolution of oscillating hca}\n\nIn the last section, we considered the case where the trap frequency of the harmonic trap is suddenly changed from $\\omega_0$ to 0. Now, we will consider the case where the trap frequency is changed from $\\omega_0$ to a non-zero value $\\omega_1$.\n\nAgain we can use the same equations as before to describe the time evolution of the system. It can be shown that if $\\omega(t) = \\omega_0$ for $t \\leq 0$ and $\\omega(t) = \\omega_1$ for $t > 0$, then\n\\begin{align*}\nb(t) = \\sqrt{1 + \\frac{\\omega_0^2 - \\omega_1^2}{\\omega_1^2} \\sin^2(\\omega_1 t)}\\\\\n\\tau(t) = \\frac{1}{\\omega_0} \\arctan\\left(\\frac{\\omega_0}{\\omega_1} \\tan(\\omega_1 t)\\right)\n\\end{align*}\nUnder these conditions, the wave function and the momentum distribution will undergo oscillations with period $T = \\pi/\\omega_1$. Using the same expressions for the OBDM and momentum distribution from the previous section, we can plot the time evolution of the momentum distribution by solving the integrals numerically. \n\nIn fig. \\ref{fig:OscHCATimeDepPair}, there are two plots depicting the time evolution of the oscillating anyon gas for the hard-core boson case ($\\kappa = 0$) and the $\\kappa = 1/2$ case. For the sake of clarity, only half the period is depicted (where full period $T = 3\\pi$) because the time evolution of the latter half of the period is the same as the first half but reversed. So, the plots in fig. \\ref{fig:OscHCATimeDepPair} only give time slices from $t = 0$ to $t = \\frac{3\\pi}{2}$ \n\nThe expression for the momentum tail coefficient in equation \\ref{MomentumTail} can be used to find the momentum tail coefficient in the oscillating case, as long as the appropriate function is used for $b(t)$. In fig. \\ref{fig:MomTailCoeffComp} there is a plot comparing the time evolution of the momentum tail coefficient for the expansion case and the oscillating case. The time evolution of each has been plotted over one full period where $T = 3\\pi$. The momentum tail coefficient decays to zero in the expanding gas case, but oscillates periodically in the case where the the trap frequency is changed to a non-zero value.\n\n\\begin{center}\n\\begin{figure}[h]\n\t\\includegraphics[scale=.52]{\"../Plots/MomDistOscillatingPair\"}\n\t\\caption{Time evolution of oscillating anyon gas $\\kappa = 0$ (left) and similarly for $\\kappa = 1/2$ (right)} \n\t\\label{fig:OscHCATimeDepPair}\n\\end{figure}\n\\end{center}\n\n\\begin{center}\n\\begin{figure}[h]\n\t\\includegraphics[scale=.4]{\"../Plots/MomTailCoeffComparison\"}\n\t\\caption{Time evolution of momentum tail in expanding case and oscillating case} \n\t\\label{fig:MomTailCoeffComp}\n\\end{figure}\n\\end{center}\n\n\\section{momentum tail coefficient for hcb (n-particle case)}\n\nIn this section I will show that for $N$ hard-core bosons in a harmonic trap, the momentum distribution has a momentum tail that decays like $1/p^4$. It can be shown that (see Girardeau et al. \\footnotemark\\,)\n\\footnotetext{M. D. Girardeau, E. M. Wright, and J. M. Triscari, Physical Review A \\textbf{63} 033601 }\n\\begin{align*}\n\\Psi_B(x_{1}, x_{2}, \\ldots, x_{N}) & = A_{N} \\exp\\left(-\\frac{1}{2} \\sum_{i = 1}^{N} x_{i}^2\\right) \\prod_{1 \\leq j < k \\leq N} |x_{k} - x_{j}|\\\\\n\\rho(x, x') & = \\int dx_{2} \\cdots \\int dx_{N} \\Psi_{B}^*(x, x_{2}, \\ldots, x_{N}) \\Psi_{B}(x', x_{2}, \\ldots, x_{N})\n\\end{align*}\nwhere $A_{N} = \\dfrac{2^{(N - 1)N/4}}{\\pi^{N/4}} \\left( \\prod_{n = 0}^{N} n! \\right)^{-1/2}$. Thus, by letting $\\tilde{A}_{N} = \\frac{N}{2 \\pi} A_{N}^2$\n%\n\\begin{align*}\nn_{B}(p) &= \\dfrac{N}{2 \\pi} \\int dx \\int dx' e^{i p (x - x')} \\rho(x, x')\\\\\n& = \\dfrac{N}{2 \\pi} \\int dx_{2} \\cdots \\int dx_{N} \\left| \\int dx e^{i p x} \\Psi_{B}^*(x, x_{2}, \\ldots, x_{N}) \\right|^2\\\\\n& = \\tilde{A}_{N} \\int dx_{2} \\cdots \\int dx_{N} \\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{2 \\leq i < q \\leq N} (x_{q} - x_{i})^2 \\right)\n\t\\left| \\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\prod_{2 \\leq j \\leq N} |x_{j} - x| \\right|^2\n\\end{align*} \n%\nFor large $p$, we can approximate the integral inside the modulus as\n\\[\n\\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\prod_{2 \\leq j \\leq N} |x_{j} - x| = \\left( \\dfrac{-2}{p^2} \\right) \\sum_{j = 2}^{N} e^{-\\frac{1}{2} x_{j}^2} e^{i p x_{j}} \\prod_{k \\neq j} |x_{k} - x_{j}|\n\\]\nPlug this back into the original expression and abbreviating the condition under the product symbol\n\\[\nn_{B}(p) = \\tilde{A}_{N} \\frac{4}{p^4} \\int dx_{2} \\cdots \\int dx_{N} \\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\prod_{ i < q} (x_{q} - x_{i})^2 \n\t\\sum_{j = 2}^{N} \\sum_{\\ell = 2}^{N} e^{-\\frac{1}{2} (x_{j}^2 + x_{\\ell}^2)} e^{i p (x_{j} - x_{\\ell})} \n\t\\prod_{k \\neq j} |x_{k} - x_{j}| \\prod_{m \\neq \\ell} |x_{m} - x_{\\ell}|\n\\]\nNow, whenever $x_{j} \\neq x_{\\ell}$ in the double sum, there will be $e^{i p (x_{j} - x_{\\ell})}$ term. Elements in the double sum with this term (after they are integrated over) will lead to higher order dependencies (e.g., $1/p^2$), and once these terms are multiplied by $1/p^4$ in the prefactor, they will no longer be leading order. Thus, we can neglect any terms in the double sum where $x_{j} \\neq x_{\\ell}$, giving\n\\begin{align*}\nn_{B}(p) & = \\tilde{A}_{N} \\frac{4}{p^4} \\int dx_{2} \\cdots \\int dx_{N} \\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\prod_{ i < q} (x_{q} - x_{i})^2 \n\t\\sum_{j = 2}^{N} e^{-x_{j}^2} \\prod_{k \\neq j} (x_{k} - x_{j})^2\\\\\n\t& = \\tilde{A}_{N} \\frac{4}{p^4} \\sum_{j = 2}^{N} \\int dx_{2} \\cdots \\int dx_{N} \n\t\\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{ i < q} (x_{q} - x_{i})^2 \\right) \n\te^{-x_{j}^2} \\prod_{k \\neq j} (x_{k} - x_{j})^2\\\\\n\\end{align*}\n\nBecause each integral in this sum is the same but with the indices rotated, we can write\n\\begin{align*}\nn_{B}(p) & = \\tilde{A}_{N} \\frac{4 * (N - 1)}{p^4} \\int dx_{2} \\cdots \\int dx_{N} \n\t\\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{ i < q} (x_{q} - x_{i})^2 \\right) \n\te^{-x_{2}^2} \\prod_{k \\neq 2} (x_{k} - x_{2})^2\\\\\n\t& = \\dfrac{C_{N}}{p^4}\\\\\nC_{N} & = 4(N - 1)\\tilde{A}_{N}  \\int dx_{2} \\cdots \\int dx_{N} \n\t\\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{ i < q} (x_{q} - x_{i})^2 \\right) \n\te^{-x_{2}^2} \\prod_{k \\neq 2} (x_{k} - x_{2})^2\\\\\n\\end{align*}\nI have tried to simplify the expression for $A_{N}$ as much as I can, but I still have not been able to find an analytic expression for it. Nonetheless, this still shows that the momentum distribution has a $1/p^4$ momentum decay for arbitrary $N$. For numerical confirmation of this result, see next section\n\n\\section{momentum tail coefficient for hca (n-particle case)}\n\nIn this section, I will find the momentum tail for $N$ hard-core anyons. We will be able to use some of the results from the previous section to help us. The anyon-fermi mapping is given by\n\\[\nA_{\\kappa}(x_{1},x_{2}, \\ldots, x_{N}) = \\prod_{2 \\leq j < k \\leq N} e^{i\\pi(1 - \\kappa) \\theta(x_{k} - x_{j})} = \\exp\\left[ i\\pi(1-\\kappa) \\left( \\sum_{j < k} \\theta(x_{k} - x_{j}) \\right) \\right]\n\\]\nThus, the anyon wave function is \n\\[\n\\Psi_{\\kappa}(x_{1}, \\ldots, x_{N}) = A_{N} \\times A_{\\kappa}(x_{1},\\ldots, x_{N}) \\times \\exp\\left(-\\frac{1}{2} \n\\sum_{i = 1}^{N} x_{i}^2\\right) \\prod_{1 \\leq j < k \\leq N} (x_{k} - x_{j})\n\\]\nBut as was mentioned in a previous section, we can also write this as\n\\[\n\\Psi_{\\kappa}(x_{1}, \\ldots, x_{N}) = A_{N}  \\exp\\left(-\\frac{1}{2} \n\\sum_{i = 1}^{N} x_{i}^2\\right) \\exp\\left( i\\frac{\\pi \\kappa}{2} \\Sigma_{j < k} \\epsilon(x_{k} - x_{j}) \\right) \\prod_{1 \\leq j < k \\leq N} |x_{k} - x_{j}|\n\\]\nLetting $\\epsilon_{\\kappa} \\equiv \\exp(i\\frac{\\pi \\kappa}{2} \\Sigma_{j=2}^N \\epsilon(x_{j} - x))$ and $\\tilde{A}_{N} = \\frac{N}{2 \\pi} A_{N}^2$, then the momentum distribution is\n\\begin{align*}\nn_{\\kappa}(p) & = \\frac{N}{2\\pi} \\int dx_{2} \\cdots \\int dx_{N} \\left| \\int dx e^{ipx} \\Psi_{\\kappa}^*(x, x_{2}, \\ldots, x_{N}) \\right|^2\\\\\n& = \\frac{N}{2\\pi} \\int dx_{2} \\cdots \\int dx_{N} \\left| \\int dx e^{ipx} \\exp(i\\frac{\\pi \\kappa}{2} \\Sigma_{j=2}^N \\epsilon(x_{j} - x)) \\Psi_{B}^*(x, x_{2}, \\ldots, x_{N}) \\right|^2\\\\\n& = \\tilde{A}_{N} \\int dx_{2} \\cdots \\int dx_{N} \\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{2 \\leq i < q \\leq N} (x_{q} - x_{i})^2 \\right)\n\t\\left| \\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq N} |x_{j} - x| \\right|^2\n\\end{align*}\nExpanding the $\\epsilon_{\\kappa}$ in the modulus square we obtain\n\\begin{align*}\n\\epsilon_{\\kappa} & = e^{i\\frac{\\pi \\kappa}{2}\\epsilon(x_{2} - x)} \\cdots e^{i\\frac{\\pi \\kappa}{2}\\epsilon(x_{N} - x)}\\\\\n& = \\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{2} - x)\\sin(\\pi \\kappa/2) \\right) \n\\cdots \\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{N} - x)\\sin(\\pi \\kappa/2)\\right)\n\\end{align*}\nTo show how we should handle this product, it will be easier to look at the case for $N = 3$, where\n\\begin{align*}\n \\int dx e^{ipx} \\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{2} - x)\\sin(\\pi \\kappa/2)\\right) \n\\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{3} - x)\\sin(\\pi \\kappa/2)\\right) e^{-\\frac{1}{2} x^2}  \\prod_{2 \\leq j \\leq 3} |x_{j} - x| \\\\\n= \\int dx e^{ipx} \\left( \\cos^2(\\pi \\kappa/2) \n+ i\\frac{1}{2}\\epsilon(x_{2} - x)\\sin(\\pi \\kappa) + i\\frac{1}{2}\\epsilon(x_{3} - x)\\sin(\\pi \\kappa)\n - \\epsilon(x_{2} - x)\\epsilon(x_{3} - x) \\sin^2(\\pi \\kappa/2) \\right) e^{-\\frac{1}{2} x^2}  \\prod_{2 \\leq j \\leq 3} |x_{j} - x|\n\\end{align*}\n%\nThe integral over the first term can be found easily by using the calculations from the boson case. I will show that all other terms that have a $\\epsilon$ function in them will not be leading order and can therefore be ignored. For instance, let's look at the integral over $x$ for the second term (ignoring prefactors)\n%\n\\begin{align*}\n\\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon(x_{2} - x) |x_{2} - x| |x_{3} - x|\n&= \\int dx e^{i p x} e^{-\\frac{1}{2} x_{2}^2} \\epsilon(x_{2} - x) |x_{2} - x| |x_{3} - x_{2}| \\\\\n& + \\int dx e^{i p x} e^{-\\frac{1}{2} x_{3}^2} \\epsilon(x_{2} -x_{3}) |x_{2} - x_{3}| |x_{3} - x| + o (\\frac{1}{p^2})\\\\\n&= 0 - \\frac{2}{p^2} e^{ipx_{3}}e^{-\\frac{1}{2} x_{3}^2} \\epsilon(x_{2} -x_{3}) |x_{2} - x_{3}| \n\\end{align*}\n\nUsing \\textit{Applications of Fourier Transforms to Generalized Functions} by M. Rahman (see the table on p. 159) to evaluate these integrals. The first integral is zero because the fourier transform of $\\epsilon(x_{2} - x) |x_{2} - x|$ with respect to $x$ is 0. Evaluating the integral with respect to $x$ over other terms in the sum yields\n\\begin{align*}\n\\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq 3} |x_{j} - x| = \\left( \\frac{-2}{p^2} \\right) \n \\cos^2(\\frac{\\pi \\kappa}{2}) \\sum_{j=2}^{3} e^{-x_{j}^2/2 + ipx_{j}} |x_{3} - x_{2}|\\\\\n + \\frac{i}{2} \\sin(\\pi \\kappa) \\left( \\frac{-2}{p^2} \\right) |x_{2} - x_{3}| \\epsilon(x_{2} - x_{3})\n \\sum_{j=2}^{3} (-1)^{j} e^{-x_{j}^{2}/2 + ipx_{j}} \n\\end{align*}\nwhere the last term in the sum with two $\\epsilon$ functions will evaluate to zero. Now, to find the momentum distribution for the $N = 3$ case, we must find the modulus square of this expression. I will leave out the derivation for the following result, but if you use the same reasoning for the boson case you will find that \n\n\\begin{align*}\n\\left| \\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq 3} |x_{j} - x| \\right|^2 & = \n\\frac{4}{p^4} |x_{2}-x_{3}|^2 \\left[ \\cos^4(\\pi \\kappa /2) \\sum_{j} e^{-x_{j^2}} + \\frac{\\sin^2(\\pi \\kappa)}{4} \\epsilon(x_{2} - x_{3})^2 \\sum_{j} e^{-x_{j}^2} \\right]\\\\\n& = \\frac{4}{p^4} |x_{2}-x_{3}|^2 \\sum_{j} e^{-x_{j^2}} \\left[ \\cos^4(\\pi \\kappa /2) + \\frac{\\sin^2(\\pi \\kappa)}{4} \\right]\\\\\n& = \\cos^2(\\pi \\kappa /2)\\frac{4}{p^4} |x_{2}-x_{3}|^2 \\sum_{j} e^{-x_{j^2}}\n\\end{align*}\nComparing this with the $N$-particle expression for bosons, we can see that for the $3$ particle case that for large $p$\n\\[\nn_{\\kappa}(p) = \\cos^2(\\pi \\kappa /2) \\frac{C_{3}}{p^4}\n\\]\n\nIt is not clear that for the $N$-particle case whether the $\\kappa$ dependence can be expressed as the power of a cosine function. Letting $\\epsilon_{ij} \\equiv \\epsilon(x_{i} - x_{j}) $ and similarly $|x_{ij}| \\equiv |x_{i} - x_{j}|$ recall that\n%\n\\begin{align*}\nn_{\\kappa}(p) & = \\tilde{A}_{N} \\int dx_{2} \\cdots \\int dx_{N} \\exp\\left(- \\sum_{i = 2}^{N} x_{i}^2\\right) \\left( \\prod_{2 \\leq i < q \\leq N} (x_{q} - x_{i})^2 \\right)\n\t\\left| \\int dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq N} |x_{j} - x| \\right|^2\\\\\n\\epsilon_{\\kappa} & =  \\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{2} - x)\\sin(\\pi \\kappa/2) \\right) \n\\cdots \\left(\\cos(\\pi \\kappa/2) + i\\epsilon(x_{N} - x)\\sin(\\pi \\kappa/2)\\right)\\\\\n& = \\sum_{q = 1}^{N} \\cos^{N-q}(\\pi \\kappa /2) (i \\sin(\\pi \\kappa /2))^{q-1}\n\\sum_{2\\leq i_{1} < \\ldots < i_{q - 1} \\leq N} \\epsilon(x_{i_{1}} - x) \\cdots \\epsilon(x_{i_{q-1}} - x)\n\\end{align*}\n\nSo making extensive use of Theorem 4.4 from Rahman, and abbreviating the summation condition for $i_{1}, i_{2}, \\ldots, i_{q - 1}$\n\\begin{align*}\n\\int & dx e^{i p x} e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq N} |x_{j} - x| =\\\\\n-\\frac{2}{p^2}& \\left[ \\sum_{q = 1}^{N} \\cos^{N-q}(\\pi \\kappa /2) (i \\sin(\\pi \\kappa /2))^{q-1}\n \\sum_{i_{1} < \\ldots < i_{q - 1}} \\sum_{j \\neq i_{1}, \\ldots, i_{q-1}} e^{-x_{j}^2/2 + ipx_{j}} \\epsilon_{i_{1}j} \\cdots \\epsilon_{i_{q-1}j} \\prod_{k \\neq j} |x_{kj}| \\right]\n\\end{align*}\n\nThe modulus square of this expression is then\n\\begin{align*}\n & \\left| \\int dx e^{i p x}  e^{-\\frac{1}{2} x^2} \\epsilon_{\\kappa} \\prod_{2 \\leq j \\leq N} |x_{j} - x| \\right|^2 =\\\\\n\\frac{4}{p^4}  \\sum_{q = 1}^{N} & \\sum_{r = 1}^{N} \\cos(\\pi \\kappa /2)^{2N-q-r} (i \\sin(\\pi \\kappa /2))^{r+q-2} (-1)^{r-1} \n\\sum_{i_{1} < \\ldots < i_{q - 1}} \\sum_{j_{1} < \\ldots < j_{r - 1}}\\\\\n&\\sum_{k \\neq i} \n\\sum_{\\ell \\neq j} \ne^{-(x_{k}^{2} + x_{\\ell}^{2})/2} e^{ip(x_{k} - x_{\\ell})} \n\\epsilon_{i_{1}k} \\cdots \\epsilon_{i_{q-1}k}\n\\epsilon_{j_{1}\\ell} \\cdots \\epsilon_{j_{r-1}\\ell}\n\\prod_{\\alpha \\neq k} |x_{\\alpha k}|\n\\prod_{\\alpha \\neq \\ell} |x_{\\alpha \\ell}|\n\\end{align*}\nwhere the sums are all supposed to be in one line but I have split them into two to fit them on the page. Suppose that $k \\neq \\ell$. Then the integral with respect to $x_{k}$ will be a fourier transform. This can only lead to vanishing terms or non-leading order terms. Due to all the singularities, this fourier transform will be split into a sum over every singularity as per Theorem 4.4. If every fourier transform in this resultant sum is negligible, then the fourier transform overall is negligible. Here I have enumerated every possible fourier transform that could result\n\n\\begin{enumerate}\n\\item $\\mathcal{F}[|x_{k} - x_{i}|] = \\mathcal{O}(\\frac{1}{p^2})$\n\\item $\\mathcal{F}[\\epsilon(x_{k} - x_{i})|x_{k} - x_{i}|] = 0$\n\\item $\\mathcal{F}[\\epsilon(x_{k} - x_{i})|x_{k} - x_{i}|^2] = \\mathcal{O}(\\frac{1}{p^3})$\n\\item $\\mathcal{F}[\\epsilon(x_{k} - x_{i})^2|x_{k} - x_{i}|^2] = \\mathcal{O}(\\frac{1}{p^3})$\n\\item $\\mathcal{F}[|x_{k} - x_{i}|^2] = \\mathcal{O}(\\frac{1}{p^3})$\n\\end{enumerate}\nWhen any of these terms is multiplied by the $\\frac{4}{p^4}$ prefactor, that term will no longer be leading order, and it can therefore be ignored. So, we can ignore any terms with $k \\neq \\ell$ giving us\n\n\\begin{align*}\n\\frac{4}{p^4}  \\sum_{q = 1}^{N} & \\sum_{r = 1}^{N} \\cos(\\pi \\kappa /2)^{2N-q-r} (i \\sin(\\pi \\kappa /2))^{r+q-2} (-1)^{r-1} \n\\sum_{i_{1} < \\ldots < i_{q - 1}} \\sum_{j_{1} < \\ldots < j_{r - 1}}\\\\\n&\\sum_{k \\neq i, j} \ne^{-x_{k}^{2}} \n\\epsilon_{i_{1}k} \\cdots \\epsilon_{i_{q-1}k}\n\\epsilon_{j_{1}k} \\cdots \\epsilon_{j_{r-1}k}\n\\prod_{\\alpha \\neq k} |x_{\\alpha k}|^2\n\\end{align*}\n\n\n\n%\\section{two anyons in harmonic trap with finite contact interaction}\n%Consider the Hamiltonian for two anyons:\n%\\[ H = -\\frac{1}{2} \\left( \\partial^2_{x_1} +\\partial^2_{x_2} \\right) + \\frac{1}{2}(x_1^2+x_2^2) + g\\delta(x_1-x_2)  \\] This can be decomposed to the COM and relative coordinates. The COM Hamiltonian is just the harmoinc oscillator, while the relative Hamiltonian takes the form ($x\\equiv x_1-x_2$): \\[ H_{\\rm rel} = -\\frac{1}{2} \\partial^2_x + \\frac{1}{2} x^2 + g\\delta(x) \\] The relative wavefunction has to satisfiy \\[  \\phi(x) = e^{i\\pi \\kappa \\epsilon(x)} \\,\\phi(-x) \\] This constraint, however, seems to indicate that the wavefunction is discontinuous at $x=0$. If this is the case, then the second order derivative term will result in a derivative in delta function, which cannot be cancelled out. The paper PRL {\\bf 83}, 1275 (1998) seems to be relevant, but I am not sure how they got from Eq. (16) to (17).\n\t\n\n\\end{document}\n", "meta": {"hexsha": "648ba20eee05122aa204489dfcc0820c4611d6ad", "size": 40276, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/two_hardcore_anyon.tex", "max_stars_repo_name": "TimSkaras/UltraColdAtoms", "max_stars_repo_head_hexsha": "18894f616cad277711e7e251be158b6b5afba6f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-18T14:09:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T14:09:28.000Z", "max_issues_repo_path": "Notes/two_hardcore_anyon.tex", "max_issues_repo_name": "TimSkaras/UltraColdAtoms", "max_issues_repo_head_hexsha": "18894f616cad277711e7e251be158b6b5afba6f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/two_hardcore_anyon.tex", "max_forks_repo_name": "TimSkaras/UltraColdAtoms", "max_forks_repo_head_hexsha": "18894f616cad277711e7e251be158b6b5afba6f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-05-27T04:04:16.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-27T04:04:16.000Z", "avg_line_length": 74.4473197782, "max_line_length": 817, "alphanum_fraction": 0.6471099414, "num_tokens": 15651, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4074158665820999}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage{diagbox}\n\\usepackage{wrapfig}\n\\usepackage[utf8]{inputenc}\n%\\usepackage[swedish]{babel}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{units}\n\\usepackage{ae}\n\\usepackage{icomma}\n\\usepackage{color}\n\\usepackage{graphics} \n\\usepackage{bbm}\n\\usepackage{float}\n\n\\usepackage{caption}\n\\usepackage{subcaption}\n\n\\usepackage{hyperref}\n\\usepackage{epstopdf}\n\\usepackage{epsfig}\n\\usepackage{braket}\n\\usepackage{pdfpages}\n\n\\usepackage{tcolorbox}\n\n\\newcommand{\\N}{\\ensuremath{\\mathbbm{N}}}\n\\newcommand{\\Z}{\\ensuremath{\\mathbbm{Z}}}\n\\newcommand{\\Q}{\\ensuremath{\\mathbbm{Q}}}\n\\newcommand{\\R}{\\ensuremath{\\mathbbm{R}}}\n\\newcommand{\\C}{\\ensuremath{\\mathbbm{C}}}\n\\newcommand{\\id}{\\ensuremath{\\,\\mathrm{d}}}\n\\newcommand{\\rd}{\\ensuremath{\\mathrm{d}}}\n\\newcommand{\\Ordo}{\\ensuremath{\\mathcal{O}}}% Stora Ordo\n\\renewcommand{\\L}{\\ensuremath{\\mathcal{L}}}% Stora Ordo\n\\newcommand{\\sub}[1]{\\ensuremath{_{\\text{#1}}}}\n\\newcommand{\\ddx}[1]{\\ensuremath{ \\frac{\\partial}{\\partial #1} }}\n\\newcommand{\\ddxx}[2]{\\ensuremath{ \\frac{\\partial^2}{\\partial #1 \\partial #2} }}\n%\\newcommand{\\sup}[1]{\\ensuremath{^{\\text{#1}}}}\n\\renewcommand{\\b}[1]{\\ensuremath{ {\\bf #1 } }}\n\\renewcommand{\\arraystretch}{1.5}\n\n\\begin{document}\n\n\\begin{center}\n\\Large \\bf On two integrals appearing in the relativistic test particle operator.\n\\end{center}\n\nWe need to evaluate\n\\begin{align}\n\\psi_0 &= \\int_0^p \\frac{\\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]}}{\\sqrt{1+s^2}} \\, \\rd s \\nonumber \\\\\n&= \\int_0^\\infty \\frac{\\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]}}{\\sqrt{1+s^2}} \\, \\rd s  - \\int_p^\\infty \\frac{\\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]}}{\\sqrt{1+s^2}} \\, \\rd s, \\nonumber \\\\\n\\psi_1 &= \\int_0^p \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s \\nonumber \\\\\n&= \\int_0^\\infty \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s  - \\int_p^\\infty \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s.\n\\end{align}\nThe two definite integrals can be expressed in terms of the modified Bessel functions $K$ as\n\\begin{align}\n\\int_0^\\infty \\frac{\\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]}}{\\sqrt{1+s^2}} \\, \\rd s &=  e^{1/\\Theta}K_0\\left(\\frac{1}{\\Theta}\\right) \\nonumber \\\\\n\\int_0^\\infty \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s   &= e^{1/\\Theta}K_1\\left(\\frac{1}{\\Theta}\\right).\n\\end{align}\nThe remainder can be rewritten, using the change of variables\n\\begin{align}\nx &= \\sqrt{1+s^2}, \\nonumber \\\\\n\\rd x &= \\frac{s}{x}\\rd s, \\nonumber \\\\\ns &= \\sqrt{x^2-1},\n\\end{align}\nso that\n\\begin{align}\n\\int_p^\\infty \\frac{\\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]}}{\\sqrt{1+s^2}} \\, \\rd s &= \\int_\\gamma^\\infty \\frac{\\exp{\\Bigl[-(x-1)/\\Theta\\Bigr]}}{\\sqrt{x^2-1}} \\, \\rd x, \\nonumber \\\\\n&= e^{-(\\gamma-1)/\\Theta}   \\int_\\gamma^\\infty \\frac{\\exp{\\Bigl[-(x-\\gamma)/\\Theta\\Bigr]}}{\\sqrt{x^2-1}} \\nonumber \\\\\n\\int_p^\\infty \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s &= \\int_\\gamma^\\infty \\frac{x}{\\sqrt{x^2-1}}\\exp{\\Bigl[-(x-1)/\\Theta\\Bigr]} \\, \\rd x, \\nonumber \\\\\n&= e^{-(\\gamma-1)/\\Theta}\\int_\\gamma^\\infty \\frac{x}{\\sqrt{x^2-1}}\\exp{\\Bigl[-(x-\\gamma)/\\Theta\\Bigr]} \\, \\rd x.\n\\end{align}\nWe can therefore write them on the Laguerre integration form\n\\begin{align}\n\\psi_0 &= e^{1/\\Theta}K_0(1/\\Theta) - e^{-(\\gamma-1)/\\Theta} \\int_\\gamma^\\infty \\frac{1}{\\sqrt{x^2-1}} w(x) \\, \\rd x , \\nonumber \\\\\n\\psi_1 &= e^{1/\\Theta}K_1(1/\\Theta) - e^{-(\\gamma-1)/\\Theta} \\int_\\gamma^\\infty \\frac{x}{\\sqrt{x^2-1}} w(x) \\, \\rd x , \\nonumber \\\\\nw &= \\exp\\Bigl[-(x-\\gamma)/\\Theta\\Bigr].\n\\end{align}\nTo obtain an energy-independent quadrature we can translate $x-\\gamma \\mapsto x$.\n\n\n\\section{Partial temperature derivative}\nFor the evaluation of the Jacobian, we need to evaluate (with $\\Theta = T/mc^2$)\n\\begin{align}\n\\frac{\\partial \\psi_0}{\\partial T} &= \\frac{1}{mc^2\\Theta^2}\\int_0^p \\left(1-\\frac{1}{\\sqrt{1+s^2}}\\right) \\exp\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr] \\nonumber \\\\\n&= \\frac{\\psi_1 - \\psi_0}{T\\Theta}, \\\\\n\\frac{\\partial \\psi_1}{\\partial T} &= \\frac{1}{mc^2\\Theta^2}\\int_0^p \\left(\\sqrt{1+s^2}-1\\right) \\exp\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]  \\nonumber \\\\\n&= \\frac{\\psi_2 - \\psi_1}{T\\theta},\n\\end{align}\nwhere we introduce \n\\begin{align}\n\\psi_2 &= \\int_0^p \\sqrt{1+s^2} \\exp{\\Bigl[-(\\sqrt{1+s^2}-1)/\\Theta\\Bigr]} \\, \\rd s \\nonumber \\\\\n&= e^{1/\\Theta}[K_0(1/\\Theta) + \\Theta K_1(1/\\Theta)] - e^{-(\\gamma-1)/\\Theta}\\int_\\gamma^\\infty \\frac{x^2}{\\sqrt{x^2-1}}w(x)\\,\\rd x\n\\end{align}\n\n\\section{Asymptotic expansions}\nIn this section we give asymptotic expansions of the $\\psi$ functions which can be useful in certain limits.\n\n\\subsection{Superthermal limit, $\\gamma - 1 \\gg \\Theta$}\n\nFor the evaluation of the three special functions $\\psi_n$, we require the evaluation of the integrals\n\\begin{align}\nP_k = \\int_{\\gamma}^\\infty \\frac{x^k}{\\sqrt{x^2-1}}e^{-(x-\\gamma)/\\Theta}\\,\\rd x,\n\\end{align}\nfor $k=0,\\,1,\\,2$. A useful asymptotic expansion valid for $\\Theta \\ll 1$ is obtained by repeated integration by parts\n\\begin{align}\nP_k &= \\Theta \\frac{\\gamma^k}{\\sqrt{\\gamma^2-1}} + \\int_\\gamma^\\infty \\frac{\\rd}{\\rd x}\\left(\\frac{x^k}{\\sqrt{x^2-1}}\\right)e^{-(x-\\gamma)/\\Theta} \\rd x \\nonumber \\\\\n&= ... \\nonumber \\\\\n&= \\Theta \\sum_{n=0}^\\infty \\Theta^n  \\left(\\frac{\\rd}{\\rd \\gamma}\\right)^n\\left(\\frac{\\gamma^k}{\\sqrt{\\gamma^2-1}}\\right). \n\\end{align}\nCarrying out this expansion to second-to-leading order yields\n\\begin{align}\nP_k &\\sim \\Theta \\frac{\\gamma^k}{p} + \\Theta^2 \\frac{\\gamma^{k-1}[(k-1)p^2 - 1]}{p^3} + \\Ordo(\\Theta^3/p^5).\n\\end{align}\nThis approximation is accurate in the superthermal limit: $p \\gg \\sqrt{\\Theta}$.\n\nThis produces the following expressions for the special functions:\n\\begin{align}\n\\psi_0 &\\sim e^{1/\\Theta}K_0\\left(\\frac{1}{\\Theta}\\right) - \\frac{\\Theta}{p} e^{-(\\gamma-1)/\\Theta} + \\Theta^2\\frac{\\gamma}{ p^3}e^{-(\\gamma-1)/\\Theta} \\nonumber \\\\\n\\psi_1 &\\sim e^{1/\\Theta}K_1\\left(\\frac{1}{\\Theta}\\right) - \\Theta \\frac{\\gamma}{p}e^{-(\\gamma-1)/\\Theta} +\\frac{\\Theta^2 }{p^3}e^{-(\\gamma-1)/\\Theta}  \\\\\n\\psi_2 &\\sim e^{1/\\Theta}K_0\\left(\\frac{1}{\\Theta}\\right) + \\Theta\\left[ e^{1/\\Theta} K_1\\left(\\frac{1}{\\Theta}\\right)  - \\frac{\\gamma^2}{p}e^{-(\\gamma-1)/\\Theta}\\right] - \\Theta^2 \\frac{\\gamma(\\gamma^2-2)}{p^3} e^{-(\\gamma-1)/\\Theta}\\nonumber\n\\end{align}\nAt $\\gamma-1 = 10\\Theta$, each of these expanded forms have a relative error of approximately $10^{-8}$, compared to the exact expressions.\n\n\n\\subsection{Non-relativistic or low-energy limit, $\\mathrm{max}(\\Theta,\\,\\gamma-1)\\ll 1$}\nIn the non-relativistic limit, we may use the alternative form of the $\\psi$ functions:\n\\begin{align}\n\\psi_n = \\int_0^p (1+s^2)^{(n-1)/2} \\exp\\Big[ - (\\sqrt{1+s^2} - 1)/\\Theta \\Big] \\rd s.\n\\end{align}\nBy making a change of variables\n\\begin{align}\n\\frac{\\sqrt{1+s^2}-1}{\\Theta} &= x^2 , \\nonumber \\\\\n\\frac{1}{\\Theta}\\frac{s\\rd s}{\\sqrt{1+s^2}} &= 2x\\rd x, \\nonumber \\\\ \ns &= \\sqrt{ (1+\\Theta x^2)^2 - 1} = x\\sqrt{2\\Theta}\\sqrt{1+ \\frac{1}{2}\\Theta x^2} ,\n\\end{align}\nthe integral is recast into\n\\begin{align}\n\\psi_n &= \\sqrt{2\\Theta} \\int_0^{x_m(p)} \\frac{(1+\\Theta x^2)^{n}}{\\sqrt{1+\\frac{1}{2}\\Theta x^2}} e^{-x^2} \\, \\rd x, \\nonumber \\\\\nx_m &= \\sqrt{\\frac{\\gamma-1}{\\Theta}}.\n\\end{align}\nThe integrand can be Taylor expanded with\n\\begin{align}\n\\frac{(1+\\Theta x^2)^{n}}{\\sqrt{1+\\frac{1}{2}\\Theta x^2}} \\sim 1 + \\frac{4n-1}{4}\\Theta x^2 + \\frac{1}{4}\\left(2n^2 - 3n + \\frac{3}{8}\\right)\\Theta^2 x^4 + \\Ordo\\bigl(\\Theta^3 x^6\\bigr).\n\\end{align}\nUsing the integral identities \n\\begin{align}\n\\int_0^{x_m} e^{-x^2} \\,\\rd x &= \\frac{\\sqrt{\\pi}}{2}\\mathrm{erf}(x_m), \\nonumber \\\\\n\\int_0^{x_m} x^2e^{-x^2} \\,\\rd x &= \\frac{\\sqrt{\\pi}}{4}\\mathrm{erf}(x_m) - \\frac{1}{2} x_m e^{-x_m^2}, \\nonumber \\\\\n\\int_0^{x_m} x^4e^{-x^2} \\,\\rd x &= \\frac{3\\sqrt{\\pi}}{8}\\mathrm{erf}(x_m) - \\frac{3+2x_m^2}{4}x_m e^{-x_m^2},\n\\end{align}\nwe obtain\n\\begin{align}\n\\frac{1}{\\sqrt{2\\Theta}}\\psi_n &\\sim \\left[ 1 + \\frac{4n-1}{8}\\Theta + \\frac{3}{16}\\left(2n^2- 3n + \\frac{3}{8}\\right)\\Theta^2 \\right] \\frac{\\sqrt{\\pi}}{2}\\mathrm{erf}(x_m) \\nonumber \\\\\n& - \\frac{\\Theta}{8} x_m e^{-x_m^2} \\left[ 4n-1 + \\Theta \\frac{3+2x_m^2}{2}\\left(2n^2-3n+\\frac{3}{8}\\right)  \\right]\n\\end{align}\nThese expressions have a relative error $<10^{-8}$ when $\\gamma-1 < 0.01$ (i.e. when $p<0.15$) or when $\\Theta < 0.005$ (corresponding to temperatures $T < 2.5\\,$keV).\n\n%\\section{Lorentz conductivity calculation}\n%Consider the equation\n%\\begin{align}\n%\\frac{1}{\\mathcal{V}'}\\frac{\\partial}{\\partial p}\\left(\\mathcal{V}'\\{A^p\\} f\\right) + \\frac{1}{\\mathcal{V}'}\\frac{\\partial}{\\partial \\xi}\\left(\\mathcal{V}' \\{A^\\xi\\} f\\right) +  = \\frac{1}{\\mathcal{V}'}\\frac{\\partial}{\\partial \\xi}\\left(\\mathcal{V}'\\{D^{\\xi\\xi}\\}\\frac{\\partial f}{\\partial \\xi} \\right) \n%\\end{align}\n%in the limit $D \\gg A$ for which $f = f_0 + f_1+ ...$ where $f_0 = f_0(p)$. The equation then takes the form\n%\\begin{align}\n%\\frac{1}{\\mathcal{V'}}\\left(\\frac{\\partial \\mathcal{V}'\\{A^p\\}}{\\partial p} + \\frac{\\partial  \\mathcal{V}'\\{A^\\xi\\}}{\\partial \\xi}\\right)f_0 + \\{A^p\\}\\frac{\\partial f_0}{\\partial p} = \\frac{1}{\\mathcal{V}'}\\frac{\\partial}{\\partial \\xi}\\left(\\mathcal{V}'\\{D^{\\xi\\xi}\\}\\frac{\\partial f_1}{\\partial \\xi} \\right) \n%\\end{align}\n%Integrating over $\\rd \\xi \\, \\mathcal{V}'$ from $\\xi = \\xi$ to $1$ (where $\\{A^\\xi\\}$ and $\\{D^{\\xi\\xi}\\}$ both vanish for $\\xi=1$) yields\n%\\begin{align}\n%\\frac{\\partial}{\\partial p}\\left( f_0\\int_\\xi^1\\rd \\xi \\, \\mathcal{V}'\\{A^p\\}\\right) - \\mathcal{V}'\\{A^\\xi\\} f_0 = -\\mathcal{V}'\\{D^{\\xi\\xi}\\}\\frac{\\partial f_1}{\\partial \\xi}.\n%\\end{align}\n%Dividing by $\\mathcal{V'}\\{D^{\\xi\\xi}\\}$ and again integrating over $\\xi$, from $0$ to $\\xi$, yields\n%\\begin{align}\n%\n%\\end{align}\n\n\\end{document}\n", "meta": {"hexsha": "fe2ad1084b783956e990db982bdb0df303fd4eda", "size": 9613, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/notes/psi0psi1evaluation.tex", "max_stars_repo_name": "chalmersplasmatheory/DREAM", "max_stars_repo_head_hexsha": "715637ada94f5e35db16f23c2fd49bb7401f4a27", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2020-09-07T11:19:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-17T17:40:19.000Z", "max_issues_repo_path": "doc/notes/psi0psi1evaluation.tex", "max_issues_repo_name": "chalmersplasmatheory/DREAM", "max_issues_repo_head_hexsha": "715637ada94f5e35db16f23c2fd49bb7401f4a27", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 110, "max_issues_repo_issues_event_min_datetime": "2020-09-02T15:29:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-09T09:50:01.000Z", "max_forks_repo_path": "doc/notes/psi0psi1evaluation.tex", "max_forks_repo_name": "chalmersplasmatheory/DREAM", "max_forks_repo_head_hexsha": "715637ada94f5e35db16f23c2fd49bb7401f4a27", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-05-21T13:24:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T14:43:12.000Z", "avg_line_length": 53.4055555556, "max_line_length": 310, "alphanum_fraction": 0.6320607511, "num_tokens": 3968, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4074158665820999}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%****************************** Third Chapter **********************************\n%*******************************************************************************\n\\chapter{Reduced Order Modeling of Comb-Drive in Electrolytes}\n\n% **************************** Define Graphics Path **************************\n\\ifpdf\n    \\graphicspath{{Chapter3/Figs/Raster/}{Chapter3/Figs/PDF/}{Chapter3/Figs/}}\n\\else\n    \\graphicspath{{Chapter3/Figs/Vector/}{Chapter3/Figs/}}\n\\fi\n\n\\section{Summary}\nThe focus of this chapter will be the development of reduced order models for the comb-drive actuator in electrolytes. We will first review the Poisson-Nernst-Planck equations for describing ionic liquids between parallel plates. This will be followed by a discussion of how these equations facilitate the conceptualization of the system as a circuit, and how this conceptualization was used to develop the classic model. In particular, the assumptions behind the classic model will be enumerated, as will it's shortcomings when fit to data. Finally, we will present our newly developed models, the assumptions behind this work, and opportunities for further work with regard to these models. \n\n\\section{Poisson-Nernst-Planck (PNP) Equations}\nWe saw in Chapter 2 that modeling a comb-drive actuator in electrolytes reduces to modeling the overlapping regions of its fingers as parallel plates filled with a dilute ionic solution. This system is classically described by the Poisson-Nernst-Planck (PNP) equations. The one-dimensional PNP equations are\n\n\\begin{align}\n    \\frac{\\partial c_\\pm}{\\partial t} = - D\\frac{\\partial}{\\partial x}\\bigg(-\\frac{\\partial c_\\pm}{\\partial x} \\mp  \\frac{ze}{k_B T}c_\\pm \\frac{\\partial \\phi}{\\partial x}\\bigg) \\label{pnp_equations_1} \\\\\n    -\\epsilon \\frac{\\partial^2 \\phi}{\\partial x^2} = \\rho_e = ze(c_+ - c_-) \\label{pnp_equations_2} \n\\end{align}\nwhere $c_+$ and $c_-$ are the concentrations of the negative and positive ions respectively, $\\phi$ is the electric potential, D is the diffusivity of the electrolyte, which is assumed to be constant throughout the domain, $z$ is the valence number of the electrolytes, $k_B$ is the Boltzmann constant, $T$ is the temperature of the domain, $\\epsilon$ is the relative permittivity of the aqueous solution, $\\rho_e$ is the electric charge density, and $e$ is the charge of an electron.\n\nBefore performing further analysis on the PNP equations, it is important that we do two things. First, we non-dimensionalize the PNP equations, and then we communicate the physical intuition of the resulting equations. We non-dimensionalize the PNP equations as was done by Druzgalski et al \\cite{Druzgalski2013}. The potential, time, concentration, and spatial coordinates are non-dimensionalized as\n\n\\begin{equation}\\label{nondim_quants}\n    \\phi^* = \\frac{\\phi}{V_T}, \\quad t^* = \\frac{Dt}{g^2}, \\quad  c^*_0 = \\frac{c}{c_0}, \\quad  x^* = \\frac{x}{g},\n\\end{equation}\nwhere $V_T = \\frac{k_B T}{e}$ is the thermal voltage, $g$ is the length of the gap between comb-drive fingers, $c_0$ is the bulk concentration of an ion, and the rest of the terms in the equation are defined after \\ref{pnp_equations_1} and \\ref{pnp_equations_2}. Using these terms, the non-dimensional form of the PNP equations is\n\\begin{align}\n    \\frac{\\partial c_\\pm^*}{\\partial t^*} = - \\frac{\\partial}{\\partial x^*}\\bigg(-\\frac{\\partial c_\\pm^*}{\\partial x^*} \\mp  c_\\pm^* \\frac{\\partial \\phi^*}{\\partial x^*}\\bigg) \\label{pnp_equations_nondim_1} \\\\\n    -2 \\gamma^2 \\frac{\\partial^2 \\phi^*}{\\partial x^{*2}} = \\rho_e^* = c_+^* - c_-^* \\label{pnp_equations_nondim_2} \n\\end{align}\nwhere $\\gamma = \\frac{\\lambda_d}{g}$. The summation in \\ref{pnp_equations_nondim_1} is essentially the nondimensional current flux, $f_\\pm^*$, of the positive and negative ions respectively.\n\n\n\\subsection{Circuit View of System using Linearized PNP Equations}\nWe have introduced and non-dimensionalized the PNP equations, as well as given physical intuition regarding its non-dimensional form. We will now use the non-dimensionalized PNP equations to explain the representation of electrolytes between parallel plates as a circuit. \n\nWe first make the critical assumption that the voltage applied to the parallel plate is small. A small voltage is defined as a voltage that is at most the same order of magnitude as the thermal voltage, $V_T$, which is about 25 $\\mV$. When the applied voltage is small, the region between the parallel plates is described as three distinct parts, figure \\ref{conc_profile}. The center of the domain is called the bulk, and is characterized by an equal concentration of positive and negative ions, low concentration gradients, and a linear potential profile. The two regions located close to the parallel plates, however, are characterized by high concentration gradients, unequal amounts of positive and negative ions, and a nonlinear potential profile. The concentration of positive ions is much higher than the negative at the parallel plate with a lower potential, and vice versa at that with one that is higher. \n\n\\begin{figure}[htpb]\n    \\begin{center}\n    \\includegraphics[width=0.7\\linewidth]{Chapter3/figure/conc_profile.png}\n    \\caption{Schematic of concentration profile of negative and positive ions of electrolyte between parallel plates.}\\label{conc_profile}\n    \\end{center}\n\\end{figure}\n\nWe can apply the non-dimensional PNP equations to these three regions separately, and use the assumption of a small applied voltage, to develop a circuit model for the system. We start with the bulk region in which the concentration gradient is zero, $\\frac{\\partial c_\\pm^*}{\\partial x^*} = 0$, and the potential profile is linear, $\\frac{\\partial \\phi^*}{\\partial x^*}=a \\implies \\frac{\\partial^2 \\phi^*}{\\partial x^{*2}}=0$, where $a$ is some constant. Using these assumptions, \\ref{pnp_equations_nondim_1} and \\ref{pnp_equations_nondim_2} reduce to\n\n\\begin{align}\n    \\frac{\\partial c_\\pm^*}{\\partial t^*} = - \\frac{\\partial}{\\partial x^*}\\bigg( \\mp  c_\\pm^* \\frac{\\partial \\phi^*}{\\partial x^*}\\bigg) = 0 \\label{pnp_equations_simple_nondim_1} \\\\\n    -\\gamma^2 \\frac{\\partial^2 \\phi^*}{\\partial x^{*2}} = \\rho_e^* = c_+^* - c_-^* = 0\\label{pnp_equations_simple_nondim_2} \n\\end{align}\n\nSo, in the bulk we can assume that the concentration of positive and negative ions are equal, and that the concentration does not change as a function of time. We can now write the net current flux in the system as\n\\begin{align}\n    j = f_+^* - f_-^* & = (c_+^* + c_-^*)\\frac{\\partial \\phi^*}{\\partial x^*} \\label{bulk_current_flux_1} \\\\ \n    & = 2c_0^*\\frac{\\partial \\phi^*}{\\partial x^*} \\label{bulk_current_flux_2}  \n\\end{align}\nwhere \\ref{bulk_current_flux_2} is obtained by using the fact that $c_+^* = c_-^*=c_0^*=1$ in the bulk. Equation \\ref{bulk_current_flux_2} has the form $I=\\frac{V}{R}$. We can, therefore, view the non-dimensional resistance and voltage of the bulk region, respectively, as \n\n\\begin{equation} \\label{bulk_resist_volt}\n    R_{Bulk}^* = \\frac{1}{2c_0^*}, \\quad V_{Bulk}^* = \\int_{0}^{g} \\frac{\\partial \\phi^*}{\\partial x^*} dx^*.\n\\end{equation}\n\nWe can perform a similar analysis on the electric double layer regions between the parallel plates. In this region, the poisson equation is \n\\begin{align}\n    -\\gamma^2 \\frac{\\partial^2 \\phi^*}{\\partial x^{*2}} & = c_+^* - c_-^* = \\rho_e^* \\label{poisson_nondim_cap_1} \\\\\n    &  = \\text{sinh}(\\frac{\\phi^*}{2}) = \\frac{dq^*}{dx^*}\\nonumber\n\\end{align}\nwhere \\ref{poisson_nondim_cap_1} is obtained by assuming a boltzmann distribution.\n\\begin{equation} \\label{boltzmann_distrib}\n    c_+^* = c_0^* e^{-\\frac{\\phi z e}{k_B T}}, \\quad c_-^* = c_0^* e^{\\frac{\\phi z e}{k_B T}}\n\\end{equation}\n Under the assumption of linearity, we rewrite \\ref{poisson_nondim_cap_1} as  \n\\begin{equation}\\label{poisson_nondim_ode}\n\\gamma^2 \\frac{d^2\\phi^*}{dx^{*2}} - \\phi^* =0.\n\\end{equation}.\nSolving this ODE, and taking a first order derivative of it's solution, yields\n\\begin{equation} \\label{poisson_nondim_odesol}\n\\frac{d\\phi^*}{dx^*} = -\\gamma^{-1} \\phi^*,\n\\end{equation}\nWe now rewrite \\ref{poisson_nondim_cap_1}, using the solution of \\ref{poisson_nondim_ode}, as\n\\begin{equation} \\label{poisson_nondim_odesol_charge}\n-2 \\bigg(\\frac{\\lambda_d}{g}\\bigg)^2 \\frac{d^2\\phi^*}{dx^{*2}} = -2 \\phi^* = \\frac{dq^*}{dx^*}\n\\end{equation}\nEquations \\ref{poisson_nondim_odesol} and \\ref{poisson_nondim_odesol_charge} indicate that the boundary regions between the electrolytes can be represented as a capacitor. We obtain the dimensionless linear differential capacitance of this region by taking the quotient of \\ref{poisson_nondim_odesol} and \\ref{poisson_nondim_odesol_charge}, yielding\n\\begin{equation} \\label{lin_diff_cap}\n\\frac{dq^*}{dx^*}\\frac{dx^*}{d\\phi^*} = \\frac{dq^*}{d\\phi^*} = 2\\frac{\\lambda_d}{g} = 2\\gamma = C_0 \n\\end{equation}\n\nBased on this analysis, it is clear that we can view electrolytes between parallel plates as a circuit composed of boundary oxide capacitors, and a bulk resistor, figure \\ref{classic_circuit}.\n\n\\section{Classic Circuit Model of Comb-Drive Actuator in Electrolyte}\nIn this section, we will discuss the classic model of the comb-drive in electrolytes, which is based on the circuit model derived in the previous section, figure \\ref{classic_circuit}.\n\n\\begin{figure}[htpb]\n    \\centering\n    \\begin{minipage}{\\textwidth}\n        \\centering\n        \\includegraphics[width=0.6\\textwidth]{Chapter3/figure/classic_circuit.png} % first figure itself\n        \\caption{Circuit schematic of the classic circuit model for describing a comb-drive actuator in electrolytes. It is composed of an oxide capacitor at the boundary, and a parallel resistor/capacitor in the bulk.}\\label{classic_circuit}\n    \\end{minipage}\\vfill\n    \\begin{minipage}{\\textwidth}\n        \\centering\n        \\includegraphics[width=0.8\\textwidth]{Chapter3/figure/leaky_ox_circuit.png} % second figure itself\n        \\caption{Circuit schematic of the leaky circuit model for describing a comb-drive actuator in electrolytes. In this case the boundary is composed of a parallel resistor and capacitor to represent the oxide.}\\label{leaky_ox_circuit}\n    \\end{minipage} \\vfill\n    \\begin{minipage}{\\textwidth}\n        \\centering\n        \\includegraphics[width=0.8\\textwidth]{Chapter3/figure/leaky_ox_stern_circuit.png} % second figure itself\n        \\caption{Circuit schematic of the leaky circuit model for describing a comb-drive actuator in electrolytes. It is similar to the leaky oxide schematic, except a stern layer is placed in series with the oxide resistor/capacitor.}\\label{leaky_ox_stern_circuit}\n    \\end{minipage} \\vfill\n\\end{figure}\n\n\\begin{comment}\n\\begin{figure}[htpb]\n    \\begin{center}\n    \\includegraphics[width=0.7\\linewidth]{Chapter3/figure/classic_circuit.png}\n    \\caption{Circuit schematic of the classic circuit model for describing a comb-drive actuator in electrolytes. It is composed of an oxide capacitor at the boundary, and a parallel resistor/capacitor in the bulk.}\\label{classic_circuit}\n    \\end{center}\n\\end{figure}\n\\end{comment}\n\nThe force, $F$, experienced by a comb-drive actuator in air can be calculated as\n\\begin{equation}\\label{air_force_comb} \nF = kx = \\dfrac{Nb\\epsilon_0}{g}V_{App}^2,\n\\end{equation}\nwhere \\textit{k}, the stiffness of the comb-drive, \\textit{x}, its displacement, \\textit{N}, the total number of comb-pair fingers, \\textit{b}, the comb finger thickness (into the page), and \\textit{g}, the distance between overlapping fingers, are properties of the comb-drive.  $\\epsilon_0$ is the permittivity of free space, and $V_{App}$ is the voltage applied to an overlapping pair of fingers. In this scenario, fringe effects of the comb-drive tip can be ignored. This simplified model is most accurate with sufficient overlap between fingers\\cite{Ye1998}. The classic model constructed by Mukundan et al. and Panchawagh et al. can be expressed by modifying \\ref{air_force_comb} \\cite{MukundanandPonce2009,Panchawagh2009},\n\\begin{equation}\\label{classic_force_comb}  \nF = \\dfrac{Nb\\epsilon_0\\epsilon_W}{g}f(\\omega)V_{AppRMS}^2 = \\dfrac{Nb\\epsilon_0\\epsilon_W}{g}f(\\omega)\\bigg(\\dfrac{V_{App}}{\\sqrt[]{2}}\\bigg)^2,\n\\end{equation}\nwhere $V_{AppRMS}$ is the root-mean-square of the applied voltage, $\\epsilon_W$ is the relative permittivity of water, and $f(\\omega)$ is a function of the applied frequency that is equal to \\cite{MukundanandPonce2009,Panchawagh2009}\n\\begin{equation} \\label{classic_frequency_eqn}\nf(\\omega) = \\bigg|\\dfrac{Z_{Bulk}}{Z_{Bulk}+2*Z_{Interface}(\\omega)}\\bigg| ^2, \\quad Z_{Interface}=Z_{Ox}.\n\\end{equation}\nHere $Z_{Bulk}$ is the impedance of the bulk resistor, and $Z_{Interface}$ the impedance of the interface between the bulk electrolyte and the electrode. In this case, $Z_{Interface}$ is equivalent to $Z_{Ox}$, the impedance of the native oxide capacitor. These impedances are expressed as \n\\begin{equation} \\label{bulk_oxide_impedances}\nZ_{Bulk} = R_{Bulk}, \\quad Z_{Ox} = \\dfrac{1}{j\\omega C_{Ox}}.\n\\end{equation}\nWe note that $C_{Bulk}$ is ignored, because $C_{Ox}$ dominates the capacitive behavior in the range of frequency we consider. From equations \\ref{classic_force_comb}-\\ref{classic_frequency_eqn}, the time-constant that governs the frequency required to overcome ionic shielding, and facilitate actuation, is \\cite{MukundanandPonce2009,Panchawagh2009}\n\\begin{equation} \\label{classic_timeconst}\n\\tau = R_{Bulk}C_{Ox}.\n\\end{equation}\nAt higher concentrations the bulk resistance, $R_{Bulk}$, decreases so higher frequencies of applied voltages are required to overcome shielding, and facilitate actuation. \n\n\\subsection{Assumptions and Validity of Classic Circuit Model}\nThe classic model, while a major breakthrough in modeling electrostatic comb-drive actuators in electrolytes, makes three major assumptions: i) that the native oxide is a pure dielectric, ii) that the ion concentration of the bulk electrolyte is constant, and iii) that the Stern layer can be neglected compared to the oxide layer. Figure \\ref{classic_circuit_fit} shows the displacement of a comb-drive actuator in KCl at concentrations of 0.1 mM, 0.5 mM, and 1 mM respectively. We see that, while the Classic model accurately captures the trend of displacement, it tends to significantly underestimate the displacement in the low frequency region, and overestimate it in the intermediate frequency regions. \n\nIn order to overcome these shortcomings, we develop a hierarchy of novel models that addresses assumptions i)-iii) both individually and in concert. Subsequently, we select the simplest model that explains the comb-drive displacement in electrolytes. The developed models are 1) Leaky Oxide, 2) Leaky Oxide + Stern, 3) Variable Resistor, and 4) Leaky Oxide + Stern + Variable Resistor models. These models, as well as the assumptions of the Classic Circuit model that they address, are listed in Table \\ref{hiearchy_table}. We find that the model which removes assumptions i) and ii) is sufficient to accurately predict the displacement of a comb-drive actuator in electrolytes.\n\n\n\\begin{figure}[htpb]\n    \\begin{center}\n    \\includegraphics[width=0.7\\linewidth]{Chapter3/figure/placeholder.png}\n    \\caption{Placeholder for classic model fit to comb-drive actuator displacement data at 0.1 mM, 0.5 mM, and 1 mM $KCl$ respectively}\\label{classic_circuit_fit}\n    \\end{center}\n\\end{figure}\n\n\\begin{table}[!htb]\n\\begin{center}\n{\\begin{tabular}{|c|c|}\n\t\\hline\n\t\\textbf{Model (i)} & \\textbf{Classic Model} \\\\\n     &  \\textbf{Assumptions Removed} \\\\\n    \\hline\n    Leaky Oxide (1) & i) Pure Dielectric Oxide\\\\\n    \\hline\n    Leaky Oxide  & i) Pure Dielectric Oxide \\\\\n    + Stern (2)    & ii)  No Stern layer \\\\\n    \\hline\n    Variable Resistor (3) & iii) Constant Bulk Resistor \\\\\n    \\hline\n    Leaky Oxide+ & i) Pure Dielectric Oxide\\\\\n    Stern+   & ii)  No Stern layer \\\\\n     Variable Resistor (4) & iii) Constant Bulk Resistor  \\\\\n    \\hline  \n\\end{tabular}}\n\\caption{Hierarchy of models developed in this paper, and the classic circuit model assumptions they address}\\label{hiearchy_table}\n\\end{center}\n\\end{table}\n\n\n\\section{Novel Circuit Models of Comb-drive Actuator in Electrolytes}\nIn this section, we outline the development of the set of models summarized in table \\ref{hiearchy_table}. In order to represent these models, we re-express the frequency dependence of the force on the comb-drive actuator, \\ref{classic_force_comb}, as\n\\begin{equation}\\label{general_red_force_comb}\nF = \\dfrac{Nb\\epsilon_0\\epsilon_W}{g}h_i(\\omega)V_{AppRMS}^2\n\\end{equation}\nwhere $h_i$ is the function of frequency that corresponds to the Leaky Oxide, Leaky Oxide + Stern, Variable Resistor, and Leaky Oxide + Stern + Variable Resistor models (i=1,2,3,4). Explicitly, \n\n\\begin{align}\\label{gen_freq_eqn}\nh_i(\\omega) = \\bigg|\\dfrac{Z_{Bulk}}{Z_{Bulk}+2*Z_i(\\omega)}\\bigg|^2,  i=1,2,3,4,5\n\\end{align}\n\nThe Leaky Oxide and Leaky Oxide + Stern models yield analytical expressions for $h_i$, while the frequency dependence of the Variable Resistor and Leaky Oxide + Stern + Variable Resistor models are evaluated numerically, after solving systems of ordinary differential equations (ODEs). \n \nThe Leaky Oxide and Leaky Oxide + Stern models are created by modifying the interface impedance, $Z_i, i=2,3$. Figures \\ref{classic_circuit}, \\ref{leaky_ox_circuit}, and \\ref{leaky_ox_stern_circuit} shows the circuit model for the Classic, Leaky Oxide, and Leaky Oxide + Stern models. For both the Leaky Oxide, and Leaky Oxide + Stern models, the bulk impedance is a constant value resistor, $Z_{Bulk}=R_{Bulk}$. However, their interface impedances vary. Noting that the leaky oxide and stern layer impedances are \n\n\\begin{equation} \\label{oxide_stern_impedances}\nZ_{Ox} = \\frac{R_{Ox}}{1+j\\omega R_{Ox}C_{Ox}}, \\quad Z_{Stern} = \\frac{1}{j\\omega C_{Stern}},\n\\end{equation}\n\nwe can right the interface impedance of the Leaky Oxide + Stern model, and the Leaky Oxide models as \n\n\\begin{align}\nZ_{LeakyOx}(\\omega) = Z_{Ox}, \\label{leaky_ox_imped} \\\\ \nZ_{LeakyOx+Stern}(\\omega) = Z_{Ox}+ Z_{Stern}  \\label{leaky_ox_stern_imped}. \n\\end{align}\n\nThe Variable Resistor and Leaky Oxide + Stern + Variable resistor models are modifications of the Classic and Leaky Oxide + Stern models respectively. Specifically, both of these models remove the assumption that the bulk resistance is constant, and instead model it as a function of bulk concentration. In addition, these models account add the stern layer, and the nonlinear electric double layer to the interface. We note that it is assumed that the concentration in the bulk changes in a manner that is spatially homogeneous. This yields a system of ODEs of the form,\n\n\\begin{align} \\label{ode_states}\n\\dot{\\mathbf{y}} = f(\\mathbf{y},t,\\omega), \\nonumber\\\\ \\mathbf{y} =[q^*,V_{Ox}^*,V_{St}^*,V_{EDL}^*,V_{Bulk}^*,i^*,c_0^*,R_{Bulk}^*]^T\n\\end{align}\n\nwhere  $q$ is the surface charge on the Electric Double Layer (EDL) capacitor, $V_{Ox}^*$  is the voltage drop across the native oxide, $V_{Stern}^*$ is the voltage drop across the stern layer, $V_{EDL}^*$ is the voltage drop across the EDL, $V_{Bulk}^*$ is the voltage drop across the bulk, $i^*$ is the current, $c_0^*$ is the concentration of the bulk electrolyte, and $R_{Bulk}^*$ is the resistance of the bulk. All of these quantities are dimensionless,  and $V_{Bulk}^*$ is re-dimensionalized to $V_{Bulk}$ when evaluating displacement. The ODEs for the Leaky Oxide + Stern + Variable Resistor model are of the same form as equation (7).\n\nThe main difference between these models is in the modification of $V_{Ox}^*$ to account for the parallel addition of $R_{Ox}$ to $C_{Ox}$, figures \\ref{leaky_ox_circuit}. Unlike for the case of the Leaky Oxide and Leaky Oxide + Stern models, evaluating the functional dependence on force, $h_i(\\omega)$, requires numerical integration. Specifically, we use the RMS integral of $V_{Bulk}$ to obtain\n\n\\begin{align} \\label{numeric_vrms}\nV_{RMS}(\\omega) = \\sqrt[]{\\frac{1}{T} \\int_{0}^{T}V_{Bulk}(\\omega,t)^2dt} = h_i(\\omega)V_{AppRMS},\\nonumber\\\\ i = 3,4\n\\end{align}\n\n\\subsection{ODEs for Numeric Circuit Models}\nWe have introduced abstractly the Variable Resistor, and the Leaky Oxide + Stern + Variable Resistor models. In this section, we enumerate the non-dimensional ODEs that must be solved in order to evaluate these models. For the variable resistor model, the system of ODEs is\n\n\\begin{align}\n\\frac{dq^*}{dt^*} = i^* \\label{charge_state} \\\\\n\\frac{dV^*_{EDL}}{dt^*} = \\frac{i^*}{C_{EDL}^*} \\label{vedl_state} \\\\%\\frac{i}{dq/dV_{EDL}} \\\\\n\\frac{dV^*_{Stern}}{dt^*} = \\frac{i^*}{C_{Stern}^*} \\label{vstern_state} \\\\%\\frac{i}{ \\frac{C_{Stern} \\lambda_{D}}{C_{Water} \\lambda_{Stern}}dq/dV_{0}} \\\\\n\\frac{dV^*_{Ox}}{dt^*} = \\frac{i^*}{C_{Ox}^*} \\label{vox_state} \\\\\n\\frac{dc^*_0}{dt^*} = -2i^*sign(q^*) \\label{concentration_state}\\\\\n\\frac{dR^*_{Bulk}}{dt^*} = \\frac{-1}{2c_{0}^{*2}}\\frac{dc^*_0}{dt^*} \\label{resistor_state}\\\\\n\\frac{dV^*_{Bulk}}{dt^*} = \\frac{di^*}{dt^*}R^*_{Bulk} + i^*\\frac{dR^*_{Bulk}}{dt^*}\\label{vbulk_state}  \\\\ \n\\frac{di^*}{dt^*} = \\frac{\\bigg(\\frac{dV^*_{Bulk}}{dt^*}-2\\frac{d}{dt^*}V^*_{INT}-i^*\\frac{dR^*_{Bulk}}{dt^*}\\bigg)}{R^*_{Bulk}} \\label{current_state} \n\\end{align}\nwhere \n\\begin{equation}\n    V^*_{INT}  = V^*_{EDL}+V^*_{Stern}+V^*_{Ox}   \n\\end{equation}\n and each state has been defined in the paragraph following \\ref{ode_states}. $C_0$ is the dimensionless linear differential capacitance of the electric double layer, \\ref{lin_diff_cap}, and $C_{EDL}$ is the dimensionless nonlinear differential capacitance of the electric double layer which is expressed as\n\\begin{equation} \\label{edl_nonlinear}\nC_{EDL} = C_{0} cosh\\bigg(\\frac{V^*_{EDL}}{2}\\bigg).\n\\end{equation}\n\nWe note four things. First, the differential equation for the bulk resistor, $R_{Bulk}^*$ is obtained by taking a time derivative of the bulk resistance expressed in \\ref{bulk_resist_volt}. Second, with the exception of the $C_{EDL}^*$, the non-dimensional capacitance of circuit element $l$, $C_l^*$, is \n\n\\begin{equation}\n    C_l^* = \\bigg(\\frac{C_{l} \\lambda_{D}}{C_{Bulk} \\lambda_{l}}C_0\\bigg)\n\\end{equation}\nwhere $C_{l}$ is the dimensional capacitance of the circuit element, $C_{Bulk}=\\frac{\\epsilon_W}{g}$ is the capacitance of the bulk which is assumed to be calculated based on the relative permitivitty of water, $\\lambda_{l}$ is the thickness of the physical layer represented by circuit element $l$, and $\\lambda_{D}$ is the debye lenght. Third, the voltages in this system are where non-dimensionalized using the thermal voltage, $V_T$. Finally, the voltage, $V_{l}$, bulk resistor, $R_{Bulk}^*$, capacitances, $C_l^*$, and time $t^*$ are the only parts of the ODE that are explicitly non-dimensionalized. The non-dimensional charge and current fall out of solving the ODEs with these quantities.\n\nThe system of ODEs for the Leaky Oxide + Stern + Variable Resistor model is identical to that of the Variable Resistor model, with the exception of a modification to \\ref{vox_state} which is rewritten as\n\\begin{align} \\label{vox_state_leakoxstern}\n\\frac{dV^*_{Ox}}{dt^*} = \\frac{i^* - V^*_{Ox}/R^*_{Ox}}{C^*_{Ox}};\n\\end{align}\n\n\\section{Neglected Effects of Novel Models}\nUp until this point, we have neglected two key effects in the development of our models. The first is the depletion layer that can develop in doped silicon, and the second is the formation of concentration gradients in the bulk electrolyte. We describe both of these effects in this section, and justify their explicit absence from our models. \n\n\\subsection{Depletion Layer Formation}\nThe silicon wafers used to fabricate the comb-drive actuators are p-type boron-doped to 0.008-0.01 \\textOmega $\\textrm{ }cm$. When a voltage is applied to the comb-drive, the resulting external electric field causes charge carriers to collect at the interface of the silicon and native oxide. This region is called the depletion layer, and can also be approximated as a capacitor. The relative importance of this capacitance, compared to other circuit elements in our models, is determined by the width of the depletion layer. We perform a scaling analysis in order to determine the importance of this depletion layer.\n\nFigure \\ref{depletion_layer} depicts the depletion layer in series with the native oxide and Stern layers, as well as the bulk electrolyte, for a single comb-drive finger. The analysis detailed in this section assumes that the native oxide is a pure dielectric, and makes use of dimensional quantities. We write Poisson's equation for the depletion layer as\n\\begin{equation}\n\\frac{d^2\\phi}{dx^2} = -\\frac{dE}{dx} = -\\frac{e}{\\varepsilon_{Si}}(n_+ - n_- + N_d), \\quad -x_d \\leq x \\leq 0\n\\end{equation}\nwhere $n_+$ and $n_-$ are positive and negative free charge carrier concentrations respectively, and $N_d$ is the concentration of the positive dopant. We solve for the electric field, assuming that there are no free charge carriers in the depletion layer.\n\\begin{equation} \nE(x) = \\frac{eN_d(x+x_d)}{\\varepsilon_{Si}}.\n\\end{equation}\nWe next require that the electric field be continuous at the interface of the native oxide and the depletion layer, $x=0$. and solve for the depletion layer width, $x_d$.\n\n\\begin{figure}[htpb]\n    \\begin{center}\n    \\includegraphics[width=0.7\\linewidth]{Chapter3/figure/depletion_layer.png}\n    \\caption{Illustration of one finger in a pair of comb-drive fingers. It depicts the Silicon substrate, the depletion layer, the native oxide, the Stern Layer, and the bulk electrolyte.}\\label{depletion_layer}\n    \\end{center}\n\\end{figure}\n% \\begin{equation}\n% E(x=0) = \\frac{eN_dx_d}{\\varepsilon_{Si}} = \\frac{V_{Ox}}{t_{Ox}}.\n% \\end{equation}\n% Re-writing equation (52) allows us to write the depletion layer width as\n\\begin{equation}\nx_d = \\frac{\\varepsilon_{Si}}{t_{Ox}}\\frac{V_{Ox}}{eN_{d}}.\n\\end{equation}\nIf we use the nominal values of the physical parameters in equation (51), shown in \\ref{table_phys_param_nomvals}, then the depletion layer width is \n\\begin{equation}\nx_d = 3 \\times 10^{-8} V_{Ox}.\n\\end{equation}\nWe know that $V_{Ox}$ is at most O(1), so we can approximate the minimum capacitance of the depletion layer as\n\\begin{equation}\nC_{D} \\approx \\frac{\\varepsilon_0 \\varepsilon_{Si}}{x_d} = 0.0034 \n\\end{equation}\n\n\\begin{table}[!htb]\n\\begin{center}\n{\\begin{tabular}{|c|c|}\n\t\\hline\n\t\\textbf{Physical Parameters} & \\textbf{Nominal Values} \\\\\n    \\hline\n    $\\varepsilon_{Si}$ & 11.68 \\\\\n    \\hline \n    $t_{Ox}$ & 2 $nm$ \\\\\n    \\hline\n    $N_d$  & $10^{25} m^{-3}$  \\\\\n    \\hline\n\\end{tabular}}\n\\caption{Nominal values of physical parameters used for approximated the width of the depletion layer.}\\label{table_phys_param_nomvals}\n%\\begin{flushleft} \n%Table III: \n%\\end{flushleft} \n\\end{center}\n\\end{table} \n\nSince the nominal capacitance of the Stern and native oxide layers are O(0.1) and O(0.01) respectively, it is clear that the effects of the depletion layer capacitance is significant. While this is relevant for conceptualizing the physical system, explicitly modeling the depletion layer does not impact the ability of our reduced models to fit the data. The models presented in this chapter are lumped circuit models, rather than spatial models. As a result, the depletion layer capacitance, which is in series with the Stern or oxide layer capacitance depending on the model, can be lumped in with the capacitance of these layers. When these models are fit, the resulting value of the Stern and oxide capacitance  should be viewed as compensating for both these respective layers and the Depletion layer.\n\n\\subsection{Concentration Gradients}\nThe variable resistor models described in the previous section assumes that the concentration of the electrolytes changes uniformly across the bulk electrolyte, i.e. that the concentration has no gradients. While this is not generally true, the impact of concentration gradients is only relevant when large low-frequency voltages are applied to the bulk. In the case of the comb-drives fabricated for this paper, we postulated that the impedance of the native oxide at low frequencies was sufficiently high enough to prevent this. We confirm in the next chapter that, in the context of our current devices, the variable resistor models that account for concentration gradients fit the data identically to our models that assume uniform concentration. For the sake of completeness, we illustrate here how we account for concentration gradients in our variable resistor model. This derivation is derived based on the work of Bazant et al \\cite{Bazant2004}.\n\nBazant et al. used matched asymptotics to derive expressions for the change in the concentration of a \\textit{z:z} electrolyte. They first expressed the dimensionless concentration in the bulk as\n\\begin{equation} \\label{concentration_asympt}\nc^* = c_+^* + c_-^* = 2c_0^* + \\gamma c_1^*\n\\end{equation}\nwhere $c_1^*$ accounts for the variation in the bulk concentration, and $\\gamma$ is as defined in \\ref{lin_diff_cap}. The time derivative of the the bulk concentration is then\n\\begin{equation} \\label{dcdt_asympt}\n\\frac{dc^*}{dt^*} = \\gamma \\frac{dc_1^*}{dt^*} = \\gamma \\frac{d^2c_1^*}{dx^{*2}},\n\\end{equation}\nwith the boundary condition\n\\begin{equation} \\label{dcdt_asympt_bc}\n\\frac{dc_1^*}{dx^*}(x=0,t) = -2 sinh\\bigg(\\frac{V_{EDL}^*}{2}\\bigg) \\frac{dV_{EDL}^*}{dt^*}.\n\\end{equation}\nIn order to account for the concentration gradient, we replace \\ref{concentration_state} with \\ref{dcdt_asympt} and \\ref{dcdt_asympt_bc}. We finally replace $R_{Bulk}^*$ and $\\frac{dR_{Bulk}^*}{dt^*}$ with\n\\begin{equation}\nR_{Bulk}^* = \\frac{1}{c^*},\n\\end{equation}\n\nand \n\n\\begin{equation}\n\\frac{dR_{Bulk}^*}{dt^*} = \\int_{0}^{g^*} \\frac{-1}{c^{*2}}\\frac{dc^*}{dt^*}dx^*.\n\\end{equation}\nrespectively.\n\n\\section{Chapter Review and Further Work}\nIn this chapter, we justified the use of a circuit model to describe the behavior of electrolytes between parallel plates using the PNP equations, detailed the classic circuit model that falls out of this circuit model, as well as the assumptions behind this model, and presented a hierarchy of models that addressed the assumptions of the classic circuit model. Moreover, we noted important effects neglected by our reduced models, and stated that, as will be shown in chapter 4, that these had no impact on describing the comb-drive actuators in electrolytes that were fabricated for this dissertation.\n\nIn the future, it would be useful to numerically, and experimentally, explore how changes in the parallel plate system, especially the thickness of the native oxide, would impact the importance of effects neglected by our model.", "meta": {"hexsha": "c4be22d7b820f592f7f01fb2b120645170b24f35", "size": 30711, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "odibua/thesisnstuff", "max_stars_repo_head_hexsha": "86322a040cb27d6af5c8dfbbb636ef380a468ed4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "odibua/thesisnstuff", "max_issues_repo_head_hexsha": "86322a040cb27d6af5c8dfbbb636ef380a468ed4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "odibua/thesisnstuff", "max_forks_repo_head_hexsha": "86322a040cb27d6af5c8dfbbb636ef380a468ed4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 87.4957264957, "max_line_length": 954, "alphanum_fraction": 0.741493276, "num_tokens": 8814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4074158665820999}}
{"text": "\\subsection{Feature Engineering}\r\n\r\nDespite the variables provided by original data, we construct some new variables to improve model performance. As we are trying to forecast whether it would precipitate in the next day, the temperature difference in each day could be important. Rain is formatted by condensation of water in air, higher temperature could contribute to evaporation of water and lower temperature may lead to condensation. Therefore, the temperature differences could be useful in predicting precipitation. \r\n\r\nWith TMAX (Max temperature in the day) and TMIN in the original data, we construct TDIF = TMAX - TMIN to measure the temperature difference each day. By looking into TDIF in different days we find some interesting phenomena. The overall TDIF is significantly larger in summer than in winter, which can be seen from the range of TDIF in Figure \\ref{tdif}. It is also interesting that TDIF at mountain areas is higher than downtown areas in summer, and right the opposite in winter. Those two phenomena indicate the existence of a seasonal pattern in TDIF, and this could be the same for PRCP.\r\n\r\n\\begin{figure}[h]\r\n\\centering\r\n\\begin{minipage}[t]{0.48\\textwidth}\r\n\\centering\r\n\\includegraphics[width=6cm]{tdif1.png}\r\n\\end{minipage}\r\n\\begin{minipage}[t]{0.48\\textwidth}\r\n\\centering\r\n\\includegraphics[width=6cm]{tdif2.png}\r\n\\end{minipage}\r\n\\caption{Stations with TDIF Records}\r\n\\label{tdif}\r\n\\end{figure}", "meta": {"hexsha": "725d6b7b7e8b724db17f8117e40ae6ed65dba0f6", "size": 1428, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Report/feature.tex", "max_stars_repo_name": "shengchenHAO/Weather-Forecast-", "max_stars_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Report/feature.tex", "max_issues_repo_name": "shengchenHAO/Weather-Forecast-", "max_issues_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Report/feature.tex", "max_forks_repo_name": "shengchenHAO/Weather-Forecast-", "max_forks_repo_head_hexsha": "0c81dd5b8b3c4572464b0e0b841ca279ecb0d650", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.1578947368, "max_line_length": 592, "alphanum_fraction": 0.7913165266, "num_tokens": 336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.4074158624346259}}
{"text": "\\chapter{Background}\\label{cha:background}\n\nThe following chapter lays the theoretical groundwork for the project. An understanding of linear algebra, numerical optimization, algorithms, and statistics is assumed. \\Cref{sec:back_mathprog,sec:back_bnb,ssec:back_mlp} are adapted from the project report \\textit{Multi-Layer Perceptrons for Branching in Mixed-Integer Linear Programming} (2020). \n\n\n\\section{Mathematical Programming}\\label{sec:back_mathprog}\n\nThis section presents the field of \\textit{mathematical programming} at the level relevant for understanding the thesis.\nIn this work, the terms mathematical programming, numerical optimization, and optimization are used interchangeably. The differences between these stem largely from the different communities who use them. The section will first cover the topic of linear programming (\\gls{LP}), then the topic of mixed-integer linear programming (\\gls{MILP}), and lastly a section on computational complexity.  \n\n\n\\subsection{Linear Programming}\n\nIn mathematical programming, the general linear problem can be stated as \\cite{gasse2019exact}:\n\\begin{align} \\label{eq:lp}\n    \\underset{\\mathbf{x}}{\\arg \\min }\\left\\{\\mathbf{c}^{\\top} \\mathbf{x} \\; \\mid \\mathbf{A} \\mathbf{x} \\leq \\mathbf{b},\\; \\mathbf{x} \\in \\mathbb{R}_+^{n}\\right\\},\n\\end{align}\nwhere $ \\mathbf{x} \\in \\mathbb{R}_+^n$ is the variable vector\nwith the objective coefficient vector $\\mathbf{c} \\in \\mathbb{R}^n $, \nthe constraint coefficient matrix $\\mathbf{A} \\in \\mathbb{R}^{m \\times n}$\nand the constraint right-hand-side vector $\\mathbf{b} \\in \\mathbb{R}^m $.\n\nThe size of the problem will be measured by the dimensions of the constraint coefficient matrix $ \\mathbf{A} $, where the number of rows and columns corresponds to the number of variables and constraints, respectively.\n\nThese problems are convex \\cite{wolsey2020integer}, and can be solved by several efficient algorithms. The simplex algorithm can solve problems on this form efficiently, and the same for interior-point methods \\cite{nocedal2006numerical}. These algorithms are good average performance but do not have guaranteed polynomial running time in the worst case. Guaranteed polynomial solution algorithms do exist, for instance \\textit{Karamkar's algorithm} \\cite{karamkar1984new}. \n\n\n\\subsection{Mixed Integer Linear Programming}\n\nMixed integer linear programming is a superset of linear programming, where one or more of the variables can be restricted to discrete values. The general problem can in this case be stated as \\cite{gasse2019exact}:\n\\begin{align}\\label{eq:milp}\n    \\underset{\\mathbf{x}}{\\arg \\min }\\left\\{\\mathbf{c}^{\\top} \\mathbf{x} \\mid \\mathbf{A} \\mathbf{x} \\leq \\mathbf{b}, \\; \\mathbf{x} \\in \\mathbb{Z}_+^{p} \\times \\mathbb{R}_+^{n-p}\\right\\},\n\\end{align}\nwhere $ p $ is the number of integer variables, otherwise the variables are the same as \\Cref{eq:lp}.\n\n% https://texample.net/tikz/examples/colored-diagram/\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture}[\n        thick,scale=0.5, \n        every node/.style={scale=0.2}\n        every path/.style = {},\n        every node/.append style = {font=\\sffamily}\n      ]\n      \\begin{scope}\n        \\shade[right color=gray, left color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (0,6.5);\n        \\node[rotate=90, above] at (0,3) {};\n        \\shade[top color=gray, bottom color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (8.5,0);\n        \\shade[left color=gray, bottom color=gray, right color=white, opacity=0.5]\n          (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;\n        \\path (-0.5,5.5) -- node[pos=0.23, sloped, above] {}\n          (8.5,3);\n        \\shade[left color=gray, right color=white, opacity=0.5]\n          (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;\n        \\path (5,0) -- node[pos=0.3, sloped, above] {} (2.5,6.5);\n        \\node[text width=6em, align=center] at (2,2)\n          {};\n        \\draw[->] (-0.5,0) -- (8.5,0) node[below] {x};\n        \\draw[->] (0,-0.5) -- (0,6.5) node[above] {y};\n        \\node[rotate=-45, above, text width=9em, align=center] at (7.25,5.25)\n          {};\n        \\path[clip] (-0.5,-0.5) rectangle (8.5,6.5);\n        \\foreach \\i in {0.5,3,...,13} {\n          \\draw[help lines] (-0.5,\\i) -- +(-45:15);\n        }\n      \\end{scope}\n      \\draw[very thick, ->] (9,3.25) -- node[above, text width=3cm, align=center]\n        {} (11.5,3.25);\n      \\begin{scope}[shift={(13,0)}]\n        \\shade[right color=gray, left color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (0,6.5);\n        \\shade[top color=gray, bottom color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (8.5,0);\n        \\shade[left color=gray, bottom color=gray, right color=white, opacity=0.5]\n          (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;\n       \\shade[left color=gray, right color=gray, opacity=0.5]\n         (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;\n        \\draw[->] (-0.5,0) -- (8.5,0) node[below] {x};\n        \\draw[->] (0,-0.5) -- (0,6.5) node[above] {y};\n        \\foreach \\i in {0,1,...,6.5} {\n          \\draw[help lines] (-0.5,\\i) -- (8.5,\\i);\n        }\n        \\foreach \\i in {2,4,...,8.5} {\n          \\draw[help lines] (\\i,6.5) -- (\\i,-0.5);\n        }\n        \\foreach \\i in {0,1,...,5} {\n          \\node[draw,cross out,label={left:\\i}] at (0,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,4} {\n          \\node[draw,cross out] at (2,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,2} {\n                \\node[draw,cross out] at (4,\\i) {};\n        }\n        \\foreach \\i in {0,2,...,6} {\n          \\node[below] at (\\i,0) {\\pgfmathparse{int(\\i/2)}\\pgfmathresult};\n        }\n      \\end{scope}\n    \\end{tikzpicture}\n    \\caption{Illustration of an \\Gls{LP} with its corresponding \\Gls{ILP}, i.e. the \\gls{LP} with integrality constraints.}\n    \\label{fig:milpfig}\n\\end{figure}\n\nIn \\Cref{fig:milpfig}, an \\gls{LP} problem and the problem with \\textit{integrality constraints} is shown. For the \\gls{LP} problem, the shaded areas represent the inequality constraints, where the diagonal lines represent the level curves of the objective function. In the \\gls{ILP} problem, the crosses represent the feasible solutions. The \\gls{LP} is also called a \\textit{relaxation} of the original \\gls{ILP}, which is fundamental to efficient solving algorithms of \\gls{MILP} problems.\n\nA problem that includes integrality constraints cannot be convex \\cite{wolsey2020integer}. The non-convexity of the feasible set of the problem constitutes a significant challenge, and it is considered unlikely that polynomial-time solutions exist \\cite{papadimitriou1982combinatorial}. \\gls{MILP} problems belong to the category of $\\mathcal{NP}$-hard problems \\cite{papadimitriou1982combinatorial} (this class of problems will be discussed in \\Cref{ssec:complexity}).   \n\nA subset of \\gls{MILP} problems can be integer linear programming (\\gls{ILP}), where all variables are restricted to integer values, or binary linear programming (\\gls{BLP}), where all variables are restricted to binary values. \n\n\\gls{ILP} and \\gls{BLP} problems belong to the category of \\textit{combinatorial optimization} (\\gls{CO}) problems, which has been the main focus of the efforts to solve entirely or partially with machine learning methods \\cite{bengio2020machine}. \n\n\n\n\n\\subsection{Computational Complexity}\\label{ssec:complexity}\n\nA basic understanding of computational complexity is required to justify the nature of the algorithms used to solve \\gls{MILP} problems. \n\nProblems can be divided into \\textit{classes} by the nature of the algorithms that can solve these problems. Problems for which there exist algorithms that can solve the problem in a time that is \\textit{polynomial} of the problem size belong to class $\\mathcal{P}$. Problems to which a correct solution can be verified in polynomial time belong to the class $\\mathcal{NP}$ (non-deterministic polynomial time) \\cite{cormen2009introduction}. \n\n\nTwo other central complexity classes in this context are the $\\mathcal{NP}$-complete and $\\mathcal{NP}$-hard classes. The $\\mathcal{NP}$-complete class contains problems that can be \\textit{reduced} to any other problem in the $\\mathcal{NP}$-complete class in polynomial time. \nThe $\\mathcal{NP}$-hard class contains problems that are at least as hard as the problems in the $\\mathcal{NP}$-complete group but has not been proved to be reducible to a $\\mathcal{NP}$-complete problem. An illustration showing this is given in \\Cref{fig:np}. The general \\gls{MILP} belongs to the $\\mathcal{NP}$-hard class, and some \\gls{MILP}s have been shown to belong to the $\\mathcal{NP}$-complete class \\cite{cormen2009introduction}. \n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.4\\linewidth]{img/npc.png}\n    \\caption{\\label{fig:np}Illustration of the most commonly held view of the P, NP, NPC, and NP-hard relationship. Adapted from Cormen et al. (2009) \\cite{cormen2009introduction}.}\n\\end{figure}\n\nAs stated, it is considered unlikely that \\gls{MILP} problems can be solved in polynomial time. Therefore, it is more fruitful to improve upon the best existing solution algorithms and evaluating the improvements on practical problems. As the improvements attempted by substituting variable selection algorithms do not affect the running time complexity of the \\gls{BnB} algorithm, this will not be discussed.  \n\n\n\n\n\n\n\n\n\n\n\\section{Branch and Bound}\\label{sec:back_bnb}\n\nA \\textit{relaxation} of a \\gls{MILP} problem is achieved by relaxing the integrality constraint, as shown in \\Cref{fig:milpfig}. Obtaining the solution to the relaxed problem gives a lower bound on the optimal solution (for a minimization problem). Naturally, any feasible solution to the integrality-constrained problem gives an upper bound to the solution. Furthermore, if the solution to the relaxed problem adheres to the integrality constraints, it is also the solution to the \\gls{MILP} problem \\cite{wolsey2020integer}.\n\n\n\n\n\n\nThe most prevalent solution algorithm for \\gls{MILP} problems exploits these results, by sequentially dividing the solution space until the optimum with the integrality constraint is found. This is done by branching in a binary tree structure according to \\cite{gasse2019exact}:\n\\begin{align} \\label{eq:branch}\n    x_{i} \\leq\\left\\lfloor x_{i}^{\\star}\\right\\rfloor \\vee x_{i} \\geq\\left\\lceil x_{i}^{\\star}\\right\\rceil, \\quad \\exists \\; i \\leq p \\mid x_{i}^{\\star} \\notin \\mathbb{Z}    \n\\end{align}\nFurther creating sub-problems with this binary decomposition. A general algorithm for this process is presented in \\Cref{alg:bnb}, and an illustration of this process is shown in \\Cref{fig:bandb1}.\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\KwResult{Optimal point and solution value of given problem.}\n    Set $L = \\{X\\}$ and initialize $\\hat{x}$\\; \n    \\While{$L \\neq \\emptyset $}{\n        Select a subproblem $S$ from $L$ to explore\\;\n        \\If{a solution $\\hat{x}_* \\in \\{x \\in S \\;|\\; f(x) < f(\\hat{x})\\}$ can be found}{\n            Set $\\hat{x} = \\hat{x}_*$\\;\n        }\n        \\If{$S$ cannot be pruned}{\n            Partition $S$ into $\\{S_1, S_2 ..., S_r\\}$\\;\n            Insert $\\{S_1, S_2 ..., S_r\\}$ into $L$\\;\n        }\n        Remove  $S$ from $L$\\;\n    }\n    Return $\\hat{x}$\\;\n    \\caption{\\label{alg:bnb} A generic branch-and-bound algorithm \\cite{morrison2016branch}.}\n\\end{algorithm}\n\n%https://tex.stackexchange.com/questions/416359/branch-and-bound-tree-in-tikz\n\\comments{\n\\begin{figure}\n\\centering\n\\begin{forest}\n  branch and bound,\n  where level=1{\n    set branch labels={x\\leq}{}{x\\geq}{},\n  }{\n    if level=2{\n      set branch labels={}{\\geq y}{}{\\leq y},\n    }{},\n  }\n  [1055.56:S:950\n    [1000:S_1:950:5\n    ]\n    [1033:S_2:950:6\n      [1033:{S_2,1}:950:1]\n      [950:{S_2,2}:1033:2]\n    ]\n  ]\n\\end{forest}\n\\caption{\\label{fig:bandb1}Illustration of the branch and bound algorithm}\n\\end{figure}}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{img/bnb.png}\n    \\caption{\\label{fig:bandb1}Illustration of the branch-and-bound algorithm adapted from a maximization problem in \\textit{Integer Programming }(2020) \\cite{wolsey2020integer}.}\n\\end{figure}\n\nFor each generated solution, represented by nodes in \\Cref{fig:bandb1}, a relaxation of the problem is solved in order to obtain an upper and lower bound on the solution of the sub-problem. \nThese values are shown on the top and bottom right, respectively. \nGenerating upper and lower bounds for solutions allows for discarding a large number of solutions \\cite{wolsey2020integer}. Branches can be \\textit{pruned} (meaning no further partitioning from that branch) if they meet at least one of the following three criteria \\cite{wolsey2020integer}:\n\\newpage\n\\begin{enumerate}[label=(\\roman*)]\n    \\item Pruning by optimality: $Z^t = \\{\\max \\bm{c}^{\\top} \\bm{x} : \\bm{x} \\in S_t\\}$ has been solved.\n    \\item Pruning by bound: $\\overline{Z}^t \\leq \\underline{Z}^t$.\n    \\item Pruning by infeasiblity: $S_t = \\emptyset $.\n\\end{enumerate}\nFor \\Cref{fig:bandb1}, the graph on the right represents the tree after solving the relaxation, resulting in $S_2$ being pruned by infeasibility, $S_3$ pruned by bound, and $S_4$ pruned by optimality.\n\n\nThe choice of node and variable to branch on to find the optimum in the fewest number of branching processes is central to an efficient implementation of \\gls{BnB}. Partitioning the feasible set such that the node with the optimal value is found in the fewest possible branching iterations is the optimal policy. \n\n\n\\subsection{Valid Inequalities}\\label{ssec:inequalities}\n\nAnother important method used in \\gls{BnB} algorithms is the concept of valid inequalities. A valid inequality is an inequality that does not remove feasible solutions of the non-convex solution set but can remove potential solutions to the relaxed problems. A valid inequality can be expressed as:\n\\begin{equation}\\label{eq:cut}\n    \\bm{\\pi}^{\\top} \\mathbf{x} \\leq \\pi_0 \\quad \\forall \\; \\mathbf{x} \\in  \\bm{X}   \n\\end{equation}\nwhere $\\bm{X}$ is the feasible set as described in \\Cref{eq:milp}. These inequalities reduce the size of the feasible set for the relaxations of the problem without removing feasible solutions of the original problem. An illustration of an \\gls{ILP} with an added valid inequality is shown in \\Cref{fig:cut}. Here the feasible set of the relaxation is reduced in size by the added constraint, while the feasible points of the \\gls{ILP} remain feasible after the application of the inequality, as is given in \\Cref{eq:cut}.\n\n\\begin{figure}\n    \\centering\n    \\begin{tikzpicture}[\n        thick,scale=0.5, \n        every node/.style={scale=0.2}\n        every path/.style = {},\n        every node/.append style = {font=\\sffamily}\n      ]\n      \\begin{scope}\n        \\shade[right color=gray, left color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (0,6.5);\n        \\shade[top color=gray, bottom color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (8.5,0);\n        \\shade[left color=gray, bottom color=gray, right color=white, opacity=0.5]\n          (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;\n       \\shade[left color=gray, right color=gray, opacity=0.5]\n         (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;\n        \\draw[->] (-0.5,0) -- (8.5,0) node[below] {x};\n        \\draw[->] (0,-0.5) -- (0,6.5) node[above] {y};\n        \\foreach \\i in {0,1,...,6.5} {\n          \\draw[help lines] (-0.5,\\i) -- (8.5,\\i);\n        }\n        \\foreach \\i in {2,4,...,8.5} {\n          \\draw[help lines] (\\i,6.5) -- (\\i,-0.5);\n        }\n        \\foreach \\i in {0,1,...,5} {\n          \\node[draw,cross out] at (0,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,4} {\n          \\node[draw,cross out] at (2,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,2} {\n                \\node[draw,cross out] at (4,\\i) {};\n        }\n      \\end{scope}\n      \\draw[very thick, ->] (9,3.25) -- node[above, text width=3cm, align=center]\n        {} (11.5,3.25);\n      \\begin{scope}[shift={(13,0)}]\n        \\shade[right color=gray, left color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (0,6.5);\n        \\shade[top color=gray, bottom color=white, opacity=0.7]\n          (-0.5,-0.5) rectangle (8.5,0);\n        \\shade[left color=gray, bottom color=gray, right color=white, opacity=0.5]\n          (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;\n        \\shade[left color=gray, right color=gray, opacity=0.5]\n          (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;\n        \\shade[left color=gray, right color=gray, opacity=0.5]\n          (0.0,6.5) -- (8.5,6.5) -- (8.5,0) -- (6.0,0) -- cycle;\n        \\draw[->] (-0.5,0) -- (8.5,0) node[below] {x};\n        \\draw[->] (0,-0.5) -- (0,6.5) node[above] {y};\n        \\foreach \\i in {0,1,...,6.5} {\n          \\draw[help lines] (-0.5,\\i) -- (8.5,\\i);\n        }\n        \\foreach \\i in {2,4,...,8.5} {\n          \\draw[help lines] (\\i,6.5) -- (\\i,-0.5);\n        }\n        \\foreach \\i in {0,1,...,5} {\n          \\node[draw,cross out] at (0,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,4} {\n          \\node[draw,cross out] at (2,\\i) {};\n        }\n        \\foreach \\i in {0,1,...,2} {\n                \\node[draw,cross out] at (4,\\i) {};\n        }\n      \\end{scope}\n    \\end{tikzpicture}\n    \\caption{Figure of an \\Gls{ILP} before and after an added valid inequality.}\n    \\label{fig:cut}\n\\end{figure}\n \n\n\nAlgorithms that find these inequalities during the \\gls{BnB} algorithm are called \\textit{branch-and-cut}. The nomenclature comes from calling the application of these inequalities \\textit{cuts} or \\textit{cutting planes}.\nWhen an application of inequalities are only employed on the root node (before dividing the solution space in the enumeration), the algorithm is sometimes referred to as \\textit{cut-and-branch} rather than \\textit{branch-and-cut} \\cite{wolsey2020integer}.\n\n\n\n\n\n\n\\subsection{Primal and Dual Heuristics}\n\nThe modern implementations of \\gls{BnB} solvers base their efficiency on the implementation of \\textit{heuristics} \\cite{khalil2020towards}, which are divided into the classes \\textit{primal} and \\textit{dual}. Heuristic is synonymous with \"human-designed rule\" in this context.\n\n\\textit{Primal heuristics} are methods for finding feasible solutions at a given \\gls{BnB} node, where the quality, i.e. the distance to the optimal bound, is the determining factor to whether the feasible solution is useful or not \\cite{khalil2020towards}. These heuristics are as costly as they are useful, and modern solvers periodically run different heuristics at different times during the solution process \\cite{khalil2020towards}.\n\n\\textit{Dual heuristics} are the methods that find the lower bound of the optimization problem. This includes solution of relaxations of the problem as well as the addition of valid inequalities. \n\nThe relationship is summarized in this quote from Khalil (2020) \\cite{khalil2020towards}:\n\\begin{quote}\n    [...] the\nprimal side refers to the quest for good feasible solutions, whereas the dual side refers to\nthe search for a proof of optimality.\n\\end{quote}\n\n\n\n\n\n\n\\subsection{Branching Variable Selection Policy}\\label{ssec:branchingpolicy}\n\nAs mentioned, an important decision in the \\gls{BnB} algorithm is the choice of the variable that should be branched on. \nThere exists many heuristics for solving this, who vary in computational complexity and accuracy. \nA good branching algorithm should choose to branch on variables that lead to small solution trees (fewer nodes evaluated) and find these variables in a computationally efficient manner. \n\nAll popular variable selection policies depend on scoring the candidate branching variables, expressed as $s_i \\in \\mathbb{R}^1 \\; \\forall \\: i \\in \\mathcal{C}$, and then selecting the variable with the most optimal score \\cite{achterberg2004branching}. The branching operation generates two child nodes, $Q_i^-$ and $Q_i^+$. The branching candidate comparison is done by comparing the two objective function changes of each candidate, denoted as $\\Delta_i^- \\coloneqq \\bar{c}_{Q_i^-}-\\bar{c}_{Q}$ and $\\Delta_i^+ \\coloneqq \\bar{c}_{Q_i^+}-\\bar{c}_{Q}$ \\cite{achterberg2004branching}. The final score is then typically calculated by a function similar to \\cite{achterberg2004branching}:\n\\begin{equation}\n    score(q^- , q^+ ) = (1 - \\mu) \\cdot \\min \\{q^- , q^+ \\} + \\mu \\cdot \\max \\{q^- , q^+ \\}\\:,\\quad \\mu \\in \\left[0, 1\\right]    \n\\end{equation}\n\n\n\nThe current branching policy resulting in the smallest solution trees is known as \\textit{strong branching} (\\gls{SB}) \\cite{applegate1995finding}, and the application of this branching policy at every node is known as \\textit{full strong branching} (\\gls{FSB}) \\cite{achterberg2004branching}. This branching policy is based on determining the best variable to branch on by solving the relaxation for every candidate variable, and is therefore very computationally expensive compared to other methods \\cite{achterberg2004branching}.\n\nAnother branching policy is \\textit{most infeasible branching} (\\gls{MIB}), where the variable with the fractional part of the relaxation optimum closest to $0.5$ is selected. This policy, though computationally inexpensive, has proved to be very poor \\cite{achterberg2004branching}. \n \nAn effective and popular policy is \\textit{pseudo-cost branching} (\\gls{PC}), which relies on the expected change in objective value based on previous branching on the variable in question\n\\cite{achterberg2004branching}. In short, the objective gain per unit change in a variable is averaged over all nodes where it has been branched upon. This value is termed the \\textit{pseudo-cost} of the variable. As is evident, these values depend on a history of branching, and will therefore be inaccurate for the first decisions \\cite{achterberg2004branching}. \n\nThe policy known as \\textit{reliability pseudo-cost branching} (\\gls{RPC}) aims to mitigate the inaccuracy of the \\gls{PC} algorithm by combining \\gls{SB} and \\gls{PC} \\cite{anand2017comparative}. In \\gls{RPC}, \\gls{SB} is employed for variables that are either uninitialized (never branched on before) or have \\textit{unreliable} pseudo-costs (pseudo-costs that stem from little data) \\cite{achterberg2004branching}. This policy is the standard of the \\gls{SCIP} optimization suite \\cite{achterberg2009scip}. \n\nIn the literature, the branching policy is referred to as a policy, strategy, or rule. In this thesis \\textit{policy} is used.  \n\n\n\n\n\n\n\n\n\\subsection{Learned Branching Policy}\n\nRecently, attempts have been made to find a branching policy based on statistical learning. \n\nUsing machine learning, specifically imitation learning, to find good candidate variables for branching in a less computationally demanding manner was proposed by Elias Khalil \\cite{khalil2016learning}. Various methods for learning in branching include \\textit{ support vector machine ranking} (\\Gls{SVM}) \\cite{khalil2016learning}, \\textit{graph convolutional neural networks} (\\gls{GCNN}) \\cite{gasse2019exact} and \\textit{feature-wise linear modulation} (\\gls{FiLM}) \\cite{gupta2020hybrid}.\n\nThe fundamental assumption to this approach is that a computationally efficient approximation to the most computationally demanding but most accurate branching policy can be learned. The algorithm will use imitation learning on the branching expert to find a computationally less expensive non-linear function approximation to the expert algorithm's variable scoring. Then, the algorithm branches on the variable with the highest score. \n%This can be expressed as: \n%\\begin{align}\n%    f(i) &=  \\pi_{SB} (i) + \\epsilon \\quad \\forall \\; i \\in \\mathcal{C}\\\\\n%    f(i) &= s_i\\\\\n%    i^*_f &= \\underset{i \\in \\mathcal{C}}{\\mathrm{argmin}} \\; \\bm{s}_i\n%\\end{align}\n%where $f$ is the learned function, $\\mathcal{C}$ is the set of possible branching variables, $\\pi_{SB}$ is the Strong Branching strategy and $\\epsilon$ is the deviation in the scoring function. \n\n\n\n\n\\section{Markov Decision Processes}\\label{sec:back_mdp}\n\nThis section presents the \\textit{Markov decision process} formulation of the variable selection problem. \n\n\n\\subsection{Markov Decision Processes Formulation}\\label{ssec:mdp}\n\nCentral to the advancement of learned policies in \\gls{BnB} is the interpretation of the solution algorithm as an \\textit{agent} in a \\textit{Markov decision process} (\\gls{MDP}) \\cite{gasse2019exact}. This interpretation relates the problem to a large collection of literature on the topic \\cite{howard1960dynamic}.\n\nIn an \\gls{MDP}, the agent is at time $t$ in a state $\\mathcal{S}_t$, from which it performs an action $\\mathcal{A}_t$ that transforms the agent to the state $\\mathcal{S}_{t+1}$ and receives the \\textit{reward} $\\mathcal{R}_{t+1}$ \\cite{prouvost2021ecole}. The probability of an agent performing action $a$ in state $s$ is given as $\\pi (a | s)$. The probability distribution for the agent to transition to a new state $s'$ is given as $\\mathbb{P}(s', r | a, s)$ \\cite{prouvost2021ecole}. \n\n \nA sequence of actions generates a sequence of trajectories $\\tau$, and is described as an \\textit{episode}. The probability of a trajectory is given in Prouvost et al. (2021) \\cite{prouvost2020ecole} as:\n\\begin{equation}\n    \\mathbb{P}(\\tau) \\sim \\underbrace{\\mathbb{P}(\\mathcal{S}_0)}_{\\text{initial state}}\n\\prod_{t=0}^\\infty \\underbrace{\\pi(\\mathcal{A}_t | \\mathcal{S}_t)}_{\\text{next action}}\n\\underbrace{\\mathbb{P}(\\mathcal{S}_{t+1}, \\mathcal{R}_{t+1} | \\mathcal{A}_t, \\mathcal{S}_t)}_{\\text{next state}}\n\\end{equation}\n\nThese definitions now allow a formulation of the \\gls{MDP} control problem, which is the problem of interest in this thesis. The control problem consists of finding the action policy that maximizes the reward. %, and can be stated as: \n%\\cite{prouvost2020ecole}\n%\\begin{equation}\\label{eq:mdprcontrol}\n%    \\pi^\\star = \\underset{\\pi}{\\operatorname{arg\\,max}}\n%\\lim_{T \\to \\infty} \\mathbb{E}_\\tau\\left[\\sum_{t=0}^{T} %\\mathcal{R}(\\mathcal{S}_t)\\right]\n%\\end{equation}\n\n\n\n\\subsection{Partially-observable Markov Decision Processes}\n\nA subset or generalization of an \\gls{MDP} is the \\textit{partially-observable Markov decision process }(\\gls{PO-MDP}) \\cite{monahan1982state}. Processes of this class allow for uncertainty of the states as well as additional acquisition of state information \\cite{monahan1982state}. The agent will therefore decide actions based on the observation of the state, given as $\\mathcal{O}$ \\cite{prouvost2021ecole}. All past observations of the observations, rewards and actions are given in the history $\\mathcal{H}_t$, given as \\cite{prouvost2021ecole}:\n\\begin{equation}\n    \\mathcal{H}_t = \\{\\mathcal{O}(\\mathcal{S}_0), \\mathcal{R}(S_0), \\mathcal{A}_0, ..., \\mathcal{O}(\\mathcal{S}_{t-1}), \\mathcal{R}(S_{t-1}), \\mathcal{A}_{t-1}, \\mathcal{O}(\\mathcal{S}_t)\\}\n\\end{equation}\nThe generalization from \\gls{MDP} to \\gls{PO-MDP} concedes the Markovian nature of the trajectories \\cite{prouvost2020ecole}.\n\nIn addition, the initial state is given by the distribution of the problem instance $I$, giving the relation $\\mathbb{P}(\\mathcal{S}_0) = \\mathbb{P}(I) \\mathbb{P}(\\mathcal{S}_0 | I)  $ \\cite{prouvost2021ecole}. \n\nThis results in the final formulation \\cite{prouvost2021ecole}:\n\\begin{equation}\n    \\mathbb{P}(\\tau) \\sim \\underbrace{ \\mathbb{P}(I) \\mathbb{P}(\\mathcal{S}_0 | I)  }_{\\text{initial state}}\n\\prod_{t=0}^\\infty \\underbrace{\\pi(\\mathcal{A}_t | \\mathcal{H}_t)}_{\\text{next action}}\n\\underbrace{\\mathbb{P}(\\mathcal{S}_{t+1}, \\mathcal{R}_{t+1} | \\mathcal{A}_t, \\mathcal{S}_t)}_{\\text{next state}}\n\\end{equation}\n\nAn illustration of the Markov decision process control loop from the documentation of \\gls{Ecole} is shown in \\Cref{fig:mdp}.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.55\\linewidth]{img/mdp.png}\n    \\caption{Illustration of the Markov decision process control loop. Figure from Prouvost et al. (2021) \\cite{prouvost2021ecole}.}\n    \\label{fig:mdp}\n\\end{figure}\n\n\n\n\\subsection{Branch \\& Bound as a PO-MDP}\\label{ssec:pomdp}\n\nInterpreted in the language of \\gls{MDP}s, the \\gls{BnB} algorithm is the \\textit{environment} and a concrete \\gls{MILP} problem instance is an \\textit{episode} in this environment. The \\textit{agent} is the brancher, where in this thesis the variable selection policy is the component of interest, ignoring the node selection policy. The state of the solver consists of the \\gls{BnB} tree at that instance, as well as the observations at each node (the \\textit{history} of the \\gls{PO-MDP}).\n\nThis formulation is the basis for the \\textit{Ecole} framework, which is discussed in \\Cref{ssec:ecole}\nThe \\gls{PO-MDP} formulation allows for the agent in the \\gls{BnB} environment to be learned through reinforcement learning, discussed in \\Cref{ssec:back_rl}.\n\n\n\n\\subsection{Branch \\& Bound Observation}\\label{ssec:obs}\n\nA prerequisite for learning in \\gls{BnB} is the observation of the state of the episode, i.e. the state of the solver of an instance at a specific node in the solution tree. \n\n%Little attention towards these features are found in the major publications in this field (\\cite{gasse2019exact,gupta2020hybrid}), however the observation is the foundation of the learning process.\n%\\textit{Learning to Branch} by Khalil et al. (2016) \\cite{khalil2016learning} contains multiple additional features, however these will not be discussed in this thesis. \n\nThe features of a \\gls{BnB} node are divided into three classes: variable features, constraint features and edge features.\n\n\n\\textbf{Variable Features}\n\nFor a candidate branching variable, relevant features include the type of the variable (binary, integer, etc.), whether the variable has a defined lower and/or upper bound, and whether the solution is at at either of these bounds.  \nIf not, the variable has a fractionality that represents the solution of the relaxed problem.\nAt the solution node, the incumbent has a value that can be compared to incumbents at other nodes, as well as the relative impact of the variable on the objective value in the incumbent. \nThe variable also has a state with respect to the solution of the relaxation with a simplex solution algorithm --- if the variable is a basic or non-basic variable or other information relating to this solution.\nPresented in Khalil et al. (2016) \\cite{khalil2016learning} are also a number of other features that will not be utilized in this work.\n\n\n\n\n\\textbf{Constraint Features}\n\nThe cosine similarity represents a coefficient of the angle between the variable and the constraint.   \nThe bias of the constraint is also included. \nAn additional feature is whether the variable is at the constraint in the relaxation\nEach constraint also has a value from the solution of the dual problem. \n\n\n\\textbf{Edge Features}\n\nThe edge features consist of the constraint coefficient, meaning the coefficient that is multiplied with the candidate variable. This will also give the relations between constraints and variables.\n\n\n\n\n\\subsection{Bipartite Graph Representation}\n\nThe application of \\gls{GCNN}s on \\gls{MILP} and sub-\\gls{MILP} problems rely on the bipartite representation of constraints and variables as presented in Gasse et al. (2019) \\cite{gasse2019exact}.\nThis concept will be introduced with an example \\gls{MILP} given as:\n\\begin{align}\\label{eq:bipex}\n    \\min \\quad &\\texttt{v}_1 + \\texttt{v}_2 + \\texttt{v}_3\\\\ \n    s.t. \\quad &\\texttt{v}_1 + \\texttt{v}_2 - \\texttt{v}_3 \\geq 1 \\qquad (c_1)\\nonumber\\\\\n    &\\texttt{v}_3 \\geq \\frac{1}{2}\\qquad\\qquad\\quad\\;\\,\\; (c_2)\\nonumber\\\\\n    &\\mathbf{v} \\in \\mathbb{B}^3 \\nonumber\n\\end{align}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.40\\linewidth]{img/bipartite_zoom.png}\n    \\caption{Example of a bipartite constraint-variable graph.}\n    \\label{fig:bipartite_cv}\n\\end{figure}\n\nFor \\Cref{eq:bipex}, the corresponding constraint-variable graph representation can be illustrated as in\n\\Cref{fig:bipartite_cv}.\n\nConstraints and variables are the numbered nodes of the graphs, while the edges represent the relation between the nodes. \n\n\n\n\\section{Machine Learning Models}\\label{sec:back_models}\n\n\nThe \\gls{ML}-models used in the thesis are presented in this section. First the multi-layer perceptron and graph convolutional neural network models, then the concepts of \\textit{ablation studies} and \\textit{reinforcement learning}.\n\n\\subsection{Multi-layer Perceptrons}\\label{ssec:back_mlp}\n\nMulti-layer perceptrons (\\gls{MLP}s), more commonly known as deep feed-forward neural networks, are recommended by Gupta et al. (2020) \\cite{gupta2020hybrid} as a less computationally expensive alternative to the approaches by Khalil et al. (2016) \\cite{khalil2016learning} and Gasse et al. (2019) \\cite{gasse2019exact}. \n\n\\gls{MLP}s are networks that generate a nonlinear function $y = f(\\mathbf{x}; \\bm{\\theta})$, where $x$ is the input, $y$ is the output, and $\\bm{\\theta}$ represents the parameters of the function. The parameters are learned during repeated optimization, and will under ideal circumstances converge to approach the optimal function $y = f^*(\\mathbf{x})$. The function is realized as a series of compositions of functions. The composed functions are represented as an acyclical, directed graph \\cite{nielsen2018neural}, and can be expressed as:\n\\begin{align}\n    y = f_L \\circ f_{L-1} \\circ \\ldots \\circ f_{1} \\circ f_{0} (\\mathbf{x})  \n\\end{align}\nThe functions are denoted as \\textit{layers} of the perceptron, and are implemented as affine functions of every input parameter at every node, $\\mathbf{z}_l = \\mathbf{x}_{l-1}^T \\mathbf{w}_l + \\mathbf{b}_l$. Applying non-linear function, known as an \\textit{activation function}, allows the \\gls{MLP} to represent arbitrary nonlinear functions \\cite{goodfellow2016deep}. This is expressed as $\\mathbf{x}_l = \\mathbf{a}(\\mathbf{z}_l)$.\n\nThe computation of the output of the function given its input is known as a \\textit{forward pass} through the network. The required computations for a single input vector into a network with $ n $ hidden layers will include $ n + 1 $ matrix multiplications and $ n + 1 $ applications of the non-linear activation function, given that there is an activation function on the output. \n\n%Depending on the training configuration, the problem can be interpreted as a classification problem or regression problem (or a ranking problem, as in \\cite{khalil2016learning}). In the following experiments, the former approach is selected, as has become popular after Gasse et al. (2019) \\cite{gasse2019exact}. \n\n\n\n\n\n\n\n\n\n\n\\subsection{Graph Convolutional Neural Networks }\n\nGraph convolutional neural network (\\gls{GCNN}) is a term for neural networks that have input data represented in a graph-structure that is processed by a convolution operation \\cite{kipf2016semisupervised}. In this thesis, the terms \\gls{GCNN} and \\gls{GNN} will be used interchangeably. \n\nThe fundamental property of the graph convolution is its ability to create representations of irregular data without altering the structure of the data. This means that, for instance, nodes that share vertices can pass information to each other, so the feature representation of a node can utilize the features of neighboring nodes.  \nAn illustration of this using the bipartite graph from \\Cref{fig:bipartite_cv} is given in \\Cref{fig:conv_ex}. The features of the nodes are transformed while maintaining the structure of the graph.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{img/conv_example.png}\n    \\caption{Example of a graph convolution on a bipartite constraint-variable graph.}\n    \\label{fig:conv_ex}\n\\end{figure}\n\nA graph convolution can be expressed as a matrix/tensor multiplication followed by a nonlinear activation function, as in \\Cref{sec:back_mdp}. This will be explained in the case of a undirected graph for the sake of simplicity. A prerequisite for this is the representation of the graph with the adjacency matrix, denoted as $\\Tilde{\\mathbf{A}}$. The adjacency matrix is a square $|\\mathbf{V}|\\times|\\mathbf{V}|$ matrix containing 0 or 1 depending on whether the pair of vertices are connected or not \\cite{kipf2016semisupervised}. In addition the adjacency matrix, the degree matrix $\\Tilde{\\mathbf{D}} = \\sum_j \\Tilde{\\mathbf{A}}_{i j}$ is necessary in order to normalize the operation \\cite{kipf2016semisupervised}.\n\nWith the given definitions, the graph convolution operation can be expressed by the propagation rule \\cite{kipf2016semisupervised}:\n\\begin{equation}\n    \\mathbf{H}^{(l+1)} = a \\left( \\Tilde{\\mathbf{D}}^{-\\frac{1}{2}} \\Tilde{\\mathbf{A}} \\Tilde{\\mathbf{D}}^{-\\frac{1}{2}} \\mathbf{H}^{(l)}\\mathbf{W}^{(l)}\\right)\n\\end{equation}\nwhere $\\mathbf{H}^{(l)}$ is the matrix of activations in layer $l$, with the first layer $\\mathbf{H}^{0}=\\mathbf{X}$.  $\\mathbf{W}^{(l)}$ is a layer of learned weights. $a( \\cdot) $ is a nonlinear activation function.\nThis operation is inspired by the first-order approximations to spectral filters on graphs \\cite{kipf2016semisupervised}.\n\n\n\n\n\nModels that leverage the graph nature of combinatorial optimization problems have been shown to have satisfactory performance, see e.g. Dai et al. (2018) \\cite{dai2018learning}. \n\\gls{GCNN}s are proposed by Gasse et al. (2019) \\cite{gasse2019exact} as an alternative to the feature-rich approaches by Khalil et al. (2016) \\cite{khalil2016learning}. \nThe application of \\gls{GCNN}s on \\gls{BnB} algorithms rely on the bipartite constraint-variable representation at each node of the \\gls{BnB} solution tree.\n\n\nThe term \\textit{embeddings} will be used in this thesis for continuous-variable representations derived from the input features, as it is used in Gasse et al. (2019) \\cite{gasse2019exact}. \n\n\nThe state of the \\gls{BnB} graph at a node can be represented as $s_t = (\\mathcal{G}, \\mathbf{C}, \\mathbf{E}, \\mathbf{V})$, where $\\mathcal{G}$ represents the bipartite \\gls{BnB} solution graph at that time instance, $\\mathbf{C}$ represents the constraints, $\\mathbf{E}$ represents the \\textit{edges} (connections) between the variables and constraints, and $\\mathbf{V}$ represents candidate variables.  \n\nGasse et al. (2019) \\cite{gasse2019exact} presents three motivating points for why graph convolutions would be a good architecture for learning to branch:\n\\begin{enumerate}[label=(\\roman*)]\n    \\item They are well-defined no matter the input graph size.\n    \\item Their computational complexity is directly related\nto the density of the graph, which makes it an ideal choice for processing typically sparse \\gls{MILP}\nproblems.\n    \\item They are permutation-invariant, that is they will always produce the same output no\nmatter the order in which the nodes are presented.\n\\end{enumerate}\n\n\n\n\n\n\n\\subsection{Ablation Studies}\n\nThe concept of ablation studies in machine learning, as presented in \nMeyes et al. (2019) \\cite{meyes2019ablation} is presented in this section.\nAblation studies hail from the field of neuroscience, in which a complex system, e.g. the brain, is examined after removing different sections. The function of the removed sections can then be inferred by the change in the observed reaction to external stimuli \\cite{meyes2019ablation}.\n\nIn the context of \\gls{ML}, ablation studies are a formalization of observing changes in performance after the removal of components of artificial neural networks \\cite{meyes2019ablation}.  \nThe concept, or at least the formalization, is not yet considered a standard method in \\gls{ML} research \\cite{sheikholeslami2019ablation}.\nIn this thesis, the concept of an ablation study will be interpreted more broadly than in Meyes et al. (2019) \\cite{meyes2019ablation}, as the networks in this thesis are retrained after each section is removed. This form of ablation study is coined as \\textit{model ablation} in Sheikholeslami (2019) \\cite{sheikholeslami2019ablation}.\n\n\n\n\n\n\\subsection{Reinforcement Learning}\\label{ssec:back_rl}\n\nThe subset of machine learning described as \\textit{reinforcement learning} (\\gls{RL}) is highly relevant in the context of \\gls{ML} in \\gls{CO}. No results will be discussed in this thesis, however, a background in the topic is necessary to understand both related work and the long-term goals of the field.\n\n\\gls{RL} encompasses the problem of an \\textit{agent} learning a \\textit{policy} for behaving in an \\textit{environment} so as to achieve a global objective. Any sequential decision-making problem with a measure of optimality that relies on past experience can be formulated as a \\gls{RL} problem \\cite{francois2018introduction}. The approach has seen success in a number of fields in the past years with the integration of deep learning models, often termed deep \\gls{RL} \\cite{francois2018introduction}. Most notable of the advancements might be AlphaZero, Google's successful chess-AI \\cite{silver2017mastering}. \\gls{RL} has the important property of being independent of data, meaning a number of core \\gls{ML} challenges (quantity, quality, and bias of data) are rendered irrelevant \\cite{goodfellow2016deep}. \n\n%\\gls{RL} is particularly interesting in \\gls{BnB} because of the \\gls{MDP} nature of the algorithm, and the assumption that the handcrafted heuristics and sub-algorithms prevalent in modern solvers are either inefficient or inaccurate compared to the theoretical capabilities of, i.e. neural networks. \n\nMany attempts have been made at implementing \\gls{RL} in \\gls{CO}, see for example Etheve et al. (2020) \\cite{etheve2020reinforcement} or Tang et al. (2020) \\cite{tang2020reinforcement}. Approaches for learning variable selection, such as reported in Scavuzzo (2020) \\cite{scavuzzo2020learning}, rely on efficient and accurate pre-trained models based on imitation learning, like the models presented in this thesis. More knowledge is likely needed for the pure \\gls{RL} approach to take over the mantle. Recently,\nCappart et al. (2021) \\cite{cappart2021combinatorial} also concluded that useful \\gls{RL} policies are not mature yet. \n", "meta": {"hexsha": "52b9af5687bc874d79ea39724eb4a20ba1c16dfe", "size": 41949, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/12-background.tex", "max_stars_repo_name": "Sandbergo/master-thesis", "max_stars_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-25T10:42:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-25T10:42:49.000Z", "max_issues_repo_path": "tex/12-background.tex", "max_issues_repo_name": "Sandbergo/master-thesis", "max_issues_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/12-background.tex", "max_forks_repo_name": "Sandbergo/master-thesis", "max_forks_repo_head_hexsha": "6da60d22b4423b4f4ca961cec55090e88ca109eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.4323001631, "max_line_length": 816, "alphanum_fraction": 0.723020811, "num_tokens": 11983, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.4072060266339286}}
{"text": "% !TeX root = ../Thermostats.tex\n\\subsection{Andersen}\n\nThe Andersen thermostat was first introduced by Hans Andersen in 1980 \\cite{Andersen1}.\nIt yields the correct velocity distribution by connecting the system to an external heat bath with the corresponding temperature T.\nAt every time step each particle has a probability $P=\\nu\\cdot\\Delta t$ --- with $\\nu$ the stochastic collision frequency --- to undergo a collision with the heat bath and thus change its momentum. These collisions are instantaneous and affect only the particle involved.\nThe new momentum of the particle after a collision is drawn at random from a Boltzmann distribution of the given temperature.\nBecause only a small, random number of particles are affected at each time step, most of the particles move freely according to the Hamiltonian. But the encounters with the heat bath are enough to relax the system to the given temperature and to let the kinetic energy fluctuate around its equilibrium according to the canonical ensemble.\n\nThe Andersen thermostat should only be applied to time-independent properties, dynamic problems should not be thermostated by an Andersen algorithm \\cite{Andersen2}.\n\n\\subsection{Lowe--Andersen}\nThe Lowe-Andersen thermostat is a Galilean invariant and momentum conserving analogue of the Andersen thermostat \\cite{LoweAndersen}.\nThe collisions with the heat bath now affect a pair of particles, and only the relative velocity along the centre of mass changes. The relative velocity $v_{ij}$ from the Maxwell-Boltzmann distribution is calculated with the equation:\n\\begin{equation}\nv_{ij}'=\\zeta\\sqrt{2k_BT},\n\\end{equation}\nwith $\\zeta$ being a random number drawn from a normal distribution with unit variance and zero mean.\nThe relative velocity of the particles after the collision is then adjusted according to\n\\begin{align}\n2\\Delta_{ij}&=r_{ij}\\left[(v_{ij}'-v_{ij})\\bullet r_{ij}\\right]\\\\\nv_i'&=v_i+\\Delta_{ij}\\\\\nv_j'&=v_j-\\Delta{ij}.\\\\\n\\end{align}\n", "meta": {"hexsha": "9dc1ef35db75d423b06bd142bf472a1cdb0ade43", "size": 1968, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Protokolle/Thermostaten/sections/patrick.tex", "max_stars_repo_name": "oerpli/ComputationalPhysics", "max_stars_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Protokolle/Thermostaten/sections/patrick.tex", "max_issues_repo_name": "oerpli/ComputationalPhysics", "max_issues_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Protokolle/Thermostaten/sections/patrick.tex", "max_forks_repo_name": "oerpli/ComputationalPhysics", "max_forks_repo_head_hexsha": "5081c46c01d078fe7b86601919a3447294304d8d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.72, "max_line_length": 338, "alphanum_fraction": 0.7952235772, "num_tokens": 446, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4072060192544206}}
{"text": "\\subsection{Chinese anti-leverage}\n\nFigure~\\ref{fig:rhos} summarises the results by plotting the posterior densities of $\\rho$ obtained from all the model fits.\nEven though not all companies behave the same way, there is a consistent picture in general about the differences between the two countries.\nThe chart shows that, based on the chosen sample, $\\rho$ is really estimated to be larger in China than in Germany, except for the periods containing the crisis, when it was similar.\n\nThe claims about China behaving differently are underpinned by Figure~\\ref{fig:negative-rhos}, which shows the number of companies with a significant leverage or anti-leverage effect.\nWe define significance at the 5\\% level in this master thesis, i.e.\\ significant leverage means that the 95\\% quantile of $\\rho$'s posterior is negative, while significant anti-leverage means that the 5\\% quantile of $\\rho$'s posterior is positive.\nInterestingly, Germany had the least number of companies with significant leverage effect in the period that just preceded the crisis, which was followed by a steep increase into the crisis.\nApart from the periods containing the boom phase of the Subprime Crisis or touching the European Debt Crisis, the figure for Germany is quite stable around 6 to 7.\nNone of the German stocks had a significantly positive $\\rho$.\n\nThe picture is much less consistent about China.\nIgnoring periods with only one significant value, the leverage effect is only present under the crisis of 2007, with some delay compared to Germany, and only in 3 stocks at most.\nSimilarly, anti-leverage is hardly observed, only before the crisis.\nStill, the companies show some consistency, since there is no period with both leverage and anti-leverage effect being present.\n\n\\comment{\nNote that the exact distribution or point estimates of $\\rho$ are not of high interest.\nOn the one hand, it is not the correlation of returns with variance changes but with log variance changes, which makes it more difficult to interpret.\nOn the other hand, comparison with correlation values obtained from other models in the literature is also not trivial, so across models only the sign and highly extreme values are interesting.\n}\n\n\\subsection{Time-varying leverage}\n\nFigures~\\ref{fig:rhos} and~\\ref{fig:negative-rhos} suggest that leverage is not constant, even its sign varies.\nThe charts show that correlation shifts to the negative direction throughout the crisis, which is consistent with recent literature~\\citep{Christensen2015}.\nIt seems to hold especially for the Chinese stocks since the German companies are more stably on the negative side throughout the whole time.\n\nFigure~\\ref{fig:company-rhos} shows how the posterior of $\\rho$ changes for each company with the rolling window of periods.\nThe German stocks are on the bottom half of the chart, they have a significant leverage effect in general since the crisis.\nThey show a quite consistent picture, the 95\\% quantile is negative for the vast majority of estimates.\nBMW and SAP show a steadily strengthening leverage effect, while it stagnates or weakens for the others.\nIf we accept that the leverage effect is stronger in crises~\\citep{Christensen2015}, then the increasing $\\rho$ in 8 out of the 10 German companies signals the end of the impact of recent crises.\n\nThe posterior $\\rho$ developed far more hectically for the Chinese companies.\nHowever, they all had the negative extremum of the posteriors around the first half of 2008, at the strongest impact of the crisis.\nHowever, the overall picture is unstable throughout the whole examined time, which questions the reliability of the results from the perspective of~\\citet{Christensen2015}.\nThere might be far more and substantially different factors in play that affect Chinese stocks' leverage effect.\n\n\\subsection{Volatility estimations}\n\nThe posterior of $\\phi$ and of the log variance are presented in Figure~\\ref{fig:persistence} on a chosen subset of periods and companies that represent the whole dataset.\nThe prior of $\\phi$ is taken to be informative, it reflects the empirical fact of highly autocorrelating volatility.\nThe posterior of $\\phi$ mainly depends on its prior and the estimate for $\\bm h$.\nHence, if the posterior is significantly different from the prior, that means that there is valuable information in $\\bm h$ about $\\phi$.\n\nAn immediately noticeable phenomenon in Figure~\\ref{fig:persistence} is that the posterior of $\\phi$ varies more for the German firms.\nMore precisely, throughout the crisis and in its short aftermath, the volatility of the German stocks was substantially more persistent than in the other periods.\nAt the same time, changes in the persistence of the Chinese companies can not be explained by the crisis periods, and the estimates are more stable and closer to the prior, except for the highly persistent 2010-2012 period of 600016 CH Equity.\nOne can also spot the differences on the log variance timeline: the time series are close to a constant value plus noise in China, containing little information about persistence.\nIn Germany, on the other hand, clusters of increasing and decreasing trends can be observed around the crisis.\n\n\\begin{figure}[p]\n\t\\vspace*{-3.2cm}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{../calculations/rhos.pdf}\n\t\\caption[Visually summarising the results]{Visually summarising the results. Each blue box corresponds to a country and a period and contains 10 rows. One row corresponds to one stock. Each row is a heatmap of $\\rho$'s posterior density estimated for that company and period. The red line is constant 0. The stocks' rows are ordered according to their posterior mean in the first period.}\n\t\\label{fig:rhos}\n\\end{figure}\n\n\\begin{figure}[p]\n\t\\vspace*{-3.2cm}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{../calculations/negative-rhos.pdf}\n\t\\includegraphics[width=\\linewidth]{../calculations/positive-rhos.pdf}\n\t\\caption[Significant leverage effect]{Top: number of companies with significant leverage effect per country and period, on a 5\\% level. Bottom: number of companies with significant anti-leverage effect per country and period, on a 5\\% level. Both: Only every second period is shown for readability.}\n\t\\label{fig:negative-rhos}\n\\end{figure}\n\n\\begin{figure}[p]\n\t\\vspace*{-3.2cm}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{../calculations/rho-timeline.pdf}\n\t\\caption[Timeline of posterior $\\rho$]{Posterior distributions of $\\rho$ in time. The prior distribution is the uniform distribution on $[-1,1]$ in all cases.}\n\t\\label{fig:company-rhos}\n\\end{figure}\n\n\\begin{figure}[p]\n\t\\vspace*{-3.2cm}\n\t\\centering\n\t\\includegraphics[width=\\linewidth]{../calculations/phi-timeline.pdf}\n\t\\includegraphics[width=\\linewidth]{../calculations/volatility.pdf}\n\t\\caption[Timeline of persistence and volatility]{Top: posterior persistence of the log variance for a subset of companies and periods. Bottom: posterior log variance for a subset of the companies. The time series are glued together from the independent volatility estimations from several periods.}\n\t\\label{fig:persistence}\n\\end{figure}\n", "meta": {"hexsha": "7a336891ea63b085927d64ead1eb7f30b3652940", "size": 7098, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/sections/results.tex", "max_stars_repo_name": "hdarjus/master-thesis", "max_stars_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-23T12:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-23T12:51:22.000Z", "max_issues_repo_path": "thesis/sections/results.tex", "max_issues_repo_name": "hdarjus/master-thesis-WU", "max_issues_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/sections/results.tex", "max_forks_repo_name": "hdarjus/master-thesis-WU", "max_forks_repo_head_hexsha": "1b0f4699dc49cb7bc5442214cf7901333afcd38a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-12T00:39:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-12T00:39:19.000Z", "avg_line_length": 81.5862068966, "max_line_length": 389, "alphanum_fraction": 0.7952944491, "num_tokens": 1576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4072060192544206}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{amssymb}\n\\begin{document}\n\n\\newcommand{\\PiL}{\\textsc{\\textbf{Pi}}}\n\\newcommand{\\PiCalc}{\\PiL${}^\\equiv$}\n\\newcommand{\\PiCat}{\\ensuremath{\\Pi\\mathbb{C}}}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Goal} \n\nOur first major milestone is (i) to develop \\emph{a sound and complete\n  calculus of permutations over finite sets}, (ii) to define, in that\nsetting, a variant of \\emph{univalence} that has a computational\ncontent, and to \\emph{prove} this univalence property. In the longer\nterm, we will want to generalize this framework to sets with negative\nand fractional cardinalities which would effectively give us (at\nleast) higher-order functions. One can in fact go further and consider\nsets with more general cardinalities: imaginary numbers, irrational\nnumbers, all the way to algebraic numbers.\n\nTo reach the first major milestone, our detailed steps are:\n\\begin{itemize}\n\n\\item to develop a \\emph{syntactic notion of permutations over finite\n    sets}. We achieve this by defining a typed programming language\n  \\PiL\\ whose types denote finite sets and whose expressions denote\n  permutations over finite sets. This language has been completely\n  developed: its syntax, type system, and operational semantics are\n  well-understood;\n\n\\item to develop a \\emph{calculus \\PiCalc\\ for reasoning about \\PiL\\\n    permutations}. We eventually want to prove that this calculus is\n  sound and complete with respect to a semantic notion of permutation\n  equivalence;\n\n\\item to develop a \\emph{semantic notion of equivalence of\n    permutations over finite sets}.  To make the connections to HoTT\n  more evident, we formalize this equivalence using a category\n  (groupoid actually) of finite sets and permutations \\PiCat\\ which we\n  establish is \\emph{rig category}, i.e., it has two symmetric\n  monoidal structures with the multiplicative one distributing over\n  the additive one. The objects of this category are discrete\n  groupoids representing finite sets; the morphisms of \\PiCat\\ are\n  permutations over the finite sets; the complete definition of the\n  category also needs an equivalence relation that specifies when two\n  morphisms should be considered equal. This equivalence relation is\n  our notion of semantic equivalence of permutations over finite\n  sets. The advantage of using the categorical setting to define the\n  semantic notion of equivalence is that the coherence laws for rig\n  categories provide us with an axiomatization of semantic equivalence\n  of permutations that is rich enough to reason about sequential\n  compositions of permutations (given by the plain categorical\n  structure), parallel compositions of permutations (given by the\n  additive monoidal structure), and tensor compositions of\n  permutations (given by the multiplicative monoidal structure) while\n  taking care of all the induced equivalences that result from the\n  interactions among these structures. \n\n\\item to derive the complete definition of \\PiCalc\\ by reifying each\n  of the primitives used in defining semantic equivalence as syntactic\n  objects; a proof of soundness and completeness is then immediate as\n  the syntactic and semantic structures are isomorphic by construction.\n\n\\item to define a variant of univalence in the current setting we\n  reason as follows. In the HoTT setting, which is not limited to\n  finite sets and permutations, we have a larger category of arbitrary\n  sets and with equivalences as morphisms. Univalence in that context\n  postulates that each equivalence between sets induces a path between\n  these sets. Translated to our setting, univalence postulates that\n  each semantic equivalence between sets induces a syntactic\n  equivalence between these sets. In the richer setting of HoTT,\n  univalence is postulated because there is no obvious way to reason\n  about extensional equivalence of the functions used to define\n  semantic equivalences. In our setting, these semantic equivalences\n  are defined using permutations which are amenable to equational\n  reasoning via the coherence laws. Therefore to make univalence\n  constructive, all we need is a computational mechanism to calculate\n  a syntactic equivalence from a semantic one. This mechanism is\n  embedded in the proof of completeness above. \n\n\\item Our complete development is formalized in Agda. \n\\end{itemize}\n\nWhich still leaves open one big question: is our main representation\nof permutations _fin~_ or CPerm ?  Or do we need both, as one is\n'syntactic' (through the use of vectors) while the other is more\nabstract (as it uses functions)?\n\nI am quite sure that all the work needed to bring FinEquivCat all the\nway to RigCategory is feasible, and not too hard [but will be\nenlightening].\n\nTo do the same with CPermCat (and SkFinSetCategory) will be a fair bit\nharder.  So it is very important for us to decide what the exact path\nwe want to take.  [Which is indeed what your outline is about!]\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Basic Utilities}\n\n\\paragraph*{LeqLemmas.} A few lemmas about natural numbers. \n\n\\paragraph*{FinNatLemmas.} A few lemmas about $\\texttt{Fin}~n$ which\nare the numbers used to index into vectors.\n\n\\paragraph*{SubstLemmas.} A few lemmas about compositions of\npropositional equalities..\n\n\\paragraph*{VectorLemmas.} A few lemmas about vectors, lookups,\nmapping functions over vectors, etc.\n\n\\paragraph*{FiniteFunctions.} Proves extensionality for finite functions. \n\n\\paragraph*{Proofs.} Collects all the above and re-exports them along\nwith a couple of other general utilities for managing Agda proofs.\n\n\\paragraph*{DivModUtils.} External library for reasoning about\nuniqueness of \\texttt{divMod}. This is used extensively to mediate\nbetween $\\texttt{Fin}~(m*n)$ and\n$\\texttt{Fin}~m \\times \\texttt{Fin}~n$.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Structures}\n\n\\paragraph*{SetoidUtils.} Any discrete type $A$ can be viewed as a\nsetoid with propositional equality $\\equiv$ as the equivalence\nrelation.\n\n\\paragraph*{Groupoid.} A definition of 1-groupoids and operations on \nthem. \n\n\\paragraph*{Categories.Everything.} Basic and some advanced category theory.\n\n\\paragraph*{SymmetricMonoidalCategory.} A definition of symmetric\nmonoidal categories.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Equivalences} \n\n\\paragraph*{Equiv.} Defines extensional equivalence of functions\n$\\sim$ and shows that it is an equivalence relation. Defines\nequivalence between sets $\\simeq$ using two functions that go back and\nforth and whose compositions are extensionally equivalent to the\nidentity, and shows that this equivalence is indeed an equivalence\nrelation. Finally shows that equivalences are injective and form a\ncongruence that respects $\\uplus$ and $\\times$. \n\n\\paragraph*{TypeEquiv.} Establishes that the Agda types $\\bot$,\n$\\top$, $\\uplus$, and $\\times$ form a commutative semiring using\n$\\simeq$ as the underlying equivalence relation.\n\n\\paragraph*{FinEquiv.} Establishes that $\\texttt{Fin}~n$ also forms a\ncommutative semiring with $\\simeq$ as the underlying equivalence\nrelation. In particular, we have:\n\\[\\begin{array}{rcll}\n\\texttt{Fin}~0 &\\simeq& \\bot \\\\\n\\texttt{Fin}~1 &\\simeq& \\top \\\\\n\\texttt{Fin}~(m+n) &\\simeq& \\texttt{Fin}~m \\uplus \\texttt{Fin}~n \\\\\n\\texttt{Fin}~(m*n) &\\simeq& \\texttt{Fin}~m \\times \\texttt{Fin}~n\n\\end{array}\\]\nand then we have all the commutative semiring axioms, e.g.,\n$\\texttt{Fin}~(0+m) \\simeq \\texttt{Fin}~m$. The actual proof says that\n0, 1, $+$, and $*$ for a commutative semiring structure under the\nequivalence that equates $m$ and $n$ if\n$\\texttt{Fin}~m \\simeq \\texttt{Fin}~n$.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Bimonoidal Categories} \n\n\\paragraph*{SkFinSetCategory.} Defines the skeletal category of finite\nsets and all functions between them. There is one object for each\nnatural number $n$ (including $n=0$), and a morphism from $m$ to $n$\nis an $m$-tuple $(f_0,\\ldots,f_{m−1})$ of numbers satisfying\n$0 \\leq f_i < n$. This structure will be a building block for\npermutations (defined in \\texttt{ConcretePermutation}).\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{To do}\n\nPiLevel0\nConcretePermutation\nVecOps\nPiPerm\n\nEnumeration ??\nSEequivSCPermEquiv ??\n\n\\paragraph*{Cauchy representation.} A permutation on $n$ elements is\nrepresented by a vector \\texttt{v : Vec (Fin n) n}. If the $n$\nelements are indexed by positions, the element at position $i$ is\nmapped to position \\texttt{v !! i} by the permutation. There is always\na trivial permutation called \\texttt{1C} that maps each position to\nitself. The Cauchy representation does not enforce that the vector\nentries are disjoint. This is enforced by the definition of ``concrete\npermutations'' below.\n\n\\paragraph*{Concrete permutation.} A concrete permutation consists of\ntwo Cauchy vectors and two proofs that their compositions is the\nidentity permutation \\texttt{1C}. Concrete permutations are an\nequivalence relation. Concrete permutations actually have more\nstructure: a sum, a unit for the sum, etc. We can also build setoids\nwhose carriers are concrete permutations under the standard $\\equiv$\npropositional equality.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{document}\n", "meta": {"hexsha": "c776f266aedf8b4966e1cddd124a9dca4d963309", "size": 9424, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Univalence/outline.tex", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/outline.tex", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/outline.tex", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 44.663507109, "max_line_length": 76, "alphanum_fraction": 0.7393887946, "num_tokens": 2275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4072060192544206}}
{"text": "% $Header: /cvsroot/latex-beamer/latex-beamer/solutions/conference-talks/conference-ornate-20min.en.tex,v 1.6 2004/10/07 20:53:08 tantau Exp $\n\n\\documentclass{beamer}\n\n\\mode<presentation>\n{\n  \\usetheme{Hawke}\n  % or ...\n\n  \\setbeamercovered{transparent}\n  % or whatever (possibly just delete it)\n}\n\n\n\\usepackage[english]{babel}\n% or whatever\n\n\\usepackage[latin1]{inputenc}\n% or whatever\n\n\\usepackage{times}\n\\usepackage[T1]{fontenc}\n\n\\usepackage{multimedia}\n\n\n%%%%%%\n% My Commands\n%%%%%%\n\n\\newcommand{\\bb}{{\\boldsymbol{b}}}\n\\newcommand{\\bx}{{\\boldsymbol{x}}}\n\\newcommand{\\by}{{\\boldsymbol{y}}}\n\\newcommand{\\bfm}[1]{{\\boldsymbol{#1}}}\n\n%%%%\n\n\\title[Lecture 17] % (optional, use only with long paper titles)\n{Lecture 17 - Predictor Corrector Methods}\n\n\n\\author[I. Hawke] % (optional, use only with lots of authors)\n{I.~Hawke}\n\n\\institute[University of Southampton] % (optional, but mostly needed)\n{\n%  \\inst{1}%\n  School of Mathematics, \\\\\n  University of Southampton, UK\n}\n\n\\date[Semester 1] % (optional, should be abbreviation of conference name)\n{MATH3018/6141, Semester 1}\n\n\\subject{Numerical methods}\n% This is only inserted into the PDF information catalog. Can be left\n% out.\n\n\n\\pgfdeclareimage[height=0.5cm]{university-logo}{mathematics_7469}\n\\logo{\\pgfuseimage{university-logo}}\n\n\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>\n    \\frametitle{Outline}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\section{Predictor-Corrector methods}\n\n\\subsection{Predictor-Corrector methods}\n\n\\begin{frame}\n  \\frametitle{Geometrical interpretation of Euler's method}\n\n  Considering IVPs in the form\n  \\begin{equation*}\n    \\by'(x) = \\bfm{f}(x, \\by(x)).\n  \\end{equation*}\n\n  The simple (first order accurate, explicit) Euler method is\n  \\begin{equation*}\n    \\by_{n+1} = \\by_n + h \\bfm{f}(x_n, \\by_n).\n  \\end{equation*} \\pause\n\n  Euler's method is not sufficiently accurate for practical use. Euler predictor-corector is second order. \\pause\n\n  Use \\emph{multiple} approximations to the slope for a more accurate result.\n\n\\end{frame}\n\n\n\\section{Runge-Kutta methods}\n\n\\subsection{Runge-Kutta methods}\n\n\\begin{frame}\n  \\frametitle{Runge-Kutta methods}\n\n  In a Runge-Kutta method, Taylor's theorem is used from the start to\n  ensure the desired accuracy. \\pause\n\n  \\vspace{1ex}\n\n  Consider a single step from known data $y_n(x_n)$. Compute one\n  estimate ($k_1$) for $f(x_n, y_n)$ using the known data. \\pause Then\n  compute $y^{(1)}$ at $x_n + \\alpha h$ using $y_n + \\beta k_1$. \\pause\n  From this compute another estimate ($k_2$) for $f(x, y)$ at\n  $x_n + \\alpha h$. Compute $y^{(2)}$ etc; combine as $y_{n+1} = a k_1 + b k_2 + \\dots$. \\pause\n\n  \\vspace{1ex}\n\n  Such methods are called \\emph{multistage}:\n  \\begin{itemize}\n  \\item a number of estimates of $f$ are combined to\n    improve accuracy;\n  \\item only the previous value $y_n$ is required to start the\n    algorithm.\n  \\end{itemize}\n\n  \\vspace{1ex}\n\n  To derive $a, b, \\dots, \\alpha, \\beta, \\dots$ expand the algorithm and match to\n  exact solution using Taylor's theorem, chain rule and IVP.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example: RK2}\n\n  \\begin{overlayarea}{\\textwidth}{0.8\\textheight}\n    \\only<1|handout:1>\n    {\n      For the second order method we have\n      \\begin{align*}\n        y_{n+1} & = y_n + a k_1 + b k_2, \\\\\n        k_1 & = h f(x_n, y_n), \\\\\n        k_2 & = h f(x_n + \\alpha h, y_n + \\beta k_1).\n      \\end{align*}\n      We have four free parameters $a, b, \\alpha, \\beta$ to fix.\n    }\n    \\only<2|handout:1>\n    {\n      Taylor expand the definition of $y_{n+1} = y(x_n + h)$:\n      \\begin{align*}\n        y_{n+1} & = y_n + h y'_n + \\tfrac{h^2}{2} y''_n + \\dots \\\\\n        & = y_n + h f_n +  \\tfrac{h^2}{2} \\left( f_n \\right)' + \\dots \\\\\n        \\intertext{using the original IVP, then use the chain rule:}\n        & = y_n + h f_n +  \\tfrac{h^2}{2} \\left( \\partial_x f_n +\n          (\\partial_y f)_n f_n \\right) + \\dots .\n      \\end{align*}\n    }\n    \\only<3-|handout:2>\n    {\n      Algorithm:\n      \\begin{align*}\n        y_{n+1} & = y_n + a k_1 + b k_2 \\\\\n        & = y_n + h f_n +  \\tfrac{h^2}{2} \\left( \\partial_x f_n +\n          (\\partial_y f)_n f_n \\right) + \\dots\n      \\end{align*}\n\n      Compare against the Taylor expansion of the second order\n      method\n      \\begin{align*}\n        y_{n+1} & = y_n + a h f_n + b h f(x_n + \\alpha h, y_n + \\beta h\n        f_n) \\\\\n        & = y_n + h (a + b) f_n + h^2 \\left[ (\\partial_x f)_n \\alpha b +\n          (\\partial_y f)_n f_n \\beta b \\right].\n      \\end{align*}\n    }\n    \\only<4|handout:2>\n    {\n      Matching coefficients\n      \\begin{equation*}\n        \\left\\{\n          \\begin{aligned}\n            a + b & = 1 \\\\\n            \\alpha b & = 1 / 2 \\\\\n            \\beta b & = 1 / 2\n          \\end{aligned}\n          \\right. .\n      \\end{equation*}\n    }\n  \\end{overlayarea}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example: RK2 (II)}\n\n  The RK2 method\n  \\begin{align*}\n    y_{n+1} & = y_n + a k_1 + b k_2, \\\\\n    k_1 & = h f(x_n, y_n), \\\\\n    k_2 & = h f(x_n + \\alpha h, y_n + \\beta k_1)\n  \\end{align*}\n  with coefficients\n  \\begin{equation*}\n    \\left\\{\n      \\begin{aligned}\n        a + b & = 1 \\\\\n        \\alpha b & = 1 / 2 \\\\\n        \\beta b & = 1 / 2\n      \\end{aligned}\n    \\right.\n  \\end{equation*}\n  is not completely specified; there is essentially one free\n  parameter. \\pause\n\n  \\vspace{1ex}\n\n  Not all choices are stable. The classic choice is $a = 1/2 = b$,\n  $\\alpha = 1 = \\beta$: this is Euler predictor-corrector.\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Runge-Kutta 4}\n\n  The most used is the classic fourth order Runge-Kutta method. This\n  requires fixing eight free parameters by matching to order\n  $h^4$. This gives a family of methods again. \\pause\n\n  \\vspace{1ex}\n\n  Standard choice is\n  \\begin{align*}\n    y_{n+1} & = y_n + \\tfrac{1}{6} \\left( k_1 + 2 (k_2 + k_3) + k_4\n    \\right), \\\\\n    k_1 & = h f(x_n, y_n), \\\\\n    k_2 & = h f(x_n + h / 2, y_n + k_1 / 2), \\\\\n    k_3 & = h f(x_n + h / 2, y_n + k_2 / 2), \\\\\n    k_4 & = h f(x_n + h    , y_n + k_3    ).\n  \\end{align*} \\pause\n\n  \\vspace{1ex}\n\n  The local error term is ${\\cal O}(h^5)$ leading to a global error\n  ${\\cal O}(h^4)$.\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Example}\n\n\n  Apply the RK4 method to\n  \\begin{equation*}\n    y'(x) = - \\sin(x), \\quad y(0) = 1.\n  \\end{equation*}\n  Integrate to $x = 0.5$. Using $h = 0.1$ gives an error $4.8 \\times\n  10^{-7}\\%$; using $h = 0.01$ gives an error of $4.8 \\times\n  10^{-11}\\%$, showing fourth order convergence. \\pause\n\n  \\vspace{1ex}\n\n  Compare with an error, for $h=0.01$, of $10^{-3}\\%$ for the Euler\n  predictor-corrector method, and $0.24\\%$ for the simple Euler\n  method.\n\n  \\vspace{1ex}\n\n  RK4 more efficient \\emph{despite} needing four times the function\n  evaluations of Euler's method.\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Example: 2}\n\n\n  Consider the system\n  \\begin{equation*}\n    \\left\\{\n      \\begin{aligned}\n        \\dot{x} & = -y \\\\ \\dot{y} & = x\n      \\end{aligned} \\right., \\quad x(0) = 1, \\, \\, y(0) = 0.\n  \\end{equation*}\n  In polar coordinates this is $\\dot{r} = 0$, $\\dot{\\phi} = 1$.\n  \\begin{columns}\n    \\begin{column}{0.5\\textwidth}\n      \\begin{overlayarea}{\\textwidth}{0.4\\textheight}\n        \\only<2-3|handout:1>\n        {\n          Use the RK4 method with $h=0.1$. At $t=500$ the\n          result matches the correct answer to the eye.\n        }\n        \\only<3|handout:1>\n        {\n\n          \\vspace{1ex}\n          The growth of the radius makes the errors visible, but they\n          are still tiny.\n\n        }\n        \\only<4-5|handout:2>\n        {\n          Use the RK4 method with $h=0.01$. At $t=500$\n          the result matches the correct answer to the eye.\n        }\n        \\only<5|handout:2>\n        {\n\n          \\vspace{1ex}\n          The growth of the radius remains, but is minute.\n        }\n      \\end{overlayarea}\n    \\end{column}\n    \\begin{column}{0.5\\textwidth}\n      \\begin{overlayarea}{\\textwidth}{0.6\\textheight}\n        \\only<2|handout:0>\n        {\n          \\begin{center}\n            \\includegraphics[height=0.5\\textheight]{figures/RK4_1}\n          \\end{center}\n        }\n        \\only<3|handout:1>\n        {\n          \\begin{center}\n            \\includegraphics[height=0.5\\textheight]{figures/RK4_rad1}\n          \\end{center}\n        }\n        \\only<4|handout:0>\n        {\n          \\begin{center}\n            \\includegraphics[height=0.5\\textheight]{figures/RK4_2}\n          \\end{center}\n        }\n        \\only<5|handout:2>\n        {\n          \\begin{center}\n            \\includegraphics[height=0.5\\textheight]{figures/RK4_rad2}\n          \\end{center}\n        }\n      \\end{overlayarea}\n    \\end{column}\n  \\end{columns}\n\n\\end{frame}\n\n\n\\section{Summary}\n\n\\subsection{Summary}\n\n\\begin{frame}\n  \\frametitle{Summary}\n\n  \\begin{itemize}\n  \\item Euler's method has local error $\\propto h^2$, hence global\n    error $\\propto h$.\n  \\item The Euler predictor-corrector method has local error $\\propto\n    h^3$, hence global error $\\propto h^2$.\n  \\item \\emph{Multistage} methods such as Runge-Kutta methods require\n    only one known value $\\by_{n}$ to start, and compute (many)\n    estimates of the function $\\bfm{f}$ for the algorithm to update\n    $\\by_{n+1}$.\n  \\item Runge-Kutta methods are the classic multistage methods; the\n    predictor-corrector method is a second order RK method.\n  \\item RK4 is useful in practice.\n  \\end{itemize}\n\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "45d952e52903ba6cceb0543f084f0e756a17fe82", "size": 9456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lectures/tex/Lecture17_EPC_RK.tex", "max_stars_repo_name": "josh-gree/NumericalMethods", "max_stars_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 76, "max_stars_repo_stars_event_min_datetime": "2015-02-12T19:51:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T15:34:11.000Z", "max_issues_repo_path": "Lectures/tex/Lecture17_EPC_RK.tex", "max_issues_repo_name": "josh-gree/NumericalMethods", "max_issues_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2017-05-24T19:49:52.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-23T21:40:42.000Z", "max_forks_repo_path": "Lectures/tex/Lecture17_EPC_RK.tex", "max_forks_repo_name": "josh-gree/NumericalMethods", "max_forks_repo_head_hexsha": "03cb91114b3f5eb1b56916920ad180d371fe5283", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2015-01-05T13:30:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-15T09:59:39.000Z", "avg_line_length": 24.9498680739, "max_line_length": 142, "alphanum_fraction": 0.5994077834, "num_tokens": 3213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.407206012874011}}
{"text": "\\section{Materials and methods}\n\\label{sec:methods}\n\nTo demonstrate the objective of replicating \\Canna\\ display dives,  I simulated the system in \\MATLAB\\ and Simulink.  This was to be followed up with a proof-of-concept demonstration, provided I am able to achieve successful trials in simulation first; however, the demonstration was affected by the global COVID-19 pandemic. Simulation was used because it was more general and allowed easy changing of parameters and control methods to more completely explore the space; simulations also allowed examination of behavior at actual hummingbird flight speeds without risking excessive damage to the hardware. Simulations make simplifying assumptions by necessity, so actual testing and demonstration using real quadrotors--namely the Crazyflie 2.1--were also planned. Unfortunately, due to the inaccessibility of hardware brought about by the stay-at-home orders issued by the DoD in March of 2020, a final hardware demonstration of trajectory flight was never executed. Progress made towards achieving a hardware demonstration is described later in this report.  \n% This part is way too wordy and non-sequitur. \n%Before I describe these processes, it is important to mention why these are the methods I chose to implement. A simulation is general in that I can run the simulation for many iterations to see how the controller will react to different input parameters. The input parameters themselves are very specific; however, the ability to change parameter values will allow me to assess the full capabilities of the quadrotor system to determine if I can eliminate the need to do a time-scaled comparison to the hummingbird trajectory. The simulation will be coded using MATLAB and Simulink, both are software with which I have the most experience in creating simulations. My simulation code will be made available after the completion to this project on Git for those wishing to replicate my simulated results. Unfortunately, the realism of this simulation is limited, and as a result I will have to do a proof-of-concept demonstration to truly prove the ability of the quadrotor. Being a much more specific process, it will likely vary slightly from the simulation results, and need to be tweaked based on the level of success seen in the first few trials. Ultimately, the proof-of-concept demonstration is an essential piece to this research since a simulation doesn’t have any real world application except in principle. The experiment will enlist the use of a Crazyflie quadrotor platform, and an OptiTrack motion capture system in order to gather position vs. time data. This will help ensure accuracy in the quadrotor’s trajectory and as such, provide a higher level of confidence in the experiment’s success.\n\nFor my concept demonstrations, I modeled the rigid body dynamics of the quadrotor using parameters obtained from the Bitcraze website\\footnote{\\url{https://wiki.bitcraze.io/misc:investigations:thrust}}, and distance measurements taken by calipers. For initial attempts at control, the hover condition was assumed. This is a control linearization region which assumes the attitude of the quadrotor is completely level, i.e. the pitch and roll angles are assumed to be approximately zero degrees during all stages of flight. A basic waypoint position controller was utilized first in order to ensure controller functionality in simulation and on the hardware itself. A PD controller was used initially for position control, as this is a ubiquitous controller well understood by students and control theorists. Initial gains were taken from the simulation \\cite{hartman2014quadcopter}\n%cite dch33/Quad-Sim on github (this is the 2014 one from hartman cited here) LINK: https://github.com/dch33/Quad-Sim \n and later adjusted to fine-tune the quadrotor response. Additionally, in order to avoid an excessive attitude command in the event of large position errors, saturation limits were be placed on the attitude command of \\ang{\\pm 45} in order to ensure the quadrotor doesn't over-rotate and accidentally flip over. \n\nThe functional block diagram of the overall Crazyflie control system is shown in \\fref{fig:demonstration-2}. The laptop is the central node in the control scheme, obtaining position and orientation information from the OptiTrack system, and then relaying this data to the Crazyflie in addition to the next desired position on the trajectory path. The Crazyflie then conducts onboard error calculation and command processing in order to control its position in 3D space.\n\n% the quaternion model in \\cite{greiff2017modeling}. A quaternion is defined as \n%\\begin{equation}\n%Q = a + b i + c j + d k\n%\\end{equation}\n%where $i$, $j$, and $k$ are imaginary unit vectors. This model also assumes a right-handed coordinate system where $i\\cdot j = k$ , and the fundamental assumptions hold true -- i.e.  $i^2 = j^2 = k^2 = ijk = -1$.  I have chosen to use this model due to the limitations of the Euler model at high rotation angles. The quaternion model will be robust to these extreme angles, and is therefore better suited for my experiment. \\emph{\\textbf{Evangelista comment here: this is sort of strange to mention here. It's like saying I plan to use math, or matrices, or eigenvalues. Choosing to represent rotations as quaternions is a useful thing for avoiding gimbal lock associated with singularities in the Euler angle representation, but would not be considered a defining characteristic of what you plan to do, more like a low level design choice comparable to what units you use, or if you like floats or doubles.}}\n\n\\subsection{Simulation of bio-inspired dive pullout maneuvers in \\Matlab}\n%To create a feasible simulation for this research, I will model the Crazyflie quadrotor platform to be used in simulation. This involves determining the various thrust vectors of the motors, and the calculation of many performance metrics. Thankfully, much of this work has already been done, and I will be relying heavily on the work in \\cite{cheng2016flight} to create a useful model for the quadrotor in \\MATLAB\\ and Simulink.\n% Due to the extreme maneuvering of the quadrotor, I have chosen to use a quaternion coordinate system to describe its position, for flight control purposes only. %A quaternion is defined as a vector of one real and three imaginary vector directions, $i$, $j$, and $k$.\n\nUsing the model of the Crazyflie quadrotor described in the \\lstinline{PC_Quadcopter_Simulation.slx} \\MATLAB\\ Simulink simulation \\cite{hartman2014quadcopter}, \n%cite quadsim_68\nand hummingbird trajectory data obtained from \\cite{clark2009courtship}, several trajectory comparisons were conducted in the $x$, $y$, $z$ Cartesian coordinate frame between the true hummingbird trajectory (desired trajectory) and the actual flown trajectory by the simulated Crazyflie. Since the dive trajectories have little deviation in the $y$ coordinate axis, they are compared only in the $x$ and $z$ axes for all relevant error calculations. \n\n%I added the following bit to explain the initial conditions, but if it's too wordy or doesn't make sense here it should be moved to a spot where it makes more sense to explain this concept.\nSimulations were conducted from two different initial quadcopter states. The first simulation was run with the quadcopter starting from rest on the ground. This requires the quadcopter to ascend to the top of the trajectory first and then begin the trajectory flight, which simulates what I would have to replicate for the hardware demonstration. The second initializes the quadcopter at the beginning of the hummingbird trajectory, with an initial velocity determined by calculating the instantaneous velocity of the second data point $\\delta x/\\delta t$, and $\\delta z/\\delta t$ (both $x$ and $z$ directions) of the original hummingbird trajectory, where $\\delta x = x(t = t_1) - x(t = t_0)$. These velocities were then multiplied by a scale factor based on the simulation speed (e.g. the initial velocities were reduced by a factor of 20 for a simulation trajectory at 20 times reduced speed) in order to maintain a realistic starting velocity at each of the different trajectory speeds.\n%end of initial conditions spiel\n%The feedback diagram of this control concept is shown below in \\fref{fig:demonstration-2}. In principle, a desired trajectory will be developed from a path-planning algorithm that takes in the time scaled hummingbird trajectory and calculates the idealized pitch and motor torque and speed at each time step in order to fit this trajectory with as little error as possible. This signal will be combined with some sort of inertial measurement true position feedback to produce the error signal to the onboard flight controller. The flight controller will send a signal to the motors on the quadrotor based on this error signal to come as close as possible to zero error for the next time step, and the cycle will repeat until the quadrotor has completed its maneuver. My simulation will replicate this decision-making process using numerical integration to obtain the position data for every iteration.\n\n%this figure needs to be moved but I'm not sure how. It's printing well above the section that it's listed in here. add a [h] (for here) or move the figure around where it is in the code. \n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=0.8\\columnwidth]{\\myroot/figures/FunctionalBlockDiagram_system.png}\n\\end{center}\n\\caption{Functional block diagram of the data communication flow concept for the autonomously controlled Crazyflie, with an included onboard controller feedback loop.}\n\\label{fig:demonstration-2}\n\\end{figure}\n\nTo determine the accuracy of the trial I compared the actual flight path of the quadrotor with the desired flight path, and determined a time-scaled root mean square error between the two position vs time datasets. This error was calculated using the distance formula \\fref{eq:demonstration-1}:\n\\begin{equation}\ne_p(t) = \\sqrt{(x_a(t)-x_d(t))^2 + (z_a(t)-z_d(t))^2}\n%\\begin{bmatrix}\n%x(t) \\\\ y(t) \\\\ z(t)\n%\\end{bmatrix}_a^2 \n%-\n%\\begin{bmatrix}\n%x(t) \\\\ y(t) \\\\ z(t)\n%\\end{bmatrix}_d^2\n%}\n\\label{eq:demonstration-1}\n\\end{equation}\nwhere $e_p(t)$ is the position error at a specific time step (time $t$) in the trajectory, and the subscripts $a$ and $d$ represent the actual traveled trajectory and the desired trajectory respectively. The error in the $y$ axis is omitted since the trajectory is 2D in the $x$-$z$ plane and errors in the $y$ axis are therefore negligible for a stable controller, as is assumed. The error for every time step was averaged together to determine the root mean square error of the data. Additionally, the standard deviation $\\sigma$ of the position error was calculated using the \\lstinline{std()} function in \\MATLAB. Without any other indications, a successful trial was considered to be one with root mean square error of less than \\SI{10}{\\centi\\meter} over the entire trajectory, and with a $\\sigma$ value of less than \\SI{5}{\\centi\\meter}. Since the hummingbird trajectory is time-scaled down to only a fraction of its true speed, the quadrotor onboard controller was responsible for marking every position at the time it is supposed to be located at that position, therefore limiting the effects that motor operation constraints, e.g. thrust saturation, as a possible source of error in the trajectory flight.\n\n\n\n\n\n\n\\subsection{Tuning controller gain} %TALK HERE ABOUT CONTROLLER GAIN TUNING METHODS\nAfter the initial simulation runs, I anticipated large position errors over the trajectory flight. As such, it was desirable to tune the control gains in order to achieve a lower root mean square error. The simulation consists of two separate levels of control. The first level is a high-level (outer loop) PD controller concerning the $x$ and $y$ position of the quadcopter, and the second level is the lower-level (inner loop) PID controller that actually determines the pitch and roll angle of the quadcopter, as well as its vertical ($z$) position. The first level is a path planning step carried out among the Optitrack (sensor), control computer, and the drone.  The second level is flight stabilization (auto mode) carried out by the flight controller native onboard the drone. The output of the first level controller is factored as input into the second level controller, along with the quadcopter state. Separate control gains are used for each degree of freedom, i.e. the control gains for the pitch angle of the quadcopter are completely independent of those for the roll angle, altitude, yaw angle, etc. In all, there are eight different control gains that characterize the behavior of the quadcopter through the 2D $x$-$z$ hummingbird trajectory: the proportional and derivative control gains for the $x$ position ($K_{px}$, and $K_{dx}$), and the proportional, derivative, and integral control gains for both the pitch $\\theta$ and altitude $z$ $($respectively, $K_{p\\theta}$, $K_{d\\theta}$, $K_{i\\theta}$, $K_{pz}$, $K_{dz}$, $K_{iz}$). \n\nIn general, the effects of changing the proportional control gain will increase the responsiveness of the system with regard to the parameter effected by the controller. As the proportional gain is increased, overcontrolling is noted as oscillations around the desired state grow with a continued gain increase. An increase in the derivative control gain will help to counterbalance this effect to improve the overall stability of the system and reduce overshoot, while an increase in the integral control gain will reduce/eliminate oscillations around the desired settling state, bringing the steady state error to zero. As such, with regard to the effect of the control gains on the simulation output, I expect that increasing both the proportional and derivative gains should help to quicken the response of the quadrotor, and achieve a smaller root mean square error when flying the desired trajectory while remaining stable.\n\n\n\\subsubsection{Manual gain tuning}\nSeveral methods of gain tuning were attempted, with varying levels of success, to reduce the root mean square error of the quadrotor flight. These methods include manual gain tuning, nonlinear optimization routines, and marginal analysis. Manual gain tuning was attempted first. Initially, the proportional gain was increased separately for each of the three characteristic control loops ($x$, $z$, and $\\theta$) until signs of overcontrol/instability were noticed in the response (mostly by large oscillations around the desired control point). Then the derivative control gains were increased for each of these controllers to quell the unstable oscillations. Manual gain tuning was successful at reducing the root mean square error, and the detailed/numerical results are recorded in the Results section of this report.\n\n\\subsubsection{Attempted optimization using \\lstinline{fmincon}} \nAfter the manual gain tuning was unable to achieve the desired performance for the quadrotor, I began looking into different ways to attempt to optimize the controller gains to achieve a minimum root mean square error. I decided to use the \\MATLAB\\ function, \\lstinline{fmincon()} to optimize the controller gains, which finds the minimum value of a constrained nonlinear multivariable function through an iterative process. Before attempting to use the function for my problem, I completed the example problem listed in the \\MATLAB\\ documentation for \\lstinline{fmincon()} to minimize Rosenbrock's function. This test allowed me to orient myself with using the \\lstinline{fmincon()} tool, and helped to build my objective function for use on my simulation. \n\nIn defining my optimization problem, the eight characteristic control gains ($K_{px}$, $K_{dx}$, $K_{p\\theta}$, $K_{d\\theta}$, $K_{i\\theta}$, $K_{pz}$, $K_{dz}$, and $K_{iz}$) are the decision variables, using the values I had determined during my manual gain tuning as the initial point $x0$. My output variable (what I'm trying to optimize) is the root mean square error between the desired and actual trajectory flown by the quadcopter in the simulation. My objective function was the piece that was a little less straightforward, as it required multiple lines of \\MATLAB\\ code to achieve. I first set up the appropriate simulation parameters based on the changes to the decision variables made by the \\lstinline{fmincon()} optimization routine. Then, I ran the simulation for a set time of 20 seconds to allow sufficient time for the quadcopter to complete the trajectory flight. Following this, I had to determine the start and end points of the trajectory flight. The start point was simply the first index of the simulation output, since the quadcopter started at the top of the trajectory. The endpoint was determined by the index of the output where the commanded position at that index was the exact same as the commanded position two iterations after that point. (The simulation continues to command the last timeseries position provided by the input until the simulation time runs out, therefore a repeated position command in adjacent time steps means that the dive trajectory has ended.) Once the starting and ending index of the simulation output were determined, I was then able to use the error calculation described by \\fref{eq:demonstration-1} to determine the root square error of each time step, and average these values to find the root mean square error, completing my objective function.\n\nIn my first attempts at running the optimization routine I left the decision variables only constrained by the basic requirement that they had to be nonzero and positive. The optimizer would complete the first iteration at the initial point with no problems, but as soon as it changed the gains for the second iteration, it caused the system to become unstable and the simulation crashed with multiple zero-crossing errors. In attempts to remedy this, I changed several different simulation settings to ignore zero crossing errors and change the simulation step size, all to no avail. I then tried to add constraints to the upper bound of the decision variables (they were already constrained on the lower bound to be greater than zero), in an attempt to prevent the simulation from becoming unstable while \\lstinline{fmincon()} tweaked the control gains. This was successful in that the optimization routine was able to run its course; however, the result only made small changes to the initial control gains (less than a tenth of a percent change) which resulted in no significant effect on the output variable, the root mean square error. The simulation is therefore seemingly unable to support optimization routines as it is currently written.\n\n\\subsubsection{Marginal analysis... when optimization failed}\nAfter the attempt at control gain optimization proved unsuccessful, I decided to conduct a marginal analysis in order to determine which variables would contribute most to the reduction of the root mean square error. A marginal analysis test simply makes a small change to a decision variable, and then records the overall benefit gained and cost incurred from making that small change. Running this analysis provides insight into how this current controller scheme could be tuned further to achieve greater success at flying the quadcopter through the desired trajectory. I again used the gain values obtained from manual tuning as my initial point, and wrote a \\MATLAB\\ script to iterate through each gain value and run the simulation on three separate cases for each: a run with the gain at the initial point, a run with the gain decreased by 5\\%, and a run with the gain increased by 5\\%. After each simulation, error data was collected and saved for processing. \n\n\n\n\n\n\n\n\n\\subsection{Demonstration of bio-inspired dive pullout maneuver using Crazyflie quadrotor}\nHardware implementation is essential to verifying that the findings of the simulation are accurate. The path to a successful hardware demonstration was a multi-step process. We needed to test the capability of the crazyflie to operate under manual control, open loop control, and then finally introduce closed-loop control of the crazyflie using an optical motion tracking system. As such, the hardware components necessary for this experiment include a fully functional Crazyflie quadrotor (Bitcraze, Malm\\\"{o}, Sweden), and an OptiTrack system (NaturalPoint Inc., Corvallis, OR). The quadrotor will be the object of the experiment, and the OptiTrack system serves as a highly accurate way to obtain position data for the Crazyflie in flight. It achieves this using visual information from nearly 20 cameras staged around the outside of the testing area. Initial experimentation will be conducted indoors to minimize any aerodynamic noise, although future trials could test controller robustness by introducing environment disturbances. Several batteries for the Crazyflie are needed to ensure sufficient trial and testing periods, and approximately five OptiTrack visual markers must be affixed asymetrically\\footnote{This is to clearly distinguish the rigid body axes relative to the markers to ensure proper pose readings.} on each Crazyflie drone to ensure that it is able to be detected by the OptiTrack system and that its state is measured appropriately. These marker additions will be taken into account in simulation first in order to ensure readiness to counteract any effect they may have on the dynamics of the quadrotor in the feedback loop.\n\nAs an initial test of hardware, I used the \\lstinline{cfclient} software (Bitcraze, Malm\\\"{o}, Sweden; \\url{https://github.com/bitcraze/crazyflie-clients-python}) to link to the crazyflie from a linux machine, and test manual control of the crazyflie using a Logitech USB gamepad (Logitech F310; Lausanne, Switzerland) and a Crazyradio sending velocity and thrust commands to the Crazyflie. This allowed me to gain a basic understanding of how the crazyflie communicated with the linux machine over radio control, and how this might be implemented in a python script. I then tested the motion tracking system capabilities by obtaining automatic 3D position tracking data via the OptiTrack. The OptiTrack system worked independently from this workstation, and recorded $x$, $y$, $z$ position data while logging the time $t$ that each data point was recorded at. \n\n%The Crazyflie was controlled manually, from a computer, using the bitcraze \\lstinline{cfclient} software (Bitcraze, Malm\\\"{o}, Sweden; \\url{https://github.com/bitcraze/crazyflie-clients-python}). To establish manual flight control, the computer was equipped with a USB gamepad (Logitech F310; Lausanne, Switzerland) and a Crazyradio sending velocity and thrust commands to the Crazyflie. The OptiTrack system worked independently from this workstation, and recorded $x$, $y$, $z$ position data while logging the time $t$ that each data point was recorded at. \n\n%DISCUSS FURTHER HARDWARE DEMONSTRATION HERE. HURDLES, ETC. FIND INFO IN PROGRESS FILE ON DRIVE\n%In simulation, we observed that as the speed of the maneuver increased, it was more difficult for the crazyflie to fly it accurately. We wanted to test the same trajectories on hardware in order to see if the actual crazyflie would behave in a similar manner (show a similar error in trajectory flight flying at the same speeds tested in simulation). \n\n%NOTE: THE TeX compiler doesn't like underscores, and won't compile if you have a naked one in the text. To solve, just put a '\\' in front of it and it will render the underscore '_' as just text and will compile just fine.\nThe next step towards a full hardware demonstration was to test autonomous control of the Crazyflie. To support this, I cloned the \\lstinline{whoenig/crazyflie_ros} github repository (\\url{https://github.com/whoenig/crazyflie_ros}) which utilizes a ROS framework to run multiple python and C++ scripts that send appropriate commands to the Crazyflie based on the tasking in the files that are run. The demo package of the repository contained a plethora of different example scripts and launch files that would provide the capability needed to complete the hardware testing that I desired, including options for manual joystick control, open-loop hovering control, and closed-loop control using both Vicon (Vicon Motion Capture; Oxford, UK), an optical motion tracking system, and VRPN connection to an alternate motion tracking system such as OptiTrack (Optitrack; Corvallis, OR). I progressively ran through several of the lower level control demo packages, testing first manual control with the USB gamepad using ROS, followed by open-loop control (which ultimately resulted in the Crazyflie crashing into the ceiling due to no closed-loop feedback). Through adaptation of the vrpn control demo scripts, I was able to achieve a successful implementation of a closed-loop hover at a desired 3D location. This worked similar to waypoint control, but only consisting of two waypoints (i.e. the starting and ending point). This meant that waypoint trajectory flight would be possible in the Maury lab with the provided controller. \n\nUnfortunately, due to the global COVID-19 pandemic, this was as much as I was able to achieve in terms of a hardware demonstration of capability. My work up to this point has been saved in a github repository (\\url{https://github.com/devangel77b/marcello-2020-code}), and should be easily accessible and run-able by any student wishing to use the combined Crazyflie OptiTrack system to conduct waypoint flight hardware demonstrations. I have also left fairly detailed instructions in a Google document, which is available on the \\lstinline{marcello-2020} Google Shared Drive.\n", "meta": {"hexsha": "608db671499355524892c42c47ea861b23047f45", "size": 25736, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ew402report/methods.tex", "max_stars_repo_name": "devangel77b/marcello-manuscripts", "max_stars_repo_head_hexsha": "7740836cd9a1bd4696d01b538e1924f975eea258", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-13T20:12:33.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-13T20:12:35.000Z", "max_issues_repo_path": "ew402report/methods.tex", "max_issues_repo_name": "devangel77b/marcello-manuscripts", "max_issues_repo_head_hexsha": "7740836cd9a1bd4696d01b538e1924f975eea258", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-02-21T12:57:08.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-21T12:57:08.000Z", "max_forks_repo_path": "ew402report/methods.tex", "max_forks_repo_name": "devangel77b/marcello-manuscripts", "max_forks_repo_head_hexsha": "7740836cd9a1bd4696d01b538e1924f975eea258", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 252.3137254902, "max_line_length": 1811, "alphanum_fraction": 0.8040876593, "num_tokens": 5476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4072060118749125}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\documentclass[preprint,aps,pra,showpacs,floatfix]{revtex4}\n%\\documentclass[aps,pra,showpacs,floatfix]{revtex4}\n%\\documentclass[preprint,aps,pra,showpacs,superscriptaddress,floatfix]{revtex4}\n%\\usepackage{showkeys}\n%\\usepackage{refcheck}                % Checks references and citations\n\\usepackage{graphicx}\n\\usepackage{times}\n\\usepackage{nicefrac}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{epsf}\n\\usepackage{bm}\n\\usepackage{bbm}\n\\usepackage{times}\n% \\usepackage{cite}\n\\usepackage[english]{babel}\n%\n% \\documentclass[4apaper,12pt]{article}\n%\n%\n% \\oddsidemargin=-0.6cm \\textwidth=17.5cm \\topmargin=-1.0cm\n% \\textheight=24.cm\n%\n% \\usepackage[english]{babel}\n% \\usepackage{amssymb}\n% \\usepackage{graphicx,amsmath,amsfonts,amssymb,cite}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% General abbreviations\n%\n\\newcommand{\\be}{\\begin{eqnarray}}\n\\newcommand{\\ee}{\\end{eqnarray}}\n\\newcommand{\\la}{\\langle}\n\\newcommand{\\ra}{\\rangle}\n\\newcommand{\\lbr}{\\langle}\n\\newcommand{\\rbr}{\\rangle}\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\veps}{\\varepsilon}\n\\newcommand{\\vare}{\\varepsilon}\n\\newcommand{\\vphi}{\\varphi}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\newcommand{\\balpha}{\\bm{\\alpha}}\n\\newcommand{\\bnabla}{\\bm{\\nabla}}\n\\newcommand{\\bfr}{{\\bf r}}\n\n\\newcommand{\\po}{$2p_{1/2}$}\n\\newcommand{\\pt}{$2p_{3/2}$}\n\\newcommand{\\s}{$2s$}\n\\newcommand{\\postr}{${2p_{1/2}}$-${2s}$}\n\\newcommand{\\ptstr}{${2p_{3/2}}$-${2s}$}\n\n\\newcommand{\\dE}{\\Delta E}\n\\newcommand{\\kk}{\\lambda}\n\\newcommand{\\kurs}{\\textit}\n\n\\newcommand{\\al}{\\alpha}\n\\newcommand{\\az}{\\alpha Z}\n\\newcommand{\\aZ}{\\alpha Z}\n% \\newcommand{\\be}{\\beta_{20}}\n\n\\newcommand{\\rb}{\\vec{r}}\n%\\newcommand{\\rb}{\\boldsymbol{r}}\n\\newcommand{\\re}{r_e}\n%\\newcommand{\\me}{m_e}\n%\\newcommand{\\mpr}{m_p}\n%\\newcommand{\\ga}{\\gamma}\n\n\\newcommand{\\ka}{\\varkappa}\n\n\\newcommand{\\albi}{\\boldsymbol{\\alpha}_i}\n\\newcommand{\\albj}{\\boldsymbol{\\alpha}_j}\n%\n\\newcommand{\\Eres}{E_{\\rm res}}\n\\newcommand{\\Ebind}{E_{\\rm bind}}\n\\newcommand{\\Eexc}{E_{\\rm exc}}\n\n\\newcommand{\\Vnucl}{V_{\\rm nuc}}\n\\newcommand{\\Vscr}{V_{\\rm scr}}\n\\newcommand{\\Veff}{V_{\\rm eff}}\n\\newcommand{\\VLDT}{V_{\\rm LDT}}\n\\newcommand{\\xalpha}{x_{\\alpha}}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\n\\usepackage{gb4e} %added by me, Erica\n\n\\begin{document}\n\n%Accurate\n\\title{\nQED calculation of~the~$\\bm{2p_{1/2}}$-$\\bm{2s}$ and~$\\bm{2p_{3/2}}$-$\\bm{2s}$\ntransition~energies and~the~ground-state hyperfine~splitting in~lithiumlike~scandium}\n%\n% \\date{}\n%\n\\author{Y.~S.~Kozhedub$^1$, D.~A.~Glazov$^1$, A.~N.~Artemyev$^1$, N.~S.~Oreshkina$^1$,\nV.~M.~Shabaev$^1$, I.~I.~Tupitsyn$^1$,  A.~V.~Volotka$^2$, and G.~Plunien$^2$}\n%\n\\affiliation{\n%\n$^1$\nDepartment of Physics, St. Petersburg State University,\nOulianovskaya 1, Petrodvorets, St. Petersburg 198504, Russia \\\\\n%\n$^2$\nInstitut f\\\"ur Theoretische Physik, TU Dresden,\nMommsenstra{\\ss}e 13, D-01062 Dresden, Germany \\\\\n%\n}\n%\n\\begin{abstract}\n%\nWe present the most accurate up-to-date theoretical values of the ${2p_{1/2}}$-${2s}$\nand ${2p_{3/2}}$-${2s}$ transition energies and the ground-state hyperfine\nsplitting in ${\\rm Sc}^{18+}$. All two- and three-electron contributions\nto the energy values up to the two-photon level are treated in the framework\nof bound-state QED without $\\aZ$-expansion. The interelectronic interaction\nbeyond the two-photon level is taken into account by means of the large-scale\nconfiguration-interaction Dirac-Fock-Sturm (CI-DFS) method. The relativistic\nrecoil correction is calculated with many-electron wave functions in order\nto take into account the electron-correlation effect. The accuracy of\nthe transition energy values is improved by a factor of five compared\nto the previous calculations. The CI-DFS calculation of interelectronic-interaction\neffects and the evaluation of the QED correction in an effective screening\npotential provide significant improvement for the $2s$ hyperfine splitting.\nThe results obtained are in good agreement with recently published\nexperimental data.\n%\n\\end{abstract}\n%\n\\pacs{12.20.Ds, 31.30.Jv, 31.10.+z, 31.30.Gs}\n%\n\\maketitle\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\section{Introduction}\n%\nThe dielectronic recombination process has proven to be a useful tool\nin high-precision measurements of the excitation energy of low-lying levels\nin middle-$Z$ lithiumlike systems \\cite{madzunkov:PRA:02,kieslich:PRA:04}.\nBy this method the energy of the ${2p_{3/2}}$-${2s}$ transition in ${\\rm Sc}^{18+}$\nwas determined to be $44.3107(19)$ eV \\cite{kieslich:PRA:04}.\nA significant improvement of the accuracy was announced recently by M.~Lestinsky\n{\\it et al}. \\cite{les:EGAS,les:HCI}, with the preliminary value of $44.3096(4)$ eV,\nand the work on further improvement of this value is in progress \\cite{wolf:SPARC}.\nIn these experiments the energy of the Rydberg resonances $\\Eres$ was measured.\nThe Rydberg state energy $\\Ebind$ was evaluated by means of relativistic many-body\nperturbation theory (RMBPT). Then the excitation energy of the ion was determined\nas $\\Eexc=\\Eres+\\Ebind$. In Ref. \\cite{kieslich:PRA:04} the theoretical value\nof $\\Eexc$ for both ${2p_{1/2}}$-${2s}$ and ${2p_{3/2}}$-${2s}$ transitions\nwas obtained by means of RMBPT, while for the quantum electrodynamic (QED)\ncorrection the result of Ref. \\cite{kim:PRA:91} was taken into account.\nThe energy resolution achieved in these experiments also allowed for resolving\nthe $2s$ hyperfine structure. As a result, the $2s$ hyperfine splitting\nof lithiumlike scandium was measured to be $6.21(20)$ meV \\cite{les:HCI}.\n\nThe main goal of the present investigation is to evaluate the ${2p_{1/2}}$-${2s}$\nand ${2p_{3/2}}$-${2s}$ transition energies and the ground-state hyperfine splitting\nin lithiumlike scandium to the utmost accuracy aiming at a stringent test\nof the present state-of-the-art theoretical description of many-electron effects.\nVarious contributions to the energy of the ${2p}$-${2s}$ transitions are considered\nin the next Section. In order to meet the experimental accuracy, rigorous\nquantum electrodynamic calculations of the first two orders of perturbation theory\nare combined with large-scale configuration-interaction Dirac-Fock-Sturm (CI-DFS)\ncalculations of the third- and higher-order contributions within the Breit approximation.\nThe relativistic nuclear recoil corrections are calculated as well. The evaluation\nof the hyperfine splitting is accomplished in Section \\ref{section:hfs}. The CI-DFS\nmethod is employed to obtain correlation effects of order $1/Z^2$ and higher.\nThe radiative correction to hyperfine splitting is calculated with an effective\nlocal screening potential.\n\nRelativistic units are used throughout the paper $(\\hbar=c=1)$.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\section{${2p_{1/2}}$-${2s}$ and ${2p_{3/2}}$-${2s}$ transition energies}\n\\label{section:en}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\nWe start with the Furry picture, where in the zeroth-order approximation\nnoninteracting electrons are bound by the Coulomb field of the nucleus.\nThe Dirac equation yields zeroth-order energies of the one-electron states.\nThe homogeneously-charged-sphere model of the nucleus is employed with\nthe value of rms radius $\\la r^2 \\ra^{1/2}=3.5443(23)$ fm \\cite{ADNDT87_185}.\n\nIn leading order of the perturbation theory. diagrams of self-energy,\nvacuum polarization, and one-photon exchange arise.\nTechniques for the evaluation of these corrections nonperturbative in $\\az$\nhave been described in numerous publications (see, e.g., Ref. \\cite{mohr:PREP:98}).\nFor the self-energy correction we interpolate the values presented in Ref. \\cite{PRA58_954}\nfor the $2s$ and $2p_{1/2}$ states and those presented in Ref. \\cite{PRA46_4421}\nfor the $2p_{3/2}$ state. The vacuum-polarization and one-photon exchange\ncorrections are recalculated in the present work with inclusion of finite-nuclear-size effects.\n\nThe second-order contributions can be classified as one-electron two-loop QED\ncorrections, two-electron QED corrections, and two-photon exchange. Rigorous\ncalculation of all two-loop QED corrections is a challenging problem. To date,\nthe dominant part of these corrections was calculated in a wide range of $Z=10-92$\nfor the $1s$ state only (see Ref. \\cite{yerokhin:SESE} and references therein).\nRecently, the corresponding results for $2s$, $2p_{1/2}$ and $2p_{3/2}$ states were\npresented for high-$Z$ ions \\cite{yerokhin:PRL:06}. However, since for low values\nof $Z$ the numerical evaluation of the second-order self-energy correction becomes\nrather difficult, so far one has to rely on the $\\az$ expansion, which reads\n%\n\\begin{align}\n\\label{two-loop}\n  \\Delta E_{\\rm two-loop}=m \\left( \\frac{\\al}{\\pi} \\right)^2 & \\frac{(\\az)^4}{n^3}\n    \\Big[\n      B_{40} + (\\az)B_{50}\n\\notag\\\\\n      &+ (\\az)^2 \\left\\{ B_{63} L^3 + B_{62} L^2 + B_{61} L + B_{60} \\right\\} + \\cdots\n    \\Big]\n\\,,\n\\end{align}\n%\nwhere $L=\\ln[(\\az)^{-2}]$. The values of the coefficients for the $2s$ state\ncan be found in Appendix A of Ref. \\cite{RPM77_000001} and for the $2p_{1/2}$\nand $2p_{3/2}$ states in Ref. \\cite{PRA72_062102}. Since the convergence of\nthe expansion in $\\az$ is known to be rather bad, we assume the uncertainty\nto be about $50\\%$ in our case.\n\nThe two-electron QED corrections are represented by the diagrams of the screened\nself-energy and the screened vacuum-polarization. Rigorous evaluation of\nthe screened self-energy in Li-like ions was performed in Ref. \\cite{yerokhin:PRA:99}\nfor $2s$ and $2p_{1/2}$ states and in Ref. \\cite{yerokhin:OS:05} for the $2p_{3/2}$ state.\n%\nThe screened vacuum-polarization correction was calculated in Ref. \\cite{PRA60_45}.\nWe obtain the corresponding values for $Z=21$ employing the procedure presented\nin these works. In order to estimate higher-order (in $1/Z$) terms of the screened\nQED correction, the following approximate scheme is used. The first-order QED\ncorrection is evaluated in an effective screening potential and the higher-order\nterms are extracted by subtracting the zeroth- and  first-order terms.\nThe uncertainty of the higher-order screened QED correciton obtained in this way\nis assumed to be $100\\%$.\n\nThe two-photon exchange correction is evaluated within the framework of QED,\nfollowing our previous investigations \\cite{PRA67_062506,PRA64_032109}.\n\nIn order to evaluate the interelectronic-interaction corrections of third\nand higher orders we proceed as follows. The Dirac-Coulomb-Breit equation\nwithin the no-pair approximation is solved by means of the large-scale CI-DFS\nmethod \\cite{PRA68_022511,PRA72_062503} yielding the many-electron wave functions\nand the energy values. The interelectronic-interaction operator employed\nin the Dirac-Coulomb-Breit equation reads\n%\n\\begin{eqnarray}\n\\label{interaction}\n  V_{\\rm Breit} = \\kk\\al \\sum_{i>j} \\left[ \\frac{1}{r_{ij}} - \\frac{\\albi \\cdot \\albj}{2r_{ij}}\n  - \\frac{(\\albi \\cdot \\bfr_{ij}) (\\albj \\cdot \\bfr_{ij})}{2r^{3}_{ij}}\\right]\n\\,,\n\\end{eqnarray}\n%\nwhere a scaling parameter $\\kk$ is introduced in order to separate terms\nof different order in $1/Z$ from the numerical results with different $\\kk$.\nHere $i,j$ enumerate the electrons and $\\balpha$ is a vector incorporating\nthe Dirac matrices. In this way, for small $\\kk$, the total energy of the system\ncan be expanded in powers of $\\kk$,\n%\n\\begin{equation}\n  E(\\kk)=E_{0}+E_{1}{\\kk}+E_{2}{\\kk^{2}}+\\sum_{k=3}^\\infty E_{k} {\\kk^k}\n\\,,\n\\end{equation}\n%\nwhere\n%\n\\begin{equation}\n\\label{derivative}\n  E_{k} = \\frac{1}{k!} \\frac{d^k}{d\\kk^k}E(\\kk)\\Big|_{\\kk=0}\n\\,.\n\\end{equation}\n%\nThe higher-order contribution $E_{\\geqslant 3}\\equiv\\sum_{k=3}^{\\infty}E_k$\nis calculated as $E_{\\geqslant 3}=E(\\kk=1)-E_{0}-E_{1}-E_{2}$, where the low-order\nterms $E_0$, $E_1$, and $E_2$ are determined numerically according to Eq. (\\ref{derivative}).\nComparison of $E_{1}$ and $E_{2}$ with corresponding QED results allows us\nto conclude that the uncertainty of the higher-order contribution due to the Breit\napproximation is less than $0.1\\%$.\n\nThe full relativistic theory of the nuclear recoil effect can be formulated only\nin the framework of QED \\cite{shabaev:PRA:98}. To evaluate the recoil effect\nwithin the lowest-order relativistic approximation one can use the operator\n(see, e.g., Ref. \\cite{shabaev:PRA:98})\n%\n\\begin{equation}\\label{recoil}\n  H_M = \\frac{1}{2M} \\sum_{i,j} \\left[ \\boldsymbol{p}_i\\cdot\\boldsymbol{p}_j\n    - \\frac{\\az}{r_i} \\left( \\albi+\\frac{(\\albi\\cdot\\boldsymbol{r}_i)\\boldsymbol{r}_i}\n    {r^{2}_{i}} \\right) \\cdot\\boldsymbol{p}_j \\right],\n\\end{equation}\n%\nwhere $M$ is the nuclear mass and $\\boldsymbol{p}_i$ is the momentum operator\nacting on the ith electron. The expectation value of $H_M$ on the many-electron\nwave function of the system, obtained by the CI-DFS method, yields the recoil\ncorrection to the energy levels in all orders of $1/Z$ within the $(\\az)^4{m^2}/{M}$\napproximation. The electron-correlation effects contribute to about $20\\%$\nof the total value and have to be taken into account in order to achieve\nthe desirable accuracy. The one- and two-electron recoil corrections of higher\norders in $\\az$ are taken from Refs. \\cite{artemyev:PRA:95, JPB28_5201}.\nThe recoil correction of the next order in $m/M$ is negligible in the case\nunder consideration.\n\nAll contributions to the transition energies considered above are collected\nin Table I. For comparison, previous theoretical results and available\nexperimental data are presented as well. As one can see from the table,\nthe theoretical values of the transition energies reported in this paper\nare about five times more precise than those in Ref. \\cite{kieslich:PRA:04}\nand agree well with the experiments. Further improvement of the theoretical\naccuracy can be achieved by more accurate calculations of the higher-order\nscreened QED effects.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\section{Hyperfine splitting}\n\\label{section:hfs}\n\nThe ground-state hyperfine splitting of a lithiumlike ion is conveniently written as\n%\n\\begin{eqnarray}\n\\label{eq:hfs}\n  \\Delta E_\\mu &=& \\frac{1}{6}\\,\\alpha\\,(\\aZ)^3\\,\\frac{m}{m_p}\\,\n    \\frac{\\mu}{\\mu_N}\\,\\frac{2I+1}{2I}\\,\\frac{1}{(1+\\frac{m}{M})^3}\\,mc^2\n\\nonumber\\\\\n  && \\times\n    \\left[ A(\\aZ)(1-\\delta)(1-\\veps) +\n    \\frac{1}{Z}B(\\aZ) + \\frac{1}{Z^2}C(Z,\\aZ)\n    + x_{\\rm{rad}} \\right]\n\\,,\n\\end{eqnarray}\n%\nwhere $m_p$ is the mass of the proton, $\\mu$ and $I$ are the nuclear magnetic moment\nand spin, and $\\mu_N$ denotes the nuclear magneton. The one-electron relativistic\nfactor $A(\\aZ)$ can easily be derived from the Dirac equation utilizing virial\nrelations \\cite{shabaev:91}. The finite-nuclear-size correction $\\delta$\nis evaluated numerically employing the homogeneously-charged-sphere model\nfor the nuclear-charge distribution. The Bohr-Weisskopf correction $\\veps$,\narising due to the nonpointlike nuclear magnetization distribution, is evaluated\nwithin the single-particle nuclear model \\cite{shabaev:94,shabaev:pra:97}.\n\nThe first-order interelectronic-interaction correction described by the function\n$B(\\az)$ is evaluated in the rigorous QED approach \\cite{shabaeva:95}.\nThe dual-kinetic-balance (DKB) approach \\cite{shabaev:04:prl} is employed\nto construct the complete set of one-electron wave functions from\nthe B splines. The finite distributions of the nuclear charge and the nuclear\nmagnetization are taken into account. The latter is introduced via the replacement\nof $1/r^2$ with $F(r)/r^2$ in the hyperfine interaction matrix elements. The explicit\nform of the function $F(r)$ can be found in Refs. \\cite{tup:02,zherebtsov:00}.\nThe higher-order correction $C(Z,\\aZ)/Z^2$ is obtained in the framework of\nthe large-scale CI-DFS method.\n\nThe QED correction $x_{\\rm{rad}}$ is evaluated in one-loop approximation\nwith an effecitve non-Coulomb binding potential $\\Veff$, which partly takes into\naccount the interelectronic-interaction effects. It is taken in the following\nform \\cite{slater,kohn-sham}\n%\n\\begin{eqnarray}\n\\label{eq:Vscr-dft}\n  \\Veff(r) = \\Vnucl(r) + {\\alpha} \\int_0^{\\infty}dr' \\frac{1}{r_>} \\rho(r')\n  - \\xalpha\\,\\frac{\\alpha}{r} \\left( \\frac{81}{32\\pi^2} r \\rho(r) \\right)^{1/3}.\n\\end{eqnarray}\n%\nHere $\\rho$ is the total electron density, including the $(1s)^2$ shell and\nthe $2s$ electron. The parameter $\\xalpha$ is taken to be $\\xalpha=2/3$, which\ncorresponds to the Kohn-Sham potential. To provide a proper asymptotic behavior,\nthe potential $\\Veff$ should be corrected at large $r$ \\cite{latter}.\nThe one-electron spectrum of the Dirac equation with $\\Veff$ is constructed\nby means of the DKB method \\cite{shabaev:04:prl}. Since the potential $\\Veff$\nis assumed to be self-consistent, the standard iteration procedure is employed.\nThe calculations performed are very similar to our recent calculations of\nthe one-loop QED corrections to the $g$~factor of Li-like ions \\cite{glazov:pla:06}.\nWe mention also that the evaluation of the QED corrections to the hyperfine\nstructure with an effective screening potential was performed in the past\nfor the case of lithiumlike bismuth \\cite{sapirstein:03}.\n\nThe individual contributions to the hyperfine splitting in litiumlike scandium\nare listed in Table II. For each contribution the corresponding term\nin the square brackets in Eq. (\\ref{eq:hfs}) is explicitly written.\nFor comparison, the experimental value from Ref. \\cite{les:HCI} as well as\nthe previously published results by Shabaev {\\it et al.} \\cite{shabaev:97}\nand by Boucard and Indelicato \\cite{boucard:00} are presented. The accuracy\nof the present result is twice better than that of Ref. \\cite{shabaev:97}\nand about two orders of magnitude higher than the experimental one.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\section{Conclusion}\n\\label{section:con}\n\nIn this paper we have presented {\\it ab initio} QED evaluations of the ${2p_{1/2}}$-${2s}$\nand ${2p_{3/2}}$-${2s}$ transition energies in lithiumlike scandium, where\nthe most accurate experimental data for middle-$Z$ lithiumlike ions have been achieved.\nAll presently available contributions to the transition energies are collected.\nExcept for the one-electron two-loop correction, all other terms up to the two-photon\nlevel are treated within the framework of bound-state QED to all orders in $\\az$.\n%\nThe third- and higher-order interelectronic-interaction effects are accounted for\nwithin the Breit approximation using large-scale CI-DFS calculations.\nThe relativistic recoil corrections are evaluated as well. As a result, the total\ntheoretical accuracy is improved by a factor of 5 compared to the previous\ncalculations.\n\nThe ground-state hyperfine splitting of lithiumlike scandium has been calculated.\nThe interelectronic-interaction correction to the first order in $1/Z$ is evaluated\nwithin the framework of QED. The higher-order electron-correlation effects are calculated\nusing the large-scale CI-DFS method. The one-loop radiative corrections are calculated\nwith an effective screening potential. The theoretical value of the hyperfine splitting\nis improved in comparison with the previous results.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\acknowledgments\nThis work was supported in part by RFBR (Grant No. 07-02-00126), INTAS-GSI\n(Grant No. 06-1000012-8881), GSI, and DFG.\nY.S.K. and N.S.O. acknowledge support by the Dynasty Foundation.\nThe work of N.S.O. and D.A.G. was supported by DAAD.\nY.S.K. acknowledges the support from GSI and from St. Petersburg Government\n(Grant No. M06-2.4D-295).\nD.A.G. also acknowledges support from the St. Petersburg Government\n(Grant No. M06-2.4K-280).\nA.N.A., A.V.V., and G.P. acknowledge financial support from DFG and GSI.\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\begin{table}\n\\label{tab:en}\n\\caption{\nIndividual contributions to the ${2p_{1/2}}$-${2s}$ and ${2p_{3/2}}$-${2s}$\ntransition energies in Li-like scandium, in eV. For comparison, the theoretical\nresult from Ref. \\cite{kieslich:PRA:04} and the experimental values, obtained\nvia optical spectroscopy \\cite{pl:suckewer80} and via the dielectronic recombination\nprocess \\cite{kieslich:PRA:04,les:EGAS}, are presented.\n}\n\\linespread{1}\n\\begin{center}\n\\begin{tabular}{lr|r@{}l|r@{}lr@{}l}\n\\hline\n\\hline\n&&\n\\multicolumn{2}{c}{\\po-\\s} &\n\\multicolumn{2}{c}{\\pt-\\s}\n\\\\\n%\n\\hline\n%\nDirac value (extended nucleus) &&\n    $-$0.&00237 &\n       8.&93553 \\\\\n%\nOne-photon exchange &&\n      41.&89788 &\n      38.&90847 \\\\\n%\nSelf-energy &&\n    $-$0.&2871(3) &\n    $-$0.&2679(3) \\\\\n%\nVacuum-polarization &&\n       0.&01979 &\n       0.&01989 \\\\\n%\nTwo-photon exchange &&\n    $-$3.&5683(2) &\n    $-$3.&2388(2) \\\\\n%\nScreened QED &&\n       0.&0387(20) &\n       0.&0331(20) \\\\\n%\nThree- and more-photon exchange &&\n    $-$0.&0594(3) &\n    $-$0.&0713(3) \\\\\n%\nTwo-loop QED &&\n       0.&00011(5) &\n       0.&00008(4) \\\\\n%\nRecoil &&\n    $-$0.&00991(2) &\n    $-$0.&01001(2) \\\\\n\\hline\n%\nTheory: &this work  &\n       38.&0294(21) &\n       44.&3091(21) \\\\\n%\n&\nS.~Kieslich {\\it et al}. \\cite{kieslich:PRA:04}&  \n       38.&0261(100) &\n       44.&3089(100) \\\\\n%\nExperiment: &\nS.~Suckewer {\\it et al}. \\cite{pl:suckewer80} &\n       38.&02(4)   &\n       44.&312(35) \\\\\n% Experiment: &\n&\nS.~Kieslich {\\it et al}. \\cite{kieslich:PRA:04} &\n       &    &\n       44.&3107(19) \\\\\n% Experiment: &\n&\nM.~Lestinsky {\\it et al}. \\cite{les:EGAS} &\n       &    &\n       44.&3096(4) \\\\\n%\n\\hline\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\begin{table}\n\\label{tab:hfs}\n\\caption{\nIndividual contributions to the ground-state hyperfine splitting of lithiumlike scandium, in meV.\nComparison with the available theoretical and experimental values in terms of the wavelength\n$\\lambda$ is presented.\n}\n\\linespread{1}\n\\begin{center}\n\\begin{tabular}{lr|r@{}l}\n\\hline\n\\hline\nDirac value                                      &$A(\\aZ)$                 &   6.&9650     \\\\\nFinite-nuclear-size correction                   &$-\\delta A(\\aZ)$         &$-$0.&0224(3)  \\\\\nBohr-Weisskopf correction                        &$-\\eps A(\\aZ)(1-\\delta)$ &$-$0.&0064(32) \\\\\nInterelectronic interaction, $1/Z$               &$B(\\aZ)/Z$               &$-$0.&8817     \\\\\nInterelectronic interaction, $1/Z^2$ and higher  &$C(Z,\\aZ)/Z^2$           &   0.&0150(2)  \\\\\nQED (with screening)                             &$x_{\\rm rad}$            &$-$0.&0061(6)  \\\\\n\\hline\nTotal theory, this work                          &$\\Delta E_\\mu$           &   6.&0633(33) \\\\\n\\hline\nWavelength, this work                            &$\\lambda$                &   0.&020448(10) cm \\\\\nTheory: & Shabaev {\\it et al.} \\cite{shabaev:97}                           &   0.&020450(20) cm \\\\\n        & Boucard and Indelicato \\cite{boucard:00}                         &   0.&020403 cm     \\\\\nExperiment: & Lestinsky {\\it et al.} \\cite{les:HCI}                        &   0.&0200(7) cm \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n%\n%\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n\\begin{thebibliography}{99}\n%\n\\bibitem{madzunkov:PRA:02}\n% QED effects in lithiumlike krypton\nS.~Madzunkov, E.~Lindroth, N.~Ekl\\\"{o}w, M.~Tokman, A.~Pa\\'{a}l, and R.~Schuch,\nPhys. Rev. A {\\bf 65}, 032505 (2002).\n%\n\\bibitem{kieslich:PRA:04}\n% Determination of the 2s-2p excitation energy of lithiumlike\n% scandium using dielectronic recombination\nS.~Kieslich, S.~Schippers, W.~Shi, A.~M\\\"{u}ller, G.~Gwinner,\nM.~Schnell, A.~Wolf, E.~Lindroth, and M.~Tokman,\nPhys. Rev. A {\\bf 70}, 042714 (2004).\n%\n\\bibitem{les:EGAS}\n% Precision measurement of the radiative screening correction\n% and the hyperfine splitting in lithiumlike scandium\nM.~Lestinsky, E.~W.~Schmidt, D.~A.~Orlov, S.~Schippers,\nE.~Lindroth, A.~M\\\"{u}ller, and A.~Wolf,\nin the Book of Abstracts of the 38th conference of European Group for Atomic Systems (EGAS), 2006 (unpublished).\n%\n\\bibitem{les:HCI}\n% Hyperfine structure and QED shifts in dielectronic recombination of Li-like 45^Sc^18+\nM.~Lestinsky, E.~W.~Schmidt, D.~A.~Orlov, F.~Sprenger, C.~Brandau,\nE.~Lindroth, S.~Schippers, A.~M\\\"{u}ller, and A.~Wolf,\nin the Book of Abstracts of the 13th conference on the Physics of Highly Charged Ions (HCI), 2006 (unpublished).\n%\n\\bibitem{wolf:SPARC}\n%\nA.~Wolf, (unpublished).\n%\n\\bibitem{kim:PRA:91}\nY.-K.~Kim, D.~H.~Baik, P.~Indelicato, and J.~P.~Desclaux,\nPhys. Rev. A {\\bf 44}, 148 (1991).\n%\n\\bibitem{ADNDT87_185}\nI.~Angeli,\nAt. Data Nucl. Data Tables \\textbf{87}, 185 (2004).\n%\n\\bibitem{mohr:PREP:98}\nP.~J.~Mohr, G.~Plunien, and G.~Soff,\nPhys. Rep. {\\bf 293}, 227 (1998).\n%\n\\bibitem{PRA58_954}\nT.~Beier, P.~J.~Mohr, H.~Persson, and G.~Soff,\nPhys. Rev. A \\textbf{58}, 954 (1998).\n%\n\\bibitem{PRA46_4421}\nP.~J.~Mohr,\nPhys. Rev. A \\textbf{46}, 4421 (1992).\n%\n\\bibitem{yerokhin:SESE}\nV.~A.~Yerokhin, P.~Indelicato, and V.~M.~Shabaev,\nPhys. Rev. Lett. \\textbf{91}, 073001 (2003);\nEur. Phys. J. D {\\bf 25}, 203 (2003);\nPhys. Rev. A {\\bf 71}, 040101(R) (2005).\n%\n\\bibitem{yerokhin:PRL:06}\nV.~A.~Yerokhin, P.~Indelicato, and V.~M.~Shabaev,\nPhys. Rev. Lett. \\textbf{97}, 253004 (2006).\n%\n\\bibitem{RPM77_000001}\nP.~J.~Mohr and B.~N.~Taylor,\nRev. Mod. Phys. \\textbf{77}, 1 (2005).\n%\n\\bibitem{PRA72_062102}\nU.~D.~Jentschura, A.~Czarnecki, and K.~Pachucki,\nPhys. Rev. A \\textbf{72}, 062102 (2005).\n%\n\\bibitem{yerokhin:PRA:99}\nV.~A.~Yerokhin, A.~N.~Artemyev, T.~Beier, G.~Plunien, V.~M.~Shabaev, and G.~Soff,\nPhys. Rev. A \\textbf{60}, 3522 (1999).\n%\n\\bibitem{yerokhin:OS:05}\nV.~A.~Yerokhin, A.~N.~Artemyev, V.~M.~Shabaev, G.~Plunien, and G.~Soff,\n%physics/0411247\nOpt. Spectrosc {\\bf 99}, 12 (2005).\n%\n\\bibitem{PRA60_45}\nA.~N.~Artemyev, T.~Beier, G.~Plunien, V.~M.~Shabaev, G.~Soff, and V.~A.~Yerokhin,\nPhys. Rev. A \\textbf{60}, 45 (1999).\n%\n\\bibitem{PRA67_062506}\nA.~N.~Artemyev, V.~M.~Shabaev, M.~M.~Sysak, V.~A.~Yerokhin, T.~Beier, G.~Plunien,\nand G.~Soff,\nPhys. Rev. A \\textbf{67}, 062506 (2003).\n%\n\\bibitem{PRA64_032109}\n% physics/0411247 [8]\nV.~A.~Yerokhin, A.~N.~Artemyev, V.~M.~Shabaev, M.~M.~Sysak, O.~M.~Zherebtsov,\nand G.~Soff,\nPhys. Rev. A \\textbf{64}, 032109 (2001).\n%\n\\bibitem{PRA68_022511}\n% Relativistic calculations of isotope shifts in highly charged ions\nI.~I.~Tupitsyn, V.~M.~Shabaev, J.~R.~Crespo L\\'opez-Urrutia, I.~Dragani\\'c, R.~Soria Orts, and J.~Ullrich,\nPhys. Rev. A {\\bf 68}, 022511 (2003).\n%\n\\bibitem{PRA72_062503}\n% Magnetic-dipole transition probabilities in B-like and Be-like ions\nI.~I.~Tupitsyn, A.~V.~Volotka, D.~A.~Glazov, V.~M.~Shabaev, G.~Plunien,\nJ.~R.~Crespo~L\\'opez-Urrutia, A.~Lapierre, and J.~Ullrich,\nPhys. Rev. A {\\bf 72}, 062503 (2005).\n%\n\\bibitem{shabaev:PRA:98}\n% QED theory of the nuclear recoil effect in atoms\nV.~M.~Shabaev,\nPhys. Rev. A {\\bf 57}, 59 (1998); Phys. Rep. {\\bf 356}, 119 (2002).\n%\n\\bibitem{artemyev:PRA:95}\n% Relativistic nuclear recoil corrections to the energy levels of hydrogenlike and high-Z lithiumlike atoms in all orders in aZ\nA.~N.~Artemyev, V.~M.~Shabaev, and V.~A.~Yerokhin,\nPhys. Rev. A {\\bf 52}, 1884 (1995).\n%\n\\bibitem{JPB28_5201}\nA.~N.~Artemyev, V.~M.~Shabaev, and V.~A.~Yerokhin,\nJ. Phys. B \\textbf{28}, 5201 (1995).\n%\n\\bibitem{pl:suckewer80}\nS. Suckewer, J. Cecci, S. Cohen, R. Fonck, and E. Hinnov,\nPhys. Lett. A {\\bf 80}, 259 (1980).\n%\n\\bibitem{shabaev:91}\nJ.~Epstein and S.~Epstein,\nAm. J. Phys.  {\\bf 30}, 266 (1962);\nV.~M.~Shabaev,\nJ. Phys. B {\\bf 24}, 4479 (1991).\n%\n\\bibitem{shabaev:94}\nV.~M.~Shabaev,\nJ. Phys. B {\\bf 27}, 5825 (1994).\n%\n\\bibitem{shabaev:pra:97}\nV.~M.~Shabaev, M.~Tomaselli, T.~K\\\"{u}hl, A.~N.~Artemyev, and V.~A.~Yerokhin,\nPhys. Rev. A {\\bf 56}, 252 (1997).\n%\n\\bibitem{shabaeva:95}\nM.~B.~Shabaeva and V.~M.~Shabaev,\nPhys. Rev. A {\\bf 52}, 2811 (1995).\n%\n\\bibitem{shabaev:04:prl}\n% Dual Kinetic Balance Approach to Basis-Set Expansions for the Dirac Equation\nV.~M.~Shabaev, I.~I.~Tupitsyn, V.~A.~Yerokhin, G.~Plunien, and G.~Soff,\nPhys. Rev. Lett. {\\bf 93}, 130405 (2004).\n%\n\\bibitem{zherebtsov:00}\nO.~M.~Zherebtsov and V.~M.~Shabaev,\nCan. J. Phys. {\\bf 78}, 701 (2000).\n%\n\\bibitem{tup:02}\nI.~I.~Tupitsyn, A.~V.~Loginov, and V.~M.~Shabaev,\nOpt Spectrosc, {\\bf 93}, 357 (2002).\n%\n\\bibitem{slater}\nJ.~C.~Slater,\nPhys. Rev. {\\bf 81}, 385 (1951).\n%\n\\bibitem{kohn-sham}\nW.~Kohn and L.~J.~Sham,\nPhys. Rev. {\\bf 140}, A1133 (1965).\n%\n\\bibitem{latter}\nR.~Latter,\nPhys. Rev. {\\bf 99}, 510 (1955).\n%\n\\bibitem{glazov:pla:06}\nD.~A.~Glazov, A.~V.~Volotka, V.~M.~Shabaev, I.~I.~Tupitsyn, and G.~Plunien,\nPhys. Lett. A {\\bf 357}, 330 (2006).\n%\n\\bibitem{sapirstein:03}\n% Calculation of radiative corrections to hyperfine splittings in the neutral alkali metals\nJ.~Sapirstein and K.~T.~Cheng,\nPhys. Rev. A  {\\bf 67}, 022512 (2003).\n%\n\\bibitem{shabaev:97}\nV.~M.~Shabaev, M.~B.~Shabaeva, and I.~I.~Tupitsyn,\nAstron. Astrophys. Trans. {\\bf 12}, 243 (1997).\n%\n\\bibitem{boucard:00}\nS.~Boucard and P.~Indelicato, Eur. Phys. J. D {\\bf 8}, 59 (2000).\n%\n\\end{thebibliography}\n%\n\\end{document}", "meta": {"hexsha": "0cd7e6043e02917e462c08fdbda3a16d38331315", "size": 29299, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "benchmark/src/with-lang/0704.2822.tex", "max_stars_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_stars_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-23T19:07:01.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-23T19:07:01.000Z", "max_issues_repo_path": "benchmark/src/with-lang/0704.2822.tex", "max_issues_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_issues_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/src/with-lang/0704.2822.tex", "max_forks_repo_name": "e-sim/pdf-text-extraction-benchmark", "max_forks_repo_head_hexsha": "42eede9867e5795a6fc040b0a7ce92da3ddd3120", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.4865229111, "max_line_length": 127, "alphanum_fraction": 0.6806034336, "num_tokens": 9584, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4072060118749125}}
{"text": "\\chapter{Assignment-Probability solutions}\n\\begin{enumerate}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\text{Total number of ways }&=4 \\times 4 \\times 4\\\\\n\t\t\\text{Number of preferred outcome }&=4 \\times 3 \\times 3\n\t\t\\intertext{( $\\because$ Any four option in step- 1 and only 3 option in step $2 \\& 3$ because he can not go to previous position)}\n\t\t\\text{Probability }&=\\frac{4 \\times 3 \\times 3}{4 \\times 4 \\times 4}=\\frac{9}{16}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (a)}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{After transferring balls from basket I into II, there can be either (a) 5 red and 3 blue or (b) 4 red and 4 blue balls in the second basket.}\n\t\t\\text{Probability that the ball transferred is blue }&=\\frac{4}{7}\\\\\n\t\t\\text{Probability that the ball transferred is red }&=\\frac{3}{7}\n\t\t\\intertext{Hence probability of drawing a blue ball from basket II}\n\t\t=\\frac{4}{7} \\times \\frac{4}{8}+\\frac{3}{7} \\times \\frac{3}{8}&=\\frac{25}{56}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (d)}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\because \\text{ Since, }f(x)&=x e^{-x / \\lambda},\\text{ therefore}\\\\\n\t\t\\langle x\\rangle&=\\frac{\\int_{-\\infty}^{\\infty} x f(x) d x}{\\int_{-\\infty}^{\\infty} f(x) d x}=\\frac{\\int_{0}^{\\infty} x \\cdot x e^{-\\frac{x}{\\lambda}} d x}{\\int_{0}^{\\infty} x e^{-\\frac{x}{\\lambda}} d x} \\Rightarrow \\frac{\\int_{0}^{\\infty} x^{2} e^{\\frac{-x}{\\lambda}} d x}{\\int_{0}^{\\infty} x e^{\\frac{-x}{\\lambda}} d x}=2 \\lambda\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (b)}\n\t\\end{answer}\n\t\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\color{red}{??}\\\\\n\t\tN&=30, m=10\n\t\t\\end{align*}\n\t\t\tSo the correct answer is \\textbf{Option (a)}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{Case I: Four steps in $x$-axis}\n\t\t\\text{Two steps in }&+x\\text{ and two steps in }-x\\\\\n\t\t\\therefore\\text{ probability }&=^{4} c_{2} \\times\\left(\\frac{1}{4}\\right)^{2}\\left(\\frac{1}{4}\\right)^{2}=\\frac{6}{4^{4}}\n\t\\intertext{\tCase II: Four steps in $y$ - axis}\n\t\t\\text{Two steps in }&+y\\text{ and two steps in }-y\\\\\n\t\t\\therefore\\text{ probability }&={ }^{4} c_{1} \\times{ }^{2} c_{1}\\left(\\frac{1}{4}\\right)^{2}\\left(\\frac{1}{4}\\right)^{2}=\\frac{6}{4^{4}}\\\\\n\t\t\\text{Case 3: Two steps in }&+x\\text{ and two steps in $-y$ axis}\\\\\n\t\t\\Rightarrow\\text{ One step in each }&+x,-x,+y \\&-y\\\\\n\t\t\\therefore \\text { probability }&={ }^{2} c_{1} \\times{ }^{2} c_{2}\\left(\\frac{1}{4}\\right)^{4}=\\frac{4}{4^{4}}\\\\\n\t\t\\therefore\\text{ probability }&={ }^{2} c_{1} \\times{ }^{2} c_{2}\\\\ \\therefore\\text{ Answer }&=\\frac{16}{4^{4}}=\\frac{1}{16}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (c)}\n\t\\end{answer}\n\t\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{The probability that the random variable takes the value between 2 and 4 is}\n\t\t\\int_{2}^{4} f(x) d x&=\\int_{2}^{4} k x^{2} d x=\\frac{k}{3}\\left[x^{3}\\right]_{2}^{4}=\\frac{k}{3} \\times 56=\\frac{56 k}{3}\\\\\n\t\t\\text{since }\\int_{-\\infty}^{\\infty} f(x) d x&=1 \\Rightarrow \\int_{1}^{5} k x^{2} d x=1\\\\\n\t\t\\text{Thus }\\frac{k}{3}\\left[x^{3}\\right]_{1}^{5}&=1 \\Rightarrow \\frac{124 k}{3}=1 \\Rightarrow k=\\frac{3}{124}\\\\\n\t\\text{\tHence required probability }&=\\frac{56}{3} \\times \\frac{3}{124}=\\frac{14}{31}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (b)}\n\t\\end{answer}\n\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\int_{-1}^{1} f(x) d x&=1 \\Rightarrow c=\\frac{3}{2}\\\\\n\t\tE(x)&=\\int_{-1}^{1} x f(x) d x=0 \\quad E\\left(x^{2}\\right)=\\int_{-1}^{1} x^{2} f(x) d x=\\frac{3}{5}\\\\\n\t\t\\operatorname{var}(x)&=E\\left(x^{2}\\right)-[E(x)]^{2}=\\frac{3}{5}\\\\\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (a)}\n\t\\end{answer}\n\t\t\\item $\\left. \\right. $\n\t\\begin{answer}\n\t\t\\begin{align*}\n\t\t\\intertext{Experiment I: The probability of getting a doublet in a single throw $=\\frac{6}{36}=\\frac{1}{6}$}\n\t\t\\text{probability of not getting }&\\text{a doublet in a single throw } =1-\\frac{1}{6}=\\frac{5}{6}.\\\\\n\t\t\\text{Hence, the probability of getting }&\\text{a doublet on 5 throws }=6 c_{5}\\left(\\frac{1}{6}\\right)^{5} \\times \\frac{5}{6}\\\\\n\t\t&=6\\left(\\frac{1}{6}\\right)^{5}\\left(\\frac{5}{6}\\right)=\\frac{5}{6^{5}}\n\t\t\\intertext{Experiment II: The probability of getting a head in a single throw $=\\frac{1}{2}$}\n\t\t\\text{The probability of not getting a head }&=1-\\frac{1}{2}=\\frac{1}{2}\n\t\t\\intertext{Hence, probability of getting 4 heads in six tosses of a coin}\n\t\t&={ }^{6} c_{4}\\left(\\frac{1}{2}\\right)^{4}\\left(\\frac{1}{2}\\right)^{2}=\\frac{15}{2^{6}}\\\\\n\t\tP_{1}&=\\frac{5}{6^{5}}, P_{2}=\\frac{15}{2^{6}}\\\\\n\t\t\\therefore \\frac{P_{1}}{P_{2}}&=\\frac{5}{2^{5} \\times 3^{5}} \\times \\frac{2^{6}}{5 \\times 3}=\\frac{2}{3^{6}}\n\t\t\\end{align*}\n\t\tSo the correct answer is \\textbf{Option (d)}\n\t\\end{answer}\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\\end{enumerate}", "meta": {"hexsha": "4f40d6118acda69cc443a009f0bb6bd6d2fb8619", "size": 4915, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "CSIR- Mathematical Physics/chapter/Assignments/Assignment-Probability Solutions.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CSIR- Mathematical Physics/chapter/Assignments/Assignment-Probability Solutions.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CSIR- Mathematical Physics/chapter/Assignments/Assignment-Probability Solutions.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6525423729, "max_line_length": 333, "alphanum_fraction": 0.6034587996, "num_tokens": 2026, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4072060091842571}}
{"text": "%% USEFUL LINKS:\n%% -------------\n%%\n%% - UiO LaTeX guides:          https://www.mn.uio.no/ifi/tjenester/it/hjelp/latex/\n%% - Mathematics:               https://en.wikibooks.org/wiki/LaTeX/Mathematics\n%% - Physics:                   https://ctan.uib.no/macros/latex/contrib/physics/physics.pdf\n%% - Basics of Tikz:            https://en.wikibooks.org/wiki/LaTeX/PGF/Tikz\n%% - All the colors!            https://en.wikibooks.org/wiki/LaTeX/Colors\n%% - How to make tables:        https://en.wikibooks.org/wiki/LaTeX/Tables\n%% - Code listing styles:       https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings\n%% - \\includegraphics           https://en.wikibooks.org/wiki/LaTeX/Importing_Graphics\n%% - Learn more about figures:  https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions\n%% - Automagic bibliography:    https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management  (this one is kinda difficult the first time)\n%%\n%%                              (This document is of class \"revtex4-1\", the REVTeX Guide explains how the class works)\n%%   REVTeX Guide:              http://www.physics.csbsju.edu/370/papers/Journal_Style_Manuals/auguide4-1.pdf\n%%\n%% COMPILING THE .pdf FILE IN THE LINUX IN THE TERMINAL\n%% ----------------------------------------------------\n%%\n%% [terminal]$ pdflatex report_example.tex\n%%\n%% Run the command twice, always.\n%%\n%% When using references, footnotes, etc. you should run the following chain of commands:\n%%\n%% [terminal]$ pdflatex report_example.tex\n%% [terminal]$ bibtex report_example\n%% [terminal]$ pdflatex report_example.tex\n%% [terminal]$ pdflatex report_example.tex\n%%\n%% This series of commands can of course be gathered into a single-line command:\n%% [terminal]$ pdflatex report_example.tex && bibtex report_example.aux && pdflatex report_example.tex && pdflatex report_example.tex\n%%\n%% ----------------------------------------------------\n\n\n\\documentclass[english,notitlepage,reprint,nofootinbib]{revtex4-1}  % defines the basic parameters of the document\n% For preview: skriv i terminal: latexmk -pdf -pvc filnavn\n% If you want a single-column, remove \"reprint\"\n\n% Allows special characters (including æøå)\n\\usepackage[utf8]{inputenc}\n% \\usepackage[english]{babel}\n\n%% Note that you may need to download some of these packages manually, it depends on your setup.\n%% I recommend downloading TeXMaker, because it includes a large library of the most common packages.\n\n\\usepackage{physics,amssymb}  % mathematical symbols (physics imports amsmath)\n\\include{amsmath}\n\\usepackage{graphicx}         % include graphics such as plots\n\\usepackage{xcolor}           % set colors\n\\usepackage{hyperref}         % automagic cross-referencing\n\\usepackage{listings} % display code\n\\usepackage{subfigure}        % imports a lot of cool and useful figure commands\n% \\usepackage{float}\n%\\usepackage[section]{placeins}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{booktabs}\n\\usepackage{subfigure}\n\\usepackage{tikz}\n\\usepackage{mathtools}\n\\usepackage{nccmath}\n\\usetikzlibrary{quantikz}\n\\parskip=5pt plus 1pt\n\\usepackage{xurl}\n% defines the color of hyperref objects\n% Blending two colors:  blue!80!black  =  80% blue and 20% black\n\\hypersetup{ % this is just my personal choice, feel free to change things\n    colorlinks,\n    linkcolor={red!50!black},\n    citecolor={blue!50!black},\n    urlcolor={blue!80!black}}\n\n% ===========================================\n\n\n\\begin{document}\n\n\\title{\\LARGE{Project 2: Feed Forward Neural Network}\\\\\n  \\large Classification and Regression, from linear and \\\\ logistic regression to neural networks}\n\\author{Adele Zaini}\n\\thanks{GitHub profile: \\href{https://github.com/adelezaini/}{ https://github.com/adelezaini/}}\n\\date{November 20, 2021}                             % self-explanatory\n\\noaffiliation                            % ignore this, but keep it.\n\n\\maketitle\n\\section{Abstract}\n\nAn implementation of a Neural Network, as Deep Learning technique, is presented. It is explored in comparison with regression methods, such as Linear and Logistic Regression, in order to appreciate the advantages of this alternative technique. Due to its architecture divided into several layers, the Neural Network can indeed lead to important improvements into the non-linear field and a good efficiency in the operations. In the present work optimizations of the related algorithm of the Stochastic Gradient Descent (SGD) and the parametrization of the network are explored. For the SGD implementation, the Ordinary Least Square (OLS) Regression shows an optimized performance for a learning rate of $10^{-5}$, $12$ minibatches and $150$ epochs, while the Ridge Regression has as optimal parameters $50$ minibatches, $150$ epochs and the two hyperparameters $\\lambda = 1.87\\ 10^{-4}$ and $\\eta = 4.33 \\ 10^{-4}$. In the Regression case, the Neural Network best performs with $\\eta=0.001$ and $\\lambda \\in [10^{-12},0.001]$, while in the Classification case it has a good flexibility on the parameters choice, but the accuracy score never exceeds the threshold of $41\\%$. While the choice of the activation function does not influence much the performance of the network, the architecture setting can lead to interesting variations. The optimal performance is found choosing few hidden layers with the number of neurons that starts close to the input size and approaches progressively the output size. \n\n% ===========================================\n\\section{Introduction}\nThe neural network, also known as artificial neural network, is a subset of machine learning techniques and is at the heart of Deep Learning algorithms. Its name and structure is inspired by the human brain, mimicking the way that biological neurons interact to one another. The very powerful point of this technique is that it can explore new ways of analysing and interpreting data, that are limited by the classical methods, such as regression ones. \n\nIn this report, we will implement a Feed Forward Neural Network with backpropagation and Stochastic Gradient Descent (SGD) in Python. We will firstly concentrate on a preliminary step for the implementation that is the optimization technique of SGD. Afterwards the focus is on the implementation of the Neural Network class both in the Regression and Classification cases, while exploring the optimization of different hyperparameters and network architectures. Comparisons with Linear and Logistic Regression will be performed to check the results.\n\nThe report is organized as follows. After this introduction, the methods are explored considering the background theory and the algorithms implemented. The following section will present the results of the work, while commenting and discussing them. The final section is to summarize the analysis into the conclusions and to have an overview on future perspective.\n\n\n    \n% ===========================================\n\n\\section{Methods} \\label{sec:methods}\n\\subsection{Theory and algorithms} \\label{sec:theory}\n\nThe basic idea of Neural Network lies on building a system of interconnected units, called \\textit{neurons}, divided in multiple layers, that broadcast signals throughout the neural system. The structure is composed of an input layer, one or more hidden layers, with different number of neurons in each of them, and the output layer. The broadcasting of the signal happens thanks to \\textit{activation functions} that elaborate the input signals for each neuron into the ouput ones. They are coupled with weights and biases associated to each neuron so that the output is more or less relevant when broadcasted to the next layer. This process starts from the input layer and it runs thoughtout each neuron of each layer, until resulting into an output layer, that is the model prediction (i.e.\\textit{Feed Forward Neural Network}). The next step is to \\textit{train} the network. Given already the expected \\textit{true} output, it is compared to the model prediction thanks to a \\textit{cost function} that evaluates the performance of the model. The aim is to minimize this value and using the \\textit{backpropagation} and Stochastic Gradient Descent algorithms, is possibile to optimize the parameters (i.e. weights and biases) to have the closest result to the expected one. This last step is extremely important because then the network is able to \\textit{predict} the results given any other input data. The overall performance of the network is evaluated thanks to the \\textit{metrics} on a test dataset.\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.5]{neural_network_structure.png}\n    \\caption{Examples of Neural Network architecture, with several neurons divided into the hidden layers and with a focus on one single neuron and its schematic operation.}\n    \\label{fig:nn}\n\\end{figure}\n\\textbf{Feed Forward Neural Network} – \nThe key idea of this type of Neural Network is that the information moves in only one direction: forward through the layers. As depicted in Figure \\ref{fig:nn}, each single neuron has $\\{x_i\\}$ as input data, which is linearly combined  with the respective weights $\\{w_i\\}$ and biases $\\{b_i\\}$ (it can be a single value for all the neurons of the layer or different values): $z=\\sum_i (w_i x_i + b_i)$ .\n\nThe output $y$ is produced via the activation function $f$ as follows:\n\\begin{equation}\ny = f\\left(\\sum_{i=1}^n w_ix_i + b_i\\right) = f(z),\n\\end{equation}\n\nIn a dense FFNN with multiple neurons and hidden layers, the inputs $\\{x_i\\}$ are the outputs of\nthe neurons in the preceding layer, and the output $y$ is one of the inputs for the next layer. At the end, the equation results to be:\n\n%\\begin{equation}\n\\begin{multline}\n    y^{L+1}_i = f^{L+1}\\left[\\!\\sum_{j=1}^{N_L} w_{ij}^3 f^L\\left(\\sum_{k=1}^{N_{L-1}}w_{jk}^{L-1}\\left(\\dots \\\\ f^1\\left(\\sum_{n=1}^{N_0} w_{mn}^1 x_n+ b_m^1\\right)\\dots\\right)+b_k^2\\right)+b_1^3\\right] \n    \\label{completeNN} \\tag{14}\n\\end{multline}\n%\\end{equation}\n\nwhere $L$ is the number of hidden layers.\n\n\\textbf{Back propagation} – \nThe back propagation is the core algorithm behind how neural networks learn. After a first forward run thoughout the network, to have the first attempt of a prediction, the network needs to be trained. In other words, it means that the parameters (i.e. weights and biases) need to be optimized to minimize the cost function, which quantifies the difference between the model output and the expected output values.\n\nThe idea behind this algorithm is to go back thoughout the network, layer by layer, using the \\textit{chain rule} to find the optimal parameters. This algorithm can be coupled with different optimization techniques that evaluate the partial derivatives for the chain rule.\n\nThe starting point is at the end of the network: evaluating the total error $\\hat{\\delta}^L$ of the output layer by computing all $\\delta_j^L$ for each outputs:\n$$\n\\delta_j^L = f'(z_j^L)\\frac{\\partial {\\cal C}}{\\partial (a_j^L)}.\n$$\n\nThen the back propagate error is computed for each $l=L-1,L-2,\\dots,2$ layer as\n\n$$\n\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l).\n$$\n\nFinally, the weights and the biases are updated using an optimization tecnique for each $l=L-1,L-2,\\dots,2$, such as the \\textit{Gradient Descent} algorithm or one of its variant:\n$$\nw_{jk}^l\\leftarrow  = w_{jk}^l- \\eta \\delta_j^la_k^{l-1},\n$$\n$$\nb_j^l \\leftarrow b_j^l-\\eta \\frac{\\partial {\\cal C}}{\\partial b_j^l}=b_j^l-\\eta \\delta_j^l,\n$$\nwhere $\\eta$ is the learning rate.\n\nThe backpropagation is an algorithm for determining how a single training example would like to nudge the weights and biases, in terms of what relative proportions to those changes cause the most rapid decrease to the cost function. But this algorithm needs to be run over all the examples (i.e. datapoints for the Regression case and digits/images for the Classification case), this is why it is convenient to use \\textit{Stochastic Gradient Descent} with mini-batches with an outer loop that steps through multiple epochs of training (see below).\n\n\\textbf{Activation functions} – \nThe choice of the activation functions is a key element in the performance of the network. The classical choice is the \\textit{sigmoid} function:\n$$\nf(x) = \\frac{1}{1 + e^{-x}},\n$$\nbut in the past it has been shown its limits for large input values (i.e. \\textit{vanishing gradient problem} in applying the back propagation algorithm). Other choices can be: \\textit{hyperbolic tangent}, \\textit{ReLU (Rectified exponential Linear Unit)}, \\textit{eLU (exponential Linear Unit)}, \\textit{Leaky ReLU}...\n\nFor the output layer the most common activation function is the \\textit{softmax}:\n$$\nf(z_i) = \\frac{e^{z_i}}{\\sum_{j=1}^K e^{z_j}}.\n$$\nWhile in the Regression case, no activation function is needed for the output layer.\n\n\\textbf{Cost function and metrics}  – \nThe \\textbf{cost function} (or loss function) is a method of evaluating how well the neural network fits the dataset or, in other words, it quantifies the error between the predicted output values and the expected ones. It is used to in the training process to optimize the paramaters in order the get to the minimum of this function. Depending on the problem, the cost function can have different expressions. The most common choice for the regression and the classification case are the Mean Squared Error (MSE) and the Cross-Entropy loss (CE) respectively.\n\n$$\nMSE(y,\\hat{y}) = \\frac{1}{n}\n\\sum_{i=0}^{n-1}(y_i-\\hat{y}_i)^2,\n$$\nwhere $\\hat{y}_i$ is the predicted value of the $i-th$ sample, $y_i$ is the corresponding true value and $n$ is the total number of datapoints.\n\n$$\nCE = -\n\\sum_{c=1}^{M}(y_c \\ \\mathsym{log}(p_c)\n$$\n\nwhere $y_c$ is the binary indicator (0 or 1) if the class label $c$ is the correct classification label, $p_c=$ is the predict probability of the class $c$ (i.e. output value before filtered by the output activation function).\n\nThe \\textbf{metrics} is a function that evaluates the overall performance of the neural network. It's a similar concept to the cost function, but while the cost function is used on the training dataset to optmize the neural network parameters (i.e. it quantifies the \\textit{in-sample error}), the metrics is used on test datasets at the end of the training process (i.e. it quantifies the \\textit{out-of-sample error}). There are different expressions for the metrics too. For the regression and the classification cases, the MSE and the Accurancy score are the most in use.\n$$\n\\text{Accuracy} = \\frac{\\sum_{i=1}^n I(t_i = y_i)}{n} ,\n$$\n\nHere $t_i$ represents the target, $y_i$ the outputs of the FFNN code, $n$ is the number of targets $t_i$ and $I$ is the indicator function: $1$ if $t_i = y_i$ and $0$\notherwise.\n\n\\textbf{Gradient Descent and Stochastic Gradient Descent} – \nThe Gradient Descent (GD) is an optimization technique and the most common way to train neural networks. It is an algorithm to minimize an objective function (i.e. cost function $C(\\mathbf{\\beta})$) parameterized by model's parameters $\\beta$ by updating the parameters in the opposite direction of the gradient of the objective function $\\gradient_{\\beta} C(\\mathbf{\\beta})$ to the parameters. It is based on the \\textit{Newton-Raphson's method}, an approximation to the first order of the Taylor expansion, where the learning rate $\\eta$ (i.e. inverse of the second derivative) determines the size of the steps we take to reach a (local) minimum. It is possible to demonstrate that in the matrix notation the optimal value of the learning rate is $\\hat{\\eta}=1 / \\lambda_{max}$, where $\\lambda_{max}$ is the maximum eigenvalue of the Hessian matrix, so that it grants convergence and efficiency in the iterations. In other words, iterating this \"parameters update\", we follow the direction of the slope of the surface created by the objective function downhill until we reach a valley (Figure \\ref{fig:sgd}).\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.2]{SGD.png}\n    \\caption{Intuitive idea of the Gradient Descent optimization when updating the parameters.}\n    \\label{fig:sgd}\n\\end{figure}\nNevertheless, the Gradient Descent algorithm represents limitations connected to its characteristic of being very precise. These concerns its low efficiency and its high dependence on initial conditions that leads to be trapped in local minima. In order to improve this algorithm, \"randomness\" needs to be included and the way is to implement the Stochastic Gradient Descent (SGD). While in the GD the gradient is evaluated from the entire dataset, in the SGD it is calculated from a randomly selected subset of the data, called \\textit{mini-batch} (Figure \\ref{fig:gd_sgd}). The \\textit{mini-batches} are embedded in an iteration loop over the number of \\textit{epochs}.\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.1]{GD_SGD.jpg}\n    \\caption{Difference of optimization paths over a two-dimensional surface: a) precise and inefficient Gradient Descent (left) and b) random and efficiency Stochastic Gradient Descent (right).}\n    \\label{fig:gd_sgd}\n\\end{figure}\n\n\\textbf{Optimizers} – There are variants of the optimization algorithms, such as SGD with momentum, AdaGrad, RMSprop, ADAM.\n\n1. \\textit{Gradient Descent}:\n$$\n\\beta \\leftarrow \\beta -\\eta \\ \\gradient C(\\beta)\n$$\n\n2. \\textit{Gradient Descent with momentum}:\n$$\n\\begin{array}{c}\nv \\leftarrow \\gamma v + \\eta \\ \\gradient C(\\beta) \\\\\n\\beta \\leftarrow \\beta - v\n\\end{array}\n$$\nwhere $\\gamma$ is the \\textit{drag} parameter, commonly set to $\\gamma = 0.9$.\n\n3. \\textit{AdaGrad}:\n$$\n\\begin{array}{c}\nr \\leftarrow r + g \\odot g \\\\\n\\beta \\leftarrow \\beta -\\frac{\\eta}{\\sqrt{r+\\delta}} \\odot g\n\\end{array}\n$$\nwhere $g=\\gradient C(\\beta)$, $\\odot$ is the \\textit{Hadamard product} or element-wise product and $\\delta\\sim10^{-8}$ is a parameter to avoid division by $0$.\n\n4. \\textit{RMSprop}:\n$$\n\\begin{array}{c}\nr \\leftarrow \\rho r + (1-\\rho) g \\odot g \\\\\n\\beta \\leftarrow \\beta -\\frac{\\eta}{\\sqrt{r+\\delta}} \\odot g\n\\end{array}\n$$\nwhere $\\rho$ is usually set to $0.9$.\n\n5. \\textit{ADAM}:\n$$\n\\begin{array}{c}\n\\hat{m} \\leftarrow [\\beta_1 m + (1-\\beta_1) g] / (1-\\beta_1) \\\\\n\\hat{v} \\leftarrow [\\beta_2 v + (1- \\beta_2) g^2] / (1-\\beta_2) \\\\\n\\beta \\leftarrow \\beta -\\frac{\\eta}{\\sqrt{\\hat{v}+\\delta}} \\odot \\hat{m}\n\\end{array}\n$$\nwhere $\\beta_1 \\sim 0.9$ and $\\beta_2 \\sim 0.999\n$.\n\nMoreover, the \\textbf{learning rate} can be chosen as \\textit{constant} value, but it can also have different \\textit{learning schedules} that make the learning rate decrease during the iteration process. In this work two \\textit{learning schedules} have been implemented:\n\\begin{enumerate}\n    \\item $\\eta(t) = t_0 / (t+t_1)$\n    \\item $\\eta(t) = \\eta_0 / t^{p_t}$, where $p_t \\sim 0.25$\n\\end{enumerate}\nwhere $t$ is the iteration counter.\n% ===========================================\n\\subsection{Code implementation}\\label{sec:code}\nThe algorithms previously explained have been implemented in a class called \\texttt{NeuralNetwork}. When initializing the class, the architecture (i.e. list of neurons and activation functions for each hidden layer) and parameters (e.g. learning rate, optimizer...) are set. The default architecture sees one hidden layer with two neurons and the  \\textit{sigmoid} as activation function. If the number of hidden layers (i.e. lenght of the list of neurons) is higher than one and the activation list is composed by a single element, the class automatically set that function as the activation for each hidden layer, otherwise different activation functions can be set for different hidden layers. The activation function of the output layer is set to \\texttt{None} in the regression case and \\texttt{softmax} in the classification case. Exceptions are thrown if the input arguments do not meet the requirements (e.g. the activation function is not in the list of the implemented ones).\n\nThe core of the class is the \\texttt{fit()} method, which receives \\texttt{X} and \\texttt{Y} as arguments, initializes the weights and the biases with the normal distribution $\\mathsym{N}(0,n)$ (where $n$ is the number of inputs to the neuron, number of neurons of the previous layer) and trains the network. It returns the network trained and ready to predict outputs from any input dataset (\\texttt{predict()} method).\n\nThe following picture shows the class structure and sequential and embedded operations in a schematic way:\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.23]{FFNN.pdf}\n    \\caption{\\texttt{\\textbf{class} NeuralNetwork}: structure and methods.}\n    \\label{fig:ffnn}\n\\end{figure}\n\nThe duties of the methods are:\n\\begin{itemize}\n    \\item[–] \\texttt{\\_\\_init\\_\\_()}: initialize the NN in terms of architecture (layers, neurons, activations functions) of the network and all the parameters needed for the backpropagation and the optimization algorithms.\n    \\item[–] \\texttt{fit()}: fit the network with the given input X and output Y and initialize layers, parameters and train the network.\n    \\item[–] \\texttt{init\\_parameters()}: initialize the weights and the biases in the given architecture (i.e. [2,4,3,2] as list of number of neurons), using a normal distribution.\n    \\item[–] \\texttt{feed\\_forward()}: implements the Feed Forward algorithm\n    \\item[–] \\texttt{compute\\_cost()}: implement the cost function with optional regulation techniques 'l1' and 'l2'\n    \\item[–] \\texttt{cost\\_function()}: return the cost function specific to Regression or Classification case.\n    \\item[–] \\texttt{backpropagation()}: implement the backward propagation\n    \\item[–] \\texttt{learning\\_rate()}: update the learning rate when it is different than a given constant value. Different types of learning rate can be chosen.\n    \\item[–] \\texttt{update\\_opt\\_parameters()}: update parameters using gradient descent algorithm with the given optimizer.\n    \\item[-] \\texttt{train()}: the core algorithm of the NN object: 1) Feed Forward to arrive to the output layer; 2) Backpropagation to evaluate all the gradients for each example/feature; 3) Update parameters (weights and biases) according to the optimizer (throughout the examples/features); 4) All wrapped up in the stochastic part (i.e. epochs and mini batches) of the SGD algorithm.\n    \\item[-] \\texttt{predict()}: predicting values with the Feed Forward algorithm, to be used after training. The output depends on the Regression or Classification case.\n    \\item[-] \\texttt{model\\_performance():} implements the metrics specific for the Regression or Classification case.\n\\end{itemize}\n\nThis is the parent class of \\texttt{\\textbf{class NN\\_Regression}} and \\texttt{\\textbf{class NN\\_Classifier}}, which inherit all the methods, but the output activation function initialization, the cost function and the metrics implementations.\n\nThis class is coupled to another class: \\texttt{\\textbf{class} activations}. This is an abstract parent class, that defines two methods: \\texttt{eval(X)} and \\texttt{gradient(X)}. These methods are then implemented in each derivative class to evaluate the function result and the function gradient at a given \\texttt{X} respectively.\nThe following activations functions are implemented:\n\\texttt{sigmoid}, \\texttt{tanh}, \\texttt{elu}, \\texttt{relu}, \\texttt{leaky\\_relu}, \\texttt{softmax}. In order to use this class into the \\textttt{NeuralNetwork} one, a dictionary was created to collect the derivative classes and the usage is the following:\n\n\\begin{verbatim}\n# Dictionary:\nACTIVATIONS = {'sigmoid': sigmoid, 'tanh': tanh,\n    'relu': relu, 'leaky_relu': leaky_relu, \n    'elu': elu, 'softmax': softmax, None: None}\n    \n# Choose the activation functions in the NN layers:\nactivations_list = ['sigmoid','relu']\n    ...\n# In the Feed Forward loop over hidden layers (l):\nact_func = ACTIVATIONS[activations_list[l]] \nAl = act_func(Zl, alpha).eval()\n\n# When updating the paramters with the \noptimization technique:\nact_func = ACTIVATIONS[activations_list[l]] \nAl = act_func(Zl, alpha).gradient()\n\\end{verbatim}\n\nFor any further information, the GitHub repository (\\href{https://github.com/adelezaini/MachineLearning/Projects/Project2}{https://github.com/adelezaini/MachineLearning}) contains all the source code with a detailed documentation.\n\n\\textbf{Neural Network Routine} After describing the class itself, we will focus briefly on the steps needed when using neural networks to solve supervised learning problems. The routine is the following:\n\n\\begin{enumerate}\n    \\item \\textit{Collect and pre-process data}: elaborate on the given input and output datasets in order to make them suitable for the Neural Network operations;\n    \\item \\textit{Define model architecture, choose cost function and optimizer}: initialize the Neural Network overall structure.\n    \\item \\textit{Initialize the model parameters}: weights and biases are initialized with a normal distribution;\n    \\item \\textit{Train the model with the training dataset}: in a loop of a certain number of epochs and mini-batches:\n    \\begin{itemize}\n        \\item[–] Calculate current loss (forward propagation)\n        \\item[–] Calculate current gradient (backpropagation)\n        \\item[–] Update paramaters (gradient descent or another optimization algorithm)\n    \\end{itemize}\n    \\item \\textit{Make prediction with the test data}: after the paramters are optimized;\n    \\item \\textit{Evaluate model performance and adjust hyperparameters}: analysis over the several paramters in order to find the minimum of the metrics of the model.\n\\end{enumerate}\n\n\\textbf{Linear Regression class}\nIn order to solve the first task and perform comparison with the Neural Network code, a class called \\texttt{LinearRegression}, and the derivative \\texttt{\\textbf{class} OLSRegression, RidgeRegression} and \\texttt{LassoRegression}, has been implemented from the code of project 1. Methods to evaluate the optimal $\\beta$ has been implemented for both the matrix-invertion evaluation and the Stocastic Gradient Descent algorithm, with the different optimizers previous exposed.\nHere is the list of the methods and their duties:\n\\begin{itemize}\n    \\item[–] \\texttt{\\_\\_init\\_\\_()}: create the object given the $X$ and $y$.\n    \\item[–] \\texttt{split()}: split the data into training and test subsets.\n    \\item[–] \\texttt{rescale()}: rescale the data using the \\texttt{StardardScaler} of Scikit-Learn.\n    \\item[–] \\texttt{solver()}: regression equation, to be implemented in each derivative class.\n    \\item[–] \\texttt{gradient()}: gradient of the \\texttt{solver}, to be implemented in each derivative class.\n    \\item[–] \\texttt{fit()}: fit the model and return beta-values, according to the \\texttt{solver}.\n    \\item[–] \\texttt{fit\\_SK()}: fit the model and return beta-values, using Scikit-Learn.\n    \\item[–] \\texttt{fitGD()}: fit the model and return beta-values, using the Gradient Descent and calling the \\texttt{gradient} method.\n    \\item[–] \\texttt{fitSGD()}: fit the model and return beta-values, using the Stochastic Gradient Descent and calling the \\texttt{gradient} method.\n    \\item[–] \\texttt{predictSGD\\_BS()}: fit the model and return beta-values, using the Stochastic Gradient Descent and the bootstrap algorithm.\n    \\item[–] \\texttt{predict()}: predict $y$ values given an external $X$. The methods of \\texttt{predict\\_train()} and \\texttt{predict\\_test()} are analogous but they work on the internal members.\n    \\item[–] \\texttt{rescaled\\_predict}: rescale $y$ prediction to the original data range.\n    \\item[–] \\texttt{MSE\\_train()}, \\texttt{MSE\\_test()}, \\texttt{R2\\_train()}, \\texttt{R2\\_test()}: evaluate the MSE or the R2 score on internal members.\n    \\item[–] \\texttt{Confidence\\_Interval()}: return the confidence interval of the beta-values.\n\\end{itemize}\nA simple example of usage is:\n\\begin{verbatim}\nmodel = OLSRegression(X,y)\nbeta = model.split().rescale().fit()\nmse = model.MSE_test()\n\\end{verbatim}\n\n\\textbf{Logistic Regression class}\nIn order to solve the last task, a draft class has been implemented for solving a Logistic Regression case to compare with the Neural Network performance. The methods are the following:\n%that have been sketched\n\\begin{itemize}\n    \\item[–] \\texttt{\\_\\_init\\_\\_()}: initialize the class with given $X$ and $y$.\n    \\item[–] \\texttt{split()}: split in train and test datasets\n    \\item[–] \\texttt{loss(()}: evaluate the cross entropy\n    \\item[–] \\texttt{gradients()}: evaluate the gradients for the Stochastic Gradient Descent\n    \\item[–] \\texttt{train()}: implement the Stochastic Gradient Descent\n    \\item[–] \\texttt{predict()}: predict new output with the trained/fitted class\n    \\item[–] \\texttt{accuracy()}: evaluate the accuracy score.\n\\end{itemize}\n\n%This class hasn't tested yet because of problems that will be explained later in the report.\n\nAll the source code can be found in the GitHub repository: \\href{https://github.com/adelezaini/MachineLearning/Projects/Project2}{ https://github.com/adelezaini/MachineLearning} in the directory \\texttt{Projects/Project2}.\n\n\n% ===========================================\n\\section{Results and discussion}\\label{sec:results}\n\nThe work for this project is divided in different tasks. Task \\textit{a} focuses on the Stochastic Gradient Descent performance, while task \\textit{b, c, d} focus on exploring neural networks. Task \\textit{e} regards the implementation of the Logistic Regression code.\n\nThe datasets are the {Franke Function} and the \\textit{Boston Housing} for the regression case, and the \\textit{Wisconsin Breast Cancer} and the \\textit{MNIST digits} for the classification case.\n\n\\subsection{Stochastic Gradient Descent}\n\n\\textit{Perform an analysis of the results for OLS and Ridge regression as\nfunction of the chosen learning rates, the number of mini-batches and\nepochs as well as algorithm for scaling the learning rate.}\n\nThe dataset is generated by the Franke Function taken $n=25$ for each dimensions $(x,y)$ (total datapoints: $N=25^2=625$) with an added stochastic noise normally distributed $\\mathsym{N}(0,0.1)$. The design matrix $X$ of a polynomial of \\texttt{degree=5}, together with $z$, is the input to initialize the \\texttt{OLSRegression} and \\texttt{RidgeRegression} objects. Splitting into train and test datasets and rescaling with \\texttt{StardardScaler(with\\_std=False)} from Sklearn have been performed before fitting the model with \\texttt{n\\_epochs = 50, n\\_minibatches = 10} and default hyperparameters $\\lambda = 10^{-12}$ and $\\eta_0 = 1 / \\lambda_{max}$ ($\\lambda_{max}$ is the maximum eigenvalue of the Hessian matrix of $X$). This first choice is reflected is quite poor $MSE$, that is equal to $2.18$ for both OLS and Ridge Regression, in the face of $MSE_{sk} = 0.0267$ given by the Sklearn model. These result is surely improvable with the optimization of the parameters.\n\nThe performance analysis starts with the optimization of the learning rate, evaluated with a \\textit{learning schedule} dependent on two parameters $t_0$ and $t_1$. Afterwards the numbers of minibatches and epochs are explored. At the end a grid-search of learning rate and $\\lambda$ gives the best combination of the Ridge case. In each step the optimal parameter found in the previous step is taken as input parameter for the next fitting.\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{SGD/SGD_eta_OLS.png}\n    \\caption{\\textbf{Task $a$ – SGD}: MSE performance of the learning rate, choosing a \\textit{learning schedule} with parameters $t_0$ and $t_1$. Maximum MSE value set to 1. The optimal values are $t_0 = 5 \\ 10^{-3}$ and $t_1 = 500$, given an initial learning rate of $\\eta_0=10^{-5}$.}\n    \\label{fig:eta0_ols}\n    \\centering \n    \\includegraphics[scale=0.3]{SGD/SGD_eta_Ridge.png}\n    \\caption{\\textbf{Task $a$ – SGD}: MSE performance of the learning rate, choosing a \\textit{learning schedule} with parameters $t_0$ and $t_1$. Maximum MSE value set to 1. The optimal values are $t_0 = 25$ and $t_1 = 500$, given an initial learning rate of $\\eta_0=5 \\ 10^{-2}$.}\n    \\label{fig:eta0_ridge}\n\\end{figure}\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{SGD/SGD_minibatches.png}\n    \\caption{\\textbf{Task $a$ – SGD}: MSE performance over the number of minibatches. A rolling mean has been implemented to better appreciate the trend.}\n    \\label{fig:sgd_mb}\n\n    \\centering \n    \\includegraphics[scale=0.3]{SGD/SGD_epochs.png}\n    \\caption{\\textbf{Task $a$ – SGD}: MSE performance over the number of epochs. A rolling mean has been implemented to better appreciate the trend.}\n    \\label{fig:sgd_epochs}\n\\end{figure}\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{SGD/SGD_lambda_eta.png}\n    \\caption{\\textbf{Task $a$ – SGD}: MSE performance in a cross-investigation over $\\lambda$ and the learning rate $\\eta$.}\n    \\label{fig:lmd_eta}\n\\end{figure}\n\nFrom the results of this MSE analysis (Figures \\ref{fig:eta0_ols}, \\ref{fig:eta0_ridge}, \\ref{fig:sgd_mb}, \\ref{fig:sgd_epochs}) we can then conclude that this implementation of the SGD, choosen a \\textit{learning schedule} for the learning rate, shows the best performance for $\\eta_0=10^{-5}$ ($t_0, t_1 = 5 \\ 10^{-3}, 500$), $n_{minibatches} = 12$, $n_{epochs} = 150$ for OLS, while $\\eta_0=5 \\ 10^{-2}$ ($t_0, t_1 = 25, 500$), $n_{minibatches} = 50$, $n_{epochs} = 150$ for Ridge. These optimized parameters give a MSE in the order of magnitude minor of $0.1$.\n\nFigures \\ref{fig:lmd_eta} shows that the best combination of $\\lambda$ and $\\eta$ is rispectively $1.87\\ 10^{-4}$ and $4.33 \\ 10^{-4}$, giving an excellent $MSE=0.049$.\n\nFurther comments can be done on the stochastic behaviour in the trends (Figure \\ref{fig:sgd_mb}, Figure \\ref{fig:sgd_epochs}) (leveled by the rolling mean) when re running the code. A version of the fitting has been implemented with the bootstrap algorithm (\\texttt{fitSGD\\_BS()}), but the results do not change that much and it's computational more expensive. The reason relies on the intrinsic stochastic character of the SGD algorithm.\n\n\\subsection{Neural Network code}\n\n\\textit{Write an FFNN code for regression with a flexible number of hidden layers and nodes using the Sigmoid function as activation function for the hidden layers.\nTrain your network and make an analysis of the regularization parameters and the learning rates employed to find the optimal MSE and R2 scores. Compare the results obtained with the Linear Regression code and your own Neural Network code.}\n\n\\textbf{\\textit{Note:} The class \\texttt{NeuralNetwork} has been implemented for both the Regression and Classification cases but because of a number of unexpected problems I had to face is currently not running yet. The reason relies on the fact that I wished to implement a very versatile class, but I have been trapped myself into the complexity of my own code. Unfortunately this led me to spend several days (weeks) on elaborating this class, lacking on the rest of the project. In order not to be blocked by any progress in the analysis, I'll present here the work I would have done if the code was running. The class credit is to Simone Mirabella, another student of the course, with whom I started structuring the code at the beginning. The class is basically the same as mine, but it runs. The implementation of my class is in the following link: \\href{https://github.com/adelezaini/MachineLearning/blob/nn/Projects/Project2/neuralnetwork.py}{https://github.com/adelezaini/MachineLearning/\nblob/nn/Projects/Project2/neuralnetwork.py}. Any feedback is more than welcomed! I also apologise for lacking in the depth of the further analysis but the time left was too little to explore more.}\n\nThe dataset choosen for this task is the {Boston Housing} because it makes the Neural Network perform on a real case of Regression in Supervised Learning. Firstly the two most correlated features has been selected, the dataset has been splitted into train and test subsets and they have been rescaled by the mean and the standard deviation.\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.35]{NN/RegrNN_200_50_None_32_50_0.0002.jpg}\n    \\caption{\\textbf{Task $b$ – NN Regression}: Training of the NN with two layers of dimensions $[200,50]$, $n_{epochs}=50$, $n_{minibatches}=32$ and $\\eta=0.001$. No regularisation has been considered.}\n    \\label{fig:train_noreg}\n    \\centering \n    \\includegraphics[scale=0.35]{NN/RegrNN_200_50_L2_32_50_0.0002.jpg}\n    \\caption{\\textbf{Task $b$ – NN Regression}: Training of the NN with two layers of dimensions $[200,50]$, $n_{epochs}=200$, $n_{minibatches}=32$ and $\\eta=0.01$. 'L2' regularisation has been considered with a $\\lambda=0.1$.}\n    \\label{fig:train_reg}\n\\end{figure}\n\n\\begin{table}[H]\n\\centering \n\\begin{tabular}{@{}ccccc@{}}\n& OLS   & Ridge & NN\\_no\\_reg & NN\\_l2\\_reg \\\\ [0.5ex] \n\\hline\\hline\n\\multicolumn{1}{|l|}{MSE\\_train} & 29.30 & 31.96 & 0.33        & \\multicolumn{1}{l|}{0.42} \\\\ \\midrule\n\\multicolumn{1}{|l|}{MSE\\_test}  & 35.35 & 23.05 & 0.61        & \\multicolumn{1}{l|}{0.65} \\\\ \\midrule\n\\multicolumn{1}{|l|}{R2\\_test}   & 0.57  & 0.63  & 0.39        & \\multicolumn{1}{l|}{0.35} \\\\ \\hline \\bottomrule\n\\end{tabular}\n\\label{tab:nn_lin}\n\\caption{\\textbf{Task $b$ – NN Regression}: Table summarizing the comparison between Linear and NeuralNetwork methods on the error analysis. The table refers to NN training of Figure \\ref{fig:train_noreg} and Figure \\ref{fig:train_reg}.}\n\\label{tab:nn_lin}\n\\end{table}\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{NN/RegrNN_lmd_eta_MSE.jpg}\n    \\caption{\\textbf{Task $b$ – NN Regression}: Cross-investigation on MSE performance of the regularisation parameter $\\lambda$ and the learning rate $\\eta$.}\n    \\label{fig:mse_nn_regr}\n    \\centering \n    \\includegraphics[scale=0.3]{NN/RegrNN_lmd_eta_R2.jpg}\n    \\caption{\\textbf{Task $b$ – NN Regression}: Cross-investigation on R2 performance of the regularisation parameter $\\lambda$ and the learning rate $\\eta$.}\n    \\label{fig:r2_nn_regr}\n\\end{figure}\n\nIn the Figures \\ref{fig:train_noreg} and \\ref{fig:train_reg}, we can appreciate the optimization process of the neural network. On the one hand, the added 'l2' regularisation term can avoid overfitting, on the other hand it leads to a slower convergence of the performance of the network (number of epochs incresed form $50$ to $200$). This is understandable, but the figures have shown an interesting point not deepened before.\n\nThe comparison with the Linear Regression (Table \\ref{tab:nn_lin}) suggests the excellent performance of the Neural Network, both with or without the regularization option, over the classic Linear Regression methods: the $MSE$ decreases of two orders of magnitude, reaching $0.33$ form $35$. Regarding the optimization of the hyperparameters, we can appreciate from Figures \\ref{fig:mse_nn_regr} and \\ref{fig:r2_nn_regr} that the neural network best performs with $\\eta=0.001$ and $\\lambda \\in [10^{-12},0.001]$.\n\n\n\\subsection{Testing different activation functions}\n\n\\textit{Test different activation functions for the hidden layers. Try out the Sigmoid, the RELU and the Leaky RELU functions and discuss your results. }\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{NN/RegrNN_activations.jpg}\n    \\caption{\\textbf{Task $c$ – NN Regression}: Different activation functions of the hidden layers are explored in terms of MSE performance.}\n    \\label{fig:activations}\n\\end{figure}\n\nFigure \\ref{fig:activations} shows that the choice of the activation function can influence the efficiency at the beginning of the training but that the performance converges to be the same independently by the choosen activation function.\n\nIn this particular case no problem is shown, but from literature the choice of the activation function can influence the network's performance.\nWhen the gradients get smaller and smaller as the backpropagation algorithm progresses down to the first hidden layers. As a result, the GD update leaves the lower layer connection weights virtually unchanged, and training never converges to a good solution. This is known in the literature as the vanishing gradients problem. In other cases, the opposite can happen, namely the the gradients can grow bigger and bigger. The result is that many of the layers get large updates of the weights the algorithm diverges. This is the exploding gradients problem. The ranking taken from the literature shows LeakyReLU performing better than ReLU, which performs better than the Sigmoid.\n\n\\subsection{Classification  analysis using neural networks}\n\n\\textit{Change the code to perform also in the classification casr. Discuss your results and give a critical analysis of the various parameters, including hyper-parameters like the learning rates and the regularization parameter $\\lambda$ (as you did in Ridge Regression), various activation functions, number of hidden layers and nodes and activation functions.}\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{Class/ClassNN_lmd_eta.jpg}\n    \\caption{\\textbf{Task $d$ – NN Classification}: Grid-search on Accurancy performance of the regularisation parameter $\\lambda$ and the learning rate $\\eta$.}\n    \\label{fig:acc_lmd_eta}\n\\end{figure}\n\n\\begin{figure}[h]\n    \\centering \n    \\includegraphics[scale=0.3]{Class/ClassNN_activations.jpg}\n    \\caption{\\textbf{Task $d$ – NN Classification}: Different activation functions of the hidden layers are explored in terms of training performance performance. At the end the Sigmoid and eLU function has an accurancy of $0.412$, while ReLU of $0.096$.}\n    \\label{fig:activations_class}\n\\end{figure}\n\nWhile training the network, the user can learn how to better set the number of hidden layers and number of neurons in each layer. Increasing the number of hidden layers does not increase the performance consistently, while the pattern of the number of neurons throughout the hidden layers seems more important. Starting from a number close to the input dimension and go progressively to the number of the outputs gives the best results in terms of performance.\n\n%\\subsection{Logistic Regression code}\n\n%\\textit{Compare the FFNN code with Logistic regression.}\n\n%The class has been implemented but the comparison with the Neural Network is left for a future development.\n\n\n% ===========================================\n\\section{Conclusion}\\label{sec:conclusion}\n\n\\textit{This last section covers task f of the project: Critical evaluation of the various algorithms.}\n\nIn this report we explored the performance of the neural networks and related algorithms, compared to standard techniques. We can state that overall the neural network can lead to excellent results, when optimizing properly the parameters and the network architecture. \n\nMost of the work behind this report has been focused on the implementation of the project, compared to the analysis and optimization of the parameters for which little time was left. Yet some interesting results can be highlighted. Starting from the SGD algorithm, the analysis shows the best performance when considering optimal values for the different parameters: $\\eta_0=10^{-5}$, $n_{minibatches} = 12$, $n_{epochs} = 150$ for the OLS Regression, while $\\eta_0=5 \\ 10^{-2}$, $n_{minibatches} = 50$, $n_{epochs} = 150$ for the Ridge Regression. Figures \\ref{fig:lmd_eta} shows that the best combination for the Ridge of $\\lambda$ and $\\eta$ is respectively $1.87\\ 10^{-4}$ and $4.33 \\ 10^{-4}$, giving an excellent $MSE=0.049$. All the figures manifest the intrisic stochastic behaviour of the algorithm.\n\nRegarding the neural network, we can appreciate its better performance over the classical method of Linear Regression (Table \\ref{tab:nn_lin}), in particular considering as hyperparameters $\\eta=0.001$ and $\\lambda \\in [10^{-12},0.001]$ (Figures \\ref{fig:mse_nn_regr} and \\ref{fig:r2_nn_regr}). The choice of the activation function does not seem to influence consistently the performance when training the network over several iterations (Figures \\ref{fig:activations} and \\ref{fig:activations_class}). As regarding the Classification case, little has been explored but it shows a good flexibility on the choice of the hyperparameters and activation function, but overall the accurancy never exceeds $0.42$. This is an interesting point to explore.\n\nSurely we can consider this work still open to improvements. Starting from fixing the code and filling the gaps, but also on the analysis of the performance. It would be very interesting to better explore the optimization and regularization algorithms, several combinations of number of hidden layers and respective neurons, various kinds of learning rate and choices of the input datasets, but also implementing new methods, such as the Batch Normalization, the Dropout or the Gradient Clipping.\n\n\\newpage\n\\newpage\n% ===========================================\n\\section*{References}\\label{sec:references}\n\\begin{itemize}\n    \\item[-] \\href{https://compphysics.github.io/MachineLearning/doc/web/course.html}{FYS-STK3155 courses' notes}\n    \\item[-] \\href{https://static.latexstudio.net/article/2018/0912/neuralnetworksanddeeplearning.pdf}{Michael Nielsen, Neural Networks and Deep Learning}\n    \\item[-] \\href{https://github.com/UdiBhaskar/Deep-Learning}{UdiBhaskar/Deep-Learning GitHub repository}\n    \\item[-] \\href{https://datascience-enthusiast.com/DL/Logistic-Regression-with-a-Neural-Network-mindset.html}{Fisseha Berhane, Logistic Regression with a Neural Network mindset}\n    \\item[-] \\href{https://ml-cheatsheet.readthedocs.io/en/latest/index.html}{ML Glossary}\n    \\item[-] \\href{https://www.youtube.com/watch?v=Ilg3gGewQ5U}{3Blue1Brown, What is backpropagation really doing? | Chapter 3, Deep learning}\n    \\item[-] \\href{https://ruder.io/optimizing-gradient-descent/index.html#stochasticgradientdescent}{Sebastian Ruder, An overview of gradient descent optimization algorithms}\n    \\item[-] \\href{https://towardsdatascience.com/stochastic-gradient-descent-clearly-explained-53d239905d31}{Medium, Aishwarya V Srinivasan, Stochastic Gradient Descent — Clearly Explained}\n    \\item[-] \\href{https://medium.com/@zeeshanmulla/cost-activation-loss-function-neural-network-deep-learning-what-are-these-91167825a4de}{Medium, Mohammed Zeeshan Mulla, Cost, Activation, Loss Function|| Neural Network|| Deep Learning. } \n    \\item[-] \\href{http://neuralnetworksanddeeplearning.com/chap2.html}{Michael Nielsen, How the backpropagation algorithm works} \n    \\item[-] \\href{https://neptune.ai/blog/cross-entropy-loss-and-its-applications-in-deep-learning}{Author Rose Wambui,Cross-Entropy Loss and Its Applications in Deep Learning.} \n    \\item[-] \\href{https://sophiamyang.github.io/DS/optimization/multiclass-logistic/multiclass-logistic.html}{Sophia Yang, Multiclass logistic regression from scratch.} \n    \\item[-] \\href{https://jovian.ai/attyuttam/03-logistic-regression}{Image Classification using Logistic Regression in PyTorch} \n\n\\end{itemize}\n%\\input{sites_references.tex}\n\n% ===========================================\n\n\\clearpage\n\n\\onecolumngrid\n\n\\bibliographystyle{apalike}\n\\bibliography{Bibliography.bib}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "43b03d835f05b5e325c5eb81986ed2d2a38e8d7d", "size": 47085, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Projects/Reports/Report2/Report2_Adele_Zaini_tex/main.tex", "max_stars_repo_name": "adelezaini/MachineLearning", "max_stars_repo_head_hexsha": "dc3f34f5d509bed6a993705373c46be4da3f97db", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Projects/Reports/Report2/Report2_Adele_Zaini_tex/main.tex", "max_issues_repo_name": "adelezaini/MachineLearning", "max_issues_repo_head_hexsha": "dc3f34f5d509bed6a993705373c46be4da3f97db", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Projects/Reports/Report2/Report2_Adele_Zaini_tex/main.tex", "max_forks_repo_name": "adelezaini/MachineLearning", "max_forks_repo_head_hexsha": "dc3f34f5d509bed6a993705373c46be4da3f97db", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.3212435233, "max_line_length": 1511, "alphanum_fraction": 0.7494106403, "num_tokens": 12002, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.7956580976404296, "lm_q1q2_score": 0.4071514602299359}}
{"text": "\\documentclass{amsart}[12pt]\n\\usepackage{amsmath, amsfonts, tikz, natbib, array}\n\\usetikzlibrary{patterns}\n\\oddsidemargin=0in \\evensidemargin=0in\n\\textwidth=6.6in \\textheight=8.7in\n\n\\title{Map projections between Euclidean and spherical quadrilaterals}\n\\author{B R S Recht}\n\\date{April 2020}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\section{Introduction}\nA small but persistent trend in creating world maps has been to map onto a\npolyhedron, and then unfold the polyhedron into a flat polyhedral net.\nMost maps in this category use regular polyhedra, often the cube or the\nicosahedron (in Fuller's second Dymaxion map).\\cite{gray94} Other polyhedra include the other regular solids and\nsome Archimedean solids; Fuller used the cuboctahedron for his first Dymaxion\nmap,\\cite{gray95} and the truncated icosahedron was used by\nSnyder.\\cite{snyder92} Maps between a polygon and a hemisphere\ncan be considered as polyhedral maps if the dihedron is\nallowed.\\cite{snyder89}\\cite{lambers} The inverse mapping can be used to\ninscribe a grid on a sphere, as in the quadrilateralized spherical\ncube\\cite{chan75}\\cite{oneill76} or discrete global grids.\\cite{sahr98}\n\nAnother is\nthe field of computer graphics, where there is some interest in functions\nbetween the square to the disk.\\cite{fong15}\\cite{fong18}\nThese functions can be composed with an appropriate map\nprojection from the disk to the hemisphere\nto create a map projection between the square and the sphere.\\cite{lambers}\n\nNearly all of the literature on map projections between Euclidean and spherical\npolygons, either in general or particular, only deals with regular polygons.\nHowever, geographical features do not follow any regular geometric rules.\nRegular polygons are mathematically easier to study, but irregular polygons are\nalso tractable. In this text, map projections between general Euclidean and\nspherical polygons will be described. Some of these are extensions of existing\nmap projections, while some are new compromise map projections.\n\n\\section{Preliminaries}\nLet $(u,v)$ be a vector in $\\mathbb R^2$, and $\\zeta = u + i v$ be the\ncorresponding complex number in $\\mathbb C$ or the Riemann sphere $\\mathbb C\n\\cup \\{\\infty\\}$. Which notation is used will depend on the mapping:\nconformal maps are best expressed in terms of complex variables.\n\n\\subsection{Spherical geometry with 3-vectors}\nSome of the map projections to be discussed are better expressed\nin terms of a vector rather than latitude and longitude. This text will only\ncover pertinent details: a fuller description can be found in e.g. \\cite{gade}.\n\nLet $\\phi \\in [-\\frac{\\pi}{2}, \\frac{\\pi}{2}]$ be latitude, and\n$\\lambda \\in (-\\pi, \\pi]$ be longitude. Let $\\mathbf v = (x, y, z)$ be a vector\nin $\\mathbb R^3$ and $\\mathbf{\\hat{v}} = (x, y, z)$ be a unit vector on the\nsphere $S^2$ such that $\\| \\mathbf{\\hat{v}} \\| = \\sqrt{x^2 + y^2 +z^2} = 1$.\nTo convert from latitude and longitude to a unit vector:\n\\begin{equation}\n  \\mathbf{\\hat{v}} = \\left(\\sin (\\phi), \\sin (\\lambda) \\cos (\\phi),\n  -\\cos (\\lambda) \\cos (\\phi) \\right)\n\\end{equation}\nTo convert from the unit vector $\\mathbf{\\hat{v}}$ to latitude and longitude:\n\\begin{equation}\\begin{split}\n  \\phi &= \\arcsin (x) = \\arctan (x, \\sqrt{y^2 + z^2}) \\\\\n  \\lambda &= \\arctan (y, -z)\n\\end{split}\\end{equation}\n\nOften in this text we'll normalize a vector to make it a unit vector.\nFor brevity,\nwe'll notate this pre-normalized vector as $\\mathbf{\\widetilde{v}}$, such that\n\\begin{equation}\n  \\mathbf{\\hat{v}} = \\frac{\\mathbf{\\widetilde{v}}}{\\|\\mathbf{\\widetilde{v}}\\|}\n\\end{equation}\n\n\\subsubsection{Great circles}\nThe shortest distance (geodesic) between two points in Euclidean space is a\nstraight line. On the sphere, the shortest distance is an arc of the great\ncircle between those points. That distance is the central angle $\\theta$\nbetween the two points. There are a few vector forms for it, the most\nnumerically stable one being the one using $\\arctan$.\n\\begin{equation}\\begin{split}\n\\theta &= \\arccos \\left(\\mathbf{\\hat{v}}_1 \\cdot \\mathbf{\\hat{v}}_2\\right) \\\\\n&= \\arcsin \\left(\\|\\mathbf{\\hat{v}}_1 \\times \\mathbf{\\hat{v}}_2\\| \\right) \\\\\n&= \\arctan \\left( \\frac{\\|\\mathbf{\\hat{v}}_1 \\times \\mathbf{\\hat{v}}_2\\|}\n  {\\mathbf{\\hat{v}}_1 \\cdot \\mathbf{\\hat{v}}_2} \\right)\n\\end{split}\\end{equation}\n\nThe great circle is the intersection of the sphere\nand a plane passing through the origin. A plane through the origin can be\nspecified as $\\hat{\\mathbf n} \\cdot \\mathbf v = 0$, where $\\hat{\\mathbf n}$ is\na unit vector normal to the plane; this vector $\\hat{\\mathbf n}$ can be used to\nspecify a great circle. Given two points $\\mathbf{\\hat{v}_1, \\hat{v}_2}$ on the\nsphere, the $\\hat{\\mathbf n}$ of the great circle between those two points is\n(up to normalization) their cross product:\n\\begin{equation}\n  \\mathbf{\\widetilde{n}} = \\mathbf{\\hat{v}}_1 \\times \\mathbf{\\hat{v}}_2\n\\end{equation}\nTwo great circles intersect at two antipodal points on the sphere. The points\nof intersection can be found as the cross product of the great circle normals:\n\\begin{equation}\n  \\mathbf{\\widetilde{v}} = \\pm \\mathbf{\\hat{n}}_1 \\times \\mathbf{\\hat{n}}_2\n\\end{equation}\n\n\\subsubsection{Interpolation}\nInterpolation in Euclidean space is standard linear interpolation. On the\nsphere, interpolation is given by spherical linear interpolation, or slerp.\n\\begin{equation}\n\\mathrm{Lerp}(\\mathbf{v_1}, \\mathbf{v_2}; t) =\n       (1-t) \\mathbf{v_1} + t \\mathbf{v_2}\n\\end{equation}\n\\begin{equation}\n\\mathrm{Slerp}(\\mathbf{\\hat{v}_1}, \\mathbf{\\hat{v}_2}; t) =\n        \\frac{\\sin ((1-t)w)}{\\sin (w)} \\mathbf{\\hat{v}_1} +\n       \\frac{\\sin (tw)}{\\sin (w)} \\mathbf{\\hat{v}_2}\n\\end{equation}\nwhere $w = \\arccos \\mathbf{\\hat{v}_1} \\cdot \\mathbf{\\hat{v}_2}$. If $\\mathbf{\\hat{v}_1} = \\mathbf{\\hat{v}_2}$, then define $\\mathrm{Slerp}(\\mathbf{\\hat{v}_1}, \\mathbf{\\hat{v}_2}; t) =\n\\mathbf{\\hat{v}_1} = \\mathbf{\\hat{v}_2}$ for all $t$.\n\n\\subsubsection{Face normal}\nFor the purposes of this text, we define the normal to a (Euclidean) polygon as\nso, where $n$ is the number of vertices in the polygon and\n$i = 0 \\dots n-1$ is an index for each vertex:\n\\begin{equation}\n  \\mathbf{\\widetilde{n}} =\n  \\sum^{n-1}_i \\mathbf{v}_i \\times \\mathbf{v}_{i+1}\n\\end{equation}\n$i$ should be treated as if it's mod $n$, so that it loops around.\nThis definition allows for a somewhat sensible extension to skew polygons:\nthe normal points in a generally reasonable direction when applied to a skew\npolygon. The normal will be outward-facing if the points are ordered\ncounterclockwise, and inward-facing if the points are ordered clockwise.\n\n\\subsection{Euclidean spaces and transformations, including $uv$ coordinates}\nThis text uses barycentric coordinates on Euclidean triangles.\nQuadrilaterals are instead specified by \\textit{$uv$ coordinates} where\n$u$ and $v$ are $\\in [-1, 1]$. The subset of the plane $[-1, 1]^2$ is termed\nthe standard square. Here we discuss transformations of those\n\n\\subsubsection{Affine transformation}\nAffine transformations are combinations of reflection, scaling, rotation,\nshearing, and translation. This can be expressed as $\\mathbf v = \\mathbf A [u,\nv]^T + v_0$, where $\\mathbf A$ is a matrix. However, it is often more\nconvenient to express affine transformations using an augmented matrix like so:\n\\begin{equation}\n  \\begin{bmatrix}  x \\\\  y \\\\  1 \\end{bmatrix}\n   = \\mathbf M\n    \\begin{bmatrix}  u \\\\  v \\\\  1 \\end{bmatrix},\\,\n    \\mathbf M = \\begin{bmatrix}\n       A_{11} & A_{12} & v_{0x} \\\\\n       A_{21} & A_{22} & v_{0y} \\\\\n       0 & 0 & 1\n       \\end{bmatrix}\n\\end{equation}\nThe transformation is invertible if $\\mathbf M$ (or $\\mathbf A$) is\ninvertible. This transformation can also transform between spaces of different\ndimension, although then $\\mathbf M$ is not a square matrix.\n\nAffine transformations are equal-area in the sense defined earlier if\n$|\\mathbf M| \\ne 0$, so if using an equal-area projection it may be desirable\nto limit oneself to affine transformations. If $|\\mathbf M| = 1$, then it defines a conformal affine transformation, effectively a combination of translation and rotation.\n\n\\subsubsection{Homography}\nHomography, or projective transformation, is commonly used in computer vision\nand graphics to handle objects seen in perspective, and may be convenient in\nsome software environments. A homography may be given by:\n\\begin{equation}\n  \\begin{bmatrix} xt \\\\ yt \\\\ t \\end{bmatrix}\n  = \\mathbf{M} \\begin{bmatrix} u  \\\\ v \\\\ 1  \\end{bmatrix}\n\\end{equation}\nwhere $\\mathbf{M}$ is called the matrix of the homography. The matrix is\ndefined up to multiplication by a positive constant: $\\mathbf{M}$ and\n$k\\mathbf{M}$ where $k>0$ define the same homography. The inverse of this\ntransformation is also a projective transformation, with matrix of the\nhomography $\\mathbf{M}^{-1}$. Given 4 points in the $uv$ plane and their target\nin the $xy$ plane, $\\mathbf{M}$ can be determined as the null-space of this\nsystem:\n\\begin{equation}\n  \\begin{bmatrix}\n  x_1 & x_1 u_1 & x_1 v_1 & -1 & -u_1 & -v_1 & 0 & 0 & 0 \\\\\n  x_2 & x_2 u_2 & x_2 v_2 & -1 & -u_2 & -v_2 & 0 & 0 & 0 \\\\\n  x_3 & x_3 u_3 & x_3 v_3 & -1 & -u_3 & -v_3 & 0 & 0 & 0 \\\\\n  x_4 & x_4 u_4 & x_4 v_4 & -1 & -u_4 & -v_4 & 0 & 0 & 0 \\\\\n  y_1 & y_1 u_1 & y_1 v_1 & 0 & 0 & 0 & -1 & -u_1 & -v_1 \\\\\n  y_2 & y_2 u_2 & y_2 v_2 & 0 & 0 & 0 & -1 & -u_2 & -v_2 \\\\\n  y_3 & y_3 u_3 & y_3 v_3 & 0 & 0 & 0 & -1 & -u_3 & -v_3 \\\\\n  y_4 & y_4 u_4 & y_4 v_4 & 0 & 0 & 0 & -1 & -u_4 & -v_4\n   \\end{bmatrix}\n   \\begin{bmatrix}\n  M_{11} \\\\ M_{12} \\\\ M_{13} \\\\\n  M_{21} \\\\ M_{22} \\\\ M_{23} \\\\\n  M_{31} \\\\ M_{32} \\\\ M_{33}\n  \\end{bmatrix} = \\mathbf{0},\n\\end{equation}\nwhere\n\\begin{equation}\n  \\mathbf{M} = \\begin{bmatrix}\n  M_{11} & M_{12} & M_{13} \\\\\n  M_{21} & M_{22} & M_{23} \\\\\n  M_{31} & M_{32} & M_{33} \\end{bmatrix}.\n\\end{equation}\nThis transformation can also be adapted to a transform from 2-d $uv$ space to a\nplane in 3-d $xyz$ space. The target points must be coplanar, and since the\nmatrix of the homography is now a 3 by 4 matrix, the inverse transformation is\ngiven by the pseudoinverse instead. Homographies are undefined along the line\nwhere $t=0$, but this rarely becomes an issue in the context of this text.\n\n\\subsubsection{Bilinear Interpolation}\n\\begin{figure}%[!htbp]\n\\begin{tikzpicture}\n  \\draw (0, 0) -- (4, 0) -- (4, 3) -- (1, 4) -- (0, 0);\n  \\draw[fill] (0, 0) circle [radius=0.05] node[anchor=east] {\\tiny 1};\n  \\draw[fill] (4, 0) circle [radius=0.05] node[anchor=west] {\\tiny 2};\n  \\draw[fill] (4, 3) circle [radius=0.05] node[anchor=west] {\\tiny 3};\n  \\draw[fill] (1, 4) circle [radius=0.05] node[anchor=east] {\\tiny 4};\n  \\draw[dotted] (2, 0) node[anchor=north] {\\tiny 1,2}\n    -- (2.5, 3.5) node[anchor=south] {\\tiny 4,3};\n  \\draw[dotted] (0.5, 2) node[anchor=east] {\\tiny 1,4}\n    -- (4, 1.5) node[anchor=west] {\\tiny 2,3};\n  \\draw[fill] (2.25, 1.75) circle [radius=0.05];\n\\end{tikzpicture}\n\\caption{Bilinear interpolation, showing intersection of lines.}\n\\label{fig:uv}\n\\end{figure}\nAnother transformation is usually called 'bilinear interpolation' in image processing applications. Let $\\mathbf v_1, \\mathbf v_2, \\mathbf v_3, \\mathbf v_4$ be points in 2-d or 3-d (or higher) space. Define:\n\\begin{equation}\\begin{split}\n\\mathbf v_{1,2} & = \\mathrm{Lerp}(\\mathbf v_1,\\mathbf v_2;\\frac{u+1}{2}),\\\\\n\\mathbf v_{4,3} & = \\mathrm{Lerp}(\\mathbf v_4,\\mathbf v_3;\\frac{u+1}{2}),\\\\\n\\mathbf v_{1,4} & = \\mathrm{Lerp}(\\mathbf v_1,\\mathbf v_4;\\frac{v+1}{2}),\\\\\n\\mathbf v_{2,3} & = \\mathrm{Lerp}(\\mathbf v_2,\\mathbf v_3;\\frac{v+1}{2})\n\\end{split}\\end{equation}\nThen bilinear interpolation determines the point $\\mathbf v$ as:\n\\begin{equation}\\begin{split}\n\\mathbf v\n& = \\mathrm{Lerp}(\\mathbf v_{1,2}, \\mathbf v_{4,3}; \\frac{v+1}{2}) \\\\\n& = \\mathrm{Lerp}(\\mathbf v_{1,4}, \\mathbf v_{2,3}; \\frac{u+1}{2}) \\\\\n& = \\frac{(1-u)(1-v)}{4} \\mathbf v_1 +\n\\frac{(1+u)(1-v)}{4} \\mathbf v_2 +\n\\frac{(1+u)(1+v)}{4} \\mathbf v_3 +\n\\frac{(1-u)(1+v)}{4} \\mathbf v_4 \\\\\n&= \\mathbf{a} + u \\mathbf{b} + v \\mathbf{c} + u v \\mathbf{d}\n\\end{split}\\end{equation}\nwhere\n\\begin{equation}\\begin{split}\n  \\mathbf{a} &= \\frac{\\mathbf v_1 +\\mathbf v_2 +\\mathbf v_3 + \\mathbf v_4}{4},\n  \\\\\n  \\mathbf{b} &= \\frac{-\\mathbf v_1 +\\mathbf v_2 +\\mathbf v_3 - \\mathbf v_4}{4},\n  \\\\\n  \\mathbf{c} &= \\frac{-\\mathbf v_1 -\\mathbf v_2 +\\mathbf v_3 + \\mathbf v_4}{4},\n  \\\\\n  \\mathbf{d} &= \\frac{\\mathbf v_1 -\\mathbf v_2 +\\mathbf v_3 - \\mathbf v_4}{4}\n\\end{split}\\end{equation}\nThe $uv$ term in the transformation illustrates the choice of name: in 3d, if\nthe vertices $v_i$ are not coplanar, then the transformation maps the plane to\na hyperbolic paraboloid. Bilinear interpolation preserves evenly spaced points\nalong an edge of the quadrilateral defined by $v_i$, and avoids the undefined\nspace of the homography. However, the inverse function is somewhat more\ncomplicated. The inverse of bilinear interpolation,\nfor $\\mathbf{v}_i \\in \\mathbb{R}^2$, is given by:\n\\begin{equation}\\begin{split}\n u &= \\frac{-b_u + \\sqrt{b_u^2 - 4 a_u c_u}}{2a_u}\\\\\n v &= \\frac{-b_v + \\sqrt{b_v^2 - 4 a_v c_v}}{2a_v}\\\\\n a_u &= \\mathbf{b} \\times \\mathbf{d}, b_u = \\mathbf{a} \\times \\mathbf{d} + \\mathbf{b} \\times \\mathbf{c}, c_u = \\mathbf{a} \\times \\mathbf{c},\\\\\n a_v &= \\mathbf{c} \\times \\mathbf{d}, b_v = \\mathbf{a} \\times \\mathbf{d} - \\mathbf{b} \\times \\mathbf{c}, c_v = \\mathbf{a} \\times \\mathbf{b},\\\\\n\\end{split}\\end{equation}\nwhere the 2d scalar cross product $\\mathbf{a} \\times \\mathbf{b} = a_x b_y - b_x\na_y$ is used here. In more than two dimensions, pick two coordinates and use\nthose as $x$ and $y$.\n\nIf the shape is a planar parallelogram (or a special case of a parallelogram\nlike a rectangle), then $\\mathbf v_1 + \\mathbf v_3 = \\mathbf v_2 + \\mathbf v_4$,\nand $\\mathbf{d} = 0$. In this case, both the homography and the hyperbolic\nparaboloid transformation reduce to an affine transformation. Qualitatively, homographies preserve all lines,\nwhile bilinear interpolation preserves lines of constant $u$ or $v$.\n\nNeither homographies nor bilinear interpolation are amenable to generalization\nin the way that barycentric coordinates are. Bilinear interpolation can be\nexpressed like so:\n\\begin{equation}\n  \\mathbf v = \\sum^4_{i=1} \\alpha_i \\mathbf v_i,\n\\end{equation}\nbut $\\alpha_i$ are not necessarily unique for a given $\\mathbf v$. Later we\nwill see some map projections that are similar in form to bilinear interpolation.\n\n\\subsection{Dealing with the ellipsoid}\nThe Earth is reasonably approximated as a sphere, and better approximated as a\nslightly flattened oblate ellipsoid. In general this text will only deal with\nthe spherical approximation, but here we mention two considerations arising\nfrom that approximation.\n\nThe vector form described in \\cite{gade} corresponds to the geodetic latitude.\nThe mapping between the sphere and the ellipsoid using geodetic latitude is not\narea-preserving, conformal, or distance-preserving, although the distortion is\nsmall on the Earth ellipsoid. If applying an area-preserving, conformal, or\ndistance-preserving map projection, and the required precision is fine enough\nthat the distortion is a concern, the geodetic latitude can be substituted\nwith the authalic (equal-area), conformal, or rectifying\n(equal-distance along meridians) latitude as described in \\cite{snyder87}.\nThese can be calculated from the geodetic latitude,\nand the difference is well-approximated by a Fourier series.\n\nConsidering polyhedral maps, in this text we require the edges of the polyhedra\nto correspond to geodesics. Geodesics on a sphere are not necessarily geodesics\non an ellipse: as proof, geodesics on an ellipse are not necessarily closed,\nwhile geodesics on a sphere are. (Of course, with the Earth ellipsoid, the\ndifference between the geodesics is small.) The equator and meridians are\ngeodesics on both surfaces, so if having exact geodesics is a concern,\nplace your polyhedron edges along the equator or meridians.\n\n\\section{Map projections}\n\n\\begin{figure}%[!htbp]\n\\begin{tikzpicture}\n  \\draw [gray] (9,1) circle [radius=1];\n  \\draw[pattern=north east lines, pattern color=gray] (8.5, 0.5) to [out=-25, in=205]\n  (9.5, 0.5) to [out=90, in=-15]\n  (9, 1.5) to [out=125, in=25]\n  (8.5, 1.5) to [out=215, in=125]\n  (8.5, 0.5);\n  \\draw[fill] (8.5,0.5) circle [radius=0.05];\n  \\draw[fill] (9.5,0.5) circle [radius=0.05];\n  \\draw[fill] (9,1.5) circle [radius=0.05];\n  \\draw[fill] (8.5,1.5) circle [radius=0.05];\n\n  \\draw [<->] (10.25,1) -- (10.75,1);\n  \\draw[pattern=north east lines, pattern color=gray] (11, 0.5) -- (12, 0.5) -- (12, 1.5) -- (11, 1.5) -- (11, 0.5);\n  \\draw[fill] (11,0.5) circle [radius=0.05];\n  \\draw[fill] (12,0.5) circle [radius=0.05];\n  \\draw[fill] (12,1.5) circle [radius=0.05];\n  \\draw[fill] (11,1.5) circle [radius=0.05];\n\n  \\draw [<->] (12.25,1) -- (12.75,1);\n  \\draw[pattern=north east lines, pattern color=gray] (13, 0.5) -- (14, 0.5) -- (13.5, 1.5) -- (13, 1.5) -- (13, 0.5);\n  \\draw[fill] (13,0.5) circle [radius=0.05];\n  \\draw[fill] (14,0.5) circle [radius=0.05];\n  \\draw[fill] (13.5,1.5) circle [radius=0.05];\n  \\draw[fill] (13,1.5) circle [radius=0.05];\n\n\\draw (10.5,1) node[anchor=south] {$P$};\n\\draw (12.5,1) node[anchor=south] {$H$};\n\n\\draw (9,0) node[anchor=north] {$R_s \\subset S^2$};\n\\draw (11.5,0) node[anchor=north] {$[u,v]$};\n\\draw (13.5,0) node[anchor=north] {$R_e \\subset \\mathbb{R}^2$};\n\n\\end{tikzpicture}\n\\caption{Schematic for the application of most projections listed in this text.\nLeft: triangles, right: quadrilaterals. $P$ indicates the projection, $A$ is an affine transformation, and $H$ is a homography or bilinear interpolation.}\n\\label{fig:schematic}\n\\end{figure}\n\nFigure \\ref{fig:schematic} illustrates the general form of application of most\nprojections in this text. (Exceptions are noted in the relevant sections.) The\ntransformation from barycentric coordinates to the plane, or from $uv$\ncoordinates to a quadrilateral, takes the same form for each projection, so in\nthis section we can ignore that part except when there are special\nconsiderations.\n\nThe polygon on the sphere $R_s$ and the polygon in the plane $R_e$ can be\nbasically anything, within the operating parameters of the projection and any\nspecial considerations that may apply. Even with respect to each other, one\ncan be a regular polygon while the other is some irregular monster, if that is\ndesirable. Of course, this will influence the distortion of the map\nprojection.\n\nThe flip side of this freedom is that there is not\nnecessarily a unique way, given $R_s$, to choose $R_e$. If one is regular,\nit may make sense to choose the other to also be regular. For irregular\ntriangles, one choice may be to choose $R_e$ such that its edges are\nproportial in length to those of $R_s$. Another may be to choose $R_e$ to have\nangles proportional to those of $R_s$: $\\alpha' = \\pi\n\\frac{\\alpha}{\\alpha+\\beta+\\gamma}$ etc. For quadrilaterals, it may be\ndesirable to carry over some quality from $R_s$ to $R_e$, but that may not\nuniquely define $R_e$: for instance, a quadrilateral is not uniquely defined\n(up to congruence) by its edge lengths alone, or its angles alone. In some\ncases, extra conditions make the choice more obvious: for example, if the\nspherical quadrilateral has equal sides and equal angles, it makes sense to\nmap it to a square. If the goal is to minimize overall distortion, one may\nchoose $R_e$ with that in mind. In the absence of guiding conditions,\naesthetics may be the best guide.\n\n\\subsection{Gnomonic}\nThe gnomonic projection was known to the ancient Greeks, and is the simplest\nof the transformations listed here.\\cite{snyder87} It has the property that\narcs of great circles are transformed into lines on the plane and vice versa:\nthat is, geodesics stay geodesics, and (spherical) polygons stay polygons. This\nprojection is called Method 1 in geodesic dome terminology.\\cite{kenner} The\nmain downside of the gnomonic projection is heavy distortion away from the\ncenter of the projection.\n\nWe'll describe this projection in vector form, which is a little unconvential\nbut will allow us to compare it to other projections later.\nLet $\\mathbf p$ be a point on a plane given in Hessian normal form by\n$\\hat{\\mathbf n} \\cdot \\mathbf p = r$. $r$ can be any value except 0.\nThe gnomonic projection can be described as so:\n\\begin{equation}\n  \\widetilde{\\mathbf v} = \\mathbf p\n\\end{equation}\n\\begin{equation}\n\\mathbf p = \\frac{r}\n  {\\hat{\\mathbf n} \\cdot \\hat{\\mathbf v}}\\hat{\\mathbf v}\n\\end{equation}\nProjection from Euclidean space to the sphere is literally just\nnormalizing the vector.\n\n\n\\subsection{Snyder equal-area}\nThe Snyder equal-area projection can be applied to any regular polygon. The\nequations in \\cite{snyder92} are lengthy, and don't seem to simplify much when\nexpressed in terms of vectors. The special cases of the hemisphere and the cube\nface do have nice simple forms, however.\\cite{lambers}\\cite{patt} Snyder's\nequations won't be repeated here.\n\nThe Snyder projection starts by subdividing a regular polygonal face into\nisosceles triangles, where two vertices of the new triangles are vertices of\nthe original polygon, and the third is the center of the polygon. Because of\nthis interruption, the projection is not differentiable on the lines from the\ncenter to the original vertices. This projection can be applied to faces larger\nthan a hemisphere, as long as each subdivision triangle is smaller than a\nhemisphere.\n\nThe Snyder projection does not require the faces of a polyhedron to be the\nsame, but does require (to maintain the equal-area property between\nsubdivsions) that the faces be subdividable into identical triangles. In\ngeneral, the Snyder equal-area projection cannot be adapted to irregular\npolygons while maintaining the equal-area property and not introducing extra\nlines of interruption. However, if a polyhedra is made up of identical\nisosceles triangles, and those triangles meet at appropriate edges, the map can\nbe applied directly to those faces without subdivision. (Isosceles triangles of\ndifferent dimensions may be allowed if one is willing to abandon either the\nequal-area property holding between different faces or the polygons on the\nplane fitting together into a net.) An example of an irregular polyhedra that\ncan be used in this way is an $n$-bipyramid, formed by gluing two $n$-sided\npyramids together at the $n$-gonal base. (This is effectively the same as\napplying the subdivision method to a $n$-dihedron.) Other polyhedra would\ninclude the (regular) icosahedron and octahedron and the tetragonal disphenoid\n(a stretched form of a tetrahedron with isosceles faces, of which the regular\ntetrahedron is a subtype).\n\n\\subsection{Fuller}\nthis entire section needs to be reworked\\cite{crider09}\n\\begin{figure}%[!htbp]\n\\begin{tikzpicture}\n  \\draw (2,2) circle [radius=2];\n\n  \\draw (0.6, 1) to [out=-25, in=205]\n  (3.4, 1) to [out=90, in=-35]\n  (2, 3.5) to [out=215, in=90]\n  (0.6, 1);\n  \\draw[fill] (2, 3.5) circle [radius=0.05] node[anchor=west] {\\tiny 1};\n  \\draw[fill] (0.6, 1) circle [radius=0.05] node[anchor=north] {\\tiny 2};\n  \\draw[fill] (3.4, 1) circle [radius=0.05] node[anchor=north] {\\tiny 3};\n  \\draw[dotted] (0.65, 1.5)  node[anchor=east] {\\tiny 1,2}\n  to [out=-15, in=195] (3.35, 1.5) node[anchor=west] {\\tiny 1,3};\n\n  \\draw[dotted] (1.8, 0.65) node[anchor=north] {\\tiny 3,2}\n  to [out=45, in=265] (2.9, 2.7) node[anchor=west] {\\tiny 3,1};\n  \\draw[dotted] (1.6, 3.1) node[anchor=east] {\\tiny 2,1}\n  to [out=-45, in=105] (2.9, 0.8) node[anchor=north] {\\tiny 2,3};\n\\end{tikzpicture}\n\\caption{Intersection of great circle arcs inside a spherical triangle,\nand the small spherical triangle formed by the arcs. Exaggerated so that the\nsmall triangle is visible; not to scale.}\n\\label{fig:intlines}\n\\end{figure}\n\nThis method can be extended to the Quadrilateral. Use Slerp to find points on\nopposing sides of the quadrilateral, use the cross product to find their\nnormal, and then use the cross product to find the point of intersection. Since\nwe draw two intersecting lines, there is only one point of intersection within\nthe quadrilateral. The formula is:\n\\begin{equation}\\label{eq:gcq}%??? does this reduce to slerp on the edges?\n\\widetilde{\\mathbf v} =\n(\\mathrm{Slerp}(\\mathbf v_1, \\mathbf v_2; \\frac{u+1}{2})\n\\times\n\\mathrm{Slerp}(\\mathbf v_4, \\mathbf v_3; \\frac{u+1}{2}))\n\\times\n(\\mathrm{Slerp}(\\mathbf v_1, \\mathbf v_4; \\frac{v+1}{2})\n\\times\n\\mathrm{Slerp}(\\mathbf v_2, \\mathbf v_3; \\frac{v+1}{2}))\n\\end{equation}\n\nThis is similar to the Great Circle method, except instead of using the great\ncircles to calculate the intersections of the lines, we use another spherical\nlinear interpolation to get a point near the intersection. We effectively use\nthe Lerp formulas from the section on coordinates, substituting Slerp for Lerp.\nUnlike Lerp, Slerp does not commute, so we take the different permutations of\nthe arguments and combine the different points that result.\n\n\n(square)\nSolve for $u, v$:\n\\begin{equation}\n  \\begin{split}\n\\begin{vmatrix} \\mathbf v &\n\\mathrm{Slerp}(\\mathbf v_1, \\mathbf v_2; \\frac{u+1}{2}) &\n\\mathrm{Slerp}(\\mathbf v_4, \\mathbf v_3; \\frac{u+1}{2}) \\end{vmatrix} &= 0 \\\\\n\\begin{vmatrix} \\mathbf v &\n\\mathrm{Slerp}(\\mathbf v_1, \\mathbf v_4; \\frac{v+1}{2}) &\n\\mathrm{Slerp}(\\mathbf v_2, \\mathbf v_3; \\frac{v+1}{2}) \\end{vmatrix} &= 0\n\\end{split}\\end{equation}\n\n\\subsection{Naive Slerp}\nThe Naive Slerp method is derived by a naive analogy with spherical linear\ninterpolation (Slerp) extended to $uv$ coordinates, thus the\nname.\n\nThese are two functions that can be derived by analogy with $uv$ coordinates.\nLet $w_{ij}$ be the spherical length of the edge between vertices $i$ and $j$.\nOne:\n\\begin{equation}\\begin{split}\\label{eq:nsq1}\n   \\widetilde{\\mathbf v} & = \\sum_{i=1}^4\\frac{s_i}{\\sin(w_u)\\sin(w_v)}  \\mathbf v_i \\\\\ns_1 & = \\sin \\left(w_u\\frac{1-u}{2}\\right)\\sin \\left(w_v\\frac{1-v}{2}\\right) \\\\\ns_2 & = \\sin \\left(w_u\\frac{1+u}{2}\\right)\\sin \\left(w_v\\frac{1-v}{2}\\right) \\\\\ns_3 & = \\sin \\left(w_u\\frac{1+u}{2}\\right)\\sin \\left(w_v\\frac{1+v}{2}\\right) \\\\\ns_4 & = \\sin \\left(w_u\\frac{1-u}{2}\\right)\\sin \\left(w_v\\frac{1+v}{2}\\right)\n\\end{split}\\end{equation}\nwhere\n\\begin{equation}\\begin{split}\n  w_u &= (1-v) w_{12} + (1+v) w_{34},\\\\\n  w_v &= (1-u) w_{23} + (1+u) w_{14}\n\\end{split}\\end{equation}\nUnlike before, the interpolations of $w_u$ and $w_v$ do not have undefined\npoints. However, they may cause undefined values in the mapping if there is a\npoint where one is equal to zero.\n\nTwo:\n\\begin{equation}\\begin{split}\\label{eq:nsq2}\n     \\widetilde{\\mathbf v} & = \\sum_{i=1}^4\\frac{\\sin(w\\gamma_i)}{\\sin(w)} \\mathbf v_i \\\\\n\\gamma_1 & = \\frac{(1-u)(1-v)}{4} \\\\\n\\gamma_2 & = \\frac{(1+u)(1-v)}{4} \\\\\n\\gamma_3 & = \\frac{(1+u)(1+v)}{4} \\\\\n\\gamma_4 & = \\frac{(1-u)(1+v)}{4}\n\\end{split}\\end{equation}\n\nwhere\n\\begin{equation}\\begin{split}\n  w = \\frac{t_{12} w_{12} + t_{23} w_{23} + t_{34} w_{34} + t_{41} w_{41}}\n              {t_{12} + t_{23} + t_{34} + t_{41}}\\\\\n  t_{12} &= (1-u)(1-v)(1+u) \\\\\n  t_{23} &= (1-v)(1+u)(1+v) \\\\\n  t_{34} &= (1-u)(1+u)(1+v) \\\\\n  t_{41} &= (1-u)(1-v)(1+v)\n\\end{split}\\end{equation}\nAgain, this expression is undefined at the vertices, but can be replaced with\nany positive value there. If all the edges are equal length, $w$ can be\nreplaced with that constant edge length.\n\n\\subsubsection{Projection of $\\widetilde{\\mathbf v}$}\nThe naive slerp methods produces unit vectors along the edges. Because the\nprojected edges already lie on the sphere, we have freedom in how to adjust\n$\\widetilde{\\mathbf v}$ to lie on the sphere. The easiest is just to centrally\nproject the vertices, that is, to normalize $\\widetilde{\\mathbf v}$ like we\nhave been. Another option is to perform a parallel projection along the\nface normal, as defined earlier. We need the parallel distance $p$ from the\nvertex to the sphere surface in the direction of the face normal\n$\\hat{\\mathbf n}$, such that $\\hat{\\mathbf v} =\n\\widetilde{\\mathbf v} + p\\hat{\\mathbf n}$. $p$ is given by:\n\\begin{equation}\n   p = -\\widetilde{\\mathbf v} \\cdot \\hat{\\mathbf n} +\n   \\sqrt{1+\\widetilde{\\mathbf v} \\cdot \\hat{\\mathbf n}-\\widetilde{\\mathbf v} \\cdot \\widetilde{\\mathbf v}}\n\\end{equation}\n$p$ can also be approximated as $\\widetilde{p} = 1 - \\|\\widetilde{\\mathbf v}\\|\n\\leq p$, which takes fewer operations and doesn't require\ncalculation of the face normal. Technically, you can project in almost any\ndirection, not just that of the face normal, but most other choices don't\nproduce a symmetric result.\n\nReally, the projection can be performed from any point in space. Central\nprojection uses rays from a point at the center of the sphere, and parallel can\nbe thought of as using rays from a point at infinity. Instead of specifying the\npoint, we define a linear combination of the two projections:\n\\begin{equation}\n  \\hat{\\mathbf v} = \\frac{\\widetilde{\\mathbf v} + kp\\mathbf c}{\\|\\dots\\|}\n\\end{equation}\nWhen $k=0$, that's the central projection: when $k=1$, it's the parallel\nprojection. $p$ may be replaced by $\\widetilde{p}$. If our goal is to optimize\na measurement of the map projection, like conformality or area distortion, we\ncan do a 1-variable optimization on $k$.\n\n\\subsubsection{Spherical rectangle}\nNaive slerp 1 simplifies nicely for some particular spherical rectangles and\nsquares. Let the target rectangle be defined by the points $(-a,-b,c)$,\n$(a,-b,c)$, $(a,b,c)$, and $(-a,b,c)$ where $a, b, c$ are in $[0,1]$ and\n$a^2 + b^2 + c^2 = 1$. The spherical center of this rectangle, and the face\nnormal, is $(0,0,1)$. Naive slerp 1 from the standard square to this rectangle\nis expressible as so:\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= \\frac{\\sin(\\frac{w_u}{2}u) \\cos(\\frac{w_v}{2}v) }\n    {\\sqrt{1-b^2}}\\\\\n  \\widetilde{y} &= \\frac{\\cos(\\frac{w_u}{2}u) \\sin(\\frac{w_v}{2}v) }\n    {\\sqrt{1-a^2}}\\\\\n  \\widetilde{z} &=\\frac{c}{\\sqrt{1-a^2}\\sqrt{1-b^2}}\n    \\cos(\\frac{w_u}{2}u) \\cos(\\frac{w_v}{2}v)\n\\end{split}\\end{equation}\nwhere $cos(w_u) = 1 - 2 a^2$ and $cos(w_v) = 1 - 2 b^2$.\n\nIn the case where $a=b$, denote $w = w_u = w_v$,\nso the above can be expressed as:\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= \\frac{\\sin\\left(\\frac{w}{2}(u+v)\\right) +\n    \\sin\\left(\\frac{w}{2}(u-v)\\right)}\n    {2\\sqrt{1-a^2}}\\\\\n  \\widetilde{y} &= \\frac{\\sin\\left(\\frac{w}{2}(u+v)\\right) -\n    \\sin\\left(\\frac{w}{2}(u-v)\\right)}\n    {2\\sqrt{1-a^2}}\\\\\n  \\widetilde{z} &=\\frac{c}{2-2a^2}\\left(\\cos\\left(\\frac{w}{2}(u+v)\\right) +\n    \\cos\\left(\\frac{w}{2}(u-v)\\right)\\right)\n\\end{split}\\end{equation}\nwhich demonstrates that this mapping on this polygon preserves diagonal lines.\n\nIn the case when $c=0$,\nand the spherical rectangle takes up an entire hemisphere, the formula further\nreduces to:\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= \\frac{\\sin(\\frac{w_x}{2}u) \\cos(\\frac{w_y}{2}v) }\n    {a}\\\\\n  \\widetilde{y} &= \\frac{\\cos(\\frac{w_x}{2}u) \\sin(\\frac{w_y}{2}v) }\n    {b}\\\\\n  \\widetilde{z} &=0\n\\end{split}\\end{equation}\n\nIn the limit where $c=0$ and $b = 0$,\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= \\sin(\\frac{\\pi}{2}u) \\\\\n  \\widetilde{y} &= v \\cos(\\frac{\\pi}{2}u) \\\\\n  \\widetilde{z} &= 0\n\\end{split}\\end{equation}\n\n\\subsection{Elliptical}\nThis quadrilateral map is based on naive slerp 1 on a spherical rectangle, as\ndescribed in the previous section. Let the vertices of the rectangle be defined\nas before.\n\n$\\sin(k x)$ may be approximated as $\\sin(k)x$, where the two expressions are\nequal at $x=-1,0,1$. Similarly, $\\cos(k x)$ may be approximated as\n$\\sqrt{1 - \\sin^2(k) x^2}$. This approximation was applied in \\cite{reynolds} to\nproduce an approximate equal-area homeomorphism, as it maintains the boundary\nof the shape where $x=\\pm1$ or $y=\\pm1$. Applying this approximation\nto the equation for naive slerp on a spherical rectangle yields:\n\n\\begin{equation}\\begin{split}\\label{eq:elliptical}\n  \\widetilde{x} &= au \\frac{\\sqrt{1-b^2 v^2} }\n    {\\sqrt{1-b^2}}\\\\\n  \\widetilde{y} &= bv \\frac{\\sqrt{1-a^2 u^2} }\n    {\\sqrt{1-a^2}}\\\\\n  \\widetilde{z} &=c \\frac{\\sqrt{1-a^2 u^2}\\sqrt{1-b^2 v^2} }\n    {\\sqrt{1-a^2}\\sqrt{1-b^2}}\n\\end{split}\\end{equation}\n\nIn the case when $c=0$, and the spherical rectangle takes up an entire\nhemisphere, the formula reduces to:\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= u \\sqrt{1-b^2 v^2} \\\\\n  \\widetilde{y} &= v \\sqrt{1-a^2 u^2} \\\\\n  \\widetilde{z} &= 0\n\\end{split}\\end{equation}\n\nWhen $a=b=\\frac{1}{\\sqrt{2}}$, this is the Nowell's elliptical function from\nthe square to the disk.\\cite{nowellsq}\\cite{fong17} Furthermore, when $c=b=0$,\n\\begin{equation}\\begin{split}\n  \\widetilde{x} &= u  \\\\\n  \\widetilde{y} &= v \\sqrt{1 - u^2} \\\\\n  \\widetilde{z} &= 0\n\\end{split}\\end{equation}\nwhich is the \"squelch\" function from the square to the disk in \\cite{fong17}.\n\n\\subsection{Grid-based}\n\n\\subsubsection{Inversion}\n\n\\subsubsection{Repeated subdivision}\nMethod 3 in geodesic dome terms\n\n\\section{Analysis}\n\\subsection{From the sphere to the plane}\n\n\\subsection{From the plane to the sphere}\n\n\\section{Conclusion}\n\n\\bibliographystyle{plain}\n\\bibliography{references}\n\n\\end{document}\n", "meta": {"hexsha": "7d2f5e721f19b02c79743f3ae0749ccfeb190b80", "size": 32914, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/spherical grids/quad_map_projections.tex", "max_stars_repo_name": "brsr/mapproj", "max_stars_repo_head_hexsha": "1ec1694149a69da6393ecb94650f7164e3cfd2e1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/spherical grids/quad_map_projections.tex", "max_issues_repo_name": "brsr/mapproj", "max_issues_repo_head_hexsha": "1ec1694149a69da6393ecb94650f7164e3cfd2e1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/spherical grids/quad_map_projections.tex", "max_forks_repo_name": "brsr/mapproj", "max_forks_repo_head_hexsha": "1ec1694149a69da6393ecb94650f7164e3cfd2e1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.9795918367, "max_line_length": 207, "alphanum_fraction": 0.708847299, "num_tokens": 10944, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40714073042787957}}
{"text": "\\chapter{Introduction}\n\n%\\parbf{What is reactive synthesis?}\n{\\small\n\\noindent\n\\li\n\\-[Dave:~] Hey, Elli, how can I calculate the week number from the date?\n\\vspace{-3mm}\n\\-[Elli:~] ...prints the C-function.\n\\vspace{-3mm}\n\\-[Dave:~] Great. Can this function also output three last requested dates?\n\\vspace{-3mm}\n\\-[Elli:~] ...prints another C-function.\n\\vspace{-3mm}\n\\-[Dave:~] Thanks. Can you also make it output the name of the requesting person?\n\\vspace{-3mm}\n\\-[Elli:~] I am sorry, Dave, I am afraid I can't do that.\n\\il\n}\n\nIn synthesis,\nwe describe the required behaviour and ask the computer to find the solution\nwith such a behaviour.\n(In the dialog above,\n Dave asks Elli to find a function that,\n given a date, outputs the week number to which the date belongs.)\nIn \\emph{reactive} synthesis, we are interested not in simple ``do-and-forget'' functions,\nbut rather in functions that interact with the user\nakin to functions with an internal state.\n(In the dialog above, the second C-function is reactive.)\nIt is not always possible to find a solution,\nin which case the synthesizer (Elli) outputs ``specification is unrealizable''.\n(In the last dialogue request, the specification became unrealizable,\n because the person name is not available to the function to be synthesized.)\n%To summarise, reactive synthesis is an automatic way\n%to translate a human intention expressed in some language\n%into a system of some kind.\n\n%\\parbf{What is reactive synthesis problem?}\n\nIn 1963, Alonzo Church introduced the reactive synthesis problem~\\cite{Church63}:\ngiven a formula in Monadic Second Order Logic of One Successor,\nand the inputs and the outputs of a circuit,\nfind such a circuit such that all behaviors of the circuit satisfy the formula.\n(The circuit behaviour is an infinite string of inputs combined with the outputs.)\nChurch's problem was solved by Rabin~\\cite{Rabin69} and\nby B\\\"uchi and Landweber~\\cite{BL69} in 1969.\\ak{how?}\n\n%\\parbf{Recent progress of reactive synthesis}\n\nRecent research in reactive synthesis focused on specifications\ngiven in Linear Temporal Logic (LTL),\nintroduced by Pnueli~\\cite{pnueli1977temporal} in 1977.\nLTL has temporal operators, like $\\G$ (always) and $\\F$ (eventually),\nand allows one to state properties like ``every request is eventually granted'':\n$\\G(r \\impl \\F g)$.\nA system satisfies a given LTL property if all its computations satisfy it.\nPnueli and Rosner proved~\\cite{DBLP:conf/popl/PnueliR89}\nthat the LTL synthesis problem is 2EXPTIME-complete.\nTheir approach translates a given LTL formula into a nondeterministic B\\\"uchi automaton,\nthen determinises it into a deterministic parity automaton\nwith the aid of involved Safra construction~\\cite{Safra},\nturns the automaton into a game, and solves the game.\nRecent research focused on how to overcome the high complexity and Safra construction:\nthe work~\\cite{Bloem12} considered the synthesis for a subset of LTL called GR(1),\nthe work~\\cite{BS,KupfermanV05} considered bounding the system size and gave a name to Bounded Synthesis,\nby combining the previous bounding with efficient data structures---Anti-chains Synthesis~\\cite{Filiot11}.\nThe SYNTCOMP competition~\\cite{syntcomp} is another recent initiative\nwith the goal to advance efficient synthesisers and popularise reactive synthesis.\n\n%\\parbf{The issues with reactive synthesis}\n\nDespite substantial progress,\nreactive synthesis is not as widespread as model checking.\nThe major reason, I believe,\nis that writing the specifications---especially \\emph{complete} specifications---is hard.\nThe issue is less pronounced in model checking,\nbecause we do not need all the properties,\nonly those to model check.\n\n%\\parbf{In light of this issue, two directions to proceed}\n\nIn light of this issue, there are two directions to proceed.\nFirst, we can develop synthesis approaches for richer logics,\nwhich can ease writing the specifications.\nSecond, we can find application contexts where high specification costs are acceptable.\nThis thesis targets both directions:\nwe develop new synthesis approaches for the logic called \\CTLstar,\nand we delve into synthesis of distributed algorithms.\n\n\\subsection*{Part I: Excursion into Branching Logic}\n\n%\\parbf{when was CTL introduced?}\n\nComputation Tree Logic (CTL)~\\cite{ctl-origin}\nwas introduced by Emerson and Clarke in 1981\nto circumvent the high complexity (PSPACE-complete) of the LTL model checking problem\nand to be able to specify structural properties.\nIn 1986 Emerson and Halpern introduced a generalization,\nComputation Tree Star Logic (\\CTLstar)~\\cite{ctlstar-origin},\nthat subsumes both CTL and LTL.\n\n%\\parbf{what is \\CTLstar?}\n\nIn contrast to LTL, which reasons about (linear) computation runs,\n\\CTLstar reasons about (branching) computation trees.\nWe can get such a tree by unfolding the system transition structure.\n\\CTLstar has---in addition to temporal operators---path quantifiers:\n$\\A$ (on all paths) and $\\E$ (there exists a path).\nSuch path quantifiers allow us to reason about branching structure of trees,\nnot just about their ``linear'' paths.\nFor example, \\CTLstar formula ``$\\AGEF reset$'' says:\n``on all tree paths, from every tree node,\n  there should be a path into a node where `reset' holds''.\nWe cannot express such a property using LTL alone.\n\n%\\parbf{what advantages does CTL* have over LTL?}\n\nDespite \\CTLstar being more expressible than LTL,\nthe complexity of \\CTLstar synthesis (2EXPTIME-complete)\nstays the same.\nThis prompted us to look into approaches to \\CTLstar synthesis.\n\n%\\parbf{what is the standard solution to CTL*?}\n\nThe standard solution~\\cite{informatio} to \\CTLstar synthesis\nturns the \\CTLstar formula into an alternating hesitant tree automaton,\nremoves nondeterminism and derives a universal co-B\\\"uchi tree automaton,\ndeterminises it using Safra construction~\\cite{Safra} into a parity tree automaton,\nand, finally, checks its non-emptiness.\nIf it is empty, then the specification is unrealisable,\notherwise we can extract the system from the proof of the non-emptiness.\nThis approach is hard to implement correctly and efficiently,\ndue to the involved Safra construction%\n\\footnote{It was a common belief that the Safra construction\n  is difficult to implement and results in impractical algorithms.\n  However, the belief might be wrong,\n  as SYNTCOMP~\\cite{syntcomp} in 2017 showed:\n  the LTL synthesiser {\\tt ltl-synt} that used Safra construction performed very well.}.\n\n%\\parbf{what is our contribution to CTL* synthesis?}\n\nPart I contribution is two practical approaches to \\CTLstar synthesis.\n\n\\subsubsection*{Contribution I.1: \\CTLstar Bounded Synthesis}\n\nWe developed two bounded synthesis approaches for the \\CTLstar specifications.\nLet us recall how the SMT-based bounded synthesis by Schewe and Finkbeiner~\\cite{BS} works:\nwe bound the system size, and\nencode the resulting synthesis problem into an SMT query\\footnote{%\n  Satisfiability Modulo Theory (SMT)~\\cite{SMT} query is a\n  set of constraints over in a given theory.\n  For example, in Linear Integer Arithmetic theory,\n  the constraints talk about integer variables,\n  use operations plus, minus, and the comparison relations.\n  Such a query asks whether there are values for integer variables\n  that make the constraint true.}.\nThe query encodes the model checking question:\nwhether a system---which is yet unknown---is accepted by the automaton.\nBounding the system size makes it possible to encode such a model checking query\ninto an SMT query.\nTo solve such a query,\nan SMT solver efficiently enumerates every possible system of a given size,\nand checks if it is correct.\nThus, if the SMT query is satisfiable, then we extract the system (of the given size),\notherwise increase the system size and repeat.\nThe loop stops when the bound on the system size%\n---provided by the user or from the theory---is reached.\n\nOur first bounded synthesiser for \\CTLstar\nresembles bottom-up \\CTLstar model checking~\\cite{PrinciplesMC}:\nit introduces an atom for each subformula of the \\CTLstar formula,\nand encodes into an SMT query whether the atom holds in a system state,\nfor every state.\nWe also require the top-level atom, representing the whole \\CTLstar formula,\nto hold in the initial system state,\nHence, if the SMT query is satisfiable,\nthen there is a system of the given size,\nwhich satisfies the \\CTLstar formula.\nOtherwise, increase the system size and repeat.\n\nOur second bounded synthesiser for \\CTLstar uses the automata framework~\\cite{ATA}:\ntranslate the \\CTLstar formula into an alternating hesitant automaton,\nthen encode into an SMT query\nwhether there is a system of a given size that is accepted by the automaton.\nConceptually, the approach is the same as the previous one,\nexcept that we do not introduce atoms for subformulas explicitly\nand instead use their automata representation.\n\nThe results constitute Chapter~\\ref{chap:bosy:ctlstar} and were published in:\n\\li\n\\-[\\cite{CTLstarCAV}]\n   \\emph{Bounded Synthesis for Streett, Rabin, and \\CTLstar},\n   by Ayrat Khalimov and Roderick Bloem,\n   at CAV conference, 2017\n\\il\n\n\\subsubsection*{Contribution I.2: \\CTLstar-via-LTL Synthesis}\n\nWe reduce synthesis for \\CTLstar properties to synthesis for LTL.\nIn the context of model checking this is impossible%\n---\\CTLstar is more expressive than LTL.\nYet, in synthesis we have knowledge of the system structure\n\\emph{and} we can add new outputs.\nThese outputs can be used to encode witnesses of\nthe satisfaction of \\CTLstar subformulas directly into the system.\nThis way, we construct an LTL formula, over old and new outputs and original inputs,\nwhich is realisable if, and only if, the original \\CTLstar formula is realisable.\nThe \\CTLstar-via-LTL synthesis approach preserves the problem complexity,\nalthough it might produce systems that are larger than necessary.\nFurthermore,\nthe approach directly benefits from the performance advances of LTL synthesisers.\nThe results constitute Chapter~\\ref{chap:ctl-via-ltl} and were published in:\n\\li\n\\-[\\cite{CTLsynt-via-LTLsynt}]\n  \\emph{\\CTLstar Synthesis via LTL Synthesis},\n  by Roderick Bloem and Sven Schewe and Ayrat Khalimov,\n  at SYNT workshop, 2017\n\\il\n\n\n\\subsection*{Part II: Excursion into Parameterized Systems}\n\n%\\parbf{why do we consider parameterized systems?}\n\nModern systems become more and more distributed.\nDistributed systems are hard to implement and even harder to debug.\nYet, the failure of such systems may be unacceptable.\nThus, substantial efforts are devoted to ensure the correctness of distributed systems.\nIn Part II,\nwe look into the hard task of automatic synthesis of distributed parameterized systems.\n\n%\\parbf{what is the parametrized synthesis problem?}\n\nMost distributed systems, algorithms, and data structures are \\emph{parameterized}:\nthey should work for a varied, not a priori fixed, number of the components.\n%We call such systems parameterized (by the number of components).\nThe parameterized synthesis problem~\\cite{JB14} asks, given\na parameterized specification, to find a process template,\nthat can be cloned to form a correctly behaving system of any size.\nAn example parameterized specification is:\n\\[ \\begin{array}{ll}\n  \\forall i \\neq j.~ & \\G \\neg ( g_i \\land g_j ) \\land \\\\\n  \\forall i.~ & \\G (r_i \\impl \\F g_i).\n  \\end{array}\n\\]\nThe synthesizer should find a process template, having input $r$ and output $g$,\nsuch that a system composed of any number of such processes,\nsatisfies the above specification.\nThe related question is that of parametrized model checking\nwhere the process template is given.\nThe intrinsic parameter,\nhidden in the parameterized synthesis problem,\nis how the processes are connected and how they communicate,\ni.e., the system architecture.\nThe survey of existing cutoff and decidability results\nfor many different system architectures can be found in~\\cite{BloemETAL15}.\nWe focus on two system architectures: guarded systems and token-ring systems.\n\n%\\parbf{what is the standard solution to parameterized synthesis problem?}\n\nA common approach to solve the parameterized synthesis and model checking problems\nis to use the cutoff reduction~\\cite{Emerso03}:\nreduce reasoning about systems with an arbitrary number of processes\nto reasoning about systems of a fixed cutoff size.\nFor example,\nif we consider the parameterized specification mentioned above and token-ring systems,\nthen it is enough to consider a system with 4 processes:\nif it is correct, then any larger system is correct.\n\n%\\parbf{what is our contribution?}\n\n\\subsubsection*{Contribution II.1: Cutoffs for Parameterized Guarded Systems}\n\nGuarded systems~\\cite{EmersonK03} are inspired by cache coherence protocols found\nin most modern processors.\nA cache coherence protocol is usually described by states,\nwhere transitions between states happen depending on whether or not\nthere is a processor in a particular state.\nI.e., the transitions are guarded.\nInspired by this, in guarded systems,\nprocesses transitions are enabled or disabled depending\non the existence of other processes in certain local states.\nOur contribution concerns both parameterized synthesis and parameterized verification.\nOur work stems from the observation that\nexisting cutoff results for guarded systems\n(i) are restricted to closed systems, and\n(ii) are of limited use for liveness properties\nbecause reductions do not preserve fairness.\nWe close these gaps and obtain new cutoff results for open systems with\nliveness properties under fairness assumptions.\nFurthermore, we obtain cutoffs for the detecting deadlocks,\nwhich are of paramount importance in synthesis.\nFinally, we prove tightness or asymptotic tightness for the new cutoffs.\nThe results constitute Chapter~\\ref{chap:guarded-systems}\nand were published in:\n\\li\n\\-[\\cite{AJK16}]\n   \\emph{Tight Cutoffs for Guarded Protocols with Fairness},\n   by Simon Au{\\ss}erlechner and Swen Jacobs and Ayrat Khalimov,\n   at VMCAI conference, 2016\n\\il\n\n%\\parbf{what is the problem with the existing parameterized synthesis?}\n\n\\subsubsection*{Contribution II.2: Case Study of Parameterized Token-ring AMBA}\n\nIn token-ring systems, a single token circulates in the system.\nA process possessing the token knows that no other process has the token.\nBased on this information, the process can, for example, raise the grant signal.\nIf all processes raise the grant only when they posses the token,\nthen the grants will be mutually exclusive.\nThus, the token serves as the resource token.\n\nThe experiments with the existing parameterized synthesis method~\\cite{JB14}\nshowed that it does not scale to large specifications.\nFirst, we optimize the method by refining the cutoff reduction.\nThe experiments show speed-ups of several orders of magnitude.\nSecond, we perform parameterized synthesis case study\non the industrial arbiter protocol AMBA~\\cite{AMBAspec}.\nWe describe new cutoff extension and decompositional synthesis tailored to AMBA\nthat, together with the previously mentioned optimizations,\nallowed us to synthesize AMBA in parameterized setting, for the first time.\nThe results constitute Chapter~\\ref{chap:token-systems}\nand were published in:\n\\li\n\\-[\\cite{Khalimov13}]\n   \\emph{Towards Efficient Parameterized Synthesis},\n   by Ayrat Khalimov and Swen Jacobs and Roderick Bloem,\n   at VMCAI conference, 2013\n\\-[\\cite{party}]\n   \\emph{PARTY: Parameterized Synthesis of Token Rings},\n   by Ayrat Khalimov and Swen Jacobs and Roderick Bloem,\n   at CAV conference, 2013\n\\-[\\cite{BJK14}]\n   \\emph{Parameterized Synthesis Case Study: AMBA AHB},\n   by Ayrat Khalimov and Swen Jacobs and Roderick Bloem,\n   at SYNT workshop, 2014\n\\il\n\n\\subsection*{Other Results}\n\nHere are the results that did not make their way into the thesis:\n\\li\n\\-[\\cite{BloemETAL15}]\n   \\emph{Decidability of Parameterized Verification},\n   book of 170 pages,\n   by Roderick Bloem and\n               Swen Jacobs and\n               Ayrat Khalimov and\n               Igor Konnov and\n               Sasha Rubin and\n               Helmut Veith and\n               Josef Widder.\\\\\nIn this book we consider the important case of systems parameterized by the number of processes in the system\nand where each process is independent of that number.\nThe literature in this area produced a wealth of computational models for systems based on token passing,\nbroadcast communication, guarded transitions, and other communication primitives.\nWe introduce a computational model that unites the central synchronization and\ncommunication primitives of many models.\nWe survey existing decidability and undecidability results,\nand provide a systematic overview of the basic problems in this research area.\n\n\n\\-[\\cite{DBLP:journals/sigact/BloemJKKRVW16}]\n   \\emph{Decidability in Parameterized Verification},\n   the journal version of the above book; appeared in SIGACT News in 2016.\n\n\\-[\\cite{DBLP:journals/corr/Khalimov16}]\n   \\emph{Specification Format for Reactive Synthesis Problems},\n   by Ayrat Khalimov,\n   at SYNT workshop, 2015.\\\\\nTo do synthesis, we need a specification.\nWriting specifications is hard.\nIn this paper, we propose a user-friendly format to ease\nthe specification work, in particularly, that of specifying partial implementations.\nAlso, we provide scripts to convert specifications in the new format into the SYNTCOMP format,\nthus benefiting from state of the art synthesizers.\n\n\\-[\\cite{AJKR14}]\n   \\emph{Parameterized Model Checking of Token-Passing Systems},\n   by Benjamin Aminof and\n               Swen Jacobs and\n               Ayrat Khalimov and\n               Sasha Rubin,\n   at VMCAI conference, 2014.\\\\\nIn this paper, we revisit the parameterized model checking problem for token-passing\nsystems and specifications in indexed $\\CTLstarmX$.\n%In foundational work, Emerson and Namjoshi (1995, 2003) showed that\n%parameterized model checking of indexed \\CTLstarmX in uni-directional token rings\n%can be reduced to checking rings up to some cutoff size.\n%Clarke et al. (2004) showed a similar result for general topologies and indexed \\LTLmX,\n%provided processes cannot choose the directions for sending or receiving the token.\nWe unify and substantially extend the results of Emerson and Namjoshi~\\cite{Emerso95b,Emerso03}\nand Clarke et al.~\\cite{Clarke04c}\nby systematically exploring fragments of indexed \\CTLstarmX with respect to general network topologies.\nFor each fragment we establish whether a cutoff exists,\nand for some concrete topologies, such as rings, cliques and stars, we infer small cutoffs.\nFinally, we show that the problem becomes undecidable, and thus no cutoffs exist,\nif processes are allowed to choose the directions in which they send or from which they receive the token.\n\n\\-[\\cite{2017arXiv171204291K}]\n  \\emph{OpenSEA: Semi-Formal Methods for Soft Error Analysis},\n  by Patrick Klampfl and Robert K\\\"onighofer and Roderick Bloem and Ayrat Khalimov and\n  Aiman Abu-Yonis  and Shiri Moran,\n  on arxiv, 2017.\\\\\nDue to alpha-particles and cosmic rays, modern circuits are prone to bit flips.\nTo alleviate the problem, designers develop protection circuits,\nbut they are hard to implement right.\nThis leads to bugs: an undetected fault can bring miscalculations,\nthe protection that alarms about harmless faults incurs performance penalty.\nIn this paper, we use formal methods on designer’s input tests, while keeping time-location open.\nThis idea is at the core of the tool OpenSEA.\nOpenSEA can\n(i) find latches vulnerable to and protected against faults,\n(ii) find tests that exhibit checker false alarms,\n(iii) use fixed and open inputs, and\n(iv) use environment assumptions.\nEvaluation on a number of industrial designs shows that OpenSEA produces valuable results.\n\\il\n", "meta": {"hexsha": "d90b154d47078e387201dd952623bbc61e9ba20d", "size": 19638, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/intro.tex", "max_stars_repo_name": "5nizza/phd-thesis", "max_stars_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/intro.tex", "max_issues_repo_name": "5nizza/phd-thesis", "max_issues_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/intro.tex", "max_forks_repo_name": "5nizza/phd-thesis", "max_forks_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.6460807601, "max_line_length": 109, "alphanum_fraction": 0.7874528974, "num_tokens": 4615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40714073042787957}}
{"text": "\\section{Toric Code}\nLast time I talked about $U(1)$ and $\\ZZ_2$ lattice gauge theory,\nand I said that we can make the Gauss law constraint an energetic constraints.\nI emphasised that this is dramatic change to the system,\nbecause it's not just change the Hamiltonian but fundamentally changes the\nHilbert space.\nBefore we had a constrained Hilbert space,\nwhereas afterwards,\nour Hilbert space is just that of a many-spin system.\nOur Hilbert space decomposes into a tensor product of qubits on sites\nand qubits on links.\n\\begin{align}\n    \\mathcal{H}\n    =\n    \\underbrace{\\bigotimes_{i\\in\\mathrm{sites}} \\CC^2}_{\\text{matter}}\n    \\otimes \n    \\underbrace{\\bigotimes_{i\\in\\mathrm{links}} \\CC^2}_{\\text{gauge field}}\n\\end{align}\nThis is an important conceptual shift.\nBefore you think gauge theory is something special and were does it come\nfrom.Gauge theory was put on some crazy pedestal.\nOnce you understand this point,\nyou can think of the gauge field as just some phase of a many-body spin system.\nYou automatically have an emergent gauge field that is dynamical and so on.\nYou realise that gauge theory can emerge from some interacting spin system.\n\nIn a way,\nthis addresses one of the great fundamental question in physics,\nand we now understand gauge theory can come from pretty many any many-body system\nemerging dynamically.\n\n\\begin{question}\n    Can we create a QED theory from this?\n\\end{question}\nYes.\nYou could get nonce normalizable gauge theories.\n\nWe removed the constraint entirely,\nbut we have some particular term in the Hamiltonian that enforces.\n\n\\begin{question}\n    Is this a computational or conceptual advance?\n\\end{question}\nIt's more a conceptual advance,\nbut we could simulate spin system.so\nIt convinces us that gauge theories can emerge from a system that has no gauge\nfields.\nWhether the standard model arises from this is its own question.\nThe standard model has Lorentz invariance,\nthere are a lot of gapless particles and they all have the same speed.\nIt's not obvious how to get that.\n\nYou can show that for some systems if you go to low energy Lorentz invariance\ncan emerge,\nbut it's slow and logarithmic so people are not convinced.\nBut gravity is nowhere here.\n\nPeople think it can emerge if the cosmological spacetime is anti-de Sitter\nspace,\nbut that's a different story.\n\nLast time,\nwe went to pure $\\ZZ_2$ lattice gauge theory\nwith Gauss law implemented energetically.\nAnd we had a Hamiltonian on plaquettes and vertices.\n\\begin{align}\n    H &=\n    -K \\sum_{\\square} B_{\\square}\n    - J \\sum_{+} A_{+}\n    - h\\sum_{l} \\sigma_l^{x}\n\\end{align}\nwhere\n\\begin{align}\n    B_{\\square} &=\n    \\prod_{l \\in \\square}\n    \\sigma_l^z\\\\\n    A_{+} &=\n    \\prod_{l\\in +}\n    \\sigma_l^x\n\\end{align}\nIf we set $h=0$,\nthis model is the famous $\\ZZ_2$ toric code model of Kitaev.\nAnd what's special about his $h=0$ limit is that every term commutes with each\nother and the mole becomes exactly solvable.\n\nFrom now on,\nI will only talk about the $h=0$ limit that is exactly solvable because\nthe $B$'s and the $A$'s all commute with each other.\nIt's easy to see that because if you take a plaquette and a vertex star,\nif they don't overlap they obviously commute.\nBut if they overlap,\nthey will always share two links with two $\\sigma_x$ and $\\sigma_z$.\n\nThus we can simultaneously diagonalize every operator here.\nBecause they are all Paulis,\n$B^2=1$ and $A^2=1$,\nso we can just go into  some basis that simultaneously diagonalises these and the\nstar is just labelled by the eigenvalues $\\pm 1$ of these operators.\nExcited states would correspond to flipping these eigenvalues.\n\nWe can actually add a constant to this Hamiltonian and make it a sum of\ncommuting projectors.\nWe can define the projector for a plaquette as\n\\begin{align}\n    P_{\\square}\n    &=\n    \\frac{1}{2}\\left( \n    1 - B_{\\square}\n    \\right)\n\\end{align}\nso that $P_{\\square}^2 = p_{\\square}$\nand similarly for the vertices\n\\begin{align}\n    P_{+}\n    &=\n    \\frac{1}{2}\\left( 1 - A_+ \\right)\n\\end{align}\nand so the Hamiltonian is just a sum of commuting projectors\n\\begin{align}\n    H &=\n    \\frac{K}{2} \\sum_{\\square} P_{\\square}\n    +\n    \\frac{J}{2} \\sum_{+} P_{+}\n\\end{align}\nBefore in the AKLT it was as sum of projectors but he projectors weren't\ncommuting.\nThere's a whole world here.\n\nA nice way to think of the ground star of this model is basically as a loop gas,\na sum over all loop configurations.\n\nPick a basis for $\\sigma_z$.\nLet's say $\\sigma^z = +1$ is the absence of a string on an edge.\nAnd if it's $-$ it's  the presence of a string on an edge.\nThe product of $\\prod_{l\\in\\square}\\sigma_l^z=1$\nmeans that there should be an even number of links that have strings.\nThen what does $\\prod_+ \\sigma_l^x$ on a star do?\nIf I have no strings on a star,\nthen it's going to create strings on the star when you apply it.\n\nActually, I got it backwards.\n\nIf $\\sigma^z = +1$ for a link,\nit means that there is a string that crosses it.\nIf $\\prod_{l\\in\\square} \\sigma_l^z = 1$ then that means there is an even number\nof strings on a plaquette.\nThis means that the strings on the dual lattice do not end.\n\nYou can think of $\\prod_{l\\in +} \\sigma_l^$ as it as a plaquette on the dual\nlattice.\n\nIf we have an even number of strings around the plaquettes of the dual lattice,\nI better have a string somewhere else,\nbasically the strings cannot end and have to keep going.\n\nSo basically we have to have closed strings on a dual lattice,\nand this other term says that if I apply it I get another closed string.\nSo the $+1$ eigenstate of\n$\\sum_{\\square}B_{\\square}$\nis the uniform superposition state of only closed loops on the dual lattice.\n\nAnd the $+1$ eigenstate of the $A_+$ operator is a uniform superposition of all\nclosed loop configurations.\nIt's not every closed loop,\nbut only loops that can be made by deforming a single operator.\n\nAt least in the situation where $K$ and $J$ are positive,\nwe can think of the ground state as a uniform superposition of closed loops.\nFor $K,J>0$,\nthe ground state is a uniform superposition of closed loops.\n\nA basis of $\\sigma^z$ is loops on the dual lattice.\n$\\sigma^x$ is loops on the primal lattice,\nbut it's just a change in perspective depending on which basis you pick.\n\nThis means that on this torus there are 4 topologically degenerate states,\ngiven by whether you have an even or odd number of closed loops around each\ncycle.\n\nThis is an example of a non-invertible topological phase,\nbecause we have this topological degeneracy.\nYou can in fact not need to define it on a square lattice,\nbut could have used any graph with the same basic properties,\nplanar graph,\nthen you can also define it on any triangulation on a genius $g$ surface,\nand you would have $2^{2g}$ different sectors.\nSo you can define a similar model on any triangulation of genus $g$ surface with\n$2^{2g}$ topologically degenerate ground states.\n\n\\subsection{Excitations}\nThis model is basically $\\ZZ_2$ lattice gauge theory,\nand you should know what the excitations are.\n\nYou can think of creating excitations by applying local operators.\n\nSuppose you apply a $\\sigma^x$ operator to a single link.\nThat's going to flip the eigenvalues of the $B_{\\square}$ operator on nearby\nplaquettes.\nIf I apply an $\\sigma^x$ on a link,\nthat's going at flip the eigenvalues next to it.\nIf you apply a product of $\\sigma^x$ operators along some string $\\gamma$,\nthen this think creates $2$ plaquette excitations far away\n\\begin{align}\n    W_m(\\hat{\\gamma}) &= \\prod_{l\\in \\hat{\\gamma}} \\sigma_l^x\n\\end{align}\nAnd the energy cost is just $2K$ at one end and $2K$ at the other end,\nand we can separte them arbitrarily far apart.\nThese are deconfined excivations because they can be separated arbtrarily far\nwithout using energy besides the initial creation.\nThese are $m$ particles.\nWe say $\\hat{\\gamma}$ denotes a string on the dual lattice.\nThen\n\nSimilarly,\nwe can apply $\\sigma^z$ to a link and that does exactly the same thing,\nexcept on the dual lattice.\nCreating it on the original lattice creates a star excitation.\n\\begin{align}\n    W_e\\left( \\gamma \\right)\n    &=\n    \\prod_{l\\in \\gamma} \\sigma_l^z\n\\end{align}\nThese are $e$ excitations.\nNo local operator can create any individual one,\nand you cannot convert one to another by local operators either,\nso they are topologically distinct.\nThe way we think about it is this.\n\n\\subsection{Topological classes of excitations}\nWe have topologically classes of excitations.\n1, $e$, $m$, and the composite particle $\\epsilon = e\\times m$.\nThese are 4 topological distinct excivations.\nAnd we have fusion rules for these,\nwhch tell us how different topological excivations fuse together to give other\nclasses of topolgoical excitaitons.\n\\begin{align}\n    e\\times e &= 1\\\\\n    m\\times m &= 1\\\\\n    \\epsilon \\times \\epsilon &= 1\\\\\n\\end{align}\n\nThey have fractional statiics if yo utake these particls around each other and\nyou have intersting phases.\nImagine applying a string operator that creates a pair of $m$ particles\nusing $W_m\\left( \\hat{\\gamma} \\right)$,\nand then we take $W_e\\left( \\gamma \\right)$ around one of the $m$ particles.\n\nAnd then I consider the order they apply\n\\begin{align}\n    W_e\\left( \\gamma \\right) W_{m}^{\\hat{\\gamma}}\n    \\ket{\\mathrm{g.s.}}\n    &=\n    -W_m\\left( \\hat{\\gamma} \\right)\n    W_e\\left( \\gamma \\right)\n    \\ket{\\psi_{\\mathrm{g.s.}}}\n\\end{align}\nThis $-$ sign is the mutual statistics between $e$ and $m$.\n\nOne more thing to mention.\nIf $\\gamma$ is a closed loop,\nthen\n\\begin{align}\n    W_e\\left( \\gamma \\right)\n    \\ket{\\psi_{\\mathrm{g.s.}}}\n    &=\n    \\ket{\\psi_{\\mathrm{g.s.}}}\n\\end{align}\nand if $\\hat{\\gamma}$ is a closed loop then\n\\begin{align}\n    W_m\\left( \\hat{\\gamma} \\right)\n    \\ket{\\psi_{\\mathrm{g.s.}}}\n    &=\n    \\ket{\\psi_{\\mathrm{g.s.}}}\n\\end{align}\nSo we have these loop operators that keep the ground state invariant.\nSo actually the ground state has a symmetry,\nbut it's a strange kind that is generated by loop operators.\nThe reason we have this symmetry because we actuallyhad it microsocpially,\nand these operators commute with the Hamiltonian.\n\n$H$ also commutes with $W_e\\left( \\gamma \\right)$ and $W_{m}\\left( \\hat{\\gamma}\n\\right)$\nif $\\gamma$ and $\\hat{\\gamma}$ are closed.\n\nComapred to conventional symmetries,\nlike flipping spins,\nthis Hamiltonian has a spcial clsass of symmetreis,\ncalled $1$-symmetries,\nbecaue thyeare dimension-1 operators.\n\nEven if we broke the symmetry they the level few the Hamiltonian by adding some\nperturbation,\nfor example the $h \\sigma^x$ perturbation,\nthen we would break the $W_m$ symmetry.\nWe could also add terms to break the $W_e$ symmetry.\nThe Hamiltonian will still have these loop symmetries,\nbut these operators will be slightly different.\n\nSo the existence of these loop symmetries is a \\emph{stable} property.\nThese days we say that these have an emergent 1-form symmetry.\n\nThere exist loop operators associated with $e$ and $m$ particles even if those\nsymmetries don't exist in in the original Hamiltonian.\nAt least  the toric code Hamiltonian,\nthose statements are certainly true.\n\nComing back here,\nwe have these mutual statistics between $e$ and $m$.\nThe exact form of the operators may change,\nbut you can think of topologically orderd phases as being characterisd by\ntopological order,\nbut they can also be cahactersied by these emergent symmetries,\nwhich are just lop operators for hte non-trivial topological operators.\n\nFor example,\nhere we but the $m$ loop open to get an $m$ segement,\nand we go through it with a $W_e$ loop.\nSo you cna in general get signs and phases,\nand more complicated things can happen.\nIn general,\nthey not even be invertible,\nand that leads at the concept of non-invertible symmetries.\n\nThat you have a minus sign n the mutual statistics is just a property of the\ntoric code.\n\nYou can imagine a different gound satte with $e$ particles\nThe point is that as $r\\to\\infty$,\n$E(r)\\to\\mathrm{const}$..\nDon't tkae the gneral thing I said too literally.\n\nNow the $e$ and the $m$ partio\n$e,m$ are bososns.\n$\\epsilon$ is a fermion.\nYou could do an exchange to find out  the phase.\nOr you can find out if you did a $2\\pi$ rotation,\nlocally this guy goes around itself.\n\nThisis all I wantd to say about $\\ZZ_2$ lattice gauge theory.\n\n\\begin{question}\n    Is it a loop?\n\\end{question}\nYou can have a more non-trivial algebra so they don't multiple = t\n\nWe noted how these can come form lattice guage htoery,\nand pure lattice gauge theory without magnteic field,\nthat'sj s t Kitaev toric code.\nThere are 4 topological excitations,\ngenerated by the $\\ZZ_2$ charge $e$\nand the $\\ZZ_2$ flux $m$.\n\n\\ssection{Parton/Slave particle approach}\nWhat I want to do now is to discuss another approach for describing spin\nliquids.\nThe phrase slave-particle has been cancelled,\nso it's called Parton, projected construction.\nXG-Wen 2004 Chapter 9 has a good description of this.\n\nWhere gauge theory comes from in a spin model,\nyou stat with microscopic spins,\nembed the 2-state Hilbert space in a larger Hilbert space with a constraint.\nThe idea here is that we parametrize microscopic Hilbert space in a real way by\nexpanding the Hilbert space and adding a constraint.\n\nSo let me say what I mean by the way.\nAt the opeartor level,\ntake my spin operator and represent it in terms of other operaotrs,\nfor example.\n\n\\begin{align}\n    \\vec{S} &=\n    \\begin{cases}\n        \\frac{1}{2}f^\\dagger \\vec{\\sigma} f\\\\\n        \\frac{1}{2}z^\\dagger \\vec{\\sigma} z\n    \\end{cases}\n\\end{align}\n$f$ is a 2-component operator and it's a fermion.\n\\begin{align}\n    f &=\n    \\begin{pmatrix}\n        f_1\\\\\n        f_2\n    \\end{pmatrix}\n\\end{align}\nsometimes called a slave-fermion or\nSchwinger fermion.\nMeanwhile,\n\\begin{align}\n    z &=\n    \\begin{pmatrix}\n        z_1\\\\\n        z_2\n    \\end{pmatrix}\n\\end{align}\nis a complex calar that describes boson,\nsometimes called ``slave boson'' or Schwinger bosons.\n\nThis i the Fermionic parton.\nSo we can write\n\\begin{align}\n    S^\\dagger &=\n    S^x + iS^y\\\\\n    &=\n    \\begin{pmatrix}\n        f_1^\\dagger & f_2\n    \\end{pmatrix}\n    \\begin{pmatrix}\n        0 & 1\\\\\n        0 & 0\n    \\end{pmatrix}\n    \\begin{pmatrix}\n        f_1\\\\\n        f_2\n    \\end{pmatrix} \\\\\n    &=\n    f_1^\\dagger f_2\n\\end{align}\nand then\n\\begin{align}\n    S^z &=\n    \\frac{1}{2}\n    \\left( \n    f_1^\\dagger f_1\n    -\n    f_2^\\dagger f_2\n    \\right)\n    S^-\\\\\n    &=\n    f_2^\\dagger f_1\n\\end{align}\nIt is an exercise to check that\n\\begin{align}\n    \\left[ S^a, S^b \\right]\n    &=\n    2i \\epsilon^{abc} S^c\n\\end{align}\nThere are two states $\\ket{\\uparrow}$ and $\\ket{\\downarrow}$.\nBut in the fermionic picture,\nthere are 4 states\n$\\ket{00}, \\ket{01}, \\ket{10}, \\ket{11}$.\nSo then $\\ket{\\uparrow}=\\ket{10}$ and $\\ket{\\downarrow}=\\ket{01}$\nand we consider $\\ket{00}$ and $\\ket{11}$ to be unphysical state.\nTo remove these unphysical states,\nwe enforce the constraint that there is just one fermion on each site.\n\\begin{align}\n    n_1 + n_2 = 1\\\\\n    n_1 &= 1- n_2\n\\end{align}\n\nWe can think of the number of $f_1$s being equal to the number of holes of\n$f_2$.\n\nConstraints on a Hilbert space is the same as saying there's a gauge redundancy\ninvovled.\nWe can introduce a gauge transformation such that the physcial states are\ninvariatn undergauge transfomraiotn,\nbut the unphysical states are not.\nAnd the gauge transformation is just to project on to the gauge invariant\nstates.\n\n\\subsection{Gauge redundancy}\nConsider the $U(1)$ gauge redundancy.\n\\begin{align}\n    f_{\\alpha}\n    &\\to\n    e^{i\\theta} f_{\\alpha}\n\\end{align}\nwhich keeps $\\vec{S}$ invariant.\n\nI have introduced these Fock states for the fermions,\nand consider how they transform.\n\\begin{align}\n    \\ket{0}_{f_1} &\\to \\ket{0}_{f_1}\\\\\n    \\ket{1}_{f_1} =\n    f^\\dagger \\ket{0}_{f_1}\n    &\\to\n    e^{-i\\theta} f_1^\\dagger f_1^\\dagger \\ket{0}_{f_1}\n    =\n    e^{-i\\theta}\\ket{1}_{f_1}\n\\end{align}\nMenawhile\n\\begin{align}\n    \\ket{0}_{f_2} &\\to e^{i\\theta} \\ket{0}_{f_2}\\\\\n    \\ket{1}_{f_2} &\\to \\ket{1}_{f_2}\n\\end{align}\nSo that means $\\ket{01}$ and $\\ket{10}$ are gauge invaritn but $\\ket{00}$ and\n$\\ket{11}$ are not gauge invariant.\nThat meansa the physical space is equal to the gauge invariant subspace of the\nfermions.\n\nIt turns out the redundancy is not just $U(1)$,\nbut we actually ahve $SU(2)$ gauge redunancy.\nLet me just tell you what it is.\n\nIf we consider\n\\begin{align}\n    \\begin{pmatrix}\n        f_1\\\\\n        f_2^\\dagger\n    \\end{pmatrix}\n    &\\to\n    W\n    \\begin{pmatrix}\n        f_1\\\\\n        f_2^\\dagger\n    \\end{pmatrix}\n\\end{align}\nfor some $W\\in SU(2)$,\nthen the spin vector $\\vec{S}$ will be invariant.\nLet me rewrite this as\n\\begin{align}\n    S^+\n    &=\n    f_1^\\dagger f_2\\\\\n    &=\n    \\frac{1}{2} \\epsilon_{\\alpha\\beta} \\tilde{f}_{\\alpha} \\tilde{f}_{\\beta}\n\\end{align}\nnoting that\n\\begin{align}\n    \\tilde{f}_1 &= f_1^\\dagger\\\\\n    \\tilde{f}_2 &= f_2\n\\end{align}\nTHis is paritcle-hole tranfomaitno.\nBecause fermions anticommute,\nI just do this with the $\\epsilon$ tensor and put in $\\frac{1}{2}$.\nIf we do it in this langgue\n\nAnd then we can write this as\n\\begin{align}\n    \\begin{pmatrix}\n        \\tilde{f}_1^\\dagger\\\\\n        \\tilde{f}_2\n    \\end{pmatrix}\n    &\\to\n    W\n    \\begin{pmatrix}\n        \\tilde{f}_1^\\dagger\\\\\n        \\tilde{f}_2^\\dagger\n    \\end{pmatrix}\n\\end{align}\nwhich I can write as a shorthand\n\\begin{align}\n    \\tilde{f} \\to W \\tilde{f}\n\\end{align}\nAnd what that tells us is that\n\\begin{align}\n    S^\\dagger &\\to\n    \\frac{1}{2} \\epsilon_{\\alpha\\beta} W_{\\alpha\\alpha'}\n    W_{\\beta\\beta'} \\tilde{f}_{\\alpha'}\n    \\tilde{f}_{\\beta'}\n\\end{align}\nand for $W\\in SU(2)$,\nwe have\n\\begin{align}\n    \\epsilon_{\\alpha\\beta}\n    W_{\\alpha\\alpha'}\n    W_{\\beta\\beta'}\n    &=\n    \\epsilon_{\\alpha'\\beta'}\\\\\n    W_{1\\alpha'}\n    W_{2\\beta'}\n    -\n    W_{2\\alpha'}\n    W_{1\\beta'}\n\\end{align}\nFor $\\alpha',\\beta'=1$,\n\\begin{align}\n    W_{11}W_{21} - W_{21}W_{11} &=0\n\\end{align}\nand for\n$\\alpha'=1$ and $\\beta'=2$,\n\\begin{align}\n    W_{11} W_{22} - W_{21} W_{12} &= |W| = 1\n\\end{align}\nSo the spin operator is kept invariant by this $SU(2)$ transformation.\nThe point is that once you write it in this way with the expanded Hilbert space,\nthat gives you access to new kinds of approximations you didn't have access to\nbefore,\nin particular new types of mean field theory.\n\nThis parton decomposition gives access to new mean-field approximations.\nTo see this,\nconsider the usual mean field theory on the Heisenberg model\n\\begin{align}\n    H\n    &=\n    \\sum_{ij} J_{ij} \\vec{S}_{i} \\cdot \\vec{S}_{j}\n\\end{align}\nand you just replace the $S$ with its expectation value,\nso the mean-field Hamiltonian is\n\\begin{align}\n    H_{\\mathrm{m.f.}}\n    &=\n    \\sum_{ij}\n    J_{ij}\n    \\left( \n    \\langle\\vec{S}_i\\rangle\n    \\cdot\n    \\vec{S}_j\n    +\n    \\vec{S}_i\\cdot\n    \\langle \\vec{S}_j \\rangle\n    -\n    \\langle\\vec{S}_i\\rangle\n    \\cdot\n    \\langle\\vec{S}_j\\rangle\n    \\right)\n\\end{align}\nBut you want to enforce consistency with\n\\begin{align}\n    \\langle \\vec{S}_i \\rangle\n    &=\n    \\bra{\\Phi_{mf}}\n    \\vec{S}_i\n    \\ket{\\Phi_{mf}}\n\\end{align}\nThis is useful a lot of the time,\nbut this is useless for $\\langle S_i \\rangle=0$,\nbecause everything is just zero.\n\nSo this could only be useful for ordered states of spins.\nIf I want to describe states that have topological order,\nusual mean field theory is no good.\nBut if I rewrite in terms of partons,\nthat goes me a new way of doing mean-field theory,\nwhich gives me a window into describing a whole new class of phases of matter\nthat I couldn't have described just by talking about expectation values of $S$.\n\nLet me just write it down and analyse it next time.\nFor the parton mean field,\nI replace the $S$ with my fermion operators.\n\\begin{align}\n    H &=\n    \\sum_{ij}\n    J_{ij}\n    \\vec{S}_i\n    \\cdot\n    \\vec{S}_j\\\\\n    &=\n    \\sum_{ij}\n    \\sum_{a}\n    J_{ij}\n    f_{i\\alpha}^\\dagger\n    f_{i\\beta}\n    f_{i\\gamma}^\\dagger\n    f_{i\\delta}\n    \\sigma_{\\alpha\\beta}^{a}\n    \\sigma_{\\gamma\\delta}^{a}\n\\end{align}\nand the identity to use here from QFT class is\n\\begin{align}\n    \\sum_{a}\n    \\sigma_{\\alpha\\beta}\n    \\sigma_{\\delta\\gamma}\n    &=\n    2\\delta_{\\alpha\\beta'}\n    \\delta_{\\alpha'\\beta}\n    -\n    \\delta_{\\alpha\\beta}\n    \\delta_{\\alpha'\\beta'}\n\\end{align}\nand the Hamiltonian simplifies to\n\\begin{align}\n    H &=\n    \\sum_{ij}\n    \\left[ \n    -\\frac{1}{2}\n    J_{ij}\n    f_{i\\alpha}^\\dagger\n    f_{j\\alpha}\n    f_{j\\beta}^\\dagger\n    f_{i\\beta}\n    +\n    J_{ij}\n    \\left( \n    \\frac{1}{2} n_i\n    -\n    \\frac{1}{4} n_i n_j\n    \\right)\n    \\right]\n\\end{align}\nwith a constraint that\n\\begin{align}\n    n_i = 1\n\\end{align}\nSo far this is just an exact rewriting.\n\n\\begin{question}\n    ???\n\\end{question}\nIn gauge theory,\nyou could have defined our gague field in the spin sstem,\nand eery time the Guass law is violated\nI'm going to call that thing matter,\nand then you can exacly embed the gague field sapce with matter,\nand it becomes and exat mapping.\nBut if you want pure gauge theory,\nit always has to be a subset.\nHere there is a mtter field.\nThera is a conjecture.\nIf you want ot exactly map the gauge field to a spin mdoel,\nyou need to mave am tter field,\nthat's the completeness conjecture.\nBut you're right,\nit seems like I embeeed it in hte larger space,\nbut there's this other thing yo ucould do,\nand that is call every Gauss law violation ``matter''\nand that maps on to the Hilbert space.\n\n\\begin{question}\n    Do these necesasrily follow fermionic commutation relations?\n\\end{question}\nI don't know.\nIt's not entirely obvious how you would define that.\nYou're thiknig of oeprators htat create a aprticular fluctuation and what its\nproperties are.\nIt oden'st have to be bosonic or fermionic.\nI might be able to talk about that level fo genearlity.\nI would have some gauge field,\nand I would have some matter,\nso I can't decompose anything,\nI can only talk about the whole of what's happening.\nIn this particular relation,\nI can decompose what I call matter and what I call gauge field and it might be\ntricky to do that.\nSo I don't have a good answer.\n\nCertainly in the theories we write down,\nit's gauge fields the couple to matter that is fermionic or bosonic.\n\n\\begin{question}\n    If bosonic matter,\n    you could call any violation of the Gauss law constraint bosonic,\n    because yo can have as many bosons at a site as you want?\n\\end{question}\nI think there will be fermionic and bosonic violations.\n", "meta": {"hexsha": "02f5956c9bfbaa7ec56bb4e27810c9e4387be1c8", "size": 22335, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phys733/lecture28.tex", "max_stars_repo_name": "ehua7365/umdphysnotes", "max_stars_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-11T12:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-11T12:53:46.000Z", "max_issues_repo_path": "phys733/lecture28.tex", "max_issues_repo_name": "ehua7365/umdphysnotes", "max_issues_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phys733/lecture28.tex", "max_forks_repo_name": "ehua7365/umdphysnotes", "max_forks_repo_head_hexsha": "00e4e2b6aba3d03baaec5caa36903e5135b014de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2642276423, "max_line_length": 81, "alphanum_fraction": 0.7097380792, "num_tokens": 6576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228891883799, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4071407304278795}}
{"text": "% !TEX root = report.tex\n\\section{Model In Alloy Analyzer}\n\nAlloy Analyzer is a tool for modeling objects with specifications regarding their related structure, and formally verifying whether some properties hold for such objects based on some other pre-asserted properties. Alloy has its own specification language as well as integrated development environment (\\textsc{ide}), which includes a visualizer. The tool was developed by Daniel Jackson and his team at the Massachusetts Institute of Technology (\\textsc{mit}). See Alloy manual in his book \\cite{Jackson:2012:SAL:2141100} or on the Alloy website {\\small\\url{http://alloy.mit.edu/alloy/documentation.html}}.\n\nTo solve the \\textsc{drc} query safety check problem, we rephrase the queries in terms of Alloy verification tasks. In this section, we explain the essential components of the model to we need to construct in Alloy specification language.\n\n\n\\subsection{Model overview}\n\nThe main question of this project is that, given a database schema and a \\textsc{drc} query as input, we need to be able to translate the input into a verification task to be solved by Alloy Analyzer. Specifically, our Alloy model would consist of the following components.\n\n\\begin{itemize}[topsep=0.5pc,itemsep=0.25pc]\n    \\item  Since we need to show whether a \\textsc{drc} query is domain-dependent, we need to be able to model multiple \\textbf{domain sets} (see \\sectionref{sub:goal}), each with different \\textbf{scalar values} in the set.\n    \\item  The model needs to be able to model \\textbf{database instances} (i.e., collection of table instances) based from the given database schema, using \\textbf{scalar values} mentioned above.\n    \\item  The given \\textsc{drc} query should be translated to a \\textbf{query function} in Alloy language. The function should output a result given a \\textbf{domain set} and a \\textbf{database instance}.\n    \\item  As per the main goal in \\sectionref{sub:goal}, we need an \\textbf{Alloy predicate} which would solve for two distinct domains which yield two distinct query results based on a common database instance.\n    \\item \\emph{Optional.} For visualization, we need a \\textbf{placeholder for results} in the Alloy model, declared as a model signature.\n\\end{itemize}\nWe discuss the details for each of these components in depth in the subsequent subsections.\n\n\n\\subsection{Domain sets and values}\n\nAs previously mentioned, we need to be able to consider different domain sets in order to ultimately determine if a query is domain-dependent. In \\autoref{src:domain},\n\n\\begin{itemize}[topsep=0.5pc,itemsep=0.25pc]\n    \\item  \\textbf{\\alloy{Superparticle}}:\\; a set of all possible scalar values across all domains.\n    \\item  \\textbf{\\alloy{Universe}}:\\; a collection of exactly two domains (or alternatively, \\emph{universes}): \\alloy{UniverseAlpha} and \\alloy{UniverseBeta}. \\; Each domain (i.e., \\emph{universe}) has one attribute called \\alloy{Element}, representing the subset of \\alloy{Superparticle}s which belong to that domain. We can refer to the first domain set as \\alloy{UniverseAlpha.Element}, for example.\n    \\item  \\textbf{\\alloy{Particle}}:\\; is the domain set of \\emph{allowable} scalar values in the actual model of database instances, which is restricted to the intersection of each of the two domain sets.\n\\end{itemize}\n\n\\begin{lstlisting}[language=alloy,float=t,caption={Alloy model signature for domain sets (\\emph{universes}) and their elements (\\emph{particles}). This stencil code will always be present in all Alloy models. The fact assert on \\autoref{li:domain-cond} ensures that each \\alloy{Superparticle} must be present in at least one domain, for the sake of conciseness of models generated by Alloy.},label={src:domain}]\nsig Superparticle {} {\n\tSuperparticle = Universe.Element <|\\label{li:domain-cond}|>\n}\n\nabstract sig Universe { Element: some Superparticle }\none sig UniverseAlpha, UniverseBeta extends Universe {}\n\nsome sig Particle in Superparticle {} {\n\tParticle = UniverseAlpha.Element & UniverseBeta.Element\n}\n\\end{lstlisting}\n\n\n\\subsection{Database instances}\n\nBecause database instances will heavily depend on the schema, instead of creating a static Alloy model, we need a method to translate the given database schema into additional Alloy model signatures. We provide a framework procedure of how it could be done.\n\n\\smallskip\n\\begin{procedure}\n    \\label{proc:tables}\n    Let $R_1, R_2, \\ldots, R_k$ be database tables, each with $n_1, n_2, \\ldots, n_k$ columns, respectively. We create the following Alloy signature.\n\n    % Code placeholder variables\n    \\newrobustcmd\\fieldsigfortable[1]{%\n        \\textnormal{\\small\\color{CodeVariable}\n            <\\hrsp{\\itshape field signature #1}\\hrsp>}}\n\n\\begin{lstlisting}[language=alloy,numbers=none]\none sig Table {\n    R_1: <|\\fieldsigfortable{$R_1$}|>,\n    R_2: <|\\fieldsigfortable{$R_2$}|>,\n               <|$\\vdots$|>\n    R_<|$k$|>: <|\\fieldsigfortable{$R_k$}|>\n}\n\\end{lstlisting}\n\n    \\newpage\\phantomsection\n    \\label{psec:foot-dummy}\n    \\marginnote{\\llap{\\normalsize* }The reason why we need a dummy signature \\alloy{Table} is that it is impossible in Alloy to create a relation with each column consisting of object with only pre-defined signatures. Hence, this is a workaround.}\n    \\noindent\n    where\n    \\[\n        \\text{\\fieldsigfortable{$R_i$}} = \\begin{cases}\n            \\;\\text{\\small\\alloy{set Particle}}\n                & \\text{if $n_i = 1$} \\\\\n            \\;\\underbrace{\\text{\\small\\alloy{Particle -> Particle ->} $\\ldots$ \\alloy{-> Particle}}}_\\text{repeated $n_i$ times}\n                & \\text{if $n_i > 1$}\n        \\end{cases}\n    \\]\n    In other words, each field \\alloy{R_}$i$ is an Alloy relation with $n_i$ columns (ignoring the first dummy column of the \\alloy{Table} signature\\hrsp{\\hyperref[psec:foot-dummy]{\\color{OrangeRed4}*}}), and \\alloy{Table.R_}$i$ is the syntax which represents table $R_i$ itself.\n\n    Note that the unary signature (i.e., table with single column) requires the keyword \\alloy{set} in order to override the default behavior which is that \\alloy{Table.R_}$i$ would have contained a single row of data instead of any number of rows.\n\\end{procedure}\n\n\\marginhead{Example of translation of database schema}\nTo illustrate how the above procedure works, we consider the following example.\n\n\\smallskip\n\\begin{example}\n    Suppose that a database schema consists of three tables named \\rel{A}, \\rel{B}, and \\rel{C}. Table \\rel{A} has a single column of integers; Table \\rel{B} contains two columns of integers followed by a column of string values; and Table \\rel{C} contains two columns of string values.\n\n    Using \\autoref{proc:tables}, all of the tables above are translated into Alloy signature as follows.\n\\begin{lstlisting}[language=alloy,numbers=none]\none sig Table {\n    A: set Particle\n    B: Particle -> Particle -> Particle\n    C: Particle -> Particle\n}\n\\end{lstlisting}\n\\end{example}\n\n\\begin{note}\n    You may have probably noticed from the example above that we make \\emph{no distinction} between different types of data, whether it be an integer or a string (or any other types). Since data types do not make any differences in this project, they can be safely disregarded.\n\\end{note}\n\n\n\\subsection{Query function}\n\nSuppose that a (simplified) \\textsc{drc} query has the form\n\\begin{equation}\n    Q = \\{x_1,x_2,\\ldots,x_m \\mid P(x_1,x_2,\\ldots,x_m)\\} \\label{eq:query}\n\\end{equation}\nwhere each $x_i$ represents a variable for scalar value and $P$ is a boolean expression, which could be\n\n\\begin{itemize}[topsep=0.5pc,itemsep=0.25pc]\n    \\item  a boolean predicate in terms of table name (see \\hyperref[psec:table-name-pred]{page~\\pageref*{psec:table-name-pred} under \\emph{table names as predicates}});\n    \\item  an equality predicate ($=$) between two values;\n    \\item  a conjunction ($\\wedge$), a disjunction ($\\vee$), a negation ($\\neg$\\hrsp), a conditional ($\\Rightarrow$), or a bi-conditional ($\\Leftrightarrow$) of other boolean expressions; or\n    \\item  a first-order, universal ($\\forall$) or existential ($\\exists$) quantification of other boolean expressions where a new variable also represents a scalar value.\n\\end{itemize}\n\nIn addition, each variable in the boolean expression $P$ must be \\emph{binded}. That is, either the variable must be one of $x_1,x_2,\\ldots,x_m$; or it must be introduced via first-order quantification in which the variable is used.\n\n\\smallskip\nThe procedure to transform a query in \\textsc{drc} into an Alloy function is described as follows.\n\n\\smallskip\n\\begin{procedure}\n    \\label{proc:query-function}\n    Given a specific \\alloy{Universe} (i.e., domain set) called $u$ as an input, we rewrite the query $Q$ as defined in \\eqref{eq:query} as a new Alloy function (using a comprehension syntax) as shown.\n\n    % Code placeholder variables\n    \\newrobustcmd\\setcomppred{%\n        \\textnormal{\\small\\color{CodeVariable}\n            <\\hrsp{\\itshape predicate expression}\\hrsp>}}\n    \\newrobustcmd\\resultsig{%\n        \\textnormal{\\small\\color{CodeVariable}\n            <\\hrsp{\\itshape output signature}\\hrsp>}}\n    % Make an escape within string\n    \\newrobustcmd\\escinstr[1]{{\\color{Purple4!80!black}\\$\\{#1\\}}}\n\n\\begin{lstlisting}[language=alloy,numbers=none]\nfun query[u: Universe]: <|\\resultsig|> {\n    { x_1,x_2,<|$\\ldots$|>,x_<|$m$|>: u.Element | <|\\setcomppred|> }\n}\n\\end{lstlisting}\n    The \\setcomppred{} above corresponds to the almost one-to-one translation of the boolean expression $P$ (from the query $Q$ as shown in \\eqref{eq:query}) into an Alloy predicate syntax string. The recursive translational algorithm is outlined below.\n\n\\SuppressNumber\n\\begin{lstlisting}[language=pseudocode,escapeinside={<|}{|>},emph={TranslateBooleanExp},emphstyle={\\bfseries\\color{Identifier}}]\nTranslateBooleanExp($P$):  <|\\ReactivateNumber|>\nif $P$ is a table-name predicate $T(x_1, x_2, \\ldots, x_m)$:\n    return \"<|\\escinstr{$x_1$}|> $\\color{String}\\rightarrow$ <|\\escinstr{$x_2$}|> $\\color{String}\\rightarrow$ $\\ldots$ $\\color{String}\\rightarrow$ <|\\escinstr{$x_m$}|> in Table.<|\\escinstr{$T$}|>\"\nelse if $P$ is the equality predicate $x_1 = x_2$:\n    return \"(<|\\escinstr{$x_1$}|> = <|\\escinstr{$x_2$}|>)\"\nelse if $P$ has the form $\\neg Q$:\n    return \"(not <|\\escinstr{TranslateBooleanExp($Q$)}|>)\"\nelse if $P$ has the form $Q \\vee R$:\n    return \"(<|\\escinstr{TranslateBooleanExp($Q$)}|> or <|\\escinstr{TranslateBooleanExp($R$)}|>)\"\nelse if $P$ has the form $Q \\wedge R$:\n    return \"(<|\\escinstr{TranslateBooleanExp($Q$)}|> and <|\\escinstr{TranslateBooleanExp($R$)}|>)\"\nelse if $P$ has the form $Q \\Rightarrow R$:\n    return \"(<|\\escinstr{TranslateBooleanExp($Q$)}|> implies <|\\escinstr{TranslateBooleanExp($R$)}|>)\"\nelse if $P$ has the form $Q \\Leftrightarrow R$:\n    return \"(<|\\escinstr{TranslateBooleanExp($Q$)}|> iff <|\\escinstr{TranslateBooleanExp($R$)}|>)\"\nelse if $P$ has the form $\\exists\\,y[Q]$:\n    return \"(some <|\\escinstr{$y$}|>: u.Element | <|\\escinstr{TranslateBooleanExp($Q$)}|>)\"\nelse if $P$ has the form $\\forall y[Q]$:\n    return \"(all <|\\escinstr{$y$}|>: u.Element | <|\\escinstr{TranslateBooleanExp($Q$)}|>)\"\n\\end{lstlisting}\n\n    \\newpage\\noindent\n    In other words, the translation propagates down through each boolean subexpressions, except for the case of table-name predicates in which we use ``arrow products'' (\\alloy{->}) and ``subset comparison operator'' (\\alloy{in}) to check if a tuple belongs to the given table. Hence, this procedure is straightforward.\n\n    For the \\resultsig{}, we use the syntax similar to that in \\autoref{proc:tables}.\n    \\[\n        \\text{\\resultsig} = \\begin{cases}\n            \\;\\text{\\small\\alloy{set Superparticle}}\n                & \\text{if $m = 1$} \\\\\n            \\;\\underbrace{\\text{\\small\\alloy{Superparticle -> Superparticle ->} $\\ldots$ \\alloy{-> Superparticle}}}_\\text{repeated $m$ times}\n                & \\text{if $m > 1$}\n        \\end{cases}\n    \\]\n\n\n\\end{procedure}\n\n\\newpage\n\\marginhead{Example of translation of query functions}\nThe following example demonstrates how we can translate one instance of \\textsc{drc} query into an Alloy function.\n\n\\smallskip\n\\begin{example}\n    Suppose that there exists a table $\\rel{T}(\\field{a, b})$ and we have a \\textsc{drc} query $Q$ such that\n    \\[\n        Q = \\{ x, y \\mid (x = y) \\vee \\rel{T}(x, y) \\vee \\exists z [\\rel{T}(x, z) \\wedge \\rel{T}(z, y)] \\}\n    \\]\n    Using \\autoref{proc:query-function}, query $Q$ can be rewritten as an Alloy function as follows.\n\n\\begin{lstlisting}[language=alloy]\nfun query[u: Universe]: Superparticle -> Superparticle {\n    { x, y: u.Element |\n        ((x = y) or (x -> y in Table.T) or\n         (some z: u.Element | (x -> z in Table.T) and\n                              (z -> y in Table.T))) }\n}\n\\end{lstlisting}\n\\end{example}\n\nWe have discussed earlier at the end of \\sectionref{psec:explicit-domain} about how the domain of a \\textsc{drc} query is \\emph{not} explicit. In an attempt to make the domain more explicit, we provide the following definition and notation.\n\n\\smallskip\n\\begin{definition}\n    \\label{def:query-interp}\n    Let $Q$ be a \\textsc{drc} query as mentioned in \\eqref{eq:query}. If the domain set is $D$, then $Q[D]$ denotes\n    \\[\n        Q[D] = \\{(x_1,x_2,\\ldots,x_m) \\in D^m \\mid P(x_1,x_2,\\ldots,x_m)\\}\n    \\]\n    That is, each row of $Q[D]$ will be a tuple of $m$ scalar values from the domain $D$.\n\n    We also sometimes interpret $Q[D]$ as the \\textbf{result} of the query $Q$ where $D$ is the domain. This interpretation directly corresponds to how the \\alloy{query} function works as defined by \\autoref{proc:query-function}\n\\end{definition}\n\n\n\\subsection{Query safety verification}\n\nLet us revisit the definition of the ``\\textit{safety} of \\textsc{drc} query'' as described in \\sectionref{sub:goal}. We rephrase the definition slightly so that it exactly fits the Alloy verification framework.\n\n\\begin{definition}\n    Suppose there exists a database schema $S$ and a \\textsc{drc} query syntax $Q$ (as defined in \\eqref{eq:query}). The query $Q$ is \\textbf{safe} \\emph{if and only if}\n    \\begin{itemize}[topsep=0.5pc,itemsep=0.25pc]\n        \\item  \\textit{for all} two domain sets $D_1$ and $D_2$, and\n        \\item  \\textit{for every} database instances $I$ based on the schema $S$, which are also valid under both domains $D_1$ and $D_2$ (i.e., all scalar values in $I$ must belong to both sets $D_1$ and $D_2$)\n    \\end{itemize}\n    we have $Q[D_1] = Q[D_2]$ \\;(i.e., the result of query $Q$ under $D_1$ and $D_2$ are the same).\n\\end{definition}\n\n\\smallskip\nThe definiton of query safety can be translated into an Alloy assertion statement as shown on the first three lines in \\autoref{src:safety}. The \\hyperref[li:check-assert]{last line} invokes the Alloy Analyzer to verify such assertion statement. The hightlighted number \\alloy{4} indicates the upper limit of the number of objects of each model to be constructed by Alloy Analyzer. This number could be changed to a larger or smaller amount. The larger the amount, the more likely that Alloy Analyzer finds the answer, but in exchange for more computation resources.\n\n\\begin{lstlisting}[language=alloy,float={t},caption={Alloy assertion statement indicating that the \\alloy{query} is true.},label={src:safety}]\nassert queryIsSafe {\n    all u, u': Universe | query[u] = query[u']\n}\ncheck queryIsSafe for <|\\hll{check-assert-num}|>4<|\\hlr{check-assert-num}\\label{li:check-assert}|>\n\\end{lstlisting}\n\n\\begin{note}\n    \\marginhead{Caveat of Alloy Analyzer}\n    It is vital to point out that Alloy Analyzer will only attempt to find a counterexample of a given assertion statement. If Alloy Analyzer fails to find such counterexample, it does \\emph{not} imply that the assertion is true. That is, the Alloy Analyzer is \\textbf{not complete}.\n\\end{note}\n\n\\smallskip\nSo far we have discussed all essential ingredients of our Alloy model to analyze the safety of a \\textsc{drc} query input. However, when the query safety assertion statement has a counterexample, and we would like to see the explicit visualization of the query result of the counterexample, we will need to provide the Alloy model signature for the result objects too.\n\n\n\\subsection{Results placeholder}\n\nAs we have previously discussed in \\autoref{def:query-interp} that the query result is the interpretation of a query for a given domain set. Considering from the mathematical point of view, it is easy to see that the query result actually has the same anatomy as database tables. That is, a \\textbf{query result} is a mathematical relation with a positive number of columns of scalar values. Therefore, we can use the syntax similarly to the declaration signature of table objects.\n\nHowever, there is one major difference: for each query, we need two query results, one for domain \\alloy{UniverseAlpha} and another for \\alloy{UniverseBeta}. In Alloy, we use the following procedure to translate the \\textsc{drc} query to the Alloy object signature as shown below.\n\n\\smallskip\n\\begin{procedure}\n    Let $Q$ be a given \\textsc{drc} query as defined in \\eqref{eq:query}. That is, each row of the result has $m$ columns. We create Alloy objects with the following signatures.\n\n    \\newrobustcmd\\fieldsigforresult{%\n        \\textnormal{\\small\\color{CodeVariable}\n            <\\hrsp{\\itshape field signature}\\hrsp>}}\n\n\\begin{lstlisting}[language=alloy,numbers=none]\nabstract sig Result {\n    Output: <|\\fieldsigforresult|>\n}\none sig ResultAlpha, ResultBeta extends Result {} {\n    ResultAlpha.@Output = query[UniverseAlpha]\n    ResultBeta.@Output = query[UniverseBeta]\n}\n\\end{lstlisting}\n    where\n    \\[\n        \\text{\\fieldsigforresult} = \\begin{cases}\n            \\;\\text{\\small\\alloy{set Superparticle}}\n                & \\text{if $m = 1$} \\\\\n            \\;\\underbrace{\\text{\\small\\alloy{Superparticle -> Superparticle ->} $\\ldots$ \\alloy{-> Superparticle}}}_\\text{repeated $m$ times}\n                & \\text{if $m > 1$}\n        \\end{cases}\n    \\]\n\n    Notice that there are two separate results of the query (called the \\alloy{Output}) from applying \\alloy{query} function to each domain.\n\\end{procedure}\n", "meta": {"hexsha": "8beb3f5e4308e9941464f3057e540f7c5f960294", "size": 18102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "master-project/report/ch02_design.tex", "max_stars_repo_name": "abhabongse/relationalcalculus-alloy", "max_stars_repo_head_hexsha": "1be5a4d76e8c7c6f61ac18a5c987cc2fe1d7216d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-03-08T16:30:55.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-08T16:30:55.000Z", "max_issues_repo_path": "master-project/report/ch02_design.tex", "max_issues_repo_name": "abhabongse/relationalcalculus-alloy", "max_issues_repo_head_hexsha": "1be5a4d76e8c7c6f61ac18a5c987cc2fe1d7216d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-03-11T18:47:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-23T20:37:09.000Z", "max_forks_repo_path": "master-project/report/ch02_design.tex", "max_forks_repo_name": "abhabongse/relationalcalculus-alloy", "max_forks_repo_head_hexsha": "1be5a4d76e8c7c6f61ac18a5c987cc2fe1d7216d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.3627118644, "max_line_length": 607, "alphanum_fraction": 0.7182079328, "num_tokens": 4979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160666, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.40714072222360054}}
{"text": "\\section{Retaining Topology}\n\\label{sct_topology}\n\nThere are cases when one is more interested in the tree's structure than in the\nbranch lengths, maybe because lengths are irrelevant or just because they are\nso short that they obscure the branching order. Consider the following tree,\n\\texttt{vrt1.nw}:\n\\begin{samepage}\n\\verbatiminput{topol_1_txt.out}\n\\end{samepage}\nIts structure is not evident, particularly in the upper half. This is because\nmany branches are short in relation to the depth of the tree, so they are not\nwell resolved. A better-resolved tree can be obtained by discarding branch\nlengths altogether:\n\\verbatiminput{topol_2_txt.cmd}\n\\begin{samepage}\n\\verbatiminput{topol_2_txt.out}\n\\end{samepage}\nThis effectively produces a \\emph{cladogram}, that is, a tree that represents\nancestry relationships but not amounts of evolutionary change. The inner nodes\nare evenly spaced over the depth of the tree, and the leaves are aligned, so\nthe branching order is more apparent.\n\nOf course, \\ascii{} trees have low resolution in the first place, so I'll show\nboth trees look in \\svg. First the original: \n\\verbatiminput{topol_3_svg.cmd}\n\\includegraphics{topol_3_svg.pdf} \\\\\n\n\\noindent{}And now as a cladogram:\n\\verbatiminput{topol_4_svg.cmd}\n\\includegraphics{topol_4_svg.pdf} \\\\\nAs you can see, even with \\svg{}'s much better resolution, it can be useful to\ndisplay the tree as a cladogram.\n\n\\topology{} has the following options: \\texttt{-b} keeps the branch lengths (obviously, using this option alone has no effect); \\texttt{-I} discards inner node labels, and \\texttt{-L} discards leaf labels. An extreme example is the following, which discards everything \\emph{but} topology:\n\\verbatiminput{topol_5_txt.cmd}\nThis produces the following tree, which is still valid Newick:\n\\verbatiminput{topol_5_txt.out}\nLet's look at it as a radial tree, for a change:\n\\verbatiminput{topol_6_svg.cmd}\n\\begin{center}\n\\includegraphics{topol_6_svg.pdf}\n\\end{center}\n\n", "meta": {"hexsha": "f4f708f2f5495341e7d510bfd201a000419db96d", "size": 1961, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/topology.tex", "max_stars_repo_name": "Cactusolo/newick_utils", "max_stars_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 62, "max_stars_repo_stars_event_min_datetime": "2015-01-08T22:22:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T09:12:51.000Z", "max_issues_repo_path": "doc/topology.tex", "max_issues_repo_name": "Cactusolo/newick_utils", "max_issues_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2015-01-22T19:34:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-27T10:53:41.000Z", "max_forks_repo_path": "doc/topology.tex", "max_forks_repo_name": "Cactusolo/newick_utils", "max_forks_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 26, "max_forks_repo_forks_event_min_datetime": "2015-05-07T09:23:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T02:43:50.000Z", "avg_line_length": 43.5777777778, "max_line_length": 289, "alphanum_fraction": 0.7914329424, "num_tokens": 515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4071407222236004}}
{"text": "It has been seen in the previous section that the complete solution of a Riemann problem in solid dynamics is possible for simple problems.\nHowever, such a solution may become complicated for multi-dimensional problems or for other non-linear problems. \nNumerical methods such as upwind or Godunov-based methods \\cite{Leveque} require the solution of many Riemann problems within a discretized medium.\nWhen dealing with non-linear problems, the exact solution of those problems may increase drastically the computational cost, making the numerical scheme unappealing.\nMoreover, numerical procedures often require only little information about the solution of Riemann problems and do not need the complete solution. In that context, alternative procedures have been developed in order to take into account the characteristic structure of a hyperbolic system by computing an approximate solution of Riemann problems.\nApproximate Riemann solvers developed for Computational Fluid Dynamics allow to extract information for either flux functions (\\textit{HLL, HLLC, Roe} and \\textit{Osher} approximate Riemann solvers \\cite{Trangenstein}, \\cite{Toro}) or for vectors of conserved quantities (\\textit{approximate--state Riemann solver} \\cite[Ch.9]{Toro}, \\cite[Ch.22]{Leveque}).\nSome of these have been applied to specific problems in solid mechanics problems such as the Osher approximate solver (see \\cite{Lee_FVM} and \\cite{Haider_FVM}) or the HLLC approximate solver (see \\cite{Ortega_HLLD}) for hyperelasticity .\nWe recall here the formulation of the approximate-state Riemann solver for solid mechanics.\nThe approach is then applied to the non-linear problem of section \\ref{sec:SVK_solution}.\n\n\\subsection{General ideas}\nAs in the previous section, we consider the Riemann problem in the space direction $\\vect{N}$:\n\\begin{equation}\n  \\label{eq:RP_approx}\n  \\begin{aligned}\n  &\\Qcb_t + \\Jbsf\\(\\Qcb\\) \\drond{\\Qcb}{X_N} = \\vect{0}, \\\\\n  &\\left\\lbrace \n    \\begin{aligned}\n      & \\Qcb(X_N,t=0) = \\Qcb^L \\quad \\text{if } X_N< 0\\\\\n      & \\Qcb(X_N,t=0) = \\Qcb^R \\quad \\text{if } X_N> 0\n    \\end{aligned}\n    \\right.\n  \\end{aligned}\n\\end{equation}\nThe approach for developing an approximate-state Riemann solver consists in linearizing the problem \\eqref{eq:RP_approx} by approximating $\\Jbsf$ in the vicinity of $\\Qcb^L$ and $\\Qcb^R$ by a constant matrix $\\bar{\\Jbsf}=\\Jbsf\\(\\Qcb^L,\\Qcb^R\\)$ \\cite[Ch.15]{Leveque}. Note that this approximation is valid for small jumps in initial data (\\textit{i.e }$\\Qcb^L\\approx\\Qcb^R$) and that $\\bar{\\Jbsf}$ must ensure hyperbolicity of the system, namely $\\bar{\\Jbsf}$ has real eigenvalues and a complete set of independent eigenvectors. The approximate matrix also satisfies the consistency condition:\n\\begin{equation}\n  \\label{eq:approx_constistency}\n  \\bar{\\Jbsf}\\(\\Qcb,\\Qcb\\)=\\Jbsf\\(\\Qcb\\)\n\\end{equation}\n\nSuch a matrix can be defined by using the definition of right eigenvectors and characteristic speeds $\\Jbsf \\Rbsf = \\Rbsf \\Cbsf \\Rightarrow \\Jbsf = \\Rbsf \\Cbsf \\Rbsf^{-1}$ in which left-going (\\textit{resp. right-going}) characteristics and associated eigenvectors are assumed to depend on $\\Qcb^L$ (\\textit{resp. on} $\\Qcb^R$) only. Namely, one writes:\n\\begin{align*}\n  &\\Rbsf = \\matrice{\\Rcb^1(\\Qcb^L),\\cdots,\\Rcb^I(\\Qcb^L),\\Rcb^{I+1}(\\Qcb^R),\\cdots,\\Rcb^m(\\Qcb^R)} \\\\\n  &\\Cbsf=\\matrice{c_1(\\Qcb^L) & & & & & \\\\ & \\cdots & & && \\\\ & &c_I(\\Qcb^L) & & &\\\\ & & &c_{I+1}(\\Qcb^R)& & \\\\ & & & &\\cdots &\\\\ &&&&&c_m(\\Qcb^R)} \n\\end{align*}\nwhere $c_I(\\Qcb)$ and $m$ are the highest negative eigenvalue and the dimension of the Jacobian matrix. \n\nAt last, the linearized Riemann problem thus written enables the determination of every state vector $\\Qcb(x,t)$ by following the procedure described in section \\ref{subsec:charac_Linear_problems} for linear problems, recalled here for convenience for a system of dimension $m$:\n\\begin{equation}\n  \\label{eq:approx_RS}\n  \\begin{aligned}\n    &  \\Qcb^R-\\Qcb^L=\\sum_{i=1}^{m} \\Rcb^i\\delta^i \\\\\n    &  \\Qcb(x,t) =\\Qcb^R -\\sum_{i=I+1}^{m} \\Rcb^i\\delta^i \\\\\n    &  \\Qcb(x,t) =\\Qcb^L+ \\sum_{i=1}^{I} \\Rcb^i\\delta^i\n  \\end{aligned}\n\\end{equation}\nwhere the point ($x,t$) lies in the region bounded by the characteristics $I$ and $I+1$.\n\n\\begin{remark}\n  Note that since one can define a complete set of independent eigenvectors of the Jacobian matrix, the matrix $\\Rbsf$ is non-singular so that $\\bar{\\Jbsf}$ can be uniquely determined.\n  % Moreover, the linearization proposed amounts to considering a heterogeneous medium where $\\Qcb^{L}$ and $\\Qcb^R$ act as material parameters.\n\\end{remark}\n\n\\subsection{Application: Hyperelastic plane wave}\nWe finish this section with an illustration of the approximate Riemann solver by considering the plane wave problem in the Saint-Venant-Kirchhoff medium treated in section \\ref{sec:SVK_solution}.\nRecall that the eigenvalues and right eigenvectors matrices read for that problem:\n\\begin{equation}\n  \\label{eq:SVK_matrices}\n  \\Cbsf = \\matrice{-c & 0 \\\\ 0 & c} \\quad ; \\quad \\Rbsf = \\matrice{c & -c\\\\ 1&1} \\:,\\quad c=\\sqrt{\\frac{\\lambda + 2\\mu}{2\\rho_0}(3F^2-1)}\n\\end{equation}\nHence, the linearized problem is written with:\n\\begin{equation}\n  \\label{eq:SVK_matrices_linear}\n  \\Cbsf = \\matrice{-c_L & 0 \\\\ 0 & c_R} \\quad ; \\quad \\Rbsf = \\matrice{c_L & -c_R\\\\ 1&1}\n\\end{equation}\nIn section \\ref{subsec:charac_Linear_problems}, the expression of the wave strengths vector $\\vect{\\delta}$ has been established for general linear systems of dimension $2$ (see equation \\eqref{eq:wave_strengths}):\n\\begin{equation}\n  \\vect{\\delta}=\\frac{1}{c_R+c_L}\\matrice{c_R \\Delta F +\\Delta v\\\\ c_L \\Delta F -\\Delta v}\n\\end{equation}\nleading to the solution $\\Qcb $ between the two discontinuous waves:\n\\begin{equation}\n  \\label{eq:SVK_approx_solution}\n  \\Qcb  = \\Qcb^L + \\delta^1 \\Rcb^1 = \\matrice{v_L \\\\F_L} +\\delta^1 \\matrice{c_L \\\\1} \\quad \\text{or} \\quad \\Qcb  = \\Qcb^R - \\delta^2 \\Rcb^2 = \\matrice{v_R \\\\F_R} -\\delta^2 \\matrice{-c_R \\\\1}\n\\end{equation}\nSubstitution of $\\delta^{1,2}$ from the second equations into the first provides straight line equations in the phase plane ($F,v$):\n\\begin{equation}\n  \\label{eq:approx_straight}\n  v  = v_L + c_L(F -F_L) \\quad ; \\quad v  = v_R + c_R(F_R-F )\n\\end{equation}\n\\begin{figure}[h!]\n  \\centering\n  {\\input{chapter2/pgfFigures/1S2R_solution_approx} \\phantomsubcaption \\label{subfig:SVK_Approx1}}\n  {\\input{chapter2/pgfFigures/1S2R_solution_weak3} \\phantomsubcaption \\label{subfig:SVK_Approx4}}\n  \\caption{Comparison of approximate (dashed lines) and exact (solid lines) solution for a one-dimensional strain problem in a Saint-Venant-Kirchhoff hyperelastic material}\n  \\label{fig:comparison_exact_approx}\n\\end{figure}\nThe intersection of those straight lines in the phase plane corresponds to the approximate solution. Figure \\ref{fig:comparison_exact_approx} shows comparisons of approximate and exact solutions for various initial data, all leading to a $1$-shock--$2$-rarefaction exact solution. As expected, approximate and exact solutions are different and get closer for small initial discontinuities, satisfying the linearization assumption $\\Qcb^L\\approx \\Qcb^R$. As a consequence, a big initial discontinuity is considered in figure \\ref{fig:comparison_exact_approx}\\subref{subfig:SVK_Approx1} so that the approximation error is larger than that of figure \\ref{fig:comparison_exact_approx}\\subref{subfig:SVK_Approx4} for which initial data are based on a weak jump.\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% ispell-local-dictionary: \"american\"\n%%% TeX-master: \"../mainManuscript\"\n%%% End:\n", "meta": {"hexsha": "8cd26fc8268732ede4ac93c34f473fe723be84e2", "size": 7551, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "manuscript/chapter2/riemann_solvers.tex", "max_stars_repo_name": "adRenaud/research", "max_stars_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-18T14:52:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-18T14:52:03.000Z", "max_issues_repo_path": "manuscript/chapter2/riemann_solvers.tex", "max_issues_repo_name": "adRenaud/research", "max_issues_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-07T13:11:11.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-07T13:11:11.000Z", "max_forks_repo_path": "manuscript/chapter2/riemann_solvers.tex", "max_forks_repo_name": "adRenaud/research", "max_forks_repo_head_hexsha": "2f0062a1800d7a17577bbfc2393b084253d567f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.4842105263, "max_line_length": 756, "alphanum_fraction": 0.7396371342, "num_tokens": 2301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4071407222236004}}
{"text": "% LaTeX2e Template by Stephen Iota (https://stepheniota.github.io/)\n% last updated: Aug. 2018\n\n% for papers\n%\\documentclass[aps,onecolumn,superscriptaddress]{revtex4-1}\n\n% https://www-d0.fnal.gov/Run2Physics/WWW/templates/revtex4.pdf\n% https://cdn.journals.aps.org/files/revtex/auguide4-1.pdf\n% for revTeX4-1 class options\n\n% for other\n\\documentclass[12pt]{article}\n\\usepackage[margin=2cm]{geometry}\n\n%%%%%%%%%%%%%%%%\n%%% Packages %%%\n%%%%%%%%%%%%%%%%\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts} % to remove math font when typesetting equations\n\\usepackage{graphicx}\n\\usepackage{enumitem} % to change labels in enum/item\n\\usepackage[dvipsnames]{xcolor} % for colored links\n\n\n% always put this at the end\n\\usepackage[\n\tcolorlinks=true,\n\tcitecolor=green!50!black,\n\tlinkcolor=NavyBlue!75!black,\n\turlcolor=green!50!black,\n\thypertexnames=false]{hyperref} \n\n \n %%%%%%%%%%%%%%%%%%\n %% New Commands %%\n %%%%%%%%%%%%%%%%%%\n \n\\newcommand{\\email}[1]{\\texttt{\\href{mailto:#1}{#1}}}\n\n\\newcommand{\\hint}[1]{\\color{Blue}{#1}}\n \n%----------------------------------------------------\n%%%%%%%%%%%%%%%%%%\n%% Front Matter %%\n%%%%%%%%%%%%%%%%%%\n\n%\\pagenumbering{gobble} % no page numbers\n\\graphicspath{{figures/}} % set directory for figures\n\n%%%%%%%%%%%%%\n%%% Title %%%\n%%%%%%%%%%%%%\n\\begin{document}\n\n\\begin{center}\n\n\\Large{\\textsc{Worksheet 2a}: \\textbf{Understanding Charge Distributions}}\n\n\\end{center}\n\n\\vspace{.5mm}\n\n%%%%%%%%%%\n%% INFO %%\n%%%%%%%%%%\n\n\\begin{tabular}{rl}\n\\textsc{SI Leader}:\n&\nStephen Iota (\\email{siota001@ucr.edu})\n\\\\\n\\textsc{Course}:\n&\nPhysics 40C (Fall 2018); Dr.~Laura Sales\n\\\\\n\\textsc{Date}:\n&\nOctober 9, 2018\n\\end{tabular}\n\n%%%%%%%%%%%%%%\n%% PROBLEMS %%\n%%%%%%%%%%%%%%\n\n\\subsubsection*{README}\n\n``\\textit{How do I even start this problem?!}''\\\\\n1) Take a deep breath\n2) carefully read the question\n3) draw and label figure and axes\n4) identify unknown and knowns\n5) write down relevant concepts and equations and \n6) crunch the numbers!\n\n\n\\section{Conceptual Questions}\n\n\\begin{enumerate}[label=(\\alph*)]\n\\item Give examples of symmetric shapes and non-symmetric shapes.\n\\item When is the dipole approximation valid?\n\\item Describe the dynamics of a dipole placed in a \\textbf{uniform} electric field.\n\\begin{itemize}\n\t\\item Does it experience a force?\n\t\\item Does it move? If so, how?\n\\end{itemize}\n\\item At the dot, in what direction does the electric field point?\n \n\\includegraphics[width=.2\\linewidth]{W2a_Fig1.png}\n\\item What are ways to increase the magnitude of the electric field at the dot?\n\n\\includegraphics[width=.2\\linewidth]{W2a_Fig2}\n\\item Draw the electric field lines for the positively charged rod above.\n\\item How much faster does the $\\vec{E}$ field of a point charge decay compared to the $\\vec{E}$ field of a charged-thin wire?\n\\end{enumerate}\n\n\\section{The Electric Field of a Continuous Distribution}\n\n\\begin{enumerate}[label=(\\alph*)]\n\n\t\\item The electric field strength $2.0$ cm from the surface of a $10$-cm-diameter metal ball is $50,000$ N/C. What is the total  charge $Q$ (in nC) on the metal ball?\n\t\\item The electric field strength $10.0$ cm away from a very long charged wire\\footnote{\\label{text}Look in text/notes to find relevant $\\vec{E}$ field equation.} is $2000$ N/C. What is the electric field strength $5.0$ cm from the wire?\n\t\n\\end{enumerate}\n\n\n\n\\section{Through the Wire}\n\nNo notes or textbook this time! \nShow that the electric field $\\vec{E}$ at point $p$ a distance $r$ above a wire of length $L$ with total charge $Q$ is: \n$$\\vec{E}(p) = \\frac{\\lambda}{4\\pi\\epsilon}\\int_{-\\frac{L}{2}}^ \\frac{L}{2} \\! \\mathrm{d}x \\ \\frac{x}{(r^2 + x^2)^\\frac{3}{2}}  \\ \\hat{y}$$\n\n\\includegraphics[width=.4\\linewidth]{W2a_fig3.png}\n\n\\hint{\\texttt{Hint 1}: See problem 1(a)}\n\n\\hint{\\texttt{Hint 2}: Use the Pythagorean theorem}\n\n\n\\end{document}\t\t\t", "meta": {"hexsha": "1d186b51b76e67f383211fdbd972cea11617d025", "size": 3834, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Worksheets/P40C_F18_Worksheet2a.tex", "max_stars_repo_name": "stepheniota/Physics40C-F18", "max_stars_repo_head_hexsha": "8b814d7989d9ee7fba1580207ba15b43c4a6c1b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Worksheets/P40C_F18_Worksheet2a.tex", "max_issues_repo_name": "stepheniota/Physics40C-F18", "max_issues_repo_head_hexsha": "8b814d7989d9ee7fba1580207ba15b43c4a6c1b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Worksheets/P40C_F18_Worksheet2a.tex", "max_forks_repo_name": "stepheniota/Physics40C-F18", "max_forks_repo_head_hexsha": "8b814d7989d9ee7fba1580207ba15b43c4a6c1b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8111888112, "max_line_length": 238, "alphanum_fraction": 0.6778821075, "num_tokens": 1138, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6619228758499941, "lm_q1q2_score": 0.40714072222360037}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{graphicx,amsmath,amsfonts,amssymb,graphicx} \n\\usepackage[varg]{txfonts}\n\\usepackage{enumerate}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{color}\n\\urlstyle{tt}\n\n\\usepackage{geometry}\n\\geometry{%\n  letterpaper,\n  lmargin=2cm,\n  rmargin=2cm,\n  tmargin=2cm,\n  bmargin=2cm,\n  footskip=12pt,\n  headheight=12pt}\n  \n\\usepackage{lastpage}\n\\usepackage{fancyhdr}\n%\\pagestyle{fancy}\n%\\headheight 35pt\n\n\\def\\squarebox#1{\\hbox to #1{\\hfill\\vbox to #1{\\vfill}}}\n\\def\\qed{\\hspace*{\\fill}\n        \\vbox{\\hrule\\hbox{\\vrule\\squarebox{.667em}\\vrule}\\hrule}}\n\\newenvironment{solution}{\\begin{trivlist}\\item[]{\\bf Solution:}}\n                      {\\textbf{//} \\end{trivlist}}\n\\lstset{\n\tlanguage=MATLAB,              % choose the language of the code (\"language=Verilog\" is popular as well)\n   tabsize=3,\t\t\t\t\t\t\t  % sets the size of the tabs in spaces (1 Tab is replaced with 3 spaces)\n\tbasicstyle=\\tiny,               % the size of the fonts that are used for the code\n\tnumbers=left,                   % where to put the line-numbers\n\tnumberstyle=\\tiny,              % the size of the fonts that are used for the line-numbers\n\tstepnumber=2,                   % the step between two line-numbers. If it's 1 each line will be numbered\n\tnumbersep=5pt,                  % how far the line-numbers are from the code\n\t%backgroundcolor=\\color{mygrey}, % choose the background color. You must add \\usepackage{color}\n\t%showspaces=false,              % show spaces adding particular underscores\n\t%showstringspaces=false,        % underline spaces within strings\n\t%showtabs=false,                % show tabs within strings adding particular underscores\n\tframe=single,\t                 % adds a frame around the code\n\ttabsize=3,\t                    % sets default tabsize to 2 spaces\n\tcaptionpos=b,                   % sets the caption-position to bottom\n\tbreaklines=true,                % sets automatic line breaking\n\tbreakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace\n\t%escapeinside={\\%*}{*)},        % if you want to add a comment within your code\n\t%commentstyle=\\color{BrickRed}   % sets the comment style\n}                    \n\\begin{document}\n\n\\title{\\bf{CSE397: Assignment \\#4}}\n\\author{Nicholas Malaya \\\\ Department of Mechanical Engineering \\\\\nInstitute for Computational Engineering and Sciences \\\\ University of\nTexas at Austin} \\date{} \n\\maketitle\n\\newpage\n\n\\subsection*{ Problem 1}\n\\textbf{Frequency-domain inverse wave problem.} \n\n\\begin{enumerate}\n\\item[(a)]\n\\begin{solution}\nThe weak form of the state equation is given by: \n\\begin{displaymath}\n\\int_{\\Omega}\\nabla u \\cdot \\nabla p - k^2mup - fp\\hspace{2 mm}dx -\n \\int_{\\Gamma}p\\nabla u \\cdot n\\hspace{2 mm}ds \\hspace{1 cm} \\forall p\n \\in H^1_0(\\Omega) \n\\end{displaymath}\nHowever since p = 0 on the boundary then the boundary term is zero. The\n Lagragian is therefore:  \n\\begin{displaymath}\n\\mathcal{L}(u,p,m) := \\int_{\\Omega}\\nabla u \\cdot \\nabla p - k^2mup -\n fp\\hspace{2 mm}dx + \\int_{\\Omega}\\left(u - u^{obs}\\right)^2 dx +\n \\frac{\\beta}{2}\\int_{\\Omega}\\nabla m \\cdot \\nabla m dx \n\\end{displaymath}\nWe now take variations with respect to each of the parameters:\n\\begin{align}\n\\delta_u\\mathcal{L}(\\tilde{u}) &= \\int_{\\Omega}(u-u^{obs})\\tilde{u} +\n \\nabla\\tilde{u}\\cdot\\nabla p - k^2m\\tilde{u}p \\hspace{2 mm} dx = 0\n \\hspace{1 cm} \\forall\\tilde{u} \\in H^1_0(\\Omega) \\nonumber \\\\ \n\\delta_p\\mathcal{L}(\\tilde{p}) &= \\int_{\\Omega} \\nabla u \\cdot\n \\nabla\\tilde{p} - k^2mu\\tilde{p} - f\\tilde{p} \\hspace{2 mm} dx = 0\n \\hspace{1 cm} \\forall\\tilde{p} \\in H^1_0(\\Omega) \\nonumber \\\\ \n\\delta_m\\mathcal{L}(\\tilde{m}) &= \\int_{\\Omega} \\beta \\nabla m \\cdot\n \\nabla\\tilde{m} - k^2\\tilde{m}up \\hspace{2 mm} dx = 0 \\nonumber \n\\end{align}\nThe last of these equations is the gradient equation. It depends\n on both p and u which come from the adjoint and state\n equations. u is found to be the solution of the\n following: \n\\begin{align}\n-\\Delta u - k^2mu &= f\\hspace{5 mm} \\text{on } \\Omega \\nonumber \\\\\nu &= 0 \\hspace{5 mm} \\text{on } \\partial\\Omega \\nonumber\n\\end{align}\nand $p$ is found to be the soultion to the adjoint equation:\n\\begin{align}\n-\\Delta p - k^2mp &= u^{obs} - u \\hspace{5 mm} \\text{on } \\Omega \\nonumber \\\\\np &= 0 \\hspace{5 mm} \\text{on } \\partial\\Omega \\nonumber.\n\\end{align}\nUsing the solutions of these equations then gives the gradient with\n $\\delta_m\\mathcal{L}(\\tilde{m}) = 0$. \n\\end{solution}\n\n\\item[(b)] Derive an expression for the (infinite dimensional) action of\n\t   the Hessian in a direction m in the single source and frequency case.\n\n\\begin{solution}\nTo get the application of a Hessian on a vector, one needs the second\n variation of the three weak forms in the previous section. These are: \n\\begin{align}\n\\left(\\delta_u+\\delta_m+\\delta_p\\right)\\left(\\delta_u\\mathcal{L}\\right)\n &= \\int_\\Omega \\hat{u}\\tilde{u} - k^2\\hat{m}\\tilde{u}p -\n k^2m\\tilde{u}\\hat{p} + \\nabla\\tilde{u}\\cdot\\nabla\\hat{p} \\hspace{2 mm}\n dx \\nonumber \\\\ \n\\left(\\delta_u+\\delta_m+\\delta_p\\right)\\left(\\delta_p\\mathcal{L}\\right)\n &= \\int_\\Omega \\nabla\\hat{u}\\cdot\\nabla\\tilde{p} - k^2m\\hat{u}\\tilde{p}\n - k^2\\hat{m}u\\tilde{p} \\hspace{2 mm} dx \\nonumber \\\\ \n\\left(\\delta_u+\\delta_m+\\delta_p\\right)\\left(\\delta_m\\mathcal{L}\\right)\n &= \\int_\\Omega \\beta\\nabla\\hat{m}\\cdot\\nabla\\tilde{m} -\n k^2\\tilde{m}\\hat{u}p - k^2\\tilde{m}u\\hat{p} \\hspace{2 mm} dx \\nonumber \n\\end{align}\nHowever this introduces two new variables $\\hat{p}$ and $\\hat{u}$\n which need to be solved for. From the second variation one gets\n $\\hat{u}$. Its strong form is given by:  \n\\begin{align}\n-\\Delta\\hat{u}-k^2m\\hat{u} &= k^2\\hat{m}u \\hspace{5 mm} \\text{on }\n \\Omega \\nonumber \\\\ \n\\hat{u} &= 0 \\hspace{5 mm} \\text{on } \\partial\\Omega \\nonumber\n\\end{align}\nSimilarly $\\hat{p}$ is given by the solution to the second variation of the adjoint equation:\n\\begin{align}\n-\\Delta\\hat{p} - k^2m\\hat{p} &= k^2\\hat{m}p - \\hat{u}\\hspace{5 mm} \\text{on } \\Omega \\nonumber \\\\\n\\hat{p} &= 0 \\hspace{5 mm} \\text{on } \\partial\\Omega \\nonumber\n\\end{align}\nUsing the solution to the state equation ($u$), the solution to the\n adjoint equation ($p$), $m$, the solution to the second variation of\n the state equation ($\\hat{u}$), the solution to the second variation of\n the adjoint equation ($\\hat{p}$), and given a direction $\\hat{m}$, the\n action of the Hessian in a direction $\\hat{m}$ is given by: \n\\begin{displaymath}\n\\int_\\Omega \\beta\\nabla\\hat{m}\\cdot\\nabla\\tilde{m} -\n k^2\\tilde{m}\\hat{u}p - k^2\\tilde{m}u\\hat{p} \\hspace{2 mm} dx = 0 \n\\end{displaymath}\n\\end{solution}\n\n\\item[(c)] Derive an expression for the (infinite dimensional) gradient\n\t   for an arbitrary number of sources and frequencies. How many\n\t   state and adjoint equations have to be solved for a single\n\t   gradient computation? \n\n\\begin{solution}\nThe gradient is still calculated in the same manner as in the previous\n case with a single source and frequency. Therefore it is the variation\n of the Lagrangian with respect to m. However, now for each $u_{ij}$\n there is a corresponding adjoint variable $p_{ij}$ and the Lagrangian\n takes a slightly different form than before. With all of the\n frequencies and sources the minimization problem is given as stated: \n\\begin{displaymath}\n\\min_m J(m) :=\n \\frac{1}{2}\\sum_{i=1}^{N_f}\\sum_{j=1}^{N_s}\\int_{\\Omega}\\left(u_{ij} -\n u_{ij}^{obs}\\right)^2 dx + \\frac{\\beta}{2}\\int_{\\Omega}\\nabla m \\cdot\n \\nabla m dx \n\\end{displaymath}\nTo form the Lagrangian this needs to be paired with the state equation. However the state equation for a single $u_{ij}$ is given by:\n\\begin{align}\n-\\Delta u_{ij} - k_i^2m(x)u_{ij}(x) &= f_j(x)\\hspace{5 mm} \\text{on }\n \\Omega \\hspace{5 mm} i = 1, 2, ..., N_f \\hspace{5 mm} j = 1, 2, ...,\n N_s \\nonumber \\\\ \nu_{ij} &= 0 \\hspace{5 mm} \\text{on } \\partial\\Omega \\nonumber\n\\end{align}\nTherefore one needs to carry all $N_sN_f$ of these into the\n Lagrangian. Note that in weak form, a single state equation looks like: \n\\begin{displaymath} \n\\int_{\\Omega}\\nabla u_{ij} \\cdot \\nabla p_{ij} - k_i^2mu_{ij}p_{ij} -\n f_jp_{ij}\\hspace{2 mm}dx \\hspace{1 cm} \\forall p_{ij} \\in H^1_0(\\Omega) \n\\end{displaymath}\nAgain the boundary term is zero since $p_{ij} = 0$ on the boundary. With\n the weak forms for each of the $u_{ij}$, the Lagrangian is given by: \n\\begin{displaymath}\n\\mathcal{L} := \\sum_{i=1}^{N_f}\\sum_{j=1}^{N_s}\\int_{\\Omega}\\left(\\nabla\n u_{ij} \\cdot \\nabla p_{ij} - k_i^2mu_{ij}p_{ij} - f_jp_{ij}\\right)dx +\n \\frac{1}{2}\\sum_{i=1}^{N_f}\\sum_{j=1}^{N_s}\\int_{\\Omega}\\left(u_{ij} -\n u_{ij}^{obs}\\right)^2 dx + \\frac{\\beta}{2}\\int_{\\Omega}(\\nabla m \\cdot\n \\nabla m) dx \n\\end{displaymath}\nTaking a variation with respect to $m$ of this gives:\n\\begin{displaymath} \n\\int_{\\Omega} \\beta (\\nabla m \\cdot \\nabla\\tilde{m})dx -\n \\sum_{i=1}^{N_f}\\sum_{j=1}^{N_s}\\int_{\\Omega}(k_i^2\\tilde{m}u_{ij}p_{ij})dx \n\\end{displaymath}\nThis will give the gradient for a point $m$, provided a solution is\n available for each of the $u_{ij}$ and the $p_{ij}$. Obtaining those\n solutions requires $N_sN_f$ solves of the state and adjoint equations\n for a total of $2N_sN_f$ PDE solves. \n\\end{solution}\n\\end{enumerate}\n\n\\newpage\n\\subsection*{Problem 2}\n\n\\begin{enumerate}\n\\item[(a)] Report the solution of the inverse problem and the number of\n\t  required iterations for the following cases:\n\n\n%Report the reconstructions and the number of required\n%\t  iterations for the following cases:\n\n\\begin{enumerate}\n \\item[$\\bullet$] Noise level of 0.01 (roughly $1\\%$ noise), and\n\t      regularization $\\beta = 5 \\cdot 10^{-10}$.\n \\item[$\\bullet$] Same, but with $\\beta = 0$, i.e., no regularization. \n \\item[$\\bullet$] No noise, and use $m \\equiv 4$ and $m \\equiv 8$ as\n\t      initial guesses for the parameter. Do you find the same\n\t      solution? Explain the behavior.  \n\\end{enumerate}\n\\begin{solution}\nThe following table summarizes the number of iterations for each of the\n desired start conditions: \n\\begin{center}\n\\begin{tabular}{| c | c | c | c |} \\cline{1-4}\nNoise & $\\beta$ & $m$ & No. of Iterations \\\\ \\cline{1-4}\n0.01 & 5E-10 & 8 & 284 \\\\ \\cline{1-4}\n0.01 & 0.0 & 8 & 27 \\\\ \\cline{1-4}\n0.0 & 0.0 & 8 & 27 \\\\ \\cline{1-4}\n0.0 & 0.0 & 4 & 24 \\\\ \\cline{1-4} \n\\end{tabular} \n\\end{center}\nThe results of these trials are can be quite different. The case with noise\n and regularization yields the following result: \n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2aNoiseRegM8.jpg}\n\\end{center}\n\nThe case with no regularization resulted in:\n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2aNoiseNoRegM8.jpg}\n\\end{center}\n\nThe case with no noise and no regularization and $m = 8$:\n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2aNoNoiseNoRegM8.jpg}\n\\end{center}\n\nThe case with no noise and no regularization and $m = 4$:\n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2aNoNoiseNoRegM4.jpg}\n\\end{center}\n\nNote the difference in the final cases where the result for $m = 4$ ($a$\n in the image) is vastly different from the other results. This is a\n direct result of steepest descent being dependent on the start\n value. The case with no noise or regularization with $m = 8$ provides a \n solution close to the truth. Similarly\n the $m = 4$ solution is close to the true solution except for the\n diagonals. Note also that the $p$ values are also rather\n different. This is likely due to the adjoint being sensitive to\n $m$. $u$ should also be sensitive to $m$, but the end result look\n roughly the same because of the misfit penalization.\n\\end{solution}\n\n\\item[(b)] Add the advective term v = (30, 0) to the inverse problem and its COMSOL\n\t  implementation and plot the resulting reconstruction of m for\n\t  a noise level of 0.01 and for a reasonably chosen regularization parameter.\n\n\\begin{solution}\nAfter adding the advective term, the result for a noise level of 0.01\n and regularization of 5e-10 is given by: \n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2bNoiseRegM8.jpg}\n\\end{center}\n\\end{solution}\n\n\\item[(c)] Since the coefficient m is discontinuous, a better choice of\n\t   regularization is total variation\n\t   rather than Tikhonov regularization, to prevent an overly smooth\n\t   reconstruction. Modify the implementation and plot the result\n\t   for a reasonably chosen regularization parameter\n\n\n%Since the coefficient $m$ is discontinuous, a better choice is to use total variation\n%regularization rather than Tikhonov regularization to prevent an overly smooth\n%reconstruction. Modify the implementation and plot the result for a reasonably\n%chosen regularization parameter.\n\n\\begin{solution}\n Since one is switching to a total variational regularization parameter,\n now two choices of parameters are needed. For the solution shown below,\n the calculation was done with the same advective term, regularization\n parameter beta, and noise level as before in part b, however it also\n uses a tau of 1e-1 as requested. The result found is: \n\\begin{center}\n\\includegraphics[width = 6 cm]{figs/prob2c.jpg}\n\\end{center}\nNote that the drift from the advective term is not fully removed by this\n regularization, though the solution is much closer than with Tikhonov\n regularization. \n\\end{solution}\n\\end{enumerate}\n\n\\newpage\n\\subsection*{Code}\nHere is the code for part c:\n\\lstinputlisting{code/elliptic_sd_ip_adv_TV.m}\n\\end{document}", "meta": {"hexsha": "632dd21cafc24575e1c391062c06bb28c1c51b06", "size": 13254, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "inv_prob/ps4/report.tex", "max_stars_repo_name": "nicholasmalaya/paleologos", "max_stars_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-04T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T17:49:42.000Z", "max_issues_repo_path": "inv_prob/ps4/report.tex", "max_issues_repo_name": "nicholasmalaya/paleologos", "max_issues_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "inv_prob/ps4/report.tex", "max_forks_repo_name": "nicholasmalaya/paleologos", "max_forks_repo_head_hexsha": "11959056caa80d3c910759b714a0f8e42f986f0f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-01-04T16:08:18.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-16T19:34:24.000Z", "avg_line_length": 43.1726384365, "max_line_length": 133, "alphanum_fraction": 0.7020522107, "num_tokens": 4283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043814, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4071407169848928}}
{"text": "\n\\documentclass{beamer}\n\n\\usepackage{graphicx}\n\\usepackage[latin1]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[english]{babel}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\usepackage{eso-pic}\n\\usepackage{mathrsfs}\n\\usepackage{url}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{multirow}\n\\usepackage{hyperref}\n\\usepackage{booktabs}\n% \\usepackage{bbm}\n\\usepackage{cooltooltips}\n\\usepackage{colordef}\n\\usepackage{beamerdefs}\n\\usepackage{lvblisting}\n\n\\usepackage{multimedia}\n\\usepackage{algorithmicx}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{algorithm}\n\n\n\\pgfdeclareimage[height=2cm]{logobig}{hulogo}\n\\pgfdeclareimage[height=0.7cm]{logosmall}{Figures/LOB_Logo}\n\n\\renewcommand{\\titlescale}{1.0}\n\\renewcommand{\\titlescale}{1.0}\n\\renewcommand{\\leftcol}{0.6}\n\n\n\\title[Eigenvalue Problems - Numerical Solutions]{Eigenvalues and Eigenvectors}\n\\authora{Thomas Siskos}\n\\authorb{}\n\\authorc{}\n\n\\def\\linka{siskosth@student.hu-berlin.de}\n\\def\\linkb{http://github.com/thsis/NIS18}\n\\def\\linkc{}\n\n\\institute{Numerical Introductory Seminar \\\\\nHumboldt--University Berlin \\\\}\n\n\\hypersetup{pdfpagemode=FullScreen}\n\n\\begin{document}\n% 0-1\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame[plain]{\n\n\\titlepage\n}\n\n\\frame{\n  \\frametitle{Agenda}\n  \\tableofcontents\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Motivation}\n\\frame[containsverbatim]{\n\\frametitle{PCA}\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.25\\textwidth}\n\t\\begin{itemize}\n\t\t\\item The iris dataset is already linearly separable.\n\t\t\\item With various techniques we can show this in even more detail.\n\t\\end{itemize}\n\\end{column}\n\\begin{column}{0.75\\textwidth}\n\\begin{figure}\n  \t\\begin{center}\n\t\\includegraphics[scale=0.20]{../media/plots/iris_raw.png}\n    \\caption{\\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris Pairplot}  \\protect\\includegraphics[scale=0.05]{qletlogo.pdf}}\n\t\\end{center}\n\\end{figure}\n\\end{column}\n\\end{columns}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\frame[containsverbatim, label=PCA-prop]{\n\\frametitle{PCA}\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.65\\textwidth}\n\t\\begin{itemize}\n\t\t\\item objective:\n\t\t\\begin{equation}\n\t\t\\label{pca_obj}\n            max\\ \\delta^{\\prime} Var \\left(X\\right) \\delta \\; s.t. \\; \\sum \\delta_i^2 = 1.\n        \\end{equation}\n        where $X \\in \\mathbb{R}^{n \\times m}; m,n \\in \\mathbb{N}; \\delta \\in \\mathbb{R}^m$\n\t\t\\item solution \\hyperlink{PCA-proof}{\\beamergotobutton{Proof}}\n:\n\t\t\\begin{equation}\n\t\t\\label{pca_sol}\n\t\t\tY = \\Gamma^{\\prime} \\left(X - \\mu\\right)\n\t\t\\end{equation}\n\t\twhere $Y \\in \\mathbb{R}^{n \\times m}$ is the matrix of rotations,\n\t\t      $\\Gamma \\in \\mathbb{R}^{m \\times m}$ is the matrix of eigenvectors,\n\t\t      $\\mu \\in \\mathbb{R}^m$ is the vector of sample means.\n\t\\end{itemize}\n\\end{column}\n\\begin{column}{0.35\\textwidth}\n\\begin{figure}\n\t\\includegraphics[width=3.5cm, height=5cm]{../media/plots/iris_pca.png}\n\t\\caption{\\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris PCA}  \\protect\\includegraphics[scale=0.05]{qletlogo.pdf}}\n\\end{figure}\n\\end{column}\n\\end{columns}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\frame{\n\\frametitle{LDA}\n\\begin{itemize}\n\t\\item objective:\n\t\t\\begin{equation}\n\t\t\\label{lda_obj}\n  \t\t\tmax \\ \\frac{w^{\\prime}S_B w}{w^{\\prime}S_W w},\n\t\t\\end{equation}\n\twhere\n\t\\begin{align*}\n  \tS_B &= \\sum\\limits_{c}^{C} (\\mu_c - \\mu)(\\mu_c - \\mu)^{\\prime}, \\\\\n  \tS_W &= \\sum\\limits_{c}^{C} \\sum\\limits^{n}_{i=1} (x_i - \\mu_c)(x_i - \\mu_c)^{\\prime}\n\t\\end{align*}\n\tand $x_i \\in \\mathbb{R}^m$, $\\mu_c$ is the vector of class means.\n\\end{itemize}\n\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\frame[containsverbatim, label=LDA-prop]{\n\\frametitle{LDA}\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.65\\textwidth}\n\\begin{itemize}\n\\item solution \\hyperlink{LDA-proof}{\\beamergotobutton{Proof}}:\n\\begin{equation}\n  \\label{lda_sol}\n    S_B^{\\frac{1}{2}}S_{W}^{-1}S_B^{\\frac{1}{2}} v = \\lambda v\n  \\end{equation}\n  with $$    v = S_B^{\\frac{1}{2}} w, $$ where this is again an Eigenvalue problem and it's solution will provide the rotation that ensures the largest possible (linear) separability.\n\\item Now how do we get the Eigenvalues?\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.35\\textwidth}\n\\begin{figure}\n\t\\begin{center}\n\t\\includegraphics[width=3.5cm, height=5cm]{../media/plots/iris_lda.png}\n\t\\caption{\\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris LDA}  \\protect\\includegraphics[scale=0.05]{qletlogo.pdf}}\n\t\\end{center}\n\\end{figure}\n\\end{column}\n\\end{columns}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Key Idea \\& Definitions}\n\\frame{\n\\frametitle{Eigenvalue}\nIf $A$ is an $n \\times n$ matrix, $v$ is a non-zero vector and $\\lambda$ is a scalar, such that\n\\begin{equation}\n\\label{eigenvalue-def}\nAv = \\lambda v\n\\end{equation}\nthen $v$ is called an \\textit{eigenvector} and $\\lambda$ is called an \\textit{eigenvalue} of the matrix $A$.\nAn eigenvalue of A is a root of the characteristic equation,\n\\begin{equation}\n\\label{eigenvalue-solve}\ndet\\left(A - \\lambda I \\right) = 0\n\\end{equation}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Characteristic Polynomial \\& Diagonal Matrices}\n\\frame[label=companion_prop]{\n\\frametitle{The characteristic polynomial}\nConsider the polynomial\n\\begin{equation}\n\\label{characteristic-polynomial}\nf(\\lambda) = \\lambda^p + a_{p-1}\\lambda^{p-1} + \\dots + a_1 \\lambda + a_0\n\\end{equation}\nWe now construct a matrix $A \\in \\mathbb{R}^{n \\times n}$ such that the eigenvalues of $A$ are the roots of the polynomial $f(\\lambda)$ \\hyperlink{companion_exmpl}{\\beamergotobutton{Example}}:\n\\begin{equation}\n\\label{companion-matrix}\nA = \\begin{bmatrix}\n        0    & 1    & 0    & \\dots & 0 \\\\\n        0    & 0    & 1    & \\cdots & 0 \\\\\n             &      &      & \\ddots & \\\\\n        0    & 0    & 0    & \\dots  & 1 \\\\\n        -a_0 & -a_1 & -a_2 & \\dots  & -a_{p-1} \\\\\n    \\end{bmatrix}\n\\end{equation}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Similarity Transformations}\n\\frame[containsverbatim]{\n\\frametitle{General Idea}\n\nWhat are the eigenvalues of $X_1$ and $X_2$?\n\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.3\\textwidth}\n\\begin{equation*}\nX_1 = \\begin{bmatrix}\n1 & 0 & 0 & 0 \\\\\n0 & 2 & 0 & 0 \\\\\n0 & 0 & 3 & 0 \\\\\n0 & 0 & 0 & 4 \\\\\n\\end{bmatrix}\n\\end{equation*}\n\\end{column}\n\\begin{column}{0.7\\textwidth}\n\\begin{equation*}\nX_2 = \\begin{bmatrix}\n        2.297 & -0.461 & -0.459 &  0.225 \\\\\n       -0.461 &  1.4   & -0.097 & -0.829 \\\\\n       -0.459 & -0.097 &  2.672 &  0.224 \\\\\n        0.225 & -0.829 &  0.224 &  3.631 \\\\\n\\end{bmatrix}\n\\end{equation*}\n\\end{column}\n\n\\end{columns}\n}\n\n\\frame[label=similarity_prop]{\n\\frametitle{Similarity Transformations}\n\nTwo $n \\times n$ matrices $A$ and $B$, are said to be \\textit{similar} if there exists a nonsingular matrix $P$ such that\n\\begin{equation}\n\\label{similarity-prop}\nA = P^{-1} B P\n\\end{equation}\n\nIf the two matrices $A$ and $B$ are similar, then they also share the same eigenvalues. \\hyperlink{similarity_proof}{\\beamergotobutton{Proof}}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection{Householder Reflections}\n\\frame[label=householder_prop]{\n\\frametitle{Householder Reflections}\nLet $u$ and $v$ be orthonormal vectors and let $x$ be a vector in the space spanned by $u$ and $v$, such that\n$$x = c_1 u + c_2 + v$$\nfor some scalars $c_1$ and $c_2$. The vector\n$$\\tilde{x}=-c_1 u + c_2 v$$\nis a \\textit{reflection} of x through the line difined by the vector u. Now consider the matrix\n\n\\begin{equation}\nQ = I - 2 uu^{\\prime}.\n\\end{equation}\n\nNote that \\hyperlink{householder_proof}{\\beamergotobutton{Proof}}:\n$$Qx = \\tilde{x}$$\n}\n\n\\frame{\n\\frametitle{Householder Reflections}\nWe will use Householder-Reflections to tranform a vector\n$$a = (a_1, \\dots, a_n)$$\ninto\n$$\\hat{a} = (\\hat{a}_1, 0, \\dots, 0)$$\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsubsection{Givens Rotations}\n\\frame[containsverbatim]{\n\\frametitle{Givens Rotations}\nUsing orthogonal transformations we can also rotate a vector in such a way that a specified element becomes 0 and only one other element in the vector is changed.\n\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.5\\textwidth}\n$$\nQ = \\begin{bmatrix}\n\\cos\\theta & \\sin\\theta \\\\\n-\\sin\\theta & \\cos\\theta\n\\end{bmatrix}\n$$\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\t\\includegraphics[scale=.5]{../media/plots/givens.png}\n\\end{column}\n\\end{columns}\n\n\n\n}\n\\frame[label=givens_prop]{\n\\frametitle{Givens Rotations}\n\n\\begin{equation}\nV_{pq}(\\theta) = \\begin{bmatrix}\n                      1 &  &  &  &  &  &  &  &  \\\\\n                       & \\ddots &  &  &  &  & &  &  \\\\\n                       &  & 1 &  &  &  &  &  &  \\\\\n                       &  &  & \\cos\\theta &  & \\sin\\theta &  &  &  \\\\\n                       &  &  &  & \\ddots &  &  &  &  \\\\\n                       &  &  & -\\sin\\theta &  & \\cos\\theta &  &  &  \\\\\n                       &  &  &  &  &  & 1 &  &  \\\\\n                       &  &  &  &  &  &  & \\ddots &  \\\\\n                       &  &  &  &  &  &  &  & 1 \\\\\n                 \\end{bmatrix}\n\\end{equation}\n\twhere $\\cos\\theta = \\frac{x_p}{||x||}$ and $\\sin\\theta = \\frac{x_q}{||x||}$\n\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Algorithms}\n\\subsection{Jacobi-Method}\n\\frame{\n\\frametitle{Jacobi Method}\n\nThe Jacobi method for determining the eigenvalues of a symmetric matrix $A$ uses a sequence of orthogonal similarity transformations that result in the transformation:\n$$A = P  \\Lambda P^{-1}$$ or rather: $$\\Lambda=P^{-1}AP$$\nwhere we use Givens Rotations to obtain $P$. The Jacobi iteration is:\n\\begin{equation}\n\\label{j-meth}\nA^{k} = V_{p_k q_k}(\\theta_k)A^{k-1}V_{p_k q_k}(\\theta_k)\n\\end{equation}\n\nThe Jacobi Method is of $O(n^3)$\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\n\\frametitle{Jacobi-Method}\n\\begin{algorithm}[H]\n\\caption{\\texttt{jacobi}}\n\\label{j-algo}\n\\begin{algorithmic}\n  \\Require symmetric matrix $A$\n  \\Ensure $0 < precision < 1$\n  \\Statex \\textbf{initialize: } $L \\gets A$; $U \\gets I$; $L_{max} \\gets 1$\n  \\While{$L_{max} > precision$}\n    \\State Find indices $i$, $j$ of largest value in lower triangle of $abs(L)$\n        \\State $L_{max} \\gets L_{i,j}$\n            \\State $\\alpha \\gets \\frac{1}{2}\\cdot \\arctan(\\frac{2A_{i, j}}{A_{i, i}-A_{j, j}})$\n    \\State $V \\gets I$\n    \\State $V_{i, i}, V_{j, j} \\gets \\cos \\alpha$; $V_{i, j}, V_{j, i} \\gets -\\sin \\alpha, \\sin \\alpha$\n    \\State $A \\gets V^{\\prime} A V$; $U \\gets UV$\n\n  \\EndWhile\n  \\Return $diag(A), U$\n\\end{algorithmic}\n\\end{algorithm}\n}\n\\subsection{QR-Method}\n\\frame{\n\\frametitle{QR-Method}\nThe QR-Method is the most common algorithm for obtaining eigenvalues and eigenvectors of a matrix $A$. It relies on the so called QR-Factorization:\n\\begin{equation}\nA = QR,\n\\end{equation}\nwhere $Q$ is an orthogonal and $R$ is an upper triangular matrix. \\\\\nThe QR iteration is:\n\\begin{equation}\n  A^k = Q_{k-1}^{\\prime} A_{k-1} Q_{k-1} = R_{k-1}Q_{k-1}\n\\end{equation}\n\nThe QR Method is of $O(n^3)$\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Basic Variant}\n\\frame{\n\\frametitle{Basic QR-Method}\n\\begin{algorithm}[H]\n\\caption{\\texttt{QRM1}}\n\\label{qr1-meth}\n  \\begin{algorithmic}\n    \\Require square matrix $A$\n    \\Statex \\textbf{initialize: } $conv \\gets False$\n    \\While{not $conv$}\n      \\State $Q, R \\gets$ QR-Factorization of $A$\n      \\State $A \\gets RQ$\n      \\If{$A$ is diagonal}\n        \\State $conv \\gets \\texttt{True}$\n        \\Statex\n      \\EndIf\n    \\EndWhile\n    \\Return $diag\\left(A\\right), Q$\n  \\end{algorithmic}\n\\end{algorithm}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Hessenberg Variant}\n\\frame{\n\\frametitle{Refined QR-Method}\n\n\\begin{columns}[onlytextwidth]\n\\begin{column}{0.5\\textwidth}\nFor faster convergence it is common to convert the matrix first into a so called upper Hessenberg form.\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n$$\n\\begin{bmatrix}\n X & X & X & X & X & X & X \\\\\n X & X & X & X & X & X & X \\\\\n 0 & X & X & X & X & X & X \\\\\n 0 & 0 & X & X & X & X & X \\\\\n 0 & 0 &  0 & X & X & X & X \\\\\n 0 & 0 & 0 & 0 & X & X & X \\\\\n 0 & 0 & 0 & 0 & 0 & X & X \\\\\n\\end{bmatrix}\n$$\n\\end{column}\n\\end{columns}\n\n\n\n\n\\begin{algorithm}[H]\n\\caption{\\texttt{QRM2}}\n\\label{qr2-meth}\n\\begin{algorithmic}\n  \\Require square matrix $A$\n  \\State $A \\gets \\texttt{hessenberg(}A\\texttt{)}$\n  \\State continue with: \\Call {QRM1} A\n\\end{algorithmic}\n\\end{algorithm}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\n  \\frametitle{QRM2 Visualized}\n  \\begin{center}\n    \\movie[width=8cm, height=5.35cm]{\\includegraphics[width=8cm, height=5.35cm]{Figures/placeholder.jpg}}{Figures/qrm_symmetric.mp4}\n\n    \\href {https://github.com/thsis/NIS18/blob/master/analysis/animation.py}{QR-Method} \\includegraphics[scale=0.05]{qletlogo.pdf}\n  \\end{center}\n\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsubsection{Accelerated Variant}\n\\frame{\n\\frametitle{Accelerated QR-Method}\n\nWe can accelerate the QR-Method by creating an artificial zero on the main diagonal of $A^k$s Hessenberg form $T$ at an iteration step $k$:\n\n\\begin{align*}\nT^{\\star} &= T - t _{p-1, p-1} I \\\\\nT^{\\star} &= QR \\\\\nT         &= T^{\\star} + t _{p-1, p-1} I\n\\end{align*}\n}\n\n\\frame{\n\\frametitle{Accelerated QR-Method}\n\\begin{algorithm}[H]\n\\begin{algorithmic}\n\\Require square matrix $A \\in \\mathbb{R}^{p \\times p}$\n\\State $T \\gets \\texttt{hessenberg}(A),\\ conv \\gets False$\n\\While{not $conv$}\n    \\State $Q, R \\gets$ QR-Factorization of $T - t_{p-1, p-1} I$\n    \\State $T \\gets RQ + t_{p-1, p-1}I$\n    \\If{$T$ is diagonal}\n        \\State $conv \\gets True$\n    \\EndIf\n\\EndWhile\n\\Return $diag\\left(T\\right), Q$\n\\end{algorithmic}\n\\end{algorithm}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Analysis}\n\\subsection{Accuracy}\n\\frame{\n\\frametitle{Unit tests - Idea}\n\\begin{enumerate}\n\\item Construct a $p \\times p$ matrix, with known Eigenvalues $\\lambda_{true} \\in \\mathbb{R}^p$. To do this we can invert the spectral decomposition.\n\\item Run the implemented algorithm on it, obtain the computed Eigenvalues $\\lambda_{algo} \\in \\mathbb{R}^p$.\n\\item Assess $L_1$-Norm: $|\\lambda_{true} - \\lambda_{algo}|$, pass the test if it is smaller than a threshold $\\epsilon$\n\\end{enumerate}\n\nRepeat the procedure $1000$ times.\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Efficiency}\n\\frame{\n\\frametitle{Time taken}\n\\begin{figure}\n\\begin{center}\n\n  \t\\caption{\\href {https://github.com/thsis/NIS18/blob/master/tests/tests_eigen.py}{Unit-tests: Time}  \\includegraphics[scale=0.05]{qletlogo.pdf}}\n  \\includegraphics[width=11.5cm, height=5cm]{../media/plots/time_boxplot.png}\n\\end{center}\n\\end{figure}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\n\\frametitle{Iterations needed}\n\\begin{figure}\n\\begin{center}\n\\caption{\\href {https://github.com/thsis/NIS18/blob/master/tests/tests_eigen.py}{Unit-tests: Iterations}  \\protect\\includegraphics[scale=0.05]{qletlogo.pdf}}\n  \\includegraphics[width=11.5cm, height=5cm]{../media/plots/iterations_boxplot.png}\n\n\\end{center}\n\\end{figure}\n}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame[label=PCA-proof]{\n\\frametitle{PCA: proof}\nThe objective of \\hyperlink{PCA-prop}{\\beamergotobutton{PCA}}:\n\t$$\n\tmax\\ \\delta^{\\prime} Var \\left(X\\right) \\delta \\; s.t. \\; \\sum \\delta_i^2 = 1\n\t$$\nCorresponding Lagrangean:\n    $$\n    \\mathcal{L}(Var \\left(X\\right), \\delta, \\lambda) =\n    \\delta^{\\prime} Var \\left(X\\right) \\delta - \\lambda \\left(\\delta^{\\prime}\\delta - 1\\right),\n    $$\n    where $\\lambda \\in \\mathbb{R}^m$ \\\\\nFirst order condition:\n\t\\begin{align}\n\t\\frac{\\partial \\mathcal{L}}{\\partial \\delta} &\\stackrel{!}{=} 0 \\notag\\\\\n\t2Var(X)\\delta - 2\\lambda_k \\delta &\\stackrel{!}{=} 0 \\notag\\\\\n\tVar(X)\\delta  &= \\lambda_k \\delta \\notag\n\t\\end{align}\nWhich is now reduced to a common Eigenvalue problem.\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame[label=LDA-proof]{\n\\frametitle{LDA: proof}\nThe objective of \\hyperlink{LDA-prop}{\\beamergotobutton{LDA}}:\n  $$ max \\ \\frac{w^{\\prime}S_B w}{w^{\\prime}S_W w},$$\nWhich we can reformulate to:\n  $$ max w^{\\prime}S_B w \\ s.t. w^{\\prime}S_W w = 1. $$\nCorresponding Lagrangean:\n  $$ \\mathcal{L}(w, S_B, S_W, \\lambda) = w^{\\prime}S_B w - \\lambda \\left(w^{\\prime}S_W w - 1\\right)$$\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\n\\frametitle{LDA: proof}\nFirst order condition:\n\\begin{align*}\n\\frac{\\partial \\mathcal{L}}{\\partial w} &\\stackrel{!}{=} 0 \\notag \\\\\n2S_B w - 2 \\lambda S_W w &\\stackrel{!}{=} 0 \\notag \\\\\nS_{W}^{-1}S_B w &= \\lambda w, \\\\\n\\end{align*}\n\nwhich is known as a generalized Eigenvalue problem. We can redefine\n\\begin{align*}\nS_B &= S_B^{\\frac{1}{2}} S_B^{\\frac{1}{2}} \\\\\nv &= S_B^{\\frac{1}{2}} w\n\\end{align*}\n}\n\\frame{\n\\frametitle{LDA: proof}\nWe then get:\n\\begin{align*}\nS_{W}^{-1}S_B w &= \\lambda w \\\\\nS_{W}^{-1}S_B^{\\frac{1}{2}} \\underbrace{S_B^{\\frac{1}{2}} w}_v  &= \\lambda w \\\\\nS_B^{\\frac{1}{2}} S_{W}^{-1}S_B^{\\frac{1}{2}} v  &=\\lambda \\underbrace{S_B^{\\frac{1}{2}} w}_v\n\\end{align*}\nWe can also rewrite this as:\n$$S_B^{-\\frac{1}{2}}S_{W}^{-1}S_B^{-\\frac{1}{2}} v = \\lambda v$$\n\nWhich now an Eigenvalue problem of a symmetric, positive semidefinite matrix \\hyperlink{LDA-prop}{\\beamergotobutton{back}}.\n\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame[label=similarity_proof]{\n\\frametitle{Eigenvalues of similar matrices}\nFrom the definition in (\\ref{similarity-prop}) it follows immediately that a matrix $A$ with Eigenvalues $\\lambda_1, \\dots, \\lambda_n$ is similar to the matrix $diag(\\lambda_1, \\dots, \\lambda_n)$.\n\nIf $A$ and $B$ are similar, as in (\\ref{similarity-prop}), it holds:\n\\begin{align*}\nB - \\lambda I &= P^{-1} B P - \\lambda P^{-1} I P \\notag \\\\\n              &= A - \\lambda I.\n\\end{align*}\n Hence $A$ and $B$ have the same eigenvalues. Additionally, important transformations are based around orthogonal matrices. If $Q$ is orthogonal and\n\\begin{equation*}\nA = Q^{\\prime} B Q,\n\\end{equation*}\n$A$ and $B$ are said to be \\textit{orthogonally similar} \\hyperlink{similarity_prop}{\\beamergotobutton{back}}.\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame[label=companion_exmpl]{\n\\frametitle{Companion-Matrix: Example}\nDemonstrate that the companion matrix \\hyperlink{companion_prop}{\\beamergotobutton{back}}:\n\\begin{enumerate}\n  \\item corresponds to a polynomial.\n  \\item has eigenvalues equal to the roots of the polynomial.\n\\end{enumerate}\n $$A = \\begin{bmatrix}\n           0    & 1 \\\\\n           -a_0 & -a_1 \\\\\n       \\end{bmatrix}$$\n\n  \\begin{align*}\n      det \\left(A - \\lambda I\\right) &= \\begin{bmatrix}\n                                            0 - \\lambda    & 1 \\\\\n                                            -a_0           & -a_1- \\lambda \\\\\n       \\end{bmatrix} \\\\\n                                     &= -\\lambda\\left(-a_1 - \\lambda\\right) + a_0 \\\\\n                                     &= \\lambda^2 + a_1 \\lambda + a_0\n  \\end{align*}\n\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\frame[label=householder_proof]{\n\\frametitle{Householder Reflections: proof}\n\\hyperlink{householder_prop}{\\beamergotobutton{back}}\nRemember:\n\\begin{itemize}\n\\item $Q = I - 2 uu^{\\prime}$.\n\\item $u$ $v$ are orthonormal.\n\\end{itemize}\n\n\\begin{align*}\nQx &= c_1 u + c_2 v - 2c_1 uuu^{\\prime} - 2 c_2 v uu^{\\prime} \\\\\n   &= c_1 u + c_2 v - 2c_1 u^{\\prime}uu - 2 c_2 u^{\\prime} v u \\\\\n   &= -c_1 u + c_2 v\\\\\n   &= \\tilde{x}\n\\end{align*}\n}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\frame{\n\\frametitle{Sources}\n\\begin{thebibliography}{3}\n\n\\bibitem{NME}\nSeffen B{\\\"o}rm and Christian Mehl.\nNumerical Methods for Eigenvalue Problems.\nWalter de Gruyter GmbH \\& Co.KG, Berlin/Boston, 2012.\n\n\\bibitem{NLA}\nJames E. Gentle.\nNumerical Linear Algebra for Applications in Statistics.\nSpringer Science + Business Media, New York, 2003.\n\n\\bibitem{MVA}\nWolfgang K. H{\\\"a}rdle and L{\\'e}opold Simar.\nApplied Multivariate Statistical Analysis.\nSpringer-Verlag Gmbh, Berlin, Heidelberg, 2015.\n\n\\end{thebibliography}\n}\n\n\\end{document}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "8b2ffecf8cd002032f78f2b3054de143ab25a3c1", "size": 21386, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation/presentation.tex", "max_stars_repo_name": "thsis/NIS18", "max_stars_repo_head_hexsha": "1f2a7be1ab209fa7c0a25cb8eace744336b07c1f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentation/presentation.tex", "max_issues_repo_name": "thsis/NIS18", "max_issues_repo_head_hexsha": "1f2a7be1ab209fa7c0a25cb8eace744336b07c1f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation/presentation.tex", "max_forks_repo_name": "thsis/NIS18", "max_forks_repo_head_hexsha": "1f2a7be1ab209fa7c0a25cb8eace744336b07c1f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3051359517, "max_line_length": 196, "alphanum_fraction": 0.5698587861, "num_tokens": 6681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228625116081, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40714071401932117}}
{"text": "\\documentclass{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n% \\usepackage{amscd, amsfonts, amsmath, amssymb, amstext, amsthm, caption, epsfig, fancyhdr, float, graphicx, latexsym, mathtools, multicol, multirow, algorithm, chngcntr}\n\\usepackage[english]{babel}\n\\usepackage{booktabs}\n\n\\usepackage{amsmath,amssymb}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subfig}\n\\usepackage{xspace}\n\\usepackage{fourier}\n\n\\usepackage{tikz}\n\\usetikzlibrary{shapes,arrows}\n\\usepackage{tkz-graph}\n\\usetikzlibrary{automata,arrows,positioning,calc}\n\\usetikzlibrary{positioning}\n\\usetikzlibrary{fit}\n\\usetikzlibrary{backgrounds}\n\\usetikzlibrary{calc}\n\\usetikzlibrary{shapes}\n\\usetikzlibrary{mindmap}\n\\usetikzlibrary{decorations.text}\n\\usetikzlibrary{snakes}\n\n% \\theoremstyle{definition} % insert bellow all blocks you want in normal text\n% \\newtheorem{definition}{Definition}\n\n\n\n% tikzmark command, for shading over items\n\\newcommand{\\tikzmark}[1]{\\tikz[overlay,remember picture] \\node (#1) {};}\n% Define block styles\n\\tikzstyle{decision} = [diamond, draw, fill=blue!20,\n    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]\n\\tikzstyle{block} = [rectangle, draw, fill=blue!20,\n    text width=5em, text centered, rounded corners]\n\\tikzstyle{line} = [draw]\n\\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,\n    minimum height=2em]\n\n\\usepackage[most]{tcolorbox}\n\n\\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow\n\n\n% Distributions.\n\\newcommand*{\\UnifDist}{\\mathsf{Unif}}\n\\newcommand*{\\ExpDist}{\\mathsf{Exp}}\n\\newcommand*{\\DepExpDist}{\\mathsf{DepExp}}\n\\newcommand*{\\GammaDist}{\\mathsf{Gamma}}\n\\newcommand*{\\LognormalDist}{\\mathsf{LogNorm}}\n\\newcommand*{\\WeibullDist}{\\mathsf{Weib}}\n\\newcommand*{\\ParetoDist}{\\mathsf{Par}}\n\\newcommand*{\\NormalDist}{\\mathsf{Norm}}\n\n\\newcommand*{\\GeometricDist}{\\mathsf{Geom}}\n\\newcommand*{\\NegBinomialDist}{\\mathsf{NegBin}}\n\\newcommand*{\\PoissonDist}{\\mathsf{Poisson}}\n\\newcommand*{\\BivariatePoissonDist}{\\mathsf{BPoisson}}\n\\newcommand*{\\CyclicalPoissonDist}{\\mathsf{CPoisson}}\n\n\\newcommand*{\\iid}{\\textbf{iid}\\@\\xspace}\n\\newcommand*{\\pdf}{\\textbf{pdf}\\@\\xspace}\n\\newcommand*{\\cdf}{\\textbf{cdf}\\@\\xspace}\n\\newcommand*{\\pmf}{\\textbf{pmf}\\@\\xspace}\n\\newcommand*{\\abc}{{\\textbf{abc}}\\@\\xspace}\n\\newcommand*{\\smc}{\\textbf{smc}\\@\\xspace}\n\\newcommand*{\\mcmc}{\\textbf{mcmc}\\@\\xspace}\n\\newcommand*{\\ess}{\\textbf{ess}\\@\\xspace}\n\\newcommand*{\\mle}{\\textbf{mle}\\@\\xspace}\n\\newcommand*{\\bic}{\\textbf{bic}\\@\\xspace}\n\\newcommand*{\\kde}{\\textbf{kde}\\@\\xspace}\n\\newcommand*{\\glm}{\\textbf{glm}\\@\\xspace}\n\\newcommand*{\\xol}{\\textbf{xol}\\@\\xspace}\n\\newcommand*{\\cpu}{\\textbf{cpu}\\@\\xspace}\n\\newcommand*{\\gpu}{\\textbf{gpu}\\@\\xspace}\n\\newcommand*{\\arm}{\\textbf{arm}\\@\\xspace}\n\n\\def \\si {\\sigma}\n\\def \\la {\\lambda}\n\\def \\al {\\alpha}\n% \\def\\e*{\\end{eqnarray*}}\n\\def \\di{\\displaystyle}\n\n\\def \\E{\\mathbb E}\n\\def \\N{\\mathbb N}\n\\def \\Z{\\mathbb Z}\n\\def \\NZ{\\mathbb{N}_0}\n\\def \\I{\\mathbb I}\n\\def \\w{\\widehat}\n\\def \\P {\\mathbb P}\n\\def \\V{\\mathbb V}\n\n\n\\newcommand{\\CL}{\\mathbb{C}}\n\\newcommand{\\RL}{\\mathbb{R}}\n\\newcommand{\\nat}{{\\mathbb N}}\n\\newcommand{\\Laplace}{\\mathscr{L}}\n\\newcommand{\\e}{\\mathrm{e}}\n\\newcommand{\\ve}{\\bm{\\mathrm{e}}} % vector e\n\n\\renewcommand{\\L}{\\mathcal{L}} % e.g. L^2 loss.\n\n\\newcommand{\\ih}{\\mathrm{i}}\n\\newcommand{\\oh}{{\\mathrm{o}}}\n\\newcommand{\\Oh}{{\\mathcal{O}}}\n\\newcommand{\\Exp}{\\mathbb{E}}\n\n\\newcommand{\\Norm}{\\mathcal{N}}\n\\newcommand{\\LN}{\\mathcal{LN}}\n\\newcommand{\\SLN}{\\mathcal{SLN}}\n\n\\renewcommand{\\Pr}{\\mathbb{P}}\n\\newcommand{\\Ind}{\\mathbb I}\n\\newcommand\\bfsigma{\\bm{\\sigma}}\n\\newcommand\\bfSigma{\\bm{\\Sigma}}\n\\newcommand\\bfLambda{\\bm{\\Lambda}}\n\\newcommand{\\stimes}{{\\times}}\n\\def \\limsup{\\underset{n\\rightarrow+\\infty}{\\overline{\\lim}}}\n\\def \\liminf{\\underset{n\\rightarrow+\\infty}{\\underline{\\lim}}}\n\n\n\n\n% vertical separator macro\n\\newcommand{\\vsep}{\n  \\column{0.0\\textwidth}\n    \\begin{tikzpicture}\n      \\draw[very thick,black!10] (0,0) -- (0,7.3);\n    \\end{tikzpicture}\n}\n\\newcommand\\blfootnote[1]{%\n  \\begingroup\n  \\renewcommand\\thefootnote{}\\footnote{#1}%\n  \\addtocounter{footnote}{-1}%\n  \\endgroup\n}\n\n% More space between lines in align\n% \\setlength{\\mathindent}{0pt}\n\n% Beamer theme\n\\usetheme{ZMBZFMK}\n\\usefonttheme[onlysmall]{structurebold}\n\\mode<presentation>\n\\setbeamercovered{transparent=10}\n\n% align spacing\n\\setlength{\\jot}{0pt}\n\n\\setbeamertemplate{navigation symbols}{}%remove navigation symbols\n\n\\title[BLOCKASTICS]{Stochastic models for blockchain analysis}\n\\author{Pierre-O. Goffard}\n\\institute[ISFA]{Institut de Science Financières et d'Assurances\\\\\n \\texttt{pierre-olivier.goffard@univ-lyon1.fr}\n}\n\\date{\\today}\n% \\titlegraphic{\\includegraphics[width=2.5cm]{../../Figures/bfs_logo.png}} \n\n\\begin{document}\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\\begin{frame}\n  \\tableofcontents\n\\end{frame}\n\n\\section{Introduction}\n\\begin{frame}{Blockchain}\nA decentralized data ledger made of blocks maintained by achieving consensus in a P2P network.\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n% \\small\n\n\\begin{itemize}\n  \\item Decentralized\n  \\item Public/private\n  \\item Permissionned/permissionless\n  \\item Immutable\n  \\item Incentive compatible\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{center}\n\\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=01cm]\n\\tikzstyle{every edge}=[snake=expanding waves,segment length=1mm,segment angle=10, draw]\n\n\\tikzstyle{full node}=[circle, fill=tublue,draw=tublue,thick,text=black,scale=0.8]\n\\tikzstyle{light node}=[circle, fill=white,draw=tublue,thick,text=black,scale=0.8]\n\\node[full node]    (1)                     {};\n\\node[full node]    (2)[above right of=1]         {};\n\\node[full node]    (3)[above left of=1]         {};\n\\node[full node]    (4)[below of=1]         {};\n\\node[full node]    (5)[right of=4]         {};\n\\node[full node]    (6)[below of=4]         {};\n\\node[light node]    (7)[left of=1]         {};\n\\node[light node]    (8)[right of=2]         {};\n\\node[light node]    (9)[left of=4]         {};\n\\node[light node]    (10)[above right of=5]         {};\n\\node[light node]    (11)[ right of=5]         {};\n\\node[light node]    (12)[ below right of=5]         {};\n% \\node[light node]    (4)[above of=2]         {};\n\\path\n\n(1) edge node{} (2)\n    edge node{} (3)\n    edge node{} (7)\n    ;\n\\path\n(5) edge node{} (10)\n    edge node{} (11)\n    edge node{} (12)\n    ;\n    \\path\n(4) edge node{} (5)\n    edge node{} (1)\n    edge node{} (9)\n    edge node{} (6)\n    ;\n    \\path\n(2) edge node{} (8)   \n    ;\n\\end{tikzpicture}\n\\end{center}\n\\end{column}\n\\end{columns}\n\n\\vspace{0.2cm}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Focus of the talk]\nPublic and permissionless blockchain equipped with the Proof-of-Work protocol.\n\\end{tcolorbox}\n\\end{frame}\n\n\\begin{frame}{Consensus protocols}\nThe mechanism to make all the nodes agree on a common data history.\\\\\n\\vspace{0.3cm}\nThe three dimensions of blockchain systems analysis\n\\begin{enumerate}\n  \\item Efficiency\n  \\begin{itemize}\n    \\item Throughputs\n    \\item Transaction confirmation time\n  \\end{itemize}\n  \\item Decentralization\n  \\begin{itemize}\n    \\item Fair distribution of the accounting right\n  \\end{itemize}\n  \\item Security \n  \\begin{itemize}\n    \\item Resistance to attacks\n  \\end{itemize}\n\\end{enumerate}\n\\footnotesize\n\\begin{thebibliography}{1}\n\\bibitem{Fu2020}\nX.~Fu, H.~Wang, and P.~Shi, ``A survey of blockchain consensus algorithms:\n  mechanism, design and applications,'' {\\em Science China Information\n  Sciences}, vol.~64, nov 2020.\n\\end{thebibliography}\n\\end{frame}\n\\begin{frame}{Applications of blockchain: Cryptocurrency}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n   \n{\\footnotesize\n\\begin{thebibliography}{1}\n\\bibitem{Na08}\nS.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at\n  \\href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},\n  2008.\n\\end{thebibliography}  \n}\n\\end{column}\n\\begin{column}{0.5\\textwidth}  %%<--- here\n    \\begin{center}\n     \\includegraphics[width=0.5\\textwidth]{../../Figures/bitcoin-6284869_1920.png}\n     \\end{center}\n\\end{column}\n\\end{columns}\n\n\\begin{itemize}\n  \\item Transaction anonymity\n  \\item Banking and reliable currency in certain regions of the world\n  \\item Money Transfer worldwide (at low fare)\n  \\item No need for a thrusted third party\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Decentralized finance}\nDEFI creates new financial architecture\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\begin{itemize}\n\\item[+] Non custodial\n\\item[+] Anonymous\n\\item[+] Permisionless\n\\item[+] openly auditable\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth} \n\\begin{itemize}\n\\item[-] Unregulated\n\\item[-] Tax evasion\n\\item[-] Fraud\n\\item[-] Money laundering\n\\end{itemize} \n\\end{column}\n\\end{columns}\n\\vspace{0.5cm}\nExtends the Bitcoin promises to more complex financial operations\n\\begin{itemize}\n  \\item Collateralized lending\n  \\item Decentralized Exchange Platform\n  \\item Tokenized assets\n  \\item Fundraising vehicle (ICO, STO, ...)\n\\end{itemize}\n\\vspace{0.3cm}\n\\scriptsize\n\\begin{thebibliography}{1}\n\n\\bibitem{werner2021sok}\nS.~M. Werner, D.~Perez, L.~Gudgeon, A.~Klages-Mundt, D.~Harz, and W.~J.\n  Knottenbelt, ``Sok: Decentralized finance (defi),'' 2021.\n\n\\end{thebibliography}\n\n\\end{frame}\n\\begin{frame}{What's inside a block?}\nA block consists of \n\\begin{itemize}\n\\item a header \n\\item a list of \"transactions\" that represents the information recorded through the blockchain. \n\\end{itemize}\nThe header usually includes \n\\begin{itemize}\n\\item the date and time of creation of the block, \n\\item the block height which is the index inside the blockchain, \n\\item the hash of the block \n\\item the hash of the previous block. \n\\end{itemize}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Question]\nWhat is the hash of a block?\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Cryptographic Hash function}\n\\small\nA function that maps data of arbitratry size (message) to a bit array of fixed size (hash value)\n$$\nh:\\{0,1\\}^\\ast\\mapsto \\{0,1\\}^d. \n$$\nA good hash function is\n\\begin{itemize}\n\\item deterministic\n\\item quick to compute\n\\item One way\n\\begin{itemize}\n  \\scriptsize\n\\item[$\\hookrightarrow$] For a given hash value $\\overline{h}$ it is hard to find a message $m$ such that \n$$\nh(m) = \\overline{h}\n$$\n\\end{itemize}\n\\item Colision resistant \n\\begin{itemize}\n\\item[$\\hookrightarrow$] Impossible to find $m_1$ and $m_2$ such that \n$$\nh(m_1) = h(m_2)\n$$\n\\end{itemize}\n\\item Chaotic\n$$m_1\\approx m_2\\Rightarrow  h(m_1) \\neq h(m_2)$$\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{SHA-256}\nThe SHA-256 function which converts any message into a hash value of $256$ bits.\n\\begin{tcolorbox}[enhanced,drop shadow, title=Example]\nThe hexadecimal digest of the message\n$$\n\\texttt{Sweet home Alabama}\n$$\nis \n\\footnotesize\n$$\n\\texttt{50f3257a3d22a56247a8978fd2505e8cdd64e1cb06e52c941d09e234722dc275}\n$$\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Mining a block}\n\\begin{figure}[!ht]\n    \\includegraphics[width = \\textwidth]{../../Figures/block_not_mined.png}\n    \\captionsetup{width=0.8\\textwidth}\n    \\centering\n    \\caption{A block that has not been mined yet.}\n    \\label{fig:block_not_mined}\n\\end{figure}\n\\end{frame}\n\\begin{frame}{Mining a block}\nThe maximum value for a 256 bits number is\n$$\nT_\\text{max} = 2^{256}-1 \\approx 1.16e^{77}.\n$$\nMining consists in drawing at random a nonce \n$$\n\\text{Nonce} \\sim \\text{Unif}(\\{0,\\ldots, 2^{32}-1\\}),\n$$\nuntil \n$$\nh(\\text{Nonce}|\\text{Block info})<T,\n$$\nwhere $T$ is referred to as the target.\n\\begin{tcolorbox}[enhanced,drop shadow, title=Difficulty of the cryptopuzzle]\n$$\nD = \\frac{T_{\\max}}{T}.\n$$\n\\end{tcolorbox}\n\n\\end{frame}\n\\begin{frame}{Mining a block}\nIf we set the difficulty to $D = 2^4$ then the hexadecimal digest must start with at least $1$ leading $0$\n\\begin{figure}[!ht]\n    \\includegraphics[width = \\textwidth]{../../Figures/block_mined.png}\n    \\captionsetup{width=0.8\\textwidth}\n    \\centering\n    \\caption{A mined block with a hash value having on leading zero.}\n    \\label{fig:block_mined}\n\\end{figure}\nThe number of trial is geometrically distributed\n\\begin{itemize}\n\\item Exponential inter-block times\n\\item Lenght of the blockchain = Poisson process\n\\end{itemize}\n\\end{frame}\n\\begin{frame}{Bitcoin protocol}\n\\begin{itemize}\n  \\item One block every 10 minutes on average\n  \\item Depends on the hashrate of the network\n  \\item Difficulty adjustment every 2,016 blocks ($\\approx$ two weeks)\n  \\item Reward halving every 210,000 blocks\n\\end{itemize}\nCheck out \\url{https://www.bitcoinblockhalf.com/}\n\n\\end{frame}\n\\section{Double spending attack}\n\\begin{frame}{Double spending attack}\n\\scriptsize\n\\begin{enumerate}\n\\item Mary transfers 10 BTCs to John\n\\item The transaction is recorded in the public branch of the blockchain and John ships the good.\n\\item Mary transfers to herself the exact same BTCs\n\\item The malicious transaction is recorded into a private branch of the blockchain\n\\begin{itemize}\n  \\scriptsize\n\\item Mary has friends among the miners to help her out\n\\item The two chains are copycat up to the one transaction\n\\end{itemize}\n\\end{enumerate}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Fact (Bitcoin has only one rule)]\nThe longest chain is to be trusted\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Double spending in practice}\n\\scriptsize\nVendor are advised to wait for $\\alpha\\in\\mathbb{N}$ of confirmations so that the honest chain is ahead of the dishonest one.\n\\begin{center}\n\\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=1cm]\n% \\tikzstyle{block} = [rectangle, draw, fill=blue!20,\n%     text width=5em, text centered, rounded corners]\n\\tikzstyle{block}=[rectangle, fill=black,draw=black,thick,text=black,scale=0.6]\n\\tikzstyle{block}=[rectangle, fill=white,draw=black,thick,text=black,scale=0.8]\n\\tikzstyle{confirmed block}=[rectangle, fill=white,draw=blue,thick,text=black,scale=0.8]\n\\tikzstyle{bad block}=[rectangle, fill=white,draw=red,thick,text=black,scale=0.8]\n\\node[block]    (1)                     {\\tiny $\\text{M}\\rightarrow \\text{J}$};\n\\node[block]    (2)[right of=1]                     {};\n\\node[block]    (3)[right of=2]                     {};\n\\node[block]    (4)[right of=3]                     {};\n\\node[confirmed block]    (5)[right of=4]                     {};\n\n\\node[bad block]    (6)[below of=1]         {\\tiny $\\text{M}\\rightarrow \\text{M}$};\n\\node[block]    (7)[right of=6]         {};\n\\node[block]    (8)[right of=7]         {};\n\\path\n(1) edge[ left]     node{}     (2)\n(2) edge[ left]     node{}     (3)\n(3) edge[ left]     node{}     (4)\n(4) edge[ left]     node{}     (5)\n(6) edge[ left]     node{}     (7)\n(7) edge[ left]     node{}     (8);\n\n\\end{tikzpicture}\n\\end{center}\nIn the example, vendor awaits $\\alpha = 4$ confirmations, the honest chain is ahead of the dishonest one by $z = 2$ blocks.\n\\begin{tcolorbox}[enhanced,drop shadow, title=Fact (PoW is resistant to double spending)]\n\\begin{itemize}\n\\item Attacker does not own the majority of computing power \n\\item Suitable $\\alpha$ \n\\end{itemize}\nDouble spending is unlikely to succeed.\n\\end{tcolorbox}\n\\tiny\n\\begin{thebibliography}{1}\n\\bibitem{Na08}\nS.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at\n  \\href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},\n  2008.\n  \n\\end{thebibliography}\n\n\\end{frame}\n\\begin{frame}{Mathematical set up}\n\\footnotesize\nAssume that\n\\begin{itemize}\n\\item $R_0=z\\geq1$ (the honest chain is z blocks ahead)\n\\item at each time unit a block is created\n\\begin{itemize}\n  \\footnotesize\n\\item[$\\hookrightarrow$] in the honest chain with probability $p$\n\\item[$\\hookrightarrow$] in the dishonest chain with probability $q=1-p$\n\\end{itemize}\n\\end{itemize}\nThe process $(R_n)_{n\\geq0}$ is a random walk on $\\mathbb{Z}$ with\n$$R_n=z+Y_1+\\ldots+Y_n,$$\nwhere $Y_1,\\ldots,Y_n$ are the \\textbf{i.i.d.} steps of the random walk. \n\n\\end{frame}\n\\begin{frame}{Double spending rate of success}\n\\scriptsize\nDouble spending occurs at time\n$$\n\\tau_z=\\inf\\{n\\in \\mathbb{N}\\text{ ; }R_n=0\\}.\n$$\n\\begin{tikzpicture}\n  %Origin and axis\n  \\coordinate (O) at (0,0);\n  \\draw[->] (-1,0) -- (9,0) coordinate[label = {below:$n$}] (xmax);\n  \\draw[->] (0,-0.5) -- (0,3) coordinate[label = {left:$Z_n$}] (ymax);\n  %Lower linear boundary\n\n \n  %Stochastic process trajectory\n  \n  \\draw (0,0) node[tublue,left] {} node{};\n  \\draw[very thick,tublue,-] (0,1) -- (1,1) node[pos=0.5, above] {} ;\n  \\draw[very thick,dashed,tublue] (1,1) -- (1,1.5) node[pos=0.5, right] {};\n  \\draw[very thick,tublue,-] (1,1.5) -- (2,1.5) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,tublue] (2,1.5) -- (2,2) node[pos=0.5, right] {};\n  \\draw[very thick,tublue,-] (2,2) -- (3,2) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,tublue] (3,2) -- (3,1.5) node[pos=0.5, right] {};\n  \\draw[very thick,tublue,-] (3,1.5) -- (4,1.5)node[pos=0.5, above] {};\n  \\draw[very thick,dashed,tublue] (4,1.5) -- (4,1) node[pos=0.5, right] {};  \n  \\draw[very thick,tublue,-] (4,1) -- (5,1) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,tublue] (5,1) -- (5,0.5) node[pos=0.5, right] {};  \n  \\draw[very thick,tublue,-] (5,0.5) -- (6,0.5) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,tublue,-] (6,0.5) -- (6,1) node[pos=0.5, above] {};\n   \\draw[very thick,tublue,-] (6,1) -- (7,1) node[pos=0.5, above] {};\n    \\draw[very thick,dashed,tublue,-] (7,1) -- (7,0.5) node[pos=0.5, above] {};\n     \\draw[very thick,tublue,-] (7,0.5) -- (8,0.5) node[pos=0.5, above] {};\n     \\draw[very thick,dashed,tublue,-] (8,0.5) -- (8,0) node[pos=0.5, above] {};\n  %Jump Times\n  \\draw (1,0) node[black,below] {$1$} node{ \\color{black}$\\bullet$};\n  \\draw (2,0) node[black,below] {$2$} node{ \\color{black}$\\bullet$};\n  \\draw (3,0) node[black,below] {$3$} node{ \\color{black}$\\bullet$};\n  \\draw (4,0) node[black,below] {$4$} node{ \\color{black}$\\bullet$};\n  \\draw (5,0) node[black,below] {$5$} node{ \\color{black}$\\bullet$};\n  \\draw (6,0) node[black,below] {$6$} node{ \\color{black}$\\bullet$};\n  \\draw (7,0) node[black,below] {$7$} node{ \\color{black}$\\bullet$};\n  \\draw (8,0) node[black,below] {$8$} node{ \\color{black}$\\bullet$};\n  %Level of the counting process\n   \\draw (0,0) node[black,below left] {$0$} node{ \\color{black}$\\bullet$};\n   \\draw (0,0.5) node[black,left] {$1$} node{ \\color{black}$\\bullet$};\n   \\draw (0,1) node[black,left] {$z=2$} node{ \\color{black}$\\bullet$};\n   \\draw (0,1.5) node[black,left] {$3$} node{ \\color{black}$\\bullet$};\n   \\draw (0,2) node[black,left] {$4$} node{ \\color{black}$\\bullet$};\n   \\draw (0,2.5) node[black,left] {$5$} node{ \\color{black}$\\bullet$};\n\n  % %Aggregated Capital gains\n%  \\draw (0,1.5) node[blue,below right] {$\\mu_1$} node{ \\color{blue}$-$};\n%  \\draw (0,2.25) node[blue,left] {$\\mu_2$} node{ \\color{blue}$-$};\n%  \\draw (0,3.75) node[blue,left] {$\\mu_3$} node{ \\color{blue}$-$};\n  %Ruin time = First-crossing time time\n%  \\draw (5,0) node[black,above right] {$\\tau_u$} node{ \\color{black}$\\times$};\n%  \\draw[dotted,black] (0,3.28) -- (5,3.28);\n%  \\draw[dotted,black] (5,0) -- (5,3.28);\n\\end{tikzpicture}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Double spending theorem]\nIf $p>q$ then the double-spending probability is given by\n$$\n\\phi(z) = \\mathbb{P}(\\tau_z<\\infty)=\\left(\\frac{q}{p}\\right)^{z}.\n$$\n\\end{tcolorbox}\n\n\\end{frame}\n\\begin{frame}{Refinements of the double spending problem}\n\\scriptsize\nThe number of blocks $M$ found by the attacker until the honest miners find $\\alpha$ blocks is a negative binomial random variable with \\pmf\n$$\n\\mathbb{P}(M = m) = \\binom{\\alpha+m-1}{m}p^\\alpha q^m,\\text{ }m\\geq0.\n$$\nThe number of block that the honest chain is ahead of the dishonest one is given by \n$$\nZ= (\\alpha-M)_+.\n$$\nApplying the law of total probability yields the probability of successful double spending with\n$$\n\\mathbb{P}(\\text{Double Spending}) = \\mathbb{P}(M\\geq \\alpha) + \\sum_{m = 0}^{\\alpha - 1}\\binom{\\alpha+m-1}{m}q^{\\alpha} p^{m}.\n$$ \n\\tiny\n\n\n\\begin{thebibliography}{1}\n  \\bibitem{rosenfeld2014analysis}\nM.~Rosenfeld, ``Analysis of hashrate-based double spending,'' {\\em arXiv\n  preprint arXiv:1402.2009}, 2014.\n  \\bibitem{GRUNSPAN2018}\nC.~Grunspan and R.~Perez-Marco, ``Double spend race,'' {\\em\n  International Journal of Theoretical and Applied Finance}, vol.~21,\n  p.~1850053, dec 2018.\n\\end{thebibliography}\n\n\\end{frame}\n\\begin{frame}{Refinements of the double spending problem}\n\\scriptsize\nLet the length of honest and dishonest chain be driven by counting processes\n\\begin{itemize}\n\\item Honest chain $\\Rightarrow$ $z+N_t\\text{ , }t\\geq0$, where $z\\geq1$.\n\\item Malicious chain $\\Rightarrow$ $M_t\\text{ , }t\\geq0$\n\\item Study the distribution of the first-\\textit{rendez-vous} time\n$$\n\\tau_z=\\inf\\{t\\geq0\\text{ , } M_t=z+N_t\\}.\n$$\n\\end{itemize}\nIf $N_t\\sim\\text{Pois}(\\lambda t)$ and $M_t\\sim\\text{Pois}(\\mu t)$ such that $\\lambda>\\mu$ then \n$$\n\\phi(z) = \\left(\\frac{\\mu}{\\lambda}\\right)^z,\\text{ }z\\geq 0.\n$$\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Goffard2019}\nP.-O. Goffard, ``Fraud risk assessment within blockchain transactions,'' {\\em\n  Advances in Applied Probability}, vol.~51, pp.~443--467, jun 2019.\n\\newblock \\url{https://hal.archives-ouvertes.fr/hal-01716687v2}.\n\n\\bibitem{Bowden2020}\nR.~Bowden, H.~P. Keeler, A.~E. Krzesinski, and P.~G. Taylor, ``Modeling and\n  analysis of block arrival times in the bitcoin blockchain,'' {\\em Stochastic\n  Models}, vol.~36, pp.~602--637, jul 2020.\n\\end{thebibliography}\n\n\\end{frame}\n\n\\section{Insurance risk theory}\n\\begin{frame}{Cramer-Lunberg model}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\scriptsize\nThe financial reserves of an insurance company over time have the following dynamic\n\\begin{equation*}\nR_t = z +ct - \\sum_{i = 1}^{N_t}U_i\\text{, }t\\geq0,\n\\end{equation*}\nwhere \n\\begin{itemize}\n  \\item $z>0$ denotes the initial reserves\n  \\item $c$ is the premium rate\n  \\item $(N_t)_{t\\geq0}$ is a counting process that models the claim arrival \n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$]  Poisson process with intensity $\\lambda$\n  \\end{itemize}\n  \\item The $U_i$'s are the randomly sized compensations\n  \\begin{itemize}\n    \\scriptsize\n    \\item[$\\hookrightarrow$] non-negative, \\textbf{i.i.d.}\n  \\end{itemize}\n\\end{itemize}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{tikzpicture}\n  %Origin and axis\n  \\coordinate (O) at (0,0);\n  \\draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\\scriptsize$t$}] (xmax);\n  \\draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\\scriptsize$R_t$}] (ymax);\n   %Initial reserves\n  \\draw (0,2) node[black,left] {\\scriptsize$z$} node{};\n % % %Length of the honest chain\n  \\draw[thick, tublue,-] (0,2) -- (2,3) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (2,3) -- (2,1) node[pos=0.5, left] {\\scriptsize\\color{black}$U_1$};\n  \\draw[thick, tublue] (2,1) -- (3,1.5) node[pos=0.5, above] {};\n  \\draw[thick, dashed, tublue] (3,1.5) -- (3, 0.5) node[pos=0.5, left] {\\scriptsize\\color{black}$U_2$};\n  \\draw[thick, tublue] (3,0.5) -- (5, 1.5) node[pos=0.5, above] {};\n   \\draw[thick, dashed, tublue] (5,1.5) -- (5, -0.5) node[pos=0.5,above left] {\\scriptsize\\color{black}$U_3$};\n\n  %Block finding Times \n  \\draw (2,0) node[black,below] {\\scriptsize$T_1$} node{ \\color{black}$\\bullet$};\n  \\draw (3,0) node[black,below] {\\scriptsize$T_2$} node{ \\color{black}$\\bullet$};\n  \\draw (5,0) node[black,below left] {\\scriptsize$\\tau_z$} node{ \\color{black}$\\bullet$};\n\\end{tikzpicture}\n\\end{column}\n\\end{columns}\n\n\\end{frame}\n\\begin{frame}{Ruin probabilities}\n\\scriptsize\nDefine the ruin time as \n$$\n\\tau_z = \\inf\\{t\\geq0\\text{ ; }R_t <0\\}\n$$\nand the ruin probabilities as \n$$\n\\psi(z,t) = \\mathbb{P}(\\tau_z < t)\\text{ and }\\psi(z) = \\mathbb{P}(\\tau_z < \\infty)\n$$\nWe look for $z$ such that \n$$\n\\mathbb{P}(\\text{Ruin}) = \\alpha\\text{ (0.05)},\n$$\ngiven that \n$$\nc=(1+\\eta)\\lambda\\mathbb{E}(U),\n$$\nwith \n$$\\eta>0\\text{ (net profit condition)}$$  \notherwise \n$$\\psi(z)=1.$$\n\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Asmussen_2010}\nS.~Asmussen and H.~Albrecher, {\\em Ruin Probabilities}.\n\\newblock {WORLD} {SCIENTIFIC}, sep 2010.\n\n\\end{thebibliography}\n\n\\end{frame}\n\n\\begin{frame}{Ruin probability computation}\n\\scriptsize\nLet \n$$\nS_t = z - R_t,\\text{ }t\\geq0\n$$\n\\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Wald exponential martingale)]\nIf $(S_t)_{t\\geq0}$ is a L\\'evy process or a random walk then\n$$\n\\{\\exp\\left[\\theta S_t-t\\kappa(\\theta)\\right]\\text{ , }t\\geq0\\},\\text{ is a martingale,}\n$$\nwhere $\\kappa(\\theta)=\\log\\mathbb{E}\\left(e^{\\theta S_1}\\right)$.\n\\end{tcolorbox}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Representation of the ruin probability)]\n\nIf $S_t\\overset{\\textbf{a.s.}}{\\rightarrow} -\\infty$, and there exists $\\gamma>0$ such that $\\{e^{\\gamma S_t}\\text{ , }t\\geq0\\}$ is a martingale then\n$$\n\\mathbb{P}(\\tau_z<\\infty)=\\frac{e^{-\\gamma z}}{\\mathbb{E}\\left[e^{\\gamma \\xi(z)}|\\tau_z<\\infty\\right]},\n$$\nwhere $\\xi(z)=S_{\\tau_z}-z\\text{ denotes the deficit at ruin.}$\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Sketch of Proof}\n\\scriptsize\n\\begin{itemize}\n\\item Because of the net profit condition $S_t = \\sum_{i=1}^{N_t}U_i-ct\\rightarrow -\\infty$ as $t\\rightarrow\\infty$\n\\item $(S_t)_{t\\geq0}$ is a Lévy process, let $\\gamma$ be the (unique, positive) solution to\n$$\n\\kappa(\\theta) = 0\\text{ (Cramer-Lundberg equation)}.\n$$\n\\item  $(e^{\\gamma S_t})_{t\\geq0}$ is a Martingale then apply the Optional stopping theorem at $\\tau_z$.\n\n\\end{itemize}\n\\end{frame}\n\\section{Link to double spending}\n\\begin{frame}{Double spending in Satoshi's framework}\n\\scriptsize\n\\begin{itemize}\n\\item The risk reserve process is $R_t=z+Y_1+\\ldots+Y_t.$\n\\item The claim surplus process is $S_t=-(Y_1+\\ldots+Y_t).$\n\\item $\\kappa(\\theta)=0$ is equivalent to\n$$pe^{-\\theta}+qe^{\\theta}=1.$$\n\\begin{itemize}\n\\item[$\\hookrightarrow$]\\scriptsize $\\gamma=\\log(p/q).$\n\\end{itemize}\n\\item If $p>q$ then $S(t)\\rightarrow - \\infty$.\n\\item  $\\xi(z)=S_{\\tau_z}-z=0$ \\textbf{a.s}.\n\\end{itemize}\nThus,\n$$\\mathbb{P}(\\tau_z<\\infty)=\\left(\\frac{q}{p}\\right)^{z}.$$\n\\end{frame}\n\n\\begin{frame}{Double spending with Poisson processes}\n\\begin{columns}\n\\begin{column}{0.5\\textwidth}\n\\scriptsize\n\\begin{itemize}\n\\item Suppose that\n$$\nN_t\\sim\\text{Pois}(\\lambda t)\\text{ and }M_t\\sim\\text{Pois}(\\mu t)\n$$\nsuch that $\\lambda>\\mu$.\n\\item The risk reserve process is $R_t=z+N_t-M_t.$\n\\item The claim surplus process is $S_t=M_t-N_t.$\n\\end{itemize}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Fact]\nThe difference of two Poisson processes is not a Poisson process, However it is L\\'evy!\n\\end{tcolorbox}\n\\end{column}\n\\begin{column}{0.5\\textwidth}\n\\begin{tikzpicture}\n  %Origin and axis\n  \\coordinate (O) at (0,0);\n  \\draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {above:\\scriptsize$t$}] (xmax);\n  \\draw[->] (0,-0.5) -- (0,5) coordinate[label = {right:\\scriptsize$n$}] (ymax);\n %Length of the honest chain\n  \\draw[thick,tublue,-] (0,3) -- (2,3) node[pos=0.5, above] {} ;\n  \\draw[thick,tublue] (2,3) -- (2,4) node[pos=0.5, above] {};\n  \\draw[thick,tublue] (2,4) -- (5.5,4) node[pos=0.5, right] {};\n  % %Length of the Malicious chain\n  \\draw[very thick,dashed,red,-] (0,0) -- (0.75,0) node[pos=0.5, above] {} ;\n  \\draw[very thick,dashed,red] (0.75,0) -- (0.75,1) node[pos=0.5, right] {};\n  \\draw[very thick,dashed,red] (0.75,1) -- (1.25,1) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,red] (1.25,1) -- (1.25,2) node[pos=0.5, right] {};\n  \\draw[very thick,dashed,red] (1.25,2) -- (2.5,2) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,red] (2.5,2) -- (2.5,3) node[pos=0.5, right] {};\n  \\draw[very thick,dashed,red] (2.5,3) -- (5,3) node[pos=0.5, right] {};\n  \\draw[very thick,dashed,red] (5,3) -- (5,4) node[pos=0.5, above] {};\n  \\draw[very thick,dashed,red] (5,4) -- (5.5,4) node[pos=0.5, above] {};\n  %Jump Times of the malicious chain\n  \\draw (0.75,0) node[red,below] {\\scriptsize$S_1$} node{ \\color{red}$\\bullet$};\n  \\draw (1.25,0) node[red,below] {\\scriptsize$S_2$} node{ \\color{red}$\\bullet$};\n  \\draw (2.5,0) node[red,below] {\\scriptsize$S_3$} node{ \\color{red}$\\bullet$};\n  \\draw (5,0) node[black,below] {\\scriptsize$S_4=\\tau_z$} node{ \\color{black}$\\bullet$};\n  % %Jump Times of the honest chain\n  \\draw (2,0) node[tublue,below] {\\scriptsize$T_1$} node{ \\color{tublue}$\\bullet$};\n  % %Aggregated Capital gains\n  \\draw (0,1) node[black,left] {\\scriptsize$1$} node{ \\color{black}$-$};\n  \\draw (0,2) node[black,left] {\\scriptsize$2$} node{ \\color{black}$-$};\n  \\draw (0,3) node[black,left] {\\scriptsize$z$} node{};\n  \\draw (0,4) node[black,left] {\\scriptsize$4$} node{ \\color{black}$-$};\n  % %Ruin time = First-meeting time\n  % \\draw (7,0) node[black,below] {$\\tau_z$} node{ \\color{black}$\\times$};\n  % \\draw[dotted,black] (7,3) -- (7,0);\n\\end{tikzpicture}\n\\end{column}\n\\end{columns}\n\\end{frame}\n\\begin{frame}{Double spending with Poisson processes}\n\n\\begin{itemize}\n\\item $\\kappa(\\theta)=0$ is equivalent to\n$$\n\\mu e^{\\theta}+\\lambda e^{-\\theta}-(\\lambda+\\mu)=0.\n$$\n\n\\begin{itemize}\n\\item[$\\hookrightarrow$] $\\gamma=\\log(\\lambda/\\mu).$\n\\end{itemize}\n\\item If $\\lambda>\\mu$ then $S_t\\rightarrow - \\infty$.\n\\item $\\xi(z)=S_{\\tau_z}-z=0$ \\textbf{a.s}.\n\\end{itemize}\nThus\n$$\\mathbb{P}(\\tau_z<\\infty)=\\left(\\frac{\\mu}{\\lambda}\\right)^{z}.$$\n\n\\end{frame}\n\n\\begin{frame}{Double spending cost}\n\\scriptsize\nMining cryptocurrency in PoW equipped blockchain is energy consuming\n\\begin{itemize}\n\\item[$\\hookrightarrow$] Operational cost for miners\n\\end{itemize}\nPer time unit a miner pays\n$$\nc = \\pi_W\\cdot W\\cdot q,\n$$\nwhere \n\\begin{itemize}\n  \\item $\\pi_W$ is the electricty price per kWh\n  \\item $W$ is the consumption of the network \\url{https://cbeci.org/}\n  \\item  $q$ is the attacker's hashpower \n\\end{itemize}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Fact]\nThe cost of double spending is $c\\cdot \\tau_z$.\n\\end{tcolorbox}\n\\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (\\textbf{P.d.f.} of the double spending time)]\nIf $\\{N_t\\text{ , }t\\geq0\\}$ is a Poisson process then the \\textbf{p.d.f.} of $\\tau_z$ is given by\n\\begin{equation*}\nf_{\\tau_z}(t)=\\mathbb{E}\\left[\\frac{z}{z+N_t}f_{S_{N_t+z}}(t)\\right],\\text{ for }t\\geq0.\n\\end{equation*}\n\\end{tcolorbox}\n\\end{frame}\n\\begin{frame}{Sketch of the proof}\n\\scriptsize\nLet's condition upon the values of $N_t$,\n\\begin{itemize}\n  \\item if $N_t=0$ then \n  $$\\tau_z = S_z\\text{ and }f_{\\tau_z|N_t=0}(t) = f_{S_z}(t)$$\n  \\item If $N_t = n$ for $n\\geq 1$ then \n  $$\n  \\{\\tau_z = t\\} = \\bigcup_{k = 1}^n\\{T_k\\leq S_{z+k-1}\\}\\cup\\{S_{n+z} = t\\}\n  $$\nWe have \n\\begin{eqnarray*}\nf_{\\tau_z|N_t = n}(t) &=& \\mathbb{P}(U_{1:n}\\leq S_z/t,\\ldots,U_{n:n}\\leq S_{z+n-1}/t\\Big\\rvert S_{n+z}=t)f_{S_{n+z}}(t)\\\\\n&=&\\frac{z}{z+n}f_{S_{n+z}}(t).\n\\end{eqnarray*}\nThanks to the properties of the Abel-Gontcharov polynomials.\n\\end{itemize}\n\\tiny\n\\begin{thebibliography}{1}\n\n\\bibitem{Goffard2019}\nP.-O. Goffard, ``Fraud risk assessment within blockchain transactions,'' {\\em\n  Advances in Applied Probability}, vol.~51, pp.~443--467, jun 2019.\n\\newblock \\url{https://hal.archives-ouvertes.fr/hal-01716687v2}.\n\\bibitem{Grunspan2021}\nC.~Grunspan and R.~P{\\'{e}}rez-Marco, ``{ON} {PROFITABILITY} {OF} {NAKAMOTO}\n  {DOUBLE} {SPEND},'' {\\em Probability in the Engineering and Informational\n  Sciences}, pp.~1--15, feb 2021.\n\n\\bibitem{Brown2020}\nM.~Brown, E.~Peköz, and S.~Ross, ``{BLOCKCHAIN} {DOUBLE}-{SPEND} {ATTACK}\n  {DURATION},'' {\\em Probability in the Engineering and Informational\n  Sciences}, pp.~1--9, may 2020.\n\n\\bibitem{Jang2020}\nJ.~Jang and H.-N. Lee, ``Profitable double-spending attacks,'' {\\em Applied\n  Sciences}, vol.~10, p.~8477, nov 2020.\n\n\\end{thebibliography}\n\\end{frame}\n\\section{Conclusion}\n\\begin{frame}{Take home message}\nBlockchain is an emerging technologies with great research opportunities for researchers of many fields\n\\begin{itemize}\n  \\item Computer science\n  \\item Applied probability\n  \\item Statistics\n  \\item Economics\n  \\item Operations research\n\\end{itemize}\n\\end{frame}\n\\end{document}\n", "meta": {"hexsha": "87c3f90098231e92351db70bfba412c9c7c23737", "size": 31793, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/Seminar_DS/seminar.tex", "max_stars_repo_name": "LaGauffre/BLOCKASTICS", "max_stars_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/Seminar_DS/seminar.tex", "max_issues_repo_name": "LaGauffre/BLOCKASTICS", "max_issues_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/Seminar_DS/seminar.tex", "max_forks_repo_name": "LaGauffre/BLOCKASTICS", "max_forks_repo_head_hexsha": "4087304a4fb6fe55b5e8746315f524eddedc72e8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-21T08:20:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T08:20:38.000Z", "avg_line_length": 33.6790254237, "max_line_length": 171, "alphanum_fraction": 0.6765325701, "num_tokens": 11541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.4071407140193211}}
{"text": "\\documentclass[12pt]{amsart}\n\\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.\n\\usepackage{bsymb}\n\\usepackage{unitb}\n\\usepackage{calculational}\n\\usepackage{ulem}\n\\usepackage{hyperref}\n\\normalem\n\\geometry{a4paper} % or letter or a5paper or ... etc\n% \\geometry{landscape} % rotated page geometry\n\n% See the ``Article customise'' template for some common customisations\n\n\\title{}\n\\author{}\n\\date{} % delete this line to display the current date\n\n%%% BEGIN DOCUMENT\n\\setcounter{tocdepth}{4}\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\newcommand{\\G}{\\text{G}}\n\\renewcommand{\\H}{\\text{H}}\n\n\\section{Initial model}\n\n\\begin{context}{ctx0}\n\n\\newset{\\G}\n\n\\with{functions} \\with{predcalc}\n\\dummy{ x,s,t : \\pred[\\G] }\n\\operator{;}{ seq : Pair [\\pred[\\G], \\pred[\\G]] \\pfun \\pred[\\G] }\n% \\operator{\\pneg}{ pneg : \\G \\pfun \\G }\n% \\operator{\\por}{ por : Pair [\\G, \\G] \\pfun \\G }\n% \\operator{\\pand}{ pand : Pair [\\G, \\G] \\pfun \\G }\n% \\operator{\\pimplies}{ pimplies : Pair [\\G, \\G] \\pfun \\G }\n% \\operator{\\pequiv}{ pequiv : Pair [\\G, \\G] \\pfun \\G } \n% \\precedence{[[\\pequiv],[\\pimplies],[\\por,\\pand],[\\pneg],[;]]}\n\\precedence{[[;],[\\pneg],[\\por,\\pand],[\\pimplies],[\\pequiv]]}\n% \n\\constant{ one, F, E : \\pred [\\G] }\n\n\\axiom{axm0}{ \\qforall{x}{}{ \\ew{ x ; one \\1\\pimplies x } } }\n\\theorem{CC:10i}{ \\qforall{s}{}{ \\ew{ s ; \\pfalse \\pequiv s \\pand E } } }\n\n\\end{context}\n\n\\end{document}", "meta": {"hexsha": "7b76988a8cfd83084569684e89dd390d09f303a1", "size": 1402, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Tests/comp-calc.tex", "max_stars_repo_name": "literate-unitb/literate-unitb", "max_stars_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-07-27T11:05:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-20T14:53:33.000Z", "max_issues_repo_path": "Tests/comp-calc.tex", "max_issues_repo_name": "unitb/literate-unitb", "max_issues_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 32, "max_issues_repo_issues_event_min_datetime": "2017-06-25T03:53:02.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-25T04:28:38.000Z", "max_forks_repo_path": "Tests/comp-calc.tex", "max_forks_repo_name": "literate-unitb/literate-unitb", "max_forks_repo_head_hexsha": "0d843456dc103bb09babc5b12855435d2e10f534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9615384615, "max_line_length": 82, "alphanum_fraction": 0.6419400856, "num_tokens": 513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266736, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4071096076756834}}
{"text": "\\documentclass{article}\n\n% math\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\C}{\\mathbb{C}}\n\n% for double images\n\\usepackage{subcaption}\n\n% Used for img import\n\\usepackage{import}\n\\usepackage{pdfpages}\n\\usepackage{transparent}\n\\usepackage{xcolor}\n\n\\newcommand{\\incfig}[2][1]{%\n    \\def\\svgwidth{#1\\columnwidth}\n    \\import{./figures/}{#2.pdf_tex}\n}\n\n\\pdfsuppresswarningpagegroup=1\n\n\\title{Calculus and Optimization for Machine Learning}\n\\date{2021-07-27}\n\\author{Seara}\n\\pagenumbering{gobble}\n\n\\begin{document}\n\\maketitle\n\\newpage\n\\pagenumbering{arabic}\n\n\\section{Week 1}\n\n\\subsection{Numerical sets and mappings}\n\n\\paragraph{Set.}\nA {\\it set} (is commonly called non-definable and fundamental) is an entity, a {\\it collection} of some objects:\n\\begin{itemize}\n    \\item An object either belongs to the set or do not\n    \\item One object could be included in the set only one time\n    \\item There is {\\it no order} (even if it is trivial) on objects of the set\n\\end{itemize}\nSets are usually denoted by capital letters: $X, Y, A, B, R, ...$ The fact of belonging to the set is denoted as: $a \\in A$.\n\\\\\nAnother essential concept concerning sets is subsets. Basically, the subset is any set of (not necessarily all) elements of the given set. We consider primarily numerical sets:\n\\begin{itemize}\n    \\item Natural numbers $\\N= \\{1, 2, 3, 4, ...\\}$\n    \\item Integer numbers $\\Z = \\{0, 1, -1, 2, -2, ...\\}$\n    \\item Rational numbers $\\Q = \\{\\frac{m}{n} | m \\in Z, n \\in N\\}$\n    \\item Real numbers $\\R=\\{a_0, a_1, ...\\}$\n\\end{itemize}\n\n\\paragraph{Mapping.}\nAssume that we have two sets $X$ and $Y$. A mapping between them is, generally speaking, ordered realtion between elements of $X$ and $Y$. Consider two logic notations: quantifiers \"for all\" $\\forall$ and \"exists\" $\\exists$.\n\n\\paragraph{Axiomatic definition of real numbers.}\n\\begin{itemize}\n    \\item $x+y=y+x, y \\cdot x = x \\cdot y$ - the commutative rule\n    \\item $(x+y)+z = x + (y+z), (x \\cdot y) \\cdot z = x \\cdot (x \\cdot z)$ - associativity\n    \\item $(x+y) \\cdot z = x \\cdot z + y \\cdot z$ - distributivity\n    \\item Existence of two neutral elements 1 and 0: $a \\cdot 1 = a, a+0=a$\n    \\item Existence of the inverse elements (exept 0): $a + (-a)=0,a \\cdot a^{-1}=1$\n    \\item Non-triviality $0 \\neq 1$\n    \\item For any two real numbers one is able to say $a>b,a<b$ or $a=b$\n    \\item This order is transitive: if $a<b,b<c$, then $a<c$\n    \\item Completeness: Assume the we consider some section of our set into two non-intersecting sets: $ \\R = A \\cup B, A \\cap B = \\O$, such as any element $a \\in A$ is smaller than any element $b \\in B$. Then there is a pivot real number $c \\in \\R$ that $a \\leq c \\leq b$ for any $a$ and $b$ elements from the corresponding sets.\n\\end{itemize}\n\n\\paragraph{Functions.}\nConsider two sets $X$ and $Y$ and mapping $f: X \\mapsto Y$. This mapping (relation) called {\\it functional} (or a {\\it function}) if and only it associates each element of the \n$X$ set to exactly on element of the $Y$ set. $X$ set is called domain (set of arguments) and $Y$ set is called codomain (set of values).\n\\\\\nFunction graph is a cetrain curve on the plane: the set of all points $(x,f(x))$ for all $x$ belonging to the function's domain.\n\\\\\nDomain - $D(f)$\n\\\\\nCodomain - $E(f)$\n\\\\\nSupport - $supp(f) = \\{x \\in X : f(x) \\neq 0\\}$\n\\\\\nComposite function or composition - $g(f(x))$\n\\\\\nVertical shift - $y = f(x) + c$\n\\\\\nHorizontal shift - $y=f(x+C)$\n\\\\\nVertical contraction - $y=C \\cdot f(x)$\n\\\\\nHorizontal contraction - $y=f(C \\cdot x)$\n\\\\\nAbsolute value - $y=|f(x)|$\n\n\\subsection{Limits, sequences}\n\n\\paragraph{Limit.}\nLimit of the sequence - the real number that resembles our sequence the most as the element's number infinitely grows(approaches infinity). The notation: \n\\[\n\\lim_{n \\to \\infty} a_n = C\n\\]\n$\\forall \\varepsilon > 0: \\exists N \\in \\N \\; that \\; \\forall n \\in \\N, n \\geq N \\Rightarrow |a_n -C| < \\varepsilon$\n\\\\\nIf a sequence has the limit equal to 0, it is called {\\it infinitesimal}.\nПривет\n\\end{document} ", "meta": {"hexsha": "aff20d043851ac1d974f009e94edbb3f364e69c3", "size": 4126, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Courses/Trash/MathForDS[abandoned]/Calculus And Optimization For Machine Learning/calculus.tex", "max_stars_repo_name": "searayeah/sublime-snippets", "max_stars_repo_head_hexsha": "deff53a06948691cd5e5d7dcfa85515ddd8fab0b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Courses/Trash/MathForDS[abandoned]/Calculus And Optimization For Machine Learning/calculus.tex", "max_issues_repo_name": "searayeah/sublime-snippets", "max_issues_repo_head_hexsha": "deff53a06948691cd5e5d7dcfa85515ddd8fab0b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Courses/Trash/MathForDS[abandoned]/Calculus And Optimization For Machine Learning/calculus.tex", "max_forks_repo_name": "searayeah/sublime-snippets", "max_forks_repo_head_hexsha": "deff53a06948691cd5e5d7dcfa85515ddd8fab0b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5090909091, "max_line_length": 330, "alphanum_fraction": 0.6749878817, "num_tokens": 1338, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.4070623716343578}}
{"text": "\\section{Background estimation}\n\\label{sec:hmhzz_bkg}\n\nIn this analysis, 97\\% of total expected background events are from irreducible ZZ backgrounds, which includes about 86\\% quark-antiquark annihilation (\\qqZZ), 10\\% of gluon-induced production (\\ggZZ) and around 1\\% of EW vector boson scattering (\\qqZZ EW) contribution.\nFor \\qqZZ EW, although it has small contribution in total background events after analysis selection, it's important for VBF category with about 16\\% contribution.\n\nIn addition to irreducible backgrounds, events from \\Zjet and \\ttbar processes, represent as reducible backgrounds, contribute at a few percent level and can be measured using data driven method that will later be described briefly.\nAdditional background called `Others', including ttV and triple-V (VVV) processes, has tiny contribution and is estimated from MC simulation directly.\n\n\\subsection{Irreducible backgrounds}\nThe Irreducible backgrounds have events with four prompt leptons.\nThe normalization of two dominant backgrounds \\qqZZ and \\ggZZ are taken from data by statistical fit, and the normalization of small \\qqZZ EW background is taken directly from MC simulation.\n\nThe \\mfl shapes of all three background components are taken from MC samples and then parameterized by an empirical function for each of them in each category respectively.\nDetails of background modellings are illustrated as below:\n\nThe empirical function used for background parameterization is:\n\\begin{equation}\n    f(\\mfl) = C_0 H(m_{0} - \\mfl) f_{1}(\\mfl) + H(\\mfl - m_{0}) f_{2}(\\mfl),\n    \\label{eq:bkg_model}\n\\end{equation}\nwhere,\n\\begin{align*}\n    f_1(x) &= \\left( \\frac{x - a_4}{a_3} \\right)^{a_1 - 1} \\left( 1 + \\frac{x - a_4}{a_3} \\right)^{-a_1 - a_2}, \\\\\n    f_2(x) &= \\exp \\left[ b_0 \\left( \\frac{x - b_4}{b_3} \\right)^{b_1 - 1} \\left( 1 + \\frac{x - b_4}{b_3} \\right)^{-b_1 - b_2} \\right], \\\\\n    C_0    &= \\frac{f_{2} (m_0)} {f_{1} (m_0)}.\n    \\label{eq:bkg_model_full}\n\\end{align*}\n\nThe function consists of two parts, the first part $f_{1}$ describes the \\mfl spectrum in low mass region where both $Z$ bosons decay on-shell, while the second one $f_{2}$ covers distribution at high mass tail.\nThe transition between the low- and high- mass parts is presented in function~\\ref{eq:bkg_model} by the Heaviside step function $H(x)$ at the transition point $m_0$.\nThe $m_0$ is chosen to optimize the smoothness of the function, and practically $m_0 = 260~(350)~\\gev$ is used for \\qqZZ (\\ggZZ and \\qqZZ EW).\nBesides, the continuity of two functions at $m_0$ is ensured by the factor $C_0$ applied to $f_{1}$.\nThe coefficients $a_{i}$ in $f_{1}$ and $b_{i}$ in $f_{2}$ are shape parameters obtained by fitting to \\mfl distribution from each MC simulated sample.\n\nFigure~\\ref{fig:qqZZ_m4l_shape_all_cut_based} to ~\\ref{fig:qqZZEW_m4l_shape_all_cut_based} shows the fitting results of \\qqZZ, \\ggZZ, \\qqZZ EW backgrounds in four cut-based categories (ggF-CBA-enriched-2$e$2$\\mu$, ggF-CBA-enriched-4$e$, ggF-CBA-enriched-4$\\mu$ and VBF-CBA-enriched).\nFigure~\\ref{fig:qqZZ_m4l_shape_all_DNN} to ~\\ref{fig:qqZZEW_m4l_shape_all_DNN} shows the fitting results of those backgrounds in five MVA-based categories (ggF-MVA-high-2$e$2$\\mu$, ggF-MVA-high-4$e$, ggF-MVA-high-4$\\mu$, ggF-MVA-low and VBF-MVA-enriched).\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZ_ggF_4mu_190_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZ_ggF_4e_190_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZ_ggF_2mu2e_190_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZ_VBF_incl_190_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\qqZZ background samples for the $4\\mu$,\n    $4e$ and $2\\mu 2e$ final states in the ggF-CBA-enriched category, and the $4\\ell$ inclusive VBF-CBA-enriched category.\n    Cut-based categorization is used.} \n    \\label{fig:qqZZ_m4l_shape_all_cut_based}\n\\end{figure}\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_ggZZ_ggF_4mu_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_ggZZ_ggF_4e_185_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_ggZZ_ggF_2mu2e_185_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_ggZZ_VBF_incl_180_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\ggZZ background samples for the $4\\mu$,\n    $4e$ and $2\\mu 2e$ final states in the ggF-CBA-enriched category, and the $4\\ell$ inclusive VBF-CBA-enriched category. \n    Cut-based categorization is used.} \n    \\label{fig:ggZZ_m4l_shape_all_cut_based}\n\\end{figure}\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZEW_ggF_4mu_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZEW_ggF_4e_180_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZEW_ggF_2mu2e_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/cut_based/bkg_shape_qqZZEW_VBF_incl_180_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\qqZZ (EW) background samples for the\n    $4\\mu$, $4e$ and $2\\mu 2e$ final states in the ggF-CBA-enriched category, and the $4\\ell$ inclusive VBF-CBA-enriched category. \n    Cut-based categorization is used.} \n    \\label{fig:qqZZEW_m4l_shape_all_cut_based}\n\\end{figure}\n\n%===========================================================================================================================\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZ_ggF_4mu_190_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZ_ggF_4e_190_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZ_ggF_2mu2e_190_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZ_VBF_incl_190_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZ_rest_190_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\qqZZ background samples for the $4\\mu$,\n    $4e$ and $2\\mu 2e$ final states in the ggF-MVA-high category, the $4\\ell$ inclusive ggF-MVA-low category and VBF-MVA-enriched category.\n    DNN-based categorization is used.} \n    \\label{fig:qqZZ_m4l_shape_all_DNN}\n\\end{figure}\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_ggZZ_ggF_4mu_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_ggZZ_ggF_4e_185_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_ggZZ_ggF_2mu2e_185_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_ggZZ_VBF_incl_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_ggZZ_rest_190_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\ggZZ background samples for the $4\\mu$,\n    $4e$ and $2\\mu 2e$ final states in the ggF-MVA-high category, the $4\\ell$ inclusive ggF-MVA-low category and VBF-MVA-enriched category.\n    DNN-based categorization is used.} \n    \\label{fig:ggZZ_m4l_shape_all_DNN}\n\\end{figure}\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZEW_ggF_4mu_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZEW_ggF_4e_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZEW_ggF_2mu2e_180_to_2200_log.pdf} \\\\\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZEW_VBF_incl_180_to_2200_log.pdf}\n    \\includegraphics[width=0.32\\textwidth]{figures/HMHZZ/background/dnn/bkg_shape_qqZZEW_rest_180_to_2200_log.pdf}\n    \\caption{Distributions of the \\mfl invariant mass fit projections of the \\qqZZ (EW) background samples for the\n    $4\\mu$, $4e$ and $2\\mu 2e$ final states in the ggF-MVA-high category, the $4\\ell$ inclusive ggF-MVA-low category and VBF-MVA-enriched category.\n    DNN-based categorization is used.} \n    \\label{fig:qqZZEW_m4l_shape_all_DNN}\n\\end{figure}\n\n\\subsection{Reducible backgrounds}\n\nSimilar to section~\\ref{sec:background}, the reducible backgrounds include \\Zjet (consisting of both heavy- and light-flavour jets), top quark pair, and $WZ$ production, which contain fake and non-isolated leptons.\nThe simulations are not very robust in terms of the selection efficiencies.\nThus, the data-driven method is applied to estimated the normalization of those processes in different control regions (CRs).\nThe estimations in this analysis are performed separately for \\llmumu and \\llee final states, with slightly different approaches for ``muon'' and ``electron'' backgrounds.\n\nThe ``electron'' backgrounds mostly come from process of a $Z$ boson with light-flavour jets ($Z$+LF) misidentified as electrons.\nThe large contribution of ``muon'' backgrounds come from heavy-flavour jets produced in association with a $Z$ boson ($Z$+HF) or in the decays of top quark.\nThe estimations are done following the common H4l studies without a specific \\mfl range requirement~\\cite{PhysRevD.91.012006}, and then the corresponding fraction of event yield in $\\mfl > 200~\\gev$ is calculated from MC simulation.\n\n\\textbf{\\llmumu final states} \n\nThe normalizations of ``muon'' backgrounds are extracted from simultaneous fits of the leading lepton pair's invariant mass ($m_{12}$) in four orthogonal CRs:\n\\begin{itemize}\n\t\\item \\textbf{Inverted $d_{0}$ CR}: this CR is formed by inverting the $d_{0}$ selection for at least one lepton in subleading lepton pair while the leptons in leading pair are required to pass all standard selection.\nThis CR enhances $Z$+HF and \\ttbar as leptons from heavy-flavour hadronic decays are characterised by large d0.\n\t\\item \\textbf{$e\\mu+\\mu\\mu$ CR}: this CR is formed using an opposite-sign different-flavour dilepton in leading pair.\nIt aims to enhance \\ttbar background as the leading lepton pair cannot come from $Z$ boson decay.\n\t\\item \\textbf{Inverted isolation CR}: in this CR, leptons in leading pair are required to satisfy all standard analysis selection, but for leptons in subleading pair, they are required to pass $d_{0}$ selection but have at least one of them failing isolation selection.\nThis CR enhances the events from $Z$+LF processes while suppress $Z$+HF by $d_{0}$ cut.\n\t\\item \\textbf{Same-sign CR}: in this CR, the leptons in subleading pair are required to have same-charge, while the leading pair still passes standard selection.\nThis CR is not dominant by any specific background since all reducible backgrounds could have sizable contribution to it.\n\\end{itemize}\n\nThe fit results of normalizations are then propagated to signal region (SR) by applying transfer factors to account for the difference of selection efficiencies between SR and CRs.\nThe transfer factors are computed using $Z+\\mu$ MC samples.\n\n\\textbf{\\llee final states} \n\nThe ``electron'' backgrounds are estimated in $3\\ell+X$ CR, where $X$ denotes the lower \\pt electron in the subleading pair.\nThe selection and identification criterias for $X$ are relaxed , while other three leptons must satisfy the standard selection.\nIn this case, $X$ could be a light-flavour jet, a photon conversion or an electron from heavy-flavour hadron decay.\nMoreover, the subleading pair is required to have same charge dilepton to ensure the orthogonality to the signal region.\nThe normalization of backgrounds are obtained based on a fit to the number of hits in the innermost ID layer in CR,\nand the transfer factors are computed from $Z+e$ simulated sample.\n\nThe \\mfl shapes of reducible backgrounds are obtained from MC simulation in signal region, and then smoothed by an one-dimensional kernel estimation,\nwhich models the input data as a superposition of Gaussian kernels, one for each data point with contributing $1/N$ to total integral $N$~\\cite{Cranmer:2000du}.\nThe difference from using different smoothing strength ($\\rho$) in kernel estimation is taken into account as additional shape uncertainties for these reducible backgrounds.\n", "meta": {"hexsha": "8e6d2d5124dd0e84117b345a89d620378e7183c3", "size": 12951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/HMHZZ/bkg.tex", "max_stars_repo_name": "zhuhel/PhDthesis", "max_stars_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/HMHZZ/bkg.tex", "max_issues_repo_name": "zhuhel/PhDthesis", "max_issues_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/HMHZZ/bkg.tex", "max_forks_repo_name": "zhuhel/PhDthesis", "max_forks_repo_head_hexsha": "55ec32affb5c105143798989d78043467c88da8e", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.5548387097, "max_line_length": 283, "alphanum_fraction": 0.7743031426, "num_tokens": 3804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.5312093733737562, "lm_q1q2_score": 0.4070623716343577}}
{"text": "\\documentclass{article}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{tikz}\n\\usepackage[all]{xy}\n\\usetikzlibrary{positioning,chains,fit,shapes,calc}\n\n\\begin{document}\n\n\\title{Homework 3}\n\\author{Josh Cai}\n\n\\maketitle\n\\section*{Section 9.5}\n\n\n\n\\textbf{30a)} The equivalence class of 010 is $[010]$, or all binary strings of 3 or more bits that start with 010.\n\n\\noindent\\textbf{30d)}  The equivalence class of 01010101 is [010], or all binary strings of 3 or more bits that start with 010.\n\\\\\\\\\n\\noindent\\textbf{34b)} The equivalence class of 1011 is [1011], which consists of only the element 1011.\n\n\\noindent\\textbf{34c)}  The equivalence class of 11111 is [11111], or all binary strings of 5 or more bits that start with 11111.\n\\\\\\\\\n\\noindent\\textbf{36a)} The congruence class $[4]_2$ is all the even numbers.\n\n\\noindent\\textbf{36b)}  The congruence class $[4]_3$ is all numbers with remainder 1 after dividing by 3.\n\n\\noindent\\textbf{36c)} The congruence class $[4]_6$ is all numbers with remainder 4 after dividing by 6.\n\n\\noindent\\textbf{36d)}  The congruence class $[4]_8$ is all numbers with remainder 4 after dividing by 8.\n\\\\\\\\\n\\noindent\\textbf{42a)} Is a partition because has each of the elements of ${-3,-2,-1,0,1,2,3}$ in the subsets and each element only occurs once within all subsets.\n\n\\noindent\\textbf{42d)}  Is not a partition because $0$ is not in the subsets.\n\\\\\\\\\n\\noindent\\textbf{44a)} Is a partition because every integer is either odd or even, so and no integer can be both odd and even.\n\n\\noindent\\textbf{44b)}  Is not a partition because zero is not in either of the subsets of the partition.\n\n\\noindent\\textbf{44e)}  Is not a partition because 2 is not divisible by 3 and is also even, and no element can exist in more than one subset of the partition.\n\\\\\\\\\n\n\\noindent\\textbf{46c)} Is not a partition because boundary points are contained within two subsets. \n\n\\noindent\\textbf{46d)}  Is not a partition because the boundary points are not in any subsets.\n\n\\noindent\\textbf{46e)}  Is a partition because every number exists in one and only one subset. The collection of subsets is the set of real numbers because $k$ is all integers.\n\\\\\\\\\n\\noindent\\textbf{48b)} \\{(a,a),(b,b),(c,c),(c,d),(d,d),(d,c),(e,e),(e,f),(f,e),(f,f),(g,g)\\}\n\n\\noindent\\textbf{48d)}  \\{(a,a),(a,c),(a,e),(a,g),(c,a),(c,c),(c,e),(c,g),(e,a),(e,c),(e,e),(e,g),(g,a), \\\\(g,c),(g,e),(g,g),(b,b),(b,d),(d,b),(d,d),(f,f)\\}\n\\\\\\\\\n\\noindent\\textbf{56a)} If $R_1$ and $R_2$ are equivalence relations on $S$, then $R_1$ and $R_2$ are both reflexive, and therefore the union of the relations would be reflexive. $R_1$ and $R_2$ are both symmetric, if $(a,b)$ was in $R_1 \\cup R_2$, then $(a,b)$ was in either $R_1, R_2$, or both. If it was in either $R_1$ or $R_2$, $(b,a)$ must exist in $R_1 \\cup R_2$ since $(b,a)$ also existed in the relation that $R_1$ existed in. $R_1 \\cup R_2$ is not necessarily transitive: if $(a,b)$ exists in $R_1$ and $(b,c)$ exists in $R_2$, $(a,c)$ need not necessarily exist. \n\n\\noindent\\textbf{56c)}  It is not reflexive because since $R_1$ and $R_2$ were both reflexive, none of those elements can exist in $R_1 \\oplus R_2$. It is symmetric because if $(a,b)$ existed in both sets, $(b,a)$ would exist in both sets, and neither would be in $R_1 \\oplus R_2$. If $(a,b)$ and $(b,a)$ existed in one set, then both would exist in $R_1 \\oplus R_2$. It is not necessarily transitive because both sets could have $(a,c)$ while one set has $(a,b)$ and another $(b,c)$. \n\\\\\\\\\n\\noindent\\textbf{60a)} $R$ is reflexive because $f(x)$ is trivially the same order as $f(x)$ (using the constant 1 for $C$ will show this). $R$ is symmetric because if $f = \\Theta(g)$ then there exists constants $C_1, C_2$ such that $|f(x)|\\le C_1|g(x)|$ and $|f(x)|\\ge C_1|g(x)|$. The constants $C_1^{-1}, C_2^{-1}$ will satisfy the same conditions for $g$, so $g = \\Theta(f)$. $R$ is transitive because if $f$ has the same order as $g$, and $g$ has the same order as $h$, then $f$ has the same order as $h$. \n\n\\noindent\\textbf{60b)} The equivalence class of $f(n) = n^2$ is all functions of degree 2. \n\\\\\\\\\n\\noindent\\textbf{Bonus a)} There are $2^5 = 32$ different equivalence relations. Since each has 2 equivalence classes, we observe that the second equivalence class is simply the complement of the first equivalence class. Therefore, we can count the number of subsets of the set. The number of subsets of a set is $2^{\\# of elements}$ because each element has the choice of being in the subset or not, and each choice is independent. However, we have overcounted with $2^6$, and we see that each subset is counted twice, once as a subset and the second as the complement of another subset. So we divide by 2, and get $2^5 = 32$ equivalence relations.\n\n\\noindent\\textbf{Bonus b)}  There are $\\binom{6}{2} = 15$ different equivalence relations. Since we have 5 equivalence classes, we know by Pigeonhole Principle one subset must have at least 2 elements. There cannot be a set with more than 2 elements, or there would be less than 5 equivalence classes. We see that the subset with 2 elements uniquely determines the equivalence relation, so we count all the different subsets of 2 elements in a set of 6 elements, which is just $\\binom{6}{2} = 6 \\times 5 / 2 = 15$.\n\n\\end{document}", "meta": {"hexsha": "305802a30538e3d88187e3f87f94ec3bf05d1b5a", "size": 5287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "discrete_math/hw3.tex", "max_stars_repo_name": "joshcai/math-hw", "max_stars_repo_head_hexsha": "f896f4d54aca2d6e8c7354f0dbd1c898f21e1f82", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "discrete_math/hw3.tex", "max_issues_repo_name": "joshcai/math-hw", "max_issues_repo_head_hexsha": "f896f4d54aca2d6e8c7354f0dbd1c898f21e1f82", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "discrete_math/hw3.tex", "max_forks_repo_name": "joshcai/math-hw", "max_forks_repo_head_hexsha": "f896f4d54aca2d6e8c7354f0dbd1c898f21e1f82", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 78.9104477612, "max_line_length": 649, "alphanum_fraction": 0.7106109325, "num_tokens": 1662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.4070623659639855}}
{"text": "\\section{Introduction}\n\nCore-collapse supernovae (CCSNe) are the explosions of massive stars that end their lives.\nThey are directly or indirectly responsible for the lion's share of elements heavier than oxygen and play important roles in many astrophysical phenomena, such as neutron star and black hole formation.\nFurthermore, these explosions occur at energies and densities relevant to address fundamental questions in nuclear, particle, and gravitational physics. \nA solid theoretical framework for the CCSN explosion mechanism may help answer important questions in fundamental physics~\\cite{janka_etal_2007}.\n\nOne essential part of the explosion mechanism is neutrino transport.\nNeutrino energy deposition is believed to be the major driver of CCSN explosions, except in peculiar cases where rapid rotation is present and magnetohydrodynamic effects may dominate (for reviews, see~\\cite{mezzacappa_2005,janka_2012,burrows_2013,muller_2016}).\nIdeally, neutrino transport would be modeled by the Boltzmann transport equation, which is an integro-partial-differential equation evolving a phase-space distribution function $f$~(e.g., see~\\cite{mezzacappaBruenn_1993a,mezzacappaBruenn_1993b,mezzacappaBruenn_1993c,mezzacappa_etal_2001,liebendoerfer_etal_2001,liebendoerfer_etal_2004,livne_etal_2004,liebendoerfer_etal_2005,ott_etal_2008,sumiyoshiYamada_2012,nagakura_etal_2014,sumiyoshi_etal_2014,nagakura_etal_2018} for studies of CCSN with Boltzmann transport in various approximate settings).\nSimulating the neutrino transport implies finding a solution of the Boltzmann equation for a specific domain and period, with acceptable accuracy.\n\nHowever, solving the Boltzmann transport equation with sufficient phase-space resolution and full weak interaction physics is at present too expensive.\nTo balance physical fidelity and computational expediency, an approximate method called the two-moment method has been adopted (e.g., see~\\cite{kuroda_etal_2016,roberts_etal_2016,just_etal_2018,vartanyan_etal_2018}).\nUsing the two-moment method, the evolved variables are the zeroth and first angular moments of the distribution function $f$ -- the spectral particle density $\\cJ$ and flux $\\bcH$, respectively.\nHowever, the equation of $\\bcH$ includes the second angular moment $\\bcK$.\nKnowledge of $\\bcK$ is needed to close the two-moment system.\nTherefore, a closure that gives $\\bcK$ consistent with $\\cJ$ and $\\bcH$ is needed.\nThe better the closure predicts $\\bcK$, the more accurate the two-moment method will be. \nThe two-moment method has been widely applied in the CCSN modeling community with different algebraic closures, such as the Minerbo~\\cite{minerbo_1978} closure (e.g.~{O'Connor} and {Couch}~\\cite{oConnorCouch_2018}, Pan and et al.~\\cite{pan_etal_2018}, Glas et al.~\\cite{glas_etal_2018}, and Just et al.~\\cite{just_etal_2018}) and the Levermore~\\cite{levermore_1984} closure (e.g.~Vartanyan et al.~\\cite{vartanyan_etal_2018}, Cabezon et al.~\\cite{cabezon_etal_2018}, and Kuroda et al.~\\cite{kuroda_etal_2016}). \n\nApplying the two-moment method does simplify the problem, but doesn't guarantee an affordable solution.\nTo be precise, how to discretize the continuous system of equatio\nns given by the two-moment method and solve the discretized system efficiently remains a question.\nIn fact, the time scales of neutrino interactions with the background (they can be $\\sim\\mathcal{O}(10^{-10})$~second) is short compared to the duration of the CCSN explosion ($\\sim\\mathcal{O}(1)$~second).  \nThis means that $\\sim\\mathcal{O}(10^{10})$ time steps could be needed for solving the system fully explicitly. \nOn the other hand, solving the moment equations fully implicitly requires inverting global band-structured matrices whose sizes depend on the phase-space discretization.\nSuch a global inversion is both expensive and unfriendly to parallelization.\nTo circumvent these challenges, implicit-explicit (IMEX) methods are taken into consideration.\nBy treating the transport terms in the two-moment equations explicitly and the collision terms implicitly, IMEX methods are subject only to a time step governed by the explicit transport terms, and the matrices to be inverted are block diagonal.\nTherefore, IMEX methods require far fewer time steps compared with a fully explicit method, and the computation for each step is easily parallelizable.\nFor the relativistic setting that we have, where the fluid and the neutrinos have comparable propagation speeds, IMEX methods can be efficient.\n\nTo model neutrino transport using a two-moment method, two (or at least two) things need to be chosen carefully: an algebraic closure based on Fermi-Dirac statistics for closing the two-moment equations and a convex-invariant, diffusion-accurate IMEX scheme to ensure a physical result.\nA convex-invariant scheme has the following property: if the solution $u^{n}\\in W$ and $W$ is a convex set, then $u^{n+1}\\in W$.\nSince the neutrino distribution function is bounded ($f\\in[0,1]$) by the Pauli exclusion principle, its moments as weighted integrals of a bounded function over the domain $\\omega\\in\\bbS^{2}$ are also bounded.\nWe call the moments satisfying the constraints due to Fermi-Dirac statistics \\textit{realizable moments} and the realizable $\\cJ$ and $\\bcH$ define a convex set~\\cite{chu_etal_2018}.\nThe algebraic closure should give a realizable $\\bcK$, and the well-posedness of the closure requires realizable $\\cJ$ and $\\bcH$.\nThis explains why an algebraic closure based on Fermi-Dirac statistics is needed.\nRealizability of $\\cJ$ and $\\bcH$ after each time step requires a convex-invariant IMEX scheme.\nSince the realizable moments form a convex set, it is possible to construct a realizability-preserving method using a convex-invariant IMEX scheme for two-moment neutrino transport.\nIn addition, the physics of neutrino transport in CCSNe requires the IMEX scheme to be diffusion-accurate.\n\nThe study of moment realizability and realizability-preserving methods with diffusion-accurate IMEX schemes motivates this work.\nGottlieb et al.~\\cite{gottlieb_etal_2001} showed that standard strong-stability-preserving IMEX schemes cannot have an order higher than first without a restricted time step.\nOne way to obtain the second-order (or higher-order) accuracy is to add some correction steps after the standard step~\\cite{huangShu_2017,hu_etal_2018}.\nUnfortunately, the correction steps can deteriorate the accuracy of the IMEX scheme in the diffusion limit or restrict the time step.\nTo keep things simple, we focus on IMEX schemes without correction steps and require them to be high-order (second or higher order) in the streaming limit and diffusion-accurate.\nWe call these IMEX schemes \\textit{PD-ARS}.\n\n\\texttt{thornado} is our toolkit for high-order neutrino-radiation hydrodynamics based on high-order Runge-Kutta Discontinuous Galerkin (RKDG) methods.\nIt is being developed at the University of Tennessee, Knoxville and Oak Ridge National Laboratory.\nIt currently includes solvers for the Euler equations for fluid dynamics and the two-moment approximation of the radiative transfer equation~\\cite{endeve_etal_2018}.\nIn this paper, we focus on the transport methods in \\texttt{thornado} with emphasis on IMEX.\n\nThis paper is organized as follows: Section~\\ref{se:Two-MomentModel} discusses the mathematical model, algebraic closures, and the constraints on the moments and algebraic closures imposed by Fermi-Dirac statistics;\nSection~\\ref{se:SpatialDiscretization} gives a first-order finite-volume spatial discretization and shows how the spatial discretization preserves constraints in an IMEX step;\nSection~\\ref{se:TimeIntegration} discusses how to use convex combination to construct two PD-ARS schemes, one with second-order accuracy in the streaming limit and the other with third-order accuracy in the same limit;\nSection~\\ref{se:NumericalTests} presents the results of the numerical tests, which demonstrate the properties of the PD-ARS schemes; Section~\\ref{se:Summary} summarizes the achievements of this paper and discusses future work.", "meta": {"hexsha": "a5b2b0f03c6c9c0c74b2df8350c4c200c22eec9e", "size": 8078, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/Astronum_2018/sections/intro.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/Astronum_2018/sections/intro.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/Astronum_2018/sections/intro.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 136.9152542373, "max_line_length": 548, "alphanum_fraction": 0.815177024, "num_tokens": 1950, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.40704759541687335}}
{"text": "\\chapter{Funcoidal groups}\n\n\\begin{rem}\n  \\fxnote{Move this into the book.}\n  If $\\mu$ and $\\nu$ are cocomplete endofuncoids, then we can describe $f \\in\n  \\continuous (\\mu,\\nu)$ without using filters by the formulas:\n  \\begin{enumerate}\n    \\item $\\rsupfun{f} \\langle \\mu \\rangle^{\\ast} X \\sqsubseteq\n    \\supfun{\\nu}^{\\ast} \\rsupfun{f} X$ (for every set $X$\n    in $\\subsets \\Ob \\mu$)\n    \n    \\item $\\langle \\mu \\rangle^{\\ast} X \\sqsubseteq \\langle f^{- 1}\n    \\rangle^{\\ast} \\supfun{\\nu}^{\\ast} \\rsupfun{f} X$ (for\n    every set $X$ in $\\subsets \\Ob \\mu$)\n    \n    \\item $\\rsupfun{f} \\langle \\mu \\rangle^{\\ast} \\langle f^{- 1}\n    \\rangle^{\\ast} Y \\sqsubseteq \\supfun{\\nu}^{\\ast} Y$ (for every set\n    $Y$ in $\\subsets \\Ob \\nu$)\n  \\end{enumerate}\n\\end{rem}\n\nFuncoidal groups are modeled after topological groups (see Wikipedia)\nand are their generalization.\n\n\\begin{defn}\n  \\emph{Funcoidal group} is a group $G$ together with endofuncoid $\\mu$ on\n  $\\Ob G$ such that\n  \\begin{enumerate}\n    \\item $(y \\cdot) \\in \\mathrm{C} (\\mu ; \\mu)$ for every $y \\in G$;\n    \n    \\item $(\\cdot x) \\in \\mathrm{C} (\\mu ; \\mu)$ for every $x \\in G$;\n    \n    \\item $(x \\mapsto x^{- 1}) \\in \\mathrm{C} (\\mu ; \\mu)$ for every $x \\in\n    G$.\n  \\end{enumerate}\n\\end{defn}\n\n\\begin{prop}\n  $t \\mapsto y \\cdot t \\cdot x$ and $t \\mapsto y \\cdot t^{- 1} \\cdot x$ are\n  continuous functions.\n\\end{prop}\n\n\\begin{proof}\n  As composition of continuous functions.\n\\end{proof}\n\n\\begin{obvious}\nComposition of functions of the forms $t \\mapsto y \\cdot t \\cdot x$ and $t\n\\mapsto y \\cdot t^{- 1} \\cdot x$ are also a function of one of these\nforms.\n\\end{obvious}\n\nWhat is the purpose of the following (yet unproved) proposition? I don't know, but it looks curious.\n\n\\begin{prop}\n  Let $E$ be a composition of functions of a form\n  $\\rsupfun{\\mu}$, $\\langle y \\cdot\n  \\rangle^{\\ast}$, $\\langle \\cdot x \\rangle^{\\ast}$, $\\langle^{- 1}\n  \\rangle^{\\ast}$ (where $x$ and $y$ vary arbitrarily)\n  such that $\\mu$ is met in the composition at least once.\n  Let also either $\\mu = \\mu \\circ \\mu$ or $\\mu$ is met exactly once in the product.\n  There are such elements $x_0$, $y_0$ that either\n  \\begin{enumerate}\n  \\item $(t \\mapsto y_0 \\cdot t \\cdot x_0) \\circ \\langle \\mu \\rangle\n  \\sqsubseteq E \\sqsubseteq \\langle \\mu \\rangle \\circ (t \\mapsto y_0 \\cdot t\n  \\cdot x_0)$;\n  \n  \\item  $(t \\mapsto y_0 \\cdot t^{- 1} \\cdot x_0) \\circ \\langle \\mu \\rangle\n  \\sqsubseteq E \\sqsubseteq \\langle \\mu \\rangle \\circ (t \\mapsto y_0 \\cdot\n  t^{- 1} \\cdot x_0)$.\n  \\end{enumerate}\n\\end{prop}\n\n\\begin{proof}\n  Using continuity a few times we prove that $E \\sqsubseteq \\langle \\mu\n  \\rangle^{\\ast} \\circ \\ldots \\circ \\langle \\mu \\rangle^{\\ast} \\circ f_n \\circ\n  \\ldots \\circ f_1$ where $f_i$ are functions of the forms $t \\mapsto y \\cdot\n  t \\cdot x$ or $t \\mapsto y \\cdot t^{- 1} \\cdot x$ for $n \\in \\mathbb{N}$.\n  But $\\langle \\mu \\rangle^{\\ast} \\circ \\ldots \\circ \\langle \\mu\n  \\rangle^{\\ast} = \\langle \\mu \\rangle^{\\ast}$ by conditions and $f_n \\circ\n  \\ldots \\circ f_1$ is of the form $t \\mapsto y \\cdot t \\cdot x$ or $t \\mapsto\n  y \\cdot t^{- 1} \\cdot x$ by above proposition. $E \\sqsubseteq \\langle \\mu\n  \\rangle \\circ (t \\mapsto y_0 \\cdot t \\cdot x_0)$ or $E \\sqsubseteq \\langle\n  \\mu \\rangle \\circ (t \\mapsto y_0 \\cdot t^{- 1} \\cdot x_0)$\n  \n  The second inequalty is similar. Note that $x_0$ and $y_0$ are the same for\n  the first and for the second item.\n\\end{proof}\n\n$(G, \\mu)$ vs $(G, \\mu^{-1})$ are they isomorphic?\n\n\\fxnote{We can also define reloidal groups.}\n\n\\section{On ``Each regular paratopological group is completely regular'' article}\n\nIn this chapter I attempt to rewrite the paper~\\cite{2014arXiv1410.1504B} in more general setting of funcoids and reloids.\nI attempt to construct a ``royal road'' to finding proofs of statements of this paper and similar ones, what is\nimportant because we lose 60 years waiting for any proof.\n\n\\subsection{Definition of normality}\n\nBy definition (slightly generalizing the special case if $\\mu$ is a\nquasi-uniform space from~\\cite{2014arXiv1410.1504B})\na pair of an endo-reloid~$\\mu$ and a complete funcoid~$\\nu$ (playing role of a generalization of a topological space)\non a set $U$ is \\emph{normal} when\n\\[ \\rsupfun{\\nu^{-1}} A \\sqsubseteq \\rsupfun{\n{\\nu^{-1}}^{\\circ}} \\rsupfun{\\nu^{-1}} \\rsupfun{F} A \\] for every entourage $F \\in\n\\up \\mu$ of $\\mu$ and every set $A \\subseteq U$.\n\nNote that this is \\emph{not} the same as customary definition of normal topological spaces.\n\n\\begin{thm}\n  An endoreloid $\\mu$ is normal on endoreloid~$\\nu$ iff\n  \\[ \\nu \\circ \\nu^{-1} \\sqsubseteq\n  \\nu^{-1} \\circ (\\mathsf{FCD}) \\mu. \\]\n\\end{thm}\n\n\\begin{proof}\n  Equivalently transforming the criterion of normality (which should hold for\n  all $F \\in \\up \\mu$) using proposition~\\ref{get-rid-interior}:\n\n  $\\rsupfun{\\nu}\n  \\rsupfun{\\nu^{-1}} A \\sqsubseteq\n  \\rsupfun{\\nu^{-1}} \\rsupfun{F} A$.\n\n  Also note\n  \n  $\\bigsqcap^{\\mathscr{F}}_{F \\in \\up \\mu} \\rsupfun{ \\nu^{-1}\n  } \\rsupfun{F} A = \\text{(because funcoids preserve\n  filtered meets)} = \\rsupfun{ \\nu^{-1}\n  }  \\bigsqcap^{\\mathscr{F}}_{F \\in \\up \\mu} \\rsupfun{F} A =\n  \\rsupfun{ \\nu^{-1} }\n  \\rsupfun{ (\\mathsf{FCD}) \\mu } A$.\n\n  Thus the above is equivalent to\n  $\\rsupfun{\\nu}\n  \\rsupfun{\\nu^{-1}} A \\sqsubseteq\n  \\rsupfun{ \\nu^{-1} }\n  \\rsupfun{ (\\mathsf{FCD}) \\mu } A$.\n\n  And this is in turn equivalent to\n  \\[ \\nu \\circ \\nu^{-1} \\sqsubseteq\n  \\nu^{-1} \\circ (\\mathsf{FCD}) \\mu. \\]\n\\end{proof}\n\n\\begin{defn}\nAn endofuncoid~$\\mu$ is \\emph{normal} on endofuncoid~$\\nu$ when $\\nu \\circ \\nu^{-1} \\sqsubseteq \\nu^{-1} \\circ \\mu$.\n\\fxwarning{No need for $\\nu$ to be endomorphism.}\n\\end{defn}\n\n\\begin{obvious}\\label{norm-fcd-rld}\n~\n\\begin{enumerate}\n\\item Endoreloid~$\\mu$ is normal on endofuncoid~$\\nu$ iff endofuncoid~$\\tofcd\\mu$ is normal on endofuncoid~$\\nu$.\n\\item Endofuncoid~$\\mu$ is normal on endoreloid~$\\nu$ iff endofuncoid~$\\torldin\\mu$ is normal on endofuncoid~$\\nu$.\n\\end{enumerate}\n\\end{obvious}\n\n\\begin{cor}\nIf $\\nu$ is a symmetric endofuncoid and $\\mu\\sqsupseteq \\nu^{-1}$, then it is normal.\n\\end{cor}\n\n\\begin{cor} (generalization of proposition~1 in~\\cite{2014arXiv1410.1504B})\nIf $\\nu$ is a symmetric endofuncoid and $\\Compl\\mu\\sqsupseteq \\nu^{-1}$, then it is normal.\n\\end{cor}\n\n\\begin{defn}\nA funcoid~$\\nu$ is \\emph{normally reloidazable} iff there exist a reloid~$\\mu$ such that\n$(\\mu,\\nu)$ is normal and $\\nu=\\Compl\\tofcd\\mu$.\n\\end{defn}\n\n\\begin{defn}\nA funcoid~$\\nu$ is \\emph{normally quasi-uniformizable} iff there exist a quasi-uniform space (=~reflexive and transitive reloid)~$\\mu$ such that\n$(\\mu,\\nu)$ is normal and $\\nu=\\Compl\\tofcd\\mu$.\n\\end{defn}\n\n\\begin{prop}\nA funcoid~$\\nu$ is normally reloidazable iff there exist a funcoid~$\\mu$ such that\n$\\mu$ is normal on~$\\nu$ and $\\nu=\\Compl\\mu$.\n\\end{prop}\n\n\\begin{prop}\nA funcoid~$\\nu$ is normally quasi-uniformizable iff there exist a quasi-proximity space (=~reflexive and transitive funcoid)~$\\mu$ such that\n$\\mu$ is normal on~$\\nu$ and $\\nu=\\Compl\\mu$.\n\\end{prop}\n\n\\begin{proof}\nObvious~\\ref{norm-fcd-rld} and the fact that~$\\tofcd$ is an isomorphism between reflexive and transitive funcoids\nand reflexive and transitive reloids.\n\\end{proof}\n\nIn other words, it is normally reloidazable or normally quasi-uniformizable when\n\\[ (\\Compl\\mu)\\circ(\\Compl\\mu)^{-1}\\sqsubseteq(\\Compl\\mu)^{-1}\\circ\\mu \\]\nfor suitable~$\\mu$.\n\n\\subsection{Urysohn's lemma and friends}\n\nFor a detailed proof of Urysohn's lemma see also:\\\\\n\\url{http://homepage.math.uiowa.edu/~jsimon/COURSES/M132Fall07/UrysohnLemma_v5.pdf}\\\\\n\\url{https://proofwiki.org/wiki/Urysohn's_Lemma}\\\\\n\\url{http://planetmath.org/proofofurysohnslemma}\n\n\\url{https://en.wikipedia.org/wiki/Proximity_space} says that\n``The resulting topology is always completely regular. This can be proven by imitating the usual proofs of Urysohn's lemma, using the last property of proximal neighborhoods to create the infinite increasing chain used in proving the lemma.''\n\nBelow follows an alternative proof of Urysohn lemma.\n\\emph{The proof was based on a conjecture proved false, see example~\\bookref{fcd-comp-ent}!}\n\n\\begin{lem}\n  If $\\supfun{\\mu} \\mathcal{A} \\asymp \\mathcal{B}$ for a complete\n  funcoid $\\mu$ and $\\mathcal{A}$, $\\mathcal{B}$ are filters on relevant\n  sets, then there exists $U \\in \\up \\mu$ such that $\\supfun{U} \\mathcal{A} \\asymp \\mathcal{B}$.\n\\end{lem}\n\n\\begin{proof}\n  Prove that $\\setcond{ \\supfun{U} \\mathcal{A} }{\n  U \\in \\up \\mu }$ is a filter base. That it\n  is nonempty is obvious.\n  \n  Let $\\mathcal{X}, \\mathcal{Y} \\in \\setcond{ \\supfun{U} \\mathcal{A}\n  }{ U \\in \\up \\mu }$. Then\n  $\\mathcal{X} = \\supfun{U_{\\mathcal{X}}} \\mathcal{A}$, $Y = \\supfun{\n  U_{\\mathcal{Y}}} \\supfun{A}$. Because $\\mu$ is complete, we have\n  (proposition~\\bookref{up-f-filt}) $U_{\\mathcal{X}} \\sqcap U_{\\mathcal{Y}} \\in \\up\n  \\mu$. Thus $\\mathcal{X}, \\mathcal{Y} \\sqsupseteq \\supfun{\n  U_{\\mathcal{X}} \\sqcap U_{\\mathcal{Y}} } \\mathcal{A} \\in \\setcond{\n  \\supfun{U} \\mathcal{A} }{ U \\in \\up \\mu }$.\n  \n  Thus $\\supfun{\\mu} \\mathcal{A} \\asymp \\mathcal{B}\n  \\Leftrightarrow \\mathcal{B} \\sqcap \\supfun{\\mu} \\mathcal{A} =\n  \\bot \\Leftrightarrow \\exists U \\in \\up \\mu: \\mathcal{B} \\sqcap\n  \\supfun{U} \\mathcal{A} = \\bot \\Leftrightarrow \\exists U \\in \\up\n  \\mu: \\supfun{U} \\mathcal{A} \\asymp \\mathcal{B}$.\n\\end{proof}\n\n\\begin{cor}\\label{disj-mu}\n  If $\\supfun{\\mu} \\mathcal{A} \\asymp \\supfun{\\mu}\n  \\mathcal{B}$ for a complete funcoid $\\mu$ and $\\mathcal{A}$,\n  $\\mathcal{B}$ are filters on relevant sets, then there exists $U \\in\n  \\up \\mu$ such that $\\supfun{U} \\mathcal{A} \\asymp \\supfun{U} \\mathcal{B}$.\n\\end{cor}\n\n\\begin{proof}\n  Applying the lemma twice we can obtain $P, Q \\in \\up \\mu$\n  such that $\\supfun{P} \\mathcal{A} \\asymp \\supfun{Q} \\mathcal{B}$. But because\n  $\\mu$ is complete, we have $U = P \\sqcap Q \\in \\up \\mu$,\n  while obviously $\\supfun{U} \\mathcal{A} \\asymp \\supfun{U} \\mathcal{B}$.\n\\end{proof}\n\n\\begin{lem}\n  (assuming conjecture~\\bookref{fcd-comp-ent}) For every $U \\in \\up \\mu$ (where $\\mu$ is a $T_4$ topological space) such that\n  $\\neg \\left( A \\rsuprel{U \\circ U^{- 1}} B \\right)$ there is $W \\in\n  \\up \\mu$ such that $U \\circ U^{- 1} \\sqsupseteq W \\circ W^{- 1}\n  \\circ W \\circ W^{- 1}$. For it holds $\\neg \\left( A \\rsuprel{W \\circ W^{-\n  1}} B \\right)$.\n  We can assume that $\\rsupfun{W}X$ is open for every set~$X$.\n\\end{lem}\n\n\\begin{proof}\n  $U \\circ U^{- 1} \\in \\up (\\mu \\circ \\mu^{- 1}) \\subseteq\n  \\up (\\mu \\circ \\mu^{- 1} \\circ \\mu \\circ\n  \\mu^{- 1})$ (normality used). Thus by the conjecture there exists $W\n  \\in \\up \\mu$ such that $U \\circ U^{- 1} \\sqsupseteq W \\circ W^{-\n  1} \\circ W \\circ W^{- 1}$. $W \\circ W^{- 1} \\sqsubseteq U \\circ U^{- 1}$\n  thus $\\neg \\left( A \\rsuprel{W \\circ W^{- 1}} B \\right)$.\n  \n  To prove that $\\rsupfun{W}X$ is open for every set~$X$, replace every $\\rsupfun{W}\\{x\\}$\n  with an open neighborhood $E\\subseteq\\rsupfun{W}X$ of $\\rsupfun{\\mu}\\{x\\}$\n  (and note that union of open sets is open).\n  This new $W$ holds all necessary properties.\n\\end{proof}\n\n\\begin{lem}\n  (assuming conjecture~\\bookref{fcd-comp-ent}) For every $U \\in \\up \\mu$ (where $\\mu$ is a $T_4$ topological space) such that\n  $\\neg \\left( A \\rsuprel{U \\circ U^{- 1}} B \\right)$ there is $W \\in \\up\\mu$\n  such that $U \\circ U^{- 1} \\sqsupseteq \\mu^{-1} \\circ W \\circ W^{-1}\\circ W \\circ W^{- 1}$.\n  For it holds $\\neg \\left( A \\rsuprel{W \\circ W^{-\n  1}} B \\right)$.\n  We can assume that $\\rsupfun{W}X$ is open for every set~$X$.\n\\end{lem}\n\n\\begin{proof}\nApplying the previous lemma twice, we have some open~$W\\in\\up\\mu$ such that\n\\[ U\\circ U^{-1} \\sqsupseteq W \\circ W^{-1}\\circ W \\circ W^{- 1} \\circ W \\circ W^{-1}\\circ W \\circ W^{- 1} \\]\nand $\\neg \\left( A \\rsuprel{W \\circ W^{-1}} B \\right)$.\nFrom this easily follows that \\[ U \\circ U^{- 1} \\sqsupseteq \\mu^{-1} \\circ W \\circ W^{-1}\\circ W \\circ W^{- 1}. \\]\n\\end{proof}\n\nA modified proof of Urysohn's lemma follows. This proof is in part based on~\\cite{2014arXiv1410.1504B}.\n(I attempt to find common generalization of Urysohn's lemma and results from~\\cite{2014arXiv1410.1504B}).\n\n$\\mathbb{Q}_2 \\eqdef \\setcond{ k/2^n }{k, n \\in \\mathbb{N}, 0 < k < 2^n }$.\n\n\\begin{thm}\nUrysohn's lemma (see Wikipedia) for disjoint closed sets~$A$ and~$B$ and function~$f$ on a topological space~$\\mu$\n(considered as complete funcoid).\n\\end{thm}\n\n\\begin{proof}\n(assuming conjecture~\\bookref{fcd-comp-ent}) (used ProofWiki among other sources)\n\nBecause $A$ and $B$ are disjoint closed sets, we\nhave $\\rsupfun{\\mu} A \\asymp \\rsupfun{\\mu} B$. Thus by the corollary~\\ref{disj-mu} take $S_0 \\in \\up\n\\mu$ and $\\neg \\left( A \\rsuprel{S_0 \\circ S_0^{- 1}} B\n\\right)$.\n\nWe have $\\mu \\circ \\mu^{- 1} \\circ \\mu \\circ \\mu^{- 1}\n\\sqsubseteq \\mu \\circ \\mu^{- 1}$ that is $\\up (\\mu\n\\circ \\mu^{- 1} \\circ \\mu \\circ \\mu^{- 1}) \\supseteq\n\\up (\\mu \\circ \\mu^{- 1})$.\n\nLet's prove by induction: There is a sequence $S$ of binary relations starting\nwith $S_0$ such that $\\neg \\left( A \\rsuprel{S_i \\circ S_i^{- 1}} B\n\\right)$ and $S_i \\circ S_i^{- 1} \\sqsupseteq \\mu^{-1} \\circ S_{i + 1} \\circ S_{i + 1}^{- 1}\n\\circ S_{i + 1} \\circ S_{i + 1}^{- 1}$. It directly follows from the lemma\n(and uses the conjecture).\n\nDenote $U_i = S_{i + 1} \\circ S_{i + 1}^{- 1}$. We have $U_i \\sqsupseteq \\mu^{-1} \\circ U_{i +\n1} \\circ U_{i + 1}$ and $\\neg \\left( A \\rsuprel{U_i} B \\right)$.\n\nBy reflexivity of~$\\mu$ we have $U_{i+1} \\subseteq U_{i+1}\\circ U_{i+1} \\subseteq U_i$.\n\nDefine fractional degree of $U$: $U^r \\eqdef U_1^{r_1} \\circ\n\\ldots \\circ U_{l_r}^{r_{l_r}}$ for every $r \\in \\mathbb{Q}_2$ where $r_1\n\\ldots r_{l_r}$ is the binary expansion of $r$.\n\nProve $U_r\\subseteq U_0$. It is enough to prove\n$U_0 \\supseteq U_1 \\circ \\ldots \\circ U_{l_r}$. It follows from $U_2 \\circ\n\\ldots \\circ U_{l_r} \\subseteq U_1$, $U_3 \\circ \\ldots \\circ U_{l_r} \\subseteq\nU_2$, \\dots, $U_{l_r} \\subseteq U_{l_r - 1}$ what was shown above.\n\nLet's prove: For each $p,q\\in\\mathbb{Q}_2$ such that $p<q$ we have $\\mu^{-1}\\circ U^p\\sqsubseteq U^q$.\nWe can assume binary expansion of~$p$ and~$q$ be the same length~$c$ (add zeros at the end of the shorter one).\nNow it is enough to prove\n\\[ U_k\\circ U_{k+1}^{q_{k+1}}\\circ\\dots\\circ U_c^{q_c}\\sqsupseteq\\mu^{-1}\\circ U_{k+1}^{p_{k+1}}\\circ U_{k+2}^{p_{k+2}}\\circ\\dots\\circ U_c^{p_c}. \\]\nBut for this it's enough\n\\[ U_k\\sqsupseteq\\mu^{-1}\\circ U_{k+1}\\circ U_{k+2}\\circ\\dots\\circ U_c \\]\nwhat can be easily proved by induction:\nIf $k=c$ then it takes the form $U_k\\sqsupseteq\\mu^{-1}$\nwhat is obvious.\nSuppose it holds for~$k$. Then $U_{k-1}\\sqsupseteq\\mu^{-1}\\circ U_k\\circ U_k\\sqsupseteq\n\\mu^{-1}\\circ U_k\\circ \\mu^{-1}\\circ U_{k+1}\\circ U_{k+2}\\circ\\dots\\circ U_c\\sqsupseteq\n\\mu^{-1}\\circ U_k\\circ U_{k+1}\\circ U_{k+2}\\circ\\dots\\circ U_c$, that is it holds\nfor all natural $k\\leq c$.\n\nIt is easy to prove that $\\rsupfun{U^r}X$ is open for every set~$X$.\n\nWe have $\\rsupfun{\\mu^{-1}}\\rsupfun{U^p}X\\sqsubseteq\\rsupfun{U^q}X$.\n\n\\[ f (z) \\eqdef \\inf \\left( \\{ 1 \\} \\cup \\setcond{ q \\in\n   \\mathbb{Q}_2 }{ z \\in \\rsupfun{U^q}\n   A } \\right). \\]\n$f$ is properly defined because $\\{ 1 \\} \\cup \\setcond{ q \\in \\mathbb{Q}_2\n}{ z \\in \\rsupfun{U^q} A }$ is\nnonempty and bounded.\n\nIf $z \\in A$ then $z \\in \\rsupfun{U^q} A$ for every $q \\in\n\\mathbb{Q}_2$, thus $f (z) = 0$, because obviously $U^q \\sqsupseteq 1$.\n\nIf $z \\in B$ then $z \\notin \\rsupfun{U^q} A$ for every $q \\in\n\\mathbb{Q}_2$, thus $f (z) = 1$, because $U^q \\sqsubseteq U_0$.\n\nIt remains to prove that $f$ is continuous.\n\nLet $D (x) = \\{ 1 \\} \\cup \\setcond{ q \\in \\mathbb{Q}_2 }{\nz \\in \\rsupfun{U^q} A }$.\n\nTo show that f is continuous, we first prove two smaller results:\n\n(a) $x\\in\\rsupfun{\\mu^{-1}}\\rsupfun{U^r}A \\Rightarrow f(x)\\leq r$.\n\nWe have $x\\in\\rsupfun{\\mu^{-1}}\\rsupfun{U^r}A \\Rightarrow \\forall s>r:x\\in\\rsupfun{U^s}A$,\nso $D(x)$ contains all rationals greater than $r$. Thus $f(x)\\leq r$ by definition of~$f$.\n\n(b) $x\\notin\\rsupfun{U^r}A \\Rightarrow f(x)\\geq r$.\n\nWe have $x\\notin\\rsupfun{U^r}A \\Rightarrow \\forall s<r:x\\notin\\rsupfun{U^s}A$.\nSo $D(x)$ contains no rational less than $r$. Thus $f(x)\\geq r$.\n\nLet $x_0\\in S$ and let $]c;d[$ be an open real interval containing $f(x)$.\nWe will find a neighborhood $T$ of $x_0$ such that $\\rsupfun{f}T\\subseteq]c;d[$.\n\nChoose $p,q\\in\\mathbb{Q}$ such that $c < p < f(x_0) < q < d$. Let $T=\\rsupfun{U^q}A\\setminus\\rsupfun{\\mu^{-1}}\\rsupfun{U^p}A$.\n\nThen since $f(x_0)<q$, we have that (b) implies vacuously that $x\\in\\rsupfun{U^q}A$.\n\nSince $f(x_0)>p$, (a) implies $x_0\\notin\\rsupfun{U^p}A$.\n\nHence $x_0\\in T$. Then $T$ is a neighborhood of~$x_0$ because $T$ is open.\n\nFinally, let $x\\in T$.\n\nThen $x\\in\\rsupfun{U^q}A\\subseteq\\rsupfun{\\mu^{-1}}\\rsupfun{U^q}A$. So $f(x)\\leq q$ by~(a).\n\nAlso $x\\notin\\rsupfun{\\mu^{-1}}\\rsupfun{U^p}A$, so $x\\notin\\rsupfun{U^p}A$ and $f(x)\\geq p$ by~(b).\n\nThus: $f(x)\\in[p;q]\\subseteq]c;d[$.\n\nTherefore $f$ is continuous.\n\n\\begin{grayed}\nClaim A: $f (x) > q \\Rightarrow x \\notin \\langle \\mu^{- 1}\n\\rangle^{\\ast} \\rsupfun{U^q} A$\n\nClaim B: $f (x) < q \\Rightarrow x \\in \\rsupfun{U^q} A$\n\nProof of claim A: If $f (x) > q$ then then there must be some gap between $q$\nand $D (x)$; in particular, there exists some $q'$ such that $q < q' < f (x)$.\nBut $q' < f (x) \\Rightarrow x \\notin \\rsupfun{U^q} A \\Rightarrow x\n\\notin \\rsupfun{\\mu^{- 1}} \\rsupfun{U^q} A$ (using that $\\rsupfun{U^r}X$ is open).\n\nProof of claim B: If $f (x) < q$ then there exists $q' \\in D (x)$ such that $f\n(x) < q' < q$, in which case $q \\in D (x)$, so $x \\in \\langle U^q\n\\rangle^{\\ast} A$.\n\nTo show that $f$ is continuous, it's enough to prove that preimages of $] a ;\n1]$ and $[0 ; a [$ are open.\n\nSuppose $f (x) \\in] a ; 1]$. Pick some $q$ with $a < q < f (x)$. We claim that\nthe open set $W = X \\setminus \\rsupfun{f^{- 1}} \\langle U^q\n\\rangle^{\\ast} A$ is a neighborhood of $x$ that is mapped by $f$ into $] a ;\n1]$. First, by (A), $f (x) > q \\Rightarrow x \\in W$, so $W$ is a neighborhood\nof $x$. If $y$ is any point of $W$, then $f (y)$ must be $\\geq q > a$;\notherwise, if $f (y) < q$, then, by (B) $y \\in \\rsupfun{U^q} A\n\\subseteq \\rsupfun{f^{- 1}} \\rsupfun{U^q} A$.\n\nSuppose $x \\in f^{- 1} [0 ; b [$ that is $f (x) < b$ and pick $q$ such that $f\n(x) < q < b$. By (B) $x \\in \\rsupfun{U^q} A$. We claim that the\nneighborhood $\\rsupfun{U^q} A$ is mapped by $f$ into $[0 ; b [$.\nSuppose $y$ is any point of $\\rsupfun{U^q} A$. Then $q \\in D\n(y)$, so $f (y) \\leq q < b$.\n\\end{grayed}\n\\end{proof}\n\n\\begin{thm}\n(from~\\cite{2014arXiv1410.1504B})\nIf $\\mu$ is a normal quasi-uniformity on a topological space~$\\nu$, then for any nonempty subset $A\\in\\Ob\\nu$\nand entourage~$U\\in\\up\\mu$ there exists a continuous function $f:\\Ob\\nu\\rightarrow[0;1]$ such that\n$A\\sqsubseteq\\rsupfun{f^{-1}}\\{0\\}\\sqsubseteq\\rsupfun{f^{-1}}[0;1[\\sqsubseteq\\rsupfun{{\\nu^{-1}}^\\circ}\\rsupfun{\\nu^{-1}}\\rsupfun{U}A$.\n\\end{thm}\n\n\\begin{proof}\nChoose inductively a sequence of entourages $(U_n)_{n = 0}^{\\infty}$ such that\n$U_0 = U$ and $U_{n + 1} \\circ U_{n + 1} \\sqsubseteq U_n$.\n\nDenote $l_r = \\max \\setcond{ n \\in \\mathbb{N} }{ r_n = 1 }$.\n\nDefine $U^r = U_{l_r}^{r_{l_r}} \\circ \\ldots \\circ U_1^{r_1}$\n\nProve $\\rsupfun{\\nu^{- 1}} \\rsupfun{U^q} A\n\\sqsubseteq \\rsupfun{\\nu^{- 1 \\circ}} \\rsupfun{\\nu^{- 1}}\n\\rsupfun{U^r} A$ for any $q < r$ in\n$\\mathbb{Q}_2$. \\fxnote{Can be easily rewritten with the formula $\\rsupfun{\\nu} \\rsupfun{\\nu^{- 1}} \\rsupfun{U^q} A\n\\sqsubseteq \\rsupfun{\\nu^{- 1}} \\rsupfun{U^r} A$\ninstead. It may extend to non-complete funcoids.}\n\nThere is such $l$ that $0 = q_l < r_l = 1$ and $q_i = r_i$ for all $i < l$.\n\nIt follows $l_q \\neq l \\leq l_r$.\n\nConsider variants:\n\\begin{description}\n  \\item[$l_q < l$] $\\rsupfun{\\nu^{- 1}} \\rsupfun{U^q} A \\sqsubseteq \\rsupfun{\\nu^{- 1}} \\left\\langle\n  U_{l_q} \\circ \\ldots \\circ U_1^{q_1q_{l_q}} \\right\\rangle^{\\ast} A = \\rsupfun{\\nu^{- 1}} \\left\\langle U_{l_q}^{r_{l_q}} \\circ \\ldots \\circ\n  U_1^{r_1} \\right\\rangle^{\\ast} A \\sqsubseteq \\langle \\nu^{- 1}\n  \\rangle^{\\ast} \\left\\langle U_{l - 1}^{r_{l - 1}} \\circ \\ldots \\circ\n  U_1^{r_1} \\right\\rangle^{\\ast} A \\sqsubseteq \\langle \\nu^{- 1 \\circ}\n  \\rangle^{\\ast} \\rsupfun{\\nu^{- 1}} \\langle U_l^{r_l} \\circ U_{l\n  - 1}^{r_{l - 1}} \\circ \\ldots \\circ U_1^{r_1} \\rangle^{\\ast} A = \\langle\n  \\nu^{- 1 \\circ} \\rangle^{\\ast} \\rsupfun{\\nu^{- 1}} \\langle U^r\n  \\rangle^{\\ast} A$ (use $U_l^{r_l} \\in \\up \\tofcd\n  \\mu$ by theorem 992).\n  \n  \\item[$l < l_q$] Inclusions $U_k \\circ U_k \\sqsubseteq U_{k - 1}$ for $l < k\n  \\leq l_q + 1$ guarantee that $U_{l_q + 1} \\circ U_{l_q} \\circ \\ldots \\circ\n  U_{l + 1} \\sqsubseteq U_l$ and then $\\rsupfun{\\nu^{- 1}}\n  \\rsupfun{U^q} A \\sqsubseteq \\rsupfun{\\nu^{- 1}}\n  \\left\\langle U_{l_q}^{q_{l_q}} \\circ \\ldots \\circ U_1^{q_1}\n  \\right\\rangle^{\\ast} A \\sqsubseteq \\rsupfun{\\nu^{- 1 \\circ}}\n  \\rsupfun{\\nu^{- 1}} \\left\\langle U_{l_q + 1}^{q_{l_q + 1}}\n  \\circ U_{l_q}^{q_{l_q}} \\circ \\ldots \\circ U_1^{q_1} \\right\\rangle^{\\ast} A\n  = \\rsupfun{\\nu^{- 1 \\circ}} \\rsupfun{\\nu^{- 1}}\n  \\left\\langle U_{l_q + 1} \\circ U_{l_q}^{q_{l_q}} \\circ \\ldots \\circ U_l^0\n  \\circ \\ldots \\circ U_1^{q_1} \\right\\rangle^{\\ast} A \\sqsubseteq \\left\\langle\n  \\nu^{- 1 \\circ} \\right\\rangle^{\\ast} \\rsupfun{\\nu^{- 1}}\n  \\langle U_l \\circ U_{l - 1}^{q_{l - 1}} \\circ \\ldots \\circ U_1^{q_1}\n  \\rangle^{\\ast} A \\sqsubseteq \\rsupfun{\\nu^{- 1 \\circ}} \\langle\n  \\nu^{- 1} \\rangle^{\\ast} \\left\\langle U_l^{r_l} \\circ U_{l - 1}^{r_{l - 1}}\n  \\circ \\ldots \\circ U_1^{r_1} \\right\\rangle^{\\ast} A \\sqsubseteq \\langle\n  \\nu^{- 1 \\circ} \\rangle^{\\ast} \\rsupfun{\\nu^{- 1}} \\left\\langle\n  U_{l_r}^{r_{l_r}} \\circ \\ldots \\circ U_1^{r_1} \\right\\rangle^{\\ast} A =\n  \\rsupfun{\\nu^{- 1 \\circ}} \\rsupfun{\\nu^{- 1}}\n  \\langle U_r \\rangle^{\\ast} A$.\n\\end{description}\nDefine $f$ by the formula $f (z) = \\inf \\left( \\{ 1 \\} \\cup \\setcond{ q \\in\n\\mathbb{Q}_2 }{ z \\in \\langle \\nu^{- 1}\n\\rangle^{\\ast} \\rsupfun{U^q} A } \\right)$.\n\nIt is clear?? that $A \\sqsubseteq \\rsupfun{f^{- 1}} \\{ 0 \\}$ and\n$\\rsupfun{f^{- 1}} [0 ; 1 [ \\sqsubseteq\n\\bigcup_{q \\in \\mathbb{Q}_2} \\rsupfun{\\nu^{- 1}} \\langle U^q\n\\rangle^{\\ast} A = \\bigcup_{r \\in \\mathbb{Q}_2} \\langle \\nu^{- 1 \\circ}\n\\rangle^{\\ast} \\rsupfun{\\nu^{- 1}} \\rsupfun{U^r} A\n\\sqsubseteq \\rsupfun{\\nu^{- 1 \\circ}} \\langle \\nu^{- 1}\n\\rangle^{\\ast} \\langle U_0 \\rangle^{\\ast} A$.\n\nTo prove that the map $f : X \\rightarrow [0, 1]$ is continuous, it suffices to\ncheck that for every real number $a \\in] 0 ; 1 [$ the sets $\\langle f^{- 1}\n\\rangle^{\\ast} [0 ; a [$ and $\\rsupfun{f^{- 1}}] a ; 1]$ are\nopen. This follows from the equalitites\n\n$\\rsupfun{f^{- 1}} [0 ; a [= \\bigcup_{\\mathbb{Q}_2 \\ni q < a}\n\\rsupfun{\\nu^{- 1 \\circ}} \\rsupfun{\\nu^{- 1}}\n\\rsupfun{U^q} A$ and $\\rsupfun{f^{- 1}}] a ; 1] =\n\\bigcup_{\\mathbb{Q}_2 \\ni r > a} (X \\setminus \\langle \\nu^{- 1}\n\\rangle^{\\ast} \\rsupfun{U^r} A)$.\n\\end{proof}\n\nHow the formulas for normal ($T_4$) topological spaces and normal quasi-uniformities are related?\nMaybe this works: Replacing $\\nu \\rightarrow \\mu \\circ \\mu^{- 1}$, $\\mu\n\\rightarrow 1$ makes $\\nu \\circ \\nu^{- 1} \\sqsubseteq \\nu^{- 1} \\circ\n\\tofcd \\mu \\rightarrow \\mu \\circ \\mu^{- 1}\n\\circ \\mu \\circ \\mu^{- 1} \\sqsubseteq \\mu \\circ \\mu^{-\n1}$.\n\n\\url{https://www.researchgate.net/project/The-lattice-LG-of-group-topologies}\n", "meta": {"hexsha": "3c8e2623674759ed229bdb68d5bbc7bd39396c57", "size": 23090, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap-tgroups.tex", "max_stars_repo_name": "vporton/algebraic-general-topology", "max_stars_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-06-26T00:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-03T04:56:16.000Z", "max_issues_repo_path": "chap-tgroups.tex", "max_issues_repo_name": "vporton/algebraic-general-topology", "max_issues_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-12-30T07:16:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T02:05:02.000Z", "max_forks_repo_path": "chap-tgroups.tex", "max_forks_repo_name": "vporton/algebraic-general-topology", "max_forks_repo_head_hexsha": "d1d02a6515a6dabbc5d30b0c00a3e6a9878b36b1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.8140417457, "max_line_length": 242, "alphanum_fraction": 0.6378951927, "num_tokens": 9266, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4070229689814234}}
{"text": "    \\documentclass[12pt]{article}\n    \n    \\usepackage[margin=1.25in]{geometry} \n    \\usepackage{amsmath,amsthm,amssymb} \n    \\usepackage{tikz}\n    \\usepackage[capposition=top]{floatrow}\n    \\usepackage{indentfirst}\n    \\usepackage{amsmath}\n    \\usepackage{wrapfig}\n\n    %\\linespread{1.5}\n\n    \\begin{document}\n    \n\\title{Balcony Height Lab Report}\n\\author{AP Physics | B Block\\\\\n\t\\\\\n\tRyan McCrystal\\\\\n\tKala'i Anderson\\\\\nBella Otterson}\n\\date{\\today}\n\\maketitle\n\\newpage\n\\begin{abstract} % Include purpose, methodologies, assumptions, and brief statement of results\n\tThe purpose of this experiment is to calculate the height of the Cooper House balcony as accurately as possible and to determine which method is the most accurate. Two different methods were used to calculate the height of the balcony. The first method we used involved creating two similar triangles by placing a pole of known length a distance away from the ground directly below the balcony. Using this setup, one of our group members aligned their eye to be col-linear to the top of the pole and the balcony. Using these measurements, we were able to mathematically construct two similar triangles giving us a calculated height of $15.4ft\\pm1.4ft$. The second method we used to indirectly calculate the height of the balcony involved a tennis ball, a stopwatch, and the appropriate kinematic equations. One of our group members dropped a ball at the top of the railing while another group member timed the amount of time it took for the ball to hit the ground. Because we know the ball's acceleration due to the constant force of gravity, we could indirectly calculate the height of the railing. This method provided us with a much more inaccurate result of  $12.6ft\\pm8.12ft$. \n\\end{abstract}\n\\newpage\n    \n\\section{Approach} %Include a detailed description of the procedures and relevant diagram(s) of the physical layout. Specify measurement apparatus and equipment used.\n\\subsection{Similar Triangles}\nThe first method we used to indirectly calculate the height of the Cooper House balcony was with similar triangles. We positioned a wooden pole perpendicular to the ground and had one of our group members stand a distance away from the pole aligning the very top of the pole to the edge of the balcony. By measuring the height of the pole, the distance of the meter stick to the bottom of the building, the height of our group member's eyes, and the distance from our group member's eyes to the pole, we were able to create two similar triangles allowing us to indirectly calculate the height of the balcony.\n\\begin{figure}[H]       % Figure showing more broadly our setup\n\t\\centering\n\t\\begin{tikzpicture}[scale=1]\n\t\t\\draw[dashed] -- node [left] {\\text{Perspective}} (0,0)\n        -- (6,3);\n        \\draw[line width=0.4mm] (6,3) -- (6,0) node[midway,right] {Balcony height};\n        \\draw[dashed] (6,0) -- (2,0);\n\t\t\\draw[dashed] (2,0) -- (0,0);\n\t\t\\draw[line width=0.4mm] -- (2,0) -- (2,1) node[midway,right] {Pole};\n\t\t\\draw[dashed] -- (6,3) -- (6.5,3) node[midway,above] {$10in$} node[right] {\\text{Balcony edge}};\n    \\end{tikzpicture}\n    \\caption{Our setup}\n\\end{figure}\n\n\\subsection{Kinematic Equations}\nUsing a stopwatch and a tennis ball we timed the time it took for the tennis ball to be dropped from the top of the balcony to the ground. Using kinematic equations we can calculate the height of the balcony given our collected information and assuming a constant gravity of $9.8\\frac{m}{s^2}$.\n\\begin{figure}[H]\n\t\\centering\n\t\\begin{tikzpicture}[scale=0.75]\n\t\t\\draw[->,dashed] -- (0,5) -- (0,0);\n\t\t\\filldraw (0,3.5) node[right]{ball} circle (3pt);\n\t\t\\draw -- (-.5,0) -- (.5,0);\n\t\t\\draw -- (.5,0) -- (4,0) node[midway,above]{ground};\n\t\t\\draw -- (-.5,5) -- (.5,5);\n\t\t\\draw -- (.5,5) -- (4,5) node[midway,above]{balcony};\n    \\end{tikzpicture}\n    \\caption{Kinematic equations setup}\n\\end{figure}\n\n\\section{Calculations} % include a detailed presentation of the data, calculations, and other relevant diagrams. Specify uncertainty of measured values. Pay attention tl significant figures.\n\\subsection{Similar Triangles}\nThe data our group gathered is as follows:\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\text{Distance from eyes to meter stick}     & =X_1 & =41cm\\pm 2cm      \\\\\n\t\t\\text{Distance from meter stick to building} & =X_2 & =455.9cm\\pm 3cm   \\\\\n\t\t\\text{Distance from eyes to top of the pole} & =Y   & =25\\pm 1cm        \\\\\n\t\t\\text{Height of eyes above ground}           & =H_2 & =157.8cm\\pm 1.2cm \n\t\\end{aligned}\n\\end{equation} \\par\nAfter gathering the data, we created two similar triangles representing our measurements like so:\n\\begin{figure}[H]\n\t\\centering\n\t\\begin{tikzpicture}[scale=1.5]\n\t\t\\draw -- node [left] {\\text{Perspective}} (0,0)\n\t\t-- (6,3) -- (6,0) node[midway,right] {$H_1$} -- (2, 0) node[midway,below] {$X_2$}\n\t\t-- (0,0) node[midway,below] {$X_1$};\n\t\t\\draw -- (2,0) -- (2,1) node[midway,right] {$Y$};\n\t\t\\draw[dashed] -- (0,0) -- (0,-1) node[midway,left] {$H_2$};\n\t\t\\draw[dashed] -- (6,3) -- (6.5,3) node[midway,above] {$10in$} node[right] {\\text{Balcony edge}};\n\t\\end{tikzpicture}\n\t\\begin{minipage}{0.5\\textwidth}    % Margin text\n\t\t\\caption{Similar triangles we used to indirectly calculate the height of the balcony}\n\t\t{\\footnotesize Note: $H_1$ is the height of the balcony without taking the height of the eyes into account. 10 inches is added to account for the balcony being inlaid from the wall.\\par}\n\t\\end{minipage}\n\\end{figure}\nUsing the angle-angle similarity postulate, we can conclude that\n$$\\frac{Y}{X_1}=\\frac{H_1}{X_1+X_2+(10in)}$$\ntherefore,\n$$H_1=\\frac{Y}{X_1}(X_1+X_2+(10in))$$\nPlugging in the our measurements:\n\\begin{equation}\n\t\\begin{aligned}\n        H_1 & =\\frac{25cm\\pm1cm}{41cm\\pm2cm}((41cm\\pm2cm)+(455.9cm\\pm3cm)+(10in)) \\\\\n        & =318.4cm\\pm40.2cm\\\\\n            H_{tot} & =H_1 + H_2 \\\\\n            &=318.4cm\\pm40.2cm+157.8cm\\pm1.2cm \\\\\n\t\t    & =476.2cm\\pm41.4cm \\\\\n\t\t    & \\approx\\boxed{15.4ft\\pm1.4ft}\n\t\\end{aligned}\n\\end{equation}\n\\subsection{Kinematic Equations}\nTo reduce our possible inaccuracy, we timed the amount of time it took for the tennis ball to reach the ground twenty times.\\par\nThe data we gathered is as follows:\n\\begin{table}[H]\n\t\\begin{tabular}{ll}\n\t\t1.060 & 0.810 \\\\\n\t\t0.870 & 0.810 \\\\\n\t\t0.780 & 0.810 \\\\\n\t\t0.830 & 1.000 \\\\\n\t\t0.810 & 1.030 \\\\\n\t\t1.030 & 0.840 \\\\\n\t\t0.780 & 0.830 \\\\\n\t\t0.870 & 1.080 \\\\\n\t\t0.860 & 0.810 \\\\\n\t\t0.860 & 0.930 \\\\\n\t\\end{tabular}\n\t\\caption{Seconds timed for each tennis ball drop}\n\t\\label{tab:times}\n\\end{table}\nUsing these measurements and assuming an uncertainty of $\\pm0.25s$, we calculated the average time to be $0.885s\\pm0.25s$.\n\\par\n\\begin{figure}[H]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\draw[->,dashed] -- (0,5) -- (0,0) node[midway,left]{$t=0.885s$};\n\t\t\\filldraw (0,3.5) node[right]{ball} circle (3pt);\n\t\t\\draw -- (-.5,0) -- (.5,0) node[midway,below]{$y_1=?$};\n\t\t\\draw -- (.5,0) -- (4,0) node[midway,above]{ground};\n\t\t\\draw -- (-.5,5) -- (.5,5) node[midway,above]{$y_0=0,v_0=0$};\n\t\t\\draw -- (.5,5) -- (4,5) node[midway,above]{balcony};\n\t\t\\node at (3,3){$g=9.8\\frac{m}{s^2}$};\n\t\t\\node at (3.5,2){$\\Delta y=v_0t+\\frac{1}{2}gt^2$};\n    \\end{tikzpicture}\n    \\caption{Kinematic equations setup}\n\\end{figure}\n\nUsing the second kinematic equation (with slight modifications to variable names), assuming $h_0=0$, $v_0=0$, and $g=9.8\\frac{m}{s^2}$,\n\\begin{equation}\n\t\\begin{aligned}\n\t\th&=h_0+v_0t-\\frac{1}{2}gt^2\\\\\n\t\t&=-\\frac{1}{2}gt^2\\\\\n\t\t-h & =\\frac{1}{2}(9.8\\frac{m}{s^2})(0.885s\\pm0.25s)^2 & \\text{\\footnotesize{$-h$ accounts for the downward direction}} \\\\\n\t\t&=3.837m\\pm2.476m\\\\\n\t\t&\\approx\\boxed{12.6ft\\pm8.12ft}\n\t\\end{aligned}\n\\end{equation}\n\n\\section{Results and Conclusions} % Were the resulting values what you expected? Why or why not? Make sure to indicate any significant sources of error, or how you would conduct the experiment next tome to improve the accuracy of your results. Was one method better than the other? if so, why?\n% say which measurement is more accurate and why\nAfter reviewing these two methods, our group determined that using the similar triangles method would warrant a more accurate result, and the uncertainty confirms this. The similar triangles method allows us to much more easily calculate accurate results, while the kinematic equations method, though much easier, provides much less accurate results due to the need to accurately time small time discrepancies. To improve the accuracy of the kinematic equations method, instead of timing by hand a slow motion camera and a robot which predictably drops the tennis ball could be used to further the accuracy of the data. For the similar triangles method, instead of aligning a group member's eye to the top of the pole and the top of the balcony, we could measure the distance a shadow makes (assuming the sun is in the right place) with the balcony and with the pole creating two similar triangles as before.\n\\end{document}", "meta": {"hexsha": "4fd497a023c0a3e6faceecc5512007f070e5101c", "size": 8893, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Balcony Height Lab Report/report.tex", "max_stars_repo_name": "rmccrystal/ap-physics-lab-reports", "max_stars_repo_head_hexsha": "c5e8ccbe6821713215d3fa4b9cbf4473d0ec0277", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Balcony Height Lab Report/report.tex", "max_issues_repo_name": "rmccrystal/ap-physics-lab-reports", "max_issues_repo_head_hexsha": "c5e8ccbe6821713215d3fa4b9cbf4473d0ec0277", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Balcony Height Lab Report/report.tex", "max_forks_repo_name": "rmccrystal/ap-physics-lab-reports", "max_forks_repo_head_hexsha": "c5e8ccbe6821713215d3fa4b9cbf4473d0ec0277", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.1241830065, "max_line_length": 1183, "alphanum_fraction": 0.7047115709, "num_tokens": 2791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.40702296898142337}}
{"text": " \\documentclass [12pt]{article} \n\n\\usepackage {amsmath}\n\\usepackage {amsthm}\n\\usepackage {amssymb}\n\\usepackage {graphicx} \n\\usepackage {float}\n\\usepackage {multirow}\n\\usepackage {xcolor}\n\\usepackage {algorithmic}\n\\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \\usepackage {array} \n\\usepackage {booktabs} \n\\usepackage {url} \n\\usepackage {parskip} \n\\usepackage [margin=1in]{geometry} \n\\usepackage [T1]{fontenc} \n\\usepackage {cmbright} \n\\usepackage [many]{tcolorbox} \n\\usepackage [colorlinks = true,\n            linkcolor = blue,\n            urlcolor  = blue,\n            citecolor = blue,\n            anchorcolor = blue]{hyperref} \n\\usepackage {enumitem} \n\\usepackage {xparse} \n\\usepackage {verbatim}\n\\usepackage{listings}\n\\usepackage{xcolor}\n\\lstset { %\n    language=C++,\n    backgroundcolor=\\color{black!5}, % set backgroundcolor\n    basicstyle=\\footnotesize,% basic font setting\n}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{remark}{Remark}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\\newtheorem{claim}{Claim}\n\n\n\n\n\\DeclareTColorBox {Solution}{}{breakable, title={Solution}} \\DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}} \\DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt} \\DeclareDocumentCommand {\\Expecting }{+m}{\\textbf {[We are expecting:} #1\\textbf {]}} \\DeclareDocumentCommand {\\Points }{m}{\\textbf {(#1 pt.)}} \n\n\\begin {document} \n\n\\vspace {1em} \n\\begin {Instruction} \nAdapted From Virginia Williams' lecture notes.\n\\end {Instruction}  \n\n{\\LARGE \\textbf {COMP 285 (NC A\\&T, Spr `22)}\\hfill \\textbf {Lecture 22} } \n\n\\begin{centering}\n\\section*{Single-Source Shortest Path in Weighted Graphs}\n\\end{centering}\n\n\n\\section{Dijkstra's Algorithm}\n\nNow we will solve the single source shortest paths problem in graphs with nonnengative\nweights using Dijkstra's algorithm. The key idea, that Dijkstra will maintain as an invariant,\nis that $\\forall t in V$, the algorithm computes an estimate $d[t]$ of the distance of $t$ from the source such that:\n\n\\begin{enumerate}\n    \\item At any point in time, $d[t] \\geq d(s, t)$, and\n    \\item when t is finished, $d[t] = d(s, t)$.\n\\end{enumerate}\n\n\n\\begin{algorithm}\n\\caption{Dijkstra($G= (V,E), S$)}\n\\label{alg:1}\n\\begin{algorithmic}\n\\STATE $\\forall t \\in V, d[t] \\gets \\infty$ \\texttt{// set initial distance estimates}\n\\STATE $d[s] \\gets 0$\n\\STATE $F \\gets \\{v \\mid \\forall v \\in V\\}$ \\texttt{// F is the set of nodes that are yet to achieve final distances estimates}\n\\STATE $D \\gets \\emptyset$ \\texttt{// D will be the set of nodes that have achieved final distance estimates}\n\\WHILE{$F \\neq \\emptyset$}\n    \\STATE $x \\gets$ elements in $F$ with minimum distance estimate\n    \\FOR{$(x,y) \\in E$}\n        \\STATE $d[y] \\gets \\min\\{d[y], d[x] + w(x,y)\\}$ \\texttt{// \"relax\" the estimate of y}\n        \\STATE \\texttt{// to maintain paths: if} $d[y]$ \\texttt{changes, then } $\\pi(y) \\gets x$\n    \\ENDFOR\n    \\STATE $F \\gets F \\setminus \\{x\\}$\n    \\STATE $D \\gets D \\cup \\{x\\}$\n\\ENDWHILE\n\\end{algorithmic}\n\\end{algorithm}\n\n\\begin{claim}[For every $u$, at any point of time $d(u) \\geq d(s, u)$.]\n\\vspace{1em}\nA formal proof of this claim proceeds by induction. In particular, one shows that at any point in time, if $d[u] < \\infty$, then $d[u]$ is the weight of some path from $s$ to $t$. Thus at any point $d[u]$ is at least the weight of the shortest path, and hence $d[u] \\geq d(s, u)$. As a base case, we know that $d[s] = 0 = d(s, s)$ and all other distance estimates are $+\\infty$, so we know that the claim holds initially. Now, when $d[u]$ is changed to $d[x] + w(x, u)$ then (by the induction hypothesis) there is a path from $s$ to $x$ of weight $d[x]$ and an edge $(x, u)$ of weight $w(x, u)$. This means there is a path from $s$ to $u$ of weight $d[u] = d[x] + w(x, u)$. This implies that $d[u]$ is at least the weight of the shortest path $= d(s, u)$, and the induction argument is complete\n\\end{claim}\n\n\n\\begin{claim}[When node $x$ is placed in $D$, $d(x) = d(s,x)$] \n\\vspace{1em}\n\nNotice that proving the above claim is sufficient to prove the correctness of the algorithm since $d[x]$ is never changed again after $x$ is added to $D$: the only way it could be changed is if for some node $y \\in F$ , $d[y] + w(y, x) < d[x]$ but this can't happen since $d[x] \\leq d[y ]$ and $w(y, x) \\geq 0$ (all edge weights are nonnegative). The assertion $d[x] \\leq d[y]$ for all $y \\in F$ stays true at all points after $x$ is inserted into D: assume for contradiction that at some point for some $y \\in F$ we get $d[y ] < d[x]$ and let $y$ be the first such $y$ . $Before d[y ]$ was updated $d[y' ] \\geq d[x]$ for all $y' \\in F$ . But then when $d[y ]$ was changed, it was due to some neighbor $y'$ of $y$ in $F$ , but$ d[y' ] \\geq d[x]$ and all weights are nonnegative, so we get a contradiction \n\nWe prove this claim by induction on the order of placement of nodes into $D$. For the base case, $s$ is placed into D where $d[s] = d(s, s) = 0$, so initially, the claim holds. \n\nFor the inductive step, we assume that for all nodes $y$ currently in $D$, $d[y ] = d(s, y )$. Let $x$ be the node that currently has the minimum distance estimate in $F$ (this is the node about to be moved from $F$ to $D$). We will show that $d[x] = d(s, x)$ and this will complete the induction. Let $p$ be a shortest path from $s$ to $x$. Suppose $z$ is the node on $p$ closest to $x$ for which $d[z] = d(s, z)$. We know $z$ exists since there is at least one such node, namely $s$, where $d[s] = d(s, s)$. By the choice of $z$, for every node $y$ on $p$ between $z$ (not inclusive) to $x$ (inclusive), $d[y ] > d(s, y )$. Consider the following options for $z$.\n\n\\begin{enumerate} \n    \\item If $z = x$, then $d[x] = d(s, x)$ and we are done.\n    \\item Suppose $z \\neq x$. Then there is a node $z'$ after $z$ on $p$. (Here it is possible that $z' = x$.) We know that $d[z] = d(s, z) \\leq d(s, x) \\leq d[x]$. The first $\\leq$ inequality holds because subpaths of shortest paths are shortest paths as well, so that the prefix of $p$ from $s$ to $z$ has weight $d(s, z)$. In addition, the weights on edges are non-negative, so that the portion of $ p$ from $z$ to $x$ has a nonnegative weight, and so $d(s, z) \\leq d(s, x)$. The subsequent $\\leq $ holds by Claim 1. We know that if $d[z] = d[x]$ all of the previous inequalities are equalities and $d[x] = d(s, x)$ and the claim holds. \n\n    Finally, towards a contradiction, suppose $d[z] < d[x]$. By the choice of $x \\in F$ we know $d[x]$ is the minimum distance estimate that was in $F$ . Thus, since $d[z] < d[x]$, we know $z \\notin F$ and must be in $D$, the finished set. This means the edges out of $z$, and in particular ($z, z' )$, were already relaxed by our algorithm. But this means that $d[z ' ] \\leq d(s, z) + w(z, z' ) = d(s, z' )$, because $z$ is on the shortest path from $s$ to $z '$ , and the distance estimate of $z '$ must be correct. However, this contradicts $z$ being the closest node on $p$ to $x$ meeting the criteria$ d[z] = d(s, z)$. Thus, our initial assumption that $d[z] < d[x]$ must be false and $d[x]$ must equal $d(s, x)$.\n\\end{enumerate}\n\\end{claim}\n\n\n\\subsection{Implementation of Dijkstra's Algorithm}\n\nConsider implementing Dijkstra's algorithm with a priority queue to store the set $F$ , where the distance estimates are the keys. The initialization step takes $O(n)$ operations to set $n$ distance estimate values to infinity and $0$. In each iteration of the while loop, we make a call to find the node $x$ in $F$ with the minimum distance estimate (via, say, \\texttt{FindMin} operation). Then, we relax each edge leaving $x$ (via \\texttt{DecreaseKey}). We remove node $x$ (via \\texttt{DeleteMin}) and add it to $D$. In total, there are $n$ calls to \\texttt{FindMin} and $n$ calls to \\texttt{DeleteMin} since nodes are never re-inserted into $F$ . Similarly, there will be $m$ calls to \\texttt{DecreaseKey} to relax the edges since each edge will be relaxed at most once.\n\nDepending on how quickly our priority queue can support \\texttt{FindMin}, \\texttt{DeleteMin}, and \\texttt{DecreaseKey} operations, the total runtime of Dijkstra's algorithm is on the order of\n$$\nn \\cdot(T_{\\texttt{FindMin}}(n) + T_{\\texttt{DeleteMin}}(n)) + m \\cdot T_{\\texttt{DecreaseKey}}(n)\n$$ \n\nWe consider the following implementations of the priority queue for storing $F$:\n\n\\begin{itemize}\n    \\item Store $F$ as an array: \n\n        Each slot corresponds to a node and stores the distance $d[j]$ if $j \\in F$ , or \\texttt{NIL} otherwise. \\texttt{DecreaseKey} runs in $O(1)$ as nodes are indexed. \\texttt{FindMin} and \\texttt{DeleteMin} run in $O(n)$ as the array is not sorted and we have to go through the whole array. The total runtime is $O(m + n^2 )$ = $O(n^2)$. \n    \\item Store $F$ as a red-black tree:\n        \n        All operations run in $O(\\log n)$ time. We implement \\texttt{DecreaseKey} by deleting and reinserting with the new key. The total runtime is $O((m + n) \\log n)$. If graph $G$ is sparse with few edges, then the red-black tree implementation is faster than the array implementation. However, it can be slower when $G$ is dense with$ m = \\Theta(n^2)$. \n    \\item Store $F$ as a Fibonacci heap: \n\n        Fibonacci heaps are a complex data structure which is able to support the operations \\texttt{Insert} in $O(1)$, \\texttt{FindMin} in $O(1)$, \\texttt{DecreaseKey} in $O(1)$ and \\texttt{DeleteMin} in $O(\\log n)$ ``amortized'' time, over a sequence of calls to these operations. The meaning of amortized time in this case is as follows: starting from an empty Fibonacci heap, any sequence of operations that includes a \\texttt{Insert}'s, b \\texttt{FindMin}'s, c \\texttt{DecreaseKey}'s and d \\texttt{DeleteMin}'s' take $O(a + b + c + d \\log n)$ time. The total runtime is $O(m + n \\log n)$. \n\\end{itemize}\n\nTo conclude, Dijkstra's algorithm can be very fast when implemented the right way! However, it has a few drawbacks:\n\n\\begin{itemize}\n    \\item It doesn't work with negative edge weights: we used the fact that the weights were\nnon-negative a few times in the correctness proof above.\n    \\item It's not very amenable to frequent updates. Suppose that you had already run Dijkstra's algorithm from a particular point, but one weight in the graph changed. How would you recover from this? Next time, we'll see the Bellman-Ford algorithm, which can be\nbetter on both of these fronts.\n\\end{itemize}\n\n\\section{Negative Edge Weights}\nNote that Dijkstra's algorithm solves the single source shortest paths problem when there\nare no edges with negative weights. While Dijkstra's algorithm may fail on certain graphs\nwith negative edge weights, having a negative cycle (i.e., a cycle in the graph for which the\nsum of edge weights is negative) is a bigger problem for any shortest path algorithm. When\ncomputing a shortest path between two vertices, each additional traversal along the cycle\nlowers the overall cost incurred and an arbitrarily small distance can be reached after looping\naround the cycle multiple times. In this case, the shortest path to a node on the cycle is not\nwell defined since it is (negatively) infinite.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[scale=0.5]{negative_cycle.png}\n\\caption{Assume there is a negative cycle along the $s-t$ path. The distance between $s$ and\n$t$ is not well-defined.}\n\\label{fig:negative_cycle}\n\\end{figure}\n\nFor example, consider the graph in Figure \\ref{fig:negative_cycle}. The shortest path from $s$ to $t$ would start from the node $s$, loop around the negative cycle an infinite number of times and eventually reach destination $t$. The shortest path would, hence, be of infinite length and is not well-defined. Besides the negative cycles, there are no problems in computing the shortest paths in a graph with negative edge weights. In fact, there are many applications where allowing negative edge weights is important.\n\n\\end{document}", "meta": {"hexsha": "a13821ad7ac724ad8722997c1c4ac3c7f6ad79d8", "size": 12026, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assets/lectures/lecture22.tex", "max_stars_repo_name": "facebookEIR/algorithms-course", "max_stars_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-16T02:47:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-16T02:47:46.000Z", "max_issues_repo_path": "assets/lectures/lecture22.tex", "max_issues_repo_name": "facebookEIR/algorithms-course", "max_issues_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/lectures/lecture22.tex", "max_forks_repo_name": "facebookEIR/algorithms-course", "max_forks_repo_head_hexsha": "f0893b43aaf3b321eb134c82512bd7b9271fdea6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2022-01-20T21:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-21T03:00:16.000Z", "avg_line_length": 71.5833333333, "max_line_length": 805, "alphanum_fraction": 0.7004822884, "num_tokens": 3587, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7772998663336157, "lm_q1q2_score": 0.4068545672644992}}
{"text": "\\section{Groebner package}\n\\begin{Introduction}{Groebner bases}\nThe GROEBNER package calculates \\nameindex{Groebner bases} using the\n\\nameindex{Buchberger algorithm} and provides related algorithms\nfor arithmetic with ideal bases, such as ideal quotients,\nHilbert polynomials (\\nameindex{Hollmann algorithm}), \nbasis conversion (\n\\nameindex{Faugere-Gianni-Lazard-Mora algorithm}), independent  \nvariable set (\\nameindex{Kredel-Weispfenning algorithm}).\n\n\n\nSome routines of the Groebner package are used by \\nameref{solve} - in\nthat context the package is loaded automatically. However, if you\nwant to use the package by explicit calls you must load it by\n\\begin{verbatim}\n    load_package groebner;\n\\end{verbatim}\n\nFor the common parameter setting of most operators in this package \nsee \\nameref{ideal parameters}.\n\\end{Introduction}\n\n\n\n\\begin{Concept}{Ideal Parameters}\n\\index{polynomial}\nMost operators of the \\name{Groebner} package compute expressions in a\npolynomial ring which given as \\meta{R}[\\meta{var},\\meta{var},...] where\n\\meta{R} is the current REDUCE coefficient domain.  All algebraically\nexact domains of REDUCE are supported.  The package can operate over rings\nand fields.  The operation mode is distinguished automatically.  In\ngeneral the ring mode is a bit faster than the field mode.  The factoring\nvariant can be applied only over domains which allow you factoring of\nmultivariate polynomials.\n\nThe variable sequence \\meta{var} is either declared explicitly as argument\nin form of a \\nameref{list} in \\nameref{torder}, or it is extracted\nautomatically from the expressions.  In the second case the current REDUCE\nsystem order is used (see \\nameref{korder}) for arranging the variables.\nIf some kernels should play the role of formal parameters (the ground\ndomain \\meta{R} then is the polynomial ring over these), the variable\nsequences must be given explicitly.\n\nAll REDUCE \\nameref{kernel}s can be used as variables.  But please note,\nthat all variables are considered as independent.  E.g. when using\n\\name{sin(a)} and \\name{cos(a)} as variables, the basic relation\n\\name{sin(a)^2+cos(a)^2-1=0} must be explicitly added to an equation set\nbecause the Groebner operators don't include such knowledge automatically.\n\nThe terms (monomials) in polynomials are arranged according to the current\n\\nameref{term order}.  Note that the algebraic properties of the computed\nresults only are valid as long as neither the ordering nor the variable\nsequence changes.\n\nThe input expressions \\meta{exp} can be polynomials \\meta{p}, rational\nfunctions \\meta{n}/\\meta{d} or equations \\meta{lh}=\\meta{rh} built from\npolynomials or rational functions.  Apart from the \\name{tracing}\nalgorithms \\nameref{groebnert} and \\nameref{preducet}, where the equations\nhave a specific meaning, equations are converted to simple expressions by\ntaking the difference of the left-hand and right-hand sides\n\\meta{lh}-\\meta{rh}=>\\meta{p}.  Rational functions are converted to\npolynomials by converting the expression to a common denominator form\nfirst, and then using the numerator only \\meta{n}=>\\meta{p}.  So eventual\nzeros of the denominators are ignored.\n\nA basis on input or output of an algorithm is coded as \\nameref{list} of\nexpressions \\{\\meta{exp},\\meta{exp},...\\} . \\end{Concept}\n\n%-----------------------------------------------------------------\n\\subsection{Term order}\n%-----------------------------------------------------------------\n\\begin{Introduction}{Term order}\n\\index{distributive polynomials}\nFor all \\name{Groebner} operations the polynomials are \nrepresented in distributive form: a sum of terms (monomials).\nThe terms are ordered corresponding to the actual \\name{term order}\nwhich is set by the \\nameref{torder} operator, and to the\nactual variable sequence which is either given as explicit\nparameter or by the system \\nameref{kernel} order. \n\\end{Introduction}\n\n\\begin{Operator}{torder}\nThe operator \\name{torder} sets the actual variable sequence and term order.\n\n1. simple term order:\n\\begin{Syntax}\n  \\name{torder}\\(\\meta{vl}, \\meta{m}\\)\n\\end{Syntax}\n\nwhere  \\meta{vl} is a \\nameref{list} of variables (\\nameref{kernel}s) and\n\\meta{m} is the name of a simple \\nameref{term order} mode \n\\ref{lex term order}, \\ref{gradlex term order}, \n\\ref{revgradlex term order} or another implemented parameterless mode.\n\n2. stepped term order:\n\\begin{Syntax}\n  \n  \\name{torder} \\(\\meta{vl},\\meta{m},\\meta{n}\\)\n\n\\end{Syntax}\n  \nwhere \\meta{m} is the name of a two step term order, one of\n\\nameref{gradlexgradlex term order}, \\nameref{gradlexrevgradlex term order},\n\\nameref{lexgradlex term order} or \\nameref{lexrevgradlex term order}, and\n\\meta{n} is a positive integer.\n\n3. weighted term order\n\\begin{Syntax}\n \\name{torder} \\(\\meta{vl}, \\name{weighted}, \\meta{n},\\meta{n},...\\); \n\\end{Syntax}\n\nwhere the \\meta{n} are positive integers, see \\nameref{weighted term order}.\n\n4. matrix term order\n\\begin{Syntax}\n \\name{torder} \\(\\meta{vl}, \\name{matrix}, \\meta{m}\\); \n\\end{Syntax}\n\nwhere \\meta{m} is a matrix with integer elements, see \n\\nameref{torder_compile}.\n\n5. compiled term order\n\\begin{Syntax}\n \\name{torder} \\(\\meta{vl}, \\name{co}\\); \n\\end{Syntax}\n\nwhere \\meta{co} is the name of a routine generated by \n\\nameref{torder_compile}.\n\n\\name{torder} sets the variable sequence and the term order mode. If the\nan empty list is used as variable sequence, the automatic variable extraction\nis activated. The defaults are the empty variable list an the \n\\nameref{lex term order}. \nThe previous setting is returned as a list. \n\nAlternatively to the above syntax the arguments of \\name{torder} may be \ncollected in a \\nameref{list} and passed as one argument to \n\\name{torder}.\n\n\\end{Operator}\n%------------------------------------------------------------\n\\begin{Operator}{torder_compile}\n\\index{term order}\nA matrix can be converted into\na compilable LISP program for faster execution by using\n\\begin{Syntax}\n    \\name{torder\\_compile}\\(\\meta{name},\\meta{mat}\\)\n\\end{Syntax}\nwhere \\meta{name} is an identifier for the new term order and \\meta{mat}\nis an integer matrix to be used as \\nameref{matrix term order}. Afterwards\nthe term order can be activated by using \\meta{name} in a \\nameref{torder}\nexpression. The resulting program is compiled if the switch \\nameref{comp}\nis on, or if the  \\name{torder\\_compile} expression is part of a compiled\nmodule.\n\\end{Operator}\n%------------------------------------------------------------\n\\begin{Concept}{lex term order}\n\\index{term order}\\index{variable elimination}\nThe terms are ordered lexicographically: two terms t1 t2 \nare compared for their degrees \nalong the fixed variable sequence: t1 is higher than t2\nif the first different degree is higher in t1.\nThis order has the \\name{elimination property}\nfor \\name{groebner basis} calculations.\nIf the ideal has a univariate polynomial in the last\nvariable the groebner basis will contain\nsuch polynomial. \\name{Lex} is best\nsuited for solving of polynomial equation systems.\n\n\\end{Concept}\n\n%------------------------------------------------------------\n\\begin{Concept}{gradlex term order}\n\\index{term order}\nThe terms are ordered first with their total\ndegree, and if the total degree is identical\nthe comparison is \\nameref{lex term order}.\nWith \\name{groebner} basis calculations this term order\nproduces polynomials of lowest degree.\n\\end{Concept}\n\n%------------------------------------------------------------\n\\begin{Concept}{revgradlex term order}\n\\index{term order}\nThe terms are ordered first with their total\ndegree (degree sum), and if the total degree is identical\nthe comparison is the inverse of \\nameref{lex term order}.\nWith \\nameref{groebner} and \\nameref{groebnerf} \ncalculations this term order\nis similar to \\nameref{gradlex term order}; it is known\nas most efficient ordering with respect to computing time.\n\\end{Concept}\n\n%------------------------------------------------------------\n\\begin{Concept}{gradlexgradlex term order}\n\\index{term order}\nThe terms are separated into two groups where the\nsecond parameter of the \\nameref{torder} call determines\nthe length of the first group. For a comparison first\nthe total degrees of both variable groups are compared.\nIf both are equal \n\\nameref{gradlex term order} comparison is applied to the first\ngroup, and if that does not decide \\nameref{gradlex term order}\nis applied for the second group. This order has the elimination\nproperty for the variable groups. It can be used e.g. for\nseparating variables from parameters.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{gradlexrevgradlex term order}\n\\index{term order}\nSimilar to \\nameref{gradlexgradlex term order}, but using\n\\nameref{revgradlex term order} for the second group.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{lexgradlex term order}\n\\index{term order}\nSimilar to \\nameref{gradlexgradlex term order}, but using\n\\nameref{lex term order} for the first group.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{lexrevgradlex term order}\n\\index{term order}\nSimilar to \\nameref{gradlexgradlex term order}, but using\n\\nameref{lex term order} for the first group\n\\nameref{revgradlex term order} for the second group.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{weighted term order}\n\\index{term order}\nestablishes a graduated ordering\nsimilar to \\nameref{gradlex term order}, where the exponents first are\nmultiplied by the given weights. If there are less weight values than\nvariables, the weight list is extended by ones. If the weighted degree\ncomparison is not decidable, the \n\\nameref{lex term order} is used.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{graded term order}\n\\index{term order}\nestablishes a cascaded term ordering:  first a graduated ordering\nsimilar to \\nameref{gradlex term order} is used, where the exponents first are\nmultiplied by the given weights. If there are less weight values than\nvariables, the weight list is extended by ones. If the weighted degree\ncomparison is not decidable, the term ordering described in the following\nparameters of the \\nameref{torder} command is used.\n\\end{Concept}\n%------------------------------------------------------------\n\\begin{Concept}{matrix term order}\n\\index{term order}\nAny arbitrary term order mode can be installed by a matrix with\ninteger elements where the row length corresponds to the variable\nnumber. The matrix must have at least as many rows as columns.\nIt must have full rank, and the top nonzero element of each column\nmust be positive.\n\nThe matrix \\name{term order mode}\ndefines a term order where the exponent vectors of the monomials are\nfirst multiplied by the matrix and the resulting vectors are compared\nlexicographically.\n\nIf the switch \\nameref{comp} is on, the matrix is converted into\na compiled LISP program for faster execution. A matrix can also be\ncompiled explicitly, see \\nameref{torder_compile}.\n\\end{Concept}\n%--------------------------------------------------------------- \n%------------------------------------------------------------\n\\subsection{Basic Groebner operators}\n%-------------------------------------------------------------\n\\begin{Operator}{gvars}\n\\begin{Syntax}\n\n  \\name{gvars}\\(\\{\\meta{exp},\\meta{exp},... \\}\\)\n\n\\end{Syntax}\n where \\meta{exp} are expressions or \\nameref{equation}s.\n\n\\name{gvars} extracts from the expressions the \\nameref{kernel}\\name{s} \nwhich can \nplay the role of variables for a \\nameref{groebner} or \\nameref{groebnerf} \ncalculation. \n\\end{Operator}\n\n%---------------------------------------------------------------\n\n\\begin{Operator}{groebner}\n\\index{Buchberger algorithm}\n\\begin{Syntax}\n\n  \\name{groebner}\\(\\{\\name{exp}, ...\\}\\)\n\n\\end{Syntax}\nwhere \\{\\name{exp}, ... \\} is a list of\nexpressions or equations.\n\n\nThe operator \\name{groebner} implements the Buchberger algorithm\nfor computing Groebner bases for a given set of\nexpressions with respect to the given set of variables in the order\ngiven.  As a side effect, the sequence of variables is stored as a REDUCE list\nin the shared variable \\nameref{gvarslast} - this is important in cases\nwhere the algorithm rearranges the variable sequence because \\nameref{groebopt}\nis \\name{on}.\n\n\\begin{Examples}\n   groebner({x**2+y**2-1,x-y})  &  \\{X - Y,2*Y**2 -1\\}\n\\end{Examples}\n\\begin{Related}\n\\item[ \\nameref{groebnerf} operator]\n\\item[ \\nameref{gvarslast} variable]\n\\item[ \\nameref{groebopt} switch]\n\\item[ \\nameref{groebprereduce} switch]\n\\item[ \\nameref{groebfullreduction} switch]\n\\item[ \\nameref{gltbasis} switch]\n\\item[ \\nameref{gltb} variable]\n\\item[ \\nameref{glterms} variable]\n\\item[ \\nameref{groebstat} switch]\n\\item[ \\nameref{trgroeb} switch]\n\\item[ \\nameref{trgroebs} switch]\n\\item[ \\nameref{groebprot} switch]\n\\item[ \\nameref{groebprotfile} variable]\n\\item[ \\nameref{groebnert} operator]\n\\end{Related}\n\\end{Operator}\n%-------------------------------------------------------\n\n\\begin{Operator}{groebner\\_walk}\nThe operator \\name{groebner\\_walk} computes a \\nameref{lex} basis\nfrom a given \\nameref{graded} (or \\nameref{weighted}) one.\n\\begin{Syntax}\n   \\name{groebner\\_walk}\\(\\meta{g}\\)\n\\end{Syntax}\n\nwhere \\meta{g} is a \\nameref{graded} basis (or \\nameref{weighted} basis\nwith a weight vector with one repeated element) of the polynomial ideal. \n\\name{Groebner\\_walk} computes a sequence of monomial bases, each\ntime lifting the full system to a complete basis.  \\name{Groebner\\_walk}\nshould be called only in cases, where a normal \\nameref{kex} computation\nwould take too much computer time.\n\nThe operator \\nameref{torder} has to be called before in order to\ndefine the variable sequence and the term order mode of \\meta{g}. \n\nThe variable \\nameref{gvarslast} is not set.\n\nDo not call \\name{groebner\\_walk} with \\name{on} \\nameref{groebopt}.\n\n\\name{Groebner\\_walk} includes some overhead (such as e. g. \ncomputation with division). On the other hand, sometimes\n\\name{groebner\\_walk} is faster than a direct \\nameref{lex} computation.\n\\end{Operator}\n\n%-------------------------------------------------------\n\n\\begin{Switch}{groebopt}\nIf \\name{groebopt} is set ON, the sequence of variables is optimized\nwith respect to execution speed of \\name{groebner} calculations; \nnote that the final list of variables is available in \\nameref{gvarslast}.\nBy default \\name{groebopt} is off, conserving the original variable\nsequence.\n\nAn explicitly declared dependency using the \\nameref{depend}\ndeclaration  supersedes the variable optimization.\n\\begin{Examples}\n\n   depend a, x, y;\n\n\\end{Examples}\nguarantees that a will be placed in front of x and y.\n\\end{Switch}\n\n\n%-------------------------------------------------------\n\n\\begin{Variable}{gvarslast}\nAfter a \\nameref{groebner} or \\nameref{groebnerf} calculation\nthe actual variable sequence is stored in the variable \n\\name{gvarslast}. If \\nameref{groebopt} is \\name{on}\n\\name{gvarslast} shows the variable sequence after reordering.\n\\end{Variable}\n\n%--------------------------------------------------------------\n\n\\begin{Switch}{groebprereduce}\nIf \\name{groebprereduce} set ON, \\nameref{groebner} \nand \\nameref{groebnerf} try to simplify the\ninput expressions: if the head term of an input expression is a\nmultiple of the head term of another expression, it can be reduced;\nthese reductions are done cyclicly as long as possible in order to\nshorten the main part of the algorithm.\n\nBy default \\name{groebprereduce} is off.\n\\end{Switch}\n\n%---------------------------------------------------------------\n\n\\begin{Switch}{groebfullreduction}\nIf \\name{groebfullreduction} set off, the polynomial reduction steps during\n\\nameref{groebner} and \\nameref{groebnerf} are limited to the pure head\nterm reduction; subsequent terms are reduced otherwise.\n\nBy default \\name{groebfullreduction} is on.\n\\end{Switch}\n\n%----------------------------------------------------------------\n\n\\begin{Switch}{gltbasis}\nIf \\name{gltbasis} set on, the leading terms of the result basis \nof a \\nameref{groebner} or \\nameref{groebnerf} calculation are\nextracted. They are collected as a basis of monomials, which is\navailable as value of the global variable \\nameref{gltb}.\n\\end{Switch}\n%------------------------------------------------------------------\n\\begin{Variable}{gltb}\nSee \\nameref{gltbasis}\n\\end{Variable}\n%------------------------------------------------------------------\n\n\\begin{Variable}{glterms}\nIf the expressions in a \\nameref{groebner} or \\nameref{groebnerf} \ncall contain parameters (symbols\nwhich are not member of the variable list), the share variable\n\\name{glterms} is set to a list of expression which during the\ncalculation were assumed to be nonzero. The calculated bases \nare valid only under the assumption that all these expressions do\nnot vanish.\n\\end{Variable}\n\n%-----------------------------------------------------------\n\\begin{Switch}{groebstat}\nif \\name{groebstat} is on, a summary of the \n\\nameref{groebner} or \\nameref{groebnerf} computation is printed\nat the end \nincluding the computing time, the number of intermediate\nH polynomials and the counters for the criteria hits.\n\\end{Switch}\n\n%-----------------------------------------------------------\n\\begin{Switch}{trgroeb}\nif \\name{trgroeb} is on, intermediate H polynomials are \nprinted during a \\nameref{groebner} \nor \\nameref{groebnerf} calculation.\n\\end{Switch}\n\n%-----------------------------------------------------------\n\\begin{Switch}{trgroebs}\nif \\name{trgroebs} is on, intermediate H and S polynomials are \nprinted during a \\nameref{groebner} or \\nameref{groebnerf} calculation.\n\\end{Switch}\n\n%-----------------------------------------------------------\n\\begin{Operator}{gzerodim?} \n\\begin{Syntax}\n\n  \\name{gzerodim!?}\\(\\meta{basis}\\)\n\n\\end{Syntax}\nwhere \\meta{bas} is a Groebner basis in the current \n\\nameref{term order} with the actual setting \n(see \\nameref{ideal parameters}). \n\n\n\\name{gzerodim!?} tests whether the ideal spanned by the given basis \nhas dimension zero. If yes, the number of zeros is returned,\n\\nameref{nil} otherwise.\n\\end{Operator}\n\n%---------------------------------------------------------------\n\n\\begin{Operator}{gdimension}\n\\index{ideal dimension}\\index{groebner}\n\\begin{Syntax}\n\n     \\name{gdimension}\\(\\meta{bas}\\) \n\n\\end{Syntax}\nwhere \\meta{bas} is a \\nameref{groebner} basis in the current\nterm order (see \\nameref{ideal parameters}). \n\\name{gdimension} computes the dimension of the ideal\nspanned by the given basis and returns the dimension as an integer\nnumber. The Kredel-Weispfenning algorithm is used: the dimension\nis the length of the longest independent variable set,\nsee \\nameref{gindependent\\_sets}\n\\end{Operator}\n\n\n%---------------------------------------------------------------\n\n\\begin{Operator}{gindependent\\_sets}\n\\index{ideal variables}\\index{ideal dimension}\\index{groebner}\n\\index{Kredel-Weispfenning algorithm}\n\\begin{Syntax}\n\n  \\name{gindependent\\_sets}\\(\\meta{bas}\\)\n\n\\end{Syntax}\nwhere \\meta{bas} is a \\nameref{groebner} basis in any \\name{term order} \n(which must be the current \\name{term order}) with the specified\nvariables (see \\nameref{ideal parameters}). \n\n\n\\name{Gindependent_sets} computes the maximal\nleft independent variable sets of the ideal, that are \nthe variable sets which play the role of free parameters in the\ncurrent ideal basis. Each set is a list which is a subset of the\nvariable list. The result is a list of these sets. For an\nideal with dimension zero the list is empty.\nThe Kredel-Weispfenning algorithm is used.\n\\end{Operator}\n\n%--------------------------------------------------------------\n\n\\begin{Operator}{dd_groebner}\nFor a homogeneous system of polynomials under \n\\nameref{graded term order}, \\nameref{gradlex term order}, \n\\nameref{revgradlex term order} \nor \\nameref{weighted term order} \na Groebner Base can be computed with limiting the grade\nof the intermediate S polynomials: \n\\begin{Syntax}\n\\name{dd_groebner}\\(\\meta{d1},\\meta{d2},\\meta{plist}\\)\n\\end{Syntax}\nwhere \\meta{d1} is a non negative integer and \\meta{d2} is an integer\nor ``infinity\". A pair of polynomials is considered\nonly if the grade of the lcm of their head terms is between\n\\meta{d1} and \\meta{d2}.\nFor the term orders \\name{graded} or \\name{weighted} the (first) weight\nvector is used for the grade computation. Otherwise the total\ndegree of a term is used.\n\\end{Operator}\n\n%--------------------------------------------------------------\n\n\n\\begin{Operator}{glexconvert}\n\\index{ideal variables}\\index{term order}\n\\begin{Syntax}\n\n\\name{glexconvert}\\(\\meta{bas}[,\\meta{vars}][,MAXDEG=\\meta{mx}]\n[,NEWVARS=\\meta{nv}]\\)\n\n\\end{Syntax}\nwhere \\meta{bas} is a \\nameref{groebner} basis\nin the current term order,  \\meta{mx} (optional) is a positive\ninteger and \\meta{nvl} (optional) is a list of variables \n(see \\nameref{ideal parameters}).\n\n\nThe operator \\name{glexconvert} converts the basis \nof a zero-dimensional ideal (finite number\nof isolated solutions) from arbitrary ordering into a basis under \n\\nameref{lex term order}. \n\n\nThe parameter \\meta{newvars} defines the new variable sequence. \nIf omitted, the\noriginal variable sequence is used. If only a subset of variables is\nspecified here, the partial ideal basis is evaluated. \n\nIf \\meta{newvars} is a list with one element, the minimal\n\\nameindex{univariate polynomial} is computed.\n\n\\meta{maxdeg} is an upper limit for the degrees. The algorithm stops with\nan error message, if this limit is reached.\n\nA warning occurs, if the ideal is not zero dimensional.\n\\begin{Comments}\nDuring the call the \\name{term order} of the input basis must\nbe active.\n\\end{Comments}\n\\end{Operator}\n\n%--------------------------------------------------------------\n\n\\begin{Operator}{greduce}\n\\begin{Syntax}\n\n\\name{greduce}\\(exp, \\{exp1, exp2, \\ldots , expm\\}\\)\n\n\\end{Syntax}\n\nwhere exp is an expression, and \\{exp1, exp2, ... , expm\\} is\na list of expressions or equations.\n\n\n\\name{greduce} is functionally equivalent with a call to\n\\nameref{groebner} and then a call to \\nameref{preduce}.\n\\end{Operator}\n\n%---------------------------------------------------------\n\n\\begin{Operator}{preduce}\n\\begin{Syntax}\n\n \\name{preduce}\\(\\meta{p}, \\{\\meta{exp}, \\ldots \\}\\)\n\n\\end{Syntax}\n\nwhere \\meta{p} is an expression, and \\{\\meta{exp}, ... \\} is\na list of expressions or equations.\n\n\n\\name{Preduce} computes the remainder of \\name{exp}\nmodulo the given set of polynomials resp. equations.\nThis result is unique (canonical) only if the given set\nis a \\name{groebner} basis under the current \\nameref{term order}\n\nsee also: \\nameref{preducet} operator.\n\n\\end{Operator}\n\n\n%-------------------------------------------\n\n\\begin{Operator}{idealquotient}\n\\begin{Syntax}\n\n\\name{idealquotient}\\(\\{\\meta{exp}, ...\\}, \\meta{d}\\)\n\n\\end{Syntax}\nwhere \\{\\meta{exp},...\\} is a list of \nexpressions or equations,  \\meta{d} is a single expression or equation.\n\n\n\\name{Idealquotient} computes the ideal quotient:\nideal spanned by the expressions \\{\\meta{exp},...\\}\ndivided by the single polynomial/expression \\meta{f}. The result\nis the \\nameref{groebner} basis of the quotient ideal.\n\\end{Operator}\n\n%-------------------------------------------------------------\n\n\\begin{Operator}{hilbertpolynomial}\n\\index{Hollmann algorithm}\n\\begin{Syntax}\n\n  hilbertpolynomial\\(\\meta{bas}\\)\n\n\\end{Syntax}\nwhere \\meta{bas} is a \\nameref{groebner} basis in the\ncurrent \\nameref{term order}.\n\nThe degree of the \\name{Hilbert polynomial} is the\ndimension of the ideal spanned by the basis. For an\nideal of dimension zero the Hilbert polynomial is a\nconstant which is the number of common zeros of the\nideal (including eventual multiplicities).\nThe \\name{Hollmann algorithm} is used.\n\\end{Operator}\n\n%-------------------------------------------\n\n\\begin{Operator}{saturation}\n\\begin{Syntax}\n\n\\name{saturation}\\(\\{\\meta{exp}, ...\\}, \\meta{p}\\)\n\n\\end{Syntax}\nwhere \\{\\meta{exp},...\\} is a list of\nexpressions or equations,  \\meta{p} is a single polynomial.\n\n\\name{Saturation} computes the quotient of the polynomial \\meta{p}\nand a power (with unknown but finite exponent) of the ideal built from\n\\{\\meta{exp}, ...\\}. The result is the computed quotient. \\name{Saturation}\ncalls \\nameref{idealquotient} several times until the result does not change\nany more.\n\\end{Operator}\n\n%-------------------------------------------------------------\n\\subsection{Factorizing Groebner bases}\n%-------------------------------------------------------------\n\n\\begin{Operator}{groebnerf}\n\\begin{Syntax}\n\n\\name{groebnerf}\\(\\{\\meta{exp}, ...\\}[,\\{\\},\\{\\meta{nz}, ... \\}]\\);\n\n\\end{Syntax}\nwhere \\{\\meta{exp}, ... \\} is a list of expressions or\nequations, and \\{\\meta{nz},... \\} is\nan optional list of polynomials to be considered as non zero\nfor this calculation. An empty list must be passed as second argument\nif the non-zero list is specified.\n\n\n\\name{groebnerf} tries to separate polynomials into individual factors and\nto branch the computation in a recursive manner (factorization tree).\nThe result is a list of partial Groebner bases. \nMultiplicities (one factor with a higher power, the same partial basis\ntwice) are deleted as early as possible in order to speed up the\ncalculation. \n\nThe third parameter of \\name{groebnerf} declares some polynomials\nnonzero. If any of these is found in a branch of the calculation\nthe branch is canceled. \n\n\\begin{Bigexample}\ngroebnerf({ 3*x**2*y+2*x*y+y+9*x**2+5*x = 3,  \n            2*x**3*y-x*y-y+6*x**3-2*x**2-3*x = -3, \n            x**3*y+x**2*y+3*x**3+2*x**2 }, {y,x});\n\n       {{Y - 3,X},\n\n                      2\n    {2*Y + 2*X - 1,2*X  - 5*X - 5}}\n\\end{Bigexample}\n\n\\begin{Related}\n\\item[ \\nameref{groebresmax} variable]\n\\item[ \\nameref{groebmonfac} variable]\n\\item[ \\nameref{groebrestriction} variable]\n\\item[ \\nameref{groebner} operator]\n\\item[ \\nameref{gvarslast} variable]\n\\item[ \\nameref{groebopt} switch]\n\\item[ \\nameref{groebprereduce} switch]\n\\item[ \\nameref{groebfullreduction} switch]\n\\item[ \\nameref{gltbasis} switch]\n\\item[ \\nameref{gltb} variable]\n\\item[ \\nameref{glterms} variable]\n\\item[ \\nameref{groebstat} switch]\n\\item[ \\nameref{trgroeb} switch]\n\\item[ \\nameref{trgroebs} switch]\n\\item[ \\nameref{groebnert} operator]\n\\end{Related}\n\n\\end{Operator}\n\n% ------------------------------------------------------------------\n\n\\begin{Variable}{groebmonfac}\nThe variable \\name{groebmonfac} is connected to\nthe handling of monomial factors.  A monomial factor is a product\nof variable powers as a factor, e.g. x**2*y  in  x**3*y -\n2*x**2*y**2.  A monomial factor represents a solution of the type\n x = 0  or  y = 0 with a certain multiplicity.  With\n\\nameref{groebnerf} the multiplicity of monomial factors is lowered \nto the value of the shared variable \\name{groebmonfac}\nwhich by default is 1 (= monomial factors remain present, but their\nmultiplicity is brought down). With\n\\name{groebmonfac}:= 0\nthe monomial factors are suppressed completely.\n\\end{Variable}\n\n% ----------------------------------------------------------------\n\\begin{Variable}{groebresmax}\nThe variable \\name{groebresmax}\ncontrols  during \\nameref{groebnerf} calculations\nthe number of partial results. Its default value is 300. If\nmore partial results are calculated, the calculation is\nterminated.\n\\end{Variable}\n\n% ----------------------------------------------------------------\n\\begin{Variable}{groebrestriction}\nDuring \\nameref{groebnerf} calculations \nirrelevant branches can be excluded\nby setting the variable \\name{groebrestriction}. The\nfollowing restrictions are implemented:\n\\begin{Syntax} \n     \\name{groebrestriction} := \\name{nonnegative} \\\\\n     \\name{groebrestriction} := \\name{positive}\\\\\n     \\name{groebrestriction} := \\name{zeropoint}\n\\end{Syntax}\nWith \\name{nonnegative} branches are excluded where one\npolynomial has no nonnegative real zeros; with \\name{positive}\nthe restriction is sharpened to positive zeros only.\nThe restriction \\name{zeropoint} excludes all branches\nwhich do not have the origin (0,0,...0) in their solution\nset.\n\\end{Variable}\n\n%---------------------------------------------------------\n\\subsection{Tracing Groebner bases}\n%---------------------------------------------------------\n\\index{tracing Groebner}\n\\begin{Switch}{groebprot}\nIf \\name{groebprot} is \\name{ON} the computation steps during\n\\nameref{preduce}, \\nameref{greduce} and \\nameref{groebner}\nare collected in a list which is assigned to the variable\n\\nameref{groebprotfile}.\n\\end{Switch}\n%----------------------------------------------------------\n\\begin{Variable}{groebprotfile}\nSee \\nameref{groebprot} switch.\n\\end{Variable}\n%----------------------------------------------------------\n\n\\begin{Operator}{groebnert}\n\\begin{Syntax}\n\n  \\name{groebnert}\\(\\{\\meta{v}=\\meta{exp},...\\}\\)\n\n\\end{Syntax}\nwhere \\meta{v} are \\nameref{kernel}\\name{s} (simple or indexed variables),\n\\meta{exp} are polynomials.\n\n\n\\name{groebnert} is functionally equivalent to a \\nameref{groebner}\ncall for \\{\\meta{exp},...\\}, but the result is a set of\nequations where the left-hand sides are the basis elements while\nthe right-hand sides are the same values expressed as combinations\nof the input formulas, expressed in terms of the names \\meta{v}\n\\begin{Bigexample}\n    groebnert({p1=2*x**2+4*y**2-100,p2=2*x-y+1});\n\n   GB1 := {2*X - Y + 1=P2,\n\n           2\n        9*Y  - 2*Y - 199= - 2*X*P2 - Y*P2 + 2*P1 + P2}\n\\end{Bigexample}\n\\end{Operator}\n%----------------------------------------------------------\n\n\\begin{Operator}{preducet}\n\\begin{Syntax}\n\n\\name{preduce}\\(\\meta{p},\\{\\meta{v}=\\meta{exp}...\\}\\)\n\\end{Syntax}\nwhere \\meta{p} is an expression, \\meta{v} are kernels \n(simple or indexed variables),\n\\name{exp} are polynomials.\n\n\\name{preducet} computes the remainder of \\meta{p} modulo \\{\\meta{exp},...\\}\nsimilar to \\nameref{preduce}, but the result is an equation\nwhich expresses the remainder as combination of the polynomials.\n\\begin{Bigexample}\n                             \n   GB2 := {G1=2*X - Y + 1,G2=9*Y**2  - 2*Y - 199}\n   preducet(q=x**2,gb2);\n\n - 16*Y + 208= - 18*X*G1 - 9*Y*G1 + 36*Q + 9*G1 - G2\n\\end{Bigexample}\n\\end{Operator}\n\n%------------------------------------------------------------\n\\subsection{Groebner Bases for Modules}\n%------------------------------------------------------------\n\\begin{Concept}{Module}\nGiven a polynomial ring, e.g. R=Z[x,y,...] and an integer n>1.\nThe vectors with n elements of R form a free MODULE under\nelementwise addition and multiplication with elements of R.\n\nFor a submodule given by a finite basis a Groebner basis\ncan be computed, and the facilities of the GROEBNER package\nare available except the operators \\nameref{groebnerf}\nand \\name{groesolve}. The vectors are encoded using auxiliary\nvariables which represent the unit vectors in the module.\nThese are declared in the share variable \\nameref{gmodule}.\n\n\\end{Concept}\n\n\\begin{Variable}{gmodule}\nThe vectors of a free \\nameref{module} over a polynomial ring R \nare encoded as linear combinations with unit vectors of\nM which are represented by auxiliary variables. These\nmust be collected in the variable \\name{gmodule} before\nany call to an operator of the Groebner package.\n\n\\begin{verbatim}\n   torder({x,y,v1,v2,v3})$\n   gmodule := {v1,v2,v3}$\n   g:=groebner({x^2*v1 + y*v2,x*y*v1 - v3,2y*v1 + y*v3});\n\\end{verbatim}\n\ncompute the Groebner basis of the submodule\n\n\\begin{verbatim}\n      ([x^2,y,0],[xy,0,-1],[0,2y,y])\n\\end{verbatim}\nThe members of the list \\name{gmodule} are automatically\nappended to the end of the variable list, if they are not\nyet members there. They take part in the actual term ordering.\n\\end{Variable}\n\n%------------------------------------------------------------\n\\subsection{Computing with distributive polynomials}\n%------------------------------------------------------------\n\n\\begin{Operator}{gsort}\n\\index{distributive polynomials}\n\\begin{Syntax}\n\n \\name{gsort}\\(\\meta{p}\\)\n\\end{Syntax}\nwhere \\meta{p} is a polynomial or a list of polynomials.\n\nThe polynomials are reordered and sorted corresponding to\nthe current \\nameref{term order}.\n\\begin{Examples}\n\n  torder lex;\\\\  \n  gsort(x**2+2x*y+y**2,{y,x});  &  {y**2+2y*x+x**2}\n\n\\end{Examples}\n\\end{Operator}\n\n%------------------------------------------------------------\n\n\\begin{Operator}{gsplit}\n\\index{distributive polynomials}\n\\begin{Syntax}\n\n \\name{gsplit}\\(\\meta{p}[,\\meta{vars}]\\);\n\\end{Syntax}\nwhere \\meta{p} is a polynomial or a list of polynomials.\n\nThe polynomial is reordered corresponding to the \nthe current \\nameref{term order} and then\nseparated into leading term and reductum. Result is\na list with the leading term as first and the reductum\nas second element.\n\\begin{Examples}\n\n  torder lex;\\\\  \n  gsplit(x**2+2x*y+y**2,{y,x});  &  \\{y**2,2y*x+x**2\\}\n\n\\end{Examples}\n\\end{Operator}\n%-------------------------------------------------------\n\n\\begin{Operator}{gspoly}\n\\index{distributive polynomials}\n\\begin{Syntax}\n\n \\name{gspoly}\\(\\meta{p1},\\meta{p2}\\);\n\n\\end{Syntax}\nwhere \\meta{p1} and \\meta{p2} are polynomials.\n\nThe \\name{subtraction} polynomial of p1 and p2 is computed\ncorresponding to the method of the Buchberger algorithm for\ncomputing \\name{groebner bases}: p1 and p2 are multiplied\nwith terms such that when subtracting them the leading terms \ncancel each other.\n\\end{Operator}\n\n", "meta": {"hexsha": "696e18cd30d6a4ca52f421a5ece593b46c2a71ac", "size": 33207, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/groebner/pk-groeb.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/groebner/pk-groeb.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/groebner/pk-groeb.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.439701174, "max_line_length": 79, "alphanum_fraction": 0.6787424338, "num_tokens": 8687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.4068200217674952}}
{"text": "\\chapter{Direct backward ray mapping}\n\\label{chap:raymapping2}\nIn Chapter \\ref{chap:raymapping1} we introduced an inverse method based on ray mapping reconstruction in PS.\nThe goal was to calculate the intensity distribution at the target of an optical system. \\\\ \\indent\nThe idea was to construct a map from the target \\point{T} to the source \\point{S} using the PS of all the optical lines, which are divided into several regions.  \nThe method developed in the previous chapter requires that the boundaries of these regions can be determined exactly in every PS. Therefore, also the positive luminance regions were found analytically and the \\textit{exact} intensity could be determined. This is only possible for systems formed by straight line segments.\\\\ \\indent\nIn this chapter we modify the method to systems formed by curved lines. In this case, the boundaries of the regions in PS cannot be determined exactly.\nBecause of this, we need to apply a numerical procedure. In particular, we develop a method that employs only the PS of the target of the system. \n% Differences\nThe boundaries are detected applying a bisection procedure in target PS in combination with backward ray tracing. The method is tested for two optical systems: the TIR-collimator and a parabolic reflector. The results are presented in Section \\ref{sec:TIR} and \\ref{sec:PR}, respectively.\n\\section{Bisection method and backward ray tracing}\\label{sec:raymapping_explanation}\nThe purpose of this section is to present the direct backward ray mapping method valid for systems formed by curved lines. \nGiven a partition $P: -1 = \\variabile{p}^0<\\variabile{p}^1<\\cdots<\\variabile{p}^{\\nbin}=1$ of the interval $[-1,1]$ with $\\nbin$ the number of bins in the partitioning, the intensity in target PS is given by Equation (\\ref{eta2}) for every $\\dir{}{}\\in P$.\nTherefore, the problem reduces to calculating the coordinates \n$\\variabile{q}^{\\textrm{\\,min}}(\\Pi, \\variabile{p})$ and $\\variabile{q}^{\\textrm{\\,max}}(\\Pi, \\variabile{p})$ of the rays on $\\partial$\\set{R}{}{}$(\\Pi)$ for every path $\\Pi$. \n\\\\ \\indent \nWe indicate with $(\\variabile{q}^{\\,\\textrm{a}}, \\variabile{p})= (-\\variabile{b}, \\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{b}}, \\variabile{p}) = (\\variabile{b}, \\variabile{p})$ the coordinates of the end points of \\set{T}{}{} along direction $\\variabile{p}$. These points are associated to two rays in PS. Consider the corresponding position coordinate $(\\variabile{x}^{\\textrm{a}}, \\variabile{z}^{\\textrm{a}})$ and $(\\variabile{x}^{\\textrm{b}}, \\variabile{z}^{\\textrm{b}})$ and angular coordinates $\\optangle^{\\variabile{a}}$ and $\\optangle^{\\variabile{b}}$ of the ray in real space, where $\\variabile{x}^{\\textrm{a}} = \\variabile{q}^{\\textrm{a}}$, $\\variabile{x}^{\\textrm{b}} = \\variabile{q}^{\\textrm{b}}$, $\\variabile{z}^{\\textrm{a}} = \\variabile{z}^{\\textrm{b}} = \\variabile{h}$ where $\\variabile{h}$ is the height of the target and $\\optangle^{\\textrm{a}}= \\optangle^{\\textrm{b}}=\\variabile{p}$ refers to the emitted ray. Next, the rays parametrizations $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$ are determined according to (\\ref{parametrization}).\nWe remind the reader that, in real space, the coordinates of each ray on line $\\lineai\\neq \\nline$ are indicated with $(\\variabile{x}_{\\lineai}, \\variabile{z}_{\\lineai})$ and $\\optangle_{\\lineai}$ where $(\\variabile{x}_{\\lineai}, \\variabile{z}_{\\lineai})$ are the coordinate of the intersection point between the ray and line $\\lineai$ and $\\optangle_{\\lineai}$ is the direction of the incident ray with respect to the \\textit{optical axis}. \n%We remind the reader that in the previous chapter we indicated with $(\\pos{t,}{\\lineai},\\dir{t,}{\\lineai})$ the coordinates of the rays in target PS \\set{T}{\\lineai}{} in where the directions coordinates were expressed with respect to the \\textit{normal} of line $\\lineai$. Note that $\\pos{\\lineai}{}=\\pos{t,}{\\lineai}$ while $\\dir{\\lineai}{}\\neq\\dir{t,}{\\lineai}$. We introduce the notation $(\\pos{\\lineai}{}^{\\textrm{a}}, \\dir{\\lineai}{}^{\\textrm{a}})$ for the coordinates of ray $\\vect{r}_{\\textrm{a}}(s)$ on line $\\lineai$.\\\\ \\indent \nThe procedure starts with intensity $I(\\variabile{p})=0$ and the end points $(\\variabile{q}^{\\,\\textrm{a}}, \\variabile{p})= (-\\variabile{b}, \\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{b}}, \\variabile{p}) = (\\variabile{b}, \\variabile{p})$. Since the boundaries of the regions in all the phase spaces are unknown, to determine from which line $\\vect{r}_{\\textrm{a}}$ and $\\vect{r}_{\\textrm{b}}$ are emitted we apply backward ray tracing. We denote with $\\nline$ the index of the target (line $\\nline$) and with $\\lineaj\\in\\{1,\\cdots, \\nline-1\\}$ and $\\lineak\\in\\{1,\\cdots, \\nline-1\\}$ the lines from which the rays with parametrization $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$ are emitted, respectively. $\\Pi^\\textrm{a} = (\\lineaj, \\nline)$ and $\\Pi^\\textrm{b} = (\\lineak,\\nline)$ are the last part of the paths followed by the two rays $\\vect{r}_{\\textrm{a}}$ and $\\vect{r}_{\\textrm{b}}$, respectively, and $(\\variabile{q}^{\\textrm{a}}, \\variabile{p})\\in\\partial$\\set{R}{}{}$(\\Pi^{\\textrm{a}})$ and $(\\variabile{q}^{\\textrm{b}}, \\variabile{p})\\in\\partial$\\set{R}{}{}$(\\Pi^{\\textrm{b}})$. At this stage we know whether the two rays are emitted from the same line or not. \\\\ \\indent \nFirst, assume $\\lineaj= \\lineak$, then $\\vect{r}_{\\textrm{a}}$ and $\\vect{r}_{\\textrm{b}}$ hit the same line before reaching the target. \nIn case $\\lineaj = 1$ a possible path from the source to the target is found and, assuming a Lambertian source, the intensity is updated according to:\n\\begin{equation}\\label{eq:intensity_brm}\nI(\\variabile{p}) = I(\\variabile{p})+\\variabile{q}^{\\textrm{max}}(\\Pi^\\textrm{a}, \\variabile{p})-\\variabile{q}^{\\textrm{min}}(\\Pi^\\textrm{a}, \\variabile{p}),\n\\end{equation}\nwhere $\\variabile{q}^{\\textrm{min}}(\\Pi^\\textrm{a}, \\variabile{p}) = \\variabile{q}^{\\textrm{min}} = \\min\\{\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}\\}$ and $\\variabile{q}^{\\textrm{max}}(\\Pi^\\textrm{a}, \\variabile{p}) = \\variabile{q}^{\\textrm{max}} = \\max\\{\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}\\}$. In case $\\lineaj\\neq 1$ the two rays $\\vect{r}_{\\textrm{a}}$ and $\\vect{r}_{\\textrm{b}}$ are traced back further using backward ray tracing.\n\\\\ \\indent Next, if $\\lineaj\\neq \\lineak$ the rays $\\vect{r}_\\textrm{a}$ and $\\vect{r}_\\textrm{b}$ are emitted from two different lines, hence $\\Pi^{\\textrm{a}}\\neq \\Pi^{\\textrm{b}}$ and belong to different regions \\set{R}{}{}$(\\Pi^{\\textrm{a}})$ and \\set{R}{}{}$(\\Pi^{\\textrm{b}})$ in \\set{T}{}{}. $\\variabile{q}^{\\textrm{a}}$ in $\\mbox{\\set{R}{}{}}(\\Pi^{\\textrm{b}})$, the other intersection points of line \n$\\variabile{p}=\\textrm{const}$ with the boundary $\\mbox{\\set{R}{}{}}(\\Pi^{\\textrm{b}})$ are unknown. To determine the other coordinates of the rays on the boundary $\\partial$\\set{R}{}{}$(\\Pi^{\\textrm{a}})$, the bisection method is applied to the segment $[\\variabile{q}^{\\,\\textrm{a}}(\\Pi^{\\textrm{a}}, \\variabile{p}), \\variabile{q}^{\\,\\textrm{b}}(\\Pi^{\\textrm{b}}, \\variabile{p})]$ in target PS \\set{T}{}{} along direction $\\variabile{p}$. Thus, this interval is repeatedly halved until the position coordinate in target PS of the ray that follows the same path $\\Pi^{\\textrm{a}}$ of $\\vect{r}_{\\textrm{a}}$ is found (the corresponding direction coordinate $\\variabile{p}$ is fixed). The bisection procedure continues until the length of the segment considered becomes smaller than a fixed tolerance. \nGiving as input the coordinates $\\variabile{q}^{\\,\\textrm{a}}(\\Pi^{\\textrm{a}}, \\variabile{p})$ and $\\variabile{q}^{\\,\\textrm{b}}(\\Pi^{\\textrm{b}}, \\variabile{p})$ of the rays with parametrization $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$, the path $\\Pi^\\textrm{a}$ and the tolerance $\\textrm{tol}= 10^{-12}$, the bisection method is implemented as in Algorithm \\ref{alg:bisection}. Similarly, others paths will be obtained later using the same procedure applied to another interval in target PS.\n\\begin{algorithm}\n\\caption{Bisection($\\variabile{q}^{\\,\\textrm{a}}(\\Pi^{\\textrm{a}}, \\variabile{p})$, $\\variabile{q}^{\\,\\textrm{b}}(\\Pi^{\\textrm{b}}, \\variabile{p})$,$\\vect{r}_{\\textrm{a}}(s)$, $\\vect{r}_{\\textrm{b}}(s)$, \\textrm{tol}, $\\Pi^\\textrm{a}$)}\\label{alg:bisection}\nInitialize: $\\textrm{step} = 0$, $\\lineai = \\nline$\n\\begin{algorithmic}[1]\n\\While {$|\\variabile{q}^{\\,\\textrm{a}}-\\variabile{q}^{\\,\\textrm{b}}|>\\textrm{tol}$}\n\\State $\\variabile{x}_{\\lineai}^{\\textrm{m}}=\\variabile{q}^{\\,\\textrm{m}}= (\\variabile{q}^{\\,\\textrm{a}}+\\variabile{q}^{\\,\\textrm{b}})/2,$ \n\\State $\\variabile{z}_{\\lineai}^{\\textrm{m}}= \\variabile{z}^{\\textrm{a}}$\n\\State $\\optangle_{\\lineai}^{\\textrm{m}}=\\variabile{p}^{\\,\\textrm{m}}=\\variabile{p}$\n\\State $\\Pi^{\\textrm{m}}= (\\nline)$\n\\State Consider the parametrization $\\vect{r}_{\\textrm{m}}$ of the ray corresponding to $(\\variabile{x}_{\\lineai}^{\\,\\textrm{m}}, \\variabile{z}_{\\lineai}^{\\,\\textrm{m}})$ and $\\optangle_{\\lineai}^{\\textrm{m}}$,\n%\\State $\\vect{r}_{\\textrm{m}}= \\variabile{q}^{\\,\\textrm{m}}+s \\variabile{p}$ with $s>0$ the arc-length,\n\\While {$\\textrm{step}<\\mbox{length}(\\Pi^\\textrm{a})-1$}\n\\State Trace back the ray with parametrization $\\vect{r}_{\\textrm{m}}$ from $\\lineai$\n\\State Find the line $\\lineaj$ that the ray hits \n\\State Find the coordinates $(\\variabile{x}^{\\textrm{m}}_{\\lineaj}, \\variabile{z}^{\\textrm{m}}_{\\lineaj})$ on line $\\lineaj$\n\\State Calculate the new direction $\\optangle_{\\lineai}^{\\textrm{m}}$ with respect to the optical axis\n\\State $\\Pi^{\\textrm{m}}=(\\lineaj,\\Pi^{\\textrm{m}})$.\n\\If {$\\lineaj=1$ or $\\lineaj=\\nline$}\n\\State $\\textrm{step} = \\mbox{length}(\\Pi^\\textrm{a})$ \\Comment If the source or the target are reached \\\\  \\Comment then exit from the while loop.\n\\Else \\State $\\textrm{step}=\\textrm{step}+1$ \n\\EndIf\n\\EndWhile\n\\If {$\\Pi^\\textrm{a} = \\Pi^\\textrm{m}$}\n\\State $\\variabile{q}^{\\,\\textrm{a}}= \\variabile{q}^{\\,\\textrm{m}}$\n\\State $\\vect{r}_{\\textrm{a}}= \\vect{r}_{\\textrm{m}}$\n\\Else \n\\State $\\variabile{q}^{\\,\\textrm{b}}= \\variabile{q}^{\\,\\textrm{m}}$\n%\\State $\\vect{r}_{\\textrm{b}}\\gets \\vect{r}_{\\textrm{m}}$\n\\State $\\Pi^\\textrm{b} =  \\Pi^{\\textrm{m}}$\n\\EndIf\n\\EndWhile\n\\State $\\variabile{q}^{\\,\\textrm{c}}= \\variabile{q}^{\\,\\textrm{a}}, \\Pi^\\textrm{c}= \\Pi^{\\textrm{a}}.$\n\\State $\\variabile{q}^{\\,\\textrm{d}}= \\variabile{q}^{\\,\\textrm{b}}, \\Pi^\\textrm{d}= \\Pi^{\\textrm{b}}.$\n\\State \\Return $(\\variabile{q}^{\\,\\textrm{c}}, \\variabile{p})$, $(\\variabile{q}^{\\,\\textrm{d}}, \\variabile{p})$, $\\Pi^{\\textrm{c}}$ and $\\Pi^{\\textrm{d}}$.\n\\end{algorithmic}\n\\end{algorithm}\n\\\\ \\indent Once bisection stops, two points with coordinates $(\\variabile{q}^{\\,\\textrm{c}}, \\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{d}}, \\variabile{p})$ in \\set{T}{}{} are found. The corresponding rays $\\vect{r}_{\\textrm{c}}$ and $\\vect{r}_{\\textrm{d}}$ follow path $\\Pi^{\\textrm{c}}=\\Pi^{\\textrm{a}}$ and $\\Pi^{\\textrm{d}}\\neq\\Pi^{\\textrm{a}}$. \nAll the rays with target coordinates $(\\variabile{q}, \\variabile{p})$ and $\\variabile{q}^{\\,\\textrm{a}}\\leq\\variabile{q}\\leq\\variabile{q}^{\\,\\textrm{c}}$ follow path $\\Pi^{\\textrm{a}}$, while the rays with target coordinates $(\\variabile{q}, \\variabile{p})$ with $\\variabile{q}^{\\,\\textrm{d}}\\leq\\variabile{q}\\leq\\variabile{q}^{\\,\\textrm{b}}$ follow another path $\\Pi \\neq \\Pi^{\\textrm{a}}$ (see Figure \\ref{fig:bisec}). \n%To clarify the procedure, in Figure \\ref{fig:bisec} we show an example of target PS of an optical system where Algorithm \\ref{alg:bisection} is run for the interval $[\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}]$ along direction $\\variabile{p}=0$. Applying bisection the coordinates $(\\variabile{q}^{\\textrm{c}}(\\variabile{p}), \\variabile{p})$ and $(\\variabile{q}^{\\textrm{d}}(\\variabile{p}), \\variabile{p})$ of two points are found. The corresponding rays follow the paths $\\Pi^{\\textrm{c}}$ and $\\Pi^{\\textrm{d}}$, where $\\Pi^{\\textrm{c}}= \\Pi^{\\textrm{a}}\\neq\\Pi^{\\textrm{d}}$. If $\\Pi^{\\textrm{c}}$ is a path from the source to the target, Algorithm \\ref{alg:bisection} is applied to the sub-interval \n%$[\\variabile{q}^{\\textrm{a}}(\\variabile{p}), \\variabile{q}^{\\textrm{c}}(\\variabile{p})]$, otherwise the it is applied again to the sub-interval $[\\variabile{q}^{\\textrm{d}}(\\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\variabile{p})]$. The bisection procedure is repeated for all the sub-intervals found along direction $\\variabile{p}$, until the entire interval $[\\variabile{q}^{\\textrm{a}}(\\variabile{p}), \\variabile{q}^{\\textrm{c}}(\\variabile{p})]$ is investigated.\n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{T4_1_example}\n  \\end{center}\n  \\caption{\\textbf{Bisection in target PS \\set{T}{}{}.} Algorithm \\ref{alg:bisection} is run for the interval $[\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}]$ along direction $\\variabile{p}=0$. The coordinates $\\variabile{q}^{\\textrm{c}}$ and $\\variabile{q}^{\\textrm{d}}$ are found such that \n$|\\variabile{q}^{\\textrm{c}}-\\variabile{q}^{\\textrm{d}}|<\\textrm{tol}$. $\\Pi^{\\textrm{c}}= \\Pi^{\\textrm{a}}$ and $\\Pi^{\\textrm{d}}\\neq \\Pi^{\\textrm{a}}$.}\n\\label{fig:bisec}\n \\end{figure}\n\\\\ \\indent Now, if $\\lineaj\\neq1$ the procedure applied to the interval \n$[\\variabile{q}^{\\textrm{a}}(\\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\variabile{p})]$ needs to be applied to $[\\variabile{q}^{\\textrm{a}}(\\variabile{p}),\\variabile{q}^{\\textrm{c}}(\\variabile{p})]$ until the source is reached, i.e., until $\\lineaj=1$. If $\\lineaj=1$, the source is reached by the rays traced back from the target. This means that a possible path $\\Pi^{\\textrm{a}}$ from \\point{S} to \\point{T} is found and the position coordinates $\\variabile{q}^{\\textrm{\\,min}}(\\Pi^{\\textrm{a}}, \\variabile{p})$ and $\\variabile{q}^{\\textrm{\\,max}}(\\Pi^{\\textrm{a}}, \\variabile{p})$ are determined and the intensity is updated according to (\\ref{eq:intensity_brm}).\n%Next, all the possible paths along direction $\\variabile{p}$ are detected by sequentially applying bisection until all the interval $[\\variabile{q}^{\\textrm{a}}(\\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\variabile{p})]$ is investigated. \n\\\\ \\indent \nFinally, to detect all possible paths that can occur along direction $\\variabile{p}$ the procedure explained above is applied also to the interval $[\\variabile{q}^{\\textrm{d}}(\\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\variabile{p})]$ along direction $\\variabile{p}$ continuing until the entire interval $[\\variabile{q}^{\\textrm{a}}(\\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\variabile{p})]$ is investigated. \nThe main steps of the method are outlined in the following.\n\\begin{enumerate}\n\\item Given a direction \\variabile{p}, the end points $(\\variabile{q}^{\\,\\textrm{a}}, \\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{b}}, \\variabile{p})$ of the target PS \\set{T}{}{}, where $\\variabile{q}^{\\,\\textrm{a}} = -\\variabile{b}$, $\\variabile{q}^{\\,\\textrm{b}} = \\variabile{b}$. Start from $\\lineai=\\nline$.\n\\item \\label{ray trace} Using backward ray tracing, trace back from line $\\lineai$ the rays with parametrizations $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_\\textrm{b}(s)$ corresponding to the position coordinates $(\\variabile{x}_{\\lineai}^{\\,\\textrm{a}}, \\variabile{z}_{\\lineai}^{\\,\\textrm{a}})$ and $ (\\variabile{x}_{\\lineai}^{\\,\\textrm{b}}, \\variabile{z}_{\\lineai}^{\\,\\textrm{b}})$ and the angular coordinates $\\optangle_{\\lineai}^{\\textrm{a}}$ and $\\optangle_{\\lineai}^{\\textrm{b}}$, respectively. \n%considering the directions $\\variabile{p}_{\\lineai}^{\\,\\textrm{a}}$ and $\\variabile{p}_{\\lineai}^{\\,\\textrm{b}}$ with respect to the optical axis. \n%We remind the reader that we indicate with $\\variabile{p}_{\\lineai}^{\\,\\textrm{a}}$ and $\\variabile{p}_{\\lineai}^{\\,\\textrm{b}}$ on \\set{T}{\\lineai}{} the rays directions with respect to the normal of line $\\lineai$. Hence, if $\\lineai=\\nline $ then $\\variable{p}_{\\lineai}^{\\,\\textrm{a}}=\\variabile{p}_{\\lineai}^{\\,\\textrm{b}}=\\variabile{p}$, otherwise $\\variabile{p}_{\\lineai}^{\\,\\textrm{a}}\\neq\\variabile{p}_{\\lineai}^{\\,\\textrm{b}}$.\n\\item Determine indices $\\lineaj\\neq\\lineai$ and $\\lineak\\neq\\lineai$ of the lines from which the rays with parametrizations $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$ originated.\n\\item Consider the new rays parametrization $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$ corresponding to the coordinates $(\\variabile{x}_{\\lineaj}^{\\textrm{a}}, \\variabile{z}_{\\lineaj}^{\\textrm{a}})$, $\\optangle_{\\lineaj}^{\\textrm{a}}$ and $(\\variabile{x}_{\\lineak}^{\\textrm{a}}, \\variabile{z}_{\\lineak}^{\\textrm{b}})$, $\\optangle_{\\lineak}^{\\textrm{b}}$, respectively.\n\\item Update the paths $\\Pi^\\textrm{a}$ and $\\Pi^\\textrm{b}$: $\\Pi^\\textrm{a} = (\\lineaj, \\Pi^{\\textrm{a}})$ and $\\Pi^\\textrm{b} = (\\lineak, \\Pi^\\textrm{b})$\n\\item If $\\lineaj=\\lineak \\neq 1$ and $\\lineaj=\\lineak \\neq \\nline$\n\\begin{itemize}\n\\item Set $\\lineai=\\lineaj$\n%\\item Consider the coordinates of rays $\\vect{r}_{\\textrm{a}}$ and $\\vect{r}_{\\textrm{b}}$ on line $\\lineaj$ \n\\item Restart the procedure from point $\\ref{ray trace}$\n\\end{itemize}\n\\item If $\\lineaj=\\lineak= 1$ \n\\begin{itemize}\n\\item A relevant path $\\Pi^{\\textrm{a}} = \\Pi^{\\textrm{b}}$ is found. \n\\item Determine \n\\begin{equation*}\n\\begin{aligned}\n\\variabile{q}^{\\textrm{min}}(\\Pi^{\\textrm{a}}, \\variabile{p})&=\\min\\{\\variabile{q}^{\\textrm{a}}(\\Pi^{\\textrm{a}}, \\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\Pi^{\\textrm{b}}, \\variabile{p})\\}\\\\ \n\\variabile{q}^{\\textrm{max}}(\\Pi^{\\textrm{a}}, \\variabile{p})&=\\max\\{\\variabile{q}^{\\textrm{a}}(\\Pi^{\\textrm{a}}, \\variabile{p}), \\variabile{q}^{\\textrm{b}}(\\Pi^{\\textrm{b}}, \\variabile{p})\\}.\n\\end{aligned}\n\\end{equation*}\n\\item Update the intensity $$I(\\variabile{p}) = I(p)+\\variabile{q}^{\\textrm{max}}(\\Pi^{\\textrm{a}}, \\variabile{p})-\\variabile{q}^{\\textrm{min}}(\\Pi^{\\textrm{a}}, \\variabile{p})$$\n\\end{itemize}\n%\\item If $\\lineaj=\\lineak= \\nline$ stop the procedure (the rays reach the target again).\n\\item If $\\lineaj\\neq\\lineak$ \n\\begin{itemize}\n\\item Apply the bisection method to the interval $[\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}]$ along direction $\\variabile{p}$, given the points $(\\variabile{q}^{\\,\\textrm{c}}, \\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{d}}, \\variabile{p})$ in target PS \\set{T}{}{} such that $|\\variabile{q}^{\\,\\textrm{c}}-\\variabile{q}^{\\,\\textrm{d}}|<\\textrm{tol}$. \n\\item If $\\lineaj\\neq\\nline$\n\\begin{itemize}\n\\item Set $\\variabile{q}^{\\textrm{b}} = \\variabile{q}^{\\textrm{c}}$,\n\\item Set $(\\variabile{x}_{\\lineaj}^{\\textrm{b}}, \\variabile{z}_{\\lineaj}^{\\textrm{b}}) = (\\variabile{x}_{\\lineaj}^{\\textrm{c}}, \\variabile{z}_{\\lineaj}^{\\textrm{b}})$ and $\\optangle_{\\lineaj}^{\\textrm{b}}= \\optangle_{\\lineaj}^{\\textrm{c}}$\n\\item Set $\\lineai = \\lineaj$\n\\item Restart from $\\ref{ray trace}$ with the updated coordinates,\n\\end{itemize}\n\\item Update $\\variabile{q}^{\\textrm{a}}= \\variabile{q}^{\\textrm{d}}$,\n\\item $\\Pi^{\\textrm{a}} = \\Pi^{\\textrm{c}}$\n\\item Update $(\\variabile{x}_{\\lineaj}^{\\textrm{a}}, \\variabile{z}_{\\lineaj}^{\\textrm{a}}) = (\\variabile{x}_{\\lineaj}^{\\textrm{d}}, \\variabile{z}_{\\lineaj}^{\\textrm{d}})$ and $\\optangle_{\\lineaj}^{\\textrm{a}}= \\optangle_{\\lineaj}^{\\textrm{d}}$\n\\item Restart from $\\ref{ray trace}$\n\\end{itemize}\n\\end{enumerate}\nGiving as input $I(\\variabile{p})=0$ for every direction $\\variabile{p}$ and the tolerance $\\textrm{tol}=10^{-12}$,\nthe method is defined in the recursive Algorithm \\ref{alg:recursiveraymapping}.\n\\begin{algorithm}\n\\caption{Recursive function for direct backward ray mapping}\\label{alg:recursiveraymapping}\nInitialize: $\\lineai = \\nline$, $\\variabile{q}^{\\,\\textrm{a}}= \\variabile{x}^{\\,\\textrm{a}}_{\\lineai}=-\\variabile{b}$, $\\variabile{q}^{\\,\\textrm{b}}= \\variabile{x}^{\\,\\textrm{b}}_{\\lineai}=\\variabile{b}$, $\\dir{}{}=\\optangle^{\\textrm{a}}_\\lineai=\\optangle^{\\textrm{b}}_\\lineai=\\textrm{const}$, $\\variabile{z}_{\\lineai}^{\\textrm{a}}=\\variabile{z}_{\\lineai}^{\\textrm{b}}= \\variabile{h}$, $\\Pi^{\\textrm{a}}=({\\nline})$.\n\\begin{algorithmic}[1]\n\\Procedure{Intensity computation}{$\\variabile{q}^{\\,\\textrm{a}}$,  $\\variabile{q}^{\\,\\textrm{b}}$, $\\variabile{x}^{\\,\\textrm{a}}_{\\lineai},$  $\\variabile{x}^{\\,\\textrm{b}}_{\\lineai},$ $\\variabile{z}^{\\,\\textrm{a}}_{\\lineai},$  $\\variabile{z}^{\\,\\textrm{b}}_{\\lineai},$ $\\dir{}{}$, $\\optangle^{\\textrm{a}}_{\\lineai}$, $\\optangle^{\\textrm{b}}_{\\lineai}$, $\\Pi^{\\textrm{a}}$, $\\lineai$}\n\\State Apply backward ray tracing to $(\\variabile{x}^{\\,\\textrm{a}}_{\\lineai},\\variabile{z}^{\\textrm{a}}_{\\lineai})$, $\\optangle_{\\lineai}^{\\textrm{a}}$ and $(\\variabile{x}^{\\,\\textrm{b}}_{\\lineai},\\variabile{z}^{\\textrm{b}}_{\\lineai})$, $\\optangle_{\\lineai}^{\\textrm{b}}$ \\State Determine the lines $\\lineaj\\neq\\lineai$ and $\\lineak\\neq\\lineai$ from which $\\vect{r}_{\\textrm{a}}(s)$ and $\\vect{r}_{\\textrm{b}}(s)$ are emitted.\n\\State Update path $\\Pi^{\\textrm{a}}=(\\lineaj, \\Pi^{\\textrm{a}})$\n\\State Calculate the position coordinates $(\\variabile{x}^{\\,\\textrm{a}}_{\\lineaj},\\variabile{z}^{\\textrm{a}}_{\\lineaj})$, $(\\variabile{z}^{\\,\\textrm{b}}_{\\lineaj}, \\variabile{p}^{\\textrm{b}}_{\\lineaj})$ and $\\optangle_{\\lineaj}^{\\textrm{a}}$, $\\optangle_{\\lineaj}^{\\textrm{b}}$.\n\\If {$\\lineaj = \\lineak$}\n\\If{$\\lineaj\\neq1$}\n\\State\\Return{\\Call{Intensity computation}{$\\variabile{q}^{\\,\\textrm{a}},$  $\\variabile{q}^{\\,\\textrm{b}},$ $\\variabile{x}^{\\,\\textrm{a}}_{\\lineaj},$ $\\variabile{x}^{\\,\\textrm{b}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{a}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{b}}_{\\lineaj},$ $\\dir{}{}$, $\\optangle^{\\textrm{a}}_{\\lineaj}$, $\\optangle^{\\textrm{b}}_{\\lineaj}$, $\\Pi^{\\textrm{a}}$, $\\lineaj$}}\n\\Else  \\State Calculate\n$\\variabile{q}^{\\textrm{min}} = \\min\\{\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}\\}$, $\\variabile{q}^{\\textrm{max}} = \\max\\{\\variabile{q}^{\\textrm{a}}, \\variabile{q}^{\\textrm{b}}\\}$\n\\State Assume Lambertian source\n\\State $I(\\dir{}{}) = I(\\dir{}{})+\\variabile{q}^{\\textrm{max}}(\\Pi^{\\textrm{a}}, \\dir{}{})\n-\\variabile{q}^{\\textrm{min}}(\\Pi^{\\textrm{a}}, \\dir{}{})$ \n\\EndIf\n\\Else \n\\State Apply bisection to the segment $[\\variabile{q}^{\\,\\textrm{a}}(\\Pi^\\textrm{a}, \\dir{}{}), \\variabile{q}^{\\,\\textrm{b}}(\\Pi^\\textrm{b}, \\dir{}{})]$\n\\State Find the target coordinates $(\\variabile{q}^{\\,\\textrm{c}},\\variabile{p})$ and $(\\variabile{q}^{\\,\\textrm{d}},\\variabile{p})$ of the rays with parame\\-trization $\\vect{r}_{\\textrm{c}}$ and $\\vect{r}_{\\textrm{d}}$, such that $$|\\variabile{q}^{\\,\\textrm{c}}-\\variabile{q}^{\\,\\textrm{d}}|<\\textrm{tol}$$\n\\If {$\\lineaj\\neq \\nline$}\n\\State\\Return{\\Call{Intensity computation}{$\\variabile{q}^{\\,\\textrm{a}},$  $\\variabile{q}^{\\,\\textrm{c}},$ $\\variabile{x}^{\\,\\textrm{a}}_{\\lineaj},$ $\\variabile{x}^{\\,\\textrm{c}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{a}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{c}}_{\\lineaj},$ $\\dir{}{}$, $\\optangle^{\\textrm{a}}_{\\lineaj}$, $\\optangle^{\\textrm{c}}_{\\lineaj}$, $\\Pi^{\\textrm{a}}$,~$\\lineaj$}}\n\\EndIf \n\\State\\Return{\\Call{Intensity computation}{$\\variabile{q}^{\\,\\textrm{d}},$  $\\variabile{q}^{\\,\\textrm{b}},$ $\\variabile{x}^{\\,\\textrm{d}}_{\\lineaj},$ $\\variabile{x}^{\\,\\textrm{b}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{d}}_{\\lineaj},$ $\\variabile{z}^{\\,\\textrm{b}}_{\\lineaj},$ $\\dir{}{}$, $\\optangle^{\\textrm{d}}_{\\lineaj}$, $\\optangle^{\\textrm{b}}_{\\lineaj}$, $\\Pi^{\\textrm{d}}$, $\\lineaj$}}\n\\EndIf\n\\EndProcedure\n\\end{algorithmic}\n\\end{algorithm}\n\\\\ \\indent The procedure is able to determine all the possible paths that the rays can follow during their propagation from \\set{S}{}{} to \\set{T}{}{}. Also, rays located on the boundaries of the regions with positive luminance in target PS \\set{T}{}{} are found.\nThe method is summarized by the flowchart in Figure \\ref{fig:flowchart_raymapping}\n\\begin{figure}[t]\n  \\begin{center}\n  \\includegraphics[width=\\textwidth]{flowchart_raymapping}\n  \\end{center}\n  \\caption{\\textbf{Main steps of direct backward ray mapping for systems with curved lines.}}\n\\label{fig:flowchart_raymapping}\n \\end{figure}\n\\\\ \\indent\nNext, the method is applied to two optical systems formed by curved lines. In the next section we show the results for the TIR-collimator and in Section \\ref{sec:PR} we provide numerical results for the parabolic reflector.\n\\section{Results for the TIR-collimator}\\label{sec:TIR}\n% Introduction \nIn this section we apply direct backward ray mapping to the TIR-collimator presented in Chapter \\ref{chap:boundaries_alpha} and depicted in Figure \\ref{fig:analyticlens}. The target PS of this system is the rectangular \\set{T}{}{}$= [-\\variabile{b}, \\variabile{b}]\\times[-1,1]$ with $\\variabile{b}=9.7$. The aim is to detect all the possible path $\\Pi$ and the rays located on the boundaries $\\partial$\\set{R}{}{}$(\\Pi)$ of the corresponding regions in target PS. \n\\\\ \\indent In Chapter \\ref{chap:boundaries_alpha}, we found five different paths for the TIR-collimator (see Figure \\ref{fig:Tir2}). The boundaries of the corresponding regions in target PS \\set{T}{}{} are in general difficult to approximate. Furthermore, along one direction $\\dir{}{}$ more than two points can be located on the boundary $\\partial$\\set{R}{}{}$(\\Pi)$ \\set{R}{}{}$(\\Pi)$ corresponding to a certain path $\\Pi$. To determine properly all the boundaries \n$\\partial$\\set{R}{}{}$(\\Pi)$, we need to divide the interval $[-\\variabile{b}, \\variabile{b}]$ in \n\\set{T}{}{} into intervals of the same length. Hence, we consider a partitioning \n$Q = -\\variabile{b}=\\variabile{q}^{0}<\\variabile{q}^{1}<\\cdots<\\variabile{q}^{\\textrm{Ni}}=\\variabile{b}$ of $[-\\variabile{b}, \\variabile{b}]$ where $\\textrm{Ni}$ is the total number of sub-intervals along the $\\variabile{q}$-axis.\nFor each direction $\\dir{}{}\\in [-1,1]$ the procedure explained in Section \\ref{sec:raymapping_explanation} is repeated for every sub-interval $[\\variabile{q}^{\\textrm{k}}(\\dir{}{}), \\variabile{q}^{\\textrm{k}+1}(\\dir{}{})]\\subset [\\variabile{q}^{\\textrm{a}}(\\dir{}{}), \\variabile{q}^{\\textrm{b}}(\\dir{}{})]$ with $\\textrm{k}=0, \\cdots, \\textrm{Ni}-1$ and $\\variabile{q}^{\\textrm{a}}(\\dir{}{}) = -\\variabile{b}$ and $\\variabile{q}^{\\textrm{b}}(\\dir{}{}) = \\variabile{b}$.\\\\ \\indent\nTo establish in how many sub-intervals \\textrm{Ni} we need to divide the target, we exploit \\'{e}tendue conservation. We use the same idea applied to determine the value of $\\alpha$ for the $\\alpha$-shapes method and to provide a stopping criterion for the triangulation refinement (see Chapters \\ref{chap:boundaries_alpha} and \\ref{chap:triangulation}). \nThe source \\'{e}tendue $U_1$ is calculated from (\\ref{eq:Usource}), obtaining roughly $U_1 \\approx 7.7$. The target \\'{e}tendue $U_\\textrm{t}$ is given by Equation (\\ref{eq:etenduetarg1}). $U_\\textrm{t}$ is calculated several times considering every time a different partitioning $Q$ for the $\\variabile{q}$-axis of the target PS. Next, the absolute value of the difference between the source and target \\'{e}tendue is obtained from\n\\begin{equation}\\label{eq:delta_raymapping}\n\\Delta U =  \\big|U_1-U_{\\textrm{t}}\\big|.\n\\end{equation}\nIf a small value of $\\Delta U$ is obtained, then a good approximation of $U_{\\textrm{t}}$ is found and therefore, the partition $Q$ used for the computation of $U_{\\textrm{t}}$ is suitable for detecting correctly the boundaries $\\partial$\\set{R}{}{}$(\\Pi)$. In Figure \\ref{fig:etendue_raymapping_tir} we show how $\\Delta U$ decreases by increasing the number of sub-intervals $\\textrm{Ni}$ in the partitioning $Q$. Note that when $\\textrm{Ni}=100$ the \\'{e}tendue difference is roughly $5\\cdot 10^{-3}$. This can be related to the fact that both the source \\'{e}tendue $U_1$ and the target \\'{e}tendue $U_{\\textrm{t}}$ are approximated.\n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{etendue_raymapping_tir}\n  \\end{center}\n  \\caption{\\textbf{Difference between the source and the target \\'{e}tendue for the TIR-collimator.} $U_{\\textrm{t}}$ is computed four times increasing every time the number of bins $\\textrm{Ni}$ where $\\textrm{Ni}\\in\\{5,10,30,100\\}$. }\n\\label{fig:etendue_raymapping_tir}\n \\end{figure}\nIn Figure \\ref{fig:boundaries_TIR_ray_mapping} we show the distribution of the rays traced using the backward ray mapping method with $\\textrm{Ni}=30$ and $\\nbin = 100.$ \n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{boundaries_ray_mapping_tir}\n  \\end{center}\n  \\caption{\\textbf{Ray distribution at target PS of the TIR-collimator.}\n The $\\variabile{q}$-axis is divided into $\\textrm{Ni}=30$ bins, the $\\variabile{p}$-axis is divided into $\\nbin = 100$ bins. Approximately $6\\cdot10^3$ rays are traced from the target to the source (red dots). Because of numerical errors, a few rays outside the region with positive luminance are found (rays rimmed in blue).}\n\\label{fig:boundaries_TIR_ray_mapping}\n \\end{figure}\nIn this case, backward ray mapping detects $11$ different paths from the source to the target. \nWe observe that only $5$ of them are the paths that we expect from PS ray tracing, which are:\n\\begin{equation}\\label{eq:paths_tir}\n\\begin{array}{llll}\n\\Pi_1&=(1,2,7,12), \\\\\n\\Pi_2&=(1,4,6,7,12), & \\Pi_3&=(1,10,8,7,12),\\\\\n\\Pi_4&=(1,3,7,12), & \\Pi_5&=(1,11,7,12).\n\\end{array}\\end{equation}\n(see Figure \\ref{fig:analyticlens} for the of the line numbering of the TIR-collimator). \nBackward ray mapping also detects the spurious paths:\n\\begin{equation}\\label{eq:paths_tir}\n\\begin{array}{llll}\n\\Pi_6&=(1,2,9,8,7,12), & \\Pi_7&=(1,2,5,6,7,12), \\\\\n\\Pi_8&=(1,2,2,7,12),& \\Pi_9&=(1,7,12),\\\\\n\\Pi_{10}&=(1,2,4,6,7,12),& \\Pi_{11}&=(1,2,10,8,7,12).\n\\end{array}\\end{equation}\nThese paths are due to numerical errors, the corresponding rays are rimmed in blue in Figure \\ref{fig:boundaries_TIR_ray_mapping}. Note that some rays inside different circles might correspond to the same path. The numerical error can be related to the precision of the bisection method and the numerical computation of the intersection points when backward ray tracing is used. We remark that in backward ray tracing, the intersection between the ray and the lens (line $2$) is computed using the Newton-Raphson procedure.\nTo detect only the boundaries of the regions formed by the rays that follow a \\textit{real} path $\\Pi_{\\variabile{j}}$, with $\\variabile{j}\\in\\{1, \\cdots, 5\\}$, we check the index of refraction that every ray has once it arrives at the source.\nIf this is equal to the same index of \\point{S} ($\\n=1$ for the TIR-collimator), then the ray follows a physical path, otherwise it follows one of the paths in (\\ref{eq:paths_tir}) and, therefore, it is not considered for the intensity calculation. This gives the ray distribution at the target PS shown in Figure \\ref{fig:boundaries_TIR_ray_mapping1}. We observe that, discarding those rays, $5$ different paths are found. These are the same paths we obtained using PS ray tracing.\n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{boundaries_ray_mapping_tir2}\n  \\end{center}\n  \\caption{\\textbf{Ray distribution at target PS of the TIR-collimator.}\n The $\\variabile{q}$-axis is divided into $\\textrm{Ni}=30$ bins, the $\\variabile{p}$-axis is divided into $\\nbin = 100$ bins. Considering only the rays that arrive to the source with the correct index of refraction ($\\n=1$), the regions with positive luminance are computed correctly.}\n\\label{fig:boundaries_TIR_ray_mapping1}\n \\end{figure}\nFigure \\ref{fig:boundaries_TIR_ray_mapping1} shows that the rays on the boundaries $\\partial$\\set{R}{}{}$(\\Pi_{\\variabile{j}})$ are determined for every path $\\Pi_{\\variabile{j}}$ with $\\variabile{j}\\in\\{1, \\cdots, 5\\}$. \n\nThe ability of the backward ray mapping method to recognize spurious paths makes it suitable to detect ghost stray light, which is unwanted light that reduce the performance of optical systems \\cite{breault1995control}. Optical designers are interested in developing methods for minimizing stray light intensity \\cite{grabarnik2015optical}. Backward ray mapping could be an alternative approach for such purpose. \n\\\\ \\indent Note that some rays in the interior of the regions are still traced because we divided the target PS along the $\\variabile{q}$-axis into $\\textrm{Ni}=30$ bins. As a consequence, also the rays located at the end points of every bin are traced. \\\\\n\\indent The target PS intensity $\\hat{I}_{\\textrm{PS}}$ is calculated using Equation (\\ref{eq:Ips}). The profile of $\\hat{I}_{\\textrm{PS}}$ with $\\textrm{Ni}=30$ is depicted in Figure \\ref{fig:intensity_tir_raymapping} with the red line. It is compared with the reference intensity (blue line) which is given by QMC ray tracing with $10^7$ rays. The picture shows that the backward ray mapping method calculates the intensity correctly.\n\\begin{figure}[t]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{intensity_tir_raymapping}\n  \\end{center}\n  \\caption{\\textbf{Profile of the intensity for the TIR-collimator.}\n The PS intensity is calculated dividing the $\\variabile{q}$-axis into $\\textrm{Ni}=30$ bins. The reference intensity is obtained from QMC ray tracing with $10^7$ rays.}\n\\label{fig:intensity_tir_raymapping}\n \\end{figure}\n\\\\ \\indent \nFinally, we compare backward ray mapping with QMC ray tracing. The errors are obtained from (\\ref{eq:error}) and are shown in a logarithmic scale in Figure \\ref{fig:error_tir_raymapping} as a function of the CPU-time. The approximation of the PS intensity $\\hat{I}_{\\textrm{PS}}$ is improved by increasing the number of bins $\\textrm{Ni}$ in the partitioning $Q$. The approximated QMC intensity $\\hat{I}_{\\textrm{QMC}}$ is calculated several times gradually increasing the number of rays $\\nrays$. Both intensities are computed using the same number of bins, $\\nbin=100$ in the partitioning $P$ of the $\\variabile{p}$-axis. The minimum ray mapping error is obtained with $\\textrm{Ni}=100$ bins, while the minimum QMC error is achieved tracing $10^6$ rays. We observe that the minimal error obtained using the backward ray mapping is of an order of magnitude of $10^{-6}$, while the minimum QMC error is of the order of $10^{-5}$. Furthermore, an extrapolation of the QMC error shows that the backward ray mapping is around than $1000$ times faster compared to QMC!\n\\begin{figure}[t]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{Error_tir_raymapping.png}\n  \\end{center}\n  \\caption{\\textbf{Errors of ray mapping and QMC ray tracing for the TIR-collimator.}\n The direct backward ray mapping method is faster and more accurate than QMC ray tracing.}\n\\label{fig:error_tir_raymapping}\n \\end{figure}\nIn Table \\ref{tab:ray_mapping_tir} the numerical results obtained for backward ray mapping are reported. The error values for QMC ray tracing were already reported in Chapter \\ref{chap:triangulation} (Table \\ref{tab:mc_error_triangulation}).\n\\begin{table}[t] \n\\centering\n\\caption{\\bf Errors of the PS intensity for the TIR-collimator}\n\\begin{tabular}{llllll}\n \\hline  $\\textrm{Ni}$\\; & $|\\Delta U|$  & PS error & CPU-time (sec.)\\\\\n  \\hline \n $5$    & $1.6\\cdot 10^{-1}$   & $5.19\\cdot10^{-4}$     & $269$  \\\\\n$10$    & $2.8\\cdot 10^{-2}$ & $2.09\\cdot 10^{-4}$   & $284$   \\\\\n$30$   & $5.7 \\cdot 10^{-3}$ & $3.15\\cdot 10^{-6}$   & $313$  \\\\\n$100$  & $5.1 \\cdot 10^{-3}$ & $2.52\\cdot 10^{-6}$   & $359$  \\\\\n \\hline\n \\end{tabular}\n \\label{tab:ray_mapping_tir}\n \\end{table}\n\\\\ \\indent In the next section we present the method for a parabolic reflector.\n\\section{Results for the parabolic reflector}\\label{sec:PR}\nIn this section we provide the results for the parabolic reflector in Figure \\ref{fig:PR}.\nThis is a very challenging example. Indeed, the rays that propagate through such a system can reflect many times along the left or the right mirror. As we have seen using PS ray tracing, this leads to many different paths. Every path corresponds to a given number of reflections with one of the two reflectors. In Chapter \\ref{chap:triangulation} we found $17$ different paths for this parabolic reflector. Here, we apply the backward ray mapping method to detect all these paths. \\\\ \\indent\nThe target PS of the parabolic reflector is the rectangular domain \\set{T}{}{}$=[-\\variabile{b}, \\variabile{b}]\\times[-1,1]$ where $\\variabile{b}=17$. Like for the TIR-collimator, we divide the interval $[-\\variabile{b}, \\variabile{b}]$ in target PS into sub-intervals of the same length. Considering the partitioning $Q~:~ -\\variabile{b}=\\variabile{q}^{0}<\\variabile{q}^{1}<\\cdots<\\variabile{q}^{\\textrm{Ni}}=\\variabile{b}$ of $[-\\variabile{b}, \\variabile{b}]$ and a direction $\\variabile{p}\\in[-1,1]$, the backward ray mapping explained in Section \\ref{sec:raymapping_explanation} is applied to every sub-interval $[\\variabile{q}^{\\textrm{k}}, \\variabile{q}^{\\textrm{k+1}}]\\subset[-\\variabile{b}, \\variabile{b}]$ with $\\textrm{k}=0, \\cdots, \\textrm{Ni}-1$ and for every direction $\\variabile{p}\\in[-1,1]$. To determine how many bins $\\textrm{Ni}$ are needed for a good approximation of the target photometric variables, we employ the same idea of the TIR-collimator. The source \\'{e}tendue $U_1$ is compared to several approximations of the \\'{e}tendue $U_{\\textrm{t}}$ at the target, each of them is given by a different partitioning $Q$ of $[-\\variabile{b}, \\variabile{b}]$. For the parabolic reflector all the rays emitted from the source arrive at the target. Therefore, the exact \\'{e}tendue as an area in PS is computed from (\\ref{eq:etenduesource1}) obtaining $U=U_1=8$. The approximated target \\'{e}tendue $U_{\\textrm{t}}$ is given by Equation (\\ref{eq:etendueintegraltarget}). In Figure \\ref{fig:etendue_ray_mapping_pr_bin} we show the comparison between $U_1$ and several approximations of $U_{\\textrm{t}}$ by gradually increasing the number of bins $\\textrm{Ni}$ in the partitioning $Q$ while fixing the maximum number of multiple reflections to $30$. Increasing the number of bins $\\textrm{Ni}$, $U_{\\textrm{t}}$ increases approaching the exact value $U_1=8$. After the division into $\\textrm{Ni}=4$ bins the improvement is slightly visible. Therefore, we conclude that $\\textrm{Ni}=4$ bins are enough to detect $30$ multiple reflections.\n\\begin{figure}[t]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{etendue_ray_mapping_pr_bin}\n  \\end{center}\n  \\caption{\\textbf{Comparison between the exact \\'{e}tendue and the approximated target \\'{e}tendue by increasing $\\textrm{Ni}$.}\n At most $30$ multiple reflections are considered. Increasing $\\textrm{Ni}$, the target \\'{e}tendue gets closer to the exact value $U_1=8$.}\n\\label{fig:etendue_ray_mapping_pr_bin}\n \\end{figure}\n\\\\ \\indent In Figure \\ref{fig:boundaries_rays_pr_raymapping} we show the ray distribution at the target PS obtained using backward ray mapping with $\\textrm{Ni}=4$ and at most $30$ multiple reflections. The rays traced from the target to the source are depicted with the red dots. Most of the rays traced are located on the boundaries $\\partial$\\set{R}{}{}$(\\Pi)$ of the regions with positive luminance. \nOnly few rays are traced inside those regions. These are the rays located at the end points of every sub-interval $[\\variabile{q}^{\\textrm{k}}, \\variabile{q}^{\\textrm{k}+1}]$ with $\\textrm{k}=0, \\cdots, \\textrm{Ni}-1$. \n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{boundaries_raymapping_pr}\n  \\end{center}\n  \\caption{\\textbf{Rays on the boundaries of the regions with positive luminance in target PS.}\n At most $30$ multiple reflections are considered and $\\textrm{Ni}=4$ and $\\nbin = 100$. Only the rays on the boundaries and on the end points of each interval are traced.}\n\\label{fig:boundaries_rays_pr_raymapping}\n \\end{figure}\n\\\\ \\indent\nThe backward ray mapping method is able to detect $61$ different paths. Indeed up to $30$ multiple reflections can occur at the left reflector and the right reflector. The path that goes directly from the source to the target (no reflections) has to be added. Using PS ray tracing we found at most $17$ paths for the same parabolic reflector. Hence, we claim that ray mapping is much more accurate than PS ray tracing. Also, we observe the procedure can be stopped later to detect even more than $30$ reflections. The more reflections are considered the better the accuracy obtained. Again, to define a stopping criterion we use \\'{e}tendue conservation. Fixing the number of bins $\\textrm{Ni}=4$ and $\\nbin=100$ and gradually increasing the number of multiple reflections we see that the approximated target \\'{e}tendue $U_{\\textrm{t}}$ changes as the blue line in Figure \\ref{fig:etendue_pr_raymapping}. The horizontal red line represents the exact intensity $U = U_{1} = 8$. We note that the more reflections are considered the smaller the value of $\\Delta U = |U_1-U_{\\textrm{t}}|$ (see also Table \\ref{tab:ray_mapping_pr}). We observe that after around $30$ multiple reflections there is no significant improvement in the computation of $U_{\\textrm{t}}$. This is due to two main reasons. First, since only few rays follow multiple reflections, they do not give a significant contribution to the total \\'{e}tendue, the regions in PS formed by those rays are very small compared to the entire PS. Second, when more paths are considered also more bins $\\nbin$ and sub-intervals $\\textrm{Ni}$ should be taken into account to obtain a more precise approximation of the \\'{e}tendue. From this we conclude that backward ray mapping has a good accuracy when around $30$ multiple reflections and $\\textrm{Ni}=4$ bins are taken into account.\n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{etendue_pr_raymapping}\n  \\end{center}\n  \\caption{\\textbf{Comparison between the exact \\'{e}tendue and the approximated target \\'{e}tendue by increasing the number of multiple reflections.}\nFixing the number of bins along the $\\variabile{q}$-axis, $\\textrm{Ni}=4$, and increasing the number of reflections considered, the \\'{e}tendue increases approaching to the exact value $U_1=8$.}\n\\label{fig:etendue_pr_raymapping}\n \\end{figure}\nOnce a stopping criterion is established, direct backward ray mapping is run and the rays on the boundaries are determined. Finally, the target intensity is calculated from Equation (\\ref{eta2}). \n\\\\ \\indent In Figure \\ref{fig:intensity_pr_raymapping} both the PS intensity (red line) and the reference intensity (dotted blue line) are shown. The PS intensity $\\hat{I}_{\\textrm{PS}}$ is obtained considering at most $30$ multiple reflections, $\\textrm{Ni}=4$ and $\\nbin = 100$. The reference intensity $\\hat{I}_{\\textrm{ref}}$ is given by QMC ray tracing with $10^8$ rays and $\\nbin = 100$. The two intensities coincide.\n\\begin{figure}[t]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{intensity_pr_raymapping}\n  \\end{center}\n  \\caption{\\textbf{Profile of the intensity for the parabolic reflector.}\nThe ray mapping error is calculated considering $\\textrm{Ni}=4$ and at most $30$ multiple reflections. The reference intensity is obtained by running QMC ray tracing with $10^8$ rays.}\n\\label{fig:intensity_pr_raymapping}\n \\end{figure}\n\\\\ \\indent\nTo conclude, we calculate the errors between the approximated intensity $\\hat{I}_{\\textrm{A}} (\\textrm{A}=\\textrm{PS}, \\textrm{QMC})$ and the reference intensity $\\hat{I}_{\\textrm{ref}}$. From the results in Figure \\ref{fig:error_raymapping_pr} we observe that the PS error (red line) converges faster than the QMC error (blues line) as long as an error of an order of $10^{-6}$ is desired. Ray mapping results to be around $1000$ times faster than QMC ray tracing! Furthermore, it is much more accurate than QMC. Our method is able to detect \\textit{all} the possible paths that can occur. The procedure is stopped when $200$ multiple reflections are reached. Our expectation is that, increasing the number of multiple reflections and the number of bins $\\textrm{Ni}$, the accuracy can be improved even more.\n\\begin{figure}[h]\n  \\begin{center}\n  \\includegraphics[width=0.7\\textwidth]{error_pr_raymapping}\n  \\end{center}\n  \\caption{\\textbf{Errors of ray mapping and QMC ray tracing for the parabolic reflector.}\nThe ray mapping error decreases by increasing the number of reflections considered.\nThe QMC error reduces by tracing more rays.\n The extended backward ray mapping method is significantly faster and more accurate than QMC ray tracing.}\n\\label{fig:error_raymapping_pr}\n \\end{figure}\nIn Tables \\ref{tab:ray_mapping_pr} and \\ref{tab:qmc_raymapping_pr} these numerical results are reported.\n\\begin{table}[t] \n\\centering\n\\caption{\\bf Errors of the PS intensity for the parabolic reflector}\n\\begin{tabular}{llllll}\n \\hline  Number of\\\\\n reflections\\;  & $|\\Delta U|$ & PS error  & CPU-time (sec.)\\\\\n  \\hline \n $5$      & $1.74\\cdot 10^{-1}$  & $3.222\\cdot10^{-4}$& $3.28$  \\\\\n$10$      & $7.52\\cdot 10^{-3}$ & $1.555\\cdot 10^{-5}$& $5.11$   \\\\\n$20$      & $9.00 \\cdot 10^{-4}$ & $2.059\\cdot 10^{-6}$& $6.83$  \\\\\n $30$    & $5.00 \\cdot 10^{-4}$ & $1.269\\cdot 10^{-6}$ & $8.38$  \\\\\n$100$    & $2.99 \\cdot 10^{-4}$ & $1.038\\cdot 10^{-6}$ & $17.49$  \\\\\n$150$    & $2.96 \\cdot 10^{-4}$ & $1.039\\cdot 10^{-6}$ & $26.38$  \\\\\n$200$    & $2.95 \\cdot 10^{-4}$ & $1.039\\cdot 10^{-6}$ & $32.21$  \\\\\n \\hline\n \\end{tabular}\n \\label{tab:ray_mapping_pr}\n \\end{table}\n\\begin{table}[t] \n\\centering\n\\caption{\\bf Errors of the QMC intensity for the parabolic reflector}\n\\begin{tabular}{lllll}\n \\hline  $\\nrays$\\;  & QMC error & CPU-time (sec.)\\\\\n  \\hline \n$10^4$     & $2.05\\cdot 10^{-4}$   & $2.81$  \\\\\n$10^5$     & $2.87\\cdot 10^{-5}$   & $25.81$   \\\\\n$10^6$     & $7.18 \\cdot 10^{-6}$  & $257.54$  \\\\\n$10^7$     & $1.15 \\cdot 10^{-6}$  & $2491.32$  \\\\\n \\hline\n \\end{tabular}\n \\label{tab:qmc_raymapping_pr}\n \\end{table}\n\\section{Conclusions}\nIn this chapter we extended the concatenated ray mapping method to systems formed by curved lines. Employing backward ray tracing and a bisection procedure in target PS, an inverse map from the target to the source was constructed such that all the possible paths that the rays can follow are determined. The direct backward ray mapping method is able to detect the rays located on the boundaries of the regions formed by rays that follow the same path. From these rays the target intensity is calculated. \n\\\\ \\indent\nWe presented two examples of optical systems: the TIR-collimator and the parabolic reflector. In both cases the target PS is divided into bins and the procedure is applied to each bin. A stopping criterion based on \\'{e}tendue conservation is developed to determine the number of bins needed to obtain a good accuracy. For the TIR-collimator we noticed that the method is able to detect rays that follow a spurious path due to numerical error. This gives the expectation that backward ray mapping can be used for detecting stray light.\nFor the parabolic reflector, many paths can occur along the reflectors. Etendue conservation is used again to determine the number of multiple reflections to be considered. The target intensity is computed for both systems and is compared with a reference intensity given by QMC ray tracing with a large number of rays. The results show that the method is able to detect all the possible paths tracing a relatively small number of rays, typically around $10^3$. Comparing our method to QMC ray tracing, significant advantages are observed in accuracy and computational time for both optical systems.\n% Explain the results\n\\\\ \\indent In the next chapter we explain how to apply the method to systems with Fresnel reflection. We present the method for a system formed by the source, an ideal lens and the target. \n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "205a99469621a71d6fcc75d60f0c39ac9c76e51e", "size": 47423, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/Extended_ray_mapping.tex", "max_stars_repo_name": "melaniafilosa/ps_raytracing", "max_stars_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/Extended_ray_mapping.tex", "max_issues_repo_name": "melaniafilosa/ps_raytracing", "max_issues_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/Extended_ray_mapping.tex", "max_forks_repo_name": "melaniafilosa/ps_raytracing", "max_forks_repo_head_hexsha": "8f9111ea4ec3ac125b593f41b3ac6fe302ea6632", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 127.8247978437, "max_line_length": 2052, "alphanum_fraction": 0.7017902705, "num_tokens": 15956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4068200204573908}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[margin=1.2in]{geometry}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{tikz}\n\\usepackage{tikz-qtree}\n\\usepackage{verbatim}\n\\usepackage{algorithm,caption}\n\n% \\usepackage{natbib}\n% \\twocolumn\n\n\\newcommand{\\ind}{\\hspace*{1em}}\n\\newcommand{\\kword}[1]{{\\bf #1}}\n\\newcommand{\\algblk}[2]{\n  \\begin{center}\n    \\begin{minipage}[c]{22em}\n      \\begin{algorithm}[H]\n        \\caption*{{\\bf Algorithm} #1}\n        #2\n      \\end{algorithm}\n    \\end{minipage}\n  \\end{center}\n}\n\n\n\\title{Adding Probabilities in the Hakaru to C Compiler (HKC)}\n\\author{Zach Sullivan}\n\\date{July 30, 2016}\n\n\\begin{document}\n\\maketitle\n\n\\section{Probabilities in Hakaru}\n\nBecause Hakaru is a probabilistic language, we provide a type just for\nprobabilities. The type {\\tt prob} has extra safety from underflow. The main way\nwe accomplish this is by storing its value as double precision floating point\nnumbers in the log-domain. We can do basic arithmetic on our probabilities.\n\n\\section{The ``LogSumExp Trick''}\nBecause our probability types are stored in the log-domain, we need to compute\n\\begin{displaymath}\n{\\rm LSE}(x) = \\log\\Bigg(\\sum_{i=0}^{n}{e^{x_i}}\\Bigg)\n\\end{displaymath}\noften called ``LogSumExp.'' The advantage of storing probabilities in the\nlog-domain is lost if we simply remove them from the log-domain before doing\ncalculations on them. We would also add a bunch of {\\tt log} and {\\tt exp}\noperations.\n\n\\begin{align*}\n{\\rm LSE^\\prime}(x) &= \\hat x + \\log\\Bigg(\\sum_{i=0}^{n}{e^{x_i-\\hat x}}\\Bigg)\\\\\n{\\rm\\bf where}&\\ \\hat x = {\\rm max}(x)\n\\end{align*}\n\nThis trick preserves the value of the largest of the numbers being summed.\n\n\n\\section{Summation over Probabilities}\n\nFor summation over probabilities a different technique for LogSumExp will need\nto be use. Since arity will not be known at runtime we need to have a function\nthat operates over an array.\n\nThis algorithm follows directly from the math:\n\n\\algblk{LogSumExp for Summation}\n{\n  \\kword{input:} an index production function\n  $f : \\mathbb{N} \\rightarrow \\mathbb{R}^+$ and a size $n \\in \\mathbb{N}$\n\n  \\kword{output:} summation of array produced by $f$ in log-space\\\\\n\n  $A[0] \\leftarrow f(0)$\\\\\n  $m \\leftarrow A[0]$\\\\\n  $s \\leftarrow 0$\\\\\n  \\kword{for} $i = 0,1,...,n-1$\\kword{:}\\\\\n  \\ind $A[i] \\leftarrow f(i)$\\\\\n  \\ind \\kword{if} $m < A[i]$ \\kword{:}\\\\\n  \\ind \\ind $m \\leftarrow A[i]$\\\\\n  \\kword{for} $i = 0,1,...,n-1$\\kword{:}\\\\\n  \\ind \\ind $s \\leftarrow s + \\exp(A[i]-m)$\\\\\n  \\kword{return} $m + \\log(s)$\n}\n\nIt scales in space at $O(n)$ and in time at $O(2n)$. We generate a function\nfor this operation and call it when we summate over probabilities. It differs\nfrom summation over {\\tt nat}, {\\tt int}, and {\\tt real} which are done in\nconstant time.\n\n\\section{$n$-ary Probability Summation}\n\nAlgorithmically, $n$-ary operations are the same operation as summation over an\narray. However, it requires different word for code generation. For summation\nwe do not know that arity at runtime. For $n$-ary operations, we do.\n\n\n\\subsection*{Max Comparison Tree}\nLogSumExp safety creates a particular challenge when generating code for our\ncompiler. HKC compiles Hakaru to C, where we have no max function that works\non an arbitrary number of arguments. The solution is to create a tree of\ncomparisons using C's ternary conditional expression to find the maximum of $n$\nnumber of arguments.\n\nHere is an example of a max comparison tree when the length of array $x$ is\n4.\n\n\\begin{center}\n\\Tree [ .{$x_0 > x_1$}\n        [ .{$x_0 > x_2$}\n          [ .{$x_0 > x_3$}\n            % {$x_0$}\n            % {$x_3$}\n          ]\n          [ .{$x_2 > x_3$}\n            % {$x_2$}\n            % {$x_3$}\n          ]\n        ]\n        [ .{$x_1 > x_2$}\n          [ .{$x_1 > x_3$}\n            % {$x_1$}\n            % {$x_3$}\n          ]\n          [ .{$x_2 > x_3$}\n            % {$x_2$}\n            % {$x_3$}\n          ]\n        ]\n      ]\n\\end{center}\n\n\\subsection*{Code Generation}\n\nAfter generating a max comparison tree, we can create leaves for our tree that\nare different LogSumExp summations. This is rather trivial given a particular\nmax index.\n\n% We use {\\tt log1p} and {\\tt expm1} to help prevent.\n\nA Hakaru program that sums 4 probabilities will generate the following C\nexpression, where {\\tt p\\_a}, {\\tt p\\_b}, {\\tt p\\_c}, and {\\tt p\\_d} are\nvariables holding probabilities:\n\n{\\small\n\\begin{verbatim}\np_a > p_b\n  ? p_a > p_c\n    ? p_a > p_d\n      ? p_a + log1p(expm1(p_c - p_a) + (expm1(p_d - p_a) + expm1(p_b - p_a)) + 3)\n      : p_d + log1p(expm1(p_b - p_d) + (expm1(p_c - p_d) + expm1(p_a - p_d)) + 3)\n    : ( p_c > p_d\n      ? p_c + log1p(expm1(p_b - p_c) + (expm1(p_d - p_c) + expm1(p_a - p_c)) + 3)\n      : p_d + log1p(expm1(p_b - p_d) + (expm1(p_c - p_d) + expm1(p_a - p_d)) + 3))\n  : (p_b > p_c\n    ? p_b > p_d\n      ? p_b + log1p(expm1(p_c - p_b) + (expm1(p_d - p_b) + expm1(p_a - p_b)) + 3)\n      : p_d + log1p(expm1(p_b - p_d) + (expm1(p_c - p_d) + expm1(p_a - p_d)) + 3)\n    : (p_c > p_d\n      ? p_c + log1p(expm1(p_b - p_c) + (expm1(p_d - p_c) + expm1(p_a - p_c)) + 3)\n      : p_d + log1p(expm1(p_b - p_d) + (expm1(p_c - p_d) + expm1(p_a - p_d)) + 3)));\n\\end{verbatim}\n}\n\nWe can use {\\tt log1p} because where $x_i$ is the maximum\n$e^{x_i - \\hat x} = 1$. We use {\\tt log1p} and {\\tt expm1} because they can be\nmore accurate for small values.\n\n\\subsection*{Discussion}\n\nThe method presented here and used in HKC for code generation produces an amount\nof code that is exponential in the number of arguments. In practice (thus far),\nthis is not a major issue because {\\tt summate} is often used to sum a large\nnumber of probabilities.\n\n\\end{document}\n", "meta": {"hexsha": "733ee9cb86a04fe143804f2cf7784cf6b854691a", "size": 5649, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "haskell/Language/Hakaru/CodeGen/logsumexp.tex", "max_stars_repo_name": "vmchale/hakaru", "max_stars_repo_head_hexsha": "78922e13876e449d6812a55a11bf84c8eb0af4d6", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 327, "max_stars_repo_stars_event_min_datetime": "2015-01-03T08:56:51.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T12:12:06.000Z", "max_issues_repo_path": "haskell/Language/Hakaru/CodeGen/logsumexp.tex", "max_issues_repo_name": "zaxtax/hakaru", "max_issues_repo_head_hexsha": "03ac5b645815e99437e28d228e6c668753b2640e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 155, "max_issues_repo_issues_event_min_datetime": "2015-05-05T17:57:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T15:43:39.000Z", "max_forks_repo_path": "haskell/Language/Hakaru/CodeGen/logsumexp.tex", "max_forks_repo_name": "zaxtax/hakaru", "max_forks_repo_head_hexsha": "03ac5b645815e99437e28d228e6c668753b2640e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 38, "max_forks_repo_forks_event_min_datetime": "2015-01-23T16:25:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T15:09:12.000Z", "avg_line_length": 31.9152542373, "max_line_length": 84, "alphanum_fraction": 0.6459550363, "num_tokens": 1891, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.40682002045739074}}
{"text": "\\documentclass[a4paper,10pt]{article}\n\\usepackage{graphicx}\n\\usepackage{lscape}\n\\title{Results}\n\\author{}\n\\date{\\today}\n\\begin{document}\n\\begin{landscape}\n\\oddsidemargin 0in \\topmargin 0in\\maketitle\n\\section{Tables of Friedman, Aligned Friedman, Bonferroni-Dunn, Holm, Hochberg and Hommel Tests}\n\\begin{table}[!htp]\n\\centering\n\\caption{Average Rankings of the algorithms (Friedman)\n}\\begin{tabular}{c|c}\nAlgorithm&Ranking\\\\\n\\hline\n RING&4.959999999999999\\\\\n TREE&5.039999999999998\\\\\n NETA&4.959999999999999\\\\\n NETB&4.959999999999998\\\\\n TORUS&5.059999999999999\\\\\n GRAPH&5.3199999999999985\\\\\n SAME&4.959999999999999\\\\\n GOODBAD&4.869999999999999\\\\\n RAND&4.869999999999999\\\\\n\\end{tabular}\n\\end{table}\n\n\nFriedman statistic (distributed according to chi-square with 8 degrees of freedom: 0.9853333333325054. \nP-value computed by Friedman Test: 0.9983393538102286.\\newline\n\nIman and Davenport statistic (distributed according to F-distribution with 8 and 392 degrees of freedom: 0.12100140011551622. \nP-value computed by Iman and Daveport Test: 0.9984061848725897.\\newline\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\n\\caption{Average Rankings of the algorithms (Aligned Friedman)\n}\\begin{tabular}{c|c}\nAlgorithm&Ranking\\\\\n\\hline\n RING&222.76999999999984\\\\\n TREE&224.60999999999981\\\\\n NETA&221.99999999999983\\\\\n NETB&221.99999999999983\\\\\n TORUS&230.91999999999982\\\\\n GRAPH&255.0099999999998\\\\\n SAME&222.76999999999984\\\\\n GOODBAD&214.70999999999984\\\\\n RAND&214.70999999999984\\\\\n\\end{tabular}\n\\end{table}\n\n\nAligned Friedman statistic (distributed according to chi-square with 8 degrees of freedom: 40.986399746359325. \nP-value computed by Aligned Friedman Test: 2.0968734527615496E-6.\\newline\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\n\\caption{Average Rankings of the algorithms (Quade)\n}\\begin{tabular}{c|c}\nAlgorithm&Ranking\\\\\n\\hline\n RING&4.926274509803922\\\\\n TREE&5.0831372549019616\\\\\n NETA&4.926274509803922\\\\\n NETB&4.926274509803923\\\\\n TORUS&5.12235294117647\\\\\n GRAPH&5.547450980392157\\\\\n SAME&4.926274509803923\\\\\n GOODBAD&4.770980392156864\\\\\n RAND&4.770980392156864\\\\\n\\end{tabular}\n\\end{table}\nQuade statistic (distributed according to F-distribution with 8 and 392 degrees of freedom: 0.2788345895242685. \nP-value computed by Quade Test: 0.9727048389531654.\\newline\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\tiny\n\\caption{Contrast Estimation}\n\\begin{tabular}{\n|r|r|r|r|r|r|r|r|r|r|}\n\\hline\n & RING& TREE& NETA& NETB& TORUS& GRAPH& SAME& GOODBAD& RAND\\\\\n\\hline\n RING&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n TREE&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n NETA&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n NETB&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n TORUS&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n GRAPH&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n SAME&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n GOODBAD&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n RAND&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000&0.000\\\\\n\\hline\n\n\\end{tabular}\n\\end{table}\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Holm / Hochberg / Holland / Rom / Finner / Li Table for $\\alpha=0.05$ (FRIEDMAN)}\n\\begin{tabular}{ccccccccc}\n$i$&algorithm&$z=(R_0 - R_i)/SE$&$p$&Holm/Hochberg/Hommel&Holland&Rom&Finner&Li\\\\\n\\hline\n8& GRAPH&0.8215838362577479&0.4113137917762598&0.00625&0.006391150954545011&0.006574125233361166&0.006391150954545011&0.0\\\\\n7& TORUS&0.34689095308660434&0.7286732435303455&0.0071428571428571435&0.007300831979014655&0.0075128293213784685&0.012741455098566168&0.0\\\\\n6& TREE&0.3103761159195924&0.7562749546662049&0.008333333333333333&0.008512444610847103&0.008764162596519848&0.019051173490195694&0.0\\\\\n5& RING&0.1643167672515496&0.8694817827381617&0.01&0.010206218313011495&0.010515350115740741&0.025320565519103666&0.0\\\\\n4& NETA&0.1643167672515496&0.8694817827381617&0.0125&0.012741455098566168&0.013109375000000001&0.031549888917161595&0.0\\\\\n3& SAME&0.1643167672515496&0.8694817827381617&0.016666666666666666&0.016952427508441503&0.016666666666666666&0.03773939976903784&0.0\\\\\n2& NETB&0.16431676725154795&0.869481782738163&0.025&0.025320565519103666&0.025&0.04388935252272508&0.0\\\\\n1& RAND&0.0&1.0&0.05&0.050000000000000044&0.05&0.050000000000000044&0.05\\\\\n\\hline\n\\end{tabular}\n\\end{table}\nBonferroni-Dunn's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolm's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHommel's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolland's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nFinner's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nLi's procedure rejects those hypotheses that have a p-value $\\le0.0$.\n\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Holm / Hochberg / Holland / Rom / Finner / Li Table for $\\alpha=0.05$ (ALIGNED FRIEDMAN)}\n\\begin{tabular}{ccccccccc}\n$i$&algorithm&$z=(R_0 - R_i)/SE$&$p$&Holm/Hochberg/Hommel&Holland&Rom&Finner&Li\\\\\n\\hline\n8& GRAPH&1.549427092939215&0.12127908507634506&0.00625&0.006391150954545011&0.006574125233361166&0.006391150954545011&0.0\\\\\n7& TORUS&0.6232310961921754&0.5331326698657505&0.0071428571428571435&0.007300831979014655&0.0075128293213784685&0.012741455098566168&0.0\\\\\n6& TREE&0.3806284918138514&0.7034789365387083&0.008333333333333333&0.008512444610847103&0.008764162596519848&0.019051173490195694&0.0\\\\\n5& RING&0.30988541858784346&0.7566480916486279&0.01&0.010206218313011495&0.010515350115740741&0.025320565519103666&0.0\\\\\n4& SAME&0.30988541858784346&0.7566480916486279&0.0125&0.012741455098566168&0.013109375000000001&0.031549888917161595&0.0\\\\\n3& NETA&0.2802809803356545&0.7792619417215579&0.016666666666666666&0.016952427508441503&0.016666666666666666&0.03773939976903784&0.0\\\\\n2& NETB&0.2802809803356545&0.7792619417215579&0.025&0.025320565519103666&0.025&0.04388935252272508&0.0\\\\\n1& RAND&0.0&1.0&0.05&0.050000000000000044&0.05&0.050000000000000044&0.05\\\\\n\\hline\n\\end{tabular}\n\\end{table}\nBonferroni-Dunn's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolm's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHommel's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolland's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nFinner's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nLi's procedure rejects those hypotheses that have a p-value $\\le0.0$.\n\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Holm / Hochberg / Holland / Rom / Finner / Li Table for $\\alpha=0.05$ (QUADE)}\n\\begin{tabular}{ccccccccc}\n$i$&algorithm&$z=(R_0 - R_i)/SE$&$p$&Holm/Hochberg/Hommel&Holland&Rom&Finner&Li\\\\\n\\hline\n8& GRAPH&0.6168852944521827&0.5373103871065616&0.00625&0.006391150954545011&0.006574125233361166&0.006391150954545011&0.0\\\\\n7& TORUS&0.2791561736510878&0.7801249754918013&0.0071428571428571435&0.007300831979014655&0.0075128293213784685&0.012741455098566168&0.0\\\\\n6& TREE&0.24800035069895815&0.8041341354591375&0.008333333333333333&0.008512444610847103&0.008764162596519848&0.019051173490195694&0.0\\\\\n5& NETB&0.12337705889043668&0.9018085226206667&0.01&0.010206218313011495&0.010515350115740741&0.025320565519103666&0.0\\\\\n4& SAME&0.12337705889043668&0.9018085226206667&0.0125&0.012741455098566168&0.013109375000000001&0.031549888917161595&0.0\\\\\n3& RING&0.12337705889043597&0.9018085226206671&0.016666666666666666&0.016952427508441503&0.016666666666666666&0.03773939976903784&0.0\\\\\n2& NETA&0.12337705889043597&0.9018085226206671&0.025&0.025320565519103666&0.025&0.04388935252272508&0.0\\\\\n1& RAND&0.0&1.0&0.05&0.050000000000000044&0.05&0.050000000000000044&0.05\\\\\n\\hline\n\\end{tabular}\n\\end{table}\nBonferroni-Dunn's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolm's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHommel's procedure rejects those hypotheses that have a p-value $\\le0.00625$.\n\n\nHolland's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nFinner's procedure rejects those hypotheses that have a p-value $\\le0.006391150954545011$.\n\n\nLi's procedure rejects those hypotheses that have a p-value $\\le0.0$.\n\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (FRIEDMAN)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Bonf}$&$p_{Holm}$&$p_{Hoch}$&$p_{Homm}$\\\\\n\\hline\n1& GRAPH&0.4113137917762598&3.2905103342100785&3.2905103342100785&1.0&1.0\\\\\n2& TORUS&0.7286732435303455&5.829385948242764&5.100712704712418&1.0&1.0\\\\\n3& TREE&0.7562749546662049&6.050199637329639&5.100712704712418&1.0&1.0\\\\\n4& RING&0.8694817827381617&6.955854261905293&5.100712704712418&1.0&1.0\\\\\n5& NETA&0.8694817827381617&6.955854261905293&5.100712704712418&1.0&1.0\\\\\n6& SAME&0.8694817827381617&6.955854261905293&5.100712704712418&1.0&1.0\\\\\n7& NETB&0.869481782738163&6.955854261905304&5.100712704712418&1.0&1.0\\\\\n8& RAND&1.0&8.0&5.100712704712418&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (FRIEDMAN)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Holl}$&$p_{Rom}$&$p_{Finn}$&$p_{Li}$\\\\\n\\hline\n1& GRAPH&0.4113137917762598&0.985576492323003&1.0&0.985576492323003&0.9999999999999998\\\\\n2& TORUS&0.7286732435303455&0.9998917449008606&1.0&0.9945803593365627&1.0000000000000002\\\\\n3& TREE&0.7562749546662049&0.9998917449008606&1.0&0.9945803593365627&1.0\\\\\n4& RING&0.8694817827381617&0.9999621247362487&1.0&0.9945803593365627&0.9999999999999999\\\\\n5& NETA&0.8694817827381617&0.9999621247362487&1.0&0.9945803593365627&0.9999999999999999\\\\\n6& SAME&0.8694817827381617&0.9999621247362487&1.0&0.9945803593365627&0.9999999999999999\\\\\n7& NETB&0.869481782738163&0.9999621247362487&1.0&0.9945803593365627&0.9999999999999999\\\\\n8& RAND&1.0&1.0&1.0&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (ALIGNED FRIEDMAN)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Bonf}$&$p_{Holm}$&$p_{Hoch}$&$p_{Homm}$\\\\\n\\hline\n1& GRAPH&0.12127908507634506&0.9702326806107605&0.9702326806107605&0.9702326806107605&0.890585076253209\\\\\n2& TORUS&0.5331326698657505&4.265061358926004&3.731928689060253&1.0&1.0\\\\\n3& TREE&0.7034789365387083&5.627831492309666&4.22087361923225&1.0&1.0\\\\\n4& RING&0.7566480916486279&6.053184733189023&4.22087361923225&1.0&1.0\\\\\n5& SAME&0.7566480916486279&6.053184733189023&4.22087361923225&1.0&1.0\\\\\n6& NETA&0.7792619417215579&6.2340955337724635&4.22087361923225&1.0&1.0\\\\\n7& NETB&0.7792619417215579&6.2340955337724635&4.22087361923225&1.0&1.0\\\\\n8& RAND&1.0&8.0&4.22087361923225&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (ALIGNED FRIEDMAN)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Holl}$&$p_{Rom}$&$p_{Finn}$&$p_{Li}$\\\\\n\\hline\n1& GRAPH&0.12127908507634506&0.6445261095927789&0.9223971309589616&0.6445261095927789&1.0000000000000007\\\\\n2& TORUS&0.5331326698657505&0.99516546853319&1.0&0.952491213461512&0.9999999999999998\\\\\n3& TREE&0.7034789365387083&0.9993202749204726&1.0&0.9609025772024482&0.9999999999999999\\\\\n4& RING&0.7566480916486279&0.9993202749204726&1.0&0.9609025772024482&0.9999999999999999\\\\\n5& SAME&0.7566480916486279&0.9993202749204726&1.0&0.9609025772024482&0.9999999999999999\\\\\n6& NETA&0.7792619417215579&0.9993202749204726&1.0&0.9609025772024482&0.9999999999999999\\\\\n7& NETB&0.7792619417215579&0.9993202749204726&1.0&0.9609025772024482&0.9999999999999999\\\\\n8& RAND&1.0&1.0&1.0&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\n\\newpage\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (QUADE)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Bonf}$&$p_{Holm}$&$p_{Hoch}$&$p_{Homm}$\\\\\n\\hline\n1& GRAPH&0.5373103871065616&4.298483096852493&4.298483096852493&1.0&1.0\\\\\n2& TORUS&0.7801249754918013&6.24099980393441&5.460874828442609&1.0&1.0\\\\\n3& TREE&0.8041341354591375&6.4330730836731&5.460874828442609&1.0&1.0\\\\\n4& NETB&0.9018085226206667&7.2144681809653335&5.460874828442609&1.0&1.0\\\\\n5& SAME&0.9018085226206667&7.2144681809653335&5.460874828442609&1.0&1.0\\\\\n6& RING&0.9018085226206671&7.214468180965337&5.460874828442609&1.0&1.0\\\\\n7& NETA&0.9018085226206671&7.214468180965337&5.460874828442609&1.0&1.0\\\\\n8& RAND&1.0&8.0&5.460874828442609&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\begin{table}[!htp]\n\\centering\\scriptsize\n\\caption{Adjusted $p$-values (QUADE)}\n\\begin{tabular}{ccccccc}\ni&algorithm&unadjusted $p$&$p_{Holl}$&$p_{Rom}$&$p_{Finn}$&$p_{Li}$\\\\\n\\hline\n1& GRAPH&0.5373103871065616&0.9978995226651626&1.0&0.9978995226651626&1.0\\\\\n2& TORUS&0.7801249754918013&0.9999751554402075&1.0&0.9978995226651626&0.9999999999999999\\\\\n3& TREE&0.8041341354591375&0.9999751554402075&1.0&0.9978995226651626&0.9999999999999999\\\\\n4& NETB&0.9018085226206667&0.9999908721399633&1.0&0.9978995226651626&1.0\\\\\n5& SAME&0.9018085226206667&0.9999908721399633&1.0&0.9978995226651626&1.0\\\\\n6& RING&0.9018085226206671&0.9999908721399633&1.0&0.9978995226651626&1.0\\\\\n7& NETA&0.9018085226206671&0.9999908721399633&1.0&0.9978995226651626&1.0\\\\\n8& RAND&1.0&1.0&1.0&1.0&1.0\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\end{landscape}\\end{document}\n", "meta": {"hexsha": "275c159d57adce82a02eec9167614a121c1c3191", "size": 13391, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "statAnalysis/controlTest/Latex/metric/output_website_phishing_0_100.tex", "max_stars_repo_name": "win7/parallel_social_spider_optimization", "max_stars_repo_head_hexsha": "9dbad144e4242fef2ff6aacc8e72376e14b03a61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-02T15:49:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-02T15:49:18.000Z", "max_issues_repo_path": "statAnalysis/controlTest/Latex/metric/output_website_phishing_0_100.tex", "max_issues_repo_name": "win7/parallel_social_spider_optimization", "max_issues_repo_head_hexsha": "9dbad144e4242fef2ff6aacc8e72376e14b03a61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "statAnalysis/controlTest/Latex/metric/output_website_phishing_0_100.tex", "max_forks_repo_name": "win7/parallel_social_spider_optimization", "max_forks_repo_head_hexsha": "9dbad144e4242fef2ff6aacc8e72376e14b03a61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.4798850575, "max_line_length": 139, "alphanum_fraction": 0.7764169965, "num_tokens": 5952, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4067489675231901}}
{"text": "\\SecDef{dca}{Differential Computational Analysis}\n\nI describe the general setting for our attacks. We consider \\emph{a keyed symmetric primitive}, e.g. a block cipher. A \\emph{white-box designer} takes a naive implementation with a hardcoded secret key and obfuscates it producing \\emph{a white-box implementation}. An adversary receives the white-box implementation and her goal is to recover the secret key or a part of it. We restrict our analysis to implementations in the form of \\emph{Boolean circuits}. \n\n\\begin{definition}\n    \\Label{def:circuit}\n    A \\emph{Boolean circuit} $C$ is a directed acyclic graph where each node with the indegree $k > 0$ has an associated $k$-ary symmetric Boolean function $g_v$. Nodes with the indegree equal to zero are called \\emph{inputs} of $C$ and nodes with the outdegree equal to zero are called \\emph{outputs} of $C$. \n    \n    Let $x = (x_1, \\ldots, x_N)$ (resp. $y = (y_1, \\ldots, y_M)$) be a vector of input (resp. output) nodes in a fixed order. For each node $v$ in $C$ we say that it computes a Boolean function $f_v: \\field{N} \\to \\field{}$ defined as follows:\n    \\begin{itemize}\n        \\item for all $1 \\le i \\le N$ set $f_{x_i}(z) = z_i$,\n        \\item for all non-input nodes $v$ in $C$ set $f_{v}(z) = g_v(f_{c_1}(z), \\ldots, f_{c_k}(z))$,\\\\\n        where $c_1, \\ldots, c_k$ are nodes having an outgoing edge to $v$.\n    \\end{itemize}\n    \n    The set of $f_v$ for all nodes $v$ in $C$ is denoted $\\FUNCS(C)$ and the set of $f_{x_i}$ for all input nodes $x_i$ is denoted $\\XFUNCS(C)$. By an abuse of notation we also define the function $C: \\field{N} \\to \\field{M}$ as $C = (f_{y_1}, \\ldots, f_{y_m})$.\n\\end{definition}\n\n\\subsubsection{Masking Schemes}\nWe assume that the white-box designer uses masking in some form, but we do not restrict him from using other obfuscation techniques. The only requirement is that there exists a relatively small set of nodes in the obfuscated circuit (called \\emph{shares}) such that during a legitimate computation the values computed in these nodes sum to \\emph{a predictable value}. We at least expect this to happen with overwhelming probability. In a more general case, we allow arbitrary functions to be used to compute the predictable value from the shares instead of plain \\txor{}. We call these functions \\emph{decoders}. The classic Boolean masking technique is based on the \\txor{} decoder. The number of shares is denoted by $\\numshares$.\n\nI give a broad definition of a masking scheme that will be used also in \\ChapRef{wbc}.\n\n\\begin{definition}[Masking Scheme]\n\\Label{def:masking}\nAn $\\nsh$-bit masking scheme is defined by an encoding function $\\enc: \\field{} \\times \\field{\\nrand} \\to \\field{\\nsh}$, a decoding function $\\dec: \\field{\\nsh} \\to \\field{}$ and a set of triplets $\\{(\\op, Eval_\\op, \\cir_\\op), \\ldots\\}$ where each triplet consists of:\n\\begin{enumerate}\n    \\item a Boolean operator $\\op: \\field{}\\times\\field{} \\to \\field{}$,\n    \\item a circuit $Eval_{\\op}: \\field{\\nsh}\\times\\field{\\nsh}\\times\\field{\\nrand'} \\to \\field{\\nsh}$.\n\\end{enumerate}\nFor any $r\\in\\field{\\nrand}$ and any $x\\in\\field{}$ it must hold that $\\dec(\\enc(x,r)) = x$. Moreover, the following equation must be satisfied for all operators $\\op$ and all values $r' \\in \\field{\\nrand'}, x_1 \\in \\field{\\nsh}, x_2 \\in \\field{\\nsh}$:\n$$\\dec(Eval_{\\op}(x_1, x_2, r')) = \\dec(x_1) \\op \\dec(x_2).$$\n\nThe degree of the masking scheme is the algebraic degree of the $\\dec$ function. The masking scheme is called nonlinear if its degree is greater than 1.\n\\end{definition}\n\nNote that $Eval_\\op$ takes three arguments in the definition. The first two are shares of the secret values and the third one is optional randomness that must not change the secret values. \n\n% -------------------------------------------------------------------\n\n\\subsubsection{Predictable Values}\n\n\\emph{A predictable value} typically is a value computed in the beginning or in the end of the reference algorithm such that it depends only on a few key bits and on the plaintexts/ciphertexts. In such case the adversary makes a guess for the key bits and computes the corresponding candidate for the predictable value. The total number of candidates is denoted by $\\numpred$.\n\nThe obfuscation method may require random bits e.g. for splitting the secret value into random shares. Even if the circuit may have input nodes for random bits in order to achieve non-deterministic encryption, the adversary can easily manipulate them. Therefore, the obfuscation method has to rely on pseudorandomness computed solely from the input. Locating and manipulating the pseudorandomness generation is a possible attack direction. However, as we aim to study the applicability of masking schemes, we assume that the adversary can not directly locate the pseudorandomness computations and remove the corresponding nodes. Moreover, the adversary can not predict the generated pseudorandom values with high probability, i.e. such values are not predictable values. \n\n% -------------------------------------------------------------------\n\n\\subsubsection{Window Coverage}\n\nIn a typical case shares of a predictable value will be relatively close in the circuit (for example, at the same circuit level or at a short distance in the circuit graph).  This fact can be exploited to improve efficiency of the attacks. The adversary covers the circuit by sets of closely located nodes. Any such set is called \\emph{a window} (as in power analysis attack terminology e.g. from~\\cite{BosApects}). The described attacks can be applied to each window instead of the full circuit. By varying the window size the attacks may become more efficient. Here we do not investigate methods of choosing windows to cover a given circuit. One possible approach is to assign each level or a sequence of adjacent levels in the circuit to a window. Choosing the full circuit as a single window is also allowed. In our attacks we assume that a coverage is already chosen. For simplicity, we describe how each attack is applied to a single window. In case when multiple windows are chosen, the attack has to be repeated for each window. The window size is denoted by $\\winsize$. It is equal to the circuit size in the case of the single window coverage.\n\n% -------------------------------------------------------------------\n\n\\subsubsection{General DCA Attack}\n\nI would like to note that the term ``differential computation analysis'' (DCA) is very general. In~\\cite{AttackBos} the authors introduced it mainly for the correlation-based attack. In fact our new attacks fit the term well and provide new tools for the ``analysis'' stage of the attack. The first stage remains the same except that we adapt the terminology for the case of Boolean circuits instead of recording the memory access traces. Our view of the procedure of the DCA attack on a white-box implementation $C$ is given in \\AlgRef{dca}\n\n\\begin{algorithm}[ht]\n\\AlgDef{dca}{General procedure of DCA attacks on a Boolean circuit $C\\colon \\field{N} \\to \\field{M}$}\n\n\\begin{algorithmic}[1]\n    \\State generate a random tuple of plaintexts $\\textset = (p_1, p_2, \\ldots), p_i \\in \\field{N}$\n    \n    \\ForAll{$p_i \\in \\textset$}\n        \\State compute the circuit $C$ on input $p_i$: $c_i \\gets C(p_i) \\in \\field{M}$\n        \n        \\ForAll{$j \\in \\seg{1}{|C|}$}\n            \\State $v_{j,i} \\gets$ computed value in the node indexed $j$\n        \\EndFor\n\n        \\ForAll{$j \\in \\seg{1}{k}$}\n            \\State $\\pv_{j,i} \\gets$ predictable value indexed $j$ \n            \\Statex \\hspace{2.35cm} computed from plaintext $p_i$ and/or ciphertext $c_i$\n        \\EndFor\n    \\EndFor\n    \n    \\State generate the list of all computed vectors:\n    \\Statex $\\vecset \\gets (v_1, \\ldots, v_{|C|})$, where $v_j = (v_{j,1}, \\ldots, v_{j,\\numtext}) \\in \\field{\\numtext}$\n    \n    \\State generate the list of all predictable vectors:\n    \\Statex $\\predset \\gets (\\pv_1, \\ldots, \\pv_{\\numpred})$, where $\\pv_j = (\\pv_{j,1}, \\ldots, \\pv_{j,\\numtext}) \\in \\field{\\numtext}$ \n    \n    \\State choose a coverage $\\mathcal{P}$ of $\\vecset$ by windows of size $\\winsize$\n    \n    \\ForAll{$W \\in \\mathcal{P}$}\n        \\State\\Label{dca-step-window} perform analysis on the window $W \\subseteq \\vecset$\n        \\Statex \\hspace{0.5cm} using the set of predictable vectors~$\\predset$\n    \\EndFor\n\\end{algorithmic}\n\\end{algorithm}\nWe remark that the correlation-based DCA attack from \\cite{AttackBos} can be implemented on-the-fly, without computing the full vectors $v_j$. In contrast, most of our attacks require full vectors. Though, various optimizations are possible.\n\nIn the following two sections I describe two classes of DCA attacks: combinatorial and algebraic. They both follow the procedure described above and differ only in the analysis part (Step~\\Ref{dca-step-window}). Afterwards, I describe two fault-injection attacks which allow to find locations of shares efficiently.", "meta": {"hexsha": "8a3b3138f2f2746d95ddd039d3e8363a77fc91b5", "size": 8931, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis-source/9wbAttacks/2dca.tex", "max_stars_repo_name": "hellman/thesis", "max_stars_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2019-05-16T19:55:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-31T15:36:12.000Z", "max_issues_repo_path": "thesis-source/9wbAttacks/2dca.tex", "max_issues_repo_name": "hellman/thesis", "max_issues_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-09T11:26:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-09T11:26:45.000Z", "max_forks_repo_path": "thesis-source/9wbAttacks/2dca.tex", "max_forks_repo_name": "hellman/thesis", "max_forks_repo_head_hexsha": "6ba1c2b241e63c07cf76108481c1b67f21a50f12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-05T19:40:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T19:40:16.000Z", "avg_line_length": 95.0106382979, "max_line_length": 1153, "alphanum_fraction": 0.7166050834, "num_tokens": 2317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4067377523053335}}
{"text": "\\documentclass[t,usenames,dvipsnames]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, xcolor, tikz, pgfplots}\n\n\\pgfplotsset{compat = 1.16}\n\\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}\n\\pgfplotsset{every axis/.append style = {axis lines = middle}}\n\\pgfplotsset{every tick label/.append style={font=\\scriptsize}}\n\\everymath{\\displaystyle}\n\n\\title{Graphs of Quadratic Expressions}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame}\n    \\maketitle\n\\end{frame}\n\n\\section{Determine the vertex and axis of symmetry of a quadratic function in standard form}\n\n\\begin{frame}{Graphing Quadratic Expressions}\nWe will be looking at graphing equations in the form\n\\[ y = ax^2 + bx + c \\]\nwhere $a$, $b$, and $c$ are real numbers with $a \\neq 0$. \n\\end{frame}\n\n\\begin{frame}{Graph of a Quadratic Expression}\nFor $y= x^2$, the graph below is a \\alert{parabola}.\n\\begin{center}\n\\begin{tikzpicture}[scale=0.8]\n\\begin{axis}[\nxmin = -3.5, xmax = 3.5,\nymin = -0.5, ymax = 4.75,\nxtick = {-3,-2,...,3},\nytick = {1,2,3,4}\n]\n\\addplot[color=blue, very thick, samples=200, smooth] {x^2};\n\\addplot[color=blue, mark=*, only marks] coordinates {(-2,4) (-1,1) (0,0) (1,1) (2,4)};\n\\node at (axis cs:-2,4) [left] {$(-2,4)$};\n\\node at (axis cs:-1,1) [left] {$(-1,1)$};\n\\node at (axis cs:0,0) [below] {$(0,0)$};\n\\node at (axis cs:1,1) [right] {$(1,1)$};\n\\node at (axis cs:2,4) [right] {$(2,4)$};\n\\end{axis}\n\\end{tikzpicture}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}{Graph of a Quadratic Expression}\nThe point $(0,0)$ is called the \\alert{vertex} of the parabola and can be either a minimum (smile) or maximum point (frown). \\newline\\\\  \\pause\n\nThrough the vertex is a vertical line called the \\alert{axis of symmetry} that divides the parabola into 2 equal halves. \n\\end{frame}\n\n\\begin{frame}{Example 1}\nFind the vertex, state whether the vertex is a maximum or minimum, and find the equation of the axis of symmetry for each.   \\newline\\\\\n(a) \\quad $y = x^2 + 4x + 1$  \\newline\\\\\n\\begin{minipage}{0.6\\textwidth}\n\\onslide<2->{\n\\begin{tikzpicture}[scale=0.8]\n\\begin{axis}[\nxmin = -5, xmax = 1,\nymin = -4, ymax = 2,\nxtick = {-4,-3,-2,-1,0},\nytick = {-3,-2,-1,0,1}\n]\n\\addplot[color=blue, very thick, samples=200, smooth] {(x+2)^2 - 3};\n\\only<5->{\\draw[color=red, dashed, very thick, <->, >=stealth] (axis cs: -2,-4) -- (axis cs: -2,2);}\n\\end{axis}\n\\end{tikzpicture} }\n\\end{minipage}\n\\hspace{-0.5cm}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<3->{Vertex $(-2,-3)$}\t\\\\[8pt]\n\\onslide<4->{Vertex is a minimum}\t\\\\[8pt]\n\\onslide<5->{Axis of symmetry: $x = -2$}\n\\end{minipage}\n\\end{frame}\n\n\n\\begin{frame}{Example 1}\n(b) \\quad $y = -2x^2+12x-17$    \\newline\\\\\n\\begin{minipage}{0.55\\textwidth}\n\\onslide<2->{\n\\begin{tikzpicture}[scale=0.8]\n\\begin{axis}[\nxmin = -1, xmax = 7,\nymin = -8, ymax = 2,\nxtick = {-1,0,...,5},\nytick = {-7,-6,...,1}\n]\n\\addplot[color=blue, very thick, samples=200, smooth, domain=0:6] {-2*(x-3)^2 + 1};\n\\only<5->{\\draw[color=red, dashed, very thick, <->, >=stealth] (axis cs: 3,-8) -- (axis cs: 3,2);}\n\\end{axis}\n\\end{tikzpicture}}\n\\end{minipage}\n\\hspace{-0.25cm}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<3->{Vertex $(3,1)$} \\\\[8pt]\n\\onslide<4->{Vertex is a maximum} \\\\[8pt]\n\\onslide<5->{Axis of symmetry: $x=3$}\n\\end{minipage}\n\\end{frame}\n\n\n\\section{Convert between standard and general form of quadratic expressions}\n\n\\begin{frame}{Standard and General Form of Quadratic Expressions}\nFor a quadratic function: \\newline\\\\  \n\\begin{itemize}\n    \\item<+-> The \\alert{general form} is $y = ax^2+bx+c$\n    \\begin{itemize}\n        \\item<+-> $a$, $b$, and $c$ are real numbers\n        \\item<+-> $a \\neq 0$    \n    \\end{itemize}   \\vspace{8pt}\n    \\item<+-> The \\alert{standard form} is $y = a(x-h)^2 + k$\n    \\begin{itemize}\n        \\item<+-> Vertex is $(h,k)$\n        \\item<+-> $a \\neq 0$\n        \\item<+-> $a$, $h$, and $k$ are real numbers\n    \\end{itemize}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Converting From General to Standard Form}\n    To convert from general form $y = ax^2 + bx + c$ to standard form $y = a(x-h)^2+k$ \\newline\\\\\n    \\begin{enumerate}\n        \\onslide<2->{\\item Find the vertex:}  \\\\[8pt]\n        \\begin{itemize}\n            \\onslide<2->{\\item $x$-coordinate: $\\frac{-b}{2a}$} \\\\[8pt]\n            \\onslide<2->{\\item $y$-coordinate: Evaluate expression at $x$-coordinate} \\\\[8pt]\n            \\onslide<2->{\\item Or use graphing technology} \\\\[8pt]\n        \\end{itemize}\n        \\onslide<2->{\\item Use the same value of $a$}\n    \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{Example 2}\nConvert each to standard form.  \\newline\\\\\n(a) \\quad $y = x^2 - 4x + 3$ \\newline\\\\\n\\onslide<2->{Vertex:} \\newline\\\\\n\\onslide<3->{$x = \\frac{-(-4)}{2(1)}$} \\newline\\\\\n\\onslide<4->{$x = 2$} \\newline\\\\\n\\onslide<5->{$y = 2^2 - 4(2) + 3$} \\newline\\\\\n\\onslide<6->{$y = -1$}\n\\end{frame}\n\n\\begin{frame}{Example 2}\n(a) \\quad $y = x^2 - 4x + 3$ \\newline\\\\\nVertex: $(2,-1)$    \\newline\\\\\n\\onslide<2->{$a = 1$}\n\\onslide<3->{\\[y = (x-2)^2 - 1\\]}\n\\end{frame}\n\n\\begin{frame}{Example 2}\nConvert each to standard form.  \\newline\\\\\n(b) \\quad $y = 6-x-x^2$  \n\\onslide<2->{\\[y = -x^2 - x + 6\\]}\n\\begin{minipage}{0.55\\textwidth}\n\\onslide<3->{\n\\begin{tikzpicture}[scale=0.8]\n\\begin{axis}[\nxmin = -4, xmax = 3,\nymin = -4, ymax = 7,\nxtick = {-3,-2,...,2},\nytick = {-3,-2,...,6}\n]\n\\addplot[color=blue, very thick, samples=200, smooth] {-x^2-x+6};\n\\addplot[color=blue, mark=*] coordinates {(-0.5,6.25)};\n\\end{axis}\n\\end{tikzpicture}}\n\\end{minipage}\n\\begin{minipage}{0.4\\textwidth}\n\\onslide<4->{Vertex: $\\left(-\\frac{1}{2},\\frac{25}{4}\\right)$} \\\\[12pt]\n\\onslide<5->{$a = -1$} \\\\[12pt]\n\\onslide<6->{$y = -\\left(x+\\frac{1}{2}\\right)^2 + \\frac{25}{4}$}\n\\end{minipage}\n\\end{frame}\n\n\\begin{frame}{Converting From Standard to General Form}\nTo convert from \\newline\n\\[ y = a(x-h)^2 + k \\]\t\\newline\nform to \t\\newline\n\\[ y = ax^2 + bx + c\\]\t\\newline\njust {\\color{blue}\\textbf{do the math}} and remember your \\underline{order of operations}.\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(a) \\quad Convert $y = (x+2)^2 - 3$ to general form.\n\\begin{align*}\n\t\\onslide<2->{y &= (x+2)^2 - 3} \\\\[8pt]\n    \\onslide<3->{y &= x^2 + 4x + 4 - 3} \\\\[8pt]\n    \\onslide<4->{y &= x^2 + 4x + 1}\t\\\\[8pt]\n    \\onslide<5->{y &= x^2 + 4x + 1}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 3}\n(b) \\quad Convert $y = -(x-7)^2 + 10$ to general form.\n\\begin{align*}\n\t\\onslide<2->{y &= -(x-7)^2 + 10} \\\\[8pt]\n\t\\onslide<3->{y &= -(x^2-14x+49) + 10} \\\\[8pt]\n\t\\onslide<4->{y &= -x^2 + 14x - 49 + 10} \\\\[8pt]\n\t\\onslide<5->{y &= -x^2 + 14x - 39}\n\\end{align*}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "71fd1dfe2c4966d954e8bb9cd2fc8564dfae3bb5", "size": 6726, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Graphs_of_Quadratic_Expressions(BEAMER).tex", "max_stars_repo_name": "BryanBain/HA2_BEAMER", "max_stars_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Graphs_of_Quadratic_Expressions(BEAMER).tex", "max_issues_repo_name": "BryanBain/HA2_BEAMER", "max_issues_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Graphs_of_Quadratic_Expressions(BEAMER).tex", "max_forks_repo_name": "BryanBain/HA2_BEAMER", "max_forks_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:45.000Z", "avg_line_length": 30.2972972973, "max_line_length": 143, "alphanum_fraction": 0.6153731787, "num_tokens": 2649, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4067377488942109}}
{"text": "\\section{Architecture}\n\\label{sec:training_of_the_cnn:architecture}\n\nDesigning a \\acrlong{cnn} architecture from scratch requires choosing the types of layers and their arrangement as well as many hyperparameters.\nFor this reason, a lot of trial an error is involved in the design process of an adequate model \\cite{training_arch_design}.\nThere are, however, certain design principles that work really well \\cite{training_arch_hyper}:\n\n\\begin{enumerate}\n  \\item Starting with a low number of filters (high-level feature detection)\n  \\item Increasing the number of filters towards the end (low-level feature detection)\n  \\item Decreasing the spatial dimensions of the feature maps towards the end\n  \\item Using kernel sizes of $3\\times 3$, $5\\times 5$ or $7\\times 7$ for convolutional layers\n  \\item Using pool sizes of $2\\times 2$ or $3\\times 3$ with a stride of two for max-pooling layers\n  \\item Adding additional layers until the model is overfitting\n  \\item Using state-of-the-art networks as inspiration\n\\end{enumerate}\n\nA summary of all the layers of the final \\acrshort{cnn} architecture is listed in table \\ref{tab:arch}.\nThe first convolutional layer uses only \\num{16} filters and a larger kernel size of $5\\times 5$ due to the large dimensions of the input images.\nAll other convolutional layers use a kernel size of $3\\times 3$ while steadily increasing the number of used filters up to \\num{128}.\nThe designed architecture uses six max-pooling layers with a pool size of $2\\times 2$ and a stride of two.\nThis reduces the spatial dimensions of the feature maps to $4\\times 5$ (height $\\times$ width).\nThe output of the fully-connected layer \\texttt{fc8} is about the size of the output layer \\texttt{fc9} squared.\nThis allows the output layer to combine many of the different high-level features to create a confident prediction.\n\nEven though the model was not yet overfitting, no additional layers were added.\nThe reason for this is that with the current architecture the classification performance is already exceptional.\n\nFurthermore, the number of trainable parameters (weights) is relative low compared to state-of-the-art networks like VGG, ResNet or Inception \\cite{training_arch_keras}.\nThis increases the throughput considerably, as less mathematical operations are required.\nThe key to keeping the total number of trainable parameter low is evident when analyzing table \\ref{tab:arch}.\nA whopping \\num{1311232} of the \\num{1614486} total weights can be attributed to the connection between the feature maps of the last convolutional layer \\texttt{conv7} and the artificial output neurons of the first dense layer \\texttt{fc8}.\nThis accounts for \\SI{81.22}{\\percent} of all trainable parameters.\nFor this reason the spatial dimensions of the feature maps should be decreased towards the end.\n\n\\begin{table}\n  \\caption{Layers of the \\acrshort{cnn} architecture}\n  \\label{tab:arch}\n  \\centering\n  \\begin{tabular}{lllllll}\n    \\toprule\n    \\textbf{Layer} & \\textbf{Type} & \\textbf{Activation} & \\textbf{Filters} & \\textbf{Kernel} & \\textbf{Output Shape} & \\textbf{Param \\#} \\\\\n    \\midrule\n    \\textbf{conv1} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{16} & $5\\times 5$ & $256\\times 320\\times 16$ & \\num{1216} \\\\\n    \\textbf{pool1} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $128\\times 160\\times 16$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv2} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{32} & $3\\times 3$ & $128\\times 160\\times 32$ & \\num{4640} \\\\\n    \\textbf{pool2} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $64\\times 80\\times 32$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv3} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{32} & $3\\times 3$ & $64\\times 80\\times 32$ & \\num{9248} \\\\\n    \\textbf{pool3} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $32\\times 40\\times 32$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv4} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{64} & $3\\times 3$ & $32\\times 40\\times 64$ & \\num{18496} \\\\\n    \\textbf{pool4} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $16\\times 20\\times 64$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv5} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{64} & $3\\times 3$ & $16\\times 20\\times 64$ & \\num{36928} \\\\\n    \\textbf{pool5} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $8\\times 10\\times 64$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv6} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{128} & $3\\times 3$ & $8\\times 10\\times 128$ & \\num{73856} \\\\\n    \\textbf{pool6} & \\texttt{MaxPooling2D} &  &  & $2\\times 2$ & $4\\times 5\\times 128$ & \\num{0} \\\\\n    \\midrule\n    \\textbf{conv7} & \\texttt{Conv2D} & \\acrshort{relu} & \\num{128} & $3\\times 3$ & $4\\times 5\\times 128$ & \\num{147584} \\\\\n    \\midrule\n    \\textbf{flatten} & \\texttt{Flatten} &  &  &  & \\num{2560} & \\num{0} \\\\\n    \\textbf{fc8} & \\texttt{Dense} & \\acrshort{relu} &  &  & \\num{512} & \\num{1311232} \\\\\n    \\textbf{fc9} & \\texttt{Dense} &  &  &  & \\num{22} & \\num{11286} \\\\\n    \\bottomrule\n  \\end{tabular}\n\\end{table}\n\n% ------------------------------------------------------------------------------------------------------------------------------\n\\subsection{Visualization}\n\\label{subsec:training_of_the_cnn:architecture:visualization}\nFigure \\ref{fig:arch} visualizes the final architecture of the \\acrshort{cnn} model.\nThe visualization was created with Ti\\textit{k}Z and the help of the open-source repository \\textit{PlotNeuralNetwork} \\cite{training_arch_plot}.\n\nThe boxes represent the outputs of the different layers.\nOn the one hand, the light orange boxes represent the feature maps of the convolutional layers and, on the other hand the purple boxes represent the artificial output neurons of the dense layers.\nThe darker colored bands on the boxes indicate that the \\acrshort{relu} activation function is applied.\nThe red boxes represent max-pooling layers, which decrease the spatial dimensions.\nThe dashed lines between the output of \\texttt{conv7} and \\texttt{fc8} depict the flattening in addition to the dense connection.\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=\\textwidth]{arch}\n  \\caption{Final architecture of the \\acrlong{cnn}}\n  \\label{fig:arch}\n\\end{figure}\n\n% ------------------------------------------------------------------------------------------------------------------------------\n\\subsection{Implementation}\n\\label{subsec:training_of_the_cnn:architecture:implementation}\nThe \\acrshort{cnn} architecture is defined in the Python script \\texttt{cnn.py}, as shown in listing \\ref{lst:arch}.\nThe script uses the open-source software library TensorFlow v2.2.0, along with the high-level Keras \\acrshort{api} implemented in the \\texttt{tf.keras} module \\cite{training_arch_tf_keras}.\nTo define the architecture a \\texttt{Sequential} model is used to arrange the desired layers in a plain stack \\cite{training_arch_tf_keras_seq}.\n\n\\begin{lstlisting}[style=python, caption={Sequential model}, label=lst:arch]\n# Convolutional Neural Network Architecture\n# Convolution layers\nmodel = models.Sequential()\nmodel.add(layers.Conv2D(16, (5, 5), padding='same', activation='relu', input_shape=fh.inf_shape))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(32, (3, 3), padding='same', activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(32, (3, 3), padding='same', activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(64, (3, 3), padding='same', activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(64, (3, 3), padding='same', activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(128, (3, 3), padding='same', activation='relu'))\nmodel.add(layers.MaxPooling2D((2, 2)))\nmodel.add(layers.Conv2D(128, (3, 3), padding='same', activation='relu'))\n\n# Dense layers\nmodel.add(layers.Flatten())\nmodel.add(layers.Dense(512, activation='relu'))\nmodel.add(layers.Dense(22))\n\\end{lstlisting}\n", "meta": {"hexsha": "ba78cbaf1746093c063f126bb72d13593098f1f6", "size": 7865, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/thesis/chapters/training_of_the_cnn/architecture.tex", "max_stars_repo_name": "MuellerDominik/AIonFPGA", "max_stars_repo_head_hexsha": "f2379782660d4053a5bb60b9f6c6dea17363f96d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-01-21T09:42:10.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:36:12.000Z", "max_issues_repo_path": "doc/thesis/chapters/training_of_the_cnn/architecture.tex", "max_issues_repo_name": "MuellerDominik/AIonFPGA", "max_issues_repo_head_hexsha": "f2379782660d4053a5bb60b9f6c6dea17363f96d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/thesis/chapters/training_of_the_cnn/architecture.tex", "max_forks_repo_name": "MuellerDominik/AIonFPGA", "max_forks_repo_head_hexsha": "f2379782660d4053a5bb60b9f6c6dea17363f96d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-20T14:17:25.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-20T14:17:25.000Z", "avg_line_length": 65.5416666667, "max_line_length": 240, "alphanum_fraction": 0.7018436109, "num_tokens": 2336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.40673774548308833}}
{"text": "\\documentclass[letter]{article}\n\\renewcommand{\\baselinestretch}{1.25}\n\n\\usepackage[margin=1in]{geometry}\n\\usepackage{physics}\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n%\\usepackage{pythonhighlight}\n\\usepackage{hyperref}\n\\usepackage{fancyvrb}\n\n% MATLAB Formating Code\n\\usepackage[numbered,framed]{matlab-prettifier}\n\\lstset{style=Matlab-editor,columns=fullflexible}\n\\renewcommand{\\lstlistingname}{Script}\n\\newcommand{\\scriptname}{\\lstlistingname}\n\n% Command for easier minimization problem def\n\\newcommand{\\optpblm}[3][eq:default]{\n\t\\begin{equation}\\label{#1}\n% Array method... more centered\t\t\n%\t\t\\begin{array}{rl}\n%\t\t\t\\text{minimize}  \\hspace{0.2in} &#2 \\vspace{5pt}\\\\\n%\t\t\t\\text{subject to} \\hspace{0.2in} &#3\n%\t\t\\end{array}\n% Aligned method... left aligned... idk if its better\n\t\t\\begin{aligned}\n\t\t\t\\text{minimize} \\hspace{0.5in} &#2\\vspace{5pt}\\\\\n\t\t\t\\text{subject to \\hspace{0.5in}} &#3\n\t\t\\end{aligned}\t\n\t\\end{equation}\n}\n\n\\newcommand{\\maxpblm}[3][eq:default]{\n\t\\begin{equation}\\label{#1}\n\t\t\\begin{aligned}\n\t\t\t\\text{maximize} \\hspace{0.5in} &#2\\vspace{5pt}\\\\\n\t\t\t\\text{subject to \\hspace{0.5in}} &#3\n\t\t\\end{aligned}\t\n\t\\end{equation}\n}\n\\allowdisplaybreaks\n\n\\title{MECH 6327 - Homework 4}\n\\author{Jonas Wagner}\n\\date{2021, April 12}\n\n\n\n\n\\begin{document}\n\n\\maketitle\n\n\\newpage\n\\tableofcontents\n\n\\newpage\n\\section*{BV Textobook Problems}\n\\subsection{Problem 5.43}\nThe dual a SOCP defined as:\n\\optpblm{f^T x}{\\norm{A_i x + b_i}_2 \\leq c_i^T x + d_i, \\ i = 1,\\dots,m}\nwith $x \\in \\real^n$ can be expressed as:\n\\maxpblm{\\sum_{i=1}^m \\qty(b_i^T u_i - d_i v_i)}{\n\t  \\sum_{i=1}^m \\qty(A_i^T u_i - c_i v_i) + f = 0\\\\\n\t& \\norm{u_i}_2 \\leq v_i, \\ i = 1,\\dots,m}\nwith variables $u_i \\in \\real^n_i$, $v_i \\in \\real, \\ i=1,\\dots,m$ and problem data $f\\in \\real^n, A_i \\in \\real^{n_i \\cross n}, b_i \\in \\real^{n_i}, c_i \\in \\real, \\ i = 1,\\dots,m$.\\\\\n\n\\newpage\n\\subsubsection{Part a}\n\\textbf{Problem:}\nDerive the dual by defining $y_i \\in \\real^{n_i}$ and $t_i \\in \\real$ and the equalities $y_i = A_i x + b_i, \\ t_i = c_i^T x + d_i$ then deriving the Lagrange dual.\\\\\n\n\\noindent\n\\textbf{Solution:}\nThe problem can first be written in a standard form as:\n\\optpblm{f^T}{\n\ty_i = A_i x + b_i\\\\\n\t&t_i = c_i^T x + d_i\\\\\n\t&\\norm{y_i}_2 \\leq t_i, \\ \\forall i = 1, \\dots, m}\n\nThe lagrange can then be defined with\n\\begin{align}\n\tL(x,y,t, \\lambda_i, \\nu_i, \\mu_i)\n\t&= f^T \n\t+ \\sum_{i=1}^m \\lambda_i \\qty(\\norm{y_i}_2 - t_i)\n\t+ \\sum_{i=1}^m \\mu_i^T (t_i - C_i x + d_i)\\\\\n\t&= \\qty(f + \\sum_{i=1}^m \\qty(A_i^T \\mu_i - c_i \\nu_i))^T x\n\t+ \\sum_{i=1}^m \\lambda_i \\norm{y_i}_2 + \\mu_i^T y_i \\nonumber\\\\\n\t&\\ \\ \\ + \\sum_{i=1}^m \\qty(-\\lambda_i + \\nu_i) t_i\n\t- \\qty(\\sum_{i=1}^m b_i^T \\mu_i - d_i \\nu_i)\n\\end{align}\n\nSince the definition of the dual optimization problem is to maximize $$g(\\lambda_i, \\nu_i, \\mu_i) = \\inf_{x,y_i,t_i} L(x,y,t, \\lambda_i, \\nu_i, \\mu_i)$$ the $\\inf$ can be found by determining when a min/max would occur for each of the variables.\n\nFor the critical point on $x$ the direvative can be set to zero and thus the following equality must hold:\n\\begin{equation}\n\tf + \\sum_{i=1}^m \\qty(A_i^T \\mu_i - c_i \\nu_i) = 0\n\\end{equation}\n\nFor the $y_i$ related term, it is known $$\\sum_{i=1}^m \\lambda_i \\norm{y_i}_2 + \\mu_i^T y_i$$ will be bounded below if it is within the cone defined by $\\lambda_i \\norm{y_i}_2 \\geq \\norm{\\mu_i}_2 y_i$ which can be rewritten as: $$\\norm{\\mu_i}_2 \\leq \\lambda_i$$\n\nFor the critical point over $t_i$ the equality $\\nu_i = \\lambda_i$.\n\nFrom this the dual problem can be obtained when the quantity $\\qty(\\sum_{i=1}^m b_i^T \\mu_i - d_i \\nu_i)$ is maximized.\n\nThus the dual problem is defined as:\n\\maxpblm{\\sum_{i=1}^m \\qty(b_i^T u_i - d_i v_i)}{\n\t\\sum_{i=1}^m \\qty(A_i^T u_i - c_i v_i) + f = 0\\\\\n\t& \\norm{u_i}_2 \\leq v_i, \\ i = 1,\\dots,m}\n\n\\newpage\n\\subsubsection{Part b}\n\\textbf{Problem:}\nStart with the conic formulation of the SOCP and use the conic dual to prove the equivalence. Use the fact that the second-order dual is self-dual.\\\\\n\n\\noindent\n\\textbf{Solution:}\nStarting with the SOCP given as\n\\optpblm{f^T x}{\\norm{A_i x + b_i}_2 \\leq c_i^T x + d_i, \\ i = 1,\\dots,m}\n\na standard form can be defined by\n\\optpblm{f^T x}{\\qty(A_i x + b_i, c_i^T x + d_i) \\preceq_{2} 0}\n\n\nSince the conic dual transformation is known to transform\n\\optpblm{f^T x}{- \\qty(A^T x + b, c^T x + d) \\preceq_{K} 0}\n\ninto its dual according to its dual cone definition\n\\maxpblm{b^T u + d \\ v}{A^T u + v c = f\\\\ &(u,v) \\succeq_{K^*} 0, \\ i = 1,\\dots,m}\n\nand from the fact that the 2-norm is self-dual, the dual program is given as\n\\maxpblm{\\sum_{i=1}^m \\qty(b_i^T u_i - d_i v_i)}{\n\t- \\sum_{i=1}^m \\qty(A_i^T u_i - c_i v_i) = f\\\\\n\t& (u_i, v_i) \\succeq_{2} 0, \\ i = 1,\\dots,m}\n\nor equivalently\n\\maxpblm{\\sum_{i=1}^m \\qty(b_i^T u_i - d_i v_i)}{\n\t\\sum_{i=1}^m \\qty(A_i^T u_i - c_i v_i) + f = 0\\\\\n\t& \\norm{u_i}_2 \\leq v_i, \\ i = 1,\\dots,m}\n\n\n\\newpage\n\\section{Problem 1: Robust control design}\nFor the standard DT dynamical system defined as:\n\\begin{equation}\n\tx_{t+1} = A x_t + B u_t\n\\end{equation}\nwith dynamic matrix $A$ unknown but assumed to belong to a set:\n\\begin{equation}\n\tA \\in \\mathcal{A} = \\text{conv}(A_1,\\dots,A_m)\n\\end{equation}\nwith $A_i$ and $B$ known.\\\\\n\n\n\\textbf{Problem:}\nFor a state-feedback controller $u_t = K x_t$ use Lyapunov techniques to design it so the system is globally asymptotically stable (GAS) by solving a semi-definite program (SDP).\\\\\n\n\\textbf{Solution:}\nThe closed-loop system for the DT dynamical system can be defined by the dynamics\n\\begin{equation}\n\tx_{t+1} = \\hat{A} x = (A + B K) x\n\\end{equation}\nwhere $\\hat{A} = A + B K$.\n\nIn order for the closed-loop system to be Globally Asymptotically Stable, a quadratic Lyapnov Function could be used to prove that if the following inequality is true then the system is GAS:\n\\begin{equation}\n\t\\hat{A}^T P \\hat{A} - P \\prec 0\n\\end{equation}\n\nSince the system dynamics themselves are uncertain, this inequality will not be enough to prove GAS. This can be be address, however, by considering all $A \\in \\mathcal{A}$ to be a linear combination of the individual corner matrices. Since this is a convex hull, it is known that following this to its conclusion, GAS can be guaranteed for all $A \\in \\mathcal{A}$ if $A_i$ is GAS $\\forall i = 1, \\dots, m$.\n\nFollowing this, a stabalizing gain can then be found as follows:\n\\begin{align}\n\t\\hat{A}_i^T P \\hat{A}_i - P \\prec 0\n\\end{align}\nrecognizing the Schur's compliment form, the following is true\n\\begin{align}\n\t\\mqty[P & \\hat{A}_i^T\\\\ \\hat{A}_i P^{-1}] \\succ 0\\\\\n\t\\mqty[P & (A_i + B K)^T\\\\ (A_i + B K) &P^{-1}] \\succ 0\n\\end{align}\n\nA SDP feasibility problem can then  be done to solve the problem such that\n\\begin{equation}\n\t\\begin{aligned}\n\t\t\\mqty[P & \\hat{A}_i^T\\\\ \\hat{A}_i P^{-1}] \\succ 0\\\\\n\t\tB^{-1} \\qty(\\hat{A}_i - A_i) - K = 0, \\ \\forall i = 1, \\dots, m\n\t\\end{aligned}\n\\end{equation}\nwith variables $P$, $\\hat{A}_i$, and $K$, along with problem data $A_i$ and $B$.\nThis is a problem that can now be easily implemented using CVX or YALMIP in MATLAB for given problem data.\n\n\n\\newpage\n\\section{Problem 2: Nonnegative and sum of squares polynomials}\nThe Motzkin polynomial is defined as:\n\\begin{equation}\n\tM(x,y) = x^2 y^4 + x^4 y^2 + 1 - 3 x^2 y^2\n\\end{equation}\n\n\\textbf{Problem:}\nShow that the Motzkin polynomial is nonnegative but can be expressed as sum of squares. It is sufficient to show this using numerical and/or symbolic solvers.\\\\\n\n\\textbf{Solution:}\nNonegativity of the Motzkin polynomial can be proven using the AM-GM inequality using $n=3$ with $x^4y^2, x^2 y^4, 1$.\n\\begin{align}\n\t\\sqrt[n]{\\prod_{i=1}^{n} x_i} &\\leq \\frac{1}{n} \\sum_{i=1}^n x_i\\\\\n\t\\sqrt[3]{(x^4 y^2)(x^2 y^4)(1)} &\\leq \\frac{1}{3} (x^4 y^2 + x^2 y^4 + 1)\\\\\n\tx^2 y^2 &\\leq \\frac{1}{3} (x^4 y^2 + x^2 y^4 + 1)\\\\\n\t3 x^2 y^2 &\\leq x^4 y^2 + x^2 y^4 + 1\\\\\n\tx^4 y^2 + x^2 y^4 + 1 - 3 x^2 y^2 &\\geq 0\n\\end{align}\nTherefore the Motzkin polynomial is non-negative.\n\nHowever, it is not possible to put this into sum of square form using the standard solver as demonstrated by the infeasability result from the solvesos() command in yalmip (shown in \\appendixname \\ref{apx:matlab})\n\n\n\n\n\n\n\n\n\n\n\\newpage\n\\appendix\n\\section{MATLAB Code:}\\label{apx:matlab}\nAll code I write in this course can be found on my GitHub repository:\\\\\n\\href{https://github.com/jonaswagner2826/MECH6337}{https://github.com/jonaswagner2826/MECH6327}\n\\lstinputlisting[caption={MECH6327\\_HW4},label={script:HW4}]{MECH6327_HW4.m}\n\n\n\n\\newpage\n\\textbf{Refrences:} * not bibtex becouse of time...\n\nhttps://people.eecs.berkeley.edu/~elghaoui/Teaching/EE227A/lecture10.pdf\n\nhttps://people.orie.cornell.edu/miketodd/iccopt.pdf\n\n\n\n\\end{document}", "meta": {"hexsha": "a6810b392a20840eb024bf7dbbce126879581656", "size": 8603, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Homework/HW4/MECH6327-HW4.tex", "max_stars_repo_name": "jonaswagner2826/MECH6327", "max_stars_repo_head_hexsha": "2b55aaf6f9e1bcf5cc684f5c853cadec26acf9d2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Homework/HW4/MECH6327-HW4.tex", "max_issues_repo_name": "jonaswagner2826/MECH6327", "max_issues_repo_head_hexsha": "2b55aaf6f9e1bcf5cc684f5c853cadec26acf9d2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Homework/HW4/MECH6327-HW4.tex", "max_forks_repo_name": "jonaswagner2826/MECH6327", "max_forks_repo_head_hexsha": "2b55aaf6f9e1bcf5cc684f5c853cadec26acf9d2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2581967213, "max_line_length": 407, "alphanum_fraction": 0.6802278275, "num_tokens": 3316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.40673774207196567}}
{"text": "% !TEX root = main.tex\n% !TEX spellcheck = en-US\n\n\\section{Non-malleability of Plonk} \n\\label{sec:plonk}\nIn this section, we show that $\\plonkprotfs$ is simulation-extractable. To this end, we first use the unique opening property to show that\n$\\plonkprotfs$ has the $\\ur{3}$ property,\ncf.~\\cref{lem:plonkprot_ur}.\nNext, we show that $\\plonkprotfs$ is rewinding-based knowledge sound. That is, given a number of accepting transcripts whose first $3$ messages match, we can either extract a witness for the proven statement or use one of the transcripts to break the $\\udlog$ assumption. This result is shown in the AGM, cf.~\\cref{lem:plonkprot_ss}. We then show that $\\plonkprotfs$ is $3$-programmable trapdoor-less ZK in the AGM, cf.~\\cref{lem:plonk_tlzk}.\n\nGiven rewinding-based knowledge soundness, $\\ur{3}$ and trapdoor-less zero-knowledge of $\\plonkprotfs$, we invoke \\cref{thm:se} and conclude that $\\plonkprotfs$ is simulation-extractable.\n\n\\newcommand{\\vql}{\\vec{q_{L}}}\n\\newcommand{\\vqr}{\\vec{q_{R}}}\n\\newcommand{\\vqm}{\\vec{q_{M}}}\n\\newcommand{\\vqo}{\\vec{q_{O}}}\n\\newcommand{\\vx}{\\vec{x}}\n\\newcommand{\\vqc}{\\vec{q_{C}}}\n\n\\subsection{Plonk Protocol Description}\n\\label{sec:plonk_explained}\n\\oursubsub{The constraint system.}\nAssume $\\CRKT$ is a fan-in two arithmetic circuit, whose\nfan-out is unlimited and has $\\numberofconstrains$ gates and $\\noofw$ wires\n($\\numberofconstrains \\leq \\noofw \\leq 2\\numberofconstrains$). The constraint\nsystem of $\\plonk$ is defined as follows:\n\\begin{compactitem}\n\t\\item Let $\\vec{V} = (\\va, \\vb, \\vc)$, where $\\va, \\vb, \\vc\n\t\\in \\range{1}{\\noofw}^\\numberofconstrains$. Entries $\\va_i, \\vb_i, \\vc_i$ represent indices of left,\n\tright and output wires of the circuit's $i$-th gate.\n\t\\item Vectors $\\vec{Q} = (\\vql, \\vqr, \\vqo, \\vqm, \\vqc) \\in\n\t(\\FF^\\numberofconstrains)^5$ are called \\emph{selector vectors}:\n\t\\begin{inparaenum}[(a)]\n\t\t\\item If the $i$-th gate is a multiplication gate then $\\vql_i = \\vqr_i = 0$,\n\t\t$\\vqm_i = 1$, and $\\vqo_i = -1$. \n\t\t\\item If the $i$-th gate is an addition gate then $\\vql_i = \\vqr_i  = 1$, $\\vqm_i =\n\t\t0$, and $\\vqo_i = -1$. \n\t\t\\item $\\vqc_i = 0$ for multiplication and addition gates.\\footnote{The $\\vqc_i$ selector vector is meant to encode (input independent) constants.} \n\t\\end{inparaenum}\n\\end{compactitem}\n\nWe say that vector $\\vx \\in \\FF^\\noofw$ satisfies constraint system if for all $i\n\\in \\range{1}{\\numberofconstrains}$\n\\[\n\\vql_i \\cdot \\vx_{\\va_i} + \\vqr_i \\cdot \\vx_{\\vb_i} + \\vqo \\cdot \\vx_{\\vc_i} +\n\\vqm_i \\cdot (\\vx_{\\va_i} \\vx_{\\vb_i}) + \\vqc_i = 0. \n\\]\n\nPublic inputs $\\brak{\\inp_j}_{j = 1}^{\\instsize}$ are enforced by adding the constrains\n\\[ \\va_i = j, \\vql_i = 1, \\vqm_i = \\vqr_i = \\vqo_i = 0, \\vqc_i = -\\inp_j\\,,\n\\]\nfor some $i \\in \\range{1}{\\noofc}$.\n\n\\oursubsub{Algorithms rolled out}\n\\label{sec:plonk_explained}\n\\plonk{} argument system is universal. That is, it allows to verify computation\nof any arithmetic circuit which has up to $\\numberofconstrains$\ngates using a single SRS. However, to make computation efficient, for each\ncircuit there is allowed a preprocessing phase which extends the SRS with\ncircuit-related polynomial evaluations.\n\nFor the sake of simplicity of the security reductions presented in this paper, we\ninclude in the SRS only these elements that cannot be computed without knowing\nthe secret trapdoor $\\chi$. The rest of the preprocessed input can\nbe computed using these SRS elements. We thus let them to be computed by the\nprover, verifier, and simulator separately.\n\n\\ourpar{$\\plonk$ SRS generating algorithm $\\kgen(\\REL)$:}\nThe SRS generating algorithm picks at random $\\chi \\sample \\FF_p$, computes\nand outputs\n\\(\n\\srs = \\left(\\gone{\\smallset{\\chi^i}_{i = 0}^{\\numberofconstrains + 5}},\n\\gtwo{\\chi} \\right).\n\\)\n\n\\ourpar{Preprocessing:}\nLet $H = \\smallset{\\omega^i}_{i = 1}^{\\numberofconstrains }$ be a\n(multiplicative) $\\numberofconstrains$-element subgroup of a field $\\FF$\ncompound of $\\numberofconstrains$-th roots of unity in $\\FF$. Let $\\lag_i(X)$ be\nthe $i$-th element of an $\\numberofconstrains$-elements Lagrange basis. During\nthe preprocessing phase polynomials $\\p{S_{id j}}, \\p{S_{\\sigma j}}$, for\n$\\p{j} \\in \\range{1}{3}$, are computed:\n\\begin{equation*}\n\\begin{aligned}\n\\p{S_{id 1}}(X) & = X,\\\\[\\myskip]\n\\p{S_{id 2}}(X) & = k_1 \\cdot X,\\\\[\\myskip]\n\\p{S_{id 3}}(X) & = k_2 \\cdot X,\n\\end{aligned}\n\\qquad\n\\begin{aligned}\n\\p{S_{\\sigma 1}}(X) & = {\\textstyle{\\sum_{i = 1}^{\\noofc} \\sigma(i) \\lag_i(X)}},\\\\[\\myskip]\n\\p{S_{\\sigma 2}}(X) & = {\\textstyle \\sum_{i = 1}^{\\noofc}\n\t\\sigma(\\noofc + i) \\lag_i(X)},\\\\[\\myskip]\n\\p{S_{\\sigma 3}}(X) & ={\\textstyle\\sum_{i = 1}^{\\noofc} \\sigma(2 \\noofc + i) \\lag_i(X)}.\n\\end{aligned}\n\\end{equation*}\nCoefficients $k_1$, $k_2$ are such that $H, k_1 \\cdot H, k_2 \\cdot H$ are\ndifferent cosets of $\\FF^*$, thus they define $3 \\cdot \\noofc$\ndifferent elements. Gabizon et al.~\\cite{EPRINT:GabWilCio19} notes that it is enough to set\n$k_1$ to a quadratic residue and $k_2$ to a quadratic non-residue.\n\nFurthermore, we define polynomials $\\p{q_L}, \\p{q_R}, \\p{q_O}, \\p{q_M}, \\p{q_C}$\nsuch that\n\\begin{equation*}\n\\begin{aligned}\n\\p{q_L}(X) & = {\\textstyle \\sum_{i = 1}^{\\noofc}} \\vql_i \\lag_i(X), \\\\\n\\p{q_R}(X) & = \\textstyle \\sum_{i = 1}^{\\noofc} \\vqr_i \\lag_i(X), \\\\\n\\p{q_M}(X) & = \\textstyle \\sum_{i = 1}^{\\noofc} \\vqm_i \\lag_i(X),\n\\end{aligned}\n\\qquad\n\\begin{aligned}\n\\p{q_O}(X) & = \\textstyle  \\sum_{i = 1}^{\\noofc} \\vqo_i \\lag_i(X), \\\\\n\\p{q_C}(X) & =  \\textstyle \\sum_{i = 1}^{\\noofc} \\vqc_i \\lag_i(X). \\\\\n\\vphantom{\\p{q_M}(X)  = \\textstyle \\sum_{i = 1}^{\\noofc} \\vqm_i \\lag_i(X),}\n\\end{aligned}\n\\end{equation*}\n\n\\ourpar{Proving statements in $\\plonkprotfs$} We show how prover's algorithm\n$\\prover(\\srs, \\inp=\\brak{\\wit'_i}_{i = 1}^\\instsize, \\wit = \\brak{\\wit_i}_{i=1}^{3 \\cdot \\noofc})$ operates for\nthe Fiat--Shamir transformed version of Plonk. Note that for notational convenience $\\wit$ also contains the public input wires $\\wit'_i=\\wit_i$, $i\\in \\range{1}{\\ell}$.\n\\begin{description}\n\t\\item[Message 1] Sample $b_1, \\ldots, b_9 \\sample \\FF_p$; compute\n\t$\\p{a}(X), \\p{b}(X), \\p{c}(X)$ as\n\t\\begin{align*}\n\t\\p{a}(X) &= (b_1 X + b_2)\\p{Z_H}(X) + \\textstyle \\sum_{i = 1}^{\\noofc} \\wit_i \\lag_i(X) \\\\\n\t\\p{b}(X) &= (b_3 X + b_4)\\p{Z_H}(X) + \\textstyle \\sum_{i = 1}^{\\noofc} \\wit_{\\noofc + i} \\lag_i(X) \\\\\n\t\\p{c}(X) &= (b_5 X + b_6)\\p{Z_H}(X) + \\textstyle \\sum_{i = 1}^{\\noofc} \\wit_{2 \\cdot \\noofc + i} \\lag_i(X) \n\t\\end{align*}\n\tOutput polynomial commitments $\\gone{\\p{a}(\\chi), \\p{b}(\\chi), \\p{c}(\\chi)}$.  \n\t\n\t\\item[Message 2] Compute challenges $\\beta, \\gamma \\in \\FF_p$ by querying random oracle\n\ton partial proof, that is,\n\t\\(\n\t\\beta = \\ro(\\tzkproof[0..1], 0)\\,, \\qquad \\gamma = \\ro(\\tzkproof[0..1], 1)\\,.\n\t\\)\n\t\n\tCompute permutation polynomial $\\p{z}(X)$\n\t\\begin{multline*}\n\t\\p{z}(X) = (b_7 X^2 + b_8 X + b_9)\\p{Z_H}(X) + \\lag_1(X) + \\\\\n\t+ \\sum_{i = 1}^{\\noofc - 1} \\left(\\lag_{i + 1} (X) \\prod_{j = 1}^{i} \\frac{\n\t\t(\\wit_j +\\beta \\omega^{j - 1} + \\gamma)(\\wit_{\\noofc + j} + \\beta k_1\n\t\t\\omega^{j - 1} + \\gamma)(\\wit_{2 \\noofc + j} +\\beta k_2 \\omega^{j- 1} +\n\t\t\\gamma)} {(\\wit_j+\\sigma(j) \\beta + \\gamma)(\\wit_{\\noofc + j} + \\sigma(\\noofc\n\t\t+ j)\\beta + \\gamma)(\\wit_{2 \\noofc + j} + \\sigma(2 \\noofc + j)\\beta +\n\t\t\\gamma)}\\right)\n\t\\end{multline*}\n\tOutput polynomial commitment $\\gone{\\p{z}(\\chi)}$\n\t\n\t\\item[Message 3] Compute the challenge $\\alpha = \\ro(\\tzkproof[0..2])$, compute the quotient\n\tpolynomial\n\t\\begin{align*}\n\t& \\p{t}(X)  = \\\\\n\t& (\\p{a}(X) \\p{b}(X) \\selmulti(X) + \\p{a}(X) \\selleft(X) + \n\t\\p{b}(X)\\selright(X) + \\p{c}(X)\\seloutput(X) + \\pubinppoly(X) + \\selconst(X)) /  \n\t\\p{Z_H}(X) +\\\\\n\t& + ((\\p{a}(X) + \\beta X + \\gamma) (\\p{b}(X) + \\beta k_1 X + \\gamma)(\\p{c}(X) \n\t+ \\beta k_2 X + \\gamma)\\p{z}(X)) \\infrac{\\alpha}{\\p{Z_H}(X)} \\\\\n\t& - (\\p{a}(X) + \\beta \\p{S_{\\sigma 1}}(X) + \\gamma)(\\p{b}(X) + \\beta \n\t\\p{S_{\\sigma 2}}(X) + \\gamma)(\\p{c}(X) + \\beta \\p{S_{\\sigma 3}}(X) + \n\t\\gamma)\\p{z}(X \\omega))  \\infrac{\\alpha}{\\p{Z_H}(X)} \\\\\n\t& + (\\p{z}(X) - 1) \\lag_1(X) \\infrac{\\alpha^2}{\\p{Z_H}(X)}\n\t\\end{align*}\n\tSplit $\\p{t}(X)$ into degree less then $\\noofc$ polynomials\n\t$\\p{t_{lo}}(X), \\p{t_{mid}}(X), \\p{t_{hi}}(X)$, such that\n\t\\(\n\t\\p{t}(X) = \\p{t_{lo}}(X) + X^{\\noofc} \\p{t_{mid}}(X) + X^{2 \\noofc}\n\t\\p{t_{hi}}(X)\\,.\n\t\\)\n\tOutput $\\gone{\\p{t_{lo}}(\\chi), \\p{t_{mid}}(\\chi), \\p{t_{hi}}(\\chi)}$.\n\t\n\t\\item[Message 4] Get the challenge $\\chz \\in \\FF_p$, $\\chz = \\ro(\\tzkproof[0..3])$.\n\tCompute opening evaluations\n\t\\(\n\t\\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma 2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega),\n\t\\)\n\tCompute the linearization polynomial\n\t\\[\n\t\\p{r}(X) =\n\t\\begin{aligned}\n\t& \\p{a}(\\chz) \\p{b}(\\chz) \\selmulti(X) + \\p{a}(\\chz) \\selleft(X) + \\p{b}(\\chz) \\selright(X) + \\p{c}(\\chz) \\seloutput(X) + \\selconst(X) \\\\\n\t& + \\alpha \\cdot \\left( (\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma)(\\p{c}(\\chz) + \\beta k_2 \\chz + \\gamma) \\cdot \\p{z}(X)\\right) \\\\\n\t& - \\alpha \\cdot \\left( (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma)\\beta \\p{z}(\\chz\\omega) \\cdot \\p{S_{\\sigma 3}}(X)\\right) \\\\\n\t& + \\alpha^2 \\cdot \\lag_1(\\chz) \\cdot \\p{z}(X)\n\t\\end{aligned}\n\t\\]\n\tOutput\n\t$\\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma\n\t\t\t2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega), \\p{r}(\\chz).$\n\t\n\t\\item[Message 5] Compute the opening challenge $v \\in \\FF_p$,\n\t$v = \\ro(\\tzkproof[0..4])$.  Compute the openings for the polynomial commitment\n\tscheme\n\t\\hspace*{-2cm}\\begin{align*}\n\t& \\p{W_\\chz}(X) = \\frac{1}{X - \\chz} \\left(\n\t\\begin{aligned}\n\t& \\p{t_{lo}}(X) + \\chz^\\noofc \\p{t_{mid}}(X) + \\chz^{2 \\noofc} \\p{t_{hi}}(X) - \\p{t}(\\chz)\n\t+ v(\\p{r}(X) - \\p{r}(\\chz)) \n\t+ v^2 (\\p{a}(X) - \\p{a}(\\chz))\\\\\n\t& + v^3 (\\p{b}(X) - \\p{b}(\\chz))\n\t+ v^4 (\\p{c}(X) - \\p{c}(\\chz))\n\t+ v^5 (\\p{S_{\\sigma 1}}(X) - \\p{S_{\\sigma 1}}(\\chz)) \\\\\n\t& + v^6 (\\p{S_{\\sigma 2}}(X) - \\p{S_{\\sigma 2}}(\\chz))\n\t\\end{aligned}\n\t\\right)\\\\\n\t& \\p{W_{\\chz \\omega}}(X) = \\infrac{(\\p{z}(X) - \\p{z}(\\chz \\omega))}{(X - \\chz \\omega)}\n\t\\end{align*}\n\tOutput $\\gone{\\p{W_{\\chz}}(\\chi), \\p{W_{\\chz \\omega}}(\\chi)}$.\n\\end{description}\n\n\\ncase{Plonk verifier $\\verifier(\\srs, \\inp, \\zkproof)$}\\ \\newline\nThe \\plonk{} verifier works as follows\n\\begin{enumerate}\n\t\\item Validate all obtained group elements.\n\t\\item Validate all obtained field elements.\n\t\\item Parse the instance as\n\t$\\smallset{\\wit_i}_{i = 1}^\\instsize \\gets \\inp$.\n\t\\item Compute challenges $\\beta, \\gamma, \\alpha, \\chz, v, u$ from the transcript.\n\t\\item Compute zero polynomial evaluation\n\t$\\p{Z_H} (\\chz) =\\chz^\\noofc - 1$.\n\t\\item Compute Lagrange polynomial evaluation\n\t$\\lag_1 (\\chz) = \\frac{\\chz^\\noofc -1}{\\noofc (\\chz - 1)}$.\n\t\\item Compute public input polynomial evaluation\n\t$\\pubinppoly (\\chz) = \\sum_{i \\in \\range{1}{\\instsize}} \\wit_i\n\t\\lag_i(\\chz)$.\n\t\\item Compute quotient polynomials evaluations\n\t\\begin{multline*}\n\t\\p{t} (\\chz) =  \\Big(\n\t\\p{r} (\\chz) + \\pubinppoly(\\chz) - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \n\t(\\p{c}(\\chz) + \\gamma)\\p{z}(\\chz \\omega) \\alpha - \\lag_1 (\\chz) \\alpha^2\n\t\\Big) / {\\p{Z_H}(\\chz)} \\,.\n\t\\end{multline*}\n\t\\item Compute batched polynomial commitment\n\t$\\gone{D} = v \\gone{r} + u \\gone {z}$ that is\n\t\\begin{align*}\n\t\\gone{D} & = v\n\t\\left(\n\t\\begin{aligned}\n\t& \\p{a}(\\chz)\\p{b}(\\chz) \\cdot \\gone{\\selmulti} + \\p{a}(\\chz)  \\gone{\\selleft} + \\p{b}  \\gone{\\selright} + \\p{c}  \\gone{\\seloutput} + \\\\\n\t& + (\t(\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma) (\\p{c} + \\beta k_2 \\chz + \\gamma) \\alpha  + \\lag_1(\\chz) \\alpha^2)  + \\\\\n\t% &   \\\\\n\t& - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz)\n\t+ \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \\alpha \\beta \\p{z}(\\chz\n\t\\omega) \\gone{\\p{S_{\\sigma 3}}(\\chi)})\n\t\\end{aligned}\n\t\\right) + \\\\\n\t& + u \\gone{\\p{z}(\\chi)}\\,.\n\t\\end{align*}\n\t\\item Computes full batched polynomial commitment $\\gone{F}$:\n\t\\begin{align*}\n\t\\gone{F} & = \\left(\\gone{\\p{t_{lo}}(\\chi)} + \\chz^\\noofc \\gone{\\p{t_{mid}}(\\chi)} + \\chz^{2 \\noofc} \\gone{\\p{t_{hi}}(\\chi)}\\right) + u \\gone{\\p{z}(\\chi)} + \\\\\n\t& + v\n\t\\left(\n\t\\begin{aligned}\n\t& \\p{a}(\\chz)\\p{b}(\\chz) \\cdot \\gone{\\selmulti} + \\p{a}(\\chz)  \\gone{\\selleft} + \\p{b}(\\chz)   \\gone{\\selright} + \\p{c}(\\chz)  \\gone{\\seloutput} + \\\\\n\t& + (\t(\\p{a}(\\chz) + \\beta \\chz + \\gamma) (\\p{b}(\\chz) + \\beta k_1 \\chz + \\gamma) (\\p{c}(\\chz)  + \\beta k_2 \\chz + \\gamma) \\alpha  + \\lag_1(\\chz) \\alpha^2)  + \\\\\n\t% &   \\\\\n\t& - (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}}(\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}}(\\chz) + \\gamma) \\alpha  \\beta \\p{z}(\\chz \\omega) \\gone{\\p{S_{\\sigma 3}}(\\chi)})\n\t\\end{aligned}\n\t\\right) \\\\\n\t& + v^2 \\gone{\\p{a}(\\chi)} + v^3 \\gone{\\p{b}(\\chi)} + v^4 \\gone{\\p{c}(\\chi)} + v^5 \\gone{\\p{S_{\\sigma 1}(\\chi)}} + v^6 \\gone{\\p{S_{\\sigma 2}}(\\chi)}\\,.\n\t\\end{align*}\n\t\\item Compute group-encoded batch evaluation $\\gone{E}$\n\t\\begin{align*}\n\t\\gone{E}  = \\frac{1}{\\p{Z_H}(\\chz)} & \\gone{\n\t\t\\begin{aligned}\n\t\t& \\p{r}(\\chz) + \\pubinppoly(\\chz) +  \\alpha^2  \\lag_1 (\\chz) + \\\\\n\t\t& - \\alpha \\left( (\\p{a}(\\chz) + \\beta \\p{S_{\\sigma 1}} (\\chz) + \\gamma) (\\p{b}(\\chz) + \\beta \\p{S_{\\sigma 2}} (\\chz) + \\gamma) (\\p{c}(\\chz) + \\gamma) \\p{z}(\\chz \\omega) \\right)\n\t\t\\end{aligned}\n\t}\\\\\n\t+ & \\gone{v \\p{r}(\\chz) + v^2 \\p{a}(\\chz) + v^3 \\p{b}(\\chz) + v^4 \\p{c}(\\chz) + v^5 \\p{S_{\\sigma 1}}(\\chz) + v^6 \\p{S_{\\sigma 2}}(\\chz) + u \\p{z}(\\chz \\omega) }\\,.\n\t\\end{align*}\n\t\\item Check whether the verification\n\t% $\\vereq_\\zkproof(\\chi)$\n\tequation holds\n\t\\begin{multline}\n\t\\label{eq:ver_eq} \n\t\\left( \\gone{\\p{W_{\\chz}}(\\chi)} + u \\cdot \\gone{\\p{W_{\\chz\n\t\t\t\t\\omega}}(\\chi)} \\right) \\bullet\n\t\\gtwo{\\chi} - \\\\\n\t\\left( \\chz \\cdot \\gone{\\p{W_{\\chz}}(\\chi)} + u \\chz \\omega \\cdot\n\t\\gone{\\p{W_{\\chz \\omega}}(\\chi)} + \\gone{F} - \\gone{E} \\right) \\bullet\n\t\\gtwo{1} = 0\\,.\n\t\\end{multline}\n\tThe verification equation is a batched version of the verification equation\n\tfrom \\cite{AC:KatZavGol10} which allows the verifier to check openings of\n\tmultiple polynomials in two points (instead of checking an opening of a single\n\tpolynomial at one point).\n\\end{enumerate}\n\n\\ncase{Plonk simulator $\\simulator_\\chi(\\srs, \\td= \\chi, \\inp)$}\\ \nWe describe the simulator in \\cref{lem:plonk_tlzk}.\n\n\\subsection{Simulation extractability of $\\plonk${}}\nDue to lack of space, we provide here only theorem statements and intuition for why they hold. Full proofs are given in \\cref{sec:plonkse_proofs}.\n\n\\oursubsub{Unique Response Property}\n\\begin{lemma}\n\t\\label{lem:plonkprot_ur}\n\tLet $\\PCOMp$ be a polynomial commitment that is $\\epsbind(\\secpar)$-binding and has unique opening property with loss $\\epsop (\\secpar)$. Then $\\plonkprotfs$ is $\\ur{3}$ against algebraic adversaries, who makes up to $q$ random oracle queries, with security loss $\\epsbinding (\\secpar) + \\epsop ( \\secpar )$.\n\\end{lemma}\n\\paragraph{Intuition.} We show that an adversary who can break the $3$-unique response property of $\\plonkprotfs$ can be either used to break the commitment scheme's evaluation binding or unique opening property. The former happens with the probability upper-bounded by $\\epsbinding (\\secpar)$, the latter with the probability upper bounded by $\\epsop (\\secpar)$. \n\n\\begin{proof}\n\tLet $\\adv$ be an algebraic adversary tasked to break the $\\ur{3}$-ness of\n\t$\\plonkprotfs$. We show that the first three prover's messages determine, along with \tthe verifiers challenges, the rest of it. We denote by $\\zkproof^0$ and $\\zkproof^1$ the two proofs that the adversary outputs. To distinguish polynomials and commitments which an honest prover would send in the proof from the polynomials and commitments computed by the adversary we write the latter using indices $0$ and $1$ (two indices as we have two transcripts), e.g.~to describe the quotient polynomial provided by the adversary we write $\\p{t}^0$ and $\\p{t}^1$ instead of $\\p{t}$ as in the description of the protocol.\n\t\n\tWe note that since the unique response property requires from $\\zkproof^{0}$ and $\\zkproof^{1}$ that the first place they possibly differ is the $4$-th prover's message, then the challenge $\\chz$, that is picked by the adversary after the $3$-rd message is the same in both transcripts. This challenge determines the evaluation point of polynomials $\\p{a}(X), \\p{b}(X), \\p{c}(X), \\p{t}(X), \\p{z}(X)$ which commitments are already sent.\n\t\n\tIn its fourth message, the prover provides evaluations of the aforementioned polynomials, along with evaluations of publicly known polynomials $\n\t\\p{S_{\\sigma 1}} (\\chz), \\p{S_{\\sigma 2}} (\\chz)$, and evaluation of a linearization polynomial $\\p{r}(\\chz)$.\n\t\n\tNote that the adversary can output two accepting proofs that differ on their fourth message only if it either manages to break evaluation binding of one of the opening, or provides an incorrect opening which is accepted due to a batching error. Since the commitment scheme is evaluation binding with security loss $\\epsbinding (\\secpar)$, %and the batched verification equation accepts an incorrect opening with probability at most $\\infrac{q}{p}$, cf.~\\cite{EPRINT:GabWilCio19}, \n\tthe adversary can make $\\zkproof^{0}$ and $\\zkproof^{1}$ differ on the fourth message with the same probability. % at most $8  \\cdot \\epsbinding (\\secpar) + \\infrac{q}{p}$. \n\t\n\tNext, assume that the transcripts are the same up to the fourth message, but differ at the fifth. In that message, the adversary provides openings of the evaluations. Since the unique opening property, the adversary can open the valid evaluation of a polynomial to two different values with probability at most $\\epsop (\\secpar)$. (We note that for the KZG polynomial commitment scheme, as used in \\cite{EPRINT:GabWilCio19}, $\\epsop (\\secpar) \\leq \\epsudlog (\\secpar) + \\infrac{q}{p}$, cf.~\\cref{lem:pcomp_op}.)\n\t% , which is upper-bounded by $\\epsudlog (\\secpar) + \\infrac{q}{p}$, cf.~\\cref{lem:pcomp_op}.\n\t\n\tBy the union bound, the adversary is able to break the unique response property with probability upper bounded by $\\epsbinding (\\secpar) + \\epsop (\\secpar)$.\n\t\\qed\n\\end{proof}\n\n\n\\oursubsub{Rewinding-Based Knowledge Soundness}\n\\begin{lemma}\n\t\\label{lem:plonkprot_ss}\n\t$\\plonkprotfs$ is $(3, 3 \\noofc + 6)$-rewinding-based knowledge sound against algebraic adversaries who make up to $q$ random oracle queries with security loss \n\t\\[\n\t\\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)}{1 - \\frac{3 \\noofc + 5}{p}}\\right) + (3 \\noofc + 6) \\cdot \\epsudlog (\\secpar) %+ (3 \\noofc + 6) \\cdot \\epsid (\\secpar)\n\t\\,,\n\t\\]\n\tHere $\\accProb$ is a probability that the adversary outputs an accepting proof, \n\t%$\\epsid(\\secpar)$ is a soundness error of the ideal verifier for $\\plonkprot$, \n\tand $\\epsudlog(\\secpar)$ is security of $(\\numberofconstrains + 5, 1)$-$\\udlog$ \n\tassumption.\n\\end{lemma}\n\n\\paragraph{Intuition.} We use Attema et al.~\\cite[Proposition 2]{EPRINT:AttFehKlo21} to bound the probability that an algorithm $\\tdv$ does not obtain a tree of accepting transcripts in an expected number of runs. This happens with probability at most\n\t\\[\n\t1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)}{1 - \\frac{3 \\noofc + 5}{p}}\n\t\\]\nThen we analyze the case that one of the proofs in the tree $\\tree$ outputted by $\\tdv$ is not accepting by the ideal verifier. This discrepancy can be used to break an instance of an updatable dlog assumption which happens with probability at most $(3 \\noofc + 6)  \\cdot \\epsudlog (\\secpar)$. %Additionally, it may be impossible to extract the witness from a tree where each of the transcripts is accepting by the ideal verifier if the adversary broke soundness of the ideal verifier in one of the transcripts. That happens with probability at most $(3 \\noofc + 6) \\cdot \\epsid (\\secpar)$.\n\n\\begin{proof}\n\tLet $\\adv^{\\ro, \\initU}(\\secparam; r)$ be the adversary who outputs $(\\inp, \\zkproof)$ such that $\\plonkprotfs.\\verifier$ accepts the proof. Let $\\tdv$ be a tree-building algorithm of \\cref{lem:attema} that outputs a tree $\\tree$, and let $\\extcss$ be an extractor that given the tree output by $\\tdv$ reveals the witness for $\\inp$. The main idea of the proof is to show that an adversary who breaks rewinding-based knowledge soundness can be used to break a $\\udlog$-problem instance. The proof goes by game hops. Note that since the tree branches after $\\adv$'s $3$-rd message, the instance $\\inp$, commitments $\\gone{\\p{a} (\\chi), \\p{b} (\\chi), \\p{c} (\\chi), \\p{z} (\\chi), \\p{t_{lo}} (\\chi), \\p{t_{mid}} (\\chi), \\p{t_{hi}} (\\chi)}$, and challenges $\\alpha, \\beta, \\gamma$ are the same in all the transcripts. Also, the tree branches after the third adversary's message where the challenge $\\chz$ is presented, thus tree $\\tree$ is built using different values of $\\chz$.\tWe consider the following games.\n\t\n\t\\ncase{Game 0} %\n\tIn this game the adversary wins if it outputs a valid instance--proof pair $(\\inp, \\zkproof)$, and the extractor $\\extcss$ does not manage to output a witness $\\wit$ such that $\\REL (\\inp, \\wit)$ holds.\n\t\n\t\\ncase{Game 1} %\n\tIn this game the environment aborts the game if the tree building algorithm $\\tdv$ fails in building a tree of accepting transcripts $\\tree$. \n\t\n\t\\ncase{Game 0 to Game 1} %\n\tBy \\cref{lem:attema} probability that Game 1 is aborted, while Game 0 is not, is at most \n\t%\\hamid{2.5}{Should this not be \"1 minus the following\"?}\n\t\\[\n\t1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)} {1 - \\frac{3 \\noofc + 5}{p}} \\,.\n\t\\]\n\t\n\t\\ncase{Game 2} %\n\tIn this game the environment additionally aborts if at least one of its proofs in $\\tree$ is not accepting by an ideal verifier.\n\t\n\t\\ncase{Game 1 to Game 2} % \n\tAs usual, we show a reduction that breaks an instance of a $\\udlog$ assumption when Game 2 is aborted, while Game 1 is not.\n\t\n\tLet $\\rdvudlog$ be a reduction that gets as input an $(\\noofc + 5, 1)$-$\\udlog$ instance $\\gone{1, \\ldots, \\chi^{\\noofc + 5}}, \\gtwo{\\chi}$. Then it can update the instance to another one $\\gone{1, \\ldots, {\\chi'}^{\\noofc + 5}}, \\gtwo{\\chi'}$. Eventually, the reduction outputs $\\chi'$.\n\t%\n\tThe reduction $\\rdvudlog$ proceeds as follows.\n\tFirst, it builds $\\adv$'s SRS $\\srs$ using the input $\\udlog$ instance. Then it processes the adversary's update query by adding it to the list $\\Qsrs$ and passing it to its own update oracle getting instance $\\gone{1, \\ldots, {\\chi'}^{\\noofc + 5}}, \\gtwo{\\chi'}$. The updated SRS $\\srs'$ is then computed and given to $\\adv$. $\\rdvdulog$ also takes care of the random oracle queries made by $\\adv$. It picks their answers honestly and write them in $\\Qro$. The reduction then starts $\\tdv(\\srs, \\adv, r, \\Qro, \\Qsrs)$.\n\t\n\tLet $(1, \\tree)$ be the output returned by $\\tdv$. Let $\\inp$ be a relation proven in $\\tree$.  Consider a transcript $\\zkproof \\in \\tree$ such that $\\vereq_{\\inp, \\zkproof}(X) \\neq 0$, but $\\vereq_{\\inp, \\zkproof}(\\chi') = 0$. Since $\\adv$ is algebraic, all group elements included in $\\tree$ are extended by their representation as a combination of the input $\\GRP_1$-elements. Hence, all coefficients of the verification equation polynomial $\\vereq_{\\inp, \\zkproof}(X)$ are known. \n\tEventually, the reduction finds $\\vereq_{\\inp, \\zkproof}(X)$ zero points and returns $\\chi'$ which is one of them.\n\t\n\tHence, the probability that the adversary wins in Game 2 but does not win in Game 1 is upper-bounded by $(3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)$.\n\t\n\t\\ncase{Conclusion}\n\t\n\tNote that the adversary can win in Game 2 only if $\\tdv$ manages to produce a tree of accepting transcripts $\\tree$, such that each of the transcripts in $\\tree$ is accepting by an ideal verifier. Note that since $\\tdv$ produces $(3 \\noofc + 6)$ accepting transcripts for different challenges $\\chz$, it obtains the same number of different evaluations of polynomials $\\p{a} (X), \\p{b} (X), \\p{c} (X), \\p{z} (X), \\p{t} (X)$. Since all the transcripts are accepting by an idealised verifier, the equality between polynomial $\\p{t} (X)$ and combination of polynomials $\\p{a} (X), \\p{b} (X), \\p{c} (X), \\p{z} (X)$ defined in prover's $3$-rd message description holds. Hence, $\\p{a} (X), \\p{b} (X), \\p{c} (X)$ encodes the valid witness for the proven statement. $\\extcss$ can recreate polynomials' coefficients by interpolation and reveal the witness given $(3 \\noofc + 6)$ evaluations. \n\t% Thus, the probability that extraction fails in that case is upper-bounded by $(3 \\noofc + 6) \\cdot \\epsid(\\secpar)$.\n\t\n\t\n\tHence, the probability that the adversary wins in Game 0 is upper-bounded by \n\t\\[\n\t\\epscss(\\secpar,\\accProb, q) \\leq \\left(1 - \\frac{\\accProb - (q + 1) \\left(\\frac{3 \\noofc + 5}{p} \\right)}{1 - \\frac{3 \\noofc + 5}{p}}\\right) + (3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)\\,. \n\t\\]\n\t\\qed\n\\end{proof}\n\n\n\\oursubsub{Trapdoor-Less Zero-Knowledge of Plonk}\n\\begin{lemma}\n\t\\label{lem:plonk_tlzk}\n\t$\\plonkprotfs$ is 3-programmable trapdoor-less zero-knowledge.\n\\end{lemma}\n\n\\paragraph{Intuition.} The simulator, that does not know the SRS trapdoor can make a simulated proof by programming the random oracle. It proceeds as follows. It picks a random witness and behaves as an honest prover up to the point when a commitment to the polynomial $\\p{t}(X)$ is sent. Since the simulator picked a random witness and $\\p{t}(X)$ is a polynomial only (modulo some negligible function) when the witness is correct, it cannot compute commitment to $\\p{t}(X)$ as it is a rational function. However, the simulator can pick a random challenge $\\chz$ and a polynomial $\\p{\\tilde{t}}(X)$ such that $\\p{t} (\\chz)  = \\p{\\tilde{t}} (\\chz)$. Then the simulator continues behaving as an honest prover. We argue that such a simulated proof is indistinguishable from a real one.\n\n\\begin{proof}\n\tAs noted in \\cref{def:upd-scheme}, subvertible zero-knowledge implies updatable zero-knowledge. Hence, here we show that Plonk is TLZK even against adversaries who picks\n\tthe SRS on its own.\n\t\n\tThe adversary $\\adv(\\secparam)$ picks an SRS $\\srs$ and instance--witness pair\n\t$(\\inp, \\wit)$ and gets a proof $\\zkproof$ simulated by the simulator\n\t$\\simulator$ which proceeds as follows.\n\t\n\tFor its $1$-st message the simulator  picks randomly both the randomizers $b_1, \\ldots, b_6$ and\n\tsets $\\wit_i = 0$ for $i \\in \\range{1}{3\\noofc}$. Then $\\simulator$\n\toutputs $\\gone{\\p{a}(\\chi), \\p{b}(\\chi), \\p{c}(\\chi)}$. For the first\n\tchallenge, the simulator picks permutation argument challenges $\\beta, \\gamma$\n\trandomly.\n\t\n\tFor its $2$-nd message, the simulator computes $\\p{z}(X)$ from\n\tthe newly picked randomizers $b_7, b_8, b_9$ and coefficients of polynomials\n\t$\\p{a}(X), \\p{b}(X), \\p{c}(X)$. Then it evaluates $\\p{z}(X)$ honestly and outputs\n\t$\\gone{\\p{z}(\\chi)}$. Challenge $\\alpha$ that should be sent by the verifier\n\tafter the simulator's $2$ message is picked by the simulator at random.\n\t\n\tIn its $3$-rd message the simulator starts by picking at random a challenge $\\chz$, which\n\tin the real proof comes as a challenge from the verifier sent \\emph{after} the prover\n\tsends its $3$-rd message. Then $\\simulator$ computes evaluations\n\t\\(\\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma\n\t\t\t2}}(\\chz), \\pubinppoly(\\chz), \\lag_1(\\chz), \\p{Z_H}(\\chz),\\allowbreak\n\t\\p{z}(\\chz\\omega)\\) and computes $\\p{t}(X)$ honestly. Since for a random\n\t$\\p{a}(X), \\p{b}(X), \\p{c}(X), \\p{z}(X)$ the constraint system is (with\n\toverwhelming probability) not satisfied and the constraints-related polynomials\n\tare not divisible by $\\p{Z_H}(X)$, hence $\\p{t}(X)$ is a rational function\n\trather than a polynomial. Then, the simulator evaluates $\\p{t}(X)$ at $\\chz$ and\n\tpicks randomly a degree-$(3 \\noofc + 15)$ polynomial $\\p{\\tilde{t}}(X)$ such that\n\t$\\p{t}(\\chz) = \\p{\\tilde{t}}(\\chz)$ and publishes a commitment\n\t$\\gone{\\p{\\tilde{t}_{lo}}(\\chi), \\p{\\tilde{t}_{mid}}(\\chi),\n\t\t\\p{\\tilde{t}_{hi}}(\\chi)}$. After that the simulator outputs $\\chz$ as a\n\tchallenge.\n\t\n\tFor the next message, the simulator computes polynomial $\\p{r}(X)$ as an honest\n\tprover would, cf.~\\cref{sec:plonk_explained} and evaluates $\\p{r}(X)$ at $\\chz$.\n\t\n\tThe rest of the evaluations are already computed, thus $\\simulator$ simply outputs\n\t\\( \\p{a}(\\chz), \\p{b}(\\chz), \\p{c}(\\chz), \\p{S_{\\sigma 1}}(\\chz), \\p{S_{\\sigma\n\t\t\t2}}(\\chz), \\p{t}(\\chz), \\p{z}(\\chz \\omega)\\,.  \\) After that it picks randomly\n\tthe challenge $v$, and prepares the the last message as an honest prover\n\twould. Eventually, $\\simulator$ and outputs the final challenge, $u$, by picking it\n\tat random as well.\n\t\n\tWe argue about zero-knowledge as usual. The property holds since the polynomials that has witness elements at their coefficients are randomized by at least two randomizers and are evaluated at at most two points; and the simulator computes all polynomials as an honest prover would.\n\t\\qed\n\\end{proof}\n\n\\subsection*{Simulation Extractability of~$\\plonkprotfs$}\nSince \\cref{lem:plonkprot_ur,lem:plonkprot_ss,lem:plonk_tlzk} hold, $\\plonkprot$ is $\\ur{3}$,\nrewinding-based knowledge sound and trapdoor-less zero-knowledge. We now make use of \\cref{thm:se} and show that\n$\\plonkprot_\\fs$ is simulation-extractable as defined in \\cref{def:updsimext}.\n\n\\begin{corollary}[Simulation extractability of $\\plonkprot_\\fs$]\n\t\\label{thm:plonkprotfs_se}\n\t$\\plonkprotfs$ is \\emph{updatable simulation-extractable} against any $\\ppt$ adversary $\\advse$ who makes up to $q$ random oracle queries and returns an accepting proof with probability at least $\\accProb$ with extraction failure probability \n\t\\[\n\t\\epsse(\\secpar, \\accProb, q) \\leq \\left(1 - \\frac{\\accProb - \\epsur (\\secpar) - (q + 1) \\epserr (\\secpar)} {1 - \\epserr (\\secpar)}\\right) + (3 \\noofc + 6) \\cdot \\epsudlog (\\secpar)\\COMMENT{ + (3 \\noofc + 6) \\cdot \\epsid (\\secpar)},\n\t\\]\n\twhere $\\epserr (\\secpar) = \\frac{3 \\noofc + 5}{p}$, $\\epsur (\\secpar) \\leq \\epsbind (\\secpar) + \\epsop (\\secpar)$, $p$ is the size of the field, and $\\noofc$ is the number of constrains in the circuit. \n\\end{corollary}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n\n", "meta": {"hexsha": "c2fb8a092efc54c6bbd8b05e4b975fd4a0852aeb", "size": 29936, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "EPRINT/non-malleability-of-pfs-eprint.tex", "max_stars_repo_name": "clearmatics/research-plonkext", "max_stars_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "EPRINT/non-malleability-of-pfs-eprint.tex", "max_issues_repo_name": "clearmatics/research-plonkext", "max_issues_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EPRINT/non-malleability-of-pfs-eprint.tex", "max_forks_repo_name": "clearmatics/research-plonkext", "max_forks_repo_head_hexsha": "7da7fa2b6aa17142ef8393ace6aa532f3cfd12b4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.2403433476, "max_line_length": 1008, "alphanum_fraction": 0.6607429182, "num_tokens": 11038, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4066519499757136}}
{"text": "\\hypertarget{haskell}{%\n\\section{Haskell - Defining Functions}\\label{haskell}}\n\n\\hypertarget{conditional-expressions}{%\n\\subsection{Conditional Expressions}\\label{conditional-expressions}}\n\nAs in most programming languages, functions can be defined using\nconditional expressions.\n\n\\begin{lstlisting}[language=Haskell]\nabs :: Int -> Int\nabs n = if n >= 0 then n else -n\n\\end{lstlisting}\n\nabs takes an integer n and returns n if it is non-negative and -n\notherwise.\n\nConditional expressions can also be nested:\n\n\\begin{lstlisting}[language=Haskell]\nsignum :: Int -> Int\nsignum n = if n < 0 then -1 else\nif n == 0 then 0 else 1\n\\end{lstlisting}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\nIn Haskell, conditional expressions must always have an else branch.\n\\end{tcolorbox}\n\n\\hypertarget{guarded-equations}{%\n\\subsubsection{Guarded Equations}\\label{guarded-equations}}\n\nAs an alternative to conditionals, functions can also be defined using\nguarded equations\n\n\\begin{lstlisting}[language=Haskell]\nabs n | n >= 0 = n\n      | otherwise = -n\n\\end{lstlisting}\n\nGuarded equations can be used to make definitions involving multiple\nconditions easier to read.\n\n\\hypertarget{pattern-matching}{%\n\\subsection{Pattern Matching}\\label{pattern-matching}}\n\nMany functions have a particularly clear definition using pattern matching on their arguments.\n\n\\begin{lstlisting}[language=Haskell]\nlucky :: (Integral a) => a -> String  \nlucky 7 = \"LUCKY NUMBER SEVEN!\"  \nlucky x = \"Sorry, you're out of luck, pal!\" \n\\end{lstlisting}\n\nWhen you call lucky, the patterns will be checked from top to bottom and when it conforms to a pattern, the corresponding function body will be used. The only way a number can conform to the first pattern here is if it is 7. If it's not, it falls through to the second pattern, which matches anything and binds it to x.\n\n\\begin{lstlisting}[language=Haskell]\nfactorial :: (Integral a) => a -> a  \nfactorial 0 = 1  \nfactorial n = n * factorial (n - 1) \n\naddVectors :: (Num a) => (a, a) -> (a, a) -> (a, a)  \naddVectors a b = (fst a + fst b, snd a + snd b)  \n--addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)\n\\end{lstlisting}\n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\nThe underscore symbol \\_ is a wildcard pattern that matches any argument value.\nPatterns are matched in order.\nPatterns may not repeat variables\n\\end{tcolorbox}\n\n\\hypertarget{list-patterns}{%\n\\subsubsection{List Patterns}\\label{list-patterns}}\n\nSince [1,2,3] is just syntactic sugar for 1:2:3:[], you can also use the former pattern. A pattern like x:xs will bind the head of the list to x and the rest of it to xs, even if there's only one element so xs ends up being an empty list. \n\n\\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]\n[1,2,3,4] means internal actually 1:(2:(3:(4:[]))). <- Syntactic Sugar\n\\end{tcolorbox}\n\nFunctions on lists can be defined using x:xs patterns. For more operations on lists refer to chapter \\ref{sec:Operationonlists}.\n\n\\begin{lstlisting}[language=Haskell]\nhead :: [a] -> a\nhead (x:_) = x\ntail :: [a] -> [a]\ntail (_:xs) = xs\n\nhead' :: [a] -> a  \nhead' [] = error \"Can't call head on an empty list, dummy!\"  \nhead' (x:_) = x  \n\nghci> let xs = [(1,3), (4,3), (2,4), (5,3), (5,6), (3,1)]  \nghci> [a+b | (a,b) <- xs]  \n[4,7,6,8,11,4]  \n\\end{lstlisting}\n\n\\subsection{Guard}\n\nWhereas patterns are a way of making sure a value conforms to some form and deconstructing it, guards are a way of testing whether some property of a value (or several of them) are true or false. Guards are indicated by pipes that follow a function's name and its parameters. A guard is basically a boolean expression. If it evaluates to True, then the corresponding function body is used. If it evaluates to False, checking drops through to the next guard and so on. Many times, the last guard is otherwise. otherwise is defined simply as otherwise = True and catches everything. \n\nGuards can also be written inline, although I'd advise against that because it's less readable, even for very short functions.\n\n\\begin{lstlisting}[language=Haskell]\nbmiTell :: (RealFloat a) => a -> a -> String  \nbmiTell weight height  \n    | bmi <= skinny = \"You're underweight, you emo, you!\"  \n    | bmi <= 25.0 = \"You're supposedly normal. Pffft, I bet you're ugly!\"  \n    | bmi <= 30.0 = \"You're fat! Lose some weight, fatty!\"  \n    | otherwise   = \"You're a whale, congratulations!\"  \n    where bmi = weight / height ^ 2 \n          skinny = 18.5  \n\nmax' :: (Ord a) => a -> a -> a  \nmax' a b | a > b = a | otherwise = b  \n\\end{lstlisting}\n\nWe put the keyword \\textbf{where} after the guards (usually it's best to indent it as much as the pipes are indented) and then we define several names or functions. These names are visible across the guards and give us the advantage of not having to repeat ourselves.\n\n\\clearpage\n\\subsection{Let Statement}\n\nThe form is let <bindings> in <expression>. The names that you define in the let part are accessible to the expression after the \\textbf{in} part. Let bindings are expressions and are fairly local in their scope, they can't be used across guards (which \\textit{where} can.\n\n\\begin{lstlisting}[language=Haskell]\ncylinder :: (RealFloat a) => a -> a -> a  \ncylinder r h = \n    let sideArea = 2 * pi * r * h  \n        topArea = pi * r ^2  \n    in  sideArea + 2 * topArea  \n    \n--Different variables are seperated with semikolon.\nghci> (let a = 100; b = 200; c = 300 in a*b*c, let foo=\"Hey \"; bar = \"there!\" in foo ++ bar)  \n(6000000,\"Hey there!\") \n\\end{lstlisting}\n\n\\hypertarget{lambda-expressions}{%\n\\subsection{Lambda Expressions}\\label{lambda-expressions}}\n\nFunctions can be constructed without naming the functions by using\nlambda expressions.\n\n\\begin{lstlisting}[language=Haskell]\n$\\lambda$x -> x + x\n\\end{lstlisting}\n\nThe symbol $\\lambda$ is the Greek letter lambda, and is typed at the keyboard as a backslash \\textbackslash{}.\n\n\\begin{itemize}\n\\tightlist\n\\item\n  Lambda expressions can be used to give a formal meaning to functions\n  defined using currying\n\\item\n  Lambda expressions are also useful when defining functions that return\n  functions as results\n\\item\n  Lambda expressions can be used to avoid naming functions that are only\n  referenced once\n\\end{itemize}\n\n\\hypertarget{operator-sections}{%\n\\subsection{Operator Sections}\\label{operator-sections}}\n\nAn operator written between its two arguments can be converted into a\ncurried function written before its two arguments by using parentheses.\n\n\\begin{lstlisting}[language=Haskell]\n> 1+2\n3\n> (+) 1 2\n3\n\nor\n> (1+) 2\n3\n\\end{lstlisting}\n\nIn general, if $\\oplus$ is an operator then functions of the form ($\\oplus$), (x$\\oplus$) and (y$\\oplus$) are called sections.\n\n\\clearpage\n", "meta": {"hexsha": "7b3f4ea350477501336fcba60d55dec7f6fbdfd4", "size": 6704, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TSM_AdvPrPa/Summary/05_Haskell04.tex", "max_stars_repo_name": "nortismo/mse-documentations", "max_stars_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_stars_repo_licenses": ["Beerware"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TSM_AdvPrPa/Summary/05_Haskell04.tex", "max_issues_repo_name": "nortismo/mse-documentations", "max_issues_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_issues_repo_licenses": ["Beerware"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TSM_AdvPrPa/Summary/05_Haskell04.tex", "max_forks_repo_name": "nortismo/mse-documentations", "max_forks_repo_head_hexsha": "cc67637785237d630f077a863edcd5f49aa52b59", "max_forks_repo_licenses": ["Beerware"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-15T07:10:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-15T07:10:24.000Z", "avg_line_length": 36.6338797814, "max_line_length": 581, "alphanum_fraction": 0.7197195704, "num_tokens": 1887, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792043, "lm_q2_score": 0.8006919949619793, "lm_q1q2_score": 0.406600894675078}}
{"text": "\\chapter{Model-based EMG-driven Control}\n\\label{ch:ModelControl}\n\n% Atualizar para novo texto presente nos artigos.\n\n\\section{Control Description}\n\nThe Model-Based control method utilizes a dynamic model of the body to predict the dynamic response according to the input given to the model.\n\nThere are basically three ways the dynamic model can be obtained: through mathematical model, system identification model and artificial intelligence model \\cite{Anam2012988}.\n\nFor this work the chosen model is the system identification model.  The system identification method is often used because of the difficulty in precisely describe the dynamic model through mathematical equations. To do so, a set of inputs and outputs are measured through experiments and then an identification algorithm develops the relationship between the inputs and outputs of the system.\n\n%Four modeling techniques were applied to determine which one better estimates the model which determines the elbow angle with EMG signals as input: ARX, ARMAX, ARIMAX and SS. The model that had the highest fitness value was the ARMAX model.\n\nBy using a dynamic model that mimics the user's limb dynamics, the exoskeleton will be capable of performing limb-like movements using the sEMG signals as input.\n\nThe main disadvantage of this control method is that, in order to develop the dynamic model, extensive experiments must be conducted on each subject to calculate his/her specific model parameters. Even a slight change in the electrode positioning on the subjects' skin can alter the results from the controller. This would require a calibration procedure every time the user wears the exoskeleton.\n\n\\section{Conducted experiment}\n\nThis section presents a method to estimate the elbow joint angle from surface electromyography (sEMG) measurements of biceps, triceps and brachioradialis. This estimation is of major importance for the design of human robot interfaces based on sEMG, for the modeling of the muscular system and for the design of bio-inspired mechanisms. However, the interpretation and processing of electromyography signals is challenging due to nonlinearities, unmodeled muscle dynamics noise and interferences. In order to determine an estimation model and a calibration procedure for the model parameters, a set of experiments were carried out with seven subjects. The experiments consisted of series of continuous (cyclical) and discrete elbow flexo-extensions. The sEMG data from the biceps brachii, triceps brachii and brachioradialis and the joint angle were recorded. After the model was selected, a second experiment was performed in order to validate the estimation procedure. The results show an effective model for the EMG-to-angle relation with great values for both correlation and mean-square-root error when compared to the measured angle data.\n\n\\subsection{Methods}\n\\subsubsection{Subjects and experimental setup}\nSeven volunteers (age: 34.3 $\\pm$ 14.7 years, height: 1.74 $\\pm$ 0.1 m, weight: 67.9 $\\pm$ 15.7 kg, 4 male, 3 female, all right-handed) with no known neuromuscular deficit participated in the experiments. Elbow joint angle along with the surface Electromyography (sEMG) of three right arm muscles, biceps brachii, triceps brachii and brachioradialis were recorded. \nsEMG was measured with 3 pairs of BTS FREEEMG 1000 \\textsuperscript{\\textregistered} electrodes with an electrode separation of 20mm with the electrode diameter being 4mm. A pair of electrodes was placed on the biceps and other pair on the triceps following the SENIAM guidelines \\cite{SENIAM20170110}. To determine the electrode positions of the brachioradialis muscle, the subject was asked to apply force to flex the forearm while keeping it at \\(90^{\\circ}\\). Then, the electrode was placed on the belly of the muscle and its respective pair placed distally at a 20mm following the muscle fiber direction. The sampling rate was of 1kHz with 16 bit resolution. The user interface was the BTS FREEEMG software. \n\nTo measure the joint angle, a six degrees of freedom Inertial Measurement Unit (IMU, VN-100 from VectorNav\\textsuperscript{\\textregistered}), with \\(0.01^{\\circ}\\) precision, was attached on the internal aspect of the forearm, located at two-thirds distance from the elbow to the wrist. The angle values were acquired with a rate of 100 samples per second. The data were collected with Matlab\\textsuperscript{\\textregistered} \n\n\\subsubsection{Experimental Protocol}\n\n\\begin{figure}[thpb]\n      \\centering\n      \\includegraphics[scale=0.32]{Images/Experiment_Image.jpg}\n      \\caption{Experimental setup on a test subject}\n      \\label{Experimental Setup}\n   \\end{figure}\n\nThe subject sat on a chair, with the knees flexed at \\(90^{\\circ}\\), the back perpendicular to the ground with the scapulas pressed against the wall. The back of the arm was leaning against a rubber support that was attached to the wall. This setup guaranteed that the subject was comfortable enough to perform repeated elbow flexions and extensions while maintaining the upper arm steady. \n\nThe test protocol had three parts: The first one consisted of an isometric force test to obtain the Maximum Voluntary Contraction (MVC). The elbow of subject was kept in a fixed position at \\(90^{\\circ}\\) and he/she was asked to apply the maximal possible force to flex the elbow. The subject was given a three minute interval before the next set.\n\n\nIn the second part, the subject was asked to perform five consecutive elbow flexion and extension movements from  \\(50^{\\circ}\\) to \\(140^{\\circ}\\) with a frequency of 0.5Hz. To help the subject reach the correct target angles a template was attached to the wall parallel to the subject, to provide visual guidance. To achieve the desired movement speed a metronome was set at the speed of 60 bpm so that the subject could synchronize the movements with the sound of the metronome.    \n\n   The subject was given a minute of rest before the third part of the experiments. In this part the subject was asked to make an elbow flexion for 1s, then hold his forearm at \\(140^{\\circ}\\) for 1 second, then a 1 second extension movement and then hold his forearm at \\(50^{\\circ}\\) for another second. This movement should be repeated five times. Another one minute resting time was given to the subject.\nBoth of the continuous and interval tests were repeated with 1.5kg and 3kg extra weight placed at the subject's hand.\n\nNo subjects reported fatigue during the experiment.\n\nThe test was repeated in a different day, on all test subjects to further analyze the repeatability of the model proposed in this work.\n\nAll the data from the tests were transferred to Matlab\\textsuperscript{\\textregistered} for further analysis and processing.\n\n\n\n\\subsubsection{Experimental Data Processing}\n\nThe EMG data were processed as follows. Further explanations can be found on the literature \\cite{Rose20161112}\\cite{hayashibe:lirmm-00429594}\n\\begin{enumerate}\n\\item high-pass filtering of the EMG data, using a 2nd order Butterworth filter, with a cutoff frequency of 30 Hz, thus removing movement artifact.\n\\item Wave rectification\n\\item Second Order Butterworth Filter, with 1Hz cutoff frequency.\n\\item normalization with the peak of Maximum Voluntary Contraction (MVC)\n\\end{enumerate}\n\nThis way, the EMG is smoothed and presented as a percentage of the subject MVC instead of Volts.\n\nA low-pass, 5 Hz cutoff frequency, second-order Butterworth filter is applied to the angular data to remove errors and other undesired signals.\n\nSince the position tracking data was sampled at 100 Hz while the EMG data was sampled at 1KHz, all the position tracking data was resampled to 1000 Hz, an antialiasing finite impulse response (FIR) lowpass filter was applied and the delay introduced by the filter was compensated.\n\nFigure \\ref{Angle and EMG} shows an example of the recorded elbow angle and processed sEMG for the continuous movement with no extra weight.\n\n\n\\begin{figure}[thpb]\n      \\centering\n      \\includegraphics[height = 0.8\\textheight]{Images/Angle_and_EMGs.jpg}\n      \\caption{a) Joint angle for the continuous movement with no extra weight, recorded with the IMU; sEMG values for the b) biceps brachii, c) triceps brachii and d) brachioradialis for the continuous movement with no extra weight.}\n      \\label{Angle and EMG}\n   \\end{figure}\n\n\n\\subsection{Linear System Modeling}\n\n\\begin{figure}[thpb]\n      \\centering\n      \\includegraphics[scale=0.5]{Images/Models_comparison_5.jpg}\n      \\caption{Estimated elbow angle using the models responses compared to the elbow angle measured with the IMU. The estimated models were ARX, State Space, ARMAX and ARIMAX.}\n      \\label{Models Comparison}\n   \\end{figure}\n\nIt was assumed that the arm has the same model with different inertia parameters for the different weights attached to the arm of the subject arm. Considering a simple model of the elbow (arm with only 1 degree of freedom): \n\n\\begin{equation}\\label{eq:simpleModel}\nT = (J + M\\cdot L^2)\\cdot \\ddot{\\theta}  + B \\cdot \\dot{\\theta}  + (m\\cdot l + M \\cdot L) \\cdot g \\cdot cos(\\theta)\n\\end{equation}\n\n\nWhere T is the elbow joint torque, J is the forearm inertia, B is the damping factor of the joint, m is the forearm mass, M is the dumbbell's mass, g is the gravity force and \\(\\theta\\) is the joint angle. From this simple model it is easy to infer that, by changing the dumbbell's mass, the arm model parameters also change.\n\nFour different modeling techniques were applied to determine which one best estimated the model that provides the elbow angle as an output taking the three EMG signals as inputs. These modeling techniques were: Auto-Regressive with Exogenous Input (ARX), Auto-Regressive Moving-Average with Exogenous Input (ARMAX), Auto-Regressive Integrated Moving-Average with Exogenous Input (ARIMAX) and State Space (SS).\n\nTo determine the best modeling technique, 10 models of each type were created with random parameter orders. Their estimation of the elbow joint angle was compared with each other. The model with the best fit value was chosen.  \n\nWith the model estimation technique chosen, it is necessary to determine the order of its parameters. To determine the chosen model order, 400 random combinations were tested for each data set with order values going from 0 to 10. The order chosen was the one that gave the best fit (see eq. \\ref{eq:NRMSE}) between the estimated value and the one measured by the experiment. The coefficients of the models were estimated using time-domain data in Matlab\\textsuperscript{\\textregistered} (The Mathworks Inc, USA), minimizing a quadratic prediction error criterion.\n\nTo determine the best fit the normalized Root-mean-square error (NRMSE)  was used:\n\\begin{equation}\n\\label{eq:NRMSE}\nNRMSE = 100*\\left(1- \\frac{||y-\\hat{y}||}{||y-mean(y)||}\\right)\n\\end{equation}\n\nWhere $y$ is the reference signal and $\\hat{y}$ is the signal being evaluated.\n\n\\subsection{Results}\n\nFigure \\ref{Models Comparison} compares the different models with measured elbow angle and shows the fitness value for each data set.\nThe ARMAX model has the highest fitness value. For this reason it was the chosen model for the consequent estimations.\n\nThe ARMAX model has the following form:\n\n\\begin{equation}\nA(q)y(t) = B(q)u(t-n_k)+C(q)e(t)\n\\end{equation}\n\n\nWhere y(t) is the output at time t, angle of the elbow joint, in this case; u(t) are the inputs, being the processed sEMG values from biceps brachii, brachioradialis and triceps brachii; e(t) is the white-noise disturbance; \\(n_k\\)  is the delay for each input; q is the delay operator; A, B and C are the model coefficients, defined by:\n\n\\begin{equation}\nA(q) = 1 + a_1q^{-1}+\\dots+a_{n_a}q^{-n_a}\n\\end{equation}\n\\begin{equation}\nB(q) = 1 + b_1q^{-1}+\\dots+b_{n_b}q^{-n_b+1}\n\\end{equation}\n\\begin{equation}\nC(q) = 1 + c_1q^{-1}+\\dots+c_{n_c}q^{-n_c}\n\\end{equation}\n\n\nWhere \\(n_a\\) is the system's number of poles; \\(n_b\\) is the number of zeroes plus one; \\(n_c\\) is the number of C coefficients.\n\nThe coefficient orders were calculated and can be found in table \\ref{ta:order}.\n\n\\begin{table}[h]\n\\caption{Model parameters orders for each subject.}\n\\label{table_example}\n\\begin{center}\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\n & \\(n_a\\) & \\(n_b\\) & \\(n_c\\) & \\(n_k\\)\\\\\n\\hline \\hline\nSubject 1 & 1 & 1, 1, 4 & 1 & 8, 7, 0\\\\\n\\hline\nSubject 2 & 1 & 1, 1, 4 & 1 & 8, 7, 0\\\\\n\\hline\nSubject 3 & 1 & 1, 1, 4 & 1 & 8, 7, 0\\\\\n\\hline\nSubject 4 & 1 & 1, 1, 4 & 1 & 8, 7, 0\\\\\n\\hline\nSubject 5 & 1 & 1, 1, 4 & 1 & 8, 7, 0\\\\\n\\hline\nSubject 6 & 1 & 1, 1, 4 &1 & 8, 7, 0\\\\\n\\hline\nSubject 7 & 5 & 10, 3, 2 & 6 & 5, 3, 4\\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\\label{ta:order}\n\\end{table}\n\n\\begin{figure}[thpb]\n      \\centering\n      \\includegraphics[scale=0.3]{Images/3kg.jpg}\n      \\caption{Comparison between the measured angle of the elbow joint and the angle calculated through the use of the estimated model, for subject 5. a) shows the comparison for the continuous movement and b) the comparison for the discrete movement}\n      \\label{Angle Comparison}\n   \\end{figure}\n\nUsing the values from table \\ref{ta:order} as the ARMAX model orders, it was possible to calculate the model for elbow joint angle using the three sEMG measurements and compare it to the experimentally measured values. As an example, figure \\ref{Angle Comparison} shows a comparison between the calculated and measured angle, for continuous and intermittent movement, for subject 5.\n\nWith the ARMAX model calculated for the test subjects, we aimed at validating the model. Using the same model order and parameters previously calculated we estimated the response of the system using a second batch of recorded data. An example of the result of this process can be seen in figure \\ref{Validation Procedure}, where the model calculated for the subject number 3 was used to estimate the elbow joint angle using the input data acquired from the second day of testing.\n\n\\begin{figure}[thpb]\n      \\centering\n      \\includegraphics[scale=0.5]{Images/validation.jpg}\n      \\caption{Validation procedure to determine if the calculated model can be applied to the same test subject for tests made in different days. a) shows the comparison for the continuous movement and b) the comparison for the discrete movement}\n      \\label{Validation Procedure}\n   \\end{figure}\n\nTo better determine the accuracy of the model, two performance parameters were used: The correlation and the root-mean-square error (RMSE)  between the estimated and the measured elbow joint angles. Table \\ref{ta:corr} shows the accuracy evaluation parameters for every test subject and every test set.\n\n\n\\begin{table}[h]\n\\caption{Correlation factor and Root-mean-square error for the estimated and measured angle values}\n\\label{table_example}\n\\begin{center}\n\\resizebox{\\columnwidth}{!}{%\n\\begin{tabular}{|c c|c c|c c|c c|c c|}\n\\hline\n\\multicolumn{2}{|c|}{} & \\multicolumn{4}{c|}{Calibration Test} & \\multicolumn{4}{c|}{Validation Test} \\\\\n\\hline\n\\multicolumn{2}{|c|}{} & \\multicolumn{2}{c|}{Continuous} & \\multicolumn{2}{c|}{Intermittent} & \\multicolumn{2}{c|}{Continuous} & \\multicolumn{2}{c|}{Intermittent} \\\\\n\\hline\n\\multicolumn{2}{|c|}{} & Correlation & RMSE & Correlation & RMSE & Correlation & RMSE & Correlation & RMSE\\\\\n\\hline \\hline\n\n& 0 kg &0.8914 &15.61 &0.8218 &20.65 & 0.8966 & 29.85 & 0.9107 & 18.44 \\\\\nSubject 1 & 1.5 kg &0.7761 &16.66 &0.8251 & 15.19 &0.825 &18.48 & 0.47 & 34.9\\\\\n& 3 kg &0.9497 &13.82 &0.9011 &16.85 & 0.6123 & 29.13 & 0.8488 & 18.85\\\\\n\\hline\n\n& 0 kg &0.9285 &11.29 &0.9659 &9.51 & 0.8249 & 19.28 & 0.941 & 20.43\\\\\nSubject 2 & 1.5 kg &0.8011 &26.33 &0.897 & 16.59 & 0.8735 & 17.48 & 0.8935 & 22\\\\\n& 3 kg &0.9314 &11.85 &0.9368 &13.7& 0.8666 & 16.32 & 0.8906 & 18.61\\\\\n\\hline\n\n& 0 kg &0.8682 &19.47 &0.9123 &16.29 & 0.9033 & 18.04 & 0.8572 & 20.17\\\\\nSubject 3 & 1.5 kg &0.9383 &16.61 & 0.9413& 12.42 & 0.922 & 16.045 & 0.9109 & 16.61\\\\\n& 3 kg &0.9341 &13.66 &0.9602 &10.43& 0.9852 & 16.4 & 0.9048 & 17.16\\\\\n\\hline\n\n& 0 kg &0.8806 &19.63 &0.88 &21.56 & 0.752 & 29.62 & 0.8931 & 21.87\\\\\nSubject 4 & 1.5 kg &0.9408 &16.052 &0.9199 &17.95 & 0.3377 & 66.23 & 0.7704 & 39.44\\\\\n& 3 kg &0.9608 &17.628 &0.862 &21.86 & 0.6104 & 139.73 & 0.7643 & 53.31\\\\\n\\hline\n\n& 0 kg &0.8974 &18.805 &0.873 &24.68 & 0.9407 & 44.398 & 0.9192 & 16.322\\\\\nSubject 5 & 1.5 kg &0.9233 &27.954 &0.823 &17.31 & 0.8801 & 15.427 & 0.8784 & 16.912\\\\\n& 3 kg & 0.9621&7.286 &0.9239 &10.89& 0.8652 & 21.81 & 0.8445 & 24.316\\\\\n\\hline\n\n& 0 kg &0.9256 &14.311 &0.9029 &20.76 & 0.8793 & 34.11 & 0.9258 & 53.08\\\\\nSubject 6 & 1.5 kg &0.8184 &19.37 &0.828 &19.93 & 0.7782 & 21.96 & 0.9317 & 26.05\\\\\n& 3 kg & 0.8323 & 19.13 &0.9169 &16.3 & 0.7722 & 102.16 & 0.8043 & 31.88\\\\\n\\hline\n\n& 0 kg &0.9147 &18.515 &0.9057 &15.48 & 0.8063 & 19.335 & 0.9 & 15.815\\\\\nSubject 7 & 1.5 kg &0.9066 & 12.424&0.9411 & 11.85 &0.8728 & 17.035 & 0.887 & 18.509\\\\\n& 3 kg &0.9194 &12.857 &0.949 &12.6 & 0.7825 & 18.16 & 0.931 & 15.12\\\\\n\\hline\n\n\\end{tabular}%\n}\n\\end{center}\n\n\\label{ta:corr}\n\\end{table}\n\n\\subsection{Non-Linear System Modeling}\n\n\\subsection{Results}\n\n\\subsection{Discussion and Conclusions}\n\nThis chapter proposed a method for determining the elbow joint angle based on the measurement of the sEMG of biceps brachii, triceps brachii and brachioradialis from 7 test subjects. The arm model was estimated using the data collected from the experiment and a system identification method, more specifically, ARMAX. Using the acquired sEMG data as input to the estimated model, it was possible to obtain an estimation of the elbow angle. Using the data from the IMU (real angle value) it was possible to validate the estimation based on sEMG.\n\nThe experimental data showed that it is possible to use only the EMG data to estimate a correlation between joint angle and sEMG values. Even though estimating one model for continuous movement and another one for discrete movement gives higher precision, it is possible to calculate a single model for both movements.\n\nAs stated before, by lifting different weights the model parameters are altered.\nFor the same test subject the A(q) and C(q) parameters (see eq. 3) maintained values with less than 1\\% difference from one another, while the B(q) values assumed a greater range of values.\n\nEven for different subjects, the estimated A(q) and C(q) parameters also had a difference of less than 1\\% from one another.\n\nFrom the seven subjects, six of them could be estimated by an ARMAX model with the same parameters order. The test subject with different order parameters was the one that presented the worst readings of the brachioradialis muscle EMG. Because of that, a lot of noise is introduced, requiring a higher order system to overcome the modeling errors. The brachioradialis is the most difficult muscle to read the sEMG signals compared to the biceps brachii and the triceps brachii. This difficulty is due to the muscle short length causing the electrodes to stay close to the tendon, which induces  reading errors. Not coincidentally, this test subject was the one with smaller stature.\n\nThe repeatability of the model was successful for the cases studied in this work, even though it is possible to note that the model is not as precise as it was for the calibration procedure.\n\nIn future works it will be studied if it is possible to define one single estimated model for each subject, independent of the weight being lifted, or even one global model that is capable of estimating joint angles for a big range of individuals. The calculated models will be used for the control of an EMG-driven upper limb exoskeleton.", "meta": {"hexsha": "f3650093e71fb5a1184d27df6787a513f5d79d60", "size": 19570, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ModelControl.tex", "max_stars_repo_name": "leofischi/Thesis", "max_stars_repo_head_hexsha": "c873ce6b0cc7fb64d2a343ececd93e4ebc5f7138", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ModelControl.tex", "max_issues_repo_name": "leofischi/Thesis", "max_issues_repo_head_hexsha": "c873ce6b0cc7fb64d2a343ececd93e4ebc5f7138", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ModelControl.tex", "max_forks_repo_name": "leofischi/Thesis", "max_forks_repo_head_hexsha": "c873ce6b0cc7fb64d2a343ececd93e4ebc5f7138", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.4814814815, "max_line_length": 1144, "alphanum_fraction": 0.75666837, "num_tokens": 5391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4065393388500099}}
{"text": "\\documentclass[letterpaper]{article}\n\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Homework 1}\n\\date{September 5, 2014}\n\\author{Jon Allen}\n\\maketitle\n\\section*{2.2 C}\nwe pick \n\\section*{2.2 D}\n\\section*{2.3 D}\n\\section*{Worksheet 1}\n\\subsection*{a}\nif $x>1$ then $x^2>x$. If $0<x<1$ then $x^2<x$\n\n\\subsubsection*{proof}\n\\begin{align*}\n  x^2&=x\\cdot x\\\\\n  x\\cdot x&>0\\text{ by axiom 8}\\\\\n  x\\cdot x&=x_1+x_2+...+x_x\\\\\n  0&<x\\\\\n  0+x&<x+x \\text{ by axiom 7}\\\\\n  x&<x_1+x_2+...+x_i \\text{ by induction}\\\\\n\\end{align*}\nTherefore $x<x^2$\n$\\Box$\n\\subsection*{b}\nif $x>0$ then $x^{-1}>0$\n\\subsubsection*{proof}\nlet $x^{-1}=z$. Then $xz=1$. Axiom 8 states that if $0>xy$ then $x<0$ or $y<0$. Because multiplication is closed on $\\mathbb{R}$ we know that $-xz=-1$. Since $-1<0$ we know that $x<0$ or $-z<0$ because $x>0$ we know that $-z<0$. Or $z>0$ $\\Box$\n\\subsection*{c}\nif $0<x<y$ then $0<y^-1<x^-1$\n\\subsubsection*{proof}\n$y^{-1}=m, x^{-1}=n$. $xn=1, ym=1$. \n\\section*{Worksheet 2}\n\\subsection*{a}\nsupremum=$\\frac{3}{2}$. infimum=$-1$. No minimum, maximum is $\\frac{3}{2}$\n\\subsection*{b}\nthis set is all reals. no supremum, infimum or min or max\n\\section*{Worksheet 3}\nlet m lower bound for A. Then $m<x$ for all x in A. and $-x < -m$. because -x is in -A then we have an upper bound of -m for -A. Thus inf(A)=-sup(-A)\n\\end{document}\n", "meta": {"hexsha": "925cc5389d604b82505aa589a1403d91bebd9403", "size": 1468, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "real analysis/analysis-hw-2014-09-05.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "real analysis/analysis-hw-2014-09-05.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "real analysis/analysis-hw-2014-09-05.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7843137255, "max_line_length": 244, "alphanum_fraction": 0.6369209809, "num_tokens": 619, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4065393350450313}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{algorithmic}\n\\usepackage{algorithm}\n\\usepackage{pst-plot}\n\\usepackage{graphicx}\n\\usepackage{endnotes}\n\\usepackage{graphics}\n\\usepackage{floatflt}\n\\usepackage{wrapfig}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{verbatim}\n\\usepackage{hyperref}\n\\usepackage{multirow}\n\\usepackage{pdflscape}\n\\usepackage{enumitem}\n\\usepackage[normalem]{ulem}\n\n\\usepackage{hyperref}\n\\hypersetup{pdfborder={0 0 0 0}}\n\n\\pdfpagewidth 210mm\n\\pdfpageheight 297mm \n\\setlength\\topmargin{0mm}\n\\setlength\\headheight{0mm}\n\\setlength\\headsep{0mm}\n\\setlength\\textheight{250mm}\t\n\\setlength\\textwidth{159.2mm}\n\\setlength\\oddsidemargin{0mm}\n\\setlength\\evensidemargin{0mm}\n\\setlength\\parindent{7mm}\n\\setlength\\parskip{0mm}\n\n\\newenvironment{exercise}[3]{\\paragraph{Exercise #1: #2 (#3pt)}\\ \\\\}{\n\\medskip}\n\\newcommand{\\question}[2]{\\setlength\\parindent{0mm}\\ \\\\$\\mathbf{Q_#1:}$ #2\\ \\\\}\n\n\\author{\\large{Tambet Matiisen, Raul Vicente}}\n\\title{\\huge{Introduction to Computational Neuroscience}\\\\\\LARGE{Practice on Artificial Neural Networks}}\n\n\\begin{document}\n\\maketitle\n\n\\textbf{A request:} Please track how long it will take to complete this set of exercises. Add this time to your final report.\n\\ \\\\\n\n%\n% Intro\n%\nIn this session we are going to have a brief look on artificial neural networks. We start with simplest artificial neuron model called perceptron. Then we will see how simple feed-forward neural networks can be thought of as universal function approximators and what their limitations are. Finally we will use artificial neural network to recognize handwritten digits.\n\n%\n% Perceptron\n%\n\\begin{exercise}{1}{Perceptron}{1}\n\n\\begin{wrapfigure}{r}{0.3\\textwidth}\n\t\\centering\n\t\\vspace{-12pt}\n\t\\includegraphics[width=0.22\\textwidth]{perceptron.png}\n\t\\caption{Simple perceptron}\n\t\\label{fig:perceptronexample}\n\t\\vspace{-5pt}\n\\end{wrapfigure}\n\nPerceptron is the simplest artificial network model invented by Frank Rosenblatt in late 1950s. He added learning rule to McCulloch-Pitts neuron, that allows it to learn certain functions from example inputs and outputs.\n\nPerceptron works on binary data – both its inputs $x_j$ and output $y$ are ones or zeros. Output 1 or 0 can be thought of as binary classification – whether object represented by input  belongs to certain class or not. \n\nPerceptron’s weights $w_j$ can be any real numbers. Its prediction is calculated with following formula:\n\n$$\ny = \\left\\{\n\t\\begin{array}{l l}\n\t\t1, \\text{if } x_1 w_1 + ... + x_m w_m + b \\geq 0\\\\\n\t\t0, \\text{otherwise}\n\t\\end{array}\n\t\\right.\n$$\n\nHere $b$ is the bias term, that is added to the sum. In practice it is easier to just add additional input, which is always one. Then we don’t have to treat bias as special, it is just additional weight. Learning rule for perceptron is very simple:\n\n$$\nw_j = w_j + (t_i - y_i) x_{ij}\n$$\n\nIndex $i$ is used to denote $i$th data sample. Learning rule must be applied for all datasamples and for each weight. You will continue updating the weights until all data samples are classified correctly.\n\nIt turns out, that perceptron is always able to successfully learn classification rule for datasets, which are \\textit{linearly separable} (data points can be separated by line in case of two intputs, plane in case of three inputs or hyperplane in case of input of any dimensionality). If the dataset is not linearly separable, perceptron will never \\textit{converge} (settle to certain weight values). \\newline\n\nExample code for this exercise is in \\texttt{perceptron.m}. Your task is to fill in the perceptron learning rule and decide for four example datasets if they are linearly separable or not. In your report include final image with decision boundary for all four datasets. For linearly separable datasets also add approximate number of steps to convergence.\n\n\\end{exercise}\n\n%\n% Sinusoid\n%\n\\begin{exercise}{2}{Function Approximation}{1.5}\n\nArtificial neural networks can be thought of as universal function approximators. Indeed, Universal Approximation Theorem states, that feed-forward network with single hidden layer containing finite number of neurons can approximate any continous function to any precision. In practice this theorem is of no use, because:\n\\begin{itemize}\n  \\item it states only, that these functions can be \\uline{represented} by feed-forward network with one hidden layer, it doesn’t say anything if they are \\uline{learnable};\n  \\item construction used in the proof uses huge number of neurons in hidden layer, which would be unreasonable for any practical application;\n  \\item as the theorem doesn’t consider learnability, it doesn’t state anything about how well the networks generalizes to samples outside of training data.\n\\end{itemize}\n\nBut it still nice result to guide your thinking – if some problem can be described as a function calculating output from several inputs, then it probably can be approximated with artificial neural network.\\newline\n\n\\begin{wrapfigure}{r}{0.3\\textwidth}\n\t\\centering\n\t\\vspace{-12pt}\n\t\\includegraphics[width=0.20\\textwidth]{sine.png}\n\t\\label{fig:sineexample}\n\t\\vspace{-5pt}\n\\end{wrapfigure}\n\nIn this practice session we are going to approximate sine function using neural network. This neural network is very simple – it consists of just one input node (the $x$), several hidden nodes and just one output node ($y = sin(x)$).\n\nHidden nodes use sigmoid activation function to achieve non-linearity. Output node is linear, no activation function is applied. Loss function is simple squared error:\n\n$$\nL = \\frac{1}{2n}\\sum_{i=1}^{n} (t_i - y_i)^2\n$$\n\nIt calculates average loss over all data points in training set. \\newline\n\nFor this exercise run the code in \\texttt{sinusoid.m} and answer following questions:\n\\question{1}{Why don't we always get the same result during training? Why we sometimes achieve better approximation and sometimes worse?}\n\\question{2}{What is the minimum number of hidden nodes to approximate sinusoid with four bumps (like in the example given)? Include figure with your report. I’m asking for occasional (or theoretical) possibility, not that it approximates reliably with that many hidden nodes. \\textbf{Bonus:} Why that might be? Function \\texttt{plot\\_sinusoid\\_components(test\\_x, nn)}  might give some hints.}\n\\question{3}{Apply network to inputs outside of training range, for example from $-4\\pi$ to $4\\pi$. How well the network generalizes to data outside of training range? Include figure.}\n\n\\end{exercise}\n\n%\n% MNIST\n%\n\\begin{exercise}{3}{Classification of handwritten digits}{1.5pt + bonus 1}\n\nFinally we will use artificial neural network to classify handwritten digits. For that we are going to use MNIST dataset, that was historically very important. This dataset was used to train convolutional neural networks by Yann LeCun et al. and the resulting system was one of the first commercial successes of neural networks in 1990s. At some point it was used to read 10\\% of the checks in North America. It is widely used bencmark even today, because it's fast to train even on modest CPU and there is plenty of baseline performances to compare to.\n\nCode for this excercise is in file \\texttt{mnist.m}. For neural networks we are making use of DeepLearnToolbox toolkit by Rasmus Berg Palm. The tookit is already included with your download in folder \\texttt{DeepLearnToolbox}. Feel free to explore the source in \\texttt{DeepLearnToolbox/NN} folder, it is quite clean Matlab code.\n\nAfter you have run the code and got initial results, your job is to improve classification accuracy. For that you need to tune learning rate, weight decay, number of hidden nodes and number of epochs (iterations over full data set). As tuning neural networks can be quite tedious and frustrating, here are few guidelines:\n\n\\begin{enumerate}\n  \\item Start with learning rate. Try 1 first and then go down by powers of ten, i.e. 1, 0.1, 0.01, 0.001 and so on. Use the first value, when the loss graph is stable (without zig-zags) and goes down. To squeeze out the last bit, you can try values between powers of ten, but usually you don't gain much.\n  \\item Once you have stabilized the learning, try to increase number of hidden nodes and see if testing error improves. \n  \\item If your network is well tuned, then you should see overfitting, which means that network learns training examples, but doesn't generalize to the test set. You can detect this from large gap between training and validation misclassification rate. Time to bring in weight decay! Start with very small values and increase in powers of ten till test error starts to get worse, i.e. 0.00001, 0.0001, 0.001, 0.01, 0.1.\n  \\item Mind that there is a delicate interplay between the parameters – if you increase weight decay, then you might need to increase also learning rate; if you increase number of hidden nodes, you might need to decrease learning rate and so on.\n  \\item Finally, if loss function seems to have steady downward direction, increase number of epochs and see how low it goes. Usually it plateaus at some point and there is no reason to train further.\n\\end{enumerate}\n\nInclude figure with training and validation error in your report, along with testing error. You are expected to achieve at least 3\\% test error rate. \\textbf{Bonus point awarded to everybody with test error below 2\\%!}\n\n\\end{exercise}\n\n\n\n%\n% Adaline video\n%\n\\begin{exercise}{4*}{Science in Action}{bonus 1}\n\nFor this excercise you have to watch one cool video from 1960s. It's about simple analog neuron called ADALINE invented by Bernard Widrow. With all the recent hype around deep learning, it is refreshing to see how much of that was already in place in 1960s.\n\nWatch the video here: \\url{https://www.youtube.com/watch?v=IEFRtz68m-8} (until 21:43)\n\n\\question{}{What applications for adaptive neurons people foresaw already in 1960s?}\n\n\\end{exercise}\n\n\n\\ \\\\\n\\ \\\\\n\\ \\\\\n\\ \\\\\n\\ \\\\\nPlease submit a \\texttt{pdf} report with answers to the questions and comments about your solutions. Include figures, explanations and essential pieces of code. Do not include the code itself as a separate file, your report should give good understanding of what you have done. Please mark how long it took to complete this set of exercises. Upload the \\texttt{pdf} to the practice session page on the course website.\n\n\\end{document}\n", "meta": {"hexsha": "8c4504be3963a03093e6d7bd3415fb57260826e4", "size": 10342, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2015/Practices/08 - Artificial Neural Networks/text/cns-ann.tex", "max_stars_repo_name": "kuz/Computational-Neuroscience-Course", "max_stars_repo_head_hexsha": "b5657c8672397fa845dca88c2740277e7206cb5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2015-01-24T01:14:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-04T20:40:00.000Z", "max_issues_repo_path": "2015/Practices/08 - Artificial Neural Networks/text/cns-ann.tex", "max_issues_repo_name": "NeuroCSUT/Computational-Neuroscience-Course", "max_issues_repo_head_hexsha": "cef9ef2dfc83cbfa91aa9b9ea1f23556aba2e9a2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2015/Practices/08 - Artificial Neural Networks/text/cns-ann.tex", "max_forks_repo_name": "NeuroCSUT/Computational-Neuroscience-Course", "max_forks_repo_head_hexsha": "cef9ef2dfc83cbfa91aa9b9ea1f23556aba2e9a2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2018-02-20T12:20:06.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-08T20:09:22.000Z", "avg_line_length": 56.8241758242, "max_line_length": 553, "alphanum_fraction": 0.7778959582, "num_tokens": 2594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4065393312400526}}
{"text": "\\documentclass[12pt]{cdblatex}\n\\usepackage{exercises}\n\\usepackage{fancyhdr}\n\\usepackage{footer}\n\n\\begin{document}\n\n% --------------------------------------------------------------------------------------------\n\\section*{Exercise 5.4 Deleting a term using tags}\n\n\\begin{cadabra}\n   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u#}::Indices(position=independent).\n\n   def add_tags (obj,tag):\n      n = 0\n      ans = Ex('0')\n      for i in obj.top().terms():\n         foo = obj[i]\n         bah = Ex(tag+'_{'+str(n)+'}')\n         ans := @(ans) + @(bah) @(foo).\n         n = n + 1\n      return ans\n\n   def clear_tags (obj,tag):\n      ans := @(obj).\n      foo  = Ex(tag+'_{a?} -> 1')\n      substitute (ans,foo)\n      return ans\n\n   expr := A_{a b} B^{a b} + A_{a b} A_{c d} B^{a b} B^{c d} - C_{a b} B^{a b}.  # cdb (ex-0504.100,expr)\n\n   expr  = add_tags (expr,'\\\\mu')                                                # cdb (ex-0504.101,expr)\n\n   substitute (expr, $\\mu_{1} -> 0$)                                             # cdb (ex-0504.102,expr)\n\n   expr = clear_tags (expr,'\\\\mu')                                               # cdb (ex-0504.103,expr)\n\n\\end{cadabra}\n\n\\begin{dgroup*}\n   \\Dmath*{ \\cdb*{ex-0504.100} }\n   \\Dmath*{ \\cdb*{ex-0504.101} }\n   \\Dmath*{ \\cdb*{ex-0504.102} }\n   \\Dmath*{ \\cdb*{ex-0504.103} }\n\\end{dgroup*}\n\n\\end{document}\n", "meta": {"hexsha": "d84aa9fd9439ea4e7d04e910a70ba5752d56938b", "size": 1340, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "source/cadabra/exercises/ex-0504.tex", "max_stars_repo_name": "leo-brewin/cadabra-tutorial", "max_stars_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2019-12-20T07:49:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T22:55:47.000Z", "max_issues_repo_path": "source/cadabra/exercises/ex-0504.tex", "max_issues_repo_name": "leo-brewin/cadabra-tutorial", "max_issues_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/cadabra/exercises/ex-0504.tex", "max_forks_repo_name": "leo-brewin/cadabra-tutorial", "max_forks_repo_head_hexsha": "5b428ae158b5346315ab6c975dee9de933e5c3d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-22T13:52:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-22T13:52:19.000Z", "avg_line_length": 27.9166666667, "max_line_length": 105, "alphanum_fraction": 0.4462686567, "num_tokens": 443, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.40647875610815637}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[a4paper, total={7in, 10in}]{geometry}\n\\usepackage[usenames, dvipsnames]{color}\n\\usepackage{listings}\n\n\\definecolor{myred}{RGB}{255, 0, 0}\n\\definecolor{mywhat}{RGB}{255, 0, 219}\n\\definecolor{mygreen}{RGB}{0, 255, 0}\n\\definecolor{myblue}{RGB}{0, 0, 255}\n\n\\begin{document}\n\\title{% \n\t\t\\LARGE \\textbf{Division in relational algebra} \\\\\n        }\n\\author{\n\tNicolas Novalic\n}\n\\begin{center}\n\t{\\Huge Understanding the division operator\\\\ in Relational Algebra} \\\\\n\\end{center}\n\nFirst lets take a quick look at how the operator works. Say we have two relations, $R$ with schema: $(A, B)$ and $S$ with schema: $(B)$. An instance of them could be:\n\\vskip 0.2in\n\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{ll}\n  \t\\hline\n    A & B \\\\\n    \\hline\n    \\multicolumn{1}{|c|}{a} & \\multicolumn{1}{c|}{1} \\\\ \\hline\n\t\\multicolumn{1}{|c|}{a} & \\multicolumn{1}{c|}{2} \\\\ \\hline\n    \\multicolumn{1}{|c|}{a} & \\multicolumn{1}{c|}{7} \\\\ \\hline\n    \\multicolumn{1}{|c|}{b} & \\multicolumn{1}{c|}{1} \\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{l}\n  \t\\hline\n    B \\\\\n    \\hline\n    \\multicolumn{1}{|c|}{1} \\\\ \\hline\n\t\\multicolumn{1}{|c|}{7} \\\\ \\hline\n    \\multicolumn{1}{|c|}{2} \\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\\vskip 0.2in\nIf we name $P$ and $Q$ these instances of $R$  and $S$ respectively, the result of $P \\div Q$ is:\n\\vskip 0.2in\n\\begin{center}\n  \\begin{tabular}{l}\n  \t\\hline\n    A \\\\\n    \\hline\n    \\multicolumn{1}{|c|}{a} \\\\ \\hline\n  \\end{tabular}\n\\end{center}\n\\vskip 0.2in\n\nWhat happened here? The division operator took all the values from attribute $A$ that were in a relation (in $R$) with \\textbf{all} the values of the $B$ attribute in $S$.\nWe were able to perform the operation because the last attribute of $R$ had the same name as the attribute on $S$. In general, the last attributes of the first operator \\textbf{must} have the same name as the attributes in the second operator and \\textbf{must} be in the same order.\n\\vskip 0.2in\n\\noindent\\fbox{\\parbox{\\textwidth}{%\nGiven two relations, $R1$ and $R2$ and their schema: $(A_1,\\dots,A_n,B_1,\\dots,B_m)$ and $(B_1,\\dots,B_m)$ resp., $R1 \\div R2$ retrieves a relation $R3$ with schema $(A_1,\\dots,A_n)$ where all the sub-tuples $(A_1,\\dots,A_n)$ of $R1$ were in a relation with every tuple of $R2$.\n}}\n\\subsection*{Advanced example and explanation}\n\nConsider the following instances of the relations $R1$ and $R2$ defined before:\n\\vskip 0.2in\n\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_z$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_\\phi$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_q$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_w$} & \\multicolumn{1}{c|}{$w_u$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_x$} & \\multicolumn{1}{c|}{$w_h$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_q$} & \\multicolumn{1}{c|}{$w_a$}\\\\ \\hline\n\t\\multicolumn{1}{|c|}{$x_2$} & \\multicolumn{1}{c|}{$y_5$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_2$} & \\multicolumn{1}{c|}{$y_4$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_x$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_x$} & \\multicolumn{1}{c|}{$w_h$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_q$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_w$} & \\multicolumn{1}{c|}{$w_u$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_z$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_1$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_\\phi$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{ll}\n  \t\\hline\n    D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_z$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_\\phi$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_b$} & \\multicolumn{1}{c|}{$w_q$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_w$} & \\multicolumn{1}{c|}{$w_u$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_b$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$w_x$} & \\multicolumn{1}{c|}{$w_h$}\\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\\newpage\n\\parbox{.70\\linewidth}{\nLet's name $X$ and $Y$ the previous instances of $R1$ and $R2$ respectively. \\\\\n\n\\vskip 0.2in\nNow, I will show a really easy way to understand the operator. It's nothing formal, just a way to see things. It consists on taking the table $X$ and group it by the attributes $(A,B,C)$, just like you do in SQL when using the \\textbf{GROUP BY} statement. The groups are then represented by the value of their respective $(A,B,C)$ attributes. Now we assign a set to each one of these groups, which contains all the pairs of values of the attributes $(D,E)$ that are in a relation with the values that represent the group. Then we can check if the tuples of $Y$ are included on each of these sets, if they are, then the values that represent that grouping are added to the solution, otherwise they are not. This is a bit confusing, but really easy to understand with the an example.\n\\vskip 0.2in\nWe start by identifying the rows of the table that are equal two to two on their $(A,B,C)$ attributes. On table to the right we colored the identified groups.\n\n\\vskip 0.2in\n}\n\\parbox{.25\\linewidth}{\n\\begin{flushright}\n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_a}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_b}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_z}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_z}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_\\phi}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_z}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_b}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_q}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_w}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_u}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_b}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_b}$}\\\\ \\hline\n\n\t\\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_x}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_h}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myred}{x_1}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{y_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{z_2}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_q}$} & \\multicolumn{1}{c|}{$\\textcolor{myred}{w_a}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_2$} & \\multicolumn{1}{c|}{$y_5$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n\t\\multicolumn{1}{|c|}{$\\textcolor{mygreen}{x_2}$} & \\multicolumn{1}{c|}{$\\textcolor{mygreen}{y_4}$} & \\multicolumn{1}{c|}{$\\textcolor{mygreen}{z_1}$} & \\multicolumn{1}{c|}{$\\textcolor{mygreen}{w_a}$} & \\multicolumn{1}{c|}{$\\textcolor{mygreen}{w_b}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_a}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_x}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_a}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_b}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_x}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_h}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_b}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_q}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_w}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_u}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_z}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_z}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{mywhat}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{mywhat}{y_1}$} & \\multicolumn{1}{c|}{$\\textcolor{mywhat}{z_1}$} & \\multicolumn{1}{c|}{$\\textcolor{mywhat}{w_a}$} & \\multicolumn{1}{c|}{$\\textcolor{mywhat}{w_b}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_b}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_b}$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$\\textcolor{myblue}{x_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{y_7}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{z_3}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_\\phi}$} & \\multicolumn{1}{c|}{$\\textcolor{myblue}{w_z}$}\\\\ \\hline\n\n\\end{tabular}\n\\end{flushright}\n}\n\nLet's split the colored table by color, obtaining five sub-tables:\n\n\\vskip 0.2in\n\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_z$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_\\phi$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_q$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_w$} & \\multicolumn{1}{c|}{$w_u$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_x$} & \\multicolumn{1}{c|}{$w_h$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} & \\multicolumn{1}{c|}{$w_q$} & \\multicolumn{1}{c|}{$w_a$}\\\\ \\hline\n  \\end{tabular}\n\n\\vskip 0.2in\n\n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_2$} & \\multicolumn{1}{c|}{$y_5$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n  \\end{tabular}\n  \n\\vskip 0.2in\n  \n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_2$} & \\multicolumn{1}{c|}{$y_4$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\\parbox{.45\\linewidth}{\n\\begin{center}\n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_x$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_x$} & \\multicolumn{1}{c|}{$w_h$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_q$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_w$} & \\multicolumn{1}{c|}{$w_u$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_z$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_b$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} & \\multicolumn{1}{c|}{$w_\\phi$} & \\multicolumn{1}{c|}{$w_z$}\\\\ \\hline\n  \\end{tabular}\n  \n\\vskip 0.2in\n \n  \\begin{tabular}{lllll}\n  \t\\hline\n    A & B & C & D & E\\\\\n    \\hline\n    \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_1$} & \\multicolumn{1}{c|}{$z_1$} & \\multicolumn{1}{c|}{$w_a$} & \\multicolumn{1}{c|}{$w_b$}\\\\ \\hline\n  \\end{tabular}\n\\end{center}\n}\n\n\\vskip 0.2in\n\nNow let's see each of those tables like this:\n\n\\begin{itemize}\n\\item $(x_1,y_2,z_2) \\rightarrow \\{ (w_a,w_b), (w_z,w_z),(w_\\phi,w_z),(w_b,w_q),(w_w,w_u),(w_b,w_b),(w_x,w_h),(w_q, w_a)\\}$\n\\item $(x_2,y_5,z_1) \\rightarrow \\{ (w_a,w_b)\\}$\n\\item $(x_2,y_4,z_1) \\rightarrow \\{ (w_a,w_b)\\}$\n\\item $(x_3,y_7,z_3) \\rightarrow \\{ (w_a,w_x),(w_a,w_b), (w_x,w_h),(w_b,w_q),(w_w,w_u),(w_z,w_z),(w_b, w_b),(w_\\phi, w_z)\\}$\n\\item $(x_3,y_1,z_1) \\rightarrow \\{ (w_a,w_b)\\}$\n\\end{itemize}\n\n\\vskip 0.2in\n\nAlso let's see the table $Y$ as a set:\n\n\\begin{itemize}\n\\item $\\{ (w_a,w_b),(w_z,w_z), (w_\\phi,w_z),(w_b,w_q),(w_w,w_u),(w_b,w_b),(w_x, w_h)\\}$\n\\end{itemize}\n\n\\newpage\n\nThis is a clear representation of our data and we are ready to calculate the result of $X \\div Y$. To simplify notation let's define a \"function\" in our universe, called \\textbf{setOf()} that retrieves the set of tuples of what we pass to it as a parameter. Let's say, if we pass the parameter $Y$, it retrieves the set of it's tuples; if we pass three values $x,y,z$, it retrieves one of the sets defined before.\n\n\\vskip 0.2in\nIt's really easy to check that:\n\n\\begin{itemize}\n  \\item $setOf(Y) \\subseteq setOf(x_1,y_2,z_2)$ \n  \\item $setOf(Y) \\not\\subseteq setOf(x_2,y_5,z_1) $ \n  \\item $setOf(Y) \\not\\subseteq setOf(x_2,y_4,z_1) $ \n  \\item $setOf(Y) \\subseteq setOf(x_3,y_7,z_3) $ \n  \\item $setOf(Y) \\not\\subseteq setOf(x_3,y_1,z_1) $ \n\\end{itemize}\n\n\\vskip 0.2in\nAnd the result of $X \\div Y$ is:\n\n\\vskip 0.2in\n\\begin{tabular}{lllll}\n  \\hline\n  A & B & C\\\\\n  \\hline\n  \\multicolumn{1}{|c|}{$x_1$} & \\multicolumn{1}{c|}{$y_2$} & \\multicolumn{1}{c|}{$z_2$} \\\\ \\hline\n  \\multicolumn{1}{|c|}{$x_3$} & \\multicolumn{1}{c|}{$y_7$} & \\multicolumn{1}{c|}{$z_3$} \\\\ \\hline\n\\end{tabular}\n\n\\vskip 0.2in\nI think this is a really good way to understand what the division operator does in relational algebra. This operator is the most confusing at first for some people, specially when using it with operands that have more than one attribute each.\n\n\\subsection*{Simple query example}\n\n\\vskip 0.2in\nLet's see a quick example of how to use it to write a query. Let's say we have a simplified version of Blockbuster's database and some relations of it's relational schema are: \n\n\\begin{lstlisting}\nCLIENTS(clientID, name, lastname)\nMOVIES(movieID, title, description, year, duration, language)\nRENTALS(clientID, movieID, date)\n\\end{lstlisting}\n\nWe want a relational algebra query that retrieves the ids of the clients that rented all the movies of the year 2010. \\\\\n\nFirst of all we can find the ids of all the movies of the year 2010:\\\\\n\n$A = \\prod_{movieID}(\\sigma_{year = 2010}MOVIES)$ \\\\\n\nNow, let's project the relation RENTALS by clientID and movieID so we retrieve all the rentals ever done: \\\\\n\n$B = \\prod_{clientID, movieID}RENTALS$ \\\\\n\nLet's divide B by A! Note that the second row of B is the same that the only row of A. By doing this we are asking for all the clientIDs that are in a relation with all the movies of 2010. To finish the query we use the JOIN operator and project the result by name and lastname: \\\\\n\n$Solution = \\prod_{name, lastname}(CLIENTS * (B \\div A)) $\n\n\\end{document}\n", "meta": {"hexsha": "4f63778b0c8c84c8e8e7d751873c6f5278c764fb", "size": 19082, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "division_relational_algebra/division-relational-algebra.tex", "max_stars_repo_name": "novalic/mathProblems", "max_stars_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-04-22T11:03:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-01T21:06:53.000Z", "max_issues_repo_path": "division_relational_algebra/division-relational-algebra.tex", "max_issues_repo_name": "novalic/articles", "max_issues_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "division_relational_algebra/division-relational-algebra.tex", "max_forks_repo_name": "novalic/articles", "max_forks_repo_head_hexsha": "ccb21bb5fb7c4c97f3ffb113c22b25b1cee049aa", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.9768976898, "max_line_length": 781, "alphanum_fraction": 0.6161827901, "num_tokens": 8384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4064787496071935}}
{"text": "\\documentclass[a4paper]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\n\n\n\\title{Chapter 5\\\\Vector Spaces}\n\\author{solutions by Hikari}\n\\date{August 2021}\n\n\\begin{document}\n\n\\newcommand{\\br}[2]{\\langle#1|#2\\rangle}\n\\newcommand{\\brr}[2]{\\left\\langle#1|#2\\right\\rangle}\n\\newcommand{\\pdv}[2]{\\frac{\\partial#1}{\\partial#2}}\n\\newcommand{\\M}{\\mathrm}\n\\newcommand{\\V}{\\mathbf}\n\\newcommand{\\VE}{\\mathbf{\\hat{e}}}\n\n\\maketitle\n\n\\section*{5.1 Vectors in Function Spaces}\n\n\\paragraph{5.1.1}\nIf there are two expansions of $f(x)$, so\n\\[\nf(x)=\\sum_{n=0}^\\infty a_n\\varphi_n(x)=\\sum_{n=0}^\\infty b_n\\varphi_n(x)\n\\]\nthen\n\\[\ng(x)=\\sum_{n=0}^\\infty(a_n-b_n)\\varphi_n(x)=0\n\\]\n\\[\n\\br{g(x)}{g(x)}=\\sum_{n=0}^\\infty(a_n-b_n)^2=0\n\\]\nso $a_n=b_n$, and the expansion is unique.\n\n\\paragraph{5.1.2}\nIf \n\\[\nf(x)=\\sum_{i=1}^Nc_i\\varphi_i(x)=\\sum_{i=1}^Nc'_i\\varphi_i(x)\n\\]\nso \n\\[\n\\sum_{i=1}^N(c_i-c'_i)\\varphi_i(x)\n\\]\nBy definition of linear independence, the linear combination of a linear independent set equals zero only if all the coefficient is zero. The set of $\\varphi_i$ is linear independent, so $c_i-c'_i$ must be zero, which means $c_i=c'_i$, the components are unique.\n\n\\paragraph{5.1.3}\nThe mean square error $M$ is\n\\[\nM=\\int_0^1(f(x)-\\sum_jc_jx^j)^2dx\n\\]\n\\[\n=\\int_0^1\\left[f(x)^2+(\\sum_jc_jx^j)(\\sum_jc_jx^j)-2f(x)(\\sum_jc_jx^j) \\right]dx\n\\]\n\nWhen $M$ is minimized, $\\pdv{M}{c_i}=0$ for every $i$, so\n\\[\n\\pdv{M}{c_i}=\\int_0^1\\left[2x^i(\\sum_jc_jx^j)-2f(x)x^i \\right]dx=0\n\\]\nso\n\\[\n\\sum_j\\int_0^1x^{i+j}dx\\cdot c_j=\\int_0^1x^if(x)dx\n\\]\nLet $\\int_0^1x^{i+j}dx=A_{ij}$,\\quad $\\int_0^1x^if(x)dx=b_i$, then the equation becomes\n\\[\n\\sum_jA_{ij}c_j=b_i\n\\]\nor $\\M{A}\\V{c}=\\V{b}$ in matrix form.\n\n\\paragraph{5.1.4}\nLet $F(x)=\\varphi_i(x)$, then\n\\[\na_j=\\delta_{ij}=\\int_a^b\\varphi_i(x)\\varphi_{j}(x)w(x)dx\n\\]\nso the basis are orthonormal. \n\nWhen the mean square error is minimized, \n\\[\n\\pdv{}{c_n}\\left(\\int_a^b[F(x)-\\sum_{k=o}^mc_k\\varphi_k(x)]^2w(x)dx \\right)=0\n\\]\nso\n\\[\n\\int_a^b 2[F(x)-\\sum_{k=o}^mc_k\\varphi_k(x)](-\\varphi_n(x))w(x)dx=0\n\\]\n\\[\n-\\int_a^bF(x)\\varphi_n(x)w(x)dx+\\sum_{k=0}^mc_k\\delta_{kn}=0\n\\]\nNote that the first term is $-a_n$, and the second term is $c_n$, so\n\\[\nc_n=a_n\n\\]\n\n\\paragraph{5.1.5}\n(a)\n\\[\n\\int_{-\\pi}^\\pi\\frac{\\sin(2n+1)x}{2n+1}\\frac{\\sin(2m+1)x}{2m+1}dx=\\int_{-\\pi}^\\pi\\frac{\\cos(2(n-m)x)-\\cos(2(n+m+1)x)}{2(2n+1)(2m+1)}\n\\]\n\\[=\n\\begin{cases}\n0,\\quad\\quad\\quad\\;\\;\\textit{when $n\\neq m$}\\\\\n\\frac{\\pi}{(2n+1)^2},\\quad\\textit{when $n=m$}\n\\end{cases}\n\\]\nso\n\\[\n\\int_{-\\pi}^\\pi\\left[f(x)\\right]^2dx=\\int_{-\\pi}^\\pi\\frac{4h^2}{\\pi^2}(\\sum_{n=0}^\\infty\\frac{\\sin(2n+1)x}{2n+1})(\\sum_{m=0}^\\infty\\frac{\\sin(2m+1)x}{2m+1})dx\n\\]\n\\[\n=\\frac{4h^2}{\\pi^2}\\sum_{n=0}^\\infty\\frac{\\pi}{(2n+1)^2}=\\frac{4h^2}{\\pi}\\sum_{n=0}^\\infty\\frac{1}{(2n+1)^2}\n\\]\n\n(b)\n\\[\n\\sum_{n=0}^\\infty\\frac{1}{(2n+1)^2}=\\frac{1}{1^2}+\\frac{1}{3^2}+\\frac{1}{5^2}+\\frac{1}{7^2}+\\cdots\n\\]\n\\[\n=(\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\frac{1}{4^2}+\\frac{1}{5^2}+\\frac{1}{6^2}+\\frac{1}{7^2}+\\cdots)-\\frac{1}{2^2}(\\frac{1}{1^2}+\\frac{1}{2^2}+\\frac{1}{3^2}+\\cdots)\n\\]\n\\[\n=\\frac{3}{4}\\zeta(2)=\\frac{\\pi^2}{8}\n\\]\nso\n\\[\n\\frac{4h^2}{\\pi}\\sum_{n=0}^\\infty\\frac{1}{(2n+1)^2}=\\frac{4h^2}{\\pi}\\frac{\\pi^2}{8}=\\frac{\\pi}{2}h^2\n\\]\n\n\\paragraph{5.1.6}\n\\[\n\\left[\\int_a^bf(x)g(x)dx \\right]^2+\\frac{1}{2}\\int_a^bdx\\int_a^bdy\\left[f(x)g(y)-f(y)g(x) \\right]^2=\\int_a^b\\left[f(x) \\right]^2dx\\int_a^b\\left[g(x) \\right]^2dx\n\\]\nand note that $\\frac{1}{2}\\int_a^bdx\\int_a^bdy\\left[f(x)g(y)-f(y)g(x) \\right]^2\\geq0$, so\n\\[\n\\left[\\int_a^bf(x)g(x)dx \\right]^2\\leq\\int_a^b\\left[f(x) \\right]^2dx\\int_a^b\\left[g(x) \\right]^2dx\n\\]\nTo prove the identity, note that\n\\[\n\\frac{1}{2}\\int_a^bdx\\int_a^bdy\\left[f(x)g(y)-f(y)g(x) \\right]^2=\\frac{1}{2}\\int_a^bdx\\int_a^bdy\\left[f(x)^2g(y)^2+f(y)^2g(x)^2-2f(x)g(x)f(y)g(y) \\right]\n\\]\n\\[=\n\\frac{1}{2}\\int_a^bdx\\left[f(x)^2\\int_a^b[g(y)]^2dy+(\\int_a^b[f(y)]^2dy)\\;g(x)^2-2f(x)g(x)\\int_a^bf(y)g(y)dy \\right]\n\\]\n\\[\n=\\frac{1}{2}\\left[\\int_a^b[f(x)]^2dx\\int_a^b[g(y)]^2dy+\\int_a^b[f(y)]^2dy\\int_a^b[g(x)]^2dx-2\\int_a^bf(x)g(x)dx\\int_a^bf(y)g(y)dy \\right]\n\\]\n\\[\n=\\int_a^b[f(x)]^2dx\\int_a^b[g(x)]^2dx-\\left[\\int_a^bf(x)g(x)dx\\right]^2\n\\]\nRearranging the terms we get the identity.\n\n\\paragraph{5.1.7}\nThe basis are orthonormal, so $\\langle a_i\\varphi_i|a_j\\varphi_j \\rangle$ is zero when $i\\neq j$ and is $|a_i|^2$ when $i=j$. Let $f=\\sum_ka_k\\varphi_k$, $k$ can be infinite, and let $\\sum_na_n\\varphi_n$ be an incomplete expansion of $f$, then \n\\[\nI=\\left\\langle f-\\sum_na_n\\varphi_n\\Big|f-\\sum_na_n\\varphi_n \\right\\rangle\n\\]\n\\[\n=\\langle f|f \\rangle-\\left\\langle \\sum_na_n\\varphi_n\\Big|f \\right\\rangle-\\left\\langle f\\Big|\\sum_na_n\\varphi_n \\right\\rangle+\\left\\langle \\sum_na_n\\varphi_n\\Big|\\sum_na_n\\varphi_n \\right\\rangle\n\\]\n\\[\n=\\langle f|f \\rangle-\\left\\langle \\sum_na_n\\varphi_n\\Big|\\sum_ka_k\\varphi_k \\right\\rangle-\\left\\langle \\sum_ka_k\\varphi_k\\Big|\\sum_na_n\\varphi_n \\right\\rangle+\\left\\langle \\sum_na_n\\varphi_n\\Big|\\sum_na_n\\varphi_n \\right\\rangle\n\\]\n\\[\n=\\langle f|f \\rangle-\\sum_n|a_n|^2-\\sum_n|a_n|^2+\\sum_n|a_n|^2\n\\]\n\\[\n=\\langle f|f \\rangle-\\sum_n|a_n|^2\\geq0\n\\]\nso\n\\[\n\\langle f|f \\rangle\\geq\\sum_n|a_n|^2\n\\]\n\n\\paragraph{5.1.8}\nBy integrating by parts, we have\n\\[\n\\int_0^1\\sin\\pi x\\,dx=\\frac{\\pi}{2}\n\\]\n\\[\n\\int_0^1x\\sin\\pi x\\,dx=\\frac{1}{\\pi}-\\frac{1}{\\pi}\\int_0^1\\cos\\pi x\\,dx=\\frac{1}{\\pi}\n\\]\n\\[\n\\int_0^1x^2\\sin\\pi x\\,dx=\\frac{1}{\\pi}-\\frac{2}{\\pi^2}\\int_0^1\\sin\\pi x\\,dx=\\frac{1}{\\pi}-\\frac{4}{\\pi^3}\n\\]\n\\[\n\\int_0^1x^3\\sin\\pi x\\,dx=\\frac{1}{\\pi}-\\frac{6}{\\pi^2}\\int_0^1x\\sin\\pi x\\,dx=\\frac{1}{\\pi}-\\frac{6}{\\pi^3}\n\\]\nLet $\\sin\\pi x=\\sum a_n\\varphi_n$, then \n\\[\na_0=\\frac{\\langle\\varphi_0|\\sin\\pi x\\rangle}{\\langle\\varphi_0|\\varphi_0\\langle}=\\frac{I_0}{1}=\\frac{2}{\\pi}\n\\]\n\\[\na_1=\\frac{\\langle\\varphi_1|\\sin\\pi x\\rangle}{\\langle\\varphi_1|\\varphi_1\\rangle}=\\frac{2I_1-I_0}{\\frac{1}{3}}=0\n\\]\n\\[\na_2=\\frac{\\langle\\varphi_2|\\sin\\pi x\\rangle}{\\langle\\varphi_2|\\varphi_2\\rangle}=\\frac{6I_2-6I_1+I_0}{\\frac{1}{5}}=\\frac{10}{\\pi}-\\frac{120}{\\pi^3}\n\\]\n\\[\na_3=\\frac{\\langle\\varphi_3|\\sin\\pi x\\rangle}{\\langle\\varphi_3|\\varphi_3\\rangle}=\\frac{20I_3-30I_2+12I_1-I_0}{\\frac{1}{7}}=0\n\\]\nso\n\\[\n\\sin\\pi x=\\frac{2}{\\pi}\\varphi_0+(\\frac{10}{\\pi}-\\frac{120}{\\pi^3})\\varphi_2+\\cdots\n\\]\n\n\\paragraph{5.1.9}\nIntegrating by parts for $n$ times, we have\n\\[\n\\int_0^\\infty x^ne^{-2x}dx=\\frac{n!}{2^{n+1}}\n\\]\nLet $e^{-x}=\\sum a_nL_n(x)$, then \n\\[\na_0=\\langle L_0|e^{-x}\\rangle=\\int_0^\\infty e^{-2x}dx=\\frac{1}{2}\n\\]\n\\[\na_1=\\langle L_1|e^{-x}\\rangle=\\int_0^\\infty e^{-2x}dx-\\int_0^\\infty xe^{-2x}dx=\\frac{1}{4}\n\\]\n\\[\na_2=\\langle L_2|e^{-x}\\rangle=\\int_0^\\infty e^{-2x}dx-2\\int_0^\\infty xe^{-2x}dx+\\frac{1}{2}\\int_0^\\infty x^2e^{-2x}dx=\\frac{1}{8}\n\\]\n\\[\na_3=\\langle L_3|e^{-x}\\rangle=\\int_0^\\infty e^{-2x}dx-3\\int_0^\\infty xe^{-2x}dx+\\frac{3}{2}\\int_0^\\infty x^2e^{-2x}dx-\\frac{1}{6}\\int_0^\\infty x^3e^{-2x}dx=\\frac{1}{16}\n\\]\nso\n\\[\ne^{-x}=\\frac{1}{2}L_0+\\frac{1}{4}L_1+\\frac{1}{8}L_2+\\frac{1}{16}L_3+\\cdots\n\\]\n\n\\paragraph{5.1.10}\nExpand $\\varphi_n$ in the $\\chi_n$ basis, we have\n\\[\n\\varphi_n=\\sum_m\\chi_m\\langle\\chi_m|\\varphi_n\\rangle\n\\]\nso\n\\[\nf=\\sum_n\\varphi_na_n=\\sum_n\\sum_m\\chi_m\\langle\\chi_m|\\varphi_n\\rangle a_n\n\\]\n\n\\paragraph{5.1.11}\n\\[\n\\sum_j|\\VE_j\\rangle\\br{\\VE_j}{\\V{a}}=\\sum_j\\VE_j(\\VE_j\\cdot\\V{a})=\\V{a}\n\\]\n\n\\paragraph{5.1.12}\n\\[\n\\br{\\V{a}}{\\V{a}}=a_1^2-2a_1a_2+ka_2^2=(a_1-a_2)^2+(k-1)a_2^2>0\\quad\\textit{(when $\\V{a}\\neq0$)}\n\\]\nso $k-1>0$,\\; $k>1$.\n\\[\n\\br{\\V{a}}{\\V{b}}^*=a_1b_1-a_1b_2-a_2b_1+ka_2b_2=b_1a_1-b_1a_2-b_2a_1+kb_2a_2=\\br{\\V{b}}{\\V{a}}\n\\]\n\\[\n\\br{\\V{a}}{\\V{b}+\\V{b'}}=a_1(b_1+b'_1)-a_1(b_2+b'_2)-a_2(b_1+b'_1)+ka_2(b_2+b'_2)\\]\n\\[\n=(a_1b_1-a_1b_2-a_2b_1+ka_2b_2)+(a_1b'_1-a_1b'_2-a_2b'_1+ka_2b'_2)=\\br{\\V{a}}{\\V{b}}+\\br{\\V{a}}{\\V{b'}}\n\\]\n\\[\n\\br{\\V{a}}{x\\V{b}}=a_1xb_1-a_1xb_2-a_2xb_1+ka_2xb_2=x(a_1b_1-a_1b_2-a_2b_1+ka_2b_2)=x\\br{\\V{a}}{\\V{b}}\n\\]\nso the condition for the scalar product to be valid is $k>1$.\n\n\\section*{5.2 Gram-Schmidt Orthogonalization}\n\n\\paragraph{5.2.1}\n\\[\nP_0^*(x)=1\n\\]\n\\[\n\\psi_1(x)=x-1\\frac{\\br{1}{x}}{\\br{1}{1}}=x-\\frac{\\int_0^1xdx}{\\int_0^1dx}=x-\\frac{1}{2}\n\\]\n\\[\nP_1^*(x)=\\frac{\\psi_1(x)}{\\psi_1(1)}=2x-1\n\\]\n\\[\n\\psi_2(x)=x^2-1\\frac{\\br{1}{x^2}}{\\br{1}{1}}-(2x-1)\\frac{\\br{2x-1}{x^2}}{\\br{2x-1}{2x-1}}=x^2-\\frac{\\int_0^1x^2dx}{\\int_0^1dx}-(2x-1)\\frac{\\int_0^1(2x^3-x^2)dx}{\\int_0^1(2x-1)^2dx}=x^2-x+\\frac{1}{6}\n\\]\n\\[\nP_2^*(x)=\\frac{\\psi_2(x)}{\\psi_2(1)}=6x^2-6x+1\n\\]\n\\[\n\\psi_3(x)=x^3-1\\frac{\\br{1}{x^3}}{\\br{1}{1}}-(2x-1)\\frac{\\br{2x-1}{x^3}}{\\br{2x-1}{2x-1}}-(6x^2-6x+1)\\frac{\\br{6x^2-6x+1}{x^3}}{\\br{6x^2-6x+1}{6x^2-6x+1}}=x^3-\\frac{3}{2}x^2+\\frac{3}{5}x-\\frac{1}{20}\n\\]\n\\[\nP_3^*(x)=\\frac{\\psi_3(x)}{\\psi_3(1)}=20x^3-30x^2+12x-1\n\\]\n\n\\paragraph{5.2.2}\n\\[\n\\varphi_0=1\n\\]\n\\[\nL_0=\\frac{\\varphi_0}{{\\br{\\varphi_0}{\\varphi_0}}^{1/2}}=\\frac{1}{(\\int_0^\\infty e^{-x}dx)^{1/2}}=\\pm1\\quad\\textit{(choose $1$)}\n\\]\n\\[\n\\varphi_1=x-1\\int_0^\\infty1 xe^{-x}dx=x-1\n\\]\n\\[\nL_1=\\frac{\\varphi_1}{{\\br{\\varphi_1}{\\varphi_1}}^{1/2}}=\\frac{x-1}{(\\int_0^\\infty(x-1)^2e^{-x}dx)^{1/2}}=\\pm(x-1)\\quad\\textit{(choose $-x+1$)}\n\\]\n\\[\n\\varphi_2=x^2-1\\int_0^\\infty1x^2e^{-x}dx-(1-x)\\int_0^\\infty(1-x)x^2e^{-x}dx=x^2-4x+2\n\\]\n\\[\nL_2=\\frac{\\varphi_2}{{\\br{\\varphi_2}{\\varphi_2}}^{1/2}}=\\frac{x^2-4x+2}{(\\int_0^\\infty (x^2-4x+2)^2e^{-x}dx)^{1/2}}=\\pm\\frac{x^2-4x+2}{2}\\quad\\textit{(choose $\\frac{x^2-4x+2}{2}$)}\n\\]\n(The choice of sign in the normalization is arbitrary and is so chosen to match the answer given in the text.)\n\n\\paragraph{5.2.3}\n\\[\n\\psi_0(x)=1\n\\]\n\\[\n\\varphi_0(x)=\\frac{\\psi_0}{\\br{\\psi_0}{\\psi_0}^{1/2}}=\\frac{1}{(\\int_0^\\infty xe^{-x}dx)^{1/2}}=1\n\\]\n\\[\n\\psi_1(x)=x-1\\int_0^\\infty1x\\cdot xe^{-x}dx=x-2\n\\]\n\\[\n\\varphi_1(x)=\\frac{\\psi_1}{\\br{\\psi_1}{\\psi_1}^{1/2}}=\\frac{x-2}{(\\int_0^\\infty(x^2-4x+4)xe^{-x}dx)^{1/2}}=\\frac{x-2}{\\sqrt{2}}\n\\]\n\\[\n\\psi_2(x)=x^2-1\\int_0^\\infty1x^2\\cdot xe^{-x}dx-\\frac{x-1}{\\sqrt{2}}\\int_0^\\infty\\frac{x-2}{\\sqrt{2}}x^2\\cdot xe^{-x}dx=x^2-6x+6\n\\]\n\\[\n\\varphi_2(x)=\\frac{\\psi_2}{\\br{\\psi_2}{\\psi_2}^{1/2}}=\\frac{x^2-6x+6}{(\\int_0^\\infty(x^4-12x^3+48x^2-72x+36)xe^{-x}dx)^{1/2}}=\\frac{x^2-6x+6}{2\\sqrt{3}}\n\\]\n(using the formula $\\int_0^\\infty x^ne^{-x}dx=n!$ can facilate the calculation.)\n\n\\paragraph{5.2.4}\nTo calculate the scalar product, we need the Gaussian integral $\\int_{-\\infty}^\\infty x^ne^{-x^2}dx$. When $n$ is odd, $\\int_{-\\infty}^\\infty x^ne^{-x^2}dx=0$ because $x^ne^{-x^2}$ is odd function. When $n$ is even, from Example 1.10.7 we have $\\int_{-\\infty}^\\infty e^{-x^2}dx=\\sqrt{\\pi}$, and by substitution we have\n\\[\n\\int_{-\\infty}^\\infty e^{-ax^2}dx=\\frac{\\sqrt{\\pi}}{\\sqrt{a}}\n\\]\ndifferentiate both sides regarding $a$, \n\\[\n\\frac{d}{da}\\int_{-\\infty}^\\infty e^{-ax^2}dx=\\int_{-\\infty}^\\infty (-x^2)e^{-ax^2}dx=-\\frac{1}{2}\\frac{\\sqrt{\\pi}}{a^{-\\frac{3}{2}}}\n\\]\nso\n\\[\n\\int_{-\\infty}^\\infty x^2e^{-ax^2}dx=\\frac{\\sqrt{\\pi}}{2a^{-\\frac{3}{2}}}\n\\]\ndifferentiate again,\n\\[\n\\frac{d}{da}\\int_{-\\infty}^\\infty x^2e^{-ax^2}dx=\\int_{-\\infty}^\\infty (-x^4)e^{-ax^2}dx=-\\frac{3}{4}\\frac{\\pi}{a^{-\\frac{5}{2}}}\n\\]\nso\n\\[\n\\int_{-\\infty}^\\infty x^4e^{-ax^2}dx=\\frac{3\\sqrt{\\pi}}{4a^{-\\frac{3}{2}}}\n\\]\n\\medskip\n\nLet $\\varphi_n$ be the non-scaled function, and $H_n=a_n\\varphi_n$, so $\\br{H_n}{H_n}=\\int_{-\\infty}^\\infty a_n^2\\varphi_n^2e^{-x^2}dx=2^nn!\\sqrt{\\pi}$. Then\n\\[\n\\varphi_0=1\n\\]\n\\[\n\\br{H_0}{H_0}=\\int_{-\\infty}^\\infty a_0^21^2e^{-x^2}dx=a_0^2\\sqrt{\\pi}=\\sqrt{\\pi}\n\\]\nso $a_0=1$, and $H_0=1$.\n\\[\n\\varphi_1=x-1\\frac{\\int_{-\\infty}^\\infty1\\cdot xe^{-x^2}dx}{\\int_{-\\infty}^\\infty1\\cdot1e^{-x^2}dx}=x\n\\]\n\\[\n\\br{H_1}{H_1}=\\int_{-\\infty}^\\infty a_1^2x^2e^{-x^2}dx=a_1^2\\frac{\\sqrt{\\pi}}{2}=2\\sqrt{\\pi}\n\\]\nso $a_1=2$, and $H_1=2x$.\n\\[\n\\varphi_2=x^2-1\\frac{\\int_{-\\infty}^\\infty1\\cdot x^2e^{-x^2}dx}{\\int_{-\\infty}^\\infty1\\cdot1e^{-x^2}dx}-2x\\frac{\\int_{-\\infty}^\\infty2x\\cdot x^2e^{-x^2}dx}{\\int_{-\\infty}^\\infty2x\\cdot2xe^{-x^2}dx}=x^2-\\frac{1}{2}\n\\]\n\\[\n\\br{H_2}{H_2}=\\int_{-\\infty}^\\infty a_2^2(x^2-\\frac{1}{2})^2e^{-x^2}dx=a_2^2\\frac{\\sqrt{\\pi}}{2}=8\\sqrt{\\pi}\n\\]\nso $a_2=4$, and $H_2=4x^2-2$.\n\n\\paragraph{5.2.5}\n\\[\n\\int_{-1}^1\\frac{x^{2n}}{\\sqrt{1-x^2}}dx=\n\\begin{cases}\n\\pi,\\quad &n=0\\\\\n\\pi\\frac{(2n-1)!!}{(2n)!!},\\quad &n=1,2,3\\cdots\n\\end{cases}\n\\]\nfrom Exercise 13.3.2, and $\\int_{-1}^1\\frac{x^{2n+1}}{\\sqrt{1-x^2}}dx=0$ because $\\frac{x^{2n+1}}{\\sqrt{1-x^2}}$ is an odd function.\n\\medskip\n\nLet $\\varphi_n$ be the non-scaled function, and\n$T_n=a_n\\varphi_n$, so $\\br{T_n}{T_n}=\\int_{-1}^1a_n^2\\varphi_n^2\\frac{1}{\\sqrt{1-x^2}}dx$. Then\n\\[\n\\varphi_0=1\n\\]\n\\[\n\\br{T_0}{T_0}=\\int_{-1}^1a_0^2\\frac{1}{\\sqrt{1-x^2}}dx=a_0^2\\pi=\\pi\n\\]\nso $a_0=1$, and $T_0=1$.\n\\[\n\\varphi_1=x-1\\frac{\\int_{-1}^11\\cdot x\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^11\\cdot1\\frac{1}{\\sqrt{1-x^2}}dx}=x\n\\]\n\\[\n\\br{T_1}{T_1}=\\int_{-1}^1a_1^2x^2\\frac{1}{\\sqrt{1-x^2}}dx=a_1^2\\frac{\\pi}{2}=\\frac{\\pi}{2}\n\\]\nso $a_1=1$, and $T_1=x$.\n\\[\n\\varphi_2=x^2-1\\frac{\\int_{-1}^11\\cdot x^2\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^11\\cdot1\\frac{1}{\\sqrt{1-x^2}}dx}-x\\frac{\\int_{-1}^1x\\cdot x^2\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^1x\\cdot x\\frac{1}{\\sqrt{1-x^2}}dx}=x^2-\\frac{1}{2}\n\\]\n\\[\n\\br{T_2}{T_2}=\\int_{-1}^1a_2^2(x^2-\\frac{1}{2})^2\\frac{1}{\\sqrt{1-x^2}}dx=a_2^2\\frac{\\pi}{8}=\\frac{\\pi}{2}\n\\]\nso $a_2=2$, and $T_2=2x^2-1$.\n\\[\n\\varphi_3=x^3-1\\frac{\\int_{-1}^11\\cdot x^3\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^11\\cdot1\\frac{1}{\\sqrt{1-x^2}}dx}-x\\frac{\\int_{-1}^1x\\cdot x^3\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^1x\\cdot x\\frac{1}{\\sqrt{1-x^2}}dx}-(2x^2-1)\\frac{\\int_{-1}^1(2x^2-1)x^3\\frac{1}{\\sqrt{1-x^2}}dx}{\\int_{-1}^1(2x^2-1)^2\\frac{1}{\\sqrt{1-x^2}}dx}=x^3-\\frac{3}{4}x\n\\]\n\\[\n\\br{T_3}{T_3}=\\int_{-1}^1a_3^2(x^3-\\frac{3}{4}x)^2\\frac{1}{\\sqrt{1-x^2}}dx=a_3^2\\frac{\\pi}{32}=\\frac{\\pi}{2}\n\\]\nso $a_3=4$, and $T_3=4x^3-3x$.\n\n\\paragraph{5.2.6}\nNote that \n\\[\n\\int_{-1}^1x^{2n+1}\\sqrt{1-x^2}dx=0\n\\]\nbecause $x^{2n+1}\\sqrt{1-x^2}$ is an odd function.\n\\medskip\n\nLet $\\varphi_n$ be the non-scaled function, and $U_n=a_n\\varphi_n$, so $\\br{U_n}{U_n}=\\int_{-1}^1a_n^2\\varphi_n^2\\sqrt{1-x^2}dx$. Then\n\\[\n\\varphi_0=1\n\\]\n\\[\n\\br{U_0}{U_0}=\\int_{-1}^1a_0^2\\sqrt{1-x^2}dx=a_0^2\\frac{\\pi}{2}=\\frac{\\pi}{2}\n\\]\nso $a_0=1$, and $U_0=1$.\n\\[\n\\varphi_1=x-1\\frac{\\int_{-1}^11\\cdot x\\sqrt{1-x^2}dx}{\\int_{-1}^11\\cdot1\\sqrt{1-x^2}dx}=x\n\\]\n\\[\n\\br{U_1}{U_1}=\\int_{-1}^1a_1^2x^2\\sqrt{1-x^2}dx=a_1^2\\frac{\\pi}{8}=\\frac{\\pi}{2}\n\\]\nso $a_1=2$, and $U_1=2x$.\n\\[\n\\varphi_2=x^2-1\\frac{\\int_{-1}^11\\cdot x^2\\sqrt{1-x^2}dx}{\\int_{-1}^11\\cdot1\\sqrt{1-x^2}dx}-2x\\frac{\\int_{-1}^12x\\cdot x^2\\sqrt{1-x^2}dx}{\\int_{-1}^12x\\cdot 2x\\sqrt{1-x^2}dx}=x^2-\\frac{1}{4}\n\\]\n\\[\n\\br{U_2}{U_2}=\\int_{-1}^1a_2^2(x^2-\\frac{1}{4})^2\\sqrt{1-x^2}dx=a_2^2\\frac{\\pi}{32}=\\frac{\\pi}{2}\n\\]\nso $a_2=4$, and $U_2=4x^2-1$.\n\n\\paragraph{5.2.7}\n\\[\n\\psi_0=1\n\\]\n\\[\n\\varphi_0=1\n\\]\n\\[\n\\psi_1=x-1\\frac{\\int_0^\\infty1\\cdot xe^{-x^2}dx}{\\int_0^\\infty1\\cdot1e^{-x^2}dx}=x-\\frac{1}{\\sqrt{\\pi}}\n\\]\n\\[\n\\varphi_1=x-\\frac{1}{\\sqrt{\\pi}}\n\\]\n\n\\paragraph{5.2.8}\n\\[\n\\V{a_1'}=\n\\begin{pmatrix}1\\\\1\\\\1\\end{pmatrix}\n\\]\n\\[\n\\V{a_1}=\\frac{\\V{a_1'}}{(\\V{a_1'}\\cdot\\V{a_1'})^{1/2}}=\\frac{1}{\\sqrt{3}}\\begin{pmatrix}1\\\\1\\\\1\\end{pmatrix}\n\\]\n\\[\n\\V{a_2'}=\\V{c_2}-\\V{a_1}(\\V{a_1}\\cdot\\V{c_2})=\\frac{1}{3}\\begin{pmatrix}-1\\\\-1\\\\2\\end{pmatrix}\n\\]\n\\[\n\\V{a_2}=\\frac{\\V{a_2'}}{(\\V{a_2'}\\cdot\\V{a_2'})^{1/2}}=\\frac{1}{\\sqrt{6}}\\begin{pmatrix}-1\\\\-1\\\\2\\end{pmatrix}\n\\]\n\\[\n\\V{a_3'}=\\V{c_3}-\\V{a_1}(\\V{a_1}\\cdot\\V{c_3})-\\V{a_2}(\\V{a_2}\\cdot\\V{c_3})=\\frac{1}{2}\\begin{pmatrix}1\\\\-1\\\\0\\end{pmatrix}\n\\]\n\\[\n\\V{a_3}=\\frac{\\V{a_3'}}{(\\V{a_3'}\\cdot\\V{a_3'})^{1/2}}=\\frac{1}{\\sqrt{2}}\\begin{pmatrix}1\\\\-1\\\\0\\end{pmatrix}\n\\]\n\n\\section*{5.3 Operators}\n\n\\paragraph{5.3.1}\n\\[\n\\br{f}{Ag}=\\br{A^{\\dagger}f}{g}=\\br{g}{A^\\dagger f}^*=\\br{(A^\\dagger)^\\dagger g}{f}^*=\\br{f}{(A^\\dagger)^\\dagger g}\n\\]\nso \\[\n\\br{f}{(A-(A^\\dagger)^\\dagger)g}=0\n\\]\nfor any $f$ and $g$. If $A-(A^\\dagger)^\\dagger\\neq0$, which means there are some $g$ such that $(A-(A^\\dagger)^\\dagger) g=\\varphi\\neq0$, then let $f=\\varphi$, and $\\br{f}{(A-(A^\\dagger)^\\dagger)g}=\\br{\\varphi}{\\varphi}>0$, contradict. So $A-(A^\\dagger)^\\dagger$ must be zero, which means \\[\n(A^\\dagger)^\\dagger=A\n\\]\n\n\\paragraph{5.3.2}\n\\[\n\\br{f}{UVg}=\\br{U^\\dagger f}{Vg}=\\br{V^\\dagger U^\\dagger f}{g}\n\\]\nalso\n\\[\n\\br{f}{UVg}=\\br{(UV)^\\dagger f}{g}\n\\]\nso \n\\[\n\\br{((UV)^\\dagger-V^\\dagger U^\\dagger)f}{g}=0\n\\]\nfor any $f$ and $g$, so $(UV)^\\dagger-V^\\dagger U^\\dagger$ must be zero, which means\n\\[\n(UV)^\\dagger=V^\\dagger U^\\dagger\n\\]\n\n\\paragraph{5.3.3}\n(a) \n\\[\n(A_1)_{ij}=\\br{\\varphi_i|A_1}{\\varphi_j}=\\br{x_i|\\sum_{k=1}^3x_k(\\pdv{}{x_k})}{x_j}=\\br{x_i}{x_j}=\\delta_{ij}\n\\]\n\\[\n(A_2)_{ij}=\\br{\\varphi_i|A_2}{\\varphi_j}=\\br{x_i|x_1(\\pdv{}{x_2})-x_2(\\pdv{}{x_1})}{x_j}=\\br{x_i}{x_1\\delta_{2j}-x_2\\delta_{1j}}=\\delta_{i1}\\delta_{2j}-\\delta_{i2}\\delta_{1j}\n\\]\nIn matrix forms,\n\\[\n\\M{A_1}=\n\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\n\\end{pmatrix}\n\\quad\\quad \\M{A_2}\n\\begin{pmatrix}\n0&1&0\\\\\n-1&0&0\\\\\n0&0&0\n\\end{pmatrix}\n\\]\n\n(b) \n\\[\n\\psi_i=\\br{\\varphi_i}{\\psi}=\\br{x_i}{x_1-2x_2+3x_3}=\\delta_{i1}-2\\delta_{i2}+3\\delta_{i3}\n\\]\nIn matrix form, \n\\[\n\\boldsymbol{\\psi}=\n\\begin{pmatrix}\n1\\\\-2\\\\3\n\\end{pmatrix}\n\\]\n\n(c) From matrix equation, \n\\[\n\\boldsymbol{\\chi}=\\left[\n\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\n\\end{pmatrix}\n-\n\\begin{pmatrix}\n0&1&0\\\\\n-1&0&0\\\\\n0&0&0\n\\end{pmatrix}\n\\right]\n\\begin{pmatrix}\n1\\\\-2\\\\3\n\\end{pmatrix}=\n\\begin{pmatrix}\n3\\\\-1\\\\3\n\\end{pmatrix}\n\\]\nwhich is $3x_1-x_2+3x_3$.\n\nBy direct application,\n\\[\n\\chi=(A_1-A_2)\\psi=\\sum_{i=1}^3x_i(\\pdv{}{x_i})(x_1-2x_2+3x_3)-\\left[x_1(\\pdv{}{x_2})-x_2(\\pdv{}{x_1}) \\right](x_1-2x_2+3x_3)\n\\]\n\\[\n=x_1-2x_2+3x_3-(-2x_1-x_2)=3x_1-x_2+3x_3\n\\]\nwhich is the same with the results from matrix multiplication.\n\n\\paragraph{5.3.4}\n(a)\n\\[\nAP_0=x\\frac{d}{dx}(\\frac{1}{\\sqrt{2}})=0\n\\]\n\\[\nAP_1=x\\frac{d}{dx}(\\sqrt{\\frac{3}{2}}x)=\\sqrt{\\frac{3}{2}}x=P_1\n\\]\n\\[\nAP_2=x\\frac{d}{dx}\\left(\\sqrt{\\frac{5}{2}}(\\frac{3}{2}x^2-\\frac{1}{2})\\right)=\\sqrt{\\frac{5}{2}}\\,3x^2=2P_2+\\sqrt{5}P_0\n\\]\n\\[\nAP_3=x\\frac{d}{dx}\\left(\\sqrt{\\frac{7}{2}}(\\frac{5}{2}x^3-\\frac{3}{2}x)\\right)=\\sqrt{\\frac{7}{2}}\\frac{15}{2}x^3-\\sqrt{\\frac{7}{2}}\\frac{3}{2}x=3P_3+\\sqrt{21}P_1\n\\]\nWe can evaluate $A_{ij}$ by $A_{ij}=\\br{P_i}{AP_j}$, and $\\br{P_i}{P_j}=\\delta_{ij}$. In matrix form,\n\\[\n\\M{A}=\n\\begin{pmatrix}\n0&0&\\sqrt{5}&0\\\\\n0&1&0&\\sqrt{21}\\\\\n0&0&2&0\\\\\n0&0&0&3\n\\end{pmatrix}\n\\]\n\n(b)\n\\[\nx^3=P_0\\int_{-1}^1\\frac{1}{\\sqrt{2}}\\,x^3dx+P_1\\int_{-1}^1\\sqrt{\\frac{3}{2}}x\\cdot x^3dx+P_2\\int_{-1}^1\\sqrt{\\frac{5}{2}}(\\frac{3}{2}x^2-\\frac{1}{2})\\cdot x^3dx+P_3\\int_{-1}^1\\sqrt{\\frac{7}{2}}(\\frac{5}{2}x^3-\\frac{3}{2}x)x^3dx\\]\n\\[=\\frac{\\sqrt{6}}{5}P_1+\\frac{2\\sqrt{14}}{35}P_3\n\\]\n\n\n(c)\n\\renewcommand{\\arraystretch}{1.5}\n\\[\n\\begin{pmatrix}\n0&0&\\sqrt{5}&0\\\\\n0&1&0&\\sqrt{21}\\\\\n0&0&2&0\\\\\n0&0&0&3\n\\end{pmatrix}\n\\begin{pmatrix}\n0\\\\\\frac{\\sqrt{6}}{5}\\\\0\\\\\\frac{2 \\sqrt{14}}{35}\n\\end{pmatrix}=\n\\begin{pmatrix}\n0\\\\\\frac{3\\sqrt{6}}{5}\\\\0\\\\\\frac{6\\sqrt{14}}{35}\n\\end{pmatrix}\n\\]\nwhich is \n\\[\n\\frac{3\\sqrt{6}}{5}(\\sqrt{\\frac{3}{2}}x)+\\frac{6\\sqrt{14}}{35}\\sqrt{\\frac{7}{2}}(\\frac{5}{2}x^3-\\frac{3}{2}x)=3x^3\n\\]\nwhich is the same as $Ax^3=x\\frac{d}{dx}(x^3)=3x^3$.\n\n\\section*{5.4 Self-Adjoint Operators}\n\n\\paragraph{5.4.1}\n(a) \n\\[\n\\br{f}{(A+A^\\dagger)g}=\\br{(A+A^\\dagger)^\\dagger f}{g}=\\br{(A^\\dagger+A)f}{g}=\\br{(A+A^\\dagger)f}{g}\n\\]\n\\[\n\\br{f}{i(A-A^\\dagger)g}=\\br{-i(A-A^\\dagger)^\\dagger f}{g}=\\br{-i(A^\\dagger-A)f}{g}=\\br{i(A-A^\\dagger)f}{g}\n\\]\n\n(b)\nFor every operator $A$,\n\\[\nA=\\frac{1}{2}(A+A^\\dagger)-\\frac{i}{2}i(A-A^\\dagger)\n\\]\nwhere both $A+A^\\dagger$ and $i(A-A^\\dagger)$ are Hermitian.\n\n\\paragraph{5.4.2}\nLet $A,B$ be Hermitian. \n\nIf $AB$ is Hermitian, then $\\br{f}{ABg}=\\br{ABf}{g}$, but also\n\\[\n\\br{f}{ABg}=\\br{Af}{Bg}=\\br{BAf}{g}\n\\]\nso $\\br{(AB-BA)f}{g}=0$ for any $f,g$, which means $(AB-BA)$ must be zero, and therefore $AB=BA$, \n\nIf $AB=BA$, then \n\\[\n\\br{f}{ABg}=\\br{Af}{Bg}=\\br{BAf}{g}=\\br{ABf}{g}\n\\]\nso $AB$ is Hermitian.\n\n\\paragraph{5.4.3}\n$A,B$ are Hermitian because they are quantum mechanical operators. $C=-i(AB-BA)$, so\n\\[\n\\br{f}{Cg}=\\br{C^\\dagger d}{g}=\\br{i(B^\\dagger A^\\dagger-A^\\dagger B^\\dagger)f}{g}=\\br{i(BA-AB)f}{g}=\\br{-i(AB-BA)f}{g}=\\br{Cf}{g}\n\\]\nso $C$ is Hermitian.\n\n\\paragraph{5.4.4}\n$\\mathcal{L}$ is Hermitian, so\n\\[\n\\br{\\psi|\\mathcal{L}^2}{\\psi}=\\br{\\psi|\\mathcal{L}\\mathcal{L}}{\\psi}=\\br{\\mathcal{L}\\psi}{\\mathcal{L}\\psi}\\geq0\n\\]\nby the definition of scalar product.\n\n\\paragraph{5.4.5}\n(a) In spherical polar coordinate, $\\varphi_1=C\\sin\\theta\\cos\\varphi$, $\\varphi_2=C\\sin\\theta\\sin\\varphi$, $\\varphi_3=C\\cos\\theta$. So\n\\[\n\\br{\\varphi_1}{\\varphi_1}=\\int_0^\\pi\\int_0^{2\\pi}(|C|^2\\sin^2\\theta\\cos^2\\varphi)\\sin\\theta\\, d\\theta\\,d\\varphi\n\\]\n\\[\n=|C|^2\\int_0^\\pi\\sin^3\\theta\\,d\\theta\\int_0^{2\\pi}\\cos^2\\varphi\\,d\\varphi=|C|^2\\frac{4\\pi}{3}=1\n\\]\nso \n\\[\nC=\\sqrt{\\frac{3}{4\\pi}}e^{i\\theta}\n\\]\nBy symmetry this $C$ also made $\\varphi_2$ and $\\varphi_3$ normalized.\n\n\\[\n\\br{\\varphi_1}{\\varphi_2}=\\int_0^\\pi\\int_0^{2\\pi}|C|^2\\sin^2\\theta\\cos^2\\varphi\\sin\\theta\\,d\\theta\\,d\\varphi\n\\]\n\\[\n=|C|^2\\int_0^\\pi\\sin^3\\theta\\,d\\theta\\int_0^{2\\pi}\\sin\\varphi\\cos\\varphi\\,d\\varphi=0\n\\]\nBy symmetry $\\br{\\varphi_2}{\\varphi_3}$ and $\\br{\\varphi_3}{\\varphi_1}$ are also zero.\n\\medskip\n\n(b) Let $i,j,k$ be a cyclic permutation of $x,y,z$, then all the three operators have the form\n\\[\nL_i=-i(x_j\\pdv{}{x_k}-x_k\\pdv{}{x_j})\n\\]\nNote that $\\pdv{}{x_k}(\\frac{1}{r})=-\\frac{x_k}{r^3}$, so\n\\[\nL_i\\varphi_b=-i\\left[x_j\\pdv{}{x_k}(\\frac{Cx_b}{r})-x_k\\pdv{}{x_j}(\\frac{Cx_b}{r}) \\right]\n\\]\n\\[\n=-iC\\left[x_j\\pdv{x_b}{x_k}\\frac{1}{r}-x_jx_b\\frac{x_k}{r^3}-x_k\\pdv{x_b}{x_j}\\frac{1}{r}+x_kx_b\\frac{x_j}{r^3} \\right]\n\\]\n\\[\n=-i\\frac{C}{r}\\left[x_j\\delta_{kb}-x_k\\delta_{jb} \\right]=-i\\left[\\varphi_j\\delta_{kb}-\\varphi_k\\delta_{jb} \\right]\n\\]\nso\n\\[\n\\br{\\varphi_a|L_i}{\\varphi_b}=-i\\left[\\br{\\varphi_a}{\\varphi_j}\\delta_{kb}-\\br{\\varphi_a}{\\varphi_k}\\delta_{jb} \\right]=-i\\left(\\delta_{aj}\\delta_{kb}-\\delta_{ak}\\delta_{jb} \\right)\n\\]\n\\[\n=\n\\begin{cases}\n-i & \\textit{when $a=j,\\;b=k$}\\\\\ni & \\textit{when $a=k,\\;b=j$}\n\\end{cases}\n\\]\nThe components of $L_i$ are $(L_i)_{ab}=\\br{\\varphi_a|L_i}{\\varphi_b}$, so in matrix form,\n\\[\nL_x=\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\\quad\nL_y=\n\\begin{pmatrix}\n0&0&i\\\\\n0&0&0\\\\\n-i&0&0\n\\end{pmatrix}\\quad\nL_z=\n\\begin{pmatrix}\n0&-i&0\\\\\ni&0&0\\\\\n0&0&0\n\\end{pmatrix}\\quad\n\\]\n\n(c)\n\\[\nL_xL_y-L_yL_x=\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\n\\begin{pmatrix}\n0&0&i\\\\\n0&0&0\\\\\n-i&0&0\n\\end{pmatrix}-\n\\begin{pmatrix}\n0&0&i\\\\\n0&0&0\\\\\n-i&0&0\n\\end{pmatrix}\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}=\n\\begin{pmatrix}\n0&1&0\\\\\n-1&0&0\\\\\n0&0&0\n\\end{pmatrix}=iL_z\n\\]\n\\medskip\n\n\\noindent\n(we can prove $[L_x,L_y]=iL_z$, $[L_y,L_z]=iL_x$, $[L_z,L_x]=iL_y$ together:\nNote that \n\\[\n\\br{\\varphi_a|L_i}{\\varphi_b}=\\begin{cases}\n-i & \\textit{when $a=j,\\;b=k$}\\\\\ni & \\textit{when $a=k,\\;b=j$}\n\\end{cases}\n\\]\nis equivalent with $(L_i)_{ab}=-i\\varepsilon_{iab}$.\nLet $i,j,k$ be a cyclic permutation of $x,y,z$, then\n\\[\n(L_iL_j)_{ab}=\\sum_c(L_i)_{ac}(L_j)_{cb}=\\sum_c-\\varepsilon_{iac}\\varepsilon_{jcb}=-\\varepsilon_{iak}\\varepsilon_{jkb}=\\varepsilon_{iak}\\varepsilon_{jbk}=\\delta_{ij}\\delta_{ab}-\\delta_{ib}\\delta_{aj}=-\\delta_{ib}\\delta_{aj}\n\\]\nby Exercise 2.1.9. So\n\\[\n(L_iL_j-L_jL_i)_{ab}=-\\delta_{ib}\\delta_{aj}+\\delta_{jb}\\delta_{ai}=\\sum_l\\varepsilon_{ijl}\\varepsilon_{abl}=\\varepsilon_{ijk}\\varphi_{abk}=\\varepsilon_{abk}=i(-i\\varepsilon_{kab})=i(L_k)_{ab}\n\\]\nwhich means $[L_i,L_j]=iL_k$ )\n\n\\section*{5.5 Unitary Operators}\n\n\\paragraph{5.5.1}\n(There are mistakes in the matrix $\\M{U}$ given in the text: $\\M{U}_{33}$ should be $\\frac{-i}{\\sqrt{2}}$ and $\\M{U}_{43}$ should be $\\frac{i}{\\sqrt{2}}$. It can be verified by checking $\\chi_3=U_{33}\\chi_3'+U_{43}\\chi_4'$. The author probably forget to take the complex conjugate of $\\chi_3'$ when calculating $\\br{\\chi_3'}{\\chi_3}=\\int_0^\\pi\\int_0^{2\\pi}\\sin\\theta\\,d\\theta d\\varphi(\\chi_3')^*\\chi_3$, as well as $\\br{\\chi_4'}{\\chi_3}$. )\n\\medskip\n\n(a) \n\\renewcommand{\\arraystretch}{1}\n\\[\nf(\\theta,\\varphi)=\\V{c}=\n\\begin{pmatrix}\n3\\\\2i\\\\-1\\\\0\\\\1\n\\end{pmatrix}\n\\]\n\\renewcommand{\\arraystretch}{1.5}\n\\[\n\\V{c'}=\\M{U}\\V{c}=\n\\begin{pmatrix}\n\\frac{-1}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}&0&0&0\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}&0&0&0\\\\\n0&0&\\frac{-i}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\\\\\n0&0&\\frac{i}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\\\\\n0&0&0&0&1\n\\end{pmatrix}\n\\begin{pmatrix}\n3\\\\2i\\\\-1\\\\0\\\\1\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{-1}{\\sqrt{2}}\\\\\\frac{5}{\\sqrt{2}}\\\\\\frac{i}{\\sqrt{2}}\\\\\\frac{-i}{\\sqrt{2}}\\\\1\n\\end{pmatrix}\n\\]\n\\[\n\\sum_ic_i'\\chi_i'=\\sqrt{\\frac{15}{8\\pi}}\\sin\\theta\\cos\\theta(\\frac{1}{\\sqrt{2}}e^{i\\varphi}+\\frac{5}{\\sqrt{2}}e^{-i\\varphi})+\\sqrt{\\frac{15}{32\\pi}}\\sin^2\\theta(\\frac{i}{\\sqrt{2}}e^{2i\\varphi}-\\frac{i}{\\sqrt{2}}e^{-2i\\varphi})+\\chi_5'\n\\]\n\\[\n=3\\sqrt{\\frac{15}{4\\pi}}\\sin\\theta\\cos\\theta\\cos\\varphi-2i\\sqrt{\\frac{15}{4\\pi}}\\sin\\theta\\cos\\theta\\sin\\varphi-\\sqrt{\\frac{15}{4\\pi}}\\sin^2\\theta\\sin\\varphi\\cos\\varphi+\\chi_5\n\\]\n\\[\n=3\\chi_1-2i\\chi_2-\\chi_3+\\chi_5=\\sum_ic_i\\chi_i=f(\\theta,\\varphi)\n\\]\n\n(b)\n\\[\n\\M{U}^{-1}\\M{U}=\n\\begin{pmatrix}\n\\frac{-1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0&0&0\\\\\n\\frac{-i}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}&0&0&0\\\\\n0&0&\\frac{-i}{\\sqrt{2}}&\\frac{i}{\\sqrt{2}}&0\\\\\n0&0&\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\\\\\n0&0&0&0&1\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{-1}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}&0&0&0\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}&0&0&0\\\\\n0&0&\\frac{-i}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\\\\\n0&0&\\frac{i}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}&0\\\\\n0&0&0&0&1\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0&0&0&0\\\\\n0&1&0&0&0\\\\\n0&0&1&0&0\\\\\n0&0&0&1 &0\\\\\n0&0&0&0&1\n\\end{pmatrix}\n\\]\n\n\\paragraph{5.5.2}\n\\renewcommand{\\arraystretch}{1.0}\n(a) The transformation is $x=z'$, $y=y'$, $z=-x'$. The new basis is defined as $\\varphi_1'=x'$, $\\varphi_2'=y'$, $\\varphi_3'=z'$, so $\\varphi_1=\\varphi_3'$, $\\varphi_2=\\varphi_2'$, $\\varphi_3=-\\varphi_1'$, which in matrix representation becomes\n\\[\n\\begin{pmatrix}\n0&0&-1\\\\\n0&1&0\\\\\n1&0&0\\\\\n\\end{pmatrix}\n\\]\n\n(b) The transformation corresponds to rotating $\\frac{\\pi}{2}$ counterclockwise about $y$-axis, so the Euler angles are $\\alpha=0$, $\\beta=\\frac{\\pi}{2}$, $\\gamma=0$. By Eq. 3.37, \\[\nS(\\alpha,\\beta,\\gamma)=\n\\begin{pmatrix}\n0&0&-1\\\\\n0&1&0\\\\\n1&0&0\\\\\n\\end{pmatrix}\n\\]\nwhich is the same as (a).\n\n(c) \n\\[\n\\begin{pmatrix}\n0&0&-1\\\\\n0&1&0\\\\\n1&0&0\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n2\\\\-3\\\\1\n\\end{pmatrix}=\n\\begin{pmatrix}\n-1\\\\-3\\\\2\n\\end{pmatrix}\n\\]\nso $f'=-x'-3y'+2z'=z-3y+2x=f$, consistent.\n\n\\paragraph{5.5.3}\n$\\varphi_1'=-\\varphi_3$, $\\varphi_2'=\\varphi_2$, $\\varphi_3'=\\varphi_1$, so the inverse transformation matrix is \n\\[\n\\M{U'}=\\begin{pmatrix}\n0&0&1\\\\\n0&1&0\\\\\n-1&0&0\\\\\n\\end{pmatrix}\n\\]\n\\[\n\\M{U'}\\M{U}=\\begin{pmatrix}\n0&0&1\\\\\n0&1&0\\\\\n-1&0&0\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n0&0&-1\\\\\n0&1&0\\\\\n1&0&0\\\\\n\\end{pmatrix}\n=\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\\\\\n\\end{pmatrix}\n\\]\nso the two matrix are matrix inverses of each other.\n\n\\paragraph{5.5.4}\n(\nThe transformation matrix $V$ given is not unitary. A possible unitary $V$ is\n\\[\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\theta&i\\sin\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\n\\end{pmatrix}\n\\]\nwhich will be used to solve the problem.)\n\n(a) \n\\[\n\\begin{pmatrix}\ni\\sin\\theta&\\cos\\theta&0\\\\\n-\\cos\\theta&i\\sin\\theta&0\\\\\n0&0&1\n\\end{pmatrix}\n\\begin{pmatrix}\n3\\\\-1\\\\-2\n\\end{pmatrix}=\n\\begin{pmatrix}\n-\\cos\\theta+3i\\sin\\theta\\\\\n-3\\cos\\theta-i\\sin\\theta\\\\\n-2\n\\end{pmatrix}\n\\]\n\\[\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\theta&i\\sin\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\n-\\cos\\theta+3i\\sin\\theta\\\\\n-3\\cos\\theta-i\\sin\\theta\\\\\n-2\n\\end{pmatrix}=\n\\begin{pmatrix}\n-\\cos\\theta+3i\\sin\\theta\\\\\n-3\\cos^2\\theta-i\\sin\\theta(\\cos\\theta+2)\\\\\n-3\\sin\\theta\\cos\\theta+i(2\\cos\\theta-\\sin^2\\theta)\n\\end{pmatrix}\n\\]\nso\n\\[\nf(x)=(-\\cos\\theta+3i\\sin\\theta)\\chi_1+(-3\\cos^2\\theta-i\\sin\\theta(\\cos\\theta+2))\\chi_2+(-3\\sin\\theta\\cos\\theta+i(2\\cos\\theta-\\sin^2\\theta))\\chi_3\n\\]\n\n(b)\n\\[\n(UV)=\\begin{pmatrix}\ni\\sin\\theta&\\cos\\theta&0\\\\\n-\\cos\\theta&i\\sin\\theta&0\\\\\n0&0&1\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\theta&i\\sin\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\n\\end{pmatrix}=\n\\begin{pmatrix}\ni\\sin\\theta&\\cos^2\\theta&i\\sin\\theta\\cos\\theta\\\\\n-\\cos\\theta&i\\sin\\theta\\cos\\theta&-\\sin^2\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\\\\\n\\end{pmatrix}\n\\]\n\\[\n\\begin{pmatrix}\ni\\sin\\theta&\\cos^2\\theta&i\\sin\\theta\\cos\\theta\\\\\n-\\cos\\theta&i\\sin\\theta\\cos\\theta&-\\sin^2\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n3\\\\-1\\\\-2\n\\end{pmatrix}=\n\\begin{pmatrix}\n-\\cos^2\\theta+i\\sin\\theta(3-2\\cos\\theta)\\\\\n-3\\cos\\theta+2\\sin^2\\theta-i\\sin\\theta\\cos\\theta\\\\\n-\\sin\\theta+2i\\cos\\theta\n\\end{pmatrix}\n\\]\n\\[\n(VU)=\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\cos\\theta&i\\sin\\theta\\\\\n0&\\sin\\theta&-i\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\ni\\sin\\theta&\\cos\\theta&0\\\\\n-\\cos\\theta&i\\sin\\theta&0\\\\\n0&0&1\n\\end{pmatrix}=\n\\begin{pmatrix}\ni\\sin\\theta&\\cos\\theta&0\\\\\n-\\cos^2\\theta&i\\sin\\theta\\cos\\theta&i\\sin\\theta\\\\\n-\\sin\\theta\\cos\\theta&i\\sin^2\\theta&-i\\cos\\theta\n\\end{pmatrix}\n\\]\n\\[\n\\begin{pmatrix}\ni\\sin\\theta&\\cos\\theta&0\\\\\n-\\cos^2\\theta&i\\sin\\theta\\cos\\theta&i\\sin\\theta\\\\\n-\\sin\\theta\\cos\\theta&i\\sin^2\\theta&-i\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\n3\\\\-1\\\\-2\n\\end{pmatrix}=\n\\begin{pmatrix}\n-\\cos\\theta+3i\\sin\\theta\\\\\n-3\\cos^2\\theta-i\\sin\\theta(\\cos\\theta+2)\\\\\n-3\\sin\\theta\\cos\\theta+i(2\\cos\\theta-\\sin^2\\theta)\n\\end{pmatrix}\n\\]\nSo only applying $VU$ gives the same answer as (a), which is quite obvious because $U$ is applied first.\n\n\\paragraph{5.5.5}\n\\newcommand{\\PP}[1]{\\mathcal{P}_{#1}}\n\\newcommand{\\FF}[1]{\\mathcal{F}_{#1}}\n\\newcommand{\\II}[1]{\\int_{-1}^1#1\\,dx}\n(a) Let the normalized $\\PP{n}=a_nP_n$ and $\\FF{n}=b_nP_n$. Let the factors $a_n$ and $b_n$ be positive real numbers (every $a_ne^{i\\theta}$ can also normalize the functions, as well as $b_ne^{i\\theta}$)\n\\[\n\\II{|a_0|^2P_0^2}=|a_0|^22=1,\\quad a_0=\\frac{1}{\\sqrt{2}},\\quad\\PP{0}=\\frac{1}{\\sqrt{2}}\n\\]\n\\[\n\\II{|a_1|^2P_1^2}=|a_1|^2\\frac{2}{3}=1,\\quad a_1=\\sqrt{\\frac{3}{2}},\\quad\\PP{1}=\\sqrt{\\frac{3}{2}}x\n\\]\n\\[\n\\II{|a_2|^2P_2^2}=|a_2|^2\\frac{2}{5}=1,\\quad a_2=\\sqrt{\\frac{5}{2}},\\quad\\PP{2}=\\sqrt{\\frac{5}{2}}(\\frac{3}{2}x^2-\\frac{1}{2})\n\\]\n\n\\[\n\\II{|b_0|^2F_0^2}=|b_0|^2\\frac{2}{5}=1,\\quad b_0=\\sqrt{\\frac{5}{2}},\\quad\\FF{1}=\\sqrt{\\frac{5}{2}}x^2\n\\]\n\\[\n\\II{|b_1|^2F_1^2}=|b_1|^2\\frac{2}{3}=1,\\quad b_1=\\sqrt{\\frac{3}{2}},\\quad\\FF{1}=\\sqrt{\\frac{3}{2}}x\n\\]\n\\[\n\\II{|b_2|^2F_2^2}=|b_2|^28=1,\\quad b_2=\\frac{1}{\\sqrt{8}},\\quad\\FF{2}=\\frac{1}{\\sqrt{8}}(5x^2-3)\n\\]\n\n(b) $U_{ij}=\\II{F_i^*P_j}$. Note that except $U_{00},U_{02},U_{11},U_{20},U_{22}$, all the other $U_{ij}$ vanish because $F_i^*P_j$ are odd functions for these $i,j$.\n\\[\nU_{00}=\\II{\\frac{\\sqrt{5}}{2}x^2}=\\frac{\\sqrt{5}}{3}\n\\]\n\\[\nU_{02}=\\II{\\frac{5}{2}(\\frac{3}{2}x^4-\\frac{1}{2}x^2)}=\\frac{2}{3}\n\\]\n\\[\nU_{11}=\\II{\\frac{3}{2}x^2}=1\n\\]\n\\[\nU_{20}=\\II{\\frac{1}{4}(5x^2-3)}=-\\frac{2}{3}\n\\]\n\\[\nU_{22}=\\II{\\frac{\\sqrt{5}}{4}(\\frac{15}{2}x^4-7x^2+\\frac{3}{2})}=\\frac{\\sqrt{5}}{3}\n\\]\nso\n\\[\n\\M{U}=\n\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&\\frac{2}{3}\\\\\n0&1&0\\\\\n-\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}\n\\]\n\n(c)$V_{ij}=\\II{P_i^*F_j}$. Note that except $V_{00},V_{02},V_{11},V_{20},V_{22}$, all the other $V_{ij}$ vanish because $P_i^*F_j$ are odd functions for these $i,j$.\n\\[\nV_{00}=\\II{\\frac{\\sqrt{5}}{2}x^2}=\\frac{\\sqrt{5}}{3}\n\\]\n\\[\nV_{02}=\\II{\\frac{1}{4}(5x^2-3)}=-\\frac{2}{3}\n\\]\n\\[\nV_{11}=\\II{\\frac{3}{2}x^2}=1\n\\]\n\\[\nV_{20}=\\II{\\frac{5}{2}(\\frac{3}{2}x^4-\\frac{1}{2}x^2)}=\\frac{2}{3}\n\\]\n\\[\nV_{22}=\\II{\\frac{\\sqrt{5}}{4}(\\frac{15}{2}x^4-7x^2+\\frac{3}{2})}=\\frac{\\sqrt{5}}{3}\n\\]\nso\n\\[\n\\M{V}=\n\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&-\\frac{2}{3}\\\\\n0&1&0\\\\\n\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}\n\\]\n\n(d)\n\\[\n\\M{U}^{-1}=\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&-\\frac{2}{3}\\\\\n0&1&0\\\\\n\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}=\\M{V}\n\\]\n\\[\n\\M{V}^{-1}=\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&\\frac{2}{3}\\\\\n0&1&0\\\\\n-\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}=\\M{U}\n\\]\n\\[\n\\M{U}\\M{U}^{-1}=\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&\\frac{2}{3}\\\\\n0&1&0\\\\\n-\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&-\\frac{2}{3}\\\\\n0&1&0\\\\\n\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\n\\end{pmatrix}\n\\]\n\\[\n\\M{V}\\M{V}^{-1}=\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&-\\frac{2}{3}\\\\\n0&1&0\\\\\n\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&\\frac{2}{3}\\\\\n0&1&0\\\\\n-\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\n\\end{pmatrix}\n\\]\n\n(e) \n\\renewcommand{\\arraystretch}{2}\n\\[\n\\V{f}_{P}=\n\\begin{pmatrix}\n\\II{(\\frac{1}{\\sqrt{2}})(5x^2-3x+1)}\\\\\n\\II{(\\sqrt{\\frac{3}{2}}x)(5x^2-3x+1)}\\\\\n\\II{\\sqrt{\\frac{5}{2}}(\\frac{3}{2}x^2-\\frac{1}{2})(5x^2-3x+1)}\\\\\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{8\\sqrt{2}}{3}\\\\-\\sqrt{6}\\\\\\frac{2\\sqrt{10}}{3}\n\\end{pmatrix}\n\\]\n\\[\n\\V{f}_{F}=\n\\begin{pmatrix}\n\\II{(\\sqrt{\\frac{5}{2}}x^2)(5x^2-3x+1)}\\\\\n\\II{(\\sqrt{\\frac{3}{2}}x)(5x^2-3x+1)}\\\\\n\\II{\\frac{1}{\\sqrt{8}}(5x^2-3)(5x^2-3x+1)}\\\\\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{4\\sqrt{10}}{3}\\\\-\\sqrt{6}\\\\-\\frac{2\\sqrt{2}}{3}\n\\end{pmatrix}\n\\]\n\\[\n\\M{U}\\V{f}_{P}=\\begin{pmatrix}\n\\frac{\\sqrt{5}}{3}&0&\\frac{2}{3}\\\\\n0&1&0\\\\\n-\\frac{2}{3}&0&\\frac{\\sqrt{5}}{3}\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{8\\sqrt{2}}{3}\\\\-\\sqrt{6}\\\\\\frac{2\\sqrt{10}}{3}\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{4\\sqrt{10}}{3}\\\\-\\sqrt{6}\\\\-\\frac{2\\sqrt{2}}{3}\n\\end{pmatrix}=\\V{f}_F\n\\]\n\n\\section*{5.6 Transformations of Operators}\n\n\\paragraph{5.6.1}\n\\renewcommand{\\arraystretch}{1.2}\n(a) \n\\[\nS_x=\n\\begin{pmatrix}\n0&\\frac{1}{2}\\\\\n\\frac{1}{2}&0\n\\end{pmatrix},\\quad\nS_y=\n\\begin{pmatrix}\n0&\\frac{-i}{2}\\\\\n\\frac{i}{2}&0\n\\end{pmatrix}\nS_z=\n\\begin{pmatrix}\n\\frac{1}{2}&0\\\\\n0&\\frac{-1}{2}\n\\end{pmatrix}\n\\]\n\n(b) \n\\[\n\\br{\\varphi_1'}{\\varphi_2'}=\\br{C(\\alpha+\\beta)}{C(\\alpha-\\beta)}=|C|^2(\\br{\\alpha}{\\alpha}-\\br{\\alpha}{\\beta}+\\br{\\beta}{\\alpha}-\\br{\\beta}{\\beta})=|C|^2(1-1)=0\n\\]\n\\[\n\\br{\\varphi_1'}{\\varphi_1'}=\\br{C(\\alpha+\\beta)}{C(\\alpha+\\beta)}=|C|^2(\\br{\\alpha}{\\alpha}+\\br{\\alpha}{\\beta}+\\br{\\beta}{\\alpha}+\\br{\\beta}{\\beta})=|C|^22=1\n\\]\nso $C=\\frac{1}{\\sqrt{2}}$ can normalize $\\varphi_1'$ and $\\varphi_2'$. The transformation matrix $\\M{U}$ is\n\\[\n\\M{U}=\n\\begin{pmatrix}\n\\br{\\varphi_1'}{\\varphi_1}&\\br{\\varphi_1'}{\\varphi_2}\\\\\n\\br{\\varphi_2'}{\\varphi_1}&\\br{\\varphi_2'}{\\varphi_2}\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}\n\\]\n\n(c) \n\\[\nS_x'=\\M{U}S_x\\M{U}^{-1}=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}\n\\begin{pmatrix}\n0&\\frac{1}{2}\\\\\n\\frac{1}{2}&0\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}=\\begin{pmatrix}\n\\frac{1}{2}&0\\\\\n0&\\frac{-1}{2}\n\\end{pmatrix}\n\\]\n\\[\nS_y'=\\M{U}S_y\\M{U}^{-1}=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}\n\\begin{pmatrix}\n0&\\frac{-i}{2}\\\\\n\\frac{i}{2}&0\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}=\\begin{pmatrix}\n0&\\frac{i}{2}\\\\\n\\frac{-i}{2}&0\n\\end{pmatrix}\n\\]\n\\[\nS_z'=\\M{U}S_z\\M{U}^{-1}=\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{1}{2}&0\\\\\n0&\\frac{-1}{2}\n\\end{pmatrix}\n\\begin{pmatrix}\n\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n\\frac{1}{\\sqrt{2}}&\\frac{-1}{\\sqrt{2}}\n\\end{pmatrix}=\\begin{pmatrix}\n0&\\frac{1}{2}\\\\\n\\frac{1}{2}&0\n\\end{pmatrix}\n\\]\n\n\\paragraph{5.6.2}\n(a) Note that $y\\pdv{}{z}(e^{-r^2})-z\\pdv{}{y}(e^{-r^2})=e^{-r^2}(-2r)(y\\frac{z}{r}-z\\frac{y}{r})=0$, so\n\\[\nL_x\\varphi_1=0\n\\]\n\\[\nL_x\\varphi_2=-iC(-ze^{-r^2})=i\\varphi_3\n\\]\n\\[\nL_x\\varphi_3=-iC(ye^{-r^2})=-i\\varphi_2\n\\]\nso in matrix form,\n\\[\nL_x=\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\n\\]\n\n(b)\n\\[\nL_x'=\\M{U}L_x\\M{U}^{-1}=\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\frac{1}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}\\\\\n0&\\frac{1}{\\sqrt{2}}&\\frac{i}{\\sqrt{2}}\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0&0\\\\\n0&\\frac{1}{\\sqrt{2}}&\\frac{1}{\\sqrt{2}}\\\\\n0&\\frac{i}{\\sqrt{2}}&\\frac{-i}{\\sqrt{2}}\\\\\n\\end{pmatrix}=\n\\begin{pmatrix}\n0&0&0\\\\\n0&1&0\\\\\n0&0&-1\n\\end{pmatrix}\n\\]\n\n(c) $\\varphi_i'$ is the $i^{th}$ column of $\\M{U}^{-1}$ in $\\varphi_i$ basis, so\n\\[\n\\varphi_1'=Cxe^{-r^2}\\quad\\varphi_2'=C\\frac{y+iz}{\\sqrt{2}}e^{-r^2}\\quad\\varphi_3'=C\\frac{y-iz}{\\sqrt{2}}e^{-r^2}\n\\]\n\n$L_x\\varphi_i'$ is the $i^{th}$ column of $L_x'$ in $\\varphi_i'$ basis, so\n\\[\nL_x\\varphi_1'=0\\quad L_x\\varphi_2'=\\varphi_2'=C\\frac{y+iz}{\\sqrt{2}}e^{-r^2}\\quad L_x\\varphi_3'=-\\varphi_3'=-C\\frac{y-iz}{\\sqrt{2}}e^{-r^2} \n\\]\n\n\\paragraph{5.6.3}\nDefinition:\n\\[\n\\varphi_1=T_{11}\\chi_1\n\\]\n\\[\n\\varphi_2=T_{12}\\chi_1+T_{22}\\chi_2\n\\]\n\\[\n\\varphi_3=T_{13}\\chi_1+T_{23}\\chi_2+T_{33}\\chi_3\n\\]\n\\[\n\\M{T}=\n\\begin{pmatrix}\nT_{11}&T_{12}&T_{13}\\\\\n0&T_{22}&T_{23}\\\\\n0&0&T_{33}\n\\end{pmatrix}\n\\]\nLet $\\psi_i$ be the orthogonalized but yet normalized functions, so\n\\[\n\\psi_1=\\chi_1\n\\]\n\\[\n\\psi_2=\\chi_2-\\psi_1\\frac{\\br{\\psi_1}{\\chi_2}}{\\br{\\psi_1}{\\psi_1}}\n\\]\n\\[\n\\psi_3=\\chi_3-\\psi_2\\frac{\\br{\\psi_2}{\\chi_3}}{\\br{\\psi_2}{\\psi_2}}-\\psi_1\\frac{\\br{\\psi_1}{\\chi_3}}{\\br{\\psi_1}{\\psi_1}}\n\\]\nBy comparing the coefficients of $\\chi_n$ in $\\varphi_n$ and $\\psi_n$, we have\n\\[\n\\varphi_n=T_{nn}\\psi_n\n\\]\nLet\n\\[\nS_{ij}=\\br{\\chi_i}{\\chi_j}\n\\]\n\\[\n\\M{S}=\n\\begin{pmatrix}\n\\br{\\chi_1}{\\chi_1}&\\br{\\chi_1}{\\chi_2}&\\br{\\chi_1}{\\chi_3}\\\\\n\\br{\\chi_2}{\\chi_1}&\\br{\\chi_2}{\\chi_2}&\\br{\\chi_2}{\\chi_3}\\\\\n\\br{\\chi_3}{\\chi_1}&\\br{\\chi_3}{\\chi_2}&\\br{\\chi_3}{\\chi_3}\\\\\n\\end{pmatrix}\n\\]\n\\[\nD_1=\\br{\\chi_1}{\\chi_1}\n\\]\n\\[\nD_2=\n\\begin{vmatrix}\n\\br{\\chi_1}{\\chi_1}&\\br{\\chi_1}{\\chi_2}\\\\\n\\br{\\chi_2}{\\chi_1}&\\br{\\chi_2}{\\chi_2}\\\\\n\\end{vmatrix}\n\\]\n\\[\nD_3=\n\\begin{vmatrix}\n\\br{\\chi_1}{\\chi_1}&\\br{\\chi_1}{\\chi_2}&\\br{\\chi_1}{\\chi_3}\\\\\n\\br{\\chi_2}{\\chi_1}&\\br{\\chi_2}{\\chi_2}&\\br{\\chi_2}{\\chi_3}\\\\\n\\br{\\chi_3}{\\chi_1}&\\br{\\chi_3}{\\chi_2}&\\br{\\chi_3}{\\chi_3}\\\\\n\\end{vmatrix}\n\\]\nNote that $S_{ij}^*=\\br{\\chi_j}{\\chi_1}$, $D_n^*=D_n$. In this problem when $|A|^2=k$, let $A=\\sqrt{k}$, without the phase factor.\n\\medskip\n\nFrom Eq. 5.79 we have\n\\[\n\\M{T}^\\dagger\\M{S}\\M{T}=\\M{I}\n\\]\nnote that from the derivation, the equation will hold for any dimension, so\n\\[\nT_{11}^*\\br{\\chi_1}{\\chi_1}T_{11}=1\n\\]\n\\[\nT_{11}=\\frac{1}{\\sqrt{D_1}}\n\\]\n\\[\n\\begin{pmatrix}\nT_{11}^*&0\\\\\nT_{12}^*&T_{22}^*\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\n\\br{\\chi_1}{\\chi_1}&\\br{\\chi_1}{\\chi_2}\\\\\n\\br{\\chi_2}{\\chi_1}&\\br{\\chi_2}{\\chi_2}\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\nT_{11}&T_{12}\\\\\n0&T_{22}\\\\\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0\\\\\n0&1\\\\\n\\end{pmatrix}\n\\]\nTake the determinant of both sides:\n\\[\nT_{11}^*T_{22}^*D_2T_{11}T_{22}=1\n\\]\n\\[\n|T_{22}|^2=\\frac{1}{|T_{11}|^2D_2}=\\frac{D_1}{D_2},\\quad T_{22}=\\sqrt{\\frac{D_1}{D_2}}\n\\]\n\\[\n\\begin{pmatrix}\nT_{11}^*&0&0\\\\\nT_{12}^*&T_{22}^*&0\\\\\nT_{13}^*&T_{23}^*&T_{33}^*\n\\end{pmatrix}\n\\begin{pmatrix}\n\\br{\\chi_1}{\\chi_1}&\\br{\\chi_1}{\\chi_2}&\\br{\\chi_1}{\\chi_3}\\\\\n\\br{\\chi_2}{\\chi_1}&\\br{\\chi_2}{\\chi_2}&\\br{\\chi_2}{\\chi_3}\\\\\n\\br{\\chi_3}{\\chi_1}&\\br{\\chi_3}{\\chi_2}&\\br{\\chi_3}{\\chi_3}\\\\\n\\end{pmatrix}\n\\begin{pmatrix}\nT_{11}&T_{12}&T_{13}\\\\\n0&T_{22}&T_{23}\\\\\n0&0&T_{33}\n\\end{pmatrix}=\n\\begin{pmatrix}\n1&0&0\\\\\n0&1&0\\\\\n0&0&1\n\\end{pmatrix}\n\\]\n\\[\nT_{11}^*T_{22}^*T_{33}^*D_2T_{11}T_{22}T_{33}=1\n\\]\n\\[\n|T_{33}|^2=\\frac{1}{|T_{22}|^2|T_{11}|^2D_3}=\\frac{D_2}{D_3},\\quad T_{33}=\\sqrt{\\frac{D_2}{D_3}}\n\\]\n\n\\[\n\\psi_1=\\chi_1\n\\]\n\\[\n\\varphi_1=T_{11}\\chi_1=\\frac{\\chi_1}{\\sqrt{D_1}}\n\\]\n\\[\n\\psi_2=\\chi_2-\\psi_1\\frac{\\br{\\psi_1}{\\chi_2}}{\\br{\\psi_1}{\\psi_1}}=\\chi_2-\\chi_1\\frac{S_{12}}{S_{11}}\n\\]\n\\[\n\\varphi_2=T_{22}\\psi_2=\\sqrt{\\frac{D_1}{D_2}}(\\chi_1\\frac{-S_{12}}{S_{11}}+\\chi_2)=\\chi_1\\frac{-S_{12}}{\\sqrt{D_1D_2}}+\\chi_2\\sqrt{\\frac{D_1}{D_2}}\n\\]\n\\[\n\\psi_3=\\chi_3-\\psi_2\\frac{\\br{\\psi_2}{\\chi_3}}{\\br{\\psi_2}{\\psi_2}}-\\psi_1\\frac{\\br{\\psi_1}{\\chi_3}}{\\br{\\psi_1}{\\psi_1}}\n\\]\n\\[\n=\\chi_3-(\\chi_2-\\chi_1\\frac{S_{12}}{S_{11}})\\frac{S_{23}-S_{13}\\frac{S_{21}}{S_{11}}}{S_{22}-\\frac{S_{12}S_{21}}{S_{11}}}-\\chi_1\\frac{S_{13}}{S_{11}}\n\\]\n\\[\n=\\chi_3+\\chi_2\\frac{S_{13}S_{21}-S_{11}S_{23}}{S_{11}S_{22}-S_{12}S_{21}}+\\chi_1\\frac{S_{11}S_{12}S_{13}-S_{12}S_{21}S_{13}-S_{11}S_{22}S_{13}+S_{12}S_{21}S_{13}}{(S_{11}S_{22}-S_{12}S_{21})S_{11}}\n\\]\n\\[\n=\\chi_3+\\chi_2\\frac{S_{13}S_{21}-S_{11}S_{23}}{D_2}+\\chi_1\\frac{S_{11}S_{12}S_{13}-S_{12}S_{21}S_{13}-S_{11}S_{22}S_{13}+S_{12}S_{21}S_{13}}{D_2D_1}\n\\]\n\\[\n\\varphi_3=T_{33}\\psi_3=\\chi_3\\sqrt{\\frac{D_2}{D_3}}+\\chi_2\\frac{S_{13}S_{21}-S_{11}S_{23}}{\\sqrt{D_2D_3}}+\\chi_1\\frac{S_{11}S_{12}S_{13}-S_{12}S_{21}S_{13}-S_{11}S_{22}S_{13}+S_{12}S_{21}S_{13}}{D_1\\sqrt{D_2D_3}}\n\\]\nso\n\\[\\M{T}=\n\\begin{pmatrix}\nT_{11}&T_{12}&T_{13}\\\\\n0&T_{22}&T_{23}\\\\\n0&0&T_{33}\n\\end{pmatrix}\n\\]\n\\[\nT_{11}=\\frac{1}{\\sqrt{D_1}}\\]\n\\[T_{12}=\\frac{-S_{12}}{\\sqrt{D_1D_2}}\\] \\[T_{22}=\\sqrt{\\frac{D_1}{D_2}}\n\\]\n\\[\nT_{13}=\\frac{S_{11}S_{12}S_{13}-S_{12}S_{21}S_{13}-S_{11}S_{22}S_{13}+S_{12}S_{21}S_{13}}{D_1\\sqrt{D_2D_3}}\n\\]\n\\[\nT_{23}=\\frac{S_{13}S_{21}-S_{11}S_{23}}{\\sqrt{D_2D_3}}\n\\]\n\\[\nT_{33}=\\sqrt{\\frac{D_2}{D_3}}\n\\]\n\n\\section*{5.7 Invariants}\n\n\\paragraph{5.7.1}\nIn matrix representation,\n\\[\n\\M{X}\\M{P}-\\M{P}\\M{X}=i\\M{I}\n\\]\n\\[\n\\M{U}\\M{X}\\M{P}\\M{U}^{-1}-\\M{U}\\M{P}\\M{X}\\M{U}^{-1}=i\\M{U}\\M{I}\\M{U}^{-1}=i\\M{I}\n\\]\n\\[\n\\M{U}\\M{X}\\M{U}^{-1}\\M{U}\\M{P}\\M{U}^{-1}-\\M{U}\\M{P}\\M{U}^{-1}\\M{U}\\M{X}\\M{U}^{-1}=i\\M{I}\n\\]\n\\[\n\\M{X}'\\M{P}'-\\M{P}'\\M{X}'=i\\M{I}\n\\]\nso $[x,p]=i$ is invariant under unitary transformation.\n\n\\paragraph{5.7.2}\n\\[\n\\boldsymbol{\\sigma}_1'=\n\\begin{pmatrix}\n\\cos\\theta&\\sin\\theta\\\\\n-\\sin\\theta&\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\n0&1\\\\\n1&0\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\theta&-\\sin\\theta\\\\\n\\sin\\theta&\\cos\\theta\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\sin2\\theta&\\cos2\\theta\\\\\n\\cos2\\theta&-\\sin2\\theta\n\\end{pmatrix}\n\\]\n\\[\n\\boldsymbol{\\sigma}_2'=\n\\begin{pmatrix}\n\\cos\\theta&\\sin\\theta\\\\\n-\\sin\\theta&\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\n0&-i\\\\\ni&0\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\theta&-\\sin\\theta\\\\\n\\sin\\theta&\\cos\\theta\n\\end{pmatrix}=\n\\begin{pmatrix}\n0&-i\\\\\ni&0\n\\end{pmatrix}\n\\]\n\\[\n\\boldsymbol{\\sigma}_3'=\n\\begin{pmatrix}\n\\cos\\theta&\\sin\\theta\\\\\n-\\sin\\theta&\\cos\\theta\n\\end{pmatrix}\n\\begin{pmatrix}\n1&0\\\\\n0&-1\n\\end{pmatrix}\n\\begin{pmatrix}\n\\cos\\theta&-\\sin\\theta\\\\\n\\sin\\theta&\\cos\\theta\n\\end{pmatrix}=\n\\begin{pmatrix}\n\\cos2\\theta&-\\sin2\\theta\\\\\n-\\sin2\\theta&-\\cos2\\theta\n\\end{pmatrix}\n\\]\n\\[\n\\boldsymbol{\\sigma}_1'\\boldsymbol{\\sigma}_2'-\\boldsymbol{\\sigma}_2'\\boldsymbol{\\sigma}_1'=\n\\begin{pmatrix}\ni\\cos2\\theta&-i\\sin2\\theta\\\\\n-i\\sin2\\theta&-i\\cos2\\theta\n\\end{pmatrix}-\n\\begin{pmatrix}\n-i\\cos2\\theta&i\\sin2\\theta\\\\\ni\\sin2\\theta&i\\cos2\\theta\n\\end{pmatrix}\n=\\begin{pmatrix}\n2i\\cos2\\theta&-2i\\sin2\\theta\\\\\n-2i\\sin2\\theta&-2i\\cos2\\theta\n\\end{pmatrix}=2i\\boldsymbol{\\sigma}_3'\n\\]\nso $[\\boldsymbol{\\sigma}_1',\\boldsymbol{\\sigma}_2']=2i\\boldsymbol{\\sigma}_3'$ is still valid under transformation.\n\n\\paragraph{5.7.3}\n(a) From Exercise 5.6.2(a), \n\\[\nL_x\\varphi_1=0\n\\]\n\\[\nL_x\\varphi_2=-iC(-ze^{-r^2})=i\\varphi_3\n\\]\n\\[\nL_x\\varphi_3=-iC(ye^{-r^2})=-i\\varphi_2\n\\]\nso in matrix form,\n\\[\nL_x=\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\n\\]\n\n(b) \n\\[\nL_x\\left[(x+iy)e^{-r^2} \\right]=L_x\\frac{\\varphi_1+i\\varphi_2}{C}=\\frac{i(i\\varphi_3)}{C}=-\\frac{\\varphi_3}{C}=-ze^{-r^2}\n\\]\n\n(c) \nIn matrix form, the above equation becomes\n\\[\n\\begin{pmatrix}\n0\\\\0\\\\-1\n\\end{pmatrix}=\n\\begin{pmatrix}\n0&0&0\\\\\n0&0&-i\\\\\n0&i&0\n\\end{pmatrix}\n\\begin{pmatrix}\n1\\\\i\\\\0\n\\end{pmatrix}\n\\]\nafter transformation,\n\\[\n\\begin{pmatrix}\n0\\\\\\frac{i}{\\sqrt{2}}\\\\\\frac{-i}{\\sqrt{2}}\n\\end{pmatrix}=\n\\begin{pmatrix}\n0&0&0\\\\\n0&1&0\\\\\n0&0&-1\n\\end{pmatrix}\n\\begin{pmatrix}\n1\\\\\\frac{i}{\\sqrt{2}}\\\\\\frac{i}{\\sqrt{2}}\n\\end{pmatrix}\n\\]\nwhere the transformed $L_x$ has been obtained in Exercise 5.6.2(b).\n\n(d) From Exercise 5.6.2(c), \n\\[\n\\varphi_1'=Cxe^{-r^2}\\quad\\varphi_2'=C\\frac{y+iz}{\\sqrt{2}}e^{-r^2}\\quad\\varphi_3'=C\\frac{y-iz}{\\sqrt{2}}e^{-r^2}\n\\]\n\n(e) \n\\[\n\\varphi_2'\\frac{i}{\\sqrt{2}}+\\varphi_3'\\frac{-i}{\\sqrt{2}}=-Cze^{-r^2}\n\\]\n\\[\n\\varphi_1'+\\varphi_2'\\frac{i}{\\sqrt{2}}+\\varphi_3'\\frac{i}{\\sqrt{2}}=C(x+iy)e^{-r^2}\n\\]\n\\[\nL_x\\varphi_1'=L_x(Cxe^{-r^2})=0\n\\]\n\\[L_x\\varphi_2'=L_x(C\\frac{y+iz}{\\sqrt{2}}e^{-r^2})=C\\frac{y+iz}{\\sqrt{2}}e^{-r^2}=\\varphi_2'\n\\] \n\\[\nL_x\\varphi_3'=L_x(C\\frac{y-iz}{\\sqrt{2}}e^{-r^2})\n=-C\\frac{y-iz}{\\sqrt{2}}e^{-r^2}=-\\varphi_3'\n\\]\nso the vectors and operators transform correctly by $\\M{U}$.\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "44e8b86943d510f82f32875c31ed8d51d4431d0b", "size": 43759, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Mathematical Methods for Physicists/Chapter 05/main.tex", "max_stars_repo_name": "hikarimusic2002/Solutions", "max_stars_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Mathematical Methods for Physicists/Chapter 05/main.tex", "max_issues_repo_name": "hikarimusic2002/Solutions", "max_issues_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mathematical Methods for Physicists/Chapter 05/main.tex", "max_forks_repo_name": "hikarimusic2002/Solutions", "max_forks_repo_head_hexsha": "3f48f7e1e97cc78c01142936a267255f7164f6a4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1922855498, "max_line_length": 440, "alphanum_fraction": 0.5965629928, "num_tokens": 22970, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4064539087606609}}
{"text": "\\chapter{Topos} \\label{topos}\nIn this section we will examine the categorical interpretation of finite sets.\nIn particular, we will prove that decidable Kuratowski finite types form a\n\\(\\Pi\\)-pretopos.\nA lot of the work for this proof has been done already: in\nTheorem~\\ref{cardinal-kuratowski} we saw that discrete Kuratowski finite types\nwere equivalent to Cardinally finite types.\nWe will use the latter definition implementation-wise from now on, as it is\nslightly easier to work with: CuTT's transport means we can do this without loss\nof generality.\n\nThere are two reasons we're interested in the categorical and topos-theoretic\ninterpretation of finite sets: first, it's an important theoretical grounding\nfor finite sets, which allows us to understand them in the context of other\nset-like constructions.\nSecondly, and more practically, the language of a topos is (or in our case the\n\\(\\Pi\\)-pretopos) is a common standard framework for doing mathematics\ngenerally.\nThis makes it a good basis for an API for building QuickCheck-like generators,\nfor example.\n\\section{Categories in HoTT}\nAt first glance, HoTT seems like a perfect setting for category theory: the\nunivalence axiom identifies isomorphisms with equality, a useful tool for\ncategory theory missing from MLTT.\nWhile this initial impression is broadly true, the construction of categories in\nHoTT is unfortunately quite complex and involved (much of the following is a\nsummary of \\citet[chapter 9]{hottbook}).\n\n\\todo{references here are tricky, need to disentangle the contributions quite\n  precisely}\nMuch of this section is simply a summary of parts of \\citet[chapter\n9]{hottbook}.\nThe formal proofs we provide are part translation of those proofs in that\nchapter, part from \\cite{iversenFredefoxCat2018}\n\\cite{huProofrelevantCategoryTheory2020}, and part our own.\n\nFirst, we need to think about the type of objects and arrows.\nWe cannot, unfortunately, leave them unrestricted: because of the potential for\nhigher homotopy in HoTT types \\todo{This sentence is a tongue twister}, we have\nto restrict the type of arrows to just the sets.\nThis notion: that of a category with all the usual laws such that arrows are a\nset, is called a \\emph{precategory}.\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Categories.tex]{precategory}\n\\end{agdalisting}\nWe will use long arrows to refer to morphisms within a category:\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Categories.tex]{morph-arrow}\n\\end{agdalisting}\n\nFrom here, we can define a notion of isomorphisms.\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Categories.tex]{isomorphism}\n\\end{agdalisting}\nIt's a condition on this type which separates the precategories from the\ncategories: if it satisfies a form of univalence, it the precategory is a full\ncategory.\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Categories.tex]{cat-univalence}\n\\end{agdalisting}\n\\section{The Category of Sets}\nNext we'll look at how to construct the category of sets (in the HoTT sense).\nMuch of this work comes directly from \\citet[chapter 10]{hottbook} and\n\\citet{rijkeSetsHomotopyType2015}.\nThe formalisation, however, is novel, as far as we know.\n\nThe objects are represented by a \\(\\Sigma\\):\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Snippets/Category.tex]{hset}\n\\end{agdalisting}\nThis will be quite similar to our objects for finite sets.\n\nSince sets in HoTT don't form a topos, there are quite a few smaller lemmas we\nneed to prove to get as close as we can (a \\(\\Pi W\\)-pretopos): we won't include\nthem here, other than the closure proofs in the following section.\n\\section{Closure}\nThe two most involved proofs for showing that discrete Kuratowski sets form a\n\\(\\Pi\\)-pretopos are those proofs that show closure under \\(\\Pi\\) and\n\\(\\Sigma\\).\nWe will describe them here.\n\\subsection{Closure of the Ordered Predicates}\nFirst, we will show that split enumerability (and, by extension, manifest\nenumerability) are closed under \\(\\Pi\\) and \\(\\Sigma\\).\nThis is the first stepping stone on our way to prove that cardinal finiteness is\nclosed under the same.\n\nPractically speaking, these proofs also open up a wide number of other closure\nproofs to us.\nBy proving that dependent products and sums are finite, we get the non-dependent\ncases for free.\n\n\\begin{lemma} \\label{split-enum-sigma} \\todo{Convert to Agda}\n  Split enumerability is closed under \\(\\Sigma\\).\n  \\begin{agdalisting}\n    \\ExecuteMetaData[agda/Cardinality/Finite/SplitEnumerable.tex]{split-enum-sigma}\n  \\end{agdalisting}\n\\end{lemma}\n\\begin{proof}\n  Our task is to construct the two components of the output pair: the support\n  list, and the cover proof.\n  We'll start with the support list: this is constructed by taking the Cartesian\n  product of the input support lists.\n  \\begin{agdalisting}\n    \\ExecuteMetaData[agda/Cardinality/Finite/SplitEnumerable.tex]{sup-sigma}\n  \\end{agdalisting}\n  We use do notation here because we're working the list monad: this applies the\n  latter function (\\(ys\\)) to every element of the list \\(xs\\), and concatenates\n  the results.\n\n  To show that this does indeed cover every element of the target type is a\n  little intricate, but not necessarily difficult. \\todo{Should a proof of this\n    be included?}\n\\end{proof}\n\nNext we'll look at closure under \\(\\Pi\\).\nIn MLTT, this is of course not provable: since all of the finiteness predicates\nwe have seen so far imply decidable equality, and since we don't have any kind\nof decidable equality on functions in MLTT, we know that we won't be able to\nshow that any kind of function is finite; even one like \\(\\AgdaDatatype{Bool}\n\\rightarrow \\AgdaDatatype{Bool}\\).\n\nCuTT is not so restricted.\nSince we have things like function extensionality and transport, we can indeed\nprove the finiteness of function types.\nOur proof here makes use directly of the univalence axiom, and makes use\nfurthermore of all the previous closure proofs.\n\\begin{theorem} \\label{split-enum-pi}\n  Split enumerability is closed under dependent functions\n  (\\(\\Pi\\)-types).\n  \\begin{agdalisting}\n    \\ExecuteMetaData[agda/Cardinality/Finite/ManifestBishop.tex]{pi-clos}\n  \\end{agdalisting}\n\\end{theorem}\n\\begin{proof}\n  Let \\(A\\) be a split enumerable type, and \\(U\\) be a type family from \\(A\\),\n  which is split enumerable over all points of \\(A\\).\n\n  As \\(A\\) is split enumerable, we know that it is also manifestly Bishop finite\n  (lemma~\\ref{split-enum-to-manifest-bishop}), and consequently we know \\(A\n  \\simeq \\AgdaDatatype{Fin}\\;n\\), for some \\(n\\) (lemma~\\ref{bishop-equiv}).\n  We can therefore replace all occurrences of \\(A\\) with \\(\\AgdaDatatype{Fin}\\;n\\),\n  changing our goal to:\n  \\begin{equation}\n    \\frac{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;(\\AgdaDatatype{Fin}\\;n) \\; \\; \\; \\left((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;\\left( U\\;x \\right)\\right)\n    }{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\left((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow U\\;x\\right)\n    }\n  \\end{equation}\n  \n  We then define the type of \\(n\\)-tuples over some type family.\n  \\begin{agdalisting}\n    \\ExecuteMetaData[agda/Data/Tuple/UniverseMonomorphic.tex]{tuple-def}\n  \\end{agdalisting}\n  We can show that this type is equivalent to functions (proven in our formalisation):\n  \\begin{agdalisting}\n    \\ExecuteMetaData[agda/Data/Tuple/UniverseMonomorphic.tex]{tuple-iso}\n  \\end{agdalisting}\n  And therefore we can simplify again our goal to the following:\n  \\begin{equation}\n    \\frac{\n      \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\;(\\AgdaDatatype{Fin}\\;n) \\; \\; \\; ((x : \\AgdaDatatype{Fin}\\;n) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\left( U\\;x \\right))\n    }{\n      \\AgdaFunction{\\ensuremath{\\mathcal{E}!}}\\;\\left(\\AgdaFunction{Tuple}\\;n\\;U\\right)\n    }\n  \\end{equation}\n  \n  We can prove this goal by showing that \\(\\AgdaFunction{Tuple}\\;n\\;U\\) is split\n  enumerable: it is made up of finitely many products of points of \\(U\\), which\n  are themselves split enumerable, and \\agdatop, which is also split enumerable.\n  Lemma~\\ref{split-enum-sigma} shows us that the product of finitely many split\n  enumerable types is itself split enumerable, proving our goal.\n\\end{proof}\n\\subsection{Closure on Cardinal Finiteness}\nSince we don't have a function of type \\(\\mathcal{C}(A) \\rightarrow\n\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A\\), closure proofs on \\(\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\) do not transfer over to\n\\(\\mathcal{C}\\) trivially (unlike with \\(\\AgdaDatatype{\\ensuremath{\\mathcal{E}!}}\\) and \\(\\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\)).\nThe cases for \\(\\bot\\), \\(\\top\\), and \\(\\AgdaDatatype{Bool}\\) are simple to adapt: we\ncan just propositionally truncate their Bishop finiteness proof.\n\nNon-dependent operators like \\(\\times\\), \\(\\uplus\\), and \\(\\rightarrow\\) are\nalso relatively straightforward: since \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_\\rVert}}\\) forms a monad, we\ncan apply \\(n\\)-ary functions to values inside it, combining them together.\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Cardinality/Finite/ManifestBishop.tex]{times-clos-sig}\n\\end{agdalisting}\nInto a truncated context:\n\\begin{agdalisting}\n  \\ExecuteMetaData[agda/Cardinality/Finite/Cardinal.tex]{times-clos-impl}\n\\end{agdalisting}\n\n\nUnfortunately, for the dependent type formers like \\(\\Sigma\\) and \\(\\Pi\\), the\nsame trick does not work.\nWe have closure proofs like:\n\\begin{equation}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\; \\; \\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x))\n  }{\n    \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x)\n  }\n\\end{equation}\nIf we apply the monadic truncation trick we can derive closure proofs like the\nfollowing:\n\\begin{equation}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\; \\; \\; \\AgdaDatatype{\\ensuremath{\\lVert}}\\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x)) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }\n\\end{equation}\nHowever our \\emph{desired} closure proof is the following:\n\\begin{equation}\n  \\frac{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;A \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\; \\; \\; ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}})\n  }{\n    \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;((x : A) \\rightarrow U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  }\n\\end{equation}\nThey don't match!\n\nThe solution would be to find a function of the following type:\n\\begin{equation}\n  ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}) \\rightarrow\n  \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\mathcal{B}}}\\;(U\\;x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n\\end{equation}\nHowever we might be disheartened at realising that this is a required goal: the\nabove equation is \\emph{extremely} similar to the axiom of choice!\n\\begin{definition}[Axiom of Choice]\n  In HoTT, the axiom of choice is commonly defined as follows \\cite[lemma\n  3.8.2]{hottbook}.\n  For any set \\(A\\), and a type family \\(U\\) which is a set at all the points\n  of \\(A\\), the following function exists:\n  \\begin{equation}\n    \\left( (x : A) \\rightarrow  \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}} \\right) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation}\n\\end{definition}\nLuckily the axiom of choice \\emph{does} hold for cardinally finite types,\nallowing us to prove the following:\n\\begin{lemma}\n  \\begin{equation}\n    \\agdacal{C}\\;A \\rightarrow ((x : A) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; (x : A) \\rightarrow U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation}\n\\end{lemma}\n\\begin{proof}\n  Let \\(A\\) be a cardinally finite type, \\(U\\) be a type family on \\(A\\), and\n  \\(f\\) be a dependent function of type \\(\\Pi(x : A) , \\AgdaDatatype{\\ensuremath{\\lVert}}\\; U(x) \\;\\AgdaDatatype{\\ensuremath{\\rVert}}\\).\n\n  First, since our goal is itself propositionally truncated, we have access to\n  values under truncations: put another way, in the context of proving our goal,\n  we can rely on the fact that \\(A\\) is manifestly Bishop finite.\n  Using the same technique as we did in lemma~\\ref{split-enum-pi}, we can switch\n  from working with dependent functions from \\(A\\) to \\(n\\)-tuples, where \\(n\\)\n  is the cardinality of \\(A\\).\n  This changes our goal to the following:\n  \\begin{equation}\n    \\AgdaFunction{Tuple}\\;n\\;(\\AgdaDatatype{\\ensuremath{\\lVert\\_\\rVert}}\\;\\AgdaFunction{\\ensuremath{\\circ}}\\; U) \\rightarrow \\AgdaDatatype{\\ensuremath{\\lVert}}\\; \\AgdaFunction{Tuple}\\;n\\;U\\;\\AgdaDatatype{\\ensuremath{\\rVert}}\n  \\end{equation}\n  Since \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_ \\rVert}}\\) is closed under finite products, this function\n  exists (in fact, using the fact that \\(\\AgdaDatatype{\\ensuremath{\\lVert\\_ \\rVert}}\\) forms a monad, we\n  can recognise this function as \\verb+sequenceA+ from the \\verb+Traversable+\n  class in Haskell).\n\\end{proof}\n\n\nThis gets us all of the necessary closure proofs on \\(\\mathcal{C}\\).\n\\section{The Absence of the Subobject Classifier}\n\\begin{agdalisting} \\label{filter-subobject}\n  \\ExecuteMetaData[agda/Cardinality/Finite/SplitEnumerable.tex]{subobject}\n\\end{agdalisting}\n\n\n\\section{Closure}\nFor the first three closure proofs, we only consider split enumerability:\nas it is the strongest of the finiteness predicates, we can derive the other\nclosure proofs from it.\n\n\\section{The Category of Finite Sets}\nHoTT and CuTT seem to be especially suitable settings for formalisations of\ncategory theory.\nThe univalence axiom in particular allows us to treat categorical isomorphisms\nas equalities, saving us from the dreaded ``setoid hell''.\n\nWe follow \\cite[chapter 9]{hottbook} in its treatment of\ncategories in HoTT, and in its proof that sets do indeed form a category.\nWe will first briefly go through the construction of the category\n\\(\\mathit{Set}\\), as it differs slightly from the usual method in type theory.\n\nFirst, the type of objects and arrows:\n\\begin{alignat}{3}\n  &\\text{Obj}_\\mathit{Set}      &&\\coloneqq \\Sigma(x : \\mathbf{Type}) , \\text{isSet}(x) \\\\\n  &\\text{Hom}_\\mathit{Set}(x , y) &&\\coloneqq  \\text{fst}(x) \\rightarrow \\text{fst}(y)\n\\end{alignat}\nAs the type of objects makes clear, we have already departed slightly from the\nsimpler \\(\\text{Obj}_\\mathit{Set} \\coloneqq \\mathbf{Type}\\) way of doing things:\nof course we have to, as HoTT allows non-set types.\nFurthermore, after proving the usual associativity and identity laws for\ncomposition (which are definitionally true in this case), we must further show\n\\(\\text{isSet}(\\text{Hom}_\\mathit{Set}(x,y))\\); even then we only have a\nprecategory.\n\nTo show that \\(\\mathit{Set}\\) is a category, we must show that categorical\nisomorphisms are equivalent to equivalences.\nIn a sense, we must give a univalence rule for the category we are working in.\n\nWe have provided formal proofs that \\(\\mathit{Set}\\) does indeed form a\ncategory, and the following:\n\\begin{theorem}[The Category of Finite Sets]\n  Finite sets form a category in HoTT when defined like so:\n  \\begin{equation}\n    \\begin{alignedat}{3}\n      &\\text{Obj}_\\mathit{FinSet}      &&\\coloneqq \\Sigma(x : \\mathbf{Type}) , \\mathcal{C}(x) \\\\\n      &\\text{Hom}_\\mathit{FinSet}(x , y) &&\\coloneqq  \\text{fst}(x) \\rightarrow \\text{fst}(y)\n    \\end{alignedat}\n  \\end{equation}\n\\end{theorem}\n\\section{The \\(\\Pi\\)-pretopos of Finite Sets}\nFor this proof, we follow again the proof that \\(\\mathit{Set}\\) forms a \\(\\Pi\nW\\)-pretopos from \\cite[chapter 10]{hottbook} and\n\\cite{rijkeSetsHomotopyType2015}.\nThe difference here is that clearly we do not have access to \\(W\\)-types, as\nthey would permit infinitary structures.\n\nWe first must show that \\(\\mathit{Set}\\) has an initial object and finite,\ndisjoint sums, which are stable under pullback.\nWe also must show that \\(\\mathit{Set}\\) is a regular category with effective\nquotients.\nWe now have a pretopos: the presence of \\(\\Pi\\) types make it a\n\\(\\Pi\\)-pretopos.\n\nWe have proven the above statements for both \\(\\mathit{Set}\\) and\n\\(\\mathit{FinSet}\\).\nAs far as we know, this is the first formalisation of either.\n\\begin{theorem} \\label{finite-topos}\n  The category of finite sets, \\(\\mathit{FinSet}\\), forms a \\(\\Pi\\)-pretopos.\n\\end{theorem}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"../paper\"\n%%% End:", "meta": {"hexsha": "955f5a2a79077e9a09a6657c23e58413480fb366", "size": 16822, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/topos.tex", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/topos.tex", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sections/topos.tex", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.1871345029, "max_line_length": 273, "alphanum_fraction": 0.7374271787, "num_tokens": 4917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4064539072775825}}
{"text": "\\ifpdf\n    \\graphicspath{{Chapter3/Figs/Vector/}{Chapter3/Figs/PDF/}{Chapter3/Figs/}}\n\\else\n    \\graphicspath{{Chapter3/Figs/Raster/}{Chapter3/Figs/}}\n\\fi\n\n\n\\chapter{Linear-Time Gaussian Processes on Hyperspheres}\n\\label{chapter:vish}\n\nStationary kernels, i.e. translation invariant covariances, are ubiquitous in machine learning when the input space is Euclidean. When working on the hypersphere, their spherical counterpart are dot-product kernels, which are invariant to rotations. They are the main object studied in this chapter. In \\cref{sec:rkhs-dotproduct-kernels}, we first show how we can construct the Reproducing Kernel Hilbert Space (RKHS) of dot-product kernel on the hypersphere. \\Cref{sec:vish} uses the RKHS to construct an efficient variational interdomain inducing variable for Gaussian processes on the hypersphere. We will then show how to expand the GP onto the complete domain $\\Reals^d$ and conclude with a series of experiments, showing the speed and accuracy of the proposed approach.\n\n\\section{Mercer Representation of Dot-Product Kernels}\n\\label{sec:rkhs-dotproduct-kernels}\n\nConsider the unit sphere in $\\Reals^d$  as the input domain\n\\begin{equation}\n    \\mathcal{X} = \\dsphere = \\{x \\in \\Reals^d: \\norm{x}_2 = 1\\}\n\\end{equation}\nand $\\nu$ to be the Lebesgue measure on $\\dsphere$, so that\n\\begin{equation}\n    \\darea = \\int_{\\dsphere} \\calcd{\\nu(x)} = \\frac{2 \\pi ^ {d/2}}{\\Gamma(d/2)}.\n\\end{equation}\nis the surface area of $\\dsphere$. We adopt the usual $L_2$ inner product for functions $f: \\dsphere \\rightarrow \\Reals$ and $g: \\dsphere \\rightarrow \\Reals$ restricted to the sphere \n\\begin{equation}\n     \\langle f, g\\rangle_{L_{2}(\\dsphere)} = \\frac{1}{\\darea} \\int_{\\dsphere} f(x)\\,g(x) \\, \\calcd{\\nu(x)}.\n\\end{equation}\n\nWe define a dot-product kernel, also known as a zonal kernel (we will use both terms interchangeably), as a p.d. kernel of the form\n\\begin{equation}\n    k(x, x') = \\kappa(x\\transpose x'),\n\\end{equation}\nwhere $\\kappa: [-1, 1] \\rightarrow \\Reals$ is a continuous function and referred to as the \\emph{shape function}. In other words, dot-product kernels only depend on the distance on the great circle between two inputs, rather than their location. They are the counterpart of stationary kernels $k(x, x') = \\kappa(x - x')$, who are functions of the difference only. For instance, where stationary kernels are translation invariant, dot-product kernel are rotationally invariant.\n\nWe can associate a kernel operator $\\mathcal{K}$ to a zonal kernel, as explained in \\cref{section:theory:spectral-formulation}, which exhibits the form\n\\begin{equation}\n    \\label{eq:kernel-operator-zonal}\n  \\mathcal{K} f = \\int_{\\dsphere} \\kappa(x\\transpose\\cdot) f(x) \\calcd{\\nu(x)}.\n\\end{equation}\nTo construct a Mercer representation of a zonal kernel's RKHS we require the eigensystem of the kernel operator $\\mathcal{K}$, or, equivalently, the set of eigenfunctions $\\{\\phi_n\\}$ and associated eigenvalues $\\{\\lambda_n\\}$ for which\n\\begin{equation}\n    \\mathcal{K} \\phi_n = \\lambda_n \\phi_n\\qquad\\text{and}\\qquad \\langle \\phi_n, \\phi_m \\rangle_{L_2(\\dsphere)} = \\delta_{nm}.\n\\end{equation}\n\nTo obtain the eigensystem of $\\mathcal{K}$, we will show that $\\mathcal{K}$ commutes with the Laplace-Beltrami operator $\\LaplaceBeltrami$, henceforth referred to as simply the Laplacian or the Laplace operator. We want to remind the reader that commuting operators share the same eigenfunctions, but not necessarily the same eigenvalues. Therefore, to find the eigenfunctions of the kernel operator $\\mathcal{K}$, it suffice to find the eigenfunctions of the Laplacian. Fortunately, the diagonalisation of the Laplace operator on $\\dsphere$ is a well-studied problem. In the following paragraph we first proof the commutativity of the operators before covering the definition of the RKHS.\n\n\\paragraph{Commutativity of $\\mathcal{K}$ and $\\LaplaceBeltrami$.}\nWe now proof that the Laplacian and the kernel operator of zonal kernels commute. For this, we first show that for zonal kernels and $x,s \\in \\dsphere$ the following property holds\n\\begin{align}\n    \\LaplaceBeltrami_x k(x, x') \n     &= \\nabla_x \\cdot \\nabla_x \\kappa(x\\transpose x') && \\text{Definition $\\LaplaceBeltrami$ and zonal kernels}\\\\\n     &= \\nabla_x \\cdot (x' \\kappa'(x\\transpose x'))  && \\text{Chainrule} \\\\\n     &= \\norm{x'}^2 \\kappa''(x\\transpose x') = \\kappa''(x \\transpose x') && \\text{Because } \\norm{x'} = 1.\n\\end{align}\nSimilarly, for $\\LaplaceBeltrami_s k(x, x')$ we obtain $k''(x \\transpose x')$, and as a result\n\\begin{equation}\n    \\label{eq:LaplaceBeltrami-x-s}\n\\LaplaceBeltrami_x k(x, x') = \\LaplaceBeltrami_{x'} k(x, x').\n\\end{equation}\nRelying on integration by parts and the previous result, we obtain\n\\begin{align}\n    \\mathcal{K} \\left[\\LaplaceBeltrami f\\right] &= \\int_{\\dsphere} k(x, x') \\left[\\LaplaceBeltrami_x f(x)\\right] \\calcd{\\nu(x)} && \\text{Definition $\\mathcal{K}$, \\cref{eq:kernel-operator-zonal}}\\\\\n    &= \\int_{\\dsphere} f(x) \\LaplaceBeltrami_x k(x, x')  \\calcd{\\nu(x)} && 2\\,\\times\\,\\text{Integration by parts}\\\\\n    &= \\int_{\\dsphere} f(x) \\LaplaceBeltrami_{x'} k(x, x')  \\calcd{\\nu(x)}  && \\text{\\cref{eq:LaplaceBeltrami-x-s}} \\\\\n    &= \\LaplaceBeltrami \\left[ \\mathcal{K} f \\right]\n\\end{align}\nwhich shows that the two operators commute and in turn implies that they share the same eigenfunctions. This result is of particular relevance to us since there is a huge body of literature on diagonalisation of the Laplace-Beltrami operator on $\\dsphere$, and that it is well known that its eigenfunctions are given by the spherical harmonics. The spherical harmonics $\\phi_{n,j}$ form an orthonormal basis for the square-integrable functions on the hypersphere. They are indexed with a level $n$ and an index within each level $j \\in \\{1, \\dots, \\dnumharmonicsforlevel\\}$. See \\cref{appendix:spherical-harmonics} for a comprehensive introduction to spherical harmonics, as well as a practical algorithm to compute them for relatively large $d$. \\Cref{fig:harmonics} shows the first 4 levels of spherical harmonics in $\\Reals^3$.\n\nThe above reasoning about the commutativity of the Laplace-Beltrami and kernel operator and the diagonalisation of the Laplace-Beltrami operator by the spherical harmonics, can be summarised by the following theorem:\n\\begin{theorem}[Mercer decomposition]\n    \\label{theorem:mercer-zonal}\nAny zonal kernel $k(x, x') = \\kappa(x\\transpose x')$ on the hypersphere can be decomposed as\n\\begin{equation}\n\\label{eq:kernel-form}\n    k(x, x') = \\sum_{n=0}^{\\infty} \\sum_{j=1}^{\\dnumharmonicsforlevel} \\lambda_{n} \\phi_{n,j}(x) \\phi_{n,j}(x'),\n\\end{equation}\nwhere $x,x' \\in \\dsphere$ and $\\lambda_{n}$ are positive coefficients, $\\phi_{n,j}$ denote the elements of the spherical harmonic basis in $\\dsphere$, and $\\dnumharmonicsforlevel$ corresponds to the number of spherical harmonics for a given level $n$. As a result of the Funk-Hecke theorem, the associated eigenvalues only depending on the level $n$\n\\begin{equation}\n    \\label{eq:compute-eigenvalues}\n        \\lambda_{n} = \\frac{\\omega_{d}}{C_n^{(\\alpha)}(1)} \\int_{-1}^1 \\kappa(t)\\,C_n^{(\\alpha)}(t)\\,(1 - t^2)^{\\frac{d-3}{2}} \\calcd{t},\n\\end{equation} \nwhere $C_n^{(\\alpha)}$ is the Gegenbauer polynomial of degree $n$, $\\alpha = \\frac{d-2}{2}$, $\\omega_d$ is a constant that depends on the surface area of the hypersphere. Analytic expressions are given in \\cref{appendix:spherical-harmonics}.\n\\end{theorem}\nAlthough it is typically stated without a proof, this theorem is already known in some communities (see \\citet{wendland2005} for a functional analysis exposition, or \\citet{peacock1999cosmological} for its use in cosmology). Given the Mercer decomposition, we can equivalently, define the associated RKHS as\n\\begin{equation}\n    \\label{eq:rkhs-sphere}\n    \\rkhs = \\left\\{\n    f = \n    \\sum_{n=0}^\\infty \\sum_{j=1}^{\\dnumharmonicsforlevel} {f}_{n,j} \\sh_{n, j}:\n    \\norm{f}_{\\rkhs} < \\infty\n    \\right\\},\n    \\quad\\text{where}\\quad\n    \\langle g, h \\rangle_{\\rkhs} = \n    \\sum_{n,j}\n            \\frac{{g}_{n, j} {h}_{n, j}}{\\lambda_{n}}\n\\end{equation}\nis the \\emph{reproducing} inner product between two functions $g,h \\in \\rkhs$. The reproducing property of the RKHS implies that for $f \\in \\rkhs$: $f(x) = \\langle f, k(x, \\cdot) \\rangle_\\rkhs$, which will enable the construction of spherical harmonic inducing features of discussing in the following section.\n\n%%%%%%%%%%%%%%%%%%%%%%\n\\section{Variational Spherical Harmonic Gaussian Processes}\n\\label{sec:vish}\n\nWe can now build on the results from the previous section, combined with interdomain inducing variables (see \\cref{section:interdomain-inducing-variables}), to propose a novel sparse variational GP model. Specifically, we are using interdomain inducing variables that are defined through the zonal kernel's RKHS inner product. As a result we will obtain expressive features $\\kux$ that exhibit non-local influence, and efficient inducing variables that induce diagonal structure in $\\Kuu$. We achieve this by defining the inducing variables $u_m$ to be the inner product between the GP and spherical harmonics:\\footnote{Note that in the context of inducing variables, we switch to a single integer $m$ to index the spherical harmonics and order them first by increasing level $n$, and then by increasing $j$ within a level.}\n\\begin{equation}\n  u_m = \\langle f, \\sh_m\\rangle_{\\rkhs}\\quad\\text{for}\\quad m \\in \\{1, \\ldots, M\\}.\n\\end{equation}\nTo leverage these new inducing variables we need to compute two quantities: 1) the covariance between $u_m$ and $f$ for $\\kux$, and 2) the covariance between the inducing variables themselves for the $\\Kuu$ matrix. Firstly, we compute the covariance of the inducing variables and the GP\n\\begin{align}\n   \\left[\\kux \\right]_m \n    &= \\ExpSymb[f(\\cdot)\\,u_m] && \\text{Definition covariance} \\\\\n    &= \\ExpSymb[f(\\cdot)\\,\\langle f, \\sh_m\\rangle_{\\rkhs}] && \\text{Definition $u_m$} \\\\\n    &= \\langle k(\\cdot, \\cdot), \\sh_m \\rangle_{\\rkhs}   && {k(\\cdot, \\cdot) = \\ExpSymb[f(\\cdot) f]} \\\\\n    &= \\phi_{m}(\\cdot) && \\text{Reproducing property.}\n\\end{align}\nwhere we relied on the linearity of the expectation and the inner product and the reproducing property of $\\rkhs$. Interestingly, using this construction we obtain the RKHS basis functions $\\{\\phi_m\\}$ as the features for the sparse approximation. Secondly, the covariance between the inducing variables is given by\n\\begin{equation}\n    \\left[\\Kuu \\right]_{m, m'} = \\ExpSymb \\left[u_m\\,u_{m'} \\right] \n    % = \\ExpSymb \\left[ \\langle f, Y_{m} \\rangle  \\langle f, Y_{m'} \\rangle  \\right] \n    = \\langle \\sh_{m}, \\sh_{m'} \\rangle_{\\rkhs} \n    = {\\delta_{mm'} \\over \\lambda_m},\n\\end{equation}\nwhere $\\delta_{mm'}$ is the Kronecker delta. Crucially, this means that $\\Kuu$ is a diagonal matrix $\\textrm{diag}(\\lambda_1, \\lambda_2, \\ldots, \\lambda_M)^{-1}$ containing the inverse eigenvalues on its diagonal. Finally, substituting $\\Kuu$ and $\\kux$ into the sparse variational approximation (\\cref{eq:qf}) leads to\n\\begin{equation}\n\\begin{aligned}\n    q(f) =\n    \\GP\\Big(\\tilde{\\bm{\\phi}}^\\top(x)\\,\\vm;\\ k(x, x') + &\\tilde{\\bm{\\phi}}^\\top(x)(\\MS - \\Kuu)\\tilde{\\bm{\\phi}}(\\vx') \\Big),\\\\ \n    &\\text{with}\\quad\\tilde{\\bm{\\phi}}(x) = [\\lambda_m \\phi_m(x)]_{m=1}^M \\in \\Reals^M.\n\\end{aligned}\n\\end{equation}\nThrough this construction we created a SVGP model with 1) spherical harmonic basis functions, and 2) a diagonal $\\Kuu$ matrix, which means that we do not incur the cubic cost of matrix inversion in the evaluation of the model or the variational lower bound. The sperical harmonic basis functions have as advantage that they have global support, so that even a few of them are able to capture the rough shape of the function. This is similar to the Fourier series approximation, in which the first few terms are already able to roughly approximate the function. In the experiments we will discuss this phenomenon in more detail.\n\nNote that while the inducing variables $\\{u_m\\}$ are independent under the prior (i.e. $p(\\vu) = \\NormDist{\\bm{0}, \\Kuu}$ with $\\Kuu$ a diagonal matrix), that does not imply that the posterior over the inducing variables is diagonal as well. As a result, we still parameterise $q(\\vu) = \\NormDist{\\vm, \\MS}$, where $\\MS$ is a full-rank matrix which captures all the pairwise covariances.\n\n\\section{Homogeneous Extension to $\\Reals^d$}\n\n\\begin{figure}[t]\n\\centering\n\\begin{minipage}{.48\\textwidth}\n  \\centering\n  \\includegraphics[width=\\linewidth]{harmonics}\n  \\captionof{figure}{Spherical Harmonics on $\\sphere^2$}\n  \\label{fig:harmonics}\n\\end{minipage}\\hfill\n\\begin{minipage}{.48\\textwidth}\n  \\centering\n  \\includegraphics[width=\\linewidth,trim=1.5cm 1.6cm 1.cm 1.55cm,clip=true]{mapping}\n  \\captionof{figure}{Example Homogeneous Extension}\n  \\label{fig:mapping}\n\\end{minipage}\n\\end{figure}\n\nSo far, the domain of interest has been the hypersphere $\\dsphere$ . However, most regression problems in machine learning have inputs defined on the complete Euclidean space. We can address this problem as follows. Consider $x \\in \\Reals^{d-1}$ to be the input of the dataset and $y \\in \\Reals$ the corresponding output.\n\\begin{enumerate}\n    \\item We start by concatenating the datapoint $x \\in \\Reals^{d-1}$ with a bias term $b \\in \\Reals$ to obtain $x = [x, b] \\in \\Reals^d$. This operation corresponds to embedding the $(d\\!-\\!1)$-dimensional datapoint on a plane in $\\Reals^d$ where $x_d = b$.\n    \\item Subsequently, the data is linearily projected to the hypersphere through normalisation: $x = {x \\over \\norm{x}} \\in \\dsphere$ and $y = {y \\over \\norm{x}}$.\n    \\item Based on the projected data we learn $f \\sim \\GP$ on $\\dsphere$ using the approach outlined in the previous section.\n    \\item Finally, the function on the sphere can be extended to the whole domain by a homogeneous extension thereof: $g: \\Reals^d \\rightarrow \\Reals$ with $g(x) = \\norm{x} f({x \\over \\norm{x}})$. In other words, by linearily extrapolating the values on the hypersphere we obtain the values of the function in the data plane.\n\\end{enumerate}\nThis procedure is explained in \\cref{fig:mapping}, which gives an illustration of the mapping between a 2D dataset (grey dots) embedded into a 3D space and its projection (orange dots) onto the unit half-circle using a linear mapping.\n\n\\subsection{First-order Arc Cosine kernel}\n\\label{sec:arccosine}\nAlthough this setup may seem very arbitrary, it is inspired by the important works on the limits of neural networks as Gaussian processes. The first order Arc Cosine kernel \\citep{cho2009kernel} is one of the most well-known examples, and mimics the computation of infinitely wide fully connected layers with ReLU activations. Let $\\sigma(t) = \\max(0, t)$, then the covariance between function values of $f(x) = \\sigma(w\\transpose x)$ for $w \\sim \\NormDist{0, d^{-1/2} \\Eye_d}$ and $w \\in \\Reals^d$ is given by\n\\begin{equation}\n\\label{eq:arccosine}\n    k(x, x') = \\Exp{w}{\\sigma(w\\transpose x)\\, \\sigma(w\\transpose x')} = \\underbrace{\\norm{x} \\norm{x'}}_{\\text{radial}}\\ \\underbrace{\\frac{1}{\\pi}\\big( \\sqrt{1 - t^2} + t\\, (\\pi - \\arccos t) \\big)}_{\\text{angular (shape function) } \\kappa(t)},\n\\end{equation}\nwhere $t = \\frac{\\vx^\\top \\vx'}{\\norm{\\vx}\\norm{\\vx'}}$. Indeed, we observe how the first order Arc Cosine kernel factorises in a radial and an angular component. The radial component simply linearly extrapolates the values on the hypersphere, while the angular component encodes the covariance on the hypersphere and is only a function of the geodesic distance. This factorisation exactly matches our setup. We can generalise the zonal kernels of the previous section and their corresponding RKHS to the complete domain $\\Reals^d$ using the following definition\n\\begin{equation}\n    k(x, x') = \\norm{x} \\norm{x'} \\kappa\\left( \\frac{x^\\top x'}{\\norm{x}\\norm{x'}} \\right), % \\quad \\text{and} \\quad f(x) = \\norm{x} f\\left({x \\over \\norm{x}}\\right).\n\\end{equation}\nwhich leads to an RKHS consisting of functions defined on $\\Reals^d$ of the form $g(x) = \\norm{x}\\,f(\\frac{x}{\\norm{x}})$, where $f \\in \\rkhs$ (from \\cref{eq:rkhs-sphere}) is defined on the unit hypersphere but fully determines the function on $\\Reals^d$. Straightforwardly we can extend the Mercer decomposition of \\cref{theorem:mercer-zonal} to\n\\begin{equation}\n    k(x, x') = \\sum_{n=0}^{\\infty} \\sum_{j=1}^{\\dnumharmonicsforlevel} \\lambda_{n} \\norm{x} \\phi_{n,j}(x) \\norm{x'} \\phi_{n,j}(x'),\n\\end{equation}\nwhere the eigenvalues $\\lambda_n$ and reproducing inner-product remain unchanged and are given by \\cref{eq:compute-eigenvalues} and \\cref{eq:rkhs-sphere}, respectively.\n\n\\section{Relation to Variational Fourier Features}\n\\label{sec:vff-vs-vish}\n\nThe most closely related method to the presented method, which going forward we are going to refer to as Variational Inducing Spherical Harmonics (VISH), is the Variational Fourier Feature (VFF) approach proposed by \\citet{hensman2017variational}. VFF is an interdomain method where the inducing variables are given by a Mat\\'ern RKHS inner product between the GP and elements of the Fourier basis:\n\\begin{equation}\nu_m = \\langle f, \\psi_m \\rangle_\\rkhs,\n\\end{equation}\nwhere $\\psi_0 = 1$, $\\psi_{2m}=\\cos(m x)$ and $\\psi_{2m+1}=\\sin(m x)$ if the input space is $[0, 2 \\pi]$. This leads to\n\\begin{equation}\n    \\Kuu = \\left[\\langle \\psi_i , \\psi_{j} \\rangle_\\rkhs^{} \\right]_{i, j = 0}^{M-1}\\qquad\\text{and}\\qquad\\kux = \\left[ \\psi_i(x)\\right]_{i = 0}^{M-1}\\, .\n\\end{equation}\nThis results in several advantages. First, the features $\\kux$ are exactly the elements of the Fourier basis, which are independent of the kernel parameters and can be precomputed. Second, the matrix $\\Kuu$ is the sum of a diagonal matrix plus low rank matrices. This structure can be used to drastically reduce the computational complexity. Finally, the variance of the inducing variables typically decays quickly with increasing frequencies, which means that by selecting the first $M$ elements of the Fourier basis we pick the features that carry the most signal.\n\nThe main flaw of VFF comes from the way it extends to multidimensional input spaces. The approach in~\\citet{hensman2017variational} for getting a set of $d$-dimensional inducing functions consists of taking the outer product of $d$ univariate basis and to consider separable kernels so that the elements of $\\Kuu$ are given by the product of the inner products in each dimension. For example, in dimension 2, a set of $M^2$ inducing functions is given by $\\{(x_1, x_2) \\mapsto \\psi_i(x_1)\\psi_j(x_2)\\}_{0 \\leq i, j \\leq M-1}$, and entries on $\\Kuu$ are $\\langle \\psi_i\\psi_j, \\psi_k\\psi_l \\rangle_{\\mathcal{H}_{k_1 k_2}^{}}^{} = \\langle \\psi_i, \\psi_k \\rangle_{\\mathcal{H}_{k_1}^{}}^{} \\langle \\psi_j, \\psi_l \\rangle_{\\mathcal{H}_{k_2}^{}}^{}$. This construction scales poorly with the dimension: for example choosing a univariate basis as simple as $\\{1, \\cos, \\sin\\}$ for an eight-dimensional problem already results in more that 6,500 inducing functions. Additionally, this construction is very inefficient in terms of captured variance, as we illustrate in  \\Cref{fig:decay-vff} for a 2D input space. The figure shows that the prior variance associated with the inducing function $\\psi_i(x_1)\\psi_j(x_2)$ vanishes quickly when both $i$ and $j$ increase. This means that most of the inducing functions on which the variational posterior is built are irrelevant, whereas some important ones such as $\\psi_i(x_1)\\psi_0(x_2)$ or $\\psi_0(x_1)\\psi_j(x_2)$ for $i, j \\geq \\sqrt{M}$ are important but ignored. Although we used a 2D example to illustrate this poor behaviour, it is important to bear in mind that the issue gets exacerbated for higher dimensional input spaces.\n\nOn the contrary for VISH, given that we ordered the spherical harmonic by increasing level $n$, choosing the first $M$ elements means we will select first inducing functions with low angular frequency (see \\cref{fig:harmonics}). Provided that the kernel spectral density is a decreasing function (this will be true for classic covariances, but not for quasi-periodic ones), this means that the selected inducing variables correspond to the ones carrying the most signal according to the prior. In other words, the decomposition of the kernel can be compared to an `infinite dimensional principal component analysis', and our choice of the inducing function is optimal since we pick the ones with the largest variance. This is illustrated in \\cref{fig:decay-vish}, which shows the analogue of \\cref{fig:decay-vff} for spherical harmonic inducing functions.\n\n\n\\begin{figure}[t!]\n  \\centering\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics[width=\\textwidth]{VFF_v2}\n  \\caption{VFF}\n  \\label{fig:decay-vff}\n\\end{subfigure}\\hfil % <-- added\n\\begin{subfigure}{0.49\\textwidth}\n  \\includegraphics[width=\\textwidth]{VISH_v2}\n  \\caption{VISH}\n  \\label{fig:decay-vish}\n\\end{subfigure}\\hfil % <-- added\n\\caption{Illustration of the variance of the prior and the inducing variables when using VFF or VISH with a two dimensional input space. Each square corresponds to an inducing function $\\psi_{i,j}$ (VFF) or $\\phi_{n,j}$ (VISH) and the area of each square is proportional to the variance of the associated inducing variable. For a given number of inducing variables as highlighted with the blue line, VFF does not select the inducing variables that contribute the most to the prior. The selection in VISH on the other hand is optimal.}\n\\label{fig:decay-vff-vs-vish}\n\\end{figure}\n\n\n% especially the \\emph{arc-sine} kernel \\citep{williams1998computation} and the \\emph{arc-cosine} kernels \\citep{cho2009kernel}. An arc-cosine kernel corresponds to the infinitely-wide limit of a single-layer ReLU-activated network with Gaussian weights. Let $\\vx, \\vx' \\in \\Reals^{d}$, such that $x_d = x'_d = b$, be an augmented input vector whose last entry corresponds to the bias. Then the arc-cosine kernel can be written as\n% \\begin{multline*}\n%     k_{ac}(\\vx, \\vx') = \\norm{\\vx}\\,\\norm{\\vx'}\\,\\underbrace{\\frac{1}{\\pi} \\big( \\sin \\theta + (\\pi - \\theta) \\cos \\theta \\big)}_{=J(\\theta)}, \\\\\n%     \\text{where}\\quad\\theta = \\cos^{-1}\\left(\\frac{\\vx\\transpose\\vx'}{\\norm{\\vx}\\norm{\\vx'}}\\right).\n% \\end{multline*}\n% The kernel is a function of the norm of the inputs $\\norm{\\vx}\\,\\norm{\\vx'}$ and a factor $J(\\theta)$ that only depends on the geodestic distance $\\theta$ (or the great-circle distance) between the projection of $\\vx$ and $\\vx'$ on the unit hypersphere. \n\n\n\\section{Experiments}\n\nWe evaluate our method Variational Inference with Spherical Harmonics (VISH) on a regression and a classification problem to demonstrate that VISH performs competitively in terms of accuracy and uncertainty quantification, while also being extremely fast (modelling a dataset of 6 million 8D datapoints in less than 2 minutes on a standard desktop).\n\n\n\\subsection{Toy Experiment: Banana Classification}\n\nThe banana dataset is a 2D binary classification problem \\citep{hensman2015scalable}. In \\cref{fig:banana} we show three different fits of VISH with $M\\in \\{9,\\ 225,\\ 784\\}$ spherical harmonics, which correspond respectively to maximum levels of $2$, $14$, and $27$ for our inducing functions. Since the variational framework provides a guarantee that more inducing variables must be monotonically better \\citep{titsias2009}, we expect that increasing the number of inducing functions will provide improved approximations. This is indeed the case as we show in the rightmost panel: with increasing $M$ the ELBO converges and the fit becomes tighter.\n\n% While this is expected behaviour for SVGP methods, it is not guaranteed by VFF. Given the Kronecker-structure used by VFF for this 2D experiment \\citet{hensman2017variational} report that using a full rank covariance matrix for the variational distribution was intolerably slow. They also show that enforcing the Kronecker structure on the posterior results in an ELBO that {\\em decreased} as frequencies were added, and they finally propose a sum-of-two-Kroneckers structure, but provide no guarantee that this would converge to the exact posterior in the limit of larger $M$. In VISH we do not need to impose any structure on the approximate covariance matrix $\\MS$, so we retain the guarantee that adding more basis functions will move us closer to the posterior process. The method remains fast despite optimising over full covariance matrices: fitting the models displayed in \\cref{fig:banana} only takes a few seconds on a standard desktop.\n\n\\begin{figure}[tbh]\n    \\centering\n    \\includegraphics[width=\\textwidth]{banana}\n    \\caption{Classification of the 2D banana dataset with growing number of spherical harmonic basis functions. The right plot shows the convergence of the ELBO with respect to increasing numbers of basis functions.\\label{fig:banana}}\n\\end{figure}\n\n\n\n\\subsection{Large-Scale Regression on Airline Delay}\n \n\\begin{table}[tb]\n\\centering\n\\resizebox{\\textwidth}{!}{\\input{Chapter3/Tables/airline.tex} }\n\\caption{Predictive mean squared errors (MSEs), negative log predictive densities (NLPDs) and wall-clock time in seconds with one standard deviation based on 10 random splits on the airline arrival delays experiment. Total dataset size is given by $N$ and in each split we randomly select 2/3 and 1/3 for training and testing.}\n\\label{tab:airline}\n\\end{table}\n\n\nThis experiment illustrates three core capabilities of VISH: 1) it can deal with large datasets and 2) it is computationally and time efficient 3) the model improves performance in terms of NLPD.\n\nWe use the 2008 U.S. airline delay dataset to asses these capabilities. The goal of this problem is to predict the amount of delay $y$ given eight characteristics $x$ of a flight, such as the age of the aircraft (number of years since deployment), route distance, airtime, etc. We follow the exact same experiment setup as \\citet{hensman2017variational}\\footnote{\\url{https://github.com/jameshensman/VFF}} and evaluate the performance on 4 datasets of size 10,000, 100,000, 1,000,000, and 5,929,413 (complete dataset), created by subsampling. For each dataset we use two thirds of the data for training and one third for testing. Every split is repeated 10 times and we report the mean and one standard deviation of the MSE and NLPD. For every run the outputs are normalized to be a centered unit Gaussian and the inputs are scaled to be within $[-1, 1]$.\n%for VFF and SVGP. For VISH we normalize the inputs so that each column falls within $[-v_d, v_d]$. The hyperparameter $v_d$ corresponds to the prior variance of the weights of an infinite-width fully-connected neural net layer (see \\citet{cho2009kernel}). We can optimise for this weight-variance by back-propagation through $k_u(x)$ w.r.t. the ELBO. This is similar to the lengthscale hyperparameters of stationary kernels.\n\n\\Cref{tab:airline} shows the outcome of the experiment. The results for VFF and SVGP are from \\citet{hensman2017variational}. We observe that VISH improves on the other methods in terms of NLPD and is within error bars in terms of MSE. Given the variability in the data the GP models improve when more data is available during training.\n\nGiven the dimensionality of the dataset, a full-VFF model is completely infeasible. As an example, using just four frequencies per dimension would already lead to $M = 4^8 = 65,536$ inducing variables. So VFF has to resort to an additive model with a prior covariance structure given as a sum of Mat\\'ern-3/2 kernels for each input dimension. Each of the functions $f_d$ is approximated using 30 frequencies.\nWe report two variants of VISH: one using all spherical harmonics up to degree 3 ($M$=210) and another up to degree 4 ($M$=660). As expected, the more inducing variables, the better the fit.\n\nWe also report the wall clock time for the experiments (training and evaluation) for $N=10,000$ and $N=5,929,413$. All these experiments were ran on a single consumer-grade GPU (Nvidia GTX 1070). On the complete dataset of almost 6 million records, VISH took $41\\pm0.81$ seconds on average. A-VFF required $75.61\\pm0.75$ seconds and the SVGP method needed approximately 15 minutes to fit and predict. This shows that VISH is roughly two orders of magnitude faster than SVGP. A-VFF comes close to VISH but has to impose additive structure to keep its computational advantage.\n\n\n\\section{Conclusion}\n\nIn this chapter we introduced the RKHS associated with dot-product kernels on the hypersphere. Using the Mercer representation of this RKHS we designed an efficient spherical harmonic inducing function for sparse variational Gaussian processes. Our general setup is closely related to VFF, and we inherit several of its advantages such as a considerable speed-up compared to classic sparse GP models as a result of sparsity in the $\\Kuu$ matrix, and having fixed features $\\kux$ .with a global influence on the approximation. However, by projecting the data onto the hypersphere and using dedicated GP models on this manifold our approach succeeds where other sparse GPs methods fail. First, VISH provides good scaling properties as the dimension of the input space increases.  Second, we showed that under some relatively weak hypothesis we are able to select the optimal features to include in the approximation. This is due to the intricate link between ``stationary'' covariances on the sphere and the Laplace-Beltrami operator. Third, the Mercer representation of the kernel means that the matrices to be inverted at training time are exactly diagonal ---resulting in a very cheap-to-compute sparse approximate GP.\n\nIn the next chapter, we are going to employ the same RKHS. However, instead of using the eigenfunctions of the kernel operator as the inducing functions, we are going to rely on the reproducing property to construct inducing functions that closely mimic the activation functions in neural networks.", "meta": {"hexsha": "988f8b38728391107f4f78cbff1a0621c7af36e1", "size": 29852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "vdutor/FYR", "max_stars_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "vdutor/FYR", "max_issues_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "vdutor/FYR", "max_forks_repo_head_hexsha": "e32e175235720c7651c3b5200dcccf8046ab3099", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 111.8052434457, "max_line_length": 1671, "alphanum_fraction": 0.7501004958, "num_tokens": 8179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.40645390326663977}}
{"text": "\\section{Theoretical Model}\n\\label{sec:section2}\n\\subsection{Setup}\\label{sec:section2.1} \nIn this section, I establish the theoretical framework for the model developed throughout this paper. Fix a non-atomic continuum of male and female agents and consider the dynamic two-sided market formed by the SBDP, which agents can join to search for potential romantic partners. \nFor ease of exposition, I assume that this market is heteronormative such that male agents search exclusively for female agents and vice-versa. \nTime is discrete and indexed by $t=0, 1, 2, ...$ over an infinite horizon. Each period, masses $\\lambda_m, \\lambda_w>0$ of new men and women enter the platform, where agents are then paired and presented a candidate partner from the opposite side of the market. \n\nWe model agents with heterogeneous preferences (capturing the notion that `beauty lies in the eye of the beholder') and thus, after being paired, each agent observes an \\textit{idiosyncratic attractiveness value} $\\theta \\in \\Theta := [0,1]$ for their candidate. \nThese values are i.i.d according to a pair of absolutely continuous CDF's, $F_m$ and $F_w$, with corresponding PDF's $f_m,f_w$. \nFemale agents draw male candidate values from $F_m$ and vice versa but, importantly, the value man $i$ draws for woman $j$ does not necessarily equal the value that $j$ draws for $i$ and, for simplicity, these are modelled as independent from one another.\n\nAfter observing their candidate's attractiveness, agents then choose to swipe left (dislike) or right (like) on them, yielding an action space $\\mathcal{A}=\\{ \\text{Swipe Left}, \\text{Swipe Right}\\}$. \nIf either agent swipes left, then they both receive a payoff of zero; however, if both agents swipe right, they are said to have \\textit{matched} and both receive a matching payoff $u(\\theta)$, where $u(\\cdot)$ is a continuous, strictly increasing function that satisfies $u(0) = 0$. \nThis last property stems from the fact that, in most SBDPs, users are allowed to unmatch with each other, and therefore matching with even the least attractive individual on the other side of the market is weakly preferred to not matching. \n\nAfter payoffs have been received, agents are paired with different candidates and the stage interaction is repeated. Given the continuum of agents, I assume that interactions take place \\textit{anonymously} in the style of \\cite{jovanovic1988anonymous}. Furthermore, to the agents' knowledge, pairings are determined in an unknown manner (since SBDPs are generally secretive regarding the algorithms they use), effectively making their problem one of uniform random search.\n\n\\begin{figure}[ht]\n    \\centering \n    \\caption{Sequence of events within each time period}\n    \\vspace{20pt} \n        \\begin{tikzpicture}\n            % draw horizontal line   \n        \\draw[thick, -Triangle] (0,0) -- (\\ImageWidth,0); %node[font=\\scriptsize,below left=3pt and -8pt]{$t+1$};\n\n        % draw vertical lines\n        \\foreach \\x in {1,2,...,6}\n        \\draw (\\x*2 cm,4pt) -- (\\x*2 cm,-4pt);\n\n        \\foreach \\x/\\descr in {2/t, 4/\\text{Arrivals}, 6/\\text{Pairings}, 8/\\text{Game Play}, 10/\\text{Departures}, 12/t+1}\n        \\node[font=\\scriptsize, text height=1.75ex,\n        text depth=.5ex] at (\\x,-.3) {$\\descr$};  \n    \\end{tikzpicture}\n    \\label{fig:timeline}\n\\end{figure}\n\nSince swiping right in the above stage game is weakly dominant for all agents, one would not expect the repeated interaction to be massively revealing of real-life preferences, where initiating a romanic encounter is often perceived by humans as a costly endeavour \\citep{dawkins2017selfish}. This becomes problematic since the main selling point of SBDPs is a reduction in searching costs for individuals seeking romantic encounters, and this is only accomplished if matches have a high likelihood of resulting in real-life romantic attraction. Because of this, SBDPs like Tinder place a cap on the total number of right swipes for each user, thus enabling this as a form of costly signalling. I refer to the total number of right-swipes a user has left as its \\textit{budget}, $b$, which evolves dynamically according to the law of motion: \n\\begin{equation*} \n  b_{t+1}= b_{t} - \\mathbbm{1}\\{a_t=\\text{Swipe Right}\\}\n\\end{equation*}\n\nThe budget sets for men and women are thus defined by $\\mathcal{B}_{s}=\\{b \\in \\mathbb{Z} : 1\\leq b \\leq B_s\\}$, for each sex $s=m,w$, with budget caps $B_m$ and $B_w$ determined exogenously. Importantly, agents depart from the platform in one of two ways: they can leave \\textit{endogenously}, if they expend their swiping budget, or \\textit{exogenously} with probability $(1-\\delta)$ in each time period. This admits to the interpretation of a geometrically distributed lifetime, such that agents discount future payments by a factor of $\\delta\\in(0,1)$. \n\nOne final remark for this setup is that, in a continuum market with anonymous interactions, the mean-field assumption established in \\autoref{sec:section2.3} effectively restricts focus onto the set of (pure) symmetric stationary strategies. This is argued in more detail in the following sections but, for now, denote these strategies by functions $\\mu: \\Theta \\times\\mathcal{B}_m\\rightarrow \\mathcal{A}$ for men and $\\omega:\\Theta \\times\\mathcal{B}_w\\rightarrow \\mathcal{A}$ for women.\n\n\\subsection{The Dating Market}\\label{sec:section2.2}\nWith the above framework in place, I now outline the platform state variables that make up the SBDP market. \nLet $N_{mt}(b), N_{wt}(b)$ denote the mass of male and female agents (respectively) with a budget of $b\\in\\mathcal{B}$ in a given time period $t$. \n%Additionally, with a slight abuse of notation, let $N_{mt}, N_{wt}$ denote the overall mass of male and female agents (respectively) in the platform, i.e. $\\sum_{b\\in\\mathcal{B}_m}N_{mt}(b)$ and $\\sum_{b\\in\\mathcal{B}_w}N_{wt}(b)$.\nSince gender imbalances can leave some agents in the long side of the market unpaired, a pairings process must also be determined. \nGiven the automated nature of SBDPs, I assume an efficient matching technology and model pairings as a Bernoulli process parametrised by market tightness; thus, the probability of being paired with a candidate is defined for both sides as:  \n\\begin{equation*}\n    \\tau_{mt}:=\\min \\left\\{\\frac{\\sum_{b\\in\\mathcal{B}_w}N_{wt}(b)}{\\sum_{b\\in\\mathcal{B}_m}N_{mt}(b)} , 1 \\right\\}, \n    \\quad \\tau_{wt}:= \\left(\\frac{\\sum_{b\\in\\mathcal{B}_m}N_{mt}(b)}{\\sum_{b\\in\\mathcal{B}_w}N_{wt}(b)} \\right) \\tau_{mt} \n\\end{equation*}\n\nFrom the above, the platform state in time period $t$ can be defined as $\\Psi_t=(N_{mt},N_{wt})$. \nFor most of this paper, I focus on characterising user behaviour and its resulting implications in a stationary setting (which is denoted by omitted time subscripts), although some discussion of coupled strategy and market dynamics is provided in \\autoref{sec:section4}. \nAs a necessary requirement, the market steady state $\\Psi_t=\\Psi_{t+1}=...=\\Psi$ must satisfy the balanced flow conditions \\footnote{Formally, these conditions rely on the exact law of large numbers, which was rigorously developed in discrete-time settings by \\cite{duffie2018dynamic}, but a technical discussion of this lies outside the scope of this paper.} for our continuum model; these are presented below for the female agents, but they apply analogously to the male side of the market. \nFirstly, the entry flow of agents into the platform must equal the departure flow: \n\\begin{equation}\\label{eq:ss1} \n    \\lambda_w\\;=\\; \\underbrace{ (1-\\delta)\\sum_{b\\in\\mathcal{B}_w}N_{wt}(b)}_{\\text{Exogenous Outflow}} \\;+\\; \\underbrace{N_w(1) \\delta \\tau_w\\int_{\\Theta}\\omega(\\theta,1)\\,dF_{m}(\\theta)}_{\\text{Endogenous Outflow}} \n\\end{equation} \n\nSecondly, for both sides, the flow of agents into any particular budget level must equal the outflow of agents from that same level. Thus, for all $b\\in\\mathcal{B}_w$: \n\\begin{equation}\\label{eq:ss2} \n    \\underbrace{N_w(b+1) \\delta \\tau_w \\int_{\\Theta} \\omega(\\theta,b+1)\\,dF_{m}(\\theta)}_{\\text{Inflow into $b$}} \\;=\\; \\underbrace{N_w(b) \\Big[ (1-\\delta) \\;+\\; \\delta \\tau_w\\int_{\\Theta} \\omega(\\theta,b)\\,dF_{m}(\\theta)\\Big]}_{\\text{Outflow from $b$}}\n\\end{equation}\n\nFinally, the entry flow of agents into the platform must equal the outflow from the top budget level, hence: \n\\begin{equation}\\label{eq:ss3} \n    \\lambda_w \\;=\\; \\underbrace{N_w(B_w) \\Big[ (1-\\delta) \\;+\\; \\tau_w \\delta \\int_{\\Theta} \\omega(\\theta,B_w)\\,dF_{m}(\\theta) \\Big]}_{\\text{Outflow from $B_w$}}\n\\end{equation} \n\nImportantly, the above conditions take the strategy profile $(\\mu,\\omega)$ as exogenously fixed. Over the next section, these are endogenously derived by characterising the agents’ best-responses in an SDBP setting, which themselves depend on the market steady state $\\Psi$.\n\n\\subsection{The Search Problem}\\label{sec:section2.3}\nWith the model framework outlined above, I now present the decision problem faced by female agents in the market given some platform steady state $\\Psi$, with analogous results and implications for the male side. \nConsider now a woman $i$ who is paired with a man $j$ in the platform. Since $j$'s swiping behaviour will depend on his own budget, which is unknown to woman $i$, then (under strict rationality) she would have to compute her expected payoff conditional on her beliefs for the market history.\n\nThis behaviour is both unreasonable and intractable in an SBDP setting, as explained in \\autoref{sec:section1.1}; instead, given a stationary platform and a continuum of anonymous agents, it is reasonable to conjecture that the average swiping rate for men, $\\overline\\mu$, is also stationary, and that any individual agent's actions have a negligible effect on the platform state dynamics\\footnote{I also assume that $\\overline\\mu>0$ to prune out degenerate equilibria where one side never swipes right.}.\nAs such, the expected ex-interim payoff for woman $i$ is the following:\n\\begin{equation*}\n    \\begin{aligned}\n        U(\\theta, a)&=\\Big(\\mathbbm{1}\\{a=\\text{Swipe Right}\\}\\Big)\\,\\overline{\\mu}u(\\theta)%, \\\\[8pt] \\quad \\text{where}\\quad \\overline{\\mu} &= \\sum_{b\\in \\mathcal{B}_m}\\int_{\\Theta}\\frac{{N}_m(b)}{N_m}  \\, \\mu(\\theta',b)\\,dF_w(\\theta')\n    \\end{aligned} \n\\end{equation*} \n\nThe above imposes a mean-field assumption, such that woman $i$ accounts for $j$'s behaviour only through $\\overline\\mu$ conditional on the platform state $\\Psi$.\nThis modelling choice, which has been employed by \\cite{immorlica2021designing} and \\cite{iyer2014mean} among others, simplifies the full dynamic game by collapsing it onto a pair of Markov Decision Processes (MDPs), one for each side of the market, such that strategy $\\omega$ is a best-response for women iff it is an optimal policy for the corresponding MDP. \nAdditionally, this also condenses $i$'s state of payoff-dependent variables to include only the value $\\theta$ that she observes for $j$ and her own budget $b$. \nTherefore, since all agents in the same side solve the same MDP, which depends only on their individual state, this effectively justifies the restricted focus on symmetric stationary strategies, as established in \\autoref{sec:section2.1}.\n\nLet the unrealized jump times of the pairing process for woman $i$ be indexed by $k$. \nGiven that, at the time of pairing, this women has a budget of $b$ right swipes left, she then solves the constrained MDP presented below, captured by the value function $V_w(\\theta,b)$: \n\\begin{equation*}\n    \\begin{aligned} \n        V_w(\\theta,b)=\\max_{\\{a_k\\}^\\infty_{k=0}} \\quad & \\mathbb{E}_{\\theta}\\left[\\sum^\\infty_{k=0} \\delta^{k} U(\\theta_k, a_k) \\;|\\; \\theta_0=\\theta, b_0=b\\right]\\\\ \n        \\textrm{s.t.} \\quad & b_{k+1} = b_k - \\mathbbm{1}\\{a_k=\\text{Swipe Right}\\} \\\\\n        & b_k\\in \\mathcal{B}_w \\cup \\{0\\},\\\\\n        & a_k\\in \\mathcal{A}  \n    \\end{aligned}\n\\end{equation*}\n\nImportantly, the first two constraints, along with the exogenous departure process, make this problem non-trivial: by limiting woman $i$'s right-swiping budget, the platform imposes an opportunity cost for swiping right on $j$ and foregoing potential future matches with more attractive men, whilst the exogenous departure process removes the possibility of simply waiting around to swipe right on the top-$B_w$ most attractive men in the platform. \nBy standard dynamic programming arguments, this problem can be captured by two Bellman equations; one for when $j$ is paired and another for when she isn't: \n\\begin{align}\n    \\begin{split} \n        V^{P}_w(\\theta,b) &=\\max \\Big\\{ \\, \\overline{\\mu}\\, u(\\theta) \\;+\\; \\delta \\tau_w \\,\\mathbb{E}_\\theta \\Big[V^P_w(\\theta', b-1)\\Big] \\;+\\; \\delta (1-\\tau)V^{NP}_w(b-1) \\, ,\\\\[6pt]\n        & \\quad\\quad\\quad\\quad\\;\\delta \\tau_w \\, \\mathbb{E}_\\theta\\Big[ V^P_w(\\theta', b) \\Big] \\;+\\; \\delta (1-\\tau_w) V^{NP}_w(b) \\, \\Big\\}\n    \\end{split}\\\\[10pt]\n    \\begin{split}\n        V^{NP}_w(b) &= {}\\delta \\tau_w \\,\\mathbb{E}_\\theta \\Big[ V^P_w(\\theta', b)\\Big] \\,+\\, \\delta (1-\\tau_w) V^{NP}_w(b)\n    \\end{split} \n\\end{align} \n\nWith some straightforward algebra, the above two equations can be merged into the full Bellman equation below. Note that, by imposing the swiping budget constraint from the above MDP, it must be the case that $V_w(\\theta, 0)=0$ for all $\\theta \\in \\Theta$, since agents who expend their budget must leave the platform and can't accumulate any additional payoffs: \n\\begin{equation}\\label{eq:full bellman}\n    \\begin{aligned} \n        V_w(\\theta,b) \\;=\\;&\\max\\left\\{\\,\\overline{\\mu} \\, u(\\theta) +\\alpha \\,\\mathbb{E}_\\theta \\Big[V_w(\\theta', b-1)\\Big]\\,,\\; \\alpha\\,\\mathbb{E}_\\theta \\Big[ V_w(\\theta', b)\\Big]\\,\\right\\}\n    \\end{aligned}\n\\end{equation}\n\nHere, $\\alpha$ is the effective discount rate accounting for the exogenous possibilities of both departures and pairings, defined as:  \n\\begin{equation*}\n\\alpha:=\\frac{\\tau_w\\delta}{1-\\delta(1-\\tau_w)}.\n\\end{equation*}\n\nUpon inspection, it is clear that the value function is of a piecewise nature over $\\Theta$. This is formally stated below (with the corresponding derivation included in \\autoref{appx: b}): \n\\begin{proposition}\\label{prop:piecewiseV}\nFix some $b\\in\\mathcal{B}_w$. Then there exists some unique reservation value $\\widetilde{\\omega}_b\\in \\Theta$ such that $V_w(\\theta,b)$ admits the following piecewise form over $\\Theta$:  \n\\begin{equation*}\n    \\begin{split}\n        V_w(\\theta,b)=\\begin{cases}\n            \\overline\\mu u(\\theta) +\\alpha \\,\\mathbb{E}_{\\theta}\\Big[V_w(\\theta', b-1)\\Big],& \\theta \\geq \\widetilde \\omega_b \\\\[10pt]\n            \\alpha \\,\\mathbb{E}_{\\theta}\\Big[V_w(\\theta', b)\\Big],& \\theta\\leq\\widetilde \\omega_b\n        \\end{cases}\\\\[8pt]  \n    \\end{split}\n\\end{equation*} \n\\end{proposition}  \n\nIn the result above, all reservation values $\\{\\widetilde\\omega\\}_{b\\in \\mathcal{B}_w}$ are such that woman $i$ is indifferent between swiping left or right. Therefore, an optimal policy for woman $i$'s MDP involves swiping right for partners who exceed the reservation value for her current budget:  \n\\begin{corollary}\\label{cor:optpolicy}\n    The following threshold policy $\\widetilde\\omega$, parametrised by $\\{\\widetilde\\omega\\}_{b\\in \\mathcal{B}_w}$, attains $V_w(\\theta,b)$:\n    \\begin{equation*}\n        \\begin{split}\n            \\widetilde\\omega(\\theta,b)&=\\begin{cases}\n                \\text{Swipe Right},\\quad \\theta\\geq \\widetilde{\\omega}_b \\\\ \n                \\text{Swipe Left}, \\quad\\theta< \\widetilde\\omega _b  \n            \\end{cases}   \n        \\end{split}\n    \\end{equation*} \n\\end{corollary} \n\nUsing both of these results, I now derive the following explicit characterisation for reservation values $\\{\\widetilde\\omega_b\\}_{b\\in \\mathcal{B}_w}$ (with a corresponding proof included in \\autoref{appx: b}). \n\\begin{proposition}\\label{prop:recurrence relation}\nThe set of reservation values for women, $\\{\\widetilde\\omega_b\\}_{b\\in \\mathcal{B}_w}$, uniquely satisfies the recurrence relation and initial condition below, over the budget set $\\mathcal{B}_w$: \n\\begin{equation}\\label{eq:recurrence relation}\n    \\begin{aligned}\n        u(\\widetilde \\omega_b) \\;=\\; \\alpha u(\\widetilde \\omega_b) F_m(\\widetilde \\omega_b) \\;+\\; \\alpha u(\\widetilde \\omega_{b-1}) \\Big[1- F_m(\\widetilde \\omega_{b-1})\\Big] \\;+\\; \\int^{\\widetilde \\omega_{b-1}}_{\\widetilde \\omega_b} \\alpha u(\\theta')\\,dF_m(\\theta')\n    \\end{aligned} \n\\end{equation}  \n\\begin{equation}\\label{eq:initial condition}\n    u(\\widetilde\\omega_1) \\;=\\; \\alpha u(\\widetilde\\omega_1)F(\\widetilde\\omega_1) \\;+\\; \\alpha \\int^1_{\\widetilde\\omega_1}u(\\theta')dF(\\theta')\n\\end{equation}\n\\end{proposition}  \n\nThis explicit characterisation allows for an improved computation of $\\{\\widetilde\\omega_b\\}_{b\\in \\mathcal{B}_w}$ over traditional numerical methods such as value iteration \\citep{bellman2015applied}, which has a runtime complexity of $\\mathcal{O}(|\\mathcal{B}_w\\times\\Theta|^2|\\mathcal{A}|)$ and can become expensive for large budget sets or fine discretisations of $\\Theta$. Using the recurrence relation in \\autoref{prop:recurrence relation}, the optimal policy was computed for an arbitrary set of exogenous parameters, with results in \\autoref{fig:swiping-rule} showing a clear cut-off rule for swiping right. \nThese cut-off values are decreasing in the agent's budget, which captures the notion that an agent's current swipe is more valuable than all preceding ones given the increasing opportunity cost.\n\n\\begin{figure}[ht]\n    \\centering\n    \\caption{The Optimal Swiping Rule}\n    \\includegraphics{swiping-rule.png}\n    \\label{fig:swiping-rule} \n\\end{figure} ", "meta": {"hexsha": "d53ce1bae13250f39243da50e1e021fab2a8cedc", "size": 17539, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "dissertation/sections/2 - model.tex", "max_stars_repo_name": "patohdzs/project-tinder", "max_stars_repo_head_hexsha": "4a8c138a63e31fa36981a421863a1af5162519c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dissertation/sections/2 - model.tex", "max_issues_repo_name": "patohdzs/project-tinder", "max_issues_repo_head_hexsha": "4a8c138a63e31fa36981a421863a1af5162519c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dissertation/sections/2 - model.tex", "max_forks_repo_name": "patohdzs/project-tinder", "max_forks_repo_head_hexsha": "4a8c138a63e31fa36981a421863a1af5162519c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 99.6534090909, "max_line_length": 842, "alphanum_fraction": 0.7289469183, "num_tokens": 5005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.40644833774749556}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on whenever\n\n\\section{Algebraic Extensions}\n\\label{sec:algebraic_extensions}\n\n\\begin{thm}[Tower Theorem]\n\tLet \\(F \\hookrightarrow E \\hookrightarrow K\\) be a composition of field extensions. Then \\([K:F] = [K:E] [E:F]\\).\n\\end{thm}\nOne can show this via vector space arguments (look at the bases of the spaces).\n\\begin{cor}\n\tIf \\(K / F\\) is a finite extension, and \\(E\\) is a subfield of \\(K\\) containing \\(F\\), then \\([E:F] \\mid [K:F] \\).\n\\end{cor}\n\n\\begin{exmp}\n\tLet \n\\begin{align*}\n\tK &= \\Q(\\sqrt[6]{2} )\\\\\n\tE &= \\Q(\\sqrt{2} )\\\\\n\tF &= \\Q\n\\end{align*} It follow directly from previous work that \\([\\Q(\\sqrt[6]{2}) : \\Q] = 6\\) and \\([\\Q(\\sqrt{2} ):\\Q] = 2\\). As for \\(K / E\\), the minimal polynomial is \\(x^3-\\sqrt{2} \\), which gives \\([\\Q(\\sqrt[6]{2} ): \\Q(\\sqrt{2} )] = 3\\), which corresponds to what the tower theorem gives us.\n\\end{exmp}\n\n\\begin{defn}\n\tAn extension \\(K / F\\) is called \\textbf{finitely generated} if there exist elements \\(\\alpha_1, \\alpha_2,\\ldots,\\alpha_n\\) such that\n\t\\begin{align*}\n\t\tK = F(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n) \\quad \\text{for }n<\\infty\n\t\\end{align*}\n\tSuch an extension can be obtained recursively via simple extensions.\n\\end{defn}\n\tWe have that \\(F(\\alpha ,\\beta ) = (F(\\alpha ))(\\beta )\\), hence the definition above is consistent.\n\\begin{exmp}\n\t\\begin{itemize}\n\t\t\\item \\(\\Q(\\sqrt[6]{2} ,\\sqrt{2} ) = \\left( \\Q(\\sqrt[6]{2} ) \\right) (\\sqrt{2} ) = \\Q(\\sqrt[6]{2} )\\) because \\(\\sqrt{2} = (\\sqrt[6]{2} )^3\\).\n\t\t\\item One can check that \\(\\Q(\\sqrt{2} ,\\sqrt{3} )\\) is a proper field extension for both \\(\\Q(\\sqrt{2} )\\) and \\(\\Q(\\sqrt{3} )\\).\n\t\\end{itemize}\n\\end{exmp}\n\\begin{thm}\n\t\\(K / F\\) is finite if and only if \\(K\\) is generated by a finite number of algebraic elements over \\(F\\).\n\\end{thm}\nWe denote by \\(\\overline{\\Q}\\) the subfield of \\(\\C\\) generated by all algebraic elements of \\(\\C\\) over \\(\\Q\\). \\(\\overline{\\Q}\\) is an infinite algebraic extension of \\(\\Q\\), and referred to as the \\textbf{field of algebraic numbers}. \\\\\n\n\\begin{thm}\n\tIf \\(E / F\\) and \\(K / E\\) are algebraic, then \\(K / F\\) is algebraic.\n\\end{thm}\n\\end{document}\n", "meta": {"hexsha": "92edd50c796821453491b2d4d18da1a968a07a9f", "size": 2543, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture17 - TowerThm.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture17 - TowerThm.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture17 - TowerThm.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.734375, "max_line_length": 290, "alphanum_fraction": 0.6460872985, "num_tokens": 891, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369904, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4064483303424949}}
{"text": "\\section*{Research question and Methodology}\n\nLanguage models can be used for a variety of purposes, such as: speech recognition, \nspelling correction, grammar correction and automatic translation. \nAll these applications have the task of assigning a probability to a \nsequence of words, based on the number of times they appear in one or more \ndocuments. As briefly mentioned in the introductory chapter, the purpose \nof the following project is to verify the existence of a further method, which \nmakes use of the concept of language model, specifically an \\emph{n-grams} model, \ncapable of expanding a query. Achieving this goal means solving the problem \nof mismatch between the terms present in the query and those present in a \ncorpus of documents. The probability of generating a new \\emph{q} query given the \nestimate of a Language Model for a \\emph{D} document can only occur through a \nranking of relevant documents. If the corpus of documents is large, thinking \nof generating \\emph{n} Language models, with \\emph{n} equal to the number of documents, \nturns out to be a computationally expensive operation. This paper has used \na useful approach to be able to generate a first ranking of documents ordered \nby relevance with the query \\emph{q}. The technique applied is the \\emph{tf-idf} recovery \nmodel. The adoption of this method of weighing the terms, as well as being \nwidely used in the state of the art, produces excellent results. The introduction \nof the \\emph{LM}, and of other semantic analysis techniques, made it possible \nto outperform the performance of the \\emph{tf-idf} baseline, generating ranking, \nstarting from the latter, of documents more pertinent to the query \\emph{q} \\cite{09}. In \nthe following paper, tests are carried out which certify the veracity of this \nthesis. It should be noted that the generation of the ranking, obtained from \nthe weights of the \\emph{tf-idf} method, is obtained using the well-known \\emph{cosine \nsimilarity} metric between the weight vectors. To comply with the set objective, \nthe position of the relevant target document, that is the document \nthat the user is searching for, was kept track. This was possible because a \nquery was chosen, among those available, that was close to the title of \nthis document. The score assigned to the target document will represent the \nminimum \\emph{threshold} to be able to form the new ranking of documents. This step \nis fundamental as, by setting a higher threshold, the target document would \nbe lost in subsequent calculations. By setting a lower threshold, however, \nthose documents that represent noise will be taken into account. From this \nranking, the \\emph{LMs} for each document will be calculated \\cite{10}, generating \\emph{n} LMs, \nwith \\emph{n} equal to the number of relevant documents, based on the terms in the \nquery. It should be noted that, in order to carry out this step, the concept \nof \\emph{skip-gram} has been applied to the query, with step \\emph{s} equal to two. The \ncreation of each LM is possible only after using one of the existing smoothing \ntechniques. To prevent a linguistic model from assigning zero probability to \nan invisible event, i.e. when a term present in the query is not present in \nan LM, we should eliminate some probability mass from some more frequent \nevents and give it to events that we haven't never seen. There \nare a variety of methods for smoothing, some of these are: \\emph{Laplace (add-\none) smoothing}, \\emph{Linear Interpolation smoothing}, \\emph{add-k smoothing}, \\emph{back-off \nsmoothing} and \\emph{Kneser-Ney smoothing}. Among these, the following paper \nhas experimented the use of the first two smoothing methods, each of which \nwill produce different results useful for achieving the final goal. The core of \nthe algorithm lies in being able to derive the best ranking of relevant documents, \nusing the initial query, through an iterative process, as s changes. \nThis variation will lead to the generation of several LMs, each with step \\emph{s}, \nwith $s=\\{2,3,\\ldots,10\\}$. At each iteration, a new ranking of documents will be generated, thanks to the calculation of the Maximum Likelihood Estimation \\emph{MLE}, between the query \\emph{q} and each document \\emph{d}(\\ref{MLE}).\n\\begin{eqnarray}\\label{MLE}\n    P(q|d) & \\approx & P(q|M_d) \\nonumber \\\\\n           & \\approx & \\prod_i^n{P(w_i|w_{i-1})} \\nonumber \\\\\n           & \\approx & \\frac{count(w_i,w_{i-1})}{\\sum_{j=1}^n count(w_j,w_{i-1})} \\nonumber \\\\\n           & = & \\frac{count(w_i, w_{i-1})}{count(w_{i-1})}\n\\end{eqnarray}\nAmong all these nine rankings, after being sorted, the one that will have the \ntarget document in the highest position, close to the first, will be chosen. \nAlso thanks to this, it will be possible to determine the lambda parameters \npresent in the interpolation smoothing technique. By focusing on the latter \ntechnique, it was necessary to implement the concept suggested by \\cite{11} as \nregards the calculation of linear interpolation. Instead of adding one to \nthe probability calculation, as is well known in Laplace's smoothing (\\ref{Laplace}), linear \ninterpolation, recursively, calculates the MLE of order two (\\emph{bi-grams}) (\\ref{LinInt}), up to \nthe order zero (\\emph{zero-grams})(\\ref{zero-grams}).\n\\begin{equation}\\label{Laplace}\n    P(w_i|w_{i-1}) = \\frac{count(w_{i-1})+1}{count(w_{i-1})+|V|}\n\\end{equation}\n\\begin{equation}\\label{LinInt}\n    P(w_i|w_{i-1}) = \\lambda P(q|M_d) + (1-\\lambda)P(q|M_c)\n\\end{equation}\n\\begin{equation}\\label{zero-grams}\n    P(w_i) = \\lambda \\frac{1}{|V|} + (1-\\lambda)P(w_i)\n\\end{equation}\n\nwhere:\n\\begin{itemize}\n    \\item $\\sum_i \\lambda_i = 1$\n    \\item $M_d$: represents the language model of the single document;\n    \\item $M_c$: represents the language model of the entire collection of documents;\n    \\item $|V|$: represents the number of unique words within the corpus of documents.\n\\end{itemize}\nIt is always good to specify that, like the iterative process of steps \\emph{s}, both $\\lambda$ \nparameters also follow the same reasoning. The idea is to assign a range of \nnumbers $\\lambda = \\{0.1, 0.2,\\ldots,1\\}$ to both values. In both smoothing techniques, \nthe \\emph{perplexity} level existing between the query word set $W = \\{w_1, w_2,\\ldots,w_N\\}$ and the language model of \nthe target document present in the ranking of relevant documents returned \nby the tf-idf model will be calculated(\\ref{perplexity}) \\cite{12}.\n\\begin{equation}\\label{perplexity}\n    pp(W) = \\sqrt[N]{\\prod_{i=1}^N\\frac{1}{P(w_i|w_{i-1})}} \n\\end{equation}\nAfter obtaining the best ranking, the next step is based on building a \\emph{term-\nterm matrix} \\cite{12}, where the terms in question are both those of the query and \nthose belonging to the language model of the entire collection of relevant \ndocuments present in the ranking. Within this matrix, the numbers of co-occurrences \nbetween all terms will be reported. On this type of matrix it is \npossible to apply the calculation of \\emph{Positive Pointwise Mutual Information \n(PPMI)}. PPMI draws on the intuition that the best way to weigh the association \nbetween two words is to ask how much more the two words co-occur in \nour corpus than we would have a priori expected them to appear by chance. \nThis measure derives from the calculation of the standard PMI which represents \na measure of frequency between two events \\emph{x} and \\emph{y}, compared to what \nwe would expect if they were independent (\\ref{pmi}).\n\\begin{equation}\\label{pmi}\n    \\emph{pmi(x,y)} = \\log_2\\frac{P(x,y)}{P(x)P(y)}\n\\end{equation}\nThe ratio gives us an estimate of how much more the two words co-occur \nthan we expect by chance. PMI values can be positive, negative or infinite. \nNegative values, which imply that events occur less often than we would \nexpect by chance, tend to be unreliable when we have documents consisting \nof few terms, as in our case. To solve this problem, the calculation of the \nPPMI is used which replaces negative values with zero(\\ref{ppmi}).\n\\begin{equation}\\label{ppmi}\n    PPMI(x,y) = \\max(\\log_2\\frac{P(x,y)}{P(x)P(y)}, 0)\n\\end{equation}\nBut the question is: why is the PPMI calculation used? The adoption of \nthis is useful for being able to calculate the similarity between words, i.e. \ntheir synonymy, search for paraphrases, keep track of the change in meaning \nof words and to automatically discover the meanings of words in different \ncorpora. To find the words most similar to those in the query, the cosine \nsimilarity is calculated on the first ten word vectors that have the highest \npositive PPMI values. Eventually, each token in the query will have a maximum \nof ten expansion terms. Thanks to this, we are already seeing how \nquery expansion can be done. Moving on, there is a problem to solve before \nwe can calculate the similarity of the cosine: the \\emph{high dimensionality} \nof the matrix. In order to obtain a good similarity, relatively low at the \ncomputational level, another concept has been implemented: \\emph{Singular Value \nDecomposition (SVD)}. The idea of applying SVD on a term-term matrix was \nproposed by \\cite{13}. Switching from sparse to dense vectors allows for better \nsimilarity comparisons. The SVD allows to decompose the term-term matrix \n(A), of dimensions $txd$, into three matrices \\cite{14} (\\ref{decomposition}):\n\\begin{equation}\\label{decomposition}\n    A = USV^T\n\\end{equation}\nWhere:\n\\begin{enumerate}\n    \\item \\emph{U}: matrix of dimension $txm$ where the columns represent the left \n    singular vectors of matrix A;\n    \\item \\emph{S}: diagonal matrix of dimension $mxm$, containing the singular values \n    of matrix A;\n    \\item \\emph{$V^T$}: transposed matrix, of dimensions $mxd$, where the columns represent \n    the right singular vectors of matrix A.\n\\end{enumerate}\nThanks to the product of the matrix \\emph{U} with the matrix \\emph{S}, a new matrix \n\\emph{$\\mathcal{D}$} (\\ref{matrixD}), of dimension $txm$, is formed containing all the terms that will be \ncompared, through cosine similarity, with the query terms present in the \nmatrix \\emph{$\\mathcal{T}$} (\\ref{matrixT}) given by the product of \\emph{S} and $V^T$ .\n\\begin{equation}\\label{matrixD}\n    \\mathcal{D} = U*S\n\\end{equation}\n\\begin{equation}\\label{matrixT}\n    \\mathcal{T} = S*V^T\n\\end{equation}\nHaving all the possible words available to be added to the query tokens, the \ntime has come to generate all the possible queries. The number of queries \nproduced will depend on the number of words present in the initial query and \non any words obtained from the calculation of the cosine similarity. Having \nset a maximum limit of ten words per token, the total of the quries generated \nis given by the product (\\ref{possQueries}) of the number of possible pairs of terms: \n\\begin{equation}\\label{possQueries}\n    \\#Queries = \\prod_i^q (\\#sim\\_words_i)\n\\end{equation}\nwhere \\emph{i} represents the single word taken in the query and \\emph{q} represents the \ntotal of the words present in the starting query. Being new queries, these \nwill be subjected to the same procedure as the original query, that is, new \nLMs will be produced and with them new rankings of documents that will \ncontain the target document in the first positions. Finally, the best query, \nor queries, will be chosen based on the level of perplexity reached.", "meta": {"hexsha": "2142b6e678506c6a15f3e6de0f5232044da856c7", "size": 11325, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/Research question and methodology.tex", "max_stars_repo_name": "flavioforenza/Information-Retrieval-Paper", "max_stars_repo_head_hexsha": "9b1528b519115f2b137027f2cd3fe0bc16bd7d79", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/Research question and methodology.tex", "max_issues_repo_name": "flavioforenza/Information-Retrieval-Paper", "max_issues_repo_head_hexsha": "9b1528b519115f2b137027f2cd3fe0bc16bd7d79", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/Research question and methodology.tex", "max_forks_repo_name": "flavioforenza/Information-Retrieval-Paper", "max_forks_repo_head_hexsha": "9b1528b519115f2b137027f2cd3fe0bc16bd7d79", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.2280701754, "max_line_length": 233, "alphanum_fraction": 0.7573509934, "num_tokens": 2924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.40604252388767037}}
{"text": "%\\documentclass[UTF8]{ctexart} % use larger type; default would be 10pt\n\\documentclass[a4paper]{article}\n\\usepackage{../mqc}\n\n\n\\title{\\textbf{Modern Quantum Chemistry, Szabo \\& Ostlund}\\\\HW}\n\\author{wsr\n\\vspace{5pt}\\\\\n}\n\\date{\\today} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n% \\boldmath\n\n\\maketitle\n\n\\tableofcontents\n\n\\newpage\n\n\\setcounter{section}{2}\n\\section{The Hartree-Fock Approximation}\n\\subsection{The HF Equations}\n\\subsubsection{The Coulomb and Exchange Operators}\n\\subsubsection{The Fock Operator}\n\\ex{3.1}\n\\begin{align}\n\\Braket{\\chi_i | \\hat{f} | \\chi_j} &= \\Braket{ \\chi_i(1) | h(1) + \\sum_{b} [\\mathscr{J}_b(1) - \\mathscr{K}_b(1)] | \\chi_j(1)} \\notag\\\\\n&= [i|h|j] + \\sum_{b\\neq j}\\qty[\\Braket{\\chi_i(1) \\chi_b(2) | \\dfrac{1}{r_{12}} | \\chi_b(2)\\chi_j(1)} - \\Braket{\\chi_i(1)\\chi_b(2) | \\dfrac{1}{r_{12}} | \\chi_b(1)\\chi_j(2)}] \\notag\\\\\n&= [i|h|j] + \\sum_{b\\neq j}\\qty([ij|bb] - [ib|bj]) \n\\end{align}\nSince\n\\begin{equation}\\label{key}\n[ij|jj] - [ij|jj] = 0\n\\end{equation}\nwe have\n\\begin{align}\n\\Braket{\\chi_i | \\hat{f} | \\chi_j}\n&= \\Braket{i|h|j} + \\sum_b\\qty(\\Braket{ib|jb} - \\Braket{ib|bj}) \\notag\\\\\n&= \\Braket{i|h|j} + \\sum_b\\Braket{ib||jb}\n\\end{align}\n\n\\subsection{Derivation of the HF Equations}\n\\subsubsection{Functional Variation}\n\\subsubsection{Minimization of the Energy of a Single Determinant}\n\\ex{3.2}\nTake the complex conjugate of\n\\begin{equation}\\label{key}\n\\mathscr{L}[\\{\\chi_\\alpha\\}] = E_0[\\{\\chi_\\alpha\\}] - \\sum_a^N\\sum_b^N \\varepsilon_{ba}([a|b] - \\delta_{ab})\n\\end{equation}\nwe have\n\\begin{equation}\\label{key}\n\\mathscr{L}[\\{\\chi_\\alpha\\}]^* = E_0[\\{\\chi_\\alpha\\}]^* - \\sum_a^N\\sum_b^N \\varepsilon_{ba}^*([a|b]^* - \\delta_{ab}^*)\n\\end{equation}\ni.e.\n\\begin{equation}\\label{key}\n\\mathscr{L}[\\{\\chi_\\alpha\\}] = E_0[\\{\\chi_\\alpha\\}] - \\sum_a^N\\sum_b^N \\varepsilon_{ba}^*([b|a] - \\delta_{ab})\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\sum_a^N\\sum_b^N \\varepsilon_{ba}([a|b] - \\delta_{ab}) = \\sum_a^N\\sum_b^N \\varepsilon_{ba}^*([b|a] - \\delta_{ab}) = \\sum_b^N\\sum_a^N \\varepsilon_{ab}^*([a|b] - \\delta_{ba})\n\\end{equation}\n$ \\therefore $\n\\begin{equation}\\label{key}\n\\varepsilon_{ba} = \\varepsilon_{ab}^*\n\\end{equation}\n\n\\ex{3.3}\n$ \\because $\n\\begin{align}\n[\\delta\\chi_a | h | \\chi_a] &= [\\chi_a | h | \\delta\\chi_a]^*\\\\\n[\\chi_a\\delta\\chi_a | \\chi_b\\chi_b] &= [\\delta\\chi_a\\chi_a | \\chi_b\\chi_b]^*\\\\\n[\\chi_a\\chi_a | \\chi_b\\delta\\chi_b] &= [\\chi_a\\chi_a | \\delta\\chi_b\\chi_b]^*\\\\\n[\\chi_a\\chi_b | \\chi_b\\delta\\chi_a] &= [\\chi_b\\delta\\chi_a | \\chi_a\\chi_b] = [\\delta\\chi_a\\chi_b | \\chi_b\\chi_a]^*\\\\\n[\\chi_a\\chi_b | \\delta\\chi_b\\chi_a] &= [\\delta\\chi_b\\chi_a | \\chi_a\\chi_b] = [\\chi_a\\delta\\chi_b | \\chi_b\\chi_a]^*\n\\end{align}\n$ \\therefore $\n\\begin{align}\n\\delta E_0 &= \\sum_a^N[\\delta\\chi_a | h | \\chi_a] \n+ \\dfrac{1}{2}\\sum_a^N\\sum_b^N \\qty([\\delta\\chi_a\\chi_a | \\chi_b\\chi_b] + [\\chi_a\\chi_a | \\delta\\chi_b\\chi_b]) \\notag\\\\\n&\\quad{} - \\dfrac{1}{2}\\sum_a^N\\sum_b^N \\qty([\\delta\\chi_a\\chi_b | \\chi_b\\chi_a] + [\\chi_a\\chi_b | \\delta\\chi_b\\chi_a]) + \\text{complex conjugates}\n\\end{align}\nwhile\n\\begin{align}\n\\sum_a^N\\sum_b^N [\\chi_a\\chi_a | \\delta\\chi_b\\chi_b] &= \\sum_b^N\\sum_a^N [\\chi_b\\chi_b | \\delta\\chi_a\\chi_a] = \\sum_a^N\\sum_b^N [\\delta\\chi_a\\chi_a | \\chi_b\\chi_b]\\\\\n\\sum_a^N\\sum_b^N [\\chi_a\\chi_b | \\delta\\chi_b\\chi_a] &= \\sum_b^N\\sum_a^N [\\chi_b\\chi_a | \\delta\\chi_a\\chi_b] = \\sum_a^N\\sum_b^N [\\delta\\chi_a\\chi_b | \\chi_b\\chi_a]\n\\end{align}\nthus\n\\begin{equation}\\label{key}\n\\delta E_0 = \\sum_a^N[\\delta\\chi_a | h | \\chi_a] \n+ \\sum_a^N\\sum_b^N \\qty([\\delta\\chi_a\\chi_a | \\chi_b\\chi_b] - [\\delta\\chi_a\\chi_b | \\chi_b\\chi_a]) + \\text{complex conjugates}\n\\end{equation}\n\n\\subsubsection{The Canonical HF Equations}\n\n\\subsection{Interpretation of Solutions to the HF Equations}\n\\subsubsection{Orbital Energies and Koopmans' Theorem}\n\\ex{3.4}\n\\begin{align}\nf_{ij} = \\Braket{\\chi_i | f | \\chi_j} = \\Braket{i|h|j} + \\sum_b\\Braket{ib||jb}\n\\end{align}\n\\begin{align}\nf_{ji}^* &= \\Braket{\\chi_j | f | \\chi_i}^* = \\Braket{j|h|i}^* + \\sum_b\\Braket{jb||ib}^*\\notag\\\\\n&= \\Braket{i|h|j} + \\sum_b\\Braket{ib||jb}\\notag\\\\\n&= f_{ij}\n\\end{align}\nthus the Fock operator is Hermitian.\n\n\\ex{3.5}\n\\begin{align}\n\\text{IP} &= ^{N-2}E - E_0 \\notag\\\\\n&= \\sum_{a\\neq c,d}\\Braket{a|h|a} + \\dfrac{1}{2}\\sum_{a\\neq c,d}\\sum_{b\\neq c,d} \\Braket{ab||ab}  - \\qty[\\sum_a\\Braket{a|h|a} + \\dfrac{1}{2}\\sum_a\\sum_b \\Braket{ab||ab} ] \\notag\\\\\n&= -\\Braket{c|h|c} - \\Braket{d|h|d} -  \\dfrac{1}{2}\\sum_{a\\neq c,d}\\Braket{ac||ac}  -  \\dfrac{1}{2}\\sum_{a\\neq c,d}\\Braket{ad||ad} - \\dfrac{1}{2}\\sum_{b\\neq c,d} \\Braket{cb||cb} - \\dfrac{1}{2}\\sum_{b\\neq c,d} \\Braket{db||db}  - \\Braket{cd||cd} \\notag\\\\\n&= -\\Braket{c|h|c} - \\Braket{d|h|d} -  \\sum_{a\\neq c,d}\\Braket{ac||ac}  -  \\sum_{a\\neq c,d}\\Braket{ad||ad}   - \\Braket{cd||cd} \\notag\\\\\n&= -\\Braket{c|h|c} - \\Braket{d|h|d} - \\qty( \\sum_{a\\neq c}\\Braket{ac||ac} - \\Braket{dc||dc}) -  \\qty(\\sum_{a\\neq d}\\Braket{ad||ad} - \\Braket{cd||cd})  - \\Braket{cd||cd} \\notag\\\\\n&= -\\varepsilon_c - \\varepsilon_d + \\Braket{cd|cd} - \\Braket{cd|dc}\n\\end{align}\n\n\\ex{3.6}\n\\begin{align}\n^N E_0 - ^{N+1}E^r &= \\sum_a\\Braket{a|h|a} + \\dfrac{1}{2}\\sum_a\\sum_b \\Braket{ab||ab} \\notag\\\\\n&{}\\quad - \\qty[\\sum_a\\Braket{a|h|a} + \\Braket{r|h|r} + \\dfrac{1}{2}\\sum_a\\sum_b \\Braket{ab||ab} + \\dfrac{1}{2}\\sum_b \\Braket{rb||rb} + \\dfrac{1}{2}\\sum_a \\Braket{ar||ar}] \\notag\\\\\n&= - \\Braket{r|h|r} - \\dfrac{1}{2}\\sum_b \\Braket{rb||rb} - \\dfrac{1}{2}\\sum_b \\Braket{br||br} \\notag\\\\\n&= - \\Braket{r|h|r} - \\sum_b \\Braket{rb||rb}\n\\end{align}\n\n\\subsubsection{Brillouin's Theorem}\n\\subsubsection{The HF Hamiltonian}\n\\ex{3.7}\nSuppose $ \\mathscr{H}_0 $ commutes with $ \\mathscr{P}_n $,\n\\begin{align}\\label{key}\n\\mathscr{H}_0\\ket{\\Psi_0} &= \\mathscr{H}_0 \\dfrac{1}{\\sqrt{N!}} \\sum_n^{N!}(-1)^{p_n} \\mathscr{P}_n \\qty{\\sum_i^N  f(i)\\chi_j(1)\\cdots\\chi_k(N)} \\notag\\\\\n&= \\dfrac{1}{\\sqrt{N!}} \\sum_n^{N!}(-1)^{p_n} \\mathscr{P}_n \\qty{ (\\varepsilon_j + \\cdots + \\varepsilon_k) \\chi_j(1)\\cdots\\chi_k(N)} \\notag\\\\\n&= \\sum_a \\varepsilon_a\n\\end{align}\nNow we show $ \\mathscr{H}_0 $ commutes with $ \\mathscr{P}_n $, for example, $ \\mathscr{P}_{ab} $\n\\begin{equation}\\label{key}\n\\mathscr{P}_{ab}\\mathscr{H}_0 = \\mathscr{P}_{ab}(\\cdots + f(a) + \\cdots + f(b) + \\cdots) = (\\cdots + f(b) + \\cdots + f(a) + \\cdots)\\mathscr{P}_{ab} = \\mathscr{H}_0 \\mathscr{P}_{ab}\n\\end{equation}\n\n\\ex{3.8}\n\\begin{equation}\\label{key}\n\\mathscr{V} = \\sum_i^N \\sum_{j>i}^N \\mathscr{O}_2 - \\sum_i^N\\sum_b^N [\\mathscr{G}_b(i) - \\mathscr{K}_b(i)]\n\\end{equation}\nthus\n\\begin{align}\n\\Braket{\\Psi_0 | \\mathscr{V} | \\Psi_0} &= \\sum_i^N \\sum_{j>i}^N \\Braket{\\Psi_0 | \\mathscr{O}_2 | \\Psi_0} - \\sum_i^N\\sum_b^N [\\Braket{\\Psi_0 | \\mathscr{G}_b(i) - \\mathscr{K}_b(i)| \\Psi_0}] \\notag\\\\\n&= \\dfrac{1}{2}\\sum_a^N \\sum_b^N \\Braket{ab||ab} - \\sum_i^N\\sum_b^N [\\Braket{ib|ib} - \\Braket{ib|bi}] \\notag\\\\\n&= -\\dfrac{1}{2}\\sum_a^N \\sum_b^N \\Braket{ab||ab}\n\\end{align}\n\n\\subsection{Restricted Closed-shell HF: The Roothaan Equations}\n\\subsubsection{Closed-shell HF: Restricted Spin Orbitals}\n\\ex{3.9}\n\\begin{align}\n\\varepsilon_i %&= \\Braket{\\chi_i | h | \\chi_i} + \\sum_b^N \\Braket{\\chi_i\\chi_b || \\chi_i\\chi_b} \\notag\\\\\n&= (i|h|i) + \\sum_b^N(\\Braket{ib|ib} - \\Braket{ib|bi}) \\notag\\\\\n&= (i|h|i) + \\sum_c^{N/2}(\\Braket{ic|ic} - \\Braket{ic|ci}) + \\sum_{\\bar{c}}^{N/2}(\\Braket{i\\bar{c}|i\\bar{c}} - \\Braket{i\\bar{c}|\\bar{c}i}) \n\\end{align}\nAssume $ \\chi_j $ has $ \\alpha $ spin, since assuming $ \\alpha $ or $ \\beta $ is identical\n\\begin{align}\n\\varepsilon_i &= (i|h|i) + \\sum_c^{N/2}\\qty[ (ic|ic)\\Braket{\\alpha|\\alpha}\\Braket{\\alpha|\\alpha} \n- (ic|ci)\\Braket{\\alpha|\\alpha}\\Braket{\\alpha|\\alpha}]\n+ \\sum_c^{N/2}\\qty[(ic|ic)\\Braket{\\alpha|\\alpha}\\Braket{\\beta|\\beta} \n- (ic|ci)\\Braket{\\alpha|\\beta}\\Braket{\\beta|\\alpha}] \\notag\\\\\n&= (i|h|i) + \\sum_c^{N/2}\\qty[ 2(ic|ic) - (ic|ci)] \\notag\\\\\n&= (i|h|i) + \\sum_n^{N/2} (2J_{ib} - K_{ib})\n\\end{align}\n\n\\subsubsection{Introduction of a Basis: The Roothaan Equations}\n\\ex{3.10}\n\\begin{align}\n(\\vb{C}^\\dagger \\vb{S} \\vb{C})_{\\mu\\nu} &= \\sum_i\\sum_j C^\\dagger_{\\mu i} S_{ij} C_{j\\nu} \\notag\\\\\n&= \\sum_i\\sum_j C^*_{i\\mu} \\Braket{\\phi_i| \\phi_j} C_{j\\nu} \\notag\\\\\n&= \\Braket{\\phi_\\mu | \\phi_\\nu} \\notag\\\\\n&= \\delta_{\\mu\\nu}\n\\end{align}\nthus\n\\begin{equation}\\label{key}\n\\vb{C}^\\dagger \\vb{S} \\vb{C} = \\iden\n\\end{equation}\n\n\\subsubsection{The Charge Density}\n\\ex{3.11}\n\\begin{align}\n\\rho(\\vb{r}) &= \\Braket{\\Psi_0 | \\hat{\\rho}(\\vb{r}) | \\Psi_0} \\notag\\\\\n&= \\sum_i^N \\dfrac{1}{N!} \\sum_I^{N!}\\sum_J^{N!} (-1)^{p_I} (-1)^{p_J} \\int \\dd \\vb{x}_1\\cdots \\dd \\vb{x}_N \\hsP_I\\{\\chi_1(1)\\cdots\\chi_N(N)\\}^* \\delta(\\vb{r}_i - \\vb{r}) \\hsP_J\\{\\chi_1(1)\\cdots\\chi_N(N)\\}\n\\end{align}\nSince $ \\{\\chi_m\\} $ are orthogonal,\n\\begin{align}\n\\rho(\\vb{r}) \n&= \\sum_i^N \\dfrac{1}{N!} \\sum_I^{N!} \\int \\dd \\vb{x}_1\\cdots \\dd \\vb{x}_N \\hsP_I\\{\\chi_1(1)\\cdots\\chi_N(N)\\}^* \\delta(\\vb{r}_i - \\vb{r}) \\hsP_I\\{\\chi_1(1)\\cdots\\chi_N(N)\\} \\notag\\\\\n&= \\sum_i^N \\dfrac{1}{N!} (N-1)!\\sum_s^N\\int \\dd \\vb{x}_i \\chi_s^*(\\vb{x}_i) \\delta(\\vb{r}_i - \\vb{r}) \\chi_s(\\vb{x}_i) \\notag\\\\\n&= \\sum_i^N \\dfrac{1}{N}\\cdot 2\\sum_s^{N/2}\\int \\dd \\vb{r}_i \\phi_s(\\vb{r}_i) \\delta(\\vb{r}_i - \\vb{r}) \\phi_s(\\vb{r}_i) \\notag\\\\\n&= \\sum_i^N \\dfrac{2}{N} \\sum_s^{N/2} \\phi_s(\\vb{r}) \\phi_s(\\vb{r}) \\notag\\\\\n&= N \\dfrac{2}{N} \\sum_s^{N/2} \\phi_s(\\vb{r}) \\phi_s(\\vb{r}) \\notag\\\\\n&= 2 \\sum_s^{N/2} \\phi_s(\\vb{r}) \\phi_s(\\vb{r}) \n\\end{align}\n\n\\ex{3.12}\nFrom Ex 3.10, we have\n\\begin{equation}\\label{key}\n\\vb{C}^\\dagger \\vb{S} \\vb{C} = \\iden\n\\end{equation}\ni.e.\n\\begin{equation}\\label{key}\n\\sum_i^K\\sum_j^K C^*_{i\\mu} S_{ij} C_{j\\nu} = \\delta_{\\mu\\nu}\n\\end{equation}\nthus\n\\begin{align}\n(\\vb{P}\\vb{S}\\vb{P})_{\\mu\\sigma} &= \\sum_\\nu^K\\sum_\\lambda^K P_{\\mu\\nu} S_{\\nu\\lambda} P_{\\lambda\\sigma} \\notag\\\\\n&= 4\\sum_\\nu^K\\sum_\\lambda^K \\sum_a^{N/2}C_{\\mu a}C_{\\nu a}^* S_{\\nu\\lambda} \\sum_b^{N/2}C_{\\lambda b}C_{\\sigma b}^* \\notag\\\\\n&= 4\\sum_a^{N/2}\\sum_b^{N/2} C_{\\mu a}\\qty(\\sum_\\nu^K\\sum_\\lambda^K C_{\\nu a}^* S_{\\nu\\lambda} C_{\\lambda b}) C_{\\sigma b}^* \\notag\\\\\n&= 4\\sum_a^{N/2}\\sum_b^{N/2}  C_{\\mu a} \\delta_{ab} C_{\\sigma b}^* \\notag\\\\\n&= 4\\sum_a^{N/2} C_{\\mu a} C_{\\sigma a}^* \\notag\\\\\n&= 2 P_{\\mu\\sigma}\n\\end{align}\nthus\n\\begin{equation}\\label{key}\n\\vb{P}\\vb{S}\\vb{P} = 2\\vb{P}\n\\end{equation}\n\n\\ex{3.13}\nEq. 3.122 shows\n\\begin{equation}\\label{key}\nf(\\vb{r}_1) = h(\\vb{r}_1) + \\sum_a^{N/2}\\int \\dd\\vb{r}_2 \\psi_a^*(\\vb{r}_2) (2-\\hsP_{12}) r_{12}^{-1} \\psi_a(\\vb{r}_2)\n\\end{equation}\nthus\n\\begin{align}\nf(\\vb{r}_1) &= h(\\vb{r}_1) \n+ \\sum_a^{N/2}\\int \\dd\\vb{r}_2 \n\\sum_\\sigma C_{\\sigma a}^* \\phi_\\sigma^*(\\vb{r}_2) (2-\\hsP_{12}) r_{12}^{-1} \\sum_\\lambda C_{\\lambda a} \\phi_\\lambda(\\vb{r}_2) \\notag\\\\\n&= h(\\vb{r}_1) \n+ \\sum_\\sigma\\sum_\\lambda \\qty(\\sum_a^{N/2} C_{\\sigma a}^*C_{\\lambda a} )\n\\int \\dd\\vb{r}_2 \\phi_\\sigma^*(\\vb{r}_2) (2-\\hsP_{12}) r_{12}^{-1}  \\phi_\\lambda(\\vb{r}_2) \\notag\\\\\n&= h(\\vb{r}_1) \n+ \\dfrac{1}{2} \\sum_{\\sigma,\\lambda} P_{\\lambda\\sigma}\n\\int \\dd\\vb{r}_2 \\phi_\\sigma^*(\\vb{r}_2) (2-\\hsP_{12}) r_{12}^{-1}  \\phi_\\lambda(\\vb{r}_2) \n\\end{align}\n\n\\subsubsection{Expression for the Fock Matrix}\n\\ex{3.14}\nIn expression $ (\\mu\\nu|\\lambda\\sigma) $, there are three interchangeable pairs, i.e. $\\mu\\leftrightarrow\\nu $, $ \\lambda\\leftrightarrow\\sigma $, and $ \\mu\\nu\\leftrightarrow\\lambda\\sigma $. Thus $ (\\mu\\nu|\\lambda\\sigma) $ has an 8-fold symmetry. Similarly, %$ ,  $ have 4-fold symmetry, \n$ (\\mu\\mu|\\lambda\\sigma), (\\mu\\nu|\\mu\\lambda), (\\mu\\nu|\\mu\\nu), (\\mu\\mu|\\sigma\\sigma) $ has 2-fold symmetry, and $ (\\mu\\mu|\\mu\\nu), (\\mu\\mu|\\mu\\mu) $ has 1-fold symmetry.\\\\\nTherefore, the number of unique 2e integrals is\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{ccc}\n\t\t\\hline\n\t\texpression & number & $ K=100 $\\\\ \\hline\n\t\t $ (\\mu\\nu|\\lambda\\sigma) $ & $ K(K-1)(K-2)(K-3)/8 $ & 11763675 \\\\\n\t\t $ (\\mu\\mu|\\lambda\\sigma)$ & $ K(K-1)(K-2)/2 $& 485100\\\\\n\t\t $ (\\mu\\nu|\\mu\\lambda)$ & $ K(K-1)(K-2)/2 $& 485100\\\\\n\t\t $ (\\mu\\nu|\\mu\\nu) $ & $ K(K-1)/2 $ & 4950\\\\\n\t\t $ (\\mu\\mu|\\sigma\\sigma) $ & $ K(K-1)/2 $ & 4950\\\\\n\t\t $ (\\mu\\mu|\\mu\\nu) $ & $ K(K-1) $ & 9900\\\\\n\t\t $ (\\mu\\mu|\\mu\\mu) $ & $ K $ & 100\\\\\n\t\t \\hline\n\t\\end{tabular}\n\\end{table}\nthus the total number is $ \\num{12753775} $.\n\n\\subsubsection{Orthogonalization of the Basis}\n\\ex{3.15}\n$ \\because $\n\\begin{equation}\\label{key}\n\\vb{U}^\\dagger \\vb{S} \\vb{U} = \\vb{s}\n\\end{equation}\n$ \\therefore $\n\\begin{equation}\\label{key}\n\\vb{S} \\vb{U} = \\vb{U} \\vb{s}\n\\end{equation}\ni.e.\n\\begin{equation}\\label{key}\n\\sum_\\nu S_{\\mu\\nu} U_{\\nu i} = U_{\\mu i} s_i\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\sum_\\mu U_{\\mu i}^* \\sum_\\nu S_{\\mu\\nu} U_{\\nu i} = \\sum_\\mu U_{\\mu i}^* U_{\\mu i} s_i\n\\end{equation}\n\\begin{equation}\\label{key}\n\\sum_\\mu \\sum_\\nu U_{\\mu i}^* \\Braket{\\phi_\\mu| \\phi_\\nu} U_{\\nu i} = s_i \\sum_\\mu \\abs{ U_{\\mu i}}^2 \n\\end{equation}\nSuppose\n\\begin{equation}\\label{key}\n\\phi'_i = \\sum_\\nu U_{\\nu i}\\phi_\\nu\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\Braket{\\phi'_i | \\phi'_i} = s_i \\sum_\\mu \\abs{ U_{\\mu i}}^2 \n\\end{equation}\n$ \\because $\n\\begin{equation}\\label{key}\n\\Braket{\\phi'_i | \\phi'_i} > 0 \\qquad \\abs{ U_{\\mu i}}^2 > 0\n\\end{equation}\n$ \\therefore $\n\\begin{equation}\\label{key}\ns_i > 0\n\\end{equation}\n\n\\ex{3.16}\n\\subex{$ \\bullet $} (3.174)\\\\\nSince ($ \\phi,\\phi',\\psi $ are row vectors)\n%\\begin{equation}\\label{key}\n%\\bm\\phi' = \\bm\\phi \\vb{X}\n%\\end{equation}\n\\begin{equation}\\label{key}\n\\bm\\psi = \\bm\\phi \\vb{C} \n\\end{equation}\n\\begin{equation}\\label{key}\n\\bm\\psi = \\bm\\phi' \\vb{C}' = \\bm\\phi \\vb{X} \\vb{C}'\n\\end{equation}\nwe have\n\\begin{equation}\\label{key}\n\\vb{C} = \\vb{X} \\vb{C}'\n\\end{equation}\ni.e.\n\\begin{equation}\\label{key}\n\\vb{C}' = \\vb{X}^{-1} \\vb{C}\n\\end{equation}\n\n\\subex{$ \\bullet $} (3.177)\n\\begin{align}\nF'_{\\mu\\nu} &= \\Braket{\\phi'_\\mu | f | \\phi'_\\nu} \\notag\\\\\n&= \\Braket{\\sum_i \\phi_i X_{i\\mu} | f | \\sum_j \\phi_j X_{j\\nu}} \\notag\\\\\n&= \\sum_i\\sum_j X^*_{i\\mu} X_{j\\nu} \\Braket{\\phi_i | f | \\phi_j} \\notag\\\\\n&= \\sum_i\\sum_j X^*_{i\\mu} F_{ij} X_{j\\nu} \n\\end{align}\ni.e.\n\\begin{equation}\\label{key}\n\\vb{F}' = \\vb{X}^\\dagger \\vb{F} \\vb{X}\n\\end{equation}\n\n\\subsubsection{The SCF Procedure}\n\n\\subsubsection{Expectation Values and Population Analysis}\n\\ex{3.17}\nFrom (3.148) in the textbook, we get\n\\begin{equation}\\label{key}\nF_{\\mu\\nu} = H_{\\mu\\nu}^{\\core} + G_{\\mu\\nu} = H_{\\mu\\nu}^{\\core} + \\sum_a^{N/2}[ 2(\\mu\\nu|aa) - (\\mu a| a\\nu)]\n\\end{equation}\nthus\n\\begin{align}\nE_0 &= \\sum_a^{N/2} [2 h_{aa} + \\sum_b^{N/2} (2 J_{ab} - K_{ab})] \\notag\\\\\n&= 2 \\sum_a^{N/2} (a|h|a) + \\sum_a^{N/2}\\sum_b^{N/2} [2 (aa|bb) - (ab|ba)] \\notag\\\\\n&= 2 \\sum_a^{N/2} \\sum_\\mu\\sum_\\nu C_{\\mu a}^* C_{\\nu a} (\\mu| h |\\nu) \n+ \\sum_a^{N/2}\\sum_b^{N/2} \\qty[2\\sum_\\mu\\sum_\\nu C_{\\mu a}^* C_{\\nu a} (\\mu\\nu|bb) - \\sum_\\mu\\sum_\\nu C_{\\mu a}^* C_{\\nu a} (\\mu b| b\\nu)] \\notag\\\\\n&= \\sum_\\mu\\sum_\\nu P_{\\nu\\mu} H_{\\mu\\nu}^{\\core} + \\dfrac{1}{2}\\sum_b^{N/2}\\sum_\\mu\\sum_\\nu[2 P_{\\nu\\mu}(\\mu\\nu|bb) - P_{\\nu\\mu}(\\mu b|b\\nu)] \\notag\\\\\n&= \\sum_\\mu\\sum_\\nu P_{\\nu\\mu} [H_{\\mu\\nu}^{\\core} + \\dfrac{1}{2}G_{\\mu\\nu}] \\notag\\\\\n&= \\dfrac{1}{2}\\sum_\\mu\\sum_\\nu P_{\\nu\\mu} [H_{\\mu\\nu}^{\\core} + F_{\\mu\\nu}] \\notag\\\\\n\\end{align}\n\n\\ex{3.18}\nFor symmetrically orthogonalized basis,\n\\begin{equation}\\label{key}\n\\vb{C}' = \\vb{S}^{1/2}\\vb{C}\n\\end{equation}\nthus\n\\begin{align}\nP'_{\\mu\\nu} &=  2\\sum_a^{N/2} C'_{\\mu a}C'^*_{\\nu a} \\notag\\\\\n&=  2\\sum_a^{N/2}  \\sum_i S^{1/2}_{\\mu i} C_{i a} \\sum_j S^{1/2*}_{\\nu j} C^*_{ja}  \\notag\\\\\n&=  \\sum_i\\sum_j  S^{1/2}_{\\mu i} \\qty( 2\\sum_a^{N/2} C_{i a} C^*_{ja} ) S^{1/2*}_{\\nu j}  \\notag\\\\\n&= \\sum_i\\sum_j  S^{1/2}_{\\mu i} P_{ij} S^{1/2*}_{\\nu j}  \\notag\\\\\n&= \\sum_i\\sum_j  S^{1/2}_{\\mu i} P_{ij} S^{1/2}_{j\\nu}\n\\end{align}\ni.e.\n\\begin{equation}\\label{key}\n\\vb{P}' = \\vb{S}^{1/2} \\vb{P} \\vb{S}^{1/2}\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\sum_\\mu (\\vb{S}^{1/2} \\vb{P} \\vb{S}^{1/2})_{\\mu\\mu} = \\sum_\\mu \\vb{P}'_{\\mu\\mu}\n\\end{equation}\n\n\\subsection{Model Calculations on \\ce{H_2} and \\ce{HeH^+}}\n\\subsubsection{The $ 1s $ Minimal STO-3G Basis Set}\n\\ex{3.19}\n\\begin{align}\n\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_A)\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_B) &= \\qty(\\dfrac{2\\alpha}{\\pi})^{3/4} \\e^{-\\alpha\\abs{\\vb{r}-\\vb{R}_A}^2} \\qty(\\dfrac{2\\beta}{\\pi})^{3/4} \\e^{-\\beta\\abs{\\vb{r}-\\vb{R}_B}^2} \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{\\pi})^{3/4} \\qty(\\dfrac{2\\beta}{\\pi})^{3/4} \\e^{-\\alpha\\abs{\\vb{r}-\\vb{R}_A}^2 - \\beta\\abs{\\vb{r}-\\vb{R}_B}^2} \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{\\pi})^{3/4} \\qty(\\dfrac{2\\beta}{\\pi})^{3/4} \\exp(-\\qty[(\\alpha+\\beta)\\abs{\\vb{r}}^2 \n\t- 2\\vb{r}\\cdot(\\alpha\\vb{R}_A + \\beta\\vb{R}_B) \n\t+ \\alpha\\abs{\\vb{R}_A}^2 +\\beta\\abs{\\vb{R}_B}^2])\n\\end{align}\nLet\n\\begin{equation}\\label{key}\np = \\alpha + \\beta \\qquad \\vb{R}_P = \\dfrac{\\alpha\\vb{R}_A + \\beta\\vb{R}_B} {\\alpha+\\beta}\n\\end{equation}\nwe have\n\\begin{align}\n\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_A)\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_B)\n&= \\qty(\\dfrac{2\\alpha}{\\pi}\\dfrac{\\beta}{\\pi})^{3/4} \n\\exp(-\\qty[p\\abs{\\vb{r}}^2 \n\t- 2\\vb{r}\\cdot(p\\vb{R}_P) \n\t+ \\alpha\\abs{\\vb{R}_A}^2 +\\beta\\abs{\\vb{R}_B}^2]) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{\\pi}\\dfrac{2\\beta}{\\pi})^{3/4} \n\\exp(-\\qty[p\\abs{\\vb{r} - \\vb{R}_P}^2 \n\t- p\\abs{\\vb{R}_P}^2\n\t+ \\alpha\\abs{\\vb{R}_A}^2 +\\beta\\abs{\\vb{R}_B}^2]) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha\\beta/p}{\\pi})^{3/4} \\qty(\\dfrac{2p}{\\pi})^{3/4} \n\\e^{-p\\abs{\\vb{r} - \\vb{R}_P}^2 }\n\\exp(p\\abs{\\vb{R}_P}^2 - \\alpha\\abs{\\vb{R}_A}^2 - \\beta\\abs{\\vb{R}_B}^2) \n\\end{align}\nLet\n\\begin{equation}\\label{key}\n\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_A)\\phi_{1s}^{\\GF}(\\alpha,\\vb{r}-\\vb{R}_B) = K_{AB} \\qty(\\dfrac{2p}{\\pi})^{3/4} \n\\e^{-p\\abs{\\vb{r} - \\vb{R}_P}^2 }\n\\end{equation}\nthus\n\\begin{align}\nK_{AB} &= \\qty(\\dfrac{2\\alpha\\beta/p}{\\pi})^{3/4} \n\\exp(p\\abs{\\vb{R}_P}^2 - \\alpha\\abs{\\vb{R}_A}^2 -\\beta\\abs{\\vb{R}_B}^2) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha\\beta/p}{\\pi})^{3/4} \n\\exp(\\dfrac{1}{p}(\n\\alpha^2\\abs{\\vb{R}_A}^2 +\\beta^2\\abs{\\vb{R}_B}^2 + 2\\alpha\\beta\\vb{R}_A\\cdot\\vb{R}_B )\n- \\alpha\\abs{\\vb{R}_A}^2 -\\beta\\abs{\\vb{R}_B}^2) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha\\beta/p}{\\pi})^{3/4} \n\\exp(\\dfrac{1}{p} \\qty(\\alpha^2\\abs{\\vb{R}_A}^2 +\\beta^2\\abs{\\vb{R}_B}^2 + 2\\alpha\\beta\\vb{R}_A\\cdot\\vb{R}_B \n- p\\alpha\\abs{\\vb{R}_A}^2 -p\\beta\\abs{\\vb{R}_B}^2)) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha\\beta/p}{\\pi})^{3/4} \n\\exp(\\dfrac{1}{p} \\qty(-\\alpha\\beta\\abs{\\vb{R}_A}^2 -\\alpha\\beta\\abs{\\vb{R}_B}^2 + 2\\alpha\\beta\\vb{R}_A\\cdot\\vb{R}_B )) \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha\\beta}{p\\pi})^{3/4} \n\\exp(-\\dfrac{\\alpha\\beta}{p} \\abs{\\vb{R}_A - \\vb{R}_B}^2 ) \n\\end{align}\n\n\\ex{3.20}\nAt $ r=0 $,\n\\begin{align}\n\\phi_{1s}^{\\text{CGF}}(\\zeta=1.0, \\text{STO-1G}) &= \\num{0.267656} \\\\\n\\phi_{1s}^{\\text{CGF}}(\\zeta=1.0, \\text{STO-2G}) &= \\num{0.389383} \\\\\n\\phi_{1s}^{\\text{CGF}}(\\zeta=1.0, \\text{STO-3G}) &= \\num{0.454986} \n\\end{align}\nwhile\n\\begin{equation}\\label{key}\n\\phi_{1s}^{\\text{SF}}(\\zeta=1.0) = \\dfrac{1}{\\sqrt{\\pi}} = \\num{0.56419}\n\\end{equation}\n\n\\subsubsection{STO-3G \\ce{H_2}}\n\\ex{3.21}\n\\begin{equation}\\label{key}\n\\phi_{1s}^{\\text{CGF}}(\\zeta=1.0, \\text{STO-1G}) = \\phi_{1s}^{\\text{GF}}(\\num{0.270950})\n\\end{equation}\nSince $ \\alpha = \\alpha_{(\\zeta=1.0)}\\cross \\zeta^2 $,\n\\begin{equation}\\label{key}\n\\phi_{1s}^{\\text{CGF}}(\\zeta=1.24, \\text{STO-1G}) = \\phi_{1s}^{\\text{GF}}(\\num{0.416613})\n\\end{equation}\nthus\n\\begin{align}\nS_{12} &= K_{AB} \\qty(\\dfrac{2\\cdot 2\\alpha}{\\pi})^{3/4} \\int \\dd\\vb{r} \\e^{-2\\alpha\\abs{\\vb{r}-\\vb{R}_P}^2} \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{2\\pi})^{3/4} \\e^{-\\tfrac{\\alpha}{2}R^2} \\qty(\\dfrac{2\\cdot 2\\alpha}{\\pi})^{3/4} \\int \\dd\\vb{r} \\e^{-2\\alpha\\abs{\\vb{r}-\\vb{R}_A}^2} \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{\\pi})^{3/2} \\e^{-\\tfrac{\\alpha}{2}R^2} 4\\pi \\int \\dd r r^2 \\e^{-2\\alpha r^2} \\notag\\\\\n&= \\qty(\\dfrac{2\\alpha}{\\pi})^{3/2} \\e^{-\\tfrac{\\alpha}{2}R^2} 4\\pi \\dfrac{\\sqrt{\\pi}}{8\\sqrt{2} \\alpha^{3/2}} \\notag\\\\\n&= \\e^{-\\tfrac{\\alpha}{2}R^2}  \n\\end{align}\nAt $ R = 1.4, \\alpha = \\num{0.416613} $,\n\\begin{equation}\\label{key}\nS_{12} = \\num{0.6648}\n\\end{equation}\n\n\\ex{3.22}\nLet \n\\begin{equation}\\label{key}\n\\psi_1 = c_1 (\\phi_1 + \\phi_2) \\qquad \\psi_2 = c_2 (\\phi_1 - \\phi_2)\n\\end{equation}\n\\begin{align}\n1 &= \\Braket{\\phi_1|\\psi_1} = c_1^2 (S_{11} + S_{12} + S_{21} + S_{22}) \\notag\\\\\n&= c_1^2 (2 + 2S_{12})\n\\end{align}\n$ \\therefore $\n\\begin{equation}\\label{key}\nc_1 = [2(1 + S_{12})]^{-1/2}\n\\end{equation}\n\\begin{align}\n1 &= \\Braket{\\phi_2|\\psi_2} = c_2^2 (S_{11} - S_{12} - S_{21} + S_{22}) \\notag\\\\\n&= c_2^2 (2 - 2S_{12})\n\\end{align}\n$ \\therefore $\n\\begin{equation}\\label{key}\nc_2 = [2(1 - S_{12})]^{-1/2}\n\\end{equation}\n\n\\ex{3.23}\nSuppose\n\\begin{equation}\\label{key}\n\\psi_1 = c_1 (\\phi_1 + \\phi_2) \\qquad \\psi_2 = c_2 (\\phi_1 - \\phi_2)\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\vb{H}^{\\core} \\vb{C} = \\vb{S} \\vb{C} \\bm\\varepsilon\n\\end{equation}\n\\begin{equation}\\label{key}\n\\mqty(H_{11}^{\\core} & H_{12}^{\\core}\\\\ H_{21}^{\\core} & H_{22}^{\\core}) \\mqty(c_1 & c_2\\\\ c_1 & -c_2) = \\mqty(S_{11} & S_{12}\\\\ S_{21} & S_{22}) \\mqty(c_1 & c_2\\\\ c_1 & -c_2) \\mqty(\\varepsilon_1 & 0\\\\ 0 &\\varepsilon_2 ) \n\\end{equation}\n\\begin{equation}\\label{key}\n\\mqty((H_{11}^{\\core} + H_{12}^{\\core}) c_1 & (H_{11}^{\\core} - H_{12}^{\\core}) c_2 \\\\ \n(H_{21}^{\\core} + H_{22}^{\\core}) c_1 & (H_{21}^{\\core} - H_{22}^{\\core})c_2)\n= \\mqty((S_{11} + S_{12}) c_1\\varepsilon_1 & (S_{11} - S_{12}) c_2\\varepsilon_2\\\\\n(S_{21} + S_{22}) c_1\\varepsilon_1 & (S_{21} - S_{22}) c_2\\varepsilon_2)\n\\end{equation}\n$ \\therefore $\n\\begin{equation}\\label{key}\n\\left\\{ \\mqty{\\varepsilon_1 = (H_{11}^{\\core} + H_{12}^{\\core})/(1 + S_{12}) \\\\\n\\varepsilon_2 = (H_{11}^{\\core} - H_{12}^{\\core})/(1 - S_{12})}\n\\right.\n\\end{equation}\n\\begin{align}\n\\varepsilon_1 = (-1.1204-0.9584)/(1+0.6593) = -1.2528\\\\\n\\varepsilon_2 = (-1.1204+0.9584)/(1-0.6593) = -0.4755\n\\end{align}\n\n\\ex{3.24}\n\\begin{equation}\\label{key}\nP_{\\mu\\nu} = 2\\sum_a^{N/2} C_{\\mu a}C_{\\nu a}^* = 2 C_{\\mu 1}C_{\\nu 1}^*\n\\end{equation}\n$ \\therefore $\n\\begin{align}\n\\vb{P} &= 2 \\mqty( C_{11}C_{11}^* & C_{11}C_{21}^*\\\\\n                   C_{21}C_{11}^* & C_{21}C_{21}^*) \\notag\\\\\n&= 2 \\mqty([2(1+S_{12})]^{-1/2}[2(1+S_{12})]^{-1/2} & [2(1+S_{12})]^{-1/2}[2(1+S_{12})]^{-1/2} \\\\ [2(1+S_{12})]^{-1/2}[2(1+S_{12})]^{-1/2} & [2(1+S_{12})]^{-1/2}[2(1+S_{12})]^{-1/2} ) \\notag\\\\\n&= (1+S_{12})^{-1} \\mqty(1 & 1 \\\\ 1 & 1)\n\\end{align}\nFor $ \\ce{H_2^+} $,\n\\begin{equation}\\label{key}\n\\vb{P}_{\\ce{H_2^+}} = \\dfrac{1}{2} (1+S_{12})^{-1} \\mqty(1 & 1 \\\\ 1 & 1)\n\\end{equation}\n\n\\ex{3.25}\n\\begin{align}\nF_{\\mu\\nu} &= H^{\\core}_{\\mu\\nu} + \\sum_{\\lambda\\sigma} P_{\\lambda\\sigma} \\qty[(\\mu\\nu|\\sigma\\lambda) - \\dfrac{1}{2}(\\mu\\lambda|\\sigma\\nu)] \\notag\\\\\n&= H^{\\core}_{\\mu\\nu} + (1+S_{12})^{-1} \\sum_{\\lambda\\sigma} \\qty[(\\mu\\nu|\\sigma\\lambda) - \\dfrac{1}{2}(\\mu\\lambda|\\sigma\\nu)] %\\notag\\\\\n%&= H^{\\core}_{\\mu\\nu} + (1+S_{12})^{-1} \n%\\qty[(\\mu\\nu|11) - \\dfrac{1}{2}(\\mu 1|1 \\nu) \n%+ (\\mu\\nu|21) - \\dfrac{1}{2}(\\mu 1|2 \\nu)\n%+ (\\mu\\nu|12) - \\dfrac{1}{2}(\\mu 2|1 \\nu)\n%+ (\\mu\\nu|22) - \\dfrac{1}{2}(\\mu 2|2 \\nu)] \\notag\\\\\n\\end{align}\n$ \\therefore $\n\\begin{align}\nF_{11} &= H^{\\core}_{11} + (1+S_{12})^{-1} \n\\qty[(11|11) - \\dfrac{1}{2}(1 1|1 1) \n+ (11|21) - \\dfrac{1}{2}(1 1|2 1)\n+ (11|12) - \\dfrac{1}{2}(1 2|1 1)\n+ (11|22) - \\dfrac{1}{2}(1 2|2 1)] \\notag\\\\\n&= H^{\\core}_{11} + (1+S_{12})^{-1} \n\\qty[\\dfrac{1}{2}(1 1|1 1) + (1 1|2 1) + (11|22) - \\dfrac{1}{2}(1 2|2 1)] \n\\end{align}\n\\iffalse\n\\begin{align}\nF_{22} &= H^{\\core}_{22} + (1+S_{12})^{-1} \n\\qty[(22|11) - \\dfrac{1}{2}(2 1|1 2) \n+ (22|21) - \\dfrac{1}{2}(2 1|2 2)\n+ (22|12) - \\dfrac{1}{2}(2 2|1 2)\n+ (22|22) - \\dfrac{1}{2}(2 2|2 2)] \\notag\\\\\n&= H^{\\core}_{22} + (1+S_{12})^{-1} \n\\qty[(22|11) - \\dfrac{1}{2}(2 1|1 2) \n+ (22|21) \n+ \\dfrac{1}{2}(2 2|2 2)] \\notag\\\\\n&= H^{\\core}_{11} + (1+S_{12})^{-1} \n\\qty[(11|22) - \\dfrac{1}{2}(1 2|2 1) \n+ (11|12) \n+ \\dfrac{1}{2}(11|11)] \n\\end{align}\n\\fi\n\\begin{align}\nF_{11} = F_{22} &= -1.1204 + (1 + 0.6593)^{-1} \\qty(\\dfrac{1}{2}\\times 0.7746 + 0.4441 + 0.5697 -\\dfrac{1}{2}\\times 0.2970) \\notag\\\\\n&= -0.3655\n\\end{align}\n\n\\begin{align}\nF_{12} &= H^{\\core}_{12} + (1+S_{12})^{-1} \n\\qty[(12|11) - \\dfrac{1}{2}(1 1|1 2) \n+ (12|21) - \\dfrac{1}{2}(1 1|22)\n+ (12|12) - \\dfrac{1}{2}(1 2|1 2)\n+ (12|22) - \\dfrac{1}{2}(1 2|2 2)] \\notag\\\\\n&= H^{\\core}_{12} + (1+S_{12})^{-1} \n\\qty[ (1 1|1 2) \n - \\dfrac{1}{2}(1 1|22)\n+  \\dfrac{3}{2}(1 2|1 2)] \n\\end{align}\n\\begin{align}\nF_{12} = F_{21} &= -0.9584 + (1 + 0.6593)^{-1} \\qty(0.4441 - \\dfrac{1}{2}\\times 0.5697 + \\dfrac{3}{2}\\times 0.2970) \\notag\\\\\n&= -0.5939\n\\end{align}\n\n\\ex{3.26}\nSimilar to the procedure in Ex 3.23, we get\n\\begin{align}\n\\varepsilon_1 &= \\dfrac{F_{11} + F_{12}}{1 + S_{12}} = \\dfrac{-0.3655 -0.5939}{1 + 0.6593} = -0.5782 \\\\\n\\varepsilon_2 &= \\dfrac{F_{11} - F_{12}}{1 - S_{12}} = \\dfrac{-0.3655 +0.5939}{1 - 0.6593} = 0.6703\n\\end{align}\n\n\\ex{3.27}\n\\begin{align}\nE_0 &= \\sum_{\\mu\\nu} \\dfrac{1}{2}P_{\\nu\\mu} (H^{\\core}_{\\mu\\nu} + F_{\\mu\\nu}) \\notag\\\\\n&= \\dfrac{1}{2}\\dfrac{1}{1 + S_{12}} \\qty(H^{\\core}_{11} + F_{11} + H^{\\core}_{12} + F_{12} + H^{\\core}_{21} + F_{21} + H^{\\core}_{22} + F_{22}) \\notag\\\\\n&= \\dfrac{H^{\\core}_{11} + F_{11} + H^{\\core}_{12} + F_{12}}{1 + S_{12}} \\notag\\\\\n&= \\dfrac{-1.1204 -0.3655 - 0.9584 - 0.5939}{1 + 0.6593} \\notag\\\\\n&= -1.8310\n\\end{align}\n\\begin{equation}\\label{key}\nE_{tot} = E_0 + \\dfrac{1}{R} = -1.1167\n\\end{equation}\n\n\\subsubsection{An SCF Calculation on STO-3G \\ce{HeH^+}}\n\\ex{3.28}\n\\begin{align}\n\\vb{X}^\\dagger_{\\text{Schmidt}} \\vb{S} \\vb{X}_{\\text{Schmidt}} &= \\mqty(1 & 0 \\\\ -S_{12}/\\sqrt{1-S_{12}^2} & 1/\\sqrt{1-S_{12}^2}) \n\\mqty(1 & S_{12} \\\\ S_{12} & 1) \n\\mqty(1 & -S_{12}/\\sqrt{1-S_{12}^2}\\\\ 0 & 1/\\sqrt{1-S_{12}^2}) \\notag\\\\\n&= \\mqty(1 & S_{12} \\\\ 0 & \\sqrt{1-S_{12}^2}) \n\\mqty(1 & -S_{12}/\\sqrt{1-S_{12}^2}\\\\ 0 & 1/\\sqrt{1-S_{12}^2}) \\notag\\\\\n&= \\mqty(1 & 0\\\\ 0 & 1)\n\\end{align}\nthus the Schmidt transformation produces orthonormal basis.\n\n\\ex{3.29}\n\\begin{align}\nE_0(R\\ra \\infty) &= \\dfrac{1}{2}\\sum_\\mu\\sum_\\nu P_{\\nu\\mu}(R\\ra \\infty) [2H_{\\mu\\nu}^{\\core} + G_{\\mu\\nu}] \n\\end{align}\nwhere\n\\begin{equation}\\label{key}\nP_{\\nu\\mu}(R\\ra \\infty) = \\mqty( 2 & 0\\\\ 0 & 0)\n\\end{equation}\n\\begin{align}\\label{key}\nG_{\\mu\\nu} &= \\sum_\\lambda\\sum_\\sigma P_{\\lambda\\sigma}(R\\ra\\infty) \\qty[(\\mu\\nu|\\sigma\\lambda) - \\dfrac{1}{2}(\\mu\\lambda|\\sigma\\nu)] \\notag\\\\\n&= 2\\qty[(\\mu\\nu|\\phi_1\\phi_1) - \\dfrac{1}{2}(\\mu\\phi_1|\\phi_1\\nu)]\n\\end{align}\nthus\n\\begin{align}\nE_0(R\\ra \\infty) &= \\dfrac{1}{2}\\sum_\\mu\\sum_\\nu P_{\\nu\\mu}(R\\ra \\infty) [2H_{\\mu\\nu}^{\\core} + G_{\\mu\\nu}] \\notag\\\\\n&= \\dfrac{1}{2}\\times 2[2H_{11}^{\\core} + G_{11}] \\notag\\\\\n&= 2(T_{11} + V^1_{11}) + 2\\qty[(\\phi_1\\phi_1|\\phi_1\\phi_1) - \\dfrac{1}{2}(\\phi_1\\phi_1|\\phi_1\\phi_1)] \\notag\\\\\n&= 2T_{11} + 2V^1_{11} + (\\phi_1\\phi_1|\\phi_1\\phi_1) \n\\end{align}\n\n\\subsection{Polyatomic Basis Sets}\n\\subsubsection{Contracted Gaussian Functions}\n\\subsubsection{Minimal Basis Sets: STO-3G}\n\\subsubsection{Double Zeta Basis Sets: 4-31G}\n\\ex{3.30}\nThe outer basis function\n\\begin{equation}\\label{key}\n\\phi''_{1s}(\\vb{r}) = g_{1s}(0.298073, \\vb{r})\n\\end{equation}\nThe inner basis function\n\\begin{equation}\\label{key}\n\\phi'_{1s}(\\vb{r}) = N[0.46954 g_{1s}(1.242567, \\vb{r}) \n+ 0.15457 g_{1s}(5.782948, \\vb{r}) + 0.02373 g_{1s}(38.47497, \\vb{r})]\n\\end{equation}\nRenormalize it, we get\n\\begin{equation}\\label{key}\nN = 1.689\n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\phi'_{1s}(\\vb{r}) = 0.79330 g_{1s}(1.242567, \\vb{r}) \n+ 0.26115 g_{1s}(5.782948, \\vb{r}) + 0.04009 g_{1s}(38.47497, \\vb{r})\n\\end{equation}\n\n\\subsubsection{Polarized Basis Sets: 6-31G* and 6-31G**}\n\\ex{3.31}\n~\\\\\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{cccc}\n\t\t\\hline\n\t\t & C & H & total\\\\ \\hline\n\t\tSTO-3G & 5 & 1 & 36\\\\\n\t\t4-31G & 9 & 2 & 66\\\\\n\t\t6-31G* (Cartesian) & 15 & 2 & 102\\\\\n\t\t6-31G** (Cartesian) & 15 & 5 & 120\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\n\\subsection{Some Illustrative Closed-shell Calculations}\n\\subsubsection{Total Energies}\n\\ex{3.32}~\\\\\nReaction I\n\\begin{table}[H]\n\t\\begin{tabular}{ccc|c}\n\t\t\\hline\n\t\tbasis & $ \\Delta E /  $ a.u.& $ \\Delta E /(\\si{kcal/mol}) $& \\\\\n\t\t\\hline\n\t\tSTO-3G   & -0.061 & -38.28 &\\\\\n\t\t4-31G    & -0.069 & -43.30 &\\\\\n\t\t6-31G*   & -0.045 & -28.24 & exoergic\\\\ \n\t\t6-31G**  & -0.055 &\t-34.51 & \\\\\n\t\tHF-limit & -0.051 & -32.00 &\\\\\n\t\t\\hline\t\t\n\t\\end{tabular}\n\\end{table}\nReaction II\n\\begin{table}[H]\n\t\\begin{tabular}{ccc|c}\n\t\t\\hline\n\t\tbasis & $ \\Delta E /  $ a.u.& $ \\Delta E /(\\si{kcal/mol}) $ &\\\\\n\t\t\\hline\n\t\tSTO-3G   &  0.186 &\t116.72 & endoergic\t\\\\ \\cline{4-4}\n\t\t4-31G    & -0.114 &\t-71.54 & \\multirow{4}{*}{exoergic}\\\\\n\t\t6-31G*   & -0.088 &\t-55.22 &\\\\\n\t\t6-31G**  & -0.095 &\t-59.61 &\\\\\n\t\tHF-limit & -0.097 &\t-60.87 &\\\\\n\t\t\\hline\t\n\t\\end{tabular}\n\\end{table}\nThe contribution of zero-point vibrations to the energy change of reaction I would be $ \\SI{-0.37}{kcal/mol} $, to the energy change of reaction II would be $ \\SI{17.78}{kcal/mol} $. Thus the effect of zero-point vibrations should not be ignored.\n\n\\subsubsection{Ionization Potentials}\n\n\\subsubsection{Equilibrium Geometries}\n\n\\subsubsection{Population Analysis and Dipole Moments}\n\n\\subsection{Unrestricted Open-shell HF: The Pople-Nesbet Equations}\n\\subsubsection{Open-shell HF: Unrestricted Spin Orbitals}\n\\ex{3.33}\n\\begin{align}\nf^\\alpha(1) &= \\int\\dd\\omega_1 \\alpha^*(\\omega_1) \n\\qty[h(1) + \\sum_a\\int\\dd\\vb{x}_2 \\chi_a^*(2)r_{12}^{-1}(1-\\hsP_{12})\\chi_a(2)] \\alpha(\\omega_1) \\notag\\\\\n&= h(1) + \\sum_a^{N_\\alpha} \n\\qty[ \\int\\dd\\omega_1 \\alpha^*(\\omega_1) \\int\\dd\\vb{x}_2 \\chi_a^*(2)r_{12}^{-1}\\chi_a(2) \\alpha(\\omega_1) \n - \\int\\dd\\omega_1 \\alpha^*(\\omega_1) \\int\\dd\\vb{x}_2 \\chi_a^*(2)r_{12}^{-1}\\chi_a(1) \\alpha(\\omega_2) ] \\notag\\\\\n&\\quad {} + \\sum_a^{N_\\beta}\n\\qty[ \\int\\dd\\omega_1 \\alpha^*(\\omega_1) \\int\\dd\\vb{x}_2 \\chi_a^*(2)r_{12}^{-1}\\chi_a(2) \\alpha(\\omega_1) \n-  \\int\\dd\\omega_1 \\alpha^*(\\omega_1) \\int\\dd\\vb{x}_2 \\chi_a^*(2)r_{12}^{-1}\\chi_a(1) \\alpha(\\omega_2) ]  \\notag\\\\\n&= h(1) + \\sum_a^{N_\\alpha}\n\\qty[\\int\\dd\\vb{r}_2 \\psi_a^{\\alpha*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^\\alpha(\\vb{r}_2)\n- \\int\\dd\\vb{r}_2\\int\\dd\\omega_2\\int\\dd\\omega_1 \n\\alpha^*(\\omega_1)\\alpha^*(\\omega_2) \\psi_a^{\\alpha*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^{\\alpha}(\\vb{r}_1) \\alpha(\\omega_1) \\alpha(\\omega_2) ] \\notag\\\\\n&\\quad {} + \\sum_a^{N_\\beta}\\qty[\\int\\dd\\vb{r}_2 \\psi_a^{\\beta*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^\\beta(\\vb{r}_2)\n- \\int\\dd\\vb{r}_2\\int\\dd\\omega_2\\int\\dd\\omega_1 \n\\alpha^*(\\omega_1)\\beta^*(\\omega_2) \\psi_a^{\\beta*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^{\\beta}(\\vb{r}_1) \\beta(\\omega_1) \\alpha(\\omega_2) ]  \\notag\\\\\n&= h(1) + \\sum_a^{N_\\alpha}\n\\qty[\\int\\dd\\vb{r}_2 \\psi_a^{\\alpha*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^\\alpha(\\vb{r}_2)\n- \\int\\dd\\vb{r}_2 \\psi_a^{\\alpha*}(\\vb{r}_2) r_{12}^{-1} \\psi_a^{\\alpha}(\\vb{r}_1) ] \n+ \\sum_a^{N_\\beta} \\qty[\\int\\dd\\vb{r}_2 \\psi_a^{\\beta*}(\\vb{r}_2)r_{12}^{-1} \\psi_a^\\beta(\\vb{r}_2) - 0 ]  \\notag\\\\\n&= h(1) + \\sum_a^{N_\\alpha}\\qty[J_a^\\alpha(1) - K_a^{\\alpha}(1) ] + \\sum_a^{N_\\beta} J_a^\\beta(1) \n\\end{align}\n\n\\ex{3.34}\n\\begin{align}\nE_0 &= \\sum_a h_{aa} + \\dfrac{1}{2}\\sum_a^{N_\\alpha}\\sum_b^{N_\\alpha} (J_{ab}^{\\alpha\\alpha} - K_{ab}^{\\alpha\\alpha}) \n%+ \\dfrac{1}{2}\\sum_a^{N_\\beta}\\sum_b^{N_\\beta} (J_{ab}^{\\beta\\beta} - K_{ab}^{\\beta\\beta}) \n+ \\sum_a^{N_\\alpha}\\sum_b^{N_\\beta} J_{ab}^{\\alpha\\beta} \\notag\\\\\n&= h_{11}^\\alpha + h_{22}^\\alpha + h_{11}^\\alpha + J_{12}^{\\alpha\\alpha} - K_{12}^{\\alpha\\alpha} + J_{11}^{\\alpha\\beta} + J_{21}^{\\alpha\\beta}\n\\end{align}\n\n\\ex{3.35}\n\\begin{align}\n\\varepsilon_i^\\alpha &= (\\psi_i^\\alpha(1) | h(1) + \\sum_a^{N_\\alpha}\\qty[J_a^\\alpha(1) - K_a^{\\alpha}(1) ] + \\sum_a^{N_\\beta} J_a^\\beta(1) | \\psi_i^\\alpha(1)) \\notag\\\\\n&= h_{ii}^\\alpha + \\sum_a^{N_\\alpha}\\qty[J_{ia}^{\\alpha\\alpha} - K_{ia}^{\\alpha\\alpha}] + \\sum_a^{N_\\beta} J_{ia}^{\\alpha\\beta}\n\\end{align}\n\\begin{align}\n\\varepsilon_i^\\beta &= (\\psi_i^\\beta(1) | h(1) + \\sum_a^{N_\\alpha}\\qty[J_a^\\beta(1) - K_a^{\\beta}(1) ] + \\sum_a^{N_\\beta} J_a^\\alpha(1) | \\psi_i^\\beta(1)) \\notag\\\\\n&= h_{ii}^\\beta + \\sum_a^{N_\\alpha}\\qty[J_{ia}^{\\beta\\beta} - K_{ia}^{\\beta\\beta}] + \\sum_a^{N_\\beta} J_{ia}^{\\beta\\alpha}\n\\end{align}\nSince\n\\begin{equation}\\label{key}\nE_0 = \\sum_a h_{aa} + \\dfrac{1}{2}\\sum_a^{N_\\alpha}\\sum_b^{N_\\alpha} (J_{ab}^{\\alpha\\alpha} - K_{ab}^{\\alpha\\alpha}) + \\dfrac{1}{2}\\sum_a^{N_\\beta}\\sum_b^{N_\\beta} (J_{ab}^{\\beta\\beta} - K_{ab}^{\\beta\\beta}) \n+ \\sum_a^{N_\\alpha}\\sum_b^{N_\\beta} J_{ab}^{\\alpha\\beta}\n\\end{equation}\nwe have\n\\begin{align}\nE_0 = \\sum_i^{N_\\alpha} \\varepsilon_i^\\alpha \n+ \\sum_i^{N_\\beta} \\varepsilon_i^\\beta \n- \\dfrac{1}{2}\\sum_i^{N_\\alpha}\\sum_a^{N_\\alpha} (J_{ia}^{\\alpha\\alpha} - K_{ia}^{\\alpha\\alpha}) \n- \\dfrac{1}{2}\\sum_i^{N_\\beta}\\sum_a^{N_\\beta} (J_{ia}^{\\beta\\beta} - K_{ia}^{\\beta\\beta}) \n- \\sum_i^{N_\\beta}\\sum_a^{N_\\alpha} J_{ia}^{\\beta\\alpha}\n\\end{align}\n\n\\subsubsection{Introduction of a Basis: The Pople-Nesbet Equations}\n\n\\subsubsection{Unrestricted Density Matrices}\n\\ex{3.36}\n\\begin{align}\n\\int\\dd\\vb{r} \\rho^S(\\vb{r}) &= \\int\\dd\\vb{r} \\qty[\\rho^\\alpha(\\vb{r}) - \\rho^\\beta(\\vb{r})] \\\\\n&= N_\\alpha - N_\\beta\n\\end{align}\nSince\n\\begin{equation}\\label{key}\n\\ev{\\hsS_z} = \\dfrac{1}{2}(N_\\alpha - N_\\beta)\n\\end{equation}\nwe get\n\\begin{equation}\\label{key}\n\\int\\dd\\vb{r} \\rho^S(\\vb{r}) = 2\\ev{\\hsS_z}\n\\end{equation}\n\n\\ex{3.37}\n\\begin{align}\n\\rho^\\alpha(\\vb{r}) &= \\sum_a^{N_\\alpha}  \\psi_a^{\\alpha*}(\\vb{r})\\psi_a^\\alpha(\\vb{r}) \\notag\\\\\n&=  \\sum_a^{N_\\alpha} \\sum_\\nu C^{\\alpha*}_{\\nu a}\\phi_\\nu^*(\\vb{r}) \n\\sum_\\mu C_{\\mu a}^\\alpha\\phi_\\mu(\\vb{r}) \\notag\\\\\n&= \\sum_\\nu\\sum_\\mu \\qty[\\sum_a^{N_\\alpha} C^{\\alpha*}_{\\nu a}C_{\\mu a}^\\alpha ] \\phi_\\nu^*(\\vb{r})\\phi_\\mu(\\vb{r}) \\notag\\\\\n\\end{align}\nLet\n\\begin{equation}\\label{key}\nP^\\alpha_{\\mu\\nu} = \\sum_a^{N_\\alpha} C^{\\alpha*}_{\\nu a}C_{\\mu a}^\\alpha \n\\end{equation}\nthus\n\\begin{equation}\\label{key}\n\\rho^\\alpha(\\vb{r}) = \\sum_\\nu\\sum_\\mu P^\\alpha_{\\mu\\nu} \\phi_\\mu(\\vb{r}) \\phi_\\nu^*(\\vb{r})\n\\end{equation}\nThe formulation for $ \\beta $ spin is similar.\n\n\\ex{3.38}\n\\begin{align}\n\\ev{\\mathscr{O}_1} &= \\sum_i^N \\Braket{\\chi_i | h | \\chi_i} \\notag\\\\\n&= \\sum_i^{N_\\alpha} (\\psi_i^\\alpha | h | \\psi_i^\\alpha) + \\sum_i^{N_\\beta} (\\psi_i^\\beta | h | \\psi_i^\\beta) \\notag\\\\\n&= \\sum_i^{N_\\alpha} \\sum_\\nu\\sum_\\mu C_{\\nu a}^{\\alpha*} (\\phi_\\nu | h | \\phi_\\mu) C_{\\mu a}^\\alpha \n+ \\sum_i^{N_\\beta} \\sum_\\nu\\sum_\\mu C_{\\nu a}^{\\beta*} (\\phi_\\nu | h | \\phi_\\mu) C_{\\mu a}^\\beta \\notag\\\\\n&= \\sum_\\nu\\sum_\\mu P_{\\mu\\nu}^\\alpha (\\phi_\\nu | h | \\phi_\\mu) \n+ \\sum_\\nu\\sum_\\mu P_{\\mu\\nu}^\\beta (\\phi_\\nu | h | \\phi_\\mu)  \\notag\\\\\n&= \\sum_\\nu\\sum_\\mu P_{\\mu\\nu}^T (\\phi_\\nu | h | \\phi_\\mu) \n\\end{align}\n\n\\ex{3.39}\n\\begin{align}\n\\ev{\\hat\\rho^S} &= \\Braket{\\Psi_0 | \\hat\\rho^S | \\Psi_0} \\notag\\\\\n&= \\dfrac{1}{N!}\\sum_{i,j}^{N!} (-1)^{p_i}(-1)^{p_j} \\int\\dd\\vb{x}_1\\cdots\\dd\\vb{x}_N \\hsP_i\\{\\chi_1(1)\\cdots\\chi_N(N)\\} \\sum_m^N 2\\delta(\\vb{r}_m - \\vb{R})s_z(m) \\hsP_j\\{\\chi_1(1)\\cdots\\chi_N(N)\\} \\notag\\\\\n&= \\dfrac{2}{N!}\\sum_{i}^{N!} \\sum_m^N  \\int\\dd\\vb{x}_1\\cdots\\dd\\vb{x}_N \\hsP_i\\{\\chi_1(1)\\cdots\\chi_N(N)\\} \\delta(\\vb{r}_m - \\vb{R})s_z(m) \\hsP_i\\{\\chi_1(1)\\cdots\\chi_N(N)\\} \\notag\\\\\n&= \\dfrac{2}{N}\\sum_{s}^{N} \\sum_m^N  \\int\\dd\\vb{x}_m \\chi_s^*(m) \\delta(\\vb{r}_m - \\vb{R})s_z(m) \\chi_s(m) \\notag\\\\\n&= \\dfrac{2}{N}\\sum_m^N  \\qty[ \\sum_{s}^{N_\\alpha} \\int\\dd\\vb{r}_m \\psi_s^{\\alpha*}(m) \\delta(\\vb{r}_m - \\vb{R})s_z(m) \\psi_s^\\alpha(m) \n+ \\sum_{s}^{N_\\beta} \\int\\dd\\vb{r}_m \\psi_s^{\\beta*}(m) \\delta(\\vb{r}_m - \\vb{R})s_z(m) \\psi_s^\\beta(m) ] \\notag\\\\\n&= \\dfrac{2}{N}\\sum_m^N  \\qty[ \\dfrac{1}{2}\\sum_{s}^{N_\\alpha} \\int\\dd\\vb{r}_m \\psi_s^{\\alpha*}(m) \\delta(\\vb{r}_m - \\vb{R}) \\psi_s^\\alpha(m) \n- \\dfrac{1}{2}\\sum_{s}^{N_\\beta} \\int\\dd\\vb{r}_m \\psi_s^{\\beta*}(m) \\delta(\\vb{r}_m - \\vb{R}) \\psi_s^\\beta(m) ] \\notag\\\\\n&= \\dfrac{2}{N}N  \\qty[ \\dfrac{1}{2}\\sum_{s}^{N_\\alpha} \\psi_s^{\\alpha*}(\\vb{R})\\psi_s^\\alpha(\\vb{R}) \n- \\dfrac{1}{2}\\sum_{s}^{N_\\beta} \\psi_s^{\\beta*}(\\vb{R})\\psi_s^\\beta(\\vb{R}) ] \\notag\\\\\n&= 2 \\qty[ \\dfrac{1}{2} \\rho^\\alpha(\\vb{R}) \n- \\dfrac{1}{2}\\rho^\\beta(\\vb{R}) ] \\notag\\\\\n&= \\rho^S(\\vb{R})\n\\end{align}\nwhere\n\\begin{align}\n\\rho^S(\\vb{R}) &= \\sum_\\nu\\sum_\\mu P^S_{\\nu\\mu} \\phi_\\mu^*(\\vb{R})\\phi_\\nu(\\vb{R}) \\notag\\\\\n&= \\sum_\\nu (\\vb{P}^S\\vb{A})_{\\nu\\nu} \\notag\\\\\n&= \\tr(\\vb{P}^S\\vb{A})\n\\end{align}\n\n\\subsubsection{Expression for the Fock Matrices}\n\n\\subsubsection{Solution of the Unrestricted SCF Equations}\n\\ex{3.40}\n\\begin{align}\nE_0 &= \\sum_a^{N_\\alpha} h_{aa}^\\alpha + \\sum_a^{N_\\beta} h_{aa}^\\beta + \\dfrac{1}{2}\\sum_a^{N_\\alpha}\\sum_b^{N_\\alpha} (J_{ab}^{\\alpha\\alpha} - K_{ab}^{\\alpha\\alpha}) + \\dfrac{1}{2}\\sum_a^{N_\\beta}\\sum_b^{N_\\beta} (J_{ab}^{\\beta\\beta} - K_{ab}^{\\beta\\beta}) \n+ \\sum_a^{N_\\alpha}\\sum_b^{N_\\beta} J_{ab}^{\\alpha\\beta} \\notag\\\\\n&= \\sum_\\mu\\sum_\\nu P^\\alpha_{\\nu\\mu}H^{\\core}_{\\mu\\nu} + \\sum_\\mu\\sum_\\nu P^\\beta_{\\nu\\mu}H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2}\\sum_\\mu\\sum_\\nu\\sum_\\lambda\\sum_\\sigma P^\\alpha_{\\nu\\mu}P^\\alpha_{\\sigma\\lambda} [(\\mu\\nu|\\lambda\\sigma) - (\\mu\\sigma|\\lambda\\nu)] \\notag\\\\\n&\\quad{} + \\dfrac{1}{2}\\sum_\\mu\\sum_\\nu\\sum_\\lambda\\sum_\\sigma P^\\beta_{\\nu\\mu}P^\\beta_{\\sigma\\lambda} [(\\mu\\nu|\\lambda\\sigma) - (\\mu\\sigma|\\lambda\\nu)] + \\sum_\\mu\\sum_\\nu\\sum_\\lambda\\sum_\\sigma P^\\alpha_{\\nu\\mu}P^\\beta_{\\sigma\\lambda} (\\mu\\nu|\\lambda\\sigma) \\notag\\\\\n&= \\sum_\\mu\\sum_\\nu P^\\alpha_{\\nu\\mu} \\qty{H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma P^\\alpha_{\\sigma\\lambda} [(\\mu\\nu|\\lambda\\sigma) - (\\mu\\sigma|\\lambda\\nu)] \n+ \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma P^\\beta_{\\sigma\\lambda} (\\mu\\nu|\\lambda\\sigma)}      \\notag\\\\\n&\\quad{} + \\sum_\\mu\\sum_\\nu P^\\beta_{\\nu\\mu} \\qty{ H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma P^\\beta_{\\sigma\\lambda} [(\\mu\\nu|\\lambda\\sigma) - (\\mu\\sigma|\\lambda\\nu)] \n+ \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma P^\\alpha_{\\sigma\\lambda}(\\mu\\nu|\\lambda\\sigma)} \\notag\\\\\n&= \\sum_\\mu\\sum_\\nu P^\\alpha_{\\nu\\mu} \\qty{H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma [P^T_{\\sigma\\lambda} (\\mu\\nu|\\lambda\\sigma) - P^\\alpha_{\\sigma\\lambda}(\\mu\\sigma|\\lambda\\nu)] }      \\notag\\\\\n&\\quad{} + \\sum_\\mu\\sum_\\nu P^\\beta_{\\nu\\mu} \\qty{H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2}\\sum_\\lambda\\sum_\\sigma [P^T_{\\sigma\\lambda} (\\mu\\nu|\\lambda\\sigma) - P^\\beta_{\\sigma\\lambda}(\\mu\\sigma|\\lambda\\nu)] } \\notag\\\\\n\\end{align}\nwhile\n\\begin{align}\nF^\\alpha_{\\mu\\nu} &= H^{\\core}_{\\mu\\nu} + \\sum_\\lambda\\sum_\\sigma \\qty[ P^T_{\\lambda\\sigma}(\\mu\\nu|\\sigma\\lambda) - P^\\alpha_{\\lambda\\sigma}(\\mu\\lambda|\\sigma\\nu)] \\\\\nF^\\beta_{\\mu\\nu} &= H^{\\core}_{\\mu\\nu} + \\sum_\\lambda\\sum_\\sigma \\qty[ P^T_{\\lambda\\sigma}(\\mu\\nu|\\sigma\\lambda) - P^\\beta_{\\lambda\\sigma}(\\mu\\lambda|\\sigma\\nu)]\n\\end{align}\nthus\n\\begin{align}\nE_0 &= \\sum_\\mu\\sum_\\nu \\qty{P^\\alpha_{\\nu\\mu} \\qty[\\dfrac{1}{2} H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2} F^\\alpha_{\\mu\\nu} ]  \n+ P^\\beta_{\\nu\\mu} \\qty[\\dfrac{1}{2} H^{\\core}_{\\mu\\nu} + \\dfrac{1}{2} F^\\beta_{\\mu\\nu} ]} \\notag\\\\\n&= \\dfrac{1}{2} \\sum_\\mu\\sum_\\nu \\qty[P^T_{\\nu\\mu} H^{\\core}_{\\mu\\nu} + P^\\alpha_{\\nu\\mu}F^\\alpha_{\\mu\\nu}  + P^\\beta_{\\nu\\mu}F^\\beta_{\\mu\\nu} ]\n\\end{align}\n\n\\subsubsection{Illustrative Unrestricted Calculations}\n\\ex{3.41}\n\\begin{align}\n\\ev{\\hsS^2} &= \\Braket{c_1 {^2\\Psi} + c_2 {^4\\Psi} | \\hsS^2 | c_1 {^2\\Psi} + c_2 {^4\\Psi}} \\notag\\\\\n&= \\dfrac{3}{4}c_1^2 + \\dfrac{15}{4}c_2^2 \\notag\\\\\n&= \\dfrac{3}{4}(1 - c_2^2) + \\dfrac{15}{4}c_2^2 \\notag\\\\\n&= \\dfrac{3}{4} + 3c_2^2\n\\end{align}\nthus\n\\linespread{1.2}\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{cccc}\n\t\t\\hline\n\t\tbasis & $ \\ev{\\hsS^2} $ & $ c_2 $ & contamination/\\% \\\\ \\hline\t\t\n\t\tSTO-3G & 0.7652 & 0.07118 & 0.5067\\\\\n\t\t4-31G  & 0.7622 & 0.06377 & 0.4067\\\\\n\t\t6-31G* & 0.7618 & 0.06272 & 0.3933\\\\\n\t\t6-31G**& 0.7614 & 0.06164 & 0.3800\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\\linespread{1.0}\n\n\\subsubsection{The Dissociation Problem and Its Unrestricted Solution}\n\\ex{3.42}\n\\begin{align}\n\\Braket{\\psi_1^\\alpha|\\psi_1^\\alpha} &= \\Braket{\\cos\\theta\\psi_1 + \\sin\\theta\\psi_2 | \\cos\\theta\\psi_1 + \\sin\\theta\\psi_2} = \\cos\\theta^2 + \\sin\\theta^2 = 1 \\\\\n\\Braket{\\psi_2^\\alpha|\\psi_2^\\alpha} &= \\Braket{-\\sin\\theta\\psi_1 + \\cos\\theta\\psi_2 | -\\sin\\theta\\psi_1 + \\cos\\theta\\psi_2} = \\sin\\theta^2 + \\cos\\theta^2 = 1 \\\\\n\\Braket{\\psi_1^\\alpha|\\psi_2^\\alpha} &= \\Braket{\\cos\\theta\\psi_1 + \\sin\\theta\\psi_2 | -\\sin\\theta\\psi_1 + \\cos\\theta\\psi_2} = -\\cos\\theta\\sin\\theta + \\sin\\theta\\cos\\theta = 0\n\\end{align}\nthus $ \\{\\psi_1^\\alpha, \\psi_2^\\alpha\\} $ is orthonormal.\\\\\nSimilarly conclusion can be derived for $ \\beta $ orbitals.\n\n\\ex{3.43}\nFor $ R = 1.4 $,\n\\begin{align}\n\\eta &= \\dfrac{h_{22} - h_{11} + J_{22} - J_{12} + 2K_{12}}{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n&= \\dfrac{(\\varepsilon_2 − 2J_{12} + K_{12} ) - (\\varepsilon_1 - J_{11}) + J_{22} - J_{12} + 2K_{12}}{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n&= \\dfrac{\\varepsilon_2 - \\varepsilon_1 + J_{11} + J_{22} − 3J_{12} + 3K_{12}   }{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n&= \\dfrac{0.6703 + 0.5782 + 0.6746 + 0.6975 - 3\\times 0.6636 + 3\\times 0.1813}{0.6746 + 0.6975 - 2\\times 0.6636 + 4\\times 0.1813} \nnotag\\\\\n&= 1.524 > 1\n\\end{align}\nthus unrestricted solution does not exist for this case.\\\\\nFor $ R = 4.0 $,\n\\begin{align}\n\\eta %&= \\dfrac{h_{22} - h_{11} + J_{22} - J_{12} + 2K_{12}}{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n%&= \\dfrac{(\\varepsilon_2 − 2J_{12} + K_{12} ) - (\\varepsilon_1 - J_{11}) + J_{22} - J_{12} + 2K_{12}}{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n&= \\dfrac{\\varepsilon_2 - \\varepsilon_1 + J_{11} + J_{22} − 3J_{12} + 3K_{12}   }{J_{11} + J_{22} - 2J_{12} + 4K_{12}} \\notag\\\\\n&= \\dfrac{0.0916 + 0.2542 + 0.5026 + 0.5259 - 3\\times 0.5121 + 3\\times 0.2651}{ 0.5026 + 0.5259 - 2\\times 0.5121 + 4\\times 0.2651} \nnotag\\\\\n&= 0.5948\n\\end{align}\n\\begin{equation}\\label{key}\n\\theta = \\arccos(\\sqrt{\\eta}) = 0.6900 = 39.53\\textdegree\n\\end{equation}\n\n\\ex{3.44}\n\\begin{align}\n\\lim\\limits_{R\\ra\\infty} \\ket{\\Psi_0} &= \\dfrac{1}{2}\\qty[\\ket{\\psi_1\\bar{\\psi}_1} - \\ket{\\psi_2\\bar{\\psi}_2} - {\\sqrt{2}}\\ket{^3\\Psi_1^2}] \\notag\\\\\n&= \\dfrac{1}{2}\\qty[\\ket{\\psi_1\\bar{\\psi}_1} - \\ket{\\psi_2\\bar{\\psi}_2} - \\qty(\\ket{\\psi_1\\bar{\\psi}_2} - \\ket{\\psi_2\\bar{\\psi}_1})] \\notag\\\\\n&= \\dfrac{1}{2}\\qty[\\dfrac{1}{2}\\ket{(\\phi_1 + \\phi_2)(\\bar\\phi_1 + \\bar\\phi_2)} \n- \\dfrac{1}{2}\\ket{(\\phi_1 - \\phi_2)(\\bar\\phi_1 - \\bar\\phi_2)} \n- \\qty(\\dfrac{1}{2}\\ket{(\\phi_1 + \\phi_2)(\\bar\\phi_1 - \\bar\\phi_2)} \n- \\dfrac{1}{2}\\ket{(\\phi_1 - \\phi_2)(\\bar\\phi_1 + \\bar\\phi_2)})] \\notag\\\\\n&=\\dfrac{1}{4}\\qty(\\ket{\\phi_1\\bar\\phi_1} + \\ket{\\phi_1\\bar\\phi_2}  \n+ \\ket{\\phi_2\\bar\\phi_1} + \\ket{\\phi_2\\bar\\phi_2} ) - \\dfrac{1}{4}\\qty(\\ket{\\phi_1\\bar\\phi_1} - \\ket{\\phi_1\\bar\\phi_2}  \n- \\ket{\\phi_2\\bar\\phi_1} + \\ket{\\phi_2\\bar\\phi_2} ) \\notag\\\\\n&\\quad{} - \\dfrac{1}{4}\\qty[\\qty(\\ket{\\phi_1\\bar\\phi_1} - \\ket{\\phi_1\\bar\\phi_2}  \n+ \\ket{\\phi_2\\bar\\phi_1} - \\ket{\\phi_2\\bar\\phi_2} )\n- \\qty(\\ket{\\phi_1\\bar\\phi_1} + \\ket{\\phi_1\\bar\\phi_2}  \n- \\ket{\\phi_2\\bar\\phi_1} - \\ket{\\phi_2\\bar\\phi_2} )] \\notag\\\\\n&= \\dfrac{1}{2}\\qty(\\ket{\\phi_1\\bar\\phi_2}  + \\ket{\\phi_2\\bar\\phi_1} )\n- \\dfrac{1}{4}\\qty(- 2\\ket{\\phi_1\\bar\\phi_2} + 2\\ket{\\phi_2\\bar\\phi_1}) \\notag\\\\\n&= \\ket{\\phi_1\\bar\\phi_2} \n\\end{align}\n\n\n\\end{document}", "meta": {"hexsha": "883323f54cc3214b55b83cf4c527abe05a3073a5", "size": 42465, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chap3/chap3.tex", "max_stars_repo_name": "hebrewsnabla/S-O-MQC-HW", "max_stars_repo_head_hexsha": "58d79bd949d34e310e4ce8c287fe4b7ecda560da", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2019-10-03T03:37:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T09:26:32.000Z", "max_issues_repo_path": "chap3/chap3.tex", "max_issues_repo_name": "hebrewsnabla/S-O-MQC-HW", "max_issues_repo_head_hexsha": "58d79bd949d34e310e4ce8c287fe4b7ecda560da", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-04-30T15:45:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T13:00:28.000Z", "max_forks_repo_path": "chap3/chap3.tex", "max_forks_repo_name": "hebrewsnabla/S-O-MQC-HW", "max_forks_repo_head_hexsha": "58d79bd949d34e310e4ce8c287fe4b7ecda560da", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2021-05-11T11:30:44.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T08:43:27.000Z", "avg_line_length": 44.7943037975, "max_line_length": 287, "alphanum_fraction": 0.5903920876, "num_tokens": 21104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102955, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4060425238876702}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%                         BIBLIOGRAPHY FILE                                 %%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% The `filecontents` command will crete a file in the inputs directory called \n%% refs.bib containing the references in the document, in case this file does \n%% not exist already.\n%% If you want to add a BibTeX entry, please don't add it directly to the\n%% refs.bib file.  Instead, add it in this file between the\n%% \\begin{filecontents*}{refs.bib} and \\end{filecontents*} lines\n%% then delete the existing refs.bib file so it will be automatically generated \n%% again with your new entry the next time you run pdfaltex.\n\\begin{filecontents*}{inputs/refs.bib}\n@book {MR2455216,\n    AUTHOR = {Gr{\\\"a}tzer, George},\n     TITLE = {Universal algebra},\n   EDITION = {second},\n      NOTE = {With appendices by Gr{\\\"a}tzer, Bjarni J{\\'o}nsson, Walter\n              Taylor, Robert W. Quackenbush, G{\\\"u}nter H. Wenzel, and\n              Gr{\\\"a}tzer and W. A. Lampe},\n PUBLISHER = {Springer, New York},\n      YEAR = {2008},\n     PAGES = {xx+586},\n      ISBN = {978-0-387-77486-2},\n   MRCLASS = {08-02},\n  MRNUMBER = {2455216},\n       DOI = {10.1007/978-0-387-77487-9},\n       URL = {http://dx.doi.org/10.1007/978-0-387-77487-9},\n}\n@article {MR0237401,\n    AUTHOR = {Gr{\\\"a}tzer, G. and Wenzel, G. H.},\n     TITLE = {On the concept of congruence relation in partial algebras},\n   JOURNAL = {Math. Scand.},\n  FJOURNAL = {Mathematica Scandinavica},\n    VOLUME = {20},\n      YEAR = {1967},\n     PAGES = {275--280},\n      ISSN = {0025-5521},\n   MRCLASS = {08.30},\n  MRNUMBER = {0237401},\nMRREVIEWER = {B. H. Neumann},\n}\n@article {MR0309833,\n    AUTHOR = {Berman, Joel},\n     TITLE = {On the congruence lattices of unary algebras},\n   JOURNAL = {Proc. Amer. Math. Soc.},\n  FJOURNAL = {Proceedings of the American Mathematical Society},\n    VOLUME = {36},\n      YEAR = {1972},\n     PAGES = {34--38},\n      ISSN = {0002-9939},\n   MRCLASS = {08A15},\n  MRNUMBER = {0309833},\nMRREVIEWER = {I. Petrescu},\n}\n\t\t\n@article {MR0308011,\n    AUTHOR = {Berman, Joel},\n     TITLE = {Strong congruence lattices of finite partial algebras},\n   JOURNAL = {Algebra Universalis},\n  FJOURNAL = {Algebra Universalis},\n    VOLUME = {1},\n      YEAR = {1971/72},\n     PAGES = {133--135},\n      ISSN = {0002-5240},\n   MRCLASS = {08A25},\n  MRNUMBER = {0308011},\nMRREVIEWER = {M. Kolibiar},\n}\n\t\t\n@book {MR2619731,\n    AUTHOR = {Berman, Joel},\n     TITLE = {{C}ongruence {L}attices of {F}inite {U}niversal {A}lgebras},\n      NOTE = {Thesis (Ph.D.)--University of Washington},\n PUBLISHER = {ProQuest LLC, Ann Arbor, MI},\n      YEAR = {1970},\n     PAGES = {64},\n   MRCLASS = {Thesis},\n  MRNUMBER = {2619731},\n       URL = {https://dl.dropboxusercontent.com/u/17739547/diss/berman-phd-thesis.pdf}\n}\n@COMMENT {http://gateway.proquest.com/openurl?url_ver=Z39.88-2004&rft_val_fmt=info:ofi/fmt:kev:mtx:dissertation&res_dat=xri:pqdiss&rft_dat=xri:pqdiss:7100941},\n@misc{Lampe:20161017,\n  author        = \"Bill Lampe\",\n  howpublished  = \"personal communication\",\n  note          = \"October 17\",\n  year          = \"2016\"\n}\n@article {MR552159,\n    AUTHOR = {Pudl{\\'a}k, Pavel and T{\\.u}ma, Ji{\\v{r}}{\\'{\\i}}},\n     TITLE = {Every finite lattice can be embedded in a finite partition\n              lattice},\n   JOURNAL = {Algebra Universalis},\n  FJOURNAL = {Algebra Universalis},\n    VOLUME = {10},\n      YEAR = {1980},\n    NUMBER = {1},\n     PAGES = {74--95},\n      ISSN = {0002-5240},\n   MRCLASS = {06B15 (05C99)},\n  MRNUMBER = {552159},\nMRREVIEWER = {James W. Lea, Jr.},\n       DOI = {10.1007/BF02482893},\n       URL = {http://dx.doi.org/10.1007/BF02482893},\n}\n@article {MR3076179,\n    AUTHOR = {Kearnes, Keith A. and Kiss, Emil W.},\n     TITLE = {The shape of congruence lattices},\n   JOURNAL = {Mem. Amer. Math. Soc.},\n  FJOURNAL = {Memoirs of the American Mathematical Society},\n    VOLUME = {222},\n      YEAR = {2013},\n    NUMBER = {1046},\n     PAGES = {viii+169},\n      ISSN = {0065-9266},\n      ISBN = {978-0-8218-8323-5},\n   MRCLASS = {08B05 (08B10)},\n  MRNUMBER = {3076179},\nMRREVIEWER = {James B. Nation},\n       DOI = {10.1090/S0065-9266-2012-00667-8},\n       URL = {http://dx.doi.org/10.1090/S0065-9266-2012-00667-8},\n}\n@unpublished{Nation-notes,\nauthor = {J. B. Nation},\ntitle = {Notes on Lattice Theory},\nnote = {Unpublished notes},\nyear = {2007, 2016},\nURL = {http://www.math.hawaii.edu/~jb/}\n}\n\\end{filecontents*}\n\\documentclass[12pt]{amsart}\n% The following \\documentclass options may be useful:\n% preprint      Remove this option only once the paper is in final form.\n% 10pt          To set in 10-point type instead of 9-point.\n% 11pt          To set in 11-point type instead of 9-point.\n% numbers       To obtain numeric citation style instead of author/year.\n\n%% \\usepackage{setspace}\\onehalfspacing\n\n\\usepackage{amsmath}\n\\usepackage{amscd,amssymb,amsthm} %, amsmath are included by default\n\\usepackage{latexsym,stmaryrd,mathrsfs,enumerate,scalefnt,ifthen}\n\\usepackage{mathtools}\n\\usepackage[mathcal]{euscript}\n\\usepackage[colorlinks=true,urlcolor=black,linkcolor=black,citecolor=black]{hyperref}\n\\usepackage{url}\n\\usepackage{scalefnt}\n\\usepackage{tikz}\n\\usepackage{color}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{scrextend}\n\n%%////////////////////////////////////////////////////////////////////////////////\n%% Theorem styles\n\\numberwithin{equation}{section}\n\\theoremstyle{plain}\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{prop}[theorem]{Proposition}\n\\theoremstyle{definition}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{definition}[theorem]{Definition}\n\\newtheorem{notation}[theorem]{Notation}\n\\newtheorem{Fact}[theorem]{Fact}\n\\newtheorem*{fact}{Fact}\n\\newtheorem{example}[theorem]{Example}\n\\newtheorem{examples}[theorem]{Examples}\n\\newtheorem{exercise}{Exercise}\n\\newtheorem*{lem}{Lemma}\n\\newtheorem*{cor}{Corollary}\n\\newtheorem*{remark}{Remark}\n\\newtheorem*{remarks}{Remarks}\n\\newtheorem*{obs}{Observation}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Acronyms\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% \\usepackage[acronym, shortcuts]{glossaries}\n%\\usepackage[smaller]{acro}\n\\usepackage[smaller]{acronym}\n\\usepackage{xspace}\n\n%% \\acs{CSP} -- short version of the acronym\\\\\n%% \\acl{CSP} -- expanded acronym without mentioning the acronym.\\\\\n%% \\acp{CSP} -- plurals.\\\\\n%% \\acfp{CSP} -- long forms into plurals.\\\\\n%% \\acsp{CSP} -- short form into a plural.\\\\\n%% \\aclp{CSP} -- long form into a plural.\\\\\n%% \\acfi{CSP} -- Full Name acronym in italics and abbreviated form in upshape.\\\\\n%% \\acsu{CSP} -- short form of the acronym and marks it as used.\\\\\n%% \\aclu{CSP} -- Prints the long form of the acronym and marks it as used.\\\\\n\n\\acrodef{lics}[LICS]{Logic in Computer Science}\n\\acrodef{sat}[SAT]{satisfiability}\n\\acrodef{nae}[NAE]{not-all-equal}\n\\acrodef{ctb}[CTB]{cube term blocker}\n\\acrodef{tct}[TCT]{tame congruence theory}\n\\acrodef{wnu}[WNU]{weak near-unanimity}\n\\acrodef{CSP}[CSP]{constraint satisfaction problem}\n\\acrodef{MAS}[MAS]{minimal absorbing subuniverse}\n\\acrodef{MA}[MA]{minimal absorbing}\n\\acrodef{cib}[CIB]{commutative idempotent binar}\n\\acrodef{sd}[SD]{semidistributive}\n\\acrodef{NP}[NP]{nondeterministic polynomial time}\n\\acrodef{P}[P]{polynomial time}\n\\acrodef{PeqNP}[P $ = $ NP]{P is NP}\n\\acrodef{PneqNP}[P $ \\neq $ NP]{P is not NP}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\usepackage{inputs/proof-dashed}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%% Put new macros in the macros.sty file\n\\usepackage{inputs/macros}\n\n\\usepackage[backend=bibtex]{biblatex}\n\\bibliography{inputs/refs.bib}\n\n\\begin{document}\n\n\\title[Congruences of Partial Algebras]{Congruences of Partial and Total Algebras}\n\\date{24 October 2016}\n\\author[W.~DeMeo]{William DeMeo}\n\\address{University of Hawaii}\n\\email{williamdemeo@gmail.com}\n\n\\maketitle\n\n%% \\begin{abstract}\\end{abstract}\n\n\\section{Introduction}\n\\label{sec:introduction}\nSection~\\ref{sec:simple-proof-well} gives a straight-forward proof that every finite\nlattice is the congruence lattice of a finite partial algebra.\nBill Lampe~\\cite{Lampe:20161017} pointed out\nthat this result has been known for a long time, and in\nSection~\\ref{sec:more-gener-appr}\nwe give some background about closure operators and \nbegin to develop the framework in which the original result was presented.\nWe also recall a theorem from Berman's thesis that relates congruence lattices of\npartial algebras with those of total algebras.\n\nThis is a mash-up of notations, definitions, and theorems\nfor the Universal Algebra and Lattice Theory Seminar\nin Hawaii, Fall Semester 2016. \nThe notes are unfinished and far from perfect.\nNonetheless, they might stimulate discussion\nin the seminar and elicit some criticism\nthat we can use to improve them.\nSo far most, if not all, of what appears below is known.\nSee, for example, \\cite{MR2619731, MR0308011, MR0237401, MR2455216}.\n\n\n\\section{A well known result}\n\\label{sec:simple-proof-well}\nIn this section we give a straight-forward proof of the fact that every finite\nlattice is the congruence lattice of a finite partial algebra.\n\n\n\\begin{lemma}\nLet $X$ be a finite set, and let $\\Eq(X)$ denote the lattice of equivalence\nrelations on $X$. If $L\\leq \\Eq(X)$ is a 0-1-sublattice,\nand $\\rho \\in \\Eq(X)$ and $\\rho \\notin L$, then for some $k < \\omega$ there exists a partial\noperation $f\\colon X^k \\rightharpoonup X$ that is compatible with $L$ and\nincompatible with $\\rho$.\n\\end{lemma}\n\\begin{proof}\n  First we focus on the relations in $L$ that are above $\\rho$.\n  Let $\\rho^\\uparrow \\cap L = \\{\\gamma \\in L \\mid \\gamma \\geq \\rho\\}$.\n  Since $\\rho\\notin L$, we have $\\gamma > \\rho$ for all $\\gamma \\in \\rho^\\uparrow \\cap L$.\n  Now, $\\rho^\\uparrow \\cap L$ has a least element\n  $\\rho^* = \\Meet (\\rho^\\uparrow \\cap L)$.  Clearly\n  $\\rho^*\\geq \\rho$ and since $\\rho^* \\in L$ we have\n  $\\rho^*\\neq \\rho$, so\n  $\\rho^* > \\rho$.  Therefore, there exists $(u,v) \\in \\rho^* - \\rho$.\n\n  Next consider the elements of $L$ that are not above $\\rho$. For each such\n  $\\alpha_i \\in L - \\rho^\\uparrow$ there exists $(x_i, y_i) \\in \\rho -\\alpha_i$.\n  Let $(x_1, y_1), \\dots, (x_k, y_k)$ be the list of all unique such pairs\n  (i.e., each pair appears in the list exactly once).\n  Define the partial function $f\\colon X^k \\rightharpoonup X$ at only two points of $X^k$; specifically, let\n  \\[ f(x_1, \\dots, x_k) = u \\quad \\text{ and } \\quad f(y_1, \\dots, y_k) = v. \\]\n  Then, since $(\\forall i)(x_i, y_i) \\in \\rho$ and $(u,v) \\notin \\rho$, \n  $f$ is incompatible with $\\rho$.  On the other hand,\n  $(u,v) \\in  \\rho^* = \\Meet (\\rho^\\uparrow \\cap L)$, so\n  $(u,v) \\in \\gamma$  for every $\\gamma \\in \\rho^\\uparrow \\cap L$, so\n  $f$ is compatible with every $\\gamma \\in \\rho^\\uparrow \\cap L$.\n  \n  \n  Finally, for each $\\alpha_i\\in L$ not above $\\rho$ there is at least one pair\n  $(x_i, y_i)\\notin \\alpha_i$.  Therefore, it is impossible for $f$ to be\n  incompatible with any such $\\alpha_i$. \n\\end{proof}\n\n\\begin{theorem}\nLet $X$ be a finite set and let $L\\leq \\Eq(X)$ be a 0-1-sublattice.\nThen there exists a finite partial algebra\n$\\mathbb X = \\< X, F\\>$ with $\\Con(\\mathbb X) =  L$.\n\\end{theorem}\n\n\\begin{proof}\n  By the lemma, for each $\\rho \\in \\Eq(X) - L$, there exists $k< \\omega$ and\n  $f_\\rho \\colon  X^k \\rightharpoonup X$ such that $f_\\rho$ is compatible with every relation in\n  $L$ and incompatible with $\\rho$.  Let $\\mathcal{R}$ be the set $\\Eq(X) - L$ of\n  all equivalence relations on $X$ that do not belong to $L$.  Define,\n  $F = \\{f_\\rho \\mid \\rho \\in \\mathcal{R}\\}$.  Evidently, $\\Con \\<X, F\\> = L$.\n\\end{proof}\n\n\\section{Closure Systems and Moore Families}\n\\label{sec:more-gener-appr}\n\n\\subsection{Closure systems and operators}\n%% \\footnote{See J. B. Nation's notes~\\cite{Nation-notes} for more details.}\nA \\defn{closure system} on a set $X$ is a collection $\\sC$\nof subsets of $X$ that is closed under arbitrary intersection (including the empty \nintersection, so $\\bigcap \\emptyset = X \\in \\sC$). \nThus a closure system is a complete meet semilattice with respect to subset\ninclusion ordering. \nSince every complete meet semilattice is automatically a complete lattice\n(see \\cite[Theorem 2.5]{Nation-notes}), \nthe closed sets of a closure system form a complete lattice. \n%% The sets in $\\sC$ are called \\defn{closed sets}. \n\nExamples of closure systems that are especially relevant for our work are the following:\n\\begin{itemize}\n\\item order ideals of an ordered set\n\\item subalgebras of an algebra \n\\item equivalence relations on a set\n\\item congruence relations of an algebra\n\\end{itemize}\n\n\\newcommand{\\cl}{\\ensuremath{\\operatorname{\\sansC}}}\n\nLet $\\bP = \\<P, \\leq \\>$ be a poset.\nAn function $\\cl \\colon P \\to P$ is called a \\defn{closure operator} on $\\bP$\nif it satisfies the following axioms for all $x, y\\in P$.\n\\begin{enumerate}\n\\item $x \\leq \\cl x$ (extensivity) \n\\item $x \\leq y$ implies $\\cl x \\leq \\cl y$ (monotonicity) \n\\item $\\cl \\cl x = \\cl x$ (idempotence) \n\\end{enumerate}\nThus, a closure operator is an extensive idempotent poset endomorphism,\nand the definition above is equivalent to the single axiom\n$(\\forall\\, x, y \\in P) (x \\leq \\cl y \\, \\longleftrightarrow  \\, \\cl x \\leq  \\cl y)$.\n\n\\begin{example}\nLet $X$ be a set and let $Y \\subseteq X$.\nDefine $\\cl_Y\\colon \\sP(X) \\to \\sP(X)$ by $\\cl_Y (W) = W \\cup Y$.\nThen $\\cl_Y$ is a closure operator on $\\<\\sP(X), \\subseteq\\>$.\n\\end{example}\n\n\nA \\defn{fixed point} of a\nfunction $\\cl \\colon  P \\to P$ is an $x\\in P$ satisfying $\\cl x = x$.\nA fixed point of a closure operator is called \\defn{closed}.\n%% A \\defn{closure operator} on a set $X$ is a map $\\sansc  \\colon \\sP(X) \\to \\sP(X)$ \n%% satisfying, for all $A, B \\in \\sP(X)$,\n%% \\begin{enumerate}[(a)]\n%% \\item $A \\subseteq \\sansC A$ (extensivity) \n%% \\item $A \\subseteq B$ implies $\\sansC A \\subseteq \\sansC B$ (monotonicity) \n%% \\item $\\sansC  \\sansC A = \\sansC A$ (idempotence) \n%% \\end{enumerate}\n%% A fixpoint of a closure operator is called a \\defn{closed set}.\nIf the poset $\\bP = \\<P, \\leq\\>$ happens to be a complete lattice,\nthen by extensivity the largest element $\\top = \\Join P$ is\na fixed point of every closure operator on $\\bP$.\nAlso, the collection of fixed points of a closure operator is closed under arbitrary meets.\n(Proof: If $\\sA$ is a set of fixed points of $\\cl$ and  \n$a \\in \\sA$, then $\\Meet \\sA \\leq a$, so by monotonicity\n$\\cl \\bigl( \\Meet \\sA \\bigr) \\leq \\cl a = a$. \nSince $a$ was arbitrary,\n$\\cl \\bigl( \\Meet \\sA \\bigr) \\leq  \\Meet \\sA$.\nBy extensivity,\n$\\Meet \\sA \\leq \\cl \\bigl( \\Meet \\sA\\bigr)$. % \\subseteq \\bigcap \\sA$,\nTherefore, $\\cl \\bigl( \\Meet \\sA \\bigr) =  \\Meet \\sA$.)\n%% ; that is,  $\\Meet \\sA$ is a fixpoint of $\\cl$.)\nThe set of closure operators on $\\bP$\nthemselves form a complete lattice under the pointwise\norder: $\\cl_1 \\leq  \\cl_2$ iff $\\cl_1 x \\leq  \\cl_2 x$ for all $x \\in P$. \n\nSome of these observations can be restated as follows:\nif $\\bP = \\<P, \\leq\\>$ is a complete lattice,\nthen the set $\\sC \\subseteq P$ of fixed points of a closure operator\nis a \\defn{Moore family} on $\\bP$---that is, \n%% A subset $\\sM \\subseteq P$ is called a \\defn{Moore family} if\n$\\Join P \\in \\sC$ and every nonempty subset of $\\sC$ is closed under arbitrary meets.\n%% If $\\bL = \\<L, \\join, \\meet\\>$ is a complete lattice with top $\\top = \\Join L$, then\n%% That is, if $\\emptyset \\neq S \\subseteq \\sM$, then $\\Meet S \\in S$.\n%% If $\\bL = \\<L, \\join, \\meet\\>$ is a complete lattice, then a\n\n\nConversely, if we are given a Moore family $\\sC$ on $\\bP$, and if we define \n$\\cl \\colon P \\to P$ by\n\\[\n\\cl a = \\Meet \\{b \\in \\sC \\mid a\\leq b\\},\n\\]\nthen $\\cl$ satisfies conditions (1)--(3)\nabove, making it a closure operator.\nTo summarize, $\\sC \\subseteq P$ is the set of fixed points (i.e., closed elements)\nof a closure operator on\n$\\bP$ if and only if $\\sC$ is a Moore family on $\\bP$.\n\nEvery Moore family on $\\bP$ is itself the universe of a complete lattice with the order inherited\nfrom $\\bP$, though the join may differ from the join of $\\bP$.\n\n\\subsubsection{More Moore families}\nThe name ``closure system'' is typically reserved for the special case\nin which $\\bP$ happens to be the powerset Boolean\nalgebra of a set $X$---that is, $\\bP = \\<\\sP(X), \\subseteq\\>$; in that case, a Moore family on $\\bP$ \nis called a closure system on $X$. \n\n\\begin{example}\n  Let $X$ be a set,\n  let $\\sansR(X) = \\bigcup_{n<\\omega}\\sP(X^n)$ be the set of all finitary\n  relations on $X$, and let\n  %% let $\\Eq(X)$ denote the lattice of equivalence relations on $X$, and let\n  $\\sansO(X) = \\bigcup_{n< \\omega} X^{X^n}$ be the set of all finitary operations on $X$.\n  Define $F \\colon  \\sP(\\sansR(X)) \\to \\sP(\\sansO(X))$\n  and $G \\colon \\sP(\\sansO(X)) \\to \\sP(\\sansR(X))$ as follows:\n  if $A \\subseteq\\sansR(X)$ and $B \\subseteq \\sansO(X)$, then\n  %% \\sF_n(S) = \\{f \\in \\sansO(X)X^{X^n} \\mid f \\text{ is compatible with every $s\\in S$}\\}\n  %% \\[  \\sF(S) = \\bigcup \\sF_n(S)  \\]\n  \\[\n  F(A) = \\{f \\in \\sansO(X) \\mid f \\text{ is compatible with every relation in $A$}\\},\n  \\]\n  \\[\n  G(B) = \\{\\rho \\in \\sansR(X) \\mid \\rho \\text{ is compatible with every operation in $B$}\\}.\n  \\]\n  Then $G \\circ F$ is a closure operator on the lattice % $\\<\\sansR(X), \\subseteq\\>$\n  of all relations on $X$.\n\\end{example}\n\n\\begin{example}\n  Let $X$ be a set,\n  let $\\Eq(X)$ denote the lattice of equivalence relations on $X$, and let\n  $X^X$ be the set of all unary operations on $X$.\n  Define $F_1 \\colon  \\sP(\\Eq(X)) \\to \\sP(X^X)$\n  and $G_1 \\colon \\sP(X^X) \\to \\sP(\\Eq(X))$ as follows:\n  if $A \\subseteq\\Eq(X)$ and $B \\subseteq X^X$, then\n  %% \\sF_n(S) = \\{f \\in \\sansO(X)X^{X^n} \\mid f \\text{ is compatible with every $s\\in S$}\\}\n  %% \\[  \\sF(S) = \\bigcup \\sF_n(S)  \\]\n  \\[\n  F_1(A) = \\{f \\in X^X\\mid f \\text{ is compatible with every relation in $A$}\\},\n  \\]\n  \\[\n  G_1(B) = \\{\\rho \\in \\Eq(X) \\mid \\rho \\text{ is compatible with every operation in $B$}\\}.\n  \\]\n  Then $G_1 \\circ F_1$ is a closure operator on the lattice $\\Eq(X)$\n  of all equivalence relations on $X$.\n\\end{example}\n\\newcommand{\\Luv}{\\ensuremath{L_{u,v}}}\n\\newcommand{\\bLuv}{\\ensuremath{\\mathbf{L}_{u,v}}}\n\\newcommand{\\juv}{\\ensuremath{\\vee_{u,v}}}\n\\newcommand{\\suv}{\\ensuremath{\\sigma_{u,v}}}\n\\begin{example}[Pudl{\\'a}k-T{\\.u}ma~\\cite{MR552159}]\n  Let $\\bL = \\<L, \\join, \\meet\\>$ be a lattice, $u, v \\in L$, and $u\\leq v$.\n  Define a subset $\\Luv$ of $L$ by\n  $\\Luv =\\{x\\in L \\mid v\\leq x \\text{ or } u \\nleq x\\}$.\n  The partial order relation of the lattice $\\bL$ induces a lattice order on\n  $\\Luv$. Denote the resulting lattice by $\\bLuv$.\n  Then the meet of $\\bLuv$ is that of $\\bL$, whereas the join of $\\bLuv$ is\n  \\[\n  x \\juv y = \n  \\begin{cases}\n    x \\join y, & \\text{ if $u \\nleq x \\join y$,}\\\\\n    x \\join y \\join v, & \\text{ if $u \\leq x \\join y$.}\n  \\end{cases}\n  \\]\n  Define a mapping $\\suv \\colon L \\to \\Luv$ as follows:\n  \\[\n  \\suv (x)  = \n  \\begin{cases}\n    x, & \\text{ if $u \\nleq x$,}\\\\\n    x \\join v, & \\text{ if $u \\leq x$.}\n  \\end{cases}\n  \\]\n  Then $\\suv$ is a surjective join-homomorphism. In fact, every\n  join-homomorphism $\\phi \\colon L \\to K$ satisfying $\\phi(u) = \\phi(v)$ splits as\n  $\\phi =  \\psi \\circ \\suv$ for some $\\psi \\colon \\Luv \\to K$.\n  (See the commutative diagram in Figure~\\ref{fig:splitting}.)\n  As a mapping from $\\bL$ to itself, $\\suv$ does not preserve joins. However,\n  $\\suv \\colon L \\to L$ is a closure operator and \n  $\\Luv$ is the set of fixed points of $\\suv$ (the closed sets).\n\n  \\begin{center}\n    \\begin{figure}[h]\n      \\begin{tikzpicture}[node distance=2cm, scale=3]\n        \\node (10) at (1,0)  {$\\Luv$};\n        \\node (21) at (2,1)  {$K$};\n        \\node (01) at (0,1)  {$L$};\n        \\node (middle) at (1,0.6)  {$\\circlearrowleft$};\n        \\draw[->,thick] (01) -- (21)  node[pos=.5,above] {$\\phi$};\n        \\draw[->,thick] (01) -- (10)  node[pos=.5,left] {$\\suv$};\n        \\draw[->,dashed,thick] (10) -- (21)  node[pos=.5,right] {$\\exists \\,\\psi$};\n      \\end{tikzpicture}\n      \\caption{Every join-homomorphism collapsing $u$ and $v$ is divisible by $\\suv$.}\n      \\label{fig:splitting}\n    \\end{figure}\n  \\end{center}\n\n  \n\\end{example}\n\n\n\\section{Algebraic Closure Systems}\nA subset $D$ of an ordered set $P$ is called \\defn{up-directed}\nif for every $x, y \\in D$ there exists $z \\in D$ such that\n$x \\leq z$ and $y \\leq z$. \nA closure operator $\\cl\\colon \\sP(X) \\to \\sP(X)$ is called \\defn{algebraic} provided,\nfor all $A\\subseteq X$, \n\\[\n\\cl A = \\bigcup \\{\\cl F \\mid F \\subseteq A \\text{ and } F \\text{ finite } \\}.\n\\]\nThe collection $\\sC$ of closed sets of an algebraic closure operator is called an\n\\defn{algebraic closure system}.\n\\begin{theorem}[cf.~\\cite{Nation-notes} Thm 3.1]\n  Let $\\sC$ be the closure system of fixed points of the closure operator $\\cl\\colon \\sP(X) \\to \\sP(X)$.\n  The following are equivalent:\n\\begin{enumerate}\n\\item $\\cl$ is an algebraic closure operator\n\\item $\\sC$ is an algebraic closure system\n\\item If $D\\subseteq \\sC$ is up-directed and $C\\subseteq D$ is a chain, then $\\bigcup C$ is closed.\n\\item If $D\\subseteq \\sC$ is up-directed, then $\\bigcup D$ is closed.\n\\item If $C\\subseteq \\sC$ is a chain, then $\\bigcup C$ is closed.\n\\end{enumerate}\n\\end{theorem}\n\n\\subsection{Algebraic closure systems are subalgebra lattices}\nFor an algebra $\\bA$, the subalgebra generation operator $\\Sg^{\\bA}$ is an algebraic\nclosure operator (on the poset $\\<\\sP(A), \\subseteq\\>$) whose fixed points are the\nsubalgebras of $\\bA$.\nThus the lattice $\\<\\Sub(\\bA), \\join, \\meet\\>$ of subalgebras of $\\bA$ is an algebraic closure\nsystem.\nConversely, given an algebraic closure system $\\sS$, we can construct an algebra\n$\\bA =\\<A, F\\>$ so that $\\sS = \\Sub(\\bA)$.\nHere is how: let $\\cl_{\\sS}$ denote the corresponding closure operator.\nFor each $a_0, a_1, \\dots, a_{n-1}, b \\in A$ such that\n$b \\in \\cl_{\\sS} \\bigl(\\{a_0, a_1, \\dots, a_{n-1}\\}\\bigr)$, define the $n$-ary operation\n$f_{\\ba, b}$ so that $f_{\\ba, b}(a_0, a_1, \\dots, a_{n-1}) = b$ and\nfor all other tuples $f_{\\ba, b}(c_0, c_1, \\dots, c_{n-1}) = c_0$.\n%% Do this for each $\\ba = (a_0, a_1, \\dots, a_{n-1})$. \nThen define\n\\[\nF = \\{f_{\\ba, b} \\mid  n< \\omega, \\, \\ba \\in A^n,  \\, b \\in \\cl_{\\sS} \\ba\\}.\n\\]\nEvery subalgebra is the union of its finitely generated subsubalgebras...\n{\\it (to be continued)}\n\n\\subsection{Congruence lattices}\nStart with an algebraic closure system $\\sS$ of equivalence relations on a set\n$A$ and let $\\cl_{\\sS}$ be the associated closure operator.\nLet $(a_0, b_0)$, $(a_1, b_1)$, $\\dots$, $(a_{n-1},b_{n-1})$, and $(c_0,\nc_1)$ belong to $A\\times A$,\nand suppose \n$(c_0,c_1) \\in \\cl_{\\sS}\\bigl(\\{(a_0, b_0), (a_1, b_1), \\dots,\n(a_{n-1},b_{n-1})\\}\\bigr)$.\nDefine $f_{\\ba, \\bb, \\bc}\\colon (A\\times A)^n \\to A\\times A$ \nso that\n$f_{\\ba, \\bb, \\bc}\\bigl((a_0, b_0), (a_1, b_1), \\dots, (a_{n-1},b_{n-1})\\bigr) =(c_0,c_1)$.\nDo this for each triple $\\ba$, $\\bb$, $\\bc$...\n{\\it (to be continued)}\n\n\n\\section{Strong Congruence Relations}\nWe use bold letters like $\\bx$ to denote tuples like $(x_0, \\dots, x_{n-1})$,\nwhere the value $n$ will be clear from context.\nLet $\\theta$ be an equivalence relation on a set $A$ and suppose\n$f\\colon A^n \\rightharpoonup A$ is a partial function.\nWe call $\\theta$ and $f$\n\\begin{itemize}\n\\item \\defn{weakly compatible} provided that, for all $(a_i, b_i) \\in \\theta$,\nif $f(\\ba)$ and $f(\\bb)$ are both defined, then $f(\\ba) \\mathrel{\\theta} f(\\bb)$.\n\\item \\defn{strongly compatible} provided that, for all $(a_i, b_i) \\in \\theta$,\nif $f(\\ba)$ is defined, then $f(\\bb)$ is defined and $f(\\ba) \\mathrel{\\theta} f(\\bb)$.\n\\end{itemize}\n\nLet $\\A = \\<A, F\\>$ be a partial algebra and $\\theta$ an equivalence relation on $A$.\nWe call $\\theta$ a \\defn{strong} (resp., \\defn{weak}) \\defn{congruence} of $\\A$\nif $\\theta$ is strongly (resp., weakly) compatible with every $f\\in F$.\nDenote by $\\SCon(\\A)$ (resp., $\\WCon(\\A)$) the set of strong (resp., weak)\ncongruences of $\\A$.\n%% If $\\A = \\<A, F\\>$ is a (partial) algebra then a \\defn{(strong) congruence relation} of $\\A$ is\n%% an equivalence relation on $A$ that is (strongly) compatible with every $f\\in F$.\n\nHere are some elementary observations about strong and weak congruences.\n(See Berman's thesis~\\cite{MR2619731} and paper~\\cite{MR0308011} for more details and proofs.)\nIf $\\A = \\<A, F\\>$ is a partial algebra then the set $\\SCon(\\A)$ of strong congruence relations of\n$\\A$ forms a sublattice of $\\Eq(A)$.\nThe set $\\WCon(\\A)$ of weak congruences also forms a lattice, but it is not a sublattice of $\\Eq(A)$\nsince there may be pairs of relations whose join in $\\Eq(A)$ is strictly below\ntheir join in $\\WCon(\\A)$. We will see examples below.\n\nA \\emph{total algebra}---an algebra for which all operations are defined everywhere---is\na special case of a partial algebra. In case a partial algebra is not total,\nwe may refer to it as a \\emph{proper partial algebra}.\nThis simply means that there is at least one operation that is not defined everywhere.\nIt should be obvious that for total algebras strong and weak congruences reduce to the usual\ndefinition of congruence relation on an algebra.\nIn particular, if $\\A$ is total, then the largest strong congruence of $\\A$ is $1_A := A\\times A$.\n%% Let $\\theta$ be a strong congruence of the partial algebra\n\nThe converse of the last sentence in the previous paragraph is also true.\nThat is, if the largest strong congruence of $\\A$ is $1_A$, then $\\A$ is total.\nTo see this, suppose $f \\in F$ is an $n$-ary partial operation and \ndenote by $\\dom(f)$ the subset of $A^n$ on which $f$ is defined.\nLet $\\theta$ be a strong congruence of $\\A$.\nThen the following implication holds:\n\\[ (a_0, a_1, \\dots, a_{n-1})\\in \\dom(f) \\;  \\Longrightarrow \\;\n   [a_0]_\\theta \\times [a_1]_\\theta \\times \\cdots \\times [a_{n-1}]_\\theta \\subseteq \\dom(f).\n   \\]\nThat is, if $f$ is defined at an $n$-tuple,\n%% $\\ba = (a_0, a_1, \\dots, a_{n-1})$,\nthen $f$ must also be defined on the whole Cartesian product of $\\theta$-blocks containing the\ncoordinates of that tuple.\nIn particular, if $1_A$ is a strong congruence of $\\A$, then every operation of\n$\\A$ must be total, while if $\\A = \\<A, F\\>$ is a \\emph{proper partial algebra},\nthen the largest strong congruence of $\\A$\nmust be strictly below $1_A$.\n\nTo summarize, $\\A$ is a total algebra iff $\\Join \\SCon(\\A) = 1_A$.\n\n\\begin{theorem}[Berman's Thesis~\\cite{MR2619731} Thm~1.18]\n  \\label{thm:berman-1-18}\n  Let $\\A$ be a finite partial algebra and $\\SCon(\\A)$ the lattice of strong\n  congruence relations of $\\A$.  Then there exists a finite algebra $\\bA$\n  such that $\\Con(\\bA) = \\SCon(\\A)$.\n\\end{theorem}\n\\begin{remarks}\\\n  \\begin{enumerate}\n  \\item  Either one or both of the algebras in Theorem~\\ref{thm:berman-1-18} can be\n    taken to be unary.\n  \\item It follows easily from Theorem~\\ref{thm:berman-1-18} that the class\n    of lattices isomorphic to strong congruence lattices of finite\n    partial algebras is equal to the class of lattices isomorphic to\n    congruence lattices of finite partial algebras.\n    (This is~\\cite[Thm~1.19]{MR2619731}.)\n  \\end{enumerate}\n\\end{remarks}\n\n\\section*{Acknowledgments}\nThe author would like to thank Peter Jipsen\nand Bill Lampe for many helpful discussions.\n\n\n%% \\appendix\n%% \\section{Appendix Title}\n%% This is the text of the appendix, if you need one.\n\n%\\bibliographystyle{amsplain} %% or amsalpha\n%% \\bibliographystyle{plain-url}\n\\printbibliography\n\n\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "2598a5f5253dfd23f1ffe58088f787f31da941f1", "size": 27530, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "par-alg-rep.tex", "max_stars_repo_name": "UniversalAlgebra/par-alg-rep", "max_stars_repo_head_hexsha": "e6d4d5678c9882cafc9c9f9d7df1976dd54fcf71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "par-alg-rep.tex", "max_issues_repo_name": "UniversalAlgebra/par-alg-rep", "max_issues_repo_head_hexsha": "e6d4d5678c9882cafc9c9f9d7df1976dd54fcf71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "par-alg-rep.tex", "max_forks_repo_name": "UniversalAlgebra/par-alg-rep", "max_forks_repo_head_hexsha": "e6d4d5678c9882cafc9c9f9d7df1976dd54fcf71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.4258443465, "max_line_length": 159, "alphanum_fraction": 0.6539048311, "num_tokens": 9232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.672331705744791, "lm_q1q2_score": 0.40604251992255297}}
{"text": "\\chapter{The $N$-representability problem}\\label{ch2}\n\nFor a given wave function, the \\gls{2dm} can be calculated using its definition. However, when given a random symmetric matrix,\nis it possible to find a corresponding (ensemble of) wave function which has the given matrix as the \\gls{2dm}? This is the essence of the $N$-representability problem.\n\n\\section{General \\mbox{$N$-representability} theorem}\\label{ch2-general-n-rep}\nA graphical depiction of this theorem can be found in \\Vref{ch2-fig1}. The boundary of the convex set\nof $N$-representable $p$th-order reduced density matrices is formed by an infinite number of tangent hyperplanes, where\neach hyperplane represents a $p$-particle Hamiltonian and its ground state energy.\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{n-representability}\n    \\caption{Graphical depiction of the necessary and sufficient conditions for $N$-representability. Every Hamiltonian $H^{(p)}$ can be represented by a hyperplane that bounds the convex set of $N$-representable ${^p\\Gamma}$.}\n    \\label{ch2-fig1}\n\\end{figure}\n\n\\section{Approximately $N$-representability conditions}\\label{2-approx-n-representability}\nIn \\Vref{ch2-general-n-rep} we showed the necessary and sufficient conditions for $N$-representability. These required the knowledge of the\nground state energy of every possible Hamiltonian and are thus not usable as a sufficient condition. We can, however, use it as a necessary\ncondition: if we restrict XX to Hamiltonians of which we know the ground state energy or a lower bound on it, we can approximate the convex set of $N$-representable \\gls{2dm}'s.\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.9\\textwidth]{approx-n-representability}\n    \\caption{Graphical depiction of the necessary conditions for $N$-representability. $H_1^{(p)}$ belongs to the class of Hamiltonians of which we know a bound on ground state energy while $H_2^{(p)}$ does not. The true convex set of $N$-representable ${^p\\Gamma}$ is smaller than the approximate convex set delimited by the Hamiltonians of the class of $H_1^{(p)}$.}\n    \\label{ch2-fig3}\n\\end{figure}\nIn \\Vref{ch2-fig3} we give a graphical interpretation of this idea. The approximate set of $N$-representable \\gls{2dm} will be larger than the true set: there will be \\gls{2dm}'s which fulfil all the necessary conditions but are still not derivable from an ensemble of wave functions.\nAs a consequence the variational optimization of the \\gls{2dm} will give a lower bound on the energy. This is one of the highly attractive features of \\gls{v2dm}.\n\n\\section{Symmetry considerations}\\label{ch2-sym}\n\n\\subsection{Spatial point group symmetry}\\label{ch2-pointsym}\n\nFor example, the $\\ce{C2H4}$ molecule shown in \\Vref{2-fig4} has $D_{2h}$ symmetry.\n\\begin{figure}[h]\n    \\centering\n    \\chemfig{H-[1]C(-[3]H)=C(-[1]H)(-[:-45]H)}\n    \\caption{The ethylene molecule has $D_{2h}$ symmetry.}\n    \\label{2-fig4}\n\\end{figure}\nThe main two-fold rotation axis is the connecting axis between the two carbon atoms (the z-axis). The two two-fold rotation axes are the x- and y-axis. The three reflection planes are xy, xz and yz.\n\nAs an example, we show the character table and the multiplication table of $C_{2}$ group in \\Vref{2-tab1}.\n\\begin{table}\n    \\begin{subtable}{.5\\linewidth}\n        \\centering\n        \\begin{tabular}{c|cc}\n            & $E$ & $C_2$ \\\\\n            \\hline\n            A & 1 & 1 \\\\\n            B & 1 & -1\n        \\end{tabular}\n        \\caption{Character table of $C_2$}\n        \\label{2-tab1a}\n    \\end{subtable}\n    ~\n    \\begin{subtable}{.5\\linewidth}\n    \\centering\n    \\begin{tabular}{c|cc}\n        & A & B \\\\\n        \\hline\n        A & A & B \\\\\n        B & B & A \n    \\end{tabular}\n    \\caption{Multiplication table of $C_2$}\n    \\label{2-tab1b}\n    \\end{subtable}\n    \\caption{$C_2$ overview: it has 2 classes of operations. The identity operation and rotations over $180\\degree$. The two irreducible representations are $A$ and $B$.}\n    \\label{2-tab1}\n\\end{table}\nThe character table contains the trace of the matrices of the irreducible representations. It it split up into conjugacy classes as the trace is invariant under a similarity transformation. These tables are extremely useful for decomposing a representation in its irreducible parts. The first irreducible representation $A$ is called the trivial representation because all the representation matrices (scalars in this case) are one. Every group has this irreducible representation.\n\n\\section{The doubly-occupied Hilbert space}\\label{ch2-doci}\nIn previous sections, we only made general assumptions about the (ensemble of) wave functions from which the \\gls{2dm} is derivable. All wave functions should be normalized and antisymmetric. For symmetry, we made assumptions on the quantum numbers of the wave function: it should be a singlet wave function, or the wave function should transform according to a certain irreducible representation.\nBut we could make other or additional assumptions. If we take a look at the \\acrfull{fullci} expansion of the wave function, we see that a Slater determinant is the basic building block\n\\begin{equation}\n    \\ket{\\Psi} = \\sum_\\mathbf{k} \\sum_\\mathbf{s} c_{\\mathbf{k};\\mathbf{s}} ~ \\padd{k_1 s_1}\\padd{k_2s_2}\\ldots\\padd{k_Ns_N}\\ket{},\n        \\label{2-eq106}\n\\end{equation}\n\n% vim: spell spelllang=en syntax=tex  tw=140\n", "meta": {"hexsha": "169634413753ed906217c85f79ad7edd4ff74802", "size": 5385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "n-representability.tex", "max_stars_repo_name": "wpoely86/PhD-template", "max_stars_repo_head_hexsha": "2415b5954e9140bf21d57121f263118abd558283", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "n-representability.tex", "max_issues_repo_name": "wpoely86/PhD-template", "max_issues_repo_head_hexsha": "2415b5954e9140bf21d57121f263118abd558283", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "n-representability.tex", "max_forks_repo_name": "wpoely86/PhD-template", "max_forks_repo_head_hexsha": "2415b5954e9140bf21d57121f263118abd558283", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.6707317073, "max_line_length": 481, "alphanum_fraction": 0.7351903435, "num_tokens": 1469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4060425159574356}}
{"text": "\\section{Machine Learning Fundamentals} \\label{sec:bt/MLF}\n\nArtificial intelligence is a field of research that has been practiced for a very long time, contrary to popular belief. The first work that is now recognized as AI was written by \\textcite{mcculloch1943}. Even still, the concept of artifacts operating under their own control can be traced back to Alexandria ca. 250 BC, where a water regulator was built that could maintain a constant flow rate. Other examples of self-regulating feedback control systems include the steam engine governor and the thermostat, all invented before the 19th-century \\cite{russell2009}. This thesis will concentrate on machine learning, a particular form of artificial intelligence that employs prior knowledge of historical data to tackle tasks that are too difficult to solve with fixed programs written and designed by human beings \\cite{goodfellow2016}.\n\n% \\subsection{Statistical Inference}\n\\subsection{Learning Algorithms}\n\nA machine learning algorithm is characterized by the fact that it can learn properties from data. \\textcite{mitchell1997} famously defines this aspect of learning as \"A computer program is said to learn from experience $E$ with respect to some class of tasks $T$ and performance measure $P$, if its performance at tasks in $T$, as measured by $P$, improves with experience $E$.\" Since machine learning algorithms can be employed in a wide range of problems and trained by an equally wide range of methods, $T$, $P$, and $E$ in this definition can be constructed as just about anything. However, a very common class of tasks $T$ central to this thesis is that of \\textit{classification}. The experience $E$ required to train towards this task is usually provided through either \\textit{supervised-} or \\textit{unsupervised learning}. \n\n\\subsubsection{Classification}\n\n% In the classification task, the computer program is asked to determine which of $k$ discrete categories some input belongs. \nClassification is the task of determining which of $k$ discrete categories some input belongs. Given data (experience $E$) produced by a function $f:\\mathbb{R}^{2}\\to\\{1,\\dots,k\\}$, a learning algorithm tasked with classification will generate a hypothesis $h:\\mathbb{R}^{2}\\to\\{1,\\dots,k\\}$ that approximates $f$. Given an input vector $\\bm{x}$, $h(\\bm{x})$ outputs a probability distribution over possible categories. One popular application is that of object detection, where an image is given as the input $\\bm{x}$, and the output is the category to which an object in the image belongs. If $k=2$, the learning problem is called binary classification, and the hypothesis $h$ merely outputs the probability of whether an input represents a single target category or not. Multi-class classification is more common in the general case, however. \n\n% \\subsubsection{The No Free Lunch Theorem}\n\nSince we often cannot assume any prior knowledge of the inherent properties of $f$, choosing a hypothesis $h$ with which to approximate it is no trivial task. We say that $h$ is selected from a \\textit{hypothesis space} $\\mathcal{H}$, which needs to be defined by the learning algorithm designer. Looking at figure \\ref{fig:bt_hypotheses}, one can see the importance of choosing a hypothesis space that is complex enough to approximate $f$ accurately yet simple enough that the function does not overfit. For this example, a 12-degree polynomial is required to produce an approximation that perfectly agrees with all the data. However, since we cannot assume that $f$ is not stochastic, this polynomial might generalize poorly to unseen data. In such a case, a simpler hypothesis in a linear or a sinusoidal function might be the optimal choice.\n\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{figures/bt_hypotheses.png}\n    \\caption{Finding hypotheses to fit data. The four plots each show best-fit functions from four different hypothesis spaces trained on the same dataset.}\n    \\source{\\cite{russell2009}}\n    \\label{fig:bt_hypotheses}\n\\end{figure}\n\n\\subsubsection{Supervised Learning}\n\nA machine learning algorithm can be called a supervised learning algorithm if it is trained by experiencing a dataset of examples $\\bm{x}$, where each example is associated with a target $y$. The training process thus becomes to approximate a function that can reproduce $y$ given $\\bm{x}$.\n\nOne classic learning algorithm is linear regression, which is supervised learning in its simplest form \\cite{goodfellow2016}. The goal of linear regression is to predict a target value $\\hat{y}\\in\\mathbb{R}$ from an $n$-dimensional input vector $\\bm{x}\\in\\mathbb{R}^n$. Since we know then that the output should be a linear function of the input, the problem becomes to approximate the hypothesis given by equation \\ref{eq:bt_linReg}. Here $\\bm{w}\\in\\mathbb{R}^n$ is a vector of model parameters, which control the behavior of the system.\n\n\\begin{equation}\n    \\label{eq:bt_linReg}\n    h(\\bm{x})=\\hat{y}=\\bm{w}^T\\bm{x}\n\\end{equation}\n\nNow, to determine the optimal value of $\\bm{w}$, we need a performance measure $P$. For this particular problem, a typical choice is the \\textit{mean squared error} (MSE), given in equation \\ref{eq:bt_MSE}. MSE is calculated from a matrix of $m$ input vectors $\\bm{X}=\\{\\bm{x}_1,\\dots,\\bm{x}_m\\}$, their corresponding $m$ target values $\\bm{y}=\\{y_1,\\dots,y_m\\}$, and model parameters $\\bm{w}$.\n\n\\begin{equation}\n    \\label{eq:bt_MSE}\n    MSE=\\frac{1}{m}\\sum_{i}(\\hat{\\bm{y}}-\\bm{y})^2\n    =\\frac{1}{m}||\\hat{\\bm{y}}-\\bm{y}||^2_2\n\\end{equation}\n\nBy setting $\\hat{\\bm{y}}=\\bm{y}$, one can see that $MSE=0$, and furthermore that it increases linearly with the euclidean distance between $\\hat{\\bm{y}}$ and $\\bm{y}$. As such, the optimal model parameters can be obtained by minimizing $MSE$ with respect to $\\bm{w}$. This can be done by solving for where its gradient is $\\bm{0}$, as is in equations \\ref{eq:bt_MSE_gradientB} to \\ref{eq:bt_MSE_gradientE}.\n\n\\begin{equation}\n    \\label{eq:bt_MSE_gradientB}\n    \\nabla_{\\bm{w}}MSE=\\bm{0}\n\\end{equation}\n\\begin{equation}\n    \\Rightarrow \\nabla_{\\bm{w}}\\frac{1}{m}||\\hat{\\bm{y}}-\\bm{y}||^2_2=\\bm{0}\n\\end{equation}\n\\begin{equation}\n    \\Rightarrow \\nabla_{\\bm{w}}\\frac{1}{m}||\\bm{X}\\bm{w}-\\bm{y}||^2_2=\\bm{0}\n\\end{equation}\n\\begin{equation*}\n    \\vdots\n\\end{equation*}\n\\begin{equation}\n    \\label{eq:bt_MSE_gradientE}\n    \\Rightarrow \\bm{w}=(\\bm{X}^T\\bm{X})^{-1}\\bm{X}^T\\bm{y}\n\\end{equation}\n\nEvaluation of equation \\ref{eq:bt_MSE_gradientE} results in a value of $\\bm{w}$ which optimally fits the training dataset. As such, it constitutes a simple learning algorithm \\cite{goodfellow2016}.\n\n% For object detection, each image in the dataset is accompanied by a value representing the object it displays. \n\n% \\subsection{Decision Tree Classifier}\n\n% Decision tree induction is one of the simplest and yet most successful forms of machine learning (\\cite{russell2009}). It is also a supervised learning algorithm, as it requires a dataset of labeled examples to be trained. The Decision Tree Classifier takes a vector of attribute values as input and returns a \"decision.\" It reaches this decision by performing a sequence of tests on one or more attributes. An example is presented in figure \\ref{fig:bt_decision_tree}. Here, one can imagine that the species of an animal is to be determined based upon a set of attributes \\{\"Has feathers?\", \"Can fly?\", \"Has finns?\"\\}. The likely animal species can be determined by following a path from the root node to a leaf node. Although this example is simple, the general principle holds for more complex classification problems as well.\n\n% \\begin{figure}[h]\n%     \\centering\n%     \\includegraphics[width=0.5\\textwidth]{Images/bt_decision_tree.png}\n%     \\caption{Decision Tree Example. Each internal node represents a test on one attribute, and its branches are labeled with possible attribute values. Leaf nodes represent a decision.}\n%     \\label{fig:bt_decision_tree}\n% \\end{figure}\n\n% The training process of decision trees is done with specialized algorithms, the specific details of which are outside the scope of this thesis. However, they are usually based on a greedy divide-and-conquer strategy, where the training dataset is split on whatever attribute is most important. Which attribute this is, and at what attribute value the split is done, is determined by a notion of \\textit{information gain}. \n\n% \\subsection{Ensemble Learning}\n\n% Ensemble learning is a relatively straightforward method that has a remarkable effect of reducing generalization error (\\cite{goodfellow2016}). When a machine learning model has been trained, one is left with a single hypothesis $h$ that, to a certain degree, is able to approximate some function $f$. However, if the model is trained once more, the resulting approximation would likely produce slightly differing predictions. The notion of ensemble learning is to train multiple independent models and combine their predictions. Specifically, by determining the output by majority voting or an average, the method is termed \\textit{model averaging}. \n% Some ensemble methods construct their ensemble of models by random, others by some rationale. \\textit{Bootstrap aggregating} (bagging), for example, trains each model on a subset of the original training dataset by sampling at random with replacement. This strategy ensures an inherent distinction between models, which offers a broader hypothesis space and reduced generalization error.", "meta": {"hexsha": "8420d796a8bafccdeb5db49860c8a6afb5d54984", "size": 9479, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/background/MLF.tex", "max_stars_repo_name": "JLysberg/thesis-NTNU", "max_stars_repo_head_hexsha": "c0a9631f89a0112b2ade27d05c22818745706fb8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/background/MLF.tex", "max_issues_repo_name": "JLysberg/thesis-NTNU", "max_issues_repo_head_hexsha": "c0a9631f89a0112b2ade27d05c22818745706fb8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/background/MLF.tex", "max_forks_repo_name": "JLysberg/thesis-NTNU", "max_forks_repo_head_hexsha": "c0a9631f89a0112b2ade27d05c22818745706fb8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 110.2209302326, "max_line_length": 846, "alphanum_fraction": 0.7686464817, "num_tokens": 2329, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4060425159574356}}
{"text": "\\chapter{CHAPTER TITLE}\n\\label{chp:chapter_1}\n\nThis chapter describes the ... In Section~\\ref{sec:SECTIONTITLE}, examples are given om how to use tables and figures in this MSc thesis.\n\n\\section{SECTION TITLE}\n\\label{sec:SECTIONTITLE}\n\n\nDefine models with math, such that\n%\n\\begin{equation}\nx = a^2 + b^2,\n\\label{eq:EQUATION}\n\\end{equation}\n%\nwhere $a$ and $b$ are your parameters, define your system.\n\nRemarks on style:\n\n\\begin{enumerate}\n\t\\item use `Section` name to refer to sections when citing (so Section~\\ref{sec:SECTIONTITLE} not Sec.~\\ref{sec:SECTIONTITLE} or Subsection~\\ref{sec:SECTIONTITLE}); Same comment applies to Tables, Algorithms and Figures\n\t\\item Tables and figures must be at the top of the page---use [t] marker (not [h], for `here`); \n\t\\item Every caption should end with a period;\n\t\\item Encapsulate equations in `()` brackets and do not add word `equation before` (therefore `in~(\\ref{eq:EQUATION})`, not `in Equation~\\ref{eq:EQUATION}` or in Eq.~\\ref{eq:EQUATION});\n\t\\item Equations are sentences, so punctuation applies at the end of it (comma, semicolon or full-stop).\n\\end{enumerate}\n\nHere is a simple table\n\n\\begin{table}[t]\n\\centering\n\\begin{tabular}{| l | c | r |}\n\\hline\nleft aligned & centred & right aligned \\\\\n\\hline \\hline\n12 & 34 & 56 \\\\\n\\hline\n\\end{tabular}\n\\caption{Complete sentence describing the tabular data. Caption should summarize the conclusions of the result.}\n\\label{tab:table_1}\n\\end{table}\n\nHere is a simple figure.\n\n\\begin{figure}[t]\n\\includegraphics[width=\\textwidth]{template-pics/tud-ens-logo-tikz/tud-ens-logo}\n\\caption{Complete sentence describing the figure thoroughly. Caption should summarize the conclusions of the result.}\n\\label{fig:example-figure}\n\\end{figure}\n\nCitations are here~\\cite{polastre2004analysis,powercast_website,hester2016persistent,schaper_msc_thesis_2017,dementyev_uist_2016}. See `bib/MyMScTUDENSThesisBibFile.bib` file for a list of requirements when typesetting a bibliography.", "meta": {"hexsha": "58cf9ae8899ccff518544545ad04c0c73e9d1a2c", "size": 1961, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chapter_1.tex", "max_stars_repo_name": "souravmohapatra/TUD_ENS_MSc_Thesis_Template", "max_stars_repo_head_hexsha": "42e6e446037547c2a864c2847adc85835643428b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-08-29T07:22:55.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-04T09:24:40.000Z", "max_issues_repo_path": "chapters/chapter_1.tex", "max_issues_repo_name": "souravmohapatra/TUD_ENS_MSc_Thesis_Template", "max_issues_repo_head_hexsha": "42e6e446037547c2a864c2847adc85835643428b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-09-03T08:58:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T11:00:04.000Z", "max_forks_repo_path": "chapters/chapter_1.tex", "max_forks_repo_name": "souravmohapatra/TUD_ENS_MSc_Thesis_Template", "max_forks_repo_head_hexsha": "42e6e446037547c2a864c2847adc85835643428b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2019-09-03T08:50:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T10:22:46.000Z", "avg_line_length": 37.7115384615, "max_line_length": 234, "alphanum_fraction": 0.7593064763, "num_tokens": 572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4060425159574356}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** Third Chapter *****************************\n%*******************************************************************************\n\n\\chapter{Numerical Methods}  %Title of the Third Chapter\n\n\\ifpdf\n    \\graphicspath{{Chapter3/Figs/PDF/}{Chapter3/Figs/}}\n\\else\n    \\graphicspath{{Chapter3/Figs/}}\n\\fi\n\nIn this chapter, we are going to discuss the details of the numerical method used in \\texttt{Gmunu} \\cite{cheong2020gmunu,cheong2020gmunu_amr}.\nIn the fully-constrained scheme, the evolution of relativistic hydrodynamics in dynamical spacetime\nconsists of a set of coupled hyperbolic-elliptic system.\nFirstly, we discuss the numerical method adopted for the hyperbolic system in \\texttt{Gmunu},\nincluding the high-resolution shock-capturing (HRSC) method and the finite volume method.\nThen, we discuss the multigrid solver in \\texttt{Gmunu},\nwhich is used to solve the elliptic system.\n\n%********************************** %First Section  **************************************\n\\section{High-resolution shock-capturing (HRSC) methods}\nThe high-resolution shock-capturing (HRSC) methods is a class of methods commonly used to\nreproduce accurately the discontinuous features in the solution\nwith no spurious oscillation \\cite{harten1997high}.\nNote that the HRSC methods can be distinguished in \\textit{finite-difference (conservative)} method\nwhich evolves the \\textit{pointwise values} of the solution,\nand \\textit{finit-volume (conservative)} method which evolves the \\textit{cell average} of the solution.\nAlthough the accuracy of finite-difference method can be extended to higher order easily,\nit is extremely diffcult to extend the method to general non-uniform grids \\cite{merriman2003understanding}.\nOn the other hand,\nthe finite-volume methods are natural to conservative scheme as well as non-structured grid,\nbut the multidimensional reconstruction algorithm is complicated and computational expensive especially for higher-order method.\\\\\nIn this section,\nwe will first discuss the finite-volume conservative methods,\nand then focus on the \\textit{Godunov methods} which guarantee the upwind property of conservative non-linear equations \\cite{van1999introduction}.\n\n\\subsection{Finite-volume conservative methods}\nGiven the conservative equation in orthogonal coordinate system $(x^1, x^2, x^3)$ in form\n\\begin{align}\\label{eq:finite_vol_cons}\n    \\partial_t \\mathbf{q} + \\frac{1}{\\sqrt{\\hat{\\gamma}}}\\hat{\\nabla}_i \\left( \\sqrt{\\hat{\\gamma}} \\mathbf{f}^i \\right)\n    &= \\mathbf{s} + \\mathbf{s}_{geom},\n\\end{align}\nwhere $\\mathbf{q}$ are the conserved variables,\n$\\mathbf{f}^i$ are the flux terms, $\\mathbf{s}$ are the source terms\nand $\\mathbf{s}_{geom}$ are the geometrical source term which is related to the 3-Christoffel symbol\n$\\hat{\\Gamma}^i{}_{jk}$ of the reference metric $\\hat{\\gamma}_{ij}$.\nWe can then discretize equation (\\ref{eq:finite_vol_cons}) on a computational domain divided into $N_1 \\times N_2 \\times N_3$ cells.\nEach cells can be represented by a tuple of integers $(i,j,k)$ where $1 \\leq i \\leq N_1$, $1 \\leq j \\leq N_2$ and $1 \\leq k \\leq N_3$.\nThe cell bounds are given by\n\\begin{align}\n    (x^1_{i-1/2}, &x^1_{i+1/2}), & (x^2_{j-1/2}, &x^2_{j+1/2}), & (x^3_{k-1/2}, &x^3_{k+1/2}).\n\\end{align}\nThus, the mesh cell spacings are \n\\begin{align}\n    \\Delta x^1_i &= x^1_{i+1/2} - x^1_{i-1/2}, & \\Delta x^2_j &= x^2_{j+1/2}- x^2_{j-1/2}, & \\Delta x^3_k &= x^3_{k+1/2} - x^3_{k-1/2},\n\\end{align}\nand the cell centres are\n\\begin{align}\n    x^1_i &= \\frac{1}{2} \\left(x^1_{i+1/2} + x^1_{i-1/2}\\right), & x^2_j &= \\frac{1}{2} \\left( x^2_{j+1/2}- x^2_{j-1/2} \\right), \n    & x^3_k &= \\frac{1}{2} \\left( x^3_{k+1/2} - x^3_{k-1/2} \\right).\n\\end{align}\nBy integrating equation \\ref{eq:finite_vol_cons} over cell volume and applying divergence theorem on the flux terms,\nit becomes\n\\begin{align}\n    \\begin{split}\n    \\frac{d}{dt} \\left\\langle \\mathbf{q} \\right\\rangle_{i,j,k} = - \\frac{1}{\\Delta V_{i,j,k}} \\bigg\\{ &\\left[\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^1 \\Delta A^1 \\right) \\right|_{i+1/2,j,k} -\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^1 \\Delta A^1 \\right) \\right|_{i-1/2,j,k} \\right] \\\\\n    + &\\left[\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^2 \\Delta A^2 \\right) \\right|_{i,j+1/2,k} -\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^2 \\Delta A^2 \\right) \\right|_{i,j-1/2,k} \\right] \\\\\n    + &\\left[\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^3 \\Delta A^3 \\right) \\right|_{i,j,k+1/2} -\n    \\left. \\left( \\left\\langle \\mathbf{f} \\right\\rangle^3 \\Delta A^3 \\right) \\right|_{i,j,k-1/2} \\right] \\bigg\\} \\\\\n    + &\\left\\langle \\mathbf{s} \\right\\rangle_{i,j,k}\n    + \\left\\langle \\mathbf{s}_{geom} \\right\\rangle_{i,j,k}\n    \\end{split}\n\\end{align}\nwhere the cell volume and the volume-average are defined as\n\\begin{align}\n    \\Delta V_{i,j,k} &\\coloneqq \\int_{cell} \\sqrt{\\hat{\\gamma}} dx^1 dx^2 dx^3, &\n    \\left\\langle \\bullet \\right\\rangle &\\coloneqq \\frac{1}{\\Delta V_{i,j,k}} \\int_{cell} \\bullet \\sqrt{\\hat{\\gamma}} dx^1 dx^2 dx^3\n\\end{align},\nwhile the cell surface and the surface-average are defined as\n\\begin{align}\n    \\Delta A^i &\\coloneqq \\int_{surface} \\sqrt{\\hat{\\gamma}} dx^{j,j\\neq i}, &\n    \\left\\langle \\bullet \\right\\rangle &\\coloneqq \\frac{1}{\\Delta A^i} \\int_{surface} \\bullet \\sqrt{\\hat{\\gamma}} dx^{j,j\\neq i}.\n\\end{align}\nSince the reference metric $\\hat{\\gamma}_{ij}$ is time-independent,\nthe cell volume, cell surface and the volume-averaged 3-Christoffel symbols\n$\\left\\langle \\hat{\\Gamma}^i{}_{jk} \\right\\rangle$ in the geometrical source term\nare determined once the coordinate is chosen.\nWe have included these quantities in Appendix.\n\n\\subsection{Godunov methods}\n\\label{section3.1.2}\nFor simplicity, we consider one-dimensional hyperbolic conservation laws\n\\begin{align}\\label{eq:conservation_law}\n    \\partial_t \\mathbf{q}\\left(x,t\\right) + \\partial_x \\mathbf{f} \\left[\\mathbf{q}\\left(x,t\\right)\\right] &= 0,\n\\end{align}\nWe apply the discretization on spatial domain into computing cell $I_j$ with size $\\Delta x$\n\\begin{align}\n    I_j &= \\left[ x_{j-1/2},x_{j+1/2} \\right], & \\Delta x &= x_{j+1/2}-x_{j-1/2},\n\\end{align}\nand time slices $\\left[t^n, t^{n+1}\\right]$.\nThus, equation (\\ref{eq:conservation_law}) can be recasted into a \\textit{conservative} scheme as\n\\begin{align}\n    \\left\\langle\\mathbf{q}\\right\\rangle^{n+1}_j &= \\left\\langle\\mathbf{q}\\right\\rangle^n_j \n    + \\frac{\\Delta t}{\\Delta x} \\left( \\left\\langle\\mathbf{f}\\right\\rangle_{j-1/2} - \\left\\langle\\mathbf{f}\\right\\rangle_{j+1/2} \\right),\n\\end{align}\nwhere\n\\begin{align}\n    \\left\\langle\\mathbf{q}\\right\\rangle^{n}_j &\\coloneqq \\frac{1}{\\Delta x} \\int^{x_{j+1/2}}_{x_{j-1/2}} \\mathbf{q} \\left(x, t^n\\right) dx\n\\end{align}\nis the \\textit{cell-average} and\n\\begin{align}\n    \\left\\langle\\mathbf{f}\\right\\rangle_{j\\pm 1/2} &\\coloneqq \\frac{1}{\\Delta t} \\int^{t^{n+1}}_{t^n} \\mathbf{f} \\left[\\mathbf{q}\\left(x_{j\\pm 1/2},t\\right)\\right] dt\n\\end{align}\nis the \\textit{numerical fluxes}.\\\\\nIn Godunov's original approach \\cite{konstantinovich1959difference},\nhe considered a piecewise-constant distribution of data\n\\begin{align}\n    \\mathbf{q}(x, t^n) &=\n    \\begin{cases}\n        \\left\\langle\\mathbf{q}\\right\\rangle^{n}_j  &\\text{if } x \\leq x_{j+1/2}, \\\\\n        \\left\\langle\\mathbf{q}\\right\\rangle^{n}_{j+1}  &\\text{if } x >x_{j+1/2},\n    \\end{cases}\n\\end{align}\nand built a local Riemann problem \n$\\mathcal{RP}\\left(\\left\\langle \\mathbf{q}\\right\\rangle_{L}, \\left\\langle \\mathbf{q} \\right\\rangle_{R} \\right)$\nwith left state $\\left\\langle \\mathbf{q}\\right\\rangle_{L} = \\left\\langle\\mathbf{q}\\right\\rangle^{n}_j$ and\nright state $\\left\\langle \\mathbf{q} \\right\\rangle_{R} = \\left\\langle\\mathbf{q}\\right\\rangle^{n}_{j+1}$.\nTherefore, the numerical fluxes\n\\begin{align}\n    \\left\\langle\\mathbf{f}\\right\\rangle_{j+ 1/2} &= \n    \\frac{1}{\\Delta t} \\int^{t^{n+1}}_{t^n} \\mathbf{f} \\left[\\mathbf{q}\\left(x_{j+ 1/2},t\\right)\\right] dt\n    = \\mathcal{F}\\left( \\left\\langle\\mathbf{q}\\right\\rangle^{n}_j, \\left\\langle\\mathbf{q}\\right\\rangle^{n}_{j+1} \\right)\n\\end{align}\nonly depends on the two constant states $\\left\\langle\\mathbf{q}\\right\\rangle^{n}_j$ and $\\left\\langle\\mathbf{q}\\right\\rangle^{n}_{j+1}$.\\\\\nNote that the Godunov method is a \\textit{monotone method}.\nConsider an explicit method of the type\n\\begin{align}\n    \\left\\langle \\mathbf{q}\\right\\rangle^{n+1}_j &=\n    \\mathcal{H} \\left(\\left\\langle \\mathbf{q}\\right\\rangle^n_j, \\left\\langle \\mathbf{q}\\right\\rangle^n_{j\\pm 1},\n    \\left\\langle \\mathbf{q}\\right\\rangle^n_{j\\pm 2}, \\dots,\n    \\left\\langle \\mathbf{q}\\right\\rangle^{n-m}_j,\\left\\langle \\mathbf{q}\\right\\rangle^{n-m}_{j\\pm 1},\n    \\left\\langle \\mathbf{q}\\right\\rangle^{n-m}_{j\\pm 2}, \\dots \\right).\n\\end{align}\nThe method is \\textit{monotone} if\n\\begin{align}\n    \\frac{\\partial \\mathcal{H}}{\\partial \\left\\langle \\mathbf{q}\\right\\rangle^n_j } &\\geq 0\n    \\quad \\forall \\left\\langle \\mathbf{q}\\right\\rangle^n_j.\n\\end{align}\nFrom this definition, we can further prove that given the data $\\{ \\left\\langle \\mathbf{q}\\right\\rangle^n_j \\}$,\nthe solution $\\{ \\left\\langle \\mathbf{q}\\right\\rangle^{n+1}_j \\}$ obtained by a monotone method is\n\\begin{align}\n    \\max_{j} \\{ \\left\\langle \\mathbf{q}\\right\\rangle^{n+1}_j \\} &\\leq \\max_{j} \\{\\left\\langle \\mathbf{q}\\right\\rangle^n_j \\}, &\n    \\min_{j} \\{ \\left\\langle \\mathbf{q}\\right\\rangle^{n+1}_j \\} &\\geq \\min_{j} \\{\\left\\langle \\mathbf{q}\\right\\rangle^n_j \\},\n\\end{align}\nthat is, no spurious new extrema introduced in the solution as time evolves.\n\n\\subsection{Reconstruction scheme}\nThe Godunov method introduced in the previous section is only first-order accurate in space and time\nbecause of the piecewise-constant distribution of data.\nIn practice, the spatial accuracy can be higher than first-order \nif the left state $\\left\\langle \\mathbf{q} \\right\\rangle_{L}$ \nand right state $\\left\\langle \\mathbf{q} \\right\\rangle_{R}$ of the Riemann problem\nat the cell interface $x_{j+1/2}$\nare \\textit{reconstructed} using a higher-order polynomial representation of $\\mathbf{q}$\nrather than $\\left\\langle \\mathbf{q} \\right\\rangle^n_j$ and $\\left\\langle \\mathbf{q} \\right\\rangle^n_{j+1}$.\\\\\nOne of the reconstruction techniques are the \\textit{slope-limiter} methods \nwhich improve the piecewise-constant representation by providing a piecewise-linear reconstruction\nof $\\mathbf{q}^n(x)$ at each cell\n\\begin{align}\n    \\mathbf{q}^n_j (x) &= \\left\\langle \\mathbf{q} \\right\\rangle^n_j + \\mathbf{\\sigma}^n_j \\left(x-x_j \\right) &\n    \\text{for } & x_{j-1/2} \\leq x \\leq x_{j+1/2},\n\\end{align}\nwhere $\\mathbf{\\sigma}^n_j$ is the slope of the linear reconstruction.\nHere, we list out several common slope-limiters\n\\paragraph{Minmod slope-limiter}\nThe \\textit{minmod slope-limiter} \\cite{ziegler2011semi,kolgan1972application,van1979towards}\nis given by\n\\begin{align}\n    \\mathbf{\\sigma}^n_j &\\coloneqq \\text{minmod}\\left(\n    \\frac{\\left\\langle \\mathbf{q} \\right\\rangle^n_j-\\left\\langle \\mathbf{q} \\right\\rangle^n_{j-1}}{\\Delta x},\n    \\frac{\\left\\langle \\mathbf{q} \\right\\rangle^n_{j+1}-\\left\\langle \\mathbf{q} \\right\\rangle^n_{j}}{\\Delta x} \\right),\n\\end{align}\nwhere\n\\begin{align}\n    \\text{minmod}\\left(\\alpha, \\beta \\right) &\\coloneqq\n    \\begin{cases}\n        \\alpha & \\text{if } |\\alpha|<|\\beta| \\text{ and } \\alpha\\beta>0, \\\\\n        \\beta & \\text{if } |\\alpha|>|\\beta| \\text{ and } \\alpha\\beta>0, \\\\\n        0 & \\text{if } \\alpha\\beta \\leq 0,\n    \\end{cases}\\\\\n    &\\coloneqq \\frac{1}{2}\\left[ \\text{sgn}{\\alpha} + \\text{sgn}{\\beta} \\right] \\min \\left(|\\alpha|,|\\beta| \\right).\n\\end{align}\n\n\\paragraph{Monotonized central-difference (MC) limiter}\nThe MC limiter \\cite{van1974towards} is given by\n\\begin{align}\n    \\mathbf{\\sigma}^n_j &\\coloneqq \\text{minmod}\\left(\n    \\frac{\\left\\langle \\mathbf{q} \\right\\rangle^n_{j+1}-\\left\\langle \\mathbf{q} \\right\\rangle^n_{j-1}}{2 \\Delta x},\n    \\frac{\\left\\langle \\mathbf{q} \\right\\rangle^n_j-\\left\\langle \\mathbf{q} \\right\\rangle^n_{j-1}}{\\Delta x},\n    \\frac{\\left\\langle \\mathbf{q} \\right\\rangle^n_{j+1}-\\left\\langle \\mathbf{q} \\right\\rangle^n_{j}}{\\Delta x} \\right),\n\\end{align}\nwhere\n\\begin{align}\n    \\text{minmod}\\left(\\alpha, \\beta, \\gamma \\right) &\\coloneqq\n    \\begin{cases}\n        \\min\\left(\\alpha, \\beta, \\gamma\\right) & \\text{if } \\alpha,\\beta,\\gamma > 0, \\\\\n        \\max\\left(\\alpha, \\beta, \\gamma\\right) & \\text{if } \\alpha,\\beta,\\gamma < 0, \\\\\n        0 & \\text{otherwise}.\n    \\end{cases}\n\\end{align}\\\\\nNote that the methods mentioned above are \\textit{total variation diminishing (TVD)}.\nThe total variation of a solution at time $t^n$ is defined as\n\\begin{align}\n    \\text{TV}\\left( \\left\\langle \\mathbf{q} \\right\\rangle^n \\right) &\\coloneqq \n    \\sum_i \\left| \\left\\langle \\mathbf{q} \\right\\rangle^n_{j+1} - \\left\\langle \\mathbf{q} \\right\\rangle^n_j \\right|,\n\\end{align}\nwhich measures the oscillations appeared in the solution.\nA numerical method is called \\textit{total variation diminishing (TVD)} if it satisfies\n\\begin{align}\\label{eq:TVD}\n    \\text{TV}\\left( \\left\\langle \\mathbf{q} \\right\\rangle^{n+1} \\right) \\leq\n    \\text{TV}\\left( \\left\\langle \\mathbf{q} \\right\\rangle^n \\right), \\quad \\forall \\left\\langle \\mathbf{q} \\right\\rangle^n,\n\\end{align}\nwhich shows that the oscillations of the solution in TVD method are reduced.\\\\\nHere, we list out all the possible reconstruction schemes in \\texttt{Gmunu} in Table \\ref{tab:limiters}.\n\\begin{table}[h]\n\t\\centering\n\t\\caption{\\label{tab:limiters}Reconstruction schemes available in \\texttt{Gmunu}.}\n\t\\begin{tabular}{ l | l | l | l | l }\n\t\t\\multicolumn{1}{c|}{ Order of accuracy } & \\multicolumn{1}{c|}{ 2nd } & \\multicolumn{1}{c|}{ 3rd } & \\multicolumn{1}{c|}{ 5th } & \\multicolumn{1}{c}{ 7th }\\\\ \\hline\n\t\t  & Minmod \\cite{ziegler2011semi,kolgan1972application,van1979towards} \n          & PPM \\cite{colella1984piecewise} & MP5 \\cite{suresh1997accurate} & WENO7\\\\\n\t\t  & MC \\cite{van1974towards} & Koren & WENO5 & MP-WENO7 \\\\\n\t\t  & Superbee \\cite{roe1986characteristic} & Cada3 & WENO5-Z & EXENO7 \\\\\n\t\t  & Vanleer \\cite{van1977towards} & WENO3 & WENO5-Z+ &  \\\\\n\t\t  & Albada & WENO3-YC-3 & WENO-NM-5 &  \\\\\n\t\t  & MC-beta &  & WENO-NM-Z &  \\\\\n\t\t  & Cada &  & WENO-NM-Z+ &  \\\\\n\t\t  & Venk &  &  &  \\\\\n\t\\end{tabular}\n\\end{table}\n\n\\subsection{Approximate Riemann solver}\nAs discussed in section \\ref{section3.1.2},\nthe Godunov method requires the solution of local \\textit{Riemann problem }\n$RP\\left(\\left\\langle \\mathbf{q} \\right\\rangle_{L}, \\left\\langle \\mathbf{q} \\right\\rangle_{R} \\right)$\nat the cell interface $x_{j+1/2}$ involving the left state $\\left\\langle \\mathbf{q} \\right\\rangle_{L}$\nand right state $\\left\\langle \\mathbf{q} \\right\\rangle_{R}$.\nAlthough the exact solution of the Riemann problem is available in relativistic hydrodynamics,\nit is computational costy in multidimensional case.\nTherefore, an \\textit{approximate Riemann solver} is used in \\texttt{Gmunu}\nwhich is computationally less expensive and yet very accurate in general.\nApproximation Riemann solver can be divided into two types\n\\begin{enumerate}[label=(\\roman*)]\n    \\item \\textit{Complete Riemann solver} which contains all the charateristic fields of the exact solution, and\n    \\item \\textit{Incomplete Riemann solver} which only contains a subset of them.\n\\end{enumerate}\nIn this section, we discuss some commonly used incomplete Riemann solver in \\texttt{Gmunu}.\nFor a comprehensive introduction, we refer readers to \\cite{toro2013riemann}.\n\n\\paragraph{The HLL solver}\nThis Riemann solver was proposed by Harten, Lax and van Leer \\cite{harten1983upstream}, hence the name \\textit{HLL Riemann solver}.\nThe solution is approximated by\n\\begin{align}\n    \\mathbf{q}(x,t) &= \n    \\begin{cases}\n        \\mathbf{q}_L & \\text{if } x/t < \\lambda_L, \\\\\n        \\mathbf{q}_{HLL} & \\text{if } \\lambda_L \\leq x/t \\leq \\lambda_R, \\\\\n        \\mathbf{q}_R & \\text{if } x/t > \\lambda_R,\n    \\end{cases}\n\\end{align}\nwhere $\\lambda_L \\leq 0$ and $\\lambda_R \\geq 0$ are the minimum and maximum of the characteristic speeds respectively\n\\begin{align}\n    \\lambda_L &\\coloneqq \\min\\left(0, \\lambda_- \\left(\\mathbf{q}_L\\right), \\lambda_- \\left(\\mathbf{q}_R\\right) \\right), \\\\\n    \\lambda_L &\\coloneqq \\max\\left(0, \\lambda_+ \\left(\\mathbf{q}_L\\right), \\lambda_+ \\left(\\mathbf{q}_R\\right) \\right),\n\\end{align}\nand $\\lambda_{\\pm}$ are given by the eigenvalues of the hydrodynamics equations.\nThe single constant state $\\mathbf{q}_{HLL}$ is given by\n\\begin{align}\n    \\mathbf{q}_{HLL} &= \\frac{\\lambda_R \\mathbf{q}_R - \\lambda_L \\mathbf{q}_L + \\mathbf{f}_L - \\mathbf{f}_R}{\\lambda_R-\\lambda_L}.\n\\end{align}\nThus, the numerical fluxes can be calculated as\n\\begin{align}\n    \\mathbf{f} &=\n    \\begin{cases}\n        \\mathbf{f}_L & \\text{if } x/t < \\lambda_L, \\\\\n        \\mathbf{f}_{HLL} & \\text{if } \\lambda_L \\leq x/t \\leq \\lambda_R, \\\\\n        \\mathbf{f}_R & \\text{if } x/t > \\lambda_R,\n    \\end{cases}\n\\end{align}\nwhere the HLL fluxes are\n\\begin{align}\\label{eq:HLL_flux}\n    \\mathbf{f}_{HLL} &=\n    \\frac{\\lambda_R \\mathbf{f}_L - \\lambda_L \\mathbf{f}_R + \\lambda_L \\lambda_R \\left(\\mathbf{q}_R - \\mathbf{q}_L\\right)}{\\lambda_R-\\lambda_L}\n\\end{align}\n\n\\paragraph{The Rusanov solver}\nThe \\textit{Rusanov approximate Riemann solver} \\cite{rusanov1962calculation},\nalso known as the \\textit{total variation diminishing Lax-Friedrichs (TVDLF) flux} \\cite{shu1989efficient},\nis a special case of the HLL Riemann solver where the condition $\\lambda_R = -\\lambda_L = \\lambda$ is imposed.\nAs a result, the Rusanov flux can be reduced from equation (\\ref{eq:HLL_flux}) as\n\\begin{align}\n    \\mathbf{f}_{Rusanov} &= \\frac{1}{2}\\left(\\mathbf{f}_L + \\mathbf{f}_R \\right) - \\frac{1}{2}\\lambda \\left(\\mathbf{q}_R - \\mathbf{q}_L \\right),\n\\end{align}\nwhere one can take the single speed $\\lambda$ to be $\\lambda = \\max\\left(|\\lambda_L|,|\\lambda_R| \\right)$.\n\n\n%********************************** %Second Section  *************************************\n\\section{Time discretization}\n\\subsection{Explicit Runge-Kutta method}\nTo perform the time integration,\none can expand time derivative using Taylor expansion\n\\begin{align}\n    \\partial_t \\mathbf{q} &= \\frac{1}{2 \\Delta t} \\left(\\mathcal{q}^{n+1} - \\mathcal{q}^{n-1} \\right).\n\\end{align}\nHowever, it is not a practical time integration scheme because\n\\begin{enumerate}[label=(\\roman*)]\n    \\item Large amount of data for the previous time steps is need to be stored in higher-order scheme.\n    \\item Stability is not guaranteed.\n\\end{enumerate}\nIn constract, in the Runge-Kutta (RK) methods,\nwe do not need to store large amount of data, \nand it enables stable time integration for higher-order-accurate scheme.\nConsider a system of equations in form\n\\begin{align}\n    \\frac{d \\mathbf{q}}{dt} &= \\mathbf{F} \\left(\\mathbf{q},t \\right),\n\\end{align}\nwhere $\\mathbf{F}$ denotes the right-hand side of the equation.\nThe general $m$-stage explicit Runge-Kutta method of the Shu-Osher form \\cite{shu1988efficient} is \n\\begin{align}\n    \\mathbf{q}^{(0)} &= \\mathbf{q}^n \\\\\n    \\mathbf{q}^{(i)} &= \\sum^{i-1}_{k=0} \\left[ \\alpha_{ik} \\mathbf{q}^{(k)} \n    + \\Delta t \\beta_{ik} \\mathbf{F}\\left( \\mathbf{q}^{(k)}, t^n + \\gamma_k \\Delta t \\right) \\irght],\n    \\quad i=1,2,\\dots,m \\\\\n    \\mathbf{q}^{n+1} &= \\mathbf{q}^{(m)},\n\\end{align}\nwhere the coefficient $\\alpha_{ik}, \\beta_{ik}$ and $\\gamma_k$ are chosen such that the order conditions are satisfied.\n\n\\subsubsection{Strong stability-preserving (explicit) Runge-Kutta methods}\nThe strong stability-preserving Runge-Kutta (SSPRK) methods \\cite{shu1988total,shu1988efficient}\nis special class of RK methods which maintains total variation diminishing property (\\ref{eq:TVD})\nin higher-order time integration scheme.\nDue to its non-oscillatory property,\nthe SSPRK methods are desirable in problems with discontinuities and strong shocks \\cite{hesthaven2007nodal}.\\\\\nAs mentioned in section \\ref{section1.5.3},\nthe hyperbolic system in the FCF scheme becomes unconditionally unstable\nif first-order or second-order explicit RK method is used.\nAs a result, we use fourth-order SSPRK scheme to evolve the FCF hyperbolic sector \nand the hydrodynamics equation in \\texttt{Gmunu}.\n\n\\subsection{Courant-Friedrichs-Lewy conditions}\nOne necessary condition for stability is the \\textit{Courant-Friedrichs-Lewy} (CFL) conditions \\cite{courant1928partiellen}.\nFrom a physical point of view,\nthe CFL condition ensures that the propagation speed of any physical perturbation\nis always smaller than the numerical speed $\\lamda_N$\n\\begin{align}\n    |\\lambda| \\leq \\lambda_N \\coloneqq \\frac{\\Delta x}{\\Delta t}.\n\\end{align}\nTherefore, the time steps for the time integration can be obtained by\n\\begin{align}\n    \\Delta t = c_{CFL} \\min_k \\left(\\frac{\\Delta x}{|\\lambda_k|} \\right),\n\\end{align}\nwhere $c_{CFL}\\leq 1$ is a dimensionless constant\nand $\\lambda_k$ is the charateristic speed of the evolution system.\n\n%********************************** %Third Section  *************************************\n\\section{Atmosphere treatment}\nOne of the challenge in astrophysical simulation is handle the interface between fluid and vacuum\nwhere the density $\\rho$, pressurece $p$ and velocities $v^i$ vanish.\nIn this section, we outline the positivity preserving limiter \\cite{hu2013positivity} used in $\\texttt{Gmunu}$\nfor atmosphere handling.\n\n\\subsection{Positivity preserving limiter}\nWe consider a discretized first-order Euler timestep\n\\begin{align}\n    &\\frac{u^{n+1}_i - u^n_i}{\\Delta t} = \\frac{1}{\\delta V_i} \n    \\left( f_{i-1/2} \\Delta A_{i-1/2} - f_{i+1/2} \\Delta A_{i+1/2} \\right),\\\\\n    &\\Rightarrow u^{n+1}_i = \\frac{1}{2}\\left( u^{+}_i - u^-_i \\right),\n\\end{align}\nwhere\n\\begin{align}\n    u^-_i &\\coloneqq \\left( u^n_i - 2\\frac{\\Delta t}{\\Delta V_i} f_{i+1/2} \\Delta A_{i+1/2} \\right), \\\\\n    u^+_i &\\coloneqq \\left( u^n_i + 2\\frac{\\Delta t}{\\Delta V_i} f_{i-1/2} \\Delta A_{i-1/2} \\right),\n\\end{align}\nTo ensure the positivity of $u^+_i$ and $u^-_i$, we modify the flux as \\cite{hu2013positivity}\n\\begin{align}\n    f_{i+1/2} &= \\theta f_{i+1/2}^{HO} + (1-\\theta) f_{i+1/2}^{LO},\n\\end{align}\nwhere $f_{i+1/2}^{HO}$ is the original high-order flux scheme\nand $f_{i+1/2}^{LO}$ is the first order Lax-Friedrichs flux.\nThe parameter $\\theta \\in \\left[0,1\\right]$ is the maximum value such that\n$u^+_i$ and $u^-_i$ are positive.\nSince the Lax-Friedrichs scheme is positivity preserving,\nwe can always choose $\\theta$ to preserve the positvity.\nNote that once the positivity in one first-order Euler timestep is preserved,\nthe positivity is guaranteed for any strong-stability preserving Runge-Kutta (SSPRK) time integrator.\\\\\nIn \\texttt{Gmunu}, we implemented the positivity preserving limiter in conserved density $D$\nand energy density $\\tau$ to preserve the positivity of density $\\rho$ and pressure $p$.\nFor the multidimensional case, we apply the limiter with component-by-component approach.\n\n%********************************** %Fourth Section  *************************************\n\\section{Multigrid Method for elliptic equations} %Section - 3.1 \n\\label{section3.1}\n\n\\subsection{Overview} %Section - 3.1.1\n\\label{section3.1.1}\nThe elliptic equations can be solved using \\textit{iterative methods} such as\nJocabi method, Gauss-Seidel (GS) method and successive overrelaxation (SOR) \\cite{young2014iterative}.\nThese methods are very effective in eliminating high-frequency or\noscillatory components of the error,\nbut less effective in reducing low-frequency or smooth components of the error\nsince the changes of error are only made with spatially locally correction \\cite{briggs2000multigrid}.\nThis problem will become even more severe for higher resolution \nbecause the convergence rate behaves like $1-\\mathcal{O}(h^2)$.\nSince the smooth modes in a fine grid become oscillatory in a coarser grid,\none can move to a coarser grid to smooth out the low-frequency mode error and return back to the fine grids.\nThis is the key idea of the multigrid method.\\\\\nIn the multigrid method, the key ingredients are\n\\begin{enumerate}[label=(\\roman*)]\n    \\item \\textbf{Multigrid cycle scheme} tells the structure of the multigrid solver (see Figure \\ref{fig:MG_cycles} for example).\n    \\item \\textbf{Restriction} maps the values from the fine grid to the coarse grid.\n    \\item \\textbf{Prolongation} maps the values from the coarse grid to the fine grid.\n    \\item \\textbf{Smoother} to smooth out the error at different levels.\n    \\item \\textbf{Direct solver} to solve the equation at the coarsest level.\n\\end{enumerate}\n\\begin{figure}[h!]\n\t\\centering\n\t\\begin{subfigure}{0.3\\columnwidth}\n\t\t\\centering\n        \\includegraphics[width=\\columnwidth]{MG_Vcycle.jpeg}\n\t\t\\caption{V-cycle}\n\t\\end{subfigure}\n\t%\\hfill\n\t\\begin{subfigure}{0.6\\columnwidth}\n\t\t\\centering\n        \\includegraphics[width=\\columnwidth]{MG_Wcycle.jpeg}\n        \\caption{W-cycle}\n\t\\end{subfigure}\n\n\t\\begin{subfigure}{0.45\\columnwidth}\n\t\t\\centering\n        \\includegraphics[width=\\columnwidth]{MG_Fcycle.jpeg}\n        \\caption{F-cycle}\n\t\\end{subfigure}\n\t\\begin{subfigure}{0.45\\columnwidth}\n\t\t\\centering\n        \\includegraphics[width=\\columnwidth]{MG_FMG.jpeg}\n        \\caption{Full multigrid (FMG) cycle}\n\t\\end{subfigure}\n\n\t\\begin{subfigure}{0.2\\columnwidth}\n\t\t\\centering\n        \\includegraphics[width=\\columnwidth]{MG_note.jpeg}\n\t\\end{subfigure}\n\n\t\\caption[Four different types of four-level cycles in multigrid methods.]{\n\t\t``S'' denotes smoothing. ``Sol'' denotes direct solver.\n\t\tDescending line $\\setminus$ denotes restriction and ascending line / denotes prolongation.\n\t}\n\t\\label{fig:MG_cycles}\n\\end{figure}\n\nFor more comprehensive discussion of multigrid method,\nwe refer the readers to \\cite{briggs2000multigrid,trottenberg2000multigrid,young2014iterative,brandt2011multigrid}.\n\n\\subsection{Cell-centred discretization and operator} %Section - 3.1.2\n\\label{section3.1.2}\nGiven a non-linear elliptic equation \n\\begin{align}\n    \\mathcal{L}\\left(u\\right) = f,\n\\end{align}\nwith elliptic operator $\\mathcal{L}$, solution $u$ and source term $f$,\nit can be discretized as\n\\begin{align}\n    \\mathcal{L}_h \\left(u_h \\right) = f_h,\n\\end{align}\nwhere $\\mathcal{L}_h$ is the discretized operator with resolution $h$,\n$u_h$ and $f_h$ are solution and source term defined at the cell-centres.\n\n\\subsubsection{Laplacian operator}\nThe Laplacian operator is one of the elliptic operators that commonly used in \\texttt{Gmunu},\nincluding the constraint \\cref{eq:XCFC_psi,eq:XCFC_alp} in XCFC scheme \nand the algebraic constraint \\cref{eq:FCF_g_trace} in the FCF scheme.\nIt is discretized with a standard 5/7-point (in 2D/3D) second-order accurate discretization.\nThe details of the discretization in different geometry is shown in Appendix.\n\n\\subsubsection{Mixed derivatives}\nIn the elliptic sector of the FCF scheme (\\cref{eq:FCF_X,eq:FCF_psi,eq:FCF_alp,eq:FCF_beta})\nand the vector elliptic equations in the XCFC scheme (\\cref{eq:XCFC_X,eq:XCFC_beta}),\nthe elliptic operators contain mixed derivative terms $\\frac{\\partial^2 u}{\\partial x \\partial y}$.\nWe use second-order accuracy discretization as follows\n\\begin{align}\n    \\left(\\frac{\\partial^2 u}{\\partial x \\partial y} \\right)_{i,j,k} &=\n    \\frac{u_{i+1,j+1,k} - u_{i-1,j+1,k} - u_{i+1,j-1,k} + u_{i-1,j-1,k}}{4 \\Delta x \\Delta y}\n\\end{align}\n\n\\subsubsection{Convection-diffusion equation}\nIn the momentum constraint (\\cref{eq:FCF_X,eq:FCF_X_2}) of the FCF scheme,\nthe elliptic operator contains a convective term $\\Delta^i{}_{kl}\\left( L X \\right)^{kl}$\nwhich has a similar form as the following\n\\begin{align}\\label{eq:convection_diff}\n    \\frac{\\partial^2 u}{\\partial x^2} + a \\frac{\\partial u}{\\partial x} = 0.\n\\end{align}\nWhile the Laplacian operator in equation (\\ref{eq:convection_diff}) is discretized using standard 5/7-point approximation,\nthe convection term needs to be discretized using upwind method \\cite{trottenberg2000multigrid}.\nIn \\texttt{Gmunu}, we adopts second-order accuracy lopsided spatial finite differencing as\n\\begin{align}\n    \\left(\\frac{\\partial u}{\\partial x} \\right)_i &= \\frac{1}{2 \\Delta x}\n    \\begin{cases}\n        3 u_i - 4 u_{i-1} + u_{i-2} &\\quad a \\leq 0,\\\\\n        -3 u_i + 4 u_{i+1} - u_{i+2} &\\quad a \\geq 0.\n    \\end{cases}\n\\end{align}\n\n\\subsection{Smoothers and solvers} %Section - 3.1.3\n\\label{section3.1.3}\nAnother essential element in multigrid method is the smoothers and direct solvers.\nIn \\texttt{Gmunu}, we implemented the point-wise \\textit{Newton Gauss-Seidel} smoothers \\cite{press1996numerical}\n\\begin{align}\n    u^{new}_{i,j,k} = u^{old}_{i,j,k} - \\Bigg(\\mathcal{L}\\left(u^{old}_{i,j,k}\\right) - f_{i,j,k} \\Bigg)\n    \\left/ \\left( \\left. \\frac{\\partial \\mathcal{L}}{\\partial u_{i,j,k}}\\right|_{u=u^{old}_{i,j,k}}\\right)\\right. ,\n\\end{align}\nwhere the components of the new approximation are used as soon as they are computed.\nNote that if $mathcal{L}$ is linear in $u$,\nthe Newton Gauss-Seidel method reduces to the standard Gauss-Seidel method.\\\\\nThere are two order of sweeping through the components $u_{i,j,k}$ implemented in \\texttt{Gmunu}.\n\\begin{enumerate}\n    \\item \\textit{Standard Gauss-Seidel} which follows the linear order of the indexes $i,j,k,$ stored in computer's memory.\n    \\item \\textit{Red-black Gauss-Seidel} which sweeps through all the even indexes first (i.e. $i+j+k$ is even) then the odd indexes.\n\\end{enumerate}\n\nAlthough the convergence rate of the smoothers is lowered in 2D/3D spherical and 3D cylindrical coordinate due to the anisotropy \\cite{trottenberg2000multigrid},\ncurrently we still implemented the smoothers for all coordinate.\nFor simplicity,\nwe adopt the Newton Gauss-Seidel method for the direct solver.\n\n\\subsection{Transfer operators: restriction and prolongation} %Section - 3.1.4\n\\label{section3.1.4}\nThe transfer operators connect data at different level.\nThe \\textit{restriction} operators map the values from the fine grid to the coarse grid,\nwhile the \\textit{prolongation} operators map the values from the coarse grid to the fine grid.\nFor prolongation,\nwe use linear interpolation based on the nearest neighbors \\cite{teunissen2019geometric,zhang2016boxlib,teunissen2018afivo},\nwhich can be described by the following:\n\\begin{align}\n    u_{x+h/2,y+h/2} &= \\frac{1}{4} \\left(2 u_{x,y} + u_{x+h, y} + u_{x,y+h} \\right) + \\mathcal{O}\\left(h^2 \\right),\\\\\n    u_{x-h/2,y+h/2} &= \\frac{1}{4} \\left(2 u_{x,y} + u_{x-h, y} + u_{x,y+h} \\right) + \\mathcal{O}\\left(h^2 \\right),\n\\end{align}\nor in stencil notation\n\\begin{align*}\n\t\\frac{1}{4} \\left]\\begin{array}{ccccc}\n\t\t\\cdot  & 1 &   & 1 & \\cdot\t\\\\\n\t\t1 & 2 &   & 2 & 1\t\\\\\n\t\t  &   & * &   &  \t\\\\\n\t\t1 & 2 &   & 2 & 1\t\\\\\n\t\t\\cdot & 1 &   & 1 & \\cdot\n\t\\end{array}\\right[^h_{2h},\n\\end{align*}\nwhere the ``$*$'' denotes the location of the coarse grid\nand the notation shows the weighting of the value which are the neighbours of the coarse grid node ``$*$''.\nFor restriction, the value of four (2D) or eight (3D) fine grid values is averaged to obtain a coarse grid value.\n\n\\subsection{The Full Approximation Scheme} %Section - 3.1.5\n\\label{section3.1.5}\nTo solve the non-linear elliptic equations,\nwe adopt the Full Approximation Scheme (FAS) \\cite{brandt1977multi,brabazon2014nonlinear,press1996numerical}.\nHere, we briefly outline the FAS algorithm.\nwe define the residual $r$\n\\begin{align}\n    r \\coloneqq f - \\mathcal{L} \\left(v \\right),\n\\end{align}\nwhere $f$ is the right-hand side of the equation, \n$\\mathcal{L}$ is the elliptic operator\nand $v$ is an approximation solution.\nFor the discretized equation with resolution $h$, we have\n\\begin{align}\n    r_h = f_h - \\mathcal{L}_h \\left( v_h \\right).\n\\end{align}\nThe current approximation $v_h$ is then restricted to coarse grid\n$v_{2h} = \\mathcal{R} \\left( v_h \\right)$ where $\\mathcal{R}$ is the restriction operator.\nA copy of $v^{old}_{2h} = v_{2h}$ is stored for later usage. \nThe coarse-grid right-hand side is then update as\n\\begin{align}\n    f_{2h} = \\mathcal{R} \\left(r_h \\right) + \\mathcal{L}_{2h} \\left(v_{2h} \\right).\n\\end{align}\nSmoothing steps are then applied to the coarse grid.\nIn the prolongation steps,\nthe solution is updated with a correction from the coarse grid as\n\\begin{align}\n    v_{h} = v_{h} + \\mathcal{P} \\left(v_{2h} - v^{old}_{2h} \\right),\n\\end{align}\nwhere $mathcal{P}$ is the prolongation operator.\nIn practise, this procedure will be repeated until the solution converges\n(i.e. the $L_\\infty$ norm of the residual is below chosen threshold value).\\\\\nSince the current version of \\texttt{Gmunu} is built upon the framework of \\texttt{AMRVAC 2.0} \\cite{xia2018mpi,keppens2021mpi},\nit is natural use the open-source geometric multigrid library \\texttt{octree-mg} \\cite{teunissen2019geometric} \nwhich is MPI-parallelized, support quadtree/octree AMR grids,\nand provide periodic, Dirichlet, and Neumann boundary conditions.\nNonetheless, the library only supports 2D/3D Cartesian coordinate and 2D cylindrical coordinate.\nWe extended it to support multidimensional spherical and cylindrical coordinates as well as the Robin boundary condition.\nIn addition, only a single layer of ghost cell without diagonal cell is used in \\texttt{octree-mg}.\nIn order to calculate the mixed derivatives and solve the convection-diffusion problems,\nwe extend the library to support multiple layers of ghost cells with diagonal cells,\nwhich also allow us to explore higher-order scheme in the future.\n\n", "meta": {"hexsha": "bd97217e3d15dbd136059a6bc05436d6add9304d", "size": 33356, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter3/chapter3.tex", "max_stars_repo_name": "alanlam1002/MPhil_thesis", "max_stars_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter3/chapter3.tex", "max_issues_repo_name": "alanlam1002/MPhil_thesis", "max_issues_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter3/chapter3.tex", "max_forks_repo_name": "alanlam1002/MPhil_thesis", "max_forks_repo_head_hexsha": "da24508526d0553840faa924bc1fbe61a3378429", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-04T05:39:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-04T05:39:22.000Z", "avg_line_length": 54.5032679739, "max_line_length": 166, "alphanum_fraction": 0.7017328217, "num_tokens": 10834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4060425159574356}}
{"text": "\\chapter{Conclusion}\n\nWe have shown that the Follow-the-Leader model converges to the unique weak entropy solution of the Lighthill-Whitham-Richards model for traffic flow, with space dependence. First, we proved that the scheme was uniformly bounded in total variation and that the maximal distance between two vehicles converge to zero. These were the key ingredients to prove compactness of the sequence of approximations, using Kolmagorov-Riesz and the Arzela-Ascoli theorem. Using the properties of the scheme, we showed that any limit of a convergent subsequence is a weak solution, and in fact a kružkov entropy solution. The uniqueness of the entropy solution ensures that the entire sequence converges. \n", "meta": {"hexsha": "6ffd06c16d808c23ebfdd6f24ec1f4ed8794ca26", "size": 713, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/4-conclusion.tex", "max_stars_repo_name": "Halvaros/thesis-NTNU", "max_stars_repo_head_hexsha": "e9fb44f6fb1c7da9da1a29da0bbd0ca1ef2f5693", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/4-conclusion.tex", "max_issues_repo_name": "Halvaros/thesis-NTNU", "max_issues_repo_head_hexsha": "e9fb44f6fb1c7da9da1a29da0bbd0ca1ef2f5693", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/4-conclusion.tex", "max_forks_repo_name": "Halvaros/thesis-NTNU", "max_forks_repo_head_hexsha": "e9fb44f6fb1c7da9da1a29da0bbd0ca1ef2f5693", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 178.25, "max_line_length": 690, "alphanum_fraction": 0.8232819074, "num_tokens": 151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.40604251595743557}}
{"text": "\\subsection{Entropy Solutions}\n\\begin{enumerate}\n    \\item For any process, we define the change in entropy as the sum of $\\frac{\\delta Q}{T}$ for many infinitesimal steps. In an adiabatic process, heat never flows, so $\\delta Q = 0$ for all of these steps. Thus, in an adiabatic process the entropy of a system remains constant.\n    \\item There are four triplets of numbers that could sum to $7$, $(5,1,1)$, $(4,2,1)$, $(3,3,1)$, and $(3,2,2)$. Each of these has $3!$ orders they could be rolled in. Hence there are $24$ microstates, for a total entropy of $k_{b}\\ln{24}$.\n    \\item In this case, all possible orders of those four triples are considered the same microstate. So we instead have four possible microstates, for a total entropy of $k_{b}\\ln{4}$.\n    \\item After one cycle, the gas medium of a heat engine is in its initial state. Since entropy is a function of state, the gas must then have the same total entropy as it did at the start of a cycle. So after one cycle, the gas's entropy will not change.\n    \\item The number of possible ways that the particles could be distributed after removing the partition is much higher than before the partition was removed (i.e. the disorder of the system increases quite a bit). So, the entropy of the system has increased. Therefore, to spontaneously return to their initial state the gases would have to violate the second law of thermodynamics. (One thing to note here is that it's technically possible that the system will eventually momentarily reach its original configuration, just extremely unlikely).\n    \\item Using the Sackur-Tetrode equation we have that \n    \\begin{equation*}\n        \\Delta S = nc_{v}\\ln{\\frac{T_1}{T_0}} + nR\\ln{\\frac{V_1}{V_0}}.\n    \\end{equation*}\n    $T_0 = 300\\textrm{K}$, $T_1 = 400\\textrm{K}$, and $n = 1\\textrm{mol}$ are given. Furthermore, since it expands to double its original size, we know that $V_1 = 2V_0$. Finally, we know that the gas has 3 degrees of freedom, since its monoatomic, and therefore $c_v = \\frac{3}{2}R$. So plugging those in we get\n    \\begin{gather*}\n        \\Delta S = (1\\textrm{mol})(\\frac{3}{2})(8.314\\frac{\\textrm{J}}{\\textrm{mol}\\cdot \\textrm{K}})\\ln{\\frac{400\\textrm{K}}{300\\textrm{K}}} + (1\\textrm{mol})(8.314\\frac{\\textrm{J}}{\\textrm{mol}\\cdot \\textrm{K}})\\ln{\\frac{2V_0}{V_0}} \\\\\n        \\Delta S \\approx 9.35\\frac{\\textrm{J}}{\\textrm{K}}\n    \\end{gather*}\n    \\item\n    \\begin{enumerate}\n        \\item From the ideal gas law, if both compartments have the same amount and volume of gas, but the right side has a higher temperature, then we know that the right side will have a higher pressure than the left. Therefore, the gas on the right side will expand and the gas on the left side of the box will be compressed (as the gas molecules on the right are pushing with more force on the central piston), in an adiabatic process (as no heat can flow). The process will terminate once the pressure on both sides of the box is equal.\n        \\item Since this process resulted in no energy gain or loss (as the box is isolated from its environment), the internal energy change of the system is zero. Since this process raises the temperature on the left to be closer to that on the right, you would think that this process raises the entropy of the system. However, since both sides of the box underwent an adiabatic process, neither had a change in entropy. Entropy is an extensive quantity, so the entropy of the box must have remained constant as well.\n        \\item At the end, the pressure of the two sides would be equal, as the net force on the central piston would be zero. The volume of the left side would be less than the right. Finally, since both sides of the box have the same number of moles of gas, we can use ideal gas law to say that after the process is over:\n    \\[\n        \\frac{P_lV_l}{T_l} = \\frac{P_rV_r}{T_r}\n    \\]\n    which since the final pressures are equal simplifies to\n    \\[\n        \\frac{V_l}{T_l} = \\frac{V_r}{T_r}\n    \\]\n    We know that the final volume of the left side is less than the final volume on the right side. Therefore, the final temperature on the right must be greater than that on the left. The system is not in thermal equilibrium, which does make sense as the two containers were not in thermal contact with one another.\n    \\end{enumerate}   \n\\end{enumerate}", "meta": {"hexsha": "dbe80f41fd20e8f927d3cd727886657d2d3433b7", "size": 4337, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Solutions/entropy-solutions.tex", "max_stars_repo_name": "RioWeil/SCIE001-thermo-notes", "max_stars_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Solutions/entropy-solutions.tex", "max_issues_repo_name": "RioWeil/SCIE001-thermo-notes", "max_issues_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Solutions/entropy-solutions.tex", "max_forks_repo_name": "RioWeil/SCIE001-thermo-notes", "max_forks_repo_head_hexsha": "8578248f8f79f5704319dc6cd4ec679ce12b949c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-30T05:36:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-30T05:36:50.000Z", "avg_line_length": 139.9032258065, "max_line_length": 547, "alphanum_fraction": 0.7270002306, "num_tokens": 1170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891451980404, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.4059245992076132}}
{"text": "\\section{Introduction}\nFor the calculability course, we had to realize a project. This project is a RAM language interpreter. The RAM language is a pseudo code discussed in class with 4 instructions. This project is divided in 3 parts: the parser, the interpreter and the graphics.\n\n\\section{About RAM program}\n\\label{sec:RAM_intro}\nA \\textit{RAM} program is a program made by :\n\\begin{itemize}\n    \\item a potentially infinity memory with three main registers\n    \\begin{itemize}\n        \\item the \\textit{memory counter ($R_C$)} which allows to know at each moment what is the current instruction to be executed. If $R_C$ is $0$ or a integer bigger then the number of instructions of the code, the program execution will stop \n        \\item \\textit{$R_0$} the first register of the memory representing the input of the program\n        \\item \\textit{$R_1$} the second register which can be seen as the case of the memory containing the output of our program\n    \\end{itemize}\n    \\item 4 instructions :\n    \\begin{itemize}\n        \\item $R_k = R_k + 1$ which increases the value stock in the register $k$ by one\n        \\item $R_k = R_k \\dotminus{} 1$, same as previous instruction, but the value is decreased by one (NB : if the value in $R_k$ is equal to 0, we have that $0 \\dotminus{} 1 = 0$ since RAM machines work in $\\mathbb{N}$ number set\n        \\item $IF \\; R_k \\neq 0 \\; THEN \\; GOTOB \\; n$ means that if the register $k$ does not equal $0$ then $R_C = R_C \\dotminus{} n$ (here, as before the subtraction is done as follow $A \\dotminus{} B = max(0, A - B)$\n        \\item $IF \\; R_k \\neq 0 \\; THEN \\; GOTOF \\; n$ which makes the following operation : $R_C = R_C + n$\n    \\end{itemize}\n\\end{itemize}\n\nWith a RAM program, as demonstrated in course, it is possible to code all the programs we usually code with any other programming language such as \\textit{Python, C, Java, etc.} \n\nAnother important aspect of RAM program we should consider is that, thanks to its infinite registers and the fact that efficiency time of programs is not taken, this program model can be reused and adapted to every new programming language.\n\nFinally working only in $\\mathbb{N}$ does not restrict RAM programs, since in fact $\\mathbb{Z}$, $\\mathbb{Q}$ and  $\\mathbb{R}$ can be seen as an extensions of $\\mathbb{N}$.\n\n\\newpage\nWe can also introduce some predefined and useful macros, such as, \\textit{rp} and \\textit{lp} (resp. for \\textit{right\\_part} and \\textit{left\\_part}), allowing to treat the value of a register as a \\textit{Cantor's couple} (see \\ref{sec:cant_pair_func}), this let you pass a variable number of parameters.\\\\\nFor example, if you have a program that calculate the sum of $x$ and $y$ then you will put $n$ that is $cantor(x,y)$ in $R_0$.\n\\\\Other two macros are \\textit{push} and \\textit{pop} which respectively push and pop the value from a register $k$ to a very big register that normally should not be used by the program (we have chosen the $2^{64}$ register).\n\n\n\\section{Design choices}\n\n\\subsection{Choice of tools}\n\n\\begin{itemize}\n\\item Technologies : \\textbf{Python3.9.9}\\\\\nTo realize this project we used the following libraries:\n    \\begin{itemize}\n        \\item ply==3.11 (For the parser)\n        \\item tkhtmlview==0.1.0 (For the help)\n    \\end{itemize}\n\\end{itemize}\n\n\\subsection{Installation}\n\nYou can use the file \\textbf{install.sh}\n\n\\begin{verbatim}\n$ chmod u+x install.sh\n$ ./install.sh\n\\end{verbatim}\nOr\n\n\\begin{verbatim}\n$ python3 -m pip install -r requirements.txt\n\\end{verbatim}", "meta": {"hexsha": "e56f1bcb72067b825078a60f090978ac01e1b331", "size": 3514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "rep/Calculability/sections/Introduction.tex", "max_stars_repo_name": "margauxschmied/RAM_language_interpreter", "max_stars_repo_head_hexsha": "608d42f76d3a2bb28906cb7664b9f852f9aee805", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-01-26T21:19:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-02T23:55:54.000Z", "max_issues_repo_path": "rep/Calculability/sections/Introduction.tex", "max_issues_repo_name": "margauxschmied/RAM_language_interpreter", "max_issues_repo_head_hexsha": "608d42f76d3a2bb28906cb7664b9f852f9aee805", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "rep/Calculability/sections/Introduction.tex", "max_forks_repo_name": "margauxschmied/RAM_language_interpreter", "max_forks_repo_head_hexsha": "608d42f76d3a2bb28906cb7664b9f852f9aee805", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.5666666667, "max_line_length": 308, "alphanum_fraction": 0.718554354, "num_tokens": 973, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.40592458550216565}}
{"text": "\\section{Computing Limits: Limit Laws}\\label{sec:ComputingLimitsAlg}\r\n\\subsection*{Properties of limits}\r\n\r\n\r\nIn Section \\ref{sec:LimitsWorkingDefn} we explored the concept of the limit without a strict definition, meaning we could only make approximations. In the previous section we gave the definition of the limit and demonstrated how to use it to verify our approximations were correct. Thus far, our method of finding a limit is 1) make a really good approximation either graphically or numerically, and 2) verify our approximation is correct using a $\\epsilon$-$\\delta$ proof.\r\n\r\nRecognizing that $\\epsilon$-$\\delta$ proofs are cumbersome, this section gives a series of theorems which allow us to find limits much more quickly and intuitively. \\\\\r\n%\\vskip \\baselineskip\r\n\r\nSuppose that $\\lim_{x\\to 2} f(x)=2$ and $\\lim_{x\\to 2} g(x) = 3$. What is $\\lim_{x\\to 2}(f(x)+g(x))$? Intuition tells us that the limit should be $ 5 $, as we expect limits to behave in a nice way. The following theorem states that already established limits do behave nicely.\r\n\r\n%\\enlargethispage{4\\baselineskip}\r\n\r\n\\begin{theorem}{Basic Limit Properties}{limit_algebra}\r\n{\r\nLet $a$, $c$, $L$ and $K$ be real numbers, let $n$ be a positive integer, and let $f$ and $g$ be functions with the following limits: \\index{limit!properties}\r\n$$\\lim_{x\\to a}f(x) = L \\text{\\ and\\ } \\lim_{x\\to a} g(x) = K.$$\r\nThe following limits hold.\r\n\\begin{enumerate}\r\n\\item \\parbox{160pt}{Constants:} $\\displaystyle \\lim_{x\\to a} c = c$\r\n\\item\t\\parbox{160pt}{Identity }\t\t\t\t\t\t$\\displaystyle \\lim_{x\\to a} x = a$\r\n\\item\t\\parbox{160pt}{Sum/Difference Rules:} $\\displaystyle \\lim_{x\\to a}(f(x)\\pm g(x)) = L\\pm K$\r\n\\item\t\\parbox{160pt}{Scalar Multiple Rule:}\t$\\displaystyle \\lim_{x\\to a} c\\cdot f(x) = cL$\r\n\\item\t\\parbox{160pt}{Limit Product Rule:}\t$\\displaystyle \\lim_{x\\to a} f(x)\\cdot g(x) = LK$\r\n\\item\t\\parbox{160pt}{Limit Quotient Rule:} $\\displaystyle \\lim_{x\\to a} f(x)/g(x) = L/K$, ($K\\neq 0)$\r\n\\item\t\\parbox{160pt}{Limit Power Rule:} \t$\\displaystyle \\lim_{x\\to a} f(x)^n = L^n$\r\n\\item\t\\parbox{160pt}{Continuity of Roots:}\t\t\\parbox[t]{185pt}{$\\displaystyle \\lim_{x\\to a} \\sqrt[n]{f(x)} = \\sqrt[n]{L}$}% \\qquad \\small (if $n$ is even then $L$ must be greater than 0; when $n$ is odd, it is true for all $L$.)}\r\n\\item\t\\parbox{80pt}{Compositions:} \\parbox[t]{240pt}{Adjust our previously given limit assumptions to: $$\\lim_{x\\to a}g(x) = L \\text{\\ and\\ } \\lim_{x\\to L} f(x) = f(L).$$ Then $\\ds \\lim_{x\\to c}f(g(x)) = f(L)$.}\r\n\\end{enumerate}\r\n}\r\n\\end{theorem}\r\n\r\n\r\n\r\n\r\nWe make a note about Property \\#8: when $n$ is even, $L$ must be greater than 0. If $n$ is odd, then the statement is true for all $L$.\r\n\r\nRegarding Property \\#9, note the special form of the condition on $f$: it is not enough to\r\nknow that $\\ds\\lim_{x\\to L}f(x) = M$, though it is a bit tricky to see\r\nwhy. We have included an example in the exercise section to illustrate this tricky\r\npoint for those who are interested. As we shall eventually see, many of the most familiar functions do have this property, so this result can therefore be applied. \r\n\r\nRoughly speaking, these rules say that to compute the limit of an algebraic expression, it is enough to compute the limits of the ``innermost bits'' and then combine these limits. This often means that it is possible to simply plug in a value for the variable, since\r\n$\\ds \\lim_{x\\to a} x =a$.\r\n\r\n\\begin{example}{Limit Properties}{LimitProperties}\r\nCompute $\\ds\\lim_{x\\to 1}{x^2-3x+5\\over x-2}$.\r\n\\end{example}\r\n\r\n\\begin{solution} \r\n If we apply the theorem in all its gory detail, we get\r\n\\begin{eqnarray*}\r\n\\lim_{x\\to 1}{x^2-3x+5\\over x-2}&=&\r\n{\\ds\\lim_{x\\to 1}(x^2-3x+5)\\over \\ds\\lim_{x\\to1}(x-2)}\\cr\r\n\\\\\r\n&=&{(\\ds\\lim_{x\\to 1}x^2)-(\\ds\\lim_{x\\to1}3x)+(\\ds\\lim_{x\\to1}5)\\over \r\n  (\\ds\\lim_{x\\to1}x)-(\\ds\\lim_{x\\to1}2)}\\cr\r\n\\\\\r\n&=&{(\\ds\\lim_{x\\to 1}x)^2-3(\\ds\\lim_{x\\to1}x)+5\\over (\\ds\\lim_{x\\to1}x)-2}\\cr\r\n\\\\\r\n&=&{1^2-3\\cdot1+5\\over 1-2}\\cr\r\n\\\\\r\n&=&{1-3+5\\over -1} = -3\r\n\\end{eqnarray*}\r\n\\end{solution}\r\n \r\n\r\n\r\n\\begin{example}{Using basic limit properties}{ex_basic_limit_1}{\r\nLet $$\\lim_{x\\to 2} f(x)=2,\\quad\\lim_{x\\to 2} g(x) = 3\\quad \\text{\\ and \\ }\\quad p(x) = 3x^2-5x+7.$$ Find the following limits:\r\n\r\n\\noindent\\begin{minipage}[t]{.5\\textwidth}\r\n\\begin{enumerate}\r\n\\item\t\t$\\ds \\lim_{x\\to 2} \\big(f(x) + g(x)\\big)$\r\n\\item\t\t$\\ds \\lim_{x\\to 2} \\big(5f(x) + g(x)^2\\big)$\r\n\\end{enumerate}\r\n\\end{minipage}\r\n\\begin{minipage}[t]{.5\\textwidth}\r\n\\begin{enumerate}\\addtocounter{enumi}{2}\r\n\\item\t\t$\\ds \\lim_{x\\to 2} p(x)$\r\n\\end{enumerate}\r\n\\end{minipage}}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{\\begin{enumerate}\r\n\\item\t\tUsing the Sum/Difference rule, we know that $\\ds \\lim_{x\\to 2} \\big(f(x) + g(x)\\big) = 2+3 =5$.\r\n\\item\t\tUsing the Scalar Multiple and Sum/Difference rules, we find that $\\ds \\lim_{x\\to 2} \\big(5f(x) + g(x)^2\\big) = 5\\cdot 2 + 3^2 = 19.$\r\n\\item\t\tHere we combine the Power, Scalar Multiple, Sum/Difference and Constant Rules. We show quite a few steps, but in general these can be omitted:\r\n\t\t\t\t\\begin{align*}\r\n\t\t\t\t\\lim_{x\\to 2} p(x) &= \\lim_{x\\to 2} (3x^2-5x+7) \\\\\r\n\t\t\t\t&= \\lim_{x\\to 2} 3x^2-\\lim_{x\\to 2} 5x+\\lim_{x\\to 2}7 \\\\\r\n\t\t\t\t &= 3\\cdot 2^2 - 5\\cdot 2+7 \\\\\r\n\t\t\t\t &= 9\r\n\t\t\t\t\\end{align*}\r\n\\end{enumerate}\r\n}\r\n\\end{solution}\r\n\r\n\r\n\r\n%\r\nPart 3 of the previous example demonstrates how the limit of a quadratic polynomial can be determined using the properties of Theorem \\ref{thm:limit_algebra}. Not only that, recognize that $$\\lim_{x\\to 2} p(x) = 9 = p(2);$$ i.e., the limit at $ 2 $ was found just by plugging $ 2 $ into the function. This holds true for all polynomials, and also for rational functions (which are quotients of polynomials), as stated in the following theorem.\r\n\r\n\r\n\\begin{theorem}{Limits of Polynomial and Rational Functions}{poly_rat}\r\n{Let $p(x)$ and $q(x)$ be polynomials and $c$ a real number. Then:\r\n\\begin{enumerate}\r\n\\item\t$\\ds \\lim_{x\\to c} p(x) = p(c)$\r\n\\item\t$\\ds \\lim_{x\\to c} \\frac{p(x)}{q(x)} = \\frac{p(c)}{q(c)}$, where $q(c) \\neq 0$.\r\n\\end{enumerate}\r\n}\r\n\\end{theorem}\r\n\r\n\\begin{example}{Finding a limit of a rational function}{ex_limit_rat}\r\n{\r\nUsing Theorem \\ref{thm:poly_rat}, find $$\\lim_{x\\to -1} \\frac{3x^2-5x+1}{x^4-x^2+3}.$$}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{Using Theorem \\ref{thm:poly_rat}, we can quickly state that \r\n\t\\begin{align*} \\lim_{x\\to -1}\\frac{3x^2-5x+1}{x^4-x^2+3} &= \\frac{3(-1)^2-5(-1)+1}{(-1)^4-(-1)^2+3} \\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t&= \\frac{9}{3} =3.\r\n\t\\end{align*}\r\n}\r\n\\end{solution}\r\n\r\n\r\n\r\n\r\nIt was likely frustrating in Example \\ref{exa:ex_compute_lim2} to do a lot of work to prove that $$\\lim_{x\\to 2} x^2 = 4$$ as it seemed fairly obvious. The previous theorems state that many functions behave in such an ``obvious'' fashion, as demonstrated by the rational function in Example \\ref{exa:ex_limit_rat}. \r\n\r\nPolynomial and rational functions are not the only functions to behave in such a predictable way. The following theorem gives a list of functions whose behavior is particularly ``nice'' in terms of limits. In the next section, we will give a formal name to these functions that behave ``nicely.''\r\n\r\n\r\n\\begin{theorem}{Special Limits}{lim_continuous}{%\r\nLet $c$ be a real number in the domain of the given function and let $n$ be a positive integer. The following limits hold: \r\n\r\n\\noindent\\begin{minipage}[t]{.33\\textwidth}\r\n\\begin{enumerate}\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\sin x = \\sin c$\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\cos x = \\cos c$\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\tan x = \\tan c$\r\n\\end{enumerate}\r\n\\end{minipage}\r\n\\begin{minipage}[t]{.33\\textwidth}\r\n\\begin{enumerate}\\addtocounter{enumi}{3}\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\csc x = \\csc c$\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\sec x = \\sec c$\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\cot x = \\cot c$\r\n\\end{enumerate}\r\n\\end{minipage}\r\n\\begin{minipage}[t]{.33\\textwidth}\r\n\\begin{enumerate}\\addtocounter{enumi}{6}\r\n\\item\t\t$\\ds \\lim_{x\\to c} a^x = a^c$ ($a>0$)\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\ln x = \\ln c$\r\n\\item\t\t$\\ds \\lim_{x\\to c} \\sqrt[n]{x} = \\sqrt[n]{c}$\\end{enumerate}\r\n\\end{minipage}\r\n}\r\n\\end{theorem}\r\n\r\n\r\n\r\n\\begin{example}{Evaluating limits analytically}{ex_limit_1}{\r\nEvaluate the following limits. \r\n\r\n\\noindent\\begin{minipage}[t]{.5\\textwidth}\r\n\\begin{enumerate}\r\n\\item\t\t$\\ds \\lim_{x\\to \\pi} \\cos x$\r\n\\item\t\t$\\ds \\lim_{x\\to 3} (\\sec^2x - \\tan^2 x)$\r\n\\item\t\t$\\ds \\lim_{x\\to \\pi/2} \\cos x\\sin x$\r\n\\end{enumerate}\r\n\\end{minipage}\r\n\\begin{minipage}[t]{.5\\textwidth}\r\n\\begin{enumerate}\\addtocounter{enumi}{3}\r\n\\item\t\t$\\ds \\lim_{x\\to 1} e^{\\ln x}$\r\n\\item\t\t$\\ds \\lim_{x\\to 0} \\frac{\\sin x}{x}$\r\n\\end{enumerate}\r\n\\end{minipage}\r\n}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{\r\n\\begin{enumerate}\r\n\\item\t\tThis is a straightforward application of Theorem \\ref{thm:lim_continuous}. $\\ds \\lim_{x\\to \\pi} \\cos x = \\cos \\pi = -1$.\r\n\\item\t\tWe can approach this in at least two ways. First, by directly applying Theorem \\ref{thm:lim_continuous}, we have:\r\n\t\t\t\t$$\\lim_{x\\to 3} (\\sec^2x - \\tan^2 x) = \\sec^23-\\tan^23.$$ Using the Pythagorean Theorem, this last expression is 1; therefore $$\\lim_{x\\to 3} (\\sec^2x - \\tan^2 x) = 1.$$\r\n\t\t\t\t\r\n\t\t\t\tWe can also use the Pythagorean Theorem from the start. $$\\lim_{x\\to 3} (\\sec^2x - \\tan^2 x) = \\lim_{x\\to 3} 1 = 1,$$ using the Constant limit rule. Either way, we find the limit is 1.\r\n\t\t\t\t\r\n\\item\t\tApplying the Product limit rule of Theorem \\ref{thm:limit_algebra} and Theorem \\ref{thm:lim_continuous} gives $$\\ds \\lim_{x\\to \\pi/2} \\cos x\\sin x = \\cos (\\pi/2)\\sin(\\pi/2) = 0\\cdot 1 = 0.$$\r\n\r\n\\item\t\tAgain, we can approach this in two ways. First, we can use the exponential/logarithmic identity that $e^{\\ln x} = x$ and evaluate $\\ds \\lim_{x\\to 1} e^{\\ln x} = \\lim_{x\\to 1} x = 1.$ \r\n\r\nWe can also use the Composition limit rule of Theorem \\ref{thm:limit_algebra}. Using Theorem \\ref{thm:lim_continuous}, we have $\\ds \\lim_{x\\to 1}\\ln x = \\ln 1 = 0$. Applying the Composition rule, $$\\ds \\lim_{x\\to 1} e^{\\ln x} = \\lim_{x\\to 0} e^x = e^0 = 1.$$ Both approaches are valid, giving the same result.\r\n\r\n\\item\t\tWe encountered this limit in Section \\ref{sec:LimitsWorkingDefn}. Applying our theorems, we attempt to find the limit as $$\\lim_{x\\to 0}\\frac{\\sin x}{x}\\rightarrow \\frac{\\sin 0}{0} \\rightarrow \\raisebox{8pt}{\\text{``\\ }}\\frac{0}{0}\\raisebox{8pt}{\\text{\\ ''}}.$$ This, of course, violates a condition of Theorem \\ref{thm:limit_algebra}, as the limit of the denominator is not allowed to be 0. Therefore, we are still unable to evaluate this limit with tools we currently have at hand.\r\n\\end{enumerate}\r\n}\r\n\\end{solution}\r\n\r\n\r\nOur final theorem for this section will be motivated by the following example.\\\\\r\n\r\n\r\n\\begin{example}{Using algebra to evaluate a limit}{ex_limit_onept}\r\n{\r\nEvaluate the following limit: $$\\lim_{x\\to 1}\\frac{x^2-1}{x-1}.$$\r\n}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{We begin by attempting to apply Theorem \\ref{thm:lim_continuous} and substituting $ 1 $ for $x$ in the quotient. This gives:\r\n\t\t$$\\lim_{x\\to 1}\\frac{x^2-1}{x-1} = \\frac{1^2-1}{1-1} = \\raisebox{8pt}{\\text{``\\ }}\\frac{0}{0}\\raisebox{8pt}{\\text{\\ ''}},$$ and indeterminate form. We cannot apply the theorem.\r\n\r\n\\mfigure{.6}{Graphing $f$ in Example \\ref{exa:ex_limit_onept} to understand a limit.}{fig:limitxplus1}{\\begin{tikzpicture}\r\n\\begin{axis}[,minor x tick num=1,axis y line=middle,axis x line=middle,ymin=-.1,ymax=3.2,xmin=-.1,xmax=2.2,name=myplot]\r\n\\addplot [{\\colorone},smooth,thick] coordinates {(0,1) (2,3)};\r\n\\fill[white,draw=black,thick] (axis cs:1,2) circle (1.5pt);\r\n%\\draw[thin,dashed,{\\colortwo}] (axis cs:0,1.5) -- (axis cs:2.25,1.5);\r\n%\\draw[thin,dashed,{\\colortwo}] (axis cs:0,2.5) -- (axis cs:6.25,2.5);\r\n%\\draw (axis cs:-.1,1.75) node [right]{\\tiny$\\left.\\rule{0pt}{7.5pt}\\right\\}\\epsilon = .5$};\r\n%\\draw (axis cs:-.1,2.25) node [right]{\\tiny$\\left.\\rule{0pt}{7.5pt}\\right\\}\\epsilon = .5$};\r\n%\\fill[{\\colortwo}] (axis cs:2.25,1.5) circle (1pt);\r\n%\\fill[{\\colortwo}] (axis cs:6.25,2.5) circle (1pt);\r\n%\\draw (axis cs:4,1) node [text width = 80pt,align=center] {\\footnotesize Choose $\\epsilon>0$. Then ...};\r\n\\end{axis}\r\n%\\fill[{\\colortwo}] (1,1) circle (1pt);\r\n\\node [right] at (myplot.right of origin) { $x$};\r\n\\node [above] at (myplot.above origin) {$y$};\r\n\\end{tikzpicture}}\r\n\t\t\r\n\t\tBy graphing the function, as in Figure \\ref{fig:limitxplus1}, we see that the function seems to be linear, implying that the limit should be easy to evaluate. Recognize that the numerator of our quotient can be factored:\r\n\t\t$$\\frac{x^2-1}{x-1} = \\frac{(x-1)(x+1)}{x-1}.$$\r\n\t\tThe function is not defined when $x=1$, but for all other $x$, $$\\frac{x^2-1}{x-1} = \\frac{(x-1)(x+1)}{x-1} = \\frac{\\hbox{\\sout{$(x-1)$}}(x+1)}{\\hbox{\\sout{$x-1$}}}= x+1.$$\r\n\t\tClearly $\\ds \\lim_{x\\to 1}x+1 = 2$. Recall that when considering limits, we are not concerned with the value of the function at 1, only the value the function approaches as $x$ approaches 1. Since $(x^2-1)/(x-1)$ and $x+1$ are the same at all points except $x=1$, they both approach the same value as $x$ approaches 1. Therefore we can conclude that $$\\lim_{x\\to 1}\\frac{x^2-1}{x-1}=2.$$\r\n}\r\n\\end{solution}\r\n\r\n\r\n\r\nThe key to the above example is that the functions $y=(x^2-1)/(x-1)$ and $y=x+1$ are identical except at $x=1$. Since limits describe a value the function is approaching, not the value the function actually attains, the limits of the two functions are always equal.\r\n\r\n\\begin{theorem}{Limits of Functions Equal At All But One Point}{limit_allbut1}\r\n{Let $g(x) = f(x)$ for all $x$ in an open interval, except possibly at $c$, and let $\\ds \\lim_{x\\to c} g(x) = L$ for some real number $L$. Then $$\\lim_{x\\to c}f(x) = L.$$}\r\n\\end{theorem}\r\n\r\nThe Fundamental Theorem of Algebra tells us that when dealing with a rational function of the form $g(x)/f(x)$ and directly evaluating the limit $\\ds \\lim_{x\\to c} \\frac{g(x)}{f(x)}$ returns ``$ 0/0 $'', % $\\ds\\raisebox{8pt}{\\text{``\\ }}\\frac{0}{0}\\raisebox{8pt}{\\text{\\ ''}}$, \r\nthen $(x-c)$ is a factor of both $g(x)$ and $f(x)$. One can then use algebra to factor this term out, cancel, then apply Theorem \\ref{thm:limit_allbut1}. We demonstrate this once more.\\\\\r\n\r\n\\begin{example}{Evaluating a limit using Theorem \\ref{thm:limit_allbut1}}{ex_limit_allbut1}\r\n{Evaluate $\\ds \\lim_{x\\to 3} \\frac{x^3-2 x^2-5 x+6}{2 x^3+3 x^2-32 x+15}$.}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{We begin by applying Theorem \\ref{thm:lim_continuous} and substituting 3 for $x$. This returns the familiar indeterminate form of ``0/0''. %\\zerooverzero. \r\nSince the numerator and denominator are each polynomials, we know that $(x-3)$ is factor of each. Using whatever method is most comfortable to you, factor out $(x-3)$ from each (using polynomial division, synthetic division, a computer algebra system, etc.). We find that $$\\frac{x^3-2 x^2-5 x+6}{2 x^3+3 x^2-32 x+15} = \\frac{(x-3)(x^2+x-2)}{(x-3)(2 x^2+9 x-5)}.$$ We can cancel the $(x-3)$ terms as long as $x\\neq 3$. Using Theorem \\ref{thm:limit_allbut1} we conclude:\r\n\t\t\\begin{align*}\r\n\t\t\\lim_{x\\to 3} \\frac{x^3-2 x^2-5 x+6}{2 x^3+3 x^2-32 x+15} &= \\lim_{x\\to 3}\\frac{(x-3)(x^2+x-2)}{(x-3)(2 x^2+9 x-5)} \\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&=\t\\lim_{x\\to 3} \\frac{(x^2+x-2)}{(2 x^2+9 x-5)}\\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&= \\frac{10}{40} = \\frac14.\r\n\t\t\\end{align*}\r\n}\r\n\\end{solution}\r\n\r\n\\begin{example}{Left and Right Limit}{leftright}\r\nEvaluate $\\ds\\lim_{x\\to 0}{x\\over|x|}$.\r\n\\end{example}\r\n\r\n\\begin{solution} \r\nThe function $f(x)=x/|x|$ is undefined at 0; when $x>0$, $|x|=x$ and\r\nso $f(x)=1$; when $x<0$, $|x|=-x$ and $f(x)=-1$. Thus\r\n$$\\ds \\lim_{x\\to 0^-}{x\\over|x|}=\\lim_{x\\to 0^-}-1=-1$$\r\nwhile \r\n$$\\ds \\lim_{x\\to 0^+}{x\\over|x|}=\\lim_{x\\to 0^+}1=1.$$\r\nThe limit of $f(x)$ must be equal to both the left and right limits; since they are\r\ndifferent, the limit $\\ds \\lim_{x\\to 0}{x\\over|x|}$ does not exist.\r\n\\end{solution}\r\n\r\nAnother of the most common algebraic tricks is called \\textit{rationalization}. \r\nRationalizing makes use of the difference of squares formula $(a-b)(a+b)=a^2-b^2$.\r\nHere is an example.\r\n\r\n\\begin{example}{Rationalizing}{Rationalizing}\r\nCompute $\\ds\\lim_{x\\to-1} {\\sqrt{x+5}-2\\over x+1}$.\r\n\\end{example}\r\n\r\n\\begin{solution} \r\n\\begin{eqnarray*}\r\n\\lim_{x\\to-1} {\\sqrt{x+5}-2\\over x+1}&=&\r\n\\lim_{x\\to-1} {\\sqrt{x+5}-2\\over x+1}\\cdot{\\sqrt{x+5}+2\\over \\sqrt{x+5}+2}\\cr\r\n\\\\\r\n&=&\\lim_{x\\to-1} {x+5-4\\over (x+1)(\\sqrt{x+5}+2)}\\cr\r\n\\\\\r\n&=&\\lim_{x\\to-1} {x+1\\over (x+1)(\\sqrt{x+5}+2)}\\cr\r\n\\\\\r\n&=&\\lim_{x\\to-1} {1\\over \\sqrt{x+5}+2}={1\\over4}\r\n\\end{eqnarray*}\r\nAt the very last step we have used the last two parts of Theorem  \\ref{limit_algebra}.\r\n\\end{solution}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\r\n\r\nWe end this section by revisiting a limit first seen in Section \\ref{sec:LimitsWorkingDefn}, a limit of a difference quotient. Let $f(x) = -1.5x^2+11.5x$; we approximated the limit $\\ds \\lim_{h\\to 0}\\frac{f(1+h)-f(1)}{h}\\approx 8.5.$ We formally evaluate this limit in the following example.\\\\\r\n\r\n\\begin{example}{Evaluating the limit of a difference quotient}{ex_limit_diffquot}{\r\nLet $f(x) = -1.5x^2+11.5x$; find $\\ds \\lim_{h\\to 0}\\frac{f(1+h)-f(1)}{h}.$}\r\n\\end{example}\r\n\r\n\r\n\\begin{solution}\r\n{Since $f$ is a polynomial, our first attempt should be to employ Theorem \\ref{thm:lim_continuous} and substitute 0 for $h$. However, we see that this gives us ``$0/0$.'' %\\zerooverzero.\r\n Knowing that we have a rational function hints that some algebra will help. Consider the following steps:\r\n\t\t\\begin{align*}\r\n\t\t\\lim_{h\\to 0}\\frac{f(1+h)-f(1)}{h} \t&= \t\\lim_{h\\to 0}\\frac{-1.5(1+h)^2 + 11.5(1+h) - \\left(-1.5(1)^2+11.5(1)\\right)}{h} \\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&=\t\\lim_{h\\to 0}\\frac{-1.5(1+2h+h^2) + 11.5+11.5h - 10}{h}\\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&=\t\\lim_{h\\to 0}\\frac{-1.5h^2 +8.5h}{h}\\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&= \t\\lim_{h\\to 0}\\frac{h(-1.5h+8.5)}h\\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&=\t\\lim_{h\\to 0}(-1.5h+8.5) \\quad (\\text{\\small using Theorem \\ref{thm:limit_allbut1}, as $h\\neq 0$}) \\\\\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&= \t8.5 \\quad (\\text{\\small using Theorem \\ref{thm:lim_continuous}})\r\n\t\t\\end{align*}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\nThis matches our previous approximation.\r\n}\r\n\\end{solution}\r\n\r\n\r\n\r\nThis section contains several valuable tools for evaluating limits. One of the main results of this section is Theorem \\ref{thm:lim_continuous}; it states that many functions that we use regularly behave in a very nice, predictable way.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\Opensolutionfile{solutions}[ex]\r\n\\section*{Exercises for \\ref{sec:ComputingLimitsAlg}}\r\n\r\n\\begin{enumialphparenastyle}\r\n\r\n%%%%%%%%%%\r\n% % % % % % % % % % %\r\n\\begin{ex}\r\n{Explain in your own words, without using $\\epsilon$-$\\delta$ formality, why $\\ds \\lim_{x\\to c} b = b$.}\r\n\r\n\\begin{sol}\r\n{Answers will vary.\r\n}\r\n\\end{sol}\r\n\r\n\\end{ex}\r\n% % % % % % % % % % % %\r\n% % % % % % % % % % %\r\n\\begin{ex}\r\n{Explain in your own words, without using $\\epsilon$-$\\delta$ formality, why $\\ds \\lim_{x\\to c} x = c$.}\r\n\r\n\\begin{sol}\r\n{Answers will vary.\r\n}\r\n\\end{sol}\r\n\r\n\\end{ex}\r\n% % % % % % % % % % % %\r\n% % % % % % % % % % %\r\n\\begin{ex}\r\n{What does the text mean when it says that certain functions' ``behavior is `nice' in terms of limits''? What, in particular, is ``nice''?}\r\n\r\n\\begin{sol}\r\n{Answers will vary.\r\n}\r\n\\end{sol}\r\n\r\n\\end{ex}\r\n% % % % % % % % % % % %\r\n\r\n% % % % % % % % % % %\r\n\\begin{ex}\r\nUsing:\r\n\r\n\\begin{tabular}{lll}\r\n$\\ds \\lim_{x\\to9}f(x) = 6$ & \\quad\\quad &$\\ds \\lim_{x\\to6} f(x) = 9$\\\\\r\n$\\ds \\lim_{x\\to9}g(x) = 3$ &  & $\\ds \\lim_{x\\to6} g(x) = 3$\r\n\\end{tabular}\r\n\r\n\\noindent evaluate the following limits, where possible. If it is not possible to know, state so.\r\n\\begin{enumerate}\r\n\\item {$\\ds \\lim_{x\\to9}(f(x)+g(x))$}\r\n\\item  {$\\ds \\lim_{x\\to9}(3f(x)/g(x))$}\r\n\\item {$\\ds \\lim_{x\\to9}\\left(\\frac{f(x)-2g(x)}{g(x)}\\right)$}\r\n\\item {$\\ds \\lim_{x\\to6}\\left(\\frac{f(x)}{3-g(x)}\\right)$}\r\n\\item  {$\\ds \\lim_{x\\to9}g\\big(f(x)\\big)$} \r\n\\item {$\\ds \\lim_{x\\to6}f\\big(g(x)\\big)$}\r\n\\item {$\\ds \\lim_{x\\to6}g\\big(f(f(x))\\big)$}\r\n\\item {$\\ds \\lim_{x\\to6}f(x)g(x)-f\\,^2(x)+g^2(x)$}\r\n\\end{enumerate}\r\n\r\n\\begin{sol}\r\n\\begin{enumerate}\r\n\\item \r\n{9}\r\n\\item\r\n{6}\r\n\\item\r\n{0}\r\n\\item \r\n{Limit does not exist.}\r\n\\item\r\n{3}\r\n\\item \r\n{Not possible to know.}\r\n\\item \r\n{3}\r\n\\item \r\n{$-45$}\r\n\\end{enumerate}\r\n\\end{sol}\r\n\r\n\\end{ex}\r\n% % % % % % % % % % % %\r\n\r\n% % % % % % % % % % %\r\n\\begin{ex}\r\n\\noindent Using:\r\n\r\n\\begin{tabular}{lll}\r\n$\\ds \\lim_{x\\to1}f(x) = 2$ & \\quad\\quad &$\\ds \\lim_{x\\to10} f(x) = 1$\\\\\r\n$\\ds \\lim_{x\\to1}g(x) = 0$ &  & $\\ds \\lim_{x\\to10} g(x) = \\pi$\r\n\\end{tabular}\r\n\r\n\\noindent evaluate the limits given, where possible. If it is not possible to know, state so.\r\n\\begin{enumerate}\r\n\\item {$\\ds \\lim_{x\\to1}f(x)^{g(x)}$}\r\n\r\n\\item {$\\ds \\lim_{x\\to10}\\cos \\big(g(x)\\big)$}\r\n\r\n\\item {$\\ds \\lim_{x\\to1}f(x)g(x)$}\r\n\r\n\\item {$\\ds \\lim_{x\\to1}g\\big(5f(x)\\big)$}\r\n\r\n\\end{enumerate}\r\n\r\n\\begin{sol}\r\n\\begin{enumerate}\r\n\\item {$1$}\r\n\\item {$-1$}\r\n\\item {$0$}\r\n\\item {$\\pi$}\r\n\\end{enumerate}\r\n\\end{sol}\r\n\r\n\\end{ex}\r\n% % % % % % % % % % % %\r\n\r\n\r\n\r\n\\begin{ex}\r\nCompute the limits. If a limit does not exist, explain why.\r\n\\begin{multicols}{2}\r\n\\begin{enumerate}\r\n\t\\item\t$\\ds \\lim_{x\\to 3}{x^2+x-12\\over x-3}$\r\n\t\\item\t$\\ds \\lim_{x\\to 1}{x^2+x-12\\over x-3}$\r\n\t\\item\t$\\ds \\lim_{x\\to -4}{x^2+x-12\\over x-3}$\r\n\t\\item {$\\ds \\lim_{x\\to\\pi}\\frac{3x+1}{1-x}$}\r\n\t\\item {$\\ds \\lim_{x\\to\\pi}\\frac{x^2+3x+5}{5x^2-2x-3}$}\r\n\t\r\n\t\\item {$\\ds \\lim_{x\\to\\pi}\\left(\\frac{x-3}{x-5}\\right)^7$}\r\n\r\n\t\\item {$\\ds \\lim_{x\\to\\pi/4}\\cos x\\sin x$}\r\n\t\r\n\t\\item {$\\ds \\lim_{x\\to0}\\ln x$}\r\n\r\n\t\\item  {$\\ds \\lim_{x\\to3}4^{x^3-8x}$}\r\n\r\n\t\\item\t$\\ds \\lim_{x\\to 2} {x^2+x-12\\over x-2}$\r\n\t\\item\t$\\ds \\lim_{x\\to 1} {\\sqrt{x+8}-3\\over x-1}$\r\n\t\\item\t$\\ds \\lim_{x\\to 0^+} \\sqrt{{1\\over x}+2} - \\sqrt{1\\over x}$\r\n\t\\item\t$\\ds\\lim _{x\\to 2} 3$\r\n\t\\item\t$\\ds\\lim _{x\\to 4 } 3x^3 - 5x $\r\n\t\\item\t$\\ds \\lim _{x\\to 0 } {4x - 5x^2\\over x-1}$\r\n\t\\item\t$\\ds\\lim _{x\\to 1 } {x^2 -1 \\over x-1 }$\r\n\t\\item\t$\\ds\\lim _{x\\to 0^ + } {\\sqrt{2-x^2 }\\over x}$\r\n\t\\item\t$\\ds\\lim _{x\\to 0^ + } {\\sqrt{2-x^2}\\over x+1}$\r\n\t\\item\t$\\ds\\lim _{x\\to a } {x^3 -a^3\\over x-a}$\r\n\t\\item\t$\\ds\\lim _{x\\to 2 } (x^2 +4)^3$\r\n\\end{enumerate}\r\n\\end{multicols}\r\n\\begin{sol}\r\n\\begin{multicols}{2}\r\n\\begin{enumerate}\r\n\t\\item\t7\r\n\t\\item\t5\r\n\t\\item\t0\r\n\t\\item {$\\frac{3\\pi+1}{1-\\pi}$}\r\n\t\\item {$\\frac{\\pi^2+3\\pi+5}{5\\pi^2-2\\pi-3} \\approx 0.6064$}\r\n\t\\item \t{$-0.000000015\\approx 0$}\r\n\t\\item {$1/2$}\r\n\t\\item \t{Limit does not exist}\r\n\t\\item \t{$64$}\r\n\t\\item\tundefined\r\n\t\\item\t$1/6$\r\n\t\\item\t0\r\n\t\\item\t3\r\n\t\\item\t172\r\n\t\\item\t0\r\n\t\\item\t2\r\n\t\\item\tdoes not exist\r\n\t\\item\t$\\ds \\sqrt2$\r\n\t\\item\t$\\ds 3a^2$\r\n\t\\item\t512\r\n\\end{enumerate}\r\n\\end{multicols}\r\n\\end{sol}\r\n\\end{ex}\r\n\r\n%%%%%%%%%%\r\n\\begin{ex}\r\nLet $f(x)=\\left\\{ \r\n\\begin{array}{cc}\r\n1 & \\text{if }x\\neq 0 \\\\ \r\n0 & \\text{if }x=0%\r\n\\end{array}%\r\n\\right.$ and $g(x)=0$. What are the values of $\r\nL=\\lim_{x\\to 0}g(x)$ and $M=\\lim_{x\\to L}f(x)$? Is it true that $\\lim_{x\\to\t0}f(g(x))=M$? What are some noteworthy differences\r\nbetween this example and part \\# 9 of Theorem~\\ref{thm:limit_algebra}?\r\n\\begin{sol}\r\n\t$L=0$ and $M=1.$ No.\r\n\\end{sol}\r\n\\end{ex}\r\n\r\n\\end{enumialphparenastyle}\r\n\r\n\\clearpage", "meta": {"hexsha": "fa0649d5a95ca91d0ecbe73d1da71a11e0f7ecf8", "size": 22877, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "3-limits/3-4-limits-props.tex", "max_stars_repo_name": "TimAlderson/OpenCalc", "max_stars_repo_head_hexsha": "7d0110b6bc4ba42a6b911729420e1406296d6964", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "3-limits/3-4-limits-props.tex", "max_issues_repo_name": "TimAlderson/OpenCalc", "max_issues_repo_head_hexsha": "7d0110b6bc4ba42a6b911729420e1406296d6964", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "3-limits/3-4-limits-props.tex", "max_forks_repo_name": "TimAlderson/OpenCalc", "max_forks_repo_head_hexsha": "7d0110b6bc4ba42a6b911729420e1406296d6964", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.0533088235, "max_line_length": 491, "alphanum_fraction": 0.6260436246, "num_tokens": 8696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.4058847202666087}}
{"text": "\\section{Dynamic Programming}\n\n\\subsection{Exercise 4.1}\n\\subsubsection*{Q}\nIn Example 4.1, if $\\pi$ is the equiprobable random policy, what is $q_\\pi(11, \\mathtt{down})$? What is $q_\\pi(7, \\mathtt{down})$?\n\n\\subsubsection*{A}\n$q_\\pi(11, \\mathtt{down}) = -1$ since goes to terminal state. $q_\\pi(7, \\mathtt{down}) = -15$.\n\n\\subsection{Exercise 4.2}\n\\subsubsection*{Q}\nIn Example 4.1, suppose a new state $15$ is added to the gridworld just below state $13$, and its actions, \\texttt{left}, \\texttt{up}, \\texttt{right}, and \\texttt{down}, take the agent to states $12$, $13$, $14$, and $15$, respectively. Assume that the transitions from the original states are unchanged. What, then, is $v_\\pi(15)$ for the equiprobable random policy? Now suppose the dynamics of state $13$ are also changed, such that action down from state $13$ takes the agent to the new state $15$. What is $v_\\pi(15)$ for the equiprobable random policy in this case?\n\n\\subsubsection*{A}\n$v_\\pi(15) = -20$ if dynamics unchanged. If dynamics changed then apparently the state value is the same, but you would need to verify Bellman equations for all states for this.\n\n\\subsection{Exercise 4.3}\n\\subsubsection*{Q}\nWhat are the equations analogous to (4.3), (4.4), and (4.5) for the action-value function $q_\\pi$ and its successive approximations by a sequence of functions $q_0, q_1, q_2, \\dots$?\n\n\\subsubsection*{A}\n\\begin{equation}\n    q_{k+1}(s, a) = \\sum_{s', r} p(s', r | s, a)\\left[r + \\gamma \\sum_{a'} \\pi(a'|s)q_k(s', a')\\right]\n\\end{equation}\n\n\\subsection{Exercise 4.4}\n\\subsubsection*{Q}\nThe policy iteration algorithm on the previous page has a subtle bug in that it may never terminate if the policy continually switches between two or more policies that are equally good. This is ok for pedagogy, but not for actual use. Modify the pseudocode so that convergence is guaranteed.\n\n\\subsubsection*{A}\nOne problem is that the $\\argmax_a$ has ties broken arbitrarily, this means that the same value function can give rise to different policies.\\\\\n\nThe way to solve this is to change the algorithm to take the whole set of maximal actions on each step and see if this set is stable and see if the policy is stable with respect to choosing actions from this set.\n\n\n\\subsection{Exercise 4.5}\n\\subsubsection*{Q}\nHow would policy iteration be defined for action values? Give a complete algorithm for computing $q_*$, analogous to that on page 80 for computing $q_*$. Please pay special attention to this exercise, because the ideas involved will be used throughout the rest of the book.\n\n\\subsubsection*{A}\nWe know that\n\\begin{equation}\n    v_\\pi(s) = \\sum_{a \\in \\mathcal{A}(s)} \\pi(a|s)q_\\pi(s, a)\n\\end{equation}\nso we know that\n\\begin{equation}\n    q_\\pi(s, \\pi'(s)) \\geq \\sum_{a \\in \\mathcal{A}(s)} \\pi(a|s)q_\\pi(s, a)\n\\end{equation}\nif $\\pi'$ is greedy with respect to $\\pi$. So we know the algorithm still works for action values.\\\\\n\nAll there is now is to substitute the update for the action-value update and make the policy greedy with respect to the last iteration's action-values. Also need to make sure that the $\\argmax_a$ is done consistently.\n\n\\subsection{Exercise 4.6}\n\\subsubsection*{Q}\nSuppose you are restricted to considering only policies that are $\\varepsilon$-soft, meaning that the probability of selecting each action in each state, $s$, is at least $\\varepsilon / |\\mathcal{A}(s)|$. Describe qualitatively the changes that would be required in each of the steps 3, 2, and 1, in that order, of the policy iteration algorithm for $v_\\pi$ (page 80).\n\n\\subsubsection*{A}\n\\begin{enumerate}\n    \\item No change (but need policy to be able to be stochastic of course)\n    \\item Need to re-write the Bellman update $v(s) \\longleftarrow \\sum_{a \\in \\mathcal{A}(s)} \\pi(a|s)\\sum_{s', r}p(s', r|s, a)\\left[ r + \\gamma v(s') \\right]$\n    \\item Construct a greedy policy that puts weight on the greedy actions but is $\\varepsilon$-soft. Be careful with the consistency of the $\\argmax$.\n\\end{enumerate}\n\n\\subsection{Exercise 4.7 (programming): Jack's Car Rental}\n\n\\includegraphics[width=\\textwidth]{\\ProjectDir/data/exercise_questions/jacks_car_rental_example.png}\n\nFirst we reproduce the original results.\n\n\\includegraphics[width=\\textwidth]{\\ProjectDir/data/exercise_output/ex_4_7/jacks_car_rental/jacks_car_rental.png}\n\n\\subsubsection*{Q}\nWrite a program for policy iteration and re-solve Jack’s car rental problem with the following changes. One of Jack’s employees at the first location rides a bus home each night and lives near the second location. She is happy to shuttle one car to the second location for free. Each additional car still costs \\$$2$, as do all cars moved in the other direction. In addition, Jack has limited parking space at each location. If more than $10$ cars are kept overnight at a location (after any moving of cars), then an additional cost of \\$$4$ must be incurred to use a second parking lot (independent of how many cars are kept there). These sorts of nonlinearities and arbitrary dynamics often occur in real problems and cannot easily be handled by optimisation methods other than dynamic programming. To check your program, first replicate the results given for the original problem. If your computer is too slow for the full problem, cut all the numbers of cars in half.\n\n\\subsubsection*{A}\n\\ProgrammingExercise\\\\\n\\includegraphics[width=\\textwidth]{\\ProjectDir/data/exercise_output/ex_4_7/altered_car_rental.png}\n\n\\subsection{Exercise 4.8}\n\\subsubsection*{Q}\nWhy does the optimal policy for the gambler’s problem have such a curious form? In particular, for capital of 50 it bets it all on one flip, but for capital of 51 it does not. Why is this a good policy?\n\n\\subsubsection*{A}\nSince the coin is biased against us, we want to minimize the number of flips that we take. At 50 we can win with probability 0.4. At 51 if we bet small then we can get up to 52, but if we lose then we are still only back to 50 and we can again with with probability 0.4. (There is a whole paper on this problem called how to gamble if you must.)\n\n\n\\subsection{Exercise 4.9 (programming): Gambler's Problem}\n\\subsubsection*{Q}\nImplement value iteration for the gambler's problem and solve it for $p_h = 0.25$ and $p_h = 0.55$. In programming, you may find it convenient to introduce two dummy states corresponding to termination with capital of $0$ and $100$, giving them values of $0$ and $1$ respectively. Show your results graphically, as in Figure 4.3. Are your results stable as $\\theta \\to 0$?\n\n\\subsubsection*{A}\n\\ProgrammingExercise\\\\\n\nThe process was stable as $\\theta \\to 0$ for $\\P{}(\\mathtt{win}) < 0.5$.\n\n\\includegraphics[width=\\textwidth]{\\ProjectDir/data/exercise_output/ex_4_9/values_and_policy_pwin_25.eps}\n\n\\includegraphics[width=\\textwidth]{\\ProjectDir/data/exercise_output/ex_4_9/values_and_policy_pwin_55.eps}\n\n\\subsection{Exercise 4.10}\n\\subsubsection*{Q}\nWhat is the analog of the value iteration update (4.10) for action values, $q_{k+1}(s, a)$?\n\n\\subsubsection*{A}\n\\begin{equation}\n    q_{k+1} = \\max_{a'} \\sum_{s', r} p(s', r| s, a)\\left[r + \\gamma q_k(s', a')\\right]\n\\end{equation}\n\n", "meta": {"hexsha": "e5a19ca64c6ef9b75eed5aff087156a16f80e553", "size": 7119, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/chapters/chapter4/chapter4_content.tex", "max_stars_repo_name": "ElliotMunro200/reinforcement_learning_an_introduction", "max_stars_repo_head_hexsha": "c4fccb46a4bb00955549be3505144ec49f0132e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 234, "max_stars_repo_stars_event_min_datetime": "2018-09-01T00:26:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T03:55:50.000Z", "max_issues_repo_path": "exercises/chapters/chapter4/chapter4_content.tex", "max_issues_repo_name": "15779235038/reinforcement_learning_an_introduction", "max_issues_repo_head_hexsha": "a0ac9e5da6eaeae14d297a560c499d1a6e579c2a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2018-11-29T21:04:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-13T17:11:50.000Z", "max_forks_repo_path": "exercises/chapters/chapter4/chapter4_content.tex", "max_forks_repo_name": "15779235038/reinforcement_learning_an_introduction", "max_forks_repo_head_hexsha": "a0ac9e5da6eaeae14d297a560c499d1a6e579c2a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 63, "max_forks_repo_forks_event_min_datetime": "2018-07-31T04:53:21.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T04:03:43.000Z", "avg_line_length": 65.3119266055, "max_line_length": 971, "alphanum_fraction": 0.7488411294, "num_tokens": 1973, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.40588471708719315}}
{"text": "\\section{Clustering}\n\n\\ifCPy\n\n\\cvCPyFunc{KMeans2}\nSplits set of vectors by a given number of clusters.\n\n\\cvdefC{int cvKMeans2(const CvArr* samples, int nclusters,\\par\n                      CvArr* labels, CvTermCriteria termcrit,\\par\n                      int attempts=1, CvRNG* rng=0, \\par\n                      int flags=0, CvArr* centers=0,\\par\n                      double* compactness=0);}\n\\cvdefPy{KMeans2(samples,nclusters,labels,termcrit)-> None}\n\n\\begin{description}\n\\cvarg{samples}{Floating-point matrix of input samples, one row per sample}\n\\cvarg{nclusters}{Number of clusters to split the set by}\n\\cvarg{labels}{Output integer vector storing cluster indices for every sample}\n\\cvarg{termcrit}{Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)}\n\\ifC\n\\cvarg{attempts}{How many times the algorithm is executed using different initial labelings. The algorithm returns labels that yield the best compactness (see the last function parameter)}\n\\cvarg{rng}{Optional external random number generator; can be used to fully control the function behaviour}\n\\cvarg{flags}{Can be 0 or \\texttt{CV\\_KMEANS\\_USE\\_INITIAL\\_LABELS}. The latter\nvalue means that during the first (and possibly the only) attempt, the\nfunction uses the user-supplied labels as the initial approximation\ninstead of generating random labels. For the second and further attempts,\nthe function will use randomly generated labels in any case}\n\\cvarg{centers}{The optional output array of the cluster centers}\n\\cvarg{compactness}{The optional output parameter, which is computed as\n$\\sum_i ||\\texttt{samples}_i - \\texttt{centers}_{\\texttt{labels}_i}||^2$\nafter every attempt; the best (minimum) value is chosen and the\ncorresponding labels are returned by the function. Basically, the\nuser can use only the core of the function, set the number of\nattempts to 1, initialize labels each time using a custom algorithm\n(\\texttt{flags=CV\\_KMEAN\\_USE\\_INITIAL\\_LABELS}) and, based on the output compactness\nor any other criteria, choose the best clustering.}\n\\fi\n\\end{description}\n\nThe function \\texttt{cvKMeans2} implements a k-means algorithm that finds the\ncenters of \\texttt{nclusters} clusters and groups the input samples\naround the clusters. On output, $\\texttt{labels}_i$ contains a cluster index for\nsamples stored in the i-th row of the \\texttt{samples} matrix.\n\n\\ifC\n% Example: Clustering random samples of multi-gaussian distribution with k-means\n\\begin{lstlisting}\n#include \"cxcore.h\"\n#include \"highgui.h\"\n\nvoid main( int argc, char** argv )\n{\n    #define MAX_CLUSTERS 5\n    CvScalar color_tab[MAX_CLUSTERS];\n    IplImage* img = cvCreateImage( cvSize( 500, 500 ), 8, 3 );\n    CvRNG rng = cvRNG(0xffffffff);\n\n    color_tab[0] = CV_RGB(255,0,0);\n    color_tab[1] = CV_RGB(0,255,0);\n    color_tab[2] = CV_RGB(100,100,255);\n    color_tab[3] = CV_RGB(255,0,255);\n    color_tab[4] = CV_RGB(255,255,0);\n\n    cvNamedWindow( \"clusters\", 1 );\n\n    for(;;)\n    {\n        int k, cluster_count = cvRandInt(&rng)%MAX_CLUSTERS + 1;\n        int i, sample_count = cvRandInt(&rng)%1000 + 1;\n        CvMat* points = cvCreateMat( sample_count, 1, CV_32FC2 );\n        CvMat* clusters = cvCreateMat( sample_count, 1, CV_32SC1 );\n\n        /* generate random sample from multigaussian distribution */\n        for( k = 0; k < cluster_count; k++ )\n        {\n            CvPoint center;\n            CvMat point_chunk;\n            center.x = cvRandInt(&rng)%img->width;\n            center.y = cvRandInt(&rng)%img->height;\n            cvGetRows( points,\n                       &point_chunk,\n                       k*sample_count/cluster_count,\n                       (k == (cluster_count - 1)) ?\n                           sample_count :\n                           (k+1)*sample_count/cluster_count );\n            cvRandArr( &rng, &point_chunk, CV_RAND_NORMAL,\n                       cvScalar(center.x,center.y,0,0),\n                       cvScalar(img->width/6, img->height/6,0,0) );\n        }\n\n        /* shuffle samples */\n        for( i = 0; i < sample_count/2; i++ )\n        {\n            CvPoint2D32f* pt1 =\n                (CvPoint2D32f*)points->data.fl + cvRandInt(&rng)%sample_count;\n            CvPoint2D32f* pt2 =\n                (CvPoint2D32f*)points->data.fl + cvRandInt(&rng)%sample_count;\n            CvPoint2D32f temp;\n            CV_SWAP( *pt1, *pt2, temp );\n        }\n\n        cvKMeans2( points, cluster_count, clusters,\n                   cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 10, 1.0 ));\n\n        cvZero( img );\n\n        for( i = 0; i < sample_count; i++ )\n        {\n            CvPoint2D32f pt = ((CvPoint2D32f*)points->data.fl)[i];\n            int cluster_idx = clusters->data.i[i];\n            cvCircle( img,\n                      cvPointFrom32f(pt),\n                      2,\n                      color_tab[cluster_idx],\n                      CV_FILLED );\n        }\n\n        cvReleaseMat( &points );\n        cvReleaseMat( &clusters );\n\n        cvShowImage( \"clusters\", img );\n\n        int key = cvWaitKey(0);\n        if( key == 27 )\n            break;\n    }\n}\n\\end{lstlisting}\n\n\\cvCPyFunc{SeqPartition}\nSplits a sequence into equivalency classes.\n\n\\cvdefC{\nint cvSeqPartition( \\par const CvSeq* seq,\\par CvMemStorage* storage,\\par CvSeq** labels,\\par CvCmpFunc is\\_equal,\\par void* userdata );\n}\n\n\\begin{description}\n\\cvarg{seq}{The sequence to partition}\n\\cvarg{storage}{The storage block to store the sequence of equivalency classes. If it is NULL, the function uses \\texttt{seq->storage} for output labels}\n\\cvarg{labels}{Ouput parameter. Double pointer to the sequence of 0-based labels of input sequence elements}\n\\cvarg{is\\_equal}{The relation function that should return non-zero if the two particular sequence elements are from the same class, and zero otherwise. The partitioning algorithm uses transitive closure of the relation function as an equivalency critria}\n\\cvarg{userdata}{Pointer that is transparently passed to the \\texttt{is\\_equal} function}\n\\end{description}\n\n\\begin{lstlisting}\ntypedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata);\n\\end{lstlisting}\n\nThe function \\texttt{cvSeqPartition} implements a quadratic algorithm for\nsplitting a set into one or more equivalancy classes. The function\nreturns the number of equivalency classes.\n\n% Example: Partitioning a 2d point set\n\\begin{lstlisting}\n\n#include \"cxcore.h\"\n#include \"highgui.h\"\n#include <stdio.h>\n\nCvSeq* point_seq = 0;\nIplImage* canvas = 0;\nCvScalar* colors = 0;\nint pos = 10;\n\nint is_equal( const void* _a, const void* _b, void* userdata )\n{\n    CvPoint a = *(const CvPoint*)_a;\n    CvPoint b = *(const CvPoint*)_b;\n    double threshold = *(double*)userdata;\n    return (double)((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y)) <=\n        threshold;\n}\n\nvoid on_track( int pos )\n{\n    CvSeq* labels = 0;\n    double threshold = pos*pos;\n    int i, class_count = cvSeqPartition( point_seq,\n                                         0,\n                                         &labels,\n                                         is_equal,\n                                         &threshold );\n    printf(\"%4d classes\\n\", class_count );\n    cvZero( canvas );\n\n    for( i = 0; i < labels->total; i++ )\n    {\n        CvPoint pt = *(CvPoint*)cvGetSeqElem( point_seq, i );\n        CvScalar color = colors[*(int*)cvGetSeqElem( labels, i )];\n        cvCircle( canvas, pt, 1, color, -1 );\n    }\n\n    cvShowImage( \"points\", canvas );\n}\n\nint main( int argc, char** argv )\n{\n    CvMemStorage* storage = cvCreateMemStorage(0);\n    point_seq = cvCreateSeq( CV_32SC2,\n                             sizeof(CvSeq),\n                             sizeof(CvPoint),\n                             storage );\n    CvRNG rng = cvRNG(0xffffffff);\n\n    int width = 500, height = 500;\n    int i, count = 1000;\n    canvas = cvCreateImage( cvSize(width,height), 8, 3 );\n\n    colors = (CvScalar*)cvAlloc( count*sizeof(colors[0]) );\n    for( i = 0; i < count; i++ )\n    {\n        CvPoint pt;\n        int icolor;\n        pt.x = cvRandInt( &rng ) % width;\n        pt.y = cvRandInt( &rng ) % height;\n        cvSeqPush( point_seq, &pt );\n        icolor = cvRandInt( &rng ) | 0x00404040;\n        colors[i] = CV_RGB(icolor & 255,\n                           (icolor >> 8)&255,\n                           (icolor >> 16)&255);\n    }\n\n    cvNamedWindow( \"points\", 1 );\n    cvCreateTrackbar( \"threshold\", \"points\", &pos, 50, on_track );\n    on_track(pos);\n    cvWaitKey(0);\n    return 0;\n}\n\\end{lstlisting}\n\n\\fi\n\n\\fi\n\n\\ifCpp\n\n\\cvCppFunc{kmeans}\nFinds the centers of clusters and groups the input samples around the clusters.\n\\cvdefCpp{double kmeans( const Mat\\& samples, int clusterCount, Mat\\& labels,\\par\n               TermCriteria termcrit, int attempts,\\par\n               int flags, Mat* centers );}\n\\begin{description}\n\\cvarg{samples}{Floating-point matrix of input samples, one row per sample}\n\\cvarg{clusterCount}{The number of clusters to split the set by}\n\\cvarg{labels}{The input/output integer array that will store the cluster indices for every sample}\n\\cvarg{termcrit}{Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)}\n\n\\cvarg{attempts}{How many times the algorithm is executed using different initial labelings. The algorithm returns the labels that yield the best compactness (see the last function parameter)}\n\\cvarg{flags}{It can take the following values:\n\\begin{description}\n\\cvarg{KMEANS\\_RANDOM\\_CENTERS}{Random initial centers are selected in each attempt}\n\\cvarg{KMEANS\\_PP\\_CENTERS}{Use kmeans++ center initialization by Arthur and Vassilvitskii}\n\\cvarg{KMEANS\\_USE\\_INITIAL\\_LABELS}{During the first (and possibly the only) attempt, the\nfunction uses the user-supplied labels instaed of computing them from the initial centers. For the second and further attempts, the function will use the random or semi-random centers (use one of \\texttt{KMEANS\\_*\\_CENTERS} flag to specify the exact method)}\n\\end{description}}\n\\cvarg{centers}{The output matrix of the cluster centers, one row per each cluster center}\n\\end{description}\n\nThe function \\texttt{kmeans} implements a k-means algorithm that finds the\ncenters of \\texttt{clusterCount} clusters and groups the input samples\naround the clusters. On output, $\\texttt{labels}_i$ contains a 0-based cluster index for\nthe sample stored in the $i^{th}$ row of the \\texttt{samples} matrix.\n\nThe function returns the compactness measure, which is computed as\n\\[\n\\sum_i \\|\\texttt{samples}_i - \\texttt{centers}_{\\texttt{labels}_i}\\|^2\n\\]\nafter every attempt; the best (minimum) value is chosen and the\ncorresponding labels and the compactness value are returned by the function.\nBasically, the user can use only the core of the function, set the number of\nattempts to 1, initialize labels each time using some custom algorithm and pass them with\n\\par (\\texttt{flags}=\\texttt{KMEANS\\_USE\\_INITIAL\\_LABELS}) flag, and then choose the best (most-compact) clustering.\n\n\\cvCppFunc{partition}\nSplits an element set into equivalency classes.\n\n\\cvdefCpp{template<typename \\_Tp, class \\_EqPredicate> int\\newline\n    partition( const vector<\\_Tp>\\& vec, vector<int>\\& labels,\\par\n               \\_EqPredicate predicate=\\_EqPredicate());}\n\\begin{description}\n\\cvarg{vec}{The set of elements stored as a vector}\n\\cvarg{labels}{The output vector of labels; will contain as many elements as \\texttt{vec}. Each label \\texttt{labels[i]} is 0-based cluster index of \\texttt{vec[i]}}\n\\cvarg{predicate}{The equivalence predicate (i.e. pointer to a boolean function of two arguments or an instance of the class that has the method \\texttt{bool operator()(const \\_Tp\\& a, const \\_Tp\\& b)}. The predicate returns true when the elements are certainly if the same class, and false if they may or may not be in the same class}\n\\end{description}\n\nThe generic function \\texttt{partition} implements an $O(N^2)$ algorithm for\nsplitting a set of $N$ elements into one or more equivalency classes, as described in \\url{http://en.wikipedia.org/wiki/Disjoint-set_data_structure}. The function\nreturns the number of equivalency classes.\n\n\n\\fi\n", "meta": {"hexsha": "74ab65506ff5256e2661bd28c2d63846e0613ca3", "size": 12158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "to/lang/OpenCV-2.2.0/doc/core_clustering_search.tex", "max_stars_repo_name": "eirTony/INDI1", "max_stars_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "to/lang/OpenCV-2.2.0/doc/core_clustering_search.tex", "max_issues_repo_name": "eirTony/INDI1", "max_issues_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2016-11-24T10:46:39.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-10T07:24:15.000Z", "max_forks_repo_path": "to/lang/OpenCV-2.2.0/doc/core_clustering_search.tex", "max_forks_repo_name": "eirTony/INDI1", "max_forks_repo_head_hexsha": "42642d8c632da53f60f2610b056547137793021b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6369863014, "max_line_length": 335, "alphanum_fraction": 0.6704227669, "num_tokens": 3200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4058847139077776}}
{"text": "% !TEX root =main.tex\n\n\n\n%\\section{Notations}\\label{sec:notation-table}\n%\n%We summarise our notation in Table \\ref{table:notation-table}.\n%\n%\\vspace{-4mm}\n%\\begin{table}[!htbp]\n%%\\begin{footnotesize}\n%\\small{\n%\\begin{center}\n%%\\footnotesize{\n%\n%%\\scalebox{.98}{\n%%\\begin{minipage}{.9\\linewidth}\n%\\caption{ \\small Notation Table.}\\label{table:notation-table} \n%\\renewcommand{\\arraystretch}{.7}\n%%\\resizebox{\\columnwidth}{!}{\n%\n%% 1st table\n%\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n%\n%\\hline \n%\n%\\cellcolor{gray!30}\\scriptsize \\textbf{Setting} &\\cellcolor{gray!30} \\scriptsize \\textbf{Symbol}&\\cellcolor{gray!30} \\scriptsize \\textbf{Description}  \\\\\n%    \\hline\n%    \n%     \\hline\n%\n%%Generic\n%\\multirow{9}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{Generic}}}\n%\n% &\\cellcolor{white!20}\\scriptsize$z$&\\cellcolor{white!20}\\scriptsize \\text{Number of puzzles or delegated verifications}\\\\   \n% \n%&\\cellcolor{gray!20}\\scriptsize$h$, $h_{\\scriptscriptstyle j}$ &\\cellcolor{gray!20}\\scriptsize Hash values  \\\\  \n%\n%&\\cellcolor{white!20}\\scriptsize$d$, $d_{\\scriptscriptstyle j}$ &\\cellcolor{white!20}\\scriptsize Randomness  of commitment\\\\ \n%\n%&\\cellcolor{gray!20}\\scriptsize$n$ &\\cellcolor{gray!20}\\scriptsize Number of file blocks\\\\ \n%&\\cellcolor{white!20}\\scriptsize$m$, $m_{\\scriptscriptstyle j}$ &\\cellcolor{white!20}\\scriptsize Plaintext messages\\\\   \n%  &\\cellcolor{gray!20}\\scriptsize$\\ddot{o}$ &\\cellcolor{gray!20}\\scriptsize Pair representation\\\\\n%&\\cellcolor{white!20}\\scriptsize$\\vv{\\bm{o}}$ &\\cellcolor{white!20}\\scriptsize Vector representation\\\\                  \n%&\\cellcolor{gray!20}\\scriptsize$\\ddot{p}:(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$ &\\cellcolor{gray!20}\\scriptsize Commitment opening\\\\ \n%                      \n%&\\cellcolor{white!20}\\scriptsize$\\mathtt{H}$ &\\cellcolor{white!20}\\scriptsize Hash function\\\\\n%\n%                      \n% \\hline\n% \n%  \\hline\n%  \n%  \n%    %CR-TLP\n%\\multirow{11}{*}{\\rotatebox[origin=c]{90}{\\scriptsize  \\textbf{C-TLP}}}\n%\n%&\\cellcolor{gray!20}\\scriptsize$\\lambda$&\\cellcolor{gray!20}\\cellcolor{gray!20}\\scriptsize TLP security parameter\\\\\n%\n%&\\cellcolor{white!20}\\scriptsize$\\Delta$&\\cellcolor{white!20}\\scriptsize Time win. message remains hidden\\\\ \n%       \n%&\\cellcolor{gray!20}\\scriptsize $S$&\\cellcolor{gray!20}\\scriptsize Max. squaring  done per sec.    \\\\ \n%    \n%&\\cellcolor{white!20}\\scriptsize $T$&\\cellcolor{white!20}\\scriptsize $T=S\\Delta$    \\\\\n%\n%&\\cellcolor{gray!20}\\scriptsize $s_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize $j\\text{-th}$ solution\\\\\n%\n%&\\cellcolor{white!20}\\scriptsize $\\ddot{o}_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize $j\\text{-th}$ puzzle, $\\ddot{o}_{\\scriptscriptstyle j}:(o_{\\scriptscriptstyle j,1},o_{\\scriptscriptstyle j,2})$\\\\\n%\n%&\\cellcolor{gray!20}\\scriptsize $f_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize Time  when  $j{\\text{-th}}$ solution is found\\\\\n%\n%&\\cellcolor{white!20}\\scriptsize $k, k_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize Sym. key encryption keys\\\\\n%\n%&\\cellcolor{gray!20}\\scriptsize $pk, sk$&\\cellcolor{gray!20}\\scriptsize Public and secret keys\\\\\n%\n%&\\cellcolor{white!20}\\scriptsize $q_{\\scriptscriptstyle 1}, q_{\\scriptscriptstyle 2}$&\\cellcolor{white!20}\\scriptsize Large prime numbers\\\\\n%\n%&\\cellcolor{gray!20}\\scriptsize $N$&\\cellcolor{gray!20}\\scriptsize RSA modulus, $N=q_{\\scriptscriptstyle 1} q_{\\scriptscriptstyle 2}$\\\\\n%\n%\\hline \n%\n%\n%  \\hline\n%  \n%  \n%%SO-PoR \n%  \\multirow{20}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{SO-PoR}}}\n%&\\cellcolor{gray!20}\\scriptsize$\\mathtt{PRF}$&\\cellcolor{gray!20}\\scriptsize Pseudorandom function\\\\  \n%                   \n%    &\\cellcolor{white!20}\\scriptsize$\\hat{k},v_{\\scriptscriptstyle j},l_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize $\\mathtt{PRF}$'s keys\\\\ \n%&\\cellcolor{gray!20}\\scriptsize$\\iota$&\\cellcolor{gray!20}\\scriptsize Security parameter, $\\iota=128$-bit\\\\ \n%&\\cellcolor{white!20}\\scriptsize$p$&\\cellcolor{white!20}\\scriptsize Large prime number, $|p|=\\iota$\\\\ \n%\n%&\\cellcolor{gray!20}\\scriptsize$w$&\\cellcolor{gray!20}\\scriptsize  Blockchain block index\\\\ \n%                    \n%&\\cellcolor{white!20}\\scriptsize$g$&\\cellcolor{white!20}\\scriptsize Blockchain security parameter: chain quality    \\\\    \n%      \n%  &\\cellcolor{gray!20}\\scriptsize$\\lambda'$&\\cellcolor{gray!20}\\scriptsize Blockchain generic security parameter\\\\  \n%&\\cellcolor{white!20}\\scriptsize${\\bm{F}}$&\\cellcolor{white!20}\\scriptsize Outsourced encoded file\\\\ \n%&\\cellcolor{gray!20}\\scriptsize$F_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize A file block\\\\ \n%&\\cellcolor{white!20}\\scriptsize$|{\\bm{F}}|$&\\cellcolor{white!20}\\scriptsize Number of file blocks, $|{\\bm{F}}|=n$\\\\ \n% &\\cellcolor{gray!20}\\scriptsize$||{\\bm{F}}||$&\\cellcolor{gray!20}\\scriptsize File bit-size\\\\     \n%% \\multirow{8}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{SO-PoR}}}\n%\n%&\\cellcolor{white!20}\\scriptsize$\\sigma_{\\scriptscriptstyle i}$&\\cellcolor{white!20}\\scriptsize Permanent tag   \\\\  \n% &\\cellcolor{gray!20}\\scriptsize$\\sigma_{\\scriptscriptstyle b,j}$&\\cellcolor{gray!20}\\scriptsize Disposable tag   \\\\    \n% \n%    &\\cellcolor{white!20}\\scriptsize$\\alpha, \\alpha_{\\scriptscriptstyle j}, r_{\\scriptscriptstyle i},r_{\\scriptscriptstyle b,j}$&\\cellcolor{white!20}\\scriptsize Pseudorandom values  \\\\ \n%                \n%&\\cellcolor{gray!20}\\scriptsize$c$&\\cellcolor{gray!20}\\scriptsize Number of challenges \\\\ \n%        \n%&\\cellcolor{white!20}\\scriptsize$\\mathcal {B}_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize Blockchain's $j{\\text{-th}}$ block\\\\ \n%\n%&\\cellcolor{gray!20}\\scriptsize$(\\mu_{\\scriptscriptstyle j},\\xi_{\\scriptscriptstyle j})$&\\cellcolor{gray!20}\\scriptsize $j{\\text{-th}}$ PoR proof\\\\ \n%&\\cellcolor{white!20}\\scriptsize$\\Delta_{\\scriptscriptstyle 1}$&\\cellcolor{white!20}\\scriptsize Time taken to generate  a PoR\\\\ \n%\n%&\\cellcolor{gray!20}\\scriptsize$\\Delta_{\\scriptscriptstyle 2}$&\\cellcolor{gray!20}\\cellcolor{gray!20}\\scriptsize Time taken a contract gets a message\\\\ \n%\n%&\\cellcolor{white!20}\\scriptsize$e$&\\cellcolor{white!20}\\scriptsize Coins paid for an accepting PoR\\\\ \n%\n%\\hline\n%\n%\n%        \n%\n%\n%\\end{tabular}\n%\n%\\end{center}\n%}\n%%\\end{footnotesize}\n%\\end{table}\n%\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\section{Notations}\\label{sec:notation-table}\n\nWe summarise our notations in Table \\ref{table:notation-table}.\n\\vspace{-6mm}\n\n\\begin{table*}[!htbp]\n\\begin{scriptsize}\n\\begin{center}\n\\footnotesize{\n\n\\caption{ \\small Notation Table.}\\label{commu-breakdown-party} \n\\renewcommand{\\arraystretch}{.84}\n\\scalebox{0.86}{\n% 1st table\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n\n\\hline \n\n\\cellcolor{gray!15}\\scriptsize \\textbf{Setting} &\\cellcolor{gray!15} \\scriptsize \\textbf{Symbol}&\\cellcolor{gray!15} \\scriptsize \\textbf{Description}  \\\\\n    \\hline\n    \n     \\hline\n\n%Generic\n\\multirow{9}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{Generic}}}\n\n &\\cellcolor{white!20}\\scriptsize$z$&\\cellcolor{white!20}\\scriptsize \\text{Number of puzzles or delegated verifications}\\\\   \n \n&\\cellcolor{gray!20}\\scriptsize$h$, $h_{\\scriptscriptstyle j}$ &\\cellcolor{gray!20}\\scriptsize Hash values  \\\\  \n\n&\\cellcolor{white!20}\\scriptsize$d$, $d_{\\scriptscriptstyle j}$ &\\cellcolor{white!20}\\scriptsize Randomness  of commitment\\\\ \n\n&\\cellcolor{gray!20}\\scriptsize$n$ &\\cellcolor{gray!20}\\scriptsize Number of file blocks\\\\ \n&\\cellcolor{white!20}\\scriptsize$m$, $m_{\\scriptscriptstyle j}$ &\\cellcolor{white!20}\\scriptsize Plaintext messages\\\\   \n  &\\cellcolor{gray!20}\\scriptsize$\\ddot{o}$ &\\cellcolor{gray!20}\\scriptsize Pair representation\\\\\n&\\cellcolor{white!20}\\scriptsize$\\vv{\\bm{o}}$ &\\cellcolor{white!20}\\scriptsize Vector representation\\\\                  \n&\\cellcolor{gray!20}\\scriptsize$\\ddot{p}:(m_{\\scriptscriptstyle j},d_{\\scriptscriptstyle j})$ &\\cellcolor{gray!20}\\scriptsize Commitment opening\\\\ \n                      \n&\\cellcolor{white!20}\\scriptsize$\\mathtt{H}$ &\\cellcolor{white!20}\\scriptsize Hash function\\\\\n\n                      \n \\hline\n \n  \\hline\n  \n  %CR-TLP\n  %CR-TLP\n\\multirow{11}{*}{\\rotatebox[origin=c]{90}{\\scriptsize  \\textbf{C-TLP}}}\n\n&\\cellcolor{gray!20}\\scriptsize$\\lambda$&\\cellcolor{gray!20}\\cellcolor{gray!20}\\scriptsize TLP security parameter\\\\\n\n&\\cellcolor{white!20}\\scriptsize$\\Delta$&\\cellcolor{white!20}\\scriptsize Time win. message remains hidden\\\\ \n       \n&\\cellcolor{gray!20}\\scriptsize $S$&\\cellcolor{gray!20}\\scriptsize Max. squaring  done per sec.    \\\\ \n    \n&\\cellcolor{white!20}\\scriptsize $T$&\\cellcolor{white!20}\\scriptsize $T=S\\Delta$    \\\\\n\n&\\cellcolor{gray!20}\\scriptsize $s_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize $j\\text{-th}$ solution\\\\\n\n&\\cellcolor{white!20}\\scriptsize $\\ddot{o}_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize $j\\text{-th}$ puzzle, $\\ddot{o}_{\\scriptscriptstyle j}:(o_{\\scriptscriptstyle j,1},o_{\\scriptscriptstyle j,2})$\\\\\n\n&\\cellcolor{gray!20}\\scriptsize $f_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize Time  when  $j{\\text{-th}}$ solution is found\\\\\n\n&\\cellcolor{white!20}\\scriptsize $k, k_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize Sym. key encryption keys\\\\\n\n&\\cellcolor{gray!20}\\scriptsize $pk, sk$&\\cellcolor{gray!20}\\scriptsize Public and secret keys\\\\\n\n&\\cellcolor{white!20}\\scriptsize $q_{\\scriptscriptstyle 1}, q_{\\scriptscriptstyle 2}$&\\cellcolor{white!20}\\scriptsize Large prime numbers\\\\\n\n&\\cellcolor{gray!20}\\scriptsize $N$&\\cellcolor{gray!20}\\scriptsize RSA modulus, $N=q_{\\scriptscriptstyle 1} q_{\\scriptscriptstyle 2}$\\\\\n\n\\hline \n\n   \n\n\\end{tabular}\n\n% 2nd table\n\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n    \\hline\n\\cellcolor{gray!15}\\scriptsize \\textbf{Setting} &\\cellcolor{gray!15} \\scriptsize \\textbf{Symbol}&\\cellcolor{gray!15} \\scriptsize \\textbf{Description}  \\\\\n    \\hline\n    \n\\hline\n\n\n\n\\hline\n\n\n%SO-PoR right\n \\multirow{20}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{SO-PoR}}}\n&\\cellcolor{gray!20}\\scriptsize$\\mathtt{PRF}$&\\cellcolor{gray!20}\\scriptsize Pseudorandom function\\\\  \n                   \n    &\\cellcolor{white!20}\\scriptsize$\\hat{k},v_{\\scriptscriptstyle j},l_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize $\\mathtt{PRF}$'s keys\\\\ \n&\\cellcolor{gray!20}\\scriptsize$\\iota$&\\cellcolor{gray!20}\\scriptsize Security parameter, $\\iota=128$-bit\\\\ \n&\\cellcolor{white!20}\\scriptsize$p$&\\cellcolor{white!20}\\scriptsize Large prime number, $|p|=\\iota$\\\\ \n\n&\\cellcolor{gray!20}\\scriptsize$w$&\\cellcolor{gray!20}\\scriptsize  Blockchain block index\\\\ \n                    \n&\\cellcolor{white!20}\\scriptsize$g$&\\cellcolor{white!20}\\scriptsize Blockchain security parameter: chain quality    \\\\    \n      \n  &\\cellcolor{gray!20}\\scriptsize$\\lambda'$&\\cellcolor{gray!20}\\scriptsize Blockchain generic security parameter\\\\  \n&\\cellcolor{white!20}\\scriptsize${\\bm{F}}$&\\cellcolor{white!20}\\scriptsize Outsourced encoded file\\\\ \n&\\cellcolor{gray!20}\\scriptsize$F_{\\scriptscriptstyle j}$&\\cellcolor{gray!20}\\scriptsize A file block\\\\ \n&\\cellcolor{white!20}\\scriptsize$|{\\bm{F}}|$&\\cellcolor{white!20}\\scriptsize Number of file blocks, $|{\\bm{F}}|=n$\\\\ \n &\\cellcolor{gray!20}\\scriptsize$||{\\bm{F}}||$&\\cellcolor{gray!20}\\scriptsize File bit-size\\\\     \n% \\multirow{8}{*}{\\rotatebox[origin=c]{90}{\\scriptsize \\textbf{SO-PoR}}}\n\n&\\cellcolor{white!20}\\scriptsize$\\sigma_{\\scriptscriptstyle i}$&\\cellcolor{white!20}\\scriptsize Permanent tag   \\\\  \n &\\cellcolor{gray!20}\\scriptsize$\\sigma_{\\scriptscriptstyle b,j}$&\\cellcolor{gray!20}\\scriptsize Disposable tag   \\\\    \n \n    &\\cellcolor{white!20}\\scriptsize$\\alpha, \\alpha_{\\scriptscriptstyle j}, r_{\\scriptscriptstyle i},r_{\\scriptscriptstyle b,j}$&\\cellcolor{white!20}\\scriptsize Pseudorandom values  \\\\ \n                \n&\\cellcolor{gray!20}\\scriptsize$c$&\\cellcolor{gray!20}\\scriptsize Number of challenges \\\\ \n        \n&\\cellcolor{white!20}\\scriptsize$\\mathcal {B}_{\\scriptscriptstyle j}$&\\cellcolor{white!20}\\scriptsize Blockchain's $j{\\text{-th}}$ block\\\\ \n\n&\\cellcolor{gray!20}\\scriptsize$(\\mu_{\\scriptscriptstyle j},\\xi_{\\scriptscriptstyle j})$&\\cellcolor{gray!20}\\scriptsize $j{\\text{-th}}$ PoR proof\\\\ \n&\\cellcolor{white!20}\\scriptsize$\\Delta_{\\scriptscriptstyle 1}$&\\cellcolor{white!20}\\scriptsize Time taken to generate  a PoR\\\\ \n\n&\\cellcolor{gray!20}\\scriptsize$\\Delta_{\\scriptscriptstyle 2}$&\\cellcolor{gray!20}\\cellcolor{gray!20}\\scriptsize Time taken a contract gets a message\\\\ \n\n&\\cellcolor{white!20}\\scriptsize$e$&\\cellcolor{white!20}\\scriptsize Coins paid for an accepting PoR\\\\ \n\n\\hline\n   \n\n           \n           \n           \n\\end{tabular}\\label{table:notation-table}\n\n}}\n\\end{center}\n\\end{scriptsize}\n\\end{table*}\n\n\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "154dc345d667a6a066ef93ba7707f26dc75a3530", "size": 12683, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/FC/notation-Table.tex", "max_stars_repo_name": "AydinAbadi/CR-LP", "max_stars_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/FC/notation-Table.tex", "max_issues_repo_name": "AydinAbadi/CR-LP", "max_issues_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/FC/notation-Table.tex", "max_forks_repo_name": "AydinAbadi/CR-LP", "max_forks_repo_head_hexsha": "b2139df715f441a48eeae0b88e038fb6acc5d6e2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5836065574, "max_line_length": 213, "alphanum_fraction": 0.691713317, "num_tokens": 4315, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40586740557261897}}
{"text": "% !TEX options=--shell-escape\n\\documentclass[french]{article}\n\\usepackage{common}\n\n\\usepackage{minted}\n\\usepackage{minted,xcolor} % [cache=false] if minted acts out\n\n\\setminted[python]{style=colorful}\n\\author{Gabriel Belouze}\n\n\\title{Kernel methods in machine learning : Homework 3}\n\\date{2021-2022}\n\n\\begin{document}\n\\maketitle\n\nIn case embedded links are not clickable on \\textit{Gradescope}, all links from this document reference specific code section of the repository \\href{https://github.com/gbelouze/mva-kernel-hw3}{https://github.com/gbelouze/mva-kernel-hw3}.\n\n\\section{Exercice 1. Support Vector Classifier}\n\n\\begin{enumerate}\n\\item\n    \\begin{enumerate}\n    \\item From the Representer theorem we can express $f = \\sum_i \\beta_i K_{x_i}$. We also write for convenience $Y = \\diag(y)$. Then the Lagrangian writes\n    \\[ \\frac{1}{2} \\beta^T K \\beta + C \\cdot \\xi^T\\mathbf{1} - \\mu^T \\xi\n    + \\alpha^T (\\mathbf{1} - \\xi - b\\cdot y - Y K \\beta)\n    \\]\n    \\item\n    The Lagrangian is affine in $b$, which yields the condition $\\alpha^Ty = 0$ for the dual function not to be $-\\infty$.\\\\\n    The Lagrangian is affine in $\\xi$, which yields the condition $\\forall i, \\; C = \\mu_i + \\alpha_i$ for the dual function not to be $-\\infty$.\\\\\n    The Lagrangian is convex, coercive in $\\beta$, such that it reaches its infinimum at a point where the gradient $\\nabla_\\beta L = K \\beta - K Y \\alpha$ vanishes. This happens for $\\hat{\\beta} \\defeq Y \\alpha$. More generally, this happens for all $\\hat{\\beta} + \\varepsilon$ where $\\varepsilon$ is in the null space of $K$. It turns out that the value of $L$ does not change when adding such $\\varepsilon$ (indeed all occurrences of $\\beta$ are applied to $K$), and it is enough to look at $\\hat{\\beta}$ to compute the dual function.\\\\\n    Finally, we obtain the dual function\n    \\[ l(\\alpha, \\mu) = \\begin{cases}\n    -\\frac{1}{2} \\alpha^T Y K Y \\alpha + \\alpha^T \\mathbf{1} \\quad \\textrm{si $\\mu_i+\\alpha_i=C$, $\\alpha^Ty=0$} \\\\\n    -\\infty \\quad \\textrm{sinon}\n    \\end{cases}\n    \\]\n    The variable $\\mu$ is redundant and we can express the dual problem in terms of the sole variable $\\alpha$ (and as a minimization so long that we change the signs) :\n    \\begin{equation*}\n    \\begin{aligned}\n    & \\underset{\\alpha}{\\text{minimize}}\n    & &  \\frac{1}{2} \\alpha^T Y K Y \\alpha - \\alpha^T \\mathbf{1}\\\\\n    & \\text{subject to}\n    & & \\alpha^Ty = 0 \\\\\n    & & & 0 \\preceq \\alpha \\preceq C\n    \\end{aligned}\n    \\end{equation*}\n    At optimal points, $\\beta^*$ minimizes the Lagrangian, and as we saw earlier, we can choose without loss of generality $\\beta^*_i \\defeq y_i \\alpha^*_i$. Then for a new input $x$, we have\n    \\[ f(x) = \\sum_i y_i \\alpha^*_i \\K(x_i, x)\n    \\]\n    Note that this is $KY\\alpha$ for the (joint) original inputs.\n    \\item In the following, we look at optimal points but omit the star notations. Complementary slackness conditions state that for all $i$,\n    \\begin{align}\n    - \\mu_i \\xi_i = 0 \\quad \\textrm{i.e.} \\quad (C - \\alpha_i) \\xi_i &= 0 \\label{eq1}\\\\\n    (1  - y_i(b - f(x_i)) - \\xi_i) \\alpha_i &= 0 \\label{eq2}\n    \\end{align}\n    Three situations arise :\\\\\n    \\textbf{If $0 < \\alpha_i < C$ --} From \\ref{eq1} we get $\\xi_i=0$ which in turn yields from \\ref{eq2} $y_i(b - f(x_i)) = 1$, i.e. \\textit{point $i$ is on the margin}.\\\\\n    \\textbf{If $\\alpha_i = 0$ --} We can only ensure that $y_i(b - f(x_i)) \\geq 1$.\\\\\n    \\textbf{If $\\alpha_i = C$ --} We can only ensure that $y_i(b - f(x_i)) \\leq 1$.\n    \\end{enumerate}\n\\item\n    \\begin{enumerate}\n    \\item See the full code \\href{https://github.com/gbelouze/mva-kernel-hw3/blob/main/src/hw3/models/kernel.py}{on Github}\n    \\inputminted{python}{snippets/ex1_q2a.py}\n    \\item See the full code \\href{https://github.com/gbelouze/mva-kernel-hw3/blob/b57749258006dcfc57c9f2e233fad94ef4b50f47/src/hw3/models/classify.py#L55}{on Github}\n    \\inputminted{python}{snippets/ex1_q2b.py}\n    \\item See the full code \\href{https://github.com/gbelouze/mva-kernel-hw3/blob/b57749258006dcfc57c9f2e233fad94ef4b50f47/src/hw3/models/classify.py#L108}{on Github}\n    \\inputminted{python}{snippets/ex1_q2c.py}\n    \\item We test our implementation on the three provided datasets. The number of support vectors is\n    $2$ for dataset 1, $25$ for dataset $2$ and $43$ for dataset $3$. See \\autoref{fig:classifier}.\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figures/classifier.png}\n        \\caption{Kernel Support Vector Classifier}\n        \\label{fig:classifier}\n    \\end{figure}\n    \\end{enumerate}\n\\end{enumerate}\n\n\\section{Exercise 2. Kernel Support Vector Regression}\n\n\\begin{enumerate}\n\\item\n    \\begin{enumerate}\n    \\item From the Representer theorem we can express $f = \\sum_i \\beta_i K_{x_i}$. Then the Lagrangian writes\n    \\begin{align*}\n    &\\frac{1}{2} \\beta^T K \\beta + C \\cdot \\sum_{i=1}^N \\xi^+_i + \\xi^-_i \\\\\n    +& \\alpha^{+T} \\big ( y - K\\beta - b \\mathbf{1} - \\eta \\mathbf{1} - \\xi^+ \\big ) \\\\\n    +& \\alpha^{-T} \\big ( -y + K\\beta + b\\mathbf{1} - \\eta \\mathbf{1} - \\xi^- \\big ) \\\\\n    -& \\mu^{+T} \\xi^+ - \\mu^{-T} \\xi^-\n    \\end{align*}\n    \\item\n    The Lagrangian is affine in $b$, which yields the condition $\\sum_i \\alpha^+_i = \\sum_i \\alpha^-_i $ for the dual function not to be $-\\infty$.\\\\\n    The Lagrangian is affine in $\\xi^+$, which yields the condition $\\forall i$, $ \\alpha^+_i + \\mu_i^+= C $ for the dual function not to be $-\\infty$.\\\\\n    The Lagrangian is affine in $\\xi^-$, which yields the condition $\\forall i$, $ \\alpha^-_i + \\mu_i^-= C $ for the dual function not to be $-\\infty$.\\\\\n    The Lagrangian is convex, coercive in $\\beta$. As in exercise $1$, we can restrict ourselves to a single point that nullifies the gradient $\\nabla_\\beta L = K\\beta - K (\\alpha^+ - \\alpha^-)$, such as $\\hat{\\beta} \\defeq \\alpha^+ - \\alpha^-$.\\\\\n    Finally, we get the Lagrange dual function\n    \\[ \\begin{cases}\n        - \\frac{1}{2}(\\alpha^+ - \\alpha^-)^T K (\\alpha^+ - \\alpha^-) + y^T (\\alpha^+ - \\alpha^-) - \\eta \\sum_i \\alpha_i^+ + \\alpha_i^- \\\\ \\qquad \\qquad \\textrm{si $\\sum_i \\alpha^+_i = \\sum_i \\alpha^-_i $, $ \\alpha^\\pm_i + \\mu_i^\\pm= C $} \\\\\n        - \\infty \\, \\qquad \\textrm{sinon}\n    \\end{cases} \\]\n    Again, the variables $\\mu^\\pm$ are redundant and we can express the dual problem in the sole variables $\\alpha^\\pm$, and by changing the signs as a minimization :\n    \\begin{equation*}\n    \\begin{aligned}\n    & \\underset{\\alpha^+, \\alpha^-}{\\text{minimize}}\n    & &  \\frac{1}{2}(\\alpha^+ - \\alpha^-)^T K (\\alpha^+ - \\alpha^-) - y^T (\\alpha^+ - \\alpha^-) + \\eta \\sum_i \\alpha_i^+ + \\alpha_i^-\\\\\n    & \\text{subject to}\n    & & \\sum_i \\alpha_i^+ = \\sum_i \\alpha_i^- \\\\\n    & & & 0 \\preceq \\alpha^+ \\preceq C\\\\\n    & & & 0 \\preceq \\alpha^- \\preceq C\n    \\end{aligned}\n    \\end{equation*}\n    At optimal points, $\\beta^*$ minimizes the Lagrangian, and as we saw earlier, we can choose without loss of generality $\\beta^*_i \\defeq \\alpha^+_i - \\alpha^-_i$. Then for a new input $x$, we have\n    \\[ f(x) = \\sum_i (\\alpha^+_i - \\alpha^-_i) \\K(x_i, x)\n    \\]\n    Note that this is $K(\\alpha^+ - \\alpha^-)$ for the (joint) original inputs.\n    \\item The reasoning is similar as in exercise 1. Skipping the computations (which are not different from earlier), we have from complementary slackness conditions:\\\\\n    \\textbf{If $0 < \\alpha^+_i < C$} then $y_i - f(x_i) - b = \\eta$, i.e. $x_i$ is on the boundary\\\\\n    \\textbf{If $0 < \\alpha^-_i < C$} then $-y_i + f(x_i) + b = \\eta$, i.e. $x_i$ is on the boundary as well.\\\\\n    Otherwise we cannot know for sure.\n    \\end{enumerate}\n\\item\n    \\begin{enumerate}\n    \\item See the full code \\href{https://github.com/gbelouze/mva-kernel-hw3/blob/b57749258006dcfc57c9f2e233fad94ef4b50f47/src/hw3/models/classify.py#L137}{on Github}\n    \\inputminted{python}{snippets/ex2_q2a.py}\n    \\item See the full code \\href{https://github.com/gbelouze/mva-kernel-hw3/blob/b57749258006dcfc57c9f2e233fad94ef4b50f47/src/hw3/models/classify.py#L209}{on Github}\n    \\inputminted{python}{snippets/ex2_q2b.py}\n    \\item We test our implementation on the provided dataset. The number of support vectors is\n    $42$ (of course...). See \\autoref{fig:regressor}.\n    \\begin{figure}\n        \\centering\n        \\includegraphics[width=\\textwidth]{figures/regressor.png}\n        \\caption{Kernel Support Vector Regressor}\n        \\label{fig:regressor}\n    \\end{figure}\n    \\end{enumerate}\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "9d6ee84ee3081674007e90144c1bca4d30d1fe19", "size": 8433, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/report.tex", "max_stars_repo_name": "gbelouze/mva-kernel-hw3", "max_stars_repo_head_hexsha": "4952971366bcd6fea4f9096d5f3553a9f7456586", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/report.tex", "max_issues_repo_name": "gbelouze/mva-kernel-hw3", "max_issues_repo_head_hexsha": "4952971366bcd6fea4f9096d5f3553a9f7456586", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/report.tex", "max_forks_repo_name": "gbelouze/mva-kernel-hw3", "max_forks_repo_head_hexsha": "4952971366bcd6fea4f9096d5f3553a9f7456586", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.8085106383, "max_line_length": 539, "alphanum_fraction": 0.6518439464, "num_tokens": 2870, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.40586739516667386}}
{"text": "%\\setcounter{page}{500}\n\\chapter{The Derivative\\label{DerivativeChapter}}\n\nThe earlier chapters are preludes to the calculus.\nWith this chapter we begin to study calculus proper.\nWe begin with  {\\it differential calculus},\nwhich is taken to mean the calculus of derivatives.\nIn later chapters, and once we have some handle \non derivatives, we then\nlook towards {\\it integral calculus} where, roughly\nspeaking, we see how to reverse what we do here.\\footnotemark\n\\footnotetext{This is a nontrivial  task, as we will see\nin later chapters.}  In short  differential\ncalculus addresses rates at which quantities change, while integral\ncalculus addresses how quantities (or the changes in quantities) accumulate.\nOnce we lay the foundations of differential and integral\ncalculus, we will  further develop and apply\nboth in very diverse circumstances for the remainder of the text.\n\n\n\\section[Derivative, Rate of Change, and Slope]%\n{The Derivative, Rates of Change and Slope\n\\label{DerivativeSection1}}\n\nSuppose that we are passengers in a car driving West to East\nalong a highway.  Further suppose that we cannot see the\nspeedometer (measuring speed)  but the highway is marked\nat regular distance intervals so we can measure our\nposition accurately.\\footnotemark\\hphantom{. }\\footnotetext{\nAlternatively, we have a very accurate odometer or global positioning device \nin plain view.}\n  Using a stopwatch,\nwe see that we traveled a total of 130 miles in 2 hours\nfor the whole trip.  \nThen we would say our average velocity (with positive\nmeasured in the Eastward direction) was \n$$\\frac{130\\ \\text{mi}}{2\\ \\text{hr}}=65\\ {\\text{mi}}/{\\text{hr}}.$$\n%\nNow suppose that during the trip we would like to know our\nactual  velocity\nat a particular time $t_1$.  The average\nfor the whole trip does not usually reflect the velocity at\nany particular time $t_1$ with acceptable\naccuracy, since we could have been stopped\nfor a break at that particular time, or speeding up to \npass a truck,  or even driving in reverse \n(for  a negative velocity).  One way to attempt to \napproximate the velocity at time $t_1$ is to begin\nour stopwatch at $t_1$, see how far we traveled\nin the next minute, and calculate the average\n velocity for the\ntime interval  $t\\in[t_1,t_1+1\\ \\text{minute}]$.\n\nAt this point some notation will be useful.  We will\ntake the position function to be $s(t)$.\nWe will denote a change in $t$ by $\\Delta t$, read\n``delta $t$.''\\footnotemark\\hphantom{. }\\footnotetext{Note that we\ntake $\\Delta t$ as one quantity.  It is {\\it not} \n``$\\Delta$ times $t$.''  One can read $\\Delta t$ to\nbe synonymous with the {\\it change} in $t$.  Occasionally\nwe will write $\\Delta t=(\\Delta t)$ to remove ambiguity\nand reinforce that it is one quantity. (Here $\\Delta$\nis the capital Greek letter delta.)}\nWith $t_1$ as the initial time in our experiment to approximate\nvelocity, and  $t_2=t_1+\\Delta t$ as the final\ntime, we see the change is indeed $t_2-t_1=\\Delta t$.  \nThe average velocity over any $[t_1,t_2]$\nis thus\n$$\\frac{s(t_2)-s(t_1)}{t_2-t_1}\n=\\frac{s(t_1+\\Delta t)-s(t_1)}{\\Delta t}.$$\n%\nIf we take $\\Delta s=s(t_1+\\Delta t)-s(t_1)$ to be\nthe change in $s$ which results from the change in\n$t$ from $t_1$ to $t_1+\\Delta t=t_2$, then we have\nthe average velocity also equal to\n$(\\Delta s)/(\\Delta t)$, i.e., \n$$\\frac{s(t_2)-s(t_1)}{t_2-t_1}\n=\\frac{s(t_1+\\Delta t)-s(t_1)}{\\Delta t}=\n\\frac{\\Delta s}{\\Delta t}.$$\nThis is akin to  the old-fashioned ``rate equals distance \ndivided by time'' that is taught in grade school.\\footnotemark \n%\n\\footnotetext{ \nThe grade school formula is lacking in that it\nalways assumes velocity is constant, and does not \ndistinguish between ``distance'' and ``displacement,''\nor ``distance'' and ``position.'' (Distance only\ncarries a nonnegative sign.) It is only mentioned\nhere because of its familiarity.}  \n%\nWith this we can get back to the problem of attempting\nto find the velocity at time $t_1$.  \nIf we let $\\Delta t$ equal one minute, then we look\nto see how far we traveled in that one minute,\nand find the average velocity for that minute.  {\\it If \nthe velocity did not change very much in that time\ninterval, then the average velocity will closely \napproximate the actual velocity}, which we will \ndenote $v(t_1)$ (what we would have read on the\nspeedometer---except for a possible sign difference---were it available): \n$$\\frac{\\Delta s}{\\Delta t}=\\frac{s(t_1+1\\ \\text{minute})-s(t_1)}\n{1\\ \\text{minute}}\\approx v(t_1).$$\nOn the other hand, many things can happen in a minute\nwhich can cause the velocity to change significantly.\nPerhaps we have a true velocity of 65  miles/hour at $t_1$,\nbut then slow to a stop at a \ntoll booth during that minute, and thus unacceptably underestimate\n$v(t_1)$ as approximated by the average velocity for $[t_1,t_2]$. \nIf possible, it would likely be\nmuch better to measure how far we traveled in the first\n{\\it second} after $t_1$, since most cars cannot change velocity\nsignificantly in such a time interval except in catastrophic\ncircumstances (e.g., collisions).  Thus\\footnotemark\n\\footnotetext{Of course we need to convert units to be \nconsistent, eg., 1 second = (1/3600) hour), and so on.}\n$$v(t_1)\\approx \\frac{s(t_1+1\\ \\text{second})-s(t_1)}{1\\ \\text{second}}.$$\nFollowing the same line of thinking,\nit  seems reasonable that we can better approximate\nthe actual value of $v(t_1)$ by taking the average velocity\nover an interval $[t_1,t_1+\\Delta t]$ with smaller and smaller\nvalues of $\\Delta t$ (such as one minute, one second, 0.001 seconds,\netc.).  For this reason we actually {\\it define} the velocity\nat time $t_1$ by\n$$v(t_1)=\\lim_{\\Delta t\\to0}\\frac{s(t_1+\\Delta t)-s(t_1)}{\\Delta t}\n=\\lim_{\\Delta t\\to 0}\\frac{\\Delta s}{\\Delta t}.$$\nRecall that we have to consider $\\Delta t\\to0^-$ as well as\n$\\Delta t\\to0^+$ in this calculation.  This is not unreasonable, \nas we could also approximate $v(t_1)$ by considering how far we\nwent in the minute, second, 0.001 second, etc., ending with $t_1$.\nNow we will state the velocity in a formal definition.\n%\n\\begin{definition}Given a position function $s(t)$, define\nthe {\\bf velocity} at a time $t$ to be the function given by\nthe limit\n\\begin{equation}\nv(t)=\\lim_{\\Delta t\\to0}\\frac{\\Delta s}{\\Delta t}=\n\\lim_{\\Delta t\\to0}\\frac{s(t+\\Delta t)-s(t)}{\\Delta t},\n\\label{VelocityDefinition}\\end{equation}\nfor each $t$ for which the limit {\\rm(\\ref{VelocityDefinition})}\nexists, and where we also define  \n\\begin{equation}\\Delta s=s(t+\\Delta t)-s(t).\\end{equation}\n\\end{definition}\n%\nFor now it is the second part of (\\ref{VelocityDefinition})\nthat will be most useful.  If we are lucky enough to \nknow an algebraic formula for $s(t)$ as a function,\nthen we can use the limit to calculate $v(t)$.\n%\n\\bex Suppose that position is given by\n$s(t)=t^2+1$.  We can use (\\ref{VelocityDefinition})\nto calculate the velocity function for any {\\it fixed\\,\\footnotemark}\n $t$:\n\\footnotetext{So we treat $t$ as a constant in the calculation\nof $v(t)$.  It is $\\Delta t$ which is approaching zero, while\n$t$ remains fixed.}\n\\begin{align*}\nv(t)&=\\lim_{\\Delta t\\to0}\\frac{s(t+\\Delta t)-s(t)}{\\Delta t}\\\\\n&= \\lim_{\\Delta t\\to0}\\frac{\\left((t+\\Delta t)^2+1\\right)\n    -\\left(t^2+1\\right)}{\\Delta t}\\\\\n&=\\lim_{\\Delta t\\to0}\\frac{(t^2+2t\\Delta t+(\\Delta t)^2+1)\n-(t^2+1)}{\\Delta t}\\\\\n&=\\lim_{\\Delta t\\to0}\\frac{t^2+2t\\Delta t+(\\Delta t)^2\n+1-t^2-1}{\\Delta t}\\\\\n&=\\lim_{\\Delta t\\to0}\\frac{2t\\Delta t+(\\Delta t)^2}{\\Delta t}\\\\\n&=\\lim_{\\Delta t\\to0}\\left(2t+\\Delta t\\right)\\\\\n&=2t.\\end{align*}\nWe showed that $v(t)=2t$.\nThus, at time $t=5$ we have the position $s(5)=5^2+1=26$, and \nvelocity $v(5)=2(5)=10$.  Note that if $s$ is measured in \nmeters, and $t$ in seconds, then the units in the limit\n(\\ref{VelocityDefinition})\nare meters/second, as we would hope.  (For $t=5$ seconds we would\nhave $s=26\\ \\text{meters}$, and $v=10\\ \\text{meters/second}$.)\n\\label{VelocityExample1}\\eex\n\nThe ability to find a nonconstant velocity function is a tremendous\nleap from the grade school notion of ``rate~=~distance/time.'' \nHaving limits at our disposal made it possible.\n\nExample~\\ref{VelocityExample1} \nis an example of what physicists call  {\\it one-dimensional}\nmotion. It is worth illustrating the motion graphically.\nIn Figure~\\ref{OneDMotionOnAxis}, page~\\pageref{OneDMotionOnAxis}\nwe  show the position at various\ntimes on a (one-dimensional)\n number line.  Note that the velocity is changing\nthroughout the motion, so for instance the velocity at\ntime $t=1$ is $+2$, but the particle moves 3 units right\nin the next second.  That is because its velocity was\nincreasing even within that second.\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(0,-1)(11.5,3)\n\\psline{<->}(0.5,1)(11.5,1)\n\\rput(11.4,1.3){$s(t)$}\n\\psline(1,.8)(1,1.2)\n\\rput(1,.5){1}\n\\psline(2,.8)(2,1.2)\n  \\rput(2,.5){2}\n\\psline(3,.8)(3,1.2)\n  \\rput(3,.5){3}\n\\psline(4,.8)(4,1.2)\n  \\rput(4,.5){4}\n\\psline(5,.8)(5,1.2)\n  \\rput(5,.5){5} \n\\psline(6,.8)(6,1.2)\n  \\rput(6,.5){6}\n\\psline(7,.8)(7,1.2)\n  \\rput(7,.5){7}\n\\psline(8,.8)(8,1.2)\n  \\rput(8,.5){8}\n\\psline(9,.8)(9,1.2)\n  \\rput(9,.5){9}\n\\psline(10,.8)(10,1.2)\n  \\rput(10,.5){10}\n\\psline(11,.8)(11,1.2)\n  \\rput(11,.5){11}\n\n\\pscircle[fillstyle=solid,fillcolor=black](1,1){.1}\n\\rput(0.15,2.5){$t=0$}\n\\rput(0.15,2){$v=0$}\n\\psline{->}(0.2,1.8)(.9,1.1)\n\n\\pscircle[fillstyle=solid,fillcolor=black](2,1){.1}\n\\rput(2,2){$t=-1$}\n\\rput(2,1.5){$v=-2$}\n\\rput(2,0){$t=1$}\n\\rput(2,-.5){$v=2$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](5,1){.1}\n\\rput(5,2){$t=-2$}\n\\rput(5,1.5){$v=-4$}\n\\rput(5,0){$t=2$}\n\\rput(5,-.5){$t=4$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](10,1){.1}\n\\rput(10,2){$t=-3$}\n\\rput(10,1.5){$v=-6$}\n\\rput(10,0){$t=3$}\n\\rput(10,-.5){$v=6$}\n\n\n\n\n\\end{pspicture}\n\\end{center}\n\n\\caption{Here we trace the one-dimensional motion $s(t)=t^2+1$\nas a position on a  number line for times\n$t=-3,-2,-1,0,1,2,3$.  The velocities $v=2t$ are\nalso given.\nThe graph reflects how the particle comes\nin from the right for negative $t$, stops at $t=0$ ($s=1$, $v=0$), and moves\nback out towards the right for positive $t$. }\n\\label{OneDMotionOnAxis}\\end{figure}\n\n\nSuch limits are useful in more than just position/velocity problems;\nwe will have use for them throughout the text.\nBecause they are ubiquitous we generalize the notation\nand call the functions which arise from these limits\n{\\it derivatives}.  \n%\n\\begin{definition}Given any quantity $Q$ which is a \nfunction of the variable $x$, i.e., $Q=Q(x)$,\ndefine the {\\bf derivative} of $Q$ {\\bf with respect\nto} $x$ by the function $Q'(x)$, read\n{\\bf ``$Q$-prime of $x$''}, defined by\n\\begin{equation}\nQ'(x)=\\lim_{\\Delta x\\to0}\\frac{Q(x+\\Delta x)-Q(x)}{\\Delta x}\n\\label{DifferenceQuotientDerivativeDefinition}\\end{equation}\nwherever that limit exists and is finite.\n\nIf this limit does not exist or is infinite at a given $x_0$,\nwe say $Q'(x_0)$ {\\bf does not exist}.  If the limit does\nexist as a finite number at $x=x_0$, we say $Q(x)$ is\n{\\bf differentiable} at $x_0$.\n\\end{definition}\n\nSo we require not only that the limit exists, but\nthat it is finite (i.e., exists as a real number).\nWe will make more use of the term {\\it differentiable} \nin later sections where its justification is clearer.\n\nWe also define the average rate of change over an interval\nas before.  If the initial value of $x$ is $x_0$\n(pronounced ``$x$-naught'' or ``$x$ sub zero''),\nand the final value is $x_f$, then the {\\it average rate of change\nof $Q(x)$ with respect to $x$} for \n$x\\in[x_0,x_f]$ or $x\\in[x_f,x_0]$ (depending upon\nwhether $x_0<x_f$ or $x_0>x_f$) is given by\n\\begin{equation}\n\\frac{Q(x_f)-Q(x_0)}{x_f-x_0}\n=\\frac{Q(x_0+\\Delta x)-Q(x_0)}{\\Delta x}\n=\\frac{\\Delta Q}{\\Delta x}\n\\label{DifferenceQuotient}\\end{equation}\nwhere \n\\begin{align}\n\\Delta x&=x_f-x_0,\\\\\n\\Delta Q&=Q(x_f)-Q(x_0)=Q(x_0+\\Delta x)-Q(x_0).\\end{align}\nSo we see that the derivative \n(\\ref{DifferenceQuotientDerivativeDefinition}) is just the limit\nof the average rate of change in $Q$ (\\ref{DifferenceQuotient})\non an interval with \nendpoints $x$ and $x+\\Delta x$, assuming that limit is finite.\nRatios of the form (\\ref{DifferenceQuotient}) are commonly\ncalled {\\it difference quotients}.\n\n\nWith this notation, we can rewrite the velocity\nfunction for a given $s(t)$ as:\n\\begin{equation}\nv(t)=s'(t).\\end{equation}\nBecause there are so many contexts, there are\nmany different notations.  They each have their\nplaces and are worth knowing.\\footnotemark\\hphantom{. }\n\\footnotetext{In a later section\nwe will introduce the very powerful Leibniz notation for the\nderivative $Q'(x)$, which we will then write\n$\\ds{dQ}/{dx}$ (notice the resemblance\nto $\\Delta Q/\\Delta x$).}\n\n\\bex\nSuppose that instead of a stopwatch and odometer we have\na very accurate fuel gage and odometer.  \nLet $V(s)$ be the volume of fuel in the tank at a \nparticular position $s$.  Then\n$$V'(s)=\n\\lim_{\\Delta s\\to0}\\frac{\\Delta V}{\\Delta s}=\n\\lim_{\\Delta s\\to0}\\frac{V(s+\\Delta s)-V(s)}{\\Delta s}$$\nrepresents the instantaneous rate of fuel consumption per unit \ndistance.  If $s$ is in miles and $V$ in gallons, this\nwould be the rate of gallons per mile consumed at that\nparticular position.  (If we prefer miles/gallon, we\ncan take the reciprocal.)  So the derivative can also \nrepresent flow of a fluid.  Notice that the fuel should \nbe leaving the tank whenever the engine is running, \nso $V$ should be decreasing as we drive.\nThis gives  $\\Delta V<0$ when $\\Delta s>0$,\ngiving $\\Delta V/\\Delta s<0$,  and thus $V'(s)<0$.\nHowever the fuel running through the engine is\nexactly the fuel leaving the tank, and so the \nactual flow rate we would report would be $-V'(s)$\n(to give a positive quantity) for any particular\nposition $s$.\n\\eex\n\nThere are countless other applications of the derivative.\nAll we need is a quantity $Q$ as a function of another quantity\n $x$, to\nmeasure the rate that $Q$ changes as $x$ changes.\nThe average rate of change of $Q$ with respect to $x$\nis again $(\\Delta Q)/(\\Delta x)$, and the instantaneous\nrate is the number we get when we let $\\Delta x\\to0$,\ngiving the rate ``at that instant.''\n\\begin{definition}\nFor a quantity $Q$ which is a function of another quantity $x$,\n\\begin{enumerate}\n\\item The {\\bf average} rate of change of $Q$ with respect\nto $x$ on the interval with endpoints $x$ and $x+\\Delta x$\n(where $\\Delta x\\ne0$)\nis given by\n\\begin{equation}\\frac{\\Delta Q}{\\Delta x}=\\frac{Q(x+\\Delta x)-Q(x)}{\\Delta x}.\n\\end{equation}\nAlternatively, for any interval with endpoints $x_1$, $x_2$, $x_1\\ne x_2$,\nthe average rate of change of $Q$ with respect to $x$ on that interval \nis \n\\begin{equation}\\frac{Q(x_2)-Q(x_1)}{x_2-x_1}\n=\\frac{Q(x_1)-Q(x_2)}{x_1-x_2}.\\end{equation}\n\\item The {\\bf instantaneous} rate of change of $Q$ with \nrespect to $x$ at the value $x$ is\n\\begin{equation}\n\\lim_{\\Delta x\\to0}\\frac{\\Delta Q}{\\Delta x}\n=\\lim_{\\Delta x\\to0}\\frac{Q(x+\\Delta x)-Q(x)}{\\Delta x}=Q'(x),\n\\end{equation} wherever that limit exists and is finite.\\end{enumerate}\n\n\\end{definition}\nAll of these applications have their own interpretations.\nInterestingly enough, the {\\it analytic geometric} interpretation\nof the derivative of a function unifies them all\nin one graphical setting.  For the remainder of this\nsection, we will concentrate on the significance\nof the derivative $f'(x)$ to the graph of $y=f(x)$.\n\nFirst we will consider a very simple case.  Suppose\n$$f(x)=mx+b,$$\nwhere $m,b\\in\\Re$ are fixed constants.  Then\n\\begin{align*}f'(x)&=\\lim_{\\Delta x\\to0}\n\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{[m(x+\\Delta x)+b]-[mx+b]}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{mx+m\\Delta x+b-mx-b}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{m\\Delta x}{\\Delta x}\n=\\lim_{\\Delta x\\to0}m=m.\n\\end{align*}\nThus, when $y=f(x)$ is the line $y=mx+b$ we get $f'(x)=m$;\nif the function is a line then its derivative is the slope.\n\nRecall that the slope of a line measures how rapidly\nthat line rises or falls as we move along the line and to the right.\nIn other words, slope measures the rate of change\nin $y$ with respect to $x$.  That rate is constant on\na line, but changes on most curves.  Still, if we\nlook closely at a point $(a,f(a))$ on the graph\nof $y=f(x)$,\nwe can often associate a slope with the curve there.\\footnotemark\n\\footnotetext{Just as a naive observation of the Earth's surface\ncan lead us to believe the Earth is flat, if we were\nstanding on a curve at $(a,f(a))$, and very focused\non the curve at and around that point, \nwe might believe we are looking at a constant\nslope. The actual slope is what we approach when\nwe focus more and more on that point, by letting $\\Delta x\\to0$.\n}\\hphantom{. }To measure this slope, again we would\nif effect measure the way $y=f(x)$ changes (instantaneously)\nwith respect to $x$ at $x=a$.  \nWith this motivation, we make the following definition:\n\n\\begin{definition}Given a function $f(x)$, the {\\bf slope}\nof the graph of $y=f(x)$ any point $(a,f(a))$ on the graph\nis given by $f'(a)$, assuming this derivative exists there.\\footnotemark\n\\footnotetext{Recall $f'(a)$ exists means exactly\nthat $\\ds{\\lim_{\\Delta x\\to0}\\frac{f(a+\\Delta x)-f(a)}{\\Delta x}}$\nexists as a limit and is finite.}\n\\end{definition}\n\n\nA function and its derivative give two types of information\nabout the graph of $y=f(x)$:\n\\begin{itemize}\n\\item $f(x)$ gives the {\\it height} of the graph for a particular $x$-value.\n\\item $f'(x)$ gives the {\\it slope} of the graph at that $x$-value.\n\\end{itemize}  \nFor instance, we saw in Example~\\ref{VelocityExample1}, \npage~\\pageref{VelocityExample1}\n(using different variables) that \n $f(x)=x^2+1\\implies f'(x)=2x$.\nWhen we graph $y=x^2+1$, i.e., when we graph the function\n$f(x)=x^2+1$, the function gives the height at each $x$,\nand the derivative $f'(x)=2x$ gives the slope.\nThis is illustrated in Figure~\\ref{FunctionWithTangents1}.\n\nOf geometric interest is the {\\it tangent line} to the graph\nof $y=f(x)$ at a point $(a,f(a))$.  This is just the \nline through $(a,f(a))$ with slope $f'(a)$:\n\\begin{definition} The line through $(a,f(a))$ with slope\n$f'(a)$, i.e., the same slope as the function at $x=a$,\nis the {\\bf tangent line} to the graph of $y=f(x)$ through $(a,f(a))$.\n\\end{definition}\nSeveral tangent lines are drawn in Figure~\\ref{FunctionWithTangents1}.\nA formula for the tangent line through $(a,f(a))$ presents itself\nimmediately, since we have a point $(a,f(a))$, and a slope $f'(a)$,\nthe modified point-slope form gives us:\n\\begin{equation}\ny=f(a)+f'(a)(x-a).\\label{TangentLineEq2}\\end{equation}\nThis form (\\ref{TangentLineEq2}) will appear throughout\nthe text, and in this chapter it will be particularly\napparent in Section~\\ref{Differentials/LinearApproxs}.\nFor the function in Figure~\\ref{FunctionWithTangents1},\nfor instance, the tangent line at $x=1$\nis through $(1,f(1))=(1,2)$, with $f'(1)=2$, is \n$y=2+2(x-1)$. \n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.4,-.6)(2.4,6)\n%%%\\begin{pspicture}(-4,-1)(4,10)\n%\\psline{<->}(0,1)(8,1)\n\\psset{xunit=.6cm,yunit=.6cm}\n\\psaxes{<->}(0,0)(-4,-1)(4,10)\n%\\psplot[plotpoints=200,linewidth=1.5pt]{-3}{3}{x dup mul 1 add}\n\\parabola[linewidth=1.5pt]{<->}(-3,10)(0,1)\n\\pscircle[fillstyle=solid,fillcolor=black](-2,5){.1}\n%\\psplot{-3}{-.8}{-4 x -2 sub mul 5 add}\n\\psline{<->}(-.8,.2)(-3,9)\n\n\\rput(-4,5){$\\ds{\\begin{aligned}\n                            f(-2)&=5\\\\\n                           f'(-2)&=-4\n                           \\end{aligned}}$}\n\\pscircle[fillstyle=solid,fillcolor=black](0,1){.1}\n%\\psplot{-3}{3}{1}\n\\psline{<->}(-3.5,1)(3.5,1)\n\\rput(-2.9,1){$\\ds{\\begin{aligned}f(0)&=1\\\\f'(0)&=0\\end{aligned}}$}\n\\pscircle[fillstyle=solid,fillcolor=black](1,2){.1}\n%\\psplot{-0.5}{3}{2 x 1 sub mul 2 add}\n\\psline{<->}(-.5,-1)(3,6)\n\\rput(2.4,2){$\\ds{\\begin{aligned} f(1)&=2\\\\ f'(1)&=2\\end{aligned}}$}\n\\end{pspicture}\n\\end{center}\n\\caption{The graph of $f(x)=x^2+1$, along with the\ntangent lines to the graph at $x=-2,0,1$.\nThe height at each $x$ is given by $f(x)$, while\nthe slope is given by $f'(x)=2x$.}\n\\label{FunctionWithTangents1}\\end{figure}\n\n\\newpage\\bex \\label{SquareRootDerivativeExample} \nConsider the function $f(x)=\\sqrt{2x+1}$.\nThen, a conjugate multiplication (third line below) gives us:\n\\begin{align*}\nf'(x)&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\sqrt{2(x+\\Delta x)+1}-\\sqrt{2x+1}}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\sqrt{2(x+\\Delta x)+1}-\\sqrt{2x+1}}{\\Delta x}\n  \\cdot\\frac{\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}}\n         {\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{(2(x+\\Delta x)+1)-(2x+1)}\n        {\\Delta x\\left(\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}\\right)}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{2x+2\\Delta x+1-2x-1}\n         {\\Delta x\\left(\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}\\right)}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{2\\Delta x}\n {\\Delta x\\left(\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}\\right)}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{2}\n{\\left(\\sqrt{2(x+\\Delta x)+1}+\\sqrt{2x+1}\\right)}%\\\\\n%&\n=\\frac{2}{2\\sqrt{2x+1}}\n = \\frac1{\\sqrt{2x+1}}.\\end{align*}\nTo summarize,\n$$f(x)=\\sqrt{2x+1}\\implies f'(x)=\\frac1{\\sqrt{2x+1}}.$$\n\n\nWe can make several observations about the form of this derivative.\nFirst, note that $f(-1/2)=0$ exists, but $f'(-1/2)$ does not.\nOf course for $x=-1/2$ we cannot take $\\Delta x\\to0^-$ or \nwe would be taking square roots of negative numbers.\nStill, it is interesting to \nnotice that $f'(x)\\to\\infty$ as $x\\to-1/2^+$.\nFurthermore, as $x\\to\\infty$, we have $f'(x)\\to0$, so the\nfunction becomes less sloped as we take $x$ farther to\nthe right.  This is all reflected in the graph, as \nillustrated in Figure~\\ref{FunctionWithTangents2}.\n\\eex\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2,-1)(8,4)\n\\psaxes{<->}(0,0)(-2,-1)(8,4)\n\\psplot[plotpoints=200]{-0.5}{8}{x 2 mul 1 add sqrt}\n\n\\pscircle[fillstyle=solid,fillcolor=black](-.5,0){.1}\n\\rput(-2.5,1){$f'\\left(-\\frac12\\right)$ does not exist.}\n\\psline{->}(-1,.8)(-.6,.1)\n\n\\pscircle[fillstyle=solid,fillcolor=black](0,1){.1}\n\\rput(1,1){$f'(0)=1$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](4,3){.1}\n\\rput(4,2.5){$f'(4)=\\frac13$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](6,3.605551275){.1}\n\\rput(6.5,3.){$f'(6)=\\frac1{\\sqrt{13}}\\approx.27735$}\n\\end{pspicture}\n\\end{center}\n\\caption{The graph of $f(x)=\\sqrt{2x+1}$, along\nwith a few slopes. Notice the behavior of the slope,\n$f'(x)=1/\\sqrt{2x+1}$ as $x\\to-1/2^+$ and $x\\to\\infty$.\n}\n\\label{FunctionWithTangents2}\\end{figure}\n\n\\newpage\\bex Consider the function $f(x)=\\frac1x$.  We will find\nits slope everywhere that it is defined.\n\\begin{align*}\nf'(x)&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\frac1{x+\\Delta x}-\\frac1x}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\frac1{x+\\Delta x}-\\frac1x}{\\Delta x}\n   \\cdot\\frac{x(x+\\Delta x)}{x(x+\\Delta x)}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{x-(x+\\Delta x)}{(\\Delta x)(x)(x+\\Delta x)}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{-\\Delta x}{(\\Delta x)(x)(x+\\Delta x)}\n=\\lim_{\\Delta x\\to0}\\frac{-1}{x(x+\\Delta x)}=\\frac{-1}{x^2}.\n\\end{align*}\nSummarizing,\n$$f(x)=\\frac1x\\implies f'(x)=-\\,\\frac1{x^2}.$$\n\n\nWe see some interesting features of this derivative as well.\nFor instance, it is always negative, so the graph is always\nsloping downwards.  Furthermore, it is the same at \n$x=a$ as $x=-a$.  Finally, we note that\n$f'(x)\\to0$ as $x\\to\\pm\\infty$, and $f'(x)\\to-\\infty$\nas $x\\to0$.  This is indeed reflected in the graph\nin Figure~\\ref{FunctionWithTangents3}.\n\\label{FunctionWithTangentsExample3}\\eex\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-5,-3.75)(5,3.75)\n\\psset{xunit=1.5cm,yunit=1.5cm}\n\n\\psaxes{<->}(0,0)(-3.2,-2.5)(3.2,2.5)\n\\psplot[plotpoints=100]{-3.2}{-0.4}{1 x div}\n\\psplot[plotpoints=100]{.4}{3.2}{1 x div}\n\\pscircle[fillstyle=solid,fillcolor=black](-1,-1){.1}\n\\rput(-2,-1){$f'(-1)=-1$}\n\\pscircle[fillstyle=solid,fillcolor=black](1,1){.1}\n\\rput(1.8,1){$f'(1)=-1$}\n\\pscircle[fillstyle=solid,fillcolor=black](.5,2){.1}\n\\rput(1.4,2){$f'(1/2)=-4$}\n\\pscircle[fillstyle=solid,fillcolor=black](2,.5){.1}\n\\rput(3,.6){$f'(2)=-1/4$}\n\\pscircle[fillstyle=solid,fillcolor=black](-.5,-2){.1}\n\\rput(-1.5,-2){$f'(-1/2)=-4$}\n\\end{pspicture}\n\\end{center}\n\n\\caption{Here $f(x)=1/x$ and $f'(x)=-1/x^2$.  Notice \nthat $f'<0$ for all $x\\ne0$.  Also notice the behavior\nof $f'(x)$ as $x\\to\\infty$, $x\\to-\\infty$, and $x\\to0$.}\n\\label{FunctionWithTangents3}\n\\end{figure}\n\n\\newpage\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item  Use the definition of the derivative, \n$$f'(x)=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x},$$\nto find $f'(x)$ for each of the following functions.\n\\begin{enumerate}[a.]\n\\item $\\ds{f(x)=5-2x}$.\n\\item $\\ds{f(x)=10}$.\n\\item $\\ds{f(x)=2x^2+3}$.\n\\item $\\ds{f(x)=3x^2-5x+9}$.\n\\item $\\ds{f(x)=\\sqrt{x}}$.\n\\item $\\ds{f(x)=\\frac3{x+2}}$.\n\\item $\\ds{f(x)=\\sqrt{9-5x}}$.\n\\item $\\ds{f(x)=\\frac1{x^2}}$.\n\\item $\\ds{f(x)=\\frac2{\\sqrt{x}}}$.\n\\item $\\ds{f(x)=x^{3/2}}$.  (Hint: Rewrite as $\\sqrt{x^3}$.)\n\\item $\\ds{f(x)=2x^3}$.\n\\item $\\ds{f(x)=\\sqrt[3]{x+1}}$.  (Hint: We made use of the difference\nof two squares (see  Section~\\ref{ArithmeticWithRealNumbers})\nin Example~\\ref{SquareRootDerivativeExample}.  Here you will\nneed to use the difference of two cubes in a similar manner.)\n\\item $\\ds{f(x)=x^4}$.\n\\item $\\ds{f(x)=\\frac{x}{x+1}}$. (Hint: easier if $f(x)$ is rewritten\n using long division.)\n\\item $\\ds{f(x)=\\frac{x+1}{x-1}}$.\n\\item $\\ds{f(x)=x^{2/3}}$.\n\\end{enumerate}\n\\item Suppose $s(t)=-16t^2+15t+20$ describes the height of\na projectile in free fall.\n\\begin{enumerate}[a.]\n\\item Find the velocity function $v(t)$.\n\\item  What is the projectile's velocity when $t=0$? $t=10$?\n\\item Find $t$  so that the projectile is stationary (i.e., $v=0$).\n\\item How high is the projectile when it is stationary?\n\\end{enumerate}\n\n\\item Consider the general quadratic function $f(x)=ax^2+bx+c$.\n\\begin{enumerate}[a.]\n  \\item Find a formula for the derivative of a \nquadratic function $f(x)=ax^2+bx+c$. \n  \\item  Assuming $a\\ne0$, this represents a parabola.  \nAssuming also that the slope is zero at the vertex,\nfind a general formula for the $x$-coordinate of the\nvertex.\n\\end{enumerate}\n\\item Find the tangent line to the graph at the given point\n$x=a$ for the given function.\n\\begin{enumerate}[a.]\n\\item $f(x)=x^2-9$, \\ $a=4$.\n\\item $f(x)=x^3$, \\ $a=-1$.\n\\item $f(x)=\\sqrt{x}$, \\ $a=9$.\n\\item $f(x)=\\frac1x$, \\ $a=\\frac1{10}$.\n\\end{enumerate}\n\\end{enumerate}\\end{multicols}\n\n\n\n\n\n\n\\newpage\\section{First Differentiation Rules\n\\label{FirstDiffRules}}\nIn this section we derive rules which let us quickly \ncompute the derivative function $f'(x)$ for \nany polynomial function $f(x)$, and for $\\sin x$ and $\\cos x$.\nAlong the way we\nwill derive a few general (though not comprehensive)\nrules for derivatives.  We will also introduce the\nvery powerful {\\it Leibniz notation} for derivatives,\nand show how knowing the derivative helps us to further\nanalyze a function.  One consequence is that we can\nmore accurately graph\na function's behavior by hand.\n\\subsection{Positive Integer Power Rule}\n\nWe will often be interested in finding derivatives of \nfunctions $f(x)=x^n$. Fortunately there is a simple\nrule which covers all such functions.  It is usually\ncalled the {\\it power rule}, as stated below. (Recall\n$\\mathbb{N}=\\{1,2,3,4,5,6,\\cdots\\}$.)\n\n\\begin{theorem}\n$\\ds{\n(f(x)=x^n)\\wedge(n\\in\\mathbb{N})\\qquad\\implies\\qquad f'(x)=n\\cdot x^{n-1}\n}$.\n\\end{theorem}\nNote that implicit in this theorem is that the derivative\nof $x^n$ exists for every $x\\in\\Re$---i.e., ``exists\neverywhere''---since it is equal to $nx^{n-1}$, defined\neverywhere.\n\n\\begin{proof} The proof we give here depends upon the \nbinomial expansion (\\ref{Binomial1}), page~\\pageref{Binomial1}.  \nIt is important to remember\nthat $x$ is a fixed number in the limit, and $\\Delta x$ is\nthe variable approaching zero as far as the limit is concerned.\nWith that in mind,\n\\begin{align*}\nf'(x)&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n&= \\lim_{\\Delta x\\to0}\\frac{(x+\\Delta x)^n-x^n}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\left(\\not{\\!x^n}+nx^{n-1}\\Delta x\n+\\frac{n(n-1)x^{n-2}(\\Delta x)^2}{1\\cdot 2}\n+\\cdots+(\\Delta x)^n\\right)-\\not{\\!x^n}}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{nx^{n-1}\\Delta x+\\frac{(n)(n-1)}{1\\cdot 2}\nx^{n-2}(\\Delta x)^2\n+\\cdots+(\\Delta x)^n}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\n\\left(\n\\vphantom{\\frac12}\nnx^{n-1}+\\frac{(n)(n-1)}{1\\cdot 2}x^{n-2}(\\Delta x)^1+\\cdots+(\\Delta x)^{n-1}\\right)\\\\\n&=nx^{n-1}+0+\\cdots+0\\\\\n&=nx^{n-1}, \\qquad\\text{q.e.d.}\\end{align*}\n\\end{proof}\nThe only term which survives in the limit\nin the fifth line is the $nx^{n-1}$ term\nbecause the others have positive integer powers of $\\Delta x$,\nwhich is approaching zero.\nWe will see later that this power rule is actually much more\ngeneral.  In fact, it can be used for $n\\in\\Re$ but we need\nsome more advanced methods to prove such generality.\nFor now we will apply it only to $n\\in\\mathbb{N}$.\n\n\\bex Here we list the derivatives of some of the positive\ninteger powers of $x$.  The first case listed below ($n=1$) does \nfollow from the proof, though we would be reading\nthe statement of the theorem for that case \n$f(x)=x^1\\implies f'(x)=1x^0=1$.  Again we do not\nreally wish to say $x^0=1$ regardless of $x$,\nfor several technical reasons (though it is fine\nas long as $x>0$), but we see how the formula\nnaively gives us what we want for $n=1$.  The\nrest of the table is more straightforward:\n$$\\begin{array}{ccc}\nf(x)&\\qquad&f'(x)\\vphantom{\\ds{\\frac11}}\\\\\n\\hline\\\\\nx&&1\\\\ \\vphantom{\\ds{\\frac12}}\nx^2&&2x\\\\ \\vphantom{\\ds{\\frac12}}\nx^3&&3x^2\\\\ \\vphantom{\\ds{\\frac12}}\nx^4&&4x^3\\\\ \\vphantom{\\ds{\\frac12}}\n\\vdots&&\\vdots\\\\ \\vphantom{\\ds{\\frac12}}\nx^{100}&&100x^{99}\\\\ \\vphantom{\\ds{\\frac12}}\n\\vdots&&\\vdots \n\\end{array}$$\n\\eex\n\n\\subsection{Leibniz Notation}\nWe will find that other derivative rules will be \nunwieldy to write with our present notation.\nThus we will introduce the very powerful Leibniz notation\nand use it except in a few settings where\nour present (prime) notation is simpler.\n\\begin{definition}\n$\\ds{\\frac{d}{dx}f(x)=f'(x).}$\n\\end{definition}\nThis is also written $\\frac{df(x)}{dx}$.  The \n$\\frac{d}{dx}$ is a {\\it differential operator} which\ntakes a function of $x$ and returns the derivative\n{\\it with respect to $x$}.  When we are interested\nin position and velocity, we can write\n\\begin{equation}\nv=\\frac{ds}{dt}.\\end{equation}\nNotice that the notation resembles difference quotients,\nbecause, with our definition of derivatives, we have\n\\begin{align*}\n\\frac{df(x)}{dx}&=\\lim_{\\Delta x\\to 0}\\frac{\\Delta f(x)}{\\Delta x},\\\\\n\\frac{ds}{dt}&=\\lim_{\\Delta t\\to0}\\frac{\\Delta s}{\\Delta t}.\n\\end{align*}\nSimilarly for any such related quantities.\nWith Leibniz notation  our power rule becomes:\n\\begin{equation}\n\\frac{d}{dx}\\left(x^n\\right)=nx^{n-1}.\\label{PowerRule}\\end{equation}\nIf we would like to compute $f'(a)$, i.e., the derivative at\na particular point, in the Leibniz notation we would write\n$$f'(a)=\\left.\\frac{d}{dx}f(x)\\right|_{x=a}.$$\nSo, for example, $\\ds{\\frac{d\\,x^5}{dx}=5x^4}$, and the \nslope at $x=1$ of the function $f(x)=x^5$ is given by\\footnotemark\n$$f'(1)=5\\cdot1^4=5,\\qquad\\text{or}\\qquad\n\\left.\\frac{d x^5}{dx}\\right|_{x=1}=\\left.\\vphantom{X_X^X}\n               5x^4\\right|_{x=1}=5\\cdot1^4=5.$$\nThe vertical line with the subscript $x=a$\nis often read, ``evaluated at $x=a$.''  \n\nNote how the Leibniz notation is often assumed to act like a \nfraction:  ${\\frac{d}{dx}\\left(x^5\\right)=\\frac{d x^5}{dx}}$.\nHowever the $d$ in the numerator, and (separately) the $dx$ in the \ndenominator are treated as inviolable; we do not ever\nbreak those terms up further.\n\\footnotetext{%%%\n%%% FOOTNOTE\nOften the ``$x=$'' is omitted when the variable is obvious, as\nin $\\ds{\\left.\\frac{d x^5}{dx}\\right|_1=\\left.\\vphantom{X_X^X}\n    5x^4\\right|_1=5\\cdot1^4=5}$.\n%%% END FOOTNOTE\n}\n\nNote the flexibility of the Leibniz notation in the following:\n$$\n\\frac{d x^3}{dx}=3x^2,\\qquad\n\\frac{d u^3}{du}=3u^2,\\qquad\n\\frac{d t^3}{dt}=3t^2.$$\nThese are actually the same rule (with different  variables):\nthat the cube of a quantity changes with respect to that quantity\nat the (instantaneous) rate of 3 times the square of the quantity,\nbe it $x$, $u$ or $t$.  Put another way, if the horizontal axis\nis given by $t$, and we graph the height $t^3$ on the vertical \naxis, then the slope is always $3t^2$.  \n\nThe Leibniz notation also keeps \nus from making the mistake of trying to use the derivative rules\n(such as the power rule) to compute, for example, $\\frac{du^3}{dx}$.\nSince the variables ($u$ and $x$) do not match,  the power rule cannot\nbe used.\\footnote{%%%\n%%% FOOTNOTE\nLater in the text we will have the chain rule, which helps us get\naround the problem of computing $\\frac{du^3}{dx}$, for instance.\nThere we will see some of the true power of the Leibniz notation,\nas we compute for instance\n$$\\frac{du^3}{dx}=\\frac{du^3}{du}\\cdot\\frac{du}{dx}=3u^2\\cdot\\frac{du}{dx}.$$\nNotice how we apparently multiplied and divided by $du$ to achieve\nthe second expression.\n%%% END FOOTNOTE\n\\label{FootnoteFirstSeeChainRule}}\n\n\nWith the power rule (\\ref{PowerRule}) and a few other\nresults we can quickly calculate the derivatives of polynomials.\nMuch of this chapter will be devoted to calculating\nderivatives using known rules, which save an enormous amount\nof time when compared to calculating derivatives using limits of difference\nquotients as in  the previous section.\n\n\n\n\n\n\n\n\\subsection{Sum and Constant Derivative Rules}\n\\begin{theorem}{\\rm\\bf(Sum Rule)}\nSuppose $\\ds{\\frac{d}{dx}f(x)}$ and $\\ds{\\frac{d}{dx}g(x)}$\nexist.  Then\n\\begin{equation}\\frac{d}{dx}\\left(f(x)+g(x)\\right)=\n        \\frac{d}{dx}f(x)+\\frac{d}{dx}g(x).\\end{equation}\n\\end{theorem}\nIn other words the derivative of a sum is the sum of \nthe respective derivatives.  Some texts write this using\nthe prime notation:\n$$(f+g)'=f'+g'.$$\n\n\\begin{proof} Assume that $\\frac{d}{dx}f(x)$ and\n$\\frac{d}{dx}g(x)$ exist at a particular $x$.\nThen\n\\begin{align*}\n\\frac{d}{dx}\\left(f(x)+g(x)\\right)\n&=\\lim_{\\Delta x\\to0}\\frac{(f(x+\\Delta x)+g(x+\\Delta x))-(f(x)+g(x))}\n      {\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)+g(x+\\Delta x)-g(x)}\n      {\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\left(\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\n      +\\frac{g(x+\\Delta x)-g(x)}{\\Delta x}\\right)\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\n      +\\lim_{\\Delta x\\to0}\\frac{g(x+\\Delta x)-g(x)}{\\Delta x}\\\\\n&=\\frac{d\\,f(x)}{dx}+\\frac{d\\,g(x)}{dx},\\qquad\\text{q.e.d.}    \\end{align*}\nThe reason that we could break this into two limits \nlegitimately is because the two limits both existed\nand were finite by assumption. (See Theorem~\\ref{UsualLimitTheorems},\npage~\\pageref{UsualLimitTheorems}.)\n\\end{proof}\n\\bex $\\ds{\\frac{d}{dx}\\left(x^3+x^2+x\\right)=\n\\frac{dx^3}{dx}+\\frac{dx^2}{dx}+\\frac{dx}{dx}=3x^2+2x+1}$.\n\\eex\nWith practice, one learns to skip the first step in the example above.\nNote how $\\frac{dx}{dx}=1$, as one might hope.  This reflects the\nfact that $x$ and $x$ change at the same rate (i.e., the ratio of\ntheir rates of change is always 1).  Put another way, the slope\nof the line $y=x$ is always 1.\n\nThe next theorem is usually given separately for emphasis.\n\n\\begin{theorem}\nThe derivative of a constant is zero; if a function\nis defined by $f(x)=C$ for all $x\\in\\Re$, where $C$\nis some fixed constant, then $f'(x)=0$ for all $x\\in\\Re$.\nWritten two different ways, we thus have:\n\\begin{align}\nf(x)=C&\\implies f'(x)=0;\\\\\n\\frac{d}{dx}C&=0.\\label{DerivativeOfAConstant}\\end{align}\\end{theorem}\nThere are a couple ways to see this. From the difference quotient\nlimit definition (\\ref{DifferenceQuotientDerivativeDefinition})\n(page \\pageref{DifferenceQuotientDerivativeDefinition}), regardless\nof $\\Delta x\\ne0$ the\ndifference quotient $[f(x+\\Delta x)-f(x)]/\\Delta x=[C-C]/\\Delta x\n=0/\\Delta x=0$,\nso it remains zero in the limit.  \nFrom another perspective regarding\nwhat we know about lines\nwe have that $f(x)=C$ is a line of slope $m=0$.\nFrom a qualitative standpoint this theorem is reasonable\nsince constants have rate of change\nzero (hence the term {\\it constant}) \nwith respect to $x$. Some texts write\\footnotemark \\ $(C)'=0$.\n%\n\\footnotetext{One weakness of Taylor's ``prime'' notation is that\nwe do not know what variable we are taking the derivative\nwith respect to.  For instance, in an earlier example\nwe have fuel volume $V$ as a function of position $s$,\nand so ${dV}/{ds}$ measured the flow rate of fuel\nper mile.  However, since $s=s(t)$, we have $V=V(s(t))$, so\nultimately $V=V(t)$, i.e., $V$ can be written as a\n(algebraically different) function of $t$ instead, in which\ncase we can calculate $\\ds{dV}/{dt}$, measuring the\nflow rate with respect to time.  So when asked to calculate\n$V'$, or even $V'(5)$,\n there is this ambiguity which is not present in the Leibniz\nnotation.  \n\nIf one wrote $V'(s)$, it would probably be understood to be $dV/ds$\nand not $dV/dt$.  Similarly, $V'(5\\text{ seconds})$ would be understood\nto mean $dV/dt$ evaluated at $t=5\\text{ seconds}$.}\n%\nWith this theorem we can write,\nfor example,\n$$\\frac{d}{dx}\\left(x^3+28\\right)=\\frac{d}{dx}\\left(x^3\\right)+\\frac{d}{dx}\n\\left(\\vphantom{x^3}28\\right)=3x^2+0=3x^2.$$\nWith very little practice one learns to write\nquickly ${\\frac{d}{dx}\\left(x^3+28\\right)=3x^2}$.\n\nWe need just one more result before we can find derivatives\nof arbitrary polynomials.  This answers the \nquestion of what to do with the coefficients of a polynomial,\nand multiplicative constants in general.\n%\n\\begin{theorem} Multiplicative constants are preserved\nin the derivative.  In other words,\n\\begin{equation}\n\\frac{d}{dx}\\left(C\\cdot f(x)\\right)=C\\cdot\\frac{d}{dx}f(x).\n\\label{DerivativeAndMultiplicativeConstants}\\end{equation}\n\\label{TheoremOnDerivativeAndMultiplicativeConstants}\\end{theorem}\nThe proof is left as an exercise.  It follows from the fact\nthat multiplicative constants ``go along for the ride''\nin limits as well.  \n(See again Theorem~\\ref{UsualLimitTheorems}.)\nFor a simple example, we have\n$$\\frac{d}{dx}\\left(5x^7\\right)=5\\cdot\\frac{d}{dx}\\left(x^7\\right)\n=5\\cdot7x^6=35x^6.$$\nAgain, with very little practice one learns to compute\nsuch a derivative in one step.\nNote how the derivative operator\n$\\frac{d}{dx}$ treats additive constants (which do not survive)\ndifferently from multiplicative constants (which do survive).\nWe can combine the power rule (\\ref{PowerRule}),\n(\\ref{DerivativeOfAConstant}), and (\\ref{DerivativeAndMultiplicativeConstants})\nto quickly compute the derivative of any given polynomial\n(where $n\\in\\mathbb{N}$):\n%\n%\\begin{equation}\n%\\begin{aligned}{ }&\\frac{d}{dx}\\left(\n%a_nx^n+a_{n-1}x^{n-1}+\\cdots+a_2x^2+a_1x+a_0\\right)\\\\\n%&=a_n\\cdot nx^{n-1}+a_{n-1}\\cdot (n-1)x^{n-2}+\\cdots+a_2\\cdot2x+a_1.\n%\\end{aligned}\n%\\label{DerivativeOfAPolynomial}\n%\\end{equation}\n\\begin{equation}\\begin{aligned}\n\\frac{d}{dx}\\left(\\vphantom{1_2x^2}\\right.&\\left.\na_nx^n+a_{n-1}x^{n-1}+\\cdots+a_2x^2+a_1x+a_0\\right)\\\\\n&=a_n\\cdot nx^{n-1}+a_{n-1}\\cdot (n-1)x^{n-2}+\\cdots+a_2\\cdot2x+a_1.\n\\label{DerivativeOfAPolynomial}\\end{aligned}\\end{equation}\n\n\n%$$\\begin{array}{ccccccccccc}\n%\\ds{\\frac{d}{dx}\\left(\\vphantom{a_nx^n}\\right.}\n%a_nx^n&+&a_{n-1}x^{n-1}&+&\\cdots&+&a_2x^2&+&a_1x&+&a_0\n%\\ds{\\left.\\vphantom{a_nx^n}\\right)}\\\\ \\\\\n%=a_n\\cdot nx^{n-1}&+&a_{n-1}(n-1)a^{n-2}&+&\\cdots&+\n%&a_2\\cdot2x&+&a_1.\\end{array}$$\n\nTo be clear on the logic, note that we first use the sum rule to\nbreak this into a sum of derivatives of the $a_kx^k$, $k=1,\\cdots,n$\nand $a_0$, \ncalculating the derivatives of the $a_kx^k$ terms in \nturn, each time  using the fact that the \nmultiplicative constants $a_k$ are along\nfor the ride, and the power rule giving $a_k\\cdot kx^{k-1}$.\nThe final term $a_0$ is an additive constant\nwith  derivative zero and thus does \nnot appear on the right hand side of (\\ref{DerivativeOfAPolynomial}).\n%\n\\bex To see how (\\ref{DerivativeOfAPolynomial}) can be\ncarried out quickly, we list a couple of examples:\n\\begin{align*}\n\\frac{d}{dx}\\left(5x^4+9x^2+13x+47\\right)&=5\\cdot4x^3+9\\cdot2x^1+13\\cdot1+0\\\\\n             &=20x^3+18x+13.\\\\\n\\frac{d}{dx}\\left(9-6x+5x^{11}\\right)&=0+(-6)\\cdot1+5\\cdot11x^{10}    \\\\\n             &=-6+55x^{10}.\\end{align*}\n\\label{PolynomialDerivativeExample}\\eex\n%\nNote that the negative sign also  ``goes along for the ride,'' since\nit is just a factor of $-1$.  In fact we could list\na {\\it derivative of a difference} rule,\n$$\\frac{d}{dx}\\left(f(x)-g(x)\\right)=\\frac{d}{dx}f(x)-\\frac{d}{dx}g(x),$$\nbut that would be redundant given the sum rule, and\nhow a multiplicative constant $-1$ (or $-2$, or $-6$, etc.) is preserved \nin the derivative.\n\nWe need to also point out that to use (\\ref{DerivativeOfAPolynomial}),\nwe need to have the function written in the form of the left hand side of that\nequation. \n\\bex $\\ds{\\frac{d}{dx}\\left[(x^2+1)^2\\right]\n=\\frac{d}{dx}\\left[x^4+2x^2+1\\right]=4x^3+4x.}$\\eex\nIn the above we needed to multiply out the polynomial.\nThus $\\frac{d}{dx}[(x^2+1)^2]\\ne2(x^2+1)$,\nsince we are taking the derivative with respect\nto $x$ and not $(x^2+1)$.\n\nWe point out again that it should be clear from the previous examples that\n(\\ref{DerivativeOfAPolynomial}) is much simpler than using the\noriginal definition of the derivative (as a limit of difference\nquotients (\\ref{DifferenceQuotientDerivativeDefinition}),\npage~\\pageref{DifferenceQuotientDerivativeDefinition})\nto calculate derivatives of polynomials.\n\n\\subsection{Applications to Graphing Polynomials}\nRecall that while $f(x)$ gives the height of the graph $y=f(x)$\nat a particular value of $x$, the derivative $f'(x)$\ngives the slope.  If the slope is positive the graph\nis ``sloping upwards;'' if negative the graph is ``sloping\ndownwards.''  Another way to speak of such things is\nto discuss functions which are {\\it increasing} or {\\it decreasing}\non an interval, say $(a,b)$.\n\n\\begin{definition}\nConsider a function $f(x)$ with an interval $(a,b)$ contained in the domain.\n\\begin{enumerate}\n\\item We say $f(x)$ is {\\bf increasing} on $(a,b)$ if and only if\n      $(\\forall x,y\\in(a,b))(x<y\\longleftrightarrow f(x)<f(y))$.\n\\item We say $f(x)$ is {\\bf decreasing} on $(a,b)$ if and only if\n      $(\\forall x,y\\in(a,b))(x<y\\longleftrightarrow f(x)>f(y))$.\n\\end{enumerate}\n(Note that it is possible that a function is not consistently increasing or\nconsistently decreasing on a given interval.)\\end{definition}\nClearly, for an increasing function on $(a,b)$, the height increases\nas $x$ increases through the interval.  Similarly, for\na decreasing function on $(a,b)$, the height decreases\nas $x$ increases through the interval.  If we know exactly\nwhere a function is increasing, and where it is decreasing,\nthat information can be of great help in plotting or \nanalyzing the function.  To see what this has to \ndo with derivatives we state the following theorem.  Its \nproof relies on the Mean Value Theorem which will be introduced\nin a later section.  However, it should already have the ring of \ntruth given what we know of derivatives and slopes.\n\n\\begin{theorem}Suppose $f(x)$ is defined for $x\\in(a,b)$, and $f'(x)$\n              exists for $x\\in(a,b)$.  Then\n  \\begin{enumerate}\n   \\item $ (\\forall x\\in(a,b))(f'(x)>0)\n                     \\implies f(x)\\text{ is increasing on }(a,b)$;\n   \\item $ (\\forall x\\in(a,b))(f'(x)<0)\n                     \\implies f(x)\\text{ is decreasing on }(a,b)$.\n  \\end{enumerate}\n(Again, if $f'(x)$ changes sign on $(a,b)$, then neither of these hold.)\n\\end{theorem}\n\n\\bex\\label{XXX-3XExample}\nTo see how we might use this to graph polynomials, consider\nthe graph of the function $f(x)=x^3-3x$.\nThis function is continuous on all of $\\Re=(-\\infty,\\infty)$.\nAlso notice that\n\\begin{align*}\n\\lim_{x\\to\\infty}f(x)&=\\lim_{x\\to\\infty}\\left[x^3\\left(1-\\frac3{x^2}\\right)\n               \\right]\\overset{\\infty\\cdot1}{\\longeq}\\infty,\\\\\n\\lim_{x\\to-\\infty}f(x)&=\\lim_{x\\to-\\infty}\\left[x^3\\left(1-\\frac3{x^2}\\right)\n               \\right]\\overset{-\\infty\\cdot1}{\\longeq}-\\infty.\\end{align*}\nIf we draw a sign chart for $f(x)$, showing where the function\nis positive and where it is negative, we can get some\nidea of what the graph looks like.  To construct a sign chart\nfor any function we look at all the\npossible points where the function can change signs. Recall that\nthe Intermediate Value Theorem (Corollary~\\ref{IntermediateValueTheorem},\npage~\\pageref{IntermediateValueTheorem})\nimplies a function $f(x)$ can only change signs, as we increase $x$,\nby either passing through zero height or having a discontinuity.\nSince our particular $f(x)$ here is continuous on all $\\Re$,\nwe look to where $f(x)=0$ to divide $\\Re$ into intervals of constant sign.\nNow $f(x)=x^3-3x=x(x^2-3)$ is zero for $x=0,\\pm\\sqrt3$.  This\ngives us four intervals on which $f(x)$ does not change signs.\nWe can test for the sign of $f(x)$ at a single point in each interval\nto get the sign of $f(x)$ on that interval.  As we did \nin Section~\\ref{ContinuityOnIntervalsSection}, we construct\nthe sign chart for $f(x)$:\n\n\\begin{center}\n\\begin{pspicture}(-0.2,-1)(12,2)\n\\psline{<->}(2,0)(12,0)\n   \\psline(4.5,-.2)(4.5,.2)\n      \\rput(4.5,-.5){$-\\sqrt3$}\n   \\psline(7,-.2)(7,.2)\n      \\rput(7,-.5){$0$} \n   \\psline(9.5,-.2)(9.5,.2)\n      \\rput(9.5,-.5){$\\sqrt3$}\n\\rput[l](-0.2,1.5){Function:}\n\\rput(7,1.5){$f(x)=x(x^2-3)$}\n\n\\rput[l](-0.2,.5){Sign Factors:}\n\\rput[l](-0.2,1.){Test $x=$}\n  \\rput(3.25,1){$-10$}\n\\rput(3.25,.5){\\bominus\\boplus}\n  \\rput(5.75,1){$-1$}\n\\rput(5.75,.5){\\bominus\\bominus}\n  \\rput(8.25,1){$1$}\n\\rput(8.25,.5){\\boplus\\bominus}\n  \\rput(10.75,1){$10$}\n\\rput(10.75,.5){\\boplus\\boplus}\n\n\\rput[l](-0.2,-.5){Sign $f(x)$:}\n\\rput(3.25,-.5){\\bominus}\n\\rput(5.75,-.5){\\boplus}\n\\rput(8.25,-.5){\\bominus}\n\\rput(10.75,-.5){\\boplus}\n\\end{pspicture}\n\\end{center}\nFrom the sign chart and the behavior as $x\\to\\pm\\infty$ we\ncan get some idea of what the graph of $f(x)$ looks like.\nThat information is reflected, however imprecisely,\nin Figure~\\ref{RoughGraphOfXXX-3X}.\n\\begin{figure}\\begin{center}\n\\begin{pspicture}(-6,-3)(6,3)\n\\psset{xunit=2cm}\n\\psaxes{<->}(0,0)(-3,-3)(3,3)\n\\rput(-1.732,.5){$-\\sqrt3$}\n\\psline(-1.732,-.15)(-1.732,.15)\n\\rput(1.732,.5){$\\sqrt3$}\n\\psline(1.732,-.15)(1.732,.15)\n\\pscurve(-2.5,-3)(-1.732,0)(-.7,1.3)(0,0)(0,0)(.7,-1.3)(1.732,0)(2.5,3)\n\\pscircle*(-.75,1.3){.07}\n\\pscircle*(.75,-1.3){.07}\n\\rput(-.75,1.6){local maximum?}\n\\rput(.75,-1.6){local minimum?}\n\\end{pspicture}\\end{center}\n\\caption{Rough graph of $f(x)=x^3-3x$ based upon its sign\nchart and behavior as $x\\to\\pm\\infty$. \nIn particular we do not know the exact\nlocations of the local maximum(s) or minimum(s) without\ninvestigating the derivative of $f(x)$.}\n\\label{RoughGraphOfXXX-3X}\\end{figure}\nA serious drawback to such a graph is that we know\nfrom the Extreme Value Theorem (Corollary~\\ref{ExtremeValueTheorem},\npage~\\pageref{ExtremeValueTheorem})\nthat there will be a value in $[-\\sqrt3,0]$ which is\na {\\bf local maximum}, and another in $[0,\\sqrt3]$ which is\na {\\bf local minimum}, but we do not know exactly where these\nare from the sign chart of the function  (we will formally define the\nboldface terms shortly). However, a sign chart for the {\\bf derivative}\nof $f(x)$ can possibly give us this information.\n\nSince $f(x)=x^3-3x$, it follows quickly that $f'(x)=3x^2-3$.\nRecall that intervals where $f'>0$, the function $f$ is increasing,\nwhile those intervals on which $f'<0$ the function is decreasing.\nSince $f'(x)$ is also an easily factored\npolynomial, constructing its sign chart is \neasy.  Note $f'(x)=3x^2-3=3(x^2-1)=3(x+1)(x-1)$ is zero\nexactly where $x=\\pm1$.\n\n\\begin{center}\n\\begin{pspicture}(-0.2,-2)(12,2)\n\\psline{<->}(2,0)(11,0)\n   \\psline(5,-.2)(5,.2)\n      \\rput(5,-.5){$-1$}\n   \\psline(8,-.2)(8,.2)\n      \\rput(8,-.5){$1$} \n  % \\rput[l](-0.2,1.5){Function:}\n\\rput(7,1.5){$f'(x)=3(x+1)(x-1)$}\n\\rput[l](-0.2,1){Test $\\hphantom{f'(}x\\hphantom{)}=$}\n\\rput[l](-.2,.5){Sign $f'(x)=$}\n\\rput[l](-0.2,-.5){Sign $f'(x)$:}\n\\rput(3.5,1){$-2$}\n  \\rput(3.5,.5){\\boplus\\bominus\\bominus}\n  \\rput(3.5,-.5){\\boplus}\n\\rput(6.5,1){$0$}\n  \\rput(6.5,.5){\\boplus\\boplus\\bominus}\n  \\rput(6.5,-.5){\\bominus}\n\\rput(9.5,1){$10$}\n  \\rput(9.5,.5){\\boplus\\boplus\\boplus}\n  \\rput(9.5,-.5){\\boplus}\n\\rput[l](-.2,-1.25){Behavior of $f(x)$:}\n  \\rput(3.5,-1){INC}\n   \\rput(3.5,-1.5){$\\nearrow$}\n   \\rput(6.5,-1.5){$\\searrow$}\n   \\rput(9.5,-1.5){$\\nearrow$}  \n\\rput(6.5,-1){DEC}\n  \\rput(9.5,-1){INC}\n\\end{pspicture}\n\\end{center}\n\nHere we used ``INC'' to abbreviate increasing, which we also\nsignified by the arrow pointing upwards ($\\nearrow$), and\nwe used ``DEC'' and ($\\searrow$) to signify decreasing.\n>From this we see we get a local maximum at \n$(-1,f(-1))=(-1,2)$, and a local minimum at \n$(1,f(1))=(1,-2)$.  These two bits of information allow us\nto draw a more accurate sketch of the graph of \n$f(x)=x^3-3x$, as illustrated in Figure~\\ref{GraphOfXXX-3X}.\nThat graph is computer-generated, but we can get a \nvery accurate picture of the function's general behavior\nby plotting the information we have gathered: the\nsign of $f$, including the {\\bf $x$-intercepts} (where $f(x)=0$),\nthe limiting behavior of $f(x)$ as $x\\to\\pm\\infty$,\nand where $f(x)$ is increasing/decreasing, including\nany local maximum and minimum points.\\footnote{%\n%%%%%%%% FOOTNOTE\nIt is\nalso worth noticing that $f'(x)=3(x+1)(x-1)\\longrightarrow\\infty$\nfor both $x\\to\\infty$ and $x\\to-\\infty$, and so the\nslope of $f(x)$ grows larger as $x\\to\\pm\\infty$.\nThis is not the case with all graphs (see Figure~\\ref{FunctionWithTangents2},\npage~\\pageref{FunctionWithTangents2}\nfor example), but it is a nice feature to notice when plotting\na graph such as Figure~\\ref{GraphOfXXX-3X} above.}\n%%%%% END FOOTNOTE\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-6,-3)(6,3)\n\\psset{xunit=2cm}\n\\psaxes{<->}(0,0)(-2.5,-3)(2.5,3)\n\\rput(-1.7,.35){$-\\sqrt3$}\n\\psline(-1.732,-.15)(-1.732,.15)\n\\rput(1.732,.3){$\\sqrt3$}\n\\psline(1.732,-.15)(1.732,.15)\n\\psplot{-2.1}{2.1}{x 3 exp x 3 mul sub}\n\\pscircle[fillstyle=solid,fillcolor=black](-1,2){.08}\n\\pscircle[fillstyle=solid,fillcolor=black](1,-2){.08}\n\\pscircle[fillstyle=solid,fillcolor=black](-1.732,0){.08}\n\\pscircle[fillstyle=solid,fillcolor=black](1.732,0){.08}\n\\rput(-1,2.3){local maximum}\n\\rput(1,-2.3){local minimum}\n\n\\end{pspicture}\n\\end{center}\\caption{Partial graph of $f(x)=x^3-3x$ showing\nthe sign of $f(x)$, the limiting behavior as $x\\to\\pm\\infty$,\nand the sign of $f'(x)$ (which indicates also the\nlocations of local extrema). The $x$-intercepts (where $f(x)=0$),\nthe local maximum and local minimum points are also illustrated.}\n\\label{GraphOfXXX-3X}\n\\end{figure}\n\\eex\nIt is important to distinguish the meanings of a sign\nchart for $f(x)$, and one for $f'(x)$.  The former\njust tells us where the function is below or above\nthe $x$-axis; the latter tells us where the function\nis increasing and where the function is decreasing.\n\nIn the above we used the following terms, which we now\ndefine:\n\\begin{definition}Given a function $f(x)$.\n\\begin{enumerate}\n\\item We call a point $x_0$ a {\\bf local maximum} of $f(x)$\n      if and only if \n\\begin{equation}(\\exists(a,b)\\ni x_0)(\\forall x\\in (a,b))(f(x)\\le f(x_0)).\n\\end{equation}\n\\item We call a point $x_0$ a {\\bf local minimum} of $f(x)$\n\\begin{equation}(\\exists(a,b)\\ni x_0)(\\forall x\\in (a,b))(f(x)\\ge f(x_0)).\n\\end{equation}\n\\end{enumerate}\n\\end{definition}\nIn other words, $x_0$ is a local maximum of $f(x)$ if there\nis an open interval containing $x_0$ in which the function\nis never greater than $x_0$ on that interval.  Local\nminimum is defined analogously.  If $f(x)$\nis continuous in an open interval around $x_0$, and\n$f'$ exists in that interval, then a change of signs\nof $f'$ at $x_0$ indicates one of these {\\it local extrema}.\nIf, for instance, $f'>0$ to the left of $x_0$ and $f'<0$\nto the right, then $f$ increases before and decreases after $x_0$,\nmaking $x_0$ a local maximum.  This can be seen in the \nderivative sign chart and graph above for our example function\n$f(x)=x^3-3x^2$.\n\\subsection{Derivatives of Sine and Cosine}\nIn this section we show how $\\sin x$ and $\\cos x$ are\nboth differentiable, compute their derivatives, and apply\nthem to functions involving the chain rule.\nWe will prove the following theorem.\n\n\\begin{figure}\\begin{center}\n\n\\hfill\\begin{pspicture}(-1,-1)(5.6,1.3)\n\\psset{xunit=.8cm,yunit=.8cm}\n\\psaxes[labels=none,ticks=none]{<->}(0,0)(-.5,-1.25)(7,1.25)\n  \\psline(-.2,1)(.2,1)  \n  \\psline(-.2,-1)(.2,-1)\n  \\rput[r](-.4,1){1}\n  \\rput[r](-.4,-1){$-1$}\n  \\psline(1.570796,-.2)(1.570796,.2)\n  \\rput(1.570796,-.5){$\\frac{\\pi}2$}\n  \\psline(3.141596,-.2)(3.141596,.2)\n  \\rput(3.1415926,-.5){$\\pi$}\n  \\psline(4.7123890,-.2)(4.7123890,.2)\n  \\rput(4.7123890,-.5){$\\frac{3\\pi}2$}\n  \\psline(6.28318531,-.2)(6.28318531,.2)\n  \\rput(6.28318531,-.5){$2\\pi$}\n     \\psplot[plotpoints=1000]{-.5}{7}{x 3.1415926535 div 180 mul sin}\n            \\rput(3.25,1.6){$y=\\sin x$}\n  \\rput{270}(3.14,-1.8){$\\implies$}\n\\end{pspicture}\\hfill\n\\begin{pspicture}(-1,-1)(5.6,1.3)\n\\psset{xunit=.8cm,yunit=.8cm}\n\\psaxes[labels=none,ticks=none]{<->}(0,0)(-.5,-1.25)(7,1.25)\n  \\psline(-.2,1)(.2,1)  \n  \\psline(-.2,-1)(.2,-1)\n  \\rput[r](-.4,1){1}\n  \\rput[r](-.4,-1){$-1$}\n  \\psline(1.570796,-.2)(1.570796,.2)\n  \\rput(1.570796,-.5){$\\frac{\\pi}2$}\n  \\psline(3.141596,-.2)(3.141596,.2)\n  \\rput(3.1415926,-.5){$\\pi$}\n  \\psline(4.7123890,-.2)(4.7123890,.2)\n  \\rput(4.7123890,-.5){$\\frac{3\\pi}2$}\n  \\psline(6.28318531,-.2)(6.28318531,.2)\n  \\rput(6.28318531,-.5){$2\\pi$}\n     \\psplot[plotpoints=1000]{-.5}{7}{x 3.1415926535 div 180 mul cos}\n          \\rput(3.25,1.6){$y=\\cos x$}\n  \\rput{270}(3.14,-1.8){$\\implies$}\n\\end{pspicture}\\hfill\n\\vskip.4truein\n\n\\hfill\\begin{pspicture}(-1,-1)(5.6,1.3)\n\\psset{xunit=.8cm,yunit=.8cm}\n\\psaxes[labels=none,ticks=none]{<->}(0,0)(-.5,-1.25)(7,1.25)\n  \\psline(-.2,1)(.2,1)  \n  \\psline(-.2,-1)(.2,-1)\n  \\rput[r](-.4,1){1}\n  \\rput[r](-.4,-1){$-1$}\n  \\psline(1.570796,-.2)(1.570796,.2)\n  \\rput(1.570796,-.5){$\\frac{\\pi}2$}\n  \\psline(3.141596,-.2)(3.141596,.2)\n  \\rput(3.1415926,-.5){$\\pi$}\n  \\psline(4.7123890,-.2)(4.7123890,.2)\n  \\rput(4.7123890,-.5){$\\frac{3\\pi}2$}\n  \\psline(6.28318531,-.2)(6.28318531,.2)\n  \\rput(6.28318531,-.5){$2\\pi$}\n     \\psplot[plotpoints=1000]{-.5}{7}{x 3.1415926535 div 180 mul cos}\n           \\rput(3.25,1.6){$\\frac{dy}{dx}=\\cos x$}\n\\end{pspicture}\\hfill\n\\begin{pspicture}(-1,-1)(5.6,1.3)\n\\psset{xunit=.8cm,yunit=.8cm}\n\\psaxes[labels=none,ticks=none]{<->}(0,0)(-.5,-1.25)(7,1.25)\n  \\psline(-.2,1)(.2,1)  \n  \\psline(-.2,-1)(.2,-1)\n  \\rput[r](-.4,1){1}\n  \\rput[r](-.4,-1){$-1$}\n  \\psline(1.570796,-.2)(1.570796,.2)\n  \\rput(1.570796,-.5){$\\frac{\\pi}2$}\n  \\psline(3.141596,-.2)(3.141596,.2)\n  \\rput(3.1415926,-.5){$\\pi$}\n  \\psline(4.7123890,-.2)(4.7123890,.2)\n  \\rput(4.7123890,-.5){$\\frac{3\\pi}2$}\n  \\psline(6.28318531,-.2)(6.28318531,.2)\n  \\rput(6.28318531,-.5){$2\\pi$}\n     \\psplot[plotpoints=1000]{-.5}{7}{0 x 3.1415926535 div 180 mul sin sub}\n            \\rput(3.25,1.6){$\\frac{dy}{dx}=-\\sin x$}\n\\end{pspicture}\\hfill\n\n\\bigskip\n\n\\end{center}\n\\caption{Partial graphs of $y=\\sin x$, $y=\\cos x$, and\ntheir respective derivative functions graphed below them.}\n\\label{SineAndCosineAndDerivativesFigure}\\end{figure}\n\n\n\\begin{theorem} The functions $\\sin x$ and $\\cos x$ are\ndifferentiable for all $x\\in\\Re$, and---when $x$\nis measured in {\\bf radians}---their derivatives\nare given by:\n\\begin{align}\n\\frac{d\\,\\sin x}{dx}&=\\cos x,\\label{SineDerivative}\\\\\n\\frac{d\\,\\cos x}{dx}&=-\\sin x.\\label{CosineDerivative}\n\\end{align}\\end{theorem}\n\nThese should seem reasonable given the respective graphs of\nFigure~\\ref{SineAndCosineAndDerivativesFigure}.\nFor instance, for the sine curve we have the following data:\n$$\n\\begin{array}{rcrrrrr}\nx&=&0,&\\ \\frac{\\pi}2,&\\ \\pi&\\ \\frac{3\\pi}2,&\\ 2\\pi\\\\\n\\sin x&=&0,&1,&0,&-1,&0\\\\\n\\cos x&=&1,&0,&-1,&0,&1\\end{array}$$\nLooking at the graph of $\\sin x$ as drawn in\nFigure~\\ref{SineAndCosineAndDerivativesFigure},\nthe slopes at these points and the values for $\\cos x$\nseem at least compatible.  Similarly for the cosine\ncurve:\n$$\n\\begin{array}{rcrrrrr}\nx&=&0,&\\ \\frac{\\pi}2,&\\ \\pi&\\ \\frac{3\\pi}2,&\\ 2\\pi\\\\\n\\cos x&=&1,&0,&-1,&0,&1\\\\\n-\\sin x&=&0,&-1,&0,&1,&0\\\\\\end{array}$$\nWe will prove the derivative formula for $\\sin x$, and leave\nthe derivative of $\\cos x$ as an exercise.  (The two \ncomputations are very similar.)\n\n%\\begin{proof}{\\bf(\\ref{CosineDerivative}):}\n%Define $f(x)=\\cos x$.  We want to show $f'(x)=-\\sin x$.\n%The proof uses a trigonometric identity on the third\n%line, and two previously proved\n%theorems on the last line:\n%$$\n%\\cos(\\alpha+\\beta)=\\cos\\alpha\\cos\\beta-\\sin\\alpha\\sin\\beta,$$\n%$$\\lim_{\\theta\\to0}\\frac{1-\\cos\\theta}\\theta=0,\n%\\qquad\\qquad\n%\\lim_{\\theta\\to0}\\frac{\\sin\\theta}{\\theta}=1.$$\n%These are, respectively, (\\ref{Cos(Alpha+Beta)}),\n%(\\ref{(1-CosX)/(X)Limit}) and (\\ref{SinX/XLimitTheoremEquation}).\n%Now we compute $f'(x)$:\n%\\begin{align*}\n%f'(x)&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n%&= \\lim_{\\Delta x\\to0}\\frac{\\cos(x+\\Delta x)-\\cos (x)}{\\Delta x}\\\\\n%&=\\lim_{\\Delta x\\to0}\n%\\frac{\\cos x\\cos\\Delta x-\\sin x\\sin\\Delta x-\\cos x}{\\Delta x}\\\\\n%&=\\lim_{\\Delta x\\to0}\\left[\n%\\frac{\\cos x(\\cos \\Delta x-1)}{\\Delta x}-\\frac{\\sin x\\sin\\Delta x}{\\Delta x}\n%\\right]\\\\\n%&=\\lim_{\\Delta x\\to0}\\left[\\cos x\\cdot\\frac{\\cos\\Delta x-1}{\\Delta x}\n%-\\sin x\\frac{\\sin\\Delta x}{\\Delta x}\\right]\\\\\n%&=\\cos x\\cdot 0 - \\sin x\\cdot 1\n%=-\\sin x,\\qquad\\text{q.e.d.}\n%\\end{align*}\n%\\end{proof}\n\\begin{proof}{\\bf(\\ref{SineDerivative})}: The proof is based upon\nthe following:\n\\begin{align*}\n\\sin(\\alpha+\\beta)&=\\sin\\alpha\\cos\\beta+\\cos\\alpha\\sin\\beta,\\\\\n\\lim_{\\theta\\to0}\\frac{\\sin\\theta}\\theta&=1,\\\\\n\\lim_{\\theta\\to0}\\frac{1-\\cos\\theta}{\\theta}&=0,\\end{align*}\nwhich are, respectively,\n(\\ref{Sin(Alpha+Beta)}) from page~\\pageref{Sin(Alpha+Beta)}, \n(\\ref{SinX/XLimitTheoremEquation}) from \npage~\\pageref{SinX/XLimitTheoremEquation}, and\n(\\ref{(1-CosX)/(X)Limit}) from page~\\pageref{(1-CosX)/(X)Limit}.\nWe will use the limit-definition of the derivative, expand\nusing the formula for $\\sin(\\alpha+\\beta)$, and rearrange the\nterms so we can use the trigonometric limits above.\n\\begin{align*}\nf'(x)&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\sin(x+\\Delta x)-\\sin x}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\sin x\\cos\\Delta x+\\cos x\\sin\\Delta x-\\sin x}\n                          {\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\frac{\\sin x(\\cos\\Delta x-1)+\\cos x\\sin\\Delta x}\n                          {\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\\left[\\sin x\\cdot\\frac{\\cos\\Delta x-1}{\\Delta x}\n                          +\\cos x\\cdot\\frac{\\sin\\Delta x}{\\Delta x}\\right]\\\\\n&=\\sin x\\cdot 0+\\cos x\\cdot 1\\\\\n&=\\cos x,\\qquad\\text{q.e.d.}\n\\end{align*}\n\\end{proof}\nNow we combine what we know into other examples.\n\\bex Find $f'(x)$ if $f(x)=x^2+\\sin x-3\\cos x$.\n\n\\underline{Solution}:\n$$f'(x)=\\frac{d}{dx}\\left[x^2+\\sin x-3\\cos x\\right]\n       =2x+\\cos x-3(-\\sin x)=2x+\\cos x+3\\sin x.$$\n\\eex\nWe can also use these derivatives to find where functions involving\n$\\sin x$ and $\\cos x$ are increasing/decreasing, and thus find any\nlocal extrema\n(that is, local maxima and minima).\n\\bex Consider the function $f(x)=\\sin x-\\cos x$.  Find where\n$f(x)$ is increasing and where $f(x)$ is decreasing, and use this\ninformation to plot $f(x)$.\n\n\\underline{Solution}:\nHere $f'(x)=\\cos x-(-\\sin x)=\\cos x+\\sin x$.  Since this is defined\nand continuous everywhere, we will check where it is zero to \ndetect where it ($f'(x)$ here) possibly changes signs.  \nThe technique below works anytime we are interested \nin solving $a\\sin x+b\\cos x=0$, where $a,b\\ne0$:\n\\begin{align*}\n\\cos x+\\sin x=0&\\iff \\sin x=-\\cos x\\\\\n               &\\iff \\frac{\\sin x}{\\cos x}=-1\\\\\n               &\\iff \\tan x=-1.\n\\end{align*}\nThe reason we can divide by $\\cos x$ is because there are no solutions\nwhere $\\cos x=0$, because such solutions would require also $\\sin x=0$,\nand these cannot be zero simultaneously because\n(recall) $\\sin^2x+\\cos^2x=1$.  So we are looking for $x\\in\\Re$ such that\n$\\tan x=-1$. This occurs  in the second quadrant (if $x$ represents\nan angle in standard position) and in the fourth quadrant, with\nreference angles $\\pi/4$:\n\n\\begin{center}\n\\begin{pspicture}(-2,-2)(2,2)\n\\psaxes[labels=none]{<->}(0,0)(-2,-2)(2,2)\n\\pscircle(0,0){1}\n\\psline{<->}(-2,2)(2,-2)\n\\end{pspicture}\n\\end{center}\n\n\\noindent Thus we are looking for angles $x=\\frac{3\\pi}4+n\\pi$, where \n$n=0,\\pm1,\\pm2,\\pm3,\\cdots$.  Now $f(x)=\\cos x+\\sin x$ is $2\\pi$-periodic,\nso we can analyze one period to see what the graph\nshould look like.  We will use the points\n$x=-\\pi/4,3\\pi/4,7\\pi/4$ for our sign chart, and declare the pattern\nfrom there:\n\n\\begin{center}\n\\begin{pspicture}(0,0)(9,6)\n\\rput(6,6){$f'(x)=\\cos x+\\sin x$}\n\\rput[l](0,5.3){Test $x$=}\n  \\rput(4.5,5.3){$0$}\n  \\rput(7.5,5.3){$\\pi$}\n\\rput[l](0,4.7){$f'(x)=$}\n  \\rput(4.5,4.7){$1+0$}\n  \\rput(7.5,4.7){$-1+0$}\n\\psline{|-|}(3,4)(9,4)\n\\rput(3,3.5){${\\frac{-\\pi}4}$}\n\\rput(6,3.5){${\\frac{3\\pi}4}$}\n\\rput(9,3.5){${\\frac{7\\pi}4}$}\n\n\\rput[l](0,2.8){Sign $f'$:}\n   \\rput(4.5,2.8){\\boplus}\n   \\rput(7.5,2.8){\\bominus}\n\\rput[l](0,2.2){Behavior of $f$:}\n   \\rput(4.5,2.2){$\\nearrow$}\n   \\rput(7.5,2.2){$\\searrow$}\n\\end{pspicture}\n\\end{center}\n\n\\noindent Because this behavior continues, we see a\nlocal maximum at $\\left(\\frac{3\\pi}4,f\\left(\\frac{3\\pi}4\\right)\\right)\n=\\left(\\frac{3\\pi}4,\\sqrt2\\right)$,\nsince\n $$f(3\\pi/4)=\\sin\\frac{3\\pi}4-\\cos\\frac{3\\pi}4=\\frac{\\sqrt2}2-\\frac{-\\sqrt2}2\n=\\frac{\\sqrt2+\\sqrt2}2=\\frac{2\\sqrt2}2=\\sqrt2.$$\nThis local maximum height then\nrepeats every $2\\pi$ in both (left and right) directions. Similarly,\nbecause of the sign chart and the fact that this function \n(and its derivative and its derivative's sign chart) repeats\nevery $2\\pi$,  we have\na local minimum at, for instance, \n$\\left(\\frac{7\\pi}4,f\\left(\\frac{7\\pi}4\\right)\\right)\n=\\left(\\frac{7\\pi}4,-\\sqrt2\\right)$, which also repeats every\n$2\\pi$ in both directions. This function is\ngraphed in Figure~\\ref{f(x)=SinX-CosXFigure}\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-6.28,-2)(6.28,2)\n\\psaxes[labels=none,Dx=.7854,Dy=1.4142]{<->}(0,0)(-6.28,-2)(6.28,2)\n\\psplot[plotpoints=1000]{-6.28}{6.28}{x 3.1415926538 div 180 mul sin %\nx 3.1415926538 div 180 mul cos sub}\n\n\\rput(.5,1.4142){$\\sqrt2$}\n\\rput(.7,-1.4142){$-\\sqrt2$}\n\n\\rput(-3.1416,-.3){$-\\pi$}\n\\rput(3.1416,-.3){$\\pi$}\n\\rput(2.36,-.5){$\\frac{3\\pi}4$}\\rput(-.785,-.5){$\\frac{-\\pi}4$}\n\\rput(-3.927,-.5){$\\frac{-5\\pi}4$}\n\\rput(5.498,-.5){$\\frac{7\\pi}4$}\n\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $f(x)=\\sin x-\\cos x$, showing for instance\nthe local minima at $x=7\\pi/4$ and $x=-\\pi/4$, and the local \nmaxima at $x=3\\pi/4$ and $x=-5\\pi/4$.  Each local extremum is\nrepeated every $2\\pi$. See Example~\\ref{f(x)=SinX-CosXExample}.}\n\\label{f(x)=SinX-CosXFigure}\\end{figure}\n\\label{f(x)=SinX-CosXExample}\n\n\n\n\n\n\n\n\\eex\n\n\n\n\n\\bex Let $f(x)=x+\\sin x$.  Find where $f(x)$ is increasing and where $f(x)$\nis decreasing.\n\n\\underline{Solution}: Here $f'(x)=1+\\cos x=0$ when $\\cos x=-1$,\nwhich is at $x=\\pm\\pi, \\pm3\\pi, \\pm5\\pi, \\cdots$.  A partial sign chart\nis given below:\n\n\\begin{center}\n\\begin{pspicture}(-0.2,-2)(12,2)\n\\psline{<->}(0,0)(12,0)\n   \\psline(3,-.2)(3,.2)\n      \\rput(3,-.5){$-\\pi$}\n   \\psline(6,-.2)(6,.2)\n      \\rput(6,-.5){$\\pi$}\n   \\psline(9,-.2)(9,.2)\n      \\rput(9,-.5){$3\\pi$}\n \n\\rput(7,1.5){$f'(x)=1+\\cos x$}\n\\rput[l](-0.2,1){Test $\\hphantom{f'(}x\\hphantom{)}=$}\n%\\rput[l](-.2,.5){Sign $f'(x)=$}\n\\rput[l](-0.2,-.5){$f'(x)$:}\n\\rput(3.5,1){$-2$}\n%  \\rput(1.5,.5){\\boplus\\bominus\\bominus}\n  \\rput(1.5,-.5){\\boplus}\n\\rput(4.5,1){$0$}\n%  \\rput(4.5,.5){\\boplus\\boplus\\bominus}\n  \\rput(4.5,-.5){\\boplus}\n\\rput(7.5,1){$10$}\n%  \\rput(7.5,.5){\\boplus\\boplus\\boplus}\n  \\rput(7.5,-.5){\\boplus}\n\\rput(10.5,1){$10$}\n%  \\rput(10.5,.5){\\boplus\\boplus\\boplus}\n  \\rput(10.5,-.5){\\boplus}\n\n\n\n%\\rput[l](-.2,-1.25){Behavior of $f(x)$:}\n   \\rput(1.5,-1.5){$\\nearrow$}\n   \\rput(4.5,-1.5){$\\nearrow$}\n   \\rput(7.5,-1.5){$\\nearrow$}  \n   \\rput(10.5,-1.5){$\\nearrow$}\n\\end{pspicture}\n\\end{center}\n\n\\eex\n\nSo this function is actually always increasing, only\nbriefly having zero slope at the odd multiples of $\\pi$.\nNote that these points occur at $(\\pi,\\pi)$,\n$(3\\pi,3\\pi)$, $(7\\pi,7\\pi)$, etc., and\n $(-\\pi,-\\pi)$,\n$(-3\\pi,-3\\pi)$, $(-7\\pi,-7\\pi)$, etc.\nThis function is graphed in Figure~\\ref{GraphOfX+SinX},\nshowing this behavior.\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-3.6,-3.6)(3.6,3.6)\n\\psset{xunit=.3cm,yunit=.3cm}\n\\psaxes[labels=none,Dx=3.1416]{<->}(0,0)(-12,-12)(12,12)\n%\\psplot{-6}{6}{x 3.1415926536 div 180 mul sin x add}\n\\psplot[plotpoints=1000]{-12}{12}{x 3.1415926536 div 180 mul sin x add}\n\\rput(-9.625,-.7){$-3\\pi$}\n\\rput(-6.483,-.7){$-2\\pi$}\n\\rput(-3.342,-.7){$-\\pi$}\n\\rput(3.142,-.7){$\\pi$}\n\\rput(6.283,-.7){$2\\pi$}\n\\rput(9.425,-.7){$3\\pi$}\n\n\\rput(1,3){3}\n\\rput(1,6){6}\n\\rput(1,9){9}\n\\rput(1.3,-3){$-3$}\n\\rput(1.3,-6){$-6$}\n\\rput(1.3,-9){$-9$}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $f(x)=x+\\sin x$.  The derivative being\n$f'(x)=1+\\cos x$, which is positive except at \n$x=\\pm\\pi,\\pm3\\pi,\\pm5\\pi,\\cdots$, the function is always\nincreasing, momentarily ``leveling off'' at these points where\n$f'(x)=0$.}\n\\label{GraphOfX+SinX}\n\\end{figure}\n\n\n\\subsection{Other Applications}\n\nWe can look back at our earlier discussion of the derivative\nto see some other applications of our present differentiation\nrules.  For instance, if we have a particle with a position\nfunction $s(t)=6t^2-9t+15$, we immediately get the velocity\nfunction:\n$$s(t)=6t^2-9t+15\\implies v=\\frac{ds}{dt}=\\frac{d}{dt}\\left[\n      6t^2-9t+15\\right]=12t-9.$$\nIf $s$ is in meters and $t$ in seconds, then $v=\\frac{ds}{dt}$\nis in meters/second.\n\nIf instead, $s(t)=\\sin t$, then $v(t)=\\frac{ds(t)}{dt}\n=\\frac{d}{dt}\\sin t=\\cos t$, so a sinusoidal motion gives\na similar (cosinusoidal?) velocity.\n\n\n\n\nFor another example,\nif we have the volume of a tank given as a function of time \n$t$ by $V(t)=t(10-t)$, $0\\le t\\le 10$ then the volume in the tank is\nchanging at a rate (for $0<t<10$) of\n$$\\frac{dV}{dt}=\\frac{d}{dt}\\left[10t-t^2\\right]=10-2t.$$\nIf $V$ is in gallons and $t$ is in minutes, then\n$\\frac{dV}{dt}$ is in gallons/minute. The maximum volume of the\ntank occurs at $t=5$, since before then we have $\\frac{dV}{dt}>0$,\nwhile after $t=5$ we have $\\frac{dV}{dt}<0$.  The actual\nmaximum volume is then $V(5)=5(10-5)=25$.\n\nThere are countless other examples of {\\it related rates}\nwe can investigate using just the rules of this section.\nHowever, we will be much better equipped to pursue \napplications after we develop the other differentiation\nrules in the next sections.  Eventually we will tackle\nmany and varied such problems to illustrate how the\ncalculus is applied to real-world questions.\n\n\n\n\n\n\n\\newpage\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\n\n\\begin{multicols}{2}\n\n\\begin{enumerate}\n\\item Find the following derivatives.\n\\begin{enumerate}\n\\item $\\ds{\\frac{d}{dx}\\left[x^2-199x+27\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac12x^2+2x\\right]}$.\n\\item $\\ds{\\frac{d}{dt}\\left[t^7-19t+10^6\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[(x+9)(x-3)\\right]}$.\n\\item $\\ds{\\frac{d}{dy}\\left[10-9y^8\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left(2x+5\\right)^2}$.\n\\end{enumerate}\n\n\\item Show that $$\\ds{\\frac{d}{dx}\\left(x^2\\cdot x^3\\right)\n\\ne\\left(\\frac{d}{dx}\\left(x^2\\right)\\right)\n\\!\\left(\\frac{d}{dx}\\left(x^3\\right)\\right).}$$\nWhy does this not violate Theorem~%\n\\ref{TheoremOnDerivativeAndMultiplicativeConstants}\n(i.e., (\\ref{DerivativeAndMultiplicativeConstants}))?\n\\label{NoSimpleProductRuleExercise}\n\\item Give an alternate proof of the integer power rule,\nTheorem~\\ref{PowerRule} by using\n\\begin{multline*}\na^n-b^n=(a-b)\\left(a^{n-1}+a^{n-2}b\\right.\\\\ \\left.+a^{n-3}b^2\n+\\cdots+ab^{n-2}+b^{n-1}\n\\right).\\end{multline*}\n(\\underline{Hint}: $a^n$ will be your $f(x+\\Delta x)$ term,\nand $b^n$ will be $f(x)$.)\n\\item Suppose $s(t)=3t^2-2t+19$.  Find $v(t)$.  Also \nfind when the particle is moving to the right ($v>0$), and when\nit is moving left ($v<0$).\n\\item Graph the function $f(x)=x^4-4x^2$, showing all\n$x$-intercepts, all local maxima and minima.  \n(See Example \\ref{XXX-3XExample}, page \\pageref{XXX-3XExample}.)\n\n\\item Use $\\cos(\\alpha+\\beta)=\\cos\\alpha\\cos\\beta-\\sin\\alpha\\sin\\beta$\nto prove (\\ref{CosineDerivative}), page~\\pageref{CosineDerivative}:\n$$\\frac{d\\cos x}{dx}=-\\sin x.$$\nIt may be helpful to see the proof for the derivative of $\\sin x$.\n\n\\item Graph $f(x)=\\sin x+\\cos x$ for $x\\in[-2\\pi,2\\pi]$,\nshowing where this function is increasing and where it is decreasing.\n\\item Graph $f(x)=x+2\\cos x$ over a reasonable interval, showing\nwhere this function is increasing and where it is decreasing.\nAlso show its behavior as $x\\to\\pm\\infty$.\n\n\n\\item 1(f) above must be expanded (``multiplied out'')\nbefore using the power rule.  The answer is $8x+20$.\nCompute 1(f) above using instead the technique in \nFootnote~\\ref{FootnoteFirstSeeChainRule}, \npage~\\pageref{FootnoteFirstSeeChainRule}. (There $u=2x+5$).\n\\end{enumerate}\n\\end{multicols}\n\\newpage\n%%%%%%\n%%%%%%\n%%%%%%\n\\section{Chain Rule I}\nThe chain rule is perhaps the most important of the \ndifferentiation rules.  It is immensely rich in application,\nand very elegantly stated when notation is chosen wisely.\nIn this section we will look closely at the rule itself,\nand the underlying intuition of the rule. \n\n\n The mechanics\nof applying the rule are of utmost importance, but as with\nother calculus principles, understanding the intuition\naids in determining when and how to apply the chain rule.\nBecause of the importance and theoretical richness of the\nchain rule, the reader is encouraged to revisit this\nsection from time to time, to reinforce this \nmost important topic.\n\n\n\nIn its simplest form, the chain rule dictates  how \nwe must calculate derivatives of compositions\nof functions, i.e., functions of the form $h(x)=f(g(x))$, \nespecially when\nwe know how to calculate $f'$ and  $g'$.  \nWith it we will be\nable to calculate derivatives for a much\nwider class of functions,  find slopes on\nimplicit curves, and to find so-called related rates\nrelationships among variables.  \n\nWe will first state \nthe chain rule using Taylor's ``prime'' notation \nand  then  re-write it in terms\nof the Leibniz notation.  Eventually the latter will be given \npreferential treatment, for in writing the chain rule\nusing Leibniz, we will get a first glance at some of the true\npower of that notation.\n\\subsection{Chain Rule in Prime Notation}\n\\begin{theorem}{\\rm\\bf(Chain Rule)} \nSuppose that $h(x)=f(g(x))$, where $g'(a)$ exists and\n$f'(g(a))$ exists.  Then\n\\begin{equation}\nh'(a)=[f'(g(a))]g'(a).\n\\end{equation}\n\\end{theorem}\n%\nAnother way of writing this in Taylor's notation is\n\\begin{equation}\\left(f(g(x))\\right)'=f'(g(x))g'(x).\n\\label{PrimeNotationChainRule}\\end{equation}\nNote that there is an ``outer'' function, namely $f$,\nand an ``inner function'' $g$.  So the chain rule\nis sometimes stated that we compute the derivative\nof the outer function {\\it with respect to the inner function},\nthat is $f'(g(x))$, and then multiply by the derivative of\nthe inner function, i.e., by $g'(x)$.  That is a common, \ncolloquial way of expressing the chain rule.  It should be\nmentioned that ``multiplying by the derivative of the inner\nfunction'' is the step that is most commonly forgotten\nin such derivative problems.\n\n\\bex Compute $f'(x)$ if $f(x)=(x^2+3x)^2$.\n\n\\underline{Solution}:\nBesides the unwieldy ``limit definition,'' thus far there \nare two possible methods for computing $f'(x)$ here:\n\\begin{itemize}\n\\item Expand the function first, and then compute the derivative, as\nwe would need to do if we had only the methods of the previous section:\n$$h(x)=x^4+6x^3+9x^2\\implies h'(x)=4x^3+18x^2+18x.$$\n\\item Use the chain rule.  Here the ``outer function'' is \n      $f(x)=x^2$ (squaring the input), \n      and the ``inner function'' is $g(x)=x^2+3x$.\n      Note that $f'(x)=2x$ while $g'(x)=2x+3$.  Using the chain rule\n      we would have\n      $$h'(x)=[f'(g(x))]g'(x)=\\left[2(g(x))^1\\right]g'(x)\n            =\\left[2(x^2+3x)^1\\right](2x+3).$$\nNote that this gives $h'(x)=2(2x^3+9x^2+9x)=4x^3+18x^2+18x$ as before.\n\\end{itemize}\n\\eex\nAs we will see, there are simpler ways of looking at the chain\nrule than labeling an ``outer function'' $f(x)$ and\nan  ``inner function'' $g(x)$, calculating $f'$ and $g'$, and\nevaluating at $g(x)$ and $x$, respectively.  Still, there are advantages over\nexpanding the function first.  For instance, expanding might not\nbe so easy.  Also, the final answer is somewhat factored which\nhelps in determining where the derivative is positive and negative.\nThe next example will demonstrate some of these\nadvantages more dramatically.\n\n\\bex Find $h'(x)$ if $h(x) =(x^3+27x+9)^{55}$.\n\n\\underline{Solution}: \nCertainly we do not want to multiply this out\nto use earlier rules.  Instead we just notice that this\nis a composition of two functions, with the\n``outer'' function being $f(x)=x^{55}$ and the\n``inner'' function being $g(x)=x^3+27x+9$.  \nNow $f'(x)=55x^{54}$, while $g'(x)=3x^2+27$.  Thus\n$$h'(x)=[f'(g(x)]g'(x)=55(g(x))^{54}\\cdot g'(x)\n=55(x^3+27x+9)^{54}\\cdot(3x^2+27).$$\nEven if we had somehow expanded the original, 165-degree polynomial first,\nand then calculated the derivative, it is unlikely\nwe would have noticed that our resulting 164-degree polynomial\nanswer factors so nicely.\\eex\n\nThe chain rule has much to say about derivatives of functions which \ncontain trigonometric functions in their structures.  \nBelow are two examples where \nthe ``outer function'' and ``inner function'' are\nsquaring and sine functions, respectively and then vice-versa.\n\\bex Find $h'(x)$ if $h(x)=\\sin^2x.$\n\n\\underline{Solution}: Note that $h(x)=(\\sin x)^2$, so the\n``outer function'' is $f(x)=x^2$, while the ``inner function''\nis $\\sin x$.  Next note that $f'(x)=2x$ and $g'(x)=\\cos x$.  Thus\n$$h'(x)=[f'(g(x))]g'(x)=[2(g(x))]g'(x)=2\\sin x\\cdot\\cos x.$$\n\\eex\n\\bex Suppose $h(x)=\\sin x^2$.  Here $f(x)=\\sin x$, $g(x)=x^2$,\n$f'(x)=\\cos x$, $g'(x)=2x$.  Hence\n$$h'(x)=[f'(g(x))]g'(x)=\\cos g(x)\\cdot g'(x)=\\cos x^2\\cdot2x=2x\\cos x^2.$$\n(It is customary to write the polynomial factor before the trigonometric\nfunction factor in the final answer, \nso it is clearer what terms are inside the trigonometric\nfunction, and which are multiplying the trigonometric function.)\n\\label{SinXXWithPrimes}\\eex\n\nNote how it is crucial to identify the outer function and the inner function.\nIt is also important that the inner function $g(x)$ is entered into\nthe derivative $f'$ of the outer function.  \n\nTo show that the chain rule makes sense from the limit-definition\nstandpoint as a derivative rule, we next offer a partial proof\nof the chain rule.  Note how the way the limit is re-written reflects\nthe ultimate statement of the chain rule.  It also reflects much of the\nintuition of the rule.\n\n\n\\subsection{Partial Proof of Chain Rule}\nWe will not completely\nprove the chain rule in this context because of some technical\ndifficulties which arise when\nproving the rule in its most general form.  However, we will look\nat a proof in perhaps the most common case, which is\nthe case that $g(x+\\Delta x)-g(x)\\longto 0$ ``properly'' \n(so that we also have %not only does $g(x+\\Delta x)-g(x)\\longto 0$,\n$(\\exists\\delta>0)[0<|\\Delta x|<\\delta\\longrightarrow\ng(x+\\Delta x)-g(x\\ne0]$.\nIn such a case we can safely divide and multiply by $g(x+\\Delta x)-g(x)$\nin the limit definition of the derivative to get\n\\begin{align*}\n\\frac{d}{dx}[f(g(x))]&=\n   \\lim_{\\Delta x\\to 0}\\frac{f(g(x+\\Delta x))-f(g(x))}{\\Delta x}\\\\\n  &=\\lim_{\\Delta x\\to 0}\n      \\underbrace{\\frac{f(g(x+\\Delta x))-f(g(x))}{g(x+\\Delta x)-g(x)}}_{(I)}\n        \\cdot\n       \\underbrace{\\frac{g(x+\\Delta x)-g(x)}{\\Delta x}}_{(II)}.\\end{align*}\nNow we claim that this limit is $f'(g(x))g'(x)$.  The second\nterm $(II)$ clearly has limit $g'(x)$, by definition.\nUnder the assumption that $g(x+\\Delta x)-g(x)\\longto0$ properly\nas $\\Delta x\\to0$, we can substitute \n$\\Delta g(x)=g(x+\\Delta x)-g(x)\\longto0$,\nand rewrite the limit $(I)$\\footnotemark  %%% FOOTNOTEMARK\n$$\\lim_{\\Delta g(x)\\to0}\\frac{f(g(x)+\\Delta g(x))-f(g(x))}{\\Delta g(x)}\n  =f'(g(x)).$$\n\\footnotetext{%%%\n%%% FOOTNOTE\nWhen we rewrite $f(g(x+\\Delta x))=f(g(x)+\\Delta g(x))$,\nwe were justified because\n\\begin{align*}\ng(x+\\Delta x)&=(g(x+\\Delta x)-g(x))+g(x)\\\\\n&=\\Delta g(x)+g(x)\\\\ &= g(x)+\\Delta g(x).\\end{align*}\n%%% END FOOTNOTE\n}%      \nNote that the computation above is also correct even if \n$\\Delta g(x)\\longto 0^+$ or $\\Delta g(x)\\longto 0^-$ properly, \nbecause the\nexistence of the two-sided limit represented by $f'(g(x))$\nis assumed to exist in our statement of the chain rule theorem.\n\n\n\n\n\n\\subsection{Leibniz Notation and the Chain Rule}\nBefore we see how the chain rule is stated with Leibniz\nnotation, first we will make some observations\nabout that notation.  For example, the following\nthree formulas say the same thing---how the square of \na quantity changes with respect\nto the quantity---albeit with different\nvariables:\n$$\\frac{d\\,x^2}{dx}=2x, \\qquad \\frac{d\\,t^2}{dt}=2t,\\qquad\n\\frac{d\\,u^2}{du}=2u.$$\nSee Figure~\\ref{XTU} for a graphical interpretation of this fact.\nIt is important that in each equation the variables matched.\n(It is \\underline{\\it not} true,\nfor instance, that $d\\,u^2/dx=2u$, as we shall soon see.)\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2,-1)(2,4.2)\n\\psaxes{<->}(0,0)(-2,-1)(2,4)\n\\psplot{-2}{2}{x dup mul}\n\\rput(.10,4.2){$x^2$}\n\\rput(2,.2){$x$}\n\\pscircle[fillcolor=black,fillstyle=solid](1.4141,2){.07}\n\\end{pspicture}\\quad\n\\begin{pspicture}(-2,-1)(2,4.2)\n\\psaxes{<->}(0,0)(-2,-1)(2,4)\n\\psplot{-2}{2}{x dup mul}\n\\rput(.10,4.2){$t^2$}\n\\rput(2,.2){$t$}\n\\pscircle[fillcolor=black,fillstyle=solid](1.4141,2){.07}\n\\end{pspicture}\\quad\n\\begin{pspicture}(-2,-1)(2,4.2)\n\\psaxes{<->}(0,0)(-2,-1)(2,4)\n\\psplot{-2}{2}{x dup mul}\n\\rput(.10,4.2){$u^2$}\n\\rput(2,.2){$u$}\n\\pscircle[fillcolor=black,fillstyle=solid](1.4141,2){.07}\n\\end{pspicture}\n\\end{center}\n\n\\caption{Three identical graphs: $x^2$ versus $x$, \n$t^2$ versus $t$, and $u^2$ versus $u$.  All have the\nsame slope---though these are dubbed $\\frac{dx^2}{dx}=2x$,\n$\\frac{dt^2}{dt}=2t$ and $\\frac{du^2}{du}=2u$\nrespectively---at each fixed horizontal axis value.\nOne such value is represented by a black dot on each of the three graphs.}\n\\label{XTU}\n\\end{figure}\n\n\n\n\n\n\n\n\nNow suppose we have a differentiable function $u=u(x)$ and want to take\nthe derivative of $\\left(u(x)\\right)^2$. The ``outer''\nfunction is $f(x)=x^2$ (i.e., squaring what is inside),\nwhile the ``inner'' function is $u=u(x)$.  Consider\nhow we find the derivative of $(u(x))^2$ (a chain rule problem)\nwith Taylor's ``prime'' notation (\\ref{PrimeNotationChainRule}), and with\nLeibniz's notation:\n\\begin{alignat}{3}\n&\\text{Taylor:}&&\\qquad&\\left((u(x))^2\\right)'&=2(u(x))^1\\cdot u'(x)\\\\\n&\\text{Leibniz:}&&&\\frac{d\\,u^2}{dx}&=\\frac{d\\,u^2}{du}\\cdot\\frac{du}{dx}\n=2u\\cdot\\frac{du}{dx}.\\label{ALeibnizMethod}\n\\end{alignat}\nThe two notations say the same thing, but the Leibniz notation \nhas several advantages, two of which we point out here:\n\\begin{itemize}\n\\item  Resemblance to algebraic manipulations: it appears\nthat we simply decomposed  $\\frac{d\\,u^2}{dx}$ by\ndividing and multiplying by\n$du$, yielding derivatives that made sense and could be\ncalculated by known rules: the first by the power rule,\nand the second by whatever method gives us $u'(x)$.\n\\item Variable of differentiation appears explicitly:\nwe know when we are taking the derivative with respect\nto $x$, and when it is with respect to $u$.  \n\\end{itemize}\nCompare (\\ref{ALeibnizMethod})  to our partial proof from the last subsection.\nBefore giving more computational examples, we will look at another argument\nfor the validity of the chain rule.  We begin with a very simple example. \n\\bex\nSuppose we have a vehicle\nwhich always achieves a fuel efficiency rating of 35 mile/gallon,\nand each gallon costs \\$1.40.  Then we can ask\nwhat is the cost per mile.  We can think of this situation\nas total cost $C$ being a function of total gallons consumed $g$,\ni.e., $C=C(g)$  and total\ngallons as a function of total miles, i.e., $g=g(m)$.\nUltimately cost is then a (composite) function of miles,\ni.e., $C=C(g(m))$.  Now cost per mile will be cost per gallon\ntimes gallons per mile.  In other words, the  rate of change in $C$\nwith respect to total miles $m$ is\n\\begin{equation}\n\\underbrace{\\frac{\\$1.40}{\\text{ gallon}}}_{\\ds{\\frac{dC}{dg}}}\n\\ \\cdot\\ \n\\underbrace{\\frac{1\\text{ gallon}}\n{35\\text{\\vphantom{g} mile}}}_{\\ds{\\frac{dg}{dm}}}\n=\\underbrace{\n\\vphantom{\\frac{\\$1.40}{\\text{ gallon}}}\n\\$0.04/\\text{mile}}_{\\ds{\\frac{dC}{dm}}}.\n\\label{DollarsPerMileExampleEquation}\\end{equation}\n\\begin{pspicture}(-6,0)(6,0)\n\\rput(0.14,.8){$\\cdot$}\n\\rput(1.9,.8){$=$}\n\\end{pspicture}\n\\eex\nThis  example  is simple because these rates do not change.\nStill, it is reasonable that\neven if these rates $dC/dg$ and $dg/dm$ only\nhold for an instant in time, {\\it during that instant} $\\frac{dC}{dm}$\nwill still be the product $\\frac{dC}{dg}\\cdot\\frac{dg}{dm}$ as above.\n(This is not a proof, but an argument for reasonableness.)\nFor that reason, we can similarly do the following\n(but where the ``instant'' is a particular value of $x$):\n\\begin{equation}\\frac{d\\,(x^3+1)^2}{dx}\n=\\frac{d\\,(x^3+1)^2}{d(x^3+1)}\\cdot\\frac{d\\,(x^3+1)}{dx}\n=2(x^3+1)^1\\cdot3x^2.\\label{ChainRuleDecompFor(x^3+1)^2}\\end{equation}\nThat $d(x^3+1)^2/d(x^3+1)=2(x^3+1)$ is not much different from\nthe argument in Figure~\\ref{XTU}, page~\\pageref{XTU},\nexcept the ``horizontal axis''\nwould be $(x^3+1)$ while the vertical would be $(x^3+1)^2$.\nThe derivative with respect to $x$---which is a ``hidden''\nvariable upon which the others depend---is found by compensation,\nthat is, the rate of change of $(x^3+1)^2$ with respect to \n$x$ is found by first finding its rate of change with respect\nto $(x^3+1)$, and then multiplying by a compensating factor\nwhich is the rate of change of $(x^3+1)$ with respect to $x$.\n\nHere we want to know how $(x^3+1)^2$ changes with respect to\n$x$, so we first ask how does $(x^3+1)^2$ changes\nwith respect to $(x^3+1)$, i.e.,  how does the square\nof a quantity change with respect to that \nquantity (power rule)---and \nmultiply by how $(x^3+1)$ changes as $x$ changes.\\footnote{%\n%%% FOOTNOTE\nThis is somewhat similar to compensating for unmatched units in physics or\nchemistry problems.  If we travel 60 miles in 75 minutes, and\nwe want our average speed in miles/hour, we can first find miles/minute,\nand then multiply by a compensating factor which relates minutes\nto hours:\n$$\\text{speed}=\\frac{60\\text{ mile}}{75\\text{ minute}}\n              =0.8\\ \\frac{\\text{mile}}{\\text{minute}}\n                 \\qquad\\cdot\\underbrace{\\frac{60\\text{ minute}}\n                     {1\\text{ hour}}}_{%\n                  \\overset{\\ds{\\text{compensating}}}{\\ds{\\text{factor}}}}\n              =48\\,\\frac{\\text{mile}}{\\text{hour}}.$$\nSince the question was how the distance relates to hours, we first\ndid the easy computation relating distance to minutes, and \nthen compensated by multiplying how minutes relate to hours.\n%%% END FOOTNOTE\n}%\n\\hphantom{. }%\nWith this kind of argument we can extend the power rule \nto have a chain rule version,\n\\begin{align}\n\\frac{du^n}{dx}&=\\underbrace{\\frac{du^n}{du}}_{||}\\cdot\\,\\frac{du}{dx},\\quad\n                     \\text{i.e.,}\\notag\\\\\n\\frac{du^n}{dx}&=nu^{n-1}\\cdot\\frac{du}{dx}.\\label{PowerRuleWithChainRule}\n\\end{align}%\n\\bex We can now quickly calculate the following \nderivatives, which would be more difficult without the chain rule:\n\\begin{itemize}\n\\item $\\ds{\\frac{d\\,(29x-x^2)^4}{dx}\n=4(29x-x^2)^3\\cdot\\frac{d}{dx}(29x-x^2)\n=4(29x-x^2)^3(29-2x)}$.\n\\item $\\ds{\\frac{d\\,(x+21)^9}{dx}=9(x+21)^8\\cdot\\frac{d(x+21)}{dx}\n           =9(x+21)^8\\cdot 1=9(x+21)^8}$. Note that \noccasionally the derivative $\\frac{du}{dx}$ \nof the ``inner function'' is just $1$.\n\\item $\\ds{\\frac{d}{dx}(5x-9)^8=8(5x-9)^7\\cdot\\frac{d}{dx}(5x-9)\n=8(5x-9)^7\\cdot5=40(5x-9)^7}$.\n\n\\end{itemize}\n\\eex\n%\nWhen we computed $\\frac{d}{dx}(5x-9)^8$, we could have written\n\\begin{equation}\n\\frac{d(5x-9)^8}{dx}=\\frac{d(5x-9)^8}{d(5x-9)}\\cdot\\frac{d(5x-9)}{dx}\n=8(5x-9)^7\\cdot5,\\label{ExampleForExpandedStyleOnChainRulesW/Powers}\n\\end{equation}\nand this is quite correct.  However it is not standard practice to\nwrite the middle step.  Indeed most authors prefer to avoid\nhaving complicated expressions in the denominator of a\ndifferential operator, preferring denominators as in\n$\\frac{d}{dx}$, $\\frac{d}{dt}$, $\\frac{d}{du}$,\netc.  In this text we will still occasionally \nwrite as in (\\ref{ExampleForExpandedStyleOnChainRulesW/Powers})\nfor clarity (which is akin to using a truth table\nto show a style of argument is valid), \nbut more often we will just state the\nchain rule version (\\ref{PowerRuleWithChainRule})  of the power rule with the \ncorrect terms in place of the general $u$:\n\\begin{equation}\\frac{d}{dx}(5x-9)^8=8(5x-9)^7\\cdot\\frac{d}{dx}(5x-9)\n=8(5x-9)^7\\cdot5=40(5x-9)^7,\\label{ExampleForStyleOnChainRulesW/Powers}\n\\end{equation}\nas in the example.  The kind of thinking that one can often settle\ninto for such examples is that we are taking the derivative,\nwith respect to $x$, of\na quantity raised to the eighth power, which gives us\neight times the quantity to the seventh power, but then times\nthe derivative of that quantity with respect to $x$ (to compensate\nfor the fact that we first took the derivative of the quantity\nto the eighth power {\\it with respect to that quantity} and\nnot with respect to $x$).  That way of thinking fits nicely into\nthe ``prime'' statement of the chain rule, and is clearly illustrated\nby the Leibniz-style decomposition of the derivative into the\ntwo factors $\\frac{d(5x-9)^8}{dx}=\n\\frac{d(5x-9)^8}{d(5x-9)}\\cdot \\frac{d(5x-9)}{dx}$, but also\ngives us a shortcut---albeit not for the careless---for\ncomputing these derivatives.\n\n{\\bf The reader is encouraged in the strongest possible terms to \nalways write the first step of ``power rule with chain rule''\nproblems as in (\\ref{ExampleForStyleOnChainRulesW/Powers})\nin practice.}  This will avoid errors, and will reinforce\nthe proper use of the chain rule version of the\npower rule, (\\ref{PowerRuleWithChainRule}).\nWe now list several further examples of this rule.\n\n\\begin{itemize}\n\\item $\\ds{\\frac{d\\,(2x+9)^3}{dx}=3(2x+9)^2\\cdot\\frac{d}{dx}(2x+9)\n                     =3(2x+9)^2\\cdot2=6(2x+9)^2}$.\n\\item $\\ds{\\frac{d\\,\\sin^2x}{dx}\n             =\\frac{d}{dx}(\\sin x)^2\n             =2(\\sin x)\\frac{d}{dx}\\sin x\n             =2\\sin x\\cos x}$.\n\\item $\\ds{\\frac{d}{dx}(x^2+\\cos x)^4=\n            4(x^2+\\cos x)^3\\frac{d}{dx}(x^2+\\cos x)\n            =4(x^2+\\cos x)^3(2x-\\sin x)}$.\n\\item $\\ds{\\frac{d}{dx}\\left(3x^2+6x+7\\right)^7\n            =7\\left(3x^2+6x+7\\right)^6\\cdot\n             \\frac{d}{dx}\\left(3x^2+6x+7\\right)}$\n\n            \\qquad $\\ds{=7\\left(3x^2+6x+7\\right)^6\\left(6x+6\\right)\n            =7(3x^2+6x+7)^6\\cdot6(x+1)=42(3x^2+6x+7)(x+1)}$.\n\\end{itemize}\nNote that the chain rule version of the power rule,\n$\\frac{d\\,u^n}{dx}=nu^{n-1}\\cdot\\frac{du}{dx}$,\ndoes not contradict the earlier power rule that $\\frac{d\\,x^n}{dx}\n=nx^{n-1}$. \nFor instance, when ``$u$'' is equal to $x$, we can write\n$$\\frac{d\\,x^9}{dx}=9x^8\\cdot\\frac{dx}{dx}=9x^8\\cdot1=9x^8,$$\nwhich agrees with our original power rule, which here would\ngive us $\\frac{d\\,x^9}{dx}=9x^8$. Thus chain rule version of the power rule\nin fact generalizes the original power rule.\n\\subsection{Chain Rule Derivatives of Sine and Cosine}\nNow we look at derivatives of $\\sin u$ and $\\cos u$ with \nrespect to $x$, assuming $u=u(x)$, i.e., that $u$ is actually\na function of $x$.  Recall (\\ref{SineDerivative}) and\n(\\ref{CosineDerivative}) from page \\pageref{SineDerivative}:\n$\\frac{d\\sin x}{dx}=\\cos x$ and $\\frac{d\\cos x}{dx}=-\\sin x$.\nThe chain rule versions of the \nderivatives of sine and cosine then become\n\\begin{align}\n\\frac{d\\sin u}{dx}&=\\cos u\\cdot\\frac{du}{dx},\\label{DerivativeSineU}\\\\\n\\frac{d\\cos u}{dx}&=-\\sin u\\cdot\\frac{du}{dx}.\\label{DerivativeCosineU}\n\\end{align}\nThe proofs utilize the Leibniz notation's decomposition pattern as before:\n\\begin{alignat*}{2}\n\\frac{d\\sin u}{dx}&=\\frac{d\\sin u}{du}\\cdot\\frac{du}{dx}&&=\n                                     \\cos u\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\cos u}{dx}&=\\frac{d\\cos u}{du}\\cdot\\frac{du}{dx}&&=\n                                     -\\sin u\\cdot\\frac{du}{dx},\n\\end{alignat*}\nq.e.d.  Now we are free to use (\\ref{DerivativeSineU})\nand (\\ref{DerivativeCosineU}) where applicable.\nIn the next example we show two methods of computing a particular\nderivative: using a Leibniz-style decomposition, and \napplying (\\ref{DerivativeSineU}) directly.\n\\bex If $f(x)=\\sin x^2$, then we can compute $f'(x)$ the following\ntwo ways:\n\\begin{align}\n\\frac{d\\sin x^2}{dx}&=\\frac{d\\sin x^2}{dx^2}\\cdot\\frac{dx^2}{dx}\n                     =\\cos x^2\\cdot 2x=2x\\cos x^2,\\label{LeibStySinXX}\\\\\n\\frac{d\\sin x^2}{dx}&=\\cos x^2\\cdot\\frac{dx^2}{dx}=\\cos x^2\\cdot2x=\n                       2x\\cos x^2.\\label{LeibStyAbbrevSinXX}\\end{align}\n\\eex\nIn the second method (\\ref{LeibStyAbbrevSinXX}) \nfor computing the derivative above,\nwe did just insert $u=x^2$ into (\\ref{DerivativeSineU}),\nbut the justification for that can also be seen in the first \nmethod (\\ref{LeibStySinXX})  with the Leibniz-style decomposition.\nNote also that we computed this same derivative in\nExample~\\ref{SinXXWithPrimes}, page \\pageref{SinXXWithPrimes}\nusing the prime notation.\n\n\\bex Compute $\\frac{d\\,f(z)}{dz}$ if $f(z)=\\cos(z^3+\\sin z)$.\n\n\\underline{Solution}: Here the names of the variables have changed,\nbut the principle of the chain rule is the same.  Again we will\ncompute this two ways, the second\n using (\\ref{DerivativeCosineU}),\nexcept with $z$ in place of $x$:\n\\begin{align*}\nf'(z)&=\\frac{d}{dz}\\,\\cos(z^3+\\sin z)\n      =\\frac{d\\cos(z^3+\\sin z)}{d(z^3+\\sin z)}\n         \\cdot\\frac{d(z^3+\\sin z)}{dz}\n      =-\\sin(z^3+\\sin z)\\cdot(3z^2+\\cos z),\\\\\nf'(z)&=\\frac{d}{dz}\\,\\cos(z^3+\\sin z)\n      =-\\sin(z^3+\\sin z)\\cdot\\frac{d(z^3+\\sin z)}{dz}\n      =-\\sin(z^3+\\sin z)\\cdot(3z^2+\\cos z).\n\\end{align*}\n\\eex\nAccepted practice is to compute the above derivative using the latter\nmethod, and so that is the method students should eventually strive to\nreproduce. As in an earlier discussion involving the power\nrule, one can think of this example as using the thought pattern\nthat says {\\it the derivative of cosine is minus sine\\dots,\nmultiplied by the derivative of what is inside the cosine. }%\nThat is perhaps an over-simplification, and should be informed by awareness\nof what we get from the Leibniz-style expansion.\n\nTo be clear on what (\\ref{DerivativeSineU}) and (\\ref{DerivativeCosineU})\nsay, and why these should hold, consider the following abstract\nequations, which are in fact restatements of (\\ref{DerivativeSineU}):%\n\\footnotemark\n\\begin{alignat*}{2}\n\\frac{d\\sin u}{dw}&=\\frac{d\\sin u}{du}\\cdot\\frac{du}{dw}\n                  &&=\\cos u\\cdot\\frac{du}{dw},\\\\\n\\frac{d\\sin\\theta}{d\\xi}&=\\frac{d\\sin\\theta}{d\\theta}\\cdot\\frac{d\\theta}{d\\xi}\n                  &&=\\cos\\theta\\cdot\\frac{d\\theta}{d\\xi},\\\\\n\\frac{d\\sin x}{dt}&=\\frac{d\\sin x}{dx}\\cdot\\frac{dx}{dt}\n                  &&=\\cos x\\cdot\\frac{dx}{dt}.\\end{alignat*}\n\\footnotetext{%\n%%% FOOTNOTE\nJust to be sure, it should be pointed out that when we write for instance\n$\\cos x\\cdot\\frac{dx}{dt}$, we mean that the $\\frac{dx}{dt}$ is outside\nof the cosine function, i.e., we mean $(\\cos x)\\cdot\\frac{dx}{dt}$.\nNote that many texts assume this meaning without making it explicit with\nthe dot ``$\\cdot$,'' and simply write $\\cos x\\,\\frac{dx}{dt}$.\nAs a matter of style, it is assumed the derivative $\\frac{dx}{dt}$ is\nnot part of the argument of the cosine function in such a case.\n%%% END FOOTNOTE\n}\n\n\\noindent Note that in all the cases, the decomposition's first\nfactor let us use the known derivative formula for sine---because\nthe variables matched---and then we compensated for introducing\nthe new variable's derivative (as a fraction of differentials)\nwith the second factor.\n\n\nWe now point out that it is quite common for the chain\nrule to apply more than once in a particular problem. \nOur next example below shows a case of a function\nwithin a function within a function, and the example\nfollowing will be a sum of two functions, each requiring\na chain rule.\n\n\\bex Compute $\\frac{d}{dx}\\left[\\sin^3(4x)\\right]$.\n\n\\underline{Solution}:  Note that the function can be \nrewritten $\\left[\\sin4x\\right]^3$.  \nNow we compute the derivative, first applying the power rule\nversion of the chain rule (\\ref{PowerRuleWithChainRule}), page\n\\pageref{PowerRuleWithChainRule}, and then \n(\\ref{DerivativeSineU}), page \\pageref{DerivativeSineU}.\nThen we show the same computation using the Leibniz-style decomposition.\n\\begin{align*}\n\\frac{d[\\sin4x]^3}{dx}&=3[\\sin4x]^2\\cdot\\frac{d\\sin4x}{dx}\\\\\n                      &=3\\sin^24x\\cdot\\cos4x\\frac{d(4x)}{dx}\\\\\n                      &=3\\sin^24x\\cos4x\\cdot4=12\\sin^24x\\cos4x.\\\\\n\\frac{d[\\sin4x]^3}{dx}\n  &=\\frac{d[\\sin4x]^3}{d[\\sin4x]}\\cdot\\frac{d\\sin4x}{d(4x)}\\cdot\n                   \\frac{d(4x)}{dx}\\\\\n  &=3[\\sin4x]^2\\cdot\\cos4x\\cdot4=12\\sin^24x\\cos4x.\\end{align*}\n\\eex\nSo the Leibniz-style decomposition will work for longer ``chains''\nof functions within functions.  But so will the abbreviated \nchain rules which say $\\frac{du^3}{dx}=3u^2\\cdot\\frac{du}{dx}$,\nand $\\frac{d\\sin u}{dx}=\\cos u\\cdot\\frac{du}{dx}$, which was\nthe first approach in the computations above: after applying\nthe power rule, the ``inner'' derivative called another\nchain rule.\\footnote{%%%\n%%% FOOTNOTE\nThis phenomenon of ``rules calling other rules'' occurs repeatedly\nthroughout the rest of the textbook.  We will see it occasionally\nin this section, and it will become the norm in later sections.\n%%% END FOOTNOTE\n}\n  Again, it is best\nto strive for the abbreviated approach in practice, though\nboth approaches are worth studying (and of course the decomposition\nexplains the abbreviated approach).\n\n\\bex Find $f'(x)$ if $f(x)=\\sin^2x+\\cos^2x$.\n\n\\underline{Solution}: The larger structure of this function is that\nof a sum of two functions, so first we use the sum rule,\nwhich tells us to add (and thus first compute) the derivatives\nof $\\sin^2x$ and $\\cos^2x$.  These are then both chain rules.\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left[\\sin^2x+\\cos^2x\\right]\\\\\n    &=\\frac{d}{dx}\\left[\\sin^2x\\right]+\\frac{d}{dx}\\left[\\cos^2x\\right]\\\\\n    &=\\frac{d}{dx}\\left[(\\sin x)^2\\right]+\\frac{d}{dx}\\left[(\\cos x)^2\\right]\\\\\n    &=2(\\sin x)\\frac{d}{dx}\\sin x+2(\\cos x)\\frac{d}{dx}\\cos x\\\\\n    &=2\\sin x\\cos x+2\\cos x(-\\sin x)\\\\\n    &=2\\sin x\\cos x-2\\cos x\\sin x\\\\\n    &=0.\\end{align*}\nActually this is what we should hope would be the answer, for the original\nfunction we are taking the derivative of is actually constant:\n$$\\frac{d}{dx}\\left[\\sin^2x+\\cos^2x\\right]=\\frac{d}{dx}[1]=0.$$\n\\eex\nIt happens frequently in calculus that it is advantageous to algebraically\nrewrite a function before taking its derivative.  In fact we did that\neach time we took a derivative of $\\sin^2x=(\\sin x)^2$, the latter\nnotation being more obvious in illustrating the composition\n(function inside of a function) structure of the original function.\nFor calculus to be consistent (which it is, so no need to fear!),\nwe should be able to rewrite the function and get the same derivative,\nas long as we rewrite the function correctly.  The derivative rules\nare eventually sufficient to compute the derivative no matter how\nthe function is rewritten, but some forms of a given function\nare easier to deal with than others.\n\n\\subsection{Power Rule for Rational Powers}\n\nWith the chain rule we have enough theoretical development to \nshow that the power rule actually holds for any constant\npower which is a rational number $p/q$ (where $p,q\\in\\mathbb{Z}$,\nand of course $q\\ne0$). \nRecall that the set of all rational\nnumbers was denoted $\\mathbb{Q}$, for ``quotients,'' i.e., \nfractions, of integers.  We already proved the rule for powers\n$n\\in\\{0,1,2,3,\\cdots\\}$, and that result is used in the \nproof for rational powers which we leave the proof until the end\nof this section, so we can expeditiously come to examples.\nBut first, the theorem.\n\n\\begin{theorem}{\\rm\\bf(Power Rule for Rational Powers)}\nFor any $r\\in\\mathbb{Q}-\\{0\\}$ (i.e., nonzero rational numbers), \n\\begin{align}\n\\frac{d\\,x^r}{dx}&= rx^{r-1},\\label{RationalPowerRuleEquation}\\\\\n\\frac{d\\, u^r}{dx}&=ru^{r-1}\\cdot\\frac{du}{dx}.\n\\label{ChainRuleVersionOfPowerRule}\\end{align}\n\\label{PowerRuleForRationalPowers}\\end{theorem}\n\\bex For example, the following (which was an exercise with\ndifference quotient limits in Section~\\ref{DerivativeSection1})\nyields quickly to the power rule:\n$$\\frac{d\\,\\sqrt{x}}{dx}=\\frac{d\\,x^{1/2}}{dx}\n=\\frac12x^{1/2-1}=\\frac12x^{-1/2}=\\frac1{2\\sqrt{x}}.$$\n\\eex\nIn fact, this particular derivative occurs often enough\nthat it, along with its chain rule \nversion, deserves special attention\n(and should be committed to memory):\n\\begin{align}\n\\frac{d\\,\\sqrt{x}}{dx}&=\\frac1{2\\sqrt{x}},\\\\\n \\frac{d\\,\\sqrt{u}}{dx}&=\\frac{1}{2\\sqrt{u}}\\cdot\\frac{du}{dx}.\n\\end{align}\n\\bex Find $f'(x)$ for $\\ds{f(x)=\\sqrt{x^2+1}}$.\n$$f'(x)=\\frac{d}{dx}\\sqrt{x^2+1}=\\frac1{2\\sqrt{x^2+1}}\\cdot\\frac{d}{dx}\n\\left(x^2+1\\right)=\\frac1{2\\sqrt{x^2+1}}\\cdot(2x)\n=\\frac{x}{\\sqrt{x^2+1}}.$$\\eex\nNote that in the above example\nthe ``outer'' function was the square root, while\nthe ``inner'' function is $x^2+1$.  One could write (though\nagain, it is not standard practice):\n$$\\frac{d}{dx}\\sqrt{x^2+1}=\n \\frac{d\\sqrt{x^2+1}}{d(x^2+1)}\\cdot\\frac{d(x^2+1)}{dx}\n=\\frac1{2\\sqrt{x^2+1}}\\cdot2x=\\frac{x}{\\sqrt{x^2+1}}.$$\n\n\\bex Suppose $f(x)=\\sqrt{x+\\sqrt{x}}$.  Then the Leibniz decomposition\nwould look like\n$$\n\\frac{d f(x)}{dx}\n=\\frac{d\\sqrt{x+\\sqrt{x}}}{d\\left(x+\\sqrt{x}\\right)}\n    \\cdot\\frac{d\\left(x+\\sqrt{x}\\right)}{dx}\n=\\frac1{2\\sqrt{x+\\sqrt{x}}}\\cdot\\left(1+\\frac1{2\\sqrt{x}}\\right).$$\nAgain---and especially with practice---one would usually not\nwrite the decomposition in the first step, but should\ninstead write\n$$\\frac{d}{dx}\\sqrt{x+\\sqrt{x}}=\\frac1{2\\sqrt{x+\\sqrt{x}}}\n  \\cdot\\frac{d\\left(x+\\sqrt{x}\\right)}{dx}\n   =\\frac1{2\\sqrt{x+\\sqrt{x}}}\\cdot\\left(1+\\frac1{2\\sqrt{x}}\\right).$$\n\\eex\nA common mistake in the above example is to think of $\\sqrt{x}$\nas the inner function, since geometrically it somehow appears\nto be innermost.  In fact the inner function is actually the whole\nof $x+\\sqrt{x}$.\n\\bex Suppose $\\ds{f(x)=\\frac2{(x^3-9x+7)^7}}$.  Then\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left[2(x^3-9x+7)^{-7}\\right]\\\\\n     &=2\\cdot(-7)(x^3-9x+7)^{-8}\\frac{d}{dx}(x^3-9x+7)\\\\\n     &=-14(x^3-9x+7)^{-8}(3x^2-9)\\\\\n     &=\\frac{-14(3x^2-9)}{(x^3-9x+7)^8}.\\end{align*}\n\\eex\nIn the previous example we were able to use the \nchain rule version (\\ref{ChainRuleVersionOfPowerRule})\nof the power rule once we wrote the function as\na power of a polynomial, albeit negative and with a multiplicative constant\nalong for the ride.  The next example calls for a rewriting (for simplicity),\nand then calls the chain rule twice.\n\n\\bex $\\ds{f(x)=\\sqrt[3]{\\frac1{x+\\sqrt{x^3+9}}}}$.\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left[\\sqrt[3]{\\frac1{x+\\sqrt{x^3+9}}}\\,\\right]\\\\\n&=\\frac{d}{dx}\\left(x+\\sqrt{x^3+9}\\,\\right)^{-1/3}\\\\\n&=-\\frac13\\left(x+\\sqrt{x^3+9}\\,\\right)^{-4/3}\n   \\cdot\\frac{d}{dx}\\left(x+\\sqrt{x^3+9}\\,\\right)\\\\\n&=-\\frac13\\left(x+\\sqrt{x^3+9}\\right)^{-4/3}\n \\cdot\\left[1+\\frac1{2\\sqrt{x^3+9}}\\cdot\\frac{d}{dx}(x^3+9)\\right]\\\\\n&=-\\frac13\\left(x+\\sqrt{x^3+9}\\right)^{-4/3}\n \\cdot\\left[1+\\frac{3x^2}{2\\sqrt{x^3+9}}\\right]\n\\end{align*}\\eex\nIn the calculation above, we first rewrote the expression as a\n$\\frac{-1}3$ power, then used the chain rule version of the\npower rule, and used the chain rule {\\it again} in calculating\nthe derivative of that ``inner'' function.\n\n\n\n\nNow we prove the power rule for rational numbers\n$$r\\in\\mathbb{Q}\\implies\\frac{d\\,x^r}{dx}=rx^{r-1},$$\nfrom which the chain rule version also follows.\nThe proof is in two steps, the first being a proof in the case\nof negative integer powers, from  which we can eventually\nrecover all rational power cases.\n\n\\begin{proof}\nNow we will use the chain rule to show that the\npower rule, $\\frac{d}{dx}x^r=rx^{r-1}$, holds\nalso for any rational power $r=p/q$, with \n$p,q$ nonzero integers.   (The case $p=0$ is trivial\nand the case $q=0$ is meaningless.)\nThe proofs below are included for completeness,\nand also because they foreshadow a method we\nwill use extensively later in the text, that\nmethod being {\\it implicit differentiation}.\n\nFirst we will show that the power rule holds\nfor $y=x^n$ for any negative integer exponents  $n$. \nIn such cases we can write\n$y=x^{-m}$ for a positive integer exponent $m$ (namely $-n$).\nBut then $y^{-1}=x^m$.  Furthermore  we already showed \nin Section~\\ref{DerivativeSection1} \n(Example~\\ref{FunctionWithTangentsExample3},\npage \\pageref{FunctionWithTangentsExample3}) that \nthe derivative definition gives us\n$\\frac{dy^{-1}}{dy}=-1/y^2$ (though the variable used in the\nproof there was $x$).\nUsing this and the chain rule, we get\n\\begin{alignat*}{2}\n&&y^{-1}&=x^m\\\\\n&\\implies\\qquad&\\frac{d}{dx}\\left[y^{-1}\\right]&=\\frac{d}{dx}\\left[x^m\\right]\\\\\n&\\implies&-\\frac1{y^2}\\cdot\\frac{dy}{dx}&=mx^{m-1}\\\\\n&\\implies&\\frac{dy}{dx}&=-y^2mx^{m-1}\\\\\n&&&=-(x^n)^2(-n)x^{-n-1}\\\\\n&&&=nx^{2n-n-1}\\qquad=nx^{n-1},\\qquad\\text{q.e.d.}\n\\end{alignat*}\n\nIt is important to that we interpret the first implication\ncorrectly.  Recall that $y=x^n$, so $y$ is a function\nof $x$.  But then so is $y^{-1}$ and, in fact,\n$y^{-1}$ and $x^m$ are {\\it the same functions of $x$}.\nHence, if $y^{-1}$ and $x^m$ were graphed versus $x$, the\ngraphs would be the same, so the slopes at each $x$-value would\nbe the same. Therefore $y^{-1}$ and $x^m$ have the same \nderivative with respect to $x$.\n\nNow we will use the chain rule in a similar way to compute the derivatives\nof rational powers of $x$.  Suppose $y=x^{p/q}$, where\n$p,q\\in\\mathbb{Z}-\\{0\\}$ are nonzero integers,\nand that $r=p/q$ is in simplified form.  Then we can raise both\nsides of $y=x^{p/q}$ to the power $q$ to get\\footnotemark\n\\footnotetext{%\n%%%%%%% FOOTNOTE\nNote that $p$ or $q$ (but not both, since $p/q$ is simplified)\ncould be negative, but what we are about to do is justified\nby the previous result that the power rule also works for negative\ninteger exponents.\n%%%%%%%%  END FOOTNOTE\n}\n\\begin{alignat*}{2}\n&&y^q&=x^p\\\\\n&\\implies\\qquad&\\frac{d\\,y^q}{dx}&=\\frac{d\\,x^p}{dx}\\\\\n&\\implies\\qquad&qy^{q-1}\\frac{dy}{dx}&=px^{p-1}\\\\\n&\\implies&\\frac{dy}{dx}&=\\frac{p}{q}y^{1-q}x^{p-1}\n                       =\\frac{p}q\\left(x^{p/q}\\right)^{1-q}x^{p-1}\n                       =\\frac{p}q\\cdot x^{\\frac{p}q-p}x^{p-1}\n                       =\\frac{p}q\\cdot x^{\\frac{p}q-1},\\end{alignat*}\nwhich can be rewritten  $\\frac{dy}{dx}=rx^{r-1}$.  Thus $y=x^r$ implies the \nform that we sought to prove for the derivative.\n\\end{proof}\n\nIn fact, once we have logarithms we can define $y=x^r$ for all $r\\in\\Re$,\nand find again that the derivative is given by the same formula as\nin our power rules here.\n\\newpage\n\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item Find the following derivatives using the power rule.\nYou may need to rewrite a function as a power, but the\nchain rule will not be necessary in any case.\n(One could make these into chain rule problems, but \nthat will be the more difficult approach in each.)\n\\begin{enumerate}\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac1{x^{11}}\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac1{\\sqrt{x}}\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\sqrt[3]{x^4}\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac{6}{x}\\right]}$.\n\\item $\\ds{\\frac{d}{dt}\\left[\\frac1{2t^2}\\right]}$.\n\\item $\\ds{\\frac{d}{dy}\\left[\\sqrt{9y}\\right]}$\n\\end{enumerate}\n\n\\item Find the following derivatives.\n\\begin{enumerate}\n\\item $\\ds{\\frac{d}{dx}\\left[(1-9x)^{11}\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[27(3x^2-10x+55)^2\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\sqrt{2x^5-1}\\right]}$\n\\item $\\ds{\\frac{d}{dx}(3x+1)^2}$.  (Do two ways: chain rule,\nand by first expanding the square.)\n\\end{enumerate}\n\\item $f'(x)$ for each of the following:\n\\begin{enumerate}\n\\item $\\ds{f(x)=(x+5)^{100}}$.\n\\item $\\ds{f(x)=(2x+5)^{100}}$.\n\\item $\\ds{f(x)=\\frac{1}{(x^4-x+1)^3}}$.\n\\item $\\ds{f(x)=\\sqrt{x+\\sqrt{x+\\sqrt{x}}}}$.\n\\end{enumerate}\n\\item Compute the following derivatives:\n\\begin{enumerate}\n\\item $\\ds{\\frac{d\\sin z}{dx}}$\n\\item $\\ds{\\frac{d\\cos\\theta}{dt}}$\n\\item $\\ds{\\frac{d\\,x^7}{dt}}$\n\\item $\\ds{\\frac{d\\sin(\\cos x)}{d\\cos x}}$\n\\end{enumerate}\n\\item Compute the following derivatives:\n\\begin{enumerate}\n\\item $\\ds{\\frac{d\\sin\\sqrt{x}}{dx}}$\n\\item $\\ds{\\frac{d}{dx}\\sqrt{\\sin x}}$\n\\item $\\ds{\\frac{d\\sin(\\cos x)}{dx}}$\n\\item $\\ds{\\frac{d}{dx}\\cos^3x}$\n\\item $\\ds{\\frac{d}{dx}\\cos(x+\\cos x)}$\n\\end{enumerate}\n\\item Find $h'(9)$ if $h(x)=f(g(x))$, $g(9)=5$, $g'(9)=2$, and\n        $f'(5)=7$.\n\\item On the unit circle, $y^2=1-x^2$.  If we take either the\nupper semicircle or the lower semicircle, then $y$ is also\na function of $x$.  Find the tangent line to the graph at\nthe point $(3/5,4/5)$ by finding $\\frac{dy}{dx}$ two ways:\n\\begin{enumerate}\n\\item Using $\\ds{y=\\sqrt{1-x^2}}$ for the upper semicircle, and\nthe chain rule.\n\\item By applying $\\frac{d}{dx}$ to both sides of $y^2=1-x^2$,\nas we did in the proof of Theorem~\\ref{PowerRuleForRationalPowers},\nand then solving for $\\frac{dy}{dx}$, and plugging into that\nexpression $(x,y)=(3/5,4/5)$.\n\\end{enumerate}\n\\item Using $\\sec x=(\\cos x)^{-1}$, \n\\begin{enumerate}\n\\item derive\n$\\ds{\\frac{d}{dx}\\sec x=\\sec x\\tan x}$.\n\\label{FindSecant'sDerivativeWithChainRuleExercise} \n\\item\nUse (a) and the chain rule to\ncompute\n$\\ds{\\frac{d}{dx}\\sec\\sqrt{x^2+1}}$.\n\\end{enumerate}\n\n\n\n\n\\end{enumerate}\n\n\n\n\n\\end{multicols}\n\n\n\\newpage\n\\newpage\n\\section{Product, Quotient and Other Trigonometric Rules}\nIn this section we first introduce the rule for the differentiation\nof a product of two functions.  From that and the chain rule,\nwe will derive a rule for differentiating a quotient of two\nfunctions.  With a quotient rule we will be able to \nuse the rules for $\\sin x$ and $\\cos x$ to\nderive rules for $\\tan x$ and $\\cot x$.  For completeness\nwe will also compute the rules for $\\sec x$ and $\\csc x$\nand thus finish\nour rules for the six basic trigonometric functions.   \n\nThe rules for calculating the derivative of a product or\na quotient are not as simple as for a sum or difference.\nHowever they are straightforward when applied correctly.\n\n\\subsection{Product Rule Stated and First Applied}\nWe begin with the statement and some discussion of the product rule,\nfollowed by several examples demonstrating its mechanics.  \nThe actual proof we leave until the next subsection.\n\\begin{theorem}{\\rm\\bf(Product Rule)} \nAt each $x$ for which $\\frac{d}{dx}f(x)$\nand $\\frac{d}{dx}g(x)$ exist, so\ndoes the derivative\n$\\frac{d}{dx}\\left(f(x)\\cdot g(x)\\right)$ exist,\nand it is given by\n\\begin{equation}\n\\frac{d}{dx}\\left[f(x)\\cdot g(x)\\right]\n=f(x)\\frac{d}{dx}g(x)+g(x)\\frac{d}{dx}f(x).\n\\label{ProductRule}\\end{equation}\\label{ProductRuleTheorem}\n\\end{theorem}\nThough we defer the proof, we can make a couple of observations.\n\\begin{itemize}\n\\item This is {\\bf not} simply the product of the two\n      derivatives. (See for example \n      Exercise~\\ref{NoSimpleProductRuleExercise} in\n      Section~\\ref{FirstDiffRules}, page \n      \\pageref{NoSimpleProductRuleExercise}.)\n\\item Recall that multiplicative constants are preserved\n      in the derivative: $\\frac{d}{dx}(Cf(x))=C\\frac{d}{dx}f(x)$.\n      One could say the the constant ``amplifies'' the function by the \n      factor $C$, and that this amplifying factor is preserved in \n      the rate of change, or derivative, of the new function $Cf(x)$.\n      (For example, $C=2$ doubles the function, and thus doubles\n      the rate of change.)\n     \n      \\ \\ \\ Next notice that the first term of (\\ref{ProductRule})\n      treats $f(x)$ as though it were a constant amplifying the\n      change in (i.e., derivative of) $g(x)$, while the\n      second term treats $g(x)$ as though it were a constant\n      amplifying the change in $f(x)$.  In this way the\n      product rule accounts for the changes in each function,\n      as amplified by the other.  A close scrutiny of the\n      proof shows how this emerges.\n\\end{itemize}\\label{NotesOnProductRule}\n\nOur first example shows how the product rule gives us\nwhat we expect for a very simple case.\n\\bex Let $f(x)=x^5$.  Then $f'(x)=5x^4$ from the power rule.\nBut we can also write $f(x)=x^3\\cdot x^2$, from which the \nproduct rule gives\n$$\\frac{d}{dx}\\left[x^3\\cdot x^2\\right]\n=x^3\\cdot\\frac{d}{dx}(x^2)+x^2\\cdot\\frac{d}{dx}(x^3)\n=x^3\\cdot2x+x^2\\cdot3x^2=2x^4+3x^4=5x^4.$$\n\\eex\nOf course the product rule will be of much more \nuse than proving things we already knew.  The\nnext example requires the product rule\n(or some {\\it very} clever tricks with difference quotients!):\n\\bex Suppose $f(x)=x^2\\sin x$.  This is a product of\ntwo differentiable\\footnote{%\n%%%%%%%%%%%  FOOTNOTE\nIf the functions are not\ndifferentiable, this fact appears as we take the derivatives\non the right-hand side of the product rule statement\n(\\ref{ProductRule}).  Thus\nwe usually just apply the rule---instead of checking differentiability\nfirst.}%%%%%%%% END FOOTNOTE\n\\  functions.  Its derivative is given by\n$$f'(x)=\\frac{d(x^2\\sin x)}{dx}\n=x^2\\cdot\\frac{d\\sin x}{dx}+\\sin x\\cdot\\frac{d(x^2)}{dx}\n=x^2\\cos x+\\sin x\\cdot2x\n=x(x\\cos x+2\\sin x)\n$$\nThe last step was just an algebraic one, factoring the final answer\nas much as possible.\n\\eex\n\nNow we list several simple examples to illustrate the basic mechanics\nof the product rule.\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}\\left[(3x^2+5x-9)(5x^3+7x^2+27x-4)\\right]}$\n\n$\\ds{=(3x^2+5x-9)\\frac{d}{dx}(5x^3+7x^2+27x-4)\n +(5x^3+7x^2+27x-4)\\frac{d}{dx}(3x^2+5x-9)}$\n\n$\\ds{=(3x^2+5x-9)(15x^2+14x+27)+(5x^3+7x^2+27x-4)(6x+5)}$.\n\n\\item $\\ds{\\frac{d}{dx}(x\\cos x)=x\\cdot\\frac{d}{dx}\\cos x\n                           +\\cos x\\cdot\\frac{d}{dx}x\n    =x(-\\sin x)+\\cos x\\cdot1=-x\\sin x+\\cos x}$.\n%\\item $\\ds{\\frac{d}{dx}\\left[x\\sqrt[3]{x^2+1}\\right]\n%       =\\frac{d}{dx}\\left[x(x^2+1)^{1/3}\\right]\n%       =x\\frac{d}{dx}(x^2+1)^{2/3}+(x^2+1)^{1/3}]frac{d}{dx}{x}}$\n\\item $\\ds{\\frac{d}{dt}[PV]=P\\cdot\\frac{dV}{dt}+V\\cdot\\frac{dP}{dt}}$.\n\n\\end{itemize}\n\nOne of the interesting aspects of the calculus is the various ways\nthat the consistency of differentiation (derivative-taking) rules\ncan be seen by using different strategies for  particular derivatives.\nEarlier we showed how to use the product rule\nto compute $\\frac{d}{dx}(x^2\\cdot x^3)=5x^4$, which we also computed\nwith the power rule $\\frac{d}{dx}(x^5)=5x^4$.\nFor another example, the behavior of multiplicative constants in \ntaking derivatives gives us, for example,\n$\\frac{d}{dx}(2\\sin x)=2\\frac{d}{dx}\\sin x\n=2\\cos x$.  But we can also compute this with the product rule:\n$$\\frac{d}{dx}(2\\sin x)=2\\cdot\\frac{d}{dx}\\sin x+\\sin x\\cdot\\frac{d}{dx}(2)\n=2\\cos x+\\sin x\\cdot0=2\\cos x+0=2\\cos x,$$\nas before. Of course the rule on multiplicative constants \n(page \\pageref{TheoremOnDerivativeAndMultiplicativeConstants}) is faster.\n\n\nBecause the product rule calls for the derivatives of \nthe factors, it often calls upon other rules to compute\nthese component derivatives.  Conversely, other rules\nmay call upon the product rule.\nAs we saw with the chain rule, it is crucial that we\nlook at the overall structure of a function to see\nwhich rule to apply first, and then work our way in \ntowards the inner structures as the differentiation rules\nrequire in their turns.  The next two examples are product rules\nfirst, which then call the chain rule.\n\\bex Suppose $f(x)=\\sin x^2\\cos x^3.$  This is foremost\n     a product of two functions,\\footnote{%%%\n%%%% FOOTNOTE\nNote that $\\sin x^2\\cos x^3$ is taken to be a\nproduct.  Indeed, it is understood that\nthe sine and cosine functions here are separate factors.  The convention is to\nunderstand this function, as written, in the following way:\n$$\\sin x^2\\cos x^3=(\\sin x^2)(\\cos x^3).$$\nAlso note that $x^2$ is the argument of the sine, and $x^3$ the\nargument of cosine.  Thus this function could also be written\n$(\\sin(x^2))\\cdot(\\cos(x^3))$.\n%%%% END FOOTNOTE\n} so we need the product rule first.\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left[\\sin x^2\\cos x^3\\right]\\\\\n     &=\\sin x^2\\cdot\\frac{d}{dx}\\cos x^3+\\cos x^3\\cdot\\frac{d}{dx}\\sin x^2\\\\\n     &=\\sin x^2\\cdot\\left(-\\sin x^3\\cdot\\frac{d}{dx}x^3\\right)\n       +\\cos x^3\\cdot\\left(\\cos x^2\\cdot\\frac{d}{dx}x^2\\right)\\\\\n     &=(\\sin x^2)(-\\sin x^3)(3x^2)+\\cos x^3\\cos x^2\\cdot2x\\\\\n     &=-3x^2\\sin x^2\\sin x^3+2x\\cos x^3\\cos x^2.\n\\end{align*}\nThus, when we took the derivatives called for by the product rule, these\nrequired the chain rule.\n(We could have factored the final computation but it is not necessary.)\n\\eex\nFor a polynomial example, consider the following:\n\\bex $f(x)=(x^2+2x+3)^2(x^2+1)^3$.  Without the product\nrule we would be forced to carry out the multiplications,\nbut since this is written as\na product of two functions, we can instead use the product rule.\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left[(x^2+2x+3)^2(x^2+1)^3\\right]\\\\\n     &=(x^2+2x+3)^2\\cdot\\frac{d}{dx}(x^2+1)^3+(x^2+1)^3\\cdot\n            \\frac{d}{dx}(x^2+2x+3)^2\\\\\n     &=(x^2+2x+3)^2\\cdot3(x^2+1)^2\\cdot\\frac{d}{dx}(x^2+1)\n      +(x^2+1)^3\\cdot2(x^2+2x+3)^1\\frac{d}{dx}(x^2+2x+3)\\\\\n     &=(x^2+2x+3)^2\\cdot3(x^2+1)^2(2x)+(x^2+1)^3\\cdot2(x^2+2x+3)(2x+2)\\\\\n     &=6x(x^2+2x+3)^2(x^2+1)^2+(4x+4)(x^2+1)^3(x^2+2x+3)\\\\\n     &=(x^2+2x+3)(x^2+1)^2\\left[6x(x^2+2x+3)+(4x+4)(x^2+1)\\right]\\\\\n     &=(x^2+2x+3)(x^2+1)^2\\left[6x^3+12x^2+18x+4x^3+4x+4x^2+4\\right]\\\\\n     &=(x^2+2x+3)(x^2+1)^2\\left[10x^3+16x^2+22x+4\\right].\n\\end{align*}\nAgain, the statement of the product rule here called for\nderivatives of the factors, and each of those required a \nchain rule.  Note how one factor of $(x^2+2x+3)$ and two\nfactors of $(x^2+1)$ were factored from each term.\n\\eex\n\nIt is also possible that a product rule can occur within \na chain rule, as in the following.\n\\bex Suppose $f(x)=\\sqrt{\\sin x\\cos x}$.  Then\n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\sqrt{\\sin x\\cos x}\\\\\n    &=\\frac1{2\\sqrt{\\sin x\\cos x}}\\cdot\\frac{d}{dx}(\\sin x\\cos x)\\\\\n    &=\\frac1{2\\sqrt{\\sin x\\cos x}}\\cdot\\left[\\sin x\\frac{d}{dx}\\cos x\n             +\\cos x\\frac{d}{dx}\\sin x\\right]\\\\\n   &=\\frac1{2\\sqrt{\\sin x\\cos x}}\\cdot\\left[\\sin x(-\\sin x)\n             +\\cos x\\cos x\\right]\\\\\n   &=\\frac{-\\sin^2x+\\cos^2x}{2\\sqrt{\\sin x\\cos x}}.\n\\end{align*}\nThis is not the only method for solving this problem, but it\nis perhaps the most straightforward.\\footnote{%\n%%%%%%%%%%% FOOTNOTE  \nActually, \nwith trigonometry we can rewrite the problem and the answer,\nusing $\\sin2\\theta=2\\sin\\theta\\cos\\theta$ and\n$\\cos2\\theta=\\cos^2\\theta-\\sin^2\\theta$.  Below,\n``$\\implies$'' represents another chain rule problem\n(calling yet another chain rule).\n$$f(x)=\\sqrt{\\frac12\\sin2x}\n\\qquad\\implies\\qquad f'(x)=\\frac{\\cos2x}{2\\sqrt{\n   \\frac12\\sin2x}}.$$}\n%%%%%%%%%%% END FOOTNOTE\n\\eex\n\n\nWe can also use these product-rule derived\nderivatives to help graph functions.\n\\bex $f(x)=x\\sqrt{1-x^2}$.  This function we will differentiate and\nthen graph.\n\\begin{align*}\nf'(x)&=x\\cdot\\frac{d}{dx}\\sqrt{1-x^2}+\\sqrt{1-x^2}\\cdot\\frac{d}{dx}(x)\\\\\n&=x\\cdot\\frac1{2\\sqrt{1-x^2}}\\cdot\\frac{d}{dx}(1-x^2)\n+\\sqrt{1-x^2}\\cdot1\\\\\n&=x\\cdot\\frac{1}{2\\sqrt{1-x^2}}\\cdot(-2x)+\\sqrt{1-x^2}\\\\\n&=\\frac{-x^2}{\\sqrt{1-x^2}}+\\sqrt{1-x^2}.\\end{align*}\nTo graph this function we would like to know where it is\nincreasing and where it is decreasing and hence local extrema. \nBut even before delving into the derivative, we\ncan first notice the domain of $f(x)$ is $-1\\le x\\le 1$,\nand the function (height) itself is zero at $x=0,\\pm 1$\n($x$-intercepts).\n\nNext we proceed to see where $f'>0$ and $f'<0$.\nFor such a task, it is best if the derivative\nis written as a single fraction, with numerator and denominator\nfactored:\n$$f'(x)=\\frac{-x^2}{\\sqrt{1-x^2}}+\\sqrt{1-x^2}\\cdot\n\\frac{\\sqrt{1-x^2}}{\\sqrt{1-x^2}}=\\frac{-x^2+1-x^2}{\\sqrt{1-x^2}}\n=\\frac{1-2x^2}{\\sqrt{1-x^2}}.$$\nNow we see that this is undefined ($f'$ DNE)\nexcept for $-1<x<1$.\nThe fraction which is $f'$ is zero exactly where the numerator\nis zero and the denominator is not.  Thus \n$$f'(x)=0\\iff 1-2x^2=0\\iff 1=2x^2\\iff \\frac12=x^2\\iff x=\\pm\\frac1{\\sqrt2}\n\\approx\\pm0.7071.$$\nFrom this we can make a sign chart for $f'$ to see where $f$ is\nincreasing/decreasing.\n\n\\begin{center}\n\\begin{pspicture}(-0.2,-2)(12,2.3)\n\\psline(2,0)(11,0)\n   \\pscircle[fillstyle=solid,fillcolor=white](2,0){.1}\n   \\pscircle[fillstyle=solid,fillcolor=white](11,0){.1}\n   \\rput(2,-.5){$-1$}\n   \\rput(11,-.5){$1$}   \n  \\psline(5,-.2)(5,.2)\n      \\rput(5,-.5){$-\\frac{1}{\\sqrt2}$}\n   \\psline(8,-.2)(8,.2)\n      \\rput(8,-.5){$\\frac{1}{\\sqrt2}$} \n  % \\rput[l](-0.2,1.5){Function:}\n\\rput(5.9,2){$\\ds{f'(x)=\\frac{1-2x^2}{\\sqrt{1-x^2}}}$}\n\\rput[l](-0.2,1){Test $\\hphantom{f'(}x\\hphantom{)}=$}\n\\rput[l](-.2,.5){Sign $f'(x)=$}\n\\rput[l](-0.2,-.5){Sign $f'(x)$:}\n\\rput(3.5,1){$-.9$}\n  \\rput(3.5,.5){\\bominus/\\boplus}\n  \\rput(3.5,-.5){\\bominus}\n\\rput(6.5,1){$0$}\n  \\rput(6.5,.5){\\boplus/\\boplus}\n  \\rput(6.5,-.5){\\boplus}\n\\rput(9.5,1){$.9$}\n  \\rput(9.5,.5){\\bominus/\\boplus}\n  \\rput(9.5,-.5){\\bominus}\n\\rput[l](-.2,-1.25){Behavior of $f(x)$:}\n  \\rput(3.5,-1){DEC}\n   \\rput(3.5,-1.5){$\\searrow$}\n   \\rput(6.5,-1.5){$\\nearrow$}\n   \\rput(9.5,-1.5){$\\searrow$}  \n\\rput(6.5,-1){INC}\n  \\rput(9.5,-1){DEC}\n\\end{pspicture}\n\\end{center}\n\nWe see a local minimum at $x=-1/\\sqrt2$, and a local\nmaximum at $x=1/\\sqrt2$.  The actual points are\n\\begin{alignat*}{2}\n\\left(-\\frac{1}{\\sqrt2},\\,f\\left(-\\frac{1}{\\sqrt2}\\right)\\right)\n&=\\left(-\\frac{1}{\\sqrt2},\\,-\\frac1{\\sqrt2}\\cdot\\sqrt{1/2}\\right)&&\\approx\n    \\left(-0.7071,\\,-\\frac12\\right),\\\\\n\\left(\\frac{1}{\\sqrt2},\\,f\\left(\\frac{1}{\\sqrt2}\\right)\\right)\n&=\\left(\\frac{1}{\\sqrt2},\\,\\frac1{\\sqrt2}\\cdot\\sqrt{1/2}\\right)&&\\approx\n    \\left(0.7071,\\,\\frac12\\right).\\end{alignat*}\nAll this behavior leads us to the graph, which is given in\nFigure~\\ref{xsqrt(1-x^2)graph}.  Notice the (computer generated)\ngraph there also reflects\nthat $\\ds{f'(x)=\\frac{1-2x^2}{\\sqrt{1-x^2}}\\longto-\\infty}$ \nas $x\\to-1^+$ or $x\\to1^-$.\n\\eex\n\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-6,-2.5)(6,2.5)\n\\psset{xunit=3cm,yunit=3cm}\n\\psaxes[Dy=.5]{<->}(0,0)(-2,-1)(2,1)\n\\psplot[plotpoints=1000]{-1}{1}{x 1 x dup mul sub sqrt mul}\n\\psline(-.7071,-.05)(-.7071,.05)\n  \\rput(-.7071,-.17){$\\frac{-1}{\\sqrt2}$}\n  \\pscircle[fillcolor=black,fillstyle=solid](-.7071,-.5){.07}\n\\psline(.7071,-.05)(.7071,.05)\n  \\rput(.7071,-.17){$\\frac{1}{\\sqrt2}$}\n  \\pscircle[fillcolor=black,fillstyle=solid](.7071,.5){.07}\n\\end{pspicture}\n\\end{center}\n\\caption{Complete graph of $f(x)=x\\sqrt{1-x^2}$, with local\nextrema marked at $x=\\pm1/\\sqrt2$.}\n\\label{xsqrt(1-x^2)graph}\\end{figure}\n\n\n\n\n\n\n\\subsection{Product Rule Proof}\n\nThe proof of the product rule is not accomplished by ``brute force,''\nbut instead utilizes some clever rewriting.  Questions of {\\it why}\none thinks of\nthe ``trick'' used to make it work should not immediately distract\nfrom the fact it does.  Many of the proofs used today have\nbeen condensed over the decades, or even centuries since the\nfirst proofs, and are therefore quite short because revisits\nto earlier proofs naturally lead us to shortcuts.\nAs a result, proofs often look less like the natural paths\nof discovery and more like terse explanations.  Nonetheless\nthere is knowledge to be gained from even these short\nproofs---for instance, the ``trick'' may be useful in another\ncontext---and so they are worth reading and understanding, though\nagain we will almost always just quote the results---without\nreference to their proofs---when solving problems.\n\nThe proof of the product rule depends upon another\ntheorem which is intuitive, is important in its own right, \nand has its own short, somewhat clever proof.\nIn sum, the theorem says that to have a well-defined slope\nat $x=a$, a function must also be continuous there.\n\\begin{theorem} ($f'(a)$ exists)\n $\\implies$ ($f(x)$ is continuous at $x=a$).\n\\label{DifferentiabilityImpliesContinuityTheorem}\\end{theorem}\n\n\\begin{proof} Recall that \n$$f'(a) \\text{ exists}\\qquad \\iff \\qquad f'(a)=\n \\lim_{\\Delta x\\to0}\\frac{f(a+\\Delta x)-f(a)}{\\Delta x}\n  \\in\\Re,$$\ni.e., the limit exists as a (finite) real number.\nWe need to show that this implies $f(x)$ is continuous at $x=a$,\nwhich is equivalent to $\\ds{\\lim_{x\\to a}f(x)=f(a)}$\n(Theorem~\\ref{ContinuityImpliesLimit=Function},\npage \\pageref{ContinuityImpliesLimit=Function}).\nFirst we\nre-write this limit using the substitution\n$x=a+\\Delta x$, which gives\n$x\\to a\\iff\\Delta x\\to0$ properly.  Then\nwe perform an algebraic expansion of the argument\nof the limit by  subtracting and adding\n$f(a)$ (which  exists and is real or the above limit\ncould not exist and be finite), and divide and multiply\nby $\\Delta x$, to get\n\\begin{align*}\\lim_{x\\to a}f(x)&=\n\\lim_{\\Delta x\\to0}f(a+\\Delta x)\\\\\n&=\\lim_{\\Delta x\\to0}\\left[f(a+\\Delta x)-f(a)+f(a)\\right]\\\\\n&=\\lim_{\\Delta x\\to0}\\left[\\frac{f(a+\\Delta x)-f(a)}{\\Delta x}\\cdot\\Delta x%\n+f(a)\\right]\\\\\n%&=\\lim_{\\Delta x\\to 0}\\left[\\Delta x\\cdot\\frac{f(a+\\Delta x)-f(a)}{\\Delta x}\n%+f(a)\\right]\\\\\n&=f'(a)\\cdot0+f(a)=f(a), \\text{\\qquad q.e.d.}\n\\end{align*}\n\\end{proof}\nNote that the last line of the proof used the fact that\nthe difference quotient approached the finite number $f'(a)$,\nand so the limit form was ``$f'(a)\\cdot0+f(a)$,'' yielding $f(a)$.\n\nThis theorem is sometimes described as ``differentiability\nimplies continuity.''  In fact differentiability is a stronger\ncriterion than continuity.\\footnote{%\n%%%%% FOOTNOTE\nIt is quite possible to have\nthe left and right limits in the definition of the derivative\nbe different, making the derivative nonexistent, while\nthe function can still be continuous.  An example is\n$f(x)=|x|$ at $x=0$.  From the left, the difference \nquotients are all $-1$, while from the right they are all\n$1$.  (Recall the function is $-x$ for $x<0$, and $x$ for $x\\ge0$.)\nIt is also possible for the limit in the derivative definition\nto be infinite and the\nfunction still continuous, as with $f(x)=\\sqrt[3]{x}$, with \n$f'(x)=1/(3x^{2/3})\\longrightarrow\\infty$ as $x\\to0$.}\n%%%%%%%%%%% END FOOTNOTE\n This result is also interesting in its contrapositive form\n(recall $P\\rightarrow Q\\iff(\\sim Q)\\rightarrow(\\sim P)$):\n$$f(x)\\text{ discontinuous at }x=a\n\\qquad\\implies\\qquad f'(x)\\text{ DNE at }x=a.$$\nTo paraphrase, at the point $x=a$, to have a tangent\nline the function must be continuous, and equivalently, \na function which is \ndiscontinuous can not have a tangent line.\nNow we use Theorem~\\ref{DifferentiabilityImpliesContinuityTheorem}\nand some algebraic tricks to prove the product rule.\n\n\n\\begin{proof}{\\bf(Product Rule)} Suppose $f(x)$ and $g(x)$\nare both differentiable at a given $x$, i.e., $f'(x)$ and $g'(x)$\nboth exist.  Then $f$ and $g$ are both continuous at $x$, and\n%$$\\frac{d}{dx}\\left[\\vphantom{\\frac22}f(x)g(x)\\right]\n%=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)g(x+\\Delta x)-f(x)g(x)}{\\Delta x}$$\n\\begin{align*}\n\\frac{d}{dx}\\left[\\vphantom{\\frac22}f(x)g(x)\\right]\n&=\\lim_{\\Delta x\\to0}\\frac{f(x+\\Delta x)g(x+\\Delta x)-f(x)g(x)}{\\Delta x}\\\\\n&=\\lim_{\\Delta x\\to0}\n\\frac{f(x+\\Delta x)\\biggl[g(x+\\Delta x)-g(x)\\biggr]\n   +g(x)\\biggl[f(x+\\Delta x)-f(x)\\biggr]}\n{\\Delta x}\\\\ \n&=\\lim_{\\Delta x\\to0}\\left[f(x+\\Delta x)\\cdot\n               \\frac{g(x+\\Delta x)-g(x)}{\\Delta x}+\ng(x)\\cdot\\frac{f(x+\\Delta x)-f(x)}{\\Delta x}\\right]\\\\ \n&=\\vphantom{\\frac{X}X}f(x)g'(x)+g(x)f'(x),\\qquad\\text{q.e.d.}\n\\end{align*}\\end{proof}\nThe last line of the proof follows because\n as $\\Delta x\\to0$, by continuity (which the previous theorem\ngives us from the differentiability) we have $f(x+\\Delta x)\\to f(x)$,\nand the two difference quotients approach $f'(x)$ and $g'(x)$\nrespectively, while $g(x)$ is constant in the limit\n(which is in $\\Delta x$, not $x$).\nThe middle two lines were simply algebra, with the\n``clever trick'' in the second line \nusing the fact that $AB-CD=A(B-D)+D(A-C)$, except\nhere it was with $f(x+\\Delta x)g(x+\\Delta x)-f(x)g(x)$.\n\\subsection{Quotient Rule}\nWe often need to find derivatives of functions of the\nform $h(x)=f(x)/g(x)$.  We can rewrite these as\n$h(x)=f(x)\\left(g(x)\\right)^{-1}$, and use the\nproduct rule, which will then call the chain rule, to get\n\\begin{align*}\nh'(x)&=\\frac{d}{dx}\\left[f(x)(g(x))^{-1}\\right]\\\\\n&=f(x)\\frac{d}{dx}\\left[(g(x))^{-1}\\right]\n   +(g(x))^{-1}\\frac{d}{dx}f(x)\\\\\n&=f(x)\\left[(-1)(g(x))^{-2}\\frac{d}{dx}g(x)\\right]\n   +(g(x))^{-1}\\frac{d}{dx}f(x)\\\\\n&=\\frac{-f(x)\\frac{d}{dx}g(x)}{(g(x))^2}+\\frac{\\frac{d}{dx}f(x)}{g(x)}\\\\\n&=\\frac{-f(x)\\frac{d}{dx}g(x)}{(g(x))^2}+\n     \\frac{g(x)\\frac{d}{dx}f(x)}{(g(x))^2}.\n\\end{align*}\nCombining the two fractions and putting the term with the negative sign\n$(-)$ second, we can write:\n\\begin{theorem}If $f$ and $g$ are differentiable at $x$, and $g(x)\\ne0$, then\n\\begin{equation}\\frac{d}{dx}\\left[\\frac{f(x)}{g(x)}\\right]\n=\\frac{g(x)\\frac{d}{dx}f(x)-f(x)\\frac{d}{dx}g(x)}{(g(x))^2}.\n\\label{QuotientRule}\n\\end{equation}\n\\label{QuotientRuleTheorem}\\end{theorem}\nAs noted in the derivation, this rule is actually redundant\ngiven the availability of the product and quotient rules. \nHowever, it is useful especially because the \nresulting derivative emerges as an already-combined fraction.\n\\bex Find $f'(x)$ if $\\ds{f(x)=\\frac{\\sin x}{x}}$.\n\n\\underline{Solution}: Using the quotient rule we have\n$$f'(x)=\\frac{x\\frac{d}{dx}\\sin x-\\sin x\\frac{d}{dx}(x)}{(x)^2}\n     =\\frac{x\\cos x-\\sin x}{x^2}.$$\n\\eex\nThe quotient rule is especially useful for rational functions,\ni.e., ratios of polynomials.\n\\bex Suppose $\\ds{f(x)=\\frac{x^3-8}{x^2-9}}$.  Then\n\\begin{align*}f'(x)&=\n   \\frac{(x^2-9)\\frac{d}{dx}(x^3-8)-(x^3-8)\\frac{d}{dx}(x^2-9)}{(x^2-9)^2}\\\\\n &=\\frac{(x^2-9)(3x^2)-(x^3-8)(2x)}{(x^2-9)^2}\\\\\n &=\\frac{3x^4-27x^2-2x^4+16x}{(x^2-9)^2}\\\\\n &=\\frac{x^4-27x^2+16x}{(x^2-9)^2}.\\end{align*}\n\\eex\nAs with the product rule, the quotient rule can be \nembedded within a chain or product rule, or vice-versa.\nThe following uses a rule derived in the  \nExercise~\\ref{FindSecant'sDerivativeWithChainRuleExercise},\npage \\pageref{FindSecant'sDerivativeWithChainRuleExercise},\nnamely that $\\frac{d}{dx}\\sec x=\\sec x\\tan x$.\n\\bex Suppose $\\ds{f(x)=\\sec\\left(\\frac{x}{x-1}\\right)}$.\nThen\n\\begin{align*}f'(x)&=\\frac{d}{dx}\\sec\\left(\\frac{x}{x-1}\\right)\\\\\n       &=\\sec\\left(\\frac{x}{x-1}\\right)\\tan\\left(\\frac{x}{x-1}\\right)\\cdot\n \\frac{d}{dx}\\left(\\frac{x}{x-1}\\right)\\\\\n  &=\\sec\\left(\\frac{x}{x-1}\\right)\\tan\\left(\\frac{x}{x-1}\\right)\n \\cdot\\left(\\frac{(x-1)\\cdot\\frac{d}{dx}(x)-x\\cdot\\frac{d}{dx}(x-1)}\n         {(x-1)^2}\\right)\\\\\n&=\\sec\\left(\\frac{x}{x-1}\\right)\\tan\\left(\\frac{x}{x-1}\\right)\n \\cdot\\frac{(x-1)(1)-(x)(1)}{(x-1)^2}\\\\\n&=\\sec\\left(\\frac{x}{x-1}\\right)\\tan\\left(\\frac{x}{x-1}\\right)\n \\cdot\\frac{-1}{(x-1)^2}\\\\\n&=\\frac{-1}{(x-1)^2}\n \\sec\\left(\\frac{x}{x-1}\\right)\\tan\\left(\\frac{x}{x-1}\\right).\n\\end{align*}\n\\eex\nIn fact the quotient rule for this particular problem could have\nbeen avoided through long division, giving\n$\\frac{d}{dx}\\left(\\frac{x}{x-1}\\right)\n=\\frac{d}{dx}\\left(1+\\frac1{x-1}\\right)$, making for\na simple power/chain rule, but the quotient rule was\nstraightforward, and left that factor as a single fraction.  \nFor an example of chain rules inside\na quotient rule, consider\nthe next example.\n\\bex Suppose $\\ds{f(x)=\\frac{\\cos2x}{\\sqrt{x^2-1}}}$.  Then\n\\begin{align*}\nf'(x)&=\\frac{\\sqrt{x^2-1}\\frac{d}{dx}\\cos2x-\\cos2x\\cdot\n   \\frac{d}{dx}\\sqrt{x^2-1}}{\\left(\\sqrt{x^2-1}\\right)^2}\\\\\n  &=\\frac{\\sqrt{x^2-1}\\cdot\\left(-\\sin2x\\cdot\\frac{d}{dx}(2x)\\right)\n    -\\cos2x\\cdot\\ds{\\frac1{2\\sqrt{x^2-1}}\\cdot\\frac{d}{dx}(x^2-1)}}{x^2-1}\\\\\n&=\\frac{\\sqrt{x^2-1}\\cdot\\left(-2\\sin2x\\right)-\\ds{\\frac{\\cos2x\\cdot\\not{2}x}\n   {\\not{2}\\sqrt{x^2-1}}}}{x^2-1}\\underbrace{\\cdot\\frac{\\sqrt{x^2-1}}{\\sqrt{x^2-1}}\n   }_{\\text{To Simplify}}\\\\\n&=\\frac{-2(x^2-1)\\sin2x-x\\cos2x}{(x^2-1)^{3/2}}.\n\\end{align*}\n\\eex\nIt is an interesting exercise in both calculus and\nalgebraic simplification to derive the same conclusion \nusing $f(x)=\\cos2x\\cdot(x^2-1)^{-1/2}$ and the product rule\n(which would also call the chain rule twice).\n\\subsection{Tangent,Cotangent, Secant and Cosecant Rules}\nThe following are derivative rules for the remaining trigonometric\nfunctions.  These rules are given in both simple\n(``matching variable'') and chain rule versions.\n\\begin{alignat}{2}\n\\frac{d \\tan x}{dx}&=\\sec^2x,\\qquad\\qquad\n    &\\frac{d\\tan u}{dx}&=\\sec^2u\\cdot\\frac{du}{dx}.\\label{TangentDerivative}\n     \\\\\n\\frac{d \\cot x}{dx}&=-\\csc^2x,\\qquad\\qquad\n    &\\frac{d\\cot u}{dx}&=-\\csc^2u\\cdot\\frac{du}{dx}.\\label{CotangentDerivative}\n\\\\\n\\frac{d\\sec x}{dx}&=\\sec x\\tan x,&\\frac{d\\sec u}{dx}&=\n                        \\sec u\\tan u\\cdot\\frac{du}{dx}.\n                  \\label{SecantDerivative}\\\\\n\\frac{d\\csc x}{dx}&=-\\csc x\\cot x,\\qquad\\qquad\\qquad\\qquad&\\frac{d\\csc u}{dx}&=\n                        -\\csc u\\cot u\\cdot\\frac{du}{dx}.\n                  \\label{CosecantDerivative}\n     \\end{alignat}\nThese should all be memorized.  It may help to\nnotice patterns when comparing the derivatives of tangent\nand cotangent, secant and cosecant, and how these are similar\nto the comparison of sine and cosine derivatives.\nIn short, these formulas come in function/cofunction pairs.\n\nWe will prove the derivative of $\\tan x$ is $\\sec^2x$ and\nleave the rest for exercises.  The chain rule\nversions then follow.  To see the formula for the tangent, we\nrewrite it as the quotient of sine and cosine, and use the quotient\nrule.\n\\begin{align*}\n\\frac{d}{dx}\\tan x&=\\frac{d}{dx}\\left[\\frac{\\sin x}{\\cos x}\\right]\\\\\n&=\\frac{\\cos x\\cdot\\frac{d\\sin x}{dx}-\\sin x\\cdot\\frac{d\\cos x}{dx}}{(\\cos x)^2}\\\\\n&=\\frac{\\cos x\\cos x-(\\sin x)(-\\sin x)}{\\cos^2x}\\\\\n&=\\frac{\\cos^2x+\\sin^2x}{\\cos^2x}\n=\\frac1{\\cos^2x}=\\sec^2x,\\\\ \\\\\n\\frac{d}{dx}\\tan u&=\\frac{d}{du}\\tan u\\cdot\\frac{du}{dx}\n                  =\\sec^2u\\cdot\\frac{du}{dx}.\\end{align*}\nThe fourth line above used some trigonometric identities\n($\\sin^2\\theta+\\cos^2\\theta=1$, $1/\\cos\\theta=\\sec\\theta$).\nThe last line was our usual chain rule argument,\ngiven $\\frac{d\\tan x}{dx}=\\sec^2x$ was already proved.\nWith (\\ref{TangentDerivative})--(\\ref{CosecantDerivative}),\nand derivatives of sine and cosine from earlier((\\ref{SineDerivative}), \n(\\ref{CosineDerivative}), page \\pageref{SineDerivative}),\nwe finally have derivatives of all six trigonometric functions.\n\nEvery student of calculus should memorize the derivatives of \nthe trigonometric functions, {\\it and be able to derive these\nnew ones} from knowing the derivatives of $\\sin x$ and $\\cos x$.\n\n\nNow we can apply these.  First we look at some of the simpler examples.\n\\bex \\qquad\n\n\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}\\sec x^9=\\sec x^9\\tan x^9\\cdot\\frac{d}{dx}(x^9)\n           =\\sec x^9\\tan x^9\\cdot9x^8=9x^8\\sec x^9\\tan x^9}$.\n\\item\n$\\ds{\\frac{d}{dx}x^2\\tan x=x^2\\cdot\\frac{d}{dx}\\tan x\n              +\\tan x\\cdot\\frac{d}{dx}(x^2)=x^2\\sec^2x+2x\\tan x}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac{x}{\\tan x}\\right]=\\frac{d}{dx}(x\\cot x)\n=x\\cdot\\frac{d}{dx}(\\cot x)+\\cot x\\cdot\\frac{d}{dx}(x)\n=(x)(-\\csc^2x)+\\cot x}$\n\n$\\ds{=-x\\csc^2x+\\cot x}$.\n\\end{itemize}\\eex\nNote that we turned a quotient rule into a product rule for the\nlast derivative problem.\n\nBefore continuing with more complicated examples, we should briefly\nconsider  why  it makes sense graphically that\n$\\frac{d}{dx}\\tan x=\\sec^2x$.\nThe graph of $f(x)=\\tan x$ is given\nin Figure~\\ref{GraphTanXForSlopes}, and so we\ncan consider its derivative formula in light of that graph.\nNow that derivative is always positive where defined;\n$\\sec^2x>0$, and in fact $\\sec^2x=1/\\cos^2x\\ge1$.  Thus $\\tan x$ is\nalways increasing in any interval on which it is defined.\nFurthermore $\\sec^2x\\to\\infty$ as $x\\to\\pm\\frac{\\pi}2,\\pm\\frac{3\\pi}2,\n\\pm\\frac{5\\pi}2$, etc., and that has implications for the\ngraph.  Of course $\\tan x=\\sin x/\\cos x$ has\nvertical asymptotes at each of those $x$-values (where $\\cos x=0$\nand $\\sin x=\\pm 1$).  Finally, note that \n$\\left.\\frac{d\\tan x}{dx}\\right|_{x=0}=\\left.\\vphantom{\\frac22}\\sec^2x\n\\right|_{x=0}=\\frac1{\\cos^20}=1$, for instance, so the slope through \nthe $(0,\\tan0)=(0,0)$ is 1.  That slope repeats every $\\pi$ in both \ndirections, due to the $\\pi$-periodic nature of the tangent. \n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-6,-3)(6,3)\n\\psaxes[labels=none,Dx=1.5708]{<->}(0,0)(-6,-3)(6,3)\n\\psline[linestyle=dashed](-4.7124,-3)(-4.7124,3)\n\\psline[linestyle=dashed](-1.5708,-3)(-1.5708,3)\n\\psline[linestyle=dashed](4.7124,-3)(4.7124,3)\n\\psline[linestyle=dashed](1.5708,-3)(1.5708,3)\n\n\\psplot{-6}{-5.03}{x 3.1415927 div 180 mul sin x %\n            3.1415927 div 180 mul cos div}\n\\psplot{-4.39}{-1.89}{x 3.1415927 div 180 mul sin x %\n            3.1415927 div 180 mul cos div}\n\\psplot{-1.25}{1.25}{x 3.1415927 div 180 mul sin x %\n            3.1415927 div 180 mul cos div}\n\\psplot{1.89}{4.39}{x 3.1415927 div 180 mul sin x %\n            3.1415927 div 180 mul cos div}\n\\psplot{5.03}{6}{x 3.1415927 div 180 mul sin x %\n            3.1415927 div 180 mul cos div}\n\\rput(-3.14,-.3){$-\\pi$}\n\\rput(3.14,-.3){$\\pi$}\n\n\\rput(-.78,-3){QIV}\n\\rput(-2.4,-3){QIII}\n\\rput(-3.93,-3){QII}\n\\rput(-5.50,-3){QI}\n\n\\rput(.78,-3){QI}\n\\rput(2.4,-3){QII}\n\\rput(3.93,-3){QIII}\n\\rput(5.50,-3){QIV}\n\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $y=\\tan x$.  Since $y=\\sin x/\\cos x$,\nthere are vertical \nasymptotes at each $x$-value where $\\cos x=0$ (and\n$\\sin\\theta=\\pm1$).  Recall that $\\tan x$ is positive\nif $x$ represents an angle in the first or third quadrants,\nand negative in the second and fourth quadrants, so the\nquadrants represented by the $x$-values are labeled\nQI--QIV.  Note that $\\frac{d}{dx}\\tan x=\\sec^2x$ which\nis positive where defined (same as where $\\tan x$ is defined), \nand thus $\\tan x$ is an increasing\nfunction where defined.}\n\\label{GraphTanXForSlopes}\n\\end{figure}\n\n\n\n\n\n\n\\bex Here is a typical chain rule problem involving the tangent.\n\\begin{align*}\n\\frac{d}{dx}\\tan \\sqrt{x^2-1}\n&=\\sec^2\\sqrt{x^2-1}\\frac{d}{dx}\\sqrt{x^2-1}\n=\\sec^2\\sqrt{x^2-1}\\cdot\\frac1{2\\sqrt{x^2-1}}\\cdot\\frac{d(x^2-1)}{dx}\\\\\n&=\\frac{\\sec^2\\sqrt{x^2-1}}{2\\sqrt{x^2-1}}\\cdot2x\n=\\frac{x\\sec^2\\sqrt{x^2-1}}{\\sqrt{x^2-1}}.\\end{align*}\n\\eex\nNote that, tempting as it may be,\nthe radicals above cannot be combined or canceled in\nany of the steps; one is outside the secant-squared function,\nand the other is safely quarantined inside.  Note also that\nsquaring the secant function does not alter its argument\n$\\sqrt{x^2-1}$.\n\\bex Another chain rule problem is the following:\n$$\\frac{d}{dx}\\cot^3x=3(\\cot x)^2\\frac{d}{dx}\\cot x\n=3\\cot^2x(-\\csc^2x)=-3\\cot^2x\\csc^2x.$$\n\\eex\n\\bex One product rule problem is the following:\n\\begin{align*}\n\\frac{d}{dx}(\\sec x\\tan x)\n&=\\sec x\\cdot\\frac{d}{dx}\\tan x+\\tan x\\frac{d}{dx}\\sec x\\\\\n&=\\sec x\\sec^2x+\\tan x\\sec x\\tan x\\\\\n&=\\sec^3x+\\sec x\\tan^2x.\\end{align*}\nThere is so much algebraic structure built into the trigonometric\nfunctions that such an answer can be rewritten many different\nways.  Recall that $\\tan^2x+1=\\sec^2x$.  Thus our final answer\ncan be written\n$$\\sec x(\\sec^2x+\\tan^2x)=\\sec x(\\sec^2x+\\sec^2x-1)=\\sec x(2\\sec^2x-1),$$\nfor instance. Another alternative is $\\sec x(\\tan^2x+1+\\tan^2x)\n=\\sec x(2\\tan^2x+1)$.  When we study integration particularly, it is important\nto consider such options.  \\eex\n\n\n\n\n\n\n\\subsection{Putting Rules Together---Carefully}\n\n\nThis subsection is just a reminder that, when \ncomputing the derivative of a complicated function\nit is quite\npossible to use several of the previous differentiation rules.\nIn such cases we need to recognize which rules apply, and\nthen exactly how to invoke them. \n\n It is easy to lapse into\nintellectual laziness by skipping steps, but this is\nan error-prone habit which does not save any time in the \nlong run.  Some steps can be combined into other steps with little\nrisk, especially with practice (the sum\nand additive and multiplicative constant rules come to mind).\nHowever, the quotient, product, power, trigonometric, and\nall forms  of the chain rule should be written out \nin their own steps {\\it before} we compute the derivatives\ninternal to these rules.  For instance,\nit is tempting to compute all at once:\n\\begin{multline*}\n\\frac{d}{dx}\\left[(x^3+9x^2+\\sin 2x)(\\tan x^5)\\right]\n\\\\ =(x^3+9x^2+\\sin2 x)(\\sec^2x^5\\cdot5x^4)\n+\\tan x^5\\cdot(3x^2+18x+\\cos2 x\\cdot2).\\end{multline*}\nHowever, this approach has a couple of disadvantages\nwhich become more important as functions become \nincreasingly complicated.  First, we have to \nkeep track of what rule applies where, without the\nbenefit of breaking it into steps.  Second, \nif we would like to check our work we can try to \nre-read what we wrote, but we find ourselves again\nperforming the same mental gymnastics we did the first \ntime, and likely repeating any mistakes we made that first time.\nWe can go a long way towards avoiding\nthese difficulties by writing out all the steps.\nSince each step invokes a single differentiation rule\n(though we may apply different rules to different terms\nin the same ``step''), much of our work is recopying the\nline above, which takes very little time.  Care in\n``bookkeeping'' will translate into clearer thinking\nand less error (and easier error correction!).  Consider \nthe following approach to the problem above:\n\\bigskip\n\n$\\ds{\\frac{d}{dx}\\left[(x^3+9x^2+\\sin x)(\\tan x^5)\\right]\n}$\n\\begin{align*}\n{}&=\\left(x^3+9x^2+\\sin2x\\right)\\frac{d}{dx}\\left(\n       \\tan x^5\\right)+\\left(\\tan x^5\\right)\n       \\cdot\\frac{d}{dx}\\left(x^3+9x^2+\\sin2x\\right)\\\\\n&=\\left(x^3+9x^2+\\sin2x\\right)\\sec^2x^5\\cdot\\frac{d\\,x^5}{dx}\n+\\tan x^5\\cdot\\left(3x^2+18x+\\cos2x\\cdot\\frac{d(2x)}{dx}\\right)\\\\\n&=(x^3+9x^2+\\sin2 x)(\\sec^2x^5\\cdot5x^4)\n+\\tan x^5\\cdot(3x^2+18x+\\cos2x\\cdot 2)\\\\\n&=5x^4(x^3+9x^2+\\sin2x)\\sec^2x^5+(3x^2+18x+2\\cos2x)\\tan x^5.\n\\end{align*}\n\nUltimately this given function is a product, so \nthe first step was exactly the statement of the product rule.\nIn the next line, we begin to take the derivatives\ndemanded within the product rule, and find some power rules\n(with the multiplicative constants along for the ride---i.e.,\nwith the rule that multiplicative constants are preserved),\nand a couple of chain rules which we write out exactly.\nNext we compute the derivatives of the ``inside''\nfunctions demanded  by the chain rule, and finally we\ndo some algebra to make the result more presentable.\nNote how we can re-read this with great assurance that it\nis correct, since each step follows differentiation rules\nin obvious (though the terms themselves may be complicated)\nways.\n\nIn the examples which\nfollow we will continue to write out all the steps, while\nbeing careful to invoke them in the proper order.\nIn effect, we work from the outside (large-structure)\ninwards.\n\n\\bex\nFind $f'(x)$ if $\\ds{f(x)=2\\sin^3 5x+\\csc\\sqrt{x^2+1}}$\n\n\\noindent\nThis is first a sum, and then there are several chain rules\nwhich come into play.  \n\\begin{align*}\nf'(x)&=\\frac{d}{dx}\\left(2\\sin^35x\\right)\n+\\frac{d}{dx}\\left(\\csc\\sqrt{x^2+1}\\right)\\\\\n&=2\\frac{d}{dx}\\sin^35x+\\left(-\\csc\\sqrt{x^2+1}\n\\cot\\sqrt{x^2+1}\\cdot\\frac{d\\,\\sqrt{x^2+1}}\n{dx}\\right)\\\\\n&=2\\cdot3\\sin^25x\\cdot\\frac{d\\sin5x}{dx}\n-\\csc\\sqrt{x^2+1}\\cot\\sqrt{x^2+1}\\cdot\n\\frac1{2\\sqrt{x^2+1}}\\frac{d(x^2+1)}{dx}\\\\\n&=6\\sin^25x\\cos5x\\cdot\\frac{d(5x)}{dx}\n-\\frac{\\csc\\sqrt{x^2+1}\\cot\\sqrt{x^2+1}}{2\\sqrt{x^2+1}}\\cdot2x\\\\\n&=6\\sin^25x\\cos5x\\cdot5-\\frac{x\\csc\\sqrt{x^2+1}\\cot\\sqrt{x^2+1}}\n{\\sqrt{x^2+1}}\\\\\n&=30\\sin^25x\\cos5x-\\frac{x\\csc\\sqrt{x^2+1}\\cot\\sqrt{x^2+1}}\n{\\sqrt{x^2+1}}.\\end{align*}\n\\eex\n\\bex Find $f'(x)$ if $\\ds{f(x)=\\sin^3\\left(x^2\\tan x\\right)}$.\n\n\\noindent This is first a power and chain rule problem,\nsince $\\ds{f(x)=\\left[\\sin\\left(x^2\\tan x\\right)\\right]^3}$.\nAfter a second, trigonometric chain rule we will have a product rule.\nIt is not necessary to notice all this structure from the beginning;\nit all becomes apparent as we dissect the \nfunction, applying\nthe appropriate differentiation rules as we go:\n\\begin{align*}\nf'(x)&=3\\left[\\sin\\left(x^2\\tan x\\right)\\right]^2\n\\cdot\\frac{d}{dx}\\left[\\sin\\left(x^2\\tan x\\right)\\right]\\\\\n&=3\\sin^2\\left(x^2\\tan x\\right)\\cdot\\cos(x^2\\tan x)\\cdot\n\\frac{d}{dx}\\left(x^2\\tan x\\right)\\\\\n&=3\\sin^2\\left(x^2\\tan x\\right)\\cos(x^2\\tan x)\n\\cdot\\left(x^2\\frac{d\\,\\tan x}{dx}+\\tan x\\cdot\\frac{d\\,x^2}{dx}\\right)\n\\\\\n&=3\\sin^2\\left(x^2\\tan x\\right)\\cos\\left(x^2\\tan x\\right)\n\\cdot\\left(x^2\\sec^2x+\\tan x\\cdot 2x\\right)\\\\\n&=3\\left(x^2\\sec^2x+2x\\tan x\\right)\n\\sin^2\\left(x^2\\tan x\\right)\\cos\\left(x^2\\tan x\\right).\n\\end{align*}\n\\eex\n\n\n\nIn some cases it is best to simplify algebraically\nbefore applying differentiation rules.  For an obvious \nillustration of this, \nconsider the following.\n\\bex Here we compute $\\ds{\\frac{d}{dz}\\left[\\frac{1+\\ds{\\frac{z+1}{z-1}}}\n{1-\\ds{\\frac{z+1}{z-1}}}\n\\right].}$\nA method of brute force would be to perform the quotient rule\nand continue from there:\n\n\\qquad$\\ds{=\\frac{\\left(1-\\frac{z+1}{z-1}\\right)\\frac{d}{dz}\n\\left(1+\\frac{z+1}{z-1}\\right)-\\left(1+\\frac{z+1}{z-1}\\right)\n\\frac{d}{dz}\\left(1-\\frac{z+1}{z-1}\\right)}{\\left(1-\n\\frac{z+1}{z-1}\\right)^2}}$,\n\n\\noindent from which we need to compute two more quotient\nrules.  However, if we instead simplify the function\nfrom the beginning, our work is greatly simplified too:\n\n$$\n=\\frac{d}{dz}\\left[\\frac{1+\\ds{\\frac{z+1}{z-1}}}{1-\\ds{\\frac{z+1}{z-1}}}\n\\cdot\\frac{z-1}{z-1}\\right]\n=\\frac{d}{dz}\\left[\\frac{z-1+(z+1)}{z-1-(z+1)}  \\right]\n=\\frac{d}{dz}\\left[\\frac{2z}{-2}\\right]=\\frac{d}{dz}(-z)=-1.\n$$\\eex\nIn applications especially, we are often led to \ncomplicated expressions for functions, for which\nwe then need to find the derivatives.  It is always better\nto look out for such cases in which algebraic simplification\nfrom the beginning will simplify our calculus tasks,\nas well as give us a look at a simpler form of the original\nfunction.  As complicated as the above function first\nappeared, it was simply the function $-z$ (where both \noriginal and simplified are both defined, which for this\nproblem means $z\\ne1$).\n\n\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item For each of the following functions,\n      compute the derivatives two different ways:\n      \\begin{enumerate}[(i)]\n        \\item  by using the rule called upon by\n               the way the function is originally written; and\n        \\item  by first simplifying the function, and then\n               computing the derivative of the simplified function\n               in the obvious way (using already established\n               derivative formulas).\n        \\item Show that the answers are the same.\n      \\end{enumerate}\n      For instance, in (a), first use the product rule, and then\n      compute $\\frac{d}{dx}(x^4)$ with the power rule, and show the\n      answers are the same (e.g., both $4x^3$ for this case).\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\left[x^2\\cdot x^2\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{x^9}{x^3}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\cos x\\sec x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\cos x\\tan x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac1{\\cos x}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\tan x\\cot x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sin x\\sec x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{1}{\\sin x}\\right]}$\n  \\end{enumerate}\n\\item Compute the following derivatives.\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\left[\\tan^2x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{x^2+1}{\\sin x-1}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sqrt{1-\\csc 2x}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[x\\sin x\\cos x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{x^3-7x+5}{x^2-3}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{1+\\frac1{x+1}}{1-\\frac1{x-1}}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sin^2x\\cos^3x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sec3x\\cot5x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{x}{\\sqrt{x^2+1}}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{(x+5)^3}{(x-4)^5}\\right]}$.  \n        Factor the numerator in your answer\n        to simplify.\n  \\item $\\ds{\\frac{d}{dx}\\left[3\\cot^29x-\\sqrt{\\cos6x+1}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\tan(x+\\tan(x+\\tan x))\\right]}$\n\n\n  \\end{enumerate}\n\n\n\n\n\n\n\\item Show that $\\frac{d}{dx}[f(x)g(x)h(x)]\n=f(x)g(x)h'(x)+f(x)g'(x)h(x)+f'(x)g(x)h(x)$.\nWhat do you think will be the derivative\nof $f(x)g(x)h(x)i(x)$?\n\\end{enumerate}\n\\end{multicols}\n\n\n\n\n\\newpage\n\\section{Chain Rule II: Implicit Differentiation\n\\label{ImplicitDifferentiationSection}}\nIn this section we will apply the chain rule in a\nsetting of so-called {\\it implicit functions},\nwhich are more general than the {\\it explicit functions}\nwe have dealt with so far.  In the next section we\nwill use the chain rule in still a third context,\n{\\it related rates}.  \n\nIn this section we first consider a brief summary and re-examination of \nall differentiation rules, including the chain rule.\nWe then perform some simple differentiation problems\nwhich are of the type typically encountered in a first study\nof implicit functions.  We then proceed to the topic of this section,\nwhich is finding the slope, $dy/dx$, for curves which are not\nnecessarily functions in the purest sense, but which are functions\nlocally, and anyway for which it is reasonable to ask about\nslope.\n\n\\subsection{Review of Differentiation Rules}\nAt this point we have many differentiation rules.\nIf we look at all the rules so far, {\\it except for the\nchain rule}, they can be summed up as follows.  First\nwe had the very general rules, regardless of $f(x)$\nand $g(x)$, and {\\it fixed constants} $C\\in\\Re$\n as long as the expressions on the right\nexisted:\n\\begin{multicols}{2}\n\\begin{itemize}\n\\item $\\ds{\\frac{d\\left[Cf(x)\\right]}{dx}=C\\cdot\\frac{df(x)}{dx}}$\n\\item $\\ds{\\frac{d[f(x)+g(x)]}{dx}=\\frac{df(x)}{dx}+\\frac{dg(x)}{dx}}$\n\\item $\\ds{\\frac{d[f(x)\\cdot g(x)]}{dx}=f(x)\\cdot\\frac{dg(x)}{dx}\n                             +g(x)\\cdot\\frac{df(x)}{dx}}$\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac{f(x)}{g(x)}\\right]\n    =\\frac{g(x)\\cdot\\frac{df(x)}{dx}-f(x)\\cdot\\frac{dg(x)}{dx}}{[g(x)]^2}}$\n\\item $\\ds{\\frac{d\\,C}{dx}=0}$\n\\bigskip\n\n\\end{itemize}\\end{multicols}\nThen we had rules for specific functions, and their chain rule \nversions:\\footnote{%\n%%% FOOTNOTE\nThe formulas in the right column assume that $u$ is a function of $x$, \nbut in fact if that is not the case,  that is if $u$ is not a function\nof $x$, then both sides of those equations do not make sense.  It\nis therefore customary to proceed to write these formulas\nbecause a problem in the left-hand side will manifest \nin the right-hand side of each equation in the right column above.\n\\label{WhatIfUNotAFunctionOfX}}\n%%% END FOOTNOTE\n\n\\begin{multicols}{2}\n\\begin{itemize}\n\\item ${\\frac{d}{dx}\\left[x^n\\right]=n\\cdot x^{n-1}}$\n\\item ${\\frac{d}{dx}\\sin x=\\cos x}$\n\\item ${\\frac{d}{dx}\\cos x=-\\sin x}$\n\\item ${\\frac{d}{dx}\\tan x=\\sec^2x}$\n\\item ${\\frac{d}{dx}\\cot x=-\\csc^2x}$\n\\item ${\\frac{d}{dx}\\sec x=\\sec x\\tan x}$\n\\item ${\\frac{d}{dx}\\csc x=-\\csc x\\cot x}$\n\\item ${\\frac{d}{dx}\\sqrt{x}=\\frac1{2\\sqrt{x}}}$\n\\item ${\\frac{d}{dx}\\left[\\frac1x\\right]=\\frac{-1}{x^2}}$\n\\item ${\\frac{d}{dx}\\left[u^n\\right]=n\\cdot u^{n-1}\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\sin u=\\cos u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\cos u=-\\sin u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\tan u=\\sec^2u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\cot u=-\\csc^2u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\sec u=\\sec u\\tan u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\csc u=-\\csc u\\cot u\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\sqrt{u}=\\frac1{2\\sqrt{u}}\\cdot\\frac{du}{dx}}$\n\\item ${\\frac{d}{dx}\\left[\\frac1u\\right]=\\frac{-1}{u^2}\\cdot\\frac{du}{dx}}$\n\n\\end{itemize}\n\\end{multicols}\n(Note that the bottom four rules were just special cases of the power rules.)\n\nWhile we will not venture here to reinvent the discussion of the\nprevious section, we will at least notice that when  the variable\nof differentiation matches the argument of the function,\nwe can use the simple derivative rules for that particular function,\nand when they do not, we multiply by the derivative of that variable\nwith respect to the variable of differentiation:\n\\begin{align}\n&\\frac{d f(x)}{dx}=f'(x),\\\\\n&\\frac{d f(u)}{dx}=f'(u)\\cdot\\frac{du}{dx}.\\label{(F(U))'=F'(U)U'}\n\\end{align}\nFor one example of (\\ref{(F(U))'=F'(U)U'}), justified with  \nLeibniz notation, we\nhad $f(x)=\\sin x$ and $u=u(x)$ yielding the following:\n$$\\frac{d\\,\\sin u}{dx}=\\frac{d\\,\\sin u}{du}\\cdot\\frac{du}{dx}=\\cos u\\cdot\n\\frac{du}{dx}.$$\nThe decomposition in the middle step\nallowed us to use the sine derivative formula \nbecause the variable in the sine---$u$---matched the \ndifferential operator $\\frac{d}{du}$ that appeared in the first term\nof the Leibniz-style decomposition.  Writing that step will\nbecome more burdensome as the argument of sine is more complicated,\nso we will skip that step in most future computations.\n\n\n%Sometimes we have several variables (or functions of several variables),\n%which are each functions of a single variable.  For instance,\n%suppose we are in an $(x,y)$-coordinate plane and our position\n%is changing with respect to time $t$.  Then the distance\n%from the origin is given as $D=\\sqrt{x^2+y^2}$, and itself\n%is changing with respect to time.  Thus\n%$$\\frac{dD}{dt}=\\frac{d}{dt}\\sqrt{x^2+y^2}\n%=\\underbrace{\\frac1{2\\sqrt{x^2+y^2}}}_{\\ds{\\frac{d\\sqrt{x^2+y^2}}{d(x^2+y^2)}}}\n%\\quad\\cdot\\underbrace{\\frac{d}{dt}\\left(x^2+y^2\\right).\n%\\vphantom{\\frac1{2\\sqrt{x^2+y^2}}}}_{\\ds{\\cdot\n%\\quad\\quad\\frac{d(x^2+y^2)}{dt}\\qquad}}$$\n%That is simply the chain rule (applied to the power rule).\n%The first ``inner variable'' is $x^2+y^2$, which is in turn\n%a function of $t$.\n%To complete the differentiation, we would write\n%\\begin{align*}\\frac{dD}{dt}&=\\frac{d}{dt}\\sqrt{x^2+y^2}\\\\\n%&=\\frac1{2\\sqrt{x^2+y^2}}\\cdot\\frac{d}{dt}\\left(x^2+y^2\\right)\\\\\n%&=\\frac1{2\\sqrt{x^2+y^2}}\\left(\\frac{d(x^2)}{dt}+\\frac{d(y^2)}{dt}\\right)\\\\\n%&=\\frac1{2\\sqrt{x^2+y^2}}\\left(2x\\frac{dx}{dt}+2y\\frac{dy}{dt}\\right)\n%=\\frac{2\\left(x\\frac{dx}{dt}+y\\frac{dy}{dt}\\right)}{2\\sqrt{x^2+y^2}}\n%=\\frac{x\\frac{dx}{dt}+y\\frac{dy}{dt}}{\\sqrt{x^2+y^2}}.\n%\\end{align*}\n%In this section, we will be more interested in situations in\n%which $y$ is a function of $x$. Examples of the simplest \n%computations we will need are given next:\n\nFor a few slightly  more complicated examples,\nconsider the following, noting that the previous\nrules still apply if we assume that $y$ is a function of $x$\n(see  Footnote~\\ref{WhatIfUNotAFunctionOfX} \nfor the case $y$ is not):\n\\bex Consider the following three derivative computations.\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}(y^2)=2y\\cdot\\frac{dy}{dx}}$.\n\\item $\\ds{\\frac{d}{dx}\\sqrt{y}=\\frac1{2\\sqrt{y}}\\cdot\\frac{dy}{dx}}$.\n\\item $\\ds{\\frac{d}{dx}(y\\sin y)=y\\cdot\\frac{d(\\sin y)}{dx}+\\sin y\\cdot\n                       \\frac{d(y)}{dx}=y\\cdot\\cos y\\cdot\\frac{dy}{dx}\n                       +\\sin y\\cdot\\frac{dy}{dx}}$.\n\\end{itemize}\n\\eex\nNotice that the last example required first the product rule,\nand so the first step was to  write---exactly---the statement\nof the product rule, where the product is $y\\sin y$.  \nThis is ultimately a product of two functions of $x$, since\nwe are assuming $y$ is a function of $x$, and thus $\\sin y$\nis also a (composite) function of $x$.\nAs with earlier derivatives, it is crucial to write out\n{\\it precisely} what the general rules dictate.  This becomes\neven more critical in the following.\n\\bex Consider the following derivative computations:\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}(xy^2)=x\\,\\frac{dy^2}{dx}+y^2\\,\\frac{dx}{dx}\n                   =x\\cdot2y\\,\\frac{dy}{dx}+y^2(1)=2xy\\,\\frac{dy}{dx}+y^2}$,\n\\item $\\ds{\\frac{d}{dx}(x^2+y^2)^2=2(x^2+y^2)^1\\frac{d}{dx}(x^2+y^2)\n          =2\\left(x^2+y^2\\right)\\left(2x+2y\\cdot\\frac{dy}{dx}\\right)}$\\newline\n      \\hphantom{$\\ds{\\frac{d}{dx}(x^2+y^2)^2}$}\n         $\\ds{=4\\left(x^2+y^2\\right)\\left(x+y\\,\\frac{dy}{dx}\\right)}$.\n\\end{itemize}\n\\eex\nNotice that we skipped an explicit writing of\nthe  ``sum rule'' step in the second computation above:\n$$\\frac{d}{dx}\\left(x^2+y^2\\right)\n  =\\frac{d}{dx}\\left(x^2\\right)+\\frac{d}{dx}\\left(y^2\\right)\n  =2x+2y\\cdot\\frac{dy}{dx}.$$\nThe first term, $\\frac{d}{dx}(x^2)$ was a simple power rule \nbecause the variables matched.\\footnote{%\n%%% FOOTNOTE\nWe can write ${\\frac{d\\left(x^2\\right)}{dx}\n=2x\\cdot\\frac{dx}{dx}}$ but then, of course, \n``inner function's'' derivative is just ${\\frac{dx}{dx}}=1$.\n%%%% END FOOTNOTE\n}  For the second term they\ndo not match, so we need the chain rule to compute\n$\\frac{d}{dx}(y^2)=2y\\,\\frac{dy}{dx}$.\\footnote{%\n%%%%%%%%%%% FOOTNOTE\nOne usually does not continue to write, for example,\n$$\\frac{d}{dx}\\left(y^2\\right)=\\frac{d\\,y^2}{dy}\\cdot\\frac{dy}{dx}\n=2y\\cdot\\frac{dy}{dx},$$\nbut skips the explicit decomposition step in the middle.\nWe repeat it occasionally just as a reminder of the computational\nreasonableness of the chain rule, best illustrated with Leibniz notation\nas above.} \n%%%%%%%%%%% END FOOTNOTE\n Notice also that in the first computation\nwe used the fact that $\\frac{dx}{dx}=1$, which is reasonable on its \nface, but technically describes the fact that the function $f(x)=x$\nis a line with slope 1, i.e., $f'(x)=1$, regardless of $x$.\\footnote{\n%%%%%%%%%% FOOTNOTE\nOf course $\\frac{dx}{dx}=1$ also follows from the power rule, loosely\ninterpreted: $\\frac{d}{dx}(x^1)=1x^0$, which seems to \ngive 1, though technically $x^0=1$ only for $x>0$ (for reasons\nwe will see later in the text). Still, in this case\nthe ``formal answer'' $x^0=1$, that is, 1, is in fact the correct answer\nfor $\\frac{d(x^1)}{dx}$. }\n%%%%%%%%%% END FOOTNOTE\n\\bex Consider the following derivative computation:\n\\begin{align*}\n\\frac{d}{dx}\\sin xy&=\\cos xy\\cdot\\frac{d(xy)}{dx}\\\\\n    &=\\cos xy\\cdot\\left(x\\frac{dy}{dx}+y\\frac{dx}{dx}\\right)\\\\\n    &=\\cos xy\\cdot\\left(x\\frac{dy}{dx}+y\\right)\\\\\n    &=x\\cos xy\\,\\frac{dy}{dx}+y\\cos xy.\\end{align*}\n\\eex\nThe above example used the chain rule first, and then \nthe product rule.  The first step could have been\nwritten\n\\begin{equation}\n\\frac{d\\sin xy}{dx}=\\frac{d\\sin xy}{d(xy)}\\cdot\\frac{d(xy)}{dx}.\n\\label{dsinxy/dx}\\end{equation}\nOf course it is important to note that, in the Leibniz notation,\n$d(xy)$ is taken to be one, encapsulated quantity.\nIt is {\\it not} a multiplication of three quantities,\nso for instance $d(xy)/dx\\ne y$.\nIndeed, $d(xy)/dx=x\\cdot(dy/dx) + y\\cdot (dx/dx)=\nx\\cdot (dy/dx)+y$ by the product rule.  However the\nchain rule {\\it does} allow for the apparent \ndivision and multiplication by $d(xy)$ in the \nderivative notation in (\\ref{dsinxy/dx}) above. \n\n\nTwo more points should be emphasized regarding the\nproduct rule computation above, which we repeat here:\n\\begin{equation}\n\\frac{d(xy)}{dx}=x\\,\\frac{dy}{dx}+y\\,\\frac{dx}{dx}.\\label{ProductRuleForXY}\n\\end{equation}\nFirst, note that (\\ref{ProductRuleForXY}) is {\\it exactly what the\nproduct rule says} for this product $xy$.  Thus it should be \nestablished true from the explicit result of the product rule.\nNext, when computing $\\frac{d}{dx}(y)$, we get exactly what we would\nfrom the chain rule, or from the power rule.  Thinking of $y$\nas a function ``raised to the power 1,'' we might write:\n\\begin{equation}\\frac{d(y)}{dx}=\\frac{d(y)}{dy}\\cdot\\frac{dy}{dx}\n=1\\cdot\\frac{dy}{dx}=\\frac{dy}{dx}.\\label{LeibnizDY/DX=DY/DX}\n\\end{equation}\nThus once again the derivative rules are self-consistent,\nas is Leibniz notation, properly interpreted.\n\n\n\n\n\n\\newpage\\subsection{Implicit Functions and Their Derivatives}\nIn previous sections we were interested in functions\n$y=f(x)$, i.e., where $y$ was given {\\it explicitly}\nas a function of $x$.  However, there are relationships and\ngraphs of interest where $y$ is related to $x$ {\\it implicitly},\nfor instance, by an equation which contains\nboth $y$ and $x$ as variables, except that\n$y$ is not solved for as an explicit function of $x$.\nIndeed, the graph of the equation\n(i.e., the graph of all $(x,y)$ which satisfy\nthe equation) might not represent a function\nat all.  However, it is quite possible for\n$y$ to be a function of $x$ {\\it locally} near\na point $(x_0,y_0)$ on the graph, and to speak of ``slope'' there.  \n\n\\begin{definition}\nWe will say $y$ is {\\bf locally} (or {\\bf implicitly}) a function of $x$\nnear $(x_0,y_0)$ if and only if there exists\n$\\delta,\\epsilon>0$ and an open rectangle \n$$\\left\\{(x,y)\\,\\left.\\vphantom{M_M^M}\\right|\n\\, \\left(|x-x_0|<\\delta\\right)\\wedge\\left(|y-y_0|<\\epsilon\\right)\\right\\}$$\nsuch that, within that open rectangle, the \ngraph represents $y$ as a function\n%\\footnotemark \nof $x$.\n\\end{definition}\n%\\footnotetext{By function here we mean, as before, it passes\n%the vertical line test, i.e., any vertical line \n%intersects the graph in at most one point inside the\n%open rectangle.}\nA simple example is a circle such as $x^2+y^2=25$.\nExcept at $(5,0)$ and $(-5,0)$, we can find a small\nenough, open rectangle around each point $(x_0,y_0)$ on \nthe graph so that $y$ is a function of $x$ \n{\\it inside that rectangle}.  Note that it is not necessary\nthat any vertical line touch the graph inside the rectangle, \nbut if it \ndoes touch the graph inside the rectangle it can only do so \nat one point.\n\n\\begin{figure}\n\n\\begin{center}\n\\begin{pspicture}(-4,-4)(4,4)\n\\psset{xunit=.7cm,yunit=.7cm}\n\n\\psframe[linestyle=dashed,%\nfillstyle=solid,fillcolor=lightgray](2.5,3.5)(3.5,4.5)\n\\pscircle[fillstyle=solid,fillcolor=black](3,4){.1}\n\n\\psframe[linestyle=dashed,%\nfillstyle=solid,fillcolor=lightgray](-1,4.5)(1,5.5)\n\\pscircle[fillstyle=solid,fillcolor=black](0,5){.1}\n\n\\psframe[linestyle=dashed,%\nfillstyle=solid,fillcolor=lightgray](-4.8,2.5)(-3.2,3.5)\n\\pscircle[fillstyle=solid,fillcolor=black](-4,3){.1}\n\n\\psaxes{<->}(0,0)(-6,-6)(6,6)\n\n\\pscircle[fillstyle=solid,fillcolor=black](0,5){.1}\n\n\\psframe[linestyle=dashed,%\nfillstyle=solid,fillcolor=lightgray](.1,-5.8989795)(1.9,-3.8989795)\n\\pscircle[fillstyle=solid,fillcolor=black](1,-4.8989795){.1}\n\n\\psframe[linestyle=dashed,%\nfillstyle=solid,fillcolor=lightgray](-2.55,-3.05)(-4.55,-4.05)\n\\pscircle[fillstyle=solid,fillcolor=black](-3.55,-3.55){.1}\n\n\\pscircle(0,0){3.5}\n\n\\end{pspicture}\n\n\\end{center}\n\\caption{The graph of $x^2+y^2=25$ gives $y$ as a \nfunction of $x$ locally except\nat $(-5,0)$ and $(5,0)$.  Some possible open rectangles\ncentered at various $(x_0,y_0)$ on the graph are drawn, \nwithin each of which (separately) $y$ is a function of $x$.}\n\\label{CircleForImplicitDifferentiation}\\end{figure}\n\nNow suppose we would like to find the slope of \nthe graph of $x^2+y^2=25$, without solving for $y$\nfirst.\\footnotemark\\footnotetext{For this one we can\nsolve for $y$, almost: $\\ds{y=\\pm\\sqrt{25-x^2}}$.\nFor many curves we\ncannot.  Even if we can, it is sometimes easier to\nuse the equation as it stands.}\\hphantom{. }\nIf we are at a point $(x_0,y_0)$ satisfying the\nequation $x^2+y^2=25$, and for which \nwe can (in principle) find an open rectangle\ncentered at $(x_0,y_0)$ in which $y=y(x)$,\ni.e., in which $y$  is a function of $x$,\nthen {\\it inside such a rectangle},\nwe have that $y^2=(y(x))^2$ is a (composite) function\nof $x$, and $x^2+y^2$ is therefore also a  function of $x$.\nFurthermore, $25$ is a (rather trivial) function of $x$ and,\ninside the rectangles, \n$x^2+y^2$ and $25$ are  in fact the {\\it same} function of $x$:\n$$\\underbrace{x^2+y^2}_{{\\begin{array}{c}\\text{function of }x\\\\\n\\text{ in each rectangle}\\end{array}}}\n=\\underbrace{25.}_{\\begin{array}{c}\\text{same function of }x\\\\\n\\text{in the rectangles}\\end{array}}$$\nBecause these are the same functions of $x$ in an open rectangle, they\nhave the same derivatives with respect to  $x$ there.  Thus we can state\n\\begin{equation}\n\\frac{d}{dx}\\left(x^2+y^2\\right)=\\frac{d}{dx}\\left(\n\\vphantom{x^2}25\\right).\\label{DerivCircRad5Step1}\\end{equation}\nNow suppose that we are in a rectangle in which $y$ is\na function of $x$.  In the above we are taking\nthe derivative with respect to $x$.  The first\nterm is a simple power rule, but the second is a\nchain rule version of the power rule since the\nvariables do not match, while the other side of the equation\nis a constant.  Thus, (\\ref{DerivCircRad5Step1}) becomes\n$${2x}+{2y\\,\\frac{dy}{dx}}={0}.$$\nIt is $\\frac{dy}{dx}$ that we want, i.e., the slope\non the original curve.  Fortunately  we can now solve for it:\n\\begin{alignat*}{2}\n&&2x+2y\\,\\frac{dy}{dx}&=0\\\\\n&\\iff&2y\\,\\frac{dy}{dx}&=-2x\\\\\n&\\iff&\\frac{dy}{dx}&=\\frac{-2x}{2y}=-\\frac{x}y.\\end{alignat*}\nSome more notation is now needed for when we wish to \nevaluate this at particular points on the curve.\nThe value of $\\frac{dy}{dx}$ at such $(x_0,y_0)$ on the curve is \nwritten\n$$\\left.\\frac{dy}{dx}\\right|_{(x_0,y_0)}.$$\nOut loud, this is said, ``$\\frac{dy}{dx}$ evaluated at \n$\\left(x_0,y_0\\right)$.''\nLooking back at the circle, we can find the slopes\nat any $(x_0,y_0)$ which is on the graph:\n\\begin{align*}\n\\left.\\frac{dy}{dx}\\right|_{(3,4)}&=\n\\left.-\\frac{x}y\\right|_{(3,4)}=-\\frac34,\\\\\n\\left.\\frac{dy}{dx}\\right|_{(0,5)}\n&=\\left.-\\frac{x}{y}\\right|_{(0,5)}=-\\frac05=0,\\\\\n\\left.\\frac{dy}{dx}\\right|_{(-4,3)}\n&=\\left.-\\frac{x}{y}\\right|_{(-4,3)}=-\\frac{-4}3=\\frac43,\n\\qquad\\text{etc.}\\end{align*}\nA quick check of the graph in Figure~\\ref{CircleForImplicitDifferentiation}\nshows that these slope calculations ring true.  In fact,\nit is interesting to notice what happens if we attempt to evaluate\n$\\left.\\frac{dy}{dx}\\right|_{(5,0)}$. If we naively\ninsert $(5,0)$ into $\\frac{dy}{dx}=-\\frac{x}y$, we \nwould get $-\\frac50$, which is undefined.  Thus the\nderivative there does not exist, which is born out\nby the graph in the sense that there is no\ndefined slope there. (Note that in the Euclidean geometry sense the \ntangent to the circle is a vertical line there.)\nSimilarly for $(-5,0)$.\n\nWe might also be interested in the equation of a tangent line.\nFor instance, at $(x,y)=(-4,3)$, we have the slope\n$$\\left.\\frac{dy}{dx}\\right|_{(-4,3)}=\\left.\\frac{-x}{y}\\right|_{(-4,3)}\n  =\\frac{-(-4)}{3}=4/3,$$\nand so with the point $(-4,3)$ we have the line $y=3+\\frac43(x+4)$.\nNote that the point $(-4,3)$ is one of the points illustrated as\nthe center of an open box in Figure~\\ref{CircleForImplicitDifferentiation},\nand a glance at the point in question shows this to be a reasonable\nslope and tangent line there.\n\nNow the circle example above need not use this {\\it implicit differentiation}\ntechnique, that is finding $dy/dx$ from an implicit curve where $y$ is not\nan explicit function of $x$.  We need not use the technique because\nnear any such $(x_0,y_0)$ on the curve, we can write $y$ as an \n{\\it explicit} function of $x$ and compute the derivative.\nOn the upper semi-circle we have $y=\\sqrt{25-x^2}$, and so\n$$\\frac{dy}{dx}=\\frac{d}{dx}\\sqrt{25-x^2}\n   =\\frac1{2\\sqrt{25-x^2}}\\,\\frac{d\\left(25-x^2\\right)}{dx}\n   =\\frac{-2x}{2\\sqrt{25-x^2}}=\\frac{-x}{\\sqrt{25-x^2}}.$$\nNotice that (on the upper semicircle)\nthis is the same as the derivative acquired through implicit\ndifferentiation:\n$$\\frac{dy}{dx}=\\frac{-x}{\\sqrt{25-x^2}}=\\frac{-x}y.$$\nA similar analysis shows that on the lower semicircle we also get\ntwo equivalent forms of the derivative:\n$$\\frac{dy}{dx}=\\frac{d}{dx}\\left[-\\sqrt{25-x^2}\\right]=\\cdots\n    =\\frac{x}{\\sqrt{25-x^2}}\n    =\\frac{x}{-y}.$$\nNow we consider other examples where it is not clearly possible\nto solve for $y$ as an explicit function of $x$.\n\n\\bex Consider the curve $\\ds{(x^2+y^2)^{3/2}=2xy}$, which is graphed\nin Figure~\\ref{GraphForExampleWhichIsAlmostR=Sin2Theta},\npage~\\pageref{GraphForExampleWhichIsAlmostR=Sin2Theta}.  (Much later\nin the text we will see how this graph came about.)\nFirst we find $\\frac{dy}{dx}$ by applying the differential\noperator $\\frac{d}{dx}$ to both sides:\n\\begin{alignat*}{2}\n&\\qquad&(x^2+y^2)^{3/2}&=2xy\\\\\n&\\implies&\\frac{d}{dx}\\left[(x^2+y^2)^{3/2}\\right]&\n                   =\\frac{d}{dx}\\left[2xy\\right]\\\\\n&\\implies&\\frac32(x^2+y^2)^{1/2}\\cdot\\frac{d}{dx}(x^2+y^2)&=\n    2\\left[x\\frac{dy}{dx}+y\\frac{dx}{dx}\\right]\\\\\n&\\implies&\\frac32(x^2+y^2)^{1/2}\\cdot\\left(2x+2y\\,\\frac{dy}{dx}\\right)\n                  &=2\\left(x\\,\\frac{dy}{dx}+y\\cdot1\\right)\\\\\n&\\implies&\\qquad\\frac32(x^2+y^2)^{1/2}(2x)+\\frac32(x^2+y^2)^{1/2}\n                                          \\left(2y\\,\\frac{dy}{dx}\\right)\n                  &=2x\\,\\frac{dy}{dx}+2y\\\\\n&\\implies &3x\\sqrt{x^2+y^2}+3y\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}&\n          =2x\\,\\frac{dy}{dx}+2y\\\\\n&\\implies&3y\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}-2x\\,\\frac{dy}{dx}&\n           =2y-3x\\sqrt{x^2+y^2}\\\\\n&\\implies&\\left[3y\\sqrt{x^2+y^2}-2x\\right]\\frac{dy}{dx}&=2y-3x\\sqrt{x^2+y^2}\\\\\n&\\implies&\\frac{dy}{dx}&=\\frac{2y-3x\\sqrt{x^2+y^2}}{3y\\sqrt{x^2+y^2}-2x}.\n\\end{alignat*}\n\nNow we will compute the slope for two points on the curve, \n$\\left(\\frac1{\\sqrt2},\\frac1{\\sqrt2}\\right)$ and\n$\\left(\\frac34,\\frac{\\sqrt{3}}4\\right)$, which are labeled\nin Figure~\\ref{GraphForExampleWhichIsAlmostR=Sin2Theta},\npage~\\pageref{GraphForExampleWhichIsAlmostR=Sin2Theta}.\n(The reader should verify that these points are actually on\nthe original curve.)\n\\begin{itemize}\n\\item $\\ds{\\left.\\frac{dy}{dx}\n       \\right|_{\\left(\\frac1{\\sqrt2},\\frac1{\\sqrt2}\\right)}\n  =\\left.\\frac{2y-3x\\sqrt{x^2+y^2}}{3y\\sqrt{x^2+y^2}-2x}\n  \\right|_{\\left(\\frac1{\\sqrt2},\\frac1{\\sqrt2}\\right)}\n  =\\frac{2\\cdot\\frac1{\\sqrt2}-3\\cdot\\frac1{\\sqrt2}\n          \\sqrt{\\left(\\frac{1}{\\sqrt2}\\right)^2\n               +\\left(\\frac{1}{\\sqrt2}\\right)^2}}\n         {3\\cdot\\frac1{\\sqrt2}\\sqrt{\\left(\\frac{1}{\\sqrt2}\\right)^2\n               +\\left(\\frac{1}{\\sqrt2}\\right)^2}-2\\cdot\\frac1{\\sqrt2}}}$\n\n\\qquad$\\ds{=\\frac{\\sqrt2-\\frac{3}{\\sqrt2}\\cdot1}{\\frac3{\\sqrt2}\\cdot1-\\sqrt2}\n           =-\\frac{\\left(\\frac3{\\sqrt2}-\\sqrt2\\right)}\n                  {\\frac3{\\sqrt2}-\\sqrt2}=-1}$.\n\nThis should seem reasonable given the position of this point on the graph.\n For the computation of $\\frac{dy}{dx}$ at\n$\\left(\\frac34,\\frac{\\sqrt{3}}4\\right)$ we will \nbe more brief.  \n\\item $\\ds{\\left.\\frac{dy}{dx}\n       \\right|_{\\left(\\frac34,\\frac{\\sqrt{3}}4\\right)}\n     =\\frac{2\\cdot\\frac{\\sqrt3}4-3\\cdot\\frac34\\sqrt{\\frac{12}{16}}}\n           {3\\cdot\\frac{\\sqrt{3}}4\\sqrt{\\frac{12}{16}}-2\\cdot\\frac34}\n     =\\frac{\\frac{\\sqrt3}{2}-\\frac94\\cdot\\sqrt{\\frac34}}\n           {3\\cdot\\frac{\\sqrt3}4\\sqrt{\\frac34}-\\frac32}\n     =\\frac{\\frac{\\sqrt3}{2}-\\frac94\\cdot\\frac{\\sqrt3}2}\n           {3\\cdot\\frac{\\sqrt3}4\\cdot\\frac{\\sqrt3}2-\\frac32}\\cdot\\frac88\n     =\\frac{4\\sqrt3-9\\sqrt3}{9-12}}$\n\n\\qquad$\\ds{=\\frac{-5\\sqrt3}{-3\\sqrt3}=\\frac53\\sqrt3\\approx2.88675135.}$\n\nThis should also seem reasonable from the graph in \nFigure~\\ref{GraphForExampleWhichIsAlmostR=Sin2Theta}.\n\\end{itemize}\n\n\n\n\n\\label{ExampleWhichIsAlmostR=Sin2Theta}\n\\eex\n\n\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-3,-3)(3,3)\n\\psset{xunit=2.3,yunit=2.3}\n\\psaxes{<->}(0,0)(-1.3,-1.3)(1.3,1.3)\n\\parametricplot{0}{90}{2 t mul sin t cos mul %\n                        2 t mul sin t sin mul }\n\\parametricplot{180}{270}{2 t mul sin t cos mul %\n                        2 t mul sin t sin mul }\n\\pscircle[fillstyle=solid,fillcolor=black](.75,.433){.07}\n  \\rput(1,.9){$\\left(\\frac1{\\sqrt2},\\frac1{\\sqrt2}\\right)$}\n\\pscircle[fillstyle=solid,fillcolor=black](.7071,.7071){.07}\n  \\rput(1.1,.4){$\\left(\\frac34,\\frac{\\sqrt3}4\\right)$}\n\n\\end{pspicture}\n\\end{center}\n\\caption{Graph of $(x^2+y^2)^{3/2}=2xy$.  \nThe slope $dy/dx$ at each point $(x,y)$ on the curve is\ncalculated in Example~\\ref{ExampleWhichIsAlmostR=Sin2Theta}.\nThe points $(x,y)=\\left(\\frac1{\\sqrt2},\\frac1{\\sqrt2}\\right)$\nand $(x,y)=\\left(\\frac34,\\frac{\\sqrt3}4\\right)$ are plotted\nas well, for which slopes were computed in that example.}\n\\label{GraphForExampleWhichIsAlmostR=Sin2Theta}\n\\end{figure}\n\n\n\n\n\n\n\n\nThe argument in the proof of the power rule\nfor rational powers of $x$,  Theorem~\\ref{PowerRuleForRationalPowers}\non page \\pageref{PowerRuleForRationalPowers},\nused this implicit differentiation technique.  As in that proof, \nwe can compute $\\frac{dy}{dx}$ without worrying about actually finding\nthe open rectangles which give $y$ locally as a function of $x$.\nThe rectangles are important in justifying the technique, but\nif something goes wrong, it will usually show up in the final\nform of the computed derivative. \n\n\n%Before proceeding, we point again for emphasis \n%that It should be pointed out that this implicit differentiation\n%is in fact a simple extension of the chain rule\n%(hence the title of this section).\n%At times we find a function of $y$ inside these equations.\n%According to the chain rule, \n%\\begin{equation}\\frac{d\\,f(y)}{dx}=f'(y)\\cdot\\frac{dy}{dx}.\\end{equation} \n%Now we present some further\n%examples of this implicit differentiation technique.\n%{(F(U))'=F'(U)U'}\n\n\n\n%\\bex Find $\\frac{dy}{dx}$ on the curve \n%$\\sin x=\\cos y$.\n%Again we apply $\\frac{d}{dx}$ to both sides.\\footnotemark\n%\\footnotetext{Recall that this is possible wherever \n%the graph gives $y$ locally as a function of $x$.\n%Thus the left-hand side and right-hand side of $\\sin x=\\cos y$\n%are the same functions of $x$, and therefore have the\n%same derivative.}\n%\\begin{alignat*}{2}\n%&&\\sin x&=\\cos y\\\\\n%\\implies&\\qquad&\\frac{d\\,\\sin x}{dx}&=\\frac{d\\, \\cos y}{dx}\\\\\n%\\implies&&\\cos x&=-\\sin y \\cdot\\frac{dy}{dx}\\\\\n%\\implies&&-\\frac{\\cos x}{\\sin y}&=\\frac{dy}{dx}.\\end{alignat*}\n%(It is not important here that we do not have $\\iff$.\n%There are technical reasons, such as the fact that we can \n%add any constant to the first line and still have the second.\n%Since we are assuming the first line is true, so must be the last.)\n%\n%We can then also  talk about tangent lines to the curve\n%(even if we cannot easily graph the equation).\n%For instance, the point $(3\\pi/4,\\pi/4)$ is on the curve.\n%The tangent line there is given by\n%\\begin{alignat*}{2}\n%{}&{}&y-\\frac{\\pi}{4}&=\\left.\\frac{dy}{dx}\\right|_{(3\\pi/4,\\pi/4)}\n%\\cdot\\left(x-\\frac{3\\pi}{4}\\right)\\\\\n%&\\iff&\\qquad\n%y-\\frac{\\pi}4&=-\\frac{\\cos\\frac{3\\pi}4}{\\sin\\frac{\\pi}4}\n%\\left(x-\\frac{3\\pi}{4}\\right)\\\\\n%&\\iff&\\qquad y-\\frac{\\pi}4&=-\\frac{-\\frac1{\\sqrt2}}{\\frac1{\\sqrt2}}\n%\\left(x-\\frac{3\\pi}{4}\\right)\\\\\n%&\\iff&\\qquad y-\\frac{\\pi}4&=x-\\frac{3\\pi}{4}\\\\\n%&\\iff&y&=x-\\frac{\\pi}2.\n%\\end{alignat*}\n%\\eex\n\n\\bex Find $\\frac{dy}{dx}$ for the graph $\\ds{5x+x^2+y^2+xy=\\tan y}$.\n\\label{UglyImplicitDiffW/TanLine}\nThis one will require a couple chain rules\nfor the $y^2$ and $\\tan y$ terms, and a product rule\nfor the $xy$ term.\nAs before, if we are careful in writing out the product rule\nwe are less likely to have errors.\n\\begin{alignat*}{2}\n&&\\frac{d}{dx}\\left[5x+x^2+y^2+xy\\right]&=\\frac{d\\,\\tan y}{dx}\\\\\n&\\implies&5+2x+2y\\cdot\\frac{dy}{dx}\n+\\left[x\\,\\frac{dy}{dx}+y\\,\\frac{dx}{dx}\\right]&=\\sec^2y\\cdot\\frac{dy}{dx}\\\\\n&\\implies&5+2x+2y\\,\\cdot\\frac{dy}{dx}+x\\,\\frac{dy}{dx}+y\n&=\\sec^2y\\cdot\\frac{dy}{dx}\\\\\n&\\implies&5+2x+y&=\\sec^2y\\,\\frac{dy}{dx}-2y\\,\\frac{dy}{dx}-x\\,\\frac{dy}{dx}\\\\\n&\\implies&5+2x+y&=\\left(\\sec^2y-2y-x\\right)\\frac{dy}{dx}\\\\\n&\\implies&\\frac{5+2x+y}{\\sec^2y-2y-x}&=\\frac{dy}{dx}.\n\\end{alignat*}\nTo find the tangent line through $(0,0)$, which is on the graph, we then \ncompute\n$$\\left.\\frac{dy}{dx}\\right|_{(0,0)}=\\left.\\frac{5+2x+y}{\\sec^2y-2y-x}\n  \\right|_{(0,0)}=\\frac{5+0+0}{1-0-0}=5,$$\nand so the tangent line through $(0,0)$ has equation $y=5x$.\n\\eex\nThough we do not have the tools to prove it here, \nit is true that we\nwill always be able to solve for $\\frac{dy}{dx}$\nin these problems.  The basic idea of a proof is that\n$\\frac{dy}{dx}$ will always be a {\\it factor} in the terms in which\nit appears, and will only appear to the\nfirst degree, so we are basically solving a {\\it linear} equation in the \n``variable'' $\\frac{dy}{dx}$, albeit with nonconstant coefficients.\nSo in fact it is no different fundamentally than\nsolving $Ax+By+C=Dx+Ey+F$ for $y$ (or for $x$, for that matter).\nOne  moves all terms containing\nthat variable to one side, the other terms to the other side, factors\nthe variable from the side which then contains it, and divides by the other\nfactor.\n\nOf course our implicit differentiation technique begins with calculus\nsteps and ends with algebra steps.  The entire process can be summarized by\nfour steps:\n\n\\begin{enumerate}[(1)]\n\\item complete all differentiation steps, flushing out all\nterms with a factor $\\frac{dy}{dx}$,\n\\item put all terms with $\\frac{dy}{dx}$ factors on one side,\nother terms on the other side of the equation,\n\\item factor the $\\frac{dy}{dx}$ from the side which\ncontains it, and finally,\n\\item divide by the remaining factor, leaving $\\frac{dy}{dx}$\non one side by itself.\n\\end{enumerate}\n\n\\bex Consider the equation $x=\\sin y$.  The slope $\\frac{dy}{dx}$\nis then computed as follows:\n\\begin{alignat*}{2}\n&\\qquad\\qquad&x&=\\sin y\\\\\n&\\implies&\\frac{d}{dx}[x]&=\\frac{d}{dx}[\\sin y]\\\\\n&\\implies&1&=\\cos y\\,\\frac{dy}{dx}\\\\\n&\\implies&\\frac1{\\cos y}&=\\frac{dy}{dx}.\n\\end{alignat*}\nSo for instance the slope at $\\left(\\frac12,\\frac{\\pi}6\\right)$\nis given by $\\frac{dy}{dx}=1/\\cos\\frac{\\pi}6=\\frac1{\\sqrt{3}/2}\n=2/\\sqrt3$, and the equation of the tangent line there is\n$$y=\\frac{\\pi}6+\\frac2{\\sqrt3}\\left(x-\\frac12\\right).$$\n\nIt is also worth noting what happens when $\\cos y=0$, and\nits implications for $\\frac{dy}{dx}$, in light of the graph.\n\nThe next example is quite long, but with persistence is also quite do-able.\n\n\\label{ExampleX=SineYForImplicitSeciton}\n\\eex\n\n\\begin{figure}[h]\n\\begin{center}\n\n\\begin{pspicture}(-2,-4)(2,4)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=20]{<->}(0,0)(-2,-8)(2,8)\n\\parametricplot[plotpoints=2000]{-8}{8}{t 180 mul 3.14159265 div sin t}\n\n\\psline(-.2,-3.1415)(.2,-3.1415)\n\\psline(-.2,3.1415)(.2,3.1415)\n\\rput[l](.3,-3.1415){$-\\pi$}\n\\rput[l](.3,3.1415){$\\pi$}\n\n\\psline(-.2,-6.28)(.2,-6.28)\n\\psline(-.2,6.28)(.2,6.28)\n\\rput[l](.3,-6.28){$-2\\pi$}\n\\rput[l](.3,6.28){$2\\pi$}\n\\pscircle[fillcolor=black,fillstyle=solid](.5,.52359){.08}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $x=\\sin y$, which is similar to $y=\\sin x$ \nexcept that the roles of $x$ and $y$ are reversed.  The point\n$(1/2,\\pi/6)$ is highlighted from \nExample~\\ref{ExampleX=SineYForImplicitSeciton}.}\n\\label{FigureForX=SineYForImplicitSection}\\end{figure}\n\n\n\\bex Find $\\frac{dy}{dx}$ on the graph of \n$\\ds{y^3\\sec\\sqrt{x^2+y^2}=\\cos2x}$.\n\\begin{alignat*}{2}\n&&\\frac{d}{dx}\\left[y^3\\sec\\sqrt{x^2+y^2}\\right]&=\\frac{d\\,\\cos 2x}{dx}\\\\\n&\\implies&y^3\\frac{d}{dx}\\left[\\sec\\sqrt{x^2+y^2}\\right]\n+\\sec\\sqrt{x^2+y^2}\\cdot\\frac{d\\,y^3}{dx}\n&=-\\sin2x\\cdot\\frac{d\\,2x}{dx}\\\\ \n&\\implies& y^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}\n\\cdot\\frac{d}{dx}\\sqrt{x^2+y^2}\\quad&\\\\ \n&&+\\sec\\sqrt{x^2+y^2}\\cdot 3y^2\\cdot\\frac{dy}{dx}\n&=-\\sin2x\\cdot2\\\\ \n&\\implies&y^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}\n\\cdot\\frac1{2\\sqrt{x^2+y^2}}\\cdot\\frac{d}{dx}(x^2+y^2)\n&\\\\\n&&+3y^2\\sec\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}&=-2\\sin2x\\\\ \n&\\implies&\\frac{y^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}\n}{2\\sqrt{x^2+y^2}}\\cdot\\left(2x+2y\\frac{dy}{dx}\\right)\\qquad\\qquad&\\\\\n&&+3y^2\n\\sec\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}\n&=-2\\sin2x.\\\\\n\\end{alignat*}\nNext we apply the distributive in the first term to flush out\nthe $\\frac{dy}{dx}$ terms and get\n\\begin{multline*}\n\\frac{xy^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}\n+\\frac{y^4\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}\n\\cdot\\frac{dy}{dx}\\\\\n+3y^2\\sec\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}=-2\\sin2x.\n\\end{multline*}\nNow we put all terms with the factor $\\frac{dy}{dx}$ on one side\n(here, the left side), and the others on the opposite side:\n\\begin{multline*}\n\\frac{y^4\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}\n\\cdot\\frac{dy}{dx}+3y^2\\sec\\sqrt{x^2+y^2}\\cdot\\frac{dy}{dx}\n\\\\\n=-2\\sin2x-\\frac{xy^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}\n\\end{multline*}\nNext we factor the $\\frac{dy}{dx}$:\n\\begin{multline*}\n\\left(\\frac{y^4\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}\n\\cdot\\frac{dy}{dx}+3y^2\\sec\\sqrt{x^2+y^2}\\right)\\frac{dy}{dx}\n\\\\\n=-2\\sin2x-\\frac{xy^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}.\n\\end{multline*}\nFinally, we divide to solve for $\\frac{dy}{dx}$:\n\n\n$$\\frac{dy}{dx}\n=\\frac{-2\\sin2x-\\ds{\\frac{xy^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}\n{\\sqrt{x^2+y^2}}}}\n{\\ds{\\frac{y^4\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}}\n+3y^2\\sec\\sqrt{x^2+y^2}}.$$\n\nFinally, if we would like, we can multiply the numerator\nand denominator by $\\ds{\\sqrt{x^2+y^2}}$ to get:\n$$\\frac{dy}{dx}\n=\\frac{-2\\sqrt{x^2+y^2}\\sin2x-xy^3\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}}\n{y^4\\sec\\sqrt{x^2+y^2}\\tan\\sqrt{x^2+y^2}+3y^2\\sqrt{x^2+y^2}\n\\sec\\sqrt{x^2+y^2}}.$$\n\n\n\nAlthough this example may seem tedious, no particular \nstep is conceptually difficult.  Success in such\na project is nearly as much dependent upon our bookkeeping \nskills as upon understanding of derivative rules.\n\n\\eex\n\n\\subsection{A Mistake to Avoid}\nBefore finishing this section a remark is in order.\nIt is tempting to try to simplify an algebraic\nequation by taking derivatives of both sides, especially\nin the case of polynomial equations.  However,\nin such cases we are looking for {\\it points} where\none side equals the other, which is very different\nfrom saying the two sides are the same {\\it functions}\nof, say, $x$.\nFor a very simple case, consider the equation\n\\begin{equation}x^2-2x+1=5-2x.\\label{DumbExample1}\\end{equation}\nThis succumbs easily to the earlier methods:\n\\begin{alignat*}{2}&\\qquad&x^2-2x+1&=5-2x\\\\&\\iff& x^2&=4\\\\\n&\\iff& x&=-2,2\\end{alignat*}\nso the solution is simply $x=\\pm2$.  Now suppose instead we\ntried to take derivatives of both sides of (\\ref{DumbExample1}):\n\\begin{alignat*}{2}\n&\\qquad&2x-2&=-2\\\\ &\\iff& 2x&=0\\\\ &\\iff& x&=0.\\end{alignat*}\nWe see that we get the incorrect answer.  Thus if we\nare {\\it solving} $f(x)=g(x)$, it does not follow that\n$f'(x)=g'(x)$.  It {\\it is} true {\\it if they are the\nsame functions}, i.e., same heights everywhere\n(and we use this fact in our implicit differentiation\nprocess), but\nwhen we solve algebraic equations we are only interested\nin those points where the graphs of the two\n(usually different) functions intersect.\nIt is unlikely that they would share the  same slopes there\nas well as the heights. Hence it is important to \nuse algebraic arguments where appropriate, and calculus\narguments where appropriate.\nSee Figure~\\ref{DumbExample1Figure}.\n\\begin{figure}\n\\begin{center}\n%\\begin{pspicture}(-1.4,-1)(8.4,9)\n%\\psset{xunit=1.4cm,yunit=.5cm}\n%\\psaxes[Dy=10]{<->}(0,0)(-1,-10)(6,50)\n%\\psplot[plotpoints=2000]{-1}{6}{x 8 mul}\n%\\psplot[plotpoints=2000]{-1}{6}{x dup mul 15 add}\n%\\end{pspicture}\n\\begin{pspicture}(-4,-1.5)(4,9)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=2]{<->}(0,0)(-4,-3.5)(4,18)\n\\psplot{-3.23}{4}{x 1 sub dup mul}\n\\psplot{-4}{4}{5 2 x mul sub}\n\n\\rput(2,14){$\\ds{\\begin{aligned}f(x)&=x^2-2x+1\\\\\n                                g(x)&=5-2x\\end{aligned}}$}\n\\end{pspicture}\n\n\n\\end{center}\n\\caption{\n%Graphs of $f(x)=x^2-2x+1$ and $g(x)=5-2x$.\n%Finding $x_0$ solving $f(x)=g(x)$ is {\\it not}\n%the same (and not  even implied by) solving $f'(x)=g'(x)$. \n%Here we see that the $x$-values that solve $f(x)=g(x)$\n%are $x=\\pm2$,\n%i.e., where the two curves meet.\n%These points do not also satisfy $f'(x)=g'(x)$,\n%or $2x-2=-2$ (which occurs at $x=0$).  From the graph\n%it is clear that  the slopes of the\n%two curves are different where they intersect.\n%In other words, we\n%cannot solve algebraic equations by taking the derivatives \n%of both sides.  However, if $f(x)$ and $g(x)$ {\\it are the\n%same functions}, then their derivatives are the same.\nThe graphs intersect at $x=\\pm2$, which is the solution\nto $x^2-2x+1=5-2x$.  However, it is clear from the picture\nthat, though $f(x)=g(x)$ at $x=\\pm2$, the derivatives (slopes)\n$f'(x)$ and $g'(x)$ at those two points are not the same.\nIn fact, the derivatives are the same at $x=0$ only,\nfrom $2x-2=-2$ (i.e., $f'(x)=g'(x)$).  A quick look at the graphs\nshows the slopes at $x=0$ do appear to  agree.}\n\\label{DumbExample1Figure}\\end{figure}\n\n\n\n\n\n\n\n\n\\newpage\n\n\n\\newpage\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item\n\\item Consider the algebraic equation\n $$x^2=9.$$\n \\begin{enumerate}\n \\item Define  functions $f(x)=x^2$ and $g(x)=9$ and graph them\n       together  on one grid.\n \\item What is its solution of the original equation, i.e.,\n       of $f(x)=g(x)$?\n \\item What is the graphical significance of the solution\n       of $f(x)=g(x)$?\n \\item Now consider the equation $f'(x)=g'(x)$ for these two \n       functions $f$ and $g$. What is the solution\n       of this new equation $f'(x)=g'(x)$?\n \\item Explain the significance of the solution of\n       $\\frac{d}{dx}f(x)=\\frac{d}{dx}g(x)$\n       for this particular example.\n \\item Explain why, if a particular $x$ satisfies $f(x)=g(x)$,\n       we cannot expect that it also satisfies $f'(x)=g'(x)$.\n \\end{enumerate}\n\\item Repeat the previous problem for the equation $\\sin x=\\cos x$,\n      for $x\\in[0,2\\pi]$.\n\\end{enumerate}\n\n\\end{multicols}\n\n\n\\newpage\n\\section{Arctrigonometric Functions and their Derivatives}\n\nIn this and the next three sections, we will explore derivatives of\nthe last of our standard classes of functions.\nPresently we will look at the arctrigonometric functions, while\nin the next two sections we will look respectively at exponential, and\nthen logarithmic functions.  While we will need to be mindful of\nthe exact natures of these functions, with their derivative formulas \nwe will usually  be able to simply apply the new formulas\ntogether with the previous rules, and in so doing nearly \nfinish our study of computing\nderivatives.  The final section will be for review, and to consider\nsome other complications which arise on occasion.\n\n\n\n\n\n\\subsection{One-to-one Functions and Inverses, Briefly}\n\nThe arctrigonometric functions are also called the \n{\\it inverse trigonometric functions}.  There is one\nproblem with this, in that the trigonometric functions\nare not invertible {\\it per se}.  But that does not\nkeep us from defining  inverse functions in specific\nlocal contexts, in ways which are still useful in other contexts.\n\n\nRecall what it means for a function $y=f(x)$ to be invertible.\nIt is also described as {\\it one-to-one}, meaning that\nfor $f:S\\longrightarrow \\Re$, i.e., where $S$ is the domain of $f$,\nwe have\n\\begin{equation}\n\\left(\\forall x_1,x_2\\in S\\right)\\left[\\left(x_1=x_2\\right)\n\\longleftrightarrow\\left(f\\left(x_1\\right)=\n                      f\\left(x_2\\right)\\right)\\right]\n                \\label{One-To-OneDefArcTrigSection}\n\\end{equation}\nNote that for $f$ to be a function we already\nhave $\\left(\\forall x_1,x_2\\in S\\right)\n\\left[\\left(x_1=x_2\\right)\\longrightarrow\n\\left( f\\left(x_1\\right)=f\\left(x_2\\right)\\right)\\right]$,\ni.e., the input completely determines the output.\nFor the function to be one-to-one means we also have $\\longleftarrow$,\ni.e., the output also completely determines what was the input.\nWhen we have such an $f$, we call its {\\it inverse} the function\n$g$ defined by the property\n\\begin{equation}\n(\\forall x\\in S)(\\forall y\\in f(S))[g(y)=x\\longleftrightarrow f(x)=y].\n\\label{DefOfInverseFunctionInGeneral}\\end{equation}\nIn such a context\nwe then denote this inverse function $g$ using a notation \ncomes from another mathematical context (not the subject of\nthis book), seems somewhat out of place here,\nbut which is so prevalent that it is used universally and will\ntherefore be adopted here.\nThat notation for the inverse function is conventionally given by\n$f^{-1}$, though here the $-1$ ``exponent'' is definitely not to be construed\nas a ``power'' as we would normally.\\footnote{%\n%%% FOOTNOTE\nIndeed, anytime we have an ``exponent'' which is not $-1$, we\nassume it is a true exponent.  However, the ``exponent''\n$-1$, when immediately modifying a function given by\nname such as $f$, $g$, etc., or any of\nthe named trigonometric functions, it is reserved to denote\ninstead (what is taken to be) the inverse function.\n%%% END FOOTNOTE\n} Thus, if $f$ is one-to-one, we have\n\\begin{alignat}{3}\n&(\\forall x\\in S)&&[f^{-1}(f(x))&&=x],\\label{InversesProp1}\\\\\n&(\\forall y\\in f(S))&&[f(f^{-1}(y))&&=y].\\label{InversesProp2}\\end{alignat}\nIn other words, the functions $f$ and $f^{-1}$ ``undo'' each other;\nfor a one-to-one function $f$ with inverse $f^{-1}$, we have\nthat their  mappings are reversible:\n$$x\\overset{f}{\\longmapsto}\\underbrace{y}_{f(x)}\n\\overset{f^{-1}}{\\longmapsto}\\underbrace{x}_{f^{-1}(y)},$$\nwhich as mappings of sets would look like\n$$S\\overset{f}{\\longrightarrow}f(S)\\overset{f^{-1}}{\\longrightarrow}S.$$\n\nThe usual algebraic (as opposed to the graphical) \nway to attempt to invert a function $f$ (that is, compute\nits inverse function) is to solve the equation $y=f(x)$ for $x$, since\n$$f\\text{ one-to-one} \\iff\n  (\\forall x,y)\\left[ y=f(x)\\longleftrightarrow x=f^{-1}(y)\\right].$$\n(This is just a re-writing of (\\ref{DefOfInverseFunctionInGeneral}).)\nOften in the process of attempting to calculate $f^{-1}$ we\nwill discover if it in fact exists, i.e., if $f$ is one-to-one.  \nThere can be many \ntechnicalities, depending upon the original function, but \nalso many computations are straightforward.\n\\bex\nConsider the function $f(x)=6x-9$.  Compute $f^{-1}(x)$,\nand from that also compute\n$f^{-1}(f(x))$ and $f(f^{-1}(y))$.\n\n\\underline{Solution}: The usual method is essentially to write\n$y=f(x)$ and try to solve for $x$.  If it can be done uniquely,\nthen our equation will be of the form $x=f^{-1}(y)$. \n$$\ny=f(x)\\qquad\\iff\\qquad y=6x-9\\qquad\n      \\iff\\qquad\\underbrace{\\frac{y+9}6}_{f^{-1}(y)}=x.$$\nIncluding our original function and the answers to the question, we\nhave:\n\\begin{align*}\nf(x)&=6x-9,\\\\\nf^{-1}(y)&=\\frac16(y+9),\\\\\nf^{-1}(f(x))&=\\frac16[f(x)+9]=\\frac16(6x-9+9)=\\frac16(6x)=x,\\\\\nf(f^{-1}(y))&=[(f^{-1}(y)]-9=6\\left(\\frac16(y+9)\\right)-9=\n                              (y+9)-9=y.\\end{align*}\n\\eex\nNote how applying $f^{-1}$ indeed ``undoes'' the process of applying $f$\nto an element in the domain of $f$, while applying $f$ ``undoes'' the\nprocess of applying $f^{-1}$ to an element of $f(S)$.  That is the essence\nof (\\ref{InversesProp1}) and (\\ref{InversesProp2}) from before.\n\n\n\n\n\n\n\n\n\\subsection{The Arctrigonometric Functions and Their Derivatives}\n\n\nIn Table~\\ref{TableOfArctrigonometricFunctions}, \npage~\\pageref{TableOfArctrigonometricFunctions}\nwe summarize the most important conclusions of what \na careful development of the \narctrigonometric functions would yield, including their domains,\ntheir ranges, and their derivatives.\nWe save the actual derivations for later subsections, since\nat this stage we are most interested in derivatives involving\nthese functions.  However, the detailed derivations are ultimately \nquite important and\nshould be studied for a couple of reasons.\nFirst, the technicalities involved there will\nreappear many times in later chapters.  \nSecond, the derivations\nare also quite interesting---and useful as exercises---because, \nas occurs in many applied problems, the techniques used form an \ninteresting mix of algebra, trigonometry, and\nour calculus techniques, particularly implicit \ndifferentiation.\\footnote{%\n%%% FOOTNOTE\nIndeed, the farther along one gets in mathematical or applied studies,\nthe more one has to borrow from a growing diversity\nof subjects.\nIt is very often the ``technicalities''---themselves often first\nfound in derivations,\nfootnotes or otherwise parenthetically---which play key roles\nin solving interesting problems, in both pure and applied mathematics.\n%%% END FOOTNOTE\n}\n\n\n\n\nHowever in this subsection\nwe concentrate on their derivatives, though\nwe keep \nan eye towards their actual definitions, including their domains and\nranges.  Armed with the derivative formulas, we will be able to \ngreatly expand the class of functions we can differentiate.\n\nNow the trigonometric functions repeat periodically, \nso there is no guarantee for \ninstance that $\\sin x_1=\\sin x_2$ implies $x_1=x_2$.\nThe way we nonetheless endeavor to ``invert'' the trigonometric\nfunctions is to temporarily restrict their domains so that they are\nforced to be one-to-one. \nFor instance,  $\\sin x$ is one-to-one\non $x\\in[-{\\pi}/2,{\\pi}/2]$, i.e.,\n$$\\left(\\forall x_1,x_2\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]\\right)\n\\left[\\left(\\sin x_1=\\sin x_2\\right)\\longleftrightarrow\n\\left(x_1=x_2\\right)\\right].$$\nThis is kind of domain restriction is explained in subsequent subsections, \nwhere for each of the six standard trigonometric functions\nwe look for a subset of its domain on which\n(1) the function is one-to-one, and (2) the set of all outputs \ncovers the whole range of the original function.\\footnote{%\n%%% FOOTNOTE\nIt is \nakin to the problem trying to invert the function\n$f(x)=x^2$, which  is not one-to-one, since\nfor instance $f(-5)=f(5)$, while $-5\\ne 5$. Since it is impossible to \ntruly invert $f(x)=x^2$, instead we define the ``principal square\nroot'' $g(y)=\\sqrt{y}$,\nwhich does give us an inverse to $f(x)$ on the set $x\\ge0$:\n$$\\left(\\forall x_1,x_2\\in[0,\\infty)\\right)\\left[\n   \\left(x_1=x_2\\right)\\longleftrightarrow\\left(x_1^2=x_2^2\\right)\\right].$$\nWhile the above is not true if we replace $[0,\\infty)$ with the whole\ndomain $\\Re$ of $f$, it is still useful to define such a $g$.\nFor instance, knowing $f(x)=K$ gives us $x=\\pm\\sqrt{K}=\\pm g(K)$,\nso the value of $g(K)$ is still useful in finding a particular\n$x$, regardless of whether we ultimately need $x=\\sqrt{K}$ or $x=-\\sqrt{K}$.\n%%% END FOOTNOTE\n} %\nThere are some\nother issues which turn out to be easier to accommodate,\nsuch as consistency and compatibility with the other\nsix trigonometric functions, and which will be explained as we develop\nthe theory.\n\n\n\n\n\n\nOf course the simplest uses for \nthe arctrigonometric functions\narise from solving trigonometric equations.\nFor instance, it often happens in applications that we need to solve an\nequation such as $\\tan\\theta=x$ for the variable $\\theta$.\n%\\begin{figure}\n%\\begin{center}\n%\\begin{pspicture}(0,-.50)(10,2.5)\n%\\psline(0,0)(3,0)(3,2)(0,0)\n%\\psline{->}(3,0)(3,2)\n%\\rput(1.5,-.3){1}\n%\\rput(3.3,1){$x$}\n%\\psarc{->}(0,0){.7}{0}{33.69}\n%\\rput(1,.3){$\\theta$}\n%\\rput(7,1){$\\ds{\\left.\n%               \\begin{array}{c}\\tan\\theta=x\\\\ \n%                                \\theta\\in\\left(\\frac{-\\pi}2,\\frac{\\pi}2\n%                           \\right)\\end{array}\\right\\}\n%                \\iff\\theta=\\tan^{-1}x.}$}\n%\\end{pspicture}\n%\\end{center}\n%\\caption{For a given $x\\in\\Re$, there are infinitely many angles $\\theta$\n%         for which $\\tan\\theta=x$.  However, if we restrict our interest\n%         to $\\theta\\in\\left(\\frac{-\\pi}2,\\frac{\\pi}2\\right)$, then\n%         we get a unique $\\theta$, which we dub $\\tan^{-1}x$.}\n%\\label{ApplicationExampleForArcTangentDiscussion}\\end{figure}\nFor this and other reasons, arctrigonometric functions become of interest.\nThese are functions which take a {\\it number,} such as $x$, and return \nan {\\it angle} such as $\\theta$ (also represented by a number, but\nthe distinction is important)\nfor which $x$ is some given trigonometric function of that\nangle.  So if we are interested in knowing an angle\n$\\theta$ such that $\\tan\\theta=x$,  there\nis an arctrigonometric function $\\arctan x$ which will give us\nsuch an angle $\\theta$ so that indeed $\\tan\\theta=x$.  Such arctrigonometric\nfunctions as arcsine, arccosine and arctangent\nare built into scientific calculators, for instance,\nalong with the original trigonometric functions sine, cosine and tangent.\nThese functions allow us to move from \nangle to trigonometric function of the angle, and back, almost.\n\nThe trouble is that\nthere is important ambiguity about the angle $\\theta$ in such \na problem,\nnamely that if some angle $\\theta$ solves $\\tan\\theta=x$,\nso do all angles of the form $\\theta+n\\pi$, where $n\\in\\mathbb{Z}$\n(i.e., $\\theta\\pm\\pi,\\theta\\pm2\\pi, \\cdots$).\nPresently calculators only output a single angle for \nsuch a problem.  Still, knowing one solution is quite useful, as it \nindirectly gives us such information as the reference angle\nof the other solutions.  \nFor instance, if we use a calculator for a solution to \n$\\tan\\theta=5$, one solution will be given by the calculator\nto be $\\theta=\\tan^{-1}5\\approx1.373400767$\n(or approximately $78.69006253^\\circ$).  If we need an angle in the third\nquadrant (not practical in most right-triangle trigonometry,\nbut useful in many applications nonetheless)\nwe can instead use, for one example,\n$\\tan^{-1}5+\\pi\\approx4.514993421$ (or \n$\\tan^{-1}5+180^\\circ\\approx258.6900675^\\circ$ if\nwe want to work in degrees).  The notations $\\arctan x$ and\n$\\tan^{-1}x$ are used interchangeably.\\footnote{%%\n%%% FOOTNOTE\nAgain note that the $-1$ ``exponent'' in $\\tan^{-1}x$ is not\nactually an exponent in the sense of ``power,'' but is rather\na notation borrowed from the study of {\\it inverse functions}.\nIndeed, we have a name for $(\\tan x)^{-1}$, specifically $\\cot x$.\n%%% END FOOTNOTE\n}\n\nLeaving the derivation for later, for now we list the derivatives\nin basic and chain rule forms.\n\\begin{alignat}{3}\n\\frac{d\\,\\sin^{-1}x}{dx}&=\\frac1{\\sqrt{1-x^2}},&\\qquad\\qquad\\qquad\n\\frac{d\\,\\sin^{-1}u}{dx}&=\\frac1{\\sqrt{1-u^2}}\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\,\\cos^{-1}x}{dx}&=\\frac{-1}{\\sqrt{1-x^2}},&\\qquad\\qquad\\qquad\n\\frac{d\\,\\cos^{-1}u}{dx}&=\\frac{-1}{\\sqrt{1-u^2}}\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\,\\tan^{-1}x}{dx}&=\\frac1{x^2+1},&\n\\frac{d\\,\\tan^{-1}u}{dx}&=\\frac1{u^2+1}\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\,\\cot^{-1}x}{dx}&=\\frac{-1}{x^2+1},&\n\\frac{d\\,\\cot^{-1}u}{dx}&=\\frac{-1}{u^2+1}\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\,\\sec^{-1}x}{dx}&=\\frac1{|x|\\sqrt{x^2-1}},&\n\\frac{d\\,\\sec^{-1}u}{dx}&=\\frac1{|u|\\sqrt{u^2-1}}\\cdot\\frac{du}{dx},\\\\\n\\frac{d\\,\\csc^{-1}x}{dx}&=\\frac{-1}{|x|\\sqrt{x^2-1}},&\n\\frac{d\\,\\csc^{-1}u}{dx}&=\\frac{-1}{|u|\\sqrt{u^2-1}}\\cdot\\frac{du}{dx}.\n\\end{alignat}\nRemarkably all these  derivatives\nare all ``algebraic'' in nature,\\footnote{%%%\n%%% FOOTNOTE\n``Algebraic'' is in contrast to ``transcendental,'' the latter\nreferring to trigonometric, arctrigonometric, logarithmic\nand exponential functions, for instance.\n%%% END FOOTNOTE\n}\nmeaning that they involve only multiplication, division,\npolynomials and radicals.  These emerging derivative forms,\ndeveloped next and \nsummarized in Table~\\ref{TableOfArctrigonometricFunctions},\nwill prove crucial in the later development of antiderivatives.\n%HHH\n\n\n\\begin{table}\n\\begin{center}\n\\scalebox{.9}{\n\\begin{tabular}{ccccc}\nFunction & Inputs (Domain) & Outputs (Range)& Outputs Graphed& Derivative\\\\\n\\hline\n\\\\\n$\\sin^{-1}x$ & $x\\in[-1,1]$ & $\\theta\\in\n                            \\left[-\\frac{\\pi}{2},\\frac{\\pi}2\\right]$\n                            &\\begin{pspicture}(-1,0)(1,1)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\psarc[linecolor=gray]{*-*}(0,0){.5}{-90}{90}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\sin^{-1}x}{dx}\n                                 =\\frac1{\\sqrt{1-x^2}}}$\\\\\n$\\cos^{-1}x$ & $x\\in[-1,1]$ & $\\theta\\in[0,\\pi]$\n                            &\\begin{pspicture}(-1,0)(1,2)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\psarc[linecolor=gray]{*-*}(0,0){.5}{0}{180}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\cos^{-1}x}{dx}\n                                 =\\frac{-1}{\\sqrt{1-x^2}}}$\\\\\n$\\tan^{-1}x$ & $x\\in\\Re$ & $\\theta\\in\\left(-\\frac{\\pi}2,\\frac{\\pi}2\\right)$\n                            &\\begin{pspicture}(-1,0)(1,2)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\psarc[linecolor=gray]{o-o}(0,0){.5}{-90}{90}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\tan^{-1}x}{dx}\n                                 =\\frac{1}{x^2+1}}$\\\\\n$\\cot^{-1}x$ & $x\\in\\Re-\\{0\\}$ & $\\theta\\in\n              \\left(-\\frac{\\pi}{2},\\frac{\\pi}2\\right)-\\{0\\}$\n                            &\\begin{pspicture}(-1,0)(1,2)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\psarc[linecolor=gray]{o-o}(0,0){.5}{-90}{0}\n                             \\psarc[linecolor=gray]{o-o}(0,0){.5}{0}{90}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             %\\psarc[linecolor=gray]{o-o}(0,0){.5}{0}{0}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\cot^{-1}x}{dx}\n                                 =\\frac{-1}{x^2+1}}$\\\\\n$\\sec^{-1}x$ & $x\\in(-\\infty,-1]\\cup[1,\\infty)$ \n            & $\\theta\\in[0,\\pi]-\\left\\{\\frac{\\pi}2\\right\\}$\n                            &\\begin{pspicture}(-1,0)(1,2)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\psarc[linecolor=gray]{*-o}(0,0){.5}{0}{90}\n                             \\psarc[linecolor=gray]{o-*}(0,0){.5}{90}{180}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\sec^{-1}x}{dx}\n                                 =\\frac{1}{|x|\\sqrt{x^2-1}}}$\\\\\n$\\csc^{-1}x$ & $x\\in(-\\infty,-1]\\cup[1,\\infty)$\n              & $\\theta\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]-\\{0\\}$\n                            &\\begin{pspicture}(-1,0)(1,2)\n                             \\psaxes{<->}(0,0)(-1,-1)(1,1)\n                              \\psarc[linecolor=gray]{*-o}(0,0){.5}{-90}{0}\n                             \\psarc[linecolor=gray]{o-*}(0,0){.5}{0}{90}\n                             \\psline{->}(0,0)(1,1)\n                             \\psarc[linewidth=1pt]{->}(0,0){.5}{0}{45}\n                             \\rput(.7,.2){$\\theta$}\n                             %\\psarc[linecolor=gray]{o-o}(0,0){.5}{0}{0}\n                             \\end{pspicture}\n                            &$\\ds{\\frac{d\\,\\csc^{-1}x}{dx}\n                                 =\\frac{-1}{|x|\\sqrt{x^2-1}}}$\\\\\n&&&\\begin{pspicture}(-1,0)(1,2)\n                             %\\psaxes{<->}(0,0)(-1,-1)(1,1)\n                             \\end{pspicture}\n&\\\\\n\\end{tabular}}\\end{center}\n\\caption{Summary of arctrigonometric functions, their domains and\nranges (given in both interval notation and\ngraphed as angles through the unit circle), \nand their derivatives.  Note that all angles \ndisplayed in the ``Outputs Graphed''\ncolumn are assumed to be between $\\frac{-\\pi}2$ and $\\pi$.}\n\\label{TableOfArctrigonometricFunctions}\n\\end{table}\n\nSome examples of derivative computations using these follow:\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}\\left[\\sin^{-1}x^2\\right]\n =\\frac{1}{\\sqrt{1-\\left(x^2\\right)^2}}\\cdot\\frac{d\\,x^2}{dx}\n =\\frac1{\\sqrt{1-x^4}}\\cdot2x=\\frac{2x}{\\sqrt{1-x^4}}}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\tan^{-1}(\\tan x)\\right]\n =\\frac1{(\\tan x)^2+1}\\cdot\\frac{d}{dx}\\tan x\n =\\frac{1}{\\tan^2x+1}\\cdot\\sec^2x\n =\\frac{1}{\\sec^2x}\\sec^2x=1.}$\n\nA careful look at the original function, particularly in \nlight of our later development,  would reveal that \n$\\tan^{-1}(\\tan x)=x+n\\pi$, so naturally the derivative should be 1.\nThis sort of thing occurs on occasion when dealing with these.  Indeed\nsometimes it is the calculus considerations which first lead us\nto such simplifications of the functions.\n\\item $\\ds{\\frac{d}{dx}\\left[x\\sec^{-1}x\\right]\n  =x\\cdot\\frac{d}{dx}\\left[\\sec^{-1}x\\right]+\\sec^{-1}x\\cdot\\frac{d\\,x}{dx}\n  =x\\cdot\\frac{1}{|x|\\sqrt{x^2-1}}+\\sec^{-1}x.}$\n\nIf we happen to know $x>0$, this simplifies to\n$\\ds{\\frac{x}{x\\sqrt{x^2-1}}+\\sec^{-1}x=\\frac1{\\sqrt{x^2-1}}+\\sec^{-1}x}$. \n\nIf $x<0$ we instead get\n$\\ds{\\frac{x}{-x\\sqrt{x^2-1}}+\\sec^{-1}x=\\frac{-1}{\\sqrt{x^2-1}}+\\sec^{-1}x}$.\n\n\\end{itemize}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\subsection{The Arcsine Function and Its Derivative}\n\nWe begin our development with the inverse trigonometric functions which\ncan be found on scientific calculators: arcsine, arccosine and arctangent\n(a.k.a. $\\sin^{-1}$, $\\cos^{-1}$\nand $\\tan^{-1}$ respectively).  Though these are the most intuitive in \ntheir derivations, in fact calculus applications find \nthe most use for the arcsine, arctangent and arcsecant,\nso the derivation of the arcsecant will also be presented in\nfull.  For completeness\nwe will include results for  arccosecant and arccotangent.\n\n%Each of these trigonometric inverse functions are best \n%considered in light of the unit circle development of \n%the trigonometric functions.  For this reason we recall\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.5,-2.7)(7,2.7)\n\\psaxes[labels=none,Dx=10,Dy=10]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{90}{270}\n\\psarc(0,0){2}{-90}{90}\n\\psline(0,0)(1.285575,1.532)\n\\pscircle[fillstyle=solid,fillcolor=black](1.285575,1.532){.07}\n\\psarc{->}(0,0){.4}{0}{50}\n\\rput(.6,.3){$\\theta$}\n\\rput[l](1.5,1.6){$(\\cos\\theta,\\sin\\theta)$}\n  \\rput(0,2.7){$\\pi/2$}\n  \\rput(0,-2.7){$-\\pi/2$}\n  \\rput(2.7,0){0}\n\\psline[linestyle=dashed](0,2)(6,2)\n\\psline[linestyle=dashed](0,-2)(6,-2)\n\\rput(6,0){$\\ds{\\begin{array}{c}\\ds{-\\frac{\\pi}2\\le\\theta\\le\\frac{\\pi}2}\\\\ \n                   \\ds{\\vphantom{\\frac11}-1\\le\\sin\\theta\\le1}\\end{array}}$}\n\\psline{->}(6,.75)(6,2)\n\\psline{->}(6,-.75)(6,-2)\n\n\n\\end{pspicture}\n\\end{center}\n\\caption{Diagram showing that part of the unit circle used to \nconstruct the arcsine function. \nFor all $x\\in[-1,1]$, there exists a unique $\\theta\\in[-\\pi/2,\\pi/2]$\nso that $\\sin\\theta=x$. }\n\\label{AnglesOutputByArcsineFigure}\n\\end{figure}\n\nWe begin with the arcsine function. We are thus interested in \nfinding a function which we will call $\\sin^{-1}x$,\nor $\\arcsin x$, so that $\\sin^{-1}x$ returns an angle $\\theta$\nso that $\\sin\\theta=x$.  Now the range (of outputs) of $\\sin\\theta$\nis $[-1,1]$, so our function $\\sin^{-1}x$ should \nbe able to input any such $x\\in[-1,1]$ and return an angle $\\theta$\nwhose sine is $x$.  As shown in Figure~\\ref{AnglesOutputByArcsineFigure},\nall such outputs $\\sin\\theta\\in[-1,1]$ are achieved if we\nrestrict the input of the sine function to $\\theta\\in\\left[-\\frac{\\pi}2,\n\\frac{\\pi}2\\right]$.  Moreover, for each $x\\in[-1,1]$ there exists\na unique $\\theta\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]$ such\nthat $\\sin\\theta=x$.  Thus we make the following definition:\n\\begin{definition}\nFor every $x\\in[-1,1]$, define\n\\begin{equation}\n\\sin^{-1}x=\\text{ ``that }\\theta\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]\n            \\text{ such that }\\sin\\theta=x.\\text{''}\n\\label{EquationDefiningArcSine}\n\\end{equation}\n\\label{DefinitionOfArcSine}\n\\end{definition}\nNote that $\\sin(\\sin^{-1}x)=x$, because in that computation we are\ntaking the sine of an angle---albeit inside of \n$\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]$---whose sine is $x$, and\nso its sine is, naturally, $x$.\\footnote{%%%\n%%% FOOTNOTE\nHowever $\\sin^{-1}(\\sin x)$\nis $x$ if and only if $x\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]$,\nthough $\\sin^{-1}(\\sin x)$ will at least share the same reference\nangle as $x$.\n%%% END FOOTNOTE\n}\nUsing this fact, we can note that\n$y=\\sin^{-1}x\\implies \\sin y=\\sin(\\sin^{-1}x)\\iff \\sin y=x,$\ni.e.,\n\\begin{equation}y=\\sin^{-1}x\\implies \\sin y=x.\n\\label{Y=ArcSineX=>X=SineY}\\end{equation}\nThe graph of  $y=\\sin^{-1}x$ is thus a subset of the graph\nof $\\sin y=x$.  This is shown in \nFigure~\\ref{FigureForX=SineY,Y=ArcsineX}. \n\n\\begin{figure}\n\\begin{center}\n\n\\begin{pspicture}(-2,-4)(2,4)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=20]{<->}(0,0)(-2,-8)(2,8)\n\\parametricplot[linecolor=gray,%\nplotpoints=2000]{-8}{8}{t 180 mul 3.14159265 div sin t}\n\\parametricplot[plotpoints=100,linewidth=2pt]%\n{-1.5708}{1.5708}{t 180 mul 3.14159265 div sin t}\n\\psline(-.2,-3.1415)(.2,-3.1415)\n\\psline(-.2,3.1415)(.2,3.1415)\n\\rput[l](.3,-3.1415){$-\\pi$}\n\\rput[l](.3,3.1415){$\\pi$}\n\n\\psline(-.2,-6.28)(.2,-6.28)\n\\psline(-.2,6.28)(.2,6.28)\n\\rput[l](.3,-6.28){$-2\\pi$}\n\\rput[l](.3,6.28){$2\\pi$}\n\\pscircle[fillcolor=black,fillstyle=solid](1,1.5708){.07}\n\\pscircle[fillcolor=black,fillstyle=solid](-1,-1.5708){.07}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $x=\\sin y$ in gray, with the\ngraph of $y=\\sin^{-1}x$, i.e., that of $\\left\\{(x,y)\\ |\\ x=\\sin y, y\\in\n        \\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]\\right\\}$\nin black.}\n\\label{FigureForX=SineY,Y=ArcsineX}\\end{figure}\n\nUsing (\\ref{Y=ArcSineX=>X=SineY}), we can now derive the\nderivative of the arcsine function.  Eventually we will need\nto refer to a variation of Figure~\\ref{AnglesOutputByArcsineFigure},\nbut the initial computations are chain rules in nature:\n\\begin{alignat*}{2}\n&&y&=\\sin^{-1}x\\\\\n&\\implies&\\qquad \\sin y&=\\sin(\\sin^{-1}x)\\\\\n&\\implies&       \\sin y&=x\\\\\n&\\implies& \\frac{d}{dx}(\\sin y)&=\\frac{d}{dx}(x)\\\\\n&\\implies&\\cos y\\cdot\\frac{dy}{dx}&=1\\\\\n&\\implies&\\frac{dy}{dx}&=\\frac1{\\cos y}.\n\\end{alignat*}\nAt this point we need to rewrite this derivative in terms of $x$\nusing $y=\\sin^{-1}x$:\n\\begin{equation}\ny=\\sin^{-1}x\\implies \\frac{dy}{dx}=\\frac1{\\cos (\\sin^{-1}x)}.\n\\label{IntermediateStepToArcsineDerivative}\n\\end{equation}\nNow recall that $\\sin^{-1}x\\in\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]$,\nand in fact $\\sin^{-1}x$ is that angle $\\theta\\in\n\\left[-\\frac{\\pi}2,\\frac{\\pi}2\\right]$ so that $\\sin\\theta=x$.\nThere are two basic cases for this $\\theta$: that $\\theta$ is in\nQuadrant I or Quadrant IV. (If $\\theta$ is axial then the analysis\nof either case will still work.)\nThese cases are given in Figure~\\ref{TrianglesForCosineArcsineX}.\n\n\nIt is important to construct angles $\\theta$ with the\nproper representative triangles: the sine of $\\theta$\nmust is labeled $x$,  here representing the vertical\ndisplacement, either positive or negative. \nThe hypotenuse is positive (since it is always a distance,\nnot a displacement), and the quadrants are correct.\nThe third side is constructed to be consistent with\nboth the Pythagorean Theorem\nand the quadrant, the latter required to get the correct sign\nfor the displacement represented by that side.\nIn both cases, $x>0$ and $x<0$, we see that the third side \nof the representative triangle is $\\sqrt{1-x^2}$\nsince it is a positive---that is, rightward---displacement\nin the horizontal direction.  From this we can\nread off $\\cos(\\sin^{-1}x)=\\cos\\theta=\\sqrt{1-x^2}$.\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{90}{270}\n\\psarc(0,0){2}{-90}{90}\n\\psline{->}(0,0)(2,2.383507)\n\\psarc{->}(0,0){.4}{0}{50}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1.285575,0)\n\\psline[linewidth=2pt]{->}(1.285575,0)(1.285575,1.532)\n\\rput(.61,1.1){1}\n\n\\rput[l](1.45,.75){$x$}\n\\rput(.65,-.3){$\\sqrt{1-x^2}$}\n\\rput(0,-3){Case $x\\ge0$}\n\n\\end{pspicture}\n\\qquad\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{90}{270}\n\\psarc(0,0){2}{-90}{90}\n\\psline{->}(0,0)(2,-2.383507)\n\\psarc{<-}(0,0){.4}{-50}{0}\n\\rput(.6,-.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1.285575,0)\n\\psline[linewidth=2pt]{->}(1.285575,0)(1.285575,-1.532)\n\\rput[l](1.45,-.75){$x$}\n\\rput(.61,-1.1){1}\n\\rput(.65,.3){$\\sqrt{1-x^2}$}\n\\rput(0,-3){Case $x\\le0$}\n\\end{pspicture}\n\\end{center}\n\\caption{Illustration of the two cases for representative triangles\nfor angles $\\theta=\\sin^{-1}x$.  With two sides of such a triangle}\n\\label{TrianglesForCosineArcsineX}\n\\end{figure}\n\nInserting this information into our derivative computation\n(\\ref{IntermediateStepToArcsineDerivative})\ngives us\n$y=\\sin^{-1}x\\implies\\frac{dy}{dx}=1/\\cos(\\sin^{-1}x)=1/\\sqrt{1-x^2}$.\nWe give this result in summary form, and then give the chain rule version:\n\\begin{align}\n\\frac{d}{dx}\\sin^{-1}x&=\\frac1{\\sqrt{1-x^2}},\\label{DerivOfArcSine}\\\\\n\\frac{d}{dx}\\sin^{-1}u&=\\frac1{\\sqrt{1-u^2}}\\cdot\\frac{du}{dx}.\n   \\label{ChainRuleVersionArcsineDerivative}\n\\end{align}\nAs usual, the latter can be decomposed into\n$$\\frac{d}{dx}\\sin^{-1}u=\\frac{d}{du}\\sin^{-1}u\\cdot\\frac{du}{dx}\n                        =\\frac1{\\sqrt{1-u^2}}\\cdot\\frac{du}{dx}.$$\n\nNote that (\\ref{DerivOfArcSine}) only makes sense for\n$x\\in(-1,1)$, and that \n$\\frac{d}{dx}\\sin^{-1}x=\\frac1{\\sqrt{1-x^2}}\\longrightarrow\\infty$ \nas $x\\to1^-$\nand as $x\\to-1^+$.  This is borne out by the graph\nof $y=\\sin^{-1}x$ given in Figure~\\ref{FigureForX=SineY,Y=ArcsineX},\npage \\pageref{FigureForX=SineY,Y=ArcsineX}. That graph also \nreflects how $\\frac{d}{dx}\\sin^{-1}x=\\frac1{\\sqrt{1-x^2}}>0$\nfor all $x\\in(-1,1)$, that is, how $\\sin^{-1}x$ is increasing\nin that interval (and in fact, in the whole domain $x\\in[-1,1]$).\n\n\\subsection{The Arccosine and Its Derivative}\nThe development for the arccosine function mirrors that of the\narcsine, except that we will take the range of the arccosine \nfunction to contain\nangles in Quadrants I and II, specifically $\\theta\\in[0,\\pi]$.\nThat is because such angles \nform exactly the kind of set we need so that the cosine is\na one-to-one function with outputs covering the whole range\n$[-1,1]$.  \n\\begin{definition}\nFor every $x\\in[-1,1]$, define\n\\begin{equation}\\cos^{-1}x = \\text{ ``that }\\theta\\in[0,\\pi]\n          \\text{ such that }\\cos\\theta=x.\\text{''}\\label{EquationDefOfArcCosineX}\n\\end{equation}\\label{DefOfArcCosineX}\n\\end{definition}\n\n\n\n\n\\begin{figure}\n\\begin{center}\n\n\\begin{pspicture}(-2,-4.1)(2,4.1)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=20]{<->}(0,0)(-2,-8.2)(2,8.2)\n\\parametricplot[linecolor=gray,%\nplotpoints=2000]{-8}{8}{t 180 mul 3.14159265 div cos t}\n\\parametricplot[plotpoints=100,linewidth=2pt]%\n{0}{3.14159365}{t 180 mul 3.14159265 div cos t}\n\\psline(-.2,-3.1415)(.2,-3.1415)\n\\psline(-.2,3.1415)(.2,3.1415)\n\\rput[l](.3,-3.1415){$-\\pi$}\n\\rput[l](.3,3.1415){$\\pi$}\n\n\\psline(-.2,-6.28)(.2,-6.28)\n\\psline(-.2,6.28)(.2,6.28)\n\\rput[l](.3,-6.28){$-2\\pi$}\n\\rput[l](.3,6.28){$2\\pi$}\n\\pscircle[fillcolor=black,fillstyle=solid](1,0){.07}\n\\pscircle[fillcolor=black,fillstyle=solid](-1,3.1415927){.07}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $x=\\cos y$ in gray, with the\ngraph of $y=\\cos^{-1}x$, i.e., that of $\\left\\{(x,y)\\ |\\ x=\\cos y,\\ \\ y\\in\n        [0,\\pi]\\right\\}$\nin black.}\n\\label{FigureForX=CosineY,X=ArcsineY}\\end{figure}\n\nThe arccosine function is given (in bold) in \nFigure~\\ref{FigureForX=CosineY,X=ArcsineY}.\nThe computation of the derivative of $\\cos^{-1}x$ is \nsimilar to that for the arcsine, eventually referring\nto an illustration of two cases, namely \n$\\theta=\\cos^{-1}x$ terminating\nin Quadrant I and $\\theta=\\cos^{-1}x$ terminating in Quadrant II.\n\\begin{alignat*}{2}\n&&y&=\\cos^{-1}x\\\\\n&\\implies\\qquad&\\cos y&=x\\\\\n&\\implies&\\frac{d}{dx}(\\cos y)&=\\frac{d}{dx}(x)\\\\\n&\\implies&-\\sin y\\,\\frac{dy}{dx}&=1\\\\\n&\\implies&\\frac{dy}{dx}&=\\frac1{-\\sin y}=\\frac1{-\\sin(\\cos^{-1}x)}.\n\\end{alignat*}\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{180}{360}\n\\psarc(0,0){2}{0}{180}\n\\psline{->}(0,0)(1.4434,2.5)\n\\psarc{->}(0,0){.4}{0}{50}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1,1.7321)\n\\psline[linewidth=2pt]{->}(1,0)(1,1.7321)\n\\psline[linewidth=2pt]{->}(0,0)(1,0)\n\\rput(.4,1.1){1}\n\n\\rput[c]{270}(1.3,.75){$\\sqrt{1-x^2}$}\n\\rput(.5,-.3){$x$}\n\\rput(0,-3){Case $x\\ge0$}\n\n\\end{pspicture}\n\\qquad\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{180}{360}\n\\psarc(0,0){2}{0}{180}\n\\psline{->}(0,0)(-1.4434,2.5)\n\\psarc{->}(0,0){.4}{0}{120}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(-1,1.7321)\n\\psline[linewidth=2pt]{->}(-1,0)(-1,1.7321)\n\\psline[linewidth=2pt]{->}(0,0)(-1,0)\n\\rput(-.4,1.1){1}\n\n\\rput[c]{90}(-1.3,.65){$\\sqrt{1-x^2}$}\n\\rput(-.5,-.3){$x$}\n\\rput(0,-3){Case $x\\le0$}\n\n\\end{pspicture}\n\\end{center}\n\\caption{Illustration of the two cases for representative triangles\nfor angles $\\theta=\\cos^{-1}x\\in[0,\\pi]$.  In both cases, the \nvertical side represents a positive displacement of\n$\\sqrt{1-x^2}$.}\n\\label{TrianglesForSineArcCosineX}\n\\end{figure}\n\n>From Figure~\\ref{TrianglesForSineArcCosineX} we see that the \nsine of the angle $\\theta=\\cos^{-1}x$ is $\\sqrt{1-x^2}$ regardless of\nin which of the two quadrants $\\theta$ terminates.  Continuing\nour earlier computation, we have\n$$y=\\cos^{-1}x\\implies \\frac{dy}{dx}=\\frac{-1}{\\sin(\\cos^{-1}x)}\n=\\frac{-1}{\\sqrt{1-x^2}}.$$\nCollecting this with its chain rule version, we have\n\\begin{align}\n\\frac{d}{dx}\\cos^{-1}x&=\\frac{-1}{\\sqrt{1-x^2}},\\label{DerivOfArcCosine}\\\\\n\\frac{d}{dx}\\cos^{-1}u&=\\frac{-1}{\\sqrt{1-u^2}}\\cdot\\frac{du}{dx}.\n   \\label{ChainRuleVersionArcCosineDerivative}\n\\end{align}\n\nThe derivative of the arccosine function is negative\nfor $x\\in(-1,1)$, and so the function itself is \ndecreasing.  Also, the derivative approaches $-\\infty$\nas $x\\to1^-$ and as $x\\to-1^+$.\n\nAnother derivation for the arccosine function relies upon the\nfact that, with these definitions of $\\sin^{-1}x$ and \n$\\cos^{-1}x$, we have an identity\n\\begin{equation}\\sin^{-1}x+\\cos^{-1}x=\\frac{\\pi}2.\n\\label{Arcsine+Arccosine=Pi/2}\n\\end{equation}\nThis is verified easily when $0<x<1$ because it reflects that\nthe acute angles of a right triangle sum to $\\pi/2$.  \nSome checking (which we omit here) shows that \n(\\ref{Arcsine+Arccosine=Pi/2}) also holds for other cases in\nwhich $x\\in[-1,1]$.  With (\\ref{Arcsine+Arccosine=Pi/2})\nwe can take derivatives of both sides and easily\nget that $\\frac{d}{dx}\\cos^{-1}x\n=-\\frac{d}{dx}\\sin^{-1}x$, which reflects why the derivatives \nof $\\cos^{-1}x$ and $\\sin^{-1}x$ are the same except for the\nsign.\n\n\n\n\\subsection{The Arctangent Function and Its Derivative}\n\\begin{definition} For every $x\\in\\Re$, define\n\\begin{equation}y=\\tan^{-1}x=\\text{ ``that }\\theta\\in\\left(-\\frac{\\pi}2,\n           \\frac{\\pi}2\\right)\\text{ such that }\\tan\\theta=x.\\text{''}\n       \\label{EquationDefiningArctangent}\n\\end{equation}\n\\label{DefinitionOfArctangent}\n\\end{definition}\n\n\\noindent\nThus the range we will use for the arctangent function\nis $\\theta\\in\\left(-\\frac{\\pi}2,\\frac{\\pi}2\\right)$.\nThe graph of $y=\\tan^{-1}x$ is a subset of the graph of\n$x=\\tan y$, as illustrated in Figure~\\ref{FigureForX=TangentY,X=ArcTangentY}.\n\n\n\\begin{figure}\n\\begin{center}\n\n\\begin{pspicture}(-6,-4.1)(6,4.1)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=20]{<->}(0,0)(-6,-8.2)(6,8.2)\n%\\parametricplot[linecolor=gray,%\n%plotpoints=2000]{-8}{8}{t 180 mul 3.14159265 div cos t}\n%\\parametricplot[plotpoints=100,linewidth=2pt]%\n%{0}{3.14159365}{t 180 mul 3.14159265 div cos t}\n\\psline(-.2,-3.1415)(.2,-3.1415)\n\\psline(-.2,3.1415)(.2,3.1415)\n\\rput[l](.3,-3.1415){$-\\pi$}\n\\rput[l](.3,3.1415){$\\pi$}\n\n\\psline[linestyle=dashed](-6,7.85398)(6,7.85398)\n\n\\parametricplot[linecolor=gray,plotpoints=1000]%\n{4.87754}{7.6888}%\n{t 180 mul 3.14159265 div sin %\n t 180 mul 3.14159265 div cos div t}\n\n\n\\parametricplot[linecolor=gray,plotpoints=1000]%\n{1.7359}{4.5472}%\n{t 180 mul 3.14159265 div sin %\n t 180 mul 3.14159265 div cos div t}\n\n\\psline[linestyle=dashed](-6.,4.71239)(6,4.71239)\n\\psline[linestyle=dashed](-6,-1.570796)(6,-1.570796)\n\\parametricplot[plotpoints=1000,linewidth=2pt]{-1.4056}{1.4056}%\n{t 180 mul 3.14159265 div sin %\n t 180 mul 3.14159265 div cos div t}\n\\psline[linestyle=dashed](-6,1.570796)(6,1.570796)\n\\parametricplot[linecolor=gray,plotpoints=1000]%\n{-1.7359}{-4.54724}%\n{t 180 mul 3.14159265 div sin %\n t 180 mul 3.14159265 div cos div t}\n\\psline[linestyle=dashed](-6.,-4.71239)(6,-4.71239)\n\n\\parametricplot[linecolor=gray,plotpoints=1000]%\n{-4.87754}{-7.6888}%\n{t 180 mul 3.14159265 div sin %\n t 180 mul 3.14159265 div cos div t}\n\\psline[linestyle=dashed](-6,-7.85398)(6,-7.85398)\n\n\n\\psline(-.2,-6.28)(.2,-6.28)\n\\psline(-.2,6.28)(.2,6.28)\n\\rput[l](.3,-6.28){$-2\\pi$}\n\\rput[l](.3,6.28){$2\\pi$}\n%\\pscircle[fillcolor=black,fillstyle=solid](1,0){.07}\n%\\pscircle[fillcolor=black,fillstyle=solid](-1,3.1415927){.07}\n\n\n\n\n\n\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $x=\\tan y$ in gray, with that part of the\ngraph which represents\n$y=\\tan^{-1}x$, i.e., that of $\\left\\{(x,y)\\ |\\ x=\\tan y, y\\in\n        \\left(-\\frac{\\pi}2,\\frac{\\pi}2\\right)]\\right\\}$\nin black.}\n\\label{FigureForX=TangentY,X=ArcTangentY}\\end{figure}\n\nThis function $y=\\tan^{-1}x$ has some interesting features.  \nFor instance, the domain\nof $\\tan^{-1}x$ is all of $\\Re$.\nso it makes sense to consider its behavior\n``at infinity.'' From the graph we can see that\n\\begin{align}\nx\\longrightarrow\\infty&\\implies \\tan^{-1}x\\longrightarrow{\\frac{\\pi}2}^-,\\\\\nx\\longrightarrow-\\infty&\\implies \\tan^{-1}x\\longrightarrow\n\\left({\\frac{-\\pi}2}\\right)^+.\\end{align}\nThese become important in later sections, as we consider\nmore limits and discuss improper integrals.\n\nIn finding the derivative of the arctangent function, we\nproceed as in the earlier derivations, \nwith Figure~\\ref{TrianglesForArcTanX} giving the relevant \ntriangles.  Note how we construct the triangles, where\n$\\theta=\\tan^{-1}x$.  In doing so we must ensure that\nthe quadrants and signs of the (vertical and horizontal)\ndisplacements are consistent\nwith both the Pythagorean Theorem, and the quadrant of the \nterminal side of $\\theta=\\tan^{-1}x$.\nNow we proceed with the derivative computation:\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{90}{270}\n\\psarc(0,0){2}{-90}{90}\n\\psline{->}(0,0)(2,2.383507)\n\\psarc{->}(0,0){.4}{0}{50}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1.285575,0)\n\\psline[linewidth=2pt]{->}(1.285575,0)(1.285575,1.532)\n\\rput{50}(.55,1.){$\\sqrt{x^2+1}$}\n\n\\rput[l](1.45,.75){$x$}\n\\rput(.65,-.3){$1$}\n\\rput(0,-3){Case $x\\ge0$}\n\n\\pscircle[fillstyle=solid,fillcolor=white](0,2){.1}\n\\pscircle[fillstyle=solid,fillcolor=white](0,-2){.1}\n\n\n\\end{pspicture}\n\\qquad\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{90}{270}\n\\psarc(0,0){2}{-90}{90}\n\\psline{->}(0,0)(2,-2.383507)\n\\psarc{<-}(0,0){.4}{-50}{0}\n\\rput(.6,-.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1.285575,0)\n\\psline[linewidth=2pt]{->}(1.285575,0)(1.285575,-1.532)\n\\rput[l](1.45,-.75){$x$}\n\\rput{-50}(.57,-1.15){$\\sqrt{x^2+1}$}\n\\rput(.65,.3){$1$}\n\\rput(0,-3){Case $x\\le0$}\n\n\\pscircle[fillstyle=solid,fillcolor=white](0,2){.1}\n\\pscircle[fillstyle=solid,fillcolor=white](0,-2){.1}\n\\end{pspicture}\n\\end{center}\n\\caption{Illustration of the two cases for representative triangles\nfor angles $\\theta=\\tan^{-1}x$.  In constructing the triangles,\nnote that we want $\\tan\\theta=x$, the horizontal displacement to be\npositive (we picked $1$), and the hypotenuse to be positive (as is\n{\\it always} the case, since it is a {\\it distance}, unlike the\nother two sides which represent horizontal or vertical\n{\\it displacements}).  Note also that these triangles reside within\ncircles of radius $\\sqrt{x^2+1}$, which are therefore not generally\nunit circles.}\n\\label{TrianglesForArcTanX}\n\\end{figure}\n\n\\begin{alignat*}{2}\n&&y&=\\tan^{-1}x\\\\\n&\\implies\\qquad&\\tan y&=x\\\\\n&\\implies&\\frac{d}{dx}(\\tan y)&=\\frac{d}{dx}(x)\\\\\n&\\implies&\\sec^2y\\cdot\\frac{dy}{dx}&=1\\\\\n&\\implies&\\frac{dy}{dx}&=\\cos^2y\\\\\n&\\implies&\\frac{dy}{dx}&=(\\cos y)^2=\\left(\\frac1{\\sqrt{x^2+1}}\\right)^2\n =\\frac1{x^2+1}.\\end{alignat*}\nSummarizing this, and the chain rule version, we have\n\\begin{align}\n\\frac{d}{dx}\\tan^{-1}x&=\\frac1{x^2+1},\\label{DerivOfArcTanX}\\\\\n\\frac{d}{dx}\\tan^{-1}u&=\\frac1{u^2+1}\\cdot\\frac{du}{dx}.\n   \\label{ChainRuleDerivOfArcTanX}\n\\end{align}\nNote that $\\frac{d}{dx}\\tan^{-1}x=\\frac1{x^2+1}>0$ for all $x\\in\\Re$,\nand so the arctangent function is increasing everywhere\n(see Figure~\\ref{FigureForX=TangentY,X=ArcTangentY}).  Moreover,\nthe slope of the graph becomes gentler as $|x|$ grows:\n\\begin{alignat*}{4}&\\lim_{x\\to\\infty}&&\\left[\\frac{d}{dx}\\tan^{-1}x\\right]&&=\n         \\lim_{x\\to\\infty}\\frac1{x^2+1}&&=0,\\\\\n&\\lim_{x\\to-\\infty}&&\\left[\\frac{d}{dx}\\tan^{-1}x\\right]&&=\n         \\lim_{x\\to-\\infty}\\frac1{x^2+1}&&=0.\\end{alignat*}\nThis reflects \nthe behavior of the slope of $y=\\tan^{-1}x$ as the graph approaches\nits horizontal asymptotes.\n\n\\subsection{The Arcsecant Function and Its Derivative}\nWe define the arcsecant to be consistent with the arccosine.\nWe begin with the fact that\n$$\\sec\\theta=x\\iff\\cos \\theta=\\frac1x.$$\nSince the range of $\\cos\\theta$ is $|\\cos\\theta|\\le1$,\nit follows that the range of secant is\n$|\\sec\\theta|=\\left|\\frac1{\\cos\\theta}\\right|\\ge1$.\nWe will define the arcsecant so that its domain (input) is \nthe same as the output of $\\sec\\theta$, and that its range is the\nsame as $\\cos^{-1}\\frac1x$ (almost that of arccosine, except \nthat $\\frac1x\\ne0$):\n\\begin{definition}\nFor $x\\in(-\\infty,-1]\\cup[1,\\infty)$, define\n\\begin{equation}\\sec^{-1}x=\\text{ ``that }\\theta\\in\n   \\left.\\left[0,\\frac{\\pi}2\\right.\\right)\\cup\n   \\left.\\left(\\frac{\\pi}2,\\pi\\right.\\right]\n   \\text{ such that }\\sec\\theta=x.\\text{''} \\label{EquationDefiningArcSecantX}\n\\end{equation}\n\\label{DefinitionOfArcSecantX}\n\\end{definition}\n\nThere are some complications which arise in the derivation\nof the arcsecant function's derivative.  That the derivation is\nnot as straightforward as the others' is\nnot surprising when we consider that the arcsecant\nfunction is not even continuous on its domain.  \nIndeed, when we pick enough\nof $x=\\sec y$ to cover all possible values for $x$ but\nnot so much that $y$ is no longer a function of $x$,\nwe are forced  to take two separate branches\nof the graph $x=\\sec y$.  In Figure~\\ref{X=SecantYGraph},\nthat part of the graph of $x=\\sec y$ which defines\n$y=\\sec^{-1}x$ is highlighted.\n\n\n\\begin{figure}\n\\begin{center}\n\n\\begin{pspicture}(-6,-4.1)(6,4.1)\n\\psset{yunit=.5cm}\n\\psaxes[Dy=20]{<->}(0,0)(-6,-8.2)(6,8.2)\n%\\parametricplot[linecolor=gray,%\n%plotpoints=2000]{-8}{8}{t 180 mul 3.14159265 div cos t}\n%\\parametricplot[plotpoints=100,linewidth=2pt]%\n%{0}{3.14159365}{t 180 mul 3.14159265 div cos t}\n\\psline(-.2,-3.1415)(.2,-3.1415)\n\\psline(-.2,3.1415)(.2,3.1415)\n\\rput[l](.3,-3.1415){$-\\pi$}\n\\rput[l](.3,3.1415){$\\pi$}\n\n\\psline[linestyle=dashed](-6,7.85398)(6,7.85398)\n\n\\parametricplot[linecolor=gray,plotpoints=1000]{4.879834}{7.6865336}%\n{1 t 180 mul 3.14159265 div cos div t}\n\n\n\\parametricplot[linecolor=gray,plotpoints=1000]{1.738292}{4.54489}%\n{1 t 180 mul 3.14159265 div cos div t}\n\n\n\n\\psline[linestyle=dashed](-6.,4.71239)(6,4.71239)\n\\parametricplot[linecolor=gray,plotpoints=1000]{-4.879834}{-7.6865336}%\n{1 t 180 mul 3.14159265 div cos div t}\n\\parametricplot[linecolor=gray,plotpoints=1000]{-1.738292}{-4.54489}%\n{1 t 180 mul 3.14159265 div cos div t}\n\n\\parametricplot[linecolor=gray,plotpoints=1000]{-1.4033}{1.4033}%\n{1 t 180 mul 3.14159265 div cos div t}\n\\psline[linestyle=dashed](-6,-1.570796)(6,-1.570796)\n\\parametricplot[plotpoints=1000,linewidth=2pt]{1.7382444}{3.14159265}%\n{1 t 180 mul 3.14159265 div cos div t}\n\\parametricplot[plotpoints=1000,linewidth=2pt]{0}{1.4033}%\n{1 t 180 mul 3.14159265 div cos div t}\n\\psline[linestyle=dashed,linewidth=2pt](-6,1.570796)(6,1.570796)\n\\psline[linestyle=dashed](-6.,-4.71239)(6,-4.71239)\n\\psline[linestyle=dashed](-6,-7.85398)(6,-7.85398)\n\n\n\\psline(-.2,-6.28)(.2,-6.28)\n\\psline(-.2,6.28)(.2,6.28)\n\\rput[l](.3,-6.28){$-2\\pi$}\n\\rput[l](.3,6.28){$2\\pi$}\n%\\pscircle[fillcolor=black,fillstyle=solid](1,0){.07}\n%\\pscircle[fillcolor=black,fillstyle=solid](-1,3.1415927){.07}\n\n\n\\pscircle[fillstyle=solid,fillcolor=black](1,0){.08}\n\\pscircle[fillstyle=solid,fillcolor=black](-1,3.14159265){.08}\n\\rput(3,2.2){$y=\\frac{\\pi}2$}\n\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $x=\\sec y$ in gray, with that part of the\ngraph which represents\n$y=\\sec^{-1}x$, i.e., that of $\\left\\{(x,y)\\ |\\ x=\\sec y,\\qquad y\\in\n        \\left.\\left[0,\\frac{\\pi}2\\right.\\right)\n        \\cup\\left.\\left(\\frac{\\pi}2,\\pi\\right.\\right]\\right\\}$\nin black.}\n\\label{X=SecantYGraph}\n\\end{figure}\n\n\n\nNow we derive $\\frac{d}{dx}\\sec^{-1}x$.  \n\\begin{alignat*}{2}\n&&\\qquad \\sec y&=x\\\\\n&\\implies&\\frac{d}{dx}(\\sec y)&=\\frac{d}{dx}(x)\\\\\n&\\implies&\\qquad\\sec y\\tan y\\frac{dy}{dx}&=1\\\\\n&\\implies&\\frac{dy}{dx}&=\\cos y\\cot y=\\cos\\left(\\sec^{-1}x\\right)\n                                       \\cot\\left(\\sec^{-1}x\\right).\n\\end{alignat*}\n\nReferring to Figure~\\ref{TrianglesForArcSecantX},\nwe see that the hypotenuse---which always must be positive---is \n$x$ when $x$ is positive, and $-x$ when $x$ is negative.\nIn both cases, we can summarize the hypotenuse as \nrepresented by the quantity $|x|$.  Thus we can continue the implications\nabove to get\n$$y=\\sec^{-1}x\\implies\\frac{dy}{dx}=\\cos(\\sec^{-1}x)\\cot(\\sec^{-1}x)\n                                   =\n\\left\\{\\begin{aligned}\\frac1{x}\\cdot\\frac{1}{\\sqrt{x^2-1}},&\\quad\n               \\text{ if }x\\ge1,\\\\\n            \\frac{-1}{-x}\\cdot\\frac{-1}{\\sqrt{x^2-1}},&\\quad\\text{ if }x\\le-1.\n            \\end{aligned}\\right.\n$$\nNow we summarize these, using the fact that $x=|x|$ in the expression\nfor $x\\ge1$, while $-x=|x|$ as well in the expression for $x\\le-1$.\nWe also include the chain rule version:\n\\begin{align}\n \\frac{d}{dx}\\sec^{-1}x&=\\frac1{|x|\\sqrt{x^2-1}},\\label{ArcSecDeriv}\\\\\n \\frac{d}{dx}\\sec^{-1}u&=\\frac1{|u|\\sqrt{u^2-1}}\\cdot\\frac{du}{dx}.\n     \\label{ChainRuleForArcSecant}\n\\end{align}\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{180}{360}\n\\psarc(0,0){2}{0}{180}\n\\psline{->}(0,0)(1.4434,2.5)\n\\psarc{->}(0,0){.4}{0}{60}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(1,1.7321)\n\\psline[linewidth=2pt]{->}(1,0)(1,1.7321)\n\\psline[linewidth=2pt]{->}(0,0)(1,0)\n\\rput{60}(.4,1.1){$x=|x|$}\n\\rput[c]{270}(1.3,.75){$\\sqrt{x^2-1}$}\n\\rput(.5,-.3){$1$}\n\\rput(0,-3){Case $x\\ge1>0$}\n\\pscircle[fillstyle=solid,fillcolor=white](0,2){.1}\n\\end{pspicture}\n\\qquad\n\\begin{pspicture}(-2.5,-3)(2.5,2.5)\n\\psaxes[Dx=2,Dy=2,labels=none]{<->}(0,0)(-2.5,-2.5)(2.5,2.5)\n\\psarc[linestyle=dashed](0,0){2}{180}{360}\n\\psarc(0,0){2}{0}{180}\n\\psline{->}(0,0)(-1.4434,2.5)\n\\psarc{->}(0,0){.4}{0}{120}\n\\rput(.6,.3){$\\theta$}\n\\psline[linewidth=2pt]{->}(0,0)(-1,1.7321)\n\\psline[linewidth=2pt]{->}(-1,0)(-1,1.7321)\n\\psline[linewidth=2pt]{->}(0,0)(-1,0)\n\\rput{-60}(-.4,1.2){$-x=|x|$}\n\n\\rput[c]{90}(-1.3,.65){$\\sqrt{x^2-1}$}\n\\rput(-.5,-.3){$-1$}\n\\rput(0,-3){Case $x\\le-1<0$}\n\n\\pscircle[fillstyle=solid,fillcolor=white](0,2){.1}\n\n\n\\end{pspicture}\n\\end{center}\n\\caption{Illustration of the two cases for representative triangles\nfor angles $\\theta=\\sec^{-1}x\\in[0,\\pi]-\\left\\{\\frac{\\pi}2\\right\\}$.  \nWe draw the triangles so that $\\sec\\theta=x$, i.e., $\\cos\\theta=\\frac1x$.\nIn doing so, however, we must be sure that the hypotenuse is always\npositive, and that the other two sides have appropriate signs.\nIn particular, we need the hypotenuse to be $x$ when $x\\ge1$\nand $-x$ when $x\\le-1$.  In both cases the hypotenuse can\nbe written $|x|$.  Also,\nin both cases the \nvertical side represents a positive displacement of\n$\\sqrt{x^2-1}$.}\n\\label{TrianglesForArcSecantX}\n\\end{figure}\n\nNotice that (\\ref{ArcSecDeriv}) implies that $y=\\sec^{-1}x$\nis increasing wherever it is differentiable.\nNotice also the limiting behavior as $x\\to\\infty$ and as $x\\to-\\infty$:\n\\begin{align}\nx\\to\\infty&\\implies \\sec^{-1}x\\to{\\frac{\\pi}{2}}^-,\\label{ASecAsXToInfty}\\\\\nx\\to-\\infty&\\implies\\sec^{-1}x\\to{\\frac{\\pi}{2}}^+.\\label{ASecAsXTo-Infty}\n\\end{align}\nWe can also see how the derivatives approach zero as $|x|\\to\\infty$,\nas happened with the arctangent function.\n\nA closely related derivative, which is left as an exercise, is\nthe following (with the chain rule form included):\n\\begin{align}\n\\frac{d}{dx}\\sec^{-1}|x|&=\\frac1{x\\sqrt{x^2-1}},\\label{DerivASec|X|}\\\\\n\\frac{d}{dx}\\sec^{-1}|u|&=\\frac1{u\\sqrt{u^2-1}}\\cdot\\frac{du}{dx}.\n\\label{DerivASec|U|}\n\\end{align}\nEquation (\\ref{DerivASec|X|})\ncan be proved using the chain rule and the fact that\n$|x|$ is the same as $x$ for $x>0$, and $-x$ for $x<0$.\nBoth cases, $x>0$ and $x<0$ (actually $x\\ge1$, $x\\le 1$ to be precise) \nshould be proved separately.  Equation (\\ref{DerivASec|U|}) then\nfollows from the chain rule.  These\nforms are preferred to (\\ref{ArcSecDeriv}) and\n(\\ref{ChainRuleForArcSecant}) when we \ncompute antiderivatives in later sections.\n\n\n\\subsection{Reciprocal Functions and Their Arctrigonometric Counterparts}\nThere is another interesting method for computing the \nderivative of $\\sec^{-1}x$, by referring to the\nderivative of the arccosine function.\nRecall that we defined the arcsecant's range to be consistent\nwith that of the arccosine, so that\n\\begin{equation}\\sec^{-1}x=\\cos^{-1}\\left(\\frac1x\\right).\\end{equation}\nWe can use this then to compute $\\frac{d}{dx}\\sec^{-1}x$:\n\\begin{alignat*}{2}\n\\frac{d}{dx}\\sec^{-1}x\n   &=\\frac{d}{dx}\\cos^{-1}\\left(\\frac1x\\right)\n   &&=\\frac{-1}{\\sqrt{1-\\left(\\frac1x\\right)^2}}\\cdot\\frac{d}{dx}\\left(\\frac1x\n               \\right)\\\\\n   &=\\frac{-1}{\\sqrt{1-\\frac1{x^2}}}\\cdot\\frac{-1}{x^2}\n   &&=\\frac{1}{x^2\\sqrt{\\frac1{x^2}\\left(x^2-1\\right)}}\\\\ \n   &=\\frac1{x^2\\cdot\\frac1{|x|}\\sqrt{x^2-1}}.\n\\end{alignat*}\nNow we claim that this is the same as our earlier expression for the\nderivative of $\\sec^{-1}x$.  The key is to notice that $x^2=|x|^2$\n(or just notice that $x^2\\cdot\\frac1{|x|}$ has to be positive), and\nso with our calculation above we get\n$$\\frac{d}{dx}\\sec^{-1}x=\\frac{d}{dx}\\cos^{-1}\\left(\\frac1x\\right)\n                =\\cdots=\\frac1{x^2\\cdot\\frac1{|x|}\\sqrt{x^2-1}}\n                   =\\frac1{\\frac{|x|^2}{|x|}\\sqrt{x^2-1}}\n                        =\\frac1{|x|\\sqrt{x^2-1}},$$\nas before. \nWhen we defined $\\sin^{-1}x$, $\\cos^{-1}x$ and $\\tan^{-1}x$,\nwe chose ranges of angles for these to output.  We can then\n{\\it define}\n\\begin{align}\n\\sec^{-1}x&=\\cos^{-1}\\left(\\frac1x\\right),\\label{Asec-WRT-Acos}\\\\\n\\csc^{-1}x&=\\sin^{-1}\\left(\\frac1x\\right),\\label{Acsc-WRT-Asin}\\\\\n\\cot^{-1}x&=\\tan^{-1}\\left(\\frac1x\\right),\\label{Acot-WRT-Atan}\\end{align}\n{\\it where the right-hand sides are defined. } \nIn fact these will give exactly the ranges we use for \narcsecant, arccosecant and arccotangent.\\footnotemark\n%%% FOOTNOTE\n\\footnotetext{The only caveat is that one could define $\\cot^{-1}0$\nto be either $\\frac{\\pi}2$ or $-\\frac{\\pi}2$, both outside\nthe range of the arctangent. Here we will decline to define $\\cot^{-1}0$.\nThe arccotangent function is rarely called upon in practice,\nand if it were then the choice of defining $\\cot^{-1}0=\\pm\\frac{\\pi}2$\nwould likely be dictated by the context.}\n%%% END FOOTNOTE\n\nIt is possible to make the definitions above because\nwe choose output ranges for the arctrigonometric functions\nto be compatible.  In particular, we like the arctrigonometric\nfunctions of reciprocal trigonometric functions\n(sine$\\leftrightarrow$cosecant, cosine$\\leftrightarrow$ secant,\nand tangent$\\leftrightarrow$cotangent) to have compatible\noutputs.\n\nFor example, $\\sec^{-1}(-2)$ is some angle $\\theta$ such that $\\sec\\theta=-2$.\nIt is convenient for that to be the same as the\nangle $\\theta=\\cos^{-1}(-\\frac12)$, which is\nthat $\\theta\\in[0,\\pi]$ so that $\\cos\\theta=\\frac{-1}2$,\nso we chose a similar range for the arcsecant,\nexcept that we have to avoid $\\frac{\\pi}2$, where the \nsecant is undefined.  Thus we chose\n$\\sec^{-1}(-2)$ to be that angle $\\theta\\in[0,\\pi]-\\{\\frac{\\pi}{2}\\}$\nsuch that $\\sec\\theta=-2$.  By choosing these similar ranges\nwe are guaranteed to output the same angles.\n\n\n\n\n\n\n\\subsection{Summary of Arctrigonometric Functions and Their Derivatives}\nTable~\\ref{TableOfArctrigonometricFunctions}\nsummarizes  the six arctrigonometric functions' domains,\nranges and derivatives. \nIt is useful to ``see'' the range\nof angles each arctrigonometric function outputs, as so these\noutputs are also graphed as angles in ``standard position,''\ni.e., measured against the positive horizontal axis.\n(It is best not to think of this axis as the ``$x$-axis,''\nsince here the variable $x$ is the input of the function.)\n\nA couple of important patterns can be seen in the table.\nFirst, the functions and cofunctions come in pairs, and\ntheir derivatives only differ by a sign.  Second,\nif we pair these arctrigonometric functions by\nthe related trigonometric functions which are reciprocal\nfunctions (so pairing $\\sin^{-1}x$ to $\\csc^{-1}x$,\n $\\cos^{-1}x$ to $\\sec^{-1}x$, and $\\tan^{-1}x$ to $\\cot^{-1}x$),\nwe see the angles outputted by the functions are almost\nexactly the same.  The only differences are that we have\nto omit angles outside the domain of the related trigonometric\nfunction.\n\nNote that the angles graphed are understood to be between\n$-\\frac{\\pi}2$ and $\\pi$.\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item Compute and simplify the following derivatives:\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\sin^{-1}x^2}$\n  \\item $\\ds{\\frac{d}{dx}\\cos^{-1}x^2}$\n  \\item $\\ds{\\frac{d}{dx}\\tan^{-1}x^2}$\n  \\item $\\ds{\\frac{d}{dx}\\cot^{-1}x^2}$\n  \\item $\\ds{\\frac{d}{dx}\\sec^{-1}x^2}$\n  \\item $\\ds{\\frac{d}{dx}\\csc^{-1}x^2}$\n  \\end{enumerate}\n\\item Compute the following derivatives:\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\sin^{-1}x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\cos^{-1}x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\tan^{-1}x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\cot^{-1}x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\sec^{-1}x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\csc^{-1}x}}$\n  \\end{enumerate}\n\\item Compute and simplify the following derivatives.  Note\n      that necessarily $x,\\sqrt{x}\\ge 0$ for each of these.\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\sin^{-1}\\sqrt{x}}$\n  \\item $\\ds{\\frac{d}{dx}\\cos^{-1}\\sqrt{x}}$\n  \\item $\\ds{\\frac{d}{dx}\\tan^{-1}\\sqrt{x}}$\n  \\item $\\ds{\\frac{d}{dx}\\cot^{-1}\\sqrt{x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sec^{-1}\\sqrt{x}}$\n  \\item $\\ds{\\frac{d}{dx}\\csc^{-1}\\sqrt{x}}$\n  \\end{enumerate}\n\\item Compute the following derivatives:\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\left[{x\\csc^{-1}x}\\right]}$  (assume $x>0$)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{\\tan^{-1}x}x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[(x^2+1)\\tan^{-1}x-x\\right]}$ (simplify answer)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sin^{-1}\\left(\\frac{x}3\\right)\\right]}$ \n            (simplify answer)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac13\\tan\\frac{x}3\\right]}$ (simplify answer)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sin^{-1}\\left(\\frac{x}{\\sqrt{x^2+1}}\n                 \\right)\\right]}$\n  \\end{enumerate}\n\\item Compute $\\frac{d}{dx}\\left[\\sin^{-1}x+\\cos^{-1}x\\right]$.\n Explain why we should have known the answer would be simple given\n the algebraic relationship between the arcsine and arccosine functions.\n\\item Compute $\\ds{\\frac{d}{dx}\\sec^{-1}\\left(\\frac1x\\right)}$ two ways:\n \\begin{enumerate}\n \\item Directly, using the chain rule, and\n \\item Rewriting the function as an arccosine function.\n \\item Show that the answers are in fact the same.  (You may need to \n       consider two cases, $x$ positive and $x$ negative.)\n \\end{enumerate}\n\n\\end{enumerate}\n\\end{multicols}\n\n\n\n\n\n\n\n\n\n\n\n\n\\qquad\\newpage\n\n\\section{Exponential Functions}\nIn this section we look at a function $f(x)=e^x$, where\n$e$ is a very important, irrational number,\\footnotemark\\  approximated by\n$e\\approx2.7182818$.\n\\footnotetext{%%%\n%%% FOOTNOTE\nIn fact, $e$ is arguably at least equal in importance to $\\pi$,\nthough its importance is not as easily accessible.\n%%%\n}\nWhat makes this function interesting, among other reasons, is\nthat $\\frac{d}{dx}(e^x)=e^x$. In fact, only functions which are constant\nmultiples of $e^x$ are their own derivatives.\nBefore arguing that such a function exists, we will look briefly\nat exponential functions $a^x$ in general, after which we will \nconcentrate on $e^x$.\n\n\nWhen we are finished with this section, we will then look at the\ninverse functions of the exponential functions.  These inverses\nare better known as {\\it logarithms}, and their derivatives fill\nan important gap in the theory.  Furthermore, these functions\nhave many useful algebraic properties which we can exploit before\nwe compute the derivatives.  In fact, in many  problems which do not\nexplicitly include logarithms, we can introduce them to exploit their\nproperties to make some derivative computations proceed much faster.\n\nMuch of what we do in this section relies upon the fact that\n$a^x$ is an everywhere continuous, differentiable function for any $a>0$.\nTo actually prove this requires integral calculus (the second\npart of this text), but this fact is believable through observations.\nFor our purposes here we will work from this assumption\n($a^x$ continuous and differentiable for $a>0$, $x\\in\\Re$),\nsee how it is reasonable,  \nand defer the proof.\\footnote{%\n%%% FOOTNOTE\nThe proof that $a^x$ is continuous and differentiable on all of $\\Re$\nis interesting and worthwhile, but it will be offered\nonly as a last subsection in a later chapter and section.\nIt is included there mostly for completeness, as it could be a distraction\nfrom the main thrust of the text.  The proof is  long, and follows a path\nwhich is essentially backwards from how we most easily learn these functions.\nIt relies upon an alternative definition of logarithms, proves all their\nproperties still hold with that definition, and then considers\nthe exponentials as inverses of the logarithms.  It makes for\nmore mathematically cohesive theory, but is \ncounterintuitive in its path of discovery.\n%%% END FOOTNOTE\n}\n\\subsection{Exponential Functions}\n\nOf course we will have use for the algebraic\nrules of exponential functions, which we quickly re-list here.\nAssuming $a,b>0$, $r,s\\in\\Re$,  $m\\in\\{1,2,3,\\cdots\\}$ we have\n\\begin{multicols}{2}\n\\begin{align*}\na^{r}a^s&=a^{r+s},\\\\\n\\frac{a^r}{a^s}&=a^{r-s},\\\\\na^0&=1,\\\\\n(ab)^r&=a^rb^r,\\\\\n\\left(\\frac{a}{b}\\right)^r&=\\frac{a^r}{b^r},\\end{align*}\\vfill\n\\begin{align*}\na^{-r}&=\\frac1{a^r},\\\\\n\\frac1{a^{-r}}&=a^r,\\\\\na^{1/m}&=\\sqrt[m]{a}\\\\\n\\left(a^r\\right)^s&=a^{r\\cdot s},\n\\\\\n\\end{align*}\\end{multicols}\n\nIn this subsection we look at functions $f(x)=a^x$.  \nIn order for this function to have domain $x\\in\\Re$, we\nrestrict ourselves to $a>0$.  (Think of what\n$(-2)^x$ would be for $x=\\frac12,\\frac14,\\frac32,\\pi$, etc.)\nWe will generally avoid the case $a=1$ as well, as the\nfunction $1^x$ is rather trivial.\n\nWe will look at two cases separately, namely $a>1$ and $a\\in(0,1)$.\nFor our prototypes, we will look at $a=2$ and $a=\\frac12$ specifically,\nand argue that the same trends hold for similar $a$'s in their\nrespective cases.\n\n\\begin{example}  Consider the function $f(x)=2^x$.  There are\ntwo trends---which are in fact reflections of each other---that we will\nobserve with this function:  what happens as $x\\to\\infty$\nand what happens as $x\\to-\\infty$.  We will do so by incrementing\nby 1 in each direction to observe the trends.\n\\begin{alignat*}{3}\n2^0&= 1\\qquad\\qquad&\\qquad\\qquad2^{-1} &=\\frac12&&=0.5\\\\\n2^1&= 2&2^{-2}&=\\frac14&&=0.25\\\\\n2^2&= 4&2^{-3}&=\\frac18&&=0.125\\\\\n2^3&= 8&2^{-4}&=\\frac1{16}&&=0.0625\\\\\n2^4&= 16&2^{-5}&=\\frac1{32}&&=0.03125\\\\\n2^5&= 32&2^{-6}&=\\frac1{64}&&=0.015625\\\\\n2^6&= 64&2^{-7}&=\\frac1{128}&&=0.0078125\\\\\n2^7&= 128&2^{-8}&=\\frac1{256}&&=0.00390625\\\\\n2^8&= 256&2^{-9}&=\\frac1{512}&&=0.001953125\\\\\n2^9&= 512&2^{-10}&=\\frac1{1024}&&=0.0009465625\\\\\n2^{10}&= 1024&&\\text{etc.}\n\\end{alignat*}\n\nThese trends continue as $x\\to\\infty$ and $x\\to-\\infty$.\nThey are also predictable since\n$$2^{x+1}=2^x2^1=2^x\\cdot2,\\qquad\\qquad 2^{x-1}=2^x2^{-1}=2^x\\cdot\\frac12.$$\nIn other words, for every increment of one to the right, the height of \nthe function is multiplied by a factor of 2; a movement of one to the \nleft lowers the function's height by half.\n\nTo Compute $2^r$ for rational numbers $r=\\frac{p}q$\nwhere $q\\in\\mathbb{N}$\nis to compute $2^{p/q}=\\sqrt[q]{2^p}$.  For an irrational number\n$s\\in\\mathbb{R}-\\mathbb{Q}$, we simply take any sequence\nof rational numbers $r_1,r_2,\\cdots$ so that $r_n\\longrightarrow s$\nand define $2^s=\\lim_{n\\to\\infty}2^{r_n}$.  In doing so we\ncan eventually define $2^x$ for any $x\\in\\Re$, thus achieving\nthe first graph in  Figure~\\ref{2^X,2^-XGraphs}, \npage~\\pageref{2^X,2^-XGraphs}. \n\\label{NeedPageForIrrationalPowersOfAExplained}\n\\end{example}\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-3,-1)(3,6)\n\\psset{xunit=.5cm,yunit=.5cm}\n\\psaxes[Dy=2]{<->}(0,0)(-6,-2)(6,10)\n\\psplot{-6}{3.321928095}{2 x exp}\n\n\n\\pscircle[fillstyle=solid,fillcolor=black](-3,.125){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](-2,.25){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](-1,.5){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](0,1){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](1,2){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](2,4){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](3,8){.07}\n\n\\rput(0,11.3){$\\ds{y=2^x}$}\n\\end{pspicture}\n\\qquad\\qquad\n\\begin{pspicture}(-3,-1)(3,6)\n\\psset{xunit=.5cm,yunit=.5cm}\n\\psaxes[Dy=2]{<->}(0,0)(-6,-2)(6,10)\n\\psplot{-3.321928095}{6}{.5 x exp}\n\n\n\\pscircle[fillstyle=solid,fillcolor=black](3,.125){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](2,.25){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](1,.5){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](0,1){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](-1,2){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](-2,4){.07}\n\\pscircle[fillstyle=solid,fillcolor=black](-3,8){.07}\n\n\\rput(0,11.3){$\\ds{y=\\left(\\frac12\\right)^x=2^{-x}}$}\n\n\\end{pspicture}\n\n\n\n\\end{center}\n\\caption{Partial graphs of $y=2^x$ and $y=\\left(\\frac12\\right)^x=2^{-x}$.\nIn both, a move to the right or left by one unit causes a \nchange in the height of the graph, by a factor of 2. Such functions\nwhose values \nchange by a (positive) constant factor with each increment are called\n{\\it exponential}.  Increasing exponential functions are said to \nrepresent {\\it exponential growth}, while decreasing \nexponential functions represent {\\it exponential decay}.}\n\\label{2^X,2^-XGraphs}\n\\end{figure}\n\nTo be sure, the argument above is not rigorous. With later techniques\nwe can eventually have a rigorous proof, but the\ngraph should be somewhat convincing, at least in its\nbehavior at the integers.  In fact, we can eventually\nprove that\n\\begin{itemize}\n\\item $f(x)=2^x$ is continuous for all $x\\in\\Re$,\n\\item $f(x)=2^x$ is one-to-one as a function $f:\\Re\\longrightarrow(0,\\infty)$.\n\\end{itemize}\nTaking these facts and the\ngraph for granted, we also notice the following limiting\nbehavior:\n\\begin{alignat}{2}x&\\longrightarrow\\infty&&\\implies 2^x\n                \\longrightarrow\\infty,\\label{2^XAsXToInfty}\\\\\n               x&\\longrightarrow-\\infty&&\\implies 2^x\n                \\longrightarrow 0^+.\\label{2^XAsXTo-Infty}\n\\end{alignat}\nWe now contrast this behavior with that of \nthe related function $g(x)=\\left(\\frac12\\right)^x$.\n\n\\bex Consider $g(x)=\\left(\\frac12\\right)^x$. Some points\non the graph of this function are indicated below:\n\\begin{alignat*}{2}\n2^0&= 1\\qquad\\qquad&\\qquad\\qquad2^{-1} \n         &=\\left(\\frac12\\right)^{-1}=2\\\\\n2^1&= \\frac12=0.5&2^{-2}\n         &=\\left(\\frac12\\right)^{-2}=4\\\\\n2^2&= \\frac14=0.25&2^{-3}\n         &=\\left(\\frac12\\right)^{-3}=8\\\\\n2^3&= \\frac18=0.125&2^{-4}\n         &=\\left(\\frac12\\right)^{-4}=16.\n\\end{alignat*}\nSuch a function shrinks in height by a factor of $1/2$ \nwith each increment of one unit to the right in $x$, and\nincreases by a factor 2 with each increment of one unit to the left.\nThus the behavior of $g(x)=\\left(\\frac12\\right)^x$ is thus just the\nopposite of that of $f(x)=2^x$.  This is not surprising, when\nwe realize one is just the reflection of the other in the sense that\n$g(x)=f(-x)$:\n$$g(x)=\\left(\\frac12\\right)^x=\\frac1{2^x}=2^{-x}=f(-x).$$\nThis function $g(x)$ is illustrated by the second graph in \nFigure~\\ref{2^XAsXTo-Infty}.\n\\eex\n\nAny function of the form\n$f(x)=a^x$ where $a>1$ represents a function which increases\nby the factor $a>1$ with every increment to the right.\nSuch behavior will ultimately imply $a^x\\longrightarrow\\infty$ as\n$x\\longrightarrow\\infty$, and $a^x\\longrightarrow0^+$ as \n$x\\longrightarrow-\\infty$.\nOn the other hand, we get the opposite if $a\\in(0,1)$, for\nwe can then write $a^x=\\left(\\frac1a\\right)^{-x}$,\nwhich is of the form $b^{-x}$ where $b=\\frac1a>1$.  This\nlimiting behavior is summarized below:\n\\begin{align*}\na>1&\\implies\\left\\{\\begin{array}{ccccccc}a^x&\\longrightarrow&\\infty\n                     &\\text{ as }&x&\\longrightarrow&\\hphantom{-}\\infty,\\\\\n                     a^x&\\longrightarrow&0^+\n                     &\\text{ as }&x&\\longrightarrow\n                          &-\\infty,\\end{array}\\right.\\\\\na\\in(0,1)&\\implies\\left\\{\\begin{array}{ccccccc}a^x&\\longrightarrow&0^+\n                     &\\text{ as }&x&\\longrightarrow&\\hphantom{-}\\infty,\\\\\n                     a^x&\\longrightarrow&\\infty\n                     &\\text{ as }&x&\\longrightarrow&-\\infty.\\end{array}\\right.\n\\end{align*}\nThe rate at which this limiting behavior occurs depends upon\n$a$.  For instance, $3^x$ increases faster than $2^x$ as $x$ increases,\nand therefore decreases faster as $x$ decreases.  Since\n$2^x$ and $3^x$ agree at $x=0$, and are positive everywhere, we thus have\n\\begin{align*}\n x>0&\\implies 3^x>2^x>0,\\\\ x<0&\\implies0\\hphantom{{}^x}< 3^x<2^x.\\end{align*}\nSimilarly $\\left(\\frac13\\right)^x$ shrinks faster than \n$\\left(\\frac12\\right)^x$ as $x$ increases, with the opposite\noccurring as $x$ decreases.  Next we see how dramatic this difference\nin growth, of $2^x$ versus $3^x$, in two ways:\n\n\\bex Show that $3^x$ grows faster than $2^x$ as $x\\longrightarrow\\infty$.\n\n\\underline{Solution}: Note first that $3^x$ and $2^x$ are both\nincreasing as $x$ increases, and have the same value at $x=0$.  That is,\n$y=3^x$ and $y=2^x$ both contain the point $(0,1)$.\nFurthermore,\n$$\\lim_{x\\to\\infty}\\left(3^x-2^x\\right)\n  =\\lim_{x\\to\\infty}\\left[2^x\\left(\\left(\\frac32\\right)^x-1\\right)\\right]\n         \\overset{\\infty\\cdot(\\infty-1)}{\\llongeq}\\infty.$$\nThus $3^x$ is an increasing distance above\n$2^x$, and in fact that distance increases without bound.\nAlternatively,\nwe can  show $3^x$ grows significantly faster\nthan $2^x$ by noting that \n$$\\lim_{x\\to\\infty}\\frac{3^x}{2^x}\\underset{\\text{ALG}}{\n \\overset{\\frac{\\infty}{\\infty}}{\\longeq}}\n      \\lim_{x\\to\\infty}{\\underbrace{\\left(3/2\\right)}_{>1}}^{\\ x}=\\infty,$$\nso $3^x$ is a nonconstant multiple of $2^x$, and that multiple\n(namely $\\left(\\frac32\\right)^x$) is blowing up as $x\\to\\infty$.\n\\eex\n\n\n\n\n\n\\subsection{Derivative of a Special Exponential Function}\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-4,-2)(4,6.5)\n\\psset{xunit=2cm,yunit=2cm}\n\\psaxes{<->}(0,0)(-2,-1)(2,3.25)\n\\psplot[plotpoints=1000,linewidth=.25pt]{-2}{1.584962501}{2 x exp}\n\\psplot[plotpoints=1000,linewidth=1pt]{-2}{1.098612289}{2.718271828 x exp}\n\\psplot[plotpoints=1000,linewidth=.5pt]{-2}{1}{3 x exp}\n\\rput(.9,3.1){$3^x$}\n\\rput(1.2,3.1){$e^x$}\n\\rput(1.7,3.1){$2^x$}\n\n\n\\end{pspicture}\n\n\n\\end{center}\n\\caption{Graphs of $2^x$, $e^x$ and $3^x$.  Only $y=e^x$\nhas slope $1$ at $x=0$, which implies ultimately that\n$\\frac{d}{dx}(e^x)=e^x$. See the discussion leading\nto (\\ref{DerivativeOfEXP}) and (\\ref{ChainRuleDerivativeOfEXP}).}\n\\label{ThreeExponentialsWithEXPBetween}\n\\end{figure}\n\n\nIf we look back at the (computer generated) graphs \nin Figure~\\ref{2^X,2^-XGraphs}, page~\\pageref{2^X,2^-XGraphs}\nit is not unreasonable to expect\nthat slope can be defined along these curves.\nIndeed, that is the case, though again we must wait to have more\ntools with which to prove it.  Still, if\nwe take for granted that $a>0\\implies \\frac{d}{dx}(a^x)$ exists, we can\nperform the following computation.  Note \nthat $a^x$ is constant in the limit (which varies $\\Delta x$, \nand not $x$ itself).\n\\begin{alignat*}{2}\nf(x)=a^x&\\implies&f'(x)&=\\lim_{\\Delta x\\to 0}\\frac{f(x+\\Delta x)-f(x)}\n                            {\\Delta x}\\\\\n        &&&=\\lim_{\\Delta x\\to0}\\frac{a^{x+\\Delta x}-a^x}{\\Delta x}\\\\\n        &&&=\\lim_{\\Delta x\\to0}\\frac{a^x(a^{\\Delta x}-a^0)}{\\Delta x}\\\\\n        &&&=a^x\\cdot\\lim_{\\Delta x\\to0}\\frac{a^{0+\\Delta x}-a^0}{\\Delta x}\\\\\n        &&&=a^x\\cdot\\lim_{\\Delta x\\to0}\\frac{f(0+\\Delta x)-f(0)}{\\Delta x}\\\\\n        &&&=a^x\\cdot f'(0).\n\\end{alignat*}\nTo get the last line from the one immediately prior\nis just to recognize the definition of $f'(0)$.  In all cases $a>0$ we see that\n\\begin{equation}f(x)=a^x\\implies f'(x)=a^x\\cdot f'(0).\\label{da^x/dxInTheory}\n\\end{equation}\nSo if $f(x)=a^x$, then $f'(x)$ is a constant multiple of the\noriginal function $a^x$,\nthat constant---namely $f'(0)$---depending upon $a$.\n\nNow, perhaps with the aid of a computer to approximate $f'(0)$\nfor various functions $f(x)=a^x$, it can be determined (for now without proof)\nthat\n\\begin{alignat*}{3}\nf(x)&=2^x&&\\implies&f'(0)&\\approx0.69314718,\\\\\nf(x)&=3^x&&\\implies&f'(0)&\\approx1.09861229.\\end{alignat*}\nDue to the nature of the functions, it is not hard to see that the\nlarger the base $a$, the greater the slope of the graph of $a^x$.\nSo for $b\\in(2,3)$, we get the slope of $b^x$ at $x=0$ should\nbe between that of $2^x$ and $3^x$ at $x=0$.\nIt is then reasonable to believe that for some number\n$e\\in(2,3)$, we will get $f'(0)=1$, so that (\\ref{da^x/dxInTheory})\nbecomes\n\\begin{equation}f(x)=e^x\\implies f'(x)=e^x\\cdot1=e^x.\\end{equation}\nIn fact, that number $e$ does exist (and we will find other ways \nto {\\it derive} it much later), and $e^x$ is \ngraphed along with $2^x$ and $3^x$ in \nFigure~\\ref{ThreeExponentialsWithEXPBetween}.\nThus we  have a derivative\nformula, with the chain rule version following as always:\n\n\\begin{equation}\n\\frac{d\\,e^x}{dx}=e^x,\\label{DerivativeOfEXP}\\qquad\\qquad\n\\frac{d\\,e^u}{dx}=e^u\\cdot\\frac{du}{dx}.\n\\end{equation}\nThe number $e$ is irrational, but can be given approximately by\\footnote{%\n%%% FOOTNOTE\nWe list 50 places after the decimal point because many students get the\nwrong impression when seeing the standard $e\\approx2.718281828$, leading\nthem to leap to the conclusion that there is a pattern in the decimal\nrepresentation.  Of course, the number $2.7\\overline{1828}$ is\na ``repeating decimal'' and therefore rational, unlike $e$ which is\nirrational.  (An interesting algebra exercise is to show that\n$2.7\\overline{1828}=271,801/99,990$, an obviously rational number.)%%% \n%%% END FOOTNOTE\n}\n\\begin{equation}\ne\\approx2.71828\\ 18284\\ 59045\\ 23536\\ 02874\\ 71352\\ 66249\\ 77572\\ 47093\\ 69996.\n\\label{EXP(1),Approximately}\n\\end{equation}\nThe function $e^x$, together with $2^x$ and $3^x$, is given \nin Figure~\\ref{ThreeExponentialsWithEXPBetween}.\nLater we will show that only constant multiples of $e^x$\nare their own derivative functions.  Now we can\ninclude such functions in derivative problems.\n\n\n\n\\bex Compute $\\ds{\\frac{d}{dx}(e^x)^2}$ two different ways:\nfirst by the chain rule in the obvious way, and then by\ninstead rewriting the function using properties of exponents.\n\n\\underline{Solution}:\n\\begin{enumerate}[(a)]\n\\item $\\ds{\\frac{d(e^x)^2}{dx}=2(e^x)\\frac{d\\,e^x}{dx}=2e^x\\cdot e^x=2e^{2x}}$.\n\\item $\\ds{\\frac{d(e^x)^2}{dx}=\\frac{d\\,e^{2x}}{dx}\n          =e^{2x}\\cdot\\frac{d\\,2x}{dx}=e^{2x}\\cdot2=2e^{2x}}$.\n\\end{enumerate}\n\\eex\nOf course we expect to be able to rewrite a function algebraically \nbefore computing a derivative, and perhaps save some work\nin the derivative steps.\n\\bex Compute $\\ds{\\frac{d}{dx}\\left[\\frac{e^x}{e^{8x}}\\right]}$.\n\n\\underline{Solution}:\n$\\ds{\\frac{d}{dx}\\left[\\frac{e^x}{e^{8x}}\\right]\n =\\frac{d}{dx}e^{x-8x}=\\frac{d}{dx}e^{-7x}\n =e^{-7x}\\frac{d}{dx}(-7x)=-7e^{-7x}}$.\n\\eex\nThe above example could have been computed using the\nquotient rule (an interesting exercise), but the \nalgebraic simplification made this easier.\nNow we list several further examples, all of which should\nbe self-explanatory.\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}(5e^x)=5\\cdot\\frac{d}{dx}e^x=5e^x}$.\n\\item $\\ds{\\frac{d}{dx}e^{x^2}=e^{x^2}\\cdot\\frac{d\\,x^2}{dx}\n             =e^{x^2}\\cdot2x=2xe^{x^2}}$.\n\\item $\\ds{\\frac{d}{dx}\\sin e^x=\\cos e^x\\cdot\\frac{d\\,e^x}{dx}\n             =\\cos e^x\\cdot e^x=e^x\\cos e^x}$.\n\\item $\\ds{\\frac{d}{dx}\\sin^{-1}e^x=\\frac{1}{\\sqrt{1-(e^x)^2}}\n              \\cdot\\frac{d}{dx}(e^x)=\\frac1{\\sqrt{1-e^{2x}}}\\cdot e^x\n               =\\frac{e^x}{\\sqrt{1-e^{2x}}}}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\frac{e^x}{x^2}\\right]\n              =\\frac{x^2\\frac{d}{dx}\\left(e^x\\right)\n                       -e^x\\frac{d}{dx}\\left(x^2\\right)}{(x^2)^2}\n              =\\frac{x^2e^x-e^x\\cdot2x}{x^4}\n              =\\frac{xe^x(x-2)}{x^4}=\\frac{e^x(x-2)}{x^3}}$.\n\\item $\\ds{\\frac{d}{dx}(e^{\\csc x})\n              =e^{\\csc x}\\frac{d}{dx}(\\csc x)\n              =e^{\\csc x}(-\\csc x\\cot x)\n              =-e^x\\csc x\\cot x}$.\n\\item $\\ds{\\frac{d}{dx}(e^{2x}\\sin3x)\n              =e^{2x}\\frac{d\\,\\sin3x}{dx}+\\sin3x\\frac{d\\,e^{2x}}{dx}\n              =e^{2x}\\cos 3x\\frac{d\\,3x}{dx}+\\sin3x\\cdot e^{2x}\\frac{d\\,2x}{dx}\n              }$\n\n              \\qquad\\qquad \n              $=3e^{2x}\\cos3x+2e^{2x}\\sin3x=e^{2x}(3\\cos3x+2\\sin3x).$\n\\item $\\ds{\\frac{d}{dx}\\sec^{-1}e^x\n         =\\frac1{|e^x|\\sqrt{(e^x)^2-1}}\\cdot\\frac{d}{dx}\\left(e^x\\right)\n         =\\frac1{{e^x}\\sqrt{e^{2x}-1}}\\cdot e^x\n         =\\frac1{\\sqrt{e^{2x}-1}}.}$\n\nHere we used the fact that $e^x>0$ for all $x$, so that $|e^x|=e^x$.\n\\item $\\ds{\\frac{d}{dx}\\sqrt[3]{e^{5x}}\n              =\\frac{d}{dx}\\left[(e^{5x})^{1/3}\\right]\n              =\\frac{d}{dx}(e^{(5/3)x})\n              =e^{(5/3)x}\\cdot\\frac{d[(5/3)x]}{dx}\n              =\\frac53e^{(5x/3)}}$.\n\\end{itemize}\nThese are all exercises involving the old differentiation rules,\ncombined with our newest derivative formula (\\ref{DerivativeOfEXP}).\nIn the last problem above, we simplified first to avoid calling\nan extra chain rule.\n\n\\subsection{Note on Differences Between Polynomials, Exponentials}\nIt should be well noted that these functions $a^x$ in general,\nand $e^x$ in particular, are very different from\nany of the other functions we had previously.  Even though\nthey involve powers, in the past the $x$-variable was\npart of the {\\bf base}, and {\\bf not the exponent}.\nCompare the behavior of $x^2$ and $2^x$, for instance,\nas well as the natures of their derivatives.\nFor a more dramatic example, consider\n\\begin{align*}\n\\frac{d}{dx}x^{20}&=20x^{19},\\\\\n\\frac{d}{dx}20^x  &=20^x\\cdot k,\\qquad\\qquad k=\\left.\\frac{d\\,20^x}{dx}\n         \\right|_{x=0}.\n\\end{align*}\nNot only are the power rule and exponential rule formulas not\nthe same, but the power rule in the polynomial\nexample decreases the power for the derivative, which does\nnot occur in the exponential problem.\\footnote{%%%\n%%% FOOTNOTE\nA common mistake among novice calculus students\nis treat exponential functions as if they are similar to polynomials\nwhen, for instance, computing derivatives.\nIt is important to notice, for example, that\n$$\\frac{d}{dx}20^x\\ne x\\cdot 20^{x-1}.$$\nThe above derivative is not a power rule.  Power rules\nassume the variable is in the base, not the exponent\n(and that the exponent is a constant).\n%%% END FOOTNOTE\n}  The two functions share at most a vague resemblance in their\nbehaviors.  (Both increase without bound, but that is almost where\nthe similarities end.)\nIt is very different to raise the (variable) $x$ to a constant power, than to\ntake a constant raised to the (variable) $x$th power.\nIn fact we will be able to show later that any \nexponential growth will trump any polynomial growth:\n\\begin{equation}\\lim_{x\\to\\infty}\\frac{a^x}{x^n}=\\infty\\qquad \\text{for }a>1,\n    \\text{ and any fixed }n.\\label{LimitA^X/X^NAsXToInfty}\n\\end{equation}\nThus, though the trend would not show itself until $x$ is \nalmost unimaginably large,\nwe have for example\n$$\\lim_{x\\to\\infty}\\frac{(1.0000000000000000001)^x}{x^{1000}}=\\infty.$$\nIt would require special programming, with a very large\nnumber of significant digits allowed, to see this trend\nwith the help of a computer, though in a later chapter\nwe will be able to prove the limit above with ease.\n\\newpage\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item Compute the following derivatives (in pairs):\n\\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}e^{\\sin x}}$,\\qquad $\\ds{\\frac{d}{dx}\\sin e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\cos x}}$,\\qquad $\\ds{\\frac{d}{dx}\\cos e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\tan x}}$,\\qquad $\\ds{\\frac{d}{dx}\\tan e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\cot x}}$,\\qquad $\\ds{\\frac{d}{dx}\\cot e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\sec x}}$,\\qquad $\\ds{\\frac{d}{dx}\\sec e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\csc x}}$,\\qquad $\\ds{\\frac{d}{dx}\\csc e^x}$\n\\end{enumerate}\n\\item Compute the following derivatives (in pairs):\n\\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}e^{\\sin^{-1} x}}$,\\qquad \n                   $\\ds{\\frac{d}{dx}\\sin^{-1} e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\cos^{-1} x}}$,\\qquad \n                    $\\ds{\\frac{d}{dx}\\cos^{-1} e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\tan^{-1} x}}$,\\qquad \n                    $\\ds{\\frac{d}{dx}\\tan^{-1} e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\cot^{-1} x}}$,\\qquad \n                    $\\ds{\\frac{d}{dx}\\cot^{-1} e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\sec^{-1} x}}$,\\qquad \n                    $\\ds{\\frac{d}{dx}\\sec^{-1} e^x}$\n  \\item $\\ds{\\frac{d}{dx}e^{\\csc^{-1}x}}$, \\qquad\n                    $\\ds{\\frac{d}{dx}\\csc^{-1} e^x}$\n  \\end{enumerate}\n\\item Compute the following derivatives by first \nrewriting the original function using properties\nof exponents. (These will still require chain rules.)\n\\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{e^x}}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac1{e^x}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}(e^{2x})^{9}}$\n  \\item $\\ds{\\frac{d}{dx}\\left(e^xe^{3x}\\right)}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{e^{5x}}{e^{3x}}\\right]}$\n\\end{enumerate}\n\\item Compute the following derivatives:\n\\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\left(e^{x^2}\\right)}$\n  \\item $\\ds{\\frac{d}{dx}\\left(e^{-x}\\right)}$\n  \\item $\\ds{\\frac{d}{dx}\\left(e^{\\sqrt{x}}\\right)}$\n  \\item $\\ds{\\frac{d}{dx}\\left(e^{-1/x^2}\\right)}$\n  \\item $\\ds{\\frac{d}{dx}(2e^x+9)^4}$\n  \\item $\\ds{\\frac{d}{dx}\\sin^2e^{x^3}}$\n  \\item $\\ds{\\frac{d}{dx}\\left(x^3e^x\\right)}$ (factor your answer)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{e^{2x}}{x^2+1}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{e^x}5\\right]}$  \n            (rewrite as a multiplication first)\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{e^x-e^{-x}}{2}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}e^{e^x}}$\n  \\item $\\ds{\\frac{d}{dx}(xe^x-x)}$ (simplify your answer)\n\n\\end{enumerate}\n\\item For general $a>1$,  use the facts that $a^x>0$ for all $x$,\n     and  that $x>0\\implies a^x>1$\n      to prove that $a^x$ is increasing, i.e., \n      $x_1<x_2\\implies a^{x_1}<a^{x_2}$.\n      (Hint: consider $a^{x_2}-a^{x_1}$, factor, and show this is \n       positive.)\n\\end{enumerate}\n\\end{multicols}\n\n\\newpage\n\\section{The Natural Logarithm I}\nIn this section we introduce the function which is the inverse\nto $e^x$, namely the {\\it natural logarithm} of $x$,\ndenoted $\\ln x$.  Its derivative, as in the case with\nthe arctrigonometric functions, is surprisingly\nsimple and algebraic, and has nothing algebraically to do with\nlogarithms, trigonometric, arctrigonometric or exponential\nfunctions.\n\nWe will derive the derivative of the natural logarithm,\nand look at several examples of derivatives involving\nthis function.  \nBefore exploring the calculus of the natural logarithm, we\nwill review the algebra of general logarithm functions.\nIn doing so, we will see examples where what would be\ndifficult derivatives can be found more quickly when we\nrewrite the function to a more convenient form for calculus,\nusing the algebraic properties of logarithms.\n\nIn the next section, we will use algebraic techniques to\nextend the results here to\ncompute derivatives of more general logarithm and exponential\nfunctions, such as $\\log_ax$ and $a^x$.  We will also\ndevelop a technique known as logarithmic differentiation\nwhich will allow faster differentiation in many cases,\nas well as differentiation of functions of the \nform $f(x)^{g(x)}$ (where the base {\\it and} the exponent\nare both allowed to vary).\n\n\\subsection{Algebra of Logarithms}\nFor $a\\in(0,1)\\cup(1,\\infty)$ we define below the logarithm---with base\n$a$---of $x$, written $\\log_ax$, as described below:\n\\begin{definition} For $x>0$, \n$\\log_ax$ is that number $y$ so that $a^y=x$.  In other words,\n$\\log_ax$ is that power of $a$ which yields $x$.\n\\end{definition}\n\\bex Consider the following logarithm computations:\n\\begin{alignat*}{3}\n\\log_28&=3\\qquad&\\qquad &\\text{since}&\\qquad\\qquad2^3&=8,\\\\\n\\log_39&=2&&\\text{since}&3^2&=9,\\\\\n\\log_{10}\\frac1{100}&=-2&&\\text{since}&10^{-2}&=\\frac1{100},\\\\\n\\log_{16}2&=\\frac14&&\\text{since}&16^{1/4}&=2,\\\\\n\\log_{27}9&=\\frac23&&\\text{since}&27^{2/3}&=9,\\\\\n\\log_{4}\\frac18&=-\\frac32&&\\text{since}&4^{-3/2}&=\\frac18.\n\\end{alignat*}\n\\eex\nAn observation which follows very quickly from the definition\nof the logarithms is the following:\n\\begin{equation}\n\\log_aa^x=x.\\label{LogBaseAOfA^X=X...FirstTime}\n\\end{equation}\nWe will make repeated use of that observation.\nFor now we note that  with (\\ref{LogBaseAOfA^X=X...FirstTime})\nwe can perform computations as above by instead rewriting\nthe argument of the logarithm as a power of $a$:\n\\bex We compute the following examples using\n(\\ref{LogBaseAOfA^X=X...FirstTime}).\n\\begin{alignat*}{2}\n\\log_28&=\\log_22^3&&=3,\\\\\n\\log_{10}1000&=\\log_{10}10^3&&=3,\\\\\n\\log_84&=\\log_88^{2/3}&&=2/3,\\\\\n\\log_3\\frac1{81}&=\\log_33^{-4}&&=-4,\\\\\n\\log_aa&=\\log_aa^1&&=1.\n\\end{alignat*}\n\\eex\nNow we list some properties of logarithms based upon\nthe definition.  We also show how they mirror the related\nproperties of exponents.  In the table below, assume\n$M=a^m$ and $N=a^n.$\n\n\\begin{center}\n\\begin{tabular}{lcl}\n{Logarithmic Property}&\\qquad\\qquad&{Exponential Property}\\\\\n\\hline\n&&\\\\\n&&\\\\\n1. $\\ds{\\log_a(MN)=\\log_aM+\\log_aN}$ &&1. $\\ds{a^ma^n=a^{m+n}}$\\\\\n&&\\\\\n2. $\\ds{\\log_a\\frac{M}N=\\log_aM-\\log_aN}$&&2. $\\ds{\\frac{a^m}{a^n}\n                                                  =a^{m-n}}$\\\\\n&&\\\\\n3. $\\ds{\\log_a M^p=p\\cdot\\log_aM}$&&3. $\\ds{(a^m)^p=a^{mp}}$\\\\\n&&\\\\\n4. $\\ds{\\log_a1=0}$&&4. $\\ds{a^0=1}$\\\\\n&&\\\\\n5. $\\ds{\\log_a\\frac1M=-\\log_aM}$&&5. $\\ds{a^{-m}=\\frac1{a^m}}$\n\n\\end{tabular}\n\\end{center}\n\nThe first logarithmic property reflects the first exponential\nproperty in the following way.  When we say $M=a^m$ and $N=a^n$,\nwe can think of these as stating \nthat while $M$ represents $m$ factors of $a$, and $N$ represents $n$ \nfactors of $a$, it follows that  $MN$ represents $m+n$ factors of $a$:  \n\n\\begin{align*}\n\\log_a(\\underbrace{\\underbrace{M}_{a^m}\\underbrace{N}_{a^n}}_{a^{m+n}})\n&=\\log_a\\underbrace{M}_{a^m}\\ +\\ \\log_a\\underbrace{N}_{a^n},\\text{ i.e.,}\\\\\n\\log_{a}a^{m+n}&=\\log_aa^m+\\log_aa^n,\\text{ i.e.,}\\\\\nm+n&=\\qquad m\\quad+\\qquad n.\\end{align*}\n\n\nThis makes perfect sense if $m,n\\in\\{0,1,2,3,4,\\cdots\\}$,\nbut we can also  make sense of having a half-factor of $a$, which\nis then $a^{1/2}$, i.e., the square root of $a$.  We \ncan also talk about having $-3$ factors of $a$, which is\nlike removing 3 factors, or dividing by $a^3$, which is\nthe same as having a factor of $a^{-3}$. Extending this\nto all real powers of $a$, we can say that by a number\nrepresenting $m$ factors of $a$ means that number being $a^m$,\nas we would have computed in the previous section.\n(For that discussion, see page \n\\pageref{NeedPageForIrrationalPowersOfAExplained}.)\n\n\nThe second property says, roughly, that if we have $m$ factors\nof $a$, and we divide by $n$ factors of $a$, then\nwe are left with $m-n$ factors of $a$.  \n\nThe third says that if $M$ represents $m$ factors of $a$,\nthen $M^p$ represents $p\\cdot m$ factors of $a$.\n\nThe fourth can be interpreted as meaning, in the context of\nmultiplication\\footnote{%%%\n%%% FOOTNOTE\nIn the context of addition, having ``nothing,'' i.e., subtracting\neverything would mean being left with\nonly zero to add.  In multiplication, we can divide everything\nleaving ``nothing,'' in a sense meaning being left with the\nfactor 1 only.  In addition, we can say we begin with zero;\nin multiplication, the factor 1.\n%%% END FOOTNOTE\n} (which is arguably the context of exponents and therefore\nultimately logarithms), having no factors of $a$ is the same\nas being left with the factor 1 only.  Of course it also\nfollows from our definition of logarithms, since 1 is the\nzeroth power of $a$.\n\nThe fifth property can be achieved by the second (with help from\nthe fourth) or from the third:\n\\begin{alignat*}{3}\n\\log_a\\frac1M&=\\log_a1-\\log_aM&&=0-\\log_aM&&=-\\log_aM,\\\\\n\\log_a\\frac1M&=\\log_a(M)^{-1}&&=-1\\log_aM&&=-\\log_aM.\n\\end{alignat*}\n\n\n%NEED EXAMPLES!!!!!!\n\nNote that the algebraic properties of logarithms follow because\nlogarithms are about\ncounting {\\it factors} of the base $a$, and so products, quotients\nand powers are more relevant to logarithms.  Thus there are\nno simple, general rules for expanding $\\log_a(M+N)$ or $\\log_a(M-N)$,\nfor instance.  \n\nHowever there is one last, crucial property which requires mention,\nsince we may be interested in computing approximations to \nnumbers such as $\\log_23$, though our calculating devices\ngenerally do not come equipped with the function $\\log_2x$.\nThus we need a ``change of base'' formula, which follows.\nIn what is below, we assume $a,b\\in(0,1)\\cup(1,\\infty)$,\nwhich (as explored in the exercises)\nis what we require of ``proper bases'' for a logarithm.\nIn the next section we will prove the change of base formula:\n\\begin{equation}\n\\log_ax=\\frac{\\ds{\\log_bx}}{\\ds{\\log_ba}}.\\label{ChangeOfBase}\n\\end{equation}\nIf we let $b=10$ we can compute on a standard scientific calculator\n$$\\log_23=(\\log_{10}3)/(\\log_{10}2)\\approx1.584962501.$$\nThis is reasonable, since $2^1=1$ and $2^2=4$, and $f(x)=2^x$\nis continuous on all of $\\Re$,\nso for some $x\\in(1,2)$ we have $2^x=3$.  (See\nFigure~\\ref{2^X,2^-XGraphs}, page \\pageref{2^X,2^-XGraphs}.)\n\nIt should be pointed out that most scientific calculators have\ntwo logarithmic keys:\n$\\log_{10}x$, labeled ``$\\log x$'' and $\\log_ex$\ngiven by ``$\\ln x$.''  Though many sciences use the \nlogarithm with base 10, for calculus it turns out that\n$\\ln x$ is much more useful, as we will see.\\footnote{%%%\n%%% FOOTNOTE\nOne has to be careful when reading formulas which contain\n``$\\log x$,'' because while most texts mean by this $\\log_{10}x$,\nthere are some which will mean $\\log_ex$, i.e., $\\ln x$.\nThe problem is akin to knowing if $\\sin x$ is a function of\n$x$ in radians, or in degrees.  We will always write\n$\\ln x$ for $\\log_{e}x$, and $\\log x$ for $\\log_{10}x$.   \n%%% END FOOTNOTE\n}\n\nOne interesting aspect of (\\ref{ChangeOfBase}) is that\nevery function $\\log_ax$ is a constant multiple of every\nother such function.  For instance, with $a=\\in(0,1)\\cup(1,\\infty)$\nand $b=e$ in (\\ref{ChangeOfBase}), we have\n\\begin{equation}\n\\log_ax=\\frac{\\log_ex}{\\log_ea}=\\frac{\\ln x}{\\ln a}.\n\\label{ChangeLogBaseToE}\\end{equation}\nIn this section we will develop the derivative of the natural\nlogarithm, and with (\\ref{ChangeLogBaseToE}) we will therefore have\nderivatives of all the other logarithms.\n\nWe will see that algebraically\nthe logarithm function in any base $a\\in(0,1)\\cup(1,\\infty)$\nis the inverse function of the exponential function with the same\nbase.  Thus the range of the exponential becomes the domain\nof the logarithm, and the domain of the exponential becomes the\nrange of the logarithm.  The range and domain of the exponential\nfunctions being $(0,\\infty)$ and $\\Re$, respectively, we have \nthe following for general $a\\in(0,1)\\cup(1,\\infty)$:\n\\begin{align}\n\\log_a a^x&\\ \\ =x,\\qquad x\\in\\Re,\\\\\na^{\\log_ax}&\\ \\ =x,\\qquad x>0,\\\\\ny=\\log_ax&\\iff \\qquad x=a^y.\\label{Log<->Exponential}\n\\end{align}\n\\subsection{Graph of the  Natural Logarithm Function}\n\n\nWe will use (\\ref{Log<->Exponential}), with the case\n$a=e$,  to both graph, and eventually  differentiate $y=\\ln x$.\nThe case $a=e$ is important enough that it bears \nemphasis:\n\\begin{align}\n             y=\\ln x&\\iff \\qquad x=e^y.\\\\ \\label{Ln<->Exp}\n\\ln e^x&\\ \\ =x,\\qquad x\\in\\Re,\\\\\n             e^{\\ln x}&\\ \\ =x,\\qquad x>0,\\end{align}\nAccording to (\\ref{Ln<->Exp}), we see that graphing $y=\\ln x$ \nis the same as graphing $x=e^y$.  Of course, graphing $x=e^y$ is\nthe same as graphing $y=e^x$, except that $x$ and $y$ have\nchanged roles, so $(0,1)$ being in the graph of $y=e^x$\nmeans that $(1,0)$ is  in the graph of $x=e^y$, i.e., $y=\\ln x$.\nIn Figure~\\ref{Ln<->ExpFigure} we have both $y=e^x$ (in gray),\nand $x=e^y$, i.e., $y=\\ln x$, in thick black.\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-2,-2)(6,6)\n\\psset{xunit=.666666666cm,yunit=.666666666cm}\n\\psaxes{<->}(0,0)(-3,-3)(9,9)\n\\psplot[plotpoints=1000,linecolor=gray]%\n               {-3}{2.197224577}{2.718281828 x exp}\n\\psplot[plotpoints=1000,linewidth=1.5pt]%\n             {0.049787068}{9}{x log 2.718281828 log div}\n\\pscircle[fillstyle=solid,fillcolor=black](2.718281828,1){.09}\n\\pscircle[linecolor=gray,fillstyle=solid,fillcolor=gray](1,2.718281828){.09}\n\\rput(2,3){$(1,e)$}\n\\rput(3,1.7){$(e,1)$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](7.389056099,2){.09}\n\\pscircle[linecolor=gray,fillstyle=solid,fillcolor=gray](2,7.389056099){.09}\n\\rput(7.4,2.5){$(e^2,2)$}\n\\rput(3,7.8){$(2,e^2)$}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graphs of $y=e^x$ in gray, and $y=\\ln x$\n(i.e., $x=e^y$) in black.}\n\\label{Ln<->ExpFigure}\n\\end{figure}\n\nReferring to the graph in Figure~\\ref{Ln<->ExpFigure}, we see\nalso the following limiting behavior:\n\\begin{align}\nx\\to 0^+&\\iff \\ln x\\to-\\infty,\\label{LnTo-Infty}\\\\\nx\\to\\infty&\\iff \\ln x\\to\\infty.\\label{LnToInfty}\n\\end{align}\nThese follow from $x\\to-\\infty\\iff e^x\\to0^+$,\nand $x\\to\\infty\\iff e^x\\to\\infty$, respectively.\nThe growth in $\\ln x$ shown in the graph is indeed \nunbounded, but it is a very slow type of growth.\nIn fact, such slow growth is dubbed {\\it logarithmic growth}.\nWe will show in a later chapter that this growth is slower\nthan any positive power of $x$, so for example\n$$\\lim_{x\\to\\infty}\\frac{\\ln x}{x^{0.00000000001}}=0.$$\nWe can replace $0.00000000001$ with any other positive\nnumber and have the same limit.  More generally,\n\\begin{equation}\\lim_{x\\to\\infty}\\frac{\\log_ax}{x^s}=0,\n\\qquad \\text{ for } a>1,\\text{ and } s>0.\\label{LimitXToInftyLoga/X^s}\n\\end{equation}\nThis is the logarithmic version of \n(\\ref{LimitA^X/X^NAsXToInfty}), page\n\\pageref{LimitA^X/X^NAsXToInfty}.\\footnote{%\n%%% FOOTNOTE\nIt may not be so obvious that $x\\to\\infty\\implies\\ln x\\to\\infty$\nfrom the graph.  Recall\n$$\\lim_{x\\to\\infty}f(x)=\\infty \\iff\n(\\forall N)(\\exists M)[x>M\\longrightarrow f(x)>N].$$\nThus we need to show that we, for any $N$, can force $\\ln x>N$ by \ntaking $x>M$ for some $M$.  Later we will show that $\\ln x$ is\nan increasing function on its domain $(0,\\infty)$, so \nwe can take $M=e^N$, so $x>M\\implies \\ln x>\\ln M=\\ln e^N=N$.\nSo for example if we want to show that eventually, as we move rightward\non the $x$-axis, we have $\\ln x>10,000,000,000$, we just \ntake $x>e^{10,000,000,000}\\ (=M)$, a very large number but certainly finite.\n%%% END FOOTNOTE\n}\n\n\\subsection{Derivative of Natural Logarithm}\nWe use (\\ref{Ln<->Exp}), that is $y=\\ln x\\iff x=e^y$, to compute\n$\\frac{d}{dx}\\ln x$ using implicit differentiation as follows:\n\\begin{alignat*}{3}\ny=\\ln x&\\iff\\qquad&e^y&=x\\\\\n       &\\implies      &\\frac{d}{dx}(e^y)&=\\frac{d}{dx}(x)\\\\\n       &\\implies      &e^y\\cdot\\frac{dy}{dx}&=1\\\\\n       &\\implies      &\\frac{dy}{dx}&=\\frac1{e^y}=\\frac1x.\n\\end{alignat*}\nWe summarize this and the chain rule version:\n\\begin{align}\n    \\frac{d}{dx}(\\ln x)&=\\frac1x,\\label{DerivativeLnX}\\\\\n    \\frac{d}{dx}(\\ln u)&=\\frac1u\\cdot\\frac{du}{dx}.\\label{DerivativeLnU}\n\\end{align}\nThus the derivative of the natural logarithm is in fact\na simple power, albeit the $-1$ power. \n\nAs nice as (\\ref{DerivativeLnX}) and (\\ref{DerivativeLnU})\nappear to be, they are incomplete.  The first clue is that\nthe derivative formulas seem to be defined as long as\n$x$ (or $u$) is nonzero, while the logarithm required\npositive $x$ (or $u$).  Thus we know what kind of function\ngives derivative $\\frac1x$ as long as $x>0$, but \n$\\frac1x$ exists for $x\\ne 0$, so we should like to know\nwhat function gives rise to derivative $\\frac1x$ for \n$x<0$ as well.  (For example, what kind of position gives\nvelocity $\\frac1t$ even when $t<0$?)  The solution to this is\nto consider the functions $\\ln|x|$, and more generally $\\ln|u|$,\nwhich are defined as long as $|x|$ and $|u|$ are simply nonzero.\nIn fact, our more general derivative formulas are the following:\n\\begin{align}\n\\frac{d}{dx}\\ln|x|&=\\frac1x,\\label{DerivativeLn|X|}\\\\\n\\frac{d}{dx}\\ln|u|&=\\frac1u\\cdot\\frac{du}{dx}.\\label{DerivativeLn|U|}\n\\end{align}\nIf we know $x$ or $u$, respectively, is positive then the absolute\nvalues above are redundant. In considering (\\ref{DerivativeLn|X|}),\nnote that the graph of $y=\\ln|x|$, given in Figure~\\ref{GraphLn|X|Figure},\npage~\\pageref{GraphLn|X|Figure}, shows how\nthat the derivative $\\frac1x$ gives reasonable slopes at several points. \n\n\n\n\\begin{figure}\n\\begin{center}\n\\begin{pspicture}(-6,-3)(6,4.5)\n%\\psset{xunit=.666666666cm,yunit=.666666666cm}\n\\psaxes{<->}(0,0)(-6,-3)(6,4)\n\\psplot[plotpoints=1000%,linewidth=1.5pt]%\n            ] {0.049787068}{6}{x  log 2.718281828 log div}\n\\psplot[plotpoints=1000%,linewidth=1.5pt]%\n           ] {-6}{-0.049787068}{0 x sub log 2.718281828 log div}\n%\\pscircle[fillstyle=solid,fillcolor=black](2.718281828,1){.09}\n%\\rput(2,3){$(1,e)$}\n%\\rput(3,1.7){$(e,1)$}\n\n\\pscircle[fillstyle=solid,fillcolor=black](2,.693147){.08}\n  \\rput{26.565}(2,1.15){$f'(2)=\\frac12$}\n\\pscircle[fillstyle=solid,fillcolor=black](4,1.38629){.08}\n  \\rput{14.0362}(4,1.8){$f'(4)=\\frac14$}\n\\pscircle[fillstyle=solid,fillcolor=black](-2,.693147){.08}\n  \\rput{-26.565}(-1.8,1.15){$f'(-2)=-\\frac12$}\n\\pscircle[fillstyle=solid,fillcolor=black](-4,1.38629){.08}\n  \\rput{-14.0362}(-4.2,1.8){$f'(-4)=-\\frac14$}\n\n\\rput(0,4.5){$f(x)=\\ln|x|$}\n\\end{pspicture}\n\\end{center}\n\\caption{Partial graph of $f(x)=\\ln|x|$ with slopes at some sample points.}\n\\label{GraphLn|X|Figure}.\n\\end{figure}\n\nWe now prove (\\ref{DerivativeLn|X|}), \nassuming  (\\ref{DerivativeLnX}) and (\\ref{DerivativeLnU}),\nas follows.  For convenience we first assume \\label{ProofOfDerivLn|X|Stuff}\n$$f(x)=\\ln|x|.$$\n\\begin{enumerate}\n\\item Case $x\\in(0,\\infty)$:  Here $f(x)=\\ln|x|=\\ln x$, so $f'(x)=\\frac1x$\n      as before (see (\\ref{DerivativeLnX}) above).\n\\item Case $x\\in(-\\infty,0)$:  Here $f(x)=\\ln|x|=\\ln(-x)$, so\n      we can let $u=-x>0$, and use (\\ref{DerivativeLnU}) as follows:\n     $$x<0\\implies f(x)=\\ln(-x)\\implies f'(x)=\\frac1{-x}\\cdot\\frac{d(-x)}{dx}\n         =\\frac{1}{-x}\\cdot(-1)=\\frac1x.$$\n\\item Thus in both cases we have $f'(x)=\\frac1x$, q.e.d.\n\\end{enumerate}\nNow we can put these derivative formulas to use.\n\\newpage\n\\bex We compute the following derivative:\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}x\\ln x=x\\cdot\\frac{d}{dx}\\ln x+(\\ln x)\\frac{d}{dx}(x)\n                             =x\\cdot\\frac1x+\\ln x\\cdot1=1+\\ln x.}$\n\\item $\\ds{\\frac{d}{dx}\\ln|\\cos x|=\\frac1{\\cos x}\\cdot\\frac{d}{dx}\\cos x\n                             =\\frac1{\\cos x}\\cdot(-\\sin x)=-\\tan x}$.\n\\item $\\ds{\\frac{d}{dx}\\sin(\\ln|x|)=\\cos(\\ln|x|)\\cdot\\frac{d}{dx}(\\ln|x|)\n            =\\cos(\\ln|x|)\\cdot\\frac1x=\\frac{\\cos(\\ln|x|)}{x}}$.\n\\item $\\ds{\\frac{d}{dx}\\ln\\sqrt{x}=\\frac1{\\sqrt{x}}\\cdot\\frac{d}{dx}\\sqrt{x}\n            =\\frac1{\\sqrt{x}}\\cdot\\frac{1}{2\\sqrt{x}}=\\frac1{2x}}$.\n\\end{itemize}\n\\eex\nNotice in the latest example we get one-half the answer we would\nhave had if we had taken the derivative of $\\ln x$.  In fact\nthat can be seen from one of the properties of logarithms:\n$$\\frac{d}{dx}\\ln\\sqrt{x}=\\frac{d}{dx}\\ln(x)^{1/2}\n      =\\frac{d}{dx}\\left[\\frac12\\ln x\\right]=\\frac12\\cdot\\frac1x,$$\nwhich agrees with what we derived before.  Thus we can at times use the\nproperties of logarithms to rewrite the function in such a way that\nthe derivative computation is simpler.  For review, and emphasis on \nthe natural logarithm, we revisit the properties of logarithms as\napplied to the special case $a=e$.  In what is below, $M,N>0$ and $p\\in\\Re$.\n\\begin{align}\n\\ln(MN)&=\\ln M+\\ln N,\\label{LnMN}\\\\\n\\ln\\frac{M}{N}&=\\ln M-\\ln N,\\label{LnM/N}\\\\\n\\ln(M^p)&=p\\cdot\\ln M,\\label{LnM^P}\\\\\n\\ln 1&=0,\\label{Ln1=0}\\\\\n\\ln\\frac1M&=-\\ln M,\\label{Ln1/M}\\\\\n\\log_aM&=\\frac{\\ln M}{\\ln a}.\\label{ChangOfBaseWithLn}\n\\end{align}\nThe absolute value can be introduced easily into the arguments\nof the natural logarithm.  For instance,\\footnotemark\n\\begin{alignat*}{2}\n\\ln|MN|&=\\ln(|M|\\cdot|N|)&&=\\ln|M|+\\ln|N|,\\\\\n\\ln|M/N|&=\\ln(|M|/|N|)&&=\\ln|M|-\\ln|N|,\\\\\n\\ln\\left|M^p\\right|&=\\ln|M|^p&&=p\\cdot\\ln|M|\\end{alignat*}\n\\footnotetext{\n%%% FOOTNOTE\nNote that $|M^p|\\ne|M|^{|p|}$ if $p<0$, as for example\n$$\\left|2^{-3}\\right|=\\left|\\frac18\\right|=\\frac18,\n\\qquad\\qquad |2|^{|-3|}=2^3=8.$$\n%%% END FOOTNOTE\n}\n\n\\bex Find $f'(x)$ if $\\ds{f(x)=\\ln\\left|x\\sin x\\right|}$.\n\n\\underline{Solution}: We will compute $f'(x)$ using two \nmethods:\n\\begin{enumerate}\n\\item $\\ds{f'(x)=\\frac1{x\\sin x}\\!\\cdot\\frac{d}{dx}(x\\sin x)\n                =\\frac1{x\\sin x}\\left[x\\cdot\\frac{d\\sin x}{dx}\n                                       +\\sin x\\cdot\\frac{dx}{dx}\\right]\\!\n                =\\frac{x\\cos x+\\sin x}{x\\sin x}=\\cot x+\\frac1x}$.\n\\item Instead we first re-write $f(x)=\\ln|x|+\\ln|\\sin x|$, from which\n\n      $\\ds{f'(x)=\\frac1x+\\frac{1}{\\sin x}\\cdot\\frac{d}{dx}\\sin x\n                =\\frac1x+\\frac1{\\sin x}\\cdot\\cos x\n                =\\frac1x+\\cot x}$.\n\\end{enumerate}\nThe first method required a chain rule calling a product rule.\nThe second required logarithm identity and a simple chain rule.\nAs often occurs, algebraic re-writing of the function made \nthe calculus easier.\n\\label{ExampleOfLogDerivBefore/AfterRewriting}\\eex \n\n\n\n\\bex Find $\\ds{\\frac{d}{dx}\\ln\\left|\\sin^4x\\cos^6(x^2)\\right|}$.\n\n\\underline{Solution}: If we did not wish to use the algebraic\nproperties of logarithms first, we would need a chain rule,\ncalling a product rule, calling two chain rules,\none of those calling yet another chain rule.  It is certainly do-able, but\nnot desirable if it can be avoided.  Instead we will use\nthe algebraic properties to expand the function to make\nfor a simpler differentiation process.  Consider the following:\n\\begin{align*}\n\\frac{d}{dx}\\ln\\left|\\sin^4x\\cos^6(x^2)\\right|\n  &=\\frac{d}{dx}\n          \\left[\\,\\ln\\left|(\\sin x)\\right|^4\n               +\\ln\\left|(\\cos(x^2))\\right|^6\n                \\,\\right]\\\\\n  &=\\frac{d}{dx}\\left[\\vphantom{\\frac11}4\\ln|\\sin x|+6\\ln|\\cos (x^2)|\\right]\\\\\n  &=4\\cdot\\frac1{\\sin x}\\cdot\\frac{d\\,\\sin x}{dx}\n      +6\\cdot\\frac1{\\cos (x^2)}\\cdot\\frac{d\\,\\cos (x^2)}{dx}\\\\\n  &=\\frac{4\\cos x}{\\sin x}+\\frac6{\\cos(x^2)}\\cdot\\left(-\\sin (x^2)\\frac{d\\,x^2}\n                   {dx}\\right)\\\\\n  &=\\frac{4\\cos x}{\\sin x}+\\frac6{\\cos(x^2)}\\cdot(-\\sin (x^2)\\cdot2x)\\\\\n  &=4\\cot x-12x\\tan( x^2).\\end{align*}\nNote that the first two lines are algebraic in  nature. (Note also\nthat $\\cos(x^2)$ is not a product.)\n\\eex\n\n\nThe natural logarithm transforms products to sums, quotients to\ndifferences, and powers to multiplying factors.  \nEach of these transformations leaves us with simpler derivative\nrules.  With some practice, the expansion of the logarithm\nbecomes natural and quick (we will strive for\na single step!), after which the differentiation\nsteps are relatively easy.\n\n\\bex Compute $\\ds{\\frac{d}{dx}\\ln\\left|\\frac{x^3\\cos x}{\\sqrt{1+x^2}}\\right|}$.\n\n\\underline{Solution}: We will write all the steps in expanding the\nfunction, but it should become clearer with practice that\nthe final rewriting of the function can be anticipated from\nthe original form (see previous paragraph).  \nThe first three steps below show the algebraic\nexpansion, from which the calculus carries us to our final answer.\n\\begin{align*}\n\\frac{d}{dx}\\ln\\left|\\frac{x^3\\cos x}{\\sqrt{1+x^2}}\\right|\n  &=\\frac{d}{dx}\\left[\\ln|x^3\\cos x|-\\ln\\sqrt{1+x^2}\\right]\\\\\n  &=\\frac{d}{dx}\\left[\\ln|x|^3+\\ln|\\cos x|-\\ln(1+x^2)^{1/2}\\right]\\\\\n  &=\\frac{d}{dx}\\left[3\\ln|x|+\\ln|\\cos x|-\\frac12\\ln(1+x^2)\\right]\\\\\n  &=3\\cdot\\frac1x+\\frac1{\\cos x}\\cdot\\frac{d\\,\\cos x}{dx}\n                 -\\frac12\\cdot\\frac1{1+x^2}\\cdot\\frac{d}{dx}(x^2+1)\\\\\n  &=\\frac3x-\\frac{\\sin x}{\\cos x}-\\frac1{2(1+x^2)}\\cdot(2x)\\\\\n  &=\\frac3x-\\tan x-\\frac{x}{1+x^2}.\n\\end{align*}\nNote how we did not use absolute values in the $\\ln\\sqrt{x^2+1}$\nterm, since $x^2+1\\ge1>0$. \n\\eex\n\nIt is interesting to note how the absolute values inside\nof the logarithms``disappear''\nin the derivative step.  For that reason some texts\nwill skip them altogether, instead assuming that the quantity\ninside a logarithm is positive.  But to be careful, even if the\nargument of the $\\ln$ in the original did not have absolute\nvalues, they still belong everywhere they appear on the right sides\nin the above example, since it is possible that $x^3\\cos x>0$\nwhile the two factors are negative, making the subsequent logarithms\nundefined.  Note how the following are all correct uses of the\nabsolute values:\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}\\left[\\ln x^2\\right]=\\frac{d}{dx}[2\\ln|x|]=\\frac2x}$.\n Note $x^2\\ge0$, and $\\ln x^2$ is defined for all $x\\ne0$.  Also,\n $x^2=|x|^2$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\ln x^3\\right]=\\frac{d}{dx}[3\\ln x]=\\frac3x}$,\n but is undefined if $x<0$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\ln|x|^3\\right]=\\frac{d}{dx}[3\\ln|x|]=\\frac3x}$,\n defined for all $x\\ne0$.\n\\end{itemize}\n\n\n\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item For each of the following, compute the derivative\ntwo ways:\n\\begin{enumerate}[(i)]\n \\item by using \n       the derivative rules called by the original\n       form (see Example~\\ref{ExampleOfLogDerivBefore/AfterRewriting} on\n                   page \\pageref{ExampleOfLogDerivBefore/AfterRewriting});\n \\item by using properties of the natural logarithm to rewrite\n       the function and then compute the derivative.\n\\end{enumerate}\n   \\begin{enumerate}\n   \\item $\\ds{\\frac{d}{dx}\\ln x^4}$\n   \\item $\\ds{\\frac{d}{dx}\\ln x^5}$\n   \\item $\\ds{\\frac{d}{dx}\\ln\\left|x^5\\right|}$\n   \\item $\\ds{\\frac{d}{dx}\\ln\\left|\\frac1x\\right|}$\n   \\item $\\ds{\\frac{d}{dx}\\ln\\left|\\sqrt[3]{x}\\right|}$\n   \\item $\\ds{\\frac{d}{dx}\\ln e^x}$\n   \\item $\\ds{\\frac{d}{dx}\\ln e^{x^2}}$\n   \\end{enumerate}\n\\item Consider $\\ds{f(x)=e^{\\ln x}}$.  \n      Note that $f(x)=x$ (though its domain is restricted to $x>0$).\n      Find $f'(x)$ using the original (unsimplified)\n      form, and show that the form of the derivative \n      can be simplified to $f'(x)=1$ (as we should \n      expect).\n\\item Compute and simplify \n      the following derivatives (using (\\ref{DerivativeLn|U|}),\n      page \\pageref{DerivativeLn|U|}):\n   \\begin{enumerate}\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\sin x|}$\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\cos x|}$\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\tan x|}$ (do not re-write first)\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\cot x|}$ (do not re-write first)\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\sec x|}$ (it is interesting to both\n                                         use this form, and alternatively to\n                                         rewrite the function first)\n   \\item $\\ds{\\frac{d}{dx}\\ln|\\csc x|}$ (see previous comment)\n   \\end{enumerate}\n\\item Compute the following derivatives:\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}(\\ln x)^2}$\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\ln x}}$\n  \\item $\\ds{\\frac{d}{dx}\\sin(\\ln x)}$\n  \\item $\\ds{\\frac{d}{dx}\\tan(\\ln x)}$\n  \\item $\\ds{\\frac{d}{dx}\\sec(\\ln|x|)}$\n  \\item $\\ds{\\frac{d}{dx}\\sin^{-1}(\\ln x)}$\n  \\item $\\ds{\\frac{d}{dx}\\tan^{-1}(\\ln x)}$\n  \\item $\\ds{\\frac{d}{dx}\\sec^{-1}(\\ln x)}$\n  \\item $\\ds{\\frac{d}{dx}\\ln|\\ln x|}$\n  \\item $\\ds{\\frac{d}{dx}\\ln(\\ln(\\ln x))}$\n  \\end{enumerate}\n\\item Compute $f'(x)$ for each of the following by first rewriting $f(x)$\n       by expanding the logarithms.\n  \\begin{enumerate}\n  \\item $\\ds{f(x)=\\ln\\left|x^3(x^2+3x)^{20}\\right|}$\n  \\item $\\ds{f(x)=}$\n\n         $\\ds{\\ln\\left|(2x+9)^3(3x^2+5x)^9(2-7x)^{10}\n             \\right|}$\n  \\item $\\ds{f(x)=\\ln\\left|\\frac{9x-1}{2x+4}\\right|}$\n  \\item $\\ds{f(x)=\\ln\\left|\\frac{(3x+5)^7}{(7x^2+2)^5}\\right|}$\n  \\item $\\ds{f(x)=\\ln\\left|\\frac{x^2\\sin^3x}{\\cos^42x\\sqrt[3]{x^2-9}}\\right|}$\n  \\end{enumerate}\n\\item Compute and simplify the following derivatives (which cannot take\n      advantage of the properties of logarithms).\n    \\begin{enumerate}\n    \\item $\\ds{\\frac{d}{dx}(x\\ln x-x)}$\n    \\item $\\ds{\\frac{d}{dx}\\sin(\\ln|\\cos x|)}$\n    \\item $\\ds{\\frac{d}{dx}\\ln(x^2+1)}$. Why is $\\ln|x^2+1|$ the\n                                         same as $\\ln(x^2+1)$?\n\n    \\end{enumerate} \n\\item Show that $\\frac{d}{dx}\\ln|\\sec x+\\tan x|=\\sec x$.\n        (Use the simplest derivative strategy.  The key\n         is in the simplification of the derivative.)\n\\item Compute the following two derivatives, show that\n        they are the same, and \n        explain why we should have expected that result:\n        \\begin{align*}\n        &\\frac{d}{dx}\\ln|\\sec x|,\\\\\n        &\\frac{d}{dx}[-\\ln|\\cos x|\\,].\\end{align*} \n\\item For $f(x)=(g(x))^{h(x)}$, where $g(x)>0$ derive the\n       following formula for $f'(x)$:\n       \\begin{multline}\n          f'(x)=h(x)(g(x))^{h(x)-1}g'(x)\\\\\n           \\ +(g(x))^{h(x)}h'(x)\\ln(g(x)).\\label{AGenPower/ExpRule}\n       \\end{multline}\n       To do so, follow the following steps:\n      \\begin{enumerate}\n      \\item Use the idea that  $a=e^{\\ln a}$ (so what is $a^x$?)\n            to show  $$f(x)=e^{[\\ln(g(x))\\cdot h(x)]}.$$\n      \\item Find $f'(x)$ using this form.\n      \\item Simplify $f'(x)$ from the step above to achieve \n              (\\ref{AGenPower/ExpRule}).\n      \\end{enumerate}\n\\item Assume $h(x)=n$ is constant.  Then rewrite $f(x)=(g(x))^{h(x)}$\n     and use (\\ref{AGenPower/ExpRule})\n     to compute $f'(x)$  for this case.\n\\item Repeat the previous problem supposing\n       instead that $g(x)=a$ is a constant, and $h(x)$ is\n     allowed to vary.\n\\item Now we consider the rationale for not allowing $a=1$ to\n       be the base of a logarithm.  To do so, we consider\n       how we would attempt to develop a function $\\log_ax$.\n    \\begin{enumerate}\n    \\item First, recall how we found the graph of $y=\\ln x=\\log_ex$\n          based upon the graph of $y=e^x$.  Show what would\n          happen if we attempted to do this for $1$ instead of $e$\n          as the base.\n    \\item Separately, consider the definition of the logarithm\n          function, and decide what would be the domain of $\\log_1x$.\n    \\item Separately still, explain why (\\ref{ChangOfBaseWithLn})\n          would preclude $a=1$.\n\n    \\end{enumerate}\n\n\\end{enumerate}\n\\end{multicols}\n\\newpage\n\\section{The Natural Logarithm II: Further Results}\nIn this section we use the properties of the natural logarithm,\nand its relationship to exponential functions and other \nlogarithms, to pursue further differentiation problems.\nThe first technique we will develop is called\n{\\it logarithmic differentiation}, in which we \nactually introduce the natural logarithm into\nproblems which can benefit from its presence.  In later\nsubsections, we use change of base-type techniques to\nrewrite problems into forms for which we have formulas.\nIn doing so, some new and more general differentiation\nrules will emerge.\n\n\n\\subsection{Logarithmic Differentiation}\nBecause the natural logarithm takes products to sums, quotients to \ndifferences, and powers to multiplying factors, we have seen\nhow many derivative problems involving natural logarithms can\nbe much reduced in complexity.  By properly {\\it introducing} the natural\nlogarithm into differentiation problems, we can \nsometimes take difficult calculations and make them much\nsimpler.  The process has its own complications to add to the\nmix, but these are relatively minor compared to \nformer methods for most of these problems.\nWe begin with an example to illustrate the method.\n\n\\bex Find $f'(x)$ if $\\ds{f(x)=\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}}$.\n\n\\underline{Solution}: The technique below is similar\nto our implicit differentiation, except that first we\napply the function $\\ln|\\cdot|$ to both sides in the following sense:\n\\begin{align*}\nf(x)&=\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}\\\\\n\\implies\\qquad\\qquad \\ln|f(x)|&=\\ln\\left|\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}\\right|.\n\\end{align*}\nThe whole point of doing so is to be able to take advantage\nof the algebraic properties of logarithms (so that \nthe differentiation steps will be easier).\n\\begin{alignat*}{2}\n&\\iff&\\ln|f(x)|&=\\ln|x|+\\ln\\left|\\sin^3x\\right|-\\ln\\left|(x^2+1)^{1/2}\n               \\right|\\\\\n&\\iff\\qquad\\qquad&\n        \\ln|f(x)|&=\\ln|x|+3\\ln|\\sin x|-\\frac12\\ln|x^2+1|.\n\\end{alignat*}\nNow we differentiate, i.e., apply $\\frac{d}{dx}$ to both \nsides.  Note where we use $\\frac{d}{dx}\\ln|u|=\\frac1u\\cdot\\frac{du}{dx}$.\n\\begin{align*}\n&\\implies\\qquad\\qquad&\\frac{d}{dx}\\ln|f(x)|&=\n                       \\frac{d}{dx}\\left[\\ln|x|+\\ln|\\sin x|^3\n                       -\\frac12\\ln|x^2+1|\\right]\\\\\n&\\implies&\\frac1{f(x)}\\cdot\\frac{d\\,f(x)}{dx}&=\n                   \\frac1x+3\\cdot\\frac1{\\sin x}\\cdot\\frac{d\\,\\sin x}{dx}\n                   -\\frac12\\cdot\\frac1{x^2+1}\\cdot\\frac{d\\,(x^2+1)}{dx}\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=\\frac1x+\\frac{3\\cos x}{\\sin x}\n                   -\\frac{2x}{2(x^2+1)}\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=\\frac1x+3\\cot x-\\frac{x}{x^2+1}\n\\end{align*}\nWe wanted $f'(x)$, so we next multiply both sides by\n$f(x)$, which gives $f'(x)$ in terms of both $x$ and $f(x)$.\nWe then finish by substituting the original form for $f(x)$.\n$$f'(x)=f(x)\\left[\\frac1x+3\\cot x-\\frac{x}{x^2+1}\\right]\n=\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}\\left[\\frac1x+3\\cot x-\\frac{x}{x^2+1}\\right].$$\n\\eex \n\nWhile the process above did require several steps, those steps\nwere arguably simpler than those in our earlier methods,\nwhich would have called for  a quotient rule calling \none product rule and two chain rules.  Furthermore \nwith practice the process of logarithmic differentiation \ncan be streamlined to be much faster.  For instance, if we\ncan anticipate the final logarithmic expansion, and also use \nthe shortcut\n\\begin{equation}\n\\frac{d\\,\\ln|u(x)|}{dx}=\\frac{u'(x)}{u(x)},\\label{ShortcutForLogDiff}\n\\end{equation}\nparticularly when  $u'(x)$ is simple to compute,\nthen we can consolidate steps from the previous example.\n(For clarity, in fact the last step from before becomes\ntwo steps below.)\n\\begin{alignat*}{2}\n&&f(x)&=\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}\\\\\n&\\implies\\qquad\\qquad&\\ln|f(x)|&=\\ln|x|+3\\ln|\\sin x|-\\frac12\\ln|x^2+1|\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=\\frac1x+3\\cdot\\frac{\\cos x}{\\sin x}\n                              -\\frac12\\cdot\\frac{2x}{x^2+1}\\\\\n&\\implies&f'(x)&=f(x)\\left[\\frac1x+3\\cot x-\\frac{x}{x^2+1}\\right]\\\\\n&\\iff          &f'(x)&=\\frac{x\\sin^3 x}{\\sqrt{x^2+1}}\\left[\n                           \\frac1x+3\\cot x-\\frac{x}{x^2+1}\\right].\n\\end{alignat*}\nTo be sure, more steps can and arguably should be written when the\ntechnique is first learned, but it should appear true that\nthe abbreviated process above is much preferable to our earlier\ntechniques, and that such eventual efficiency is an achievable \ngoal.\n\nThe process of logarithmic differentiation does not\nreplace our earlier methods entirely.  Indeed, it is\nonly immediately useful for finding $f'(x)$ if $f(x)$\nis the type of function whose natural log (of its \nabsolute value to be more precise) can\nbe expanded in a useful way.  For instance, \nthe function above yielded nicely to the process because\nit consisted of powers of functions, combined through multiplication\nand division.  However, it would not be advantageous, for instance,\nto attempt logarithmic differentiation on a function such as\n$f(x)=\\sec x+\\tan x+9x^2-\\frac1x$, since this is a sum,\nand there is no algebraic expansion for the natural log of a \nsum.\\footnote{%%\n%%% FOOTNOTE\nOne could rewrite $f(x)=y_1+y_2+y_3+y_4$, for instance, and perform\nlogarithmic differentiation on each $y_i$ separately to find each\n$y_i'$, and thus have $f'(x)=y_1'+y_2'+y_3'+y_4'$, and \nindeed sometimes this is necessary.  For the example\nthis note refers to, that would certainly not decrease the\nwork required to find $f'(x)$.}\n%%% END FOOTNOTE\n\\hphantom{. }\n\nThe logarithmic differentiation process for finding $f'(x)$\nfor a given $f(x)$ is as follows:\n\\begin{enumerate}\n\\item Beginning with the equation which defines $f(x)$,\n      apply $\\ln|\\cdot|$ to both sides.\n\\item Expand the logarithm on the right-hand side (may be \n      consolidated into Step 1).\n\\item Apply $\\frac{d}{dx}$ to both sides.  the left-hand side\n      will be $\\frac{f'(x)}{f(x)}$.\n\\item Multiply the resulting equation by $f(x)$, thus\n      solving for $f'(x)$ in terms of $x$ and $f(x)$.\n\\item Substitute the original formula for $f(x)$ on the \n      right-hand side (may be consolidated into Step 4).\n\\end{enumerate}\n\nWe will see that there are other times where \napplying $\\ln|\\cdot|$ to both sides before differentiation \nis advantageous besides just for finding certain\nderivatives $f'(x)$, but for now another example of this\nfirst type is called for.\n\n\\bex Find $f'(x)$ if $\\ds{f(x)=\\frac{5\\sin2x\\cos^34x}{\\sqrt[3]{1+\\tan6x}}}$.\n\n\\underline{Solution}: We proceed as before, this time being\nmore verbose in our chain rule computations.\n\\begin{alignat*}{2}\n&&f(x)&=\\frac{5\\sin2x\\cos^34x}{\\sqrt[3]{1+\\tan6x}}\\\\\n&\\implies\\qquad\\qquad\n  &\\ln|f(x)|&=\\ln\\left|\\frac{5\\sin2x\\cos^34x}{(1+\\tan6x)^{1/3}}\\right|\\\\\n&\\implies\n  &\\ln|f(x)|&=\\ln|5|+\\ln|\\sin2x|+3\\ln|\\cos 4x|-\\frac13\\ln|1+\\tan6x|\\\\\n&\\implies&\\frac{d}{dx}\\ln|f(x)|&=\\frac{d}{dx}\\left[\n            \\ln|5|+\\ln|\\sin2x|+3\\ln|\\cos 4x|-\\frac13\\ln|1+\\tan6x|\\right]\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=0+\\frac1{\\sin2x}\\cdot\\frac{d\\,\\sin2x}{dx}\n            +3\\cdot\\frac{1}{\\cos4x}\\cdot\\frac{d\\,\\cos4x}{dx}\\\\\n            &&&\\qquad-\\frac13\\cdot\\frac1{1+\\tan6x}\\cdot\\frac{d(1+\\tan6x)}{dx}\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=\\frac1{\\sin2x}\\cdot\\cos2x\\cdot\n          \\frac{d\\,2x}{dx}+\n            3\\cdot\\frac1{\\cos 4x}\\cdot(-\\sin4x)\\cdot\\frac{d\\,4x}{dx}\\\\\n       &&&\\qquad    -\\frac13\\cdot\\frac1{1+\\tan6x}\\cdot\n            \\left(0+\\sec^26x\\cdot\\frac{d\\,6x}{dx}\\right)\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=2\\cot2x+3\\tan4x\\cdot(-4)\n                  -\\frac{6\\sec^26x}{3(1+\\tan6x)}\\\\\n&\\implies&f'(x)&=f(x)\\left[2\\cot2x-12\\tan4x-\\frac{2\\sec^26x}{1+\\tan6x}\\right]\\\\\n&\\implies&f'(x)&=\\frac{5\\sin2x\\cos^34x}{\\sqrt[3]{1+\\tan6x}}\n      \\left[2\\cot2x-12\\tan4x-\\frac{2\\sec^26x}{1+\\tan6x}\\right].\n\\end{alignat*}\n\n\\eex\n\nA few more notes about the process are in order.\n\\begin{enumerate}[(i)]\n\\item The absolute values introduced with the natural \n      logarithm vanish in the derivative step.  For this\n      reason some textbooks do not include them, but\n      technically they should be included.  One nice\n      feature of the process is that the correct answer\n      can be found even when absolute values are (naively?) omitted.\n\\item The answer this process delivers is of a different\n      form than our earlier methods, but they are algebraically\n      the same, {\\bf except} that the answer here may need to\n      be expanded and simplified to be, technically, completely \n      correct.  For instance, if $\\cos4x=0$\n      this answer appears undefined because of the $\\tan4x$ \n      term, though $\\cos4x=0$ does not necessarily \n      break the differentiability.  When we distribute\n      the $f(x)$ factor across the brackets in our final answer, \n      a factor of $\\cos4x$ will cancel the denominator\n      in the $\\tan4x$ term.  Algebraically that is not\n      correct if $\\cos4x=0$, but in fact the naively\n      simplified form---with the $\\cos4x$ term (as well\n      as the $\\sin 2x$ in the $f(x)$ and $\\cot2x$ terms) \n      canceled---ultimately \n      gives the correct derivative $f'(x)$.\n\\item Related to the previous item, note that we cannot technically\n      compute $\\ln|f(x)|$ wherever $f(x)=0$ (such as when\n      $\\sin2x=0$ or $\\cos4x=0$), but this too\n      gets glossed over in the differentiation process,\n      especially in the final answer if $f(x)$ is distributed\n      across the brackets, and the offending terms canceled.\n\\end{enumerate}\nThus in some ways logarithmic differentiation is better than\nexpected, in that even when certain things technically\nshould be going wrong in the process (such as being outside\nthe domain of the natural logarithm), in the end---at least\nin the simplified answer---we get the correct result.\n\nLogarithmic differentiation gives a nice proof of \nthe generalized product rule:\\footnote{%%%\n%%%% FOOTNOTE\nSee notes on the roles of the various factors in the \nproduct rule, page \\pageref{NotesOnProductRule}.\nComments there generalize to more general products.\n%%%% END FOOTNOTE\n}\n\\begin{theorem}For $f(x)=g_1(x)g_2(x)g_3(x)\\cdots g_n(x)$, we have\n\\begin{multline}\nf'(x)=[g_1'(x)g_2(x)g_3(x)\\cdots g_n(x)] \\ + \\ \n         [g_1(x)g_2'(x)g_3(x)\\cdots g_n(x)]\\  +\\ \n        \\\\ +\\ [g_1(x)g_2(x)g_3'(x)\\cdots g_n(x)] \\ + \\cdots\n        \\ + \\ [g_1 (x)g_2(x)g_3(x)\\cdots g_n'(x)].\\end{multline}\n\\end{theorem}\nA proof in the case $f(x)=g_1(x)g_2(x)g_3(x)$ shows the \npattern of argument for the general case.\n\\begin{alignat*}{2}\n&&f(x)&=g_1(x)g_2(x)g_3(x)\\\\\n&\\implies\\qquad\\qquad&\\ln|f(x)|&=\\ln|g_1(x)g_2(x)g_3(x)|\\\\\n&\\iff\\qquad\\qquad&\\ln|f(x)|&=\\ln|g_1(x)|+\\ln|g_2(x)|+\\ln|g_3(x)|\\\\\n&\\implies&\\frac{d}{dx}[\\ln|f(x)|]&=\\frac{d}{dx}\\left[\n              \\ln|g_1(x)|+\\ln|g_2(x)|+\\ln|g_3(x)|\\right]\\\\\n&\\implies&\\frac{f'(x)}{f(x)}&=\\frac{g_1'(x)}{g_1(x)}+\n                               \\frac{g_2'(x)}{g_2(x)}+\n                               \\frac{g_3'(x)}{g_3(x)}\\\\\n&\\implies&f'(x)&=f(x)\\left[\\frac{g_1'(x)}{g_1(x)}+\\frac{g_2'(x)}{g_2(x)}+\n                             \\frac{g_3'(x)}{g_3(x)}\\right]\\\\\n&\\implies&f'(x)&=g_1(x)g_2(x)g_3(x)\n                    \\left[\\frac{g_1'(x)}{g_1(x)}+\\frac{g_2'(x)}{g_2(x)}+\n                             \\frac{g_3'(x)}{g_3(x)}\\right]\\\\\n&\\implies&f'(x)&=g_1'(x)g_2(x)g_3(x)+g_1(x)g_2'(x)g_3(x)\n                   +g_1(x)g_2(x)g_3'(x),\\text{ q.e.d.}\n\\end{alignat*}\n\\bex Thus we can perform the following quickly, this time in primed notation.\n\\begin{align*}\n\\frac{d}{dx}(x^3e^x\\sin x)\n    &=(x^3)'e^x\\sin x+x^3(e^x)'\\sin x+x^3e^x(\\sin x)'\\\\\n    &=3x^2e^x\\sin x+x^3e^x\\sin x+x^3e^x\\cos x.\\\\\n    &=x^2e^x(3\\sin x+x\\sin x+x\\cos x)\\end{align*}\n\\eex\nIf such a product is more complicated, we should revert to \nLeibniz notation:\n$$\\frac{d}{dx}(f(x)g(x)h(x))\n=f(x)g(x)\\cdot\\frac{d\\,h(x)}{dx}\n  +f(x)h(x)\\cdot\\frac{d\\,g(x)}{dx}\n  +g(x)h(x)\\cdot\\frac{d\\,f(x)}{dx}$$\nWith more complicated $f$, $g$ or $h$, this has the advantage\nthat the derivative computations are the rightmost factors\nin each term, so keeping them separate from the other terms,\nand expanding as we call up the various rules, is more\nconvenient.  To take full advantage of the Leibniz style, we \ntherefore have to write the terms of a generalized\nproduct rule in a different order than given in the theorem\nabove.  \n\n\n\\bex\nLater in the text we will often be computing derivatives with\nrespect to time $t$, though that variable might not explicitly\nappear in the problem.  Still it will make sense to apply\n$\\frac{d}{dt}$ to quantities which do, in fact, depend upon\ntime $t$.  So for instance there is the formula from\nchemistry that $PV=k\\cdot T$, where $k$ is a constant,\nand we have an {\\it ideal gas} with some fixed number of \nparticles.  In a mathematically sophisticated advanced\nchemistry text or article, it is not unusual to see\na computation like\n$$PV=k\\cdot T\\implies\n\\frac1P\\cdot\\frac{dP}{dt}+\\frac1V\\cdot\\frac{dV}{dt}\n=\\frac{1}T\\cdot\\frac{dT}{dt}.$$\nWithout logarithmic differentiation this might seem rather\nmysterious.  However, one well versed in the technique would\nlikely see the truth of this implication quickly, being\npracticed in the middle steps:\n\\begin{alignat*}{2}\nPV=k\\cdot T&\\implies\n&\\ln(PV)&=\\ln(kT)\\\\\n&\\implies&\\ln P+\\ln V&=\\ln k+\\ln T\\\\\n&\\implies&\\frac{d}{dt}\\left[\\ln P+\\ln V\\right]&=\\frac{d}{dt}\n                      \\left[\\ln k+\\ln T\\right]\\\\\n&\\implies&\\frac1P\\cdot\\frac{dP}{dt}+\n          \\frac1V\\cdot\\frac{dV}{dt}&=0+\\frac1T\\cdot\\frac{dT}{dt},\n\\qquad\\text{ q.e.d.}\n\\end{alignat*}\n\\label{FirstAppearanceOfPV=kT}\nWe would have a different equation involving these functions\n(of $t$) $P,V,T$ if we simply applied $\\frac{d}{dt}$ to both sides\nrather than first applying the natural logarithm function.  If we\nchose that strategy we would require the product rule on the left\nside.  In fact the equations we get with either method are\nequivalent under the original assumption, that $PV=k\\cdot T$.\nTo show the two equations involving the derivatives  in fact say\nthe same thing is an exercise in algebra.\n\nNote also that we normally apply $\\ln|\\cdot|$ to both sides\nwhen intending to perform logarithmic differentiation, but here we\ncould just apply $\\ln(\\cdot)$ because the quantities involved are never\nnegative.\n\\eex\n\nRecalling that powers become multiplying factors, another quick\nexample, this time from basic electricity, would be\n\\begin{alignat*}{2}\nP=\\frac{E^2}{R}&\\implies&\\ln P&=2\\ln E-\\ln R\\\\\n&\\implies&\\frac1P\\cdot\\frac{dP}{dt}\n=\\frac2{E}\\cdot\\frac{dE}{dt}-\\frac1R\\cdot\\frac{dR}{dt}.\\end{alignat*}\nWith practice one is quite likely to be confident enough to\nskip the middle step.\n\n\\subsection{Bases Other Than $e$: Logarithms}\nIn this subsection we look at derivatives of \nfunctions $\\log_ax$ for more general $a$.\nThis is a simple application of our\nchange of base formula (\\ref{ChangeOfBase}),\npage \\pageref{ChangeOfBase} (note that\n$\\frac1{\\ln a}$ is a constant):\n$$\\frac{d}{dx}\\log_ax=\\frac{d}{dx}\\left[\\frac{\\ln x}{\\ln a}\n  \\right] =\\frac{d}{dx}\\left[\\frac1{\\ln a}\\cdot\\ln x\\right]\n=\\frac1{\\ln a}\\cdot\\frac1x=\\frac1{x\\ln a}.$$\nWe can also perform the computation above with $|x|$\nreplacing $x$, and the same argument which worked\nwith $\\frac{d}{dx}\\ln |x|=\\frac1x$ will work here.\nIn fact, since this function $\\log_ax$ is just a constant\nmultiple of $\\ln x$, all the rules we had for $\\ln x$\nwork here, with the constant carrying through.\nThus the absolute value and chain rule versions are just\n\\begin{align}\n\\frac{d}{dx}\\log_a|x|&=\\frac{d}{dx}\\left[\\frac1{\\ln a}\n             \\ln|x|\\right]=\\frac1{x\\ln a},\\label{DerivLog_a}\\\\\n\\frac{d}{dx}\\log_a|u|&=\\frac{d}{dx}\\left[\\frac1{\\ln a}\n             \\ln|u|\\right]=\\frac1{u\\ln a}\\cdot\\frac{du}{dx}.\n              \\label{DerivLog_aU}\n\\end{align}\n\\bex Consider the following derivative computations:\n\\begin{itemize}\n\\item $\\ds{\\frac{d}{dx}\\log_{10}x=\\frac1{x\\ln10}}$.\n\\item $\\ds{\\frac{d}{dx}\\log_2\\left|x\\sqrt{x^2+1}\\right|\n           =\\frac{d}{dx}\\left[\\log_2|x|\n         +\\frac12\\log_2(x^2+1)\\right]\n         =\\frac1{x\\ln2}+\\frac1{(x^2+1)\\ln2}\n           \\cdot\\frac{d}{dx}(x^2+1)}$\n\n      $\\ds{=\\frac1{x\\ln2}+\\frac{2x}{(x^2+1)\\ln2}}$.\n\\item $\\ds{\\frac{d}{dx}\\log_3\\left|\\frac{\\sin x}{2x+5}\\right|\n        =\\frac{d}{dx}\\left[\\log_3|\\sin x|\n          -\\log_3|2x+5|\\vphantom{X_X^X}\\right]}$\n\n       $\\ds{    =\\frac1{\\sin x\\ln3}\\cdot\\frac{d\\,\\sin x}{dx}\n     -\\frac1{(2x+5)\\ln3}\\cdot\\frac{d(2x+5)}{dx}\n     =\\frac{\\cos x}{\\sin x\\ln3}-\\frac{2}{(2x+5)\\ln3}}.$\n\\item $\\ds{\\frac{d}{dx}\\log_3(\\log_5x)\n     =\\frac{1}{\\log_5x\\ln3}\\cdot\\frac{d\\log_5x}{dx}\n     =\\frac1{\\log_5x\\ln3}\\cdot\\frac1{x\\ln5}\n     =\\frac1{\\frac{\\ln x}{\\ln 5}\\ln 3\\cdot x\\ln 5}\n     =\\frac1{x\\ln x\\ln3}}$\n\n\\end{itemize}\nIn fact, we can cut short the {\\rm calculus} steps using algebraic\nproperties of logarithms first:\n$$\\frac{d}{dx}\\log_3(\\log_5x)\n =\\frac{d}{dx}\\log_3\\left[\\frac{\\ln x}{\\ln 5}\\right]\n =\\frac{d}{dx}\\left[\\log_3(\\ln x)-\\log_3(\\ln 5)\\right]\n =\\frac1{\\ln x\\ln3}\\frac{d\\ln x}{dx}-0\n =\\frac1{\\ln x\\ln 3\\cdot x}.$$\n\n\\eex\n\n\\subsection{Bases other than $e$: Exponential Functions}\nHere we look at derivatives of exponential functions $a^x$ ($a>0$) and\nfunctions involving these.  \nTwo computations of the derivative of $a^x$ are offered.\nBoth illustrate useful techniques which are worth remembering.\nThe first technique is logarithmic differentiation.  We find $\\frac{dy}{dx}$\nunder the assumption $y=a^x$. Note that $y>0$ so no absolute values are\nneeded.\n\\begin{alignat*}{2}\n&&y&=a^x\\\\\n&\\implies& \\ln y&=\\ln a^x\\\\\n&\\iff &\\ln y&=x\\ln a\\\\\n&\\implies& \\frac{d\\,\\ln y}{dx}&=\\frac{d\\,[(\\ln a)x]}{dx}\\\\\n&\\implies&\\frac1y\\cdot\\frac{dy}{dx}&=\\ln a\\\\\n&\\implies&\\frac{dy}{dx}&=y\\ln a\\\\\n&\\iff &\\frac{dy}{dx}&=a^x\\ln a.\\end{alignat*}\nNext we instead use the fact that $a=e^{\\ln a}$, and compute\n$\\frac{d}{dx}\\left[a^x\\right]$ using the chain rule.  Note that\n$a^x=\\left[e^{\\ln a}\\right]^x=e^{(\\ln a)x}$.\n$$\\frac{d}{dx}a^x=\\frac{d}{dx}\\left[e^{\\ln a}\\right]^x\n               =\\frac{d}{dx}e^{(\\ln a)x}\n               =e^{(\\ln a)x}\\cdot\\frac{d[(\\ln a)x]}{dx}\n               =\\left[e^{\\ln a}\\right]^x\\cdot\\ln a\n               =a^x\\ln a.$$\nFrom either method, we get the derivative of $a^x$, and\nits chain rule version:\n\\begin{align}\n\\frac{d\\,a^x}{dx}&=a^x\\ln a,\\label{DerivOfA^X}\\\\\n\\frac{d\\,a^u}{dx}&=a^u\\ln a\\cdot\\frac{du}{dx}.\\label{DerivOfA^U}\n\\end{align}\nNote that if $a=e$, we have $\\ln a=\\ln e=1$, giving us \n$\\frac{d}{dx}e^x=e^x\\ln e=e^x\\cdot1=e^x$ as before.\n\n\nWe proved (\\ref{DerivOfA^X}), from which (\\ref{DerivOfA^U}) follows.\nWhile the first technique was the (now) familiar logarithmic differentiation,\nthe second was to change the base, rewriting\n$a^x=(e^{\\ln a})^x=e^{(\\ln a)x}$.  This can be exploited in other\nvenues, but in particular it allows one to use the simpler and\nubiquitous derivative formula for $e^x$ by an {\\it algebraic}\nrewriting, rather than relying upon the more obscure (but not\nunimportant) formula (\\ref{DerivOfA^X}).\n       \n\\bex We can now compute the following derivatives using (\\ref{DerivOfA^X})\nand (\\ref{DerivOfA^U}):\n\\begin{itemize}\n\\item $\\ds{\\frac{d\\,2^x}{dx}=2^x\\ln2}$.\n\\item $\\ds{\\frac{d}{dx}3^{5x}=3^{5x}\\ln 3\\cdot\\frac{d}{dx}\\left[5x\\right]\n           =3^{5x}\\ln3\\cdot 5=5(\\ln 3)3^{5x}}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\sin10^x\\right]=\\cos10^x\\cdot\\frac{d}{dx}\n           \\left[10^x\\right]=\\cos10^x\\cdot 10^x\\ln10=10^x\\ln10\\cos10^x}$.\n\\item $\\ds{\\frac{d}{dx}\\left[x^210^x\\right]=x^2\\cdot\\frac{d}{dx}\n           \\left[10^x\\right]+10^x\\cdot\\frac{d}{dx}\\left[x^2\\right]\n           =x^2\\cdot10^x\\ln10+10^x\\cdot2x}$.\n\n          \\qquad\\qquad\\quad\\ $\\ds{=x\\cdot10^x\\left[x\\ln10+2\\right]}$.\n\\item $\\ds{\\frac{d}{dx}\\left[2^{3^x}\\right]\n  =2^{3^x}\\ln2\\cdot\\frac{d}{dx}\\left[3^x\\right]\n  =2^{3^x}\\ln2\\cdot3^x\\ln3=2^{3^x}3^x\\ln2\\ln3}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\tan^{-1}2^x\\right]\n          =\\frac1{\\left(2^x\\right)^2+1}\\cdot\\frac{d}{dx}\\left[2^x\\right]\n          =\\frac1{4^x+1}\\cdot2^x\\ln2=\\frac{2^x\\ln2}{4^x+1}}$.\n\\item $\\ds{\\frac{d}{dx}\\left[2^{\\tan^{-1}x}\\right]\n          =2^{\\tan^{-1}x}\\ln2\\cdot\\frac{d}{dx}\\left[\\tan^{-1}x\\right]\n          =2^{\\tan^{-1}x}\\ln2\\cdot\\frac1{x^2+1}\n          =\\frac{2^{\\tan^{-1}x}\\ln2}{x^2+1}}$.\n\\item $\\ds{\\frac{d}{dx}\\left[\\ln10^x\\right]=\\frac{1}{10^x}\\cdot\n          \\frac{d}{dx}\\left[10^x\\right]\n          =\\frac1{10^x}\\cdot10^x\\ln10=\\ln10}$.\n\nNote that an alternative, arguably superior strategy would be to first \nre-write the function:\n\n$\\ds{\\frac{d}{dx}\\left[\\ln 10^x\\right]=\\frac{d}{dx}\\left[x\\ln10\\right]=\\ln10}$,\nfollowing from the usual power rule with a constant multiple $\\ln10$\ncarrying through the computation.\n\\end{itemize}\n\n\\eex\nWhile the last derivative above allowed us to first use the \nrules of logarithms and exponents, it should be pointed out that \nthere are not useful rewritings for every possible case.  In fact that last\nderivative computation was the only one above for which there\nwas a useful way to algebraically rewrite the problem.  \nNow it happens that most\nof those above would be fine candidates for logarithmic differentiation\nif we wanted to avoid the formulas for derivatives of \nexponential functions in bases other than $e$, namely \n(\\ref{DerivOfA^X}) and (\\ref{DerivOfA^U}).  Indeed\nonly the arctangent example\nabove could not be computed directly with logarithmic differentiation.\nHowever, using our formulas for $\\frac{d\\,a^x}{dx}$ and $\\frac{d\\,a^u}{du}$\nwill get us our results much more expeditiously.\n\n\\subsection{Derivative of $(f(x))^{g(x)}$}\n\nSo far we have two derivative rules for functions which can loosely\nbe defined as powers:\n\\begin{alignat*}{2}\n\\frac{d}{dx}\\left[x^n\\right]&=n\\cdot x^{n-1},&\\qquad n&\\in\\Re,\\\\\n\\frac{d}{dx}\\left[a^x\\right]&=a^x\\ln a,&\\qquad a&\\ge0.\\end{alignat*}\nCrucially, in each of those cases either the base or the exponent is fixed,\ni.e., constant.\nFurthermore, we should expect very different\nderivative formulas for these since\nthe functions behave very differently.\nFor instance, if $n\\in\\{1,2,3,\\cdots\\}$, that function $x^n$\nhas {\\it polynomial growth}, while if $a>1$ the function $a^x$ has\n{\\it exponential growth}, which is eventually\nmuch faster.  There were other cases,\nbut for the moment let us consider these.  So for instance\n$x^2$ grows without bound,\nbut $2^x$ grows even faster, though we will have to wait for\nanother chapter to actually prove this fact.  Consider then\na function like $x^x$ in which the base grows without bound, and so\ndoes the exponent.  Here these two growth conspire\nin such a way that this new function will grow much faster than\neither $x^2$ or $2^x$.  This is not difficult to believe, for suppose\n$x=100$.  Then\n$$\\underbrace{100^2}_{=10,000}\n<<\\underbrace{2^{100}}_{\\approx1.26\\times10^{30}}\n<<\\underbrace{100^{100}}_{=10^{1000}}.$$\nHere the notation ``$<<$'' means ``much less than,'' and as such is\nusually used subjectively, in much the same way that ``$\\approx$''\nis also subjective.  It is used here for emphasis.  The numerical\nresults above give just a small glimpse of the relative growth rates of these\nthree functions, $x^2$, $2^x$ and $x^x$.\\footnote{%\n%%% FOOTNOTE\nNote that $x^x$ is only continuous for $x>0$.  That is because, while\nit is defined for many negative numbers, it is undefined for many more.\nFor instance, $(-3)^{-3}$ and $(-1)^{-1}$ make sense, but $(-1/2)^{-1/2}$\nand $(-\\pi)^{-\\pi}$ do not.  Nor does $0^0$, unless we care to {\\it define}\nit to be some number.  In fact many algebra books do define it to be $1$,\nbut we will see in the next chapter that there are other choices which \nmake equal sense, so we will decline to define $0^0$.\n\nOne way to define $x^x$ and see that it is continuous for\n$x>9$ is to rewrite this function\nas $x^x=\\left(e^{\\ln x}\\right)^x=e^{(\\ln x)x}$.  In this last form\nwe see that the only thing that can ``break'' the continuity\nis for $x$ to be nonpositive.  We will use that \nkind of technique for rewriting such a function\non occasion in what follows, and indeed used it\nbefore in one computation of $\\frac{d\\,a^x}{dx}$.\n%%% END FOOTNOTE\n} \n\nNow we are interested in computing derivatives of functions in which\nthere is a base and an exponent, but both are allowed to vary.\nThe usual method is logarithmic differentiation, but a formula\nis possible, and it carries some interesting intuition.  In fact\ntypes of problems are often taught only as logarithmic differentiation\nproblems, so the reader should be both aware of that and able to \ncompute these through logarithmic differentiation, but the formula\nwe will derive is also worth knowing.\\footnote{%%\n%%% FOOTNOTE\nOne could in fact use logarithmic differentiation to \nderive the power rule, product rule, or quotient rule,\nas we will see in the exercises.  However, we do not abandon\nthese rules since they are convenient, efficient, and \ncan be easily implemented when called by other rules, while\nlogarithmic differentiation requires whole sides of equations\nto be products, quotients, or powers, not for instance sums,\ndifferences, or other combinations which can not have their\nlogarithms expanded.  Consider attempting, for instance,\nlogarithmic differentiation on the problem of finding $\\frac{dy}{dx}$\nif \n$$y=\\sin\\left(x^2+1\\right)+\\tan^{-1}x-\\cos e^x+\\sec x\\tan x.$$\nThis would be a somewhat long but\nfairly simple problem using the older rules, but\nlogarithmic differentiation would be useless here, except\npossibly for computing the derivative of the last,\n$\\sec x\\tan x$ term as a separate\nproblem.  Even for that term, while we {\\it could} use logarithmic\ndifferentiation, a more efficient method would be to simply use\nthe product rule.\n%%% END FOOTNOTE\n}\n\n\\bex  Find $\\frac{d}{dx}\\left[x^{\\sin x}\\right]$.\n\n\\underline{Solution}:  For convenience we \n(equivalently) find $\\frac{dy}{dx}$ where $y=x^{\\sin x}$.\n\\begin{alignat*}{2}\ny=x^{\\sin x}&\\iff &\\ln y&=\\ln\\left[x^{\\sin x}\\right]\\\\\n           &\\iff& \\ln y&=\\sin x\\cdot\\ln x\\\\\n           &\\implies&\\frac{d\\,\\ln x}{dx}&\n                  =\\frac{d}{dx}\\left[\\sin x\\cdot\\ln x\\right]\\\\\n           &\\implies&\\frac1y\\cdot\\frac{dy}{dx}&\n                  =\\sin x\\cdot\\frac{d\\,\\ln x}{dx}\n               +\\ln x\\cdot\\frac{d\\,\\sin x}{dx}\\\\\n           &\\implies&\\frac1y\\cdot\\frac{dy}{dx}\n             &=\\frac{\\sin x}x+\\ln x\\cos x\\\\\n           &\\iff&\\frac{dy}{dx}&=\n            y\\left[\\frac{\\sin x}x+\\ln x\\cos x\\right]\n            =x^{\\sin x}\\left[\\frac{\\sin x}x+\\ln x\\cos x\\right].\n\\end{alignat*}\n\n\\eex\nIt is very interesting to note here that the derivative simplifies\nto\n\\begin{align*}\n\\frac{dy}{dx}&=\\frac{\\sin x\\cdot x^{\\sin x}}{x}+x^{\\sin x}\\ln x\\cdot\\cos x\\\\\n             &=(\\sin x)x^{\\sin x-1}+x^{\\sin x}\\ln x\\cdot\\frac{d\\sin x}{dx}.\n\\end{align*}\nIn the sum above, the first term is what we would have if we\nassumed naively that the $\\sin x$ exponent were a constant and\nwe used the power rule $\\frac{d}{dx}\\left[x^n\\right]=n\\cdot x^{n-1}$\nwith $n=sin x$.  The second term is what we would have if\nwe assumed naively that instead the base $x$ were a constant,\nand we used the formula for the derivative of an exponential\nfunction $\\frac{d}{dx}\\left[a^u\\right]=a^u\\ln a\\cdot\\frac{du}{dx}$.\nSo it appears that the change we measure by applying $\\frac{d}{dx}$\nhas two components, the first assuming that the exponent is constant\nand measuring that part of the change we get from the base changing,\nand the second assuming the base is constant and measuring the change\nwe get from the exponent changing.  This is very much akin\nto our earlier interpretation of the product rule\n(See again the notes on the roles of the various factors in the \nproduct rule, page \\pageref{NotesOnProductRule}.)  This gives us\na general formula, which is slightly more complicated than one might\nanticipate from the above example because of a chain rule involved\nin computing the component from the change in the base:\n\\begin{equation}\n\\frac{d}{dx}\\left[(f(x))^{g(x)}\\right]\n   =g(x)\\cdot[f(x)]^{g(x)-1}\\cdot\\frac{d}{dx}[f(x)]\n    \\ +\\ (f(x))^{g(x)}\\ln f(x)\\cdot\\frac{d}{dx}[g(x)].\n\\label{FuctionRaisedToAFunction}\\end{equation}\nAgain, the first term is computed as though the exponent were\nconstant and the power rule employed, while the second term \nis computed as though the base were constant and the exponential\nrule used.  In both cases, chain rule versions were necessary\nto be most general.\n\nTwo possible proofs come to mind.  One is to rewrite the original\nfunction with a constant base, so that\n$$(f(x))^{g(x)}=\\left[e^{\\ln f(x)}\\right]^{g(x)}\n   =e^{(\\ln f(x))(g(x))},$$\nand use the chain rule, with a product rule inside, finally rewriting\nthe result with the original base.\n\nMore in the spirit of how these problems are usually presented is a\nproof using logarithmic differentiation.  Below we consolidate\nsome of the steps.  Note that we assume $f(x)>0$ for continuity's sake.\n\\begin{alignat*}{2}\ny=(f(x))^{g(x)}&\\implies&\\ln y&=g(x)\\ln f(x)\\\\\n &\\implies&\\frac{1}{y}\\cdot\\frac{dy}{dx}\n  &=g(x)\\cdot\\frac{d\\,\\ln f(x)}{dx}+\\ln f(x)\\cdot\\frac{d\\,g(x)}{dx}\\\\\n &\\implies&\\frac{1}{y}\\cdot\\frac{dy}{dx}\n  &=g(x)\\cdot\\frac{1}{f(x)}\\cdot\\frac{d\\,f(x)}{dx}\n     +\\ln f(x)\\cdot\\frac{d\\,g(x)}{dx}\\\\\n &\\implies&\\frac{dy}{dx}&=y\\left[g(x)\\cdot\\frac{1}{f(x)}\\cdot\\frac{d\\,f(x)}{dx}\n     +\\ln f(x)\\cdot\\frac{d\\,g(x)}{dx}\\right]\\\\\n &\\implies&\\frac{dy}{dx}&=(f(x))^{g(x)}\n \\left[g(x)\\cdot\\frac{1}{f(x)}\\cdot\\frac{d\\,f(x)}{dx}\n     +\\ln f(x)\\cdot\\frac{d\\,g(x)}{dx}\\right]\\\\\n &\\implies&\\frac{dy}{dx}&=\n  g(x)\\cdot[f(x)]^{g(x)-1}\\cdot\\frac{d}{dx}[f(x)]\n    \\ +\\ (f(x))^{g(x)}\\ln f(x)\\cdot\\frac{d}{dx}[g(x)],\n\\end{alignat*}\nq.e.d.  While the formula above is rather long, it is easy enough\nto memorize if it is remembered in spirit:  again, the\nfirst term treats $g(x)$ as a constant, and the second treats\n$f(x)$ as a constant.  Still, it is predictable that many\nstudents would feel more comfortable either using logarithmic\ndifferentiation, or the change of base (to $e$) strategy.\n\nIt is interesting to note that this new derivative formula\nin fact generalizes the power and exponential rules.\n\\begin{enumerate}\n\\item If $g(x)$ is constant, so $\\frac{d}{dx}[g(x)]=0$, then\nwe get the power rule, in its chain rule version.\n\\item If $f(x)$ is constant, so $\\frac{d}{dx}[f(x)]=0$, then\nwe get the exponential rule, in its chain rule version.\n\\end{enumerate}\n\nBut for now we need to consider more examples.\n\n\\bex Find $\\ds{\\frac{d}{dx}\\left[(\\ln x)^x\\right]}$.\n\n\\underline{Solution}: While we can use logarithmic differentiation\nhere, we will use our general formula, first treating the \nexponent $x$ as constant, and then the base $\\ln x$ as constant.\n\\begin{align*}\n\\frac{d}{dx}\\left[(\\ln x)^x\\right]\n &=x(\\ln x)^{x-1}\\frac{d}{dx}\\ln x+(\\ln x)^x(\\ln(\\ln x))\\cdot\\frac{d}{dx}[x]\\\\\n &=x(\\ln x)^{x-1}\\cdot\\frac1x+(\\ln x)^x(\\ln(\\ln x))\\cdot1\\\\\n &=(\\ln x)^{x-1}+(\\ln x)^x\\ln(\\ln x).\\footnotemark\n\\end{align*}\n\\eex\n\\footnotetext{%\n%%% FOOTNOTE\nIn most mathematical literature, the short-hand for\n$\\ln(\\ln x)$ is simply $\\ln\\ln x$.  It is not uncommon to see\nsuch things as $\\ln\\ln\\ln x\\ln \\ln x$, meaning\n$[\\ln(\\ln(\\ln x))][\\ln(\\ln x)]$, for instance.\n%%% END FOOTNOTE\n}\n\\bex Compute $\\ds{\\frac{d}{dx}\\left[x^{e^x}\\right]}$.\n\n\\underline{Solution}:\n\\begin{align*}\n\\frac{d}{dx}\\left[x^{e^x}\\right]\n&=e^x[x]^{e^x-1}\\frac{dx}{dx}+x^{e^x}\\ln x\\frac{d\\,e^x}{dx}\\\\\n&=e^x[x]^{e^x-1}\\cdot1+x^{e^x}\\ln x\\cdot e^x\\\\\n&=e^x[x]^{e^{x}-1}+e^xx^{e^x}\\ln x.\n\\end{align*}\n\n\n\n\\eex\n\\newpage\n\\begin{center}\\underline{\\Large{\\bf Exercises}}\\end{center}\n\\bigskip\n\\begin{multicols}{2}\n\\begin{enumerate}\n\\item Compute the following derivatives.\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\left[4^{\\sin x}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\sin4^x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\log_2|\\tan x|}$\n  \\item $\\ds{\\frac{d}{dx}\\tan\\left(\\log_2x\\right)}$\n  \\item $\\ds{\\frac{d}{dx}\\log_43^x}$\n  \\item $\\ds{\\frac{d}{dx}\\log_2\\left|\\frac{x}{x^2+1}\\right|}$\n  \\item $\\ds{\\frac{d}{dx}\\log_2\\left[\\sin^2x\\cos^4x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[3^{2^x}\\right]}$\n  \\end{enumerate}\n\\item Use logarithmic differentiation\n  to prove the following,  previous differentiation rules.\n  \\begin{enumerate}\n  \\item  $\\ds{\\frac{d\\,a^x}{dx}=a^x\\ln a}$,\n      assuming $a>0$.\n  \\item $\\ds{\\frac{d[uv]}{dx}=u\\cdot\\frac{dv}{dx}\n                                  +v\\cdot\\frac{du}{dx}}$.\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{u}v\\right]\n           =\\frac{v\\cdot\\frac{du}{dx}-u\\cdot\\frac{dv}{dx}}{v^2}}$.\n  \\item $\\ds{\\frac{d\\,x^n}{dx}=n\\cdot x^{n-1}}$.\n  \\item $\\ds{\\frac{d\\,\\sec x}{dx}=\\sec x\\tan x}$, using the derivative\n        formula for $\\cos x$ and the fact that $\\sec x=1/\\cos x$.\n  \\item $\\ds{\\frac{d\\,e^x}{dx}=e^x}$\n  \\end{enumerate}\n\\item Use logarithmic differentiation to compute the following.\n  \\begin{enumerate}\n  \\item $\\ds{\\frac{d}{dx}\\sqrt{\\frac{1+x}{1-x}}}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\left(10x^2+9\\right)\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\n             \\left[\\left(x^2+4\\right)^3\\left(x^3+5\\right)^6\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[\\frac{x^5}{\\left(x^4+8x-\\right)^3}\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\\left[e^{2x}\\sin5x\\cos9x\\right]}$\n  \\item $\\ds{\\frac{d}{dx}\n        \\left[\\frac{\\sin^5x\\sqrt[3]{x^2-2}}{2(6x-7)^4(2x+5)^3}\\right]}$\n  \\end{enumerate}\n\\item Compute $\\frac{dy}{dx}$ for each of the following.  You may use\n      either logarithmic differentiation, \n      or (\\ref{FuctionRaisedToAFunction}).  (It would be useful\n      to use both and examine how the results are in fact the same.)\n  \\begin{enumerate}\n  \\item $\\ds{y=x^x}$\n  \\item $\\ds{y=x^{1/x}}$\n  \\item $\\ds{y=x^{x^x}=(x)^{\\left(x^x\\right)}}$\n  \\item $\\ds{y=\\left(\\frac{\\sin x}x\\right)^x}$\n  \\end{enumerate}\n\n\\end{enumerate}\n\\end{multicols}\n\n\n\n\n\n\n          \n\\newpage\n\n\n\n\n\n\n\n\n\n\\newpage\n\n\n\n", "meta": {"hexsha": "1405e6e0577f0e08b2b476284a66a850993838fb", "size": 318748, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "michael.dougherty/chapter04.tex", "max_stars_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_stars_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "michael.dougherty/chapter04.tex", "max_issues_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_issues_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "michael.dougherty/chapter04.tex", "max_forks_repo_name": "UNDL-edu/Calculo-Infinitesimal", "max_forks_repo_head_hexsha": "2ad971127ae31b88de02b5e85fb8ba2249278e2e", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.891340603, "max_line_length": 86, "alphanum_fraction": 0.6669249689, "num_tokens": 113452, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.40586739513028103}}
{"text": "\\documentclass{memoir}\n\\usepackage{notestemplate}\n\n%\\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}\n%\\institute{Rice University}\n%\\faculty{Faculty of Whatever Sciences}\n%\\department{Department of Mathematics}\n%\\title{Class Notes}\n%\\subtitle{Based on MATH xxx}\n%\\author{\\textit{Author}\\\\Gabriel \\textsc{Gress}}\n%\\supervisor{Linus \\textsc{Torvalds}}\n%\\context{Well, I was bored...}\n%\\date{\\today}\n\n%\\makeindex\n\n\\begin{document}\n\n% \\maketitle\n\n% Notes taken on \n\n\\subsection{Meromorphic Functions and Residues}\n\\label{sub:meromorphic_functions_and_residues}\n\n\n\n\\begin{defn}[Meromorphic Function]\n\tLet \\(\\Omega \\subset \\C\\) be an open subset. Suppose that a function \\(f\\) has poles at \\(\\left\\{ z_i \\right\\}_{i=1}^{\\infty}\\). Then \\(f\\) is \\textbf{meromorphic} if \\(f\\) is holomorphic on \\(\\Omega \\setminus\\left\\{ z_i \\right\\}_{i=1}^{\\infty}\\).\n\\end{defn}\n\n\\begin{anki}\nTARGET DECK\nComplex Qual::Complex Analysis\nSTART\nMathJaxCloze\nText: Let \\(\\Omega \\subset \\C\\) be an open subset. Suppose that a function \\(f\\) has {{c1::poles at \\(\\left\\{ z_i \\right\\}_{i=1}^{\\infty}\\)}}. Then \\(f\\) is **meromorphic** if {{c1::\\(f\\) is holomorphic on \\(\\Omega \\setminus\\left\\{ z_i \\right\\}_{i=1}^{\\infty}\\)}}.\nTags: analysis complex_analysis singularities_residues defn\n<!--ID: 1626125582286-->\nEND\n\\end{anki}\n\n\n\\begin{exmp}[Polynomials]\n\tLet \\(p \\in \\C[z]\\) be a polynomial. Then \\(f(z) = \\frac{1}{p(z)}\\) is a meromorphic function with poles at the zeros of \\(p\\).\n\\end{exmp}\n\nEarlier, we showed that a function holomorphic on \\(\\Omega \\) is analytic on \\(\\Omega \\), and hence is equal to a unique power series within \\(\\Omega \\). Because poles are isolated, if \\(f\\) is meromorphic on a region \\(\\Omega \\), then there exists a Laurent expansion at each pole \\(\\left\\{ z_i \\right\\}_{i=1}^{\\infty}\\) which is valid on some open neighborhood of each pole. The Laurent expansion carries useful information about the pole, which we capture with the notion of \\textit{residues}.\n\n\\begin{defn}[Residue]\n\tLet \\(\\Omega \\subset \\C\\) be an open subset and let \\(f\\) be meromorphic on \\(\\Omega \\) with a pole at \\(z_0\\) of order \\(k\\), with Laurent expansion\n\t\\begin{align*}\n\t\tf(z) = \\sum_{n=-k}^{\\infty} a_n (z-z_0)^{n}.\n\t\\end{align*}\n\tThe coefficient \\(a_{-1}\\) is the \\textbf{residue} of \\(f\\) at \\(z_0\\), which we will denote \\(\\textrm{Res}_{z_0}f := a_{-1}\\). Furthermore, the partial sum\n\t\\begin{align*}\n\t\t\\sum_{n=-k}^{-1} a_n (z-z_0)^{n}\n\t\\end{align*}\n\tis called the \\textbf{principal part} of \\(f\\) at \\(z_0\\).\n\\end{defn}\n\nWe can use residues to calculate integrals rather easily.\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Let \\(\\Omega \\subset \\C\\) be an open subset and let \\(f\\) be meromorphic on \\(\\Omega \\) with a pole at \\(z_0\\) of order \\(k\\), with Laurent expansion\n\\(\\begin{align*}\n  \tf(z) = \\sum_{n=-k}^{\\infty} a_n (z-z_0)^{n}.\n  \\end{align*}\\)\nThe {{c1::coefficient \\(a_{-1}\\)}} is the **residue** of \\(f\\) at \\(z_0\\), which we will denote {{c1::\\(\\textrm{Res}_{z_0}f := a_{-1}\\)}}. Furthermore, the partial sum\n{{c1::\\(\\begin{align*}\n      \t\\sum_{n=-k}^{-1} a_n (z-z_0)^{n}\n        \\end{align*}\\)}} \nis called the **principal part** of \\(f\\) at \\(z_0\\).\nTags: analysis complex_analysis singularities_residues defn\n<!--ID: 1626125582303-->\nEND\n\\end{anki}\n\n\n\\begin{thm}\n\tLet \\(z_0 \\in \\C\\) be given, and suppose \\(f\\) is a complex-valued function meromorphic on \\(D_r(z_0)\\) for some \\(r>0\\) with exactly one pole at \\(z_0\\). Then\n\t\\begin{align*}\n\t\t\\int_{\\partial D_r(z_0)}f \\,d t = 2\\pi i \\textrm{Res}_{z_0}f. \n\t\\end{align*}\n\\end{thm}\n\nWe can extend this to a more general residue formula.\n\n\\begin{cor}[Residue Formula]\n\tLet \\(\\Omega \\subset \\C\\) be an open set and let \\(\\gamma \\) be a closed piecewise-smooth curve in \\(\\Omega \\) homologous to a point. Suppose \\(f\\) is a meromorphic function on \\(\\Omega \\) with poles \\(\\left\\{ z_i \\right\\}_{i=1}^{n}\\). Then\n\t\\begin{align*}\n\t\t\\int_{\\gamma } f \\,d t = 2\\pi i \\sum_{j=1}^{n} n(\\gamma ,z_j) \\textrm{Res}_{z_j}f. \n\t\\end{align*}\n\\end{cor}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Let \\(\\Omega \\subset \\C\\) be an open set and let \\(\\gamma \\) be a closed piecewise-smooth curve in \\(\\Omega \\) homologous to a point. Suppose \\(f\\) is a meromorphic function on \\(\\Omega \\) with poles \\(\\left\\{ z_i \\right\\}_{i=1}^{n}\\). Then\n{{c1::\\(\\begin{align*}\n        \t\\int_{\\gamma } f \\,d t = 2\\pi i \\sum_{j=1}^{n} n(\\gamma ,z_j) \\textrm{Res}_{z_j}f. \n        \\end{align*}\\)::residue formula}} \nTags: analysis complex_analysis singularities_residues\n<!--ID: 1626125582321-->\nEND\n\\end{anki}\n\n\\begin{exmp}\n\t\\(\\int_{-\\infty}^{\\infty} \\frac{1}{1+x^2}\\,d x = \\pi \\)\n\\end{exmp}\n\n\\begin{exmp}\n\t\n\\end{exmp}\n\n\\begin{lemma}[Tools to Help Calculate Residues]\n\t\\begin{itemize}\n\t\t\\item Let \\(f\\) be a meromorphic function with a simple pole at \\(z_0\\), and suppose \\(g\\) is a function holomorphic at \\(z_0\\). Then\n\t\t\t\\begin{align*}\n\t\t\t\t\\textrm{Res}_{z_0}(fg) = g(z_0) \\textrm{Res}_{z_0}(f).\n\t\t\t\\end{align*}\n\t\t\\item Let \\(f\\) be a function with a simple zero at \\(z_0\\). Then \\(\\sfrac{1}{f}\\) has a simple pole at \\(z_0\\) with residue \\(\\sfrac{1}{f'(z_0)}\\).\n\t\t\\item Let \\(f\\) be a function with a pole of order \\(n\\) at \\(z_0\\). Then\n\t\t\t\\begin{align*}\n\t\t\t\t\\textrm{Res}_{z_0}f = \\lim_{z \\to z_0} \\frac{1}{(n-1)!} \\left( \\frac{d}{\\,d z} \\right)^{n-1}(z-z_0)^{n}f(z).\n\t\t\t\\end{align*}\n\t\\end{itemize}\n\\end{lemma}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: \n* Let \\(f\\) be a meromorphic function with a simple pole at \\(z_0\\), and suppose \\(g\\) is a function holomorphic at \\(z_0\\). Then\n {{c1::\\(\\begin{align*}\n         \t\\textrm{Res}_{z_0}(fg) = g(z_0) \\textrm{Res}_{z_0}(f).\n         \\end{align*}\\)::residue of product}} \n* Let \\(f\\) be a function with a simple zero at \\(z_0\\). Then {{c2::\\(\\sfrac{1}{f}\\)}} has a simple pole at \\(z_0\\) with residue {{c2::\\(\\sfrac{1}{f'(z_0)}\\)}} .\n* Let \\(f\\) be a function with a pole of order \\(n\\) at \\(z_0\\). Then\n{{c1::\\(\\begin{align*}\n        \t\\textrm{Res}_{z_0}f = \\lim_{z \\to z_0} \\frac{1}{(n-1)!} \\left( \\frac{d}{\\,d z} \\right)^{n-1}(z-z_0)^{n}f(z).\n        \\end{align*}\\)::residue of point via higher derivatives}} \nTags: analysis complex_analysis singularities_residues\n<!--ID: 1626125582338-->\nEND\n\\end{anki}\n\n\n%\\begin{defn}[Bounding]\n%\tA cycle \\(\\gamma\\) is said to bound the region \\(M\\) if and only if \\(n(\\gamma,a)\\) is defined and equal to \\(1\\) for all points \\(a \\in M\\) and either undefined or equal to zero for all points \\(a\\) not in \\(M\\).\n%\\end{defn}\n\n\\subsection{Argument Principle}\n\\label{sub:argument_principle}\n\nThere is a deep connection between residues, winding numbers, and the complex logarithm. It turns out that all of these notions capture in some form the change in argument of a meromorphic function-- the theorem that ties these ideas together is what we refer to as the \\textit{argument principle}.\\\\\n\nRecall that the goal of the complex logarithm is to provide an inverse function for \\(e^{x}\\). In other words, we define the logarithm so that\n\\begin{align*}\n\t\\ln(\\left| z \\right| e^{i \\theta }) = \\ln_\\R (\\left| z \\right| ) + i \\theta .\n\\end{align*}\nWe refer to \\(\\theta \\) as \\(\\textrm{Arg}(z)\\) more generally. The imaginary term alone captures in its entirety the angle of the input \\(z\\)-- this observation leads us to utilize the logarithm as an intermediate tool to capture more generally the change in angle of a function.\n\n\\begin{general}[Logarithmic Derivative]\n\tLet \\(f\\) be a complex-valued meromorphic function. Consider the composition \\(\\ln(f)\\). Observe that\n\t\\begin{align*}\n\t\t\\frac{\\partial }{\\partial z} \\ln(f(z)) = \\frac{f'(z)}{f(z)}.\n\t\\end{align*}\n\tWe refer to \\(\\frac{f'}{f}\\) as the \\textbf{logarithmic derivative} of \\(f\\). \\\\\n\n\tNotably, the logarithmic derivative carries an additive formula:\n\t\\begin{align*}\n\t\t\\frac{\\partial }{\\partial z} \\ln\\left( \\prod_{n=\\infty}^{N} f_n  \\right) = \\sum_{n=1}^{N} \\frac{f'_n}{f_n}.\n\t\\end{align*}\n\\end{general}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: Let \\(f\\) be a complex-valued meromorphic function. Consider the composition \\(\\ln(f)\\). Observe that\n {{c1::\\(\\begin{align*}\n         \t\\frac{\\partial }{\\partial z} \\ln(f(z)) = \\frac{f'(z)}{f(z)}.\n         \\end{align*}\\)}} \nWe refer to {{c1::\\(\\frac{f'}{f}\\)}} as the **logarithmic derivative** of \\(f\\). \n\nNotably, the logarithmic derivative carries an additive formula:\n{{c1::\\(\\begin{align*}\n        \t\\frac{\\partial }{\\partial z} \\ln\\left( \\prod_{n=\\infty}^{N} f_n  \\right) = \\sum_{n=1}^{N} \\frac{f'_n}{f_n}.\n        \\end{align*}\\)}}\nExtra: What is the connection between the logarithm and residues? Suppose \\(f\\) is holomorphic with a zero of order \\(n\\) at \\(z_0\\). Then\n\\(\\begin{align*}\n  \tf(z) = (z-z_0)^{n}g(z)\n  \\end{align*}\\)\nfor \\(g\\) holomorphic and non-vanishing in a neighborhood of \\(z_0\\). The logarithmic derivative of \\(f\\) is hence\n\\(\\begin{align*}\n  \t\\frac{f'(z)}{f(z)} = \\frac{n}{z-z_0}+ \\frac{g'(z)}{g(z)}\n  \\end{align*}\\)\nby the additive property of the logarithmic derivative. But \\(g\\) and \\(g'\\) are holomorphic and non-vanishing-- and hence the logarithmic derivative has transformed \\(f\\) into a meromorphic function with a simple pole at \\(z_0\\) with residue \\(\\textrm{Res}_{z_0} = n\\). Likewise, if \\(f\\) is meromorphic with a pole of order \\(n\\) at \\(z_0\\), then\n\\(\\begin{align*}\n  \tf(z) = (z-z_0)^{-n}h(z)\n  \\end{align*}\\)\nfor \\(h\\) holomorphic and non-vanishing. One can see the above follows but with \\(-n\\).\nTags: analysis complex_analysis singularities_residues defn\n<!--ID: 1626125582356-->\nEND\n\\end{anki}\n\n\nAt this point, the connection between the logarithm and winding number is clear-- by performing a \\(w\\)-substitution with \\(w = f(z)\\), we see that that the logarithmic derivative is merely another way to write\n\\begin{align*}\n\t\\frac{f'}{f} \\,d z = \\frac{dw}{w}\n\\end{align*}\nand hence when integrated on a closed curve, captures the winding numbers of singularities of \\(f\\) inside the curve. Furthermore, we have the identity\n\\begin{align*}\n\t\\int_\\gamma \\,d \\ln(f(z)) = \\int_\\gamma \\,d \\left[ \\ln \\left| f(z) \\right| + i \\textrm{arg}(f(z)) \\right] = \\int_\\gamma \\,d \\ln\\left| f(z) \\right| + \\int_\\gamma \\,d \\textrm{arg}(f(z)).\n\\end{align*}\nBecause the first integral always evaluates to zero (verify this), we see that the logarithmic derivative allows us to capture the change in argument of a function.\\\\\n\nWhat is the connection between the logarithm and residues? Suppose \\(f\\) is holomorphic with a zero of order \\(n\\) at \\(z_0\\). Then\n\\begin{align*}\n\tf(z) = (z-z_0)^{n}g(z)\n\\end{align*}\nfor \\(g\\) holomorphic and non-vanishing in a neighborhood of \\(z_0\\). The logarithmic derivative of \\(f\\) is hence\n\\begin{align*}\n\t\\frac{f'(z)}{f(z)} = \\frac{n}{z-z_0}+ \\frac{g'(z)}{g(z)}\n\\end{align*}\nby the additive property of the logarithmic derivative. But \\(g\\) and \\(g'\\) are holomorphic and non-vanishing-- and hence the logarithmic derivative has transformed \\(f\\) into a meromorphic function with a simple pole at \\(z_0\\) with residue \\(\\textrm{Res}_{z_0} = n\\). Likewise, if \\(f\\) is meromorphic with a pole of order \\(n\\) at \\(z_0\\), then\n\\begin{align*}\n\tf(z) = (z-z_0)^{-n}h(z)\n\\end{align*}\nfor \\(h\\) holomorphic and non-vanishing. One can see the above follows once more but with \\(-n\\).\\\\\n\nIn summary-- the logarithmic derivative transforms \\textit{singularities of algebraic order \\(n\\)} into \\textit{simple poles with residue \\(n\\)}. Thus, a contour integral of the logarithmic derivative will sum the algebraic orders of the singularities contained. This remarkable conclusion is the argument principle.\n\n\\begin{thm}[Argument Principle]\n\tIf \\(f\\) is meromorphic in \\(\\Omega\\subset \\C \\) with zeros \\(\\left\\{ z_j \\right\\}\\) and the poles \\(\\left\\{ w_k \\right\\} \\), then\n\t\\begin{align*}\n\t\t\\frac{1}{2\\pi i} \\int_{\\gamma} \\frac{f'}{f} \\,d t = \\sum_{j} n(\\gamma,z_j) - \\sum_{k} n(\\gamma,w_k) \n\t\\end{align*}\n\tfor every closed piecewise-smooth curve \\(\\gamma\\) which is homologous to zero in \\(\\Omega \\) and does not pass through any of the zeros or poles.\n\\end{thm}\nIn light of our earlier discussion, we refer to\n\\begin{align*}\n\t\\frac{1}{2\\pi i} \\int_\\gamma \\frac{f'}{f}\\,d t\n\\end{align*}\nas the \\textbf{winding number of \\(f\\) along \\(\\gamma \\)}. We urge the reader to appreciate how remarkable it is that the change in angle of a meromorphic function can be captured so simply via its zeros and poles!\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: **Argument Principle**\nIf \\(f\\) is meromorphic in \\(\\Omega\\subset \\C \\) with zeros \\(\\left\\{ z_j \\right\\}\\) and the poles \\(\\left\\{ w_k \\right\\} \\), then\n{{c1::\\(\\begin{align*}\n        \t\\frac{1}{2\\pi i} \\int_{\\gamma} \\frac{f'}{f} \\,d t = \\sum_{j} n(\\gamma,z_j) - \\sum_{k} n(\\gamma,w_k) \n        \\end{align*}\\)}}\n\tfor every closed piecewise-smooth curve \\(\\gamma\\) which is homologous to zero in \\(\\Omega \\) and does not pass through any of the zeros or poles.\nExtra: We refer to\n\\(\\begin{align*}\n  \t\\frac{1}{2\\pi i} \\int_\\gamma \\frac{f'}{f}\\,d t\n  \\end{align*}\\)\nas the \\textbf{winding number of \\(f\\) along \\(\\gamma \\)}.\nTags: analysis complex_analysis singularities_residues\n<!--ID: 1626125582372-->\nEND\n\\end{anki}\n\n\n\\begin{cor}[Rouche's Theorem]\n\tLet \\(\\Omega \\subset \\C\\) be an open bounded subset with \\(\\partial \\Omega \\) piecewise-smooth. Let \\(f,g\\) be holomorphic functions on \\(\\overline{\\Omega }\\) with \\(\\left| g(z) \\right| < \\left| f(z) \\right| \\) for all \\(z \\in \\partial\\Omega \\). Then \\(f\\) and \\(f+g\\) have the same number of zeros in \\(\\Omega \\).\n\\end{cor}\nWe can interpret \\(g\\) as a \"holomorphic perturbation\" of \\(f\\) in \\(\\Omega \\)-- and hence the theorem really states that if the perturbation is bounded above by \\(f\\) along the boundary, then it cannot perturb any zero outside \\(\\Omega \\). To see why this should be true, recall that the maximum principle tells us that \\(g\\) globally and locally achieves its maxima on the boundary. If \\(g\\) were to \"push\" a zero \\(z_0\\) of \\(f\\) outside \\(\\Omega \\), then \\(g\\) would have to exceed \\(f\\) somewhere on the boundary for the maximum principle to hold. Formalizing this argument is difficult, however. The argument principle simplifies this process greatly.\n\\begin{proof}\n\tNote that the hypothesis implicitly requires that \\(f\\) and \\(f+g\\) are non-zero on \\(\\gamma \\). Thus, we can rewrite\n\t\\begin{align*}\n\t\tf+g &= f\\left( 1+ \\frac{g}{f} \\right)\n\t\\end{align*}\n\tApplying the logarithmic derivative gives us\n\t\\begin{align*}\n\t\t\\int_\\gamma \\frac{(f+g)'}{f+g}\\,d t = \\int_\\gamma \\frac{f'}{f} \\,d t + \\int_{\\gamma }\\frac{(1+\\sfrac{g}{f})'}{1+\\sfrac{g}{f}} \\,d t.\n\t\\end{align*}\n\tBut we have that \\(\\left| \\frac{g}{f} \\right|<1\\) on \\(\\gamma \\), and so there are no zeros of \\(\\frac{g}{f}\\) within \\(\\gamma \\), and likewise no poles (because \\(\\frac{g}{f}\\) is holomorphic). Hence, the argument principle tells us that the right-hand integral is zero, and hence\n\t\\begin{align*}\n\t\t\\int_\\gamma \\frac{(f+g)'}{f+g} \\,d t = \\int_\\gamma \\frac{f'}{f}\\,d t\n\t\\end{align*}\n\twhich implies they must have the same zeros.\n\\end{proof}\n\n\\begin{anki}\nSTART\nMathJaxCloze\nText: **Rouche's Theorem**\nLet \\(\\Omega \\subset \\C\\) be an open bounded subset with \\(\\partial \\Omega \\) piecewise-smooth. Let \\(f,g\\) be holomorphic functions on \\(\\overline{\\Omega }\\) with \\(\\left| g(z) \\right| < \\left| f(z) \\right| \\) for all \\(z \\in \\partial\\Omega \\). Then {{c1::\\(f\\) and \\(f+g\\) have the same number of zeros in \\(\\Omega \\)}}.\nExtra: We can interpret \\(g\\) as a \"holomorphic perturbation\" of \\(f\\) in \\(\\Omega \\)-- and hence the theorem really states that if the perturbation is bounded above by \\(f\\) along the boundary, then it cannot perturb any zero outside \\(\\Omega \\).\nTags: analysis complex_analysis singularities_residues\n<!--ID: 1626125582389-->\nEND\n\\end{anki}\n\nNow we will look at some applications of the two powerful theorems here to evaluating integrals.\n\n%% Deal with later\n\n% \\subsection{Definite Integrals}\n% \\label{sec:definite_integrals}\n% \n% First, note that all integrals of the form\n% \\begin{align*}\n% \t\\int_{0}^{2\\pi} R(\\cos(\\theta),\\sin(\\theta)) \\,d \\theta \n% \\end{align*}\n% where the integrand is a rational function of the two trigonometric functions can be done via residues. Substituting \\(z = e^{i\\theta}\\) yields\n% \\begin{align*}\n% \t-i \\int_{\\left| z \\right| =1} R \\left[ \\frac{1}{2}\\left( z+ \\frac{1}{z} \\right) , \\frac{1}{2i}\\left( z-\\frac{1}{z} \\right)  \\right] \\frac{\\,d z}{z}.\n% \\end{align*}\n% \n% --\n% \n% An integral of the form\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) \\,d x \n% \\end{align*}\n% converges if and only if the rational function \\(R(x)\\) the degree of the denomination is at least 2 degrees higher tahn taht of the numerator, and if there is no pole ON the real axis. We do this by integrating the complex function \\(R(z)\\) over a closed curve consisting of a line segment \\((-p,p)\\) and the semicircle from \\(p,-p)\\) in the upper half plane. Choosing \\(p\\) large enough  encloses all poles in the upper half plane, and so the integral is equal to \\(2\\pi i\\) times the sum of the residues in the upper half plane. So,\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) \\,d x = 2\\pi i \\sum_{y>0} \\textrm{Res}R(z) \n% \\end{align*}\n% \n% -\n% \n% We can do this same method for integrals of the form\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) e^{ix} \\,d x \n% \\end{align*}\n% whose real and imaginary parts determine the integrals\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) \\cos(x) \\,d x, \\quad \\int_{-\\infty}^{\\infty} R(x) \\sin(x) \\,d x  \n% \\end{align*}\n% Because \\(e^{-y}\\) is bounded in the upper half plane, so the integral over the semicircle tends to zero (as long as \\(R(z)\\) has a zero of at least order two at infinity). Thus\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) e^{ix}\\,d x = 2\\pi i \\sum_{y>0} \\textrm{Res}R(z) e^{ix} .\n% \\end{align*}\n% This holds when \\(R(z)\\) only has order one zero at infinity, but not by the semicircle argument.\\\\\n% \n% Note that we assumed that \\(R(z)\\) has no poles on the real axis; however, if it coincides with zeros of \\(\\sin(x)\\), then it very well can be evaluated! It will work out to yield\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x)e^{ix}\\,d x = 2\\pi i \\sum_{y>0} \\textrm{Res}R(z) e^{iz} + \\pi i \\sum_{y=0} \\textrm{Res}R(z)e^{iz} \n% \\end{align*}\n% Often, integrals containing powers of cosine and sine can be written as linear combinations via double angle identities, and hence\n% \\begin{align*}\n% \t\\int_{-\\infty}^{\\infty} R(x) e^{imx}\\,d x = \\frac{1}{m} \\int_{-\\infty}^{\\infty} R\\left( \\frac{x}{m} \\right) e^{ix} \\,d x.  \n% \\end{align*}\n% \n% -\n% \n% Now consider\n% \\begin{align*}\n% \t\\int_{0}^{\\infty} x^{\\alpha}R(x) \\,d x \n% \\end{align*}\n% with \\(\\alpha \\in (0,1)\\subset \\R\\). This only converges if \\(R(z)\\) has a zero of at least order two at \\(\\infty\\) and at most a simple pole at the origin. Using the substitution of \\(x = t^2\\) and then omitting the negative imaginary axis, we can apply the residue theorem to yield\n% \\begin{align*}\n% \t(1-e^{2\\pi i \\alpha}) \\int_{0}^{\\infty} z^{2\\alpha+1}R(z^2) \\,d z \n% \\end{align*}\n% Thus we determine the residues of the integrand in the upper hlaf plane. This is the same as the residues of \\(z^{\\alpha}R(z)\\) in the whole plane.\n% \\printindex\n\\end{document}\n", "meta": {"hexsha": "4cc7cf76c9a02e95ec9ba56483a257ca4211d2b8", "size": 19058, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Complex Analysis/Notes/source/Residues.tex", "max_stars_repo_name": "gjgress/Libera-Mentis", "max_stars_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T23:18:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T23:18:15.000Z", "max_issues_repo_path": "Complex Analysis/Notes/source/Residues.tex", "max_issues_repo_name": "gjgress/Libera-Mentis", "max_issues_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2021-05-20T22:09:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T23:23:22.000Z", "max_forks_repo_path": "Complex Analysis/Notes/source/Residues.tex", "max_forks_repo_name": "gjgress/LibreMath", "max_forks_repo_head_hexsha": "d9f1bfd9e6ea62a9d56292f7890f99c450b54c9b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0710382514, "max_line_length": 657, "alphanum_fraction": 0.6609822647, "num_tokens": 6535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.7931059560743422, "lm_q1q2_score": 0.4058454870130133}}
{"text": "%%========================================================\n%% Section 0.02: Overview of the ILW Direct Scattering Map\n%%========================================================\n\n\\documentclass[../dissertation.tex]{subfiles}\n\n\\begin{document}\n\\section{Overview of the ILW Direct Scattering Map}\\label{sec0:DM}\n\nWhile there are a series of papers from the late 1970's and early 1980's \nculminating in a paper by Y. Kodama, M.J. Ablowitz and J. Satsuma \n\\cite{Kodama1982} and a subsequent paper by P.M. Santini, M.J. Ablowitz and A.S. \nFokas \\cite{Santini1984} which formally describe the Inverse Scattering \nTransform (IST) for the ILW, little research has been done to place the Inverse \nScattering Method for the ILW equation on a rigorous mathematical footing. \nAt the time of writing this dissertation, the author found no results in the \nliterature showing that the IST for the ILW equation is actually well-defined\nor bi-Lipschitz continuous\\textemdash{}even for small data.\n\nAs described in Section \\ref{sec0:IST}, using the Inverse\nScattering Method to solve the ILW entails constructing \nan invertible, bi-Lipschitz\ncontinuous map from initial data to the corresponding scattering data in such \na way that linearizes the flow\\textemdash{}\\textit{i.e.} the time dependence \nof the output of this map applied to initial data is determined by a linear \ndifferential equation. The ``forward\ndirection'' of this map which takes initial data to scattering data is referred to \nas the ``direct scattering map,'' and its inverse\nis referred to as the ``inverse scattering map.'' This distinction is made as the process for \nconstructing the direct scattering map for a given equation is often very different from\nthe process for constructing the corresponding inverse scattering map. As previously mentioned,\nthe combination of this direct scattering map with the corresponding inverse \nscattering map and the linear differential equation used to propagate the scattering data in \ntime is called an Inverse Scattering Transform for the ILW.\n\nWhat allows us to construct an IST for the ILW\nis\nfact that the ILW is an isospectral flow for the linear spectral problem\n\\begin{align}\\label{eq0:SpecProb}\n\tL_\\delta (\\Psi) \n\t\t:= \\frac{1}{i} \\frac{\\partial}{\\partial x} \\Psi^+ \n\t\t\t- \\zeta \\left(\\Psi^+ - \\Psi^-\\right) = u \\Psi^+,\n\\end{align}\nwhich is a part of the Lax pair\\footnote{Please see the appendix titled\n\\hyperref[app:Lax]{\\textit{Lax Representation}} for a comparison of \n\\eqref{eq0:Lax} with the ILW Lax pair typically given in the literature.}\n\\begin{subequations}\\label{eq0:Lax}\n\t\\begin{align}\n\t\t\\frac{1}{i} \\frac{\\partial}{\\partial x} \\Psi^+ \n\t\t\t\t- \\zeta \\left(\\Psi^+ - \\Psi^-\\right)\n\t\t\t &= u \\Psi^+ \n\t\t\t \\label{eq0:LaxX} \\\\\n\t\t\\frac{1}{i} \\frac{\\bd}{\\bd t} \\Psi^\\pm + 2 i \n\t\t\t\t\\( \\zeta-\\frac{1}{2\\delta} \\) + \\Psi_{xx}\n\t\t\t&= \\left[ \\pm i u_x  - T u_x + \\eta  \\right] \\Psi^\\pm,\n\t\t\t\\label{eq0:LaxT}\n\\end{align}\n\\end{subequations}\nwhere $\\Psi$ is a function analytic in the complex strip\\label{sym:Sdelta} \n\\[\n\t\\mathcal S_\\delta := \\{ z \\in \\mathbb C \\, : \\, 0 < \\im z < 2 \\delta\\}\n\\]\nwith respective lower and upper boundary values\\label{sym:bndries}\n\\begin{align}\\label{eq0:bndryvaluedefn}\n\t\\Psi^+(x):= \\lim_{y \\searrow 0} \\Psi(x + i y), \\qquad \n\t\\text{and}\\qquad\n\t\\Psi^-(x):= \\lim_{y \\nearrow 2\\delta} \\Psi(x + i y),\n\\end{align}\nwhere we use the superscript notation $f^\\pm$ throughout this dissertation to \nindicate lower and upper boundary values as shown above of functions $f$ \nanalytic on the complex strip $\\mathcal S_\\delta$.\nThe spectral parameter $\\zeta \\in (0, \\infty)$\\label{sym:zeta} is itself parametrized by a second spectral \nparameter $\\lambda \\in \\mathbb R$\\label{sym:lambda} as \n\\[\n\t\\zeta(\\lambda; \\delta) := \\frac{\\lambda}{1 - e^{-2 \\delta \\lambda}},\n\\]\nwhere we use the notation $f(\\dotarg; t_1, \\ldots, t_n):=f_{t_1, \\ldots, t_n}$ to denote a \nfamily of functions ``indexed'' in a (possibly) uncountable sense by $t_1, \\ldots, t_n$. \nThe output of direct scattering map $\\mathscr D$ for the ILW is determined by the \nlower boundary values\n$M_1^+$, $M_e^+$, $N_1^+$, $N_e^+$ of eigenfunctions $M_1$, $M_e$, $N_1$, $N_e$\nof $L_\\delta$ which satisfy the asymptotic conditions given in \\eqref{eq0:JostDEasymp}.\nSuch eigenfunctions are referred to in the literature as ``Jost solutions,'' and, given their\nimportance in the construction of the direct scattering map $\\mathscr D$, we explicitly\ndefine Jost solutions as follows:\n\\begin{defn}[Jost solutions]\\label{defn0:jost}\n\tThe Jost solutions $M_1$, $M_e$, $N_1$, $N_e$ are solutions to the linear \n\tspectral problem \\eqref{eq0:SpecProb} whose lower boundary values\n\t$M_1^+$, $M_e^+$, $N_1^+$, $N_e^+$ as defined in \\eqref{eq0:bndryvaluedefn}\n\tobey the following asymptotic conditions\n\t\\begin{subequations}\\label{eq0:JostDEasymp}\n\t\t\\begin{align}\n\t\t\t\\lim_{x\\to -\\infty} \n\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\\left( \n\t\t\t\t\t\tM_1^+(x; \\lambda, \\delta) - 1 \n\t\t\t\t\t\\right)\n\t\t\t\t&= \\lim_{x\\to \\infty} \n\t\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\t\\left( \n\t\t\t\t\t\t\tN_1^+(x; \\lambda, \\delta) - 1\n\t\t\t\t\t\t\\right)\n\t\t\t\t= 0 \\\\\n\t\t\t\\lim_{x\\to -\\infty} \n\t\t\t\t\t\\inn{x} \\left( \n\t\t\t\t\t\tM_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\n\t\t\t\t\t\\right)\n\t\t\t\t&= \\lim_{x\\to \\infty} \n\t\t\t\t\t\t\\inn{x} \n\t\t\t\t\t\t\\left( \n\t\t\t\t\t\t\tN_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\n\t\t\t\t\t\t\\right)\n\t\t\t\t= 0,\n\t\t\\end{align}\n\t\\end{subequations}\n\twhere we use the notation $\\inn{x}:=\\sqrt{1+|x|^2}$\\label{sym:xbracket} to \n\tindicate a linear weight.\n\n\tAdditionally, we require the upper boundary values $M_{(\\dotarg)}^-$, $N_{(\\dotarg)}^-$\n\t(where $(\\dotarg)$ represents either the subscript $1$ or $e$) of \n\t$M_{(\\dotarg)}$, $N_{(\\dotarg)}$ to have a decomposition \n\t\\begin{align*}\n\t\tM_1^- - 1 &= M_1^{(1)} + M_1^{(2)} \\qquad &\\text{and}& \\qquad\n\t\t&N_1^- - 1 &= N_1^{(1)} + N_1^{(2)} \\\\\n\t\tM_e^- - e^{i\\lambda x}\\,e^{-2\\delta\\lambda} &= M_e^{(1)} + M_e^{(2)} \\qquad &\\text{and}& \\qquad\n\t\t&N_e^- - e^{i\\lambda x}\\,e^{-2\\delta\\lambda} &= N_e^{(1)} + N_e^{(2)} \\\\\n\t\\end{align*}\n\tsatisfying \n\t\\begin{align*}\n\t\t\\inn{x}^{1+\\upsilon} \\left|M_{(\\dotarg)}^{(1)}(x)\\right| \\lesssim 1 \n\t\t\t\\quad (\\text{for } x \\ll -1), \\qquad \n\t\t\\inn{x}^{1+\\upsilon} \\left|N_{(\\dotarg)}^{(1)}(x)\\right| \\lesssim 1\n\t\t\t\\quad (\\text{for } x \\gg 1),\n\t\\end{align*}\n\tand\n\t\\begin{align*}\n\t\t\\inn{\\dotarg}^\\tau M_{(\\dotarg)}^{(2)}, \n\t\t\t~\\inn{\\dotarg}^\\tau N_{(\\dotarg)}^{(2)} \\in L^2(\\mathbb R)\n\t\\end{align*}\n\tfor any $\\upsilon \\in \\left(0,\\frac{1}{2}\\right)$ and $\\tau \\in [0,1)$, where we \n\tuse the notation  $a\\lesssim b$ to indicate $a \\leq C \\, b$ for some constant $C>0$.\n\t\\label{sym:lesssim}\n\t% \\begin{subequations}\\label{eq0:JostDEasymp}\n\t% \t\\begin{align}\n\t% \t\t\\left\\{\n\t% \t\t\t\\begin{aligned}\n\t% \t\t\t\t&\\lim_{x\\to -\\infty}\tM_1^+(x; \\lambda, \\delta) - 1\n\t% \t\t\t\t\t= \\lim_{x\\to \\infty} N_1^+(x; \\lambda, \\delta) - 1\n\t% \t\t\t\t\t= 0 \\\\\n\t% \t\t\t\t&\\lim_{x\\to -\\infty} \\big( M_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\\big)\n\t% \t\t\t\t\t= \\lim_{x\\to \\infty} \\big( N_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\\big)\n\t% \t\t\t\t\t= 0\n\t% \t\t\t\\end{aligned}\n\t% \t\t\\right.\n\t% \t\t\\qquad (\\lambda \\ne 0)\n\t% \t\\end{align}\n\t% \tand\n\t% \t\\begin{align}\n\t% \t\t\\left\\{\n\t% \t\t\t\\begin{aligned}\n\t% \t\t\t\t&\\lim_{x\\to -\\infty}\n\t% \t\t\t\t\t\t\\inn{x}^{-1} \\big(M_1^+(x; \\lambda, \\delta) - 1\\big)\n\t% \t\t\t\t\t\t\\\\\n\t% \t\t\t\t&\\qquad\\qquad= \\lim_{x\\to \\infty} \\inn{x}^{-1} \n\t% \t\t\t\t\t\t\\big(N_1^+(x; \\lambda, \\delta) - 1\\big)\n\t% \t\t\t\t\t= 0 \\\\\n\t% \t\t\t\t&\\lim_{x\\to -\\infty}\\inn{x}^{-1} \n\t% \t\t\t\t\t\t\\big( M_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\\big)\n\t% \t\t\t\t\t\t\\\\\n\t% \t\t\t\t\t&\\qquad\\qquad= \\lim_{x\\to \\infty}\\inn{x}^{-1} \n\t% \t\t\t\t\t\t\\big( N_e^+(x; \\lambda, \\delta) - e^{i\\lambda x}\\big)\n\t% \t\t\t\t\t= 0\n\t% \t\t\t\\end{aligned}\n\t% \t\t\\right.\n\t% \t\t\\qquad (\\lambda = 0)\n\t% \t\\end{align}\n\t% \\end{subequations}\n\\end{defn}\n\nFor a given \n$u(x)$, the corresponding output $r = \\mathscr D u$ of direct scattering map is\ngiven by \n$r(\\lambda; \\delta) = b(\\lambda;\\delta) / a(\\lambda; \\delta)$,\\label{sym0:reflection} \nwhere\n\\begin{align*}\n\tb(\\lambda)\n\t\t&:= \n\t\t\t\\frac{i}{1-2\\delta\\zeta(-\\lambda)} \n\t\t\t\\int_{\\mathbb R} e^{-i\\lambda x} \n\t\t\t\tu(x) \\, M_1^+(x; \\lambda,\\delta) \n\t\t\t\\, \\mathrm{d}x\n\t\t\t\\\\\n\ta(\\lambda)\n\t\t&:=\n\t\t\t1 \n\t\t\t+ \\frac{i}{1-2\\delta \\zeta(\\lambda)}\n\t\t\t\t\\int_{\\mathbb R} \n\t\t\t\t\tu(x) \\, M_1^+(x; \\lambda,\\delta) \n\t\t\t\t\\, \\mathrm{d}x.\n\\end{align*}\nIn this dissertation, we prove the following result:\n\\begin{thm}\\label{thm0:MainResult}\n\tFor sufficiently small $c_0 > 0$ the map\n\t\\begin{align*}\n\t\t\\mathscr D : B_X(0, c_0) &\\to L^\\infty(\\mathbb R) \\\\\n\t\t                       u &\\mapsto r\n\t\\end{align*}\n\tis well-defined for all real $\\lambda$, where \n\t$X$ denotes the space $\\inn{\\dotarg}^{-4} L^2(\\mathbb R)$, and \n\t$B_X(0, c_0)$ \\label{sym:ball} \n\tis the ball in the \n\tspace $X$ about zero with radius $c_0$.\\footnote{See Theorem \\ref{thm4:Dwelldefined}\n\tin Section \\ref{sec4:DM} of Chapter \\ref{cptr04:DM}.}\n\tFurther, $\\mathscr D$\\label{sym0:DSM} is \n\tLipschitz continuous as a map from $B_X(0, c_0)$ to \n\t$L^\\infty\\big((-\\infty, k]\\cup[k, \\infty)\\big)$ for each fixed \n\t$k>0$.\\footnote{See Theorem \\ref{thm4:DlipR} in Section \\ref{sec4:DM} of Chapter \n\t\\ref{cptr04:DM}.}\n\\end{thm}\n\nA crucial first step to showing that $\\mathscr D$ is well-defined is showing that \nfor each given $u \\in B_X$ the corresponding Jost solutions both exist and are \nunique. To do so, one uses \nthe (formal) Green's Functions $G_L$ and $G_R$, given by \n\\begin{subequations}\n\t\\label{eq0:GFs}\n\t\\begin{align}\n\t\t\\label{eq0:GFL}\n\t\tG_L(z; \\lambda, \\delta) \n\t\t\t&= \n\t\t\t\t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\frac{1}{2\\pi} \n\t\t\t\t\\int\\limits_{\\mathbb R - i\\varepsilon} \n\t\t\t\t\t\\frac{e^{iz\\xi}}\n\t\t\t\t\t\t{\\xi -  \\zeta(\\lambda) \\left(1- e^{-2 \\delta \\xi}\\right) } \n\t\t\t\t\\, \\mathrm{d}\\xi, \n\t\t\t\t\\qquad \\left(z\\in \\overline{\\mathcal{S}}_\\delta \\right)\\\\\n\t\t\\intertext{and}\n\t\t\\label{eq0:GFR}\n\t\tG_R(z; \\lambda, \\delta) \n\t\t\t&= \n\t\t\t\t\\lim_{\\varepsilon \\searrow 0} \n\t\t\t\t\\frac{1}{2\\pi} \n\t\t\t\t\\int\\limits_{\\mathbb R + i\\varepsilon} \n\t\t\t\t\t\\frac{e^{iz\\xi}}\n\t\t\t\t\t\t{\\xi -  \\zeta(\\lambda) \\left(1- e^{-2 \\delta \\xi}\\right) } \n\t\t\t\t\\, \\mathrm{d}\\xi,\n\t\t\t\t\\qquad \\left(z\\in \\overline{\\mathcal{S}}_\\delta \\right)\n\t\\end{align}\n\\end{subequations}\nto rewrite \\eqref{eq0:SpecProb} with asymptotic conditions \\eqref{eq0:JostDEasymp} \nas the integral equations\n\\begin{subequations}\n\t\\label{eq0:JostIE}\n\t\\begin{align}\n\t\t\\label{eq0:JostIEleft}\n\t\t\\begin{pmatrix}\n\t\t\tM_1^+(x; \\lambda, \\delta) \\\\\n\t\t\tM_e^+(x; \\lambda, \\delta)\n\t\t\\end{pmatrix}\n\t\t\t&= \n\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t1 \\\\\n\t\t\t\t\te^{i\\lambda x} \n\t\t\t\t\\end{pmatrix}\n\t\t\t\t+ \\int_{\\mathbb R} G_L^+(x - x'; \\lambda, \\delta) \n\t\t\t\t\tu(x')\n\t\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t\tM_1^+(x'; \\lambda, \\delta) \\\\\n\t\t\t\t\t\tM_e^+(x'; \\lambda, \\delta) \n\t\t\t\t\t\\end{pmatrix}\n\t\t\t\t\t\\, \\mathrm{d}x' \\\\[0.3\\baselineskip]\n\t\t\\label{eq0:JostIEright}\n\t\t\\begin{pmatrix}\n\t\t\tN_1^+(x; \\lambda, \\delta) \\\\\n\t\t\tN_e^+(x; \\lambda, \\delta)\n\t\t\\end{pmatrix}\n\t\t\t&= \n\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t1 \\\\\n\t\t\t\t\te^{i\\lambda x} \n\t\t\t\t\\end{pmatrix}\n\t\t\t\t+ \\int_{\\mathbb R} G_R^+(x - x'; \\lambda, \\delta) \n\t\t\t\t\tu(x')\n\t\t\t\t\t\\begin{pmatrix}\n\t\t\t\t\t\tN_1^+(x'; \\lambda, \\lambda) \\\\\n\t\t\t\t\t\tN_e^+(x'; \\lambda, \\lambda) \n\t\t\t\t\t\\end{pmatrix}\n\t\t\t\t\t\\, \\mathrm{d}x',\n\t\\end{align}\n\\end{subequations}\nwhere we again use the ``$+$'' superscript to indicate the lower boundary\nvalues of functions analytic in the complex strip $\\mathcal S_\\delta$.\n\nFormally, assuming that the solutions to equations \\eqref{eq0:JostIE} \nhave analytic extensions to the strip $\\mathcal S_\\delta$ with upper\nboundary values\n$M_1^-$, $M_e^-$, $N_1^-$, and $N_e^-$, one can show through a simply \nheuristic computation that solutions to the integral equations \\eqref{eq0:JostIE} \nshould satisfy the spectral problem \\eqref{eq0:SpecProb} with asymptotic \nconditions \\eqref{eq0:JostDEasymp}. However, as discussed in Section \n\\ref{sec1:RootsOfP},the integrand of $G_L$ and $G_R$ has exactly two poles \nalong the real line as shown in \\textemdash{}namely $\\xi = 0$ and \n$\\xi = \\lambda$\\textemdash{}and countably many poles in the complex plane. \nWorse, the Fourier symbol $p(\\xi)$ of $G_L$, $G_R$ does not belong to any\nstandard symbol class due to its radically different asymptotic behavior \nas $\\xi \\to -\\infty$, and $\\xi \\to +\\infty$, respectively. As such,\nit is hardly obvious that $G_L$ and $G_R$ are even remotely well \ndefined as convolution operators. As such, before we can even begin to prove \nthat the direct scattering map $\\mathscr D$ is well-defined, we require a \nthorough understanding of the Green's functions $G_L$, $G_R$ as convolution \noperators\\textemdash{}indeed, such is the focus of Chapters \\ref{cptr01:GF} \nthrough \\ref{cptr03:xContin} of this dissertation.\n\nWe begin our study of the Green's functions $G_L$, $G_R$ in Chapter \n\\ref{cptr01:GF} by analyzing the properties of the lower boundary \nvalues $G_L^+$, $G_R^+$ as functions.\nUsing a combination of a contour shift\nand several dyadic decompositions, we show\nthat the boundary values $G_L^+$ and $G_R^+$ can be represented as \n\\begin{align}\\label{eq0:GFrep}\n\tG_L^+(x; \\lambda, \\delta)\n\t\t&= \n\t\t\t\\begin{cases}\n\t\t\t\tK^+(x; \\lambda, \\delta), &x < 0 \\\\\n\t\t\t\tK^+(x; \\lambda, \\delta)\n\t\t\t\t+ i \\alpha(\\lambda; \\delta) \n\t\t\t\t+ i \\beta(\\lambda; \\delta) \\, e^{i \\lambda \\, x}, \n\t\t\t\t&x >0 \n\t\t\t\\end{cases}\n\\end{align}\nwhere $G_L(z; \\lambda, \\delta) = \\overline{G_R(-\\re z +i\\im z; \\lambda, \\delta)}$, \n\\begin{align*}\n\t\\alpha(\\lambda; \\delta) \n\t\t= \\frac{1}{1-2\\delta\\lambda(\\lambda)},\n\t\\qquad\n\t\\beta(\\lambda; \\delta) \n\t\t= \\frac{1}{1 - 2\\delta\\lambda(-\\lambda) e^{-2\\delta\\lambda}},\n\\end{align*}\n\\label{sym0:residues}and the function $K^+$\\label{sym0:K} satisfies the properties\n\\begin{itemize}\n\t\\item[(i)] $K^+(x) = \\mathcal O \\left( \\frac{e^{-\\pi|x|}}{x} \\right)$ \n\t\tfor $|x| \\geq 1$, and\n\t\\item[(ii)] $|K^+(x)| \\leq C + C \\log\\left(\\frac{1}{|x|}\\right)$ for $|x| < 1$.\n\\end{itemize}\n\nOur study of the boundary values $G_L^+$, $G_R^+$ continues in Chapter \n\\ref{cptr02:GFmapping} as we use \\ref{eq0:GFrep} to understand the mapping\nproperties of $G_L^+$, $G_R^+$ as convolution operators. More specifically, \nwe study the operators $T_{L, \\lambda, u}$, $T_{R, \\lambda, u}$ given by\n\\begin{align} \\label{eq0:Tstar}\n\tT_{L, \\lambda, u} f:= G_L^+(\\dotarg; \\lambda, \\delta)*(uf) \n\t\\qquad \\text{and} \\qquad \n\tT_{R, \\lambda, u} f:= G_R^+(\\dotarg; \\lambda, \\delta)*(uf) \n\\end{align}\nand show that the are bounded operators acting the space \n$\\inn{\\dotarg}L^\\infty(\\mathbb R)$ whose operator norms depend only \non the $\\nm{u}_X$ and not on $\\lambda$. We further show in Chapter \n\\ref{cptr02:GFmapping} that for every \n$f \\in \\inn{\\dotarg} L^\\infty(\\mathbb R)$\nand $u \\in X$ the operators $T_{L, \\lambda, u}$, $T_{R, \\lambda, u}$\nsatisfy the asymptotic behavior\n\\begin{align*}\n\t\\lim_{x\\to-\\infty} T_{L, \\lambda, u} f(x) \n\t\t= \\lim_{x\\to-\\infty} T_{R, \\lambda, u} f(x) \n\t\t= 0\n\\end{align*}\nwhen real $\\lambda \\ne 0$, and \n\\begin{align*}\n\t\\lim_{x\\to-\\infty} \\inn{x}^{-1} T_{L, \\lambda, u} f(x) \n\t\t= \\lim_{x\\to-\\infty} \\inn{x}^{-1} T_{R, \\lambda, u} f(x) \n\t\t= 0\n\\end{align*}\nfor every $\\lambda \\in \\mathbb R$. That $T_{L, \\lambda, u}$, \n$T_{R, \\lambda, u}$ satisfy the above limits is a property we use later to \nprove solutions to the integral equations \\eqref{eq0:JostIE} satisfy the \nasymptotic conditions in \\eqref{eq0:JostDEasymp}.\n\nThe focus for our final chapter on the the Green's functions, Chapter \n\\ref{cptr03:xContin}, is analytically extending $G_L^+$, $G_R^+$ in \nthe variable $x$ to $G_L$ and \n$G_R$ defined on the complex strip $\\mathcal S_\\delta$ and showing that $G_L$, $G_R$ \nhave upper boundary values $G_L^-$, $G_R^-$. Analytically extending $G_L^+$, \n$G_R^+$ is important as it allows us to analytically extend the solutions \n$M_1^+$, $M_e^+$, $N_1^+$, $N_e^+$ to the integral equations \\ref{eq0:JostIE},\nwhich is a prerequisite to showing that solutions to the integral \nequations \\ref{eq0:JostIE} are Jost solutions. While, extending $G_L^+$, $G_R^+$\n(as convolution operators) to the open strip $\\mathcal S_\\delta$ is straight\nforward, showing the existence of the upper boundaries $G_L^-$, $G_R^-$ is \nconsiderably more involved, as it involves working with a singular operator\nthat is reminiscent of the Hilbert transform. In fact, nearly the entirety of\nChapter \\ref{cptr03:xContin} is devoted to proving the existence (in an $L^2$ \nsense) of $G_L^-$ and $G_R^-$.\n\nOur analysis of the Green's functions in \\ref{cptr01:GF} through \n\\ref{cptr03:xContin} allows us to finally prove in Section \\ref{sec4:equiv}\nof Chapter \\ref{cptr04:DM} the equivalence of Jost solutions and solutions to\nthe integral equations \\eqref{eq0:JostIE}. The big pay-off in proving this \nequivalence is that it allows us to consider the Jost solutions as solutions\nto Volterra type integral equations instead of an ordinary differential \nequation on a complex strip involving complex boundary values. Being able to do\nso is invaluable as the theory of Volterra type integral equations is far better \nunderstood (at least by this author) than the theory of such complex ordinary \ndifferential equations. Indeed, it is precisely by treating the Jost solutions \nas solutions to integral equations \\eqref{eq0:JostIE} that we are ultimately \nable in Chapter \\ref{cptr04:DM} to prove that $\\mathscr D$ is well-defined and, \nat least for real $\\lambda$ values away from zero, $\\mathscr D$ is also \nLipschitz continuous.\n\\end{document}\n\n\n\n% {\\color{red}\n% Using \\eqref{eq0:GFrep}, we further show in Chapter \\ref{cptr01:GF} that, when \n% taken as a convolution operator, $G_L^+$ and $G_R^+$ are bounded and continuous \n% operators on $L^1\\cap L^p$ for $p \\in (1, 2]$. This allows us \n% to show in Chapter \\ref{cptr03:xContin} that taken as convolution \n% operators, $G_L$, $G_R$ are analytic in the open strip \n% $\\mathcal S_\\delta = \\{ z\\in \\mathbb C \\,:\\, 0 < z < 2\\delta \\}$.\n\n% Using techniques from harmonic analysis, we show in Chapter \\ref{cptr03:xContin} the \n% existence of the upper boundary values $G_L^-$, $G_R^-$, and study their mapping \n% properties as convolution operators. Doing so is important as it allows us to \n% then prove the equivalence between solutions of the differential equation \n% \\eqref{eq0:SpecProb} satisfying \n% asymptotic conditions \\eqref{eq0:JostDEasymp} and solutions of the integral equations \n% \\eqref{eq0:JostIE}. Proving this equivalence allows us to use the integral equations\n% \\eqref{eq0:JostIE} to prove the existence and uniqueness of solutions to the linear \n% spectral problem \\eqref{eq0:SpecProb} governed by asymptotic conditions \n% \\eqref{eq0:JostDEasymp}.\n% Further, by studying the asymptotics of the solutions to \\eqref{eq0:JostIE}, we \n% are then able to determine in Section \\ref{sec3:IE} that the scattering is then given by the integral \n% formulas\n% \\reversemarginpar\n% \\marginnote{\\color{red} Need to prove $a$, $b$ continuous in $u$. \n% Want to characterize $a$, $b$ and specify spaces for $a$, $b$.}\n% \\begin{align*} \n% \ta(\\lambda)\t\n% \t\t&=\t1 + i \\alpha(\\lambda) \n% \t\t\t\\int_{-\\infty}^x u(x') M_1^+(x',\\lambda) \\, \\mathrm{d}x'\t\\\\\n% \t\\intertext{and}\n% \tb(\\lambda)\t\n% \t\t&=\ti \\beta(\\lambda) \n% \t\t\t\\int_{-\\infty}^x e^{-i\\lambda x'} u(x') M_1^+(x',\\lambda) \\, \\mathrm{d}x'.\n% \\end{align*}\n% \\sout{Since we are able to use the properties of $M_1^+$ to prove that the above integral\n% equations are uniquely solvable}, this completes the Direct Map of the ILW's \n% Inverse Scattering Transform. \n\n\n% The first step in constructing the inverse scattering map involves setting up and \n% solving a Riemann-Hilbert problem (RHP) involving the scattering data. \n% However, in order to construct the correct\n% RHP, we need to first understand the analytic (in $\\lambda$) properties of the \n% scattering data, which means also understanding the analytic (in $\\lambda$) \n% properties of the previously mentioned Jost solutions and Green's functions.  \n% While this dissertation focuses primarily on the Direct Map, a discussion\n% of the analytic properties of the scattering data is provided at the end of \n% this disseration in {\\color{red}?Chapter/Section? ??.??} as a staging point for \n% future research into the ILW's Inverse Scattering Transform.}", "meta": {"hexsha": "bfacc3d218bdff2950d784dfdca93f098ebf157d", "size": 19934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter0-Intro/0.2-DirectMap.tex", "max_stars_repo_name": "ADGC/ilw-dsm-dissertation", "max_stars_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter0-Intro/0.2-DirectMap.tex", "max_issues_repo_name": "ADGC/ilw-dsm-dissertation", "max_issues_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter0-Intro/0.2-DirectMap.tex", "max_forks_repo_name": "ADGC/ilw-dsm-dissertation", "max_forks_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3347826087, "max_line_length": 107, "alphanum_fraction": 0.6613323969, "num_tokens": 7034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4058082331163082}}
{"text": "\n\n    \\filetitle{'...!!...'}{Beginning of aliasing inside descriptions and labels}{modellang/alias}\n\n\t\\paragraph{Syntax in descriptions of variables, shocks, and\nparameters}\\label{syntax-in-descriptions-of-variables-shocks-and-parameters}\n\n\\begin{verbatim}\n'Description !! Alias' Name\n\\end{verbatim}\n\n\\paragraph{Syntax in equations labels}\\label{syntax-in-equations-labels}\n\n\\begin{verbatim}\n'Label !! Alias' Equation;\n\\end{verbatim}\n\n\\paragraph{Description}\\label{description}\n\nWhen used in descriptions of variables, shocks, and parameters, or in\nequation labels, the double exclamation mark starts an alias (but the\nexlamation marks are not included in it). The alias can be used to\nspecify, for example, a LaTeX code associated with the variable, shock,\nparameter, or equation. The aliases can be retrieved from the model code\nby using the appropriate query in the function\n\\href{model/get}{\\texttt{model/get}}.\n\n\\paragraph{Example}\\label{example}\n\n\\begin{verbatim}\n!transition_variables\n    'Output gap !! $\\hat y_t$` Y_GAP\n\\end{verbatim}\n\nIn the resulting model object, the description of the variables\n\\texttt{Y\\_GAP} will be\n\n\\begin{verbatim}\nOutput gap\n\\end{verbatim}\n\nwhile its alias will be\n\n\\begin{verbatim}\n$\\hat y_t$.\n\\end{verbatim}\n\n\n", "meta": {"hexsha": "63e7d2c86d7ebccb95babca792d378a3d1378e9e", "size": 1249, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/modellang/alias.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/modellang/alias.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/modellang/alias.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 25.4897959184, "max_line_length": 97, "alphanum_fraction": 0.7646116894, "num_tokens": 315, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.40580823311630815}}
{"text": "\\begin{document}\n\t\\chapter{Network Representation}\n\n\t\n\t\\section{Complex Networks}\n\t\n\tCommunication networks, transportation systems, social studies, biology and neuroscience all presents some characteristic elements that can be related to a social network. Social networks are structures were social actors interact with each other and through the \\textit{social network analysis} it is possible to undergo deeply on the characterization of the network itself. While social network emerged as a prominent sociology topic in 1908 by Georg Simmel, it was later re-discovered by physicists and mathematically formalized in late 1950s. Through the years many researchers developed newer and more fine-grained models for these networks (Barabási–Albert\\cite{Barabasi1999}, Erdős–Rényi\\cite{Erdos1959}, Watts–Strogatz\\cite{Watts1998}) producing a vast literature on the topic and several unique models that would capture essential properties of different scenarios.\n\t\n\tSocial networks are usually complex networks, networks whose structure features non-trivial topology. Scale-free networks are complex networks of particular interest as they are random graphs (graphs whose degree distribution is regulated by a probability function) governed by a power-law probability function. The first scale-free network to be ever observed and formalized was the WWW network by Barabàsi, A.L. and Albert, R. \\cite{Barabasi1999} which were the first to notice the lack of expressive power of the existing models that were failing to capture essential properties such as the growth factor or the preferential attachment which are characteristic features of real networks.\n\t\n\tThe fundamental results of their work in WWW and, later, in many other real networks, is that some nodes manifest a degree that can be order of magnitudes with respect to other nodes of the network. The terms scale-free was coined by Barabàsi and collaborators to indicate network whose probability distribution looks the same regardless the size of the network. \n\t\n\tSuch probability density function brings some characteristic features unique to scale-free networks that can't be observed on random graph models such as Erdős–Rényi, where degree distribution responds to a Poisson distribution, or Watts-Strogatz model that produces a degree distribution that follows a Dirac delta function. Typical features of a scale-free network are:\n\t\\begin{itemize}\n\t\t\\item Preferential attachment: it's the likelihood expressed by a node of receiving new edges proportional to its degree k and it's often referred as $\\Pi(k)$. In their work, the BA-model assumes the preferential attachment to be a linear probability defined as $$\\Pi(k_i) = \\frac{k_i}{\\sum_{j}k_j}$$ and express the probability that a new node will be connected to node $i$, based on its degree $k$ and it has been demonstrated that with this preferential attachment, the degree probability distribution converges to $$P(k) \\sim k^{\\gamma}, \\gamma = 3$$\n\t\tAs proved in \\cite{Krapivsky2000} by Krapivsky, Redner and Leyvraz, for every $\\Pi(k)$ that is asymptotically linear, the graph is scale free with degree distribution $$P(k) \\sim k^{\\gamma}, 2 < \\gamma < \\infty $$\n\t\t\n\t\t\\item  Small World Property: expresses the fact that the length of any shortest path between a pair of nodes is always small compared to the size of the network. Cohen and Havlin proved that a power-law graph with $2 < \\gamma < 3$ will have diameter $d \\sim \\ln\\ln N$ where $N$ is the order of the network \\cite{Cohen2002}. \n\t\t\n\t\t\\item Clustering: depending on the network topology, scale-free networks may presents many clusters or cliques inside of which the density of links is very high with respect to the number of links that connect the various clusters.\n\t\t\n\t\t\\item Network resilience: disconnecting random nodes from the network, even a large portion, does not impact the connectedness of the graph. Usually high-degree vertices take place in the middle of the network, while lower-degree nodes occupy the peripheral regions.\n\t\\end{itemize}\n\t\n\t\\section{Dynamic Networks}\n\t\n\tThe nature of the Lightning Network implicitly suggests that the network itself should not be considered as a static entity. Instead, due to time constraints over the contracts that compose the links of the network, the system is subject to the phenomenon of \\textit{churn}, which refers to the behavior of some nodes to arrive or depart from the network at time intervals and that has been addressed recently in many systems whose composition evolves through time \\cite{Baldoni2010} \\cite{Ko2008} with a particular attention to P2P systems \\cite{Liben-Nowell2002} \\cite{Mostefaoui}. \n\t\n\tThe strict relationship between time and money in the Lightning Network puts it in an incredibly interesting spot regarding the dynamic properties of it: there must exist channels connecting pair of nodes along a payment path and every node involved in the payment path must be online in the moment a transaction is performed. A third constraint on a payment procedure is that every node involved in the payment process must have enough funds to transfer.\n\t\n\tThe three constraints play a key role in the modeling of the network and put in evidence the dynamic feature of the network itself. Therefore the network is not a static entity but a dynamic one, and a lots of its feature will be shown have similarities with social networks. The dynamicity of a network has lately seen intensive research efforts and a vast literature is available, yet it often results to be very problem-specific and lacks of a universal formal description. An important contribution to this research area was the formalization of \\textit{Time-Varying Graphs}\\cite{Casteigts2012} that is a unified framework that address the main characteristics of a dynamic network, and whose goal is to put in evidence and formally define important concepts that were present in other research areas (delay-tolerant networks, opportunistic networks, real-world complex networks) but not related each other.\n\t\n\t\n\t\\section{Time Varying Graph}\n\n\tA Time-Varying Graph (TVG) is described by a quintuple \\(\\text{TVG} = (V, E, T, \\rho, \\zeta) \\):\n\t\\begin{itemize}\n\t\t\\item a set of nodes \\(V\\).\n\t\t\n\t\t\\item a set of relations between nodes \\(E\\) (edges).\t\n\t\t\n\t\t\\item an alphabet \\(L\\) (optional).\n\t\t\n\t\t\\item a relation \\(E \\subseteq V \\times V \\times L\\) where \\(L\\) are domain-specific labels and can be used (or omitted) to enrich the description of the network.\n\t\t\n\t\t\\item a time span \\( \\mathcal{T} \\subseteq \\mathbb{T}\\) called \\textit{lifespan} with \\(\\mathbb{T}\\) representing the domain of time which usually coincides with the \\(\\mathbb{N}\\) if the system is discrete, \\(\\mathbb{R}^+\\) otherwise.\n\t\t\n\t\t\\item a function \\(\\rho : E \\times \\mathcal{T} \\to \\{0, 1\\} \\) called \\textit{presence} to track the availability of an edge at a given time.\n\t\t\n\t\t\\item a function \\(\\zeta : E \\times \\mathcal{T} \\to \\mathbb{T}\\) called latency function that indicates the time needed to cross an edge at a given date.\n\t\\end{itemize}\n\n\tThe model can also be enriched with two more functions that can capture the nodes dynamic behavior in a way similar to \\(\\rho\\) and \\(\\zeta\\).\n\t\\begin{itemize}\n\t\t\\item a function \\(\\psi : V \\times \\mathcal{T} \\to \\{0, 1\\}\\) called \\textit{node presence function}, expressing the availability of a node at a given time T.\n\t\t\n\t\t\\item a function \\(\\phi : V \\times \\mathcal{T} \\to \\mathbb{T}\\) called \n\t\\end{itemize}\n\t\n\tInside the definition of a time varying graph we have the notion of \\textit{underlying graph}, that is the graph \\(G = (V, E)\\) which is the backbone of the dynamic network. One important thing to notice is that a connected component G doesn't imply the connectivity of the TVG, in fact the TVG could be disconnected for every time instant of its lifespan.\n\t\n\t\\begin{figure}\n\t\t\\begin{subfigure}{0.5\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.65]{example_tvg}\n\t\t\t\\caption{The visual representation of a TVG.}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.5\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.65]{example_underlying}\n\t\t\t\\caption{The underlying graph.}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.5\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.65]{example_tvg_0_1}\n\t\t\t\\caption{Edges availability according to presence function at time interval [0, 1].}\n\t\t\\end{subfigure}\n\t\t\\begin{subfigure}{0.5\\textwidth}\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.65]{example_tvg_2_3}\n\t\t\t\\caption{Edges availability according to presence function at time interval [2, 3].}\n\t\t\\end{subfigure}\n\t\t\\caption{Layers of a Time Varying Graph. Image courtesy of \\cite{Casteigts2012}.}\n\t\\end{figure}\n\t\n\t\\begin{itemize}\n\t\t\\item \\textit{Edge-centric evolution}: every edges has associated a set of the union of all the dates in which an edge \\(e\\) is available. Such set is denoted by \\(I(e)\\) and every element of \\(I\\) is such that \\(I(e) = \\{t \\in \\mathcal{T} | \\rho(e,t) = 1\\}\\), that is, the elements of the set are of the kind \\(I(e) = \\{t_1, t_2, t_3 ... \\}\\) and since they express time intervals it is possible to subdivide them in two sets \\(App(e)\\) and \\(Dis(e)\\), \\textit{appearance and disappearance}, where \\(App(e) = \\{t_n | t_n \\in I(e), n = 2N + 1\\}\\) and \\(Dis(e) = \\{t_n | t_n \\in I(e), n = 2N\\}\\), i.e. every \\(t\\) in an even position is a date of appearance while \\(t\\) in odd position are dates of disappearance.\n\t\t\n\t\t\\item \\textit{Vertex-centric evolution}: nodes spawn and de-spawn causes changes in the configuration of the neighbor for some nodes, and it is expressed through \\textit{sequences of neighborhoods} \\(N_{t_1}(v), N_{t_2}(v), N_{t_3}(v) ...\\). This kind of configuration is not very common in the literature.\n\t\t\n\t\t\\item \\textit{Graph-centric evolution}: it is the situation in which graphs are subject to events (edges appearance and disappearance) that make their topology change. Each of this events happens in a \\textit{characteristic date}, and these dates are sorted in chronological such that \\(S_{\\mathcal{T}}(\\mathcal{G}) = sort(\\cup\\{S_{\\mathcal{T}}(e) : e \\in E\\})\\) with \\( \\mathcal{G}\\) being a TVG. From a global point of view, it is possible to have a look at the evolution of the graph as a sequence of graph snapshot \\(S_{\\mathcal{G}} = G_1, G_2, G_3\\) where \\(G_i\\) is a static snapshot of \\(\\mathcal{G}\\) at time \\(i\\).\n\t\\end{itemize}\n\t\n\tThe time-varying graph framework also put emphasis on the different peculiarity of the different networks that can be modeled as a TVG by providing a classification method based on some particular properties. They are thirteen in total and are \\textit{minimum reachability, all-nodes-reachability, connectivity over time, round connectivity, recurrent connectivity, recurrence of edges, time bounded recurrence of edges, periodicity of edges, constant connectivity, T-interval connectivity, eventual instant-connectivity, eventual instant-routability, complete graph of interaction}.\n\tSuch a classification should help to categorize better a problem, and to help navigating the literature with well defined properties that have been investigated in other works.\n\\end{document}", "meta": {"hexsha": "7eaa214457cc0dc65281080864984f026fc83244", "size": 11126, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "dynamic_networks/dynamic_networks.tex", "max_stars_repo_name": "randomBEAR/master_thesis", "max_stars_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dynamic_networks/dynamic_networks.tex", "max_issues_repo_name": "randomBEAR/master_thesis", "max_issues_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dynamic_networks/dynamic_networks.tex", "max_forks_repo_name": "randomBEAR/master_thesis", "max_forks_repo_head_hexsha": "ee37187abb269fa6b581f9bdf5ba77b7b60b8128", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 115.8958333333, "max_line_length": 912, "alphanum_fraction": 0.7650548265, "num_tokens": 2768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984445, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.40580821555726965}}
{"text": "\\documentclass{article}\n\n\\setlength{\\evensidemargin}{.25in}\n\\setlength{\\oddsidemargin}{.25in}\n\\setlength{\\textwidth}{6.0in}\n%\\setlength{\\parindent}{0.25in}\n\\setlength{\\topmargin}{-0in}\n\\setlength{\\textheight}{8.0in}\n%\\newtheorem{theorem}{Theorem}\n%\\newtheorem{proposition}{Proposition}\n%\\newtheorem{lemma}{Lemma}\n%\\newtheorem{corollary}{Corollary}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\bibliographystyle{siam}\n\n\\title{\\bf An implementation of the Volume Algorithm}\n\\author{Francisco Barahona}\n\\date{June 22, 2000}\n\\maketitle\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Introduction}\n\nHere we describe an implementation of the Volume algorithm (VA) originally\npresented in \\cite{BA}. We focus on the {\\it uncapacitated facility location\nproblem} (UFLP) as an example, see \\cite{BC} for some of the theoretical\nissues. As a first step, a new user should be able to run our code ``as is''.\nThis can also be used as a framework for Lagrangian relaxation. The user would\nhave to modify the files {\\tt ufl.hpp}, {\\tt ufl.cpp}, {\\tt ufl.par}, and {\\tt\ndata}, to produce an implementation for a different problem. The files {\\tt\nvolume.hpp} and {\\tt volume.cpp} are specific to the VA, so the user should\nnot have to change them. We hope to receive reports about bugs and/or\nsuccessful experiences.\n\n\\smallskip\n\nInitially this directory contains the files: {\\tt INSTALL, Makefile,\n  volume.hpp, volume.cpp, ufl.hpp, ufl.cpp, ufl.par, data, doc.ps}. See the\n  {\\tt INSTALL} file for instructions on installation.\n\nNow we present the linear program used in \\cite{BC}. This is\n\\begin{eqnarray}\n\\min \\sum c_{ij} x_{ij} & + & \\sum f_i y_i  \\label{fp1} \\\\\n\\sum_i x_{ij} & = & 1, \\hbox{ for all } j,  \\label{fp2} \\\\\nx_{ij} & \\leq & y_i, \\hbox{ for all } i, j, \\label{fp3} \\\\\nx_{ij} & \\ge  & 0, \\hbox{ for all } i, j,   \\label{fp4} \\\\ \ny_i    & \\le  & 1, \\hbox{ for all } i.      \\label{fp5}\n\\end{eqnarray}\n\nHere the variables $y$ correspond to the locations, and the variables $x$\nrepresent connections between customers and locations. Let $u_j$ be a set of\nLagrange multipliers for equations (\\ref{fp2}). When we dualize equations\n(\\ref{fp2}), we obtain the {\\it lagrangian problem}\n\\begin{eqnarray*}\nL(u) & = & \\min \\sum \\bar c_{ij} x_{ij} + \\sum \\bar f_i y_i + \\sum u_j, \\\\\nx_{ij} & \\le & y_i, \\hbox{ for all } i, j, \\\\\nx_{ij} & \\ge & 0, \\hbox{ for all } i, j, \\\\\ny_i    & \\le & 1, \\hbox{ for all } i.\n\\end{eqnarray*}\n\n\\noindent Where the {\\it reduced costs} $\\bar c_{ij}=c_{ij}-u_j$, and\n$\\bar f_i = f_i$. We apply the VA to maximize $L(\\cdot)$ and to produce a\nprimal vector $(\\bar x, \\bar y)$ that is an approximate solution of\n(\\ref{fp1})-(\\ref{fp5}). Using this primal information we run a heuristic\nthat gives an integer solution.\n\nIn what follows we describe the different files in this directory.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{ufl.par}\n\nThis file contains a set of parameters that control the algorithm and contain\nsome information about the data. Each line has the format\n\n{\\tt keyword=value}\n\n\\noindent where {\\tt keyword} should start in the first column. If we add any\nother character in the first column, the line is ignored or considered as a\ncomment. The file looks as below\n\n\\bigskip\n\\begin{verbatim}\nfdata=data\n*dualfile=dual.txt\ndual_savefile=dual.txt\nint_savefile=int_sol.txt\nh_iter=100\n\nprintflag=3\nprintinvl=5\nheurinvl=10\n\ngreentestinvl=1\nyellowtestinvl=4\nredtestinvl=10\n\nlambdainit=0.1\nalphainit=0.1\nalphamin=0.0001\nalphafactor=0.5\nalphaint=50\n\nmaxsgriters=2000\nprimal_abs_precision=0.02\ngap_abs_precision=0.\ngap_rel_precision=0.01\ngranularity=0.\n\\end{verbatim}\n\nThe first group of parameters are specific to the UFLP and the user should\ndefine them. {\\tt fdata} is the name of the file containing the data. {\\tt\ndualfile} is the name of a file containing an initial dual vector. If we add\nan extra character at the beginning ({\\tt *dualfile}) this line is ignored,\nthis means that no initial dual vector is given. {\\tt dual\\_savefile} is the\nname of a file where we save the final dual vector. If this line is missing,\nthen the dual vector is not saved. {\\tt int\\_savefile} is the name of a file\nto save the best integer solution found by the heuristic procedure, if this\nline is missing, then this vector is not saved. {\\tt h\\_iter} is the number of\ntimes that the heuristic is run after the VA has finished.\n\nThe remaining parameters are specific to the VA. See the {\\tt VOL\\_parms.html}\nfile for their documentation (this file will be created after doing a `make\ndoc` or it's available on the Internet).\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{data}\n\nThe file {\\tt data} has the following format. On the first line we have the\nnumber of possible locations and the number of customers. On the next lines,\nthe cost of opening each location appears, one cost per line. Then each of the\nremaining lines is like\n\n$\ni \\quad j \\quad d_{ij},\n$\n\n\\noindent where $i$ refers to a location, $j$ refers to a customer, and\n$d_{ij}$ is the cost of serving customer $j$ from location $i$. The indices\n$i$ and $j$ start from 1. If a pair $i,j$ is missing then the cost $d_{ij}$ is\nset to $10^7$.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{ufl.hpp}\n\nThis file contains C++ classes specific to the UFLP.\n\nFirst we have a class of parameters specific to the UFLP. The description\nof these parameters appears in the preceding section.\n\n\\begin{verbatim}\nclass UFL_parms {\npublic:\n   string fdata;         // file with the data\n   string dualfile;      // file with an initial dual solution\n   string dual_savefile; // file to save final dual solution\n   string int_savefile;  // file to save primal integer solution\n   int h_iter;           // number of times that the primal heuristic will be\n                         // run after termination of the volume algorithm\n   \n   UFL_parms(const char* filename);\n   ~UFL_parms() {}\n};\n\\end{verbatim}\n\nBefore the next class we should mention the classes {\\tt VOL\\_dvector} and\n{\\tt VOL\\_ivector} defined in {\\tt Volume.hpp}. The pseudo-code below\nillustrates their use. \n\n\\begin{verbatim}\nint n=100; \nVOL_dvector x(n);  // a double vector with n entries \nx=0.;              // sets to 0. all entries of x \nVOL_dvector y;     // a double vector, it size remains to be set \ny.allocate(n);     // size is set\ny=x;               // copy each entry of x into y \nVOL_dvector z(y);  // a double vector of the same size as y, \n                   // all entries of y are copied into z \nx[0]=-1;           // first entry of x is set to -1 \ny[0]=x[0];         // copy first entry of x into first entry of y\n\\end{verbatim}\n\nThe class {\\tt VOL\\_ivector} is used for vectors of {\\tt int}. One can do the\nsame operations as for {\\tt VOL\\_dvector}.\n\nThen we have a class containing the data for the UFLP.\n\n\\begin{verbatim}\nclass UFL\\_data { // original data for uncapacitated facility location\npublic:\n   VOL_dvector fcost; // cost for opening facilities\n   VOL_dvector dist;  // cost for connecting a customer to a facility\n   VOL_dvector fix;   // vector saying if some variables should be fixed\n                      // if fix=-1 nothing is fixed\n   int ncust, nloc;   // number of customers, number of locations\n   VOL_ivector ix;    // best integer feasible solution so far\n   double      icost; // value of best integer feasible solution \npublic:\n   UFL_data() : icost(DBL_MAX) {}\n   ~UFL\\_data() {}  \n};\n\\end{verbatim}\n\nThen we have\n\n\\begin{verbatim}\nclass UFL_hook : public VOL_user_hooks {\npublic:\n   // for all hooks: return value of -1 means that volume should quit\n   // compute reduced costs\n   int compute_rc(void * user_data, \n                  const VOL_dvector& u, VOL_dvector& rc);\n   // solve lagrangian problem\n   int solve_subproblem(void * user_data, \n                        const VOL_dvector& u, const VOL_dvector& rc,\n                        double& lcost, VOL_dvector& x, VOL_dvector&v,\n                        double& pcost);\n   // primal heuristic\n   // return DBL_MAX in heur_val if feas sol wasn't/was found \n   int heuristics(void * user_data, const VOL_problem& p, \n                  const VOL_dvector& x, double& heur_val);\n};\n\\end{verbatim}\n\nHere the function {\\tt compute\\_rc} is used to compute reduced costs. In the\nfunction {\\tt solve\\_subproblem} we solve the lagrangian problem. In {\\tt\nheuristics} we run a heuristic to produce a primal integer solution.\n\nFinally in this file we have {\\tt UFL\\_parms::UFL\\_parms(const char\n*filename)}, where we read the values for the members of {\\tt UFL\\_parms}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{ufl.cpp}\n\nThis file contains several functions that we describe below.\n\nFirst we have {\\tt int main(int argc, char* argv[])}. In here we initialize\nthe classes described in {\\tt ufl.hpp}, and read the data. Then {\\tt\nvolp.psize()} is set to the number of primal variables, and {\\tt volp.dsize()}\nis set to the number of dual variables. Then we check if a dual solution is\nprovided and if so we read it.\n\nFor the UFLP all relaxed constraints are equations, so the dual variables are\nunrestricted. In this case we do not have to set bounds for the dual\nvariables. If we have inequalities of the type $ax \\ge b$, then we have to set\nthe lower bounds of their dual variables equal to 0. If we had constraints of\nthe type type $ax \\le b$, then we have to set the upper bounds of their\nvariables equal to 0. This would be done as in the pseudo-code below.\n\n\\begin{verbatim}\n// first the lower bounds to -inf, upper bounds to inf \nvolp.dual_lb.allocate(volp.dsize);\nvolp.dual_lb = -1e31;\nvolp.dual_ub.allocate(volp.dsize);\nvolp.dual_ub = 1e31;\n// now go through the relaxed constraints and change the lb of the ax >= b\n// constrains to 0, and change the ub of the ax <= b constrains to 0.\nfor (i = 0; i < volp.dsize; ++i) {\n   if (\"constraint i is '<=' \") {\n      volp.dual_ub[i] = 0;\n   }\n   if (\"constraint i is '>=' \") {\n      volp.dual_lb[i] = 0;\n   }\n}\n\\end{verbatim}\n\nThe function {\\tt volp.solve} invokes the VA. After completion we compute the\nviolation of the fractional primal solution obtained. This vector is {\\tt\npsol}. Then we check if the user provided the name of a file to save the dual\nsolution. If so, we save it. Then we run the primal heuristic using {\\tt psol}\nas an input. Notice that this heuristic has also been run periodically during\nthe execution of the VA. Then if the user has provided the name of a file to\nsave the integer heuristic solution, we do it. Finally the values of the\nsolutions and some statistics are printed.\n\nThe next function is {\\tt void UFL\\_read\\_data(const char* fname, UFL\\_data\\&\ndata)}, where we read the data. {\\tt data.nloc} is the number of locations,\n{\\tt data.ncust} is the number of customers. {\\tt data.fcost} is a vector\ncontaining the cost of opening each location. {\\tt data.dist} is a vector\ncontaining the cost of serving customers from facilities. All entries are\ninitialized to $10^7$ and then particular entries are being set with the\nstatement\n\n{\\tt dist[(i-1)*ncust + j-1]=cost;}\n\n\\noindent where {\\tt i} is the index of a location and {\\tt j} is the index\nof a customer. Here the indices start from 1. Finally we have a vector {\\tt\ndata.fix} associated with the locations. A particular entry is set to 0 if the\nlocation should be closed, it is set to 1 if it should be open, and it is set\nto -1 if this variable is free. Initially all entries are set to -1.\n\nIn the function \n\n{\\tt double solve\\_it(void * user\\_data, const double* rdist, \nVOL\\_ivector\\& sol)}\n\n\\noindent we solve the lagrangian problem.\nWe receive the data and reduced costs as input and return a primal vector. The\nsolution is in the vector {\\tt sol}. Its first {\\tt n} entries correspond to\nthe locations, then all remaining entries correspond to connections between\nlocations and customers.\n\nIn the function \n\n{\\tt int UFL\\_hook::compute\\_rc(void * user\\_data, const VOL\\_dvector\\& u, \nVOL\\_dvector\\& rc)}\n\n\\noindent we compute the reduced costs. They will be used to solve the\nlagrangian problem. \n\nIn the function \n\n\\begin{verbatim}\n   int \n   UFL_hook::solve_subproblem(void *user_data, \n                              const VOL_dvector& u, const VOL_dvector& rc,\n                              double& lcost, VOL_dvector& x, \n                              VOL_dvector& v, double& pcost)\n\\end{verbatim}\n\n\\noindent we compute the lagrangian value, we call {\\tt solve\\_it}, we compute\nthe objective value and the vector $v$ defined as follows. If $\\hat x$ is the\nprimal solution given by {\\tt solve\\_it}, and $Ax \\sim b$ is the set of\nrelaxed constraints, then the difference $v$ is $$v = b - A \\hat x.$$\n\nThe last function in this file is\n\\begin{verbatim}\n   int \n   UFL_hook::heuristics(void * user_data, const VOL_problem& p,\n                        const VOL_dvector& x, double& icost)\n\\end{verbatim}\n\n\\noindent where we run the following simple heuristic. \nGiven a fractional solution $(\\bar x, \\bar y)$, let $\\bar y_i$ be the variable\nassociated with location $i$. We pick a random number $r \\in [ 0, 1 ]$ and if\n$r < \\bar y_i$ facility $i$ is open, and closed otherwise. We repeat this for\nevery facility, then given the set of open facilities we find a minimum cost\nassignment of customers. This function is invoked periodically in the VA and\nby the main program after the VA has finished.\n\n\n\\bibliography{ufldoc}\n\n\\end{document}\n\n\n", "meta": {"hexsha": "e94c985ebc2d15bbe6d6dd61d42ad322a834f18a", "size": 13574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "gsa/wit/COIN/Vol/Doc/ufldoc.tex", "max_stars_repo_name": "kant/CMMPPT", "max_stars_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-25T05:25:23.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-25T05:25:23.000Z", "max_issues_repo_path": "gsa/wit/COIN/Vol/Doc/ufldoc.tex", "max_issues_repo_name": "kant/CMMPPT", "max_issues_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-09-04T17:34:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-16T08:10:57.000Z", "max_forks_repo_path": "gsa/wit/COIN/Vol/Doc/ufldoc.tex", "max_forks_repo_name": "kant/CMMPPT", "max_forks_repo_head_hexsha": "c64b339712db28a619880c4c04839aef7d3b6e2b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2019-07-22T19:01:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T15:36:11.000Z", "avg_line_length": 38.5625, "max_line_length": 78, "alphanum_fraction": 0.6863120672, "num_tokens": 3651, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341027751814, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4057853346022107}}
{"text": "\\documentclass[aspectratio=169]{beamer}\n\\usetheme[]{msubeamer}\n\\usepackage[T1]{fontenc}\n\\usepackage[backend=bibtex,sorting=none]{biblatex}\n\\addbibresource{mybeamer.bib} \n\\usepackage{multirow}\n\\usepackage[ruled,linesnumbered]{algorithm2e}\n\\usepackage{algorithmic}\n\\usepackage{subfigure}\n\\usepackage{float}\n\\usepackage{epstopdf}\n%\\setbeamerfont{footnote}{size=\\small}\n\\begin{document}\n\t\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\xdefinecolor{dred}{rgb}{0.6, 0.0, 0.0}\n\\setbeamercolor{math text}{fg=dred}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\title[Adam-CBO]{A consensus-based global optimization method with adaptive momentum estimation}\n\\maketitleframe\n\\begin{frame}\n\\frametitle{Machine learning tasks}\n\nHighly nonconvex unconstrained optimization problem\n\\begin{align*}\nx^* = \\arg\\min_{x\\in \\mathbb{R}^d} f(x)\n\\end{align*}\nwith the loss function\n\\begin{equation*}\nf(x) = \\frac{1}{n}\\sum_{i=1}^n f_i(x) = \\frac{1}{n}\\sum_{i=1}^n\\|\\mathcal{N}_x(\\hat{x})-\\hat{y}\\|\n\\end{equation*}\n\\begin{itemize}\n\t\\item[] $x$ is the parameter vector\n\t\\item[] $\\mathcal{N}_x$ represents a neural network representation\n\t\\item[] $(\\hat{x}_i,\\hat{y}_i)_{i=1}^n$ is a set of labeled data\n\t\\item[] $\\|\\cdot\\|$ is the $L^2$ distance\n\t\\item[] \\textcolor{red}{$d\\gg 1$}\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}<beamer>\n\\frametitle{\\textbf{Outline}}\n\\tableofcontents[]\n\\end{frame}\n\n\\section{Optimization methods: Zero-order or first-order?}\n\n\\begin{frame}\n\\frametitle{First-order methods}\n\n\\begin{itemize}\n\t\\item gradient descent method\n\t\\begin{equation*}\n\tx^{t+1} = x^t - \\alpha \\nabla f(x^t)\n\t\\end{equation*}\t\n\twith $\\alpha$ being the learning rate\n\t\\item stochastic gradient descent (SGD) method\n\t\\begin{equation*}\n\t\tx^{t+1} = x^t - \\alpha \\nabla f_i(x^t)\n\t\\end{equation*}\t\n\t\\item SGD method with momentum term \\footfullcite{Qian1999Jan}\n\t\\begin{align*}\n\t\t&x^{t+1} = x^t - m^t\\\\\n\t\t&m^t = -\\gamma m^{t-1} + \\alpha \\nabla f_i(x^t)\n\t\\end{align*}\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Cont'd}\n\n\\begin{itemize}\n\t\\item Adaptive momentum method (Adam) \\footfullcite{kingma2014adam} \n\t\\begin{align*}\n\t&x^{t+1} = x^t - \\gamma \\frac{\\hat{m}^t}{\\sqrt{\\hat{v}^t}+\\epsilon}\\\\\n\t&m^t = \\beta_1 m^{t-1} + (1-\\beta_1) \\nabla f(x^t), \\quad \\hat{m}_t = \\frac{m_t}{1-\\beta_1^t}\\\\\n\t&v^t = \\beta_2 v^{t-1} + (1-\\beta_2) \\nabla^2 f(x^t), \\quad \\hat{v}_t = \\frac{v_t}{1-\\beta_1^t}\n\t\\end{align*}\n\twhere $0<\\beta_1,\\beta_2<1$\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{First-order methods}\n\n\\begin{itemize}\n\t\\item mostly have problems with loss functions containing large noise or non-differentiable units\n\t\\item gradient tends to explode or vanish as the neural network gets deeper\\footfullcite{hanin2018neural}\n\t\\item are easily influenced by the loss landscape\\footfullcite{liu2020bad}\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Zero-order methods: Gradient-free}\n\t\n\t\\begin{itemize}\n\t\t\\item Nelder-Mead method\n\t\t\\item genetic algorithm\n\t\t\\item simulated annealing method\n\t\t\\item particle swarm optimization\n\t\t\\item \\textcolor{red}{consensus based optimization (CBO) method} \\footfullcite{carrillo2018analytical}\\footfullcite{totzeck2018numerical}\\footfullcite{pinnau2017consensus}\n\t\\end{itemize}\n\\end{frame}\n\n\\section{CBO method}\n\\begin{frame}\n\t\\frametitle{Original CBO method}\n\t\n   Interacting particles during the dynamic evolution\n   \\begin{itemize}\n   \t\\item tend to their weighted average\n   \t\\item undergo fluctuation due to the random noise \n   \\end{itemize}\n\n\tN particles $X^i$, $i =1, \\cdots N$\n   \\begin{equation*}\n   \t\t\\dot X^i = -\\lambda (X^i - \\bar{x}^*) +\\sigma \\textcolor{red}{|X^i-\\bar{x}^*|} \\dot W^i_t\n   \\end{equation*}\n   \\begin{itemize}\n   \t\\item[] weighted average $\\bar{x}^* = \\frac{1}{\\sum_{i=1}^N e^{-\\beta L(X^i)}}\\sum_{i=1}^N X^i e^{-\\beta L(X^i)}$ \n   \t\\item[] cost (loss) function $L(x)$ to be optimized\n   \t\\item[] white noise $\\dot W_t$\n   \\end{itemize}\n   Discretization of the above system with unit stepsize \n   \\begin{equation*}\n   \t\tX^i_{t+1} =  X^i_{t} -\\lambda (X^i - \\bar{x}^*) +\\sigma \\textcolor{red}{|X^i-\\bar{x}^*|}  dW^i_t\n   \\end{equation*}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Curse of dimensionality (CoD)}\n\n\\begin{itemize}\n\t\\item Exponential convergence rate under dimension-dependent conditions \\footfullcite{carrillo2018analytical}\n\t\\item The larger the dimension, the smaller the learning rate (\\textcolor{red}{CoD})\n\t\\item Replacement of the isotropic geometric Brownian motion with the component-wise one \\footfullcite{carrillo2019consensus}\n\t\\begin{equation*}\n\tX^i_{t+1} =  X^i_{t} -\\lambda (X^i - \\bar{x}^*) +\\sigma \\textcolor{red}{(X^i-\\bar{x}^*)}  dW^i_t\n\t\\end{equation*}\n\t\\item[] Random mini-batch: $\\mathcal{O}(N) \\rightarrow \\mathcal{O}(\\frac{N}{M})$\n\t\\item Convergence to the global minimizer with dimension-independent parameters \\footfullcite{ha2019convergence}\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Some practical issues in CBO}\n\t\\begin{itemize}\n\t\t\\item \\textcolor{red}{the initial data need to be well-chosen}\n\t\t\\item difficult to optimize high dimensional no-convex function (Rastrigin Function over $20$ dimension)\n\t\t\\item difficult to optimize deep neural networks with many parameters\n\t\\end{itemize}\n\\end{frame}\n\\section{Adam-CBO Method}\n\\begin{frame}\n\t\\frametitle{First-order momentum}\n\t\n\t\\begin{itemize}\n\t\t\\item[] The same system without random term but with inertial effect\n\t\t\\begin{equation*}\n\t\t\\sigma \\ddot X^i_t + \\dot X^i_t = -(X_t- x^*) , \\quad i=1,\\cdots,N\n\t\t\\end{equation*}\n\t\t\\item[] An equivalent first-order system\n\t\t\\begin{align*}\n\t\t&\\dot X_t^i = -M_t^i \\\\\n\t\t&\\sigma \\dot M_t^i + M_t^i = X_t^i - x^*\n\t\t\\end{align*}\n\t\t\\item[] Discretization\n\t\t\\begin{align*}\n\t\t&X^i_{t+1} = X_t^i -\\delta t M^i_{t+\\frac{1}{2}}\\\\\n\t\t&M^i_{t+\\frac{1}{2}} = \\frac{\\sigma - \\delta t}{\\sigma+ \\delta t}M_{t-\\frac{1}{2}} + \\frac{2\\delta t}{\\sigma  + \\delta t } (X_t^i - x^*)\n\t\t\\end{align*}\n\t\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Cont'd}\n\n\\begin{itemize}\n\t\\item[] Relabel $M^i_{t+\\frac{1}{2}}$ by $M^i_{t+1}$\n\t\\begin{equation*}\n\t\\begin{aligned}\n\t&X^i_{t+1} = X_t^i - \\lambda M^i_{t+1}  \\\\\n\t\\ &M^i_{t+1} = \\beta_1 M^i_{t} + (1-\\beta_1) (X_t^i - \\bar{x}^*)\n\t\\end{aligned}\n\t\\end{equation*}\n\twith $\\lambda = \\delta t $ and $\\beta_1 =\\frac{\\sigma - \\delta t}{\\sigma+ \\delta t} =1 - \\frac{2\\delta t }{\\sigma  + \\delta t }  $\n\t\\item[] $\\beta_1$ is near 1 ($=0.9$ in practice) since $\\delta t$ is small\n\t\\item[] Add the stochastic term\n\t\t\\begin{equation*}\n\t\\begin{aligned}\n\t&X^i_{t+1} = X_t^i - \\lambda M^i_{t+1} + \\sigma_t  W^i_t \\\\\n\t\\ &M^i_{t+1} = \\beta_1 M^i_{t} + (1-\\beta_1) (X_t^i - \\bar{x}^*)\n\t\\end{aligned}\n\t\\end{equation*}\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Expectation}\n\n\\begin{itemize}\n\t\\item[] A recursive argument of $M_t^i$ yields\n\t\\begin{equation*}\n\t\\begin{aligned}\n\tM^i_t & = \\beta_1 M^i_{t-1} + (1-\\beta_1)(X^i_{t-1} - x^*)\\\\\n\t& = \\beta_1 (\\beta_1 M^i_{t-2} + (1-\\beta_1) (X_{t-1}^i - x^*)) + (1-\\beta_1) (X^i_{t-2} - x^*)\\\\\n\t& = (1-\\beta_1) \\sum_{k=0}^{t-1} \\beta_1^{t-k} (X_{k}^i - x^*).\n\t\\end{aligned}\n\t\\end{equation*}\n\t\\item[] Stationary assumption of $X_{k}^i - x^*$ w.r.t. $k$ leads to\n\t\\begin{equation*}\n\t\\begin{aligned}\n\t\\mathbb{E} [M^i_t] & =(1-\\beta_1)   \\mathbb{E} [\\sum_{k=0}^t \\beta_1^{t-k} (X_{k}^i - x^*)] \\\\\n\t&= (1-\\beta_1^t)  \\mathbb{E}[ X_{t}^i - x^* ]\n\t\\end{aligned}\n\t\\end{equation*}\n\t\\item[] Unbiased estimation of first-order moment\n\t\\[\n\t\\hat{M}^i_{t+1} = \\frac{M^i_{t+1}}{(1-\\beta_1^t)}\n\t\\]\n\t\\end{itemize}\t\n\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Second-order momentum $\\mathbb{E}(|X^i_t-x^*|^2)$}\n\t\n\t\\begin{itemize}\n\t\t\\item Define $V^i_t  = \\beta_2 V^i_{t-1} + (1-\\beta_2) |X^i_t - x^*|^2$\n\t\t\\item[] Application of the same argument for $\\mathbb{E}[X^i_t]$ yields\n\t\t\\begin{equation*}\n\t\t\\mathbb{E}[V^i_t] = (1-\\beta_2^t) \\mathbb{E}[|X^i_t-x^*|^2]\n\t\t\\end{equation*}\n\t\t\\item[] Unbiased estimation of $\\mathbb{E}(|X^i_t-x^*|^2)$\n\t\t\\[\\hat{V}^i_t = \\frac{V^i_t}{1-\\beta_2^t}\\]\n\t\t\\item Modify the model\n\t\t\\begin{equation*}\n\t\t\tX^i_{t+1} = X_t^i - \\frac{\\lambda \\hat{M}^i_{t+1}}{\\sqrt{\\hat{V}^i_{t+1}} + \\epsilon} + \\sigma^ t  W_t^i\n\t\t\\end{equation*}\n\t\twith a small $\\epsilon$ ($1e-8$) to avoid the vanishing of denominator\n\t\\end{itemize}\n\n\\end{frame}\n\n\\section{Linear stability analysis of Adam-CBO}\n\\begin{frame}\n\\small{\n\\begin{algorithm}[H]\n\\KwIn{$\\lambda$, $N$, $M$, $t_N$, $\\beta_1$, $\\beta_2$}\n\n  Initialize $X^i_0$, $i = 1,\\cdots N$ by the uniform distribution;\n  \n  Initial $M^i_0,V^i_0 =0$;\n  \\tcc{Initialize first order and second order moments.}\n  \n  \\For{$t = 0$ \\textbf{to} $t_N$ }{\n    Generate a random permutation of index $\\{1,2,\\cdots,N\\}$ to form set  $P_k$;\n    \n    Generate batch set of particles in order of $P_k$ as $B^1,\\cdots B^{\\frac{N}{M}}$ with each batch having $M$ particles;\n    \n    \\For{$j = 0$  \\textbf{to} $\\frac{N}{M}$}{\n        Update $x^* =\\sum\\limits_{k\\in B^j} \\frac{X_t^k\\mu^k_t}{\\sum\\limits_{i\\in B^j} \\mu_t^i }$, where $\\mu_t^i = \\omega_f^\\alpha (X_t^i)$;\n        \n        Update $X^i_t$ for $j \\in B^j$ as follows\n        \n        $\n        M^i_{t+1} = \\beta_1 M_{t}^i +(1-\\beta_1) (X^i_t-x^*) \\quad \\quad \\hat{M}^i_{t+1} = M^i_{t+1}/(1-\\beta_1^t)\n        $;\n        \n        $\n        V^i_{t+1} = \\beta_2 V_{t}^i +(1-\\beta_2) (X^i_t-x^*)^2 \\quad \\quad  \\hat{V}^i_{t+1} = V^i_{t+1}/(1-\\beta_2^t)\n        $;\n        \n        $\n        X^i_{t+1} = X^i_t - \\lambda \\hat{M^i_t}/(\\sqrt{\\hat{V^i_t}}+\\epsilon) + \\sigma^t \\sum_{k = 1}^d \\vec{e}_k z_i  %\\quad z_i\\; \\text{ is a random variable}\n        $.\n    }\n    }\n    \\KwOut{$X_{t_N}^i, \\quad i = 1\\cdots N$}\n\\end{algorithm}\n}\n\\end{frame}\n\n\\begin{frame}\n\t\\frametitle{Linear stability analysis of Adam-CBO}\n\t\n\t Continuous formulation without the stochastic term\n\t\\begin{align*}\n&\\dot m = (\\beta_1 -1) m + (1-\\beta_1) (x-\\bar{x})\\\\\n&\\dot v = (\\beta_2 -1) v + (1-\\beta_2) (x-\\bar{x})^2\\\\\n&\\hat{m} = \\frac{m}{1-\\beta_1^t} \\quad  \\hat{v} = \\frac{v}{1-\\beta_2^t} \\\\\n&\\dot x =  - \\lambda \\frac{\\hat{m}}{\\sqrt{\\hat{v}}+\\epsilon}\n\t\\end{align*}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Linearization around $m = 0, x = \\bar{x}, v = 0 $}\n\t\\begin{align*}\t\n\t&\\dot m = -(1-\\beta_1) m + (1-\\beta_1) \\tilde{x}\\\\\n\t&\\dot v = -(1-\\beta_2)v \\\\\n\t&\\dot {\\tilde{x}} = -\\frac{\\lambda }{(1-\\beta_1^t)\\epsilon}m \\rightarrow -\\frac{\\lambda}{\\epsilon} m = -\\mu m  \\quad (t \\rightarrow \\infty)\n\t\\end{align*}\n\twith $\\tilde{x} = x - \\bar{x}$ and $\\mu=\\lambda/\\epsilon$, and in a vector form\n\t\\begin{equation*}\n\t\\begin{aligned}\n\t\\mathrm{d}_t\t\\left(\\begin{matrix}\n\t\t\tm \\\\ v \\\\ \\tilde x\n\t\t\\end{matrix}\\right) = \n\t\\left(\\begin{matrix}\n\t\t-(1-\\beta_1) & 0 & 1-\\beta_1\\\\ \n\t\t0 &  -(1-\\beta_2) & 0  \\\\\n\t\t -\\mu & 0 & 0  \n\t\\end{matrix}\\right) \n\t\\left(\\begin{matrix}\n\tm \\\\ v \\\\ \\tilde x\n\t\\end{matrix}\\right)\n\t\\end{aligned}\n\t\\end{equation*}\n\\end{frame}\n\n\\begin{frame}\n\\begin{theorem}\n\tThe Adam-CBO method generates a sequence that converges to the optimal solution with rates independent of the learning rate $\\lambda$. \n\t\\begin{proof}\n\tEigenvalues of the matrix on the right-hand side are $\\beta_2-1$ and $\\frac{1}{2}( \\beta_1 - 1 \\pm i  \\sqrt{1-\\beta_1}\\sqrt{\\beta_1-1+4\\mu})$ (typically $1-\\beta_1\\ll 4\\mu$), respectively. Thus, $m,v,\\tilde{x}$ decay to $0$  exponentially with rate $\\beta_2 -1 $ when $\\beta_1>2\\beta_2+1$ and with rate $\\frac{1}{2}(\\beta_1-1)$ when $\\beta_1 < 2 \\beta_2 + 1$ in an oscillatory way. \n\t\\end{proof}\n\\end{theorem} \t\n\n\\begin{itemize}\n\t\\item $\\beta_1 = 0.9$ and $\\beta_2 = 0.99$\n\t\\item Continuous formuation of CBO without random noise\n\t\\begin{equation*}\n\t\\dot x = - \\lambda (x- \\bar{x})\n\t\\end{equation*}\n\t\\item The decay rate of the CBO method depends exponentially on the learning rate $\\lambda$\n\\end{itemize}\n\n\\end{frame}\n\n\\section{Numerical results}\n\\subsection{Rastirgin function}\n\\begin{frame}\n\t\\frametitle{Rastrigin function}\n\\begin{columns}\n\\column{0.5\\textwidth}\n\\begin{equation*}\n\\begin{aligned}\n\t\tf(x) &= \\frac{1}{d} \\sum_{i=1}^d \\left[(x_i-B)^2 \\right.\\\\\n\t\t &\\left.-10\\cos(2\\pi (x_i-B)) + 10\\right] + C\n\\end{aligned}\n\\end{equation*}\nwith $B = \\arg \\min f(x)$ and $C= \\min f(x)$ \n\\column{0.5\\textwidth}\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics[width=1.1\\linewidth]{Figure/R_function}\n\t%\\caption{$d=2$ and $B=C=0$}\n\t\\end{figure}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Massive local minima of Rastrigin function}\n\n\\begin{itemize}\n\t\\item Exponential growth of the number of local minima: $5^d$\n\t\\item Number of minima is $5^{1000}\\approx 10^{690}$, when $d=1000$\n\t\\begin{table}[ht]\n\t\t\n\t\t\\centering\\begin{tabular}{|c|c|c|c|c|c|}\n\t\t\t\\hline\n\t\t\td & 1 & 2 & 30 & 100 & 1000 \\\\\n\t\t\t\\hline\n\t\t\tNumber of local minima & $5$ & $5^2$ & $5^{30}$ & $5^{100}$ & $5^{1000}$\\\\\n\t\t\t\\hline \n\t\t\\end{tabular}\n\t\t\\caption{Number of local minima in terms of dimension}\n\t\\end{table}\n\\end{itemize}\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Comparison with different random processes}\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|c|}\n\t\t\\hline\n\t\t\\multirow{2}*{$d$}&\n\t\t\\multirow{2}*{$N$}&\n\t\t\\multirow{2}*{$M$}&\\multicolumn{3}{c|}{CBO}\\\\\n\t\t\\cline{4-6}\n\t\t~& ~ & ~ &  $\\mathcal{N}(0,1)$&$\\mathcal{U}(-1,1)$ &Wiener process  \\\\\n\t\t\\hline \n\t\t2  & 50 & 40 & 100\\% & 100\\% & 99\\% \\\\\n\t\t10 & 50 & 40 & 100\\% & 100\\% & 2\\%  \\\\\n\t\t20 & 50 & 40 & 98\\%  & 22\\%  & 0\\%  \\\\\n\t\t20 & 50 & 20 & 66\\%  & 2\\%   & 0\\%  \\\\\n\t\t30 & 50 & 40 & 26\\%  & 0\\%   & 0\\%  \\\\\n\t\t30 & 500&5   &  0\\%  & 0\\%   & 0\\%  \\\\\n\t\t%30 & 500 & 400 &     & 0\\%   &  \\%  \\\\\n\t\t\\hline\n\t\t\\multirow{2}*{$d$}&\n\t\t\\multirow{2}*{$N$}&\n\t\t\\multirow{2}*{$M$}&\\multicolumn{3}{c|}{Adam-CBO}\\\\\n\t\t\\cline{4-6}\n\t\t~& ~ & ~ &  $\\mathcal{N}(0,1)$& $\\mathcal{U}(-1,1)$ &Wiener process  \\\\\n\t\t\\hline\n\t\t30 & 500  & 5  & 99\\% & 100\\% & 0\\% \\\\\n\t\t100& 5000 & 5  & 100\\% & 100\\% & 0\\%\\\\\n\t\t1000& 8000 & 50 & 92\\% & 20\\% &0\\%\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\t\n\\end{frame}\n\\begin{frame}\n\\frametitle{$\\lambda = 0.1$, and $\\sigma^t= 0.99^{\\frac{t}{20}}$}\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|}\n\t\t\\hline\n\t\t\\multirow{2}*{$d$}&\n\t\t\\multirow{2}*{$N$}&\n\t\t\\multirow{2}*{$M$}&\\multicolumn{2}{c|}{Adam-CBO}\\\\\n\t\t\\cline{4-5}\n\t\t~& ~ & ~ &  $\\mathcal{N}(0,1)$& $\\mathcal{U}(-1,1)$\\\\\n\t\t\\hline\n\t\t1000& 8000 &  50  & 92\\% & 20\\% \\\\\n\t\t1000& 10000 & 50  & 100\\% & 28\\% \\\\\n\t\t1000& 12000 & 50  & 100\\% & 28\\% \\\\\n\t\t1000& 14000 & 50  & 100\\% & 32\\% \\\\\n\t\t1000& 16000 & 50  & 100\\% & 32\\%  \\\\\n\t\t\\hline\n\t\\end{tabular}\n\t%\\caption{Different numbers of particles when the dimension is $1000$}\n\t\\label{tbl:p_N sr}\n\\end{table}\n\n\\end{frame}\n\\subsection{Machine learning tasks}\n\\begin{frame}\n\\frametitle{Spectrail bias \\cite{Rahaman2018}/Frequency principle \\cite{xu2019frequency}}\n\n\t\\begin{columns}\n\t\\column{0.5\\textwidth}\n\t\n\t\\begin{itemize}\n\t\t\\item[] \\begin{align*}\n\t\tu(x) = \\sin(2\\pi x) + \\sin(8 \\pi x ^2)\n\t\t\\end{align*}\n\t\t\\item Network width $ = 50$, depth $ = 3$, and $2701$ parameters \n\t\t\\item $\\lambda=0.2$\n\t\t\\item $N = 500$ and $M=5$ in the first $50000$ iterations\n\t\t\\item Afterwards the random term is ignored and $M = 10$\n\t\\end{itemize}\n\t\n\t\\column{0.5\\textwidth}\n\t\\begin{figure}[ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\linewidth]{Figure//Fprinciple_exm1}\n\t\\end{figure}\t\n\t\\end{columns}\n\n\\end{frame}\n\\begin{frame}\n\\begin{columns}\n\\column{0.5\\textwidth}\n\t\\begin{align*}\n\t&u(x) = \\left\\{\\begin{matrix}\n\t1   & x < -\\frac{7}{8}, x> \\frac{7}{8}, -\\frac{1}{8}<x<\\frac{1}{8}\\\\\n\t-1  & \\frac{3}{8}< x< \\frac{5}{8} , -\\frac{5}{8}< x<- \\frac{3}{8}\\\\\n\t0 & \\text{otherwise} \n\t\\end{matrix} \\right.\n\t\\end{align*}\n\tThe same setup as in the previous slide\n\t\\column{0.5\\textwidth}\n\t\\begin{figure}[ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\linewidth]{Figure//Fprinciple_exm2}\n\t\\end{figure}\t\t\n\\end{columns}\n\\end{frame}\n\\begin{frame}\n\\frametitle{Gradient exploding or vanishing: DNN with fixed width $10$ and different depths}\n\n\\begin{equation*}\n\tu(x) = \\sin(k\\pi x ^k)\n\\end{equation*} \n$N = 500$, $M = 5$\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|}\n\t\\hline\n\t\t depth & Num of parameters & k = 2 &  k = 3 & k = 4  \\\\\n\t\t\\hline\n\t\t4   & 141 & 6.62 e-03 & 1.32 e-02 & 1.71 e-01\\\\\n\t\t7   & 471 & 4.78 e-03 & 1.42 e-02 & 7.54 e-03\\\\\n\t\t12  & 1021 & 7.44 e-03 & 1.30 e-02 & 5.32 e-02\\\\\n\t\t22  & 2121 & 1.00 e-02 & 1.01 e-02 & 1.21 e-01\\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Absolute $L^2$ norm in terms of network depth when $k=2, 3, 4$}\n\\end{table}\t\n\nSGD or Adam fails to converges well (with final error around $0.3$) when the network depth is $4$ and $10$, respectively\n\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Solving PDEs by DNNs: Deep Ritz method \\footfullcite{weinan2018deep}}\n\n\\begin{equation*}\n\\left\\{\n\\begin{aligned}\n&-\\nabla \\cdot ( A(x) \\nabla u) = - \\sum_{i=1}^d\\delta(x_i) & x\\in \\Omega=[-1,1]^d\\\\\n&u(x) = g(x)  & x\\in \\partial \\Omega\n\\end{aligned}\\right.\n\\end{equation*} \nwith\n\\begin{equation*}\n\tA(x)= \n\t\\left[\\begin{matrix}\n\t\t(x_1^2)^{\\frac{1}{4}} & & \\\\\n\t\t& \\ddots & &\\\\\n\t\t& &  (x_d^2)^{\\frac{1}{4}}\n\t\\end{matrix}\\right].\n\\end{equation*}\n\\begin{itemize}\n\t\\item Exact solution $u(x)= \\sum_{i=1}^d|x_i|^{\\frac{1}{2}}$ is only in $H^{1/2}(\\Omega)$ \n\t\\item Derivatives have singularities at $x_i =0$\n\\end{itemize}\n\n\\end{frame}\n\\begin{frame}\n\\frametitle{Loss function in Deep Ritz method}\n\n\\begin{equation*}\n\\begin{aligned}\n\tI[u] =& \\int_{\\Omega}\\frac{1}{2}(\\nabla u)^T  A(x)  \\nabla u(x)\\mathrm{d}x + \\sum_{i=1}^d\\int_{-1}^{1}\\delta(x_i)u(x)\\mathrm{d}x_i \\\\ & + \\eta \\int_{\\partial \\Omega} (u(x)-g(x))^2 \\mathrm{d}x,\n\t\\end{aligned}\n\\end{equation*}\t\n\\tiny{\n\\begin{table}[H]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|c|}\n\t\t\\hline\n\t\td & n & m &  Activation-Optimizer & $L^2$ error & $L^{\\infty}$ error\\\\\n\t\t\\hline\n\t\t\\multirow{4}*{2}&\\multirow{4}*{20} & \\multirow{4}*{2} & ReLu-Adam & 1.23 e-02 & 9.91 e-02\\\\\n\t\t& &  & ReQu-Adam & 2.22 e-02  & 4.21 e-01 \\\\\n\t\t& &  & sigmoid-Adam & 2.19 e-02 & 3.14 e-01\\\\\n\t\t& &  & $|x|^{0.5}$ - Adam-CBO & 3.96 e-03 & 2.09 e-02\\\\\n\t\t\\hline\n\t\t\\multirow{4}*{4}&\\multirow{4}*{40} & \\multirow{4}*{2} & ReLu-Adam & 6.72 e-03 & 3.70 e-01\\\\\n\t\t& &  & ReQu-Adam & 1.43 e-02 & 1.10 e -00\\\\\n\t\t& &  & sigmoid-Adam & 7.90 e-03 & 7.66 e -02\\\\\n\t\t& &  & $|x|^{0.5}$ -Adam-CBO & 3.13 e-03 & 9.52 e -02\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\caption{Errors in $L^2$ and $L^{\\infty}$ norms by Adam and Adam-CBO methods}\n\\end{table}\t\n}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Cont'd}\n\n\t\\begin{figure}\n\t\\subfigure[$L^{\\infty}$ error]{\n\t\t\\includegraphics[width=0.45\\linewidth]{Figure//singular_PDE_4D_L_infty_error}\n\t}\n\t\\subfigure[$L^2$ error]{\n\t\t\\includegraphics[width=0.45\\linewidth]{Figure//singular_PDE_4D_L2_error}\n\t}\n\t\\caption{Training process of Adam and Adam-CBO methods when $d=4$}\n\\end{figure}\n\n\\end{frame}\n\\begin{frame}\n\\frametitle{Singularities}\n\n\\begin{figure}\n\t\\subfigure[$x_2=x_3=x_4=0$]{\n\t\t\\includegraphics[width=0.45\\linewidth]{Figure//singular_PDE_4D_Landscape_x1}\n\t}\n\t\\subfigure[$x_1=x_3=x_4=0$]{\n\t\t\\includegraphics[width=0.45\\linewidth]{Figure//singular_PDE_4D_Landscape_x2}\n\t}\n\t\\caption{One-dimensional solution profiles at the intersection}\n\\end{figure}\t\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Conclusion}\n\nAdam-CBO is\n\\begin{itemize}\n\t\\item able to find the global minimizer in high dimensions\n\t\\item free of curse of dimensionality\n\t\\item suitable for machine learning tasks with\n\t\\begin{itemize}\n\t\t\\item gradient explosion or vanishing\n\t\t\\item non-different activation functions\n\t\\end{itemize}\n\\end{itemize}\n{\\huge\\medskip\n\\begin{center}\n\tThank you for your attention!\n\\end{center}\n}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "0f4bf578ce0cc16114388ebb303f7fb3f0d405f6", "size": 19286, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/ADAM_CBO/ADAM_CBO.tex", "max_stars_repo_name": "Lyuliyao/Lyuliyao.github.io", "max_stars_repo_head_hexsha": "49cd5ba8861120809c23c9496563a4269971cab1", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/ADAM_CBO/ADAM_CBO.tex", "max_issues_repo_name": "Lyuliyao/Lyuliyao.github.io", "max_issues_repo_head_hexsha": "49cd5ba8861120809c23c9496563a4269971cab1", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/ADAM_CBO/ADAM_CBO.tex", "max_forks_repo_name": "Lyuliyao/Lyuliyao.github.io", "max_forks_repo_head_hexsha": "49cd5ba8861120809c23c9496563a4269971cab1", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0064308682, "max_line_length": 383, "alphanum_fraction": 0.622679664, "num_tokens": 8134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4057853344274475}}
{"text": "%&context\n\n\\section[sct_match]{Finding subtrees in other trees}\n\n\n\\match{} tries to match a (typically smaller) \"pattern\" tree to one or more\n\"target\" tree(s). If the pattern matches the target, the target tree is\nprinted. Intuitively, a pattern matches a target if one can superimpose it onto\nthe target without \"breaking\" either. More accurately, the following happens\n(in both trees):\n\\startitemize[n]\n\t\\item leaves with labels found in both trees are kept, the other ones are\n\t\tpruned\n\t\\item inner labels are discarded\n\t\\item both trees are ordered (as done by \\order{}, see  \\in{}[sct_order])\n\t\\item branch lengths are discarded\n\\stopitemize\nAt this point, the modified pattern tree is compared to the modified target, and if the \\nw{} strings are identical, the match is successful.\n\n\\subsubsection{Example: finding trees with a specified  subtree topology}\n\nFile \\filename{hominoidea.nw} contains seven trees corresponding to successive\ntheories about the phylogeny of apes (these were taken from\n\\from[URL:Hominoidea]). Let us see which of them group\nhumans and chimpanzees as a sister clade of gorillas (which is the current\nhypothesis).\n\n\\page[no]\nHere are small images of each of the trees in \\filename{hominoidea.nw}: \\\\\n\n\\startcombination[2*4]\n{\\externalfigure[homino_0][scale=700]} {1 (until 1960)}\n{\\externalfigure[homino_1][scale=700]} {2 (Goodman, 1964)}\n{\\externalfigure[homino_2][scale=700]} {3 (gibbons as outgroup)}\n{\\externalfigure[homino_3][scale=700]} {4 (Goodman, 1974: orangs as outgroup)}\n{\\externalfigure[homino_4][scale=700]} {5 (resolving trichotomy)}\n{\\externalfigure[homino_5][scale=700]} {6 (Goodman, 1990: gorillas as outgroup)}\n{\\externalfigure[homino_6][scale=700]} {7 (split of {\\em Hylobates})}\n\\stopcombination\n\nTrees \\#6 and \\#7 match our criterion, the rest do not. To look for matching trees in \\filename{hominoidea.nw}, we pass the pattern on the command line:\n\n\\typefile{match_1_txt.cmd}\n\\page[no]\n\\typefile{match_1_txt.out}\n\n\nNote that only the pattern tree's topology matters: we would get the\nsame results with pattern \\code{((Homo,Pan),Gorilla);},\n\\code{((Pan,Homo),Gorilla);}, etc., but not with\n\\code{((Gorilla,Pan),Homo);} (which would select trees \\#1, 2, 3, and 5. In\nfuture versions I might add an option for strict matching.\n\nThe behaviour of \\match{} can be reversed by passing option \\code{-v} (like\n\\code{grep -v}): it will print trees that {\\em do not} match the pattern.\nFinally, note that \\match{} only works on leaf labels (for now), and assumes\nthat labels are unique in both the pattern and the target tree.\n", "meta": {"hexsha": "b18bdb4156ba260be250d2028b674703a35fcb7f", "size": 2572, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/c-match.tex", "max_stars_repo_name": "Cactusolo/newick_utils", "max_stars_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 62, "max_stars_repo_stars_event_min_datetime": "2015-01-08T22:22:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-07T09:12:51.000Z", "max_issues_repo_path": "doc/c-match.tex", "max_issues_repo_name": "Cactusolo/newick_utils", "max_issues_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2015-01-22T19:34:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-27T10:53:41.000Z", "max_forks_repo_path": "doc/c-match.tex", "max_forks_repo_name": "Cactusolo/newick_utils", "max_forks_repo_head_hexsha": "da121155a977197cab9fbb15953ca1b40b11eb87", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 26, "max_forks_repo_forks_event_min_datetime": "2015-05-07T09:23:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T02:43:50.000Z", "avg_line_length": 44.3448275862, "max_line_length": 152, "alphanum_fraction": 0.7531104199, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341027751814, "lm_q2_score": 0.640635847978761, "lm_q1q2_score": 0.40578533025629604}}
{"text": "\n% In this section we describe how \\minesp works. To do so, we first introduce relevant definitions, followed by an overview of the algorithm. We subsequently discuss each component of the algorithm in detail.\n\n% To describe how \\minesp works, we first formally define time series and provide an overview of the algorithm. We subsequently discuss each component of the algorithm in detail.\nTo describe how \\minesp works, we first provide an overview of the algorithm, then discuss each of its component in detail.\n\n% % ------------------------------------------------\n% \\subsection{Definitions}\n% % ------------------------------------------------\n% % To both establish notation and clarify the sorts of data for which \\minesp is applicable, we introduce the following definitions.\n% % To facilitate a precise explanation of \\minesp, we introduce the following definitions.\n% \\begin{Definition} \\b{Sample.} A sample is a vector $\\x \\in \\R^D$. $D$ is termed the sample's \\b{dimensionality}. Each element of the sample is an integer represented using a number of bits $w$, termed the \\b{bitwidth}. The bitwidth $w$ is shared by all elements.\n% \\end{Definition}\n% \\begin{Definition} \\b{Time Series.} A time series $\\X$ of length $T$ is a sequence of $T$ samples, $\\x_1,\\ldots,\\x_T$. All samples $\\x_t$ share the same bitwidth $w$ and dimensionality $D$. If $D = 1$, $\\X$ is called \\b{univariate}; otherwise it is \\b{multivariate}.\n% % , and the meaning of each dimension is consistent from sample to sample.\n% \\end{Definition}\n% \\begin{Definition} \\b{Rows, Columns.} In a database context, we assume that each sample of a time series is one row and each dimension is one column. Because data arrives as samples and memory constraints may limit how many samples can be buffered, we assume that the data is stored in row-major order---i.e., such that each sample is stored contiguously.\n% \\end{Definition}\n\n% ------------------------------------------------\n\\subsection{Overview}\n% ------------------------------------------------\n\n\\minesp is a bit packing-based predictive coder. It consists of four components:\n\\begin{enumerate}\n% \\itemsep0em\n\\item \\b{Forecasting.} \\minesp employs a forecaster to predict each sample based on previous samples. It encodes the difference between the next sample and the predicted sample, which is typically closer to zero than the next sample itself.\n\\item \\b{Bit packing.} \\minesp then bit packs the errors as a ``payload'' and prepends a header with sufficient information to invert the bit packing.\n\\item \\b{Run-length encoding.} If a block of errors is all zeros, \\minesp waits for a block in which some error is nonzero and then writes out the number of all-zero blocks instead of the (otherwise empty) payload.\n\\item \\b{Entropy coding.} \\minesp Huffman codes the headers and payloads.\n\\end{enumerate}\n\nThese components are run on blocks of eight samples (motivated in Section~\\ref{sec:bitpacking}), and can be modified to yield different compression-speed tradeoffs. Concretely, one can 1) skip entropy coding for greater speed and 2) choose between delta coding and our online learning method as forecasting algorithms. The latter is slightly slower but often improves compression.\n\nWe chose these steps since they allow for high speed and exploit the characteristics of time series. Forecasting leverages the high correlation of successive samples to reduce the entropy of the data. Run-length encoding allows for extreme compression in the (common) scenario that there is no change in the data---e.g., a user's smartphone may be stationary for many hours while the user is asleep. Our method of bit packing exploits temporal correlation in the variability of the data by using the same bitwidth for points that are within the same block. Huffman coding is not specific to time series but has low memory requirements and improves compression ratios.\n\n % in general is not especially geared towards time series, but our bit packing scheme exploits temporal correlation in the variability of the data by using the same bitwidth for points that are within the same block. Huffman coding is not specific to time series but has low memory requirements and improves compression ratios.\n\n % \\textit{per se}, but provides a vectorizable and low-memory means of reducing the encoding size. Similarly, Huffman coding is not specific to time series but has low memory requirements and improves compression ratios.\n\n% Before describing the four components in greater detail, we first provide an outline of the overall algorithms for compressing and decompressing blocks of data.\n\n% We elaborate upon each of the four components in the following subsections, but first provide an outline of the overall compression and decompression functions.\n\n\\newcommand{\\err}{\\texttt{err}}\n\\newcommand{\\nbits}{\\texttt{nbits}}\n\\newcommand{\\packed}{\\texttt{packed}}\n\\newcommand{\\buff}{$\\texttt{buff}$}\n\\newcommand{\\bytes}{\\texttt{bytes}}\n% \\newcommand{\\header}{\\texttt{header}}\n\\newcommand{\\payload}{\\texttt{payload}}\n\\newcommand{\\f}{\\texttt{f}}\n\\newcommand{\\fore}{\\texttt{forecaster}}\n\\newcommand{\\self}{\\texttt{self}}\n\n% ------------------------ compress overview\n\nAn overview of how \\minesp compresses one block of samples is shown in Algorithm~\\ref{algo:compress}. In lines \\ref{line:bodyStart}-\\ref{line:encPredictEnd}, \\minesp predicts each sample based on the previous sample and any state stored by the forecasting algorithm. For the first sample in a block, the previous sample is the last element of the previous block, or zeros for the initial block. In lines \\ref{line:eachColStart}-\\ref{line:bodyEnd}, \\minesp determines the number of bits required to store the largest error in each column and then bit packs the values in that column using that many bits. (Recall that each column is one variable of the time series). If all columns require 0 bits, \\minesp continues reading in blocks until some error requires $>$0 bits (lines \\ref{line:rleLoopStart}-\\ref{line:rleLoopEnd}). At this point, it writes out a header of all 0s and then the number of all-zero blocks. Finally, it writes out the number of bits required by each column in the latest block as a header, and the bit packed data as a payload. Both header and payload are compressed with Huffman coding.\n\n\\begin{algorithm}[h]\n% \\caption{encodeBlock($\\{\\x_1, \\ldots, \\x_B \\}, \\vtheta $)}\n\\caption{encodeBlock($\\{\\x_1, \\ldots, \\x_B \\}, \\fore$)}\n\\label{algo:compress}\n\\begin{algorithmic}[1]\n\n\\State{Let \\buff\\sp be a temporary buffer}\n\n\\For {$i \\leftarrow 1,\\ldots,B$} \\COMMENTT {For each sample} \\label{line:bodyStart}\n    % \\State{$ \\hat{\\x}_i, \\vtheta \\leftarrow $predictAndTrain$(\\x_{i-1}, \\vtheta)  $}\n    \\State{$ \\hat{\\x}_i \\leftarrow $ $\\fore$.predict$(\\x_{i-1})$}\n    \\State{$ \\err_i \\leftarrow \\x_i - \\hat{\\x}_i  $}\n    \\State{$\\fore$.train($\\x_{i-1}$, $\\x_i$, $\\err_i$)} \\label{line:encPredictEnd}\n\\EndFor\n\\For {$j \\leftarrow 1,\\ldots,D$} \\COMMENTT {For each column} \\label{line:eachColStart}\n    \\State{$ \\nbits_j \\leftarrow \\max_i\\{ $requiredNumBits$(\\err_{ij}) \\} $}\n    \\State{$ \\packed_j \\leftarrow $ bitPack$(\\{\\err_{1j},\\ldots,\\err_{Bj} \\},\\text{ }\\nbits_j) $}  \\label{line:bodyEnd}\n\\EndFor\n\n\\LineComment{Run-length encode if all errors are zero}\n\\If{$\\nbits_j$ \\texttt{==} $0$, $1 \\le j \\le D$}\n    \\Repeat  \\COMMENT{Scan until end of run} \\label{line:rleLoopStart}\n        \\State{Read in another block and run lines \\ref{line:bodyStart}-\\ref{line:bodyEnd} }\n    \\Until {$\\exists_j [\\nbits_j \\neq 0 ]$} \\label{line:rleLoopEnd}\n    % \\State{Read in another block and run lines \\ref{line:bodyStart}-\\ref{line:bodyEnd} until some nbits$_j$ != $0$}\n    \\State{Write $D$ $0$s as headers into \\buff}\n    \\State{Write number of all-zero blocks as payload into \\buff}\n    \\State{Output huffmanCode(\\buff)}\n\\EndIf\n\n\\State{Write $\\nbits_j$, $j = 1,\\ldots,D$ as headers into \\buff}\n\\State{Write $\\packed_j$, $j = 1,\\ldots,D$ as payload into \\buff}\n\\State{Output huffmanCode(\\buff)}\n\n% \\RETURN {$ odds_{event} - \\max(odds_{noise}, odds_{next}) $}\n\\end{algorithmic}\n\\end{algorithm}\n\n% ------------------------ decompress\n\n\\minesp begins decompression (Algorithm~\\ref{algo:decomp}) by decoding the Huffman-coded bitstream into a header and a payload. Once decoded, these two components are easy to separate since the header is always first and of fixed size. If the header is all 0s, the payload indicates the length of a run of zero errors. In this case, \\minesp runs the predictor until the corresponding number of samples have been predicted. Since the errors are zero, the forecaster's predictions are the true sample values. In the nonzero case, \\minesp unpacks the payload using the number of bits specified for each column by the header.\n\n\\begin{algorithm}[h]\n% \\caption{decodeBlock(\\bytes, $B$, $D$, $\\vtheta$)}\n\\caption{decodeBlock(\\bytes, $B$, $D$, $\\fore$)}\n\\label{algo:decomp}\n\\begin{algorithmic}[1]\n\n\\State{$\\nbits$, $\\payload$ $\\leftarrow$ huffmanDecode(\\bytes, $B$, $D$) }\n\n% \\State{$\\f \\leftarrow \\texttt{Forecaster()} $}\n\\If{$\\nbits_j$ \\texttt{==} $0$ $\\forall j$} \\COMMENT{Run-length encoded}\n    \\State{$\\texttt{numblocks} \\leftarrow $ readRunLength()}\n    \\For {$i \\leftarrow 1,\\ldots,(B $ $\\cdot$ \\texttt{numblocks})}\n        % \\State{$ \\hat{\\x}_i, \\vtheta \\leftarrow $ $\\fore$.predict$(\\x_{i-1}, \\vtheta) $}\n        \\State{$ \\x_i \\leftarrow $ $\\fore$.predict$(\\x_{i-1})$}\n        \\State{Output $\\x_i$}\n        % \\State{$\\fore$.train($\\x_{i-1}$, $\\x_i$, 0)}\n    \\EndFor\n    % \\RETURN {}\n% \\EndIf\n\\Else \\COMMENT{Not run-length encoded}\n% \\State{}\n\\For {$i \\leftarrow 1,\\ldots,B$}\n    % \\State{$ \\hat{\\x}_i, \\vtheta \\leftarrow $ $\\fore$.predict$(\\x_{i-1}, \\vtheta)  $}\n    \\State{$ \\hat{\\x}_i \\leftarrow $ $\\fore$.predict$(\\x_{i-1})$}\n    \\State{$ \\err_i \\leftarrow $unpackErrorVector$(i$, \\nbits, \\payload$) $}\n    \\State{$ \\x_i \\leftarrow \\err_i + \\hat{\\x}_i  $}\n    \\State{Output $\\x_i$}\n    \\State{$\\fore$.train($\\x_{i-1}$, $\\x_i$, $\\err_i$)}\n\\EndFor\n\\EndIf\n\\end{algorithmic}\n\\end{algorithm}\n\n% ------------------------------------------------\n\\subsection{Forecasting}\n% ------------------------------------------------\n\n\\minesp forecasting can use either delta coding or \\justfire \\text{ } (Fast Integer REgression), a novel online forecasting algorithm we introduce.\n\n% ================================\n\\subsubsection{Delta Coding}\n% ================================\n\nForecasting with delta coding consists of predicting each sample $\\x_i$ to be equal to the previous sample $\\x_{i-1}$, where $\\x_{0} \\triangleq \\vec{0}$. This method is stateless given $\\x_{i-1}$ and is extremely fast. It is particularly fast when combined with run-length encoding, since it yields a run of zero errors if and only if the data is constant. This means that decompression of runs requires only copying a fixed vector, with no additional forecasting or training. Moreover, when answering queries, one can sometimes avoid decompression entirely---e.g., one can compute the max of all samples in the run by computing the max of only the first value.\n\n% ================================\n\\subsubsection{FIRE}\n% ================================\n\nForecasting with \\fire is slightly more expensive than delta coding but often yields better compression.\nThe basic idea of \\fire is to model each value as a linear combination of a fixed number of previous values and learn the coefficients of this combination. Specifically, we learn an autoregressive model of the form:\n% Consider a linear model for predicting a given value $x_i$ of some variable at time step $i$.\n\\begin{align}\n    x_i = a x_{i-1} + b x_{i-2} + \\eps_i\n\\end{align}\nwhere $x_i$ denotes the value of some variable at time step $i$ and $\\eps_i$ is a noise term.\n\nDifferent values of $a$ and $b$ are suitable for different data characterisics. If $a = 2$, $b = -1$, we obtain double-delta coding, which extrapolates linearly from the previous two points and works well when the time series is smooth. If $a = 1$, $b = 0$, we recover delta coding, which models the data as a random walk. If $a = \\frac{1}{2}$, $b = \\frac{1}{2}$, we predict each value to be the average of the previous two values, which is optimal if the $x_i$ are i.i.d. Gaussians. In other words, these cases are appropriate for successively noisier data.\n\n% The idea of \\fire is to learn online what the best coefficients are.\n\nThe reason \\fire is effective is that it learns online what the best coefficients are for each variable.\n% \\Fire learns appropriate coefficients online using gradient descent with L1 loss.\n% To make prediction and learning as efficient as possible, however, \\justfire\nTo make prediction and learning as efficient as possible, \\justfire \\text{} restricts the coefficients to lie within a useful subspace. Specifically, we exploit the observation that all of the above cases can be written as:\n\\begin{align}\n    x_i = x_{i-1} + \\alpha x_{i-1} - \\alpha x_{i-2} + \\eps_i\n\\end{align}\nfor $\\alpha \\in [-\\frac{1}{2}, 1]$. Letting $\\delta_i \\triangleq x_i - x_{i-1}$ and subtracting $x_{i-1}$ from both sides, this is equivalent to\n% \\begin{align}\n%     x_i = x_{i-1} + \\delta_i + \\alpha (x_{i-1} - x_{i-2}) + \\eps_i\n% \\end{align}\n% . Subtracting $x_{i-1}$ from both sides, we obtain\n\\begin{align}\n    \\delta_i &= \\alpha \\delta_{i-1} + \\eps_i\n\\end{align}\n% \\begin{align}\n%     \\delta_i &= \\delta_{i-1} + \\alpha  + \\eps_i \\\\\n% \\end{align}\n% and therefore\n% \\begin{align}\n%     \\delta_i &= \\alpha \\delta_{i-1} \\eps_i \\\\\n% \\end{align}\nThis means that we can capture all of the above cases by predicting the next delta as a rescaled version of the previous delta. This requires only a single addition and multiplication, and reduces the learning problem to that of finding a suitable value for a single parameter.\n\n% % ------------------------------------------------\n% \\subsubsection{Details}\n% % ------------------------------------------------\n% Pseudocode for \\fire prediction and training is given in Algorithm~\\ref{algo:xff}.\n\n% To make this underlying model practical and performant for integers,\n% : \\fire initialization (line~\\ref{line:xffCtor}), prediction (line~\\ref{line:xffPredict}), and training (line~\\ref{line:xffTrain}).\nTo train and predict using this model, we use the functions shown in Algorithm~\\ref{algo:xff}. First, to initialize a \\fire forecaster, one must specify three values: the number of columns $D$, the learning rate $\\eta$, and the bitwidth $w$ of the integers stored in the columns. Internally, the forecaster also maintains an accumulator for each column (line~\\ref{line:counter}) and the difference (delta) between the two most recently seen samples (line~\\ref{line:deltas}). The accumulator is a scaled version of the current $\\alpha$ value with a bitwidth of $2w$. It enables fast updates of $\\alpha$ with greater numerical precision than would be possible if modifying $\\alpha$ directly. The accumulators and deltas are both initialized to zeros. % updates without the expense of division or multiplication instructions.\n\n% ------------------------ xff pseudocode\n\n\\begin{algorithm}[h]\n% \\begin{struct}[h]\n% \\label{algo:xff}\n% \\floatname{algorithm}{Algorithm}\n\\caption{FIRE\\_Forecaster Class} \\label{algo:xff}\n\\begin{algorithmic}[1]\n\n\\Function{Init}{$D$, $\\eta$, $w$} \\label{line:xffCtor}\n\\State $\\self$.learnShift $\\leftarrow \\lg(\\eta)$\n\\State $\\self$.bitWidth $\\leftarrow w$ \\COMMENT{8-bit or 16-bit}\n\\State $\\self$.accumulators $\\leftarrow $ zeros($D$) \\label{line:counter}\n\\State $\\self$.deltas $\\leftarrow $ zeros($D$) \\label{line:deltas}\n\\EndFunction\n\n\\Function{Predict}{$\\x_{i-1}$} \\label{line:xffPredict}\n\\State $\\texttt{alphas} \\leftarrow \\self$.accumulators \\rshift $\\self$.learnShift\n% \\State $\\texttt{alphas} \\leftarrow (\\texttt{alphas} \\text{ }\\rshift 4) \\text{ }\\lshift 4$\n\\State $\\hat{\\vdelta} \\leftarrow$ (\\texttt{alphas} $\\odot$ $\\self$.deltas) $\\rshift \\self$.bitWidth\n\\RETURN $\\x_{i-1} + \\hat{\\vdelta}$\n\\EndFunction\n\n\\Function{Train}{$\\x_{i-1}$, $\\x_{i}$, $\\err_i$} \\label{line:xffTrain}\n\\State $\\texttt{gradients} \\leftarrow {-\\sign(\\err_i)} \\odot \\self$.deltas\n% \\State $\\self$.accumulators $\\leftarrow \\self$.accumulators + $\\texttt{gradients}$\n% \\State $\\self$.accumulators \\texttt{-=} $\\texttt{gradients}$\n\\State $\\self$.accumulators $\\leftarrow$ $\\self$.accumulators $-$ $\\texttt{gradients}$\n\\State $\\self$.deltas $\\leftarrow \\x_{i} - \\x_{i-1}$\n\\EndFunction\n\n\\end{algorithmic}\n\\end{algorithm}\n\n\n% To predict (line~\\ref{line:xffPredict})\nTo predict, the forecaster first derives the coefficient $\\alpha$ for each column based on the accumulator. By right shifting the accumulator $\\log2(\\eta)$ bits, the forecaster obtains a learning rate of $2^{-\\log2(\\eta)} = \\eta$. It then estimates the next deltas as the elementwise product (denoted $\\odot$) of these coefficients and the previous deltas. It predicts the next sample to be the previous sample plus these estimated deltas.\n\nBecause all values involved are integers, the multiplication is done using twice the bitwidth $w$ of the data type---e.g., using 16 bits for 8 bit data. The product is then right shifted by an amount equal to the bit width. This has the effect of performing a fixed-point multiplication with step size equal to $2^{-w}$.\n\n% The forecaster trains (line~\\ref{line:xffTrain})\nThe forecaster trains by performing a gradient update on the L1 loss between the true and predicted samples. I.e., given the loss:\n\\begin{align}\n    \\mathcal{L}(x_i, \\hat{x}_{i}) = \\abs{x_i - \\hat{x}_i}\n    = \\abs{x_i - (x_{i-1} + \\frac{\\alpha}{2^w} \\cdot \\delta_{i-1})} \\\\\n    = \\abs{\\delta_{i} - \\frac{\\alpha}{2^w} \\cdot \\delta_{i-1}}\n\\end{align}\nfor one column's value $x_i = \\x_{ij}$ for some $j$ and coefficient $\\alpha$, the gradient is:\n\\begin{align}\n    % x = 5\n    % \\frac{\\partial x}{\\partial \\alpha} x = 5\n    % \\mathcal{L}(\\x_i, \\hat{\\x}_i)\n        \\frac{\\partial }{\\partial \\alpha} \\abs{\\delta_{i} - \\frac{\\alpha}{2^w} \\cdot \\delta_{i-1}}\n% \\begin{equation*}\n&= \\begin{cases}\n        -{2^{-w}}\\vdelta_{i-1} & \\x_{i} > \\hat{\\x}_{i} \\\\\n        {2^{-w}}\\vdelta_{i-1} & \\x_{i} \\le \\hat{\\x}_{i}\n\\end{cases} \\\\\n&= -\\sign(\\eps) \\cdot {2^{-w}}\\vdelta_{i-1} \\\\\n&\\propto -\\sign(\\eps) \\cdot \\vdelta_{i-1}\n% \\end{equation*}\n\\end{align}\nwhere we define $\\eps \\triangleq \\x_{i} - \\hat{\\x}_{i}$ and ignore the $2^{-w}$ as a constant that can be absorbed into the learning rate. In all experiments reported here, we set the learning rate to $\\frac{1}{2}$. This value is unlikely to be ideal for any particular dataset, but preliminary experiments showed that it consistently worked reasonably well. % and was large enough to avoid zeroing out small gradients.\n\nIn practice, \\fire differs from the above pseudocode in three ways. First, instead of computing the coefficient for each sample, we compute it once at the start of each block. Second, instead of performing a gradient update after each sample, we average the gradients of all samples in each block and then perform one update. Finally, we only compute a gradient for every other sample, since this has little or no effect on the accuracy and slightly improves speed.\n\n\\begin{figure*}[t]\n\\begin{center}\n    \\includegraphics[width=\\textwidth]{paper/overview}\n    \\caption{Overview of \\minesp using a delta coding predictor.\\textit{ a)} Delta coding of each column, followed by zigzag encoding of resulting errors. The maximum number of significant (nonzero) bits is computed for each column. \\textit{b)} These numbers of bits are stored in a header, and the original data is stored as a (byte-aligned) payload, with leading zeros removed. When there are few columns, each column's data is stored contiguously. When there are many columns, each row is stored contiguously, possibly with padding to ensure alignment on a byte boundary.}\n    % With blocks of eight samples (only four shown for clarity), this ensures that each column's data begins on a byte boundary.\n    \\label{fig:overview}\n    \\vspace{-5mm}\n\\end{center}\n\\end{figure*}\n\n% ------------------------------------------------\n\\subsection{Bit Packing} \\label{sec:bitpacking}\n% ------------------------------------------------\n\nAn illustration of \\mine's bit packing is given in Figure~\\ref{fig:overview}. The prediction errors from delta coding or \\fire are zigzag encoded \\cite{zigzag} and then the minimum number of bits required is computed for each column. Zigzag encoding is an invertible transform that interleaves positive and negative integers such that each integer is represented by twice its absolute value, or twice its absolute value minus one for negative integers. This makes all values nonnegative and maps integers farther from zero to larger numbers.\n% ). % We zigzag encode because it is extremely efficient and facilitates computing the number of bits necesasary.\n\nGiven the zigzag encoded errors, the number of bits $w^\\prime$ required in each column can be computed as the bitwidth minus the fewest leading zeros in any of that column's errors. E.g., in Figure~\\ref{fig:overview}a, the first column's largest encoded value is 16, represented as \\texttt{00010000}, which has three leading zeros. This means that we require $w^\\prime = 8 - 3 = 5$ bits to store the values in this column. One can find this value by ORing all the values in a column together and then using a built-in function such as GCC's $\\texttt{\\_\\_builtin\\_clz}$ to compute the number of leading zeros in a single assembly instruction (c.f. \\cite{fastpfor}). This optimization motivates our use of zigzag encoding to make all values nonnegative.\n\nOnce the number of bits $w^\\prime$ required for each column is known, the zigzag-encoded errors can be bit packed. First, \\minesp writes out a header consisting of $D$ unsigned integers, one for each column, storing the bitwidths. Each integer is stored in $\\log2(w)$ bits, where $w$ is the bitwidth of the data. Since there are $w+1$ possible values of $w^\\prime$ (including 0), width $w-1$ is treated as a width of $w$ by both the encoder and decoder. E.g., 8-bit data that could only be compressed to 7 bits is both stored and decoded with a bitwidth of 8.\n\nAfter writing the headers, \\minesp takes the appropriate number of low bits from each element and packs them into the payload. When there are few columns, all the bits for a given column are stored contiguously (i.e., column-major order). When there are many columns, the bits for each \\textit{sample} are stored contiguously (i.e., row-major order). In the latter case, up to seven bits of padding are added at the end of each row so that all rows begin on a byte boundary. This means that the data for each column begins at a fixed bit offset within each row, facilitating vectorization of the decompressor. The threshold for choosing between the two formats is a sample width of $32$ bits.\n\nThe reason for this threshold is as follows. Because the block begins in row-major order and we seek to reconstruct it the same way, the row-major bit packing case is more natural. For small numbers of columns, however, the row padding can significantly reduce the compression ratio. Indeed, for univariate 8-bit data, it makes compression ratios greater than 1 impossible. This gives rise to the column-major case; using a block size of eight samples and column-major order, each column's data always falls on a byte boundary without any padding. The downside of this approach is that both encoder and decoder must transpose the block. However, for up to four 8-bit columns or two 16-bit columns, this can be done quickly using SIMD shuffling instructions.\\footnote{For recent processors with AVX-512 instructions, one could double these column counts, but we refrain from assuming that these instructions will be available.} This gives rise to the cutoff of 32 bit sample width for choosing between the formats.\n\nAs a minor bit packing optimization, one can store the headers for two or more blocks contiguously, so that there is one group of headers followed by one group of payloads. This allows many headers to share one set of padding bits between the headers and payload. Grouping headers does not require buffering more than one block of raw input, but it does require buffering the appropriate number of blocks of compressed output. In addition to slightly improving the compression ratio, it also enables more headers to be unpacked with a given number of vector instructions in the decompressor. Microbenchmarks show up to $10\\%$ improvement in decompression speed as the number of blocks in a group grows towards eight. However, we use groups of only two in all reported experiments to ensure that our results tend towards pessimism and are applicable under even the most extreme buffer size constraints.\n\n% ------------------------------------------------\n\\subsection{Entropy Coding}\n% ------------------------------------------------\n\nWe entropy code the bit packed representation of each block using Huff0, an off-the-shelf Huffman coder \\cite{fse}. This encoder treats individual bytes as symbols, regardless of the bitwidth of the original data. We use Huffman coding instead of Finite-State Entropy \\cite{fse} or an arithmetic coding scheme since they are slower, and we never observed a meaningful increase in compression ratio.\n\nThe benefit of adding Huffman coding to bit packing stems from bit packing's inability to optimally encode individual bytes. For a given packed bitwidth $w$, bit packing models its input as being uniformly distributed over an interval of size $2^{w}$. Appropriately setting $w$ allows it to exploit the similar variances of nearby values, but does not optimally encode individual values (unless they truly are uniformly distributed within the interval). Huffman coding is complementary in that  it fails to capture relationships between nearby bytes but optimally encodes individual bytes.\n\nWe Huffman code after bit packing, instead of before, for two reasons. First, doing so is faster. This is because the bit packed block is usually shorter than the original data, so less data is fed to the Huffman coding routines. These routines are slower than the rest of \\mine, so minimizing their input size is beneficial. Second, this approach increases compression. Bit packed bytes benefit from Huffman coding, but Huffman coded bytes do not benefit from bit packing, since they seldom contain large numbers of leading zeros. This absence of leading zeros is unsurprising since Huffman codes are not byte-aligned and use ones and zeros in nearly equal measure.\n\n% 1) Huffman coding is slower than the rest of \\mine, so running it on the smaller bit packed block is (usually) shorter than the original data.\n\n% so applying it last is faster faster than Huffman coding the original data or the errors,\n\n\n% ------------------------------------------------\n\\subsection{Vectorization}\n% ------------------------------------------------\n\nMuch of \\mine's speed comes from vectorization. For headers, the fixed bitwidths for each field and fixed number of fields allows for packing and unpacking with a mix of vectorized byte shuffles, shifts, and masks. For payloads, delta (de)coding, zigzag (de)coding, and \\fire all operate on each column independently, and so naturally vectorize. Because the packed data for all rows is the same length and aligned to a byte boundary (in the high-dimensional case), the decoder can compute the bit offset of each column's data one time and then use this information repeatedly to unpack each row. In the low-dimensional case, all packed data fits in a single vector register which can be shuffled/masked appropriately for each possible number of columns. This is possible since there are at most four columns in this case. On an \\texttt{x86} machine, bit packing and unpacking can be accelerated with the \\texttt{pext} and \\texttt{pdep} instructions, respectively.\n", "meta": {"hexsha": "fa431b93f3077d59728abcbfd46444ebaabc15f6", "size": 27797, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "communicate/ubicomp/method.tex", "max_stars_repo_name": "dblalock/sprintz", "max_stars_repo_head_hexsha": "a056cdb67d049669875ab5487359aca99ae873ea", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 45, "max_stars_repo_stars_event_min_datetime": "2019-02-02T15:50:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:42:06.000Z", "max_issues_repo_path": "communicate/ubicomp/method.tex", "max_issues_repo_name": "memetb/sprintz", "max_issues_repo_head_hexsha": "a056cdb67d049669875ab5487359aca99ae873ea", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-03-27T23:29:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T01:37:08.000Z", "max_forks_repo_path": "communicate/ubicomp/method.tex", "max_forks_repo_name": "memetb/sprintz", "max_forks_repo_head_hexsha": "a056cdb67d049669875ab5487359aca99ae873ea", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2019-03-08T09:04:29.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-18T22:28:23.000Z", "avg_line_length": 89.9579288026, "max_line_length": 1108, "alphanum_fraction": 0.723747167, "num_tokens": 7010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4057853257356183}}
{"text": "\\documentclass[11pt, letterpaper, twoside, final]{article}\n\\usepackage{amssymb, amsmath, amsthm} \n\\usepackage{mathtools, thmtools}\n\\usepackage{csquotes}\n\\usepackage{cleveref}\n\\usepackage[margin=1in]{geometry}\n\\newcommand*{\\dto}{\\overset{d}{\\longrightarrow}}\n\\newcommand*{\\pto}{\\overset{p}{\\longrightarrow}}\n\\newcommand*{\\mvert}{\\,\\middle\\vert\\,}\n\\newcommand*{\\ivert}{\\,\\vert\\,}\n\\newcommand*{\\W}{\\mathcal{W}}\n\\DeclareMathOperator*{\\Var}{\\mathbb{V}ar}\n\\DeclareMathOperator*{\\Cov}{\\mathbb{C}ov}\n\\DeclareMathOperator*{\\E}{\\mathbb{E}}\n\\newtheorem{lemma}{theorem}\n\n\\author{Xu Cheng and Eric Renault and Paul Sangrey} \n\\title{Derivation of Asymptotic Covariance Matrix}\n\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\nWe want to estimate $\\omega \\coloneqq (\\rho, c, \\delta, \\phi, \\pi, \\theta)'$ and get its asymptotic distribution.\nWe also have some auxiliary parameters: $\\xi_1 \\coloneqq (\\beta, \\gamma, \\psi)'$ and $\\xi_2 \\coloneqq \\phi^2$.\nThe way we do this by splitting $\\omega$ in two parts.\nThe first $\\omega_s$ is the vector of purely structural parameters: $(\\phi, \\pi, \\theta)'$.\nThe second part $\\omega_r$ is composed of parameters that we can estimate directly without model-based\ncross-equation restrictions, but are of interest.\nWe collect all of the reduced parameters into a vector: $\\xi \\coloneqq (\\omega_r', \\xi_a)'$.\nWe start by constructing a GMM estimator for $\\xi$, we will then show how to convert this into an estimator for\n$\\omega$.\nThroughout, I will denote the partial derivative of some function $f$ with respect to some variable $x$ with\n$f_x$.\n\n\\section{Stage 1}\n\nWe view estimating the first stage as a particular form of GMM.\nFrom standard GMM theory, we know that the following holds, for some asymptotic covariance matrix $\\Omega_{\\xi}$.\n\n\\begin{equation}\n    \\sqrt{T} (\\hat{\\xi} - \\xi)  \\dto N\\left(0, \\Omega_{\\xi}\\right)\n\\end{equation}\n\nWe will construct $\\Omega_{\\xi}$ in three steps.\nFirst, we will derive the asymptotic covariance matrices for each of $\\omega_r, \\xi_1, \\xi_2$.\nThen we will show how to combine them into one joint covariance matrix.\n\n\\subsection{$\\omega_r$}\\label{sec:omega_r}\n\n\\begin{equation}\n    h\\left(\\sigma^2_{t},\\sigma^2_{t+1} \\mvert \\omega_r\\right) \\coloneqq \n\\begin{bmatrix}\n    \\sigma^2_{t+1} - (c \\delta + \\rho \\sigma^2_{t}) \\\\\n%\n    \\sigma^2_{t} \\left(\\sigma^2_{t+1} - (c \\delta + \\rho \\sigma^2_{t})\\right)\\\\\n%\n    \\sigma^4_{t+1} - \\left(c^{2} \\delta + 2 c \\rho \\sigma^2_{t} + \\left(c \\delta + \\rho\n    \\sigma^2_{t}\\right)^{2}\\right)\\\\\n%\n    \\sigma^2_{t} \\left(\\sigma^4_{t+1} - \\left(c^{2} \\delta + 2 c \\rho \\sigma^2_{t} + \\left(c \\delta + \\rho\n    \\sigma^2_{t}\\right)^{2}\\right)\\right)\\\\\n\n    \\sigma^4_{t} \\left(\\sigma^4_{t+1} - \\left(c^{2} \\delta + 2 c \\rho \\sigma^2_{t} + \\left(c \\delta + \\rho\n    \\sigma^2_{t}\\right)^{2}\\right)\\right)\\\\\n\\end{bmatrix}\n\\end{equation}\n\nBy standard GMM theory, the following holds, if the weighting matrix \\newline $W_{\\omega_r,T} \\pto \\E[h(\\sigma^2_t,\n\\sigma^2_{t+1} \\ivert \\omega_r)' h(\\sigma^2_t, \\sigma^2_{t+1} \\ivert \\omega_r)]^{-1}$.\nWe have \n\n\\begin{equation}\n    \\sqrt{T}(\\widehat{\\omega}_r - \\omega_r) \\dto N\\left(0, \\Omega_{\\omega_r}\\right),\n\\end{equation}\n\n\\noindent where\n\n\\begin{equation}\n    \\Omega_{\\omega_r} \\coloneqq \\left(\\E\\left[h_{\\omega_r}(\\sigma^2_{t}, \\sigma^2_{t+1}, \\xi_{1})\\right]'\n    \\E[h(\\sigma^2_t, \\sigma^2_{t+1} \\ivert \\omega_r)' h(\\sigma^2_t, \\sigma^2_{t+1} \\ivert \\omega_r)]^{-1}\n    \\E\\left[h_{\\omega_r}(\\sigma^2_{t}, \\sigma^2_{t+1}, \\xi_{1})\\right]\\right)^{-1}\n\\end{equation}\n\n\\noindent We estimate this by replacing the population expectations and covariances by their sample counterparts.\n\n\\subsection{$\\xi_1$}\\label{sec:est_xi2}\n\nWe estimate $\\xi_1$ by weighted least squares, a special case of GMM. \n\n\\begin{equation}\n    \\E\\left[r_{t+1} \\mvert \\sigma^2_t, \\sigma^2_{t+1}\\right]  = \\gamma + \\beta \\sigma^2_t + \\psi \\sigma^2_{t+1}\n\\end{equation}\n\nThe only unusual part is we know that $\\Var(r_{t+1} \\ivert \\sigma^2_t, \\sigma^2_{t+1}) = (1-\\phi^2)\n\\sigma^2_{t+1}$.\nConsequently, the regression results  are more efficient if we adjust for heteroskedasticity.\nHowever, we do not know $\\phi$, and so this might seem impossible.\nHowever, since time-invariant parts of heteroskedasticity adjustments cancel, reweighting by the inverse of\n$\\sigma^2_{t+1}$ achieves is equivalent to the optimal reweighting. \nAlso, since $\\sigma^2_{t+1}$ is contained in the conditioning set, the fact that it is viewed as a random variable\nin other parts  of the regression is irrelevant.\nLet $u_t = \\frac{r_{t+1} - (\\gamma + \\beta \\sigma^2_{t} + \\psi \\sigma^2_{t+1}}{\\sigma^2_{t+1}}$.\n\nSince this regression is exactly identified, any positive-definite weight matrix, including the identity is\noptimal.\nConsequently, we have the following result, where the WLS covariance matrix has the standard form:\n\n\\begin{equation}\n    \\Omega_{\\xi_1} = \\E\\left[\\left(1, \\sigma^2_{t}, \\sigma^2_{t+1}\\right) \\left(1, \\sigma^2_{t},\n    \\sigma^2_{t+1}\\right)'\\right]^{-1} \\Var\\left(u_t\\right).\n\\end{equation}\n\n\n\\subsection{Step 3: $\\xi_2$}\n\nWe know that $\\Var(r_{t+1} \\vert \\sigma^2_{t+1} \\sigma^2_t) = (1-\\phi^2) \\sigma^2_{t+1}$.\nThis implies $\\Var(\\frac{r_{t+1}}{\\sigma_{t+1}} \\vert \\sigma^2_{t+1}, \\sigma^2_t) = 1 - \\phi^2$.\nSince we consistently estimate the conditional mean of $r_{t+1}$ in \\cref{sec:est_xi2}, the residuals ---\n$\\widehat{u}_t = \\frac{r_{t+1} - \\widehat{\\gamma} - \\widehat{\\beta}\\sigma^2_t - \\widehat{\\psi}\n\\sigma^2_{t+1}}{\\sigma_{t+1}}$ --- satisfy $\\frac{1}{T} \\sum_{t=1}^T \\hat{u}_t^2 \\pto (1 - \\phi^2)$.\n\nDefine $\\widehat{\\xi}_2 \\coloneqq 1 - \\frac{1}{T} \\sum_{t=1}^T \\hat{u}_t^2 \\pto (1 - \\phi^2)$.\nThen $\\widehat{\\xi}_2 \\dto N(0, \\Omega_{\\xi_2})$ for some covariance matrix $\\Omega_{\\xi_2}$, since this is a  GMM\nestimator.\nWhat is $\\Omega_{\\xi_2}$.\nSince we are just identified, standard GMM theory says it is the covariance of the moment condition scaled by the\nappropriate derivative. \nSince we are estimating a mean shifted by a constant, the derivative equals $1$.\nConsequently, $\\Omega_{\\xi_2} = \\Var(\\frac{u^2_t}{\\sigma^2_{t+1}})$, which can be estimated by\n$\\frac{1}{T} \\sum_{t=1}^T (\\frac{\\widehat{u}_t^2}{\\sigma^2_{t+1}} - \\frac{1}{T} \\sum_{t=1}^T\n\\frac{\\widehat{u}_t^2}{\\sigma^2_{t+1}})^2$, i.e.\\@ the sample covariance of the squared residuals. \n\n\\subsection{Combining $\\Omega_{\\omega_r}, \\Omega_{\\xi_2}$, and $\\Omega_{\\xi_2}$}\n\nEach of $\\Omega_{\\xi_i}$ are of the form $(\\E[h_{\\xi_{i}}(\\sigma^2_{t+1}, \\sigma^2_t \\ivert \\xi_i)]'\n\\Var(h(\\sigma^2_{t+1}, \\sigma^2_t \\ivert \\xi_i) \\ivert \\xi_i)^{-1} \\E[h_{\\xi_{i}}(\\sigma^2_{t+1}, \\sigma^2_t\n\\ivert \\xi_i) \\ivert \\xi_i])^{-1}$.\nConsequently, the off-diagonal blocks of the joint covariance matrix $\\Omega$ come from two places:\nthe derivatives and the covariance of the moments.  \nSince the moments in the first stage do not depend on the parameters in the second stage, and vice-versa, the\nderivatives to not cause any co-movement. \nThe other cases are trickier, and so we consider them each in turn.\n\nConsider the covariance between $h(\\sigma^2_{t+1}, \\sigma^2_t, \\omega_r)$ and $h(\\sigma^2_{t+1}, \\sigma^2_t,\n\\xi_2)$, which we can rearrange since the moments are mean zero.  \n\n\\begin{gather}\n    \\Cov\\left(h\\left(r_{t+1}, \\sigma^2_{t+1}, \\sigma^2_t \\mvert \\omega_{r} \\right) ,\n      h\\left(\\sigma^2_{t+1} \\sigma^2_t \\mvert \\xi_2 \\right) \\right) \n%\n%\n    = \\E\\left[h(r_{t+1},  \\sigma^2_{t+1}, \\sigma^2_t \\mvert \\omega_r) h\\left(\\sigma^2_{t+1}, \\sigma^2_t \\mvert\n       \\xi_2 \\right) \\right]\n%\n%\n       \\intertext{By the law of iterated expectations.}\n%\n%\n    = \\E\\left[\\E[h\\left(r_{t+1},  \\sigma^2_{t+1}, \\sigma^2_t \\mvert \\omega_r\\right) \\mvert \\sigma^2_{t+1},\n       \\sigma^2_t] \\E\\left[h\\left(\\sigma^2_{t+1}, \\sigma^2_t \\mvert \\xi_2 \\right) \\mvert \\sigma^2_{t+1},\n       \\sigma^2_t\\right] \\right]\n\\end{gather}\n\nThe first term in the expression above equals zero, and, hence, so does the entire expression.\nIn other words, the first two set of moment conditions are independent.  \nBy an identical argument, the first and third moments are independent as well.\n\nWe now consider how the second and their sets of moments are related.\nSince the derivatives are with respect to different parameters (and constant) no dependence arises from there.\nThe question is how are the moment conditions in the second and third steps related.\nThe second stage moment condition is a conditional mean and third stage moment is a conditional covariance.\nLet $u_t$ denote the error term in that regression (as it did above).\n\n\\begin{equation}\n    \\E\\left[\\E\\left[\\frac{r_{t+1} - \\E\\left[r_{t+1}\\mvert \\sigma^2_{t+1} \\sigma^2_t\\right]}{\\sigma_{t+1}} \\right]\n    \\E\\left[\\frac{(r_{t+1} - \\E\\left[r_{t+1} \\mvert \\sigma^2_{t+1} \\sigma^2_t\\right])^2}{\\sigma^2_{t+1}}\\right]\n    \\right] \n%\n    = \\E\\left[\\E\\left[\\frac{u_t u_t^2}{\\sigma^2_{t+1}}\\right] \\mvert \\sigma^2_t, \\sigma^2_{t+1} \\right]  = 0\n\\end{equation}\n\nSince $u_t$ is conditionally Gaussian, its conditional third moment equals zero.  \nBy the law of iterated expectations, its unconditional moment does as well.\n\nIn other words, the second and third set of moments are uncorrelated.\nNow, the careful reader might be worried about filling in the population expectations instead of their estimators\nin the regression above.\nHowever, since the expectations are linear and consistently estimable, this error vanishes in the limit. \nIntuitively, OLS mean and variance estimates are asymptotically independent.\n\nIn addition, since all three components are asymptotically independent; the inverse of a block-diagonal matrix is\nblock-diagonal, and we using optimal weighting matrices in each part, we are using an\noptimal weighting matrix for $\\xi$, not just its components.\n\n\n\\section{Stage 2}\n\nIn this stage, we convert the estimates for $\\xi$ into estimates for $\\omega$. \nWe do this by specifying a link function.\nSince $(\\rho, c, \\delta)'$ shows up in both $\\xi$ and $\\omega$, the link function for those parameters is the\nidentify function.\nThe third set of parameters $\\xi_3 = \\phi^2$, and so we use that as a link function.\nWe also use the reduced-form estimates as link functions, as well, i.e.\\@\n\n\\begin{equation}\n    g(\\xi, \\omega) = \\xi - (\\rho, c, \\delta, \\beta(\\rho, c, \\phi, \\pi, \\theta), \\gamma(\\rho, \\delta, c, \\phi, \\pi,\n    \\theta), \\psi(\\rho, c, \\phi, \\theta), \\phi^2)'\n\\end{equation}\n\nWe specify $g(\\xi, \\omega)$ in this way because it gives us the correct off-diagonal elements.\nIf we estimated $(\\rho, c, \\delta)$ by themselves and just plugged them in here, we would have to relate the\noff-diagonal terms in a separate step.\nIn addition, by using the optimal weight matrix for this stage, we estimate all of the parameters as efficiently\npossible using our moment conditions.\n\nDoing this implies we must be careful and treat the $\\rho,c$, and $\\delta$ on each sides of the equation as\ndifferent.\nThe 2nd-stage sample criterion function is \n\n\\begin{equation}\n    Q_T(\\omega) \\coloneqq \\frac{1}{2} g(\\widehat{\\xi}_T, \\omega)' \\W_{T} g(\\widehat{\\xi}_T, \\omega)\n\\end{equation}\n\n\\noindent  with second stage weight matrix $\\W_T$.\nWe need to estimate $\\omega$, and so we differentiate and get the first-order condition at $\\omega_0$, where $\\W\n\\coloneqq \\lim_{T \\to \\infty} \\E[W_T]$.\nThis gives\n\n\\begin{equation}\n    \\frac{\\partial Q_T}{\\partial \\omega}(\\omega_0) =  g_{\\omega}\\left(\\xi_0, \\omega_0\\right)  \\W g\\left(\\xi_0,\n    \\omega_0\\right) = 0.\n\\end{equation}\n\n\\noindent We now expand $\\widehat{\\xi}_T$ around $\\xi_0$, for some $\\widetilde{\\xi}_T$ between $\\xi_0$ and\n$\\widetilde{\\xi}_T$, \n\n\\begin{align}\n    \\sqrt{T} \\frac{\\partial Q}{\\partial \\omega}(\\omega_0) \n%\n    &= g_{\\omega}\\left(\\omega_0, \\widehat{\\xi}_T\\right) \\W_T \\left[\\sqrt{T} g\\left(\\omega_{0},\\xi_0\\right) +\n       g_{\\xi}\\left(\\omega_{0}, \\widetilde{\\xi}_T\\right)' \\sqrt{T} \\left(\\widetilde{\\xi}_T - \\xi_0\\right)\\right]\n%\n%\n    \\intertext{The first term equals zero by assumption, and the derivative is the identity matrix.}\n%\n%\n    &= g_{\\omega}\\left(\\omega, \\widehat{\\xi}_T\\right) \\W_T \\left[ \\sqrt{T} \\left(\\widetilde{\\xi}_T -\n       \\xi_0\\right)\\right]\n\\end{align}\n\n\\noindent We also need to compute the Hessian and evaluate it at $\\widehat{\\omega}_T$ a consistent estimator for\n$\\omega$.\n\n\\begin{align}\n    \\frac{\\partial^2 Q}{\\partial \\omega \\partial \\omega'}(\\widehat{\\omega}_T) &=\n%\n    g_{\\omega}\\left(\\widehat{\\omega}_T, \\widehat{\\xi}_T\\right)' \\W_T g_{\\omega} \\left(\\widehat{\\omega}_T,\n    \\widehat{\\xi}_T\\right)+ g_{\\omega, \\omega}\\left(\\widehat{\\omega}_T, \\widehat{\\xi}_T\\right) \\W_T\n    g\\left(\\widehat{\\omega}_T, \\widehat{\\xi}_T\\right)' \\\\\n%\n    &\\pto g_{\\omega}\\left(\\omega, \\xi_0\\right)' \\W g_{\\omega} \\left(\\omega, \\xi_0\\right) + 0. \n\\end{align}\n\n\\noindent if we use the optimal weight matrix --- $\\W \\coloneqq \\E[g_{\\omega_s}(\\theta_0, \\xi_0)]$.\nStandard extremum estimator theory gives\n\n\\begin{equation}\n    \\sqrt{T} \\left(\\widehat{\\omega}_T - \\omega_{0}\\right)  \\dto N\\left(0, \\left(\\E[g_{\\omega}(\\theta_0, \\xi_0)]'\n    \\Omega_{\\xi}^{-1} \\E[g_{\\omega}(\\theta_0, \\xi_0)]\\right)^{-1}\\right).\n\\end{equation}\n\n\\noindent The covariance in the middle is GMM-covariance of the reduced-form parameters.\nWe estimate it by plugging $\\widehat{\\xi}$ into to the formulas above and their derivatives.\nWe estimate the asymptotic covariance matrix by replacing its components with their sample counterparts.\n\n\n\\section{Asymptotic Distribution of the Reduced-Form Parameter}\n\nThis section gives the asymptotic distribution of the reduced-form parameter. \n\nWrite $\\omega =(\\omega_{1},\\omega_{2},\\omega_{3}),$ where $\\omega_{1}=(\\rho ,c)$, $\\omega_{2} = (\\gamma ,\\beta ,\\psi)$, and $\\omega_{3} = \\phi ^{2}$. \nBelow we describe the estimator $\\widehat{\\omega}_{1},\\widehat{\\omega}_{2},\\widehat{\\omega}_{3}$ and provide\nthe asymptotic distribution of $\\widehat{\\omega} = (\\widehat{\\omega}_{1},\\widehat{\\omega\n}_{2},\\widehat{\\omega}_{3})$.\nWe estimate these parameters separately because $\\omega_{1}$ only shows up in the conditional mean and variance of\n$r_{t+1};$ $\\omega_{2}$ only shows up in the conditional mean of $\\sigma_{t+1}^{2};$ and $\\phi $ only shows up in\nthe conditional variance of $\\sigma_{t+1}^{2}.$\n\nWe estimate $\\omega_{1}$ by GMM based on the moment condition: \n\n\\begin{eqnarray}\n    \\mathbb{E}[h_{t}(\\omega_{1,0}) & = &0,\\text{ where}  \\nonumber \\\\\n%\n    h_{t}(\\omega_{1}) & = &\\left(\n        \\begin{array}{c} \n            \\sigma_{t+1}^{2}-\\left( c\\delta +\\rho \\sigma_{t}^{2}\\right)  \\\\ \n%\n            \\sigma_{t}^{2}\\left( \\sigma_{t+1}^{2}-\\left( c\\delta +\\rho \\sigma _{t}^{2}\\right) \\right)  \\\\ \n%\n            \\sigma_{t+1}^{4}-\\left( c^{2}\\delta +2c\\rho \\sigma_{t}^{2}+\\left( c\\delta +\\sigma_{t+1}^{2}-\\left(\n            c\\delta +\\rho \\sigma_{t}^{2}\\right) ^{2}\\right) \\right)  \\\\ \n%\n            \\sigma_{t}^{2}\\left( \\sigma_{t+1}^{4}-\\left( c^{2}\\delta +2c\\rho \\sigma _{t}^{2}+\\left( c\\delta\n            +\\sigma_{t+1}^{2}-\\left( c\\delta +\\rho \\sigma _{t}^{2}\\right) ^{2}\\right) \\right) \\right)  \\\\ \n%\n            \\sigma_{t}^{4}\\left( \\sigma_{t+1}^{4}-\\left( c^{2}\\delta +2c\\rho \\sigma _{t}^{2}+\\left( c\\delta\n            +\\sigma_{t+1}^{2}-\\left( c\\delta +\\rho \\sigma _{t}^{2}\\right) ^{2}\\right) \\right) \\right) \n        \\end{array}\\right).\n\\end{eqnarray}\n%\nThe optimal GMM estimator is\n%\n\\begin{eqnarray}\n    \\widehat{\\omega}_{1} & = & \\underset{\\omega_{1}\\in \\Lambda_{1}}{\\arg\\min} \n%\n    \\overline{h}_{T}(\\omega_{1})^{\\prime}W_{T}\\overline{h}_{T}(\\omega_{1}), \\text{ where}  \\nonumber \\\\ \n%\n    \\overline{h}_{T}(\\omega_{1}) & = &T^{-1}\\sum_{t = 1}^{T}h_{t}(\\omega_{1}), \\nonumber \\\\\n%\n    W_{T} & = &T^{-1}\\sum_{t = 1}^{T}h_{t}(\\widetilde{\\omega}_{1})h_{t}(\\widetilde{\\omega}_{1})^{\\prime\n   }-\\overline{h}_{T}(\\widetilde{\\omega}_{1})\\overline{h} _{T}(\\widetilde{\\omega}_{1})^{\\prime},\n\\end{eqnarray}\n%\nwhere $\\widetilde{\\omega}_{1}$ is the preliminary GMM estimator based on the identify covariance matrix.\n\nWe estimate $\\omega_{2}$ by the GLS estimator because $\\gamma, \\beta, \\psi$ are the intercept and linear\ncoefficients of the conditional mean function and the conditional variance is proportional to $\\sigma_{t+1}^{2}$. \nDefine $x_{t} = \\sigma_{t+1}^{-1}(1,\\sigma_{t}^{2},\\sigma_{t+1}^{2})$ and $y_{t} = \\sigma_{t+1}^{-1}r_{t+1}$. \nThe GLS\\ estimator of $\\omega_{2}$ is\n%\n\\begin{equation}\n    \\widehat{\\omega}_{2} = \\left( \\sum_{t = 1}^{T}x_{t}x_{t}^{\\prime}\\right) ^{-1}\\sum_{t = 1}^{T}x_{t}y_{t}.\n\\end{equation}\n\nWe estimate $\\omega_{3}$ by the sample variance estimator. \nDefine \n%\n\\begin{equation}\n    \\widehat{y}_{t} = x_{t}\\widehat{\\omega}_{2} = \\sigma_{t+1}^{-1}(\\widehat{\\gamma}+\\widehat{\\beta\n   }\\sigma_{t}^{2}+\\widehat{\\psi}\\sigma_{t+1}^{2}).\n\\end{equation}\n%\nThe estimator of $\\omega_{3}$ is \n\\begin{equation}\n    \\widehat{\\omega}_{3} = \\max \\{1-T^{-1}\\sum_{t = 1}^{T}\\left( y_{t}-\\widehat{y}_{t}\\right) ^{2},0\\}.\n\\end{equation}%\n[**XC. In practice, do we need to impose the estimator is positive?]\n\nThe next lemma provides the asymptotic distribution of the estimator $\\widehat{\\omega}$. \nLet $h_{\\omega ,t}(\\omega_{1})\\in \\mathbb{R}^{5\\times 2}$ denote the derivative of $h_{t}(\\omega_{1})$ w.r.t.\\@\n$\\omega_{1}$.\nDefine\n%\n\\begin{eqnarray}\n    \\Omega_{1} & = &\\left \\{ \\mathbb{E}\\left[ h_{\\omega ,t}\\left( \\omega _{1,0}\\right) \\right]^{\\prime}\n        \\mathbb{E}[h_{t}(\\omega_{1,0})h_{t}(\\omega _{1,0})^{\\prime}]^{-1}\\mathbb{E}\\left[\n    h_{\\omega,t}\\left(\\omega_{1,0}\\right) \\right] \\right \\} ^{-1},  \\notag \\\\ \n%\n    \\Omega_{2} & = &\\mathbb{E}\\left[ x_{t}x_{t}^{\\prime}\\right] ^{-1}\\mathbb{E[(} y_{t}-x_{t}^{\\prime\n   }\\omega_{2,0})^{2}],  \\notag \\\\\n%\n    \\Omega_{3} & = &\\mathbb{V[}\\left( y_{t}-x_{t}^{\\prime}\\omega_{2,0}\\right)^{2}]\n\\end{eqnarray}\n\n\\begin{lemma}\nSuppose Assumptions *** hold. Then\n\n\\begin{equation}\n    T^{1/2}\\left( \n%\n    \\begin{array}{c}\n        \\widehat{\\omega}_{1}-\\omega_{1,0} \\\\ \n        \\widehat{\\omega}_{2}-\\omega_{2,0} \\\\ \n        \\widehat{\\omega}_{3}-\\omega_{3,0}%\n    \\end{array}\\right) \n%\n    \\rightarrow_{d}\\xi_{\\omega}  = \n%\n   \\left(\\begin{array}{c}\n            \\xi_{\\omega 1} \\\\ \n            \\xi_{\\omega 2} \\\\ \n            \\xi_{\\omega 3}%\n   \\end{array}\\right) \n%\n   \\sim N\\left( 0,\n%\n    \\begin{array}{ccc}\n        \\Omega_{1} & 0 & 0 \\\\ \n        0 & \\Omega_{2} & 0 \\\\ \n        0 & 0 & \\Omega_{3}%\n    \\end{array}\\right).\n\\end{equation}\n\\end{lemma}\n\n\n\\begin{proof}\n    Will be added later.\n\\end{proof}\n\n\n\\section{Robust Inference for Risk Price}\n\nThe reduced-form parameters are $\\omega  = (\\rho ,c,\\gamma ,\\beta ,\\psi ,\\phi ^{2})$. \nUsing the conditional mean and conditional variance derived in the paper, we estimate $\\, \\omega_{1} = (\\rho ,c)$\nby the GMM estimator, estimate $\\omega_{2} = (\\psi ,\\beta ,\\gamma )$ by the GLS estimator, and estimate\n$\\omega_{3} = \\phi^{2}$ by the method of moments estimator for the variance.\n\nWe can show that the estimator $\\widehat{\\omega}$ satisfies\n\n\\begin{equation}\n    T^{1/2}(\\widehat{\\omega}-\\omega_{0})\\rightarrow_{d}\\upsilon_{\\omega}\\sim N(0,V).\n\\end{equation}%\n\nSee the next section for details. \nNote that these estimators do not involve the structural parameters $\\theta $ and $\\pi$.\nWe do not plug in $\\beta ,\\gamma ,\\psi $ as functions of $\\theta $ and $\\pi .$ Instead, we treat $\\beta ,\\gamma\n,\\psi $ just as linear coefficients and estimate them by GLS.\n\nWe estimate the structural parameters $\\theta $ and $\\pi $ using $\\widehat{ \\omega}$ and the link functions\nspecified below. \nFirst, we know that\n%\n\\begin{equation}\n    \\label{psi_fn} \n    \\psi_{0}=\\phi_{0}\\left( c_{0}\\left( 1+\\rho_{0}\\right) \\right) ^{-1/2} - \\left( 1-\\phi_{0}^{2}\\right)\n    /2-(1-\\phi_{0}^{2})\\theta_{0}\n\\end{equation}\n%\nwhen all parameters are evaluated at the true values. \nThis equation strongly identifies $\\theta_{0}$ because $\\phi_{0}$ is assumed to be negative and bounded away from\n1 in magnitude.. \nIt follows from (\\cref{psi_fn}) that\n\n\\begin{equation}\n    \\theta_{0} = L(\\omega_{0})=-(1-\\phi_{0}^{2})^{-1}\\left[ \\psi_{0}-\\phi_{0}\\left( c_{0}\\left( 1+\\rho_{0}\\right)\n    \\right)^{-1/2}-\\left( 1-\\phi_{0}^{2}\\right) /2\\right] .\n\\end{equation}\n%\nThus, we estimate $\\theta_{0}$ by\n%\n\\begin{equation}\n    \\widehat{\\theta}=L(\\widehat{\\omega}).\n\\end{equation}\n%\nBy the delta method, we know that\n%\n\\begin{equation}\n    T^{1/2}(\\widehat{\\theta}-\\theta_{0})\\rightarrow_{d}L_{\\omega}(\\omega_{0})^{\\prime}\\upsilon_{\\omega},\n\\end{equation}\n%\nwhere $L_{\\omega}(\\omega )\\in R^{d_{\\omega}}$ denote the derivative of $L(\\omega )$ w.r.t.\\@ $\\omega$. \nThe inference for $\\theta $ is standard. \nA confidence interval for $\\theta $ can be obtained by inverting the $t$-statistic with a critical value obtained\nfrom the standard normal distribution.\n\nNext, we consider inference for the structural parameter $\\pi$. \nThis is a non-standard problem because $\\pi $ is potentially weakly identified. \nDefine\n%\n\\begin{equation}\n    g(\\pi ,\\omega )=\\left( \n%\n    \\begin{array}{c}\n        \\gamma -\\left[ B\\left( \\pi +C\\left( \\theta_{L}-1\\right) \\right) -B\\left( \\pi +C\\left( \\theta_{L}\\right)\n        \\right) \\right]  \\\\ \n%\n        \\beta -\\left[ A\\left( \\pi +C\\left( \\theta_{L}-1\\right) \\right) -A\\left( \\pi +C\\left( \\theta_{L}\\right)\n        \\right) \\right] \n    \\end{array}\\right),\n%\n    \\text{ where}\\ \\theta_{L} = L(\\omega).\n\\end{equation}\n%\nWe know \n%\n\\begin{equation}\n    g(\\pi_{0}, \\omega_{0})=0 \\in \\mathbb{R}^{2}.\n\\end{equation}\n%\nInference on $\\pi $ is based on the function $g(\\pi ,\\widehat{\\omega})$ because $\\widehat{\\omega}$ is a\nconsistent estimator of $\\omega_{0}$.\nBy the consistency of $\\widehat{\\omega}$,\n%\n\\begin{equation}\n    T^{1/2}\\left[ g(\\pi, \\widehat{\\omega}) - g(\\pi,\\omega_{0})\\right] \\Rightarrow \\upsilon(\\pi) = G(\\pi,\n    \\omega_{0})^{\\prime}\\upsilon_{\\omega},\n\\end{equation}%\n\n\\noindent where $G(\\pi ,\\omega )$ denote the derivative of $g(\\pi ,\\omega )$ w.r.t.\\@ to $\\omega$. \nThe Gaussian process $\\upsilon(\\pi)$ has covariance kernel \n%\n\\begin{equation}\n    \\Sigma (\\pi_{1},\\pi_{2})=G(\\pi_{1},\\omega_{0})^{\\prime}VG(\\pi_{2},\\omega_{0}).\n\\end{equation}\n%\nWe can estimate $\\Sigma (\\pi_{1},\\pi_{2})$ by \n%\n\\begin{equation}\n    \\widehat{\\Sigma}(\\pi_{1},\\pi_{2})=G(\\pi_{1},\\widehat{\\omega})^{\\prime}\n    \\widehat{V}G(\\pi_{2},\\widehat{\\omega}),\n\\end{equation}\n\n\\noindent where $\\widehat{V}$ is a consistent estimator of $V.$\n\nWe construct a confidence interval for $\\pi $ by inverting tests $H_{0}:\\pi =\\pi_{0}$ vs $H_{0}:\\pi \\neq \\pi_{0}$. \nThe test statistic is the QLR statistic:\n%\n\\begin{equation}\n    QLR=Tg(\\pi_{0},\\widehat{\\omega})^{\\prime}\\widehat{\\Sigma}(\\pi_{0},\\pi _{0})^{-1}g(\\pi_{0},\\widehat{\\omega})\n    - \\underset{\\pi \\in \\Pi}{\\min}Tg(\\pi ,\\widehat{\\omega})^{\\prime}\\widehat{\\Sigma}(\\pi,\\pi)^{-1}\n    g(\\pi,\\widehat{\\omega}).  \n\\end{equation} \n\nTo obtain the critical value, we follow the conditional inference approach in Andrews and Mikusheva (2016). To\nthis end, first construct a projection residual process:\n%\n\\begin{equation}\n    h(\\pi ,\\widehat{\\omega})=g(\\pi ,\\widehat{\\omega})-\\widehat{\\Sigma}(\\pi ,\\pi_{0})\\widehat{\\Sigma\n   }(\\pi_{0},\\pi_{0})^{-1}g(\\pi_{0},\\widehat{\\omega}).\n\\end{equation}\n%\nBy construction, $h(\\pi ,\\widehat{\\omega})$ and $g(\\pi_{0},\\widehat{\\omega})$ are independent asymptotically. \nConditional on $h(\\pi ,\\widehat{\\omega})$, we obtain the $1-\\alpha $ quantile of the QLR statistic, denoted\n$c_{\\alpha}(h)$, by sampling from the asymptotic distributions of $g(\\pi_{0},\\widehat{\\omega})$ under the null.\nSpecifically, we take independent draws $\\upsilon^{\\ast}\\sim N(0,\\Sigma (\\pi_{0},\\pi_{0}))$ and produce simulated\nprocess:\n%\n\\begin{equation}\n    g^{\\ast}(\\pi ,\\widehat{\\omega}) = h\\left(\\pi ,\\widehat{\\omega}\\right) + \\widehat{\\Sigma} (\\pi\n    ,\\pi_{0})\\widehat{\\Sigma}(\\pi_{0},\\pi_{0})^{-1}\\upsilon^{\\ast}.\n\\end{equation}%\n%\nWe then calculate\n\\begin{equation}\n    QLR^{\\ast}=Tg^{\\ast}(\\pi_{0},\\widehat{\\omega})^{\\prime}\\widehat{\\Sigma} (\\pi_{0},\\pi_{0})^{-1}g^{\\ast\n   }(\\pi_{0},\\widehat{\\omega})-\\underset{\\pi \\in \\Pi}{\\min}Tg^{\\ast}(\\pi ,\\widehat{\\omega})^{\\prime\n   }\\widehat{\\Sigma} (\\pi ,\\pi )^{-1}g^{\\ast}(\\pi ,\\widehat{\\omega}), \n\\end{equation}\n%\nwhich is a random drawn from the conditional distribution of the $QLR$ statistic given $h_{T}(\\pi ,\\widehat{\\omega\n})$, when $g(\\pi_{0},\\widehat{ \\omega})$ is drawn from its asymptotic distribution. \nIn practice, we repeat this process for a large number of times and obtain $c_{\\alpha}(h)$ by simulation.\n\nWe reject the null $H_{0}:\\pi =\\pi_{0}$ if $QLR\\geq c_{\\alpha}(h)$. \nThe confidence interval for $\\pi $ is the collection of null values that are not rejected as the null value. \nNote that the construction of this CI\\ does not involve estimation of $\\pi$.\n\n\n\\end{document}\n\n\n", "meta": {"hexsha": "cc982310073161362ba6507af68e888e5a57d863", "size": 24514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/early versions/asymptotic_dist_derivation.tex", "max_stars_repo_name": "sangrey/RiskPriceInference", "max_stars_repo_head_hexsha": "9ec8b235e3d1f24281890a5f689840affd3f495e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/early versions/asymptotic_dist_derivation.tex", "max_issues_repo_name": "sangrey/RiskPriceInference", "max_issues_repo_head_hexsha": "9ec8b235e3d1f24281890a5f689840affd3f495e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/early versions/asymptotic_dist_derivation.tex", "max_forks_repo_name": "sangrey/RiskPriceInference", "max_forks_repo_head_hexsha": "9ec8b235e3d1f24281890a5f689840affd3f495e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.1693693694, "max_line_length": 150, "alphanum_fraction": 0.6592151424, "num_tokens": 8596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4057853168690259}}
{"text": "\\documentclass{stdlocal}\n\\begin{document}\n\\section{Preliminaries} % (fold)\n\\label{sub:preliminaries}\n  To systematically approach the implementation of PRNGs, basic knowledge in the topics of stochastics and statistics is administrable.\n  Together, these topics will give a deeper understanding of randomness in deterministic computer systems, a formal description of pseudorandom sequences and generators, and the mathematical foundation of Monte Carlo algorithms.\n  Based on them, we are capable of scientifically analyzing PRNGs concerning their randomness properties.\n  Afterwards, we will give a brief overview of template mechanisms in the C++ programming language and the fundamentals of modern computer architecture.\n\n  \\subsection{Probability Theory} % (fold)\n  \\label{sub:stochastics}\n    The observation of random experiments resulted in the construction of probability theory.\n    But probability theory itself does not use a further formalized concept of randomness \\autocite{schmidt2009}.\n    % Randomness itself plays a minor role in probability theory and is used in form of realizations of random variables.\n    In fact, it allows us to observe randomness without defining it \\autocite{volchan2002}.\n    % Actually, typical formalizations rely on probability theory.\n    % This connection makes the development of RNGs possible.\n    % Hence, in the following we will give only the formal definition of relevant structures without further discussions and will postpone an examination of randomness to the next section.\n    Hence, we will postpone an examination of truly random sequences to section \\ref{sec:pseudorandom_number_generators}.\n\n    According to \\textcite{schmidt2009}, Kolmogorov embedded probability theory in the theory of measurement and integration.\n    Although it heavily relies on these theoretical structures, probability theory is one of the most important applications of measurement and integration theory.\n    Therefore we will assume basic knowledge in this topic and refer to \\textcite{schmidt2009} and \\textcite{elstrodt2011} for a more detailed introduction to measure spaces, measurable functions, and integrals.\n    Propositions and theorems will be given without proof.\n\n    The underlying structure of probability theory, which connects it to measure theory, is the probability space.\n    It is a measure space with a finite and normalized measure.\n    This gives access to all the usual results of measure theory and furthermore unifies discrete and continuous distributions.\n    \\autocite[\\ppno~193-195]{schmidt2009}\n\n    \\begin{definition}[Probability Space]\n      A probability space is a measure space $\\roundBrackets{\\Omega, \\mathscr{F}, P}$ such that $P(\\Omega)=1$.\n      In this case, we call $P$ the probability measure, $\\mathscr{F}$ the set of all events, and $\\Omega$ the set of all possible outcomes of a random experiment.\n    \\end{definition}\n    % For our purposes, the set of possible outcomes $\\Omega$ will be a finite or countable infinite set.\n    % Hence, we can choose $\\mathscr{F}$ to be the power set $\\mathscr{P}(\\Omega)$.\n    Due to the complex definition\n    % \\footnote{Notation and symbols not directly defined are explained in the symbol table.}\n    of a measure space, it is convenient to not have to explicitly specify the probability space when analyzing random experiments.\n    Instead, we use random variables which are essentially measurable functions on a probability space \\autocite[\\pno~194]{schmidt2009}.\n    For complicated cases, these will serve as observables for specific properties and will make the analysis much more intuitive.\n\n    \\begin{definition}[Random Variable]\n      Let $(\\Omega,\\mathscr{F},P)$ be a probability space and $(\\Sigma,\\mathscr{A})$ a measurable space.\n      A measurable function $\\function{X}{\\Omega}{\\Sigma}$ is called a random variable.\n\n      In this case, we denote with $P_X\\define P\\composition\\inverse{X}$ the distribution and with $(\\Sigma,\\mathscr{A},P_X)$ the probability space of $X$.\n      % We call $X(ω)$ for $ω\\in\\Omega$ a realization of $X$.\n      % Let $\\function{Y}{\\Omega}{\\Sigma}$ be another random variable.\n      % $X$ and $Y$ are identically distributed if $P_X = P_Y$.\n      Two random variables are identically distributed if they have the same distribution.\n      Additionally, we say that $X$ is a real-valued random variable if $\\Sigma = \\setReal$ and $\\mathscr{A} = \\mathscr{B}(\\setReal)$.\n    \\end{definition}\n    From now on, if a random variable is defined then, if not stated otherwise, it is assumed there exists a proper probability space $(\\Omega,\\mathscr{F},P)$ and measurable space $(\\Sigma, \\mathscr{A})$.\n\n    Another important concept of stochastics is known as independence.\n    In \\textcite{schmidt2009} it is defined for a family of events, a family of sets of events, and a family of random variables.\n    If we think of random variables as observables then their independence means that their outcomes do not influence each other.\n    % It makes only sense in the context of probability theory\n    For our purposes, the general definition of all three forms of independence is distracting.\n    In a computer, it makes no sense to talk about uncountably many elements.\n    Therefore the following definition of independence takes only a countable sequence of random variables into account.\n    Furthermore, to make it more understandable, this definition uses a theorem from \\textcite[\\pno~238]{schmidt2009} which characterizes the independence of random variables.\n    % Here, we will use a simpler equivalent definition  because, for a computer, all we need are finite sequences of random variables.\n\n    \\begin{definition}[Independence]\n      % Let $(\\Omega,\\mathscr{F},P)$ be a probability space.\n      % Two events $A, B \\in \\mathscr{F}$ are independent if $P(A\\cap B)=P(A)P(B)$.\n      % Let $(\\Sigma_i,\\mathscr{A}_i)$ for $i\\in\\set{1,2}{}$ be measurable spaces and $X_i$ random variables with $X\\define X_1\\times X_2$.\n      % They are called independent if $P_X = P_{X_1} \\otimes P_{X_2}$.\n      Let $I\\subset\\setNatural$ and $X_i$ be a random variable for all $i\\in I$.\n      Then these random variables are independent if the following equation holds for all finite subsets $J\\subset I$ whereby we denote the respective random vector with $X_J \\define \\roundBrackets{X_i}_{i\\in J}$.\n      \\[\n        P_{X_J} = \\bigotimes_{i\\in J} P_{X_i}\n      \\]\n    \\end{definition}\n    Typical observations of random sequences include the estimation of the expectation value and the variance.\n    Both of these values are needed for analyzing PRNGs and the development of Monte Carlo simulations \\autocite{landau2014}.\n    Due to their deep connection to the integral, both of these moments are defined for real-valued random variables.\n    We give the usual definitions based on \\textcite[\\ppno~274-276]{schmidt2009} in a simplified form.\n\n    \\begin{definition}[Expectation Value and Variance]\n      Let $X$ be a real-valued random variable such that $\\integral{\\Omega}{}{\\absolute{X}}{P}<\\infty$.\n      Then the expectation value $\\expect X$ and variance $\\var X$ of $X$ is defined in the following way.\n      \\[\n        \\expect X \\define \\integral{\\Omega}{}{X(ω)}{P(ω)}\n        \\separate\n        \\var X \\define \\expect\\roundBrackets{X - \\expect X}^2\n      \\]\n    \\end{definition}\n    To not rely on the underlying probability space directly, we want to be able to compute the expectation value through the respective distribution of the random variable.\n    The theory of measure and integration gives the following proposition, also known as rule of substitution \\autocite[\\pno~276]{schmidt2009}.\n\n    \\begin{proposition}[Substitution]\n    \\label{proposition:substitution}\n      Let $X$ be real-valued random variable and $\\function{f}{\\setReal}{\\setReal}$ a measurable function such that $\\integral{\\Omega}{}{\\absolute{f}}{P_X} < \\infty$.\n      Then the following equation holds.\n      \\[\n        \\expect(f\\composition X) = \\integral{\\setReal}{}{f(x)}{P_X(x)}\n      \\]\n      In particular, if $\\expect \\absolute{X} < \\infty$ then the above equation can be reformulated as follows.\n      \\[\n        \\expect X = \\integral{\\setReal}{}{x}{P_X(x)}\n      \\]\n    \\end{proposition}\n    The distribution of real-valued random variables is univariate and as a result can be described by so-called cumulative distribution functions (CDFs).\n    The CDF intuitively characterizes the distribution and simplifies the analysis.\n    Further, it can be proven that every CDF belongs to a univariate distribution.\n    According to \\textcite[\\pno~246]{schmidt2009}, this is the theorem of correspondence.\n    Sometimes it is even possible to define a probability density; a function that is the Lebesgue density of the respective distribution \\autocite[\\pno~255]{schmidt2009}.\n\n    \\begin{definition}[Probability Density and Cumulative Distribution Function]\n      Let $X$ be a real-valued random variable.\n      Then the respective cumulative distribution function is defined as follows.\n      \\[\n        \\function{F_X}{\\setReal}{[0,1]}\n        \\separate\n        F_X(x) \\define P_X((-\\infty,x])\n      \\]\n      We call the function $\\function{p}{\\setReal}{[0,\\infty)}$ a probability density of $X$ if for all $A\\in\\mathscr{B}(\\setReal)$\n      \\[\n        P_X(A) = \\integral{A}{}{p(x)}{λ(x)}\\ .\n      \\]\n    \\end{definition}\n    % \\begin{theorem}[Correspondence]\n    %   Let $X$ be a real-valued random variable.\n    %   There exists a unique monotone non-decreasing, right-continuous function $\\function{F_X}{\\setReal}{[0,1]}$ with\n    %   \\[\n    %     \\lim_{x\\rightarrow -\\infty} F_X(x) = 0\n    %     \\separate\n    %     \\lim_{x\\rightarrow +\\infty} F_X(x) = 1\n    %   \\]\n    %   such that\n    %   \\[\n    %     P_X((a,b]) = F(b) - F(a)\n    %   \\]\n    % \\end{theorem}\n    As well as CDFs, probability densities can greatly simplify computations which are based on absolute continuous random variables.\n    The following proposition, obtained from \\textcite{schmidt2009}, shows the simplified computation of an expectation value through a Lebesgue integral.\n\n    \\begin{proposition}[Chaining]\n    \\label{proposition:chaining}\n      Let $X$ be a real-valued random variable with $p$ as its probability density.\n      If $\\function{f}{\\setReal}{\\setReal}$ is a measurable function such that $\\expect \\absolute{f\\circ X} < \\infty$ then\n      \\[\n        \\expect \\roundBrackets{f\\composition X} = \\integral{\\setReal}{}{f(x)p(x)}{λ(x)}\\ .\n      \\]\n    \\end{proposition}\n    A last important theorem to name is the strong law of large numbers (SLLN).\n    According to \\textcite[\\pno~13]{graham2013}, the principles of Monte Carlo methods are based on this theorem.\n    It uses a sequence of identically and independently distributed (iid) random variables.\n    Please note, there exist many more variations of this theorem.\n    We will use a simplified version from \\textcite{graham2013}.\n\n    \\begin{theorem}[Strong Law of Large Numbers]\n    \\label{theorem:slln}\n      Let $(X_n)_{n\\in\\setNatural}$ be a sequence of iid real-valued random variables with finite expectation value $μ$.\n      Then the following equation holds $P$-almost everywhere.\n      \\[\n        \\lim_{n\\to\\infty} \\frac{1}{n}\\sum_{i=1}^n X_i = μ\n      \\]\n    \\end{theorem}\n  % subsection stochastics (end)\n\n  % \\subsection{Number Theory and Finite Fields} % (fold)\n  % \\label{ssub:finite_fields}\n\n  % % subsection finite_fields (end)\n\n  \\subsection{The C++ Programming Language} % (fold)\n  \\label{sub:the_c_programming_language}\n    As already told in the introductory section \\ref{sec:introduction}, the C++ programming language is an adequate candidate for developing high-performance low-level structures while keeping the high degree of abstraction that makes the use of libraries easier and more consistent.\n    C++ features multiple programming styles, like procedural programming, data abstraction, object-oriented programming, as well as generic programming which is also known as template metaprogramming \\autocite{stroustrup2014,vandevoorde2018}.\n    The type mechanism makes C++ a strongly typed language.\n    To exploit this, we will always try to map problems to an abstract data structure.\n    Furthermore, the built-in facilities of C++, such as templates, function overloading, type deduction, and lambda expressions, simplify the type handling and the generalization of algorithms.\n    Additionally, C++ provides a standard library, called the standard template library (STL), consisting of header files providing default templates to use for a wide variety of problems.\n    In this thesis, we will rely on the random utilities the STL exhibits.\n    We will also assume basic knowledge in C++ and refer to \\textcite{stroustrup2014} and \\textcite{meyers2014} for a detailed introduction to the general usage of the language.\n    A complete online reference of the language is given by \\textcite{cppreference}.\n\n    The C++ programming language keeps evolving by defining different language standards every three years which are published by the ISO C++ standardization committee.\n    Newer standards typically introduce modern language features, fix old behavior and add new algorithms and templates to the STL.\n    Hence, modern C++ separates into the standards C++11, C++14, and C++17 each published in the year 2011, 2014, and 2017, respectively.\n    Currently, we are waiting for the C++20 standard specification which will provides even more advanced features concerning template metaprogramming and concurrency.\n    At the time of writing this thesis, C++17 is the most modern specification and as a consequence it will be used throughout the code.\n    \\autocite{stroustrup2014,meyers2014,vandevoorde2018}\n\n    To design the API of a library supplying vectorized RNGs and some advanced utilities, we will heavily rely on different template metaprogramming techniques.\n    For getting deeper into the topic, we will refer to \\textcite{vandevoorde2018} and again to \\textcite{meyers2014}.\n    Here, we will only be able to list the most important terms, techniques and rules that will be used throughout the code.\n\n    \\begin{description}\n      \\item[Template Argument Deduction]\n        \\textquote[\\cite{cppreference}]{%\n          In order to instantiate a function template, every template argument must be known, but not every template argument has to be specified.\n          If possible, the compiler will deduce the missing template arguments from the function arguments.\n        }\n      \\item[Overloading Function Templates]\n        \\textquote[\\cite{vandevoorde2018}]{%\n          Like ordinary functions, function templates can be overloaded.\n          That is, you can have different function definitions with the same function name so that when that name is used in a function call, a C++ compiler must decide which one of the various candidates to call.\n        }\n      \\item[Variadic Templates]\n        \\textquote[\\cite{vandevoorde2018}]{%\n          Since C++11, templates can have parameters that accept a variable number of template arguments.\n          This feature allows the use of templates in places where you have to pass an arbitrary number of arguments of arbitrary types.\n        }\n      \\item[Perfect Forwarding]\n        C++11 introduced so-called move semantics to optimize specific copy operations by moving internal resources instead of creating a deep copy of them.\n        Perfect forwarding is a template-based pattern that forwards the basic properties of a type concerning its reference and modification type.\n        % \\autocite{vandevoorde2018}\n      \\item[SFINAE]\n        Substituting template arguments to resolve function template overloading could lead to errors by creating code that makes no sense.\n        The principle \\enquote{substitution failure is not an error} (SFINAE) states that in these circumstances the overload candidates with such substitution problems will be simply ignored.\n        % \\autocite{vandevoorde2018}\n      \\item[{\\footnotesize \\texttt{\\textbf{decltype}}}]\n        This is a specifier introducing an unevaluated context from which it is deducing the type of the given expression without actually evaluating the expression.\n        % \\autocite{stroustrup2014}\n      \\item[\\texttt{\\textbf{\\footnotesize std::enable\\_if\\_t}}]\n        This is a helper template from the STL to ignore function templates by using SFINAE under certain compile conditions.\n        If the template argument evaluates to true then \\code{std::enable\\_if\\_t} will evaluate to an actual type.\n        Otherwise, it will have no meaning triggering the SFINAE principle for overloads.\n        % \\autocite{vandevoorde2018}\n      \\item[\\texttt{\\textbf{\\footnotesize std::declval}}]\n        The given STL function template is only declared, not defined and therefore cannot be called in evaluated contexts.\n        It can be used as a placeholder for an object reference of a specific type.\n        Typically, this routine will be inserted instead of a default constructor in the unevaluated context argument of \\code{decltype}.\n        % \\autocite{vandevoorde2018}\n      \\item[Type Traits]\n        Type traits are general functions defined over types to modify or evaluate them.\n        In the STL a typical examples is given by \\code{std::is_same_v} which is evaluating if two types are the same.\n    \\end{description}\n  % subsection the_c_programming_language (end)\n% section preliminaries (end)\n\\end{document}", "meta": {"hexsha": "2715dc545d94ec173733fe1c51b7ded29a323134", "size": 17472, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/thesis/sections/preliminaries.tex", "max_stars_repo_name": "lyrahgames/random-number-generators", "max_stars_repo_head_hexsha": "c78931c1a5c0a85a1ad36d7d8979567b0853be52", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-03-28T15:12:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-20T00:07:23.000Z", "max_issues_repo_path": "docs/thesis/sections/preliminaries.tex", "max_issues_repo_name": "lyrahgames/random-number-generators", "max_issues_repo_head_hexsha": "c78931c1a5c0a85a1ad36d7d8979567b0853be52", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/thesis/sections/preliminaries.tex", "max_forks_repo_name": "lyrahgames/random-number-generators", "max_forks_repo_head_hexsha": "c78931c1a5c0a85a1ad36d7d8979567b0853be52", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.0338983051, "max_line_length": 283, "alphanum_fraction": 0.7349473443, "num_tokens": 4148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.40578530817719677}}
{"text": "%%=================================\n%% Section 1.04: Asymptotics of K^+\n%%=================================\n\\documentclass[../dissertation.tex]{subfiles}\n\\def\\rest{\\text{rest}}\n\n\\begin{document}\n\n\\section{Asymptotics of $K^+$}\\label{sec1:AsympK}\nA cursory inspection of the integrand of $G_\\star^+$ ($\\star = L \\text{, or }R$) \nindicates that $G_\\star^+$ behavior\ndiffers wildly for $x \\in \\mathbb R$ near zero, and $|x| > c$, where $c>0$ is any\nfixed constant. While $1/p(\\xi)$ decays roughly exponentially as $\\xi \\to -\\infty$, \nthe fact that $1/p(\\xi)$ decays as $1/\\xi$ for $\\xi \\gg 1$ means the oscillatory term \n$e^{ix\\xi}$ in the integrand of $G_\\star^+$ is imperative for the contour \nintegral in $G_\\star^+$ of $e^{ix\\xi} / p(\\xi)$ to even have a chance for convergence.\nIn this section we study the ``nice'' case of $|x|>1$ and show that not only does \nthe integral in $G_\\star^+$ converge in this scenario, it is rapidly decaying (as long \nas $x$ stays away from zero). In the Section \\ref{sec1:KSingularity}, we study\nthe behavior of $G_\\star^+$ for $x$ near zero and show $G_\\star^+$ has at worst a log \ntype singularity at $x=0$. Taken together, the results from this section \ncombined with the results from Section \\ref{sec1:KSingularity} constitute a \nproof of Theorem \\ref{thm1:krep} from the introduction of this chapter. \n\nKey to the analysis in both this section and Section \\ref{sec1:KSingularity}\nare the representation formulas \\eqref{eq1:GFrep} proven in Section \n\\ref{sec1:GreensFunctions}. In particular, \\eqref{eq1:GFrep} allows us\nto reduce our analyses to a thorough study of $K^+$\n\nTo understand the properties of $K^+$, we study the convergence of the integral\n\\begin{align*}\n\t\\int\\limits_{\\Sigma_{\\sign(x)}} \\frac{e^{ix\\xi}}{p(\\xi)} \\, \\mathrm{d}\\xi,\n\\end{align*}\nwhere $\\Sigma_{\\sign(x)} := \\mathbb R + i \\sign(x) \\pi$.\\label{sym1:SigRealLine}\nLet $\\Sigma\\big(R,~\\sign(x)\\big)$\\label{sym1:SigR} denote the contour \n$(-R, R) + i \\sign(x) \\pi$. Recall \nthat $p(\\xi)$ can be written as \n\\[\n\tp(\\xi) = \\xi - \\zeta(\\lambda)\\( 1 - e^{-2\\xi} \\),\n\\] \nwhich implies $p'(\\xi) = 1 - 2 \\zeta(\\lambda) \\, e^{-2\\xi}$. In which case\n\\begin{align*}\n\t\\int\\limits_{\\Sigma\\big(R,~\\sign(x)\\big)} \\frac{e^{ix\\xi}}{p(\\xi)} \\, \\mathrm{d}\\xi\n\t\t&=  \\left.\\frac{e^{ix\\xi}}{p(\\xi)}\\right|_{-R + i \\sign(x)\\pi}^{R + i \\sign(x)\\pi}\n\t\t\t- \\frac{1}{ix} \\int\\limits_{\\Sigma\\big(R,~\\sign(x)\\big)} e^{ix\\xi} \\, \n\t\t\t\\frac{p'(\\xi)}{\\big(p(\\xi)\\big)^2} \\, \\mathrm{d}\\xi.\n\\end{align*}\nNow \n\\begin{align*}\n\tp'(t \\pm i \\pi) \n\t\t= 1 - 2 \\zeta(\\lambda) e^{-2t} e^{\\mp 2 \\pi i}\n\t\t= 1 - 2 \\zeta(\\lambda) e^{-2t} \n\t\t= p'(t), \\qquad t\\in \\RR.\n\\end{align*}\nFurther\n\\[\n\t\\zeta(t \\pm i \\pi ) - \\zeta(\\lambda)\n\t\t= \\frac{t}{1 - e^{-2t}} - \\zeta(\\lambda) \\pm \\frac{i\\pi}{1 - e^{-2t}}\n\t\t= \\zeta(t) - \\zeta(\\lambda) \\pm \\frac{i\\pi}{1 - e^{-2t}}, \\qquad t\\in \\RR,\n\\]\nwhich implies\n\\begin{align} \\label{eq1:shiftedP}\n\tp(t \\pm i \\pi)\n\t\t&= \\big(\\zeta(t \\pm i \\pi) - \\zeta(\\lambda) \\big)\\( 1- e^{-2t} \\) \\\\\n\t\t&= \\big(\\zeta(t) - \\zeta(\\lambda)\\big)\\(1 - e^{-2t}\\) \\pm i\\pi\n\t\t= p(t) \\pm i \\pi. \\nonumber\n\\end{align}\nCombining the two calculations above, we see that\n\\begin{align*}\n\t\\frac{1}{ix} \\int\\limits_{\\Sigma\\big(R,~\\sign(x)\\big)} e^{ix\\xi} \\, \n\t\t\t\\frac{p'(\\xi)}{\\big(p(\\xi)\\big)^2} \\, \\mathrm{d}\\xi\n\t\t= \\frac{e^{-|x|\\pi}}{ix} \\int_{-R}^R e^{ixt} \n\t\t\t\\frac{p'(t)}\n\t\t\t{\\big( p(t) + i \\sign(x) \\pi \\big)^2} \\, \\mathrm{d}t.\n\\end{align*}\t\nThus, \n\\[\n\t\\lim_{R\\to\\infty} \\frac{1}{\\left|p\\big(\\pm R + i \\sign(x)\\pi\\big)\\right|}=0\n\\]\nand, formally,\n\\begin{align} \\label{eq1:RemainderIntegralBnd}\n\t\\left| \\int\\limits_{\\Sigma_{\\sign(x)}} \\frac{e^{ix\\xi}}{p(\\xi)} \\, \\mathrm{d}\\xi \\right|\n\t\t\\leq \\frac{e^{-|x|\\pi}}{|x|} \\int_{\\RR} \n\t\t\t\\frac{\\left| p'(t) \\right|}{p(t)^2 + \\pi^2} \\, \\mathrm{d}t,\n\\end{align}\nwhere we proceed to establish the convergence of the integral on the right-hand\nside of \\eqref{eq1:RemainderIntegralBnd}. Note that $p'(t) = 0$ only when\n$t = \\frac{1}{4} \\ln\\big( \\zeta(\\lambda) \\big)$. Further, given \n$p''(t) = 4\\zeta(\\lambda)\\,e^{-2t} > 0$ for all real $t$, \n\\[\n\t|p'(t)| =\n\t\t\\begin{cases}\n\t\t\t-p'(t), & t < t_0 \\\\\n\t\t\tp'(t), & t \\geq t_0,\n\t\t\\end{cases}\n\\]\nwhere $t_0:= \\frac{1}{4} \\ln\\big( \\zeta(\\lambda) \\big)$. Given this fact, we now proceed\nto evaluate the integral on the right-hand side of \\eqref{eq1:RemainderIntegralBnd}\nthrough $u$-substitution by setting $u = p(t)$. Observe that\n\\begin{align}\n\t\\int \\frac{p'(t)}{p(t)^2 + \\pi^2} \\, \\mathrm{d}t\n\t\t= \\int \\frac{1}{u^2 + \\pi^2}\n\t\t= \\frac{1}{\\pi} \\arctan\\( \\frac{u}{\\pi} \\) + C\n\t\t= \\frac{1}{\\pi} \\arctan\\( \\frac{p(t)}{\\pi} \\) + C.\n\\end{align}\nSo, for $R > |t_0|$, \n\\[\n\t\\int_{-R}^{t_0} \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt\n\t\t= - \\int_{-R}^{t_0} \\frac{p'(t)}{p(t)^2 + \\pi^2}\n\t\t= -\\frac{1}{\\pi} \\left[ \\arctan\\(\\frac{p(t_0)}{\\pi}\\) \n\t\t\t- \\arctan\\(\\frac{p(-R)}{\\pi}\\)\\right],\n\\]\nand\n\\[\n\t\\int_{t_0}^R \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt\n\t\t= \\frac{1}{\\pi} \\left[\\arctan\\(\\frac{p(R)}{\\pi}\\) \n\t\t\t- \\arctan\\(\\frac{p(t_0)}{\\pi}\\)\\right].\n\\]\nNow\n\\[\n\t\\lim_{R\\to \\infty} p(\\pm R) \n\t\t= \\lim_{R\\to \\infty} \\left[ \\pm R - \\zeta(\\lambda) \\( 1 - e^{\\mp 2R} \\) \\right]\n\t\t= \\infty,\n\\]\nwhich implies that\n\\begin{align*}\n\t\\lim_{R\\to \\infty} \\int_{-R}^R \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt\n\t\t&= \\lim_{R\\to\\infty} \\(\\int_{-R}^{t_0} \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt\n\t\t\t+ \\int_{t_0}^{R} \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt \\)\\\\\n\t\t&= \\frac{1}{\\pi}\\left[ \\lim_{R\\to\\infty} \\arctan\\(\\frac{p(R)}{\\pi}\\) \n\t\t\t\t+\\lim_{R\\to\\infty} \\arctan\\(\\frac{p(-R)}{\\pi}\\) \\right. \\\\\n\t\t&\\qquad\\quad- \\left. 2 \\arctan\\(\\frac{p(t_0)}{\\pi}\\) \\right] \\\\\n\t\t&= 1 - \\frac{2}{\\pi} \\arctan\\( \\frac{p(t_0)}{\\pi} \\)\n\\end{align*}\n\nSince\n\\[\n\tp(t_0) \n\t\t= \\frac{1}{4} \\ln\\zeta(\\lambda) - \\zeta(\\lambda) \n\t\t\t+ \\big(\\zeta(\\lambda) \\big)^{\\frac{1}{2}},\n\\]\n$p(t_0) \\to - \\infty$ as $\\lambda \\to \\pm \\infty$, and \n\\[\n\t\\lim_{\\lambda\\to\\pm\\infty} \\int_\\RR \\frac{|p'(t)|}{p(t)^2 + \\pi^2}\\,dt = 2.\n\\]\nPutting everything together, we see that\n\\begin{align}\\label{eq1:Kasymp}\n\tK^+(x; \\lambda) = \\mc O\\left( \\frac{e^{-|x| \\pi}}{|x|} \\right)\n\\end{align}\nfor $|x| \\geq 1$.\n% \\begin{align}\\label{eq1:FinalGffromula}\n% \tG_L^+(x, \\lambda, 1) =\n% \t\t\\begin{cases}\n% \t\t\ti \\frac{1 - e^{2\\lambda}}{2\\lambda\\,e^{2\\lambda} - e^{2\\lambda}+1} \n% \t\t\t\t+ i \\frac{1 - e^{2\\lambda}}{2\\lambda - e^{2\\lambda}+1} e^{ix\\lambda}\n% \t\t\t\t+ \\mc O\\( \\frac{e^{-|x| \\pi}}{|x|} \\), & x > 1 \\\\ \n% \t\t\t~\\\\\n% \t\t\t\\mc O\\( \\frac{e^{-|x| \\pi}}{|x|} \\), & x < -1,\n% \t\t\\end{cases}\n% \\end{align}\n% where the $\\mc O\\( \\frac{e^{-|x| \\pi}}{|x|} \\)$ terms are uniformly bounded in \n% $\\lambda$.\n\n% Finally, since\n% \\[\n% \\begin{array}{ccc}\n% \t\\ds \\lim_{\\lambda\\to-\\infty} \\frac{1 - e^{2\\lambda}}{2 \\lambda e^{2\\lambda} - e^{2\\lambda}+1} = 1, \n% \t&\\qquad&\n% \t\\ds \\lim_{\\lambda\\to\\infty} \\frac{1 - e^{2\\lambda}}{2 \\lambda e^{2\\lambda} - e^{2\\lambda}+1} = 0, \\\\\n% \t\\ds \\lim_{\\lambda\\to-\\infty} \\frac{1 - e^{2\\lambda}}{2 \\lambda - e^{2\\lambda}+1} = 0, \n% \t&\\qquad& \n% \t\\ds \\lim_{\\lambda\\to\\infty} \\frac{1 - e^{2\\lambda}}{2 \\lambda - e^{2\\lambda}+1} = 1,\n% \\end{array}\n% \\]\n% we see from \\eqref{eq1:Gffraw} that $|G_L^+(x; \\lambda)|$ is uniformly bounded in $\\lambda$.\n\n\\end{document}\n", "meta": {"hexsha": "354f38fdef02913ba754b59cf47991329e229241", "size": 7097, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter1-GF/1.3-AsymptoticsOfK.tex", "max_stars_repo_name": "ADGC/ilw-dsm-dissertation", "max_stars_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1-GF/1.3-AsymptoticsOfK.tex", "max_issues_repo_name": "ADGC/ilw-dsm-dissertation", "max_issues_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1-GF/1.3-AsymptoticsOfK.tex", "max_forks_repo_name": "ADGC/ilw-dsm-dissertation", "max_forks_repo_head_hexsha": "de0f27b6389ee55c24d155ff482743acbe6a35a1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8707865169, "max_line_length": 103, "alphanum_fraction": 0.5682682824, "num_tokens": 3157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.4057470769839567}}
{"text": "\\chapter{Image processing and tracking of all the cells in the given $\\textbf{\\textit{E.coli}}$ movie using u-track 2.0, and perform data analysis} % Main chapter title\n\n\\label{Part1_chapter} % For referencing the chapter elsewhere, use \\ref{Chapter1} \n\n\\section{Get data form movie}\n \nFor the video: 1 pixel = 0.65 $\\mu m$, 1 frame = 0.1 second.\\\\\nThe data were extracted by u-track to track the cell by method of Single-Particles and Gaussian Mixture-model Fitting. There are more than 14000 tracks.\n\n\\newpage\n\\section{Single bacteria trajectory}\n\nForm 14721 tracks, I chose the track with the biggest number of un-NAN values and removed all of the NAN value to plot the movement of this single bacteria. \n\n%----------------------------------------------------------------------------------------\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\linewidth]{Figures/P3_fig1.png}\n\\caption{Single Bacteria Random Walk Trajectory}\n\\label{P2_fig1}\n\\end{figure}\n\n\\section{Bacteria population trajectory}\nAlso track all the cells from the data, to calculate the population motions. The statistical results are shown in Figure 3.2.\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.75\\linewidth]{Figures/P3_fig2.png}\n\\caption{The ``mean displacement'' and ``mean displacement-square'' overtime for the cells in vedio}\n\\label{P2_fig2}\n\\end{figure}\n\n\\section{Fitting the Data with the Model}\nFor a series of scatter points $(x_i, y_i)(i=1,2,...,n)$, if a direct proportional function was used to fit the data, we have:\\\\\n\\begin{equation*} \n\\begin{aligned} \n\\centering\ny     &= \\beta x \\\\\n\\beta &= \\sum_{i=1}^n x_i y_i \\Big / \\sum_{i=1}^n x_i^2 \\\\\n\\end{aligned} \n\\end{equation*}\nAs for our model: \\\\\n\\begin{equation*} \n\\begin{aligned} \n\\centering\n\\frac{1}{n} \\sum_{i=1}^{n}x_i(t)^2 &= v_x^2t \\\\\n\\frac{1}{n} \\sum_{i=1}^{n}y_i(t)^2 &= v_y^2t \\\\\n\\end{aligned} \n\\end{equation*}\nSo there are the fitting model: \\\\\n\\begin{equation*} \n\\begin{aligned} \n\\centering\n\\frac{1}{n} \\sum_{i=1}^{n}x_i(t)^2 &= \\beta_x t = v_x^2t \\\\\n\\frac{1}{n} \\sum_{i=1}^{n}y_i(t)^2 &= \\beta_y t = v_y^2t \\\\\n\\beta_x = \\sum_{i=1}^n & t_i x_i \\Big / \\sum_{i=1}^n t_i^2 \\\\\n\\beta_y = \\sum_{i=1}^n & t_i y_i \\Big / \\sum_{i=1}^n t_i^2 \\\\\n\\end{aligned} \n\\end{equation*}\nWe get: \\\\\n\\begin{equation*} \n\\begin{aligned} \n\\centering\n\\beta_x &= 0.9862 \\mu m^2 /s^2 \\\\\nv_x &= 0.9931 \\mu m /s \\\\\n\\beta_y &= 0.8366 \\mu m^2 /s^2 \\\\\nv_y &= 0.9147 \\mu m /s \\\\\n\\end{aligned} \n\\end{equation*}\n%betaX = 0.9862\n%betaY = 0.8366\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1\\linewidth]{Figures/P3_fig3.png}\n\\caption{Fitting the Data by Model}\n\\label{P3_fig3}\n\\end{figure}\n%----------------------------------------------------------------------------------------\n\n\n\n%----------------------------------------------------------------------------------------\n\n\n\n\n%The \\code{biblatex} package is used to format the bibliography and inserts references such as this one \\parencite{Reference1}. The options used in the \\file{main.tex} file mean that the in-text citations of references are formatted with the author(s) listed with the date of the publication. Multiple references are separated by semicolons (e.g. \\parencite{Reference2, Reference1}) and references with more than three authors only show the first author with \\emph{et al.} indicating there are more authors (e.g. \\parencite{Reference3}). This is done automatically for you. To see how you use references, have a look at the \\file{Chapter1.tex} source file. Many reference managers allow you to simply drag the reference into the document as you type.\n\n", "meta": {"hexsha": "c246a078d8a79e651241e186b775f9bf6b3fac5b", "size": 3563, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW3/Chapters/Chapter3.tex", "max_stars_repo_name": "c235gsy/Sustech_Systems-Biology", "max_stars_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW3/Chapters/Chapter3.tex", "max_issues_repo_name": "c235gsy/Sustech_Systems-Biology", "max_issues_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW3/Chapters/Chapter3.tex", "max_forks_repo_name": "c235gsy/Sustech_Systems-Biology", "max_forks_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0337078652, "max_line_length": 750, "alphanum_fraction": 0.6626438395, "num_tokens": 1089, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.40574706688974205}}
{"text": "\\section{Proofs of Monitors}~\\label{sec:proof}\n\nIn addition to proofs on the soundness of the Copilot compilation process, we\nalso support (in the {\\tt Copilot.Theorem} module) some automated proving of\nsafety properties about Copilot specifications themselves. A proposition is a\nCopilot value of type \\lstinline{Prop Existential} or \\lstinline{Prop Universal},\n which can be introduced using \\lstinline{exists} and\n\\lstinline{forall}, respectively. These are functions taking as an argument a\nnormal Copilot stream of type \\lstinline{Stream Bool}. Propositions can be added\nto a specification using the \\lstinline{prop} and \\lstinline{theorem} functions,\nwhere \\lstinline{theorem} must also be passed a tactic for autmatically proving\nthe proposition. Consider this Copilot monitor specification for a version of\nthe fibonacci sequence:\n\n\\begin{lstlisting}[language = Copilot]\nmodule Fib where\n\nimport Prelude ()\nimport Copilot.Language\nimport Copilot.Language.Reify\nimport Copilot.Theorem\nimport Copilot.Theorem.Prover.SMT\n\nfib = do\n  theorem \"fibn_gre_n\" (forall $ fibn >= n) $ kInduction def cvc4\n\n  observer \"fibn\" fibn\n  observer \"n\"    n\n  where\n    fibn :: Stream Word32\n    fibn = [1, 1] ++ (fibn + drop 1 fibn)\n    n = [0] ++ (n + 1)\n\\end{lstlisting}\n\nIn the specification above, in addition to observing the value of streams in\nthe specification, \\lstinline{fibn_gre_n} names a theorem provable\nautomatically with induction using the Z3 SMT solver. This theorem can be\nchecked during reification:\n\n\\begin{code}\n*Fib> reify fib\nfibn_gre_n: valid (proved with k-induction (k = 3))\nFinished: fibn_gre_n: proof checked successfully\n\\end{code}\n\nThe {\\tt Copilot.Theorem} module provides two main mechanisms for interacting\nwith SMT solver backends: a generic backend at {\\tt Copilot.Theorem.Prover.SMT}\nthat nominally supports a wide range of SMT solvers and {\\tt\nCopilot.Theorem.Prover.Z3}, a backend specialized to Z3. The example above uses\nthe generic {\\tt SMT} backend with the CVC4 SMT solver.\n\nSee Figure~\\ref{fig:solvers} for an overview of SMT solvers that have at least\nbeen tested to work with our tool. The second column contains the value of type\n{\\tt Backend} from the {\\tt Copilot.Theorem.Prover.SMT} module which must be\npassed to the tactics in this module for executing the tactic using that SMT\nsolver (e.g., as is done in the second argument to {\\tt kInduction} in the\nexample above). To use a certain SMT solver, the solver must be installed and\nthe executable should reside in one of the directories listed in the {\\tt\n\\$PATH} environment variable.\n\n\\newcommand{\\Yes}{\\checkmark}\n\\newcommand{\\No}{\\textsf{X}}\n\\newcommand{\\Some}{\\textsf{Some}}\n\n\\begin{figure}\n\\begin{center}\n\\begin{tabular}{llllcccc}\nTool       & {\\tt Backend} & Version & Interface & NL Real Arith.\\ & Trig.\\ funs.\\ & Quantif. & Bitvec. \\\\\n\\toprule\nAlt-Ergo   & {\\tt altErgo} & 0.99.1  & SMTLib2   & \\Yes{}          & \\No{}         & \\Yes{}      & \\No{}      \\\\\nCVC4       & {\\tt cvc4}    & 1.4     & SMTLib2   & \\Some{}         & \\No{}         & \\Yes{}      & \\Yes{}     \\\\\nDReal      & {\\tt dReal}   & 2.15.01 & SMTLib2   & \\Yes{}          & \\Yes{}        & \\No{}       & \\No{}      \\\\\nMathSAT    & {\\tt mathSat} & 5.3.7   & SMTLib2   & \\Some{}         & \\No{}         & \\No{}       & \\Yes{}     \\\\\nMetiTarski & {\\tt metit}   & 2.5     & TPTP      & \\Yes{}          & \\Yes{}        & \\Yes{}      & \\No{}      \\\\\nYices      & {\\tt yices}   & 2.4.0   & SMTLib2   & \\Some{}         & \\No{}         & \\No{}       & \\Yes{}     \\\\\nZ3         & {\\tt z3}      & 4.4.0   & SMTLib2   & \\Yes{}          & \\No{}         & \\Yes{}      & \\Yes{}     \\\\\n\\end{tabular}\n\\end{center}\n\\caption{An overview of some supported SMT solvers.}\n\\label{fig:solvers}\n\\end{figure}\n\nAs seen in the figure mentioned above, different SMT solvers have different\nfeature sets and the methods for using the various features are generally not\nwell standardized. As a result, we also have backend specialized to Z3, one of\nthe more feature-rich SMT solvers we've tested. The example above using the Z3\nbackend looks very similar to the version above:\n\n\\begin{lstlisting}[language = Copilot]\nmodule Fib where\n\nimport Prelude ()\nimport Copilot.Language\nimport Copilot.Language.Reify\nimport Copilot.Theorem\nimport Copilot.Theorem.Prover.Z3\n\nfib = do\n  theorem \"fibn_gre_n\" (forall $ fibn >= n) $ kInduction def\n\n  observer \"fibn\" fibn\n  observer \"n\"    n\n  where\n    fibn :: Stream Word32\n    fibn = [1, 1] ++ (fibn + drop 1 fibn)\n    n = [0] ++ (n + 1)\n\\end{lstlisting}\n\nInstead of importing {\\tt Copilot.Theorem.Prover.SMT}, we import {\\tt\nCopilot.Theorem.Prover.Z3}, and we no longer need to pass the {\\tt cvc4}\nargument to {\\tt kInduction} (because the SMT solver backend will be Z3). But\nnow when we go to reify {\\tt fib}:\n\n\\begin{code}\n*Fib> reify fib\nfibn_gre_n: unknown (proof by k-induction failed)\nFinished: fibn_gre_n: proof failed\nWarning: failed to check some proofs.\n\\end{code}\n\nThis demonstrates an important limitation of the {\\tt\nCopilot.Theorem.Prover.SMT} backend: it encodes fixed-width integers using the\nSMTLib {\\tt Int} type (with some extra propositions about the bounds of {\\tt\nInt} variables)---it {\\em does not model overflow}. The {\\tt\nCopilot.Theorem.Prover.Z3} backend, however, encodes Copilot's fixed-width\ninteger types using Z3's bitvectors. Now if we allow {\\tt fibn} to overflow, the\ntheorem from the above example is clearly not true.\n\nThe above example contains a single {\\tt theorem}. A {\\tt theorem} takes three\narguments: the name of the theorem (which is only used to identify the theorem\nin output), a proposition, and a proof ``tactic'' to use when trying to\nautomatically prove the proposition using SMT solvers. The {\\tt\nCopilot.Theorem.Prover.SMT} and {\\tt Copilot.Theorem.Prover.Z3} modules both\nexport the same set of tactics\\footnote{In fact, these modules share a lot a\nduplicated code and desparately need to be refactored.}:\n\\begin{itemize}\n\\item {\\tt onlySat}: check that the proposition is satisfiable.\n\\item {\\tt onlyValidity}: check that the negation of the proposition is\nunsatisfiable.\n\\item {\\tt induction}: special case of $k$-induction, with $k = 0$.\n\\item {\\tt kInduction}: version of induction where the induction hypothesis is\nstrengthened by including $k$ previous states.\n\\end{itemize}\n\nAdditionally, a few other tactics live in {\\tt Copilot.Theorem.Tactics}:\n\\begin{itemize}\n\\item {\\tt instantiate}: turn a proof for a universally quantified proposition\ninto a proof for an existentially quantified one.\n\\item {\\tt assume}: prove a proposition true under an assumption.\n\\item {\\tt admit}: prove anything.\n\\end{itemize}\n\nAlso, we support some older versions of the Kind2 model checker.\n", "meta": {"hexsha": "3288faab30f9ba35547dc1d60718e622ec5fcf72", "size": 6710, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TutorialAndDevGuide/Tutorial/MonProofs.tex", "max_stars_repo_name": "Copilot-Language/copilot-discussion", "max_stars_repo_head_hexsha": "caccad918b23dae991095344a845827ddccd6047", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-06-10T00:44:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-17T13:20:09.000Z", "max_issues_repo_path": "TutorialAndDevGuide/Tutorial/MonProofs.tex", "max_issues_repo_name": "Copilot-Language/copilot-discussion", "max_issues_repo_head_hexsha": "caccad918b23dae991095344a845827ddccd6047", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 30, "max_issues_repo_issues_event_min_datetime": "2019-04-01T20:24:19.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-07T22:34:17.000Z", "max_forks_repo_path": "TutorialAndDevGuide/Tutorial/MonProofs.tex", "max_forks_repo_name": "Copilot-Language/copilot-discussion", "max_forks_repo_head_hexsha": "caccad918b23dae991095344a845827ddccd6047", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.5714285714, "max_line_length": 112, "alphanum_fraction": 0.7071535022, "num_tokens": 1908, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6442251064863698, "lm_q1q2_score": 0.4057166135175199}}
{"text": "\\documentclass{IEEEtran}\n\n\\usepackage{graphicx}\n\\usepackage{hyperref}\n\n\\title{A mutual information based medical image registration methodology based on JVHW entropy estimator}\n\\author{Sihan Li, Tsinghua University}\n\n\\begin{document}\n  \\maketitle\n\n  \\begin{abstract}\n    Mutual information (MI) based medical image registration has gained much attention for its robustness. However, Jiao found that maximum likelihood estimator (MLE), although widely used to implement MI-based registration, is sub-optimal when the number of observations is comparable to the parameter dimension \\cite{jiao2015minimax}. They proposed a new entropy estimator, JVHW estimator, which is claimed to outperform MLE estimator. Based on previous works, we propose a mutual information based registration methodology based on JVHW entropy estimator. The contribution of this paper can be divided into three parts: 1) A C++ version of JVHW estimators using only C++ standard library is effectively implemented, 2) a new similarity metric based on JVHW mutual information estimator is created as an elastix component, and 3) the new metric is evaluated and compared with other metrics. Dataset from Retrospective Image Registration Evaluation Project (RIRE) is used to evaluate and compare various implementations.\n\n  \\end{abstract}\n\n  \\section{Introduction}\n\n  Image registration is a process of aligning two or more images geometrically. These images can be taken at different time, from different viewpoints or from different sensors. It is vital in image analysis when the data collected from different sources need to be combined. To achieve this, a variety of techniques have been developed and researched, aiming for different kinds of applications. \\cite{brown1992survey, zitova2003image}\n\n  Image registration methodologies consist of three major parts: \\emph{Similarity measures}, which measure the degree of similarity between two images. \\emph{Transforms}, which transform pixels/voxels from one image domain to another. \\emph{Optimizations}, which minimize the similarity measures to achieve the registration.\n\n  Similarity measure is a criteria to judge the degree of similarity of two images. It is know as \\emph{cost function}, or \\emph{registration basis} in Maintz's classification \\cite{maintz1998survey}. Commonly used measures include intensity based measures, which analysis the images as a whole, and feature based measures, which detect and match features of two images.\n\n  \\subsection{Mutual information}\n\n  Mutual information based registration methodologies use mutual information (MI) or its variant as the similarity measures. It is a kind of area-based metric. The Methodology based on a simple assumption that the gray level distributions of images to be registered are correlated. Mutual information is defined as:\n\n  \\begin{equation}\n    I(A, B) = H(A) + H(B) - H(A, B)\n  \\end{equation}\n\n  where $H(A)$ is the entropy of $A$. It describes the amount of uncertainty about image minus the uncertainty about $A$ when $B$ is known \\cite{pluim2003mutual}. The most common entropy measure used in paper is Shannon entropy, which is defined as\n\n  \\begin{equation}\n    H = -\\sum_i{p_i\\log{p_i}}\n  \\end{equation}\n\n  where $p_i$ represents the probability of a event $e_i$. In order to register two images, the joint gray value distribution is calculated from them. Other entropy measures include Arimoto entropy \\cite{li20153d}, Tsallis entropy \\cite{khader2012information} etc.\n\n  A popular variant of MI is Normalized mutual information (NMI), which is overlap invariant, which is defined as\n\n  \\begin{equation}\n    NMI(A, B) = \\frac{H(A) + H(B)}{H(A, B)}\n  \\end{equation}\n\n  by Studholme in 1999 \\cite{studholme1999overlap}. To achieve image registration, the MI/NMI between two images are maximized. Mutual information based measures are generally applicable, and does not need complex initialization \\cite{pluim2003mutual}.\n\n\n  % \\subsection{Retrospective Image Registration Evaluation Project}\n\n  % Retrospective Image Registration Evaluation Project (RIRE) is a project designed to compare different registration techniques. It contains a set of CT, PET and MR images. An example of the input images is shown in Figure~\\ref{fig:before-registration}. Each MR-CT images pair and MR-PET images pair has been corrected using frames and markers, so the results of different registration methods can be compared with the ``gold standard'' registration results.\n\n  % In RIRE dataset, a ``from'' image, which is a CT or PET image, is registered to a ``to'' image, which is a MR image. The relation is depicted in Figure~\\ref{fig:RIRE-from-to}. An example of an image pair can be seen in Figure~\\ref{fig:before-registration}. The transformations are expected to be rigid, and can be uploaded to compare with the ``gold standard'' transformations. The transformation is described by the transformed coordinates of eight corner in moving image. We are using RIRE to measure the performance of different registration methodologies.\n\n  % \\begin{figure}[htbp]\n  %   \\centering\n  %   \\includegraphics[width=0.7\\columnwidth]{RIRE_from_to.jpg}\n  %   \\caption{Modalities of images in RIRE project. The registration is expected to be done from left (CT/PET) to right (different weighted MR). \\cite{rireprotocol}}\n  %   \\label{fig:RIRE-from-to}\n  % \\end{figure}\n\n  % \\begin{figure}[htbp]\n  %   \\includegraphics[width=\\columnwidth]{before_registration.png}\n  %   \\caption{A CT(green layer)-MR(red layer) image pair from RIRE project. Notice the two images are different in size.}\n  %   \\label{fig:before-registration}\n  % \\end{figure}\n\n  \\subsection{JVHW estimators}\n\n  As we mentioned before, MI-based methodologies calculate the mutual information between two gray level distributions. However, in reality the distributions are unknown, so the exact MI can not be calculated and needs to be estimated. Most implementations simply use a straightforward maximum likelihood estimator (MLE) to estimate MI. However, Jiao pointed out that MLE and other previous prevailing approaches can be highly sub-optimal, and proposed a \\emph{minimax} entropy/MI estimator, which means the estimator minimizes the maximum $L_2$ risk \\cite{jiao2015minimax}. They showed that their estimator outperform MLE and many other estimators.\n\n  \\section{Implementations}\n\n  \\subsection{C++ version of JVHW estimator}\n\n  In order to make a comparison between MLE and JVHW estimator, we are going to re-implement both of them in C++. To reuse as much as code as possible, we have to analyze both estimator and point out what they have in common. Actually, both of the estimator are linear estimators which can be expressed in the following way:\n\n  \\begin{equation}\n    H = \\sum_{i = 1}^n{a_jF_j},\n  \\end{equation}\n\n  Where $F_j$ is called ``fingerprint'', representing the number of symbols that show up for $j$ times in the sample. The only different between two estimator is $a_j$. In MLE it follows the following form:\n\n  \\begin{equation}\n    a_j = -\\frac{j}{n}\\log_2{\\frac{j}{n}},\n  \\end{equation}\n\n  and in JVHW estimator $a_j$ is calculated during run time. So instead of simply migrating MATLAB or Python code into C++ code, we divide the function into several sub-function. That is:\n\n  \\subsubsection{CalculateFingerprint}\n  Collect the samples into a certain number of bins to get a histogram, then calculate the fingerprint from it.\n\n  \\subsubsection{est\\_entro\\_JVHW}\n  Estimator entropy from an integer vector using JVHW estimator.\n\n  \\subsubsection{est\\_entro\\_MLE}\n  The same as above, except using MLE.\n\n  \\subsubsection{NormalizeVector}\n  Normalize the sample from a double vector to an integer vector.\n\n  \\subsubsection{CombineVector}\n  Combine samples to form a joint-distributed sample.\n\n  \\subsubsection{est\\_MI\\_JVHW}\n  Invoke above functions to calculate the MI.\n\n  \\subsubsection{est\\_MI\\_MLE}\n  The same as above, except using MLE.\n\n\n  To avoid file operations which will take lots of time, we embed \\texttt{poly\\_coeff\\_r} into our source code. That is, we make it a static array, which will be loaded into the memory only once when the program starts. It will take about 314 KB memory. Given that metric function will be invoked continuously during registration, this memory consumption is really acceptable.\n\n  \\subsection{Elastix component}\n\n  Elastix is built using CMake, and has been divided into small components. In order to add new metrics, optimizers, transformations or something else into elastix, one has to:\n\n  \\begin{enumerate}\n    \\item Implement an \\texttt{itk} class, which does the actual works.\n    \\item Implement an \\texttt{elastix} class, which takes care of things like parameter-setting.\n    \\item Put source files in the correct directory together with a \\texttt{CMakeLists.txt}, which declares the component.\n    \\item Re-compile elastix.\n  \\end{enumerate}\n\n  So in order to use JVHW entropy estimator in the metric, we have to implement two classes. Building the classes from nowhere can be a painful and error-prone, so we take most of the code from \\texttt{AdvancedMeanSquares}, which is a simple metric that iterate over every voxels and compute the mean square error.\n\n  \\subsection{Optimizers and parameters}\n\n  Elastix offers a branch of built-in optimizers, including \\emph{Adaptive Stochastic Gradient Descent}, \\emph{Standard Gradient Descent}, \\emph{Quasi Newton LBFGS} etc. However, it should be noticed that most of the optimizers need to know the derivative of the cost function, which is especially hard to acquire when applying JVHW entropy estimator. Therefore, we will pick our optimizer from the ones that do not need to know the derivative of the cost function. Both \\emph{CMA Evolution Strategy} and \\emph{Simultaneous Perturbation} has been tested, and the latter one shows more robustness when applied to our problem.\n\n  When it comes to parameters, \\emph{Maximum Number Of Iterations} has been set to 500.\n\n  The source code is available at \\url{https://github.com/ThomasLee969/stanford-project}.\n\n  \\section{Results}\n\n  To evaluate the two new metrics, we have to make sure that they are valid metric, and can be used to preform image registration. Thus, we perform registration on RIRE dataset using four metrics: \\emph{Mattes MI}, \\emph{NMI}, \\emph{MLE} and \\emph{JVHW}. The former two metrics are shipped with elastix. They use \\emph{Parzen window method}, also known as \\emph{kernel density estimate method}, to estimate the underlying distribution from a series of samples, as depicted in Figure~\\ref{fig:parzenhistogram}\n\n  \\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{parzenhistogram.png}\n    \\caption{Comparison of a histogram and a kernel density estimate.}\n    \\label{fig:parzenhistogram}\n  \\end{figure}\n\n  Also, for \\emph{Mattes MI}, \\emph{NMI} method we also deploy a \\emph{Adaptive Stochastic Gradient Descent} optimizer. The result can be seen in Figure~\\ref{fig:CT_32bin} and Figure~\\ref{fig:PET_32bin}\n\n  \\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{CT_32bin.png}\n    \\caption{Quantile errors for CT to MR registration using 32 bins.}\n    \\label{fig:CT_32bin}\n  \\end{figure}\n\n  \\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{PET_32bin.png}\n    \\caption{Quantile errors for PET to MR registration using 32 bins.}\n    \\label{fig:PET_32bin}\n  \\end{figure}\n\n  We adopt the methodologies using in \\cite{pluim2004f} to evaluate the accuracy of each implementation. The 0.5 and 0.9 quantile errors over all CT-MR and PET-MR pairs of 9 patients have been calculated. 0.9 quantile is used instead of the maximum value, because the maximum can be affected by a single outliers. It can be seen that we have implemented our metrics correctly. Moreover, our metrics outperform the built-in MI-based metrics.\n\n  Having confirmed that we have implemented the metrics correctly, we are going to adjust the number of bins, which is one of the most important parameters in our metrics. The results can be seen in Figure~\\ref{fig:CT-MLE-JVHW} and Figure~\\ref{fig:PET-MLE-JVHW}.\n\n  \\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{CT-MLE-JVHW.png}\n    \\caption{Quantile errors for CT to MR registration}\n    \\label{fig:CT-MLE-JVHW}\n  \\end{figure}\n\n  \\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]{PET-MLE-JVHW.png}\n    \\caption{Quantile errors for PET to MR registration}\n    \\label{fig:PET-MLE-JVHW}\n  \\end{figure}\n\n  It can be seen that when there are few bins, MLE performs a little bit better than JVHW. But when the number of bins increase, the errors given by MLE increase faster than the errors given by JVHW. This is because when the number of samples is significantly larger than the support size, the MLE is essentially the optimal scheme. In our situation, the support size is about $10^3$, while the number of samples is about $10^6$. So it can be concluded that our JVHW-based metric outperform traditional MLE metric in general, especially when the number of bins are large.\n\n  \\section{Acknowledgment}\n\n  The images and the standard transformation(s) were provided as part of the project, ``Retrospective Image Registration Evaluation'', National Institutes of Health, Project Number 8R01EB002124-03, Principal Investigator, J. Michael Fitzpatrick, Vanderbilt University, Nashville, TN.\n\n  \\bibliographystyle{IEEEtran}\n  \\bibliography{task4}\n\n\\end{document}\n", "meta": {"hexsha": "6b6665a5524416d27a409f4425ad47aa21ef2251", "size": 13456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week4/reoport/task4.tex", "max_stars_repo_name": "ThomasLee969/stanford-project", "max_stars_repo_head_hexsha": "ab1e576446d417710e4a5a993be6b7216ce0853a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week4/reoport/task4.tex", "max_issues_repo_name": "ThomasLee969/stanford-project", "max_issues_repo_head_hexsha": "ab1e576446d417710e4a5a993be6b7216ce0853a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week4/reoport/task4.tex", "max_forks_repo_name": "ThomasLee969/stanford-project", "max_forks_repo_head_hexsha": "ab1e576446d417710e4a5a993be6b7216ce0853a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 70.4502617801, "max_line_length": 1021, "alphanum_fraction": 0.7752675386, "num_tokens": 3256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.40571661351751986}}
{"text": "% !TEX root = ../main.tex\n\\section{Empirical Study}\n\\label{sec:case-study}\n\\label{sec:pvi-experiments}\n\\input{ch-pvi/tab_sbn}\nWe developed \\acrfull{PVI}. We now empirically study \\gls{PVI}, variational inference, and deterministic annealing~\\citep{Katihara:2008}.\\footnote{Source code for reproducibility is available at \\url{https://github.com/altosaar/proximity_vi}.}\n\nWe first study sigmoid belief networks and find that \\gls{PVI} improves over deterministic annealing and \\gls{VI} in terms of held-out values of the \\gls{ELBO} and marginal likelihood. We then study a variational autoencoder model of images.  Using an orthogonal proximity statistic, we show that \\gls{PVI} improves over classical \\gls{VI} by reducing overpruning. Finally, we study a deep generative model fit to a large corpus of text, where \\gls{PVI} yields better predictive performance with little hyperparameter tuning.\\footnote{We also compared \\gls{PVI} to \\citet{khan2015kullback}. Specifically, we tested \\gls{PVI} on the Bayesian logistic regression model from that paper and with the same data.  Because Bayesian logistic regression has a single mode, all   methods performed equally well.  We note that we could not apply their algorithm to the sigmoid belief network because it would require approximating difficult iterated expectations.}\n\n\\paragraph{Hyperparameters.} For \\gls{PVI}, we use the inverse Huber distance for $d$.\\footnote{We define the inverse Huber distance   $d(x, y)$ to be $|x - y|$ if $|x - y| < 1$ and $0.5(x-y)^2 + 0.5$   otherwise. The constants ensure the function and its derivative are   continuous at $|x-y| = 1$.} The inverse Huber distance penalizes smaller values than the square difference. For \\gls{PVI} \\Cref{algo:global}, we set the exponential moving average decay constant for $\\tmblambda$ to $\\alpha=0.9999$. We set the constraint scale $k$ (or temperature parameter in deterministic annealing) to the initial absolute value of the \\gls{ELBO} unless otherwise specified. We explore two annealing schedules for \\gls{PVI} and deterministic annealing: a linear decay and an exponential decay. For the exponential decay, the value of the magnitude at iteration $t$ of $T$ total iterations is set to $k\\cdot \\gamma^{\\frac{t}{T}}$ where $\\gamma$ is the decay rate. We use the Adam optimizer~\\citep{kingma2015adam:} unless otherwise specified.\n\\subsection{Sigmoid Belief Network}\nThe sigmoid belief network is a discrete latent variable model with layers of Bernoulli latent variables~\\citep{neal1992connectionist,ranganath2015deep}. It is used to benchmark variational inference algorithms~\\citep{Mnih:2016:VIM:3045390.3045621}. The approximate posterior is a collection of Bernoullis, parameterized by an inference network with weights and biases.  We fit these variational parameters with \\gls{VI}, deterministic annealing~\\citep{Katihara:2008}, or \\gls{PVI}, and learn the model parameters (weights and biases) using variational expectation-maximization.\n\n\\input{ch-pvi/tab_sbn_3}\nWe learn the weights and biases of the model with gradient ascent. We use a step size of $\\rho=10^{-3}$ and train for $4\\times10^6$ iterations with a batch size of $20$.  For \\gls{PVI} \\Cref{algo:global} and deterministic annealing, we grid search over exponential decays with rates $\\gamma\\in \\{10^{-5}, 10^{-6}, ..., 10^{-10}, 10^{-20}, 10^{-30}\\}$ and report the best results for each algorithm.  (We also explored linear decays but they did not perform as well.)  To reduce the variance of the gradients, we use the leave-one-out control variate of~\\citet{Mnih:2016:VIM:3045390.3045621} with $5$ samples. (This is an extension to the black box variational inference algorithm in \\citet{ranganath2014black}.)\n\n\\paragraph{Results on MNIST.} We train a sigmoid belief network model on the binary MNIST dataset of handwritten digits~\\citep{pmlr-v15-larochelle11a}. For evaluation, we compute the \\gls{ELBO} and held-out marginal likelihood with importance sampling on the validation set of $10^4$ digits using $5000$ samples, as in \\citet{rezende2014stochastic}. In Table~$1$ we show the results for a model with one layer of $200$ latent variables. \\Cref{table:sbn_3_layer} displays similar results for a three-layer model with $200$~latent variables per layer. In both one and three-layer models the \\gls{KL} proximity statistic performs worse than the mean/variance and entropy statistics; it requires different decay schedules. Overall, \\gls{PVI} with the entropy and mean/variance proximity statistics yields improvements in the held-out marginal likelihood in comparison to deterministic annealing and \\gls{VI}.\n\n\\input{ch-pvi/tab_dlgm}\n\\subsection{Variational Autoencoder}\n\\label{sec:variational_autoencoder}\nTo demonstrate the value of designing proximity statistics tailored to specific   models,  we study the variational autoencoder~ \\citep{kingma2014autoencoding,rezende2014stochastic}. This model is difficult to optimize, and current optimization techniques yield solutions that do not use the full model capacity~\\citep{Burda2016}. In \\Cref{sec:proximity_examples} we designed an orthogonal proximity statistic to make backpropagation in neural networks easier. We show that this statistic enables us to find a better approximate posterior in the variational autoencoder by reducing overpruning.\n\nWe fit the variational autoencoder to binary MNIST data~\\citep{pmlr-v15-larochelle11a} with variational expectation-maximization. The model has one layer of $100$ Gaussian latent variables. The inference network and generative network are chosen to have two hidden layers of size $200$ with rectified linear units. We use an orthogonal initialization for the inference network weights. The learning rate is set to $10^{-3}$ and we run \\gls{VI} and \\gls{PVI} for $5\\times 10^4$ iterations. The orthogonal proximity statistic changes rapidly during optimization, so we use constraint magnitudes $k \\in \\{1, 10^{-1}, 10^{-2}, ..., 10^{-5}\\}$, with no decay, and report the best result.\n\nWe compute the \\gls{ELBO} and importance-sampled marginal likelihood estimates on the validation set. \\Cref{table:dlgm2} shows that \\gls{PVI} with the orthogonal proximity statistic on the weights of the inference network enables easier optimization and improves over \\gls{VI}.\n\nWhy does \\gls{PVI} improve upon \\gls{VI} in the variational autoencoder? The choice of rectified linear units in the inference network allows us to  study overpruning of the latent code~\\citep{mackay2001,Burda2016}. We study  the fraction of `dead units'--- the fraction of rectified linear units in each layer of the inference   neural network whose input is below zero. With \\gls{PVI} \\Cref{algo:global} and the orthogonal proximity constraint, the inference network has $1.6\\%$ fewer dead units in the hidden layer and shows a $3.2\\%$ reduction in the output layer than in the same model learned using classic variational inference.\n\nOnce the input to a rectified linear unit drops below zero, the unit stops receiving gradient updates. The output layer parametrizes the latent variable distribution, so this means \\gls{PVI} reduced the pruning of the approximate posterior and led to the utilization of $3$ additional latent variables. This is the reason it outperformed a variational autoencoder fit with \\gls{VI}.\n\n\\input{ch-pvi/tab_poisson}\n\\subsection{Deep Generative Model of Text}\n\\label{sec:poisson_factor_analysis}\nDeep exponential family models, Bayesian analogues to neural networks, represent a flexible class of models~\\citep{ranganath2015deep}. However, black box variational inference is commonly used to fit these models, which requires variance reduction~\\citep{ranganath2014black}. Deep exponential family models with Poisson latent variables present a challenging approximate inference problem because they are discrete and high-variance. We demonstrate that \\gls{PVI} with the mean/variance proximity constraint improves predictive performance in such an unsupervised model of text.\n\nThe generative process for a single-layer deep exponential family model of text, with Poisson latent variables and Poisson likelihood, is\n\\begin{align*}\n\\mbz &\\sim \\textrm{Poisson}(\\mblambda) \\\\\n\\mbx &\\sim \\textrm{Poisson}(\\mbz^\\top g(W)) \\,,\n\\end{align*}\nwhere $W$ are real-valued model parameters and $g$ is an elementwise function that maps to the positive reals (we use the softplus function). The dimension of $\\mbz$ is $K$, so the model parameters must have shape $(K, V)$ where $V$ is the cardinality of the count-valued observations $\\mbx$. We use this as a model of documents, so $\\mbx$ is the bag-of-words representation of word counts, $W$ represents the common factors in documents, and the per-document latent variable $\\mbz$ captures factors prevalent in documents' language.\n\nWe study the performance of our method on a corpus of articles from the academic journal \\emph{Science}. The corpus contains $138$k documents in the training set, $1$k documents in the test set, and $5.9$k terms. We set the latent dimension to $100$, and fit the variational Poisson parameters using black box variational inference~\\citep{ranganath2014black} using minibatches of size $64$ and $32$~samples of the latent variables to estimate the gradients.\n\nPoisson variables have high variance, so we use  the optimal control variate scaling developed in \\citet{ranganath2014black} and estimate this scaling in a round-robin fashion as in \\citet{Mnih:2016:VIM:3045390.3045621} for efficiency. We use the RMSProp adaptive gradient optimizer~\\citep{Hinton} with a step size of $0.01$. For \\gls{PVI}~\\Cref{algo:global} with the mean/variance proximity statistic, we use an exponential decay for the constraint and test decay rates $\\gamma$ of $10^{-5}$ and $10^{-10}$. We train for $10^6$ iterations on the \\emph{Science} corpus, using variational expectation-maximization to learn the model parameters.\n\n\\input{ch-pvi/tab_poisson_topics}\nFor evaluation, we keep the model parameters fixed and hold out $90\\%$ of the words in each document in the test set. Using the $10\\%$ of observed words in each document, we learn the variational parameters using \\gls{PVI} or variational inference with $300$ iterations per document. We compute perplexity on the held-out documents, which is given by\n\\begin{align*}\n\\exp\\left(\\frac{-\\sum_{d\\in{\\textrm{docs}}} \\sum_{w\\in d} \\log p(w \\mid\n\\textrm{\\# held-out in d})}{N_{\\textrm{held-out words}}}\\right).\n\\end{align*}\nConditional on the number of held-out words in a document, the distribution over held-out words is multinomial. The mean of the conditional multinomial is the normalized Poisson rate of the document matrix-multiplied with the softplus of the weights. This is the same evaluation metric as in \\citet{ranganath2015deep}. The results of fitting the model to the corpus of \\emph{Science} documents are reported in \\Cref{table:poisson} and \\Cref{table:poisson_topics}. While the topics found by models fit with both \\gls{PVI} and \\gls{VI} are similar, \\gls{PVI} gives better predictive performance in terms of held-out perplexity.", "meta": {"hexsha": "e73f0eef58d2b178c51b4eb738b6fea71ed46d1f", "size": 11052, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch-pvi/sec_experiments.tex", "max_stars_repo_name": "altosaar/thesis", "max_stars_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-05-21T18:56:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T12:18:53.000Z", "max_issues_repo_path": "ch-pvi/sec_experiments.tex", "max_issues_repo_name": "altosaar/thesis", "max_issues_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch-pvi/sec_experiments.tex", "max_forks_repo_name": "altosaar/thesis", "max_forks_repo_head_hexsha": "287484c87db0eca46f4cdae70ff8582bd66ce5a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 204.6666666667, "max_line_length": 1032, "alphanum_fraction": 0.7872783207, "num_tokens": 2821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.40571661351751986}}
{"text": "\\documentclass[14pt,aspectratio=169]{beamer}\n\\usepackage{polyglossia}\n\\setdefaultlanguage{english}\n\\usetheme{SaintPetersburg}\n\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{listings}\n\\usepackage{booktabs}\n\\usepackage{graphicx}\n\\usepackage{tikz}\n\n\\graphicspath{{figures/}}\n\n\\newcommand{\\Fourier}[1]{\\mathcal{F}\\left\\{#1\\right\\}}\n\\newcommand{\\InverseFourier}[1]{\\mathcal{F}^{-1}\\left\\{#1\\right\\}}\n\\newcommand{\\Var}[1]{\\sigma_{#1}^2}\n\n\\AtBeginSection[]{\n%\t\\iffirstsection\n%\t\t\\begin{frame}{Plan}\n%\t\t\t\\tableofcontents\n%\t\t\\end{frame}\n%\t\t\\firstsectionfalse\n%\t\\fi\n%\t\\begin{frame}{Plan}\n%\t\t\\tableofcontents[currentsection]\n%\t\\end{frame}\n\t\\frame{\\sectionpage}\n}\n\n\\title{Generating standing and propagating ocean waves with three-dimensional ARMA model}\n\\subtitle{Technical report}\n\\author{Ivan Gankevich}\n\\date{Aug 26, 2016}\n\n\\begin{document}\n\n\t\\frame{\\maketitle}\n\n\t\\section{Two methods of finding wave's ACF}\n\n\t\\begin{frame}\n\t\t\\frametitle{Analytic method}\n\t\t\\only<1>{%\n\t\t\tApply Wiener---Khinchin theorem to a wave profile $\\zeta$ to get ACF $K$:\n\t\t\t\\begin{equation*}\n\t\t\t\tK(t) = \\Fourier{\\left| \\zeta(t) \\right|^2}.\n\t\t\t\t\\label{eq:wiener-khinchin}\n\t\t\t\\end{equation*}%\n\t\t}\n\t\t\\only<2>{%\n\t\t\t\\begin{example}\n\t\t\t\tStanding wave profile:\n\t\t\t\t\\begin{equation*}\n\t\t\t\t\t\\zeta(t, x, y) = A \\sin (k_x x + k_y y) \\sin (\\sigma t).\n\t\t\t\t\t\\label{eq:standing-wave}\n\t\t\t\t\\end{equation*}\n\t\t\t\tStanding wave ACF:\n\t\t\t\t\\begin{equation*}\n\t\t\t\t\tK(t,x,y) =\n\t\t\t\t\t\\gamma\n\t\t\t\t\t\\exp\\left[-\\alpha (|t|+|x|+|y|) \\right]\n\t\t\t\t\t\\cos \\beta t\n\t\t\t\t\t\\cos \\left[ \\beta x + \\beta y \\right].\n\t\t\t\t\t\\label{eq:standing-wave-acf}\n\t\t\t\t\\end{equation*}\n\t\t\t\\end{example}%\n\t\t}\n\t\t\\only<3>{%\n\t\t\t\\begin{example}\n\t\t\t\tPropagating wave profile:\n\t\t\t\t\\begin{equation*}\n\t\t\t\t\t\\zeta(t, x, y) = A \\cos (\\sigma t + k_x x + k_y y).\n\t\t\t\t\t\\label{eq:propagating-wave}\n\t\t\t\t\\end{equation*}\n\t\t\t\tPropagating wave ACF:\n\t\t\t\t\\begin{equation*}\n\t\t\t\t\tK(t,x,y) =\n\t\t\t\t\t\\gamma\n\t\t\t\t\t\\exp\\left[-\\alpha (|t|+|x|+|y|) \\right]\n\t\t\t\t\t\\cos\\left[\\beta (t+x+y) \\right].\n\t\t\t\t\t\\label{eq:propagating-wave-acf}\n\t\t\t\t\\end{equation*}\n\t\t\t\\end{example}%\n\t\t}\n\t\t\\only<4>{%\n\t\t\tSome observations:\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Taking Fourier transform of sine/cosine wave profile requires\n\t\t\t\t\t  multiplying it by an decaying exponent to produce useful ACF.\n\t\t\t\t\\item Fourier Transform of squared exponent (Gaussian) is another Gaussian.\n\t\t\t\\end{itemize}\n\t\t\t\\vfill\\centering%\n\t\t\t\\alert{Why use Fourier transform at all?}%\n\t\t}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Empirical method}\n\t\tThe algorithm:\n\t\t\\begin{enumerate}\n\t\t\t\\item Multiply wave profile by an decaying exponent.\n\t\t\t\\item Adjust sine/cosine phase to move maximum value to the origin\n\t\t\t\t  (or substitute sine with cosine to get the same effect).\n\t\t\\end{enumerate}\n\t\t\\vfill%\n\t\tIn case of plain waves result is the same as for analitic method.\n\t\\end{frame}\n\n\t\\section{Governing equations for 3-dimensional ARMA process}\n\n\t\\begin{frame}\n\t\t\\frametitle{3-D ARMA process}\n\t\tThree-dimensional autoregressive moving average process is defined by\n\t\t\\begin{equation*}\n\t\t\t\\zeta_{i,j,k} =\n\t\t\t\\sum\\limits_{l=0}^{p_1}\n\t\t\t\\sum\\limits_{m=0}^{p_2}\n\t\t\t\\sum\\limits_{n=0}^{p_3}\n\t\t\t\\Phi_{l,m,n} \\zeta_{i-l,j-m,k-n}\n\t\t\t+\n\t\t\t\\sum\\limits_{l=0}^{q_1}\n\t\t\t\\sum\\limits_{m=0}^{q_2}\n\t\t\t\\sum\\limits_{n=0}^{q_3}\n\t\t\t\\Theta_{l,m,n} \\epsilon_{i-l,j-m,k-n}\n\t\t\t,\n\t\t\t\\label{eq:arma-process}\n\t\t\\end{equation*}\n\t\t\\small{%\n\t\t\twhere $\\zeta$ --- wave elevation, $\\Phi$ --- AR coefficients, $\\Theta$ --- MA\n\t\t\tcoefficients, \\newline$\\epsilon$ --- white noise with Gaussian distribution,\n\t\t\t$(p_1,p_2,p_3)$ --- AR process order, $(q_1,q_2,q_3)$ --- MA process order, and\n\t\t\t$\\Phi_{0,0,0} \\equiv 0$, $\\Theta_{0,0,0} \\equiv 0$.% \n\t\t}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Determining coefficients}\n\t\t\\framesubtitle{AR process}\n\t\t\\small%\n\t\tSolve linear system of equations (3-D Yule---Walker equations) for $\\Phi$:\n\t\t\\begin{equation*}\n\t\t    \\Gamma\n\t\t    \\left[\n\t\t        \\begin{array}{l}\n\t\t            \\Phi_{0,0,0}\\\\\n\t\t            \\Phi_{0,0,1}\\\\\n\t\t            \\vdotswithin{\\Phi_{0,0,0}}\\\\\n\t\t            \\Phi_{p_1,p_2,p_3}\n\t\t        \\end{array}\n\t\t    \\right]\n\t\t    = \n\t\t    \\left[\n\t\t        \\begin{array}{l}\n\t\t            K_{0,0,0}-\\Var{\\epsilon}\\\\\n\t\t            K_{0,0,1}\\\\\n\t\t            \\vdotswithin{K_{0,0,0}}\\\\\n\t\t            K_{p_1,p_2,p_3}\n\t\t        \\end{array}\n\t\t    \\right],\n\t\t    \\qquad\n\t\t    \\Gamma=\n\t\t    \\left[\n\t\t        \\begin{array}{llll}\n\t\t            \\Gamma_0 & \\Gamma_1 & \\cdots & \\Gamma_{p_1} \\\\\n\t\t            \\Gamma_1 & \\Gamma_0 & \\ddots & \\vdotswithin{\\Gamma_0} \\\\\n\t\t            \\vdotswithin{\\Gamma_0} & \\ddots & \\ddots & \\Gamma_1 \\\\\n\t\t            \\Gamma_{p_1} & \\cdots & \\Gamma_1 & \\Gamma_0\n\t\t        \\end{array}\n\t\t    \\right],\n\t\t\\end{equation*}\n\t\t\\begin{equation*}\n\t\t\t\\Gamma_i = \n\t\t\t\\left[\n\t\t\t\\begin{array}{llll}\n\t\t\t\t\\Gamma^0_i & \\Gamma^1_i & \\cdots & \\Gamma^{p_2}_i \\\\\n\t\t\t\t\\Gamma^1_i & \\Gamma^0_i & \\ddots & \\vdotswithin{\\Gamma^0_i} \\\\\n\t\t\t\t\\vdotswithin{\\Gamma^0_i} & \\ddots & \\ddots & \\Gamma^1_i \\\\\n\t\t\t\t\\Gamma^{p_2}_i & \\cdots & \\Gamma^1_i & \\Gamma^0_i\n\t\t\t\\end{array}\n\t\t\t\\right]\n\t\t\t\\qquad\n\t\t\t\\Gamma_i^j= \n\t\t\t\\left[\n\t\t\t\\begin{array}{llll}\n\t\t\t\tK_{i,j,0} & K_{i,j,1} & \\cdots & K_{i,j,p_3} \\\\\n\t\t\t\tK_{i,j,1} & K_{i,j,0} & \\ddots &x \\vdotswithin{K_{i,j,0}} \\\\\n\t\t\t\t\\vdotswithin{K_{i,j,0}} & \\ddots & \\ddots & K_{i,j,1} \\\\\n\t\t\t\tK_{i,j,p_3} & \\cdots & K_{i,j,1} & K_{i,j,0}\n\t\t\t\\end{array}\n\t\t\t\\right].\n\t\t\\end{equation*}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Determining coefficients}\n\t\t\\framesubtitle{MA process}\n\t\t\\small%\n\t\tSolve non-linear system of equations for $\\Theta$:\n\t\t\\begin{equation*}\n\t\t\tK_{i,j,k} = \n\t\t\t\\left[\n\t\t\t\t\\displaystyle\n\t\t\t\t\\sum\\limits_{l=i}^{q_1}\n\t\t\t\t\\sum\\limits_{m=j}^{q_2}\n\t\t\t\t\\sum\\limits_{n=k}^{q_3}\n\t\t\t\t\\Theta_{l,m,n}\\Theta_{l-i,m-j,n-k}\n\t\t\t\\right]\n\t\t\t\\Var{\\epsilon}\n\t\t\\end{equation*}\n\t\tvia fixed-point iteration method:\n\t\t\\begin{equation*}\n\t\t\t\\theta_{i,j,k} =\n\t\t\t\t-\\frac{K_{0,0,0}}{\\Var{\\epsilon}}\n\t\t\t\t+\n\t\t\t\t\\sum\\limits_{l=i}^{q_1}\n\t\t\t\t\\sum\\limits_{m=j}^{q_2}\n\t\t\t\t\\sum\\limits_{n=k}^{q_3}\n\t\t\t\t\\Theta_{l,m,n} \\Theta_{l-i,m-j,n-k}.\n\t\t\\end{equation*}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Determining coefficients}\n\t\t\\framesubtitle{ARMA process}\n\t\tTo mix processes one needs to divide ACF between processes, and\n\t\trecompute one of the parts to match process properties (mean,\n\t\tvariance etc.).\n\t\t\\vfill%\n\t\t\\begin{center}\n\t\t\t\\alert{There is no recomputation formula for 3-D proccess.}\n\t\t\\end{center}\n\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Our approach}\n\t\tUse AR process for standing waves and MA process for\n\t\tpropagating waves.\n\t\t\\vfill%\n\t\tSupporting experimental results:\n\t\t\\begin{itemize}\n\t\t\t\\item It works that way in practice.\n\t\t\t\\item It does not work the other way round\n\t\t\t\t  (processes diverge).\n\t\t\t\\item Wavy surface integral characteristics \n\t\t\t\t  match the ones of real ocean waves.\n\t\t\\end{itemize}\n\t\\end{frame}\n\n\t\\section{Evaluation and verification}\n\n\t\\begin{frame}\n\t\t\\frametitle{Experiment setup}\n\t\t\\begin{itemize}\n\t\t\t\\item Generate standing/propagating waves with\n\t\t\t\t  AR/MA processes respectively.\n\t\t\t\\item Estimate distributions of integral\n\t\t\t\t  characteristics.\n\t\t\t\\item Compare estimated distributions to the\n\t\t\t\t  known ones via QQ plots.\n\t\t\\end{itemize}\n\t\t\\vfill%\n\t\t\\begin{center}\n\t\t\t\\small\n\t\t\t\\begin{tabular}{ll}\n\t\t\t\t\\toprule\n\t\t\t\tCharacteristic & Weibull shape ($k$) \\\\\n\t\t\t\t\\midrule\n\t\t\t\tWave height & 2 \\\\\n\t\t\t\tWave length & 2.3 \\\\\n\t\t\t\tCrest length & 2.3 \\\\\n\t\t\t\tWave period & 3 \\\\\n\t\t\t\tWave slope & 2.5 \\\\\n\t\t\t\tThree-dimensionality & 2.5 \\\\\n\t\t\t\t\\bottomrule\n\t\t\t\\end{tabular}%\n\t\t\\end{center}\n\t\\end{frame}\n\n%\t\\begin{frame}\n%\t\t\\frametitle{Input ACFs (time slices)}\n%\t\tStanding wave ACF:\n%\t\t\\vfill%\n%\t\t\\begin{tabular}{llll}%\n%\t\t\t\\includegraphics[scale=0.45]{standing-acf-0} &\n%\t\t\t\\includegraphics[scale=0.45]{standing-acf-1} &\n%\t\t\t\\includegraphics[scale=0.45]{standing-acf-3} &\n%\t\t\t\\includegraphics[scale=0.45]{standing-acf-4} \\\\\n%\t\t\\end{tabular}\n%\t\t\\vfill%\n%\t\tPropagating wave ACF:\n%\t\t\\vfill%\n%\t\t\\begin{tabular}{llll}%\n%\t\t\t\\includegraphics[scale=0.45]{propagating-acf-00} &\n%\t\t\t\\includegraphics[scale=0.45]{propagating-acf-01} &\n%\t\t\t\\includegraphics[scale=0.45]{propagating-acf-03} &\n%\t\t\t\\includegraphics[scale=0.45]{propagating-acf-04} \\\\\n%\t\t\\end{tabular}\n%\t\\end{frame}\n\n\t\\begin{frame}\n\t\t\\frametitle{Verification results (QQ plots)}\n\t\t\\small%\n\t\t\\centering\n\t\t\\begin{columns}\n\t\t\t\\begin{column}{0.5\\textwidth}\n\t\t\t\t\\centering%\n\t\t\t\tStanding waves\n\t\t\t\t\\begin{tabular}{ll}\n\t\t\t\t\t\\includegraphics[scale=0.5]{standing-elevation} &\n\t\t\t\t\t\\includegraphics[scale=0.5]{standing-wave-height-x} \\\\\n\t\t\t\t\t\\addlinespace\n\t\t\t\t\t\\includegraphics[scale=0.5]{standing-wave-length-x} &\n\t\t\t\t\t\\includegraphics[scale=0.5]{standing-wave-period} \\\\\n\t\t\t\t\\end{tabular}\n\t\t\t\\end{column}\n\t\t\t\\begin{column}{0.5\\textwidth}\n\t\t\t\t\\centering%\n\t\t\t\tPropagating waves\n\t\t\t\t\\begin{tabular}{ll}\n\t\t\t\t\t\\includegraphics[scale=0.5]{propagating-elevation} &\n\t\t\t\t\t\\includegraphics[scale=0.5]{propagating-wave-height-x} \\\\\n\t\t\t\t\t\\addlinespace\n\t\t\t\t\t\\includegraphics[scale=0.5]{propagating-wave-length-x} &\n\t\t\t\t\t\\includegraphics[scale=0.5]{propagating-wave-period} \\\\\n\t\t\t\t\\end{tabular}\n\t\t\t\\end{column}\n\t\t\\end{columns}\n\t\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "bf1a1846d947f34e93162c2299e942cb39e1cebd", "size": 9107, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "200+ beamer 模板合集/beamertheme-saintpetersburg(圣彼得堡国立大学)/example.tex", "max_stars_repo_name": "lemoxiao/Awesome-Beamer-Collection", "max_stars_repo_head_hexsha": "3ab28a23fb60cb0a97fcec883847e2d8728b98c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2019-07-30T04:09:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-24T09:27:26.000Z", "max_issues_repo_path": "200+ beamer 模板合集/beamertheme-saintpetersburg(圣彼得堡国立大学)/example.tex", "max_issues_repo_name": "lemoxiao/Awesome-Beamer-Collection", "max_issues_repo_head_hexsha": "3ab28a23fb60cb0a97fcec883847e2d8728b98c0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "200+ beamer 模板合集/beamertheme-saintpetersburg(圣彼得堡国立大学)/example.tex", "max_forks_repo_name": "lemoxiao/Awesome-Beamer-Collection", "max_forks_repo_head_hexsha": "3ab28a23fb60cb0a97fcec883847e2d8728b98c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2019-11-02T03:10:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-12T04:13:23.000Z", "avg_line_length": 27.1850746269, "max_line_length": 89, "alphanum_fraction": 0.6255627539, "num_tokens": 3411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4057166045645092}}
{"text": "\\documentclass[letterpaper,final,12pt,reqno]{amsart}\n\n\\usepackage[total={6.3in,9.2in},top=1.1in,left=1.1in]{geometry}\n\n\\usepackage{times,bm,bbm,empheq,fancyvrb,graphicx}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{longtable}\n\\usepackage{booktabs}\n\n\\usepackage[within=section]{newfloat}\n\n\\usepackage{tikz}\n\\usetikzlibrary{decorations.pathreplacing}\n\n\\usepackage[kw]{pseudo}\n\\pseudoset{left-margin=15mm,topsep=5mm,idfont=\\texttt}\n\n% hyperref should be the last package we load\n\\usepackage[pdftex,\ncolorlinks=true,\nplainpages=false, % only if colorlinks=true\nlinkcolor=blue,   % ...\ncitecolor=Red,    % ...\nurlcolor=black    % ...\n]{hyperref}\n\n\\renewcommand{\\baselinestretch}{1.05}\n\n\\allowdisplaybreaks[1]  % allow display breaks in align environments, if they avoid major underfulls\n\n\\newtheoremstyle{claim}% name\n  {5pt}% space above\n  {5pt}% space below\n  {\\itshape}% body font\n  {}% indent amount\n  {\\itshape}% theorem head font\n  {.}% punctuation after theorem head\n  {.5em}% space after theorem head\n  {\\thmname{#1}\\thmnumber{ #2}\\thmnote{ (#3)}}% theorem head spec\n\\theoremstyle{claim}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\n\\newcommand{\\eps}{\\epsilon}\n\\newcommand{\\RR}{\\mathbb{R}}\n\n\\newcommand{\\grad}{\\nabla}\n\\newcommand{\\Div}{\\nabla\\cdot}\n\\newcommand{\\trace}{\\operatorname{tr}}\n\n\\newcommand{\\hbn}{\\hat{\\mathbf{n}}}\n\n\\newcommand{\\bb}{\\mathbf{b}}\n\\newcommand{\\be}{\\mathbf{e}}\n\\newcommand{\\bbf}{\\mathbf{f}}\n\\newcommand{\\bg}{\\mathbf{g}}\n\\newcommand{\\bn}{\\mathbf{n}}\n\\newcommand{\\br}{\\mathbf{r}}\n\\newcommand{\\bu}{\\mathbf{u}}\n\\newcommand{\\bv}{\\mathbf{v}}\n\\newcommand{\\bw}{\\mathbf{w}}\n\\newcommand{\\bx}{\\mathbf{x}}\n\n\\newcommand{\\bF}{\\mathbf{F}}\n\\newcommand{\\bV}{\\mathbf{V}}\n\\newcommand{\\bX}{\\mathbf{X}}\n\n\\newcommand{\\bxi}{\\bm{\\xi}}\n\n\\newcommand{\\bzero}{\\bm{0}}\n\n\\newcommand{\\rhoi}{\\rho_{\\text{i}}}\n\n\\newcommand{\\ip}[2]{\\left(#1,#2\\right)}\n\n\\newcommand{\\mR}{R^{\\bm{\\oplus}}}\n\\newcommand{\\iR}{R^{\\bullet}}\n\n\\newcommand{\\nn}{{\\text{n}}}\n\\newcommand{\\pp}{{\\text{p}}}\n\\newcommand{\\qq}{{\\text{q}}}\n\\newcommand{\\rr}{{\\text{r}}}\n\n\\newcommand{\\bus}{\\bu|_s}\n\n% norm |||x|||\n\\newcommand{\\vertiii}[1]{{\\left\\vert\\kern-0.25ex\\left\\vert\\kern-0.25ex\\left\\vert #1 \\right\\vert\\kern-0.25ex\\right\\vert\\kern-0.25ex\\right\\vert}}\n\n% numbering\n\\setcounter{tocdepth}{3}\n\\makeatletter\n\\def\\l@subsection{\\@tocline{2}{0pt}{4pc}{5pc}{}}\n\\makeatother\n\n\\numberwithin{equation}{section}\n\\numberwithin{figure}{section}\n\\numberwithin{table}{section}\n\\numberwithin{theorem}{section}\n\n\\DeclareFloatingEnvironment[name=Pseudocode]{pcode}\n\n\\begin{document}\n\\title[Multilevel computation of glacier geometry from Stokes dynamics]{Multilevel computation of glacier geometry \\\\ from Stokes dynamics}\n\n\\author{Ed Bueler}\n\n\\author{Lawrence Mitchell}\n\n\\date{\\today}\n\n\\begin{abstract} FIXME MCD for steady and evolving geometry with Glen-Stokes dynamics\n\\end{abstract}\n\n\\maketitle\n\n%\\tableofcontents\n\n\\thispagestyle{empty}\n%\\bigskip\n\n\\section{Introduction} \\label{sec:intro}\n\nFIXME a multigrid \\cite{Trottenbergetal2001} method basically by \\cite{Tai2003} for obstacle problems; see \\cite{Bueler2022} and \\cite{GraeserKornhuber2009};  obstacle problem view first extended to Stokes by \\cite{WirbelJarosch2020}\n\n\n\\section{The steady ice geometry problem} \\label{sec:stokesgeometry}\n\nThe standard model for determining the geometry of glaciers is based upon a dynamical description of ice flow, namely a shear-thinning version of the Stokes equations.  However, this Glen-Stokes ice-dynamics model only determines the free-surface glacier geometry when combined with the surface kinematical equation (SKE) and a climate input, namely the balance of the rates of snow accumulation and melting/runoff (ablation).  In this section we state the strong form of the resulting ``coupled'' glacier geometry model in the steady-state case, which we call the steady ice geometry problem (SIGP).  The emphasis here is on the complementarity-problem nature of the SIGP, which is often not explicit in the glaciers literature (but see \\cite{SchoofHewitt2013}).  We then define the weak form, noting along the way several unresolved aspects of the theory.  The steady model has a straightforward extension to a time-discretized evolving-geometry model, the implicit ice geometry problem (IIGP; Section \\ref{sec:evolution}).\n\nThe SIGP is defined on a fixed, bounded map-plane region $\\Omega \\subset \\RR^d$ for $d=1,2$ (Figure \\ref{fig:stokesdomain}; coordinates on $\\Omega$ are denoted as $x$ when $d=1$ and $x,y$ when $d=2$).  On $\\Omega$ we assume that a time-independent climatic mass balance (CMB) \\cite{Cogleyetal2011} function $a(x,y)$ is defined at every point, whether or not ice is present at that location.  In ice-free areas this function is the ``potential'' CMB, namely the annual balance of snow accumulation and melt if ice were present, e.g.~as computed by energy balance in a climate or weather model.  We assume $a$ has units of ice thickness per time, compatible with our assumption of constant ice density.  Also, a bed elevation function $b(x,y)$ is defined everywhere on $\\Omega$; it gives the topography upon which the glacier sits.  The functions $a$ and $b$ are the data (inputs) of the SIGP.\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{genfigs/stokesdomain.pdf}\n\\end{center}\n\\caption{In the SIGP the CMB $a$ (arrows; down for accumulation) and bed elevation $b$ (solid) are given data on a map-plane region $\\Omega \\subset \\RR^d$ for $d=1,2$.  The solution includes a surface elevation $s$ (dashed) on $\\Omega$, such that $s\\ge b$, plus the ice velocity $\\bu$ and pressure $p$ on the icy domain $\\Lambda_s = \\{b < z < s\\} \\subset \\RR^{d+1}$.}\n\\label{fig:stokesdomain}\n\\end{figure}\n\nNow, the Glen-Stokes stress balance equations (below) only apply in a certain icy domain in $\\RR^{d+1}$.  We make a strong, but common \\cite[for example]{IsaacStadlerGhattas2015,Jouvetetal2008,Lengetal2012,WirbelJarosch2020} assumption that this domain has a well-defined upper surface elevation, a function $s(x,y)$.  That is, we assume there are \\emph{no overhangs}, and that the under-side of the ice is in contact with the bed $b$.  We then define $s$ everywhere in $\\Omega$ by extending with $s=b$ where ice is absent, thus $s\\ge b$ applies on all of $\\Omega$.  Note that $s$ is part of the model solution; it is not given data.\n\nBased on this well-defined upper surface, the icy domain is the open set\n\\begin{equation}\n\\Lambda_s = \\{(x,y,z)\\,|\\,(x,y) \\in \\Omega \\,\\text{ and }\\, b(x,y) < z < s(x,y)\\}  \\subset \\RR^{d+1}, \\label{eq:lambdas}\n\\end{equation}\nwhere $z$ is vertically-upward.  The domain $\\Lambda_s$, which is a \\emph{solution} in our model, has the topology of the product of an open subset of $\\Omega$ and an interval, and we will approximate it using an extruded mesh (Section \\ref{sec:fe}).\n\nWe model the ice as an incompressible, very-viscous \\cite{Acheson1990}, non-Newtonian fluid in $\\Lambda_s$.  Allowing any Glen exponent $\\nn\\ge 1$ \\cite{GreveBlatter2009}, the equations are\n\\begin{align}\n- \\nabla \\cdot \\tau + \\nabla p &= \\rhoi \\bg &&\\text{\\emph{stress balance}} \\label{eq:forcebalance} \\\\\n\\nabla \\cdot \\bu &= 0 &&\\text{\\emph{incompressibility}} \\label{eq:incompressible} \\\\\n\\tau &= B_\\nn |D\\bu|^{(1/\\nn) - 1} D\\bu  &&\\text{\\emph{flow law}} \\label{eq:viscflowlaw}\n\\end{align}\nThe solution fields here are the velocity $\\bu$, pressure $p$, and deviatoric stress $\\tau$.  Equations \\eqref{eq:forcebalance} and \\eqref{eq:viscflowlaw} form the momentum conservation (stress balance) model, while \\eqref{eq:incompressible} follows from constant density and mass conservation \\cite[Chapter 1]{FowlerNg2021}.\n\nRegarding tensors and their notation, recall that the Cauchy stress tensor $\\sigma$ decomposes into the deviatoric part $\\tau$ minus the pressure, i.e.~$\\sigma = \\tau - p\\,I$, so equation \\eqref{eq:forcebalance} simply says $-\\Div \\sigma = \\rhoi \\bg$.  The strain rate tensor $D\\bu$ is the symmetric part of $\\grad \\bu$, $D\\bu = \\frac{1}{2} \\left(\\grad\\bu + \\grad\\bu^\\top\\right)$, and the tensor norm used in \\eqref{eq:viscflowlaw} satisfies $|D\\bu|^2 = \\frac{1}{2} (D\\bu)_{ij} (D\\bu)_{ij}$.  Because $D\\bu$ is symmetric, and because it has trace zero by equation \\eqref{eq:incompressible}, i.e.~$\\trace(D\\bu)=\\nabla \\cdot \\bu = 0$, equation \\eqref{eq:viscflowlaw} then implies that $\\tau$ is also symmetric with trace zero, thus that $p=-\\trace \\sigma / (d+1)$.\n\nIn computations we will use the following constants: Glen exponent $\\nn=3$, ice density $\\rhoi=910 \\,\\text{kg}\\,\\text{m}^{-3}$ \\cite{Huybrechtsetal1996}, and gravity $\\bg=\\left<0,0,-g\\right>$, with $g=9.81\\,\\text{m}\\,\\text{s}^{-2}$.  The ice hardness $B_\\nn$ is a constant because we assume isothermal conditions \\cite{GreveBlatter2009}, with value $B_3=6.8082\\times 10^7\\,\\text{Pa}\\,\\text{s}^{1/3}$ \\cite{Huybrechtsetal1996}.\n\nFor the $\\nn=1$ (Newtonian) Stokes equations one would write \\eqref{eq:viscflowlaw} as $\\tau = 2\\nu D\\bu$ with viscosity $\\nu>0$, but exponents $\\nn>1$ suggest an effective viscosity function of $|D\\bu|$.  This would be singular in the limit of small strain rates, and so, motivated by the actual finite viscosity of glacier ice \\cite{GreveBlatter2009}, we define the following regularized effective viscosity using $\\eps>0$,\n\\begin{equation}\n\\nu_\\eps(|D\\bu|) = \\frac{1}{2} B_\\nn \\left(|D\\bu|^2 + \\eps\\, D_0^2\\right)^{(\\pp-2)/2}, \\label{eq:regeffvisc}\n\\end{equation}\nwhere $\\pp=(1/\\nn)+1$, with $\\pp=4/3$ in computations.  The constant $D_0$ defines a strain-rate scale for glacier flow; values $D_0 = 1 \\,\\text{a}^{-1}$ and $\\eps = 10^{-4}$ are used in computations.\n\nOur SIGP model uses dynamic boundary conditions for an isolated, grounded, and non-sliding glaciers.  (Floating and sliding cases are topics for additional research.)  In addition to the already-stated assumption that the top and bottom boundaries of $\\Lambda_s$ can be identified, we further assume these surfaces have well-defined tangents.  On the base we impose no slip:\n\\begin{equation}\n\\bu = \\bzero  \\qquad\\qquad \\text{\\emph{base} } \\Gamma_0. \\label{eq:basebc}\n\\end{equation}\nOn the sub-aerial surfaces we set a condition of zero applied stress,\n\\begin{equation}\n\\left(2 \\nu_\\eps(|D\\bu|) D\\bu - pI\\right) \\bn = \\bzero  \\qquad \\qquad \\text{\\emph{upper ice surface}} \\label{eq:topbc}\n\\end{equation}\nwhere $\\bn$ is any normal to $\\partial \\Lambda_s$.  (A nonzero atmospheric pressure at the surface is straightforward to apply if desired.)  Note that the ice flow extends in the horizontal direction until a free boundary at the glacier margin is reached.  Generally $\\grad s$ is singular at a glacier margin.\n\nThe simultaneous determination of $\\Lambda_s$ and $(\\bu,p)$ is the goal of the SIGP model.  However, the above equations make no reference to the climate input function $a$, so we need another ``equation'', one which is fundamentally an inequality as well.  Noting that the surface elevation is already defined on all of $\\Omega$, with $s=b$ off the ice, we set\n\\begin{equation}\n\\bn_s = \\left<-s_x,-s_y,1\\right> \\label{eq:surfacenormal}\n\\end{equation}\nas an (un-normalized) top-surface normal defined almost everywhere on $\\Omega$.  Furthermore we extend the surface value of the velocity to all of $\\Omega$:\n\\begin{equation}\n\\bus(x,y) = \\begin{cases} \\bu(x,y,s(x,y)), & s(x,y) > b(x,y), \\\\\n                     \\bzero, & \\text{elsewhere}. \\end{cases} \\label{eq:surfacevelocity}\n\\end{equation}\nA discontinuity of this function is (generally) expected at the ice margin.\n\nThe steady-state surface kinematical equation (SKE) \\cite[equation (5.21)]{GreveBlatter2009} is the needed additional equation:\n\\begin{equation}\n\\bus \\cdot \\bn_s + a = 0 \\qquad \\text{\\emph{on the ice}}. \\label{eq:ske}\n\\end{equation}\nNote that $a(x,y)$ is the \\emph{vertical} ice thickness added per time \\cite{GreveBlatter2009}.  Though kinematical balance \\eqref{eq:ske} applies only on the ice, $\\bus \\cdot \\bn_s + a \\le 0$ applies everywhere in $\\Omega$ because $a$ is nonpositive in steady state in ice-free locations.  In fact, when combined with the constraint that $s\\ge b$ everywhere on $\\Omega$, SKE \\eqref{eq:ske} is part of an infinite-dimensional nonlinear complementarity problem (NCP) \\cite{Bueler2021conservation}.  By definition, an NCP on a vector space $V$ combines the three statements\n\\begin{equation}\nx\\ge 0, \\quad f(x)\\ge 0, \\quad x f(x)=0 \\label{eq:ncp}\n\\end{equation}\nfor all $x\\in V$, where $f:V\\to V$ \\cite{FacchineiPang2003}.\n\nWe may now state the strong form of the SIGP, as follows, by including all of the above conditions, and also by eliminating $\\tau$ from \\eqref{eq:forcebalance} and \\eqref{eq:viscflowlaw}:\n\\begin{align}\ns - b &\\ge 0 && \\text{on $\\Omega$} \\label{eq:strongform} \\\\\n- \\bu|_s \\cdot \\bn_s - a &\\ge 0 && \\text{\\emph{same}} \\notag \\\\\n(s - b) (- \\bu|_s \\cdot \\bn_s - a) &= 0 && \\text{\\emph{same}} \\notag \\\\\n- \\nabla \\cdot \\left(2 \\nu_\\eps(|D\\bu|)\\, D\\bu\\right) + \\nabla p - \\rhoi \\mathbf{g} &= \\bzero && \\text{on $\\Lambda_s$} \\notag \\\\\n\\nabla \\cdot \\bu &= 0 && \\text{\\emph{same}} \\notag \\\\\n\\bu &= \\bzero && \\text{on $\\Gamma_0$} \\notag \\\\\n\\left(2 \\nu_\\eps(|D\\bu|) D\\bu - pI\\right) \\bn &= \\bzero && \\text{on $\\partial \\Lambda_s \\setminus \\Gamma_0$} \\notag\n\\end{align}\nThe first three statements in \\eqref{eq:strongform} form the NCP, but this problem is coupled to the boundary value problem formed by the last four statements.\n\nThe solution of \\eqref{eq:strongform} is a triple of functions $s(x,y)$, $\\bu(x,y,z)$, $p(x,y,z)$ on $\\Omega,\\Lambda_s,\\Lambda_s$, respectively.  However, as the domain on which $\\bu,p$ are defined is only known via the solution, \\eqref{eq:strongform} is at best an incomplete description.  (The weak form in the next section, using a solution operator which maps $s$ to $\\bu|_s$, will address this concern.)  However, whether in strong or weak form, inequality-constrained system \\eqref{eq:strongform} has a largely-unresolved theory regarding well-posedness and solution regularity.  Certain well-posedness theory is known for the SIA version of this problem, with existence established by \\cite{JouvetBueler2012}, including uniqueness in the flat bed case.\n\nAs a consequence of the no-overhangs assumption, the SIGP as described here is likely not to be well-posed because of an issue at the ice margin.  There may be no steady state because the fluid in the vicinity of a steep ice margin, especially on a steep bed feature, generates an overhang, violating the assumption that the function $s$ is well-defined.  Furthermore the same concern applies to each time step of an evolving model; overhangs can develop at the margin.  Because overhangs are small features in large glaciers and ice sheets, most modeling literature ignores this possibility and assumes well-defined surface elevation and thickness \\cite{Jouvetetal2008,Lengetal2012,WirbelJarosch2020}.  The exceptional literature \\cite{Jouvetetal2011,PralongFunk2005} provides a model in which ice-cliff calving occurs via a damage variable and a stress-fracture failure criterion, which might explain how a (nearly) well-defined surface elevation and thickness could arise in a more-complete, and well-posed, model.  However, such a model is a nontrivial extension of the above equations.  Neither marginal cliffs nor overhangs are allowed in our theory.\n\nAfter stating the SIGP weak form next in Section \\ref{sec:weakido}, in Sections \\ref{sec:fe}--\\ref{sec:results} we will construct and demonstrate a multilevel scheme for the problem.  Noting that numerical solutions have traditionally applied explicit time-stepping, even when computing steady states, splitting the dynamics and the SKE into sub-steps and using truncation to address the NCP \\cite[for example]{Jouvetetal2008,Lengetal2012}, the implicit time-stepping model in Section \\ref{sec:evolution} avoids time-splitting and is unconditionally stable.\n\n\n\\section{The weak form using an ice dynamics operator} \\label{sec:weakido}\n\nThe weak form of the fixed-geometry Glen-Stokes model for ice flow, which extends the linear Stokes weak form \\cite{Elmanetal2014} to regularized power-law rheology, is relatively well-known \\cite{IsaacStadlerGhattas2015,JouvetRappaz2011,Lengetal2012}, and we summarize it here.  Then we address the weak form of the geometry-determining SIGP.\n\nDenote by $W^{k,r}$ the Sobolev space \\cite{Evans2010} of functions with $k$ weak derivatives which are $r$th-power integrable.  Suppose for the moment that $\\Lambda \\subset \\RR^{d+1}$ is a fixed, bounded domain on which we prescribe a Dirchlet condition $\\bu=0$ on some positive-measure portion of $\\partial\\Lambda$, and otherwise suppose the boundary is stress-free (Neumann boundary).  Let $\\pp=(1/\\nn)+1$ as in \\eqref{eq:regeffvisc}, and $\\qq=(1-\\pp^{-1})^{-1}=\\nn+1$ the conjugate exponent; $\\pp=4/3$ and $\\qq = 4$ if $\\nn=3$.  Let $W_0^{1,\\pp}(\\Lambda)^{d+1}$ be the space of velocity functions, zero along the Dirichlet boundary, and let\n\\begin{equation}\n\\mathcal{M}_\\Lambda = W_0^{1,\\pp}(\\Lambda)^{d+1} \\times L^\\qq(\\Lambda)  \\label{eq:mixed}\n\\end{equation}\nbe the (mixed) space of admissible velocity and pressure pairs.  The Glen-Stokes solution $(\\bu,p) \\in \\mathcal{M}_\\Lambda$ satisfies the weak form\n\\begin{equation}\nF_\\Lambda(\\bu,p)[\\bv,q] = \\int_\\Lambda 2 \\nu_\\eps(|D\\bu|) D\\bu : D\\bv - p \\Div\\bv - (\\Div\\bu) q - \\rhoi \\bg \\cdot \\bv\\,d\\bx = 0 \\label{eq:glenstokesweak}\n\\end{equation}\nfor all $(\\bv,q) \\in \\mathcal{M}_\\Lambda$.  If $\\bu,p$ are sufficiently regular then they satisfy strong equations \\eqref{eq:forcebalance}--\\eqref{eq:topbc}.  Jouvet and Rappaz \\cite{JouvetRappaz2011} prove that this fixed-domain Glen-Stokes formulation is well-posed under the above assumptions if also the Neumann boundary of $\\Lambda$ is $C^1$.  They show \\eqref{eq:glenstokesweak} is equivalent to minimization of a convex and coercive functional over the divergence-free subspace, and that there is a unique pressure $p$.\n\nHowever, we must go beyond predetermined ice geometry to solve the weak form of SIGP \\eqref{eq:strongform}.  Again suppose $\\Omega \\subset \\RR^d$ is a fixed map-plane domain with $C^1$ boundary, and that the bed elevation $b$ is in $W^{1,\\qq}(\\Omega)$.  The Sobolev space $W^{1,\\qq}(\\Omega)$ supports a linear trace operator which defines the symbol $|_{\\partial \\Omega}$ \\cite[Section 5.5]{Evans2010}.  Let\n\\begin{equation}\n\\mathcal{K} = \\{s \\in W^{1,\\qq}(\\Omega) \\,:\\, s \\ge b \\, \\text{ and } \\, s\\big|_{\\partial\\Omega} = b\\big|_{\\partial\\Omega}\\}  \\label{eq:Kconstraintset}\n\\end{equation}\nbe the closed and convex set of admissible surface elevations of an isolated glacier or ice sheet.  From now on we also assume that $\\nn>1$.  Because $\\qq = \\nn+1 > d$, each $s \\in W^{1,\\qq}(\\Omega)$ is continuous \\cite[Morrey's inequality, section 5.6.2]{Evans2010}, and so there are no cliffs in the $s$ geometry.  (Though it is not yet clear that the correct Sobolev space is identified in \\eqref{eq:Kconstraintset}, existence for the simpler SIA model finds that a power of the ice thickness, $u=(s-b)^{2q/(q-1)}$, is in $\\mathcal{K} = \\{v \\ge 0\\} \\subset W^{1,\\qq}(\\Omega)$ \\cite{JouvetBueler2012}.)  Recalling definition \\eqref{eq:lambdas}, we further suppose that\n\\begin{equation}\ns\\in \\mathcal{K} \\text{ defines an icy domain } \\Lambda_s \\text{ which has a $C^1$ upper surface.} \\label{eq:quixotic}\n\\end{equation}\nAssumption \\eqref{eq:quixotic} would follow from a sufficiently-strong regularity result for the theory of the current paper, something we cannot offer.  However, in the SIA model the surface $s$ solves an elliptic equation, and $s$ is $C^1$ on $\\{s>b\\} \\subset \\Omega$ if $b$ is continuous \\cite{JouvetBueler2012}.\n\nWe now define an ice dynamics operator (IDO), a map $\\Phi$ which uses the trace of the velocity solution to the Glen-Stokes problem \\eqref{eq:glenstokesweak}; see Figure \\ref{fig:idoaction}.  For each $s \\in \\mathcal{K}$ the output $\\Phi(s)$ is the negative normal component of the (unique) velocity solution $\\bu$ of \\eqref{eq:glenstokesweak} over the upper surface of $\\Lambda_s$, but extended by zero to all of $\\Omega$:\n\\begin{equation}\n\\Phi(s) = \\begin{cases} - \\bu|_s \\cdot \\bn_s, & s > b, \\\\\n                        0, & \\text{otherwise}. \\end{cases} \\label{eq:ido}\n\\end{equation}\nHere $\\bu|_s$ denotes a trace operator on $W^{1,\\pp}(\\Lambda_s)^{d+1}$; compare \\eqref{eq:mixed}.  Note that $\\Phi(s)$ is a scalar function on $\\Omega$ which may jump or be singular at the glacier margin even if $s$ is smooth on $\\{s>b\\}$.  We will only need $\\Phi(s)$ to be in the dual of $W^{1,\\qq}(\\Omega)$.\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=\\textwidth]{genfigs/idoaction.pdf}\n\\end{center}\n\\caption{The IDO $\\Phi$ maps the surface elevation $s$ (dashed) to the normal ice surface motion $\\Phi(s)=- \\bu|_s \\cdot \\bn_s$.  Both $s$ and $\\Phi(s)$ are defined on all of $\\Omega$, but $\\Phi(s)$ is generally discontinuous.}\n\\label{fig:idoaction}\n\\end{figure}\n\nWe believe that formula \\eqref{eq:ido} defines a nonlinear operator $\\Phi:\\mathcal{K} \\subset W^{1,\\qq}(\\Omega) \\to (W^{1,\\qq}(\\Omega))^* = W^{-1,\\pp}(\\Omega)$.  This operator is \\emph{expensive} and \\emph{nonlocal}.  Evaluating $\\Phi(s)$ requires solving Glen-Stokes problem \\eqref{eq:glenstokesweak} on $\\Lambda_s \\subset \\RR^{d+1}$ defined in \\eqref{eq:lambdas}, and furthermore the solution $\\bu$ is influenced everywhere by changes in the icy domain geometry.  In particular, if $\\tilde s=s + r$ defines $\\Lambda_{\\tilde s} \\supset \\Lambda_s$, for $r\\in C_c^\\infty(\\Omega)$ with $r\\ge 0$ supported inside $\\{s>b\\}$, then the Stokes solutions are generically different \\emph{everywhere}; generically $\\tilde\\bu - \\bu \\ne 0$ a.e.~on $\\Lambda_s$.  It follows that an FE discretization (Section \\ref{sec:fe}) of $\\Phi(s)$ will have a dense Jacobian matrix.\n\nBy contrast, in the simpler isothermal, nonsliding, $d=2$ SIA model the operator is a nonlinear, second-order differential operator,\n\\begin{equation}\n\\Phi_{\\text{SIA}}(s) = - \\frac{\\gamma}{\\qq} (s-b)^{\\qq} |\\grad_2 s|^{\\qq} - \\grad_2 \\cdot\\left[\\frac{\\gamma}{\\qq+1} (s-b)^{\\qq+1} |\\grad_2 s|^{\\qq-2} \\grad_2 s\\right], \\label{eq:phisia}\n\\end{equation}\nfor $\\gamma = 2(\\rhoi g)^{\\nn} (B_\\nn)^{-\\nn} > 0$ constant and $\\grad_2 = (\\partial_x,\\partial_y)$.  Thus an FE discretization of $\\Phi_{\\text{SIA}}(s)$ has sparse Jacobian.  However, $\\Phi_{\\text{SIA}} \\approx \\Phi$ for shallow glaciers to the degree that the lubrication approximation \\cite{Acheson1990} is valid, and in fact for ice sheets we expect the Jacobian of $\\Phi$ to be well-approximated by a banded matrix.\n\nIn this section we will use $\\Phi$ to simplify the SIGP strong form and express its weak form, but later we will be concerned with two other aspects of the IDO:\n\\renewcommand{\\labelenumi}{(\\emph{\\roman{enumi}})}\n\\begin{enumerate}\n\\item Section \\ref{sec:smoothers} approximates the diagonal entries of the Jacobian $\\Phi'$ to construct smoothers.\n\\item Section \\ref{sec:evolution} relates the spectrum of $\\Phi'$ to the stability of time-stepping methods.\n\\end{enumerate}\n\nFor now we re-write \\eqref{eq:strongform} as a cleaner NCP with a hidden dynamical problem:\n\\begin{align}\ns - b &\\ge 0  \\label{eq:idostrongform} \\\\\n\\Phi(s) - a &\\ge 0 \\notag \\\\\n(s - b) (\\Phi(s) - a) &= 0 \\notag\n\\end{align}\nThese statements hold on all of $\\Omega$, and the roles of the data $a,b$ are evident, and the solution is the ice surface $z=s(x,y)$, but the variables $\\bu,p$ are hidden within the evaluation of $\\Phi(s)$.\n\nTo reveal the SIGP weak form we define a functional which is simply the dual of $\\Phi$:\n\\begin{equation}\nF(s)[r] = \\ip{\\Phi(s)}{r} = \\int_\\Omega \\Phi(s)\\, r \\,dx dy \\label{eq:sigpfunctional}\n\\end{equation}\n% in here one could integrate-by-parts on the vertical velocity using incompressibility:\n% u|_s . n|_s = u|_s s_x + v|_s s_y + w|_s = u|_s s_x + v|_s s_y - \\int_b^s (u_x + v_y) dz\n% and then integrate by parts in plane\nwhere $r \\in W^{1,q}(\\Omega)$.  One computes $F(s)[r]$ by defining $\\Lambda_s$ as in \\eqref{eq:lambdas}, solving \\eqref{eq:glenstokesweak}, evaluating the surface trace of the velocity to compute $\\Phi(s)$, and then integrating the result against (i.e.~dual pairing with) the test function $r$.  The weak form itself is the following variational inequality (VI) \\cite{KinderlehrerStampacchia1980} for $s\\in\\mathcal{K}$:\n\\begin{equation}\nF(s)[r - s] \\ge \\ip{a}{r-s} \\quad \\text{for all $r \\in \\mathcal{K}$.}  \\label{eq:sigpweakform}\n\\end{equation}\nOne can prove that if $s$ is $C^1$ and solves \\eqref{eq:sigpweakform} then it solves strong forms \\eqref{eq:ske} and \\eqref{eq:idostrongform} \\cite{Bueler2021conservation}.  Note that the strong SKE \\eqref{eq:ske}, which holds on $s>b$, is the interior condition of VI \\eqref{eq:sigpweakform} \\cite{KinderlehrerStampacchia1980}.\n\nSpeaking geometrically, \\eqref{eq:sigpweakform} says that $s$ is located in $\\mathcal{K}$, generically on $\\partial\\mathcal{K}$, at a point where $\\Phi(s)-a$ points directly into $\\mathcal{K}$.  (The ``angle'' between $\\Phi(s)-a$ and an arbitrary vector $r-s$ pointing into $\\mathcal{K}$ is at most $90^\\circ$.)  It is well-known that certain VIs arise as inequality-constrained minimization problems \\cite{GraeserKornhuber2009,KinderlehrerStampacchia1980}, but to the best of our knowledge \\eqref{eq:sigpweakform} does \\emph{not} arise in this way.  Existence has been proven for the SIA analog of VI \\eqref{eq:sigpweakform} \\cite{JouvetBueler2012}, and this SIA model is not a minimization except in the flat-bed case.\n\nThe SIGP weak form \\eqref{eq:sigpweakform} is coupled to the Glen-Stokes weak form \\eqref{eq:glenstokesweak} through definition \\eqref{eq:ido} of the IDO $\\Phi$.  VI problem \\eqref{eq:sigpweakform} therefore has three fundamental nonlinearities:\n\\renewcommand{\\labelenumi}{(\\emph{\\roman{enumi}})}\n\\begin{enumerate}\n\\item the Glen power-law rheology,\n\\item the inequality constraint, and\n\\item the nonlinearity of free-surface flow as a function of the surface.\n\\end{enumerate}\nRegarding (\\emph{ii}), observe that the solution of the classical obstacle problem for the linear Laplacian operator is a nonlinear function of the data \\cite{KinderlehrerStampacchia1980}.  For (\\emph{iii}), note that a free-surface flow for Newtonian (linear) rheology produces a nonlinear equation for the flow thickness, e.g.~as expressed in the kinematic wave equation \\cite{Ockendonetal2003}.\n\nWe will need the (Gateaux) derivative of $\\Phi$.  Suppose $s\\in \\mathcal{K}$, $\\eps>0$, and $t \\in W_0^{1,\\qq}(\\Omega)$ is such that $s+\\eps t \\in \\mathcal{K}$.  Then\n\\begin{equation}\n\\Phi'(s)[t] = - \\lim_{\\eps\\to 0^+} \\frac{\\bu|_{s+\\eps t} \\cdot \\bn_{s+\\eps t} - \\bus \\cdot \\bn_s}{\\eps} \\label{eq:idoderiv}\n\\end{equation}\non $\\{s>b\\}$.  However, $\\Phi'(s)[t]$ is a one-sided directional derivative on $\\{s=b\\}$.  That is, $s+\\eps t\\ge b$ is required for all sufficiently-small $\\eps>0$, thus $t\\ge 0$, on the (active) set where $s=b$.  To simplify we define an $s$-independent set\n\\begin{equation}\n\\mathcal{W}_+ = \\{t \\in W_0^{1,\\qq}(\\Omega) \\,:\\, t(x,y) \\ge 0\\}. \\label{eq:infdefectset}\n\\end{equation}\nThen $\\Phi'(s)[t]$ is well-defined on inputs $(s,t) \\in \\mathcal{K} \\times \\mathcal{W}_+$, and $F'(s)[t,r]=\\int_\\Omega \\Phi'(s)[t] r$ is well-defined for $(s,t,r) \\in \\mathcal{K} \\times \\mathcal{W}_+ \\times W^{1,\\qq}(\\Omega)$.\n\nThe difference in \\eqref{eq:idoderiv} depends on the support of $t$:\n\\begin{equation}\n\\bu|_{s+\\eps t} \\cdot \\bn_{s+\\eps t} - \\bus \\cdot \\bn_s = \\begin{cases}\n           (\\bu|_{s+\\eps t} - \\bus) \\cdot \\bn_{s+\\eps t} + \\eps\\, \\bus \\cdot \\left<t_x,t_y,0\\right>, & s > b \\\\\n           \\bu|_{s+\\eps t} \\cdot \\bn_{s+\\eps t}, & s=b, t > 0 \\\\\n           0, & s=b, t = 0.\n                 \\end{cases} \\label{eq:differencecases}\n\\end{equation}\nThus a necessary condition for differentiability of $\\Phi$ is that $\\bu|_{s+\\eps t} \\cdot \\bn_{s+\\eps t} = o(\\eps)$ on the ice-free area $\\{s=b\\}$.  In physical terms, the ice motion part of the SKE \\eqref{eq:ske} must vanish for shrinking ice masses on bare ground, a reasonable supposition if the ice cannot slide.\n\nIn the next three sections we will construct an iterative, multilevel finite element solver for SIGP weak form \\eqref{eq:sigpweakform}.  Performance and stability concerns related to evaluating $\\Phi'$ are addressed in Section \\ref{sec:smoothers}.\n\n\n\\section{Finite element discretization} \\label{sec:fe}\n\nAssume $d=2$ and that $\\Omega \\subset \\RR^d$ is polygonal with triangulation $\\mathcal{T}$.  (If $d=1$ then $\\mathcal{T}$ would denote an interval decomposition of $\\Omega$.)  Based on low expected regularity at the ice margin, we will represent surface elevations $s\\in \\mathcal{K}$ using the $P_1$ finite element (FE) space\n\\begin{equation}\n\\mathcal{V}^h = \\{s \\in C^0(\\Omega) : s|_T \\text{ is linear if } T \\in \\mathcal{T}\\} \\subset W^{1,\\qq}(\\Omega).\n\\end{equation}\nNote \\cite{JouvetBueler2012} makes the same FE choice for the corresponding SIA problem, and that, because of low regularity at the free boundary, $P_1$ is a common choice even for the classical obstacle problem with smooth data \\cite{GraeserKornhuber2009}.\n\nLet $b^h \\in \\mathcal{V}^h$ be the discretized bed elevation, e.g.~the $\\mathcal{V}^h$ interpolant of $b$, and define the following closed and convex admissible subset of $\\mathcal{V}^h$:\n\\begin{equation}\n\\mathcal{K}^h = \\{s^h \\in \\mathcal{V}^h \\,:\\, s^h \\ge b^h \\text{ and } s^h|_{\\partial\\Omega} = b^h|_{\\partial\\Omega}\\}.  \\label{eq:feK}\n\\end{equation}\n(Compare \\eqref{eq:Kconstraintset}.)  Each $s^h\\in \\mathcal{K}^h$ defines a numerical icy domain $\\Lambda_{s^h} \\subset \\RR^{d+1}$ as in \\eqref{eq:lambdas}.  A triangle (interval) $T\\in\\mathcal{T}$ is said to be ice-free in $\\Lambda_{s^h}$ if $s^h=b^h$ at every vertex of $T$, and icy otherwise.\n\nGiven $b^h \\in \\mathcal{V}^h$ and $s^h \\in \\mathcal{K}^h$, we use Firedrake to construct an extruded mesh \\cite{McRaeetal2016} on $\\Lambda_{s^h}$ consisting of triangular prisms (or quadrilaterals if $d=1$); the triangulation $\\mathcal{T}$ of $\\Omega$ is now called the ``base mesh''.  As shown in Figure \\ref{fig:extruded}, each icy $T \\in \\mathcal{T}$ generates a column of $m_z \\ge 1$ prism (quadrilateral) elements in the extruded mesh.  However, ice-free $T$ have no extruded mesh elements at all; these columns are empty.  The extruded mesh is regenerated each time $F^h(s^h)$ is evaluated, but the base mesh $\\mathcal{T}$ is unchanged.\n\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=\\textwidth]{genfigs/extruded.pdf}\n\\end{center}\n\\caption{We compute the FE IDO $\\Phi^h(s^h)$ by solving \\eqref{eq:glenstokesweak} on an extruded mesh with $m_z$ layers.  In the ``pinched'' extrusion (left), the trace of $\\bu^h$ is evaluated on the graph of $s^h$ (bold).  In the ``cliffs'' extrusion (right) all elements have a minimum thickness (dotted).}\n\\label{fig:extruded}\n\\end{figure}\n\nOn the extruded mesh we approximately solve Glen-Stokes problem \\eqref{eq:glenstokesweak} using the $P_2\\times P_1$ Taylor-Hood mixed space \\cite{Elmanetal2014} which we denote $\\mathcal{M}^h$.  Thus $(\\bu^h,p^h) \\in \\mathcal{M}^h$ solves\n\\begin{align}\nG_{\\Lambda_{s^h}}(\\bu^h,p^h)[\\bv^h,q^h] &= 0  \\label{eq:feglenstokesweak}\n\\end{align}\nfor all $(\\bv^h,q^h) \\in \\mathcal{M}^h$, where\n\\begin{equation}\nG_{\\Lambda_{s^h}} = \\int_{\\Lambda_{s^h}} 2 \\nu_\\eps(|D\\bu^h|) D\\bu^h : D\\bv^h - p^h \\Div\\bv^h - (\\Div\\bu^h) q^h - \\rhoi \\bg \\cdot \\bv^h\\,d\\bx.  \\label{eq:feglenstokesfunctional}\n\\end{equation}\n\nThe power-law nonlinearity in \\eqref{eq:feglenstokesweak} is resolved by using a Newton iteration, with direct solution of the step equations and back-tracking line search.  As stated in Section \\ref{sec:intro}, our goal in the current paper is to show that $O(1)$ iterations of the multilevel scheme are needed to solve the discrete SIGP, \\eqref{eq:fesigpweakform} below.  Overall optimality of the solution algorithm would also require an optimal solution of Glen-Stokes problem \\eqref{eq:feglenstokesweak}, such as the multigrid scheme in \\cite{IsaacStadlerGhattas2015}.\n\nIn fact we will compare two extrusion modes when solving problem \\eqref{eq:feglenstokesweak}.  In the ``pinched'' extrusion the prism elements tile $\\Lambda_{s^h}$ exactly but the elements at the ice margin are degenerate; they have positive volume but zero height at some nodes or even empty (vertical) facets.  In the alternate ``cliffs'' extrusion, each extruded element is nondegenerate and they tile a larger domain $\\tilde\\Lambda_{s^h} \\supset \\Lambda_{s^h}$.  Specifically, each prism has minimum thickness $H_{\\text{min}}/m_z$ where $H_{\\text{min}} > 0$ is the minimum total thickness, with $H_{\\text{min}} = 20$ meters in computations.  The surface $s^h$ remains unchanged (and continuous), and cliffs only appear in problem \\eqref{eq:feglenstokesweak}.\n\nLet $\\Phi^h:\\mathcal{K}^h \\to (\\mathcal{V}^h)'$ be the FE approximation of the IDO $\\Phi$.  By definition $\\Phi^h(s^h)$ is the normal component of the numerical surface velocity after solving the Glen-Stokes equation \\eqref{eq:feglenstokesweak} on the domain $\\Lambda_{s^h}$.  That is, we evaluate $\\Phi^h(s^h)$ using the surface trace as in \\eqref{eq:ido}, and then extend by zero to all of $\\Omega$.  In the ``cliffs'' extrusion the velocity trace is computed at the top of each column, and thus only nearby the original surface $s^h$, but the normal direction uses $s^h$ itself.\n\nFinally, let $F^h(s)[r] = - \\ip{\\Phi^h(s)}{r}$; compare \\eqref{eq:sigpfunctional}.  The discrete SIGP computes $s^h \\in \\mathcal{K}^h$ satisfying\n\\begin{equation}\nF^h(s^h)[r^h - s^h] \\ge \\ip{a}{r^h-s^h} \\quad \\text{for all } r^h \\in \\mathcal{K}^h. \\label{eq:fesigpweakform}\n\\end{equation}\nThe only role of the extruded mesh in solving \\eqref{eq:fesigpweakform} is in the evaluation of the IDO $\\Phi^h(s^h)$.  We believe that \\eqref{eq:fesigpweakform} is well-posed in each extrusion mode, but we have no proof.\n\n\n\\section{Smoothers} \\label{sec:smoothers}\n\nIn this section we consider single-level solvers for \\eqref{eq:fesigpweakform}, namely certain nonlinear iterations which are made suitable for VIs \\cite{KinderlehrerStampacchia1980}.  While these iterations are, in some cases, adequate smoothers in a multilevel method (next section), they converge slowly if used directly as solvers.  Because of the non-locality and density of the IDO $\\Phi^h$ (Section \\ref{sec:weakido}), we must make careful approximations in order to retain adequate per-iteration performance.  These iterative solvers, \\emph{smoothers} from now on, can be categorized by the number of nodes which are adjusted at each iteration: pointwise, patch-type, and global.\n\nSuppose there are $m$ interior vertices ($P_1$ nodes) of $\\mathcal{T}$, denote a vertex in $\\mathcal{T}$ by $(x_j,y_j)$, and let $\\psi_j \\in \\mathcal{V}^h$ be the corresponding $P_1$ hat function, with $\\psi_j(x_k,y_k)=\\delta_{jk}$.  Let $s^h\\in \\mathcal{K}^h$ be the current surface elevation iterate.  The Richardson pointwise smoother sweeps through the nodes and subtracts-off the residual: $s^h \\gets s^h - \\alpha (F^h(s^h)-a)$ where $\\alpha>0$ must be chosen so that the iteration converges.  By contrast the Gauss-Seidel, and Jacobi pointwise smoothers sweep through the nodes solving one-dimensional VI problems for a value $c\\in \\RR$ (below).  If each pointwise update $s^h \\gets s^h + c \\psi_i$ is done immediately then the smoother is of Gauss-Seidel (GS) type, also called serial or multiplicative, while a (parallel, additive) Jacobi smoother computes and stores solutions $c$ at every node before doing any updates.  In linear problems GS generally converges in about half as many iterations \\cite{Greenbaum1997}.\n\nTo be more precise, let $\\mathcal{W}_+^h = \\{t^h \\in \\mathcal{V}^h \\,:\\, t^h \\ge 0 \\text{ and } t^h|_{\\partial\\Omega} = 0\\}$.  If $i=0,\\dots,m-1$ index the interior vertices of $\\mathcal{T}$, note that $\\psi_i \\in \\mathcal{W}_+^h$, and that $s^h + c \\psi_i \\in \\mathcal{K}^h$ if and only if $c\\ge \\beta_i^{s^h} = b^h(x_i,y_i) - s^h(x_i,y_i)$.  (One might call $\\beta_i^{s^h}$ the pointwise defect obstacle \\cite{GraeserKornhuber2009} for $s^h$.)  The one-dimensional VI at interior node $i$ is derived from the discrete SIGP \\eqref{eq:fesigpweakform} by replacements $s^h \\to s^h+c \\psi_i$, $r^h \\to r^h + \\gamma \\psi_i$ for some scalars $c,\\gamma$.  We then seek $c \\ge \\beta_i^{s^h}$ such that\n\\begin{equation}\nF^h(s^h+c \\psi_i)[(s^h+\\gamma \\psi_i) - (s^h+c \\psi_i)] \\ge \\ip{a}{(s^h+\\gamma \\psi_i) - (s^h+c \\psi_i)} \\label{eq:fepointwiseviEARLY}\n\\end{equation}\nfor all $\\gamma \\ge \\beta_i^{s^h}$.  Let\n\\begin{equation}\n\\rho_i(s^h; c) = F^h(s^h+c\\psi_i)[\\psi_i] - \\ip{a}{\\psi_i} \\label{eq:ferhoi}\n\\end{equation}\nbe the pointwise residual function, and observe that \\eqref{eq:fepointwiseviEARLY} simplifies to\n\\begin{equation}\n(\\gamma - c) \\,\\rho_i(s^h; c) \\ge 0. \\label{eq:fepointwisevi}\n\\end{equation}\nThe smoother approximately solves \\eqref{eq:fepointwisevi} for $c$ and then updates $s^h \\gets s^h + c \\psi_i$ either in serial or parallel.  Observe that admissibility is preserved because $s^h+c \\psi_i \\in \\mathcal{K}^h$ when $c \\ge \\beta_i^{s^h}$.\n\nIf $\\rho_i(s^h; c)$ were linear and increasing in $c$, e.g.~$\\rho_i(s^h; c) = \\rho_i(s^h; 0) + \\alpha c$ with $\\alpha > 0$, then the solution to VI \\eqref{eq:fepointwisevi} would be given by the simple formula $c = \\max\\left\\{-\\rho_i(s^h; 0)/\\alpha, \\beta_i^{s^h}\\right\\}$ \\cite{GraeserKornhuber2009}.  In fact $\\rho_i(s^h; c)$ is nonlinear, and we will linearize\n\\begin{equation}\n\\rho_i(s^h; c) \\approx \\rho_i(s^h; 0) + c\\, \\rho_i'(s^h; 0). \\label{eq:rhoapprox}\n\\end{equation}\nAt each node where $\\rho_i'(s^h; 0) > 0$ we will do one projected Newton step using the simple formula.  However, if $\\rho_i'(s^h; 0) \\le 0$, so that the model has degenerated in the sense that the linearized, pointwise operator is not acting elliptically with respect to a perturbation, we set $c = \\beta_i^{s^h}$ to remove the ice at that location.  % FIXME TOO AGGRESSIVE?\n\nUsing a single Newton step and approximation \\eqref{eq:rhofd}, GS is a well-defined smoother, so we state it in Pseudocode \\ref{pc:pngsslow}.  It is given in a form which also allows over-relaxation ($\\id{omega} > 1$) or under-relaxation ($\\id{omega} < 1$) if desired.  Note that the Glen-Stokes problem \\eqref{eq:glenstokesweak} is solved $2m$ times per application of this function.\n\n\\begin{pcode}[ht]\n\\begin{pseudo*}\n\\pr{pngs}(s^h,b^h,\\id{omega}=1.0)\\text{:} \\\\+\n    \\ct{check admissibility: $s^h \\ge b^h$} \\\\\n    for $i = 0,\\dots,m-1$ \\\\+\n        $\\alpha_i = \\rho_i'(s^h; 0)$  \\qquad\\qquad \\ct{Jacobian diagonal entry} \\\\\n        if $\\alpha_i > 0$ \\\\+\n            $c_i = - \\rho_i(s^h; 0) / \\alpha_i$ \\\\\n            $(s^h)_i \\gets \\max\\{(s^h)_i + \\id{omega}\\,c_i, (b^h)_i\\}$ \\\\-\n        else \\\\+\n            $(s^h)_i \\gets \\beta_i$ \\qquad\\qquad \\ct{non-elliptic case}\n\\end{pseudo*}\n\\caption{Projected nonlinear GS iteration, a conceptual in-place, pointwise smoother which solves one-dimensional VIs \\eqref{eq:fepointwisevi} in serial.}\n\\label{pc:pngsslow}\n\\end{pcode}\n\nPatch-type smoothers \\cite{Farrelletal2019} have to our knowledge not been used for VI problems before, but they would sweep through the nodes solving local VIs of small dimension $\\ell>1$, and again there would be serial and parallel versions.  However, we first consider the opposite extreme from a pointwise smoother, namely a global smoother in which all the degrees of freedom are coupled together into an algebraic system.\n\nFIXME reduced-space Newton solver using a banded Jacobian approximation\n\n\n\\section{Approximate Jacobians} \\label{sec:jacobians}\n\nThe above pseudocodes assume the accessibility of the diagonal of the Jacobian (pointwise smoothers) or of arbitrary entries (Newton solver).\n\nBecause the interior PDE in the SIA is elliptic, it follows that $\\rho_i'(s^h; 0) > 0$ on the icy part of $\\Omega$ \\cite{JouvetBueler2012}, but for the full Glen-Stokes model there is no such guarantee to our knowledge.  Note that the derivative $\\rho_i'(s^h; 0)$, which is also a diagonal entry of the Jacobian of $F^h$, can be approximated by a finite difference,\n\\begin{equation}\n\\rho_i'(s^h; 0) = (F^h)'(s^h)[\\psi_i,\\psi_i] \\approx \\frac{\\rho_i(s^h; \\eps) - \\rho_i(s^h; 0)}{\\eps}.  \\label{eq:rhofd}\n\\end{equation}\nLiteral use of \\eqref{eq:rhofd} is very expensive because each value $\\rho_i(s^h; \\eps)$ requires a separate Glen-Stokes computation for the residual.\n\nA glaring difference between the GS and Jacobi smoothers now dominates.  Namely, GS imposes the expense of far more residual evaluations.\n\nFIXME finite-difference approximation using pseudo-coloring based on ice thicknesses or rather longitudinal coupling length \\cite{KambEchelmeyer1986}\n\nTo build a better smoother we return to the computation of the Jacobian diagonal entry $\\rho_i'(s^h; 0)$.  Suppose we partition the support of $\\psi_i$ into where there is ice and not,\n\\begin{equation}\n\\theta_i = \\{\\psi_i > 0\\} \\cap \\{s^h > b^h\\}, \\qquad {\\hat\\theta}_i = \\{\\psi_i > 0\\} \\setminus \\theta_i.  \\label{eq:thetasupport}\n\\end{equation}\nRecall that $\\bu|_{z}$ denotes the surface velocity of the solution to the Glen-Stokes problem \\eqref{eq:glenstokesweak} on the domain $\\Lambda_{z}$, using an extruded mesh (Section \\ref{sec:fe}).  By \\eqref{eq:idoderiv}, \\eqref{eq:differencecases}, and \\eqref{eq:ferhoi} we may compute\n\\begin{equation}\n\\rho_i(s^h; 0) = F^h(s^h)[\\psi_i] - \\ip{a}{\\psi_i} = - \\int_{\\theta_i} (\\bu|_{s^h} \\cdot \\bn_{s^h}- a)\\, \\psi_i  \\label{eq:rhozero}\n\\end{equation}\nand\n\\begin{align}\n\\rho_i'(s^h; 0) &= (F^h)'(s^h)[\\psi_i,\\psi_i]  \\label{eq:rholocalderiv} \\\\\n  &= - \\int_{\\theta_i} \\lim_{\\eps\\to 0^+} \\frac{(\\bu|_{s^h+\\eps\\psi_i} - \\bu|_{s^h}) \\cdot \\bn_{s^h+\\eps\\psi_i}}{\\eps} \\psi_i - \\int_{{\\hat\\theta}_i} \\lim_{\\eps\\to 0^+} \\frac{\\bu|_{s^h+\\eps\\psi_i} \\cdot \\bn_{s^h+\\eps\\psi_i}}{\\eps} \\psi_i.  \\notag\n\\end{align}\n\nClearly, any smoother application, which is a sweep over all nodes in $\\mathcal{T}$, will require at least one Glen-Stokes velocity solution, namely from solving \\eqref{eq:glenstokesweak} on the geometry determined by the current surface elevation $s^h$.  Formulas \\eqref{eq:rhozero} and \\eqref{eq:rholocalderiv} as stated require a Stokes solution $\\bu|_{s^h+\\eps\\psi_i}$ for each mesh node.\n\nHowever, we may estimate the surface velocity for a such perturbed surface elevation, namely with a small ``bump'' $\\eps\\psi_i$, by replacing the geometrical bump with a local perturbation of the body force.  That is, we may perturb the gravitational load relative to the solution which gave $s^h$, but without changing the geometry.  The change to the nonlinearities in this Glen-Stokes problem should be small, and the most important change to the velocity and pressure fields from a small bump perturbation is through its weight.  We suppose that other effects, such as a perturbed normal direction on the surface, are significantly smaller.\n\nFIXME Let us fix a current surface elevation $s^h$ and assume that problem \\eqref{eq:glenstokesweak} for $\\Lambda_{s^h}$ yields solution $\\bu^h,p^h$ at the convergence of its (Newton) iteration.  Noting that we are using a stable mixed space for this Glen-Stokes problem (Section \\ref{sec:fe}), the final step in the iteration can be regarded as providing the solution of a linear system\n\\begin{equation}\n    \\begin{bmatrix} A & B^\\top \\\\\n                    B & 0      \\end{bmatrix}\n    \\begin{bmatrix} \\bu^h \\\\ p^h \\end{bmatrix}\n    = \\begin{bmatrix} \\rhoi \\bg \\\\ 0 \\end{bmatrix}.  \\label{eq:system}\n\\end{equation}\nwhere we note that the matrix depends on $s^h$.  (Even the size of $K$ depends on $s^h$ because it is used to determine which $T\\in\\mathcal{T}$ get extruded icy columns.)  Also denote the perturbed problem, for surface $s^h + \\eps \\psi_i$, using an $\\eps$ subscript.\n\nWe assert that the perturbed-geometry Glen-Stokes solution is approximated by re-using the unperturbed matrix but adding the mass of the bump $\\eps \\psi_i$ to the right-hand side:\n\\begin{equation}\n\\begin{bmatrix} A_\\eps & B_\\eps^\\top \\\\\n                B_\\eps & 0      \\end{bmatrix}\n\\begin{bmatrix} \\bu_\\eps^h \\\\ p_\\eps^h \\end{bmatrix}\n    = \\begin{bmatrix} \\rhoi \\bg \\\\ 0 \\end{bmatrix}\n\\qquad \\approx \\qquad\n\\begin{bmatrix} A & B^\\top \\\\\n                B & 0      \\end{bmatrix}\n\\begin{bmatrix} \\bu_\\eps^h \\\\ p_\\eps^h \\end{bmatrix}\n    = \\begin{bmatrix}  \\rhoi (1 + \\eps \\tau_i)\\bg  \\\\ 0 \\end{bmatrix}.  \\label{eq:systemmassanalogy}\n\\end{equation}\nHere $\\tau_i$ is a positive $P_1$ function on $\\Lambda_{s^h}$, that is, on the extruded $d+1$-dimensional mesh, with support only at the top-surface node with base mesh index $i$, and with magnitude such that if $\\eps=1$ meter then\n\\begin{equation}\n  \\int_{\\Lambda_{s^h}} \\tau_i\\,dx\\,dy\\,dz = \\int_\\Omega \\psi_i\\,dx\\,dy . \\label{eq:massanalogy}\n\\end{equation}\nIn words, we approximate the Glen-Stokes solution $\\bu_\\eps^h,p_\\eps^h$ for the perturbed geometry by re-using the same (i.e.~$s^h$) geometry but solving the final linear system using a right-hand-side perturbation of the equivalent mass to the geometry perturbation.  This is shown in Figure \\ref{fig:massanalogy}.\n\n\\begin{figure}[t]\n\\begin{center}\nFIXME %\\includegraphics[width=\\textwidth]{genfigs/massanalogy.pdf}\n\\end{center}\n\\caption{A sketch of the mass-perturbation approximation in equations \\eqref{eq:systemmassanalogy} and \\eqref{eq:massanalogy}.}\n\\label{fig:massanalogy}\n\\end{figure}\n\nFIXME Pseudocode \\ref{pc:pnj} for PNJ with bump approximation\n\n\\begin{pcode}[ht]\n\\begin{pseudo*}\n\\pr{pnj}(s^h,b^h,\\id{omega}=1.0)\\text{:} \\\\+\n    \\ct{check admissibility: $s^h \\ge b^h$} \\\\\n    evaluate $\\{\\rho_i(s^h; 0)\\}_{i=0}^{m-1}$  \\qquad\\qquad \\ct{and save the final Newton step linear system} \\\\\n    for $i = 0,\\dots,m-1$ \\\\+\n        $\\alpha_i = (A^{-1})_{ii}$  \\qquad\\qquad \\ct{FIXME: give correct Jacobian diagonal entry} \\\\\n        if $\\alpha_i > 0$ \\\\+\n            $c_i = - \\rho_i(s^h; 0) / \\alpha_i$ \\\\--\n    for $i = 0,\\dots,m-1$ \\\\+\n        if $\\alpha_i > 0$ \\\\+\n            $(s^h)_i \\gets \\max\\{(s^h)_i + \\id{omega}\\,c_i, (b^h)_i\\}$ \\\\-\n        else \\\\+\n            $(s^h)_i \\gets \\beta_i$ \\qquad\\qquad \\ct{non-elliptic case}\n\\end{pseudo*}\n\\caption{Projected nonlinear Jacobi smoother using a bump approximation for the Jacobian diagonal entry $\\alpha_i$.  Problem \\eqref{eq:glenstokesweak} is solved only once per application of \\pr{pnj}, but additional linear algebra is needed to compute $\\alpha_i$.}\n\\label{pc:pnj}\n\\end{pcode}\n\nWe finish this section with some observations which are supported by the results reported in Section \\ref{sec:results}.  Constructing an efficient smoother is the most difficult part of building an effective multilevel scheme for numerically solving the SIGP.  In the time-stepping approach to steady state, used by almost all existing models, the difficulty is reflected in the nontrivial determination of a valid conditionally-stable time step criterion for the evolving geometry model.  Here the concern is associated to the ``ellipticity'' of the coupled equations for the SIGP, reflected in whether the diagonal Jacobian entry $\\alpha_i$, used in the above pointwise smoothers, is indeed positive.\n\nIn fact, suppose $s^h$ gives the $P_1$ geometry of the ice which solves the discrete SIGP.  For each icy node $i$ in $\\Omega$, i.e.~such that $(s^h)_i>(b^h)_i$, one can see that $\\alpha_i>0$ if and only if the addition of a thin (e.g.~one meter) layer of ice to surface of the ice, covering the vicinity of node $i$ (e.g.~the support of $\\psi_i$) will cause a dynamical response in which the surface goes down.  One can show this is so for the SIA theory \\cite{JouvetBueler2012}, but, even for nonsliding ice, we know of no proof that the Glen-Stokes SIGP always gives $\\alpha_i>0$ at icy locations.  It follows that pointwise smoothers like \\pr{pngs\\_slow} and \\pr{pnj} are inherently fragile across a full range of glacier geometries.\n\nFIXME PSEUDO-COLORING WITH LATERAL SEPARATION OF A FEW ICE THICKNESSES\n\n\n\\section{Multilevel constraint decomposition} \\label{sec:mcdstokes}\n\nIn this section we propose a new multilevel scheme for solving the discrete SIGP weak form \\eqref{eq:fesigpweakform} using iterated V-cycles.  The fundamental idea of such a scheme, in fact the basic geometric multigrid idea, is that smoothing on coarse levels will rapidly reduce the high frequencies in the error.  However, here we must maintain admissibility on each level in a manner which does not re-introduce high frequencies.  Our method is derived from the multilevel constraint decomposition (MCD) method of \\cite{Tai2003} (see also \\cite{GraeserKornhuber2009}), but our nonlinear variant (MCDN) uses a full approximation scheme (FAS) multigrid \\cite{Trottenbergetal2001} approach which transfers both the current residual and an approximation of the solution down to coarser levels.\n\nRegarding notation for multiple mesh levels, suppose $\\mathcal{T}^0$ is a fixed triangulation of $\\Omega$, the coarse level.  For $J\\ge 0$, which gives the number of finer levels, suppose $\\{\\mathcal{T}^j\\}_{j=1}^J$ are standard uniform refinements of $\\mathcal{T}^0$ by edge bisection so that each $T \\in \\mathcal{T}^j$ becomes four similar triangles in $\\mathcal{T}^{j+1}$ \\cite{Braess2007}.  (Halve each interval when $d=1$.)  Let $\\mathcal{V}^j$ be the $P_1$ FE space on $\\mathcal{T}^j$, with subspace $\\mathcal{V}_0^j = \\mathcal{V}^j \\cap W_0^{1,\\qq}(\\Omega)$.  If $m_j$ is the number of interior nodes $\\{(x_i^j,y_i^j)\\}$ in $\\mathcal{T}^j$ then $\\dim(\\mathcal{V}_0^j)=m_j$.\n\nWe seek an admissible solution to \\eqref{eq:fesigpweakform} on the fine level $\\mathcal{T}^J$.  Suppose $b^J \\in \\mathcal{V}^J$ denotes the fine-level bed topography.  The admissible fine-level surface elevations form a closed and convex set\n\\begin{equation}\n\\mathcal{K}^J = \\{r^J \\in \\mathcal{V}^J \\,:\\, r^J \\ge b^J, r^J|_{\\partial\\Omega} = b^J|_{\\partial\\Omega}\\}.  \\label{eq:singleadmissible}\n\\end{equation}\nHowever, we follow \\cite{GraeserKornhuber2009} in formulating a ``defect obstacle'' decomposition, instead of direct solution over the set $\\mathcal{K}^J$.  Suppose $s^J \\in \\mathcal{K}^J$ is an admissible current iterate and let\n\\begin{equation}\n\\chi^J = b^J - s^J \\in \\mathcal{V}_0^J \\label{eq:finedefectobstacle}\n\\end{equation}\nbe the associated defect obstacle, so that $\\chi^J \\le 0$.  Note that $z^J \\in \\mathcal{V}_0^J$ is an admissible perturbation of $s^J$, i.e.~$s^J+z^J \\in \\mathcal{K}^J$, if and only if $z^J \\ge \\chi^J$.\n\nNow we define the monotone restriction operator $\\mR : \\mathcal{V}_0^j \\to \\mathcal{V}_0^{j-1}$ \\cite{GraeserKornhuber2009} on $z^j = \\sum_{i=0}^{m_j-1} z^j[i] \\psi_i^j$, with coefficients $z^j[i]\\in\\RR$, by maximizing nodal values over the (open) supports of each coarser-level hat function:\n\\begin{equation}\n\\mR z^j = \\sum_{\\ell=0}^{m_{j-1}-1} \\max\\left\\{z^j[i] \\,:\\,\\psi_\\ell^{j-1}(x_i^j,y_i^j) \\right\\}\\,\\psi_\\ell^{j-1}.  \\label{eq:monotonerestriction}\n\\end{equation}\nWe use this nonlinear operator to define a defect obstacle on each level:\n\\begin{equation}\n\\chi^{j-1} = \\mR \\chi^j  \\label{eq:recursivedefectobstacle}\n\\end{equation}\nfor $j=1,\\dots,J$.  An example is shown in Figure \\ref{fig:decompclassical}.  We also compute the differences,\n\\begin{equation}\n\\phi^j = \\chi^j - \\chi^{j-1},  \\label{eq:downobstacles}\n\\end{equation}\nwith $\\phi^0=\\chi^0$ by definition; note $\\phi^j\\le 0$.\n\n% figure generated in mg-glaciers/py by using decomposition_plain() in visualize.py and then:\n% $ ./obstacle.py -J 5 -jcoarse 1 -irtol 1.0e-5 -monitor -diagnostics -random -randommodes 15 -o classical.pdf\n% to get decomp_classical.pdf\n\\begin{figure}[t]\n\\begin{center}\n\\includegraphics[width=0.7\\textwidth]{fixfigs/decompclassical.pdf}\n\\end{center}\n\\caption{An example ($d=1$, $J=4$) of an MCD decomposition of the defect obstacle $\\chi^J$.  Defect obstacles $\\chi^j$ are generated using the monotone restriction operator $\\mR$ as in \\eqref{eq:recursivedefectobstacle}.}\n\\label{fig:decompclassical}\n\\end{figure}\n\nA point-wise smoother on a given level will solve one-dimensional VIs at each node.  However, different admissible sets are used going down and up in the V-cycle.  Let\n\\begin{equation}\n\\mathcal{D}^j = \\left\\{y^j \\in \\mathcal{V}_0^j \\,:\\, y^j \\ge \\phi^j\\right\\}, \\qquad \\mathcal{U}^j = \\left\\{z^j \\in \\mathcal{V}_0^j \\,:\\, z^j \\ge \\chi^j\\right\\}. \\label{eq:downupsets}\n\\end{equation}\nNote that $0 \\in \\mathcal{D}^j \\cap \\mathcal{U}^j$; a zero perturbation is always admissible.  The down-admissible constraint sets $\\mathcal{D}^j$ sum to an up-admissible constraint set for each level.  The $\\mathcal{U}^j$ are themselves nested,\n\\begin{equation}\n\\mathcal{U}^0 \\subset \\mathcal{U}^1 \\subset \\dots \\subset \\mathcal{U}^J \\subset W_0^{1,\\qq}(\\Omega). \\label{eq:innerconeapprox}\n\\end{equation}\n\nWe seek a solution to VI \\eqref{eq:fesigpweakform} on the fine level.  The original idea of Tai \\cite{Tai2003} is to use a multilevel constraint decomposition (MCD) like the above  system $\\{\\mathcal{D}^j\\}$ to compute corrections $y^j \\in \\mathcal{D}^j$ which sum to a solution of the (nonlinear) fine-level VI,\n\\begin{equation}\nF^J(s^J + y^J + \\dots + y^j)[v^j - y^j] \\ge (a,v^j - y^j) \\quad \\text{for all } v^j \\in \\mathcal{D}^j. \\label{eq:mcdoriginal}\n\\end{equation}\n(Here $F^J = F^h$ in \\eqref{eq:fesigpweakform}.)  Observe that \\eqref{eq:mcdoriginal} exploits the simplification $(s^J + y^J + \\dots + v^j) - (s^J + y^J + \\dots + y^j) = v^j - y^j$.  Also note that $y^J + \\dots + y^j \\in \\mathcal{U}^J$ so the updated fine-level iterate is admissible in the original sense: $s^J + y^J + \\dots + y^j \\ge b^J$.\n\nIn \\cite{Tai2003}, VIs \\eqref{eq:mcdoriginal} are to be solved on descending levels $j=J$ down to $j=0$, forming a down-slash or V(1,0) cycle.  (See also \\cite[Algorithm 4.7]{GraeserKornhuber2009}.)  However, there is no practical way to achieve rapid solution of VI \\eqref{eq:mcdoriginal} on coarse levels if the latest iterate $s^J + y^J + \\dots + y^j$ must be directly represented; it has fine-level content.  This is the reason to add a full approximation scheme (FAS) \\cite{Trottenbergetal2001} coarse-level ``equation'', which is here a nonlinear VI.  In order to implement our approach we will need to state the FAS coarse-level correction equation using appropriate linear restriction and prolongation operators, as follows.\n\nLet $\\iR: \\mathcal{V}^{j+1} \\to \\mathcal{V}^j$ be the injection operator \\cite{Trottenbergetal2001}.  Suppose $y^j \\in \\mathcal{D}^j$ denotes the desired down-correction on the $j$th level.  For corrections $y^j \\in \\mathcal{D}^j$, define $t^j \\in \\mathcal{V}^j$ as the $j$th-level approximation to the corrected fine-level solution (i.e.~$t^j \\approx s^J + y^J + \\dots + y^j$),\n\\begin{equation}\nt^j = \\begin{cases} s^J, & j=J \\\\\n                    \\iR(t^{j+1} + y^{j+1}), & j < J.\n      \\end{cases}  \\label{eq:fassolution}\n\\end{equation}\nNote that $t^j$ satisfies $t^j \\ge \\iR(\\dots(\\iR(b^J))\\dots)$ by construction because $y^j \\in \\mathcal{D}^j$.  Though represented on a coarse level, $t^j$ has admissible point values relative to the fine bed $b^J$.\n\nLet $F^j$ represent the FE discretization of $F$ (Section \\ref{sec:fe}) on the $j$th level, and let $R: (\\mathcal{V}^{j+1})^* \\to (\\mathcal{V}^j)^*$ be the canonical restriction on functionals \\cite{GraeserKornhuber2009}.  The FAS coarse-level VI is\n\\begin{equation}\nF^j(t^j+y^j)[v^j-y^j] \\ge \\ell^j[v^j-y^j] \\quad \\text{for all } v^j \\in \\mathcal{D}^j. \\label{eq:fasequation}\n\\end{equation}\nwhere\n\\begin{equation}\n\\ell^j[v] = \\begin{cases} \\ip{a}{v}, & j=J \\\\\n                          F^j(t^j)[v] + R \\left(\\ell^{j+1} - F^{j+1}(t^{j+1}+y^{j+1})\\right)[v], & j < J. \\end{cases}  \\label{eq:fasell}\n\\end{equation}\nOn the one hand, all quantities in VI \\eqref{eq:fasequation} are represented on the $j$th level, without reference to finer-mesh data.  On the other hand, for $j<J$ the VI \\eqref{eq:fasequation} can be rearranged using \\eqref{eq:fasell} to a correction form like the FAS equation for PDEs (e.g.~\\cite[equation (5.3.12)]{Trottenbergetal2001}),\n\\begin{equation}\nF^j(t^j+y^j)[v^j-y^j] - F^j(t^j)[v^j-y^j] \\ge R \\left(\\ell^{j+1} - F^{j+1}(t^{j+1}+y^{j+1})\\right)[v^j-y^j], \\label{eq:fasequationtraditional}\n\\end{equation}\nfor all $v^j \\in \\mathcal{D}^j$.  In \\eqref{eq:fasequationtraditional} the functional on the left and right side should be smooth, thus explaining \\eqref{eq:fasequation}.  Following the solution of \\eqref{eq:fasequation} on all descending levels $j=J,\\dots,0$, in fact done by a smoother on each level, a V(1,0) cycle is completed and the new fine-mesh iterate is $s^J + y^J + \\dots + y^0$.\n\nThe above formulas suffice for a V(1,0) cycle, and represent the FAS extension of Algorithm 4.7 in \\cite{GraeserKornhuber2009}, and of the method of Tai \\cite{Tai2003}.  However, for better performance we note that on the ascending part of a V-cycle we can smooth in a less-constrained set, the larger set $\\mathcal{U}^j \\supset \\mathcal{D}^j$.  Regarding admissibility, the difference between descending and ascending in a V-cycle is that in the former case there are yet-to-be-computed corrections which we must force into small-enough sets $\\mathcal{D}^j$ so that their sum is still admissible.  When ascending we have already summed the coarser-level corrections so we can smooth the result in the larger, nested sets $\\mathcal{U}^j$ without destroying the admissibility of the yet-finer corrections to come.\n\nThe above ideas define the following MCDN V-cycle Pseudocode \\ref{pc:mcdn-vcycle}.  This algorithm calls a smoothers from Section \\ref{sec:smoothers} and it uses the canonical prolongation $P:\\mathcal{V}^j \\to \\mathcal{V}^{j+1}$.  The default settings correspond to a V(0,1) cycle which we have found to be most efficient in tests on the classical obstacle problem \\cite{Bueler2022}.  The returned value is a correction to the current iterate $s^J$.\n\n\\begin{pcode}[ht]\n\\begin{pseudo*}\n\\pr{mcdn-vcycle}(J,s^J,b^J,\\id{down}=0,\\id{coarse}=1,\\id{up}=1)\\text{:} \\\\+\n    $\\chi^J, \\,\\ell^J, \\,t^J = b^J - s^J, \\,\\ip{a}{\\cdot}, \\,s^J$ \\\\\n    for $j=J$ downto $j=1$ \\\\+\n      $\\chi^{j-1} = \\mR \\chi^j$ \\\\\n      $\\phi^j = \\chi^j - \\chi^{j-1}$ \\\\\n      $y^j = 0$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{down}}}(y^j,t^j,\\ell^j,\\phi^j)$ \\qquad \\qquad \\ct{in $\\mathcal{D}^j$} \\\\\n      $t^{j-1} = \\iR(t^j + y^j)$ \\\\\n      $\\ell^{j-1} = F^{j-1}(t^{j-1}) + R(\\ell^j - F^j(t^j+y^j))$ \\\\-\n    $y^0 = 0$ \\\\\n    $\\text{\\pr{smoother}}^{\\text{\\id{coarse}}}(y^0,t^0,\\ell^0,\\chi^0)$ \\qquad \\qquad \\ct{in $\\mathcal{U}^0$} \\\\\n    $z^0 = y^0$ \\\\\n    for $j=1$ to $j=J$ \\\\+\n      $z^j = P z^{j-1} + y^{j}$ \\\\\n      $\\text{\\pr{smoother}}^{\\text{\\id{up}}}(z^j,t^j,\\ell^j,\\chi^j)$ \\qquad \\qquad \\ct{in $\\mathcal{U}^j$} \\\\-\n    return $z^J$\n\\end{pseudo*}\n\\caption{MCDN V-cycle.}\n\\label{pc:mcdn-vcycle}\n\\end{pcode}\n\nTo our knowledge two aspects of this MCDN V-cycle are new:\n\\begin{enumerate}\n\\item While Tai \\cite{Tai2003} defines and proves the convergence of a nonlinear MCD method, the implementation of this method cannot achieve $O(m_J)$ time for each V-cycle in nonlinear cases because the method refers to the fine level for the residual evaluation on each coarser level.  Our FAS-type modification achieve $O(m_J)$ time per V-cycle when applied to a local nonlinear problem, for example in the SIA model application in \\cite{Bueler2022} in which the smoother is $O(m_j)$ on each level.  In our current Stokes case the smoother is nonlocal and $O(m_j)$ smoother time is not achieved.\n\\item Our V($\\alpha$,$\\beta$) cycles, with $\\alpha$ down-smoother and $\\beta$ up-smoother applications, are more efficient when $\\beta >0$ than the method proposed in \\cite{GraeserKornhuber2009} for $V(1,1)$ cycles because the smoothing occurs in a less-constrained set.\n\\end{enumerate}\n\nFinally we consider when iterated V-cycles have converged.  For any discrete obstacle $\\chi^j \\in \\mathcal{V}^j$, admissible iterate $z^j\\in \\{r^j \\ge \\chi^j\\} \\subset \\mathcal{V}^j$, and residual vector $r^j \\in (\\mathcal{V}^j)'$ let\n\\begin{equation}\n\\vertiii{r^j}_{(z^j,\\chi^j)} = \\left(\\sum_{z_i > \\chi_i} |r^j[\\psi_i^j]|^2 + \\sum_{z_i = \\chi_i} |\\min\\{r^j[\\psi_i^j],0\\}|^2\\right)^{1/2}, \\label{eq:cpnorm}\n\\end{equation}\nwhere $\\psi_i^j$ denotes a $j$th-level nodal basis function.  This defines a ``CP residual norm'' associated to the finite-dimensional complementarity problem $z^j \\ge \\chi^j$, $r^j(z^j) \\ge 0$, and $(z^j-\\chi^j) r^j(z^j) = 0$.  Note $z^j \\in \\mathcal{V}^j$ solves this CP if and only if $z^j$ is admissible and $\\vertiii{r^j(z^j)}_{(z^j,\\chi^j)}=0$.\n\nAs shown in Pseudocode \\ref{pc:mcdn-solver}, we iterate MCDN V-cycles until the CP residual norm is small according to either an absolute or a relative tolerance.\n\n\\begin{pcode}[ht]\n\\begin{pseudo*}\n\\pr{mcdn-solver}(J,s^J,b^J,\\id{atol}=10^{-20},\\id{rtol}=10^{-3},\\id{stol}=10^{-20},\\id{max}=100)\\text{:} \\\\+\n    $\\rho_0=\\vertiii{(a,\\cdot) - F^J(s^J)[\\cdot]}_{(s^J,b^J)}$ \\\\\n    for $k=1,\\dots,\\id{cyclemax}$ \\\\+\n        $z^J = \\pr{mcdn-vcycle}(J,s^J,b^J)$ \\\\\n        $s^J \\gets s^J + z^J$ \\\\\n        $\\rho_k=\\vertiii{(a,\\cdot) - F^J(s^J)[\\cdot]}_{(s^J,b^J)}$ \\\\\n        if $\\rho_k < \\id{atol}$ or $\\rho_k \\le \\id{rtol} \\, \\rho_0$ or $\\|z^J\\| \\le \\id{stol}$ \\\\+\n            break \\\\--\n\\end{pseudo*}\n\\caption{The SIGP is solved in-place by iterating V-cycles (Pseudocode \\ref{pc:mcdn-vcycle}) until the CP residual norm \\eqref{eq:cpnorm} is small.}\n\\label{pc:mcdn-solver}\n\\end{pcode}\n\n\n\\section{Performance models} \\label{sec:perfmodels}\n\nFIXME\n\n\n\\section{Results for steady geometry} \\label{sec:results}\n\nFIXME The computations in this section use the Python FE library Firedrake \\cite{Rathgeberetal2016}, which applies an embedded domain language \\cite{Alnaesetal2014} to convert weak forms into discrete equations which are solved in parallel using the PETSc \\cite{Balayetal2020} library.  Each time the smoother is applied the Glen-Stokes problem is solved, by Newton linearization and (parallel) direct solution of the Newton step equations, in order to evaluate the IDO $\\Phi(s)$.  To replace this non-scalable approach we propose in future work to apply existing geometric \\cite{BrownSmithAhmadia2013,IsaacStadlerGhattas2015} and algebraic \\cite{Tuminaroetal2016} multigrid strategies.\n\nFIXME convergence results; scaling results\n\n\n\\section{Multilevel methods for evolving geometry} \\label{sec:evolution}\n\nFIXME time-dependent runs\n\n\n\\section*{Acknowledgments}  Thanks to David Maxwell for discussions regarding the formulation of the model.\n\n\\small\n\n\\bigskip\n\\bibliography{msg}\n\\bibliographystyle{siam}\n\n\\appendix\n\n\\section{Glossary of acronyms} \\label{app:glossary}\n\n\\renewcommand{\\arraystretch}{1.1}\n\\begin{longtable}{l|l|l}\n\\caption{Glossary of acronyms used in this paper.}\n\\label{tab:acronyms} \\\\ % \\\\ REQUIRED HERE\n\\toprule\n\\textbf{Acronym} {\\Large$\\strut$} & \\textbf{Definition} & \\textbf{Reference} \\\\ \\hline\nCMB & climatic mass balance & Section \\ref{sec:stokesgeometry} \\\\\nFAS & full approximation scheme & Section \\ref{sec:mcdstokes} \\\\\nFE & finite element & Section \\ref{sec:fe} \\\\\nGS & Gauss-Seidel & Section \\ref{sec:smoothers} \\\\\nIDO & ice dynamics operator & Section \\ref{sec:weakido}, equation \\eqref{eq:ido} \\\\\nIIGP & implicit ice geometry problem & Section \\ref{sec:evolution} \\\\\nMCD & multilevel constraint decomposition & Section \\ref{sec:mcdstokes} \\\\\nMCDN & multilevel constraint decomposition (nonlinear) & Section \\ref{sec:mcdstokes}, Pseudocode \\ref{pc:mcdn-vcycle} \\\\\nNCP & nonlinear complementarity problem & Section \\ref{sec:stokesgeometry} \\\\\nPNGS & projected, nonlinear Gauss-Seidel (smoother) & Section \\ref{sec:smoothers}, Pseudocode \\ref{pc:pngsslow} \\\\\nPNJ & projected, nonlinear Jacobi (smoother) & Section \\ref{sec:smoothers}, Pseudocode \\ref{pc:pnj} \\\\\nSIA & shallow ice approximation & Section \\ref{sec:intro} \\\\\nSIGP & steady ice geometry problem & Section \\ref{sec:stokesgeometry}, equation \\eqref{eq:strongform} \\\\\nSKE & surface kinematical equation & Section \\ref{sec:stokesgeometry}, equation \\eqref{eq:ske} \\\\\nVI & variational inequality & Section \\ref{sec:weakido} \\\\\nWU & work units & Section \\ref{sec:mcdstokes} \\\\ % final \\\\ required\n\\bottomrule\n\\end{longtable}\n\n\\end{document}\n", "meta": {"hexsha": "6b9548ceb599777cc30bb0737978528271e0655a", "size": 64035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/msg.tex", "max_stars_repo_name": "bueler/multilevel-stokes-geometry", "max_stars_repo_head_hexsha": "a7e0703f7e9605c67d8fa6b0b026c545f8af305e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/msg.tex", "max_issues_repo_name": "bueler/multilevel-stokes-geometry", "max_issues_repo_head_hexsha": "a7e0703f7e9605c67d8fa6b0b026c545f8af305e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/msg.tex", "max_forks_repo_name": "bueler/multilevel-stokes-geometry", "max_forks_repo_head_hexsha": "a7e0703f7e9605c67d8fa6b0b026c545f8af305e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 90.4449152542, "max_line_length": 1156, "alphanum_fraction": 0.7153275552, "num_tokens": 20814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.405707859242893}}
{"text": "% !TeX root = ../main.tex\n\n\\begin{survey}\n\\label{cha:survey}\n\n\\title{\n  Bound Analysis : A Brief Overview\n}\n\n\\maketitle\n\nAutomatic methods for computing bounds on the resource consumption of programs are an active research field. Bound analysis, or complexity analysis, tells the potential worst-case scenario complexity of a program, and is thus useful for predicting performance. This literature review briefly documents some of the recent works on automated bound analysis. \n\n\\tableofcontents\n\n\\section{Introduction}\n\nBound analysis is a branch of program analysis which attempts to determine the \\textit{resource consumption} of a given program. The result is a symbolic formula over the input parameters of the program. Basically, it's the problem of deciding how many steps a Turing machine can take at most, given any input.\n\nThis is obviously an undecidable problem, since if it's decidable, we can use the decision procedure to decide the famous halting problem:\n\n\\begin{theorem}[Turing 1936\\cite{turing_computable_1937}, Halting Problem]\n  Given a Turing machine M and input word w, it is undecidable if M will halt on w.\n\\end{theorem}\n\nBound analysis nowadays is usually based upon \\textit{termination analysis}{\\cite{cook_proving_2011}}, which is the problem of deciding if a program always terminates on any input. Termination analysis is even not semi-decidable. In fact, it is neither RE nor co-RE.\n\nThe undecidability of this problem implies that, any sound method to bound analysis must be incomplete. That is, there is always an input on which the method cannot give a result. Current techniques often presume a special subset of program features that make the program class decidable (for termination), one of which is simple linear loop program. Even so, proof of a program to be terminating is not always directly appliable to bound analysis.\n\nThere are many automated bound analysis methods in the literature. We mainly focus on two methodologies in the following sections.\n\n\\section{Preliminary}\n\nWe briefly introduce some concepts here.\n\n\\begin{definition}[Transition System]\n  Formally, a {\\textbf{transition system}} is a pair $(S, R, I)$ where $S$ is a set of states and R is a relation of state transitions (i.e., a subset of $S \\times S$). A transition from state p to state q, i.e. $(p, q) \\in R$, is written as $R(p,q)$. $I$ is the set of initial states.\n\\end{definition}\n\nTransition system can be seen as the most low-level model we use. On the other hand, a program has higher abstraction via CFG:\n\n\\begin{definition}[Program]\n  A program is a CFG $(L, \\tau, l_0)$, where L is the set of program locations, $\\tau \\subseteq L \\times R \\times L$ is the transition relation, where $R \\subseteq S \\times S$, and $l_0$ is a distinguished initial location.\n  \n  A program state is $(l, s)$ where l is a location and s is a memory state.\n  \n  A computation is a sequence $(l_0, s_0), (l_1, s_1), \\ldots$ where for each i > 0, there is $(l_i, \\rho, l_{i + 1}) \\in \\tau$ and $\\rho (s_i, s_{i + 1})$.\n  \n  A program is said to be terminating if there is no infinite computation.\n\\end{definition}\n\nIf all the variables of a program are natural number, we can get a special case : the lossy VASS.\n\n\\begin{definition}[Lossy Vector Addition System with States]\n  A VASS is a program with a fixed set of variables $\\{ x_1, \\ldots, x_n \\}$. The edge is denoted as $x' \\leqslant x + d$ with $d \\in \\mathbb{N}^n$.\n\\end{definition}\n\nNote that variables in VASS are natural numbers, so there is a lower bound 0 for them.\n\n\\begin{definition}[Loop]\n  Let G = (V, E) be a directed graph with a unique entrypoint such that all nodes are reachable from the entry point. A node a dominates a node b, if every path from entry to b includes a. An edge l1 $\\rightarrow$ l2 is a back edge, if l2 dominates l1 . G is reducible, if G becomes acyclic after removing all backedges. A node is a loop header, if it is the target of a back edge. The (natural) loop of a loop header h in a reducible graph is the maximal set of nodes L such that for all x $\\in$ L (1) h dominates x and (2) there is a back edge from some node n to h such that there is a path from x to node n that does not contain h.\n  \n  A loop-path $\\pi$ is a simple cyclic path, which starts and ends at some loop header l, and visits only locations inside the natural loop of l.\n\\end{definition}\n\n\\begin{definition}[Inductive Invariants]\n  An invariant map Q maps program locations l to state formulas $I_l$.\n  \n  For a program C, Q is inductive if for any $(l, l', \\rho) \\in \\tau_C$, the following holds: \n  \n  \\[ \\forall s, s', I_l (s) \\wedge \\rho (s, s') \\rightarrow I_{l'} (s') \\]\n  \n\\end{definition}\n\n\\section{Control Flow Abstraction}\n\nThe tool \\textit{Loopus} {\\cite{sinn_simple_2014, sinn_complexity_2017, sinn_difference_2015}} utilizes an automated method of bound analysis. The algorithm is composed of 4 steps:\n\n\\begin{enumerate}\n  \\item Abstracting a program into a VASS\n  \n  \\item Control Flow Abstraction, which 'flatten' the VASS and merge the loops\n  \n  \\item Ranking function generation, which proves the VASS to be terminating\n  \n  \\item Bound Analysis, which computes a bound for every transition.\n\\end{enumerate}\n\nThe first step is neglected here. The second step, \\textit{control flow abstraction}, basically analysizes the program and find all the loop paths. It then transform the original VASS into a singleton state transition system with many transtion on it. The algorithm is as follows:\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{survey1.pdf}\n    \\caption{control flow abstraction}\n\\end{figure}\n\nNow we get a transition system with a single state where each transition stands for a loop path. In {\\cite{sinn_simple_2014}}, the transition system is then analysized and a ranking function is generated. The ranking function is lexicographic, and each component of the ranking function is a variable among $x_1, \\ldots, x_n$. In general, a ranking function could be any valid expression, thus it's possible that a single-variable ranking function does not exist. However inexpressive, this generation algorithm is relatively complete.\n\nThe last step of the analysis gives the actual bound. Suppose the transtion $\\rho$ has the ranking function component x, then $\\rho$ can be executed $\\tmop{Init} (x)$ times if no other transitions increase x. So we have to take\nother transitions into account. The algorithm is as follows:\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=0.8\\linewidth]{survey2.pdf}\n    \\caption{algorithm to compute the bound}\n\\end{figure}\n\nNow that a bound for each transition is obtained, we simply add them to get\nthe final bound.\n\n\\section{Compute WCCC using Ehrhart polynomials}\n\nThe tool \\textit{Rank}{\\cite{alias_multi-dimensional_2010}} gives a novel way of computing \\textit{worst-case computational complexity}(WCCC). The method also generate (lexicographic) ranking function first. However, different to the method mentioned above, the ranking function can be any affine expression. Besides, since no control flow abstraction are used, the CFG is general. Thus every location in the graph is assigned a ranking function, in other words, the ranking function is inductive.\n\nConsider any trace $(l_0, x_0), \\ldots, (l_p, x_p)$, by definition of ranking function, we have $r (l_i, x_i) < r (l_{i + 1}, x_{i + 1})$, thus, every states in the trace must be distinct.\n\nHence the length of a trace is bounded by:\n\n\\[ \\tmop{WCCC} \\leqslant \\# \\bigcup_k r (k, P_k) \\leqslant \\sum_k \\#r (k, P_k)\n\\]\n\nThe goal here is to compute $r (k, P_k)$ for each location k, where $P_k$ is the inductive invariant at location k. Basically, we find the number of points in the intersection of $\\mathbb{Z}^n$ and the image of a polyhedron.\n\nThe authors use Smith normal form and Ehrhart polynomials to compute this ordinal. Suppose $r (k, x) = R x + r$, we compute $R = U S V$, where U and V are unimodular and $S = \\left[ \\begin{array}{cc}\n  D & 0\\\\\n  0 & 0\n\\end{array} \\right]$ where D is diagonal positive matrix of the same rank as R. Then $\\#V$ is a slight overapproximation of $\\#r (k, P_k)$. The number of integer vector in V is obtained using Ehrhart polynomials.\n\n\\bibliographystyle{unsrtnat}\n\\bibliography{ref/library}\n\n\\end{survey}", "meta": {"hexsha": "3fff20940b3869fa950355d225f724aaa844fd65", "size": 8279, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "data/appendix-survey.tex", "max_stars_repo_name": "linusboyle/bound-validate", "max_stars_repo_head_hexsha": "826a7397ba8b3168225ca5dd81ee171e3767b2f3", "max_stars_repo_licenses": ["LPPL-1.3c"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "data/appendix-survey.tex", "max_issues_repo_name": "linusboyle/bound-validate", "max_issues_repo_head_hexsha": "826a7397ba8b3168225ca5dd81ee171e3767b2f3", "max_issues_repo_licenses": ["LPPL-1.3c"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "data/appendix-survey.tex", "max_forks_repo_name": "linusboyle/bound-validate", "max_forks_repo_head_hexsha": "826a7397ba8b3168225ca5dd81ee171e3767b2f3", "max_forks_repo_licenses": ["LPPL-1.3c"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.7196969697, "max_line_length": 635, "alphanum_fraction": 0.7522647663, "num_tokens": 2143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.40570785204945337}}
{"text": "\\section{Reduction Method and Challenges} \\label{gua:sec:paramsynt}\n \nWe show how to use existing cutoff results of Emerson and Kahlon~\\cite{Emerson00} to reduce the PMCP to a standard model checking problem,\nand parameterized template synthesis to template synthesis.\nWe note the limitations of the existing results that are crucial in the context of synthesis.\n\n\\subsection*{Reduction by Cutoffs} \\label{page:gua:def:cutoff}\n\n\\parbf{Cutoffs}\nA \\emph{cutoff} for a system type $(\\templateI,\\templateII)$ and a specification $\\spec$ is a number $c \\in \\bbN$ such that:\n\\[ \n\\forall n \\ge c: \\left( \\cutoffsys \\models \\spec ~~\\Iff~~ \\largesys \\models \\spec \\right).\n\\]\nSimilarly,\na \\emph{cutoff for deadlock detection} for a system type $(\\templateI,\\templateII)$ is a number $c \\in \\bbN$ such that:\n\\[ \n\\forall n \\ge c: \\left( \\cutoffsys \\textit{ has a deadlock} ~~\\Iff~~ \\largesys \\textit{ has a deadlock}\\right).\n\\]\nHere, ``has a deadlock'' means ``there is a locally or globally deadlocked run''.\n\nFor the systems and specifications presented in this work, cutoffs can be computed from \nthe size of the process template $B$ and the number $k$ of copies of $B$ \nmentioned in the specification, and are given as expressions like \n$\\card{B}+k+1$.\n\n\\begin{remark}\\label{re:EK_cutoffs}\nOur definition of a cutoff is different from that of Emerson and Kahlon~\\cite{Emerson00}, and instead similar to, e.g., Emerson and Namjoshi~\\cite{Emerso03}. The reason is that we want the following property to hold for any $(A,B)$ and $\\Phi$: \n\\begin{quote}\nif $n_0$ is the smallest number such that ~$\\forall n \\geq n_0:\\ \\largesys \\models \\Phi$,\nthen any $c<n_0$ is not a cutoff, any $c\\geq n_0$ is a cutoff.\n\\end{quote}\nWe call $n_0$ the \\emph{tight} cutoff.\nThe definition of Emerson and Kahlon~\\cite[page 2]{Emerson00} requires that\n$\\forall{n\\leq c}. \\largesys \\models \\Phi$\nif and only if\n$\\forall{n \\geq 1}: \\largesys \\models \\Phi$, and thus allows stating $c<n_0$ as a cutoff if $\\Phi$ does not hold for all $n$.\n\\end{remark}\n\n\\parbf{Parameterized synthesis}\nWe encourage the reader to revisit Chapter~\\ref{defs:bounded_synthesis} on page~\\pageref{page:defs:bounded_synthesis}\nto recall how bounded synthesis works in the case of non-distributed systems.\nNow we adapt the procedure to guarded parameterized systems.\nIn parameterized model checking\na cutoff allows us to check whether any ``big'' system satisfies the specification\nby checking it in the cutoff system.\nA similar reduction applies to the parameterized synthesis problem~\\cite{JB14}.\nFor guarded protocols, we obtain the following \n\\emph{semi-decision procedure for parameterized synthesis}\\ak{is it decidable?}:\n\\begin{enumerate}\n  \\item[0.] set initial bound $(\\bound_A,\\bound_B)$ on the size of the process templates;\n  \\item[1.] determine the cutoff for $(\\bound_A,\\bound_B)$ and $\\spec$;\n  \\item[2.] solve the bounded template synthesis problem for cutoff, size bound, and $\\spec$;\n  \\item[3.] if successful, return $(A,B)$, else increase $(\\bound_A,\\bound_B)$ and goto (1).\n\\end{enumerate}\nThis procedure was implemented inside our parameterized synthesis tool PARTY~\\cite{party}\nby Simon Au{\\ss}erlechner as a part of his Master Thesis~\\cite{SimonThesis}.\n\n\\subsection*{Existing Cutoff Results}\nEmerson and Kahlon~\\cite{Emerson00} have shown:\n\n\\begin{theorem}[Disjunctive Cutoff Theorem] \\label{thm:disj-cutoff-pairs}\n    For closed disjunctive systems $A{\\parallel}B^n$,\n    $\\card{B}+2$ is a cutoff {$^{(\\dagger)}$} for formulas of the\n    form $\\A h(A,B^{(1)})$ and $\\E h(A,B^{(1)})$, and for global\n    deadlock detection.\n\\end{theorem}\n \n\\begin{theorem}[Conjunctive Cutoff Theorem] \\label{thm:conj-cutoff}\n    For closed conjunctive systems ${A{\\parallel}B^n}$,\n    $2\\card{B}$ is a cutoff {$^{(\\dagger)}$} for formulas of the\n    form $\\A h(A)$ and $\\E h(A)$, and for global deadlock detection.\n    For formulas of the form $\\A h(B^{(1)})$ and $\\E h(B^{(1)})$,\n    $2\\card{B}+1$ is a cutoff.\n\\end{theorem}\n\\noindent\nIn the above theorems,\n$h(A)$ (resp.\\ $h(B^{(1)})$) means that the formula talks about the $A$-process only (resp.\\ $B_1$).\n\n\\begin{remark} ${(\\dagger)}$\nNote that Emerson and Kahlon \\cite{Emerson00} proved these results for\na different definition of a cutoff (see Remark \\ref{re:EK_cutoffs}).  \nTheir results also hold for our definition, except possibly for\nglobal deadlocks.  For the latter case to hold with the new cutoff definition, one \nalso needs to prove the direction ``global deadlock in the cutoff system implies global\ndeadlock in a large system'' (later called Monotonicity Lemma).\nIn Sections~\\ref{gua:sec:proofs-disj-deadlock-unfair} and \\ref{gua:sec:proofs-disj-deadlock-fair},\nSections~\\ref{gua:sec:proofs-conj-deadlock-unfair} and \\ref{gua:sec:proofs-conj-deadlock-fair},\nwe prove these lemmas for the case of general deadlock (global \\emph{or} local).\n\\end{remark}\n\n\\subsection*{Challenge: Open Systems}\nFor any open system $S$ there exists a closed system $S'$ such that $\nS$ and $S'$ cannot be distinguished by $\\LTL$ specifications \n(e.g., see Manna and Pnueli~\\cite{Manna92}). Thus, one approach to PMC for open \nsystems is to use a translation between open and closed systems, and then use the \nexisting cutoff results for closed systems.\n\n%While such an approach works in theory, it is not feasible when cutoffs \n%depend on the size of process templates: in this case the conversion not only results in a \n%blowup of the local state space of each process, but also in the number of \n%processes that we need to consider. \nWhile such an approach works in theory, it might not be feasible in practice:\nsince cutoffs depend on the size of the process templates,\nand the translation blows up the process template,\nit also blows up the cutoffs.\nThus, cutoffs that directly support open systems are important.\n\n\n\\subsection*{Challenge: Liveness and Deadlocks under Fairness}\nWe are interested in cutoff results that support liveness properties.\nConsider a specification $\\Phi=h(A,B^{(k)})$.\nIn general, we would like to consider only runs where all processes move infinitely often,\ni.e.,\nuse the unconditional fairness assumption $\\forall{p}. \\GF \\sched_p$ and thus have $\\A_{uncond}\\Phi$.\nHowever, this would mean that we accept all systems that always go into a local deadlock,\nsince then the assumption is violated (i.e., there will be no unconditionally-fair runs).\nThis is especially undesirable in synthesis, because the synthesizer often tries to violate the assumptions to satisfy the specification.\nTo avoid this,\nwe require the absence of local deadlocks.\nBut local deadlocks may appear due to unfair scheduling.\nTherefore we require the absence of local deadlocks under the strong fairness assumption,\ni.e., we require satisfaction of the formula\n$\\A_{strong} \\spec_{\\neg dead}=\\big(\\forall{p}. (\\GF \\enabled_p \\impl \\GF \\sched_p)\\big) \\impl \\forall{p}. \\GF\\enabled_p$.\nThis formula can be roughly read as ``the absence of local deadlocks under fair scheduling''.\nSince absence of global deadlocks and absence of local deadlocks under strong fairness imply unconditional fairness,\nwe can safely use $\\A_{uncond}\\Phi$.\n\n%In these systems, processes may be disabled depending on their input and the global state. \\change{Thus, strong fairness $\\forall{p}. (\\GF \\enabled_p \\impl \\GF \\sched_p)$ is an insufficient assumption, since the environment can easily violate liveness properties by choosing inputs and scheduling such that some process is only enabled finitely often.}\n%{Thus, strong fairness $\\forall{p}. (\\GF \\enabled_p \\impl \\GF \\sched_p)$ is an\n%insufficient assumption, since the environment can easily violate a process's liveness\n%property by choosing inputs and scheduling such that the process never moves \n%after some moment.}\n%%\n%Moreover, using the unconditional fairness assumption $\\forall{p}. \\GF \\sched_p$\n%\\remove{for the complete specification} is also undesirable, since then we would accept all systems that always go into a local deadlock. This is especially undesirable in synthesis.\n%To exclude this case, we require absence of local deadlocks under the strong fairness assumption. \n\nIn summary, for a parameterized specification $\\spec$, we consider satisfaction of\n\\[\n\\begin{array}{lllll}\n\\textit{``all runs are infinite''} &~~\\land~~& \\A_{strong} \\spec_{\\neg dead} & ~~\\land~~ & \\A_{uncond} \\spec.\n\\end{array}\n\\]\n%\nThis is equivalent to $\\textit{``all runs are infinite''} \\land \\A_{strong} (\\spec_{\\neg dead} \\,\\land\\, \\spec)$, but by considering the form above we can separate the tasks of deadlock detection and of model checking $\\LTLmX$-properties, and obtain modular cutoffs. \n(The phrase ``all runs are infinite'' is another way of saying ``all runs have no global deadlocks''.)\n\n%%%In the following, we present cutoffs for problems of the forms \n%%%(i) $\\A_{uncond} \\spec$ and\n%%%(ii) $\\E_{strong} \\spec_{dead} \\lor \\textit{``some run is finite''}$\n%%%(and the variants of (i) with $\\E$ path quantifier).\n%%%%, as well as for the detection of global deadlocks.\n%%%% AK: the previous version reads like we provide cutoffs for three problems -- we have only two\n", "meta": {"hexsha": "4b220b93e4f8261eb056bf5b1cb2cf58b077539a", "size": 9114, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/guarded-systems/reduction-cutoff.tex", "max_stars_repo_name": "5nizza/phd-thesis", "max_stars_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/guarded-systems/reduction-cutoff.tex", "max_issues_repo_name": "5nizza/phd-thesis", "max_issues_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/guarded-systems/reduction-cutoff.tex", "max_forks_repo_name": "5nizza/phd-thesis", "max_forks_repo_head_hexsha": "74a7a4c6ed06aa2894d2ba05f417f5f812730b78", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.1818181818, "max_line_length": 353, "alphanum_fraction": 0.7468729427, "num_tokens": 2440, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.40560212622522623}}
{"text": "%++++++++++++++++++++++++++++++++++++++++\n% Don't modify this section unless you know what you're doing!\n\\documentclass[letterpaper,11pt]{article}\n\\usepackage{natbib}\n\\bibliographystyle{unsrtnat}\n\\usepackage{tabularx} % extra features for tabular environment\n\\usepackage{amsmath}  % improve math presentation\n\\usepackage{graphicx} % takes care of graphic including machinery\n\\usepackage{listings}\n\\usepackage{braket}\n\\usepackage[margin=1in,letterpaper]{geometry} % decreases margins\n%\\usepackage{cite} % takes care of citations\n\\usepackage[final]{hyperref} % adds hyper links inside the generated pdf file\n\\hypersetup{\n\tcolorlinks=true,       % false: boxed links; true: colored links\n\tlinkcolor=blue,        % color of internal links\n\tcitecolor=blue,        % color of links to bibliography\n\tfilecolor=magenta,     % color of file links\n\turlcolor=blue         \n}\n%++++++++++++++++++++++++++++++++++++++++\n\n\\usepackage[\nbackend=biber,\nstyle=numeric,\nsorting=none\n]{biblatex}\n\n\\addbibresource{bibliography.bib}\n\n\\begin{document}\n\n\\title{Quantum Machine Learning Project}\n\\maketitle\n\n\nFor this project, you will perform quantum machine learning on the Scikit learn breast cancer data set. The data can be obtained the following way\n\\begin{lstlisting}[language=Python]\nfrom sklearn.datasets import load_breast_cancer\n\ndata = load_breast_cancer()\nx = data.data #features\ny = data.target #targets\n\n\\end{lstlisting}\nx is the feature matrix and y are the targets.\n\n\\section*{a) Encoding the Data Into a Quantum State}\nFor this task you will consider a simple way of encoding a randomly generated data set sample into a quantum state:\n\n\\begin{lstlisting}[language=Python]\nimport qiskit as qk\nimport numpy as np\nnp.random.seed(42)\n\np = 2 #number of features\ndata_register = qk.QuantumRegister(p)\nclassical_register = qk.ClassicalRegister(1)\n\ncircuit = qk.QuantumCircuit(data_register, classical_register) \n\nsample = np.random.uniform(size=p)\ntarget = np.random.uniform(size=1)\n\nfor feature_idx in range(p):\n    circuit.ry(2*np.pi*sample[feature_idx],data_register[feature_idx])\n\nprint(circuit)\n\\end{lstlisting}\nThe above code shows how a randomly generated data sample of $p=2$ features are encoded into a quantum state on two qubits utilizing Qiskit. Each feature is encoded into a respective qubit utilizing a $R_y(\\theta)$ gate. The features are scaled with $2\\pi$ to represent rotation angles (the $R_y(\\theta)$ gate performs a rotation). The classical register will be used later for storing the measured value of the circuit.  print(circuit) can be utilized at any point to see what the circuit looks like.\n\n\\bigskip\n\nYour task is to get familiar with the functionality utilized in the above example and implement your own function to encode $p$ of the first features in the breast cancer data set to a quantum state.\n\n\\section*{b) Processing the Encoded Data with Parameterized Gates}\nAfter the quantum state has been encoded with the information of a data set sample, one needs extend the circuit with operations that process the state in a way that allows us to infer the target data. This can be done by introducing quantum gates that are dependant on learnable parameters $\\boldsymbol{\\theta}$. We will do this in a similar fashion as for the encoding of the features:\n\n\\begin{lstlisting}[language=Python]\nn_params = 4\ntheta = 2*np.pi*np.random.uniform(size=n_params)\n\ncircuit.rx(theta[0],data_register[0])\ncircuit.ry(theta[1],data_register[1])\ncircuit.cx(data_register[0],data_register[1])\ncircuit.ry(theta[2],data_register[0])\ncircuit.rx(theta[3],data_register[1])\n\nprint(circuit)\n\\end{lstlisting}\nThe above parameterization of the quantum state is what we will refer to as the 'ansatz'. Your task is again to familiarize yourself with the functionality utilized in the above example and implement your own ansatz to be utilized together with the $p$ first features of the breast cancer data set. The number of learnable parameters 'theta' should be arbitrary.\n\n\\section*{c) Measuring the Quantum State and Making Inference}\nThe next step is to generate a prediction from our quantum machine learning model. This is done by performing a measurement on the quantum state:\n\\begin{lstlisting}[language=Python]\ncircuit.measure(data_register[-1],classical_register[0])\nshots=1000\n\njob = qk.execute(circuit,\n                backend=qk.Aer.get_backend('qasm_simulator'),\n                shots=shots,\n                seed_simulator=42\n                )\nresults = job.result()\nresults = results.get_counts(circuit)\n\nprediction = 0\nfor key,value in results.items():\n    if key == '1':\n        prediction += value\nprediction/=shots\nprint('Prediction:',prediction,'Target:',target[0])\n\\end{lstlisting}\n\\begin{verbatim}\n    Prediction: 0.285 Target: 0.7319939418114051\n\\end{verbatim}\nIn the above example, we are first applying a measurement operation on the final qubit in the circuit, and we are interpreting our prediction as the probability that this qubit is in the $\\ket{1}$ state. Make sure all the steps in the example are understood.\n\nImplement your own function that generates a prediction by measuring one of the qubits.\n\n\\section*{d) Putting it all together}\nNow it is time to put together all of the above steps. Ideally, you should make a class or a function that given a feature matrix of $n$ samples and an arbitrary number of model parameters, returns a vector of $n$ outputs. For example:\n\\begin{lstlisting}[language=Python]\nn = 100 #number of samples\np = 10 #number of features\ntheta = np.random.uniform(size=20) #array of model parameters\nX = np.random.uniform(size=(n,p)) #design matrix\ny_pred = model(X,theta) #prediction, shape (n)\n\\end{lstlisting}\n\n\\bigskip\n\nWe will now deal with how to train the model:\n\n\\section*{e) Parameter Shift-Rule and Calculating the Analytical Gradient}\nSince the model with random initial parameters is no good for inference, we need to optimize the parameters in order to yield good results, as is the usual with machine learning. \n\nSince we are dealing with classification, we will use cross-entropy as the loss function\n\n\\begin{equation*}\n    L = -\\sum_{i=1}^{n}{y_i \\ln{f(x_i;\\boldsymbol{\\theta})}},\n\\end{equation*}\nwhere $y_i$ are the target labels, and $f(\\boldsymbol{x}_i;\\boldsymbol{\\theta})$ is the output of our model for a given sample $\\boldsymbol{x}_i$ and parameterization $\\boldsymbol{\\theta})$. We calculate the gradiant by taking the derivative of the loss with respect to the parameters\n\n\\begin{equation*}\n    \\frac{\\partial}{\\partial \\boldsymbol{\\theta}_k}L = \\sum_{i=1}^{n}{\\frac{f_i - y_i}{f_i(1 - f_i)}} \\frac{\\partial}{\\partial \\boldsymbol{\\theta}_k}f_i,\n\\end{equation*}\nwhere $f_i = f(x_i;\\boldsymbol{\\theta})$ for clarity. The only term we do not know how to calculate is $\\frac{\\partial}{\\partial \\boldsymbol{\\theta}_k}f(x_i;\\boldsymbol{\\theta})$, but it turns out there is a simple trick to do this, the so-called parameter shift-rule \\cite{ParameterShift}. To calculate the derivative of the model output, we need to evaluate the model twice with the respective parameter shifted by a value $\\frac{\\pi}{2}$ up and down. The two resulting outputs are then put together to yield the derivative\n\n\n\n\n\\begin{equation*}\n    \\frac{\\partial f(x_i; \\theta_1, \\theta_2, \\dots, \\theta_k)}{\\partial \\theta_j}  = \\frac{f(x_i; \\theta_1, \\theta_2, \\dots, \\theta_j + \\pi /2, \\dots, \\theta_k) -f(x_i; \\theta_1, \\theta_2, \\dots, \\theta_j - \\pi /2, \\dots, \\theta_k)}{2}\n\\end{equation*}\n\nTrain your model by utilizing the Parameter Shift-Rule and some gradient descent algorithm. Compare your results with for example logistic regression.\n\n\n\\section*{f) Adding Variations on the Data Encoding and Ansatz}\nChange the gates utilized for the encoding of the data samples and also make changes to the parameterized ansatz. Train these new models on the breast cancer data set. How do they compare?\n\n\n\\newpage \n\n\\printbibliography\n\n\\end{document}\n", "meta": {"hexsha": "e84a0bbd3513ae878bb09246857abf6b9bf17cd6", "size": 7893, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/Projects/2021/Project2/qml/main.tex", "max_stars_repo_name": "Schoyen/ComputationalPhysics2", "max_stars_repo_head_hexsha": "9cf10ffb2557cc73c4e6bab060d53690ee39426f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 87, "max_stars_repo_stars_event_min_datetime": "2015-01-21T08:29:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T07:11:53.000Z", "max_issues_repo_path": "doc/src/Projects/2021/Project2/qml/main.tex", "max_issues_repo_name": "Schoyen/ComputationalPhysics2", "max_issues_repo_head_hexsha": "9cf10ffb2557cc73c4e6bab060d53690ee39426f", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-01-18T10:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T13:15:42.000Z", "max_forks_repo_path": "doc/src/Projects/2021/Project2/qml/main.tex", "max_forks_repo_name": "Schoyen/ComputationalPhysics2", "max_forks_repo_head_hexsha": "9cf10ffb2557cc73c4e6bab060d53690ee39426f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 54, "max_forks_repo_forks_event_min_datetime": "2015-02-09T10:02:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T10:44:14.000Z", "avg_line_length": 46.7041420118, "max_line_length": 525, "alphanum_fraction": 0.7530723426, "num_tokens": 1988, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.405586054970079}}
{"text": "\n\\chapter{Symbolic notation}\n\\label{app.notation}\n\n\\section{Alternative nomenclature}\n\n\\paragraph{Truth-functional logic.} TFL goes by other names. Sometimes it is called \\emph{sentential logic}, because this branch of logic deals fundamentally with sentences. Sometimes it is called \\emph{propositional logic} because it might also be thought to deal fundamentally with propositions. We have used with \\emph{truth-functional logic} to emphasize that it deals only with assignments of truth and falsity to sentences and that its connectives are all truth-functional.\n\n\\paragraph{Formulas.} In \\S\\ref{s:TFLSentences}, we defined \\emph{sentences} of TFL. These are also sometimes called `formulas' (or `well-formed formulas') since in TFL there is no distinction between a formula and a sentence.\n\n\\paragraph{Valuations.} Some texts call valuations \\emph{truth-assignments} or \\emph{truth-value assignments}.\n\n\n\\section{Alternative symbols}\nIn the history of formal logic, different symbols have been used at different times and by different authors. Often, authors were forced to use notation that their printers could typeset. This appendix presents some common symbols, so that you can recognize them if you encounter them in an article or in another book.\n\n\\paragraph{Negation.} Two commonly used symbols are the \\emph{hoe}, `$\\neg$', and the \\emph{swung dash} or \\emph{tilda}, `${\\sim}$.' In some more advanced formal systems it is necessary to distinguish between two kinds of negation; the distinction is sometimes represented by using both `$\\neg$' and `${\\sim}$'. Older texts sometimes indicate negation by a line over the formula being negated, e.g., $\\overline{A \\eand B}$. \n\n\\paragraph{Disjunction.} The symbol `$\\vee$' is typically used to symbolize inclusive disjunction. One etymology is from the Latin word `vel', meaning `or'.%In some systems, disjunction is written as addition.\n\n\\begin{table*}\\centering\\sffamily\\footnotesize\n\\ra{1.25}\n\\begin{tabular}{@{}l l@{}}\\toprule\n\\textth{Symbols of formal logic} & \\\\\\midrule\nnegation & $\\neg$, ${\\sim}$\\\\\nconjunction & $\\wedge$, $\\&$, {\\scriptsize\\textbullet}\\\\\ndisjunction & $\\vee$\\\\\nconditional & $\\rightarrow$, $\\supset$\\\\\nbiconditional & $\\leftrightarrow$, $\\equiv$\\\\\n\\bottomrule\n\\end{tabular}\n\\caption{}\\label{symbols-all}\n\\end{table*}\n\n\\paragraph{Conjunction.}\nConjunction is often symbolized with the \\emph{ampersand}, `{\\&}'. The ampersand is a decorative form of the Latin word `et', which means `and'.  (Its etymology still lingers in certain fonts, particularly in italic fonts; thus an italic ampersand might appear as `\\emph{\\&}'.) This symbol is commonly used in natural English writing (e.g.  `Smith \\& Sons'), and so even though it is a natural choice, many logicians use a different symbol to avoid confusion between the object and metalanguage---as a symbol in a formal system, the ampersand is not the English word `\\&'. The most common choice now is `$\\wedge$', which is a counterpart to the symbol used for disjunction. Sometimes a single dot, `{\\scriptsize\\textbullet}', is used. In some older texts, there is no symbol for conjunction at all; `$A$ and $B$' is simply written `$AB$'.\n\n\\paragraph{Conditional.} There are two common symbols for the conditional (which can also be called the \\textit{material conditional}): the \\emph{arrow}, `$\\rightarrow$', and the \\emph{hook}, `$\\supset$'.\n\n\\paragraph{Biconditional.} The \\emph{double-headed arrow}, `$\\leftrightarrow$', is used in systems that use the arrow to represent the biconditional. Systems that use the hook for the conditional typically use the \\emph{triple bar}, `$\\equiv$', for the biconditional.\n\n\n\n%\n%\n%\n%\\section*{Polish notation}\n%\n%This section briefly discusses sentential logic in Polish notation, a system of notation introduced in the late 1920s by the Polish logician Jan {\\L}ukasiewicz.\n%\n%Lower case letters are used as sentence letters. The capital letter $N$ is used for negation. $A$ is used for disjunction, $K$ for conjunction, $C$ for the conditional, $E$ for the biconditional. (`A' is for alternation, another name for logical disjunction. `E' is for equivalence.)\n%%\\marginpar{\n%%\\begin{tabular}{cc}\n%%notation & Polish\\\\\n%%of TFL & notation\\\\\n%%\\enot & $N$\\\\\n%%\\eand & $K$\\\\\n%%\\eor & $A$\\\\\n%%\\eif & $C$\\\\\n%%\\eiff & $E$\n%%\\end{tabular}\n%%}\n%\n%In Polish notation, a binary connective is written \\emph{before} the two sentences that it connects. For example, the sentence $A\\eand B$ of TFL would be written $Kab$ in Polish notation.\n%\n%The sentences $\\enot A\\eif B$ and $\\enot (A\\eif B)$ are very different; the main logical operator of the first is the conditional, but the main connective of the second is negation. In TFL, we show this by putting parentheses around the conditional in the second sentence. In Polish notation, parentheses are never required. The left-most connective is always the main connective. The first sentence would simply be written $CNab$ and the second $NCab$.\n%\n%This feature of Polish notation means that it is possible to evaluate sentences simply by working through the symbols from right to left. If you were constructing a truth table for $NKab$, for example, you would first consider the truth-values assigned to $b$ and $a$, then consider their conjunction, and then negate the result. The general rule for what to evaluate next in TFL is not nearly so simple. In TFL, the truth table for $\\enot(A\\eand B)$ requires looking at $A$ and $B$, then looking in the middle of the sentence at the conjunction, and then at the beginning of the sentence at the negation. Because the order of operations can be specified more mechanically in Polish notation, variants of Polish notation are used as the internal structure for many computer programming languages.\n%\n", "meta": {"hexsha": "739903220fa85f5131d46e7a5a8b567ccd342964", "size": 5754, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "forallx-msu-part5--notation.tex", "max_stars_repo_name": "loighic/forallx-msu", "max_stars_repo_head_hexsha": "d3ee7928df9679c938298571a51e5505ea21920a", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "forallx-msu-part5--notation.tex", "max_issues_repo_name": "loighic/forallx-msu", "max_issues_repo_head_hexsha": "d3ee7928df9679c938298571a51e5505ea21920a", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "forallx-msu-part5--notation.tex", "max_forks_repo_name": "loighic/forallx-msu", "max_forks_repo_head_hexsha": "d3ee7928df9679c938298571a51e5505ea21920a", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 82.2, "max_line_length": 838, "alphanum_fraction": 0.7553006604, "num_tokens": 1459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.4055487223939977}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{graphicx,caption}\n\\graphicspath{ {./images/} }\n\\usepackage{float}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage[unicode]{hyperref}\n\\usepackage{amsmath}\n\\usepackage[shortlabels]{enumitem}\n\n\\title{Homework 3 - Theory}\n\\author{Dainese Fabio, 857661}\n\\date{March 22, 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Exercise 1}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{1.png}\n        \\caption{Graph \\(G=(V,E)\\)}\n        \\label{fig:figure-1}\n    \\end{figure}\n    \n    \\begin{enumerate}[a)] \n        \\item The \\textit{clique number} of \\(G\\) is \\(w(G) = 3\\). This also means that the \\textit{chromatic number} (\\(c(G)\\)) has a lower bound of:\n        \\begin{align*}\n            c(G) &\\geq w(G) \\\\\n            c(G) &\\geq 3\n        \\end{align*}\n        \n        \\item The \\textit{max degree} of \\(G\\) is \\(\\triangle(G) = max\\{d(V) | v \\in V\\} = 4\\). This also means that the \\textit{chromatic number} (\\(c(G)\\)) has a upper bound of:\n        \\begin{align*}\n            c(G) &\\leq \\triangle(G)+1 \\\\\n            c(G) &\\leq 5\n        \\end{align*}\n    \\end{enumerate}\n    \n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.5\\textwidth]{2.png}\n        \\caption{Graph \\(G=(V,E)\\)}\n        \\label{fig:figure-2}\n    \\end{figure}\n    \n    \\begin{enumerate}[c)]\n        \\item The coloring illustrated in the 'Figure \\ref{fig:figure-2}' is not a proper 3-colouring of \\(G\\), since the vertices \\(v_{2}\\) and \\(v_{4}\\) are adjacent and with the same color.\n        \n        \\item The partitions of the vertex set induced by the provided colouring are:\n        \\begin{align*}\n            V_{black} &= \\{v_{2},v_{4},v_{5},v_{9},v_{11},v_{15},\\} \\\\\n            V_{red} &= \\{v_{1},v_{3},v_{7},v_{8},v_{13},v_{14},\\} \\\\\n            V_{blue} &= \\{v_{6},v_{10},v_{12},v_{16},\\} \\\\\n        \\end{align*}\n    \\end{enumerate}\n    \n\\section{Exercise 2}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=\\textwidth]{3.png}\n        \\caption{Multi-layer network}\n        \\label{fig:figure-3}\n    \\end{figure}\n    The multi-layer network pictured in the 'Figure \\ref{fig:figure-3}' has its vertex and edge sets equals to:\n    \n    \\begin{align*}\n        V_{M}=&\\{v_{1}=\\{1,A\\},v_{2}=\\{2,A\\},v_{3}=\\{3,A\\},v_{4}=\\{5,A\\},v_{5}=\\{1,B\\},v_{6}=\\{2,B\\},\\\\\n        &v_{7}=\\{3,B\\},v_{8}=\\{4,B\\},v_{9}=\\{5,B\\},v_{10}=\\{1,C\\},v_{11}=\\{2,C\\},v_{12}=\\{4,C\\},\\\\\n        &v_{13}=\\{5,C\\},v_{14}=\\{2,D\\},v_{15}=\\{3,D\\},v_{16}=\\{4,D\\},v_{17}=\\{5,D\\}\\}\n    \\end{align*}\n    \\begin{align*}\n        E_{M}=&\\{\\{v_{1},v_{2}\\}, \\{v_{2},v_{3}\\}, \\{v_{3},v_{4}\\}, \\{v_{1},v_{5}\\}, \\{v_{7},v_{8}\\}, \\{v_{9},v_{10}\\}, \\{v_{10},v_{11}\\}, \\{v_{12},v_{13}\\}, \\\\ &\\{v_{11},v_{14}\\}, \\{v_{12},v_{16}\\}, \\{v_{13},v_{17}\\}, \\{v_{14},v_{15}\\}, \\{v_{15},v_{16}\\}\\}\n    \\end{align*}\n    \n    \\noindent With that said, it also has the following characteristics:\n    \n    \\begin{enumerate}[a)]\n        \\item Intra-layer edge sets:\n        \\begin{align*}\n            E_{A,A}&=\\{\\{v_{1},v_{2}\\}, \\{v_{2},v_{3}\\}, \\{v_{3},v_{4}\\}\\} \\\\\n            E_{A,B}&=\\{\\{v_{7},v_{8}\\}\\} \\\\\n            E_{A,C}&=\\{\\{v_{10},v_{11}\\},\\{v_{12},v_{13}\\}\\} \\\\\n            E_{A,D}&=\\{\\{v_{14},v_{15}\\},\\{v_{15},v_{16}\\}\\} \\\\ \\\\\n            E_{A}&= E_{A,A} \\cup E_{A,B} \\cup E_{A,C} \\cup E_{A,D} \\\\\n            &= \\{\\{v_{1},v_{2}\\}, \\{v_{2},v_{3}\\}, \\{v_{3},v_{4}\\},\\{v_{7},v_{8}\\},\\\\ &\\quad\\quad\\{v_{10},v_{11}\\},\\{v_{12},v_{13}\\},\\{v_{14},v_{15}\\},\\{v_{15},v_{16}\\}\\}\n        \\end{align*}\n        \n        \\par\\noindent Inter-layer edge sets:\n        \\begin{align*}\n            E_{C,A,B}&=\\{\\{v_{1},v_{5}\\}\\} \\\\\n            E_{C,B,C}&=\\{\\{v_{9},v_{10}\\}\\} \\\\\n            E_{C,C,D}&=\\{\\{v_{11},v_{14}\\}, \\{v_{12},v_{16}\\},\\{v_{13},v_{17}\\}\\} \\\\ \\\\\n            E_{C}&=E_{C,A,B} \\cup E_{C,B,C} \\cup E_{C,C,D} = E_{M} \\setminus E_{A} \\\\\n            &= \\{\\{v_{1},v_{5}\\},\\{v_{9},v_{10}\\},\\{v_{11},v_{14}\\}, \\{v_{12},v_{16}\\}, \\{v_{13},v_{17}\\}\\}\n        \\end{align*}\n        \n        \\par\\noindent Coupling edge set:\n        \\begin{align*}\n            E_{\\widetilde{C},A,B}&=\\{\\{v_{1},v_{5}\\}\\} \\\\\n            E_{\\widetilde{C},C,D}&=\\{\\{v_{11},v_{14}\\}, \\{v_{12},v_{16}\\}, \\{v_{13},v_{17}\\}\\} \\\\ \\\\\n            E_{\\widetilde{C}}&=E_{\\widetilde{C},A,B} \\cup E_{\\widetilde{C},C,D} \\\\ &=\\{\\{v_{1},v_{5}\\},\\{v_{11},v_{14}\\}, \\{v_{12},v_{16}\\}, \\{v_{13},v_{17}\\}\\}\n        \\end{align*}\n        \n        \\item The provided network is not \\textit{fully interconnected} since not all the layers contain all the nodes.\n        \n        \\item The tensor representation of the network is:\n        \\begin{align*}\n            A_{::,A,A} &= \n            \\begin{bmatrix}\n            0 & 1 & 0 & 0 & 0 \\\\\n            1 & 0 & 1 & 0 & 0 \\\\\n            0 & 1 & 0 & 0 & 1 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 1 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,B,B} &= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 1 & 0 \\\\\n            0 & 0 & 1 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,C,C} &= \n            \\begin{bmatrix}\n            0 & 1 & 0 & 0 & 0 \\\\\n            1 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 1 \\\\\n            0 & 0 & 0 & 1 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,D,D} &= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 1 & 0 & 0 \\\\\n            0 & 1 & 0 & 1 & 0 \\\\\n            0 & 0 & 1 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,A,B} = A_{::,B,A} &= \n            \\begin{bmatrix}\n            1 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,B,C} = A_{::,C,B} &= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 & 1 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            1 & 0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,C,D} = A_{::,D,C} &= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 1 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 1 & 0 \\\\\n            0 & 0 & 0 & 0 & 1 \\\\\n            \\end{bmatrix} \n        \\end{align*}\n        \n        \\noindent Just to clarify, the rest of the tensors combinations has not been reported for brevity, since they all are equals to the null matrix.\n        \n    \\end{enumerate} \n    \n\\section{Exercise 3}\n    \\begin{figure}[H]\n        \\centering\n        \\includegraphics[width=0.6\\textwidth]{4.png}\n        \\caption{Multi-layer graph}\n        \\label{fig:figure-4}\n    \\end{figure}\n    \\begin{enumerate}[a)]\n    \\item The multi-layer graph pictured in the 'Figure \\ref{fig:figure-4}' has the following tensor representation:\n    \\begin{align*}\n            A_{::,A,A} &= \n            \\begin{bmatrix}\n            0 & 1 & 0 & 0 \\\\\n            1 & 0 & 1 & 0 \\\\\n            0 & 1 & 0 & 1 \\\\\n            0 & 0 & 1 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,B,B} &= \n            \\begin{bmatrix}\n            0 & 1 & 0 & 0 \\\\\n            1 & 0 & 1 & 0 \\\\\n            0 & 1 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,C,C} &= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 \\\\\n            0 & 0 & 1 & 0 \\\\\n            0 & 1 & 0 & 1 \\\\\n            0 & 0 & 1 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,D,D} &= \n            \\begin{bmatrix}\n            0 & 1 & 0 & 0 \\\\\n            1 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 1 \\\\\n            0 & 0 & 1 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,A,B} = A_{::,B,A} &= \n            \\begin{bmatrix}\n            1 & 0 & 0 & 0 \\\\\n            0 & 0 & 1 & 0 \\\\\n            0 & 1 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,B,C} = A_{::,B,C}&= \n            \\begin{bmatrix}\n            0 & 0 & 0 & 0 \\\\\n            0 & 0 & 1 & 0 \\\\\n            0 & 1 & 0 & 0 \\\\\n            0 & 0 & 0 & 1 \\\\\n            \\end{bmatrix}\\\\\n            A_{::,C,D} = A_{::,D,C} &= \n            \\begin{bmatrix}\n            1 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 \\\\\n            0 & 0 & 0 & 0 \\\\\n            \\end{bmatrix}\\\\\n    \\end{align*}\n    \n    \\noindent As before, the rest of the tensors combinations has not been reported for brevity, since they all are equals to the null matrix.\n    \n    \\item The degree of each node are:\n    \\begin{align*}\n        d_{1} &= (1,1,0,1) \\\\\n        d_{2} &= (2,2,1,1) \\\\\n        d_{3} &= (2,1,2,1) \\\\\n        d_{4} &= (1,0,1,1) \\\\\n    \\end{align*}\n    \n    \\par\\noindent Meanwhile the overlapping degree are:\n    \\begin{align*}\n        o_{1} &= 3 \\\\\n        o_{2} &= 6 \\\\\n        o_{3} &= 6 \\\\\n        o_{4} &= 3 \\\\\n    \\end{align*}\n    \n    \\par\\noindent Finally by applying the uniform-vector-like eigenvector centrality we obtain:\n    \n    \\begin{align*}\n    \\Tilde{A} = A_{::,A,A}^{T} + A_{::,B,B}^{T} + A_{::,C,C}^{T} + A_{::,D,D}^{T} =\n        \\begin{bmatrix}\n            0 & 3 & 0 & 0 \\\\\n            3 & 0 & 3 & 0 \\\\\n            0 & 3 & 0 & 3 \\\\\n            0 & 0 & 3 & 0 \\\\\n        \\end{bmatrix}\\\\\n    \\end{align*}\n    \n    \\noindent In which every column, and also every row since it's a symmetric matrix, identifies the eigenvector of the relative node (e.g. first row = first column = eigenvector of \\(v_{1}\\)).\n    \n    \\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "72d4a7ef1baddd19ab9a140bdb28b4523ba51cf1", "size": 9629, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignments/Task 3/Source Solution/main.tex", "max_stars_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_stars_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-27T13:28:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-26T15:53:47.000Z", "max_issues_repo_path": "Assignments/Task 3/Source Solution/main.tex", "max_issues_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_issues_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignments/Task 3/Source Solution/main.tex", "max_forks_repo_name": "FabioDainese/Networks_in_Economics_and_Social_Science", "max_forks_repo_head_hexsha": "b3f5bccdbc5e2a7d638356f2757118684a810d60", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.662962963, "max_line_length": 257, "alphanum_fraction": 0.4081420708, "num_tokens": 3748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.76908023177796, "lm_q1q2_score": 0.4055487140211056}}
{"text": "% Created 2019-09-05 jue 11:37\n\\documentclass[letterpaper,fleqn]{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{fixltx2e}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{float}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{marvosym}\n\\usepackage{wasysym}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\tolerance=1000\n\\usepackage{khpreamble}\n\\usepackage{tabularx}\n\\usepackage{geometry}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=1.13}\n\\geometry{top=20mm, bottom=20mm, left=24mm, right=18mm}\n\\author{Kjartan Halvorsen}\n\\date{}\n\\title{Pole-placement exercise}\n\\hypersetup{\n  pdfkeywords={},\n  pdfsubject={},\n  pdfcreator={Emacs 25.3.50.2 (Org mode 8.2.10)}}\n\\begin{document}\n\n\\maketitle\n\n\\section*{Plot the poles}\n\\label{sec-1}\n\\begin{center}\n\\textbf{s-plane} \\hspace*{0.4\\linewidth} \\textbf{z-plane}\\\\\n\\includegraphics[height=0.34\\textheight]{../../figures/sgrid-crop} \\hspace*{3mm}\n\\includegraphics[height=0.34\\textheight]{../../figures/zgrid-crop}\\\\\n\\end{center}\n\nPlot the poles of the following closed-loop discrete-time systems (as crosses in the z-plane). Plot also the corresponding continous-time poles (in the s-plane) using the sampling period \\(h=0.2\\). Rank the systems from 1 to 5 according to how desirable the performance of each system is.\n\\begin{description}\n\\item[{a}] \\( G_c(z) = \\frac{0.026z + 0.024}{z(z-0.95)}\\)\n\\item[{b}] \\( G_c(z) = \\frac{0.13z + 0.12}{z^2 - z + 0.25} \\)\n\\item[{c}] \\(G_c(z) = \\frac{0.54z + 0.52}{(z-0.5)^2 + 0.81}\\)\n\\item[{d}] \\(G_c(z) = \\frac{0.025z + 0.025}{(z-0.8)^2 - 0.09}\\)\n\\item[{e}] \\(G_c(z) = \\frac{0.068z + 0.062}{(z-0.8)^2 + 0.09}\\)\n\\end{description}\n\n\\newpage \n\n\n\\section*{Pole placement and step response}\n\\label{sec-2}\nPair each of the discrete-time systems in the previous exercise with the correct step response below.\n\\begin{center}\n\\includegraphics[width=\\linewidth]{../../figures/closed-loop-step-responsen}\n\\end{center}\n% Emacs 25.3.50.2 (Org mode 8.2.10)\n\\end{document}", "meta": {"hexsha": "e75d33b5bc5509aaaae79a58bc9db5228c9c0fa9", "size": 2041, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "discrete-time-systems/exercises/pole-placement-excercise.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "discrete-time-systems/exercises/pole-placement-excercise.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "discrete-time-systems/exercises/pole-placement-excercise.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 32.3968253968, "max_line_length": 288, "alphanum_fraction": 0.7138657521, "num_tokens": 746, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984434543458, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.40549458852752474}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage[\ntop    = 2.50cm,% presumably you don't want it to be 0pt as well?\nbottom = 2.50cm,\nleft   = 2cm,\nright  = 2cm,\nmarginparsep = 0pt,\nmarginparwidth=0pt,\n]{geometry}\n\n\\usepackage{amssymb}\n\\usepackage{fancyhdr}\n\\usepackage[most]{tcolorbox}\n\\usepackage{siunitx}\n\\usetikzlibrary{calc,patterns,angles,quotes}\n\\usepackage{amsmath}\n\\usepackage{tikz, tikz-3dplot}\n\\usepackage{caption}\n\\usepackage{pgfplots}\n\\usepackage{multicol}\n\\pagestyle{fancy}\n\\fancyhead[l]{Waves - Abridged edition}\n\\fancyhead[r]{Giorgio Grigolo {\\textcopyright}}\n\\newcommand\\textcenter[1]{\n\t\\begin{center}\n\t\t#1\n\t\\end{center}\n}\n\\begin{document}\n\t\\section{Simmple Harmonic Motion: }\n\t\\subsection{Definition: }\n\\begin{center}\n\t\tThe type of oscillatory motion in which the acceleration of the oscillating body is proportinal  to the body's displacement from the equilibrium position and always acts towards the equilibrium position.\n\\end{center}\n\t\\subsection{Graph: }\n\t\\begin{center}\n\t\t{\\begin{tikzpicture}[scale=1]\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tx=1cm,y=1cm,\n\t\t\t\t\taxis lines=middle,\n\t\t\t\t\tymajorgrids=true,\n\t\t\t\t\txmajorgrids=true,\n\t\t\t\t\txmin=0,\n\t\t\t\t\txmax=12,\n\t\t\t\t\tymin=-3,\n\t\t\t\t\tx label style={at={(axis description cs:0.5,-0.1)},anchor=north},\n\t\t\t\t\ty label style={at={(axis description cs:-0.1,0.5)},rotate=90,anchor=south},\n\t\t\t\t\txlabel=$t$ time,\n\t\t\t\t\tylabel=$s$ displacement,\n\t\t\t\t\tymax=3,\n\t\t\t\t\txtick={0,1,...,12},\n\t\t\t\t\tytick={-3,-2,...,3},]\n\t\t\t\t\t\\addplot[color=red, domain=0:12,samples=1000]{2*sin(90*(x+1))};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\captionof*{figure}{}}\n\t\\end{center}\n\t\\subsection{Diagram: }\n\t\\begin{center}\n\t\t\\begin{tikzpicture}[scale=1.6]\n\t\t\t% save length of g-vector and theta to macros\n\t\t\t\\pgfmathsetmacro{\\Gvec}{1.5}\n\t\t\t\\pgfmathsetmacro{\\myAngle}{45}\n\t\t\t% calculate lengths of vector components\n\t\t\t\\pgfmathsetmacro{\\Gcos}{\\Gvec*cos(\\myAngle)}\n\t\t\t\\pgfmathsetmacro{\\Gsin}{\\Gvec*sin(\\myAngle)}\n\t\t\t\n\t\t\t\\coordinate (centro) at (0,0);\n\t\t\t\\draw[dashed,gray,-] (centro) -- ++ (0,-3.5) node (mary) [black,below]{$ $};\n\t\t\t\\draw[thick] (centro) -- ++(270+\\myAngle:3) coordinate (bob);\n\t\t\t\\pic [draw, ->, \"$\\theta$\", angle eccentricity=1.5] {angle = mary--centro--bob};\n\t\t\t\\draw [blue,-stealth] (bob) -- ($(bob)!\\Gcos cm!(centro)$);\n\t\t\t\\draw [-stealth] (bob) -- ($(bob)!-\\Gcos cm!(centro)$)\n\t\t\tcoordinate (gcos)\n\t\t\tnode[midway,above right] {$mg\\cos\\theta$};\n\t\t\t\\draw [-stealth] (bob) -- ($(bob)!\\Gsin cm!90:(centro)$)\n\t\t\tcoordinate (gsin)\n\t\t\tnode[midway,above left] {$mg\\sin\\theta$};\n\t\t\t\\draw [-stealth] (bob) -- ++(0,-\\Gvec)\n\t\t\tcoordinate (g)\n\t\t\tnode[near end,left] {$mg$};\n\t\t\t\\pic [draw, ->, \"$\\theta$\", angle eccentricity=1.5] {angle = g--bob--gcos};\n\t\t\t\\filldraw [fill=black!40,draw=black] (bob) circle[radius=0.1];\n\t\t\\end{tikzpicture}\n\t\\end{center}\n\t\\subsection{Equation: }\n\t\\begin{equation}\n\t\ta = -\\frac{4\\pi^2}{T^2} \\times x\\tag{\\si{\\meter\\per\\second\\squared}}\n\t\\end{equation}\n\n\\begin{center}\n\tWhere $T$ is the \\textbf{periodic time} (\\si{\\second}).\n\\end{center}\n\t\n\t\\section{Phase difference: }\n\\subsection{\\textcolor{blue}{$\\frac{T}{4}$}, \\textcolor{green}{$\\frac{T}{2}$} phase difference: }\n\t\\begin{center}\n\t\t\\begin{tikzpicture}[scale=1.2]\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tx=1cm,y=1cm,\n\t\t\t\t\taxis lines=middle,\n\t\t\t\t\tymajorgrids=true,\n\t\t\t\t\txmajorgrids=true,\n\t\t\t\t\txmin=0,\n\t\t\t\t\txmax=12,\n\t\t\t\t\tymin=-3,\n\t\t\t\t\tx label style={at={(axis description cs:0.5,-0.1)},anchor=north},\n\t\t\t\t\ty label style={at={(axis description cs:-0.1,0.5)},rotate=90,anchor=south},\n\t\t\t\t\txlabel=$t$ time,\n\t\t\t\t\tylabel=$s$ displacement,\n\t\t\t\t\tymax=3,\n\t\t\t\t\txtick={0,1,...,12},\n\t\t\t\t\tytick={-3,-2,...,3},]\n\t\t\t\t\t\\addplot[color=red, domain=0:12,samples=1000]{2*sin(80*(x+1))};\n\t\t\t\t\t\\addplot[color=blue, domain=0:12,samples=1000]{2*sin(80*(x))};\n\t\t\t\t\t\\addplot[color=green, domain=0:12,samples=1000]{2*sin(80*(x-1))};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\\end{center}\n\n\\subsection{Full representation of SHM: }\n\\begin{center}\n\\begin{tikzpicture}[scale=1.2]\n\t\t\\begin{axis}[\n\t\t\tx=1cm,y=1cm,\n\t\t\taxis lines=middle,\n\t\t\tymajorgrids=true,\n\t\t\txmajorgrids=true,\n\t\t\txmin=0,\n\t\t\txmax=12,\n\t\t\tymin=-3,\n\t\t\tx label style={at={(axis description cs:0.5,-0.1)},anchor=north},\n\t\t\ty label style={at={(axis description cs:-0.1,0.5)},rotate=90,anchor=south},\n\t\t\txlabel=$t$ time,\n\t\t\tymax=3,\n\t\t\txtick={0,1,...,12},\n\t\t\tytick={-3,-2,...,3},]\n\t\t\t\\addplot[color=red, domain=0:12,samples=1000]{2*sin(45*(x))};\n\t\t\t\\addplot[color=blue, domain=0:12,samples=1000]{2*sin(45*(-x))};\n\t\t\t\\addplot[color=green, domain=0:12,samples=1000]{2*sin(45*(x+2};\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\begin{tikzpicture}[\n\t\tblacknode/.style={shape=circle, draw=black, line width=2},\n\t\tbluenode/.style={shape=circle, draw=blue, line width=2},\n\t\tgreennode/.style={shape=circle, draw=green, line width=2},\n\t\trednode/.style={shape=circle, draw=red, line width=2}\n\t\t]\n\t\t\\matrix [draw,below left] at (0,0) {\n\t\t\t\\node [greennode,label=right:Velocity] {}; \\\\\n\t\t\t\\node [bluenode,label=right:Acceleration] {}; \\\\\n\t\t\t\\node [rednode,label=right:Displacement] {}; \\\\\n\t\t};\n\t\\end{tikzpicture}\n\\end{center}\n\n\\section{$n$\\textsuperscript{th} harmonic}\n\n\\begin{equation}\n\tf_n = \\frac{n }{2l}\\sqrt{\\frac{T}{\\mu}}\n\\end{equation}\n\n\\begin{center}\n\tWhere $l$ is the \\textbf{length} (\\si\\meter) of the given string, $T$ the \\textbf{tension} (\\si\\newton) present through it and $\\mu$ its \\textbf{linear mass density} (\\si{\\kilogram\\per\\meter}).\n\\end{center}\n\\section{Young's Double Slit Experiment}\n\n\\begin{center}\n\t \\begin{tikzpicture}[scale=1.5,every node/.append style={transform shape}]\n\t \t\\foreach \\x in {-0.5,-0.25,0} {\n\t \t\t\\draw (\\x,-1) -- (\\x,1);\n\t \t}\n\t \t\\foreach \\x in {-0.375,-0.125,-0.125} {\n\t \t\t\\draw[dashed] (\\x,-1) -- (\\x,1);\n\t \t}\n\t \t\\draw[fill=black!10] (0.5,-2,-1) -- (0.5,-2,1) -- (0.5,2,1) -- (0.5,2,-1) -- (0.5,-2,-1);\n\t \t\\fill (0.5,0,0) circle (0.05);\n\t \t\\foreach \\r in {0.25,0.5,...,1.75} {\n\t \t\t\\draw (0.5,0) ++(-60:\\r) arc (-60:60:\\r);\n\t \t}\n\t \t\\foreach \\r in {0.125,0.375,...,1.875} {\n\t \t\t\\draw[dashed] (0.5,0) ++(-60:\\r) arc (-60:60:\\r);\n\t \t}\n\t \t\\draw[fill=black!10] (2,-2,-1) -- (2,-2,1) -- (2,2,1) -- (2,2,-1) -- (2,-2,-1);\n\t \t\\fill (2,0.5) circle (0.05) (2,-0.5) circle (0.05);\n\t \t\\foreach \\r in {0.25,0.5,...,2} {\n\t \t\t\\draw (2,0.5) ++(-60:\\r) arc (-60:60:\\r);\n\t \t\t\\draw (2,-0.5) ++(-60:\\r) arc (-60:60:\\r);\n\t \t}\n\t \t\\foreach \\r in {0.125,0.375,...,2.125} {\n\t \t\t\\draw[dashed] (2,0.5) ++(-60:\\r) arc (-60:60:\\r);\n\t \t\t\\draw[dashed] (2,-0.5) ++(-60:\\r) arc (-60:60:\\r);\n\t \t}\n\t \t\\draw (2,0.5,0.625) -- (2,0.5,0.5);\n\t \t\\draw (2,-0.5,0.625) -- (2,-0.5,0.5);\n\t \t\\draw (2,0.5,0.5) -- (2,-0.5,0.5);\n\t \t\\draw[densely dotted] (2,0.5,0.5) -- (2,0.5,0);\n\t \t\\draw[densely dotted] (2,-0.5,0.5) -- (2,-0.5,0);\n\t \t\\draw[fill=black!10] (4,-2,-1) -- (4,-2,1) -- (4,2,1) -- (4,2,-1) -- (4,-2,-1);\n\t \t%       LABELLING\n\t \t\\begin{scope}[canvas is yz plane at x=2,rotate=-90]\n\t \t\t\\node[above] at (0,0.5) {A};\n\t \t\t\\node[below] at (0,-0.5) {B};\n\t \t\t\\node[left] at (-0.5,0) {d};\n\t \t\\end{scope}\n\t \t\\begin{scope}[canvas is yz plane at x=0.5,rotate=-90]\n\t \t\t\\node[below left=-0.1cm] at (0,0) {S${}_0$};\n\t \t\\end{scope}\n\t \t\\begin{scope}[xshift=4cm,yshift=2cm,rotate=-90,canvas is xy plane at z=0]\n\t \t\t\\fill[white] (0,0) rectangle (4,1);\n\t \t\t\\begin{axis}[\n\t \t\t\twidth=5.575cm,\n\t \t\t\txmin=-0.62,\n\t \t\t\txmax=0.62,\n\t \t\t\tymin=0,\n\t \t\t\tticks=none\n\t \t\t\t]\n\t \t\t\t\\addplot [samples=500,black,smooth\n\t \t\t\t]\n\t \t\t\t{(cos(deg(5*pi*sin(deg(x)))))^(2)*((sin(deg(4*pi*sin(deg(x)))))/(4*pi*sin(deg(x))))^(2)};\n\t \t\t\t\\draw[thin, densely dashed,blue] (axis cs:0.1593,0.1327) -- (axis cs:0.1593,0);\n\t \t\t\t\\draw[thin, densely dashed,blue] (axis cs:-0.1593,0.1327) -- (axis cs:-0.1593,0);\n\t \t\t\t\\draw[thin, densely dashed,blue] (axis cs:0.3941,0.03938) -- (axis cs:0.3941,0);\n\t \t\t\t\\draw[thin, densely dashed,blue] (axis cs:-0.3941,0.03938) -- (axis cs:-0.3941,0);\n\t \t\t\\end{axis}\n\t \t\\end{scope}\n\t \t\\draw[thin,densely dashed,blue] (2,0) -- (6.9,0);\n\t \t\\begin{scope}\n\t \t\t\\clip (2,-2) rectangle (4,2);\n\t \t\t\\draw[thin,densely dashed,blue] (2,0) --    +(15:4);\n\t \t\t\\draw[thin,densely dashed,blue] (2,0) --    +(-15:4);\n\t \t\t\\draw[thin,densely dashed,blue] (2,0) --    +(32:4);\n\t \t\t\\draw[thin,densely dashed,blue] (2,0) --    +(-32:4);\n\t \t\t\\draw[thin,densely dashed,red] (2,0) --     +(8:4);\n\t \t\t\\draw[thin,densely dashed,red] (2,0) --     +(-8:4);\n\t \t\t\\draw[thin,densely dashed,red] (2,0) --     +(24:4);    \n\t \t\t\\draw[thin,densely dashed,red] (2,0) --     +(-24:4);               \n\t \t\\end{scope}\n\t \\end{tikzpicture}\\\\\nThe observable pattern achieved in this experiment can be seen above. It consists of alternate dark and bright bands. The centreal band, the one equidistant from both slits is always bright ($AO - BO = 0\\lambda$)\n\\begin{multicols}{2}\n\tdestructive interference $\\implies$ dark\\\\\n\tconstructive interference $\\implies$ bright\n\\end{multicols}\n\\end{center}\n\\subsection{Path difference}\n\\begin{multicols}{2}\n\t\\begin{center}\n\t\t\\textbf{\\underline{Bright band}}\\\\\n\t\t~\\\\\n\t\t$n\\lambda,\\, n \\in \\mathbb{N}$\n\t\\end{center}\n\t\\begin{center}\n\t\\textbf{\\underline{Dark band}}\\\\\n\t~\\\\\n\t$n\\frac12\\lambda,\\, n \\in \\mathbb{N}$\n\\end{center}\n\\end{multicols}\n\\subsection{Bright slit interval distance: }\n\\begin{equation}\n\ty=\\frac{D\\lambda}{d}\\tag{\\si{\\meter}}\n\\end{equation}\n\\begin{center}\n\tWhere $D$ is the \\textbf{distance} (\\si{\\meter}) between the slits and the screen, $d$ is the \\textbf{seperation} ({\\si{\\meter}}) between the two slits and $\\lambda$ the \\textbf{wavelength} (\\si{\\meter}) of the wave at the source.\n\\end{center}\n\\end{document}", "meta": {"hexsha": "f870b3cb1b6d354a6b1430d16946824b86ad0ab4", "size": 9374, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Physics/6. Waves/waves.tex", "max_stars_repo_name": "Girogio/My-LaTeX", "max_stars_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-12T11:45:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-30T21:47:25.000Z", "max_issues_repo_path": "Physics/6. Waves/waves.tex", "max_issues_repo_name": "Girogio/My-LaTeX", "max_issues_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Physics/6. Waves/waves.tex", "max_forks_repo_name": "Girogio/My-LaTeX", "max_forks_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2406015038, "max_line_length": 231, "alphanum_fraction": 0.6068914017, "num_tokens": 3776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.40549457436417374}}
{"text": "\n    \\foldertitle{modellang}{Model File Language}{modellang/Contents}\n\n\tModel file language is used to write model files. The model files are\nplain text files (saved under any filename with any extension) that\ndescribes the model: its equations, variables, parameters, etc. The\nmodel file, on the other hand, does not describe what to do with the\nmodel. To run the tasks you want to perform with the model, you need\nfirst to load the model file into Matlab using the\n\\href{model/model}{\\texttt{model}} function. This function creates a\nmodel object. Then you write your own m-files using Matlab and IRIS\nfunctions to perform the desired tasks with the model object.\n\nWhy do all the keywords (except pseudofunctions) start with an\nexclamation point? Why do the comments have the same style as in Matlab?\nWhy do substitutions and steady-state references use the dollar sign?\nBecause this way, you can get the model files syntax-highlighted in the\nMatlab editor. Syntax highlighting improves enormously the readability\nof the files, and helps understand the model more quickly. See\n\\href{setup/Contents}{the setup instructions} for more details.\n\n\\paragraph{Variables, parameters, substitutions and\nfunctions}\\label{variables-parameters-substitutions-and-functions}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/transitionvariables}{\\texttt{!transition\\_variables}}\n  - List of transition variables.\n\\item\n  \\href{modellang/transitionshocks}{\\texttt{!transition\\_shocks}} - List\n  of transition shocks.\n\\item\n  \\href{modellang/measurementvariables}{\\texttt{!measurement\\_variables}}\n  - List of measurement variables.\n\\item\n  \\href{modellang/measurementshocks}{\\texttt{!measurement\\_shocks}} -\n  List of measurement shocks.\n\\item\n  \\href{modellang/exogenousvariables}{\\texttt{!exogenous\\_variables}} -\n  List of exogenous variables.\n\\item\n  \\href{modellang/parameters}{\\texttt{!parameters}} - List of\n  parameters.\n\\item\n  \\href{modellang/autoexogenise}{\\texttt{!autoexogenise}} - Definition\n  of variable/shock pairs for use in autoexogenised simulation plans.\n\\end{itemize}\n\n\\paragraph{Equations}\\label{equations}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/transitionequations}{\\texttt{!transition\\_equations}}\n  - Block of transition equations.\n\\item\n  \\href{modellang/measurementequations}{\\texttt{!measurement\\_equations}}\n  - Block of measurement equations.\n\\item\n  \\href{modellang/dtrends}{\\texttt{!dtrends}} - Block of deterministic\n  trend equations.\n\\item\n  \\href{modellang/links}{\\texttt{!links}} - Define dynamic links.\n\\end{itemize}\n\n\\paragraph{Linearised and log-linearised\nvariables}\\label{linearised-and-log-linearised-variables}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/logvariables}{\\texttt{!log\\_variables}} - List of\n  log-linearised variables.\n\\item\n  \\href{modellang/allbut}{\\texttt{!all\\_but}} - Inverse list of\n  log-linearised variables.\n\\item\n  \\href{modellang/regexpression}{\\texttt{\\textless{}...\\textgreater{}}}\n  - Regular expression in log-variable list.\n\\end{itemize}\n\n\\paragraph{Special operators}\\label{special-operators}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/sstateversion}{\\texttt{!!}} - Steady-state version of\n  an equation.\n\\item\n  \\href{modellang/ttrend}{\\texttt{!ttrend}} - Linear time trend in\n  deterministic trend equations.\n\\item\n  \\href{modellang/laglead}{\\texttt{\\{...\\}}} - Lag or lead.\n\\item\n  \\href{modellang/sstateref}{\\texttt{\\&}} - Reference to the\n  steady-state level of a variable.\n\\item\n  \\href{modellang/exactnonlin}{\\texttt{=\\#}} - Mark an equation for\n  exact non-linear simulation.\n\\item\n  \\href{modellang/alias}{\\texttt{'...!!...'}} - Beginning of aliasing\n  inside descriptions and labels.\n\\end{itemize}\n\n\\paragraph{Pseudofunctions}\\label{pseudofunctions}\n\nPseudofunctions do not start with an exclamation point.\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/min}{\\texttt{min}} - Define loss function for optimal\n  policy.\n\\item\n  \\href{modellang/diff}{\\texttt{diff}} - First difference\n  pseudofunction.\n\\item\n  \\href{modellang/dot}{\\texttt{dot}} - Gross rate of growth\n  pseudofunction.\n\\item\n  \\href{modellang/difflog}{\\texttt{difflog}} - First log-difference\n  pseudofunction.\n\\item\n  \\href{modellang/movavg}{\\texttt{movavg}} - Moving average\n  pseudofunction.\n\\item\n  \\href{modellang/movprod}{\\texttt{movprod}} - Moving product\n  pseudofunction.\n\\item\n  \\href{modellang/movsum}{\\texttt{movsum}} - Moving sum pseudofunction.\n\\end{itemize}\n\n\\paragraph{Preparser control commands}\\label{preparser-control-commands}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\href{modellang/substitutions}{\\texttt{!substitutions}} - Define text\n  substitutions.\n\\item\n  \\href{modellang/pseudosubs}{\\texttt{\\${[}...{]}\\$}} -\n  Pseudosubstitutions.\n\\item\n  \\href{modellang/import}{\\texttt{!import}} - Include the content of\n  another model file.\n\\item\n  \\href{modellang/export}{\\texttt{!export}} - Create a carry-around file\n  to be saved on the disk.\n\\item\n  \\href{modellang/if}{\\texttt{!if...!elseif...!else...!end}} - Choose\n  block of code based on logical condition.\n\\item\n  \\href{modellang/switch}{\\texttt{!switch...!case...!end}} - Switch\n  among several cases based on expression.\n\\item\n  \\href{modellang/for}{\\texttt{!for...!do...!end}} - For loop for\n  automated creation of model code.\n\\item\n  \\href{modellang/linecomments}{\\texttt{\\%}} - Line comments.\n\\item\n  \\href{modellang/blockcomments}{\\texttt{\\%\\{...\\%\\}}} - Block comments.\n\\end{itemize}\n\n\\paragraph{Getting on-line help on model file\nlanguage}\\label{getting-on-line-help-on-model-file-language}\n\nWhen getting help on model file language, type the names of the keywords\nand commands without the exclamation point:\n\n\\begin{verbatim}\nhelp modellang\nhelp modellang/keyword\nhelp modellang/command \nhelp modellang/pseudofunction\n\\end{verbatim}\n\n\\paragraph{Matlab functions and user functions in model\nfiles}\\label{matlab-functions-and-user-functions-in-model-files}\n\nYou can use any of the built-in functions (Matlab functions, functions\nwithin the Toolboxes you have on your computer, and so on). In addition,\nyou can also use your own functions (written as an m-file) as long as\nthe m-file is on the Matlab search path or in the current directory.\n\nIn your own m-file functions, you can also (optionally) supply the first\nderivatives that will be used to compute Taylor expansions when the\nmodel is being solved, and the second derivatives that will be used when\nthe function occurs in a loss function.\n\nWhen asked for the derivatives, the function is called with two extra\ninput arguments on top of that function's regular input arguments. The\nfirst extra input argument is a text string \\texttt{'diff'} (indicating\nthe call to the function is supposed to return a derivative). The second\nextra input argument is a number or a vector of two numbers; it\ndetermines with respect to which input argument or arguments the first\nderivative or the second derivative is requested.\n\nFor instance, your function takes three input arguments,\n\\texttt{myfunc(x,y,z)}. To be able to supply derivates avoiding thus\nnumerical differentiation, the function must be written so that the\nfollowing three calls\n\n\\begin{verbatim}\nmyfunc(x,y,z,'diff',1)\nmyfunc(x,y,z,'diff',2)\nmyfunc(x,y,z,'diff',3)\n\\end{verbatim}\n\nreturn the first derivative wrt to the first, second, and third input\nargument, respectively, while\n\n\\begin{verbatim}\nmyfunc(x,y,z,'diff',[1,2])\n\\end{verbatim}\n\nreturns the second derivative wrt to the first and second input\narguments. Note that second derivatives are only needed for functions\nthat occur in an equation defining optimal policy objective,\n\\href{modellang/min}{min}.\n\nIf any of these calls fail, the respective derivative will be simply\nevaluated numerically.\n\n\\paragraph{Basic rules IRIS model\nfiles}\\label{basic-rules-iris-model-files}\n\n\\begin{itemize}\n\\item\n  There can be four types of equations in IRIS models: transition\n  equations which are simply the endogenous dynamic equations,\n  measurement equations which link the model to observables,\n  deterministic trend equations which can be added at the top of\n  measurement equations, and dynamic links which can be used to link\n  some parameters or steady-state values to each other.\n\\item\n  There can be two types of variables and two types of shocks in IRIS\n  models: transition variables and shocks, and measurement variables and\n  shocks.\n\\item\n  Each model must have at least one transition (aka endogenous) variable\n  and one transition equation.\n\\item\n  Each variable, shock, or parameter must be declared in the appropriate\n  declaration section.\n\\item\n  The declaration sections and equations sections can be written in any\n  order.\n\\item\n  You can have as many declaration sections or equations sections of the\n  same kind as you wish in one model file; they all get combined\n  together at the time the model is being loaded.\n\\item\n  Transition variables can occur with lags and leads in transition\n  equations. Transition variables cannot, though, have leads in\n  measurement equations.\n\\item\n  Measurement variables and the shocks cannot have any lags or leads.\n\\item\n  Transition shocks cannot occur in measurement equations, and the\n  measurement shocks cannot occur in transition equations.\n\\item\n  Exogenous variables can only occur in dtrends (deterministic trend\n  equations), and must be always supplied in the input database to\n  commands like \\texttt{model/simulate}, \\texttt{model/jforecast},\n  \\texttt{model/filter}, \\texttt{model/estimate}, etc. They are not\n  returned in the output databases.\n\\item\n  You can choose between linearisation and log-linearisation for each\n  individual transition and measurement variable. Shocks are always\n  linearised. Exogenous variables must be always introduced so that\n  their effect on the respective measurement variable is linear.\n\\end{itemize}\n\n\n\n", "meta": {"hexsha": "f29ff6d624fad4ba1388d359d67d0b18ba333760", "size": 9962, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/modellang/Contents.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/modellang/Contents.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/modellang/Contents.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 35.963898917, "max_line_length": 73, "alphanum_fraction": 0.7716322024, "num_tokens": 2671, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.40544193098427345}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\\begin{document}\n\n\\logo\n\n\\rulename{Differential Moving Average Momentum}\n\\tblofcontents\n\\ruledescription{This trading rules takes the slope, or derivative or momentum of two different price moving averages and subtracts one slope from the other to determine position size. The parameters accepted are the momentum length, the look back length of the short moving average and the look back length of the long moving average.}\n\n\\ruleparameters\n{Short price average length}{20}{Number of days in the short price\naverage.}{$\\averagelengthshort^{\\price}$}\n{Long price average length}{100}{Number of additional days in the longer price average (added to the number in the short price average).}{$\\averagelengthlong^{\\price}$}\n{Moving average momentum length}{5}{Number of days in the moving\naverage slope calculation.}{$M^{\\price}$}\n\\stoptable\n\n\n\\section{Equation}\n\n\\begin{equation}\n\\bigcontribution(\\averagelengthshort, \\price) = \\frac{1}{\\averagelengthshort} \\sum_{\\dummyiterator=0}^{\\averagelengthshort} \\price_{n}\n\\end{equation}\n\n\\begin{equation}\n\\bigcontribution(\\averagelengthlong, \\price) = \\frac{1}{\\averagelengthlong} \\sum_{\\dummyiterator=0}^{\\averagelengthlong} \\price_{n}\n\\end{equation}\n\n\\begin{equation}\n\\bigcontribution(\\bigcontribution(\\averagelengthshort, \\price), M^{\\price}, \\currenttime) = \\frac\n{(\\bigcontribution(\\averagelengthshort, \\price)(t) -\n(\\bigcontribution(\\averagelengthshort, \\price)(\\currenttime - M^{\\price}))}\n{M^{\\price}}\n\\end{equation}\n\n\\begin{equation}\n\\bigcontribution(\\bigcontribution(\\averagelengthlong, \\price), M^{\\price}, \\currenttime) = \\frac\n{(\\bigcontribution(\\averagelengthlong, \\price)(t) -\n(\\bigcontribution(\\averagelengthlong, \\price)(\\currenttime - M^{\\price}))}\n{M^{\\price}}\n\\end{equation}\n\n\\begin{equation}\n\\position(\\currenttime) =\n\\bigcontribution(\\bigcontribution(\\averagelengthshort, \\price), M^{\\price}, \\currenttime) - \\bigcontribution(\\bigcontribution(\\averagelengthlong, \\price), M^{\\price}, \\currenttime)\n\\end{equation}\n\n\\hspace{200mm}\n\n\\noindent where $\\position_\\currenttime$ is the portfolio allocation at time $\\currenttime$ and $\\price = \\price(\\currenttime)$ is the value of the price series.\n\n\\hspace{200mm}\n\\hspace{200mm}\n\n\\keyterms\n\n\\furtherlinks\n\n\\end{document}\n", "meta": {"hexsha": "bb15cb0e76c26dc145dad6b54c00d7ae22a2e422", "size": 2385, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/DifferentialMovingAverageMomentum.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/DifferentialMovingAverageMomentum.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/DifferentialMovingAverageMomentum.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 37.265625, "max_line_length": 336, "alphanum_fraction": 0.7651991614, "num_tokens": 698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.40544192186054195}}
{"text": "\\documentclass{article}\n\n\\usepackage{mathtools}\n\\usepackage[margin=0.5in]{geometry}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{hyperref}\n\\usepackage{booktabs}\n\\usepackage{float}\n\\usepackage{multirow}\n\n\\setlength{\\parindent}{0pt}\n\\graphicspath{ {./experiment/data/} }\n\n\\title{Edge Detection Evaluation of HEp-2 Cells in Fluorescent Images}\n\\author{Ossama Edbali - ID: 1466610}\n\n\\begin{document}\n\t\n\t\\maketitle\t\n\t\n\t\\section{Aim}\n\t\n\tThis study aims to analyse the results and efficacy of several edge detection algorithms\n\ton HEp-2 cells.\n\t\n\tThe edge detection/segmentation algorithms used are: Otsu, Sobel, Roberts, Canny,\n\tCanny using anisotropic diffusion,\n\tLaplacian of Gaussian, Difference of Gaussians and dilate-erode method.\n\t\n\tThe evaluation of each method is carried by ROC curves, sensitivity-specificity variation graphs and correspondence analysis.\n\t\n\t\\textbf{All the Matlab code and full data can be found here: \\url{http://uobcs.github.io/hep2-edge-detection/}.}\n\t\n\t\\section{Method}\n\n\tFirst of all the experiments where conducted using three main scripts (one for each\n\timage):\n\t\\verb|x9343AM_task|, \\verb|x10905JL_task| and \\verb|x43590AM_task|.\n\t\n\tEach script loads the relative image and true edge image. Then produces a greyscale image using the \\texttt{rgb2gray} Matlab function.\n\tFinally, it performs all the edge detection algorithms described above (delegating\n\t\tto the class \\texttt{EdgeDetection.m}).\n\tA pre-analysis (qualitative) of the input has been carried out using the\n\tbackground approximation image as a surface to see where illumination varies (using \\verb|show_background| function).\n\tIt can be seen that the various input images are the outcome of different fluorescence patterns on\tthe HEp-2 cells.\n\t\n\tFor all edge detectors there is a method inside the \\texttt{EdgeDetection} class\n\tas well as methods for generating the ROC space and specificity and sensitivity\n\tin function of some parameters (e.g. threshold, sigma, number of iterations).\n\t\n\tFor Roberts and Sobel a function \\verb|detect_edges(img, filterX, filterY)| was developed which convolves \\verb|img| with the two filters and uses\n\t\\verb|magnitude| to produce the final result (before thresholding).\n\t\n\tIn regards to LoG, Gaussian smoothing was performed using \\verb|gaussian_smoothing(image, sigma)|. Then convolve the smoothed image with the laplacian\n\toperator and finally find the zero crossings using \\verb|edge(res, 'zerocross')|.\n\t\n\t\\subsection*{Otsu's method}\n\tOne of the algorithms used in this study is Otsu's algorithm.\n\tThe aim is to find the threshold value where the sum of foreground and background spreads is at its minimum. First of all I calculate the weighted mean and variance\n\tfor both the background and foreground ($\\mu_b$, $\\sigma_b^2$ and\n\t$\\mu_f$, $\\sigma_f^2$). Then I compute the \\textbf{within-class variance} (two variances multiplied by their associated weights): $\\sigma_W^2 = W_b \\sigma_b^2+W_f \\sigma_f^2$. I do the same calculation for candidate thresholds and the one that has the lowest within-class variance will be chosen. This algorithm is implemented in Matlab's\n\t\\verb|graythresh|. This will produce a binary image which edges' can be detected\n\teasily by any of the edge detectors (Sobel in the experiment).\n\t\n\t\\subsection*{Dilate-erode method}\t\n\t\n\tThe dilate-erode method is a 4-step algorithm that uses a combination of  morphological operators before using Sobel edge detector. The reason why this method\n\thas been used is that when Sobel (or Roberts) is performed on the greyscale image, there are some lines of high contrast surrounding\n\tthe actual edge (like noise). The gaps between these small lines and the actual edge\n\tcan be filled using a \\textbf{dilate morphological operator} (or non-linear neighbourhood\n\toperator) with a structuring element (from the \\verb|strel| function). Then\n\t\\verb|imfill| has been used to fill the holes inside the cell - this step can\n\tbe skipped but it will result in a lower performance.\n\tThe next step is to \"reduce\" the cell to get it back to its state before\n\tdilation using\n\tthe \\textbf{erosion} operator. Finally the Sobel filter has been used to detect\n\tedges.\n\tThere are various ways to create the  morphological operators. Here is the one\n\tused in this study (erode example using a 5x5 mask): \\verb|erode = @(x) min(x(:)); out = nlfilter(in,[5 5],erode)|.\n\t\n\t\\subsection*{Canny with anisotropic diffusion (CAD)}\t\n\t\n\tFrom the study it has been noted that Canny performed with sensitivity lower than\n\t0.4 in all input images. To enhance the images but still preserving true edges,\n\t\\textbf{anisotropic diffusion} has been used.\n\tAnisotropic diffusion is a non-linear diffusion filtering for avoiding the\n\tblurring problems of Gaussian smoothing (and others). It is an iterative\n\tprocess to perform edge-preserving smoothing on the cells.\n\tThe algorithm is described mathematically as follows:\n\t\n\t\\begin{center}\n\t$\\frac{\\partial}{\\partial t}I(x, t) = \\nabla \\bullet (c(x, t) \\nabla I(x, t))$\n\t\\end{center}\t\t\n\t\n\tHere $t$ is the iteration step, $c(x, t)$ is a decreasing diffusion function\n\tof the image gradient magnitude.\n\t\n\tThe \\verb|anisodiff2D(im, num_iter, delta_t, kappa, option)| function in the codebase\n\thas been implemented to accomplish anisotropic diffusion. Here \\verb|im| is the\n\tinput image, \\verb|num_iter| is the number of iterations, \\verb|delta_t| is\n\tthe integration constant, \\verb|kappa| is the diffusion constant and\n\t\\verb|option| defines which diffusion function to use.\n\t\\newline\n\t\n\tI adopted three evaluation methods in order to assess the accuracy/efficacy of each edge\n\tdetector technique:\n\t\n\t\\subsection*{ROC curve}\n\t\n\tThe ROC curve has been used to detect which parameter to choose according\n\tto a \\textbf{diagnosis line} (in the experiment\n\t(0, 1) to (1, 0) has been used). The implementation can be found under\n\tthe \\verb|compute_roc(ID, IT)| function, where ID is the image\n\twith detected edges and \\verb|IT| is the image with true edges.\n\tBasically it takes the two binary images and performs logical operations\n\tfor all possible cases (e.g. true positive, false positive etc\\ldots) and\n\tcalculates the sum of \"on\" pixels in the resulting images. Then it combines\n\tthe results to find sensitivity and specificity:\n\t\n\t\\begin{center}\n\t\\verb|sensitivity = TP / (TP + FN)| and \\verb|specificity = TN / (TN + FP);|\n\t\\end{center}\n\t\n\t\\subsection*{Sensitivity/Specificity variation}\t\n\t\n\tThis evaluation method simply uses the sensitivity and specificity parameters in function\n\tof a variable (threshold, sigma, kappa or number of iterations). From this we\n\tcan see how different algorithms respond to the variation of some parameters.\n\tThis is implemented by the \\verb|roc_params_comparison| static method in the\n\t\\verb|EdgeDetection| class.\n\t\n\t\\subsection*{Correspondence analysis (intra-method analysis)}\t\n\t\n\tFrom $N$ edge detection results (using the same edge detector) test for\n\tcorrespondence as follows: a pixel location identified as an edge by\n\tall $N$ detector configurations (i.e. changing parameter)\n\twill have the highest correspondence ($N$), and a\n\tlocation identified as an edge by only one detector setup will have the lowest.\n\t\n\tThis is computed by the \\verb|correspondence_analysis| function in the codebase which\n\tadds all the input image matrices and, using Matlab's \\verb|bar|, plots a bar diagram\n\twith frequencies for each correspondence level (using \\verb|histc|).\n\t\n\t\\section{Results}\n\t\n\tA very interesting result is the comparison between Canny and Canny with anisotropic diffusion (using 9343 AM as a reference).\n\n\\begin{figure}[htp]\n\n\\centering\n\\includegraphics[width=.3\\textwidth]{x9343AM/comparison.png}\\hfill\n\\includegraphics[width=.3\\textwidth]{x9343AM/canny/result.png}\\hfill\n\\includegraphics[width=.3\\textwidth]{x9343AM/cad/result_15_iterations.png}\n\n\\caption{(1) ROC space comparison, (2) Canny, (3) Canny with anisotropic diffusion }\n\\label{fig:figure3}\n\n\\end{figure}\n\t\n\tIt can be noted that Canny does not perform very well (sensitivity under 0.4).\n\tHowever if we apply anisotropic diffusion,\n\tsensitivity drastically increases (over 0.8). This happens because the input image\n\tis very dark at the borders and Canny looses information in the smoothing\n\tstep as well as in the non-maximum suppression step. Supporting this statement\n\tare the results of applying Canny to 43590 AM (which is very dark compared to\n\tthe other two images and therefore a high smoothing).\n\t\n\tA summary of the whole data using the optimal parameters (\\textbf{for the FULL evaluation graphs, tables and image results please visit this site: \\url{http://uobcs.github.io/hep2-edge-detection/}}):\n\t\n\\begin{table}[H]\n\\centering\n\\caption{Overall results (1: 9343 AM, 2: 10905JL, 3: 43590AM)}\n\\label{my-label}\n\\begin{tabular}{|c|c|l|l|}\n\\hline\n\\multicolumn{1}{|l|}{Edge detector} & \\multicolumn{1}{l|}{Image} & Sensitivity & Specificity \\\\ \\hline\n\\multirow{3}{*}{Otsu}               & 1                          & 0.9225      & 0.9974      \\\\ \\cline{2-4} \n                                    & 2                          & 0.9279      & 0.9957      \\\\ \\cline{2-4} \n                                    & 3                          & 0.8813      & 0.9958      \\\\ \\hline\n\\multirow{3}{*}{Sobel}              & 1                          & 0.8498      & 0.8638      \\\\ \\cline{2-4} \n                                    & 2                          & 0.8953      & 0.8852      \\\\ \\cline{2-4} \n                                    & 3                          & 0.8195      & 0.8237      \\\\ \\hline\n\\multirow{3}{*}{Roberts}            & 1                          & 0.8477      & 0.8400      \\\\ \\cline{2-4} \n                                    & 2                          & 0.8646      & 0.8779      \\\\ \\cline{2-4} \n                                    & 3                          & 0.7540      & 0.8215      \\\\ \\hline\n\\multirow{3}{*}{Canny}              & 1                          & 0.3404      & 0.9408      \\\\ \\cline{2-4} \n                                    & 2                          & 0.3057      & 0.9863      \\\\ \\cline{2-4} \n                                    & 3                          & 0.2396      & 0.9808      \\\\ \\hline\n\\multirow{3}{*}{CAD}                & 1                          & 0.7910      & 0.86651     \\\\ \\cline{2-4} \n                                    & 2                          & 0.8139      & 0.9204      \\\\ \\cline{2-4} \n                                    & 3                          & 0.6734      & 0.8921      \\\\ \\hline\n\\multirow{3}{*}{Dilate-Erode}       & 1                          & 0.8299      & 0.8058      \\\\ \\cline{2-4} \n                                    & 2                          & 0.8003      & 0.8119      \\\\ \\cline{2-4} \n                                    & 3                          & 0.7446      & 0.7863      \\\\ \\hline\n\\multirow{3}{*}{LoG}                & 1                          & 0.2250      & 0.9419      \\\\ \\cline{2-4} \n                                    & 2                          & 0.2135      & 0.9324      \\\\ \\cline{2-4} \n                                    & 3                          & 0.1996      & 0.9207      \\\\ \\hline\n\\multirow{3}{*}{DoG}                & 1                          & 0.2137      & 0.9857      \\\\ \\cline{2-4} \n                                    & 2                          & 0.2446      & 0.9941      \\\\ \\cline{2-4} \n                                    & 3                          & 0.17301     & 0.99094     \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\t\n\\begin{table}[H]\n\\centering\n\\caption{Otsu evaluation}\n\\label{otsu}\n\\begin{tabular}{@{}llll@{}}\n\\toprule\nImage    & Sensitivity & Specificity & Threshold \\\\ \\midrule\n9343 AM  & 0.9225      & 0.9974      & 0.0902    \\\\\n10905 JL & 0.9279      & 0.9957      & 0.1333    \\\\\n43590 AM & 0.8813      & 0.9958      & 0.0510    \\\\ \\bottomrule\n\\end{tabular}\n\\end{table}\n\nOverall Otsu has proven to be the best choice in all the images. Although\ncomputationally expensive, Otsu's method takes into account foreground and\nbackground and gives satisfactory results only when the numbers of pixels in each class are close to each other (which is the case here).\n\nSobel and Roberts have performed almost equally in all images however Sobel has\nhigher specificity because it is less sensitive to isolated high intensity point variations. Thus it gives correct results when the edge do not exist in a given point.\n\nIn regards to the dilate-erode method\nwe can notice that the sensitivity decreases very fast compared to Sobel (or Roberts). This is because during the erode process some edges might be removed and this propagates to the Sobel edge detection and thresholding.\n\n\n\t\n\t\\section{Conclusion}\n\t\n\tIn this study various alternatives to the traditional edge detectors have been\n\ttried because of their specific application to cell edge detection. For example\n\tCanny is very sensitive to the fluorescence around the cells. LoG and DoG have\n\tlow sensitivity (for optimal parameters) because they highlight regions\n\tof rapid intensity changes but the input images have gradual\n\tchange from the cell to the background (fluorescence effect). Some extensions to\n\tthe edge detectors (such as dilate-erode, adjust and anisotropic diffusion)\n\thave proven to increase the efficacy of the edge detection.\n\t\n\\end{document}", "meta": {"hexsha": "a91b46d0626d76df82cb3eb7ca912879fb1c94cb", "size": 13293, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report.tex", "max_stars_repo_name": "UoBCS/hep2-edge-detection", "max_stars_repo_head_hexsha": "346baf66c980f169d3590b10587e5c30462833e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "report.tex", "max_issues_repo_name": "UoBCS/hep2-edge-detection", "max_issues_repo_head_hexsha": "346baf66c980f169d3590b10587e5c30462833e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report.tex", "max_forks_repo_name": "UoBCS/hep2-edge-detection", "max_forks_repo_head_hexsha": "346baf66c980f169d3590b10587e5c30462833e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.9297520661, "max_line_length": 339, "alphanum_fraction": 0.661776875, "num_tokens": 3469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.40544191834612003}}
{"text": "\\documentclass{article}\n\n\\usepackage{tikz}\n\\usepackage{amsthm,amsmath,amssymb}\n\\usepackage{csquotes}\n\\usetikzlibrary{automata}\n\\usetikzlibrary{graphs}\n\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}\n\n\\begin{document}\n\n\\section{Formal Verification of Flexibility in Swarm Robotics}\n\nMicroscopic v.s. macroscopic\napproach to model checking\nswarm robotics.\n\n\"The first approach consists of building a model by first creating a corresponding\nfinite state machine for each robot behavior and then by taking the composition of\nall those finite state machines. The second approach consists of building a single\nfinite state machine containing a state for each different sub-behavior of the robots.\nEach state is associated with a counter that keep track of the number of robot\ncurrently in that state.\"\n\n\\section{Transition System Representing a Battle}\n\n\\begin{tikzpicture}\n    \\matrix[row sep=2cm, column sep=1cm]{\n        \\node (E) {$E$} ; &\n        \\node (K) {$K$} ; &\n        \\node (G) {$G$} ; \\\\\n    } ;\n\n    \\graph[use existing nodes] {\n         E -> [edge label={atk},loop above]\n         E ->[edge label={atk}]\n         K ->[edge label={atk},loop above]\n         K ->[edge label={done}] G ;\n    } ;\n\\end{tikzpicture}\n\nAt the beginning of each battle, some number\nof robots are assigned to fit enemy $ i $,\nwhich is represented in state E. In state E,\nthe action \"attack\" can be taken. This action\nwill probabilistically result in the defeat\nof the enemy, or require additional attacks.\n\nThe probability of neutralizing an enemy\nis given in the next section.\n\nIf the attack succeeds, then the battle transitions\nto the \"complete\" phase (state K), upon which\nall robots get redistributed to the other\nbattles that are being fought (concurrently)!\nFurthermore, we must set the base level of the\nfreshly defeated enemy as 0.\n\nBecause we create a product transition system\nin which the action \"attack\" is a handshake action,\nwe include a dummy \"attack\" action in state K\nthat goes to itself, in order to allow other\nbattles to continue.\n\nUpon the completion of all battles, there is a\n\"done\" action that can be taken (also a handshake action)\nthat allows all battles to reach\nthe \"goal\" state simultaneously, thus\nconcluding the engagement.\n\nFuture extensions: Attacks could probabilistically result\nin casualties.\n\n\\section{The Role of Probability}\n\nAs discussed, the event of defeating some enemy\noccurs probabilistically. We have heterogeneous\nenemies, which we model by assigning them\n\"levels\". Conceptually, enemies with higher\nlevels are more difficult to defeat than other\nenemies (i.e. the probability of defeating an\nenemy in an attack is lower).\n\nHowever, conceptually it also makes sense that\na higher number of robots attacking the same\nenemy would make it more likely that an enemy\nis defeated in a round of combat.\n\nHence, we define the probability of \\textbf{not defeating}\nan enemy in a round of combat using the following\nfunction of the level of the enemy\n(the cumulative distribution function of the\nexponential distribution).\n\n$$ f(l_i) = 1 - e^{-\\lambda_i l_i} $$\n\nThis is motivated by the idea of dynamically adjusting the\nprobability of not defeating an enemy as there\nare more robots fighting it.\n\n$ \\mathcal{l}_i $ is the base level of an enemy.\nThen, we say that $ \\lambda_i = \\frac{1}{cn_i + 1} $ is the adjustment\nfactor, where $ n_i $ is the number of robots\ncurrently fighting enemy $ i $, and $ c $ is a\nhyperparameter that describes robot neutralization efficiency.\n1 must be added to avoid division by zero problems.\n\n\\section{Optimization}\n\nRoughly stated, the ultimate goal is to find the optimal\nportioning of robots to minimize the number of rounds of\ncombat in order to successively neutralize all targets.\n\n\\begin{displayquote}\n\n    We have N robots.\n\n    Let $ \\mathcal{M} = \\{m_1, m_2, \\ldots, m_k \\} $ be the set of all enemies.\n\n    Further, let L be the bound in $ \\mathcal{L} = \\{ 1, \\ldots, L \\} $.\n\n    Our goal is to find a function $ L^\\mathcal{M} \\to [0,1]^\\mathcal{M} $\n    such that the expected number of turns to neutralize all enemies\n    is minimized.\n\n\\end{displayquote}\n\nThis function takes ordered tuples of enemies levels (the remaining battles),\nand produces a probability distribution\nover them that is used to inform the proportions by which the newly unallocated\nrobots are distributed among the remaining battles.\n\nBecause arbitrary functions cannot be described in PRISM, we have assumed\nthat the distribution of robots over the remaining battles will simply be the weighted distribution\nby current adjusted level (what we previously called $ \\lambda_i l_i $).\n\nHowever, we would like to be able to tune the function in order\nto optimize how robots are (re)distributed among battles.\nFor our initial experiment, we choose the function $ g(x) = x^a $,\nwhere $ a $ is a parameter that will be tuned using\nsimulated annealing (by verifying desired properties repeatedly\nusing different values of $ a $). This function can be interchanged\nwith any other function in order to achieve the desired scaling amount\nfor redistribution.\n\nThus, we can now define our\nfunction $ L^\\mathcal{M} \\to [0,1]^\\mathcal{M} $ as follows:\n\n$$ f(\\langle l_1, \\ldots, l_k \\rangle) = \\frac{g(\\langle \\lambda_1 l_1, \\ldots, \\lambda_k l_k \\rangle)}{\\sum_j^{g(\\langle \\lambda_j l_j \\ldots \\lambda_k l_k \\rangle)}} i \\in \\{1, \\ldots, M\\} $$\n\nWe assume that the functions g and f operate element-wise on tuples.\n\nWe assume that all of our robots are homogeneous.\nHowever, our enemies are assumed to be heterogeneous\n(as defined using our level system).\n\n\\end{document}\n", "meta": {"hexsha": "8dcb02b260f314922abfbbeeffaed87cc4d2f581", "size": 5610, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/writeup_notes.tex", "max_stars_repo_name": "tsani/tortoise", "max_stars_repo_head_hexsha": "a4f141b6e56416a6bb92b94a4e172e60d412d8e1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/writeup_notes.tex", "max_issues_repo_name": "tsani/tortoise", "max_issues_repo_head_hexsha": "a4f141b6e56416a6bb92b94a4e172e60d412d8e1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/writeup_notes.tex", "max_forks_repo_name": "tsani/tortoise", "max_forks_repo_head_hexsha": "a4f141b6e56416a6bb92b94a4e172e60d412d8e1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0625, "max_line_length": 193, "alphanum_fraction": 0.7527629234, "num_tokens": 1387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.40544191343510666}}
{"text": "\\Lecture{Jayalal Sarma}{Sept 29, 2020}{08}{PIE and three applications}{Sumanth Naik}{$\\alpha$}{JS}\n\n%\\section{Introduction}\nThe journey so far has been that we have been doing counting by bijections and established certain ideas regarding double counting and the bijections behind the scenes. Then we came to Principle of Inclusion-Exclusion(PIE) as a consequence of a bijection argument. In this lecture, we will look at another proof (an algebraic proof) for PIE and then 3 interesting applications of PIE.\n\n\\section{Principle of Inclusion Exclusion (PIE) - An Algebraic Proof} \\label{sec:Principle of Inclusion - Exclusion(PIE)}\nIf there are $n$ subsets of a ground set $X$; $A_1$, $A_2$, $A_3, \\ldots A_n$ $\\subseteq$ $X$, then PIE helps us to estimate the size of the set of union of all $n$ subsets of the ground set. Mathematically, PIE states that,\n\\begin{align*}\n\\left|\\bigcup_{i=1}^{n} A_i\\right| &= \\sum_{1 \\le i \\le n} | A_i|\n\\hspace{0.1cm}- \\sum_{1 \\le i < j \\le n} \\left| A_i \\cap A_j \\right| \\\\\n&\\hspace{0.5cm}+ \\sum_{1 \\le i < j < k \\le n} | A_i \\cap A_j \\cap A_k| \\hspace{0.2cm}.\\hspace{0.1cm}.\\hspace{0.1cm}.\\hspace{0.1cm}.\\hspace{0.1cm}.\\\\\n\\left|\\bigcup_{i=1}^{n} A_i\\right| &= \\sum_{\\emptyset \\neq I \\subseteq [n]} (-1)^{|I| +1} \\left|\\bigcap_{i \\in I} A_i \\right|\\\\\n&=\\sum_{\\emptyset \\neq I \\subseteq [n]} (-1)^{|I| +1} \\left|A_I\\right|\n\\end{align*}\nwhere $[n] = \\{1,2,3, \\ldots, n\\} $ (short-hand notation for $1$ to $n$ elements) and $A_I = \\bigcap_{i \\in I} A_i$.\\\\\n\\\\\nNote that the intuition behind understanding the formula in the second step from first is that, $ \\emptyset \\neq I \\subseteq [n]$ captures all the combinations of $1,2,3, \\ldots ,n$ sized sets from $n$ sized set of numbers, i.e., $1 \\le i \\le n$ (set of combinations of 1 sized set from n sized set), $1 \\le i < j \\le n$ (set of combinations of 2 sized set from n sized set) and so on up to set of combinations of $n$ sized set from n sized set. The alternating sign in first equation's term is captured by $(-1)^{|I| +1}$ in second equation. And finally, the intersection part of all the terms in first equation, i.e., $|A_i|, |A_i \\cap A_j|,  |A_i \\cap A_j \\cap A_j| \\ldots$ is captured in $ \\bigcap_{i \\in I} A_i$ of the second equation.\n\\begin{proof}\nDefine the characterestic function of the set $A_i$ as $f_i$ described as : $f_i:X\\longrightarrow\\{0,1\\}$, where the images are defined as $$\\forall x \\in X,\\hspace{0.3cm} f_i(x) = \n  \\begin{cases}\n    1&\\mbox{if } x \\in A_i \\\\\n    0& \\textrm{otherwise }\n  \\end{cases}\n$$\n\nBy definition, $(1-f_i(x))$ is the characteristic function for the compliment of $A_i$ (i.e. $X\\setminus A_i$ or $\\overline A_i$). In other words, when you subtract the characteristic function of a set from $1$, the difference is the characteristic function of the compliment of the same set. It is also to be noted that $f_i(x)f_j(x)$ is the characteristic function of $A_i\\cap A_j$. In other words; when you multiply the characteristic functions of two sets with each other, the product is the characteristic function of the intersection of the two sets. \n\\begin{align}\n\\intertext{Consider a function defined as,} F(x) &= \\prod_{i=1}^{n}(1-f_i(x))\\nonumber \\\\\n&= (1-f_1(x))(1-f_2(x)) \\ldots (1-f_n(x))\\nonumber  \\\\\n&= \\sum_{I\\subseteq[n]}(-1)^{|I|}\\left(\\prod_{i \\in I} f_i(x)\\right) \\label{eq:F_def_in_PIE}\n\\end{align}\nNote that the $F(x)$ represents the characteristic function of intersection of compliments (compliment of each $f_i$), hence by De-Morgan's Law, its mathematical equivalent is,\n\\[\n\\overline{\\left(\\bigcup_{i=1}^{n} A_i\\right)} = X \\setminus \\bigcup\t_{i=1}^{n}A_i\n\\]\nTo get the size of the set in the $RHS$ of previous equation (it has all the elements which are not present in any of the $n$ subsets of $X$), we just need to count the number of $x$'s in $X$ for which $F(x)$ is 1 (as $F(x)$ will be 1 for any $x$ only if every $f_i(x)$ is 0, i.e., $\\forall i,x \\notin A_i$). Hence:\n\\begin{equation}\n\\label{eq:sigma_F_1}\n|X \\setminus \\bigcup_{i=1}^{n}A_i| = \\sum_{x \\in X} F(x) \n\\end{equation}\n\nAlso from (\\ref{eq:F_def_in_PIE}),\n\\begin{align}\n\\sum_{x \\in X} F(x)&= \\sum_{x} \\sum_{I \\subseteq [n]} (-1)^{|I|} \\left(\\prod_{i \\in I} f_i(x)\\right)\\nonumber \\\\\n&= \\sum_{I \\subseteq [n]} (-1)^{|I|} \\left(\\sum_{x} \\left(\\prod_{i \\in I} f_i(x)\\right)\\right)\\nonumber \\\\\n&=\\sum_{I \\subseteq [n]} (-1)^{|I|} \\left|\\bigcap_{i \\in I}A_i\\right|\\label{eq:sigma_F_2}\n\\end{align}\nThe last step is because $(\\prod_{i \\in I} f_i(x))$ is the characteristic function of intersection of $n$ subsets, i.e., $\\bigcap_{i \\in I}A_i$. And its summation over $x$, $(\\sum_{x} (\\prod_{i \\in I} f_i(x)))$ will give us the size of the intersection, $\\left|\\bigcap_{i \\in I}A_i\\right|$. Also, note that the convention when $I=\\emptyset$ is,\n%\\begin{equation}\n$\\left|\\bigcap_{i \\in I}A_i\\right| = |X|$.\nwhich can be reasoned as when $I$ is empty, $\\left(\\prod_{i \\in I} f_i(x)\\right)$ is $1$ for any $x$. And its summation over $x$, $\\sum_{x} \\left(\\prod_{i \\in I} f_i(x)\\right)$ gives $|X|$.\n\\begin{align*}\n\\intertext{By (\\ref{eq:sigma_F_1}) and (\\ref{eq:sigma_F_2}),}\n\\left|X \\setminus \\bigcup_{i=1}^{n}A_i\\right| &= \\sum_{I \\subseteq [n]} (-1)^{|I|} \\left|\\bigcap_{i \\in I}A_i\\right|\\\\\n|X | - \\left| \\bigcup_{i=1}^{n}A_i\\right| &= \\sum_{I \\subseteq [n]} (-1)^{|I|} \\left|\\bigcap_{i \\in I}A_i \\right|\\\\\n\\left| \\bigcup_{i=1}^{n}A_i \\right| &= |X| - \\sum_{I \\subseteq [n]} (-1)^{|I|} \\left|\\bigcap_{i \\in I}A_i\\right|\\\\ \n&=\\sum_{\\emptyset \\neq I \\subseteq [n]} (-1)^{|I|+1} \\left|\\bigcap_{i \\in I}A_i \\right| \\\\\n\\end{align*}\nThis completes the algebraic proof for PIE.\n\\end{proof}\n\n\n\\section{Applications of PIE} \\label{sec:Applications of PIE - lec1}\n\nWe now see three different applications of PIE which exposes some interesting features of the tool.\n\n\\subsection{Counting the number of derangements on $n$ elements.} \\label{subsec:derangements application}\nConsider a scenario where, $n$ people go to a theatre to watch a movie, they keep their hats outside with the gatekeeper. On return, in a rush, the gatekeeper panicked and gave back the hats randomly.\\\\\n\\textbf{Question:} What is the chance that nobody got their own hat for a very large $n$?\\\\\n\\textbf{Answer (surprisingly high)}: roughly 36\\% ! (more precisely, the probability is $1/e = 0.3678$).\n\nFormally, if we view the rearrangement as a permutation on $n$ elements, the property that we are looking for can be expressed mathematically as follows : A permutation $\\sigma \\in S_n$ is said to be a derangement if $\\forall i \\in [n], \\sigma(i) \\ne i$.\nNow we prove the following theorem.\n\n\\begin{theorem}\nNumber of derangements on $n$ elements is $$\\left(\\sum_{k=0}^{n} \\frac{(-1)^k}{k!}\\right)n!$$\n\\end{theorem}\n\nBefore we proceed, let us demonstrate why this implies our surprising answer. We know that the total number of ways for the $n$ people to pick $n$ hats is $n!$ (factorial of $n$) and hence the chance of derangement is $\\left(\\sum_{k=0}^{n} \\frac{(-1)^k}{k!}\\right)$. As $n\\rightarrow\\infty$, $\\left(\\sum_{k=0}^{n} \\frac{(-1)^k}{k!}\\right) \\rightarrow 1/e \\thicksim 0.3678$.). We now proceed with the proof of the above theorem, which is a nice application of PIE.\n\n\\begin{proof}\nLet $S_n$ be the set of permutations on $n$ elements. $\\sigma \\in S_n$ is a permutation function on $n$  elements ($\\sigma : [n] \\rightarrow [n]$). $\\forall_{i=1}^{n},~ \\sigma(i)$ is defined as the person to whom $i^{\\text{th}}$ person's hat was given. If $\\sigma(i) = i$, then it means that the $i^{\\text{th}}$ person got the correct hat - in terms of formal language of permutations, this is called a \\textit{fix-point} of the permutation. What we are looking for is to count the number of fix-point-free permutations in $S_n$. \n\n\nThe strategy is to count the number of non-derangements and subtract from $n!$.\nMathematically, non-derangement is captured as $\\exists i,\\hspace{0.2cm} \\sigma(i) = i$. Now we set up the application of PIE in this context, by defining the $A_i$s first. Define $A_i$ as, \n$$\\forall i \\in \\{1,2,...n\\},\\hspace{0.2cm} A_i = \\{\\sigma \\in S_n\\hspace{0.1cm} |\\hspace{0.1cm} \\sigma(i) = i\\}$$ \nSo, $A_i$ represents the set of $n$ elements whose $i^{\\text{th}}$ element is fixed to $i$, other elements can be any non repeating value of $1$ to $n$ (except $i$ as it is taken).\n\nThe set that we want to estimate the size of - the set of non-derangement can be represented as $\\bigcup_{i=1}^{n} A_i$.\nHence, we are interested in finding the number of non-derangements $|\\bigcup_{i=1}^{n} A_i|$.\n\nWe want to apply PIE - which is about intersection of these $A_i$. Can $A_i$ and $A_j$ really intersect? Indeed, they can, and we can even estimate the size of the intersection: indeed, for a permutation to be in the intersection it has to be fixing the element $i$ and $j$ and it has the freedom to choose any permutation for the remaining values. Hence,\n$$|A_i \\cap A_j| = (n-2)!$$\n\nNow we generalize this estimate to arbitrary size intersections since they appear in the RHS of PIE. For a shorthand notation, define, $A_I = \\bigcap_{i \\in I} A_i$. Now, from the statement of $PIE$, we need to estimate sizes of $\\left| A_I \\right|$ for different $I \\subseteq [n]$. Observe that,\n\\begin{align}\n|A_I| &= (n-|I|)! \\label{eq:size_of_A_I_derangement_problem}\n\\end{align}\nIndeed, in $A_I$, $\\forall i \\in I$, $\\sigma(i)$ is fixed to $i$ by definition. For the remaining $n-|I|$ values, $\\sigma$ can take any arbitrary permutation of the same $n-|I|$ values, hence $(n-|I|)!$ gives the number of possibilities.\\\\\n\nUsing PIE and using the idea of fixing size of $I$ and sum over each size in next step,\n\\begin{align}\n|\\bigcup_{i=1}^{n} A_i| &= \\sum_{\\emptyset \\neq I \\subseteq [n]} (-1)^{|I|+1} |A_I|\\nonumber \\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} \\left(\\sum_{I\\subseteq [n],|I|=k} |A_I|\\right)\\nonumber \\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} \\left(\\sum_{I\\subseteq [n],|I|=k} (n-k)!\\right)\\nonumber \\tag{By (\\ref{eq:size_of_A_I_derangement_problem})}\\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} (n-k)! {n \\choose k}\\nonumber \\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} \\frac{n!} {k!}\\nonumber \\\\\n&=  \\left(\\sum_{k=1}^{n}  \\frac{(-1)^{k+1}} {k!}\\right)n! \\label{eq:non_derangements}\n\\end{align}\nNow, to get number of derangements, subtract (\\ref{eq:non_derangements}) from $n!$, which is \n\\begin{align*}\nn! - \\left(\\sum_{k=1}^{n}  \\frac{(-1)^{k+1}} {k!}\\right)n! &= \\left(\\sum_{k=0}^{n} \\frac{(-1)^k}{k!}\\right)n!\n\\end{align*}\n\\end{proof}\n\n\\subsection{Euler's $\\Phi$ function.} \\label{subsec:euler's function application}\n\\begin{theorem}\nLet $n \\in N$, $\\Phi (n)$ = number of numbers $\\leq n$, which are relatively prime to $n$. If $$n=\\prod_{i=1}^{k}p_i^{\\alpha_i}$$ where $p_i$ are distinct primes and $\\forall i,~ \\alpha_i \\geq 1$, then $$\\Phi(n) = n \\left(\\prod_{i=1}^{k}\\left(1-\\frac{1}{p_i}\\right) \\right)$$\n\\end{theorem}\n\\begin{proof}\nLet $X=\\{1,2,3,...,n\\}$. Then,\n\\[\n\\forall 1 \\leq i \\leq k, A_i = \\{m\\in X ~|~p_i \\textrm{ divides } m\\}\n\\]\nThus, $A_i$ represents the set of multiples of $p_i$ less than $n$.\nNumber of numbers which are not relatively prime to $n$ is given by (as every number in any of $A_i$ will have $p_i$ as common factor) - is given by exactly the set : $\\bigcup_{i=1}^{k} A_i$.  Thus we have the ground set for application for PIE. We need to be able to estimate the sizes of the intersections. More precisely:\n\\begin{align}\n\\Phi (n) &= n - |\\bigcup_{i=1}^{k}A_i| \\tag{apply PIE}\n\\nonumber \\\\\n&=n- \\sum_{I \\subseteq [k], I \\neq \\emptyset} (-1)^{|I|+1}|A_I| \\label{eq:mobius_with_PIE}\n\\end{align}\nwhere\n%\\begin{align}\nTo esteimate $|A_I|$. We claim that $|A_I| = |\\bigcap_{i \\in I}A_i| = \\frac{n}{\\prod_{i \\in I}p_i}$. This can be reasoned as follows : in $\\bigcap_{i \\in I}A_i$, there will be those numbers which are multiples of all the $p_i$'s. The same set can be obtained by including the product of every $p_i$, i.e., $\\prod_{i \\in I}p_i$, and all the numbers less than $n$ which are multiples of that product. The number of such numbers can be captured by $\\frac{n}{\\prod_{i \\in I}p_i}$.\\\\\nBy Equation~\\ref{eq:mobius_with_PIE} and using the convention of $\\prod_{i \\in I}p_i$ is 1 when $I=\\emptyset$, \n\\begin{align*}\n\\Phi (n) &= n - \\sum_{I \\subseteq [k], I \\neq \\emptyset} (-1)^{|I|+1}\\frac{n}{\\left(\\prod_{i \\in I}p_i\\right)}\\\\\n&= \\sum_{I \\subseteq [k]} (-1)^{|I|}\\frac{n}{(\\prod_{i \\in I}p_i)}\\\\\n&= n\\sum_{I \\subseteq [k]} (-1)^{|I|}\\frac{1}{\\left(\\prod_{i \\in I}p_i\\right()}\\\\\n&=n\\left(\\prod_{i=1}^{k}\\left(1-\\frac{1}{p_i}\\right)\\right)\n\\end{align*}\nNote that the last step is done similar to  (\\ref{eq:F_def_in_PIE}) in PIE (section \\ref{sec:Principle of Inclusion - Exclusion(PIE)}) derivation : $f_i$ there is equivalent to $\\frac{1}{p_i}$ here. This completes the proof for the theorem.\n\\end{proof}\n\\vspace{.5cm}\n\\noindent\n\\begin{corollary}$\\Phi$ is multiplicative when numbers are co-primes. i.e., if $n_1, n_2$ are co-primes, then $\\Phi(n_1 n_2) = \\Phi(n_1) \\Phi(n_2)$.\n\\end{corollary}\n\\begin{proof}\nLet $A$ be the set of prime factors of $n_1n_2$. Since $n_1n_2$ is the product of two numbers $n_1$ and $n_2$, any prime $p \\in A$ should divide at least one of $n_1$ and $n_2$. If $n_1$ and $n_2$ are co-primes, then the do not have any common prime factor. Therefore, any prime $p \\in A$ should divide exactly one of $n_1$ and $n_2$. So, we can partition the set $A$ into two sets $X$ and $Y$ where $X$ is the set of prime factors of $n_1$ and $Y$ is that of $n_2$.\n\\begin{align*}\n    \\Phi(n_1n_2) &= n_1 n_2  (\\prod_{p \\in A}(1-\\frac{1}{p}))\\\\\n    &= n_1 (\\prod_{p\\in X}(1-\\frac{1}{p})). n_2 (\\prod_{p\\in Y}(1-\\frac{1}{p}))\\\\\n    &= \\Phi(n_1) \\Phi(n_2)\n\\end{align*}\nThus, if $n_1$, $n_2$ are co-primes, then $\\Phi(n_1 n_2) = \\Phi(n_1) \\Phi(n_2)$. \\end{proof}\n\n\n\\subsection{Probability that two natural numbers are co-primes} \\label{subsec:co-primes application}\nFor two randomly chosen natural numbers, what is the probability that they do not have a common factor (other than 1)?\\\\\nAnswer: $\\sim60\\% $\n\\begin{proof}\nFix $n$; $S = \\{(a,b) | a,b \\in [n]\\}$.\\\\\nConsider two definitions, the good set $G$ (represents set of pairs whose elements have $gcd = 1$) and the bad set $B$ (represents set of pairs whose elements have $gcd > 1$),\n\\[\nG = \\{(a,b)| \\text{ no } d > 1 \\text{ exist such that }d  \\hspace{0.1cm}divides \\hspace{0.1cm} a \\text{ and } d  \\hspace{0.1cm}divides \\hspace{0.1cm} b\\}\n\\]\n\\[\nB = \\{(a,b)| \\exists d > 1 \\text{ such that }d \\hspace{0.1cm}divides \\hspace{0.1cm} a \\text{ and } d \\hspace{0.1cm}divides \\hspace{0.1cm} b\\}\n\\]\nWe want the upper bound of $|B|$ in terms of $n^2$.\\\\\nDefine $X$ which has all the permutations of pairs possible as, $$X = \\{(a,b)|a,b \\in [n]\\}$$\nAnd for prime $p \\le n$, define $A_p$ as a set which contains pairs whose elements both have $p$ as a prime factor and the pair belongs to $X$. $$A_p = \\{(a,b)|p \\hspace{0.1cm}divides \\hspace{0.1cm}a,p \\hspace{0.1cm}divides \\hspace{0.1cm}b, p \\hspace{0.1cm}is\\hspace{0.1cm}prime ,(a,b)\\in X\\}$$\nClearly, $$B = \\bigcup_{p \\le n} A_p$$\nBy PIE, \n\\begin{align}\n|B| = \\sum_{I \\subseteq Q, I \\neq \\emptyset} (-1)^{|I|+1} |A_I| ~~\\text{where,} ~~Q = \\{p|p \\le n, prime\\}\\label{eq:PIE_usage_application_3}\n\\end{align}\nNow, the aim is to estimate $|A_I|$ (as stated in PIE), we can write,\n\\begin{align}\n|A_I| =|\\bigcap_{p_i \\in I} A_{p_i}|\\label{eq:size_of_A_I_mobius}\n\\end{align}\nHere, $\\bigcap_{p_i \\in I} A_{p_i}$ denotes the set of pairs whose elements are both divisible by product of numbers (which are primes) in $I$. Note that the product need not be a prime. We can not write the resulting set ($\\bigcap_{p_i \\in I} A_{p_i}$) in terms of $A_p$ as $p$ is prime in the definition. So, lets create a new definition.\\\\\nLet's define $A_d$, which denotes the set of pairs whose elements both have $d$ as a factor and the pairs belongs to $X$ (note that this definition is different from $A_p$ as there $p$ should be a prime, here $d$ can be any number), $$A_d = \\{(a,b)|d \\hspace{0.1cm}divides \\hspace{0.1cm} a, d \\hspace{0.1cm}divides \\hspace{0.1cm} b, (a,b) \\in X\\}$$\nRewriting (\\ref{eq:size_of_A_I_mobius}) using the definition of $A_d$,\n\\begin{align}\n|A_I| =|A_d| \\label{eq:size_of_A_I_equals_size_of_A_d}\n~~where, \\hspace{0.3cm}d = \\prod_{p_i \\in I}p_i\n\\end{align}\nEstimating $|A_d|$ separately, from definition, $a$ can be any mutiple of $d$ which is less than or equal to $n$, similarly $b$ too can be any mutiple of $d$ which is less than or equal to $n$. Hence, \n\\begin{align}\n|A_d| &=\\lfloor \\frac{n}{d} \\rfloor \\lfloor \\frac{n}{d} \\rfloor\\nonumber\\\\\n&=(\\lfloor \\frac{n}{d} \\rfloor)^2 \\label{eq:size_of_A_d}\n\\end{align}\nFrom (\\ref{eq:PIE_usage_application_3}), splitting the summation by number of primes taking part, \n\\begin{align}\n|B| &=\\sum_{k \\geq 1} (\\sum_{I \\subseteq Q, I \\neq \\emptyset,|I| = k} (-1)^{|I|+1} |A_I|) \\nonumber \\tag{Apply (\\ref{eq:size_of_A_I_equals_size_of_A_d}) and (\\ref{eq:size_of_A_d}) }\\\\\n&=  \\sum_{k \\geq 1}(\\sum_{d \\le n,\\substack{d\\text{ is a product } \\\\ \\text{of } k \\text{ distinct}\\\\ \\text{primes from }Q} }(-1)^{k+1}(\\lfloor \\frac{n}{d} \\rfloor)^2)  \\label{eq:bad_set}\n\\end{align}\nNote that the value of $k$ is used only to determine the sign of the terms in $|B|$. Usage of Mobius function gives a clever way to reduce the equation of $|B|$ to a single summation from double summation.\\\\\nMobius function $\\mu(d)$ is given by\n\\[\n  \\mu(d) = \n  \\begin{cases}\n    0 &\\mbox{if } p^2 \\hspace{0.1cm} \\text{divides} \\hspace{0.1cm} d, \\hspace{0.1cm} p  \\hspace{0.1cm} \\text{is prime}\\\\\n    1 &\\mbox{if } d = 1\\\\\n    (-1)^k &\\mbox{if } d \\text{ is a product of }k \\text{ distinct primes} \n  \\end{cases}\n\\]\nUsing $\\mu(d)$ in (\\ref{eq:bad_set}),\n$$|B| = \\sum_{2 \\le d \\le n}(-\\mu(d) ((\\lfloor \\frac{n}{d} \\rfloor)^2))$$\nNow estimating $|G|$; since all of $S$ can be either in $G$ or $B$ but not both and size of $S$ is $n^2$,\n\\begin{align}\n|G| &= n^2 - |B|\\nonumber \\\\\n&= n^2 + \\sum_{2 \\le d \\le n}\\mu(d) ((\\lfloor \\frac{n}{d} \\rfloor)^2)\\nonumber \\\\\n&= \\sum_{1 \\le d \\le n}\\mu(d) ((\\lfloor \\frac{n}{d} \\rfloor)^2) \\label{eq:good_set_1}\n\\end{align}\nLast step uses the fact that $\\mu(1) = 1$ in the Mobius function.\\\\\n Furthermore for any $x$,\n\\begin{align*}\n(\\lfloor x \\rfloor )^2 - x^2 &= (x-\\{x\\})^2 - x^2\\\\\n&= x^2 - 2\\{x\\}x + \\{x\\}^2 -x^2\\\\\n&= -2x\\{x\\} + \\{x\\}^2\\\\\n&= O(x)\n\\end{align*}\nUsing this fact in (\\ref{eq:good_set_1}),\n\\begin{align}\n|G| &= \\sum_{1 \\le d \\le n}\\mu(d) (\\frac{n^2}{d^2} + O(\\frac{n}{d}))\\nonumber \\\\\n&= n^2 \\sum_{1 \\le d \\le n}\\frac{\\mu(d)}{d^2} +  O(n \\sum_{1 \\le d \\le n}(\\frac{\\mu(d)}{d})) \\label{eq:good_set_2}\n\\end{align}\nEstimating the second term in (\\ref{eq:good_set_2}): \n\\begin{align}\nn \\sum_{1 \\le d \\le n}(\\frac{\\mu(d)}{d}) &\\le n (\\sum_{1 \\le d \\le n}\\frac{1}{d})\\nonumber \\\\\n&\\le n \\log{n} \\label{eq:term_2_in_good_set}\n\\end{align}\nLast step is derived by the asymptotic estimate of the sequence of Harmonic series. \\\\ \\\\\nEstimating the first term in (\\ref{eq:good_set_2}):\\\\\nUsing Euler's series, the following approximation can be done.\n\\begin{align}\nM = \\sum_{d=1}^{\\infty} \\frac{\\mu(d)}{d^2} \\sim \\frac{6}{\\pi^2} \\label{eq:approx_M}\n\\end{align} \\\\\nIt can also be proven that\n\\begin{align}\n|M-\\sum_{1 \\le d \\le n} \\frac{\\mu(d)}{d^2}| \\le \\frac{1}{n}\\label{eq:term_1_in_good_set}\n\\end{align}\nUsing (\\ref{eq:good_set_2}), (\\ref{eq:term_2_in_good_set}), (\\ref{eq:approx_M}) and (\\ref{eq:term_1_in_good_set}),\n\\begin{align*}\n|G| &= n^2 (\\frac{6}{\\pi^2} + \\frac{1}{n})+ O(n \\log{n})\\\\\n|G| &= n^2 \\frac{6}{\\pi^2} + O(n \\log{n})\\\\\n\\frac{|G|}{n^2}&=\\frac{6}{\\pi^2} + O(1)\n\\end{align*}\nThus, as $n\\rightarrow \\infty$, the probability that two randomly chosen numbers do not have a common factor converges to $\\frac{6}{\\pi^2}$ $\\sim$ $60\\%$.\n\\end{proof}\n\n\\Lecture{Jayalal Sarma}{Sept 29, 2020}{09}{Surjections and Stirling numbers}{Raghul}{$\\alpha$}{JS}\n\n\\section{Introduction}\nIn this lecture, we will look at another application of Principle of Inclusion-Exclusion(PIE) - counting number of surjections. Later, we will look at a concept related to that application - Stirling numbers of the second kind.\n\n\\section{Applications of PIE} \\label{sec:Applications of PIE - lec2}\n\\subsection{Number of surjections from $[m]$ to $[n]$} \\label{subsec:surjections application}\nConsider $f : [m] \\rightarrow [n]$. The total number of functions is $n^m$ - each element in $[m]$ has $n$ choices for its image. The number of injections is ${n \\choose m}m!$ - the $m$ different images required can be chosen from $[n]$ in ${n \\choose m}$ ways and then these images can assigned their pre-images from $[m]$ in $m!$ ways. The number of surjections is not that obvious and can be derived using PIE.\\\\\n\\begin{theorem}\nThe number of surjections from $[m]$ to $[n]$ is given by\n$$\\sum_{k=0}^{n} (-1)^k (n-k)^m {n \\choose k}$$\n\\end{theorem}\n\\begin{proof}\nLet $X$ be the set of all functions from $[m]$ to $[n]$. We know that\n\\begin{align}\n    |X| = n^m \\label{eq:surjection:size(X)}\n\\end{align}\nLet us define $A_i$ ($\\subseteq X$) for all $i\\in[n]$ as follows.\n$$A_i = \\{f : [m] \\rightarrow [n] ~|~ \\forall j \\in [m],~ f(j) \\neq i\\} $$\nIn other words, $A_i$ is the set of functions in which the element $i$ in $[n]$  does not have a pre-image and hence any element in $A_i$ is a non-surjection. The union of all the $A_i$'s will be the set of all non-surjections.\\\\\nClearly, $|A_i| = (n-1)^m$ : since each element in $[m]$ has only $n-1$ choices for its image. Similarly, $\\forall i < j, ~|A_i\\cap A_j| = (n-2)^m$ and so on. Thus, for any $I \\subseteq [n]$,\n\\begin{align}\n|A_I| = |\\bigcap_{i \\in I} A_i| = (n-|I|)^m \\label{eq:surjection:size(A_I)}\n\\end{align}\nUsing PIE to find the number of non-surjections, \n\\begin{align}\n|\\bigcup_{i=1}^{n} A_i| &= \\sum_{\\emptyset \\neq I \\subseteq [n]} (-1)^{|I| +1} |A_I|\\nonumber\\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} \\sum_{I \\subseteq [n], |I| = k} |A_I|\\nonumber\\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} \\sum_{I \\subseteq [n], |I| = k} (n-k)^m \\nonumber\\tag{By \\ref{eq:surjection:size(A_I)}}\\\\\n&= \\sum_{k=1}^{n} (-1)^{k+1} (n-k)^m {n \\choose k} \\label{eq:surjection:size(unionA_i)}\n\\end{align}\nTherefore, the number of surjections is given by\n\\begin{align*}\n|X \\setminus \\bigcup_{i=1}^{n} A_i| &= |X| - |\\bigcup_{i=1}^{n} A_i|\\\\\n&= n^m - \\sum_{k=1}^{n} (-1)^{k+1} (n-k)^m {n \\choose k} \\tag{using \\ref{eq:surjection:size(X)} and \\ref{eq:surjection:size(unionA_i)}}\\\\\n&= (-1)^0 (n-0)^m {n \\choose 0}+ \\sum_{k=1}^{n} (-1)^{k} (n-k)^m {n \\choose k}\\\\\n&= \\sum_{k=0}^{n} (-1)^{k} (n-k)^m {n \\choose k}\n\\end{align*}\nThis completes the proof.\n\\end{proof}\n\\noindent\\\\\n\\section{Stirling numbers of the second kind}\nLet us now look at another way of counting the number of surjections - in terms of Stirling numbers of the second kind. The number of ways of partitioning $[n]$ into $k$ non-empty parts, where neither the order of the parts nor the order of elements within a part matter, is denoted by ${n \\brace k}$ and is a Stirling number of the second kind. \\\\\nFor example; ${4 \\brace 1} = 1$ because [1,2,3,4] is the only way of partitioning, ${4 \\brace 2} = 7$ because $[1,2,3|4]$, $[1,2,4|3]$, $[1,3,4|2]$, $[2,3,4|1]$, $[1,2|3,4]$, $[1,3|2,4]$ and $[1,4|2,3]$ are the ways of partitioning, ${4 \\brace 3} = 6$ because $[1,2|3|4]$, $[1,3|2|4]$, $[1,4|2|3]$, $[1|2,3|4]$, $[1|2,4|3]$ and $[1|2|3,4]$ are the ways of partitioning and ${4 \\brace 4}$ = 1 because $[1|2|3|4]$ is the only way of partitioning.\\\\ \\\\\nLet us now count the number of surjections from $[m]$ to $[n]$ in terms of Stirling numbers of the second kind. We know that in a surjection, every element in the co-domain $[n]$ has at least one pre-image. So, we could partition the domain $[m]$ into $n$ non-empty parts such that all the elements within a part have the same image in the co-domain. (For example; for $f : [5] \\rightarrow {0,1,2}$, $f(x) = x ~mod~3 $, the partition of the domain is $[1,4|2,5|3]$.) Such a partition could be done in ${m \\brace n}$ ways and then each of these parts can be assigned to one element in $[n]$ in $n!$ ways. Thus the number of surjections from $[m]$ to $[n]$ in terms of Stirling numbers of the second kind is ${m \\brace n}n!$. \\\\ \\\\\nWe have counted the number of surjections in 2 different ways (using PIE and in terms of ${m \\brace n}$). These two values should be equal and equating them would give us an expression for ${m \\brace n}$ as follows.\n\\begin{align*}\n    {m \\brace n}n! &= \\sum_{k=0}^{n} (-1)^{k} (n-k)^m {n \\choose k}\\\\\n    {m \\brace n} &= {\\frac{1}{n!}}\\sum_{k=0}^{n} (-1)^{k} (n-k)^m {n \\choose k}\n\\end{align*}\nIt is to be noted that by convention, ${0 \\brace 0} = 1$ and $\\forall n>0, {n \\brace 0} = {0 \\brace n} = 0$. \\\\\n\\begin{theorem} For any $n,k \\in \\N$;\n$${n \\brace k} = {n-1 \\brace k-1} + k {n-1 \\brace k}$$\n\\end{theorem}\n\\begin{proof}\nWe shall use double counting to prove this theorem. Let us count the number of ways of partitioning $[n]$ into $k$ non-empty parts.\\\\ Clearly, the L.H.S. of the equation is the number of ways of partitioning $[n]$ into $k$ non-empty parts. \\\\\nConsider the element $n$ in $[n]$; in a partition, this element can either be in a part of size $1$ or a part of size $\\geq 2$. The number of partitions in which $n$ is in a part of size $1$ is ${n-1 \\brace k-1}$ : $n$ is the only element in a part and then the remaining $n-1$ elements are to be partitioned into $k-1$ non-empty parts. The number of partitions in which $n$ is in a part of size $\\geq 2$ is $k {n-1 \\brace k}$ : the remaining $n-1$ elements are to be partitioned into $k$ non-empty parts and then $n$ is added to one of those parts in $k$ ways. Thus, the total number of partitions is ${n-1 \\brace k-1} + k {n-1 \\brace k}$, which is the R.H.S. of the equation.\\\\\nThese two methods have counted the same value and hence should be equal.\n\\end{proof}\n\\noindent\nThe equation stated in the theorem above is actually a very important property of Stirling numbers of the second kind. It is often used to connect any function or a set of numbers with the Stirling numbers of the second kind. \\\\\n\\section{Instances of Stirling numbers of the second kind}\nFollowing are some of the instances where Stirling numbers of second kind appear.\n\\subsection{$n^{th}$ derivative of $e^{e^x}$} \nThe $n^{\\text{th}}$ derivative of the function $f(x) = e^{e^x}$ is given by\n    $$f^{(n)}(x) = f(x) \\sum_{k=0}^{\\infty}{n \\brace k} e^{kx}$$\n\\subsection{Falling factorials of $x$}\nWe know that polynomials in one variable $x$ (like $4x^2+3x+2$, $10x^3+9x$, etc.) can be expressed as a linear combination of the powers of $x$ i.e. $x^0,x^1,x^2,\\ldots$. Thus, the powers of $x$ are said to form a basis for such polynomials. \\\\\n    The falling factorials of $x$ form another basis for polynomials in one variable $x$. The falling factorials are given by\n    \\begin{align*}\n        (x)_0 &= 1 &\n        (x)_1 &= x\\\\\n        (x)_2 &= x(x-1) &\n        for~ any~k > 0,~ (x)_k &= x(x-1)(x-2)\\ldots(x-k+1) \n    \\end{align*}\n    One can easily prove that the falling factorials form a basis for polynomials if it can be proved that $\\forall n$, $x^n$ is a linear combination of falling factorials (for any polynomial, write the polynomial as a linear combination of $x^n$'s and then replace $x^n$'s with the corresponding linear combinations of $(x)_n$'s).\n\\begin{theorem}Powers of $x$ can be written as the linear combination of falling factorials of $x$ using the following equation.\n    $$\\forall n, x^n \\equiv \\sum_{k=0}^n {n \\brace k} (x)_k$$\n\\end{theorem}    \n    \\begin{proof} (Note: This proof was done during the discussion session - not in the lecture video.)\\\\\n    Let the polynomial on the L.H.S. be $P(x)$ and that on the R.H.S. be $Q(x)$. In order to prove that $P(x) \\equiv Q(x)$, it is sufficient to prove that $P(x) = Q(x)$ for sufficiently large number of distinct values of $x$. The reasoning for the same is as follows.\\\\\n    One can clearly see that the degree of both $P(x)$ and $Q(x)$ is $n$. So, the maximum degree of the polynomial $R(x) = P(x) - Q(x)$ is also $n$. This implies that the maximum number of roots for the equation $R(x)=0$ is $n$. Therefore, if one can prove that $R(x)=0$ for at least $n+1$ distinct values of $x$, then it must be the case that $R(x) \\equiv 0$ and hence $P(x) \\equiv Q(x)$.\\\\\n    So, all we have to do now is to prove that $P(x) = Q(x)$ for at least $n+1$ distinct $x$'s where $n$ is the degree of the polynomial $P(x)$. Let us use double counting to prove this.\\\\\n    \\noindent\\\\\n    Let $x$ be any natural number. Let us count the number of different strings of length $n$ over \\{$1,2,3\\ldots x$\\} in two different ways. \n    \\begin{enumerate}\n        \\item Each character in the string can be chosen in $x$ ways and there are $n$ characters in total. Therefore the count is $x^n$ ($=P(x)$).  \n        \\item Let there be $k$ distinct characters in our string. Clearly, $0 \\leq k \\leq n$ and different values of $k$ would lead to different strings. So, we have to do summation over the value of $k$. Now, let us partition the $n$ available spaces into $k$ non-empty parts - so that spaces within the same part will get the same character and spaces in different parts get different characters. This partitioning can be done in ${n \\brace k}$ ways. There are $k$ parts now and we have to assign one character each to these parts from \\{$1,2,3\\ldots x$\\}. The character for the first part can be chosen in $x$ ways, for the second part it is $(x-1)$ ways, for the third part it is $(x-2)$ ways and so on until $(x-k+1)$ ways for the $k^{\\text{th}}$ part. Therefore, the count here is given by\n        \\begin{align*}\n            \\sum_{k=0}^{n}{n \\brace k} x(x-1)(x-2)\\ldots(x-k+1) = \\sum_{k=0}^{n}{n \\brace k} (x)_k = Q(x)\n        \\end{align*}\n    \\end{enumerate}\n    These two methods count the same number and hence they should be equal. Therefore, $\\forall x \\in \\N, ~ P(x)=Q(x)$, irrespective of the value of $n$. This means that for any $n$, we have proven that $P(x)=Q(x)$ for an infinite number of values of $x$. Hence, $\\forall n,~P(x)\\equiv Q(x)$.\n    \\end{proof}\n\\section{Other interesting types of numbers}\n\\subsection{Bell numbers ($B_n$) }\n    The number of ways of partitioning $[n]$ into non-empty parts is given by the Bell number $B_n$. It can clearly be seen that \n    $$B_n = \\sum_{k=0}^{n} {n \\brace k}$$\n    \\begin{figure}[h]\n        \\centering\n         \\includegraphics[scale = 0.7]{images/Stirling1.png}\n        \\caption{Permutations on 4 elements with 2 cycles }\n        \\label{Fig:StirlingI}\n    \\end{figure}\n\\subsection{Stirling numbers of the first kind (${n \\brack k}$)} The number of ways of permuting $n$ elements such that the permutations have $k$ cycles is given by the Stirling number of the first kind ${n \\brack k}$. Figure \\ref{Fig:StirlingI} shows all possible ways of permuting 4 elements with 2 cycles (${4 \\brack 2} = 11$). From the definition of ${n \\brack k}$, it can clearly be seen that $$n! = \\sum_{k=0}^{n} {n \\brack k}$$\n\n\n\\Lecture{Jayalal Sarma}{Sept 29, 2020}{10}{Tutte’s Matrix Tree Theorem and counting arborescences}{Raghul}{$\\alpha$}{JS}\n\\section{Introduction}\nIn this lecture, we will be looking at another application of the Principle of Inclusion-Exclusion(PIE) - Matrix Tree Theorem. We will understand the theorem and then we will cover all the bases required to prove the theorem. The proof of the theorem will be completed in the next lecture.\n\n\\section{Kirchoff’s Matrix Tree Theorem} \\label{sec:kirchoff's application}\nThe original theorem for undirected graphs was stated by Kirchoff in the 19th century and the generalised verion for directed graphs was stated by Tutte in the 20th century. This theorem is a classical bridge between combinatorial and algebraic quantities. Let us define few important terms before we jump into the theorems and proofs.\\\\\n\\begin{definition}\\textbf{Laplacian Matrix for undirected graphs:} \nFor any undirected graph $G(V,E)$ with $n$ vertices, let us define a $n$x$n$ matrix $L(G)$ called the \\textit{Laplacian matrix} of $G$ as follows.\n\\[\n  L(G)_{ij} = \n  \\begin{cases}\n    deg(v_i) &\\mbox{if }~ i = j\\\\\n    -1 &\\mbox{if }~ i \\neq j ~\\text{and}~(v_i,v_j)\\in E\\\\\n    0 &\\mbox{otherwise}\n  \\end{cases}\n\\]\n\\end{definition}\n\\noindent\nIt can also be noted that for a graph $G(V,E)$ without any self edges (i.e. $\\forall i, ~ (v_i,v_i) \\notin E$), the Laplacian matrix can also be defined as $L(G) = D - A$ where $D$ is a diagonal matrix with $D_{ii} = ~deg(v_i)$ and $A$ is the adjacency matrix of $G$.\n\\begin{theorem} Matrix Tree Theorem for undirected graphs by Kirchoff:\\\\\nFor any undirected graph $G(V,E)$, the number of different spanning trees rooted at $v_i$ contained in $G$ is given by $det(L_G[i])$ where $L_G[i]$ refers to the matrix obtained by removing the $i^{\\text{th}}$ row and the $i^{\\text{th}}$ column from $L(G)$ (for any $i \\in [n]$).\n\\end{theorem}\n\\noindent\nNote that the theorem has connected a combinatorial quantity to an algebraic one. It should also be noted that $det(L_G[i])$ is the same for every value of $i$ (since the number of undirected spanning trees does not change with the root $v_i$). The usual proof of this theorem is done using induction on the number of vertices. Instead we will use PIE to prove the generalised version and this theorem will follow as a consequence. Before doing the proof, let us cover few other concepts required for the proof.\n\\section{Determinant of a Matrix}\\label{sec:determinant of a matrix}\nFrom high school mathematics; we all know that for a 2x2 matrix $A$ and a 3x3 matrix $B$, the determinants are given by \n\\begin{align*}\n  det(A) &= a_{11}a_{22}-a_{12}a_{21}\\\\\n  det(B) &= b_{11}b_{22}b_{33}-b_{11}b_{23}b_{32}-b_{12}b_{21}b_{33}+b_{12}b_{23}b_{31}+b_{13}b_{21}b_{32}-b_{13}b_{22}b_{31}\n\\end{align*}\nIt is to be noticed that in the determinant expression of a $n$x$n$ matrix, the subscripts in each term match with one of the $n!$ possible permutations on $[n]$ and there are $n!$ terms in the expression. For example; the first term in the expression for $|A|$ represents the permutation $[1\\rightarrow1; ~2\\rightarrow2]$ and the other term represents $[1\\rightarrow2; ~2\\rightarrow1]$. Similarly, the second term in the expression for $|B|$ represents $[1\\rightarrow1; ~2\\rightarrow3;~3\\rightarrow2]$ while the fifth term represents $[1\\rightarrow3; ~2\\rightarrow1;~3\\rightarrow2]$.\\\\\nThus, each term in determinant expression of a $n$x$n$ matrix represents one of the permutations of $[n]$ and all the permutations are represented exactly once. In other words, given a permutation $\\sigma$ on $[n]$, the term $\\prod_{i=1}^{n} a_{i\\sigma(i)}$ appears exactly once in the expression of the determinant of a $n$x$n$ matrix $A$.\\\\\nGiven any permutation $\\sigma$ on $[n]$, we can represent it in the point representation as a $n$-tuple as $(\\sigma(1),\\sigma(2),\\sigma(3)\\ldots \\sigma(n))$. We can define the number of inversions of $\\sigma$ ($Inv(\\sigma)$) as follows.\n$$Inv(\\sigma) = |\\{(i,j)~|~i<j~\\text{and}~\\sigma(i)>\\sigma(j)\\}|$$\nFor example; for the permutation $\\sigma_1 = (1,3,2)$, $Inv(\\sigma_1) = 1$ (since (2,3) is the only such $(i,j)$ pair); for $\\sigma_2 = (3,1,2)$, $Inv(\\sigma_2) = 2$ (since (1,2) and (1,3) are the $(i,j)$ pairs) and for $\\sigma_3 = (3,2,1)$, $Inv(\\sigma_3) = 3$ (since (1,2), (2,3) and (1,3) are the $(i,j)$ pairs). \\\\\nIt can be noticed that the sign of a term representing the permutation $\\sigma$ in the determinant expression is given by\n$$Sign(\\sigma) = (-1)^{Inv(\\sigma)}$$\nFrom the inferences done above, one can logically guess the determinant expression for a $n$x$n$ matrix $A$ in terms of\n$Sign(\\sigma)$ and $\\prod_{i=1}^{n} a_{i\\sigma(i)}$. However, until proven mathematically, this remains nothing more than a logical guess. So, let us state this as a theorem and prove it.\n\\begin{theorem}\nFor any $n \\in \\N$, the determinant of the $n^{\\text{th}}$ order square matrix $A$ is given by\n$$det(A) = \\sum_{\\sigma \\in S_n} Sign(\\sigma)  \\prod_{i=1}^{n} a_{i\\sigma(i)}$$\nwhere $S_n$ is the set of all permutations on $[n]$. \n\\end{theorem}\n\\begin{proof}\nWe know that the determinant of any matrix $A$ follows the following four properties.\n\\begin{enumerate}\n    \\item If all the elements in a row of $A$ are 0, then $det(A)=0$\n    \\item If two rows of $A$ are identical, then $det(A)=0$\n    \\item If a row of $A$ is a multiple of another row, then $det(A)=0$\n    \\item Adding the multiple of a row of $A$ to another row, does not change the value of $det(A)$\n\\end{enumerate}\nThough not done as part of the lecture, it can be proven that there is only one expression in terms of $a_{ij}$'s that satisfies all the four properties. Therefore, it is sufficient to prove that the expression given in the theorem satisfies all the four properties stated above to prove the whole theorem. \\\\\nLet us now prove the first property : Let all the elements in row $k$ be 0 i.e. $\\forall_{j\\in[n]}~ a_{kj} = 0$. It can clearly be seen that each term in the determinant expression stated in the theorem has some $a_{k\\sigma(k)}$ in it. So each term will be 0 and hence $det(A)=0$. \\\\\nProving that the expression stated in the theorem satisfies the other three properties is left as an exercise for the students.\n\\end{proof}\n\n\\section{Applications of PIE} \\label{sec:Applications of PIE - lec3}\n\\subsection{Tutte’s Matrix Tree Theorem} \\label{subsec:tutte's application}\n Now, let us continue our journey towards stating and proving Tutte's Matrix Tree Theorem. Firstly, let us define Spanning Arborescences - the directed graphs equivalent for spanning trees and Laplacian matrix for directed graphs.\n\\begin{definition}\\textbf{Spanning Arborescences:} An \\textit{Arborescence} is a directed graph in which a vertex $u$ is called the root and for every other vertex $v$ in the graph, there is exactly one directed path from $u$ to $v$. In simpler terms, an arborescence is an directed tree in which all the edges are directed away from the root. A \\textit{Spanning Arborescence} $S(V,E)$ of a directed graph $G(V',E')$ is an arborescence such that $V=V'$ and $E\\subseteq E'$.\n\\end{definition}\n\\noindent\\\\\n\\begin{definition}\\textbf{Laplacian matrix for directed graphs:} For any directed graph $G(V,E)$ with $n$ vertices, let us define a $n$x$n$ matrix $L(G)$ called the \\textit{Laplacian matrix} of $G$ as follows.\n\\[\n  L(G)_{ij} = \n  \\begin{cases}\n    indeg(v_i) &\\mbox{if }~ i = j\\\\\n    -1 &\\mbox{if }~ i \\neq j ~\\text{and}~(v_i,v_j)\\in E\\\\\n    0 &\\mbox{otherwise}\n  \\end{cases}\n\\]\n\\end{definition}\n\\begin{theorem} Tutte's Matrix Tree Theorem for directed graphs\\\\\nFor any directed graph $G(V,E)$, the number of different spanning arborescences rooted at $v_i$ contained in $G$ is given by $det(L_G[i])$ where $L_G[i]$ refers to the matrix obtained by removing the $i^{\\text{th}}$ row and the $i^{\\text{th}}$ column from $L(G)$ (for any $i \\in [n]$).\n\\end{theorem}\n\\noindent\nNote that since spanning arborescences are directed, the number of spanning arborecences depend on the chosen root. Hence, unlike the undirected case, $det(L_G[i])$ here depends on the value of $i$. Without loss of generality, we can choose $i = n$ for our proof. Therefore, all we should prove is the number of spanning arborescences rooted at $v_n$ for the directed graph $G$ is given by\n\\begin{align}\n    det(L_G[n]) = \\sum_{\\sigma \\in S_{n-1}}~\n    Sign(\\sigma)~\\prod_{i=1}^{n-1}l_{i\\sigma(i)}\n    \\label{eq:to_prove:Tutte}\n\\end{align} \nThe R.H.S. of the equation is the determinant expression for the $(n-1)$x$(n-1)$ matrix $(L_G[n])$.\\\\Now let us define another type of directed graphs called Spregs to help with our proof process.\\\\\n\\noindent\\\\\n\\begin{definition}\\textbf{Spregs:} Single prdecessor graphs or \\textit{Spregs} with distinguished vertex $v$ of a directed graph $G(V,E)$ is a subgraph $T(V,E')$, $E' \\subseteq E$, such that each vertex in $T$ except the vertex $v$ has exactly one predecessor and the vertex $v$ has no predecessors. In other words; in the spreg T, $indeg(v) = 0$ and for every $u \\neq v$, $indeg(u)=1$.\\\\\n\\end{definition}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale = 0.5]{images/Spreg1.png}\n    \\caption{Both spreg and arborescence}\n    \\label{Fig:Spreg1}\n\\end{figure}\n\\begin{figure}[h]\n    \\centering\n    \\includegraphics[scale = 0.6]{images/Spreg2.png}\n    \\caption{Spreg but not arborescence}\n    \\label{Fig:Spreg2}\n\\end{figure}\n\\noindent\\\\\nIt is important to distinguish between spregs and spanning arborescences : spregs may contain disconnected components and cycles in them. On the other hand, spanning arborescences are directed spanning trees and hence are single connected components and do not have cycles in them. The directed graph in figure \\ref{Fig:Spreg1} is a spreg with distinguished vertex $A$ and an arborescence rooted at $A$. On the other hand, the graph in figure \\ref{Fig:Spreg2} is a spreg with distinguished vertex $A$ but not an arborescence. Now let us consider the following lemma and prove it.\n\\noindent\\\\\n\\begin{lemma} If $T(V,E)$ is a spanning arborescence rooted at $v$, then $T$ is a spreg with distinguished vertex $v$.\n\\end{lemma}\n\\begin{proof}\nLet $T(V,E)$ is a spanning arborescence rooted at $v$. We know from the definition that for every other vertex $u$ in $T$, there is a unique directed path from $v$ to $u$. The underlying undirected graph of $T$ is a tree and does not have any cycles and hence there should not be any cycles (directed/undirected) in $T$.\\\\\nLet us now assume that $indeg(v) \\neq 0$. This means that there exists a vertex $u$ in $T$ such that the edge $e = (u,v)\\in E$. We know that there is a unique path in $T$ from $v$ to $u$ - let that path be $P$. Now the path $P+e$ is a directed cycle in $T$. A contradiction. Therefore, $indeg(v) = 0$.\\\\\nLet us now assume that for some $u \\neq v$ in $T$, $indeg(u) = 0$. This implies that T is not a spanning arborescence.  A contradiction. Therefore, $indeg(u) > 0$. \\\\\nLet us now assume that for some $u \\neq v$ in $T$, $indeg(u) \\geq 2$. This implies $\\exists u_1 \\neq u_2$ such that $e_1 = (u_1,u) \\in E$ and $e_2 = (u_2,u) \\in E$. We know that there exists a unique path $P_1$ from $v$ to $u_1$ and another path $P_2$ from $v$ to $u_2$. Since $u_1 \\neq u_2$, $P_1 \\neq P_2$. Now, $P_1+e_1$ and $P_2+e_2$ are two distinct paths from $v$ to $u$. A contradiction. Therefore, $indeg(u) = 1$.\\\\\nTherefore,  $indeg(v) = 0$ and for every other vertex $u$, $indeg(u) = 1$. In other words, $T$ is a spreg with distinguished vertex $v$.\n\\end{proof}\n\\noindent It is important to note that the converse of the above stated lemma is not true because spregs may contain discconnected components and cycles in them. Now, we will look at another lemma.\n\\noindent\\\\\n\\begin{lemma} If $T(V,E)$ is a spreg with distinguished vertex $v$, then the spreg consists of an arborescence rooted at $v$ and zero or more weakly connected components (the underlying undirected component is connected). Each of these weakly connected components have exactly one directed cycle in them.\n\\end{lemma}\n\\begin{proof}\nThe proof of this lemma is left as an exercise for the students to complete.\n\\end{proof}\n\\noindent Thus; (a spreg  with distinguished vertex $v$) = (an arborescence rooted at $v$) + $k$ (weakly connected components with one directed cycle each); where $k \\geq 0$. \\\\\n\\noindent\\\\\nFor proving Tutte's theorem; the idea to count the number of arborescences rooted at $v_n$ is that we would count the number of spregs with distinguished vertex $v_n$ and then remove the number of spregs that are not arborescences - the terms in such a expression would exactly match with that of the R.H.S. of \\ref{eq:to_prove:Tutte}.\\\\\n\\noindent\\\\\nIn the R.H.S. of \\ref{eq:to_prove:Tutte}, consider the term for $\\sigma =$ identity permutation i.e. $\\forall i,~ \\sigma(i)=i$. Clearly, $Sign(\\sigma)=1$ since $Inv(\\sigma)=0$. The term would be $+ \\prod_{i=1}^{n-1}l_{ii}$. This is exactly equal to the total number of spregs with distinguished vertex $v_n$ - the reasoning is as follows.\\\\\nSince $v_n$ is the distinguished vertex, ignore all the edges whose end vertex is $v_n$. For every other vertex $u$, choose exactly one of the edges whose end vertex is $u$ ($\\prod_{i=1}^{n-1}indeg(v_i)$ ways). Clearly, such a subgraph is a spreg - by definition of spregs. Therefore, the number of distinct spregs is $\\prod_{i=1}^{n-1}indeg(v_i) = \\prod_{i=1}^{n-1}l_{ii}$ (by the definition of Laplacian matrix). \\\\\n\\noindent\\\\\nWe have counted all the spregs; now, spregs with cycles have to be removed from the count. This part of the proof involves PIE and will be done in the next lecture.\n\n", "meta": {"hexsha": "b524a861a2c35ef20c7739ee936d84a562e90477", "size": 44370, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week03.tex", "max_stars_repo_name": "Achyuth-Prakash/theory-toolkit", "max_stars_repo_head_hexsha": "a717e5fecdb6a52689fadd6e64baa23182f15435", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week03.tex", "max_issues_repo_name": "Achyuth-Prakash/theory-toolkit", "max_issues_repo_head_hexsha": "a717e5fecdb6a52689fadd6e64baa23182f15435", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-10-08T07:34:26.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-30T06:06:12.000Z", "max_forks_repo_path": "week03.tex", "max_forks_repo_name": "Achyuth-Prakash/theory-toolkit", "max_forks_repo_head_hexsha": "a717e5fecdb6a52689fadd6e64baa23182f15435", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2020-09-25T01:35:07.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-28T11:22:06.000Z", "avg_line_length": 90.736196319, "max_line_length": 795, "alphanum_fraction": 0.6800991661, "num_tokens": 15114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5234203638047913, "lm_q2_score": 0.7745833945721304, "lm_q1q2_score": 0.4054327221840947}}
{"text": "The Integrated Information Theory (IIT) has is proposed as a mathematical way to understand consciousness.\nIt revolves around analyzing the phenomenology of a system, that is, how a system experiences the environment.\nIIT 3.0 mostly does this by finding the maximally irreducible conceptual structures formed by a causal structure interacting with the environment.\nThe theory tries to assume properties of consciousness (axioms), and from there, it postulates the properties that must be necessary for a physical substrate hosting the system.\nThe causal structure, also called a cause-effect structure (CES), is analyzed to find conceptual structures that measure how well a system integrates information.\nA more substantial amount of integrated information results in a higher amount of possible states in the system.\nIntegrated information is when there is no way to cut the CES without losing information.\nThe CES is an unfolding of a model of the neural substrate in the sense that the model is cut in every possible way (imagine cutting a network of nodes).\nThe CES maps to the properties of experience, and the CES can be quantified by $\\Phi$ \\cite{oizumi_phenomenology_2014}.\n\nAlthough IIT might seem overly abstract, the first tangible result was published as a study on the question \"Why does space feel the way it does?\".\nHere a model of the Visual Cortex 1 and 2 (V1 and V2) was cut into a CES, using the knowledge of the grid cells that are proven to be essential for localization \\cite{haun_why_2019}.\n\n\\paragraph{A summary of corollaries} of IIT, based on the article by Oizumi et. al \\cite{oizumi_phenomenology_2014}:\nAn intelligent system will usually consist of a main \\textbf{complex}, and smaller supporting complexes.\nThis central complex will be the most conscious part of the system, like the part of our brain that we could not function without, while the supporting complexes could be compared to smaller parts of the brain, like, for example, the visual cortex.\nIntelligent systems will not be modular, that is, if the system produces less functionality than their components, and they have to produce functionality that is more than a higher order of the combined components.\nInactive systems can be conscious in the way that a system may have significant parts that are ready to be activated or that are passively affecting the state of the system.\nA system can perform very complex functions but still not be conscious.\nIn particular, feed-forward networks would not be conscious.\nAn example if this is a microprocessor implementing a neural network that, in some cases, can recognize thousands of different objects faster than a human can recognize one object.\nIIT states that it is not only the functionality of a system that determines how conscious it is but also how the function performs internally.\nA network that can recognize objects based on internal states and previous experiences is more conscious compared to a feed-forward neural network, which only recognizes the object based on the external input it gets.\nNetworks that are not necessarily feed-forward only, but simulated on a physical substrate that implements functionality based on numerical approximation, would not be termed conscious in IIT 3.0 \\cite{marshall_integrated_2016}.\nA final corollary that summarises the ones above says that an intelligent system can develop concepts based on other concepts within itself without the need for external stimuli.\nThese internal concepts would more often be connected to a large number of other concepts and not contribute to specific details.\n\n\\paragraph{In this project} I hope to utilize IIT as a way to analyze the perception of automated agents, evolved as SNN \\vref{sect:snn} animats \\vref{sect:agent} on BrainScaleS \\vref{sect:bss}.\nAs the complexity and states of the animats are known, the animats can be analyzed.\nAnalyzing the animats in regards to IIT will only be attempted if time permits.\n", "meta": {"hexsha": "efe4c2ebb16685a01e0bdff0c05f7397704757c6", "size": 3950, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mymaster/sections/iit.tex", "max_stars_repo_name": "danxan/neuromorphic-evolution", "max_stars_repo_head_hexsha": "e934d1491b22a8441e124927c3daaba74231e1bc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mymaster/sections/iit.tex", "max_issues_repo_name": "danxan/neuromorphic-evolution", "max_issues_repo_head_hexsha": "e934d1491b22a8441e124927c3daaba74231e1bc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mymaster/sections/iit.tex", "max_forks_repo_name": "danxan/neuromorphic-evolution", "max_forks_repo_head_hexsha": "e934d1491b22a8441e124927c3daaba74231e1bc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 127.4193548387, "max_line_length": 248, "alphanum_fraction": 0.8139240506, "num_tokens": 810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585903489892, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4053503965041186}}
{"text": "\\par\n\\section{Prototypes and descriptions of {\\tt MT} methods}\n\\label{section:MT:proto}\n\\par\nThis section contains brief descriptions including prototypes\nof all methods found in the {\\tt MT} source directory.\n\\par\n\\subsection{Matrix-matrix multiply methods}\n\\label{subsection:MT:proto:mvm}\n\\par\nThere are five methods to multiply a vector times a dense matrix.\nThe first three methods, called {\\tt InpMtx\\_MT\\_nonsym\\_mmm*()}, \nare straightforward,\n$y := y + \\alpha A x$, where $A$ is nonsymmetric, and $\\alpha$ is\nreal (if $A$ is real) and complex (if $A$ is complex).\nThe fourth method, {\\tt InpMtx\\_MT\\_sym\\_mmm()}, \nis used when the matrix is real symmetric or complex symmetric, \nthough it is not necessary that only the lower or upper\ntriangular entries are stored.\n(If one fills the {\\tt InpMtx} object with only the entries in\nthe lower triangle of $A$, and then permute the matrix $PAP^T$,\nthe entries will not generally be found in only the lower or upper\ntriangle. However, the code is still correct.)\nThe last method, \n{\\tt InpMtx\\_MT\\_herm\\_mmm()}, is used when the matrix is\ncomplex hermitian.\n\\par\n%=======================================================================\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid InpMtx_MT_nonsym_mmm ( InpMtx *A, DenseMtx *Y, double alpha[], DenseMtx *X,\n                            int nthread, int msglvl, int msgFile ) ;\nvoid InpMtx_MT_sym_mmm ( InpMtx *A, DenseMtx *Y, double alpha[], DenseMtx *X,\n                            int nthread, int msglvl, int msgFile ) ;\nvoid InpMtx_MT_herm_mmm ( InpMtx *A, DenseMtx *Y, double alpha[], DenseMtx *X,\n                            int nthread, int msglvl, int msgFile ) ;\n\\end{verbatim}\n\\index{InpMtx_MT_nonsym_mmm@{\\tt InpMtx\\_MT\\_nonsym\\_mmm()}}\n\\index{InpMtx_MT_sym_mmm@{\\tt InpMtx\\_MT\\_sym\\_mmm()}}\n\\index{InpMtx_MT_herm_mmm@{\\tt InpMtx\\_MT\\_herm\\_mmm()}}\nThese methods compute the matrix-vector product $y := y + \\alpha A x$,\nwhere $y$ is found in the {\\tt Y DenseMtx} object,\n$\\alpha$ is real or complex in {\\tt alpha[]},\n$A$ is found in the {\\tt A Inpmtx} object, and\n$x$ is found in the {\\tt X DenseMtx} object.\nIf any of the input objects are {\\tt NULL}, an error message is\nprinted and the program exits.\n{\\tt A}, {\\tt X} and {\\tt Y} must all be real or all be complex.\nWhen {\\tt A} is real, then $\\alpha$ = {\\tt alpha[0]}.\nWhen {\\tt A} is complex, then $\\alpha$ = \n{\\tt alpha[0]} + i* {\\tt alpha[1]}.\nThis means that one cannot call the methods with a constant as the\nthird parameter, e.g.,\n{\\tt InpMtx\\_MT\\_nonsym\\_mmm(A, Y, 3.22, X, nthread, msglvl, msgFile)},\nfor this may result in a segmentation violation.\nThe values of $\\alpha$ must be loaded into an array of length 1 or 2.\nThe number of threads is specified by the {\\tt nthread} parameter;\nif, {\\tt nthread} is {\\tt 1}, the serial method is called.\nThe {\\tt msglvl} and {\\tt msgFile} parameters are used for\ndiagnostics during the creation of the threads' individual data\nstructures.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt A}, {\\tt Y} or {\\tt X} are {\\tt NULL},\nor if {\\tt coordType} is not {\\tt INPMTX\\_BY\\_ROWS},\n{\\tt INPMTX\\_BY\\_COLUMNS} or {\\tt INPMTX\\_BY\\_CHEVRONS},\nor if {\\tt storageMode} is not one of {\\tt INPMTX\\_RAW\\_DATA},\n{\\tt INPMTX\\_SORTED} or {\\tt INPMTX\\_BY\\_VECTORS},\nor if {\\tt inputMode} is not {\\tt SPOOLES\\_REAL} or\n{\\tt SPOOLES\\_COMPLEX},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid InpMtx_MT_nonsym_mmm_T ( InpMtx *A, DenseMtx *Y, double alpha[], DenseMtx *X,\n                            int nthread, int msglvl, int msgFile ) ;\n\\end{verbatim}\n\\index{InpMtx_MT_nonsym_mmm_T@{\\tt InpMtx\\_MT\\_nonsym\\_mm\\_Tm()}}\nThis method computes the matrix-vector product $y := y + \\alpha A^T x$,\nwhere $y$ is found in the {\\tt Y DenseMtx} object,\n$\\alpha$ is real or complex in {\\tt alpha[]},\n$A$ is found in the {\\tt A Inpmtx} object, and\n$x$ is found in the {\\tt X DenseMtx} object.\nIf any of the input objects are {\\tt NULL}, an error message is\nprinted and the program exits.\n{\\tt A}, {\\tt X} and {\\tt Y} must all be real or all be complex.\nWhen {\\tt A} is real, then $\\alpha$ = {\\tt alpha[0]}.\nWhen {\\tt A} is complex, then $\\alpha$ = \n{\\tt alpha[0]} + i* {\\tt alpha[1]}.\nThis means that one cannot call the methods with a constant as the\nthird parameter, e.g.,\n{\\tt InpMtx\\_MT\\_nonsym\\_mmm(A, Y, 3.22, X, nthread, msglvl, msgFile)},\nfor this may result in a segmentation violation.\nThe values of $\\alpha$ must be loaded into an array of length 1 or 2.\nThe number of threads is specified by the {\\tt nthread} parameter;\nif, {\\tt nthread} is {\\tt 1}, the serial method is called.\nThe {\\tt msglvl} and {\\tt msgFile} parameters are used for\ndiagnostics during the creation of the threads' individual data\nstructures.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt A}, {\\tt Y} or {\\tt X} are {\\tt NULL},\nor if {\\tt coordType} is not {\\tt INPMTX\\_BY\\_ROWS},\n{\\tt INPMTX\\_BY\\_COLUMNS} or {\\tt INPMTX\\_BY\\_CHEVRONS},\nor if {\\tt storageMode} is not one of {\\tt INPMTX\\_RAW\\_DATA},\n{\\tt INPMTX\\_SORTED} or {\\tt INPMTX\\_BY\\_VECTORS},\nor if {\\tt inputMode} is not {\\tt SPOOLES\\_REAL} or\n{\\tt SPOOLES\\_COMPLEX},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid InpMtx_MT_nonsym_mmm_H ( InpMtx *A, DenseMtx *Y, double alpha[], DenseMtx *X,\n                            int nthread, int msglvl, int msgFile ) ;\n\\end{verbatim}\n\\index{InpMtx_MT_nonsym_mmm_H@{\\tt InpMtx\\_MT\\_nonsym\\_mmm\\_H()}}\nThis method computes the matrix-vector product $y := y + \\alpha A^H x$,\nwhere $y$ is found in the {\\tt Y DenseMtx} object,\n$\\alpha$ is complex in {\\tt alpha[]},\n$A$ is found in the {\\tt A Inpmtx} object, and\n$x$ is found in the {\\tt X DenseMtx} object.\nIf any of the input objects are {\\tt NULL}, an error message is\nprinted and the program exits.\n{\\tt A}, {\\tt X} and {\\tt Y} must all be complex.\nThe number of threads is specified by the {\\tt nthread} parameter;\nif, {\\tt nthread} is {\\tt 1}, the serial method is called.\nThe {\\tt msglvl} and {\\tt msgFile} parameters are used for\ndiagnostics during the creation of the threads' individual data\nstructures.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt A}, {\\tt Y} or {\\tt X} are {\\tt NULL},\nor if {\\tt coordType} is not {\\tt INPMTX\\_BY\\_ROWS},\n{\\tt INPMTX\\_BY\\_COLUMNS} or {\\tt INPMTX\\_BY\\_CHEVRONS},\nor if {\\tt storageMode} is not one of {\\tt INPMTX\\_RAW\\_DATA},\n{\\tt INPMTX\\_SORTED} or {\\tt INPMTX\\_BY\\_VECTORS},\nor if {\\tt inputMode} is not {\\tt SPOOLES\\_COMPLEX},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n\\subsection{Multithreaded Factorization methods}\n\\label{subsection:FrontMtx:proto:factorMT}\n\\par\n%=======================================================================\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nChv * FrontMtx_MT_factorInpMtx ( FrontMtx *frontmtx, InpMtx *inpmtx, \n             double tau, double droptol, ChvManager *chvmanager,\n             IV *ownersIV, int lookahead, double cpus[], int stats[],  \n             int msglvl, FILE *msgFile ) ;\nChv * FrontMtx_MT_factorPencil ( FrontMtx *frontmtx, Pencil *pencil, \n             double tau, double droptol, ChvManager *chvmanager,\n             IV *ownersIV, int lookahead, double cpus[], int stats[],  \n             int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{FrontMtx_MT_factorInpMtx@{\\tt FrontMtx\\_MT\\_factorInpMtx()}}\n\\index{FrontMtx_MT_factorPencil@{\\tt FrontMtx\\_MT\\_factorPencil()}}\nThese two methods compute a multithreaded factorization for a matrix\n$A$ (stored in {\\tt inpmtx}) or a matrix pencil\n$A + \\sigma B$ (stored in {\\tt pencil}).\nThe {\\tt tau} parameter is used when pivoting is enabled, each\nentry in $U$ and $L$ (when nonsymmetric) will have magnitude less\nthan or equal to {\\tt tau}.\nThe {\\tt droptol} parameter is used when the fronts are stored in\na sparse format, each entry in $U$ and $L$ (when nonsymmetric) \nwill have magnitude greater than or equal to {\\tt droptol}.\nThe map from fronts to owning processes is found in {\\tt ownersIV}.\nThe {\\tt lookahead} parameter governs the\n``upward--looking'' nature of the computations.\nChoosing {\\tt lookahead = 0} is usually the most conservative with\nrespect to working storage, while positive values increase the\nworking storage and sometimes decrease the factorization time.\nOn return, the {\\tt cpus[]} vector is filled with the following\ninformation.\n\\begin{itemize}\n\\item\n{\\tt cpus[0]} --- time spent managing working storage.\n\\item\n{\\tt cpus[1]} --- time spent initializing the fronts\n                  and loading the original entries.\n\\item\n{\\tt cpus[2]} --- time spent accumulating updates from descendents.\n\\item\n{\\tt cpus[3]} --- time spent inserting aggregate fronts.\n\\item\n{\\tt cpus[4]} --- time spent removing and assembling aggregate fronts.\n\\item\n{\\tt cpus[5]} --- time spent assembling postponed data.\n\\item\n{\\tt cpus[6]} --- time spent to factor the fronts.\n\\item\n{\\tt cpus[7]} --- time spent to extract postponed data.\n\\item\n{\\tt cpus[8]} --- time spent to store the factor entries.\n\\item\n{\\tt cpus[9]} --- miscellaneous time.\n\\end{itemize}\nOn return, the {\\tt stats[]} vector is filled with the following\ninformation.\n\\begin{itemize}\n\\item\n{\\tt stats[0]} --- number of pivots.\n\\item\n{\\tt stats[1]} --- number of pivot tests.\n\\item\n{\\tt stats[2]} --- number of delayed rows and columns.\n\\item\n{\\tt stats[3]} --- number of entries in $D$.\n\\item\n{\\tt stats[4]} --- number of entries in $L$.\n\\item\n{\\tt stats[5]} --- number of entries in $U$.\n\\item\n{\\tt stats[6]} --- number of locks of the {\\tt FrontMtx} object.\n\\item\n{\\tt stats[7]} --- number of locks of aggregate list.\n\\item\n{\\tt stats[8]} --- number of locks of postponed list.\n\\end{itemize}\n\\par \\noindent {\\it Error checking:}\nIf {\\tt frontmtx}, {\\tt inpmtxA}, {\\tt cpus} or {\\tt stats}\nis {\\tt NULL},\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n\\subsection{Multithreaded $QR$ Factorization method}\n\\label{subsection:FrontMtx:proto:factorQR_MT}\n\\par\n%=======================================================================\n\\begin{enumerate}\n%-----------------------------------------------------------------------\n\\item\n\\begin{verbatim}\nvoid FrontMtx_MT_QR_factor ( FrontMtx *frontmtx, InpMtx *mtxA,\n                             ChvManager *chvmanager, IV *ownersIV, double cpus[],\n                             double *pfacops,  int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{FrontMtx_MT_QR_factor@{\\tt FrontMtx\\_MT\\_QR\\_factor()}}\nThis method computes the\n$(U^T+I)D(I+U)$ factorization of $A^TA$ if $A$ is real\nor\n$(U^H+I)D(I+U)$ factorization of $A^HA$ if $A$ is complex.\nThe {\\tt chvmanager} object manages the working storage.\nThe map from fronts to threads is found in {\\tt ownersIV}.\nOn return, the {\\tt cpus[]} vector is filled as follows.\n\\begin{itemize}\n\\item\n{\\tt cpus[0]} -- time to set up the factorization.\n\\item\n{\\tt cpus[1]} -- time to set up the fronts.\n\\item\n{\\tt cpus[2]} -- time to factor the matrices.\n\\item\n{\\tt cpus[3]} -- time to scale and store the factor entries.\n\\item\n{\\tt cpus[4]} -- time to store the update entries\n\\item\n{\\tt cpus[5]} -- miscellaneous time\n\\item\n{\\tt cpus[6]} -- total time\n\\end{itemize}\nOn return, {\\tt *pfacops} contains the number of floating point\noperations done by the factorization.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt frontmtx}, {\\tt frontJ} or {\\tt chvmanager} is {\\tt NULL},\nor if {\\tt msglvl > 0} and {\\tt msgFile} is {\\tt NULL},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n\\subsection{Multithreaded Solve method}\n\\label{subsection:FrontMtx:proto:solve-multithreaded}\n\\par\n\\begin{enumerate}\n%=======================================================================\n\\item\n\\begin{verbatim}\nvoid FrontMtx_MT_solve ( FrontMtx *frontmtx, DenseMtx *mtxX, DenseMtx *mtxB,\n                         SubMtxManager *mtxmanager, SolveMap *solvemap,\n                         double cpus[], int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{FrontMtx_MT_solve@{\\tt FrontMtx\\_MT\\_solve()}}\nThis method is used to solve one of three linear systems of equations\nusing a multithreaded solve\n---\n$(U^T + I)D(I + U) X = B$,\n$(U^H + I)D(I + U) X = B$ or\n$(L + I)D(I + U) X = B$.\nEntries of $B$ are {\\it read} from {\\tt mtxB} and\nentries of $X$ are written to {\\tt mtxX}.\nTherefore, {\\tt mtxX} and {\\tt mtxB} can be the same object.\n(Note, this does not hold true for an MPI factorization with pivoting.)\nThe submatrix manager object manages the working storage.\nThe {\\tt solvemap} object contains the map from submatrices to\nthreads.\nThe map from fronts to processes that own them is given in the {\\tt\nownersIV} object.\nOn return the {\\tt cpus[]} vector is filled with the following.\nThe {\\tt stats[]} vector is not currently used.\n\\begin{itemize}\n\\item\n{\\tt cpus[0]} --- set up the solves\n\\item\n{\\tt cpus[1]} --- fetch right hand side and store solution\n\\item\n{\\tt cpus[2]} --- forward solve\n\\item\n{\\tt cpus[3]} --- diagonal solve\n\\item\n{\\tt cpus[4]} --- backward solve\n\\item\n{\\tt cpus[5]} --- total time in the method.\n\\end{itemize}\n\\par \\noindent {\\it Error checking:}\nIf {\\tt frontmtx}, {\\tt rhsmtx}, {\\tt mtxmanager},\n{\\tt solvemap}, {\\tt cpus} or {\\tt stats} is {\\tt NULL},\nor if {\\tt msglvl} > 0 and {\\tt msgFile} is {\\tt NULL},\nan error message is printed and the program exits.\n%-----------------------------------------------------------------------\n\\end{enumerate}\n\\par\n\\subsection{Multithreaded $QR$ Solve method}\n\\label{subsection:FrontMtx:proto:QRsolve-MT}\n\\par\n\\begin{enumerate}\n%=======================================================================\n\\item\n\\begin{verbatim}\nvoid FrontMtx_MT_QR_solve ( FrontMtx *frontmtx, InpMtx *mtxA, DenseMtx *mtxX,\n              DenseMtx *mtxB, SubMtxManager *mtxmanager, SolveMap *solvemap,\n              double cpus[], int msglvl, FILE *msgFile ) ;\n\\end{verbatim}\n\\index{FrontMtx_MT_QR_solve@{\\tt FrontMtx\\_MT\\_QR\\_solve()}}\nThis method is used to minimize $\\|B - AX\\|_F$, where\n$A$ is stored in {\\tt mtxA},\n$B$ is stored in {\\tt mtxB},\nand $X$ will be stored in {\\tt mtxX}.\nThe {\\tt frontmtx} object contains a\n$(U^T+I)D(I+U)$ factorization of $A^TA$ if $A$ is real\nor\n$(U^H+I)D(I+U)$ factorization of $A^HA$ if $A$ is complex.\nWe solve the seminormal equations\n$(U^T+I)D(I+U)X = A^TB$ or $(U^H+I)D(I+U)X = A^HB$\nfor $X$.\nOn return the {\\tt cpus[]} vector is filled with the following.\n\\begin{itemize}\n\\item\n{\\tt cpus[0]} --- set up the solves\n\\item\n{\\tt cpus[1]} --- fetch right hand side and store solution\n\\item\n{\\tt cpus[2]} --- forward solve\n\\item\n{\\tt cpus[3]} --- diagonal solve\n\\item\n{\\tt cpus[4]} --- backward solve\n\\item\n{\\tt cpus[5]} --- total time in the solve method.\n\\item\n{\\tt cpus[6]} --- time to compute $A^TB$ or $A^HB$.\n\\item\n{\\tt cpus[7]} --- total time.\n\\end{itemize}\nOnly the solve is presently done in parallel.\n\\par \\noindent {\\it Error checking:}\nIf {\\tt frontmtx}, {\\tt mtxA}, {\\tt mtxX}, {\\tt mtxB}, {\\tt mtxmanager},\n{\\tt solvemap} or {\\tt cpus} is {\\tt NULL},\nor if {\\tt msglvl} > 0 and {\\tt msgFile} is {\\tt NULL},\nan error message is printed and the program exits.\n%=======================================================================\n\\end{enumerate}\n\n\n", "meta": {"hexsha": "02ae129cd299f5effdb6105191e944b87e05a4e6", "size": 15655, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/MT/doc/proto.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/MT/doc/proto.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/MT/doc/proto.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 41.4153439153, "max_line_length": 82, "alphanum_fraction": 0.6434366017, "num_tokens": 4594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585903489892, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4053503965041186}}
{"text": "% !TeX root = ../main.tex\n\n\\section{Introduction}\nThe idea of the recursive nearest neighbors method came up in the process of studying\nrecommender systems in the framework of this thesis. The method that will be presented is an\neffort to overcome the limitations of neighborhood-based approach. That is, to provide more\nrating predictions than the conventional K-Nearest Neighbors method, which fails when it\ncannot connect users or items directly due to sparseness constraints.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{ |c|c|c|c|c|c|c| }\n\\hline\n\\diagbox{$User$}{$Item$} & \\textbf{$Item_1$} & \\textbf{$Item_2$} & \\textbf{$Item_3$} & \\textbf{$Item_4$}  & \\textbf{$Item_5$} & \\textbf{$Item_6$} \\\\\n\\hline\n\\textbf{$User_1$} & 5 & 2 & 3 & \\textbf{?} & 1 & 5 \\\\\n\\hline\n\\textbf{$User_2$} & 1 & 2 & 4 & \\textbf{?} & 2 & 2 \\\\\n\\hline\n\\textbf{$User_3$} & 4  & 3 & 5 & \\textbf{?} & 4 & 3 \\\\\n\\hline\n\\textbf{$User_4$} & 5 & 2 & 3 &  \\textbf{?} & \\textbf{?} & \\textbf{?} \\\\\n\\hline\n\\textbf{$User_5$} & \\textbf{?} & \\textbf{?}  & \\textbf{?} & 4 & 1 & 1 \\\\\n\\hline\n\\textbf{$User_6$} & \\textbf{?} & \\textbf{?} & \\textbf{?}  & 3 & 5 & 2 \\\\\n\\hline\n\\textbf{$User_7$} & \\textbf{?} & \\textbf{?} & \\textbf{?}  & 5 & 1 & 2 \\\\\n\\hline\n\\textbf{$User_8$} & \\textbf{?} & \\textbf{?} & \\textbf{?}  & 5 & 4 & 4 \\\\\n\\hline\n\\end{tabular}\n\\caption{Modified Ratings Matrix}\n\\label{table:Modified Ratings Matrix}\n\\end{table}\n\nThe above table is a modification/extension of \\autoref{table:Ratings Matrix}. If KNN was applied to\nthis rating matrix with $\\mathcal{K}=4$(all users do not have 4 available NN, instead\nthey use the largest amount of NN available to them before 4) using user cosine similarity,\nit would produce the rating predictions in the table below.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{ |c|c|c|c|c|c|c| }\n\\hline\n\\diagbox{$User$}{$Item$} & \\textbf{$Item_1$} & \\textbf{$Item_2$} & \\textbf{$Item_3$} & \\textbf{$Item_4$}  & \\textbf{$Item_5$} & \\textbf{$Item_6$} \\\\\n\\hline\n\\textbf{$User_1$} & 5 & 2 & 3 & {\\color{red}4.3} & 1 & 5 \\\\\n\\hline\n\\textbf{$User_2$} & 1 & 2 & 4 & {\\color{red}4.15} & 2 & 2 \\\\\n\\hline\n\\textbf{$User_3$} & 4  & 3 & 5 & {\\color{red}4.12} & 4 & 3 \\\\\n\\hline\n\\textbf{$User_4$} & 5 & 2 & 3 &  {\\color{green}\\textbf{?}} & {\\color{red}2.35} & {\\color{red}3.42} \\\\\n\\hline\n\\textbf{$User_5$} & {\\color{red}3.35} & {\\color{red}2.35}  & {\\color{red}4.02} & 4 & 1 & 1 \\\\\n\\hline\n\\textbf{$User_6$} & {\\color{red}3.21} & {\\color{red}2.4} & {\\color{red}4.15}  & 3 & 5 & 2 \\\\\n\\hline\n\\textbf{$User_7$} & {\\color{red}3.46} & {\\color{red}2.32} & {\\color{red}3.94}  & 5 & 1 & 2 \\\\\n\\hline\n\\textbf{$User_8$} & {\\color{red}3.36} & {\\color{red}2.35} & {\\color{red}4.03}  & 5 & 4 & 4 \\\\\n\\hline\n\\end{tabular}\n\\caption{Modified Ratings Matrix After KNN}\n\\label{table:Modified Ratings Matrix after KNN}\n\\end{table}\n\\justify\nIt seems that KNN was unable to predict how $User_4$ would rate $Item_4$.\\\\\nThe connections from user cosine similarity that could be formed were the following:\n\\begin{align*}\n\t&cos(User_1,User_2) = 0.7659 &cos(User_1,User_3) = 0.8660 & &cos(User_1,User_4) = 0.7705\\\\\n\t&cos(User_1,User_5) = 0.1767 &cos(User_1,User_6) = 0.3041 & &cos(User_1,User_7) = 0.2510\\\\\n\t&cos(User_1,User_8) = 0.3973 &cos(User_2,User_3) = 0.9434 & &cos(User_2,User_4) = 0.6325\\\\\n\t&cos(User_2,User_5) = 0.1750 &cos(User_2,User_6) = 0.4217 & &cos(User_2,User_7) = 0.2034\\\\\n\t&cos(User_2,User_8) = 0.3935 &cos(User_3,User_4) = 0.7680 & &cos(User_3,User_5) = 0.1905\\\\\n\t&cos(User_3,User_6) = 0.4870 &cos(User_3,User_7) = 0.2108 & &cos(User_3,User_8) = 0.4282\\\\\n\t&cos(User_5,User_6) = 0.7264 &cos(User_5,User_7) = 0.9897 & &cos(User_5,User_8) = 0.8741\\\\\n\t&cos(User_6,User_7) = 0.7108 &cos(User_6,User_8) = 0.9239 & &cos(User_7,User_8) = 0.8947\\\\\n\\end{align*}\n\\vfill\n\\justify\nThe following figure is a graphical representation of the user connections.\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_3/user_connections.eps}\n\\caption{User Connections}\n\\label{figure:user_connections}\n\\end{figure}\n\nIt seems that from users who have rated $Item_4$, it is possible to create a connection to $User_4$, but in\norder to do that they must use the intermediate connections they have in common. Graph-based\nmethods are known to utilize these connections efficiently to produce link similarities that\nsurpass the direct connection between users or items \\citep{Ricci,Aggarwal}.\n\\section{Methodology}\nThe Recursive K-Nearest Neighbors algorithm utilizes the intermediate connections that two users\nhave in common in order to find a path to predict ratings that the conventional KNN could not find.\nThe concept of this algorithm, is to use the rating predictions produced by KNN, in order\nto consider the users that have not rated the target item, as neighbors. As presented in\n\\autoref{figure:user_connections_with_KNN} below,\nthe KNN rating predictions related to $Item_4$ for $User_1$, $User_2$ and $User_3$ have been\nadded to the figure to indicate them as real rating values that these users gave to $Item_4$.\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_3/user_connections_with_KNN.eps}\n\\caption{User Connections as \\autoref{figure:user_connections} with KNN predictions from \\autoref{table:Modified Ratings Matrix after KNN}}\n\\label{figure:user_connections_with_KNN}\n\\end{figure}\nThen, as new similarities can be formed for $User_4$ with $User_1$, $User_2$ and $User_3$ for $Item_4$, the weighted sum formula used in KNN can be\nagain used to compute the rating prediction of $User_4$ to $Item_4$ as shown in \\autoref{figure:RKNN_prediction}.\\\\\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_3/RKNN_prediction.eps}\n\\caption{Recursive KNN Rating Prediction}\n\\label{figure:RKNN_prediction}\n\\end{figure}\nThe Recursive K-Nearest Neighbors methodology for predicting how $User_A$ would rate $Item_B$,\n(with the assumption that, given a similarity metric, KNN would not be able to predict this rating)\nconsists of the following steps:\n\\begin{itemize}\\label{RKNN}\n\t\\item[] \\textbf{Step 1:} Select users that are connected with $User_A$, and name it $Group_A$.\n\t\\item[] \\textbf{Step 2:} Out of $Group_A$, choose those users that have connections with\n\tusers who have rated $Item_B$, and name it $Group_B$.\n\t\\item[] \\textbf{Step 3:}  Order $Group_B$ by descending similarity with $User_A$.\n\t\\item[] \\textbf{Step 4:}  Choose how many neighbors from $Group_B$ will contribute in the\n\trating prediction by selecting the top $\\mathcal{K}$ out of all the available\n\tneighbors in this group, and name it $Group_C$.\n\t\\item[] \\textbf{Step 5:} For each neighbor in $Group_C$, predict how this neighbor would\n\trate $Item_B$ using the KNN algorithm. For convenience, we name the number of recursive\n\tneighbors each neighbor in $Group_C$ uses as, $\\mathcal{M}$-Nearest Neighbors.\n\t\\item[] \\textbf{Step 6:} Use the rating predictions applied on $Group_C$ to perform\n\tthe KNN algorithm on $User_A$ for $Item_B$.\n\\end{itemize}\n\nNow that the steps for performing the Recursive K-Nearest Neighbors algorithm have been\nintroduced let us look at a general case as in the figure below:\\\\\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\textwidth]{chapter_3/Recursive_Nearest_Neighbors.eps}\n\\caption{Recursive Nearest Neighbors Algorithm}\n\\label{figure:recursive_algorithm}\n\\end{figure}\nInterpretation of the figure:\n\\begin{enumerate}\n\t\\item After the selection of the top $\\mathcal{K}$ relevant Neighbors.\n\t(\\textbf{Steps 1,2,3,4})\n\t\\item For each Neighbor, name it $Neighbor_i$, out of $\\mathcal{K}$'s choose $\\mathcal{M}$\n\tNeighbors to apply KNN on $Neighbor_i$. (\\textbf{Step 5})\n\t\\item Use the rating predictions applied on $\\mathcal{K}$'s to predict the requested\n\tUser-Item rating.\\\\ (\\textbf{Step 6})\n\\end{enumerate}\n", "meta": {"hexsha": "b913b4b9ac8c66461316b3b034962903b205e6f7", "size": 7746, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diploma/chapters/chapter_3.tex", "max_stars_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_stars_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-06T16:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-06T16:08:44.000Z", "max_issues_repo_path": "diploma/chapters/chapter_3.tex", "max_issues_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_issues_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "diploma/chapters/chapter_3.tex", "max_forks_repo_name": "tseste/Recursive-K-Nearest-Neighbors", "max_forks_repo_head_hexsha": "5e35c643dc8c530102554492c56bfcf05b242298", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.9605263158, "max_line_length": 148, "alphanum_fraction": 0.7117221792, "num_tokens": 2751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704796847396, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.40535039427279174}}
{"text": "\\chapter{Nonlinear filtering}\n\\label{ch:RNN}\n\nThe SWR detectors discussed up to this point -- both the band-pass and the GEVec-based filters -- calculate their output as a linear combination of input samples. This chapter explores whether a nonlinear method to calculate the output signal can improve SWR detection performance.\n\n\\input{RNNs}\n\\input{GRU-eqs}\n\\input{Optimize}\n\\input{Results}\n", "meta": {"hexsha": "027671ef6823968c91f8e3bb4fff0dbf35ee9fd9", "size": 391, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "modules/RNN/index.tex", "max_stars_repo_name": "tfiers/master-thesis", "max_stars_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-23T01:39:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-23T01:39:24.000Z", "max_issues_repo_path": "modules/RNN/index.tex", "max_issues_repo_name": "tfiers/master-thesis", "max_issues_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 46, "max_issues_repo_issues_event_min_datetime": "2018-09-18T16:38:12.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-10T22:37:35.000Z", "max_forks_repo_path": "modules/RNN/index.tex", "max_forks_repo_name": "tfiers/master-thesis", "max_forks_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1, "max_line_length": 281, "alphanum_fraction": 0.7928388747, "num_tokens": 92, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4053503900062879}}
{"text": "\\documentclass[t]{beamer}\n\\usetheme{Copenhagen}\n\\setbeamertemplate{headline}{} % remove toc from headers\n\\beamertemplatenavigationsymbolsempty\n\n\\usepackage{amsmath, tikz, bm, pgfplots, tcolorbox}\n\\pgfplotsset{compat = 1.16}\n\n\\title{Quadratic Formula}\n\\author{}\n\\date{}\n\n\\AtBeginSection[]\n{\n  \\begin{frame}\n    \\frametitle{Objectives}\n    \\tableofcontents[currentsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\begin{frame} \n\\maketitle\n\\end{frame}\n\n\\section{Solve quadratic equations using the quadratic formula}\n\n\\begin{frame}{The Quadratic Formula}\nThe \\alert{quadratic formula} can be used to solve \\underline{any} quadratic equation that is equal to 0.\t\\newline\\\\\t\\pause\n\n\\begin{center}\nFor $ax^2 + bx + c = 0$\n\\end{center}\n\n\\begin{tcolorbox}[colback=red!10!white, colframe=red!60!black, title=Quadratic Formula]\n\\[x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}\\]\n\\end{tcolorbox}\n\\end{frame}\n\n\\begin{frame}{Example 1}\nSolve each of the following using the quadratic formula. Exact answers only.\t\\newline\\\\\n(a) \\quad $3x^2 + 8x - 28 = 0$\t\t\\pause\n\\[ a = 3 \\quad b = 8 \\quad c = -28 \\]\n\\begin{align*}\n\\onslide<3->{x &= \\frac{-8 \\pm \\sqrt{8^2-4(3)(-28)}}{2(3)}} \\\\[10pt]\n\\onslide<4->{x &= \\frac{-8 \\pm \\sqrt{400}}{6}} \\\\[10pt]\n\\onslide<5->{x &= \\frac{-8 \\pm 20}{6}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n\\[x = \\frac{-8 \\pm 20}{6} \\]\n\\begin{align*}\n\\onslide<2->{x &= \\frac{-8+20}{6} & x &= \\frac{-8-20}{6}} \\\\[10pt]\n\\onslide<3->{x &= 2 & x &= -\\frac{14}{3}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(b) \\quad $5x^2 + 9x - 5 = 0$ \\pause\n\\[ a = 5 \\quad b = 9 \\quad c = -5 \\]\n\\begin{align*}\n\\onslide<3->{x &= \\frac{-9 \\pm \\sqrt{9^2-4(5)(-5)}}{2(5)}} \\\\[10pt]\n\\onslide<4->{x &= \\frac{-9 \\pm \\sqrt{181}}{10}}\n\\end{align*}\n\\onslide<5->{\\[x = \\frac{-9 + \\sqrt{181}}{10} \\quad x = \\frac{-9 - \\sqrt{181}}{10}\\]}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(c) \\quad $6x^2 - 6x - 15 = -10$ \\pause\n\\[ 6x^2 - 6x - 5 = 0 \\]\t\\pause\n\\[a = 6 \\quad b = -6 \\quad c = -5 \\]\n\\begin{align*}\n\\onslide<4->{x &= \\frac{6 \\pm \\sqrt{6^2-4(6)(-5)}}{2(6)}} \\\\[10pt]\n\\onslide<5->{x &= \\frac{6 \\pm \\sqrt{156}}{12}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n\\[x = \\frac{6 \\pm \\sqrt{156}}{12} \\]\n\\begin{align*}\n\\onslide<2->{x &= \\frac{6 \\pm 2\\sqrt{39}}{12}} \\\\[10pt]\n\\onslide<3->{x &= \\frac{2\\left(3\\pm \\sqrt{39}\\right)}{12}} \\\\[10pt]\n\\onslide<4->{x &= \\frac{3 \\pm \\sqrt{39}}{6}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n(d) \\quad $7x^2 + 20x - 8 = -3x^2 - 1 + 10x$\t\\pause\n\\[ 10x^2 + 10x - 7 \\]\t\\pause\n\\[a = 10 \\quad b = 10 \\quad c = -7\\]\n\\begin{align*}\n\\onslide<4->{x &= \\frac{-10 \\pm \\sqrt{10^2-4(10)(-7)}}{2(10)}} \\\\[10pt]\n\\onslide<5->{x &= \\frac{-10 \\pm \\sqrt{380}}{20}}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example 1}\n\\[x = \\frac{-10 \\pm \\sqrt{380}}{20} \\]\n\\begin{align*}\n\\onslide<2->{x &= \\frac{-10 \\pm 2\\sqrt{95}}{20}} \\\\[10pt]\n\\onslide<3->{x &= \\frac{2\\left(-5\\pm \\sqrt{95}\\right)}{20}} \\\\[10pt]\n\\onslide<4->{x &= \\frac{-5 \\pm \\sqrt{95}}{10}}\n\\end{align*}\n\\end{frame}\n\n\\section{Use the discriminant to determine the types of solutions to a quadratic equation}\n\n\\begin{frame}{The Discriminant}\nThe expression {\\color{blue}$b^2-4ac$} in the square root is called the \\alert{discriminant}. It can tell us about the solutions to a quadratic equation:\t\\newline\\\\\t\\pause\n\n\\begin{itemize}\n\t\\item \\textbf{Discriminant is negative:} No real values of $x$ make the original equation true. \\newline\\\\ \\pause\n\t\\item \\textbf{Discriminant is 0:} There is one value of $x$ (called a \\emph{double root}). \\newline\\\\ \\pause\n\t\\item \\textbf{Discriminant is positive:} There are 2 unique answers for $x$.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}{The Discriminant}\nIn addition, if $\\sqrt{b^2 - 4ac}$ equals a \\alert{rational number}, then the quadratic equation is factorable over the integers (only use integers in your factoring).\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "809b90873f5808e484d3ee07841f77a374e51b58", "size": 3839, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Quadratic_Formula(BEAMER).tex", "max_stars_repo_name": "BryanBain/HA2_BEAMER", "max_stars_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Quadratic_Formula(BEAMER).tex", "max_issues_repo_name": "BryanBain/HA2_BEAMER", "max_issues_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Quadratic_Formula(BEAMER).tex", "max_forks_repo_name": "BryanBain/HA2_BEAMER", "max_forks_repo_head_hexsha": "a5e021f12d3cdd0541353c9e121ff5e4df7decd1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-26T15:49:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T15:49:45.000Z", "avg_line_length": 30.712, "max_line_length": 171, "alphanum_fraction": 0.6277676478, "num_tokens": 1550, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.7981867729389246, "lm_q1q2_score": 0.40532871320911734}}
{"text": "Standard stereo recording practice typically considered the damping of sound with distance to not be a consideration in the effect of a stereo recording array. However, there are cases where the damping of sound between microphones may be a non-trivial consideration. This effect is typically more pronounced in the flanking microphones when used, however may be a consideration for wider-set main arrays as well.\n\nConfounding this are issues with accurately modelling the emission and propagation of sound. As previously mentioned, the goal is not a physical model, but a practically useable abstraction. To this end, a model that includes a perceptually accurate representation of the significant effect of the phenomena is sufficient, even if the detail is lacking.\n\nTo represent an abstraction of the propagation of sound and its damping with distance, three different damping compensation arrangements have been implemented. To abstract the actual propagation of sound with respect to an real source's statistical directivity pattern and facing, an additional parameter can be introduced that affects the amount of damping with distance. Accompanying this, a Boolean parameter, $\\gamma$ is introduced to allow the user to enable or disable the $\\Delta{l}$ calculation.\n\nThis gives the expansion of $m(S)$ to:\n\n\\begin{equation}\nm(S) = \\left(\\begin{cases}\n\\Delta{v} \\cdot \\Delta{l} & \\; \\text{if} \\; \\gamma = 1 \\\\\n\\Delta{v} &\\; \\text{if} \\; \\gamma = 0\n\\end{cases}\\right)\n+ \\Delta{t}\n\\end{equation}\n\nNoting that $\\Delta{v}$ and $\\Delta{l}$ should be in the form of amplitude scalars, rather than decibel amounts\\footnote{Decibels amounts would need to be summed rather than multiplied.}\n\n\\subsection {Sound Damping Formula}\n\nIf there are two points in a free-field space, each a distance of $r$ from a sound source, and if we know the sound pressure level in decibels, $l$, at one of the points: then the sound pressure level at the other distance can be calculated as:\n\n\\begin{equation}\nl_2 = l_1 - \\left|20 \\cdot \\log_{10}\\frac{r_1}{r_2}\\right|\n\\end{equation}\n\nSubstituting the positions of the virtual microphone and sound source into the formula, and assuming that the microphone's signal is measured at a unit distance of one, the level at a virtual microphone can be found as:\n\n\\begin{equation}\nl_m = l_S - \\left|20 \\cdot \\log_{10}\\frac{1}{d_{\\vec{v}}}\\right|\n\\end{equation}\n\nFrom this, the damping amount at the microphone's distance from the sound source is simply:\n\n\\begin{equation}\n\\Delta{l}_m = 20 \\cdot\\log_{10}(d_{\\vec{v}})\n\\end{equation}\n\nAs previously discussed, the actual damping amount displayed by a sound source in practice also depends on the directivity of the source and the acoustic environment. The most expedient method for reducing the amount of damping with distance, is to reduce the value of the multiplier for the $\\log$ function in the calculation. This can be done by replacing the multiplier with a user-adjustable parameter, $\\sigma$ from the multiplier, where $\\sigma \\in [0,20]$. To simplify the user-experience, this implementation uses $\\sigma \\in \\{5, 10, 20\\}$ which corresponds with a 1.5dB, 3dB, and 6dB amount of damping per doubling of distance.\n\n\\begin{equation}\\label{distancedamping}\n\\Delta{l}_m = \\sigma\\cdot\\log_{10}(d_{\\vec{v}})\n\\end{equation}\n\nFinally, this can be converted to an amplitude scalar value following the usual conversion\\footnote{See (\\ref{dbscalarconvert})}:\n\n\\begin{equation}\n\\Delta{l}_m= -10^{\\frac{\\Delta{l}_m}{20}}\n\\end{equation}\n\n\\subsection{Implementing $\\Delta{l}$ Correction}\n\nFor aesthetic/artistic reasons, a direct modeling of the propagation of sound is likely to be undesirable. Additionally, it may even defeat the purpose in the near-capture of the real sound source. To this end there are two processing considerations made in the model: the actual distance-damping that is compensated for and the specific virtual microphones to which the $\\Delta{l}$ correction is applied.\n\n\\subsubsection{Correction Amount}\n\nIt is unnecessary to apply the full amount of $\\Delta{l}$ to the virtual microphones. The damping due to the distance between the source and the nearest microphone serves no artistic purpose in modelling, and will only cause the mixing engineer to have to (re)adjust the aesthetic balance of the recorded track. Thus, the compensation only needs to be applied for the distance differences between the microphones.\n\nThis can be done simply by finding the smallest value for $l$ in the set of virtual microphones, and subtracting that number from every other microphone. If $j \\in M \\;|\\; \\Delta{l}_j \\leq \\Delta{l}_i, \\forall i \\in M$, then the distance-damping formula (\\ref{distancedamping}) is redefined as the intermediate value $\\Delta{l}_m$, and the function $\\Delta{l}(m)$ becoming:\n\n\\begin{equation}\n\\Delta{l}(m) = \\Delta{l}_m - \\Delta{l}_j\n\\end{equation}\n\n\\subsubsection{Microphone relationships}\n\nDepending on the musical context, it may or may not be desirable to consider the damping effect on the full microphone array. Three different arrangements are considered by breaking the microphone array into two parts: $M = W \\cup U \\;|\\; W = \\left\\{m_c, m_{mL}, m_{mR}\\right\\}, U = \\left\\{m_{fL}, m_{fR}\\right\\}$. These four options are (1) damping applied to $M$, (2) damping applied to $W$ and $F$ independently, and (3) damping only applied to $F$. To facilitate this, the user-settable parameter can be defined so that $\\gamma \\in \\{0, 1, 2, 3\\}$, and $\\Delta{l}_j$ is taken from the same subset as $\\Delta{l}_m$:\n\n\\begin{equation}\n\\Delta{l}(m) = \\begin{cases}\n\\text{for}\\; \\gamma = 0:\\Delta{l}_m \\\\\n\\text{for}\\; \\gamma = 1:\\Delta{l}_m - \\Delta{l}_j\\\\\n\\text{for}\\; \\gamma = 2:\\begin{cases}\n\\Delta{l}_m - \\Delta{i}_j \\; &\\text{if}\\; m\\land{}j\\in{}W\\\\\n\\Delta{l}_m - \\Delta{i}_j \\; &\\text{if}\\; m\\land{}j\\in{}U\n\\end{cases}\\\\\n\\text{for}\\; \\gamma = 3:\\begin{cases}\n\\Delta{l}_m \\; &\\text{if}\\;\\Delta{l}_m\\in{}W\\\\\n\\Delta{l}_m - \\Delta{l}_j \\; &\\text{if}\\;m\\in{}U \\;|\\; j\\in{}U\n\\end{cases}\n\\end{cases}\n\\end{equation}\n", "meta": {"hexsha": "45a19457d8bbe48091d2b7ef2111e2c9456755db", "size": 6016, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Technical Documentation/soundpressuredamping.tex", "max_stars_repo_name": "jmclark85/StereoPairsEmulator", "max_stars_repo_head_hexsha": "a78161b4b99b50e481c133ba8a5049d548561954", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Technical Documentation/soundpressuredamping.tex", "max_issues_repo_name": "jmclark85/StereoPairsEmulator", "max_issues_repo_head_hexsha": "a78161b4b99b50e481c133ba8a5049d548561954", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-08-26T18:24:14.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-26T18:24:14.000Z", "max_forks_repo_path": "Technical Documentation/soundpressuredamping.tex", "max_forks_repo_name": "jmclark85/StereoPairsEmulator", "max_forks_repo_head_hexsha": "a78161b4b99b50e481c133ba8a5049d548561954", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.4819277108, "max_line_length": 637, "alphanum_fraction": 0.7488364362, "num_tokens": 1594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.538983220687684, "lm_q1q2_score": 0.40532215900269003}}
{"text": "\\section{Superconductivity}\n\\label{s:superconductivity}\n\nWe consider two approaches to realizing a superconducting state.\nFirst, we assume a proximity induced state obtained by\nlayering a TMD on an $s$-wave superconductor.\nSecond, we study an intrinsic correlated phase arising\nfrom density-density interactions.\n\nWe use $d^ν_{τ {\\s}} \\ofK$ as the annihilation operator\nfor tight-binding $d$-orbital states,\nand $c^n_{τ {\\s}} \\ofK$ for the eigenstates of the non-interacting Hamiltonian,\n$λ_{\\vK}$ for the energy dispersion for Bogoliubov quasiparticles,\nand $Δ_{\\vK}$ for the superconducting gap function.\n\n\\subsection{Induced State}\n\nA proximity $s$-wave superconductor will inject Cooper pairs\naccording to\n\\begin{equation}\n  H^V\n  = ∑_{\\vK, ν, τ} \\cc{B}_ν\n    d^ν_{-τ ↓} \\ofMK d^ν_{τ ↑} \\ofK + \\frac{ε}{2} + \\hc\n\\end{equation}\nThe coupling constants $B_ν$ and the overall constant $ε$\ndepend on the material interface %\n\\footnote{%\n  Note that all sums over $\\vK$ are restricted to $\\left| \\vK \\right|$\n  less than some cutoff that restricts the momentum to a single valley.\n}.\nUsing the abbreviated notation\n$c_{\\vK α} = c^-_{τ {\\s}} \\ofK$,\nwith $α =\\ ↑↓$ for $τ = {\\s} = ±$,\nprojecting onto the upper valence bands yields,\n\\begin{multline}\n  \\label{eq:induced}\n  P_{τ = {\\s}}^{n = -} \\left( H^0 + H^V - μ N \\right)\n  = ∑_{\\vK, α} ξ_{\\vK} c_{\\vK α}^† c_{\\vK α} \\\\\n  - \\sumK \\left( \\cc{Δ}_{\\vK} c_{-\\vK ↓} c_{\\vK ↑}\n  + Δ_{\\vK} c_{\\vK ↑}^† c_{-\\vK ↓}^† \\right)\n  + ε,\n\\end{multline}\nwhere $ξ_{\\vK} = E_{+ ↑}^- \\of{\\abs{\\vK}} - μ$ and\nthe effective BCS gap function is\n\\begin{equation}\n  Δ_{\\vK}\n  = \\frac{1}{2} \\left( B_+ + B_- \\right)\n  + \\frac{1}{2} \\left( B_+ - B_- \\right)\n    \\cos{θ_{\\vK}},\n\\end{equation}\nwith $θ_{\\vK} = θ_{+↑}^- \\of{\\abs{\\vK}}$.\nThis form is identical to the standard BCS Hamiltonian with\nan effective spin index $α$.\nHowever, the spin state of the Cooper pair is an equal superposition\nof the singlet and the $m = 0$ component of spin triplet.\nThe corresponding quasiparticle eigenstates are\n$γ_{\\vK α}\n= α \\cos{β_{\\vK}} c_{\\vK α} + \\sin{β_{\\vK}} c_{-\\vK, -α}^†$,\nwith energies\n$λ_{\\vK} = ± \\sqrt{ξ_{\\vK}^2 + Δ_{\\vK}^2}$,\nwhere $\\cos{2 β_{\\vK}} = ξ_{\\vK} / λ_{\\vK}$.\nNote that if $B_+ = B_-$,\nthen $Δ_{\\vK}$ is a constant and independent of $\\vK$.\nEven when $B_+$ and $B_-$ are different,\nthe constant term dominates.\nBefore exploring the nature of this state,\nwe analyze the case of intrinsic superconductivity,\nand show that the same state is energetically preferred.\n\n\\subsection{Intrinsic Phase}\n\nFor a local attractive density-density interaction\n(e.g.\\ one mediated by phonons), the potential is\n$V ⋍ \\frac{1}{2} ∑_{\\vR, \\vR'} v_{\\vR \\vR'}\n\\normalorder{n_{\\vR} n_{\\vR'}}$,\nwith $v_{\\vR \\vR'} = v_0 δ_{\\vR \\vR'}$\nand $n_{\\vR}$ the total Wannier electron density at lattice vector $\\vR$.\nProjecting onto states near the chemical potential gives\n\\begin{multline}\n  \\label{eq:channels}\n  P_{τ = {\\s}}^{n = -} \\left( H^V \\right)\n  = \\sumKK v \\of{\\vK' - \\vK} \\\\\n  × \\left(\n    A_{\\vK \\vK'}^2 c_{\\vK' ↑}^† c_{-\\vK' ↑}^† c_{-\\vK ↑} c_{\\vK ↑}\n  + A_{\\vK' \\vK}^2 c_{\\vK' ↓}^† c_{-\\vK' ↓}^† c_{-\\vK ↓} c_{\\vK ↓}\n    \\right. \\\\ + \\left.\n      2 \\abs{A_{\\vK \\vK'}}^2\n      c_{\\vK' ↑}^† c_{-\\vK' ↓}^† c_{-\\vK ↓} c_{\\vK ↑}\n    \\vphantom{2 \\abs{V_{\\vK \\vK'}}^2} \\right),\n\\end{multline}\nwhere\n\\begin{equation}\n  A_{\\vK \\vK'}\n  = e^{i \\left( ϕ_{\\vK'} - ϕ_{\\vK} \\right)}\n    \\sin{\\frac{θ_{\\vK'}}{2}} \\sin{\\frac{θ_{\\vK}}{2}}\n  + \\cos{\\frac{θ_{\\vK'}}{2}} \\cos{\\frac{θ_{\\vK}}{2}}.\n\\end{equation}\nThe first two terms in \\cref{eq:channels} lead to intravalley pairing,\nand the third to intervalley pairing.\nWe analyze the possible states within mean field theory.\nThe BCS order parameter is\n\\begin{equation}\n  χ\n  = v_0 \\sumK \\cc{g}_{\\vK} \\ev{c_{-\\vK α'} c_{\\vK α}},\n\\end{equation}\nwhere the form of $g_{\\vK}$ depends on the particular pairing channel.\nThe resulting Hamiltonian has the same form as the BCS Hamiltonian in\n\\cref{eq:induced}\nbut with an effective $Δ_{\\vK} = g_{\\vK} · χ$.\nThe intravalley pairing has three symmetry channels,\nwith the couplings given by\n$2 g_{\\vK} = 1 +  \\cos{θ_{\\vK}}$,\n$\\sqrt{2} e^{- i ϕ_{\\vK}} g_{\\vK} = \\sin{θ_{\\vK}}$\nand $2 e^{- 2 i ϕ_{\\vK}} g_{\\vK} = 1 - \\cos{θ_{\\vK}}$.\nFor these channels, since\n$\\ev{c_{-\\vK α} c_{\\vK α}} = - \\ev{c_{\\vK α} c_{-\\vK α}}$,\nrelabeling $\\vK → -\\vK$ in the sum gives $χ = 0$ %\n\\footnote{%\n  For odd parity interactions, where $v \\ofMK = -v \\ofK$, the\n  intravalley pairing is not excluded by symmetry.\n  Specifically, repeating the calculation with this assumption,\n  the intervalley terms fully cancel, and one obtains \\cref{eq:channels}\n  without the intervalley term on the third line.\n}.\nThe intervalley pairing also has three symmetry channels:\n$g_{\\vK} = \\sqrt{2}$,\n$g_{\\vK} = \\sqrt{2} \\cos{θ_{\\vK}}$,\nand $g_{\\vK} = \\sqrt{2} \\sin{θ_{\\vK}} \\vc{\\hat{k}}$.\nOf the three,\nthe constant valued channel is dominant %\n\\footnote{%\n  For example, using the values for \\ce{WSe2},\n  $\\sin^2 {θ_{\\vK}} = 0.44$ and $\\cos^2 {θ_{\\vK}} = 0.56$\n  at the chemical potential.\n}.\nThis is to be expected, as the local density-density interaction\nleads to the largest pairing for electrons of opposite spins.\nSince the intravalley processes have the same spin,\nthey are disfavored as compared to the intervalley pairing.\n\nThe key features of the intrinsic superconducting state\nare identical to the proximally induced case when density-density\ninteractions dominate.\nWe restrict further analysis to that case,\nand turn to the question of pair-breaking phenomena\ninduced either by optical or magnetic fields.\n", "meta": {"hexsha": "7651e9e581d7ac075e790993712be9d3ca872a15", "size": 5571, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/_superconductor.tex", "max_stars_repo_name": "razor-x/aps-dichalcogenides-superconductivity", "max_stars_repo_head_hexsha": "311fab11004ecf5efd79f0fbbe48a5f6f3b62da8", "max_stars_repo_licenses": ["BSD-Source-Code"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/_superconductor.tex", "max_issues_repo_name": "razor-x/aps-dichalcogenides-superconductivity", "max_issues_repo_head_hexsha": "311fab11004ecf5efd79f0fbbe48a5f6f3b62da8", "max_issues_repo_licenses": ["BSD-Source-Code"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/_superconductor.tex", "max_forks_repo_name": "razor-x/aps-dichalcogenides-superconductivity", "max_forks_repo_head_hexsha": "311fab11004ecf5efd79f0fbbe48a5f6f3b62da8", "max_forks_repo_licenses": ["BSD-Source-Code"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.8979591837, "max_line_length": 79, "alphanum_fraction": 0.6596661282, "num_tokens": 2081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.4053221530115411}}
{"text": "%!TEX root = ../notes.tex\n\\section{April 27, 2022}\n\\subsection{GGH Cryptosystem: Public-Key Cryptosystem}\n\\recall last time we talked about GGH digital signatures.\n\nWe're going to use similar ideas to construct a public-key cryptosystem. As before, we'll have the same public/private key setup as last time.\n\n\\ul{Alice}: will choose a random basis $\\{\\bvec{v}_i\\}$ which will be her private key, which is a \\emph{sufficiently good} basis. Alice will then compute $\\{\\bvec{w}_i\\}$ which is a bad basis (by multiplying by some $U\\in\\mathsf{SL}_n(\\ZZ)$) which is her public key.\n\n\\ul{Bob}: will encrypt message $\\{m_i\\}$ by computing\n\\[\\bvec{c} = \\sum m_i \\bvec{w}_i + \\bvec{r}\\]\nwhere $\\bvec{r}$ is a randomly generated short vector.\n\n\\ul{Alice}: Find the closest lattice point to $\\bvec{c}$ using Babai's algorithm, and express it in the public basis $\\{\\bvec{w}_i\\}$.\n\nCode in \\textsf{lattices.ipynb}.\n\n\\subsection{Lattice Reduction}\n\\emph{Warm-up}: Gaussian Lattice Reduction.\n\nWe'll see how to find the shortest vector in a 2-dimensional lattice.\n\nWith Gram-Schmidt, we made an orthgonal basis.\n\\begin{center}\n    \\begin{tikzpicture}\n        \\draw[->, thick](0,0) node[left]{$O$} -- node[above]{$\\bvec{v}_2$} (4, 1);\n        \\draw[->, thick](0,0) -- node[below]{$\\bvec{v}_1$} (3, 0);\n        \\draw[->, densely dotted](4,1) -- node[above]{$\\mu\\cdot \\bvec{v}_1$} (0,1);\n        \\draw[->, thick, red](0,0) -- node[left, red]{$\\bvec{v}_2'$} (0,1);\n    \\end{tikzpicture}\n\\end{center}\n\nUsing Gram-Schmidt, we have $\\bvec{v}_2' = \\bvec{v}_2 - \\mu\\cdot \\bvec{v}_1$ where $\\mu = \\frac{\\bvec{v}_1\\cdot \\bvec{v}_2}{\\bvec{v}_1\\cdot \\bvec{v}_1}$.\n\nWith lattice reduction, we round $\\mu$ to subtract by an integer multiple of $\\bvec{v}_2$ instead.\n\n\\begin{center}\n    \\begin{tikzpicture}\n        \\draw[->, thick](0,0) node[left]{$O$} -- node[above]{$\\bvec{v}_2$} (4, 1);\n        \\draw[->, thick](0,0) -- node[below]{$\\bvec{v}_1$} (3, 0);\n        \\draw[->, densely dotted](4,1) -- node[above]{$1\\cdot \\bvec{v}_1$} (1,1);\n        \\draw[->, thick, red](0,0) -- node[above left, red]{$\\bvec{v}_2'$} (1,1);\n    \\end{tikzpicture}\n\\end{center}\n\nLattice reduction gives us\n\\[\\bvec{v}_2' = \\bvec{v}_2 - \\lfloor\\mu\\rceil\\cdot \\bvec{v}_1\\]\n\nWe do this again and again.\n\nCode in \\textsf{lattices.ipynb}.\n\nWe should prove that this gives us a reasonable basis when this algorithm finishes.\n\\begin{proposition}\n    This algorithm terminates.\n\\end{proposition}\n\\begin{proof}\n    Integer vectors $||\\bvec{v}_1||$ and $||\\bvec{v}_2||$ always decrease, and there are only \\emph{finitely many} lattice vectors that strictly decrease.\n\\end{proof}\n\n\\begin{proposition}\n    When this algorithm terminates, $\\bvec{v}_1$ is the shortest vector in the lattice.\n\\end{proposition}\n\\begin{proof}\n    At the end, we know that $||\\bvec{v}_2||\\geq ||\\bvec{v}_1||$ and that\n    \\[-\\frac{1}{2}\\leq \\mu = \\frac{\\bvec{v}_1\\cdot \\bvec{v}_2}{\\bvec{v}_1\\cdot \\bvec{v}_1} \\leq \\frac{1}{2}.\\]\n    Any vector $\\bvec{w} = a_1\\bvec{v}_1 + a_2\\bvec{v}_2$. So\n    \\begin{align*}\n        ||\\bvec{w}||^2 & = a_1^2\\cdot ||\\bvec{v}_1||^2 + 2a_1a_2(\\bvec{v}_1\\cdot \\bvec{v}_2) + a_2^2||\\bvec{v}_2||^2 \\\\\n                       & \\geq a_1^2\\cdot ||\\bvec{v}_1||^2 + a_1a_2||\\bvec{v}_1||^2 + a_2^2||\\bvec{v}_2||^2           \\\\\n                       & = (a_1^2 + a_1a_2 + a_2^2)||\\bvec{v}_1||^2\n    \\end{align*}\n    And $a_1^2 + a_1a_2 + a_2^2 = \\frac{3}{4}(a_1 - a_2)^2 + \\frac{1}{4}(a_1 + a_2)^2 > 0$. \\textsc{otoh} $a_1, a_2\\in\\ZZ$ so $a_1^2 + a_1a_2 + a_2^2\\geq 1$.\n\n    So any $||\\bvec{w}||^2 \\geq ||\\bvec{v}_1||^2$.\n\\end{proof}", "meta": {"hexsha": "73f09c8b4510fbd6f81cf13e9d05d30374d733f5", "size": 3568, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lectures/2022-04-27.tex", "max_stars_repo_name": "jchen/math1580-notes", "max_stars_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-14T15:03:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T15:03:38.000Z", "max_issues_repo_path": "lectures/2022-04-27.tex", "max_issues_repo_name": "jchen/math1580-notes", "max_issues_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lectures/2022-04-27.tex", "max_forks_repo_name": "jchen/math1580-notes", "max_forks_repo_head_hexsha": "9784be9e0faa57bbb3c421d8a104daadebf99a2f", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.9473684211, "max_line_length": 266, "alphanum_fraction": 0.6224775785, "num_tokens": 1418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.40526563120620124}}
{"text": "\\documentclass{segabs}\n\\usepackage{mathrsfs,amsmath,url,xspace}\n\n\n% An example of defining macros\n\\newcommand{\\rs}[1]{\\mathstrut\\mbox{\\scriptsize\\rm #1}}\n\\newcommand{\\rr}[1]{\\mbox{\\rm #1}}\n% My equations\n%-----------------------------------------------------------\n\\renewcommand{\\div}{\\nabla\\cdot}\n\\newcommand{\\grad}{\\vec \\nabla}\n\\newcommand{\\curl}{{\\vec \\nabla}\\times}\n\\renewcommand{\\H}{{\\vec H}}\n\\newcommand {\\J}{{\\vec J}}\n\\newcommand {\\E}{{\\vec E}}\n\\newcommand{\\siginf}{\\sigma_\\infty}\n\\newcommand{\\dsig}{\\triangle\\sigma}\n\\newcommand{\\dcurl}{{\\mathbf C}}\n\\newcommand{\\dgrad}{{\\mathbf G}}\n\\newcommand{\\Acf}{{\\mathbf A_c^f}}\n\\newcommand{\\Ace}{{\\mathbf A_c^e}}\n\\renewcommand{\\S}{{\\mathbf \\Sigma}}\n\\newcommand{\\St}{{\\mathbf \\Sigma_\\tau}}\n\\newcommand{\\T}{{\\mathbf T}}\n\\newcommand{\\Tt}{{\\mathbf T_\\tau}}\n\\newcommand{\\diag}{\\mathbf{diag}}\n\\newcommand{\\M}{{\\mathbf M}}\n\\newcommand{\\MfMui}{{\\M^f_{\\mu^{-1}}}}\n\\newcommand{\\MfMuoi}{{\\M^f_{\\mu_0^{-1}}}}\n\\newcommand{\\dMfMuI}{{d_m (\\M^f_{\\mu^{-1}})^{-1}}}\n\\newcommand{\\dMfMuoI}{{d_m (\\M^f_{\\mu_0^{-1}})^{-1}}}\n\\newcommand{\\MeSig}{{\\M^e_\\sigma}}\n\\newcommand{\\MeSigInf}{{\\M^e_{\\sigma_\\infty}}}\n\\newcommand{\\MeSigInfEtab}{{\\M^e_{\\sigma_\\infty \\bar{\\eta}}}}\n\\newcommand{\\MeSigInfEtat}{{\\M^e_{\\sigma_\\infty \\peta}}}\n\\newcommand{\\MedSig}{{\\M^e_{\\triangle\\sigma}}}\n\\newcommand{\\MeSigO}{{\\M^e_{\\sigma_0}}}\n\\newcommand{\\Me}{{\\M^e}}\n\\newcommand{\\Js}{\\mathbf{J}^s}\n\\newcommand{\\Mes}[1]{{\\M^e_{#1}}}\n\\newcommand{\\Mee}{{\\M^e_e}}\n\\newcommand{\\Mej}{{\\M^e_j}}\n\\newcommand{\\BigO}[1]{\\mathcal{O}\\bigl(#1\\bigr)}\n\\newcommand{\\bE}{\\mathbf{E}}\n\\newcommand{\\bEp}{\\mathbf{E}^p}\n\\newcommand{\\bB}{\\mathbf{B}}\n\\newcommand{\\bBp}{\\mathbf{B}^p}\n\\newcommand{\\bEs}{\\mathbf{E}^s}\n\\newcommand{\\bBs}{\\mathbf{B}^s}\n\\newcommand{\\bH}{\\mathbf{H}}\n\\newcommand{\\B}{\\vec{B}}\n\\newcommand{\\D}{\\vec{D}}\n\\renewcommand{\\H}{\\vec{H}}\n\\newcommand{\\s}{\\vec{s}}\n\\newcommand{\\bfJ}{\\bf{J}}\n\\newcommand{\\vecm}{\\vec m}\n\\renewcommand{\\Re}{\\mathsf{Re}}\n\\renewcommand{\\Im}{\\mathsf{Im}}\n\\renewcommand {\\j}  { {\\vec j} }\n\\newcommand {\\h}  { {\\vec h} }\n\\renewcommand {\\b}  { {\\vec b} }\n\\newcommand {\\e}  { {\\vec e} }\n\\renewcommand {\\d}  { {\\vec d} }\n\\renewcommand {\\u}  { {\\vec u} }\n\n\\renewcommand {\\dj}  { {\\mathbf{j} } }\n\\renewcommand {\\dh}  { {\\mathbf{h} } }\n\\newcommand {\\db}  { {\\mathbf{b} } }\n\\newcommand {\\de}  { {\\mathbf{e} } }\n\n\\newcommand{\\vol}{\\mathbf{v}}\n\\newcommand{\\I}{\\vec{I}}\n\\newcommand{\\A}{\\mathbf{A}}\n\\newcommand{\\bI}{\\mathbf{I}}\n\\newcommand{\\bus}{\\mathbf{u}^s}\n\\newcommand{\\brhss}{\\mathbf{rhs}_s}\n\\newcommand{\\bup}{\\mathbf{u}^p}\n\\newcommand{\\brhs}{\\mathbf{rhs}}\n%%-------------------------------\n\\newcommand{\\bon}{b^{on}(t)}\n\\newcommand{\\bp}{b^{p}}\n\\newcommand{\\dbondt}{\\frac{db^{on}(t)}{dt}}\n\\newcommand{\\dfdt}{\\frac{df(t)}{dt}}\n\\newcommand{\\dbdt}{\\frac{\\partial \\b}{\\partial t}}\n\\newcommand{\\dfdtdsiginf}{\\frac{\\partial\\frac{df(t)}{dt}}{\\partial\\siginf}}\n\\newcommand{\\dfdsiginf}{\\frac{\\partial f(t)}{\\partial\\siginf}}\n\\newcommand{\\dbgdsiginf}{\\frac{\\partial b^{Impulse}(t)}{\\partial\\siginf}}\n\\newcommand{\\digint}{\\frac{2}{\\pi}\\int_0^{\\infty}}\n\\newcommand{\\Gbiot}{\\mathbf{G}_{Biot}}\n%%-------------------------------\n\\newcommand{\\peta}{\\tilde{\\eta}}\n\\newcommand{\\petadt}{\\frac{\\partial \\tilde{\\eta}}{\\partial t}}\n\\newcommand{\\eFmax}{\\e^{F}_{max}}\n\\newcommand{\\dip}{d^{IP}}\n\\newcommand{\\sigpert}{\\delta\\sigma}\n\n\n\\newcommand{\\SimPEG}{\\textsc{SimPEG}\\xspace}\n\\newcommand{\\simpegEM}{\\textsc{simpegEM}\\xspace}\n\n\n\n\n\\begin{document}\n\n\\title{Moving between dimensions in electromagnetic inversions}\n\n\\renewcommand{\\thefootnote}{\\fnsymbol{footnote}}\n\n\\author{Seogi Kang\\footnotemark[1], Rowan Cockett, Lindsey J. Heagy, \\& Douglas W. Oldenburg, Geophysical Inversion Facility, University of British Columbia}\n\n\\footer{Example}\n\\lefthead{Kang et al.}\n\\righthead{Moving between dimensions in EM inversions}\n\n\\maketitle\n\\begin{abstract}\nElectromagnetic (EM) methods are used to characterize the electrical conductivity distribution of the earth. Recently, due in part to computational advances, EM geophysical surveys are increasingly being simulated and inverted in 3D. However, the availability of computational resources does not invalidate the use of lower dimensional formulations and methods, which can be useful depending on the geological complexity as well as the survey geometry. For example, a progressive procedure can be used to invert EM data, starting with 1D inversion, then moving to multi-dimensional inversions. As such, we require a set of tools that allow a geophysicists to easily move between dimensions of the EM problem. In this study, we suggest a mapping function, which transforms the inversion model to physical property model for forward modeling. Using this general framework, we apply EM inversion with a suite of models from 1D to 3D and suggests the importance of choosing a proper model based on the task you have in the EM inversion.\n\\end{abstract}\n\\renewcommand{\\figdir}{Fig} % figure directory\n% In this presentation, we will share examples as well as our experience from creating a range of simulation and inversion tools for EM methods that span dimensions (1D, 2D and 3D). The flexibility and consistency in our EM package allows us to be methodical so that we have the capacity to tackle a spectrum of problems in EM geophysics.\n% This is the motivation behind the open source software package \\simpegEM which is part of a software ecosystem for Simulation and Parameter Estimation in Geophysics (\\SimPEG).\n\\section{Introduction}\nUsing electromagnetic (EM) waves, we excite the earth and measure signals from the earth.\nThis signal includes conductivity distribution of the earth. By solving Maxwell's\nequations, we can compute forward response of the system with known conductivity\ndistribution.\nUsing the EM inversion technique, we recover a conductivity model, which explains the\nmeasured EM response.\nThis model can be discretized voxel of the 3D conductivity.\nTo proceed this 3D inversion, we need to compute forward response from the 3D earth.\nTherefore a natural choice of the inversion model can be 3D distribution of the conductivity.\nRecently, 3D EM inversion technique using gradient based optimiztion has actively been\ndeveloped and interrogated on various applications (\\cite{Doug2013,Gribenko2007,Chung2014}).\n\nThe gradient based geophysical inversion technique includes several pieces in general:\nuncertainty, data misfit, sensitivity, model and regularization.\nOur focus in this paper is the inversion model.\nIn most cases, the inversion model has been considered as 3D distribution of the conductivity.\nHowever, our model can be more general. For example, let us assume we have 3D conductivity\nmodel for sewatuer intrusion as shown in Figure ~\\ref{fig:mapping123D}.\nAlthough physical property model can be in 3D, inversion model can be either 1D or 2D\nas shown in Figure ~\\ref{fig:mapping123D}.\nRealization of this is possible using model mapping function, which can be defined as\n\\begin{equation}\n  \\sigma  = \\mathcal{M}[m],\n\\end{equation}\nwhere $\\sigma$ is the electrical conductivity (S/m). This mapping function\n($\\mathcal{M}[\\cdot]$) transforms the space from the inversion model to physical property\nmodel. Moving our spatial dimensions from 1D to 3D or 2D to 3D can be possible using this\nmapping function. On top of that, we can use a geometric function like sphere or\nellipsoid to parameterize 3D structure with few parameters (\\cite{MikeParam2014}).\nImplementation of this is done through \\simpegEM which is part of a software ecosystem\nfor Simulation and Parameter Estimation in Geophysics (\\cite{SimPEG}).\n\\simpegEM provides forward and inverse problem of EM methods in both frequency and time domain (\\cite{SimPEGEM}).\n\nIn this study, we exploit seawater intrusion problem with ground loop EM survey to visit\nsuite of model spaces that we can use in the EM inversion. We use time domain EM (TEM)\nmethods. To setup a survey design, we use 1D seawater intrusion model and perform feasibility test. Based on this, we compute forward response from 3D seawater intrusion\nmodel. 1D stitched and 2D inversion to a line profile data are going to be applied to\nrestore the 2D conductivity model. Using multiple line profile data, we perform 3D EM\ninversion to restore 3D conductivity model. Based on the knowledge from 1D 2D and 3D inversion, parameterization of seawater intrusion model with arbitrary geometric function\nis possible, and this may allow us to answer specialized question like ``where is the\ninterface between seawater and freshwater''.\n\n\n\\plot{mapping123D}{width=0.8\\columnwidth}\n{Conceptual diagram of 1D, 2D and 3D models for the seawater intrusion problem.}\n\n\\section*{Methodology}\nEM inversion is gearing towards recovering a model, which explains measured response. EM response is governed by Maxwell's equations.  In time domain we have\n\\begin{equation}\n  \\curl \\e = -\\dbdt,\n\\end{equation}\n\\begin{equation}\n  \\curl \\mu^{-1}\\b -\\sigma \\e = \\j_s,\n\\end{equation}\nwhere $\\e$ is electrical field, $\\b$ is magnetic flux density, $\\j_s$ is the source term, $\\sigma$ is conductivity and $\\mu$ is magnetic susceptibility.\n% \\begin{equation}\n%   \\curl \\E = -\\imath \\omega \\B,\n% \\end{equation}\n% \\begin{equation}\n%   \\curl \\mu^{-1}\\B -\\sigma \\E = \\J_s.\n% \\end{equation}\nWe consider electrical conductivity ($\\sigma$) as a physical model that we want to recover from the EM inversion, and this can be 3D distribution: $\\sigma(x, y, z)$. We excite the earth by putting time varying current through source term: $\\j_s$, and measure EM response form the earth on receiver locations. By discretizing above Maxwell's equations for both TD and FD, we can compute forward response, which can be simply written as\n\\begin{equation}\n  d^{pre} = F[\\sigma],\n\\end{equation}\nwhere $F[\\cdot]$ is Maxwell's operator and $d^{pre}$ is computed EM response on receiver locations for corresponding source.\nA major goal of EM survey is to recover distribution of the conductivity. To achieve this goal, we use geophysical inversion technique based on gradient based optimization. Objective function of the inversion can be written as\n\\begin{equation}\n  \\phi(m) = \\phi_d(m) + \\beta\\phi_m(m),\n\\end{equation}\nwhere $\\phi$ is the objective function, $\\phi_d=\\frac{1}{2}\\|d^{pred}-d^{obs}\\|^2_2$ is data misfit, $\\phi_m$ is regularization term, $\\beta$ is trade-off term between $\\phi_d$ and $\\phi_m$, and $m$ is the inversion model. Recalling we defined model mapping function: $\\sigma = \\mathcal{M}[m]$, we can transform the inversion model to conductivity in 3D. The core of the gradient based optimization is the sensitivity function:\n\\begin{equation}\n  J = \\frac{\\partial F[\\sigma]}{\\partial m} = \\frac{\\partial d^{pred}}{\\partial \\sigma}\\frac{\\partial \\sigma}{\\partial m}.\n\\end{equation}\nAssuming that we know how to compute $\\frac{\\partial F[\\sigma]}{\\partial \\sigma}$, we can proceed EM inversion with the knowledge of derivative of the mapping function($\\frac{\\partial \\sigma}{\\partial m} = \\frac{\\partial \\mathcal{M}(m)}{\\partial m}$).\nThis mapping does not necessarily has to be a single function, but can be a combination of multiple functions, and computation of derivative can be defined using chain-rule. For example, conventionally in EM inversion, we use logarithmic conductivity ($m = log(\\sigma)$) as our model, and we do not include air cells in our forward modeling domain. Therefore, in this case, our mapping can be expressed as a combination of two different maps:\n\\begin{equation}\n  \\sigma = \\mathcal{M}_{exp}[\\mathcal{M}_{active}[m]],\n  \\label{eq:combomap1}\n\\end{equation}\nwhere $\\mathcal{M}_{exp}[m]=exp(m)$ is exponential map and $\\mathcal{M}_{active}[m]$ is active map. Here, the active maps transforms our model parameter, which is only defined inside of the earth:\n\\begin{equation}\n  \\sigma = \\mathcal{M}_{active}[m] = Q_{active}m + m_{inactive},\n\\end{equation}\nwhere $Q_{active}$ is a mapping matrix composed of 0 and 1, which maps active cells to entire cells in the domain. $m_{inactive}$ is a model for inactive cells, and this has same dimension with entire cells. Computating the derivative of mapping $w.r.t$ $m$ for these maps are straightforward. Similarly, we can have 1D or 2D maps ($\\mathcal{M}_{1D}[m]$ and $\\mathcal{M}_{2D}[m]$), which take 1D or 2D model and transform to 3D model. Therfore combined model with equation (\\ref{eq:combomap1}), can be written as\n\\begin{equation}\n  \\sigma = \\mathcal{M}_{exp}[\\mathcal{M}_{1D \\ or \\ 2D}[\\mathcal{M}_{active}[m]]].\n  \\label{eq:combomap2}\n\\end{equation}\nFor this case, with 1D map in vertical direction, our model can be logarithmic conductivity of subsurface layers, but the output of the combined map is 3D conductivity of the earth including air cells. Implementation of a geometircal model such as ellipsoid and arbitrary plane to the inversion is straightforward, once we have knowledge to evaluate mapping function and its derivative.\n\n\\section*{Seawater intrusion example}\nIn coastal area, seawater intrusion is a serious problem due to the contamination of groundwater (Figure \\ref{fig:concept}). One of the key to treat this problem is to recognizing the distribution of highly saturated zone by seawater. Ground loop EM survey has been used to detect intruded seawater, because of highly conductive nature of the seawater (\\cite{Mills1988}). Figure \\ref{fig:concept} shows typical ground loop TEM survey geometry and hydorological model on coastal area. By putting time-varying current through the transmitter loop, we excite the earth. We use EM induction phenomenon to excite the earth in this case, which is highly sensitive to conductive structure. 3D conductivity model shown in Figure \\ref{fig:sigtrue} clearly shows intruded seawater distribution in 3D. As a geophyscist, we may want to suggest possible region where we have serious seawater intrusion. Therefore, recovering conductivity distribution, which has high correlation with seawater saturation is a principal task. More specifically, interface between freshwater and seawater is an important information.\n\\plot{concept}{width=0.8\\columnwidth}\n{Conceptual diagram of sea water intrusion and geometry of ground loop EM survey.}\n\n\\plot{sigtrue}{width=1.0\\columnwidth}\n{Plan and section views of 3D conductivity model for seawater intrusion.}\n\n\\subsection*{Feasibility test: anomalous response}\nTo measure EM response from the intruded seawater, we need to design a proper survey parameter. Figure \\ref{fig:geometry} shows survey geometry of ground loop EM survey. We have two circular loops, which has 250 m radius. We use simple layered earth model (1D) to make this analyses simple. Because ground loop source is circular thus, survey parameters are distance from the center of the loop ($r$) and time. We compute two forward responses due to the layered model with seawater layer and without seawater layer, and compute amplitude ratio between them. This 1D model is shown in the right panel of Figure \\ref{fig:ampratio_time}. Because we measure vertical component of magnetic flux density ($b_z$), amplitude ratio that we compute can be written as $\\Big|\\frac{b_z[\\sigma_{seawater}]|}{b_z[\\sigma_{background}]}\\Big|$. In the right panel of Figure \\ref{fig:ampratio_time}, we provide amplitude ratio in 2D plane of which axes are time and $r$. Contours on high amplitude ratios clearly shows measured response at time range 1-10 ms are sensitive to the seawater. At the center of the loop ($r$=0), we have maximum ratio, and it decreases $r$ increases. Based on this feasibility test, we designed ground loop EM survey geometry as shown in Figure \\ref{fig:geometry}, and the time range we measure EM response is 0.1-10 ms.\n\n\\plot{geometry}{width=0.8\\columnwidth}\n{Ground loop EM survey geometry. Blue and red color indicate corresponding Tx and Rx pairs. Black dots show a line profile data used for 1D and 2D inversion. }\n\n\\plot{ampratio_time}{width=1.0\\columnwidth}\n{Layered-earth model for seawater intrusion (left panel). Amplitude ratio of vertical magnetic flux density with seawater and without seawater (right panel).}\n\n\\subsection*{1D and 2D inversion}\nConventionally for ground loop EM survey, we only measure one or two profile lines of the data in the loop (CITE). And for the interpretation of this data, we use 1D inversion, which assume layered-earth structure; here 1D inversion for each datum is separate. After 1D inversion for each datum, we stitch recovered 1D conductivity model together to make a 2D-like section images. We generated synthetic ground TEM data set using conductivity model shown in Figure \\ref{fig:sigtrue} with survey geometry shown in Figure \\ref{fig:geometry}. Using mappting function for 1D and 2D inversion (equation (\\ref{eq:combomap2})), we can proceed EM inversion. For 2D case, the forward modeling is performed in 3D, although our inversion model is in 2D. Applying same procedure to 1D stitched case is possible, but this will be expensive. We use 2D cylinderical mesh by exploiting azimuthal symmetry of the system. For this case, thus conductivity is defined on 2D mesh, although the inversion model is 1D layered-earth.\nConsidering typical field configuration, we only used a profile line in two loops for 1D and 2D inversions, which are expressed as black dots in Figure \\ref{fig:geometry}.\nRecovered 1D stitched inversion model shown on the left panel of Figure \\ref{fig:1DinvTD} shows reasonable layering on the east-side. However, on the west-side we can recognize artifacts in 1D stitched inversion due to 3D effect. On the right panel of Figure \\ref{fig:1DinvTD}, we have also shown recovered conductivity model from 2D inversion. This shows better horizontal resolution then 1D inversion results, whereas layering show more spreaded distribution compared to 1D case. Comparison of observed and predicted data for these 1D and 2D inversions are shown in Figure \\ref{fig:1D2Dobspred}. Although both predicted data from 1D and 2D inversion results show reasonable match with the observed data, we can recognize some discrepancy between observed and predicted data, which may be caused by 3D effect that we cannot explain with 1D or 2D model.\n\n\\plot{1DinvTD}{width=1.0\\columnwidth}\n{Vertical sections of recovered conductivity. Left and right panel show 1D stitched and 2D inversion.}\n\n\\plot{1D2Dobspred}{width=1.0\\columnwidth}\n{Comparisons of observed and predicted data for 1D and 2D inversions. }\n\n\\subsection*{3D inversion}\nIn reality, the distribution of intruded seawater is in 3D, thus restoration of 3D conductivity model is one of the important tasks to characterize seawater intruded region in the subsurface. For 1D and 2D inversions, we used a profile line data, which were located in the loops. However, for 3D inversion, having more measurement points aside from the center line is be crucial to have reasonable sensitivity for the 3D volume. We used all receivers shown in Figure \\ref{fig:geometry}. Using mapping function shown in equation \\ref{eq:combomap1}, we perform 3D EM inversion. Figure \\ref{fig:3DinvTD} shows plan and section views of the recovered conductivity model from the 3D inversion. Interface between fresh and seawater is nicely imaged in both horizontal and vertical directions. We fit the observed data well as shown in Figure \\ref{fig:3Dobspred}. We also provide cut-off 3D volume of conductivity distribution in Figure \\ref{fig:final}.\n\n\\plot{3DinvTD}{width=1.0\\columnwidth}\n{Plan and section views of recovered 3D conductivity.}\n\n\\plot{3Dobspred}{width=1.0\\columnwidth}\n{A comparison of observed and predicted response for transmitter one.}\n\n\\section*{Conclusions}\nUsing mapping function in our geophysical inversion, we decoupled inversion model space from physical model space. This enables us to set an arbitrary inversion model, although our forward modeling space can be in 3D. We set three different inversion models, which were 1D, 2D and 3D using mapping function, and performed TEM inversions for seawater intrusion problem. Each inversion showed reasonable recovered model based on the used mapping for each case. Although we treated limited subsets of inversion models such as 1D, 2D and 3D, general definition of mapping function that we suggested can be extended to a parametric inversion model such as geometry of interfaces. For instance, we can ask a specific question: ``where is the boundary of freshwater and seawater?'' in the EM inversion using this mapping function. We believe this separation of inversion model from physical property model will be a powerful concept in the geophysical inversion because the capability to resolve a certain geological feature of the earth system  will accelerate communications with other disciplines in geoscience.\n\n\\plot{final}{width=1.0\\columnwidth}\n{Cut-off 3D volume of true and recovered conductivity distribution of seawater intrusion.}\n\n% \\plot{model}{width=0.75\\columnwidth, height=0.22\\textheight}\n% {Planal and sectional views of 3D complex conductivity model based on Cole-Cole representation. Dashed line in contours the boundary of the conductive IP body.}\n\n% \\multiplot{2}{resp_ch1,resp_ch2}{width=0.5\\textwidth, height=0.18\\textheight}\n% {Responses of $EMIP$ (black line), $EM$ (blue line) at $t=6$ (a) and $t=24$ $ms$ (b). Top-left panels of (a) and (b) show time decay curves at center sounding location and dashed circles here show that corresponding time for other figures. Bottom pannels of (a) and (b) show that responses from all the sounding in the survey geometry at specific time channel and solid circles here indicate sounding locations. Red dashed line indicates the profile lines, which are shown at top-right panels of (a) and (b).}\n\n\n\n\\section{Acknowledgement}\nThank you for Klara Steklova for helpful discussion about hydrological problem and  \\SimPEG developers. Generating 3D distribution of seawater intrusion model was performed using GIFtools.\n\n\\twocolumn\n\\onecolumn\n% \\append{The source of the bibliography}\n% \\verbatiminput{example.bib}\n\\bibliographystyle{seg}  % style file is seg.bst\n\\bibliography{example}\n\n\\end{document}\n", "meta": {"hexsha": "fb82c180103694421c62f4c4060f53d0d3ab6bcd", "size": 22018, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "finaldocs/SEG2015/SEG2015_MovingDims.tex", "max_stars_repo_name": "rowanc1/AGU2014MovingDimensionsinEM", "max_stars_repo_head_hexsha": "cfe406b677db6b00948f90ac47050b1c1a493ac0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-16T04:38:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-16T04:38:28.000Z", "max_issues_repo_path": "finaldocs/SEG2015/SEG2015_MovingDims.tex", "max_issues_repo_name": "rowanc1/AGU2014MovingDimensionsinEM", "max_issues_repo_head_hexsha": "cfe406b677db6b00948f90ac47050b1c1a493ac0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "finaldocs/SEG2015/SEG2015_MovingDims.tex", "max_forks_repo_name": "rowanc1/AGU2014MovingDimensionsinEM", "max_forks_repo_head_hexsha": "cfe406b677db6b00948f90ac47050b1c1a493ac0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.4873646209, "max_line_length": 1331, "alphanum_fraction": 0.7629212463, "num_tokens": 5907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4052656237817491}}
{"text": "\\documentclass{beamer}\n\n\\title{Raven Comparison Statistics}\n\\author{Josh Cogliati\\\\ (and this would not have happened without\\\\ Ivan Rinaldi and Cristian Rabiti.  \\\\Thanks also to Andrea Alfonsi and Diego Mandelli)}\n\n\n\\begin{document}\n\n\\begin{frame}\n  \\titlepage\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Outline}\n  \\tableofcontents\n\\end{frame}\n\n\\section{Motivation}\n\n\\begin{frame}\n  \\frametitle{Why are we doing this?}\n  We have codes that we need to compare to each other and to experiments.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example}\n  \\includegraphics[height=6cm]{example}\n\\end{frame}\n\n\\section{Comparisons}\n\n%cdf area difference\n\\begin{frame}\n  \\frametitle{CDF difference area}\n  This calculates the difference in area between the two CDFs\n  \\begin{equation}\n    cdf\\_area\\_difference = \\int_{-\\infty}^{\\infty}{\\|CDF_a(x)-CDF_b(x)\\|dx}\n  \\end{equation}\n  \\begin{columns}\n    \\column{.5\\textwidth}\n    \\includegraphics[height=3cm]{example_cdf_area}\n    \\column{.5\\textwidth}\n    Note that this area will have the same units as x.\n  \\end{columns}\n\\end{frame}\n\n%common pdf area\n\\begin{frame}\n  \\frametitle{Common PDF area}\n  This calculates the common area between the two PDFs.\n  \\begin{equation}\n    pdf\\_common\\_area = \\int_{-\\infty}^{\\infty}{\\min(PDF_a(x),PDF_b(x))}dx\n  \\end{equation}\n  \\begin{columns}\n    \\column{.5\\textwidth}\n    \\includegraphics[height=3cm]{example_pdf_common}\n    \\column{.5\\textwidth}\n    This will range from 0\\% to 100\\%, with 100\\% being a complete match.\n  \\end{columns}\n\\end{frame}\n\n\n%difference between pdfs\n\\begin{frame}\n  \\frametitle{Difference between PDFs}\n  This calculates a difference between the PDFs.\n  \\begin{equation}\n    f_Z(z) = \\int_{-\\infty}^{\\infty}f_X(x)f_Y(x-z)dx\n  \\end{equation}\n  \\begin{columns}\n    \\column{0.5\\textwidth}\n    \\includegraphics[height=3cm]{f_z}\n    \\column{0.5\\textwidth}\n    This generates a new pdf, with mean related\n    to the average difference, and variance depending on a variety of\n    factors.\n  \\end{columns}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Use of Differences between PDFs}\n  This calculates the average:\n  \\begin{equation}\n    \\bar{z} = \\int_{-\\infty}^{\\infty}{z f_Z(z)dz}\n  \\end{equation}\n  This calculates the variance:\n  \\begin{equation}\n    var = \\int_{-\\infty}^{\\infty}{(z-\\bar{z})^2 f_Z(z)dz}\n  \\end{equation}\n\\end{frame}\n\n\\section{Implementation}\n\n%getting bins\n\\begin{frame}\n  \\frametitle{Getting the Numeric CDF and PDF}\n  \\begin{enumerate}\n  \\item Get the data and sort it\n  \\item Choose bins boundaries, and count the number of points in each bin\n  \\item Normalize the number of bins, and then calculate the running total to get the CDF\n  \\item Take the derivative of the CDF to get the PDF.\n  \\end{enumerate}\n\\end{frame}\n\n%creating interpolation functions\n\\begin{frame}\n  \\frametitle{Interpolation functions}\n  \\begin{itemize}\n  \\item Using scipy's intererpolate.interp1d with the numeric data\n  \\item For the pdf, force the numbers outside the data to be zero\n  \\item For the cdf, force the numbers lower that the data to zero and higher to one\n  \\end{itemize}\n\\end{frame}\n\n%integrating\n\\begin{frame}\n  \\frametitle{Integrating functions}\n  \\begin{itemize}\n  \\item Use Simpson method for calculating numbers\n  \\item For the pdfs and cdfs, use $-3\\sigma+\\mu$ to $3\\sigma+\\mu$ as\n    the bounds (and the min and max of these if there are multiple\n    ones)\n  \\item For the $f_Z$, the midpoint is $\\mu_X-\\mu_Y$ and the lower and\n    upper bounds are $3\\sigma_{max}$ away (where the largest $\\sigma$\n    is used).\n  \\end{itemize}\n\\end{frame}\n\n\\section{Future Directions}\n\n\\begin{frame}\n  \\frametitle{Future things to do}\n  \\begin{itemize}\n  \\item Multidimensional data\n  \\item Correlated data (input and output correlated)\n  \\item Flexibility for statistics (plugins or interfaces)\n  \\end{itemize}\n\\end{frame}\n\n\\section{Comments}\n\n\\begin{frame}\n  \\frametitle{Comments, complaints, concerns, contraindications, contributions \\ldots ?}\n\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "905a8dfe3e17468c11c1c3ce2e794fb6718735fb", "size": 3969, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/misc/comparison_stats/stats_presentation/presentation.tex", "max_stars_repo_name": "rinelson456/raven", "max_stars_repo_head_hexsha": "1114246136a2f72969e75b5e99a11b35500d4eef", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 159, "max_stars_repo_stars_event_min_datetime": "2017-03-24T21:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:44:40.000Z", "max_issues_repo_path": "doc/misc/comparison_stats/stats_presentation/presentation.tex", "max_issues_repo_name": "rinelson456/raven", "max_issues_repo_head_hexsha": "1114246136a2f72969e75b5e99a11b35500d4eef", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1667, "max_issues_repo_issues_event_min_datetime": "2017-03-27T14:41:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T19:50:06.000Z", "max_forks_repo_path": "doc/misc/comparison_stats/stats_presentation/presentation.tex", "max_forks_repo_name": "rinelson456/raven", "max_forks_repo_head_hexsha": "1114246136a2f72969e75b5e99a11b35500d4eef", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 95, "max_forks_repo_forks_event_min_datetime": "2017-03-24T21:05:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-08T17:30:22.000Z", "avg_line_length": 27.0, "max_line_length": 155, "alphanum_fraction": 0.7180650038, "num_tokens": 1221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.405265620069523}}
{"text": "\\chapter{Formalism}\n\\label{chap:cpv:theory}\n\nThe measurement of \\ARaw, as defined in \\cref{eqn:cpv:introduction:araw}, can\nbe contaminated by production and detection asymmetries.\nBy reconstructing \\LcTopKK\\ and \\LcToppipi\\ decays from\n\\decay{\\PLambdab}{\\PLambdac\\Pmuon X}\\ decays, \\ARaw\\ can include the effects of\nthe \\PLambdab/\\APLambdab\\ production asymmetry, the \\Pmuon/\\APmuon detection\nasymmetry, and the detection asymmetry of the \\PLambdac\\ final state\n$f$/$\\bar{f}$.\n\nThe \\PLambdab\\ production asymmetry is predicted to be non-zero due to the \\pp\\\ncollision environment~\\cite{PhysRevD.90.014023}, and indeed \\lhcb\\ has found\nevidence of such an asymmetry as a function of \\PLambdab\\\nrapidity~\\cite{Aaij:2015fea}.\nThe two detection asymmetries are also expected to be non-zero, due to the\nknown differences between the hadron/anti-hadron and muon/anti-muon\ncross-sections with matter~\\cite{PDG2014}.\nThe final state detection asymmetry can be broken down into two terms: one due\nto the detection asymmetry of the proton; and another due to the detection\nasymmetry of the \\KmKp pair and the \\pimpip\\ pair.\nIf the meson kinematics are equal within a given mode, for example if the\n\\PKminus kinematics are identical to those of the \\PKplus\\ in the \\pKK\\ data,\nthen the final state asymmetry reduces to the proton detection asymmetry.\n\nBoth the \\PLambdab\\ production and the muon detection asymmetries should be\nindependent of the \\PLambdac\\ final state, given the same \\PLambdac\\\nkinematics.\nDifferent acceptance efficiencies between \\pKK\\ and \\ppipi\\ can create unequal\n\\PLambdac\\ kinematics, but the kinematics can be weighted to equalise them\nbetween the modes.\n\nIt will now be shown how the background asymmetries entering \\ARaw\\ can be\nremoved in the difference \\dACP\\@.\nThe number of reconstructed \\LcTof\\ decays can be expressed as the product of\nseveral effective probabilities\n\\begin{equation}\n  N(f) = \\prob(\\PLambdab)\\cdot\n         \\Gamma(\\LbToLcmuX)\\cdot\n         \\Gamma(\\LcTof)\\cdot\n         \\eff(\\Pmuon)\\cdot\n         \\eff(f),\n  \\label{eqn:cpv:theory:yield}\n\\end{equation}\nwhere $\\prob(\\PLambdab)$ is the probability of producing a $\\PLambdab$ baryon\ngiven a \\pp\\ collision, and $\\eff(\\Pmuon)$ and $\\eff(f)$ are the muon and\n$\\PLambdac$ final-state detection efficiencies.\nA similar expression exists for $N(\\bar{f})$, where are particles are replaced\nby their charge conjugates.\nIt is assumed that the \\LbToLcmuX\\ decay is \\CP-symmetric, but that all other\nfactors may not be, for example $\\eff(\\Pmuon) \\neq \\eff(\\APmuon)$.\n\nTo express \\ARaw\\ in terms of its component asymmetries, the notation of a\ngeneral asymmetry parameter $X$ is defined, which describes the asymmetry\nbetween two quantities $x$ and $\\bar{x}$\n\\begin{equation}\n  X = \\frac{x - \\bar{x}}{x + \\bar{x}}.\n  \\label{eqn:cpv:theory:generic_asym}\n\\end{equation}\nThis can be rearranged as\n\\begin{align}\n  x &= \\frac{1}{2}(x + \\bar{x})(1 + X),\\ \\text{and}\\label{eqn:cpv:theory:asym_form_one}\\\\\n  \\bar{x} &= \\frac{1}{2}(x + \\bar{x})(1 - X).\\label{eqn:cpv:theory:asym_form_two}\n\\end{align}\nAn asymmetry parameter like that in \\cref{eqn:cpv:theory:generic_asym} can be defined for each of the relevant terms in\n\\cref{eqn:cpv:theory:yield}\n\\begin{align*}\n  \\APLb(f) &= \\frac{%\n    \\prob(\\PLambdab) - \\prob(\\APLambdab)\n  }{%\n    \\prob(\\PLambdab) + \\prob(\\APLambdab)\n  },\\\\\n  \\ADmu(f) &= \\frac{%\n    \\eff(\\Pmuon) - \\eff(\\APmuon)\n  }{%\n    \\eff(\\Pmuon) + \\eff(\\APmuon)\n  },\\ \\text{and}\\\\\n  \\ADf(f)  &= \\frac{%\n    \\eff(f) - \\eff(\\bar{f})\n  }{%\n    \\eff(f) + \\eff(\\bar{f})\n  },\n\\end{align*}\nand the asymmetry in $\\Gamma(\\LcTof)$ is \\ACP\\ as in\n\\cref{eqn:cpv:introduction:acp}.\nEach parameter is, at least implicitly, dependent on the detected \\PLambdac\\\nfinal state, as each parameter can vary in quantities that may also vary\nbetween \\PLambdac\\ decay modes.\nSubstituting Equation~\\ref{eqn:cpv:theory:yield} into\nEquation~\\ref{eqn:cpv:introduction:araw}\n\\begin{equation*}\n  \\ARaw(f) = \\frac{%\n    \\prob(\\PLambdab)\\Gamma(f)\\eff(\\Pmuon)\\eff(f) -\n    \\prob(\\APLambdab)\\Gamma(\\bar{f})\\eff(\\APmuon)\\eff(\\bar{f})\n  }{%\n    \\prob(\\PLambdab)\\Gamma(f)\\eff(\\Pmuon)\\eff(f) +\n    \\prob(\\APLambdab)\\Gamma(\\bar{f})\\eff(\\APmuon)\\eff(\\bar{f})\n  },\n\\end{equation*}\nand then substituting each quantity for its equivalent form as in\n\\cref{eqn:cpv:theory:asym_form_one,eqn:cpv:theory:asym_form_two}, all factors\nof $\\sfrac{1}{2}$ and all factors of the form $(x - \\bar{x})$ cancel, leaving\n\\begin{equation}\n  \\ARaw(f) = \\frac{Y}{Z}.\n\\end{equation}\nwhere (dropping the final state parameter temporarily for compactness)\n\\begin{align}\n  Y = \\APLb\\ADmu\\ADf &+ \\APLb\\ADmu\\ACP + \\APLb\\ADf\\ACP + \\ADmu\\ADf\\ACP \\nonumber\\\\\n                     &+ \\APLb +  \\ADmu + \\ADf + \\ACP,\n\\end{align}\nand\n\\begin{align}\n  Z = 1 &+ \\APLb\\ADmu + \\APLb\\ADf + \\APLb\\ACP + \\ADmu\\ADf + \\ADmu\\ACP \\nonumber\\\\\n        &+ \\ADf\\ACP + \\APLb\\ADmu\\ADf\\ACP.\n\\end{align}\nAssuming that the individual asymmetries are small, of the order of\n\\SI{1}{\\percent}, the product of two or more asymmetries is negligible with\nrespect to the leading order, and so\n\\begin{equation}\n  \\ARaw(f) \\approx \\ACP(f) + \\APLb(f) + \\ADmu(f) + \\ADf(f).\n  \\label{eqn:cpv:theory:araw_approx}\n\\end{equation}\nBy assuming that these background asymmetries are mode-independent, that is to\nsay $\\AD(f) = \\AD(g)$ and $\\AP(f) = \\AP(g)$, the difference between \\ARaw\\ for\nthe \\pKK\\ and \\ppipi\\ will only have contributions from \\ACP\n\\begin{align}\n  \\dACP &= \\ARaw(\\pKK) - \\ARaw(\\ppipi),\\label{eqn:cpv:theory:dacp}\\\\\n        &\\approx \\ACP(\\pKK) - \\ACP(\\ppipi)\\nonumber.\n\\end{align}\n\nThe assumption that the production and detection asymmetries in\n\\cref{eqn:cpv:theory:araw_approx} are mode independent is not true in general.\nThis can been seen by first making a weaker assumption that the background\nasymmetries are dependent only on the kinematics of the representative\nparticles.\nDifferent final states will in general have different acceptance,\nreconstruction and selection efficiencies as a function of \\PLambdac\\\nkinematics.\nThe kinematics of the \\PLambdac\\ are correlated to those of the muon and the\n\\PLambdab, and so two samples with different \\PLambdac\\ kinematics will likely\nalso have different \\PLambdab\\ and muon kinematics.\nHence, there can still be net production and detection asymmetries in \\dACP\\@.\n\nThe assumption that the background asymmetries depend only on particle\nkinematics is not unreasonable.\nThe production asymmetry, for example, is a difference in cross-sections, which\nare usually parameterised by the kinematics of the produced particle (\\pT\\ and\neither \\Eta\\ or rapidity).\nSimilarly, a detection asymmetry describes the differences of material\ninteractions between matter and antimatter, and these are dependent on the\nmomentum of the particle in question and, assuming a non-uniform material\ndistribution, its flight path.\n\nAs it is not given that the \\PLambdac\\ kinematics are the same between\n\\LcTopKK\\ and \\LcToppipi\\ decays in the data, the data can be weighted to\nequalise the \\PLambdac\\ kinematics.\nThe background asymmetries \\AP\\ and \\ADmu\\ will then cancel in the difference\n\\dACP\\@.\nThe proton kinematics will not necessarily agree after such a weighting, as the\nenergy release in the \\pKK\\ and \\ppipi\\ decays is different.\nThese considerations govern the analysis strategy: measure the number of\n\\PLambdac\\ candidates in the \\pKK\\ and \\ppipi\\ samples after weighting them\nsuch that the \\PLambdac\\ kinematics look alike, such that the \\PLambdab\\ and\n\\Pmuon kinematics also agree.\nAdditional weighting may be required to equalise the proton kinematics.\n\n\\section{Decay phase space}\n\\label{chap:cpv:theory:phsp}\n\nThe phase space of a decay is the set of variables which fully parameterises\nall possible dynamics.\nAlthough a three-body decay requires 12 parameters to describe the kinematics,\nunder the assumptions of four-momentum conservation and that the masses of the\nthree decay products are known, the number of free parameters is only five.\nWhen all particles involved have zero spin, the distribution of the momenta of\nthe decay products is isotropic, such that there are only 2 degrees of freedom.\nThese are usually taken to be two child-pair squared masses, which can be\nvisualised as a Dalitz plot.\nIn the case of \\LcTophh, the spin \\sfrac{1}{2} of the proton means that the\nthree-body system is no longer rotationally symmetric, and the full five\ndegrees of freedom are required to describe the phase space.\n\nFor a meaningful comparison of the measurement of \\dACP\\ with theoretical\npredictions, which are not presently available, the efficiency of the\n\\PLambdac\\ selection across the five-dimensional phase space must be known.\nThe definition of ``selection'' includes the effects of the \\lhcb\\ acceptance\nand the trigger, stripping, and offline requirements.\nThe efficiency model can either be provided to theorists so that they can apply\nthe same efficiencies to their phase space models, or it can be used to correct\nthe data before the \\dACP\\ measurement is made.\n\nThe five dimensions of the phase space are defined here in a similar way to the\n\\LcTopKpi\\ amplitude analysis performed by the \\esno\\\ncollaboration~\\cite{Aitala:1999uq}.\nThis defines two child-pair squared masses, of the proton and\noppositely-charged child \\msqphm\\ and of the two opposite-sign pseudo-scalars\n\\msqhh, and three decay angles.\nThe child-pair squared masses are invariant under Lorentz transformations, but\nthe decay angles are not and so a definition of the frame in which they are\ncomputed is required.\n\nThe \\esno\\ analysis defines a coordinate system in the \\PLambdac\\ rest frame.\nThe $z$-axis, also called the quantisation axis or polarisation axis \\polzlcp,\nis perpendicular to the plane of production\n\\begin{equation}\n  z = \\polzlcp = \\phatbeam \\times \\phatlcp,\n\\end{equation}\nwhere \\phatbeam\\ is the direction of the beam\\footnotemark\\ and \\phatlcp\\ is\nthe direction of the \\PLambdac\\ measured in the laboratory frame.\n\\footnotetext{%\n  E791 was a fixed-target experiment, colliding a \\SI{500}{\\GeVc} pion beam\n  with metal foils.\n}\nThe $x$-axis of the \\PLambdac\\ rest frame is \\phatlcp.\nAs the \\PLambdac\\ candidates in this analysis are not produced directly from\nthe \\pp\\ collision but in the decays of \\PLambdab\\ baryons, here the `beam\ndirection' is defined as the direction of the \\PLambdab\\ momentum vector, which\nis equal to the direction vector pointing from the \\pp\\ primary vertex\n$v_{\\pp}$ to the $\\PLambdac\\Pmuon$ vertex $v_{\\PLambdac\\Pmuon}$\n\\begin{equation}\n  \\phatbeam = \\phatlbz = v_{\\PLambdac\\Pmuon} - v_{\\pp}.\n\\end{equation}\nWith this coordinate system and inertial frame, the three decay angles are\ndefined as:\n\\begin{enumerate}\n  \\item The angle \\thetap\\ between the proton momentum vector and the $z$-axis;\n  \\item The angle \\phip\\ between the proton momentum vector and the $x$-axis;\n    and\n  \\item The angle \\phihh\\ between the plane containing the proton momentum\n    vector and the $z$-axis and the plane containing the two pseudo-scalar\n    meson momentum vectors.\n\\end{enumerate}\nThese definitions are illustrated in \\cref{fig:cpv:theory:phsp:angles}\n\nThe distributions of the five phase space variables will be presented in\n\\cref{chap:cpv:phsp}, along with the evaluation of the efficiency as a function\nof the position in phase space.\n\n\\begin{figure}\n  \\begin{subfigure}{0.5\\textwidth}\n    \\resizebox{\\textwidth}{!}{%\n      \\input{figures/cpv/theory/phase_space_angles}\n    }\n  \\end{subfigure}\n  \\begin{subfigure}{0.5\\textwidth}\n    \\resizebox{\\textwidth}{!}{%\n      \\input{figures/cpv/theory/phase_space_planes}\n    }\n  \\end{subfigure}\n  \\caption{%\n    Definition of inertial reference frame axes and \\LcTophh\\ phase space decay\n    angles.\n    Adapted from Figure~1 in the \\esno\\ \\LcTopKpi\\ amplitude analysis\n    paper~\\cite{Aitala:1999uq}.\n  }\n  \\label{fig:cpv:theory:phsp:angles}\n\\end{figure}\n", "meta": {"hexsha": "cc3ca2c964f35d21727d69c1bddd7b77dc4bb42c", "size": 11857, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/cpv/theory.tex", "max_stars_repo_name": "alexpearce/Thesis", "max_stars_repo_head_hexsha": "d727d04b7ee619ba0eb45c7faf1004eb418e046e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-18T00:58:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T00:58:34.000Z", "max_issues_repo_path": "chapters/cpv/theory.tex", "max_issues_repo_name": "alexpearce/Thesis", "max_issues_repo_head_hexsha": "d727d04b7ee619ba0eb45c7faf1004eb418e046e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/cpv/theory.tex", "max_forks_repo_name": "alexpearce/Thesis", "max_forks_repo_head_hexsha": "d727d04b7ee619ba0eb45c7faf1004eb418e046e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-05-13T07:54:57.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-06T23:42:27.000Z", "avg_line_length": 45.9573643411, "max_line_length": 119, "alphanum_fraction": 0.7473222569, "num_tokens": 3541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4052656163572968}}
{"text": "\\subsection{Analysis of Rapid Environmental Fluctuations}\nIn this article, to analyze the interaction of the mixed growth of multiple fungi, we establish Multi-groups Logistic Model. However, we do not make a detailed analysis of the environmental changes. Hence, we are going to examine the sensitivity of our model to rapid fluctuations in the environment.\n\\par\nIn the real natural environment, disasters that are not conducive to the survival and reproduction of living things happen from time to time. When a disaster occurs, the natural environment fluctuates rapidly, and the survival of organisms in the area is threatened and restricted. Combining our model and the characteristics of fungi, we find that when the environment fluctuates rapidly, the inherent growth rate of fungi will change rapidly in a short time. Meanwhile, the natural maximum capacity of fungi will be reduced accordingly.", "meta": {"hexsha": "7aaa8fb1121b9cef0e564852abc1249a534412d3", "size": 902, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "5/1.tex", "max_stars_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_stars_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-11-07T14:38:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-11T10:37:34.000Z", "max_issues_repo_path": "5/1.tex", "max_issues_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_issues_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "5/1.tex", "max_forks_repo_name": "syy11cn/2021-mcm-meritorious-article", "max_forks_repo_head_hexsha": "3eaf143f4319fae681d98134bfc7e699833d8273", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 225.5, "max_line_length": 538, "alphanum_fraction": 0.8237250554, "num_tokens": 167, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4052360528289044}}
{"text": "\\chapter{Introduction}\n\\label{chap:introduction}\n\n\\section{Motivation and the research needs}\nBoolean satisfiability (SAT)~\\cite{SATHandbook} has been successfully applied to numerous research fields\nincluding artificial intelligence~\\cite{Nilsson2014,Russell2020},\nelectronic design automation~\\cite{Marques2000,Wang2009},\nsoftware verification~\\cite{Jhala2009, Berard2013}, etc.\nThe tremendous benefits have encouraged the development of more advanced decision procedures\nfor satisfiability with respect to more complex logics beyond pure propositional.\nFor example,\nsolvers for majority SAT (MAJSAT) decide whether the majority of the assignments satisfy a propositional formula,\nand its functional problem is known as model counting~\\cite{SATHandbook-ModelCounting};\nquantified Boolean formula (QBF)~\\cite{Narizzano2006,SATHandbook-QBF} allows both existential and universal quantifiers;\nstochastic Boolean satisfiability (SSAT)~\\cite{Littman2001,SATHandbook-SSAT} models uncertainty with randomized quantification;\ndependency QBF (DQBF)~\\cite{Balabanov2014,Scholl2018} equips Henkin quantifiers to describe multi-player games with partial information;\nand solvers of the satisfiability modulo theories (SMT)~\\cite{Moura2011,HBMC-SMT} accommodate first order logic fragments.\nDue to their simplicity and generality,\nvarious satisfiability formulations are under active investigation.\n\nAmong various generalizations of Boolean satisfiability,\n\\textit{stochastic Boolean satisfiability} (SSAT)~\\cite{SATHandbook-SSAT} is a logical formalism\nfor problems endowed with randomness.\nFirst formulated by Papadimitriou,\nSSAT is interpreted as \\textit{games against nature}~\\cite{Papadimitriou1985}.\nNondeterministic factors are introduced into the world of propositional logic\nthrough the creation of the \\textit{randomized quantifier}.\nA Boolean variable $x$ can be randomly quantified with a probability $p\\in[0,1]$ in an SSAT formula\nby a randomized quantifier $\\random{p}$ that requires $x$ to take the Boolean value\n\\true with probability $p$ and\n\\false with probability $1-p$.\nVia randomized quantifiers,\na variety of computational problems inherent with uncertainty can be encoded into SSAT formulas,\nsuch as propositional probabilistic planning~\\cite{Littman1998},\nBayesian-network inference~\\cite{Cooper1990,Jensen1996,Bacchus2003},\nand the analysis of partially observable Markov decision process (POMDP)~\\cite{Majercik2003}.\n\nWhile SSAT has been employed to solve various AI problems,\nto the best of our knowledge,\nit has not yet been applied to analyze VLSI systems,\nand how VLSI systems would benefit from the probabilistic reasoning of SSAT remains unclear.\nConventionally, uncertain system behavior is undesirable and\nwould be mitigated by employing techniques such as\nerror detection~\\cite{Constantinescu2003} and error correction~\\cite{Mitra2006}.\nNevertheless, in the post-Moore's era,\nthe variability and uncertainty of manufacturing at the atomic level\nmake devices under miniaturization sensitive to process variation and environmental fluctuation.\nAs a result, the manufactured ICs may exhibit uncertain probabilistic behavior,\nwhich imposes serious challenges to the design of reliable systems.\n\nRecent research efforts have been made to accept the inevitable imperfection of devices\nbased on the notions of \\textit{approximate design} and \\textit{probabilistic design}.\nIn both notions, a system's behavior may deviate from its expected specification;\nhowever, this deviation is deterministic in the former case but probabilistic in the latter case.\nDespite the advancements made by prior endeavors,\nthe analysis and synthesis of probabilistic design have gained relatively less attention.\nHence,\n\\textbf{there is a research need of a framework to evaluate probabilistic design},\nand SSAT stands up as a suitable logical formalism to address the need.\n(In the following,\nthe term ``design'' is used as a general term to refer to a single design instance,\na set of design instances,\nor design process;\nthe term ``synthesis\" is referred to as the design automation process\ntransforming a system under design from high-level system specification to low-level circuit implementation.)\n\nSSAT is closely related to two generalizations of Boolean satisfiability:\n\\textit{model counting} of propositional formulas and \\textit{quantified Boolean formulas} (QBFs).\nGiven a propositional formula, model counting asks to compute the number of its satisfying assignments.\nIn the weighted version, weights are assigned to the Boolean variables in the formula,\nand the goal is to compute the summation of weights of the satisfying assignments.\nAlgorithms for model counting are under active development in recent years.\nIn addition to \\textit{exact} model counting~\\cite{Sang2004,Sang2005ModelCounting},\n\\textit{approximate} model counting~\\cite{Gomes2006,Gomes2007,Chakraborty2016}\nhas been investigated to improve scalability by relaxing exactness.\nOn the other hand, from the perspective of the computational complexity,\nsolving an SSAT formula lies in the PSPACE-complete~\\cite{Stockmeyer1973} complexity class,\nthe same as solving a QBF.\nMany endeavors have been invested in the algorithmic improvement~\\cite{SATHandbook-QBF}\nand solver evaluation~\\cite{Narizzano2006} for QBF.\n\nNevertheless, in spite of its broad applications and profound theoretical values,\nSSAT has drawn relatively little attention compared to SAT, model counting, or QBF.\nMost prior efforts for SSAT solving are based on the conventional\nDavis-Putnam-Logemann-Loveland (DPLL) search~\\cite{Davis1962},\nwhich suffers from the scalability issue when problem sizes grow.\nTherefore, \\textbf{there is a research need to develop novel algorithms to enhance the scalability of SSAT solving},\nand the recent advancements of SAT/QBF solving and model counting can be leveraged to help the algorithm design.\n\nIn spite of its rich expressiveness to encode problems ranging from AI to VLSI,\nSSAT is limited by its descriptive power within the PSPACE complexity class.\nMore complex problems with nondeterminism might not be succinctly modeled as SSAT formulas.\nAs a result, \\textbf{there is a research need of a logical formalism for problems beyond PSPACE and with uncertainty.}\n\nFinally, most research work regarding SSAT solving was done\nbefore the year 2010~\\cite{Majercik1998,Majercik2003,Majercik2004,Majercik2005,Teige2010,SATHandbook-SSAT}.\nOpen-source implementations and SSAT instances for testing are barely available,\nwhich hinder the understanding of the algorithmic details and empirical solver comparison.\nConsequently, \\textbf{there is a need to provide open-source implementations and databases of SSAT instances to facilitate convenient evaluation of different algorithms and drive further advancements.}\n\n\\section{Our contributions}\n\\begin{figure}[t]\n      \\centering\n      \\includegraphics{fig/build/nutshell.pdf}\n      \\caption{The contributions of this dissertation in a nutshell}\n      \\label{fig:intro-nutshell}\n\\end{figure}\n\nThis dissertation aims at contributing to the aforementioned research needs.\nOur achievements positioned in the hierarchy of various complexity classes beyond NP are visualized in~\\cref{fig:intro-nutshell}.\nIn a nutshell, we investigate the application of SSAT to VLSI analysis,\nleverage the advancements of SAT, MAJSAT, and QBF to design new decision procedures for SSAT,\nand combine SSAT and DQBF to propose a new formulation, called DSSAT, for NEXPTIME problems with uncertainty.\nIn the following, we will explain each contribution in more detail.\n\nFirst, we approach the analysis of probabilistic design by\nformalizing the problem of \\textit{probabilistic property evaluation}.\nDifferent computational solutions are provided for the problem.\nParticularly, random-exist and exist-random quantified SSAT formulas are exploited\nto solve the average-case and worst-case analyses, respectively.\nTo the best of our knowledge,\nthis is the first attempt that analyzes VLSI systems with SSAT.\n(In the following,\nthe terms ``analysis'' and ``evaluation'' are used interchangeably as general terms\nreferring to the process of determining qualitative or quantitative properties of a design.\nWe will formulate the problem of \\textit{probabilistic property evaluation},\nand refer to the term ``evaluation\" as computing the satisfying probability of\ncertain properties of a probabilistic design.)\n\nSecond, in contrast to the previous DPLL-based algorithms,\nwe utilize modern techniques of SAT/QBF solving and model counting to improve SSAT solving.\nMotivated by the new VLSI applications,\nwe focus on random-exist and exist-random quantified fragments of SSAT formulas.\n\nThe random-exist quantified SSAT formula is of the form $\\Qf=\\random{}X,\\exists Y.\\pf$,\nwhich is the counterpart of the forall-exist QBF.\nIt has applications in Bayesian-network inference~\\cite{Cooper1990,Bacchus2003}.\nWe propose an algorithm that uses modern SAT solvers~\\cite{Een2003Solver,Een2003Incremental} as plug-in engines.\nIn addition to SAT solving,\nwe also incorporate weighted model counting,\nwhich has been widely used in probabilistic inference~\\cite{Sang2005BayesianInference,Chavira2008},\nto tackle randomized quantifiers.\nThe randomized quantification in an SSAT formula can be approached with weighted model counting\nby assigning the weight of a variable quantified by $\\random{p}$ to be $p$.\nThe proposed algorithm uses an SAT solver and a model counter in a \\textit{stand-alone} manner,\nleaving the internal structures of these solvers intact.\nDue to the stand-alone usage of these solvers,\nthe proposed algorithm may directly benefit from the advancement of the solvers without any modification.\n\nThe exist-random quantified SSAT formulas has the form $\\Qf=\\exists X,\\random{}Y.\\pf$,\nwhich is also known as \\textit{E-MAJSAT}~\\cite{Littman1998}.\nComputational problems, such as computing a maximum-a-posteriori (MAP) hypothesis or\na maximum-expected-utility (MEU) solution~\\cite{Dechter1998} in Bayesian networks,\nand searching an optimal plan for probabilistic conformant planning domains~\\cite{Littman1998},\ncan be formulated with E-MAJSAT.\nInspired by the \\textit{clause-selection}~\\cite{Janota2015,Rabe2015} technique,\nwhich is recently devised for QBF solving and becomes the state-of-the-art,\nwe propose a learning method based on the \\textit{clause-containment principle} to solve E-MAJSAT.\nTo the best of our knowledge,\nthis is the first attempt to adopt QBF approaches for SSAT solving.\n\nMoreover, the proposed algorithms solve an SSAT formula in a gradual manner\nthat converges from approximate bounds of the satisfying probability to the exact answer.\nTherefore, they are able to provide useful information even if the exact answer is unavailable (e.g., due to limited computational resources).\n\nThird, to provide a logical formalism for more complex problems with uncertainty,\nwe extend \\textit{dependency QBF} (DQBF)~\\cite{Balabanov2014,Scholl2018} to the stochastic domain\nin view of the close relation between QBF and SSAT.\nDQBF is a representative problem in the NEXPTIME-complete~\\cite{Peterson2001} complexity class.\nIt equips QBF with Henkin quantifiers to describe multi-player games with partial information.\nWe formalize the problem of \\textit{dependency SSAT} (DSSAT) as a generalization for SSAT.\nWe prove that DSSAT has the same NEXPTIME-complete complexity as DQBF,\nand therefore it can succinctly encode decision problems with uncertainty in the NEXPTIME complexity class.\nWe demonstrate the potential applications of DSSAT to the synthesis of probabilistic and approximate design and the encoding of decentralized POMDP (Dec-POMDP)~\\cite{Oliehoek2016} problems.\nOur theoretical results would encourage the solver development.\n\nFourth, our implementation of the proposed SSAT algorithms\nand formula instances used in the experiments are open-source,\nwhich will help other researchers to understand the details of the approaches and\nfacilitate convenient empirical evaluation of different algorithms.\n\n\\section{An overview of the dissertation}\nThe structure of this dissertation is outlined as follows.\n\\begin{itemize}\n      \\item\n            In~\\cref{chap:related-work}, a brief survey of the literature is provided to highlight the advancements made in this dissertation.\n      \\item\n            In~\\cref{chap:background}, background knowledge required throughout the dissertation is discussed.\n            Specific material for an individual chapter will be introduced when it is needed.\n      \\item\n            In~\\cref{chap:prob-design-eval}, a formal framework to evaluate properties of probabilistic design is proposed.\n            Especially, random-exist and exist-random quantified SSAT formulas are exploited to solve the formulation.\n            This chapter is based on our conference paper~\\cite{LeeICCAD14ProbDesign} published at ICCAD\\,'14 and journal paper~\\cite{LeeTC18ProbDesign} published in IEEE Transactions on Computers.\n      \\item\n            In~\\cref{chap:random-exist-ssat}, modern SAT-solving and model-counting techniques are combined to solve random-exist quantified SSAT formulas.\n            This chapter is based on our conference paper~\\cite{LeeIJCAI17RESSAT} published at IJCAI\\,'17.\n      \\item\n            In~\\cref{chap:exist-random-ssat}, a clause-learning technique inspired by \\textit{clause selection}, a prevailing method recently invented for QBF, is devised to solve exist-random quantified SSAT formulas.\n            This chapter is based on our conference paper~\\cite{LeeIJCAI18ERSSAT} published at IJCAI\\,'18.\n      \\item\n            In~\\cref{chap:dependency-ssat}, SSAT is lifted from the PSPACE-complete complexity class to the NEXPTIME-completeness.\n            We show the applicability of the lifted formalism to the analysis of probabilistic design and decentralized POMDP.\n            This chapter is based on our conference paper~\\cite{LeeAAAI21DSSAT} published at AAAI\\,'21.\n      \\item\n            In~\\cref{chap:conclusion-future-work}, we give concluding remarks and point out some potential directions for future investigation.\n\\end{itemize}\n\n\\section{Data availability statement}\nTo improve the reproducibility of the results presented in this dissertation,\nwe provide a reproduction package on Zenodo~\\cite{dissertation-artifact},\nincluding the source code of the proposed solvers,\nthe pre-compiled binaries of the evaluated tools,\nthe used benchmark sets,\nthe scripts to perform experiments,\nand the raw data generated from our experiments.\nCurrent versions of the proposed SSAT solvers are available at~\\url{\\ssatabcurl}.\nThe collection of SSAT instances is hosted at~\\url{\\ssatbenchmarkurl}.\nThe \\LaTeX~code for this dissertation as well as the slides used in the oral defense is also made public at~\\url{\\thesisurl}.", "meta": {"hexsha": "9ad1faf169c1d1f602546fd811d0ea481acc5c07", "size": 14806, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/introduction.tex", "max_stars_repo_name": "nianzelee/PhD-Dissertation", "max_stars_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-11T19:38:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T19:38:13.000Z", "max_issues_repo_path": "paper/introduction.tex", "max_issues_repo_name": "nianzelee/PhD-Dissertation", "max_issues_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/introduction.tex", "max_forks_repo_name": "nianzelee/PhD-Dissertation", "max_forks_repo_head_hexsha": "061e22dd55b4e58b3de3b0e58bb1cbe11435decd", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.9174311927, "max_line_length": 218, "alphanum_fraction": 0.8088612725, "num_tokens": 3343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4052360528289044}}
{"text": "\n\\chapter{Fitting the Spectra}\n\nFitting of the spectra involves selecting a spectral line of interest (e.g. \\ion{Fe}{12} 195.12\\,\\AA) from the spectral windows of the data and determining a guess on the fit parameters. The next ingredient for a fit is the selection of an optimization method\\sidenote{Here we use a Python implementation of the well-known IDL method mpfit which solves the non-linear least squares problem using the Levenberg-Marquardt algorithm. The Python implementation mpfit.py is found on GitHub (https://github.com/segasai/astrolibpy/) and included in our analysis software.}.\n\nFor this we've created a set of fit templates for different spectral lines. An \\verb+h5dump+ on the file shows that it contains a \\verb+/template+ group for the initial guess on the fit parameters and a \\verb+/parinfo+ group containing constraints on the parameters for \\verb+mpfit.py+.\n\n\\begin{lstlisting}\nh5dump -n fe_12_195_119.2c.template.h5\nHDF5 \"fe_12_195_119.2c.template.h5\" {\nFILE_CONTENTS {\n group      /\n group      /parinfo\n dataset    /parinfo/fixed\n dataset    /parinfo/limited\n dataset    /parinfo/limits\n dataset    /parinfo/tied\n dataset    /parinfo/value\n group      /template\n dataset    /template/component\n dataset    /template/data_e\n dataset    /template/data_x\n dataset    /template/data_y\n dataset    /template/fit\n dataset    /template/fit_back\n dataset    /template/fit_gauss\n dataset    /template/line_ids\n dataset    /template/n_gauss\n dataset    /template/n_poly\n dataset    /template/order\n dataset    /template/wmax\n dataset    /template/wmin\n }\n\\end{lstlisting}\n\n The object \\verb+eis_read_template.py+ can be used to read a template file and examine the contents.\n\n\\begin{lstlisting}\nfrom eis_read_template import eis_read_template\nfilename = 'fe_12_195_119.2c.template.h5'\ntemplate = eis_read_template(filename)\n\\end{lstlisting}\n\nThis produces the output below, showing the \\verb+/parinfo+ group that contains  parameters (peak, centroid, width, background) for a double Gaussian fit along with the parameter constraints. Note that this is specific to using the \\verb+mpfit+ method (see the GitHub page for more info).\n\\begin{lstlisting}\n+ template file = fe_12_195_119.2c.template.h5\n*PARAMETER CONSTRAINTS*\n*              Value      Fixed            Limited                 Limits               Tied\n p[0]     57514.6647          0          1          0       0.0000       0.0000\n p[1]       195.1179          0          1          1     195.0778     195.1581\n p[2]         0.0289          0          1          1       0.0191       0.0510\n p[3]      8013.4013          0          1          0       0.0000       0.0000\n p[4]       195.1779          0          1          1     195.1378     195.2181          p[1]+0.06\n p[5]         0.0289          0          1          1       0.0191       0.0510          p[2]\n p[6]       664.3349          0          0          0       0.0000       0.0000\n \\end{lstlisting}\n\n Next you'll want to prep the data for fitting. Once you've read in a template file, you can use the central wavelength to find the desired spectral window in the data using \\verb+eis_read_raster+ as shown in the previous chapter.\n\n\\begin{lstlisting}\nfrom eis_read_raster import eis_read_raster\nfrom eis_read_template import eis_read_template\n\n# input data and template files\nfile_data     = 'eis_20190404_131513.data.h5'\nfile_template = 'fe_12_195_119.2c.template.h5'\n\n# read fit template\ntemplate = eis_read_template(file_template)\n\n# get central wavelength\nwmin = template.template['wmin']\nwmax = template.template['wmax']\nwave = wmin + (wmax-wmin)*0.5\n\n# read raster\nraster = eis_read_raster(file_data, wave)\nints   = raster.data['data']\nwave   = raster.data['wave']\ncorr   = raster.data['wave_corr']\n\\end{lstlisting}\n\nPrepping of the data can be handled at various levels of sophistication at the user's discretion, however, at a minimum it should include handling bad values\\sidenote{Negative values are a result of the background subtraction.} in the raster, correcting for the wavelength offsets\\sidenote{From thermal drift over the  orbit.}, and computing the errors on the intensities\\sidenote{The square root of the counts is a good first-order approximation.}.\n\n\\begin{lstlisting}\n# get dimensions\nndata = ints.shape\nnx    = ndata[0]\nny    = ndata[1]\nnz    = ndata[2]\n\n# bad data correction\nbad = np.where(ints<0)\nints[bad] = 0.0\n\n# compute error on counts\nerrs = np.sqrt(ints)\n\n# wavelength correction\nnewwave = np.zeros(ndata)\nfor i in range(nx):\n    for j in range(ny):\n        newwave[i,j,::] = wave-corr[i,j]\nwave = newwave\n\\end{lstlisting}\n\nNow on to the fitting! Now that you have a fit template and the data elements, you can perform a fit of the entire raster by calling \\verb+eis_fit_raster.py+\\sidenote{Here's what's happening under the hood. The object eis-fit-raster calls eis-scale-guess to scale the initial parameter guess to the data, then calls eis-mpfit to implement the Levenberg-Marquardt fitting. The module eis-fit-deviates contains the callable function that returns the fit deviates computed from a model function for eis-mpfit.}. The fit results can be saved and read back using \\verb+eis_save_fit.py+ and \\verb+eis_read_fit.py+.\n\n\\begin{lstlisting}\nfrom eis_fit_raster import eis_fit_raster\nfrom eis_save_fit import save_fit\nfrom eis_read_fit import read_fit\n\n# fit profile\nparinfo  = template.parinfo\ntemplate = template.template\nfit = eis_fit_raster(wave, ints, errs, template, parinfo)\n\n# save fit output\nfit = fit.fit\nfile_fit = save_fit(fit, file_data)\n\n# read fit output back from file\nfit = read_fit(file_fit[0])\n\\end{lstlisting}\n\nThe output fit parameters are stored to a dictionary.\n\n\\begin{lstlisting}\nbackground   float64      (512, 87, 1)\ncentroid     float64      (512, 87, 2)\nchi2         float64      (512, 87)\ncomponent    int64        1\ne_background float64      (512, 87, 1)\ne_centroid   float64      (512, 87, 2)\ne_int        float64      (512, 87, 2)\ne_peak       float64      (512, 87, 2)\ne_width      float64      (512, 87, 2)\nint          float64      (512, 87, 2)\nline_ids     object       (2,)\nn_gauss      int16        1\nn_poly       int16        1\nparams       float64      (512, 87, 7)\npeak         float64      (512, 87, 2)\nperror       float64      (512, 87, 7)\nstatus       float64      (512, 87)\nwavelength   float64      (512, 87, 24)\nwidth        float64      (512, 87, 2)\n\\end{lstlisting}\n\nThe above steps are illustrated in the example routine \\verb+eis_fit_example.py+, which produces a plot like the one shown below.\n\n\\begin{figure}[t]\n  \\centerline{\\includegraphics[clip,width=0.8\\linewidth,bb=0 0 750 737]{figures/fit_example.pdf}}\n  \\centerline{\\includegraphics[clip,width=0.8\\linewidth,bb=750 0 1500 737]{figures/fit_example.pdf}}  \n  \\caption{Example line profile fits. The top two panels show the raster formed by summing over the\n    profile (left) and fitting each profile (right). The bottom panels show fits to four\n    \\ion{Fe}{12} 195.119\\,\\AA\\ line profiles.}\n  \\label{fig:fit_example}\n\\end{figure}\n\nAs a final note about the fitting routines, there's also a parallelized version for fitting the raster that uses the Python Multiprocessing module \\sidenote{This uses a pool of processes and parallelizes over the rasters so that each sub-process gets a raster position.}. When using the parallel version, an extra argument can be passed to the function to specify the number of processes to use (default=4) as in the below example. You can also check out the example in \\verb+eis_fit_example_parallel.py+.\n\n\\begin{lstlisting}\nfit = eis_fit_raster_parallel(wave, ints, errs, template, parinfo, ncpu=8)\n\\end{lstlisting}\n", "meta": {"hexsha": "f62a48d1f1157b7d1ca283a8caac6ae55c838cad", "size": 7656, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "3-EAG/04-fitting.tex", "max_stars_repo_name": "andrekorol/pyEIS-test", "max_stars_repo_head_hexsha": "6e05475cfed52147e6c74cc3fb5b24db3e0d1452", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-10-08T15:50:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-04T19:35:21.000Z", "max_issues_repo_path": "3-EAG/04-fitting.tex", "max_issues_repo_name": "andrekorol/pyEIS-test", "max_issues_repo_head_hexsha": "6e05475cfed52147e6c74cc3fb5b24db3e0d1452", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-06-16T19:47:34.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-16T19:47:34.000Z", "max_forks_repo_path": "3-EAG/04-fitting.tex", "max_forks_repo_name": "andrekorol/pyEIS-test", "max_forks_repo_head_hexsha": "6e05475cfed52147e6c74cc3fb5b24db3e0d1452", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-10-08T15:50:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-28T18:08:44.000Z", "avg_line_length": 45.8443113772, "max_line_length": 608, "alphanum_fraction": 0.7032392894, "num_tokens": 2146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4052360444932489}}
{"text": "\\subsection{Overview of Examples}\nWe establish some fundamental properties of solutions to the SIP under different QoI maps in terms of the skewness of the $Q$'s being compared.\nWe seek an estimated probability measure $\\hat{\\PP}_\\pspace$ on the parameter space to converge (with respect to the metric $d_\\text{TV}$) to some reference measure $\\PP_\\pspace$ as more samples (i.e., model evaluations), $\\nsamps$ are used.\nSuch a reference measure could be either some known distribution taken as truth, or another approximation deemed to be sufficiently resolved for the given application or computational budget (i.e. higher-fidelity model, mesh, or Monte Carlo sample-size).\\footnote{However, we could also choose to interrogate the push-forward measures given by propagating the $\\hat{\\PP}_\\pspace$ and $\\PP_\\pspace$ forward to a data space by a QoI map and taking the distance on the resulting output space.\nThis would measure the ability of the maps to reconstruct the output probability measure.}\n\nIn Figure~\\ref{fig:voronoi_sols}, we illustrate the solution to the problem of comparing measures defined on two different (implicitly-defined) $\\sa$s shown in Figure~\\ref{fig:voronoi_issues}.\nBy introducing a third set against which both sample sets of size $\\nsamps=50$ are compared, we can leverage theoretical results from Lemma~\\ref{lem:measuresets} to compare solutions to the SIP under different QoI maps.\n\n\\begin{figure}[ht]\n\\centering\n\t\\begin{minipage}{.275\\textwidth}\n\t\t\\includegraphics[width=\\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N25_r0_no_label}\n\t\\end{minipage}\n\t\\begin{minipage}{.4\\textwidth}\n\t\t\\includegraphics[width=\\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N500_r50}\n\t\\end{minipage}\n\t\t\\begin{minipage}{.275\\textwidth}\n\t\t\\includegraphics[width=\\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N25_r10_no_label}\n\t\\end{minipage}\n\\caption{\n(Left/Right): The two partitions from Figure~\\ref{fig:voronoi_issues} will be projected onto a third reference partition (center), in order to compare them on a common $\\sa$.\nCenter: A possibly over-resolved reference sample set, generated using $\\nsamps = 500$ uniform i.i.d.~random samples.\n}\n\\label{fig:voronoi_sols}\n\\end{figure}\n\nTo isolate the effect of skewness on the ability to approximate sets with finite sampling, we choose the maps so that they preserve the sizes of sets between $\\pspace$ and $\\dspace$ under the push-forward measure given in Eq.~\\eqref{eq:dataspace_pushforward_measure}.\nThe sizes of these inverse sets correspond to the average precision of maps $Q$, so we fix the maps to all be equally informative from this perspective; for linear maps, this means they all have the same determinant.\n\nAll of our experiments follow the same structure, where $\\qspace$ denotes a set of QoI maps under consideration in each example:\n\\begin{itemize}\n\\item[[0-a]] Select $\\qoi\\in\\qspace$ and define $\\PP_{\\dspace_\\qoi}$ as a uniform distribution centered on a reference QoI value $Q(\\paramref)$ for $\\paramref$ taken as the midpoint of $\\pspace$.\nNote that $\\PP_{\\dspace_\\qoi}$ is exactly discretized with $M=1$ sample, so that\n\\[\nP_{\\pspace, 1} = P_\\pspace.\n\\]\n\\item[[0-b]] Create a regular grid of samples in $\\pspace=[0,1]^n$ using $N_{\\text{ref},i}$ equispaced points in each dimension.\nSet $\\bar{N} := \\prod N_{\\text{ref},i}$.\nSince $n$ is small in the numerical examples shown here, we select $N_{\\text{ref},i} = 200 \\; \\forall \\; i$ in each example.\n\\item[[0-c]] Use Algorithm~\\ref{alg:inv_density} to construct a reference solution $\\PP_{\\pspace,\\bar{N}}\\approx \\PP_\\pspace$.\n\\item[[1]] Generate $\\set{S_k^{(n)}}_{n=1}^{50}$ sets of uniform i.i.d.~random samples where $N_k = 25, 50, 100, 200, \\hdots, 6400$, and $n$ represents the number of repeated trials of a sample size $N_k$.\n%, constructing $\\set{\\set{\\VVV_k^{(j)}}_{k=1}^{50}}_{j=1}^{N}$ so that when we compute Total Variation distances on the approximate measures defined on each $\\set{\\VVV_k^{(j)}}{j=1}{N}$, we can reduce the variance in our expected Total Variation distance values for each instance of $N$. Note that we experimented with using more trials and found the variance in expected Total Variation distances was sufficiently low with as few as twenty trials for the maps under consideration herein.\n%\\item[[3]] For every trial $T$ and $N$ value (including $\\bar{N}$), the reference parameter $\\lambda = (\\lambda_1, \\lambda_2) = (0.5, 0.5)$ is mapped by $Q$ to $\\dspace_\\qoi = Q(\\pspace)$.\n%\\item[3] A uniform distribution with support $[Q(\\lambda_1) - 0.05, Q(\\lambda_1) + 0.05] \\times [Q(\\lambda_2) - 0.05, Q(\\lambda_2) + 0.05]$ is defined on $\\dspace_\\qoi$, representing equal uncertainty in each component of our measured functional values.\n\\item[[2]] Solve the SIPs using Algorithm~\\ref{alg:inv_density} to construct $\\set{\\PP_{\\pspace,M,N}^{(n)}}_{n=1}^{50}$.\n\\item[[3]] Use $1E5$ i.i.d.~random samples to estimate $\\set{d_H^2( \\PP_{\\pspace,M,N}^{(n)}, \\PP_{\\pspace,\\bar{N}})}_{n=1}^{50}$.\n\\item[[4]] Average over all trials $n$ for each $N$ to estimate the {\\em expected} Total Variation distance for $N$ samples and analyze convergence to $\\PP_{\\pspace,\\bar{N}}$.\n\\item[[5]] Repeat steps [0-a]--[4] for each $\\qoi\\in\\qspace$ under consideration.\n\\end{itemize}\n\n\\FloatBarrier\n", "meta": {"hexsha": "e58b9d805a6db37aef3cbaea690e68afe81b0e20", "size": 5264, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ch03/experimental_setup.tex", "max_stars_repo_name": "mathematicalmichael/thesis", "max_stars_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-04-24T08:05:49.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-28T20:34:29.000Z", "max_issues_repo_path": "ch03/experimental_setup.tex", "max_issues_repo_name": "mathematicalmichael/thesis", "max_issues_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2019-12-27T23:15:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T17:52:57.000Z", "max_forks_repo_path": "ch03/experimental_setup.tex", "max_forks_repo_name": "mathematicalmichael/thesis", "max_forks_repo_head_hexsha": "2906b10f94960c3e75bdb48e5b8b583f59b9441e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 99.320754717, "max_line_length": 489, "alphanum_fraction": 0.7462006079, "num_tokens": 1506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804196836383, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4052360436209456}}
{"text": "\\documentclass{article}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n% necessary packages\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{bm}\n\\usepackage{oldstyle}\n\\usepackage{color}\n\\usepackage{soul}\n% disabled b/c we're using tcolorbox\n\\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}\n\n% math stuff\n\\providecommand{\\inv}[1]{{#1}^{\\ensuremath{\\mathsf{-1}}}} % inverse ...\n\\providecommand{\\tr}[1]{{#1}^{\\ensuremath{\\mathsf{T}}}} % transpose ...\n\\providecommand{\\itr}[1]{{#1}^{\\ensuremath{\\mathsf{-T}}}} % transpose ...\n\\providecommand{\\strans}[1]{{#1}^{\\ensuremath{\\mathsf{S}}}} % transpose ...\n\\providecommand{\\abs}[1]{\\lvert#1\\rvert}\n\\providecommand{\\norm}[1]{\\left\\lVert#1\\right\\rVert}\n\\providecommand{\\svect}[1]{\\hat{\\bm{#1}}}\n\\providecommand{\\vect}[1]{\\bm#1}\n\\providecommand{\\mat}[1]{\\mathbf#1}\n\\providecommand{\\smat}[1]{\\hat{\\mathbf{#1}}}\n\\providecommand{\\bigTheta}{\\mathit{\\Theta}}\n\\providecommand{\\bigO}{\\mathit{O}}\n\\providecommand{\\sgn}[1]{\\textrm{sgn}(#1)}\n\\providecommand{\\xform}[3]{\\hspace{0mm}_#1\\mat{#2}_#3}\n\\newcommand{\\ud}{\\,\\mathrm{d}}\n\n% lists\n\\newcommand{\\ia}{(\\textos{a})\\!}\n\\newcommand{\\ib}{(\\textos{b})\\!}\n\\newcommand{\\ic}{(\\textos{c})\\!}\n\\newcommand{\\id}{(\\textos{d})\\!}\n\\newcommand{\\ie}{(\\textos{e})\\!}\n\\newcommand{\\1}{(\\textos{1})\\!}\n\\newcommand{\\2}{(\\textos{2})\\!}\n\\newcommand{\\3}{(\\textos{3})\\!}\n\\newcommand{\\4}{(\\textos{4})\\!}\n\\newcommand{\\5}{(\\textos{5})\\!}\n\\newcommand{\\6}{(\\textos{6})\\!}\n\\newcommand{\\7}{(\\textos{7})\\!}\n\\newcommand{\\8}{(\\textos{8})\\!}\n\n\\DeclareMathOperator*{\\minimize}{minimize}\n\n% indicate necessary changes\n\\providecommand{\\captiontxt}[1]{\\caption{\\emph{#1}}}\n\\providecommand{\\note}[1]{\\textcolor{orange}{#1}} \n\\providecommand{\\changeme}[1]{\\textcolor{red}{#1}} \n\\providecommand{\\TODO}[1]{\n\\sethlcolor{yellow}\n\\noindent\n$\\cdot$\\ \\hl{#1}\n\\\\\n} \n\n\\title{Computing the principal pivoting transform for solving Linear Complementarity Problems with Lemke's Algorithm}\n\\date{}\n\\author{Hongkai Dai and Evan Drumwright\\\\Toyota Research Institute}\n\n\\begin{document}\n\\maketitle\n\\section{Problem statement} Given tuples $w = \\{ w_1, \\hdots, w_n \\}$ and $z = \\{z_1, \\hdots, z_n, z_{n+1}\\}$, which can be arranged into vectors as follows:\n\\begin{align*}\n\t\\vect{w} =& \\tr{\\begin{bmatrix}w_1 & \\hdots & w_n \\end{bmatrix}}\\in\\mathbb{R}^n \\\\\n\t\t\\vect{z} =& \\tr{\\begin{bmatrix}z_1 & \\hdots & z_n & z_{n+1} \\end{bmatrix}}\\in\\mathbb{R}^{n+1},\n\\end{align*}\nwe seek to permute the relationship:\n\\begin{align*}\n\t\\vect{w} = \\vect{q} + \\mat{M}\\vect{z}\n\\end{align*}\nwhere $\\vect{q}\\in\\mathbb{R}^n, \\mat{M}\\in\\mathbb{R}^{n\\times (n+1)}$ are a given vector/matrix (note that boldface is used to help distinguish vectors and matrices from sets). $z_{n+1}$ will hereforth be referred to as the ``artificial variable'' by swapping some entries in the ``dependent variable tuple'' $w$ with some entries in the ``independent variable'' tuple $z$, yielding two new sets $z'$ and $w'$. Similarly to the matrix/vector relationship above, vectors $\\vect{z}' \\in \\mathbb{R}^{n+1}$ and $\\vect{w}' \\in \\mathbb{R}^n$ can be defined that correspond to variable indices of $z$ and $w$. \\emph{The problem that this document seeks to solve is the vector} $\\vect{q}'$ \\emph{and the matrix} $\\mat{M}'$ (actually, just a single column of it) \\emph{such that the relationship}:\n\\begin{align*}\n\\vect{w}' = \\vect{q}' + \\mat{M}'\\vect{z}'\n\\end{align*}\nfollows from the ordering in the vectors corresponding to the positions of the\nindividual $w$ and $z$ variables in the tuples $w'$ and $z'$. Recall that\npivoting takes the value $\\vect{z'} = \\vect{0}$, which allows $\\vect{w'}$ to be\ndetermined simply be setting it equal to $\\vect{q}'$, via the equation above.\nThis rearrangement is known as a \\emph{principal pivoting transform}. \n\nOne of the variables in the independent variable tuple $z'$ will be identified as the \\textit{driving variable}. We will denote this variable as $z'_{\\textrm{driving}}$. Our goal is to find the vector $\\vect{q}'$, together with the column in $\\mat{M}'$ that will be multiplied (i.e., via the inner product operation) with $z'_{\\textrm{driving}}$. We will denote this column as $\\mat{M}'_{\\textrm{driving}}$.\n\n\\subsubsection{Running example} \nWe consider the LCP from Example 4.4.7 in \\cite{Cottle:1992}:\n\\begin{align*}\n\t\\begin{bmatrix} w_1 \\\\ w_2 \\\\ w_3\\end{bmatrix} = \\underbrace{\\begin{bmatrix}-3 \\\\ 6 \\\\ -1\\end{bmatrix}}_{q} + \\underbrace{\\begin{bmatrix}  0 & -1 & 2 & 1\\\\ 2 & 0 & -2 & 1 \\\\ -1 & 1 & 0 & 1\\end{bmatrix}}_{M}\\begin{bmatrix}z_1 \\\\ z_2 \\\\ z_3 \\\\ z_4\\end{bmatrix}\n\\end{align*}\nAfter some number of pivoting operations, assume that the ``dependent'' tuple $w'$ and ``independent'' tuple $z'$ consist of:\n\\begin{align}\n\tw' = \\{ z_4, w_2, z_3 \\} ,\n\tz' = \\{ w_1, w_3, z_2, z_1 \\} \n    \\tag{1} % NOTE: Do not change equation number without changing\n            % unrevised_lemke_solver_test.cc\n\\end{align}\n\n\n\\subsection{Terminology} \\label{subsec:terminology}\nWe now introduce some terminology:\n\\begin{itemize}\n\t\\item \\textsc{independent w}: the tuple of variables from $w$ that (partially) comprise $z'$ in the order in which they are found in $w$  (i.e., the elements of \\textsc{independent w} appear in ascending order, e.g., $\\{ w_1, w_2 \\}$). In the running example, \\textsc{independent w} is $\\{ w_1, w_3 \\}$.\n\t\t\\begin{itemize}\n\t\t\t\\item  $\\alpha$: the positions in $w$ of the elements from \\textsc{independent w}. In the running example, $\\alpha = \\{ 1, 3 \\}$. From the definition of \\textsc{independent w}, these $w$ elements of $\\alpha$ appear in ascending order.\n\t\t\t\\item $\\alpha'$: the respective indices in $z'$ of the variables from \\textsc{independent w}. In the running example, $\\alpha' = \\{ 1, 2\\}$. These $w$ elements of $\\alpha'$ \\emph{elements will not necessarily be present in ascending order.} \n\t\t\\end{itemize}\n\t\tNote that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \\textbf{observe} the invariant $w_{\\alpha_i} = z'_{\\alpha'_i}$.\n\t\\item \\textsc{dependent z}: the tuple of variables from $z$ that (partially) comprise $w'$ in the order in which they are found in $z$ (i.e., the elements of \\textsc{dependent z} appear in ascending order, e.g., $\\{ z_3, z_4 \\}$). In the running example, \\textsc{dependent z} is $\\{ z_3, z_4 \\}$.\n\t\t\\begin{itemize}\n\t\t\t\\item $\\beta$: the positions in $z$ of the elements from \\textsc{dependent z}. In the running example, $\\beta = \\{3, 4\\}$ (corresponding to $z_3$ and $z_4$). From the definition of \\textsc{dependent z}, these $z$ elements of $\\beta$ appear in ascending order.\n\t\t\t\\item $\\beta'$: the respective indices in $w'$ of the variables from \\textsc{dependent z}. In the running example, $\\beta' = \\{3, 1\\}$. These $z$ elements of $\\alpha'$ \\emph{elements will not necessarily be present in ascending order.}\n\t\t\\end{itemize}\n\t\tAgain, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \\textbf{observe} the invariant $z_{\\beta_i} = w'_{\\beta'_i}$.\n\t\\item \\textsc{dependent w}: the tuple of variables from $w$ that (partially) comprise $w'$ in the order in which they are found in $w$ (i.e., the elements of \\textsc{dependent w} appear in ascending order, e.g., $\\{ w_1, w_2 \\}$). In the running example, \\textsc{dependent w} is $\\{ w_2 \\}$.\n\t\t\\begin{itemize}\n\t\t\t\\item $\\bar{\\alpha}$: the positions in $w$ of the elements from \\textsc{dependent w}. In the running example, $\\bar{\\alpha} = \\{ 2 \\}$. From the definition of \\textsc{dependent w}, these $w$ elements of $\\bar{\\alpha}$ appear in ascending order.\n\t\t\t\\item $\\bar{\\alpha}'$: the respective indices in $w'$ of the variables from \\textsc{dependent w}. In the running example, $\\bar{\\alpha}' = \\{ 2 \\}$. These $w$ elements of $\\bar{\\alpha}$'s \\emph{elements are not necessarily present in ascending order}.\n\t\t\\end{itemize}\n\t\tAgain, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \\textbf{observe} the invariant $w_{\\bar{\\alpha}_i} = w'_{\\bar{\\alpha}'_i}$.\n\t\\item \\textsc{independent z}: the tuple of variables from $z$ that (partially) comprise $z'$ in the order in which they are found in $z$ (i.e., the elements of \\textsc{independent z} appear in ascending order, e.g., $\\{ z_1, z_2 \\}$). In the running example, \\textsc{independent z} is $\\{ z_1, z_2 \\}$. The elements in \\textsc{independent z} are present in ascending order (e.g., $\\{ z_1, z_2 \\}$).\n\t\t\\begin{itemize}\n\t\t\t\\item $\\bar{\\beta}$: one greater, respectively, than the positions in $z$ of the elements from \\textsc{independent z}. In the running examples, $\\bar{\\beta} = \\{1, 2 \\}$. From the definition of \\textsc{independent z}, the elements of $\\bar{\\beta}$'s elements appear in ascending order.\n\t\t\t\\item $\\bar{\\beta}'$: the respective indices in $z'$ of the variables from \\textsc{independent z}. In the running example, $\\bar{\\beta}' = \\{4, 3 \\}$. These $z$ elements of $\\bar{\\beta}'$ \\emph{elements are not necessarily present in ascending order}.\n\t\t\\end{itemize}\n\t\tOnce more, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \\textbf{observe} the invariant $z_{\\bar{\\beta}_i} = z'_{\\bar{\\beta}'_i}$.\n\\end{itemize}\n\n\\section{Approach}\n\\begin{lemma}\n\tThe length of \\textsc{independent w} is the same as that of \\textsc{dependent z}.\n\\end{lemma}\nWe will denote the length of \\textsc{independent w} as $m$. In the running example, $m = 2$.\n\\subsection{Computing $q'$}\nWe first define a \\textit{square} matrix $\\mat{M}^{\\alpha\\beta} \\in\\mathbb{R}^{m \\times m}$ as being comprised of entries $i \\in 1,\\ldots,m$ and $j \\in 1, \\ldots, m$:\n\\begin{align*}\n\t\\mat{M}^{\\alpha\\beta}_{ij} = \\mat{M}_{\\alpha_i\\beta_j}\n\\end{align*}\nand a rectangular matrix $\\mat{M}^{\\bar{\\alpha}\\beta} \\in\\mathbb{R}^{(n-m)\\times m}$ as being comprised of entries $i \\in 1,\\ldots,n-m$ and $j \\in 1, \\ldots, m$:\n\\begin{align*}\n\t\\mat{M}^{\\bar{\\alpha}\\beta}_{ij} = \\mat{M}_{\\bar{\\alpha}_i\\beta_j}\n\\end{align*}\n\nLikewise, we define vectors $\\vect{q}^{\\alpha} \\in \\mathbb{R}^m$ and $\\vect{q}^{\\bar{\\alpha}} \\in \\mathbb{R}^{(n-m)}$ as being comprised of entries $i \\in 1,\\ldots,m$ and $j \\in 1, \\ldots, n-m$:\n\\begin{align*}\n\tq^{\\alpha}_i & = q_{\\alpha_i} \\\\\n\tq^{\\bar{\\alpha}}_j & = q_{\\bar{\\alpha}_j}\n\\end{align*}\nIn the running example---recall that $\\alpha = \\{1, 3\\}, \\beta = \\{3, 4\\},\n\\bar{\\alpha} = \\{2 \\}$---we highlight the parts of $\\vect{q}$ and $\\mat{M}$ that correspond to $\\textcolor{red}{q^{\\alpha}}$, $\\textcolor{red}{M^{\\alpha\\beta}}$ in red, and $\\textcolor{blue}{q^{\\bar{\\alpha}}}$, $\\textcolor{blue}{M^{\\bar{\\alpha}\\beta}}$ in blue. Now putting the example into ``tableaux form'':\n\\begin{center}\n\t\\begin{tabular}{|c|c|c c c c|}\n\t\t\\hline\n\t\t      &  & $z_1$ & $z_2$ & $\\textcolor{red}{z_3}$ & $\\textcolor{red}{z_4}$\\\\\n\t\t\\hline\n\t\t$\\textcolor{red}{w_1}$ &\\textcolor{red}{-3} & 0 & -1 & \\textcolor{red}{2} & \\textcolor{red}{1}\\\\\n\t\t$\\textcolor{blue}{w_2}$ & \\textcolor{blue}{6} & 2 & 0 & \\textcolor{blue}{-2} & \\textcolor{blue}{1}\\\\\n\t\t$\\textcolor{red}{w_3}$ & \\textcolor{red}{-1} & -1 & -1 & \\textcolor{red}{0} & \\textcolor{red}{1}\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\nthereby yielding the following vectors and matrices:\n\\begin{align*}\n\t\t\\textcolor{red}{q^{\\alpha} = \\begin{bmatrix} -3 \\\\ -1\\end{bmatrix}},\n\t\t\\textcolor{blue}{q^{\\bar{\\alpha}} = \\begin{bmatrix} 6\\end{bmatrix}},\n\t\t\\textcolor{red}{M^{\\alpha\\beta} = \\begin{bmatrix} 2 & 1 \\\\ 0 & 1\\end{bmatrix}},\n\t\t\\textcolor{blue}{M^{\\bar{\\alpha}\\beta} = \\begin{bmatrix} -2 & 1 \\end{bmatrix}}\n\\end{align*}\nWith the index sets $\\alpha', \\bar{\\alpha}'$ defined in Subsection\n\\ref{subsec:terminology}, and Equation 10 from Page 71 of~\\cite{Cottle:1992}, we\ncan write $\\vect{q}'$ as:\n\\begin{align}\n\t\\vect{q}'^{\\beta'} = -(\\mat{M}^{\\alpha\\beta})^{-1}\\vect{q}^{\\alpha}\n \\tag{2} \\\\ \n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\t\\vect{q}'^{\\bar{\\alpha}'} = \\vect{q}^{\\bar{\\alpha}} +\n    \\mat{M}^{\\bar{\\alpha}\\beta}\\vect{q}'^{\\beta'}\n \\tag{3} \n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\\end{align}\nwhere $\\vect{q}'^{\\alpha'}, \\vect{q}'^{\\bar{\\alpha}'}$ are ``views'' of the\nvector $q'$, as $\\vect{q}'^{\\alpha'}_i = \\vect{q}'_{\\alpha'_i},\n\\vect{q}'^{\\bar{\\alpha}'}_i = \\vect{q}'_{\\bar{\\alpha}'_i}$. In the running\nexample $\\vect{q}'^{\\alpha'} = \\tr{\\begin{bmatrix}1 & 1\\end{bmatrix}},\n\\vect{q}'^{\\bar{\\alpha}'} = [5]$. \\textbf{$\\vect{q}'$ is not composed by\nstacking $\\vect{q}'^{\\alpha'}, \\vect{q}'^{\\bar{\\alpha}'}$ as is done in similar procedures in~\\cite{Cottle:1992}.}\n\n\n\n\\subsection{Computing $\\mat{M}'_{\\textrm{driving}}$}\nThis computation requires considering two cases for the driving variable, which is an entry in the new independent variable $z'$. The driving variable can be either:\n\\begin{enumerate}\n\t\t\\item a dependent variable from $w$.\n\t\t\\item an independent variable $z$.\n\\end{enumerate}\nin the running example, if the driving variable is $w_1$ or $w_3$, then it belongs to the first case; if the driving variable is $z_2$ or $z_1$, then it belongs to the second case. Let's discuss the two cases separately.\n\n\\subsubsection{Driving variable is a dependent variable from $w$}\nIf the driving variable $z'_{\\textrm{driving}}$ is a dependent variable from $w$, then it also belongs to the vector \\textsc{independent w}. We denote the index of $z'_{\\textrm{driving}}$ in \\textsc{independent w} as $\\gamma$, namely: \n\\begin{align}\n\tw^{\\alpha}_\\gamma = w_{\\alpha_\\gamma} = z'_{\\textrm{driving}} \\tag{4}\n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\\end{align}\nwhere $w^{\\alpha}$ is the vector \\textsc{independent w}. In the running example,\n\\textsc{independent w} is $\\{ w_1, w_3 \\}$, thus $\\alpha = \\{ 1, 3 \\}$. If\n$z'_{\\textrm{driving}} \\equiv w_1$, then the index $\\gamma \\equiv 1$. If\n$z'_{\\textrm{driving}} \\equiv w_3$, then the index $\\gamma \\equiv 2$. To compute\nthe column vector $\\mat{M}'_{\\textrm{driving}}$, we need to first compute the\n$\\gamma^{\\textrm{th}}$ column of the matrix $(\\mat{M}^{\\alpha\\beta})^{-1}$. To\nthis end, we define a unit vector $\\vect{e} \\in\\mathbb{R}^m$ as:\n\\begin{align*}\n\t&e_{\\gamma} = 1\\\\\n\t&e_i = 0 \\quad \\text{if } i \\neq \\gamma\n\\end{align*}\nand we can compute $M'_{\\textrm{driving}}$ as:\n\\begin{align}\n\t&\\mat{M}'^{\\beta'}_{\\textrm{driving}} =\n    (\\mat{M}^{\\alpha\\beta})^{-1}\\vect{e}\\label{eq:b_prime_alpha_prime} \n    \\tag{5}\\\\\n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\t&\\mat{M}'^{\\bar{\\alpha}'}_{\\textrm{driving}} =\n    \\mat{M}^{\\bar{\\alpha}\\beta}\\mat{M}'_{\\textrm{driving}_{\\beta'}} \\tag{6}\n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\\end{align}\nNotice that $\\mat{M}'_{\\textrm{driving}_{\\alpha'}}$ is the\n$\\gamma^{\\textrm{th}}$ column of $\\mat{M}_{\\alpha\\beta}^{-1}$ according to Equation~\\eqref{eq:b_prime_alpha_prime}.\n\n\\subsubsection{Driving variable is an independent variable from $z$}\nIf the driving variable $z'_{\\textrm{driving}}$ is an independent variable from $z$, we denote the position in $z$ of $z'_{\\textrm{driving}}$ as $\\zeta$. In the running example, if the driving variable is $z_2$, then $\\zeta \\equiv 2$; if the driving variable is $z_1$, then $\\zeta \\equiv 1$.\n\nTo compute the column vector $\\mat{M}'_{\\textrm{driving}}$ in $\\mat{M}'$, we\nneed the $\\zeta^{\\textrm{th}}$ column of $\\mat{M}$, denoted $\\vect{g}$, which\nwill be decomposed into two sub-vectors. One sub-vector  $\\vect{g}^{\\alpha}$\ncontains the entries with row indices in $\\alpha$ while the other,  $\\vect{g}^{\\bar{\\alpha}}$, contains the entries with row indices from $\\bar{\\alpha}$. Namely:\n\\begin{align*}\n\t&g^{\\alpha}_i = M_{\\alpha_i\\zeta}\\\\\n\t&g^{\\bar{\\alpha}}_i = M_{\\bar{\\alpha}_i\\zeta}\n\\end{align*}\n\nIn the running example, $\\textcolor{red}{w_1, w_3}$ will be pivoted to $z'$, and\n$\\textcolor{blue}{w_2}$ will remain in $w'$. If the driving variable is $z_2$,\nwe highlight the vector $\\textcolor{red}{g^{\\alpha}},\n\\textcolor{blue}{g^{\\bar{\\alpha}}}$ in $\\mat{M}$ as:\n\\begin{center}\n\\begin{tabular}{|c|cccc|}\n\t\\hline\n\t\t& $z_1$ & $z_2$ & $z_3$ & $z_0$\\\\\n\t\t\\hline\n\t\t$\\textcolor{red}{w_1}$ & 0 & \\textcolor{red}{-1} & 2 & 1\\\\\n\t\t$\\textcolor{blue}{w_2}$ & 2 & \\textcolor{blue}{0} & -2 & 1\\\\\n\t\t$\\textcolor{red}{w_3}$ & -1 & \\textcolor{red}{1} & 0 & 1\\\\\n\t\t\\hline\n\\end{tabular}\n\\end{center}\nso $\\textcolor{red}{g^{\\alpha}} \\equiv \\tr{\\begin{bmatrix}-1 & 1\\end{bmatrix}}, \\textcolor{blue}{g^{\\bar{\\alpha}}} = [0]$.\n\nwith the vector $\\vect{g}^{\\alpha}, \\vect{g}^{\\bar{\\alpha}}$, we can then\ncompute $\\mat{M}'_{\\textrm{driving}}$ as\n\\begin{align}\n\t&\\mat{M}'^{\\beta'}_{\\textrm{driving}} =\n    -(\\mat{M}^{\\alpha\\beta})^{-1}\\vect{g}^{\\alpha} \\tag{7} \\\\\n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\t&\\mat{M}'^{\\bar{\\alpha}'}_{\\textrm{driving}} = \\vect{g}^{\\bar{\\alpha}} +\n    \\mat{M}^{\\bar{\\alpha}\\beta}\\mat{M}'^{\\beta'}_{\\textrm{driving}} \\tag{8}\n  % NOTE: Do not change equation number without changing\n  % unrevised_lemke_solver.cc\n\\end{align}\n\n\\bibliographystyle{abbrv}\n\\begin{thebibliography}{56}\n\\bibitem{Cottle:1992}\nRichard W. Cottle, Jong-Shi Pang, and R.E. Stone. \\emph{The Linear\nComplementarity Problem}, Academic Press, 1992.\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "b9d306bcab9c9bf1ddad664964eb997b769c5d43", "size": 17429, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/pivot_column.tex", "max_stars_repo_name": "RobotLocomotion/drake-python3.7", "max_stars_repo_head_hexsha": "ae397a4c6985262d23e9675b9bf3927c08d027f5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-02-25T02:01:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-17T04:52:04.000Z", "max_issues_repo_path": "doc/pivot_column.tex", "max_issues_repo_name": "RobotLocomotion/drake-python3.7", "max_issues_repo_head_hexsha": "ae397a4c6985262d23e9675b9bf3927c08d027f5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/pivot_column.tex", "max_forks_repo_name": "RobotLocomotion/drake-python3.7", "max_forks_repo_head_hexsha": "ae397a4c6985262d23e9675b9bf3927c08d027f5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-13T12:05:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-13T12:05:39.000Z", "avg_line_length": 61.5865724382, "max_line_length": 788, "alphanum_fraction": 0.6714670951, "num_tokens": 6154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.4052360361575932}}
{"text": "\\chapter{Experiment Setup And Execution}\n\\section{Goals}\nAs already mentioned this study is investigating the coverage of the parts which already can be automatically optimized by Polly, the various reasons for these parts not being even larger and the impact to the coverage and the speedup if these reasons could be eliminated.\n\n\\section{Measurement Methology}\nFor measuring, analysis and evaluation of the results the following definitions are introduced.\n\\subsection{Definition Coverage}\nLet \\(T_i\\in\\mathbb{N}\\) be the execution time of all instructions within all \\scops of a project and \\(T\\in\\mathbb{N}\\) the overall execution time of that project.\nThen the coverage of parallelizable regions \\(DynCov\\in\\mathbb{Q}\\) is defined as:\n\\[DynCov := \\frac{T_i}{T}\\]\n\n\\subsection[Amdahl's Law]{Amdahl's Law \\cite{AmdahlsLaw}}\nLet \\(N\\in\\mathbb{N}\\) be the number of processors and \\(DynCov\\in\\mathbb{Q}\\) be the coverage of parallelizable regions.\nThen the speedup \\(S\\in\\mathbb{Q}\\) is defined as:\n\\[S := \\frac{N}{(1-DynCov)*N+DynCov}\\]\n\\subsection{Reasons for SCoPs being invalid}\nThese are the criteria implemented by Polly for rejecting a parent of a \\scop being also a \\scop.\nSome of these criteria are referencing to a \\llvm specific value called \\undefv \\cite{llvmUndef}.\n\\begin{itemize}\n    \\item Parent is top level (\\autoref{lst:parentIsToplevel})\\\\\n        This is simply when the parent of a \\scop is a top level region.\n        Per default a top level region can not be a \\scop in Polly.\n    \\item Unsupported terminator instruction\\\\\n        This is occurring when a flow breaking instruction like \\texttt{return}, \\texttt{throw} or \\texttt{goto} is called within a loop.\n    \\item Unreachable in exit block (\\autoref{lst:unreachableExitBlock})\\\\\n        This is appearing when \\texttt{unreachable()} is called within an exit block \\cite{llvmUnreachable}.\n    \\item Irreducible regions (\\autoref{lst:irreducibleLoops})\\\\\n        \\Eg a region is interfering with another region using labels.\n        So that the loop can not be changed in general.\n    \\item Undefined branch condition\\\\\n        It is occurring whenever at least a part of a branch condition is based on the value \\undefv.\n    \\item Non-integer branch condition\\\\\n        Appears if the branch condition is neither constant nor using an integer comparison.\n    \\item Undefined operands in comparison\\\\\n        Arises when the value \\undefv is used in a comparison.\n    \\item Non-affine branch condition\\\\\n        This is the case if the branch is not affine like it contains a function call.\n    \\item No base pointer\\\\\n        Occurs if a base pointer is missing.\n    \\item Undefined base pointer\\\\\n        It is raised when a base pointer holds the value \\undefv.\n    \\item Variant base pointer (\\autoref{lst:variantBasePointer})\\\\\n        Occurs when a base pointer in a region is not invariant.\n    \\item Non-affine memory accesses (\\autoref{lst:nonAffineMemoryAccesses})\\\\\n        This is appearing when accessing memory in a non-affine way like using \\(i^2\\) as access steps.\n        More precisely: Appears if the array subscript of an access is not affine.\n    \\item Accesses with differing sizes\\\\\n        Arises if an array is accessed using data types of differing sizes.\n    \\item Uncomputable loop bounds (\\autoref{lst:uncomputeableLoopBounds})\\\\\n        Appears if Polly fails to derive an affine loop bound \\eg the loop bounds could not be computed because they are depending on an input parameter.\n    \\item Loop without exit (\\autoref{lst:loopWithoutExit})\\\\\n        Occurs if the loop has no exit or if not all latches are part of the loop region.\n    \\item Function call with side effects (\\autoref{lst:functionCallSideEffects})\\\\\n        This is raised when a function is called which is not guaranteed to have no side effects or at least it is not known whether it has side effects.\n    \\item Complicated access semantics (volatile or atomic)\\\\\n        Arises if memory is accessed which is not \\enquote{simple}.\n        This means the keywords volatile is used or an atomic variable is accessed.\n    \\item Base address aliasing (\\autoref{lst:baseAddressAliasing})\\\\\n        Occurs if Polly can not determine whether two pointer are accessing the same memory or -- when talking about arrays -- whether these arrays overlap.\n    \\item Integer to pointer conversion (\\autoref{lst:integerToPointer})\\\\\n        This occurs when a regular int is used as pointer somewhere into the memory.\n    \\item Stack allocations\\\\\n        Stack allocations like using \\texttt{alloca} can not be handled.\n    \\item Unknown instructions\\\\\n        Arises if an instruction is used where Polly knows no definition.\n    \\item Contains entry block\\\\\n        Polly is yet not able to handle regions which contain the entry of a function.\n    \\item Assumed to be unprofitable (\\autoref{lst:assumedUnprofitable})\\\\\n        When the region is very small or it is not likely that an optimization improves the execution it is left out.\n        This means at least Polly is not able to find a profitable polyhedral optimization for the given region.\n        As already mentioned in this study also these unprofitable regions are discussed.\n    \\item Polly does not return a reason\\\\\n        When requesting the reason for a region not being a \\scop Polly may return an empty string.\n        This occurs if the Log object used internally has errors or if it does not exist at all.\n\\end{itemize}\n\n\\begin{comment}\n    Following is copy\\&pasted from pollys ScopDetectionDiagnostic.cpp\n\nSCOP_STAT(CFG, \"\"),\nSCOP_STAT(InvalidTerminator, \"Unsupported terminator instruction\"),\nSCOP_STAT(UnreachableInExit, \"Unreachable in exit block\"),\nSCOP_STAT(IrreducibleRegion, \"Irreducible loops\"),\nSCOP_STAT(LastCFG, \"\"),\nSCOP_STAT(AffFunc, \"\"),\nSCOP_STAT(UndefCond, \"Undefined branch condition\"),\nSCOP_STAT(InvalidCond, \"Non-integer branch condition\"),\nSCOP_STAT(UndefOperand, \"Undefined operands in comparison\"),\nSCOP_STAT(NonAffBranch, \"Non-affine branch condition\"),\nSCOP_STAT(NoBasePtr, \"No base pointer\"),\nSCOP_STAT(UndefBasePtr, \"Undefined base pointer\"),\nSCOP_STAT(VariantBasePtr, \"Variant base pointer\"),\nSCOP_STAT(NonAffineAccess, \"Non-affine memory accesses\"),\nSCOP_STAT(DifferentElementSize, \"Accesses with differing sizes\"),\nSCOP_STAT(LastAffFunc, \"\"),\nSCOP_STAT(LoopBound, \"Uncomputable loop bounds\"),\nSCOP_STAT(LoopHasNoExit, \"Loop without exit\"),\nSCOP_STAT(FuncCall, \"Function call with side effects\"),\nSCOP_STAT(NonSimpleMemoryAccess,\n          \"Compilated access semantics (volatile or atomic)\"),\nSCOP_STAT(Alias, \"Base address aliasing\"),\nSCOP_STAT(Other, \"\"),\nSCOP_STAT(IntToPtr, \"Integer to pointer conversions\"),\nSCOP_STAT(Alloca, \"Stack allocations\"),\nSCOP_STAT(UnknownInst, \"Unknown Instructions\"),\nSCOP_STAT(Entry, \"Contains entry block\"),\nSCOP_STAT(Unprofitable, \"Assumed to be unprofitable\"),\nSCOP_STAT(LastOther, \"\")\n\\end{comment}\n\n\\section{Experiment Variables}\nThe experiment variables are listed in \\autoref{tab:experimentVariables}.\\\\\nThe classification \\(C\\) describes two types of regions handled within the study.\nThe one is \\enquote{\\scop} like explained in \\autoref{subsec:definitionScop}.\nThe other is \\enquote{parent} which is the next bigger region surrounding a \\scop.\\\\\nThe variables \\dyncovs and \\dyncovp are depending on \\(TI\\) because the selection of tests to run influences the regions executed and how often they are executed.\nSo \\(TI\\) has to be controlled.\nThis is done by using on the one hand integrated benchmarks brought by the tested programs and on the other hand using benchmarks which are accepted by the community like SPEC2006. (see \\autoref{tab:subjectPrograms})\\\\\nAlso the speedups \\(S_s\\) and \\(S_p\\) are dependent because they are calculated out of \\dyncovs and \\dyncovp.\n\\begin{table}[H]\n    \\myfloatalign\n    \\small\n    \\begin{tabularx}{\\textwidth}{Xccccc} \\toprule\n        \\tableheadline{Name}              & \\tableheadline{Abbr.} & \\tableheadline{Type} & \\tableheadline{Scale Type} & \\tableheadline{Unit}                          & \\tableheadline{Range} \\\\ \\midrule\n        Classification                    & \\(C\\)                 & Indep.               & Nominal                    & \\makecell{\\{Parent,\\\\\\scop\\}}                 & Text\\\\\n        Test inputs                       & \\(TI\\)                & Con.                 & Nominal                    & \\makecell{see\\\\\\autoref{tab:subjectPrograms}} & Text\\\\\n        \\midrule\n        Coverage of \\scops                & \\dyncovs              & Dep.                 & Ratio                      & \\%                                            & \\([0; 1[ \\in \\mathbb{Q}\\)\\\\\n        Coverage of MaxRegions            & \\dyncovp              & Dep.                 & Ratio                      & \\%                                            & \\([0; 1[ \\in \\mathbb{Q}\\)\\\\\n        Theoretical speedup of \\scops     & \\(S_s\\)               & Dep.                 & Ratio                      & \\%                                            & \\([0; 1[ \\in \\mathbb{Q}\\)\\\\\n        Theoretical speedup of MaxRegions & \\(S_p\\)               & Dep.                 & Ratio                      & \\%                                            & \\([0; 1[ \\in \\mathbb{Q}\\)\\\\\n        \\bottomrule\n    \\end{tabularx}\n    \\caption[Experiment Variables]{\n        Experiment variables (Dep.=Dependent; Indep.=Independent; Con.=Controlled).\n        The term \\enquote{MaxRegions} contains all regions classified as parent and the \\scops which have only a parent which is a top level region.\n    }\n    \\label{tab:experimentVariables}\n\\end{table}\nBesides the experiment variables also the term \\enquote{MaxRegions} has to be introduced.\nMaxRegions contains all regions classified as parent and the \\scops which have only a parent which is a top level regions.\n\n\\section{Hypotheses}\n\\(H_1\\): The main reason for rejecting a \\scop should be that its parent already is a top level region because also all \\scops classified as unprofitable by Polly are processed.\nSo a lot of very small functions may be processed.\nWhenever such a function has a \\scop it is likely that its parent is already a top level region.\\\\\n\\(H_2\\): The coverage \\dyncovs is expected to be about \\hTwoAbout, on average.\nEven if there are a lot of \\scops which are processed the -- according to the execution time -- big \\scops may not be able to be optimized, on average.\\\\\n\\(H_3\\): It is expected that \\dyncovp \\(\\gg\\) \\dyncovs, on average.\nThis may be a result of the fact that \\dyncovp ignores whether the reasons of parents being rejected as \\scop can be eliminated or not.\\\\\n\n\\section{Subject Programs}\nThe intention is to measure programs which are well known and often used by the community to get a more realistic picture.\nThe selection of programs (\\autoref{tab:subjectPrograms}) is limited due the list of programs available using benchbuild\\footnote{Benchbuild is a tool for automating the process of downloading, building, applying an experiment at compile time and executing a project on a SLURM \\cite{slurm} Cluster.} \\cite{benchbuild}.\n\\LTXtable{\\textwidth}{tables/subjectPrograms.tex}\n\n\\section{Tasks}\n\\begin{sloppypar}\n    We use benchmarks and scenarios integrated into the projects or test-suites that are respected by the corresponding development communities to get as close to a real-world scenario as possible.\n    Furthermore, \\lnt provides a whole range of benchmarks used by \\llvm.\n    Projects annotated with \\enquote{\\(program_{lnt}\\)} belong to \\lnt.\n\\end{sloppypar}\n\n\\section{Design}\nBased on the experiment variables (see \\autoref{tab:experimentVariables}) three experiments are performed to validate the hypotheses.\\\\\nThe first experiment takes the most common reason for rejecting a parent as valid \\scop and checks whether it is \\enquote{parent is top level region}.\\\\\nIn the second experiment the average value of \\dyncovs is calculated and checked whether it is near \\hTwoAbout.\\\\\nThe third experiment \\dyncovp and \\dyncovs are compared to check whether \\dyncovp \\(\\gg\\) \\dyncovs.\n\n\\section{Experiment Setting}\\label{sec:experimentSettings}\n\\begin{sloppypar}\n    This study uses instrumentation to retrieve precise timing information instead of using frameworks like OProfile \\cite{oprofile} or GProf \\cite{gprof}.\n    The measurement is realized using the \\papi library \\cite{papi}.\\\\\n    To take these measurement the following steps are performed:\\\\\n    The first step is implementing a new pass for Polly for instrumenting regions.\n    Afterwards a so called experiment for benchbuild \\cite{benchbuild} has to be created.\n    This experiment is calling the actual pass of Polly by specifying the appropriate clang options using \\texttt{-Xclang}, collects the generated data and persists it.\\\\\n    The pass itself is a FunctionPass.\n    Thus it is processing every function of the program.\n    In this case the pass is called twice.\n    Once for instrumenting the actual \\scops within, which also includes regions classified by Polly as \\enquote{unprofitable}, and once for instrumenting their parents.\n    Even the \\enquote{unprofitable} \\scops are included because they may get profitable to optimize when they are extended to the size of their parents.\n    To include these \\scops the option \\texttt{-polly-process-unprofitable} has to be specified using the \\texttt{-mllvm} option of clang.\n    While doing so the information about why these parents were rejected as \\scops are collected.\\\\\n    The instrumentation is designed to work for any region (\\autoref{subsec:definitionRegion}).\n    For a given region every incoming edge in the \\cfg (\\autoref{subsec:cfg}) is bent to a new node splitting the edges and pointing to the entry of the region.\n    Within this new node an instruction is placed starting the measurement of the execution time.\n    This instruction has the same for regions unique id and remembers the system time at the point where it was called.\n    The same way every outgoing edges in the \\cfg of this region is also split introducing a further new node in which an instruction is placed for stopping the measurement having the same id.\n    When it is called the current system time is requested again and the difference to the starting call is calculated providing the duration of the measured region.\n    The instrumented version of \\autoref{lst:matmulcpp} is shown in \\autoref{fig:afterInstrument} (The nodes having names ending with \\enquote{.profile.exit.split} are the newly introduced nodes).\n    \\begin{figure}[!h]\n        \\caption[Example of instrumented method]{\n            This figure shows \\autoref{lst:matmulcpp} after it is instrumented.\n            The nodes introduced through the instrumentation are the nodes having names ending with \\enquote{.profile.exit.split}.\n            In this case Polly warns about \\enquote{Call instruction: tail call @enter\\_region(...) [...]} which are exactly these entry calls.\n        }\n        \\includegraphics[width=\\textwidth]{gfx/matmulScopsAfterInstrumentation.png}\n        \\label{fig:afterInstrument}\n    \\end{figure}\n    The exact versions of the used software components are listed in \\autoref{tab:usedSoftware}.\\\\\n    All measurements are executed on an Intel Xeon E5-2650 v2 machine (2 Sockets with each 8 physical cores each 2.6GHz) with 128GB RAM.\n    The precise specifications are listed in \\autoref{tab:lscpu} and \\autoref{tab:meminfo}.\n\\end{sloppypar}\n\\begin{table}[!h]\n    \\myfloatalign\n    \\begin{tabularx}{.5\\textwidth}{Xc}\n        \\tableheadline{Name} & \\tableheadline{Version}\\\\ \\toprule\n        benchbuild           & (2bd0060)\\\\\n        LLVM                 & (04facbb8)\\\\\n        clang                & (89be37b)\\\\\n        polly                & (0fd4fea)\\\\\n        polli                & (697351d)\\\\\n        \\bottomrule\n    \\end{tabularx}\n    \\caption[Software used for measurements]{\n        This table lists the software used for the measurements.\n        The components LLVM, clang, polly and polli belong to the compiler infrastructure \\llvm itself.\n        benchbuild is a program for applying a certain \\enquote{experiment} (see \\autoref{sec:experimentSettings}) on a selection of programs, distributing them on a SLURM \\cite{slurm} cluster and run them.\n        (Versions in parenthesis represent short git hashes)\n    }\n    \\label{tab:usedSoftware}\n\\end{table}\n\n\\section{Deviations}\\label{sec:deviations}\nOnly about \\usefulRatio of the measured execution times can be used due to on the one hand bugs in the implementation and one the other hand the projects measured which could not be fixed because of time constraints.\nThe bug in the implementation is occurring in certain constellations of the basic blocks when instrumenting a parent like the following one which is found in the project bzip2 within the file bzlib.c:\n\\begin{code}\n    \\caption[Example of a non working parent]{\n        This lists a method within the file bzlib.c of the project bzip2.\n        The current instrumentation is not working when instrumenting regions within this method.\n    }\n    \\inputminted{c}{c/notWorkingParent.c}\n    \\label{lst:notWorkingParent}\n\\end{code}\nTo cope with it measurements of regions which have a bigger duration than the hole execution time of the project are excluded.\nAlso measurements of coverages are excluded where the coverage is greater than 100\\%.\nThese occur because the filtering of the obviously bad measurements is not enough to exclude all bad ones.\\\\\nFurthermore for minimizing the influences of the underlying OS multithreading is deactivated, the cluster node is used exclusively, the number of tasks is limited to one and the number of CPUs used per task is limited to 10.\n", "meta": {"hexsha": "51da933d288aa9c8582139960a6c78797626e71c", "size": 17665, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/EmpirischeStudie.tex", "max_stars_repo_name": "TrackerSB/Bachelorarbeit", "max_stars_repo_head_hexsha": "85c8b747bbf9cc2a010803942120b659d4e7a2e7", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/EmpirischeStudie.tex", "max_issues_repo_name": "TrackerSB/Bachelorarbeit", "max_issues_repo_head_hexsha": "85c8b747bbf9cc2a010803942120b659d4e7a2e7", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/EmpirischeStudie.tex", "max_forks_repo_name": "TrackerSB/Bachelorarbeit", "max_forks_repo_head_hexsha": "85c8b747bbf9cc2a010803942120b659d4e7a2e7", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.6041666667, "max_line_length": 319, "alphanum_fraction": 0.7187659213, "num_tokens": 4172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.519521321952093, "lm_q1q2_score": 0.4052229426532606}}
{"text": "\\section{Accounting for the variability in gene copy number during the cell\ncycle} \\label{supp_multi_gene}\n\n(Note: The Python code used for the calculations presented in this section can\nbe found in the\n\\href{https://www.rpgroup.caltech.edu/chann_cap/src/theory/html/moment_dynamics_cell_division.html}{following\nlink} as an annotated Jupyter notebook)\n\nWhen growing in rich media, bacteria can double every $\\approx$ 20 minutes.\nWith two replication forks each traveling at $\\approx$ 1000 bp per second, and\na genome of $\\approx$ 5 Mbp for {\\it E. coli} \\cite{Moran2010}, a cell would\nneed $\\approx$ 40 minutes to replicate its genome. The apparent paradox  of\ngrowth rates faster than one division per 40 minutes is solved by the fact that\ncells have multiple replisomes, i.e. molecular machines that replicate the\ngenome running in parallel. Cells can have up to 8 copies of the genome being\nreplicated simultaneously depending on the growth rate \\cite{Bremer1996}.\n\nThis observation implies that during the cell cycle gene copy number varies.\nThis variation depends on the growth rate and the relative position of the gene\nwith respect to the replication origin, having genes close to the replication\norigin spending more time with multiple copies compare to genes closer to the\nreplication termination site. This change in gene dosage has a direct effect on\nthe cell-to-cell variability in gene expression \\cite{Jones2014a,\nPeterson2015}.\n\n\\subsection{Numerical integration of moment equations}\n\n(Note: The Python code used for the calculations presented in this section can\nbe found in the\n\\href{https://www.rpgroup.caltech.edu//chann_cap/software/moment_dynamics_cell_division.html}{following\nlink} as an annotated Jupyter notebook)\n\nFor our specific locus ({\\it galK}) and a doubling time of $\\approx$ 60 min for\nour experimental conditions, cells have on average 1.66 copies of the reporter\ngene during the cell cycle \\cite{Jones2014a}. What this means is that cells\nspend 60\\% of the time having one copy of the gene and 40\\% of the time with\ntwo copies. To account for this variability in gene copy number across the cell\ncycle we numerically integrate the moment equations derived in\n\\siref{supp_moments} for a time $t = [0, t_s]$ with an mRNA production rate\n$r_m$, where $t_s$ is the time point at which the replication fork reaches our\nspecific locus. For the remaining time before the cell division $t = [t_s,\nt_d]$ that the cell spends with two promoters, we assume that the only\nparameter that changes is the mRNA production rate from $r_m$ to $2 r_m$. This\nsimplifying assumption ignores potential changes in protein translation rate\n$r_p$ or changes in the repressor copy number that would be reflected in\nchanges on the repressor on rate $\\kron$.\n\n\\subsubsection{Computing distribution moments after cell division}\n\n(Note: The Python code used for the calculations presented in this section can\nbe found in the\n\\href{https://www.rpgroup.caltech.edu//chann_cap/software/binomial_moments.html}{following\nlink} as an annotated Jupyter notebook)\n\nWe have already solved a general form for the dynamics of the moments of the\ndistribution, i.e. we wrote differential equations for the moments ${d\\ee{m^x\np^y}\\over dt}$. Given that we know all parameters for our model we can simply\nintegrate these equations numerically to compute how the moments of the\ndistribution evolve as cells progress through their cell cycle. Once the cell\nreaches a time $t_d$ when is going to divide the mRNA and proteins that we are\ninterested in undergo a binomial partitioning between the two daughter cells.\nIn other words, each molecule flips a coin and decides whether to go to either\ndaughter. The question then becomes given that we have a value for the moment\n$\\ee{m^x p^y}_{t_d}$ at a time before the cell division, what would the value\nof this moment be after the cell division takes place $\\ee{m^x p^y}_{t_o}$?\n\nThe probability distribution of mRNA and protein after the cell division\n$P_{t_o}(m, p)$ must satisfy\n\\begin{equation}\n  P_{t_o}(m, p) = \\sum_{m'=m}^\\infty \\sum_{p'=p}^\\infty \n                  P(m, p \\mid m', p') P_{t_d}(m', p'),\n\\label{eq_dist_post_div}\n\\end{equation}\nwhere we are summing over all the possibilities of having $m'$ mRNA and $p'$\nproteins before cell division. Note that the sums start at $m$ and $p$; this is\nbecause for a cell to have these copy numbers before cell division it is a\nrequirement that the mother cell had at least such copy number since we are not\nassuming that there is any production at the instantaneous cell division time.\nSince we assume that the partition of mRNA is independent from the partition of\nprotein, the conditional probability $P(m, p \\mid m', p')$ is simply given by a\nproduct of two binomial distributions, one for the mRNA and one for the\nprotein, i.e.\n\\begin{equation}\nP(m, p \\mid m', p') = {m' \\choose m} \\left( {1 \\over 2} \\right)^{m'} \\cdot\n                      {p' \\choose p} \\left( {1 \\over 2} \\right)^{p'}.\n\\label{eq_binom_prod}\n\\end{equation}\nBecause of these product of binomial probabilities are allowed to extend the\nsum from\n\\eref{eq_dist_post_div} to start at $m'=0$ and $p'=0$ as\n\\begin{equation}\n  P_{t_o}(m, p) = \\sum_{m'=0}^\\infty \\sum_{p'=0}^\\infty \n                  P(m, p \\mid m', p') P_{t_d}(m', p'),\n\\end{equation}\nsince the product of the binomial distributions in \\eref{eq_binom_prod} is zero\nfor all $m' < m$ and/or $p' < 0$. So from now on in this section we will assume\nthat a sum of the form $\\sum_x \\equiv \\sum_{x=0}^\\infty$ to simplify notation.\n\nWe can then compute the distribution moments after the cell division $\\ee{m^x\np^y}_{t_o}$ as\n\\begin{equation}\n\\ee{m^x p^y}_{t_o} = \\sum_m \\sum_p m^x p^y P_{t_o}(m, p),\n\\end{equation}\nfor all $x, y \\in \\mathbb{N}$. Substituting \\eref{eq_dist_post_div} results in\n\\begin{equation}\n\\ee{m^x p^y}_{t_o} = \\sum_m \\sum_p m^x p^y\n\\sum_{m'} \\sum_{p'} P(m, p \\mid m', p') P_{t_d}(m', p').\n\\end{equation}\nWe can rearrange the sums to be \n\\begin{equation}\n\\ee{m^x p^y}_{t_o} = \\sum_{m'} \\sum_{p'} P_{t_d}(m', p')\n                     \\sum_m \\sum_p m^x p^y P(m, p \\mid m', p').\n\\end{equation}\nThe fact that \\eref{eq_binom_prod} is the product of two independent events\nallows us to rewrite the joint probability $P(m, p \\mid m', p')$ as\n\\begin{equation}\nP(m, p \\mid m', p') = P(m \\mid m') \\cdot P(p \\mid p').\n\\end{equation}\nWith this we can then write the moment $\\ee{m^x p^y}_{t_o}$ as\n\\begin{equation}\n\\ee{m^x p^y}_{t_o} = \\sum_{m'} \\sum_{p'} P_{t_d}(m', p')\n                     \\sum_m  m^x  P(m \\mid m')\n                     \\sum_p p^y P(p \\mid p').\n\\end{equation}\nNotice that both terms summing over $m$ and over $p$ are the conditional\nexpected values, i.e.\n\\begin{equation}\n\\sum_z  z^x  P(z \\mid z') \\equiv \\ee{z^x \\mid z'}, \\; \n{\\text{ for } z\\in \\{m, p \\}}.\n\\end{equation}\nThese conditional expected values are the expected values of a binomial random\nvariable $z \\sim \\text{Bin}(z', 1/2)$, which can be easily computed as we will\nshow later in this section. We then rewrite the expected values after the cell\ndivision in terms of these moments of a binomial distribution\n\\begin{equation}\n\\ee{m^x p^y}_{t_o} = \\sum_{m'} \\sum_{p'} \\ee{m^x \\mid m'} \\ee{p^y \\mid p'} \n                     P_{t_d}(m', p').\n  \\label{eq_general_binom_mom}\n\\end{equation}\n\nTo see how this general formula for the moments after the cell division works\nlet's compute the mean protein per cell after the cell division $\\ee{p}_{t_o}$.\nThat is setting $x = 0$, and $y = 1$. This results in\n\\begin{equation}\n\\ee{p}_{t_o} = \\sum_{m'} \\sum_{p'} \\ee{m^0 \\mid m'} \\ee{p \\mid p'} \n               P_{t_d}(m', p').\n\\end{equation}\nThe zeroth moment $\\ee{m^0 \\mid m'}$ by definition must be one since we have\n\\begin{equation}\n\\ee{m^0 \\mid m'} = \\sum_m m^0 P(m \\mid m') = \\sum_m P(m \\mid m') = 1,\n\\end{equation}\nsince the probability distribution must be normalized. This leaves us then with\n\\begin{equation}\n\\ee{p}_{t_o} = \\sum_{m'} \\sum_{p'} P_{t_d}(m', p') \\ee{p \\mid p'}.\n\\end{equation}\nIf we take the sum over $m'$ we simply compute the marginal probability\ndistribution $\\sum_{m'} P_{t_d}(m', p') = P_{t_d}(p')$, then we have\n\\begin{equation}\n\\ee{p}_{t_o} = \\sum_{p'} \\ee{p \\mid p'} P_{t_d}(p').\n\\end{equation}\nFor the particular case of the first moment of the binomial distribution with\nparameters $p'$ and $1/2$ we know that\n\\begin{equation}\n\\ee{p \\mid p'} = {p' \\over 2}.\n\\end{equation}\nTherefore the moment after division is equal to\n\\begin{equation}\n\\ee{p}_{t_o} = \\sum_{p'} {p' \\over 2} P_{t_d}(p')\n             = {1 \\over 2} \\sum_{p'} p' P_{t_d}(p').\n\\end{equation}\nNotice that this is just 1/2 of the expected value of $p'$ averaging over the\ndistribution prior to cell division, i.e.\n\\begin{equation}\n\\ee{p}_{t_o} = {\\ee{p'}_{t_d} \\over 2},\n\\end{equation}\nwhere $\\ee{\\cdot}_{t_d}$ highlights that is the moment of the distribution\nprior to the cell division. This result makes perfect sense. What this is\nsaying is that the mean protein copy number right after the cell divides is\nhalf of the mean protein copy number just before the cell division. That is\nexactly we would expect. So in principle to know the first moment of either the\nmRNA distribution $\\ee{m}_{t_o}$ or the protein distribution $\\ee{m}_{t_o}$\nright after cell division it suffices to multiply the moments before the cell\ndivision $\\ee{m}_{t_d}$ or $\\ee{p}_{t_d}$ by 1/2. Let's now explore how this\ngeneralizes to any other moment $\\ee{m^x p^y}_{t_o}$.\n\n\\subsubsection{Computing the moments of a binomial distribution}\n\nThe result from last section was dependent on us knowing the functional form of\nthe first moment of the binomial distribution. For higher moments we need some\nsystematic way to compute such moments. Luckily for us we can do so by using\nthe so-called moment generating function (MGF). The MGF of a random variable\n$X$ is defined as\n\\begin{equation}\nM_X(t) = \\ee{e^{tX}},\n\\end{equation}\nwhere $t$ is a dummy variable. Once we know the MGF we can obtain any moment of\nthe distribution by simply computing\n\\begin{equation}\n  \\ee{X^n} = \\left. {d^n \\over dt^n} M_X(t) \\right\\vert_{t=0},\n  \\label{eq_mgf_def}\n\\end{equation}\ni.e. taking the $n$-th derivative of the MGF returns the $n$-th moment of the\ndistribution. For the particular case of the binomial distribution $X \\sim\n\\text{Bin}(N, q)$ it can be shown that the MGF is of the form\n\\begin{equation}\nM_X(t) = \\left[ (1 - q) + qe^{t} \\right]^N.\n\\end{equation}\nAs an example let's compute the first moment of this binomially distributed\nvariable. For this, the first derivative of the MGF results in\n\\begin{equation}\n  {d M_X(t) \\over dt} = N [(1 - q) + qe^t]^{N - 1} q e^t.\n\\end{equation}\nWe just need to follow \\eref{eq_mgf_def} and set $t = 0$ to obtain the first\nmoment\n\\begin{equation}\n  \\left. {d M_X(t) \\over dt} \\right\\vert_{t=0} = N q,\n  \\label{eq_mgf_mean}\n\\end{equation}\nwhich is exactly the expected value of a binomially distributed random\nvariable.\n\nSo according to \\eref{eq_general_binom_mom} to compute any moment $\\ee{m^x\np^y}$ after cell division we can just take the $x$-th derivative and the $y$-th\nderivative of the binomial MGF to obtain $\\ee{m^x \\mid m'}$ and $\\ee{p^y \\mid\np'}$, respectively, and take the expected value of the result. Let's follow on\ndetail the specific case for the moment $\\ee{m p}$. When computing the moment\nafter cell division $\\ee{mp}_{t_o}$ which is of\nthe form\n\\begin{equation}\n\\ee{mp}_{t_o} = \\sum_{m'} \\sum{p'} \\ee{m \\mid m'} \\ee{p \\mid p'} \n                P_{t_d}(m', p'),\n\\end{equation}\nthe product $\\ee{m \\mid m'} \\ee{p \\mid p'}$ is then\n\\begin{equation}\n\\ee{m \\mid m'} \\ee{p \\mid p'} = {m' \\over 2} \\cdot {p' \\over 2},\n\\end{equation}\nwhere we used the result in \\eref{eq_mgf_mean}, substituting $m$ and $p$ for\n$X$, respectively, and $q$ for 1/2. Substituting this result into the moment\ngives\n\\begin{equation}\n\\ee{mp}_{t_o} = \\sum_{m'} \\sum_{p'} {m' p' \\over 4} P_{t_d}(m', p') \n              = {\\ee{m' p'}_{t_d} \\over 4}.\n\\end{equation}\nTherefore to compute the moment after cell division $\\ee{mp}_{t_o}$ we simply\nhave to divide by 4 the corresponding equivalent moment before the cell\ndivision. \n\nNot all moments after cell division depend only on the equivalent moment before\ncell division. For example if we compute the third moment of the protein\ndistribution $\\ee{p^3}_{t_o}$, we find\n\\begin{equation}\n  \\ee{p^3}_{t_o} = {\\ee{p^3}_{t_d} \\over 8} + {3 \\ee{p^2}_{t_d} \\over 8}.\n\\end{equation}\nSo for this particular case the third moment of the protein distribution\ndepends on the third moment and the second moment before the cell division. In\ngeneral all moments after cell division $\\ee{m^x p^y}_{t_o}$ linearly depend on\nmoments before cell division. Furthermore, there is ``moment closure'' for this\nspecific case in the sense that all moments after cell division depend on lower\nmoments before cell division. To generalize these results to all the moments\ncomputed in this work let us then define a vector to collect all moments before\nthe cell division up the $\\ee{m^x p^y}_{t_d}$ moment, i.e.\n\\begin{equation}\n\\bb{\\ee{m^x p^y}}_{t_d} = \\left(\n\\ee{m^0 p^0}_{t_d}, \\ee{m^1}_{t_d}, \\ldots , \\ee{m^x p^y}_{t_d}\n\\right).\n\\end{equation}\nThen any moment after cell division $\\ee{m^{x'} p^{y'}}_{t_o}$ for $x' \\leq x$ and $y' \\leq y$ can be computed as\n$$\n\\ee{m^{x'} p^{y'}}_{t_o} = \\bb{z}_{x'y'} \\cdot \\bb{\\ee{m^x p^y}}_{t_d},\n$$\nwhere we define the vector $\\bb{z}_{x'y'}$ as the vector containing all the\ncoefficients that we obtain with the product of the two binomial distributions.\nFor example for the case of the third protein moment $\\ee{p^3}_{t_o}$ the\nvector $\\bb{z}_{x'y'}$ would have zeros for all entries except for the\ncorresponding entry for $\\ee{p^2}_{t_d}$ and for $\\ee{p^3}_{t_d}$, where it\nwould have $3/8$ and $1/8$ accordingly.\n\nIf we want then to compute all the moments after the cell division up to\n$\\ee{m^x p^y}_{t_o}$ let us define an equivalent vector\n\\begin{equation}\n\\bb{\\ee{m^x p^y}}_{t_o} = \\left(\n\\ee{m^0 p^0}_{t_o}, \\ee{m^1}_{t_o}, \\ldots , \\ee{m^x p^y}_{t_o}\n\\right).\n\\end{equation}\nThen we need to build a square matrix $\\bb{Z}$ such that each row of the matrix\ncontains the corresponding vector $\\bb{z}_{x' y'}$ for each of the moments.\nHaving this matrix we would simply compute the moments after the cell division\nas\n\\begin{equation}\n\\bb{\\ee{m^x p^x}}_{t_o} = \\bb{Z} \\cdot \\bb{\\ee{m^x p^x}}_{t_d}.\n\\end{equation}\nIn other words, matrix $\\bb{Z}$ will contain all the coefficients that we need\nto multiply by the moments before the cell division in order to obtain the\nmoments after cell division. Matrix $\\bb{Z}$ was then generated automatically\nusing Python's analytical math library sympy \\cite{sympy}.\n\n\\fref{sfig_first_mom_cycles} (adapted from \\fref{fig3_cell_cycle}(B)) shows how\nthe first moment of both mRNA and protein changes over several cell cycles. The\nmRNA quickly relaxes to the steady state corresponding to the parameters for\nboth a single and two promoter copies. This is expected since the parameters\nfor the mRNA production were determined in the first place under this\nassumption (See \\siref{supp_model}). We note that there is no apparent delay\nbefore reaching steady state of the mean mRNA count after the cell divides.\nThis is because the mean mRNA count for the two promoters copies  state is\nexactly twice the expected mRNA count for the single promoter state (See\n\\siref{supp_model}). Therefore once the mean mRNA count is halved after the\ncell division, it is already at the steady state value for the single promoter\ncase. On the other hand, given that the relaxation time to steady state is\ndetermined by the degradation rate, the mean protein count does not reach its\ncorresponding steady state value for either promoter copy number state.\nInterestingly once a couple of cell cycles have passed the first moment has a\nrepetitive trajectory over cell cycles. We have observed this experimentally by\ntracking cells as they grow under the microscope. Comparing cells at the\nbeginning of the cell cycle with the daughter cells that appear after cell\ndivision shown that on average all cells have the same amount of protein at the\nbeginning of the cell cycle (See Fig. 18 of \\cite{Phillips2019}), suggesting\nthat these dynamical steady state takes place \\textit{in vivo}.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS08.pdf}\n\t\\caption{\\textbf{First and second moment dynamics over cell the cell cycle.}\n\tMean $\\pm$ standard deviation mRNA (upper panel) and mean $\\pm$ standard\n\tdeviation protein copy number (lower panel) as the cell cycle progresses. The\n\tdark shaded region delimits the fraction of the cell cycle that cells spend\n\twith  a single copy of the promoter. The light shaded region delimits the\n\tfraction of the cell cycle that cells spend with two copies of the promoter.\n\tFor a 100 min doubling time at the {\\it galK} locus cells spend 60\\% of the\n\ttime with one copy of the promoter and the rest with two copies.}\n  \\label{sfig_first_mom_cycles}\n\\end{figure}\n\nIn principle when measuring gene expression levels experimentally from an\nasynchronous culture, cells are sampled from any time point across their\nindividual cell cycles. This means that the moments determined experimentally\ncorrespond to an average over the cell cycle. In the following section we\ndiscuss how to account for the fact that cells are not uniformly distributed\nacross the cell cycle in order to compute these averages.\n\n\\subsection{Exponentially distributed ages}\n\nAs mentioned in \\siref{supp_param_inference}, cells in exponential growth have\nexponentially distributed ages across the cell cycle, having more young cells\ncompared to old ones. Specifically the probability of a cell being at any time\npoint in the cell cycle is given by \\cite{Powell1956}\n\\begin{equation}\n  P(a) = (\\ln 2) \\cdot 2^{1 - a},\n  \\label{seq_age_prob}\n\\end{equation}\nwhere $a \\in [0, 1]$ is the stage of the cell cycle, with $a = 0$ being the\nstart of the cycle and $a = 1$ being the cell division. In\n\\siref{supp_cell_age_dist} we reproduce this derivation. It is a surprising\nresult, but can be intuitively thought as follows: If the culture is growing\nexponentially, that means that all the time there is an increasing number of\ncells. That means for example that if in a time interval $\\Delta t$ $N$ ``old''\ncells divided, these produced $2N$ ``young'' cells. So at any point there is\nalways more younger than older cells.\n\nOur numerical integration of the moment equations gave us a time evolution of\nthe moments as cells progress through the cell cycle. Since experimentally we\nsample asynchronous cells that follow \\eref{seq_age_prob}, each time point\nalong the moment dynamic must be weighted by the probability of having sampled\na cell at such specific time point of the cell cycle. Without loss of\ngenerality let's focus on the first mRNA moment $\\ee{m(t)}$ (the same can be\napplied to all other moments). As mentioned before, in order to calculate the\nfirst moment across the entire cell cycle we must weigh each time point by the\ncorresponding probability that a cell is found in such point of its cell cycle.\nThis translates to computing the integral\n\\begin{equation}\n  \\ee{m}_c = \\int_{\\text{beginning cell cycle}}^{\\text{end cell cycle}}\n                       \\ee{m(t)} P(t) dt,\n\\end{equation}\nwhere $\\ee{m}_c$ is the mean mRNA copy number averaged over the entire cell\ncycle trajectory, and $P(t)$ is the probability of a cell being at a time $t$ of\nits cell cycle.\n\nIf we set the time in units of the cell cycle length we can use\n\\eref{seq_age_prob} and compute instead\n\\begin{equation}\n  \\ee{m} = \\int_0^1 \\ee{m(a)} P(a) da,\n  \\label{seq_moment_avg}\n\\end{equation}\nwhere $P(a)$ is given by \\eref{seq_age_prob}.\n\nWhat \\eref{seq_moment_avg} implies is that in order to compute the first moment\n(or any moment of the distribution) we must weigh each point in the moment\ndynamics by the corresponding probability of a cell being at that point along\nits cell cycle. That is why when computing a moment we take the time trajectory\nof a single cell cycle as the ones shown in \\fref{sfig_first_mom_cycles} and\ncompute the average using \\eref{seq_age_prob} to weigh each time point. We\nperform this integral numerically for all moments using Simpson's rule.\n\n\\subsection{Reproducing the equilibrium picture}\n\nGiven the large variability of the first moments depicted in\n\\fref{sfig_first_mom_cycles} it is worth considering why a simplistic\nequilibrium picture has shown to be very successful in predicting the mean\nexpression level under diverse conditions \\cite{Garcia2011c, Brewster2014,\nBarnes2019, Razo-Mejia2018}. In this section we compare the simple repression\nthermodynamic model with this dynamical picture of the cell cycle. But before\ndiving into this comparison, it is worth recapping the assumptions that go into\nthe equilibrium model.\n\n\\subsubsection{Steady state under the thermodynamic model}\n\nGiven the construction of the thermodynamic model of gene regulation for which\nthe probability of the promoter microstates rather than the probability of mRNA\nor protein counts is accounted for,  we are only allowed to describe the\ndynamics of the first moment using this theoretical framework\n\\cite{Phillips2015}. Again let's only focus on the mRNA first moment $\\ee{m}$.\nThe same principles apply if we consider the protein first moment. We can write\na dynamical system of the form\n\\begin{equation}\n  \\dt{\\ee{m}} = r_m \\cdot \\pbound - \\gm \\ee{m},\n\\end{equation}\nwhere as before $r_m$ and $\\gm$ are the mRNA production and degradation rates\nrespectively, and $\\pbound$ is the probability of finding the RNAP bound to the\npromoter \\cite{Bintu2005a}. This dynamical system is predicted to have a single\nstable fixed point that we can find by computing the steady state. When we\nsolve for the mean mRNA copy number at steady state $\\ee{m}_{ss}$ we find\n\\begin{equation}\n  \\ee{m}_{ss} = {r_m \\over \\gm} \\pbound.\n\\end{equation}\n\nSince we assume that the only effect that the repressor has over the regulation\nof the promoter is exclusion of the RNAP from binding to the promoter, we\nassume that only $\\pbound$ depends on the repressor copy number $R$. Therefore\nwhen computing the fold-change in gene expression we  are left with\n\\begin{equation}\n  \\foldchange = {\\ee{m (R \\neq 0)}_{ss} \\over \\ee{m (R = 0)}_{ss}}\n              = {\\pbound (R \\neq 0) \\over \\pbound (R = 0)}.\n\\end{equation}\nAs derived in \\cite{Garcia2011c} this can be written in the language of\nequilibrium statistical mechanics as\n\\begin{equation}\n  \\foldchange = \\left(1 + {R \\over \\Nns}e^{-\\beta \\eR}  \\right)^{-1},\n  \\label{seq_fold_change_thermo}\n\\end{equation}\nwhere $\\beta \\equiv (k_BT)^{-1}$, $\\eR$ is the repressor-DNA binding energy,\nand $\\Nns$ is the number of non-specific binding sites where the repressor can\nbind.\n\nTo arrive at \\eref{seq_fold_change_thermo} we ignore the physiological changes\nthat occur during the cell cycle; one of the most important being the\nvariability in gene copy number that we are exploring in this section. It is\ntherefore worth thinking about whether or not the dynamical picture exemplified\nin \\fref{sfig_first_mom_cycles} can be reconciled with the predictions made by\n\\eref{seq_fold_change_thermo} both at the mRNA and protein level.\n\n\\fref{sfig_lacI_titration} compares the predictions of both theoretical\nframeworks for varying repressor copy numbers and repressor-DNA affinities. The\nsolid lines are directly computed from \\eref{seq_fold_change_thermo}. The\nhollow triangles and the solid circles, represent the fold-change in mRNA and\nprotein respectively as computed from the moment dynamics. To compute the\nfold-change from the kinetic picture we first numerically integrate the moment\ndynamics for both the two- and the three-state promoter (See\n\\fref{sfig_first_mom_cycles} for the unregulated case) and then average the\ntime series accounting for the probability of cells being sampled at each stage\nof the cell cycle as defined in \\eref{seq_moment_avg}. The small systematic\ndeviations between both models come partly from the simplifying assumption that\nthe repressor copy number, and therefore the repressor on rate $\\kron$ remains\nconstant during the cell cycle. In principle the gene producing the repressor\nprotein itself is also subjected to the same duplication during the cell cycle,\nchanging therefore the mean repressor copy number for both stages.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS09.pdf}\n\t\\caption{\\textbf{Comparison of the equilibrium and kinetic reressor titration\n\tpredictions.} The equilibrium model (solid lines) and the kinetic model with\n\tvariation over the cell cycle (solid circles and white triangles) predictions\n\tare compared for varying repressor copy numbers and operator binding energy.\n\tThe equilibrium model is directly computed from \\eref{seq_fold_change_thermo}\n\twhile the kinetic model is computed by numerically integrating the moment\n\tequations over several cell cycles, and then averaging over the extent of the\n\tcell cycle as defined in \\eref{seq_moment_avg}.}\n  \\label{sfig_lacI_titration}\n\\end{figure}\n\nFor completeness \\fref{sfig_IPTG_titration} compares the kinetic and\nequilibrium models for the extended model of \\cite{Razo-Mejia2018} in which the\ninducer concentration enters into the equation. The solid line is directly\ncomputed from Eq. 5 of \\cite{Razo-Mejia2018}. The hollow triangles and solid\npoints follow the same procedure as for \\fref{sfig_lacI_titration}, where the\nonly effect that the inducer is assume to have in the kinetics is an effective\nchange in the number of active repressors, affecting therefore $\\kron$.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS10.pdf}\n\t\\caption{\\textbf{Comparison of the equilibrium and kinetic inducer titration\n\tpredictions.} The equilibrium model (solid lines) and the kinetic model with\n\tvariation over the cell cycle (solid circles and white triangles)\n\tpredictions are compared for varying repressor copy numbers and inducer\n\tconcentrations. The equilibrium model is directly computed as Eq. 5 of\n\treference \\cite{Razo-Mejia2018} with repressor-DNA binding energy $\\eR =\n\t-13.5 \\; k_BT$ while the kinetic model is computed by numerically\n\tintegrating the moment dynamics over several cell cycles, and then averaging\n\tover the extent of a single cell cycle as defined in \\eref{seq_moment_avg}.}\n  \\label{sfig_IPTG_titration}\n\\end{figure}\n\n\\subsection{Comparison between single- and multi-promoter kinetic model}\n\nAfter these calculations it is worth questioning whether the inclusion of this\nchange in gene dosage is drastically different with respect to\nthe simpler picture of a kinetic model that ignores the gene copy number\nvariability during the cell cycle. To this end we systematically computed the\naverage moments for varying repressor copy number and repressor-DNA affinities.\nWe then compare these results with the moments obtained from a single-promoter\nmodel and their corresponding parameters. The derivation of the steady-state\nmoments of the distribution for the single-promoter model are detailed in\n\\siref{supp_moments}.\n\n\\fref{sfig_lacI_titration} and \\fref{sfig_IPTG_titration} both suggest that\nsince the dynamic multi-promoter model can reproduce the results of the\nequilibrium model at the first moment level it must then also be able to\nreproduce the results of the single-promoter model at this level (See\n\\siref{supp_param_inference}). The interesting comparison comes with higher\nmoments. A useful metric to consider for gene expression variability is the\nnoise in gene expression \\cite{Shahrezaei2008}. This quantity, defined as the\nstandard deviation divided by the mean, is a dimensionless metric of how much\nvariability there is with respect to the mean of a distribution. As we will\nshow below this quantity differs from the also commonly used metric known as\nthe Fano factor (variance / mean) in the sense that for experimentally\ndetermined expression levels in fluorescent arbitrary units, the noise is a\ndimensionless quantity while the Fano factor is not.\n\n\\fref{sfig_noise_comparison} shows the comparison of the predicted protein\nnoise between  the single- (dashed lines) and the multi-promoter model (solid\nlines) for different operators and repressor copy numbers. A striking\ndifference between both is that the single-promoter model predicts that as the\ninducer concentration increases, the standard deviation grows much slower than\nthe mean, giving a very small noise. In comparison the multi-promoter model has\na much higher floor for the lowest value of the noise, reflecting the expected\nresult that the variability in gene copy number across the cell cycle should\nincrease the cell-to-cell variability in gene expression \\cite{Peterson2015,\nJones2014a}\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS11.pdf}\n\t\\caption{\\textbf{Comparison of the predicted protein noise between a single-\n\tand a multi-promoter kinetic model.} Comparison of the noise\n\t(standard deviation/mean) between a kinetic model that considers a single\n\tpromoter at all times (dashed line) and the multi-promoter model developed\n\tin this section (solid line) for different repressor operators. (A) Operator\n\tO1,  $\\eR = -15.3 \\; k_BT$, (B) O2, $\\eR = -13.9 \\; k_BT$, (C) O3, $\\eR =\n\t-9.7 \\; k_BT$}\n  \\label{sfig_noise_comparison}\n\\end{figure}\n\n\\subsection{Comparison with experimental data}\\label{supp_theory_vs_data_mom}\n\nHaving shown that the kinetic model presented in this section can not only\nreproduce the results from the equilibrium picture at the mean level (See\n\\fref{sfig_lacI_titration} and \\fref{sfig_IPTG_titration}), but make predictions\nfor the cell-to-cell variability as quantified by the noise (See\n\\fref{sfig_noise_comparison}), we can assess whether or not this model is able\nto predict experimental measurements of the noise. For this we take the single\ncell intensity measurements (See Methods) to compute the noise at the protein\nlevel.\n\nAs mentioned before this metric differs from the Fano factor since for\nfluorescent arbitrary units the noise is a dimensionless quantity. To see why\nconsider that the noise is defined as\n\\begin{equation}\n\\text{noise} \\equiv \\frac{\\sqrt{\\left\\langle p^2 \\right\\rangle -\n                        \\left\\langle p \\right\\rangle^2}}\n                        {\\left\\langle p \\right\\rangle}.\n    \\label{seq_noise_protein}\n\\end{equation}\nWe assume that the intensity level of a cell $I$ is linearly proportional to\nthe absolute protein count, i.e.\n\\begin{equation}\nI = \\alpha p,\n\\label{seq_calibration_factor}\n\\end{equation}\nwhere $\\alpha$ is the proportionality constant between arbitrary units and\nprotein absolute number $p$. Substituting this definition on\n\\eref{seq_noise_protein} gives\n\\begin{equation}\n  \\text{noise} = {\\sqrt{\\ee{(\\alpha I)^2} - \\ee{\\alpha I}^2} \\over\n                \\ee{\\alpha I}}.\n\\end{equation}\n\nSince $\\alpha$ is a constant it can be taken out of the average operator\n$\\ee{\\cdot}$, obtaining\n\\begin{equation}\n  \\text{noise} = {\\sqrt{\\alpha^2 \\left(\\ee{I^2} -\n                \\ee{I}^2 \\right)} \\over\n                \\alpha \\ee{I}}\n       = {\\sqrt{\\left(\\ee{I^2} - \\ee{I}^2 \\right)} \\over\n                \\ee{I}}.\n\\end{equation}\n\nNotice that in \\eref{seq_calibration_factor} the linear proportionality between\nintensity and protein count has no intercept. This ignores the autofluorescence\nthat cells without reporter would generate. To account for this, in practice we\ncompute\n\\begin{equation}\n\\text{noise} = {\\sqrt{\\left(\\ee{(I - \\ee{I_\\text{auto}})^2} -\n                    \\ee{I - \\ee{I_\\text{auto}}}^2 \\right)} \\over\n                \\ee{I - \\ee{I_\\text{auto}}}}.\n\\end{equation}\nwhere $I$ is the intensity of the strain of interest and $\\ee{I_\\text{auto}}$\nis the mean autofluorescence intensity, obtained from a strain that does not\ncarry the fluorescent reporter gene.\n\n\\fref{sfig_noise_delta} shows the comparison between theoretical predictions\nand experimental measurements for the unregulated promoter. The reason we split\nthe data by operator despite the fact that since these are unregulated\npromoters, they should in principle have identical expression profiles is to\nprecisely make sure that this is the case. We have found in the past that\nsequences downstream of the RNAP binding site can affect the expression level\nof constitutively expressed genes. We can see that both models, the\nsingle-promoter (gray dotted line) and the multi-promoter (black dashed line)\nunderestimate the experimental noise to different degrees. The single-promoter\nmodel does a worse job at predicting the experimental data since it doesn't\naccount for the differences in gene dosage during the cell cycle. But still we\ncan see that accounting for this variability takes us to within a factor of two\nof the experimentally determined noise for these unregulated strains.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS12.pdf}\n\t\\caption{\\textbf{Protein noise of the unregulated promoter.} Comparison of\n\tthe experimental noise for different operators with the theoretical\n\tpredictions for the single-promoter (gray dotted line) and the multi-promoter\n\tmodel (black dashed line). Each datum represents a single date measurement of\n\tthe corresponding $\\Delta lacI$ strain with $\\geq 300$ cells. The points\n\tcorrespond to the median, and the error bars correspond to the 95\\%\n\tconfidence interval as determined by 10,000 bootstrap samples.}\n  \\label{sfig_noise_delta}\n\\end{figure}\n\nTo further test the model predictive power we compare the predictions for the\nthree-state regulated promoter. \\fref{sfig_noise_reg} shows the theoretical\npredictions for the single- and multi-promoter model for varying repressor\ncopy numbers and repressor-DNA binding affinities as a function of the inducer\nconcentration. We can see again that our zero-parameter fits systematically\nunderestimates the noise for all strains and all inducer concentrations. We\nhighlight that the $y$-axis is shown in a log-scale to emphasize more this\ndeviation; but, as we will show in the next section, our predictions still fall\nwithin a factor of two from the experimental data.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS13_v2.pdf}\n\t\\caption{\\textbf{Protein noise of the regulated promoter.} Comparison of the\n\texperimental noise for different operators ((A) O1,  $\\eR = -15.3 \\; k_BT$,\n\t(B) O2, $\\eR = -13.9 \\; k_BT$, (C) O3, $\\eR = -9.7 \\; k_BT$) with the\n\ttheoretical predictions for the single-promoter (dashed lines) and the\n\tmulti-promoter model (solid lines). Points represent the experimental noise\n\tas computed from single-cell fluorescence measurements of different {\\it E.\n\tcoli} strains under 12 different inducer concentrations. Dotted line\n\tindicates plot in linear rather than logarithmic scale. Each datum represents\n\ta single date measurement of the corresponding strain and IPTG concentration\n\twith $\\geq 300$ cells. The points correspond to the median, and the error\n\tbars correspond to the 95\\% confidence interval as determined by 10,000\n\tbootstrap samples. White-filled dots are plot at a different scale for better\n\tvisualization.}\n  \\label{sfig_noise_reg}\n\\end{figure}\n\n\\subsubsection{Systematic deviation of the noise in gene expression}\n\n\\fref{sfig_noise_delta} and \\fref{sfig_noise_reg} highlight that our model\nunderestimates the cell-to-cell variability as measured by the noise. To\nfurther explore this systematic deviation \\fref{sfig_noise_pred_vs_data} shows\nthe theoretical vs. experimental noise both in linear and log scale. As we can\nsee the data is systematically above the identity line. The data is colored by\ntheir corresponding experimental fold-change values. The data that has the\nlargest deviations from the identity line also corresponds to the data with the\nlargest error bars and the smallest fold-change. This is because measurements\nwith very small fold-changes correspond to intensities very close to the\nautofluorescence background. Therefore minimal changes when computing the noise\nare amplified given the ratio of std/mean. In \\siref{supp_empirical} we will \nexplore empirical ways to improve the agreement between our minimal model and\nthe experimental data to guide future efforts to improve the minimal.\n\n\\begin{figure}[h!]\n\t\\centering \\includegraphics\n  {../fig/si/figS14.pdf}\n\t\\caption{\\textbf{Systematic comparison of theoretical vs experimental noise\n\tin gene expression.} Theoretical vs. experimental noise both in linear\n\t(left) and log (right) scale. The dashed line shows the identity line of\n\tslope 1 and intercept zero. All data are colored by the corresponding value\n\tof the experimental fold-change in gene expression as indicated by the color\n\tbar. Each datum represents a single date measurement of the corresponding\n\tstrain and IPTG concentration with $\\geq 300$ cells. The points correspond\n\tto the median, and the error bars correspond to the 95\\% confidence interval\n\tas determined by 10,000 bootstrap samples.}\n  \\label{sfig_noise_pred_vs_data}\n\\end{figure}", "meta": {"hexsha": "4350724bb4a82a3cba2432a395a94226f89dd794", "size": 37006, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/appendix_multiple_gene_copy.tex", "max_stars_repo_name": "RPGroup-PBoC/chann_cap", "max_stars_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-21T04:06:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-09T07:36:58.000Z", "max_issues_repo_path": "doc/appendix_multiple_gene_copy.tex", "max_issues_repo_name": "RPGroup-PBoC/chann_cap", "max_issues_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/appendix_multiple_gene_copy.tex", "max_forks_repo_name": "RPGroup-PBoC/chann_cap", "max_forks_repo_head_hexsha": "f2a826166fc2d47c424951c616c46d497ed74b39", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-04-29T17:43:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-09T00:20:16.000Z", "avg_line_length": 53.2460431655, "max_line_length": 113, "alphanum_fraction": 0.757120467, "num_tokens": 9934, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4050846961713026}}
{"text": "% !TEX root = ../../main.tex\n\n\\section{Introduction}\n\\label{chap1:intro}\n\n\n\nThe goal of this work is to develop high order and efficient numerical methods for nonlinear collisionless kinetic models, such as the Vlasov-Poisson equations or drift-kinetic models. In most situations, the nonlinearity in the transport term originates from the coupling with a Poisson type problem that is used to compute the electric field.  \n\nHistorically, particle in cell methods have been extensively used to treat kinetic problems. In this approach, the unknown is sampled by discrete particles which are advanced in time using an ODE solver, whereas the electric field is computed on a spatial grid. For some problems, these methods can tackle high dimensional kinetic problems with a relatively low computational cost. However, they also suffer from numerical noise which pollutes the accuracy in low density regions of phase space. Moreover, as the number of particles is increased the error only decreases as the inverse of the square of the number of particles. Thus, convergence is slow. For a review of particle methods we refer the reader to \\cite{Verboncoeur:2005}.\n\nOn the other hand, Eulerian methods ({\\it e.g.}~finite volumes or finite differences), which directly discretize the phase space, are able to reach high order accuracy in time, space, and velocity.  However, in addition to the fact that they are costly, these methods usually suffer from stability constraints that force a relation between the time step and the phase space grid sizes, the so-called Courant--Friedrichs--Lewy (CFL) condition. Hence, a large number of time steps is required to reach the long times that are often required in plasma physics applications. \n\nTo overcome this CFL condition, semi-Lagrangian methods have been developed during the last decades. These methods realize a compromise between the Lagrangian (\\ie~particle in cell) and Eulerian approaches by exploiting the characteristics equations to overcome the CFL condition, while still performing computations on a grid in both space and velocity \\cite{Cheng:1976,Sonnendrucker:1999,Filbet:2003}. This approach is usually combined with splitting methods to avoid a costly multidimensional interpolation step. This allows for a separate treatment of the terms in the equation and the corresponding characteristic curves can then, at least in some situations, be computed analytically. For purely hyperbolic problems, the setting we consider here, it is also possible to construct high order splitting schemes \\cite{Casas:2017}.\n\nSplitting results in a very accurate and efficient scheme for the Vlasov-Poisson equation. This is the case because the problem is only split into two parts, the characteristics of which can then be solved exactly in time.  However, this is not necessarily true for more complicated equations such as gyrokinetic or drift-kinetic models. Indeed, for the drift-kinetic model, a three terms splitting has to be performed so that a relatively large number of stages are required to reach high order accuracy in time.  In addition, some stages can not be solved exactly in time and thus require additional numerical work to approximate them.\n\nIn \\cite{Crouseilles:2018} an alternative approach based on exponential integrators was proposed. These schemes exploit the fact that in many applications where (gyro)kinetic models are used, the most stringent CFL condition is associated with the linear part of the model. This observation serves as the basis for the numerical methods we will consider in this work. Starting from the variation of constant formula, the linear part of the model will be solved exactly as part of an exponential integrator, whereas the nonlinear part, which is very often orders of magnitudes less stiff than the linear part, will be treated explicitly in time. In practice, the linear part can then be solved in phase space by using Fourier techniques or semi-Lagrangian schemes and the nonlinear part is approximated by standard finite difference/finite volume/discontinuous Galerkin techniques. \n\nThe numerical results presented in \\cite{Crouseilles:2018} were generally very favorable. The authors were able to take larger time steps compared to what has been reported for splitting methods in the literature and the computational cost was significantly reduced. In addition, since exponential integrators treat the nonlinear part explicitly, they can be adapted much more easily to different models. Despite these many favorable properties, the largest stable time step size was difficult to predict and varied significantly from method to method. Moreover, as we will see, many exponential integrators can behave rather erratically depending on the specific configuration of the simulation.\n\nThus, the main goal in this paper is to understand the stability of exponential integrators when applied to purely hyperbolic problems. While there is a large literature and well established theory for exponential integrators applied to parabolic problems (see \\cite{Hochbruck:2010} and references therein), we will see that for purely hyperbolic problems many surprises are encountered. Based on this analysis we will then propose to use a class of exponential methods, Lawson methods, that do not suffer from the described deficiency. Our analysis explains the efficient and robust behavior of Lawson integrators for this kind of problems. We will also present numerical results for both the Vlasov--Poisson equations and a drift-kinetic model that confirm the expected behavior and shows that using this approach significant performance improvements compared to the exponential integrators used in \\cite{Crouseilles:2018}, and by extension compared to splitting methods, can be attained.\n\nThe paper is organized as follows. First, we offer a brief introduction to exponential methods (section \\ref{sec:expint}). Then, in section \\ref{ode} a linear stability analysis is performed for both the time and phase space discretization. For the explicit part, we consider both centered differences (such as Arakawa's method) and weighted essentially non-oscillatory schemes (WENO) schemes. In sections \\ref{sec:vp} and \\ref{sec:dk} we investigate the performance of these methods for the Vlasov--Poisson equations and a four-dimensional drift-kinetic model, respectively. \n\n\\section{Exponential integrators and Lawson methods\\label{sec:expint}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nExponential methods are a class of time integration schemes that are applied to differential equations of the form\n\\begin{equation}\n  \\label{eq:expint-eq}\n  \\dot{u} = Au + F(u),\n\\end{equation}\nwhere $A$ is a matrix and $F$ is a, in general nonlinear, function of $u$. Usually, both $A$ and $F$ are the result of a spatial semi-discretization of a partial differential equation. Exponential methods are applied to problems where $A$ is stiff or otherwise poses numerical challenges, while $F$ can be treated explicitly. For the hyperbolic case, a prototypical example is the Vlasov equation \\eqref{vlasov}. Exponential methods are advantageous if the largest velocity is large compared to the electric field. Then the linear part has a much more stringent CFL condition than the nonlinear part of the equation. We will consider this example in some detail later in the paper.\n\nIn this paper, we will consider two types of exponential methods. The idea of \\textit{exponential integrators} is to use the variation of constants formula to rewrite equation \\eqref{eq:expint-eq} in the following form\n\\[\n  u(t_n+\\Delta t) = \\exp(\\Delta t A) u(t_n) + \\int_0^{\\Delta t} \\exp((\\Delta t -s)A) F(u(t_n+s)) \\dd{s},\n\\]\nwhere we denote the time step size by $\\Delta t >0$ and $t_n = n\\Delta t$ with $n\\in\\mathbb{N}$. This expression is still exact; \\ie no approximation has been made. Note, however, that this can not be used as a numerical method as evaluating the integral would require the knowledge of $u(t_n+s)$, which is not available. The idea of an exponential integrator is to approximate the nonlinear part $F(u(t_n+s))$ in terms of the available data. In the simplest case we just evaluate it at the left endpoint. That is, we use $F(u(t_n+s))\\approx F(u^n)$. Then we can integrate the term $\\exp((\\Delta t -s)A)$ exactly and obtain.\n\\[\n  u(t_n+\\Delta t) \\approx u^{n+1} = \\exp(\\Delta t A) u^n + \\Delta t \\varphi_1(\\Delta t A) F(u^n),\n\\]\nwhere $\\varphi_1(z)=(\\mathrm{e}^z-1)/z$ is an entire function. This is the first order exponential Euler method. In a similar way exponential Runge--Kutta methods can be constructed. We refer to the literature, in particular the review article \\cite{Hochbruck:2010}, for more details.\n\nAnother ansatz to remove the stiff linear term from equation \\eqref{eq:expint-eq} is to introduce the change of variable\n\\[\n  v(t) := \\exp(-t A) u(t).\n\\]\nPlugging this into equation \\eqref{eq:expint-eq} yields\n\\begin{equation}\n  \\label{eq:lawson-eq}\n  \\dot{v}(t) = \\exp(-t A) F(\\exp(t A) v(t)).\n\\end{equation}\nNow we apply an explicit Runge--Kutta method to the transformed equation. In the simplest case, applying the explicit Euler scheme yields\n\\[\n  v(t_n+\\Delta t) \\approx v^{n+1} = v^{n} + \\Delta t \\exp(-t_n A) F(\\exp(t_n A)v^{n}).\n\\]\nReversing the change of variables yields\n\\[\n  u^{n+1} = \\exp(\\Delta t A) u^{n} + \\Delta t \\exp(\\Delta t A) F(u^{n}).\n\\]\nThis is the Lawson--Euler method, also a method of order one. Lawson methods are also commonly referred to as integrating factor methods. We immediately see that any explicit Runge--Kutta method applied to equation \\eqref{eq:lawson-eq} uniquely determines a Lawson scheme. We call the chosen Runge--Kutta method the \\textit{underlying Runge--Kutta method}. For more details we refer the reader to \\cite{Lawson:1967a,Canuto:1988,Trefethen:2000,Minchev:2005}.\n\nThe example of the Lawson--Euler method already shows the similarity between Lawson schemes and exponential integrators. In fact, Lawson methods can be considered a subclass of exponential integrators. That is, they are a type of exponential integrators that only involve the exponential, but no other matrix functions. For the purpose of this paper we keep the nomenclature distinct. A Lawson scheme is a numerical method obtained as described above, while an exponential integrator is a numerical scheme that, in addition to the matrix exponential, uses other matrix functions.\n\nThe efficiency of exponential methods crucially depends on a good method to evaluate the application of the required matrix functions to a vector. A range of methods has been developed to accomplish this. For example, Krylov methods or interpolation at Leja points can be used for a wide range of problems; see, for example, \\cite{Higham:2008,Hochbruck:1997,Al-Mohy:2011,Caliari:2014, Caliari:2016}. However, often the most efficient approach is to exploit particular knowledge about the differential equation under consideration. For example, in the hyperbolic case $A$ might be a linear advection operator. In this case the application of $\\exp(\\Delta t A)$ can be computed by using Fourier techniques or semi-Lagrangian schemes. Much research effort has been dedicated towards improving spectral and semi-Lagrangian schemes for kinetic problems \\cite{Crouseilles:2011,Einkemmer:2014,Einkemmer:2017a,Filbet:2003,Grandgirard:2006,Klimas:1994,Morrison:2017,Rossmanith:2011,Sonnendrucker:1999,Cheng:1976,Sircombe:2009,Crouseilles:2015,Crouseilles:2016,Einkemmer:2019,Einkemmer:2014b,Einkemmer:2014a} and obtaining good performance on state of the art HPC systems \\cite{Rozar:2014,Einkemmer:2015,Bigot:2012,Latu:2007,Mehrenberger:2013,Einkemmer:2016,Crouseilles:2009,Einkemmer:2020}.\n\nBefore proceeding, let us note that for parabolic problems, \\ie~where $A$ is an elliptic operator, a mature theory for exponential integrators is available. We again refer the reader to the review article \\cite{Hochbruck:2010}. In this setting there are relatively few surprises with respect to stability and even rigorous convergence results are available. In addition, exponential integrators have been considered for problems that include both hyperbolic and parabolic terms (see, for example \\cite{Martinez:2009,Tambue:2010,Einkemmer:2017,Einkemmer:2013}). An interesting point to make is that in this community Lawson methods have all but lost their appeal. In fact, there are many reasons why exponential integrators are to be preferred. For example, if a Krylov method is used to compute the matrix functions, the $\\varphi_1$ function usually converges faster than the exponential. In addition, exponential integrators that retain their full order for non-homogeneous boundary conditions have been constructed~\\cite{Hochbruck:2005}. It has been shown that this property can not be achieved for Lawson methods \\cite{Hochbruck:2020}. However, the situation for purely hyperbolic problems is markedly different. Most of the theoretical results that have been obtained in an abstract framework do not apply and there is relatively little literature available. We will see  that the stability for exponential integrators in the fully hyperbolic setting is full of surprises. Moreover, since for kinetic problems we usually have efficient methods to compute the matrix exponential and complicated boundary conditions are rather rare, Lawson methods are an attractive choice due to their improved stability, as we will see.\n\n\n\n\\section{Linear analysis\\label{ode}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\nDetermining the stability of a numerical scheme by conducting an analysis of a linear and scalar test equation is very well established in the literature. Usually, the Dahlquist test equation $\\dot{u} = \\lambda u$ is considered. The justification for this is that a linear ODE can be written as $\\dot{u} = A u$. Once the matrix $A$ is diagonalized we essentially obtain the test equation. For linear PDEs we first perform a space discretization. Then the same argument can be applied to the resulting differential equation and stability constraints, such as the famous CFL condition, can be deduced. In the nonlinear case this, of course, only gives an indication for stability. Nevertheless, in many practical problems the theory derived in this fashion agrees very well with what is observed in numerical experiments.\n\nThe situation for exponential integrators and Lawson methods is more complicated as we separate two parts of the differential equation. Thus, we will consider the following test equation\n\\begin{equation}\n  \\label{ode_linear}\n  \\dot{u} = ia u + \\lambda u, \\qquad a\\in\\mathbb{R}, \\lambda\\in\\mathbb{C}, \\qquad u(0) = u_0\\in\\mathbb{C}.\n\\end{equation}\nWe note that we are here exclusively interested in equations with two hyperbolic parts. The reason why we allow $\\lambda$ to lie in the complex plane is that some space discretization schemes introduce numerical diffusion. Thus, the discretization moves the eigenvalues from the imaginary axis to the left half complex plane.\n\nAlthough this test equation is used frequently in the literature, its use is also frequently criticized. The reason for this criticism is that in the linear case the equation $\\dot{u} = Au + Bu$ can only be transformed to the form given in equation \\eqref{ode_linear} if $A$ and $B$ are simultaneously diagonalizable. This is a severe restriction which is usually not true in practice. Thus, the test equation, even in the linear case, gives only a necessary condition for stability. While this argument is certainly correct, we emphasize that if a numerical integrator does not work for the test equation~\\eqref{ode_linear} there is not much hope that it would work for more complicated problems. Therefore, the test equation is still useful and in fact we will see that many of the deficiencies of exponential integrators observed in practice can be illustrated well using the test equation~\\eqref{ode_linear}.\n\n%In the following, we will denote by $u^n$ an approximation of $u(t_n)$, with $t_n=n\\Delta t$, \n%$\\; \\forall n\\in \\mathbb{N}$, $\\Delta t>0$ being the time step size.  We will study the stability of \n%different Lawson and exponential integrators by focusing on the influence of $a\\in\\mathbb{R}$ and \n%$\\lambda\\in\\mathbb{C}$. \n\n\\subsection{Lawson methods}\n% --------------------------------------------------------------------\n\nApplying a Lawson method to the test equation~\\eqref{ode_linear} proceeds as follows. First, we introduce the change of variable\n\\[\n  v(t)=e^{-iat} u(t).\n\\]\nwhich yields the equation\n\\[\n  \\dot{v} = e^{-iat} \\lambda (e^{iat }v) = \\lambda v.\n\\]\nThus, we precisely obtain the  Dahlquist test equation. We now apply an explicit Runge--Kutta method to that equation. It is well known that this results in\n\\[\n  v^{n+1} = \\phi(z) v^n, \\qquad z=\\lambda \\Delta t,\n\\]\nwhere $\\phi$ is the so-called stability function. Reversing the change of variable we obtain\n\\[\n  u^{n+1} = e^{ia\\Delta t} \\phi(z) u^{n}, \\qquad z=\\lambda \\Delta t.\n\\]\nThe condition for stability is $| e^{ia\\Delta t} \\phi(z) | = | \\phi(z) | \\leq 1$. Thus, the linear stability characteristics of a Lawson scheme is identical to that of its underlying Runge--Kutta method. \n\nThis makes the problem rather easy as the stability constraint for explicit Runge--Kutta methods has been extensively studied in the literature. In our present application we are primarily interested in obtaining numerical methods that maximize the part of the imaginary axis that is included in the domain of stability. It is well known that an $s$ stage method can include at most $i [-(s-1),s-1]$. This is, for example, stated as an exercise in \\cite[Chapter. IV.2, exercise 3]{Hairer:1996}. Thus, unfortunately, there is no analog to Runge--Kutta--Chebyshev methods for hyperbolic problems.\n\nFor the sake of completeness we plot in Figure \\ref{fig:RK_sd2} the curve given by $|\\phi(z)| = 1$ for different Runge-Kutta methods. The only non-standard method here is \\textit{RK(3,2) best} which is a three stage second order method that has been purposefully constructed to enhance stability on the imaginary axis (see Appendix \\ref{butcher} for its Butcher tableau). We also emphasize that the stability domain of the classic four stage fourth order Runge--Kutta method is quite close to the theoretical bound $i [-(s-1),s-1], s=4$.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=0.3\\textwidth]{\\localPath/figures/rk_sd.png}\n    \\caption{The domain of stability for some classic explicit Runge--Kutta methods is shown. The nomenclature \\textit{RK(s,p)} denotes a method with $s$ stages that is of order $p$. The Butcher tableaus of these methods are given in Appendix \\ref{butcher}.\n    }\n\t\\label{fig:RK_sd2}\n\\end{figure}\n\n\n\n\n\\subsection{Exponential integrators}\n% --------------------------------------------------------------------\n\nWe now apply commonly used exponential integrators to the test equation \\eqref{ode_linear}. In this work we will consider the following methods: ExpRK22 (a classic two stage second order method), the method of Cox--Matthews \\cite{Cox:2002}, the method of Hochbruck--Ostermann  \\cite{Hochbruck:2005}, and the method of Krogstad \\cite{Krogstad:2005}. We refer to \\cite{Hochbruck:2010} for more details and to Appendix \\ref{butcher} for the Butcher tableaus of these methods. \n\nFor the sake of brevity we will only detail the calculation for the ExpRK22 scheme. Applying this method to the test equation we obtain\n\\begin{eqnarray*}\n  k_1&=&e^{ia\\Delta t}u^n + \\Delta t\\varphi_1(ia\\Delta t)\\lambda u^n\\nonumber\\\\\n  u^{n+1}&=& e^{ia\\Delta t}u^n + \\Delta t \\Big[ (\\varphi_1(ia\\Delta t)-\\varphi_2(ia\\Delta t))\\lambda u^n + \\varphi_2(ia\\Delta t)\\lambda k_1\\Big], \n\\end{eqnarray*}\nwhere $\\varphi_1(z)=(e^{z}-1)/z$ and $\\varphi_2(z)=(e^{z}-1-z)/z^2$ are entire functions. This yields the stability function\n\\[\n  \\phi(z) = e^{ia\\Delta t} + \\Big(\\varphi_1(ia\\Delta t)-\\varphi_2(ia\\Delta t)+e^{ia\\Delta t}\\varphi_2(ia\\Delta t)\\Big)z + \\varphi_1(ia\\Delta t)\\varphi_2(ia\\Delta t)z^2,\n\\]\nwhere, as before, we use $z=\\lambda \\Delta t$.\n\nOur first observation is that, in contrast to Lawson methods, the behavior of this stability function can not be understood by the domain of stability of the underlying $RK(2, 2)$ method, \\ie~the explicit method we obtain if we take $a \\to 0$. In fact, as we vary $a$ the domain of stability changes drastically. The domain of stability for the four exponential integrators (ExpRK22, Cox--Matthews, Hochbruck--Ostermann, and Krogstad) is plotted in Figure~\\ref{fig:expRK_sd} for $a\\Delta t=1.1$ and $a\\Delta t=3.4$. It is most striking that for large $\\vert a\\Delta t \\vert$ the domain of stability does not contain a symmetric interval of the imaginary axis. It should be evident that this has the potential to causes severe stability issues.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/expRK22_sd.png}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/K_sd.png}\n\t\\end{subfigure}\n\n\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/CM_sd.png}\n\t\\end{subfigure}\n\t\t\\begin{subfigure}[b]{0.3\\textwidth}\n\t\t\\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/HO_sd.png}\n\t\\end{subfigure}\n    \\caption{Stability domain of exponential integrators for two different values of $a\\Delta t\\in\\{1.1, 3.4\\}$.  From top left to bottom right: ExpRK22,  Krogstad, Cox--Matthews and Hochbruck--Ostermann.}  \n\t\\label{fig:expRK_sd}\n\\end{figure}\n\n\n\n\n\\subsection{Phase space discretization}\n% --------------------------------------------------------------------\n\nWe start from the two-dimensional linear transport equation\n\\begin{equation}\n\t\\label{vp_linear}\n  \\partial_t f + d\\partial_x f + b\\partial_v f = 0, \\;\\; d, b\\in\\mathbb{R}, \\;\\; x\\in [0, 2 \\pi], \\;\\; v\\in [-v_{\\max},v_{\\max}], \n\\end{equation}\nwhere $v_{\\max}>0$  refers to the truncated velocity domain. The sought-after distribution function is $f(t,x,v)$ and we impose periodic boundary conditions in the $x$-direction. We assume that $d$ and $b$ are constants and thus the corresponding operators commute. This is an idealization of the Vlasov equation we will consider in the next section. In preparation for that example it is most useful to think that $d$ is large and thus would induce a stringent CFL condition if discretized by an explicit scheme.\n\nWe now have to discretize this equation both in the $x$ and the $v$ direction. In the spatial direction $x$, we will consider a spectral approximation. Performing a Fourier transformation of equation \\eqref{vp_linear} yields\n\\begin{equation} \n  \\label{fourier_x_vlasov}\n  \\partial_t \\hat{f}_{k} +  i d k\\hat{f}_{k} +b \\partial_v \\hat{f}_{k} = 0,\n\\end{equation} \nwhere $\\hat{f}_k(t,v)$ denotes the Fourier transform of $f(t,x,v)$ with respect to $x$. The corresponding frequency is denoted by $k$. \n\nWe now perform the discretization in the $v$ direction. The grid points are denoted by $v_j=-v_{\\max}+j \\Delta v$, with $\\Delta v=2v_{\\max}/N_v$, where $N_v$ is the number of points. We will consider two options here. Namely, either using a centered difference scheme or an upwind scheme.\n\n\\paragraph{Centered scheme in $v$\\\\}\nThe classic centered scheme is obtained by approximating the velocity derivative in equation \\eqref{fourier_x_vlasov} by\n$$\n  (\\partial_v \\hat{f}_{k})(v_j) \\approx \\frac{\\hat{f}_{k, j+1}-\\hat{f}_{k, j-1}}{2\\Delta v},\n$$ \nwhere $\\hat{f}_{k,j}$ is an approximation of $\\hat{f}_{k}(v_j)$.  Inserting this centered approximation \nin \\eqref{fourier_x_vlasov} yields\n\\begin{equation} \\label{eq:half-fourier}\n  \\partial_t \\hat{f}_{k,j} +  i d k\\hat{f}_{k,j} +b \\frac{\\hat{f}_{k,j+1} -\\hat{f}_{k,j-1} }{2\\Delta v} = 0.\n\\end{equation}\nThe system is already diagonal with respect to the index $k$. We now also diagonalize it with respect to the index $j$. To do that we express the function in terms of its Fourier modes with respect to $v$. That is,\n\\[\n  \\hat{f}_{k,j} = \\sum_m \\bar{f}_{k, m}\\exp\\left(i \\frac{2\\pi m}{2v_{\\max}}  v_j\\right),\n\\]\nwhere $\\bar{f}_{k,m}$ denotes the (double) Fourier transform of $f$ with frequency in space $k$ and frequency in velocity $m$. Inserting this into equation \\eqref{eq:half-fourier} yields\n\\begin{equation}\n  \\label{discrete_linear_transport}\n\t\\partial_t \\bar{f}_{k,m} + i dk\\bar{f}_{k,m} +b \\frac{i\\sin(2\\pi m \\Delta v/(2v_{\\max})) }{\\Delta v} \\bar{f}_{k,m}= 0.  \n\\end{equation}\nWe immediately see that this equation is precisely in the form of equation \\eqref{ode_linear} as studied in the previous section. We also observe that $\\lambda \\in i\\mathbb{R}$. That is, the eigenvalues for the centered difference approximation lie exclusively on the imaginary axis. One immediate consequence is that for Lawson methods the CFL condition is given by $b \\Delta t < C \\Delta v$, where $C$ is chosen such that $i [-C,C]$ lies in the domain of stability of the underlying Runge--Kutta method.\n\n\n\n\\paragraph{Linearized WENO approximation in $v$\\\\}\nA common technique to discretize hyperbolic partial differential equations is to use the so-called weighted essentially non-oscillatory schemes (WENO) schemes. These are nonlinear schemes that limit oscillations in regions where sharp gradients occur, but still yield high order accuracy in smooth regions of the phase space. In the linear case WENO schemes reduce to upwind discretizations. Here, we will consider the LW5 scheme (the linearized version of the WENO5 scheme as considered in \\cite{Baldauf:2008, Lunet:2017, Motamed:2010, Wang:2007}) that is given by (from now on we assume w.l.o.g.~that $b>0$)\n\\begin{align*}\n  (\\partial_v \\hat{f}_k)(v_j) &\\approx \\frac{1}{\\Delta v}\\Big(-\\frac{1}{30} \\hat{f}_{k,j-3} +\\frac{1}{4} \\hat{f}_{k,j-2} -\\hat{f}_{k,j-1} + \\frac{1}{3} \\hat{f}_{k,j} +\\frac{1}{2} \\hat{f}_{k,j+1} - \\frac{1}{20} \\hat{f}_{k,j+2}\\Big). \n\\end{align*}\nWe now perform the same analysis as for the centered scheme (see \\cite{Baldauf:2008, Crouseilles:2012}). This yields\n\\begin{align}\n  \\left( \\frac{2\\pi }{2 v_{\\max}}  i m \\bar{f}_{k, m} \\approx \\right)\n  %(i m \\bar{f}_{k, m} \\approx ) \\;\\; \n  \\mu_m \\bar{f}_{k, m} &:= \\frac{\\bar{f}_{k,m}}{\\Delta v}\\Big(-\\frac{1}{30} e^{-\\frac{3i m\\pi \\Delta v}{v_{\\max}}} +\\frac{1}{4} e^{-\\frac{2i m \\pi \\Delta v}{v_{\\max}}} -e^{-\\frac{i m \\pi \\Delta v}{v_{\\max}}}  \\nonumber\\\\\n  &\\hspace{1cm}+ \\frac{1}{3}  +\\frac{1}{2} e^{\\frac{i m \\pi \\Delta v}{v_{\\max}}} - \\frac{1}{20} e^{\\frac{2i m \\pi \\Delta v}{v_{\\max}}}\\Big). \n  \\label{lw5symbol}\n\\end{align}\nWe then obtain the equation \n\\begin{equation}\n\t\\label{discrete_linear_transport_weno}\n\t\\partial_t \\bar{f}_{k,m} + i dk\\bar{f}_{k,m} +b \\mu_m \\bar{f}_{k,m}= 0.\n\\end{equation}\nOnce again this is precisely the form of equation \\eqref{ode_linear}, where $a=dk\\in\\mathbb{R}$ and $\\lambda=b\\mu_m \\in\\mathbb{C}$. The main difference to the centered difference scheme is that $\\lambda$ is not necessarily on the imaginary axis. In fact, the eigenvalues aquire a negative real part which stabilizes the scheme and avoids spurious oscillations, but also adds unphysical dissipation to the numerical method.\n\n\\begin{remark}\n  Let us remark that performing a Fourier approximation in $v$ is also possible. Using the same notation as before, the counterpart of \\eqref{discrete_linear_transport} and \\eqref{discrete_linear_transport_weno} in that case is\n  $$\n    \\partial_t \\bar{f}_{k,m} + i dk\\bar{f}_{k,m} +b i \\frac{2\\pi m}{2 v_{\\max}} \\bar{f}_{k,m}= 0.\n  $$\n  It is worth mentioning that this last equation can be obtained by considering the limit $\\Delta v$ goes to zero in  \\eqref{discrete_linear_transport} or \\eqref{discrete_linear_transport_weno}. The stability condition can be computed as for the centered difference case, since the eigenvalues of the Fourier approximation also lies on the imaginary axis. The CFL condition is given by $b \\pi  < C \\Delta v$, where $C$ is chosen such that $i [-C,C]$ lies in the domain of stability of the underlying Runge--Kutta method. \n\\end{remark}\n\n\n\n\\subsection{Computing the CFL condition}\n% --------------------------------------------------------------------\n\nEquipped with the knowledge of the domain of stability for the time discretization and the eigenvalues of the space discretization, we are now in a position to determine the CFL condition for the linear transport equation \\eqref{vp_linear}. This task will be rather easy to accomplish for the Lawson schemes, where the stability does not depend on the advection speed for the transport in the $x$ direction. However, for exponential integrators even this linear analysis is rather complicated, as we will see.\n\n\n\\subsubsection{Centered scheme in $v$}\n% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn the case of centered approximation of the velocity derivative, the Fourier multiplier is a \npure imaginary complex number (see equation \\eqref{discrete_linear_transport}). We thus look for $y_{\\max}\\in \\mathbb{R}_+$ such that the interval $i(-y_{\\max},y_{\\max}) \\subset {\\cal D}$, where ${\\cal D}$ is the domain of stability for the chosen time integrator. \n\n\\paragraph{Lawson integrators\\\\} \nWe simply look for the largest value $y_{\\max}$ such that $i(-y_{\\max}, y_{\\max}) \\subset \\mathcal{D}$. The corresponding values for a number of schemes are listed in Table \\ref{tab:ymax_Lawson}. These values have to be understood in the following way: they induce the CFL condition $b \\Delta t\\leq y_{\\max}\\Delta v$ for the discretized equation \\eqref{discrete_linear_transport}, where $\\Delta t$ denotes the time step size and $\\Delta v$ is the velocity mesh size. \n\n\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|}\n\t\t\\hline\n\t\tMethods & Lawson($RK(3,2) \\; best$) & Lawson($RK(3,3)$) & Lawson($RK(4,4)$) \\\\\n\t\t\\hline\n\t\t$y_{\\max}$ & $2$ & $\\sqrt{3}$ & $2\\sqrt{2}$\\\\\n\t\t\\hline  \n\t\\end{tabular}\n\t\\caption{CFL number for some Lawson schemes applied to \\eqref{discrete_linear_transport}. }\n\t\\label{tab:ymax_Lawson}\n\\end{table}\n\n\\paragraph{Exponential integrators\\\\}\nFor the exponential integrators the domain of stability is very sensitive to the value of $(a\\Delta t)$. To get an idea of what we can expect, we consider the quantity $$y_{\\max}=\\min_{(a\\Delta t)\\in\\mathbb{R}} \\; y^{exp}_{\\max}(a \\Delta t).$$ As before, $y^{exp}_{\\max}(a\\Delta t)$ is the largest value such that : $$i(-y^{exp}_{\\max}(a\\Delta t), y^{exp}_{\\max}(a\\Delta t))\\subset {\\cal D},$$ where ${\\cal D}$ is the domain of stability for the chosen exponential time integrator for a given $(a\\Delta t)$. Even for relatively simple numerical methods it is not possible to compute this quantity analytically. Thus, we resort to numerical approximations. Unfortunately, it turns out that for most exponential integrators this value is zero. This can be appreciated by considering Figure \\ref{fig:expRK_sd} once more. Clearly, there are values of $(a \\Delta t)$ such that no relevant part of the imaginary axis (or only half the imaginary axis) is part of the domain of stability. Thus, most exponential integrators are unstable in the von Neumann sense. However, this is not what we observe in practice. In fact, already the results presented in \\cite{Crouseilles:2018} indicate that we can successfully run numerical simulations using, for example, the Cox--Matthews scheme. There are two major points to consider here\n\\begin{itemize}\n    \\item The $y_{\\max}$ obtained is a worst case estimate. In fact, we know that for $\\Delta t \\to 0$ we regain the stability of the underlying Runge--Kutta method. Thus, for small $(a \\Delta t)$ the methods is expected to work well.\n    \\item As is usually done we have mandated that $\\vert \\phi(z) \\vert \\leq 1$. However, strictly speaking this is not necessary for practical simulation. If we assume that $\\vert \\phi(z) \\vert \\leq 1+\\varepsilon$ and we take $n$ steps the amplification of the error is given by $(1+\\varepsilon)^n$. In the limit $n \\to +\\infty$ this quantity diverges. However, since we usually do not take infinitely small time steps we still can hope to obtain a relatively accurate approximation, especially if $\\varepsilon$ is small. In particular, if $\\varepsilon = C \\Delta t = C t_{final}/n$ (where $t_{final}$ denotes the final time and $n$ the number of iterations) we have $(1+\\varepsilon)^n = (1+\\tfrac{C t_{final}}{n} )^n \\leq \\exp(C t_{final})$ and thus the scheme is stable, while the error constant is increased by $\\exp(C t_{final})$.\n\\end{itemize}\n\nTo investigate this further, we propose to relax the stability condition by introducing a threshold $\\varepsilon>0$ in the definition of the stability domain\n\\begin{equation}\n  \\label{d_eps}\n\t\\mathcal{D}_\\varepsilon = \\{ z\\in\\mathbb{C} : |\\phi(z)| \\leq 1+\\varepsilon \\}. \n\\end{equation}\n\nIn Figure~\\ref{ymax_example}, we plot the domain of stability for the Cox--Matthews method and $a\\Delta t = 3.4$ for $\\varepsilon=0$ and $\\varepsilon=10^{-2}$. One can observe that in the latter case a non-zero $y_{\\max}^{exp}(3.4)$ is obtained. We also call attention to the fact that the part of the imaginary axis included in this relaxed stability domain is not symmetric. \n\n\\begin{figure}[h]\n  \\centering\n  \\begin{subfigure}[b]{0.33\\textwidth}\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/CM_sd_ymax_e0p00.png}\n  \\end{subfigure}\n  \\begin{subfigure}[b]{0.33\\textwidth}\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/CM_sd_ymax_e0p01.png}\n  \\end{subfigure}\n  \\caption{Example of variation of $y_+$ and $y_-$ when we relax the stability condition for the Cox--Matthews scheme. We represent $\\mathcal{D}_{0}$ on the left, and $\\mathcal{D}_{10^{-2}}$ on the right with the values $y_+$ and $y_-$  such that \n  $i(y_-, y_+)\\subset \\mathcal{D}_{\\varepsilon}$.}\n  \\label{ymax_example}\n\\end{figure}\n\nIn Figure \\ref{ymax_expRK22}, we plot the dependence of $y^{exp}_{\\max}$ as a function of $(a\\Delta t)$ for $\\varepsilon=10^{-2}$ and the ExpRK22 method. Let us recall that for $\\varepsilon=0$, the method gives $y_{\\max}=0$. One can observe that the  domain of stability ${\\cal D}_\\varepsilon$  of this method is still symmetric with respect to the real axis. In addition, the method becomes more stable as $|a\\Delta t|$ increases. Thus, the behavior of the method is completely different from the configuration with $\\varepsilon=0$.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[scale=0.3]{\\localPath/figures/ymax_expRK22_0p01}\n  \\caption{$y^{exp}_{\\max}$, $|y_+|$ and $|y_-|$ as a function of $a \\Delta t$ for the ExpRK22 method with $\\varepsilon=10^{-2}$. } \n\t\\label{ymax_expRK22}\n\\end{figure}\n\nIn Figure \\ref{ymax_HO}, we plot $y^{exp}_{\\max}$ as a function of $(a\\Delta t)$ for the Hochbruck--Ostermann method (once again for $\\varepsilon=10^{-2}$). This schemes also gives $y_{\\max}=0$ for $\\varepsilon=0$. In this case the domain of stability is not symmetric and the stability depends quite erratically on the value of $(a \\Delta t)$.\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[scale=0.3]{\\localPath/figures/ymax_HO_0p01}\n\t\\caption{$y^{exp}_{\\max}$, $|y_+|$ and $|y_-|$  as a function of $a\\Delta t$ for the Hochbruck--Ostermann method with $\\varepsilon=10^{-2}$.} \n\t\\label{ymax_HO}\n\\end{figure}\nIn Table \\ref{tab:ymax_expo} we have summarized the values of $y_{\\max}$ for the four exponential integrators considered in this paper.\n\n\\begin{table}\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|}\n\t\t\\hline\n\t\tMethods                                & ExpRK22 & Krogstad & Cox--Matthews & Hochbruck--Ostermann      \\\\\n\t\t\\hline\n\t\t$y^{exp}_{\\max} (\\varepsilon=10^{-3})$ & $0.300$ & $0.100$  & $0.150$      & $0.250$ \\\\\n\t\t\\hline\n\t\t$y^{exp}_{\\max} (\\varepsilon=10^{-2})$ & $0.551$ & $0.200$  & $0.450$      & $0.501$ \\\\\n\t\t\\hline  \n\t\t$y^{exp}_{\\max} (\\varepsilon=10^{-1})$ & $1.001$ & $0.601$  & $1.351$      & $1.702$ \\\\\n\t\t\\hline  \n\t\\end{tabular}\n\t\\caption{CFL number, assuming the relaxed stability constraint, for some exponential integrators applied to \\eqref{discrete_linear_transport}.}\n\t\\label{tab:ymax_expo}\n\\end{table}\n\nFinally, we give an illustration of the above comments by running \\eqref{vp_linear} ($d=b=1$ and $v_{\\max}=3$) with a discontinuous initial data to study the impact of high-frequency on the stability of exponential schemes coupled with a centered scheme in $v$. The initial condition is \n$$\n  f_0(x, v) = 1 \\mbox{ if } \\sqrt{(x-\\pi)^2+v^2} \\leq 1, \\mbox{ and } 0  \\mbox{ elsewhere}. \n$$\nFrom the stability analysis we know that for each $k$ it holds that $\\bar{f}^{n+1}_{k,m} = \\phi(z)\\bar{f}^{n}_{k,m}$, where $\\phi$ is the stability function. Our study enables us to estimate the amplification factor $|\\phi(z)|$ by $(1+\\varepsilon)$ (uniformly with respect to $k$) so that $|\\bar{f}^{n+1}_{k,m}|^2 \\leq  (1+\\varepsilon)^2 |\\bar{f}^{n}_{k,m}|^2$. Hence, for a given $\\varepsilon$, we consider a time step according to Table \\ref{tab:ymax_expo} and run two exponential schemes, namely Hochbruck-Ostermann and Cox-Matthews, for $100$ timesteps. After each time step we compute $\\| f^n\\|^2_{\\ell^2} / \\| f^0\\|^2_{\\ell^2}$. The results can be found in Figure~\\ref{instab}.\n\\begin{figure}\n  \\centering\n  \\begin{tabular}{cc}\n    \\includegraphics[scale=0.5]{\\localPath/figures/error_growup_HO.pdf} & \n    \\includegraphics[scale=0.5]{\\localPath/figures/error_growup_CM.pdf} \n  \\end{tabular}\n  \\caption{Evolution of $\\| f^n\\|^2_{\\ell^2} / \\| f^0\\|^2_{\\ell^2}$ and of $(1+\\varepsilon)^{2n}$ as a function of $n$ for different values of $\\varepsilon$. Left: Hochbruck-Ostermann scheme. Right: Cox-Matthews scheme.}\n  \\label{instab}\n\\end{figure}\nFirst, we have a numerical confirmation that $(1+\\varepsilon)$ is an estimate of the amplification factor (the ratio $\\| f^n\\|^2_{\\ell^2} / \\| f^0\\|^2_{\\ell^2}$ always lies under the curve $n\\mapsto (1+\\varepsilon)^{2n}$). Second, since the number of time steps is fixed, for $\\varepsilon=0.1$ the simulation becomes unstable for $n\\geq 20$. As soon as $\\varepsilon$ is small enough, the simulation is stable. \n%As mentioned above, if $\\varepsilon$ as $\\varepsilon =C \\Delta t = Ct_{final}/n$  \n%(with $\\Delta t=y_{\\max} \\Delta v$, $y_{\\max}$ being given by Table \\ref{tab:ymax_expo} and $\\Delta v=6/81$), \n%the scheme is  stable and considering a final time $t_{final} = n\\Delta t$, the linear analysis leads to \n%\\begin{eqnarray*}\n%\\|{f}^{n}\\|_{\\ell^2} &=& \\|\\bar{f}^{n}\\|_{\\ell^2} \\leq  (1+\\varepsilon)^n \\|\\bar{f}^{0}\\|_{\\ell^2} =  (1+C\\Delta t)^{t_{final}/\\Delta t} \\|\\bar{f}^{0}\\|_{\\ell^2} \\nonumber\\\\\n%&\\leq & \\exp(Ct_{final}) \\|\\bar{f}^{0}\\|_{\\ell^2} = \\exp(Ct_{final}) \\|{f}^{0}\\|_{\\ell^2}, \n%\\end{eqnarray*}\n%which gives some practical informations on the stability of the methods since $C$ and $t_{final}$ are known a priori. \n%\n\n\\subsubsection{Linearized WENO5 (LW5) scheme}\n% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn the case of a WENO5 approximation of the velocity derivative, we can not easily find a Fourier multiplier because of its nonlinearity. Recent studies about stability of WENO5 \\cite{Wang:2007, Motamed:2010, Lunet:2017} considered the linearized version of WENO schemes by freezing the nonlinear weights, so that WENO5 reduces to a high order (linear) upwind scheme called LW5. For this LW5 scheme we can compute the eigenvalues, see equation \\eqref{lw5symbol}, and different time stepping schemes can be studied to determine the stability limit. We consider only Lawson methods here since we found that the exponential schemes we considered (\\ie{}~ExpRK22, Krogstad, Cox--Matthews, Hochbruck--Ostermann) lead to unstable results when they are combined with LW5 (even in the weak sense considered in the previous section).\n\nThe goal  is then to determine the largest non-negative real number $\\sigma>0$ such that the eigenvalues of the upwind scheme LW5 scaled by $\\sigma$ are contained in the domain of stability for the time integrator. Since the eigenvalues of LW5 are not as simple as in the case of the centered scheme, we determine $\\sigma$ numerically. The main idea of the algorithm to obtain an estimation of $\\sigma$ is:\n\\begin{enumerate}\n  \\item The argument $\\varphi$ of the eigenvalues $\\mu_m$  (normalized by $\\Delta v$) given by \\eqref{lw5symbol} are discretized using a fine angular grid $\\{ \\varphi_k\\} \\subset [-\\pi/2, \\pi/2]$, since the real part of $\\mu_{m}$ is negative due to its diffusive character.\n  \\item A discretized version of the boundary of the stability domain of the underlying Runge--Kutta method is computed.\n  \\item For each discretized eigenvalue, we look for the closest boundary point of the Runge--Kutta stability domain. \n  This enables us to compute the associated stretching factor $\\sigma(\\varphi_k)$.\n  \\item Taking the minimum over all the discretized eigenvalues yields $\\sigma:=\\min_{k} \\sigma(\\varphi_k)$. \n\\end{enumerate}\n\nIn Figure \\ref{cfl_rk44_lw5} (left), we plot the dependence of $\\sigma$ with respect to the angle $\\varphi\\in [-\\pi/2, \\pi/2]$ for Lawson($RK(4, 4)$) coupled with LW5. We also plot (Figure \\ref{cfl_rk44_lw5} (right)) the stability domain of Lawson($RK(4, 4)$), the eigenvalues for LW5 (normalized by $\\Delta v$) and the eigenvalues for LW5 scaled by $\\sigma$. The CFL number for some Lawson schemes is shown in Table \\ref{tab:ymax_weno_Lawson}. It is interesting to note that the time step size is  reduced compared to the centered scheme.\n\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|}\n\t\t\\hline\n\t\tMethods & Lawson($RK(3,2) \\; best$) & Lawson($RK(3,3)$) & Lawson($RK(4,4)$) \\\\\n\t\t\\hline\n\t\t$\\sigma $ & $1.344$ & $1.433$   & $1.73$   \\\\\n\t\t\\hline  \n\t\\end{tabular}\n\t\\caption{CFL number for some Lawson schemes applied to \\eqref{discrete_linear_transport_weno}.}\n\t\\label{tab:ymax_weno_Lawson}\n\\end{table}\n\n\\begin{figure}[h]\n  \\centering\n  \\begin{subfigure}[b]{0.4\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/cfl_rk44_weno_phi.png}\n  \\end{subfigure}\n  \\begin{subfigure}[b]{0.3\\textwidth}\n    \\centering\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/cfl_rk44_weno.png}\n  \\end{subfigure}\n  \\caption{Left: $\\sigma$ as a function of the angle $\\varphi$. Right: stability domain of Lawson($RK(4,4)$) (red), eigenvalues for LW5 normalized by $\\Delta v$ (blue) and eigenvalues for LW5 normalized by $\\Delta v$ stretched with factor $\\sigma=1.73$ (dashed green).} \n  \\label{cfl_rk44_lw5}\n\\end{figure}\n\n\n\n\n\\section{Numerical simulation: Vlasov-Poisson equations\\label{sec:vp}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nIn this section we apply Lawson methods and exponential integrators to the Vlasov-Poisson system. We will see that the linear theory developed in the last section gives a good indication of the stability even for this nonlinear problem. We consider a distribution function $f(t, x, v)$ depending on time $t\\geq 0$, space $x$, with periodic boundary conditions, and velocity $v$, which satisfies the Vlasov equation \n\\begin{equation}\n\t\\label{vlasov}\n  \\partial_t f(t, x, v) + v\\partial_x f(t, x, v) + E(f)(t, x)\\partial_v f(t, x, v) = 0   \n\\end{equation}\ncoupled to a Poisson problem for the electric field $E(f)(t, x)$ \n\\begin{equation}\n  \\partial_x  E(f)(t, x)= \\int_{\\mathbb{R}} f(t, x, v) \\dd{v} -1. \n\\end{equation}\nWe employ a Fourier approximation in space. In velocity we either use a centered discretization\n$$\n  \\partial_t \\hat{f}_{k,j} + v_j i k \\hat{f}_{k,j} + \\Widehat{\\Big(E_{\\cdot} \\frac{f_{\\cdot,j+1}  -f_{\\cdot,j-1}}{2\\Delta v}\\Big)}_k = 0\n$$  \nor the WENO5 discretization\n\\begin{equation}\n  \\displaystyle\\partial_t \\hat{f}_{k,j} + v_j ik \\hat{f}_{k,j} + \\Widehat{\\Big(E^+_{\\cdot} \\frac{f^+_{\\cdot,j+1/2} - f^+_{\\cdot,j-1/2}}{\\Delta v} \\Big)}_k \n+ \\Widehat{\\Big(E^-_{\\cdot} \\frac{f^-_{\\cdot,j+1/2} - f^-_{\\cdot,j-1/2}}{\\Delta v} \\Big)}_k = 0, \n  \\label{vp_weno}\n\\end{equation} \nwhere $E^+=\\max(E, 0)$, $E^-=\\min(E, 0)$ and $f^\\pm_{j+1/2}$ denote the numerical fluxes (see Appendix \\ref{app_weno} for more details). Both of these phase space discretizations can be easily cast in the following form\n\\[\n  \\partial_t \\hat{f}_{k,j} = - v_j i k \\hat{f}_{k,j} + F(f)_{k,j},\n\\]\nfor an appropriately defined $F$. We can now apply an exponential integrator or a Lawson scheme. To illustrate this let us consider the exponential Euler method. This gives\n\\[\n  \\hat{f}^{n+1}_{k,j} = \\exp(-\\Delta t v_j i k) \\hat{f}^n_{k,j} + \\Delta t \\varphi_1(-\\Delta t v_j i k) F(f^n)_{k,j}.\n\\]\nSince in Fourier space the exponential and $\\varphi_1$ functions have only scalar arguments, their computation is easy and efficient (\\ie~no matrix functions have to be computed). Due to the nonlinearity, it is favorable to compute $E \\partial_v f$ in real space. This is done efficiently by using the fast Fourier transform. Generalizing this scheme to multiple dimensions in both space and velocity is straightforward.\n\nTo apply our theory from the linear analysis to the nonlinear Vlasov-Poisson case, we need a way to compute the CFL condition. Note that the coefficient of the $v$ advection depends on $E$ and thus implicitly on time. We choose the time step for the centered scheme as follows\n\\begin{equation}\n  \\label{cfl_vlasov_lc}\n  \\Delta t_n = \\frac{y_{\\max} \\Delta v}{\\| E^n \\|_{L^\\infty}}, \n\\end{equation}\nwhereas for the WENO5 scheme we use the CFL condition computed from its linearized version (LW5)\n\\begin{equation}\n  \\label{cfl_vlasov_lw}\n  \\Delta t_n = \\frac{\\sigma \\Delta v}{\\| E^n \\|_{L^\\infty}}.\n\\end{equation}\nThe value $\\| E^n \\|_{L^\\infty}$ is just the maximal value of the electric field at time $t_n$. The values for  $y_{\\max}$ and $\\sigma$ are given in Tables \\ref{tab:ymax_Lawson}, \\ref{tab:ymax_expo}, and \\ref{tab:ymax_weno_Lawson} according to the chosen time integrator. \n\n\n\n\\subsection{Landau damping test}\n% --------------------------------------------------------------------\n\nWe present numerical results for the standard Landau damping test case. The initial condition is given by\n$$\n  f_0(x, v) = \\frac{1}{\\sqrt{2\\pi}} e^{-\\frac{v^2}{2}} (1+0.001 \\cos(0.5 x)), \\;\\; x\\in [0, 4\\pi], v\\in \\mathbb{R}. \n$$\nThe numerical parameters are chosen as follows: the number of points in space is $N_x=81$ whereas the velocity domain is truncated to $[-v_{\\max}, v_{\\max}]$ with $v_{\\max}=8$ and is discretized with $N_v=128$ grid points.\n\nLet us remark that for the Landau damping test, the conditions \\eqref{cfl_vlasov_lc} and \\eqref{cfl_vlasov_lw} allow us to take very large time steps, since $\\| E^n \\|_{L^\\infty} \\leq \\| E^0 \\|_{L^\\infty} = 2\\cdot 10^{-3}$. Then, we get $\\Delta t = C \\Delta v \\; 0.5\\cdot 10^3 =  62.5 C$, where $C$ can be either $y_{\\max}$ or $\\sigma$ depending on the chosen time integrator. This means that in practice we can choose the time step $\\Delta t$ independently from the mesh. This is clearly a desirable feature of the time integrator.\n\nIn Figure \\ref{ld}, the time history of the electric energy $\\|E^n\\|_{L^2}$ (in semi-log scale) using Lawson($RK(4, 4)$)-WENO5 (with two different time steps $\\Delta t=1/8$ and $\\Delta t=1$), and using Hochbruck--Ostermann-CD2 (with $\\Delta t=1$). One can observe that the expected damping rate ($\\gamma=-0.153$) is recovered for the three schemes. Although, the accuracy deteriorates for $\\Delta t=1$ Lawson($RK(4, 4)$)-WENO5, the Hochbruck--Ostermann-CD2 scheme gives very good results even with $\\Delta t=1$. We note that all the numerical schemes are clearly stable.\n\n\\begin{figure}[h]\n\t\\centering\n  %\t\\input{\\localPath/figures/Emax}\n  \\includegraphics[width=\\textwidth]{\\localPath/figures/linear_landau.pdf}\n\t\\caption{Landau damping test: time history of $\\|E(t)\\|_{L^2}$ (semi-log scale) obtained with Lawson($RK(4, 4)$) and WENO5 \n\t(with $\\Delta t=1/8$ and $\\Delta t=1$) and with Hochbruck-Ostermann and CD2 (with $\\Delta t=1$)}.\n\t\\label{ld}\n\\end{figure}\n\n\n\n\\subsection{Bump on tail test}\n% --------------------------------------------------------------------\n\nNext, we consider the bump on tail test for which the initial condition is \n$$\n  f_0(x, v) = \\left[\\frac{0.9}{\\sqrt{2\\pi}} e^{-\\frac{v^2}{2}} + \\frac{0.2}{\\sqrt{2\\pi}} e^{-2(v-4.5)^2} \\right](1+0.04 \\cos(0.3 x)), \\;\\; x\\in [0, 20\\pi], v\\in \\mathbb{R}. \n$$\nThe numerical parameters are chosen as follows: the number of points in space is $N_x=135$ whereas the velocity domain $[-v_{\\max}, v_{\\max}]$ (with $v_{\\max}=8$) is discretized with $N_v=256$ grid points. Concerning the time step, as in the Landau damping example, the conditions \\eqref{cfl_vlasov_lc} and \\eqref{cfl_vlasov_lw} turn out to be very light for Lawson schemes. Indeed, we found $\\max_n \\| E^n \\|_{L^\\infty} \\approx 0.6$ so that, with the considered velocity grid, the time step has to be smaller than $0.14$ \nin the worst case (Lawson($RK(3, 2) \\; best)$ combined with WENO5). To capture correctly the phenomena involved in the bump on tail test, we take the following time step size\n\\begin{equation}\n  \\label{dtbot}\n  \\Delta t_n = \\min \\Big( 0.1,  \\frac{C \\Delta v}{\\|E^n\\|_{L^\\infty}} \\Big), \n\\end{equation}\nwith $C=y_{\\max}$ or $\\sigma$ depending on the chosen scheme. Thus, also in this configuration we are mostly limited by the accuracy and not by the stability constraint.\n\nIn Figure \\ref{space}, the full distribution function $f$ is plotted at time $t=40$ ($\\Delta t=0.05$) for different schemes (exponential or Lawson in time and WENO or centered differences in velocity). One can observe spurious oscillations when the centered differences scheme case is used (second and third rows) whereas the slope limiters of WENO5 (first line) are able to control this phenomena so that extremas are well preserved. This is consistent with what has been observed in the literature.\n\n%In Figure \\ref{space}, the full distribution function $f$ is plotted at time $t=40$ for \n%Lawson($RK(4, 4)$) coupled with the WENO5 scheme, Lawson($RK(4, 4)$) coupled with the centered scheme \n%and Hochbruck--Ostermann coupled with the centered scheme. In these figures, we look at the impact of the velocity \n%approximation.  One can observe spurious oscillations in the centered scheme case (middle figure) whereas the slope \n%limiters of WENO5 are able to control this phenomena so that extremas are well preserved. This is consistent with what has been observed in the literature.\n\n\\begin{figure}\n  \\begin{tabular}{ccc}\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/vp_dt0p05_weno.png} \\\\\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/vp_dt0p05_o2.png}\\\\\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/vp_dt0p05_expRK.png}\n  \\end{tabular}\n  \\caption{Distribution function at time $t=40$ as a function of $x$ and $v$ for: $(i)$ Lawson schemes ($RK(4, 4)$, $RK(3, 3)$, $RK(3, 2)$) + WENO5 (first row) ; $(ii)$ Lawson schemes ($RK(4, 4)$, $RK(3, 3)$, $RK(3, 2)$) + centered difference scheme (second row) ; $(iii)$ exponential schemes (Cox-Matthews, Krogstad, Hochbruck--Ostermann) + centered difference scheme (third row).}\n  \\label{space}      \n\\end{figure}\n\n%\\begin{figure}\n%\\centering\n%    \\includegraphics[width=\\textwidth]{\\localPath/figures/vp_cfl.png}\n%    \\caption{Distribution function at time $t=40$ as a function of $x$ and $v$ for Lawson($RK(4, 4)$) + WENO5 (left), Lawson($RK(4, 4)$) + centered scheme (center), Hochbruck--Ostermann + centered scheme (right).}  \n%\\label{space}      \n%\\end{figure}\n\nIn Figure \\ref{total_energy}, we plot the time evolution of $({\\cal H}^n -{\\cal H}(0))/{\\cal H}(0)$, where ${\\cal H}^n\\approx {\\cal H}(n\\Delta t)$ and ${\\cal H}(t)$ is the total energy defined by \n$$\n  {\\cal H}(t) = \\frac{1}{2}\\int\\int |v|^2 f(t, x, v) \\dd{x}\\dd{v} + \\frac{1}{2}\\int |E|^2(t, x) \\dd{x}. \n$$\nThis quantity is known to be preserved with time at the continuous level. It is thus a useful metric to evaluate and compare the different numerical methods. At this stage, all the used numerical methods are stable and we now look at their accuracy with respect to conservation of energy.\n% and thus allows us to look at the accuracy of the different methods considered in this paper.\nWe observe that Lawson/centered schemes (referred as 'CD2' in the legend) preserve this quantity well. It is well known (see for example \\cite{Crouseilles:2004}) that centered schemes are better at preserving the total energy compared to upwind schemes. The reason is that upwind schemes introduce numerical diffusion. The exponential integrators that are considered show all very similar behavior with respect to energy conservation. They seem to include less drift than the Lawson methods, but for the time scales considered here their error is larger.\n\n\\begin{figure}%[h]\n\t\\centering\n\t%\\input{\\localPath/figures/H}\n  \\includegraphics[width=0.9\\textwidth]{\\localPath/figures/H.png}\n\t\\caption{Time evolution of the relative error of the total energy for the different methods. }\n\t\\label{total_energy}\n\\end{figure}\n\nAlthough being able to choose the time step size independently of the mesh is a desirable feature, it makes checking the sharpness of the CFL estimate derived in the previous section more difficult. To accomplish this, we consider the same parameters as before, except for the phase space mesh which now uses $N_x=81$ and $N_v=512$ grid points.  Then the maximum time step becomes $\\Delta t=\\min_n C\\Delta v/\\|E^n\\|_{L^\\infty} \\approx 0.052C$ (since $\\max_n \\|E^n\\|_{L^\\infty}\\approx 0.6$ and $\\Delta v=16/512=0.03125$). We consider two different time steps:  $\\Delta t=0.052C$ (which satisfies the linearized CFL condition) and $\\Delta t = 1.4 \\times 0.052C$ (which violates the linearized CFL condition). The results are shown in Figure \\ref{unstable}. There the Lawson($RK(4,4)$) method has been chosen for the time discretization whereas WENO5 and centered scheme are both considered for the velocity discretization. More specifically,\n\\begin{itemize}\n    \\item for WENO5 we use $C=1.73$ (obtained from the linearized version LW5) and we compare the results obtained \n    with $\\Delta t=0.09$ (satisfies the CFL condition) and $\\Delta t=0.13$ (does not satisfy the CFL condition). \n    \\item for the centered scheme, we use $C=2\\sqrt{2}$ and we compare the results obtained with $\\Delta t=0.14$ (satisfies the CFL condition) with $\\Delta t=0.2$ (does not satisfy the CFL condition). \n\\end{itemize}\nIn Figure \\ref{unstable}, the time evolution of the electric energy $\\|E(t)\\|^2_{L^2}$ is displayed for these two velocity discretizations. One can observe for the time step size that satisfies the CFL condition the simulation is stable and gives the expected results, whereas for the choice that violates the CFL condition the simulation blows up. Thus, the results confirm that the CFL condition obtained by the linear theory yields a good prediction for the nonlinear Vlasov--Poisson equation. On the right part of Figure \\ref{unstable}, the time history of the quantity $C \\Delta v/ \\|E^n\\|_{L^\\infty}$ is shown (red) together with the time step size considered for the WENO velocity discretization. The choice $\\Delta t=0.13$ (blue line) is larger than the allowed time step size around $t\\approx 20$, which explains the numerical instability observed at that point in time. \n\n\\begin{figure}\n  \\centering\n  \\begin{tabular}{cccc}\n    \\includegraphics[scale=0.3]{\\localPath/figures/ee_weno_rk44.png} &\\hspace{-0.2cm}\\includegraphics[scale=0.3]{\\localPath/figures/ee_o2_rk44.png} & \\hspace{-0.2cm}\\includegraphics[scale=0.3]{\\localPath/figures/bot_cfl_weno_rk44.png} \n  \\end{tabular}\n  \\caption{Illustration of the accuracy of the CFL estimate obtained from the linear theory. History of electric energy with Lawson($RK(4,4)$) + WENO5 (left),  Lawson($RK(4,4)$) + centered scheme (middle) and history of CFL condition for Lawson($RK(4,4)$) + WENO5 case (right)}\n  \\label{unstable}      \n\\end{figure}\n \n\n\\section{Numerical simulation: drift-kinetic equations\\label{sec:dk}}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nIn this section we will consider a model motivated by the simulation of strongly magnetized plasmas, such as those found in tokamaks. In this case the dynamics is governed by gyrokinetic equations. Gyrokinetics averages out the fast oscillatory motion of the charged particles around the magnetic field lines. In a simplified slab geometry, gyrokinetic models reduce to the drift-kinetic equation. In this case the unknown $f$ depends on three cylindrical spatial coordinates $(r,\\theta,z)$ and one velocity direction $v$. This model is composed of a guiding-center dynamics in the plane orthogonal to the magnetic field lines and of a Vlasov type dynamics in the direction parallel (to the magnetic field lines). In addition to its relevance in physics, it is also a good test case for stressing exponential methods. The latter is due to the fact that after some time the nonlinearity can become strong enough such that the time step size is dictated by stability constraints (especially for high order methods).\n\nOur goal in this section is to find a numerical approximation of $f=f(t,r,\\theta,z,v)$ satisfying the following $4D$ slab drift-kinetic equation (see \\cite{Grandgirard:2006})\n\\begin{equation}\n  \\label{dk}\n  \\partial_tf-\\frac{\\partial_\\theta \\phi}{r}\\partial_rf+\\frac{\\partial_r \\phi}{r}\\partial_\\theta f + v\\partial_zf-\\partial_z\\phi\\partial_{v}f = 0,\n\\end{equation}\nfor $(r,\\theta,z,v)\\in \\Omega\\times[0,L]\\times \\mathbb{R}$, $\\Omega=[r_{\\rm min},r_{\\rm max}]\\times [0, 2\\pi]$. The self-consistent potential $\\phi=\\phi(r,\\theta,z)$ is determined by solving the quasi neutrality equation\n\\begin{align}\n  -\\left[\\partial_r^2\\phi+\\left(\\frac{1}{r}+\\frac{\\partial_r n_0(r)}{n_0(r)}\\right)\\partial_r\\phi \\right.&+\\left.\\frac{1}{r^2}\\partial_\\theta^2\\phi\\right]+\\frac{1}{T_e(r)}(\\phi-\\langle\\phi\\rangle)\\nonumber\\\\\n  \\label{qn}\n  &\\hspace{-3cm}=\\frac{1}{n_0(r)}\\int_{\\mathbb{R}} f\\dd{v}-1,\n\\end{align}\nwhere $\\langle\\phi\\rangle = \\frac{1}{L}\\int_0^L \\phi(r,\\theta,z)\\dd{z}$ and the functions $n_0$ and $T_e$ depend only on $r$ and are given analytically.\n\nIn many situations the $v \\partial_z f$ term yields the most restrictive CFL condition. In this setting exponential methods can be very successful as they remove the most stringent CFL condition, while still treating the remaining terms explicitly (which computationally is relatively cheap). The $\\varphi$ functions can be computed in Fourier space (as has been discussed in some detail for the Vlasov--Poisson system in the previous section) or using a semi-Lagrangian approach. Exponential integrators for the drift-kinetic model have been proposed in \\cite{Crouseilles:2018}. They compare favorably to splitting schemes and have the advantage that they can be more easily adapted to different models. In \\cite{Crouseilles:2018} only a second order exponential integrator and the fourth order Cox--Matthews scheme have been considered. Due to the investigations in the present paper we now understand that this is not an ideal choice. Thus, the purpose of this section is to demonstrate that Lawson methods can be more efficient and to further corroborate the results obtained in the previous sections. The difference in stability for Lawson schemes and exponential integrators will be very evident in the numerical simulations that are presented.\n\n\\subsection{Numerical discretization}\n% --------------------------------------------------------------------\n\nFirst, we remark that $z$ is a periodic variable which motivates us to consider the Fourier transform in this direction. The corresponding frequencies are denoted by $k$. Equation \\eqref{dk} then becomes\n$$\n  \\partial_t \\hat{f}_k -\\partial_r \\widehat{\\left(\\frac{\\partial_\\theta \\phi}{r}f\\right)}_k+\\partial_\\theta \\widehat{\\left(\\frac{\\partial_r \\phi}{r} f\\right)}_k +vik \\hat{f}_k-\\partial_v\\widehat{\\left( \\partial_z\\phi \\, f\\right)}_k=0.\n$$\nSetting $F(t, f)= \\partial_r \\widehat{\\left(\\frac{\\partial_\\theta \\phi}{r}f\\right)}-\\partial_\\theta \\widehat{\\left(\\frac{\\partial_r \\phi}{r} f\\right)} +\\partial_v\\widehat{\\left( \\partial_z\\phi \\,f\\right)}$, this equation can be written as\n$$\n  \\partial_t \\hat{f} = - vik \\hat{f} + F(t, f). \n$$\nThis is now precisely in the form to which we can apply an exponential method. In addition, computing the required matrix functions is very efficient as all the frequencies decouple (see the corresponding discussion in section \\ref{sec:vp}).\n\nTo complete the numerical scheme, one has to detail the phase space approximation. As in \\cite{Crouseilles:2018} we will use Arakawa's method to approximate the derivatives needed to compute $F$. Arakawa's method is a centered difference scheme that conserves three invariants. More details can be found in \\cite{Crouseilles:2018}.\n\n\n\n\\subsection{Numerical results \\label{subsec:driftkinetic-results}}\n% --------------------------------------------------------------------\n\nIn this section, we detail the physical parameters of the considered test case. The set up is identical to \\cite{Crouseilles:2018} (see also \\cite{Coulette:2013, Crouseilles:2014}). The initial value is given by \n\\begin{align*}\n  f(t=0,r,\\theta,z,v) &=\n  f_{\\rm eq}(r,v)\\left[1+\\epsilon \\exp\\left(-\\frac{(r-r_p)^2}{\\delta r}\\right)\\cos\\left(\\frac{2\\pi n}{L}z+m\\theta\\right)\\right],\n\\end{align*}\nwhere the equilibrium distribution is given by\n\\begin{equation} \\label{eq:equilibrium}\n  f_{\\rm eq}(r,v)=\\frac{n_0(r)\\exp(-\\frac{v^2}{2T_i(r)})}{(2\\pi T_i(r))^{1/2}}.\n\\end{equation}\nThe radial profiles $T_i$, $T_e$, and $n_0$ have the analytic expressions\n$$\n  \\mathcal{P}(r) = C_\\mathcal{P}\\exp\\left(-\\kappa_\\mathcal{P}\\delta r_{\\mathcal{P}}\\tanh(\\frac{r-r_p}{\\delta r_{\\mathcal{P}}})\\right), \\; \\mathcal{P}\\in \\{T_i,T_e,n_0\\}\n$$\nwith the constants defined as follows\n$$\n  C_{T_i}=C_{T_e}=1,\\ C_{n_0}=\\frac{r_{\\rm max}-r_{\\rm min}}{\n\\int_{r_{\\rm min}}^{r_{\\rm max}}\\exp(-\\kappa_{n_0}\\delta r_{n_0}\\tanh(\\frac{r-r_p}{\\delta r_{n_0}}))\\dd{r}}.\n$$\nFinally, we consider the parameters of \\cite{Coulette:2013} (MEDIUM case)\n\\begin{eqnarray*}\n  &&r_{\\rm min} = 0.1,\\ r_{\\rm max} = 14.5,\\\\\n  && \\kappa_{n_0}= 0.055,\\ \\kappa_{T_i}=\\kappa_{T_e}= 0.27586,\\\\\n  &&\\delta r_{T_i}=\\delta r_{T_e}=\\frac{\\delta r_{n_0}}{2}= 1.45,\\ \\epsilon=10^{-6},\\ n=1,\\ m=5,\\\\\n  &&L=1506.759067,\\ r_p = \\frac{r_{\\rm min}+r_{\\rm max}}{2},\\delta r = \\frac{4 \\delta r_{n_0}}{\\delta r_{T_i}},\n\\end{eqnarray*}\nand use a $v$-range of $v \\in [-7.32,7.32]$.\n\nWe consider two configurations. A direct formulation, where the boundary conditions are given by\n$$\n  f(r_{\\rm min},\\theta ,z,v)=f_{eq}(r_{\\rm min},v) \\qquad\n  f(r_{\\rm max},\\theta ,z,v)=f_{eq}(r_{\\rm max},v).\n$$\nNote that these are not homogeneous Dirichlet boundary conditions. It is well known (and supported by \\cite{Crouseilles:2018}) that the Arakawa scheme works better for homogeneous boundary conditions. In addition to the direct formulation, we therefore also introduce a so-called perturbation formulation (see also \\cite{Crouseilles:2014, Latu:2014}). First, we note that the equilibrium function $f_{\\rm eq}$ defined in (\\ref{eq:equilibrium}) is a steady state for our problem. We therefore divide $f$ into\n$$\n  f(t,r,\\theta ,v)=f_{eq}(r,v)+\\delta f(t,r,\\theta ,v).\n$$\nWith this formulation, our problem (\\ref{dk}) becomes\n$$\n  \\partial_t\\delta f+\\frac{E_\\theta}{r}\\partial_r (f_{eq} + \\delta f)-\\frac{E_r}{r}\\partial_\\theta \\delta f+v\\partial_z\\delta f+E_z \\partial_v (f_{eq} + \\delta f)=0,\n$$\nwhere $E_\\theta=-\\partial_\\theta \\phi$, $E_r=-\\partial_r \\phi$ and $E_z=-\\partial_z \\phi$. Expanding the various terms we obtain\n$$\n  \\partial_t\\delta f+\\frac{E_\\theta}{r}\\partial_r\\delta f-\\frac{E_r}{r}\\partial_\\theta \\delta f+v\\partial_z\\delta f+ E_z \\partial_v \\delta f\n  +\\frac{E_\\theta}{r}\\partial_r f_{eq} + E_z \\partial _v f_{eq}=0\n$$\nwhich can be written as\n$$\n  \\partial_t\\delta f + v\\partial_z \\delta f -F(\\delta f) +\\frac{E_\\theta}{r}\\partial_r f_{eq} +E_z\\partial _v f_{eq} = 0.\n$$\nNote that the equation is very similar to equation (\\ref{dk}). We, however, have obtained two additional source terms, which depend on the equilibrium distribution $f_{eq}$ as well as on the electric field. Furthermore, the right hand side of the quasi-neutrality equation (\\ref{qn}) becomes\n$$\n  \\frac{1}{n_0}\\int f_{eq} \\dd{v}+\\frac{1}{n_0}\\int \\delta f \\dd{v} - 1 = \\frac{1}{n_0}\\int \\delta f \\dd{v}.\n$$\nDue to the similarity of the direct formulation and the perturbation formulation, the same code can be used for both by simply exchanging the right hand side of the quasi-neutrality equation, changing the boundary conditions, and adding the appropriate source terms. Thus, to implement the exponential integrator we consider the following equation \n$$\n  \\partial_t\\delta f + v\\partial_z \\delta f  = F_{pert}(\\delta f),\n$$\nwith\n$$\n  F_{pert} (\\delta f)= F(\\delta f) -\\frac{E_\\theta}{r}\\partial_r f_{eq} - E_z\\partial _v f_{eq},\n$$\nand proceed as before (with $F$ replaced by $F_{pert}$). The space discretization of the source terms can be done either analytically or using a numerical approximation. In our implementation we have used standard centered differences. The Arakawa scheme that is used to discretize $F(\\delta f)$ now employs homogeneous Dirichlet boundary conditions for $\\delta f$ in the $r$-direction.\n\nWe have seen in section \\ref{sec:vp} that for the Vlasov--Poisson equation we can derive a constraint on the time step size which ensures stability. For Lawson methods this also gives a good estimate in practice. However, for exponential integrators the situation is far more complicated, see the discussion in section \\ref{ode}. Thus, a natural question that arises is how large time steps can we take in practice. To do that we will employ an adaptive step size controller that uses Richardson extrapolation to obtain an error estimate. By denoting a time step as follows $f^{n+1} = \\varphi_{\\Delta t_n}(f^n)$ and considering $\\tilde{f}^{n+1} = \\varphi_{\\Delta t_n/2}\\circ \\varphi_{\\Delta t_n/2}(f^n)$ we can construct the Richardson extrapolated numerical solution of a method of order $p$ as follows $f_R^{n+1} = (2^{p+1} \\tilde{f}^{n+1} - f^{n+1})/(2^{p+1} -1)$, which turns out \nto be an approximation of order $(p+1)$ of the exact solution. Then, it is possible to determine an estimate of the local error $e_{n+1}$ of the time integrator through the following expression\n$$\n  e_{n+1} = \\left\\Vert f_R^{n+1} - f^{n+1}\\right\\Vert_{L^{\\infty}} + {\\cal O}(\\Delta t_n^{p+2}), \n  %\\left\\Vert \\frac{2^{p+1} (\\tilde{f}^{n+1} - f^{n+1})}{2^{p+1}  - 1} - f^{n+1} \\right\\Vert_{L^2} + {\\cal O}(\\Delta t_n^{p+2}), \n$$\nwhere the $L^\\infty$ norm is considered in the $r, \\theta, z, v$ variables. If the estimate for the error $e_{n+1}$ is larger than a specified $\\text{tol}$ we reject the step and start again from time $t_n$. Otherwise, the step is accepted and we proceed with the time integration. In either case we then determine the new step size $\\Delta t_{new}$ such that the local error is smaller than the tolerance. That is, we choose \n\\begin{equation} \n  \\label{compute_dt}\n  \\Delta t_{new}=s \\Delta t_{n}\\left(\\frac{\\text{tol}}{e_{n+1}}\\right)^{1/(p+1)}, \n\\end{equation}\nwhere $\\text{tol}$ is the prescribed tolerance, $p$ is the order of the method, and $s=0.8$ is a safety factor. This process is very well established in the literature and we refer the interested reader to \\cite{Gustafsson:1988,Gustafsson:1988,Soderlind:2002,Soderlind:2006,Einkemmer:2018}. Other strategies can also be considered such as embedded Lawson or exponential methods (see \\cite{Hairer:2006, Balac:2013}). Such methods may be more efficient but we restrict ourselves here to the strategy based on Richardson extrapolation since it can be applied to any time integrator.\n\nAn interesting property of this adaptive step size controller is that it forces the time step size to satisfy the stability constraint of the numerical method. This is perhaps surprising at first sight since the scheme only controls the local error. However, numerical instability are characterized by error amplification as integration proceeds in time. Thus, a single step can violate the stability constraint, but later on the error amplification increases the local error in such a way that the adaptive step size controller is forced to reduce the time step size. Thus, the controller ensures that we obtain a stable numerical simulation for which the local error is below the specified tolerance.\n\nThis procedure allows us to perform a fair comparison between Lawson methods and exponential integrators. Since we are mainly interested in the stability of the methods and, particularly in the nonlinear regime, prescribing a stringent tolerance is infeasible in any case, we will choose a relatively large tolerance for our simulation ($\\text{tol}=10^{-2}$ for the perturbation formulation). To avoid the problem of too large time steps at the beginning of the simulation, where accuracy and not stability dictates the time step, we limit the maximal step size to $\\Delta t=11$ (coarse) and $\\Delta t=10$ (fine) for second order methods, $\\Delta t=30$ for third order methods and Lawson($RK(3, 2) \\; best$), and $\\Delta t=40$ for fourth order methods.\n\nTo evaluate the performances of the different time integrators, we consider the time evolution of the electric energy defined by\n$$\n  {\\cal E}(t) = \\left( \\int_{0}^{L} \\int_0^{2\\pi} \\phi^2(t, r_p, \\theta, z ) \\dd{\\theta} \\dd{z} \\right)^{1/2}, \\;\\;\\; \\mbox{ with } r_p=\\frac{r_{\\min}+r_{\\max}}{2}, \n$$\nas well as the time evolution of the total mass and the total energy \n\\begin{eqnarray*}\n  {\\cal M}(t) &=& \\int_{r_{\\min}}^{r_{\\max}} \\int_{0}^{L} \\int_0^{2\\pi} \\int_{\\mathbb R} f(t, r, \\theta, z, v ) \\dd{v} \\dd{\\theta} \\dd{z} \\dd{r}, \\nonumber\\\\ \n  {\\cal N}(t) &=&\\int_{r_{\\min}}^{r_{\\max}} \\int_{0}^{L} \\int_0^{2\\pi} \\int_{\\mathbb R} \\frac{v^2}{2} f(t, r, \\theta, z, v ) \\dd{v} \\dd{\\theta} \\dd{z} \\dd{r} \\nonumber\\\\ \n  && + \\int_{r_{\\min}}^{r_{\\max}} \\int_{0}^{L} \\int_0^{2\\pi} \\int_{\\mathbb R} f(t, r, \\theta, z, v )\\phi(t, r, \\theta, z) \\dd{v} \\dd{\\theta} \\dd{z} \\dd{r}. \n\\end{eqnarray*}\nThe numerical results for the perturbation formulation are given in Figure \\ref{fig:driftkinetic-pert1}. There the time history of the electric energy and the time step size as of function of time for two different discretizations in phase space, $32 \\times 32 \\times 32 \\times 64$ and  $64 \\times 64 \\times 64 \\times 128$ grid points, are shown. We first see that all the time integrators agree very well; that is, we see an initial exponential growth (the rate is in good agreement with the linear theory; see, for example, \\cite{Coulette:2013}) in the electric energy. This phase is followed by saturation at very similar levels for all numerical methods used. We also observe that all exponential integrators, except the method of Krogstad, are forced to reduce their step size after time $t\\approx 5000$ for the fine, \\ie $64\\times 64 \\times 64 \\times 128$ grid points, case. This is particularly drastic for ExpRK33 and the Cox--Matthews method which suffer from stability issues even for the coarse discretization. In general, for the finer space discretization (see the right plot in Figure \\ref{fig:driftkinetic-pert1}), the problem becomes significantly more severe. It is also worth mentioning that ExpRK33 leads to unstable results in spite of the step size controller, which clearly highlights the unstable nature of that integrator. \nNeither of the Lawson schemes have similar issues and the size of the stability domain on the imaginary axis gives a good indication of the relative time steps this methods can take. We also note that at later times Lawson schemes are able to take significantly larger time steps compared to exponential integrators. \nThe only exponential integrator that performs well in this regime is the method of Krogstad. Thus, the numerical results agree well with what we would expect based on the theoretical analysis. \n\n\n\\begin{figure}[h]\n\t\\centering\n\t\\begin{subfigure}[b]{0.48\\textwidth}\n%       \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1.00e-02-32x32x32x64-pert1}.pdf\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1e-02-32x32x32x64-pert1}%.pdf\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.48\\textwidth}\n%       \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1.00e-02-64x64x64x128-pert1}.pdf\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1e-02-64x64x64x128-pert1}%.pdf\n\t\\end{subfigure}\n    \\caption{Numerical simulation for a number of Lawson methods and exponential integrators for the drift-kinetic model (perturbation formulation). The upper plots show the time step size as a function of time. The lower plots show the time evolution of the electric energy. The configuration on the left uses $32 \\times 32 \\times 32 \\times 64$ grid points and the configuration on the right uses $64 \\times 64 \\times 64 \\times 128$ grid points.}\\label{fig:driftkinetic-pert1}\n\\end{figure}\n\nThe corresponding numerical results using the direct formulation are shown in Figure \\ref{fig:driftkinetic-pert0}. The situation for the direct formulation is very similar to the perturbation formulation, even if one \ncan observe that the time steps are slightly larger than in the perturbation formulation. \nOne explanation comes from the fact that the relative error computed in the perturbation \ncase involves the norm of $\\delta f$ which can be quite different from the norm \nof $f$ so that equation \\eqref{compute_dt} leads to different value of the time step \neven if the accuracy of the solution is the same.\n\n\n\\begin{figure}[h]\n\t\\centering\n\t\\begin{subfigure}[b]{0.48\\textwidth}\n%       \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1.00e-02-32x32x32x64-pert0.pdf}\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1e-02-32x32x32x64-pert0}%.pdf\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.48\\textwidth}\n%        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1.00e-02-64x64x64x128-pert0.pdf}\n         \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/driftkinetic-tol1e-02-64x64x64x128-pert0}%.pdf\n\t\\end{subfigure}\n\t\\caption{Numerical simulation for a number of Lawson methods and exponential integrators for the drift-kinetic model (direct formulation). The upper plots show the time step size as a function of time. The lower plots show the time evolution of the electric energy. The configuration on the left uses $32 \\times 32 \\times 32 \\times 64$ grid points and the configuration on the right uses $64 \\times 64 \\times 64 \\times 128$ grid points.}\\label{fig:driftkinetic-pert0}\n\\end{figure}\n\nIn Figure \\ref{fig:mass_energy}, the time history of the relative error of the total mass and of the total energy \nare displayed with the phase space discretization $64\\times 64\\times 64\\times 128$ and \nusing Lawson($RK(4,4)$) and Cox--Matthews time integrators (the perturbation formulation is used here). Since mass is a linear invariant it is preserved, up to machine precision, by the exponential integrator, see \\cite{Einkemmer:2015}. We also observe good conservation of energy even in the nonlinear phase, which confirms the excellent behavior of the methods. \n\n\\begin{figure}[h]\n\t\\centering\n        \\centering \\includegraphics[width=\\textwidth]{\\localPath/figures/diagnostics.pdf}\n    \\caption{Numerical simulation for Lawson(RK(4,4)) and the Cox--Matthews method for the drift-kinetic model (perturbation formulation). Left: time history of the error in total mass. \n\tRight: time history of the error in total energy. The configuration uses  $64 \\times 64 \\times 64 \\times 128$ grid points.}\n\t\\label{fig:mass_energy}\n\\end{figure}\n\n\nFinally, we show slices of the distribution function and the density at different times. The simulation in Figure \\ref{fig:snapshots-lrk44} is conducted with the Lawson($RK(4,4)$) scheme and the simulation in Figure \\ref{fig:snapshots-cm} with the Cox--Matthews scheme (both \nwith the perturbation formulation). In both cases the configuration of Figure \\ref{fig:driftkinetic-pert1} and the fine space resolution has been employed. As comparison, a reference solution computed with the Lawson($RK(4,4)$) scheme and a step size controller that keeps the error below $10^{-5}$ per unit time step is shown in Figure \\ref{fig:snapshots-ref}. We remark that all simulations show good agreement: the $m=5$ modes in the $\\theta$ \ndirection are recovered and after initial growth of the unstable mode,\n we can observe a shearing of the structures and the appearance of small scale structures which are typical for the nonlinear phase. \n\n\\begin{figure}[h]\n\t\\centering\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/snapshots-lawson-rk44-tol1e-2.pdf}\n    \\caption{A slices at $(z,v)=(0,0)$ of the distribution function  (on the left) and a slice at $z=0$ of the density (on the right) are shown for times $t=3000$, $4000$, and $5000$. The Lawson($RK(4,4)$) scheme, in the configuration described in section \\ref{subsec:driftkinetic-results}, with $64\\times64\\times64\\times128$ grid points is used. \\label{fig:snapshots-lrk44}}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\t\\centering\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/snapshots-coxmatthews-tol1e-2.pdf}\n    \\caption{A slices at $(z,v)=(0,0)$ of the distribution function  (on the left) and a slice at $z=0$ of the density (on the right) are shown for times $t=3000$, $4000$, and $5000$. The Cox--Matthews scheme, in the configuration described in section \\ref{subsec:driftkinetic-results}, with $64\\times64\\times64\\times128$ grid points is used. \\label{fig:snapshots-cm}}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\t\\centering\n    \\includegraphics[width=\\textwidth]{\\localPath/figures/snapshots-reference-1e-5.pdf}\n    \\caption{A slices at $(z,v)=(0,0)$ of the distribution function  (on the left) and a slice at $z=0$ of the density (on the right) are shown for times $t=3000$, $4000$, and $5000$. The Lawson($RK(4,4)$) scheme with a tolerance of $10^{-5}$ per unit step and $64\\times64\\times64\\times128$ grid points is used. \\label{fig:snapshots-ref}}\n\\end{figure}\n\n\n\n\n\\section*{Acknowledgement}\n\\addcontentsline{toc}{section}{Acknowledgement}\n\nWe would like to thank David C. Seal (U.S. Naval Academy) and Sigal Gottlieb (University of Massachusetts, Dartmouth) for the helpful discussion.\n\nThis work has been carried out within the framework of the EUROfusion Consortium and has received funding from the Euratom research and training programme 2014- 2018 and 2019-2020 under grant agreement No 633053. The views and opinions expressed herein do not necessarily reflect those of the European Commission. The work has been supported by the French Federation for Magnetic Fusion Studies (FR-FCM) and by the Austrian Science Fund (FWF): project number P 32143-N32. \n\n\\begin{subappendices}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Butcher tableaus}\n\\label{butcher}\nIn this section, we write down the different numerical methods used in this work. As in section \\ref{sec:expint},\nwe consider the following equation\n$$\n\\dot{u} = A u + F(u),\n$$\nwhere $A$ is a matrix and $F$ a general nonlinear function of $u$.\nThe Butcher tableaus for the Lawson integrators used in the main text are stated in this section.\nA Lawson method is uniquely determined by the underlying (explicit) Runge--Kutta methods and can be written as follows\n$$\n\\begin{aligned}\n        u^{(\\ell)} &= e^{c_\\ell \\Delta t A}u^n + \\Delta t\\sum_{j=1}^s a_{\\ell, j} e^{-(c_j-c_\\ell)\\Delta t A} F(u^{(j)}),  \\\\\n    u^{n+1} &= e^{\\Delta t A}u^n + \\Delta t\\sum_{j=1}^s    b_j e^{(1-c_j)\\Delta t A} F(u^{(j)}),\n  \\end{aligned}\n$$\nwhere the coefficients  $a_{\\ell, j}$ and $b_j$ are given by the Butcher tableaus.\nThe Butcher tableaus for the \\textit{RK(2,2) best}, \\textit{RK(3,3)} (the classic method of order 3),\nand \\textit{RK(4,4)} (the classic method of order 4) are shown in Table \\ref{rks}.\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}\n{c|cccc}\n$0$\\\\\n$\\frac{1}{2}$ & $\\frac{1}{2}$\\\\\n$\\frac{1}{2}$ &$0$ &$\\frac{1}{2}$ \\\\\n$1$& $0$& $0$& $1$\\\\\n\\hline\n& $\\frac{1}{6}$ &$\\frac{1}{3}$ &$\\frac{1}{3}$ &$\\frac{1}{6} $\n\\end{tabular}\n\\hspace{1cm}\n\\begin{tabular}\n{c|ccc}\n$0$\\\\\n$\\frac{1}{2}$ & $\\frac{1}{2}$\\\\\n$1 $ &$-1$ &$2$ \\\\\n\\hline\n& $\\frac{1}{6}$ &$\\frac{2}{3}$ &$\\frac{1}{6}$\n\\end{tabular}\n\\hspace{1cm}\n\\begin{tabular}\n{c|ccc}\n$0$\\\\\n$\\frac{1}{2}$ & $\\frac{1}{2}$\\\\\n$\\frac{1}{2}$              &$0$ &$\\frac{1}{2}$ \\\\\n\\hline\n& $0$ &$0$ &$1$\n\\end{tabular}\n    \\caption{Butcher tableaus for $RK(4,4)$ (left), $RK(3,3)$ (middle) and $RK(3,2)\\text{ best}$ (right).}\n\\label{rks}\n\\end{table}\n\n\nA general exponential integrator can be written as\n$$\n  \\begin{aligned}\n        u^{(\\ell)} &= u^n + \\Delta t\\sum_{j=1}^s a_{\\ell, j}(\\Delta t A)\\left( F(u^{(j)}) + A u^n \\right) \\\\\n    u^{n+1} &= u^n + \\Delta t\\sum_{j=1}^s    b_j(\\Delta t A)\\left( F(u^{(j)}) + A u^n \\right),\n  \\end{aligned}\n$$\nwhere the coefficients $a_{\\ell, j}(\\Delta t A)$ and $b_j(\\Delta t A)$ can be written as a linear combination of $\\varphi_\\ell$ and $\\varphi_{\\ell,  j}$\n(see \\cite{Hochbruck:2010})\n$$\n \\varphi_\\ell(z) = \\frac{e^{z} - \\sum_{k=0}^{\\ell-1}\\frac{1}{k!}z^k}{z^\\ell},\n$$\nand we use the notations $\\varphi_\\ell :=\\varphi_\\ell(\\Delta t A)$ and $\\varphi_{\\ell,j} := \\varphi_\\ell(c_j \\Delta t A)$. The coefficients are collected in tableau form, see Table \\ref{tab:butcher_expRK}.\n\\begin{table}[h]\n  \\centering\n  \\begin{tabular}{c|ccccc}\n    $0$    &  & $$ & $$  & \\\\\n    $c_2$    & $a_{2, 1}$ &  & $$ &  \\\\\n    $\\vdots$ & $\\vdots$ & $\\ddots$ & $$ &  \\\\\n    $c_s$    & $a_{s1}$ & $\\cdots$ & $a_{s, s-1}$ &  \\\\ \\hline\n    & $b_1$ & $\\cdots$ & $b_{s-1}$ & $b_s$\n  \\end{tabular}\n    \\caption{Butcher tableau of a general exponential integrators}\\label{tab:butcher_expRK}\n\\end{table}\nThe Butcher tableaus for the exponential integrators used in the main text are given in Tables \\ref{butcherexprk22}, \\ref{butcherK}, \\ref{butcherHO} and \\ref{butcherCM}.\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{c|cc}\n    $0$ & \\\\\n    $1$ & $\\varphi_{1,2}$ \\\\\n    \\hline\n    & $\\varphi_1 - \\varphi_2$ & $\\varphi_2$\n  \\end{tabular}\n  \\caption{Butcher tableau of ExpRK22.}\n  \\label{butcherexprk22}\n\\end{table}\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{c|cccc}\n    $0$           & \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,2}$ \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,3}-\\varphi_{2,3}$ & $\\varphi_{2,3}$ \\\\\n    $1$           & $\\varphi_{1,4}-2\\varphi_{2,4}$           & $0$          & $2\\varphi_{2,4}$ \\\\\n    \\hline\n    & $\\varphi_1-3\\varphi_2+4\\varphi_3$ & $2\\varphi_2-4\\varphi_3$ & $2\\varphi_2-4\\varphi_3$ & $-\\varphi_2+4\\varphi_3$ \\\\\n  \\end{tabular}\n  \\caption{Butcher tableau of the Krogstad method.}\n    \\label{butcherK}\n\\end{table}\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{c|ccccc}\n    $0$           & \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,2}$ \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,3}-\\varphi_{2,3}$    & $\\varphi_{2,3}$ \\\\\n    $1$           & $\\varphi_{1,4}-2\\varphi_{2,4}$              & $\\varphi_{2,4}$ & $\\varphi_{2,4}$ \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,5}-2a_{5,2}-a_{5,4}$ & $a_{5,2}$       & $a_{5,2}$       & $\\frac{1}{4}\\varphi_{2,5} - a_{5,2}$ \\\\\n    \\hline\n    & $\\varphi_1-3\\varphi_2+4\\varphi_3$ & $0$ & $0$ & $-\\varphi_2+4\\varphi_3$ & $2\\varphi_2-8\\varphi_3$ \\\\\n  \\end{tabular}\n\n    $$\\begin{aligned} a_{5,2} &= \\frac{1}{2}\\varphi_{2,5}-\\varphi_{3,4}+\\frac{1}{4}\\varphi_{2,4}-\\frac{1}{2}\\varphi_{3,5} \\\\ a_{5,4} &= \\frac{1}{4}\\varphi_{2,5}-a_{5,2} \\end{aligned}\n  $$\n  \\caption{Butcher tableau of the Hochbruck--Ostermann method.}\n  \\label{butcherHO}\n\\end{table}\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{c|cccc}\n    $0$           & \\\\\n    $\\frac{1}{2}$ & $\\frac{1}{2}\\varphi_{1,2}$ \\\\\n    $\\frac{1}{2}$ & $0$                        & $\\frac{1}{2}\\varphi_{1,3}$ \\\\\n    $1$           & $\\frac{1}{2}\\varphi_{1,3}(\\varphi_{0,3}-1)$ & $0$ & $\\varphi_{1,3}$ \\\\\n    \\hline\n    & $\\varphi_1-3\\varphi_2+4\\phi_3$ & $2\\varphi_2-4\\varphi_3$ & $2\\varphi_2-4\\varphi_3$ & $4\\varphi_3-\\varphi_2$ \\\\\n  \\end{tabular}\n  \\caption{Butcher tableau of the Cox--Matthews method.}\n    \\label{butcherCM}\n\\end{table}\n\n\n\\section{WENO5 scheme}\n\\label{app_weno}\nThe different ingredients of the WENO5 scheme used in \\eqref{vp_weno} are detailed here. First the fluxes are given by\n$$\n  \\begin{aligned}\n    {f}_{j+\\frac{1}{2}}^+   =\\ & w_0^+\\left(  \\frac{2}{6}f_{j-2} - \\frac{7}{6}f_{j-1} + \\frac{11}{6}f_{j}   \\right)\n                                +    w_1^+\\left( -\\frac{1}{6}f_{j-1} + \\frac{5}{6}f_{j}   +  \\frac{2}{6}f_{j+1} \\right) \\\\\n                                +  & w_2^+\\left(  \\frac{2}{6}f_{j}   + \\frac{5}{6}f_{j+1} -  \\frac{1}{6}f_{j+2} \\right)\n  \\end{aligned}\n$$\nand\n$$\n  \\begin{aligned}\n    {f}_{j+\\frac{1}{2}}^-   =\\ & w_2^-\\left( -\\frac{1}{6}f_{j-1} + \\frac{5}{6}f_{j}   + \\frac{2}{6}f_{j+1} \\right)\n                                +    w_1^-\\left(  \\frac{2}{6}f_{j}   + \\frac{5}{6}f_{j+1} - \\frac{1}{6}f_{j+2} \\right) \\\\\n                                +  & w_0^-\\left( \\frac{11}{6}f_{j+1} - \\frac{7}{6}f_{j+2} + \\frac{2}{6}f_{j+3} \\right).\n  \\end{aligned}\n$$\nThe weights are defined through the $\\beta$ coefficients\n$$\n  \\begin{aligned}\n    \\beta_0^+ &= \\frac{13}{12}(\\underbrace{f^+_{j-2} - 2f^+_{j-1} + f^+_{j}  }_{\\Delta x^2(f''_j + \\mathcal{O}(\\Delta x))}))^2 + \\frac{1}{4}( \\underbrace{f^+_{j-2} - 4f^+_{j-1} + 3f^+_{j}}_{2\\Delta  f'_j + \\mathcal{O}(\\Delta x^2))}  )^2 \\\\\n    \\beta_1^+ &= \\frac{13}{12}( \\underbrace{f^+_{j-1} - 2f^+_{j}   + f^+_{j+1}}_{\\Delta x^2(f''_j + \\mathcal{O}(\\Delta x^2))} )^2 + \\frac{1}{4}( \\underbrace{f^+_{j-1} -  f^+_{j+1}}_{2\\Delta x f'_j + \\mathcal{O}(\\Delta x^2))})^2 \\\\\n    \\beta_2^+ &= \\frac{13}{12}( \\underbrace{f^+_{j}   - 2f^+_{j+1} + f^+_{j+2}}_{\\Delta x^2(f''_j + \\mathcal{O}(\\Delta x))} )^2 + \\frac{1}{4}(\\underbrace{3f^+_{j}   - 4f^+_{j+1} +  f^+_{j+2}}_{-2\\Delta  f'_j + \\mathcal{O}(\\Delta x^2))})^2 \\\\\n  \\end{aligned}\n$$\nwith\n$$\n  \\begin{aligned}\n    \\beta_0^- &= \\frac{13}{12}(f^-_{j+1} - 2f^-_{j+2} + f^-_{j+3})^2 + \\frac{1}{4}(3f^-_{j+1} - 4f^-_{j+2} +  f^-_{j+3})^2 \\\\\n    \\beta_1^- &= \\frac{13}{12}(f^-_{j}   - 2f^-_{j+1} + f^-_{j+2})^2 + \\frac{1}{4}( f^-_{j}   -  f^-_{j+2})^2 \\\\\n    \\beta_2^- &= \\frac{13}{12}(f^-_{j-1} - 2f^-_{j}   + f^-_{j+1})^2 + \\frac{1}{4}( f^-_{j-1} - 4f^-_{j}   + 3f^-_{j+1})^2 \\\\\n  \\end{aligned}\n$$\nThen, the normalized weights are\n$$\n  \\alpha_i^\\pm = \\frac{\\gamma_i}{(\\varepsilon + \\beta_i^\\pm)^2},\\quad i=0,1,2,\n$$\nwhere  $\\varepsilon$ is a numerical regularization parameter set to $10^{-6}$\nand $\\gamma_0=\\frac{1}{10}$, $\\gamma_1=\\frac{6}{10}$\nand $\\gamma_2=\\frac{3}{10}$. Finally the weights are given by\n$$\n  w_i^\\pm = \\frac{\\alpha_i^\\pm}{\\sum_m \\alpha_m^\\pm},\\quad i=0,1,2.\n$$\n\\end{subappendices}\n\n", "meta": {"hexsha": "3555038982173daf0d3d8079a0272d0839107443", "size": 86698, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chaps/thesis/chap1/sections/article.tex", "max_stars_repo_name": "kivvix/draft", "max_stars_repo_head_hexsha": "33b605be27e556df061f856be8e84e5b3f49a219", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chaps/thesis/chap1/sections/article.tex", "max_issues_repo_name": "kivvix/draft", "max_issues_repo_head_hexsha": "33b605be27e556df061f856be8e84e5b3f49a219", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chaps/thesis/chap1/sections/article.tex", "max_forks_repo_name": "kivvix/draft", "max_forks_repo_head_hexsha": "33b605be27e556df061f856be8e84e5b3f49a219", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 91.2610526316, "max_line_length": 1723, "alphanum_fraction": 0.7174098595, "num_tokens": 25834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4050846961713026}}
{"text": "% NB: use pdflatex to compile NOT pdftex.  Also make sure youngtab is\n% there...\n\n% converting eps graphics to pdf with ps2pdf generates way too much\n% whitespace in the resulting pdf, so crop with pdfcrop\n% cf. http://www.cora.nwra.com/~stockwel/rgspages/pdftips/pdftips.shtml\n\n\n\n\n\\documentclass[10pt,aspectratio=169,dvipsnames]{beamer}\n\n\\usetheme[color/block=transparent]{metropolis}\n\n\\usepackage[absolute,overlay]{textpos}\n\\usepackage{booktabs}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{tikz}\n\n\n\\usepackage[scale=2]{ccicons}\n\n\\usepackage[official]{eurosym}\n\n\n%use this to add space between rows\n\\newcommand{\\ra}[1]{\\renewcommand{\\arraystretch}{#1}}\n\n\n\\newcommand{\\R}{\\mathbb{R}}\n\n\n\n\\setbeamerfont{alerted text}{series=\\bfseries}\n\\setbeamercolor{alerted text}{fg=Mahogany}\n\\setbeamercolor{background canvas}{bg=white}\n\n\n\n\\def\\l{\\lambda}\n\\def\\m{\\mu}\n\\def\\d{\\partial}\n\\def\\cL{\\mathcal{L}}\n\\def\\co2{CO${}_2$}\n\\def\\bra#1{\\left\\langle #1\\right|}\n\\def\\ket#1{\\left| #1\\right\\rangle}\n\\newcommand{\\braket}[2]{\\langle #1 | #2 \\rangle}\n\\newcommand{\\norm}[1]{\\left\\| #1 \\right\\|}\n\\def\\corr#1{\\Big\\langle #1 \\Big\\rangle}\n\\def\\corrs#1{\\langle #1 \\rangle}\n\n\n\\def\\mw{\\text{ MW}}\n\\def\\mwh{\\text{ MWh}}\n\\def\\emwh{\\text{ \\euro/MWh}}\n\n\\newcommand{\\ubar}[1]{\\text{\\b{$#1$}}}\n\n\n% for sources http://tex.stackexchange.com/questions/48473/best-way-to-give-sources-of-images-used-in-a-beamer-presentation\n\n\\setbeamercolor{framesource}{fg=gray}\n\\setbeamerfont{framesource}{size=\\tiny}\n\n\n\n\\newcommand{\\source}[1]{\\begin{textblock*}{5cm}(10.5cm,8.35cm)\n    \\begin{beamercolorbox}[ht=0.5cm,right]{framesource}\n        \\usebeamerfont{framesource}\\usebeamercolor[fg]{framesource} Source: {#1}\n    \\end{beamercolorbox}\n\\end{textblock*}}\n\n\\usepackage{hyperref}\n\n\\usepackage{tikz}\n\n\n\\usepackage[europeanresistors,americaninductors]{circuitikz}\n\n\n%\\usepackage[pdftex]{graphicx}\n\n\n\\graphicspath{{graphics/}}\n\n\\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg,.gif}\n\n\n\n\\def\\goat#1{{\\scriptsize\\color{green}{[#1]}}}\n\n\n\n\\let\\olditem\\item\n\\renewcommand{\\item}{%\n\\olditem\\vspace{5pt}}\n\n\n\\title{Energy System Modelling\\\\ Summer Semester 2020, Lecture 8}\n%\\subtitle{---}\n\\author{\n  {\\bf Dr. Tom Brown}, \\href{mailto:tom.brown@kit.edu}{tom.brown@kit.edu}, \\url{https://nworbmot.org/}\\\\\n  \\emph{Karlsruhe Institute of Technology (KIT), Institute for Automation and Applied Informatics (IAI)}\n}\n\n\\date{}\n\n\n\\titlegraphic{\n  \\vspace{0cm}\n  \\hspace{10cm}\n    \\includegraphics[trim=0 0cm 0 0cm,height=1.8cm,clip=true]{kit.png}\n\n\\vspace{5.1cm}\n\n  {\\footnotesize\n\n  Unless otherwise stated, graphics and text are Copyright \\copyright Tom Brown, 2020.\n  Graphics and text for which no other attribution are given are licensed under a\n  \\href{https://creativecommons.org/licenses/by/4.0/}{Creative Commons\n  Attribution 4.0 International Licence}. \\ccby}\n}\n\n\\begin{document}\n\n\\maketitle\n\n\n\\begin{frame}\n\n  \\frametitle{Table of Contents}\n  \\setbeamertemplate{section in toc}[sections numbered]\n  \\tableofcontents[hideallsubsections]\n\\end{frame}\n\n\n\\section{Optimisation Revision}\n\n\\begin{frame}\n  \\frametitle{Optimisation problem}\n\n\nWe have an \\alert{objective function} $f: \\R^k \\to \\R$\n\\begin{equation*}\n  \\max_{x} f(x)\n\\end{equation*}\n[$x = (x_1, \\dots x_k)$] subject to some \\alert{constraints} within $\\R^k$:\n\\begin{align*}\n  g_i(x) & = c_i \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_i \\hspace{1cm} i = 1,\\dots n \\\\\n  h_j(x) & \\leq d_j \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\m_j \\hspace{1cm} j = 1,\\dots m\n\\end{align*}\n\n$\\l_i$ and $\\m_j$ are the \\alert{KKT multipliers} we introduce for\neach constraint equation; they measure the change in the objective value of the optimal solution obtained by relaxing the constraints (for this reason they are also called \\alert{shadow prices}).\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{KKT conditions}\n\nThe \\alert{Karush-Kuhn-Tucker (KKT) conditions} are necessary conditions that an optimal solution $x^*,\\m^*,\\l^*$ always satisfies (up to some regularity conditions):\n\\begin{enumerate}\n\\item \\alert{Stationarity}: For $l = 1,\\dots k$\n  \\begin{equation*}\n  \\frac{\\d \\cL}{\\d x_l} =   \\frac{\\d f}{\\d x_l} - \\sum_i \\l_i^* \\frac{\\d g_i}{\\d x_l}  - \\sum_j \\m_j^* \\frac{\\d h_j}{\\d x_l} = 0\n  \\end{equation*}\n    \\item \\alert{Primal feasibility}:\n      \\begin{align*}\n        g_i(x^*) & = c_i \\\\\n        h_j(x^*) &\\leq d_j\n      \\end{align*}\n    \\item \\alert{Dual feasibility}: $\\m_j^* \\geq 0$\n    \\item \\alert{Complementary slackness}: $\\m_j^* (h_j(x^*) - d_j) = 0$\n\\end{enumerate}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{min/max and signs}\n\n  If the problem is a \\alert{maximisation} problem (e.g. welfare maximisation), then\n  \\alert{$\\m_j^* \\geq 0$} since $\\m_j = \\frac{\\d \\cL}{\\d d_j}$ and if we\n  increase $d_j$ in the constraint $h_j(x) \\leq d_j$, then the\n  feasible space can only get bigger. Since if $X \\subseteq X'$\n  \\begin{equation*}\n \\max_{x\\in X} f(x ) \\leq     \\max_{x\\in X'} f(x)\n  \\end{equation*}\n  then the objective value at the optimum point can only get bigger, and thus $\\m_j^* \\geq 0$. (If $d_j \\to \\infty$\n  then the constraint is no longer binding, if $d_j \\to -\\infty$ then\n  the feasible space vanishes.)\n\n  If however the problem is a \\alert{minimisation} problem (e.g. cost minimisation) then we can use\n  \\begin{equation*}\n      \\min_{x\\in X} f(x) = - \\max_{x\\in X} \\left[ -f(x)\\right]\n  \\end{equation*}\n  We can keep our definition of the Lagrangian and almost all the KKT\n  conditions, but we have a change of sign \\alert{$\\m_j^* \\leq 0$}, since\n  \\begin{equation*}\n   \\min_{x\\in X} f(x ) \\geq     \\min_{x\\in X'} f(x)\n  \\end{equation*}\n  The $\\l_i^*$ also change sign.\n\n\\end{frame}\n\n\n\n\n\\section{Welfare maximisation revision}\n\n\n\n\\begin{frame}{KKT and Welfare Maximisation 1/2}\n\n  Apply KKT now to maximisation of total economic welfare:\n  \\begin{align*}\n    \\max_{\\{d_b\\}, \\{g_s\\}} f(\\{d_b\\}, \\{g_s\\}) = \\left[ \\sum_b U_b (d_b)  -  \\sum_s C_s (g_s) \\right]\n  \\end{align*}\n  subject to the balance constraint:\n  \\begin{align*}\n    g(\\{d_b\\}, \\{g_s\\}) = \\sum_b d_b -  \\sum_s g_s  = 0 \\hspace{1cm} \\leftrightarrow \\hspace{1cm} \\l\n  \\end{align*}\n  and any other constraints (e.g. limits on generator capacity, etc.).\n\n  Our optimisation variables are $\\{x\\} = \\{d_b\\} \\cup \\{g_s\\}$.\n\n  We get from KKT stationarity at the optimal point:\n  \\begin{align*}\n    0 & =   \\frac{\\d f}{\\d d_b} - \\sum_b \\l^* \\frac{\\d g}{\\d d_b} = U_b'(d_b^*) - \\l^* = 0 \\\\\n    0 & =   \\frac{\\d f}{\\d g_s} - \\sum_s \\l^* \\frac{\\d g}{\\d g_s} = -C_s'(g_s^*) + \\l^* = 0\n  \\end{align*}\n\n\n\\end{frame}\n\n\n\n\n\n\\begin{frame}{KKT and Welfare Maximisation 2/2}\n\n  So at the optimal point of maximal total economic welfare we get the\n  same result as if everyone maximises their own welfare separately based on the price $\\l^*$:\n  \\begin{align*}\n U_b'(d_b^*) =  \\l^*  \\\\\n C_s'(g_s^*) = \\l^*\n  \\end{align*}\n\n  This is the CENTRAL result of microeconomics.\n\n  If we have further inequality constraints that are binding (e.g. capacity constraints), then\n  these equations will receive additions with $\\m_i^* > 0$.\n\n\n\\end{frame}\n\n\n\n\n\\section{Optimise Single Node with Linear Generation Costs and Demand Utility}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplified world: linear generation costs, linear demand utility}\n\n  We will now turn to a simpler world: all the generator cost\n  functions are linear\n  \\begin{align*}\n    C_s(g_s) = o_s g_s\n  \\end{align*}\n  and each generator has limited output $0 \\leq g_s \\leq G_s$. The marginal cost function is a constant $C_s'(g_s) = o_s$.\n\n\n  The quantity $G_s$ and marginal cost $o_s$ define a \\alert{supply offer}.\n\n\n  All the consumer utility functions are also linear\n  \\begin{align*}\n    U_b(d_b)  = v_b d_b\n  \\end{align*}\n  and each consumer has limited consumption $0 \\leq d_b \\leq D_b$. The marginal utility function is a constant $U_b'(d_b)  = v_b$.\n\n\n  The quantity $D_b$ and marginal utility $v_b$ define a \\alert{demand bid}.\n\n\n\\end{frame}\n\n\n\n\\begin{frame}{Supply-demand linear example: generator offers}\n\n  Example from Kirschen and Strbac pages 56-58.\n\n  The following generators offer into the market for the hour between 0900 and 1000 on 20th April 2016:\n  \\ra{1.1}\n  \\begin{table}[!t]\n    \\begin{tabular}{lrr}\n      \\toprule\n      Company & Quantity [MW] &  Marginal cost [\\$/MWh]\\\\\n      \\midrule\n      Red & 200 & 12 \\\\\n      Red & 50 & 15 \\\\\n      Red & 150 & 20 \\\\\n      Green & 150 & 16 \\\\\n      Green & 50 & 17 \\\\\n      Blue & 100 & 13 \\\\\n      Blue & 50 & 18 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\n\n\\end{frame}\n\n\n\n\\begin{frame}{Supply-demand linear example: consumer bids}\n\n  The following consumers make bids for the same period:\n  \\ra{1.1}\n  \\begin{table}[!t]\n    \\begin{tabular}{lrr}\n      \\toprule\n      Company & Quantity [MW] &  Marginal utility [\\$/MWh]\\\\\n      \\midrule\n      Yellow & 50 & 13 \\\\\n      Yellow & 100 & 23 \\\\\n      Purple & 50 & 11 \\\\\n      Purple & 150 & 22 \\\\\n      Orange & 50 & 10 \\\\\n      Orange & 200 & 25 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\n\n\\end{frame}\n\n\n\n\n\\begin{frame}{Supply-demand example: Curve}\n\n  If the bids and offers are stacked up in order, the supply and\n  demand curves meet with a demand of 450~MW at a system marginal\n  price of $\\l^* = 16$~\\$/MWh.\n\n  \\centering\n\n\n  \\includegraphics[width=10cm]{supply-bid-example}\n\n\n  \\source{Kirschen \\& Strbac}\n\n\n\n\\end{frame}\n\n\n\n\n\n\\begin{frame}{Supply-demand example: Revenue and Expenses}\n\n  Dispatch and revenue/expense of each company:\n  \\ra{1.1}\n  \\begin{table}[!t]\n    \\begin{tabular}{l|rr|rr}\n      \\toprule\n      Company & Production& Consumption & Revenue& Expense\\\\\n       & [MWh] & [MWh] & [\\$] & [\\$] \\\\\n      \\midrule\n      Red & 250 &  & 4000 & \\\\\n      Blue & 100 & & 1600 & \\\\\n      Green & 100 & & 1600 & \\\\\n      Orange && 200 && 3200 \\\\\n      Yellow && 100 && 1600 \\\\\n      Purple && 150 && 2400 \\\\\n      \\midrule\n      Total & 450 & 450 & 7200 & 7200 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\n\n\\end{frame}\n\n\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplified world: linear generation costs, single inelastic demand}\n\n  For the analysis of the KKT equations, we will simplify even further.\n\n  We consider a single demand bid of volume $D$ so that the demand does not respond to price changes (i.e. the demand is \\alert{inelastic}) up to a very high marginal utility $v >> o_s\\,\\, \\forall s$, i.e.\n  \\begin{align*}\n    U(d) = vd\n  \\end{align*}\n  for $d\\leq D$.\n\n  $v$ is sometimes called the \\alert{Value Of Lost Load (VOLL)}.\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplify representation of consumers and generators}\n\n  In this case we get for our welfare maximisation:\n  \\begin{align*}\n    \\max_{d, \\{g_s\\} }\\left[ vd  -  \\sum_s o_s g_s \\right]\n  \\end{align*}\n  subject to:\n  \\begin{align*}\n    d -  \\sum_s g_s   = 0 \\hspace{1cm} & \\leftrightarrow \\hspace{1cm} \\l \\\\\n    d  \\leq D  \\hspace{1cm}  & \\leftrightarrow \\hspace{1cm} \\m \\\\\n        g_s   \\leq  G_s  \\hspace{1cm}& \\leftrightarrow\\hspace{1cm} \\bar{\\m}_s \\\\\n    - g_s   \\leq  0   \\hspace{1cm}& \\leftrightarrow\\hspace{1cm} \\ubar{\\m}_s\n  \\end{align*}\n\n\\end{frame}\n\n\n\n\\begin{frame}{Simplest example: one generator type, inelastic demand}\n\n  Suppose all generators have the same marginal cost $o$ and we\n  represent their total dispatch by $g$ and total capacity by $G$\n  \\begin{align*}\n    \\max_{d, g }\\left[ vd  -  og\\right]\n  \\end{align*}\n  such that:\n  \\begin{align*}\n    d - g & = 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l \\\\\n    d & \\leq D  \\hspace{1cm} \\leftrightarrow \\hspace{1cm} \\m \\\\\n    g  & \\leq  G  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m} \\\\\n    - g  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}\n  \\end{align*}\n\n\\end{frame}\n\n\n\\begin{frame}{Simplest example: one generator type, inelastic demand}\n\n  If $D < G$ then since $v >> o$, it will be always be welfare-maximising to dispatch to satisfy the load, i.e.\n  \\begin{equation*}\n    g^* = d^* = D\n  \\end{equation*}\n  If the demand is non-zero then since $g^* > 0$ by complementarity we\n  have $\\ubar{\\m}^* = 0$. Since $D < G$ then $g^* < G$ and\n  by complementarity we have $\\bar{\\m}^* = 0$. To compute $\\l^*$ we use stationarity:\n  \\begin{align*}\n    0 & = \\frac{\\d \\cL}{\\d g } =   \\frac{\\d f}{\\d g} - \\sum_i \\l_i^* \\frac{\\d g_i}{\\d g}  - \\sum_j \\m_j^* \\frac{\\d h_j}{\\d g} = - o + \\l^* - \\bar{\\m}^* + \\ubar{\\m}^*\n  \\end{align*}\n  Thus $\\l^* = o$, which is the cost per unit of supplying extra demand. The \\alert{generator sets the price}. There is no generator profit and a large consumer surplus.\n\n  For the load $\\m^*$ can be non-zero because $d^*=D$:\n    \\begin{align*}\n      0 & = \\frac{\\d \\cL}{\\d d} =   \\frac{\\d f}{\\d d} - \\sum_i \\l_i^* \\frac{\\d g_i}{\\d d}  - \\sum_j \\m_j^* \\frac{\\d h_j}{\\d d} = v - \\l^* - \\m^*\n    \\end{align*}\n    $\\m^* = v - \\l^*$ is the marginal benefit of each increase in demand.\n\\end{frame}\n\n\n\n\\begin{frame}{Simplest example: one generator type, inelastic demand}\n\n  For the case $D < G$:\n\n  \\includegraphics[width=12cm]{supply-bigger-demand-single.pdf}\n\n\\end{frame}\n\n\\begin{frame}{Simplest example: one generator type, inelastic demand}\n\n  If $D > G$ then the generator will dispatch up to its maximum capacity\n  \\begin{equation*}\n    g^* = d^* = G\n  \\end{equation*}\n  For its lower limit we have $\\ubar{\\m}^* = 0$. From stationarity:\n  \\begin{align*}\n    0 & = \\frac{\\d \\cL}{\\d g } =   \\frac{\\d f}{\\d g} - \\sum_i \\l_i^* \\frac{\\d g_i}{\\d g}  - \\sum_j \\m_j^* \\frac{\\d h_j}{\\d g} = - o + \\l^* - \\bar{\\m}^* + \\ubar{\\m}^*\n  \\end{align*}\n  Thus $\\l^* = o + \\bar{\\m}^*$. To find $\\l^*$ we have to look at the demand:\n    \\begin{align*}\n      0 & = \\frac{\\d \\cL}{\\d d} =   \\frac{\\d f}{\\d d} - \\sum_i \\l_i^* \\frac{\\d g_i}{\\d d}  - \\sum_j \\m_j^* \\frac{\\d h_j}{\\d d} = v - \\l^* - \\m^*\n    \\end{align*}\n  Since $d^* < D$, $\\m^* = 0$, $\\l^* = v$ and thus $\\bar{\\m}^* = v-o$, which is the marginal benefit of increasing the generator capacity $G$. The \\alert{demand sets the price}. There is no consumer surplus and the generator makes a large profit.\n\n\\end{frame}\n\n\n\\begin{frame}{Simplest example: one generator type, inelastic demand}\n\n  For the case $D > G$:\n\n  \\includegraphics[width=12cm]{demand-bigger-supply.pdf}\n\n\\end{frame}\n\n\n\\begin{frame}{Next simplest example: several generators, fixed demand}\n\n  Suppose we have several generators with dispatch $g_s$ and strictly ordered\n  operating costs $o_s$ such that $o_s < o_{s+1}$. We now maximise\n  \\begin{align*}\n    \\max_{\\{d, g_s\\}}  \\left[ vd  -  \\sum_s o_s g_s \\right]\n  \\end{align*}\n  such that\n  \\begin{align*}\n    d -  \\sum_s g_s  & = 0 \\hspace{1cm} \\leftrightarrow \\hspace{1cm} \\l \\\\\n    d & \\leq D  \\hspace{1cm} \\leftrightarrow \\hspace{1cm} \\m \\\\\n        g_s  & \\leq  G_s  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_s \\\\\n    - g_s  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_s\n  \\end{align*}\n\n\n\\end{frame}\n\n\\begin{frame}{Next simplest example: several generators, fixed demand}\n\n  Stationarity gives us for each generator $g_s$:\n  \\begin{align*}\n    0  = \\frac{\\d \\cL}{\\d g_s} = -o_s + \\l^* - \\bar{\\m}^*_s + \\ubar{\\m}^*_s\n  \\end{align*}\n  and from complementarity we get\n  \\begin{align*}\n    \\bar{\\m}_s(g_s^* - G_s)  = 0 \\hspace{2cm}    \\ubar{\\m}_sg_s^*  = 0\n  \\end{align*}\n  We can see by inspection that we will dispatch the cheapest\n  generation first. Suppose that we have enough generation for the\n  demand, i.e. $D < \\sum_s G_s$. [If $D > \\sum_s G_s$ we have the same\n    situation as for a single generator, i.e. $\\l^* = v$, so that the demand sets the price.]\n\n  Find the generator $m$ on the margin where the supply curve\n  intersects with the demand $D$, i.e. the $m$ where $\\sum_{s=1}^{m-1}\n  G_s < D < \\sum_{s=1}^{m} G_s$.\n\n  For $s \\leq m-1$ we have $g_s^* = G_s$, $\\ubar{\\m}^*_s = 0$,\n  $\\bar{\\m}^*_s =  \\l^* - o_s$.\n\n  For $s = m$ we have $g_m^* = D - \\sum_{s=1}^{m-1} G_s$ to cover\n  what's left of the demand. Since $0 < g_m^* < G_m$ we have\n  $\\ubar{\\m}^*_m = \\bar{\\m}^*_m = 0$ and thus $\\l^* = o_m$.\n\n\n\\end{frame}\n\n\n\n\\begin{frame}{Next simplest example: several generators, fixed demand}\n\n  Specific example of two generators with $G_1 = 300$~MW, $G_2 =\n  400$~MW, $o_1 = 10$~\\euro/MWh, $o_2 = 30$~\\euro/MWh and $D = 500$~MW.\n\n  In this case $m=2$, $g_1^* = G_1 = 300$~MW, $g_2^* = d - G_1 = 200$~MW,\n  $\\l^* = o_2$, $\\ubar{\\m}_i = 0$, $\\bar{\\m}_2 = 0$ and $\\bar{\\m}_1 =\n  o_2 - o_1$.\n\n  \\centering\n  \\includegraphics[width=8cm]{supply-demand-two.pdf}\n\n\n\n\n\\end{frame}\n\n\n\n\n\n\\begin{frame}{From welfare maximisation to cost minimisation}\n\n  For the case $D > \\sum_s G_s$ we can instead imagine that the demand\n  is rigidly fixed to $D$ and that instead we have a dummy generator\n  with dispatch $g_d = D-\\sum_s G_s$ that represents \\alert{load shedding}.\n  In this case we can substitute $d = D - g_d$ to get\n  \\begin{align*}\n    \\max_{\\{g_d, g_s\\}}  \\left[ vD - vg_d  -  \\sum_s o_s g_s \\right]\n  \\end{align*}\n  such that\n  \\begin{align*}\n    D - g_d -  \\sum_s g_s  & = 0 \\hspace{1cm} \\leftrightarrow \\hspace{1cm} \\l \\\\\n        g_s  & \\leq  G_s  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_s \\\\\n    - g_s  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_s\n  \\end{align*}\n\n  Since $vD$ is a constant, we can use\n      $\\max_{x\\in X} \\left[ -f(x)\\right] = - \\min_{x\\in X} f(x)$\n  to recast this as a minimisation of the total generator costs,\n  absorbing $g_d$ into the set $\\{g_s\\}$. The constant $vD$ is dropped.\n\n\\end{frame}\n\n\n\\begin{frame}{From welfare maximisation to cost minimisation}\n\n We have  turned the maximisation of total welfare into \\alert{cost minimisation}:\n  \\begin{align*}\n    \\min_{\\{g_s\\}}  \\sum_s o_s g_s\n  \\end{align*}\n  such that:\n  \\begin{align*}\n    \\sum_s g_s - d & = 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l \\\\\n        g_s  & \\leq  G_s  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_s \\\\\n    - g_s  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_s\n  \\end{align*}\n\n  The most expensive generator has $o_s = v$ and $G_s = \\infty$ and\n  represents \\alert{load shedding}.\n\n  We've replaced the symbol $D$  with $d$ for simplicity going forward ($d$ is now a constant).\n\n\n\n  NB: Because the signs of the KKT multipliers change when we go from\n  maximisation to minimisation, we've also changed the sign of the\n  balance constraint to keep the marginal price $\\l$ positive.\n\\end{frame}\n\n\n\\section{Optimise nodes in a network}\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Welfare optimisation for several nodes in a network}\n\n  Now let's suppose we have several nodes $i$ with different loads and\n  different generators, with flows $f_\\ell$ in the network lines $\\ell$.\n\n  Now we have additional optimisation variables $f_\\ell$ AND\n  additional constraints for welfare maximisation:\n  \\begin{align*}\n    \\max_{\\{d_{i,b}\\},\\{g_{i,s}\\},\\{f_\\ell\\}}\\left[\\sum_{i,b} U_{i,b}(d_{i,b}) - \\sum_{i,s} C_{i,s} (g_{i,s}) \\right]\n  \\end{align*}\n  such that demand is met either by generation or by the network at each node $i$\n  \\begin{align*}\n    \\sum_{b} d_{i,b} - \\sum_{s} g_{i,s} +  \\sum_\\ell K_{i\\ell}f_\\ell  = 0 \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_i\n  \\end{align*}\n  Note there is now a \\alert{market price for each node}. As before, generator constraints are satisified\n    \\begin{align*}\n        g_{i,s}  & \\leq  G_{i,s}  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_{i,s} \\\\\n    - g_{i,s}  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_{i,s}\n  \\end{align*}\n\n\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Linear cost minimisation at several nodes in a network}\n\n  For cost minimisation we have a fixed load $d_i$ at each node, and\n  absorb load-shedding above a value $v$ into a dummy generator.\n\n  Now we minimise over $f_\\ell$ and $g_{i,s}$ for the case of linear cost functions:\n  \\begin{align*}\n    \\min_{\\{g_{i,s}\\},\\{f_\\ell\\}}  \\sum_{i,s} o_{i,s} g_{i,s}\n  \\end{align*}\n  such that demand is met either by generation or by the network at each node $i$\n  \\begin{align*}\n    \\sum_{s} g_{i,s} - d_i = \\sum_\\ell K_{i\\ell}f_\\ell  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_i\n  \\end{align*}\n  and generator constraints are satisified\n    \\begin{align*}\n        g_{i,s}  & \\leq  G_{i,s}  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_{i,s} \\\\\n    - g_{i,s}  & \\leq  0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_{i,s}\n  \\end{align*}\n\n\n\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Several generators at different nodes in a network}\n\n  In addition we have constraints on the line flows.\n\n  First, they have to satisfy Kirchoff's Voltage Law around each closed cycle $c$:\n  \\begin{align*}\n    \\sum_{c} C_{\\ell c} x_\\ell f_\\ell = 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_c\n  \\end{align*}\n  and in addition the flows cannot overload the thermal limits, $|f_\\ell| \\leq F_\\ell$\n  \\begin{align*}\n    f_\\ell \\leq F_\\ell  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_\\ell \\\\\n        - f_\\ell \\leq F_\\ell  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_\\ell\n  \\end{align*}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplest example: two nodes connected by a single line}\n\n  At node 1 we have demand of $d_1 = 100$~MW and a generator with\n  costs $o_1 = 10$~\\euro/MWh and a capacity of $G_1 = 300$~MW.\n\n  At node 2 we have demand of $d_2 = 100$~MW and a generator with\n  costs $o_2 = 20$~\\euro/MWh and a capacity of $G_2 = 300$~MW.\n\n  What happens if the capacity of the line connecting them is $F = 0$?\n\n  What about $F = 50$~MW?\n\n  What about $F = \\infty$?\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplest example: two nodes connected by a single line}\n\n\\centering\n\\begin{circuitikz}\n  \\draw [ultra thick] (1,13) node[anchor=south]{1} -- (4,13);\n  \\draw(2.5,13) |- +(0,0.5) to [short,i^=$f$] +(5,0.5) |- +(0,-0.5);\n  \\draw [ultra thick] (6,13) node[anchor=south]{2} -- (9,13);\n  \\draw (1.5,13) -- +(0,-0.5) node[sground]{};\n  \\draw (3,12) node[vsourcesinshape, rotate=270](V2){}\n  (V2.left) -- +(0,0.6);\n  \\draw (1.5,11) node{$d_1$};\n  \\draw (3,11) node{$g_{1}$};\n  \\draw (6.5,13) -- +(0,-0.5) node[sground]{};\n  \\draw (8,12) node[vsourcesinshape, rotate=270](V2){}\n  (V2.left) -- +(0,0.6);\n  \\draw (6.5,11) node{$d_2$};\n  \\draw (8,11) node{$g_{2}$};\n\n\\end{circuitikz}\n\n\n\\centering\n\\begin{columns}[T]\n  \\begin{column}{5cm}\n\n    \\centering\n\n $g_1 - d_1 = f \\quad \\leftrightarrow \\quad \\l_1$\n\n    \\hspace{1cm}\n\n    $d_1 =$ 100~MW\n\n    $G_1 =$ 300~MW\n\n    $o_1 = 10$~\\euro/MWh\n\n  \\end{column}\n  \\begin{column}{5cm}\n\n    \\centering\n    $g_2 - d_2 =  -f   \\quad \\leftrightarrow \\quad \\l_2$\n\n    \\hspace{1cm}\n\n    $d_2 =$ 100~MW\n\n    $G_2 =$ 300~MW\n\n    $o_2 = 20$~\\euro/MWh\n\n  \\end{column}\n\\end{columns}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Simplest example: two nodes connected by a single line}\n\n  Out optimisation problem has objective function:\n  \\begin{equation*}\n    \\min_{g_1,g_2,f}  \\left[o_1 g_1 + o_2 g_2 \\right]\n  \\end{equation*}\n  subject to the following constraints:\n  \\begin{align*}\n    g_1 - d_1  = f \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_1 \\\\\n    g_2 - d_2  = -f \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_2 \\\\\n  g_1 \\leq G_1  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_1 \\\\\n    - g_1 \\leq 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_1  \\\\\n  g_2 \\leq G_2  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_2  \\\\\n  - g_2 \\leq 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_2  \\\\\n    f \\leq F  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}  \\\\\n    - f \\leq F  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}\n\\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Two nodes: Case $F = 0$ }\n\n  For the case $F = 0$ the nodes are like two separated islands, $f^* = 0$.\n\n  The generator on each island provides the demand separately, so:\n  \\begin{equation*}\n    g_1^* = d_1  \\hspace{2cm} \\textrm{and} \\hspace{2cm} g_2^* = d_2\n  \\end{equation*}\n\n  Neither generator has any binding constraints, since in each case the demand (100~MW) is less than the generator capacity (300~MW), so\n  \\begin{equation*}\n    \\bar{\\m}_1^* = \\ubar{\\m}_1^* =     \\bar{\\m}_2^* = \\ubar{\\m}_2^* = 0\n  \\end{equation*}\n\n  From stationarity for each site we get\n  \\begin{equation*}\n    0 = \\frac{\\d \\cL}{\\d g_{i}} = o_i - \\l_i^*  -  \\bar{\\m}_i^* + \\ubar{\\m}_i^*\n  \\end{equation*}\n\n  Thus we have at each site $\\l_i^* = o_i$, as if we had optimised the nodes separately.\n\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Two nodes: Case $F =$ 50~MW }\n\n  For the case $F = $50~MW the cheaper node 1 will export to the more\n  expensive node 2 as much as the restricted capacity $F$ allows:\n  \\begin{equation*}\n    f^* = F = 50\\textrm{ MW}\n  \\end{equation*}\n  Generator 1 covers 50~MW of the demand from node 2:\n  \\begin{equation*}\n    g_1^* = d_1+f^* = 150\\textrm{ MW}  \\hspace{2cm} \\textrm{and} \\hspace{2cm} g_2^* = d_2 - f^* = 50\\textrm{ MW}\n  \\end{equation*}\n  Neither generator has any binding constraints, so\n  \\begin{equation*}\n    \\bar{\\m}_1^* = \\ubar{\\m}_1^* =     \\bar{\\m}_2^* = \\ubar{\\m}_2^* = 0\n  \\end{equation*}\n  and thus we have again different prices at each $\\l_i^* = o_i$. For the flow:\n  \\begin{equation*}\n    0 = \\frac{\\d \\cL}{\\d f} = 0 +  \\l_1^* - \\l_2^*  -  \\bar{\\m}^* + \\ubar{\\m}^*\n  \\end{equation*}\n  Only the upper limit is binding, so we get $\\ubar{\\m}^* = 0$ and\n    $\\bar{\\m}^* = \\l_1^* - \\l_2^* = o_1 - o_2 = -10 $ \\euro/MWh.\n\n$\\bar{\\m}^*$ is the cost reduction if we expand the transmission capacity $F$ by $\\varepsilon$, allowing us to substitute some of the expensive generation at node 2 with cheap generation from node 1.\n\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Two nodes: Case $F = \\infty$ }\n\n  For the case $F = \\infty$ we have unrestricted capacity, so it is\n  like merging the two nodes to one node. Now all the demand is\n  covered by the cheapest node:\n  \\begin{equation*}\n    f^* = d_2 = 100\\textrm{ MW}\n  \\end{equation*}\n  Generator 1 covers all the demand:\n  \\begin{equation*}\n    g_1^* = d_1+d_2  = 200\\textrm{ MW} \\hspace{2cm} \\textrm{and} \\hspace{2cm} g_2^* = 0\n  \\end{equation*}\n  Only generator 2 has a non-zero KKT multiplier, so at node 1 we have\n  $\\l_1^* =o_1$ and at node 2 we have:\n  \\begin{equation*}\n   \\ubar{\\m}_2^* = \\l_2^* - o_2\n  \\end{equation*}\n  From KKT for the flow $f$ we have no constraints so $\\bar{\\m}^* = \\ubar{\\m}^* = 0$ and from stationarity\n  \\begin{equation*}\n    0 = \\frac{\\d \\cL}{\\d f} = 0 +  \\l_1^* - \\l_2^*  -  \\bar{\\m}^* + \\ubar{\\m}^*\n  \\end{equation*}\n  i.e. $\\l_1^* = \\l_2^*$. We have price equalisation, as if it were a single node.\n\n\\end{frame}\n\n\n\n\\begin{frame}{Two node: demand pagements versus generation revenue}\n\n  Now let's compare for our examples what each demand pays $\\l_i^*d_i$ and what each generator receives as revenue $\\l_i^*g_i^*$ from each market.\n  \\ra{1.1}\n  \\begin{table}[!t]\n    \\begin{tabular}{rrrrrrrrr}\n      \\toprule\n      Case & $\\l_1^*$  & $\\l_2^*$ & $\\l_1^*d_1$ & $\\l_2^*d_2$ & $\\sum_i \\l_i^*d_i$ & $\\l_1^*g_1^*$  & $\\l_2^*g_2^*$ & $\\sum_i \\l_i^*g_i^*$ \\\\\n       & [\\euro/MWh] &  [\\euro/MWh] & [\\euro/h] & [\\euro/h] & [\\euro/h] & [\\euro/h] & [\\euro/h] & [\\euro/h] \\\\\n      \\midrule\n      $F = 0$ & 10 & 20 & 1000 & 2000 & 3000 & 1000 & 2000 & 3000 \\\\\n      $F = 50$ & 10 & 20 & 1000 & 2000 & 3000 & 1500 & 1000 & 2500 \\\\\n      $F = \\infty$ & 10 & 10 & 1000 & 1000 & 2000 & 2000 & 0 & 2000 \\\\\n%      $F = 50$ & 3000 & 2500 & 10 & 50 & 500\n%      $F = \\infty$ & 2000 & 2000 & 0 & 100 & 0  \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\n  NB: In the case with $F=50$, total demand payments are 3000~\\euro/h, whereas the generators are only receiving 2500~\\euro/h.\n\n  Where is the missing money (500~\\euro/h) going?\n\n  Answer: to the network operator for service of doing arbitrage, buying low and selling high.\n\n\\end{frame}\n\n\n\n\n\\begin{frame}{Congestion rent}\n\nDue to the congestion of the transmission line, the marginal cost of producing electricity can be different at node 1 and node 2. The competitive price at node 2 is higher than at node 1 -- this corresponds to \\alert{locational marginal pricing}, or \\alert{nodal pricing}.\n\nSince consumers pay and generators get paid the price in their local market, in case of congestion there is a difference between the total payment of consumers and the total revenue of producers -- this is the \\alert{merchandising surplus} or \\alert{congestion rent}, collected by the network operator. For each line it is given by the price difference in both regions times the amount of power flow between them:\n\\begin{align*}\n\\text{Congestion rent =}\\:\\Delta \\lambda\\times f\n\\end{align*}\n\n\n\\end{frame}\n\n\n\\begin{frame}{Congestion rent: Two node example}\n\n  Returning to our two node example:\n  \\ra{1.1}\n  \\begin{table}[!t]\n    \\begin{tabular}{rrrrrr}\n      \\toprule\n      Case & Demand pays & Generator gets & $\\l_2^* - \\l_1^*$ & flow $f$ & Cong. rent \\\\\n       & [\\euro/h] & [\\euro/h] & [\\euro/MWh] & [MW] & [\\euro/h] \\\\\n      \\midrule\n      $F = 0$ & 3000 & 3000 & 10 & 0 & 0 \\\\\n      $F = 50$ & 3000 & 2500 & 10 & 50 & 500 \\\\\n      $F = \\infty$ & 2000 & 2000 & 0 & 100 & 0 \\\\\n      \\bottomrule\n    \\end{tabular}\n  \\end{table}\n\nTo get a congestion rent, we need congestion to cause a price\ndifference between the nodes, as well as a non-zero flow between the\nnodes.\n\n\\end{frame}\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Congestion rent}\n\n  In this example we saw that the sum of what consumers pay does not always equal the sum of generator revenue.\n\n  In fact if we take the balance constraint and sum it weighted by the market price at each node we find\n  \\begin{align*}\n    \\sum_i \\l_i^* d_i -   \\sum_i \\l_i^* \\sum_{s} g^*_{i,s} = -\\sum_i \\l_i^* \\sum_\\ell K_{i\\ell}f^*_\\ell\n  \\end{align*}\n\n  The quantity for each $\\ell$\n  \\begin{equation*}\n    -f_\\ell^*\\sum_i K_{i\\ell} \\l_i^* = f_\\ell (\\l_{\\textrm{end}}^* - \\l_{\\textrm{start}}^*)\n  \\end{equation*}\n  is called the \\alert{congestion rent} and is the money the network\n  operator receives for transferring power from a low price node (start)\n  to a high price node (end), `buy it low, sell it high'.\n\n  It is zero if: a) the flow is zero or b) the price difference is zero.\n\n\\end{frame}\n\n\n\n\n\n\\section{The European Market}\n\n\n\\begin{frame}\n  \\frametitle{Existing bidding zones}\n\n\n\n\\begin{columns}[T]\n  \\begin{column}{5cm}\n\n    \\includegraphics[width=5.8cm]{european_bidding_zones.png}\n  \\end{column}\n\n  \\begin{column}{8cm}\n\n    \\begin{itemize}\n    \\item Bids for German electricity take place in a \\alert{giant bidding zone} encompassing both Germany and Luxembourg (Austria was separated from the German bidding zone in October 2018)\n    \\item This means that transmission constraints are only visible to the market at the \\alert{borders} to the other national zones\n    \\item Internal transmission constraints are \\alert{ignored} - market bids are handled as if they do not exist\n    \\item Only KCL enforced on most borders - KVL much harder\n    \\end{itemize}\n\n\\end{column}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{The Problem}\n\n  Renewables are not always located near demand centres, as in this example from Germany.\n\n\n\n\\begin{columns}[T]\n  \\begin{column}{6cm}\n\\includegraphics[width=6cm]{scigrid-load}\n  \\end{column}\n\n  \\begin{column}{6cm}\n      % left bottom right top\n  \\includegraphics[trim=0 0cm 0 1cm,width=6.3cm,clip=true]{scigrid-wind}\n\n\n\\end{column}\n\\end{columns}\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{The Problem}\n\n\n\n\\begin{columns}[T]\n  \\begin{column}{5.5cm}\n        \\vspace{.5cm}\n\\includegraphics[width=6cm]{scigrid-loading}\n  \\end{column}\n\n  \\begin{column}{6cm}\n    \\begin{itemize}\n      \\item This leads to \\alert{overloaded lines} in the middle of Germany, which\n   cannot transport all the wind energy from North Germany to the load\n   in South Germany\n\n   \\item It also overloads lines in neighbouring countries due to\n     \\alert{loop flows} (unplanned physical flows `according to least\n     resistance' which do not correspond to traded flows)\n\n     \\item It also \\alert{blocks imports and exports} with\n       neighbouring countries, e.g. Denmark\n\n    \\end{itemize}\n\n\\end{column}\n\\end{columns}\n\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Solution 1: Redispatch after energy market clearing}\n\n  These problems are \\alert{not visible} in the day-ahead electricity\n  market, which treats the whole of Germany and Austria as a single\n  bidding zone. It dispatches wind in North Germany as if there was no\n  internal congestion...\n\n  To ensure that the physical limits of transmission are not exceeded,\n  the network operator must \\alert{`re-dispatch'} power stations and\n  \\alert{curtail} (Einspeisemanagement) renewables to restore order.\n  This is \\alert{costly} (0.8 redispatch + 0.6 RE-compensation = 1.4 billion\n  EUR in 2017 - although exceptional circumstances in 1st quarter) and\n  results in \\alert{lost CO$_2$-free generation} (5.5 TWh curtailment of RE\n  and CHP in 2017).\n\n  \\alert{International redispatch} is sometimes also required\n  (Multilateral Remedial Actions = MRA).\n\n  Furthermore, there are \\alert{no market incentives} to reinforce the North-South\n  grid, to locate more power stations in South Germany or to\n  build storage / P2X in North Germany.\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Solution 2: Smaller bidding zones to ``see'' congested boundaries}\n\n\n\\begin{columns}[T]\n  \\begin{column}{5cm}\n\\includegraphics[width=6cm]{nordel.png}\n  \\end{column}\n  \\begin{column}{5cm}\n    \\begin{itemize}\n      \\item In Scandinavia they have solved this by introducing \\alert{smaller bidding zones}\n      \\item Now congestion at the boundaries between zones is taken\n        into account in the \\alert{implicit auctions} of the market\n      \\item This is also done in Italy (again, a long country),\n          where prices for small consumers are \\alert{uniformised} for fairness\n    \\end{itemize}\n\n\\end{column}\n\\end{columns}\n\n\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Solution 3: Nodal pricing}\n\n\n\\begin{columns}[T]\n  \\begin{column}{6cm}\n\n    \\vspace{.5cm}\n\\includegraphics[width=7cm]{lmp.png}\n  \\end{column}\n  \\begin{column}{5cm}\n    \\begin{itemize}\n    \\item The ultimate solution, as used in the US and other markets,\n      is \\alert{nodal pricing}, which exposes all transmission congestion\n    \\item Considered too complex and subject to market power to be\n      used in Europe, but this is questionable...\n      \\item Here we see clearly why many argue for a North-South\n        German split\n    \\end{itemize}\n\n\\end{column}\n\\end{columns}\n\n\n\n\\end{frame}\n\n\n\n\n\\begin{frame}\n  \\frametitle{First step: Split Germany North-South}\n\n\n\\begin{columns}[T]\n  \\begin{column}{5cm}\n    \\vspace{.5cm}\n\\includegraphics[width=5.2cm]{DE_split.png}\n  \\end{column}\n  \\begin{column}{6cm}\n\n    \\vspace{.7cm}\n    \\begin{itemize}\n\n    \\item Initial price difference could average up to 12 EUR/MWh\n    \\item Prices would converge with more network expansion\n    \\item Redispatch costs reduced by 39\\% in 2025, 58\\% in 2035 (assuming NEP 2030 transmission projects get built)\n    \\item Politically difficult, may require, like Italy, uniformised\n      price on consumer side\n    \\end{itemize}\n  \\end{column}\n\\end{columns}\n\n\\source{\\href{https://www.strommarkttreffen.org/2018-02_Fraunholz&Hladik_Zwei_Preiszonen_in_D.pdf}{Fraunholz \\& Hladik, 2018}}\n\\end{frame}\n\n\n\n\\begin{frame}\n  \\frametitle{Solution 1.5: Flow-based market coupling}\n\n  Flow-based market coupling can be used in zonal markets to see\n  precise individual line constraints, instead of ``boxing'' the feasible space\n  like ATC/NTC schemes do.\n\n  \\centering \\includegraphics[width=13cm]{fbmc}\n\n  \\source{Van den Bergh, Boury, Delarue}\n\\end{frame}\n\n\n\n\n\n\n\n\\section{Storage Optimisation}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Storage equations}\n\n  Now, like the network case where we add different nodes $i$\n  with different loads, for storage we have to\n  consider different time periods $t$.\n\n  Label conventional generators by $s$, storage by $r$ and now minimise\n  \\begin{align*}\n    &    \\min_{\\{g_{i,s,t}\\},\\{g_{i,r,t,\\textrm{charge}}\\},\\{g_{i,r,t,\\textrm{discharge}}\\},\\{f_{\\ell,t}\\}}\\\\\n    &\\left[  \\sum_{i,s,t} o_{i,s} g_{i,s,t} +   \\sum_{i,r,t} o_{i,r,\\textrm{charge} }\\, g_{i,r,t,\\textrm{charge}} +   \\sum_{i,r,t} o_{i,r,\\textrm{discharge}}\\, g_{i,r,t,\\textrm{discharge}} \\right]\n  \\end{align*}\n  The power balance constraints are now (cf. Lecture 5) for each node $i$ and time $t$ that the demand is met either by generation, storage or network flows:\n  \\begin{align*}\n    \\sum_{s} g_{i,s,t} + \\sum_{r}(g_{i,r,t,\\textrm{discharge}} - g_{i,r,t,\\textrm{charge}}) - d_{i,t} = \\sum_\\ell K_{i\\ell}f_{\\ell,t}  \\hspace{0.5cm}\\leftrightarrow\\hspace{0.5cm} \\l_{i,t}\n  \\end{align*}\n  Now we have a market price $\\l_{i,t}$ for each node $i$ and time $t$.\n\\end{frame}\n\n\\begin{frame}[fragile]\n  \\frametitle{Storage equations}\n\n  We have constraints on normal generators\n    \\begin{align*}\n        0 \\leq g_{i,s,t}  \\leq  G_{i,s}\n  \\end{align*}\n    and on the storage\n    \\begin{align*}\n    0 & \\leq g_{i,r,t,\\textrm{discharge}} \\leq G_{i,r,\\textrm{discharge}} \\\\\n    0 & \\leq g_{i,r,t,\\textrm{charge}} \\leq G_{i,r,\\textrm{charge}}\n    \\end{align*}\n\n    The energy level of the storage is given by\n  \\begin{align*}\n    e_{i,r,t} = \\eta_0e_{i,r,t-1} + \\eta_1g_{i,r,t,\\textrm{charge}} -  \\eta_2^{-1} g_{i,r,t,\\textrm{discharge}}\n  \\end{align*}\n  and limited by\n  \\begin{align*}\n    0 \\leq e_{i,r,t} \\leq E_{i,r}\n  \\end{align*}\n\n\\end{frame}\n\n\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Idea of storage}\n\n\n  Storage does `buy it low, sell it high' \\alert{arbitrage}, like network, but\n  in time rather than space, i.e. between cheap times (e.g. with lots\n  of zero-marginal-cost renewables) and expensive times (e.g. with\n  high demand, low renewables and expensive conventional generators).\n\n\n\n\\end{frame}\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Storage charges at low prices, discharges at high prices}\n\n  Simplified example from \\url{https://model.energy} For Germany with only wind and hydrogen storage to meet a flat 100~MW demand.\n\n  Average charging price (with electrolyser): 43 \\euro/MWh\n\n  Average discharging price (with turbine): 144 \\euro/MWh\n\n  %single_node_storage_bids.ipynb\n    \\centering \\includegraphics[width=8cm]{storage_bids.pdf}\n\n\n\n\\end{frame}\n\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Storage plus network equations}\n\n\n\n  Finally for the flows we repeat the constraints for each time $t$.\n\n  We have KVL for each cycle $c$ and time $t$\n  \\begin{align*}\n    \\sum_{c} C_{\\ell c} x_\\ell f_{\\ell,t} = 0  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\l_{c,t}\n  \\end{align*}\n  and in addition the flows cannot overload the thermal limits, $|f_{\\ell,t}| \\leq F_\\ell$\n  \\begin{align*}\n    f_{\\ell,t} \\leq F_\\ell  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\bar{\\m}_{\\ell,t} \\\\\n        - f_{\\ell,t} \\leq  F_\\ell  \\hspace{1cm}\\leftrightarrow\\hspace{1cm} \\ubar{\\m}_{\\ell,t}\n  \\end{align*}\n\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n  \\frametitle{Preview: Investment optimisation}\n\n  Preview for next time:\n\n  Next time we will also optimise \\alert{investment} in the \\alert{capacities} of generators,\n  storage and network lines, to maximise \\alert{long-run efficiency}.\n\n  We will promote the capacities $G_{i,s}$, $G_{i,r,*}$, $E_{i,r}$ and\n  $F_{\\ell}$ to optimisation variables.\n\n\\end{frame}\n\n\n\\end{document}\n", "meta": {"hexsha": "efe506d8cc31019f725b6dd4194ab9be40d80873", "size": 39039, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "esm-lecture-8.tex", "max_stars_repo_name": "pitmonticone/esm-lectures", "max_stars_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-09T06:51:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-09T06:51:11.000Z", "max_issues_repo_path": "esm-lecture-8.tex", "max_issues_repo_name": "pitmonticone/esm-lectures", "max_issues_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "esm-lecture-8.tex", "max_forks_repo_name": "pitmonticone/esm-lectures", "max_forks_repo_head_hexsha": "8e46ff7e01bf0ef4da378d71f2265acf71ab317b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0069177556, "max_line_length": 413, "alphanum_fraction": 0.6539870386, "num_tokens": 13703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.40508469229819893}}
{"text": "%%%%%%%% ICML 2020 EXAMPLE LATEX SUBMISSION FILE %%%%%%%%%%%%%%%%%\n\n\\documentclass{article}\n\n% Recommended, but optional, packages for figures and better typesetting:\n\\usepackage{microtype}\n\\usepackage{graphicx}\n\\usepackage{subfigure}\n\\usepackage{booktabs} % for professional tables\n\n% hyperref makes hyperlinks in the resulting PDF.\n% If your build breaks (sometimes temporarily if a hyperlink spans a page)\n% please comment out the following usepackage line and replace\n% \\usepackage{icml2020} with \\usepackage[nohyperref]{icml2020} above.\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n% Attempt to make hyperref and algorithmic work together better:\n\\newcommand{\\theHalgorithm}{\\arabic{algorithm}}\n\n% Use the following line for the initial blind version submitted for review:\n\\usepackage{icml2020}\n\n% If accepted, instead use the following line for the camera-ready submission:\n%\\usepackage[accepted]{icml2020}\n\n% The \\icmltitle you define below is probably too long as a header.\n% Therefore, a short form for the running title is supplied here:\n\\icmltitlerunning{Kalman Filter Powered Variational Autoencoder for Acoustic Unit Discovery}\n\n\\begin{document}\n\n\\twocolumn[\n\\icmltitle{Kalman Filter Powered Variational Autoencoder \\\\ \n      for Acoustic Unit Discovery}\n\n% It is OKAY to include author information, even for blind\n% submissions: the style file will automatically remove it for you\n% unless you've provided the [accepted] option to the icml2020\n% package.\n\n% List of affiliations: The first argument should be a (short)\n% identifier you will use later to specify author affiliations\n% Academic affiliations should list Department, University, City, Region, Country\n% Industry affiliations should list Company, City, Region, Country\n\n% You can specify symbols, otherwise they are numbered in order.\n% Ideally, you should not use this facility. Affiliations will be numbered\n% in order of appearance and this is the preferred way.\n\\icmlsetsymbol{equal}{*}\n\n\\begin{icmlauthorlist}\n\\icmlauthor{Jayanta Mukherjee}{linkedin} \n\\end{icmlauthorlist}\n\n\\icmlaffiliation{linkedin}{LinkedIn Corporation, Mountain View, CA, USA 94043} \n\n\\icmlcorrespondingauthor{Jayanta Mukherjee}{jmukherjee@linkedin.com}\n\n% You may provide any keywords that you\n% find helpful for describing your paper; these are used to populate\n% the \"keywords\" metadata in the PDF but will not be shown in the document\n\\icmlkeywords{Deep Learning, Variational Autoencoder, Kalman Filter, Unsupervised Learning, Acoustic Unit Discovery}\n\n\\vskip 0.3in\n]\n\n% this must go after the closing bracket ] following \\twocolumn[ ...\n\n% This command actually creates the footnote in the first column\n% listing the affiliations and the copyright notice.\n% The command takes one argument, which is text to display at the start of the footnote.\n% The \\icmlEqualContribution command is standard text for equal contribution.\n% Remove it (just {}) if you do not need this facility.\n\n\\printAffiliationsAndNotice{}  % leave blank if no need to mention equal contribution\n%\\printAffiliationsAndNotice{\\icmlEqualContribution} % otherwise use the standard text.\n\n\\begin{abstract}\nVariational Autoencoder (VAE) empowers identification of dominant latent structure to approximate Bayesian Inference for observation models. Structured Variational Autoencoders (SVAE) have been shown to provide efficient neural network-based approximate inference in the presence of both discrete and continuous latent variables. Inspired by SVAE, a VAE has been developed with Extended Kalman Filter(EKF)s to model latent variables. The contribution of this paper is to introduce the Extended Kalman Filter (EKF) for Variational Autoencoder (VAE) to the task of acoustic unit discovery combining the benefit of EKF for continuous space modeling of latent variables with the power of deep generative models provided by VAE. The EKF-VAE is designed to identify and leverage the latent variable structure. With Extended Kalman Filter in Linear-Gaussian State-Space models, the accuracy of the acoustic unit discovery has been significantly improved by reducing the training loss by 47\\% and root-mean-square error by more than 50\\% by the EKF-VAE for acoustic discovery on the TIMIT dataset \\cite{timit-article}. The experimental results demonstrated that the EKF-VAE model outperforms Hidden Markov Model (HMM) VAEs \\cite{Raj_2017} in acoustic discovery.\n\n\\end{abstract}\n\n\\section{Introduction}\n\\label{intro}\nMany speech technologies such as automatic speech recognition (ASR) and text-to-speech synthesis (TTS) have been used widely around the world. However, most such systems only cover rich-resource languages. For low-resource languages, using such technologies remains limited due to lack of labeled datasets to achieve good performance.\n \n \\par\nIt is important to develop unsupervised learning algorithms which can use the unlabelled data. For acoustic discovery where methods of speech processing needs to be learnt from raw speech, the task of acoustic discovery can be recognized. Finding the phone-like subword units as acoustic building blocks to discover semantically meaningful linguistic building blocks is necessary. The Variational Autoencoder which can be used for generative purposes as its latent variable models uses deep neural networks to parameterize flexible probability distributions can be an important tool to perform any recognition task including AUD. An auto-encoder encodes some input into a new and usually more compact representation which can be used to reconstruct the input data again. A VAE makes the assumption that the compact representation follows a probabilistic distribution (usually Gaussian) which makes it possible to sample new points and decode them into new data from a trained variational auto-encoder. There have been lots of work being done using Hidden Markov Model (HMM) \\cite{Raj_2017} as well as using Latent Variable Models (LVM). One striking difference between these two models is that in the Hidden Markov Model (HMM) the latent variables are discrete while in LVM the latent variables can be continuous. One more difference is that for LVM both the latent and observed variables follow Gaussian Distribution, while for HMM only the observed variables have to be of Gaussian Distribution. LVM is a class of statistical models that seek to model the relationship of observed variables with a set of latent variables to allow for modeling of more complex, generative processes. The inference in these models is often difficult or intractable, motivating a class of variational methods that frame the inference problem as optimization. Variational Autoencoders \\cite{Kingma2014}, in particular, have seen success in tasks of image generation \\cite{gregor15}.\n\n\\par\nOn the other hand, the Kalman Filter \\cite{Kalman_1960} has been popular as one of state-of-the-art algorithms for estimating dynamic state for noisy and incomplete measurements in discrete-time for multiple decades. The Extended Kalman Filter (EKF) \\cite{Julier97anew} handles the system nonlinearities through conversion of nonlinear system equations into linear ones by applying a first order Taylor-series approximation around the current mean error and covariance, so that the traditional linear Kalman filter can be applied. \n\n\\par\nThe contribution of this work is to apply the Extended Kalman Filter \\cite{ekf_2002} to VAE to improvise the prediction of the words by moving in a direction which will reduce the distance between the actual word and predicted word. Applied Kalman Filter at every training step of the VAE to reduce the error and training losses by as much as 48\\% while incurring a maximum overhead of less than 14\\% of the epoch duration. Used PyTorch \\cite{paszke2017automatic},\\cite{NEURIPS2019_9015} Gated Recurrent Unit (GRU) and Recurrent Neural Network (RNN) \\cite{SchusterP97} to model the speech recognition aka Acoustic Unit Discovery (AUD). Applied the model to TIMIT \\cite{timit-article} and compared its performance against a Hidden Markov Model (HMM) \\cite{Raj_2017}.\n\n\\par\nThe paper is organized as follows. In Section \\ref{section:related} discusses about the related work in the field of Variational Autoencoder (VAE) and Kalman Filter. The Section \\ref{section:background} recapitulates the core concepts used in building the proposed model, e.g., VAE, Recurrent Neural Network based encoder and decoder. The proposed EKF-VAE model is introduced in Section \\ref{section:model} along with model estimation forward algorithms, Kalman Filter and its extended version. Section \\ref{section:experiments} describes the AUD experiments being conducted on the TIMIT \\cite{timit-article} database, while Section \\ref{section:conclusions} offers some conclusions.  \n\n\\section{Related Work}\n\\label{section:related}\nThere has been substantial exploration on both the acoustic discovery and variational autoencoder fronts.\nThe attention mechanism \\cite{bahdanau2016neural} has been extensively used with RNN encoder-decoder models \\cite{wang2016learning} to enhance their ability to deal with long source inputs. A basic RNN-based VAE \\cite{bowman2016generating} generative model has been used to explicitly model different properties of sentences to propose two workarounds: 1. KL cost annealing and 2. masking parts of the source and target tokens with special symbols in order to improvise inference by weakening the decoder. The intent was to generate coherent novel sentences as opposed to AUD that interpolate between known sentences using RNN-based VAE.\n\nThe Kalman variational autoencoder (KVAE) \\cite{nipsFraccaroKPW17} extends ideas from the SVAE, modelling latent state using a Linear Gaussian State Space Model (LGSSM). To allow for non-linear dynamics, the KVAE uses a recognition model to produce time-varying parameters for the LGSSM, weighting a set of K constant parameters using weights generated by a neural network. They applied KVAE to learn a recognition and dynamics model from video and used it to impute missing data and perform long-term generation in four different environments.  \n\n\\cite{pmlr-v97-tan19b} proposed decomposing of the overall learning problem into many smaller problems, which are coordinated by the hierarchical mixture, represented by a sum-product network (SPN) and showed that their model outperform classical VAEs on almost all of their experimental benchmarks.\n\nIn a recent work on HMM-VAE \\cite{Raj_2017}, the Hidden Markov Models (HMMs) was being used as latent models to perform acoustic unit discovery (AUD) in a zero resource scenario, and showed significant improvement in the accuracy of the acoustic unit discovery. The kernel Kalman rule has been proven as an improvement over the Kernel Bayes rule \\cite{Gebhardt2017}. The Extended Kalman Filter being superior in modeling dynamic state, applied the Extended Kalman Filter with Variational Auto-encoder to bring further improvement in accuracy in acoustic unit discovery. \n\n\\par\n\\cite{pagnoni2018conditional} augmented the encoder-decoder NMT paradigm by introducing a continuous latent variable to model features of the translation process by extending this model with a co-attention mechanism motivated by \\cite{parikh2016} in the inference network to show that the conditional variational model improves upon both discriminating attention-based translation and the conditional variational language model for machine translation presented in \\cite{zhang2016}. \\cite{pagnoni2018conditional} presented some exploration of the learned latent space to illustrate what the latent variable is capable of capturing by utilizing the latent variable without weakening the translation model.\n\n\\par\nThe contrastive variational autoencoder (cVAE) \\cite{abid2019contrastive} was designed to identify and enhance salient latent features by explicitly modeling latent features that are shared between the MNIST dataset \\cite{lecun-mnisthandwrittendigit-2010}, as well as those that are enriched in one dataset relative to the other.\n\n\\par\n\\cite{tjandra2020transformer} built a Transformer-based Vector Quantised Variational AutoEncoder (VQ-VAE) for unsupervised unit discovery system that addresses two major components such as 1) given speech audio, extract subword units in an unsupervised way and 2) re-synthesize the audio from novel speakers. In VQ-VAE, the focus was on the discrete latent representation as opposed to continuous representations costing it to achieve likelihood close but not as good as the continuous representation.\n\nThe work proposed in this paper bears some resemblance to the HMM-VAE \\cite{Raj_2017} or VQ-VAE \\cite{tjandra2020transformer}  which used VAE for acoustic discovery but it is an improvement over VQ-VAE model as it leveraged the continuous latent space representation along with handling the non-linearities of the system. Also, EKF-VAE is an enhancement over HMM-VAE as it reduces the error and loss by taking care of the non-linearities of the system by updating the state, weights and covariance effectively.\n\n\\section{Background}\n\\label{section:background}\nFirst, let me give a brief overview of Variational Autoencoder (VAE)s along with Recurrent Neural Network (RNN) based Encoder-Decoder.\n\n\\subsection{Variational Autoencoder}\nVariational Autoencoders \\cite{Kingma2014} (VAEs) got popularity in unsupervised learning \\cite{varadarajan-etal-2008-unsupervised} of complicated distributions.  \n\nFor every datapoint Z in the dataset, \\cite{doersch2021tutorial} there is one (or many) settings of the latent variables which causes the model to generate something very similar to Z. The objective is to optimize $\\theta$ such that we can sample x from p(x) and, with to maximize probability, f(x; $\\theta$) with the aim maximize the probability of each Z in the training set under the entire generative process,\n\\begin{equation} \\label{eq:vaeEq}\n    P(Z) = \\int P(Z | x; \\theta)P(x) dx\n\\end{equation}\n\nHere, $f(x; \\theta)$ has been replaced by a distribution $p(Z | x; \\theta)$, which allows us to make the dependence of Z on x explicit by using the law of total probability. Based on the principle of \"Maximum Likelihood\" if the model is likely to produce training set samples, then it is also likely to produce similar samples, and unlikely to produce dissimilar ones.  \n\n\\begin{equation}\n    \\hat{x}_{ml} = arg \\: \\underset{x}{max} \\:  p(z | x)\n\\end{equation}\n \n\nIn VAEs, the choice of this output distribution is Gaussian, i.e., $p( Z | x; \\theta) = \\mathcal{N} (Z | f(x; \\theta), \\sigma^{2}I)$.  \n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[scale=.4]{img/VAE.png}\n  \\caption{ Generative Model in solid lines for $p_{\\theta}(x)p_{\\theta}(z|x)$, dashed lines denote the variational approximation $q_{\\phi}(x|z)$ to intractable posterior $p_{\\theta}(x|z)$.  }\n  \\label{fig:fig1}\n\\end{figure}\n\nThe Kullback-Leibler divergence (KL divergence) between $p(x | Z)$ and Q(x) for some arbitrary Q, can be written while applying Bayes rule to $p(x | Z)$ as follows:\n\\begin{equation}\n    \\begin{split}\n    K&L[Q(x)\\: ||\\: p(x | Z)] = \\\\\n  & E_{x\\sim Q}[log\\: Q(x) - log\\: p(Z | x) - log\\: p(x)] + log\\: p(Z)\n    \\end{split}\n\\end{equation}\n\nHere, log p(Z) comes out of the expectation because it does not depend on latent variable x. The objective is to construct a Q which does depend on Z, and in particular, one which makes $KL[Q(x)\\: ||\\: p(x | z)]$ small:\n\\begin{equation}\\label{eq:vaeOpt}\n    \\begin{split}\n        log\\: p(Z) &- KL[Q(x | Z)\\: ||\\: p(x | Z)] = \\\\\n        &E_{x\\sim Q}[log\\: p(Z | x)] - KL[Q(x | Z)\\: ||\\: p(x)] \n    \\end{split} \n\\end{equation}\nthe left hand side of Equation \\ref{eq:vaeOpt} has the quantity which needs to be maximized: log p(Z) (plus an error term, which makes Q produce x’s that can reproduce a given Z. The right hand side is optimized by Extended Kalman Filter (or stochastic gradient descent) given the right choice of Q.  \n\n\\par\nThe first term in Equation \\ref{eq:vaeOpt} is a bit more tricky. A possible option is to sample to estimate $E_{x\\sim Q}[log\\: p(Z | x)]$, but getting a good estimate would require passing many samples of x through f , which would be expensive. The full equation to optimize is:\n\\begin{equation}\\label{vae2}\n    \\begin{split}\n        E_{Z\\sim KL}&[log\\: p(Z) - KL[Q(x|Z)\\: ||\\: p(x | Z)] = \\\\\n        & E_{Z\\sim KL}[E_{x\\sim Q}[log\\: p(Z | x)] - KL[Q(x|Z)\\: ||\\: p(x)]] \n    \\end{split}  \n\\end{equation}\n\nSample a single value of Z and a single value of x from the distribution $Q(x|Z)$, and compute the gradient of the right-hand side. We can then average the gradient of this function over arbitrarily many samples of X and z, and the result converges to the gradient of Equation \\ref{vae2}.  \n\\subsection{RNN Based Encoder-Decoder}\nA novel architecture is built leveraging the {\\it RNN Encoder-Decoder} proposed by \\citet{cho2014learning} and \\citet{sutskever2014sequence} to perform acoustic discovery.\n\nIn the Encoder-Decoder framework, an encoder reads the input sentence, a\nsequence of vectors $x=\\left( x_1, \\cdots, x_{T_x} \\right)$, into a vector\n$c$. The most common approach is to use an RNN such that  \n\\begin{align}\n    \\label{eq:forward_state}\n    h_t = f\\left( x_{t}, h_{t-1} \\right)\n\\end{align}\nand\n\\begin{align*}\n    c = q\\left(\\left\\{ h_1, \\cdots, h_{T_x} \\right\\}\\right),\n\\end{align*}\nwhere $h_t \\in \\mathcal{R}^{n}$ is a hidden state at time $t$, and $c$ is a vector\ngenerated from the sequence of the hidden states. $f$ and $q$ are some\nnonlinear functions. \\citet{sutskever2014sequence} used an LSTM as $f$ and\n$q\\left(\\left\\{ h_1, \\cdots, h_T \\right\\}\\right)=h_T$, for instance.\n\nThe decoder \\cite{bahdanau2016neural} is trained to predict the next word $y_{t'}$ given the context vector $c$ and all the previously predicted words $\\left\\{ y_1, \\cdots, y_{t'-1}\n\\right\\}$. In other words, the decoder defines a probability over the translation by decomposing the joint probability into the ordered conditionals:\n\\begin{align}\n    \\label{eq:decoder_prob}\n    p(y) = \\prod_{t=1}^T p(y_t \\mid \\left\\{ y_1, \\cdots, y_{t-1} \\right\\}, c),\n\\end{align}\nwhere $y = \\left( y_1, \\cdots, y_{T_y} \\right)$. With an RNN, each conditional probability is modeled as\n\\begin{align}\n    \\label{eq:output_rnn}\n    p(y_t \\mid \\left\\{ y_1, \\cdots, y_{t-1} \\right\\}, c) = g(y_{t-1}, x_{t}, c),\n\\end{align}\nwhere $g$ is a nonlinear, multi-layered, function that outputs the probability of $y_t$, and $x_t$ is the hidden state of the RNN.   \n\n\\section{Model}\n\\label{section:model}\n\nBuilt the model using RNN, GRU Cell of PyTorch and developed Encoder and Decoder RNN as part of the VAE model for comparing the performance of the proposed model EKF-VAE against the HMM-VAE as baseline. \n\n\\subsection{Kalman Filter \\& Extended Kalman Filter} \nThe Kalman filter \\cite{SSS06Oxford} is being popular in predicting the next state of dynamic systems. It uses an iterative approach to tune the model to rectify the error. \n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[scale=.22]{img/kalman.png}\n  \\caption{ Kalman Filter showing latent and observed variables}\n  \\label{fig:fig2}\n\\end{figure}\n\nThe Kalman filter and smoother are based on the following probabilistic model \\cite{JWMiller16}.\n\\begin{itemize}\n\\item Like a discrete-state HMM as shown in the Figure \\ref{fig:fig2}, the sequence of observations $z_{1},z_{2}, . . . , z_{n}$ is modeled jointly along with a sequence of hidden latent states $x_{1}, x_{2}, ....., x_{n}$ with the assumption that:\n\\begin{equation}\np(z_{1:n}, x_{1:n}) = p(x_{1})p(z_{1}|x_{1}) \\displaystyle\\prod_{j=2}^{n} p(x_{j}|x_{j-1})p(z_{j}|x_{j}) \n\\end{equation}  \n\\item Difference from a discrete-state HMM is that each hidden state $x_j$ is modeled as a continuous random variable in $\\mathcal{R}^d$ with a multivariate normal distribution.\n \n\\item The initial distribution $p(x_{1})$, the transition distributions $p(x_{j} | x_{j-1})$ (a.k.a. the \"process model\") and the emission distributions $p(z_{j} | x_{j} )$ (a.k.a. the \"measurement model\") are assumed to be\n\\begin{equation}\n\\begin{split}\np(x_{1}) = &\\mathcal{N} (x_{1} | \\mu_{0}, P_{0}) \\\\\np(x_j | x_{j - 1}) = &\\mathcal{N}  (x_{j}| F x_{j - 1}, Q) \\\\\np(z_j | x_j) = &\\mathcal{N}  (z_j| Hx_j, R)\n\\end{split}\n\\end{equation}  \nwhere\n\\begin{itemize}\n    \\item $x_{j} \\in \\mathcal{R}^{d} $ (the state of the system at time step j),\n    \\item $z_{j} \\in \\mathcal{R}^d$ (the measurements at time step j),\n    \\item $\\mu_{0} \\in \\mathcal{R}^d$ is an arbitrary vector (the initial “best guess” at the initial state),\n    \\item $P_{0} \\in \\mathcal{R}^{d \\times d}$ is a symmetric positive definite matrix (the initial covariance matrix, quantifying the uncertainty about the initial state),\n    \\item $F \\in \\mathcal{R}^{d \\times d}$ is an arbitrary matrix (modeling the physics of the process nonlinear vector function, or a linear approximation thereof),\n    \\item $Q \\in \\mathcal{R}^{d \\times d}$ is a symmetric positive definite matrix (quantifying the noise/error in the process that is not captured by F),\n    \\item $H \\in \\mathcal{R}^{D \\times d}$ is an arbitrary matrix (relating the measurements to the state),\n    \\item $R \\in \\mathcal{R}^{D \\times D}$is a symmetric positive definite matrix (quantifying the noise/error of the measurements).\n\\end{itemize}\n\\item The model can easily be extended to handle time-dependence in F, Q, H, and R, by simply replacing them with $F_{j}, Q_{j}, H_{j}, and R_{j}$ in the expressions above.  \n\\end{itemize}   \n\nThe Kalman filter (KF) is a method based on recursive Bayesian filtering where the noise in the system is assumed to be Gaussian. The \\textbf{Extended Kalman Filter} (EKF) is an extension of the classic Kalman Filter for non-linear systems where non-linearity are approximated using the first or second order derivative.  \n\n\\subsection{Extended Kalman Filter: Forward Algorithm}\nThe Extended Kalman filter (EKF) is the nonlinear version of the Kalman filter which linearizes about an estimate of the current mean and covariance. \n\n\\textbf{Model and Observation:}\\\\\nConsider the nonlinear system, described by the difference equation and the observation\nmodel with additive noise:\n\\begin{equation}\n    x_{j} = f(x_{j-1}) + w_{j-1}\n\\end{equation}\n\\begin{equation}\n    z_{j} = h(x_{j}) + v_{j}\n\\end{equation}\n\n\\textbf{Initialization:}\\\\\nThe initial state $x_{0}$ is a random vector with known mean $\\mu_{0} = E[x_{0}]$ and covariance $P_{0} = E[(x_{0} - \\mu_{0})(x_{0} - \\mu_{0})^{T} ]$.\n\nIn the Extended Kalman Filter forward algorithm, Compute $p(x_j | z_{1:j})$ sequentially for j = 1, 2, ...., n in that order. Here is the generalized form for step j \\cite{JWMiller16}, $p(x_{j-1} | z_{1 : j-1}) = \\mathcal{N}(x_{j - 1} | \\mu_{j - 1}, V_{j - 1})$\n\n\\textbf{Model Forecast Step/Predictor:}\\\\\nThe forecast value for $x_{j}$ is $x_{j}^{f}$, which can be expressed as:\n\\begin{equation}\n    x_{j}^{f} \\approx f(x_{j-1}^{a})\n\\end{equation} \n\n\\textbf{Data Assimilation Step/Corrector:}\\\\\nThe state-estimate $x_{j}^{a}$ can be expressed as:\n\\begin{equation}\n    x_{j}^{a} \\approx x_{j}^{f} + K_{j}(z_{j} - h(x_{j}^{f}))\n\\end{equation} \nKalman Gain at step j $K_{j}$ can be expressed as:\n\\begin{equation}\n    K_{j} = P_{j-1}H^{T}(H P_{j-1}H^{T} + R)^{-1}\n\\end{equation}, \n\nUpdate the matrix P as it captures the uncertainty about the initial state and improve based on the Kalman Gain $K_{j}$\n\\begin{equation}\n    P_{j} = (I - K_{j}H)P_{j-1} \n\\end{equation}\nThe update of weights of the neural network $dW_{j}$ can be computed based on the difference of the actual output y and the approximate Jacobian H factored by the Kalman Gain. Approximated Jacobian (H) based on weight, $d\\sigma$.\n\nPutting the above equations altogether, the algorithm \\ref{alg:ekfalgo} can be described as follows.\n\n\\begin{algorithm}[tbh]\n   \\caption{Extended Kalman Filter Forward Algorithm}\n   \\label{alg:ekfalgo}\n\\begin{algorithmic}\n   \\STATE {\\bfseries Input:} Input state $x_{j}$, Observed data $z_j$, size $n$ and model parameters $P_{0}$, F, Q, H, R, step\n   \\STATE {Initialization:}\n   \\STATE $ K_{1} = P_{0}H^{T}(HP_{0}H^{T} + R)^{-1} $ \\\\ \n   \\STATE $ P_{1} = (I - K_{1}H)P_{0} $ \\\\ \n   \\FOR{$j = 2$ {\\bfseries to} $n$}\n      \\STATE Approximate Jacobian H\n      \\STATE $ K_{j} = P_{j-1}H^{T}(HP_{j-1}H^{T} + R)^{-1} $ \\\\\n      \\STATE $P_{j} = (I - K_{j}H)P_{j-1} $  \\\\\n      \\STATE $ dW_{j} = step K_{j} (z_{j} - H)$ \n      \\STATE $W_{j} = W_{j-1} + dW_{j}$\n      \\IF{Q != 0} \n        \\STATE $P_{j} = P_{j} + Q$\n      \\ENDIF\n   \\ENDFOR \n\\end{algorithmic}\n\\end{algorithm} \nIn the above algorithm \\ref{alg:ekfalgo}, P is the variance of the state estimation, Q is the variance of the process noise, R captures the variance of the measurement noise.\n\nThe Kalman filter is identical to the forward algorithm for discrete-state HMMs, except that it is expressed in terms of $\\mu_{j}, V_{j}$ instead of $s_{j} (z_{j})$ (and the derivation involves an integral instead of a sum).\n\n\\subsection{EKF-VAE}\nThe Extended Kalman Filter based Variational Autoencoder (EKF-VAE) is built on a Sequence-to-Sequence model made up of an EncoderRNN module and a DecoderRNN module which leverage Extended Kalman Filter. \n\nThe forward behavior depends on whether ground-truth is being provided or not. When ground-truth is provided it returns cross-entropy loss, else, it returns predicted word (id).\n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[scale=.20]{img/EKF-VAE-Loss.png}\n  \\caption{EKF-VAE uses EKF for updating weights and state-estimates. A RNN based Encoder-Decoder to reconstruct by generative process.}\n  \\label{fig:fig3}\n\\end{figure}\n\nThe Figure \\ref{fig:fig3} shows a schematic diagram of the EKF based VAE which consists of the following:\n\\begin{itemize}\n    \\item EKF is a neural network to update state-estimation and covariance matrix to provide better prediction.\n    \\item RNN Based Encoder-Decoder to perform regenerative actions\n    \\item Check against ground-truth (when provided) to compute loss, else, provide reconstructed input.\n    \\item Observed and latent variables.\n\\end{itemize}\nThe EKF updates the weight and covariance matrix to improve the state-estimation. The Encoder RNN is a Bi-directional multi-layer gated recurrent unit (GRU) RNN. The Attention decoder is based on \\textbf{Listen, Attend and Spell (LAS)} \\cite{chan2015listen}. \n\nThe Decoder RNN applies two simple and effective classes of attentional mechanism: a global approach which always attends to all source words and a local one that only looks at a subset of source words at a time similar to the attentional mechanism proposed by \\cite{luong2015effective}. \n\nThe novel EKF-VAE algorithm calls EKF (described in the algorithm \\ref{alg:ekfalgo}) to update the weights of the neural network to provide better convergence by predicting the state variables and covariance matrix. Adam optimizer is being used with the $torch.optim.lr\\_scheduler.ReduceLROnPlateau$ scheduler as it allows dynamic learning rate reducing based on some validation measurements. The Kalman Filter based Neural Net (EKF) is a feed-forward neural network (NN). The EKF implements the Extended Kalman Filter algorithm to train. Technically, it could potentially be possible to be trained by stochastic gradient descent (SGD). Trained the NN using the feed-forward function to compute the NN output, and the classify function to round a feed-forward to the nearest class values. Also check-pointed the EKF object in the working directory.\n\n\\begin{algorithm}[tbh]\n   \\caption{EKF Feed Forward Algorithm}\n   \\label{alg:ekfFeedAlgo}\n\\begin{algorithmic}\n   \\STATE {\\bfseries Input:} Input training data x, activation function $\\sigma$, current weight $W_{j}$ of the neural network \\\\ \n   \\STATE $l = \\sigma (W_{j} x) $ \\\\\n   \\STATE $ h = W_{j} l$  \\\\\n   \\STATE  return h, l\n\\end{algorithmic}\n\\end{algorithm} \n\nUpdating the weights of the neural network using EKF allows us to predict and update the states. The hypothesis behind weight update using EKF is to capture the non-linearities of the underlying system.\n\n\\section{Experiments}\n\\label{section:experiments}\nFor experimenting Extended Kalman Filter (EKF) based Variational Autoencoder (VAE), applied Extended Kalman Filter based forward prediction specified in algorithm \\ref{alg:ekfalgo} along with Feed Forward algorithm \\ref{alg:ekfFeedAlgo} at each step of the training to improve the prediction of the dynamic state. As the EKF improves the prediction at each step the error (Root Mean Square) reduces as compared to HMM-VAE).\n \nApplied the EKF-VAE model on TIMIT \\cite{timit-article} data and computed the error by computing the distance between the actual and predicted data and learning from it.\n\n\\subsection{Dataset: TIMIT}\nThe Texas Instruments/Massachusetts Institute of Technology (TIMIT) \\cite{timit-article} corpus of read\nspeech has been designed to provide speech data for the acquisition of acoustic-phonetic knowledge and for the development and evaluation of automatic speech recognition systems. TIMIT contains speech from 630 speakers representing 8 major dialect divisions of American English, each speaking 10 phonetically-rich sentences. The TIMIT corpus includes time-aligned orthographic, phonetic, and word transcriptions, as well as speech waveform data for each spoken sentence.\n\nThe acoustic features are 80-dimensional filter banks. They are stacked every 3 consecutive frames, so the time resolution is reduced. Following the standard recipe, used a 462-speaker training set with all SA records removed. Outputs are mapped to 39 phonemes when evaluating.\n\n\\subsection{Experiment Settings}\nThe EKF-VAE consists of an Encoder Recurrent Neural Network (RNN) and an Decoder Recurrent Neural Network (RNN). The Encoder RNN consists of three encoder layers and the Decoder RNN consists of two decoder layers with Relu activation. \nThe encoder has an input size of 240. Both encoder and decoder have a hidden unit size of 256. The target size is equal to the vocabulary size of the tokenizer.For training purposes, used a batch size of 64 with a dropout percentage of 0.5.\n\n\\subsection{Results}\nTrained the EKF-VAE algorithm to perform the acoustic discovery on TIMIT data. The algorithm was trained for 50 iterations and then 100 iterations. Observed that the Root Mean Square Error (RMSE) goes down very fast and but the dev loss plateaued for both EKF-VAE as well as HMM-VAE, but the rate of reduction of RMSE is faster for ELF-VAE and remained even as the number of iterations have been increased.\n\n\\begin{figure*}[h]\n  \\centering\n  \\begin{minipage}[b]{0.4\\textwidth}\n    \\includegraphics[width=\\textwidth]{img/TrainLoss.pdf}\n    \\caption{Training Loss}\n    \\label{fig:fig4}\n  \\end{minipage}\n  \\hfill\n  \\begin{minipage}[b]{0.4\\textwidth}\n    \\includegraphics[width=\\textwidth]{img/DevLoss.pdf}\n    \\caption{Evaluation/Dev Loss}\n    \\label{fig:fig5}\n  \\end{minipage} \n\\end{figure*}\nAs shown in Figure \\ref{fig:fig4}, the EKF-VAE achieved more than 47\\% reduction in training loss at the end of 100 iterations (epochs) and experienced a maximum of 49\\% reduction in dev loss individual epoch as shown in Figure \\ref{fig:fig5}. Although both the HMM and EKF are Gaussian based, the training loss reduction is better for EKF-VAE (shown in green) as compared to HMM-VAE as EKF handles the non-linearity and predicts the dynamic state better. As shown in Figure \\ref{fig:fig5}, the evaluation (dev) loss has increased in EKF-VAE in later iterations and HMM over-performed by 10\\%.\n\n\\begin{figure}[H] \n    \\includegraphics[scale=.55]{img/ErrorRate.pdf}\n    \\caption{Error Rate}\n    \\label{fig:fig6}\n\\end{figure}\n\nThe Kalman filter seems to be effective in modeling language as word utterances can be modeled as discrete occurrences of words. Applying Kalman Filter at each step forced the current state uncertainty $P_{j}$ to converge faster causing error rate to go down. For acoustic discovery use-case, the error rate has been reduced up to 37\\% by Extended Kalman Filter based VAE (EKF-VAE) over HMM VAE as shown in Figure \\ref{fig:fig6}. \n\n\\begin{figure}[htb]   \n    \\includegraphics[scale=.5]{img/RMSE.pdf}\n    \\caption{Root Mean Square Error}\n    \\label{fig:fig7} \n\\end{figure}\n\nThe error has been computed based on distance of expected and predicted word. The root-mean square error (RMSE) as shown in Figure \\ref{fig:fig7} reduced by 57\\% at individual epoch in EKF-VAE as compared to its HMM-VAE counterpart. \n\n\\begin{figure}[htb] \n    \\includegraphics[scale=.5]{img/EpochDuration.pdf}\n    \\caption{Epoch Duration Comparison between HMM-based and EKF-based VAE}\n    \\label{fig:fig8}\n\\end{figure}\n\nBut, as the EKF is being called in each iteration, it increases the training time. It is essential to understand the trade-off between incurring an additional cost of time for extended kalman filter based prediction to improve convergence and the error reduction rate. The additional Extended Kalman Filter computation increases the training time at every iteration which resulted in less than 14\\% increase in epoch duration as shown in Figure \\ref{fig:fig8}.  \n\n\\begin{figure}[H] \n    \\includegraphics[scale=.5]{img/lr.pdf}\n    \\caption{Learning Rate Comparison between HMM-VAE and EKF-VAE}\n    \\label{fig:fig9}\n\\end{figure}\n\nAs shown in Figure \\ref{fig:fig9} the learning rate between HMM-VAE and EKF-VAE, the learning rate for HMM-VAE dropped to 0.00005 while the learning rate for EKF-VAE remained at 0.00015. The HMM-VAE kept learning at a higher rate potentially can cause an oscillation in predicting the words. The lower the learning rate, the lesser is the oscillations and hence can expect to have a better convergence.\n\nThe EKF-VAE has predicted the words more accurately than its HMM rivals as it predicted the discrete state more accurately. EKF kept computing the Kalman Gain at each step to decide how much to tune/update the weights to provide a better prediction resulting in superior acoustic discovery. \n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[scale=.25]{img/EKF-Predict.png}\n  \\caption{ Extended Kalman Filter based VAE Prediction}\n  \\label{fig:fig10}\n\\end{figure}\nThe EKF based predictions as shown in Figure \\ref{fig:fig10} and Figure \\ref{fig:fig11} demonstrates the actual word prediction.\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[scale=.42]{img/TIMIT_EKF.png}\n  \\caption{Acoustic Discovery}\n  \\label{fig:fig11}\n\\end{figure}\nUsing RNN-Based Encoder-Decoder along with the attention model allowed us to have a better word prediction.  \n\n\\section{Conclusions}\n\\label{section:conclusions}\nThe proposed an Extended Kalman Filter (EKF) Powered Variational Autoencoder (VAE) for acoustic discovery has achieved a faster convergence as it models the latent space better. From the results, it is evident that the EKF based Variational Model outperforms the HMM based Variational model. The EKF-VAE provides significant improvement over HMM based VAE due to better prediction of the dynamic state by the Kalman filter. Finally, it is shown that the EKF-VAE can reduce the error significantly (~49\\%) to assure superior prediction accuracy.\n\n%%%%%%%%%%%%% Acknowledgements %%%%%%%%%%%%%\n%\\footnotesize\n\\section{Acknowledgements}\nThanks to Prof Bhiksha Raj Ramakrishnan of the Carnegie Mellon University for his immense encouragement and suggestions. Thanks to Nihit Purwar for his support. Thanks to my beautiful wife Mahaswata for motivating me to pursue my passion and buying an NVIDIA RTX2080 based laptop on which all the experiments were performed.\n\n%%%%%%%%%%%%%%   Bibliography   %%%%%%%%%%%%%%\n\\normalsize\n\\bibliography{references}\n\\bibliographystyle{icml2020}\n\n% In the unusual situation where you want a paper to appear in the\n% references without citing it in the main text, use \\nocite\n%\\nocite{langley00}\n\n\n\n\n\\end{document}\n\n% This document was modified from the file originally made available by\n% Pat Langley and Andrea Danyluk for ICML-2K. This version was created\n% by Iain Murray in 2018, and modified by Alexandre Bouchard in\n% 2019 and 2020. Previous contributors include Dan Roy, Lise Getoor and Tobias\n% Scheffer, which was slightly modified from the 2010 version by\n% Thorsten Joachims & Johannes Fuernkranz, slightly modified from the\n% 2009 version by Kiri Wagstaff and Sam Roweis's 2008 version, which is\n% slightly modified from Prasad Tadepalli's 2007 version which is a\n% lightly changed version of the previous year's version by Andrew\n% Moore, which was in turn edited from those of Kristian Kersting and\n% Codrina Lauth. Alex Smola contributed to the algorithmic style files.\n\n\n", "meta": {"hexsha": "e8ab9273b213ff356a694db25cdb23ebd279287b", "size": 36505, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "EKF_VAE.tex", "max_stars_repo_name": "jmukher1/EKF-VAE-Paper", "max_stars_repo_head_hexsha": "9be405e1a11c6f1d46e24d4de224f423326fdabe", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "EKF_VAE.tex", "max_issues_repo_name": "jmukher1/EKF-VAE-Paper", "max_issues_repo_head_hexsha": "9be405e1a11c6f1d46e24d4de224f423326fdabe", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EKF_VAE.tex", "max_forks_repo_name": "jmukher1/EKF-VAE-Paper", "max_forks_repo_head_hexsha": "9be405e1a11c6f1d46e24d4de224f423326fdabe", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.893970894, "max_line_length": 1964, "alphanum_fraction": 0.7638953568, "num_tokens": 9505, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.40508468842509515}}
{"text": "\\section{Method}\n\\label{section:method}\n\\subsection{A new empirical gyrochronology relation}\n\nWe fit a broken power law to the 650 Myr Praesepe cluster in order to\ncalibrate a gyrochronology relation that takes advantage of new data available\nfrom the \\ktwo\\ and \\gaia\\ surveys.\nThis relation captures the detailed shape of Praesepe's rotation period-color\nrelation, and is calibrated to \\gaia\\ \\gcolor\\ color.\nPraesepe is the ideal calibration cluster because it has the largest number of\nmembers with precisely measured rotation periods, over a large range of colors\n\\citep[spanning spectral types A0 through M6,][]{rebull2017}, of any open\ncluster.\nIt is relatively tightly clustered on the sky and many of its members were\ntargeted in a single \\ktwo\\ campaign, from which rotation periods have been\nmeasured via light curve frequency analysis \\citep{douglas2017, rebull2017}.\nWe compiled rotation periods, \\Gaia\\ photometry and \\gaia\\ parallaxes for\nmembers of the 650 Myr Praesepe cluster \\citep{fossati2008} by identifying\nPraesepe members with measured rotation periods from \\citet{douglas2017} in\nthe \\ktwo-\\gaia\\ crossmatch catalog provided at\n\\url{https://gaia-kepler.fun/}.\nThis catalog cross-matched the EPIC catalog \\citep{huber2016} with the\nGaia DR2 catalog \\citep{brown2018}, using a 1'' search radius.\nThe result was a sample of 757 stars with rotation periods, parallaxes and\n\\gaia\\ $G$, $G_{BP}$ and $G_{RP}$-band photometry, shown in figure\n\\ref{fig:praesepe}\\footnote{This analysis was performed in a Jupyter notebook\navailable here: \\url{\n    https://github.com/RuthAngus/stardate/blob/master/paper/code/Praesepe.ipynb}}.\nAlthough this new model does not perfectly describe the rotation period of\nevery star, it provides a better representation of rotational evolution than\nprevious models such as the \\citet{angus2015} model (shown as the blue solid\nline in figure \\ref{fig:praesepe}).\n\\begin{figure}\n  \\caption{\n    The rotation periods of Praesepe members \\citep{douglas2016},\n    vs. their \\Gaia\\ colors (\\gcolor) with a broken power law model, fit to\n    these data.\n    The dashed line and shaded region shows the mean and variance model\n    described in equation \\ref{eqn:gyro} at 650 Myrs (lower model) and 4.56\n    Gyrs (upper model).\n    The solid blue line shows the \\citep{angus2015} gyrochronology relation at\n    650 Myrs (lower model) and 4.56 Gyrs (upper model).\n    Shaded regions show the 1$\\sigma$ range of the rotation period\n    model (equation \\ref{eqn:gyro}).\n    The rotation periods of stars bluer than around 0.56 dex and redder than\n    around 2.7 dex in \\gcolor\\ are modeled as a broad log-normal distribution\n    with a standard deviation of 0.5 dex, added to observational\n    uncertainties.\n    This figure was generated in a Jupyter notebook available at\n    \\url{https://github.com/RuthAngus/stardate/blob/master/paper/code/Fitting_Praesepe.ipynb}\n}\n  \\centering\n    \\includegraphics[width=1.1\\textwidth]{Praesepe.pdf}\n\\label{fig:praesepe}\n\\end{figure}\nIn order to fit a relation to Praesepe, we removed rotational outliers bluer\nthan \\gcolor\\ = 2.7 via sigma-clipping and fit a 5th-order polynomial to the\nremaining FGK and early M stars.\n\\racomment{We found that a 5th order polynomial provided a substantially\nbetter fit than lower-order polynomials, which were not able to capture the\nsharp `elbow’ in the rotation period-color relation. Additional orders\nprovided either a worse\nfit, tending towards extreme values at the boundaries, or diminishing returns\nin goodness-of-fit.}\nWe also fit a straight line to the late M dwarfs (\\gcolor\\ $>$ 2.7), to\ncapture the mass-dependent initial rotation periods of low mass stars\n\\citep{somers2017}.\nWe fit a separable straight line function to the period-age relation using\nthe ages of Praesepe and the Sun\\footnote{The fitting process was\nperformed in a Jupyter notebook available at\n\\url{https://github.com/RuthAngus/stardate/blob/master/paper/code/Fitting_Praesepe.ipynb}.}.\nThis new Praesepe-calibrated gyrochronology relation is,\n\\begin{equation}\n    \\log_{10}(P_\\mathrm{rot}) =\n    c_A\\log_{10}(t) +\n    \\sum_{n=0}^4 c_n[\\log_{10}(G_{BP}-G_{RP})]^n\n\\label{eqn:fgk_gyro}\n\\end{equation}\nfor stars with \\gcolor\\ $<$ 2.7 and\n\\begin{equation}\n    \\log_{10}(P_\\mathrm{rot}) =\n    c_A\\log_{10}(t) +\n    \\sum_{m=0}^1 b_m[\\log_{10}(G_{BP}-G_{RP})]^m\n\\label{eqn:m_gyro}\n\\end{equation}\nfor stars with \\gcolor\\ $>$ 2.7, where $P_{\\mathrm{rot}}$ is rotation period\nin days and $t$ is age in years.\nBest-fit coefficient values are shown in table \\ref{tab:coefficients}.\n\\begin{table}[h!]\n  \\begin{center}\n      \\caption{Coefficient values for equations \\ref{eqn:fgk_gyro} and\n      \\ref{eqn:m_gyro}.}\n    \\label{tab:coefficients}\n    \\begin{tabular}{l|c} % <-- Alignments: 1st column left and 2nd middle, with vertical lines in between\n      Coefficient & Value  \\\\\n      \\hline\n      $c_A$ & 0.65 $\\pm$ 0.05 \\\\\n      $c_0$ & -4.7 $\\pm$ 0.5 \\\\\n      $c_1$ & 0.72 $\\pm$ 0.05 \\\\\n      $c_2$ & -4.9 $\\pm$ 0.2 \\\\\n      $c_3$ & 29 $\\pm$ 2 \\\\\n      $c_4$ & -38 $\\pm$ 4 \\\\\n      $b_0$ & 0.9 $\\pm$ 0.5 \\\\\n      $b_1$ & -13.6 $\\pm$ 0.1 \\\\\n    \\end{tabular}\n  \\end{center}\n\\end{table}\n\nWe calibrated this new relation using Praesepe and the Sun alone, without\nincluding other clusters, because different open clusters have slightly\ndifferent period-color relationships \\citep{agueros2018, agueros2018b,\ncurtis2018, curtis2019} and, given that we used an age-color separable\nrelation, adding in extra clusters was unlikely to improve the calibration.\nWe did not include asteroseismic stars because most are slightly evolved and\nwould require a gyrochronology relation that depends on $\\log g$.\nThis new relation, fit to Praesepe and the Sun, does not perfectly predict the\nrotation periods of stars at all colors and ages, but it provides several\nimprovements over previous empirical gyrochronology relations.\nFirstly, it uses new \\ktwo\\ rotation period measurements to model the\nperiod-color relation of Praesepe in detail, secondly, it includes a model for\nthe rotational behavior of M dwarfs, and thirdly, it is calibrated to \\Gaia\\\n\\gcolor\\ color: a directly observable quantity and the most widely available\nphotometric color index.\n\nEquation \\ref{eqn:fgk_gyro}, describing the rotational evolution of FGK and\nearly M stars, is most closely analogous to previously calibrated empirical\ngyrochronology relations \\citep[\\eg][]{barnes2003, barnes2007, mamajek2008,\nbarnes2010, angus2015}.\nIt describes stars with Sun-like magnetic dynamos that follow a\n`Skumanich-like' magnetic braking law, \\ie\\ their rotation period increases\nwith the square root of their age.\nIt does not describe stars hotter than around 6250 K which have a thin\nconvective layers and a weak magnetic dynamo, nor does it describe fully\nconvective stars which take a long time to converge onto the\n\\citet{skumanich1972} braking law \\citep{krishnamurthi1997}.\nIn addition, stars with Rossby numbers larger than around 2 do not show\nSkumanich-like magnetic braking \\citep{vansaders2016, vansaders2018}, so\nequation \\ref{eqn:fgk_gyro} does not describe these stars.\nIt also does not describe the rotation periods of subgiants or giants, whose\nrotation periods are influenced by their expanding radii, changing winds, and\ncore-to-surface differential rotation \\citep[\\eg][]{vansaders2013, tayar2018}.\nFinally, this relation does not describe the rotation periods of dynamically\nor magnetically interacting binaries which often rotate more rapidly than\nisolated stars at the same age and color \\citep{douglas2016}.\nIn order to include non-Skumanich type stars in our combined gyrochronal and\nisochronal model, we designed a composite gyrochronology relation which\ndescribes a mean and variance model for the rotation period distributions\nacross the HRD.\nRotation periods are modeled differently for stars of different photometric\ncolor, EEP, Rossby number, age and metallicity.\nThe rotation period model for each of these groups is described below.\n\\begin{itemize}\n    \\item{The rotation periods of late F, GK, and early M dwarfs\n        (0.56 $<$ \\gcolor\\ $<$ 2.7), with Rossby numbers less than 2, are\n        modeled as a log-normal distribution, with mean given by equation\n        \\ref{eqn:fgk_gyro}, and variance given by the squared inverse of their\n        observational uncertainties.}\n    \\item{The rotation periods of fully convective stars (\\gcolor\\ $>$ 2.7)\n        are modeled with a log-normal distribution with mean given by equation\n        \\ref{eqn:m_gyro}, and an extra standard deviation of\n        0.5 dex, added to observational uncertainties.\n        This distribution reflects the observed rotation periods of late M\n        dwarfs in the Praesepe cluster which span a broad range at every\n        color.\n        Late M dwarfs with masses $\\lesssim$ 0.3 M$_\\odot$, temperatures\n        $\\lesssim$ 3500 and \\gcolor $\\gtrsim$ 2.7 exhibit weak magnetic\n        braking until at least after the age of Praesepe ($\\sim$650 million\n        years).\n    \\item{The rotation periods of F-type and hotter stars, with \\gcolor\\ $<$\n        0.56 dex, are modeled as a log-normal distribution with mean,\n        $\\log_{10}(P_\\mathrm{rot})=0.56$,\n        and an additional standard deviation, added to observational\n        uncertainties, of 0.5 dex.\n        Stars more massive than around 1.25 M$_\\odot$, with a temperature\n        $\\gtrsim$ 6250 K and a \\gcolor\\ $\\lesssim$ 0.56 do not spin down\n        appreciably over their main-sequence lifetimes because they do not\n        have the deep convective envelope needed to generate strong magnetic\n        fields.\n        This model for the mean and variance of hot star rotation periods is\n        based on stars hotter than 6250 K in the \\citet{mcquillan2014} sample,\n        which have a mean $\\log_{10}(P_\\mathrm{rot})$ of 0.56 dex and a\n        standard deviation of around 0.5 dex.}\n        Both hot and cool stars retain rotation periods that are similar to\n        their primordial distribution \\citep[see \\eg][]{matt2012,\n        somers2017}.}\n    \\item{The rotation periods of stars with large Rossby numbers are\n        modeled as follows.\n        The age at which a star's Rossby number would exceed 2 is calculated\n        by inverting equation \\ref{eqn:fgk_gyro}.\n        If a star's age is greater than this, its mean rotation period is\n        given by $P_\\mathrm{max} = 2/\\tau$, where $\\tau$ is the convective\n        turnover timescale, calculated via stellar mass using equation 11 from\n        \\citet{wright2011}.}\n    \\item{The rotation periods of subgiants are described with a log-normal\n        distribution with mean given by equation \\ref{eqn:fgk_gyro},\n        \\ref{eqn:m_gyro} or 0.56, depending on its color, and an additional\n        standard deviation of 5 dex.\n        This is not an accurate model of subgiant rotation\n        periods \\citep[see, \\eg][]{vansaders2013} but the highly\n        inflated variance makes it a weakly constraining one.\n        Isochrone fitting provides precise ages for subgiants, so by inflating\n        the variance of the gyrochronology relation at large EEP, we allow a\n        star's position on the HRD/CMD to dominate the age information over\n        its rotation period.\n        This is useful because we have not yet built an accurate rotation-age\n        relation for subgiants into our model.}\n    \\item{We model stars younger than around 250 Myrs with a log-normal\n        distribution with mean function given by equation \\ref{eqn:fgk_gyro},\n        \\ref{eqn:m_gyro} or 0.56, depending on it whether it has\n        an intermediate, red, or blue color respectively and a inflated\n        standard deviation of 0.5 dex.\n        Rotation periods in young open clusters show a large amount of scatter\n        because they have not yet converged onto the \\citet{skumanich1972}\n        spin-down sequence.}\n    \\item{Finally, we model stars with very low and high metallicites (-0.2\n        $>$ [Fe/H] $>$ 0.2) with a log-normal distribution with mean given by\n        equation \\ref{eqn:fgk_gyro}, \\ref{eqn:m_gyro} or 0.56, depending on\n        its color, and a standard deviation of 0.5 dex.\n        Gyrochronology is not calibrated at these extreme metallicities due to\n        a lack of suitable metal poor and rich calibration stars.\n        Rather than assume the same gyrochronology model can be na\\\"ively\n        applied to these stars, we take a more conservative approach and model\n        them with a broad Gaussian distribution.}\n\\end{itemize}\nInflating the variance of the rotation period distribtion for stars with\nnon-Skumanich magnetic braking behavior has two purposes: 1) in the cases of\nhot stars and fully convective stars, it allows the broad distributions of\nrotation periods observed in clusters and the field to be matched, and 2) it\ndown-weights the age-information provided by rotation periods in regions of\nthe HRD/CMD where rotation periods are not information-rich or the\ngyrochronology model is inaccurate or uncalibrated.\nIf the observational uncertainties on rotation periods are 5\\% on average,\nwhich corresponds to 0.05/$\\ln(10)$ $\\sim$ 0.02 dex, adding 0.5 amounts to\na 25$\\times$ increase in standard deviation, or a $\\sim$ 600$\\times$ increase\nin variance.\n% The variance on stellar ages inferred via gyrochronology is directly\n% proportional to the variance on rotation periods, so a 600$\\times$ increase\n% in period variance corresponds to a 600$\\times$ reduction in the\n% age-information provide by gyrochronology, a 600$\\times$ increase in\n% gyrochronal age variance and a 25$\\times$ increase in gyrochronal standard\n% deviation.\nSo, practically speaking, when the standard deviation is inflated to 0.5 dex\nor more, ages are almost entirely inferred via isochrone fitting.\n\n\nWe used the following composite gyrochronology model to infer ages from\nrotation periods,\n\\begin{equation}\n    \\log_{10}(P_\\mathrm{rot}) \\sim \\begin{cases}\n        \\mathcal{N}\\left[(\\ref{eqn:fgk_gyro}), (\\sigma+\\sigma_P)^2\\right], & Ro < 2,\n        0.56 < G_{BP} - G_{RP} < 2.7 \\\\\n        \\mathcal{N}[(\\ref{eqn:m_gyro}), (\\sigma+\\sigma_P)^2], & Ro < 2,\n        G_{BP} - G_{RP} > 2.7 \\\\\n        \\mathcal{N}[\\log_{10}(P_\\mathrm{max}), (\\sigma+\\sigma_P)^2],& Ro \\geq 2 \\\\\n        \\mathcal{N}[0.56, (\\sigma+\\sigma_P)^2],& G_{BP} - G_{RP} < 0.56,\n    \\end{cases}\n\\label{eqn:gyro}\n\\end{equation}\nwhere $\\sigma$ is the relative period uncertainty, divided by $\\ln(10)$, on\nindividual rotation period measurements and $\\sigma_P$ is an additional\nscatter that is a function of EEP, age, metallicity and color.\nIt takes a maximal value of 0.5 for hot stars and fully convective stars, 5\nfor subgiants and giants, and a minimal value of zero for late F, GK and early\nM dwarfs.\nThe variance model is shown in figure \\ref{fig:variance}.\nSigmoid functions were used to provide smooth transitions between regions of\nlow and high variance.\nSharp changes in variance would produce sharp changes in likelihood, which\nwould cause the posterior distributions over stellar parameters to be more\ndifficult to sample.\nThe sigmoid functions shown in figure \\ref{fig:variance} reach half their\nmaximum values at \\gcolor\\ = 0.56 and 2.5 for hot and cool stars respectively,\nEEP = 454 for subgiants, age = 250 Myrs for young stars, $[$M/H$]$ = -0.2 for\nmetal poor stars and 0.2 for metal rich stars.\nThe logistic growth rate, or steepness, of the sigmoid functions is 100\ndex$^{-1}$ for both color transitions, .2 EEP$^{-1}$ for the EEP transition,\n20 dex$^{-1}$ for the age transition and 5 dex$^{-1}$ for the both metallicity\ntransitions.\nThe additional standard deviation is additive, so if a star is \\eg\\ hot,\nevolved and metal poor, the additional standard deviation of its rotation\nperiod rises to 6.\n\n\\begin{figure}\n  \\caption{\n    The additional rotation period scatter, $\\sigma_P$, added to the\n    observational period uncertainties in the model (see equation\n    \\ref{eqn:gyro}).\n    The standard deviation was increased for early F and hotter\n    stars (\\gcolor $<$ 0.56), late M dwarfs (\\gcolor\\ $>$ 2.7) and evolved\n    stars (EEP $\\gtrsim$ 420) in order to down-weight the age-information\n    supplied\n    by rotation periods and reproduce observed rotation period distributions.\n    We also increased the variance for stars younger than around 250 Myrs,\n    because the rotation periods of these stars typically have not yet\n    converged onto a tight gyrochronology sequence, and for very high and low\n    metallicity stars (-0.2 $\\gtrsim$ [Fe/H] $\\gtrsim$ 0.2) because the\n    gyrochronology relations have not been calibrated at these extreme values.\n    Down-weighting the gyrochronal likelihood by the inverse variance\n    ($1/\\sigma^2$) allowed the ages of these stars to be mostly inferred\n    via isochrone fitting.\n    Sigmoid functions were used to provide smooth transitions between regions\n    of low and high variance.\n}\n  \\centering\n    \\includegraphics[width=1.\\textwidth]{variance}\n\\label{fig:variance}\n\\end{figure}\n\n\\subsection{Simultaneously fitting gyrochronology and isochrones}\nThe previous part of this section describes the model for the mean and\nvariance of rotation periods as a function of their ages (and colors, EEPs,\nmasses and metallicities).\nIn what follows, we describe how this model was combined with a stellar\nevolution model to infer stellar ages (and other parameters) via\ngyrochronology and isochrone fitting simultaneously.\nOur goal was to infer the age of a star from its observable properties by\nestimating the posterior probability density function (PDF) over age,\n\\begin{equation} \\label{eqn:eqn1}\n    % p(t|{\\bf m_x}, T_{\\mathrm{eff}}, \\log(g), \\hat{F},\n    p(t|{\\bf m_x}, P_{\\mathrm{rot}}, \\bar{\\pi}),\n\\end{equation}\nwhere $t$ is age, ${\\bf m_x}$ is a vector of\napparent magnitudes in various bandpasses,\n\\prot\\ is the rotation period and \\pmega\\ is parallax.\nSpectroscopic properties (\\teff, \\logg\\ and $\\mathrm{[Fe/H]}$) and/or\nasteroseismic parameters (\\dnu\\ and \\numax) may also be available for a star,\nin which case they would appear to the right of the `$|$' in the above\nequation since they are observables.\nIn order to calculate a posterior PDF over age, other stellar parameters must\nbe marginalized over.\nThese parameters are distance ($D$), V-band extinction ($A_V$), the\ninferred metallicity, $[M/H]$\\footnote{The inferred metallicity, [M/H] is a\nmodel parameter which is different to the {\\it observed} metallicity, [Fe/H]\nwhich would appear on the right side of the $`|'$ in equation \\ref{eqn:eqn1}.},\nand equivalent evolutionary phase (abbreviated to EEP or\n$E$).\nEEP is a dimensionless number ranging from around 200 for M dwarfs up\nto around 1600 for giants and is 355 for the Sun \\citep[see][]{dotter2016,\nchoi2016}.\nStars are defined as subgiants when their EEP exceeds 454.\nMass is uniquely defined by EEP, age and metallicity.\nThe marginalization involves integrating over these extra parameters,\n\\begin{eqnarray} \\label{eqn:bayes}\n    % & p(A|{\\bf m_x}, T_{\\mathrm{eff}}, \\log(g), \\hat{F},\n    & p(t|{\\bf m_x},\n    P_{\\mathrm{rot}}, \\bar{\\pi})\n\\\\ \\nonumber\n    % & \\propto \\int p({\\bf m_x}, T_{\\mathrm{eff}}, \\log(g), \\hat{F},\n    & \\propto \\int p({\\bf m_x},\n    P_\\mathrm{rot}, \\bar{\\pi}|\n    t, E, [M/H], D, A_V)~p(t)\\, p(E)\\, p([M/H])\\, p(D)\\, p(A_V)\\, \\mathrm{d}E\\,\n    \\mathrm{d}[M/H]\\, \\mathrm{d}D\\, \\mathrm{d}A_V.\n\\end{eqnarray}\nThis equation is a form of Bayes' rule,\n\\begin{equation} \\label{eqn:eqn2}\n\\mathrm{Posterior} \\propto \\mathrm{Likelihood} \\times \\mathrm{Prior},\n\\end{equation}\nwhere the likelihood of the data given the model is,\n\\begin{equation} \\label{eqn:full_likelihood}\n    % p({\\bf m_x}, T_{\\mathrm{eff}}, \\log(g), \\hat{F}, \\bar{\\pi},\n    p({\\bf m_x}, \\bar{\\pi}, P_{\\mathrm{rot}}|t, E, D, A_V, [M/H]),\n\\end{equation}\nand the prior PDF over parameters is,\n\\begin{equation} \\label{eqn:prior}\n    p(t)\\, p(E)\\, p(D)\\, p(A_V)\\, p([M/H]).\n\\end{equation}\nThe priors we used are described in the appendix.\n\nWe assumed that the process of magnetic braking is independent of hydrogen\nburning in the core, outside of the dependencies that are captured in the\nmodel.\nThis assumption allowed us to multiply two separate likelihood\nfunctions together: one computed using an isochronal model and one computed\nusing a gyrochronal model.\nWe assumed that the probability of observing the measured observables given\nthe model parameters was a Gaussian and that the observables were identically\nand independently distributed.\nThe isochronal likelihood function was,\n\\begin{eqnarray} \\label{eqn:isochrones_only_likelihood}\n    % & \\mathcal{L_{\\mathrm{iso}}} = p({\\bf m_x}, T_{\\mathrm{eff}}, \\log(g),\n    & \\mathcal{L_{\\mathrm{iso}}} = p({\\bf m_x},\n    \\bar{\\pi}|t, E, [M/H], D,\n    A_V) \\\\ \\nonumber\n    & = \\frac{1}{\\sqrt{(2\\pi)^n \\det(\\Sigma)}}\n    \\exp\\left( -\\frac{1}{2} ({\\bf O_I} - {\\bf I})^T \\Sigma ^{-1}\n    ({\\bf O_I} - {\\bf I})\\right),\n\\end{eqnarray}\nwhere ${\\bf O_I}$ is the vector of n observables: \\pmega, ${\\bf m_x}$ plus\nspectroscopic and/or asteroseismic observables if available, and $\\Sigma$ is\nthe covariance matrix of that set of observables.\n${\\bf I}$ is the vector of {\\it model} observables that correspond to a set of\nparameters: $t$, $E$, $[M/H]$, $D$ and $A_V$, calculated using an isochrone model.\nWe assumed there is no covariance between these observables and so this\ncovariance matrix consists of individual parameter variances along the\ndiagonal with zeros everywhere else.\nThe gyrochronal likelihood function was,\n\\begin{eqnarray} \\label{eqn:gyro_likelihood}\n    & \\mathcal{L_{\\mathrm{gyro}}} = p(P_\\mathrm{rot} |t, E, [M/H], D, A_V) \\\\ \\nonumber\n    & = \\frac{1}{\\sqrt{(2\\pi) \\det(\\Sigma_P)}}\n    \\exp\\left( -\\frac{1}{2} ({\\bf P_O} - {\\bf P_P})^T \\Sigma_P ^{-1}\n    ({\\bf P_O} - {\\bf P_P})\\right),\n\\end{eqnarray}\nwhere ${\\bf P_O}$ is a 1-D vector of observed logarithmic rotation periods,\nand ${\\bf P_P}$ is the vector of corresponding logarithmic rotation periods,\npredicted by the model.\n$\\Sigma_P$ was comprised of individual rotation period measurement\nuncertainties, plus an additional variance that is a function of EEP and\n\\gcolor\\\ncolor, added in quadrature.\nThis variance accounts for the stochastic nature of the rotation periods of\nvery hot and very cool stars and allowed us to predominantly use isochrone\nfitting to measure the ages of subgiants.\nThe full likelihood used in our model was the product of these two likelihood\nfunctions,\n\\begin{equation}\n    \\mathcal{L}_{\\mathrm{full}} = \\mathcal{L}_{\\mathrm{iso}} \\times\n    \\mathcal{L}_{\\mathrm{gyro}}.\n\\end{equation}\n\nThe inference processes proceded as follows.\nFirst, a set of parameters: age, EEP, metallicity, distance and extinction,\nand observables for a single star were passed to the isochronal likelihood\nfunction in equation \\eqref{eqn:isochrones_only_likelihood}.\nThen, a set of observables corresponding to those parameters were generated\nfrom the MIST model grid using {\\tt isochrones.py} \\citep{isochrones} and\ncompared to the measured observables via the isochronal likelihood,\n$\\mathcal{L}_{\\mathrm{iso}}$ (also computed using {\\tt isochrones.py}).\nThe parameters were also passed to the gyrochronology model (equation\n\\ref{eqn:gyro}) where $t$, $E$,\n$[M/H]$, $D$ and $A_V$ were used to calculate \\gcolor\\ color and mass from the\nMIST model grid and, in turn, rotation period via the gyrochronology model.\nEEP and \\gcolor\\ were also used to calculate the additional rotation period\nvariance, added to the individual period uncertainties.\nThis model rotation period was compared to the measured rotation period using\ngyrochronal likelhood function of equation \\ref{eqn:gyro_likelihood}.\nThe gyrochronal log-likelihood was added to the isochronal log-likelihood to\ngive the full likelihood, which was then added to the log-prior to produce a\nsingle sample from the posterior PDF.\n\nAges were inferred with \\sd\\ using Markov Chain Monte Carlo.\nThe joint posterior PDF over age, mass, metallicity, distance and extinction\nwas sampled using the affine invariant ensemble sampler, {\\tt emcee}\n\\citep{foreman-mackey2013} with 50 walkers.\nSamples were drawn from the posterior PDF until 100 {\\it independent} samples\nwere obtained.\nWe actively estimated the autocorrelation length, which indicates how many\nsteps were taken per independent sample, after every 100 steps using the\nautocorrelation tool built into {\\tt emcee}.\nThe MCMC concluded when {\\it either} 100 times the autocorrelation length was\nreached and the change in autocorrelation length over 100 samples was less\nthan 0.01, {\\it or} the maximum of 500,000 samples was obtained.\nThis method is trivially parallelizable, since the inference process for each\nstar can be performed on a separate core.\nThe age of a single star can be inferred in around 1 hour on a laptop\ncomputer.\n", "meta": {"hexsha": "d3c327c4081a45ce837dc679b06883e2a47173e4", "size": 24802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/method.tex", "max_stars_repo_name": "john-livingston/stardate", "max_stars_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-02-19T13:46:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-31T23:46:36.000Z", "max_issues_repo_path": "paper/method.tex", "max_issues_repo_name": "john-livingston/stardate", "max_issues_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-02-21T21:37:05.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-09T10:38:15.000Z", "max_forks_repo_path": "paper/method.tex", "max_forks_repo_name": "john-livingston/stardate", "max_forks_repo_head_hexsha": "5c0d45c1e2eb9ec5b6c57aeacbcb301304065bbc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2019-02-11T02:46:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T22:16:53.000Z", "avg_line_length": 54.3903508772, "max_line_length": 105, "alphanum_fraction": 0.7385291509, "num_tokens": 6824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4050514695886537}}
{"text": "\\section{Quantitative Results}\nThe system outlined here performs quite well, even on somewhat difficult questions.\nFor example, for the questions ``Mary earns \\$46 cleaning a home. How many homes did she clean, if she made 276 dollars?''\nthe system is able to correctly identify that ``\\$46'' should be multiplied by ``x homes'' (remember that variables are instantiated by ``much-many\\_a\\_rel'' predicates, and they are associated with the ARG1 entity, here ``homes'').\nHere, the system can use only the distance between the entity noun vectors and the verbs associated with each, as no other abstract predications obtain (besides ``much-many\\_a\\_rel'', common to all variables regardless of operation). \n\nHowever, the system does still make many significant errors. \nFor the questions ``There are 8 calories in a candy bar. How many calories are there in 3 candy bars?'' \nthe system erroneously predicts that ``x calories'' should be subtracted from ``3 candy bars'', whereas in a correct equation the latter would be divided by the former. \nThis error is in part due to the fact that ``3 candy bars'' is not associated with any verbal predication, and ``x calories'' is only associated with a relatively neutral ``\\_be\\_v\\_there\\_rel'' verbal predication. \nHowever, according to the parse, the ARG1 of the ``\\_in\\_p\\_rel'' associated with the candy bars is the ARG0 of the verbal predicate associated with the calories. \nAt present, our system is not capable of exploring such connections between event predicates, but we plan to improve this in future work. \n\n\n\\section{Conclusion}\nThis paper has presented a method for utilizing Minimal Recursion Semantics for improving a math word problem solving system. \nWe show that with limited adaptation to the math word problem domain, we can achieve a 3.0\\% absolute improvement in operator prediction accuracy compared to a previous state-of-the-art semantic-based technique.\nFurthermore, the techniques for relating entities across sentences discussed here are more applicable to other domains besides math word problems due to the general nature of the semantic representation over which they work. \nFinally, we make our code available to the public to support further development of applications which take advantage of Minimal Recursion Semantics.\n", "meta": {"hexsha": "b458b3832bf89539bdadd9b85b6df06056c02b5a", "size": 2301, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/discussion.tex", "max_stars_repo_name": "rikkarikka/groundRefEv", "max_stars_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-07-11T18:56:57.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-11T18:56:57.000Z", "max_issues_repo_path": "paper/discussion.tex", "max_issues_repo_name": "rikkarikka/groundRefEv", "max_issues_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/discussion.tex", "max_forks_repo_name": "rikkarikka/groundRefEv", "max_forks_repo_head_hexsha": "c60895262f48c159876935741b03363e74a146f6", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 115.05, "max_line_length": 234, "alphanum_fraction": 0.7922642329, "num_tokens": 473, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.40505146345970056}}
{"text": "\\documentclass[journal, letterpaper]{IEEEtran}\n%\\documentclass{scrartcl}\n\n\\usepackage[ngerman,english]{babel}\n%\\usepackage[latin1]{inputenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{verbatim}\n\\usepackage{subcaption}\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\\usepackage[pdftex]{hyperref}\n\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmiccomment}[1]{\\ \\ // #1} % C-like // Comments\n\n\\hyphenation{render}\n\n% No clubs and widows allowed\n\\clubpenalty10000\n\\widowpenalty10000\n\\displaywidowpenalty=10000\n\n\\begin{document}\n\n%\\title{Simulating elastic spheres without external forces}\n%\\subtitle{Project 1 for class CS6491 Computer Graphics}\n\\title{Swirl\\\\\n\t{\\large Project 2 for class CS6491 Computer Graphics}}\n%\\author{Sebastian Weiss}\n\\author{Sebastian Weiss, Kristian Eberhardson\\\\ \\today}\n%\\date{\\today}\n\n\\maketitle\n\n\\begin{tikzpicture}[remember picture,overlay]\n   \\node[anchor=north east,inner sep=0pt] at (current page.north east)\n              {\\includegraphics[scale=1]{pic}};\n\\end{tikzpicture}\n\\begin{tikzpicture}[remember picture,overlay]\n   \\node[anchor=north west,inner sep=10pt] at (current page.north west)\n              {\\includegraphics[scale=0.4]{pictures/P4.png}};\n\\end{tikzpicture}\n\n\\section{Objective}\nWe are provided with a starting and ending frame in 3D, called $A_0$ and $A_1$. We wish to create a continuous, affine and steady motion which interpolates $A_0$ and $A_1$.\n \n\\section{Input}\nThe Frames $A_0$ and $A_1$ consist of a point $P_i$ and a right hand coordinate system of orthogonal vectors $I_i$, $J_i$, and $K_i$, each of the same length ($i \\in \\{0,1\\}$). All vectors are three dimensional.\n\\subsection{Terms} \n1. An \\underline{affine} transformation in three dimensions can be expressed as a 4x4 matrix multiplied onto a point or a vector, is reversible, and can be expressed solely as a combination of rotation, translation, scaling and shearing. In this work, we only concentrate on rotation, translation and scaling.\n\\newline\n2. A \\underline{continuous} transformation is one in which $\\forall \\epsilon>0 \\\\ \\exists \\delta>0 \\; : \\; |P_x - P_y|<\\epsilon \\; \\forall x,y \\; \\text{with} \\; |x-y|<\\delta$. $P_x$ and $P_y$ denotes the interpolated point at time $x$ and $y$. Intuitively, this means we can draw the motion with a pen in a single stroke.\n\\newline\n3. A \\underline{steady} transformation is independent of the time t and the velocities are constant over time. \n\n\\section{Related interpolation schemes}\n\n\\subsection{Logarithmic spiral in 2D}\nIn 2D, a frame is given by three two-dimensional vectors. Prof. Rossignac proposes a combination of a linear rotation and an exponential scaling to realize a steady interpolation between two dimensional frames, see Fig. \\ref{fig:P6}.\nThe formula for this approach is the following:\n\\begin{equation}\n P(t) := F + m^t FP_0 ^{\\;\\circ} (\\alpha t)\n\\label{eq:logSpiral}\n\\end{equation}\n$FP_0 ^{\\;\\circ} (\\alpha t)$ denotes the normal 2d rotation of the vector $FP_0$ around the origin with the angle $\\alpha t$.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.4]{pictures/P6.png}\n\t\\caption{log spiral in 2D}\n\t\\label{fig:P6}\n\\end{figure}\n\n\\subsection{Linear interpolation in 3D}\nFor all points in $A_0$, draw a straight line to its corresponding point in $A_1$. Motion is simply moving the frame along these lines.  This is neither an elegant solution nor is it steady.\n\n\\section{Proposed model}\nWe wish to create a swirling motion in 3D related to the logarithmic spiral in 2D. Therefore, we are using a combination of linear rotation around the rotation axis $N$ with the origin in $F$ and an exponential scaling with the factor $m$. We propose the following formula:\n\\begin{equation}\n P(t) := F + m^t FP_0 ^{\\;\\circ} (\\alpha t; N)\n\\label{eq:Interpolation}\n\\end{equation}\nSince the rotation and scaling are steady on its own and these operations commute, the final motion is also steady.\n\n\\subsection{3D rotation}\nA rotation in 2D is very straightforward because there is no choice of the rotation axis. In 3D we are given the rotation axis and rotate around it in the following way:\n\n\\begin{equation}\n\\begin{array}{lcl}\n X^{\\circ}(\\alpha; N) &:=& W + U^{\\circ}(\\alpha; N) \\\\\n                        & =& W + \\cos \\alpha U - \\sin \\alpha (N \\times U) \\\\\n \\multicolumn{3}{l}{\\text{with } W := W\\angle\\underline{N} = (W\\bullet\\underline{N})\\underline{N}} \\\\\n \\multicolumn{3}{l}{\\text{and } U = X-W}\n\\end{array}\n\\label{eq:Rotation}\n\\end{equation}\n\nFig. \\ref{tikz:Rot} visualizes the rotation around the axis $N$ in 3D.\n\n\\begin{figure}[H]\n\\centering\n\\begin{tikzpicture}\n\t\\filldraw[color=white,fill=blue!20,fill opacity=0.5] (-3,-1.5) -- (2,-1.5) -- (3,1.5) -- (-2,1.5) -- cycle;\n\t\\draw[color=orange] (-0.5,0) arc (-180:-61.7:0.5);\n\t\\draw[line width=1mm,color=black!60,->] (0,0) -- (-1.5,0);\n\t\\draw[line width=1mm,color=black!60,->] (0,0) -- (0.7,-1.3);\n\t\\draw[line width=1mm,dotted,color=black!50] (-1.5,0) -- (-1.5,1);\n\t\\draw[line width=1mm,dotted,color=black!50] (0.7,-1.3) -- (0.7,0.5);\n\t\\draw[line width=1.5mm,color=green,->,line cap=round] (0,0) -- (-1.5,1);\n\t\\draw[line width=1.5mm,color=red,->,line cap=round] (0,0) -- (0.7,0.5);\n\t\\draw[line width=1.5mm,color=black,->,line cap=round] (0,0) -- (0,2);\n\t\\node at (0.4,2) {$N$};\n\t\\node at (-0.7,1) {$FP_0$};\n\t\\node at (1.7,0.7) {$FP_1=FP_0 ^{\\;\\circ} (\\alpha; N)$};\n\t\\node at (-1.8,0.5) {$W$};\n\t\\node at (1,-0.4) {$W$};\n\t\\node at (-0.75,-0.3) {$U$};\n\t\\node at (0.1,-0.9) {$U$};\n\t\\node[color=orange] at (-0.35,-0.6) {$\\alpha$};\n\\end{tikzpicture}\n\\caption{3D-Rotation}\n\\label{tikz:Rot}\n\\end{figure}\n\n\n\\subsection{Calculating $N$, $\\alpha$ and $m$}\nSince $m$ is the scaling factor, it is calculated as:\n\\begin{equation}\n m := |I_1| / |I_0|\n\\label{eq:m}\n\\end{equation}\nBecause $I_i$, $J_i$, and $K_i$ are of the same length for each $i$, it does not matter which we use. \n \nTo calculate the rotation axis $N$, we first define \n\\begin{equation}\n\\Delta I:= I_1 - I_0, \\ \\Delta J := J_1 - J_0, \\ \\Delta K := K_1 - K_0\n\\end{equation}\nThen we pick the largest vector in the euclidean norm out of \n\\begin{equation}\nN_a := \\Delta I \\times \\Delta J, \\ N_b := \\Delta I \\times \\Delta K, \\ N_c := \\Delta J \\times \\Delta K\n\\end{equation}\nWe call the largest vector $N$. Since $I_i$, $J_i$ and $K_i$ form an orthogonal basis, these vectors all point in the same direction and differ only in the scaling. The reasons for choosing the largest one are numerically issues. Some of these $N$'s can be very small when the rotation axis is almost parallel to the frame axes, they are zero if they are exactly parallel. The special case when all $N$'s are zero, so $\\Delta I$, $\\Delta J$ and $\\Delta K$ are all zero, happens if there is no rotation at all. See section \\ref{NoRot} on how to deal with this case. In the later computation, we always need the normalized vector $\\underline{N}:=N/|N|$.\n  \nFurthermore, we need the rotation angle $\\alpha$. To compute this angle, we first project each basis vector into the plane defined by $\\underline{N}$ and normalize them:\n\\begin{equation}\n\\begin{array}{lcl}\n proj(X) &:=& X - X\\angle\\underline{N} = X - (X \\bullet \\underline{N})\\underline{N} \\\\\n norm(X) &:=& X / |X| \\\\\n B' &:=& norm(proj(B_i)) \\ \\forall B \\in \\{I_0,...,K_1\\}\n\\end{array}\n\\label{eq:ProjBasis}\n\\end{equation}\nThe $B'$-vectors correspond to normalized versions of the $U$-vectors in Fig. \\ref{tikz:Rot}.\nThen we define\n\\begin{equation}\n \\alpha = \\max \\{ \\cos^{-1}(I_0' \\bullet I_1'), \\cos^{-1}(J_0' \\bullet J_1'), \\cos^{-1}(K_0' \\bullet K_1') \\}\n\\label{eq:}\n\\end{equation}\nWe take the maximum angle here because all angles are equal by the definition of $N$. At most one of these angles can be zero, this happens in the case if the rotation axis is exactly orthogonal to that frame axis, see Fig. \\ref{fig:P1}.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.4]{pictures/P1.png}\n\t\\caption{rotation parallel to a frame axis}\n\t\\label{fig:P1}\n\\end{figure}\n\n\\subsection{Calculating $F$}\nNow we have $N$, $\\alpha$ and $m$ and we can compute $F$ now by solving the equation system\n\\begin{equation}\n P_1 = P(1) := F + m FP_0 ^{\\;\\circ} (\\alpha; N)\n\\label{eq:Feq}\n\\end{equation}\nThis system is a linear system in the three variables $F_x$, $F_y$ and $F_z$. We obtain an explicit formulation for $F$ by converting it into matrix form, solving it using Cramer's Rule and applying simplification. For purposes of notation, we introduce the following variables for the vector components: $P_0=(P_{0,x},P_{0,y},P_{0,z})^T, P_1=(P_{1,x},P_{1,y},P_{1,z})^T,\\\\ \\underline{N}=(N_x,N_y,N_z)^T$.\n\\begin{equation}\n\\begin{array}{lcl}\n\tF_x &=& (m P_{0,x} + m^3 P_{0,x} - P_{1,x} - m^2 P_{1,x} \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,x} - P_{1,x}) N_y^2 \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,x} - P_{1,x}) N_z^2 \\\\\n\t\t&& - m (1+m) (\\cos\\alpha - 1) (P_{0,y} - P_{1,y}) N_x N_y \\\\\n\t\t&& - m (1+m) (\\cos\\alpha - 1) (P_{0,z} - P_{1,z}) N_x N_z \\\\\n\t\t&& - m (m-1) \\sin\\alpha (P_{0,y} - P_{1,y}) N_z \\\\\n\t\t&& + m (m-1) \\sin\\alpha (P_{0,z} - P_{1,z}) N_y \\\\\n\t\t&& - 2 m^2 P_{0,x} \\cos\\alpha + 2 m P_{1,x} \\cos\\alpha ) \\\\\n\t\t&& / (m-1)(1 + m^2 - 2m\\cos\\alpha)\n\\end{array}\n\\label{eq:Fx}\n\\end{equation}\n\\begin{equation}\n\\begin{array}{lcl}\n F_y &=& -(m^2 P_{0,y} - m^3 P_{0,y} + P_{1,y} - m P_{1,y} \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,x} - P_{1,x}) N_x N_y \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,y} - P_{1,y}) N_y^2 \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,z} - P_{1,z}) N_y N_z \\\\\n\t\t&& - m (m-1) \\sin\\alpha (P_{0,x} - P_{1,x}) N_z \\\\\n\t\t&& + m (m-1) \\sin\\alpha (P_{0,z} - P_{1,z}) N_x \\\\\n\t\t&& - m P_{0,y} \\cos\\alpha + m^2 P_{0,y} \\cos\\alpha \\\\\n\t\t&& - m P_{1,y} \\cos\\alpha + m^2 P_{1,y} \\cos\\alpha) \\\\\n\t\t&& / (m-1)(1 + m^2 - 2m\\cos\\alpha)\n\\end{array}\n\\label{eq:Fy}\n\\end{equation}\n\\begin{equation}\n\\begin{array}{lcl}\n F_z &=& -(m^2 P_{0,z} - m^3 P_{0,z} + P_{1,z} - m P_{1,z} \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,x} - P_{1,x}) N_x N_z \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,y} - P_{1,y}) N_y N_z \\\\\n\t\t&& + m (1+m) (\\cos\\alpha - 1) (P_{0,z} - P_{1,z}) N_z^2 \\\\\n\t\t&& - m (m-1) \\sin\\alpha (P_{0,y} - P_{1,y}) N_x \\\\\n\t\t&& + m (m-1) \\sin\\alpha (P_{0,x} - P_{1,x}) N_y \\\\\n\t\t&& - m P_{0,z} \\cos\\alpha + m^2 P_{0,z} \\cos\\alpha \\\\\n\t\t&& - m P_{1,z} \\cos\\alpha + m^2 P_{1,z} \\cos\\alpha) \\\\\n\t\t&& / (m-1)(1 + m^2 - 2m\\cos\\alpha)\n\\end{array}\n\\label{eq:Fz}\n\\end{equation}\nFor the implementation, we strongly suggest to further factorize these formulas and to store the common intermediate results.\n\n\\subsection{Dealing with special cases}\nThe proposed model contains two singularities in the computations: \nFirst, $N$ is the zero vector when the rotation between the two input frames is zero.\nSecond, $F$ goes to infinity when $m$ goes to one, since the translation of the frames rely on the scaling.\n\n\\subsubsection{No translation}\nStrictly speaking, this case is no special case at all. When there is no translation, $P_0$, $P_1$ and $F$ are all at the same position, see Fig. \\ref{fig:P8}. This model handles this case without further additions.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.4]{pictures/P8.png}\n\t\\caption{no translation}\n\t\\label{fig:P8}\n\\end{figure}\n\n\\subsubsection{No rotation, but scaling}\\label{NoRot}\nIn the case that there is no rotation, the rotation axis $N$ is the zero vector and the rotation angle $\\alpha$ is also zero.\nThe translation is then realized by the scaling, see Fig. \\ref{fig:P2}. The fixpoint $F$ is calculated as usual. Intuitively, this is the intersection point of the lines connecting the tips of the arrows and the frame origin from the start frame to the end frame.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.4]{pictures/P2.png}\n\t\\caption{no rotation, translation by scaling}\n\t\\label{fig:P2}\n\\end{figure}\n\n\\subsubsection{No rotation, no scaling}\nIf we start with the case presented in the previous section and let $m$ run to 1, the fixpoint $F$ runs against infinity. We therefore observe that the case of no rotation and no scaling degenerates to a linear interpolation with pure translation, see Fig. \\ref{fig:P5}.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.4]{pictures/P5.png}\n\t\\caption{pure translation}\n\t\\label{fig:P5}\n\\end{figure}\n\n\\subsubsection{No scaling, but rotation and translation}\nIf the scaling factor $m$ is 1, $F$ goes to infinity. The swirl degenerates to a circular movement in the rotation plane plus a linear translation orthogonal to the rotation plane. The swirl is therefore a perfect spiral, see Fig. \\ref{fig:P7}.\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.3]{pictures/P7.png}\n\t\\caption{no scaling, but rotation and translation}\n\t\\label{fig:P7}\n\\end{figure}\nThis special case can be implemented by projecting the frames in the rotation plane, solving the circular motion there equivalent to the Logarithmic Spiral in 2D and then adding a translation orthogonal to the rotation plane.\n\n\\section{Implementation}\nWe provide a framework for playing around with our Swirl Implementation. You can rotate the camera and scale it. Furthermore, the start and end frame can be modified by clicking and dragging the center of the frames or the tips of the frame axes. Additionally, you can select if you want to display the rotation axis $N$ (gray line) and the fixpoint $F$ (gray sphere on the rotation axis) and if the extrapolating frames should be drawn or not. \n\nA typical swirl produced by our program is shown in Fig. \\ref{fig:P3}. You can see how the motion is attracted by the fixpoint $F$.\n\n\\begin{figure}\n\t\\centering\n\t\t\\includegraphics[scale=0.3]{pictures/P3.png}\n\t\\caption{swirl motion is attracted by the fixpoint $F$}\n\t\\label{fig:P3}\n\\end{figure}\n\n\\section{Future work}\nAs an extension to this work, we could include shearing in the interpolation model. With shearing, every affine transformation would be supported.\n\n\\end{document}", "meta": {"hexsha": "0bb256cc82b5687ee974c1a0bcfded864b28cbee", "size": 13879, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/Project2.tex", "max_stars_repo_name": "shamanDevel/Swirl", "max_stars_repo_head_hexsha": "6ad0a2badda87877dd99f202d0e5b94455a5e792", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/Project2.tex", "max_issues_repo_name": "shamanDevel/Swirl", "max_issues_repo_head_hexsha": "6ad0a2badda87877dd99f202d0e5b94455a5e792", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Paper/Project2.tex", "max_forks_repo_name": "shamanDevel/Swirl", "max_forks_repo_head_hexsha": "6ad0a2badda87877dd99f202d0e5b94455a5e792", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5678571429, "max_line_length": 651, "alphanum_fraction": 0.689530946, "num_tokens": 4631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.4050514603952239}}
{"text": "\\documentclass{article}\n\\usepackage{tocloft}\n\\include{common_symbols_and_format}\n\\renewcommand{\\cfttoctitlefont}{\\Large\\bfseries}\n\n\\begin{document}\n\\logo\n\\rulename{Percentage Volume Oscillator} %Argument is name of rule\n\\tblofcontents\n\n\\ruledescription{The percentage volume oscillator (PVO) is a momentum indicator that measures the difference between two moving averages as a percentage of the larger moving average. The fast moving average uses a lower period, and is thus more reactive to changes in volume. The slow moving average uses a faster period and is therefore less reactive. The PVO is positive when the shorter volume EMA is above the longer volume EMA and negative when the shorter volume EMA is below. This indicator can be used to define the ups and downs for volume, which can then be used to confirm or refute other signals. A bullish reversal of an asset is identify when the PVO cross above zero line. And a bearish reversal when the PVO cross below the zero line.\n}\n\n\\howtotrade\n{The strategy is to identify Bullish and Bearish Reversal.\nBullish Reversal - when PVO is above zero \\&\nBearish Reversal - when PVO is below zero.\n}\n\n\\ruleparameters %You can include however many arguments (in groups of 4) as you want!\n{Short term look back Length}{12}{Short term look back length used to compute EMA.}{$\\lookbacklength_{s}$}\n{Long term look back Length}{26}{Long term look back length used to compute EMA.}{$\\lookbacklength_{l}$}\n{Signal look back Length}{9}{Look back length used to generate Signal line.}{$S_{l}$}\n\\stoptable %must be included or Tex engine runs infinitely\n\n\\newpage\n\\section{Equation}\nBelow are the equations which govern how this specific trading rule calculates a trading position.\n\n\\begin{equation}\n    PVO = \\frac{EMA(\\lookbacklength_{s}) -         EMA(\\lookbacklength_{l})}{EMA(\\lookbacklength_{l})} \\times 100\n\\end{equation}\n\\begin{equation}\n    Signal = EMA(S_{l})\n\\end{equation}\n\\begin{equation}\n    PVO_{hist} = PVO - Signal\n\\end{equation}\n\\\\ % creates some space after equation\nwhere:\n\n$EMA(\\lookbacklength_{s})$: is the short term exponentially weighted volume average.\n\n$EMA(\\lookbacklength_{l})$: is the long term exponentially weighted volume average.\n\n$EMA(S_{l})$: is the exponentially weighted volume average computed to generate signal line.\n\n$PVO_{hist}$: is the Percentage Volume Oscillator histogram.\n\n\\keyterms\n\\furtherlinks %The footer\n\\end{document}", "meta": {"hexsha": "36184d6df6044f46b905f7e828c46ef431a61e81", "size": 2412, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/strategies/tex/PercentageVolumeOscillator.tex", "max_stars_repo_name": "parthgajjar4/infertrade", "max_stars_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2021-03-25T13:32:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-06T23:03:01.000Z", "max_issues_repo_path": "docs/strategies/tex/PercentageVolumeOscillator.tex", "max_issues_repo_name": "parthgajjar4/infertrade", "max_issues_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 137, "max_issues_repo_issues_event_min_datetime": "2021-03-25T10:59:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-28T19:36:30.000Z", "max_forks_repo_path": "docs/strategies/tex/PercentageVolumeOscillator.tex", "max_forks_repo_name": "parthgajjar4/infertrade", "max_forks_repo_head_hexsha": "2eebf2286f5cc669759de632970e4f8f8a40f232", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2021-03-26T14:26:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-10T18:21:14.000Z", "avg_line_length": 46.3846153846, "max_line_length": 750, "alphanum_fraction": 0.7736318408, "num_tokens": 611, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632683808533, "lm_q2_score": 0.7461389873857265, "lm_q1q2_score": 0.40505144935859577}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\\usepackage[export]{adjustbox}[2011/08/13]\n\\usepackage{float}\n\\usepackage{hyperref}\n\\usepackage{setspace}\n\\usepackage{fullpage}\n\n\\hypersetup{colorlinks=true}\n\n% shortcuts for covariant basis vectors\n\\newcommand{\\er}{{\\mathbf e}_{\\rho}}\n\\newcommand{\\ev}{{\\mathbf e}_{\\vartheta}}\n\\newcommand{\\ez}{{\\mathbf e}_{\\zeta}}\n\n\\bibliographystyle{ieeetr}\n\n\\title{APC 524 Design Document}\n\\author{Daniel Dudt, Dario Panici, Evan Yerger}\n\\date{December 15, 2020}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Background}\n\n\\subsection{Motivation}\n\nDetermining the equilibrium of a plasma is crucial for the design and operation of magnetic confinement fusion reactors.\nEquilibrium calculations are used for understanding basic plasma physics, interpreting diagnostic data from experiments, running real-time control systems to stabilize the plasma, and for optimizing the design of future machines.\nMost mainstream magnetic confinement concepts for controlled fusion involve toroidal reactors, such as the tokamak and stellarator.\nThe tokamak is characterized by toroidal symmetry, while the stellarator does not have an ignorable coordinate and is fully ``three-dimensional''.\nThe nonlinear partial differential equations that describe an equilibrium are computationally challenging to solve, especially for the complicated geometries of stellarators.\nExisting codes such as VMEC \\cite{Hirshman1983} are expensive to run and do not always converge to the desired result, making them poorly equipped for future progress.\nDESC \\cite{Dudt2020} is a modern code designed to meet the increasing demands of advanced stellarator performance, and the goal of this project is to make significant contributions to the development of DESC.\n\n\\subsection{Theory}\n\\label{sec:theory}\n\nIdeal magnetohydrodynamics (MHD) is a single-fluid model of plasma.\nIt describes the equilibrium of a static plasma through a force balance equation, along with Amp\\`ere's and Gauss's laws:\n%\n\\begin{subequations}\n  \\label{eq:equil}\n  \\begin{align}\n    \\label{eq:momentum}\n    \\mathbf{J} \\times \\mathbf{B} &= \\nabla p \\\\\n    \\label{eq:Ampere}\n    \\nabla \\times \\mathbf{B} &= \\mu_0 \\mathbf{J} \\\\\n    \\label{eq:Gauss}\n    \\nabla \\cdot \\mathbf{B} &= 0.\n  \\end{align}\n\\end{subequations}\n%\nHere $\\mathbf{J}$ is the current density, $\\mathbf{B}$ is the magnetic field, $p$ is the plasma pressure, and $\\mu_0$ is the magnetic constant.\nCombining the force balance (\\ref{eq:momentum}) and  Amp\\`ere's Law (\\ref{eq:Ampere}), a force balance error $\\mathbf{F}$ can be defined as\n%\n\\begin{equation}\n  \\label{eq:F}\n  \\mathbf{F} \\equiv \\frac{1}{\\mu_0} \\left( \\nabla \\times \\mathbf{B} \\right) \\times \\mathbf{B} - \\nabla p = F_\\rho \\nabla\\rho + F_\\beta \\mathbf{\\beta} = \\mathbf{0}\n\\end{equation}\n%\nwhere $\\mathbf{\\beta} \\equiv B^\\zeta \\nabla \\vartheta - B^\\vartheta \\nabla \\zeta$.\nThe flux coordinate system $(\\rho,\\vartheta,\\zeta)$ is a specific choice that makes the magnetic field lines ``appear straight'' to simplify calculations, and is related to the usual toroidal coordinates $(R,\\phi,Z)$ as shown in Figure \\ref{fig:coords}.\nEquation (\\ref{eq:F}) is a system of nonlinear partial differential equations (PDEs) and it must be satisfied throughout the entire plasma volume when in equilibrium.\nUsing Gauss's law (\\ref{eq:Gauss}) and assuming that nested flux surfaces exist $\\mathbf{B}\\cdot\\nabla\\rho=B^\\rho=0$, the magnetic field can be expressed in the following contravariant form of the flux coordinate system $(\\rho,\\vartheta,\\zeta)$:\n%\n\\begin{equation}\n  \\label{eq:B}\n  \\mathbf{B} = B^\\vartheta \\ev + B^\\zeta \\ez = \\frac{\\partial_\\rho \\Psi}{2\\pi \\sqrt{g}} \\left( \\iota \\ev + \\ez \\right).\n\\end{equation}\n%\nHere $\\Psi$ is the toroidal magnetic flux and $\\iota\\equiv d\\vartheta/d\\zeta = B^\\vartheta/B^\\zeta$ is the rotational transform.\nThe covariant basis vectors $\\ev$ and $\\ez$ and the jacobian of the coordinate system $\\sqrt{g}$ are known from the shapes of the flux surfaces: $R(\\rho,\\vartheta,\\zeta)$ and $Z(\\rho,\\vartheta,\\zeta)$.\nSolving the force balance given in (\\ref{eq:F}) subject to a magnetic field of the form given in (\\ref{eq:B}) will satisfy all of the MHD equilibrium conditions provided in (\\ref{eq:equil}).\nThe actual scalar equations that get minimized are\n%\n\\begin{subequations}\n  \\label{eq:f}\n  \\begin{align}\n    f_\\rho(R,Z) &= F_\\rho \\lVert\\nabla\\rho\\rVert_2 \\sqrt{g} \\Delta\\rho\\Delta\\vartheta\\Delta\\zeta \\text{sign}\\left(\\nabla\\rho\\cdot\\er\\right) \\\\\n    f_\\beta(R,Z) &= F_\\beta \\lVert\\mathbf{\\beta}\\rVert_2 \\sqrt{g} \\Delta\\rho\\Delta\\vartheta\\Delta\\zeta \\text{sign}\\left(\\mathbf{\\beta}\\cdot\\ev\\right) \\text{sign}\\left(\\mathbf{\\beta}\\cdot\\ez\\right)\n  \\end{align}\n\\end{subequations}\n%\nalong with additional equations to enforce the boundary conditions.\nThis is known as an ``inverse formulation'' because the toroidal coordinates are solved for in terms of the flux coordinates, which are treated as the independent variables.\nCalculating the equilibrium magnetic field is equivalent to determining the transformation between these two coordinate systems.\n\nThe PDEs are discretized using pseudospectral methods.\nThe flux surfaces are represented by the coefficients of a global Fourier-Zernike basis set of the form:\n%\n\\begin{subequations}\n\t\\begin{align}\n\t\\label{eq:R_basis}\n\tR(\\rho,\\vartheta,\\zeta) &= \\sum_{n=-N}^{N} \\sum_{m=-M}^{M} \\sum_{l\\in L} R_{lmn} \\mathcal{Z}^{m}_{l}(\\rho,\\vartheta) \\mathcal{F}^{n}(\\zeta) \\\\\n\t\\label{eq:Z_basis}\n\tZ(\\rho,\\vartheta,\\zeta) &= \\sum_{n=-N}^{N} \\sum_{m=-M}^{M} \\sum_{l\\in L} Z_{lmn} \\mathcal{Z}^{m}_{l}(\\rho,\\vartheta) \\mathcal{F}^{n}(\\zeta)\n\t\\end{align}\n\\end{subequations}\n%\nwhere $\\mathcal{Z}^{m}_{l}$ is the Zernike polynomial with radial mode $l$ and azimuthal mode $m$, $\\mathcal{F}^{n}$ is a Fourier component with wave number $n$, and $L = |m|, |m|+2, |m|+4, \\ldots, 2 M - |m|$.\nFrom the state vector of coefficients $\\mathbf{x} = [R_{lmn}, Z_{lmn}]^T$, the values and partial derivatives of $R(\\rho,\\vartheta,\\zeta)$ and $Z(\\rho,\\vartheta,\\zeta)$ are transformed to physical space at a set of collocation points.\nAll of the nonlinear calculations involved to compute (\\ref{eq:f}) are performed in physical space at these nodes, resulting in a residual vector $\\mathbf{f} = [f_\\rho, f_\\beta]^T$.\nStarting from an initial guess, DESC computes the equilibrium solution by finding the flux surface geometry that minimize these errors on a given grid of collocation points: $\\mathbf{f}(\\mathbf{x}) \\approx \\mathbf{0}$.\nThis optimization process is performed with a quasi-Newton method, and will be referred to as the ``inner loop'' of the DESC algorithm.\nThe ``outer loop'' performs a sequence of these optimizations with different input parameters, and can perturb the previous solution to give a good initial guess for the next optimization step with the new inputs.\nFor example, this outer loop can be used to increase the numerical resolution from a crude initial solution to one with many spectral modes.\nAnother application is to perform scans in solution space over a physics parameter such as pressure, by starting from a vacuum solution and then solving for the equilibrium at increasingly higher pressures.\n\n\\begin{figure}\n\t\\centering\n\t\\includegraphics[width=0.8\\linewidth,center]{./figs/coordinates.pdf}\n\t\\caption{Toroidal coordinate system $(R,\\phi,Z)$ and the flux coordinates $(\\rho,\\vartheta,\\zeta)$.}\n\t\\label{fig:coords}\n\\end{figure}\n\n\\section{Project Goals}\n\n\\subsection{Initial State}\n\nBefore undertaking this project, DESC already existed as an open-source Python software package.\nThe user interface was to create an input file detailing all of the solver parameters, and then pass that input file as a command line argument.\nThe user could also pass flags to plot the results, but this output was only preset routines without much opportunity for customization.\nInternally, the DESC algorithm was implemented sequentially with a functional rather than class structure.\nAlthough the functions were well documented, each had a unique call signature and there was a lack of a common interface between different parts of the code.\nNew features were added to the code by creating another option in the input file format, and handling the new cases with if-else logic in the main driver script.\n\nDESC relies on other software packages to outsource some functionality.\nThe NumPy \\cite{NumPy} library is used to handle and vectorize all array operations in the system of equations.\nInitially, all of the optimization routines for the inner loop were provided by the SciPy \\cite{SciPy} optimization library.\nMany of these routines rely on information of how the objective function changes with respect to state variables, which is encoded in the Jacobian matrix $\\frac{\\partial\\mathbf{f}}{\\partial\\mathbf{x}}$.\nThis information is also needed to perform the outer loop perturbations, so it is important for DESC to compute the Jacobian matrix quickly and accurately.\nThis is accomplished with the use of JAX \\cite{JAX}, an open source machine learning package for Python.\nJAX provides automatic differentiation of arbitrary Python functions by overloading NumPy operations, as well as just-in-time (JIT) compilation and optimization for speed-up on repeated function calls.\nIt also allows for operations to be computed on a GPU, which can greatly accelerate the matrix-vector operations necessary for the optimization algorithm.\nThe initial state of the code had JAX implemented, but was disorganized about when it should be used over regular NumPy operations.\n\n\\subsection{Goals}\n\nWhile DESC was functional in its initial state, it did not have a unified or high-level class structure organization to it.\nIt also was not extensively covered by testing, had not been thoroughly profiled for speed optimization, and lacked certain features that would make it more useful to the user.\nWith those shortcoming in mind, the aim of this project was to improve DESC in the following ways:\n%\n\\begin{enumerate}\n\\item Refactor the code into a modular class structure\n\\item Expand the coverage of the existing testing suite\n\\item Profile the code to identify bottlenecks and explore optimization options\n\\item Extend the plotting capabilities to provide more solution visualization capabilities\n\\end{enumerate}\n\nAs mentioned in the previous section, the previous version of DESC had very minimal class structure.\nThis resulted in cumbersome control logic and unclear interfaces between different parts of the code.\nOur primary goal of this project is to refactor DESC into a class structure that takes advantage of object-oriented programming.\nThis improvement will streamline the code and provide a consistent application programming interface (API) for adding new functionality as users expand the software to meet additional applications.\nThe new modularity will also make it easier to perform unit testing to ensure that the code is implemented properly and returns the desired output.\nThe existing continuous integration (CI) automated testing suite only covered 22\\% of the DESC code, and our goal was to increase this converage to over 50\\%.\nComputational efficiency is also essential for DESC, since it was developed in the hope of finding stellarator equilibria faster than other codes.\nOnce the major refactoring was complete, we planned to profile the code to identify the bottlenecks and pursue any opportunities for optimization.\nFinally, we also intended to create a class responsible for plotting.\nAccurate solutions are only useful if they can be viewed, and the goal of this effort was to provide the user with a more flexible and interactive analysis tool.\n\n\\section{Design}\n\n\\subsection{Software Architecture}\n\nThe final architecture of the refactored DESC code is represented by the Unified Modeling Language (UML) diagram in Figure \\ref{fig:DESC_UML}.\nAt the core of the design is the \\texttt{Configuration} class, which acts as a container to store all of the spectral coefficients that describe a plasma state and their corresponding spectral basis sets.\nThe \\texttt{Equilibrium} class inherits from \\texttt{Configuration}, and uses the decorator pattern to add more information about how the equilibrium solution was solved such as the objective function that was minimized and the optimization method used.\nThe \\texttt{Equilibrium} attributes get updated when the equilibrium is solved in each inner loop, but it also contains another \\texttt{Configuration} attribute to hold the initial guess.\n\\texttt{EquilibriaFamily}, which inherits from \\texttt{MutableSequence}, is used as a container to store the \\texttt{Equilibrium} for each outer loop iteration.\n\n\\texttt{ObjectiveFunction} is an Abstract Base Class (ABC) that represents the objective function $\\mathbf{f}(\\mathbf{x})$ to be minimized.\nSection \\ref{sec:theory} only outlined one such function for the equilibrium force error, but there could be other equivalent definitions for equilibrium (such as minimizing the plasma energy) or other physical quantities of interest that need to be optimized.\nThe \\texttt{ObjectiveFunctionFactory} provides a factory design method to systematically determine which child of \\texttt{ObjectiveFunction} to use.\nThis objective function would be minimized by an optimization object with a very similar structure: an \\texttt{OptimizerFactory} will return an instance of an ABC \\texttt{Optimizer} class that represents different optimization methods.\nThis has not been implemented in the code yet because the SciPy optimization library is still being used, but the planned design is included in the UML in red.\n\nAnother major component of the design is the \\texttt{Transform} class, which is responsible for transforming spectral coefficients to real space and fitting data to a spectral basis.\nThis is needed whenever the \\texttt{Configuration} data is used, such as during the evaluation of an objective function or while plotting the state of the plasma.\nA \\texttt{Transform} object is defined by a \\texttt{Grid} and a \\texttt{Basis}.\nThe \\texttt{Basis} is an ABC that represents a set of basis functions such as the Fourier-Zernike basis from (\\ref{eq:R_basis}) and (\\ref{eq:Z_basis}), a double Fourier series to represent the boundary surface, or a power series to describe the pressure profile.\nThe \\texttt{Grid} represents a set of collocation points, and is intended to act as an abstract class but can be instatiated directly to create a grid of arbitrary nodes.\n\nThe outer loop is designed to be handled by the \\texttt{EquilibriumSolver} class, which will be responsible for calling the factory methods at each iteration, updating the transforms as the resolution changes, and perturbing the solutions between iterations.\nThis functionality still lives in a script, but has been streamlined to work with the new interface and will eventually be updated into the proposed class structure.\nThere are several other classes that are necessary to achieve the desired modularity of the code, and can be seen in Figure \\ref{fig:DESC_UML}.\n\n\\subsection{Input \\& Output}\n\nA new interface for the input and output (IO) of these class objects was also developed.\nThis design is particularly useful for saving and loading the solutions contained in an \\texttt{EquilibriaFamily}, but the interface is intentionally general for any class object.\nAny object we want to make savable inherits from the ABC \\texttt{IOAble}, which includes methods to save and initialize the object from a file.\nChild classes need only specify a method to initialize from initialization arguments (i.e. initializing from scratch), a list of attributes to save and load, and a dictionary of classes it may need to initialize on the fly during a load from file.\nThis architecture was chosen after our initial idea resulted in circular import errors:\neither the objects could depend on the IO in some way or the IO could depend on the objects in some way, but both could not happen while keeping the IO functions and objects in different modules.\nWe decided to have the objects inherit from the IO, as it would allow for a homogeneous and simple interface when saving and loading objects.\n\nWe also altered the IO back end code significantly towards a number of goals: a homogeneous interface across file formats, protecting read/write permissions, and less code reproduction.\nStarting with an ABC \\texttt{IO}, which includes methods handling how all files will be treated, we specify that files should be closed on garbage collection, and files of the specified type should be opened if the class constructor is passed a file path.\nClasses specifying IO operations specific to file-format, like opening files and creating sub directories inherit directly from \\texttt{IO}.\nParallel to this, we introduced the abstract base classes \\texttt{Reader} and \\texttt{Writer}, which specify the interface for any \\texttt{IO} class that reads from or writes to file, respectively.\nThe utility of this inheritance structure, shown in Figure \\ref{fig:EquilIO_UML}, is that one only needs to specify a file format wrapper for \\texttt{IO} and read or write functions to have a reader or writer that can be hot-swapped for any other.\n\n\\subsection{User Interface}\n\nThe user interface is generally split into two parts: one computes an equilibrium from command line arguments; the other to plot solutions from saved files (generated by the solver).\nWhen calculating a solution, the user must call the program with the input filename as an argument.\nOther optional arguments may be included and are detailed in the existing documentation.\nThe command line arguments and input file are parsed, and the required instances of the class objects will be created in order to solve.\nA solution algorithm is called as a method of the EquilibriaFamily class, which creates new Equilibrium objects inside of it and saves aspects of the solution to the output file, as well as uses the linked EquilibriumSolver object to solve the problem.\nAnother envisioned use of the code is in an interactive sense, where the user could instantiate an Equilibrium or EquilibriaFamily from an input file, and then use the solve method of these classes to compute the solutions.\n\nOnce a solution has been found and an output file saved, the user can then instantiate a \\texttt{Plot} class with the name of the output file.\nMethods of this class are called to plot specified parts of the solution (magnetic field, flux surfaces, etc) for specified domains (1-D profiles, 2-D plots at a given toroidal cross-section, etc) at a specified iteration of the outer loop.\nIn this way, the user can use the Plot class to visualize not only the final result but also to see intermediate solutions with different input parameters, which are stored as Equilibrium objects inside of an EquilibriaFamily.\n\n\\begin{figure}[!h]\n\t\\includegraphics[width=\\textwidth,center]{figs/DESC_UML.pdf}\n\t\\caption{UML diagram of the improved DESC software architecture. Classes in green have already been implemented; classes in red are planned.}\n\t\\label{fig:DESC_UML}\n\\end{figure}\n\n\\begin{figure}[!h]\n\t\\includegraphics[width=0.8\\textwidth,center]{figs/EquilibriumIO_UML.pdf}\n\t\\caption{UML Diagram for the new Eqiulibrium IO setup.}\n\t\\label{fig:EquilIO_UML}\n\\end{figure}\n\n\\section{Development Process}\n\n\\subsection{Git Workflow}\n\nFor our project, we decided to go with the git workflow that uses infinite, parallel development and master branches.\nThe idea of the workflow is to branch from \\texttt{master} to work on feature branches, then merge those into \\texttt{dev} where the testing takes place.\nThen, once the tests have passed, the feature branch is merged back into \\texttt{master}.\n\nThis works well when the feature branches are all independent of each other, so merge conflicts on \\texttt{dev} are minimized.\nHowever, in our project we were refactoring an existing code base and a lot of our feature branches had some sort of inter-dependence, especially at the start.\nA case of this is in the creation of the \\texttt{Transform} class that is used as the base class for the coordinates at which we evaluate our objective functions.\nWe initially each made separate feature branches off of \\texttt{master} with a defined refactoring task for each branch.\nBut, when it came time to merge the branches back into\\texttt{master}, we realized that the \\texttt{transform} branch, where the \\texttt{Transform}, \\texttt{Grid}, and \\texttt{Basis} classes were created and other code was edited to work with them, touched many parts of the other branches' files.\nThis created a headache when it came time to merge the \\texttt{transform} branch into \\texttt{dev}, as not only merge conflicts had to be resolved, but also other working parts from other feature branches were broken.\n\nHow we ended up resolving this issue was to first merge the other, less broadly-changing feature branches into \\texttt{master}.\nThen, from the \\texttt{transform} branch, we cherry-picked the latest commits from \\texttt{master} into \\texttt{transform}.\nWe could then resolve merge conflicts locally on the \\texttt{transform} branch so it would play nice with the other branch commits.\nThis allowed us to keep the \\texttt{dev} branch strictly for testing and not for bug-fixing commits.\nSo, we were able to modify the other necessary parts of the code that enabled it to run with the \\texttt{Transform} classes, and then merged everything back to master without conflicts.\n\nFrom this experience, we learned that the infinite and parallel \\texttt{dev} and \\texttt{master} workflow works best when feature branches are smaller in scope and are merged back to master often.\nThis way, any individual feature branch does not fall behind the master branch, and each feature branch can more easily be independent of each other.\nAnother thing we learned as we used this workflow was that the \\texttt{dev} branch should be used only for testing.\nFinding bugs on \\texttt{dev} and then fixing them by committing code to \\texttt{dev} seemed fine at first.\nHowever, when we would go to make further changes on our feature branches, we would realize that some bug we fixed on \\texttt{dev} was still present on the feature branch.\nThis would then require us to have to re-commit the same bug fix on the feature branch.\nThen when we wanted to test the feature branch by merging it into \\texttt{dev} before submitting a pull request into \\texttt{master}, we would encounter confusing merge conflicts due to having fixed the bug separately on both \\texttt{dev} and on the feature branch.\nThus, we learned the hard way that the \\texttt{dev} branch should never be advanced alone but rather by merging feature branches, and all work and fixes should be done on feature branches to keep all branches up-to-date on bug fixes.\n\n\\subsection{Continuous Integration}\n\nThe continuous integration (CI) workflow with automated testing helped us catch bugs as new code was developed.\nIn our requirements file we had initially listed support for the latest version of JAX, version 0.2.5, as a remnant from the original DESC repository when we forked it.\nJAX is still being actively developed and there have been major changes in the past year.\nWhen pushing changes to the new \\texttt{Transform} class structure that relies heavily on the use of \\texttt{jax.numpy} arrays, the new changes were passing the tests on our local computers without JAX but failing on the virtual machines that were running with JAX.\nThis problem was puzzling because JAX is intended to replicate most of the usual numpy operations.\nAround the same time, an independent user of the code had also reported a problem with running JAX on the original DESC repository.\nIt turned out that some of the operations we were using were no longer supported in the newer version of JAX, and reducing the installation requirement to version 0.1.77 resolved the issue.\nThe lesson learned was that maintaining compatibility with other software packages can be laborsome, but frequent testing (from both automated tests and beta users) can help catch problems when they arise.\n\n\\section{Profiling \\& Optimization}\n\\label{sec:profiling}\n\nOnce a stable version of the refactored code was reached, we performed profiling to measure its performance.\nAlthough DESC is intended to be primarily run with JAX on large clusters that have multiple GPUs, the profiling was performed on a CPU without JAX.\nThe JIT-ed code is more difficult to profile since the compiled functions are not executed as originally written, so working without JAX allowed us to use conventional python profiler tools.\nThis represents the slowest-case scenario for running DESC, but is not irrelevant for real applications -- some users may wish to run computations on their personal laptop.\nWe assumed that any performance gains made on this setup would also benefit other architectures because JAX only adds overhead to the underlying NumPy operations, and GPU parallelization is still limited by the serial processes of each thread.\nThe wall time to execute DESC depends strongly on the particular inputs chosen, since the dimension of the system of equations scales with the spectral resolution.\nFor these profiling tests, a stellarator input with 8 poloidal Fourier modes and 2 toroidal Fourier modes were used, with 100 inner loop iterations in a single outer loop step.\nFor reference, the total run time for this test case was about two minutes.\n\nAt a high level, the DESC algorithm has two major components: pre-computation of the spectral transform matrices, and the inner loop optimization.\nThe transform matrices are built by evaluating basis functions on a given grid, and the optimization loop is repeatedly calling the objective function.\nWithin the objective function itself, there are two components: the equilibrium force balance errors, and the errors in satisfying the boundary conditions.\nAt the spectral resolution of the reference case, each of these components consumes a roughly equal portion of the total objective function evaluation time.\ncProfile was used to identify which sub-functions were the bottleneck for the overall algorithm, and then the line profiler lprun was used to determine the most expensive operations within those functions.\n\nWe discovered that the single function taking up the most computation time was the one responsible for computing the coordinate system jacobian, which is calculated from the triple product $\\sqrt{g} = \\er\\cdot\\ev\\times\\ez$ and gets called each time the objective function is evaluated.\nThe cross-product, called by \\texttt{jax.numpy.cross(a, b)}, is a relatively expensive operation because it involves manipulating multidimensional arrays.\nThis vector algebra was easily avoided by writing out the triple product explicitly in the code, reducing all of the operations to element-wise multiplication and addition.\nThis reduced the computation time of the equilibrium force errors by 36\\% and the total evaluation time of the objective function by 20\\%, as shown in Figure \\ref{fig:compute_time_opt}.\nWriting out the triple product explicitly does make the code somewhat less human-readable, but it does not add many extra lines of code and is certainly worth doing for the notable speedup.\n\nThe next greatest bottleneck after the jacobian terms was Fourier basis evaluation.\nThis function gets called when building the transform matrices, and also when evaluating the boundary condition errors in the objective function since that transformation cannot be pre-computed.\nIn the original version of this function, the Fourier series was written in the complex notation $e^{im\\theta}(im)^d$, where $d$ is the required order of derivative with respect to $\\theta$.\nLine profiling revealed that the differentiation step was taking a substantial amount of time, but was not always necessary.\nThe derivatives are needed in the transform matrices that can be pre-computed, while the objective function that gets called repeatedly only evaluates the Fourier series without differentiating.\nThis excessive operation was avoided by re-writing the function to evaluate the derivatives recursively, so that the base case of $d=0$ does not waste time differentiating.\nAdditional performance gains were made by replacing the complex format with all real values, and changing how the two-dimensional arrays were formed.\nThese edits reduced the computation time of the boundary conditions errors by 19\\% and the total evaluation time of the objective function by 10\\%, also shown in Figure \\ref{fig:compute_time_opt}.\nSince the Fourier basis evaluation is also called while pre-computing the transform matrices, this also reduced the time to build the Fourier-Zernike transformations by 36\\% as shown in Figure \\ref{fig:compile_time_opt}.\nThe build process is now dominated by the Jacobi polynomial evaluations, which comprise the radial terms of the Zernike basis functions (see Figure \\ref{fig:compile_time_rel}).\n\nWith both of these optimizations combined, the time to compute the objective function was reduced by 28\\% from about 4.8 ms to 3.4 ms.\nThe equilibrium force balance errors and boundary condition errors still take roughly the same amount of time to compute, as they did in the initial reference version (see Figure \\ref{fig:compute_time_rel}).\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.6\\linewidth,center]{./figs/compute_time_opt.png}\n\t\\caption{Reduction in execution time to compute the objective function, relative to the original code, for different stages of optimization.}\n\t\\label{fig:compute_time_opt}\n\\end{figure}\n%\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.6\\linewidth,center]{./figs/compile_time_opt.png}\n\t\\caption{Reduction in execution time to evaluate the Fourier-Zernike basis function, relative to the original code, for different stages of optimization.}\n\t\\label{fig:compile_time_opt}\n\\end{figure}\n%\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.6\\linewidth,center]{./figs/compile_time_rel.png}\n\t\\caption{Relative portion of time to evaluate the Fourier-Zernike basis function spent in each subfunction, for different stages of optimization.}\n\t\\label{fig:compile_time_rel}\n\\end{figure}\n%\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.6\\linewidth,center]{./figs/compute_time_rel.png}\n\t\\caption{Relative portion of time to compute the objective function spent in each subfunction, for different stages of optimization.}\n\t\\label{fig:compute_time_rel}\n\\end{figure}\n\n\\section{Future Work}\n\n\\subsection{Finish Realization of Object-Oriented Design}\n\nThe most immediate future work for this project would be to complete the refactoring of the code into an object-oriented design.\nThe main part of the code that remains in a functional implementation is the outer loop solver.\nWhile the refactoring we completed did increase the legibility of the outer loop solver function, there are still aspects that would benefit from being modularized.\nThis would come in the form of creating the \\texttt{EquilibriumSolver} and \\texttt{Optimizer} classes from the UML diagram, which would handle the logic of the inner-outer loop optimization algorithm.\nWe foresee the most difficulty in this task coming from deciding how to split the necessary steps and control logic across the respective objects.\nFor example, in the outer loop, a new \\texttt{Equilibrium} must be created and perturbed, in order to then be sent into the inner optimization loop.\nShould the \\texttt{EquilibriumSolver} object be able to create new \\texttt{Equilibrium} objects, even though it is not directly connected to an \\texttt{Equilibrium}?\nOr would this be better handled by \\texttt{EquilibriaFamily}?\nWe have in our UML diagram an outline of what we think is the best to approach, but it is the concrete answers to these questions that we will need to decide in order to finish the implementation of our complete design.\n\n\\subsection{Expand Testing Suite}\n\nWhile we did increase the percentage of code covered by tests by roughly 20\\%, there is still a lot of room for improvement.\nIncreasing the modularity of the code helped us to more easily implement unit tests for the lower level, simpler components.\nThough there are still simple classes left for us to cover with unit tests, among what is remaining are the classes that take these simpler objects and use them in a more complex way to return some physically meaningful quantites.\nWe have two goals to improve testing in the future, given this complexity.\n\nThe first is to have a broader integration testing suite, where we test the overall output of our code against analytically solvable solutions.\nWhile this sort of testing suite cannot narrow down issues to specific objects or functions, it can narrow down issues to certain types of problems.\nFor example, an equilibrium that is axisymmetric is much simpler to compute than a non-axisymmetric equilibrium, as they are different dimensions (2-D versus 3-D).\nSo, with integration testing of both types of equilibria, we would be able to at least see if problems arise only with certain types of equilibria.\nAdditionally, this sort of testing suite would instill confidence in the output of the code.\n\nThe second is to use the mock object features of the Python unit testing modules to contrive simple examples for these more complex classes.\nThis would work by allowing us to create mock objects to take the place of objects that would normally be created by reading an input file and performing intermediate calculations.\nWe would then be able to create simple scenarios where we could more easily check the expected output, when we have control over exactly what the inputs into the function are.\n\n\\subsection{Further Profiling \\& Optimization}\n\nA preliminary round of profiling and code optimization was performed as mentioned in Section \\ref{sec:profiling}, but there is certainly more room for improvement.\nProfiling is an ongoing effort, but our time was limited during this project and we decided to prioritize the code refactoring over optimization of existing code.\nIt would be helpful to profile additional test cases with higher spectral resolutions to understand how the relative bottlenecks scale with the dimensionality of the system.\nThese same tests then need to be reproduced with JAX in use to check if there are opportunities specific to their overloading of the usual NumPy operations, which will have to be done using the TensorBoard profiler.\nWe also need to determine when it is advantageous to JIT functions and optimize the code to reduce those compile times.\nAnother need is to profile on different computer architectures, including with GPUs.\nDESC currently has some GPU compatibility and basic parallelization, but this avenue has not been explored in much detail yet.\nFinally, work is needed to optimize memory management.\nThe Jacobian matrix calculations can consume large amounts of memory at high resolutions, and storing this data could be especially problematic when running on GPUs.\nWe should explore potential solutions to remedy this, such as splitting up the Jacobian and evaluating it on multiple GPUs in parallel.\n\n\\bibliography{sources}\n\n\\end{document}\n", "meta": {"hexsha": "222191736cbd4282f8c397b4897e6d8d1c96cd80", "size": 35216, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/main.tex", "max_stars_repo_name": "dpanici/DESC", "max_stars_repo_head_hexsha": "e98a16394d02411952efc18cc6c009e5226b11e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-20T17:17:50.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-20T17:17:50.000Z", "max_issues_repo_path": "report/main.tex", "max_issues_repo_name": "dpanici/DESC", "max_issues_repo_head_hexsha": "e98a16394d02411952efc18cc6c009e5226b11e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-19T05:22:13.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-15T03:50:33.000Z", "max_forks_repo_path": "report/main.tex", "max_forks_repo_name": "dpanici/DESC", "max_forks_repo_head_hexsha": "e98a16394d02411952efc18cc6c009e5226b11e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 90.529562982, "max_line_length": 297, "alphanum_fraction": 0.7972796456, "num_tokens": 7843, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4049846084547341}}
{"text": "\\documentclass{article}[12pt]\n\\usepackage{amsmath}\n\\usepackage{hyperref}\n\\usepackage{graphicx}\n\\graphicspath{ {./} }\n\\newcommand{\\rot}[3]{#3#2#1}\n\\newcommand{\\myskip}{\\bigskip\\noindent}\n\n\\title{Interpreting Neural Networks by Reducing Nonlinearities during Training}\n\\author{Elod Pal Csirmaz\\\\\n\\texttt{\\rot{\\rot{maz.}{csir}{ep}com}{@}{elod}}}\n\n\\date{\\today}\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nMachine learning and neural networks are used more and more widely,\ndespite the fact that they mostly function as black boxes, and we\nhave little insight into how they generate their output.\nThis makes it difficult to scrutinize and account for decisions made using these systems.\n\nIn this paper we present a simple solution that makes it possible to\nextract rules from a neural network that employs Parametric Rectified Linear Units (PReLUs).\nWe introduce a force, applied in parallel to backpropagation, that\naims to reduce PReLUs into the identity function, which then causes\nthe neural network to collapse into a smaller system of linear functions and inequalities\nsuitable for review or use by human decision makers.\n\nAs this force reduces the capacity of neural networks, it is expected to help avoid overfitting as well.\n\n\\myskip\n{\\bf Keywords:} % (4-6)\nmachine learning,\nneural networks,\nrule extraction\n\n\\myskip\n{\\bf MSC classes:} % http://www.ams.org/mathscinet/msc/msc2010.html\n62M45,  % Neural nets and related approaches\n68T05   % Learning and adaptive systems\n\n% \\myskip\n% {\\bf ACM classes:} % http://www.acm.org/about/class/ccs98-html\n\n\\end{abstract}\n\n\\section{Introduction}\n\nMachine learning solutions and, more specifically, neural networks are used\nin more and more areas of our lives. At the same time, since it is difficult to \ngrasp at any level how they function and so they can be seen as black boxes,\nthere is a reluctance in their adoption in the case of companies who need to\nremain accountable for business and/or legal reasons. This fact also impacts\nthe trust the public places in such systems.\n\nBecause of this, providing tools that can help us understand how these\nmodels arrive at a certain decision is an area of active research.\nThe tools range from visualization tools, tools that identify the\nmost significant input, tools that allow experimenting with the input data\nto understand the relative importance the model attributes to different\nsignals, and, the focus of this paper, significantly reducing the complexity\nof a neural network to the point where ``rules'' for decisions could be\nextracted from it, which can then be reviewed or even used by human decision-makers.\n\nOne form these rules can take is a closed, relatively simple algebraic\nexpression (for example, a linear function) which has a behavior more\npredictable for humans than the full function implemented by a neural\nnetwork involving parameters and nonlinear functions in the range of\nmillions.\n\nIn this paper we detail a method of reducing the complexity of a neural\nnetwork during its training, which then allows describing its output as a\nsimple system of linear functions limited to regions defined by linear\ninequalities.\nIn particular,\nwe investigate feed-forward neural networks\nwhere all nonlinearities are Parametric Rectified Linear Units (PReLUs)\ndefined as\n\\[ f(x) = \\max(0, x) + a \\min(0, x). \\]\nwhere $0\\leq a\\leq 1$.\\cite{PR}\n\nLet the input of the network be the vector (or tensor, which we flatten) $I=(i_1, i_2, \\ldots, i_n)$\nand the output be the vector (or tensor) $O=(o_1, o_2, \\ldots, o_m)$.\n\n\\section{The Neural Network as a Combination of Linear Functions}\n\nIt is easy to see that the output $O$ of such a network can be expressed\nas a set of linear combinations of $i_x$, each restricted to a particular region of input values\nby a set of linear inequalities on $i_x$ (the conditions).\n\nIntuitively, this is true because the output is a linear function of the input\nas long as (that is, inside regions of the possible input vectors in which) none of the inputs of PReLUs\ncross from negative to positive or \\emph{vice versa}; and because the borders of these regions\nare linear as well.\n\nMore formally, we can show that this statement is true by constructing a suitable\nsystem of linear combinations and inequalities for any given neural network.\nFor all PReLUs in the network, let us decide whether their inputs are negative, or nonnegative.\nIf the number of PReLUs is $\\delta$, this means $2^\\delta$ possible scenarios.\nIn each scenario, the neural network becomes completely linear, with the output being a linear function of the input,\nand, in fact, with all partial results inside the network being linear functions of the input as well.\nThis entails that the inputs of PReLUs are also linear functions of the input $I$, yielding\nthe $\\delta$ linear inequalities (the conditions) that mark out the region of the input space where this scenario applies.\n\nNaturally, this system of $2^\\delta$ linear combinations yielding the output, each controlled by $\\delta$\nconditions is likely to be redundant, as the conditions may not be independent,\nor may be contradictory, in which case some of the $2^\\delta$ regions of the input space will be empty.\nBut this system will be an accurate description of the output of the neural network nevertheless.\n\n\\myskip\nWhile a linear function may seem easy to interpret and to predict for us humans, clearly $2^\\delta$\nfunctions will not be so if $\\delta$ is in the range of thousands or millions as in most modern neural networks.\nWe therefore need to construct an approximation of the output of our neural network which is linear in much\nlarger regions of the input space, and has far less different regions as well.\nThis is equivalent to trying to find another neural network that approximates our network well,\nbut contains a small number of PReLUs only.\n\n\\section{Reducing PReLUs into Linearities}\n\nWe achieve this by continuing training the original neural network while applying a force on each of\nits PReLUs that moves its parameter $a$ towards 1.\n\nNote that if $a=1$, then the PReLU degenerates into the identity function $f(x)=x$, and ceases to be a nonlinearity.\nIn a sense, it disappears, and the neural network ``collapses'' around it, inasmuch as the linear mapping\nthat precedes the degenerate PReLU and the one after it can now be combined into a single linear map.\n\nThis force therefore finds a balance between approximating the training data\nand reducing the number of PReLUs, thereby yielding a neural network that is feasible to express\nas a set of linear functions and inequalities for human consumption.\nBy removing nonlinearities, this force also reduces the capacity of the neural network,\nand therefore we expect that it can also be helpful to avoid overfitting.\n\nWe chose a\nforce that is independent of $a$ and is applied after each backpropagation step, and moves the parameter by an adjustment rate\n$\\eta_p$ but never above 1:\n\\[ a_{t+1} = \\max\\left(0,\\;\\min\\big(1,\\;a_t + \\eta_p\\,\\mathrm{sgn}(1-a_t)\\,\\big)\\right) \\]\n\nIn our research we considered any PReLU fully linear if\n\\[ a > 0.9995 \\]\n\nWe also made $\\eta_p$ dependent on the current error exhibited by the network,\nto allow the network initially to train without interference, and then\npull the PReLU parameters to 1 more and more aggressively. We chose\n\\[ \\eta_p = \\eta_0\\,0.01\\,\\max\\big(0,\\; -\\log_{10}(err)-2\\big) \\]\nwhere $\\eta_0=0.01$ is the learning rate for the whole model, and $err$ is the training error.\nThis means that $\\eta_p$ will start becoming non-zero when the training error\nfalls below 0.01, and can grow indefinitely as the training error falls\n(although the $a$ parameters are clipped anyway).\n\n\\section{Example}\n\nSample code demonstrating the above is available at\n\\url{https://github.com/csirmaz/trained-linearization}.\nThe code implements training a small neural net with the force on PReLU parameters,\nand contains logic to extract a system of linear inequalities and combinations\nfrom the weights and other parameters of the model.\n\nThe neural network itself\nhas 4 input nodes, 3 output nodes, and\n4 hidden layers in between with 5 nodes on each.\nThese layers are linked by trainable fully-connected layers\nwith PReLU activation following them, except for the last fully connected layer,\nwhich simply provides the output.\n\nThe network is expected to learn the following relationships:\n\\begin{align}\n\\mathrm{out}_1 &= \\mathrm{in}_1 \\;\\mathrm{xor}\\; \\mathrm{in}_2 \\\\\n\\mathrm{out}_2 &= \\mathrm{in}_3 \\;\\mathrm{xor}\\; \\mathrm{in}_4 \\\\\n\\mathrm{out}_3 &= \\mathrm{in}_1 \\cdot \\mathrm{in}_2\n\\end{align}\nwhere all the inputs and outputs are 0 or 1 with some extra noise added to the inputs.\nWe generate the training data according to the expressions above, for all $2^4$ possible combinations of 0 and 1 for the input.\nNew noise is generated for each batch of training data.\n\n\\begin{figure}[ht]\n\\centering\n\\includegraphics[height=10cm]{example}\n\\caption{A trained network with 4 input nodes (top) and 3 output nodes (bottom). Red lines denote positive, blue lines negative weights.\nLines leading from the right denote bias values. Green boxes mark PReLUs that are considered linear, while red ones mark nonlinear PReLUs.}\n\\label{fig}\n\\end{figure}\n\nFigure \\ref{fig} visualizes a trained model. Two nonlinearities are enough to solve this problem, and indeed the training\nsettled on a solution where only two PReLUs were nonlinear.\n\nAlthough in the visualization the relationships between the inputs and the outputs are far from clear,\nonce the rest of the PReLUs are considered linear, all the weights collapse into very simple expressions.\nSee figure \\ref{output} for the output of the code listing these expressions for the $2^2$ cases arising from the\ntwo nonlinear PReLUs.\nThese correspond completely to the relationships in the training data.\n\n\\begin{figure}[ht]\n\\begin{verbatim}\nIF +0.00*in1 +0.00*in2 -1.00*in3 -1.00*in4 +1.00 < 0\n   (PReLU #3 on level 1 is neg. ln(1-weight)=-2.58)  \nIF +1.00*in1 +1.00*in2 -0.00*in3 -0.00*in4 -1.00 < 0\n   (PReLU #1 on level 4 is neg. ln(1-weight)=-2.60)  \nTHEN    \n  out1 = +1.01*in1 +1.01*in2 -0.00*in3 -0.00*in4 +0.00  \n  out2 = -0.00*in1 -0.00*in2 -1.03*in3 -1.03*in4 +2.04  \n  out3 = -0.00*in1 -0.00*in2 +0.00*in3 +0.00*in4 -0.00  \n        \nIF +0.00*in1 +0.00*in2 -1.00*in3 -1.00*in4 +1.00 < 0\n   (PReLU #3 on level 1 is neg. ln(1-weight)=-2.58)  \nIF +1.00*in1 +1.00*in2 -0.00*in3 -0.00*in4 -1.00 > 0\n   (PReLU #1 on level 4 is pos. ln(1-weight)=-2.60)  \nTHEN    \n  out1 = -1.01*in1 -1.01*in2 +0.00*in3 +0.00*in4 +2.02  \n  out2 = -0.00*in1 -0.00*in2 -1.03*in3 -1.03*in4 +2.04  \n  out3 = +1.00*in1 +1.00*in2 +0.00*in3 +0.00*in4 -1.01  \n        \nIF +0.00*in1 +0.00*in2 -1.00*in3 -1.00*in4 +1.00 > 0\n   (PReLU #3 on level 1 is pos. ln(1-weight)=-2.58)  \nIF +1.00*in1 +1.00*in2 +0.00*in3 +0.00*in4 -1.00 < 0\n   (PReLU #1 on level 4 is neg. ln(1-weight)=-2.60)  \nTHEN    \n  out1 = +1.01*in1 +1.01*in2 +0.00*in3 +0.00*in4 +0.00  \n  out2 = -0.00*in1 -0.00*in2 +1.00*in3 +1.00*in4 +0.01  \n  out3 = -0.00*in1 -0.00*in2 -0.00*in3 -0.00*in4 +0.00  \n        \nIF +0.00*in1 +0.00*in2 -1.00*in3 -1.00*in4 +1.00 > 0\n   (PReLU #3 on level 1 is pos. ln(1-weight)=-2.58)  \nIF +1.00*in1 +1.00*in2 +0.00*in3 +0.00*in4 -1.00 > 0\n   (PReLU #1 on level 4 is pos. ln(1-weight)=-2.60)  \nTHEN    \n  out1 = -1.01*in1 -1.01*in2 -0.00*in3 -0.00*in4 +2.02  \n  out2 = -0.00*in1 -0.00*in2 +1.00*in3 +1.00*in4 +0.01  \n  out3 = +1.00*in1 +1.00*in2 -0.00*in3 -0.00*in4 -1.01\n\\end{verbatim}\n\\caption{Sample output of the code}\n\\label{output}\n\\end{figure}\n\n\\section{Future work}\n\nFuture work can include and improved algorithm to extract linear rules from the network\nthat recognizes dependencies between the inequalities to simplify its output.\n\nAnother alternative is to approximate PReLUs that are deemed linear not with $f(x)=x$,\nbut with e.g. $f(x)=\\frac{a+1}{2}x$, which can allow replacing more PReLUs with a fully linear function than we currently do.\n\n\\begin{thebibliography}{99}\n\\bibitem{PR}\nKaiming He and\n               Xiangyu Zhang and\n               Shaoqing Ren and\n               Jian Sun,\n``Delving Deep into Rectifiers: Surpassing Human-Level Performance on\n               ImageNet Classification,''\nMicrosoft Research,\n6 February 2015.\nhttp://arxiv.org/abs/1502.01852.\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "06c99812827995d5c2c0af443b1e888649e09f35", "size": 12308, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "linearize.tex", "max_stars_repo_name": "csirmaz/trained-linearization", "max_stars_repo_head_hexsha": "aa6fdfec7cabd0501f5a5bf027e8dd91a22ca2cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "linearize.tex", "max_issues_repo_name": "csirmaz/trained-linearization", "max_issues_repo_head_hexsha": "aa6fdfec7cabd0501f5a5bf027e8dd91a22ca2cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "linearize.tex", "max_forks_repo_name": "csirmaz/trained-linearization", "max_forks_repo_head_hexsha": "aa6fdfec7cabd0501f5a5bf027e8dd91a22ca2cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7054263566, "max_line_length": 139, "alphanum_fraction": 0.7493500162, "num_tokens": 3509, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4049846084547341}}
{"text": "\\chapter{The control algorithm}\n\\label{ch:controlalgorithm} \nUnmanned aerial vehicles (UAVs) are a class of aircraft under the control of either a remote human pilot or a on board computer. UAVs were originally developed for military purposes, although recent advances in technologies, like Li-Ion batteries and brush-less motors, have brought this type of aircraft to  others scopes of usage, like commercial, scientific and also recreational.\nAlthough most UAVs are fixed-wing aircraft, rotorcraft are becoming popular too due to the low price and ease of maintenance and run.\\graffito{Quad-copter, more commonly referred to as \\emph{drones}, are commercially available to a large amateur public.} The demand for this type of drone is increasing and the global market for commercial use is expected to grow in the next few years, thats why the study case is a low-level controller for helicopters, ducted-fan tail-sitters and multi-propeller helicopters.\n\n\\section{A novel approach to the copter control proble}\nA common control strategy is a cascade feedback: an outer loop for the position and an inner loop for the attitude. The inner control loop is usually composed by 3 control loop for the roll, pitch and yaw attitude angles. While this is a easy and intuitive approach to the problem, a more advanced one can be developed: the rest of this chapter describes a novel approach as presented in \\autocite{marconi}.\n\n\\section{Quaternions for rotations representation}\nAlthough the attitude has 3 degrees of freedom\\graffito{Rotations of 3D objects in a 3D world can be expressed by 3 scalar quantities, usually Euler angles or roll-pitch-yaw angles (RPY).}, any minimal parametrization suffers of singularity problems (or gimbals-look).\\\\\n\\graffito{A rotation matrix is a 3x3 orto-normal matrix, so although it is composed by 9 scalar values, the matrix itself has just 3 degrees of freedom}\nA very common alternative representation is rotational matrices: those do not suffer of singularities problems but are quite  redundant since 9 scalar values are used to express just 3 degrees of freedom.\\\\\nA good trade-off between compactness and ease of representation is archived with unit quaternions, a notation that allows to represent rotations in a compact form and with no gimbals-lock problems. Another advantage to consider is numerical stability: numerical drifts make both rotation matrices and unit quaternions loose their own properties: respectively being orthonormal and having module one; it is however way easier to scale a vector than force the orthonormal structure of a matrix. More details can be found in \\cite{bib:quat} and \\cite{bib:rotquat}.\\\\\nNo insight in Hamiltonian math is reported there, it just follows a note about the notation used in the following chapters: in general a quaternion $q$ is given by:\n\\begin{equation} \\label{eq:coptermodelmat}\n\\begin{split}\nq := \\begin{bmatrix}\n\\eta\\\\\n\\epsilon\n\\end{bmatrix}\n\\end{split}\n\\end{equation}\nwhere $\\eta$ is the \\emph{real} component and $\\epsilon$ is the \\emph{pure imaginary} vector component of $q$ and the Hamilton product between 2 quaternion is indicated by the symbol $\\oplus$.\n\n\\section{The copter model}\nThe dynamic model of the copter is given by:\n\n\\begin{equation} \\label{eq:coptermodelmat}\n\\begin{split}\n\tM \\ddot{p} &= -u_{f}Re_{3} + Mge_{3}\\\\\n\t\\dot{R} &= RS(w)\\\\\n\tJ\\dot{w} &= S (Jw) w + u_{\\tau}\n\\end{split}\n\\end{equation}\n\nWhere we call $ p $ the position vector of the center of gravity of the copter in the inertial reference frame $ \\pazocal{F}_{i} $ and $ w $ the angular velocity of the vehicle in the body reference frame $ \\pazocal{F}_{b} $. $ R $ is the rotation matrix representing the orientation of $ \\pazocal{F}_{b} $ wrt $ \\pazocal{F}_{i} $, $ J $ is the inertia matrix of the system and $ u_{f} $ and $ u_{\\tau} $ are respectively the force and  the torque vector generated by the propellers.\\graffito{Note that the while the $u_{f}$ is a scalar force which direction always aligned with the $z$ axis of $\\pazocal{F}_{b}$, $u_{\\tau}$ is a 3-dimensional vector.}\nThe $S(m)$ function generates a $3\\times3$ matrix from vector $m$ such that the matrix product between $S(m)$ and another $3\\times1$ vector $n$ correspond to the cross (vector) product between $m$ and $n$. $S$ can be constructed as:\n\\begin{equation} \\label{eq:coptermodelmat}\n\\begin{split}\nS(m) :&= \\begin{bmatrix}\n0 & -m_{3} & m_{2}\\\\\nm_{3} & 0 & -m_{1}\\\\\n-m_{2} & m_{1} & 0\n\\end{bmatrix}\n\\end{split}\n\\end{equation}\n\nThe copter model can be rewritten using quaternions to represent rotations by mean of the Rodriguez formula\\cite{bib:rodriguez}:\n\\[ \\pazocal{R}(q) = I + 2 \\mu \\pazocal{S}(\\epsilon) + 2 \\pazocal{S}(\\epsilon)^{2}\n \\]\nas\n\\begin{equation} \\label{eq:coptermodelquat}\n\\begin{split}\nM \\ddot{p} &= -u_{f}\\pazocal{R}(q)e_{3} + Mge_{3}\\\\\n\\dot{q} &= \\frac{1}{2} q \\oplus \\begin{bmatrix} 0 \\\\ w \\end{bmatrix} \\\\\nJ\\dot{w} &= S (Jw) w + u_{\\tau}\n\\end{split}\n\\end{equation}\n\n\n\n\\section{Position control loop}\nWe can write the position error dynamic as:\n\\begin{equation} \\label{eq:poserrdyn}\n\\begin{split}\nM \\ddot{\\overline{p}} &= -u_{f}\\pazocal{R}e_{3} + Mge_{3} - M\\ddot{p}_{R}\n\\end{split}\n\\end{equation}\nAnd define the control force as:\n\\begin{equation} \\label{eq:ctrlforce}\n\\begin{split}\nv^{c}_{R}(\\ddot{p}_{R})&:=Mge_{3} - M\\ddot{p}_{R}\\\\\nv^{c}(\\overline{p},\\dot{\\overline{p}},\\ddot{p}_{R})&:=v^{c}_{R}(\\ddot{p}_{R}) + \\kappa(\\overline{p},\\dot{\\overline{p}} )\n\\end{split}\n\\end{equation}\nwhere $ \\kappa(\\overline{p},\\dot{\\overline{p}}) $ is a feedback action that can be computed as follow:\n\\begin{equation} \\label{eq:feedback}\n\\begin{split}\n\\zeta_{1}&:=\\overline{p}\\\\\n\\zeta_{2}&=\\dot{\\overline{p}} + \\lambda_{1} \\sigma (\\frac{k_{1}}{\\lambda_{1}}\\lambda_{2})\\\\\n\\kappa(\\overline{p},\\dot{\\overline{p}}) &:=\\lambda_{2}\\sigma(\\frac{k_{2}}{\\lambda{2}}\\zeta_{2})\n\\end{split}\n\\end{equation}\nwhere $k_{1}$, $k_{2}$, $\\lambda_{1}$ and $\\lambda_{2}$ are parameters to be tuned.\\\\\nIn \\autoref{eq:ctrlforce} is mandatory to respect the constraint\n\\begin{equation} \\label{eq:const}\n\\begin{split}\nR_{R}e_{3} &= \\frac{v^{c}_{R}(\\ddot{p}_{R})}{\\lVert v^{c}_{R}(\\ddot{p}_{R})\\rVert}\n\\end{split}\n\\end{equation}\n\nThe control scalar control force is than computed as:\n\\begin{equation} \\label{eq:controlForce}\n\\begin{split}\nu_{f} &:= \\lVert v^{c}(\\overline{p},\\dot{\\overline{p}},\\ddot{p}_{R})\\rVert\n\\end{split}\n\\end{equation}\n\\autoref{eq:controlForce} gives the total thrust the propeller should generate, however as already explained it is also necessary to compute the torque necessary to correct the vehicle attitude.\\\\\n\\autoref{sec:attControlLoop} will describe the attitude control low.\n\n\\section{Attitude control loop}\\label{sec:attControlLoop}\nThe torque control vector is computed in a control loop nested into the position control loop, therefore, as usual in cascade control loops, it has a faster dynamic.\nWe start by defining the error attitude quaternion and the error angular velocity vector:\n\\begin{equation} \\label{eq:qerr}\n\\begin{split}\n\\overline{q}&=q_{c}^{-1}\\oplus q\\\\\n\\overline{w}:&=w-\\overline{w}_{c}\\\\\n\\end{split}\n\\end{equation}\nwith\n\\begin{equation}\n\\begin{split}\n\\overline{w}_{c}:&=\\pazocal{R}(\\overline{q})^{T}w_{c}\n\\end{split}\n\\end{equation}\nand $q_{c}$ computed as explained in \\autoref{se:attSP}.\n\nThen the control torque is given by:\n\\begin{equation}\n\\begin{split}\nu_{\\tau}&=u_{\\tau}^{FF}(\\overline{q},w_{c},\\dot{w}_{c})   + u_{\\tau}^{FB}(\\overline{q},\\overline{w},\\overline{h})\\\\\nu_{\\tau}^{FF}(\\overline{q},w_{c},\\dot{w}_{c})   &=  J\\pazocal{R}(\\overline{q})^{T}\\dot{w}_{c}   - S(J\\overline{w}_{c}) \\overline{w}_{c}\\\\\nu_{\\tau}^{FB}(\\overline{q},\\overline{w},\\overline{h})   &=  -k_{p}\\overline{h}\\overline{\\epsilon}  -k_{d}\\overline{w}\n\\end{split}\n\\end{equation}\nIn the previous formula $k_{p}$ and $k_{d}$ are positive gains and $\\overline{h} = \\{-1,1\\}$ is obtained by the hybrid function $\\pazocal{H}_{c}$\n\\begin{equation}\n\\begin{split}\n\\pazocal{H}_{c} &= \\begin{cases} \\dot{\\overline{h}} = 0  & \\overline{h}\\overline{\\eta} \\geq -\\delta \\\\ \\overline{h}^{+} \\in \\overline{sgn}(\\overline{\\eta}) & \\overline{h}\\overline{\\eta} \\leq -\\delta  \\end{cases}\\\\\n\\overline{sgn}(s) &= \\begin{cases} sgn(s)  & \\lvert s \\rvert > 0 \\\\ \\{-1,1\\} &  s=0 \\end{cases}\\\\\n\\end{split}\n\\end{equation}\n$\\eta \\in (0,1)$ is the hysteresis threshold.\\\\\n\nThe control problem is more extensively explained in \\autocite{marconi}, however the article does not specify how to compute the reference attitude $R_{R}$; this problem is addressed in the following section.\n\n\n\\section{Attitude set-point generation} \\label{se:attSP}\nThe attitude reference orientation should be computed satisfying constraint \\ref{eq:const}. The problem has just 1 degree of freedom which, for standard uses cases (i.e. for non acrobatic maneuver), is the vehicle yaw angle.\\\\\nThis thesis proposes an algorithm to compute the reference rotation matrix $R_{R}$ based on geometric projection. Considering the $yaw$ angle given, then the heading vector is defined as:\n\\begin{equation}\n\\begin{split}\nd(yaw) &= [\\cos{(yaw)} , \\sin{(yaw)} , 0]^{T}\n\\end{split}\n\\end{equation}\nThe matrix $R_{R}$ is computed column-by-column as follows:\n\\begin{equation}\n\\begin{split}\nR_{R}e_{3} :&= \\frac{g e_{3} - \\ddot{p}}{\\lVert g e_{3} - \\ddot{p} \\rVert}\\\\\nR_{R}e_{2} :&= \\frac{R_{R}e_{3} \\times d(yaw)}{\\lVert R_{R}e_{3} \\times d(yaw)  \\rVert}\\\\\nR_{R}e_{1} :&= \\frac{R_{R}e_{2} \\times R_{R}e_{3}}{\\lVert R_{R}e_{2} \\times R_{R}e_{3} \\rVert}\n\\end{split}\n\\end{equation}\nThis technique allows to easily compute the reference rotation matrix that can be then easily converted to the quaternion rotation thanks to the Rodriguez formula.\nThe control attitude required in \\autoref{eq:qerr} is then computed as follows:\n\\begin{equation}\n\\begin{split}\nR_{c}e_{3} :&= \\frac{v_{c} }{\\lVert v_{c}  \\rVert} \\\\\nR_{c}e_{1} :&= \\frac{R_{R}e_{1} \\times R_{c}e_{3}}{\\lVert R_{R}e_{1} \\times R_{c}e_{3} \\rVert}  \\\\\nR_{c}e_{2} :&= \\frac{R_{c}e_{3} \\times R_{c}e_{1}}{\\lVert R_{c}e_{3} \\times R_{c}e_{1} \\rVert}  \n\\end{split}\n\\end{equation}\nend finally\n\\begin{equation}\n\\begin{split}\nq_{c} &= \\pazocal{R}^{-1}(R_{c})\n\\end{split}\n\\end{equation}\n", "meta": {"hexsha": "2c28077ba5e2c950ac377fe0c9a95f6bdaf73149", "size": 10133, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/Chapter05.tex", "max_stars_repo_name": "fmr42/MasterThesis", "max_stars_repo_head_hexsha": "0ff0d2100d6547afb67af40c0f355bec1a3c9150", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/Chapter05.tex", "max_issues_repo_name": "fmr42/MasterThesis", "max_issues_repo_head_hexsha": "0ff0d2100d6547afb67af40c0f355bec1a3c9150", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/Chapter05.tex", "max_forks_repo_name": "fmr42/MasterThesis", "max_forks_repo_head_hexsha": "0ff0d2100d6547afb67af40c0f355bec1a3c9150", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.9585798817, "max_line_length": 652, "alphanum_fraction": 0.7180499359, "num_tokens": 3303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4049846084547341}}
{"text": "\\chapter{Multiscale Entropy as a Measure of Relevant Information in an Image}\n \nSince the multiscale entropy extracts the information from the signal only, \nit was a  challenge to see if the  astronomical content of  an image\nwas related to its multiscale entropy.\n\nFor this purpose, we studied the astronomical content of 200 images \nof 1024 $\\times$ \n1024 pixels extracted from scans of 8 different plates carried out  \nby the MAMA facility (Paris, France) \n\\cite{astro:guibert92} and stored at CDS (Strasbourg, France) \nin the Aladin\narchive \\cite{compress:bonnarel99}. We estimated the content of these images \nin three different ways:\n\\begin{enumerate}     \n\\item By counting the number of objects in an astronomical catalog\n(USNO A2.0 catalog)   \nwithin the image. The\n USNO (United States Naval Observatory) \ncatalog was obtained by source extraction from the same survey \n plates as we used in our study.\n\\item By counting the number of objects estimated in the image by the\n Sextractor object detection \npackage \\cite{astro:bertin96}. As in the case of USNO \nthese detections are mainly point sources (stars, as opposed to \nspatially extended objects like galaxies).\n\\item  By counting the number of structures detected at several scales using \n the MR/1 multiresolution analysis package \\cite{starck:mr1_99}.\n\\end{enumerate}\n\n\\begin{figure}[htb]\n\\centerline{\n\\vbox{\n\\psfig{figure=fig_cds_pmm_entropy.ps,bbllx=2.8cm,bblly=2.8cm,bburx=20.5cm,bbury=15.4cm,width=10cm,height=6cm,clip=}\n\\psfig{figure=fig_cds_sext_entropy.ps,bbllx=2.8cm,bblly=2.8cm,bburx=20.5cm,bbury=15.4cm,width=10cm,height=6cm,clip=}\n\\psfig{figure=fig_cds_support_entropie.ps,bbllx=2.8cm,bblly=2.8cm,bburx=20.5cm,bbury=15.4cm,width=10cm,height=6cm,clip=}\n}}\n\\caption{Multiscale entropy versus the number of objects: the number\nof objects is, respectively, obtained from (top) the USNO catalog, (middle)\nthe Sextractor package, and (bottom) the MR/1 package.}\n\\label{fig_cds_entropy}\n\\end{figure}\n\nFigs.~\\ref{fig_cds_entropy} show the results of plotting these numbers \nfor each image against the multiscale signal entropy of the image. \nThe best results are obtained using the MR/1 package, \n followed by Sextractor and then by the number of sources extracted\n from USNO. Of course the latter two basically miss the content\nat large scales, which is taken into account by MR/1.\n\nSextractor and multiresolution methods were also applied to a set of CCD \nimages from CFH UH8K, 2MASS and DENIS near infrared surveys.\nResults obtained were very similar to what was obtained above.  This seems\nto point to multiscale entropy as being a universal measurement of image \ncontent.\n\nSubsequently we looked for the relation between the multiscale entropy and \nthe optimal compression\nrate of an image which we can obtain by multiresolution \ntechniques \\cite{starck:book98}. \n By optimal compression rate we mean \na compression rate which allows all the sources to be preserved, and which \ndoes not\ndegrade the astrometry and photometry.\nLouys et al.\\ \\cite{starck:louys99}  and Couvidat \\cite{compress:couvidat99}\nhave  estimated   this optimal\ncompression rate using the compression program of the \nMR/1 package  \\cite{starck:mr1_99}.\n\n\\begin{figure}[htb]\n\\centerline{\n\\hbox{\n\\psfig{figure=fig_cds_taux.ps,bbllx=2.8cm,bblly=2.8cm,bburx=20.5cm,bbury=15.4cm,width=10cm,height=6cm,clip=}\n}}\n\\caption{Multiscale entropy of astronomical images versus the optimal\ncompression ratio. Images which contain a high number of sources have\na small ratio and a high multiscale entropy value. The relation \nis almost linear.}\n\\label{fig_cds_taux}\n\\end{figure}\n\nFig.~\\ref{fig_cds_taux} shows the relation obtained \nbetween the multiscale entropy and the optimal compression rate\nfor all the images used in our previous tests including CCD ones. \nThe power law  relation is obvious thus allowing us to conclude that:\n\\begin{itemize}\n\\item  The compression rate depends strongly on the astronomical content \nof the image. We can then say that compressibility is \nalso an estimator of the content of the image.\n\\item The multiscale entropy allows us to predict the optimal \ncompression rate of the image.\n\\end{itemize}\n\n", "meta": {"hexsha": "9a9185c24d70864bc995d0dde2465c05db1c5e78", "size": 4167, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_mra/doc_mr2/cds.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_mra/doc_mr2/cds.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_mra/doc_mr2/cds.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.329787234, "max_line_length": 120, "alphanum_fraction": 0.7924166067, "num_tokens": 1126, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.40498460433201033}}
{"text": "% ------------------------------------------------------------------------\n% bjourdoc.tex for birkjour.cls*******************************************\n% ------------------------------------------------------------------------\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass{birkjour}\n%\n%\n% THEOREM Environments (Examples)-----------------------------------------\n%\n \\newtheorem{thm}{Theorem}[section]\n% \\newtheorem{cor}[thm]{Corollary}\n% \\newtheorem{lem}[thm]{Lemma}\n% \\newtheorem{prop}[thm]{Proposition}\n% \\theoremstyle{definition}\n \\newtheorem{defn}[thm]{Definition}\n% \\theoremstyle{remark}\n% \\newtheorem{rem}[thm]{Remark}\n% \\newtheorem*{ex}{Example}\n \\numberwithin{equation}{section}\n\n\\usepackage[noadjust]{cite}\n\\usepackage{amsfonts}\n\\usepackage{listings}\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\\usepackage{booktabs}\n\\usepackage{float}\n\\usepackage{caption}\n\n\\begin{document}\n\n%-------------------------------------------------------------------------\n% editorial commands: to be inserted by the editorial office\n%\n%\\firstpage{1} \\volume{228} \\Copyrightyear{2004} \\DOI{003-0001}\n%\n%\n%\\seriesextra{Just an add-on}\n%\\seriesextraline{This is the Concrete Title of this Book\\br H.E. R and S.T.C. W, Eds.}\n%\n% for journals:\n%\n%\\firstpage{1}\n%\\issuenumber{1}\n%\\Volumeandyear{1 (2004)}\n%\\Copyrightyear{2004}\n%\\DOI{003-xxxx-y}\n%\\Signet\n%\\commby{inhouse}\n%\\submitted{March 14, 2003}\n%\\received{March 16, 2000}\n%\\revised{June 1, 2000}\n%\\accepted{July 22, 2000}\n%\n%\n%\n%---------------------------------------------------------------------------\n%Insert here the title, affiliations and abstract:\n%\n\n\n\\title[Linear-Time Estimation of Smooth Rotations in ARAP Deformation]\n {Linear-Time \\\\Estimation of Smooth Rotations in \\\\ARAP Surface Deformation}\n\n%----------Author 1\n\\author[Mauricio Cele Lopez Belon]{Mauricio Cele Lopez Belon}\n\\address{Madrid, Spain}\n\\email{mclopez@outlook.com}\n\n%----------classification, keywords, date\n\\subjclass{Parallel algorithms 68W10; Clifford algebras, spinors 15A66}\n\n\\keywords{Geometric Algebra, Quaternion Estimation, Mesh Deformation}\n\n\\date{October 21, 2019}\n%----------additions\n%\\dedicatory{To my wife}\n%%% ----------------------------------------------------------------------\n\n\\begin{abstract}\n\nIn recent years the As-Rigid-As-Possible with Smooth Rotations (SR-ARAP \\cite{Levi2015}) technique has gained popularity in applications where an isommetric-type of surface mapping is needed. The advantage of SR-ARAP is that quality of deformation results is comparable to more costly volumetric techniques operating on tetrahedral meshes. The SR-ARAP relies on local/global optimization approach to minimize the non-linear least squares energy. The power of this technique resides on the local step. The local step estimates the local rotation of a small surface region, or cell, with respect of its neighboring cells, so a local change in one cell's rotation affect the neighboring cell's rotations and viceversa. The main drawback of this technique is that the local step requires a global convergence of rotation changes. Currently the local step is solved in an iterative fashion, where the number of iterations needed to reach convergence can be prohibitively large and so, in practice, only a fixed number of iterations is possible. This trade-off is, in some sense, defeating the goal of SR-ARAP. We propose a linear-time closed-form solution for estimating the codependent rotations of the local step by solving a sparse linear system of equations. Our method is more efficient than state-of-the-art since no iterations are needed and optimized sparse linear solvers can be leveraged to solve this step in linear time. It is also more accurate since this is a closed-form solution. We apply our method to generate interactive surface deformation, we also show how a multirresolution optimization can be applied to achieve real-time animation of large surfaces. \n\n\\end{abstract}\n\n%%% ----------------------------------------------------------------------\n\\maketitle\n%%% ----------------------------------------------------------------------\n%\\tableofcontents\n\\section{Introduction}\n\n\\indent Quatily of surface deformation aims to preserve local properties of shapes as much as possible, removing distortion in the form of shear and stretch. As-Rigid-As-Possible with Smooth Rotations (SR-ARAP) \\cite{Levi2015} aims to create a surface mapping that minimize the deviation from rigid behavior on the local scale. It also makes rigid transformations smoothly vary on local neighborhoods distributing the distortions  uniformly over the surface. The resulting deformations not only preserves the shape at small scale but also at large scale significantly increasing the quality of the final result.\n\nThere are two main disadvangates on the current SR-ARAP method. First is the local step, which looks for best rotations of corresponding surface cells while keeping neighbor rotations similar to each other. It needs to reach global convergence for the whole mesh. Currently the local step is solved with a relaxation method i.e., optimizing rotations for individual cells keeping cell's neighbor rotations fixed and also optimizing neighbor rotations in the same manner repeating that process until convergence. Although the cost per relaxation iteration can be reduced considerably by avoiding SVD calculations (\\cite{Ligare2020}) usually a fixed number of iterations is used in order to bound the solver time. That compromises the quality of results since a fixed number of iterations (usually two or three) is not enough to reach optimal rotations across the surface. Second is the high computational cost, that increases drastically when the number of vertices grows. The SR-ARAP is a non-linear technique that requires several iterations of local/global optmimization to converge.\n\nIn this paper we address both drawbacks of SR-ARAP, first we propose a method to solve the local step as a single linear system of equations, avoiding the need of iteratively solve a series of SVD problems which are codependant to each other. Second we propose a simple multiresolution method based on solving the non-linear system on a simplified surface mesh first and then use harmonic interpolation of rotations to transfer the optimized rotations to the full resolution mesh, leveraging the Laplacian matrix needed to solve the global step of the optimization.\n\n\n\\section{Related Work}\n\nSince the focus of this paper is on As-Rigid-As-Possible (ARAP) surface deformation methods we will only review previous works on ARAP deformation. The ARAP Surface Modeling was introduced by Sorkine and Alexa \\cite{Sorkine2007} to produce robust and physically plausible deformation by minimizing the local rigid transformation of the laplacian coordinates associated to every vertex. Although results on low resolution meshes looks close to physical deformations the method fails to achieve satisfactory results  on high resolution meshes. The reason is that the ARAP energy is minimized by preserving rigidity on large parts of the mesh at the expense of concentrating all the distortion on small parts of the mesh. This problem has been solved in the Smooth Rotation enhanced ARAP method (SR-ARAP) of Levi and Gotsman \\cite{Levi2015} where the deformation energy is extended with a further factor that penalizes too different rotations of close vertices, significantly increasing the quality of the final result. Chao \\emph{et al} \\cite{Chao2010} derives the ARAP enegry from the elastic energy of continuum mechanics showing a consistent discretization for volumetric ARAP with tetrahedron cells and for 2D ARAP with triangle cells in 2D. However the ARAP energy doesn't have a consistent discretization for triangle surfaces in 3D. The SR-ARAP method  \\cite{Levi2015} also address this issue providing an energy with a consistent discretization for surfaces in 3D. Further enhancements have been proposed to the SR-ARAP deformation technique addressing performance issues on large meshes \\cite{Morsucci2018, Ligare2020}, making it able to adjust physical stiffness \\cite{Chen2017, LeVaou2020} and Introducing local scaling to the rotation i.e., turning rigid transforms into a similarity transforms \\cite{Jiang2017}.\n\n\n\n\\section{As-Rigid-As-Possible Shape Deformation with Smooth Rotations}\n\nGiven two meshes $Q$ and $P$ consisting of vertices $q_i$ and $p_i$ respectively, and directed edges $p_{ij} = p_j - p_i$ and $q_{ij} = q_j - q_i$ , the discrete As-Rigid-As-Possible with Smooth Rotations (SR-ARAP) energy is defined as:\n\\begin{equation}\nE(Q, P) = \\sum_{i=1}^m { (\\sum_{j \\in N(i)} { c_{ij} \\|R_i (q_j - q_i) \\tilde R_i - (p_j - p_i)  \\|^2 } \\nonumber \\\\\n+ \\alpha A \\sum_{j \\in N(i)} {w_{ij} \\| R_j - R_i \\|^2} )}\\nonumber\n\\end{equation}\nwhere $R_1, ..., R_m \\in \\mathbb{H}$ are local quaternions, $N(i)$ denote the set of $1$-ring neighbors of vertex at position $i$, $c_{ij}$ are weighting coefficients such that $\\sum_j^n{c_{ij}} = 1$, typically the familiar cotangent weights, $w_{ij}$ are positive weighting coefficients such that $\\sum_j^n{w_{ij}} = 1$, $A$ is the mesh area used to make the energy scale invariant and $\\alpha$ is a positive scalar parameter.\n\nThe main idea of this method is breaking the surface into overlapping cells and seek for keeping the cells transformations as rigid as possible in the least squares sense. Overlap of the cells is necessary to avoid surface stretching or shearing at the boundary of the cells. \nThe first term is a membrane energy which penalizes stretching and shearing of a cell and the second term is the bending energy which penalizes the difference between a cell's rotation and the rotations of its neighboring cells. \nThe objective of the membrane term is to lower the distortion of a cell by keeping the map differential close to rigid. \nThe objective of the bending term is to keep the variation in the rotations in a cell neighborhood low, such that the neighborhood would transform as a unit, as much as possible. \n\nThe vertices of mesh $Q$ are in original position while vertices of mesh $P$ are the deformed vertices and the quaternion $R_i$ is the best rigid transformation, in the least squares sense, relating the original and the deformed vertices.\nThis is a non-linear optimization problem that is tipically solved by a iterative local/global method that solves two linear sub-problems on each iteration. \n\nThe first step, so called local step, is to consider the vertices of $P$ constant and obtain the best rigid transformation $R_i$ for each cell. The second step, so called global step, is to consider the rotations $R_i$ constant and computing the optimal deformed vertices $p_i$ in the least squares sense. \n\n\\section{Global Step}\n\nThe global step is computing the optimal vertices $\\{p_i\\} \\in P$.\n\\begin{eqnarray*}\nE(P) = \\min_{p_1,...,p_m \\in \\mathbb R^3} \\sum_{i=1}^m  (  \\sum_{j \\in N(i)} { c_{ij} \\|R_i q_{ij} \\tilde R_i -  p_{ij}\\|^2 } \\\\\n+ \\alpha A \\sum_{j \\in N(i)} { w_{ij} \\|R_i - R_j\\|^2 } )\n\\end{eqnarray*}\nTaking the partial derivatives of $E(P)$ w.r.t. $p_i$ and equating the result to zero lead us to obtain the linear system of Equation~(\\ref{eq:ls_for_p_ga}) (\\cite{Lopez2013}):\n\\begin{eqnarray}\n\\label{eq:ls_for_p_ga}\n\\sum_{j \\in N(i)} { c_{ij} (p_j - p_i) } = \\sum_{j \\in N(i)} { \\frac{c_{ij}}{2} (R_i q_{ij} \\tilde  R_i + R_j q_{ij} \\tilde R_j) }\n\\end{eqnarray}\nwhich can be expressed in matrix form as $\\mathrm L \\; \\mathrm P = \\mathrm C$, where $\\mathrm L$ is the discrete Laplace-Beltrami operator, $\\mathrm P$ is the column of target positions and $\\mathrm C$ a column vector whose $i$th row is the right hand side of equation (\\ref{eq:ls_for_p_ga}). Constraints of the form $p_i = p^{const}_i$ are incorporated into the system by substituting the corresponding variables i.e., erasing respective rows and columns from $\\mathrm L$ and updating the right-hand side of equation (\\ref{eq:ls_for_p_ga}) with the values $p^{const}_i$. The system is then solved in the least squares sense:\n\\begin{eqnarray}\n(\\mathrm L^T \\mathrm L) \\; \\mathrm P = \\mathrm L^T \\ \\mathrm C\n\\end{eqnarray}\n\n\\section{Local Step}\n\nAs described in a previous sections, the rotations matching cell's are codependent to each other over the whole mesh. The current approach is to optimize the rotations with a relaxation method in which the rotation of each cell is independently computed, while keeping the neighbor rotations fixed, repeating it until global convergence is reached. At least two relaxation iterations must be done per each global iteration. In this section we show how the local step can be solved in closed form as a single sparse linear system eliminating entirely the need of relaxation iterations.\n\n\\subsection{Closed Form of Local Step}\n\nWe attempt to minimize the SR-ARAP energy function:\n\\begin{eqnarray}\nE(R) = \\min_{R_1,...,R_m \\in \\mathbb H} \\sum_{i=1}^m  (  \\sum_{j \\in N(i)} { c_{ij} \\|R_i q_{ij} \\tilde R_i -  p_{ij}\\|^2 } \\\\\n+ \\alpha A \\sum_{j \\in N(i)} { w_{ij} \\|R_i - R_j\\|^2 } )\n\\end{eqnarray}\n\nIgnoring temporarily the sum over all vertices, the energy to minimize in the neighborhood of a point $p_i$ is $E_i(R_i)$:\n\n\\begin{eqnarray}\nE_i(R_i) =  \\sum_{j \\in N(i)} { c_{ij} \\|R_i q_{ij} \\tilde R_i - p_{ij}  \\|^2 } + \\alpha A \\sum_{j \\in N(i)} {w_{ij} \\| R_j - R_i \\|^2} \\nonumber\n\\end{eqnarray}\nNotice that the first term $\\sum_{j \\in N(i)} { c_{ij} \\|R_i q_{ij} \\tilde R_i - p_{ij}  \\|^2 } $ can be written in matrix language as the quadratic form $R_i^T M_i R_i$ where $M_i$ is a $4\\times4$ matrix constructed from vectors $q_{ij}$ and $p_{ji}$ (see Section \\ref{section:the_form_of_arap_matrix}):\n\\begin{eqnarray}\n\t\tE_i(R_i) = R_i^T M_i R_i + \\alpha A \\sum_{j \\in N(i)} {w_{ij} \\| R_j - R_i \\|^2  }\\\\ \\nonumber\n\\end{eqnarray}\n\nDifferentiating with respect to $R_i$ we get:\n\\begin{eqnarray}\n\t\\label{eqn:max_energy}\n\t\\frac{\\partial E_i(R_i)}{\\partial R_i}  = 2 M_i R_i + 2 \\alpha A \\sum_{j \\in N(i)} {w_{ij} (R_i - R_j) }\\\\\n\t= M_i R_i + \\alpha A R_i - \\alpha A \\sum_{j \\in N(i)} {w_{ij} R_j } \n\\end{eqnarray}\n\nSetting the partial derivatives to zero $\\frac{\\partial E_i(R_i)}{\\partial R_i}  = 0$\n\n\\begin{eqnarray}\n\t\\label{eqn:local_solution}\n\t(M_i + \\alpha A I)R_i  = \\alpha A \\sum_{j \\in N(i)} {w_{ij} R_j }\\\\ \\nonumber\n\\end{eqnarray}\n\nWhich is a linear system of equations. The system (\\ref{eqn:local_solution}) can be solved for all quaternions in closed form. Writing (\\ref{eqn:local_solution}) in matrix form we get:\n\n\\begin{eqnarray}\n\t\\label{eqn:local_solution_closed_form}\n\t\\mathrm M \\; \\mathrm R = \\mathrm W \\; \\mathrm R\\\\\n\t(\\mathrm M - \\mathrm W) \\mathrm R = \\mathrm 0\n\\end{eqnarray}\n\nWhere $\\mathrm M$ is a symmetric sparse  matrix  with dimensions $4n\\times 4n$ which is stacking $M_i$ at its diagonal, $\\mathrm W$ is a discrete Laplacian matrix with dimensions $4n\\times 4n$ derived from RHS of (\\ref{eqn:local_solution}) i.e., $\\sum_{j \\in N(i)} {\\alpha A w_{ij} R_j }$ holding the coefficients $\\alpha A w_{ij}$. $\\mathrm R$ is column matrix of dimensions $1\\times 4n$ stacking the coefficients of quaternions $R_i$.\n\nThe sparse linear system of (\\ref{eqn:local_solution_closed_form}) can be solved by imposing quaternion constraints $R^{const}_i$ which corresponds to best rotation of constrained points $p^{const}_i$:\n\\begin{eqnarray}\n\t\\label{eqn:local_solution_closed_form_const}\n\t(\\mathrm M - \\mathrm W) \\mathrm R = \\mathrm 0\\\\\n\ts.t. \\ R_i = R^{const}_i \\nonumber\n\\end{eqnarray}\n\nConstraints of the form $R_i = R^{const}_i$ are incorporated into the system by substituting the corresponding variables i.e., erasing respective rows and columns from $(\\mathrm M - \\mathrm W)$ and updating the right-hand side of (\\ref{eqn:local_solution_closed_form_const}) with the values $R^{const}_i$. The system is then solved in the least squares sense.\n\nSince the constraint $R_i^T R_i = 1$ is not honored by the linear system the quaternion $R_i$ given as solution must be normalized. As shown in \\cite{Ligare2020} the solution of (\\ref{eqn:local_solution}) gives a linear approximate solution to the optimal quaternion in the least squares sense. Our results confirm that the proposed linearization is accurate for the SR-ARAP rotations and it is not affecting accuracy in any significant way.\n\n\\subsection{Rotation constraints $R^{const}_i$}\n\nThe rotation constraints $R^{const}_i$ in (\\ref{eqn:local_solution_closed_form_const}) have to be computed directly from equation (\\ref{eqn:local_solution}) for each constrained point $p^{const}_i$:\n\\begin{equation}\n\tR^{const}_i  = (M_i + \\alpha A I)^{-1}  \\sum_{j \\in N(i)} {\\alpha A w_{ij} R^{prev}_j } \\nonumber\n\\end{equation}\nwhere neighbor rotations $R^{prev}_j$ are known from previous iteration. So computing constraint quaternionss amounts to solve a small $4\\times4$ linear system. The resulting quaternion $R^{const}_i$ must be normalized.\n\n \\subsection{Rotation's Feedback}\n \nThe linear system of (\\ref{eqn:local_solution_closed_form_const}) find quaternions from scratch i.e., it doesn't take into account the previous state of the quaternions i.e., the temporal coherence. That might lead to undesired results in an animation sequence. In particular, the sense of the rotations found by (\\ref{eqn:local_solution_closed_form_const}) for some animation step are not always respecting the sense of rotations from previous time. The abrupt change in the sense of rotation cause animation artifacts specially for large rotations.\n\nThe equation (\\ref{eqn:local_solution_closed_form_const}) allow us to introduce \\emph{feedback} quaternions to the RHS which acts as \\emph{hints} to find quaternions close to the ones in previous iteration. Given the quaternion $R^{prev}_i$ and a positive small scalar value $\\epsilon_i$ we augment equation (\\ref{eqn:local_solution}) in the following way:\n\n\\begin{eqnarray}\n\t\\label{eqn:local_solution_feedback}\n\t(M_i + \\alpha A I)R_i  = \\alpha A \\sum_{j \\in N(i)} {w_{ij} R_j} + \\epsilon R^{prev}_i\n\\end{eqnarray}\nwhere  $\\sum_{j \\in N(i)} {w_{ij}} = 1-\\epsilon$. Our intention is to make $R_i$ a neighbor of itself, in some sense. The strength of feedback is given by $\\epsilon$. So the global system is changed as follows: \n\\begin{eqnarray}\t\\label{eqn:local_solution_closed_form_const_feedback}\n\t(\\mathrm M - \\mathrm W) \\mathrm R = \\epsilon \\mathrm R^{prev}\\\\\n\ts.t. \\ R_i = R^{const}_i \\nonumber\n\\end{eqnarray}\nwhere $\\mathrm R^{prev}$ is a $1\\times4n$ column vector stacking all the unconstrained quaternions $R^{prev}_i$ from previous iteration.\n\n\\section{Multiresolution Optimization}\n\nFor achieving real-time performance we optimize the SR-ARAP energy in a low resolution version of the input mesh and then we transfer that solution to the full resolution mesh. To obtain the low resolution mesh we simplify the mesh using \\emph{half edge collapses} (i.e., the simplified mesh is a triangulation of a subset of the original vertices) while minimizing the Quadrics error metric.\nAfter we obtained the optimal deformed shape on the simplified mesh we transfer the optimized rotations to the full resolution mesh using Harmonic Interpolation of quaternions (see Section \\ref{section:harmonic_interpolation_rotors}) and then solve the following linear system using the optimized vertices of the low resolution mesh as positional constraints:\n\\begin{eqnarray*}\n\\sum_{j \\in N(i)} { c_{ij} (p_j - p_i) } = \\sum_{j \\in N(i)} { \\frac{c_{ij}}{2} (R_i q_{ij} \\tilde  R_i + R_j q_{ij} \\tilde R_j) }\n\\end{eqnarray*}\n\n\\subsection{Harmonic Interpolation of Quaternions}\n\\label{section:harmonic_interpolation_rotors}\n\nThe seminal work of Pinkall and Polthier \\cite{Pinkall1993} shows how to interpolate given data over a discrete domain using harmonic maps. Harmonic maps are critical points of the Dirichlet energy (stretching energy) $\\int_{\\Omega}{ |\\nabla f|^2 dA }$, which generates minimal surfaces. \nThe \\emph{discrete harmonic energy} of a map $f$ defined on mesh vertices $\\{p_i\\}$ has the form:\n\\begin{equation}\nE(f) = \\sum_{i,j}{c_{ij} \\| f(p_j) - f(p_i) \\|^2 }\n\\end{equation}\nwhere $w_{ij}$ are the (symmetric) cotangent weights \\cite{Pinkall1993} defined on triangle edges going from $p_i$ to $p_j$. The discrete Laplacian operator can be identified in that energy as:\n\\begin{equation}\n\\Delta f = \\sum_{j \\in N_i} { c_{ij} ( f(p_j) - f(p_i) ) }\n\\end{equation}\nwhere $N_i$ is the set of indices of the neighbors of vertex $p_i$. It is known that harmonic energy minimizes angular distortions. That means that harmonic functions smoothly blend boundary conditions over the domain. Harmonic functions are intrinsic to surfaces and independent of the discretization used to produce meshes. In spirit similar to \\cite{Zayer2005}, we propose the interpolation of quaternions over a mesh using harmonic functions. The harmonic quaternion interpolation over a surface mesh can be formulated as the solution to the following discrete harmonic equation:\n\\begin{eqnarray}\n\\label{eq:harmonic_rotor}\n   \\sum_{j \\in N(i)} { c_{ij} ( R_j - R_i ) } = 0\n\\end{eqnarray}\nsubject to Dirichlet boundary conditions $R_k = R^{const}_k$, where $\\{R^{const}_k\\}$ are the optimized quaternions from the lower resolution mesh and $\\{c_{ij}\\}$ are the cotangent weights. This leads to the solution of a sparse linear matrix system. This interpolation produces a smooth field of quaternions by ``averaging'' the boundary conditions gradually over the surface. This is in effect equivalent to a linear interpolation of boundary conditions across the surface. It can be written in matrix form as:\n\\begin{eqnarray}\n\t\\mathrm L \\; \\mathrm R = 0\\\\\n\ts.t. \\ R_k = R^{const}_k \\nonumber\n\\end{eqnarray}\nwhere $\\mathrm L$ is discrete Laplacian operator used to solve the global step. Note that interpolated quaternons are not of unit length and must be normalized afterwards. Despite the simplicity of this approach, it works surprisingly well, it is extremely efficient, and it provides a natural propagation at no extra cost.\n\n \\section{The form of $M_i$}\n \\label{section:the_form_of_arap_matrix}\n\nNotice that the membrane term $\\sum_j \\|R_i q_{ij} \\tilde R_i - p_{ij} \\|^2$ is equivalent to $\\sum_j  \\|R_i q_{ij} - p_{ij} R_i\\|^2$ under the L2 norm. Also notice that  $R_i q_{ij} - p_{ij} R_i$ can be rewriten as $(w_i + B_i) q_{ij}  - p_{ij} (w_i + B_i)$ for some a scalar $w_i$ and pure quaternion $B_i$ such that $R_i = w_i + B_i$. Expanding the quaternion product in terms of the inner product and the cross product we get:\n\\begin{eqnarray}\n     (q_{ij} - p_{ij}) w_i - (q_{ij} - p_{ij}) \\cdot B_i - (q_{ij} + p_{ij}) \\times B_i\n\\end{eqnarray}\nThe expression above can be written in matrix form to get the matrix system $M_{ij} R_i$:\n\\begin{eqnarray}\n\tM_{ij} R_i =\n\t\\left[\\begin{array}{cc}\n\t\t0        &       -d_{ij}^T \\\\\n\t\td_{ij}  &   \\left[ s_{ij} \\right]^T_\\times \\\\\n\t\\end{array}\\right]\n\t\\left[\\begin{array}{c} \n\t\tw_i \\\\\n\t\tB_i\n\t\\end{array}\\right] = \n\t\\left[\\begin{array}{c}\n\t\t-d_{ij}^T B_i \\\\\n\t\tw_i d_{ij} - s_{ij} \\times B_i \n\t\\end{array}\\right]\\\\\n\td_{ij} = q_{ij} - p_{ij} \\ \\ s_{ij} = p_{ij} + q_{ij}  \\nonumber\n\\end{eqnarray}\nwhere $d_{ij}$ and $s_{ij}$ are $3 \\times 1$ column vectors holding pure quaternion coefficients, $M_{ij}$ is a skew-symmetric $4\\times 4$ real matrix, so that $M_{ij}^T = -M_{ij}$. The quaternion $R_i$ is represented as $4 \\times 1$ column vector made of the scalar $w_i$ and the $3 \\times 1$ column vector $B_i$ holding the pure quaternion components. The $3\\times 3$ matrix $\\left[ s_{ij} \\right]_\\times$ is representing the skew-symmetric cross-product matrix as usually defined for vectors in $\\mathbb R^3$.\n\nWe can express $\\sum_j \\|R_i q_{ij} - p_{ji} R_i\\|^2$ as the quadratic form $R_i^T M_i R_i$ where $M_i = \\sum_j^n { c_{ij} M_{ij}^T M_{ij}}$. Note that since $M_{ij}$ is skew-symmetric, the product $M_{ij}^T M_{ij}$ is symmetric and positive semi-definite.\nConsequently the matrix $M_i$ is also symmetric positive semi-definite. It follows that all eigenvalues of $M_i$ are real and $\\lambda_i \\geq 0$.\n\\begin{eqnarray}\n\tM_{ij}^T M_{ij} = \n\t\\left[\\begin{array}{cc}\n\t\t\\| d_{ij} \\|^2       &         (s_{ij} \\times d_{ij})^T \\\\\n\t\ts_{ij} \\times d_{ij}  &    d_{ij} d_{ij}^T - \\left[ s_{ij} \\right]^2_\\times \\\\\n\t\\end{array}\\right]\\\\\n\td_{ij} = q_{ij} - p_{ij} \\ \\ s_{ij} = p_{ij} + q_{ij}  \\nonumber\n\\end{eqnarray}\n\n\n \\subsection{Efficient Computation of $M_i$}\n\nThe symmetric matrix $M_{ij}^T M_{ij}$ has a simple form:\n\n\\begin{eqnarray*}\n\tM_{ij}^T M_{ij} = \n\t\\left[\\begin{array}{cc}\n\t\t\\| d_{ij} \\|^2        &         (s_{ij} \\times d_{ij})^T \\\\\n\t\ts_{ij} \\times d_{ij}  &    d_{ij} d_{ij}^T - s_{ij} s_{ij}^T + \\| s_{ij} \\|^2 I_{3\\times3} \\\\\n\t\\end{array}\\right]\\\\\n     d_{ij} = q_{ij} - p_{ij} \\ \\ s_{ij} = p_{ij} + q_{ij}  \\nonumber\n\\end{eqnarray*}\n\nWriting it in terms of $p_{ij}$ and $q_{ij}$ we get:\n\n\\begin{eqnarray}\n   \\label{eqn:matrix_fast}\n   \tM_{ij}^T M_{ij} \n   \t= 2\n\t\\left[\\begin{array}{cc}\n\t\tq_{ij}^T p_{ij}       &         (q_{ij} \\times p_{ij})^T \\\\\n\t\tq_{ij} \\times p_{ij}  &    q_{ij} p_{ij}^T + p_{ij} q_{ij}^T - q_{ij}^T p_{ij} I_{3\\times3} \\\\\n\t\\end{array}\\right]\\\\ \\nonumber\n    + (\\| p_{ij} \\|^2 + \\| q_{ij} \\|^2) I_{4\\times4}\n\\end{eqnarray}\nAll terms of \\ref{eqn:matrix_fast} can be derived from the dyadic tensor $q_{ij} p_{ij}^T$ plus the quantity $\\|p_{ij} \\|^2 + \\| q_{ij} \\|^2$. Since matrix $q_{ij} p_{ij}^T$ is of $3\\times3$ its computation is efficient. \n\n\\section{Implementation}\n\nThe author's source code is publicly available at github \\cite{GALinearizedArap}.\n\n\\section{Results}\n\n\\section{Conclusion}\n\n\n\n\n\\bibliographystyle{abbrv}\n\\bibliography{linealizedrotations}\n\n% ------------------------------------------------------------------------\n\\end{document}\n% ------------------------------------------------------------------------\n", "meta": {"hexsha": "a68774b9c017e63716f8115887af4d3302025772", "size": 25748, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "fast-linealized-rotation/linealizedrotations.tex", "max_stars_repo_name": "mauriciocele/arap-sr-linearized", "max_stars_repo_head_hexsha": "94d7cb8b48b63da2065993528dcc97712523fb07", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T15:14:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-08T14:08:49.000Z", "max_issues_repo_path": "fast-linealized-rotation/linealizedrotations.tex", "max_issues_repo_name": "mauriciocele/arap-sr-linearized", "max_issues_repo_head_hexsha": "94d7cb8b48b63da2065993528dcc97712523fb07", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fast-linealized-rotation/linealizedrotations.tex", "max_forks_repo_name": "mauriciocele/arap-sr-linearized", "max_forks_repo_head_hexsha": "94d7cb8b48b63da2065993528dcc97712523fb07", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 76.1775147929, "max_line_length": 1822, "alphanum_fraction": 0.7197840609, "num_tokens": 7057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.40498460433201033}}
{"text": "\\chapter{Comments Prior to Implementation}\n \n\\begin{quotation}\nIf God has made the world a perfect mechanism, he has at least\nconceded so much to our imperfect intellect that in order to predict\nlittle parts of it, we need not solve innumerable differential\nequations, but can use dice with fair success.  \n{\\em Max Born, quoted  in H.~R.~Pagels, The Cosmic Code \\cite{pagels1982}}\n\\end{quotation}\n\n\\abstract{This chapter aims at giving an overview on some of the most\n  used methods to solve ordinary differential equations. Several\n  examples of applications to physical systems are discussed, from the\n  classical pendulum to the physics of Neutron stars.}\n\n\nIn this chapter we discuss a few external libraries used in the implementation and how they work. Also we will discuss a few guiding principles we will apply to our implementation later. We will mainly discuss armadillo, MPI and general parallel programming. We will also mention OpenMP and external math libraries. The external math library we will use is Intel MKL.\n\n\\section{Armadillo}\nArmadillo is a C++ linear algebra library. The library is designed to be similar to matlab in syntax. It provides good speed relative to other libraries and makes it easy to utilize matrix or vector multiplications in an efficient way. The armadillo documentation is available in Ref.\\cite{armadillo-ref1}. Armadillo is also available for other programming languages, but we will strictly focus on the C++ version.\n\n\\subsection{Armadillo Types}\nArmadillo has its own objects. We will use four objects in armadillo. The first three are vector, matrix and cube. These are simply put one, two and three dimensional arrays defined by standard to contain numerical values of double precision. The last is field. A field in armadillo is a two dimensional array that can contain other things than numerical values. A field can contain things like strings, vectors, matrices or cubes. Anything that can be used in combination with the \"=\" operator and a copy, like memcpy(). A field can be defined like this:\n\n\\begin{equation}\nfield<mat> A \\nonumber\n\\end{equation}\nThis defines a two dimensional field of matrices, meaning a four dimensional array. The field is called \"A\". This can be accessed by first two indexes for the field and next two indexes for the matrix. A(0,1) for example is the matrix with indexes 0 and 1 in the field. A(0,1)(2,3) is a double precision number with indexes 2,3 in the matrix located in indexes 0,1 in the field A.\n\n\\subsection{Matrix Operations}\nMatrix multiplication can be utilized very easy in armadillo. If there are three matrices defined, A, B and C, we can easily call on matrix multiplication by stating:\n\n\\begin{lstlisting}\nC = A * B \n\\end{lstlisting}\nOther operations available are additions, subtractions, element wise multiplications and element wise divisions. These are accessed in order like this:\n\n\\begin{lstlisting}\nC = A + B;\nC = A - B;\nC = A % B;\nC = A / B;\n\\end{lstlisting}\nAlso there is a function called accu(C). This is an accumulation function that accumulates the values of C, where C can be a vector, matrix or a cube. If used in combination we can define\n\n\\begin{lstlisting}\nD = accu(A % B)\n\\end{lstlisting}\nThis leaves D as a double precision number. Here A and B are first element wise multiplied and the resulting matrix accumulated. A and B must be same size. This will be used in our implementation. Take for example the term\n\n\\begin{equation}\nD_{ij}^{ab} t_{ij}^{ab} \\leftarrow \\sum_{cd} I_{ab}^{cd} \\tau_{ij}^{cd} . \\label{armadilloterm}\n\\end{equation}\n\nIf we store I as a field with indexing I(a,b)(c,d) and $\\tau_{ij}^{cd}$ is stored as a field with indexing $\\tau$(i,j)(c,d) then we can use element wise multiplication and accumulation to calculate Eq. \\eqref{armadilloterm}.\n\n\\begin{equation}\n\\sum_{cd} I_{ab}^{cd} \\tau_{ij}^{cd}\n= accu(I(a,b) \\% \\tau(i,j)) .\n\\end{equation}\nHere I(a,b) is a matrix and $\\tau$(i,j) is a matrix of same size. A major positive of armadillo is that it is possible to link other effective external math libraries to perform the actual matrix operations. We can link BLAS, LAPACK, OpenBLAS and many others. Armadillo initiates calls to these libraries automatic and effectively if installed properly. We then get the effectiveness of the best external math libraries, and the simplicity of the armadillo syntax.\n\n\\subsection{Element access}\nAn interesting feature when using armadillo is the way we access elements. In C syntax one usually allocates an array using malloc(). This gives great control over memory accessing, as we can have even multidimensional arrays sequential in memory. \\\\\n\nIn armadillo we usually allocate a matrix with just mat A. We can have a field of matrices with field<mat>. However each element in the field must be allocated on its own. Also armadillo has a few checks in place to ensure a bug free working code. Based on performance and experience, this is not efficient. \\\\\n\nOther types in armadillo such at mat or vector is quite efficient. However when using this library it is important to be aware that not all types in armadillo are as efficient when it comes to memory access. Usually it is best to stick with one or two dimensional arrays as much as possible, even make temporary vectors or matrices to avoid accessing a field to much. Trial and error is thus a good tool if we want to use armadillo for high performance computing. This comment applies to armadillo at the time of this thesis. The armadillo developers are continuously working to improve the performance. \\\\\n\nAnother problem we encountered in our implementation is that OpenMPI does not take armadillo types in its communication functions. Armadillo does have functions that can help modestly in this regard, like the function .memptr(). However, we found it was not an optimal combination.\n\n\\section{Parallel Computing and OpenMPI}\nThe Open Source Message Passing Interface, OpenMPI, will be used in our implementation, Ref.\\cite{openmpi_cite}. OpenMPI is a library that makes parallel computing much easier. It removed the need for low level parallel programming. In this section we will discuss briefly why we need parallel computing and what it is.\n\n\\subsection{The CPU \\label{the_cpu_section}}\nThe CPU, or the Central Processing Unit, is the brain of the computer. This unit processes instructions, many of which requires transfer from or to the memory on a computer. \\\\\n\nThe CPU integrates many components, such as registres, FPUs and caches. The CPU has a \"clock\" that synchronizes the logic units within the CPU each clock cycle to precess instructions. Among other things this clock allows us to accurately measure the time used from one section of the program to another. \\\\\n\nInstructions are put in a pipeline for the CPU to execute. While the CPU is processing instructions, it also looks down the pipeline, to see what instructions it will need to perform soon and what values it will need. These values can then pre-emptively placed in the cache. In the cache they are faster to access when they are needed. \\\\\n\nIf the CPU makes a wrong guess on for example an if test, the pipeline is filled with instructions that should not be processed and must be flushed. This slows down performance. \\\\\n\nA supercomputer consists of nodes. Each node has a number of CPUs. On the abel super computing cluster, each node has 16 CPUs. \n\n\\subsection{The Compiler}\nThe compiler allows the CPU to understand easy syntax such as C++. The compiler takes the code as input and produce the .o file. In the .o file there are instructions for the CPU to process. The CPU only understands the .o file, as such we must always compile our code. The compiler also creates the pipeline. We want the pipeline to be as optimal as possible, for this reason we need a good compiler. \\\\\n\nA normal compiler performs a three step procedure. Step one is to check the code for syntax errors, include problems and other basics. \\\\\n\nStep two is to translate the code into an intermediate language. Here optimizations are performed. If we wrote a code segment like this\n\n\\begin{lstlisting}\ndouble A, B, C;\nA = 50;\nB = 20;\nC = B * B * B;\n\n// More calculations\n\nB *= A;\n\\end{lstlisting}\n\nThe compiler will take note that the variable A is defined early on, and used much later. A is defined, stored into memory, then read from memory and finally it takes part in calculations. The compiler can rearrange our code to optimize this segment. \n\n\\begin{lstlisting}\ndouble B, C;\nB = 20;\nC = B * B * B;\n\n// More calculations\n\ndouble A = 50;\nB *= A;\n\\end{lstlisting}\n\nHere the variable A is defined and used directly. It is defined were we need it and ready in the pipeline for calculations. If the pipeline for some reason is filled with wrong instructions, we will not take advantage of optimizations such as this. \\\\\n\nStep three is to output the .o file. Compilers are extremely complex, we should mention this was a brief and simplified description. \n\n\\subsection{Data}\nData is stored in memory as a sequence of 0s and 1s. One 0 or 1 occupies one bit. 8 bits is one byte. The memory is read as bytes. Even a bool which can either be true or false is one byte. A bool of value true is stored in memory as 00000001. \\\\\n\nOther types of data have different sizes in memory. An int is 4 bytes, a float 4 bytes and a double 8 bytes. Data is usually stored in memory, or rapid access memory, RAM. Here we can access it faster than from disk. \\\\\n\nOn a supercomputer, each node has a fixed number of memory available. The CPUs on the node can share this memory, or we can distribute it into smaller chunks were each CPU has its own unshared memory. \n\n\\subsection{Bandwidth}\nThe bandwidth is a measure of number of bytes transferred per second. The bandwidth is a feature of the hardware, we will look at it as a constant value. We will be dealing with software. \\\\\n\nIf we want to send an array of 100 doubles from one computer to another, this will be 800 bytes. If we sent it as floats, it would be 400 bytes. If we assume the bandwidth is same, it would be twice as fast to transfer floats than doubles. \\\\\n\nHowever, we will always use double precision values. But also in situations where we can reduce the size of the array, if it for example is symmetric. If we reduce the size by half, to 50 doubles or 400 bytes, we have saved much time in communication. \\\\\n\nThe communication inside a node is quite fast on a supercomputer. However when we need to use multiple nodes at once there are challenges. The nodes are not at the same physical distance to each other, this means we can not achieve the same bandwidth between different nodes. Abel supercomputer has nodes stacked in a rack. The nodes inside the same rack are closer. The bandwidth is usually higher in communication inside a rack, relative to communication between nodes in different racks. \n\n\\subsection{Designing Parallel Algorithms}\nWhen we design a parallel algorithm we look for hotspots. These are computation intense areas, and a parallel implementation should be designed to work good around this area. \\\\\n\nHowever we must be careful, as communication can sometimes overtake computation. This can happen even in computation intense areas. A measure known as Granularity is known as the ratio of computation versus communication.\n\n\\subsection{Performance}\nA serial algorithm is evaluated by its runtime. The runtime of a parallel program depends on input size , number of processors and the communication. This is a multidimensional problem, and not so easy to measure. \\\\\n\nSometimes we can use two different algorithms to solve the same problem. One algorithm may be more efficient in serial, while the other is more efficient in parallel. \\\\\n\nTo measure how good performance our parallel algorithm gives, it must be measured against the best serial algorithm for the given problem. This is true even if the best serial algorithm is in no way close to the same as the parallel algorithm. \\\\\n\nOne could imagine a serial program that solves a problem in 10 seconds, but is impossible to run in parallel. And we can imagine another algorithm that solves it in 100 seconds, but runs easily in parallel. If we run the second algorithm with 5 CPUs, and say this takes 20 seconds. It would still be better to use the first serial algorithm. The parallel performance can only be described as not good. This is true until you can run the second algorithm in less time than 10 seconds. \\\\\n\nA good model of performance we will use is the Speedup, S.\n\n\\begin{equation}\nS(p) = \\frac{T_0}{T_p} .\n\\end{equation}\nWith ideal performance $S(p)$ is linear, preferably $S(p) = p$. As we noted in section \\ref{the_cpu_section} values needed for calculation are pre-emptively placed in the catche. If a CPU cannot fit all values needed for calculations in the catche, the CPU must get these values from main memory. This slows down performance considerably. \\\\\n\nWe consider a large array we want to use in calculations. It is twice as large as the catche. If we introduce two CPUs, we can split the array in two and fit it in the catche. We will then avoid the performance loss from memory accessing. This creates the possibility of super linear scaling. This is a situation where we double the number of CPUs, and get more than a doubling in performance. Figure \\ref{super_linear_scaling} is an illustration of different types of scaling.\n\n\\begin{figure}[ht!]\n\\centering\n\\includegraphics[width=90mm]{scaling_plots_examples_1000.eps}\n\\caption{Illustration of possible scaling plots. Linear, Super linear and non linear is plotted.}\n\\label{super_linear_scaling}\n\\end{figure}\n\n\\subsection{Overhead}\nIf we try to solve a problem using two processor, it will normally not be twice as fast as it would be on one processor. This is because of overhead. Overhead are things like wasted computations, communication and latency. \\\\\n\nWasted computation would be additional computations required for running the algorithm in parallel. Latency is the time interval required to initiate a communication, and also to tell the processors that the communication is completed. \\\\\n\nRuntime in a serial program is often denoted as $T_S$. The time from the first processor to start, until the last processor exits, is often noted a parallel runtime, $T_P$. The overhead, $T_O$, can then be described as\n\n\\begin{equation}\nT_O = p T_P - T_S ,\n\\end{equation}\nwhere p is the number of processors. Overhead is commonly increased as we increase the number of processors.\n\n\\subsection{General Parallel Guidelines}\nFor this implementation we will use a few simple guidelines with MPI. First we want to minimize the number of initiated communications. This is to reduce latency. When a communication is initiated, processors are syncronized. This means all processors enter into an MPI function at the same time. If one CPU is faster than another, this CPU will have to be idle and wait for the others to reach the communication function. This is undesireable. Also when exiting a communication, CPUs does not exit at the same time. This is another reason for minimizing the number of synchronizations. \\\\\n\nSecond we want to minimize the number of bytes to be communicated, mainly through symmetries. We want to design our algorithm specifically for this purpose. Third we want to use OpenMPI, which has optimized functions for communication implemented. In Appendix A we list many of these functions, with a short description of what they do.\n\n\\subsection{Optimizing Communication}\n\nWe will not go in detail on how the MPI functions are optimized. A good book on the subject is Ref. \\cite{mpi_boka_cite_referanse}. We will only entertain a small example. \\\\\n\n\\begin{figure}[ht!]\n\\centering\n\\includegraphics[width=90mm]{mpi_communication.jpg}\n\\caption{Illustration of two scenarios. Scenario one is a naive implementation of a broadcast. Scenario two is one example on how performance can be improved.}\n\\label{mpi_communication_illustration_thingy}\n\\end{figure}\n\nThis example is illustrated in figure \\ref{mpi_communication_illustration_thingy}. Say we have four processors. We want to broadcast a message from processor 1 to all the others. We distinguish the first processor by its rank, it is rank 1. If rank 1 sends its message to rank 2, then rank 3 and then rank 4, there must be three communications performed by rank 1. One communication must wait for the other to finish in this example. \\\\\n\nHowever, if rank 1 sends its message to rank 2. And then rank 1 sends to rank 3 at the same time as rank 2 sends to rank 4, there has only been two individual communication procedures by rank 1. This gives a better performance. \\\\\n\nEach vertical line in figure \\ref{mpi_communication_illustration_thingy} represents one send and recieve with MPI. A MPI\\_Send and MPI\\_Recieve scales as\n\n\\begin{equation}\nt = t_s + m t_b .\n\\end{equation}\nHere $t_s$ is the startup time, $t_b$ is the bandwidth and m is the number of bytes. In scenario one we would be performing (P-1) such send/recieves, where P is the number of MPI procs.\n\n\\begin{equation}\nT_1 = (P-1) \\times (t_s + m t_b) .\n\\end{equation}\nIn scenario two we still perform send/recieves, but since they can now be done simontaniously the number of send/recieves scales as $\\lceil log_2(P) \\rceil$.\n\n\\begin{equation}\nT_2 = \\lceil log_2(P) \\rceil \\times (t_s + m t_b) .\n\\end{equation}\n\nIdeally we do not want the number of sends/recieves performed by one CPU to increase at all when we increase the number of processors. \\\\\n\n\\newpage\n\n\\begin{figure}[ht!]\n\\centering\n\\includegraphics[width=90mm]{timeconsumption_scenario_one_vs_two.eps}\n\\caption{Illustration of communication in the two scenarios. Plotted are the number of send/recieves that must be performed.}\n\\label{mpi_communication_illustration_thingy2}\n\\end{figure}\n\nWe also perform performance tests of the actual performance on abel of the OpenMPI broadcast function. Results are presented in figure \\ref{mpi_communication_real}. We notice there are indeed optimizations present from the non linear scaling. \n\n\\begin{figure}[ht!]\n\\centering\n\\includegraphics[width=90mm]{mpi_bcast_scaling.eps}\n\\caption{Illustration of actual communication with different number of CPUs. Time is measured for 100 Broadcasts with $8 \\times 70^4$ bytes.}\n\\label{mpi_communication_real}\n\\end{figure}\n\n\\subsection{Optimizing Work Distribution \\label{work_dist_section_1341}}\nAlso in parallel programming it is important that all processors get assigned the same workload. We think of the workload as a series of jobs that can be executed in parallel. \\\\\n\nFirst we must define what is one job and second we must distribute these jobs among processors. Imagine running the following calculation in parallel.\n\n\\begin{equation}\nK = \\sum_{ijkl}^N X_{ij} Y_{kl} Z_{lk} .\n\\end{equation}\nWe first factorize it.\n\n\\begin{equation}\nZ = \\sum_{ij}^N X_{ij} \\times \\sum_{kl}^N Y_{kl} Z_{lk} .\n\\end{equation}\nWe will look at two possible definitions of one job in this scenario. First, we define a job by its job ID. This job ID can for example be expressed as a function of i and j. For example\n\n\\begin{equation}\njob\\_ID = i + j . \\label{example_job_distribution}\n\\end{equation}\nIf we choose this definition we have $N \\times N$ jobs to distribute. Alternatively we can define a job ID as a function of i, j, k and l. For example\n\n\\begin{equation}\njob\\_ID = i + j + k + l .\n\\end{equation}\nWe would then have $N^4$ jobs to distribute. If we have $N^4$ jobs, we can  use $N^4$ CPUs at max. If we however chose to prior job definition, we could only use $N^2$ CPUs. In general we want to have as many jobs as possible to distribute, but sometimes this can lead to additional communication. \\\\\n\nAnother important feature is to optimize the job distribution. If we chose one job\\_ID to be expressed by i and j, we can visualize the job\\_ID in a matrix. Each column is a different index i, and each row is an index j. The matrix elements are the job\\_IDs. If we use N = 4 and Eq. \\eqref{example_job_distribution} we would get\n\n\\begin{center}\n\\begin{tikzpicture}\n\n        \\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)\n        {\n            0 & 1 & 2 & 3 \\\\\n            1 & 2 & 3 & 4 \\\\\n            2 & 3 & 4 & 5 \\\\\n            3 & 4 & 5 & 6 \\\\\n        };  \n    \\end{tikzpicture}\n\\end{center}\nWe want all jobs to have a different ID. We redefine the job\\_ID to be\n\n\\begin{equation}\njob\\_ID = i \\times N + j .\n\\end{equation}\nUsing this definition our matrix of job\\_IDs becomes\n\n\\begin{center}\n\\begin{tikzpicture}\n\n        \\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)\n        {\n            0 & 1 & 2 & 3 \\\\\n            4 & 5 & 6 & 7 \\\\\n            8 & 9 & 10 & 11 \\\\\n            12 & 13 & 14 & 15 \\\\\n        };  \n    \\end{tikzpicture}\n\\end{center}\nEach matrix element represent a job\\_ID. Here each job has got its unique ID, and it is easier to distribute. When we distribute work we must use the MPI rank and total number of MPI procs, p. For example we can define a condition for each processor that must be true if the processor are to perform the job.\n\n\\begin{lstlisting}\nif (job_ID % p = rank){\n   // Perform job\n}\n\\end{lstlisting}\nFrom the perspective of our CPUs we can use this relation to identify our job distribution. Noted now in the matrix is what processor performs which job. We assume we have p = 8.\n\n\\begin{center}\n\\begin{tikzpicture}\n\n        \\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)\n        {\n            0 & 1 & 2 & 3 \\\\\n            4 & 5 & 6 & 7 \\\\\n            0 & 1 & 2 & 3 \\\\\n            4 & 5 & 6 & 7 \\\\\n        };  \n    \\end{tikzpicture}\n\\end{center}\nWe see the job distribution is optimal, because the amount of work for all CPUs are identical. If we used the job\\_ID defined in Eq. \\eqref{example_job_distribution} the amount of work for each processor would not be the same. This is a sub-optimal work distribution. \n\n\\subsection{Why Parallel}\nConstructing a parallel program seems like quite the challenging feature. Every year there are new processors released with improved performance. Why do we not just wait for a great CPU that can solve all our problems? The reason we do not wait for this, is that it will never happen. The problem with great performance CPUs is that their power consumption is generally very high. A CPU with twice the performance generally needs 3 or 4 times the power, according to a lecture from Intel on parallel programming, Ref.\\cite{intelduden_citeation}. It is therefore much more feasable to have several CPUs with less performance, than one high performance CPU. \\\\\n\nSo not only does parallel programming enable us to perform calculations faster and on larger systems, it also requires less power. Power consumption is the limiting factor in CPU performance today. Parallel programming is thus very important, and likely to become even more important in the future. On a sidenote, this is a reason why GPUs have become so popular in scientific programming, GPUs are optimized for performance per watt. Christoffer Hirth wrote extensively about this in his thesis, Ref.\\cite{non_refer_numba1}. His principles has not been incorporated in our implementation, but is a likely source of further performance gains.\n\n\\section{OpenMP}\nOpenMP is another library for parallel programming. It is developed by Intel and can be activated in most compilers. OpenMP use shared memory model. Here the main memory is available on all processors. The key word here is main memory, as each processor has its own cache. OpenMP is very easy to get started with. We will not be using it, but more information is available in Ref.\\cite{openmp_citation_po_g}.\n\n\\section{External Math Libraries}\nExternal Math Libraries are optimized for performance. They have built-in functions to handle matrix-matrix multiplications, vector-matrix multiplications, and similar problems. The best libraries are the likes of OpenBLAS, Ref.\\cite{openblas_citation}, and Intel MKL, Ref.\\cite{mkl_citation}. For our implementation we will make use of MKL on the Abel computing cluster. These libraries often give a huge performance gain in matrix operations, relative to a naive for-loop implementation. \\\\\n\nWe also mention that MKL comes with a parallel version, in where it makes use of OpenMP. Both these libraries are developed by Intel. For our purposes we only made use of the serial version. \n\n\n\n\n\n\n\n\n\n\\section{Input File}\nThis section will deal with the user friendly part of our program. This means easy input. We must be able to define what method to use, what atoms and where they are placed and other input variables. We want these to be defined in a separate textfile, to ensure the user  never needs to recompile or edit any code. The input file must be named \"INCAR\". \\\\\n\n\\begin{figure}[h!]\n\\begin{center}\n\\fbox{\\includegraphics[width=\\textwidth]{inputfile100.eps}}\n\\caption{Example of input file for our program}\n\\label{fig:inputfile100}\n\\end{center}\n\\end{figure}\n\nAn example of input file is given in figure \\ref{fig:inputfile100}. This is the only file we need to change the system or method in use. Our program uses the standard fstream library to read the textfile. We then go through it searching for keywords. The keywords are defined to be the leftmost word in each line. \\\\\n\nBasis\\_Set is the first keyword. Here we can choose from a variety of basis sets and the program will make use of this. The current options are STO-3G, 3-21G, 4-31G, 6-31G, 6-311ss, 6-311-2d2p and 6-311-3d3p. Most of basis sets are implemented for all atoms for which they are available. \\\\\n\nThe next keyword is Method. Here the choices are HF, CCSD, CCSDT-1a, CCSDT-1b, CCSDT-2, CCSDT-3, CCSDT-4 and CCSDT. The CCSDT part will be discussed in the next chapter. \\\\\n\nconvergence\\_criteria is defined to be $10^{n}$, where n is given in the textfile. -8.0 gives a convergence criteria of $10^{-8}$. The same convergence criteria is used for all methods. \\\\\n\nRelax\\_Pos is meant to call a relaxation procedure, but this is not jet implemented in the program. \\\\\n\nuse\\_angstrom gives the user the option to give atomic coordinates in angstrom, instead of atomic units. The options here are true or false. If it is set to true the coordinates are transformed to atomic units inside the program. \\\\\n\nprint\\_stuffies is a variable that gives the user the option if he wants extra values printed. If this is set to true there are several interesting numbers printed during calculations. If this is set to false we only print the final energy. This option is added for a situation where we want to perform several hundred smaller calculation. A situation where we most likely are only interested in a final number.. \\\\\n\nFreeze\\_Core is an option available for CCSD. This is not jet implemented. \\\\\n\nThe next few lines give the atoms and its positions in x, y and z. The first letter is used to determine the number of electrons and nuclei charge. The program does not deal with ions. The simplicity of atom positions and charge is an advantage. Usually in computational chemistry packages the number of atom types and number of atoms of each type must be defined. Here we keep it simple and user friendly. \\\\\n\nThe input file stops searching for keywords once they are all found. Hence the user is free to put comments for self in the input file, as long as they are not placed next to keywords or inside the ATOMS section.\n\n\\section{General Code Overview}\nIn this section we describe the general overview of the code. We will present this as figures, and fill inn the blanks throughout the remaining sections. Each class will be described by its input, output and internal workings. \\\\\n\n\\begin{figure}[h!]\n\\begin{center}\n\\fbox{\\includegraphics[width=\\textwidth]{structure.eps}}\n\\caption{Code structure}\n\\label{fig:structure}\n\\end{center}\n\\end{figure}\n\nThe first class in use is the initializer. This class takes the input from main and makes sure we use it correctly. If angstroms is used as units, the coordinates are transformed to atomic units. If we want extra print options, this is ensured here. We also define a Hartree Fock object in this class, since all methods in computational chemistry generally start with a HF calculation. \\\\\n\nWe then make sure the correct method is called, and pass the HF object. For this reason we drew an arrow from HF to initializer only in figure \\ref{fig:structure}, since it is now passed as an object to the other methods. \n\n\n\\section{Hartree Fock}\nIn this section we discuss the HF implementation in detail. Our Hartree Fock implementation is grounded in the class hartree\\_fock\\_solver. The main function is called Get\\_Energy. In this function we will calculate the HF energy. The main outlay can be seen in figure \\ref{fig:hfimp}. \\\\\n\n\\newpage\n\n\\begin{figure}[h!]\n\\begin{center}\n\\fbox{\\includegraphics[width=\\textwidth]{hf_imp.jpg}}\n\\caption{Basic Outlay of HF Implementation. First column is what action is done, second column is in what class this action takes place}\n\\label{fig:hfimp}\n\\end{center}\n\\end{figure}\n\nThe code is described in the text. We have also included key lines from the code itself to better illustrate the implementation. \\\\\n\n\\subsubsection{Filling numbers from EMSL}\n\\begin{lstlisting}\n   // Set Matrix Sizes\n   matrix_size_setter matset(Z, Basis_Set, n_Nuclei);\n   Matrix_Size = matset.Set_Matrix_Size();\n\n   // Fill numbers from EMSL\n   Fill_Alpha Fyll(n_Nuclei, Z, Basis_Set,\nMatrix_Size, matset.Return_Max_Bas_Func());\n   alpha = Fyll.Fyll_Opp_Alpha();\n   c = Fyll.Fyll_Opp_c();\n   n_Basis = Fyll.Fyll_Opp_Nr_Basis_Functions();\n   Number_Of_Orbitals = Fyll.Fyll_Opp_Antall_Orbitaler();\n   Potenser = Fyll.Fyll_Opp_Potenser();\n\\end{lstlisting}\n\nThe first procedure performed in this function is to call the matrix\\_size\\_setter class. We make an object of this class and send the basis set in use and which atoms are in play. This class then returns how large our arrays must be. We then allocate these arrays. \\\\\n\nThe next step is going to the fill\\_alpha class. This class contains data from EMSL, and fills up this data in arrays. The array alpha is filled with values for $\\alpha_i$, the array c is filled with values of $c_i$ and Potenser is filled with the angular momentum. We also make a one dimensional array, Number\\_Of\\_Orbitals, which holds information on how many basis functions are in use for a specific atom. The array n\\_Basis holds how many primitives each of these basis functions consist of. \\\\\n\n\\subsubsection{Normalizing GTOs}\n\\begin{lstlisting}\n   // Normalize coefficients from EMSL\n   Normalize_small_c();\n\\end{lstlisting}\n\nThe next step is to multiply in the normalization constant. This is multiplied in with the array c, through the function Normalize\\_small\\_c. In this function we have implemented the equations from section \\ref{normalization_section}. \\\\\n\n\\subsubsection{Overlap Integrals}\nThe next step is to make an object of the class hartree\\_integrals. Inside this class we will eventually calculate all the integrals we need. However the first step is to fill up an array of $E_t^{ij}$. These values are present in all our integrals. For this we use Eqs. \\eqref{important_hf1}, \\eqref{important_hf2} and \\eqref{important_hf3}. The values for $E_t^{ij}$ will be calculated for all combinations of two primitive GTOS. This enables us to reuse the values in all our integrals, even the electron-electron repulsion. \\\\\n\n\\begin{lstlisting}\n   // Precalculations\n   HartInt.Fill_E_ij();\n\n   // Overlap\n   O = HartInt.Overlap_Matrix();\n\\end{lstlisting}\n\nWe then calculate the integrals. The overlap is stored in a matrix S and is calculated using Eq. \\eqref{overlap_integral}. \\\\\n\n\\subsubsection{Kinetic Energy}\nThe two index integrals are stored in a matrix EK. EK consists of our kinetic energy and the nuclei-electron interaction. \\\\ \n\n\\begin{lstlisting}\n   // One electron operator\n   EK = -0.5*HartInt.Kinetic_Energy()+\n   - HartInt.Nuclei_Electron_Interaction();\n\\end{lstlisting}\n\nThe kinetic energy is calculated using Eq. \\eqref{EKintegralsss}. \\\\\n\n\\subsubsection{Hermite Integrals}\nFor the nuclei-electron interaction we need to calculate the Hermite Integrals, $R_tuv^n$. We make a new function to calculate these called Set\\_R\\_ijk. This function implements the equations given in Eqs. \\eqref{nucelec_0_int}, \\eqref{nucelec_1_int}, \\eqref{nucelec_2_int} and \\eqref{nucelec_3_int}. We include the implementation of Eqs. \\eqref{nucelec_0_int} and  \\eqref{nucelec_1_int}. We put the values in a global four dimensional array R\\_ijk.\n\n\\begin{lstlisting}\nvoid Hartree_Integrals::Set_R_ijk(double p, int t, int u, int v, rowvec R1, rowvec R2)\n{\n   int t_max,nn,i,j,k,tt = t,uu = u,vv = v;\n   t_max = t+u+v;\n   double Boys_arg;\n   rowvec Rcp(3);\n   Rcp = R1-R2;\n   Boys_arg = p*dot(Rcp, Rcp);\n   Boys_arg = Boys(Boys_arg, 0);\n   \n   // Initialize R^n_0,0,0\n   for (nn=0; nn<(t_max+1);nn++){\n      R_ijk.at(nn)(0,0,0) = pow(-2*p, nn) *    F_Boys(nn);\n   }\n\n   // Fill up R^n_i,0,0\n   for (i=0; i<tt; i++){\n      for (nn=0; nn<(t_max-i); nn++){\n         R_ijk.at(nn)(i+1,0,0) = Rcp(0) * R_ijk.at(nn+1)(i,0,0);\n         if (i > 0){\n            R_ijk.at(nn)(i+1,0,0) += i * R_ijk.at(nn+1)(i-1,0,0);\n         }\n      }\n   }\n   \n   // Rest of Set_R_ijk function   \n\\end{lstlisting}\nWe here make use of the Boys function.\n\n\\subsubsection{Boys Function}\nThe function that calculates a value for the Boys function is called Boys. We have two equations we can use, Eq. \\eqref{boys_int_1} and Eq. \\eqref{boys_int_2}. One works for small x, the other for large x. We define everything less than x = 50 to be small, and everything greater or equal to 50 to be large. We include the implementation of large x. \\\\\n\n\\begin{lstlisting}\nif (x > 50){\n   Set_Boys_Start(N);\n   F = Boys_Start / pow(2.0, N+1) * sqrt(M_PI/pow(x, 2*N+1));\n}\n\\end{lstlisting}\nFor small x we Taylor expand around zero. We choose M = 100 in Eq. \\eqref{boys_int_1} for the Taylor expansion. \n\n\\begin{lstlisting}\nelse{\n   double F=0, sum=0;\n   int M;\n   for (int j=0; j<100; j++){\n      sum = pow(2*x, j);\n      M = 2*N+1;\n      while (M < (2*N+2+2*j)){\n         sum /= M;\n         M += 2;\n      }\n      F += sum;\n   }\n   F *= exp(-x);\n}\n\\end{lstlisting}\nWe then use the recursive relation in Eq. \\eqref{boys_int_3}. \n\n\\begin{lstlisting}\nF_Boys(N) = F;\nfor (int i = N; i > 0; i--){\n   F_Boys(i-1) = (2*x*F_Boys(i) + exp(-x))/(2*i-1);\n}\n\\end{lstlisting}\nWe are left with designing a value to N. N denotes the starting $F_n$ value, from which we will iterate down to the approximate solution. Popular here is putting N as some function of angular momentum, like $N = 6 \\times l$. However we just put it to 30. In this value we were able to recreate all the benchmark values in Refs. \\cite{boys_referanse_1} and \\cite{boys_referanse_2}. These articles discuss the numerical calculation of the Boys function. Using N = 30 our results were also in agreement with the rest of the Computational Physics Group.\n\n\\subsubsection{Nuclei-Electron Interaction}\nWith these functions we can implement nuclei-electron interaction as given in Eq. \\eqref{final_nuclei_electron_thang}. We add these into the array EK. \n\n\\subsubsection{Electron-Electron Interaction}\nThe electron-electron repulsion integrals are stored in a four dimensional field, field\\_Q. They are calculated through a function called Calc\\_Integrals\\_On\\_The\\_Fly. This function takes the input of four orbitals, i, j, k, l, and returns its value for $\\langle i j | k l \\rangle$. The function is an implementation of Eq. \\eqref{electron_electron_int_1_1}, also using Eq. \\eqref{electron_electron_int_1_2}. \\\\\n\n\\begin{lstlisting}\ndouble Calc_Integrals_On_The_Fly(int orb1, int orb2, int orb3, int orb4)\n{    \n    int i,j,k,m;\n\n    // Figure out what atom the AO belongs to, need atomic position\n    i = Calc_Which_Atom_We_Are_Dealing_With(orb1);\n    j = Calc_Which_Atom_We_Are_Dealing_With(orb3);\n    k = Calc_Which_Atom_We_Are_Dealing_With(orb2);\n    m = Calc_Which_Atom_We_Are_Dealing_With(orb4);\n\n    // Here we calculate the two electron integrals\n    // We have already stored E_ij^t so we reuse these\n    // Symmetry considerations are applied elsewhere.\n\n    int E_counter1, E_counter2; // These ensures we get the right E_ij^t\n    int n,p,o,q; // Index for primitive GTO\n    double temp = 0;\n    E_counter1 = E_index(orb1,orb2);\n    for (n=0; n<n_Basis(orb1); n++)\n    {\n        for (p=0; p<n_Basis(orb2); p++)\n        {\n            E_counter2 = E_index(orb3, orb4);\n            for (o=0; o<n_Basis(orb3); o++)\n            {\n                for (q=0; q<n_Basis(orb4); q++)\n                {\n                    temp += c(orb1,n)*c(orb2,p)*c(orb3,o)*c(orb4,q)*\n                            HartInt.Electron_Electron_Interaction_Single\n                (orb1, orb3, orb2, orb4,\n                  i, j, k, m, n, o, p,\n                q, E_counter1, E_counter2);\n\n                // E_t^ij is stored for x,y,z direction\n            // Hence +3 on the counter\n                    E_counter2 += 3;\n                }\n            }\n            E_counter1 += 3;\n        }\n    }\n    return temp; // temp is the value of <ij|kl>\n}\n\\end{lstlisting}\n\n\n\nWe also take advantage of the eighfold symmetries, written our in Eqs. \\eqref{interchangesym} and \\eqref{interchangesym2}. We constructed the code like this originally to have the option to not store these integrals at all, and instead calculate them as needed. This would be a game changer in terms of what calculations are possible, since memory would now be scaling as $n^2$ instead of $n^4$. However we later decided on a memory distribution model was sufficient for our purposes, since we want to use coupled cluster. Coupled Cluster use more memory than HF, so the system size is restricted as is. \n\n\\subsubsection{Parallel Implementation and Memory Distribution}\nThe hotspot in HF is the two electron integrals. We are not looking to make an optimized HF solver, but we must run this part of the calculation in parallel. \\\\\n\nWe want the workload of the integrals $\\langle i j | k l \\rangle$ distributed for a given index i and j. We only calculate one version of each symmetric term. \\\\\n\n\\begin{lstlisting}\n    field_Q.set_size(Matrix_Size, Matrix_Size);\n    for (int i = 0; i < Matrix_Size; i++)\n    {\n        for (int j = 0; j < Matrix_Size; j++)\n        {\n        // Leave parts of the field un-initialized\n        // size = number of MPI procs\n        // rank = my MPI rank\n            if ((i+j)%size == rank)\n            {\n                field_Q(i,j) = zeros(Matrix_Size, Matrix_Size);\n            }\n        }\n    }\n\\end{lstlisting}\n\nThe two electron integrals are a part of the Fock matrix calculation. We want to run this also in parallel, so ensure we can keep the integrals distributed in memory. We remember the Fock matrix was dependant upon \n\n\\begin{equation}\n\\sum_{kl} \\langle i j | k l \\rangle ,\n\\end{equation}\nand\n\n\\begin{equation}\n\\sum_{kl} \\langle i l | k j \\rangle .\n\\end{equation}\nBecause of this we define field\\_Q to store the integrals as such\n\n\\begin{equation}\nfield\\_Q(i,k)(j,l) = \\langle i j | k l \\rangle .\n\\end{equation}\nWe place the two indexes to be swapped in the matrix part of our armadillo field. We then store a $N^3$ sized array of temporary values, F\\_temp(i,j,k). We then add the terms together in the correct order to produce $F_{ij}$. Here we can use functions like MPI\\_Reduce, or make our own implementation of this function to produce the same result. \\\\\n\nThe important feature is that each processor only calculates terms based on the index i and k. This enables us to leave the indexes not in use in the field undefined, thus distributing the $N^4$ memory over all our P MPI processors in use (MPI procs). Each processor then only stores $\\frac{N^4}{P}$ doubles. The amount of bytes for communication scales as $N^3$ doubles. \\\\\n\nHowever we earlier calculated the integrals with a work distribution of indexes i and j. This work distribution makes it easier to use symmetries to avoid recalculation of symmetric terms. We therefore also introduce a communication procedure where we reshuffle the terms in field\\_Q among the MPI procs. The amount of bytes for communication here is $\\frac{1}{8} N^4$, and must be done using MPI\\_Alltoallw or a similar implementation producing an identical result. Our HF implementation is not particularly optimized. Comments on we could optimize this implementation is available in the Future Prospects chapter. \n\n\\subsubsection{Pre Iterative Steps}\nThe equation to solve in HF is the eigenvalue equation from Eq. \\eqref{FOCK_EQUATION_STUFF}. To do this on a computer we must rewrite it slightly. The equation stands as\n\n\\begin{equation}\nF C = S C \\epsilon . \\label{fdsaghbxcxd}\n\\end{equation}\nWe define a matrix V that satisfies\n\n\\begin{equation}\nV^{\\dag} S V = I , \\label{fdsafafdsafdsafa}\n\\end{equation}\nwhere I is the identity matrix. We insert $V^{\\dag}$ to the left on both sides. Also $V V^{-1} $ is inserted into the equations. This leaves\n\n\\begin{equation}\nV^{\\dag} F V V^{-1} C = V^{\\dag} S V V^{-1} C \\epsilon .\n\\end{equation}\nWe also define \n\n\\begin{equation}\nF' = V^{\\dag} F V ,\n\\end{equation}\nand\n\n\\begin{equation}\nC' = V^{-1} C .\n\\end{equation} \nWe insert Eq. \\eqref{fdsafafdsafdsafa}, F' and C' into Eq. \\eqref{fdsaghbxcxd}.\n\n\\begin{equation}\nF' C' = C' \\epsilon .\n\\end{equation}\nThis is a true eigenvalue problem, where $\\epsilon$ will be the eigenvalues of F' and C' will be the eigenfunctions. \\\\\n\nWe also define an intermediate P, which will be the electron density. \n\n\\begin{equation}\nP_{ij} = \\sum_k^N C_i^k C_j^k ,\n\\end{equation}\nwhere N is the number of electrons. We are now ready to begin an iterative procedure. This procedure will be different for RHF and UHF. \n\n\\subsubsection{RHF Iterative Procedure}\nFor RHF we initially put the density P to be filled with zeroes. In RHF we will have an equal number of electrons with spin up and spin down. This simplifies our density matrix to\n\n\\begin{equation}\nP_{ij} = \\sum_k^{N/2} C_i^k C_j^k .\n\\end{equation}\nWe use Eq. \\eqref{Fock_Restricted_1} to find the Fock matrix. We first insert P into the equation.\n\n\\begin{equation}\nF_{ij} = (EK)_{ij} + \\sum_{kl} P_{kl} (2 \\langle i j | k l \\rangle - \\langle i l | k j \\rangle) .\n\\end{equation}\nWe then perform the iterations until we reach self consistency. \\\\\n\n\\begin{algorithm}[H]\n \\While{RHF\\_continue = true}{\n  Calculate $F$ \\\\\n  $F' = V^{\\dag} F V$ \\\\\n  Solve $F' C' = C' \\epsilon$ \\\\\n  Compute $C = V C'$ \\\\\n  Compute P \\\\\n  \\If{RHF = converged}{\n    RHF\\_continue = false\n  }\n }\n \\caption{Psudocode for RHF iterations}\n \\label{RHF_ITERATIVE_PROCEDURE}\n\\end{algorithm}\nAfter we have reached self consistency we calculate the energy.\n\n\\begin{lstlisting}\ndouble Hartree_Fock_Solver::Calc_Energy()\n{\n    // Optimized RHF energy calculations\n    Single_E_Energy = accu(EK % P);\n    Two_E_Energy = 0.5*accu(Energy_Fock_Matrix % P) - 0.5*Single_E_Energy;\n    return Single_E_Energy+Two_E_Energy;\n}\n\\end{lstlisting}\nUsing armadillo the energy calculation simplifies to only two lines of code. \n\n\\subsubsection{UHF Iterative Procedure}\nFor UHF we define two densities, $P^{\\alpha}$ and $P^{\\beta}$, which are the densities for spin up and down. \n\n\\begin{equation}\nP^{\\alpha}_{ij} = \\sum_k^{N_{\\alpha}} C^{\\alpha}_{ik} C^{\\alpha}_{jk} .\n\\end{equation}\n\n\\begin{equation}\nP^{\\beta}_{ij} = \\sum_k^{N_{\\beta}} C^{\\beta}_{ik} C^{\\beta}_{jk} .\n\\end{equation}\nHere $N_{\\alpha}$ is the number of spin up particles, while $N_{\\beta}$ is the number of spin down particles. These must be defined as input as must be equal to the total number of electrons in the system. We define the starting density to be random uniform numbers. We ensure the two matrices are not equal to each other for the first iteration. We use Eqs. \\eqref{Fock_Restricted_2} and \\eqref{Fock_Restricted_3} to find the Fock matrices. \\\\\n\n\\begin{algorithm}[H]\n \\While{UHF\\_continue = true}{\n  Calculate $F_{\\alpha}$ \\\\\n  Calculate $F_{\\beta}$ \\\\\n  $F_{\\alpha}' = V^{\\dag} F_{\\alpha} V$ \\\\\n  $F_{\\beta}' = V^{\\dag} F_{\\beta} V$ \\\\\n  Solve $F_{\\alpha}' C_{\\alpha}' = C_{\\alpha}' \\epsilon_{\\alpha}$ \\\\\n  Solve $F_{\\beta}' C_{\\beta}' = C_{\\beta}' \\epsilon_{\\beta}$ \\\\\n  Compute $C_{\\alpha} = V C_{\\alpha}'$ \\\\\n  Compute $C_{\\beta} = V C_{\\beta}'$ \\\\\n  Compute $P_{\\alpha}$ \\\\\n  Compute $P_{\\beta}$ \\\\\n  \\If{UHF = converged}{\n    UHF\\_continue = false\n  }\n }\n \\caption{Psudocode for UHF iterations}\n \\label{UHF_ITERATIVE_PROCEDURE}\n\\end{algorithm}\nAfter iterations we again calculate the energy. With armadillo the energy calculation simplifies to just two lines of code.\n\n\\begin{lstlisting}\ndouble Hartree_Fock_Solver::Unrestricted_Energy()\n{\n    // Oprimized energy for UHF\n    Single_E_Energy = accu((P_up + P_down) % EK);\n    Two_E_Energy = 0.5 * accu(EnF_up % P_up) + 0.5 * accu(EnF_down % P_down) - 0.5 * Single_E_Energy;\n    return Single_E_Energy + Two_E_Energy;\n}\n\\end{lstlisting}\n\n\n\\subsubsection{Helping Convergence}\nSometimes our solution has problems converging. This is a numerical problem and we can introduce a few features to help the convergence along. \\\\\n\nDamping is one option. This means updating the density only slightly, by inserting\n\n\\begin{equation}\nP_{new}' = \\gamma P_{old} + \\left( 1 - \\gamma \\right) P_{new} .\n\\end{equation}\nThis reduce the change in density between iterations. We only used this in UHF. \\\\\n\nA better alternative is the DIIS method, discussed in section \\ref{diis_section_po_g}. We implemented this method for RHF. The first part of our DIIS implementation is calculating the error, $\\Delta p$. \n\n\\begin{lstlisting}\ndelta_p = F*P*O - O*P*F;\n\\end{lstlisting}\n\nWe then store the error and Fock matrices for the last M iterations. M is defined to M = 3 in our implementation. After this we construct the matrix B. \n\n\\begin{lstlisting}\nfor (int i = 0; i < number_elements_DIIS; i++){\n   for (int j = 0; j < number_elements_DIIS; j++){\n      mat1 = Stored_Error.at(i);\n      mat2 = Stored_Error.at(j);\n      DIIS_B(i,j) = trace(mat1.t() * mat2);\n   }\n}\n\\end{lstlisting}\n\nWe then find the coefficients c.\n\n\\begin{lstlisting}\nDIIS_c = solve(DIIS_B, DIIS_Z);\n\\end{lstlisting}\n\nAnd finally we construct the new Fock matrix, as a linear combination of the previous Fock matrices. \n\n\\begin{lstlisting}\nF = DIIS_c.at(0) * Stored_F.at(0);\nfor (int i = 1; i < number_elements_DIIS; i++){\n   F += DIIS_c.at(i) * Stored_F.at(i);\n}\n\\end{lstlisting}\n\n\\newpage\n\n\\section{Atomic Orbital to Molecular Orbital}\nAtomic Orbital (AO) to Molecular Orbital (MO) is required before we can do any CCSD calculations. In this section we describe how to implement this transformation. We are here looking for a highly optimized implementation. Some background is available in Ref.\\cite{aotomo_1_cite}. However the author found the algorithms in the literature unsatisfactory. For this reason we will present a new algorithm. First, the simplest transformation is:\n\n\\begin{equation}\n\\langle ab | cd \\rangle = \\sum_{ijkl} C_i^a C_j^b C_k^c C_l^d \\langle ij|kl \\rangle .\n\\end{equation}\nThis scales as $n^8$ and can be factorized. \n\n\\begin{equation}\n\\langle ab | cd \\rangle = \\sum_i C_i^a \\sum_j C_j^b \\sum_k C_k^c \\sum_l C_l^d  \\langle ij|kl \\rangle .\n\\end{equation}\nThis is usually split into four quarter transformations. \n\n\\begin{equation}\n\\langle aj|kl \\rangle = \\sum_{i} C_i^a \\langle ij|kl \\rangle .\n\\end{equation}\n\n\\begin{equation}\n\\langle ab|kl \\rangle = \\sum_{j} C_j^b \\langle aj|kl \\rangle .\n\\end{equation}\n\n\\begin{equation}\n\\langle ab|cl \\rangle = \\sum_{k} C_k^c \\langle ab|kl \\rangle .\n\\end{equation}\n\n\\begin{equation}\n\\langle ab|cd \\rangle = \\sum_{l} C_l^d \\langle ab|cl \\rangle .\n\\end{equation}\nEach of these quarter transformations scale as $n^5$. The implementation of this must be done in an effective way in terms of speed and memory. The latter is the most important as the memory here scales as $N^4$, where N is the number of contracted GTOs, for both $\\langle ij | kl\\rangle$, $\\langle ab | cd \\rangle$ and also the intermediates in between each quarter transformation. \\\\\n\n\\begin{algorithm}[H]\n \\KwData{Psudo Code}\n \\KwResult{Algorithm for parallel AOtoMO transformation }\n \\For{a=0; a<N}{\n  \\For{k=0; k<N}{\n   \\For{l=0; l<N}{\n    \\If{Grid k and l over threads}{\n     \\For{j=0; j<N}{\n      \\For{i=0; i<N}{\n       $QT1(k,l,j) += \n       C_i^a \\times \\langle ij|kl \\rangle$\n      }\n     }\n     \\For{j=0; j<N}{\n      \\For{b=0; b<N}{\n       $QT2(k,l,b) += C_j^b \\times QT1(k,l,j)$\n       }\n      }\n    }\n   }\n  }\n  Communicate $QT2(k,l,b)$\n  \n  \\For{b=0; b<N}{\n   \\For{c=0; c<N}{\n    \\If{Grid b and c over threads}{\n     \\For{k=0; k<N}{\n      \\For{l=0; l<N}{  \n       $QT3(b,c,l) = C_k^c \\times QT2(k,l,b)$\n       }\n      }\n      \\For{l=0; l<N}{\n        \\For{d=0; d<N}{\n       $QT4(b,c,d) = C_l^d \\times QT3(b,c,l)$\n        }\n      }\n     }\n    }\n   }\n   \n   Communicate $QT4(b,c,d)$\\\\\n   \n   \\If{Store distributed MOs to given thread}{\n    $\\langle ab|cd \\rangle = QT4(b,c,d)$\n   }\n }\n  \n \\caption{Simple Psudocode for parallel AOtoMO transformation. QT1, QT2, QT3 and QT4 are intermediates}\n \\label{aotomotrans}\n\\end{algorithm}\n\nAlgorithm \\ref{aotomotrans} is a description of how we optimize this implementation. Further optimizations will come later, but first an illustration of the general idea. We first hold index $a$ constant throughout the transformation. This enables us to use $N^3$ size intermediates. \\\\\n\nSecond the grid over k and l is chosen because neither of these are involved as an index in $C$ for the first two quarter transformations. This makes sure that the terms of $QT2(k,l,b)$ calculated by each thread is the fully two quarter transformed term. This avoids the use of MPI\\_Reduce or similar operations and means only one thread needs to communicate these two quarter transformed terms with specific $k$ and $l$, minimizing the communication. The total amount of double precision values communicated in the first communication for now is $N^3$ for each $a$, making it $N^4$ in total for all $a$. \\\\\n\nAfter the first communication each thread has all terms in $QT2(k,l,b)$ available. We then make a new grid over $b$ and $c$ and continue calculations in parallel. The grid could be made over $a$ and $b$, but the prior makes in general a better work distribution. This is because index $a$ is held fixed. After the fourth quarter transformation each thread has the fully transformed MOs available for certain $b$ and $c$ indexes. \\\\\n\nAt this point we can distribute the MOs in the same grid as for $b$ and $c$, and start CCSD calculations. However because we want to have the distribution optimized for CCSD we implement another communication. This communication is $N^3$ for each $a$, making it $N^4$ in total for all $a$. \\\\\n\nAfter the second communication we simply store the MOs in a memory distributed manner. It is also possible to write to disk. \\\\\n\n$QT2$ and $QT4$ must be stored as one dimensional arrays, to minimize the number of communication procedures initiated, hence minimize latency. Also all multiplications are written using external math libraries through armadillo. We should also introduce symmetries to optimize our calculations further. The starting AOs had eight-fold symmetries. So does the resulting MOs. However these symmetries does not hold at all the quarter transformed intermediates. This complicates things slightly. \\\\\n\nThe second quarter transformed four dimensional array, QT2, will have symmetries in the two untouched indexes, as well as in the two transformed indexes. We were able to make use of this to reduce communication by 75\\%, since symmetric terms need not be communicated twice. This also holds true at the QT4 level obviously. The algorithm using symmetries and external math libraries is presented in algorithm \\ref{aotomo2}. \\\\\n\n\\begin{algorithm}\n \\KwData{Psudo Code}\n \\KwResult{Effective Algorithm for parallel AOtoMO transformation using external math libraries}\n \\For{a=0; a<N}{\n  \\For{k=0; k<N}{\n   \\For{l=0; l<=k}{\n    \\If{Calculate on local thread}{\n     A1(*) = C(a,*) $\\times$ $\\langle kl | ** \\rangle$ \\\\\n     A2($0 \\rightarrow a$) = C($0 \\rightarrow a$, *) $\\times$ A1 \\\\\n     \\For{b=0; b<=a}{\n       QT2(b,k,l) = A2(b) \n      }\n    }\n   }\n  }\n  \n  MPI\\_Allgatherv(QT2) \\\\\n  \n  \\For{b=0; b<=a}{\n   \\For{c=0; c<N}{\n    \\If{Calculate on local thread}{\n \t A1(*) = C(c,*) $\\times$\n \t  QT2(b,*,*) \\\\\n     A2($0 \\rightarrow c$) = C($0 \\rightarrow c$, *) $\\times$ A1 \\\\\n     \\For{d=0; d<=c}{\n       QT4(b,c,d) = A2(d) \n      }\n     }\n    }\n   }\n   MPI\\_Allgatherv(QT4) \\\\\n   \n   \\If{Store distributed MOs to given thread}{\n    $\\langle ab|cd \\rangle = QT4(b,c,d)$ \\\\\n    or write to disk\n   }\n }\n  \n \\caption{Psudocode for parallel AO to MO transformation using armadillo. A1 and A2 are one dimensional intermediates}\n \\label{aotomo2}\n\\end{algorithm}\n\nThe communication is somewhat tricky in this algorithm. Since we have inserted symmetries, the size of the message to be transmitted changes dependant upon the index $a$. This also applies to the displacement. We therefore store both in two dimensional arrays where $a$ is the outer index, the inner is the MPI rank. \\\\\n\nWe run through the algorithm one time in advance to calculate these variables. We also calculate and store where each processor will start calculations. This is done to remove any pipeline flushes, which can be caused by the CPU wrongly guessing the answer of an if test. \\\\\n\nFor this reason we define another two dimensional array, this one of size N times the number of MPI procs. In the first two quarter transformation, each rank here stored at what index $l$ will calculations start for a given index $k$. The next $l$ the same rank will perform calculations on will then be \n\n\\begin{equation}\nl \\rightarrow l + p ,\n\\end{equation}\nwhere p is the number of MPI procs. The exact same procedure is repeated for quarter transformation 3 and 4. \\\\\n\nWe have also in the more advanced algorithm inserted one dimensional arrays A1 and A2. Using these provide more optimize ways of accessing memory. It may at first sight seem like an additional complication to first calculate A2 as a one dimensional array and later store it in QT2, but this is a more efficient way when using armadillo. \\\\\n\nThe algorithm is implemented in the function \n\n\\begin{lstlisting}\nvoid Prepear_AOs(int nr_freeze);\n\\end{lstlisting}\nThe argument is how many core orbitals to freeze. The argument is somewhat wasted, since frozen core approximation is not implemented yet.\n\n\\section{CCSD Serial Implementation \\label{optimize_serial_version_bii}}\nOur CCSD implementation is quite large, actually close to 10 000 lines. However this is small compared to other optimized implementations, which are usually around 40 000 lines of code. Implementation is important in CCSD, since it scales quickly for larger systems. Additional information on on the advancement of CCSD is available in a series of books, Ref.\\cite{book_om_advancements_ccsd}. The most effective implementation to the authors knowledge is the Cyclic Tensor Framework, see Refs.\\cite{most_effective_ccsd_dude}, \\cite{most_effective_ccsd_dude2} and \\cite{most_effective_ccsd_dude3}. \\\\\n\nIn this thesis we will present a simple and effective implementation of CCSD in parallel. First we look at a simple serial implementation. This section discusses the serial implementation. There are two specific goals for this implementation. First getting the energy in the smallest amount of time, second being able to run larger systems. \\\\\n\nEven more precise we can state that our goals are: \\\\\na) Never get zero in a multiplication\\\\\nb) All multiplication should be done by external math libraries\\\\\nc) Do not store anything more than needed\\\\\n\nWe first present the general structure of the code. Later we will discuss a few details about different optimizations we have implemented. These will be contrasted to what kind of optimizations is commonly implemented in CCSD. Then, there will be a pros and cons list for our implementation. The chapter will be quite technical as there are several considerations behind each optimization, and it all works in combination. \n\n\\newpage\n\n\\subsection{Structure}\n\nFor our serial program we first define arrays to store all intermediates, MOs and amplitudes. Two arrays are defined for each amplitude, one for the old amplitudes and one for the new amplitudes. We define a convergence criteria, which stops iterations once the difference of energy from one iteration to the next is bellow this criteria. \\\\\n\n\\begin{algorithm}[H]\n \\KwData{Psudo Code}\n \\KwResult{Structure of CCSD serial program}\n \\While{CCSD continue = true}{\n  Set Eold = Enew \\\\\n  Calc F1 \\\\\n  Calc F2 \\\\\n  Calc F3 \\\\\n  Calc W1 \\\\\n  Calc W2 \\\\\n  Calc W3 \\\\\n  Calc W4 \\\\\n  Calc New t1 amplitudes \\\\\n  Calc New t2 amplitudes \\\\\n  Set t1 = t1new \\\\\n  Set t2 = t2new \\\\\n  Calc $\\tau_{ij}^{ab}$ \\\\\n  Calc New Energy \\\\\n  \\If{Enew - Eold < Convergence criteria}{\n  \tCCSD continue = false\n  }\n }\n \\caption{Psudocode for our serial CCSD program}\n \\label{CCSD_STRUCTURE_SERIAL}\n\\end{algorithm}\n\nAlgorithm \\ref{CCSD_STRUCTURE_SERIAL} illustrates the algorithm as psudocode. Each of the terms behind \"Calc\" is taken as a separate function to make the code easily readable. \n\n\\subsection{Removing redundant zeroes \\label{compact_storage}}\nWe now briefly reconsider the molecular integrals, which were calculated as such\n\n\\begin{equation}\n\\langle pq|rs \\rangle = \n\\sum_{\\alpha \\beta \\xi \\nu} C_{\\alpha}^p C_{\\beta}^q C_{\\xi}^r C_{\\nu}^s \\langle \\alpha \\beta | \\xi \\nu \\rangle .\n\\end{equation}\nHere $\\langle \\alpha \\beta | \\xi \\nu \\rangle$ are our atomic orbitals (AOs). These come from our RHF calculations. $\\langle pq|rs \\rangle$ are the molecular orbitals (MOs). MOs here are presented as a linear combination of AOs. The MOs appear in CCSD as a double bar integral. This is defined as such\n\n\\begin{equation}\n\\langle pq||rs \\rangle = \\langle pq | rs \\rangle\n- \\langle pq | sr \\rangle  .\n\\end{equation}\nDue to spin considerations, if we fill a matrix with $\\langle pq||rs \\rangle$ it will be filled with mostly zeroes. However when using an RHF based CCSD it is common that all even numbered spin orbitals have the same spin orientation. This means all odd numbered orbitals will also have the same spin orientation. This results in the zeroes forming pattern that we have identified and utilized. \\\\\n\n$\\langle pq || rs \\rangle$ are diagonal in total spin projection. In RHF the total spin is also equal to zero. When we have all odd numbered orbitals with the same spin orientation, and same with even numbered orbitals, this has a practical implication. The implication is that the only terms that will not be equal to zero are those where the sum of the orbital indexes are equal to an even number. \\\\\n\nWe will now visualize this. We construct a program that performs the AO to MO transformation and print $\\langle pq||rs \\rangle$ for a fixed $p=1$ and $r=1$. In the span of $q$ and $s$ there is formed a matrix, we have noted the terms that will be zero and also the terms that will be non-zero with the indexes (q, s).\n\n\\[ \\left( \\begin{array}{ccccccc}\n(0,0) & 0 & (0,2) & 0 & (0,4) & 0 & \\dots \\\\\n0 & (1,1) & 0 & (1,3) & 0 & (1,5) & \\dots \\\\\n(2,0) & 0 & (2,2) & 0 & (2,4) & 0 & \\dots \\\\\n0 & (3,1) & 0 & (3,3) & 0 & (3,5) & \\dots \\\\\n(4,0) & 0 & (4,2) & 0 & (4,4) & 0 & \\dots \\\\\n0 & (5,1) & 0 & (5,3) & 0 & (5,5) & \\dots \\\\\n\\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots \\end{array} \\right)\\]\n\nThis array is now stored in our computer as a four dimensional array that we call $I[a][b][c][d]$. We on purpose use a different index in the array than we do for the orbital, even though index a in this example is a referance to orbital p. We can note which orbitals our array-indexes refers to as such\\\\\na = p \\\\\nb = r \\\\\nc = q \\\\\nd = s \\\\\n\nThis will be an array of size $(2N)^4$, where $N$ is the number of contraction Gaussian Type Orbitals (GTOs). We now perform a trick. We want our indexes of I to refer to a different orbital, in practise we want:\\\\\na = p\\\\\nb = r\\\\\nc = q/2 + (q\\% 2) N\\\\\nd = s/2 + (s\\% 2) N\\\\\n\nWhere \\% is the binary operator and we use integer division by 2. The number 2 comes from two spin orbitals per spacial orbital. Now index c is no longer a referance to orbital q, but a referance to orbital [q/2 + (q \\% 2) N]. If we now visualize the same double bar integral with fixed $p=1$ and $r=1$ it looks like this\n\n\\[ \\left( \\begin{array}{cccccccc}\n(0,0) & (0,2) & (0,4) & \\dots & 0 & 0 & 0 & \\dots \\\\\n(2,0) & (2,2) & (2,4) & \\dots & 0 & 0 & 0 & \\dots\\\\\n(4,0) & (4,2) & (4,4) & \\dots & 0 & 0 & 0 & \\dots\\\\\n\\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots\\\\\n(1,1) & (1,3) & (1,5) & \\dots & 0 & 0 & 0 & \\dots\\\\\n(3,1) & (3,3) & (3,5) & \\dots & 0 & 0 & 0 & \\dots\\\\\n(5,1) & (5,3) & (5,5) & \\dots & 0 & 0 & 0 & \\dots\\\\\n\\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots \\end{array} \\right)\\]\n\nPerforming this trick will always result in a matrix that looks something like this. We can split this matrix into four sub-matrices, one top left, one top right, one bottom left and one bottom right. Regardless of $a$ and $b$, we will always have either the two left sub-matrices, or the two right sub-matrices always filled with zeroes. These do not need to be stored. If we ensure we \\emph{only perform calculations on orbitals with a non-zero contribution} we can change our array-indexing to:\\\\\na = p\\\\\nb = r\\\\\nc = q/2 + (q\\% 2) N\\\\\nd = s/2 \\\\\n\nThis means for two orbital where s = 2 and s = 3 we will have the same d value. However one of these orbitals will always be zero, so if we avoid doing calculations on this there will be no problems. And we also reduce the size of the array to half. Visualizing now the same array it looks like this.\n\\[ \\left( \\begin{array}{cccc}\n(0,0) & (0,2) & (0,4) & \\dots \\\\\n(2,0) & (2,2) & (2,4) & \\dots \\\\\n(4,0) & (4,2) & (4,4) & \\dots \\\\\n\\dots & \\dots & \\dots & \\dots \\\\\n(1,1) & (1,3) & (1,5) & \\dots \\\\\n(3,1) & (3,3) & (3,5) & \\dots \\\\\n(5,1) & (5,3) & (5,5) & \\dots \\\\\n\\dots & \\dots & \\dots & \\dots  \\end{array} \\right)\\]\n\nAnd its size will be $\\frac{1}{2} (2N)^2$. This kind of indexing can and should be performed on $\\textbf{all}$ stored integrals, amplitudes and intermediates. This ensures all memory is reduced by at least 50 \\%. Also if a,b,c,d is referencing orbitals in the same manner in all stored arrays we can still use external math libraries as before. However now we will not be passing any zeroes into these external math libraries, so calculations can be faster. This change in indexing keeps all symmetries and also allow easy row and column access. The row is accessed as usual.\n\n\\begin{tikzpicture}\n        \\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)\n        {\n            (0,0) &(0,2) &(0,4) &\\dots \\\\\n            (2,0) & (2,2) & (2,4) & \\dots \\\\\n            (4,0) & (4,2) & (4,4) & \\dots \\\\\n            \\dots & \\dots & \\dots & \\dots \\\\\n            (1,1) & (1,3) & (1,5) & \\dots \\\\\n\t\t\t(3,1) & (3,3) & (3,5) & \\dots \\\\\n\t\t\t(5,1) & (5,3) & (5,5) & \\dots \\\\\n\t\t\t\\dots & \\dots & \\dots & \\dots \\\\\n        };  \n        \\draw[color=red] (m-1-1.north west) -- (m-1-3.north east) -- (m-1-4.north east) -- (m-1-4.south east) -- (m-1-1.south west) -- (m-1-1.north west);\n    \\end{tikzpicture}\n\nA column is slightly different, since we only require either the top half or the bottom half of the matrix.\n\n\\begin{tikzpicture}\n        \\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)\n        {\n            (0,0) &(0,2) &(0,4) &\\dots \\\\\n            (2,0) & (2,2) & (2,4) & \\dots \\\\\n            (4,0) & (4,2) & (4,4) & \\dots \\\\\n            \\dots & \\dots & \\dots & \\dots \\\\\n            (1,1) & (1,3) & (1,5) & \\dots \\\\\n\t\t\t(3,1) & (3,3) & (3,5) & \\dots \\\\\n\t\t\t(5,1) & (5,3) & (5,5) & \\dots \\\\\n\t\t\t\\dots & \\dots & \\dots & \\dots \\\\\n        };  \n        \\draw[color=red] (m-1-2.north west) -- (m-3-2.south west) -- (m-4-2.south west) -- (m-4-2.south east) -- (m-3-2.north east) -- (m-1-2.north east) -- (m-1-2.north west);\n\\end{tikzpicture}\n\nThis can be specified using the submatrix command in armadillo. The attributes of the double bar integrals in RHF are such that there will be some remaining zeroes after removing these. This is because total spin must be zero. However there will be another pattern formed where all remaining zeroes are placed in one of two remaining sub-matrices. This can also be accounted for, reducing memory needs by an additional $\\frac{1}{8}$. These calculations can also easily be avoided using submatrix calls in armadillo.\\\\\n\nSince we are using an RHF basis some matrix elements become independent of spin. This means spin up will have the same value as spin down. This happens mostly for the two dimensional intermediates, and when we store in this manner the practical implications of this becomes identical upper and lower submatrices. In this situation we do not calculate the same term twice. In the future we will refer to this method as compact storage. This method removes all zeroes without defining additional arrays, as is usually done today. \n\n\\subsection{Pre Iterative Calculations}\nBefore calculations can start we perform a few tricks. We do not store our MOs in one gigantic array, instead we split it up into several smaller ones. This is done at the end of the AOtoMO transforamtion. These are variables such as MO3 and MO4, decleared in the header file ccsd\\_memory\\_optimized.h.\n\n\\begin{lstlisting}\nfield<mat> MO3, MO4 ...\n\\end{lstlisting}\nThis is a very common procedure in CCSD implementation. It is performed to enable more effectively use of external math libraries. The reason it is more effective is because of memory accessing. If we want to send parts of an array into an external math library, we need first to extract which parts to send. Instead, we can define several smaller arrays like MO3. MO3 is then designed specifically to be sent directly into the external math library. \\\\\n\nRef.\\cite{ccsd_fac3} also ponders this. In fact, this is such an optimization that even redundant storage of double bar integrals is often used. This means storing a value twice, just to have it easily available for passing to external math library. \\\\\n\nOriginally, we took advantage of this straight forward optimization. However, in the current implementation we will not be storing redundant values. Instead, we will be storing the single bar integrals, and have functions to map these into two dimensional arrays of double bar integrals ready for external math library use. We have surgically designed each and every for loop such that this mapping is redundant in terms of program efficiency. It does reduce memory requirements drastically. \\\\\n\nThe splitting of the integrals for us then becomes somewhat redundant in this regard, but as we will see later it is of clinical importance when we implement memory distribution. \\\\\n\nBefore iterations can start we also allocate memory for our intermediates and amplitudes. We use the principles of section \\ref{compact_storage} here. In fact every array to come in contact with an external math library must be stored on this form.\n\n\\subsection{F1, F2 and F3}\nWe now start the iterative procedure. The first three intermediates are two dimensional and\nvery straight forward to calculate. We use Eqs. \\eqref{intermedF1}, \\eqref{intermedF2} and \\eqref{intermedF3}. Our implementation has some additional complications which will be discussed shortly, but is still equivalent to our initial naive implementation.\n\n\\begin{lstlisting}\nfor (int a = 0; a < unocc_orb; a++){\n  for (int m = 0; m < n_Electrons; m++){\n     F1(a/2, m/2) = accu(integ2(a,m) % T_1);\n  }\n}\n\\end{lstlisting}\n\nIn this initial naive implementation integ2 is one part of the double bar integrals we pulled out. Since we want to store only the single bar integrals, we replace this with a function Fill\\_integ\\_2\\_2D(int a, int m) to fill up a global mat integ2\\_2D. This is then used in external math libraries.\n\n\\begin{lstlisting}\nfor (int a = 0; a < unocc_orb; a++){\n  for (int m = 0; m < n_Electrons; m++){\n     Fill_integ_2_2D(a, m);\n     F1(a/2, m/2) = accu(integ2_2D % T_1);\n  }\n}\n\\end{lstlisting}\n\n$[F_2]$ and $[F_3]$ are calculated in a similar procedure.\n\n\\subsection{W1, W2, W3 and W4}\nThese intermediates are calculated using Eqs. \\eqref{intermedw1}, \\eqref{intermedW2}, \\eqref{intermedW3} and \\eqref{intermedW4}. We include the initial naive implementation of $[W_1]$.\n\n\\begin{lstlisting}\nfor (int i = 0; i < n_Electrons; i++){\n   for (int j = i+1; j < n_Electrons; j++){\n      Fill_integ8_2D;\n      W_1(i,j)(k/2,l/2) = integ8_2D;\n   }\n}\n\nfor (int k = 0; k < n_Electrons; k++) {\n   for (int l = 0; l < n_Electrons; l++){      \n      Fill_integ6_2D(k,l);\n      Fill_integ4_2D(k,l);\n      for (int i = 0; i < n_Electrons; i++){\n         for (int j = i+1; j < n_Electrons; j++){\n            W_1(i,j)(k/2,l/2) += accu(integ6_2D.col(j)\n                % T_1.col(i));\n            W_1(i,j)(k/2,l/2) -= accu(integ6_2D.col(i)\n                % T_1.col(j));\n            W_1(i,j)(k/2,l/2) += 0.5*accu(integ4_2D\n                % tau3.at(i,j));\n         }\n      }\n   }\n}\n\\end{lstlisting}\n\nHere the mapping into two dimensional double bar integrals is still done as a $N^4$ procedure, whereas the calculation is now an $N^6$ procedure. For easy external math library use later we store these variables as W1(i,j)(k,l), W2(i,j)(a,m), W3(i,m)(e,n) and W4(a,i)(c,k). We also use symmetries where they can be applied.\n\n\\subsection{New amplitudes}\nThe T1 amplitudes are calculated using Eq. \\eqref{LINK_THIS_SHIT_1_T1}. For the T2 amplitudes we use Eq. \\eqref{LINK_THIS_SHIT_1_T2}. To make this amplitude most optimal for external math libraries we store it as\n\n\\begin{equation}\nT2(a,i)(b,j) . \\label{howtostoret2}\n\\end{equation}\n\n\\subsection{$\\tau_{ij}^{ab}$ and Energy}\n$\\tau_{ij}^{ab}$ is calculated in Eq. \\eqref{intermedtau}. It is stored in a variable tau3(a,b)(i,j) for optimal use in external math libraries. The energy can be calculated using Eq. \\eqref{CCSD_TOTAL_ENERGY}. However we can simplify this further by introducing $\\tau_{ij}^{ab}$.\n\n\\begin{equation}\nE_{CCSD} = E_0 + \\sum_{ai} f_{ai} t_i^a + \\frac{1}{4} \\sum_{abij} \\langle ij || ab \\rangle \\tau_{ij}^{ab} .\n\\end{equation}\nHere we have inserted $t_i^a t_j^b = \\frac{1}{2} \\left( t_i^a t_j^b - t_j^a t_i^b \\right)$. Also the term $f_{ai}$ will always be equal to zero when the basis for our CCSD calculations are a diagonalized Fock matrix.\n\n\\begin{equation}\nE_{CCSD} = E_0 + \\frac{1}{4} \\sum_{abij} \\langle ij || ab \\rangle \\tau_{ij}^{ab} .\n\\end{equation}\n\n\\subsection{Dodging Additional Unnecessary Calculations}\nIn section \\ref{compact_storage} we discussed how to avoid multiplication where both terms are zero. However, for CCSD we originally had several terms to be multiplied, and we factorized them. This causes another potential optimization, that we wish to introduce with a simplified example. Consider four terms, A, B, C and D, that want to multiply together.\n\n\\begin{equation}\nF = A \\times B \\times C \\times D .\n\\end{equation}\nImagine factorizing this would speed up our calculations.\n\n\\begin{equation}\nF = A \\times (B \\times (C \\times D ) ) .\n\\end{equation}\nLet us define intermediate E.\n\n\\begin{equation}\nE = B \\times (C \\times D ) .\n\\end{equation}\nAfter we calculated this we are left with\n\n\\begin{equation}\nF = A \\times E .\n\\end{equation}\nAt the end of the calculation, it turns out A was equal to zero. This means the entire calculation was wasted, as F would have been zero anyway. Spin consideration causes this situation to occur in CCSD. Luckily because this comes from spin considerations, it is deterministic. We can identify all these situations and avoid calculations. \\\\\n\nThis is implemented in our code, and we want to present an example from the contributions to $t_{ij}^{ab}$ from $[W4]$.\n\n\\begin{equation}\nD_{ij}^{ab} t_{ij}^{ab} \\leftarrow \\sum_{kc} t_{jk}^{bc} \\times [W_4]_{ic}^{ak} .\n\\end{equation}\nIndex $b$ and $j$ only appear in the T2 amplitudes, while indexes $a$ and $i$ appear in the intermediate. Imagine now that index $b$ is an odd number, while index $j$ is an even number. \\\\\n\nIn the sum over $k$ and $c$, $k$ and $c$ can themselves be odd or even. We remember we arranged our MOs so that all odd numbers had same spin orientation. Inside the sum, whenever now $c$ is an odd number we will be exciting two electron into spin up orbitals. If $j$ was an even number we also remove an electron from a spin down orbital. \\\\\n\nRegardless of index $k$ this will not result in zero spin in total and the amplitude must be equal to zero with our spin restriction. In section \\ref{compact_storage} we noted a situation where one of the two sub-matrices would be zero. This is the situation. \\\\\n\nAlso, the indexes $a$, $b$, $i$ and $j$ must themselves result in zero spin in total, or the amplitude will be zero. This limits the number of possible combinations of $t_{jk}^{bc}$ and $[W_4]_{ic}^{ak}$ to where we can actually avoid calculating some terms of $[W_4]_{ic}^{ak}$ that are not equal to zero. \\\\\n\nThe easiest and most human-time effective way of implementing this is to simply go through the factorization backwards, to identify which multiplications we did not need. This has been done.\n\n\\section{CCSD Parallel Implementation}\nIn parallel implementation we will make extensive use of memory distribution. In CCSD it is quite normal to read some of the MOs from disk. We will not be doing this, but we will place memory distribution as our number one priority. The code was however originally designed to read from disk, so this option is left easily available.\n\n\\subsection{Memory Distribution \\label{kriseseksjon}}\nIn a serial implementation of CCSD the leading memory consumer is an $\\frac{1}{16 \\times 2} n_v^4$ sized array, $\\langle ab||cd \\rangle$. The $\\frac{1}{16}$ comes from only storing spacial single bar MOs, $\\langle ab|cd \\rangle$, with $n_v$ being the number of virtual spin orbitals. The factor $\\frac{1}{2}$ comes from symmetry. This array is called MO9 in our implementation. \\\\\n\nHowever, the array only appears in the calculation of $t_{ij}^{ab}$, as this is the only place where the double bar integrals has three or more virtual indexes (which are $a$, $b$, $c$ etc). This means we can ensure one processor only requires parts of the array MO9 if we distribute work here correctly. It is also possible to distribute the double bar integrals themselves, \\cite{ccsd_minne_distribuert_double_bar_artikkel} presents such an algorithm. \\\\\n\n\\begin{lstlisting}\nfor (int a = 0; a < unocc_orb; a++){\n   for (int b = a+1; b < unocc_orb; b++){\n      // Distribute work with Work_ID variable\n      if (Work_ID % size == rank){\n         // Perform calculation\n     // Only the processor who passes this if test\n     // will need <ab||cd> with specific a and b\n      }\n   }\n}\n\\end{lstlisting}\n\nAll the largest parts of the single bar integrals will be distributed in memory. This leaves the largest un-distributed arrays as our T2 amplitudes and some intermediates. Specifically the old and new $t_{ij}^{ab}$, $[W_4]$ and $\\tau_{ij}^{ab}$. \\\\\n\nWe will be able to distribute $[W_4]$, through some quite complex operations that actually also provides quite good parallel performance. \\\\\n\nBecause we want to store the old T2 amplitudes as specified in Eq. \\eqref{howtostoret2} we are unable to take advantage of symmetries. We are however able take advantage of one symmetry for $\\tau_{ij}^{ab}$ and the new T2 amplitudes. Also we have the storage of section \\ref{compact_storage}. This means non distributed memory is scaling as\n\n\\begin{equation}\nM(n_v, n_o) = \\left(\\frac{1}{2} + \\frac{1}{4} + \\frac{1}{16} + \\frac{1}{16} \\right) n_v^2 n_o^2 \\approx n_v^2 n_o^2 .\n\\end{equation}\nThe factor $\\frac{1}{2}$ is the old T2 amplitudes. The $\\frac{1}{4}$ is the intermediate $\\tau_{ij}^{ab}$. This intermediate improves performance only modestly in our factorization, but is very helpful when optimizing the use of external math libraries. We therefore keep it. The final factors $\\frac{1}{16}$ are parts of the MOs we where unable to distribute in memory and also the new T2 amplitudes. The new T2 amplitudes require less memory because we only store one version of each symmetric term. How to distribute $[W_4]$ will be discussed shortly. Contributions from $n_v n_o^3$ is ignored in the non distributed memory scaling.\n\n\\subsection{Three Part Parallel}\nOur parallel implementation will be quite straight forward. We will split the iterative procedure in three. Part two is the calculation of $[W_4]$. Part three is the amplitudes. Part one is everything else. The split is performed to keep in line with our guiding parallel principles of minimizing communication initiations. In each part we will also discuss what type of performance we can expect with increased number of CPUs in use. This is known as scaling. \\\\\n\n\\subsubsection{Part 3}\nWe first look at the third parallel part, the amplitudes. Each processor allocates memory for the new T2 amplitudes. At first each processor only stores the terms it performs calculations on itself. That is, the T2 amplitudes are distributed in memory. \\\\\n\nWe want $I_{ab}^{cd}$ distributed in memory. The numbers for this variable is stored in MO9. To make the memory distribution easy, we distribute work for $t_{ij}^{ab}$ based on indexes $a$ and $b$. These indexes are symmetric in $t_{ij}^{ab}$. We thus only need calculations on $b > a$. Since we stored the single bar spacial MOs, we must distribute work very delicately if we are to not get to much overhead. \\\\\n\nWork is distributed with in a block cyclic manner, with the block always being of size 2. This block size is identical to the number of spin MOs per spacial MO. The optimal work distribution with these limitations has the mathematical formula, with all divisions being integer divisions.\n\n\\begin{equation}\nWork\\_ID = \\frac{a}{2} \\times \\frac{n_v}{2} + \\frac{b}{2} - \\sum_{n=0}^a \\frac{n}{2} .\n\\end{equation}\nThe number two is the block size, $\\frac{n_v}{2}$ is the size of a column in MO9 and the sum ensures we get the optimal distribution for $b > a$. This forumla distributes work over indexes a/2 and b/2 optimally. The work ID is used by the processors to figure out if the calculation is to be performed.\n\n\\begin{lstlisting}\n// Find new T2 amplitudes, function\nfor (int a = 0; a < unocc_orb; a++)\n{\n   sum_a_n += a/2;\n   A = a/2;\n   AA = A* Speed_Occ - sum_a_n;\n\n   // Potential to read from file here.\n   // Read in a 3 dimensional array of single bar integrals for a\n   // specific index a. Same array is used for a and a+1\n   // Can use for example MPI_File_read(...)\n\n   // a is an even number\n   for (int b = a+2; b < unocc_orb; b++){ // b is even number\n      B = b/2;\n      Work_ID = AA+B;\n      if (Work_ID % size == rank){\n     // Load up 2D arrays for external math libraries\n         Fill_integ3_2D(a, b);\n         Fill_integ9_2D(a, b);\n\n     // Reindexing of tau for external math library use\n         Fill_2D_tau(a, b);\n\n         for (int i = 0; i < n_Electrons; i++){ // i is even number\n            for (int j = i+2; j < n_Electrons; j++){ // j is even number\n               MY_OWN_MPI[index_counter] =\n        (-MOLeftovers(a/2, b/2)(j/2, i/2)\n        + MOLeftovers(a/2, b/2)(i/2, j/2)\n        + W_5(a,b)(i/2,j/2)\n                - W_5(a,b)(j/2,i/2)\n        - accu(W_2(i,j)(a/2, span()) % T_1.row(b/2))\n                + accu(W_2(i,j)(b/2, span()) % T_1.row(a/2))\n        + 0.5*accu(W_1(i,j)(span(0, Speed_Elec-1), span()) % tau1(span(0, Speed_Elec-1), span())) // Half matrix = 0, skip this\n        - accu(t2.at(b,i)(span(0, Speed_Occ-1), j/2) % D3.row(a).t())\n                + accu(t2.at(a,i)(span(0, Speed_Occ-1), j/2) % D3.row(b).t())\n        + accu(t2.at(a,j)(b/2, span()) % D2.row(i/2))\n                - accu(t2.at(a,i)(b/2, span()) % D2.row(j/2))\n        - accu(integ9_2D(span(0, Speed_Occ-1), i/2) % T_1(span(0, Speed_Occ-1), j/2))\n                + accu(integ9_2D(span(0, Speed_Occ-1), j/2) % T_1(span(0, Speed_Occ-1), i/2))\n        + 0.5*accu(integ3_2D(span(0, Speed_Occ-1), span()) % tau3(i,j)(span(0, Speed_Occ-1), span()))) // Half matrix = 0, skip this\n        \n        / (DEN_AI(a/2,i/2)+DEN_AI(b/2, j/2));\n\n        // This is one new T2 amplitude.\n        // Plus one on index counter, and calculate the next\n                index_counter++;\n                j++;\n             }\n             i++;\n          }\n       }\n       b++;\n    }\n}\n\\end{lstlisting}\n\nThe code segment above is a part of the function for the new T2 amplitudes. This is how our actual code looks. It is designed for performance. The outer loop is index a. If we wanted to read from file, we would be reading in the single bar integrals for a specific index a, into an $N^3$ sized array. \\\\\n\nThe next loop is index b. Here we figure out if a local processor is to perform these calculations. If the processor shall perform calculations, we fill up the largest arrays needed for external math library use. The smaller arrays used in external math libraries are already filled. \\\\\n\nThe next loops are i and j. Since spin must be zero, an even number a and b only allows for even number i and j. The other combinations of odd b, even a etc are also implemented in our code but not included here. \\\\\n\nInside the four loops we calculate the amplitude $t_{ij}^{ab}$. We notice every term is written using external math libraries, with the accumulation function. We also skip calculations using the span() function where appropriate, as noted in the previous section. Finally we divide by the denominator and store the new amplitude in a one dimensional array for easier MPI function use. \\\\\n\nOnce calculations are completed we must gather the results and update the old T2 amplitudes. The new T2 amplitudes are all stored in a one dimensional array on each local processor, so we only need to initiate one communication procedure. The most effective would be a collective all-to-all communication, where we send in the new amplitudes and gather them/write over the old ones. For this we could use a function like MPI\\_Allgatherv. However this does not work with armadillo, since we cannot map values into an armadillo field directly with MPI. \\\\\n\nThis complicates things slightly. We see two solutions to the problem, but neither is as efficient as the before mentioned one. \\\\\n\nWe can either allocate a new one-dimensional array and perform the prior solution with a mapping of the new amplitudes into the armadillo field afterwards. Or we can perform P one-to-all broadcasts, where P is the number of MPI procs. Then each processors sends its information to others, and this is mapped into the armadillo type array. We chose the prior, but it is slightly less effective. There will be a mapping procedure required. The scaling of the communication will be identical to the scaling of an MPI\\_Allgatherv.\n\n\\begin{lstlisting}\nMPI_Allgatherv(MY_OWN_MPI, WORK_EACH_NODE(rank), MPI_DOUBLE,\n                   SHARED_INFO_MPI, Work_Each_Node_T2_Parallel, Displacement_Each_Node_T2_Parallel,\n                   MPI_DOUBLE, MPI_COMM_WORLD);\n\\end{lstlisting}\n\nHere my own MY\\_OWN\\_MPI holds the information calculated on the processor. SHARED\\_INFO\\_MPI will contain the full new non distributed T2 amplitudes. The new amplitudes are symmetric, and we only store one version of each symmetric term. SHARED\\_INFO\\_MPI is the array we counted as non distributed new T2 amplitudes in section \\ref{kriseseksjon}. But our algorithm is really designed to distribute the the new T2 amplitudes. However because we use armadillo with MPI we need this extra variable.\\\\\n\nWithout the complication arising from armadillo and MPI we could also skip this mapping of symmetries into the old T2 amplitudes.\n\n\\begin{lstlisting}\nfor (int K = 0; K < size; K++){\n   sum_a_n = 0;\n   for (int a = 0; a < unocc_orb; a++){\n      sum_a_n += a/2;\n      A = a/2;\n      AA = A * Speed_Occ - sum_a_n;\n\n      for (int b = a+2; b < unocc_orb; b++){\n         B = b/2;\n         INDEX_CHECK = AA+B;\n         if (INDEX_CHECK % size == K){\n            for (int i = 0; i < n_Electrons; i++){\n               for (int j = i+2; j < n_Electrons; j++){\n                  temp = SHARED_INFO_MPI[index_counter];\n\n          // Map out symmetries after communication\n                  t2(a,i)(b/2, j/2) = temp;\n                  t2(b,i)(a/2, j/2) = -temp;\n                  t2(a,j)(b/2, i/2) = -temp;\n                  t2(b,j)(a/2, i/2) = temp;\n\n                  index_counter++;\n                  j++;\n               }\n               i++;\n            }\n         }\n         b++;\n      }\n   }\n}\n\\end{lstlisting}\n\n\\subsubsection{Part 2}\nNext is part two of the parallel implementation, which is the $[W_4]$ calculation. Here we also want to distribute this variable in memory. We want to store $[W_4]$ as described previous to make use of external math libraries most effectively.\n\n\\begin{equation}\nW4(a,i)(c,k) .\n\\end{equation}\nMost of the contributions to $[W_4]$ are themselves distributed in memory on the indexes a and k. We therefore perform calculations on a local processor in a cyclic grid over these two indexes. A local processor thus holds\n\n\\begin{equation}\nW4(a,*)(*,k) .\n\\end{equation}\nHere star means all terms in this index. If we temporarily swaps the indexes i and k we can store W4(a,k)(*,*), and calculate these terms.\n\n\\begin{lstlisting}\nfor (int a = 0; a < unocc_orb; a++){\n   for (int m = Where_To_Start_Part2(rank,a); m < n_Electrons; m+=jump){\n      // Fill 2D arrays ready for external math libraries\n      // These are distributed in memory\n      Fill_integ7_2D(a,m);\n      Fill_integ5_2D(a,m);\n\n      for (int e = 0; e < unocc_orb; e++){\n         Fill_integ2_2D_even_even(e, m);\n         for(int i = 0; i < n_Electrons; i++){\n            W4(a,m)(e,i) = -integ7_2D(e/2,i/2)\n        - accu(W_3.at(i,m)(e/2,span()) % T_1.row(a/2))\n                + accu(integ5_2D(span(0, Speed_Occ-1),e/2) % T_1(span(0, Speed_Occ-1),i/2))\n                + 0.5*accu(integ2_2D % t2.at(a,i));\n            i++;\n         }\n         e++;\n      }\n   }\n   a++;\n}\n\\end{lstlisting}\n\nThe Where\\_To\\_Start\\_Part2(rank,a) variable will be explained later. However, when this intermediate contributes to the T2 amplitudes we need the full matrix that is stored in $W4(a,i)$. \\\\\n\nTherefore we perform a communication. To pick the correct MPI function we also need to know what to do with the array after the communication. Afterwards we want to multiply\n\n\\begin{equation}\n\\sum_{ck} W4(a,i)(c,k) \\times t2(b,j)(c,k)   .\\label{gasghashkashfbdbhcxxcnxcruu}\n\\end{equation}\nThis multiplication will run in parallel, with work distributed cyclically over $a$ and $i$. The optimal work distribution forumla is\n\n\\begin{equation}\nWork\\_ID = a \\times n_o + i .\n\\end{equation}\nThe communication needed to get the correct array needed prior and after is thus an all-to-all personalized communication. We will use MPI\\_Alltoallw. Each processor here sends its own personalized message to the other MPI procs. The message is reduced to a one dimensional array in MY\\_OWN\\_MPI before communication. \\\\\n\n\\begin{lstlisting}\nMPI_Alltoallw(MY_OWN_MPI, Global_Worksize_2[rank], Global_Displacement_2[rank], mpi_types_array, SHARED_INFO_MPI, Global_Worksize_2_1[rank], Global_Displacement_2_1[rank], mpi_types_array, MPI_COMM_WORLD);\n\\end{lstlisting}\n\nWe then perform the multiplication in Eq. \\eqref{gasghashkashfbdbhcxxcnxcruu}, with work distributed over a and i. We want this contribution to be added to the new T2 amplitudes, which themselves are work distributed over $a$ and $b$. This means we add another MPI\\_Alltoallw communication to get the correct data to the correct processor. \\\\\n\nWe have introduced a temporary memory distributed variable $W5(a,b)(i,j)$ to store this contribution to $t_{ij}^{ab}$. The positive features of this algorithm is that we indeed get all the variables distributed in memory, and communication procedures initiated are two All-to-All communications. All-to-All is generally the most effective kind of communication in MPI. We note that the number of initiated communications is independent of number of processors. This is exactly in line with our parallel implementation guidelines states earlier. The scaling of this communication will be identical to the scaling of two MPI\\_Alltoallw functions. This function is highly optimized. Also the work distribution is optimal.\n\n\\subsubsection{Part 1 \\label{problem_part_ccsd_parallel}}\nThe final part of our parallel implementation consist of everything else. Here we construct $[W_1]$, $[W_2]$, $W_3]$, $[F_1]$, $[F_2]$ and $[F_3]$. The contribution from $[F_1]$ to $[F_2]$ and $[F_3]$ is a $n^3$ contribution. Thus we do not need to run this part in parallel. The energy and $\\tau_{ij}^{ab}$ is also calculated in serial in the current implementation. These are $n^4$ terms, and will be the leading non parallel calculations. \\\\\n\nTo perform this part of the parallel implementation we make cyclical grids of different kinds. We can reuse the array of new T2 amplitudes, since it is not needed at this step in the calculations. This enables less memory usage. We fill the array with all numbers calculated on the processor. Then perform communication just as in Part 3, and map the correct numbers into the correct armadillo fields. \\\\\n\n\\begin{lstlisting}\nMPI_Allgatherv(MY_OWN_MPI, Work_Each_Node_part1_Parallel[rank], MPI_DOUBLE, SHARED_INFO_MPI, Work_Each_Node_part1_Parallel, Displacement_Each_Node_part1_Parallel, MPI_DOUBLE, MPI_COMM_WORLD);\n\\end{lstlisting}\n\nWe combine all these variables into one communication to maximise the number of jobs to distribute in accordance to the principles stated in section \\ref{work_dist_section_1341}. Also to minimize the latency by initializing less communication procedures. \\\\\n\nHowever because we combine several different variables we combine jobs that are not of the same size. This causes problems in our job distribution. The job distribution of part one in our parallel implementation is sub-optimal. In larger calculations some CPUs can get twice the workload of other CPUs. We have used a few tricks to lessen this performance problem. These are things like shifting the job distribution.\n\n\\begin{lstlisting}\nif ((Work_ID + Shift) % size == rank){\n   // Perform job\n}\n\\end{lstlisting}\n\nThe results however are not optimal and as such we cannot expect an optimal performance of this part of the CCSD implementation. Even with this concern combining all remaining variables into one MPI communication was still the better solution, compared to performing communications after each intermediate calculation.   \n\n\\newpage\n\n\\subsection{Extra Pre Iterative Procedures}\nBefore we start iterating we must map out a few new variables. These are extra calculations not needed in serial and includes variables such as displacement and size of messages in the communications. They are calculated in the class \\\\ ccsd\\_non\\_iterative\\_part. \\\\\n\n\\begin{lstlisting}\nif (Work_ID % size == rank)\n{\n    // Do calculation\n}\n\\end{lstlisting}\n\nWe also map out which Work\\_ID each processor are to perform calculations on. This is for example the Where\\_To\\_Start\\_Part2(rank,a) variable. This enables us to remove all if tests like the one above from our iterative procedure. If tests inside a for loop can be very time consuming if the value true or false changes often from one index to the next. This is especially true if we have two processors. In this case, the value would change every time an index is changed. This means the number of pipeline flushes could potentially be large, dependant upon the compiler. \\\\\n\nFor P processors, the value of the if test changes after (P-1) index changes. Not having any if tests helps performance somewhat, in particular for a small number of MPI procs.\n\n", "meta": {"hexsha": "7180354370a4cf4cfb892393f05d7b0601e186a0", "size": 91766, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/chapters/chapter8.tex", "max_stars_repo_name": "ManyBodyPhysics/CQMech", "max_stars_repo_head_hexsha": "8395f082392844a0e2831649aab4108324c86312", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-06-18T14:34:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T14:44:41.000Z", "max_issues_repo_path": "doc/src/chapters/chapter8.tex", "max_issues_repo_name": "ManyBodyPhysics/CQMech", "max_issues_repo_head_hexsha": "8395f082392844a0e2831649aab4108324c86312", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/chapters/chapter8.tex", "max_forks_repo_name": "ManyBodyPhysics/CQMech", "max_forks_repo_head_hexsha": "8395f082392844a0e2831649aab4108324c86312", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-02-18T15:21:45.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-18T15:21:45.000Z", "avg_line_length": 61.7121721587, "max_line_length": 718, "alphanum_fraction": 0.7273391016, "num_tokens": 24516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878414043816, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.40498459504063}}
{"text": "% TODO: introduce notation and concept of fv/bv and fn/bn\n\n\\chapter{Background}\\label{chapter:background}\n\n\\textit{\nThis chapter explores what \\emph{formal systems} are and what they are useful for. \nIt looks at a number of related formal systems and their relation to computation. \nIt outlines the context on which the rest of this project is built.\n}\n\n% TODO: explain that ideas will become clearer as they are\n%       used and we see how they interact with other concepts\n%       introduced later. it's ok to leave concepts not entirely\n%       developed\n\n\\section{Formal Systems}\n\nFormal systems are sets of rules for writing and manipulating\nformul\\ae. Formul\\ae\\ are constructed from a set of characters called the\n\\emph{alphabet} by following some formul\\ae-construction rules called\nthe \\emph{grammar}. The only formul\\ae\\ considered \\emph{well formed} in\na system are those constructed according to the grammar of a system.\nFormal systems are used to model domains of knowledge to help better\nand more formally understand those domains.\n\n\\subsection{Syntax and Grammars}\n\nThe grammar of a formal system describes the system's syntax. Grammars are \nrules for constructing formul\\ae\\ that are well formed. Formul\\ae\\\nproduced according to the grammar of a system are well formed according to \nthe syntax of that system.\n\nGrammars are normally defined by using Backus-Naur Form or BNF:\n\n\\[\n  M ::= t\\ \\mid\\ f\n\\]\n\nThis grammar describes that syntactically-valid constructs are either the letter $t$ or the letter $f$. \nGrammars can be recursive which allows much more expressive construction rules:\n\n\\begin{figure}[!h]\\label{fig:tf-grammar}\n\\[\n  \\begin{array}{lclr}\n    M,N&::=&t&\\textcolor{pale-gray}{(1)} \\\\\n      &|&f&\\textcolor{pale-gray}{(2)} \\\\\n      &|&M\\ a\\ N&\\textcolor{pale-gray}{(3)} \\\\\n  \\end{array}\n\\]\n\\caption{Grammar for producing the letters $t$ or $f$ connected by the letter $a$}\n\\end{figure}\n\nThis grammar describes formul\\ae\\ containing any number of occurrences of the letters $t$ or $f$ separated by an $a$. \n\\[\n\\begin{array}{ll}\n  \\by{t}{1} \\\\\n  \\by{t\\ a\\ f}{2 \\& 3} \\\\\n  \\by{t\\ a\\ f\\ a\\ t}{1 \\& 3}\n\\end{array}\n\\]\n\n\\subsection{Derivation Rules}\nWhereas a grammar describes the rules for producing well-formed formul\\ae,\nthe derivation rules describe rules for transforming formul\\ae\\ of a particular form into new formul\\ae. \nUsing the grammar from Figure \\ref{fig:tf-grammar}, we add derivation (rewriting) rules:\n\n\\[\n\\begin{array}{lcl}\n  t\\ a\\ M &\\to& M \\\\ \n  M\\ a\\ t &\\to& M \\\\\n  f\\ a\\ M &\\to& f \\\\\n  M\\ a\\ f &\\to& f \\\\\n\\end{array}\n\\]\n\nThese rules describe that if a formula matches the pattern on the \nleft-hand side, where $M$ represents a well-formed formula, it can be\nreplaced by the formula on the right-hand side.\n\n\\subsection{Domain Modelling}\n\nThe syntax and derivation rules of a formal system are defined to model \nsome domain. This isomorphism between the domain and the formal system\nmeans we can attempt to discover truths about the domain through studying\nthe formal system.\n\nFor example, take the $tf$-system described above. \nWithout understanding the domain, we are able to manipulate formul\\ae\\ of the system to create new formul\\ae. \nWithout going into detail, it is easy to verify that the $tf$-system is isomorphic to a subset of Boolean algebra:\n\n\\[\n\\begin{array}{cc}\n\\text{$tf$-system} & \\text{Boolean algebra} \\\\\nt & 1 \\\\\nf & 0 \\\\\na & \\wedge \\\\\n\\end{array}\n\\]\n\nUsing formal systems allows us to understand the domains they model from\ndifferent perspectives and thereby learn novel truths about them.\n\n\\subsection{Derivation Strategies}\n% TODO: explain that when you can make more than one decision,\n%       you can have a strategy for which decision you take\n\nWhen applying derivation rules to compound terms, we can imagine the \ncompound term being decomposed into simpler terms until one of the \nderivation rules applies. When we decompose a term, we separate it into a\ndominant term and a context.\n\n\\begin{figure}[!h]\\label{fig:decomposing}\n\\[\n\\begin{array}{lcr}\n  & t\\ o\\ f\\ a\\ t \\\\\n  t\\ o\\ f\\ && \\square\\ a\\ t \n\\end{array}\n\\]\n\\end{figure}\n\nThe left-hand side is the dominant term and the right-hand side is the context. \nThe $\\square$ in the context denotes a hole that needs to be filled to create a full term.\nOnce we have a term that we can apply a derivation rule to, \nwe apply the derivation rule and recombine the context with the resulting term. \nFor example, we start with the term:\n\\[\n  t\\ a\\ f\\ a\\ t\n\\]\nThis term is decomposed into a dominant term (on the left) and a context (on the right):\n\\[\n  t\\ a\\ f \\quad\\quad \\square\\ a\\ t\n\\]\nUsing the derivation rules from above, we can rewrite the dominant term $t\\ a\\ f$ as $f$:\n\\[\n  f \\quad\\quad \\square\\ a\\ t\n\\]\nFinally, once the dominant term cannot be reduced further, we recombine it with the context to get:\n\\[\n  f\\ a\\ t\n\\]\n\nHowever the the term $t\\ a\\ f\\ a\\ t$ can be decomposed in two ways:\n\\[\n\\begin{array}{rlr}\n  1. & t\\ a\\ f\\ & \\square\\ a\\ t  \\\\\n  2. & f\\ a\\ t & t\\ a\\ \\square  \\\\\n\\end{array}\n\\]\nWhen we have more than one way derivation rules can be applied to a term,\nwe can use \\emph{derivation strategies} to determine which rule we apply.\nFor compound terms, derivation strategies decide which derivation rule to applied to which subterm.\nIn our $tf$-system, there are two obvious derivation strategies:\neither apply derivations starting from the left or starting from the right.\n\n\\[\n\\begin{array}{rcl}\n  \n  \\textbf{(left)} & t\\ a\\ f\\ a\\ t \\\\\n  \\to                & t\\ a\\ f & \\square\\ a\\ t \\\\\n  \\to                & f       & \\square\\ a\\ t \\\\\n  \\textit{recombine} & f\\ a\\ t & \\\\\n  \\\\\n  \\textbf{(right)}   & t\\ a\\ f\\ a\\ t \\\\\n  \\to                & f\\ a\\ t & t\\ a\\ \\square \\\\\n  \\to                & f       & t\\ a\\ \\square \\\\\n  \\textit{recombine} & t\\ a\\ f & \\\\\n  \n\\end{array}\n\\]\nWhereas derivation rules are defined in the system, \nderivation strategies are strategies \\emph{about} the system: methods for choosing which derivation rule to apply when given a choice. \n\n\\section{\\lam-Calculus}\n\nIn response to Hilbert's \\emph{Entscheidungsproblem}, Alonzo Church defined the \\lam-calculus \\cite{ChurchEnt36}. \nIt is a formal system capable of expressing the set of effectively-computible algorithms.\nShortly after, G{\\\"o}del and Turing created their own models of effective computibility.\n\\footnote{General recursive functions and Turing machines, respectively} \nThese models were later proved to be equivalent.\n\n\\subsection{Syntax}\n  \n  \\lam-variables are taken from an infinite set and are written $x,y,z$, etc. Variables are open positions in a term that can be filled by other terms.\n  The grammar for constructing well-formed \\lam-terms is:\n\n  \\begin{figure}[!h]\n  \\definition{ \n    \\textsc{(Grammar for untyped \\lam-calculus)}\n    \\item $`l$-variables are denoted by $x, y,\\dots$ \\\\\n    \\[\n    \\begin{array}{rcll}\n    M,N & ::= & x         & \\text{(Variable)} \\\\\n        & \\mid\\ & `lx.M & \\text{(Abstraction)} \\\\ \n        & \\mid\\ & (M\\ N)   & \\text{(Application)} \\\\ \n    \\end{array}\n    \\]\n  }\n  \\end{figure}\n\n  \\lam-abstractions are anonymous functions and are represented by $`lx.M$ where $x$ is a parameter and $M$ is the body of the abstraction. \n  The same idea is expressed by more conventional notation as a mathematical function $f(x) = M$. \n  The $`l$ annotates the beginning of an abstraction and the $.$ separates the parameter from the body of the abstraction.\n  This grammar is recursive, meaning the body of an abstraction is just another term constructed according to the grammar. \n  Some examples of abstractions are:\n  \n  \\begin{figure}[!h]\n    \\[\n      \\begin{array}{l}\n      `lx.x \\\\\n      `lx.xy \\\\\n      `lx.(`ly.xy)\n      \\end{array}\n    \\]\n  \\caption{Examples of valid \\lam-abstractions}\n  \\end{figure}\n  \n  Applications are represented by any two terms, \n    both constructed according to the grammar, \n  placed alongside one another. \n  We assume the convention that application gives highest precedence to the left-most application. \n  This means we can drop brackets where our convention will prevent ambiguity.\n  Note that this means that if the term is an application, the outermost brackets can always be dropped.\n  For example, we can drop the outermost, leftmost brackets from the term $((xy)z)$ and instead write $xyz$.\n  To ensure the application of terms in any other order, we must leave the brackets explicit.\n  For example the brackets in the term $x(yz)$ cannot be removed without changing the meaning of the term.\n  Examples of applications are:\n    \\begin{figure}[!h]\n      \\[\n        \\begin{array}{l}\n        (xy) \\\\\n        xyz \\\\\n        x(yz) \\\\\n        (`lx.x)y\n        \\end{array}\n      \\]\n    \\caption{Examples of valid applications}\n    \\end{figure}\n\n\\subsection{Reduction Rules}\n  \n  The reduction rules for the \\lam-calculus are like the derivation rules from formal systems.\n  They determine how terms of a particular form can be transformed into new terms.\n  \n  First we will introduce the substitution notation $M[N/x]$. This denotes \n  the term M with all occurrences of x replaced by N. The substitution \n  notation is defined inductively as:\n   \n    \\begin{figure}[!h]\n    \\definition{ \n      \\textsc{(Substitution notation for \\lam-terms)}\n      \\[\n      \\begin{array}{rclr}\n      x[y/x] & \\rightarrow & y \\\\\n      z[y/x] & \\rightarrow & z & (z \\neq x) \\\\\n      (`lz.M)[y/x] & \\rightarrow & `lz.(M[y/x]) \\\\\n      (M N)[y/x] & \\rightarrow & M[y/x] N[y/x]\n      \\end{array}\n      \\]\n    }\n    \\end{figure}\n\n\\subsubsection{\\bta-reduction}\n  The main derivation rule of the \\lam-calculus is \\bta-reduction. If term\n  $M$ \\bta-reduces to term $N$, we write $M \\rightarrow_{`b} N$ although \n  the \\bta\\ subscript can be omitted if it is clear from context. \\bta-reduction\n  is defined for the application of two terms:\n  \\begin{figure}[!h]\\label{def:beta-reduction}\n  \\definition{ \n    \\textsc{($`b$-reduction for \\lam-calculus)} \n    \\cite{Bakel15}\n    \\\\\n    $i)$ $\\to_{`b}$ is defined as the compatible closure of the rule:\n    \\[\n    \\begin{array}{rcl}\n    (`lx.M) N & \\rightarrow_{`b} & M[N/x]\n    \\end{array}\n    \\]\n    $ii)$ $\\to_{`b}^{*}$ is defined as the transitive closure of $\\to_{`b}$\n  }\n  \\end{figure}\n \n  \\lam-variables and \\lam-abstactions are \\emph{values}: they do not reduce to other terms. \n  If a term is a value, the reduction cannot be applied to that term: it has \\emph{terminated} on that value. \n  Only applications whose left-hand side is an abstraction can reduce to other terms. \n  This means that an application of this form is called a reducible expression or a \\emph{redex}. \n  Reducing a redex models the computing of a function. \n\n% TODO: define free variables and bound variables\n\\subsubsection{$`a$-reduction}\n \n  The variables in a \\lam-term are either \\emph{bound} or \\emph{free}. \n  The bound variables of a term are those introduced by \\lam-abstractions before their use.\n \n  \\definition{\n  \\textsc{Bound variables $bv$ of \\lam-terms}\n  \\cite{Bakel15}\n  \\[\n  \\begin{array}{lcl}\n    bv(x)     & = & \\varnothing \\\\\n    bv(`lx.M) & = & bv(M) \\cup \\{x\\} \\\\\n    bv(MN) & = & bv(M) \\cup bv(N) \\\\\n  \\end{array} \n  \\]\n  }\n  \\definition{\n  \\textsc{Free variables $fv$ of \\lam-terms}\n  \\cite{Bakel15}\n  \\\\\n  The free variables of a term $M$ are variables that occur in $M$ that are not bound.\n  \\\\\n  }\n \n  % TODO: explain this in terms of bound and free variables\n  The \\lam-calculus defines a reduction rule for renaming variables.\n  Variable names are arbitrary and chosen just to denote identity:\n  all occurrences of $x$ are the same. This can become a problem\n  in the following case:\n  \\[\n    (`ly.`lx.xy)(`lx.x)\n  \\]\n  After the application is reduced, we have the term:\n  \\[\n    `lx.x(`lx.x) \n  \\]\n  In this case, it is ambiguous which \\lam-abstraction the right-most $x$\n  is bound by. When this term is applied to another, will the substitution\n  occur to all occurrences of $x$? From the initial term, it is clear that\n  this would be incorrect. The \\lam-calculus introduces $`a$-reduction to\n  solve this:\n  \\begin{figure}[H]\n  \\definition{ \n    \\label{def:alpha-reduction}\n    \\textsc{($`a$-reduction for \\lam-calculus)}\n  \\[\n    \\begin{array}{rl}\n    `lx.M \\rightarrow_{`a} `ly.M[y/x] & (y \\notin fv(M))\n    \\end{array}\n  \\]\n  }\n  \\end{figure}\n  This means we can rename the lead variable of an abstraction $M$ on the \n  conditions that: \n  \\begin{enumerate}\n    \\item All variables bound by that abstraction are renamed the same \n    \\item The variable it is changed to does not already appear in $M$ \n  \\end{enumerate}\n  Returning to the term above, we can $`a$-reduce the right-hand term to reduce ambiguity before $`b$-reducing the whole term:\n  \\[\n  \\begin{array}{rll}\n             & (`ly.`lx.xy)(`lx.x) \\\\\n    \\to_{`a} & (`ly.`lx.xy)(`lz.z) & (z \\not= x \\land z \\not= y) \\\\\n    \\to_{`b} & `lx.x(`lz.z)\n  \\end{array}\n  \\]\n  Using $`a$-reduction, we can ensure that the binding of every variable in a term is unambiguous.\n  \n  \\subsection{Reduction Strategies}\n \n  A term is in normal form for a reduction strategy if, \n    following that reduction strategy,\n  no more reductions can take place.\n  For instance, a term that can no longer be \\bta-reduced is in \\bta-normal form.\n  We use $\\to_{`b}^{nf}$ to denote a term in \\bta-normal form.\n  Again, we can omit the \\bta\\ subscript if it is clear from context.\n  \n  Lazy reduction is a reduction strategy that restricts the reduction to the outermost, leftmost redex.\n  Any other subterms that are redexes cannot be reduced.\n  \\definition{\n  \\textsc{Lazy reduction of \\lam-terms}\\\\\n  $i)$ The outermost, leftmost term is the only one that can be reduced \\\\\n  $ii)$ No other reductions can take place, including underneath an abstraction \\\\\n  $iii)$ We use $\\to^{L}$ to denote lazy reduction\n  }\n  \\\\  \n  \\\\\n  For example, let us begin \\bta-reducing $(`lx.`ly.xy)(`lz.z)$: \n  \\[\n  \\begin{array}{rll}\n            & (`lx.`ly.xy)(`lz.z) \\\\\n    \\to_{`b}& `ly.(`lz.z)y\n  \\end{array}\n  \\]\n  Whereas \\bta-reduction would continue and reduce the inner redex $(`lz.z)y$,\n  lazy reduction does not reduce beneath \\lam-abstractions.\n  This term is in normal form for lazy reduction.\n\n\\section{Logic and Types}\n\n  There are many formal systems for describing logic.\n  These systems attempt to describe the relationship between logical statements.\n  Like all formal systems, \n  they allow us to derive new logical statements by following transformation rules.\n\n  Logic relates statements together with logical connectives.\n  Under an interpretation, a statement is either true or false.\n  Depending on the truth value of the component statements, a compound statement is either true or false.\n  As far as we are concerned, the logical connectives consist of $\\land, \\lor, \\to$, and $\\neg$.\n  \\begin{itemize}\n    \\item $M \\land N$ (read: `and') is true only when both $M$ and $N$ are true.\n    \\item $M \\lor N$ (read: `or') is true only if either $M$ or $N$ are true. \n    \\item $M \\to N$ (read: `implies') is false when $M$ is true but $N$ is false.\n    \\item $\\neg M$ (read: `not') is true only when $M$ is false.\n  \\end{itemize}\n  The symbol $\\to$ represents implication: whenever $M$ is true, $N$ is true.\n  \n  \\subsection{Natural Deduction}\n \n  Natural deduction is a system of logic.\n  In natural deduction, there are \\emph{introduction} and \\emph{elimination} rules for each logical connective.\n  These are presented as \\emph{inference rules}.\n  Logical inference rules describe that if some statement $A$ is true,\n  then it follows that some other statement $B$ is true.\n  This is denoted by:\n  \n  \\[\n    \\Inf{A}{B} \n  \\]\n  \n  Using this notation, we can now describe the inference rules for logical implication, $\\to$.\n  For our purposes, this is the only logical connective we are interested in.\n  The reason for this will become clear.\n  \n  \\definition{\n  \\textsc{$\\to$ introduction and elimination rules} \n  \\[\n  \\begin{array}{rl@{\\quad\\quad}rl}\n    \\Inf { A \\to B \\hspace{0.5cm} A }\n        {B}\n        {\\hspace{0.2cm} \\to \\mathcal{E} }\n    &\n    \\Inf { \\infer*{B}{[A]} }\n        { A \\to B}\n        {\\hspace{0.2cm} \\to \\mathcal{I} }\n  \\end{array}\n  \\]\n  }\n  \n  The $\\to\\mathcal{E}$ rule says that assuming the statement $A \\to B$ and the statement $A$ are true,\n  we can conclude that $B$ is the case. The rule is read as an implication.\n  For instance, consider \n \n  \\[\n  \\begin{array}{lcl}\n    A & = & \\textit{It is raining} \\\\\n    B & = & \\textit{It is wet outside} \\\\\n    A \\to B & = & \\textit{If (it is raining) then (it is wet outside)}\n  \\end{array}\n  \\]\n  If we know that ``if (it is raining) then (it is wet outside)'' and we are told ``it is raining'',\n  clearly we can take for granted ``it is wet outside''.\n  \n  The $\\to\\mathcal{I}$ rule says that if we assume $A$ and from that assumption we deduce $B$,\n  we can conclude that $A$ implies $B$.\n  Let us assume (where $[A]$ denotes that we assume $A$ is true): \n  \\[\n    [A] = \\textit{Turing did not see Church's work} \n  \\]\n  From this assumption, it's clear that that \n  \\[\n    B = \\textit{Turing could not have stolen Church's work} \n  \\]\n  The $\\to\\mathcal{I}$ rule lets us conclude from these statements that\n  \\[\n    A \\to B = \\textit{If Turing did not see Church's work, he could not have stolen it}\n  \\]\n \n  Note the removal of the assumption ([\\ ]) from $A$.\n  By restricting ourselves to these rules, we are working within \\emph{Implicative Intuitionistic Logic} (IIL).\n  IIL is a restricted form of logic.\n  For example Pierce's law, which says $((P \\to Q) \\to P) \\to P$, is not applicable to IIL.\n  \\footnote{IIL also rejects the law of excluded middle which says for every $P$, $P \\lor \\neg P$.\n  According to intuitionistic logic, unless we have a \\emph{constructive} proof for which of $P$ or $\\neg P$ is true, the statement is false}\n  \n  \n  \n  \\subsection{Sequent Calculus}\n  \n  Gentzen explored natural deduction through the sequent calculus \\cite{Wadler15}.\n  We have followed Girard \\emph{et al.}'s observation that the syntax of the sequent calculus is overcomplicated for the purpose of natural deduction \\cite{Girard89}.\n  However it is useful for both classical natural deduction and type assignment systems (see Sections \\ref{sec:classical-logic} and \\ref{sec:type-assignment} respectively).\n  \n  Sequent calculus manipulates \\emph{sequents} where a sequent is denoted by:\n  \n    \\[\n      `G \\vdash `D\n    \\]\n    \n  On the left-hand side, the $`G$ represents a sequence of zero or more statements called the \\emph{antecedent}.\n  On the right-hand side of the $\\vdash$, $`D$ represents a different sequence of zero or more statements called the \\emph{succedent}.\n  The whole sequent denotes that the conjunction of the statements in the antecedent imply the disjunction of the statements in the succedent.\n  That is to say, if all the statements on the left are true then at least one of the statements on the right is true:\n  \n  \\[\n    \\begin{array}{c}\n    A_1,A_2,\\dots,A_n \\vdash S_1,S_2,\\dots,S_m \\\\\n      \\text{denotes} \\\\\n    A_1 \\wedge A_2 \\wedge \\dots \\wedge A_n \\to S_1 \\lor S_2 \\lor \\dots \\lor S_m \\\\\n    \\end{array}\n  \\]\n\n  \\subsection{Classical Natural Deduction}\\label{sec:classical-logic}\n  \n  Gentzen's classical natural deduction used the sequent calculus and introduced a set structural rules for manipulating sequents \\cite{Groote94}.\n  \n  \\definition{\n  \\textsc{Structural rules of classical natural deduction} \n  \\[\n  \\begin{array}{c@{\\quad\\quad}c}\n  \n    \\Inf{`G,C,D,`G' \\vdash `D}\n       {`G,D,C,`G' \\vdash `D}\n       {\\hspace{5pt}\\mathcal{L}X}\n    &\n    \\Inf{`G \\vdash `D,C,D,`D'}\n       {`G \\vdash `D,D,C,`D'}\n       {\\hspace{5pt}\\mathcal{R}X}\n    \\\\\n    \\\\\n    \\Inf{`G \\vdash `D}\n       {`G,C \\vdash `D}\n       {\\hspace{5pt}\\mathcal{L}W}\n    &\n    \\Inf{`G \\vdash `D}\n       {`G \\vdash `D,C}\n       {\\hspace{5pt}\\mathcal{R}W}\n   \\\\\n   \\\\\n   \\Inf{`G,C,C \\vdash `D}\n       {`G,C \\vdash `D}\n       {\\hspace{5pt}\\mathcal{L}C}\n    &\n    \\Inf{`G \\vdash C,C,`D}\n       {`G \\vdash C,`D}\n       {\\hspace{5pt}\\mathcal{R}C}\n   \\\\\n   \\\\\n   \\multicolumn{2}{c}{\n    \\Inf{`G \\vdash `D,A \\hspace{10pt} A,`G' \\vdash `D'}\n        {`G,`G' \\vdash `D,`D'}\n        {\\hspace{5pt}\\textbf{Cut}}\n   }\n  \\end{array} \n  \\]\n  }\n  \n  The first set of rules, $\\mathcal{LX}$ and $\\mathcal{RX}$, are left and right exchange rules. \n  They express the commutativity of statements in the left and right sequences.\n  The weakening rules, $\\mathcal{LW}$ and $\\mathcal{RW}$, allow the introduction of new formul\\ae\\ on either the left or right sequences.\n  The contraction rules, $\\mathcal{LC}$ and $\\mathcal{RC}$, allow the contraction of multiple occurrences of a formula into a single occurrence. \n  The cut rule allows us to replace assumptions of formul\\ae\\ with their concrete proofs, if we have proved them somewhere else.\n  \n  In addition to these, the system has a set of logical rules which relate closely to natural deduction.\n  Although rules for all the logical connectives exist, we again choose to highlight just the cases important to this project:\n  \\definition{\n  \\textsc{Logical rules of classical natural deduction} \\cite{Groote94}\n  \\[\n  \\begin{array}{c@{\\quad\\quad}c}\n    \\Inf{`G \\vdash C,`D \\hspace{10pt} `G',D \\vdash `D'}\n        {`G,`G',C \\to D \\vdash `D,`D'}\n        {\\hspace{5pt}\\mathcal{L}\\to}\n    &\n    \\Inf{`G,C \\vdash D,`D}\n        {`G \\vdash C \\to D,`D}\n        {\\hspace{5pt}\\mathcal{R}\\to}\n    \\\\\n    \\\\\n    \\Inf{`G \\vdash C,`D}\n        {`G,\\neg C \\vdash `D}\n        {\\hspace{5pt}\\mathcal{L}\\neg}\n    &\n    \\Inf{`G,C \\vdash `D}\n        {`G \\vdash \\neg C,`D}\n        {\\hspace{5pt}\\mathcal{R}\\neg}\n  \\end{array}\n  \\]\n  }\n  Moving a statement from the left-hand sequent to the right negates that statement.\n  The same is true moving a statement from the right-hand sequent to the left.\n  The implication rules allow the introduction of $\\to$ in either the left or right sequent.\n  \n  \\subsection{Type Assignment}\\label{sec:type-assignment}\n  \n  There are many type assignment different systems.\n  Systems of type assignment introduce additional grammar and restrictions on the reduction rules of a formal system. \n  These extensions prevent logically inconsistent terms from being constructed. \n  A type assignment has the form:\n  \\[\n    M : `a \n  \\]\n  which states that term $M$ has the type $`a$. \n  Like variables, type variables are abstract: \n  they do not describe anything more about a type than its identity. \n  That is to say $x: A$ and $y : A$ have the same type but we cannot say any more about what that type is.\n \n  A type is either some uppercase Latin letter or it is two valid types connected by a $\\rightarrow$. \n  This is described by the following BNF grammar:\n \\\\ \n  \\definition{\n    \\textsc{(Grammar for constructing types)} \n    \\item Type variables are represented by the lower-case greek alphabet $`a,`b,`g,...$\n    \\[\n      A ::= `v \\mid `v \\rightarrow B \n    \\]\n  }\n  \n  \\subsection{Typed \\lam-Calculus}\n  The typed \\lam-calculus is an extension of the \\lam-calculus with types assigned to \\lam-terms.\n  \\lam-abstractions have arrow types: $A \\to B$.\n  This describes that the abstraction can only be applied to a value of type $A$ and returns one of type $B$.\n  Type assignment rules for the \\emph{typed} \\lam-calculus are:\n\n  \\[\n  \\begin{array}{c@{\\quad\\quad}c@{\\quad\\quad\\quad}c}\n    \\Inf{ `G,x:A \\vdash x : A }\n    &\n    \\Inf{\n      `G \\vdash M : A \\to B \\hspace{20pt} N:A \n    }{\n      `G \\vdash M N : B \n    }\n    &\n    \\Inf{\n      `G,x:A \\vdash M : B\n    }{\n      `G \\vdash `lx.M : A \\to B \n    }\n    \\vspace{5pt}\n    \\end{array}\n  \\]\n  Similarly to the sequent calculus, \n  the letter $`G$ represents a sequence of type assignment statements.\n  In $`G$, each variable can only have one type.\n  The form of these rules denote that the typing judgement on the right-hand side of the $\\vdash$ are a consequence of the sequence of type assignment statements in $`G$.\n  The first rule states that the application of a term of type $A \\to B$ to\n  a term of type $A$ has type $B$. \n  The second rule says a term of type $B$ in a context where $x:A$ is the same as an abstraction of type $A \\to B$ in a context without $x:A$. \n  These rules add restrictions on what constitutes a well-formed term.\n  These restrictions prevent the formation of terms with undesirable properties.  \n  \n  \\begin{example}[Type-assignment restricts set of valid terms]\n  \\[  \n  \\begin{array}{lr}\n    (`lx.xx)(`lx.xx) \\\\\n    xx : B \\\\\n    x : A \\to B \\\\\n    x : A\n  \\end{array}\n  \\]\n  The variable $x$ is applied to a term so it must have type $A \\to B$.\n  The term it is applied to must have type $A$.\n  However $x$ is applied to itself so it must have type $A$ and $A \\to B$.\n  This means the term $`lx.xx$ is untypable according to this simple type assignment system:\n  the conflicting types for $x$ mean the term is disallowed by the rules of the typed \\lam-calculus.\n  \\end{example}\n \n  \\subsection{Curry-Howard Isomophism}\n  \n  The Curry-Howard isomorphism states that there is a true isomorphism between the type of a term and a logical proposition. \n  The type of a term is a logical proposition and the term itself its a proof of that proposition.\n  The simplification of a proof maps to the evaluation of the corresponding program \\cite{Wadler15}.\n  \n  Looking again at the type assignment rules of the typed \\lam-calculus and the inference rules of IIL,\n  the correspondence is clear:\n  \n  \\[\n  \\begin{array}{cc@{\\quad\\quad}c}\n    & `l\\textbf{-calculus} & \\textbf{IIL}\n    \\\\\n    \\\\\n    \\to\\mathcal{E} \n    &\n    \\Inf{ `G \\vdash M : A \\to B \\hspace{20pt} N:A }\n        { `G \\vdash M N : B }\n    &\n    \\Inf{ A \\to B \\hspace{0.5cm} A }\n        {B}\n    \\\\\n    \\\\\n    \\to\\mathcal{I} \n    &\n    \\Inf{ `G,x:A \\vdash M : B }\n      { `G \\vdash `lx.M : A \\to B }\n    &\n    \\Inf{ \\infer*{B}{[A]} }\n        { A \\to B}\n   \\\\\n    \\end{array}\n  \\]\n \n  The correspondence between logic and programs is not limited to IIL and the typed \\lam-calculus.\n  There are many features of computer programs that have counter-parts in logical systems.\n  % TODO: add more - examples and demonstration\n\n\\section{Haskell}\n  % TODO: describe purity and laziness\n  % TODO: add section on exceptions\n  \n  \\subsection{Data Types}\n  New data types can be introduced into Haskell in 3 distinct ways. First,\n  using the \\mono{data} keyword:\n  \n  \\Verbatimcode\n    data Animal a = Dog a\n      | Cat\n  \\end{Verbatim}\n  \n  The \\mono{data} keyword begins the definition of a new data type. The\n  word immediately following determines the type constructor for the new\n  type. Following this is a type parameter for the type constructor. There\n  can be any number of type parameters, including zero. The right-hand\n  side of the \\mono{=} introduces a \\mono{|}-separated list of data \n  constructors.\n  \n  \\Verbatimcode\n    > let hector = Cat\n    > :t hector\n    hector :: Animal a\n    > let topaz = Dog \"foo\"\n    > :t topaz\n    topaz :: Animal String\n  \\end{Verbatim}\n  \n  The type parameter is constrained by the type of the value the data\n  constructor was initialized with. In the example above, calling the\n  \\mono{Dog} data constructor with a string makes the type \\mono{Animal\n  String} rather than the more general \\mono{Animal a}.\n  \n  The second method for introducing new data types is the \\mono{newtype} keyword. \n  The key difference between \\mono{data} and \\mono{newtype} is that \\mono{newtype} can only have one data constructor and this data constructor can only have a single argument\n  Informally, this implies a kind of isomorphism:\n\n  \\Verbatimcode\n    newtype Foo a = Foo (a -> Integer)\n  \\end{Verbatim}\n  The type constructor can take type parameters which will be constrained\n  by the inhabitants of the data constructor. This data type expresses\n  an isomorphism between \\mono{Foo a} and functions from \\mono{a} to\n  \\mono{Integer}s.\n  \n  Finally, we can introduce type aliases using the \\mono{type} keyword:\n  \\Verbatimcode\n    type Name = String \n  \\end{Verbatim}\n  \n  Again, we introduce a type constructor \\mono{Name} but this time we name another type in place of a data constructor, \n  in this case \\mono{String}.\n  This means that the type \\mono{Name} is a type alias for \\mono{String} and will share the same data constructors. \n \n  \\subsection{Type Level/Value Level}\n  \n  Haskell distinguishes between terms on the type level and terms on the value level. \n  This is the same as the separate layer of terms and types in the typed \\lam-calculus.\n  Types in Haskell are descriptions of the types of a value.\n  They provide restrictions on the construction of invalid terms. \n  For instance if we have a function of type \\mono{String -> Integer}, \n  we cannot apply it to a term of type \\mono{Boolean}. \n  The type checker will throw an error before any value-level computation is initiated.\n \n  % TODO: better description needed\n  The value level is the level on which data is constructed and manipulated.\n  The operation \\mono{1+1} occurs on the value level. The value level is\n  where computation takes place and the type level is where static analysis\n  of the program type takes place.\n  \n  \\subsection{Type Classes}\n  Haskell adds type classes to the type level. Types can have instances of\n  type classes. The most similar concept from Object-Oriented programming\n  is \\emph{interfaces}.\n  \n  \\Verbatimcode\n    class Addable a where\n      (add) :: a -> a -> a\n  \\end{Verbatim}\n  \n  Type classes are introduced using the \\mono{class} keyword. Beneath that\n  are the function names and corresponding type-signatures of the functions\n  that an instance of a class must implement.\n  \n  For example, we can create instances of the \\mono{Addable} class:\n  \\Verbatimcode\n    data Number = One | Two | ThreeOrMore\n    \n    instance Addable Number where\n      add One One = Two \n      add _ _     = ThreeOrMore \n  \\end{Verbatim}    \n  To declare an instance of a type class, we must supply the bodies for functions in the class specification.\n  The \\mono{Addable} class, for instance, requires that the body of the \\mono{add} function is defined.\n  When declaring an instance, we have to ensure the type specification of each function is respected.\n  \n% TODO: these explanations of continuations (diff between delim and \n%       undelim) are incorrect \n\\section{Continuations}\n \n  As in the example in Figure \\ref{fig:decomposing}, \n  compound \\lam-terms can be evaluated into a dominant term and a context:\n  \\begin{figure}[H]\\label{fig:decomposing-lambda}\n    \\hspace{1cm}Assume that $M \\rightarrow^{*}_{`b} M^\\prime$\n    \\[\n    \\begin{array}{lrcl}\n    \\textit{(Compound term)}&& MN \\\\\n    \\textit{(Decompose)}&M && \\square N \\\\\n    \\textit{(Beta-reduce dominant term)}& M^\\prime && \\square N \\\\\n    \\textit{(Refill hole of context)}&& M^\\prime N \\\\\n    \\end{array}\n    \\]\n  \\caption{Decomposing a term into a dominant term and a context}\n  \\end{figure}\n  \n  Contexts are partial terms that remain to be reduced after the reduction of the dominant term.\n  After the dominant term has reduced to a value,\n  that value will fill the hole ($\\square$) of the context to form a new term. \n  For example, consider the term \n  \\[\n    (`lx.`ly.xy)(`lz.z)t\n  \\]\n  According to our bracketing convention, the leftmost redex is reduced first:\n  \\[\n    (`lx.`ly.xy)(`lz.z) \n  \\]\n  After this term has reduced, the reduct will be applied to $t$:\n  \\[\n    \\square t \n  \\]\n  In this way, the context $\\square t$ holds information about the \\emph{rest} of the reduction steps.\n  The context of a term is the future computation of that term: what will happen to the term after it has been reduced.\n  For this reason, the context is also called a \\emph{continuation}.\n \n  \\subsection{Undelimited Continuations} \n \n  For more complex terms, the waiting context will grow as the dominant term gets further decomposed:\n  \n  \\begin{figure}[H]\n    \\[\n    \\begin{array}{ll}\n      (MM^\\prime) M^{\\prime\\prime} \\\\\n      (MM^\\prime) & \\square M^{\\prime\\prime} \\\\\n      M & (\\square M^\\prime) M^{\\prime\\prime} \\\\\n    \\end{array}\n    \\]\n  \\caption{Decomposing a term into multiple contexts}\n  \\end{figure}\n\n  By amalgamating continuations into one big continuation we only have two components at any point during the reduction: \n  the current dominant term and the \\emph{current continuation}. \n \n  By adding additional operators to a language, the continuations of terms can be exposed.\n  This provides programmers with the ability to control continuations.\n  Control operators that only allow manipulation of the entire remaining continuation are \\textbf{undelimited continuations}. \n  For example, Scheme's \\mono{call/cc} operator aborts the entire remaining continuation.\n\n  \\subsection{Delimited Continuations}\n\n  Instead, if we maintain continuations in a stack when decomposing complex terms, \n  we can keep the continuations separated:\n  \n  \\begin{figure}[H]\n    \\[\n    \\begin{array}{lll}\n      (MM^\\prime) M^{\\prime\\prime} \\\\\n      (MM^\\prime) & \\square M^{\\prime\\prime} \\\\\n      M & \\square M^\\prime & \\square M^{\\prime\\prime} \\\\\n    \\end{array}\n    \\]\n  \\caption{Decomposing a term into multiple contexts}\n  \\end{figure}\n\n  Here, when a dominant term has been reduced, \n  the reduct is returned to the continuation at the top of the stack. \n  This newly joined term then becomes the dominant term. \n  After this new dominant term has been reduced, \n  it will be returned to the next waiting continuation, and so on. \n  Throughout this process, we maintain each continuation separately.\n\n  If the control operators of a language allow manipulation of portions of the continuation stack,\n  the continuations are \\textbf{delimited}.\n  To manipulate portions of the stack, these operators need a \\emph{control delimiter}.\n  A control delimiter marks a point on the stack that delimits how far the operators can control.\n  These delimiters commonly called \\emph{prompts}, after Felleisen first introduced them as such \\cite{Felleisen88}.\n  By allowing prompts to be pushed onto the stack, we can recall portions of the stack \\emph{up until} a prompt.\n  This gives the operators a finer grain of control over continuations.\n\n  \\subsection{Continuation-Passing Style}\n \n  By rewriting \\lam-terms, a term's continuation can be made explicit. \n  All terms must be turned into \\lam-abstractions of some variable $k$ where $k$ is the continuation of a term. \n  $k$ is then called on the result of the term, triggering the continuation to take control.\n  This style of writing \\lam-terms is called continuation-passing style or CPS \\cite{Sussman98}.\n  \n  \\definition{\n    \\textsc{(Translation of standard \\lam-terms into CPS)}\n    \\cite{Groote94}\n    \\[\n    \\begin{array}{lcl}\n      \\tr{x}     & = & `lk.kx      \\\\\n      \\tr{`lx.M} & = & `lk.k(`lx.\\tr{M}) \\\\\n      \\tr{M N} & = & `lk.M(`lm.m\\tr{N}(`ln.mnk)\n    \\end{array}\n    \\]\n  }\n  \n  The term that a CPS program terminates on will be of the form\n  $`lk.kM$. In order to extract the value, a \\emph{final continuation}\n  must be provided. Depending on the context, this could be an identity \n  function $`lx.x$ or a display operation $`lx.\\textsc{display }x$ to\n  display the results of the program.\n\n  \\begin{example}{Extracting the final value from a terminated CPS program}\n  \\[\n  \\begin{array}{ll}\n                & (`lk.kM)(`lx.x) \\\\\n    \\rightarrow & (`lx.x)M \\\\\n    \\rightarrow & M\n  \\end{array}\n  \\]\n  \\end{example}\n \n  The translation of standard \\lam-terms into CPS similarly transforms the \n  \\emph{types} of \\lam-terms. For example, a term $x : A$ becomes \n  $`lk.kx : (A \\to B) \\to B$. This type represents a delayed computation:\n  a computation that is waiting for a function to continue execution with. \n  In order to resume the computation, the term must be applied to a \n  continuation.\n  \n  As an example, take the term $M$ where\n  \n  \\[\n    M = `lk.kx\n  \\]\n\n  To access the value $x$ contained in $M$, we have to apply $M$ to a\n  continuation function $`lm.N$:\n  \n  \\[\n  \\begin{array}{rl}\n      & (`lk.kx)(`lm.N) \\\\\n      \\to & (`lm.N)x \\\\\n      \\to & N[x/m]\n  \\end{array}\n  \\]\n  \n  Within the body of $N$, $m$ is bound to the value contained by $M$.\n  So we can think about $M$ as a suspended computation that, when applied\n  to a continuation, applies the continuation to $x$. Looking at\n  the type $(A \\to B) \\to B$ again, it is clear that $A$ is the type\n  of the term passed to the continuation of the CPS-term:\n  \n  \\[\n  \\begin{array}{l}\n    `lk.kx : (A \\to B) \\to B \\\\\n    k : (A \\to B) \\\\\n    kx : B \\\\\n    x : A \\\\\n  \\end{array} \n  \\]\n  \n  % TODO: explain how order-of-evaluation can be enforced using \n  %       cps.\n \n  \\subsection{Monads}\n  \n  If we have two suspended computations $M$ and $M^\\prime$ and we want to\n  run $M$ and then $M^\\prime$, we have to apply $M$ to a continuation\n  to access its value and then do the same to $M^\\prime$:\n  \n  \\[\n    M(`lm.M^\\prime(`lm^\\prime.N))\n  \\]\n  \n  This is a common operation so we define a utility operator \\mono{>>=} \n    (read: 'bind') \n  that binds the first suspended computation to a continuation which returns another suspended computation:\n  \\[\n    \\mono{>>=} : ((A \\to B) \\to B) \\to (A \\to ((B \\to C) \\to C)) \\to ((B \\to C) \\to C)\n  \\]\n  The type $(A \\to B) \\to B$ that represents a suspended computation returning\n  a value of type $A$ to its continuation we will call an $A$-computation or\n  $Comp\\ A$. We can rewrite the type signature of \\mono{>>=}:\n  \n  \\[\n    \\mono{>>=} : Comp\\ A \\to (A \\to Comp\\ B) \\to Comp\\ B\n  \\]\n  \n  We define another operator, $return$, that takes a value and returns a \n  suspended computation that returns that value:\n  \n  \\[\n    return : A \\to Comp\\ A \n  \\]\n \n  The type constructor $Comp\\ A$, together with the two utility functions\n  \\mono{>>=} and $return$, make up Haskell's Monad type class:\n  \n  \\Verbatimcode\n    class Monad M where\n      (>>=) :: M a -> (a -> M b) -> M b\n      return :: a -> M a\n  \\end{Verbatim}\n  \n  The Monad type class generalizes CPS terms: they represent suspended\n  computations that can be composed using \\mono{>>=}. Just like CPS terms,\n  a Monad type \\mono{M a} tells us that we have a term that will pass\n  values of type \\mono{a} to the continuation it is bound to using\n  \\mono{>>=}.\n  \n  % TODO: finish explanation of linking suspended-computations and CPS\n  %       to monads\n\n\\section{\\lmu-Calculus}\n  \n  Michel Parigot defined the \\lmu-calculus as a system with an isomorphism to classical natural deduction.\n  It is an extension of the \\lam-calculus. \n  This means that the grammar and reduction rules of the \\lmu-calculus are a superset of those of the \\lam-calculus.\n  \n\n  % TODO: intuitively, that mu-terms are expressed easily by continuation \n  %       passing style gives us some idea that they are about control flow\n  %       and that they will be easily expressed by monads\n  % TODO: add rules for consumption of multiple terms\n  % TODO: add typing rules\n  % TODO: add reduction strategy and information about normal form\n  \\subsection{Syntax}\n  \n  Just as \\lam\\ introduces \\lam-abstractions, \n  $`m$ introduces $`m$-abstractions. \n  The body of a $`m$-abstraction must be a named term. \n  A named term consists of a name of the form $[`a]$ followed by an unnamed \n  term. \n\n  \\begin{figure}[H]\n  \\definition{ \n    \\textsc{(Grammar for \\lmu-calculus)}\n    \\item $`l$-variables are denoted by $x, y,\\dots$ and $`m$-variables are denoted by $`a, `b,\\dots$ \\\\\n    \\[\n    \\begin{array}{lrcl}\n    \n    \\text{(Unnamed term)} & M,N & ::= & x\\ |\\ `lx.M\\ |\\ M\\ N\\ |\\ `m`a.C \\\\\n    \\text{(Named term)} & C & ::= & [`a]M\n    \\end{array}\n    \\]\n  }\n  \\end{figure}\n  \n  \\subsection{Reduction Rules}\n  \\begin{figure}[H]\n  \\definition{ \n    \\textsc{(Reduction rules for \\lmu-calculus)}\\\\\n    $i)$ $\\to_{`b`m}$ is defined as the compatible closure of rules:\n    \\\\ \n    \\[\n    \\begin{array}{rrcll}\n    \\text{(logical)} & (`lx.M) N & \\to_{`b} & M[N/x] \\\\\n    \\text{(structural)} & (`m`a.[`b]M) N & \\to{`m} & `m`a.[`b](M\\{[`g]M^\\prime N/[`a]M^\\prime\\}) & (`b \\not= `a)\\\\\n        & (`m`a.[`b]M) N & \\to{`m} & `m`a.[`g](M\\{[`g]M^\\prime N/[`a]M^\\prime\\})N & (`b = `a) \\\\\n    \\text{($`m`h$)} & `m`a.[`a]M & \\to{`m} & M & (`a \\notin fn(M)) \\\\\n    \\text{(renaming)} & `m`d.[`b](`m`g.[`a]M) & \\to{`m} & `m`d.([`a]M)[`b/`g] \\\\\n    \\end{array}\n    \\]\n    $ii)$ $\\to_{`b`m}^{*}$ is defined as the transitive closure of $\\to_{`b`m}$.\n  }\n  \\end{figure}\n\n  The structural reduction rule simply states that the application of a $`m$-abstraction $`m`a.M$ to a term $N$ applies all the sub-terms of $M$ labelled $[`a]$ to $N$ and relabels them with a fresh $`m$ variable.\n  It can be thought of as a \\lam-abstraction that can be applied to any number of variables \\cite{Parigot92}.\n  If we knew how many variables the term is applied to, we could replace\n  \\[ `m`a\\dots[`a]M \\]\n  with \n  \\[ `lx_1\\dots`lx_n\\dots Mx_1\\dots x_n \\]\n  where $n$ is the number of variables the term is applied to.\n  \n  \\subsection{Computational Significance}\n\n  A \\lmu-abstraction applied to some term $N$ points the $`m$-variable to the context $\\square N$.\n  In this sense, the \\lmu-abstraction captures contexts where the contexts are supplied by application.\n  For this reason, \\lmu-calculus is described as using \\emph{applicative} contexts.\n  When an unnamed term is labelled with a \\lmu-variable, it is evaluated in that context. \n  For instance the named term $[`a]M$ has the effect of evaluating $M$ in the context pointed to by $`a$.\n  \n  By translating $`m$-terms into CPS, we can see the mapping between $`m$-variables and contexts more clearly:\n  \\definition{\n  \\textsc{CPS translation of $`m$-terms} \\cite{Groote94}\n  \\[\n  \\begin{array}{rcl}   \n    \\tr{`m`a.M} & \\triangleq & `l`a.\\tr{M} \\\\\n    \\tr{[`a]M} & \\triangleq & `lk.\\tr{M}\\ `a\\ k\n  \\end{array}\n  \\]\n  }\n  A $`m$-abstraction binds a continuation to a variable for use throughout the abstraction's body.\n  A named term applies the term to the name, effectively running the term in the continuation.\n  \n  To make this more concrete, consider the compound term $(`m`a.[`b]M)\\ N$. \n  First we decompose the term into a dominant term $`m`a.[`b]M$ and a context $\\square N$. \n  The dominant term is now a $`m$-abstraction so we can think about the variable at the head of the $`m$-abstraction now mapping to the context $\\{`a \\Rightarrow \\square N\\}$:\n  \n  % TODO: reform to get rid of context mapping:\n  %   keep mu abstraction in dominant and consult context for\n  %   what to apply named-terms to\n  \\begin{example}[]\n  \\[\n  \\begin{array}{lc}\n    \\textbf{Dominant} & \\textbf{Context} \\\\\n    (`m`a.[`b]M) N \\\\\n    `m`a.[`b]M & \\square N \\\\\n  \\end{array}\n  \\]\n  \\end{example}\n\n  All subterms of $M$ labelled $`a$ will now be evaluated in the context $\\square N$ after which the context will be destroyed. \n  For example, let us replace $M$ with \\mbox{$`m\\nonocc.[`a](`ls.fs)$}:\n  \\footnote{Following van Bakel, we use $\\nonocc$ to denote a $`m$-variable that does not occur in the body of the \\lmu-abstraction.}\n  \n  \\begin{example}\n    \\[\n    \\begin{array}{lcr}\n    \\textbf{Dominant} & \\textbf{Context} \\\\\n    `m`a.[`b]`m\\circ.[`a](`ls.fs)    & \\square N \\\\\n    `m`a.[`a](`ls.fs)    & \\square N \\\\\n    `m`g.[`g](`ls.fs)N   & & (`g\\ \\text{fresh})  \\\\\n    \\end{array}\n    \\]\n  \\end{example}\n\n  % TODO: explain applicative contexts\n  After applying the term $[`a](`ls.fs)$ to $N$, \n  the context $\\square N$ is consumed and every occurrence of $`a$ is replaced with a fresh variable \n  -- in this case a $`g$ -- \n  to clarify that the $`m$-abstraction now points to a new context. \n  This means that $`m$-abstractions will pass all of the applicative contexts to the named subterms:\n  \n  \\begin{example}\n    \\[\n    \\begin{array}{lcr}\n    \\textbf{Dominant} & \\textbf{Context} \\\\\n    (`m`a.[`a](`ls.`lt.st)) M N \\\\\n    (`m`a.[`a](`ls.`lt.st))M & \\square N \\\\\n    `m`a.[`a](`ls.`lt.st) & \\square M:\\square N \\\\\n    `m`g.[`g](`ls.`lt.st)M & \\square N & (`g\\ \\text{fresh}) \\\\\n    `m`d.[`d](`ls.`lt.st)MN & \\square N & (`d\\ \\text{fresh}) \\\\\n    \\end{array}\n    \\]\n  \\end{example}\n  \n  \\subsection{Curry-Howard Isomorphism}\n  The typed variant of the \\lmu-calculus is isomorphic to classical natural deduction.\n  The type assignment rules for the typed \\lmu-calculus are as follows:\n  \n  \\definition{\n  \\textsc{Typing rules for the typed \\lmu-calculus} \\\\\n  The three type-assignment rules from the \\lam-calculus are still valid. In addition:\n  \\[\n  \\begin{array}{c@{\\quad\\quad}c}\n    \\Inf{`G \\vdash M : B\\ |\\  `a : A, `b : B, `D}\n        {`G \\vdash `m`a.[`b]M : A\\ |\\ `b : B, `D}\n    &\n    \\Inf{`G \\vdash M : A\\ |\\ `a : A, `D}\n        {`G \\vdash `m`a.[`a]M : A\\ |\\ `D}\n  \\end{array}\n  \\]\n  }\n  \n  These rules correspond to the structural rules of classical natural deduction.\n  The original presentation of Parigot's type assignment makes the isomorphism clearer.\n  Our presentation here makes it easier to understand the role of the operators.\n  \n  \\subsection{Lazy Reduction}\n  We define lazy-reduction for the \\lmu-calculus similarly to \\lam-calculus.\n  The outermost, leftmost reduction takes place first. \n  If no reductions can take place on the outermost level, then the term is in lazy normal form.\n  For instance, consider the $`m$-term:\n  \\[\n    `m`a.[`b]((`lx.x)z)\n  \\]\n  This term is in lazy normal form: the only redex, $(`lx.x)z$, is beneath a $`m$-abstraction.\n  The term cannot be reduced any further.\n\n\\section{Calculus of Delimited Continuations}\n\n  Simon Peyton-Jones \\textit{et al.}\\ extended the \\lam-calculus with additional operators in order create a framework for implementing delimited continuations \\cite{JonesDS07}. \n  This calculus will be referred to as the calculus of delimited-continuations or \\emph{CDC}. \n  Many calculi have been devised with control mechanisms for manipulating continuations, like the \\lmu-calculus.\n  These control mechanisms manipulate either delimited or undelimited continuations. \n  CDC provides a set of operators that are capable of expressing many of the common control mechanisms found in the literature.\n\n  \\subsection{Syntax}\n  The grammar of CDC is an extension of the standard \\lam-calculus:\n\n  \\begin{figure}[!h]\n  \\definition{ \n    \\textsc{(Grammar for CDC)}\n    \\[\n    \\begin{array}{lrcl}\n    \\textrm{(Variables)} & x, y, \\dots \\\\\n    \\textrm{(Expressions)} & e & ::= & x\\ |\\ `lx.e\\ |\\ e\\ e^\\prime \\\\\n                           &   &  |  &  newPrompt\\ |\\ pushPrompt\\ e\\ e \\\\\n                           &   &  |  &  withSubCont\\ e\\ e\\ |\\ pushSubCont\\ e\\ e\n    \\end{array}\n    \\]\n  }\n  \\end{figure}\n\n  \\subsection{Reduction Rules}\n  \n  The operational semantics can be understood through an abstract machine that transforms tuples of the form $\\langle e,\\ D,\\ E,\\ q \\rangle$.\n  The tuple consists of:\n    \\begin{itemize}\n      \\item $e$ - the current dominant term\n      \\item $D$ - the current context/continuation\n      \\item $E$ - the stack of remaining continuations\n      \\item $q$ - a global counter for producing fresh prompt values\n    \\end{itemize}\n  By representing terms in this way, \n  the reduction rules are able to make the control of terms and their continuations more explicit.\n  \n  The abstract machine also introduces some Haskell-style notation for dealing with sequences. An empty sequence is represented by $[]$. \n  A value added to the head of a list is represented by the symbol $:$, for instance $D:[]$. $\\app$ represents two lists appended together. \n  $E\\until{p}$ and $E\\from{p}$ denote the subsequence of $E$ \\emph{until} prompt $p$ and \\emph{from} prompt $p$, respectively; \n  neither of these subsequences contain $p$.\n\n  \\begin{figure}[!h]\\label{fig:cdc-abstract-machine}\n  \\relscale{0.9}\n  \\definition{ \n    \\textsc{(Operational semantics for CDC)} \\cite{JonesDS07}\n    \\[\n    \\begin{array}{lcll}\n      \\langle e\\ e^\\prime, D, E, q \\rangle &\\to &\\langle e, D[\\square\\ e^\\prime], E, q \\rangle &\\text{e non-value} \\\\\n      \\langle v\\ e, D, E, q \\rangle &\\to &\\langle e, D[v\\ \\square], E, q \\rangle &\\text{e non-value} \\\\\n      \\langle pushPrompt\\ e\\ e^\\prime, D, E, q \\rangle &\\to &\\langle e, D[pushPrompt\\ \\square\\ e^\\prime], E, q \\rangle &\\text{e non-value} \\\\\n      \\langle withSubCont\\ e\\ e^\\prime, D, E, q \\rangle &\\to &\\langle e, D[withSubCont\\ \\square\\ e^\\prime], E, q \\rangle &\\text{e non-value} \\\\\n      \\langle withSubCont\\ p\\ e, D, E, q \\rangle &\\to &\\langle e, D[withSubCont\\ p\\ \\square], E, q \\rangle &\\text{e non-value} \\\\\n      \\langle pushSubCont\\ e\\ e^\\prime, D, E, q \\rangle &\\to &\\langle e, D[pushSubCont\\ \\square\\ e^\\prime], E, q \\rangle &\\text{e non-value} \\\\\n    \\\\\n      \\langle (`lx.e)\\ v, D, E, q \\rangle &\\to &\\langle e[v/x], D, E, q \\rangle \\\\\n      \\langle newPrompt, D, E, q \\rangle &\\to &\\langle q, D, E, q+1 \\rangle \\\\\n      \\langle pushPrompt\\ p\\ e, D, E, q \\rangle &\\to &\\langle e, \\square, p : D : E, q \\rangle \\\\\n      \\langle withSubCont \\ p\\ v, D, E, q \\rangle &\\to &\\langle v (D : E\\until{p}, \\square, E\\from{p}, q \\rangle \\\\\n      \\langle pushSubCont E^\\prime\\ e, D, E, q \\rangle &\\to &\\langle e, \\square, E^\\prime \\app (D : E), q \\rangle \\\\\n    \\\\\n      \\langle v, D, E, q \\rangle &\\to &\\langle D[v], \\square, E, q \\rangle \\\\\n      \\langle v, \\square, p : E, q \\rangle &\\to &\\langle v, \\square, E, q \\rangle \\\\\n      \\langle v, \\square, D : E, q \\rangle &\\to &\\langle v, D, E, q \\rangle\n    \\end{array}\n    \\]\n  }\n  \\end{figure}\n  \n  \\subsection{Significance}\\label{cdc-explanation}\n\n  % TODO: ensure prompts and continuation stack has been explained before reaching this point\n  The additional terms behave as follows:\n  \\begin{itemize}\n  \\item \\op{newPrompt} returns a new and distinct prompt.\n  \\item \\op{pushPrompt}'s first argument is a prompt which is pushed onto the continuation stack before evaluating its second argument. \n  \\item \\op{withSubCont} captures the subcontinuation from the most recent occurrence of the first argument (a prompt) on the excution stack to the current point of execution. Aborts this continuation and applies the second argument (a \\lam-abstraction) to the captured continuation.\n  \\item \\op{pushSubCont} pushes the current continuation and then its first argument (a subcontinuation) onto the continuation stack before evaluating its second argument.\n  \\end{itemize}\n  \n  The abstract machine defined in Figure \\ref{fig:cdc-abstract-machine} also encodes the reduction strategy:\n  the first block of rules define in what order redexes are reducted.\n \n\\section{\\ltry-Calculus}\n\n\\ltry\\ is a system defined by van Bakel in \\cite{Bakel15} for modelling exceptions.\nIt is an syntactic and semantic extension of the \\lam-calculus.\nUnlike previous systems, the \\ltry-calculus introduces the idea of named exceptions.\n\n\\subsection{Exceptions}\n\n\\emph{Exceptions} in programming languages are indications that control flow cannot continue.\nFor example, if you attempt to open a non-existent file,\nthe operation might throw an exception.\nIf an exception occurs without being caught, a program will exit with an error.\nExceptions can be caught and attempts at recovery can be made by \\emph{exception handlers}.\n\nThe common syntax for introducing exception handlers is in try-catch blocks.\nAn exception that occurs in a try-catch block will be handled by a corresponding handler.\nFor example, see the Javascript syntax for this:\n\n\\begin{Verbatim}\n  try {\n    /* possibly throw exception */\n  } catch (e) {\n    /* recover thrown exception */ \n  }\n\\end{Verbatim}\n\nThe \\mono{catch (e) \\{ ... \\}} introduces a single exception handler.\nThis exception handler will be called if an exception is thrown inside the try block.\nIf we want to introduce multiple exception handlers,\nwe need a mechanism for deciding which handler will be called for which exception.\nJava solves this by registering different exception handlers based on their type:\n\n\\begin{Verbatim}\n  try {\n    /* possibly throw exception */\n  } catch (IOException e) {\n    /* recover from IOException */  \n  } catch (FileNotFoundException e) {\n    /* recover from FileNotFoundException */ \n  }\n\\end{Verbatim}\n\nHere, which handler is called depends on the type of the exception thrown.\n\n\\subsection{Syntax}\n\nThe grammar of the \\ltry-calculus is as follows:\n\\definition{\n\\textsc{(Grammar of the \\ltry-calculus)}\n\\[\n  \\begin{array}{rclr}\n    C &::=& \\catch{ n$_1$($x$) = $M_1$ }; \\dots; \\catch{n$_i$($x$) = $M_i$} & (i \\geq 1) \\\\\n    M,N &::=& x\\ |\\ `lx.M\\ |\\ MN\\ |\\ \\try M;\\ C\\ |\\ \\throw{n($M$)}\n  \\end{array}\n\\]\n}\n\nThe grammar for $C$ describes a catch block as a series of one or more catch statements. \nFor convenience, we will use the notation \n\\[\n  \\mult{\\catch{n$_i$($x$) = $M_i$}}\n\\]\nto describe a catch block with one or more catch statements. \n\nThe \\ltry-calculus adds three new syntactic constructs:\n\\begin{itemize}\n\\item \\textbf{throw n($M$)} denotes the throwing of an exception with name $n$ passing it the value $M$.\n\\item \\textbf{catch n($x$) = $M$} registers the exception handler $M$ to the name $n$ with parameter $x$.\n\\item \\textbf{try $M$; $C$} attempts to run term $M$ in an environment with the exception handlers in catch block $C$ registered.\n\\end{itemize}\n\n\\subsection{Reduction Rules}\nIn conjunction with the additional syntactic constructions,\nthe \\ltry-calculus introduces some reduction rules:\n\n\\definition{\n\\textsc{(\\ltry\\ reduction rules)}\\cite{Bakel15}\n\\[\n\\begin{array}{rlcl}\n  \\text{($`b$):}      & (`lx.M)N &\\to& M[N/x] \\\\\n  \\text{(throw):}     & (\\throw{n($M$)})N &\\to& \\throw{n($M$)} \\\\\n  \\text{(try-throw):} & \\try \\throw{n$_l$($N$)};\\ \\mcatch &\\to& M_l[N/x] \\\\\n  \\text{(try-value):} & \\try V;\\ \\mcatch &\\to& V \\\\\n\\end{array}\n\\]\n}\n\nThe $`b$ reduction rule is familiar from the \\lam-calculus. \nA \\textbf{throw} term applied to any term discards the second term.\nA \\textbf{try} term that contains a throw reduces to the handler that corresponds to the name of the exception thrown with all occurrences of the parameter replaced by the value thrown. \nFor instance a $\\throw{n(N)}$ inside a \\textbf{try} will reduce to $M[N/x]$ if there is a $\\catch{n($x$) = $M$}$ in the catch block.\nA \\textbf{try} term that contains a value reduces to just that value.\n\n\\subsection{Significance}\nThe occurrence of an exception aborts the current computation.\n\\ltry\\ models this by discarding terms that a \\textbf{throw} is applied to.\nThe \\textbf{try-catch} statements mirror the syntax of try-catch statements in programming languages in the C-syntax family.\n\n", "meta": {"hexsha": "07be06a0c5cf4f7ff25f38e41ffb60f38d4fd3e8", "size": 54286, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "background.tex", "max_stars_repo_name": "FilWisher/exceptions-in-haskell", "max_stars_repo_head_hexsha": "d928a9ea8e25a4dd73c9beda6f8bf11f9b3c9b7a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-09-02T10:02:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-05T18:44:49.000Z", "max_issues_repo_path": "background.tex", "max_issues_repo_name": "FilWisher/exceptions-in-haskell", "max_issues_repo_head_hexsha": "d928a9ea8e25a4dd73c9beda6f8bf11f9b3c9b7a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-08-23T12:25:59.000Z", "max_issues_repo_issues_event_max_datetime": "2016-09-05T18:02:50.000Z", "max_forks_repo_path": "background.tex", "max_forks_repo_name": "FilWisher/exceptions-in-haskell", "max_forks_repo_head_hexsha": "d928a9ea8e25a4dd73c9beda6f8bf11f9b3c9b7a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9455481972, "max_line_length": 283, "alphanum_fraction": 0.6729543529, "num_tokens": 15768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.404943249177962}}
{"text": "\\documentclass[letterpaper, 11 pt, conference]{ieeeconf}  \n\\IEEEoverridecommandlockouts                             \n\\overrideIEEEmargins\n\n\\usepackage{graphics} % for pdf, bitmapped graphics files\n\\usepackage{epsfig} % for postscript graphics files\n\\usepackage{mathptmx} % assumes new font selection scheme installed\n%\\usepackage{times} % assumes new font selection scheme installed\n\\usepackage{amsmath} % assumes amsmath package installed\n\\usepackage{url}\n\\usepackage{amssymb}  % assumes amsmath package installed\n\n\\title{\\LARGE \\bf\nExploring the Space of Machine Learning Algorithms on Learning Stencil Based Kernels\n}\n\n\\author{Sandesh Borgaonkar \\& Vinu Joseph}% \n\\begin{document}\n\n\\maketitle\n\\thispagestyle{empty}\n\\pagestyle{empty}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{abstract}\nAbstract— Stencil based computations are used extensively in High Performance Computing (HPC) domain for finding\nsolutions of Partial Differential Equations (PDEs). These computations are represented in a polynomial form where the coefficients of the polynomial are influenced by the parameters such as boundary values, initial values, and the degree of accuracy. In this work, we present an empirical study to explore the solution space for following questions: i) is it possible to learn the coefficients of a given polynomial using regression analysis, and ii) how accurate the learning could be as compared to the original solution? And iii) what is the competitiveness of the various machine learning algorithms deployed for this purpose. Specifically, we use two state-of-the-art\nmachine learning packages, Libsvm and Liblinear, for learning the polynomial coefficients. In addition, we also implement our own version of learning model using stochastic gradient descent algorithm. Given the intractable size of the training data produced by the stencil kernels, we employ sampling strategy used in the prior work to reduce the sample size. We measure the effect of sample size on the quality of learning with respect to the three  different learning models described earlier.\n\\end{abstract}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{INTRODUCTION}\nStencil based computations are an important area of study in the scientific domain. They find a variety of applications in areas such as solutions to Partial Differential Equations (PDEs) and related areas of scientific computation research. Stencil computations essentially are repeated update of neighboring points on a multidimensional grid, based on a given intial condition (initial value problem) or intial and boundary conditions (boundary value problem), and can be used to represent a wide variety of real world differential equations such as heat and wave propagations. The effort in this project was to learn the stencil points using the constituent grid points as features, and compare the performance of various learning algorithms on such a learning. If the study is successful, the results could be potentially utilized in a variety of applications that mandate computational optimizations on stencils. Also, the comparitive analysis could help in making informed choices over picking a given learning algorithm over others. For this project, the PDE we used was heat1d equation.\n\n\\section{THEORETICAL BASIS}\n\\subsection{Equation}\nAs shown in Fig.1, the evaluation of any given grid point on the stencil of the heat1d PDE can be represented as :\\\\ \n\\begin{align*}\nh[i+1,j] &=\\alpha*h[i][j-1] +(2-\\alpha)*h[i][j] \\\\\n&\\qquad +h[i][j+1] + h[i][j+1] + f[i][j]*dt\n\\end{align*}\n\\\\\nHere, $i+1$ is indicative of the time step for which the computation is being done, and $j$ is the $j_{th}$ discrete point that is being evaluated on the basis of $(j-1)_{th}$, $j_{th}$ and $(j+1)_{th}$ positions of the current time step $i$. The parameter $\\alpha$ (also known as $cfl$) is defined by \\\\\\\\\n\\centerline{$\\alpha = \\dfrac{dt}{(dx)^2}$}\\\\\n\nwhere $dt$ and $dx$ are the sizes of discretized time and length steps. Further, the term $f[i][j]*dt$ is the value of actual heat1d equation at point $(i,j)$ multiplied by the discretized time step $dt$.\n\n\\subsection{Initial and Boundary Conditions }\n\\textit{Initial condition} refers to the value of initial temperature of the rod element to be considered for heating. Such a condition is spread across the length of the rod, except for the end points. The temperature of the end points constitute the \\textit{Boundary Condition}, which is imposed at every progressive time step of computation. We consider the following three initial condition variants : \\\\\n\\indent1. Triangular \\\\\n\\indent2. Sinusoidal \\\\\n\\indent3. Piecewise Linear \\\\\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_uni_1.png}\n\\caption{Uniform IC:50 and BC:90,70}\n\\label{uni1}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_uni_2.png}\n\\caption{Uniform IC:25 and BC:50,50}\n\\label{uni2}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_uni_3.png}\n\\caption{Uniform IC:0 and BC:25,80}\n\\label{uni3}\n\\end{figure}\n\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_tri_1.png}\n\\caption{Triangular IC:70/(L/2)x and BC:0,0}\n\\label{tri1}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_tri_2.png}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_tri_3.png}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_tri_4.png}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_pwl_1.png}\n\\end{figure}\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_pwl_2.png}\n\\end{figure}\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_pwl_3.png}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_pwl_4.png}\n\\end{figure}\n\n%TEST CASES\n\\begin{figure}\n\\includegraphics[scale=0.35]{plot_test_original_uni_4.png}\n\\end{figure}\nwhile keeping the boundary conditions constant.\nThe goal of this project is to try to learn the computation of stencil points for heat1d stencil for a randomized set of initial condition, boundary condition, and discretized time steps $dt$ and $dx$, in order to learn weights that can be deployed towards computation of any heat1d stencil in general.  We deploy 3 learning algorithms - LibSVM, LibLinear and our own implementation of \\textit{stochastic gradient descent} derived over an SVM objective, and also present a performance cross comparison of each of the algorithms used.\n\nThe following section decribes our experiments in detail. We try to outline the process of data collection, sampling, learning, cross validation and choice of hyper parameters, error collection finally the performance comparison of each of the algorithms used.  \n\n\n\\section{EXPERIMENTS}\n\\subsection{Data collection}\nWe collected the data by running the standard stencil program for heat1d \\cite{c7} and listing the results in the standard LibSVM format. The collection comprised of results from multiple runs of the program over randomized sets of initial conditions, boundary conditions and the discretized sets of time and length steps. The same randomized set of inputs was repeated for each variant of initial conditions (i.e. Triangular, Sinusoidal and Piecewise Linear) to give us corresponding 3 sets of raw data collections (one for each variant).\n\\subsection{Sampling}\nIn this work, we employed the sampling approach described in \\cite{c5}, where the  number of samples are tabulated for various confidence levels expressed as $(1-\\delta)*100$\\% and error $\\epsilon$ . The work described in \\cite{c2} provides pointers on information theoretic (entropy) based sampling, where a new sample from the population is added into the sample pool, based on how much variation it brings in into the training set.\n\\subsection{Choice of Parameters}\nCross validation experiment on each of the variants per algorithm (9cases), and the parameters finally chosen. \n\\subsection{Learning}\nMaybe show the weights reported in graphs?\n\\subsubsection{Using LibSVM}\n3 variants\n\\subsubsection{Using LibLinear}\n3 variants\n\\subsubsection{Using Our Implentation}\n3 variants\n\n\\subsection{Test Error Analysis}\nDeployment of the functions thus learned on the test set (9 cases again). Maybe show 3 plots, each for a variant with 3 lines for errors generated (bar graphs for training vs testing error)?\n\\subsubsection{Figures and Tables}\n\n\\section{Conclusion}\n\n\n\\addtolength{\\textheight}{-12cm}   \n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section*{ACKNOWLEDGMENT}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{thebibliography}{99}\n\n\\bibitem{c1} Vishal C. Sharma, Ganesh Gopalakrishnan, Greg Bronevetsky, Detecting Soft Errors in Stencil based Computations\n\n\\bibitem{c2} \nSiamak Mehrkanoon, Johan A.K Suykens, Learning solutions to partial differcential equations using LS-SVM. 2015\n\n\\bibitem{c3}\nSiamak Mehrkanoon, Johan A.K Suykens, LS-SVM approximate solutions to linear time varying descriptor systems, 2012\n\n\\bibitem{c4}\nEduardo Berrocal, Leonardo Bautista-Gomez, Sheng Di, Zhilling Lan and Frank Capello, Lightweight Silent Data Corruption Detection Based on Runtime Data Analysis for HPC Applications\n\n\\bibitem{c5}\nKen Kelly, Sample size planning for the coefficient of variation from the accuracy in parameter estimation\n\n\\bibitem{c6}\nRichard H Byrd, Gillian M. Chin, Jorge Nocedal, Yuchen Wu, Sample Size Selection in Optimization Methods for Machine Learning\n\n\\bibitem{c7}\nBurkardt, John, ”Scientific Computing Library” : \\url{https://people.sc.fsu.edu/~jburkardt}\n\n\\bibitem{c8}\nKreyszig, Erwin.”Advanced engineering mathematics”. Wiley, 2011.\n\n\\bibitem{c9}\nVishal C Sharma, Approaches for Approximate Stencil based Computations\n\n\\bibitem{c10}\nRong-En Fan, Kai-Wei Chang, Cho-Jui Hsieh, Xiang-Rui Wang, Chih-Jen Lin, LIBLINEAR: A Library for Large Linear Classification , NTU\n\n\\bibitem{c11}\nJohn burkardt, Florida State University, Codes and Data Sets \\url{https://people.sc.fsu.edu/~jburkardt/py_src/fd1d_heat_explicit/}\n\n\\bibitem{c12}\nMichael Bowles, Machine Learning in Python, Essential Techniques for Predictive Analysis\n\n\\bibitem{c13}\nBitbucket Repository \\url{https://vinutah@bitbucket.org/ufmr/cs6350mlproj.git}\n\n\\bibitem{14}\nIsaac Elias Lagaris, Aristidis Likas and Dimitirios I Fotiadis, Artificial Neural Networks for Solving ODE's and PDE's \n\n\\end{thebibliography}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "cf8cc004fe7f2bdfaf9b37e3f375863b7aae55ba", "size": 10546, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ml/report/main.tex", "max_stars_repo_name": "vinutah/projects", "max_stars_repo_head_hexsha": "e105ed9d9d6b4fd1784c97bcdd82c3f1f947cd06", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-12-14T22:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-14T22:11:00.000Z", "max_issues_repo_path": "ml/report/main.tex", "max_issues_repo_name": "vinutah/projects", "max_issues_repo_head_hexsha": "e105ed9d9d6b4fd1784c97bcdd82c3f1f947cd06", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ml/report/main.tex", "max_forks_repo_name": "vinutah/projects", "max_forks_repo_head_hexsha": "e105ed9d9d6b4fd1784c97bcdd82c3f1f947cd06", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.3608247423, "max_line_length": 1094, "alphanum_fraction": 0.7674947848, "num_tokens": 2567, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.4049432457436277}}
{"text": "\\documentclass[../../main]{subfiles}\n\\pagestyle{fancy}\n\n\\begin{document}\n\n\\chapter{Internal core model induction}\n\\label{chapter.internal-core-model-induction}\n\\thispagestyle{fancy}\n\n\n\\section{Operators and hybrid mice}\n\nWe'll need a generalisation of the concept of mice as we move up to the higher reaches of the core model induction, a generalisation usually known as either \\textit{hybrid mice} or \\textit{operator mice}. The basic concept is simple. When we're constructing ``pure'' mice we're traversing the $\\J$-hierarchy, applying the $\\J(x):=\\rud(x\\cup\\{x\\})$ operator at every step, and taking unions at limit stages. In the hybrid case we're simply replacing $\\J$ with another \\textit{operator} $\\F$, again applying it at every successor stage and taking unions at limits.\n\n\\qquad Figuring out what operators we're allowed to pick is the hard part, as we want to maintain all the fine structure that we get in the ``pure'' case. This has been done in great detail in \\cite{SchlutzenbergTrang}, and we'll introduce a particularly simple case of their general definition here.\n\n\\defi[Schlutzenberg-Trang]{\n  For a set $x$ write $\\rho_x:x\\to\\rk x$ for the rank function of $x$ and define the \\textbf{rank closure} $\\hat x:=\\trcl(\\{x, \\rho_x\\})$ of $x$ and the \\textbf{cone} $C_x := \\{\\hat y\\in H_\\kappa\\mid x\\in\\J_1(\\hat y)\\}$ over $x$.\n}\n\n\\defi[Schlutzenberg-Trang]{\n  Let $\\kappa$ be an infinite cardinal, $D$ a set of self-wellordered\\footnote{A set $x$ is \\textit{self-wellordered} if there's a wellorder of $x$ in $\\J(x)$.} sets and fix $b\\in H_\\kappa$. An \\textbf{operator on $H_\\kappa$ over $b$ with support $D$} is a partial function\n  \\eq{\n    \\F\\colon H_\\kappa\\dashrightarrow H_\\kappa\n  }\n  \n  such that $D\\cap C_b\\subset\\dom\\F$ and $\\dom\\F$ is closed under both unions and applications of $\\F$. We also call $C_b$ the \\textbf{cone over $b$} and $b$ the \\textbf{base of $C_b$}.\n}\n\nBefore we move on, let's take a step back and have a look at a few examples of operators. As this is supposed to be a generalisation of the $\\J$-function we'd want that to also be an operator, of course. Indeed, if $V=L$ then note that $\\hat x=x$ for all $x$, so if we take $\\emptyset$ to be our base then $C_a=J_\\kappa$, making $\\dom\\J=J_\\kappa$ trivially closed under both unions and applications of $\\J$.\n\n\\qquad We could also let $x$ be any set, assume that $V=L(\\hat x)$ and consider the operator $\\J_x$, which is simply applying $\\J$ but with base $\\hat x$ instead of $\\emptyset$. A similar argument as above would show that this is an operator on $J_\\kappa(\\hat x)$ ($=H_\\kappa^{L(\\hat x)}$) as well.\n\n\\qquad A slightly more sophisticated example would be $\\F := (-)^\\sharp$, where $x^\\sharp$ is the smallest initial segment of $\\lp(x)$ with a measure\\todo{Elaborate}. We can consider $\\F$ as an operator on $\\hc$ over $\\emptyset$, where $\\F(\\emptyset) = 0^\\sharp$ and $\\F^\\omega(\\emptyset) = \\bigcup_{n<\\omega}\\F^n(\\emptyset)$ is the smallest $\\sharp$-closed structure.\n\n\\todo[inline]{Check the last example}\n\nWe now, somewhat informally\\footnote{For a comprehensive definition, see \\cite[Section 2]{SchlutzenbergTrang}.}, define what hybrid mice are. Namely, an \\textbf{$\\F$-mouse on $\\hat x$} is a structure $\\M$ built by successively applying $\\F$ to $\\hat x$ and taking unions at limits. We can stop the construction at any point and denote the amount of $\\F$-applications by $l(\\M)$, the \\textbf{length} of $\\M$. The \\textbf{initial segments} of $\\M$ are simply the intermediate models up to $\\M$, being of the form $\\F^\\alpha(\\hat x)$ for some $\\alpha<l(\\M)$.\n\n\\qquad As with regular mice, we require that they are \\textit{amenable}, \\textit{acceptable} and that proper initial segments $\\F$-mice are \\textit{sound}. An extra property that we require in the hybrid context is that every proper initial segment $\\P\\pinit\\M$ is \\textit{${<}\\omega$-condensing}, roughly stating that if $\\pi\\colon\\N\\to\\P$ is a sufficiently elementary embedding from a ``nice'' $\\F$-structure then either $\\N$ is an initial segment of $\\P$ or an element of an ultrapower of $\\P$\\footnote{For a proper definition of these concepts in the hybrid context, see \\cite[Section 2]{SchlutzenbergTrang}.}.\n\n\\qdefi{\n  Let $\\kappa$ be an infinite cardinal and $\\F$ an operator on $H_\\kappa$ over $b\\in H_\\kappa$. We then define the \\textbf{$\\F$-lower part model on $b$} as\n  \\eq{\n    \\lp^{\\F}(b) := \\{\\M\\mid\\text{$\\M$ is a sound $\\F$-mouse projecting to $b$}\\}\\tag*{$\\circ$}\n  }\n}\n\n\\prop{\n  Let $\\kappa$ be an infinite cardinal and $\\F$ an operator on $H_\\kappa$ over $b\\in H_\\kappa$. Assuming $\\dc_{\\hat b}$ holds, $\\lp^{\\F}(b)$ is itself an $\\F$-premouse.\n}\n\\proof{\n  If $\\M\\pinit\\lp^{\\F}(b)$ then $\\M = \\chull^{H_\\nu}(\\hat b\\cup o(\\M))$, so that there's an isomorphism from $\\hat b^{<\\omega}$ onto $\\M$. Now, using $\\dc_{\\hat b}$, we can take a countable hull containing $\\hat b$, meaning that without loss of generality we may assume that $\\hat b$, and hence also $\\M$, is countable.\n\n  \\qquad This means that whenever we have two $\\M,\\N\\pinit\\lp^{\\F}(b)$ we may assume that they're both countable, which means that a comparison argument shows that one of them is an initial segment of the other. This means that all the mice in $\\lp^{\\F}(b)$ line up, which implies that all the axioms for being an $\\F$-premouse trivially hold for $\\lp^{\\F}(b)$.\n}\n\nFurther, $\\lp^{\\F}$ is itself an operator on $H_\\kappa$ over $b$ and we write $\\lp^{\\F}_\\alpha(b) := (\\lp^{\\F})^\\alpha(b)$.\n\n\\todo[inline]{Check that the definition of $\\lp^{\\F}$ is correct and that it \\textit{does} in fact have the two properties above.}\n\n\\defi[Schindler-Steel]{\n  Let $\\kappa$ be an infinite cardinal and $\\F$ an operator on $H_\\kappa$ over $b\\in H_\\kappa$. Then $\\F$ \\textbf{condenses well} if whenever $g\\subset\\col(\\omega,\\kappa)$ is $V$-generic and that there are models $\\overline\\M, \\M\\in H_\\kappa$ and $\\overline\\M^+\\in V[g]$, all on $b$, with \n  \\begin{enumerate}\n    \\item $\\abs{\\overline\\M} = \\abs{b}\\cdot\\aleph_0$;\n    \\item $\\overline\\M\\in\\overline\\M^+$;\n    \\item $\\overline\\M^+=\\hull_1^{\\overline\\M^+}(\\overline\\M)$;\n    \\item Either\n    \\begin{enumerate}\n      \\item There's a map $\\pi\\colon\\overline\\M^+\\to\\F(\\M)$ in $V[g]$ with $\\pi(\\overline\\M)=\\M$ and $\\pi\\restr(b\\cup\\{b\\})=\\id$ which is $\\Sigma_0$-cofinal or $\\Sigma_2$-elementary; or\n      \\item There's a model $\\P\\in\\dom\\F$ on $b$ with $\\F(\\P)\\in H_\\kappa$ and maps $i\\colon\\F(\\P)\\to\\overline\\M^+$ and $\\pi\\colon\\overline\\M^+\\to\\F(\\M)$, both in $V[g]$ but with their composition in $V$, with $i(\\P)=\\overline\\M$, $\\pi(\\overline\\M)=\\M$,\n      \\eq{\n        i\\restr(b\\cup\\{b\\})=\\pi\\restr(b\\cup\\{b\\})=\\id,\n      }\n      \n      $i$ is $\\Sigma_0$-cofinal or $\\Sigma_2$ elementary, and $\\pi$ is a weak $\\Sigma_1$-embedding.\n    \\end{enumerate}\n  \\end{enumerate}\n\n  Then $\\overline\\M^+ = \\F(\\overline\\M)\\in V$.\n}\n\nIt turns out that \\textit{condenses well} is a bit too strong to do proper core model theory, as shown in \\cite{SchlutzenbergTrang}, and in that paper they propose a technical weakening of this concept which they call \\textit{condenses finely}, whose definition is of a similar spirit as the above. We therefore formally require that our desired operators only condense finely, but as all the operators that we will encounter ``in the wild'' in this thesis condense well, we will omit the definition of fine condensation here.\n\n\\defi{\n  An operator $\\F$ \\textbf{determines itself on generic extensions} if there exists a formula $\\varphi(v_0, v_1)$ such that whenever $\\M$ is an $\\F$-premouse with\n  \\eq{\n    \\M\\models\\kp + \\godel{\\text{there are arbitrarily large cardinals}},\n  }\n\n  $\\kappa$ is an $\\M$-cardinal and $g\\subset\\col(\\omega, \\kappa)$ is $\\M$-generic, then $\\hc^{\\M[g]}$ is closed under $\\F$ and $\\F\\restr\\hc^{\\M[g]} = (\\tau_\\kappa^{\\M})^g$, with $\\tau_\\kappa^{\\M}$ being the unique $\\tau$ such that $\\M\\models\\varphi[\\kappa, \\tau]$.\n}\n\n\\defi{\n  Let $\\kappa$ be an infinite cardinal and $\\F$ an operator on $H_\\kappa$ over $b\\in H_\\kappa$. We then say that $\\F$ is \\textbf{radiant}\\footnote{The terminology is meant to suggest that the operator is preserved when moving in ``any direction'': down to smaller models or up to larger forcing extensions.} if $\\F$ condenses finely and determines itself on generic extensions.\n}\n\n\n\\section{Core model dichotomy}\n\n\\lemm[Mesken-N.][lemm.opit]{\n  Let $\\theta$ be a regular uncountable cardinal or $\\theta=\\infty$ and let $\\N$ be a tame hybrid mouse operator on $H_\\theta$ which relativises well. Then $\\N$ is countably iterable iff it's $(\\theta,\\theta)$-iterable, guided by $\\N$. Furthermore, for every $x\\in H_\\theta$, if $M_1^{\\N}(x)$ exists and is countably iterable, then it's also $(\\theta,\\theta)$-iterable, guided by $\\N$.\n  \\todo[inline]{Change this to model operators; perhaps change parts of the proof and/or assumptions needed.}\n  }\n\\proof{\n  Fix $x\\in H_\\theta$ and assume that $\\N(x)$ is countable iterable. We first show that $\\N(x)$ is $(\\theta,\\theta)$-iterable. Let $\\T\\in H_\\theta$ be a normal tree of limit length on $\\N(x)$. Let $\\eta\\gg\\rk(\\T)$ and let\n  \\eq{\n    \\h:= \\chull^{H_\\eta}(\\{x,\\N(x),\\T\\})\n  }\n    \n  with uncollapse $\\pi\\colon\\h\\to H_\\eta$. Set $\\overline a:=\\pi^{-1}(a)$ for every $a\\in\\ran\\pi$. Note that $\\overline{\\N(x)}=\\N(\\overline x)$ since $\\N$ relativises well. Now $\\overline\\T$ is a normal, countable iteration tree on $\\N(\\overline x)$ and hence our iteration strategy yields a wellfounded cofinal branch $\\overline b\\in V$ for $\\overline\\T$. Note that $\\overline\\Q:=\\Q(\\overline b,\\overline\\T)$ exists, since if $\\overline b$ drops then there's nothing to do, and otherwise we have that \n  \\eq{ \n    \\rho_{1}(\\M^{\\overline\\T}_{\\overline b})=\\rho_{1}(\\N(\\overline x))=\\rk\\overline x<\\delta(\\overline\\T),\n  }\n\n  so $\\delta(\\overline\\T)$ is not definably Woodin over $\\M^{\\overline\\T}_{\\overline b}$, as there is a definable surjection from $\\rho_1(\\M^{\\overline\\T}_{\\overline b})$ onto $\\delta(\\overline\\T)$.\n  \\clai{\n    $\\overline\\Q\\init\\N(\\M(\\overline\\T))$\n  }\n\n  \\cproof{\n    If $\\overline\\Q=\\M(\\overline\\T)$ then the claim is trivial, so assume that $\\M(\\overline\\T)\\pinit\\overline\\Q$. Note that $\\overline\\Q\\init M_{\\overline b}^{\\overline\\T}$ by definition of $\\Q$-structures, and that $M_{\\overline b}^{\\overline\\T}$ satisfies $(2)$ of the definition of relativises well, meaning that\n    \\eq{\n      M_{\\overline b}^{\\overline\\T}\\models\\godel{\\text{$\\forall\\eta\\forall\\zeta>\\eta:$ if $\\eta$ is a cutpoint then $M_{\\overline b}^{\\overline\\T}|\\zeta\\not\\models\\varphi_{\\N}[\\bar x,p_{\\N}]$}}.\\tag*{(1)} \n    }\n\n    This statement is $\\Pi^1_2$ and $\\overline\\Q$ is $\\Pi^1_2$-correct since it contains a Woodin cardinal, so that $\\Q$ satisfies the statement as well. Since $\\N$ is tame we get that $\\delta(\\overline\\T)$ is a cutpoint of $\\overline\\Q$, so that $\\N(\\M(\\overline\\T))=\\N(\\overline\\Q|\\delta(\\overline\\T))$ is \\textit{not} a proper initial segment of $\\overline\\Q$. Further, as we're assuming that both $\\N(\\M(\\overline\\T))$ and $\\M^{\\overline\\T}_{\\overline b}$ are $(\\omega_{1}{+}1)$-iterable above $\\delta(\\overline\\T)$ the same thing holds for $\\overline\\Q\\init\\M_{\\overline b}^{\\overline\\T}$, so that we can compare $\\N(\\M(\\overline\\T))$ with $\\overline\\Q$ (in $V$). Let\n    \\eq{ \n      (\\N(\\M(\\overline\\T)),\\overline\\Q) \\leadsto (\\P,\\R) \n    }\n\n    be the result of the coiteration. We claim that $\\R\\init\\P$. Suppose $\\P\\pinit\\R$. Then there is no drop in $\\N(\\M(\\overline\\T))\\leadsto\\P$ and in fact $\\N(\\M(\\overline\\T))=\\P$ since $\\N(\\M(\\overline\\T))$ projects to $\\delta(\\overline\\T)$. Furthermore, as we established that $\\N(\\M(\\overline\\T))=\\N(\\overline\\Q|\\delta(\\overline\\T))$ isn't a proper initial segment of $\\overline\\Q$ it can't be a proper initial segment of $\\R$ either, as the coiteration is above $\\delta(\\overline\\T)$. But we're assuming that $\\N(\\M(\\overline\\T))=\\P\\pinit\\R$, a contradiction. So $\\R\\init\\P$.\n        \n    \\qquad Since $\\N(\\M(\\overline\\T))$ and $\\overline\\Q$ agree up to $\\delta(\\overline\\T)$ and there is no drop $\\overline\\Q\\leadsto\\R$ we have that $\\overline\\Q=\\R$. If $\\N(\\M(\\overline\\T))\\leadsto\\P$ doesn't move either we're done, so assume not. Let $F$ be the first exit extender of $\\N(\\M(\\overline\\T))$ in the coiteration. We have $\\lh(F) \\le o(\\overline\\Q)$, $\\overline\\Q\\init\\P$ and $\\lh(F)$ is a cardinal in $\\P$.\n        \n    \\qquad As $\\overline\\Q$ is $\\delta(\\overline\\T)$-sound and projects to $\\delta(\\overline\\T)$ it follows that $J(\\overline\\Q|\\lh(F))$ collapses $\\lh(F)$, so it has to be the case that $\\overline\\Q|\\lh(F)=\\P$ and thus $o(\\P)=\\lh(F)$. But this means that $\\P=\\N(\\M(\\overline\\T))$ even though we assumed that $\\N(\\M(\\T))\\leadsto\\P$ moved, a contradiction.\n  }\n\n  Now, in a sufficiently large collapsing extension extension of $\\h$, $\\overline b$ is the unique cofinal, wellfounded branch of $\\overline\\T$ such that $\\Q(\\overline b,\\overline\\T) \\init\\N(\\M(\\overline\\T))$ exists. Hence, by the homogeneity of $\\col(\\omega,\\theta)$, $\\overline b \\in H$. By elementarity there is a unique cofinal, wellfounded branch $b$ of $\\T$ such that $\\Q(b,\\T)\\init\\N(\\M(\\T))$. This proves that $M$ is (uniquely) $\\on$-iterable and virtually the same argument yields the iterability of $M$ via successor-many stacks of normal trees.\n  \n  \\qquad To show that $M$ is fully iterable, it remains to be seen that the unique iteration strategy (guided by $\\N$) of $M$ outlined above leads to wellfounded direct limits for stacks of normal trees on $M$ of limit length. Let $\\lambda$ be a limit ordinal and $\\vec\\T = (\\T_i \\mid i<\\lambda)$ a stack according to our iteration strategy. Suppose $\\lim_{i<\\lambda}\\M^{\\T_i}_\\infty$ is illfounded.\n  \n  \\qquad Redefine $\\eta\\gg\\rk(\\vec\\T)$, $\\h:=\\chull^{H_\\eta}(\\{x,M,\\vec\\T\\})$ and $\\pi:\\h\\to H_\\eta$ the uncollapse, again with $\\overline a:=\\pi^{-1}(a)$ for every $a\\in\\ran\\pi$. By elementarity we get that $\\h\\models\\godel{\\lim_{i<\\overline\\lambda}\\M^{\\overline\\T_i}_\\infty\\text{ is illfounded}}$. But $\\overline{\\vec\\T}$ is countable and according to the iteration strategy guided by $\\N$, so that\n  \\eq{\n  V\\models\\godel{\\lim_{i<\\overline\\lambda}\\M^{\\overline\\T_i}_\\infty\\text{ is wellfounded.}}\n  }\n\n  Now note that $(\\lim_{i<\\overline\\lambda}\\M^{\\overline\\T_i}_\\infty)^{\\h}=(\\lim_{i<\\overline\\lambda}\\M^{\\overline\\T_i}_\\infty)^V$ and wellfoundedness is absolute between $\\h$ and $V$, a contradiction.\n    \n  \\qquad Now assume that $M_1^{\\N}(x)$ exists for some $x\\in H_\\theta$, and that it's countably iterable. We then do exactly the same thing as with $\\N(x)$ \\textit{except} that in the claim we replace $(1)$ with\n  \\eq{\n    \\overline\\Q\\models\\forall\\eta(\\overline\\Q|\\eta\\not\\models\\godel{\\text{$\\delta(\\overline\\T)$ is not Woodin}}),\n  }\n\n  so that if $\\P\\pinit\\R$ then $\\delta(\\overline\\T)$ is still Woodin in $\\P=\\N(\\M(\\overline\\T))$, contradicting the defining property of $M_1^{\\N}(x)$ (and thus also of $\\R$). The rest of the proof is a copy of the above.\n}\n\n\\theo[Hybrid core model dichotomy][theo.kdichotomy]{\n  Let $\\theta$ be a $\\beth$-fixed point or $\\theta=\\infty$, and let $\\F$ be a model operator on $H_\\theta$ that condenses well. Let $x\\in H_\\theta$. Then either:\n  \\begin{enumerate}\n    \\item The core model $K^{\\F}(x)|\\theta$ exists and is $(\\theta,\\theta)$-iterable; or\n    \\item $M_1^{\\F}(x)$ exists and is $(\\theta,\\theta)$-iterable.\n  \\end{enumerate}\n}\n\\proof{\n  Assume first that $K^{c,\\F}(x)|\\theta$ reaches a premouse which isn't $\\F$-small; let $\\N_\\xi$ be the first part of the construction witnessing this. Then $\\core(\\N_\\xi)=M_1^{\\F}(x)$\\todo{Insert argument?}, and by Lemma \\ref{lemm.opit} it suffices to show that $M_1^{\\F}(x)$ is countably iterable.\\todo[inline]{Show that $M_1^{\\F}(x)$ is countably iterable.}\n\n  \\qquad We can thus assume that $K^{c,\\F}(x)|\\theta$ is $\\F$-small. Note that if $K^{c,\\F}(x)|\\theta$ has a Woodin cardinal then because the model is $\\F$-closed we contradict $\\F$-smallness, so the model has no Woodin cardinals either, making it $(\\theta,\\theta)$-iterable.\n    \n  \\qquad Let $\\kappa<\\theta$ be any uncountable cardinal and let $\\Omega:=\\beth_\\kappa(\\kappa)^+$. Note that $\\Omega<\\theta$ since we assumed that $\\theta$ is a $\\beth$-fixed point and $\\kappa<\\theta$. If $\\Omega$ is a limit cardinal in $K^{c,\\F}(x)|\\theta$ then let $\\S:=\\lp(K^{c,\\F}(x)|\\Omega)$ and otherwise let $\\S:=K^{c,\\F}(x)|\\Omega$. Then by Lemma 3.3 of\n  \\cite{mousestack} we get that $\\S$ is countably iterable, with largest cardinal $\\Omega$ in the ``limit cardinal case''.\n    \n  \\qquad This also means that $\\Omega$ isn't Woodin in $L[\\S]$, as it's trivial in the case where $\\Omega$ is a successor cardinal of $K^{c,\\F}(x)|\\theta$ by our case assumption, and in the ``limit cardinal case'' it also holds since \n  \\eq{\n    K^{c,\\F}(x)|\\Omega^{+K^{c,\\F}(x)|\\theta}\\subseteq\\S.  \n  }\n\n  By \\cite{fernandes} and \\cite{JensenSteel} this means that we can build $K^{\\F}(x)|\\kappa$, as the only places they use that there's no inner model with a Woodin are to guarantee that $K^{c,\\F}(x)|\\Omega$ exists and has no Woodin cardinals, and in Lemma 4.27 of \\cite{JensenSteel} in which they only require that $\\Omega$ isn't Woodin in $L[\\S]$.\n    \n  \\qquad As $\\kappa<\\theta$ was arbitrary we then get that $K^{\\F}(x)|\\theta$ exists. Note that $K^{\\F}(x)|\\theta$ has no Woodin cardinals either and is $\\F$-small, so that $\\Q$-structures trivially exist, making it $(\\theta,\\theta)$-iterable.\n}\n\n\n\\section{Mouse witness equivalence}\n\n\\defi{\n  \\todo[inline]{Define coarse $(k,U,x)$-Woodin pairs}\n}\n\n\\defi{\n  Let $\\F$ be a total condensing operator and let $\\alpha$ be an ordinal. Then the \\textbf{coarse mouse witness condition at $\\alpha$ with $\\F$}, written $W^*_\\alpha(\\F)$, states that given any scaled-co-scaled $U\\subset\\mathbb R$ whose associated sequences of prewellorderings are elements of $\\lp^{\\F}_\\alpha(\\mathbb R)$, we have for every $k<\\omega$ and $x\\in\\mathbb R$ a coarse $(k,U,x)$-Woodin pair $(N,\\Sigma)$ with $\\Sigma\\restr\\hc\\in\\lp^{\\F}_\\alpha(\\mathbb R)$.\\todo{Check if this is a reasonable definition.}\n}\n\n\\theo[Hybrid witness equivalence][theo.witness]{\n  Let $\\theta>0$ be a cardinal, $g\\subset\\col(\\omega,{<}\\theta)$ $V$-generic,  $\\mathbb R^g:=\\bigcup_{\\alpha<\\theta}\\mathbb R^{V[g\\restr\\alpha]}$, $\\F$ a total radiant operator and $\\alpha$ a critical ordinal of $\\lp^{\\F}(\\mathbb R^g)$. Assume that\n  \\eq{\n    \\lp^{\\F}(\\mathbb R^g)\\models\\dc+\\godel{W^*_\\beta(\\F)\\text{ holds for all }\\beta\\leq\\alpha}.\n  }\n  \n  Then there is a hybrid mouse operator $\\N\\in V$ on $H_{\\aleph_1^{V[g]}}$ such that\n  \\eq{\n    \\lp^{\\F}(\\mathbb R^g)\\models W^*_{\\alpha+1}(\\F)\\quad\\text{iff}\\quad V\\models\\godel{\\text{$M_n^{\\N}$ is total on $H_{\\aleph_1^{V[g]}}$ for all $n<\\omega$}}\n  }\n\n  Furthermore, if $\\theta<\\aleph_1^V$ then we only need to assume that $\\F$ is total and condensing.\n}\n\n\\todo[inline]{Be more explicit about what the given operator $\\N$ looks like.}\n\n\n\\end{document}\n", "meta": {"hexsha": "72768b3c029c91e1647741594f7a9b182f57ae78", "size": 18870, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/part2/internal-core-model-induction.tex", "max_stars_repo_name": "saattrupdan/phd", "max_stars_repo_head_hexsha": "21481596be517c874e311797f5a70829e0cba7d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/part2/internal-core-model-induction.tex", "max_issues_repo_name": "saattrupdan/phd", "max_issues_repo_head_hexsha": "21481596be517c874e311797f5a70829e0cba7d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/part2/internal-core-model-induction.tex", "max_forks_repo_name": "saattrupdan/phd", "max_forks_repo_head_hexsha": "21481596be517c874e311797f5a70829e0cba7d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.0094339623, "max_line_length": 672, "alphanum_fraction": 0.6784313725, "num_tokens": 6200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4049432421375034}}
{"text": "\\section{Conclusion}\\label{sec:conclusion}\n\nThis work presents a novel approach to investigating a healthcare population\nthat encompasses the topics of segmentation analysis, queuing models, and the\nrecovery of queuing parameters from incomplete data. This is done despite common\nlimitations in operational research with regard to the availability of\nfine-grained data, and this work only uses administrative hospital spell data\nfrom patients presenting COPD from the Cwm Taf Morgannwg UHB.\\\n\nBy considering a variety of attributes present in the data, and engineering\nsome, an effective clustering of the spell population is identified that\nsuccessfully feeds into a multi-class, \\(M/M/c\\) queue to model a hypothetical\nCOPD ward. With this model, a number of insights are gained by investigating\npurposeful changes in the parameters of the model that have the potential to\ninform actual public health policy.\n\nIn particular, since neither the resource capacity of the system or the clinical\nprocesses of the spells are evident in the data, service times and resource\nlevels are not available. However, length of stay is. Using what is available,\nthis work assumes that mean service times can be parameterised using mean\nlengths of stay. By using the Wasserstein distance to compare the distribution\nof the simulated lengths of stay data with the observed data, a best performing\nparameter set is found via a parameter sweep.\n\nThis parameterisation ultimately recovers a surrogate for service times for each\ncluster, and a common number of servers to emulate resource availability. The\nparameterisation itself offers its strengths by being simple and effective.\nDespite its simplicity, a good fit to the observed data is found, and --- as is\nevident from the closing section of this work --- substantial and useful\ninsights can be gained into the needs of the population being studied.\n\nThis analysis, and the formation of the entire model, in effect, considers all\ntypes of patient arrivals and how they each impact the system in terms of\nresource capacity and length of stay. By investigating scenarios into changes in\nboth overall patient arrivals and resource capacity, it is clear that there is\nno quick solution to be employed from within the hospital to improve COPD\npatient spells.  The only effective, non-trivial intervention is to improve the\noverall health of the patients arriving at the hospital. This is shown by moving\npatient arrivals between clusters. In reality, this would correspond to an\nexternal, preventative policy that improves the overall health of COPD patients.\n", "meta": {"hexsha": "e0a96f1da240f3b63456fc2f9c5f8fb318f27fba", "size": 2592, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sections/conclusion.tex", "max_stars_repo_name": "drvinceknight/copd-paper", "max_stars_repo_head_hexsha": "387a14f886d3c562228bb4be45abdd7ed996eda1", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sections/conclusion.tex", "max_issues_repo_name": "drvinceknight/copd-paper", "max_issues_repo_head_hexsha": "387a14f886d3c562228bb4be45abdd7ed996eda1", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-06-28T13:59:15.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T12:15:13.000Z", "max_forks_repo_path": "sections/conclusion.tex", "max_forks_repo_name": "drvinceknight/copd-paper", "max_forks_repo_head_hexsha": "387a14f886d3c562228bb4be45abdd7ed996eda1", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-23T20:29:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T20:29:08.000Z", "avg_line_length": 63.2195121951, "max_line_length": 80, "alphanum_fraction": 0.8194444444, "num_tokens": 512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.40494323526883513}}
{"text": "\\documentclass[11pt,a4paper]{article}\n\\usepackage{algorithm, algorithmic, listings} % Code\n\\usepackage{amsmath,mathtools,amssymb,amsfonts,dsfont,cancel} % Math\n\\usepackage{amstext}\n\\usepackage{color, xcolor} % Color\n\\usepackage{diagbox, tabularx} % Table\n\\usepackage{enumerate} % List\n\\usepackage{epsfig, epstopdf, graphicx, multicol, multirow, palatino, pgfplots, subcaption, tikz} % Image.\n\\usepackage{fancybox}\n\\usepackage{verbatim}\n\n\\usepackage[font=footnotesize]{caption} % labelfont=bf\n\\usepackage[margin=1in]{geometry}\n\\usepackage[hidelinks]{hyperref}\n\\epstopdfsetup{outdir=./Figure/Converted/}\n\\graphicspath{{./Figure/}}\n\n\\makeatletter\n\\def\\input@path{{./Figure/}}\n\\makeatother\n\n% MATLAB code settings\n\\lstset{extendedchars=false, % Shutdown no-ASCII compatible\nbasicstyle=\\normalsize\\tt, % the size of the fonts that are used for the code\nlanguage=Matlab, tabsize=4, numbers=left, numberstyle=\\small, stepnumber=1, numbersep=8pt, keywordstyle=\\color[rgb]{0,0,1}, commentstyle=\\color[rgb]{0.133,0.545,0.133}, stringstyle=\\color[rgb]{0.627,0.126,0.941}, backgroundcolor=\\color{white}, showspaces=false, showstringspaces=false, showtabs=false, frame=single, captionpos=t, breaklines=true, breakatwhitespace=false, morekeywords={break, case, catch, continue, elseif, else, end, for, function, global, if, otherwise, persistent, return, switch, try, while}, title=\\lstname,\nmathescape=true,escapechar=? % escape to latex with ?..?  \nescapeinside={\\%*}{*)}, % if you want to add a comment within your code  \n%morestring=[m]', % strings\n%columns=fixed, % nice spacing\n}\n\n\\begin{document}\n\\title{\\sc\\vspace{3cm}\\hrule\\vspace{0.3cm}{\\LARGE DD2423}\\\\\\vspace{0.1cm}{\\Large Image Analysis and Computer Vision}\\vspace{0.3cm}\\hrule\\vspace{1.5cm}{\\Large Laboratory Report}\\\\{\\large Lab 2: Edge Detection \\& Hough Transform}}\n\\author{Jiang, Sifan\\\\sifanj@kth.se}\n\\maketitle\n\\newpage\n\n\\newcounter{Counter}\n\\setcounter{Counter}{0}\n\n\\section*{1\\hspace{0.5cm}Difference operators}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} What do you expect the results to look like and why? Compare the size of \\texttt{dxtools} with the size of \\texttt{tools}. Why are these sizes different?\n\t\t\t\\par The $x$-wise derivative is expected to be an image with the edge of the original image in the $x$ direction. The $y$-wise derivative is expected to be an image with the edge of the original image in the $y$ direction. The result is shown in Figure \\ref{fig:Question_1}.\n\t\t\t\\begin{figure}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=\\columnwidth]{Question_1.eps}\n\t\t\t\t%\\scalebox{1}{\\input{Question_1.tex}}\n\t\t\t\t\\caption{The first row of images is applied by simple difference operator. The second row is applied by central differences. The third row is applied by Robert's diagonal operator. The last row is applied by the Sobel operator.}\n\t\t\t\t\\label{fig:Question_1}\n\t\t\t\\end{figure}\n\t\t\t\\par The sizes of the derivative images are different from each other or from the original image because of the difference of the kernel sizes in each method. The image size is shown in Table \\ref{tab:Image_Size}. \n\t\t\t\\begin{table}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\caption{Image size.}\n\t\t\t\t\\label{tab:Image_Size}\n\t\t\t\t\\begin{tabular}{ccc}\n\t\t\t\t\t\\hline\n\t\t\t\t\tImage & $x$ direction ($y \\times x$) & $y$ direction ($y \\times x$) \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\tOriginal & $256 \\times 256$ & $256 \\times 256$ \\\\\n\t\t\t\t\tSimple difference operator & $256 \\times 254$ & $254 \\times 256$ \\\\\n\t\t\t\t\tCentral difference operator & $256 \\times 254$ & $254 \\times 256$ \\\\\n\t\t\t\t\tRoberts cross edge operator & $255 \\times 255$ & $255 \\times 255$ \\\\\n\t\t\t\t\tSobel operator & $254 \\times 254$ & $254 \\times 254$ \\\\\n\t\t\t\t\t\\hline\n\t\t\t\t\\end{tabular}\n\t\t\t\\end{table}\n\t\t\t\\par The reason why these sizes are different is because of the difference between the kernel size of each difference operators. If the image is of size $N \\times M$ and in the case of the simple difference operator, the kernel when considering the $x$-direction has size of $1 \\times 3$. Since all the elements in the kernel should be multiplied by a element in the image, the kernel will fit the image $N$ times in the $y$ direction, but $M-2$ times in the $x$ direction.\n\t\\end{itemize}\n\\section*{2\\hspace{0.5cm}Point-wise thresholding of gradient magnitudes}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Tools_Gradient_Magnitude.eps}\n\t\t\\caption{Gradient magnitude of the derivative images for \\texttt{few256}.}\n\t\t\\label{fig:Question_2_Tools_Gradient_Magnitude}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Tools_Hist.eps}\n\t\t\\caption{Histogram of gradient magnitude of the derivative images for \\texttt{few256}.}\n\t\t\\label{fig:Question_2_Tools_Hist}\n\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.85\\columnwidth]{Question_2_Tools_Threshold.eps}\n\t\t\\caption{Gradient magnitude of the derivative images with different threshold for \\texttt{few256}. The threshold in the case of simple difference operator is 27.2. 13.6 for central difference operator. 32.7 for Roberts cross edge operator. 92.7 for Sobel operator.}\n\t\t\\label{fig:Question_2_Tools_Threshold}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Godthem_Gradient_Magnitude.eps}\n\t\t\\caption{Gradient magnitude of the derivative images for \\texttt{godthem256}.}\n\t\t\\label{fig:Question_2_Godthem_Gradient_Magnitude}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Godthem_Hist.eps}\n\t\t\\caption{Histogram of gradient magnitude of the derivative images for \\texttt{godthem256}.}\n\t\t\\label{fig:Question_2_Godthem_Hist}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.85\\columnwidth]{Question_2_Godthem_Threshold.eps}\n\t\t\\caption{Gradient magnitude of the derivative images with different threshold for \\texttt{godthem256}. The threshold in the case of simple difference operator is 29.1. 14.6 for central difference operator. 35.2 for Roberts cross edge operator. 103 for Sobel operator.}\n\t\t\\label{fig:Question_2_Godthem_Threshold}\n\t\\end{figure}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} Is it easy to find a threshold that results in thin edges? Explain why or why not!\n\t\t\t\\par It is not easy to find a threshold that results in thin edges at the most time.\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item Applying a threshold to the whole image where the brightness for all edges are different would obtain thin edges for some objects while other edges could disappear or be too thick.\n\t\t\t\t\\item Different operator would give different result as illustrated in Figure \\ref{fig:Question_2_Tools_Gradient_Magnitude}. So the threshold for each operator should be different.\n\t\t\t\t\\item Noise with big magnitude could also make it hard to find a threshold that results in thin edges.\n\t\t\t\\end{itemize}\n\t\t\t\\par However, in the case of \\texttt{few256}, the histogram, Figure \\ref{fig:Question_2_Tools_Hist}, accumulated to the left border of the histogram pretty well, so we can set the threshold based on the bin edges of the first cluster of the histogram. The threshold in the case of simple difference operator is 27.2. 13.6 for central difference operator. 32.7 for Roberts cross edge operator. 92.7 for Sobel operator.\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Tools_Gaussian_2-25.eps}\n\t\t\t\\caption{Smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ for \\texttt{few256}.}\n\t\t\t\\label{fig:Question_2_Tools_Gaussian_2-25}\n\t\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_Tools_Gaussian_2-25_Hist.eps}\n\t\t\t\\caption{Histogram for smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ for \\texttt{few256}.}\n\t\t\t\\label{fig:Question_2_Tools_Gaussian_2-25_Hist}\n\t\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.85\\columnwidth]{Question_2_Tools_Gaussian_2-25_Threshold.eps}\n\t\t\t\\caption{Smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ and different threshold for \\texttt{few256}. The threshold in the case of simple difference operator is 25.4. 12.7 for central difference operator. 16 for Roberts cross edge operator. 89.9 for Sobel operator.}\n\t\t\t\\label{fig:Question_2_Tools_Gaussian_2-25_Threshold}\n\t\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_House_Gaussian_2-25.eps}\n\t\t\t\\caption{Smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ for \\texttt{godthem256}.}\n\t\t\t\\label{fig:Question_2_House_Gaussian_2-25}\n\t\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_2_House_Gaussian_2-25_Hist.eps}\n\t\t\t\\caption{Histogram for smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ for \\texttt{godthem256}.}\n\t\t\t\\label{fig:Question_2_House_Gaussian_2-25_Hist}\n\t\t\\end{figure}\n\t\t\\begin{figure}[!ht]\n\t\t\t\\centering\n\t\t\t\\includegraphics[width=0.85\\columnwidth]{Question_2_House_Gaussian_2-25_Threshold.eps}\n\t\t\t\\caption{Smoothed gradient magnitude using Gaussian filter with $\\sigma^{2}=2.25$ and different threshold for \\texttt{godthem256}. The threshold in the case of simple difference operator is 23.4. 11.7 for central difference operator. 16 for Roberts cross edge operator. 93.4 for Sobel operator.}\n\t\t\t\\label{fig:Question_2_House_Gaussian_2-25_Threshold}\n\t\t\\end{figure}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} Does smoothing the image help to find edges?\n\t\t\t\\par Yes, smoothing the image helps to find edges. Smoothing would remove noise from the image, thus making the detected ``edges'' are more likely to be real edges.\n\t\t\t\\par However, smoothing the image with Gaussian filter could blur the edges, thus making it difficult to detect the edges with difference operators and find a threshold. This can also be seen from the histograms of the images after smoothing which are more shewed when compared to the gradient magnitude with no Gaussian smoothing.\n\t\\end{itemize}\n\n\\section*{4\\hspace{0.5cm}Computing differential geometry descriptors}\n\t\\par The images after applying Gaussian filter to \\texttt{godthem256} with different value of $\\sigma^{2}$ is illustrated in Figure \\ref{fig:Question_4_House_Gaussian}. The second order derivative of \\texttt{godthem256} after Gaussian smoothing is shown in Figure \\ref{fig:Question_4_House_Second_Order} and the third order derivative is shown in Figure \\ref{fig:Question_4_House_Third_Order}. Also, the third order derivative of \\texttt{few256} after Gaussian smoothing is shown in Figure \\ref{fig:Question_4_Tools_Third_Order}.\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_4_House_Gaussian.eps}\n\t\t%\\scalebox{0.9}{\\input{Question_4_House_Gaussian.tex}}\n\t\t\\caption{Gaussian smoothing for \\texttt{godthem256} with different scale.}\n\t\t\\label{fig:Question_4_House_Gaussian}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_4_House_Second_Order.eps}\n\t\t%\\scalebox{0.9}{\\input{Question_4_House_Second_Order.tex}}\n\t\t\\caption{Second order derivative for \\texttt{godthem256} after Gaussian smoothing.}\n\t\t\\label{fig:Question_4_House_Second_Order}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_4_House_Third_Order.eps}\n\t\t%\\scalebox{0.9}{\\input{Question_4_House_Third_Order.tex}}\n\t\t\\caption{Third order derivative for \\texttt{godthem256} after Gaussian smoothing.}\n\t\t\\label{fig:Question_4_House_Third_Order}\n\t\\end{figure}\n\t\\begin{figure}[!ht]\n\t\t\\centering\n\t\t\\includegraphics[width=0.9\\columnwidth]{Question_4_Tools_Third_Order.eps}\n\t\t%\\scalebox{0.9}{\\input{Question_4_Tools_Third_Order.tex}}\n\t\t\\caption{Third order derivative for \\texttt{few256} after Gaussian smoothing.}\n\t\t\\label{fig:Question_4_Tools_Third_Order}\n\t\\end{figure}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} What can you observe? Provide explanation based on the generated images.\n\t\t\t\\par From Figure \\ref{fig:Question_4_House_Gaussian}, we can observe that, the larger the scale is (which means the larger the variance of the Gaussian white noise is), the more blurry and the less noisy the image becomes. This is also true when comes to the result of the edge detection. \n\t\t\t\\par However, higher variance of Gaussian filter also blurs the edges and making it harder to determine the real position of the edges. Also, from Figure \\ref{fig:Question_4_House_Second_Order}, \\ref{fig:Question_4_House_Third_Order}, and \\ref{fig:Question_4_Tools_Third_Order}, we can see that Gaussian filter with higher variance would make the edges seem to be thickened thus losing the accuracy.\n\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} Assemble the results of the experiment above into an illustrative collage with the \\texttt{subplot} command. Which are your observations and conclusions?\n\t\t\t\\par As stated at the beginning of this section, the images are shown in Figure \\ref{fig:Question_4_House_Gaussian}, \\ref{fig:Question_4_House_Second_Order}, \\ref{fig:Question_4_House_Third_Order}, and \\ref{fig:Question_4_Tools_Third_Order}, where the conclusion could be extracted: the bigger the variance of the Gaussian filter applied to the image is, the less noise will appear in the high order derivative while the less accurate the edges are found.\n\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} How can you use the response from $\\widetilde{L}_{vv}$ to detect edges, and how can you improve the result by using $\\widetilde{L}_{vvv}$?\n\t\t\t\\par The local maximum and local minimum of the gradient magnitude would be reached when $\\widetilde{L}_{vv}=0$, however, if we want to find edges more accurately, we only want the local maximum be reserved. So when $(\\widetilde{L}_{vv}=0 \\cap \\widetilde{L}_{vvv}<0)$, the local maximum would be reached. Based on such idea, we can improve the response from $\\widetilde{L}_{vv}$ by combining the result of $\\widetilde{L}_{vv}$ and $\\widetilde{L}_{vvv}$ above. The combining result is shown in Figure \\ref{fig:Question_6_House_Lvv_Lvvv} and \\ref{fig:Question_6_Tools_Lvv_Lvvv}.\n\t\t\t\\begin{figure}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_6_House_Lvv_Lvvv.eps}\n\t\t\t\t%\\scalebox{0.9}{\\input{Question_6_House_Lvv_Lvvv.tex}}\n\t\t\t\t\\caption{Combination of $\\widetilde{L}_{vv}=0$ and $\\widetilde{L}_{vvv}<0$ of \\texttt{godthem256}.}\n\t\t\t\t\\label{fig:Question_6_House_Lvv_Lvvv}\n\t\t\t\\end{figure}\n\t\t\t\\begin{figure}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_6_Tools_Lvv_Lvvv.eps}\n\t\t\t\t%\\scalebox{0.9}{\\input{Question_6_House_Lvv_Lvvv.tex}}\n\t\t\t\t\\caption{Combination of $\\widetilde{L}_{vv}=0$ and $\\widetilde{L}_{vvv}<0$ of \\texttt{few256}.}\n\t\t\t\t\\label{fig:Question_6_Tools_Lvv_Lvvv}\n\t\t\t\\end{figure}\n\t\\end{itemize}\n\n\\section*{5\\hspace{0.5cm}Extraction of edge segments}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} Present your best results obtained with \\texttt{extractedge} for \\texttt{house} and \\texttt{tools}.\n\t\t\t\\par The best results obtained for \\texttt{house} and \\texttt{tools} are shown in Figure \\ref{fig:Question_7_House_Overlay_Curves} and \\ref{fig:Question_7_Tools_Overlay_Curves} respectively. The \\texttt{godthem256} is applied by Gaussian smoothing with variance $\\sigma^{2}=4$ and threshold $4$. The \\texttt{few256} is applied by Gaussian smoothing with variance $\\sigma^{2}=4$ and threshold $6$.\n\t\t\t\\begin{figure}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_7_House_Overlay_Curves.eps}\n\t\t\t\t%\\scalebox{0.9}{\\input{Question_6_House_Lvv_Lvvv.tex}}\n\t\t\t\t\\caption{Best result for \\texttt{godthem256}.}\n\t\t\t\t\\label{fig:Question_7_House_Overlay_Curves}\n\t\t\t\\end{figure}\n\t\t\t\\begin{figure}[!ht]\n\t\t\t\t\\centering\n\t\t\t\t\\includegraphics[width=0.9\\columnwidth]{Question_7_Tools_Overlay_Curves.eps}\n\t\t\t\t%\\scalebox{0.9}{\\input{Question_6_House_Lvv_Lvvv.tex}}\n\t\t\t\t\\caption{Best result for \\texttt{few256}.}\n\t\t\t\t\\label{fig:Question_7_Tools_Overlay_Curves}\n\t\t\t\\end{figure}\n\t\\end{itemize}\n\n\\section*{6\\hspace{0.5cm}Hough transform}\n\\subsection*{6.1\\hspace{0.5cm}Hints and practical advice}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{????? Question \\arabic{Counter}:} Identify the correspondences between the strongest peaks in the accumulator and line segments in the output image. Doing so convince yourself that the implementation is correct. Summarize the results in one or more figures.\n\t\t\t\\par The strongest peaks in the accumulator should be the longest and the most obvious line segments in the edge plot.\n\t\t\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{Question \\arabic{Counter}:} How do the results and computational time depend on the number of cells in the accumulator?\n\t\t\t\\par The accuracy of the results depends on the resolution of the accumulator since the larger of \\texttt{ntheta} and \\texttt{nrho}, the more accurate the points and curves would be presented in the accumulator thus the intersection points would be easier to find its real position in accumulator thus finding accurate line in spatial domain. However, high resolution could also lead to more local maximum, thus giving multiple lines for a single edge we would like to obtain from the image.\n\t\t\t\\par When the resolution is higher, it would take much more computational time. The time complexity could be $O(n^{2})$, where $n$ is the resolution in $x$ or $y$ direction. \n\t\\end{itemize}\n\n\\subsection*{6.2\\hspace{0.5cm}Choice of accumulator incrementation function}\n\t\\begin{itemize}\n\t\t\\item\\addtocounter{Counter}{1}\\textbf{????? Question \\arabic{Counter}:} How do you propose to do this? Try out a function that you would suggest and see if it improves the results. Does it?\n\t\t\t\\par I would like to try some monotonically increasing function like $\\log$ or square root functions. The increasing rate of such functions becomes smaller when the magnitude becomes larger.\n\t\\end{itemize}\n\n% Template\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\begin{figure}[H]\n%\t\\centering\n%\t\\scalebox{0.9}{\\input{test.tex}}\n%\t\\caption{Test.}\n%\t\\label{fig:Test}\n%\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\begin{figure}[!ht]\n%\t\\footnotesize\n%\t\\centering \n%\t\\begin{subfigure}[t]{.32\\linewidth} % .32 for three polts .49 for two plots\n%\t\\includegraphics[width=\\columnwidth]{Linearity_F.eps}\n%\t\\caption{Image F}\n%\t\\label{fig:F}\n%\t\\end{subfigure}\n%\t\\begin{subfigure}[t]{.32\\linewidth} % .32 for three polts\n%\t\\includegraphics[width=\\columnwidth]{Linearity_G.eps}\n%\t\\caption{Image G = F'}\n%\t\\label{fig:G}\n%\t\\end{subfigure}\n%\t\\begin{subfigure}[t]{.32\\linewidth} % .32 for three polts\n%\t\\includegraphics[width=\\columnwidth]{Linearity_H.eps}\n%\t\\caption{Image H = F + 2 * G}\n%\t\\label{fig:H}\n%\t\\end{subfigure}\n%\t\\caption{Origin images.}\n%\t\\label{fig:origin}\n%\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\begin{align*}\n%\tvar_{t = 0.1} &= \\begin{bmatrix} 0.0133 & 0.0000 \\\\ 0.0000 & 0.0133 \\end{bmatrix} \\\\\n%\tvar_{t = 0.3} &= \\begin{bmatrix} 0.2811 & 0.0000 \\\\ 0.0000 & 0.2811 \\end{bmatrix} \\\\\n%\tvar_{t = 1.0} &= \\begin{bmatrix} 1.0000 & 0.0000 \\\\ 0.0000 & 1.0000 \\end{bmatrix} \\\\\n%\tvar_{t = 10.0} &= \\begin{bmatrix} 10.0000 & 0.0000 \\\\ 0.0000 & 10.0000 \\end{bmatrix} \\\\\n%\tvar_{t = 100.0} &= \\begin{bmatrix} 100.0000 & 0.0000 \\\\ 0.0000 & 10.0000 \\end{bmatrix}\n%\\end{align*}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% \\lstinputlisting{x.m}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{document}", "meta": {"hexsha": "a91e161ddf4d9ab1fc60509bc115e6bdcb697ebd", "size": 19632, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lab2/Lab_2_Report.tex", "max_stars_repo_name": "JasperRice/DD2423", "max_stars_repo_head_hexsha": "1a47ff056576aea61c2960c813115b1b03f242c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-17T03:09:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T03:09:13.000Z", "max_issues_repo_path": "Lab2/Lab_2_Report.tex", "max_issues_repo_name": "JasperRice/DD2423", "max_issues_repo_head_hexsha": "1a47ff056576aea61c2960c813115b1b03f242c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lab2/Lab_2_Report.tex", "max_forks_repo_name": "JasperRice/DD2423", "max_forks_repo_head_hexsha": "1a47ff056576aea61c2960c813115b1b03f242c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.2328767123, "max_line_length": 579, "alphanum_fraction": 0.7510187449, "num_tokens": 5964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.40494323509704455}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% fphw Assignment\n% LaTeX Template\n% Version 1.0 (27/04/2019)\n%\n% This template originates from:\n% https://www.LaTeXTemplates.com\n%\n% Authors:\n% Class by Felipe Portales-Oliva (f.portales.oliva@gmail.com) with template \n% content and modifications by Vel (vel@LaTeXTemplates.com)\n%\n% Template (this file) License:\n% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)\n%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n%----------------------------------------------------------------------------------------\n%    PACKAGES AND OTHER DOCUMENT CONFIGURATIONS\n%----------------------------------------------------------------------------------------\n\n\\documentclass[\n    12pt, % Default font size, values between 10pt-12pt are allowed\n    %letterpaper, % Uncomment for US letter paper size\n    %spanish, % Uncomment for Spanish\n]{fphw}\n\n% Template-specific packages\n\\usepackage[utf8]{inputenc} % Required for inputting international characters\n\\usepackage[T1]{fontenc} % Output font encoding for international characters\n\\usepackage{fontspec,unicode-math} % Required for using utf8 characters in math mode\n\\usepackage{parskip}  % To add extra space between paragraphs\n% \\usepackage{mathpazo} % Use the Palatino font\n\\usepackage{graphicx} % Required for including images\n\\usepackage{booktabs} % Better horizontal rules in tables\n\\usepackage{hyperref} % For links (both internal and external)\n% \\usepackage{listings} % Required for insertion of code\n\\usepackage{enumerate}% To modify the enumerate environment\n\\usepackage{cleveref} % Better \\ref command -> \\cref\n\\usepackage{import}   % This 4 packages and the command allow importing pdf\n\\usepackage{xifthen}  % figures generated with inkscape\n\\usepackage{pdfpages} % Source: https://castel.dev/post/lecture-notes-2/\n\\usepackage{mathtools}\n\\usepackage{wrapfig}\n\\usepackage{cancel}\n\\usepackage{transparent}\n\\newcommand{\\incfig}[1]{%\n    \\def\\svgwidth{0.95\\columnwidth}\n    \\small\n        \\import{./images/}{#1.pdf_tex}\n}\n\n\\setlength{\\parindent}{15pt}\n\\setlength{\\headheight}{22.66pt}\n\n%----------------------------------------------------------------------------------------\n%    ASSIGNMENT INFORMATION\n%----------------------------------------------------------------------------------------\n\n\\title{Task 3 \\\\ Convenient Coordinates} % Assignment title\n\n\\author{Emilio Domínguez Sánchez} % Student name\n\n\\date{March 16th, 2021} % Due date\n\n\\institute{University of Murcia \\\\ Faculty of Mathematics} % Institute or school name\n\n\\class{Geometría Global de Superficies} % Course or class name\n\n\\professor{Dr. Luis J. Alías Linares} % Professor or teacher in charge of the assignment\n\n%----------------------------------------------------------------------------------------\n%    Definitions\n%----------------------------------------------------------------------------------------\n\n\\usepackage{physics}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\inner}[2]{\\left\\langle #1, \\; #2 \\right\\rangle}\n\n\\DeclareDocumentCommand\\covariantderivative{ s o m g d() }\n{ % Covariant derivative\n\t% s: star for \\flatfrac flat covariant derivative\n\t% o: optional n for nth covariant derivative\n\t% m: mandatory (x in Df/dx)\n\t% g: optional (f in Df/dx)\n\t% d: long-form D/dx(...)\n\t\\IfBooleanTF{#1}\n\t{\\let\\fractype\\flatfrac}\n\t{\\let\\fractype\\frac}\n\t\\IfNoValueTF{#4}\n\t{\n\t\t\\IfNoValueTF{#5}\n\t\t{\\fractype{D \\IfNoValueTF{#2}{}{^{#2}}}{\\diffd #3\\IfNoValueTF{#2}{}{^{#2}}}}\n\t\t{\\fractype{D \\IfNoValueTF{#2}{}{^{#2}}}{\\diffd #3\\IfNoValueTF{#2}{}{^{#2}}} \\argopen(#5\\argclose)}\n\t}\n\t{\\fractype{D \\IfNoValueTF{#2}{}{^{#2}} #3}{\\diffd #4\\IfNoValueTF{#2}{}{^{#2}}}}\n}\n\\DeclareDocumentCommand\\cdv{}{\\covariantderivative} % Shorthand for \\covariantderivative\n\n\\begin{document}\n\n\\maketitle % Output the assignment title, created automatically using the information in the custom commands above\n\n%----------------------------------------------------------------------------------------\n%    ASSIGNMENT CONTENT\n%----------------------------------------------------------------------------------------\n\n\\section*{Problem}\n\n\\begin{problem}\n    Let $p \\in S$ be a point of a regular surface $S$\n    and $\\qty{e_1, e_2}$ an orthonormal basis of $T_pS$.\n    Consider $X(u, v) = \\exp_p(ue_1 + ve_2)$,\n    a normal coordinate system centered in $p$\n    that is defined over a neighbourhood $U$ of $(0, 0) \\in \\R^2$.\n    Prove that the following statements are true.\n\n    \\begin{enumerate}\n        \\item For any $v = ae_1 + be_2 \\in T_pS$, $v \\ne 0$,\n        the coordinate expression of the maximal geodesic $γ_v(t)$ is\n        $(u(t), v(t)) = (at, bt)$.\n\n        \\item The Christoffel symbols $\\qty{Γ_{ij}^k : 1 \\le i,j,k \\le 3}$\n        and the partial derivatives of $E$, $F$ and $G$ are zero in $(0, 0)$.\n    \\end{enumerate}\n\\end{problem}\n\n%----------------------------------------------------------------------------------------\n\n\\subsection*{Answer}\n\n    By the homogenity of geodesics and the definition of the exponential function,\n$γ_v(t) = γ_{tv}(1) = \\exp_p(tv) = \\exp_p(tae_1 + tbe_2)$.\nBecause $X$ has to be inyective,\n$(u(t), v(t)) = t(a, b)$ is the coordinates expression of $γ_v$.\nThanks to this simple expression,\nthe differential equation for a geodesic\\footnote{\n    For simplicity,\n    we have omitted the point of evaluation $(u, v)$ of the Christoffel symbols.\n},\n\\begin{equation*}\n    \\begin{cases}\n        u'' + (u')^2Γ^1_{11} + 2u'v'Γ^1_{12} + (v')^2Γ^1_{22} = 0 \\\\\n        v'' + (u')^2Γ^2_{11} + 2u'v'Γ^2_{12} + (v')^2Γ^2_{22} = 0\n    \\end{cases},\n\\end{equation*}\nbecomes\n\\begin{equation*}\n    \\begin{cases}\n        a^2Γ^1_{11} + 2abΓ^1_{12} + b^2Γ^1_{22} = 0 \\\\\n        a^2Γ^2_{11} + 2abΓ^2_{12} + b^2Γ^2_{22} = 0\n    \\end{cases}.\n\\end{equation*}\nGiven that $v$ is arbitrary and that\n$X(0, 0) = p = γ_v(0)$ is a point common to any $γ_v$,\nwe can conclude that all the Christoffel symbols are $0$ in $(0, 0)$.\nThat is,\nsubstituting with $v = e_1$ gives $Γ^1_{11}(0, 0), Γ^2_{11}(0, 0) = 0$,\nsubstituting with $v = e_2$ gives $Γ^1_{22}(0, 0), Γ^2_{22}(0, 0) = 0$,\nand knowing that,\nsubstituting with $v = e_1 + e_2$ gives $Γ^1_{12}(0, 0), Γ^2_{12}(0, 0) = 0$.\nUltimately, writing\n\\begin{equation*}\n    \\mqty(\n        \\frac{E_u}{2} & \\frac{E_v}{2} & F_v - \\frac{G_u}{2} \\\\\n        F_u - \\frac{E_v}{2} & \\frac{G_u}{2} & \\frac{G_v}{2}\n    ) =\n    \\mqty(E & F \\\\ F & G)\n    \\mqty(Γ^1_{11} & Γ^1_{12} & Γ^1_{22} \\\\ Γ^2_{11} & Γ^2_{12} & Γ^2_{22}) = 0,\n\\end{equation*}\nwe can conclude that the partials of $E$, $F$ and $G$ are $0$ in $(0, 0)$ as well.\n\n%----------------------------------------------------------------------------------------\n\n\\end{document}\n", "meta": {"hexsha": "08e50a05cd00966dd541b231fd630a0f0ae9d8f2", "size": 6622, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "convenient_coordinates.tex", "max_stars_repo_name": "useredsa/exercises-surfaces-geometry", "max_stars_repo_head_hexsha": "19b17a0a4c729e3a99f51ea285ae1539352c742b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-25T03:04:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-25T03:04:15.000Z", "max_issues_repo_path": "convenient_coordinates.tex", "max_issues_repo_name": "useredsa/introductory-exercises-of-differential-geometry", "max_issues_repo_head_hexsha": "19b17a0a4c729e3a99f51ea285ae1539352c742b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "convenient_coordinates.tex", "max_forks_repo_name": "useredsa/introductory-exercises-of-differential-geometry", "max_forks_repo_head_hexsha": "19b17a0a4c729e3a99f51ea285ae1539352c742b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.625, "max_line_length": 114, "alphanum_fraction": 0.5687103594, "num_tokens": 2045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.40492074170310116}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{Infinite Offset Paradox with \\texttt{tikz}}\n\\author{Leonard Kleinhans}\n\\date{January 2017}\n\\usepackage[a4paper, left=2cm, right=2cm, top=3cm]{geometry}\n\n\\usepackage{tikz}\n\\usepackage{ifthen}\n\\usepackage{float}\n\n\\usetikzlibrary{decorations.pathreplacing}\n\n\\newcommand{\\infiniteoffsetparadox}[3]{\n   \\begin{tikzpicture}[darkstyle/.style={circle,draw,fill=gray!40,minimum size=20}]\n% number of rectangles\n\\def \\count {#1}\n% print fraction for the first \\print rectangles \n\\def \\print {#2}\n% color overlap for first \\overlap rectangles\n\\def \\overlap {#3}\n% rectangle width\n\\def \\a {4} \n% rectangle height\n\\def \\b {1} \n% rectangle start offset in grid \n\\def \\s {1}\n% offset of nth rectangle\n\\def \\o {0}\n\\pgfmathsetmacro{\\c}{\\count-1}\n\\pgfmathsetmacro{\\overlap}{\\overlap-1}\n\\pgfmathsetmacro{\\ocolor}{0}\n% calculate offset for coloring\n\\foreach \\cy in {0,...,\\overlap} {\n    \\pgfmathsetmacro{\\oocolor}{\\ocolor+((2*(\\cy+1))^(-1)*\\a)}\n    \\global\\let\\ocolor=\\oocolor\n}\n\\foreach \\y in {0,...,\\c} {\n    \\draw\n        (\\s+\\o,    \\s-\\y*\\b) rectangle\n        (\\s+\\a+\\o, \\s-\\b-\\y*\\b);\n    % calculate new offset\n    \\pgfmathsetmacro{\\oo}{\\o+((2*(\\y+1))^(-1)*\\a)}    \n    \\pgfmathsetmacro{\\f}{2*\\y+2}\n    % print fraction with curly brace\n    \\ifthenelse{\\y<\\print}{\n    \\draw [decorate, line width=.5pt, decoration={brace, mirror}] (\\s+\\o, \\s-\\y*\\b-1.1*\\b) --  (0.99*\\s+0.99*\\oo, \\s-\\y*\\b-1.1*\\b) node [midway, below=3pt]\n    {\\footnotesize$\\frac{1}{\\pgfmathprintnumber\\f}$};\n    };{};\n    \n    % add color\n    \\ifthenelse{\\NOT{\\y>\\overlap}}{\n        \\pgfmathsetmacro{\\rectend}{min(\\s+\\ocolor,\\s+\\o+\\a)}\n        % for overlap\n        \\fill [overlapcolor] (\\s+\\o,    \\s-\\y*\\b) rectangle (\\rectend, \\s-\\b-\\y*\\b);\n        % for setoff\n        \\fill [setoffcolor] (\\rectend,    \\s-\\y*\\b) rectangle (\\s+\\o+\\a, \\s-\\b-\\y*\\b);\n    };{};\n    % update offset\n    \\global\\let\\o=\\oo\n}\n\n\\end{tikzpicture}\n}\n\n\n\\begin{document}\n\n\n\\maketitle\n\n\\section{Introduction}\nThis document contains a fully customizable function that generates illustrations of the Infinite Offset Paradox. The figures are generated using \\texttt{tikz}. The provided command \\texttt{infiniteoffsetparadox} takes three arguments, that is first the number of rectangles to draw, the number of labels to generate and the number of rectangles that get colored regarding overlap and offset. The next section provides example outputs.\n\n\\section{Examples}\n% define color\n\\definecolor{overlapcolor}{HTML}{801A15}\n\\definecolor{setoffcolor}{HTML}{537614}\n\n\\begin{figure}[H]\n    \\centering\n    \\infiniteoffsetparadox{3}{2}{2}\n    \\caption{Illustration of the Infinite Offset Paradox with parameters $(3,2,2)$}\n\\end{figure}\n\n% use different colors for second figure\n\\definecolor{overlapcolor}{HTML}{A5CA00}\n\\definecolor{setoffcolor}{HTML}{085286}\n\n\\begin{figure}[H]\n    \\centering\n    \\infiniteoffsetparadox{5}{1}{4}\n    \\caption{Illustration of the Infinite Offset Paradox with parameters $(5,1,4)$}\n\\end{figure}\n\\end{document}", "meta": {"hexsha": "681ff6b0b5f5bf9e8dc316d4232c36d7d3fb212f", "size": 3018, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "main.tex", "max_stars_repo_name": "leo-labs/InfiniteOffsetParadoxTikz", "max_stars_repo_head_hexsha": "18a7d1f6a185a822e756ef780ee7bbe7ff9861cd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.tex", "max_issues_repo_name": "leo-labs/InfiniteOffsetParadoxTikz", "max_issues_repo_head_hexsha": "18a7d1f6a185a822e756ef780ee7bbe7ff9861cd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.tex", "max_forks_repo_name": "leo-labs/InfiniteOffsetParadoxTikz", "max_forks_repo_head_hexsha": "18a7d1f6a185a822e756ef780ee7bbe7ff9861cd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4375, "max_line_length": 435, "alphanum_fraction": 0.6749502982, "num_tokens": 996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.4048936378738108}}
{"text": "\\section{PI for the man in the road}\n\\subsection{}\n\n\\begin{frame}\n\\frametitleTC{Foreword}\n\\framesubtitleTC{PI (Proportional plus Integral) control as an intuitive idea}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item We now introduce PI control in a totally intuitive manner, ie., the way\\\\\n       ``the man in the road'' would do --- and incidentally, the way somebody\\\\\n       says it was initially invented (we are not discussing this).\n \\item The purpose of this part of our activity is twofold:\n       \\begin{itemize}[<+-| alert@+>]\n       \\item show that PI control is intuitive indeed,\n       \\item but also that intuition without theory is often misleading.    \n       \\end{itemize}\n \\item Exercise: as we proceed, try to spot the flaws (not necessarily true ``errors''\\\\\n       but symptoms of a partial viewpoint) in the reasoning by the man\\\\\n       in the road and take note of them...\n \\item[] \\vspace{-0.75mm}...and then, when we re-visit the matter formally later on, check\\\\\n       your notes to see if you spotted \\underline{all} such flaws.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Intuition \\# 1}\n\\framesubtitleTC{Proportional control}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The man in the road says: \\blue{``the farther the controlled variable $y$ is\\\\\n       from the reference $w$, the more intense the control action $u$ has to be''}.\n \\item \\vfill Naming $e$ the error $w-y$, this introduces the \\TC{Proportional (P) action}\n       \\begin{displaymath}\n        u_P(k) = K_P \\, e(k),\n       \\end{displaymath}\n       where $K_P$ is a configuration parameter.\n \\item Seems definitely a good idea.\n \\item However $u_P$ is nonzero only if so is $e$, hence with P action alone\n       \\begin{itemize}[<+-| alert@+>]\n       \\item either $y$ can stay at ANY value ($w$ can be anything) with $u=0$,\n       \\item or one has to accept an error to have a control action.    \n       \\end{itemize} \n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Intuition \\# 2}\n\\framesubtitleTC{Introducing an automatic bias}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item Alternatively, a bias can be included in $u$ so as to zero the error:\n       \\begin{displaymath}\n        u(k) = u_P(k)+ u_{bias}.\n       \\end{displaymath}\n \\item But how to compute $u_{bias}$?\n \\item The man in the road says: \\blue{``automatically; if the error is zero keep it constant\\\\\n       because you found the right value, otherwise increase or decrease it at each step,\\\\\n       proportionally to the error''}.    \n \\item This means\n       \\begin{displaymath}\n        u_{bias}(k) = u_{bias}(k-1)+ K_{bias} e(k),\n       \\end{displaymath}\n       where $K_{bias}$ is another configuration parameter.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{Intuition \\# 3}\n\\framesubtitleTC{Toward integral control}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The main in the road continues: \\blue{``the automatic bias is also consistent with the\\\\\n       idea that if the error does not diminish this means that the system is reluctant\\\\\n       to obey to the control action, hence the said action has to become stronger\\\\\n       and stronger''}. \n \\item In fact, $u_{bias}(k)$ as just defined, sums each new error weighed by $K_{bias}$, which comes\n       to determine the ratio of the control variation \\TC{rate} to the value of the error.\n \\item We can say that this is \\TC{integrating} the error, and name the corresponding control component\n       the \\TC{Integral (I) action}\n       \\begin{displaymath}\n        u_I(k) = u_I(k-1)+ K_I e(k),\n       \\end{displaymath}\n        with $K_I$ as the second controller configuration parameter besides $K_P$.\n \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n\\frametitleTC{The PI control law}\n\\framesubtitleTC{}\n\\myPause\n \\begin{itemize}[<+-| alert@+>]\n \\item The control signal is the sum of the P and the I action:\n       \\begin{displaymath}\n        \\left\\{\\begin{array}{rcl}\n         u_P(k) &=& K_P \\, e(k) \\\\\n         u_I(k) &=& u_I(k-1)+ K_I e(k) \\\\\n         u(k)   &=& u_P(k)+u_I(k)\n        \\end{array}\\right.\n       \\end{displaymath}\n \\item \\vfill Intuition basically stops here.\n \\item To understand how to give a value to $K_P$ and $K_I$ (or to the more\\\\\n       comfortable equivalent parameters we shall define in the following)\\\\\n       we must resort to theory.\n \\end{itemize}\n\\end{frame}\n", "meta": {"hexsha": "62e2e7acc61cf642e94c9c559a269b4346099f34", "size": 4347, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/Unit-05/sections/05-PS02-PI4MIR.tex", "max_stars_repo_name": "albertoleva/PID4CSE", "max_stars_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-19T16:38:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-19T16:38:10.000Z", "max_issues_repo_path": "slides/Unit-05/sections/05-PS02-PI4MIR.tex", "max_issues_repo_name": "albertoleva/PID4CSE", "max_issues_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/Unit-05/sections/05-PS02-PI4MIR.tex", "max_forks_repo_name": "albertoleva/PID4CSE", "max_forks_repo_head_hexsha": "66ec14c204e16c97a5792c2e240b2daed4b39e83", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0094339623, "max_line_length": 103, "alphanum_fraction": 0.6641361859, "num_tokens": 1242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.4048936378738108}}
{"text": "\\documentclass[epsfig,10pt,fullpage]{article}\n\n\\newcommand{\\LabNum}{3}\n\\newcommand{\\CommonDocsPath}{../../common/docs}\n\\input{\\CommonDocsPath/preamble.tex}\n\n\\begin{document}\n\n\\centerline{\\huge OpenCL}\n~\\\\\n\\centerline{\\huge Laboratory Exercise \\LabNum}\n~\\\\\n\\centerline{\\large Lane Detection for Autonomous Driving}\n~\\\\\n\nThis exercise introduces you to the Hough transform and how it can be used for detecting lanes in an autonomous driving application. \nThe exercise uses the Canny edge detector that you implemented in Exercise 2.\n\n\n\\section*{Lane Detection Using Line Detection}\n\nLane detection is a technique that uses a vehicle's sensor data to\ndetermine the vehicle's position relative to the lanes and/or road boundaries. \nThe position information is used to make steering adjustments and to change lanes, which\nmakes lane detection a fundamental part of an autonomous vehicle.\n\n~\\\\\nThere are many different lane detection schemes that make use a variety of different sensor combinations.\nIn this exercise, we will implement a simple scheme that uses a camera attached to the front of the vehicle. \nSince lane and road boundaries tend to appear as lines in the camera feed, we will accomplish lane detection\nby detecting the lines in the image. \nOnce we have the positions and angles of the lines, we can use our knowledge of the perspective of the camera \nto infer the vehicle's position relative to the lane boundaries.\nTo detect the lines, we will employ edge detection and a technique called the {Hough transform}.\nFigures~\\ref{fig:road},~\\ref{fig:road_edges}, and~\\ref{fig:road_lines} show the application of edge detection\nfollowed by the Hough transform to detect lines in an image.\n\n\n~\\\\\n\\begin{figure}[h]\n\\centering\n\\begin{minipage}[b]{0.32\\textwidth}\n\t\\includegraphics[width=\\textwidth]{figures/fig_road.png}\n\t\\caption{Original image.}\n\t\\label{fig:road}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[b]{0.32\\textwidth}\n\t\\includegraphics[width=\\textwidth]{figures/fig_road_edges.png}\n\t\\caption{Edge-detected image.}\n\t\\label{fig:road_edges}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[b]{0.32\\textwidth}\n\t\\includegraphics[width=\\textwidth]{figures/fig_road_lines.png}\n\t\\caption{Line-detected image.}\n\t\\label{fig:road_lines}\n\\end{minipage}\n\\end{figure}\n\n\n\n\n\\section*{The Hesse Normal Representation for Lines}\n\nBefore starting our discussion of line detection, we must first consider the system we will use to describe lines in an image.\nFor efficiency, we want to describe a line using the fewest parameters possible. \nA commonly used line representation is $y = mx + b$ which describes lines using two parameters \\textit{m} and \\textit{b}.\nThe problem with this system is that it cannot describe vertical lines as m would assume an undefined value.\nThe line representation that we will use is known as the Hesse normal form. This system uses\ntwo parameters ($\\rho$, $\\theta$) to describe a line \\textbf{A} as follows:\n\n\\begin{enumerate}\n\\item $\\rho$ is the distance from the origin (the center of the image) to the closest point on A.\n\\item $\\theta$ is the angle between the x axis and the normal line connecting the origin to the closest point on A.\n\\end{enumerate}\n\nTo account for all possible lines in an image, the parameters range: $0 \\leq \\theta < 180^\\circ$ and \n\n$-\\sqrt(image\\_height^2+image\\_width^2)/2 \\leq \\rho \\leq \\sqrt(image\\_height^2+image\\_width^2)/2$\n\nExamples of lines and their ($\\rho$, $\\theta$) parameters are shown in Figure~\\ref{fig:hesse_normal_examples}.\nThe line being described is displayed in red, and the normal line is displayed in magenta. \nTake note that $\\rho$ can be a negative value which extends the normal line in the reverse direction from the angle\ndenoted by $\\theta$, as shown in Examples 2, 3, and 4. The line shown in Example 3 is\nparameterized as $(-7, 0^\\circ)$ and not $(7, 180^\\circ)$, due to the valid range of theta: $0 \\leq \\theta < 180^\\circ$.\nFor the same reason, the line in Example 4 is parameterized as $(-7, 90^\\circ)$ and not $(7, 270^\\circ)$.\n\n\\begin{figure}[H]\n   \\begin{center}\n       \\includegraphics[scale = 0.78]{figures/fig_hesse_normal_examples}\n   \\end{center}\n   \\caption{Lines (in red) and their ($\\rho$, $\\theta$) parameters.}\n\t\\label{fig:hesse_normal_examples}\n\\end{figure}\n\nLines described in ($\\rho$, $\\theta$) form can be mapped to pixels in (x,y) coordinates and vice-versa using the equation $\\rho = x*cos(\\theta) + y*sin(\\theta)$. \nNote that a pixel can lie on an infinite number of lines, as there are the infinite $\\theta$ values from $0^\\circ$ to $180^\\circ$.\nFigure~\\ref{fig:pixel_to_lines} shows a pixel at (x,y) coordinate (8,5) and some of the lines that it is positioned upon.\n\n\\begin{figure}[H]\n   \\begin{center}\n       \\includegraphics[scale = 0.95]{figures/fig_pixel_to_lines}\n   \\end{center}\n   \\caption{A pixel in an image can lie on an infinite number of lines, including the four lines shown.}\n\t\\label{fig:pixel_to_lines}\n\\end{figure}\n\n\n\\pagebreak\n\n\\section*{The Hough Transform}\n\nThe Hough transform takes an edge-detected input image and transforms it to a 2-dimensional integer array called \nthe accumulator.\nThe two dimensions of the accumulator are indexed by $\\rho$ and $\\theta$ respectively,\nand each element stores how many edge pixels in the input image\nare positioned along the corresponding line ($\\rho$, $\\theta$). \n%Effectively, the accumulator values measure the length of each line that is present in the input image. \nThe most prominent lines in the input image can then be inferred by finding the lines with the \nhighest values in the accumulator.\nThe process by which the Hough transform calculates the values in the accumulator is described below.\n\n~\\\\\nThe accumulator elements are first initialized to zero, then \\textit{accumulate} in value as the Hough transform\nalgorithm sweeps across the pixels of the input image. \nEach edge pixel encountered by the algorithm contributes +1 to the accumulator values\nof all lines on which it is positioned. \nSince there are theoretically an infinite number of such lines, we must select a resolution for $\\rho$ and $\\theta$ to\nlimit the number of lines being tracked by the algorithm.\n\n\\begin{figure}[H]\n   \\begin{center}\n       \\includegraphics[scale = 0.83]{figures/fig_line_20x14}\n   \\end{center}\n   \\caption{Applying the Hough transform ($\\theta$ resolution = $45^\\circ$) on a 20x14 image with five edge pixels.}\n\t\\label{fig:hough_demonstration}\n\\end{figure}\n\nAs a demonstration, let us choose a $\\theta$ resolution of $45^\\circ$ and a $\\rho$ resolution of 1 pixel to \ntransform a 20x14 image. This requires an accumulator array, \\texttt{accum[RHOS][THETAS]}, with dimensions \nRHOS = 24, and THETAS = 4. Integer values of $\\rho$ range $-12 \\leq \\rho < 12$, \nand $\\theta$ values range $0^\\circ, 45^\\circ, 90^\\circ,$ and $135^\\circ$. \nFigure~\\ref{fig:hough_demonstration} shows the operations involved in \ntransforming a 20x14 edge-detected image with five edge pixels in the top-right corner. \nThe five pixels form the line $(8, 45^\\circ)$, which is shown as the bold red line.\nEach pixel contributes +1 to the four accumulator indices corresponding to the four possible $\\theta$ values.\nThe $\\rho$ index corresponding to each $\\theta$ is calculated using the formula $\\rho = x*cos(\\theta) + y*sin(\\theta)$.\nAfter the Hough transform completes, the accumulator is as shown in Figure~\\ref{fig:accumulator}. As\nexpected, \\texttt{accum[8][45$^\\circ$]} has the highest value of 5, since there were five pixels along it in the input image.\n\n\n\\begin{figure}[H]\n   \\begin{center}\n       \\includegraphics[scale = 0.8]{figures/fig_accumulator}\n   \\end{center}\n   \\caption{The accumulator resulting from the Hough transform of the image in Figure~\\ref{fig:hough_demonstration}.}\n\t\\label{fig:accumulator}\n\\end{figure}\n\n\n\\subsection*{Extracting Lines from Local Maxima in the Accumulator}\n\n\nUpon completion of the Hough transform we are left with the task of extracting prominent lines from the accumulator.\nThe simplest method for extracting the N most prominent lines from the accumulator is to \nfind the N highest values (global maxima). However, this approach is prone to issues which we will discuss below.\n\n~\\\\\nA source of error when using the Hough transform for line detection is the potential for  \nthe pixels of a single \"real\" line in an image contributing to multiple adjacent elements in \nthe accumulator. This could happen if the line was not perfectly straight due to noise, or if \nour resolution for $\\rho$ or $\\theta$ was inadequate. For example, consider transforming an image with the line \n(11,$7.5^\\circ$) using a $\\theta$ resolution of $1^\\circ$. During the transform some of the pixels in the line may\ncontribute to \\texttt{accum[11][7]} while others may contribute to \\texttt{accum[11][8]} resulting in\nmultiple nearby accumulator elements with similarly high values.\nAfter the transform if we simply searched for the global maxima to detect lines,\nwe could falsely detect two or more lines resulting from the single real line.\n\n~\\\\\nTo eliminate false duplicates, we will extract lines from local maxima in the accumulator rather than global maxima.\nWhenever there are multiple high accumulator values in a vicinity we will only consider the one whose \nvalue is highest, and eliminate those neighboring. This approach allows us to detect the single line which is likely the best\nfit to the real line in the input image. \nFigures~\\ref{fig:global_maxima} and \\ref{fig:local_maxima} illustrate the differences between global maxima and\nlocal maxima extraction. Note that this approach runs the risk of elliminating lines that actually did exist near eachother\nin the input image, but for the purposes of lane detection we can assume lane markings are sufficiently spaced apart for\nthis to not be an issue.\n\n~\\\\\nSearching for local minima also allows us to search for a fewer lines in total while cover all of the lanes in the image. \nConsider an image with two lane markings where one was significantly longer than the other. In this case,\nthe longer lane may yield multiple accumulator values that are greater than any of the values\nfor the shorter lane. If we then searched for two global maxima with the expectation of detecting the two lanes, \nwe would detect the longer lane twice and the shorter lane not at all. Searching for local maxima means that we would\nonly extract one line corresponding to the longer lane, allowing for the detection of the second lane as long as it was the\nsecond highest local maximum in the accumulator.\n\n\n\\begin{figure}[h]\n\\centering\n\\begin{minipage}[b]{0.47\\textwidth}\n\t\\includegraphics[width=\\textwidth]{figures/fig_road_lines_global_maxima.png}\n\t\\caption{Lines extracted from global maxima.}\n\t\\label{fig:global_maxima}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[b]{0.47\\textwidth}\n\t\\includegraphics[width=\\textwidth]{figures/fig_road_lines_local_maxima.png}\n\t\\caption{Lines extracted from local maxima.}\n\t\\label{fig:local_maxima}\n\\end{minipage}\n\\end{figure}\n\n\\subsection*{Elliminating the Horizon and Horizontal Lines}\n\nTo improve the accuracy of our lane detector, we will make two simple optimizations to the Hough transform and\nline extraction.\n\n~\\\\\nThe first optimization aims to prevent detecting lines from objects far in the horizon (such as those detected from hills or clouds). Figure~\\ref{fig:local_maxima} shows an example where the upper portion of the image contains the horizon and\nthe sky. When implementing the Hough transform we will elliminate the horizon by \nonly going through the bottom half of the edge-detected image when incrementing the accumulator.\n%limiting the Y coordinate range of pixels that we sweep through the pixels of the input image during the Hough transform.\nNot only will this optimization potentially prevent false lines, it will reduce the runtime of the Hough transform by\nskipping over half of the input pixels.\n\n~\\\\\nThe second optimization elliminates horizontal lines from being extracted from the accumulator. \nThis optimization is based on the knowledge that lanes boundaries \nwill tend to point outward from the camera's perspective (from the bottom of the image towards the top), \nmeaning that vertical and slanted lines are the ones likely to correspond to lanes. \nFigure~\\ref{fig:bus} shows a scenario where this optimization is particularly beneficial, as the merging bus contains features\nthat would result in prominent horizontal lines being detected. \nWe can implement this optimization in our line extraction stage by ignoring the lines in the accumulator whose $\\theta$\nindicates a horizontal line ($80^\\circ < \\theta < 100^\\circ$). \n\n\\begin{figure}[H]\n   \\begin{center}\n       \\includegraphics[scale = 0.3]{figures/fig_bus}\n   \\end{center}\n   \\caption{A merging bus contains prominent horizontal lines that may be detected instead of the lane markings.}\n\t\\label{fig:bus}\n\\end{figure}\n\n\n\\section*{Part 1}\n\nWrite a C-language program to implement the Hough transform. \nStart with the skeleton code provided in \\textit{/design\\_files/part1/hough.c}. \nYour program should load a 720x540 BMP image, apply edge detection, apply the Hough transform, extract the lines, \noverlay the lines onto the original image, then save the resulting image as a BMP file. \n\n~\\\\\nYour Hough transform should use a $\\theta$ resolution of $1^\\circ$ and a $\\rho$ resolution of 2 pixels. \nEllminate the horizon and horizontal lines using the optimizations described in the previous section.\nExtract five lines from the five highest local maxima in the accumulator. \nA value is considered the local maximum if it is the highest value in the 5x5 square around it (+/- 2 to the $\\rho$ and $\\theta$ indices). \nOverlay the extracted lines onto the original image (as shown in Figure~\\ref{fig:local_maxima}), then save it as a BMP file. \nUse the images provided in \\textit{/design\\_files/test\\_images/} to test your program.\nHow closely do the detected lines align to the lane boundaries? For images\nwhere lane detection was less successful, explain potential source(s) of error.\n\n~\\\\\nRecord the runtime of the Hough transform across the test images.\nWhy does the Hough transform runtime vary by image?\nUsing the average total runtime across the images, calculate framerate at which you processed them.\nThe total runtime includes edge detection, Hough transform, and line extraction, but not operations\ninvolved with loading and saving the BMP images.\nDetermine the upper bound on the runtime of the Hough transform and calculate the minimum framerate.\n\n\n\\section*{Part 2}\n\nCreate an OpenCL kernel for the Hough transform. Start with the\nthe skeleton code provided in \\textit{/design\\_files/part2/}. \nUse the same parameters as in Part 1.\nTo improve performance, use local memory to hold the accumulator array and unroll critical loop(s).\nInstantiate your edge detection kernel from Exercise 2 to compile a single \\textit{.aocx} image that \ncontains both the edge detector and the hough transform.\n\n~\\\\\nSkeleton host code is provided in \\textit{/design\\_files/part2/host/}. You must add to the code so that\nthe host program first calls the edge detection kernel, waits for it to complete, then feeds the edge detected data\nbuffer to the hough transform kernel. As in Part 1, your host program should extract five lines from the five \nhighest local maxima in the accumulator, overlay them onto the original image, and save it as a BMP file.\n\n~\\\\\nRecord the runtime of the Hough transform across the test images. How does the runtime compare to your\nimplementation in Part 1? Using the average total runtime across the images, calculate framerate at which you processed them.\nDetermine the upper bound on the runtime of the Hough transform and calculate the minimum framerate.\n\n~\\\\\nWhen implementing the Hough transform kernel, you can use the pragma \\texttt{\\#pragma ivdep}\nto tell the OpenCL compiler that accesses to \\texttt{accum} in subsequent loop iterations are free of data dependencies for\nbetter pipelining of the circuit.\nThe OpenCL compiler would otherwise have difficulty in determining the lack of dependency, as subsequent indices calculated by\nthe formula $\\rho = x*cos(\\theta) + y*sin(\\theta)$ are seemingly unpredictable.\nWe as designers however, know that the formula will ensure subsequent accesses to \\texttt{accum} will be at different indices,\nas we sweep $\\theta$ from $0^\\circ$ to $179^\\circ$ for each edge pixel.\n\n\\section*{Part 3}\n\nImprove the performance of your design from Part 2 by using OpenCL pipes to connect the output of your edge-detection kernel \nto the input of your Hough transform kernel. Doing this allows your kernels to share data completely inside the FPGA,\nrather than using slow external memory as intermediary storage. Use a blocking pipe with a depth of 1.\nCompile your piped kernels using the \\texttt{aoc} flag \\texttt{-profile=all} to enable profiling.\nMake the necessary modifications to your host program to support your newly piped kernels. \n\n~\\\\\nAfter running your application, use the profile monitor to check for kernel stalls.\nDo your kernels stall as a result of the blocking pipe? What do the stalls (or lack of stalls)\nindicate about the throughput of your edge detection kernel compared to your Hough transform kernel?\n\n~\\\\\nRecord the runtime of your piped implemention across the test images. How does the runtime compare to your\nimplementation in Part 2? Using the average total runtime across the images, calculate framerate at which you processed them.\nDetermine the upper bound on the runtime of the Hough transform and calculate the minimum framerate.\n\n\n\\input{\\CommonDocsPath/copyright.tex}\n\\end{document}\n", "meta": {"hexsha": "c45c6fda9849f181e3bacde7124d299962e0b03a", "size": 17600, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lab3/doc/opencl_lab3.tex", "max_stars_repo_name": "fpgacademy/Lab_Exercises_OpenCL", "max_stars_repo_head_hexsha": "923005e0f727cfd922d3904ad21a47faa86c7a51", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab3/doc/opencl_lab3.tex", "max_issues_repo_name": "fpgacademy/Lab_Exercises_OpenCL", "max_issues_repo_head_hexsha": "923005e0f727cfd922d3904ad21a47faa86c7a51", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab3/doc/opencl_lab3.tex", "max_forks_repo_name": "fpgacademy/Lab_Exercises_OpenCL", "max_forks_repo_head_hexsha": "923005e0f727cfd922d3904ad21a47faa86c7a51", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.4891640867, "max_line_length": 242, "alphanum_fraction": 0.7777840909, "num_tokens": 4208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290806, "lm_q2_score": 0.8031738034238807, "lm_q1q2_score": 0.4047242355526043}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{mathtools}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\degrees}{^{\\circ}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 104, HW10}\n\\maketitle\n\\newpage\n\n\\section{Q1: Ross 33.7}\n\\subsection{a}\nLet $P$ be an arbitrary partition such that $P=\\{a=t_1 < t_2 < ... < t_n = b\\}$. Now consider\n$$U(f^2,P) - L(f^2,P) = (M[t_1,t_2]-m[t_1,t_2])(t_2-t_1) + ... + (M[t_{n-1},t_n]-m[t_{n-1},t_n])(t_{n}-t_{n-1})$$\n\nSince RHS and LHS has the same partition $P$, each $t_k$ is also the same on the RHS. We consider just $P_1=[t_1, t_2]$:\n\\newline\nLet the $M(f^2,P_1)=f(x_0)^2, m(f^2,P_1)=f(x_1)^2$\n$$U(f^2,P_1) - L(f^2,P_1) = (f(x_0)^2-f(x_1)^2)(t_2-t_1) = (f(x_0)+f(x_1))(f(x_0)-f(x_1))(t_2-t_1)$$\nNow consider the same partition for $f$:\n$$U(f,P_1) - L(f,P_1) =(M(f,P_1)-m(f,P_1))(t_2-t_1)$$\nSince $B \\geq f(x)$ for all $x \\in [a,b]$, we have $2B \\geq (f(x_0)+f(x_1))$. Since $M(f,P_1)$ is the maximum of the function over this interval and $m(f,P_1)$ is the minimum, their difference is greater than any other differences in this interval $P_1$, namely $M(f,P_1)-m(f,P_1) \\geq (f(x_0)-f(x_1))$.\n\\newline\nTherefore we have $U(f^2,P_1) - L(f^2,P_1) \\leq 2B(U(f,P_1) - L(f,P_1))$. Now we can repeat this with all intervals of $[t_k, t_k-1]$ where $2 \\leq k \\leq n$, thus we have shown that $$U(f^2,P) - L(f^2,P) \\leq 2B(U(f,P) - L(f,P))$$ for any partition $P$\n\n\\subsection{b}\nSince $f$ is integrable, for any $\\epsilon > 0$, there exists a partition $P$ such that $U(f,P)-L(f,P)<\\epsilon$. Now for any $\\epsilon > 0$, choose $\\epsilon_0 = \\epsilon \\times 4B$ where $B$ is the absolute bound for $f$, since $f$ is integrable we find $P_0$ that the difference between the Darboux sums is less than $\\epsilon_0$\n\\newline\nNow consider $U(f^2,P_0)-L(f^2,P_0)$, from part(a) we know that $U(f^2,P_0)-L(f^2,P_0) \\leq 2B(U(f,P_0)-L(f,P_0)) \\leq \\frac{\\epsilon}{2}<\\epsilon$\n\\newline\nTherefore $f^2$ is integrable.\n\n\\section{Q1, Ross 33.8}\nBy our theorem we know that the sum(difference) of two integrable functions is integrable. Therefore we know that $(f+g)$ and $(f-g)$ are integrable. By 33.7 we know that $(f+g)^2$, $(f-g)^2$ are integrable. Now we simply take the difference: $(f+g)^2-(f-g)^2 = 4fg$. We apply the integrability theorem again and we know that this is integrable as well. Thus $fg$ must be integrable.\n\\newpage\n\n\\section{Q2}\n\\subsection{a}\nThe function is continuous at decreasing intervals as $|x|$ decreases, it is also continuous at $x=0$. Since $-1 \\leq \\text{sgn}(x) \\leq 1$, $-x \\leq f(x)\\leq x$ therefore the function converges to $0$ at $x=0$ by squeeze theorem.\n\\newline\nNow for any other point, the continuity breaks when $\\sin \\frac{1}{x}$ is 0 since the whole expression which was not 0 before suddenly \"drops\" or \"rises\" to 0. More rigorously, if $\\sin \\frac{1}{x} \\not = 0$, then sgn$(x)=1$ or $-1$, then $f(x)=x$ or $-x$, which does not have the value $0$ unless $x=0$. Therefore the function is discontinuous at all points where $\\sin(\\frac{1}{x})=0$, or $\\frac{1}{x} = n \\pi$ where $n$ is an integer.\nSince it is continuous everywhere else, we have that the function is continuous on $[-1,-\\frac{1}{\\pi}), (-\\frac{1}{\\pi},-\\frac{1}{2\\pi})... (\\frac{1}{2\\pi},\\frac{1}{\\pi}), (\\frac{1}{\\pi},1]$\n\n\\subsection{b}\nEven though $f$ is not piecewise continuous on all of $[-1,1]$, the discontinuities increase near 0. We claim that it is piecewise continuous on $[-1,0)$ and $(0,1]$. Let $a_n$ be the sequence of postive discontinuous points: $a_n = \\frac{1}{n\\pi}$, and let $b_n=-a_n$. Since $0<a_n < 1/n$ we know that it converges to $0$, by similar logic so does $b_n$.\nLet $0<x_0\\leq 1$, we know that between each $a_n$ the function is either $x$ or $-x$ which is uniformly continuous. Moreover, we know that since $a_n \\to 0$, there is $n \\in \\N$ such that $a_n < x_0$. Let $n_0$ be the smallest such $n$. Let the first partition be $[x_0, a_{n_0-1}]$, and the last $[a_1,1]$.\nThe same is true if $-1 \\leq x_1 < 0$, let $n_1$ be the smallest $n \\in \\N$ such that $a_{n} > x_1$. We define our first partiton as $[-1,a_1]$, and the last $[a_{n},x_1]$, between each closed interval the function is uniformly continuous.\n\\newline\nNow for any $\\epsilon > 0$, choose $u = \\sqrt{\\epsilon}/4, v = - u$. As we have shown above the function is integrable in $[-1,v]$ and $[u,1]$. Therefore we only need to consider the interval $[v,u]$. In this interval the greatest value $f$ can take is $u$ when $\\text{sgn}(\\sin(\\frac{1}{x}))=1$ and $f(x)=x$\nSimilarly the least value it can take is $v$ when $f(x)=-x$\n$$U(f,[v,u]) = u(u-v)$$\n$$L(f, [v,u]) = v(u-v)$$\nThus $U(f,[v,u])-L(f, [v,u]) = (u-v)^2 = \\frac{\\epsilon}{16} < \\epsilon$. Therefore the function is integrable.\n\\newpage\n\n\n\\section{Ross 34.2}\n\\subsection{a}\nWe first assumes that the function $e^{t^2}$ is the derivative of a function $F(t)$, so by the Fundamental Theorem of Calculus, we simplify the expression into $\\lim_{x \\to 0} \\frac{F(x)-F(0)}{x}$.\nSince the denominator approaches 0, we apply L'Hospital's rule and the limit is equal to $\\lim_{x \\to 0} \\frac{F'(x)-F'(0)}{1} = \\frac{e^{x^2}(x')-e^0(0')}{1} = 1$\n\\newline\nIn the last step, we needed to apply the chain rule and take the derivative of the function inputs, ending with $1-0=1$\n\n\\subsection{b}\nWe first assumes that the function $e^{t^2}$ is the derivative of a function $F(t)$, so by the Fundamental Theorem of Calculus, we simplify the expression into $\\lim_{x \\to 0} \\frac{F(3+h)-F(3)}{h}$.\nSince the denominator approaches 0, we apply L'Hospital's rule and the limit is equal to $\\lim_{x \\to 0} \\frac{F'(3+h)-F'(3)}{1} = \\frac{e^{(3+h)^2}(3+h)'-e^3(0')}{1} = e^9$\n\\newpage\n\n\n\\section{Q4}\n\\subsection{a}\nFor $x < 0$, $F(x)=0$ since $f(x)=0$\n\\newline\nFor $0 \\leq x \\leq 1$, $F(x)=\\frac{1}{2}x^2$ since we have proven the power rule and $\\frac{1}{x}x^2$ has a derivative of\n$x$.\n\\newline\nFor $x > 1$, $F(x) = \\frac{1}{2} + 4(x-1)$. The one half comes from $F(1)-F(0)$, and since the function is constant, the upper and lower Darboux sums will be the same for any partition.\n\n\\subsection{b}\n$F$ is continuous everywhere. In the intervals $x<0, 0<x<1, x>1$ we know $F$ is continuous since their functions are continuous. At $x=0$, let $\\epsilon_0 > 0$, pick $\\delta_0 = \\sqrt{\\epsilon_0}$\nLet $|x-0|<\\delta$, then if $x<0$, $|F(x)-F(0)|=0$, otherwise $|F(x)-F(0)| < \\epsilon_0/2-0 < \\epsilon$, therefore $F$ is continuous at 0\n\\newline\nAt $x=1$, let $\\epsilon_1 > 0$, pick $\\delta_1 = \\sqrt{\\epsilon_0}$. If $x>1$\n\n\\subsection{c}\n$F$ is differentiable at $(-\\infty, 1)$. $F'(x)$ for $x < 0$ is $0$ since it is constant. $F'(x)$ on $[0,1]$ is $x$ and since $F'(x)=0$ on both negative and positive sides of $x=0$, therefore $F$ is differentiable at $0$\n\\newline\nFor $x>1$, $F'(x)= 4$. Therefore it is also differentiable at $(1, \\infty)$. It is not differentiable at $1$ since on the negative side it is $1$, but on the positive it is $4$\n\\newpage\n\n\n\\section{Ross 34.5}\nFor each $x \\in \\R$, limit both $F,f$ to $[x-1,x+2]$. Since $f$ is continuous on this interval and $F$ is its integral, $F$ is differentiable at $x$ by the Fundamental Theorem of Calculus.\n\\newline\nSince the upper bound of the integral computed in $F$ has an upper bound of $x+1$, by the same theorem we know that it is equal to $f(x+1)$ .\n\\newpage\n\n\n\\section{Ross 34.7}\nLet $J$ be the interval $(-\\infty, \\infty)$, $u:J \\to \\R $ is defined as $u=x^2$ and $u' = 2x$, and $f: \\R \\to \\R$, $f = -\\frac{2}{3}(1-a)^{3/2}$, by the power rule $f' = \\sqrt{1-a}$. Now since $U(J) \\subseteq \\R$, we can apply u-subsitution here.\n\\newline\nLet the integral equal $I$, we know that $2I = \\int_0^1 2x \\sqrt{1-x^2} dx= \\int_0^1 u'(f'\\circ u) = \\int_{u(0)}^{u(1)}f' = f(1)-f(0) = \\frac{2}{3}$\n\\newline\nNow we have $2I = \\frac{2}{3}$, so our original integral $I = \\frac{1}{3}$\n\\newpage\n\n\\section{Ross 34.12}\nAssume that there exists some $f$ where it is not $0$ everywhere that satisfies this integrala. Since $g$ is an arbitrary continuous function and $f$ is continuous, let $g=f$. Now our integral becomes $\\int_a^b f^2(x)dx = 0$\nNow since $f^2(x) \\geq 0$, we know that $f^2(x) = 0$ everywhere in our interval.\n\\newline\nTo see that it is true, we let $f^2(x_0) > 0$, then by continuity there exists $\\delta > 0$ such that $|f^2(x)-f^2(x_0)|< f^2(x_0)/2$, then in this interval the integral is at least $\\delta f^2(x_0)/2$, thus the whole integral must be greater than or equal to it. Since the expression is positive, there is no way for the integral to be 0. Thus $x_0$ does not exist and $f^2(x)=0$ in our interval.\n\\newline\nFrom our conclusion above it is simple to see that $f(x)=0$ everywhere for $f^2(x)=0$, therefore we have reached a contradiction, and $f(x)=0$ for all $x \\in [a,b]$\n\\end{document}\n", "meta": {"hexsha": "98771992285dc45b4465a491e393f4178b6ce00c", "size": 9343, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hw10/main.tex", "max_stars_repo_name": "TianshuangQiu/Math104-Homework", "max_stars_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hw10/main.tex", "max_issues_repo_name": "TianshuangQiu/Math104-Homework", "max_issues_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hw10/main.tex", "max_forks_repo_name": "TianshuangQiu/Math104-Homework", "max_forks_repo_head_hexsha": "87625a461e62db12905cb91bb9a7116af145ef8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.723880597, "max_line_length": 437, "alphanum_fraction": 0.6637054479, "num_tokens": 3459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.8031738034238806, "lm_q1q2_score": 0.4047242355526041}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Random variables}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Random variables}\n\n\\begin{itemize}\n\n\\item A \\hl{random variable} is a numeric quantity whose value depends on the outcome of a random event\n\\begin{itemize}\n\\item We use a capital letter, like $X$, to denote a random variable\n\\item The values of a random variable are denoted with a lowercase letter, in this case $x$\n\\item For example, $P(X = x)$\n\\end{itemize}\n\n\\item There are two types of random variables:\n\\begin{itemize}\n\\item \\hl{Discrete random variables} often take only integer values\n\\begin{itemize}\n\\item Example: Number of credit hours, Difference in number of credit hours this term vs last\n\\end{itemize}\n\\item \\hl{Continuous random variables} take real (decimal) values\n\\begin{itemize}\n\\item Example: Cost of books this term, Difference in cost of books this term vs last\n\\end{itemize}\n\\end{itemize}\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Expectation}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Expectation}\n\n\\begin{itemize}\n\n\\item We are often interested in the average outcome of a random variable.\n\n\\item We call this the \\hl{expected value} (mean), and it is a weighted average of the possible outcomes\n\\formula{\\[\\mu = E(X) = \\sum_{i = 1}^k x_i ~ P(X = x_i)\\]}\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Expected value of a discrete random variable}\n\n\\dq{In a game of cards you win \\$1 if you draw a heart, \\$5 if you draw an ace (including the ace of hearts), \\$10 if you draw the king of spades and nothing for any other card you draw. Write the probability model for your winnings, and calculate your expected winning.}\n\n\\pause\n\n\\begin{center}\n\\renewcommand{\\arraystretch}{1.5}\n\\begin{tabular}{l | c | c | c }\nEvent\t\t& $X$ \t\t& $P(X)$        \t\t& $X ~ P(X)$ \\\\\n\\hline\nHeart (not ace)\t& $1$\t\t& $\\frac{12}{52}$\t& $\\frac{12}{52}$ \\\\\nAce\t\t\t& $5$\t\t& $\\frac{4}{52}$\t& $\\frac{20}{52}$ \\\\\t\nKing of spades\t& $10$\t\t& $\\frac{1}{52}$\t& $\\frac{10}{52}$ \\\\\t\nAll else\t\t& $0$\t\t& $\\frac{35}{52}$\t& $0$ \\\\\n\\hline\nTotal\t\t\t&\t\t\t&\t\t\t\t& $E(X) = \\frac{42}{52} \\approx 0.81$\n\\end{tabular}\n\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Expected value of a discrete random variable (cont.)}\n\nBelow is a visual representation of the probability distribution of winnings from this game:\n\n\\begin{center}\n\\includegraphics[width=0.8\\textwidth]{3-4_random_variables/figures/card_game/card_game}\n\\end{center}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Variability in random variables}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Variability}\n\nWe are also often interested in the variability in the values of a random variable.\n\n\\formula{\n\\[ \\sigma^2 = Var(X) = \\sum_{i = 1}^k (x_i - E(X))^2 P(X = x_i) \\]\n\\[ \\sigma = SD(X) = \\sqrt{Var(X)} \\]\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Variability of a discrete random variable}\n\n\\dq{For the previous card game example, how much would you expect the winnings to vary from game to game?}\n\n\\vspace{2mm}\n\\only<2->{\n{\\footnotesize\n\\begin{center}\n\\renewcommand{\\arraystretch}{2}\n\\begin{tabular}{c | c | c | l | p{4cm}}\n$X$ & $P(X)$         & $X ~ P(X)$      & \\multicolumn{1}{c|}{$(X - E(X))^2$}  & \\multicolumn{1}{c}{$P(X) ~ (X - E(X))^2$}  \\\\\n\\hline\n1 & $\\frac{12}{52}$  & $1 \\times \\frac{12}{52} = \\frac{12}{52}$ & $(1 - 0.81)^2 = 0.0361$ &  $\\frac{12}{52} \\times 0.0361 = 0.0083$ \\\\\n\\hline\n5 & $\\frac{4}{52}$   & $5 \\times \\frac{4}{52} = \\frac{20}{52}$ & $(5 - 0.81)^2 = 17.5561$  & $\\frac{4}{52} \\times 17.5561 = 1.3505$ \\\\\n\\hline\n10  & $\\frac{1}{52}$ & $10 \\times \\frac{1}{52} = \\frac{10}{52}$  & $(10 - 0.81)^2 = 84.4561$   & $\\frac{1}{52} \\times 84.0889 = 1.6242$ \\\\\n\\hline\n0 & $\\frac{35}{52}$  & $0 \\times \\frac{35}{52} = 0$  & $(0 - 0.81)^2 = 0.6561$ & $\\frac{35}{52} \\times 0.6561 = 0.4416$ \\\\\n\\hline\n  &       & $E(X) = 0.81$ & & \\soln{\\only<3->{$V(X) = 3.4246$}} \\\\\n &       &                                                         & & \\soln{\\only<4>{$SD(X) = \\sqrt{3.4246} = 1.85$}} \\\\\n\\end{tabular}\n\\end{center}\n}\n}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Linear combinations of random variables}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Linear combinations}\n\n\\begin{itemize}\n\n\\item A \\hl{linear combination} of random variables $X$ and $Y$ is given by\n\n\\[ aX + bY \\]\n\nwhere $a$ and $b$ are some fixed numbers.\n\n\\pause\n\n\\item The average value of a linear combination of random variables is given by\n\\formula{\\[ E(aX + bY) = a \\times E(X) + b \\times E(Y) \\]}\n\n\\end{itemize}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Calculating the expectation of a linear combination}\n\n\\dq{On average you take 10 minutes for each statistics homework problem and 15 minutes for each chemistry homework problem. This week you have 5 statistics and 4 chemistry homework problems assigned. What is the total time you expect to spend on statistics and chemistry homework for the week?}\n\n\\soln{\n\\pause\n\\begin{align*} \nE(S + S + S + S + S + C + C + C + C) &= 5 \\times E(S) + 4 \\times E(C) \\\\\n&= 5 \\times 10 + 4 \\times 15 \\\\\n&= 50 + 60 \\\\\n&= 110~min \n\\end{align*}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Variability in linear combinations of random variables}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Linear combinations}\n\n\\begin{itemize}\n\n\\item The variability of a linear combination of two independent random variables is calculated as\n\\formula{\\[ V(aX + bY) = a^2 \\times V(X) + b^2 \\times V(Y) \\]}\n\n\\pause \n\n\\item The standard deviation of the linear combination is the square root of the variance.\n\n\\end{itemize}\n\n\\pause \n\\vfill\n\n\\Note{If the random variables are not independent, the variance calculation gets a little more complicated and is beyond the scope of this course.}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Calculating the variance of a linear combination}\n\n\\dq{The standard deviation of the time you take for each statistics homework problem is 1.5 minutes, and it is 2 minutes for each chemistry problem. What is the standard deviation of the time you expect to spend on statistics and physics homework for the week if you have 5 statistics and 4 chemistry homework problems assigned? Suppose that the time it takes to complete each problem is independent of another.}\n\n\\soln{\n\\pause\n\\begin{align*} \nV(S + S + S + S + S + C + C + C + C) &= V(S) + V(S) + V(S) + V(S) + V(S) + V(C) + V(C) + V(C) + V(C) \\\\\n&= 5 \\times V(S) + 4 \\times V(C) \\\\\n&= 5 \\times 1.5^2 + 4 \\times 2^2 \\\\\n&= 27.25\n\\end{align*}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Recap}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Practice}\n\n\\pq{A casino game costs \\$5 to play. If the first card you draw is red, then you get to draw a second card (without replacement). If the second card is the ace of clubs, you win \\$500. If not, you don't win anything, i.e. lose your \\$5. What is your expected profits/losses from playing this game? {\\small Remember: profit/loss = winnings - cost.}}\n\n\\begin{multicols}{2}\n\\begin{enumerate}[(a)]\n\\item A profit of 5\\textcent\n\\solnMult{A loss of 10\\textcent}\n\\item A loss of 25\\textcent\n\\item A loss of 30\\textcent\n\\end{enumerate}\n\\end{multicols}\n\n\\soln{\n\\only<2>{\n{\\small\n\\renewcommand\\arraystretch{1.25}\n\\begin{tabular}{l c c c r}\nEvent\t\t\t\t& Win\t& Profit: $X$\t& $P(X)$\t& $ X \\times P(X)$\t\\\\\n\\hline\n\\orange{Red}, {A}{$\\clubsuit$}\t\t& 500\t\t& 500 - 5 = 495\t& $\\frac{26}{52} \\times \\frac{1}{51} = \t0.0098$ & \t $495 \\times 0.0098 = 4.851$ \\\\\nOther\t& 0 \t\t\t& 0 - 5 = -5\t& $1 - 0.0098 = 0.9902$ & $-5 \\times 0.9902 = -4.951$ \\\\  \n\\hline\n\t\t\t\t\t&\t\t\t&\t\t\t& \t\t\t& $E(X) = -0.1$\n\\end{tabular}\n}\n}\n}\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Fair game}\n\nA \\hl{fair} game is defined as a game that costs as much as its expected payout, i.e. expected profit is 0.\n\n\\pause\n\n$\\:$\n\n\\dq{Do you think casino games in Vegas cost more or less than their expected payouts?}\n\n\\soln{\n\\pause\n\\begin{columns}[c]\n\\column{0.6\\textwidth}\nIf those games cost less than their expected payouts, it would mean that the casinos would be losing money on average, and hence they wouldn't be able to pay for all this:\n\\column{0.4\\textwidth}\n\\includegraphics[width=\\textwidth]{3-4_random_variables/figures/bellagio.jpg}\n\\end{columns}\n\\ct{Image by Moyan\\_Brenn on Flickr \\webURL{http://www.flickr.com/photos/aigle\\_dore/5951714693}.}\n}\n\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Simplifying random variables}\n\nRandom variables do not work like normal algebraic variables:\n\\[ X + X \\ne 2X \\]\n\n\\pause\n\n{\\small\n\\twocol{0.45}{0.45}\n{\n\\begin{align*}\nE(X + X) &= E(X) + E(X) \\\\\n&= 2 E(X) \\\\\n&~  \\\\\nE(2X) &= 2 E(X) \\\\\n&~ \n\\end{align*}\n}\n{\n\\begin{align*}\nVar(X + X) &= Var(X) + Var(X)~{\\scriptsize \\text{(assuming independence)}} \\\\\n&= 2~Var(X) \\\\\n&~  \\\\\nVar(2X) &= 2^2~Var(X) \\\\\n&= 4~Var(X)\n\\end{align*}\n}\n}\n\n\n\\pause\n\n\\vspace{3mm}\n\n\\mathhl{E(X + X)  = E(2X)}, but \\mathhl{Var(X + X) \\ne Var(2X)}.\n\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{frame}\n\\frametitle{Adding or multiplying?}\n\n\\dq{A company has 5 Lincoln Town Cars in its fleet. Historical data show that annual maintenance cost for each car is on average \\$2,154 with a standard deviation of \\$132. What is the mean and the standard deviation of the total annual maintenance cost for this fleet?}\n\n\\pause\n\nNote that we have 5 cars each with the given annual maintenance cost $(X_1 + X_2 + X_3 + X_4 + X_5)$, not one car that had 5 times the given annual maintenance cost $(5X)$.\n\n\\pause\n\n{\\small\n\\begin{eqnarray*} \nE(X_1 + X_2 + X_3 + X_4 + X_5) &=& E(X_1) + E(X_2) + E(X_3) + E(X_4) + E(X_5) \\\\\n\\pause\n&=& 5 \\times E(X) = 5 \\times 2,154 = \\$ 10,770 \\\\\n\\pause\nVar(X_1 + X_2 + X_3 + X_4 + X_5) &=& Var(X_1) + Var(X_2) + Var(X_3) + Var(X_4) + Var(X_5) \\\\\n\\pause\n&=& 5 \\times V(X) = 5 \\times 132^2 = \\$ 87,120 \\\\\n\\pause\nSD(X_1 + X_2 + X_3 + X_4 + X_5) &=& \\sqrt{87,120} =  295.16\n\\end{eqnarray*}\n}\n\n\\end{frame}\n\n", "meta": {"hexsha": "d26a2c352a63953f9fa87e05592a01ec4f8b5e05", "size": 10228, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/3-4_random_variables/3-4_random_variables.tex", "max_stars_repo_name": "sumitrmishra/data504", "max_stars_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/3-4_random_variables/3-4_random_variables.tex", "max_issues_repo_name": "sumitrmishra/data504", "max_issues_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/3-4_random_variables/3-4_random_variables.tex", "max_forks_repo_name": "sumitrmishra/data504", "max_forks_repo_head_hexsha": "e0cb3259f6dd362c9591375390c9d6e5d59689b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-10-20T07:26:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-20T07:26:35.000Z", "avg_line_length": 27.7181571816, "max_line_length": 412, "alphanum_fraction": 0.6060813453, "num_tokens": 3345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583270090337583, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.40471464991682127}}
{"text": "\\chapter{Preliminary Investigation}\n\\label{ch:investigation}\nOne of the most recurrent subject in talks regarding Android, is how much the platform does not help developers write secure code. Speakers usually make examples of how developers forget to make usage of private mode when saving preferences or either resorting in saving important documents on the SD card, where are publicly available\\cite{codemotion}. Moreover, resources such as Stack Overflow, where developers can share solutions to common problems, do not really help when the security of the published code is often of no importance. Therefore, before starting this work, I identified common vulnerabilities which I thought could be fixed at the compiler level and each of them is here presented with an appropriate threat model\\footnote{To prevent malicious uses of this work, threat models are explained in as much details as possible, but no code will be provided.}. Furthermore, the fact that these problems were reported did not mean that they were present in top Android apps, hence, before actually creating \\emph{DevArtist} to solve these security issues, an investigation was necessary to determine whether they were present and how wide-spread they were.\n\n\\section{Hashing}\nThe term is used to identify the process of transforming data of arbitrary length to data of fixed size, which can be obtained with so called \\emph{Hash functions}. Many fields of computer science use these functions to achieve a variety of results, ranging from memory optimization to algorithms which produce randomness or, as analyzed in this thesis, to verify data integrity. However, the possibility to use such functions in the latter field, exists due to another property: collision-resistance. In fact, any secure hash function is collision-resistant in the sense that it is computationally hard to find two inputs which produce the same hash, otherwise it is said that such function is not cryptographically secure in respect to collisions. Furthermore, due to the fact that on Android the full Java cryptography package is available, a developer must decide which hashing algorithm has to use, depending on its use case because not all of the already existing ones are cryptographically secure.\n\n\\subsection{The MD5 Case}\nMessage Digest 5, hence the MD5 acronym, was developed by Ronald Rivest in 1991 and it was formalized on RFC 1321. However, since Dobbertin found a collision\\cite{dobbertin} in 1996, many other publications reported cases against the algorithm, culminating in 2012 with Marc Stevens, who published in \\cite{stevens}, an algorithm and sources to execute a collision attack on MD5 with the use of a normal laptop. Due to these reasons, the cryptography community suggested to move on to more secure hashing methods such as SHA-1. It is worth to mention that the algorithm could still be used safely to verify data integrity when there is no reason to believe that intentional corruption, by a malicious third-party, took place.\n\n\\subsection{The SHA1 Case}\nSecure Hashing Algorithm 1, \\enquote{SHA1} in short, was developed by the United States Security Agency in 1995. Ten years later Rijmen and Oswald published an initial collision attack\\cite{sha1b1}, which was followed in 2005 by another paper from Marc Stevens\\cite{sha1b2}, who estimated that an attack could be made by investing maximum 2.77 million U.S. dollars in virtualized computing power. More recently, Google's employees achieved and showed in \\cite{sha1b3} how it was possible to create collisions for SHA1. Therefore, cryptography researchers and companies suggest to move on more secure hashing methods, such as SHA-256, whenever the computational power of the device allows.\n\n\\subsection{Threat Model}\nAttacks on Android apps which make use of hashing functions are difficult to report, due to the fact it depends on how the app uses the function. The most common attack vector for this kind of vulnerability is a Man-In-The-Middle (MITM) attack for apps that download from the Internet a package and verify its integrity with MD5 or SHA1. In this case, the attacker can use a proxy between the app and the outside network to change the package with a malicious one which has the same hash as the original one. Of course, being able to install a proxy is an intermediate level of difficulty, whilst creating a malicious package which has the same hash as the original one is definitively harder, but it is indeed possible and it is not too far dissimilar from what happened with the Swift keyboard app shipped within the Galaxy Samsung S6 in 2015 (CVE-2015-4640 and CVE-2015-4641)\\footnote{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4641}, which was downloading language packs from the Internet. Although, \\emph{DevArtist} wouldn't have voided completely the above mentioned attack, due to its sophistication, SHA1 was still in use to verify the downloaded zip and, if the checksum field in the json file was transferred over \\texttt{HTTP} instead of \\texttt{HTTPS}, someone with the right amount of money and time would have performed an attack similar to the one described above. This example and many other apps in the Play Store, such the ones which download wallpapers or themes to style the interface of Android, show that such functionality exists and could be exploited. \n\n\\section{SQL and Injections}\nAs the definition applies: a database is a collection of data and the software which manages it is called Database Management System or, in short, DBMS. Many kinds of DBMS are being developed since 1960 but the most popular one, still in 2017 (the year of writing), as shown in Fig: \\ref{appendix:dbmarketshare} by solid-IT in their DB-Engine ranking\\footnote{https://db-engines.com/en/ranking} is a direct descendant of the relational database described in \\cite{dbrelational} by Edgar F. Codd in 1970. Probably for this reason and for the possibility to have a database in one single file, Google, on its Android, decided to provide developers with a relational database named SQLite as their only DBMS option. Therefore, developers are allowed to create as many databases as they want inside their own, hopefully private, folders. However, by doing this, it left an open margin for SQL Injections (SQLi), which are particular code injections techniques with the aim of stealing user's data from any SQL-enabled database. In fact, the main concept behind SQLi is the ability to write valid SQL code inside an input field, which modifies the behavior of the original one to extract protected information, thus showing the private ones instead of the expected information. These kind of attacks were really \\emph{popular} during the early PHP era and they allowed massive breaches, which produced incredible amounts of stolen credit cards, password and other user information\\footnote{Examples of data breaches with SQL Injection can be found extensively on-line.}. \n\n\\subsection{The Case of the \\emph{RawQuery} Method}\nAndroid developers interact with the underlying SQLite within the class \\texttt{SQliteDatabase}, which provides all the methods to perform CRUD operations. However, both for performances and incrementation of the capability offered by the system, a way to execute queries in a non constructed manner is provided as API, leaving the responsibility of proper usage to developers. That API is the \\emph{rawQuery()} method. In fact, if a developer is unaware of the danger which such API exposes to, malicious attackers could use it to perform SQL injections and extract user data. The code in listing \\ref{lst:injection} shows an example of possible Android code, supposedly returning only the passwords for the defined account id and URL. However, the value of the variable \\emph{url} can be manipulated in such a way which makes the query return all the passwords also for other accounts.\\newline\\newline\n\n\\lstset{numbers=left, numberstyle=\\tiny, stepnumber=1, numbersep=5pt}\n\\begin{lstlisting}[language=Java, label={lst:injection}, caption=\"SQL injection example\", captionpos=b]\npublic List<String> foo(int id, String url){\n\tString sql = \"SELECT password FROM passwords \"+\n\t   \t\t\t\" WHERE accountID=\"+id+\" AND URL='\"+url\"'\";\n\tSQliteDatabase db = getReadableDatabase();\n\tCursor c = db.rawQuery(sql, null);\n\tList<String> foos = new ArrayList<>();\n\twhile(c.hasNext()){\n\t\tfoos.add(c.getString(0));\n\t}\n\treturn foos;\n}\n\\end{lstlisting}\n\n% \\subsection{Threat Model}\n% There are several Attack models for SQL injection on Android and they are here described on the level of difficulty which is required to successfully take advantage of them.\n\n% \\subsubsection{Easy attack}\n% This threat model envisions that a malicious person (Eve) steals shares, even for a short period of time, the mobile phone of another person (Alice). If this event occurs and Eve knows that an application (A) is subject to an SQL Injection it can simply open the app and run the SQL Injection. This attack might seem ephemeral at first, but take as example an app that shows contacts based on the account in use by the Android system or, as mentioned before, a password manager. In these cases, even if the attack is easy and requires manual intervention, the danger of exposing unwanted information to the wrong person is high.\n\n\\subsubsection{Advanced Attack} \nAs mentioned in section \\ref{sc:exportedcomponents}, certain components in the Android's SDK  are allowed to be accessed publicly by other applications. One possible case of such components is the \\texttt{ContentProvider}, which can offer data from a SQLite database owned by the app (A) to another app (B), if exported, through an interface. In this case, if the interface is using string composition as showed earlier and the method \\texttt{rawQuery}, an attacker could install a rogue app which exploits this vulnerability and leak the information contained in A. Installing such application is not that hard, one can do it manually if physical access to the device is granted or remotely by inducing the victim (with a Whatsapp message if the number of the victim is known, or other social engineering means) in downloading an app that pretends to do one thing and, in the meanwhile, exploits the vulnerability.\n\n\\newpage\n\\section{Randomness}\n\\label{sec:randominvestigation}\nIn Computer Science, it is often necessary to produce random data and, although generating real randomness is still an open problem, Java provides two classes to produce pseudo-random data: \\emph{Random} and \\emph{SecureRandom}. The former class, should not be employed in a hardened environment due to the fact that it is using a Linear Congruential Generator (LCG) which has been demonstrated to be broken in \\cite{lcgbreak} by Hugo Krawczyk. On the other hand, \\emph{SecureRandom}, if used correctly, draws its randomness from \\emph{/dev/urandom}, which is considered more secure by the cryptographic community as discussed in \\cite{secrandom} and \\cite{urandom}. However, as reported by BBC\\cite{bbc} and other news publishers, the algorithm in use by \\emph{SecureRandom} could be broken by the U.S National Security Agency (NSA). To avoid philosophical discussions over what is trusted or not in this work, we assume that \\emph{SecureRandom} provides a better security over the \\emph{Random} class. The only exception to this assumption is on Android Jellybean, where \\texttt{SecureRandom} was vulnerable, as described in \\cite{bitcoinalert} and \\cite{randomalert}, but since this project is built for Android 7 \\enquote{Nougat}, the case is not a concern.\n\n\\subsection{Threat Model}\nSince describing meaningful attack vectors of apps which contains an insecure usage of random is difficult due to their dependency on the purpose of their target, I will make use of an example: a poker app which needs to shuffle the deck and allows the player to buy virtual coins in exchange of real coins. In this case, the developer of the app might have used the class \\texttt{Random} instead of \\texttt{SecureRandom} and, if the player manages to guess the seed it can reproduce the shuffle of the deck and win every match. Although the difficulty of performing such an attack is hard, it might still be perpetrated by a resolute attacker especially due to the fact that money is involved, thus showing the importance of patching randomness.\n\n\\section{Preliminary Analysis}\n\\label{sc:preliminaryanalysis}\nTo investigate on the severity of the above issues, it was necessary to check if applications already published in the Play Store contained the signatures of the Java methods used to produce them. Therefore, I developed an \\emph{Artist} module which detects the signatures of methods listed below and extended Monkey Troop to re-compile applications with my module, allowing me to count the number of usages of those calls.\\newpage Moreover, the full source code of this module and the Monkey Troop extension is available on Github\\footnote{\\url{https://www.github.com/jibbo/master_thesis}}.\n\n\\begin{itemize}\n\t\\label{it:signs}\n\t\\item{For Random: java.util.Random.\\textless init\\textgreater}\n\t\\item{For SecureRandom: java.security.SecureRandom.\\textless init\\textgreater}\n\t\\item{For MD5, SHA-1, SHA-256: java.security.MessageDigest.getInstance(java.lang.String)}\n\t\\item{For rawQuery():\\newline android.database.sqlite.SQLiteDatabase.rawQuery(java.lang.String, java.lang.String[])}\n\\end{itemize}\n\n\\subsection{The List of Apps}\nThe evaluation was conducted on the top 500 apps of the Play Store, available in Germany as the 1st of January 2017, the full list can be found in \\ref{appendix:appslist}, ordered alphabetically by their package name, which is unique. Therefore, popular apps such as Facebook, Telegram, WhatsApp, Instagram, Snapchat, Pinterest (to name a few) are included in the list. It is a general belief that the most downloaded apps are either social networks or games and that, especially the latter category, these apps are less secure. However, it is worth to mention that top apps are computed over the most downloaded apps in every every category available on the Store, such as: Finance, Productivity, News, Photography and so on \\footnote{Full list available in appendix \\ref{appendix:categorieslist}}.\n\n\\subsection{Monkey Troop Extension}\nThe first change to this automated system was to specify, through a script, the commands needed to be executed and they can be found below. Since every signature could be checked through static analysis when compiling, these commands do not need to be many and follow every execution path, but they need to ensure that any app can at least be launched without crashing and provide an extensive log for deeper investigation. Therefore, I instructed the system with the commands below and then extended the analyzer class (\\texttt{ResultAnalyzer.py}) to keep track of the specific log outputs of my module. These logs get stored inside a SQLite Database only when the above mentioned class reported that all the steps had been executed successfully. Moreover, the database was composed of only one table which contained two fields: the package-name of the apps and a specific line of the Logcat designed for the purpose. In fact, to detect the hashing algorithm, my module logged a line with the following shape: \\enquote{[DC][HASHING][ALGORITHM\\_NAME]}, whilst for all the other cases, the form \\enquote{[DC][SIGNATURE] usage found} was used. In this way, counting only the the needed signatures or specific hashing function could be achieved by filtering the log line through standard SQL queries.\n\n\\begin{itemize}\n\t\\item{Download app from the Play Store}\n\t\\item{Install the app on the device}\n\t\\item{Run the app}\n\t\\item{Re-Compile the app with the module}\n\t\\item{Run the instrumented app}\n\t\\item{Copy the full Logcat in a file}\n\t\\item{Repeat with another app from the list}\n\\end{itemize}\n\n\\subsection{Results}\nMonkey Troop makes usage of a third party tool to download application from the Play Store, but, due to authentication problems between the third-party tool and the Play Store, happening systematically only when downloading certain apps, the population shrunk from 500 apps to 492.  In addition, although the remaining part of the apps could be run, the actual population shrunk again to 392 due to \\emph{Artist} itself, which (in my own tests) has a success rate in instrumenting of only 85,40\\%. From a preliminary analysis, these apps seem to be using APIs which are not supported by \\emph{Artist} as also mentioned in \\cite{artist}. Moreover, taking in consideration apps below the top 500 line, to increment the number of examined apps, would have decreased too much the quality of the population, thus risking worse results. Every number reported in table \\ref{tb:respreliminary} was extracted from the SQL database, filtered by the signature and grouped by the app package-name when necessary.\n\n\\begin{table}[H]\n\t\\vspace{1.5cm}\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\t\\hline\n\t\tSubject & Found in \\# of apps  & Times used \\\\\n\t\t\\hline\n\t\tRandom & 261 & 2909 \\\\\n\t\t\\hline\n\t\tSecureRandom & 244 & 1023\\\\\n\t\t\\hline\n\t\trawQuery & 296 & 737\\\\\n\t\t\\hline\n\t\tMD5 & 189 & 2743\\\\\n\t\t\\hline\n\t\tSHA-1 & 119 & 1091\\\\\n\t\t\\hline\n\t\tSHA-256 & 29 & 339\\\\\n\t\t\\hline\n\t\\end{tabular}\n\t\\caption{Number of method signatures found}\n\t\\label{tb:respreliminary}\n\t\\vspace{1.5cm}\n\\end{table}\n\n\\subsection{Interpretation}\nTable \\ref{tb:respreliminary} shows that MD5 is used in more than 48\\% of the cases alone, making it the most widely used hash function. Moreover, even SHA-1 reaches a remarkable 30\\% of usage, making it clear that the usage of broken hash functions is very common and it should be the first danger addressed by this work. Furthermore, the usage of the insecure \\texttt{rawQuery()} method is also astonishingly wide-spread, since the method is present in more than the 75,5\\% of the apps. In addition, although the class \\texttt{SecureRandom} and \\texttt{Random} are present in almost the same amount of apps, the insecure one is used almost twice as many times. Therefore, this data suggested that there is a real need in addressing the issue.\n\n", "meta": {"hexsha": "c5b6353985729b3c4db46900806ed2e81f7e8cea", "size": 18107, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writeup/chapter_inve.tex", "max_stars_repo_name": "jibbo/master_thesis", "max_stars_repo_head_hexsha": "c8f64bc429d6dd43579fb11aea8b660b76aa078f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "writeup/chapter_inve.tex", "max_issues_repo_name": "jibbo/master_thesis", "max_issues_repo_head_hexsha": "c8f64bc429d6dd43579fb11aea8b660b76aa078f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "writeup/chapter_inve.tex", "max_forks_repo_name": "jibbo/master_thesis", "max_forks_repo_head_hexsha": "c8f64bc429d6dd43579fb11aea8b660b76aa078f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 158.8333333333, "max_line_length": 1590, "alphanum_fraction": 0.7961009554, "num_tokens": 4051, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.40471463594393997}}
{"text": "%!TEX root = ../../dissertation.tex\n\n\\subsection{Cellular Automaton} % (fold)\n\\label{sub:cellular_automaton}\n\nA cellular Automaton is a model of a system of cells within a grid with a given shape, each of this cells can be on one of a finite set of states. It evolves during a finite amount of time steps with a set of simple rules according to each state of the neighboring cells.\nThe neighborhood of the cell can be defined in many different ways, the most common is the use of the adjacent cells. \n\nThis models have various applications, such as modeling of nature aspects (Figure~\\ref{fig:CArule30shell}), textures, and as inspiration to architecture (Figure~\\ref{fig:CAarchitecture}).\n\n\\begin{figure}\n        \\centering\n        %\\begin{subfigure}[b]{0.5\\textwidth}\n                \\includegraphics[width=0.45\\textwidth]{images/Theory/Cellular_A/dome1.jpg}\n        %        \\caption{}\n  %              \\label{fig:CAdome}\n        %\\end{subfigure}%\n        %~ %add desired spacing between images, e. g. ~, \\quad, \\qquad, \\hfill etc.\n          %(or a blank line to force the subfigure onto a new line)\n          ~~\n        %\\begin{subfigure}[b]{0.5\\textwidth}\n                \\includegraphics[width=0.45\\textwidth]{images/Theory/Cellular_A/main1.jpg}\n        %        \\caption{}\n   %             \\label{fig:CArule30}\n        %\\end{subfigure}\n        \\caption{Examples of cellular automata applied in architecture}\n        \\label{fig:CAarchitecture}\n\\end{figure}\n\nThe case where each cell have two possible states and the next generation state depends only on the previous state of the cell and the two immediate neighbors is called an \\emph{elementary cellular automaton}. In this case we have $2^3 = 8$ possible patterns for a neighborhood and $2^8 = 256$ sets of possible different rules. This rules are referred by their \\emph{Wolfram code} \\cite{CellularAutWOLFRAM}. \n\nA common initial state for this elementary cellular automata is a random line. But to be able to compare the results between rules and get clean results another option is to start with a line with zeros except the middle cell that is initialized with the value one. Applying this second option and the set of rules in Figure~\\ref{fig:CArule} (the rule 30), we get the pattern in the Figure~\\ref{fig:resultCA} that represents the evolution of a cellular automaton over a few generations.\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=0.85\\textwidth]{images/Theory/Cellular_A/Rules.png}\n\t\\caption{Example Production Rules\\cite{Shiffman2012}}\n\t\\label{fig:CArule}\n\\end{figure}\n\n\n\n\\begin{figure}[h!]\n    \\centering\n    \\includegraphics[width=0.75\\textwidth]{images/Theory/Cellular_A/Result.png}\n    \\caption{Sierpiński Triangle, rule 90}\n    \\label{fig:resultCA}\n\\end{figure}\n\n\nIn Figure~\\ref{fig:resultCA} each line represents an iteration of the system with the application of the rules. With this set of rules a Sierpiński triangle is reproduced.\n\n\nCellular automata are used mainly to model phenomena that occur in the physical world, most of them can only express the basic idea of a phenomenon, but some are accurate enough to be able to make predictions.\n\nIn this context, cellular automata are used to model natural shapes and textures, Figure~\\ref{fig:CArule30shell} shows on the left, a natural texture on the shell of a \\emph{Textile Cone Snail}, that looks like the patterns formed with the cellular automaton on the right.\n\n\n\n\\begin{figure}\n        \\centering\n        %\\begin{subfigure}[b]{0.3\\textwidth}\n                \\includegraphics[width=0.45\\textwidth]{images/Theory/Cellular_A/shell.jpeg}\n        %        \\caption{a)}\n\t\t%\t\t\\label{fig:CAshell}\n        %\\end{subfigure}%\n        %~ %add desired spacing between images, e. g. ~, \\quad, \\qquad, \\hfill etc.\n          %(or a blank line to force the subfigure onto a new line)\n          ~~\n        %\\begin{subfigure}[b]{0.5\\textwidth}\n                \\includegraphics[width=0.45\\textwidth]{images/Theory/Cellular_A/Rule30.png}\n\t\t%\t\t\\caption{b)}\n\t\t%\t\t\\label{fig:CArule30}\n        %\\end{subfigure}\n        \\caption{Example of the representation of natural patterns with cellular automata. On the left, a Natural Shell \\cite{Shiffman2012} and on the right a Pattern formed with the rule 30}\n\t\t\\label{fig:CArule30shell}\n\\end{figure}\n\n\n\n% subsection cellular_automaton (end)", "meta": {"hexsha": "23a3740280496fe5b5b8bd856f53d6a3db894e07", "size": 4316, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/over-sections/2-cellular_automaton.tex", "max_stars_repo_name": "arturalkaim/Dissertation", "max_stars_repo_head_hexsha": "8acf0d8de0f312ec0f70f6aece795f4f93260d76", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/over-sections/2-cellular_automaton.tex", "max_issues_repo_name": "arturalkaim/Dissertation", "max_issues_repo_head_hexsha": "8acf0d8de0f312ec0f70f6aece795f4f93260d76", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/over-sections/2-cellular_automaton.tex", "max_forks_repo_name": "arturalkaim/Dissertation", "max_forks_repo_head_hexsha": "8acf0d8de0f312ec0f70f6aece795f4f93260d76", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.2839506173, "max_line_length": 486, "alphanum_fraction": 0.7143188137, "num_tokens": 1146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.4047146252895186}}
{"text": "\\subsubsection{Mixed Cell Radionuclide Mass Balance Model}\\label{sec:mixed_cell}\n\nSlightly more complex, the Mixed Cell model incorporates the influence of\nporosity, elemental solubility limits, and sorption in addition to the\ndegradation behavior of the Degradation Rate model. A graphical representation\nof the discrete sub-volumes in the mixed cell model is given in Figure\n\\ref{fig:deg_sorb_volumes}.\n\n\\input{./nuclide_models/mass_balance/mixed_cell/deg_sorb_volumes}\n\nAfter some time degrading, the total volume in the degraded region $(V_d)$ can be \nexpressed as in equation \\eqref{deg_volumes}. Additionally, given a volumetric \nporosity, $\\theta$, the intact and degraded volumes can also be described in \nterms of their constituent solid matrix $(V_{is} + V_{ds})$ and pore fluid \nvolumes $(V_{if} + V_{df})$,\n\n\\begin{align}\nV_d(t_n) &= \\mbox{ degraded volume at time }t_n [m^3]\\nonumber\\\\\n          &= V_{df}(t_n) + V_{ds}(t_n)\n\\intertext{where}\nV_{df}(t_n) &= \\mbox{ degraded fluid volume at time }t_n[m^3]\\nonumber\\\\\n       &= \\theta V_d(t_n)\\\\\n       &= \\theta d(t_n) V_T\n\\end{align}\n\\begin{align}\nV_{ds}(t_n) &= \\mbox{ degraded solid volume at time }t_n [m^3]\\nonumber\\\\\n       &= (1-\\theta) V_d(t_n)\\\\\n       &= (1-\\theta) d(t_n) V_T\n\\end{align}\n\\begin{align}\nV_i(t_n) &= \\mbox{ intact volume at time }t_n [m^3]\\nonumber\\\\\n       &= V_{if}(t_n) + V_{is}(t_n)\n\\end{align}\n\\begin{align}\nV_{if}(t_n) &= \\mbox{ intact fluid volume at time }t_n [m^3]\\nonumber\\\\\n       &= \\theta V_i(t_n)\\\\\n       &= \\theta (1-d(t_n))V_T\n\\intertext{and}\nV_{is}(t_n) &= \\mbox{ intact solid volume at time }t_n [m^3]\\nonumber\\\\\n       &= (1-\\theta) V_i(t_n)\\\\\n       &= (1-\\theta) (1-d(t_n))V_T.\n\\end{align}\n\nThis model distributes contaminant masses throughout each sub-volume of the\ncomponent. Contaminant\nmasses and concentrations can therefore be expressed with notation indicating\nin which volume they reside, such that\n\n\\begin{align}\nC_{df} &= \\frac{m_{df}}{V_{df}} \\label{c_df}\\\\\nC_{ds} &= \\frac{m_{ds}}{V_{ds}} \\label{c_ds}\\\\\nC_{if} &= \\frac{m_{if}}{V_{if}} \\label{c_if}\\\\\nC_{is} &= \\frac{m_{is}}{V_{is}}.  \\label{c_is}\n\\intertext{where}\n        df = \\mbox{degraded fluid}\\\\\n        ds = \\mbox{degraded solid}\\\\\n        if = \\mbox{intact fluid}\\\\\n        is = \\mbox{intact solid.}\n\\end{align}\n\nThe contaminant mass in the degraded fluid ($m_{df}$) is the contaminant mass that is\ntreated as ``available'' to adjacent components. That is, $m_{df}$ is the mass \nvector $m_{ij}$ which has been released by component $i$ and can be transferred \nto component $j$ in the following mass transfer phase. \n\n\\paragraph{Sorption}\n\nThe mass in all volumes exists in both sorbed and non-sorbed phases. The\nrelationship between the sorbed mass concentration in the solid phase (e.g. the\npore walls),\n\n\\begin{align}\ns &=\\frac{\\mbox{ mass of sorbed contaminant} }{ \\mbox{mass of total solid phase }}\n\\label{solid_conc}\n\\end{align}\nand the dissolved liquid concentration,\n\\begin{align}\nC &=\\frac{\\mbox{ mass of dissolved contaminant} }{ \\mbox{volume of total liquid phase }}\n\\label{liquid_conc}\n\\end{align}\ncan be characterized by a sorption ``isotherm'' model. A sorption isotherm\ndescribes the equilibrium relationship between the amount of material bound to\nsurfaces and the amount of material in the solution. The Mixed Cell mass\nbalance model uses a linear isotherm model.\n\nWith the linear isotherm model, the mass of contaminant sorbed onto the\nsolid phase, also referred to as the solid concentration, can be found\n\\cite{schwartz_fundamentals_2004}, according to the relationship\n\\begin{align}\ns_p &= K_{dp} C_{p}\n\\label{linear_iso}\n\\intertext{where}\ns_p &= \\mbox{ the solid concentration of isotope p }[kg/kg]\\nonumber\\\\\nK_{dp} &= \\mbox{ the distribution coefficient of isotope p}[m^3/kg]\\nonumber\\\\\nC_p &= \\mbox{ the liquid concentration of isotope p }[kg/m^3].\\nonumber\n\\end{align}\n\nThus, from \\eqref{solid_conc},\n\n\\begin{align}\ns_{dsp} &= K_{dp} C_{dfp}\\nonumber\\\\\n         &= \\frac{K_{dp}m_{dfp}}{V_{df}}\\nonumber\n\\intertext{where}\ns_{dsp} &= \\mbox{ isotope p concentration in degraded solids } [kg/kg] \\nonumber\\\\\nC_{dfp} &= \\mbox{ isotope p concentration in degraded fluids } [kg/m^3]. \\nonumber\n\\end{align}\n\nIn this model, sorption is taken into account throughout the volume. In the\nintact matrix, the contaminant mass is distributed between the pore walls and\nthe pore fluid by sorption.  So too, contaminant mass released from the intact\nmatrix by degradation is distributed between dissolved mass in the free fluid\nand sorbed mass in the degraded and precipitated solids. Note that this model is \nagnostic to the mechanism of degradation. It simulates degradation purely from \na rate and release is accordingly congruent \\cite{kawasaki_congruent_2004} with \nthat degradation. \n\nTo begin solving for the boundary conditions in this model, the amount of non-sorbed\ncontaminant mass in the degraded fluid volume must be found. Dropping the\nisotope subscripts and beginning with equations \\eqref{c_df} and \\eqref{linear_iso},\n\n\\begin{align}\nm_{df} &= C_{df}V_{df}\n\\intertext{and assuming the sorbed material is in the degraded solids}\nm_{df} &= \\frac{s_{ds}V_{df}}{K_d},\\nonumber\\\\\n\\intertext{then applying the definition of $s_{ds}$ and $m_{ds}$}\nm_{df} &= \\frac{\\frac{m_{ds}}{m_T}V_{df}}{K_d}\\nonumber\\\\\n       &= \\frac{(dm_T-m_{df})V_{df}}{K_dm_T}.\\nonumber\n\\intertext{This can be rearranged to give}\nm_{df} &= \\frac{dV_{df}}{K_d}\\frac{1}{\\left( 1+ \\frac{V_{df}}{K_dm_T}\\right)}\\nonumber\\\\\n       &= \\frac{dV_{df}}{\\left( K_d+ \\frac{V_{df}}{m_T}\\right)}.\n\\intertext{Finally, using the definition of $V_{df}$ in terms of total volume,}\nm_{df} &= \\frac{d^2 \\theta V_T}{K_d + \\frac{d \\theta V_T}{m_T}}.\n       \\label{sorption}\n\\end{align}\n\n\\paragraph{Solubility}\nDissolution of the contaminant into the\navailable fluid volume is constrained by the\nelemental solubility limit.\nThe reduced mobility of radionuclides with lower\nsolubilities can be modeled \\cite{hedin_integrated_2002} as a reduction in the\namount of solute available for transport, thus:\n\n\\begin{align}\n  m_{i}(t)&\\le V(t)C_{sol, i}\\label{sol_lim}\n  \\intertext{where}\n  m_{i} &= \\mbox{ mass of isotope i in volume }V [kg]\\nonumber\\\\\n  V &= \\mbox{ a distinct volume of fluid } [m^3]\\nonumber\\\\\n  C_{sol, i} &= \\mbox{ the maximum concentration of i } [kg\\cdot m^{-3}].\\nonumber\n\\end{align}\n\nThat is, the mass $m_{i}$ in  kg of a radionuclide $i$ dissolved into the waste package\nvoid volume $V_1$ in m$^3$, at a time t, is limited by the solubility limit,\nthe maximum concentration, $C_{sol}$ in kg/m$^3$ at which that radionuclide is\nsoluble \\cite{hedin_integrated_2002}.\n\n\nThe final available mass is therefore the $m_{df}$ from equation\n\\eqref{sorption} constrained by:\n    \\begin{align}\n      m_{df,i} &\\leq V_{df} C_{sol,i}\n      \\label{solubility}\n    \\intertext{where}\n      m_{df,i} &= \\mbox{ solubility limited mass of isotope i in volume }V_{df} [kg]\\nonumber\\\\\n      C_{sol,i} &= \\mbox{ the maximum dissolved concentration limit of i }[kg/m^3].\\nonumber\n    \\end{align}\n\n\n", "meta": {"hexsha": "5d20749e2164f0adfe854c19b8fd4f0057d377ab", "size": 7042, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "nuclide_models/mass_balance/mixed_cell/mixed_cell.tex", "max_stars_repo_name": "katyhuff/2017-huff-rapid", "max_stars_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nuclide_models/mass_balance/mixed_cell/mixed_cell.tex", "max_issues_repo_name": "katyhuff/2017-huff-rapid", "max_issues_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nuclide_models/mass_balance/mixed_cell/mixed_cell.tex", "max_forks_repo_name": "katyhuff/2017-huff-rapid", "max_forks_repo_head_hexsha": "cfb06a9a2e744914e7f3d088014db7a71a68c39d", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6686390533, "max_line_length": 95, "alphanum_fraction": 0.711445612, "num_tokens": 2212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4046877140057088}}
{"text": "\\documentclass[a4paper,10pt]{article}\n\n\\usepackage{amsthm,amsfonts,amsmath,amssymb,amscd}\n\\usepackage{indentfirst}\n\\usepackage[usenames]{color}\n\\usepackage{color}\n\\usepackage{colortbl}\n\n\\usepackage[singlelinecheck=off,center]{caption}\n\\usepackage{soul}\n\n\\usepackage{cite}\n\n\\usepackage[plainpages=false,pdfpagelabels=false]{hyperref}\n\\definecolor{linkcolor}{rgb}{0.9,0,0}\n\\definecolor{citecolor}{rgb}{0,0.6,0}\n\\definecolor{urlcolor}{rgb}{0,0,1}\n\\hypersetup{\n    colorlinks, linkcolor={linkcolor},\n    citecolor={citecolor}, urlcolor={urlcolor}\n}\n\n\\usepackage{graphicx}\n\\graphicspath{{images/}}\n\n\\makeatother\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\newcommand{\\ket}[1]{|#1\\rangle}\n\\newcommand{\\bra}[1]{\\langle#1|}\n\\newcommand{\\ketbra}[2]{\\ket{#1}\\langle#2|}\n\\newcommand{\\tr}{\\ensuremath{{\\rm Tr}}}\n\n\\begin{document}\n\n\\begin{center}\n\\Large{{\\bf Self-check problems on\\\\  Quantum information processing}\\\\{\\it Part 2: Measurements and evolution}}\\\\\n\\vspace{5pt}\n\\large{Last update: \\today}\n\\end{center}\n\n\\subsection*{Problem 1}\nConsider a qubit, called ``system'', in some pure state $\\ket{\\psi_{0}}$, and another qubit, called ``probe'', in the initial state $\\ket{0}$.\nLet the system and the probe interact according to a Hamiltonian \n\\begin{equation}\n\tV=\\frac{1}{2}\\sigma_{z}\\otimes\\sigma_{y}\n\\end{equation} \nfor time period $t$ (the first tensor factor corresponds to the first qubit, the second factor -- to the probe).\nLet then the probe be measured in $\\{\\ket{+}, \\ket{-}\\}$ basis (remember, that it corresponds to projective $\\sigma_{x}$measurement).\n\\begin{enumerate}\n\t\\item Find evolution of the initial state for cases $\\ket{\\psi_{0}}=\\ket{0}$ and $\\ket{\\psi_{0}}=\\ket{1}$.\n\tDraw pictures of evolution of Bloch vectors for the system and the probe for the both cases.\n\t\\item Consider the general case of $\\ket{\\psi_{0}}=\\alpha\\ket{0}+\\beta\\ket{1}$. Find the reduced state of the system and probe.\n\tHow do the Bloch vectors of the system and the probe evolve in this general case?\n\tWhat we can say about entanglement between the system and the probe? (Remember, that entanglement of a pure bipartite state is characterized by mixedness of its parties.)\n\t\\item Consider the case $\\ket{\\psi_{0}}=\\ket{0}$ and find probabilities of obtaining outcomes $+1$ and $-1$ in the $\\sigma_{x}$-measurement of the probe as function of time $t$.\n\tWhat about the case $\\ket{\\psi_{0}}=\\ket{1}$?\n\t\\item Let's consider the general case $\\ket{\\psi_{0}}=\\alpha\\ket{0}+\\beta\\ket{1}$ again. Let at time $t=\\frac{\\pi}{2}$ the probe be measured in the state $\\ket{+}$ (with a corresponding outcome +1). What will be the resulting ``collapsed'' state of the system in this case? Consider the same story but with $t=\\frac{\\pi}{4}$. How the collapsed state changed?\n\t\\item Consider the case $\\ket{\\psi_{0}}=\\ket{+}$ and $t=\\frac{\\pi}{2}$. Let the system be given to Alice, and the probe -- to Bob. Remember what is the state of Alice's particle (you have calculated it already).\n\tLet Bob measure $\\sigma_{x}$ of the probe, but keep the result of his measurement in a secret from Alice.\n\tWhat is an ``effective'' state of Alice's particle (the system) without this information?\n\tLet then Bob phone Alice and tell that he obtained +1 outcome in his measurement (we assume that Bot is honest). \n\tWhat is the state of Alice's particle now?\n\t\\item Think a bit about the statement ``Information is physical'' :-)\n\t\\item Find POVM realized on the system by projective measurement of the probe for $t=\\frac{\\pi}{2}$, $t=\\frac{\\pi}{4}$.\n\\end{enumerate}\n\n\n\\subsection*{Problem 2}\nConsider a qubit POVM\n\\begin{equation}\n\tM = \\left\\{\\frac{1}{2}\\ket{0}\\bra{0}, \\frac{1}{2}\\ket{1}\\bra{1}, \\frac{1}{2}{\\bf 1}\\right\\}\n\\end{equation}\n(here ${\\bf 1}$ is a $2\\times 2$ identity matrix).\n\\begin{enumerate}\n\t\\item Check that $M$ is a valid POVM.\n\t\\item Design a projective measurement, which corresponds to the given POVM, in an extended space obtained by considering qubit states as states of some 4-level system. \n\t\\item Design a projective measurement, which corresponds to the given POVM, on a two qubit state $\\rho\\otimes\\ket{0}\\bra{0}$ (here $\\rho$ is a states measured with POVM).\n\\end{enumerate}\n\n\n\\subsection*{Problem 3}\nConsider a realistic single-photon detector.\nLet the input state coming to detector live in the two-dimensional Hilbert space spanned by vectors $\\ket{0}$ (no photon) and $\\ket{1}$ (one photon).\nOur detector is characterized by two parameters: efficiency $\\eta\\in [0,1]$ (probability that incoming photon will be observed by the detector), and dark-count probability $p_{\\rm dark}\\in[0,1]$ (probability that in a given time-window the detector will ``click'' regardless presence of photon in the input channel).\nWrite down POVM elements corresponding to outcomes ``click'' and ``no click'' of the detector.\nHow the POVM will change if we extend the space of input states to higher photon numbers ($\\ket{2}, \\ket{3}, \\ldots$)?\n\n\\subsection*{Problem 4}\nDesign a construction of SIC-POVM elements for arbitrary $d$-dimensional Hilbert space ($d>2$).\n\n\n\\subsection*{Problem 5}\nConsider a three-qubit system where the first qubit is prepared in an arbitrary state $\\rho$ and two other qubits in the fixed state $\\ket{00}_{2,3}$.\nLet the initial state of qubits be affected by unitary operator\n\\begin{equation}\n\tU = \\ket{000}_{1,2,3}\\bra{000} +  \\ket{111}_{1,2,3}\\bra{100} + \\ldots.\n\\end{equation}\nFind Kraus operators of a map $\\Phi_{1\\rightarrow 3}[\\cdot]$ which outputs the resulting state of the third qubit depending on the initial state of the first qubit $\\rho$.\nFind Kraus operators of a dual map $\\Phi_{1\\rightarrow (1,2)}[\\cdot]$ which outputs the resulting state of the first and the second qubits depending on the initial state of the first qubit $\\rho$.\nCheck that the obtained operators satisfy normalization condition.\n\n\n\\subsection*{Problem 6}\nLet $\\Phi[\\rho]=\\sum_{i}A_{i}\\rho A_{i}^{\\dagger}$ be a CPTP map.\nLet $u_{i,j}$ be elements of some unitary matrix $U$, and $B_{i}=\\sum_{i}u_{ij}A_{j}$.\nShow that $\\Phi[\\rho]=\\sum_{i}B_{i}\\rho B_{i}^{\\dagger}$.\n\n\n\\subsection*{Problem 7}\nConsider a CPTP map $\\Phi[\\cdot]$ and a corresponding Choi state\n\\begin{equation}\n\t\\rho_{\\rm Choi} = \\sum_{i,j} \\ket{i}_{1}\\bra{j}\\otimes\\Phi[\\ket{i}_{2}\\bra{j}]\n\\end{equation}\n(here $\\{\\ket{i}\\}$ is a orthonormal basis for the Hilbert space of inputs).\nShow that the action of $\\Phi[\\cdot]$ on some input state $\\rho$ is given by\n\\begin{equation}\n\t\\Phi[\\rho]=\\tr_{1}(\\rho\\otimes {\\bf 1} \\rho_{\\rm Choi}^{\\rm T_{1}})=\n\t\\tr_{1}(\\rho^{\\rm T_{1}}\\otimes {\\bf 1} \\rho_{\\rm Choi}),\n\\end{equation}\nwhere ${\\rm T}_{1}$ stands for a partial transpose in ``the first space''.\n\n\n\\subsection*{Problem 8}\nConsider a single-qubit Pauli transformation \n\\begin{equation}\n\t\\rho\\rightarrow \\sigma_{\\alpha}\\rho\\sigma_{\\alpha}, \\quad \\alpha\\in\\{x,y,z\\}.\n\\end{equation}\nHow this transformation affects the Bloch vector of $\\rho$?\n\nShow that \n\\begin{equation}\n\t\\frac{1}{4}\\left({\\bf 1}\\rho{\\bf 1}+\\sum_{\\alpha\\in\\{x,y,z\\}}\\sigma_{\\alpha}\\rho\\sigma_{\\alpha}\\right) = \\frac{\\bf 1}{2}\n\\end{equation}\nfor any $\\rho$.\n\n{\\bf Hint}: decompose $\\rho$ in sum of terms with Pauli matrices.\n\n\n\\subsection*{Problem 9}\nWrite Choi matrices for dephasing, depolarizing, and damping channels.\n\n\\end{document}\n", "meta": {"hexsha": "e5f42f66f591d37f4e5bdb778e7eb9e6a8ca5f7c", "size": 7297, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Self-check/assignment_2.tex", "max_stars_repo_name": "EvgeniyKiktenko/RQC-MIPT-q-inf-proc-course", "max_stars_repo_head_hexsha": "d6fc465224d5bd014d6a9725dd432cbfdcb6bb79", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-10-13T14:45:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-09T11:21:54.000Z", "max_issues_repo_path": "Self-check/assignment_2.tex", "max_issues_repo_name": "EvgeniyKiktenko/RQC-MIPT-q-inf-proc-course", "max_issues_repo_head_hexsha": "d6fc465224d5bd014d6a9725dd432cbfdcb6bb79", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Self-check/assignment_2.tex", "max_forks_repo_name": "EvgeniyKiktenko/RQC-MIPT-q-inf-proc-course", "max_forks_repo_head_hexsha": "d6fc465224d5bd014d6a9725dd432cbfdcb6bb79", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6736111111, "max_line_length": 359, "alphanum_fraction": 0.7115252844, "num_tokens": 2170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.40468770585086006}}
{"text": "\\documentclass[a4paper,12pt]{article}\n\\usepackage[utf8x]{inputenc}\n\\usepackage{amsfonts}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{bm}\n\\usepackage{extarrows}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\\usepackage{indentfirst}\n\\usepackage{fancyhdr}\n\\usepackage{verbatim}\n\\usepackage{booktabs}\n\\usepackage[dvipdfm,colorlinks,linkcolor=blue,citecolor=blue]{hyperref}\n\\usepackage{natbib}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%defining the bra and ket\n\\newcommand{\\bra}[1]{\\langle #1| }\n\\newcommand{\\ket}[1]{|#1 \\rangle }\n\n%here the definition used in text\n\\newcommand{\\brat}[1]{$\\langle #1|$ }\n\\newcommand{\\kett}[1]{$|#1 \\rangle $}\n\n%here define the math bold font for the vector operator:\n\\newcommand{\\hei}[1]{\\mathbf{\\hat{#1}} }\n\\newcommand{\\heit}[1]{$\\mathbf{\\hat{#1}}$}\n\\newcommand{\\heiti}[1]{\\mathbf{#1} }\n\n%% define the mathbf type of characters\n\\newcommand{\\vect}[1]{$\\mathbf{#1}$}\n\n%% define the theorem enviroment for the whole text\n\\theoremstyle{definition}\\newtheorem{law}{Law}\n\\theoremstyle{plain}\\newtheorem{theorem}{Theorem}\n\\theoremstyle{remark}\\newtheorem{remark}{Remark}\n\\theoremstyle{axiom}\\newtheorem{axiom}{Axiom}\n\n\n%opening\n\\title{Matrix Element}\n\n\\begin{document}\n\n\\maketitle\nLet's start by considering the equation 10 in Yihan's note, there we generally\nhave:\n\\begin{equation}\n \\label{eq:1}\n\\langle\\Psi_{I}|\\Psi_{J}^{[x]}\\rangle = T_{I}T_{J}^{[x]} +\n\\sum_{ia}\\sum_{jb}T_{I,ia}T_{J,jb}\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{j}\\rangle\n\\end{equation}\nHere in this expression, we follow the general convention that to use $T$ to\nrepresent the Slater determinant coefficients in CIS state, to use $C$ to\ndesignate the MO coefficients, $\\Psi$ is used to refer to CIS state, and $\\Phi$\nmeans the Slater determinants, $\\varphi$ is MO.\n\nFor the index, all the capital letters such as $I,J,K,L$ etc. indicates it's\nCIS states, and the lowercase letter is used to refer to MO. $\\Phi^{a}_{i}$\nmeans the electron is excited from occupied orbital $i$ to virtual orbital $a$.\nFor simplicity, here in this derivation we omit the spin state. \n\nIn (\\ref{eq:1}), the first term $T_{I}T_{J}^{[x]}$ generally needs to solve the\nCP-CIS equation to get the response for CIS amplitude, now all the remaining\nproblems now concentrates on $\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{j}\\rangle$.\n\n\\section{The first step: general consideration}\n%\n%\n%\n%\nFor some general Slater determinant, we have:\n\\begin{equation}\n \\label{eq:2}\n\\Phi = \\frac{1}{\\sqrt{n!}}\n\\begin{vmatrix}\n   \\varphi_{1}(1) & \\varphi_{2}(1) & \\cdots & \\varphi_{n}(1) \\\\\n  \\varphi_{1}(2) & \\varphi_{2}(2) & \\cdots & \\varphi_{n}(2) \\\\\n  \\cdots & \\cdots & \\cdots & \\cdots                                \\\\\n  \\varphi_{1}(n) & \\varphi_{2}(n) & \\cdots & \\varphi_{n}(n) \\\\\n\\end{vmatrix}\n\\end{equation}\nFor it's derivatives, from mathematical derivation we know that:\n\\begin{equation}\n \\label{eq:3}\n\\Phi^{[x]} = \\sum_{p=1}^{n}\\frac{1}{\\sqrt{n!}}\n\\begin{vmatrix}\n   \\varphi_{1}(1) & \\varphi_{2}(1) & \\cdots & \n  \\frac{\\partial \\varphi_{p}(1)}{\\partial \\bm{x}} &\n   \\cdots & \\varphi_{n}(1) \\\\\n   \\varphi_{1}(2) & \\varphi_{2}(2) & \\cdots &\n   \\frac{\\partial \\varphi_{p}(2)}{\\partial \\bm{x}} &\n   \\cdots  & \\varphi_{n}(2) \\\\\n   \\cdots & \\cdots & \\cdots & \\cdots  & \\cdots   & \\cdots     \\\\\n   \\varphi_{1}(n) & \\varphi_{2}(n) & \\cdots & \n   \\frac{\\partial \\varphi_{p}(n)}{\\partial \\bm{x}}  \n   &\\cdots & \\varphi_{n}(n) \\\\\n\\end{vmatrix}\n\\end{equation}\n\nFirstly, let's think about the second order Slater\ndeterminants. After calculation, it turns out that\n$\\langle\\Phi|\\Phi^{[x]}\\rangle$ equals to\n$\\sum_{p}^{2}\\langle\\varphi_{p}|\\varphi^{[x]}_{p}\\rangle$. Hence we can suggest\nsome hypothesis below:\n\\begin{theorem}\n\\begin{equation}\n\\label{eq:8}\n \\langle\\Phi|\\Phi^{[x]}\\rangle =\n\\sum_{p}^{n}\\langle\\varphi_{p}|\\varphi^{[x]}_{p}\n\\rangle\n\\end{equation}\nestablishes for the $nth$ order Slater determinants.\n\\end{theorem}\n\nNow let's go to prove it by starting from the definition of determinant:\n\\begin{equation}\n \\label{eq:4}\n\\Phi = \\sum_{1\\leq i1<i2\\cdots<in\\leq n}(-1)^{P( i1, i2, \\cdots,\nin)}\\varphi_{i1}(1)\\varphi_{i2}(2)\\cdots\\varphi_{in}(n)\n\\end{equation}\n$P$ is the permutation operator.\n\nAccordingly, for $\\Phi^{[x]}$, we have similar expansion:\n\\begin{equation}\n \\label{eq:5}\n\\Phi^{[x]} = \\sum_{p}\\sum_{1\\leq i1<i2\\cdots<in\\leq n}(-1)^{P( i1, i2, \\cdots,\nin)}\\varphi_{i1}(1)\\varphi_{i2}(2)\\cdots\\varphi_{p}^{'}(k)\\cdots\\varphi_{in}(n)\n\\end{equation} \nWe use $\\varphi_{p}^{'}(n)$ to designate the MO derivatives.\n\nFor $\\langle\\Phi|\\Phi^{[x]}\\rangle$, we can see; there's always have MO\nderivatives in the ket. So generally we have have two cases:\n\\begin{itemize}\n \\item $\\ket{\\varphi_{p}^{'}}$ and $\\bra{\\varphi_{p}}$ have same electron\nresiding on\n \\item $\\ket{\\varphi_{p}^{'}}$ and $\\bra{\\varphi_{p}}$ have different electron\nresiding on\n\\end{itemize}\nFor the second situation, it's easy to see that $\\bra{\\varphi_{p}}$ is\nimpossible to find ``correct'' MO to make the integral equal to $1$. Hence the\nwhole expression, in the second situation will goes to zero.\n\nFor the first situation, it's easy to know that (below $p$ is fixed):\n\\begin{align}\n \\label{eq:6}\n&\\frac{1}{n!}\n\\begin{vmatrix}\n   \\varphi_{1}(1) & \\varphi_{2}(1) & \\cdots & \\varphi_{n}(1) \\\\\n  \\varphi_{1}(2) & \\varphi_{2}(2) & \\cdots & \\varphi_{n}(2) \\\\\n  \\cdots & \\cdots & \\cdots & \\cdots                                \\\\\n  \\varphi_{1}(n) & \\varphi_{2}(n) & \\cdots & \\varphi_{n}(n) \\\\\n\\end{vmatrix}\n\\begin{vmatrix}\n   \\varphi_{1}(1) & \\varphi_{2}(1) & \\cdots & \n  \\frac{\\partial \\varphi_{p}(1)}{\\partial \\bm{x}} &\n   \\cdots & \\varphi_{n}(1) \\\\\n   \\varphi_{1}(2) & \\varphi_{2}(2) & \\cdots &\n   \\frac{\\partial \\varphi_{p}(2)}{\\partial \\bm{x}} &\n   \\cdots  & \\varphi_{n}(2) \\\\\n   \\cdots & \\cdots & \\cdots & \\cdots  & \\cdots   & \\cdots     \\\\\n   \\varphi_{1}(n) & \\varphi_{2}(n) & \\cdots & \n   \\frac{\\partial \\varphi_{p}(n)}{\\partial \\bm{x}}  \n   &\\cdots & \\varphi_{n}(n) \\\\\n\\end{vmatrix} \\nonumber \\\\\n&= \\frac{1}{n!}\\sum_{i}^{n}\\langle\\varphi_{p}(i)|\\frac{\\partial\n\\varphi_{p}(i)}{\\partial \\bm{x}}\\rangle\n\\times\\langle\\bigtriangleup^{(p, i)}|\\bigtriangleup^{(p,\ni)}\\rangle \\nonumber \\\\\n&= \\frac{1}{n}\\sum_{i}^{n}\\langle\\varphi_{p}(i)|\\frac{\\partial\n\\varphi_{p}(i)}{\\partial \\bm{x}}\\rangle \\nonumber \\\\\n&=  \\langle\\varphi_{p}|\\frac{\\partial\n\\varphi_{p}}{\\partial \\bm{x}}\\rangle\n\\end{align}\nHere we have used the Laplace theorem to expand the Slater determinant, and \nin deriving the final conclusion we have used the relation that\nelectrons are indistinguishable.\n\nFinally, combined with expression in (\\ref{eq:3}), we get:\n\\begin{equation}\n \\label{eq:7}\n\\langle\\Phi|\\Phi^{[x]}\\rangle =\n\\sum_{p}^{n}\\langle\\varphi_{p}|\\varphi^{[x]}_{p}\\rangle\n\\end{equation}\n\n\\section{The second step: considering the CIS Slater determinants}\n%\n%\n%\n%\nSo far what we have demonstrated, is only for two identical determinants; the\nonly difference is that the one in the ket has MO derivatives. \nGenerally, for the CIS case, the integration of Slater determinants can have\nfollowing four\nchoices:\n\\begin{itemize}\n\\item $\\langle\\Phi^{a}_{i}|\\Phi^{a[x]}_{i}\\rangle$, which has been proved\n\\item $\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{i}\\rangle$, $a \\neq b$\n\\item $\\langle\\Phi^{a}_{i}|\\Phi^{a[x]}_{j}\\rangle$, $i \\neq j$\n\\item $\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{j}\\rangle$, $i \\neq j$ and $a \\neq\nb$\n\\end{itemize}\nWe can analyze each of the situation in the similar way.\n\nFor the second case, we may have the following possibilities:\n \\begin{itemize}\n \\item $\\ket{\\varphi_{b}^{'}}$, MO derivatives is on orbital b \n \\item $\\ket{\\varphi_{i}^{'}}$, MO derivatives is on orbital i \n \\item $\\ket{\\varphi_{p}^{'}}$, $p \\neq i$ and $p \\neq b$\n\\end{itemize} \nIn the third situation, it's easy to see the integral of\n$\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{i}\\rangle$ definitely goes to\nzero. Since the orbital b in the ket can not find its ``pair'' to make the\nintegral equal to 1. In the second situation,  while the MO derivatives is on\norbital i; for the same reason the integral will go to zero, too. Hence the MO\nderivatives can be only on orbital b.\n\nNext, let's consider the bra corresponds to $\\ket{\\varphi_{b}^{'}}$. It's easy\nto see only the integral below is not zero:\n\\begin{equation}\n \\label{eq:10}\n\\langle\\varphi_{a}|\\varphi_{b}^{'}\\rangle\n\\end{equation}\nSince if we have $\\bra{\\varphi_{p}}$ ($p \\neq a$), then the orbital a in the\nbra can not find its corresponding orbital in ket so that to make integral\nequal to 1.Hence finally, we see:\n\\begin{equation}\n\\label{eq:11}\n \\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{i}\\rangle =\n\\langle\\varphi_{a}|\\varphi_{b}^{'}\\rangle\n\\end{equation}\nSimilarly, for the $\\langle\\Phi^{a}_{i}|\\Phi^{a[x]}_{j}\\rangle$ we have:\n\\begin{align}\n\\label{eq:12}\n \\langle\\Phi^{a}_{i}|\\Phi^{a[x]}_{j}\\rangle &=\n\\langle\\varphi_{i}|\\varphi_{j}^{'}\\rangle \n\\end{align}\nand by applying the same technique, for the\n$\\langle\\Phi^{a}_{i}|\\Phi^{b[x]}_{j}\\rangle$ we can see it's always zero. \n\nFinally, we can express (\\ref{eq:1}) as:\n\\begin{equation}\n \\label{eq:13}\n\\begin{split}\n \\langle\\Psi_{I}|\\Psi_{J}^{[x]}\\rangle &= T_{I}T_{J}^{[x]} +\n\\sum_{ia}T_{I,ia}\\sum_{p}T_{J,ia}\\langle\\varphi_{p}|\\varphi^{[x]}_{p}\\rangle\n\\nonumber \\\\\n&+\\sum_{iab}T_{I,ia}T_{J,ib}\\langle\\varphi_{a}|\\varphi_{b}^{[x]}\\rangle\n+\\sum_{ija}T_{I,ia}T_{J,ja}\\langle\\varphi_{i}|\\varphi_{j}^{[x]}\\rangle \n\\end{split}\n\\end{equation}\n \nSo far we do not consider how to express the response the MO, what we do here\nis just to find a way converting the Sater determinants into the MO expression.\nIn the next step, we will begin to consider the detailed expression of\n$\\varphi^{[x]}$.\n\n\\section{Detailed discussion for $\\varphi^{[x]}$} \n%\n%\n%\nGenerally, the MO can be expressed as:\n\\begin{equation}\n \\label{eq:14}\n\\varphi_{p} = \\sum_{\\mu}C_{\\mu p}\\phi_{\\mu}\n\\end{equation}\nHence the MO derivatives can be expressed as:\n\\begin{equation}\n \\label{eq:15}\n\\varphi_{p}^{[x]} = \\sum_{\\mu}C^{[x]}_{\\mu p}\\phi_{\\mu} + \\sum_{\\mu}C_{\\mu\np}\\phi^{[x]}_{\\mu}\n\\end{equation}\nThe $C^{[x]}_{\\mu p}$ characterizes the MO response to the external Hamiltonian\nchange, and as we know; for occupied orbitals virtual part is added in, and for\nvirtual orbitals the occupied part added in. Hence determining from the\nexpression of (\\ref{eq:13}), it's clear that there will be no MO response terms\nappearing in the expression. Hence we can re-express the (\\ref{eq:15}) as:\n\\begin{equation}\n \\label{eq:16}\n\\varphi_{p}^{[x]} = \\sum_{\\mu}C_{\\mu p}\\phi^{[x]}_{\\mu}\n\\end{equation}\n\nNow we can bring in the (\\ref{eq:16}) into the (\\ref{eq:13}) to get the final\nexpression:\n\\begin{equation}\n \\label{eq:17}\n\\begin{split}\n \\langle\\Psi_{I}|\\Psi_{J}^{[x]}\\rangle &= T_{I}T_{J}^{[x]} +\n\\sum_{ia}T_{I,ia}T_{J,ia}\\sum_{p}^{ALL MO}\n\\sum_{\\mu}\\sum_{\\nu}C_{\\mu p}C_{\\nu p}\n\\langle\\phi_{\\mu}|\\phi^{[x]}_{\\nu}\\rangle\n\\nonumber \\\\\n&+\\sum_{iab}T_{I,ia}T_{J,ib}\\sum_{\\mu}\\sum_{\\nu}C_{\\mu a}C_{\\nu\nb}\\langle\\phi_{\\mu}|\\varphi_{\\nu}^{[x]}\\rangle \\nonumber \\\\\n&+\\sum_{ija}T_{I,ia}T_{J,ja}\\sum_{\\mu}\\sum_{\\nu}C_{\\mu i}C_{\\nu\nj}\\langle\\phi_{\\mu}|\\varphi_{\\nu}^{[x]}\\rangle \n\\end{split}\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "803d56cc14b24fcfeac7bdeeb19085dbd25e0004", "size": 11056, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "archived/matrix_element.tex", "max_stars_repo_name": "murfreesboro/fenglai-note", "max_stars_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-16T07:23:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-16T07:23:48.000Z", "max_issues_repo_path": "archived/matrix_element.tex", "max_issues_repo_name": "murfreesboro/fenglai-note", "max_issues_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "archived/matrix_element.tex", "max_forks_repo_name": "murfreesboro/fenglai-note", "max_forks_repo_head_hexsha": "7bdf943f681e54948cd68775a31e4c93a53a13f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4884488449, "max_line_length": 79, "alphanum_fraction": 0.6625361795, "num_tokens": 4009, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.40468770585086006}}
{"text": "\\documentclass [11pt, proquest] {thesis}[2015/03/03]\n \n\\setcounter{tocdepth}{1}  % Print the chapter and sections to the toc\n \n\\include{macros}\n\n%\\usepackage{fullpage}\n\\usepackage{hyperref}\n\\usepackage{microtype}\n\\usepackage{mathtools}\n\\usepackage[usenames,dvipsnames]{color}\n\\usepackage[pdftex]{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{url}\n%\\usepackage{thmtools}\n%\\usepackage{thm-restate}\n\n\\includeonly{\nchapters/1_introduction,\nchapters/2_outline_and_results,\nchapters/3_background,\nchapters/4_main_theorem,\nchapters/5_zero_sums,\nchapters/6_remarks_future_work,\n}\n\n\\newcommand{\\NN}{\\mathbb{N}}\n\\newcommand{\\B}{\\mathcal{B}}\n\\newcommand{\\qedb}{\\hfill $\\blacksquare$}\n\\newcommand{\\nrm}[1]{\\left\\|#1\\right\\|}\n\\newcommand{\\pr}{^{\\prime}}\n\\newcommand{\\Les}{L_E(s)}\n\\newcommand{\\Lams}{\\Lambda_E(s)}\n\\newcommand{\\Lfs}{L(f,s)}\n\\newcommand{\\ldLes}{\\frac{L_E\\pr}{L_E}(s)}\n\\newcommand{\\ldLfs}{\\frac{L_f\\pr}{L_f}(s)}\n\\newcommand{\\ldLe}[1]{\\frac{L_E\\pr}{L_E}\\left(#1\\right)}\n\\newcommand{\\ldLf}[1]{\\frac{L_f\\pr}{L_f}\\left(#1\\right)}\n\\newcommand{\\ldLam}[1]{\\frac{\\Lambda_E\\pr}{\\Lambda_E}\\left(#1\\right)}\n\\newcommand{\\ldatzero}{\\frac{L\\pr(E,0)}{L(E,0)}}\n\\newcommand{\\xbar}{\\overline{x}}\n\\newcommand{\\ybar}{\\overline{y}}\n\\newcommand{\\AGM}{\\text{AGM}}\n\\newcommand{\\conj}[1]{\\overline{#1}}\n\\newcommand{\\EQ}{E(\\QQ)}\n\\newcommand{\\EFp}{E(\\Fp)}\n\\newcommand{\\Ensfpe}{E_{\\text{ns}}(\\FF_{p^e})}\n\\newcommand{\\softO}{\\tilde{O}}\n\\newcommand{\\en}[1]{\\lVert #1 \\rVert}\n\n\\DeclareMathOperator{\\Li}{Li}\n\\DeclareMathOperator{\\sinc}{sinc}\n\n\n\\usepackage{alltt}  % \n\\newenvironment{demo}\n  {\\begin{alltt}\\leftskip3em\n     \\def\\\\{\\ttfamily\\char`\\\\}%\n     \\def\\{{\\ttfamily\\char`\\{}%\n     \\def\\}{\\ttfamily\\char`\\}}}\n  {\\end{alltt}}\n\n\\newtheorem{innercustomthm}{Theorem}\n\\newenvironment{quotedtheorem}[1]\n  {\\renewcommand\\theinnercustomthm{#1}\\innercustomthm}\n  {\\endinnercustomthm}\n  \n\\newtheorem{innercustomcor}{Corollary}\n\\newenvironment{quotedcorollary}[1]\n  {\\renewcommand\\theinnercustomcor{#1}\\innercustomcor}\n  {\\endinnercustomcor}\n  \n\\newtheorem{innercustomconj}{Conjecture}\n\\newenvironment{quotedconjecture}[1]\n  {\\renewcommand\\theinnercustomconj{#1}\\innercustomconj}\n  {\\endinnercustomconj}\n \n% metafont font.  If logo not available, use the second form\n%\n% \\font\\mffont=logosl10 scaled\\magstep1\n\\let\\mffont=\\sf\n% --- end-of-sample-stuff ---\n \n\n\\begin{document}\n \n% ==========   Preliminary pages\n\\prelimpages\n \n%\n% ----- copyright and title pages\n%\n\\Title{The Zeros of Elliptic Curve $L$-functions: \\\\\nAnalytic Algorithms with Explicit Time Complexity}\n\\Author{Simon Spicer}\n\\Year{2015}\n\\Program{UW Mathematics}\n\n\\Chair{William Stein}{Professor}{Mathematics}\n\\Signature{Ralph Greenberg}\n\\Signature{Neal Koblitz}\n\\Signature{Bernard Deconinck, GSR}\n\n\\copyrightpage\n\n% \\titlepage  \n\n% --- sample stuff only -----\n% unusual footnote not found in a real thesis\n% You just use the \\titlepage as commented out above\n\n{\\Degreetext{A dissertation submitted in partial fulfillment \\\\of the requirements for the degree of}\n \\def\\thefootnote{\\fnsymbol{footnote}}\n \\let\\footnoterule\\relax\n \\titlepage\n }\n\\setcounter{footnote}{0}\n\n% --- end-of-sample-stuff ---\n \n%\n% ----- signature and quoteslip are gone\n%\n\n%\n% ----- abstract\n%\n\\setcounter{page}{-1}\n\\abstract{%\nElliptic curves are central objects of study in modern-day algebraic number theory. The problem of how to determine the rank of a rational elliptic curve is a difficult one, and at the time of the writing of this thesis an unconditional general method for doing so is not known. \\\\\n\nIt has been known for decades that contingent on the Birch and Swinnerton-Dyer Conjecture, an algorithm to compute rank exists, but this algorithm has unknown time complexity. In the first part of this thesis we prove that, assuming standard conjectures, an {\\it effective} algorithm exists to compute rank with time complexity  that is polynomial in the curve's conductor. This method involves evaluating the $L$-function of the curve in question, and as such is practical for curves with conductors up to $\\sim 10^{16}$ on current computer architecture. \\\\\n\nThe second part of this work addresses the question of what can be done when the conductor is too large for the above method to be practical. To this end we exhibit an analytic method to bound rank from above that doesn't rely on directly evaluating an elliptic curve's $L$-function, and as such can be used on curves with very large conductors. Because this method involves sums over the imaginary parts of the zeros of an elliptic curve $L$-function, we also include results concerning the locations thereof, and an exposition of related quantities.\n}\n\n\\chapter*{Preface}\nI have attempted to emphasize accessibility and readability throughout this work. Specifically, no knowledge beyond standard graduate-level complex analysis and algebra is assumed, and advanced knowledge of number theoretic topics is {\\it not} required. As such, I hope that the results in this dissertation are accessible to a wide audience, even those at the advanced undergraduate level. Chapter 1 was written specifically to be a gentle introduction to the subject matter of this thesis. \\\\\n\nFor the expert I recommend skipping straight to Chapter 2, wherein the main results are stated. Proofs for these results can be found in Chapters 4 and 5 (from 5.2 onwards). \\\\\n\nFinally, a note on conjecture dependencies. Many of the results in this work are contingent on the validity of three of the major open conjectures in number theory: the Birch and Swinnerton-Dyer conjecture (BSD), the Generalized Riemann Hypothesis (GRH) and the ABC conjecture (ABC). For ease of exposition, instead of stating explicitly in a result which of the above conjectures are assumed, we will list the three-letter initial of each assumed conjecture after the heading of each result. For example, the following result:\n\\begin{proposition}[BSD]\nA rational elliptic curve with odd parity has a point of infinite order.\n\\end{proposition}\nmeans that this proposition follows under the assumption that BSD is true.\n\n%\n% ----- contents & etc.\n%\n\\tableofcontents\n%\\listoffigures\n%\\listoftables  % I have no tables\n \n%%\n%% ----- glossary \n%%\n%\\chapter*{Glossary}      % starred form omits the `chapter x'\n%\\addcontentsline{toc}{chapter}{Glossary}\n%\\thispagestyle{plain}\n%%\n%\\begin{glossary}\n%\\item[argument] replacement text which customizes a \\LaTeX\\ macro for\n%each particular usage.\n%\\item[back-up] a copy of a file to be used when catastrophe strikes\n%the original.  People who make no back-ups deserve\n%no sympathy.\n%\\item[control sequence] the normal form of a command to \\LaTeX.\n%\\item[delimiter] something, often a character, that indicates\n%the beginning and ending of an argument.\n%More generally, a delimiter is a field separator.\n%\\item[document class] a file of macros that tailors \\LaTeX\\ for\n%a particular document.  The macros described by this thesis\n%constitute a document class.\n%\\item[document option] a macro or file of macros\n%that further modifies \\LaTeX\\ for\n%a particular document.  The option {\\tt[chapternotes]}\n%constitutes a document option.\n%\\item[figure] illustrated material, including graphs,\n%diagrams, drawings and photographs.\n%\\item[font] a character set (the alphabet plus digits\n%and special symbols) of a particular size and style.  A couple of fonts\n%used in this thesis are twelve point roman and {\\sl twelve point roman\n%slanted}.\n%\\item[footnote] a note placed at the bottom of a page, end of a chapter,\n%or end of a thesis that comments on or cites a reference\n%for a designated part of the text.\n%\\item[formatter] (as opposed to a word-processor) arranges printed\n%material according to instructions embedded in the text.\n%A word-processor, on the other hand, is normally controlled\n%by keyboard strokes that move text about on a display.\n%\\item[\\LaTeX] simply the ultimate in computerized typesetting.\n%\\item[macro]  a complex control sequence composed of \n%other control sequences.\n%\\item[pica] an archaic unit of length.  One pica is twelve points and\n%six picas is about an inch.\n%\\item[point] a unit of length.  72.27 points equals one inch.\n%\\item[roman]  a conventional printing typestyle using serifs.\n%the decorations on the ends of letter strokes.\n%This thesis is set in roman type.\n%\\item[rule] a straight printed line; e.g., \\hrulefill.\n%\\item[serif] the decoration at the ends of letter strokes.\n%\\item[table] information placed in a columnar arrangement.\n%\\item[thesis] either a master's thesis or a doctoral dissertation.\n%This document also refers to itself as a thesis, although it\n%really is not one.\n% \n%\\end{glossary}\n \n%\n% ----- acknowledgments\n%\n\\acknowledgments{\nBy no means did I produce this dissertation in a vacuum. Many individuals have provided critical contributions over the course of my studies, and I am thankful to all of them. However, some I must mention specifically. Sincere thanks must be given to my advisor William Stein, who for many years has provided the patient mentorship and guidance needed to make this dissertation a reality; thank you too to the other members of my dissertation reading committee: Ralph Greenberg, Neal Koblitz and Bernard Deconinck. I would also like to extend a heartfelt thanks to the University of Washington department of Mathematics as a whole, and to the graduate student coordinator Brooke Miller in particular, for supporting me throughout my studies at UW. \\\\\n\nBeyond this, a number of mathematicians have given valuable advice. I am grateful for the correspondence with Barry Mazur on the explicit formula for elliptic curves, which was my entry point into the whole topic of elliptic curve $L$-functions; moreover I thank Peter Sarnak for his input on low-lying zeros of elliptic curve $L$-functions, and helping spur the formulation of the central idea of this thesis. John Cremona and Noam Elkies gave sage insight on the topics of the real period and regulator respectively. And I am grateful to John Voight, who used an early version of my rank estimation code and highlighted some significant bugs. And thanks must be given to Wei Ho, Jen Balakrishnan, Jamie Weigandt and Nathan Kaplan for putting up with my less-than-expert attempts to compute the ranks of large databases of elliptic curves. \\\\\n\nAnd last but not least, a huge thank you to my wife Kimberly for her constant unwavering support throughout. \n}\n\n%\n% ----- dedication\n%\n\\dedication{\\begin{center}To Kimberly and Bram, who comprise two thirds of the Spicer Theorem.\\end{center}}\n\n%\n% end of the preliminary pages\n \n%\n% ==========      Text pages\n%\n\\textpages\n \n% ========== Chapter 1\n\\chapter{Introduction}\n\\input{chapters/1_introduction}\n \n% ========== Chapter 2\n\\chapter{Problem Outline and Major Results}\\label{sec:outline_results}\n\\input{chapters/2_outline_and_results}\n \n% ========== Chapter 3 \n\\chapter{Notation, Definitions and Background}\\label{sec:defs_background}\n\\input{chapters/3_background}\n\n% ========== Chapter 4\n\\chapter{An Algorithm to Compute Rank}\\label{chap:main_theorem}\n\\input{chapters/4_main_theorem}\n\n% ========== Chapter 5\n\\chapter{Zero Sums}\n\\input{chapters/5_zero_sums}\n\n% ========== Chapter 6\n\\chapter{Remarks and Future Work}\n\\input{chapters/6_remarks_future_work}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\printendnotes\n\n%\n% ==========   Bibliography\n%\n\\nocite{*}   % include everything in the thesis.bib file\n\\bibliographystyle{acm}\n\\bibliography{bibliography}\n%\n% ==========   Appendices\n%\n\\appendix\n\\raggedbottom\\sloppy\n \n% ========== Appendix A\n \n\\chapter{Code Repo and Blog Posts}\n \nThe analytic rank estimation code mentioned in this thesis is hosted on GitHub, and is accessible to all free of charge under the GNU General Public License.\n\n\\begin{itemize}\n\\item The repo can be found at\n\\begin{description}\n\\item[] \\verb%https://github.com/haikona/GSoC_2014%\n\\end{description}\nThe relevant Sage Trac ticket is\n\\begin{description}\n\\item[]\\verb%http://trac.sagemath.org/ticket/16773%\n\\end{description}\n\n\\item Moreover, as it was being written the code was blogged about extensively; the posts on various aspects of the code's functionality can be found at\n\\begin{description}\n\\item[]  \\verb%http://mathandhats.blogspot.com/%\n\\end{description}\n\n\\end{itemize}\n\n\\vita{Simon Spicer was born and raised in Johannesburg, South Africa, but has spent the past six years in Seattle pursuing his mathematics PhD at the University of Washington. At the time of completing this thesis he and his wife Kimberly have just welcomed their first child, Bramwell, into the world. In his spare time Simon enjoys writing code, piloting airplanes and attempting to teach his family Afrikaans.}\n\n\n\\end{document}\n", "meta": {"hexsha": "2f85e653a7ce19d4cf17a6ad87d92863625def8a", "size": 12672, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis.tex", "max_stars_repo_name": "haikona/thesis", "max_stars_repo_head_hexsha": "d20302fc3aaf5a075329ebd36b233965b719c7d1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis.tex", "max_issues_repo_name": "haikona/thesis", "max_issues_repo_head_hexsha": "d20302fc3aaf5a075329ebd36b233965b719c7d1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis.tex", "max_forks_repo_name": "haikona/thesis", "max_forks_repo_head_hexsha": "d20302fc3aaf5a075329ebd36b233965b719c7d1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.9602649007, "max_line_length": 843, "alphanum_fraction": 0.7559185606, "num_tokens": 3287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.4046815659812165}}
{"text": "%!TEX root = ../main.tex\n\nThis chapter covers the steps needed to produce the wanted results. The input needed is a fiducial marker $M$ to provide the object position in the real world; and a 3D mesh $O$ which will be rendered in Augmented Reality. The output is a set of light sources $L_i$, each one having a position, orientation, intensity, color, type and size. In order to complete the luminance ($L()$) analysis a 360 panoramic image is required, but it will be generated as a previous step, it is not necessary to have one beforehand. The entirety of the process is layed out in the flowchart in Figure 1, and each step is described in more detail afterwards.\n\n\\begin{figure}[H]\n  \\centering\n  \\setlength{\\unitlength}{\\textwidth} \n    \\begin{picture}(1,0.5)\n       \\put(-0.1,0){\\includegraphics[width=1.3\\unitlength]{Figures/Flowchart.png}}\n       \n    \\end{picture}\n    \\caption{The method in a nutshell}\n\\end{figure}\n\n\\section{Capture 360 panoramic image}\nIn this work panoramic images are used as a tool, therefore it's not within the scope of the method to define a new way of capturing 360 images. The implementation will be based on the one by Chuang et al. \\cite{ThreeSixty}\n$M$ will provide the origin of the virtual world for placing and orienting $O$ within it. In order for the lights to be mapped to the same position as $M$ the user will be asked to place the marker in the desired position and start capturing the environment while the marker is centered in frame. This will also simplify calculations of light orientations later on.\n\n\\section{Image processing}\nOnce the panoramic image exist the first step in order to be able to analyze the luminance is to get rid of the chromatic information. This is achieved with the following equation:\n\n\\begin{equation}\n    L(R_{ij},G_{ij},B_{ij}) = 0,2126 \\times R_{ij} + 0,7152 \\times G_{ij} + 0,0722 \\times B_{ij}; \\quad \\forall \\  P_{ij}\n\\end{equation}\n\nWhere $L$ is the luminance obtained at D65 white point and $P$ is the pixel in the $i,j$ position of the image \\newline\nThe contrast ratio has to be adjusted, so that the regions with high luminance are more clearly differentiable. \n\n\\begin{equation}\n     g(i,j) = \\alpha \\times f(i,j) + \\beta\n\\end{equation}\n\nWhere $g(i,j)$ is the adjusted image, $f(i,j)$ is the original grayscale image and $\\alpha$ and $\\beta$ are the brightness and contrast constants, determined by parameter tuning. The parameter tuning will be carried out in a trial and error way, propose initial extreme values and run the program, changing the values in order to achieve the best result.\nIn order to prevent outlier pixels and noise from causing false positives, let $g(i,j)$ be normalized like so:\n\n\\begin{equation}\n    L(P_{ij}) = \\frac{ 2 \\times P_{ij} }{min(L) + max(L)}\n\\end{equation}\n\nWhere $min(L)$ and $max(L)$ are the overall minimum and maximum luminance values in the image. \n\\newline\nThe result of these steps is a black and white image with the rough shape of the light source. If the image ends up completely black it means there are no important visible light sources and ambient illumination alone would give a good enough result on the rendered model. A region of high luminance is defined as follows:\n\n\\begin{equation}\n    R(H) = \\{p_{00}, p_{01}, ... , p_{mn}\\}\n\\end{equation}\n Where $p_{ij}$ is the pixel in the i,j position of the image. Such that \n\\[\n    L(p_{ij}) > 0.9 \\times max(L(p_{ij})) \n\\]\n\nThe region must also be continuous, so the pixels must be adjacent.\\newline\nIf there are regions of high luminance in the image, they would be discovered with a fair amount of noise and artifacts, caused by clear objects, reflections of light sources on highly reflective surfaces, or even light sources that are so far away in the distance that don't really contribute an important amount of light to the area of interest. Therefore it's necessary to also add a relative size constraint to the definition. What constitutes an acceptable region size to deem the light source is not an easy question to answer. The best approach to face this problem is to define it as a percentage of the width and height of the overall image and tune the parameter in search for the best solution. The size constraint would therefore be:\n\n\\begin{equation}\n    width(R(H)) \\times height(R(H)) \\geq k \\times W \\times H\n\\end{equation}\n\nWhere $k$ is the parameter to be tuned; $W$ and $H$ are the total image width and height.\\newline\n\nThese constraints also help keep the amount of lights to be processed within an acceptable range for a real-time application, even if the real environment has many light sources a simplification of them is necessary when modelling them to keep the application feasible. Once the relevant light sources have been identified their properties need to be calculated.\n\n\\section{Calculate light properties}\nThe properties needed to calculate for each light are position, orientation, intensity, size and color. In the real world it is not trivial to calculate the position and size at the same time, because at least one of them would have to be known. Fortunately in the virtual world this is not necessary, as long as it is consistent, for the area size of the light the pixel measures can be used. With this in mind all the other properties can be calculated.\n\n\\begin{enumerate}\n\\item Width and height: The pixel measures will be used for this, they can me determined from the size constraint in the previous step.\n\\item Position: It is possible to calculate the distance from and object to a camera lens knowing a few parameters from the lens, namely the focal length and the sensor size. In Android these values are easily obtainable through the ExifInterface class. In iOS the values are publicly known per device family, so it's possible to create a lookup table with the values and have the application ask what device it's running on to match the necessary set of values. The calculation is then done as follows:\n\n\\begin{equation}\n    d(L_i) = \\frac{ f \\times h_i}{sensorHeight}\n\\end{equation}\n\n\\item  Orientation: Since the user was enforced to capture the environment starting from the north and the environment is the entire 360 degrees it is easy to map the pixel width to the angle of incidence of the light source. We can for example define the following ratio to calculate the angle:\n\n\\begin{equation}\n    \\phi = \\frac{pos(L_i)_x \\times 180}{imageWidth \\times 0.5}\n\\end{equation}\n\n\\item Color: Storing both versions of the panorama, one in full color and another one after processing will allow us to have both the color and the luminance information. Once a light source is detected, the equivalent area in the color image can be averaged to determine the color of the light source.\n\\item Type: There are two main shapes of lamps in the real world, quadrilateral and elliptical. It is indeed possible to find lights with more complex shapes, however, as long as the area of emission is the same, simplifying it to a quadrilateral or elliptical shape yields the same result for the purposes of the method.\n\\newline \nDetermining if the light is a spotlight or an area light will be done through the shape. Elliptical lights will be tagged spotlights and quadrilateral lights area light. Shape detection will be carried out using OpenCV contour detection and counting the vertices of the contour. Even if in the real world the light is a perfect square and the camera is facing it with no parallax it is expected that,  due to artifacts and noise, the function may not find exactly 4 vertices. This is not a big problem, because the number of vertices needed to create smooth circle range in the dozens. So adjusting a threshold value is a simple and acceptable solution.\n\\end{enumerate}\n\n\\section{Calculate ambient light}\nEnvironment mapping is an image-based technique to approximate the appearance of the overall light conditions of an environment. This is accomplished by means of a precomputed texture image mapped as a far-away environment surrounding. Said surrounding is usually a geometric surface, when Blinn first introduced the method\\cite{Blinn76} a sphere was used. Nowadays there are other alternatives, such as cube, paraboloid, pyramid or cylinder maps. The principle for each surface is the same, but the way to map a planar image onto the surface varies per surface.\\newline\nSince a panoramic image of the environment is already available using it to implement environment mapping would be an adequate use of resources. In order to generate an environment map it is necessary that the panorama is made into a High Dynamic Range image. This is because the Low Dynamic Range image captured directly from the device camera fails to capture the information necessary to simulate correct color balance, shadows, and highlights of the lighting environment; ultimately producing both inaccurate and less visually pleasing results. This has been illustrated by Paul Debevec.\\cite{DebevecRSO}\\newline \nA relatively easy and effective way to make an image into an HDR version is a technique called Tone Mapping, in which versions with different exposure values of the same image are blended together to include the full range of highlights and shadows of the overexposed and underexposed versions in a single image. Since asking the user to capture the environment more than once would have a bad impact on user friendliness, and also it's highly unlikely that the produced image would have the exact same framing every time, the different exposure values for the Tone Mapping will be produced altering the brightness and contrast values of the base image using equation 2 once again. After that the HDR image is produced using Debevec's weighting algorithm\\cite{Debevec}.\\newline\nIt's important to disclaim that the Tone Mapping process will not yield an actual HDR image. In the first place, it will be a standard 24 bit image in the $0...255$ range, with highlight and shadow valued clipped. The upside to still going through this process nonetheless is that the environment will be described in a richer way, capturing the bright areas and the shadows better than the standard exposure image.\\newline\nAfter the HDR version of the panorama is created it can be used to have an actual ground truth about the environment light color and intensity at any given point in the virtual space. This will be detailed in the Real-time Phase step subsection.\n\n\\section{Real-time Phase}\nEverything proposed in the method may be accurate and could theoretically yield more convincing AR rendering, but it has to be tested in order to determine for sure if that is the case. That is the motivation for implementing a tailor made AR application where all actors come into play to prove or disprove the accuracy and feasibility of the composited virtual objects in the camera feed.\\newline\nThe system is intended to work with ARToolkit, which already has implemented an OpenGL ES 2.0 and an OpenSceneGraph context. OpenGL ES 2.0 allows for great flexibility for lighting, due to the fact that it doesn't have a fixed functionality way to make lighting, a custom made shader has to be made. All the fixed functionality variables from OpenGL, such as the gl\\_LightSource array are gone, left for every developer to implement the shader inputs and outputs however they see fit. So there won't be any concerns about getting the light parameters that OpenGL understands, the shader will just read an array of data and as long as the logic is well implemented everything will just work.\\newline\nThe virtual side of the application will have the set of lights, the model $O$ to display and the HDR environment mapped into a cylinder. For the object, a matte diffuse shader, a shiny plastic-like shader and a reflective metal-like shader will be implemented. For performance concerns a refractive glass-like shader or Fresnel effect will not be present. The cylinder with the environment will not be rendered as such, but it will be used to calculate the environment lighting and reflections on the shaders that have reflectivity, to emulate the effect of a raytracer within the OpenGL rasterizer. This effect is achieved with a per-vertex lighting shader.  The reflected color is calculated with the normal vector at a vertex of the surface, and the view vector. The reflection is calculated like so:\n\\begin{equation}\n    R = I - 2\\times dot(N,I) \\times N\n\\end{equation}\nWhere $I$ is the view vector and $N$ is the current vertex normal. GLSL has a shorthand method for equation 8 called reflect().\nThe light ray that is reflected by the object at the current point of the surface is same as R vector, so using it the color from the environment can be obtained and finally the reflected color is mixed with diffuse color of the object in the proportion defined in the material parameters. \\newline\nAfter the color of $O$ the influence of the light sources calculated on the pre-calculation phase on the current vertex will be calculated using Lambert's cosine law.", "meta": {"hexsha": "3551049e652948ccaea54d1ca0a50809e86b582f", "size": 12995, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Handins/Report/method.tex", "max_stars_repo_name": "samssonart/gmtThesisAR", "max_stars_repo_head_hexsha": "14813a2efb2e7fcf0aaf753ca68ab3ed7edcbd2e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Handins/Report/method.tex", "max_issues_repo_name": "samssonart/gmtThesisAR", "max_issues_repo_head_hexsha": "14813a2efb2e7fcf0aaf753ca68ab3ed7edcbd2e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Handins/Report/method.tex", "max_forks_repo_name": "samssonart/gmtThesisAR", "max_forks_repo_head_hexsha": "14813a2efb2e7fcf0aaf753ca68ab3ed7edcbd2e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 127.4019607843, "max_line_length": 804, "alphanum_fraction": 0.7876106195, "num_tokens": 2847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8221891130942472, "lm_q2_score": 0.4921881357207956, "lm_q1q2_score": 0.40467172678379193}}
{"text": "\\documentclass[10pt,a4paper]{book}\n\\usepackage[latin1]{inputenc}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\newcommand\\tab[1][1cm]{\\hspace*{#1}}\n\\author{Daniel Frederico Lins Leite}\n\\title{Probability}\n\\begin{document}\n\t\\section{Introduction}\n\t\\subsection{Subset}\n\t\n\t\\subsection{Population}\n\tA \\textbf{population} is defined as a collection of statistical units of the same nature whose quantifiable information we are interested in. The \tpopulation constitutes the reference universe during the study of a given statistical problem.\n\t\\subsection {Sample}\n\tA \\textbf{sample} is a \\textit{subset} of a \\textit{population} on which statistical studies are made in order to draw conclusions relative to the \\textit{population}.\n\t$w$ is a \"sample point\".\\\\\n\t$S$ is a \"sample space\" if\\\\\n\t\t\\tab $w$ is a \"sample point and $w \\in S$;\\\\\n\t\t\\tab and $\\forall_{i,j}{(w_i \\cap w_j = \\emptyset \\text{, if } i \\neq j)}$;\\\\\n\t\t\\tab and $w_1 \\cup w_2 \\cup ... \\cup w_n = S$.\\\\\n\t\tA is a \"family of events\" if is a set of \"sample points\"\\\\\n\t\t\\tab $A = \\{w\\}$ where $w$ is a \"sample point\"\\\\\n\t\t\\tab $A^\\complement = \\{w : w \\notin A\\}$\\\\\n\t\t\\tab $A \\cup B = \\{w: w \\in A \\lor w \\in B\\}$\\\\\n\t\t\\tab $A \\cap B = \\{w: w \\in A \\land w \\in B\\}$\\\\\n\t\t\\tab $S^\\complement = \\emptyset$\\\\\n\t\t\\tab $A \\cup A^\\complement = S$\\\\\n\t\t\\tab $A \\cap A^\\complement = \\emptyset$\\\\\n\t\t\\tab $A \\cap S = A$\\\\\n\t\t\\tab $A \\cup S = S$\\\\\n\t\t\\tab $A \\cup \\emptyset = A$\\\\\n\t\t\\tab $\\cup$ is commutative, associative, distributive\\\\\n\t\t\\tab $\\cap$ is commutative, associative, distributive\\\\\n\t\tP is a \"probability measure\" if is a mapping between S and the \"real numbers\" with the following properties:\\\\\n\t\t\\tab $P = f: S \\mapsto {\\rm I\\!R}$\\\\\n\t\t\\tab $P(A) = f(A)$\\\\\n\t\t\\tab $f(S) = \\sum_{\\forall i}{f(A_i)} = 1$\\\\\n\t\t\\tab $0 <= f(A) <= 1$\\\\\n\t\t\\tab if $A \\cap B = \\emptyset$ then $f(A \\cup B) = f(A) + f(B).$\\\\\n\t\t\\\\\n\t\tThe triplet (S,A,P) defines a \"probability system\", a consistent axiomatic theory of probability of finite \"sample spaces\".\n\t\t\\\\\n\t\t\"Conditional probability\" is the probability of \"family of events\" A, given that the \"family of events B\" occurred.\\\\\n\t\t$$P(A|B) \\triangleq \\frac{P(A \\cap B)}{P(B)}$$\\\\\n\t\t$A$ and $B$ are \"statistical independent\" if:\\\\\n\t\t$$P(A \\cap B) = P(A)*P(B)$$\n\t\twich can be extended to:\\\\\n\t\t$$ P\\big(\\bigcap_{\\forall i}{ A_i}\\big) = \\prod_{\\forall i}{P(A_i)} $$\\\\\n\t\tGiven the last two properties we have that the \"conditional property\" of two \"statistical independent\" \"family of events\" is:\\\\\n\t\t$$ P(A|B) = \\frac{P(A \\cap B)}{P(B)} = \\frac{P(A)*P(B)}{P(B)} = P(A) $$.\n\t\tThe \"Theorem of total probability\" states that:\\\\\n\t\t$$P(B) = \\sum_{\\forall i}{P(A_i|B)}$$\n\t\t\n\t\t\\section{Reference}\n\t\t\\begin{enumerate}\n\t\t\t\\item {The Concise Encyclopedia of Statistics - Yadolah Dodge}\n\t\t\\end{enumerate}\n\n\\end{document}", "meta": {"hexsha": "bb7a7dbe034f713c320ad1d3558a70bf288bf5b3", "size": 2826, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "texts/math/Handout.Probability.tex", "max_stars_repo_name": "xunilrj/sandbox", "max_stars_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2017-04-01T17:18:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T05:23:23.000Z", "max_issues_repo_path": "texts/math/Handout.Probability.tex", "max_issues_repo_name": "xunilrj/sandbox", "max_issues_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-05-24T13:36:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T06:44:20.000Z", "max_forks_repo_path": "texts/math/Handout.Probability.tex", "max_forks_repo_name": "xunilrj/sandbox", "max_forks_repo_head_hexsha": "f92c12f83433cac01a885585e41c02bb5826a01f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-20T01:07:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-22T14:55:38.000Z", "avg_line_length": 46.3278688525, "max_line_length": 242, "alphanum_fraction": 0.6415428167, "num_tokens": 1030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4045627253015856}}
{"text": "\\section{Test Plan}\nIn order to verify the correctness of the system the following tests were made:\n\\begin{enumerate}\n\t\\item \\textbf{Unit Tests}: following the \\textbf{bottom-up} strategy, each sub-module (Parallel Multiplier, Ripple Carry Adder Pipelined...), after completing the implementation, has a dedicated testbench in order to check the correctness of the single sub-module in isolation. Considering the fact that this test are \\textbf{trivial} (just checking if the sum or the product of some numbers is correct) the single modules were not separately implemented in python. So this part will not be showed in this documentation.\n\t\\item \\textbf{System Estimation Test}: in this phase, some testbenches were written with particular inputs. The aim of this test is only to check if the result will resemble the sigmoid curve by varying the inputs in time in an increasing way.\n\t\\item \\textbf{System Aimed Test}: after checking that the system is \\textit{likely} correct by the latter test, through a python script will be made a test with different inputs in the range considered and check, with an additional testbench, if the outputs are equal.\n\\end{enumerate}\n\\subsection{System Estimation Test}\nEven before checking the correctness of the output of the system by a given input, three \"estimation tests\" were made. The aim of these tests is just to obtain a sigmoid curve by setting each $x_{i}$ and $w_{i}$ and varying the bias $b$ in the range of $[-1; +1]$.\n\\subsubsection{Estimation Test 1}\nIn this case we have the \\textbf{following inputs}:\n\\begin{equation}\n\tx_{1} \\dots x_{10} = 0, w_{1} \\dots w_{10} = 0\n\\end{equation}\nThe bias b will vary in the whole range of $[-1, +1]$. Just to remind the sigmoid function curve, we \\textbf{expect to obtain a curve with an odd symmetry and a \"linear\" behaviour}, due to the fact that we are considering the values near zero of the curve:\n\\begin{figure}[H]\n\t\\centering\n\t\\caption{Sigmoid Function Plot}\n\t\\includegraphics[width=8cm]{img/sigmoid.png}\n\\end{figure}\nThe output of the system is the following:\n\\begin{figure}[H]\n\t\\centering\n\t\\caption{Output of the System 1}\n\t\\includegraphics[width=\\textwidth]{img/est_test_1.png}\n\\end{figure}\nThere are different replication of the system due to the fact that the bias b will \"turn back\" when he will get to his maximum. We can state that, by comparing the two figures, the \\textbf{first estimation test is passed}. \n\\subsubsection{Estimation Test 2}\n\\begin{equation}\n\tx_{1} \\dots x_{10} \\approx 1, w_{1} \\dots w_{10} \\approx 1\n\\end{equation}\nThe bias b will vary in the whole range of $[-1, +1]$. \\textbf{We expect to obtain a likely flat curve with some \"high values\"} due to the fact that the summation of the ten product is 10 and the sigmoid at that value tends to 1.\n\\begin{figure}[H]\n\t\\centering\n\t\\caption{Output of the System 2}\n\t\\includegraphics[width=\\textwidth]{img/est_test_2.png}\n\\end{figure}\nThe output of the system is similar to a flat curve. We can state that, by comparing the system output with what we expected, the \\textbf{second estimation test is passed}.\n\\subsubsection{Estimation Test 3}\n\\begin{equation}\n\tx_{1} \\dots x_{10} \\approx -1, w_{1} \\dots w_{10} \\approx 1\n\\end{equation}\nThe bias b will vary in the whole range of $[-1, +1]$.\\textbf{ We expect to obtain a likely flat curve with some \"low values\"} due to the fact that the summation of the ten product is -10.\n\\begin{figure}[H]\n\t\\centering\n\t\\caption{Output of the System 3}\n\t\\includegraphics[width=\\textwidth]{img/est_test_3.png}\n\\end{figure}\nThe curve is flat with low values but we can notice some \\textit{noise}. This is due to the fact that to obtain a proper output some clock cycles are needed: this will lead to obtain intermediate results that are not good. But we can state that, by comparing the system output with what we expected, the \\textbf{third estimation test is passed}.\n\\subsection{System Aimed Test}\nAt this point will be carried out some tests with the same inputs using the \\textbf{Perceptron} architecture realized at this point and a \\textit{python script} which will simulate the desired behaviour of the \\textbf{Perceptron}. The latter is described through the following script:\n\n\\begin{lstlisting}[language=python]\nimport math\n\ndef get_outputs(i, x, w, b):\n\tprint(f\"################### TEST #{i} ###################\")\n\tprint(f\"X: {x}\")\n\tprint(f\"W: {w}\")\n\tprint(f\"b: {b}\")\n\t\n\tsum = summation(x, w, b)\n\tprint(f\"Sum result:\\t\\t\\t\\t {sum}\")\n\t\n\tf_z = sigmoid_output(sum)\n\tprint(f\"Sigmoid output:\\t\\t\\t {f_z}\")\n\t\n\t#the sum with 12 bits\n\tsum_in_circuit = round(sum/lsb_in)\n\tprint(f\"Sum value quantized:\\t {sum_in_circuit}\")\n\n\tf_z_in_circuit = round(f_z/lsb_out)\n\tprint(f\"Output value quantized:\\t {f_z_in_circuit}\")\n\ndef summation(x, w, b):\n\tsum = 0\n\tfor i in range(0, 10):\n\t\tsum += x[i]*w[i]\n\tsum += b\n\treturn sum\n\ndef sigmoid_output(s):\n\tres = (1)/(1 + math.exp(-s))\n\treturn res\n\nlsb_out = (1)/(2**15 - 1)\nlsb_in = (32)/(2**11 - 1)\n#Test #1\nx = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]\nw = [1,1,1,1,1,1,1,1,1,1]\nb = 0\nget_outputs(1, x, w, b)\n...\n#Other tests\n...\n\\end{lstlisting}\n\nBy running the python script the following output has been displayed in the console:\n\n\\begin{lstlisting}\n################### TEST #1 ###################\nX: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t -10\nSigmoid output:\t\t\t 4.5397868702434395e-05\nSum value quantized:\t -640\nOutput value quantized:\t 1\n################### TEST #2 ###################\nX: [-0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t -7.5\nSigmoid output:\t\t\t 0.0005527786369235996\nSum value quantized:\t -480\nOutput value quantized:\t 18\n################### TEST #3 ###################\nX: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t -5.0\nSigmoid output:\t\t\t 0.0066928509242848554\nSum value quantized:\t -320\nOutput value quantized:\t 219\n################### TEST #4 ###################\nX: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5]\nW: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]\nb: 0\nSum result:\t\t\t\t -2.5\nSigmoid output:\t\t\t 0.07585818002124355\nSum value quantized:\t -160\nOutput value quantized:\t 2486\n################### TEST #5 ###################\nX: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5]\nW: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nb: 0\nSum result:\t\t\t\t 0.0\nSigmoid output:\t\t\t 0.5\nSum value quantized:\t 0\nOutput value quantized:\t 16384\n################### TEST #6 ###################\nX: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5]\nW: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5]\nb: 0\nSum result:\t\t\t\t 2.5\nSigmoid output:\t\t\t 0.9241418199787566\nSum value quantized:\t 160\nOutput value quantized:\t 30281\n################### TEST #7 ###################\nX: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t 5.0\nSigmoid output:\t\t\t 0.9933071490757153\nSum value quantized:\t 320\nOutput value quantized:\t 32548\n################### TEST #8 ###################\nX: [0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t 7.5\nSigmoid output:\t\t\t 0.9994472213630764\nSum value quantized:\t 480\nOutput value quantized:\t 32749\n################### TEST #9 ###################\nX: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 0\nSum result:\t\t\t\t 10\nSigmoid output:\t\t\t 0.9999546021312976\nSum value quantized:\t 640\nOutput value quantized:\t 32766\n################### TEST #10 ###################\nX: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: 1\nSum result:\t\t\t\t 11\nSigmoid output:\t\t\t 0.999983298578152\nSum value quantized:\t 704\nOutput value quantized:\t 32766\n################### TEST #11 ###################\nX: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\nW: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\nb: -1\nSum result:\t\t\t\t -11\nSigmoid output:\t\t\t 1.670142184809518e-05\nSum value quantized:\t -704\nOutput value quantized:\t 1\n\\end{lstlisting}\n\nBy running a new testbench with \\textbf{likely} the same inputs the following results were displayed in \\textbf{Modelsim}:\n\\begin{figure}[H]\n\t\\centering\n\t\\caption{Output of the System 3}\n\t\\includegraphics[width=\\textwidth]{img/aimed_test.png}\n\\end{figure}\n\nA comparison with the outputs can be seen in the following table:\n\\begingroup\n\\setlength{\\tabcolsep}{10pt} % Default value: 6pt\n\\renewcommand{\\arraystretch}{2} % Default\n\\begin{center}\n\t\\begin{tabular}{|p{2cm}||p{2.4cm}|p{2.4cm}|p{2.4cm}|p{2.4cm}|}\n\t\t\\hline\n\t\t\\multirow{2}{*}{\\textbf{Test}}  & \\multicolumn{2}{|p{3cm}|}{\\textbf{Python Script}} & \\multicolumn{2}{|p{3cm}|}{\\textbf{Modelsim}} \\\\\n\t\t\\cline{2-5}\n\t\t & $round\\left(\\dfrac{z}{LSB}\\right)$ & $round\\left(\\dfrac{f(z)}{LSB}\\right)$ &  $round\\left(\\dfrac{z}{LSB}\\right)$ & $round\\left(\\dfrac{f(z)}{LSB}\\right)$ \\\\\n\t\t\\hline\n\t\tTest $\\#$1 & -640 & 1 & -638 (+2) & 1 (=)\\\\\n\t\tTest $\\#$2 & -480 & 18 & -479 (+1) & 18 (=)\\\\\n\t\tTest $\\#$3 & -320 & 219 & -319 (+1) & 225 (+5)\\\\\n\t\tTest $\\#$4 & -160 & 2486 & -160 (=) & 2482 (-4)\\\\\n\t\tTest $\\#$5 & 0 & 16384 & 0 (=) & 16384 (=)\\\\\n\t\tTest $\\#$6 & 160 & 30281 & 160 (=) & 30284 (+3)\\\\\n\t\tTest $\\#$7 & 320 & 32548 & 318 (-2) & 32541 (-7)\\\\\n\t\tTest $\\#$8 & 480 & 32749 & 478 (-2) & 32748 (-1)\\\\\n\t\tTest $\\#$9 & 640 & 32766 & 632 (-8) & 32765 (-1)\\\\\n\t\tTest $\\#$10 & 704 & 32766 & 696 (-8) & 32766 (=)\\\\\n\t\tTest $\\#$11 & -704 & 1 & -702 (+2) & 0 (-1)\\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{center}\n\\endgroup\n\nIn the latter table are compared the z and f(z) (See Equation (1) and (2) for further details) as they are represented in the architecture: with a C2 representation.\\\\ \nAs we can see in the latter table the outputs are \\textbf{likely} the same, with some few differences that can be ignored. These differences can be easily explained: \\textbf{Python's float} number will use \\textbf{64 bits} instead of 12 or 16 as in our case. This difference will change the outputs, in fact, in our case, the number $+1$ (\"01111111\" in base of $x_{i}$ with 8 bits), for example, can't be represented precisely with a finite number of bits: so, the higher number of bits are available, the higher precision will be granted. All things considered, we can state \\textbf{the system has passed the System Aimed Test} and, for our purpose, \\textbf{can be considered verified.}", "meta": {"hexsha": "ebc24ce2594688fcf5ca0fb2e639b321f44d7f8f", "size": 10364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/chapters/test_plan.tex", "max_stars_repo_name": "gerti98/Electronic-Systems-Project", "max_stars_repo_head_hexsha": "0691bbef06eb5a038c1324b3b8aa529d2346dbdc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/chapters/test_plan.tex", "max_issues_repo_name": "gerti98/Electronic-Systems-Project", "max_issues_repo_head_hexsha": "0691bbef06eb5a038c1324b3b8aa529d2346dbdc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/chapters/test_plan.tex", "max_forks_repo_name": "gerti98/Electronic-Systems-Project", "max_forks_repo_head_hexsha": "0691bbef06eb5a038c1324b3b8aa529d2346dbdc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8584070796, "max_line_length": 687, "alphanum_fraction": 0.6422230799, "num_tokens": 3790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371503, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.40456271887100725}}
{"text": "%\\documentclass{article}\n%\\usepackage{amsmath}\n%\\begin{document}\n\n\\section{Boundary layer turbulence model}\n{\\bf \\Large\n\\begin{tabular}{ccc}\n\\hline\n  Corresponding author & : & Seiya Nishizawa\\\\\n\\hline\n\\end{tabular}\n}\n\n\\def\\half{\\frac{1}{2}}\n\n\\subsection{Mellor-Yamada Nakanishi-Niino model}\nlevel 2.5\n\n\\begin{align}\n  \\frac{\\partial \\rho u}{\\partial t}\n  &= -\\frac{\\partial}{\\partial z} \\rho \\overline{u'w'}, \\\\\n  \\frac{\\partial \\rho v}{\\partial t}\n  &= -\\frac{\\partial}{\\partial z} \\rho \\overline{v'w'}, \\\\\n  \\frac{\\partial \\rho \\theta_l}{\\partial t}\n  &= -\\frac{\\partial}{\\partial z} \\rho \\overline{\\theta_l'w'}, \\\\\n  \\frac{\\partial \\rho q_a}{\\partial t}\n  &= -\\frac{\\partial}{\\partial z} \\rho \\overline{q_a'w'}, \\\\\n  \\frac{\\partial }{\\partial t}\\rho q^2\n  &= -2\\left(\\rho\\overline{u'w'}\\frac{\\partial u}{\\partial z}+\\rho\\overline{v'w'}\\frac{\\partial v}{\\partial z}\\right)\n  +2\\frac{g}{\\theta_0}\\rho\\overline{\\theta_v' w'}\n  -\\frac{\\partial}{\\partial z}\\rho\\overline{q^2w'}\n  -2\\rho\\epsilon, \\label{eq: q2}\n\\end{align}\nwhere:\n\\begin{equation}\n  q_a = q_v + q_c + q_r + q_i + q_s + q_g,\n\\end{equation}\nand $q^2$ is doubled turbulence kinetic energy:\n\\begin{equation}\n  q^2 = u'^2 + v'^2 + w'^2.\n\\end{equation}\n\nThe higher order moments and the dissipation term are parameterized as follows:\n\\begin{align}\n  \\overline{u'w'} &= -LqS_M\\frac{\\partial u}{\\partial z}, \\\\\n  \\overline{v'w'} &= -LqS_M\\frac{\\partial v}{\\partial z}, \\\\\n  \\overline{\\theta_l'w'} &= -LqS_H\\frac{\\partial \\theta_l}{\\partial z}, \\\\\n  \\overline{q_a'w'} &= -LqS_H\\frac{\\partial q_a}{\\partial z}, \\\\\n  \\overline{q^2w'} &= -3LqS_M\\frac{\\partial q^2}{\\partial z}, \\\\\n  \\overline{\\theta_v' w'} &= \\beta_\\theta\\overline{\\theta_l'w}'+\\beta_q\\overline{q_a'w'}, \\\\\n  \\epsilon &= \\frac{q^3}{B_1L},\n\\end{align}\nwhere:\n\\begin{align}\n  S_M &= \\alpha_cA_1\\frac{\\Phi_3-3C_1\\Phi_4}{D_{2.5}}, \\\\\n  S_H &= \\alpha_cA_2\\frac{\\Phi_2+3C_1\\Phi_5}{D_{2.5}}, \\\\\n  \\beta_\\theta &= 1 + 0.61 q_a - 1.61 Q_l - \\tilde{R} abc, \\\\\n  \\beta_q &= 0.61\\theta + \\tilde{R} ac.\n\\end{align}\n\n\\begin{align}\n  D_{2.5} &= \\Phi_2\\Phi_4 + \\Phi_5\\Phi_3, \\\\\n  \\Phi_1 &= 1-3\\alpha_c^2A_2B_2(1-C_3)G_H, \\\\\n  \\Phi_2 &= 1-9\\alpha_c^2A_1A_2(1-C_2)G_H, \\\\\n  \\Phi_3 &= \\Phi_1+9\\alpha_c^2A_2^2(1-C_2)(1-C_5)G_H, \\\\\n  \\Phi_4 &= \\Phi_1-12\\alpha_c^2A_1A_2(1-C_2)G_H, \\\\\n  \\Phi_5 &= 6\\alpha_c^2A_1^2G_M, \\\\\n  \\alpha_c &= \\left\\{\n  \\begin{array}{ll}\n    q/q_2, & q<q_2 \\\\\n    1, & q \\ge q_2\n  \\end{array}\n  \\right. , \\\\\n  G_M &= \\frac{L^2}{q^2}\\left\\{\\left(\\frac{\\partial u}{\\partial z}\\right)^2 + \\left(\\frac{\\partial v}{\\partial z}\\right)^2\\right\\}, \\\\\n  G_H &= -\\frac{L^2}{q^2}N^2, \\\\\n  R &= \\frac{1}{2}\\left\\{1+\\mathrm{erf}\\left(\\frac{Q_1}{\\sqrt{2}}\\right)\\right\\}, \\\\\n  \\tilde{R} &= R - \\frac{Q_l}{2\\sigma_s}\\frac{1}{\\sqrt{2\\pi}}\\exp\\left(-\\frac{q_1^2}{2}\\right), \\\\\n  Q_l &= 2\\sigma_s\\left\\{RQ_1+\\frac{1}{\\sqrt{2\\pi}}\\exp\\left(-\\frac{Q_1^2}{2}\\right)\\right\\}, \\\\\n  Q_1 &= \\frac{a}{2\\sigma_s}(q_a-Q_{sl}), \\\\\n  \\sigma_s^2 &= \\frac{1}{4}a^2L^2\\alpha_cB_2S_H\\left(\\frac{\\partial q_a}{\\partial z} -b\\frac{\\partial \\theta_l}{\\partial z}\\right)^2, \\\\\n  \\delta Q_{sl} &= \\left.\\frac{\\partial Q_s}{\\partial T}\\right|_{T=T_l}, \\\\\n  a &= \\left(1+\\frac{L}{C_p}\\delta Q_{sl}\\right)^{-1}, \\\\\n  b &= \\frac{T}{\\theta}\\delta Q_{sl}, \\\\\n  c &= (1+0.61q_a - 1.61Q_l)\\frac{\\theta}{T}\\frac{L_v}{C_p} - 1.61\\theta,\n\\end{align}\nand $Q_{sl}$ is the saturation-specific humidity at temperature $T_l (=\\theta_l T/\\theta)$.\n\nThe buoyancy flux term, which is the third term on the left hand side of eq. \\ref{eq: q2} is:\n\\begin{align}\n  2\\frac{g}{\\theta_0}\\overline{\\theta_v' w'}\n  &= 2\\frac{g}{\\theta_0}\\left(-\\beta_\\theta LqS_H\\frac{\\partial \\theta_l}{\\partial z} - \\beta_q LqS_H\\frac{\\partial q_a}{\\partial z}\\right) \\nonumber \\\\\n  &= -2LqS_H\\frac{g}{\\theta_0}\\left(\\beta_\\theta\\frac{\\partial \\theta_l}{\\partial z}+\\beta_q\\frac{\\partial q_a}{\\partial z}\\right) \\nonumber \\\\\n  &= -2LqS_H\\frac{g}{\\theta_0}\\frac{\\partial \\theta_v}{\\partial z} \\nonumber \\\\\n  &= -2LqS_HN^2,\n\\end{align}\nwhere $N^2$ is the square of the Brunt-Vaisala frequency.\n\n\\begin{align}\n  \\frac{\\partial }{\\partial t}\\rho q^2\n  &= 2\\rho LqS_M\\left\\{\\left(\\frac{\\partial u}{\\partial z}\\right)^2\n                +\\left(\\frac{\\partial v}{\\partial z}\\right)^2\\right\\} \\nonumber\\\\\n  &-2\\rho LqS_HN^2\n  +\\frac{\\partial}{\\partial z}\\left(3\\rho LqS_M\\frac{\\partial}{\\partial z}q^2\\right)\n  -2\\rho\\frac{q^3}{B_1L}\n\\end{align}\n\n$S_{M2}, S_{H2}$, and $q_2$ are for level 2 schemes corresponding to $S_M, S_H$, and $q$, respectively:\n\\begin{align}\n  S_{M2} &= \\frac{A_1F_1}{A_2F_2}\\frac{R_{f1}-Rf}{R_{f2}-Rf} S_{H2}, \\\\\n  S_{H2} &= 3 A_2 (\\gamma_1 + \\gamma_2) \\frac{Rf_c - Rf}{1-Rf}, \\\\\n  q_2^2 &= B_1 L^2 S_{M2} (1-Rf) \\left\\{\\left(\\frac{\\partial u}{\\partial z}\\right)^2+\\left(\\frac{\\partial v}{\\partial z}\\right)^2\\right\\}.\n\\end{align}\n$Rf$ and $Rf_c$ are the flux Richardson number and the critical flux Richardson number, respectively.\nThe gradient Richardson number, $Ri$, is:\n\\begin{equation}\n  Ri = Rf \\frac{S_{M2}}{S_{H2}}.\n\\end{equation}\n$Rf$ is then:\n\\begin{align}\n  Rf &= \\frac{1}{2}\\frac{A_2F_2}{A_1F_1}\n  \\left\\{ Ri + \\frac{A_1F_1}{A_2F_2}R_{f1}\n        -\\sqrt{Ri^2+2\\frac{A_1F_1}{A_2F_2}(R_{f1}-2R_{f2})Ri+\\left(\\frac{A_1F_1}{A_2F_2}R_{f1}\\right)^2} \\right\\}, \\\\\n  Rf_C &= \\frac{\\gamma_1}{\\gamma_1+\\gamma_2}, \\\\\n\\end{align}\nwhere:\n\\begin{align}\n  R_{f1} &= B_1\\frac{\\gamma_1-C_1}{F_1}, \\\\\n  R_{f2} &= B_1\\frac{\\gamma_1}{F_2}.\n\\end{align}\n\nThe turbulent length scale, $L$, is determined by the smallest length scale among three scales:\n\\begin{equation}\n  \\frac{1}{L} = \\frac{1}{L_s} + \\frac{1}{L_T} + \\frac{1}{L_B}.\n\\end{equation}\nthe surface layer scale, $L_s$, the boundary layer scale, $L_T$, and buoyancy length scale, $T_B$:\n\\begin{align}\n  L_S &= \\left\\{\n  \\begin{array}{ll}\n    kz/3.7, & \\zeta \\ge 1 \\\\\n    kz/(1+2.7\\zeta), & 0 \\le \\zeta < 1 \\\\\n    kz(1-100\\zeta)^{0.2}, & \\zeta < 0\n  \\end{array}\n  \\right. , \\\\\n  L_T &= 0.23\\frac{\\int_0^\\infty qz dz}{\\int_0^\\infty q dz}, \\\\\n  L_B &= \\left\\{\n  \\begin{array}{ll}\n    q/N,                      & \\partial \\theta_v/\\partial z > 0 \\;\\mathrm{and}\\; \\zeta \\ge 0 \\\\\n    \\{1+5(q_c/L_TN)^{1/2}\\}q/N, & \\partial \\theta_v/\\partial z > 0 \\:\\mathrm{and}\\; \\zeta < 0 \\\\\n    \\infty, & \\partial \\theta_v/\\partial z \\le 0\n  \\end{array}\n  \\right. ,\n\\end{align}\nwhere $\\zeta$ is the dimensionless height:\n\\begin{equation}\n  \\zeta = \\frac{z}{L_M}.\n\\end{equation}\n$L_M$ is the Monin-Obukhov length:\n\\begin{equation}\n  L_M = -\\frac{\\theta_0 u_*^3}{kg\\overline{\\theta_v'w'}_g},\n\\end{equation}\nwhere $u_*$ is the friction velocity, and the subscript $g$ denotes the ground surface.\n$q_c$ is a velocity scale defined in a similar manner to convective velocity $w_*$, except that the depth $z_i$ of the convective boundary layer is replaced by $L_t$:\n\\begin{equation}\n  q_c = \\left\\{\\frac{g}{\\theta_0}\\overline{\\theta_v' w'}_gL_T\\right\\}^{1/3}\n\\end{equation}\n\n\n\\begin{align}\n  A_1 &= B_1\\frac{1-3\\gamma_1}{6}, \\\\\n  A_2 &= \\frac{1}{3\\gamma_1 B_1^{1/3} Pr_N}, \\\\\n  B_1 &= 24.0, \\\\\n  B_2 &= 15.0, \\\\\n  C_1 &= \\gamma_1 - \\frac{1}{3A_1B_1^{1/3}}, \\\\\n  C_2 &= 0.75, \\\\\n  C_3 &= 0.352, \\\\\n  C_5 &= 0.2, \\\\\n  \\gamma_1 &= 0.235, \\\\\n  \\gamma_2 &= \\frac{2A_1(3-2C_2)+B_2(1-C_3)}{B_1}, \\\\\n  F_1 &= B_1(\\gamma_1-C_1)+2A_1(3-2C_2)+3A_2(1-C_2)(1-C_5), \\\\\n  F_2 &= B_1(\\gamma_1+\\gamma_2)-3A_1(1-C_2), \\\\\n  Pr_N &= 0.74.\n\\end{align}\n\n\n\\subsubsection{Discretization}\nThe diffusion equations for $q^2a$ are solved implicitly:\n\\begin{align}\n  \\rho_k \\frac{(q^2_k)^{n+1}-(q^2_k)^n}{\\Delta t}\n  &= \n  2\\rho_k \\left[ (LqS_M)_k\\left\\{\\left(\\frac{\\partial u}{\\partial z}\\right)^2+\\left(\\frac{\\partial v}{\\partial z}\\right)^2\\right\\} + (LqS_HN^2)_k \\right] \\nonumber \\\\\n  &+ \\frac{1}{\\Delta z_k}\\left\\{ (3\\rho LqS_M)_{k+\\half} \\frac{(q^2_{k+1})^{n+1}-(q^2_k)^{n+1}}{\\Delta z_{k+\\half}} - (3\\rho LqS_M)_{k-\\half} \\frac{(q^2_k)^{n+1}-(q^2_{k-1})^{n+1}}{\\Delta z_{k-\\half}} \\right\\} \\nonumber \\\\\n  &-\\frac{2\\rho_k q_k}{B_1L_k}(q^2_k)^{n+1}.\n\\end{align}\n\\begin{equation}\n  a_k (q^2_{k+1})^{n+1} + b_k (q^2_k)^{n+1} + c_k (q^2_{k-1})^{n+1} = d_k,\n\\end{equation}\nwhere:\n\\begin{align}\n  a_k &= -\\frac{\\Delta t}{\\Delta z_{k+\\half}\\Delta z_k\\rho_k}(3\\rho LqS_M)_{k+\\half}, \\\\\n  b_k &= -a_k - c_k + 1 + \\frac{2\\Delta tq_k}{B_1L}, \\\\\n  c_k &= -\\frac{\\Delta t}{\\Delta z_k\\Delta z_{k-\\half}\\rho_k}(3\\rho LqS_M)_{k-\\half}, \\\\\n  d_k &= (q^2_k)^n + 2\\Delta t \\left[ LqS_M\\left\\{\\left(\\frac{\\partial u}{\\partial z}\\right)^2+\\left(\\frac{\\partial v}{\\partial z}\\right)^2\\right\\} - LqS_HN^2 \\right]\n\\end{align}\n\\begin{equation}\n  (q^2_k)^{n+1} = e_k (q^2_{k+1})^{n+1} + f_k,\n\\end{equation}\nwhere:\n\\begin{align}\n  e_k &= -\\frac{a_k}{b_k+c_ke_{k-1}}, \\\\\n  f_k &= \\frac{d_k-c_kf_{k-1}}{b_k+c_ke_{k-1}}.\n\\end{align}\n\nVertical fluxes for $\\rho u, \\rho v, \\rho\\theta, \\rho q_x$ are also solved implicitly.\nFor instance, the flux for $\\rho u$, $F_u$ is calculated by:\n\\begin{equation}\n  F_{u,k+\\half} = (\\rho LqSM)_{k+\\half}\\frac{u^{n+1}_{k+1}-u^{n+1}_k}{\\Delta z_{k+\\half}}.\n\\end{equation}\n$u^{n+1}$ is calculated as the same way with $q^2$, but:\n\\begin{align}\n  a_k &= -\\frac{\\Delta t}{\\Delta z_{k+\\half}\\Delta z_k\\rho_k}(\\rho LqS_M)_{k+\\half}, \\\\\n  b_k &= -a_k - c_k + 1, \\\\\n  c_k &= -\\frac{\\Delta t}{\\Delta z_k\\Delta z_{k-\\half}\\rho_k}(\\rho LqS_M)_{k-\\half}, \\\\\n  d_k &= u_k^n.\n\\end{align}\n\n%\\end{document}\n\n", "meta": {"hexsha": "621314e4ee66e0407a58f01b126bc11cc7823ef6", "size": 9253, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/descriptions/turbulence_mynn.tex", "max_stars_repo_name": "slayoo/scale", "max_stars_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-06-14T11:12:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T05:29:55.000Z", "max_issues_repo_path": "doc/descriptions/turbulence_mynn.tex", "max_issues_repo_name": "slayoo/scale", "max_issues_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-07-29T03:38:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-30T05:08:47.000Z", "max_forks_repo_path": "doc/descriptions/turbulence_mynn.tex", "max_forks_repo_name": "slayoo/scale", "max_forks_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-07-10T10:39:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-28T22:20:41.000Z", "avg_line_length": 40.5833333333, "max_line_length": 222, "alphanum_fraction": 0.612017724, "num_tokens": 4084, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.47268347662043286, "lm_q1q2_score": 0.40454669909391056}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{II}\n\n\\def\\ntitle{Algebraic Topology}\n\\def\\nlecturer{H.\\ Wilton}\n\n\\def\\nterm{Michaelmas}\n\\def\\nyear{2018}\n\n\\input{header}\n\n\\DeclareMathOperator{\\rel}{rel}\n\\newcommand{\\w}{\\vee}\n\\renewcommand{\\b}{\\partial} % boundary of a simplicial complex\n\\newcommand{\\interior}{\\mathring} % interior\n\\DeclareMathOperator{\\mesh}{mesh}\n\\DeclareMathOperator{\\St}{St} % star\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Introduction}\n\n\\begin{question}\n  Is the Hopf link really linked? More formally, is there a homeomorphism \\(\\R^3 \\to \\R^3\\) taking \\(H\\) to \\(U\\)?\n\\end{question}\n\n\\(H\\) can be realised as \\(S^1 \\amalg S^1 \\to \\R^3\\). For \\(U\\), we can consider \\(S^1 \\amalg S^1\\) as boundary of \\(D^1 \\amalg D^1\\) and the map extends to a map to discs.\n\nSo it makes sense to phrase the question as\n\n\\begin{question}\n  Does the Hopf link \\(\\eta: S^1 \\amalg S^1 \\to \\R^3\\)extend to a map of discs?\n\\end{question}\n\nThis is an example of an \\emph{extension problem}.\n\nHere is another example. Define the \\(n\\)-sphere \\(S^{n - 1} := \\{x \\in \\R^n: \\sum_{i = 1}^n x_i^2 = 1\\}\\), which sits inside \\(D^n = \\{x \\in \\R^n: \\sum_{i = 1}^n x_i^2 = 1\\}\\). We can ask:\n\n\\begin{question}\n  Does the identity map \\(\\id_{S^{n - 1}}: S^{n - 1} \\to S^{n - 1}\\) factor through \\(D^n\\)?\n\\end{question}\n\nTo gain some intuition, let's consider small \\(n\\). For \\(n = 1\\), \\(S^0 = \\{-1, 1\\}\\). The answer is no by Intermediate Value Theorem, or connectedness from topology. For \\(n = 2\\), this answer is again no by winding number argument. What about \\(n \\geq 3\\)?\n\nThese problems are hard because we have to consider continuous maps between two spaces, which are in general very big and hard to compute. On the other hand, a comparable algebraic problem is\n\n\\begin{question}\n  Does the map \\(\\id: \\Z \\to \\Z\\) factor through \\(0\\)?\n\\end{question}\n\nWell that's much much easier!\n\n\\section{The fundamental group}\n\nThroughout this course, ``maps'' mean continuous maps.\n\n\\subsection{Deforming maps and spaces}\n\n\\begin{definition}[homotopy]\\index{homotopy}\n  Let \\(f_0, f_1: X \\to Y\\) be maps. A \\emph{homotopy} between \\(f_0\\) and \\(f_1\\) is a map \\(F: X \\times [0, 1] \\to X\\) such that \\(F(x, 0) = f_0(x)\\) and \\(F(x, 1) = f_1(x)\\) for all \\(x \\in X\\).\n\n  If \\(F\\) exists, we say that \\(f_0\\) is \\emph{homotopic} to \\(f_1\\) and write \\(f_0 \\simeq f_1\\), or to emphasise the homotopy, \\(f_0 \\simeq_F f_1\\).\n\\end{definition}\n\n\\begin{notation}\n  \\(I = [0, 1]\\). We often write \\(f_t(x) = F(x, t)\\).\n\\end{notation}\n\n\\begin{eg}\n  If \\(Y\\) is a convex region in \\(\\R^n\\) then for any \\(f_0, f_1: X \\to Y\\), the \\emph{straightline homotopy} \\(F(x, y) = t f_1(x) + (1 - t) f_0(x)\\) is a homotopy \\(f_0 \\simeq f_1\\).\n\\end{eg}\n\n\\begin{definition}[relative homotopy]\n  If \\(Z \\subseteq X\\) and \\(F(z, t) = f_0(z) = f_1(z)\\) for all \\(z \\in Z, t \\in I\\), then \\(F\\) is a \\emph{homotopy relative to \\(Z\\)}, write \\(f_0 \\simeq_F f_1 \\rel Z\\).\n\\end{definition}\n\n\\begin{lemma}\n  The relation \\(\\simeq\\) (\\(\\rel Z\\)) is an equivalence relation on maps \\(X \\to Y\\).\n\\end{lemma}\n\n\\begin{proof}\n  Reflexivity and symmetry are easy. For transitivity, suppose \\(f_0 \\simeq_{F_0} f_1 \\simeq_{F_1} f_2\\). Let\n  \\[\n    F(x, t) =\n    \\begin{cases}\n      F_0(x, 2t) & t \\leq \\frac{1}{2} \\\\\n      F_1(x, 2t - 1) & t \\geq \\frac{1}{2}\n    \\end{cases}\n  \\]\n  which is the homotopy we need.\n\\end{proof}\n\n\\begin{definition}[homotopy equivalence]\\index{homotopy equivalence}\n  \\(f: X \\to Y\\) and \\(g: Y \\to X\\) is a \\emph{homotopy equivalence} if \\(g \\compose f \\simeq \\id_X\\) and \\(f \\compose g \\simeq \\id_Y\\). In this case we say \\(X\\) is homotopy equivalent to \\(Y\\) and write \\(X \\simeq Y\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(X = *\\), the space with one point and \\(Y = \\R^n\\). Let \\(f: * \\mapsto 0\\), \\(g\\) be the unique map \\(Y \\to X\\). Then \\(g \\compose f = \\id_X\\), and \\(f \\compose g = 0 \\simeq \\id_Y\\) via the straightline homotopy. Therefore \\(\\R^n\\) is homotopy equivalent to \\(*\\).\n\\end{eg}\n\n\\begin{definition}[contractible]\\index{contractible}\n  A space \\(X\\) is \\emph{contractible} if \\(X \\simeq *\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(X = S^1, Y = \\R^2 - \\{0\\}\\). Let \\(f: X \\to Y\\) be the natural inclusion and \\(g: Y \\to X, x \\mapsto \\frac{x}{\\norm x}\\). Then\n  \\begin{align*}\n    g \\compose f &= \\id_X \\\\\n    f \\compose g(x) &= \\frac{x}{\\norm x} \\in \\R^2\n  \\end{align*}\n  Although \\(Y\\) is not convex, for all \\(x, t\\), straightline homotopy \\(F(x, t)\\) between \\(f \\compose g\\) and \\(\\id_Y\\) satisfies \\(F(x, t) \\neq 0\\) so \\(f \\compose g \\simeq_F \\id_Y\\). Thus \\(X \\simeq Y\\).\n\\end{eg}\n\n\\begin{definition}[retract, deformation retract]\\index{retract}\\index{deformation retract}\n  Let \\(f: X \\to Y\\) and \\(g: Y \\to X\\). If \\(g \\compose f = \\id_X\\) then \\(X\\) is a \\emph{retract} of \\(Y\\).\n\n  If in addition \\(f \\compose g \\simeq \\id_Y \\rel f(X)\\) then we say \\(X\\) is a \\emph{deformation retract} of \\(Y\\).\n\\end{definition}\n\nNote that whenever we have \\(g \\compose f = \\id_X\\), \\(f\\) is injective so we can think \\(X\\) as being embedded in \\(Y\\). Informally, \\(Y\\) is ``as complicated'' as \\(X\\).\n\n\\begin{lemma}\n  Homotopy equivalence is an equivalence on topological spaces.\n\\end{lemma}\n\n\\begin{proof}\n  Symmetry and reflexivity are obvious. For transitivity, consider\n  \\[\n    \\begin{tikzcd}\n      X \\ar[r, \"f\", shift left] & Y \\ar[l, \"g\", shift left] \\ar[r, \"f\", shift left] & Z \\ar[l, \"g\", shift left]\n    \\end{tikzcd}\n  \\]\n  Need to show that \\(g \\compose (g' \\compose f') \\compose f \\simeq \\id_X\\) (and the other direction will follow similarly). By hypothesis \\(g' \\compose f' \\simeq_{F'} \\id_Y\\). Now\n  \\[\n    g(F'(f(x), t))\n  \\]\n  is a homotopy\n  \\[\n    g \\compose g' \\compose f' \\compose f \\simeq g \\compose \\id_Y \\compose f = g \\compose f \\simeq \\id_X.\n  \\]\n\\end{proof}\n\n\\subsection{The fundamental group}\n\n\\begin{definition}[path, loop]\\index{path}\\index{loop}\n  A \\emph{path} (from \\(x_0\\) to \\(x_1\\)) is a continuous map \\(\\gamma: I \\to X\\) (with \\(\\gamma(0) = x_0, \\gamma(1) = x_1\\)).\n\n  A \\emph{loop} (based at \\(x_0\\)) is a path from \\(x_0\\) to \\(x_0\\).\n\\end{definition}\n\n\\begin{definition}[homotopy of path]\\index{homotopy of path}\n  Let \\(\\gamma_0, \\gamma_1\\) be paths from \\(x_0\\) to \\(x_1\\). A \\emph{homotopy (of path)} from \\(\\gamma_0\\) to \\(\\gamma_1\\) is a homotopy\n  \\[\n    \\gamma_0 \\simeq_F \\gamma_1 \\rel \\{0, 1\\}.\n  \\]\n\\end{definition}\n\n\\begin{definition}[concatenation of path, constant path, inverse path]\n  Let \\(\\gamma\\) be a path from \\(x\\) to \\(y\\) and \\(\\delta\\) a path from \\(y\\) to \\(z\\).\n  \\begin{enumerate}\n  \\item The \\emph{concatenation} of \\(\\gamma\\) and \\(\\delta\\) is\n    \\[\n      (\\gamma \\cdot \\delta) (t) =\n      \\begin{cases}\n        \\gamma(2t) & t \\leq \\frac{1}{2} \\\\\n        \\delta(2t - 1) & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n  \\item The \\emph{constant} path (at \\(x\\)) is \\(c_x(t) = x\\).\n  \\item The \\emph{inverse path} to \\(\\gamma\\) is \\(\\overline \\gamma(t) = \\gamma(1 - t)\\).\n  \\end{enumerate}\n\\end{definition}\n\n\\begin{theorem}[fundamental group]\\index{fundamental group}\n  Let \\(x_0 \\in X\\). Let\n  \\[\n    \\pi_1(X, x_0) = \\{\\text{loops based at } x_0\\} / \\simeq.\n  \\]\n  This has a group structure with\n  \\begin{itemize}\n  \\item \\([\\gamma][\\delta] = [\\gamma \\cdot \\delta]\\),\n  \\item identity \\([c_{x_0}]\\),\n  \\item \\([\\gamma]^{-1} = [\\overline \\gamma]\\).\n  \\end{itemize}\n\n  We call \\(\\pi_1(X, x_0)\\) the \\emph{fundamental group} of \\(X\\) (based at \\(x_0\\)).\n\\end{theorem}\n\n\\begin{proof}\n  To prove the theorem, we need to check that multiplication and inverses are well-defined and the group axioms are satisfied.\n\n  \\begin{lemma}\n    If \\(\\gamma_0, \\gamma_1\\) are paths to \\(y\\) and \\(\\delta_0, \\delta_1\\) are paths from \\(y\\) and \\(\\gamma_0 \\simeq \\gamma_1, \\delta_0 \\simeq \\delta_1\\), then\n    \\[\n      \\gamma_0 \\cdot \\delta_0 \\simeq \\gamma_1 \\cdot \\delta_1.\n    \\]\n\n    Also \\(\\overline \\gamma_0 \\simeq \\overline \\gamma_1\\).\n  \\end{lemma}\n\n  \\begin{proof}\n    We only show for concatenation. Inverses are similar. Let \\(\\gamma_0 \\simeq_F \\gamma_1, \\delta_0 \\simeq_G \\delta_1\\). (proof by picture) Algebraically, the homotopy is given by\n    \\[\n      H(s, t) =\n      \\begin{cases}\n        F(s, 2t) & t \\leq \\frac{1}{2} \\\\\n        G(s, 2t - 1) & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n  \\end{proof}\n\n  Now we check that the group axioms are satisfied.\n\n  \\begin{lemma}\\leavevmode\n    \\begin{enumerate}\n    \\item \\((\\alpha \\cdot \\beta) \\cdot \\gamma \\simeq \\alpha \\cdot (\\beta \\cdot \\gamma)\\).\n    \\item \\(\\alpha \\cdot c_x \\simeq \\alpha \\simeq c_w \\cdot \\alpha\\).\n    \\item \\(\\alpha \\cdot \\overline \\alpha \\simeq c_w\\).\n    \\end{enumerate}\n  \\end{lemma}\n\n  \\begin{proof}\n    We show \\(1\\). The other two are similar. Let\n    \\[\n      \\delta =\n      \\begin{cases}\n        \\alpha(3t) & t \\leq \\frac{1}{3} \\\\\n        \\beta(3t - 1) & \\frac{1}{3} \\leq t \\leq \\frac{2}{3} \\\\\n        \\gamma(3t - 2) & \\frac{2}{3} \\leq t \\leq 1\n      \\end{cases}\n    \\]\n    Let\n    \\[\n      f_0(t) =\n      \\begin{cases}\n        \\frac{4}{3}t & t \\leq \\frac{1}{2} \\\\\n        \\frac{1}{3} + \\frac{2}{3} t & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n    and\n    \\[\n      f_1(t) =\n      \\begin{cases}\n        \\frac{2}{3}t & t \\leq \\frac{1}{2} \\\\\n        -\\frac{1}{3} + \\frac{4}{3}t & t \\geq \\frac{1}{2}\n      \\end{cases}\n    \\]\n    Note that \\(f_0 \\simeq f\\) as \\emph{paths} via the straightline homotopy in \\(I\\). But\n    \\begin{align*}\n      (\\alpha \\cdot \\beta) \\cdot \\gamma &= \\delta \\compose f_0 \\\\\n      \\alpha \\cdot (\\beta \\cdot \\gamma) &= \\delta \\compose f_1\n    \\end{align*}\n    so they are homotopic as path.\n  \\end{proof}\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = \\R^n, x_0 = 0\\). Consider a loop \\(\\gamma\\) in \\(\\R^n\\) based at \\(0\\). The straightline homotopy shows that \\(\\gamma \\simeq c_0\\) as path. Therefore \\(\\pi_1(\\R^n, 0) \\cong 1\\).\n\\end{eg}\n\n\\begin{lemma}\n  Let \\(f: X \\to Y\\) be such that \\(f(x_0) = y_0\\). There is a well-defined homomorphism\n  \\begin{align*}\n    f_*: \\pi_1(X, x_0) &\\to \\pi_1(Y, y_0) \\\\\n    [\\gamma] &\\mapsto [f \\compose \\gamma]\n  \\end{align*}\n  Furthermore,\n  \\begin{enumerate}\n  \\item if \\(f \\simeq f' \\rel \\{x_0\\}\\) then \\(f_* = f_*'\\).\n  \\item if \\(g: Y \\to Z\\) is another map then \\(f_* \\compose g_* = (f \\compose g)_*\\).\n  \\item \\((\\id_X)_* = \\id_{\\pi_1(X, x_0)}\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  Easy.\n\\end{proof}\n\nWe'd like to eliminate the dependence of \\(\\pi_1(X, x_0)\\) on \\(x_0\\), at least when \\(X\\) is path-connected. Suppose \\(x_0, x_1 \\in X\\). What do \\(\\pi_1(X, x_0)\\) and \\(\\pi_1(X, x_1)\\) have to do with each other, where \\(X\\) is path-connected?\n\nFix \\(\\alpha\\) a path from \\(x_0\\) to \\(x_1\\).\n\n\\begin{lemma}\n  There is a well-defined group homomorphism\n  \\begin{align*}\n    \\alpha_\\#: \\pi_1(X, x_0) &\\to \\pi_1(X, x_1) \\\\\n    [\\gamma] &\\mapsto [\\overline \\alpha \\cdot \\gamma \\cdot \\alpha]\n  \\end{align*}\n  Furthermore\n  \\begin{enumerate}\n  \\item if \\(\\alpha \\simeq \\alpha'\\) then \\(\\alpha_\\# = \\alpha_\\#'\\),\n  \\item \\((c_{x_0})_\\# = \\id_{\\pi_1(X, x_0)}\\),\n  \\item if \\(\\beta\\) is a path from \\(x_1\\) to \\(x_2\\), \\(\\beta_\\# \\compose \\alpha_\\# = (\\alpha \\cdot \\beta)_\\#\\).\n  \\item if \\(f: X \\to Y\\) then \\((f \\compose \\alpha)_\\# \\compose f_* = f_* \\compose \\alpha_\\#\\).\n  \\end{enumerate}\n\\end{lemma}\n\nNow it makes sense to talk about isomorphism type of the fundamental group of a path-connected space.\n\n\\begin{definition}[simply connected]\\index{simply connected}\n  If \\(X\\) is path-connected and \\(\\pi_1(X, x_0) \\cong 1\\) for some (i.e.\\ any) \\(x_0 \\in X\\) then we say \\(X\\) is \\emph{simply connected}.\n\\end{definition}\n\nOur last task is to understand what homotopies that don't fix basepoints do to the fundamental group.\n\n\\begin{lemma}\n  Suppose \\(f, g: X \\to Y\\) is such that \\(f \\simeq_F g\\). Define \\(\\alpha(t) = F(x_0, t)\\), a path from \\(f(x_0)\\) to \\(g(x_0)\\). Then the following diagram commutes:\n\\[\n  \\begin{tikzcd}\n    & \\pi_1(Y, f(x_0)) \\ar[dd, \"\\alpha_\\#\"] \\\\\n    \\pi_1(X, x_0) \\ar[ur, \"f_*\"] \\ar[dr, \"g_*\"] \\\\\n    & \\pi_1(Y, g(x_0))\n  \\end{tikzcd}\n\\]\ni.e.\\ \\(g_* = \\alpha_\\# \\compose f_*\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\([\\gamma] \\in \\pi_1(X, x_0)\\). We need to show that\n  \\[\n    [g \\compose \\gamma] = g_*[\\gamma] = \\alpha_\\# \\compose f_*[\\gamma] = [\\overline \\alpha \\cdot (f \\compose \\gamma) \\cdot \\alpha]\n  \\]\n  which is saying\n  \\[\n    g \\compose \\gamma \\simeq \\overline \\alpha \\cdot (f \\compose \\gamma) \\cdot \\alpha\n  \\]\n  as paths. Consider\n  \\begin{align*}\n    I \\times I &\\to Y \\\\\n    (s, t) &\\mapsto F(\\gamma(s), t)\n  \\end{align*}\n  Let \\(H\\) be the straightline homotopy in \\(I \\times I\\) between the yellow path and the brown path. Then \\(G \\compose H\\) is the homotopy we need.\n\\end{proof}\n\n\\begin{theorem}\n  If \\(f: X \\to Y, g: Y \\to X\\) is a pair of homotopy equivalences and \\(x_0 \\in X\\) then \\(f_*: \\pi_1(X, x_0) \\to \\pi_1(Y, f(x_0))\\) is an isomorphism.\n\\end{theorem}\n\n\\begin{proof}\n  Suffices to prove that \\(f_*\\) is bijective. Let \\(g \\compose f \\simeq_F \\id_X\\) and \\(\\alpha\\) be the path defined from \\(F\\) as above. Then\n  \\[\n    g_* \\compose f_* = (g \\compose f)_* = \\alpha_\\# \\compose \\id_{\\pi_1(X, x_0)} = \\alpha_\\#\n  \\]\n  so \\(f_*\\) is injective. Similarly it is surjective.\n\\end{proof}\n\n\\begin{corollary}\n  Contractible spaces are simply connected.\n\\end{corollary}\n\n\\section{Covering spaces}\n\n\\subsection{Definition and first examples}\n\n\\begin{definition}[covering space]\\index{covering space}\n  Let \\(p: \\hat X \\to X\\) be a map. An open set \\(U \\subseteq X\\) is \\emph{evenly covered} if there is a discrete space \\(\\Delta_U\\) and an identification \\(p^{-1}(U) = \\Delta_U \\times U\\) such that on \\(p^{-1}(U)\\), \\(p\\) coincides with projection to the second factor.\n\n  If every \\(x \\in X\\) has an evenly covered neighbourhood, we say that \\(p\\) is a \\emph{covering map} and \\(\\hat X\\) is a \\emph{covering space}\n\\end{definition}\n\nAlternatively, write \\(U_\\delta = \\{\\delta\\} \\times U\\). Then \\(p^{-1}(U) = \\coprod_{\\delta \\in \\Delta_U} U_\\delta\\). Write \\(p|_\\delta = p|_{U_\\delta}\\) which is a homeomorphism.\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\hat X = \\R, X = S^1\\) and define\n  \\begin{align*}\n    p: \\R &\\to S^1 \\\\\n    t &\\mapsto e^{2\\pi i t}\n  \\end{align*}\n  Let \\(1 \\in U \\subsetneq S^1\\). Choose a branch of \\(\\log\\) well-defined on \\(U\\) such that \\(\\log 1 = 0\\). Every point \\(\\hat z \\in p^{-1}(U)\\) can be written uniquely as\n  \\[\n    \\hat z = k + \\frac{\\log(z)}{2\\pi i}\n  \\]\n  where \\(z = p(\\hat z) \\in U\\) and \\(k \\in \\Z\\), i.e.\\ \\(p^{-1}(U) = \\Z \\times U\\). Thus \\(U\\) is evenly covered. The same proof shows that \\(p\\) is a covering map.\n\\item Let \\(\\hat X = X = S^1\\). Define\n  \\begin{align*}\n    p_n: S^1 &\\to S^1 \\\\\n    z &\\mapsto z^n\n  \\end{align*}\n  This is also a covering map by essentially the same proof by choosing a \\(n\\)th root of unity. In this case \\(\\Delta_n\\) is the \\(n\\)th roots of unity.\n\\item Let \\(\\hat X = S^2\\) and \\(G = \\Z/2\\Z\\) acts on \\(S^2\\) via the antipodal map. Let\n  \\[\n    X = \\hat X / G = \\{\\{x, -x\\}: x \\in S^2\\}\n  \\]\n  and \\(p: \\hat X \\to X\\) be the quotient map. The orbit space \\(X\\) can be identified with straightlines in \\(\\R^3\\) passing through the origin. Given a line \\(\\ell\\) through the origin, let\n  \\[\n    C_\\ell = \\{y \\in S^2: y \\text{ perpendicular to } \\ell\\}.\n  \\]\n  Then \\(S^2 - C_\\ell = U_+ \\amalg U_-\\). Let \\(U = p(U_+ \\amalg U_-)\\), an open neighbourhood of \\(\\ell\\) in \\(X\\). Note that \\(p|_{U_+}\\) and \\(p|_{U_-}\\) are both homeomorphisms onto \\(U\\). Thus \\(U\\) is evenly covered and \\(p\\) is a covering map. \\(X = \\R P^2\\) is the \\emph{real projective plane}.\n\\end{enumerate}\n\\end{eg}\n\nNote that in all three examples, for all points \\(x \\in X\\), the number of copies of \\(U\\) in \\(p^{-1}(U)\\) is the same. We give a name to such covering spaces:\n\n\\begin{definition}[\\(n\\)-sheeted]\n  A covering map \\(p: \\hat X \\to X\\) is \\emph{\\(n\\)-sheeted} where \\(n \\in \\N \\cup \\{\\infty\\}\\) if for all \\(x \\in X\\), \\(\\# p^{-1}(x) = n\\).\n\\end{definition}\n\n\\subsection{Lifting properties}\n\nLet \\(p: \\hat X \\to X\\) be a covering map throughout the section.\n\n\\begin{definition}[lift]\\index{lift}\n  A \\emph{lift} of \\(f: Y \\to X\\) to \\(\\hat X\\) is a map \\(\\hat f: Y \\to \\hat X\\) such that \\(f = p \\compose \\hat f\\), i.e.\\ the following diagram commutes:\n  \\[\n    \\begin{tikzcd}\n      & \\hat X \\ar[d, \"p\"] \\\\\n      X \\ar[ur, \"\\hat f\", dashed] \\ar[r, \"f\"] & X\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\n\\begin{lemma}[uniqueness of lift]\n  Suppose \\(f: Y \\to X\\) where \\(Y\\) is connected and locally path-connected. % in fact locally path-connected not necessary\n  Let \\(\\hat f_1, \\hat f_2: Y \\to \\hat X\\) are both lifts of \\(f\\). If there exists \\(y \\in Y\\) such that \\(\\hat f_1(y) = \\hat f_2(y)\\) then \\(\\hat f_1 = \\hat f_2\\).\n\\end{lemma}\n\n\\begin{proof}\n  Consider\n  \\[\n    S = \\{y \\in Y: \\hat f_1(y) = \\hat f_2(y)\\}.\n  \\]\n  Claim that \\(S\\) is both open and closed, from which the lemma follows immediately. Given \\(y_0 \\in Y\\), let \\(U\\) be an evenly covered neighbourhood of \\(f(y_0)\\) and \\(V \\subseteq \\hat f^{-1}(U)\\) a path-connected neighbourhood of \\(y_0\\). Let \\(y \\in V\\) be arbitrary. Need to show that \\(y_0 \\in S\\) if and only if \\(y \\in S\\). If \\(y_0 \\in S\\) then \\(\\hat f_1(y_0) = \\hat f_2(y_0) \\in U_\\delta\\) for some \\(\\delta \\in \\Delta_U\\). Let \\(\\alpha\\) be a path in \\(V\\) from \\(y_0\\) to \\(y\\). Then \\(f \\compose \\alpha\\) is a path from \\(f(y_0)\\) to \\(f(y)\\). Then \\(\\hat f_i \\compose \\alpha\\) is a path in \\(p^{-1}(U)\\) from \\(\\hat f_i(y_0)\\) to \\(\\hat f_i(y)\\). It follows that \\(\\hat f_i(y) \\in U_\\delta\\) so \\(\\hat f_1(y) = (\\delta, f(y)) = \\hat f_2(y)\\) so \\(y \\in S\\). The converse is identical.\n\\end{proof}\n\n\\begin{definition}[lift at a point]\n  Let \\(\\gamma: I \\to X\\) be a path with \\(\\gamma(0) = x_0\\). A (unique) lift of \\(\\gamma\\) to \\(\\hat X\\) such that \\(\\hat \\gamma(0) = \\hat x_0 \\in p^{-1}(x_0)\\) is called the \\emph{lift of \\(\\gamma\\) at \\(\\hat x_0\\)}.\n\\end{definition}\n\n\\begin{lemma}[path-lifting lemma]\\index{path-lifting lemma}\n  Let \\(\\gamma: I \\to X\\) be a path with \\(\\gamma(0) = x_0\\). For any \\(\\hat x_0 \\in p^{-1}(x_0)\\) there is a uniqueness \\(\\hat \\gamma\\) of \\(\\gamma\\) at \\(\\hat x_0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Uniqueness follows from the more general uniqueness of lift so suffices to show existence. Consider\n  \\[\n    S = \\{t \\in I: \\text{ lift of } \\gamma|_{[0, t]} \\text{ at } \\hat x_0 \\text{ exists}\\},\n  \\]\n  as \\(0 \\in S\\), the lemma follows if we can show \\(S\\) is both open and closed. Let \\(t_0 \\in I\\). Then \\(\\gamma(t_0) \\in U\\) for some evenly covered neighbourhood \\(U\\). There exists a path-connected neighbourhood \\(V\\) of \\(t_0\\) such that \\(\\gamma(V) \\subseteq U\\). Let \\(t \\in V\\). We'll prove that \\(t_0 \\in S\\) if and only if \\(t \\in S\\). By symmetry suffices to show one direction. Suppose \\(t_0 \\in S, t \\notin S\\). Since \\(t_0 \\in S\\), \\(\\hat \\gamma(t_0)\\) is well-defined so let \\(\\hat \\gamma(t_0) \\in U_\\delta\\). Since \\([t_0, t] \\subseteq V\\) (as \\(t \\notin S\\)), \\(\\gamma([t_0, t]) \\subseteq U\\) so the path\n  \\[\n    s \\mapsto\n    \\begin{cases}\n      \\hat \\gamma(s) & s \\leq t_0 \\\\\n      p_\\delta^{-1} \\compose \\gamma & t_0 \\leq s \\leq t\n    \\end{cases}\n  \\]\n  is a lift of \\(\\gamma|_{[0, t]}\\) so \\(t \\in S\\). Contradiction.\n\\end{proof}\n\n\\begin{lemma}\n  If \\(X\\) is path-connected the \\(p\\) is \\(n\\)-sheeted for some \\(n \\in \\N \\cup \\{\\infty\\}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(x, y \\in X\\) and \\(\\alpha\\) a path between them. Let \\(\\hat x \\in p^{-1}(x)\\) and let \\(\\hat \\alpha_{\\hat x}\\) be the unique lift of \\(\\alpha\\) at \\(\\hat x\\). Define a map\n  \\begin{align*}\n    p^{-1} (x) &\\to p^{-1}(y) \\\\\n    \\hat x &\\mapsto \\hat \\alpha_{\\hat x}(1)\n  \\end{align*}\n  Now replacing \\(\\alpha\\) with \\(\\overline \\alpha\\) defines an inverse to this map.\n\\end{proof}\n\n\\begin{definition}[degree of covering map]\\index{degree}\n  \\(n\\) is called the \\emph{degree} of \\(p\\).\n\\end{definition}\n\n\\begin{lemma}[homotopy lifting lemma]\\index{homotopy lifting lemma}\n  \\label{lem:homotopy lifting lemma}\n  Let \\(f_0: Y \\to X\\) be a map where \\(Y\\) is path-connected. Let \\(F: Y \\times I \\to X\\) be a homotopy with \\(F(\\cdot, 0) = f_0\\). Let \\(\\hat f_0: Y \\to \\hat X\\) be a lift of \\(f_0\\) to \\(\\hat X\\). Then there is a unique lift \\(\\hat F\\) of \\(F\\) to \\(\\hat X\\) such that \\(\\hat F(\\cdot, 0) = \\hat f_0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(y_0 \\in Y\\). Let \\(\\gamma_{y_0}(t) = F(y_0, t)\\) be a path. By path lifting lemma, there is a unique lift \\(\\hat \\gamma_{y_0}\\) such that \\(\\hat \\gamma_{y_0}(0) = \\hat f_0(y_0)\\) such that \\(\\hat F(y_0, t) = \\hat\\gamma_{y_0}(t)\\). By uniqueness of path lifting, this is the only choice for \\(\\hat F\\), but it is not clear that \\(\\hat F\\) is continuous.\n\n  We will construct a map that is obviously continuous and argue that it is also a lift. Fix \\(y_0\\). For all \\(t\\) there exists \\(U_t\\) an evenly covered neighbourhood of \\(F(y_0, t)\\). By definition of product topology,\n  \\[\n    (y_0, t) \\in V_t \\times J_t \\subseteq F^{-1}(U_t).\n  \\]\n  Compactness of \\(I\\) implies that \\(\\{y_0\\} \\times I\\) is covered by \\(V_1 \\times J_1, \\dots, V_n \\times J_n\\) where \\(t_i \\in J_i\\). Setting \\(V = \\bigcap_{i = 1}^n V_i\\) (and passing to a path-connected subset), we have \\(\\{y_0\\} \\times I\\) covered by \\(V \\times J_1, \\dots, V \\times J_n\\). Now define \\(\\tilde F\\) on \\(V \\times I\\) by\n  \\[\n    \\tilde F(y, t) = p_{\\delta_i}^{-1} \\compose F(y, t)\n  \\]\n  for \\(y \\in V, t \\in J_i\\). Need to check that \\(\\tilde F\\) is well-defined. Suppose \\(t \\in J_i \\cap J_j\\). Let \\(y \\in V\\). Choose \\(\\alpha\\) in \\(V\\) from \\(y_0\\) to \\(y\\) and let \\(\\alpha_t(s) = F(\\alpha(s), t)\\). Now \\(p_{\\delta_i}^{-1} \\compose \\alpha_t\\) is the lift of \\(\\alpha_t\\) at \\(\\hat F(y_0, t)\\). Same for \\(p_{\\delta_j}^{-1} \\compose \\alpha_t\\) so they are equal. Therefore their endpoints coincide: \\(p_{\\delta_i}^{-1} \\compose F(y, t) = p_{\\delta_j}^{-1} \\compose F(y, t)\\) . Thus \\(\\tilde F\\) is well-defined.\n\n  \\(\\tilde F\\) is clearly continuous and a lift of \\(F\\), so it remains to check that \\(\\tilde F = \\hat F\\) on \\(V \\times I\\). By construction \\(\\tilde F(y_0, 0) = \\hat F(y_0, 0)\\). Now \\(\\tilde F(\\alpha(\\cdot), 0)\\) is a lift of \\(f_0 \\compose \\alpha\\), so will agree with \\(\\hat f_0 \\compose \\alpha\\). So \\(\\tilde F(y, 0) = \\hat f_0(y)\\) for all \\(y \\in V\\). Finally \\(\\tilde F(y, \\cdot)\\) is a lift of \\(\\gamma_y\\) starting at \\(\\hat f_0(y)\\), so by uniqueness again, \\(\\tilde F(y, t) = \\tilde \\gamma_y(t) = \\hat F(y, t)\\) for all \\(y \\in V, t \\in I\\).\n\\end{proof}\n\nWe have discussed lifts of maps, paths and homotopies. Recall that homotopy of paths is a slightly stronger form of homotopy and the next lemma shows that indeed the lift of a homotopy of paths is a homotopy of paths:\n\n\\begin{lemma}\n  \\label{lem:lift of homotopy of paths}\n  Let \\(F: I \\times I \\to X\\) be a homotopy of paths and \\(\\hat F\\) be a lift of \\(F\\) to \\(\\hat X\\). Then \\(\\hat F\\) is also a homotopy of paths.\n\\end{lemma}\n\n\\begin{proof}\n  As \\(F\\) is a homotopy of path, \\(F(0, t) = x_0\\) for all \\(t\\). Consider \\(\\hat F(0, \\cdot): I \\to \\hat X\\). For any \\(t \\in I\\) we have\n  \\[\n    \\hat F(0, t) \\in p^{-1}(F(0, t)) = p^{-1}(x_0)\n  \\]\n  which is discrete. As \\(I\\) is connected \\(\\hat F(0, \\dots)\\) is constant. Same for \\(\\hat F(1, \\dots)\\) so \\(\\hat F\\) is a homotopy of paths.\n\\end{proof}\n\n\\subsection{Applications to calculations of fundamental groups}\n\n\\begin{lemma}\n  If \\(p: \\hat X \\to X\\) is a map, \\(x \\in X\\) and \\(\\hat x \\in p^{-1}(x)\\) then\n  \\[\n    p_*: \\pi_1(\\hat X, \\hat x) \\to \\pi_1(X, x)\n  \\]\n  is an injection.\n\\end{lemma}\n\n\\begin{proof}\n  Suppose \\([\\hat \\gamma] \\in \\ker p_*\\), i.e.\\ \\(p_*([\\hat \\gamma]) = [p\\compose \\hat \\gamma] = [\\gamma] = 1 \\in \\pi_1(X, x)\\). Then \\(\\gamma\\) is homotopic to the constant path. But by \\nameref{lem:homotopy lifting lemma} this lifts to homotopy between \\(\\hat \\gamma\\) and constant path.\n\\end{proof}\n\nAs last time, path lifting defines an \\emph{action} of \\(\\pi_1(X, x)\\) on \\(p^{-1}(x)\\) by\n\\begin{align*}\n  \\pi_1(X, x) \\times p^{-1}(x) &\\to p^{-1}(x) \\\\\n  ([\\gamma], \\hat x) &\\mapsto \\hat x . \\gamma\n\\end{align*}\nwhere \\(\\hat x . \\gamma\\) is the endpoint of the lift of \\(\\gamma\\) at \\(\\hat x\\). Note that by \\Cref{lem:lift of homotopy of paths} this is indeed in the fibre of \\(x\\). Furthermore it shows that this is well-defined. Finally note that this is a \\emph{right action} (ultimately because we defined concatenation of paths from left to right).\n\nGiven \\(G\\) action on \\(X\\), orbit-stabiliser says that there is a bijection between the left cosets of stabiliser \\(G_x\\) of an element \\(x\\) and the orbit \\(G^x\\). Furthermore, \\(G\\) has a natural action on the left cosets \\(G/G_x\\) such that the bijection is \\(G\\)-equivariant. Spelling this out (and use right action instead of left), we have\n\n\\begin{lemma}\n  Suppose \\(\\hat X\\) is path-connected and \\(x \\in X\\). Let \\(\\hat x \\in p^{-1}(x)\\). Then\n  \\begin{align*}\n    p_*\\pi_1(\\hat X, \\hat x) \\backslash \\pi_1(X, x) &\\to p^{-1}(x) \\\\\n    (p_* \\pi_1(\\hat X, \\hat x)) [\\gamma] &\\mapsto \\hat x. \\gamma\n  \\end{align*}\n  Furthermore, the map is equivariant.\n\\end{lemma}\n\n\\begin{proof}\n  Suffices to show that the action is transitive and the stabiliser of \\(\\hat x\\) is \\(p_* \\pi_1(\\hat X, \\hat x)\\). As \\(\\hat X\\) is path-connected there exists a path \\(\\hat \\gamma\\) between any two points in \\(p^{-1}(x)\\), whose image \\(\\gamma\\) under \\(p\\) is a loop bases at \\(x\\), and is the only loop whose lift is \\(\\hat \\gamma\\) by uniqueness. The stabiliser of \\(\\hat x\\) are precisely the homotopy classes of loops based at \\(x\\) whose lifts are loops based at \\(\\hat x\\), which is precisely \\(p_* \\pi_1(\\hat X, \\hat x)\\).\n\\end{proof}\n\n\\begin{definition}[universal cover]\\index{universal cover}\n  If \\(p: \\tilde X \\to X\\) is a covering map with \\(X\\) path-connected and \\(\\tilde X\\) simply connected then \\(\\tilde X\\) is called a \\emph{universal cover} of \\(X\\).\n\\end{definition}\n\n\\begin{corollary}\n  If \\(p: \\tilde X \\to X\\) is a universal cover and \\(p(\\tilde x) = x\\) then\n  \\begin{align*}\n    \\pi_1(X, x) &\\to p^{-1}(x) \\\\\n    [\\gamma] &\\mapsto \\tilde x . \\gamma\n  \\end{align*}\n  is an equivariant bijection.\n\\end{corollary}\n\nThe map is not only bijective, but also equivariantly so. Thus by looking into the universal cover we can recover information about the fundamental group of the base space.\n\n\\begin{eg}[fundamental group of \\(S^1\\)]\n  Consider \\(p: \\R \\to S^1, t \\mapsto e^{2\\pi it}\\) is a covering map. Since \\(\\R\\) is contractible, this is the universal cover so\n  \\begin{align*}\n    \\pi_1(S^1, 1) &\\to p^{-1}(1) = \\Z \\\\\n    [\\gamma] &\\mapsto 0. \\gamma\n  \\end{align*}\n  is a bijection. Therefore we can write down representative loops for each element of \\(\\pi_1(S^1, 1)\\). For \\(n \\in \\Z\\), let \\(\\tilde \\gamma_n(t) = nt\\) so \\(\\gamma_n = p \\compose \\tilde \\gamma_n\\) is a loop in \\(S^1\\) based at \\(1\\). As \\([\\gamma_n] \\mapsto n\\), these represent every element of \\(\\pi_1(S^1, 1)\\) uniquely.\n\n  To recover the group structure, note that for any \\(m, n \\in \\Z\\), \\(m + \\tilde \\gamma_n\\) is the lift of \\(\\gamma_n\\) at \\(m\\). On the other hand, the endpoint of the lift of \\(\\gamma_m \\cdot \\gamma_n\\) at \\(0\\) is \\(m + n\\), which is the endpoint of \\(m + \\tilde \\gamma_n\\). So\n  \\begin{align*}\n    m+n: [\\gamma_m \\cdot \\gamma_n] \\mapsto m + n\n  \\end{align*}\n  is a homomorphism. Thus\n  \\[\n    \\pi_1(S^1, 1) \\cong \\Z.\n  \\]\n\\end{eg}\n\n\\subsection{The fundamental group of \\(S^1\\)}\n\n\\begin{theorem}\n  \\(\\id_{S^1}\\) does not extend over \\(D^2\\), i.e.\\ \\(S^1\\) is not a retract of \\(D^2\\).\n\\end{theorem}\n\n\\begin{proof}\n  Suppose otherwise and \\(r: D^2 \\to S^1\\) is a retraction. Then \\(\\id_{S^1} = r \\compose i\\):\n  \\[\n    \\begin{tikzcd}\n      S^1 \\ar[r, \"\\id\"] \\ar[dr, \"i\"'] & S^1 \\\\\n      & D^2 \\ar[u, \"r\"]\n    \\end{tikzcd}\n  \\]\n  Look at the induced fundamental groups, we have\n  \\[\n    \\id_\\Z = r_* \\compose i_*\n  \\]\n  so\n  \\[\n    \\begin{tikzcd}\n      \\Z \\ar[r, \"\\id\"] \\ar[dr, \"i_*\"'] & \\Z \\\\\n      & 0 \\ar[u, \"r_*\"]\n    \\end{tikzcd}\n  \\]\n  Absurd.\n\\end{proof}\n\n\\begin{corollary}[Brouwer fixed point theorem]\\index{Brouwer fixed point theorem}\n  Every continuous map \\(f: D^2 \\to D^2\\) has a fixed point.\n\\end{corollary}\n\n\\begin{proof}\n  If there exists \\(f\\) such that \\(f(x) \\neq x\\) for all \\(x \\neq D^2\\) then we can construct a continuous retraction \\(r: D^2 \\to S^1\\): for all \\(x \\in D^2\\), let \\(r(x)\\) be the intersection of the ray from \\(f(x)\\) to \\(x\\) with \\(S^1\\) (well-defined since \\(f(x) \\neq x\\)). It is continuous. As \\(r\\) fixes \\(S^1\\) this is a retract.\n\\end{proof}\n\n\\begin{theorem}[fundamental theorem of algebra]\n  Every nonconstant polynomial \\(p: \\C \\to \\C\\) has a root.\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof]\n  Suppose \\(p(z) = z^d + a_{d - 1} z^{d - 1} + \\dots + a_1 z + a_0\\) has no root. Then \\(p: \\C \\setminus \\{0\\} \\to \\C \\setminus \\{0\\}\\). Let\n  \\begin{align*}\n    r: \\C \\setminus \\{0\\} &\\to S^1 \\\\\n    z &\\mapsto \\frac{z}{|z|}\n  \\end{align*}\n  be the usual retraction. Let \\(\\lambda_R(z) = Rz\\) for \\(R > 0\\) and consider \\(f_R\\) which is the composition\n  \\[\n    \\begin{tikzcd}\n      S^1 \\ar[r, \"\\lambda_R\"] & \\C \\setminus \\{0\\} \\ar[r, \"p\"] & \\C \\setminus \\{0\\} \\ar[r, \"r\"] & S^1\n    \\end{tikzcd}\n  \\]\n  as all these maps are homotopic, they induce the same map \\(f_*: \\Z \\to \\Z\\) which is multiplication by some number \\(m\\), independent of \\(R\\). When \\(R\\) is small, we can argue that \\(f_R\\) is homotopic to a constant map so \\(m = 0\\). When \\(R\\) is large, \\(p\\) is approximately \\(z \\mapsto z^d\\) so \\(m = d\\), contradiction.\n\\end{proof}\n\n\\subsection{Existence of universal covers}\n\n\\begin{theorem}\n  If \\(X\\) is path-connected and locally simply connected then \\(X\\) has a universal cover.\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof][non-examinable]\n  Let\n  \\[\n    \\mathfrak X = \\{\\gamma: I \\to X: \\gamma(0) = x_0\\}\n  \\]\n  and define \\(\\tilde X = \\mathfrak X /\\simeq\\), the homotopy classes of paths. Define\n  \\begin{align*}\n    p: \\tilde X &\\to X \\\\\n    [\\gamma] &\\mapsto \\gamma(1)\n  \\end{align*}\n  The verification is omitted.\n\\end{proof}\n\n\\subsection{The Galois correspondence}\n\n\\begin{definition}[covering space isomorphism]\\index{covering space isomorphism}\n  Let \\(X\\) be a path-connected topological space and \\(p_1: \\hat X_1 \\to X, p_2: \\hat X_2 \\to X\\) are covering spaces of \\(X\\). An \\emph{isomorphism of covering spaces} is a map \\(\\varphi: \\hat X_1 \\to \\hat X_2\\) such that \\(p_2 \\compose \\varphi = p_1\\).\n\n  If \\(\\hat x_1, \\hat x_2\\) are bases points and \\(\\varphi(\\hat x_1) = \\hat x_2\\), we say \\(\\varphi\\) is \\emph{based}.\n\\end{definition}\n\n\\begin{remark}\n  \\(\\varphi\\) is a lift of \\(p_1\\) to \\(\\hat X_2\\).\n\\end{remark}\n\n\\begin{theorem}[Galois correspondence with base points]\\index{Galois correspondence}\n  Let \\(X\\) be path-connected, locally simply connected space and \\(x_0 \\in X\\). Then there is a bijection between based isomorphism class of path-connected covering space \\(p: (\\hat X, \\hat x_0) \\to (X, x_0)\\) and subgroups of \\(\\pi_1(X,x_0)\\), given by\n  \\[\n    \\hat X \\mapsto p_*\\pi_1(\\hat X, \\hat x_0).\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Non-examinable and omitted.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^1\\), we have path-connected covering space \\(p: \\R \\to S^1, t \\mapsto e^{2\\pi it}\\) and \\(p_n: S^1 \\to S^1, z \\mapsto z^n\\). The subgroups of \\(\\Z\\) are precisely \\(n\\Z\\). It is easy to see that \\(p\\) corresponds to \\(0\\) and \\(p_n\\) corresponds to \\(n\\Z\\). Galois correspondence then tells us that these are all the path-connected covering space of \\(S^1\\) up to isomorphism.\n\\end{eg}\n\n\\begin{corollary}\n  Let \\(X\\) be ``reasonable''. Then any two universal covers \\(p_1: \\tilde X_1 \\to X, p_2: \\tilde X_2 \\to X\\) are isomorphic.\n\\end{corollary}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\n%If we insist that the base space is locally simply connected so there exists\n\n\\begin{corollary}\n  Let \\(X\\) be path-connected, locally simply connected and \\(x_0 \\in X\\). Then there is a bijection between isomorphism class of path-connected covering space \\(p: (\\hat X, \\hat x_0) \\to (X, x_0)\\) and subgroups of \\(\\pi_1(X, x_0)\\) modulo conjugation, given by\n  \\[\n    \\hat X \\mapsto p_*\\pi_1(\\hat X, \\hat x_0).\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Surjectivity of the map follows from immediately from the previous theorem. We need to prove that if \\(p_{1*}\\pi_1(\\hat X_1, \\hat x_1)\\) and \\(p_{2*}\\pi_1(\\hat X_2, \\hat x_2)\\) are conjugate then \\(\\hat X_1\\) and \\(\\hat X_2\\) are isomorphic covering spaces. So let\n  \\[\n    \\label{eq:a}\n    p_{1*} \\pi_1(\\hat X_1, \\hat x_1) = [\\gamma] p_{2*} \\pi_1(\\hat X_2, \\hat x_2) [\\overline \\gamma].\n    \\tag{\\ast}\n  \\]\n  Let \\(\\overline{\\hat \\gamma}\\) be the lift of \\(\\overline \\gamma\\) and \\(\\hat x_2' = \\overline{\\hat \\gamma}(1)\\). \\eqref{eq:a} then tells us that\n  \\[\n    \\p_{1*}\\pi_1(\\hat X_1, \\hat x_1)\n    = p_{2*} \\hat \\gamma_\\# \\pi_1(\\hat X_2, \\hat x_2)\n    = p_{2*} \\pi_1(\\hat X_2, \\hat x_2').\n  \\]\n  Then by the original Galois correspondence, there is a based isomorphism between \\(\\hat X_1\\) and \\(\\hat X_2\\). Of course they are isomorphic.\n\\end{proof}\n\n\\begin{definition}[covering transformation]\\index{covering transformation}\\index{deck transformation}\n  Let \\(p: \\hat X \\to X\\) be a covering space. A \\emph{covering transformation} or \\emph{deck transformation} \\(\\hat X \\to \\hat X\\) is a homeomorphism that is also a cover isomorphism.\n\\end{definition}\n\n\\begin{corollary}\n  Let \\(X\\) be ``reasonable'', path-connected and locally simply connected and \\(p: \\tilde X \\to X\\) a universal cover. Let \\(x_0 \\in X\\) and \\(\\tilde x_0 \\in p^{-1}(x_0)\\). Let \\(\\tilde x \\in p^{-1}(x_0)\\). Then there is a unique covering transformation \\(\\varphi_{\\tilde x} : \\tilde X \\to \\tilde X\\) such that \\(\\varphi_{\\tilde x}(\\tilde x_0) = \\tilde x\\).\n\\end{corollary}\n\n\\begin{proof}\n  Both \\((\\tilde X, \\tilde x_0)\\) and \\((\\tilde X, \\tilde x)\\) correspond to the trivial subgroup of \\(\\pi_1(X, x_0)\\) so the result follows from 2.27.\n\\end{proof}\n\nNow we have two different correspondences:\n\n\\blindtext\n\nIn fact these are isomorphic. automorphism of universal covers is isomorphic to fundamental group of base group.\n\nWe can thus make \\(\\pi_1(X, x_0)\\) act on \\(\\tilde X\\) on the \\emph{left} by covering transformation.\n\\begin{remark}\n  Left vs. right action. Abelian group in case of \\(S^1\\).\n\\end{remark}\n\n\\section{Seifert-van Kampen theorem}\n\nSo far we have only seen one space with nontrivial fundamental group. In general, the fundamental groups are notoriously difficult to compute. In this chapter, we will develop the machinery needed to divide and conquer the problem of finding the fundamental group of a complex space. Specifically, given \\(X = Y_1 \\cup Y_2\\), we will ultimate describe \\(\\pi_1X\\) in terms of \\(\\pi_1Y_1, \\pi_1Y_2\\) and \\(\\pi_1(Y_1 \\cap Y_2)\\). But before that, we have to develop more group theory.\n\n\\subsection{Free groups and presentations}\n\nWe have seen groups described in the following form in IA Groups:\n\\[\n  D_{2n} = \\langle r, s | s^2 = r^n = e, srs = r^{-1} \\rangle\n\\]\nwhere we impose \\emph{relations} on the right on the group generated by the \\emph{generators} on the left. This is an example of a \\emph{presentation}. What should be the group generated by the generators be? Should it, for example, have an element of order 2? Morally, the answer should be ``no'' as we should move all relations to the right. This leaves us with a free group, which is a group with no relation. Given a set \\(A\\) of generators, called an \\emph{alphabet}, \\(FA\\) is the free group generated by \\(A\\). Thus a free group has presentation\n\\[\n  FA = \\langle a \\in A \\rangle.\n\\]\nFormally\n\n\\begin{definition}[free group]\\index{free group}\n  A group \\(F(A)\\) equipped with a map of set \\(A \\to F(A)\\) is the \\emph{free group} on \\(A\\) if it satisfies the following universal property: whenever \\(G\\) is a group and \\(A \\to G\\) is a set map there is a unique canonical homomorphism \\(f: F(A) \\to G\\) such that\n  \\[\n    \\begin{tikzcd}\n      F(A) \\ar[dr, \"f\"] \\\\\n      A \\ar[u] \\ar[r] & G\n    \\end{tikzcd}\n  \\]\n  commutes.\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(F(\\emptyset) \\cong 1\\).\n  \\item Let \\(A = \\{a\\}\\). If \\(A \\to G, a \\mapsto g\\), define \\(f: \\Z \\to G, n \\mapsto g^n\\). Then the diagram\n    \\[\n      \\begin{tikzcd}\n        \\Z \\ar[dr, \"f\"] \\\\\n        A \\ar[u] \\ar[r] \\ar[r] & G\n      \\end{tikzcd}\n    \\]\n    commutes. Thus \\(\\Z\\) is the free group on \\(A\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item Free group is defined uniquely up to a unique isomorphism: suppose \\(A \\to F'(A)\\) also satisfies the universal property. Take \\(G = F'(A)\\) in the universal property for \\(F(A)\\), then there is a canonical homomorphism \\(f: F(A) \\to F'(A)\\) such that\n    \\[\n      \\begin{tikzcd}\n        F(A) \\ar[dr] \\\\\n        A \\ar[u] \\ar[r] & F'(A)\n      \\end{tikzcd}\n    \\]\n    commutes. Conversely, take \\(G = F(A)\\) in the universal property for \\(F'(A)\\), then there is a canonical homomorphism \\(f': F'(A) \\to F(A)\\) such that the corresponding diagram commutes. Now both \\(\\id_{F(A)}\\) and \\(f' \\compose f\\) both make the diagram commute so by uniqueness \\(f' \\compose f = \\id_{F(A)}\\). Likewise \\(f \\compose f' = \\id_{F'(A)}\\) so \\(f\\) and \\(f'\\) are isomorphisms.\n  \\item The definition does not guarantee the existence of free groups. We'll cover this later.\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{notation}\n  We identify \\(a \\in A\\) with its image in \\(F(A)\\).\n\\end{notation}\n\n\\begin{definition}[presentation]\\index{presentation}\n  Let \\(A\\) be an \\emph{alphabet}. A subset \\(R \\subseteq F(A)\\) defines a \\emph{(group) presentation}\n  \\[\n    \\langle A | R \\rangle = F(A) / \\langle \\langle R \\rangle \\rangle\n  \\]\n  where \\(\\langle\\langle R \\rangle\\rangle\\) is the normal closure of \\(R\\) in \\(F(A)\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\langle a | a^n \\rangle \\cong \\Z/n\\Z\\).\n  \\item \\(\\langle r, s | r^n, s^2, srsr \\rangle \\cong D_{2n}\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{lemma}[universal property of group presentation]\n  Given a presentation \\(\\langle A | R\\rangle\\) and the quotient map \\(q: F(A) \\to \\langle A | R \\rangle\\), for any homomorphism \\(g: F(A) \\to G\\) such that \\(g(r) = 1\\) for all \\(r \\in R\\), there exists a unique homomorphism \\(f: \\langle A | R \\rangle \\to G\\) such that \\(f \\compose q = g\\). In other words, the following diagram commutes:\n  \\[\n    \\begin{tikzcd}\n      \\langle A | R \\rangle \\ar[dr, \"f\"] \\\\\n      F(A) \\ar[u, \"q\"] \\ar[r, \"g\"] & G\n    \\end{tikzcd}\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Follows easily from universal property of quotient map.\n\\end{proof}\n\n\\begin{definition}[pushout]\\index{pushout}\n  Let \\(i: C \\to A, j: C \\to B\\) be group homomorphisms. Homomorphism \\(k: A \\to \\Gamma, \\ell: B \\to \\Gamma\\) is a \\emph{pushout} if it satisfies the following property: for any group \\(G\\) and homomorphisms \\(f: A \\to G, g: B \\to G\\) such that \\(f \\compose i = g \\compose j\\), then there is a unique homomorphism \\(\\varphi: \\Gamma \\to G\\) such that \\(f = \\varphi \\compose k, g = \\varphi \\compose \\ell\\). In other words the following diagram commutes.\n  \\[\n    \\begin{tikzcd}\n      C \\ar[r, \"i\"] \\ar[d, \"j\"] & A \\ar[d, \"k\"] \\ar[ddr, bend left, \"f\"] \\\\\n      B \\ar[r, \"\\ell\"] \\ar[drr, bend right, \"g\"] & \\Gamma \\ar[dr, \"\\varphi\", dashed] \\\\\n      & & G\n    \\end{tikzcd}\n  \\]\n\\end{definition}\n\nAgain \\(\\Gamma\\) is uniquely defined by the universal property.\n\nWe mainly care about special cases of the definition.\n\n\\begin{definition}[free product, amalgamated free product]\\index{free product}\\index{free product!amalgamated}\n  If \\(C \\cong 1\\), then \\(\\Gamma\\) is called the \\emph{free product} of \\(A\\) and \\(B\\), denoted \\(A * B\\).\n\n  More generally, if \\(i\\) and \\(j\\) are injective then \\(\\Gamma\\) is called the \\emph{amalgamated free product}, denoted \\(A *_C B\\).\n\\end{definition}\n\n\\begin{eg}\n  \\(\\Z * \\Z \\cong F_2\\) since they satisfy the same universal property. More generally, we can check that\n  \\[\n    \\underbrace{\\Z * \\Z * \\dots * \\Z}_r \\cong F_r.\n  \\]\n\\end{eg}\n\n\\begin{notation}\n  Write \\(F_n\\) for the free group with \\(n\\) generators.\n\\end{notation}\n\n\\begin{lemma}\n  \\[\n    \\begin{tikzcd}\n      C \\ar[r, \"i\"] \\ar[d] & A \\ar[d] \\\\\n      1 \\ar[r] & A /\\langle \\langle i(C) \\rangle\\rangle\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{lemma}\n\n\\begin{proof}\n  \\blindtext\n\\end{proof}\n\npresentation for free group with amalgamation\n\n\\subsection{Seifert-van Kampen theorem for wedges}\n\n\\begin{definition}[wedge]\\index{wedge}\n  Given two pointed spaces \\((X, x_0), (Y, y_0)\\), the \\emph{wedge} is\n  \\[\n    X \\w Y = X \\amalg Y /(x_0 \\sim y_0).\n  \\]\n\\end{definition}\n\nUsually \\(X\\) and \\(Y\\) are path-connected so we can define wedges \\(X \\w Y\\) without specifying basepoints.\n\n\\begin{theorem}[Seifert-van Kampen for wedges]\\index{Seifert-van Kampen theorem}\n  If \\(Y_1, Y_2\\) are path-connected and \\(x_0\\) is the wedge point of \\(X = Y_1 \\w Y_2\\). Then\n  \\[\n    \\pi_1(X, x_0) = \\pi_1(Y_1, x_0) * \\pi_1(Y_2, x_0).\n  \\]\n\\end{theorem}\n\n\\begin{proof}[Sketch of proof]\n  non-examinable\n\n  Suppose \\(f_1: \\pi_1(Y_i, x_0) \\to G\\) are group homomorphisms for \\(i = 1, 2\\). We need to find a unique \\(\\phi: \\pi_1(X, x_0) \\to G\\) such that \\(\\phi\\) restricts to \\(f_i\\) on \\(\\pi_1(Y_i, x_0)\\).\n\n  First replace \\(X\\) by \\(X'\\) (drawing) with \\(X \\simeq X'\\). Let \\(\\gamma: I \\to X'\\) be a based loop. We can ``straighten'' \\(\\gamma\\) so that it is of the form\n  \\[\n    \\gamma = \\alpha_1 \\cdot \\beta_1 \\cdot \\alpha_2 \\cdot \\beta_2 \\cdots \\alpha_n \\cdot \\beta_n\n  \\]\n  where \\(\\alpha_i\\)'s are in \\(\\pi_1(Y_1, x_0)\\) and \\(\\beta_i\\)'s are in \\(\\pi_1(Y_1, x_0)\\). Define\n  \\[\n    \\phi(\\gamma) = f_1(\\alpha_1) f_2(\\beta_2) f_1(\\alpha_2) \\cdots f_2(\\beta_{n - 1}) f_1(\\alpha_n) f_2(\\beta_n)\n  \\]\n  uniquely. This is easily seen to be a homomorphism but we need to prove that \\(\\phi\\) is well-defined. Let \\(\\gamma' \\simeq_F \\gamma\\) with\n  \\[\n    \\gamma' = \\alpha_1' \\cdot \\beta_1' \\cdots \\alpha_m' \\beta_m'\n  \\]\n  so\n  \\[\n    \\phi(\\gamma') = f_1(\\alpha_1')f_2(\\beta_1') \\cdots f_1(\\alpha_m') f_2(\\beta_m'),\n  \\]\n  we need to prove that \\(\\phi(\\gamma) = \\phi(\\gamma')\\). The key idea is to ``straighten'' \\(F\\) so that it is ``transverse'' to \\(x_0\\): this means that \\(F^{-1}(x_0) \\subseteq I \\times I\\) consists of a finite union of circles and intervals embedded in \\(I \\times I\\). If there is a circle \\(S! \\subseteq F^{-1}(0)\\) then we can ``cut it out'' and remove it. An arc with both endpoints on \\(\\gamma\\) exhibit a subarc \\(\\delta \\subseteq \\Gamma\\) such that \\(\\delta \\simeq c_{x_0}\\) in \\(Y_1\\) or \\(Y_2\\), reducing \\(n\\) without changing \\(\\phi(\\gamma)\\). After finitely many of these moves, we are left with a picture of the following form (drawing). Therefore \\(m = n\\) and \\(\\alpha_i \\simeq \\alpha_i', \\beta_i \\cong \\beta_i'\\) as paths so \\(\\phi(\\gamma) = \\phi(\\gamma')\\) as required.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^1 \\w S^1\\), then\n  \\[\n    \\pi_1 X \\cong \\pi_1S^1 * \\pi_1S^1 \\cong \\Z * \\Z \\cong F_2.\n  \\]\n  More generally, let \\(X_r = \\bigvee_{i = 1}^r S^1\\), sometimes called a bouquet, then\n  \\[\n    \\pi_1 X_r \\cong \\underbrace{\\Z * \\cdot * \\Z}_{r} \\cong F_r.\n  \\]\n\\end{eg}\n\n%find universal cover of X_r\n\n\\subsection{Seifert-van Kampen theorem}\n\n\\begin{theorem}[Seifert-van Kampen]\\index{Seifert-van Kampen}\n  If \\(X = Y_1 \\cup_Z Y_2\\) with \\(Y_1, Y_2, Z\\) open and path-connected and \\(x_0 \\in Z\\) then the diagram\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(Z, x_0) \\ar[r, \"i_{1*}\"] \\ar[d, \"i_{2*}\"] & \\pi_1(Y_1, x_0) \\ar[d, \"j_{1*}\"] \\\\\n      \\pi_1(Y_2, x_0) \\ar[r, \"j_{2*}\"] & \\pi_1(X, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{theorem}\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\n\\begin{eg}\n  Let \\(X = S^n\\) where \\(n \\geq 2\\). Let \\(x_\\pm = (\\pm 1, 0, \\dots, 0)\\) be the north/south poles and define\n  \\begin{align*}\n    U_\\pm &= S^n - \\{x_\\mp\\} \\\\\n    V &=  U_+ \\cap U_- = S^n - \\{x_\\pm\\}\n  \\end{align*}\n  Then \\(X = U_+ \\cup_V U_-\\). Stereographic projection tells us that \\(U_\\pm \\cong \\R^n\\). Project \\(V\\) radially onto the cylinder \\((-1, 1) \\times S^{n - 1}\\), which is a homeomorphism so \\(V \\cong (-1, 1) \\times S^{n - 1} \\simeq S^{n - 1}\\). \\(S^{n - 1}\\) is path-connected for \\(n \\geq 2\\) so by Seifert-van Kampen the following diagram is a pushout:\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^{n - 1}, x_0) \\ar[r] \\ar[d] & 1 \\ar[d] \\\\\n      1 \\ar[r] & \\pi_1(S^n, x_0)\n    \\end{tikzcd}\n  \\]\n  so \\(\\pi_1(S^n, x_0)\\) is a quotient of \\(1\\) so is trivial.\n\\end{eg}\n\n\\begin{definition}[neighbourhood deformation retract]\\index{neighbourhood deformation retract}\n  A subset \\(Y \\subseteq X\\) is called a \\emph{neighbourhood deformation retract} if there exists \\(Y \\subseteq V \\subseteq X\\) where \\(V\\) is open in \\(X\\) such that \\(Y\\) is a deformation retraction of \\(V\\).\n\\end{definition}\n\n\\begin{corollary}\n  If \\(X = Y_1 \\cup_Z Y_2\\) with \\(Y_1, Y_2, Z\\) path-connected and closed and \\(Z\\) a neighbourhood deformation retract of \\(Y_1\\) and \\(Y_2\\) and \\(x_0 \\in Z\\) then\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(Z, x_0) \\ar[r] \\ar[d] & \\pi_1(Y_1, x_0) \\ar[d] \\\\\n      \\pi_1(Y_2, x_0) \\ar[r] & \\pi_1(X, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout.\n\\end{corollary}\n\n\\begin{proof}\n  See online notes.\n\\end{proof}\n\n\\subsection{Attaching cells}\n\n\\begin{definition}[cell]\\index{cell}\n  An \\emph{\\(n\\)-cell} is a copy of \\(D^n\\), the closed ball in \\(\\R^n\\).\n\\end{definition}\n\n\\begin{definition}\n  Let \\(\\alpha: S^{n - 1} = \\partial D^n \\to X\\) be a continuous map. The space\n  \\[\n    X \\cup_\\alpha D^n := X \\amalg D^n / \\sim\n  \\]\n  where \\(\\sim\\) is the finest equivalence relation such that \\(\\alpha(\\theta) \\sim \\theta\\) for all \\(\\theta \\in S^{n - 1}\\), is called an \\emph{attaching cell}.\n\\end{definition}\n\nWhat effect does attaching an \\(n\\)-cell have on \\(\\pi_1\\)?\n\nLet's start with \\(n \\geq 3\\):\n\n\\begin{lemma}\n  If \\(n \\geq 3\\) and \\(\\alpha: S^{n - 1} \\to X\\) is a continuous map. Let \\(x_0 = \\alpha(\\theta_0)\\) for \\(\\theta_0 \\in S^{n - 1}\\). Then the (not necessarily injective) inclusion map \\(i: X \\to X \\cup_\\alpha D^n\\) induces an isomorphism \\(i_*: \\pi_1(X, x_0) \\to \\pi_1(X \\cup_\\alpha D^n, x_0)\\).\n\\end{lemma}\n\n\\begin{proof}\n  The main obstacle is that \\(\\alpha\\) might not be injective. However, we can divide \\(D^n\\) into two parts and attach \\(D^n\\) in two stages: the mapping cylinder of \\(\\alpha\\) is\n  \\[\n    M_\\alpha := X \\amalg (S^{n - 1} \\times I) / \\sim\n  \\]\n  where \\(\\alpha(\\theta) \\sim (\\theta, 0)\\) for all \\(\\theta \\in S^{n - 1}\\). Note that\n  \\begin{enumerate}\n  \\item \\(X\\) is a deformation retract of \\(M_\\alpha\\).\n  \\item \\(S^{n - 1} \\times \\{1\\} \\subseteq M_\\alpha\\) is a neighbourhood deformation retract.\n  \\item \\(S^{n - 1} \\subseteq D^n\\) is a neighbourhood deformation retract.\n  \\end{enumerate}\n  If we choose \\(\\theta_1 \\in S^{n - 1}\\), the previous corollary tells us that\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^{n - 1}, \\theta_1) \\ar[r] \\ar[d] & \\pi_1(M_\\alpha, \\theta_1) \\ar[d, \"j_*\"] \\\\\n      \\pi_1(D^n, \\theta_1) \\ar[r] & \\pi_1(M_\\alpha \\cup_{S^{n - 1}} D^n, \\theta_1)\n    \\end{tikzcd}\n  \\]\n  is a pushout. Therefore the inclusion \\(j: M_\\alpha \\to M_\\alpha \\cup_{S^{n - 1}} D^n\\) induces an isomorphism on \\(\\pi_1\\). Since \\(X \\cup_\\alpha D^n = M_\\alpha \\cup_{S^{n - 1}} D^n\\) and \\(M_\\alpha'\\) deformation retracts to \\(X\\), the result follows.\n\\end{proof}\n\nWhat about \\(n = 2\\)?\n\n\\begin{lemma}\n  If \\(\\alpha: S^1 \\to X\\) is a continuous map and \\(x_0 = \\alpha(\\theta_0)\\) where \\(\\theta_0 \\in S^1\\). Then\n  \\[\n    \\pi_1(X \\cup_\\alpha D^2, \\theta_0) \\cong \\pi_1(X, x_0) / \\langle\\langle [\\alpha] \\rangle\\rangle\n  \\]\n  and the inclusion map \\(X \\embed X \\bigcap_\\alpha D^2\\) induces the quotient map\n  \\[\n    \\pi_1(X, x_0) \\to \\pi_1(X \\cup_\\alpha D^2, x_0).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  As in the proof of the previous lemma, the diagram\n  \\[\n    \\begin{tikzcd}\n      \\pi_1(S^1, \\theta_0) \\ar[r, \"\\alpha_*\"] \\ar[d] & \\pi_1(X, x_0) \\ar[d, \"i_*\"] \\\\\n      \\pi_1(D^2, \\theta_0) \\ar[r] & \\pi_1(X \\cup_\\alpha D^2, x_0)\n    \\end{tikzcd}\n  \\]\n  is a pushout. By lemma 3.2 the result follows.\n\\end{proof}\n\n\\begin{theorem}\n  If \\(G = \\langle A | R \\rangle\\) with \\(A, R\\) both finite then it is the fundamental group of some space. Moreover the spaces can be taken to be compact.\n\\end{theorem}\n\nIn fact, we don't have to restrict our attention to finitely generated or finitely presented groups. So every group is the fundamental group of some space (although not compact in general).\n\n\\begin{proof}\n  If \\(R = \\{r_1, \\dots r_n\\}\\) then\n  \\begin{align*}\n    G &= F(A) / \\langle\\langle r_1, \\dots, r_n \\rangle\\rangle \\\\\n      &\\cong (F(A) / \\langle\\langle r_1, \\dots, r_{n - 1} \\rangle\\rangle) / \\langle\\langle r_n \\rangle\\rangle \\\\\n      &\\cong \\dots \\\\\n      &\\cong (\\dots (F(A)/ \\langle \\langle r_1 \\rangle\\rangle) \\dots ) / \\langle\\langle r_n \\rangle\\rangle,\n  \\end{align*}\n  one way to check this is to show they satisfy the same universal property. Now induction on \\(n\\), with the base case \\(n = 1\\) being the wedge of \\(|A|\\) circles.\n\\end{proof}\n\n\\subsection{Classification of surfaces}\n\n\\begin{definition}[topological manifold]\\index{topological manifold}\n  An \\emph{\\(n\\)-dimensional (topological) manifold} is a Hausdorff space \\(M\\) such that every \\(x \\in M\\) has an open neighbourhood \\(U\\) homeomorphic to an open subset of \\(\\R^n\\).\n\\end{definition}\n\n\\begin{definition}[surface]\\index{surface}\n  A \\(2\\)-dimensional manifold is called a \\emph{surface}.\n\\end{definition}\n\n\\begin{eg}\n  Let \\(\\alpha: S^1 \\to *\\). Consider \\(X = * \\cup_\\alpha D^2\\). Note that \\(\\int D^2 \\cong \\R^2\\) and \\(S^2 - \\{x_+\\} \\cong \\R^2\\) via stereographic projection. Moreover the homeomorphism \\(i: \\int D^2 \\to S^1 - \\{x_+\\}\\) extends to a unique continuous bijection \\(X \\to S^2\\), so a homeomorphism. In particular \\(S^2\\) is a surface.\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\Gamma_{2g} = \\bigvee_{i = 1}^{2g} S_i^1\\), with each \\(S_i' \\cong S^1\\). Choose unit speed loops \\(\\alpha_1, \\dots, \\alpha_g\\) and \\(\\beta_1, \\dots, \\beta_g\\) in the circles. Let\n  \\[\n    \\rho_g = (\\alpha_1 \\cdot \\beta_1 \\cdot \\overline \\alpha_1 \\cdot \\overline \\beta_1) \\cdot (\\alpha_2 \\cdot \\beta_2 \\cdot \\overline \\alpha_2 \\cdot \\overline \\beta_2) \\dots (\\alpha_g \\cdot \\beta_g \\cdot \\overline \\alpha_g \\cdot \\overline \\beta_g)\n  \\]\n  and let\n  \\[\n    \\Sigma_g = \\Gamma_{2g} \\cup_{\\rho_g} D^2.\n  \\]\n  Claim \\(\\Sigma_g\\) is a surface. There are three cases to consider. If a point in the interior of \\(D^2\\) then it has a neighbourhood homeomorphic to an open disk. If a point is in the interior of image of a path the ``two parts'' glue together to form an open disk. Similarly all the edges are identified together.\n\n  \\(\\Sigma_0\\) is just \\(S^2\\). \\(\\Sigma_1\\) is the square with two sides identified to a torus. In general \\(\\Sigma_g\\) is called the (orientable surface) with genus \\(g\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\Gamma_{g + 1} = \\bigvee_{i = 0}^g S_i^1\\) and let\n  \\[\n    \\sigma_j = \\alpha_0 \\cdot \\alpha_0 \\cdot \\alpha_1 \\cdot \\alpha_1 \\dots \\alpha_g \\cdot \\alpha_g\n  \\]\n  let\n  \\[\n    S_g = \\Gamma_{g + 1} \\cup_{\\sigma_g} D^2.\n  \\]\n  Similarly we can check these are surfaces. This is the \\emph{non-orientable surface} of genus \\(g\\). \\(S_0 = \\R P^2\\) and \\(S_1\\) is the Klein bottle.\n\n  We have\n  \\begin{align*}\n    \\pi_1 \\Sigma_g &= \\langle a_1, \\dots, a_g, b_1, \\dots, b_g | a_1b_1a_1^{-1}b_1^{-1} \\cdots a_gb_ga_g^{-1}b_g^{-1}\\rangle \\\\\n    \\pi_1 S_g &= \\langle a_0, \\dots, a_g | a_0^2 a_1^2 \\cdots a_g^2 \\rangle\n  \\end{align*}\n\\end{eg}\n\nWe state without proof\n\n\\begin{theorem}[classification of compact surfaces]\\index{classification of compact surfaces}\n  If \\(M\\) is a compact surface then either \\(M \\cong \\Sigma_g\\) or \\(M \\cong S_g\\).\n\\end{theorem}\n\nWe won't prove this but a good point to start is to consider given an identification of \\(S^1\\) of \\(D^2\\), how can we convert it into one of the two forms?\n\nWe also ask the following question: are \\(\\{\\Sigma_g\\}\\) and \\(\\{S_g\\}\\) pairwise non-homeomorphic? What about homotopy equivalence? The only tool available to us is \\(\\pi_1\\). The strategy is to that the fundamental groups map onto different abelian groups. % abelianisation\n\n\\begin{lemma}\n  Let \\(g \\in \\N\\).\n  \\begin{enumerate}\n  \\item The group \\(\\pi_1 \\Sigma_g\\) surjects \\(\\Z^{2g}\\) but not \\(\\Z^{2g} \\oplus (\\Z/(2))\\).\n  \\item The group \\(\\pi_1 S_g\\) surjects \\(\\Z^g \\oplus (\\Z/(2))\\) but not \\(\\Z^{g + 1}\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  Easy. See notes.\n\\end{proof}\n\nAnd as a result we get want we want\n\n\\begin{corollary}\n  The strategy works.\n\\end{corollary}\n\n\\section{Simplicial complexes}\n\nWe have seen that the fundamental groups are useful, and for example, when it works, it tells us \\(S^n\\) is contractible for \\(n > 1\\). There are higher dimensional analogues of \\(\\pi_1\\), called the \\emph{homotopy groups} \\(\\pi_n\\). However, they are notoriously difficult to compute. Instead, we will use (more or less) the only thing in mathematics we understand fully (again, more or less) --- linear algebra. This is called \\emph{homology}.\n\nThere are many types of homologies and we'll only define \\emph{simplicial homologies} in this course.\n\n\\subsection{Simplices and stuff}\n\n\\begin{definition}\n  A finite set \\(V \\subseteq \\R^n\\) is in \\emph{general position} if the smallest affine subspace containing \\(V\\) is of dimension \\(|V| - 1\\).\n\\end{definition}\n\nThis is quite an abstract definition, but there are a few equivalent notions. For example, if \\(V = \\{v_0, \\dots, v_n\\}\\) then for any \\(t_0, \\dots t_n\\) such that \\(\\sum_{i = 0}^n t_i = 0\\), if \\(\\sum_{i = 0}^n t_iv_i = 0\\) then \\(t_i = 0\\) for all \\(i\\).\n\n\\begin{definition}[simplex]\\index{simplex}\n  For \\(n \\geq 0, V = \\{v_0, \\dots, v_n\\} \\subseteq \\R^m\\). The \\emph{span} of \\(V\\) is\n  \\[\n    \\langle V \\rangle = \\{\\sum_{i = 0}^n t_iv_i: t_i \\geq 0, \\sum_{i = 0}^n t_i = 1\\}.\n  \\]\n\n  If \\(V\\) is in general position, \\(\\sigma = \\langle V \\rangle\\) is an \\emph{\\(n\\)-simplex}.\n\\end{definition}\n\n\\begin{definition}[face]\\index{face}\n  Let \\(V = \\{v_0, \\dots, v_n\\}\\) in general position. If \\(U \\subseteq V\\) then \\(\\langle U \\rangle\\) is called a \\emph{face} of \\(\\langle V\\rangle\\), write \\(\\langle U \\rangle \\leq \\langle V \\rangle\\).\n\n  If \\(U \\neq V\\) then \\(\\langle U\\rangle\\) is called a \\emph{proper} face.\n\\end{definition}\n\n\\begin{definition}[simplicial complex, dimension, skeleton]\\index{simplicial complex}\\index{dimension}\\index{skeleton}\n  A \\emph{simplicial complex} is a finite set of simplices \\(K\\) in some \\(\\R^m\\) satisfying the following condition:\n  \\begin{enumerate}\n  \\item if \\(\\sigma \\in K\\) and \\(\\tau \\leq \\sigma\\) then \\(\\tau \\in K\\),\n  \\item if \\(\\sigma, \\tau \\in K\\) then \\(\\sigma \\cap \\tau \\leq \\sigma\\) and \\(\\sigma \\cap \\tau \\leq \\tau\\).\n  \\end{enumerate}\n\n  The \\emph{dimension} of \\(K\\), denoted \\(\\dim K\\), is the largest \\(n\\) such that \\(K\\) contains an \\(n\\)-simplex.\n\n  The \\emph{\\(d\\)-skeleton} of \\(K\\) is\n  \\[\n    K_{(d)} = \\{\\sigma \\in K: \\dim \\sigma \\leq d\\}.\n  \\]\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item If \\(\\sigma\\) is a simplex then \\(K = \\{\\tau: \\tau \\leq \\sigma\\}\\) is a simplicial complex.\n  \\item If \\(\\sigma\\) is a simplex then the set of proper faces of \\(\\sigma\\), denoted \\(\\b \\sigma\\), is also a simplicial complex. It is called the \\emph{boundary}\\index{boundary} of \\(\\sigma\\). The set of points in \\(\\sigma\\) not in a simplex of \\(\\b \\sigma\\) is called the \\emph{interior}, denoted by \\(\\interior \\sigma\\).\n  \\end{enumerate}\n\\end{eg}\n\nNote that if \\(\\sigma\\) is a \\(0\\)-simplex then \\(\\interior \\sigma = \\sigma\\).\n\n\\begin{definition}[realisation/polyhedron]\\index{realisation}\\index{polyhedron}\n  The \\emph{realisation} or \\emph{polyhedron} of a simplicial complex \\(K\\) is the union of the simplices in \\(K\\), denoted by \\(|K|\\).\n\\end{definition}\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item In \\(\\R^{n + 1}\\), the standard basis \\(\\{e_0, \\dots e_n\\}\\) is in general position. The simplex it spans \\(\\sigma_n = \\langle e_0, \\dots, e_n\\rangle\\) is called the \\emph{standard \\(n\\)-simplex}.\n  \\item The \\emph{standard (simplicial) \\((n - 1)\\)-sphere} is \\(\\b \\sigma_n\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}[triangulation]\\index{triangulation}\n  A \\emph{triangulation} of a space \\(X\\) is a homeomorphism \\(h: |K| \\to X\\).\n\\end{definition}\n\nIt's not hard to see that there is a triangulation \\(h: |\\b \\sigma_n| \\to S^{n - 1}\\).\n\n\\begin{eg}\n  Here is another way of triangulating \\(S^n\\). For now set \\(n = 2\\). The convex hull of \\(\\{\\pm e_0, \\pm e_1, \\pm e_2\\}\\) is a surface of an octahedron, which is triangulation of \\(S^2\\). In general, let \\(\\{e_0, \\dots, e_n\\}\\) be the standard basis for \\(\\R^{n + 1}\\) and \\(E = \\{\\pm e_0, \\dots, \\pm e_n\\}\\). Let\n  \\[\n    E_0 = \\{S \\subseteq E: \\text{ for all \\(i\\) exactly one of \\(\\pm e_i\\) is in } S\\}.\n  \\]\n  Let \\(K = \\{\\langle S \\rangle: S \\in E_0\\}\\). This is the \\emph{octahedral \\(n\\)-sphere} and there exists a triangulation \\(|K| \\to S^n\\).\n\\end{eg}\n\n\\begin{definition}[simplicial map]\\index{simplicial map}\\index{simplicial map!realisation}\n  Let \\(K, L\\) be simplicial complexes. A \\emph{simplicial map} \\(f: K \\to L\\) is a map such that for all \\(\\langle v_0, \\dots, v_n \\rangle \\in K\\),\n  \\[\n    f(\\langle v_0, \\dots, v_n \\rangle) = \\langle f(v_0), \\dots, f(v_n) \\rangle\n  \\]\n  where \\(f(\\{v_i\\}) = \\{f(v_i)\\}\\).\n\n  The \\emph{realisation} of \\(f: K \\to L\\) is the continuous map \\(|f|: |K| \\to |L|\\) defined on \\(\\sigma = \\langle v_0 , \\dots, v_n \\rangle\\) to be\n  \\[\n    f_\\sigma \\left( \\sum_{i = 0}^n t_iv_i \\right) = \\sum_{i = 0}^n t_i f(v_i).\n  \\]\n\\end{definition}\n\nNote that if \\(\\tau \\leq \\sigma\\) then \\(f_\\tau = f_\\sigma|_\\tau\\), so \\(|f|\\) is well-defined and continuous.\n\\begin{eg}\n  (drawing)\n\\end{eg}\n\n\\subsection{Barycentric subdivision}\n\nRealisation of simplicial maps are piecewise linear and thus very rigid. On the other hand, the realisations of simplicial complexes, as topological spaces, are ``deformable''. Is every continuous map \\(|K| \\to |L|\\) homotopic to a realisation of a simplicial map? For example for \\(K = L = \\b \\sigma_2\\), there are infinitely many homotopy classes of continuous maps, which are in bijection with \\(\\pi_1(S^1)\\). On the other hand there are only finitely many simplicial map \\(K \\to L\\), and thus at most that many realisations. To establish the correspondence, we need subdivision.\n\n\\begin{definition}[barycentre]\\index{barycentre}\n  If \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\), the \\emph{barycentre} of \\(\\sigma\\) is\n  \\[\n    \\hat \\sigma_n = \\frac{1}{n + 1} \\sum_{i = 0}^n v_i.\n  \\]\n\\end{definition}\n\n\\begin{definition}[barycentric subdivision]\\index{barycentric subdivision}\n  Suppose \\(K\\) is a simplicial complex. The \\emph{barycentric subdivision} of \\(K\\) is \\(K'\\) with vertices \\(\\{\\hat \\sigma: \\sigma \\in K\\}\\). A collection of barycentres \\(\\{\\hat \\sigma_0, \\dots, \\hat \\sigma_n\\}\\) spans a simplex in \\(K'\\) whenever \\(\\sigma_0 \\leq \\sigma_1 \\leq \\dots \\leq \\sigma_n\\).\n\\end{definition}\n\n\\begin{lemma}\n  \\(K'\\) is a simplicial complex and \\(|K'| = |K|\\).\n\\end{lemma}\n\n\\begin{proof}\n  See online notes.\n\\end{proof}\n\n\\begin{definition}\n  We define\n  \\begin{align*}\n    K^{(0)} &= K \\\\\n    K^{(r)} &= (K^{(r - 1)})'\n  \\end{align*}\n  the \\(r\\)th barycentric subdivision.\n\\end{definition}\n\n\\begin{definition}[mesh]\\index{mesh}\n  Let \\(K\\) be a simplicial complex. Define the \\emph{mesh} of \\(K\\) to be\n  \\[\n    \\mesh(K) = \\max_{\\langle v_0, v_1 \\rangle \\in K} \\norm{v_0 - v_1}_2.\n  \\]\n\\end{definition}\n\nHere the \\(2\\)-norm is just taken for the sake of convenience and concreteness.\n\n\\begin{lemma}\n  If \\(\\dim K = n\\) then\n  \\[\n    \\mesh(K^{(r)}) \\leq \\left(\\frac{n}{n + 1}\\right)^r \\mesh(K).\n  \\]\n  In particular\n  \\[\n    \\lim_{r \\to \\infty} \\mesh(K^{(r)}) = 0.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  \\(\\dim K' = \\dim K = n\\) so by induction it suffices to show that\n  \\[\n    \\mesh(K') \\leq \\frac{n}{n + 1} \\mesh(K).\n  \\]\n  A \\(1\\)-simplex in \\(K'\\) is of the form \\(\\langle \\hat \\tau, \\hat \\sigma \\rangle\\) where \\(\\tau \\leq \\sigma\\). Note that \\(K'\\) is a finite set and mesh is realised by some pairs of vertices. By a bit geometric reasoning this is achieved by some vertex. We may thus assume that \\(\\hat \\tau = v_0\\), a vertex of \\(\\sigma = \\langle v_0, \\dots, v_m\\rangle\\). Thus\n  \\begin{align*}\n    \\norm{\\hat \\tau - \\hat \\sigma}\n    &= \\norm*{v_0 - \\frac{1}{m + 1} \\sum_{i = 0}^m v_i} \\\\\n    &= \\norm*{\\frac{m}{m + 1} v_0 - \\frac{1}{m + 1} \\sum_{i = 1}^m v_i} \\\\\n    &= \\frac{1}{m + 1} \\norm*{\\sum_{i = 1}^m (v_0 - v_i)} \\\\\n    &\\leq \\frac{1}{m + 1} \\sum_{i = 1}^m{v_0 - v_1} \\\\\n    &\\leq \\frac{m}{m + 1} \\mesh(K) \\\\\n    &\\leq \\frac{n}{n + 1} \\mesh (K)\n  \\end{align*}\n\\end{proof}\n\n\\subsection{Simplicial approximation theorem}\n\n\\begin{definition}[star]\\index{star}\n  Let \\(v\\) be a vertex of \\(K\\). The \\emph{star} of \\(v\\) is\n  \\[\n    \\St_K(v) = \\bigcup_{v \\in \\sigma \\in K} \\interior \\sigma\n  \\]\n\\end{definition}\n\n\\begin{definition}[simplicial approximation]\\index{simplicial approximation}\n  Let \\(\\phi: |K| \\to |L|\\) be a continuous map. A simplicial map \\(f: K \\to L\\) is a \\emph{simplicial approximation} of \\(\\phi\\) if for every vertex \\(v\\) of \\(K\\),\n  \\[\n    \\phi(\\St_K(v)) \\subseteq \\St_L(f(v)).\n  \\]\n\\end{definition}\n\n\\begin{lemma}\n  If \\(f: K \\to L\\) is a simplicial approximation to \\(\\phi: |K| \\to |L|\\) then \\(|f| \\simeq \\phi\\).\n\\end{lemma}\n\n\\begin{proof}\n  Suppose \\(|L| \\subseteq \\R^m\\) as usual. Consider the straightline homotopy \\(H\\) between \\(|f|\\) and \\(\\varphi\\). We will prove that \\(H\\) stays inside \\(|L|\\). Let \\(x \\in \\interior \\sigma\\) and let \\(\\phi(x) \\in \\interior \\tau\\). We'll show that \\(f(\\sigma) \\leq \\tau\\). The result then follows because \\(\\tau\\) is a convex subset of \\(R^m\\).\n\n  Let \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\). For each \\(i\\), \\(x \\in \\St_K(v_i)\\) so\n  \\[\n    \\phi(x) \\in \\phi(\\St_K(v_i)) \\subseteq \\St_L(f(v_i))\n  \\]\n  so \\(f(v_i)\\) is a vertex of \\(\\tau\\). So \\(f(\\sigma) \\tau\\) as desired.\n\\end{proof}\n\n\\begin{theorem}[simplicial approximation theorem]\\index{simplicial approximation theorem}\n  Let \\(K, L\\) be simplicial complexes and \\(\\phi: |K| \\to |L|\\) a continuous map. For some \\(r \\in \\N\\) there is a simplicial approximation to \\(\\phi\\), \\(f: K^{(r)} \\to L\\).\n\\end{theorem}\n\n\\begin{proof}\n  Let\n  \\[\n    U = \\{\\phi^{-1}(\\St_L(u)): u \\text{ a vertex of } L\\}\n  \\]\n  which is an open cover of \\(|K|\\). Claim that there is \\(\\delta > 0\\) such that for all \\(x \\in |K|\\), there exists a vertex of \\(L\\) such that\n  \\[\n    B(x, \\delta) \\subseteq \\phi^{-1}(\\St_L(u)).\n  \\]\n\n  \\begin{proof}\n    Lebesgue number lemma.\n  \\end{proof}\n  Choose \\(r\\) large enough such that \\(\\mesh(K^{(r)}) < \\delta\\). Then for any vertex \\(v\\) of \\(K^{(r)}\\),\n  \\[\n    \\St_{K^{(r)}}(v) \\subseteq B(v, \\delta) \\subseteq \\phi^{-1}(\\St_L(u))\n  \\]\n  for some \\(u\\). Set \\(f(v) = u\\) for some such \\(u\\). Left to check this is a simplicial map, i.e.\\ for all \\(\\sigma \\in K^{(r)}, f(\\sigma) \\in L\\). But as in the proof of the previous lemma, if \\(x \\in \\interior \\sigma\\) and \\(\\phi(x) \\in \\interior \\tau\\) then \\(f(\\sigma)\\) must be a face of \\(\\tau\\).\n\\end{proof}\n\n\\section{Homology}\n\n\\subsection{Simplicial homology}\n\nThe analogue in simplices of a path is a \\emph{chain}, which is a formal sum of simplices. If we interpret positive coefficient as copies of a simplex, what does it mean to have a negative simplex? To make sense of this we need the notion of \\emph{oriented simplex}.\n\n\\begin{definition}[orientation]\\index{orientation}\n  Let \\(V = (v_0, \\dots, v_n)\\) be an ordered set of points in general position in \\(\\R^M\\). Consider the natural action action of \\(S_{n + 1}\\) on \\(V\\). The subgroup \\(A_{n + 1} \\leq S_{n + 1}\\) has 2 orbits on \\(V\\), as long as \\(n \\geq 1\\). An \\emph{orientation} on \\(\\sigma = \\langle V \\rangle\\) is a choice of \\(A_{n + 1}\\)-orbit under the action on \\(V\\).\n\n  We will abuse notation and write \\(\\langle v_0, \\dots, v_n \\rangle\\) for the simplex \\(\\langle v_0, \\dots, v_n \\rangle\\) equipped with the orientation which is the \\(A_{n + 1}\\)-orbit of \\((v_0, \\dots, v_n)\\).\n\\end{definition}\n\n\\begin{eg}\n  Let \\(V = \\{v_0, v_1\\}\\). The two possible orientations are \\(\\langle v_0, v_1 \\rangle\\) and \\(\\langle v_1, v_0\\rangle\\), which corresponds to ``arrows going in opposite directions''.\n\\end{eg}\n\n\\begin{eg}\n  Let \\(V = \\{v_0, v_1, v_2\\}\\). There are two orientations, for example \\(\\langle v_0, v_1, v_2 \\rangle\\) and \\(\\langle v_2, v_1, v_0 \\rangle\\) are two representatives.\n\\end{eg}\n\n\\begin{definition}[chain]\\index{chain}\n  Let \\(K\\) be a simplicial complex. The group of \\emph{\\(n\\)-chains} on \\(K\\) is\n  \\[\n    C_n(K) = \\bigoplus_{\\sigma \\in K, \\dim \\sigma = n} \\langle \\sigma \\rangle.\n  \\]\n\\end{definition}\n\nIn particular if there are no \\(n\\)-simplex (e.g.\\ \\(n > \\dim K\\) or \\(n < 0\\)) then \\(C_n(K) \\cong 0\\). Arbitrarily choose orientations on the simplices of \\(K\\) and then identify \\(-\\sigma\\) with the opposite oriented simplex. Note that this arbitrary choice isn't important --- it could be realised by an automorphism of \\(C_n(K)\\).\n\n\\begin{remark}\n  Note that these groups are abelian, which is a huge advantage compared to homotopy groups if you actually want to do anything with them. On the other hand, it also means that there are things that a homotopy group can see but homology groups cannot.\n\\end{remark}\n\n\\begin{definition}[boundary homomorphism]\\index{boundary homomorphism}\n  The \\emph{(\\(n\\)th) boundary homomorphism} \\(\\b_n\\), usually just written as \\(\\b\\), is defined by\n  \\begin{align*}\n    C_n(K) &\\to C_{n - 1}(K) \\\\\n    \\langle v_0, \\dots, v_n \\rangle &\\mapsto \\sum_{i = 0}^n (-1)^i \\langle v_0, \\dots, \\hat v_i, \\dots, v_n \\rangle\n  \\end{align*}\n  where \\(hat v_i\\) means that the vertex \\(v_i\\) is omitted.\n\\end{definition}\n\nNote this is well-defined.\n\n\\begin{eg}\n  Let \\(\\sigma = \\langle v_0, v_1 \\rangle\\). Then \\(\\b(\\sigma) = \\langle v_1 \\rangle - \\langle v_0 \\rangle\\).\n\\end{eg}\n\n\\begin{eg}\n  Let \\(\\sigma = \\langle v_0, v_1, v_2 \\rangle\\). Then\n  \\begin{align*}\n    \\b(\\sigma)\n    &= \\langle v_1, v_2 \\rangle - \\langle v_0, v_2 \\rangle + \\langle v_0, v_1 \\rangle \\\\\n    &= \\langle v_1, v_2 \\rangle + \\langle v_2, v_0 \\rangle + \\langle v_0, v_1 \\rangle\n  \\end{align*}\n\\end{eg}\n\n\\begin{definition}[cycle, boundary]\\index{cycle}\\index{boundary}\n  Let \\(n \\in \\Z\\). The group\n  \\[\n    Z_n(K) = \\ker \\b_n \\leq C_n(K)\n  \\]\n  is the group of \\emph{\\(n\\)-cycles}.\n\n  The group\n  \\[\n    B_n(K) = \\im \\b_{n + 1} \\leq C_n(K)\n  \\]\n  is the group of \\emph{\\(n\\)-boundaries}.\n\\end{definition}\n\nThese are analogous to loops and homotopies respectively.\n\n\\begin{lemma}\n  Every \\(n\\)-boundary is an \\(n\\)-cycle, i.e.\n  \\[\n    B_n(K) \\leq Z_n(K),\n  \\]\n  i.e.\n  \\[\n    \\b_n \\compose \\b_{n + 1} = 0.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(\\sigma = \\langle v_0, \\dots, v_n \\rangle\\). By definition\n  \\[\n    \\b(\\sigma) = \\sum_{i = 0}^n (-1)^i \\langle v_0, \\dots, \\hat v_i, \\dots, v_n \\rangle\n  \\]\n  so\n  \\begin{align*}\n    \\b \\compose \\b(\\sigma)\n    &= \\sum_{i, j < i} (-1)^i (-1)^j \\langle v_0, \\dots, \\hat v_j, \\dots, \\hat v_i, \\dots, v_n \\rangle\n      + \\sum_{i, j > i} (-1)^i (-1)^{j - 1} \\langle v_0, \\dots, v_i, \\dots, v_j, \\dots, v_n \\rangle \\\\\n    &= \\sum_{i, j < i} (-1)^{i + j} \\langle v_0, \\dots, \\hat v_j, \\dots, \\hat v_i, \\dots v_n \\rangle\n      - \\sum_{i, j > i} (-1)^{i + j} \\langle v_0, \\dots, \\hat v_i, \\dots, \\hat v_j, \\dots, v_n \\rangle\n  \\end{align*}\n\\end{proof}\n\n\n\n\n\\printindex\n\\end{document}\n\n% https://www.dpmms.cam.ac.uk/~hjrw2/teaching.html\n", "meta": {"hexsha": "4beec75ee64de080d215f32d80ce858bd503d09c", "size": 67277, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "II/algebraic_topology.tex", "max_stars_repo_name": "b-mehta/tripos", "max_stars_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-27T11:16:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-27T11:16:41.000Z", "max_issues_repo_path": "II/algebraic_topology.tex", "max_issues_repo_name": "b-mehta/tripos", "max_issues_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "II/algebraic_topology.tex", "max_forks_repo_name": "b-mehta/tripos", "max_forks_repo_head_hexsha": "8d3037ede28fed3a3cdb82a88dd3a005bf94b310", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0170998632, "max_line_length": 801, "alphanum_fraction": 0.6220996775, "num_tokens": 24483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.40453866421388324}}
{"text": "% Prelim, Chapter 4\n% by Rachel Slaybaugh\n\n\\chapter{Preconditioning}\n\\label{sec:Chp4}\nThe new ``grand challenge'' problems facing the nuclear transport community are large and complex. Cutting edge methods are required to solve them. While the second and third chapters discussed methods that enable the solution of such problems, low-cost preconditioners that can reduce the number of iterations needed for convergence will be invaluable. In Benzi et al.'s 2002 survey paper on preconditioning techniques for large linear systems they state ``it is widely recognized that preconditioning is the most critical ingredient in the development of efficient solvers for challenging problems in scientific computation \\cite{Benzi2002}.'' \n\nThis is true for Krylov methods in particular because the memory required and cost per iteration increase dramatically with the number of iterations \\cite{Benzi2002}. And, as discussed in Chapter \\ref{sec:Chp3}, Krylov methods can converge very slowly for poorly conditioned systems. When this happens the eigenvector is not converged in a reasonable number of iterations and RQI cannot converge the eigenvalue. Preconditioning is therefore required to make RQI useful. \n\nThis chapter is about the new preconditioner added to Denovo. First some background information that includes an introduction to preconditioning, an overview of preconditioners used in the nuclear community, and a discussion of multigrid methods is given. Next, past and related work is discussed. Finally the new preconditioner is explained, and results demonstrating its impact are given. \n\n%-------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------\n\\section{Background}\nThe general idea of preconditioning is to transform the system of interest into another equivalent system that has more favorable properties, for example one with a smaller condition number. A preconditioner is a matrix that induces such a transformation by improving the spectral properties of the problem being solved. Let $\\ve{G}$ be a non-singular preconditioner, then $\\ve{A}x=b$ can be transformed in the following ways \\cite{Benzi2002}: \n%\n\\begin{alignat}{3}\n  \\ve{G}^{-1}\\ve{A}x &= \\ve{G}^{-1}b  &  &\\text{left preconditioning,} \\\\\n  \\ve{AG}^{-1}y &= b, \\qquad  &x = \\ve{G}^{-1}y \\qquad &\\text{right preconditioning, and } \\\\\n  \\ve{G}_{1}^{-1}\\ve{AG}_{2}^{-1}y &= \\ve{G}_{1}^{-1}b, \\qquad \\ve{G} = \\ve{G}_{1}\\ve{G}_{2}, \\qquad  &x = \\ve{G}_{2}^{-1}y  \\qquad &\\text{split preconditioning.} \n\\end{alignat}\n\nIf $\\ve{A}$ and/or $\\ve{G}$ are non-normal then each of the preconditioning constructs will likely give different behavior, though they will converge to the same answer because the matrices are similar and therefore have the same eigenvalues  \\cite{Benzi2002}. Right preconditioning leaves the right hand side of the equation unaffected and does not change the norm of the residual, which is used for convergence testing in most iterative methods. Right preconditioning is usually preferred over left preconditioning for iterative solvers for this reason \\cite{Knoll2004}. A right preconditioner was implemented in this work, and the remaining discussion will be presented in right preconditioner format. \n\nThe matrix $\\ve{A}\\ve{G}^{-1}$ is not formed in practice. The preconditioner can be applied by using some method to solve $\\ve{G}y=c \\to y \\approx \\ve{G}^{-1}c$, or by otherwise implementing the action of $\\ve{G}^{-1}$ without ever explicitly forming and inverting $\\ve{G}$. There are two extremes between which all other preconditioners lie: $\\ve{G} = \\ve{A}$, in which case the solution can be found directly, and $\\ve{G} = \\ve{I}$, which will have no effect \\cite{Benzi2002}, \\cite{Trefethen1997}. \n\nFunctionally, a good preconditioner should make the system easier to solve and result in faster convergence. It should also be cheap to construct and apply. These tend to be competing goals in that the easier a preconditioner is to construct and apply the less it typically does to improve convergence. A preconditioner is considered good if $\\ve{A}\\ve{G}^{-1}$ is not too far from normal and its eigenvalues are clustered \\cite{Trefethen1997}. \n\nThere are many different types of preconditioners, but they can be put into two general categories: matrix-based and physics-based. Matrix-based preconditioners rely entirely on the structure of the matrix $\\ve{A}$ regardless of the physics of the problem. That is, these methods do not change when the underlying problem changes. This can be a very useful property because matrix-based methods are then broadly applicable and do not require any understanding of the physical problem. Extrapolation methods and incomplete factorizations are examples of matrix-based preconditioners \\cite{Trefethen1997}.\n\nPhysics-based preconditioning uses knowledge about the physics of the problem in question to guide the creation of the preconditioner. This means that some methods only work with certain kinds of problems, and that the preconditioners may have to be tailored or adapted for different applications. However, such methods take advantage of knowing something about the problem and can be more effective than matrix-based methods for the range of problems for which they are intended. Rebalance and synthetic acceleration are examples of physics-based preconditioners \\cite{Trefethen1997}.\n\n%-----------------------------------------------------------------------------------------------\n\\subsection{Preconditioners in the Nuclear Community}\nA variety of acceleration methods have been used by the nuclear computational community over the years. This subsection gives a high-level overview of some common methods. In 2002 Adams and Larsen put together a comprehensive overview of the development of iterative methods for solving the \\Sn transport equation \\cite{Adams2002}. For more detail and history about each method, refer to this publication. \n\n\\subsubsection{Extrapolation Methods}\nExtrapolation methods were historically used to accelerate $k$-eigenvalue calculations. These tend to be based on simple iterative solvers or polynomial approximations. One step of a simple iterative method such as Jacobi, Gauss Seidel, or successive over relaxation (SOR) can be used at the outset of a problem to serve as a preconditioner \\cite{Trefethen1997}. When applied to neutron transport, an overrelaxation method looks like $\\ve{F}_{i+1} = \\omega(\\tilde{\\ve{F}}_i - \\ve{F}_i) + \\ve{F}_i$ with $1 \\le \\omega < 2$, where the unaccelerated new iterate for the fission source is designated $\\tilde{\\ve{F}}_i$ \\cite{Lewis1993}.\n\nPolynomial preconditioners create a matrix polynomial $\\ve{G}^{-1} = p(\\ve{A})$, where $p(\\ve{A})$ serves as a polynomial approximation to $\\ve{A}^{-1}$. Common polynomial choices are truncated Neumann series and Chebyshev polynomials. An advanced variation of this method is to determine the polynomial coefficients adaptively \\cite{Trefethen1997}. When Chebyshev polynomials are applied to the transport equation, $\\ve{F}_{i+1} = \\ve{F}_i + \\alpha_{i+1}(\\tilde{\\ve{F}}_i - \\ve{F}_i) + \\beta_i(\\ve{F}_i - \\ve{F}_{i-1})$, where $\\alpha$ and $\\beta$ are iteration dependent \\cite{Lewis1993}. Neither of these extrapolation methods are widely used today as they have not been very successful in multi-dimensional problems. There are analogous versions of these methods for fixed source problems \\cite{Alcouffe1977}.  \n\n\\subsubsection{Rebalance}\nRebalance methods are designed to accelerate iteration on the scattering or fission source by imposing a balance condition on the unconverged solution over either coarse or fine regions. If the region is coarse, this is a coarse-grid approximation preconditioner since fine-grid physics are excluded. If the region is fine, this is a local approximation preconditioner where short range effects are permitted and long range interactions are excluded \\cite{Trefethen1997}, \\cite{Adams2002}.\n\nIn either case, the unaccelerated solution is multiplied by a constant in each region that satisfies the balance equation. The rebalance process adjusts the average amplitude of the flux over a region and the iteration adjusts the space-angle distribution. The notion is that these processes work in concert to eliminate all error modes simultaneously \\cite{Adams2002}. \n\nCoarse mesh rebalance (CMR) has been more successful than the fine version and is therefore used more often. In practice, choosing regions properly must be done with care \\cite{Lewis1993}. Traditional forms of CMR can be unstable for problems where the spatial mesh is large compared to the neutron mean-free-path and where the scattering ratio is close to unity \\cite{Alcouffe1977}. \n\n\\subsubsection{Incomplete Factorizations}\nIncomplete factorization methods were first introduced in the 1950s by Buleev, and independently by Varga. In the late 1970s these methods started gaining popularity, and since then have been under active development. The idea is to partially factor the matrix $\\ve{A}$ such that the resulting matrices are sparse enough to take advantage of sparse solver methods, but close enough to $\\ve{A}$ to be valuable as preconditioners \\cite{Benzi2002}.\n\nIncomplete Cholesky (IC) or incomplete LU (ILU) factorization have both been extensively used within the nuclear community. The Cholesky version is used when $\\ve{A}$ is symmetric and LU when non-symmetric. Factorizations typically destroy sparsity, resulting in matrices that are denser than the originals and making their use more costly. Different variations of incomplete factorization methods address this by permitting the new matrices to have values only in positions where $\\ve{A}$ has values, allowing a prescribed amount of fill in, or only saving entries greater than some tolerance \\cite{Trefethen1997}, \\cite{Patton2002}, \\cite{Oliveira1998}.\n\n\\subsubsection{Synthetic Acceleration}\nIn synthetic acceleration a low-order approximation to the transport operator is used to accelerate the full transport problem \\cite{Lewis1993}. If a system is discretized with a high-order method it can be preconditioned with a lower-order approximation. The low-order method is often much sparser than the original, but still captures the general behavior of the problem \\cite{Trefethen1997}. This is generally done with either the diffusion equation, giving diffusion synthetic acceleration (DSA), or a transport equation  that is simpler than the one actually being solved, giving transport synthetic acceleration (TSA). These can be used for fission or fixed source problems \\cite{Adams2002}. \n\n%Synthetic methods have at least two iteration stages. The simplest way to illustrate this is to use source iteration for the within-group solver. The first step is a transport sweep, giving:\n%%\n%\\begin{equation}\n%  \\ve{L}\\psi^{(l+\\frac{1}{2})} = \\ve{S}\\psi^{(l)} + q \\:, \\qquad l \\ge 0 \\:.\n%  \\label{eq:synthetic}\n%\\end{equation}\n%%\n%Here $l$ is the iteration index, $\\ve{L}$ is the transport operator, $\\ve{S}$ is the scattering matrix, and $q$ is the external source. Equation \\eqref{eq:synthetic} is subtracted from the exact equation to get an expression for an exact additive correction:\n%%\n%\\begin{equation}\n%  \\bigl( \\ve{L} - \\ve{S} \\bigr)\\bigl( \\psi - \\psi^{(l+\\frac{1}{2})} \\bigr) = \\ve{S}\\bigl(\\psi^{(l+\\frac{1}{2})} - \\psi^{(l)} \\bigr) \\:.\n%  \\label{eq:correction}\n%\\end{equation}\n%%\n%This cannot be solved exactly, but the idea of synthetic methods is to find an $\\ve{G}^{-1} \\approx (\\ve{L} - \\ve{S})^{-1}$ that will be easier to evaluate than $(\\ve{L} - \\ve{S})^{-1}$. Equation \\eqref{eq:synthetic} is solved by a high-order scheme and Equation \\eqref{eq:correction} is solved with a low-order approximation. If the synthetic system converges, it must satisfy the original transport equation \\cite{Adams2002}. \n\nOriginal DSA formulations exhibited instability in some instances. In 1977 Alcouffe demonstrated with diamond difference that stability can be obtained by using a consistent spatial differencing scheme \\cite{Alcouffe1977}. The transport and diffusion equations cannot be discretized independently or the diffusion equation may not satisfy the original transport equation. The discretization of the diffusion equation must therefore be derived from the discretization of the transport equation such that they are consistent. Alcouffe's idea has since been extended to accelerate currents, to more dimensions, and to different spatial discretizations \\cite{Larsen1982}. \n\nDSA can be implemented a few different ways, each of which performs a transport sweep and then solves a corrected diffusion equation. Different terms in the diffusion equation can be corrected for different problem types \\cite{Alcouffe1977}. DSA has been found to degrade in the presence of material discontinuities in addition to when it is not consistently derived. However, Warsa et al.\\ found that when DSA is used as a preconditioner for Krylov iterative methods, it is effective even when only partially consistent \\cite{Warsa2004}.\n\nTo address the concerns about spatial discretization associated with DSA, a low-order transport solve could be used to find the correction term instead. Larsen and Miller developed a method that neglects scattering in the low-order transport equation, but this can cause instability in multi-dimensional problems \\cite{Larsen1986}. Ramone et al.\\ proposed including some scattering by using a tunable parameter. A high-order transport equation is solved first, then a transport equation with a coarse quadrature and reduced scattering is solved to find the correction that is applied to the new iterate of the scalar flux \\cite{Ramone1997}. This algorithm can be viewed as Richardson iteration with a coarse operator preconditioner. Synthetic acceleration methods are widely used and actively researched in the transport community today.\n\n%-----------------------------------------------------------------------------------------------------\n\\subsection{Multigrid Methods}\nThe new preconditioner added to Denovo does multigrid in the energy dimension. To understand why multigrid in energy makes sense, why multigrid methods work must be understood. The material presented here is largely from \\emph{A Multigrid Tutorial} by Briggs, Henson, and McCormick \\cite{Briggs2000}, supplemented by Dr. Strang's lectures on multigrid and preconditioners available as MIT Open Courseware \\cite{Strang}.\n\nIn what follows, the system of equations will be denoted as $\\ve{A}u=b$ where $u$ will represent the exact solution and $v$ will indicate the approximate solution. The algebraic error is given by $e = u - v$. Since $e$ cannot be calculated exactly (otherwise the answer would be known), the residual $r = b - \\ve{A}v$ is used instead. A certain grid will be denoted as $\\Omega^{h}$ where $h$ is the grid spacing, and vectors on that grid are $u^{h}$. \n\nThe error in any guess can be written as a combination of Fourier modes. A Fourier mode is described by a wavenumber, $k$, which denotes the frequency of oscillation. The $j$th Fourier mode is \n% \n\\begin{equation}\n    e_{j} = \\sin\\bigl(\\frac{jk\\pi}{n}\\bigr) \\:, \\qquad 0 \\le j \\le n \\:, \\qquad 1 \\le k \\le n-1 \\:.\n\\end{equation} \n%\nThere are $k$ half sine waves that comprise $e$ on the domain of the problem. The term $e_{k}$ indicates an $e$ with wavenumber $k$. The $k$th wave has $\\frac{k}{2}$ full sine waves with a wavelength of $\\frac{2}{k}$. Modes with wavenumbers in the range $1 \\le k \\le \\frac{n}{2}$ are called low-frequency or smooth modes and those in $\\frac{n}{2} \\le k \\le n-1$ are called high-frequency or oscillatory modes. Figure \\ref{fig:FourierModes} shows what a few different modes look like. \n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.45\\textwidth, height=0.2\\textheight] {FourierModes}\n   \\end{center}\n   \\caption{Three Fourier Modes \\cite{Briggs2000}}\n   \\label{fig:FourierModes}\n\\end{figure}\n\nIterative methods, also referred to as smoothers or relaxers, remove high frequency error components very quickly, but take a long time to remove the low frequency components. This is illustrated in Figure~\\ref{fig:FourierError}, where weighted Jacobi was applied to Fourier modes of different frequencies on an $n$ = 64 grid. The error is reduced much faster for higher modes. \n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.5\\textwidth, height=0.3\\textheight] {FourierError}\n   \\end{center}\n   \\caption{Log of Error As a Function of Iteration Count When a Relaxer is Applied to Three Fourier Modes \\cite{Briggs2000}}\n   \\label{fig:FourierError}\n\\end{figure}\n%\nThe rapid removal of oscillatory and slow removal of smooth error modes is often seen in practice. Figure~\\ref{fig:MGerrorExample} shows an error plot that exhibits this behavior\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.7\\textwidth, height=0.4\\textheight] {MGerrorExample}\n   \\end{center}\n   \\caption{Error As a Function of Iteration Count; Oscillatory Components Are Removed Rapidly, Leaving Smooth Components \\cite{Briggs2000}}\n   \\label{fig:MGerrorExample}\n\\end{figure}\n\nThe idea of multigrid methods is to take advantage of the smoothing effect by making smooth error look oscillatory so it can be removed more easily. Error that is low frequency on a fine grid can be mapped onto a coarser grid where it is oscillatory. This change can be thought of as increasing the number of oscillations per grid point. Look at Figure~\\ref{fig:FourierGridError} for an example. When $n$ = 12, the maximum number of half-sine waves is 12, so $k$ = 4 is relatively smooth. When mapped to $n$ = 6, $k$ = 4 is relatively oscillatory. \n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.55\\textwidth, height=0.33\\textheight] {FourierGridError}\n   \\end{center}\n   \\caption{Relative Oscillation of a Fourier Mode Mapped Between Two Grids \\cite{Briggs2000}}\n   \\label{fig:FourierGridError}\n\\end{figure}\n\nUsing this information, multigrid methods can be understood. The error is mapped from a fine grid to a coarser grid. A smoother is applied on the coarse grid to remove the newly oscillatory error components. The result is mapped back to the fine grid and used to correct the solution there. A few more relaxations are done back on the fine grid. That whole process is called a v-cycle, which is described in Algorithm~\\ref{algo:MG}. A call to this method is symbolized as $v^h \\leftarrow \\ve{G}(v^h, b^h)$ and is effectively doing $v^{h} \\approx \\ve{G}^{-1}b^{h}$.\n%\n\\begin{algorithm}\n  \\caption{ Multigrid v-cycle: $v^h \\leftarrow \\ve{G}(v^h, b^h)$}\n  \\label{algo:MG}\n  \\begin{list}{}{\\hspace{2.5em}}\n    \\item Relax $\\nu_1$ times on $\\ve{A}^h u^h = b^h$ on the fine grid $\\Omega^h$ using initial guess $v^h$.\n    \\item Compute the residual $r^h = b^h - \\ve{A} v^h$. \n    \\item Using some restriction operator, $\\ve{R}_h^{2h}$, restrict the residual to a coarser grid: $r^{2h} =  \\ve{R}_h^{2h} r^h$. \n    \\item Solve the residual equation $\\ve{A}^{2h} e^{2h} = r^{2h}$ on the coarse grid $\\Omega^{2h}$. \n    \\item Using some prolongation operator, $\\ve{P}_{2h}^h$, prolong (interpolate) the coarse grid error back to a finer grid: $e^h = \\ve{P}_{2h}^h e^{2h}$. \n    \\item Add the error to the fine grid guess: $v^h \\leftarrow v^h + e^h$. \n    \\item Relax $\\nu_2$ times on $\\ve{A}^h u^h = b^h$ on $\\Omega^h$ to get an improved solution. \n   \\end{list}\n\\end{algorithm}\n\nThe details of how restriction and prolongation are done are problem dependent. Simple iterative schemes can have very simple operators while more complex schemes may require more complex mappings. Other implementation choices are what relaxer to use and how many relaxations to do on each grid.\n\nThere are many variations of how multigrid methods are put together. All methods, however, are built on the basic v-cycle correction scheme. A V-cycle is an extension of the v-cycle. Instead of only using two grids, many grids are used. The problem is restricted from grid to grid until it is on some grid which is coarse enough to directly invert the equations. Then the errors are prolonged back up the chain, continuously correcting on finer grids, until the finest grid is reached. Multigrid methods are differentiated by how many times the V-cycle is done and how many grids are used. A five-grid V-cycle can be seen in Figure~\\ref{fig:Vcycle} (a). A W-cycle is when V-cycles are repeated to further improve the answer. An example can be seen in Figure~\\ref{fig:Vcycle} (b). \n\\begin{figure}\n    \\begin{center}\n      \\includegraphics [width=0.7\\textwidth, height=0.7\\textheight, angle=180 ] {multigridFig}\n   \\end{center}\n   \\caption{Grid Schedule for (a) a V-cycle, (b) a W-cycle, and (c) a Full Multigrid Pattern \\cite{Briggs2000}}\n   \\label{fig:Vcycle}\n\\end{figure}\n\nMultigrid can also be used to obtain an initial guess where much of the smooth error has been removed. This is called nested iteration, and the iterations begin on the coarsest grid and move up to the finest grid. If nested iteration is combined with V-cycles, the full multigrid method (FMG) is obtained, as seen in Figure~\\ref{fig:Vcycle} (c). A call to any of the combinations of v-cycles is denoted $v \\leftarrow \\ve{G}(v, b)$. The optimal combination of grids and cycles may depend on problem type. The addition of more grids and cycles will reduce error, but at an added cost. \n\nMultigrid methods can be thought of as stationary iterative schemes that can be used alone or as accelerators for other methods. In the past these methods were highly problem specific and only applied to second-order elliptic PDEs. Over time they have been extended to different problem types, geometries, and discretizations \\cite{Benzi2002}. \n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\section{Past Work}\nThis section discusses some past work from most of the categories of preconditioners that were presented above. The focus is on methods that have been used to precondition Krylov solvers and on multigrid methods. This section is intended to illustrate the need for preconditioning Krylov methods in transport and to demonstrate the new preconditioner's originality. \n\nAs an aside, it is important to note that how well a preconditioner is going to perform for a certain problem when using Krylov methods cannot be known \\emph{a priori}. At this time there are no set methods or procedures for predicting preconditioner behavior with Krylov methods. As a result, preconditioning Krylov methods is somewhat ``guess and check.'' Despite this, the rewards of preconditioning Krylov methods ensure that they are an essential part of their practical use \\cite{Knoll2004}, \\cite{Benzi2002}. \n\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Rebalance}\nCMR has been widely used in transport codes since at least the 1970s and new variants of it are being applied to Krylov solvers \\cite{Dahmani2002}, \\cite{Yamamoto2005}. For example, Dahmani et al.\\ investigated using GMRES and preconditioned GMRES for solving the 3-D transport equation using the method of characteristics (MOC) in 2005. Self-collision rebalance (SCR) was used as a left preconditioner. SCR uses the probability of a region scattering particles to itself to rebalance the energy distribution in each region. MOC is quite different from \\Sn and requires a specific derivation to be able to use GMRES \\cite{Dahmani2002}. \n\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Incomplete Factorizations}\nIncomplete factorizations have also been used to precondition Krylov methods, though without much success for large transport problems. Patton and Holloway investigated the use of a variety of preconditioners for GMRES to solve the multi-group, diamond-difference, 1-D, \\Sn equations. They compared matrix-based and physics-based right preconditioners. A variety of factorization methods, the matix-based preconditioners, were considered: ILU(0), modified ILU(0) (MILU), ILU($\\tau=10^{-4}$), ILU($p=10$), and ILU($\\tau=10^{-4}, p=10$), where $\\tau$ is the drop tolerance and $p$ indicates the amount of fill-in allowed. A single integer indicates the fill-in limit. \n\nThe bandwidth of $\\ve{A}$ increases as the number of energy groups and/or discrete ordinates increases \\cite{Patton2002}. Here, the bandwidth of the matrix is $2GM$ where $G$ is the number of energy groups and $M$ is the number of discrete ordinates. The computational time required by ILU factorization increases with the bandwidth of $\\ve{A}$. This makes factorization methods unattractive as accelerators for finely discretized problems. This prompted Patton and Holloway to consider physics-based methods. \n\n%A matrix splitting was chosen such that the original problem formulation was written as:\n%%\n%\\begin{equation}\n%  \\ve{L}\\psi - \\ve{S}_{in}\\psi = \\ve{Q} \\:,\n%\\end{equation}\n%%\n%where $\\ve{L}$ is the streaming plus removal term, $\\ve{S}_{in}$ is the inscattering source, and $\\ve{Q}$ contains the external source. Patton and Holloway use $(\\ve{L} - \\ve{S}_{down})^{-1}$ as the preconditioner, where  $\\ve{S}_{down}$ is the downscatter part of the $\\ve{S}$ matrix. They use source iteration as the within-group solver such that each new guess is obtained by applying $(\\ve{L} - \\ve{S}_{down})^{-1}(\\ve{S}_{in} - \\ve{S}_{down})$ to the old guess. \nA matrix splitting method was chosen that used physics rather than generic structural properties to inform how to do the splitting. They used source iteration as the within-group solver. For the 1-D case they found that this physics-based preconditioner was faster than the matrix-based factorization preconditioner, but that DSA was faster than both \\cite{Patton2002}. This is not surprising because DSA is so effective for 1-D with diamond difference. \n\nIn 2004 Chen and Sheu compared preconditioned conjugate gradient methods with SOR for 3-D, multigroup neutron transport. They used ILU and MILU to precondition both conjugate gradient squared (CGS) and BiCGSTAB. They chose these iterative techniques because they have good residual error control procedures that give good convergence rates in general \\cite{Chen2004}.\n\nKozlowski, Downar, and Lewis investigated a Krylov preconditioning method for the multi-group $SP_3$ transport equations. This method involves reordering the fluxes to facilitate the use of block ILU as the preconditioner. This idea worked well for small problems, but may require too much storage for large problems \\cite{Kozlowski2003}.\n\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Synthetic Acceleration}\nDSA has been under continuous development since Alcouffe's 1977 paper. For example, a recent research string began when Wareing, Larsen, and Adams developed a simple DSA scheme for bilinear discontinuous (BLD) discretizations in 2-D. An unconditionally efficient multigrid technique for solving these 2-D, BLD equations was derived by Morel, Dendy, and Wareing. This was later extended to bilinear nodal differencing and bilinear characteristic differencing \\cite{Adams2002}. New versions of DSA are applied to Krylov solvers in current transport codes.\n\nVery recently Rosa et al.\\ performed detailed Fourier Analysis on TSA combined with Inexact Parallel Block-Jacobi (IPBJ) splitting applied to the one- and two-dimensional transport cases. They noted that both experience in the nuclear community and analytical work have shown that solution methods such as GMRES(m) can stagnate for problems containing optically thin spatial regions. Rosa et al.'s analysis and results show that using modified TSA improves the spectral properties such that convergence can be obtained using a relatively small m when using GMRES(m) \\cite{Rosa2010}.\n\n\\subsubsection{DSA in Denovo}\nDenovo has the option to use DSA to precondition the within-group transport equation, $\\bigl(\\ve{I} - \\ve{DL}^{-1}\\ve{MS}_{gg}\\bigr) \\phi_{g} = \\ve{DL}^{-1}Q_{g}$, which works very well when using a Krylov method. High-frequency error modes are what often cause instability in DSA. Krylov iteration, like iterative methods in general, will rapidly damp such oscillatory modes. Eliminating the high-frequency error enables the removal of the consistency requirement since DSA is not likely to fail when those error modes are gone \\cite{Evans2009d}. This means DSA can be applied successfully for a variety of spatial discretizations. \n\nThe DSA-preconditioned one-group equation is:\n%\n\\begin{equation}\n  \\bigl(\\ve{I} + \\ve{PC}^{-1}\\ve{RS}\\bigr) \\bigl(\\ve{I} - \\ve{DL}^{-1}\\ve{MS}\\bigr) \\phi = \\bigl(\\ve{I} + \\ve{PC}^{-1}\\ve{RS}\\bigr)\\ve{DL}^{-1}\\bar{Q} \\:. \n  \\label{DSA1group}\n\\end{equation}\n%\nHere $\\ve{C}$ is the diffusion operator defined in Appendix~\\ref{sec:AppendixA}; $\\ve{R}$ is the restriction operator that maps the transport solution onto the diffusion vector; and $\\ve{P}$ is the projection operator that maps the diffusion vector onto the transport solution. Denovo does not actually form these operators, instead it solves the diffusion equation and updates the $\\phi_{00}$ moments. In practice this means that for a Krylov iteration\n%\n\\begin{equation}\n  \\ve{C}z = \\ve{RS}\\bigl(\\ve{I} - \\ve{DL}^{-1}\\ve{SM}\\bigr) v\n\\end{equation}\n%\nis solved for each group. In Denovo, DSA has been found to be beneficial for diffusive problems with high scattering ratios that are close to being isotropic \\cite{Evans2009d}. This is consistent with experiences of the wider nuclear community.\n\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Multigrid Methods}\nBeginning in the late 1980s, the nuclear community started using spatial \\mg and/or angular \\mg as both solvers and preconditioners. The first use of spatial \\mg for transport equations in 1-D and 2-D was investigated by Nowak et al. Since that time \\mg has been used in multiple dimensions, for both isotropic and anisotropic scattering, and for various spatial discretizations \\cite{Adams2002}. Some highlights from recent work are discussed below. All are applied to the \\Sn neutron transport equation unless otherwise noted. \n\nIn 1996 Sjoden and Haghighat used a simplified spatial \\mg method that does not use the residual as a solver for the 3-D, parallel code PENTRAN \\cite{Sjoden1996}. In 1998 multigrid in space and multigrid in angle were used as preconditioners for Krylov methods and were tested for the 1-D, one-group, modified linear discontinuous (MLD) neutron transport equations by Oliveira and Deng. They looked at isotropic scattering without absorption, isotropic with absorption, and anisotropic cases. They had better results with multigrid than when using ILU as a preconditioner \\cite{Oliveira1998}.\n\nIn 2007 Chang et al.\\ used 2-D spatial \\mg for the isotropic scattering case with corner balance finite difference in space and a four-color block-Jacobi relaxation scheme. A bilinear interpolation operator and its transpose were used for grid transfer. The method had some trouble with heterogeneous problems. The authors assert their algorithm is parallelizable \\cite{Chang2007}.\n\nIn 2010 Lee developed a method to do \\mg in space and angle simultaneously for two and three dimensions, isotropic and anisotropic scattering, one energy group, and a variety of spatial discretizations. The method can perform \\mg in only space, only angle, or some combination there of. It also handles thick and thin cells \\cite{Lee2010}.\n\nThis list is hardly comprehensive, but is intended to be representative of new and recent developments in this area. No cases were found where \\mg was used in the energy variable either as a solution technique or as a preconditioner. \n\n\\subsubsection{Two-Grid Acceleration}\nThe two-grid acceleration method developed by Adams and Morel was one of the earlier spatial \\mg methods and it has been built upon by others \\cite{Adams1993}. It is intended to accelerate convergence of the outer iterations for the transport equation when upscattering is present; the outer iteration method is Gauss Seidel and the method is only applied to upscattering groups. The original work was done for slab geometries with linear discontinuous (LD) discretization. The general approach is expounded upon here to provide an example of \\mg methods applied to the transport equation and because a variation of this method is used in Denovo. \n\nAdams and Morel create a within group error equation by subtracting the GS equation from the transport equation. If the error in iteration $k$ is $\\epsilon^k$ and the $l$th moment of the residual is $R_l^k$, then for group $g$ in 1-D this gives:\n%\n\\begin{align}\n   \\mu \\frac{\\partial \\epsilon_{g}^{k+1}(\\mu)}{\\partial x} + \\Macro_{t,g} \\epsilon_{g}^{k+1}(\\mu) &= \\sum_{l=0}^{L}\\frac{2l+1}{4\\pi} \\bigl( \\sum_{g'=1}^{G}\\Macro_{s,g' \\to g, l} \\epsilon_{g',l}^{k+1} \n   +  R_{g,l}^{k+1}\\bigr) P_{l}(\\mu) \\:,\\label{eq:GSerror} \\\\\n  \\epsilon_{g}^{k+1}(\\mu) &= \\psi_{g}(\\mu) - \\psi_{g}^{k+1}(\\mu) \\:, \\\\\n  \\epsilon_{g',l}^{k+1} &= 2\\pi \\int_{-1}^{1}\\epsilon_{g'}^{k+1}(\\mu') P_{l}(\\mu') d\\mu' \\:, \\\\ \n  R_{g,l}^{k+1} &=  \\sum_{g'=g+1}^{G}\\Macro_{s,g' \\to g, l} \\bigl( \\phi_{g',l}^{k+1} - \\phi_{g',l}^{k} \\bigr) \\:.\n\\end{align}\n%\nThe diffusion approximation is applied to Equation \\eqref{eq:GSerror}, giving a coarse grid equation. The fine grid is the \\Sn equations for the upscattering groups. The coarse grid is the isotropic, one-group, diffusion equation. \n\nIt is assumed that the zeroth moment of the error is a product of a spectral shape function, $\\xi_g$ and a space-dependent modulation function, $E(x)$, giving\n%\n\\begin{align}\n  \\epsilon_{g,0}^{k+1}(x) &= E(x)\\xi_{g} \\:, \\text{ and} \\label{eq:errorExpand} \\\\\n  \\sum_{g=1}^{G} \\xi_{g} &= 1 \\:.\n\\end{align} \n%\nThe spectral shape function corresponds to the slowest converging error mode, i.e.\\ the mode to be eliminated. To find the shape function, Fourier analysis is performed on the GS iterative method. The zeroth moment of the cross sections is used to form the Fourier matrix, and then an eigenproblem can be formed. The spectral radius of the isotropic GS matrix is the eigenvalue, and the corresponding eigenvector is the shape function. Because the shape function is dependent on materials, one such calculation must be done for each material region. Note that by using the zeroth moment only the isotropic component of the solution is accelerated.\n\nTo restrict the residual, which is used as the source, to the coarse grid in the angular dimension, the anisotropic terms are truncated. To restrict to one energy group, the residual is simply summed in energy. The coarse grid equation is then solved on the coarse grid for the error. That error is prolonged to the fine grid and used to correct the flux there. The anisotropic terms are not recovered in the prolongation. The shape functions are used to expand the one group diffusion solution (error) into multiple groups. \n\nThe coarse grid diffusion equations that result from Equations \\eqref{eq:GSerror} and \\eqref{eq:errorExpand} differ slightly in form from the standard diffusion equation in that there is an extra term containing the gradient of the shape function. This is zero in homogeneous regions, but undefined at material interfaces. Adams and Morel found that neglecting the gradient term all together still gave good results for their test problems. This may not be true for more complex cases.\n\nThe two-grid method requires the diffusion operator to be consistent with the transport operator, just like in DSA. This requirement can be difficult to meet for multi-dimensional problems, particularly for some spatial discretizations \\cite{Adams1993}. \n\n\\subsubsection{Two-Grid in Denovo}\n\\label{sec:TTG}\nDenovo has a two-grid acceleration scheme based on the one developed by Adams and Morel. As noted above, the iteration procedure uses a collapsed one-group diffusion equation to correct the low-order Fourier modes \\cite{Adams1993}. Because of the consistency requirement for the discretization of the diffusion operator in multi-dimensional and multi-material problems, this method can fail for systems of interest \\cite{Evans2009d}. \n\nThe original two-grid method was modified by Evans et al.\\ to make it applicable for the desired cases by using a one-group transport equation instead of the diffusion equation. The modified method is called transport two-grid (TTG). Adams and Morel showed that the slowest converging spatial modes are diffusive and can be exactly computed in the infinite homogeneous case. To preserve this, the TTG method gives the correct error estimation in that limit \\cite{Evans2009d}. \n\nThe cross sections used in TTG are therefore calculated to give the same energy-collapsed cross sections as the diffusion equation for the infinite homogeneous case, as seen in Equations \\eqref{TTGxsecs1} and \\eqref{TTGxsecs2}. TTG solves a one-group transport equation for the low-order error in each GS iteration, where $[g1, g2]$ is the group range of the upscatter block:\n%\n\\begin{align}\n  \\ve{\\hat{\\Omega}} \\cdot \\nabla \\psi_{\\epsilon} &+ \\bar{\\Macro}\\psi_{\\epsilon} = \\frac{1}{4\\pi}\\bar{\\Macro}_{s}\\phi_{\\epsilon} + \\frac{1}{4\\pi}\\bar{R} \\:, \\\\\n  \\bar{\\Macro} &= \\frac{1}{\\sum_{g=g_1}^{g_2} \\frac{1}{\\Macro^g}\\zeta^g} \\label{TTGxsecs1} \\:,\\\\\n  \\bar{\\Macro}_{s} &= \\frac{1}{\\sum_{g=g_1}^{g_2} \\frac{1}{\\Macro^g}\\zeta^g} - \\sum_{g=g_1}^{g_2} \\bigl(\\Macro^g\\zeta^g - \\sum_{g'=g_1}^{g_2} \\Macro_{s0}^{gg'} \\zeta^{g'} \\bigr) \\label{TTGxsecs2} \\:. \n\\end{align}\n%\nThe spatial components of the error are $\\psi_{\\epsilon}$ and $\\phi_{\\epsilon}$; $\\bar{R}$ is the residual. Just as in the original method, it is assumed that the error is separable in space and energy at each iteration: $\\epsilon_g^k = \\phi_g - \\phi_g^k = \\phi_{\\epsilon}(\\vec{r})\\zeta^g$, where $\\zeta^g$ is a material-dependent spectral function \\cite{Evans2009d}. \n\nTo execute the TTG scheme in Denovo, a transport sweep in conducted in each group, a residual is calculated, the low-order transport solve described above is performed, an error form of the transport sweep is conducted, and the scalar flux is updated. All of that can be seen in the following equations: \n\\begin{align}\n  \\ve{L}_g \\psi_g^{k+\\frac{1}{2}} &= \\ve{M}\\bigl(\\ve{S}_{gg}\\phi_g^{k+\\frac{1}{2}} + \\sum_{g'=g_1}^{g-1} \\ve{S}_{gg'}\\phi_{g'}^{k+\\frac{1}{2}} + \\sum_{g'=g+1}^{g_2}\\ve{S}_{gg'}\\phi_{g'}^k \\bigr) + q_{e,g}  \\:, \\\\\n  R^{k+\\frac{1}{2}}_g &= \\ve{M} \\sum_{g'=g+1}^{g_2}\\ve{S}_{gg'} \\bigl( \\phi_{g'}^{k+\\frac{1}{2}} - \\phi_{g'}^k \\bigr) \\:, \\qquad l = m = 0 \\:, \\\\\n  \\bar{\\ve{L}}\\psi_{\\epsilon} &= \\ve{M\\bar{S}} \\phi_{\\epsilon} + \\bar{R} \\:, \\qquad l = m = 0 \\:, \\label{TTGerrorEqn} \\\\\n  \\phi_g^{k+1} &= \\phi_{g}^{k+\\frac{1}{2}} + \\phi_{\\epsilon}\\zeta^g \\:, \\qquad l = m = 0 \\:.\n\\end{align}\nThe operators with over-bars use the collapsed cross sections given in Equations \\eqref{TTGxsecs1} and \\eqref{TTGxsecs2}, and $\\bar{R} = \\sum_{g=g_1}^{g_2} R_g^{k+\\frac{1}{2}}$. \n\nThe $\\zeta_g$ term is calculated from the eigenvalue problem obtained through Fourier analysis of the GS method using isotropic scattering, just like the original two-grid method:\n%\n\\begin{equation}\n  \\bigl(\\ve{T} - \\ve{S}_L + \\ve{S}_D\\bigr)^{-1} \\ve{S}_U\\zeta = \\rho\\zeta \\:,\n\\end{equation}\nwhere $\\ve{T}$ is the diagonal, total cross section matrix. As with the original two-grid method, the TTG method is limited to correcting only the isotropic flux moments. This is an adequate limitation as these moments are dominant in thermal groups where upscattering is most prevalent\\cite{Evans2009d}.   \n\nThe additional cost of the method is like solving one extra group, so for cases with many upscattering groups the cost can be amortized. The acceleration equation can be preconditioned with DSA for additional speed. Finally, a reduced quadrature set can be used when solving Equation~\\eqref{TTGerrorEqn} to limit the cost. Some test problems have shown TTG to be quite effective in improving the speed of convergence for upscatter problems when compared to unaccelerated GS \\cite{Evans2009d}.\n\n%-------------------------------------------------------------------------------------------------------\nClearly, a wide variety of preconditioning techniques have been applied to the neutron transport equation. It is worth noting that many of these methods are dependent upon the choice of spatial discretization employed, only apply to within group iterations, or have other important limitations. Preconditioning Krylov methods for solving the neutron transport problem is an active and vital area of research where much progress has been made and in which there is still much room for development. \n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\section{Multigrid in Energy}\nPreconditioning is a very important part of increasing the robustness of Krylov methods. This is particularly true in this work for two reasons. The first is that the multigroup Krylov solver can create very large Krylov subspaces because it forms the subspaces withmultiple-group-sized vectors. As a result, any reduction in iteration count will have a large benefit in terms of both memory and cost per iteration. The second is that preconditioning is needed to compensate for the ill-conditioned systems created by RQI so that the eigenvector can be converged. \n\nA new physics-based, multigrid-in-energy preconditioner has been added to Denovo to improve the performance of the Krylov solves. Choosing a physics-based preconditioner supports the goal of accelerating a code that solves a specific equation rather than developing an all purpose preconditioner. It makes sense to take advantage of information specific to the neutron transport equations. Previous work has shown that physics-based preconditioners often provide more benefit than matrix-based methods. Further, the matrix $\\ve{A}$ is never formed in Denovo, ruling out matrix-based preconditioners. \n\nAmong physics-based preconditioners, a multigrid method was selected because they have been generally successful at accelerating the transport equation, and the residual behavior in the Krylov iterations inside RQI looks like the ideal case for multigrid methods.\n\nThe preconditioner was designed to take advantage of the energy decomposition added by the MG Krylov method. Having grids in energy rather than space or angle means that each energy set can use its own grids without communicating with other sets. An additional benefit is the simplicity of energy grids. Energy is one dimensional, which makes the grids much less complex (and likely less costly) than angular or multi-D spatial grids. \n\nTo make energy grids, the energy group structure is coarsened so each lower grid has fewer groups on it. The finest grid is the input energy structure, and the coarsest grid has one or a few groups. Each level has half as many groups as the previous level, rounded up if applicable. This is conceptually straightforward because the energy groups can be combined (restricted) and separated (prolonged) linearly. \n\nThere are a variety of options that must be considered in designing a multigrid scheme: the restriction and prolongation operators, the relaxation method, the number and/or pattern of V-cycles to use, the number of relaxations to do on each grid level, and the depth of the V-cycle. Among these the number of number of V-cycles and the number of relaxations per level have been implemented as user input options; the others are fixed. \n\nThe implemented restriction operator is a simple averaging scheme. Neighboring fine data are averaged together to make coarse data. Recall that in multigrid methods the variables being restricted and prolonged are error modes. For a grid with spacing $h$ and a next-coarser grid $2h$, the errors are restricted as $e_{g}^{2h} = \\frac{1}{2}(e_{2g}^{h} + e_{2g+1}^{h})$ for $g = 1,...,G$, where $G$ is the number of groups on the coarse grid and $2G+1$ is the number of groups on the fine grid. If there are an odd number of groups the lowest energy group's datum is just copied. This scheme was chosen so that the thermal energy groups would retain more granularity, which should improve accuracy for thermal reactors. The errors are restricted every time there is a transfer to a coarser grid.\n\nThe cross sections are restricted from the finest to the coarsest grid during problem initialization and they do not change thereafter. The total and fission cross sections are restricted in the same way as the errors. Scattering is slightly more complicated since it has two indices, $g$ and $g'$. When there are an even number of groups all cross sections are treated the same way. For $g' = 1,..., G'$ and $g = 1, ..., G$,\n\\begin{equation}\n  \\Sigma_s^{2h}(g,g') = \\frac{1}{4}[\\Sigma_s^{h}(2g,2g') + \\Sigma_s^{h}(2g+1,2g') + \\Sigma_s^{h}(2g,2g'+1) + \\Sigma_s^{h}(2g+1,2g'+1)] \\:. \n  \\label{eq:XSSeven}\n\\end{equation}\n% \nUnless there is upscattering in every group, some of the entries in Equation~\\eqref{eq:XSSeven} will be zero. When there are an odd number of groups Equation \\eqref{eq:XSSeven} is used until $g=G-1$ and $g'=G'-1$. For the last group\n  \\begin{align}\n    \\Sigma^{2h}_s(G,g') &= \\frac{1}{2}[\\Sigma^{h}_s(2G,2g') + \\Sigma^{h}_s(2G,2g'+1)] \\qquad \\text{for } g' = 0,...,G'-1 \\:,\\nonumber \\\\\n    \\Sigma^{2h}_s(g,G') &=  \\frac{1}{2}[\\Sigma^{h}_s(2g,2G') + \\Sigma^{h}_s(2g+1,2G')] \\qquad \\text{for } g  = 0,...,G-1 \\:,\\nonumber \\\\\n    \\Sigma^{2h}_s(G,G') &= \\Sigma^{h}_s(2G,2G') \\nonumber \\:.\n  \\end{align}\n\nThe cross sections could be flux-weighted and re-restricted every time a new value for the flux were available, i.e.\\ every new application of the preconditioner, to more accurately preserve physics. The experience of the computational community has been that preconditioners do not have to rigorously and accurately preserve physics to be effective and the tradeoff between the physics preservation and the performance of the preconditioner cannot be known \\emph{a priori}. The assumption in this work is that the cost of recomputing the cross sections in every preconditioner application is greater than the benefit of more accurately representing the physics.\n\nTo prolong from a coarse to a fine grid, the points that line up between the grids are mapped directly: $e_{2g}^{h} = e_{g}^{2h}$. To fill in the intermediate points on the fine grid, the adjacent coarse values are averaged: $e_{2g+1}^{h} = \\frac{1}{2}(e_{g}^{2h} + e_{g+1}^{2h})$. The errors are prolonged every time there is a transfer to a finer grid. Since cross sections do not change they are never prolonged. \n\nThere are other restriction and prolongation operators that are more rigorous and would preserve more accuracy when transferring between grids than the implemented ones. For example, a full weighting restriction operator would be more rigorous in combination with the current prolongation method than the current restriction operator is \\cite{Briggs2000}. This change would be straightforward to implement. \n\nAn example of a more complex prolongation operator that would be more accurate would be to use shape functions to prolong from a coarse grid to a fine grid. The shape functions could be based on the previous iterate of the fine-grid vector, some known desirable expansion, etc. Such a change would be more difficult to implement and require more research. \n\nThese issues were not investigated in this work since the chosen operators, which were simple to code and check for correct implementation, were sufficient in practice. Any errors that may have been added by the restriction and prolongation operators were largely removed by the relaxations. In addition, because this is a preconditioner all of the pieces do not need to be rigorous. It is likely not valuable to spend time on complex grid transfer operators. However, it could be of value to investigate other simple operators. \n\nThe user chooses the number of V-cycles done on each preconditioner application, $v \\leftarrow \\ve{G}(v,b)$. Recall that one V-cycle, seen in Figure~\\ref{fig:Vcycle} (a), goes from the finest grid to the coarsest grid and back up to the finest. The input option specifies the number of the large Vs that are concatenated together. The default number of V-cycles is 2. Each additional V-cycle should remove more error, but also has a computational cost. \n\nAt this time the depth of the V-cycle is determined by the number of groups such that the grids will be coarsened until there is only one energy group. The number of grids needed is given by \\cite{BinaryTree2011}\n\\begin{equation}\n  \\text{floor}\\bigl( \\log_{2}(G-1) \\bigr) + 2 \\:.\n  \\label{eq:NumGrids}\n\\end{equation}\n%\nHow this is handled when using energy sets is discussed below. The depth of the cycle is an option that could be changed in the future if it is found that restricting down to only one group is unnecessary, particularly if there are a large number of groups. Investigating the optimal V-cycle depth is an important issue, but beyond the scope of this work. \n\nSome number of relaxations are performed on each level while traversing down and up the grids in a V-cycle. The number of relaxations per level, $\\nu_{1,2}$ from Algorithm~\\ref{algo:MG}, is a user input choice with a default of 2. Doing more relaxations per grid should remove more error, but also has a computational cost. The implemented relaxation method is weighted Richardson iteration, whose $k$th step is\n%\n\\begin{equation}\n  \\phi^{k} = \\phi^{k-1} + \\omega^{k}\\ve{P}^{-1}(b^{k-1} - \\ve{A}\\phi^{k-1}) \\:.\n  \\label{eq:Richardson}\n\\end{equation}\n%\n$\\ve{P}$ is some easily invertible matrix, the details of which determine exactly what method is being used. If $\\omega^{k}$ is constant then this is the stationary Richardson method \\cite{Moore1999}. \n\nIn this work $\\ve{P} = \\ve{I}$, $\\ve{P}^{-1} = \\ve{I}$, and $\\omega$ is a constant selected by the user that defaults to 1. When applied to the Transport equation, this looks like\n%\n\\begin{align}\n  \\phi^{k} &= \\phi^{k-1} + \\omega\\bigr(b^{k-1} - (\\ve{I} - \\ve{TMS})\\phi^{k-1}\\bigl) \\:, \\text{ or} \\nonumber \\\\\n  \\phi^{k} &= \\bigr(\\ve{I} + \\omega(\\ve{TMS} - \\ve{I})\\bigl)\\phi^{k-1} + \\omega b^{k-1} \\:.\n  \\label{eq:relax}\n \\end{align}\n  \nAn important principle is that the preconditioner is only attempting to roughly invert $\\ve{A}$, so choosing to simplify the preconditioner beyond the solution method alone, i.e.\\ using Richardson instead of Krylov, is reasonable. In this vein it is possible to use a smaller angle set in the preconditioner than the rest of the code. For example, the whole problem can be solved at $S_{10}$, but the preconditioner would only use $S_{2}$. There is an input option to specify what to use in preconditioner; the default is to use the same angle set as the rest of the problem. At this time this option has only been implemented for vacuum boundary conditions. \n\nRecall that right preconditioning is applied as $\\ve{A} \\ve{G}^{-1} \\ve{G} \\phi = b$, where $\\ve{A} = \\ve{I} - \\ve{TMS}$. To implement this in Denovo, $y$ was defined as $\\ve{G}\\phi$ and the problem was broken into two steps: \n%\n\\begin{align}\n  \\text{with a Krylov method solve} \\qquad \\ve{AG}^{-1}y &= b \\:. \\label{eq:PrecondKrylov} \\\\\n  \\text{After finding }y\\text{, the final step is} \\qquad \\phi &= \\ve{G}^{-1}y \\:. \\label{eq:PrecondPhi}\n\\end{align}\n%\nThe Krylov solvers cannot be modified easily because they are provided by an external library, so the preconditioner must be applied to the iteration vector that is handed to the solver to carry out Equation~\\eqref{eq:PrecondKrylov}. Equations~\\eqref{eq:invertG} and \\eqref{eq:ApplyA} show how this is accomplished for each application of the Krylov solver. Equation~\\eqref{eq:findPhi} shows how Equation~\\ref{eq:PrecondPhi} is solved.  \n\nLet $v^{j}$ be an iteration vector that represents $y$, and let $z^{j}$ be an intermediate iteration vector. In each step below the equations are written three ways to show what is going on algorithmically: the equation being solved, the symbolic representation of the outcome, and the way this is written in multigrid syntax. The first thing is to apply the preconditioner to the intermediate vector to affect the inversion of $\\ve{G}$. For Krylov iteration index $j = 1, ..., J$:\n%\n\\begin{align}\n  \\ve{G}z^{j} &= v^{j} \\:,  \\label{eq:invertG} \\\\\n  z^{j} &\\approx \\ve{G}^{-1}v^{j} \\:, \\nonumber \\\\\n  z^{j} &\\leftarrow \\ve{G}(z^{j}, v^{j}) \\:. \\nonumber\n\\end{align}\n%\nNext, apply the operator $\\ve{A}$ to $z^{j}$ and set it equal to $v^{j+1}$:\n\\begin{align}\n  v^{j+1} &= \\ve{A}z^{j} \\:,   \\label{eq:ApplyA} \\\\\n  v^{j+1} &\\approx \\ve{AG}^{-1}v^{j} \\:, \\nonumber \\\\\n  v^{j+1} &= \\ve{A}[z^{j} \\leftarrow \\ve{G}(z^{j}, v^{j})] \\:. \\nonumber\n\\end{align}\n%\nOnce $v$ has converged, $y = v^{J}$. The final step is to apply the preconditioner again to recover $\\phi$ from $y$:\n%\n\\begin{align}\n  \\ve{G}\\phi &= y \\:,   \\label{eq:findPhi} \\\\\n  \\phi &\\approx \\ve{G}^{-1}y \\:, \\nonumber \\\\\n  \\phi &\\leftarrow \\ve{G}(\\phi, y) \\:. \\nonumber\n\\end{align}\n\nThe operator $\\ve{A}$ is used within the preconditioner to compute the residual, $r^{h} = \\ve{A}^{h}e^{h} - b^{h}$, and the form of the operator is used in the relaxation method. The default behavior when doing RQI is to use the regular, unshifted operator in the preconditioner. There is an option to use the shifted operator instead. In that case $\\mathbf{S}$ becomes $\\tilde{\\ve{S}} = \\ve{S} + \\rho\\ve{F}$ and the right hand side becomes $(\\frac{1}{k} - \\rho)\\ve{TMF}e$. The use of the shifted operator can be turned on through an input option, changing the calculation of the residual as well as the $\\ve{S}$ used in the relaxer.\n\nAn important attribute of this preconditioner is that it is parallelizable in energy because it can use the energy sets introduced earlier in this work. There are two ways to handle energy grids and energy sets together. One way is to restrict from $G$ groups down to $1$ group just as if there were no energy sets. This requires cross-set communication as soon as there are fewer groups than sets. This also causes some logistical difficulties related to what data is held by which sets at various points in the calculation. \n\nThe other way is to prohibit cross-set communication by having each set do its own ``mini'' V-cycle. Each set restricts, prolongs, and relaxes on only its groups. This strategy requires there to be at least two groups on every set. With an unequal number of groups per set, there is a choice between forcing all sets to have the same grid depth and allowing those with more groups to have deeper Vs. The first option enforces energy load balancing between sets while the second allows the sets with more groups to remove more error. \n\nThe choice to have all sets use the same grid depth was made for this work because the benefit of load balancing is likely to be larger than having some sets use an extra grid. Thus, each set restricts to one or two group(s) giving approximately $num\\_sets$ total groups across sets at the coarsest level. The number of grids needed is determined by the set with the minimum number of groups since it will be the first to reach a grid with one group. This modifies Equation~\\eqref{eq:NumGrids} to be\n\\begin{align}\n  num\\_g_{min} &= \\text{floor}\\bigl(\\frac{num\\_groups}{num\\_sets}\\bigr) \\:, \\\\\n  num\\_grids &= \\text{floor}\\bigl( \\log_{2}(num\\_g_{min}) \\bigr) + 2 \\:.\n  \\label{eq:multisetGrids}\n\\end{align}\n\n%To choose the number of levels, Algorithm~\\ref{algo:multisetsGrids} is used. \n%%\n%\\begin{algorithm}\n%  \\caption{ Calculating the Number of Preconditioner Grids When There Are Energy Sets}\n%  \\label{algo:multisetsGrids}\n%   $num\\_groups$ = $G$, $num\\_levels$ = 1, $num\\_local\\_min$ = floor$\\bigl( \\frac{num\\_groups}{num\\_sets}\\bigr)$ \\\\\n%   while ($num\\_local\\_min$ $>$ 1)\n%  \\begin{list}{}{\\hspace{2.5em}}\n%    \\item $num\\_levels$ = $num\\_levels$ + 1\n%    \\item $num\\_groups$ = ($num\\_groups$ + 1) / 2\n%    \\item $num\\_local\\_min$ = floor$\\bigl( \\frac{num\\_groups}{num\\_sets}\\bigr)$\n%   \\end{list}\n%\\end{algorithm}\n\nThe communication costs and logistical complications of the first strategy seem likely to overwhelm the benefit gained by going to one group instead of $num\\_sets$ groups. The second strategy was chosen because it involves much less communication and overhead cost. The value of this choice will become apparent in the results section and commented upon in Chapter~\\ref{sec:Chp5}. \n\nWith the implemented energy set strategy there are tradeoffs between the number of sets and the number of grids for a fixed number of groups. When there are more sets, more cores can be used at once and wall time should decrease. When there are fewer sets each V-cycle can go deeper so the preconditioner should be more effective, which will reduce iteration count and hopefully decrease wall time. \n\n%-------------------------------------------------------------------------------------------------------\n\\section{Results}\nMany tests were done to characterize the impact of preconditioning on a full spectrum of problem types. The preconditioning parameters are the Richardson iteration weight, $w_{k}$, the number of V-cycles per preconditioner application, and the number of relaxations per level. The syntax used throughout this section will be that $w\\#$ is the weight, $r\\#$ is the number of relaxations per level, and $v\\#$ is the number of V-cycles, e.g.\\ $w1r1v1$ is one relaxation per level, one V-cycle, and a weight of 1. Using more preconditioning means using larger values of $w$ and/or $r$ and/or $v$.  \n\nThe range of problem types include fixed source, eigenvalue with power iteration, and eigenvalue with Rayleigh quotient iteration. Each of these problem types can have many groups or few groups, and the number of groups per set when doing multisets can be varied. Calculations were done to investigate as much of the problem space as possible. All tests were solved with the multigroup Krylov solver unless otherwise noted. \n\nThe goal of using the preconditioner is to improve convergence behavior of the multigroup Krylov solves. The best metric for measuring this is the total number of multigroup Krylov iterations used in a calculation because it is the most consistent and fair measure. The number of eigenvalue iterations is also compared for most eigenvalue tests. This is a point of interest rather than a measure of goal attainment. The total number of Krylov iterations is the best proxy for convergence behavior as it encompasses the work that is done within each eigenvalue iteration.  \n\nTiming comparisons, which are given for some tests, should be considered heuristically. In cases where the calculations were done on a single core, the machine was not dedicated to these calculations and times could vary if the same calculations were repeated. Some problems use the optimized version of the code and others use the debug. The two versions should give the same iteration count, but not necessarily the same relative times between problems. Further, little effort has been put into optimizing the preconditioner for speed. Once the multigrid-in-energy solver has been optimized for efficiency, the preconditioned times should decrease. How much improvement can be gained is a matter for future study. \n\n\\subsection{RQI Parameter Scoping}\nThe first two problems calculated with preconditioning were the small Rayleigh quotient iteration unit tests reported on in Chapter~\\ref{sec:Chp3}. These easy problems were done to find out three things. The first was to check that the preconditioner reduces the number of Krylov iterations used in an RQI calculation. The second was to get some guidance on the effect of the preconditioning parameters. The third was find out whether or not the shifted version of the operator should be used in the preconditioner. All tests used the debug version of Denovo on one processor with GMRES as the multigroup Krylov solver.\n\nThe small RQI unit test with vacuum boundary conditions was tested first. In all cases the correct $k$ and flux were found. The tolerance used to compare the flux to the reference case was $1 \\times 10^{-5}$. The results are shown in Table~\\ref{table:RQIUnitTestVac}. ``Krylov'' is the total number of Krylov iterations and ``RQI'' is the total number of eigenvalue iterations. Note that throughout this chapter a $w$ and/or $r$ and/or $v$ of 0 in a table or figure indicates the unpreconditioned case.\n%\n\\begin{table}[!h]\n\\caption{RQI Unit Test with Vacuum Boundaries, Preconditioning Parameter Study}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | c |}\n\\hline\nWeight & Relaxations & V-cycles & Krylov & RQI \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 39 & 6 \\\\\n1    & 1 & 1 & 27 & 6 \\\\\n1.2 & 1 & 1 & 31 & 6 \\\\\n1    & 2 & 1 & 16 & 6 \\\\\n1.2 & 2 & 1 & 19 & 6 \\\\\n1    & 1 & 2 & 16 & 6 \\\\\n1.2 & 1 & 2 & 19 & 6 \\\\\n1    & 2 & 2 & 11 & 6 \\\\\n1.2 & 2 & 2 & 11 & 6 \\\\\n\\hline\n1    & 2 & 3 & 10 & 6 \\\\\n1.2 & 2 & 3 & 10 & 6 \\\\\n1.3 & 2 & 3 & 10 & 6 \\\\\n1.4 & 2 & 3 & 10 & 6 \\\\\n\\hline\n1    & 3 & 3 & 6   & 6 \\\\\n1    & 4 & 4 & 6   & 6 \\\\\n1.3 & 4 & 4 & 6   & 6 \\\\\n1    & 5 & 5 & 6   & 6 \\\\\n1.3 & 5 & 5 & 6   & 6 \\\\\n\\hline \n\\end{tabular}\n\\end{center}\n\\label{table:RQIUnitTestVac}\n\\end{table}\n\nIn all tests the preconditioned version used fewer Krylov iterations than the base case. The number of RQ iterations was not affected by the preconditioning. To get much benefit from preconditioning this problem, larger values for the $r$ and $v$ parameters were needed. With $w1r1v1$ the Kyrlov iteration count was only reduced from 39 to 27; with $w1r3v3$ it went to 6. When only a small amount of preconditioning was used ($r$ and $v$ of 1 or 2), increasing the weight increased the number of Krylov iterations needed. When $r$ was 3 and $v$ was 3, changing the weight had no effect. When larger values were used for the preconditioning parameters, the problem did not break down. \n\nIncreasing $r$ or $v$ or both reduced the number of Krylov iterations, where there is a lower limit of 1 Krylov iteration per eigenvalue iteration. Note that reaching this limit means that one application of the preconditioner converged the eigenvector. The effect of $r$ and $v$ on iteration count were the same. That is $r1v2$ gave the same result as $r2v1$. Both of those combinations result in the same number of relaxations being done on the flux moments on each energy grid. In the first case one relaxation is done on every grid and each grid is cycled through twice. In the second case two relaxations are done on every grid and each grid is visited once. Both versions result in two relaxations per grid. \n\nWhile the iteration count is the same, using a larger $v$ and a smaller $r$ may be more time consuming than a smaller $v$ and a larger $r$. Executing relaxations through V-cycles requires more prolongation and restriction operations to transfer between grids whereas executing them through relaxations per level does not. The total number of relaxations scales with the product of $v$ and $r$; the total number of restrictions and prolongations scales with $v$.\n\n%-------------------------------------------------------------------------------------------------------\nThis test was also tried with the shifted version of the operator in the preconditioner. Unless otherwise noted the correct $k$ and flux were found. The flux checking tolerance was again $1 \\times 10^{-5}$. The results are shown in Table~\\ref{table:RQIUnitTestVacShifted}.\n%\n\\begin{table}[!h]\n\\caption{RQI Unit Test with Vacuum Boundaries and Shifted Operator, Preconditioning Parameter Study}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | c |}\n\\hline\nWeight & Relaxations & V-cycles & Krylov & RQI \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 39 & 6 \\\\\n1    & 1 & 1 & 20 & 6$^{*}$ \\\\\n1.2 & 1 & 1 & 31 & 7$^{\\dag}$ \\\\\n1    & 2 & 1 & 12 & 6 \\\\\n1.2 & 2 & 1 & 16 & 6 \\\\\n1    & 1 & 2 & 12 & 6 \\\\\n1.2 & 1 & 2 & 16 & 6 \\\\\n1    & 2 & 2 & 10 & 6 \\\\\n1.2 & 2 & 2 & 10 & 6 \\\\\n1    & 2 & 3 & 6   & 6 \\\\\n\\hline \n\\end{tabular}\\\\\n$^{*}$flux was not correct and $k$ was 0.17632 instead of 0.17528 \\\\\n $^{\\dag}$flux was not correct and $k$ was 0.17494 instead of 0.17528\n\\end{center}\n\\label{table:RQIUnitTestVacShifted}\n\\end{table}\n\nFewer Krylov iterations were needed with the shifted operator than with the unshifted operator. For example, using $w1r2v3$ yielded 6 iterations while the same parameters in the unshifted version yielded 10. However, the two $r1v1$ cases did not calculate the right eigenvalue, suggesting the shifted operator may not be as robust as the unshifted version. This study exhibited the same patterns for weight, number of relaxations per level, and number of V-cycles as the unshifted study. \n\nThe incorrect eigenvalues and fluxes were only found when preconditioning parameters were small. That wrong answers were found was unexpected because the problem was simple enough that the eigenvector and value converged without preconditioning. This behavior is likely because the shift tends to make the operator ill-conditioned, making its use inside the preconditioner prone to the same problems as when it is used outside the preconditioner. \n\n%-------------------------------------------------------------------------------------------------------\nThe next test was the small RQI unit test with reflecting boundary conditions. The flux was not tested against a very tight tolerance, either $1 \\times 10^{-2}$ or $1 \\times 10^{-3}$ unless otherwise noted. Unless the calculation failed, the correct eigenvalue-vector pair were found. The results are shown in Table~\\ref{table:RQIUnitTestRefl}. The maximum number of Krylov iterations was set to 100 for this calculation.\n%\n\\begin{table}[!h]\n\\caption{RQI Unit Test with Reflecting Boundaries, Preconditioning Parameter Study}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | c | c |}\n\\hline\nWeight & Relaxations & V-cycles & $k$ & Krylov & RQI \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 2 & 35   & 5 \\\\\n1    & 1 & 1 & 2 & 30   & 2$^{*}$ \\\\\n1.2 & 1 & 1 & 2 & 127 & 2$^{*,\\dag}$ \\\\\n1.3 & 1 & 1 & 2 & 200 & 2$^{\\dag}$ \\\\\n1.4 & 1 & 1 & 1.9977  & n/a & test failed \\\\\n\\hline\n0.7 & 2 & 2 & 2 & 13   & 2 \\\\\n0.9 & 2 & 2 & 2 & 12   & 2 \\\\\n1    & 2 & 2 & 2 & 12   & 2 \\\\\n1.2 & 2 & 2 & 2 & 29   & 2 \\\\\n\\hline\n1    & 3 & 3 & 2 & 8     & 2 \\\\\n1    & 4 & 4 & 2 & 6     & 2 \\\\\n1    & 5 & 5 & 2 & 4     & 2$^{*}$ \\\\\n1.2 & 5 & 5 & 2 & 14   & 2 \\\\\n\\hline\n1    & 4 & 1 & 2 & 12   & 2 \\\\\n1    & 1 & 4 & 2 & 12   & 2 \\\\\n1    & 4 & 2 & 2 & 8     & 2 \\\\\n1    & 2 & 4 & 2 & 8     & 2 \\\\\n1    & 4 & 3 & 2 & 6     & 2 \\\\\n1    & 3 & 4 & 2 & 6     & 2 \\\\\n\\hline \n\\end{tabular}\\\\\n$^{*}$used a tighter comparison tolerance of $1 \\times 10^{-5}$ and still passed\\\\\n$^{\\dag}$at least one eigenvector iteration did not converge\n\\end{center}\n\\label{table:RQIUnitTestRefl}\n\\end{table}\n\nThe results show that the number of RQ iterations was reduced when preconditioning was used, and the number of  Krylov iterations was reduced as long as the eigenvector converged. This problem was more sensitive to increasing the weight than the vacuum problem was and there were no cases in which increasing weight reduced iteration count. With $r1v1$, increasing the weight prevented the Krylov iterations from converging. Using a weight less than 1 with $r2v2$ was not beneficial, though it did not cause the calculation to fail. \n\nAgain, when $r$ and $v$ were increased iteration count went down noticeably. High $r$ and $v$ values reduced iteration count and did not cause breakdown. This calculation also showed that exchanging the values of $r$ and $v$ gave the same iteration count. \n\n%-------------------------------------------------------------------------------------------------------\nThe reflecting boundary test was repeated with the shifted version of the operator in the preconditioner as well. Many of these calculations did not pass the unit tests. The flux was tested against the same loose tolerance as the unshifted case unless otherwise noted. The results are show in Table~\\ref{table:RQIUnitTestReflShifted}. The maximum number of Krylov iterations was 100.\n%\n\\begin{table}[!h]\n\\caption{RQI Unit Test with Reflecting Boundaries and Shifted Operator, Preconditioning Parameter Study}\n\\begin{center}\n\\begin{tabular}{| c | c | c | l | c | c |}\n\\hline\nWeight & Relaxations & V-cycles & $k$ & Krylov & RQI \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 2 & 35 & 2 \\\\\n1    & 1 & 1 & test failed & & \\\\\n1.4 & 1 & 1 & test failed & & \\\\\n1    & 2 & 2 & test failed & & \\\\\n1.4 & 2 & 2 & test failed & & \\\\\n1    & 3 & 3 & test failed & & \\\\\n1.4 & 3 & 3 & test failed & & \\\\\n1    & 4 & 1 & test failed & & \\\\\n1    & 4 & 2 & test failed & & \\\\\n1    & 4 & 3 & test failed & & \\\\\n1    & 4 & 4 & 2 & 18 & 6 \\\\ \n1    & 3 & 4 & test failed & & \\\\\n1.2 & 3 & 4 & 2.0024 & 41 & 6 \\\\\n1.3 & 3 & 4 & 1.9997 & 1200 & 12 \\\\\n1.4 & 3 & 4 & 2.0037 & 4100 & 41 \\\\\n1    & 5 & 5 & 2 & 8 & 4$^{*}$ \\\\\n1.2 & 5 & 5 & 2& 32 & 4 \\\\\n\\hline \n\\end{tabular}\\\\\n$^{*}$used a tighter comparison tolerance of $1 \\times 10^{-5}$ and still passed\n\\end{center}\n\\label{table:RQIUnitTestReflShifted}\n\\end{table}\n\nThis problem only managed to pass and get the right answer with a lot of preconditioning, and only with a few sets of parameters. When the problem did not fail, increasing the weight made the behavior worse. Of the four cases in which all the Krylov iterations converged, one took more multigroup iterations than the unpreconditioned case. All of tests used more RQ iterations than the base case. Overall the shifted operator did not work well at all for this problem.\n\nSome preliminary conclusions were drawn from the RQI unit tests that were used to steer subsequent investigation. A major finding is that using the shifted operator with reflecting boundaries has a risk of failure and with vacuum boundaries has a risk of false convergence. With reflecting boundaries the shifted operator nearly always failed. And, while it reduced the number of iterations needed for the vacuum tests, that was only true if ``enough'' preconditioning was used to converge the problem. There is no way to determine whether sufficient preconditioning was done, however, because there is no indication when a wrong answer is reported. \n\nIt is not so surprising that the shifted operator can be troublesome in the preconditioner. Using an ill-conditioned system inside a preconditioner designed to mitigate the effects of ill-conditioning does not make much sense. Just as in the unpreconditioned RQI results, when the shift works it works very well, but most of the time it does not converge. The shifted operator was not investigated further in this work.\n\nWith the unshifted operator, the correct $k$ and flux were always found when the overall problem converged. The preconditioner reduced the number of Krylov iterations as long as the problem converged the eigenvector. In the vacuum case, preconditioning did not reduce the number of RQ iterations, but it did in the reflecting case. \n\nWith vacuum boundary conditions, increasing the weight in the relaxation method was beneficial when larger $r$ and/or $v$ were used. With small $r$ and/or $v$ higher weight was detrimental. A larger $w$ was never useful in the reflecting case. In all cases increasing $r$ and/or $v$ decreased the number of Krylov iterations. The effect of increasing $r$ and $v$ were found to be interchangeable from a Krylov iteration reduction standpoint. \n\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Fixed Source Parameter Studies}\nSome fixed source tests were done next, with the selection of preconditioning parameters informed by the RQI unit tests. The fixed source calculations are particularly useful because the preconditioner can be studied apart from eigenvalue iterations. All tests used the debug version of Denovo on one processor with GMRES as the multigroup Krylov solver.\n\nThe first test was a small vacuum boundary problem. It used 1 material, 10 groups, 5 upscattering groups, $P_{0}$, $S_{4}$, a 3 $\\times$ 3 $\\times$ 3 grid, and a tolerance and an upscatter tolerance of 1 $\\times$ 10$^{-6}$. The first 3 groups had an isotropic source. This problem was used to further study the effects of weight, relaxations per level, and V-cycles.\n\nIn one set of tests the weight was varied with the relaxations per level and number of V-cycles both set to 1. The results can be seen in the top plot in Figure~\\ref{fig:FxdSrcVac}; note that the y-axis is on a log scale. In this and all subsequent plots an $r$, $v$, or $w$ of 0 corresponds to the unpreconditioned case. It is clear that increasing the weight is initially beneficial, reducing the iteration count to 6 from the unpreconditioned 10. After a certain level, increased weight begins to increase the number of iterations. A weight of 2 seems to be a ``sweet spot'' that reduced the number of iterations again, though only to 7. However, when a weight of 2.1 was used the problem did not converge. All of the data for the weight study can be found in Appendix~\\ref{sec:AppendixD}, Table~\\ref{table:FxdSrcTstVacWeight}.\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.7\\textwidth, height=0.8\\textheight] {FxdSrcVac}\n   \\end{center}\n   \\caption{Small Fixed Source Problem with Vacuum Boundaries, Preconditioning Parameter Studies}\n   \\label{fig:FxdSrcVac}\n\\end{figure}\n\nNext the number of relaxations per grid and the number of V-cycles were varied with the weight fixed at 1. These results are shown in the bottom plot of Figure~\\ref{fig:FxdSrcVac}. Here $r$ and $v$ were changed together, so the number on the x-axis represents both parameters. That is, if the x-axis value is 3 then $r$ and $v$ were both 3. \n\nInitially, increasing $r$ and $v$ reduced the number of iterations needed for convergence. After enough preconditioning was done that only 4 iterations were needed, no additional amount of preconditioning reduced the iteration count further. The data from this plot is in Appendix~\\ref{sec:AppendixD}, Table~\\ref{table:FxdSrcTstVacRV}. \n\nA calculation using $w1.3r10v10$, the largest set of preconditioning parameters tested, also yielded 4 iterations. This both confirms that more preconditioning did not improve results, and demonstrated that a lot of preconditioning did not cause breakdown. \n\n%-------------------------------------------------------------------------------------------------------\nThe previous problem was repeated with reflecting boundary conditions, and both a weight variation and $r$/$v$  variation study were done. This time the tolerance and upscatter tolerance were 1 $\\times$ 10$^{-6}$. A plot of results for varying the weight with 1 relaxation per level and 1 V-cycle is in the top of Figure~\\ref{fig:FxdSrcRefl}. The results for varying with number of relaxations per grid and the number of V-cycles with the weight fixed at 1 can be seen in the bottom plot. A few $r$/$v$ variations were also done using a weight of 1.3, indicated by large green dots.\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.7\\textwidth, height=0.8\\textheight] {FxdSrcRefl}\n   \\end{center}\n   \\caption{Small Fixed Source Problem with Reflecting Boundaries, Preconditioning Parameter Studies}\n   \\label{fig:FxdSrcRefl}\n\\end{figure}\n\nThe behavior of this problem was similar to but slightly different from the vacuum case. Increasing the weight parameter again decreased the number of iterations initially, and increased the number with higher $w$s. This behavior is different from what was observed in the RQI unit test reflecting case where increased weight always had a negative impact. For this test there was no ``sweet spot'' as in the vacuum case, and 1,000 iterations was reached at $w1.8$ rather than $w2.1$.\n\nThe $r$ and $v$ study showed two new things compared to the vacuum case. One is that early on a higher weight of 1.3 was better than a weight of 1. The other was that the number of iterations could be decreased to 1 when a large amount of preconditioning was done. Whether and when 1 iteration can be reached for a given problem is related to how well Richardson iteration works for that problem's characteristics. \n\nThese two sets of results confirm that increasing $r$ and/or $v$ decreases Krylov iteration count. They also indicate that using a small amount of weight can be beneficial, but a large amount is not. Neither of these problems exhibited the problems with a weight over 1 at low $r$ and $v$. However, all of the tests discussed so far were very small and simple. Testing with larger and more complex problems is needed as well. \n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Fixed Source Solver and Angle Comparisons} \nAnother fixed source problem was the half iron, half graphite cube from Chapter~\\ref{sec:Chp2}. For this calculation a grid of 10 $\\times$ 10 $\\times$ 10 was used with an $S_{8}$ angle set. The tolerance and upscatter tolerance were 1 $\\times$ 10$^{-6}$. This problem has vacuum boundaries and 27 energy groups, 13 of which have upscattering. A few calculations were done with this configuration to compare one set of preconditioning parameters to a few solvers without preconditioning. The solver comparisons can be seen in Table~\\ref{table:FeC solvers} (note, the first three values in this table were shown in Chapter \\ref{sec:Chp2}). The last column in the table shows the ratio of the case of interest's time to the MG Krylov time to provide a better sense of how the times compare to one another.\n%\n\\begin{table}[!h]\n\\caption{Iron Graphite Fixed Source Cube, Solver and Preconditioning Comparison}\n\\begin{center}\n\\begin{tabular}{| l | c | l | c | c |}\n\\hline\nSolver & GS Iters & Krylov & Subspace Length & Rel Time$^{*}$\\\\[0.5ex]\n\\hline\nGS &  12 & 1,727 & 1 group & 2.41 \\\\ %$2.12 \\times 10^{2}$\nGS TTG & 11 & 1,687 & 1 group & 2.27 \\\\ %$1.99 \\times 10^{2}$\nMG Krylov & n/a & 30 & 27 groups & 1.00 \\\\ %$8.78 \\times 10^{1}$\nw1 r2 v2 & n/a & 10 & 27 groups & 8.05 \\\\ %$7.07 \\times 10^{2}$\nw1.3 r4 v4 & n/a & 4 & 27 groups & 14.68 \\\\ %$1.29 \\times 10^{3}$\n\\hline\n\\end{tabular}\\\\\n$^{*}$compared to unpreconditioned MG Krylov, 87.8 seconds\n\\end{center}\n\\label{table:FeC solvers}\n\\end{table}\n\nAll of the calculations using the block Krylov solver dramatically reduced the number of Krylov iterations for this problem, which contains highly scattering material. While the Krylov subspace sizes are made from smaller vectors when GS is used, all the problems using MG Krylov took many fewer iterations. The preconditioner also had a big impact. The highly preconditioned problem needed 4 Krylov iterations while the unpreconditioned Krylov case took 30 and unaccelerated Gauss Seidel needed 1,727.  \n\nThe timing comparison is not as favorable. With the current unoptimized state of the preconditioner, using it for fixed source problems increases rather than decreases run time. Even though many fewer Krylov iterations are taken, the overall preconditioned run times are longer than all other calculations. \n\nThis problem investigated the option of using a reduced angle set within the preconditioner. The preconditioning parameters were $w1r2v2$. The overall problem was solved with $S_{8}$, but the preconditioner used $S_{2}$. Changing the number of solution directions did not change the number of iterations. The solution time was reduced from $7.07 \\times 10^{2}$ seconds to $1.57 \\times 10^{2}$ seconds, a factor of 4.5. The relative time is 1.79. With this option the solve time was less than both GS cases and approaching the unpreconditioned MG Krylov case. Using fewer solve directions inside the preconditioner had a very positive impact; it reduced time but did not impact the number of iterations.\n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\subsection{RQI Intermediate Problem}\nThe intermediate-size infinite medium problem from Chapter~\\ref{sec:Chp3} that has 27 groups and a very small dominance ratio was solved with preconditioned RQI. This was the first system that tested if the preconditioner can converge the Krylov iterations when they did not converge without it. Recall that originally RQI got an eigenvalue close to the correct answer, but was unable to converge the eigenvector. For this test both $k$ and the flux were compared to a reference solution. Like all the problems discussed so far, this was solved without any parallelization using GMRES and the debug version of Denovo. \n\n\\begin{table}[!h]\n\\caption{Infinite Medium Eigenvalue Problem, Preconditioning Results with Rayleigh Quotient Iteration}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | l | c | c | c | c |}\n\\hline\n$w$ & $r$ & $v$ & $k$ & Krylov & RQI & Max Rel Diff & RMS Err & Rel Time$^{+}$ \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 0.3970 & 39,025              & 40$^{*}$  & n/a & n/a & 211.03 \\\\%$5.43 \\times 10^{4}$ \\\\\n1    & 1 & 1 & 0.3982 & 3,014$^{\\dag}$ & 4 & $1.67 \\times 10^{-1}$ & $3.32 \\times 10^{-2}$ & 103.56 \\\\%$2.66 \\times 10^{4}$ \\\\\n1    & 3 & 1 & 0.3983 & 50                     & 3 & 0.0 & 0.0 & 40.19 \\\\ %$1.03 \\times 10^{4}$ \\\\\n1    & 4 & 1 & 0.3983 & 44$^{\\dag}$      & 3 & 0.0 & 0.0 & 4.51 \\\\ %$1.16 \\times 10^{3}$ \\\\\n1    & 2 & 2 & 0.3983 & 44$^{\\dag}$      & 3 & 0.0 & 0.0 & 1.11 \\\\ %$2.86 \\times 10^{2}$ \\\\\n1    & 4 & 4 & 0.4001 & 16                     & 3 & $1.67 \\times 10^{-1}$ & $3.21 \\times 10^{-2}$ & 7.73 \\\\ %$1.99 \\times 10^{3}$ \\\\\n1    & 5 & 4 & 0.4001 & 14$^{\\dag}$     & 3 & $1.67 \\times 10^{-1}$ & $3.21 \\times 10^{-2}$ & 8.81 \\\\ %$2.27 \\times 10^{2}$ \\\\\n1.4 & 5 & 4 & -0.4711 & 12$^{\\dag}$    & 2 & $1.67 \\times 10^{-1}$ & $3.21 \\times 10^{-2}$ & 6.77 \\\\ %$1.74 \\times 10^{3}$ \\\\\n1    & 5 & 5 & -0.4575 & 7$^{\\dag}$      & 2 & $3.43 \\times 10^{-6}$ & $3.67 \\times 10^{-5}$ & 6.13 \\\\ %$1.58 \\times 10^{3}$ \\\\\n\\hline\n1.1 & 4 & 1 & 0.3983 & 43$^{\\dag}$      & 3 & 0.0 & 0.0 & 4.51 \\\\ %$1.16 \\times 10^{3}$ \\\\\n1.1 & 1 & 4 & 0.3983 & 43$^{\\dag}$      & 3 & 0.0 & 0.0 & 5.24 \\\\ %$1.35 \\times 10^{3}$ \\\\\n1.1 & 2 & 2 & 0.3983 & 43$^{\\dag}$      & 3 & 0.0 & 0.0 & 4.57 \\\\ %$1.18 \\times 10^{3}$ \\\\\n\\hline\n0.7 & 1 & 1 & 0.3999 & 3,001$^{\\dag}$ & 4 & 1.0 & $3.72 \\times 10^{-1}$ & 87.34 \\\\ %$2.25 \\times 10^{4}$ \\\\\n0.7 & 3 & 1 & 0.4001 & 87$^{\\dag}$      & 5 & 0.0 & 0.0 & 7.60 \\\\ %$1.95 \\times 10^{3}$ \\\\\n0.7 & 3 & 3 & 0.4001 & 47$^{\\dag}$      & 5 & 0.0 & 0.0 & 11.34 \\\\ %$2.92 \\times 10^{3}$ \\\\\n0.4 & 3 & 1 & 0.4001 & 1,052$^{\\dag}$ & 4 & $1.18 \\times 10^{-5}$ & $8.43 \\times 10^{-8}$      & 67.57 \\\\ %$1.74 \\times 10^{4}$ \\\\\n\\hline \n\\end{tabular}\\\\\n$^{+}$compared to unpreconditioned PI, $2.57 \\times 10^{2}$ seconds\\\\\n$^{*}$terminated manually\\\\\n$^{\\dag}$negative flux\n\\end{center}\n\\label{table:impi RQI}\n\\end{table}\n%\nThe preconditioned results are shown in Table~\\ref{table:impi RQI}. In the table ``Max Rel Diff'' is the maximum over all cells and all groups of the relative difference between the reference flux and the absolute value of the computed flux, $\\max[ (\\phi_{ref} - \\vert\\phi_{calc}\\vert) / \\phi_{ref}]$. ``RMS Err'' is the root mean squared (rms) relative error, $\\sqrt{ \\sum_{1}^{N}(rel\\_err)^{2} / N}$. As a reminder, the total and upscattering tolerances were $1 \\times 10^{-4}$, and the $k$ tolerance was $1 \\times 10^{-5}$. Recall that if the Krylov iteration count is in the thousands it means the eigenvector did not converge in every iteration. The ``Rel Time'' column is the ratio of the found time to the unpreconditioned PI time of $2.57 \\times 10^{-2}$ seconds.\n\nTwo pieces of information are pertinent for interpreting these results. One is that when a calculation is terminated manually, the flux information is not reported since the calculation does not go through post-processing. This means that for the unpreconditioned case it is only known that the flux did not converge, not whether the flux was positive or negative, nor how far the estimate at termination was from the reference solution. Recall that Denovo terminates if a negative eigenvalue is computed. For the two cases in which a negative eigenvalue is reported it simply means a negative $k$ was computed on iteration 2, not that the problem converged in 2 RQ iterations. \n\nThis calculation performed strangely when preconditioned, though the results were not necessarily worse than when it was not. A wide variety of preconditioning parameter combinations were tried and there were zero out of fifteen cases that exactly matched the reference eigenpair. \n\nOf the thirteen cases where the eigenvector converged in every iteration, the flux was completely correct in one and correct in magnitude but negative in seven. There were two cases, $w1r5v5$ and $w0.4r3v1$, where the absolute value of the flux did not match the reference exactly but was within the convergence tolerance. The first of these terminated before convergence because of a negative eigenvalue, and the second had one set of Krylov iterations that did not converge. In the remaining cases there was a real difference between the found and reference eigenvectors, even though the eigenvectors and values converged. \n\nAnother important issue was that the correct eigenvalue of 0.40031 was never found within $1 \\times 10^{-5}$, even when the flux matched the reference exactly. The reported eigenvalues differ from the reference by between $2.03 \\times 10^{-4}$ and $2.03 \\times 10^{-3}$, excluding the negative $k$ and unconverged Krylov cases. Because the converged-upon $k$ is farther from the reference than the $k$ tolerance, the method is converging to the wrong value. \n\nThese behaviors bring up some serious concerns. One is that the method gives no warning or indication that something has gone awry until a negative eigenvector/value is reported at the end of the calculation. Another is that in one case the flux matched the reference exactly, but $k$ did not. Finally, that the problem can converge to the wrong $k$ is disconcerting. Note that none of these behaviors were observed in any other test cases.  \n\nTo investigate whether some of the strange behavior was coming from GMRES, this problem was also attempted with BiCGSTAB. The preconditioning was set to $r2v2$, and the weight was increased in 0.1 increments from 1.0 to 1.5. In the cases where the calculation terminated itself; $w1.0$, $w1.4$, $w1.5$; it was because a negative eigenvalue was found. Those eigenpairs were incorrect. \n\nIn the other cases; $w1.1$, $w1.2$, $w1.3$; the problems were terminated manually. At termination, the eigenvalue was oscillating between a number close to the correct answer and a large number like 11. The flux was not printed for the manually terminated cases, so it is unknown whether the flux was correct or not. Not only did BiCGSTAB not improve the results, it performed worse than GMRES.\n\nThis intermediate problem was also solved with power iteration using no preconditioning and using a lot of preconditioning. Without preconditioning the problem took 180 Krylov iterations and $2.57 \\times 10^{2}$ seconds. With $w1r5v5$ preconditioning it took 12 Krylov iterations and $2.19 \\times 10^{3}$ seconds. Both calculations obtained an eigenvalue and flux within the reference solutions. Preconditioning substantially reduced the number of Krylov iterations needed. Further, power iteration got the right answer when RQI did not. \n\nAt this time it is unknown why preconditioned RQI had such a hard time with this calculation. Preconditioned RQI did have more trouble with the small reflecting problem than the vacuum problem, and this test had all reflecting boundaries. Perhaps the characteristics of $\\ve{A}$ for this problem are quite difficult for RQI. Whatever the reason, RQI did not perform well on this problem regardless of whether it was preconditioned.  \n\nSome parameter information can still be gleaned from this study. The eigenvector did not converge after the first iteration when $r1v1$ was used with either $w1$ or $w0.7$. With more preconditioning the problem converged and the number of both RQI and Krylov iterations was reduced. This is similar to what has been seen before. However, when a lot of preconditioning was used, the problem calculated a negative eigenvalue. This is a behavior that was not observed in the simpler problems. \n\nThese numbers further confirm that it is the total number of relaxations done, not the specific combination of $r$ and $v$, that determine the reduction in iteration count. That is, iteration count with $r4v1$ is the same as with $r2v2$ and $r1v4$; though there is a difference in timing. The way the $r4v1$ and $r2v2$ times differ from one another is not the same between $w1$ and $w1.1$. This suggests these timing numbers may not be reliable, which was expected because these calculations were not done on a machine dedicated to their computation.\n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\subsection{2-D C5G7 Benchmark Study}\nNext, the preconditioner was applied to the 2-D C5G7 benchmark using both PI and RQI with the goals of seeing if preconditioned RQI could converge the flux and $k$, to investigate the effect of preconditioning in both RQI and PI, and to see whether the lessons learned about preconditioning parameters still hold in a real problem. The calculation used 16 cores on the small orthanc cluster at Oak Ridge: 4 $x$-blocks, 4 $y$-blocks, 1 $z$-block and 1 energy set. The total and upscattering tolerances were $1 \\times 10^{-3}$, with a $k$ tolerance of $1 \\times 10^{-5}$. An optimized version of Denovo was used.  \n\nA weight variation study was done with power iteration first. The results using $r1v1$ are plotted as Krylov Iterations vs.\\ Weight, and Time in seconds vs.\\ Weight in Figure~\\ref{fig:2-Dc5g7PI}. The data that is plotted can be found in Appendix~\\ref{sec:AppendixD}, Table~\\ref{table:2-D c5g7}. All calculated $k$s were within the uncertainty of the benchmark and so are not reported. All preconditioned cases needed 31 power iterations while the unpreconditioned case took 32.\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.7\\textwidth, height=0.7\\textheight] {2Dc5g7PI}\n   \\end{center}\n   \\caption{2-D C5G7 Benchmark, Preconditioner Weight Variation with Power Iteration}\n   \\label{fig:2-Dc5g7PI}\n\\end{figure}\n\nThis study shows the preconditioner is very effective at reducing the number of Krylov iterations used by power iteration. The unpreconditioned case, corresponding to a weight of 0 on the plot, took 3,129 MG Krylov iterations. As the weight was increased from 1 to 1.4, the number of Krylov iterations and the time to solution both decreased. With $w1.4$, 1,458 MG Krylovs were taken. The time and iteration count both went back up with a weight of 1.5. When the weight was increased beyond 1.5 none of the multigroup iterations converged, and the problem was terminated manually after several power iterations. \n\nTwo other calculations with a higher level of preconditioning were also done. When the parameters were $w1.4r2v2$ the number of Krylov iterations were reduced to 438 and the calculation took $1.77 \\times 10^{4}$ seconds, both lower than all the cases using $r1v1$. For $w1r3v3$, 253 Krylov iterations and $2.28 \\times 10^{4}$ seconds were required. This had the smallest number of Krylov iterations, but a slightly longer time than all the calculations except $w1.5r1v1$.\t\n\nThe results from the RQI study are in Table~\\ref{table:2-D c5g7 rqi}. In all cases, except the unpreconditioned one, $k$ was within the uncertainty of the benchmark value. The ``$<$ 1,000?'' column indicates whether or not the multigroup iterations converged during the RQI process. If the value is ``no'' that means the eigenvector only converged during the first iteration. A number indicates the last eigenvalue iteration for which the Krylov method took less than 1,000 iterations. All subsequent iterations required the full 1,000. A ``yes'' means all of the Krylov iterations converged. The relative time is the ratio of the case of interest to the unpreconditioned PI time of $8.54 \\times 10^{3}$ seconds.\n%\n\\begin{table}[!h]\n\\caption{2-D C5G7 Benchmark, Convergence Study with Rayleigh Quotient Iteration}\n\\begin{center}\n\\begin{tabular}{| c | c | c | l | c | c | c |}\n\\hline\nWeight & Relaxations & V-cycles & Krylov & RQI & $<$ 1,000? & Rel Time$^{\\dag}$\\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 119,006 & 120$^{*}$ & no & 10.98 \\\\%$9.38 \\times 10^{4}$ \\\\\n1    & 1 & 1 & 16,007   & 17            & no & 23.65 \\\\ %$2.02 \\times 10^{5}$ \\\\\n1.2 & 1 & 1 & 40,008   & 41$^{*}$   & no & 13.00 \\\\ %$2.06 \\times 10^{5}$ \\\\\n1    & 3 & 1 & n/a         & n/a$^{*}$  & 7   & n/a \\\\\n1    & 2 & 2 & 11,158   & 19            & alternated & 46.72 \\\\ %$3.99 \\times 10^{5}$ \\\\\n1    & 3 & 2 & 3,320     & 19            & 14 &19.23 \\\\ % $1.64 \\times 10^{5}$ \\\\\n\\hline\n1    & 3 & 3 & 299        & 19            & yes & 3.01 \\\\ %$2.57 \\times 10^{4}$ \\\\\n1.1 & 3 & 3 & 281        & 19            & yes & 2.80 \\\\ %$2.40 \\times 10^{4}$ \\\\\n1.3 & 3 & 3 & 254        & 19            & yes & 2.57 \\\\ %$2.19 \\times 10^{4}$ \\\\\n1.5 & 3 & 3 & n/a         & n/a$^{*}$ & no & n/a \\\\\n\\hline \n\\end{tabular} \\\\\n$^{\\dag}$compared to unpreconditioned PI, $8.54 \\times 10^{3}$ seconds\\\\\n$^{*}$terminated manually\n\\end{center}\n\\label{table:2-D c5g7 rqi}\n\\end{table}\n%\n\nThese results show a few important things. Most significantly, with enough preconditioning the multigroup iterations within RQI can be converged and the right eigenpair can be found. For the first three $w\\#r3v3$ cases all of the Krylov iterations converged. In these cases the calculation time decreased by an order of magnitude compared to the ones where they did not converge every time because so many fewer eigenvalue iterations were needed. This test case was the first to demonstrate that the preconditioner can get RQI to converge. \n\nFor many of the calculations the eigenvector did not converge or did not converge all the time, but the correct eigenvalue was still found (even in the $w1.2r1v1$ case that was terminated manually). As the preconditioning increased, the eigenvector came closer to converging for all iterations. When the Krylov iterations converged, increasing the weight decreased iteration count and wall time for small weights. As in other tests, too much weight caused the calculation not to converge at all. \n\nAdditionally, it seems that preconditioning held RQI on track enough to get the right eigenvalue when the eigenvector did not quite converge. As was hypothesized for the unpreconditioned infinite medium test, it may be that the eigenvector was close enough to correct that a good approximation to the eigenvalue could still be made from it, even though the vector itself did not converge. \n\nOnly the $w1r3v3$ calculation overlaped between RQI and PI. PI took fewer Krylov iterations, 253 compared to 299, and less time, $2.28 \\times 10^{4}$ compared to $2.57 \\times 10^{4}$ seconds. For this test preconditioned RQI did not perform as well as preconditioned PI, though the times and iteration counts were close to one another. \n\nFrom the standpoint of comparing eigenvalue solution methods, it is worth noting that RQI required 19 eigenvalue iterations while PI required 31. Both methods use eigenvectors from the inside multigroup solves to compute eigenvalues in the outer iterations. When given eigenvectors that have been converged to the same tolerance, RQI needed fewer eigenvalue iterations than PI. In this case it took more Krylov iterations within each multigroup solve to get the eigenvector to that tolerance, so RQI was not better in terms of total Krylov count.\n\nThe RQI problem was also tried with BiCGSTAB as the Krylov solver for an unpreconditioned case and a $w1r3v3$ case. Every multigroup iteration went to the 1,000 iteration limit and the problem was terminated manually after several RQ iterations.\n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n \\subsection{3-D C5G7 Benchmark Study}\nThe preconditioner using both PI and RQI was also applied to the 3-D C5G7 benchmark with an optimized version of Denovo. The goals of this study were essentially the same as the 2-D study, except that this problem is larger, and the first to approach a real ``grand challenge'' type of calculation. The medium-sized oic cluster at Oak Ridge was used and each problem was given 720 cores with 40 $x$-blocks, 18 $y$-blocks, and 5 $z$-blocks. The total and upscattering tolerances were $1 \\times 10^{-4}$, with a $k$ tolerance of $1 \\times 10^{-5}$ unless otherwise indicated. The wall time limit was 12 hours. \n\nThe power iteration results are in Table~\\ref{table:3-D c5g7}. The relative time is compared to unpreconditioned PI, $4.46 \\times 10^{3}$ seconds. The unpreconditioned power iteration calculation computed a $k$ that was not within the uncertainty bounds of the reported benchmark; it was low by about 0.011. All preconditioned PI and RQI tests computed a $k$ that was within the Denovo $k$ tolerance of the unpreconditioned PI result so they are not reported here. Subsequent to these calculations it was determined that using a more accurate quadrature gives the correct $k$. \n%\n\\begin{table}[!h]\n\\caption{3-D C5G7 Benchmark, Preconditioning Parameter Scoping with Power Iteration}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | l | c |}\n\\hline\nWeight & Relaxations & V-cycles & Krylov & PI & Rel Time$^{\\dag}$ \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & 1,224 & 32 & 1.00 \\\\ %$4.46 \\times 10^{3}$ \\\\\n1    & 1 & 1 & 708    & 32 & 5.90 \\\\ %$2.12 \\times 10^{4}$ \\\\\n1.2 & 1 & 2 & 448    & 32 & 5.33 \\\\ %$2.38 \\times 10^{4}$ \\\\\n1.2 & 2 & 1 & 448    & 32 & 5.37 \\\\ %$2.39 \\times 10^{4}$ \\\\\n1.3 & 2 & 2 & 288    & 32 & 6.37 \\\\ %$2.84 \\times 10^{4}$ \\\\\n1    & 3 & 3 & 126    & 14$^{*}$  & 9.05 \\\\ %$4.04 \\times 10^{4}$ \\\\\n1.5 & 3 & 3 & 192    & 32 & 8.36 \\\\ %$3.73 \\times 10^{4}$ \\\\\n1    & 4 & 4 & n/a     & n/a          & exceeded wall time \\\\\n1    & 4 & 4 & n/a     & n/a$^{*}$ & exceeded wall time \\\\\n1.5 & 5 & 5 & n/a     & n/a          & exceeded wall time \\\\\n\\hline \n\\end{tabular}\\\\\n$^{\\dag}$compared to unpreconditioned PI, $4.46 \\times 10^{3}$ seconds\\\\\n$^{*}$tol and upscatter tol = $1 \\times 10^{-5}$, $k$ tol = $1 \\times 10^{-3}$\n\\end{center}\n\\label{table:3-D c5g7}\n\\end{table}\n\nThe 3-D benchmark study shows the preconditioner with PI can reduce the number of required Krylov iterations substantially for challenging problems. The number of eigenvalue iterations for a given tolerance set were never changed by preconditioning. \n\nThe effect of preconditioning parameters was consistent with what was observed in other test problems. However, using large values for $r$ and $v$ made the calculation take too long to get results. On the oic machine, if a calculation exceeds wall time there is no way to get any of the results from the scratch space. Therefore, no conclusions can be drawn from this problem about the effect of substantial preconditioning when using power iteration for a real, 3-D problem. \n\nThe RQI results are in Table~\\ref{table:3-D c5g7 rqi}. The relative time is compared to unpreconditioned PI, $4.46 \\times 10^{3}$ seconds. Many cases did not finish in time to report results. What is likely happening when the problems with lower parameter values run out of time is that the eigenvector is not converging. As was seen before, the calculations take a long time when every eigenvalue iteration uses 1,000 Krylov iterations. Unfortunately, there is no way to confirm this theory or find out if the eigenvalue is close to correct since the output cannot be obtained. \n%\n\\begin{table}[!h]\n\\caption{3-D C5G7 Benchmark, Preconditioning Parameter Scoping with Rayleigh Quotient Iteration}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | l | c |}\n\\hline\nWeight & Relaxations & V-cycles & Krylov & RQI & Rel Time$^{+}$ \\\\[0.5ex]\n\\hline\n0    & 0 & 0 & n/a     & n/a          & exceeded wall time \\\\\n1    & 1 & 1 & n/a     & n/a          & exceeded wall time \\\\\n1.5 & 1 & 1 & n/a     & n/a          & exceeded wall time \\\\\n1.2 & 2 & 1 & n/a     & n/a          & exceeded wall time \\\\\n1.3 & 2 & 2 & 302    & 19           & 5.20 \\\\ %$2.32 \\times 10^{4}$ \\\\\n1    & 3 & 3 & 103    & 9$^{*}$    & 6.67 \\\\ %$3.02 \\times 10^{4}$ \\\\\n1    & 3 & 3 & 164    & 15$^{\\dag}$ & 7.59 \\\\ %$3.38 \\times 10^{4}$ \\\\\n1.5 & 3 & 3 & 187    & 19           & 7.26 \\\\ %$3.24 \\times 10^{4}$ \\\\\n1    & 4 & 4 & n/a     & n/a          & exceeded wall time \\\\\n1    & 4 & 4 & 74     & 9$^{*}$    & 5.13 \\\\ %$2.29 \\times 10^{4}$ \\\\\n1.5 & 5 & 5 & n/a     & n/a          & exceeded wall time \\\\\n\\hline \n\\end{tabular}\\\\\n$^{+}$compared to unpreconditioned PI, $4.46 \\times 10^{3}$ seconds\\\\\n$^{*}$tol and upscatter tol = $1 \\times 10^{-5}$, $k$ tol = $1 \\times 10^{-3}$\\\\\n$^{\\dag}$tol and upscatter tol = $1 \\times 10^{-4}$, $k$ tol = $5 \\times 10^{-5}$\n\\end{center}\n\\label{table:3-D c5g7 rqi}\n\\end{table}  \n\nWith an intermediate amount of preconditioning, RQI converged and performed better than the analogous PI cases. There are three cases where both problems finish and the same tolerances were used: $w1.3r2v2$, $w1r3v3$, $w1.5r3v3$. These results are shown together in Table~\\ref{table:PI RQI} for ease of comparison. This table displays time instead of relative time since the comparison is between two cases rather than across all cases. In all three the RQI calculations took less time and fewer eigenvalue iterations than PI. In the second two they also took fewer Krylov iterations. RQI even finished in time to get results from the $w1r4v4$ calculation when PI did not. \n%\n\\begin{table}[!h]\n\\caption{3-D C5G7 Benchmark, Rayleigh Quotient Iteration and Power Iteration Comparison}\n\\begin{center}\n\\begin{tabular}{| c | c | c | c | c | c | c |}\n\\hline\nSovler & Weight & Relaxations & V-cycles & Krylov & Eigenvalue & Time (s) \\\\[0.5ex]\n\\hline\nRQI & 1.3 & 2 & 2 & 302    & 19           & $2.32 \\times 10^{4}$ \\\\\nPI    & 1.3 & 2 & 2 & 288    & 32           & $2.84 \\times 10^{4}$ \\\\\nRQI & 1    & 3 & 3 & 103    & 9$^{*}$   & $3.02 \\times 10^{4}$ \\\\\nPI    & 1    & 3 & 3 & 126    & 14$^{*}$ & $4.04 \\times 10^{4}$ \\\\\nRQI & 1.5 & 3 & 3 & 187    & 19           & $3.24 \\times 10^{4}$ \\\\\nPI    & 1.5 & 3 & 3 & 192    & 32           & $3.73 \\times 10^{4}$ \\\\\n\\hline \n\\end{tabular}\\\\\n$^{*}$tol and upscatter tol = $1 \\times 10^{-5}$, $k$ tol = $1 \\times 10^{-3}$\n\\end{center}\n\\label{table:PI RQI}\n\\end{table}  \n\nThe 3-D benchmark problem shows that for at least some problems, preconditioned RQI converges more quickly in all senses than preconditioned PI. It is pertinent that this is true is the most interesting problem shown so far. It seems, however, that RQI can only be useful if it is preconditioned enough to get the eigenvector to converge. \n\nThese results continue to confirm that a small amount of weight works well for real problems. Increasing $r$ and $v$ decrease iteration count, but at what can be a high time penalty. An intermediate amount of preconditioning will likely provide the best balance of reduced iteration count for the time invested once the preconditioner is optimized. \n\n%-------------------------------------------------------------------------------------------------------\n%-------------------------------------------------------------------------------------------------------\n\\subsection{Multisets}\nAnother important area of investigation was how the preconditioner faired when using multisets. To investigate the effect of multigrid in energy with multisets on the Krylov iterations without worrying about impacts of an eigenvalue calculation, the iron graphite fixed source problem was considered first. These data were calculated on orthanc using an optimized version of the code. All previous parameter studies were used to pick preconditioning values that were likely to work well. \n\nFor this study the spatial grid was increased to $50 \\times 50 \\times 50$ and $S_{4}$ was used instead of $S_{8}$. The unpreconditioned version was compared to one with $w1r2v2$ on 1 to 10 sets. Note that with 27 groups, 10 sets was the maximum possible to still be able to use the preconditioner. In addition, 2 $x$-blocks, 2 $y$-blocks, and 1 $z$-block were used. The calculations were therefore done on between 4 and 40 cores. The preconditioned calculation took 27 GMRES iterations while the unpreconditioned took 123 regardless of the number of sets used.\n\nBecause the number of iterations did not change with sets, the only thing to compare is time. The focus is on relative change in time rather than absolute time since there is still room for the preconditioner to be optimized. All times in this section include the improved multiset communication strategy that was described at the end of Chapter~\\ref{sec:Chp2}. \n\nThree plots are shown in Figure~\\ref{fig:FeC multisets}. From the top, the first shows the wall time for the preconditioned and unpreconditioned (``regular'') calculations as a function of number of energy sets. The second plots the efficiency of the regular and preconditioned tests, where the base case is 1 set. The last plot is of the relative difference between the two times. The data that are plotted can be found in Appendix~\\ref{sec:AppendixD}, Table~\\ref{table:FeC multisets}.\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.67\\textwidth, height=0.85\\textheight] {FeCmultisets}\n   \\end{center}\n   \\caption{Iron Graphite Fixed Source Problem, Preconditioned Multiset Study}\n   \\label{fig:FeC multisets}\n\\end{figure}\n\nThe 1 set wall time without preconditioning was $8.00 \\times 10^{2}$ seconds and the 10 set time was $1.37 \\times 10^{2}$ seconds. Another way to say this is that the 1 set time took about 6 times longer to run than the 10 set time. If the problem scaled linearly in energy, it would have taken 10 times longer. The unpreconditioned efficiency degraded slowly with increasing energy sets, and the efficiency with 10 sets was less than 60\\%.\n\nWith preconditioning the 1 set time was $3.64 \\times 10^{3}$ and the 10 set time was $3.63 \\times 10^{2}$. Going from 1 to 10 sets in this case was linear. The efficiency changed a bit with the number of energy sets, but ranged between about 90\\% and 110\\%. Thus for some sets the preconditioned case gave better than linear speedup. While the exact efficiencies may not be accurate because of timing variability, the general trends are clear. \n\nWhat the difference between the efficiencies in the preconditioned and regular tests means is that the preconditioned tests were accelerated more by using multisets than the unpreconditioned tests. As a result the preconditioned times approached the regular times as more sets were used. This can be seen in the bottom plot of relative difference between the times. \n\nBefore more results with similar trends are shown, some reasons for the preconditioner's super-linear scaling in energy should be discussed. As the number of sets increases, each application of the preconditioner becomes less costly. The total preconditioning cost goes down because the V-cycle becomes shallower. That is, each application of the preconditioner is doing fewer total relaxations and is therefore less time intensive. This effect becomes more pronounced with larger $r$ and $v$. If the total number of Krylov iterations remains constant with sets, then there is no tradeoff and the preconditioner simply costs less with increased energy parallelization.\n\nAnother reason for the behavior is that this problem has a group structure that is not always balanced between sets. The multigrid preconditioner mitigates the penalty of energy set load imbalance. Recall that each set uses the same number of grids even if the groups per set are different. This means the work in the preconditioner is energy-load-balanced in all cases. Thus the relative amount of time spent waiting because of load imbalance decreases when the preconditioner is used. \n\nThis test was also run with increased preconditioning parameters for 1 set and 10 sets to see if that made a difference. The angle set was changed back to $S_{8}$ and there was no decomposition in space. With $w1.3r4v4$ the number of Krylov iterations decreased to 11. With 1 set this took $6.49 \\times 10^{4}$ seconds to complete. With 10 sets this was reduced to $5.02 \\times 10^{3}$ seconds. A 10 fold increase in computing power gave nearly a 13 fold decrease in run time, or an efficiency of 129\\%. \n\nWithout preconditioning the 1 set wall time was $8.81 \\times 10^{3}$ seconds and the 10 set time was $1.04 \\times 10^{3}$ seconds. The ratio of 1 set to 10 set time was about 8.5, or 85\\% efficient. This problem configuration scaled better than the previous configuration overall. The comparison between the preconditioned and unpreconditioned cases is similar. \n\n%-------------------------------------------------------------------------------------------------------\nThe infinite medium, 27 group problem was also used to study how the preconditioner faired with energy set decomposition. Because this problem has reflecting boundary conditions it could only be used with power iteration (recall, multisets are not implemented for RQI with reflecting boundaries at this time). These calculations were also done on orthanc, using between 1 and 10 sets and an optimized version of the code. No other problem settings were changed from what was presented above. \n\nThree plots comparing unpreconditioned PI and PI with $w1r2v2$ are shown in Figure~\\ref{fig:impi multisets}. Each plot is of the same parameters as the corresponding plots in the iron graphite cube figure. A table of the data can be found in Appendix~\\ref{sec:AppendixD}, Table~\\ref{table:impi multisets}.\n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.67\\textwidth, height=0.85\\textheight] {impimultisets}\n   \\end{center}\n   \\caption{Infinite Medium Eigenvalue Problem, Preconditioned Multiset Study with Power Iteration}\n   \\label{fig:impi multisets}\n\\end{figure}\n\nThe infinite medium test with power iteration exhibited behavior similar to the fixed source test, though this problem scaled better in energy in general. With preconditioning the Krylov iterations were reduced from 180 (90 Krylov per PI with 2 PI) to 46 (23 Krylov per PI with 2 PI). Neither the number of Krylov nor eigenvalue iterations were changed by using more sets.  \n\n%The preconditioned 1 set time was faster than the 10 set time by a factor of 12.9, while it was only 7.8 for the regular version. The preconditioned time was always at least linear, with the efficiency ranging from 1 to 1.55 and an average efficiency of 1.24. The regular efficiency was between 60\\% and 99\\%, with an average of 90\\%. The relative difference between the preconditioned and regular times decreased from 1.51 with 1 set to 0.52 with 10 sets. These results show that the preconditioned results benefited more from multisets than the regular results, and the times approached one another as set count increased. \nThis test was run with increased preconditioning parameters for 1 set and 10 sets as well. The number of Krylov iterations decreased to 8 per eigenvalue iteration, with 2 eigenvalue iterations when $w1r4v4$ was used. With 1 set this took $4.02 \\times 10^{2}$ seconds to complete. With 10 sets this was reduced to $2.94 \\times 10^{1}$ seconds. This preconditioning parameter set also performed very well, yielding a speedup of 13.7 for a 10 fold increase in computing power.  \n \nA few key conclusions can be drawn from the multiset studies about the tradeoff between the number of groups per set and about the overall usefulness of the multigrid-in-energy method with multisets. An important observation is that the number of GMRES iterations did not change with the number of sets. This means convergence improvement from the preconditioner does not come from the depth of V-cycle. Only restricting down 1 or 2 grids had as much of an impact as restricting down something like 6. This indicates it is not necessary to coarsen down to one group. \n\nFrom an error mode reduction standpoint, this conclusion suggests what a Fourier expansion of the error in energy might look like. Because a few coarser grid had a large impact but many coarser grids did not, the bulk of the error might be intermediately oscillatory in energy. If the smooth error were dominant, then the coarsest grids would likely be necessary. Only solving on a fine grid, however, was not good enough, so the error is not only oscillatory either. This leaves the modes that are between the two extremes as the likely culprit for slow convergence. \n\nThe super-linear energy scaling of the preconditioner warrants more discussion. Relaxing on the coarsest energy grids did not provide convergence benefit, meaning much work that was not beneficial was done when only a few sets were used. When many sets were used all of this work was eliminated without any negative consequences. Thus, the energy scaling was very good.\n\nOnce the preconditioner is optimized, the scaling in energy may not be as good since the preconditioner will take a smaller total fraction of the runtime. The scaling will also be less impressive if the preconditioner is modified to use only two or three grids all the time instead of always restricting down to one energy group. This would eliminate the un-beneficial work in all cases. \n\nOverall, the multigrid-in-energy method performed very well with multisets. After the modifications mentioned in the last paragraph are made, the preconditioner will likely no longer cause the entire calculation to scale so well in energy. However, the preconditioner does not communicate between sets and it does load-balance in energy. It therefore seem likely that the preconditioner can at worst leave the energy scaling behavior unchanged. \n\n\\subsection{PWR Study}\nFinally, the full-facility PWR problem was calculated on the Jaguar machine as the illustrative example of using all the new methods in combination. This test used the multigroup Krylov solver, the Rayleigh quotient iteration eigenvalue solver, and the parallelized multigrid-in-energy preconditioner. It is also exactly the kind of large and challenging problem this work is designed to solve. The PWR900 was solved with PI + MG Krylov + the multigrid-in-energy preconditioner as well. \n\nThe 44-group, 1.7 trillion unknown version of the problem was used for this strong scaling study. The tolerance and $k$ tolerance were $1 \\times 10^{-3}$, and the upscattering tolerance was $1 \\times 10^{-4}$. The preconditioner settings were $w1r3v3$. 1, 4, 11, and 22 sets were used giving 44, 11, 4, and 2 groups per set and 8, 6, 4, and 2 energy grids, respectively. There were 578 $\\times$ 578 $\\times$ 700 mesh elements. With 22 sets, 96 $x$-blocks, 94 $y$-blocks, and 10 $z$-blocks were used. All other cases had 102 $x$-blocks, 100 $y$-blocks, and 10 $z$-blocks. The results using both eigenvalue solvers are in Table~\\ref{table:full PWR}. \n%\n\\begin{table}[!h]\n\\caption{PWR900, Preconditioned Strong Scaling Study}\n\\begin{center}\n\\begin{tabular}{| l | c | c | c | l | c | c | l |}\n\\hline\nSolver & Sets & Cores & $k$ & Krylov & Eigenvalue & Total (m) & Solver (m)\\\\[0.5ex]\n\\hline\nRQI & 1   & 10,200   & 0.182 & 12    & 2$^{\\dag}$ & 720.05    & n/a \\\\\n%PI    & 1   & 10,200   &  &  &       &  &  \\\\\nRQI & 4   & 40,800   & 1.269 & 76   &  6               & 802.60   & 801.32 \\\\\nRQI w/ $S_{2}$ & 4   & 40,800   & 1.269 & 79   &  6               & 192.48   & 191.42 \\\\\nPI    & 4   & 40,800   & 1.270 & 101 & 10$^{\\dag}$ & 1440.12 & n/a \\\\\nRQI & 11 & 112,200 & 1.269 & 76   & 6                & 331.43    & 330.38 \\\\\nPI    & 11 & 112,200 & 1.270 & 111 & 11$^{\\dag}$ & 480.63    & n/a \\\\\nRQI & 22 & 198,528 & 1.269 & 76   & 6                & 143.62    & 142.56 \\\\\nPI    & 22 & 198,528 & 1.271 & 161 & 16$^{*}$      & 285.92    & n/a \\\\\n\\hline \n\\end{tabular}\\\\\n$^{\\dag}$exceeded wall time limit \\\\ \n$^{*}$machine taken down for maintenance during calculation\n\\end{center}\n\\label{table:full PWR}\n\\end{table}  \n\nBased on the full PWR calculations done previously by Evans and Davidson, $k$ is approximately 1.27, though there were no results where the dominance ratio was reported. The previous calculations that used PI with the multigroup Krylov solver and multisets had looser tolerances than these tests, so $k$ is not known more accurately and timing comparisons are not valid. All of the calculations, even those that did not finish excluding the 1 set RQI case, found the correct $k$ compared to the accuracy with which it is known. \n\nOnly RQI was used for the 1 set test. Jaguar limits problems using fewer than 20,000 cores to a 12 hour wall limit. Because the 4 set case took more than 12 hours it was not expected that the 1 set cases would finish. The test was still conducted to see whether the behavior of progress made toward solution differed from the multiset cases. That is, at eigenvalue iteration $x$ with 1 set were the $k$ and associated errors the same or different from those at iteration $x$ with a different number of sets. The purpose of this comparison was to see if the number of grid levels used in the preconditioner affected the iteration behavior. \n\nThe 1 set RQI case had the same $k$ estimate and had done the same number of GMRES iterations as the 4, 11, and 22 set cases at iteration 2. Thus eight energy grid levels gave the same improvement as two energy grid levels at the outset of the calculation. Since the 1 set calculation did not finish it cannot be known if this trend would have held, though it seems likely. This behavior is consistent with what was found in the other two multiset studies, but of higher import since this was for a real problem.\n\nRQI converged for 22, 11, and 4 sets. Changing the number of sets did not change the number of eigenvalue or eigenvector iterations for these cases. Neither an unpreconditioned calculation, nor one with different preconditioning parameters were tried. Nevertheless, these three tests show that the preconditioner can ensure that RQI converges both the eigenvalue and the multigroup iterations for a large, real problem. \n\nThe ``RQI w/ $S_{2}$'' calculation used the reduced angle set option in the preconditioner. The overall calculation used $S_{12}$. Reducing that to $S_{2}$ within the preconditioner had a large impact, reducing the solver time from 13.36 to 3.19 hours, or 76\\%. \n\nThere were no cases where PI completed the calculation. Partway through the 22 set calculation a portion of the Jaguar machine was taken offline for maintenance leaving only 162,240 cores, so the calculation was terminated. The calculation cannot be completed because the machine will not be restored to the full 224,256 cores before this work must be submitted. \n\nThe 11 and 4 set PI problems did not finish before the wall time limit was reached because the limit was not set high enough. Limits of 8 and 24 hours were chosen based on the RQI finish times of 5.5 and 13.4 hours, respectively. In previous problems the solve time for PI was close to or less than RQI, so the selected limits seemed reasonable. The 1 set case was not performed. It was determined that the additional information it might provide would not change any conclusions that can be made based on all of the other results. \n\nA true comparison between PI and RQI is difficult because PI never finished the calculations. However, all results clearly show that RQI was much faster and required far fewer Krylov and eigenvalue iterations than PI for this problem. This test shows that RQI can be the better eigenvalue solver choice for at least some problems. It is promising that the calculation for which RQI is decisively faster than PI is the one for which this work was designed. \n\nRQI scaled very well with energy sets. To help visualize the improvement, a plot of solve time vs.\\ the number of cores used is shown in of Figure~\\ref{fig:PWRprecondRQI}. The 1 set case is excluded because it was restricted to the 12 hour time limit. The plot shows the times that were measured as well as the linear time. Recall that $\\text{t\\_linear} = (\\frac{\\text{base\\_domains}}{\\text{used\\_domains}}) \\times \\text{base\\_time}$. The 4 set information was used for the base case. \n%\n\\begin{figure}[!ht]\n    \\begin{center}\n      \\includegraphics [width=0.8\\textwidth, height=0.5\\textheight] {PWRPrecondRQI}\n   \\end{center}\n   \\caption{PWR900, Strong Scaling with Preconditioned Rayleigh Quotient Iteration}\n   \\label{fig:PWRprecondRQI}\n\\end{figure}\n\nThe solver time decreased rapidly with increasing cores, and the 198,528-core test performed better than linearly. %The 11 set time was 88\\% efficient, and 22 sets had an efficiency of 115\\%. \nThe high efficiency and the increase in efficiency with sets was expected based on the previous two multiset studies. That the scaling is so good is likely attributable to the multigrid preconditioner. However, this demonstrates that RQI can use multisets without causing the scaling to degrade is some significant way. \n\nWhile rigorous timing comparisons cannot be made between preconditioned RQI and unpreconditioned PI, some general remarks can be made. The unpreconditioned PI test of the PWR with 11 sets on 112,200 cores had a solve time of 36.3 minutes. The preconditioned RQI time was 330.38 minutes, or about an order of magnitude longer. This is not a favorable comparison, but it is expected the comparison would improve if 1) the two tests used the same tolerances, 2) the preconditioned case used a reduced preconditioner angle set, 3) the number of energy grid levels were reduced, and 4) the preconditioner were optimized in general.\n\nThe PI case was likely solved with an upscattering tolerance of $1 \\times 10^{-3}$ rather than $1 \\times 10^{-4}$, though this number cannot be confirmed. Converging to the tighter tolerance would likely increase the calculation time for PI. The 4 set preconditioned RQI tests showed that using $S_{2}$ rather than $S_{12}$ reduced solve time by about 75\\% while still getting the right answer. Improvement of that order would likely be seen in the 11 set case as well. The number of grids with 11 sets could be reduced from three to two without an iteration count impact and this would reduce preconditioner time. Finally, any optimization of the preconditioner would bring the two solve times closer together. Another possible but not guaranteed way to reduce the preconditioned RQI time is by using a smaller amount of preconditioning, like $w1r2v2$. This might be sufficient to converge RQI and might also decrease calculation time. \n\n\\subsection{Summary of Findings}\nAll of the test results lead to some useful conclusions. In terms of preconditioning parameters, increasing $r$ and/or $v$ almost always decreased Krylov iteration count and sometimes decreased eigenvalue iteration count. The Krylov iteration reduction is determined by the total number of relaxations, which is determined by $r$ and $v$. All of the relaxations can be executed via $r$ or $v$ or some combination. The way the relaxations are distributed between $r$ and $v$ may influence the calculation time since the distribution changes the number of prolongation and restriction operations. \n\nIt would seem that the order in which the relaxations are done could have an impact on the end iteration count. Smoothing a lot on each grid once could have a different effect on the error modes than smoothing a little bit, going down a grid and smoothing a little, smoothing a little more on the first grid, and then repeating. Different components of the error would be reduced in a different order in a way that could have an impact. If this does have an impact, though, it was not large enough to influence the end iteration count in the tests conducted.  \n \nOverall, a moderate amount of preconditioning gave the best performance. A little bit of preconditioning did not do enough to ensure eigenvector convergence in all cases. Using a large number of relaxations and V-cycles to reduce iteration count was often not worth the extra run time. Because the preconditioner is not yet optimized it is difficult to provide strong conclusions about exactly what $r$ and $v$ values are most worthwhile. \n \nIncreasing the weight a small amount, up to about 1.3 or 1.4, was generally beneficial. However, using a large weight was sometimes detrimental. Weight was the least consistent parameter, behaving differently in different problems with different degrees of preconditioning. Using a weight of 1 with small $r$ and $v$ and a weight between 1 and 1.3 for an intermediate $r$ and $v$ is probably the safest approach. \n\nNote that the improvement gained from the multigrid-in-energy preconditioner is non-linear; doubling the preconditioning parameters does not necessarily halve the iteration count. This means the impact of preconditioning parameters can not be accurately predicted ahead of time. The wider computational community's experience with preconditioning Krylov methods is also that performance cannot be well predicted \\emph{a priori} in general.\n\nSome lessons were also learned about preconditioner choices besides $w$, $r$, and $v$. GMRES, which is the default Krylov method, should always be selected over BiCGSTAB when using RQI. The shifted operator should never be used inside the preconditioner when there are reflecting boundaries, and should probably never be used at all. While it reduced the number of iterations in the vacuum test case compared to the unshifted operator, it was not robust and gave no indication when it resulted in incorrect answers. The default behavior is to use the unshifted operator. \n\nUsing the reduced angular expansion option within the preconditioner may have a lot of pay off. In the two cases where it was tried it reduced calculation time noticeably. This option must be turned on by the user, and should be exploited when possible. It is applicable when the angular expansion is larger than $S_{2}$, but is currently limited to vacuum boundary cases.\n\nBased on the multiset results, the multigrid method likely does not need to restrict down to one energy group. The depth of the V-cycles should be set to only a few or two levels, and experiments should be done to investigate the effect on serial calculation time and energy scaling. Implementing this choice requires changing the code itself. To give the user more control over this setting the code could be modified to provide a user-input option that controls the depth of the V-cycle.\n\nOverall, the multigrid-in-energy preconditioner was shown to be very effective at reducing iteration count. It was demonstrated that it takes advantage of energy parallelization efficiently. The tests showed that RQI can be used with the new preconditioner to solve problems it could not solve without it. They also showed that preconditioned RQI can be faster than preconditioned PI for challenging problems. Will preconditioned RQI ever be faster than unpreconditioned PI? That cannot be answer based on the existing data, but the data do not exclude that possibility. \n\n%-------------------------------------------------------------------------------------------------------\n\\section{Implications}\nThere were two primary motivations for the multigrid-in-energy preconditioner. Power iteration, the traditional eigenvalue solver, can converge slowly for systems with high dominance ratios. This motivated the implementation of RQI, which uses an optimal shift to converge loosely coupled systems in fewer eigenvalue iterations. As was found in Chapter~\\ref{sec:Chp3}, Krylov methods stagnate for poorly conditioned systems such as those created by RQI. Preconditioning is therefore required to be able to use RQI for real problems. \n\nIn addition, ever-expanding computers allow codes to use hundreds of thousands of cores for large computations. Any new preconditioner in Denovo must be able to use these machines efficiently. At its core, the multigroup in energy preconditioner is designed to take advantage of energy parallelization. The way it has been implemented, the multigrid-in-energy method does not require any inter-set communication and it is always energy-load balanced so it should scale extremely well. The new energy decomposition provided by the MG Krylov solver is what allows this preconditioner to be parallelized in energy. Without that, the preconditioner would not be as attractive. \n\nUsing a multigrid method in the energy domain is new for the neutron transport equation. No similar ideas were found in the literature. This is not surprising because the energy scaling motivation for the preconditioner is relatively new as well. Only in the last few years has parallelization in energy become feasible. Without that driver there was no reason to do multigrid in energy. \n\nThe goals for the new preconditioner were to decrease iteration count for at least some problems, to enable RQI, and to be decomposable in energy. All goals were achieved. The multigrid-in-energy preconditioner reduced the number of Krylov iterations for all problem types as long as the eigenvector converged. In some cases it reduced the number of eigenvalue iterations as well. The preconditioner makes the use of RQI in real problems possible, and it scales to hundreds of thousands of cores without trouble. \n\n\n\n\\separatorpage{}\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "1a298a4b85316095a1b94225f59dd89829ee389d", "size": 130221, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "precond.tex", "max_stars_repo_name": "rachelslaybaugh/RNS_Thesis", "max_stars_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-01-07T09:06:04.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-16T17:13:56.000Z", "max_issues_repo_path": "precond.tex", "max_issues_repo_name": "rachelslaybaugh/RNS_Thesis", "max_issues_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "precond.tex", "max_forks_repo_name": "rachelslaybaugh/RNS_Thesis", "max_forks_repo_head_hexsha": "d931afe50367e1d91b952a9d570c286e0b7f6d42", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-24T17:15:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-24T17:15:21.000Z", "avg_line_length": 124.3753581662, "max_line_length": 937, "alphanum_fraction": 0.732278204, "num_tokens": 33780, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266736, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.404538662046008}}
{"text": "\\documentclass[nofootinbib,amssymb,amsmath]{revtex4}\n\\usepackage{mathtools}\n\\usepackage{amsthm}\n\\usepackage{amsmath}\n\\usepackage{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{lmodern}\n\\usepackage{graphicx}\n\\usepackage{color}\n\\usepackage{bm}\n\n%Put an averaged random variable between brackets\n\\newcommand{\\ave}[1]{\\left\\langle #1 \\right\\rangle}\n\n\\newcommand{\\vzero}{{\\bf 0}}\n\\newcommand{\\vI}{{\\bf I}}\n\\newcommand{\\vb}{{\\bf b}}\n\\newcommand{\\vd}{{\\bf d}}\n\\newcommand{\\vf}{{\\bf f}}\n\\newcommand{\\vc}{{\\bf c}}\n\\newcommand{\\vv}{{\\bf v}}\n\\newcommand{\\vz}{{\\bf z}}\n\\newcommand{\\vn}{{\\bf n}}\n\\newcommand{\\vm}{{\\bf m}}\n\\newcommand{\\vG}{{\\bf G}}\n\\newcommand{\\vQ}{{\\bf Q}}\n\\newcommand{\\vM}{{\\bf M}}\n\\newcommand{\\vW}{{\\bf W}}\n\\newcommand{\\vX}{{\\bf X}}\n\\newcommand{\\vPsi}{{\\bf \\Psi}}\n\\newcommand{\\vSigma}{{\\bf \\Sigma}}\n\\newcommand{\\vlambda}{{\\bf \\lambda}}\n\\newcommand{\\vpi}{{\\bf \\pi}}\n\\newcommand{\\valpha}{{\\bm{\\alpha}}}\n\\newcommand{\\vbeta}{{\\bm{\\beta}}}\n\\newcommand{\\vomega}{{\\bm{\\omega}}}\n\\newcommand{\\vLambda}{{\\bf \\Lambda}}\n\\newcommand{\\vA}{{\\bf A}}\n\n\\newcommand{\\code}[1]{\\texttt{#1}}\n\\newcommand*{\\Comb}[2]{{}^{#1}C_{#2}}\n\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{corollary}{Corollary}\n\n\\def\\SL#1{{\\color [rgb]{0,0,0.8} [SL: #1]}}\n\\def\\DB#1{{\\color [rgb]{0,0.8,0} [DB: #1]}}\n\n\\newcommand{\\HOM}{$\\mathsf{Hom}$}\n\\newcommand{\\HET}{$\\mathsf{Het}$}\n\\newcommand{\\REF}{$\\mathsf{Ref}$}\n\\newcommand{\\epss}{\\varepsilon}\n\n\\begin{document}\n\n\\title{Mathematical Notes on Mutect}\n\\author{David Benjamin}\n\\email{davidben@broadinstitute.org}\n\\affiliation{Broad Institute, 75 Ames Street, Cambridge, MA 02142}\n\\author{Takuto Sato}\n\\email{tsato@broadinstitute.org}\n\\affiliation{Broad Institute, 75 Ames Street, Cambridge, MA 02142}\n\n\\date{\\today}\n\n\\maketitle\n\n\\section{Somatic Likelihoods Model}\\label{introduction}\n\nWe have a set of potential somatic alleles and read-allele likelihoods $\\ell_{ra} \\equiv P({\\rm read~}r|{\\rm allele~}a)$.  We don't know which alleles are real somatic alleles and so we must compute, for each subset $\\mathbb{A}$ of alleles, the likelihood that the reads come from $\\mathbb{A}$.  A simple model for this likelihood is as follows: each read $r$ is associated with a latent indicator vector $\\vz_r$ with one-hot encoding $z_{ra} = 1$ iff read $r$ came from allele $a \\in \\mathbb{A}$.  The conditional probability of the reads $\\mathbb{R}$ given their allele assignments is\n\\begin{equation}\nP( \\mathbb{R} | \\vz, \\mathbb{A}) = \\prod_{r \\in \\mathbb{R}} \\prod_a \\ell_{ra}^{z_{ra}}.\n\\end{equation}\nThe alleles are not equally likely because there is a latent vector $\\vf$ of allele fractions -- $f_a$ is the allele fraction of allele $a$.  Since the components of $\\vf$ sum to one it is a categorical distribution and can be given a Dirichlet prior,\n\\begin{equation}\nP(\\vf) = {\\rm Dir}(\\vf | \\valpha).\n\\end{equation}\nThen $f_a$ is the prior probability that a read comes from allele $a$ and thus the conditional probability of the indicators $\\vz$ given the allele fractions $\\vf$ is\n\\begin{equation}\nP(\\vz | \\vf) = \\prod_r \\prod_a f_a^{z_{ra}}.\n\\end{equation}\nThe full-model likelihood is therefore\n\\begin{equation}\n\\mathbb{L}(\\mathbb{A}) = P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) = {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r \\left( f_a \\ell_{ra}\\right)^{z_{ra}}.\n\\label{full_likelihood}\n\\end{equation}\nAnd the marginalized likelihood of $\\mathbb{A}$, that is, the model evidence for allele subset $\\mathbb{A}$, is\n\\begin{equation}\nP(\\mathbb{R} | \\mathbb{A}) = \\sum_\\vz \\int d \\vf \\, {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r \\left( f_a \\ell_{ra}\\right)^{z_{ra}},\n\\label{evidence}\n\\end{equation}\nwhere the integral is over the probability simplex $\\sum_a f_a = 1$.\n\nThe integral over $\\vf$ is the normalization constant of a Dirichlet distribution and as such we can simply look up its formula.  However, the sum over all values of $\\vz$ for all reads has exponentially many terms.  We will get around this difficulty by handling $\\vz$ with a mean-field approximation in which we factorize the likelihood as $\\mathbb{L} \\approx q(\\vz) q(\\vf)$.  This approximation is exact in two limits: first, if there are many reads, each allele is associated with many reads and therefore the Law of Large Numbers causes $\\vf$ and $\\vz$ to become uncorrelated.  Second, if the allele assignments of reads are obvious $\\vz_r$ is effectively not a random variable at all (there is no uncertainty as to which of component is non-zero) and also becomes uncorrelated with $\\vf$.\n\nIn the variational Bayesian mean-field formalism the value of $\\vf$ that $\\vz$ ``sees'' is the expectation of $\\log \\mathbb{L}$ with respect to $q(\\vf)$ and vice versa.  That is,\n\\begin{equation}\nq(\\vf) \\propto {\\rm Dir}(\\vf | \\valpha) \\prod_a  \\prod_r f_a^{\\bar{z}_{ra}} \\propto {\\rm Dir}(\\vf | \\valpha + \\sum_r \\bar{\\vz}_r),\n\\label{qf}\n\\end{equation}\nwhere $\\bar{z}_{ra} \\equiv E_q \\left[ z_{ra} \\right]$, and\n\\begin{equation}\nq(\\vz_r) = \\prod_a \\left( \\tilde{f}_a \\ell_{ra}\\right)^{z_{ra}}, \\tilde{f}_a = \\exp E[\\ln f_a]\n\\end{equation}\nBecause $q(\\vz)$ is categorical and $q(\\vf)$ is Dirichlet\\footnote{Note that we didn't \\textit{impose} this in any way.  It simply falls out of the mean field equations.} the necessary mean fields are easily obtained and we have\n\\begin{equation}\n\\bar{z}_{ra} = \\frac{\\tilde{f}_a \\ell_{ra}}{\\sum_{a^\\prime} \\tilde{f}_{a^\\prime} \\ell_{ra^\\prime}}\n\\label{z_mean_field}\n\\end{equation}\nand\n\\begin{equation}\n\\ln \\tilde{f}_a = \\psi(\\alpha_a + \\sum_r \\bar{z}_{ra}) - \\psi(\\sum_{a^\\prime} \\alpha_{a^\\prime} + N)\n\\label{f_mean_field}\n\\end{equation}\nwhere $\\psi$ is the digamma function and $N$ is the number of reads.  To obtain $q(\\vz)$ and $q(\\vf)$ we iterate Equations \\ref{z_mean_field} and \\ref{f_mean_field} until convergence.  A very reasonable initialization is to set $\\bar{z}_{ra} = 1$ if $a$ is the most likely allele for read $r$, 0 otherwise.  Having obtained the mean field of $\\vz$, we would like to plug it into Eq \\ref{evidence}.  We can't do this directly, of course, because Eq \\ref{evidence} says nothing about our mean field factorization.  Rather, we need the variational approximation (Bishop's Eq 10.3) to the model evidence, which is\n\\begin{align}\n\\ln P(\\mathbb{R} | \\mathbb{A}) \\approx& \\sum_{\\vz} \\int d \\vf q(\\vz) q(\\vf) \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) - \\ln q(\\vz) - \\ln q(\\vf) \\right] \\\\\n=& E_q \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) \\right] - E_q \\left[ \\ln q(\\vz) \\right] - E_q \\left[ \\ln q(\\vf) \\right]. \\label{lagrangian}\n\\end{align}\nBefore we proceed, let's introduce some notation.  First, from Eq \\ref{qf} the posterior $q(\\vf)$ is\n\\begin{equation}\nq(\\vf) = {\\rm Dir}(\\vf | \\vbeta), \\quad \\vbeta = \\valpha + \\sum_r \\bar{\\vz}_r.\n\\end{equation}\nSecond, let's define the log normalization constant of a Dirichlet distribution as $g$ so that\n\\begin{equation}\n\\ln {\\rm Dir}(\\vf | \\vomega) = g(\\vomega) + \\sum_a (\\omega_a - 1) \\ln f_a, \\quad g(\\vomega) = \\ln \\Gamma(\\sum_a \\omega_a) - \\sum_a \\ln \\Gamma(\\omega_a).\n\\end{equation}\nFinally, define the Dirichlet mean log (aka ``that digamma stuff\") as $h$:\n\\begin{equation}\nE_{\\rm Dir(\\vf | \\vomega)} \\left[ \\ln f_a \\right] = \\psi(\\omega_a) - \\psi(\\sum_{a^\\prime} \\omega_{a^\\prime}) \\equiv h_a(\\vomega).\n\\end{equation}\n\nThe log of Eq \\ref{full_likelihood} is\n\\begin{equation}\n\\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) = g(\\valpha) + \\sum_a (\\alpha_a - 1) \\ln f_a + \\sum_{ra} z_{ra} (\\ln f_a + \\ln \\ell_{ra}).\n\\end{equation}\nand thus the first term in Eq \\ref{lagrangian} is\n\\begin{align}\nE_q \\left[ \\ln P(\\mathbb{R}, \\vz, \\vf | \\mathbb{A}) \\right] =& g(\\valpha) + \\sum_a (\\alpha_a - 1) h_a(\\vbeta) + \\sum_{ra}\\bar{z}_{ra} \\left( h_a(\\vbeta) + \\ln \\ell_{ra} \\right) \\\\\n=& g(\\valpha) + \\sum_a (\\beta_a - 1) h_a(\\vbeta) + \\sum_{ra}\\bar{z}_{ra} \\ln \\ell_{ra}, \\label{first_term}\n\\end{align}\nwhere we used the relationship $\\vbeta = \\valpha + \\sum_r \\bar{\\vz}_r$.\n\nThe second term in Eq \\ref{lagrangian} is\n\\begin{align}\n- E_q \\left[ \\ln q(\\vz) \\right] = - \\sum_{ra} \\bar{z}_{ra} \\ln \\bar{z}_{ra} \\label{second_term}.\n\\end{align}\n\nThe third term in Eq \\ref{lagrangian} is\n\\begin{align}\n- E_q \\left[ \\ln q(\\vf) \\right] = -g(\\vbeta) - \\sum_a (\\beta_a - 1) E_q [\\ln f_a] = -g(\\vbeta) - \\sum_a (\\beta_a - 1) h_a(\\vbeta) \\label{third_term}.\n\\end{align}\n\nAdding Eqs \\ref{first_term}, \\ref{second_term}, and \\ref{third_term} and noting the cancellation between parts of Eqs \\ref{first_term} and \\ref{third_term} we obtain\n\\begin{equation}\n\\ln P(\\mathbb{R} | \\mathbb{A}) \\approx g(\\valpha) - g(\\vbeta) +  \\sum_{ra} \\bar{z}_{ra} \\left( \\ln \\ell_{ra} - \\ln \\bar{z}_{ra} \\right).\n\\end{equation}\n\nWe now have the model evidence for allele subset $\\mathbb{A}$.  This lets us choose which alleles are true somatic variants.  It also lets us make calls on somatic loss of heterozygosity events.  Furthermore, instead of reporting max-likelihood allele fractions as before, we may emit the parameters of the Dirichlet posterior $q(\\vf)$, which encode both the maximum likelihood allele fractions and their uncertainty.\n\n\\section{Strand Artifact Model}\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.3\\textwidth]{strand_artifact_pgm.png}\n\\caption{\\label{fig:strand artifact}The probabilistic graphical model for the strand artifact model}\n\\end{figure}\n\nThe strand artifact filter detects sequencing artifacts in which the evidence for the alt allele consists entirely of forward strand reads alone or reverse strand reads alone. We must detect this while taking into account the fact that at some loci, such as near the end of an exome target, \\emph{all} reads are biased towards one direction, and therefore a bias towards a particular strand among alt reads is no cause for alarm.\n\nLet $z \\in \\{ z_+, z_-, z_o \\}$ be a latent random variable with 1-hot encoding that represents the artifact state of a suspected variant. $z_+ = 1$ when the candidate variant is a forward strand artifact, $z_- = 1$ when it's a reverse artifact, and $z_o = 1$ when there's no artifact. At each locus, the conditional distribution over the number of forward alt reads $x^+$ is a binomial random variable\n\n\\begin{equation}\nP(x^+ | f, \\epsilon, z) = \\text{Bin} (x^+ | n^+, f + \\epsilon(1-f))^{z_+} \\text{Bin} (x^+ | n^+, f)^{1 - z_+}\n\\end{equation}\n\nwhere $n^+$ is the number of \\emph{total} forward reads, $f$ is the allele fraction, and $\\epsilon$ is the artifactual error rate, which is the probability that we mistakenly read a ref allele as alt due to strand artifact. We put a flat prior on $f$ and a beta prior on $\\epsilon$. The conditional distribution of $x^-$ is defined analogously.\n\nIn order to decide whether to filter a variant, we compute the posterior probabilities of $z$ given the observed alt read counts $X = \\{ x^+, x^- \\}$.  We obtain the likelihood $P(X | z)$ by marginalizing the latent variables $f$ and $\\epsilon$ out of the joint distribution $P(X, f, \\epsilon | z)$, and we do this for each of the three possible values of $z$ separately. First consider the case $z_+ = 1$, which we denote by the shorthand $z_+$ below.\n\n\\begin{align}\nP(X | z_+ )  &= \\iint  P(X, f, \\epsilon | z_+) \\,df\\,d\\epsilon \\nonumber \\\\\n\t\t  &= \\iint  P(f) P(\\epsilon) P(x^+ | z_+, f, \\epsilon) P(x^- | z_+, f, \\epsilon) \\,df\\,d\\epsilon \\nonumber \\\\\n\t\t  &= \\iint \\mathrm{Beta}(\\epsilon|\\alpha, \\beta) \\mathrm{Bin}(x^+ | n^+, f + \\epsilon(1-f)) \\mathrm{Bin}(x^- | n^-, f) \\,df\\,d\\epsilon\n\\end{align}\n\nwhere $\\alpha$ and $\\beta$ are fixed hyperparameters to the beta prior on $\\epsilon$. By Bayes Rule the posterior probability of strand bias for forward reads is therefore\n\n\\begin{align}\nP(z_+ | X) & \\propto P(z_+) P(X | z_+) = \\pi_+ P(X | z_+) \n\\end{align}\n\nwhere $\\pi_+ = P(z_+)$ is a fixed prior probability of strand artifact. The posterior probability of reverse strand artifact $P(z_- | X)$ may be derived analogously. \n\nThe derivation of $P(z_o|X)$ is similar except that the integral becomes much simpler because $P(X|z_o)$ does not depend on the artifactual error rate $\\epsilon$.\n\n\\begin{align}\nP(X | z_o)  &= \\iint P(\\epsilon) P(x^+ | z_o, f, \\epsilon) P(x^- | z_o, f, \\epsilon) \\,df\\,d\\epsilon \\nonumber \\\\\n\t \t &= \\int  P(x^+ | z_o, f) P(x^- | z_o, f) \\,df \\int  P(\\epsilon) d\\epsilon \\nonumber \\\\\n\t\t &= \\int  \\mathrm{Bin}(x^+ | n^+, f) \\mathrm{Bin}(x^- | n^-, f) \\,df\n\\end{align}\n\nAnd the posterior probability is\n\n\\begin{equation}\nP(z_o | X) \\propto P(z_o) P(X | z_o) =  \\pi_o P(X | z_o) \n\\end{equation}\n\nwhere $\\pi_o = P(z_o = 1)$ is the fixed prior probability of no artifact. We normalize the posteriors and filter the variant if the posterior probability of $z_+ = 1$ or $z_- = 1$ exceeds the threshold.\n\n\\section{Germline Filter}\\label{germline-filter}\nSuppose we have detected an allele such that its (somatic) likelihood in the tumor is $\\ell_t$ and its (diploid) likelihood in the normal is $\\ell_n$\\footnote{This is the total likelihood for het and hom alt in the normal.}.  By convention, both of these are relative to a likelihood of $1$ for the allele \\textit{not} to be found.  If we have no matched normal, $\\ell_n = 1$.  Suppose we also have the population allele frequency $f$ of this allele.  Then the prior probabilities for the normal to be heterozygous and homozygous alt for the allele are $2f(1-f)$ and $f^2$ and the prior probability for the normal genotype not to contain the allele is $(1-f)^2$.  Finally, suppose that the prior for this allele to arise as a somatic variant is $\\pi$.\n\nWe can determine the posterior probability that the variant exists in the normal genotype by calculating the unnormalized probabilities of four possibilities:\n\\begin{enumerate}\n\\item The variant exists in the tumor and the normal as a germline het.  This has unnormalized probability $2f(1-f) \\ell_n \\ell_t (1 - \\pi)$.\n\\item The variant exists in the tumor and the normal as a germline hom alt.  This has unnormalized probability $f^2 \\ell_n \\ell_t (1 - \\pi)$.\n\\item The variant exists in the tumor but not the normal.  This has unnormalized probability $(1-f)^2 \\ell_t \\pi$.\n\\end{enumerate}\n\nWe exclude possibilities in which the variant does not exist in the tumor sample because we really want the conditional probability that the variant is germline given that it would otherwise be called.\n\nNormalizing, we obtain the following posterior probability that an allele is a germline variant:\n\\begin{equation}\nP({\\rm germline}) = \\frac{(1) + (2)}{(1) + (2) + (3)} = \\frac{\\left(2f(1-f) + f^2 \\right) \\ell_n \\ell_t (1 - \\pi)}{\\left(2f(1-f) + f^2 \\right) \\ell_n \\ell_t  (1 - \\pi) + \\ell_t (1-f)^2  \\pi}.\n\\end{equation}\n\nThe above equation, in which the factors of $\\ell_t$ could cancel if we wished, is not quite right.  The tumor likelihood $\\ell_t$ is the probability of the tumor data given that the allele exists in the tumor \\textit{as a somatic variant}.  If the allele is in the tumor as a germline het we must modify $\\ell_t$ to account for the fact that the allele fraction is determined by the ploidy -- it must be either $f_g$ or $1- f_g$with equal probability, where $f_g$ is the minor allele fraction of germline hets.  It would be awkward to recalculate the tumor likelihood with the allele frequency constrained to these two values\\footnote{The model could easily accommodate this change, but the likelihoods are long gone from memory once the germline computation occurs.}, but we can estimate a correction factor as follows:  assuming that the posterior on the allele fraction in the somatic likelihoods model is fairly tight, the likelihood of $a$ alt reads out of $n$ total reads is $\\binom na (1-f_t)^{n-a}f^a$, where $f_t$ is the tumor alt allele fraction.  That is, our sophisticated model that marginalizes over $f_t$ reduces to something more naive.  If the variant is a germline event, the likelihood becomes $\\frac{1}{2} \\binom na  \\left[(1-f_g)^{n-a}f_g^a + f_g^{n-a}(1-f_g)^a \\right]$.  Thus, in case (1) we have $\\ell_t \\rightarrow \\chi \\ell_t$, where\n\\begin{equation}\n\\chi = \\frac{1}{2} \\frac{(1-f_g)^{n-a}f_g^a + f_g^{n-a}(1-f_g)^a}{(1-f_t)^{n-a}f_t^a}.\n\\end{equation}\nFor germline hom alts, both the tumor and normal allele fractions will be similarly large, so to decent approximation we don't have to modify $\\ell_t$.  Of course, this only applies if the allele fraction is large.  Rather than try to model the count of ref reads within a germline hom alt site, we simply set a threshold of allele fraction 0.9, so that in case (2) $\\ell_t \\rightarrow {\\rm I}[f_t > 0.9] \\ell_t$.\nand the corrected germline probability is\n\\begin{equation}\nP({\\rm germline}) = \\frac{(1) + (2)}{(1) + (2) + (3)} = \\frac{\\left( 2f(1-f) \\chi + {\\rm I}[f_t > 0.9] f^2 \\right) \\ell_n (1 - \\pi)}{\\left( 2f(1-f) \\chi + {\\rm I}[f_t > 0.9] f^2 \\right) \\ell_n  (1 - \\pi) + (1-f)^2  \\pi}.\n\\end{equation}\nTo filter, we set a threshold on this posterior probability.\n\nSo far we have assumed that the population allele frequency $f$ is known, which is the case if it is found in our germline resource, such as gnomAD.  If $f$ is not known we must make a reasonable guess as follows.  Suppose the prior distribution on $f$ is ${\\rm Beta}(\\alpha, \\beta)$.  The mean $\\alpha/(\\alpha +\\beta)$ of this prior is the average human heterozygosity $\\theta \\approx 10^{-3}$, so we have $\\beta \\approx \\alpha / \\theta$.  We need one more constraint to determine $\\alpha$ and $\\beta$, and since we are concerned with imputing $f$ when $f$ is small we use a condition based on rare variants.  Specifically, the number of variant alleles $n$ at some site in a germline resource with $N/2$ samples, hence $N$ chromosomes, is given by $f \\sim {\\rm Beta}(\\alpha, \\beta), n \\sim {\\rm Binom}(N,f)$.  That is, $n \\sim {\\rm BetaBinom}(\\alpha, \\beta, N)$.  The probability of a site being non-variant in every sample is then $P(n = 0) = {\\rm BetaBinom}(0 | \\alpha, \\beta, N)$, which we equate to the empirical proportion of non-variant sites in our resource, about $7/8$ for exonic sites in gnomAD.  Solving, we obtain approximately $\\alpha = 0.01, \\beta = 10$ for gnomAD.  Now, given that some allele found by Mutect is not in the resource, the posterior on $f$ is ${\\rm Beta}(\\alpha, \\beta + N)$, the mean of which is, since $\\beta << N$, about $\\alpha / N$.  By default, Mutect uses this value.\n\n\\section{Contamination Filter}\\label{contamination-filter}\nSuppose our tumor bam has contamination fraction $\\alpha$ and that at some site we have $a$ alt reads out of $d$ total reads.  Suppose further that the alt allele has population allele frequency $f$.  We will compute a simple estimate of the posterior probability that these alt reads came from a contaminating sample and not from a true somatic variant.  Let $\\pi$ be the prior probability of somatic variation as above.  Our crude model for the alt count distribution of somatic variation is a uniform distribution.  That is, we assume that any value of $a$ from $0$ to $d$ is equally likely.  Then the likelihood of the data given a true somatic variant is\n\\begin{equation}\nP(a | {\\rm somatic})  = \\frac{1}{d + 1}.\n\\end{equation}\n\nWe consider two models of contamination.  If there are multiple contaminants we approximate each contaminant read as independent.  Then the probability of any given read being an alt contaminant read is $\\alpha f$, so we have\n\\begin{equation}\nP(a | {\\rm many~contaminant}) = {\\rm Binom}(a | d, \\alpha f).\n\\end{equation}\nIf there is a single contaminating sample it is heterozygous with probability $2f(1-f)$ and homozygous for the alt with probability $f^2$, in which cases fractions $\\alpha/2$ and $\\alpha$ of all reads to be alt contaminants.  The contaminant is homozygous for the ref with probability $(1-f)^2$, which yields no alt reads. Thus\n\\begin{equation}\nP(a | {\\rm one~contaminant}) = 2f(1-f) {\\rm Binom}(a | d, \\alpha /2) + f^2 {\\rm Binom}(a | d, \\alpha) + (1-f)^2 {\\rm I}[a = 0].\n\\end{equation}\nWe take the likelihood $P(a | {\\rm contamination})$ to be the maximum of these, which admittedly is not quite rigorous.  Usually one will be overwhelmingly larger than the other, however, so it's a decent approximation.  Our posterior probability of contamination is then\n\\begin{equation}\nP({\\rm contamination} | a) = \\frac{  P(a, {\\rm contamination}) } {P(a, {\\rm contamination}) + P(a, {\\rm somatic}) } = \\frac{  (1-\\pi)P(a | {\\rm contamination}) } {(1-\\pi)P(a | {\\rm contamination}) + \\pi P(a | {\\rm somatic}) }\n\\end{equation}\nWe filter by setting a threshold on this posterior probability.\n\n\\section{Finding Active Regions}\nMutect triages sites based on their pileup at a single base locus.  If there is sufficient evidence of variation Mutect proceeds with local reassembly and realignment.  As in the downstream parts of Mutect we seek a likelihood ratio between the existence and non-existence of an alt allele.  Instead of obtaining read likelihoods via Pair-HMM, we assign each base a likelihood.  For substitutions we can simply use the base quality.  For indels we assign a heuristic effective quality that increases with length.  Supposing we have an effective quality for each element in the read pileup we can now estimate the likelihoods of no variation and of a true alt allele with allele fraction $f$.  Let $\\mathcal{R}$ and $\\mathcal{A}$ denote the sets of ref and alt reads.  The likelihood of no variation is the likelihood that every alt read was in error.  Letting $\\epsilon_i$ be the error probability of pileup element $i$ we have:\n\n\\begin{equation}\nL({\\rm no~variation}) = \\prod_{i \\in \\mathcal{R}} (1 - \\epsilon_i) \\prod_{j \\in \\mathcal{A}} \\epsilon_j \\approx \\prod_{j \\in \\mathcal{A}} \\epsilon_j, \n\\end{equation}\nwhere the approximation amounts to ignoring the possibility that ref reads are actually alt, or, equivalently, giving each ref read infinite quality.  This is not necessary but it speeds the computation because, as we will see, we will only need to keep alt base qualities in memory.\n\\begin{equation}\nL(f) = \\prod_{i \\in \\mathcal{R}} \\left[ (1 -f)(1 - \\epsilon_i) + f \\epsilon_i \\right] \\prod_{j \\in \\mathcal{A}} \\left[f(1 - \\epsilon_j) + (1 - f) \\epsilon_j \\right]\n\\approx (1-f)^{N_{\\rm ref}} \\prod_{j \\in \\mathcal{A}} \\left[f(1 - \\epsilon_j) + (1 - f) \\epsilon_j \\right],\n\\end{equation}\nwhere we again assign infinite base quality to ref reads and let $N_{\\rm ref} = | \\mathcal{R}|$.\n\nThis is equivalent to the following model in which we give the $n$th alt read a latent indicator $z_j$ which equals 1 when the read is an error:\n\\begin{align}\nP({\\rm reads}, f, \\vz) = (1-f)^{N_{\\rm ref}} \\prod_{n=1}^{N_{\\rm alt}} \\left[ (1-f)\\epsilon_n \\right]^{z_n} \\left[ f (1 - \\epsilon_n) \\right]^{1 - z_n}\n\\end{align}\nWe will approximate the model evidence $L(f) = \\sum_\\vz \\int \\, df P({\\rm reads}, f, \\vz)$ via a mean field variational Bayes approximation in which we factorize the full data likelihood as $P({\\rm reads}, f, \\vz) \\approx q(f) q(\\vz) = q(f) \\prod_n q(z_n)$\\footnote{The latter step is an induced factorization -- once $f$ and $\\vz$ are decoupled, then the different $z_n$ become independent as well.}.  For simplicity and speed, we will not iteratively compute $q(f)$.  Rather, we use the fact that $z_n$ is almost always 0 to see, by inspection, that\n\\begin{equation}\nq(f) \\approx {\\rm Beta}(f | \\alpha, \\beta), \\quad \\alpha = N_{\\rm alt} + 1, \\beta = N_{\\rm ref} + 1.\n\\end{equation}\nHere the ``$+1$\"s come from the pseudocounts, one ref and one alt, of a flat prior of $f$.  Then, following the usual recipe of averaging the log likelihood with respect to $f$ and re-exponentiating, we find that $z_n$ ``sees\" the following distribution:\n\\begin{align}\nq(z_n) &\\propto \\left[ \\epsilon_n \\exp \\overline{\\ln (1 - f)} \\right]^{z_n} \\left[ (1 - \\epsilon_n) \\exp \\overline{\\ln f} \\right]^{1 - z_n} \\\\\n&= \\left[ \\epsilon_n \\rho \\right]^{z_n} \\left[ (1 - \\epsilon_n) \\tau \\right]^{1 - z_n},\n\\end{align}\nwhere we have defined the standard Beta distribution moments (with respect to $q(f)$) $\\ln \\rho \\equiv \\overline{\\ln (1 - f)} = \\psi(\\beta) - \\psi(\\alpha + \\beta)$ and $\\ln \\tau \\equiv \\overline{\\ln f} = \\psi(\\alpha) - \\psi(\\alpha + \\beta)$. By inspection, we see that\n\\begin{equation}\nq(z_n) = {\\rm Bernoulli}(z_n | \\gamma_n), \\quad \\gamma_n = \\frac{ \\rho \\epsilon_n}{\\rho \\epsilon_n + \\tau (1 - \\epsilon_n)}.\n\\end{equation}\nThen, Equation 10.3 of Bishop gives us the variational lower bound on $L(f)$:\n\\begin{align}\nL(f) &\\approx E_q \\left[ \\ln P({\\rm reads}, f, \\vz) \\right] + {\\rm entropy}[q(f)] + \\sum_n {\\rm entropy}[q(z_n)] \\\\\n&= H(\\alpha, \\beta) +  N_{\\rm ref} \\ln \\rho + \\sum_n \\left[ \\gamma_n \\ln \\left( \\rho \\epsilon_n \\right) + (1 - \\gamma_n) \\ln \\left( \\tau (1 - \\epsilon_n) \\right) + H(\\gamma_n) \\right],\n\\end{align}\nwhere $H(\\alpha, \\beta)$ and $H(\\gamma)$ are Beta and Bernoulli entropies.  We summarize these steps in the following algorithm:\n\n\\begin{algorithm}\n\\begin{algorithmic}[1]\n\\State Record the base qualities, hence the error probabilities $\\epsilon_n$ of each alt read.\n\\State $\\alpha = N_{\\rm alt} + 1$, $\\beta = N_{\\rm ref} + 1$\n\\State $\\rho = \\exp \\left( \\psi(\\beta) - \\psi(\\alpha + \\beta) \\right) $, $\\tau = \\exp \\left( \\psi(\\alpha) - \\psi(\\alpha + \\beta) \\right)$.\n\\State $\\gamma_n =  \\rho \\epsilon_n / \\left[ \\rho \\epsilon_n + \\tau (1 - \\epsilon_n) \\right]$\n\\State $L(f) \\approx H(\\alpha, \\beta) + N_{\\rm ref} \\ln \\rho + \\sum_n \\left[ \\gamma_n \\ln \\left( \\rho \\epsilon_n \\right) + (1 - \\gamma_n)\\ln \\left( \\tau (1 - \\epsilon_n) \\right) + H(\\gamma_n) \\right]$\n\\end{algorithmic}\n%\\caption{Pair HMM algorithm}\n%\\label{pairHMM}\n\\end{algorithm}\nTo get the log odds we subtract the log likelihood, $\\sum_n \\ln \\epsilon_n$, from $L(f)$.\n\n\n\n\\section{Calculating Contamination}\nBelow, we present the GATK's fast, simple, and accurate method for calculating the contamination of a sample.  This methods does not require a matched normal, makes no assumptions about the number of contaminating samples, and remains accurate even when the sample has a lot of copy number variation.\n\nThe inputs to our tool are a bam file and a vcf of common variants -- for example ExAC, gnomAD, or 1000 Genomes -- with their allele frequencies.  The basic idea, which comes from ContEst\\footnote{ContEst: estimating cross-contamination of human samples in next-generation sequencing data, \\textit{Bioinformatics} \\textbf{27}, 2601 (2011)} by Kristian Cibulskis and others in the Broad Institute Cancer Genome Analysis group, is simply to count ref reads at hom alt sites and subtract the number of ref reads expected from sequencing error to obtain the number of ref reads contaminating these hom alt sites.  Finally, we use the allele frequencies to account for the fact that some contaminating reads have the alt allele.  The only subtlety is in distinguishing hom alt sites from loss of heterozygosity events, which we describe below.\n\nSuppose we have a set $\\mathbb{H}$ of SNPs at which our sample is homozygous for the alternate allele.  Let $N_{\\rm ref}$ be the total number of ref reads at these sites.  We can decompose $N_{\\rm ref}$ as follows:\n\\begin{align}\nN_{\\rm ref} = N_{\\rm ref}^{\\rm error} + N_{\\rm ref}^{\\rm contamination}, \\label{decomposition}\n\\end{align}\nwhere $N_{\\rm ref}^{\\rm error}$  and $N_{\\rm ref}^{\\rm contamination}$ are as the number of ref reads due to error and contamination, respectively.  We can obtain $N_{\\rm ref}$ by counting reads, and we estimate $N_{\\rm ref}^{\\rm error}$ as follows.  Suppose, WLOG, that the ref allele is A and the alt is C.  Then, assuming that all substitution errors are equally likely, $N_{\\rm ref}^{\\rm error}$ is approximately half the number of Gs and Ts.  This is, of course, not a perfect assumption for any one site, but on average over all the sites in $\\mathbb{H}$ it is very good.\n\nNext we take the expectation of both sides of Equation \\ref{decomposition} to obtain\n\\begin{align}\n\\ave{N_{\\rm ref} - N_{\\rm ref}^{\\rm error}} =& \\ave{\\sum_{s \\in \\mathbb{H}} {\\rm number~of~contaminant~ref~reads~at~}s} \\\\\n=& \\sum_{s \\in \\mathbb{H}} \\ave{{\\rm number~of~contaminant~ref~reads~at~}s} \\\\\n=& \\sum_{s \\in \\mathbb{H}} \\ave{{\\rm number~of~contaminant~reads~at~}s \\times {\\rm ref~fraction~of~contaminant~reads~at~}s} \\\\\n=& \\sum_{s \\in \\mathbb{H}} \\ave{{\\rm number~of~contaminant~reads~at~}s} \\times \\ave{{\\rm ref~fraction~of~contaminant~reads~at~}s}\n\\end{align}\nwhere we have used the linearity of the expectation and the independence of the total number of contaminant reads with the fraction of contaminant reads that are ref.  The expectation of the total number of contaminant reads is the depth $d_s$ at site $s$ times the contamination, which we denote by $\\chi$.  The expected fraction of contaminant reads that are ref is one minus the alt allele frequency $f_s$.  Crucially, this fact is independent of how many contaminating samples there are.  Thus we have\n\\begin{align}\n\\ave{N_{\\rm ref} - N_{\\rm ref}^{\\rm error}} = \\chi \\sum_{s \\in \\mathbb{H}} d_s (1 - f_s)\n\\end{align}\nand obtain the estimate\n\\begin{align}\n\\hat{\\chi} \\approx \\frac{N_{\\rm ref} - N_{\\rm ref}^{\\rm error}}{\\sum_{s \\in \\mathbb{H}} d_s (1 - f_s)} \\label{contamination_estimate}\n\\end{align}\n\n\nLet us now roughly estimate the error bars on this result.  The main source of randomness is the stochasticity in the number of contaminating ref reads.  Although the nature of this randomness depends on the number of contaminants, the most variable case, hence an upper bound, is that of a single haploid contaminant, since at each site the only possibilities are the extremes of all contaminant reads being ref or all being alt.  In this case, the contribution to the numerator of Eq. \\ref{contamination_estimate} from site $s$ is the random variable $X_sZ_s$, where $X_s \\sim {\\rm Binom(d_s, \\chi)}$ is the number of contaminant reads at $s$ and $Z_s$ is a binary indicator for whether the contaminant reads are ref, with $P(Z_s=1) = 1 - f_s$.  $X$ and $Z$ are independent, so we can work out the variance of $XZ$ as:\n\\begin{align}\n{\\rm var}(XZ) =& E[X^2Z^2] - E[XZ]^2 \\\\\n=& (1 - f_s) E[X^2] - (1-f_s)^2 E[X]^2 \\\\\n=& (1 - f_s) \\left( {\\rm var}(X) + E[X]^2 \\right) - (1 - f_s)^2E[X]^2 \\\\\n=& (1 - f_s) d_s \\chi(1 - \\chi) + f_s(1 - f_s) d_s^2 \\chi^2\n\\end{align}\nAnd therefore the standard error on $\\hat{\\chi}$ comes out to the square root of the sum of these per-site variances, divided by the denominator of Eq. \\ref{contamination_estimate}, that is,\n\\begin{equation}\n{\\rm std}(\\hat \\chi) = \\frac{\\sqrt{  \\sum_s \\left[ (1 - f_s) d_s \\hat{\\chi}(1 - \\hat{\\chi}) + f_s(1 - f_s) d_s^2 \\hat{\\chi}^2  \\right] }}{\\sum_s d_s (1 - f_s) }\n\\end{equation}\n\nIt remains to describe how we determine which sites are hom alt.  The fundamental challenge here is that in cancer samples loss of heterozygosity may cause het sites to look like hom alt sites.  Our strategy is to partition the genome into allelic copy-number segments, then infer the minor allele fraction of those segments.  We segment the genome just as in GATK CNV, using a kernel segmenter with a Gaussian kernel computed on the alt fraction.  A nonlinear kernel is important because each segment is multimodal, with peaks for hom ref, alt minor het, alt major het, and hom alt.  \n\nWe then perform maximum likelihood estimation MLE on a model with learned parameters $\\mu$, the local minor allele fraction for each segment, $\\chi$, the contamination, and a constant base error rate parameter $\\epsilon$ determined by counting reads that are neither the ref nor primary alt base at biallelic SNPs as described above.  The model likelihood is\n\\begin{equation}\nP(\\{ a\\}| \\{f\\}, \\chi, \\{d\\}) =    \\prod_{{\\rm segments~}n}\\prod_{{\\rm sites~}s} \\sum_{{\\rm genotype~}g} P(g|f_s) {\\rm Binom}(a_s | d_s, (1 - \\chi) \\phi(g, \\mu_n, \\epsilon) + \\chi f_s)\n\\end{equation}\nwhere $a_s$ and $d_s$ are the alt and total read counts at site $s$, allelic CNV genotypes $g$ run over hom ref, alt minor, alt major, and hom alt with priors $P({\\rm hom~ref}) = (1-f_s)^2$, $P({\\rm alt~minor}) = P({\\rm alt~major}) = f_s(1-f_s)$, and $P({\\rm hom alt} = f^2$.  $\\phi(g, \\mu, \\epsilon)$ is the alt allele fraction of the uncontaminated sample: $\\phi({\\rm hom~ref}) = \\epsilon$, $\\phi({\\rm alt~minor}) = \\mu$, $\\phi({\\rm alt~major}) = 1 - \\mu$, $\\phi({\\rm hom~alt}) = 1 - \\epsilon$.  The binomial is the weighted average of the uncontaminated sample and sample reads drawn independently from allele frequency $f$.  This is inconsistent with a single diploid contaminant sample, or indeed with any finite number of contaminants, which is why we do not the the MLE estimate in the final output of the tool.  The model also assumes that the uncontaminated and contaminating samples have the same overall depth distribution at each site, which is inconsistent with any differences in copy-number.  We perform the MLE by brute force, alternately maximizing with respect to $\\chi$ with $\\mu$ fixed and vice versa.  In order to make the solution more robust, we exclude segments with low $\\mu$ from the maximization over $\\chi$ by taking the highest possible threshold (up to 0.5, of course) for $\\mu$ that retains at least $1/4$ of all sites.\n\nOnce we have learned the parameters of this model, we can easily infer the posterior probabilities of hom alt genotypes.  We take every site with a posterior probability greater than 0.5.  In order to make the result more reliable against CNVs, we again impose a threshold on segment minor allele fraction and apply the above formula only to hom alt sites in these segments.  This time, however, we choose the highest possible threshold such that the estimated relative error is less than 0.2.\n\nFinally, we note that the same calculation can be reversed by using alt reads in hom ref sites as the signal and replacing $f$ by $1-f$ everywhere above.  We use the estimate from hom refs as a backup when the hom alt estimate has too great an error, as can occur in the case of targeted panels with few sites.  We do not use this as our primary estimate because it is much more affected by uncertainty in the population allele frequencies and is thus susceptible to systematic bias.\n\n\\section{Proposed tumor in normal estimation tool}\n\nNote: the following notes are just a proposal for which no GATK tool yet exists.  A popular tool is DeTiN\\footnote{DeTiN: overcoming tumor-in-normal contamination, \\textit{Nature Methods} \\textbf{15}, 531 (2018)} by Amaro Taylor-Weiner and others at the Broad Institute Cancer Genome Analysis group.\n\nSimilar to the spirit of CalculateContamination, the fraction of tumor reads in the normal bam is a single number with a large amount of evidence and is probably well-estimated by simple descriptive statistics rather than a full-fledged probabilistic model.  It shouldn't be much more complicated than finding somatic variants and comparing their signal in the normal sample to that in the tumor.\n\nWe propose the following steps to obtain our input of confident somatic SNVs:\n\\begin{itemize}\n\\item Run Mutect in tumor-only mode to obtain a preliminary list of somatic SNVs.  For the sake of speed, we could implement a pileup-based mode in which we skip reassembly and equate read likelihoods with base qualities.  This would allow us to obtain variant annotations using the existing architecture of Mutect and therefore to filter calls with no new code.  It would probably make sense at this stage to filter more stringently than usual based on population allele frequencies in gnomAD.\n\\item Run FilterMutectCalls.  With default settings this eliminates the great majority of sequencing artifacts.  To eliminate even more we could increase the log odds threshold slightly, essentially requiring a slightly larger alt allele count.  Normally we don't do this because it sacrifices some sensitivity, but for our purposes here a 10 or 20 percent loss of sensitivity is perfectly acceptable as long as we are left with enough SNVs for our estimate.\n\\item Remove all SNVs that have enough read counts in the normal that we conclude they are germline variants, as opposed to tumor in normal contamination.  We could also accomplish this by using tumor-normal mode in the first step, but we would need to modify our active region determination which currently would mark a region as inactive based only on a small number of tumor-in-normal alt reads.  We would also have to turn off the normal artifact filter.\n\\end{itemize}\n\nThe above steps are all very reliable, so at this point we can assume we have a collection of confident biallelic somatic SNVs that are hom ref in the germline.  Similar to CalculateContamination, we can now estimate the number of alt reads in the normal at these sites:\n\\begin{align}\n{\\rm alt~in~normal} \\approx \\sum_{\\rm sites} ({\\rm depth~in~normal}) \\times ({\\rm alt~fraction~in~tumor}) \\times ({\\rm tumor~in~normal~fraction})\n\\end{align}\nHence we estimate\n\\begin{align}\n{\\rm tumor~in~normal~fraction} \\approx \n\\frac{\\rm total~number~of~alt~reads~in~normal~at~somatic~SNV~sites}\n{\\sum_{\\rm somatic~SNV~sites} ({\\rm depth~in~normal}) \\times ({\\rm alt~fraction~in~tumor})}\n\\end{align}\n\n\\section{Mutect filters}\n\\code{Mutect2} emits candidate variants with a set of annotations.  After that \\code{FilterMutectCalls} produces filtered calls by subjecting these variants to a series of hard filters that reject sites if some annotation is out of an allowable range.  Here are the command line arguments that control these filters, along with the annotations they relate to.\n\n\\begin{itemize}\n\\item  \\code{tumor-lod} is the minimum likelihood of an allele as determined by the somatic likelihoods model required to pass.\n\\item \\code{max-events-in-region} is the maximum allowable number of called variants co-occurring in a single assembly region.  If the number of called variants exceeds this they will all be filtered.\n\\item \\code{unique-alt-read-count} is the minimum number of unique (start position, fragment length) pairs required to make a call.  This count is a proxy for the number of unique molecules (as opposed to PCR duplicates) supporting an allele.  Normally PCR duplicates are marked and filtered by the GATK engine, but in UMI-aware calling this may not be the case, hence the need for this filter.\n\\item \\code{max-alt-allele-count} is the maximum allowable number of alt alleles at a site.  By default only biallelic variants pass the filter.\n\\item \\code{max-germline-posterior} is the maximum posterior probability, as determined by the above germline probability model, that a variant is a germline event.\n\\item \\code{normal-artifact-lod} is the maximum acceptable likelihood of an allele in the normal \\textit{by the somatic likelihoods model}.  This is different from the normal likelihood that goes into the germline model, which makes a diploid assumption.  Here we compute the normal likelihood as if it were a tumor in order to detect artifacts.  \n\\item \\code{max-strand-artifact-probability} is the posterior probability of a strand artifact, as determined by the model described above, required to apply the strand artifact filter.  This is necessary but not sufficient -- we also require the estimated max a posteriori allele fraction to be less than \\code{min-strand-artifact-allele-fraction}.  The second condition prevents filtering real variants that also have significant strand bias, i.e. a true variant that \\textit{also} has some artifactual reads.\n\\item \\code{min-median-base-quality} is the minimum median base quality of bases supporting a SNV.\n\\item \\code{min-median-mapping-quality} is the minimum median mapping quality of reads supporting an allele.\n\\item \\code{max-median-fragment-length-difference} is the maximum difference between the median fragment lengths reads supporting alt and reference alleles.  Note that fragment length is based on where paired reads are mapped, not the actual physical fragment length.\n\\item \\code{min-median-read-position} is the minimum median length of bases supporting an allele from the closest end of the read.  Indels positions are measured by the end farthest from the end of the read.\n\\item If \\code{FilterMutectCalls} is passed a \\code{contamination-table} from \\code{CalculateContamination} it will filter alleles with allele fraction less than the whole-bam contamination in the table\\footnote{This should be made more sophisticated by integrating the possibility of contamination into the germline model.}.\n\\end{itemize}\n\nAdditionally, there are two unadjustable filters. the panel of normals filter removes all alleles at a site belonging to the panel of normals, which is a vcf of blacklisted artifact sites.  It can be disabled by not passing a panel of normals to \\code{Mutect2}.  There is also an STR contraction filter which removes variants that are the deletion of a single repeat unit of an STR when this repeat unit contains more than one base.  This filter can be disabled with the argument \\code{-XA TandemRepeat} which turns off the \\code{TandemRepeat} annotation.\n\nHere for convenience is a table of \\code{Mutect2} filters with their corresponding annotations specified by the \\code{-A} argument\\footnote{Most of these are default annotations and do not need to be invoked explicitly.}, vcf keys for these annotations, and command line arguments controlling filtering thresholds.\n\n\\begin{table}[h!]\n\\centering\n \\begin{tabular}{|| c c c c ||} \n \\hline\n Filter & Annotation & Key & Argument \\\\ [0.5ex] \n \\hline\\hline\n \\code{t\\_lod} & - &\\code{TLOD} & \\code{tumor\\_lod} \\\\ \n \\code{clustered\\_events} & - & \\code{ECNT} & \\code{max-events-in-region} \\\\\n \\code{duplicate\\_evidence} & \\code{UniqueAltReadCount} & \\code{UNIQ\\_ALT\\_READ\\_COUNT} & \\code{unique-alt-read-count} \\\\\n \\code{multiallelic} & - & - & \\code{max-alt-alleles-count} \\\\\n \\code{germline\\_risk} & - & \\code{P\\_GERMLINE} & \\code{max-germline-posterior} \\\\\n \\code{artifact\\_in\\_normal} & - & \\code{N\\_ART\\_LOD} & \\code{normal-artifact-lod} \\\\\n \\code{strand\\_artifact} & \\code{StrandArtifact} & \\code{SA\\_POST\\_PROB}, \\code{SA\\_MAX\\_AF} & \\code{max-strand-artifact-probability} \\\\\n \\code{base\\_quality} & \\code{BaseQuality} & \\code{MBQ} & \\code{min-median-base-quality} \\\\\n \\code{mapping\\_quality} & \\code{MappingQuality} & \\code{MMQ} & \\code{min-median-mapping-quality} \\\\\n \\code{fragment\\_length} & \\code{FragmentLength} & \\code{MFRL} & \\code{max-median-fragment-length-difference} \\\\\n \\code{read\\_position} & \\code{ReadPosition} & \\code{MPOS} &\\code{min-median-read-position} \\\\\n \\code{panel\\_of\\_normals} & - & \\code{IN\\_PON} & \\code{panel-of-normals} \\\\\n \\code{contamination} & - & - & \\code{contamination-table} \\\\\n \\code{str\\_contraction} & \\code{TandemRepeat} & \\code{RU}, \\code{RPA} & - \\\\  [1ex] \n \\hline\n \\end{tabular}\n\\end{table}\n\n\n\\section{Read Orientation Artifact Filter}\n\nThe read orientation artifact, also known as the orientation bias artifact, arises due to a chemical change in the nucleotide during library prep that results in, for example, G base-paring with A. This kind of artifact has a clear signature (e.g. C to A SNP that occurs predominantly for the middle C in the DNA sequence CCG), and it's single-stranded in nature. Downstream, this artifact manifests as low allele fraction SNPs whose evidence for the alt allele consists almost entirely F1R2 reads or F2R1 reads. A read pair is F1R2 (forward 1st, reverse 2nd) if the sequence of bases in Read 1 maps to the forward strand of the reference (F1), and the sequence of Read 2 to the reverse strand of the reference (R2). F2R1 is defined similarly.\n\nWithout loss of generality, suppose that the reference context at locus $i$ is ACT. Let $\\vz_i$ denote the genotype at locus $i$ with the one-hot encoding $z_{ik} = 1$ iff the genotype of locus $i$ is $k$, where the possible genotypes are\n\\begin{equation*}\nz_i \\in \\{ \\text{F1R2}_A, \\text{F1R2}_G, \\text{F1R2}_T, \\text{F2R1}_A, \\text{F2R1}_G, \\text{F2R1}_T,  \\text{Hom Ref}, \\text{Germline Het}, \\text{Somatic Het}, \\text{Hom Var} \\}\n\\end{equation*}\n$z_i = \\mathrm{F1R2_A}$ denotes that at locus $i$ we have an artifact in which the evidence for alt allele A consists entirely of reads in the F1R2 orientation. The remaining artifact states are defined analogously. Let $\\vpi$ denote the prior probabilities of the $\\vz_i$ under the reference context ACT. Then we have \n\\begin{equation}\nP(\\vz_i) = \\prod_k \\pi_{k}^{z_{ik}}\n\\end{equation}\n\nThe number of alt reads at a locus depends on the genotype $z_i$. Let $n_i$ and $m_i$ denote the total depth and alt depth at locus $i$, respectively. The conditional distribution of $m_i$ is\n\\begin{equation}\nP(m_i | z_{ik} = 1) = \\mathrm{BetaBinomial}(m_i | n_i, \\alpha_k, \\beta_k)\n\\end{equation}\nwhere $\\alpha_k$ and $\\beta_k$ are fixed hyperparameters for genotype $z_k$. When the site's genotype indicates in $m_i$ alt reads we expect a heavily skewed distribution of F1R2 reads. This is captured in the conditional distribution of F1R2 alt reads. Let $c_i$ denote the number of F1R2 reads among the $m_i$ alt reads at locus $i$. Then we have\n\\begin{equation}\nP(c_i | m_i, z_{ik} = 1) = \\mathrm{BetaBinomial}( c_i | m_i, \\alpha'_k, \\beta'_k)\n\\end{equation}\nWe learn the prior artifact probabilities $\\vpi$ based on the observed values of $n_i$, $m_i$, $c_i$ for each of $N$ loci using the EM algorithm. In the E-step, we compute the posterior probabilities of $\\vz_i$ for $i = 1 ... N$. The joint probabilities of $\\vz$ factorizes over $i$, thus the posteriors over $\\vz$ are independent across loci. \n\\begin{equation}\nP(z_{ik} = 1 | m_i, c_i) \\propto P(z_{ik} = 1, m_i, c_i) = \\pi_{k} \\mathrm{BetaBinomial}(m_i | n_i, \\alpha_k, \\beta_k)  \\mathrm{BetaBinomial}( c_i | m_i, \\alpha'_k, \\beta'_k)\n\\end{equation}\nIn the M-step we maximize the expectation of the log complete-data likelihood with respect to $\\vpi$. The log complete data likelihood is given as\n\\begin{equation}\n\\ln P(\\vz, \\vm, \\vc) = \\sum_i \\sum_k z_{ik} \\big( \\ln \\pi_{k} + \\ln \\mathrm{BetaBinomial} ( m_i | n_i, \\alpha_k, \\beta_k)  + \\ln \\mathrm{BetaBinomial}( c_i | m_i, \\alpha'_k, \\beta'_k) \\big)\n\\end{equation}\nMaximizing the log likelihood under the constraint $\\sum_k \\pi_k = 1$ gives us\n\\begin{equation}\n\\pi_k = \\frac{N_k}{N}\n\\end{equation}\nwhere $N_k = \\sum_i P(z_{ik} | m_i, c_i)$ is the effective count of loci with genotype $k$. We alternate E-step and M-step until convergence. We then use the learned prior genotype probabilities to compute the posterior artifact probabilities of variants in a vcf. The filtering threshold is set such that the false discovery rate doesn't exceed a specified value, as described below.\n\n\\section{Filtering False Discovery Rate}\n\nLet $p_1 \\leq p_2 \\leq ... \\leq p_n$ denote ordered posterior probabilities that given variants are sequencing artifacts. Suppose we filter variants for which $p_i > p_j$ for some index $j$; that is, we keep the first $j$ variants as \\code{PASS} and filter the rest. Then the expected number of false positives is\n\\begin{equation}\n\\mathbb{E} [ \\mathrm{FP}(j)] = \\sum_{i = 1}^{j} p_i\n\\end{equation}\nAnd the expected false positive rate is\n\\begin{equation} \\label{eq:fpr}\n\\mathbb{E} [ \\mathrm{FPR}(j)]= \\frac{1}{j} {\\sum_{i = 1}^{j} p_i}\n\\end{equation}\nWe choose the threshold so as to maximize the number of variants to let through while keeping the false positive rate below $\\delta \\in [0, 1]$. In other words, we solve for\n\\begin{equation}\nj^* = \\mathrm{argmax}_j \\mathbb{E} [ \\mathrm{FPR}(j)]= \\frac{1}{j} \\sum_{i = 1}^{j} p_i\n\\end{equation}\nunder the constraint $ \\mathbb{E} [ \\mathrm{FPR}(j)] < \\delta$. We can prove by induction that $\\mathbb{E} [ \\mathrm{FPR}(j)]$ is monotonically increasing in $j$. Thus we test $\\mathbb{E} [ \\mathrm{FPR}(j)]$ for $j = 1, \\cdots, k$, where $k$ is the smallest integer such that $\\mathbb{E} [ \\rm{FPR}(k)] > \\delta$, and set $j^* = k-1$. \n\n\\end{document}", "meta": {"hexsha": "6446fb389a5bf4ee05f0d41a62118af92d2e0f34", "size": 47528, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/mutect/mutect.tex", "max_stars_repo_name": "Unip0rn/gatk", "max_stars_repo_head_hexsha": "10aa8c77e056493b9787190230bef076de98a890", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/mutect/mutect.tex", "max_issues_repo_name": "Unip0rn/gatk", "max_issues_repo_head_hexsha": "10aa8c77e056493b9787190230bef076de98a890", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/mutect/mutect.tex", "max_forks_repo_name": "Unip0rn/gatk", "max_forks_repo_head_hexsha": "10aa8c77e056493b9787190230bef076de98a890", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 97.5934291581, "max_line_length": 1406, "alphanum_fraction": 0.7228581047, "num_tokens": 14204, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4045386620460079}}
{"text": "\\section{Putting Our Homemade Climate Model Through Its Paces}\nBig stream this stream as we got some working code! Always great when stuff works. This stream, we tackled the radiation problem, added axial tilt to the planet, fixed vertical motion (but not\nadvection), added stratospheric heating and some other code clean up stuff. This means that the big rework is getting closer and closer. How exciting!\n%TESTSSSS WE GOT WORKING CODE! HELLO WORLD!\n\n\\subsection{Fixing Up the Code}\nFirst thing to mention is that vertical advection is still broken. Why? Because the gradient in the $z$ direction is broken. This is due to finite differencing on an exponential function. The way\nwe calculate the differenc from one layer to the other is by differencing them (subtracting) which is always finite. Therefore we always get some inaccuracies. Usually that is fine, but with an \nexponential function the differences, you guessed it, become exponentially wrong. As such, the function would eventually be so far off that the model would blow up. So we need to fix it. To \nprevent a blow up, we have disabled the call to the gradient $z$ funciton in \\autoref{alg:divergence layer}. This ensures that the horizontal bits still work, but the vertical stuff does not.\nAs always, we will try to fix this in a future stream. \n\nWe also fixed up the radiation scheme, as shown in \\autoref{alg:optical depth}. Basically we had the definition of $U[k + 1] = \\text{something something} U[k + 1]$. This means that the definition\nwas relying on itself, which is obviously impossible and wrong. So we changed it to it's current form and it is fixed, hooray!\n\nVertical motion has also been fixed, as shown in \\autoref{alg:velocity}. Due to some error in the representation of the vertical motion it did not work. So we changed from that representation to \nanother. Now the vertical velocity is proportional to the rate of change of the pressure which does work like it should.\n\n\\subsection{Tilting the Planet}\nIn order to model a planet that has seasons, like Earth, we need to tilt the planet. This has as effect that the sun is not always directly above the equator but is above a certain band around\nthe equator as the year moves on. This means that some hemispheres receive more/less sun based on what part of the year it is. Which corresponds to the various seasons we have on Earth. But in\norder to do that, we have to change the \\texttt{solar} function. The new version as shown in \\autoref{alg:solar tilt} will replace \\autoref{alg:solar}. Here $\\alpha$ is the tilt in degrees.\n\n\\begin{algorithm}\n    \\SetKwInput{Input}{Input}\n    \\SetKwInOut{Output}{Output}\n    \\Input{insolation $ins$, latitude $lat$, longitude $lon$, time $t$, time in a day $d$}\n    \\Output{Amount of energy $S$ that hits the planet surface at the given latitude, longitude and time combination.}\n    $sun\\_lon \\leftarrow -t \\text{ mod } d$ \\;\n    $sun\\_lon \\leftarrow sun\\_lon \\cdot \\frac{360}{d}$ \\;\n    $sun\\_lat \\leftarrow \\alpha\\cos(\\frac{2t\\pi}{year})$ \\;\n    $S \\leftarrow insolation\\cos(\\frac{\\pi(lat - sun\\_lat)}{180})$ \\;\n\n    \\uIf{$S < 0$}{\n        \\Return{$0$} \\;\n    } \\uElse {\n        $lon\\_diff \\leftarrow lon - sun\\_lon$ \\;\n        $S \\leftarrow S\\cos(\\frac{lon\\_diff\\pi}{180})$ \\;\n\n        \\uIf{$S < 0$}{\n            \\uIf{$lat + sun\\_lat > 90$ or $lat + sun\\_lat < -90$}{\n                \\Return{$insolation\\cos(\\frac{\\pi(lat + sun\\_lat)}{180})\\cos(\\frac{lon\\_diff\\pi}{180})$} \\;\n            } \\uElse {\n                \\Return{$0$} \\;\n            }\n        } \\uElse {\n            \\Return{$S$} \\;\n        }\n    }\n    \\caption{Calculating the energy from the sun (or similar star) that reaches a part of the planet surface at a given latitude and time}\n    \\label{alg:solar tilt}\n\\end{algorithm}\n\nWhat the code in \\autoref{alg:solar tilt} does boils down to calculating the latitude and longitude of the sun and checking whether the planet receives any energy. If not return $0$ immediately.\nIf so we check if the difference between the sun's longitude and the planet's longitude and calculate how much energy would hit the planet given that the sun is not straight above the equator. \nWe do this by multiplying the energy it would receive from the sun if it were above the equator $S$ by the cosine of the difference in longitudes, which represents the tilt. Then we check again \nif the planet is receiving energy, if not we check if it happens around the poles. We do this because due to the tilt it can be the case that at certain points in the year the pole is in constant\nsunlight, i.e. the sun does not go down. This creates a sort of overshoot which needs to be accounted for. If it does this then we add the latitudes of the sun and the planet together and use\nthat to calculate the energy that would hit that spot. If it is not the case that we are around the poles and we do not receive energy, then we return $0$. If it happens to be that we do receive \nenergy (so no negative values) then we return $S$.\n\n\\subsection{Adding In Some Ozone (Or Something Else That Approximates It)}\nAdding in ozone in the stratosphere is hella complicated, so we leave that as an exercise to the reader as in true academic fashion. Just joking, if you want you can work on implementing ozone \nhowever we opt not to because it is quite complicated. Instead we approximate it, which is decent enough for our purpose. We need to do it in \\autoref{alg:optical depth} as we need to adjust the\n$Q$. We add in a check to see if we are currently calculating the radiation in the stratosphere. If so we add some radiation extra to replicate the effect of ozone. As can be seen in \n\\autoref{alg:ozone}, where we only focus on the $Q$ part of \\autoref{alg:optical depth}, we add in some extra radiation based on how high the current layer calculation is, which scales with the\nheight. \n\n\\begin{algorithm}\n    \\For{$level \\in [0, nlevels]$}{\n        $Q[level] \\leftarrow - \\frac{S_z(U - D, 0, 0, level)}{10^3 \\cdot densityProfile[level]}$ \\;\n        \\uIf{$heights[level] > 20 \\cdot 10^3$}{\n            $Q[level] \\leftarrow Q[level] + \\texttt{solar}(5, lat, lon, t) \\frac{24 \\cdot 60 \\cdot 60(\\frac{heights[level] - 20 \\cdot 10^3}{10^3})^2}{30^2}$ \\;\n        }\n    }\n    \\caption{Replicating the effect of ozone}\n    \\label{alg:ozone}\n\\end{algorithm}\n\nIt is at this point that we reached the state that CLAuDE is in a testable state. This means that we have the model working in such a way that we can do some simple experiments like altering how\nlong a day is, what would happen if the sun would send out more energy (which usually means that it is bigger) or what would happen if you tidally lock a planet (stop it rotating completely). ", "meta": {"hexsha": "293f3c638c7882e14e49d30b88f67392d982be98", "size": 6692, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex-docs/streams/Stream10.tex", "max_stars_repo_name": "balintf/claude", "max_stars_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex-docs/streams/Stream10.tex", "max_issues_repo_name": "balintf/claude", "max_issues_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex-docs/streams/Stream10.tex", "max_forks_repo_name": "balintf/claude", "max_forks_repo_head_hexsha": "a3ebf0605ca26c4aadd0273f6b70813bdf931c9c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 82.6172839506, "max_line_length": 195, "alphanum_fraction": 0.7278840406, "num_tokens": 1726, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.40453864673820067}}
{"text": "%\\documentclass[12pt]{article}\n\\documentclass[12pt,landscape]{article}\n\n\n\\include{preamble}\n\n\\newcommand{\\instr}{\\small Your answer will consist of a string (e.g. \\texttt{aebgd}) where the order of the letters does not matter nor does upper / lowercase. \\normalsize}\n\n\\title{Math 369 / 650 Fall \\the\\year{} \\\\ Midterm Examination One}\n\\author{Professor Adam Kapelner}\n\n\\date{Wednesday, September 30, \\the\\year{}}\n\n\\begin{document}\n\\maketitle\n\n%\\noindent Full Name \\line(1,0){410}\n\n\\thispagestyle{empty}\n\n\\section*{Code of Academic Integrity}\n\n\\footnotesize\nSince the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.\n\nActivities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:\n\n\\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using an unauthorized cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.\n\\\\\n\n\\noindent By taking this exam, you acknowledge and agree to uphold this Code of Academic Integrity. \\\\\n\n%\\begin{center}\n%\\line(1,0){250} ~~~ \\line(1,0){100}\\\\\n%~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date\n%\\end{center}\n\n\\normalsize\n\n\\section*{Instructions}\n\nThis exam is 75 minutes (variable time per question) and closed-book. You are allowed \\textbf{one} page (front and back) of a \\qu{cheat sheet}, blank scrap paper and a graphing calculator. Please read the questions carefully. No food is allowed, only drinks. %If the question reads \\qu{compute,} this means the solution will be a number otherwise you can leave the answer in \\textit{any} widely accepted mathematical notation which could be resolved to an exact or approximate number with the use of a computer. I advise you to skip problems marked \\qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \\fbox{Box} in your final answers. Good luck!\n\n\\pagebreak\n\n\n\\problem\\timedsection{8} The following are questions about testing and power.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{9} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n%\\item Type I errors are only possible if $H_0$ is true\n%\\item Type I errors are only possible if $H_a$ is true\n\\item Type II errors are only possible if $H_0$ is true\n\\item Type II errors are only possible if $H_a$ is true\n\\item If you set a higher $\\alpha$, the probability of making a Type II error increases (if $H_a$ is true)\n\\item If you set a higher $\\alpha$, the probability of making a Type II error decreases (if $H_a$ is true)\n\\item As $n$ increases, the probability of making a Type I error increases (if $H_0$ is true)\n\\item As $n$ increases, the probability of making a Type II error increases (if $H_a$ is true)\n%\\item If the standard deviation of the sampling distribution increases, the power increases\n%\\item If the standard deviation of the sampling distribution increases, the power decreases\n\\item A lower $\\alpha$ setting makes the p-value come out larger.\n\\item A lower $\\alpha$ setting makes null hypothesis rejections more \\qu{statistically significant}. \n\n\n\\item Imagine you are doing a two-tailed two-sample (or two-proportion) test. Let \\qu{effect size} denote $\\theta_1 - \\theta_2$. If you are trying to prove a large effect size, the power is higher than if you trying to prove a small effect size.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\\problem\\timedsection{5} The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the company known to be the best national lab rat supplier.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{7} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\\item The 30 rats is likely a representative sample of all rats if the sampling was done by the supplier via simple random sampling.\n\\item The 30 rats is likely a representative sample of all brown rats if the sampling was done by the supplier via simple random sampling.\n\\item The 30 rats is likely a representative sample of all Sprague-Dawley rats if the sampling was done by the supplier via simple random sampling.\n%\\item The 30 rats is definitely representative of all Sprague-Dawley rats even if the sampling was done by the supplier \\emph{without} simple random sampling.\n\\item The 30 rats could be representative of all Sprague-Dawley rats even if the sampling was done by the supplier \\emph{without} simple random sampling.\n\\item The population size is $N=30$.\n\\item The population size is infinite.\n\\item There is no definite population, but you assume a population and consider this population to be infinite if you invoke the population sampling assumption.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{5} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier.} Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem).\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{10} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\\item The data collected is commonly denoted $x_1, x_2, \\ldots, x_{30}$.\n\\item The data collected is commonly denoted $X_1, X_2, \\ldots, X_{30}$.\n\\item The DGP is most likely $\\iid \\normnot{\\theta}{\\sigsq}$ and $\\theta$ measures how long the rats live.\n\\item The DGP is most likely $\\iid \\normnot{\\theta}{\\sigsq}$ and $\\theta$ measures the probability of heart problems.\n\\item The DGP is most likely $\\iid \\bernoulli{\\theta}$ and $\\theta$ is mean life length measured in years.\n\\item The DGP is most likely $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one lifetime heart problem.\n\\item The DGP is most likely hypergeometric and thus the rat measurements are dependent.\n\\item The DGP is most likely $\\iid$ with mean 10mg.\n\\item The DGP is most likely $\\iid$ with mean 2yr.\n\\item The researcher's intent is most likely to use the data to make inference about population or DGP parameter(s).\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\n\\problem\\timedsection{4} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem).} Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{6} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\\item $\\theta$ is a parameter of the DGP.\n\\item $\\theta$ is a realization from a rv.\n\\item $\\theta$ is a point estimate.\n\\item The value of $\\theta$ is known before the study begins and this study will only confirm it.\n\\item The value of $\\theta$ is unknown before the study begins.\n\\item The value of $\\theta$ is unknown before the study begins but will be known after the study is over as that is the purpose of this study.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{6} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem).} Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{9} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\\item We can use the data to compute a point estimate $\\thetahathat$ which is the best numeric guess of the value of $\\theta$.\n\\item The point estimate of $\\theta$ is a realization from the rv denoted $X$.\n\\item The point estimate of $\\theta$ is a realization from the rv denoted $\\thetahat$.\n\\item The point estimate of $\\theta$ is a realization from the sampling distribution.\n\\item To compute the point estimate of $\\theta$, you need to presuppose an $H_a$.\n\\item A reasonable point estimate of $\\theta$ is the proportion of $x_i$'s that are equal to one.\n\\item A reasonable point estimate of $\\theta$ is the proportion of $x_i$'s that are equal to zero.\n\\item A reasonable point estimate of $\\theta$ is $\\xbar$.\n\\item A reasonable point estimate of $\\theta$ is $\\hat{\\sigma}^2$.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{11} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem). Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$.} The point estimate we will use for $\\theta$ is $\\xbar$ and the estimator is $\\Xbar$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{12} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\\item The estimator is biased.\n\\item The estimator is asymptotically unbiased.\n\\item The estimator is unbiased.\n\\item The estimator has an MSE of zero for some values of $\\theta \\in (0, 1)$.\n\\item The largest MSE of the estimator is $1/(4n)$.\n\\item Consider $\\ell(\\thetahathat, \\theta) = 0$ if $\\thetahathat = \\theta$ and 1 otherwise. This is a legal loss function.\n\\item The loss function in (f) is a reasonable loss function that you can use to compare other estimators to $\\Xbar$.\n\\item The risk under the loss function in (f) is equal to the variance.\n\\item Consider $\\ell(\\thetahathat, \\theta) = |\\thetahathat - \\theta|$. This is a legal loss function.\n\\item The loss function in (i) is a reasonable loss function that you can use to compare other estimators to $\\Xbar$.\n\\item The risk under the loss function in (i) is equal to the variance.\n\\item The estimator $\\thetahat = \\half\\parens{\\max{x_1, x_2, \\ldots, x_{30}} + \\min{x_1, x_2, \\ldots, x_{30}}}$ will have similar MSE to $\\Xbar$.\n%\\item The sampling distribution is normally distributed.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{4} Same as before. \\ingray{\\footnotesize The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem). \\normalsize Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$. The point estimate we will use for $\\theta$ is $\\xbar$ and the estimator is $\\Xbar$.} We wish to prove that the incidence of heart problems in the rats given magnesium \\emph{is less than} 48\\% (the national average for heart problems in the American adult population).\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{11} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\n\\item $H_a: \\theta < 0.48$\n\\item $H_a: \\theta > 0.48$\n\\item $H_a: \\theta \\neq 0.48$\n\\item $H_0: \\theta \\leq 0.48$\n\\item $H_0: \\theta \\geq 0.48$\n\\item $H_0: \\theta = 0.48$\n\\item $\\alpha = 5\\%$ is the scientific community's standard.\n\\item $\\alpha = 2.5\\%$ in the left tail is the scientific community's standard.\n\\item A target power of $1$ is desirable and achievable.\n\\item A target power of $1 - \\alpha$ is desirable and achievable.\n\\item A target power of $\\alpha$ is desirable and achievable.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{7} Same as before. \\ingray{\\footnotesize The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem).  Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$. The point estimate we will use for $\\theta$ is $\\xbar$ and the estimator is $\\Xbar$.\\normalsize We wish to prove that the incidence of heart problems in the rats given magnesium \\emph{is less than} 48\\%, the national average for heart problems in the American adult population.} Thus $H_a: \\theta < 0.48$ and $H_0: \\theta \\geq 0.48$. Upon the study's completion, the researchers compute $\\thetahathat = 9/30 = 0.3$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{7} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n\n\\item The binomial test is an exact test of the hypothesis of interest. \\\\\n\nLet $B \\sim \\binomial{30}{48\\%}$ with PMF $p_B(x)$ and CDF $F_B(x)$. The following is an abridged table of the PMF and CDF. The values are rounded to the nearest two digits but should be treated as exact.\n\n%xs = 7:22\n%pacman::p_load(xtable)\n%xtable(\n%rbind(\n%  xs,\n%  round(dbinom(xs, 30, .48),2),\n%  round(pbinom(xs, 30, .48),2)\n%))\n\\begin{table}[ht]\n\\centering\n\\begin{tabular}{c|rrrrrrrrrrrrrrrr}\n$x$ & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 \\\\ \\hline\n$p_B(x)$ & 0 & 0.01 & 0.02 & 0.04 & 0.07 & 0.10 & 0.13 & 0.14 & 0.14 & 0.12 & 0.09 & 0.06 & 0.04 & 0.02 & 0.01 & 0 \\\\ \n$F_B(x)$ & 0 & 0.01 & 0.04 & 0.08 & 0.14 & 0.24 & 0.37 & 0.52 & 0.66 & 0.78 & 0.87 & 0.93 & 0.97 & 0.99 & 1 & 1 \\\\ \n   \\hline\n\\end{tabular}\n\\end{table}\n\n\\item The scientific standard of $\\alpha = 5\\%$ is attainable in the binomial test. \n\\item A retainment region of $\\braces{0, 1, \\ldots, 9}$ is the the region that most closely provides the scientific standard of $\\alpha = 5\\%$.\n\\item A rejection region of $\\braces{0, 1, \\ldots, 9}$ is the the region that most closely provides the scientific standard of $\\alpha = 5\\%$.\n\\item At $\\alpha = 0.04$, the test rejects the null hypothesis.\n\\item At $\\alpha = 0.04$, the test retains the null hypothesis.\n\\item Fisher's p value is 1\\%.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{5} Same as before. \\ingray{\\footnotesize The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The data is whether or not each rat had heart problems during their life (i.e. each rat either \\emph{did have} a heart problem or \\emph{did not have} a heart problem).  Thus the DGP is $\\iid \\bernoulli{\\theta}$ and $\\theta$ is the probability of at least one heart problem and we denote the data $x_1, x_2, \\ldots, x_{30}$. The point estimate we will use for $\\theta$ is $\\xbar$ and the estimator is $\\Xbar$.~\\normalsize We wish to prove that the incidence of heart problems in the rats given magnesium \\emph{is less than} 48\\%, the national average for heart problems in the American adult population.} Thus $H_a: \\theta < 0.48$ and $H_0: \\theta \\geq 0.48$. Upon the study's completion, the researchers compute $\\thetahathat = 9/30 = 0.3$. We wish to test by using the one-proportion z test at $\\alpha = 1\\%$. Note that $\\Phi(-2.33) = 1\\%$.\n\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{8} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\n%\\item The one-proportion z test is an approximate test.\n\\item  $\\thetahat~|~H_0 \\approxdist \\normnot{0.48}{0.48 (1 - 0.48)}$\n\\item  $\\thetahat~|~H_0 \\approxdist \\normnot{0.48}{0.48 (1 - 0.48) / 30}$\n\\item  $30(\\thetahat~|~H_0 - 0.48) / (0.48 (1 - 0.48)) \\approxdist \\stdnormnot$\n\\item  $\\sqrt{30}(\\thetahat~|~H_0 - 0.48) / \\sqrt{0.48 (1 - 0.48)} \\approxdist \\stdnormnot$\n\\item The retainment region is $\\thetahathat \\geq .27$  (to the nearest two digits)\n\\item The retainment region is $z \\geq -2.33$ on the standardized scale\n\\item The test rejects the null hypothesis.\n\\item The test retains the null hypothesis.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{5} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection.} The researchers also were interested in mean life expectancy of the magnesium-supplemented rats. Regardless of what $\\theta$ was before, we now denote mean life expectancy as $\\theta$.  The lifespans in years of each rat were 1.09, 2.48, 3.08, 2.57, 1.04, 0.87, 4.18, 2.23, 3.22, 1.33, 2.49, 1.69, 3.18, 1.39, 2.52, 4.8, 2.44, 1.47, 2.64, 3.96, 3.08, 2.71, 2.8, 3.4, 3.86, 2.28, 3.65, 3.28, 1.54, 1.94. Here are two statistics: $\\xbar = 2.57$ and $s = 1.00$. We wish to test if these rats lived longer than the average life expectancy of 2 years. \n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{9} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\\item $H_a: \\theta < 0.48$\n\\item $H_a: \\theta > 2$\n\\item $H_a: \\theta \\neq 2$\n%\\item $H_0: \\theta \\leq 2$\n%\\item $H_0: \\theta \\geq 2$\n%\\item $H_0: \\theta = 2$\n\\item We can use the one sample z test to run this test without any assumptions.\n\\item We can use the one sample z test to run this test by assuming an $\\iid \\normnot{\\theta}{1^2}$ DGP.\n\\item We can use the one sample z test to run this test by assuming an $ \\iid \\normnot{\\theta}{\\sigsq}$ DGP if $\\sigsq$ were given to you.\n\\item We can use the one sample z test to run this test by assuming an $ \\iid \\normnot{\\theta}{\\sigsq}$ DGP where $\\sigsq$ is an unknown constant.\n\\item We can use the one sample t test to run this test by assuming an $ \\iid \\normnot{\\theta}{1^2}$ DGP.\n\\item We can use the one sample t test to run this test by assuming an $ \\iid \\normnot{\\theta}{\\sigsq}$ DGP if $\\sigsq$ were given to you.\n\\item We can use the one sample t test to run this test by assuming an $\\iid \\normnot{\\theta}{\\sigsq}$ DGP where $\\sigsq$ is an unknown constant.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\\problem\\timedsection{5} Same as before. \\ingray{The rats used in most laboratories are called Sprague-Dawley rats (the \\qu{lab rat}), a special breed of brown rat because they are calmer and easier to handle. 30 Sprague-Dawley rats are purchased from the rat supplier. Animal studies are frequently done on rats since rats are considered a model for humans. Consider a nutritional study that tests the effect of magnesium supplementation on cardiovascular disease. In this study, the $n=30$ rats are given 10mg of magnesium daily. Since the lifespan of rats is on average 2 years, this multi-year study waits until all the rats die until they do the data collection. The researchers also were interested in mean life expectancy of the magnesium-supplemented rats. Regardless of what $\\theta$ was before, we now denote mean life expectancy as $\\theta$. } The lifespans in years of each rat were 1.09, 2.48, 3.08, 2.57, 1.04, 0.87, 4.18, 2.23, 3.22, 1.33, 2.49, 1.69, 3.18, 1.39, 2.52, 4.8, 2.44, 1.47, 2.64, 3.96, 3.08, 2.71, 2.8, 3.4, 3.86, 2.28, 3.65, 3.28, 1.54, 1.94. Here are two statistics: $\\xbar = 2.57$ and $s = 1.00$. We wish to test if these rats lived longer than the average life expectancy of 2 years. Hence $H_a: \\theta > 2$ and $H_0: \\theta \\leq 2$. We will use the one-sample t-test and use $\\alpha = 1\\%$. Note that $F_{T_{29}}(-2.46) = 1\\%$.\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{6} \n\n\\begin{enumerate}[(a)]\n%\\setcounter{enumi}{3}\\item $H_a: \\theta < 0.48$\n\\item The rejection region is $\\thetahathat > 4.46$ (to the nearest two digits)\n\\item The rejection region is $\\thetahathat > 5.03$ (to the nearest two digits)\n\\item The rejection region is $\\thetahathat > 2.45$ (to the nearest two digits)\n\\item The rejection region is $\\thetahathat > 3.02$ (to the nearest two digits)\n%\\item You can conclude from this test that Sprague-Dawley rats given daily supplements of 10mg of magnesium live longer than the average rat.\n\\item You can conclude from this test that the power in this test is very high (i.e. near 1).\n\\item The one-sample t-test is an approximate test.\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n%xbar1 = 2.57\n%s1 = 1\n%n1 = 30\n%n2 = 6\n%\n%set.seed(1984)\n%x = rnorm(n2, 2.7, 1)\n%paste0(round(x, 2), collapse = \", \")\n%\n%xbar2 = mean(x)\n%s2 = sd(x)\n%\n%\n%\n%ssqpooled = ((n1-1) * s1^2 + (n2-1) * s2^2) / (n1+n2-2)\n%naive_pooled_ssq = s1^2 / n1 + s2^2 / n2\n%\n%round(ssqpooled, 2)\n%round(sqrt(ssqpooled), 2)\n%n_factor = sqrt(1/n1+1/n2)\n%round(sqrt(ssqpooled) * n_factor, 2) #*************************************\n%round(sqrt(ssqpooled) * n_factor^2, 2)\n%round(naive_pooled_ssq, 2)\n%round(sqrt(naive_pooled_ssq), 2)\n%round(sqrt(naive_pooled_ssq) * n_factor, 2)\n%\n%#now if they used just sigma = 1\n%round(sqrt(1) * n_factor, 2)\n%\n%#satterthwaite df\n%sdf = naive_pooled_ssq^2 / (s1^4 / (n1^2 * (n1 - 1)) + s2^4 / (n2^2 * (n2 - 1)))\n%sdf\n%n1+n2-2\n%qt(.01, n1+n2-2)\n%qt(.01, sdf)\n\n\\problem\\timedsection{10} Same as before. [But no space to put the old text] Researchers repeated this study with a higher dose of magnesium on 6 rats. The lifespan of these \\qu{higher} dose rats where 3.11, 2.38, 3.34, 0.85, 3.65, 3.89. Here are their statistics: $\\xbar = 2.87$ and $s = 1.11$. The statistics for the previous sample of rats (who received the 10mg dose which we now called the \\qu{lower} dose) was $n=30$, $\\xbar = 2.57$ and $s = 1.00$. We want to test if there's any difference in rat lifespan between the two doses. We will assume the same DGP (iid normal) for the higher dose group (but with a different mean than the lower dose group). We will also assume the same variance for both groups. Note that $F_{T_{34}}(-2.44) = 1\\%$ and $F_{T_{6.70}}(-3.04) = 1\\%$.\n\\vspace{-0.2cm}\\benum\\truefalsesubquestionwithpoints{11} \n\n\\begin{enumerate}[(a)]\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 1.04 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 1.02 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 0.46 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 0.20 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 0.24 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 0.49 (to the nearest two digits)\n\\item The standard error of the sampling distribution of $\\thetahat_{\\text{higher}} - \\thetahat_{\\text{lower}}$ is 0.22 (to the nearest two digits)\n\n\\item You were given sufficient information to compute an exact rejection region\n\\item You were given sufficient information to compute a retainment region at $\\alpha = 1\\%$\n\\item You were given sufficient information to compute a retainment region at $\\alpha = 2\\%$\n\\item You were given sufficient information to compute a retainment region at $\\alpha = 5\\%$\n\\end{enumerate}\n\\eenum\\instr\\pagebreak\n\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\end{document}", "meta": {"hexsha": "8eea92fb21c45bec949b22b73789a7c81d2e7aa1", "size": 28431, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exams/midterm1/midterm1.tex", "max_stars_repo_name": "kapelner/QC_Math_369_Fall_2020", "max_stars_repo_head_hexsha": "1ff69eb22cd004dcfb095c99b0673d152aaba117", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-08-25T01:50:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-16T01:21:15.000Z", "max_issues_repo_path": "exams/midterm1/midterm1.tex", "max_issues_repo_name": "kapelner/QC_Math_369_Fall_2020", "max_issues_repo_head_hexsha": "1ff69eb22cd004dcfb095c99b0673d152aaba117", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exams/midterm1/midterm1.tex", "max_forks_repo_name": "kapelner/QC_Math_369_Fall_2020", "max_forks_repo_head_hexsha": "1ff69eb22cd004dcfb095c99b0673d152aaba117", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-08-30T04:15:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-27T02:37:09.000Z", "avg_line_length": 77.6803278689, "max_line_length": 1523, "alphanum_fraction": 0.7328268439, "num_tokens": 8187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.4045274931106847}}
{"text": "\\chapter{Transport domain analysis}\n\nIn this chapter, we will analyze two variants of the Transport domain: sequential and temporal. To do this, we will describe the datasets\nused for devising experiments and discuss the properties of Transport\nthat will help us in developing better quality planners.\n\n\\section{Problem complexity}\n\nWhen domain-independent planners solve a sequential Transport problem,\nthey face a harder task than planners that have access to domain knowledge ahead of time.\nFor domain-independent planners, deciding whether a plan of a given length exists\n(the \\textsc{Plan-Length} decision problem) is\na NEXPTIME-complete task.\nDeciding if a plan exists at all (the \\textsc{Plan-Existence} decision problem)\nis an EXPSPACE-complete task \\citep[Table~3.2]{Ghallab2004}.\n\nThat does not mean domain knowledge makes Transport easy, as is evident from\nthe very thorough analysis by \\citet{Helmert2001, Helmert2001a}.\nWe will categorize our problems using Helmert's notation to\nbe able to apply their results to our domain.\nHelmert's \\textsc{Transport} task is a 9-tuple $(V, E, M, P, fuel_0, l_0, l_G, cap, road),$\nwhere:\n\\begin{itemize}\n\\item $(V, E)$ is the road graph;\n\\item $M$ is a finite set of vehicles (mobiles);\n\\item $P$ is a finite set of packages (portables);\n\\item $fuel_0 : V \\to \\N_0$ is the fuel function;\n\\item $l_0: (M \\cup P) \\to V$ is the initial location function;\n\\item $l_G: P \\to V$ is the goal location function;\n\\item $cap: M \\to \\N$ is the capacity function; and\n\\item $road: M \\to 2^E$ is the movement constraints function.\n\\end{itemize}\n$V$, $M$, and $P$ are pairwise disjoint.\nNo Transport domain variants assume movement constraints, therefore, $road$ is a constant\nfunction $\\forall m \\in M : road(m) = E$.\n\nA simplified notation is also introduced in \\citet{Helmert2001a} for special cases of \\textsc{Transport} tasks.\nFor $i,j \\in \\{1, \\infty, *\\},$ $k \\in \\{1, +, *\\}$ a $\\textsc{Transport}_{i,j,k}$ task is defined as a\ngeneral \\textsc{Transport} task (defined above) that satisfies:\n\\begin{itemize}\n\\item if $i=1$, then $\\forall m \\in M : cap(m) = 1$ (vehicles can only carry one package);\n\\item if $i=\\infty$, then $\\forall m \\in M : cap(m) = |P|$ (vehicles have unlimited capacity);\n\\item if $j=1$, then $\\forall v \\in V : fuel_0(v) = 1$ (one fuel unit per location);\n\\item if $j=\\infty$, then $\\forall v \\in V : fuel_0(v) = \\infty$ (unlimited fuel per location);\n\\item if $k=+$, then $\\forall m \\in M : road(m) = E$ (no movement restrictions); and\n\\item if $k=1$, then $M = \\{m\\} \\And road(m) = E$ (single vehicle, no restrictions).\n\\end{itemize}\nThe $*$ value for $i$, $j$ or $k$ signifies no restriction on that property.\nNote that\n\\textsc{Transport} refers to the notation from \\citet{Helmert2001a}, while Transport refers to our studied domain.\n\nUsing this notation, the sequential Transport domain could be thought of as a $\\textsc{Transport}_{c,\\infty,+}$ task, where $c \\in \\N$\n(equivalent to $\\textsc{Transport}_{1,\\infty,+}$).\nSimilarly, the temporal variant represents a $\\textsc{Transport}_{c,f,+}$ task, for $c, f \\in \\N$\n(equivalent to $\\textsc{Transport}_{1,1,+}$).\n\nFor sequential and temporal Transport without fuel, the \\textsc{Plan-Existence} problem\nreduces to verifying reachability of each package by at least one vehicle\nand the reachability of target locations from the starting locations of all packages,\nwhich we can do in polynomial time, as noted in \\citet[Theorem 8]{Helmert2001}.\nWith fuel, there is no straightforward way of determining\nif a plan exists and this problem is NP-complete, which is proven in \\citet[Theorem 9 and 10]{Helmert2001}.\n\nEven though fuel constraints are modeled differently than in Transport (constraints per location versus per vehicle), the proof of \nNP-completeness of \\textsc{Plan-Existence} for $\\textsc{Transport}_{\\infty,1,1}$\npresent in \\citet[Theorem~3.9]{Helmert2001a}\ncan be trivially edited to prove the NP-completeness\nof \\textsc{Plan-Existence} for temporal Transport.\nInstead of adding fuel conditions\nto the entrance and exit nodes of a location,\nwe simply add it to edge between them. The rest of the proof holds as was presented originally.\n\nSimilarly, the \\textsc{Plan-Length} problem is NP-complete for all mentioned variants of Transport\n\\citep[Section~3.6]{Helmert2001a}.\nThe fact that all the mentioned proofs work for temporal variants is explained in \\citet[Section~3.5]{Helmert2001a}.\nAll of these results make clear that looking for an explicit planning algorithm is infeasible,\ndespite the advantage we gain by only focusing on one planning domain.\n\n\n\n\n\n\n\n\n\n\n\n\n\\section{Domain information}\\label{domain-info}\n\nThere are several interesting properties and invariants that hold in both sequential and temporal Transport, which might prove useful for designing planners:\n\\begin{enumerate}\n\\item \\textbf{Do not pick up delivered packages}: The simplest and trivially correct decision is to never touch packages that are already at their destinations, since there is nothing\nwe can do using those packages that would result in a plan with a lower total cost.\n\n\\item \\textbf{Drop when at the destination}: Likewise, it is\nalways correct for a vehicle containing a package with a destination equal\nto the vehicle's location to do a \\drop{} action immediately.\n\n\\item \\textbf{Do not drop and pick up}: It never makes sense to plan a \\drop{} and \\pickup{}\naction of\nthe same package by the same vehicle in succession. We will only get to the same state\nby using a longer plan. This rule also applies if an action of a different vehicle\ngets between the two successive actions, even if it does an action with the\ndropped package.\nIt is important to note that this is a symmetric property: picking up\nand then dropping equally results in a worse plan.\n\\begin{enumerate}\n\\item \\textbf{Do not drop a package where we picked it up}: A generalization\nof the previous rule is that vehicles should never drop a package\nat the location they last picked it up, independent of the actions they took\nbetween the relevant \\pickup{} and \\drop{}. This rule is also symmetric.\n\n\\item \\textbf{Never drop after picking up at a location}:\nWhile the order of successive \\pickup{} and \\drop{} actions does not\ninfluence the optimality of a plan, it makes the search space smaller and the implementation of these rules simpler,\nwithout loss of generality.\n\\end{enumerate}\n\n\\item \\textbf{Do not drive suboptimally}: If a vehicle does a series of\n\\drive{} actions from location $A$ to $B$ without ``touching'' packages\nor refueling at any of the locations it visits,\nit has to follow the shortest possible path from $A$ to $B$. If it does not,\nthe induced plan can be made less costly or shorter by swapping the actual \\drive{} actions\nfor precalculated optimal \\drive{} actions along the shortest path.\nDo note, that it is not important for the application of this rule whether actions are in direct succession (in a sequential plan) or not.\n\\begin{enumerate}\n\\item \\textbf{Do not drive in cycles}: A special but important case of the previous rule is that vehicles should not drive in cycles.\n\\end{enumerate}\n\n\\item \\textbf{Do not forward packages using other vehicles}:\nLet $p$ be a package of size $|p|$ located at $A$.\nLet $v$ be a vehicle which drove through location $A$ to location $B \\neq A$\nand picked up $p$ at $B$,\nwithout having less than $|p|$ free space in any intermediate state between leaving $A$ and picking up $p$.\nIf this sequence of events occurs, the plan is suboptimal in a sequential setting, because\n$v$ could have picked up $p$ when driving through $A$, and the total plan cost\nwould have gone down by at least 2. The reason is that a different vehicle had to pick up, drive, and drop package $p$ at $B$.\nWhile we cannot say if the \\drive{} actions themself\nwere redundant, the \\pickup{} and \\drop{} actions definitely were.\nBy removing them, we save \n2 on the total cost. \n\nIn a temporal domain without fuel, assuming that vehicles only drive along the shortest routes,\nthe plan does not necessarily have to be suboptimal, but it\nis of equal length or longer: due to concurrent actions, the vehicles could have driven simultaneously.\nIn a few cases, the other vehicle could have dropped $p$ at $B$ before $v$ wants to pick it up,\nwhich means that the total makespan of the partial plan did not become longer, but stayed the same.\nThe plan could not have become shorter, because $v$ does not have any time in this scenario when it is available to do another action.\n\nIn a temporal domain with fuel, it is not safe to say whether\nsuch a scenario hurts the plan duration. If there is a petrol station at $B$\nand $v$ wants to refuel there, the other vehicle could have enabled the parallelization \nof the \\refuel{} and \\pickup{} actions, therefore shaving off 1 time unit in total.\nHowever, if there is no petrol\nstation at $B$, this situation reduces to the no-fuel variant. Given the relative rarity of petrol stations, this will reduce the search space somewhat.\n\\end{enumerate}\nAnother insight can only be applied to the sequential variant of Transport:\n\\begin{enumerate}\n\\item \\textbf{Drop from an active vehicle only}: Without loss of generality,\nwe can prune all plans where a \\drop{} action of a vehicle happens\nright after an action of a different vehicle. It is trivial to see that if we had a plan where\na \\drop{} action\noccurs after an action of a different vehicle, we can swap that action with the \\drop{} action without changing the total plan cost or changing the validity of the plan.\n\nDoing this repeatedly will yield an equivalent plan, in which the \\drop{} action\noccurs right after a different action of the same vehicle and the plan is of the same total cost and validity as the original plan. Repeating this process for each \\drop{} action will yield a plan equivalent to the original plan, which additionally satisfies this rule.\n\\end{enumerate}\nFinally, these are the properties that only meaningfully apply to the temporal variant:\n\\begin{enumerate}\n\\item \\textbf{Refueling and dropping/picking up can occur at the same time}: \nA plan in which a vehicle starts to pick up a package at the same location it just refueled at is suboptimal, if there was a time point during the \\refuel{} action\nwhen the vehicle was not dropping or picking up packages and the package was already\nco-located with the vehicle at that time.\n\n\\item \\textbf{No fuel left means refueling or ignoring the vehicle}:\nIf a vehicle is stuck with no fuel left, or with less fuel than is required for\nany valid \\drive{} action,\nthe correct thing to do is to either refuel or drop all packages and ignore the vehicle in further planning. Unfortunately,\nwe cannot say anything about the (non-)optimality of a plan where this occurs.\n\\end{enumerate}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\section{Datasets \\& problem instances}\\label{datasets}\n\nFor evaluation and comparison with other planners, we have acquired several problem datasets from previous runs of the IPC.\nTable~\\ref{tab:ipc-datasets} provides an overview of the individual datasets, their associated IPC competition, the track at the competition and the domain variant the problems are modeled in.\n\n\\begin{table}[tb]\n\\centering\n\\begin{tabular}{lclc}\n\\toprule\n{\\hspace{0.75em}\\textbf{Dataset}} & \\textbf{Competition} & {\\hspace{2.5em}\\textbf{IPC Track}} & \\textbf{Formulation}\\\\ \n\\midrule\nnetben-opt-6 & \\multirow{4}{*}{IPC-6} & \\href{http://icaps-conference.org/ipc2008/deterministic/NetBenefitOptimization.html}{Net-benefit: optimization} & Numeric \\\\ \nseq-opt-6 & & \\href{http://icaps-conference.org/ipc2008/deterministic/SequentialOptimization.html}{Sequential: optimization} & STRIPS \\\\ \nseq-sat-6 & & \\href{http://icaps-conference.org/ipc2008/deterministic/SequentialSatisficing.html}{Sequential: satisficing} & STRIPS \\\\ \ntempo-sat-6 & & \\href{http://icaps-conference.org/ipc2008/deterministic/TemporalSatisficing.html}{Temporal: satisficing} & Temporal \\\\ \n\\midrule\nseq-mco-7 & \\multirow{3}{*}{IPC-7} & \\href{http://www.plg.inf.uc3m.es/ipc2011-deterministic/SequentialMulticore.html}{Sequential: multi-core} & \\multirow{3}{*}{STRIPS} \\\\ \nseq-opt-7 & & \\href{http://www.plg.inf.uc3m.es/ipc2011-deterministic/SequentialOptimization.html}{Sequential: optimization} &  \\\\ \nseq-sat-7 & & \\href{http://www.plg.inf.uc3m.es/ipc2011-deterministic/SequentialSatisficing.html}{Sequential: satisficing} &  \\\\ \n\\midrule\nseq-agl-8 & \\multirow{4}{*}{IPC-8} & \\href{https://helios.hud.ac.uk/scommv/IPC-14/seqagi.html}{Sequential: agile} & \\multirow{4}{*}{STRIPS} \\\\ \nseq-mco-8 & & \\href{https://helios.hud.ac.uk/scommv/IPC-14/seqmulti.html}{Sequential: multi-core} &  \\\\ \nseq-opt-8 & & \\href{https://helios.hud.ac.uk/scommv/IPC-14/seqopt.html}{Sequential: optimization} &  \\\\ \nseq-sat-8 & & \\href{https://helios.hud.ac.uk/scommv/IPC-14/seqsat.html}{Sequential: satisficing} &  \\\\ \n\\bottomrule\n\\end{tabular}\n\\caption[Transport datasets from the 2008, 2011, and 2014 IPCs.]{Transport datasets from the 2008, 2011, and 2014 IPCs. All formulations assume capacitated vehicles. Numeric and temporal formulations also contain fuel demands and capacities. The temporal formulation additionally adds concurrent actions and a notion of time. More information can be found in Section~\\ref{domain-desc}.}\n\\label{tab:ipc-datasets}\n\\end{table}\n\nShort descriptions of the various tracks and subtracks can be found in the rule pages of IPC-6,\\puncfootnote{\\url{http://icaps-conference.org/ipc2008/deterministic/CompetitionRules.html}}\nIPC-7,\\puncfootnote{\\url{http://www.plg.inf.uc3m.es/ipc2011-deterministic/CompetitionRules.html}}\nand IPC-8.\\puncfootnote{\\url{https://helios.hud.ac.uk/scommv/IPC-14/rules.html}}\nWe have decided to split our further research based on the tracks at the IPC: we will focus on constructing\nTransport-specific planners for the seq-sat-6, seq-sat-7, seq-sat-8, and tempo-sat-6 datasets,\ncorresponding to the sequential and temporal variants of Transport.\n\nThe datasets labeled seq-opt correspond to sequential optimality planning tracks,\nwhere only optimal plans for problems are accepted as correct.\nDatasets labeled seq-mco are used in multi-core satisficing tracks (multi-threaded planners)\nand seq-agl are used in agile tracks (minimize the CPU time required to find a satisficing plan).\nThe netben-opt-6 dataset contains Net Benefit problems, where the aim\nis to compensate between achieving \\textit{soft goals} and minimizing the total cost.\nSoft goals are goals that do not necessarily have to be satisfied in a goal state,\nbut it is usually better for the total score if they are.\nEach problem usually specifies a metric used for calculation of the score.\nWe will not focus on \nthese problems in this work.\n\nIn addition to the domain definition, we need to take a look at the individual problems to fully utilize our knowledge advantage.\nBoth the seq-sat-6 and tempo-sat-6 contain 30 problems, while seq-sat-7 and seq-sat-8 only contain 20 problems each. Table~\\ref{tab:dataset-dimensions} shows the\ndimensions of each problem instance for each mentioned dataset.\n\nWhile the planners (including our domain-specific ones) do not know this,\neach problem was constructed with a scenario in mind. Locations in problems are not just\nplaced randomly, but usually belong to cities. Inside a city, the road network\ntends to be dense and road lengths small, while roads connecting cities\nare rare and usually significantly longer.\n\n\n\\begin{table}[p]\n\\scriptsize\n\\centering\n\\begin{subtable}[t]{0.42\\textwidth}\n\\centering\n\\csvreader[tabular=rrrrrrl,\n    table head=\\toprule\\textbf{\\#} & \\rot{\\textbf{Vehicles}} & \\rot{\\textbf{Packages}} & \\rot{\\textbf{Cities}} & \\rot{\\textbf{Locations}} & \\rot{\\textbf{Roads}} & \\rot{\\textbf{States}}\\\\\\midrule,\n    late after line=\\mbox{},\n    table foot=\\\\\\bottomrule]%\n{../data/seq-sat-6.csv}{Problem=\\problem,Vehicles=\\vehicles,Packages=\\packages,Cities=\\cities,Locations=\\locations,%\nRoads=\\roads,Stateslat=\\stateslat}%\n{\\problem & \\vehicles & \\packages & \\cities & \\locations & \\roads & \\stateslat}%\n\\caption{Problem dimensions of seq-sat-6.}\n\\label{tab:seq-sat-6-dims}\n\\end{subtable}\n\\quad\n\\begin{subtable}[t]{0.54\\textwidth}\n\\centering\n\\csvreader[tabular=rrrrrrrl,\n    table head=\\toprule\\textbf{\\#} & \\rot{\\textbf{Vehicles}} & \\rot{\\textbf{Packages}} & \\rot{\\textbf{Cities}} & \\rot{\\textbf{Locations}} & \\rot{\\textbf{Roads}} & \\rot{\\textbf{Petrol}} & \\rot{\\textbf{States}}\\\\\\midrule,\n    late after line=\\mbox{},\n    table foot=\\\\\\bottomrule]%\n{../data/tempo-sat-6.csv}{Problem=\\problem,Vehicles=\\vehicles,Packages=\\packages,Cities=\\cities,Locations=\\locations,%\nRoads=\\roads,Petrol=\\petrol,Stateslat=\\stateslat}%\n{\\problem & \\vehicles & \\packages & \\cities & \\locations & \\roads & \\petrol & \\stateslat}%\n\\caption{Problem dimensions of tempo-sat-6.}\n\\label{tab:tempo-sat-6-dims}\n\\end{subtable} \n\n\\vspace{0.21cm}\n\\begin{subtable}[t]{0.42\\textwidth}\n\\centering\n\\csvreader[tabular=rrrrrrl,\n    table head=\\toprule\\textbf{\\#} & \\rot{\\textbf{Vehicles}} & \\rot{\\textbf{Packages}} & \\rot{\\textbf{Cities}} & \\rot{\\textbf{Locations}} & \\rot{\\textbf{Roads}} & \\rot{\\textbf{States}}\\\\\\midrule,\n    late after line=\\mbox{},\n    table foot=\\\\\\bottomrule]%\n{../data/seq-sat-7.csv}{Problem=\\problem,Vehicles=\\vehicles,Packages=\\packages,Cities=\\cities,Locations=\\locations,%\nRoads=\\roads,Stateslat=\\stateslat}%\n{\\problem & \\vehicles & \\packages & \\cities & \\locations & \\roads & \\stateslat}%\n\\caption{Problem dimensions of seq-sat-7.}\n\\label{tab:seq-sat-7-dims}\n\\end{subtable}\n\\quad\n\\begin{subtable}[t]{0.54\\textwidth}\n\\centering\n\\csvreader[tabular=rrrrrrl,\n    table head=\\toprule\\textbf{\\#} & \\rot{\\textbf{Vehicles}} & \\rot{\\textbf{Packages}} & \\rot{\\textbf{Cities}} & \\rot{\\textbf{Locations}} & \\rot{\\textbf{Roads}} & \\rot{\\textbf{States}}\\\\\\midrule,\n    late after line=\\mbox{},\n    table foot=\\\\\\bottomrule]%\n{../data/seq-sat-8.csv}{Problem=\\problem,Vehicles=\\vehicles,Packages=\\packages,Cities=\\cities,Locations=\\locations,%\nRoads=\\roads,Stateslat=\\stateslat}%\n{\\problem & \\vehicles & \\packages & \\cities & \\locations & \\roads & \\stateslat}%\n\\caption{Problem dimensions of seq-sat-8.}\n\\label{tab:seq-sat-8-dims}\n\\end{subtable}\n\\caption[Problem dimensions of selected Transport IPC datasets.]{Problem dimensions of selected Transport IPC datasets.\nThe ``states'' value is a state space size estimate as discussed in Section~\\ref{datasets} (in temporal domains calculated with $f_{max} = 100$ and the $\\mt{GCD}$ of \\texttt{fuel-demand}s equal to 1).\nBold problem instances correspond to Figure~\\ref{fig:ipc08_seq-sat_p13} and Figure~\\ref{fig:ipc08_tempo-sat_p30}, respectively.}\n\\label{tab:dataset-dimensions}\n\\end{table}\n\n\\begin{figure}[tbp]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{../img/ipc08_tempo-sat_p30_land}\n\\caption[Road network visualization of the \\texttt{p30} problem from the tempo-sat track of IPC 2008.]{Road network visualization of the \\texttt{p30} problem from the tempo-sat track of IPC 2008. Red dots represent locations (graph nodes), roads (graph edges) are represented by black arrows, vehicles are plotted as blue squares, and packages as purple squares. Darker red dots represent locations with petrol stations. In this specific problem, the circle of darker nodes in the center represents truck hubs and each of the attached subgraphs are individual cities.}\n\\label{fig:ipc08_tempo-sat_p30}\n\\end{figure}\n\nAll sequential problem instances in seq-sat datasets have symmetric roads and road lengths and can, therefore,\nbe simplified by assuming the use of an undirected graph.\nAll packages are always positioned at locations\nin the initial state, not in vehicles (in all domain variants).\n\nThe temporal problems in tempo-sat-6 do not have the same properties;\nthe problems 1--20 have symmetric roads and lengths, but\nthe 21--30 problems only have symmetric roads, not lengths in general.\nThe same applies to fuel demands of roads. Additionally,\nthese problems have vehicle target locations, which means that not only packages,\nbut also\nvehicles will need to be positioned at specific locations\nafter package delivery finishes. We can interpret this goal\nin a similar way as in a VRP, where a vehicle target location is thought to be\na truck depot or hub. A visualization of such a problem can be seen in Figure~\\ref{fig:ipc08_tempo-sat_p30}.\nNo sequential problem has this requirement, even though the domain formulation allows it.\n\nGiven a specific Transport problem, we can calculate the size of the set of states $S$.\nFor sequential Transport, the state space size can be estimated as: $$l^v \\cdot (l+v)^p,$$ where $l$ is the number of locations,\n$v$ the number of vehicles, and $p$ the number of packages. The formula represents\nthe number of choices for the location of vehicles, combined with the number of choices\nfor the location of packages (these include being loaded onto a vehicle). We have eliminated\ninvalid states arising from inconsistent $\\mt{in}(p)$ and $\\mt{at}(p)$ state variable values,\nbut some invalid states are still left in the state size estimate (for example states,\nwhere vehicles are loaded beyond maximum capacity). We did not include a notion of\ncapacity in this estimate because it can be computed from the locations of packages.\n\nFor temporal Transport, the problem state space size estimate is more complicated,\ndue to actions being parallel. A reasonable estimate could be:\n$$(l+r)^v \\cdot \\left(\\frac{f_{max}}{\\mt{GCD} \\{\\mt{fuel-demand}(l_1, l_2) | (l_1, l_2) \\in R\\}}\\right)^v \\cdot (l+v)^p,$$ where $R$ represents the set of roads, $r = |R|$ is the number of roads,\n$\\mt{GCD}$ is the greatest common divisor function,\nand $f_{max}$ is the maximum fuel capacity for vehicles. The $f_{max}$ value presents a simplification, where all vehicles\nhave an equal maximum fuel capacity.\nThe formula expresses the choice of positions of vehicles (vehicles can now be in the middle\nof a \\drive{} action), the choice of the current fuel capacity of vehicles (cannot be simply\ncalculated from the other state variables, only from all previous actions),\nand the choice of location for packages.\n\nWe can see that problems vary not only in size but also in what features they include\nand what assumptions they make.\nA summary of the acquired dataset-specific insights is available in Table~\\ref{tab:problem-properties}.\n\n\\begin{table}[tb]\n\\centering\n\\begin{tabular}{cccccr}\n\\toprule\n\\multirow{3}{*}{\\textbf{Dataset}} & \\multirow{3}{*}{\\textbf{Problems}} & \\textbf{Sym.} & \\textbf{Sym.} & \\textbf{Vehicle} & \\multirow{3}{*}{\\textbf{$\\approx$ \\# states}}\\\\\n& &  \\textbf{road} & \\textbf{fuel} & \\textbf{fuel} &\\\\\n& & \\textbf{lengths} & \\textbf{demands} & \\textbf{locations} &\\\\\n\\midrule\nseq-sat-6 & 01--30 & Yes & N/A & No & $10^{3} \\to 10^{43}$\\\\\nseq-sat-7 & 01--30 & Yes & N/A & No & $10^{25} \\to 10^{59}$\\\\\nseq-sat-8 & 01--30 & Yes & N/A & No & $10^{50} \\to 10^{78}$\\\\\\midrule\n\\multirow{2}{*}{tempo-sat-6} & 01--20 & Yes & Yes & No & $10^{8} \\to 10^{52}$\\\\\n& 21--30 & No & No & Yes & $10^{18} \\to 10^{81}$\\\\\n\\bottomrule\n\\end{tabular} \n\\caption[Summary of problem instance properties in IPC Transport datasets.]{Summary of problem instance properties in IPC Transport datasets.\nState space size estimates in temporal domains\nare calculated using $f_{max} = 100$ and the $\\mt{GCD}$ of \\texttt{fuel-demand}s equal to 1.}\n\\label{tab:problem-properties}\n% https://www.wolframalpha.com/input/?i=l%5Ev+*+(v%2Bl)%5Ep,+p+%3D+2,+v+%3D+2,+l+%3D+5\n% https://www.wolframalpha.com/input/?i=(l%2Br)%5Ev+*+c%5Ev+*(v%2Bl)%5Ep,+p+%3D+2,+v+%3D+2,+l+%3D5,+r%3D12,+c%3D100\n\\end{table}\n\n", "meta": {"hexsha": "dbd7c6056b108f3b1d67703bc806809fbfb59f08", "size": 23519, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "transport-docs/bp/en/transport-analysis.tex", "max_stars_repo_name": "oskopek/TransportEditor", "max_stars_repo_head_hexsha": "5f99e64ae6e4068fae69d3df6c1d9e58e73e9d11", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-11-19T15:36:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-05T18:43:51.000Z", "max_issues_repo_path": "transport-docs/bp/en/transport-analysis.tex", "max_issues_repo_name": "oskopek/TransportEditor", "max_issues_repo_head_hexsha": "5f99e64ae6e4068fae69d3df6c1d9e58e73e9d11", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-05-15T21:05:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-01T00:57:38.000Z", "max_forks_repo_path": "transport-docs/bp/en/transport-analysis.tex", "max_forks_repo_name": "oskopek/TransportEditor", "max_forks_repo_head_hexsha": "5f99e64ae6e4068fae69d3df6c1d9e58e73e9d11", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-03-19T15:56:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-06T00:54:12.000Z", "avg_line_length": 59.9974489796, "max_line_length": 568, "alphanum_fraction": 0.7546239211, "num_tokens": 6386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4043454853364163}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n\n\\title{Math 217 -- Geometry and Physics -- Lec03}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{08}{10}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n\n\\begin{document}\n\\maketitle\n\n\n\\section{Stuff}\n\nSeminal paper: Witten --- Supersymmetry and Morse Theory (J. Diff. Geometry, 1982)\n\n\\subsection{Chern conjecture}\n\nLet's go over the Chern conjecture from last time. If $M = M^{2n}$ is a compact closed manifold, then\n\\begin{equation}\n\\chi(M) = \\int_M \\varepsilon(TM).\n\\end{equation}\nGiven the metric $g$ on $TM$, we have the Levi-Civita connection $\\nabla^g$. Then we have $R^{\\nabla^g} = (\\nabla^g)^2$ where $R$ is skew-symmetric, and \n\\begin{eqn}\n\\abs{Pf(R^{\\nabla^g})} = \\varepsilon(TM) \\in H^{2n}(M).\n\\end{eqn}\n[not sure transcribed correctly, was fast and messy on the board.] If $R^{\\nabla^g} = 0$ then $\\chi(M)= 0$ where \n\\begin{eqn}\n\\chi(M) = \\sum_{i=0}^{2n} (-1)^i b_i, \\qquad b_i = \\dim_\\R H^i (M).\n\\end{eqn}\n\nThe Chern conjecture is based on that. Conjecture: If $M^{2n}$ is an affine flat closed compact manifold, then $\\chi(M) = 0$. Let's define what affine flat means. Write $M = \\cup_{\\alpha \\in I} U_\\alpha$. Then it is affine flat iff\n\\begin{eqn}\n\\varphi_\\beta \\circ \\varphi_\\alpha^{-1}(x_\\alpha) = A_{\\alpha\\beta} x_\\alpha + B_{\\alpha\\beta},\n\\end{eqn}\nwhere $A_{\\alpha\\beta}, B_{\\alpha\\beta}$ are constant matrices $\\iff$ there exists an affine connection \n\\begin{eqn}\n\\nabla : \\Gamma(TM) \\rightarrow \\Gamma(T^* M \\otimes TM)\n\\end{eqn}\nwhere $\\nabla(fs) = f \\nabla s + f \\nabla s$. \n\nThe Chern conjecture is known in 2 dimensions (the torus). Not sure if known in any other dimensions. (See Sullivan-Kostant-Milnor for special cases.) \n\n\n\\subsection{Poincare duality}\n\nSays that $H^p \\cong H^{n-p}$. \n\n\\begin{exercise}\nAs an exercise, show (cf. Bott-Tu):\n\\begin{enumerate}\n\\item $M = \\R^n$. \n\\begin{equation}\n\tH^k (\\R^n) = \n\t\\begin{cases}\n\t0, & k = 0, \\\\\n\t\\R, & k \\neq 0\n\t\\end{cases}\n\t\\qquad\n\tH_c^k (\\R^n) = \n\t\\begin{cases}\n\t0, & k \\neq n \\\\\n\t\\R, & k = n.\n\t\\end{cases}\n\\end{equation}\n\\item $M = \\cup_{\\alpha \\in I} U_\\alpha$. \n\\end{enumerate}\n\\end{exercise}\n\nNow, given $\\Delta \\subseteq M$ a $p$-cycle in $M$, we have \n\\begin{eqn}\n[\\Delta] \\in H_p (M, \\R) \\cong H^{n-p}(M, \\R)\n\\end{eqn}\nThen we can write \n\\begin{eqn}\n\\begin{matrix}\n\\int_\\Delta \\omega & : & H_\\text{dR}^p(M) & \\rightarrow & \\R \\\\\n&& [\\omega] & \\mapsto & \\int_\\Delta \\omega\n\\end{matrix}\n\\end{eqn}\nfor a $p$-form $\\omega$. Write $\\Delta = \\sum_i a_i \\underbrace{\\Delta_i}_{=\\varphi_i(\\tilde{\\Delta}_i)}$ where $\\tilde{\\Delta}_i \\subseteq [\\text{something}] \\overset{\\varphi_i}{\\longrightarrow} M$\n\n\n\\subsection{stuff}\n\n[missed a lot here on whatever he was talking about]\n\n\n\\subsection{Lie groups}\n\n\\begin{definition}\nA Lie group $G$ is a smooth manifold with a group structure in the following sense:\n\\begin{enumerate}\n\\item Multiplication $G \\times G \\rightarrow G$ taking $(g, g') \\mapsto gg'$, and\n\\item Inverse $G \\rightarrow G$ taking $g \\mapsto g^{-1}$\n\\end{enumerate}\n\\end{definition}\n\nSome examples are given by: $\\C, \\C, \\Q, \\Q_p, \\dots$. Write $M_n(K) = \\text{$n \\times n$ matrices with entries in $K$}$. The group with elements $g = (a_{ij})_{n \\times n} \\in GL_n(\\R)$ with $\\det g \\neq 0$ is called the general linear group. Note that any subgroup submanifold is also a Lie group. \n\n\\begin{definition}\nA Lie subgroup $H$ of $G$ is a subgroup which is also a submanifold. If $H \\cong \\R$ then $i : \\R \\rightarrow G$ defines a one-parameter subgroup. \n\\end{definition}\n\nSome more examples: $SL_n(\\R), O_n(\\R), SO_n(\\R), U_n, SU_n$\n\n\\begin{definition}\nA Lie group homomorphism $\\psi : G \\rightarrow G'$ is a map satisfying $\\psi(gg') = \\psi(g) \\psi(g')$. If $\\psi$ is a diffeomorphism then it is called an isomorphism. It will be useful to also define\n\\begin{itemize}\n\\item $R_g : G \\rightarrow G$ mapping $R_g (g') = g' g$ for all $g' \\in G$\n\\item $L_g : G \\rightarrow G$ mapping $L_g (g') = g g'$ for all $g' \\in G$.\n\\end{itemize}\n\\end{definition}\n\n\\begin{definition}\nA vector field $X$ on $G$ is said to be left invariant if $L_g X = X$.\n\\end{definition}\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "29e8b61d6693a6b92f4b363a52cd950b971faa45", "size": 4362, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geometry/lec03.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "geometry/lec03.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geometry/lec03.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0454545455, "max_line_length": 300, "alphanum_fraction": 0.6691884457, "num_tokens": 1524, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.40434548394465386}}
{"text": "\\documentclass{article}\n\n\\usepackage[margin=1in]{geometry}\n\\usepackage{syntax}\n\\usepackage{float}\n\\usepackage{amsmath}\n\\usepackage{tikz}\n\\usetikzlibrary{arrows,automata}\n\\usepackage{minted}\n\n\\title{Deep Strictness: Milestone 2}\n\\author{Kenny, Hengchu}\n\n\\begin{document}\n\\maketitle\n\nWe aim to extend QuickCheck with the ability to probabilistically verify the\nlaziness/strictness behavior of Haskell functions. That is, we will allow users\nto write a specification of the strictness behavior of a particular function,\nand by fuzzing inputs to the function, determine if the function is\n\\emph{exactly} as strict as the user has specified.\n\nBefore describing in detail how our proposed tool will work, we give several\ndefinitions regarding laziness in Haskell:\n\nA lazy function takes an \\emph{input} to an \\emph{output}. For now, we consider\nonly inputs and outputs restricted to single algebraic datatypes which do not\ncontain functions (that is, all functions we can speak about are unary\nfirst-order functions). We plan to extend this to multi-argument and\nhigher-order functions in later stages of this project.\n\nWhen a lazy function is applied to an input, it is done so in a \\emph{context}\nwhich makes use of some part of its output---that is, the context may not use\nthe entire output data structure to continue its own computation. We call the\nportion of the input which is used by the context the \\emph{demand} on the\noutput. The semantics of lazy evaluation dictate that any portion of the input\nwhich is not required to compute the demanded portion of the output are not\nevaluated in the first place---that is, evaluation only occurs as much as is\nnecessary to satisfy the demand of the calling context.\n\nFor example, let us consider a function \\verb|f :: Int -> Int -> Int| where\n\\verb|f x n = fst (x, fib n)|. Although computing the second component of the\npair in \\verb|f 1 100000000| would be very expensive, this computation never\noccurs because the demand placed upon the pair (extracting the first component)\nonly requires the first component to be evaluated. We say that \\verb|f| is\n\\emph{strict} in its first parameter (\\verb|x|) and \\emph{lazy} in its second\nparameter (\\verb|n|).\n\nWe can capture this notion formally as a function from a given demand of the\noutput to a demand of the input. We call this a \\emph{demand\n  specification}. Here, we can concretely represent a demand as a\n\\emph{subshape} of the input/output---that is, a data structure corresponding to\none of these data types, but which can be truncated at any arbitrary position in\nthe structure of the data type. We call this derived data type the \\emph{demand\n  type} corresponding to a data type.\n\nFor example, the corresponding demand type for the type \\verb|(Int, Int)| would be:\n\n\\verb|Demand (Demand Int, Demand Int)|\n\nwhere\n\n\\begin{minted}{haskell}\ndata Demand a = ~   -- ^ Not demanding\n              | ! a -- ^ Demanding the constructor at this level\n              | *   -- ^ Demanding a primitive or nullary constructor\n\\end{minted}\n\nAll the values of these types are:\n\\verb|~, (~, ~), ! (*, ~), ! (~, *)|, and \\verb|! (*, *)|. These\nrepresent all of the possible demands which a context could place on\nthe type \\verb|(Int, Int)|.\n\nSuppose we have a function \\verb|g :: (Int, Int) -> Int|. The corresponding\ndemand specification for g would be a function\n\\verb|gSpec :: Demand Int -> Demand (Demand Int, Demand Int)|.\n\nConcretely, consider the function \\verb|fst| (for integers):\n\n\\begin{minted}{haskell}\nfst :: (Int, Int) -> Int\nfst (a, b) = a\n\\end{minted}\n\nAn accurate demand specification for \\verb|fst| is:\n\n\\begin{minted}{haskell}\nfstSpec :: Demand Int -> Demand (Demand Int, Demand Int)\nfstSpec ~ = ~\nfstSpec * = ! (*, ~)\n\\end{minted}\n\nThis states that if we demand nothing from the result of \\verb|fst|, we do not\nneed to evaluate its argument at all. (This is true for \\emph{every} function in\na lazy language!) However, if we demand the resultant integer from \\verb|fst|,\nwe must evaluate the first integer in the input pair, but we do not need to\nevaluate the second element of the pair.\n\nFor functions like \\verb|fst|, the demand on input is a \\emph{static demand}:\nthat is, for each demand on the output, any input to the function will be\nevaluated to the same degree.\n\nThis is not true in general, and not merely in pathological examples. Many\n(perhaps most!) useful functions have dynamic demand behavior---that is, their\ndemand specification depends on the values of the input. We say that such\nfunctions have \\emph{dependent demand}: that is, the demand specification of\nthese functions must consider the input values of the function as well.\n\n\\begin{minted}{haskell}\ntake :: (Int, [Int]) -> [Int]\ntake (n, xs) =\n  case (n, xs) of\n    (0, _)     -> []\n    (n',x:xs') -> x:(take ((n'-1), xs'))\n    (n', [])   -> []\n\\end{minted}\n\nJust given some demand on the output list, we can't guess the demand on the\nsecond element of the input pair, although we do know that the first element of\nthe pair will always be evaluated.\n\nSuppose we have demand the first 2 elements of some result of take, there is no\none input demand that corresponds to this output demand. However, if we know\nwhat the first argument to \\verb|take| is, we can determine the degree to which\nthe input list must be evaluated. Note that the demand on the output still is\nanother factor in determining the demand on the input, since if we demand\nnothing on the output, then nothing on the input will be demanded.\n\nThe demand specification of \\verb|take| could be\n\n\\begin{minted}{haskell}\ntakeSpec :: (Int, [Int]) -> Demand [Demand Int] -> Demand (Demand Int, Demand [Demand Int])\ntakeSpec _       ~    =  ~\ntakeSpec (0, _)  ![]  =  !(*, ~)\ntakeSpec (n, xs) !ds  =\n  case (ds, xs) of\n    ([],     _)    -> !(*, ![])\n    (d:ds', x:xs') ->\n      let !(_, !ds'') = takeSpec (n-1, xs') !ds' in\n      !(*, !(d:ds''))\n\\end{minted}\n\nDetermining statically whether a function meets its demand spec is undecidable\ndue to the Halting Problem. So, instead of statically approximating these\nbehavior, we choose to apply runtime instrumentation with randomized testing,\nthis gives a high level of confidence.\n\nWe choose to implement this as an extension to QuickCheck (CITATION). We will\nuse generic programming to derive the demand types of functions under\nconsideration. We will use existing QuickCheck generator infrastructure to fuzz\ninputs to the function, and demands on the output of the function. Because only\ncertain shapes of demand are realizable on a given output, we specialize the\ndemand generators to produce only sensible demands on each invocation of the\nfunction. We then run the function on the random input to obtain un-evaluated\noutput, and place a random demand on this output while instrumenting the\nfunction to determine the resultant demand on the input. We can then use the\ndemand specification to check whether the demand specification exactly matches\nwhat the actual demand behavior of the function was in this trial.\n\nBecause we integrate with the existing functionality of QuickCheck, we can\nemploy its \\emph{shrinking} abilities to produce minimal counterexamples of\ninput/demand pairs which fail to satisfy a given demand specification, if this\nspecification is faulty.\n\nNote that there are two ways in which a specification may be faulty: it may fail\nto produce an input demand which exactly matches the real observed input demand,\nor it may fail to cover all possible realizable combinations of input and\ndemand.\n\nTo avoid unnecessary metaprogramming, we choose not to calculate an instrumented\nversion of the function under consideration. We do not need to resort to such\nstrategies because we can instead instrument the input data structure to report\nto us how it is evaluated by the function. As such, we may treat our functions\nas a black box.\n\nIn order to instrument a lazy data structure, we must use so-called ``unsafe''\nfeatures of Haskell---in particular, the function \\verb|unsafePerformIO| which\nallows us to attach a callback to a particular lazy value so that the callback\nis run when that value is evaluated. We may traverse the generated input data\nstructure to add such a callback to every node in that structure. By tracking\nwhich of these callbacks are invoked when we demand a particular part of the\noutput of some function applied to the instrumented structure, we produce an\nexact representation of the input demand of this function given a particular\noutput demand and input value.\n\nOnce we have obtained a pair of generated output demand and observed input\ndemand, it's trivial to run the demand specification on the output demand and\ncheck whether it exactly matches the observed demand. If it does not, we may\nrepeat this process by shrinking inputs to the function to compute a minimal\nexample exhibiting the detected violation of the demand specification.\n\nWe need not only to consider how to \\emph{check} such specifications, but also\nhow to specify them in the first place! To that end, we will use Haskell's\ngeneric programming features to provide a syntax for users to succinctly write\nthese demand specifications without worrying about the details of our\nimplementation. Ideally, this syntax would look very similar to the syntax we\nuse above, but we may need to make some concessions due to the limitations of\nthe implementation strategy we choose for this interface.\n\nMoving forward, we want to allow users to check demand specifications of\nmulti-argument functions, higher-order functions, and functions on data\nstructures which themselves contain functions.\n\n\\section{Progress as of Second Milestone}\n\nAs of now, we have successfully implemented a proof-of-concept for the\ninstrumentation of functions over lists. By making use of a mutable\npointer-based data structure, we managed to implement this instrumentation such\nthat the execution of the instrumented function is a constant multiplicative\nfactor slower than the execution of the uninstrumented function. We have also\n(mostly) implemented the module which will enable us to handle instrumenting\nfunctions of an arbitrary number of arguments. Tomorrow, we plan to meet with\nJos\\'e Manuel Calder\\'on Trilla tomorrow, who's done quite a bit on strictness\nanalysis. We are also anticipating collaborations with Leo Lampropoulos (expert\nin property based random testing) and Antal Spector-Zabusky (well versed in\ngeneric programming in Haskell).\n\nHere are some examples of functions that operate on the \\verb|List| data type.\nEach of these functions demonstrate different strictness on the input list. For\nexample, the lazy \\verb|Context| doesn't inspect the input list at all, and thus\nis completely lazy. By contrast, \\verb|spineStrict| evaluates the structure of\nthe list without forcing its contents to be evaluated. A more complex example of\na demand context is \\verb|evenStrict| which, like \\verb|spineStrict|, evaluates\nthe entire structure of the list, but which also evaluates every other element\ncontained in the list.\n\n\\begin{minted}{haskell}\ntype Context a = a -> ()\n\nlazy :: Context [a]\nlazy = const ()\n\nwhnf :: Context [a]\nwhnf = flip seq ()\n\nnthStrict :: Int -> Context [a]\nnthStrict n = flip seq () . (!! n)\n\nspineStrict :: Context [a]\nspineStrict = flip seq () . foldl' (flip (:)) []\n\nallStrict :: NFData a => Context [a]\nallStrict = rnf\n\noddStrict :: NFData a => Context [a]\noddStrict []           = ()\noddStrict [x]          = rnf x\noddStrict (x : _ : xs) = rnf x `seq` oddStrict xs\n\nevenStrict :: NFData a => Context [a]\nevenStrict []           = ()\nevenStrict [_]          = ()\nevenStrict (_ : x : xs) = rnf x `seq` evenStrict xs\n\\end{minted}\n\nTo observe the behavior of these functions, we used the \\verb|demandList|\nfunction on each of the contexts defined above. We evaluate the same function\n(\\verb|take 6|) on the same data (\\verb|[1..5]|), but with differing demands on\nthe result.\n\n\\begin{minted}{haskell}\nmapM_ printDemand_primList $\n   map (\\context -> demandList context (take 6) [1..5]) $\n      [lazy,\n       whnf,\n       spineStrict,\n       nthStrict 2,\n       allStrict,\n       oddStrict,\n       evenStrictt]\n\\end{minted}\n\nWe then print a representation of the demand on the \\emph{input} which is\nincurred by this evaluation. An ``O'' indicates that the data at that list cell\nwas forced in the corresponding context, and an underscore indicates means that\nthe data at its list cell was not evaluated. An ellipsis indicates that the rest\nof the list was not evaluated, while a closing square bracket indicates that the\nlist was evaluated all the way down to its end.\n\n\\begin{verbatim}\nlazy:         ...\nwhnf:         [_, ...\nspineStrict:  [_, _, _, _, _, _]\nnthStrict 2:  [_, _, O, ...\nallStrict:    [O, O, O, O, O, O]\noddStrict:    [O, _, O, _, O, _]\nevenStrict:   [_, O, _, O, _, O]\n\\end{verbatim}\n\nThe process of \\emph{currying} takes a function of one argument which returns\nanother function of one argument and converts it into a function taking two\narguments and returning a result. Conversely, \\emph{uncurrying} takes such a\nfunction of two arguments and converts it into a function of one argument which\nreturns another function of one argument.\n\nWith clever type-level programming, we can generalize currying to functions with\narbitrary numbers of arguments. This is necessary to enable our library to\nhandle testing such ``curried'' functions, which are ubiquitous in Haskell. As\nsuch, we have implemented the following (non-trivial) functions, which will be a\nnecessary part of our internal infrastructure.\n\n\\begin{minted}{haskell}\ncurryAll   :: function -> (Tuple (Args function) -> Result function)\nuncurryAll :: (Tuple (Args function) -> Result function) -> function\n\\end{minted}\n\nThere is a mechanical transformation between the type of a function and the\ncorresponding type of its demand specification. Similarly, there is a mechanical\ntransformation from the type of a value to the type of the representation of the\ndemand upon it.\n\nIn order to perform these transformations, we use a feature in Haskell called\nType Families. Type Families allow us to write recursive functions over the\nstructure of types to compute other types. The Haskell compiler GHC has another\nfeature called Generics, which transforms any type to a generic representation\nthat uses sums, products and arrows. We have named our two Type Families\n\\verb|Spec| and \\verb|Demand| respectively, and here is their definition.\n\n\\begin{minted}{haskell}\ndata Thunk a = T | E a\n\nDemand (a :+: b) = Demand a :+: Demand b\nDemand (a :*: b) = Thunk (Demand a) :*: Thunk (Demand b)\nDemand (a -> b)  = FuncDemand\n\nSpec (a :+: b)   = Spec a :+: Spec b\nSpec (a :*: b)   = Spec a :*: Spec b\nSpec (a -> b)    = (a, Spec a) -> Demand b -> Thunk (Demand a)\n\\end{minted}\n\nWe use the data type \\verb|Thunk| to introduce an additional layer of\nindirection. A value of type \\verb|Demand a| can only ever be a prefix of its\ncorresponding value at the type \\verb|a|, and thunks represent the locations\nwhere the remaining structure can be chopped off by a lack of further evaluation\nof the data structure.\n\nWith higher-order functions, uncurrying all of the arguments of the higher order\nfunction before applying \\verb|Spec| is critical to generate the most\nfine-grained type of its demand specification. Consider the example \\verb|map|\nwhich maps a function over a list.\n\\begin{minted}{haskell}\nmap :: (a -> b) -> [a] -> [b]\n\\end{minted}\n\nIf we don't uncurry \\verb|map|, then its specification will have type\n\\begin{figure}[H]\n  \\centering\n\\begin{minted}{haskell}\n(a -> b, (a, Spec a) -> Demand b\n                     -> Thunk (Demand a))\n-> Demand ([a] -> [b])\n-> Thunk (Demand (a -> b))\n\\end{minted}\n\\caption{curried \\texttt{map} specification type}\n\\end{figure}\n\nThis type just simplifies to\n\\begin{minted}{haskell}\n(a -> b, (a, Spec a) -> Demand b\n                     -> Thunk (Demand a))\n-> FuncDemand\n-> Thunk FuncDemand\n\\end{minted}\n\n\\verb|FuncDemand| only captures whether the function was called or not. However,\nin a typical implementation of \\verb|map|, the usage of the input function\ndepends on whether the input list is empty or not. It's impossible to specify\nthe demand behavior of Haskell standard library's implementation of \\verb|map|\nusing this type signature.\n\nHowever, consider the uncurried \\verb|map|, which has type\n\\begin{minted}{haskell}\n(a -> b, [a]) -> [b]\n\\end{minted}\n\n\\clearpage\nApplying \\verb|Spec| to this type produces\n\\begin{figure}[H]\n  \\centering\n\\begin{minted}{haskell}\n((a -> b, [a]), ((a, Spec a) -> Demand b\n                             -> Thunk (Demand a), Spec [a]))\n-> Demand [b]\n-> Thunk (Demand [a])\n\\end{minted}\n\\caption{uncurried \\texttt{map} specification type}\n\\end{figure}\n\nHere, we see that this type in fact takes the input list \\verb|[a]| as an input\nto the specification as well! This allows a precise and correct specification of\n\\verb|map|. This observation applies to general higher-order functions.\n\nWe will integrate the \\verb|Spec| and \\verb|Demand| Type Families with GHC's\ngenerics mechanism to automatically derive specification types of algebraic data\ntypes. We will then write generic generators for representations of\nspecifications and demands, and then we will develop a presentable API for\nprogrammers to write property based test cases to check the demand behaviors of\nHaskell programs.\n\\end{document}\n", "meta": {"hexsha": "41a2c2206b93fb951a0e264ffacda1cdf2b3f1ff", "size": 17355, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentations/report.tex", "max_stars_repo_name": "nomeata/StrictCheck", "max_stars_repo_head_hexsha": "77f6621d4fd35a87558c36a178fb1f7120233975", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "presentations/report.tex", "max_issues_repo_name": "nomeata/StrictCheck", "max_issues_repo_head_hexsha": "77f6621d4fd35a87558c36a178fb1f7120233975", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentations/report.tex", "max_forks_repo_name": "nomeata/StrictCheck", "max_forks_repo_head_hexsha": "77f6621d4fd35a87558c36a178fb1f7120233975", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3875, "max_line_length": 91, "alphanum_fraction": 0.7475655431, "num_tokens": 4266, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4043454813044682}}
{"text": "\\section{Optimizations}\\label{sec:method}\n\n%Now comes the ``beef'' of the paper, where you explain what you\n%did. Again, organize it in paragraphs with titles. As in every section\n%you start with a very brief overview of the section.\n\n%For this class, explain all the optimizations you performed. This mean, you first very briefly\n%explain the baseline implementation, then go through locality and other optimizations, and finally SSE (every project will be slightly different of course). Show or mention relevant analysis or assumptions. A few examples: 1) Profiling may lead you to optimize one part first; 2) bandwidth plus data transfer analysis may show that it is memory bound; 3) it may be too hard to implement the algorithm in full generality: make assumptions and state them (e.g., we assume $n$ is divisible by 4; or, we consider only one type of input image); 4) explain how certain data accesses have poor locality. Generally, any type of analysis adds value to your work.\n\nThe code was optimized in an iterative manner, driven by insights from analysing and profiling the code. In a first phase, we focused on general optimizations that would not change the interfaces and generality of the implementation. In a second phase the special property of the recommender system were exploited, trading in generality for speed and interfering drastically with the interface of the library.\n\nIn both phases, we started off by reducing the OP count, without considering the computational intensity. We then profiled our code to find critical points where we could optimize memory access patterns or reorder operations to increase the performance.\n\nWe also considered to work in the logarithmic domain. This would have enabled us to express the product over the messages as a sum,  making it less likely to suffer from numerical rounding errors and sometimes making the computation faster. In our case the accuracy did not improve. Furthermore the runtime increased due to the additional overhead when transforming from/to the log domain. We therefore decided to not utilize this option.\n\n% -- Optimize calculation of product -- \n\\mypar{Optimize calculation of product (Phase 1)}\nWe observed that the incoming message product is recomputed each time a message gets updated. This is expensive because the product often spans a hundred or more factors. To improve the situation we pre-computed the product once over all messages. When changing a message the product is updated by multiplying with the new message and dividing by the old one. \nSpeed-up: 1.6 on the big dataset.\n\n%TODO: sicherstellen, ziemlich früh zu erwähnen, dass alle performance angaben stark vom datensatz (size AND shape) abhängen. Konvention: wir beziehen den speedup immer auf den datensatz u1, den wir zu beginn immer verwendet haben\n\n% -- C++ refactoring --\n\\mypar{Memory friendly C++ (Phase 1)}\nEncouraged by profiling results, a subsequent optimization step consisted in the re-factoring of the code base with the main objective to reduce memory ops. The biggest improvement we achieved by modifying functions to operate in-place. Another improvement consisted in the creation of buffers for intermediate results and to avoid superfluous creation and destruction of data. \nSpeed-up: 2.0 on the big dataset.\n\n%-- Switch to single precision\n\\mypar{Switch to single precision  (Phase 1)}\nAt this stage, the code was memory bound. To further reduce memory traffic, we enabled the support for single point precision. However, because the sum-product algorithm requires to calculate products with a large number of factors $f \\in [0,1]$, a trade-off approach was chosen: the calculation of products was still performed with double precision, but the messages were stored in single precision (after normalisation). Due to decreased precision, the number of message processed was reduced by a factor of 6 while giving a total speed-up of around 12, so a net speed-up of 2.0 can be achieved. Our code can still be compiled for both single and double precision (storage) through a compiler flag.\n\n%-- Heap/Multimap\n\\mypar{Using a Heap (Phase 1)}\nThe baseline implementation used a sorted \\texttt{std::multimap} to store the residuals. Updating a specific value was, however, expensive because the \\texttt{std::multimap} only supports erase/insert. We introduced a pairing heap from the boost library which provided an efficient update method. Initially the heap introducing more memory intensive operations. In our first versions this seemed to have a negative effect on the runtime. However, as we moved forward we became less memory bound, in the final version the heap results in a speed-up of 3 compared to the multimap.\n\n\\mypar{Efficient storage of messages (Phase 2)}\n%-- More efficient storage of messages.\nFor every iteration, a possibly large number of messages is read and stored. Therefore, it is beneficial to optimize the message lookups. Because a message $m$ represents a normalized probability distribution that satisfies $\\sum_{i=1}^N m_i = 1$, it suffices to store only $N-1$ values for every message. The re\\-commender system uses binary variables:  like and dislike. Therefore the amount of bytes required to store a message can be divided by two. \n\n%-- Exploit the special pattern how messages are updated\n\\mypar{Exploit special patterns (Phase 2)}\nPattern analysis of message products revealed a repeating pattern. Hard-coding this pattern is beneficial because an index lookup can be avoided. Technically, the optimization is comparable with a loop unrolling where the innermost loop necessary for the index lookup is flattened away.\nEfficient storage of messages and exploiting special patterns result in a speed-up of 2.0 for the big dataset.\n\n\\mypar{Compressing the graph (Phase 2)}\nWe compress the graph by using the same factor object for all factors. This was possible because the factors do not change and are always represented by the same $2\\times2$ matrix. Using only a single factor greatly reduced memory traffic and resulted in a speed-up of 1.4 for the big dataset.\n\n%-- Precalculate reciprocals\n\\mypar{Pre-calculate reciprocals (Phase 2)}\nThe first optimization (pre-calculation of message products, with later division of a message) increased the pressure on the division unit. This turned into one of the major bottlenecks of the code. We tried to solve this issue by pre-calculating reciprocals (“1/message”) but the speed-up was not significant. We tried to utilize vectorization to compute multiple divisions at once and make use of the fast but less accurate \\_mm\\_rcp\\_ps. Unfortunately our experiments showed that the lack of accuracy with the \\_mm\\_rcp\\_ps instruction lead to a worse convergence of our algorithm, greatly increasing the runtime. Furthermore, vectorizing turned out to be harder than anticipated because our computations strongly depend on each other. We could not predict which message we would update next unless we finished updating the current message. This is why vectorization had not a significant impact on our performance.\n\n%As important as the final results is to show that you took a structured, organized approach to the optimization and that you explain why you did what you did.\n\n%Mention and cite any external resources including library or other code.\n\n%Good visuals or even brief code snippets to illustrate what you did are good. Pasting large amounts of code to fill the space is not good.\n", "meta": {"hexsha": "5404ed5c7b9286ea7939b53c605012aa3bb3b2a2", "size": 7443, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/03-method.tex", "max_stars_repo_name": "flurischt/libDAI", "max_stars_repo_head_hexsha": "20683a222e2ef307209290f79081fe428d9c5050", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-05-03T00:17:48.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-03T00:17:48.000Z", "max_issues_repo_path": "report/03-method.tex", "max_issues_repo_name": "flurischt/libDAI", "max_issues_repo_head_hexsha": "20683a222e2ef307209290f79081fe428d9c5050", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/03-method.tex", "max_forks_repo_name": "flurischt/libDAI", "max_forks_repo_head_hexsha": "20683a222e2ef307209290f79081fe428d9c5050", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 130.5789473684, "max_line_length": 918, "alphanum_fraction": 0.8014241569, "num_tokens": 1572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.40434547991270586}}
{"text": "\\documentclass[11pt]{article}\n\\title{Numerically Solving Newton's Second Law}\n\\date{}\n\n\\begin{document}\n\\maketitle\n\n\\section{Pre-notebook}\nWork through these questions with your group before you move onto the IPython notebook.\n\n\\subsection{Solving Newton's Second Law for a mass on a spring}\\label{Newtons}\nWrite down Newton's Second Law for a mass $m$, on a spring with spring constant $k$.\nInitially assume that there is no friction in the system.\n\\begin{itemize}\n\\item Can you rewrite this in terms of derivatives of the position variable?\n\\item Solve this differential equation and find an expression for the position of the mass as a function of time.\n\\end{itemize}\n\n\\subsection{Conservation of Energy}\nGiven the solution you found in section~\\ref{Newtons}, find the velocity of the mass as a function of time.\nWith the position and velocity expressions, check to make sure that the system conserves energy.\n\nOkay, now go and start working through the notebook.\n\n\\section{Numerical Updates for Position and Velocity}\nWe want to model our system discretely so it can be solved on a computer.\n\\subsection{Written Updates}\nGiven the ``delta t'' versions of the acceleration and velocity equations, what are the updates for $v_{t+\\Delta t}$ and $x_{t+\\Delta t}$.\n\\subsection{Coded Updates}\nWe've filled in the update for $x$ and $t$ for you. Write the code to update $a$\n\n\\section{Problems with the Model}\nIf you made your $\\Delta t$ larger, you might have noticed that the oscillations started to blow up in our numerical version.\n\\subsection{Conservation of Energy}\nCan you show if energy is conserved given the updates for $x$ and $v$ that you derived earlier?\n\\subsection{Adding Drag}\nWhat if we want to add drag to the model? Write down the updates for $x$ and $v$ again with a drag term included.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "0d8787635eac2d34a185ed7c18a5418f28c111f5", "size": 1822, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "integration/worksheet/worksheet.tex", "max_stars_repo_name": "JesseLivezey/science-programming", "max_stars_repo_head_hexsha": "fd2713260f7d6e7404344795f41d120070d88610", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "integration/worksheet/worksheet.tex", "max_issues_repo_name": "JesseLivezey/science-programming", "max_issues_repo_head_hexsha": "fd2713260f7d6e7404344795f41d120070d88610", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "integration/worksheet/worksheet.tex", "max_forks_repo_name": "JesseLivezey/science-programming", "max_forks_repo_head_hexsha": "fd2713260f7d6e7404344795f41d120070d88610", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.380952381, "max_line_length": 138, "alphanum_fraction": 0.7749725576, "num_tokens": 435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5506073507867328, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.40421161107023384}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n%\\usepackage{physics}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\\usepackage{hyperref}\n\\usepackage[arrowdel]{physics}\n\n\\usetikzlibrary{automata,positioning}\n\n%\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Pset\\ \\#2}\n\\newcommand{\\hmwkDueDate}{Due on 6th February, 2019}\n\\newcommand{\\hmwkClass}{Electromagnetism}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\n\\maketitle\n(\\textbf{Acknowledgements} - I would like to thank Junaid Majeed for discussions.)\n\\\\\n\n\\begin{homeworkProblem}\n\t\\textbf{Zangwill - Problem} 24.1\\\\\n\t\\textbf{Part (a)}\n\tGiven, \n\t\\begin{align*}\n\t\\pdv{F_i}{\\dot{r}_j} &= - \\pdv{F_j}{\\dot{r}_i} \\\\\n\t\\implies \\pdv[2]{F_i}{\\dot{r}_j}{\\dot{r}_k} &= - \\pdv{F_j}{\\dot{r}_i}{\\dot{r}_k}\\\\\n\t\\pdv[2]{F_i}{\\dot{r}_k}{\\dot{r}_j}&= - \\pdv{F_j}{\\dot{r}_k}{\\dot{r}_i}\\\\\n\t-\\pdv[2]{F_k}{\\dot{r}_i}{\\dot{r}_j} &=  \\pdv{F_k}{\\dot{r}_j}{\\dot{r}_i}\\\\\n\t\\implies  \\pdv{F_k}{\\dot{r}_j}{\\dot{r}_i} &=0\n\t\\end{align*}\n\tFrom Hemholtz first relation, we know that integrating the above equation should give us an object which is antisymmetric under the exchange of indices. We can take this into account by introducing our friendly neighbourhood antisymmetric object, namely the \\textit{Levi-Civita symbol}.\n\t\\begin{equation*}\n\t\\implies \\pdv{F_i}{\\dot{r}_j} =  \\epsilon_{ijk} Q_k (\\vb{r},t) \\implies F_i = \\epsilon_{ijk} Q_k (\\vb{r},t) \\dot{r}_j + P(\\vb{r}, t)\n\t\\end{equation*}\n\tHence proved.\n\t\\\\\n\t\n\t\\textbf{Part (b)}\n\tThe second Helmholtz relation says,\n\t\\begin{align*}\n\t\\pdv{F_i}{r_j} - \\pdv{F_j}{r_i} &= \\dfrac{1}{2} \\dv{t} \\qty(\\pdv{F_i}{\\dot{r}_j} - \\pdv{F_j}{\\dot{r}_i} )\\\\\n\t\\pdv{P_i}{r_j} - \\pdv{P_j}{r_i} + \\epsilon_{ijk} \\qty(\\pdv{Q_k}{r_j} + \\pdv{Q_k}{r_i})  &=\\dv{t} (\\epsilon_{ijk} Q_k(\\vb{r},t) )\\\\\n\t\\pdv{P_i}{r_j} - \\pdv{P_j}{r_i} + \\epsilon_{ijk} \\qty(\\pdv{Q_k}{r_j} + \\pdv{Q_k}{r_i})  &=\\epsilon_{ijk} \\qty(\\pdv{Q_k}{t} + \\pdv{Q_k}{r_a}\\dot{r}_a)\\\\\n\t\\end{align*}\n\tAs we can see, there are no terms involving $ \\dot{r}_a $ on the LHS. Hence, the term involving $ \\dot{r}_a $ on the RHS should be zero!\n\t\\begin{equation*}\n\t\\implies \\pdv{Q_k}{r_a}\\dot{r}_a = \\grad{Q} = 0\n\t\\end{equation*}\n\tNext, we multiply both sides of the equation with $ \\epsilon_{l j i} $, and use the fact that $ \\epsilon_{lmk} \\epsilon_{ijk} = (\\delta_{li} \\delta_{mj} - \\delta_{lj} \\delta_{mi}) $,\n\t\\begin{align*}\n\t\\epsilon_{l j i} \\qty(\\pdv{P_i}{r_j} - \\pdv{P_j}{r_i}) + \\epsilon_{l j i}\\epsilon_{ijk}  \\qty(\\pdv{Q_k}{r_j} + \\pdv{Q_k}{r_i})  &= \\epsilon_{l j i} \\epsilon_{ijk}  \\qty(\\pdv{Q_k}{t} )\\\\\n\t\\epsilon_{lmk} \\qty(\\pdv{P_i}{r_j} - \\pdv{P_j}{r_i}) +  \\qty(\\pdv{Q_k}{r_m} + \\pdv{Q_k}{r_l} - \\pdv{Q_k}{r_l} - \\pdv{Q_k}{r_m})  &=  \\qty(\\pdv{Q_k}{t} )\\\\\n\t\\therefore \\epsilon_{lmk} \\qty(\\pdv{P_i}{r_j} - \\pdv{P_j}{r_i})  &=  \\qty(\\pdv{Q_k}{t} )\\\\\n\t\\therefore \\curl{P} &= \\pdv{Q}{t}\n\t\\end{align*}\n\t\n\t\\textbf{Zangwill - Problem} 24.2\\\\\n\t\\textbf{Part (a)}\\\\\n\t\\begin{align*}\n\tH(r,p) &= \\dfrac{p^2}{2m} + g(r) + p^2 f(r) = \\qty(\\dfrac{1 + 2 fm}{2m}) p^2 + g(r)\\\\\n\t\\implies \\dot{r} &= \\pdv{H}{p} = \\dfrac{p}{m} + 2p f(r) \\\\\n\t\\implies p &= \\dfrac{m \\dot{r}}{1 + 2 fm}\n\t\\end{align*}\n\t\\begin{equation*}\n\t\\therefore L(r, \\dot r) = \\dfrac{m \\dot{r}^2}{1 + 2 fm} - \\dfrac{m \\dot{r}^2}{2(1 + 2 fm)} - g(r) = \\dfrac{m \\dot{r}^2}{2(1 + 2 fm)} - g(r)\n\t\\end{equation*}\n\t\\textbf{Part (b)}\\\\\n\tWe write the Euler Lagrange equations for this Lagrangian,\n\t\\begin{align*}\n\t\\dv{t} \\qty(\\dfrac{m \\dot{r}}{1 + 2 fm}) + \\pdv{g}{r} &= 0  \\\\\n\t\\dfrac{m \\ddot{r}}{1 + 2 fm} - \\dfrac{m \\dot{r}}{(1 + 2 fm)^2} \\dot{r} \\dv{f}{r} + \\dv{g}{r}&= 0 \\\\\n\t{m \\ddot{r}} - \\dfrac{m \\dot{r}^2}{(1 + 2 fm)} \\dv{f}{r} + (1 + 2 fm)\\dv{g}{r}&= 0\n\t\\end{align*}\n\tAs one can see from the above equation, the force depends on $ \\ddot{r}, \\dot{r}, f , g $.\n\t\\\\\n\t\n\t\\textbf{Zangwill - Problem} 24.4\\\\\n\tLet's first work with $ c=1 $. We shall restore the factors of $ c $ at the end.\n\t\\begin{align*}\n\tS &= - m\\int \\dd{s} - g \\int \\dd{s} \\phi (\\va{r}(s))\\\\\n\t&= - m\\int \\dd{t} \\dv{s}{t} - g \\int \\dd{t} \\dv{s}{t} \\phi (\\va{r}(s))\\\\\n\tS &= \\int - \\dfrac{m}{\\gamma} \\dd{t} +  \\int \\dfrac{- g \\phi}{\\gamma } \\dd{t} \n\t\\end{align*}\n\tFrom the above form of action $ S $, the Lagrangian is evidently,\n\t\\begin{equation*}\n\tL = - \\dfrac{m + g \\phi}{\\gamma} \\qq{where} \\gamma = \\dfrac{1}{\\sqrt{1 - \\va{v} \\vdot \\va{v}}} =  \\dfrac{1}{\\sqrt{1 - \\dot{\\va{r}} \\vdot\\dot{\\va{r}} }}\n\t\\end{equation*}\n\t\\begin{align*}\n\t\\therefore \\dv{t} \\qty( \\pdv{L}{\\dot{\\va{r}}}) &= \\pdv{L}{\\va{r}} \\\\\n\t\\dv{(m + g \\phi) \\gamma \\dot{\\va{r}}}{t} &= - \\dfrac{g \\grad{\\phi}}{\\gamma}\n\t\\end{align*}\n\tRestoring the factors of $ c $,\n\t\\begin{equation*}\n\t\\dv{(m + g \\phi/c) \\gamma \\dot{\\va{r}}}{t} = - \\dfrac{g c \\grad{\\phi}}{\\gamma}\n\t\\end{equation*}\n\tThis differs from the electric field force equation, and has an extra term on the left (second term).\n\t\\\\\n\t\n\t\\textbf{Zangwill - Problem} 24.11\\\\\n\t\\begin{equation*}\n\tL_{CS} = \\int \\dd^3 r [\\rho \\phi - \\va{j} \\vdot \\va{A} + 1/2 \\{\\epsilon_0 (\\va{E}^2 - c^2 \\va{B}^2) - \\phi  (\\va{d} \\vdot \\va{B}/c) + \\va{d} \\vdot (\\va{A} \\cross \\va{E}/c) + d_0 \\va{A} \\vdot \\va{B}  \\}]\n\t\\end{equation*}\n\tIt is given that the Lagrangian remains invariant under usual gauge tranformations $ \\phi \\rightarrow \\phi + \\partial_t {\\lambda} $ and $ \\va{A} \\rightarrow \\va{A} - \\grad{\\lambda} $. Hence,\n\t\\begin{align*}\n\tL'_{CS} - L_{CS} = \\int \\dd^3 r [ \\rho \\partial_t \\lambda + \\va{j} \\vdot \\grad{\\lambda} + 1/2(- \\va{d} \\vdot (\\grad{\\lambda} \\cross \\va{E}/c) - d_0 \\grad{\\lambda} \\vdot \\va{B} - \\partial_t \\lambda (\\va{d} \\vdot \\va{B}/c)  )] \\\\\n\t= \\int \\dd^3 r [ \\partial_t(\\rho \\lambda) - \\lambda \\partial_t \\rho + \\div{(\\lambda \\va{j})} - \\lambda \\div{\\va{j}} + 1/2(- \\va{d} \\vdot (\\grad{\\lambda} \\cross \\va{E}/c) - d_0 \\grad{\\lambda} \\vdot \\va{B} - \\partial_t \\lambda (\\va{d} \\vdot \\va{B}/c)  )]\n\t\\end{align*}\n\tThe first four terms above vanish in the integral - the first and the third because they are boundary terms and the other two because of conservation.\n\t\\begin{align*}\n\tL'_{CS} - L_{CS} &= \\int \\dd^3 r [ 1/2(- \\va{d} \\vdot (\\grad{\\lambda} \\cross \\va{E}/c) - d_0 \\grad{\\lambda} \\vdot \\va{B} - \\partial_t \\lambda (\\va{d} \\vdot \\va{B}/c)  )] \\\\\n\tL'_{CS} - L_{CS} &= \\int \\dd^3 r [ 1/2(\\va{d} \\vdot \\lambda/c \\curl{\\va{E}}  - d_0 \\div{\\lambda \\va{B}} + d_0 \\lambda \\div{\\va{B}}  - \\partial_t [\\lambda (\\va{d} \\vdot \\va{B}/c) )] + \\lambda/c(\\partial_t\\va{d} \\vdot \\va{B} + \\partial_t\\va{B} \\vdot \\va{d})] \\\\\n\t&= \\int \\dd^3 r [ 1/2(- \\va{d} \\vdot\\curl{(\\lambda \\va{E}/c)} + \\lambda\\va{d} \\vdot\\curl{( \\va{E}/c)}  + d_0 \\lambda \\div{\\va{B}} - d_0 \\div - \\partial_t \\lambda (\\va{d} \\vdot \\va{B}/c)  )]\n\t\\end{align*}\n\t\n\t\\textbf{Zangwill - Problem} 24.12\\\\\n\t\\begin{equation*}\n\tL = \\va{j} \\vdot \\va{A} - \\rho \\phi - \\dfrac{1}{2} \\epsilon_0 (\\va{E}^2 - c^2 \\va{B}^2 ) - \\epsilon_0 \\va{E} \\vdot (\n\t\\grad{\\phi} + \\dot{\\va{A}} ) - \\epsilon_0 c^2 \\va{B} \\vdot (\\curl{\\va{A}})\n\t\\end{equation*}\n\t\\begin{align*}\n\t\\pdv{L}{\\va{E}} = - \\epsilon_0 \\va{E} - \\epsilon_0  (\\grad{\\phi} + \\dot{\\va{A}} ) &\\qq{,} \\pdv{L}{\\dot{\\va{E}}} = 0 \\implies \\va{E} = -\\grad{\\phi} - \\dot{\\va{A}} \\\\\n\t\\pdv{L}{\\va{B}} = \\epsilon_0 c^2 \\va{B} - \\epsilon_0 c^2 \\curl{\\va{A}} &\\qq{,}  \\pdv{L}{\\dot{\\va{B}}} = 0 \\implies \\va{B} = \\curl{\\va{A}}\\\\\n\t\\pdv{L}{\\phi} = - \\rho - \\epsilon_0 \\pdv{\\va{E} \\vdot \\grad{\\phi}}{\\phi} =  - \\rho + \\epsilon_0 \\div{\\va{E}} &\\qq{,} \\pdv{L}{\\dot{\\phi}} = 0 \\implies \\div{\\va{E}} = \\dfrac{\\rho}{\\epsilon_0} \\\\\n\t\\pdv{L}{\\va{A}} = \\va{j}  -\\epsilon_0 c^2  \\pdv{\\va{B} \\vdot (\\curl{\\va{A}})}{\\va{A}} =  \\va{j}  -\\epsilon_0 c^2 & \\pdv{(\\va{A} \\vdot (\\curl{\\va{B}}) + \\div{\\va{A} \\cross \\va{B}} )}{\\va{A} } = \\va{j} -\\epsilon_0 c^2 \\curl{\\va{B}}\\\\\n\t\\pdv{L}{\\dot{\\va{A}}} = - \\epsilon_0 \\va{E} &\\implies \\curl{B} = \\dfrac{\\va{j}}{\\epsilon_0 c^2} + \\dfrac{1}{c^2} \\dot{\\va{E}}\n\t\\end{align*}\n\tThe first two equations can be rewritten as $ \\div{B} = 0 $ and $ \\curl{E} = - \\pdv{\\va{B}}{t} $. Hence we have all the Maxwell equations.\n\t\n\tThere are 7 primary constraints (whose momenta vanish).\n\\end{homeworkProblem}\n\n\n\\begin{homeworkProblem}[2]\n\t\\textbf{Part (a)}\\\\\n\tGiven that,\n\t\\begin{align*}\n\tL_D &= \\sum_a \\qty(\\dfrac{1}{2} m_a \\va{u}_a^2 + \\dfrac{1}{8c^2} m_a \\va{u}_a^4 ) + \\sum_a \\sum_{b\\ne a} \\qty[ - \\dfrac{q_a q_b}{8 \\pi \\epsilon_0 r_{ab}} + \\dfrac{q_a q_b}{16 \\pi \\epsilon_0 c^2 r_{ab}} \\qty( \\va{u}_a \\vdot \\va{u}_b + (\\va{u}_a \\vdot \\vu{r}_{ab}) (\\va{u}_b \\vdot \\vu{r}_{ab}) )]   \\\\\n\t\\implies \\pdv{L_D}{\\va{u}_a}  &= \\qty( m_a \\va{u}_a+ \\dfrac{1}{2c^2} m_a \\va{u}_a^2 \\va{u}_a ) + \\sum_{b\\ne a} \\qty[\\dfrac{q_a q_b}{16 \\pi \\epsilon_0 c^2 r_{ab}} \\qty(  2 \\va{u}_b + 2 \\vu{r}_{ab} (\\va{u}_b \\vdot \\vu{r}_{ab}) )]  \\\\\n\t  \\pdv{L_D}{\\va{u}_a}  &= \\underbrace{ \\sum_{b\\ne a} \\qty[\\dfrac{q_b}{8 \\pi \\epsilon_0 c^2 r_{ab}} \\qty(  \\va{u}_b + \\vu{r}_{ab} (\\va{u}_b \\vdot \\vu{r}_{ab}) )]}_{\\va{p}_a^{kin}}  +q_a   \\underbrace{ \\sum_{b\\ne a} \\qty[\\dfrac{q_b}{8 \\pi \\epsilon_0 c^2 r_{ab}} \\qty(  \\va{u}_b + \\vu{r}_{ab} (\\va{u}_b \\vdot \\vu{r}_{ab}) )]}_{\\va{A}_a}\n\t\\end{align*}\n\twhich is the required form.\n\t\n\t\\textbf{Part (b)}\\\\\n\t\n\t\\textbf{Part (c)}\\\\\n\tConsider,\n\t\\begin{align*}\n\t\\pdv{r_{ab}}{\\va{r}_a} &= \\pdv{\\sqrt{(\\va{r}_a - \\va{r}_b)\\vdot (\\va{r}_a - \\va{r}_b)}}{\\va{r}_a} = \\dfrac{2 }{2 r_{ab}} (\\va{r}_a - \\va{r}_b) = \\vu{r}_{ab} \\qq{and} \\\\\n\t\\pdv{\\vu{r}_{ab}}{\\va{r}_a} &= \\pdv{(\\va{r}_{ab}/r_{ab})}{\\va{r}_a} = \\dfrac{1}{r_{ab}}  - \\dfrac{\\va{r}_{ab} \\vdot \\vu{r}_{ab}}{r_{ab}^2} = 0\n\t\\end{align*}\n\t\\begin{align*}\n\t\\implies \\pdv{L_D}{\\va{r}_a} &=  2\\sum_{b\\ne a} \\qty[ - \\dfrac{q_a q_b}{8 \\pi \\epsilon_0 r_{ab}^2} \\vu{r}_{ab} + \\dfrac{q_a q_b \\vu{r}_{ab}}{16 \\pi \\epsilon_0 c^2 r_{ab}^2} \\qty( \\va{u}_a \\vdot \\va{u}_b + (\\va{u}_a \\vdot \\vu{r}_{ab}) (\\va{u}_b \\vdot \\vu{r}_{ab}) )]    \\\\\n\t-q_a \\pdv{\\va{r}_a} (\\phi_a - \\va{u}_a \\vdot \\va{A}_a ) &=  \\sum_{b\\ne a} \\qty[ - \\dfrac{q_a q_b}{4 \\pi \\epsilon_0 r_{ab}^2} \\vu{r}_{ab} + \\dfrac{q_a q_b \\vu{r}_{ab}}{8 \\pi \\epsilon_0 c^2 r_{ab}^2} \\qty( \\va{u}_a \\vdot \\va{u}_b + (\\va{u}_a \\vdot \\vu{r}_{ab}) (\\va{u}_b \\vdot \\vu{r}_{ab}) )]   \\\\\n\t\\implies \\pdv{L_D}{\\va{r}_a} &= -q_a \\pdv{\\va{r}_a} (\\phi_a - \\va{u}_a \\vdot \\va{A}_a ) = -q_a \\grad_a{\\phi_a}  + q_a \\grad_a{(\\va{u}_a \\vdot \\va{A}_a)}\n\t\\end{align*}\n\tNote that, in the first expression, there is an extra factor of $ 2 $ due to the summation over $ a $.\n\t\n\t\\textbf{Part (d)}\\\\\n\tWe write our equations of motion,\n\t\\begin{align*}\n\t\\dv{t} \\qty(\\pdv{L_D}{\\va{u}_a} ) &= \\pdv{L_D}{\\va{r}_a} \\\\\n\t\\dv{\\va{p}_a^{kin}}{t} + q_a \\dot{\\va{A}}_a &= -q_a \\grad_a{\\phi_a}  + q_a \\grad_a{(\\va{u}_a \\vdot \\va{A}_a)}\n\t\\end{align*}\n\tUsing $ \\grad{(\\va{a} \\vdot \\va{b}) } = (\\va{a} \\vdot \\grad) \\va{b} + (\\va{b} \\vdot \\grad) \\va{a} + \\va{a} \\cross (\\curl{\\va{b}}) +  \\va{b} \\cross (\\curl{\\va{a}} )  $,\n\t\\begin{align*}\n\t\\dv{\\va{p}_a^{kin}}{t} + q_a \\partial_t\\va{A}_a + q_a ( \\va{u}_a \\vdot \\grad_a )\\va{A}_a &= -q_a \\grad_a{\\phi_a}  + q_a ((\\va{u}_a \\vdot \\grad_a) \\va{A}_a + (\\va{A}_a \\vdot \\grad_a) \\va{u}_a + \\va{u}_a \\cross (\\curl{\\va{A}_a}) +  \\va{A}_a \\cross (\\curl{\\va{u}_a }) ) \\\\\n\t\\dv{\\va{p}_a^{kin}}{t} + q_a \\partial_t\\va{A}_a &= -q_a \\grad_a{\\phi_a}  + q_a ((\\va{u}_a \\vdot \\grad_a) \\va{A}_a + (\\va{A}_a \\vdot \\grad_a) \\va{u}_a + \\va{u}_a \\cross (\\curl{\\va{A}_a}) +  \\va{A}_a \\cross (\\curl{\\va{u}_a }) )\n\t\\end{align*}\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}\n\t\\textbf{Part (a)}\\\\\n\t\\begin{equation*}\n\tL_{BI} = \\dfrac{B_0^2}{\\mu_0} - \\dfrac{B_0}{\\mu_0} \\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}\n\t\\end{equation*}\n\tWe know that,\n\t\\begin{align*}\n\t\\va{D} = \\pdv{L_{BI}}{\\va{E}} &= - \\dfrac{B_0}{2\\mu_0} \\dfrac{-\\dfrac{2 \\va{E}}{c^2} - \\dfrac{2(\\va{E}\\vdot \\va{B}) \\va{B}}{c^2 B_0^2}}{\\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}} \\\\\n\t\\implies c\\va{D} &=  \\dfrac{B_0}{\\mu_0 c} \\dfrac{{ \\va{E}} + \\dfrac{(\\va{E}\\vdot \\va{B}) \\va{B}}{ B_0^2}}{\\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}} \\\\\n\t\\implies c\\va{D}&= \\eta_E (\\va{E} + \\alpha c \\va{B})\n\t\\end{align*}\n\t\\begin{align*}\n\t\\va{H} = -\\pdv{L_{BI}}{\\va{B}} &=  \\dfrac{B_0}{2 \\mu_0} \\dfrac{{2 \\va{B} - \\dfrac{2  (\\va{E} \\vdot \\va{B}) \\va{E}}{(cB_0)^2}}}{\\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}} \\\\\n\t\\va{H} &= \\dfrac{B_0}{ \\mu_0 c} \\dfrac{{ c\\va{B} - \\dfrac{  (\\va{E} \\vdot \\va{B}) \\va{E}}{cB_0^2}}}{\\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}}\\\\\n\t\\implies \\va{H} &= \\eta_E(c \\va{B} - \\alpha \\va{E})\n \t\\end{align*}\n \tFrom the above expressions, one can write,\n \t\\begin{align*}\n \tc \\va{D} \\vdot \\va{H} &= \\eta_E^2 [- \\alpha\\va{E}^2 + \\alpha c^2 \\va{B}^2 + (1 - \\alpha^2 )c \\va{E} \\vdot \\va{B}] \\\\\n \t&= \\eta_E^2 [- \\alpha\\va{E}^2 + \\alpha c^2 \\va{B}^2 + (1 - \\alpha^2 )c^2 \\alpha B_0^2 ]\\\\\n \t&= \\eta_E^2 (c^2 \\alpha B_0^2 )\\qty[- \\dfrac{\\va{E}^2 }{c^2 B_0^2}+  \\dfrac{\\va{B}^2 }{B_0^2}+ (1 - \\alpha^2 )]\\\\\n \tc \\va{D} \\vdot \\va{H} &= \\eta_E^2 \\va{E} \\vdot \\va{B} c \\dfrac{1}{\\eta_E^2 (\\mu_0 c)^2}\\\\\n \t\\implies  (\\mu_0 c)^2 \\va{D} \\vdot \\va{H} &=\\va{E} \\vdot \\va{B} \\\\\n \t\\implies \\alpha &= \\dfrac{(\\mu_0 c)^2 \\va{D} \\vdot \\va{H}}{c B_0^2}\n \t\\end{align*} \t\n \t\\textbf{Part (b)}\\\\\n \t\\begin{align*}\n \t\\va{D}^2 - \\dfrac{1}{c^2} \\va{H}^2 &= \\dfrac{\\eta_E^2}{c^2} (\\va{E}^2 + \\alpha^2 c^2 \\va{B}^2 + 2 \\alpha c \\va{E} \\vdot \\va{B} - c^2 \\va{B}^2 - \\alpha^2 \\va{E}^2 + 2 \\alpha c \\va{E} \\vdot \\va{B}) \\\\\n \t&= \\dfrac{\\eta_E^2}{c^2} ((1- \\alpha^2)(\\va{E}^2 - c^2 \\va{B}^2) + 4 \\alpha^2 c^2 B_0^2 )\n \t\\end{align*}\n \tBut we know,\n \t\\begin{align*}\n \t\\eta_E = \\dfrac{1}{ \\mu_0 c} \\dfrac{1}{\\sqrt{1 - \\alpha^2 + \\dfrac{1}{B_0^2} \\qty(\\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2)}} \\implies B_0^2 \\qty(\\dfrac{1}{(\\mu_0 c)^2 \\eta_E^2} + \\alpha^2 -1) = \\qty(\\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2) \\\\\n \t\\eta_H = \\dfrac{\\mu_0 c}{\\sqrt{1 - \\alpha^2 + \\qty(\\dfrac{\\mu_0 c}{B_0})^2 \\qty(\\va{D}^2 - \\dfrac{1}{c^2} \\va{H}^2)}} \\implies \\qty[ \\qty(\\dfrac{\\mu_0c}{\\eta_H})^2 + \\alpha^2 -1 ] \\qty(\\dfrac{B_0}{\\mu_0 c})^2 = \\va{D}^2 - \\dfrac{1}{c^2} \\va{H}^2 \n \t\\end{align*}\n \tHence, we can rewrite the expression as,\n \t\\begin{align*}\n\t \\qty[ \\qty(\\dfrac{\\mu_0c}{\\eta_H})^2 + \\alpha^2 -1 ] \\qty(\\dfrac{B_0}{\\mu_0 c})^2  &= - {\\eta_E^2} \\qty((1- \\alpha^2) \\qty[ B_0^2 \\qty(\\dfrac{1}{(\\mu_0 c)^2 \\eta_E^2} + \\alpha^2 -1)] + 4 \\alpha^2 c^2 B_0^2 ) \\\\\n\t \\qty(\\dfrac{\\mu_0c}{\\eta_H})^2 + \\alpha^2 -1   &=  (\\alpha^2 - 1) \\qty[ {1} + {\\eta_E^2}(\\mu_0 c)^2 (\\alpha^2 -1)] - 4 \\alpha^2 c^2 {\\eta_E^2} (\\mu_0 c)^2 \\\\\n\t  \\qty(\\dfrac{\\mu_0c}{\\eta_H})^2   &= (\\mu_0 c)^2 (\\alpha^2 - 1)  {\\eta_E^2} (\\alpha^2 -1) - 4 \\alpha^2 c^2 {\\eta_E^2} \\\\\n\t   \\qty(\\dfrac{1}{\\eta_H})^2   &=  {\\eta_E^2} \\qty[(\\alpha^2 - 1)^2  - {4 \\alpha^2 c^2 }] = \\eta_E^2 (\\alpha^2 + 1)^2\n \t\\end{align*}\n \t\\begin{equation*}\n \t\\qq{Hence,} \\eta_E \\eta_H (1 + \\alpha^2) = 1\n \t\\end{equation*}\n \tWe know, \n \t\\begin{equation*}\n \t\\va{H} = \\eta_E(c \\va{B} - \\alpha \\va{E}) \\qq{and} c\\va{D} = \\eta_E (\\va{E} + \\alpha c \\va{B})\n \t\\end{equation*}\n \tHence,\n \t\\begin{align*}\n \t\\alpha c \\va{D} + \\va{H} = \\eta_E c ( 1 + \\alpha^2 ) \\va{B} &\\implies \\va{B} = {\\eta_H} \\qty({\\alpha  \\va{D} + \\dfrac{\\va{H}}{c}}) \\\\\n \tc \\va{D} - \\alpha \\va{H} = \\eta_E (1 + \\alpha^2 ) \\va{E} &\\implies \\va{E} = \\eta_H (c \\va{D} - \\alpha \\va{H})\n \t\\end{align*}\n \tApplying $ \\dfrac{\\va{E}}{\\mu_0 c} \\leftrightarrow \\va{H}$ and $ \\dfrac{\\va{B}}{\\mu_0 c} \\leftrightarrow \\va{D} $, we have,\n \t\\begin{align*}\n \t\\eta_H = \\dfrac{\\mu_0 c}{\\sqrt{1 - \\alpha^2 + \\qty(\\dfrac{1}{B_0})^2 \\qty(\\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2)}} &= (\\mu_0 c)^2 \\eta_E\\\\\n \t\\dfrac{\\va{E}}{\\mu_0 c} = \\eta_E(\\mu_0 c^2 \\va{D} - \\alpha \\mu_0 c \\va{H}) &\\implies \\va{E} = (\\mu_0 c)^2 \\eta_E(c \\va{D} - \\alpha \\va{H}) = \\eta_H (c \\va{D} - \\alpha \\va{H}) \\\\\n \tc\\dfrac{\\va{B}}{\\mu_0 c} = \\eta_E (\\mu_0 c) (\\va{H} + \\alpha c \\va{D}) &\\implies \\va{B} = {\\eta_H} \\qty({\\alpha  \\va{D} + \\dfrac{\\va{H}}{c}}) \\\\\n \t \\mu_0 c \\va{D} = {\\eta_H} \\dfrac{1}{\\mu_0 c} \\qty({\\alpha  \\va{B} + \\dfrac{\\va{E}}{c}}) &\\implies c\\va{D} = \\eta_E (\\va{E} + \\alpha c \\va{B})\\\\\n \t \\mu_0 c \\va{H} = \\dfrac{\\eta_H}{\\mu_0 c} (c \\va{B} - \\alpha \\va{E}) &\\implies \\va{H} = \\eta_E(c \\va{B} - \\alpha \\va{E})\n \t\\end{align*}\n \tThus, we have shown that BI theory has a duality transformation.\n \t\n \t\\textbf{Part (c)}\\\\\n\t\\begin{align*}\n\t\\delta  L_{BI} =& - \\dfrac{B_0}{2\\mu_0} \\dfrac{1}{\\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}}} \\qty(2 \\va{B} \\vdot \\delta \\va{B} - \\dfrac{2 \\va{E} \\vdot \\delta \\va{E}}{c^2} - \\dfrac{2 \\va{E} \\vdot \\va{B}}{(cB_0)^2} (\\va{B} \\vdot \\delta \\va{E} + \\va{E} \\vdot \\delta \\va{B})) \\\\\n\t&= c \\eta_E (\\va{E} \\vdot \\delta \\va{E} ) = - \\div{\\qty(\\eta_E \\dfrac{\\va{E}}{c} \\delta \\phi)} - \\partial_t \\qty(\\eta_E \\dfrac{\\va{E}}{c} \\vdot \\delta \\va{A}) + \\div{\\qty(\\eta_E \\dfrac{\\va{E}}{c})} + \\partial_t \\qty{\\eta_E \\dfrac{\\va{E}}{c}} \\vdot \\delta \\va{A}\n\t\\end{align*}\n\t\\begin{align*}\n\tc \\eta_E (\\va{E} \\vdot \\delta \\va{E} ) &= - \\div{\\qty(\\eta_E \\dfrac{\\va{E}}{c} \\delta \\phi)} - \\partial_t \\qty(\\eta_E \\dfrac{\\va{E}}{c} \\vdot \\delta \\va{A}) + \\div{\\qty(\\eta_E \\dfrac{\\va{E}}{c})} + \\partial_t \\qty{\\eta_E \\dfrac{\\va{E}}{c}} \\vdot \\delta \\va{A} \\\\\n\t-c \\eta_E (\\va{B} \\vdot \\delta \\va{B} ) &= \\div{(c \\eta_E \\va{B} \\cross \\delta \\va{A})}  = \\delta \\va{A} \\vdot \\curl{c \\eta_E \\va{B}}\\\\\n\t\\eta_E\\alpha \\va{E} \\vdot \\delta \\va{B} &= \\eta_E \\alpha \\va{E} \\vdot \\curl{\\delta \\va{A}} - \\delta \\va{A} \\vdot \\curl{(c \\eta_E \\va{B})}\\\\\n\t\\eta_E\\alpha \\va{B} \\vdot \\delta \\va{E} &= - \\div{(\\eta_E \\alpha \\va{E} \\cross \\delta \\va{A})} - \\partial_t (\\eta_E \\alpha \\va{B} \\vdot \\delta \\va{A})\n\t\\end{align*}\n\t\n \t\\textbf{Part (d)}\\\\\n \tIncluding the point charge,\n \t\\begin{equation*}\n \tL = \\dfrac{B_0^2}{\\mu_0} - \\dfrac{B_0}{2\\mu_0} \\sqrt{B_0^2 + \\va{B}^2 - \\dfrac{1}{c^2} \\va{E}^2  - \\dfrac{(\\va{E} \\vdot \\va{B})^2}{(cB_0)^2}} + \\va{J} \\vdot \\va{A} - \\rho \\phi\n \t\\end{equation*}\n\\end{homeworkProblem}\n\\end{document}\n", "meta": {"hexsha": "69ca778cc6938b91a939848b632c528e2103fd86", "size": 20934, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem2/em/pset2/pset1.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem2/em/pset2/pset1.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem2/em/pset2/pset1.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.9536082474, "max_line_length": 334, "alphanum_fraction": 0.5768606095, "num_tokens": 10101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.4040793053887694}}
{"text": "\\section{IBE and AKE}\n\nThis section aims to describe the IBE and AKE schemes developed as part of the SAFEcrypto project from an implementation perspective. It should be noted that both schemes are almost identical.\n\n\\subsection{Key Generation}\n\nIBE and AKE rely upon the algorithm in Figure \\ref{fig:ibe_keygen} to generate the public key \\textit{h} and \\textit{Master Secret Key \\textbf{B}}. In IBE the \\textit{Extract} function (see Figure \\ref{fig:ibe_extract}) is detached from Key Generation as it is required to derive a secret key for each user from the master key, whilst it is incorporated into AKE's key generation function as it effectively has only one user \\textit{id} (see Figure \\ref{fig:ake_digital_signature}).\n\nThe key generation function is quite involved. The principle operations involve repeated trials of the randomly generated keys \\textit{(f, g)} with Extended GCD and GCD functions until co-prime relationships have been found. An added complexity of this step is the need to compute the GCD's using large integer arithmetic in order to obtain an integer GCD and Bezout coefficients.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=11cm]{ibe_keygen.png}\n\\caption{IBE KeyGen}\n\\label{fig:ibe_keygen}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=11cm]{ibe_extract.png}\n\\caption{IBE Extract}\n\\label{fig:ibe_extract}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=9cm]{ake_hash_and_sign.png}\n\\caption{Whole is less... Digital Signature Scheme}\n\\label{fig:ake_digital_signature}\n\\end{figure}\n\n\\subsection{IBE Encrypt and Decrypt}\n\nThe IBE encrypt and decrypt operations involve mapping binary bits onto the lattice and recovering them - in a similar manner to the RLWE encryption scheme. It should be noted that this scheme uses large modulus values to reduce the failure probability of the encryption operation - therefore decryption failures should be expected at a negligible rate during any testing of the scheme.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=14cm]{ibe_encrypt.png}\n\\caption{IBE Encrypt}\n\\label{fig:ibe_encrypt}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=14cm]{ibe_decrypt.png}\n\\caption{IBE Decrypt}\n\\label{fig:ibe_decrypt}\n\\end{figure}\n\n\\subsection{Extract and Signing}\n\nAKE signing is almost identical to IBE extract, both requiring Gaussian Sampling over a lattice.\n\n\\subsection{AKE Signatures with Message Recovery}\n\nAKE also defines a \\textit{Signature with Message Recovery} scheme (see Figure \\ref {fig:ake_signature_with_recovery}) that can be used to produce smaller signatures at the cost of more CPU cycles. Instead of sending the signature as $(s_1, m)$ and recovering $s_2$, it is instead transmitted as $(s_1, s_2)$ and the message $m$ is recovered by the verifier.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=11cm]{ake_with_message_recovery.png}\n\\caption{Whole is less... Digital Signature Scheme with Message Recovery}\n\\label{fig:ake_signature_with_recovery}\n\\end{figure}\n\n\n\\subsection{Software Implementation}\n\nThe generic AKE scheme shown in Figure \\ref{fig:generic_ake} indicates that the signature keys are typically generated once whilst the KEM keys are generated on a per-session basis. Therefore the complexity of AKE \\textit{SigKeyGen} should not be a burden as it can effectively be treated as an off-line computation. Real performance gains in a system will be achieved by optimising the regularly used \\textit{Sign, Verify, KEMKeyGen, Encapsulate} and \\textit{Decapsulate} operations. Similarly for IBE, the regularly used \\textit{Extract, Encrypt} and \\textit{Decrypt} functions should be the focus of optimisation.\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=9cm]{ake_kem.png}\n\\caption{AKE KEM}\n\\label{fig:ake_kem}\n\\end{figure}\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=7cm]{generic_ake.png}\n\\caption{A Generic AKE Construction from a KEM and a Digital Signature}\n\\label{fig:generic_ake}\n\\end{figure}\n\nThe main areas of work that are foreseen in implementing both IBE and AKE within the SAFEcrypto library are the following:\n\n\\begin{enumerate}[1]\n\\item A generic implementation of the IBE \\textit{Master\\_Keygen} function to be used by both IBE and AKE.\n\\begin{enumerate}[a]\n\\item Big integer arithmetic functions (add/sub, multiply, divide, GCD) [currently using GMP, libtommath has been added to the build system].\n\\item XGCD with integer polynomial coefficients (NTL and FLINT have this function and can be used as a reference).\n\\end{enumerate}\n\\item Implementing a discrete Gaussian Sampling scheme over a lattice using the polynomial basis \\textit{\\textbf{B}}, i.e. IBE Extract and AKE SigKeyGen.\n\\item Verifying the correctness of the already implemented AKE KEM as one of the parameter sets appears to be incorrect.\n\\item Acceleration of the Whole KEM scheme, in particular inversion modulo 2 used in \\textit{KEMKeyGen}.\n\\item Re-factoring the RLWE Encryption encrypt/decrypt source code for IBE encrypt/decrypt.\n\\end{enumerate}\n", "meta": {"hexsha": "8f1fbe5eaeaefd7c7410078a5763f321eb694806", "size": 5012, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/SAD/ibe_and_ake.tex", "max_stars_repo_name": "simonjj22/libsafecrypto", "max_stars_repo_head_hexsha": "3717bec9d9298f163f45acd5af54d708e03e0b9f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/SAD/ibe_and_ake.tex", "max_issues_repo_name": "simonjj22/libsafecrypto", "max_issues_repo_head_hexsha": "3717bec9d9298f163f45acd5af54d708e03e0b9f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/SAD/ibe_and_ake.tex", "max_forks_repo_name": "simonjj22/libsafecrypto", "max_forks_repo_head_hexsha": "3717bec9d9298f163f45acd5af54d708e03e0b9f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.6701030928, "max_line_length": 616, "alphanum_fraction": 0.795490822, "num_tokens": 1238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.5273165233795672, "lm_q1q2_score": 0.4040792997599512}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[usenames]{color} %used for font color\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{wasysym}\n\\usepackage[utf8]{inputenc} %useful to type directly diacritic characters\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{float}\n\\usepackage{mathtools}\n\\usepackage [english]{babel}\n\\usepackage [autostyle, english = american]{csquotes}\n\\MakeOuterQuote{\"}\n\\graphicspath{ {./} }\n\\newcommand{\\Z}{\\mathbb{Z}}\n\\newcommand{\\N}{\\mathbb{N}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\Q}{\\mathbb{Q}}\n\\newcommand{\\prob}{\\mathbb{P}}\n\\newcommand{\\degrees}{^{\\circ}}\n\\DeclarePairedDelimiter\\ceil{\\lceil}{\\rceil}\n\\DeclarePairedDelimiter\\floor{\\lfloor}{\\rfloor}\n\n\\author{Tianshuang (Ethan) Qiu}\n\\begin{document}\n\\title{Math 74, Week 15}\n\\maketitle\n\n\\section{Mon Lec, 2b}\n$g_2 = \\sqrt{a_1a_2}$, so $(1+g_2)^2 = 1 + a_1a_2 + 2\\sqrt{a_1a_2}$\n\\newline\nOur left hand side should be $(1+a_1)(1+a_2) = 1 + a_1a_2 + a_1 + a_2$. By Am-GM, $LHS \\geq RHS$\n\\newline\nNow we consider 3 elements. $g_3 = \\sqrt[3]{a_1a_2a_3}$, and $(1+g_3)^3 = 1 + a_1a_2a_3 + 3\\sqrt[3]{a_1a_2a_3} + 3(a_1a_2a_3)^{2/3}$.\n\\newline\nNow LHS has $(1+a_1)(1+a_2)(1+a_3) = 1 + a_1 + a_2 + a_3 + a_1a_2 + a_1a_3 + a_2a_3 + a_1a_2a_3 $\nHere we can cancel the $1$ on both sides, and by AM-GM we have $a_1+a_2+a_3 \\geq 3\\sqrt[3]{a_1a_2a_3}$. Now let the three terms be $a_1a_2$, $ a_1a_3$, and $ a_2a_3$. By AM-GM we have $a_1a_2 + a_1a_3 + a_2a_3 \\geq 3 \\sqrt[3]{a_1^2a_2^2a_3^2}$.\n\\newline\nThus we have shown that $LHS \\geq RHS$ term by term.\n\n\n\\section{Mon Lec, 3c}\nSince our plane passes through the point $(5,9,12)$, we know that the equation of a plane can be given by $\\frac{x}{r} +\n\\frac{y}{s} + \\frac{z}{t} = 1$.\nFurthermore we have $\\frac{5}{r} + \\frac{9}{s} + \\frac{12}{t} = 1$. Now we apply the Hamonic Mean-GM inequality:\n$$\\frac{3}{\\frac{5}{r} + \\frac{9}{s} + \\frac{12}{t}} \\leq \\sqrt[3]{\\frac{rst}{540}}$$\nNow from the equation of the plane we know that $LHS = 3$, so now $\\sqrt[3]{\\frac{rst}{540}} \\geq 3$, $\\frac{rst}{540} \\geq 27$\nFinally, since the volume of this terahedron is equal to $\\frac{1}{2}rst$, we know that $V \\geq 7290$.\n\\newline\nWhen the terms $\\frac{5}{r}, \\frac{9}{s},\\frac{12}{t}$ are equal, we have $V = 7290$. Furthermore their sum is equal to 1. Therefore they are eaech a third. $r = 15, s = 27, t = 36$.\n\\newpage\n\n\n\\section{Mon Dis, 5c}\nIf two functions are convex, then their second derivatives must be non-negative. Then the sum must have a second derivatie that i also non-negative. Therefore this sum must also be convex.\n\n\\newpage\n\n\\section{Wed Lec, 2}\n\\subsection{c}\n$g(0)=1$, $g(1) = 1$. The second derivative of $\\frac{1}{x+1}$ is $\\frac{1}{(x+1)^3}$, which on the domain of $[0,1]$, is positive. The second half to the function is linear and therefore convex. The sum of two convex functions is also convex, thus $g$ is convex on $[0,1]$\n\\newline\nBy the convex function theorem the maximum of $g$ on $[0,1]$ is $1$, so $g(x)\\leq 1$.\n\n\\subsection{e}\nWe can first fix $b, c$ in $[0,1]$, in this case our function consists of a constant, a linear function, and two convex functions (from $c$ we know that the second derivative of fractional functions is positive).\nThus by our theorem that the sum of convex functions is convex, the original function is also convex.\n\\newline\nNow we find the values of these functions at the end points: $f(0) = 1, f(1) = 1$. The above is true also for fixed $a,b$ or $a,c$, thus the original is maximized when they are either $0$ or $1$. Finally we can use the convex theorem to state that the original function must be less than or equal to $1$ on the domain $[0,1]$.\n\n\n\\section{Wed Lec, 4}\n\\subsection{b}\n$f(x) = \\frac{1}{x}$. Its second derivative is positive for $x>0$. By JI,\n$$\\frac{f(x_1)+f(x_2)+...+f(x_n)}{n} \\geq f(\\frac{x_1+x_2+...+x_n}{n})$$\n$$\\frac{\\frac{1}{x_1}+...+\\frac{1}{x_n}}{n} \\geq \\frac{n}{x_1+x_2+...+x_n}$$\nThe above inequality is equivalent to\n$$\\frac{n}{\\frac{1}{x_1}+...+\\frac{1}{x_n}} \\leq \\frac{x_1+x_2+...+x_n}{n}$$\n, which is true due to the Arithmetic-Harmonic mean inequality.\n\n\\subsection{c}\n$f(x) = x^{7/3}$. Its second derivative is positive for $x>0$. By JI,\n$$\\frac{f(x_1)+f(x_2)+...+f(x_n)}{n} \\geq f(\\frac{x_1+x_2+...+x_n}{n})$$\n$$\\frac{x_1^{\\frac{7}{3}} + ... x_n^{\\frac{7}{3}}}{n} \\geq (\\frac{x_1+x_2+...+x_n}{n})^{\\frac{7}{3}}$$\nThe above inequality is equivalent to\n$$(\\frac{x_1^{\\frac{7}{3}} + ... x_n^{\\frac{7}{3}}}{n})^{\\frac{3}{7}}\\geq \\frac{x_1+x_2+...+x_n}{n}$$\n, which is true due to the Arithmetic-Power mean inequality. This power mean is equal to $\\frac{7}{3} > 1$, so it is greater than or equal to the arithmetic mean.\n\n\\section{Wed Lec, 5c}\nPer the algebraic definition for convex functions: $(\\lambda x_1+(1- \\lambda)x_2) \\geq \\lambda f(x_1)+(1- \\lambda)f(x_2)$\nBy our assumption $\\frac{f(x_1)+f(x_2)+f(x_3)+f(x_4)}{4} \\geq f(\\frac{x_1+x_2+x_3+x_4}{4})$\n\\newline\n$\\frac{x_1+x_2+x_3+x_4+x_5}{5} = \\frac{4}{5}\\frac{x_1+x_2+x_3+x_4}{4} + \\frac{x_5}{5}$. let $\\lambda = \\frac{4}{5}$, and since the function is convex we have\n$$f(\\frac{x_1+x_2+x_3+x_4+x_5}{5}) = \\lambda f(y_1)+(1- \\lambda)f(y_2) \\leq (\\lambda f(y_1)+(1- \\lambda)f(y_2))$$\n$$ = \\frac{4}{5}f(x_1+x_2+x_3+x_4) + \\frac{1}{5}f(x_5) $$\nNow by our inductive hypothesis the last term is less than or equal to $\\frac{4}{5}\\frac{f(x_1)+f(x_2)+f(x_3)+f(x_4)}{4} + \\frac{f(x_5)}{5} = \\frac{f(x_1)+f(x_2)+f(x_3)+f(x_4)+f(x_5)}{5}$\nThus we have shown that\n$$f(\\frac{x_1+x_2+x_3+x_4+x_5}{5}) \\leq \\frac{f(x_1)+f(x_2)+f(x_3)+f(x_4)+f(x_5)}{5}$$\nAnd our proof is complete.\n\\newpage\n\n\\section{Wed Dis, 3a}\nWe know that both sides of the equation is positive, so the inequality is equivalent to us taking the natural log of both sides\n$$\\ln{x^x} \\geq \\ln{(\\frac{x+1}{2})^{x+1}}$$\n$$x \\ln{x} \\geq (x+1)\\ln{\\frac{x+1}{2}}$$\nNow consider the function $y\\ln(y)$ and two values $1, x$. By Jensen's inequality we have $(\\ln(1)+x\\ln(x))/2 \\geq \\frac{x+1}{2}\\ln\\frac{x+1}{2}$, which is identical to our initial statement when we multiply both sides by 2.\n\n\\newpage\n\n\\section{Friday Lec, 2}\n\\subsection{a}\n$x_1 = 10, x_2 = 36, x_3 = 74$.\n$$AM = \\frac{x_1+x_2+x_3}{3} = 40$$\n$$HM = \\frac{3}{\\frac{1}{10} + \\frac{1}{36} + \\frac{1}{74}} = \\frac{19980}{941} \\approx 21.2 < AM$$\nProperty holds.\n\n\\subsection{b}\n$$x_1 = 10, x_2 = 36, x_3 = 74, AM = 40, HM \\approx 21.2$$\n$$x_1 = 10, x_2 = 40, x_3 = 70, AM = 40, HM \\approx 21.5$$\n$$x_1 = 40, x_2 = 40, x_3 = 40, AM = 40, HM = 40$$\nPerformed this operation twice.\n\n\\subsection{c}\nGiven $x_1<a<x_2$, we compute $x_1+x_2-a+a = x_1+x_2$. Therefore the sum of these two before and after the operation is the same, and the arithmetic change remains constant.\n\\newline\nNow consider $\\frac{1}{x_1}+\\frac{1}{x_2} = \\frac{x_1+x_2}{x_1x_2}$. $\\frac{1}{a}+\\frac{1}{x_1+x_2-a} = \\frac{x_1+x_1}{x_1a+x_2a-a^2}$. In order to compare the size of the denominators, we take their difference: $x_1x_2 -(x_1a+x_2a-a^2) = (x_1)(x_2-a) - a(x_2-a) = (x_2-a)(x_1-a) $. Since $x_1<a<x_2$, the difference is negative.\nThus the denominator of the latter is larger, so $\\frac{1}{x_1}+\\frac{1}{x_2}>\\frac{1}{a}+\\frac{1}{x_1+x_2-a}$\n\n\\subsection{d}\nThis smoothing proccess eventually stops when all terms are equal to the arithmetic mean, or when all the terms are the same. This process means that for any number, we have a process in which we can inrease its harmonic mean and eventually be equal to the arithmetic mean.\nThis process implies that the harmonic mean is less than or equal to the arithmetic mean, otherwise this process would have been erroneous. Therefore it proves the AM-HM inequality.\n\\end{document}\n", "meta": {"hexsha": "130fb49b4fa31bb4da58751643b6607e1d87a018", "size": 7616, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "week15/main.tex", "max_stars_repo_name": "TianshuangQiu/Math74-Homework", "max_stars_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week15/main.tex", "max_issues_repo_name": "TianshuangQiu/Math74-Homework", "max_issues_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week15/main.tex", "max_forks_repo_name": "TianshuangQiu/Math74-Homework", "max_forks_repo_head_hexsha": "89f1c999b9744af6062185ab91834887a81ca3d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.2631578947, "max_line_length": 329, "alphanum_fraction": 0.6684611345, "num_tokens": 3042, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165085228825, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.40407928837536816}}
{"text": "\\documentclass[11pt]{article}\n%\\usepackage{fancyheadings}\n\\usepackage{wrapfig}\n\\usepackage{epsfig}\n\\usepackage{hyperref}\n\\setlength{\\headheight}{0pt}\n%\\setlength{\\footheight}{0pt}\n\\setlength{\\topmargin}{-.5in}\n\\setlength{\\oddsidemargin}{-0.25in}\n\\setlength{\\evensidemargin}{-0.25in}\n\\setlength{\\textwidth}{7truein}\n\\setlength{\\textheight}{9truein}\n\\setlength{\\parskip}{6pt}\n\n\\begin{document}\n\n\\section*{Social Distancing}\n\n%\\subsection*{Description}\n\n\\begin{wrapfigure}{r}{3in}\n\\vspace{-10pt}\n\\epsfig{figure=restaurant,width=3in}\n\\vspace{-30pt}\n\\end{wrapfigure}\n\nYou own a restaurant, and you want your customers to be as happy as possible. You've learned over the years that customers really don't like sitting very close to each other. They prefer if others cannot hear their conversations. This however, is a pretty hard problem, so you've decided to construct an algorithm that can figure out where to seat your patrons to maximize the distance between them.\n\nYour restaurant is in an old building, and thus has a peculiar shape. The restuarant is very long and not very wide (it was the cheapest space available for lease!). Because of this your tables are all in a horizontal line down your restaurant, but the distances between the tables vary. Given a list of the positions of the tables in your restaurant, and the number of patrons that wish to be seated, return the maximum distance between any two of the patrons after being seated in the optimal arrangement.\n\n\\subsection*{Input}\nThe input file will begin with one line containing $n \\leq 10^6$ and $p \\leq 10^6$, the number of tables in your restaurant and the number of patrons to sit respectively. The following $n$ lines will each contain a single integer $l_i \\leq 10^8$ describing the integer position of table $i$. These positions will be sorted in increasing order. All positions will be unique.\n\n\\subsection*{Output}\nOutput the largest possible value of the minimum distance between patrons after being seated in the optimal seating arrangement.\n\n\n\n\\vspace{0.25in}\\hspace{-0.3in}\\begin{tabular}{ll}\n\n%\\subsection*{Sample Input}\n\\parbox{3in}{{\\large\\bf Sample Input}\n\n\\vspace{0.15in}\n\n{\\tt \n5 3\\linebreak\n1\\linebreak\n2\\linebreak\n4\\linebreak\n8\\linebreak\n9\n}\n}\n\n&\n\n\\parbox{3in}{{\\large\\bf Sample Output}\n\n\\vspace{0.15in}\n\n{\\tt\n3\n}\n}\n\n\\\\\n\\end{tabular}\n\n\\end{document}\n", "meta": {"hexsha": "50774eaf4a5bc00ccd488fb847988c47899fa8d6", "size": 2336, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homeworks/divideconq-advanced/seating.tex", "max_stars_repo_name": "csonmezyucel/cs4102-f21", "max_stars_repo_head_hexsha": "75f93b5801644e50cb512f9d00e0fda3e9d5dcf7", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homeworks/divideconq-advanced/seating.tex", "max_issues_repo_name": "csonmezyucel/cs4102-f21", "max_issues_repo_head_hexsha": "75f93b5801644e50cb512f9d00e0fda3e9d5dcf7", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homeworks/divideconq-advanced/seating.tex", "max_forks_repo_name": "csonmezyucel/cs4102-f21", "max_forks_repo_head_hexsha": "75f93b5801644e50cb512f9d00e0fda3e9d5dcf7", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-01-31T21:10:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-29T23:06:24.000Z", "avg_line_length": 32.9014084507, "max_line_length": 507, "alphanum_fraction": 0.7688356164, "num_tokens": 632, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093882168609, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.4040647707377195}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{October 2 2018}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\n\\begin{document}\n\n\\maketitle\n\nExamples:\n\\begin{enumerate}\n  \\item Let \\[f(x, y) = \\int_a^{x + y}g\\] where \\(g: \\reals \\to \\reals\\) is continuous. We compute \\(Df(c, d)\\) as follows:\n  We have that \\(f = q \\circ s\\), where\n  \\[q(t) = \\int_a^tg, s(x, y) = x + y\\]\n  We have\n  \\[Df(c, d) =  g'(s(c, d))s'(c, d) = g(c + d)(c + d)\\]\n  since \\(q'(t) = g(t)\\).\n\n  \\item Let \\[f(x, y) = \\int_a^{x^y}g\\] We have\n  \\[f = g \\circ \\xi, \\xi(x, y) = x^y = e^{y\\log x}\\]\n  Hence,\n  \\[D\\xi(x, y) = x^yD(y\\log x) = x^y((0, 1)\\log x + (1/x, 0)y) = x^y(y/x, \\log x)\\]\n  \\[\\implies Df(c, d) = q'(\\xi(c, d))\\xi'(c, d) = g(c^d)c^d(d/c, \\log c)\\]\n\\end{enumerate}\n\n\\section*{Higher-order Derivatives}\nLet \\(f: U \\to \\reals\\) be a function where \\(U \\subseteq \\reals^m\\) and suppose\n\\[D_if = \\prt{f}{x_i}: U \\to \\reals\\]\nexists for all \\(i\\). So we could now consider\n\\[D_j(D_if) = \\prt{}{x_j}\\left(\\prt{f}{x_i}\\right)\\]\nWe'll write \\(D_{ij}f\\) to denote the above. Notice \\(i\\) is applied \\textit{first}. We may also write \\(f_{x_ix_j}\\) and \\(\\frac{\\partial^2 f}{\\partial x_j \\partial x_i}\\). We have that\n\\[\\frac{\\partial^2 f}{\\partial x_j \\partial x_i}(a) = \\frac{\\partial^2 f}{\\partial x_i \\partial x_j}(a)\\]\nif both mixed partials exist and are continuous in a neighborhood of \\(a\\) (proof uses \\(\\int\\)).\n\nIn general, we can consider taking higher order partials as well, as in\n\\[\\frac{\\partial^{\\alpha_1 + ... + \\alpha_n}f}{\\partial x_1^{\\alpha_1} ... \\partial x_n^{\\alpha_n}}\\]\nOf course we have to worry about the order, but the order is irrelevant if \\(f\\) is \\(\\mc{C}^\\infty\\), i.e. that all partial derivatives of all orders exist (and are hence continuous).\n\n\\section*{Multi-index notation}\nIn multi-index notation, \\(\\alpha = (\\alpha_1,...,\\alpha_m)\\) is a vector of non-negative integers. We define the \\textit{total order of \\(\\alpha\\)}\n\\[|\\alpha| = \\alpha_1 + ... + \\alpha_m\\]\nFurthermore, we define\n\\[x = (x_1,...,x_m) \\implies x^\\alpha = x_1^{\\alpha_1}...x_m^{\\alpha_m}\\]\nOnce we look at Taylor's theorem, the notation\n\\[x! = x_1!...x_m!\\]\nwill also come in handy.\n\nWe can now perform another example:\n\\begin{itemize}\n\n  \\item [3.] Let\n  \\[f(x, y) = \\left\\{\\begin{array}{cc}\n    xy\\frac{x^2 - y^2}{x^2 + y^2} & (x, y) \\neq (0, 0) \\\\\n    0 & (x, y) = (0, 0)\n  \\end{array}\\right.\\]\n  Is this function differentiable at the origin? Yes: \\(f'(0, 0) = (0, 0)\\). Let's check: we need to show that\n  \\[\\lim_{(x, y) \\to (0, 0)}\\frac{f(x, y) - f(0, 0) - \\cancel{(0, 0)\\begin{pmatrix} x \\\\ y \\end{pmatrix}}}{\\sqrt{x^2 + y^2}} = \\lim_{(x, y) \\to (0, 0)}xy\\frac{x^2 - y^2}{x^2 + y^2}\\frac{1}{\\sqrt{x^2 + y^2}} = 0\\]\n  We have that\n  \\[\\left|xy\\frac{x^2 - y^2}{x^2 + y^2}\\frac{1}{\\sqrt{x^2 + y^2}}\\right| \\leq \\frac{|xy|}{\\sqrt{x^2 + y^2}} \\to 0\\]\n\n\\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "176d1a3c82a6d39d9a376b7d66d59ad6510cfd2b", "size": 3646, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/october2.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/october2.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/october2.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.2043010753, "max_line_length": 212, "alphanum_fraction": 0.6187602852, "num_tokens": 1462, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.4040647565650411}}
{"text": "\\subsection{Random Forests}\n\\label{random_forests}\n\n\\noindent{\\bf Description}\n\\smallskip\n\n\nRandom forest is one of the most successful machine learning methods for classification and regression. \nIt is an ensemble learning method that creates a model composed of a set of tree models.\nThis implementation is well-suited to handle large-scale data and builds a random forest model for classification in parallel.\\\\\n\n\n\\smallskip\n\\noindent{\\bf Usage}\n\\smallskip\n\n{\\hangindent=\\parindent\\noindent\\it%\n\t{\\tt{}-f }path/\\/{\\tt{}random-forest.dml}\n\t{\\tt{} -nvargs}\n\t{\\tt{} X=}path/file\n\t{\\tt{} Y=}path/file\n\t{\\tt{} R=}path/file\n\t{\\tt{} bins=}integer\n\t{\\tt{} depth=}integer\n\t{\\tt{} num\\_leaf=}integer\n\t{\\tt{} num\\_samples=}integer\n\t{\\tt{} num\\_trees=}integer\n\t{\\tt{} subsamp\\_rate=}double\n\t{\\tt{} feature\\_subset=}double\n\t{\\tt{} impurity=}Gini$\\mid$entropy\n\t{\\tt{} M=}path/file\n\t{\\tt{} C=}path/file\n\t{\\tt{} S\\_map=}path/file\n\t{\\tt{} C\\_map=}path/file\n\t{\\tt{} fmt=}format\n\t\n}\n\n \\smallskip\n \\noindent{\\bf Usage: Prediction}\n \\smallskip\n \n {\\hangindent=\\parindent\\noindent\\it%\n \t{\\tt{}-f }path/\\/{\\tt{}random-forest-predict.dml}\n \t{\\tt{} -nvargs}\n \t{\\tt{} X=}path/file\n \t{\\tt{} Y=}path/file\n \t{\\tt{} R=}path/file\n \t{\\tt{} M=}path/file\n \t{\\tt{} C=}path/file\n \t{\\tt{} P=}path/file\n \t{\\tt{} A=}path/file\n \t{\\tt{} OOB=}path/file\n \t{\\tt{} CM=}path/file\n \t{\\tt{} fmt=}format\n \t\n }\\smallskip\n \n \n\\noindent{\\bf Arguments}\n\\begin{Description}\n\t\\item[{\\tt X}:]\n\tLocation (on HDFS) to read the matrix of feature vectors; \n\teach row constitutes one feature vector. Note that categorical features in $X$ need to be both recoded and dummy coded.\n\t\\item[{\\tt Y}:]\n\tLocation (on HDFS) to read the matrix of (categorical) \n\tlabels that correspond to feature vectors in $X$. Note that classes are assumed to be both recoded and dummy coded. \n\tThis argument is optional for prediction. \n\t\\item[{\\tt R}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to read matrix $R$ which for each feature in $X$ contains column-ids (first column), start indices (second column), and end indices (third column).\n\tIf $R$ is not provided by default all features are assumed to be continuous-valued.   \n\t\\item[{\\tt bins}:] (default:\\mbox{ }{\\tt 20})\n\tNumber of thresholds to choose for each continuous-valued feature (determined by equi-height binning). \n\t\\item[{\\tt depth}:] (default:\\mbox{ }{\\tt 25})\n\tMaximum depth of the learned trees in the random forest model\n\t\\item[{\\tt num\\_leaf}:] (default:\\mbox{ }{\\tt 10})\n\tParameter that controls pruning. The tree\n\tis not expanded if a node receives less than {\\tt num\\_leaf} training examples.\n\t\\item[{\\tt num\\_samples}:] (default:\\mbox{ }{\\tt 3000})\n\tParameter that decides when to switch to in-memory building of the subtrees in each tree of the random forest model. \n\tIf a node $v$ receives less than {\\tt num\\_samples}\n\ttraining examples then this implementation switches to an in-memory subtree\n\tbuilding procedure to build the subtree under $v$ in its entirety.\n\t\\item[{\\tt num\\_trees}:] (default:\\mbox{ }{\\tt 10})\n\tNumber of trees to be learned in the random forest model\n\t\\item[{\\tt subsamp\\_rate}:] (default:\\mbox{ }{\\tt 1.0})\n\tParameter controlling the size of each tree in the random forest model; samples are selected from a Poisson distribution with parameter {\\tt subsamp\\_rate}.\n\t\\item[{\\tt feature\\_subset}:] (default:\\mbox{ }{\\tt 0.5})\n\tParameter that controls the number of feature used as candidates for splitting at each tree node as a power of the number of features in the data, i.e., assuming the training set has $D$ features $D^{\\tt feature\\_subset}$ are used at each tree node.\n\t\\item[{\\tt impurity}:] (default:\\mbox{ }{\\tt \"Gini\"})\n\tImpurity measure used at internal nodes of the trees in the random forest model for selecting which features to split on. Possible value are entropy or Gini.\n\t\\item[{\\tt M}:] \n\tLocation (on HDFS) to write matrix $M$ containing the learned random forest (see Section~\\ref{sec:decision_trees} and below for the schema) \n\t\\item[{\\tt C}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to store the number of counts (generated according to a Poisson distribution with parameter {\\tt subsamp\\_rate}) for each feature vector. Note that this argument is optional. If Out-Of-Bag (OOB) error estimate needs to be computed this parameter is passed as input to {\\tt random-forest-predict.dml}. \n\t\\item[{\\tt A}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to store the testing accuracy (\\%) from a \n\theld-out test set during prediction. Note that this argument is optional.\n\t\\item[{\\tt OOB}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to store the Out-Of-Bag (OOB) error estimate of the training set. Note that the matrix of sample counts (stored at {\\tt C}) needs to be provided for computing OOB error estimate. Note that this argument is optional.\n\t\\item[{\\tt P}:] \n\tLocation (on HDFS) to store predictions for a held-out test set\n\t\\item[{\\tt CM}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to store the confusion matrix computed using a held-out test set. Note that this argument is optional.\n\t\\item[{\\tt S\\_map}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to write the mappings from the continuous-valued feature-ids to the global feature-ids in $X$ (see below for details). Note that this argument is optional.\n\t\\item[{\\tt C\\_map}:] (default:\\mbox{ }{\\tt \" \"})\n\tLocation (on HDFS) to write the mappings from the categorical feature-ids to the global feature-ids in $X$ (see below for details). Note that this argument is optional.\n\t\\item[{\\tt fmt}:] (default:\\mbox{ }{\\tt \"text\"})\n\tMatrix file output format, such as {\\tt text}, {\\tt mm}, or {\\tt csv};\n\tsee read/write functions in SystemML Language Reference for details.\n\\end{Description}\n\n\n \\noindent{\\bf Details}\n \\smallskip\n\nRandom forests~\\cite{Breiman01:rforest} are learning algorithms for ensembles of decision trees. \nThe main idea is to build a number of decision trees on bootstrapped training samples, i.e., by taking repeatedly samples from a (single) training set. \nMoreover, instead of considering all the features when building the trees only a random subset of the features---typically $\\approx \\sqrt{D}$, where $D$ is the number of features---is chosen each time a split test at a tree node is performed. \nThis procedure {\\it decorrelates} the trees and makes it less prone to overfitting. \nTo build decision trees we utilize the techniques discussed in Section~\\ref{sec:decision_trees} proposed in~\\cite{PandaHBB09:dtree}; \nthe implementation details are similar to those of the decision trees script.\nBelow we review some features of our implementation which differ from {\\tt decision-tree.dml}.\n\n\n\\textbf{Bootstrapped sampling.} \nEach decision tree is fitted to a bootstrapped training set sampled with replacement (WR).  \nTo improve efficiency, we generate $N$ sample counts according to a Poisson distribution with parameter {\\tt subsamp\\_rate},\nwhere $N$ denotes the total number of training points.\nThese sample counts approximate WR sampling when $N$ is large enough and are generated upfront for each decision tree.\n\n\n\\textbf{Bagging.}\nDecision trees suffer from {\\it high variance} resulting in different models whenever trained on a random subsets of the data points.  \n{\\it Bagging} is a general-purpose method to reduce the variance of a statistical learning method like decision trees.\nIn the context of decision trees (for classification), for a given test feature vector \nthe prediction is computed by taking a {\\it majority vote}: the overall prediction is the most commonly occurring class among all the tree predictions.\n\n \n\\textbf{Out-Of-Bag error estimation.} \nNote that each bagged tree in a random forest model is trained on a subset (around $\\frac{2}{3}$) of the observations (i.e., feature vectors).\nThe remaining ($\\frac{1}{3}$ of the) observations not used for training is called the {\\it Out-Of-Bag} (OOB) observations. \nThis gives us a straightforward way to estimate the test error: to predict the class label of each test observation $i$ we use the trees in which $i$ was OOB.\nOur {\\tt random-forest-predict.dml} script provides the OOB error estimate for a given training set if requested.  \n\n\n\\textbf{Description of the model.} \nSimilar to decision trees, the learned random forest model is presented in a matrix $M$  with at least 7 rows.\nThe information stored in the model is similar to that of decision trees with the difference that the tree-ids are stored\nin the second row and rows $2,3,\\ldots$ from the decision tree model are shifted by one. See Section~\\ref{sec:decision_trees} for a description of the model.\n\n\n\\smallskip\n\\noindent{\\bf Returns}\n\\smallskip\n\n\nThe matrix corresponding to the learned model is written to a file in the format specified. See Section~\\ref{sec:decision_trees} where the details about the structure of the model matrix is described.\nSimilar to {\\tt decision-tree.dml}, $X$ is split into $X_\\text{cont}$ and $X_\\text{cat}$. \nIf requested, the mappings of the continuous feature-ids in $X_\\text{cont}$ (stored at {\\tt S\\_map}) as well as the categorical feature-ids in $X_\\text{cat}$ (stored at {\\tt C\\_map}) to the global feature-ids in $X$ will be provided. \nThe {\\tt random-forest-predict.dml} script may compute one or more of\npredictions, accuracy, confusion matrix, and OOB error estimate in the requested output format depending on the input arguments used. \n \n\n\n\\smallskip\n\\noindent{\\bf Examples}\n\\smallskip\n\n{\\hangindent=\\parindent\\noindent\\tt\n\t\\hml -f random-forest.dml -nvargs X=/user/biadmin/X.mtx Y=/user/biadmin/Y.mtx\n\tR=/user/biadmin/R.csv M=/user/biadmin/model.csv\n\tbins=20 depth=25 num\\_leaf=10 num\\_samples=3000 num\\_trees=10 impurity=Gini fmt=csv\n\t\n}\\smallskip\n\n\n\\noindent To compute predictions:\n\n{\\hangindent=\\parindent\\noindent\\tt\n\t\\hml -f random-forest-predict.dml -nvargs X=/user/biadmin/X.mtx Y=/user/biadmin/Y.mtx R=/user/biadmin/R.csv\n\tM=/user/biadmin/model.csv P=/user/biadmin/predictions.csv\n\tA=/user/biadmin/accuracy.csv CM=/user/biadmin/confusion.csv fmt=csv\n\t\n}\\smallskip\n\n\n%\\noindent{\\bf References}\n%\n%\\begin{itemize}\n%\\item B. Panda, J. Herbach, S. Basu, and R. Bayardo. \\newblock{PLANET: massively parallel learning of tree ensembles with MapReduce}. In Proceedings of the VLDB Endowment, 2009.\n%\\item L. Breiman. \\newblock{Random Forests}. Machine Learning, 45(1), 5--32, 2001.\n%\\end{itemize}\n", "meta": {"hexsha": "553939194ea5a9f14edcaa79d1acfb53bcf0a082", "size": 10348, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "system-ml/docs/Algorithms Reference/RandomForest.tex", "max_stars_repo_name": "alcedo/systemml", "max_stars_repo_head_hexsha": "4d371a6d6b52e5517b1411302af3fdd8cd3c156a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-03-17T18:03:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-25T08:17:09.000Z", "max_issues_repo_path": "system-ml/docs/Algorithms Reference/RandomForest.tex", "max_issues_repo_name": "alcedo/systemml", "max_issues_repo_head_hexsha": "4d371a6d6b52e5517b1411302af3fdd8cd3c156a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "system-ml/docs/Algorithms Reference/RandomForest.tex", "max_forks_repo_name": "alcedo/systemml", "max_forks_repo_head_hexsha": "4d371a6d6b52e5517b1411302af3fdd8cd3c156a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-11-26T00:43:09.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-02T06:29:30.000Z", "avg_line_length": 53.0666666667, "max_line_length": 321, "alphanum_fraction": 0.7358909934, "num_tokens": 2835, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40403644029833585}}
{"text": "\\chapter{Cross Section Determination Method}\n\\label{crosssectionchapter}\n\\label{limits}\n\nThis chapter summarizes the technique used to measure the single top quark cross section as well as the systematic uncertainties on the expected signal and background yields. Section~\\ref{CrossSectionDetermination} derives the Bayesian posterior density function and shows how it is used to determine the single top quark production cross section. The treatment of systematic uncertainties is also covered in this section. A description of each systematic uncertainty and its effect on the signal acceptance and background yield is presented in Section~\\ref{systematics}. Section~\\ref{ensembles} describes the method designed to measure the stability and linearity of the cross section measurement technique. Finally, the expected sensitivity and cross section resolution for a Standard Model single top signal in the full dataset is presented in Section~\\ref{exp-performance}.\n\n\\section{Bayesian Posterior Density Function}\n\\label{CrossSectionDetermination}\n\nThe single top cross section is measured by creating a Bayesian posterior density function, which yields the probability density for all single top quark production cross sections\\footnote{The Bayesian posterior density function is sometimes referred to as the posterior in this text.}. The posterior is defined as the conditional probability that a process $\\mathcal{A}$ is true given that another process $\\mathcal{B}$ is also true; it is equal to the conditional probability of process $\\mathcal{B}$ given process $\\mathcal{A}$ multiplied by the prior probability for process $\\mathcal{A}$ ($\\pi(\\mathcal{A})$) divided by the prior probability for process $\\mathcal{B}$ ($\\pi(\\mathcal{B})$), as shown in  Eq.~\\ref{bayestheorem}.\n\n\\begin{equation}\n\\label{bayestheorem}\nP(\\mathcal{A}|\\mathcal{B}) = \\frac{P(\\mathcal{B}|\\mathcal{A})\\pi(\\mathcal{A})}{\\pi(\\mathcal{B})}\n\\end{equation}\n\nIn the single top quark analysis $\\mathcal{A}$ is the number of signal and background events and $\\mathcal{B}$ is the observed number of events. The conditional probability $P(\\mathcal{B}|\\mathcal{A})$ is then interpreted as the probability to observe $N$ events given $n$, where $n$ is the expected number of signal and background events. Numerically this is given as the value of the Poisson probability density function for observed number of events given the expectation as seen in Eq.~\\ref{poisson}. This term is also referred to as the likelihood and its application in the single top quark analysis is given latter in this section.\n\n\\begin{equation}\n\\label{poisson}\nP(\\mathcal{B}|\\mathcal{A}) \\equiv \\mathcal{L}(N|n) = \\frac{n^{N}e^{-n}}{N!}\n\\end{equation}\n\nThe quantity of interest in this analysis is the signal cross section and not the number of expected signal and background events. To expose the cross section dependence the expected yield $n$ is re-written as\n\n\\begin{equation}\n\\label{expected}\nn = n_{S} + n_{B} = \\alpha_{S} L \\sigma_{S} + \\sum_{i} n_{B,i},\n\\end{equation}\n\n\\noindent where $\\alpha_{S}$ is the signal acceptance, $L$~is the integrated luminosity, $\\sigma_{S}$ is the signal cross section, and $\\sum_{i} n_{B,i}$ is the sum of background yields.\\footnote{For the rest of this section, the luminosity is absorbed by the acceptance term ($\\alpha_{S} \\times L \\rightarrow \\alpha_{S}$).} The likelihood is also re-written as $\\mathcal{L}(N|n) = \\mathcal{L}(N|\\sigma_{S},\\alpha_{S},\\vec{n}_{B})$ and the prior $\\pi(n)$ is re-written as $\\pi(\\sigma_{S},\\alpha_{S}, \\vec{n}_{B})$. \n\nThe prior can be factored into a term dependent on the cross section and a term dependent on the signal acceptance and the background yield as shown in Eq.~\\ref{prior}. \n\n\\begin{equation}\n\\label{prior}\n\\pi(n) \\equiv \\pi(\\sigma_{S},\\alpha_{S}, \\vec{n}_{B}) = \\pi(\\sigma_{S}) \\times \\pi(\\alpha_{S}, \\vec{n}_{B})\n\\end{equation}\n\nThe likelihood is modified to combined multiple independent channels by replacing the original likelihood by the product of the likelihoods for each channel, as shown in Eq.~\\ref{combine}.\n\n\\begin{equation}\n\\label{combine}\n\\mathcal{L}(N|\\sigma_{S},\\alpha_{S}, \\vec{n}_{B}) \\rightarrow \\prod_{i} \\mathcal{L}(N_{i}|\\sigma_{S},\\alpha_{S,i}, \\vec{n}_{B,i})\n\\end{equation}\n\nFor the matrix element analysis method the values of $N$,~$\\alpha$, and~$\\vec{n}_{B}$ are given in the form of two-dimensional histograms, where one axis corresponds to the $s$-channel discriminant and the other axis corresponds to the $t$-channel discriminant. The histograms are filled with matrix element discriminants for the data (N), the signal Monte Carlo ($\\alpha_{S}=n_{S}/\\sigma_{S}$), and background Monte Carlo ($\\vec{n}_{B}$). To incorporate the shape information of these quantities, the likelihood is further modified for a given channel as the product of the likelihoods for each bin in the two-dimensional histogram, as shown in Eq.~\\ref{bins}.\n\n\\begin{equation}\n\\label{bins}\n\\mathcal{L}(N|\\sigma_{S},\\alpha_{S}, \\vec{n}_{B}) \\rightarrow \\prod_{\\rm{Bins}\\{j\\}} \\mathcal{L}(N_{j}|\\sigma_{S},\\alpha_{S,j}, \\vec{n}_{B,j})\n\\end{equation}\n\nThe acceptance and background yield dependence on the posterior are removed by integrating the likelihood and prior with respect to the signal acceptance and each background yield, as shown in Eq.~\\ref{remove}.\n\n\\begin{equation}\n\\label{remove}\nP(\\sigma|N) = \\frac{1}{P(N)} \\int \\int \\mathcal{L}(N|\\sigma_{S},\\alpha^{'}_{S}, \\vec{n}^{'}_{B}) \\times \\pi(\\sigma_{S}) \\times \\pi(\\alpha^{'}_{S}, \\vec{n}^{'}_{B}) ~ d\\alpha^{'}_{S} d\\vec{n}^{'}_{B}\n\\end{equation}\n\n\\noindent The term $P(N)$ is the posterior normalization such that the posterior retains a probability density function interpretation (i.e~$\\int P(\\sigma|N) \\rm{d}\\sigma = 1$~). To ensure that the normalization is finite the prior for the signal cross section $\\pi(\\sigma_{S})$ is cut off at a maximum value, $\\sigma_{\\rm{max}}$. The prior is flat in the region of $0<\\sigma<\\sigma_{\\rm{max}}$ and zero beyond this region.\\footnote{A flat prior represents a minimal bias towards any signal cross section.} The value of $\\sigma_{\\rm{max}}$ is chosen to be large enough such that beyond that limit the likelihood is negligibly small for all $\\alpha_{S}$ and $\\vec{n}_{B}$.\n\nThe prior $\\pi(\\alpha^{'}_{S}, \\vec{n}^{'}_{B})$ is defined separately for the case of no systematics uncertainties and complete systematics. Both cases are described in the following section.\n\n\\subsection{Prior Definition With and Without Systematic Uncertainties}\n\n\\subsubsection{Prior Without Systematics}\n\nIn the case of no systematic uncertainties the signal acceptance and background yields are perfectly known. This requires the prior to be a product of two delta functions, as shown in Eq.~\\ref{priornosys}, and leads to a posterior shown in Eq.~\\ref{postnosys}.\n\n\\begin{equation}\n\\label{priornosys}\n\\pi(\\alpha^{'}_{S}, \\vec{n}^{'}_{B})=\\delta(\\alpha^{'}_{S}-\\alpha_{S})\\times\\delta(\\vec{n}^{'}_{B}-\\vec{n}_{B})\n\\end{equation}\n\n\\begin{equation}\n\\label{postnosys}\nP(\\sigma|N) = \\frac{\\mathcal{L}(N|\\sigma_{S},\\alpha_{S}, \\vec{n}_{B}) \\times \\pi(\\sigma_{S})}{\\int \\mathcal{L}(N|\\sigma^{'}_{S},\\alpha_{S}, \\vec{n}_{B}) \\times \\pi(\\sigma^{'}_{S})~d\\sigma^{'}_{S}}\n\\end{equation}\n\n\\subsubsection{Prior With Systematics}\n\nIn the case of systematic uncertainties the prior is modified to reflect the uncertainty in $\\alpha_{S}$ and $\\vec{n}_{B}$. For each systematic uncertainty the $\\pm$1$\\sigma$~uncertainty is propagated through the analysis resulting in a $\\pm$1$\\sigma$~uncertainties for the signal acceptance~($\\delta\\alpha_{S}$) and the background yield~($\\delta\\vec{n}_{B}$). From these values a covariance matrix is created, which accounts for all correlations between systematics (e.g. the uncertainty in the integrated luminosity affects both the signal acceptance and the $\\ttbar$ normalization). The covariance matrix element \\{i,j\\} for background or signal $i$ and $j$ is defined as\n\n\\begin{equation}\n\\rm{cov}_{i,j} = p_{i}p_{j} \\sum_{k=1}^{m} f_{i,k}f_{j,k},\n\\end{equation}\n\n\\noindent where $p_{i}$ is the signal or background yield for the $i^{th}$ source and $f_{i,k}$ is the fractional uncertainty from the $k^{th}$ systematic component for the $i^{th}$ signal or background. The prior is then calculated as a multivariate Gaussian, as shown in Eq.~\\ref{priorsys}.\n\n\\begin{equation}\n\\label{priorsys}\n\\pi(\\alpha^{'}_{S}, \\vec{n}^{'}_{B})= \\frac{1}{\\sqrt{(2\\pi)^{N}|\\Sigma|}} \\mathrm{exp} \\left\\{ -\\frac{1}{2}(\\vec{x} - \\mu)^{T} \\Sigma^{-1} (\\vec{x}-\\mu) \\right\\}\n\\end{equation}\n\n\\noindent where $\\Sigma$ is the covariance matrix, $\\vec{x}$ represents $\\{ \\alpha^{'}_{S}, \\vec{n}^{'}_{B} \\}$, and $\\mu$ represents $\\{ \\alpha_{S}, \\vec{n}_{B} \\}$\n\nThe posterior, when systematics are included, is solved using Monte Carlo importance sampling. In this method a set of points in $\\{ \\alpha_{S}, \\vec{n}_{B} \\}$-space are generated according the prior density defined in Eq.~\\ref{priorsys}. The solution to the posterior is given by\n\n\\begin{equation}\n\\label{mcint}\n\\int \\int \\mathcal{L}(N|\\sigma_{S},\\alpha_{S}, \\vec{n}_{B}) \\times \\pi(\\alpha_{S}, \\vec{n}_{B}) ~ d\\alpha_{S}d\\vec{n}_{B} = \\frac{1}{K} \\sum_{i=1}^{K} \\mathcal{L}(N|\\sigma_{S},\\alpha_{S}, \\vec{n}_{B})\n\\end{equation}\n\nA discussion of the systematic uncertainties and their magnitudes can be found in Section~\\ref{systematics} of this chapter.\n\n\\subsection{Cross Section Extraction}\n\nIf there is an excess of data events over the expected background yield then it is possible to determine the production cross section for a given process. The cross section is defined as the value which maximizes the posterior, as seen in Fig.~\\ref{CrossSection}. The solid blue line represents the cross section (3.9 pb) and the dashed-blue lines represent the $\\pm1\\sigma$ uncertainty on the cross section. The uncertainties are calculated by integrating the posterior curve until 33.15$\\%$ of the area is contained on each side of the cross section. In the case of Fig.~\\ref{CrossSection} the $+1\\sigma$ error band covers 2.3~pb above the cross section and the $-1\\sigma$ error band covers 2.2~pb below the cross section.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Limits/CrossSection.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Example cross section measurement (solid blue line) with $\\pm1\\sigma$ error band (dashed blue lines).}\n\\label{CrossSection}\n\\end{figure}\n\nIf there is no excess of data above the background, then upper limits on the production cross section can be set. An upper cross section limit, $\\sigma_{\\rm{CL}}$, at a given confidence level is found by integrating the posterior until an area equal to the confidence level is obtained, as shown in Eq.~\\ref{cl}. Fig.~\\ref{CrossSectionLimit} shows the cross section limit for the same posterior shown in Fig.~\\ref{CrossSection}. The limit is 8.4 pb at 95$\\%$~CL.\n\n\\begin{equation}\n\\label{cl}\n\\int_{0}^{\\sigma_{\\rm{CL}}} P(\\sigma|N)~d\\sigma = CL\n\\end{equation}\n\n\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Limits/Limit.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Example of the 95$\\%$~CL upper cross section limit. The value of the upper limit is shown by the blue curve. For this posterior the cross section limit is 8.4 pb.}\n\\label{CrossSectionLimit}\n\\end{figure}\n\nFinally, a quantity used to optimize the sensitivity of a particular analysis channel is the Bayes ratio. This quantity is an approximation to the Bayes factor which is the likelihood for the case of signal+background divided by the background only likelihood. The Bayes ratio is defined as the ratio of the posterior at its maximum over the posterior at zero cross section. The larger the Bayes ratio the more sensitive a channel is to measure a cross section different from zero. This is shown graphically in Fig.~\\ref{BayesRatio} for the same posterior curve used in the previous two figures.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Limits/BayesRatio.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Example of the Bayes ratio defined as the maximum of the posterior (top blue line) over the posterior at zero cross section (lower blue line). The Bayes ratio for this curve is 5.0.}\n\\label{BayesRatio}\n\\end{figure}\n\n\\subsection{$s+t$-channel Cross Section Definition}\n\nAll cross sections presented in this thesis are the combined $s$-channel plus $t$-channel cross section. In this case the ratio of $s/t$-channel cross sections ($0.88/1.98=0.44$) is assumed to be consistent with the Standard Model. With an increased dataset a measurement of the individual $s$-channel and $t$-channel cross sections will be a future addition to this analysis.\n\n\\clearpage\n\\section{Systematic Uncertainties}\n\\label{systematics}\n\\label{sysdescription}\n\nThis section describes all systematic uncertainties considered in the matrix element analysis. In most cases the uncertainty source applies both to the signal acceptance ($\\alpha$) and the background expectation ($n_{B}$). The other systematics are only applied to certain backgrounds as explained in the following text. Two sources of systematic uncertainties (jet energy scale and tag-rate functions) are referred to as  ``shape changing'' systematics, while the rest solely affect the signal or background normalization and are referred to as ``flat'' systematics. Flat systematics have a uniform uncertainty across all bins of the matrix element discriminant, while shape changing systematics vary bin-to-bin. Table~\\ref{tab:generalsys} summarizes the relative uncertainties due to each systematic source\\footnote{Appendix~\\ref{allsys}~shows the uncertainties for each background yield and signal acceptance for each analysis channel.}. The effect of each systematic uncertainty on the measured single top cross section can be found in Chapter~\\ref{results}.\n\n\\vspace{-0.1in}\n\\begin{table}[h]\n\\begin{center}\n\\caption{A summary of the relative systematic uncertainties\nfor each of the applied corrections and efficiencies. The uncertainty\nshown is the error on the correction or the efficiency, before it has\nbeen applied to the MC or data samples.}\n\\label{tab:generalsys}\n\\begin{tabular}{c|c||c|c}\n%\\multicolumn{4}{c}{\\underline{Relative Systematic Uncertainties}}\\\\\n\\hline\n{\\ttbar} cross section\t\t& $18\\%$\t\t& Primary vertex                    \t\t\t&  $3\\%$  \\\\\nLuminosity                      \t&  $6\\%$  \t\t& Electron reco * ID                \t\t\t&  $2\\%$  \\\\\nElectron trigger                   & $3\\%$   \t\t& Electron trackmatch \\& likelihood \t\t&  $5\\%$  \\\\\nMuon trigger                       \t& $6\\%$   \t\t& Muon reco * ID                    \t\t\t&  $7\\%$  \\\\\nJet energy scale               \t&wide range\t& Muon trackmatch \\& isolation      \t\t&  $2\\%$  \\\\\nJet efficiency                     \t& $2\\%$  \t\t& Electron~$\\varepsilon_{\\rm{W+jets}}$ \t&  $2\\%$  \\\\\nJet fragmentation              \t& 5--7$\\%$\t& Muon~$\\varepsilon_{\\rm{W+jets}}$    \t&  $2\\%$  \\\\\nHeavy flavor ratio             \t& $30\\%$  \t& Electron~$\\varepsilon_{\\rm{Multijet}}$ \t&3--40$\\%$\\\\ \nTag-rate functions             \t&2--16$\\%$\t& Muon~$\\varepsilon_{\\rm{Multijet}}$    \t&2--15$\\%$\n\\end{tabular}\n\\end{center}\n\\end{table}\n\n\n\\begin{itemize}\n\\item {\\bf Integrated luminosity} \\\\ \nThe error on the integrated luminosity used in the analysis is $6.1\\%$. This uncertainty comes from the error on the measured inelastic $\\ppbar$~cross section. The error on the luminosity estimate affects the $\\ttbar$ background since this background is normalized using the integrated luminosity.\n\n\\item {\\bf Theoretical cross sections} \\\\ \nThe $\\ttbar$ background yield is normalized to the NLLO theoretical cross section. The uncertainty of this cross section for a top mass of 175~GeV is $18\\%$. The uncertainty on the cross section is mainly due to the uncertainty from the top mass, but also from the choice of scale and parton distribution function uncertainties.\n\n\\item {\\bf Trigger efficiency} \\\\\nThe uncertainty on the trigger efficiency is determined by varying the trigger term efficiencies at each trigger level by the $\\pm1\\sigma$ uncertainties. A total uncertainties of $3\\%$ was assigned to the $e$+jets trigger and $6\\%$ to the $\\mu$+jets trigger. Fig.~\\ref{triggeruncer} shows the affect of the $\\pm1\\sigma$~shift in the $e$+jets trigger efficiency on the electron $p_{T}$ in $\\dilepton$ Monte Carlo events.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Systematics/trigger.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Electron $p_{T}$ in weighted $\\dilepton$ Monte Carlo events. The three curves represent the estimated yield in each $p_{T}$ bin for the case of $+1\\sigma$ trigger weights (red), nominal trigger weights (black), and $-1\\sigma$ trigger weights (blue).}\n\\label{triggeruncer}\n\\end{figure}\n\n\\item {\\bf Primary vertex selection efficiency} \\\\\nThe longitudinal position of the primary interaction vertex is not well modeled in the Monte Carlo. The maximum deviation between the data and Monte Carlo is $3\\%$ thus this number was taken as the systematic uncertainty. This uncertainty accounts for the beam profile along the longitudinal direction~\\cite{beamshifts}.\n\n\\item {\\bf Jet reconstruction and identification} \\\\\nThis systematic is due to the difference between the data and Monte Carlo for the $\\eta$ and number of jets distributions. A $2\\%$ uncertainty is assigned to this effect.\n\n\\item {\\bf Jet energy scale (JES) and jet energy resolution} \\\\\nThe JES correction is raised and lowered by one standard deviation and\nthe whole analysis is repeated. In the data the JES uncertainty\ncontains the jet energy resolution uncertainty; however, in the Monte Carlo\nthe jet energy resolution uncertainty is not taken into account in the\nJES uncertainty. To account for this the Monte Carlo energy smearing\nis varied by the size of the jet energy resolution in MC. This\nuncertainty affects the acceptance and the shapes of the\ndistributions. The $1\\sigma$ error on the JES as a function of jet $p_{T}$ for central jets is shown in Fig.~\\ref{jes2}. The JES uncertainty is larger for lower $p_{T}$ and more forward jets.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Systematics/jes.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{$1\\sigma$~uncertainties from each of the jet energy scale components as a function of jet $p_{T}$ for jets with $\\eta=0.0$. The total uncertainty is shown by the black line. }\n\\label{jes2}\n\\end{figure}\n\n\\item {\\bf Jet fragmentation} \\\\\nThe uncertainty of the jet fragmentation model is determined by the difference in fragmentation models between the Pythia and Herwig Monte Carlo generators. This uncertainty also covers the uncertainties due to initial and final state radiation. The total uncertainty is $5\\%$ for $\\dilepton$ and single top quark events and $7\\%$ for $\\lepjets$~events.\n\n\\item {\\bf Electron reconstruction and identification efficiency} \\\\\nThis uncertainty derives from the error on the electron reconstruction Monte Carlo correction factor. The uncertainty is determined by varying the correction factor by $1\\sigma$ in the parameterized bins of $p_{T}$ and $\\phi$. The total uncertainty is determined to be $2\\%$.\n\n\\item {\\bf Electron track matching and likelihood efficiency} \\\\\nThis uncertainty derives from the error on the electron track match and likelihood Monte Carlo correction factor. The uncertainty is determined by varying the correction factor by $1\\sigma$ in the parameterized bins of $\\eta$ and $\\phi$. The total uncertainty is determined to be $5\\%$.\n\n\\item {\\bf Muon reconstruction and identification efficiency} \\\\\nThis uncertainty derives from the error on the muon reconstruction Monte Carlo correction factor. The uncertainty is determined by varying the correction factor by $1\\sigma$ in the parameterized bins of $\\eta$ and $\\phi$. The total uncertainty is determined to be $7\\%$.\n\n\\item {\\bf Muon track matching and isolation} \\\\\nThis uncertainty derives from the error on the muon track match and isolation Monte Carlo correction factor. The uncertainty is determined by varying the correction factor by $1\\sigma$ in the parameterized bins of $\\eta$ and $\\phi$ for the track match factor and $p_{T}$ and the number of jets for the isolation factor. The total uncertainty is determined to be $2\\%$.\n\n\\item {\\bf Matrix method normalization} \\\\\nThe normalization of the W+jets and multijet backgrounds is performed using the matrix method and its error is dominated by the error on the efficiency that a lepton not originating from a $W$ decay will pass the electron likelihood or muon isolation cut ($\\delta\\varepsilon_{\\rm{Multijet}}$). The statistics of the normalized samples also contributes to the total uncertainty. The average values and errors for $\\varepsilon_{\\rm{Multijet}}$ for both electron and muon events is shown in Table~\\ref{eps-qcd}.\n\n\\begin{table}[!h!tbp]\n\\begin{center}\n\\caption{$\\varepsilon_{\\rm{Multijet}}$ for electrons as a function of\nthe trigger period and jet multiplicity, and $\\varepsilon_{\\rm{Multijet}}$ for muons averaged over $\\eta$. The definition of the trigger periods is found in Chapter~\\ref{analysis}.}\n\\label{eps-qcd}\n\\begin{tabular}{c|ccccc|c}\n%\\multicolumn{7}{c}{\\hspace{0.8in}\\underline{Fake-Lepton Probabilities}}\n%\\vspace{0.05in}\\\\\n& \\multicolumn{5}{c|}{ Electron $\\varepsilon_{\\rm{Multijet}}$ For Five Trigger Periods ($\\%$)} & \\multicolumn{1}{c}{ Muon $\\varepsilon_{\\rm{Multijet}}$  ($\\%$)} \\\\\nJets & I   &     II     &     III    &     IV    &     IV     &     I \\\\\n\\hline \n 2 & $12.8 \\pm 1.0$ & $19.2 \\pm 1.0$ & $18.8 \\pm 2.2$ & $19.4 \\pm 1.1$ & $22.0 \\pm 1.2$ & $35.8 \\pm 3.2$ \\\\\n 3 & $13.6 \\pm 1.5$ & $19.5 \\pm 1.6$ & $19.8 \\pm 3.4$ & $19.2 \\pm 1.6$ & $19.4 \\pm 1.7$ & $34.2 \\pm 4.5$ \\\\\n\\end{tabular}\n\\vspace{-0.1in}\n\\end{center}\n\\end{table}\n\n\n\\item {\\bf Ratio of $Wb\\bar{b}+Wc\\bar{c}$ to $Wjj$ Events} \\\\\nThere is a $30\\%$ systematic error due to the uncertainty on this ratio. The error is much larger than the fit to the events in the zero tag sample to account for theoretical shape-dependent errors that are not modeled in the Monte Carlo. The largest of these theoretical errors is the shape change to the $b$-quark $p_{T}$ between NLO and LO $Wbb$ events. The error on this ratio is folded into the overall matrix method normalization uncertainty when determining the acceptance and background yield uncertainties.\n\n\\item {\\bf Monte Carlo tag-rate functions}\\\\\nThe uncertainty associated with the tag-rate functions is evaluated by shifting the TRFs by $\\pm1\\sigma$ and evalulating the change in the signal acceptance and background yield. The tag-rate function uncertainties are dominated by the assumed fraction of heavy flavor in the multijet samples used to determine the fake tagging rate in data and the decreased statistics in each bin due the parameterization in $p_{T}$ and $\\eta$. The tag rate functions for $B$-jets and charm-jets and the $1\\sigma$~error bands are shown in Fig.~\\ref{trfserror2}. The total uncertainty depends heavily on the number of $B$-tagged jets in the event.\n\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.48\\textwidth]{eps/Systematics/trf_b_0.775_pt.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Systematics/trf_b_0.775_eta.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Systematics/trf_c_0.775_pt.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Systematics/trf_c_0.775_eta.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Neural network $B$-jet tagger efficiency (green line) and $1\\sigma$~error bands (dashed lines) jet $p_{T}$ and $\\eta$ for $B$-jets (upper row) and charm-jets (lower row). The red lines represent the efficiency of the $B$-tagging algorithm when applied directly to the Monte Carlo.}\n\\label{trfserror2}\n\\end{figure}\n\n\\end{itemize}\n\n\\clearpage\n\\section{Ensemble Testing}\n\\label{ensembles}\n\nEnsemble tests are performed to ensure there is no bias in the measured cross section. An ensemble is a group of pseudo-datasets created with a known fraction of signal and background events. Since the fractions are known the linearity of the measured cross section can be tested against the known cross section.\n\nThe ensembles are generated from a large set of weighted signal and background events. For each analysis channel the total background yield, as shown in Chapter~\\ref{background}, is used as the expected value of a Poisson distribution and a new background yield is generated from this distribution. The uncertainty in the yield due to systematics is included when generating a new background and signal yield as explained in Appendix~\\ref{ensemblegeneration}. This procedure will on average produce the expected background compositeness (e.g. ratio of Wbb to Wjj events). The cross section is then determined for all psuedo-datasets in the ensemble.\n\nFive ensembles were generated with the following $s+t$-channel input signal cross sections:\n\n\\begin{itemize}\n\\item $\\sigma_{s+t} = 2$~pb.\n\\item $\\sigma_{s+t} = 2.9$~pb. (Expected Standard Model cross section)\n\\item $\\sigma_{s+t} = 4$~pb.\n\\item $\\sigma_{s+t} = 6$~pb.\n\\item $\\sigma_{s+t} = 8$~pb.\n\\end{itemize}\n\n\\noindent 2,000 datasets were generated in each ensemble. A histogram of the measured cross sections for each of these ensembles is shown in Fig.~\\ref{blue}. A plot of the mean of these histograms versus the input cross section is shown in Fig.~\\ref{linearity}. A linear fit to the data points yields a good $\\chi^{2}$/dof of 0.13/3, a slope consistent with 1 of $1.03\\pm0.03$, and an offset of $0.32\\pm0.09$.\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.48\\textwidth]{eps/Limits/Blue2.0.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Limits/Blue2.9.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Limits/Blue4.0.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Limits/Blue6.0.eps}\n\\includegraphics[width=0.48\\textwidth]{eps/Limits/Blue8.0.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Observed cross section for a set of 2,000 pseudo-datasets for the five ensembles: $\\sigma_{s+t}=2.0$~pb (upper left), $\\sigma_{s+t}=2.9$~pb (upper right), $\\sigma_{s+t}=4.0$~pb (middle left), $\\sigma_{s+t}=6.0$~pb (middle right), and $\\sigma_{s+t}=8.0$~pb (bottom middle)}\n\\label{blue}\n\\end{figure}\n\n\n\\begin{figure}[!h!tbp]\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{eps/Limits/Linearity.eps}\n\\end{center}\n\\vspace{-0.1in}\n\\caption{Response of the five generated ensemble sets versus input cross section. The response is measured as the mean value of the histogram for each ensemble.}\n\\label{linearity}\n\\end{figure}\n\n\\clearpage\n\\section{Expected Results}\n\\label{exp-performance}\n\nThis section presents the expected performance of the analysis given a Standard Model single top signal. To test the expected sensitivity the number of data events is set equal to the number of signal and background events in each bin of the Likelihood (i.e. the excess of data over background in each bin is equal, by construction, to the number of events expected from a signal with $\\sigma=2.9$ pb). This test is performed for each analysis channel and various combinations of the channels. Figs.~\\ref{exp-post-1d-2j} and \\ref{exp-post-1d-3j} show the\nresulting $tb$+$tqb$\\footnote{$tb+tqb$ is used to donate the combined $s$-channel plus $t$-channel cross section measurement} posterior for the combined $e$+$\\mu$ $\\geq$~1\n$B$-tag channel in two-jet and three-jet events.\nFigure~\\ref{exp-post-1d-allj} shows the $tb$+$tqb$ posterior for the\ncombination of all channels. The figures on the left correspond to the case\nof only statistical uncertainties, whereas the figures on the right include statistical and systematic uncertainties. \n\n\\vspace{0.1in}\n\\begin{figure}[!h!tbp]\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/nosys/expected_limit_TBTQ_LeptonsCombined_2Jet_TagsCombined}\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/sys/expected_limit_TBTQ_LeptonsCombined_2Jet_TagsCombined}\n\\vspace{-0.1in}\n\\caption{Expected 1D posterior plots for the combined\n$e$+$\\mu$ $\\geq$~1 $B$-tag channel in two-jet events, with statistical\nuncertainties only (left plot) and including also systematic\nuncertainties (right plot).}\n\\label{exp-post-1d-2j}\n\\end{figure}\n\n\\vspace{0.1in}\n\\begin{figure}[!h!tbp]\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/nosys/expected_limit_TBTQ_LeptonsCombined_3Jet_TagsCombined}\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/sys/expected_limit_TBTQ_LeptonsCombined_3Jet_TagsCombined}\n\\vspace{-0.1in}\n\\caption{Expected 1D posterior plots for the combined\n$e$+$\\mu$ $\\geq$~1 $b$-tag channel in three-jet events, with\nstatistical uncertainties only (left plot) and including also\nsystematic uncertainties (right plot).}\n\\label{exp-post-1d-3j}\n\\end{figure}\n\n\\vspace{0.1in}\n\\begin{figure}[!h!tbp]\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/nosys/expected_limit_TBTQ_LeptonsCombined_JetsCombined_TagsCombined}\n\\includegraphics[width=0.49\\textwidth]\n{eps/MatrixElement/posterior/sys/expected_limit_TBTQ_LeptonsCombined_JetsCombined_TagsCombined}\n\\vspace{-0.1in}\n\\caption{Expected 1D posterior plots for the\ncombination of all channels, with statistical uncertainties only (left\nplot) and including also systematic uncertainties (right plot).}\n\\label{exp-post-1d-allj}\n\\end{figure}\n\nTable~\\ref{tab:expxsecs} shows the expected cross sections for various\ncombinations of analysis channels. The expected result for each\ncombination is consistent with the standard model cross\nsection. Table~\\ref{exp-errors} summarizes the relative uncertainty on\nthe expected $tb$+$tqb$ cross section measurement, defined as half the\nwidth of the $tb$+$tqb$ posterior, divided by the cross section value\nat the posterior peak.\n\n\\begin{table}[!h!tbp]\n\\begin{center}\n\\caption{Expected $tb$+$tqb$ cross sections, without and\nwith systematic uncertainties, for many combinations of the analysis\nchannels. The final expected result of this analysis are shown in the\nlower right hand corner in bold type.}\n\\label{tab:expxsecs}\n\\begin{tabular}{c|cc|cc|cc|c}\n%  \\multicolumn{8}{c}{\\hspace{0.5in}\\underline{Expected $tb$+$tqb$ Cross Section}}\\vspace{0.1in}\\\\\n& \\multicolumn{2}{c|}{1,2tags + 2,3jets}& \\multicolumn{2}{c|}{$e$,$\\mu$ + 2,3jets}\n& \\multicolumn{2}{c|}{$e$,$\\mu$ + 1,2tags}& All \\\\\n                 &  $e$-chan & $\\mu$-chan& 1 tag & 2 tags& 2 jets& 3 jets&channels\\\\\n\\hline\nStatistics only  &  $2.8^{+1.5}_{-1.4}$  & $2.8^{+1.8}_{-1.7}$ & $2.9^{+1.3}_{-1.2}$ & $2.8^{+2.5}_{-2.2}$ & $2.9^{+1.4}_{-1.3}$ & $2.8^{+2.2}_{-2.1}$ & $2.9^{+1.2}_{-1.1}$ \\\\\nWith systematics &  $3.0^{+2.2}_{-1.8}$  & $3.1^{+2.5}_{-2.1}$ & $2.9^{+1.8}_{-1.6}$ & $2.7^{+3.4}_{-2.7}$ & $2.9^{+1.9}_{-1.6}$ & $2.5^{+3.5}_{-2.5}$ & $\\mathbf{3.0^{+1.8}_{-1.5}}$ \\\\\n\\end{tabular}\n\\vspace{-0.1in}\n\\end{center}\n\\end{table}\n\n\\vspace{-0.1in}\n\\begin{table}[!h!tbp]\n\\begin{center}\n\\caption{Relative uncertainties on the expected\n$tb$+$tqb$ cross section, without and with systematic uncertainties,\nfor many combinations of the analysis channels. The best value from\nall channels combined, with systematics, is shown in bold type.}\n\\label{exp-errors}\n\\begin{tabular}{l|cc|cc|cc|c}\n%  \\multicolumn{8}{c}{\\hspace{0.5in}\\underline{Relative Uncertainties on the Expected $tb$+$tqb$ Cross Section}}\\vspace{0.1in}\\\\\n& \\multicolumn{2}{c|}{1,2tags + 2,3jets}& \\multicolumn{2}{c|}{$e$,$\\mu$ + 2,3jets}\n& \\multicolumn{2}{c|}{$e$,$\\mu$ + 1,2tags}& All \\\\\n                 &  $e$-chan & $\\mu$-chan& 1 tag & 2 tags& 2 jets& 3 jets&channels\\\\\n\\hline\nStatistics only  &  $52\\%$  & $60\\%$ & $45\\%$ & $83\\%$  &  $46\\%$  & $75\\%$  & $41\\%$     \\\\\nWith systematics &  $67\\%$  & $75\\%$ & $59\\%$ & $115\\%$ &  $60\\%$  & $121\\%$ & $\\mathbf{55\\%}$     \\\\\n\\end{tabular}\n\\vspace{-0.1in}\n\\end{center}\n\\end{table}", "meta": {"hexsha": "a3200b7ec20a9b9480b26d30cf6d48f0d5d24912", "size": 31722, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SystematicsCrossSection.tex", "max_stars_repo_name": "tgadf/thesis", "max_stars_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SystematicsCrossSection.tex", "max_issues_repo_name": "tgadf/thesis", "max_issues_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SystematicsCrossSection.tex", "max_forks_repo_name": "tgadf/thesis", "max_forks_repo_head_hexsha": "19d4a6bc7f7ac8660fce582322703d50e0d6bd31", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.9440559441, "max_line_length": 1062, "alphanum_fraction": 0.7379105983, "num_tokens": 9039, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40403644029833585}}
{"text": "\\chapter{Electronic transport calculations with the \\bw\\ module}\\label{ch:boltzwann}\n\nBy setting $\\verb#boltzwann#=\\verb#TRUE#$, \\postw\\ will call the \\bw\\ routines to calculate some transport coefficients using the Boltzmann transport equation in the relaxation time approximation.\n\nIn particular, the transport coefficients that are calculated are: the electrical conductivity $\\bvec \\sigma$, the Seebeck coefficient $\\bvec S$ and the coefficient $\\bvec K$ (defined below; it is the main ingredient of the thermal conductivity). \n\nThe list of parameters of the \\bw\\ module are summarized in Table~\\ref{parameter_keywords_bw}. \nAn example of a Boltzmann transport calculation can be found in the \\wannier\\ Tutorial. \n\n\\textbf{Note}: By default, the code assumes to be working with a 3D bulk material, with periodicity along all three spatial directions. If you are interested in studying 2D systems, set the correct value for the \\texttt{boltz\\_2d\\_dir} variable (see Sec.~\\ref{sec:boltz2ddir} for the documentation). This is important for the evaluation of the Seebeck coefficient.\n\nPlease cite the following paper~\\cite{pizzi-cpc14} when publishing results obtained using the \\bw\\  module:\n\\begin{quote}\nG. Pizzi, D. Volja, B. Kozinsky, M. Fornari, and N. Marzari, \\\\\n\\emph{BoltzWann: A code for the evaluation of thermoelectric and electronic transport properties with a maximally-localized Wannier functions basis},\\\\\nComp. Phys. Comm. 185, 422 (2014), DOI:10.1016/j.cpc.2013.09.015.\n\\end{quote}\n\n%Reference: [BoltzWann paper]\n\\section{Theory}\n\\label{sec:boltzwann-theory}\nThe theory of the electronic transport using the Boltzmann transport equations can be found for instance in Refs.~\\cite{ziman-book72,grosso-book00,mahan-itc06}. Here we briefly summarize only the main results. \n\nThe current density $\\bvec J$ and the heat current (or energy flux density) $\\bvec J_Q$ can be written, respectively, as\n\\begin{align}\n  \\bvec J   &= \\bvec \\sigma(\\bvec E - \\bvec S \\bvec \\nabla T) \\\\\n  \\bvec J_Q &= T \\bvec \\sigma \\bvec S \\bvec E - \\bvec K \\bvec \\nabla T,\n\\end{align}\nwhere the electrical conductivity $\\bvec \\sigma$, the Seebeck coefficient $\\bvec S$ and $\\bvec K$ are $3\\times 3$ tensors, in general.\n\nNote: the thermal conductivity $\\bvec \\kappa$ (actually, the electronic part of the thermal conductivity), which is defined as the heat current per unit of temperature gradient in open-circuit experiments (i.e., with $\\bvec J=0$) is not precisely $\\bvec K$, but  $\\bvec\\kappa = \\bvec K-\\bvec S \\bvec \\sigma \\bvec S T$ (see for instance Eq.~(7.89) of Ref.~\\cite{ziman-book72} or Eq.~(XI-57b) of Ref.~\\cite{grosso-book00}).\nThe thermal conductivity $\\bvec \\kappa$ can be then calculated from the $\\bvec \\sigma$, $\\bvec S$ and $\\bvec K$ tensors output by the code.\n\nThese quantities depend on the value of the chemical potential $\\mu$ and on the temperature $T$, and can be calculated as follows:\n\\begin{align}\n  [\\bvec \\sigma]_{ij}(\\mu,T)&=e^2 \\int_{-\\infty}^{+\\infty} d\\varepsilon \\left(-\\frac {\\partial f(\\varepsilon,\\mu,T)}{\\partial \\varepsilon}\\right)\\Sigma_{ij}(\\varepsilon), \\\\\n  [\\bvec \\sigma \\bvec S]_{ij}(\\mu,T)&=\\frac e T \\int_{-\\infty}^{+\\infty} d\\varepsilon \\left(-\\frac {\\partial f(\\varepsilon,\\mu,T)}{\\partial \\varepsilon}\\right)(\\varepsilon-\\mu)\\Sigma_{ij}(\\varepsilon), \\label{eq:boltz-sigmas}\\\\\n  [\\bvec K]_{ij}(\\mu,T)&=\\frac 1 T \\int_{-\\infty}^{+\\infty} d\\varepsilon \\left(-\\frac {\\partial f(\\varepsilon,\\mu,T)}{\\partial \\varepsilon}\\right)(\\varepsilon-\\mu)^2 \\Sigma_{ij}(\\varepsilon),\\label{eq:boltz-thermcond}\n\\end{align}\nwhere $[\\bvec \\sigma \\bvec S]$ denotes the product of the two tensors $\\bvec \\sigma$ and $\\bvec S$, $f(\\varepsilon,\\mu,T)$ is the usual Fermi--Dirac distribution function \n\\begin{equation*}\n  f(\\varepsilon,\\mu,T) = \\frac{1}{e^{(\\varepsilon-\\mu)/K_B T}+1}\n\\end{equation*}\nand $\\Sigma_{ij}(\\varepsilon)$ is the Transport Distribution Function (TDF) tensor, defined as\n\\begin{equation*}\n  \\Sigma_{ij}(\\varepsilon) = \\frac 1 V \\sum_{n,\\bvec k} v_i(n,\\bvec k) v_j(n,\\bvec k) \\tau(n,\\bvec k) \\delta(\\varepsilon - E_{n,k}).\n\\end{equation*}\n\nIn the above formula, the sum is over all bands $n$ and all states $\\bvec k$ (including spin, even if the spin index is not explicitly written here). $E_{n,\\bvec k}$ is the energy of the $n-$th band at $\\bvec k$, $v_i(n,\\bvec k)$ is the $i-$th component of the band velocity at $(n,\\bvec k)$, $\\delta$ is the Dirac's delta function, $V$ is the cell volume, and finally $\\tau$ is the relaxation time. In the \\emph{relaxation-time approximation} adopted here, $\\tau$ is assumed as a constant, i.e., it is independent of $n$ and $\\bvec k$ and its value (in fs) is read from the input variable \\verb#boltz_relax_time#.\n\n\\section{Files}\n\\subsection{{\\tt seedname\\_boltzdos.dat}}\nOUTPUT. Written by \\postw\\ if {\\tt boltz\\_calc\\_also\\_dos} is \\verb#true#. Note that even if there are other general routines in \\postw\\ which specifically calculate the DOS, it may be convenient to use the routines in \\bw\\ setting {\\tt boltz\\_calc\\_also\\_dos = true} if one must also calculate the transport coefficients. In this way, the (time-demanding) band interpolation on the $k$ mesh is performed only once, resulting in a much shorter execution time.\n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each energy $\\varepsilon$ on the grid, containing a number of columns. The first column is the energy $\\varepsilon$. The following is the DOS at the given energy $\\varepsilon$.\nThe DOS can either be calculated using the adaptive smearing scheme\\footnote{%\nNote that in \\bw\\ the adaptive (energy) smearing scheme also implements a simple adaptive $k-$mesh scheme:\nif at any given $k$ point one of the band gradients is zero, then that $k$ point is replaced by 8 neighboring $k$ points. Thus, the final results for the DOS may be slightly different with respect to that given by the {\\tt dos} module.} if {\\tt boltz\\_dos\\_adpt\\_smr} is \\verb#true#, or using a ``standard'' fixed smearing, whose type and value are defined by {\\tt boltz\\_dos\\_smr\\_type} and {\\tt boltz\\_dos\\_smr\\_fixed\\_en\\_width}, respectively.\nIf spin decomposition is required (input flag {\\tt spin\\_decomp}), further columns are printed, with the spin-up projection of the DOS, followed by spin-down projection.\n\n\\subsection{{\\tt seedname\\_tdf.dat}}\nOUTPUT. This file contains the Transport Distribution Function (TDF) tensor $\\bvec \\Sigma$ on a grid of energies. \n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each energy $\\varepsilon$ on the grid, containing a number of columns. The first is the energy $\\varepsilon$, the followings are the components if $\\bvec \\Sigma(\\varepsilon)$ in the following order: $\\Sigma_{xx}$, $\\Sigma_{xy}$, $\\Sigma_{yy}$, $\\Sigma_{xz}$, $\\Sigma_{yz}$, $\\Sigma_{zz}$. If spin decomposition is required (input flag {\\tt spin\\_decomp}), 12 further columns are provided, with the 6 components of $\\bvec \\Sigma$ for the spin up, followed by those for the spin down.\n\nThe energy $\\varepsilon$ is in eV, while $\\bvec \\Sigma$ is in \n $\\displaystyle\\frac{1}{\\hbar^2}\\cdot\\frac{\\mathrm{eV}\\cdot\\mathrm{fs}}{\\text{\\AA}}$.\n\n\\subsection{{\\tt seedname\\_elcond.dat}}\nOUTPUT. This file contains the electrical conductivity tensor $\\bvec \\sigma$ on the grid of $T$ and $\\mu$ points. \n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each $(\\mu,T)$ pair, containing 8 columns, which are respectively: $\\mu$, $T$, $\\sigma_{xx}$, $\\sigma_{xy}$, $\\sigma_{yy}$, $\\sigma_{xz}$, $\\sigma_{yz}$, $\\sigma_{zz}$. (The tensor is symmetric).\n\nThe chemical potential is in eV, the temperature is in K, and the components of the electrical conductivity tensor ar in SI units, i.e. in 1/$\\Omega$/m.\n\n\\subsection{{\\tt seedname\\_sigmas.dat}}\nOUTPUT. This file contains the tensor $\\bvec\\sigma\\bvec S$, i.e. the product of the electrical conductivity tensor and of the Seebeck coefficient as defined by Eq.~\\eqref{eq:boltz-sigmas}, on the grid of $T$ and $\\mu$ points. \n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each $(\\mu,T)$ pair, containing 8 columns, which are respectively: $\\mu$, $T$, $(\\sigma S)_{xx}$, $(\\sigma S)_{xy}$, $(\\sigma S)_{yy}$, $(\\sigma S)_{xz}$, $(\\sigma S)_{yz}$, $(\\sigma S)_{zz}$. (The tensor is symmetric).\n\nThe chemical potential is in eV, the temperature is in K, and the components of the tensor ar in SI units, i.e. in A/m/K.\n\n\\subsection{{\\tt seedname\\_seebeck.dat}}\nOUTPUT. This file contains the Seebeck tensor $\\bvec S$ on the grid of $T$ and $\\mu$ points. \n\nNote that in the code the Seebeck coefficient is defined as zero when the determinant of the electrical conductivity $\\bvec \\sigma$ is zero. If there is at least one $(\\mu, T)$ pair for which $\\det \\bvec \\sigma=0$, a warning is issued on the output file.\n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each $(\\mu,T)$ pair, containing 11 columns, which are respectively: $\\mu$, $T$, $S_{xx}$, $S_{xy}$, $S_{xz}$, $S_{yx}$, $S_{yy}$, $S_{yz}$, $S_{zx}$, $S_{zy}$, $S_{zz}$.\n\nNOTE: therefore, the format of the columns of this file is different from the other three files (elcond, sigmas and kappa)!\n\nThe chemical potential is in eV, the temperature is in K, and the components of the Seebeck tensor ar in SI units, i.e. in V/K.\n\n\\subsection{{\\tt seedname\\_kappa.dat}}\nOUTPUT. This file contains the tensor $\\bvec K$ defined in Sec.~\\ref{sec:boltzwann-theory} on the grid of $T$ and $\\mu$ points.\n\nThe first lines are comments (starting with \\# characters) which describe the content of the file.\nThen, there is a line for each $(\\mu,T)$ pair, containing 8 columns, which are respectively: $\\mu$, $T$, $K_{xx}$, $K_{xy}$, $K_{yy}$, $K_{xz}$, $K_{yz}$, $K_{zz}$. (The tensor is symmetric).\n\nThe chemical potential is in eV, the temperature is in K, and the components of the $\\bvec K$ tensor are the SI units for the thermal conductivity, i.e. in W/m/K.\n\n\n\n\n\n", "meta": {"hexsha": "568a8f49db8f4aa8c7241a498e79d327d2275efc", "size": 10176, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "wannier90_2.1/doc/user_guide/boltzwann.tex", "max_stars_repo_name": "comscope/comsuite", "max_stars_repo_head_hexsha": "d51c43cad0d15dc3b4d1f45e7df777cdddaa9d6c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2019-06-15T18:08:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-30T05:01:29.000Z", "max_issues_repo_path": "wannier90_2.1/doc/user_guide/boltzwann.tex", "max_issues_repo_name": "comscope/Comsuite", "max_issues_repo_head_hexsha": "b80ca9f34c519757d337487c489fb655f7598cc2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "wannier90_2.1/doc/user_guide/boltzwann.tex", "max_forks_repo_name": "comscope/Comsuite", "max_forks_repo_head_hexsha": "b80ca9f34c519757d337487c489fb655f7598cc2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2019-06-05T02:57:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-29T02:54:25.000Z", "avg_line_length": 91.6756756757, "max_line_length": 614, "alphanum_fraction": 0.7260220126, "num_tokens": 2969, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40403643329080435}}
{"text": "\\chapter{Human as a feedback system}\n\n\\section{Human behavior as a special case of the general feedback equation}\n\nLet \\(x ~ t\\) be the input vector at time \\(t\\);\nthis vector has at least some billions of elements.\nThe function \\(x\\) represents the state of all sensors at a given time.\n\nLet \\(y ~ t\\) be the control vector at time \\(t\\);\nthis vector is also big.\n\nLet \\(z~t\\) be the output vector at time \\(t\\).\n\nThe environment feeds back a part of the output to the input.\nCan the agent determine the response function?\n\nThe feedback forms memory, but see ``Memory without feedback in a neural network''.\nhttps://www.ncbi.nlm.nih.gov/pubmed/19249281\n\n\\section{Hardwiring the concept of time}\n\nWe can transform a non-temporal behavior \\(f~x = y\\) into a temporal behavior \\(f'~t = y'\\)?\n\n\\section{Life of one neuron?}\n\n% http://biology.stackexchange.com/questions/5306/how-do-neurons-form-new-connections-in-brain-plasticity\n\n\\section{A brain at a given time is an array function.}\n\nA brain at a given time is an array function\nhaving type \\(\\Real^\\infty \\to \\Real^\\infty\\).\nEach component of the input array is a signal from a sensor.\nEach component of the output array goes to an actuator.\n\nSince the brain is finite,\nthere must be infinitely many zeros in the input and output arrays.\n\n\\section{An array iself is also a function.}\n\nAn \\(E\\)-array is a function having type \\(\\Nat \\to E\\).\nThe input is an index.\nThe output is the value of the component at that index.\nSubscripting denotes function application.\n\n\\section{Each brain has a maximand.}\n\nSuch maximand is a hidden function.\nThe brain always tries to maximize the maximand.\n\nA differential change in brain tries to increase the maximand.\nThe brain follows gradient.\n\n\\section{Consider functions of length-one arrays.}\n\nLet \\(h\\) be a differential change in brain.\n\n\\section{Draft}\n\nThe only way to know whether the system has learning something\nis by testing it with samples the system has never seen.\n\nPractically all machine learning cases deal with functions\nthat is continuous enough to form a Hilbert space.\n\nEvery classification problem in the real world can be written as \\(f : I^n \\to I\\) for an \\(n : \\Nat\\).\nUsually \\(I\\) is discrete.\n\nConsider the case where \\(I = [0,1]\\).\nContinuous map from \\(I^n\\) to \\(I\\).\nContinuous map from a hyperplane to a line.\n\n\\section{How do we relate vector functions and intelligence?}\n\n\\section{How does feedback happen in the brain?}\n\nFeedback is due to environment and the physical laws.\nWhen we move our hand, we see it, because the light\nreflected by our hand now reaches our eyes.\n\nThe next input depends on the previous input.\n\\begin{align*}\n    y_k &= b~x_k\n    \\\\\n    x_{k+1} &= f~x_k~y_k\n\\end{align*}\n\n\\section{The brain is a recurrence relation.}\n\nThis pictures the brain as a parallel dataflow computer\nwith clock period of a few microseconds.\n\n% https://en.wikipedia.org/wiki/Dataflow_architecture\n\nLet \\(m\\) be memory, \\(x\\) be senses, and \\(y\\) be actuators.\n\\begin{align*}\n    m_{t+1} &= f~x_t~m_t\n    \\\\\n    y_{t+1} &= g~x_t~m_t\n\\end{align*}\n\nThere is also a version with implicit time.\n\\begin{align*}\n    m' &= f~x~m\n    \\\\\n    y' &= g~x~m\n\\end{align*}\n\nThere is also a continuous version.\n\\begin{align*}\n    m_{t+h} &= h \\cdot f~x_t~m_t\n    \\\\\n    y_{t+h} &= h \\cdot g~x_t~m_t\n\\end{align*}\n\n\\section{The brain evolved from simpler nervous systems.}\n\nNervous systems are control systems.\n\nNervous systems must have provided some evolutionary benefit;\notherwise natural selection would have phased them out.\n\nBacterial chemotaxis detects chemical concentration difference.\n\nNematode.\nCaenorhabditis elegans.\n", "meta": {"hexsha": "5f842860e2d6f6306ced12188679243411a0d6af", "size": 3636, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "research/human.tex", "max_stars_repo_name": "edom/work", "max_stars_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_stars_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "research/human.tex", "max_issues_repo_name": "edom/work", "max_issues_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_issues_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-12-02T18:37:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-16T00:55:32.000Z", "max_forks_repo_path": "research/human.tex", "max_forks_repo_name": "edom/work", "max_forks_repo_head_hexsha": "df55868caa436efc631e145a43e833220b8da1d0", "max_forks_repo_licenses": ["Apache-2.0", "CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-10-02T15:20:22.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-02T15:20:22.000Z", "avg_line_length": 28.8571428571, "max_line_length": 105, "alphanum_fraction": 0.7315731573, "num_tokens": 942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.523420348936324, "lm_q1q2_score": 0.40399859845721375}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\\usepackage{latexsym,amssymb}\n\\usepackage{array}\n\\usepackage{amsmath}\n \\usepackage{graphicx}\n\\usepackage{setspace}\n\\usepackage{mathtools}\n\\usepackage{sectsty}\n\\usepackage{tocloft}\n\\usepackage{amsthm}\n\\usepackage{float} \n\\usepackage[hidelinks]{hyperref}\n\\usepackage{semantic}\n\\usepackage{xcolor}\n\\usepackage{tikz}\n\\usetikzlibrary{shadings}\n\\usepackage{fancyhdr}\n\\usepackage{physics}\n\\usepackage{pgfplots}\n\n%Plot settings\n\\pgfplotsset{my style/.append style={axis x line=middle, axis y line=\n           middle, xlabel={$x$}, ylabel={$y$}, axis equal }}\n\n\\setlength{\\textwidth}{450pt}\n\\setlength{\\textheight}{720pt}\n\\setlength{\\topmargin}{-50pt}\n\\setlength{\\oddsidemargin}{12pt}\n\\setlength{\\parskip}{1pt plus 1pt}\n\\setlength{\\mathsurround}{1pt}\n\\renewcommand{\\baselinestretch}{1.05}\n\n\\setcounter{secnumdepth}{2}\n\\setcounter{secnumdepth}{0}\n\\sectionfont{\\Large}\n\\subsectionfont{\\fontsize{12}{8}\\selectfont}\n\n\\renewenvironment{proof}{{\\bfseries Proof.}}{\\hfill $\\square$}\n\\renewcommand*{\\d}{\\mathop{\\kern5pt\\mathrm{d}}\\!{}}\n\\newcommand*\\Eval[3]{\\left.#1\\right\\rvert_{#2}^{#3}}\n\\newcommand{\\floor}[1]{\\lfloor #1 \\rfloor}\n\\newcommand{\\dotp}{\\boldsymbol{\\cdot}}\n\\newtheorem{theorem}{\\indent\\sc Theorem}[section]\n\\newtheorem{lemma}{\\indent\\sc Lemma}[section]\n\\newcommand{\\Thmstop}{\\hglue-6pt.\\kern6pt}\n\n\\DeclareMathOperator{\\R}{\\mathbb{R}} \n\\DeclareMathOperator{\\N}{\\mathbb{N}} \n\\DeclareMathOperator{\\Z}{\\mathbb{Z}} \n\\DeclareMathOperator{\\Q}{\\mathbb{Q}} \n\\DeclareMathOperator{\\C}{\\mathbb{C}} \n\n\\onehalfspacing\n\\begin{document}\n\\begin{titlepage}\n    \\begin{center}\n    \\huge{\\bfseries Course Name: HW \\#}\\\\\n         \\vspace{0.5cm}\n    \\large{Name}\\\\\n    \\large{Student ID}\\\\\n     \\large{Date}\\\\\n    \\end{center}\n    \\begin{center}\n    \t\\tableofcontents\n    \\end{center}\n\\end{titlepage}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Header}\n\\cfoot{Page \\thepage}\n\n\\section{Question 1}\nLet $a_n = \\dfrac{18n^5+2n-5}{6n^5-n^3-3}$. We want to show that $(\\forall \\epsilon > 0)(\\exists K \\in \\N)[n \\geq K \\Rightarrow |a_n-3| < \\epsilon]$. \\\\\\\\\nWe have:\n\\begin{align*}\n\\left|\\dfrac{18n^5+2n-5}{6n^5-n^3-3} - 3\\right| &= \\left|\\dfrac{18n^5+2n-5 - 3(6n^5-n^3-3)}{6n^5-n^3-3}\\right| \\\\\n&= \\left|\\dfrac{3n^3+2n+4}{6n^5-n^3-3}\\right| \\\\\n&< \\left|\\dfrac{3n^3+3n^3+4n^3}{6n^5-n^3-3}\\right| && \\text{\\small(as for $n \\in \\N$, $2n < 3n \\leq 3n^3$ and $4 \\leq 4n \\leq 4n^3$)} \\\\\n&\\leq \\left|\\dfrac{10n^3}{6n^5-n^5-3n^5}\\right| && \\text{\\small(as for $n \\in \\N$, $n^5 \\geq n^3$ and $3n^5 \\geq 3$)} \\\\\n&=\\left|\\dfrac{10n^3}{2n^5}\\right| \\\\\n&=\\left|\\dfrac{5}{n^2}\\right| \\\\\n&=\\dfrac{5}{n^2} && \\text{$(*)$}\n\\end{align*}\nNote that for $\\epsilon > 0$ and $n > 0$, $\\dfrac{5}{n^2} < \\epsilon \\iff n > \\sqrt{\\dfrac{5}{\\epsilon}}$. \\\\\n\\begin{proof}\nLet $\\epsilon > 0$ be given. By the Archimedean property of $\\R$, $\\exists K \\in \\N$ such that $K >  \\sqrt{\\dfrac{5}{\\epsilon}}$. Then for all $n \\geq K$, we have:\n\\begin{align*}\n\\left|\\dfrac{18n^5+2n-5}{6n^5-n^3-3} - 3\\right| &< \\dfrac{5}{n^2} && \\text{(by $(*))$} \\\\\n&\\leq \\dfrac{5}{K^2} && \\text{(since $n \\geq K$)} \\\\\n&< \\dfrac{5}{\\left(\\dfrac{5}{\\epsilon}\\right)} && \\text{(since $K > \\sqrt{\\dfrac{5}{\\epsilon}}$)} \\\\\n&= \\epsilon \\\\\n\\end{align*} \nHence, we have $\\lim\\limits_{n \\to \\infty}{\\dfrac{18n^5+2n-5}{6n^5-n^3-3}} = 3$, as required.\n\\end{proof}\n\n\\section{Question 2}\nLet $a$ be the common limit of the subsequences. We want to show that $(\\forall \\epsilon > 0)(\\exists K \\in \\N)[n \\geq K \\Rightarrow |a_n-a| < \\epsilon]$. \\\\\\\\\nWe know that:\n$$(\\forall \\epsilon > 0)(\\exists K_1 \\in \\N)[k \\geq K_1 \\Rightarrow |a_{2k}-a| < \\epsilon]$$\n$$(\\forall \\epsilon > 0)(\\exists K_2 \\in \\N)[k \\geq K_2 \\Rightarrow |a_{4k-1}-a| < \\epsilon]$$ \n$$(\\forall \\epsilon > 0)(\\exists K_3 \\in \\N)[k \\geq K_3 \\Rightarrow |a_{4k-3}-a| < \\epsilon]$$\n\nWe also note that these 3 subsequences partition $(a_n)$. This is because the integers can be partitioned into the equivalences classes of $\\Z_4$. When $n$ is even, we have the union of equivalence classes $[0] \\cup [2]$. In other words, if we only look at the positive, even values of $n$, we get the sequence $(a_{2k})$. If n is odd, we have the union of equivalence classes $[1] \\cup [3]$. In other words, if we only look at the positive, odd values of $n$, we get either the sequence $(a_{4k-1})$ or $(a_{4k-3})$. \\\\\n\n\\begin{proof}\nLet $\\epsilon > 0$ be given. Let $K = \\max\\{2K_1, 4K_2-1, 4K_3-1\\}$. Then for all $n \\geq K$, we have:\n\\[ \\begin{cases}\n\t|a_n-a| = |a_{2k}-a| < \\epsilon & \\text{if } n = 2k \\text{\t(since $k = \\frac{n}{2} \\geq \\frac{K}{2} \\geq K_1$)} \\\\\n      \t|a_n-a| = |a_{4k-1}-a| < \\epsilon & \\text{if } n = 4k-1 \\text{\t(since $k = \\frac{n+1}{4} \\geq \\frac{K+1}{4} \\geq K_2$)} \\\\\n      \t|a_n-a| = |a_{4k-3}-a| < \\epsilon & \\text{if } n = 4k-3 \\text{\t(since $k = \\frac{n+3}{4} \\geq \\frac{K+3}{4} \\geq K_3$)} \\\\\n\\end{cases} \n\\]\n\\end{proof}\n\n\\section{Question 3}\nNote that $$x_1 = 6, x_2 = 5.33, x_3 = 5.12, x_4 = 5.05, x_5 = 5.02, x_6 = 5.01, ...$$  \n\\begin{proof} \nWe first show that $x_n \\geq 5$ for all $n \\in \\N$. Let $P(n)$ be the statement that $x_n \\geq 5$. Clearly, $P(1)$ holds, as $x_{1} = 6 \\geq 5$. Assume $P(k)$ holds, i.e. $x_k \\geq 5$. Then $x_{k+1} = \\dfrac{8x_k}{3+x_k} = 8 - \\dfrac{24}{3+x_k} \\geq 8 - \\dfrac{24}{3+5}$, which gives $x_{k+1} \\geq 5$. So, $P(k+1)$ holds. Thus, by the principle of mathematical induction,  $x_n \\geq 5$ for all $n \\in \\N$, i.e., $(x_n)$ is bounded below by 5. \\\\\\\\\nNow we show that $x_n$ is decreasing for all $n \\in \\N$. Let $D(n)$ be the statement $x_{n+1} \\leq x_{n}$. Then, since $x_2 = \\dfrac{48}{9} \\leq 6$, $D(1)$ holds. Assume $D(k)$ holds, i.e. $x_{k+1} \\leq x_{k}$. Then $x_{k+2} - x_{k+1} = \\dfrac{8x_{k+1}}{3+x_{k+1}} - \\dfrac{8x_{k}}{3+x_{k}} = \\dfrac{24(x_{k+1}-x_{k})}{(3+x_{k+1})(3+x_{k})}$. Note that $(3+x_{k+1})(3+x_{k}) \\geq 0$, since $x_k \\geq 5$ for all $k \\in \\N$, and by our induction hypothesis, $x_{k+1}-x_{k} \\leq 0$. Thus, $\\dfrac{24(x_{k+1}-x_{k})}{(3+x_{k+1})(3+x_{k})} \\leq 0$. So, $D(k+1)$ holds. Thus, by the principle of mathematical induction,  $x_{n+1} \\leq x_{n}$ for all $n \\in \\N$, i.e., $x_n$ is decreasing. \\\\\\\\\nSince $(x_n)$ is decreasing and bounded below, by Corollary 3.3.2(ii), it follows from the Monotone Convergence Theorem that $(x_n)$ converges. Let $\\lim\\limits_{n \\to \\infty}{x_{n}} = x \\in \\R$. By Theorem 3.4.1, as $(x_{n+1})$ is a subsequence of $(x_n)$, we know that  $\\lim\\limits_{n \\to \\infty}{x_{n+1}} = \\lim\\limits_{n \\to \\infty}{x_{n}} = x$. Hence,\n\\begin{align*}\nx = \\lim\\limits_{n \\to \\infty}{x_{n+1}} &= \\lim\\limits_{n \\to \\infty}{\\dfrac{8x_n}{3+x_n}} \\\\\n&= \\dfrac{\\lim\\limits_{n \\to \\infty}{8x_n}}{\\lim\\limits_{n \\to \\infty}{3+x_n}} && \\text{(as $x_n$ is bounded below by 5, so $3+x_n \\neq 0$ for any $n$)} \\\\\n&= \\dfrac{8\\cdot\\lim\\limits_{n \\to \\infty}{x_n}}{3+\\lim\\limits_{n \\to \\infty}{x_n}} \\\\\n&= \\dfrac{8x}{3+x} \n\\end{align*} \nThus, $x = \\dfrac{8x}{3+x}$, which gives $x^2-5x = 0$. So either $x = 5$ or $x = 0$. Let $y_n = 5$ be a constant sequence. So, by Theorem 3.2.9(b), as $x_n \\geq 5$ (from above), $x = \\lim\\limits_{n \\to \\infty}{x_{n}} \\geq \\lim\\limits_{n \\to \\infty}{y_{n}} = 5$. Hence, $x = 5$.\n\\end{proof}\n\n\\section{Question 4}\n\\begin{proof}\nLet $m_1 = \\liminf x_n$, $m_2 = \\liminf y_n$ and $m = \\min\\{m_1, m_2\\}$. Note that as $(x_n), (y_n)$ are bounded, $\\exists a, b, c, d \\in \\R$ such that $a \\leq x_n \\leq b$ and $c \\leq y_n \\leq d$ for all $n \\in \\N$. As $z_n = \\min\\{x_n, y_n\\}$, each term in $(z_n)$ is either in $(x_n)$ or $(y_n)$. So, $\\min\\{a, c\\} \\leq z_n \\leq \\max\\{b, d\\}$, i.e., $z_n$ is bounded. We know that $(\\forall n \\in \\N)[(z_n \\leq x_n) \\land (z_n \\leq y_n)]$, so by Theorem 3.5.4, $\\liminf z_n \\leq \\liminf x_n  = m_1$ and $\\liminf z_n \\leq \\liminf y_n = m_2$. Hence, $\\liminf z_n \\leq \\min\\{m_1, m_2\\} = m$. \\\\\\\\\\ (Note that since $x_n, y_n, z_n$ are bounded, by the Bolzano-Weierstrass Theorem, each of the sequences have at least one convergent subsequence, which means $S(x_n), S(y_n)$, and $S(z_n)$ are non-empty and thus $\\liminf x_n$, $\\liminf y_n$, and $\\liminf z_n$ exist.) \\\\\\\\\nNow let $z \\in S(z_n)$. Then, there exists a subsequence $(z_{n_k})$ of $(z_n)$ (with each $n_k \\geq k$) such that $\\lim\\limits_{n \\to \\infty}{z_n} = z$. Now as $(x_n), (y_n)$ are bounded sequences, by Theorem 3.5.2: \n$$(\\forall \\epsilon > 0)(\\exists K_1 \\in \\N)[n \\geq K_1 \\Rightarrow x_n > m_1-\\epsilon]$$ \n\\begin{center} and \\end{center}\n$$(\\forall \\epsilon > 0)(\\exists K_2 \\in \\N)[n \\geq K_2 \\Rightarrow y_n > m_2-\\epsilon]$$ \\\\\nSo, let $\\epsilon > 0$ be given and $K = \\max\\{K_1, K_2\\}$. Then $(\\forall n \\geq K)[(x_n > m_1-\\epsilon) \\land (y_n > m_2-\\epsilon)]$. So, $(x_n > \\min\\{m_1-\\epsilon, m_2-\\epsilon\\}) \\land (y_n > \\min\\{m_1-\\epsilon, m_2-\\epsilon\\})$. Hence, $z_n > \\min\\{m_1-\\epsilon, m_2-\\epsilon\\}$. As $\\epsilon$ is a constant, we get $z_n > \\min\\{m_1, m_2\\} - \\epsilon$, which is equivalent to $z_n > m - \\epsilon$. Now, as $(z_{n_k})$ is a subsequence of $(z_n)$, $n_k \\geq k$, so:\n\\begin{align*}\nk \\geq K &\\Rightarrow n_k \\geq k \\geq K \\\\\n&\\Rightarrow z_{n_k} > m - \\epsilon \\\\\n&\\Rightarrow z_{n_k} \\geq m - \\epsilon\n\\end{align*} \nThus, we have shown that $(\\forall \\epsilon > 0)(\\exists K \\in \\N)[k \\geq K \\Rightarrow z_{n_k} \\geq m-\\epsilon]$. Now, if we let $k \\to \\infty$, by Theorem 3.2.9, $z = \\lim\\limits_{n \\to \\infty}{z_{n_k}} \\geq m - \\epsilon$. As $\\epsilon > 0$ is arbitrary, $z \\geq m$. \\\\\\\\\nHence, as $z$ is arbitrary, we have shown that $(\\forall z \\in S(z_n))[z \\geq m]$. So, $m$ is a lower bound of $S(z_n)$. By definition, $\\inf{S(z_n)}$ is greatest lower bound of $S(z_n)$, so $\\liminf z_n \\geq m$. \\\\\\\\\nConsequently, as $(\\liminf z_n \\geq m) \\land (\\liminf z_n \\leq m)$, $\\liminf z_n = m = \\min\\{\\liminf x_n,\\liminf y_n\\}$, as required.\n\\end{proof}\n\n\\section{Question 5}\n\\subsection{(a)}\nFalse\n\\subsection{(b)}\nFalse\n\\subsubsection{(i)}\nFalse\n\\subsubsection{(ii)}\nFalse\n\n\\end{document}", "meta": {"hexsha": "6f5ebfcf6a83c3b5e099f1e8dfcf408919e47b85", "size": 9874, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW Template.tex", "max_stars_repo_name": "Prabhav10/LaTeX", "max_stars_repo_head_hexsha": "ac256bb388682faf6a609bd5b7337a2a147a4265", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 52, "max_stars_repo_stars_event_min_datetime": "2021-12-23T17:48:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T03:01:42.000Z", "max_issues_repo_path": "HW Template.tex", "max_issues_repo_name": "Prabhav10/LaTeX", "max_issues_repo_head_hexsha": "ac256bb388682faf6a609bd5b7337a2a147a4265", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-12-25T23:17:11.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-26T10:21:59.000Z", "max_forks_repo_path": "HW Template.tex", "max_forks_repo_name": "Prabhav10/LaTeX", "max_forks_repo_head_hexsha": "ac256bb388682faf6a609bd5b7337a2a147a4265", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-12-27T07:26:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T15:20:50.000Z", "avg_line_length": 62.1006289308, "max_line_length": 869, "alphanum_fraction": 0.6180879076, "num_tokens": 4229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.4039985957101876}}
{"text": "\\documentclass[11pt, oneside]{article}   \t% use \"amsart\" instead of \"article\" for AMSLaTex format\n\n\n%\\usepackage{draftwatermark}\n% \\SetWatermarkText{Confidential}\n% \\SetWatermarkScale{5}\n% \\SetWatermarkLightness {0.85} \n% \\SetWatermarkColor[rgb]{0.7,0,0}\n\n\n\\usepackage{geometry}                \t\t% See geometry.pdf to learn the layout options. There are lots.\n\\geometry{letterpaper}                   \t\t% ... or a4paper or a5paper or ... \n%\\geometry{landscape}                \t\t% Activate for for rotated page geometryA. G. Barto, R. S. Sutton, and C. W. Anderson\n%\\usepackage[parfill]{parskip}    \t\t% Activate to begin paragraphs with an empty line rather than an indent\n\\usepackage{graphicx}\t\t\t\t% Use pdf, png, jpg, or eps� with pdflatex; use eps in DVI mode\n\t\t\t\t\t\t\t\t% Tex will automatically convert eps --> pdf in pdflatex\t\t\n\\usepackage{amssymb}\n\\usepackage{mathrsfs}\n\\usepackage{hyperref}\n\\usepackage{url}\n\\usepackage{authblk}\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{graphicx}\n\\usepackage{fixltx2e}\n\\usepackage{hyperref}\n\\usepackage{alltt}\n\\usepackage{color}\n\n\\newcommand{\\argmax}{\\operatornamewithlimits{argmax}}\n\\newcommand{\\argmin}{\\operatornamewithlimits{argmin}}\n\n\\DeclareMathOperator{\\E}{\\mathbb{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\n\n\n\\title{The Law of Large Numbers and Policy Gradients}\n\\author{David Meyer \\\\ dmm@\\{1-4-5.net,uoregon.edu,...\\}}\n\n\\date{Last update: \\today}\t\t\t\t\t\t\t% Activate to display a given date or no date\n\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction} \n\nThe \\emph{Strong Law of Large Numbers} (LLN) is usually stated as follows: \n\n\\bigskip\n\\noindent\nLet $x_{1}, x_{2}, \\hdots, x_{M}$ be a sequence of independent and identically distributed (i.i.d) random variables, each having a finite mean $\\mu_i = E[x_{i}]$. \n\n\\bigskip\n\\noindent\nThen with probability one\n\\begin{equation}\n\\frac{1}{M}\\sum\\limits_{i=1}^{M} x_i \\rightarrow E[x]\n\\end{equation}\nas  $M \\rightarrow \\infty$.\n\n\\bigskip\n\\noindent\nA complementary theorem, Ergodic Theorem, is stated as follows:\n\\bigskip\n\\noindent\nLet $\\theta^{(1)}, \\theta^{(2)}, \\hdots, \\theta^{(M)}$ be $M$ samples from a Markov chain that is \\emph{aperiodic}, \\emph{irreducible}, and \\emph{positive recurrent}\\footnote{In this case, the chain is said to be \\emph{ergodic}.}, and $E[g(\\theta)] < \\infty$.\n\n\\bigskip\n\\noindent\nThen with probability one\n\\begin{equation}\n\\frac{1}{M}\\sum\\limits_{i = 1}^{M} g(\\theta_{i}) \\rightarrow E[g(\\theta)]  = \\int_{\\Theta}^{}g(\\theta) \\: \\pi(\\theta) \\:d\\theta\n\\end{equation}\nas $M \\rightarrow \\infty$ and where $\\pi$ is the stationary distribution of the Markov chain.\n\n\\section{The LLN and Likelihood Ratio Policy Gradients} \nSuppose that $r(x)$ is a performance measure that depends on some random variable $X$, and \n$q(x; \\theta)$ is the is the probability that $X = x$, \nparameterized by $\\theta \\in \\mathbb{R}^K$. Under mild regularity conditions, the gradient with respect to $\\theta$ \nof the expected performance $\\eta(\\theta)$ can be seen to be the following:\n\n\\begin{flalign}\n\\eta(\\theta) &= \\E_{x \\sim q(xl \\theta)} [r(x)] \n \\: \\quad \\qquad \\qquad \\qquad \\qquad \\qquad \\mathrel{\\#} \\text{definition of }  \\eta(\\theta) \\\\\n&= \\sum\\limits_{x} r(x) \\cdot q(x; \\theta) \n \\: \\; \\qquad \\qquad \\qquad \\qquad \\qquad \\mathrel{\\#} \\text{definition of expectation}  \\\\\n\\nabla \\eta(\\theta)  &= \\sum_{x} r(x) \\nabla_{\\theta} q(x; \\theta) \n\\qquad \\qquad \\qquad \\qquad \\qquad \\mathrel{\\#} \\text{take the derivative of both sides}  \\\\\n&= \\sum_{x} r(x) \\frac{\\nabla_{\\theta} q(x; \\theta)}{q(x; \\theta)} q(x; \\theta) \n\\quad \\qquad \\qquad \\qquad \\mathrel{\\#} \\text{multiply by } 1 = \\frac{q(x; \\theta)} {q(x; \\theta)} \\\\\n&= \\E_{x \\sim q(x;\\theta)} r(x)  \\frac{\\nabla_{\\theta} q(x; \\theta)}{q(x; \\theta)}\n \\; \\quad \\qquad \\qquad \\qquad \\mathrel{\\#} \\text{definition of expectation} \n\\end{flalign}\n\n\\bigskip\n\\noindent\nSo our gradient \n$\\nabla_{\\theta} \\eta(\\theta) = \\E_{x \\sim q(x;\\theta)} r(x)  \\frac{\\nabla_{\\theta} q(x; \\theta)}{q(x; \\theta)}$, which \nmeans we can estimate the expectation (gradient) with \n\n\\begin{equation*}\n\\hat{\\eta}(\\theta) = \\frac{1}{N} \\sum\\limits_{i = 1}^N  r(x)  \\frac{\\nabla_{\\theta} q(x; \\theta)}{q(x; \\theta)}\n\\end{equation*}\n\n\\bigskip\n\\noindent\nNow, given the law of large numbers we know \n\n\\begin{flalign*}\n\\hat{\\eta}(\\theta) \\rightarrow \\eta(\\theta) \\text{ with probability one}\n\\end{flalign*}\n\n\\bigskip\n\\noindent\nThis means our gradient estimator ($\\hat{\\eta}(\\theta)$) is \\emph{unbiased} since its expected value \nequals the true gradient. Specifically:\n\n\\begin{flalign}\n\\E[\\hat{\\eta}(\\theta)] &= \\nabla \\eta(\\theta) \n\\end{flalign}\n\n\n\n\\newpage\n\\bibliographystyle{ieeetr}\n\\bibliography{/Users/dmm/papers/bib/ml}\n\n\n\n\\end{document} \n", "meta": {"hexsha": "324a150a05421117259ddcb8d489c76fc4b36217", "size": 4710, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "_my_stuff/papers/ml/lln_policy_gradients/lln_policy_gradient.tex", "max_stars_repo_name": "davidmeyer/davidmeyer.github.io", "max_stars_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_my_stuff/papers/ml/lln_policy_gradients/lln_policy_gradient.tex", "max_issues_repo_name": "davidmeyer/davidmeyer.github.io", "max_issues_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_my_stuff/papers/ml/lln_policy_gradients/lln_policy_gradient.tex", "max_forks_repo_name": "davidmeyer/davidmeyer.github.io", "max_forks_repo_head_hexsha": "14f01e0a50b9c643b5176a10c840f270b9da7bc1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1492537313, "max_line_length": 259, "alphanum_fraction": 0.68492569, "num_tokens": 1604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621764862150636, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4039768740173003}}
{"text": "\\chapter{AHTR Optimization Preliminary Work}\n\\label{chap:rollo-demo}\nThis chapter demonstrates the preliminary work completed for \\gls{AHTR} optimization. \nI used \\gls{ROLLO} to apply genetic algorithms to maximize $k_{eff}$ in a single \n\\gls{AHTR} fuel slab. \nThen, I presented spatial and energy homogenizations for applications to \n\\gls{AHTR} multiphysics simulations.\nThe \\texttt{dissertation-results} Github repository contains all the scripts, \nresults, and plots shown in this chapter \\cite{chee_dissertation_2021}.\n\n\\section{ROLLO Optimization: AHTR Fuel Slab}\n\\label{sec:rollo_opt_ahtr_slab}\nThis demonstration problem explores how heterogenous fuel distributions impact \n$k_{eff}$ compared with homogenous fuel distributions customary in most reactor \ndesigns. \nI use OpenMC v0.12.0 \\cite{romano_openmc_2013} for these neutronics calculations \nwith the ENDF/B-VII.1 data library \\cite{chadwick_endf/b-vii.1_2011}. \n\n\\subsection{Problem Definition}\nThe reactor core explored is a single fuel slab from the \\gls{FHR} benchmark\n\\gls{AHTR} design.\nI modified the fuel slab to be straightened with perpendicular sides, instead \nof slanted as in Figure \\ref{fig:ahtr-fuel-plank}. \nFigure \\ref{fig:straightened_slab} illustrates the straightened fuel slab with \nperiodic boundary conditions in the x-y axis. \nThe periodic surfaces are: 1-3, 2-4. \n\\begin{figure}[]\n    \\centering\n    \\includegraphics[width=0.85\\linewidth]{straightened_slab.png}\n    \\begin{tikzpicture}\n        \\draw[ thick,-latex] (0,0) -- (1,0) node[anchor=south west] {$x$};\n        \\draw[ thick,-latex] (0,0) -- (0,1) node[anchor=south west] {$y$};\n        \\draw[ thick,-latex] (0,0) -- (1,1) node[anchor=south west] {$z$};\n       \\tkzText[above](-0.3,-0.7){}\n       \\end{tikzpicture} \n    \\raggedright\n    \\resizebox{0.3\\textwidth}{!}{\n        \\hspace{1cm}\n        \\fbox{\\begin{tabular}{ll}\n            \\textcolor{fhrblue}{$\\blacksquare$} & FLiBe \\\\\n            \\textcolor{fhrgrey}{$\\blacksquare$} & Graphite (Fuel Plank)\\\\\n            \\textcolor{fhrred}{$\\blacksquare$} & Graphite (Fuel Stripe) \\\\\n            \\textcolor{fhrblack}{$\\blacksquare$} & TRISO particle \n\n            \\end{tabular}}}\n    \\caption{Straightened \\acrfull{AHTR} fuel slab, with x-y periodic surfaces: \n    1-3, 2-4, and reflective z-axis surfaces (out of the page). Original slanted\n    fuel slabs can be seen in Figures \\ref{fig:ahtr-fuel-assembly} \n    and \\ref{fig:ahtr-fuel-plank}.}\n    \\label{fig:straightened_slab}\n\\end{figure}\nThe slab has $27.1 \\times 3.25 \\times 1.85\\ cm^3$ dimensions with reflective \ntop and bottom (along z-axis) boundary conditions.\nI use the same materials as in the \\gls{FHR} benchmark, except that I homogenized \neach \\gls{TRISO} particle's four outer layers: \nporous carbon buffer, inner pyrolytic carbon, silicon carbide layer, and the \nouter pyrolytic carbon. \nThe \\gls{TRISO} particle dimensions remain the same.\nTable \\ref{tab:keff_triso} reports the $k_{eff}$ for this original straightened \n\\gls{AHTR} configuration with and without the outer layer \\gls{TRISO} \nhomogenization.\n\\begin{table}[]\n    \\centering\n    \\onehalfspacing\n    \\caption{Straightened \\acrfull{AHTR} fuel slab $k_{eff}$ for case with \n    no \\gls{TRISO} homogenization and case with homogenization of the four outer \n    layers. Both simulations were run on one BlueWaters XE Node.}\n\t\\label{tab:keff_triso}\n    \\footnotesize\n    \\begin{tabular}{llc}\n    \\hline \n    \\textbf{TRISO Homogenization}& \\textbf{$k_{eff}$} & \\textbf{Simulation time [s]}  \\\\\n    \\hline \n    None & $1.38548 \\pm 0.00124$ & 233\\\\ \n    Four outer layers & $1.38625 \\pm 0.00109$ & 168\\\\ \n    \\hline\n    \\end{tabular}\n\\end{table}\nThe \\gls{TRISO} particle outer four-layer homogenization resulted in a $30\\%$ \nspeed-up without compromising accuracy with $k_{eff}$ values within each \nother's uncertainty.\n\nThe \\gls{ROLLO} optimization objective aims to maximize the slab $k_{eff}$. \nIt does so by varying the \\gls{TRISO} particle packing fraction across the slab\nwhile keeping the total packing fraction constant at 0.0979. \nThis total packing fraction is consistent with the original straightened slab with \nTRISO particles in fuel stripes (Figure \\ref{fig:straightened_slab}). \nI divided the slab into ten cells along the x-axis between the \\gls{FLiBe} and \ngraphite buffers, resulting in ten $2.31 \\times 2.55 \\times 1.85\\ cm^3$ cells. \nA sine distribution governs the \\gls{TRISO} particle packing fraction's \ndistribution across cells:\n\\begin{align}\n    PF(x) &= \\left(a\\cdot sin(b\\cdot x + c) + 2\\right) \\cdot NF\\\\\n    \\intertext{where}\n    PF &= \\mbox{packing fraction } [-] \\nonumber \\\\ \n    a &= \\mbox{amplitude, peak deviation of the function from zero } [-] \\nonumber \\\\\n    b &= \\mbox{angular frequency, rate of change of the function argument } [\\frac{radians}{cm}] \\nonumber \\\\\n    c &= \\mbox{phase, the position in its cycle the oscillation is at t = 0 } [radians]\\nonumber \\\\\n    x &= \\mbox{midpoint value for each cell } [cm]\\nonumber \\\\\n    NF &= \\mbox{Normalization factor } [-]\\nonumber\n\\end{align}\nThe normalization factor ensures a consistent total packing fraction \nin the slab regardless the \\gls{TRISO} particle distribution.\nFor example, a packing fraction distribution of \n$PF(x) = \\left(0.5\\cdot sin(\\frac{\\pi}{3}\\cdot x + \\pi) + 2\\right)  \\cdot NF$, \nresults in the following packing fractions for the ten cells: 0.103, 0.120, \n0.049, 0.138, 0.076, 0.081, 0.136, 0.048, 0.125, and 0.098. \nFigure \\ref{fig:triso_distribution} shows this sine distribution, highlights \nthe packing fraction at the respective midpoints, and displays the slab's x-y \naxis view with packing fraction varying based on this sine distribution. \n\\begin{figure}[]\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{triso_distribution_sine.png}} \n    \\caption{Above: Straightened \\acrfull{AHTR} fuel slab with varying \\gls{TRISO} particle \n    distribution across ten cells based on the sine distribution. \n    Below: $PF(x) = (0.5\\ sin(\\frac{\\pi}{3}x + \\pi) + 2)  \\times NF$ \n    sine distribution with red points indicating the packing fraction at each cell. }\n    \\label{fig:triso_distribution}\n\\end{figure}\n\nIn \\gls{ROLLO}, a genetic algorithm varies the $a$, $b$, and $c$ variables to \nfind a combination that produces a packing fraction distribution that maximizes \nthe slab's $k_{eff}$. \nI defined $a$, $b$, and $c$'s upper and lower bounds as: \n\\begin{align*}\n    0 <\\ &a < 2 \\\\\n    0 <\\ &b < \\frac{\\pi}{2} \\\\\n    0 <\\ &c < 2 \\pi\n\\end{align*}\nThe bounds of $a$ keep the sine distribution from falling \nbelow zero. \nThe $b$ and $c$ variable bounds spread wide enough to allow the genetic \nalgorithm to explore various sine distributions. \nThe OpenMC evaluator calculates $k_{eff}$. \nOpenMC runs each simulation with 80 active cycles, 20 inactive cycles, and \n8000 particles to reach $\\sim$130pcm uncertainty. \nFigure \\ref{fig:rollo-input-simple} shows the \\gls{ROLLO} input file for this \ngenetic algorithm optimization problem. \n\\texttt{ahtr\\_slab\\_openmc.py} is the template OpenMC straightened \\gls{AHTR} \nslab script that accepts $a$, $b$ and $c$ from \\gls{ROLLO}, calculates packing \nfraction distribution, and assigns packing fraction values to each fuel cell. \nSubsequently, \\gls{ROLLO} runs the templated OpenMC script to generate $k_{eff}$. \n\\begin{figure}[]\n    \\begin{minted}[\n        frame=lines,\n        framesep=2mm,\n        baselinestretch=1.2,\n        fontsize=\\footnotesize,\n        linenos\n        ]{json}\n        {\n            \"control_variables\": {\n                \"a\": {\"min\": 0.0, \"max\": 2.0},\n                \"b\": {\"min\": 0.0, \"max\": 1.57},\n                \"c\": {\"min\": 0.0, \"max\": 6.28},\n            },\n            \"evaluators\": {\n                \"openmc\": {\n                    \"input_script\": \"ahtr_slab_openmc.py\",\n                    \"inputs\": [\"a\", \"b\", \"c\"],\n                    \"outputs\": [\"keff\"],\n                    \"keep_files\": false,\n                }\n            },\n            \"constraints\": {\"keff\": {\"operator\": [\">=\"], \"constrained_val\": [1.0]}},\n            \"algorithm\": {\n                \"objective\": \"max\",\n                \"optimized_variable\": \"keff\",\n                \"pop_size\": 60,\n                \"generations\": 10,\n                \"mutation_probability\": 0.23,\n                \"mating_probability\": 0.46,\n                \"selection_operator\": {\"operator\": \"selTournament\", \"inds\": 15, \"tournsize\": 5},\n                \"mutation_operator\": {\n                    \"operator\": \"mutPolynomialBounded\",\n                    \"eta\": 0.23,\n                    \"indpb\": 0.23,\n                },\n                \"mating_operator\": {\"operator\": \"cxBlend\", \"alpha\": 0.46},\n            },\n        }\n        \n    \\end{minted}\n    \\caption{\\acrfull{ROLLO} JSON input file to maximize $k_{eff}$ in the \n    straightened \\acrfull{AHTR} fuel slab by varying packing fraction distribution \n    with control variables $a$, $b$, and $c$.}\n    \\label{fig:rollo-input-simple}\n\\end{figure}\n\n\\subsection{Hyperparameter Search}\n\\label{sec:hyperparameter_search}\nIn a \\gls{ROLLO} input file, the user defines hyperparameters for the genetic \nalgorithm.\nA good hyperparameter set guides the optimization process by \nbalancing exploitation and exploration to find an optimal solution quickly \nand accurately. \nFinding a good hyperparameter set requires a trial-and-error process. \n\nI performed the hyperparameter search with a coarse-to-fine random sampling scheme, \nwhose advantages I previously discussed in Section \\ref{sec:balance}.\nThe hyperparameters varied included population size, number of generations, \nmutation probability, mating probability, selection operator, selection operator's \nnumber of individuals, selection operator's tournament size, mutation operator, \nand mating operator.  \nI started with 25 coarse experiments and fine-tuned the hyperparameters\nwith 15 more experiments. \nFor each genetic algorithm experiment, the number of OpenMC evaluations remained\nconstant at 600.\nThe number of evaluations correlated the population size and number of generations. \nI randomly sampled population size and used the following equation to calculate \nthe number of generations: \n\\begin{align}\n    \\mbox{no. of generations} &= \\frac{\\mbox{no. of evaluations}}{\\mbox{population size} }\n\\end{align}\nTable \\ref{tab:hyperparameter_search} shows the lower and upper bounds used \nfor randomly sampling each hyperparameter.\n\\begin{table}[]\n    \\centering\n    \\onehalfspacing\n    \\caption{Hyperparameter search is conducted in three phases: \\textit{Coarse Search}, \n    \\textit{Fine Search 1}, \\textit{Fine Search 2}. Each hyperparameter's lower and\n    upper bounds for each search phase are listed.}\n\t\\label{tab:hyperparameter_search}\n    \\footnotesize\n    \\makebox[\\textwidth][c]{\\begin{tabular}{p{4cm}lp{3.4cm}p{3.4cm}p{3.4cm}}\n    \\hline \n    \\textbf{Hyperparameter}& \\textbf{Type} & \\textbf{Coarse Search Bounds} & \\textbf{Fine Search 1 Bounds} & \\textbf{Fine Search 2 Bounds} \\\\\n    \\hline\n    Experiments & - & 0 to 24 & 24 to 34 & 35 to 39 \\\\ \n    \\hline\n    Population size (pop) & Continuous & 10 $<$ x $<$ 100 & 20 $<$ x $<$ 60 & 60 \\\\ \n    Mutation probability & Continuous & 0.1 $<$ x $<$ 0.4 & 0.2 $<$ x $<$ 0.4& 0.2 $<$ x $<$ 0.3\\\\\n    Mating probability & Continuous & 0.1 $<$ x $<$ 0.6 &  0.1 $<$ x $<$ 0.3 &  0.45 $<$ x $<$ 0.6\\\\\n    Selection operator & Discrete & \\texttt{SelTournament}, \\texttt{SelBest}, \\texttt{SelNSGA2} & \\texttt{SelTournament}, \\texttt{SelBest}, \\texttt{SelNSGA2}& \\texttt{SelTournament}\\\\\n    Selection individuals & Continuous & $\\frac{1}{3}pop$ $<$ x $<$ $\\frac{2}{3}pop$ & $\\frac{1}{3}pop$ $<$ x $<$ $\\frac{2}{3}pop$ & 15\\\\\n    Selection tournament size (only for SelTournament) & Continuous & 2 $<$ x $<$ 8 &2 $<$ x $<$ 8&5\\\\\n    Mutation operator & Discrete & \\texttt{mutPolynomialBounded} &\\texttt{mutPolynomialBounded}&\\texttt{mutPolynomialBounded}\\\\\n    Mating operator & Discrete& \\texttt{cxOnePoint}, \\texttt{cxUniform}, \\texttt{cxBlend} &\\texttt{cxOnePoint}, \\texttt{cxUniform}, \\texttt{cxBlend}&\\texttt{cxOnePoint}, \\texttt{cxBlend}\\\\ \n    \\hline\n    \\end{tabular}}\n\\end{table}\n\nThe initial 25 coarse experiments' sought to narrow down the hyperparameters \nto find a smaller set of hyperparameter bounds that produce higher $k_{eff}$ values.\nFigure \\ref{fig:hyperparameter_sens} shows the hyperparameters' plotted against \neach other with a third color dimension representing the average $k_{eff}$ value\n($\\overline{k_{eff}}$) in each experiment's final generation. \nLighter scatter points indicate higher final population $\\overline{k_{eff}}$ values, \nwhich suggests better hyperparameter sets. \n\\begin{figure}[]\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.3\\linewidth]{hyperparameter_sens.png}} \n    \\caption{Coarse hyperparameters search's results. Hyperparameter values are plotted \n    against each other with a third color dimension representing each experiment's \n    final population's $\\overline{k_{eff}}$.}\n    \\label{fig:hyperparameter_sens}\n\\end{figure}\nI plotted the hyperparameters against each other to visualize the interdependence \nbetween hyperparameters. \nFrom the coarse hyperparameter search, I noticed the following trends: \n\\begin{itemize}\n    \\item Mutation probability has a higher $\\overline{k_{eff}}$, between 0.2 and 0.4. \n    \\item Mating probability has a higher $\\overline{k_{eff}}$, between 0.1 and 0.3. \n    \\item Population size has a higher $\\overline{k_{eff}}$, between 20 and 60. \n    \\item No obvious interdependence between hyperparameters. \n\\end{itemize} \n\nNext, I proceeded to the fine searches. \nFrom Figure \\ref{fig:hyperparameter_sens}, I narrowed down population size, \nmutation probability, and mating probability bounds, as shown in Table \n\\ref{tab:hyperparameter_search}'s \\textit{Fine Search 1 Bounds} column. \nI found no significant trends in the other hyperparameters, so I left them \nas is. \nI ran ten more experiments (25 to 34), sampling hyperparameters from \nthe \\textit{Fine Search 1 Bounds}. \nFrom these results, I conducted a second fine search with five experiments \n(35 to 39) with further tuned hyperparameter bounds, as shown in Table \n\\ref{tab:hyperparameter_search}'s \\textit{Fine Search 2 Bounds} column. \nI determined these new hyperparameter bounds based on these reasons: \n\\begin{itemize}\n    \\item Mutation probability has a higher $\\overline{k_{eff}}$, between 0.2 and 0.3.\n    \\item I overlooked $\\overline{k_{eff}}$  peaking at mating probability between \n    0.45 and 0.6 in the previous \\textit{Fine Search 1}, thus shifted the bounds. \n    \\item The highest $\\overline{k_{eff}}$ occurred for \\texttt{selTournament}. \n    \\item I narrowed down mating operator options to \\texttt{cxBlend} and \n    \\texttt{cxOnePoint} since they had higher $\\overline{k_{eff}}$. \n    \\item I selected arbitrary numbers for population size, \n    selection individuals, and tournament size since they did not \n    correlate with $\\overline{k_{eff}}$ values. \n\\end{itemize}\nFigure \\ref{fig:input_hyperparameters_sens} shows the relationship between \nhyperparameter values and $a$, $b$, $c$ control parameters, final generation \n$k_{eff max}$, and final generation $\\overline{k_{eff}}$. \nThe coarse experiments' scatter points are $50\\%$ transparent, while the fine \nexperiments' scatter points are opaque. \n\\begin{figure}[]\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.3\\linewidth]{input_hyperparameters_sens.png}} \n    \\caption{Hyperparameters search's results for all 40 experiments (coarse \n    and fine). I plotted the hyperparameters against: a,b,c control parameters, \n    each experiment's final generation $k_{eff max}$, and final generation \n    $\\overline{k_{eff}}$ with a third color dimension representing each experiment's final \n    population's $\\overline{k_{eff}}$ (color bar representing the $k_{eff}$ values \n    provided on the right side of the figure). Coarse experiments' (0 to 24) scatter points \n    are $50\\%$ transparent, while the fine experiments' (24 to 39) scatter points \n    are opaque. }\n    \\label{fig:input_hyperparameters_sens}\n\\end{figure}\nIn Figure \\ref{fig:input_hyperparameters_sens}, on average, the fine experiments \n(opaque scatter points) have higher $\\overline{k_{eff}}$, which indicates that the\nhyperparameter search process met its objective of finding hyperparameter \nbounds that enable quicker and more accurate optimization. \n\nTable \\ref{tab:topfive} shows the hyperparameters for the five experiments \nwith the highest final generation $\\overline{k_{eff}}$.\n\\begin{table}[]\n    \\centering\n    \\onehalfspacing\n    \\caption{Control Parameters, $k_{eff}$ results, and hyperparameter values for \n    the five hyperparameter search experiments with the highest final generation \n    $\\overline{k_{eff}}$.}\n\t\\label{tab:topfive}\n    \\footnotesize\n    \\makebox[\\textwidth][c]{\\begin{tabular}{p{3cm}p{3cm}p{3cm}p{3cm}p{3cm}p{3cm}}\n    \\hline \n    & \\multicolumn{5}{c}{\\textbf{Experiment No.}} \\\\\n    \\cline{2-6}\n    \\textbf{Control/Output Parameters} & \\textbf{6} & \\textbf{15} & \\textbf{24} & \\textbf{36} & \\textbf{39}\\\\\n    \\hline \n    $\\overline{k_{eff}}$ [-] & 1.39876 &1.40155&1.40118&1.39906&1.40165\\\\ \n    $k_{eff max}$ [-] & 1.40954 &1.40440&1.40365&1.40590&1.40519\\\\ \n    a [-] & 1.993&1.998&1.999&1.997&1.989\\\\\n    b [$\\frac{radians}{cm}$] & 0.057&0.367&0.320&0.339&0.354\\\\ \n    c [radians] & 3.571&3.022&3.615&3.053&3.143\\\\\n    \\hline\n    \\textbf{Hyperparameter}& &&&&\\\\\n    Population size & 83 & 28&74&60&60\\\\ \n    Generations &8&22&9&10&10 \\\\\n    Mutation probability & 0.32 &0.26&0.21&0.23&0.23\\\\\n    Mating probability & 0.17 &0.53&0.48&0.59&0.46\\\\\n    Selection operator & \\texttt{selTournament} &\\texttt{selTournament}&\\texttt{selBest}&\\texttt{selTournament}&\\texttt{selTournament}\\\\\n    Selection individuals & 38 &14&25&15&15\\\\\n    Selection tournament size & 7 &5&-&5&5\\\\\n    Mutation operator & \\texttt{mutPolynomial} \\texttt{Bounded}&\\texttt{mutPolynomial} \\texttt{Bounded}&\\texttt{mutPolynomial} \\texttt{Bounded}&\\texttt{mutPolynomial} \\texttt{Bounded}&\\texttt{mutPolynomial} \\texttt{Bounded}\\\\\n    Mating operator & \\texttt{cxOnePoint} &\\texttt{cxOnePoint}&\\texttt{cxUniform}&\\texttt{cxBlend}&\\texttt{cxBlend}\\\\ \n    \\hline\n    \\end{tabular}}\n\\end{table}\nFigure \\ref{fig:topfiveplot} shows the packing fraction distributions that \nproduced the $k_{eff max}$ from the top five experiments. \n\\begin{figure}[]\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1\\linewidth]{topfive_plot.png}} \n    \\caption{Packing fraction distribution across the x-axis of the \\acrfull{AHTR} \n    slab for the five hyperparameter search experiments with the highest final generation \n    $\\overline{k_{eff}}$. $k_{eff}$ uncertainty are $\\sim$130pcm.}\n    \\label{fig:topfiveplot}\n\\end{figure}\nFour experiments had similar packing fraction distributions peaking at approximately \n0.23 in the slab's center. \nIn contrast, one experiment had an exponential-like distribution with a peak \npacking fraction of 0.31 at the slab's side.\nThe similar final packing fraction distributions demonstrate genetic algorithms' \nrobustness to find the optimal global solutions with different hyperparameters. \n\nI ran these simulations on the BlueWaters supercomputer \\cite{ncsa_about_2017}. \nIn each \\gls{ROLLO} simulation, each generation runs a population size number \nof individual OpenMC simulations. \nEach OpenMC simulation takes approximately 13 minutes to run on a single BlueWaters \nXE node. \nWith approximately 600 OpenMC evaluations per \\gls{ROLLO} simulation, the\n\\gls{ROLLO} simulation takes about 130 BlueWaters node-hours. \nThe hyperparameter search ran 40 \\gls{ROLLO} simulations, thus using approximately\n5200 node-hours.\n\n\\subsection{Results for Best Hyperparameter Set}\n\\label{sec:best}\nI define the best-performing hyperparameter set as the experiment that produces \nthe highest $\\overline{k_{eff}}$ in its final generation. \n\\textit{Fine Search 2}'s experiment 39 produces the best performing \nhyperparameter set, shown in Table \\ref{tab:topfive}, with \ncenter-peaking packing fraction distribution of $max(k_{eff}) = 1.40519$. \nExperiment 39's $k_{eff max}$ exceeds the original straightened \\gls{AHTR} \nconfiguration's $k_{eff}$ by $\\sim2000$pcm, demonstrating that optimizing\ninhomogenous fuel distributions enables better neutronics. \nFigure \\ref{fig:triso_distribution_sine_39} shows the packing fraction distribution \nthat produced $k_{eff max} = 1.40519 \\pm 0.00130$. \n\\begin{figure}[]\n    \\centering\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{triso_distribution_sine_39.png}} \n    \\caption{Experiment 39 packing distribution that produced $k_{eff max} = 1.40519 \\pm 0.00130$. \n    Below: $PF(x) = (1.98\\ sin(0.35x+3.14)+2)  \\times NF$ sine distribution with \n    red points indicating the packing fraction at each cell. \n    Above: Straightened \\acrfull{AHTR} fuel slab with varying \\gls{TRISO} particle \n    distribution across ten cells based on the sine distribution. }\n    \\label{fig:triso_distribution_sine_39}\n\\end{figure}\n\nFigures \\ref{fig:keff_conv_39} and \\ref{fig:pf_39} show the $k_{eff}$ evolution\nand packing fraction distribution through the best performing 39$^{th}$ \nexperiment's generations.\n\\begin{figure}[]\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{keff_conv_39.png}} \n    \\caption{Minimum, average, and maximum $k_{eff}$ value evolution.}\n    \\label{fig:keff_conv_39}\n    \\end{subfigure}\n    \\begin{subfigure}{\\textwidth}\n        \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{pf_39.png}} \n        \\caption{$k_{eff max}$ packing fraction distribution evolution.}\n        \\label{fig:pf_39}\n    \\end{subfigure}\n    \\caption{Each generation's results for \\gls{ROLLO}'s genetic algorithm \n    optimization of the Straightened \\acrfull{AHTR} Fuel Slab. The \\gls{ROLLO} \n    simulation used the 39$^{th}$ experiment's hyperparameter set. $k_{eff}$ \n    uncertainty are $\\sim$130pcm.}\n    \\label{fig:39}\n\\end{figure}\nThe $k_{eff max}$ converged quickly by generation 1; however, this usually \ndoes not occur. \nThe genetic algorithm optimizes stochastically, resulting in the possibility \nthat the algorithm randomly samples a control parameter set that maximizes \nthe objective function early in the optimization process. \nThe $\\overline{k_{eff}}$ demonstrates how each generation's average $k_{eff}$\nconverges towards a higher value with each generation's improvements.\nTo demonstrate how the genetic algorithm optimization process usually goes, \nFigures \\ref{fig:keff_conv_15} and \\ref{fig:pf_15} show the $k_{eff}$ evolution \nand packing fraction distribution through the second-best performing 15$^{th}$ \nexperiment's generations.  \nExperiment 15 demonstrates how both maximum and average $k_{eff}$ converge\ntowards a higher $k_{eff}$ with improvements from each generation.\n\\begin{figure}[]\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n    \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{keff_conv_15.png}} \n    \\caption{Minimum, average, and maximum $k_{eff}$ values evolution.}\n    \\label{fig:keff_conv_15}\n    \\end{subfigure}\n    \\begin{subfigure}{\\textwidth}\n        \\makebox[\\textwidth][c]{\\includegraphics[width=1.1\\linewidth]{pf_15.png}} \n        \\caption{$k_{eff max}$'s packing fraction distribution evolution.}\n        \\label{fig:pf_15}\n    \\end{subfigure}\n    \\caption{ Results for each generation for \\gls{ROLLO}'s genetic algorithm optimization \n    of the Straightened \\acrfull{AHTR} Fuel Slab. The \\gls{ROLLO} simulation used \n    the 15$^{th}$ experiment's hyperparameter set. $k_{eff}$ uncertainty are $\\sim$130pcm.}\n    \\label{fig:15}\n\\end{figure}\n\nIn both Experiments 39 and 15, packing fractions peaked at approximately \n0.23 in the slab center and decreased to zero at the sides.  \nThe amplitude, $a$, for the packing fraction distribution that produced $k_{eff max}$ \nfor Experiment 39 and the other top-five experiments (Table \\ref{tab:topfive}) \nhave settled at the upper bound of approximately 2. \nA large sine distribution amplitude, $a$, demonstrates that a slab geometry \nwith larger packing fraction variations results in a higher $k_{eff}$. \nThese observations about packing fraction distribution for $k_{eff max}$ are \nconsistent with conclusions from the \\gls{FHR} benchmark (Chapter \n\\ref{chap:fhr-benchmark}): a high $k_{eff}$ occurs with a good balance between \nfuel loading and moderation space. \nFission occurs at high \\gls{TRISO} particle concentration areas at thermal flux;\nhowever, the neutrons are born at fast flux and require moderation to slow down \nto thermal ranges.\nTherefore, larger moderation areas ensure higher resonance escape probability for \nthe fast neutrons resulting in higher thermal flux, leading to more \nfission occurring and a higher $k_{eff}$. \n\nI also observed that \\gls{TRISO} particle packing fraction peaks in the center \nof the slab, showing that if the optimization problem focuses purely on the \nslab's neutronics by maximizing $k_{eff}$, the fuel tends to culminate in the \nmiddle. \nCenter-peaking fuel density is nonideal for other key reactor core \nqualities, such as maximal heat transfer and minimal power peaking factor (PPF).\nThus, the \\gls{AHTR} slab optimization problem must be extended to include \nthese key reactor core qualities. \n\n\\section{AHTR Multiphysics Model Preliminary Work}\n\\label{sec:multiphysics_homo}\n% compare TRISO particles \nIn the proposed PhD scope, I will use the open-source simulation tool, Moltres, \nto conduct \\gls{AHTR} multiphysics simulations. \nMoltres, an application built atop the \\gls{MOOSE} parallel finite element \nframework \\cite{gaston_moose:_2009}, contains physics kernels and boundary \nconditions to solve arbitrary-group deterministic neutron diffusion and \nthermal-hydraulics \\glspl{PDE} simultaneously on a single mesh\n\\cite{lindsay_introduction_2018,park_advancement_2020}. \n\\gls{AHTR} Moltres simulations will capture thermal feedback effects, absent\nfrom the purely neutronics OpenMC simulations.  \nThe objective of setting up the Moltres \\gls{AHTR} simulation is to eventually \ncouple Moltres with \\gls{ROLLO} for \\gls{AHTR} multiphysics optimization. \n\nThe benefits of Moltres over other multiphysics software, RELAP5 and NESTLE \n(used previously for \\gls{AHTR} modeling and described in Section \n\\ref{sec:previous_ahtr}) for the purposes of this work, for coupled neutronics \nand thermal-hydraulics simulation are: \n\\begin{itemize}\n  \\item Moltres supports up to 3-D meshes, solving neutron diffusion and \n  thermal-hydraulics \\glspl{PDE} simultaneously on the same mesh \n  \\cite{park_advancement_2020}. This is much more flexible than \n  \\gls{NESTLE} and RELAP5, which only support rectangular and hexagonal assembly \n  lattices. Therefore, Moltres can explore arbitrary reactor geometries easily.\n  \\item Moltres tightly couples neutronics and thermal-hydraulics, thus providing\n    higher accuracy in some tightly coupled problems. \n  \\item Moltres, a \\gls{MOOSE}-based application, uses MPI for parallel computing,\n  and compiles and runs on \\glspl{HPC}. \n\\end{itemize}\n\nTo run Moltres simulations, the user provides group constant data from a neutron \ntransport solver, such as OpenMC, for the Moltres multigroup neutron diffusion \ncalculations and a mesh file representing the reactor geometry. \nA TRISO-level fidelity mesh file is impractical and will result in an extremely \nlong Moltres runtime. \nFor successful \\gls{AHTR} Moltres simulation, I must establish \nsuitable spatial and energy homogenization that preserves accuracy while \nmaintaining an acceptable runtime.\n\n\\subsection{Straightened AHTR Fuel Slab Multigroup Simulation}\nI use the continuous energy OpenMC simulation to generate \nmultigroup cross section data defined over discretized energy groups \nand spatial segments. \nI then use OpenMC's multigroup calculation mode with the previously generated \nmultigroup cross section data to calculate $k_{eff}$. \nComparison of $k_{eff}$ for the continuous and multigroup simulations\ndetermines if the energy and spatial homogenization used are acceptable. \n\nIn this section, the straightened AHTR fuel slab simulations use the \\gls{TRISO} \nparticle distribution that generated $k_{eff max}$ from the best hyperparameter \nset (Section \\ref{sec:best}). \nFor spatial homogenization of the straightened \\gls{AHTR} fuel slab, I used \nOpenMC's \\textit{cell} domain type to compute multigroup cross sections for \ndifferent \\textit{cells}. \nI discretized the slab into 13 \\textit{cells}: FLiBe, left graphite, right \ngraphite, and ten fuel cells (each cell has a different packing fraction). \nFigure \\ref{fig:straightened_slab_mg} illustrates the \\gls{AHTR} spatial \nhomogenization for the OpenMC multigroup calculation. \n\\begin{figure}[]\n    \\centering\n    \\includegraphics[width=\\linewidth]{straightened_slab_mg.png}\n    \\raggedright\n    \\resizebox{0.5\\textwidth}{!}{\n        \\hspace{1cm}\n        \\fbox{\\begin{tabular}{llll}\n            \\textcolor{fhrblue}{$\\blacksquare$} & FLiBe & \n            \\textcolor{fhrgrey}{$\\blacksquare$} & Left Graphite \\\\\n            \\textcolor{fhrred}{$\\blacksquare$} & Right Graphite &\n            \\textcolor{fhrpink}{$\\blacksquare$} & Fuel cell 1/6 \\\\\n            \\textcolor{fhryellow}{$\\blacksquare$} & Fuel cell 2/7 &\n            \\textcolor{fhrorange}{$\\blacksquare$} & Fuel cell 3/8 \\\\\n            \\textcolor{fhrgreen}{$\\blacksquare$} & Fuel cell 4/9 &\n            \\textcolor{fhrpurple}{$\\blacksquare$} & Fuel cell 5/10 \\\\\n            \\end{tabular}}}\n    \\caption{Straightened \\acrfull{AHTR} fuel slab spatially discretized into \n    13 \\textit{cells} for OpenMC multigroup calculation.}\n    \\label{fig:straightened_slab_mg}\n\\end{figure}\nI used the four group energy structure derived by Gentry et al. \n\\cite{gentry_development_2016} for \\gls{AHTR} geometries. \nTable \\ref{tab:energy_structures} defines the group boundaries. \n\\begin{table}[]\n    \\centering\n    \\onehalfspacing\n    \\caption{4-group energy structures for \\acrfull{AHTR} geometry \n    derived by \\cite{gentry_development_2016}.}\n\t\\label{tab:energy_structures}\n    \\footnotesize\n    \\begin{tabular}{lll}\n    \\hline\n    \\multicolumn{3}{c}{\\textbf{Group Boundaries [MeV]}} \\\\ \n    \\hline\n    \\textbf{Group $\\#$}& \\textbf{Upper Bound} & \\textbf{Lower Bound}  \\\\\n    \\hline \n    1 & $2.0000\\times 10^1$ & $9.1188\\times 10^{-3}$ \\\\ \n    2 & $9.1188\\times 10^{-3}$ & $2.9023\\times 10^{-5}$\\\\\n    3 & $2.9023\\times 10^{-5}$ & $1.8554\\times 10^{-6}$\\\\\n    4 & $1.8554\\times 10^{-6}$ & $1.0000\\times 10^{-12}$\\\\\n    \\hline\n    \\end{tabular}\n\\end{table}\n\nTable \\ref{tab:keff_multigroup} shows the $k_{eff}$ values from the continuous \nenergy simulation and the spatial and energy homogenized simulation. \nThe 26pcm difference between $k_{eff}$ values is within both uncertainty values, \nassuring that the spatial and energy homogenization used is suitable for generating \ngroup constants for Moltres. \n\\begin{table}[]\n    \\centering\n    \\onehalfspacing\n    \\caption{Straightened \\acrfull{AHTR} fuel slab's $k_{eff}$ for case with \n    continuous energy and space and case with spatial and energy homogenization. \n    Both simulations were run on one BlueWaters XE Node, with 80 active cycles, \n    20 inactive cycles, and 8000 particles.}\n\t\\label{tab:keff_multigroup}\n    \\footnotesize\n    \\begin{tabular}{lll}\n    \\hline \n    \\textbf{Homogenization}& \\textbf{$k_{eff}$} & \\textbf{Simulation time [s]}  \\\\\n    \\hline \n    None & $1.40473 \\pm 0.00115$ & 808\\\\ \n    Spatial and Energy & $1.40499 \\pm 0.00109$ & 50\\\\ \n    \\hline\n    \\end{tabular}\n\\end{table}\n\n\\section{Summary}\nThis chapter demonstrated the preliminary work completed for \\gls{AHTR} \noptimization. \nI conducted a multigroup \\gls{AHTR} slab simulation with four-group energy \nand spatial homogenization, which resulted in $k_{eff}$ within the uncertainty of \nthe continuous energy simulation. \nThe minimal $k_{eff}$ difference assures that I can use these homogenizations \nwhen generating group constants for Moltres. \nI also successfully applied \\gls{ROLLO} to maximize $k_{eff}$ in a straightened \n\\acrfull{AHTR} fuel slab by varying the \\gls{TRISO} particle packing fraction \ndistribution. \nThe optimization process began with a coarse-to-fine random sampling \nhyperparameter search to find the genetic algorithm hyperparameters that worked \nbest. \nExperiment 39 performed the best with a hyperparameter set that produced the \nhighest final generation $\\overline{k_{eff}}$ of 1.40165 $\\pm$ 0.00130. \nThe \\gls{TRISO} particle packing fraction distribution that produced the final \ngeneration's maximum $k_{eff}$ of 1.40519 peaks at the slab's center with \npacking fraction distribution: $PF(x)=1.989\\ sin(0.54x+3.143)$. \nThis demonstration problem had a single objective function of maximizing\n$k_{eff}$. \nHowever, many other objectives should be considered, such as maximizing heat \ntransfer and minimizing power peaking factor.\nThus, in the next chapter, I propose future simulations for optimizing\nthese objective functions simultaneously.\n", "meta": {"hexsha": "513cf286419fdb60967476b44373eb695873bf1e", "size": 33103, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/rollo-demo.tex", "max_stars_repo_name": "gwenchee/2021-chee-prelim", "max_stars_repo_head_hexsha": "e28fae5f64ab4a4464d73b4cc42cb5c767754e5a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/rollo-demo.tex", "max_issues_repo_name": "gwenchee/2021-chee-prelim", "max_issues_repo_head_hexsha": "e28fae5f64ab4a4464d73b4cc42cb5c767754e5a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/rollo-demo.tex", "max_forks_repo_name": "gwenchee/2021-chee-prelim", "max_forks_repo_head_hexsha": "e28fae5f64ab4a4464d73b4cc42cb5c767754e5a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5444444444, "max_line_length": 225, "alphanum_fraction": 0.7229556234, "num_tokens": 9366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4039580821889596}}
{"text": "\\chapter{Modeling  the heterogeneity of the Dox-induced GFP (or mCherry) expressions} % Main chapter title\n\n\\label{Part3_chapter} % For referencing the chapter elsewhere, use \\ref{Chapter1} \n\n\\section{The model}\nIn order to access the heterogeneity of Dox-induced single-cell expressions in both feedback and no-feedback systems, we model the random ﬂuctuation in biochemical reactions, random copy number variation and random epigenetic inheritance in expression systems.\n\n\\subsection{Random epigenetic inheritance}\n\nRandom epigenetic inheritance also plays an important part of ﬂuctuation in cell population. I incorporate random epigenetic inheritance on single cell level. Epigenetic regulations, including DNA methylation, histone modiﬁcation and others, inﬂuence gene expression by regulating chromatin accessibility and the interaction between DNA and protein. In the model, the reaction constants of each transcription was influenced by a random variable $\\mu$ which subscribes to normal distribution.\n\nWhere:\n\n\\begin{equation} \n\\begin{aligned} \n\\centering\n% \\underset{A}{B}\n% \\overset{…}{…}\nK_{real}   &= K_{deterministic} \\times (1+\\mu_1) \\\\\nk_{d-real} &= k_{d-deterministic} \\times (1+\\mu_2) \\\\\nr_{real}   &= r_{deterministic} \\times (1+\\mu_3) \\\\\n\\beta_{real}   &= \\beta_{deterministic} \\times (1+\\mu_4) \\\\\n\\end{aligned} \n\\end{equation}\n\n\\subsection{Random copy number variance}\n\nRandom copy number variance is an important source of noise in cell population. We incorporate random copy number variation on single cell level. In the modeling, the copy number was considered in the $\\alpha$, which was influenced by a random variable $\\tau$ which subscribes to normal distribution.\n\nWhere:\n\n\\begin{equation} \n\\begin{aligned} \n\\centering\n% \\underset{A}{B}\n% \\overset{…}{…}\n\\alpha_{real}   &= \\alpha_{deterministic} \\times (1+\\tau) \\\\\n\\end{aligned} \n\\end{equation}\n\n\\subsection{Random basal expression level of GFP, mCherry and tetR-dimer}\n\nRandom copy number variance is an important source of noise in cell population. We incorporate random copy number variation on single cell level. In the modeling, the basal expression level of GFP, mCherry and free tetR-dimer were influenced by a random variable $\\xi$ which subscribes to normal distribution.\n\nWhere:\n\n\\begin{equation} \n\\begin{aligned} \n\\centering\n% \\underset{A}{B}\n% \\overset{…}{…}\n[GFP]_{0-real}   &= [GFP]_{0-deterministic} \\times (1+\\xi_1) \\\\\n[mCherry]_{0-real}   &= [mCherry]_{0-deterministic} \\times (1+\\xi_2) \\\\\n[R^2_0]_{0-real}   &= [R^2_0]_{0-deterministic} \\times (1+\\xi_3) \\\\\n\\end{aligned} \n\\end{equation}\n\n%----------------------------------------------------------------------------------------\n\\section{Simulate the flow cytometry data with simulations of 1000 cells}\n\nCombing the factors of random ﬂuctuation in biochemical reactions, random copy number variance and random epigenetic inheritance described above, we establish model to study the heterogeneity of Dox-induced single-cell expressions in both feedback and no-feedback systems. For each doxycycline concentration, we stimulate 1000 single cells.\n\n\\subsection{Heterogeneity of Dox-induced single-cell expressions, without feedback}\n\nFor the heterogeneity of Dox-induced single-cell expressions of GFP without feedback, the stimulation result is as follows:\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1.0\\linewidth]{Figures/Q3_1.png}\n\\caption{Cytometry simulations of Dox-induced GFP expression \\\\ system without feedback in 1000 cells}\n\\label{part_3_1}\n\\end{figure}\n\nFrom the ﬁgure we can see that for each concentration of doxycycline, the GFP expression in cell population is like a normal distribution. At low concentration of doxycycline, increasing doxycycline concentration would not cause much to distribution of GFP expression, this is because at this stage there is surplus of tetR dimer in addition to binding most of tetO. At higher concentration of doxycycline, increasing doxycycline concentration would not cause much change to the distribution of GFP expression, this is because at this stage the doxycycline is enough to bind most of the tetR dimer.\n\n\\subsection{Heterogeneity of Dox-induced single-cell expressions, with feedback}\n\nFor the heterogeneity of Dox-induced single-cell expressions of mCherry with feedback, the result is as follows:\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1.0\\linewidth]{Figures/Q3_2.png}\n\\caption{Cytometry simulations of Dox-induced mCherry expression \\\\system with feedback in 1000 cells ($log10 \\approx 3.2$)}\n\\label{part_3_2}\n\\end{figure}\n\nFrom the ﬁgure we can see that for each concentration of doxycycline, the mCherry expression in cell population is like a normal distribution. As the concentration of doxycycline increase, the mean of mCherry expression show a steady increase. This is because there is a negative feedback control loop in this system, increasing the concentration of doxycycline will always lead to the system to reach a new equilibrium.\n\n%----------------------------------------------------------------------------------------\n\\newpage\n\\section{Discussion}\nIn this session, we discuss the result and compare our results with the experiment result.\n\nFor part1, our result looks very similar to the experiment result, including the initial value, the end value and the turning point. At low concentration of doxycycline, increasing doxycycline concentration would not cause much difference to GFP expression, this is because at this stage there is surplus of tetR dimer in addition to binding most of tetO. At higher concentration of doxycycline, increasing doxycycline concentration would not cause much to GFP expression too, this is because at this stage the doxycycline is enough to bind most of the tetR dimer. This system is responsive to doxycycline only in a narrow range of doxycycline concentration, and the response is ultrasensitive.\n\nFor part2, our result also looks very alike to the experiment result, including the initial value and the end value. As the concentration of doxycycline increase, the mean of mCherry expression show a steady increase. This is because there is a negative feedback control loop in this system, increasing the concentration of doxycycline will always lead to the system to reach a new equilibrium. This system is sensitive to a wide range doxycycline and it is easy to tune to achieve precise and quantitate control mCherry expression.\n\nWe combine the result of part1 and part2 together, the result is as follows:\n\n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=0.8\\linewidth]{Figures/Q3_3.png}\n\\caption{The modeling results for GFP without feedback \\\\ and mCherry with feedback}\n\\label{part_3_3}\n\\end{figure}\n\nThe system without feedback is ultrasensitive to doxycycline in a narrow concentration range, while the system with feedback is sensitive to a wide range doxycycline and it is easy to tune to achieve precise and quantitate control mCherry expression. The difference is due to the feedback control: It can control the equilibrium of the reaction and stabilize the system, thus the system with feedback is responsive to wider range of doxycycline concentration, and increasing the concentration of doxycycline will lead to gentle change in target gene expression.\n\nFor part3, our modeling result of the system without feedback has similar mean value of the distribution comparing with the experiment result. But at higher concentration of doxycycline, the distribution of experiment result has heavier tail than our modeling result. We hypothesis that the difference is due to some unknown biological pathways. For instance, at higher concentration of doxycycline, some other biological pathways are affected thus lead to the heavier tail in the distribution of experiment result. In addition, our modeling result of system with feedback is similar to the experiment result, both in mean value and distribution shape.\n\n", "meta": {"hexsha": "a8291ff573a5df8560b8c85ed750ce9442a2253b", "size": 7917, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW2/Chapters/Chapter3.tex", "max_stars_repo_name": "c235gsy/Sustech_Systems-Biology", "max_stars_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW2/Chapters/Chapter3.tex", "max_issues_repo_name": "c235gsy/Sustech_Systems-Biology", "max_issues_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW2/Chapters/Chapter3.tex", "max_forks_repo_name": "c235gsy/Sustech_Systems-Biology", "max_forks_repo_head_hexsha": "bd72b7e7d1238e22901b410b3254a4622d249964", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.3243243243, "max_line_length": 694, "alphanum_fraction": 0.7798408488, "num_tokens": 1871, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4039580821889596}}
{"text": "When trying to analyze a program, the user sometimes needs to fully understand how the results were calculated. Especially, if he aims to use them to improve his code. Therefore, we will discuss \\suaca's most important algorithms in this chapter. We will first explain the individual steps and fit them together in the end.\n\n\\section{Dependency Analysis}\n\\label{sec:depanalysis}\n\n\\subsection{Single Iteration}\n\nHere we want to take a look at the algorithm that computes the dependency graph. \\\\\nFirst we want to discuss a simpler version that ignores the control flow of the program.\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Dependency analysis without control flow}\n    \\label{alg:depsingle}\n    \\SetKwFunction{dep}{dep\\_analysis}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{instructionlist inst\\_list}}{\n        Map $:=$ map from register to line\\;\n        DG $:=$ Graph that has the same nodes as CFG, but no edges\\;\n        \\ForEach{instruction $i$ in inst\\_list} {\n             \\ForEach{register\\_operand $r$ in operands($i$)} {\n                 \\eIf{is\\_read($r$)} {\n                     DG.add\\_edge(Map[$r$], line\\_of($i$))\\;\n                 }{\n                    Map[$r$] = line\\_of(i)\\;\n                }\n            }\n        }\n        \\Return DG\\;\n    }\n\\end{algorithm}\n\n\\newpage\n\nWhere\n\\begin{itemize}\n    \\item \\emph{Map} maps each register to the last line with a write access.\n    \\item \\emph{operands(i)} returns a list of all operands of instruction $i$. A register that is first read then written to will be contained twice. The order will be first read then write access.\n    \\item \\emph{is\\_read(r)} returns true if the operand $r$ will be read and false if it will be written to.\n    \\item \\emph{line\\_of(i)} returns the line of instruction $i$ in the original program.\n\\end{itemize}\n\nThis algorithm will iterate over all instructions in program order. For each instruction $i$ it will then iterate over all of its operands. For each operand it will check if it is accessed via read or write. If it is written to, the algorithm will map the register to the current line. If it is read, the algorithm will add an edge from the last write access to the current line.\\\\\n\nThe runtime of this algorithm is $\\mathcal{O}(n*m)$ where $n$ is the number of instructions and $m$ the maximum number of operands that occur in the program.\\\\\n\nNote that we consider every operand as a register. In practice, an operand can of course be a memory address. In this case \\suaca\\ will extract all registers from that address and treat them as read operands. \\suaca\\ does not support memory dependencies so far as we would need to keep track of the whole memory. As we have seen in \\autoref{fig:wloop}, \\suaca\\ is able to differentiate between the different flags. For readability we ignore the special case of the \\emph{RFLAGS} register here.\n\nNow we want to take a look at the control flow sensitive algorithm that \\suaca\\ actually uses. \n\\newpage\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Control flow sensitive dependency analysis}\n    \\label{alg:dep}\n    \\SetKwFunction{deps}{dep\\_analysis\\_start}\n    \\SetKwFunction{dep}{dep\\_analysis}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\deps{CFG}}{\n        Map $:=$ map from register to line\\;\n        DG $:=$ graph that has the same nodes as CFG, but no edges\\;\n        Node $:=$ startnode of CFG\\;\n        \\dep{CFG, DG, Map, Node}\\;\n        \\Return DG\\;\n    }\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{CFG, DG, Father-Map, Node}}{\n        Map $:=$ copy of Father-Map\\;\n        \\While{true} {\n            \\ForEach{register\\_operand $r$ in operands(instruction\\_of(Node))} {\n                \\eIf{is\\_read($r$)} {\n                    DG.add\\_edge(Map[$r$], line\\_of($i$))\\;\n                }{\n                    Map[$r$] = line\\_of(i)\\;\n                }\n            }\n            \\If{num\\_successors(CFG, Node) = 0}{\\Return;}\n            Node = successor(CFG, Node, 0)\\;\n            \\If{num\\_successors(CFG, Node) $>$ 1} {\n                \\dep{CFG, DG, Map, successor(CFG, Node, 1)}\\; \n            }\n        }\n    }\n\\end{algorithm}\n\\vspace{5pt}\n\nWhere\n\\begin{itemize}\n    \\item \\emph{DG} has a Node for every instruction in the program. Just like the CFG.\n    \\item \\emph{instruction\\_of(Node)} returns the instruction that Node represents.\n    \\item \\emph{num\\_successors(Graph, Node)} returns the number of successors of \\emph{Node} in the Graph.\n    \\item \\emph{successor(Graph, Node, i)} returns the $i^{th}$ successor of $Node$ in the Graph.\n\\end{itemize}\n\nThis time we will ``climb along'' the $CFG$. If we never face a branch i.e., \\emph{num\\_successors()} never returns a value greater than $1$, this algorithm will do exactly the same as the one we have just seen.\\\\\nIn the case of \\emph{num\\_successors()} $> 1$ we will make another call of \\emph{dep\\_analysis()} on the ``right branch''. From this point on, there will be two analyses, one for every branch in the $CFG$. Each analysis has its own $Map$ since there can be different writes on each branch. Note that we will not join the two analyses as we would need to find the first mutual descendant.\\\\\nIn the worst case every instruction is a branch, so we would spawn a new function for each of them. This leads to a runtime of $\\mathcal{O}(n^2*m)$.\\\\\n\nWe assume no backbranches i.e., no loops, in the program for the above mentioned algorithm. In practice, \\suaca\\ will simply check for each branch if it is a backbranch, and should the situation arise ignore it.\n\n\n\\subsection{Multiple Iterations}\n\nWhen ordering \\suaca\\ to run the program in multiple loops we need to adjust the dependency analysis algorithm as this can cause some ``loop dependencies''. In order to solve this, we will simply consider the program twice. So we will append a copy of the program to itself, compute the $CFG$ and afterwards run the above mentioned algorithm. Because we know the original length of our program, we can extract all ``loop dependencies'' from the resulting dependency graph.\n\n\n\\section{Simulation of the Front-End}\n\\label{sec:simfrontend}\n\nAlthough our main task is to simulate the scheduler we still want to consider the front-end in our analysis. Depending on the microarchitecture, the front-end is able to produce a certain amount of \\microops\\ each cycle. For example, the Sandy Bridge architecture will produce at most $4$ \\microops\\ per cycle. However, we still have to acknowledge the capacity of the scheduler since the front-end might be faster than the execution itself. The scheduler of the Sandy Bridge architecture has a maximum capacity of $54$ \\microops.\\\\\nWe will now briefly discuss how our simulation actually performs those loads.\n\\newpage\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Load instructions into scheduler}\n    \\SetKwFunction{dep}{load\\_instructions}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{instruction\\_queue queue}}{\n        Waiting $:=$ first element of queue that is not fully loaded\\;\n        Loadable $:= max(Loads\\ per\\ cycle, remaining\\ space\\ in\\ station)$\\;\n        \\While{Loadable $> 0$} {\n            loaded $:=$ load\\_\\microops(Waiting, Loadable)\\;\n            Loadable = Loadable $-$ loaded\\;\n        }\n    }\n\\end{algorithm}\n\\vspace{5pt}\nWhere\n\\begin{itemize}\n    \\item \\emph{queue} is a queue of all instructions that still have to be executed.\n    \\item \\emph{Waiting} is initially set by searching for the first element in queue that has not been loaded into the scheduler by the front-end.\n    \\item \\emph{load\\_\\microops(Waiting, $x$)} loads $x$ \\microops\\ of \\emph{Waiting} and returns the number of \\microops\\ that were actually loaded.\n\\end{itemize}\n\nSo it is possible that an instruction is partially (i.e., only some of its \\microops) loaded into the scheduler.\n\n\\section{Choosing the Ports}\n\\label{sec:chooseport}\n\nIn this section we are going to discuss how exactly the ports which an instruction uses are chosen. As we have seen in \\autoref{sec:measurements} we know of how many \\microops\\ an instruction consists and which ports those \\microops\\ can use. As seen in \\autoref{sec:simfrontend}, an instruction can be loaded partially, which we will have to consider here.\\\\\nThe following algorithm contains several crucial details to the simulation. First we will see how \\suaca\\ tries to distribute all \\microops\\ equally over all ports. It also demonstrates the exact situations in which we will execute an instruction. Lastly it explains how the \\emph{had to wait} and \\emph{caused to wait} columns we introduced in \\autoref{sec:plain} are computed. \n\\newpage\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Choose ports for loaded instructions}\n    \\label{alg:choose}\n    \\SetKwFunction{dep}{choose\\_ports}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{instruction\\_queue queue}}{\n        \\While{loaded\\_\\microops(Instruction) $> 0$} {\n            \\eIf{\\textbf{not} all\\_dependencies\\_resolved(Instruction)} {\n                Instruction.has\\_to\\_wait++\\;\n                \\ForEach{Father $\\in$ direct\\_predecessors(Instruction)} {\n                    Father.caused\\_to\\_wait++\\;\n                    Father.caused\\_to\\_wait\\_depedency(Instruction)++\\;\n                    Instruction.had\\_to\\_wait\\_depedency(Father)++\\;\n                }\n            } {\n                Executable $:= true$\\;\n                \\If{\\textbf{not} is\\_fully\\_loaded(Instruction)}{Executable $= false$\\;}\n                \\ForEach{\\microop\\ $\\mu$ $\\in$ loaded\\microops(Instruction)} {\n                    Success $:=$ assign\\_to\\_ports($\\mu$)\\;\n                    \\If{\\textbf{not} Success} {\n                        Executable $= false$\\;\n                    }\n                }\n                \\eIf{Executable} {\n                    add\\_to\\_executionlist(Instruction)\\; \\label{line:if}\n                }{\n                    Blamed $:=$ Set of instructions\\; \\label{line:else}\n                    \\ForEach{p $\\in$ blocked\\_ports(Instruction)} {\n                        \\If{\\textbf{not} Blamed.contains(p.using\\_instruction())} {\n                            p.using\\_instruction().caused\\_to\\_wait++\\;\n                            p.using\\_instruction().caused\\_to\\_wait\\_port(p)\\;\n                            Instruction.had\\_to\\_wait\\_port(p)\\;\n                            Blamed.add(p.using\\_instruction())\\;\n                        }\n                    }\n                    Instruction.has\\_to\\_wait++\\;\n                }          \n            }\n            Instruction $=$ queue.next(Instruction)\\;\n        }\n    }\n\\end{algorithm}\n\n~\\\\[-1em]\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Assign \\microop\\ to port}\n    \\label{alg:assign}\n    \\SetKwFunction{dep}{assign\\_to\\_ports}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{\\microop\\ $\\mu$}}{\n        \\ForEach{p $\\in$ port\\_queue} {\n            \\If{$\\mu$.can\\_use(p) \\textbf{and} p.is\\_free()} {\n                p.uses($\\mu$)\\;\n                \\Return $true$\\;\n            }\n        }\n        \\Return $false$\\;\n    }\n\\end{algorithm}\n\\vspace{5pt}\n\n\\autoref{alg:choose} iterates over all instructions in program order as long as the current instruction is at least partially loaded into the scheduler. For each instruction it will first check if all of its dependencies have been resolved i.e., all predecessors in the dependency graph have finished their execution (or at least produced the needed results). If not, it cannot be executed and the delay counters have to be increased. Notice that we have separate counters for the cumulative delays and the special delays (e.g. caused\\_to\\_wait\\_depedency(), caused\\_to\\_wait\\_port(p)), which are only needed for the detailed analysis (\\autoref{sec:detail}). We will see the same behavior for the ports and this explains why the special delays will not always sum up to the cumulative ones.\\\\\nIf all dependencies have been resolved, \\suaca\\ will try to assign all \\microops\\ of the instruction to a port. To achieve this the algorithm will iterate over all \\microops\\ that have been loaded into the scheduler. Note that this will ignore all \\microops\\ that have been put into a port already. So if all \\microops\\ of an instruction are currently in the port pipeline this algorithm will basically just put the instruction into the execution list.\\\\ \nThe function \\emph{assign\\_to\\_ports(\\microop, Instruction)} is described in \\autoref{alg:assign}. This function will iterate over all ports in prior usage order and assign the \\microop\\ if possible. More precisely \\emph{port\\_queue} contains all ports and is sorted by usage throughout the whole simulation. If possible it will assign the \\microop\\ to the port and return a success. If no usable port was free it will return a fail.\\\\\nWe can observe that this is a greedy algorithm that is obviously not optimal in regards to the distribution of all \\microops\\ over the ports. However, we assume that this greedy algorithm comes close to what the schedulers are doing in reality.\\\\\nIf the assignment or the load of a single \\microop\\ failed the flag \\emph{Executable} will be set to \\emph{false}. As we can see in \\autoref{line:if} the instruction will only be added to the execution list (which we will further discuss in \\autoref{sec:execute}) if this flag is set. This means that an instruction will not be executed as soon as a single port was blocked. Note that an instruction can not block itself i.e., if all blocked ports were blocked by a \\microop\\ of the same instruction this function will still return \\emph{true}. We did not include this special case here for the sake of readability.\\\\\nWe have to be this strict, because of our measurements. As we have seen in \\autoref{sec:measurements} those will always contain the best case for latency. The biggest problem we face here is the missing information about the \\microops. We do not know anything about the dependencies between them and so we do not know if there is an order in which those have to be executed, or if they can be executed simultaneously. So we have to assume a delay as soon as a single \\microop\\ is denied a port although that might not actually be the case in reality. This means that we will potentially overestimate the latency of a single instruction or the whole program. It is possible though that \\suaca\\ will actually underestimate the latency of a program as one can note in the following examples.\\\\\n\n\nConsider two instructions \\emph{X} and \\emph{Y}. \\emph{X} consists of two \\microops\\, one of which can use port $0$, and the other can use port $1$. \\emph{Y} only consists of one \\microop\\ which can use port~$1$. \\emph{X} is in front of \\emph{Y} in program order, both are fully loaded, not dependent on each other and have a latency of $2$ cycles.\\\\\nFor this example we assume that the second \\microop\\ (port $1$) of \\emph{X} depends on the first (port $0$). The problem is that \\suaca\\ does not have this information. So the simulation will do the following: In the first cycle it will assign \\emph{X} to ports $0$ and $1$. There is no port left for \\emph{Y} so it will not be added to the execution list. This will happen in the second cycle and as \\emph{Y}'s latency was two cycles \\suaca\\ will compute a total latency of three cycles (as \\emph{X} was executed in the first and second).\\\\\nHowever, in reality \\emph{X} will not block port $1$ in the first cycle as this particular \\microop\\ depends on the one that uses port $0$. So in the first cycle \\emph{X} will only use port $0$. \\emph{Y} can then freely use port $1$. In the second cycle \\emph{X} can then use port $1$. No port was ever blocked so there simply will be no delay, both instructions could be executed simultaneously. So the ``real latency'' of our example would be two cycles.\\\\\n\nNow we will consider the same example but with switched instruction order of \\emph{X} and \\emph{Y}. In this case \\suaca\\ will first assign \\emph{Y}'s \\microop\\ to port $1$. It will then try to assign \\emph{X}, but it will only be able to assign the first \\microop\\ to port $0$ as port $1$ is blocked. As discussed before \\emph{X} will therefore not be added to the execution list. In the second cycle the leftover of \\emph{X} will be assigned to a port and the execution will start. As the latency was two cycles the simulation will stop after the third cycle.\\\\\nAgain this is an overestimation of the reality. Due to the dependency of the second \\microop\\ of \\emph{X} it does not matter that \\emph{Y} blocks port $1$ in the first cycle. \\emph{X} only needs port $0$ in the first cycle and in the second cycle it can then freely use port $1$. Again the ``real latency'' of our example would be two cycles.\\\\\n\nFinally we will construct an example were our simulation actually underestimates the throughput. We can once more use our two instructions \\emph{X} and \\emph{Y}. This time we assume that \\emph{Y} cannot be executed in the first cycle, because of a dependency on an arbitrary third instruction. Our simulation basically works like in our first case, except for the reason why \\emph{Y} cannot be executed. So it will compute a latency of three cycles for those two instructions.\\\\\nIn reality \\emph{Y} will be denied port $1$ in the second cycle as it will be used by \\emph{X}. So the execution will start in the third cycle and end in the fourth.\\\\\n\nNote that it is still impossible that the latency of a single instruction is underestimated as we will always simulate the execution of at least as many cycles as we measured under a best case scenario. Also an important detail is, that it is impossible for an instruction to block itself. So if multiple \\microops\\ of a single instruction need to use the same port this will not cause a delay. This is again due to the measurements as the delay caused by ``inner instructional port blockings'' is already included in the best case runtime. We did not include this in the pseudo code above for the sake of readability.\\\\\n\nUltimately we will consider the rest of the algorithm starting in \\autoref{line:else}. This part will increase the counters similarly to what we have seen at the start of the algorithm. Notable here is the function \\emph{blocked\\_ports(Instruction)} that will return all ports that have been blocked during the assignment phase as well as the \\emph{Blamed} set which ensures that every instructions is held responsible at most once. We need this as we want to count the number of cycles that an instruction caused a delay and not the number of blocked ports in a particular cycle.\n\n\\newpage\n\n\\section{Executing Applicable Instructions}\n\\label{sec:execute}\n\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Execute applicable instructions}\n    \\label{alg:execute}\n    \\SetKwFunction{dep}{execute\\_instructions}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{instruction\\_queue queue}}{\n        \\ForEach{I $\\in$ Executionlist} {\n            I.executed\\_cycles$++$\\;\n            \\If{I.executed\\_cycles $=$ I.latency} {\n                queue.remove(I)\\;\n            }\n            inform\\_children\\_im\\_done(I)\\;\n        }\n        Executionlist.clear()\\;\n    }\n\\end{algorithm}\n\n\nThis part is rather simple. Every instruction knows its latency and how many cycles it has been executed. This value gets increased and if the latency is hit it will be removed from the instructionqueue. The most interesting part here is the function \\emph{inform\\_children\\_im\\_done(Instruction)}. As we have seen in \\autoref{sec:measurements} the children of an instruction do not necessarily have to wait for the instruction to finish. Sometimes they only need part of the results, which are available earlier. So this function will iterate over all children and check if the execution is advanced enough and if so ``release the dependency'' in a way that the \\emph{all\\_dependencies\\_resolved()} function in \\autoref{alg:assign} will consider the instruction as finished. Finally we have to clear the execution list as we will fill it again in the next cycle.\n\n\\section{Performing a Cycle}\n\nLastly we want to briefly discuss how a whole cycle is performed. \\suaca\\ will run each of the three simulation algorithms we explained above. It will then free up all ports that were used during the cycle, in order to enable the port pipelining. It also passes the queue that contains all instructions that still have to be executed to the three functions. A short pseudo code representation can be found below.\n\\newpage\n\\begin{algorithm}[H]\n    \\SetAlgoLined\n    \\caption{Perform a whole cycle}\n    \\SetKwFunction{dep}{perform\\_cycle}\n    \\SetKwProg{Fn}{Function}{:}{\\textbf{end}}\n    \\Fn{\\dep{instruction\\_queue queue}}{\n        load\\_instructions(queue)\\;\n        choose\\_ports(queue)\\;\n        execute\\_instructions(queue)\\;\n        \\ForEach{p $\\in$ Ports} {\n            p.clear()\\;\n        }\n    }\n\\end{algorithm}\n\\vspace{5pt}\nThe interesting observation here is that an instruction can actually get loaded, put into a port and then executed within a single cycle, due to the order of the function calls.\\\\\nThis function will be executed in a loop as long as there are instructions to be executed. After said loop \\suaca\\ will generate its output.\n\n\n\\section{The Divider Pipe}\n\\label{sec:dividerpipe}\n\nInstructions that perform a division of some kind have to use the divider pipe, which is located on port~$0$. \\suaca's output will only show the divider pipe if one of the instructions needs it. We have to consider it when choosing the ports for the instructions during \\hyperref[alg:assign]{algorithm~\\ref*{alg:assign}}, because the division \\microops\\ cannot be pipelined. More precisely our measurements contain a ``div-cycle'' property for the corresponding instructions, which tells us how many cycles the divider pipe will be blocked. Because the divider pipe is located on port~$0$ each of those instructions has to have at least one \\microop\\ that uses port $0$ exclusively. \\suaca\\ will block the divider pipe as soon as this particular \\microop\\ is assigned to port $0$. As long as it is blocked all future division \\microops\\ are denied port $0$. After ``div-cycle'' many cycles the divider pipe will be available again.\\\\\nWe did not include this in the algorithms above for two reasons. First is readability, as the implementation of this behavior would add some otherwise unnecessary if statements. On the other hand this is a very special case as using a division is definitely not advised when you are trying to write high performance code.\n", "meta": {"hexsha": "819bbecc2ed341560ace79fb05d312d52edec271", "size": 22515, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/Chapters/algorithms.tex", "max_stars_repo_name": "Henni16/SUACA", "max_stars_repo_head_hexsha": "2f9561e69a285415053333bc5b92b45d6fd91aed", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/Chapters/algorithms.tex", "max_issues_repo_name": "Henni16/SUACA", "max_issues_repo_head_hexsha": "2f9561e69a285415053333bc5b92b45d6fd91aed", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-25T13:47:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-25T13:52:37.000Z", "max_forks_repo_path": "Thesis/Chapters/algorithms.tex", "max_forks_repo_name": "Henni16/SUACA", "max_forks_repo_head_hexsha": "2f9561e69a285415053333bc5b92b45d6fd91aed", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 79.2781690141, "max_line_length": 933, "alphanum_fraction": 0.708194537, "num_tokens": 5522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4039580821889596}}
{"text": "\\documentclass{article}\n\\usepackage[english]{babel}\n\\usepackage{amsmath,enumerate,bbm}\n\n%%%%%%%%%% Start TeXmacs macros\n\\catcode`\\|=\\active \\def|{\n\\fontencoding{T1}\\selectfont\\symbol{124}\\fontencoding{\\encodingdefault}}\n\\newcommand{\\assign}{:=}\n\\newcommand{\\mathd}{\\mathrm{d}}\n\\newcommand{\\tmop}[1]{\\ensuremath{\\operatorname{#1}}}\n\\newenvironment{enumeratenumeric}{\\begin{enumerate}[1.] }{\\end{enumerate}}\n\\newenvironment{tmindent}{\\begin{tmparmod}{1.5em}{0pt}{0pt} }{\\end{tmparmod}}\n\\newenvironment{tmparmod}[3]{\\begin{list}{}{\\setlength{\\topsep}{0pt}\\setlength{\\leftmargin}{#1}\\setlength{\\rightmargin}{#2}\\setlength{\\parindent}{#3}\\setlength{\\listparindent}{\\parindent}\\setlength{\\itemindent}{\\parindent}\\setlength{\\parsep}{\\parskip}} \\item[]}{\\end{list}}\n\\newtheorem{corollary}{Corollary}\n\\newtheorem{theorem}{Theorem}\n%%%%%%%%%% End TeXmacs macros\n\n\\begin{document}\n\n\\section{Why}\n\n\\section{How}\n\n\\subsection{Notation}\n\n\n\n\\subsection{Bayesian Approach}\n\nLet $n \\in \\mathbbm{N}^{+}$ the number of relavent features of making a good\ncup of coffee, e.g. the temperature of water; $x \\in \\mathbbm{R}^{n}$ the\nvalues of the features. Let $Y$ the taste of coffee under a given $x$, which\nis either $0$ (tastes bad) or $1$ (tastes good), thus naturally is a random\nvariable obeys a Bernoulli distribution with probability (confidence) $\\psi$,\ni.e. $Y \\sim \\tmop{Ber} ( \\psi )$. Let $f$ the model relates $x$ and $\\psi$,\ndepending also on paramters $w \\in \\mathbbm{R}^{m}$ for some $m \\in\n\\mathbbm{N}^{+}$, i.e. $\\psi =f ( x;w )$.\n\nThe Bayesian approach is as follow.\n\n\\begin{theorem}\n  We have\n  \\[ p ( Y=1|X=x ) =\\mathbbm{E}_{w_{( s )} \\sim p ( W )} [  f ( x,w_{( s )} )\n     ] , \\]\n  where $w_{( s )} \\sim p ( W )$ means that $\\{ w_{( s )} :s=1,2, \\ldots \\}$\n  are sampled from $P ( W )$.\n\\end{theorem}\n\n\\begin{proof}\n  By Bayesian formula,\n  \\[ p ( Y=1|X=x ) = \\frac{p ( X=x,Y=1 )}{p ( X=x )} . \\]\n  Then by total probability formula,\n  \\[ p ( X=x,Y=1 ) = \\int_{\\mathbbm{R}^{m}} \\mathd w p ( X=x,Y=1,W=w ) , \\]\n  then Bayesian formula gives\n  \\[ p ( X=x,Y=1 ) = \\int_{\\mathbbm{R}^{m}} \\mathd w p ( Y=1|X=x,W=w )  p (\n     X=x,W=w ) . \\]\n  Since $x$ and $w$ are independent, $p ( X=x,W=w ) =p ( X=x )  p ( W=w )$.\n  Put all together,\n  \\begin{eqnarray*}\n    p ( Y=1|X=x ) & = & \\frac{p ( X=x,Y=1 )}{p ( x )}\\\\\n    & = & \\frac{\\int_{\\mathbbm{R}^{m}} \\mathd w p ( Y=1|X=x,W=w )  p (\n    X=x,W=w )}{p ( X=x )}\\\\\n    & = & \\frac{\\int_{\\mathbbm{R}^{m}} \\mathd w p ( Y=1|X=x,W=w )  p ( X=x ) \n    p ( W=w )}{p ( X=x )}\\\\\n    & = & \\int_{\\mathbbm{R}^{m}} \\mathd w p ( Y=1|X=x,W=w )  p ( W=w ) ,\n  \\end{eqnarray*}\n  or simply,\n  \\[ p ( Y=1|X=x ) =\\mathbbm{E}_{w_{( s )}} [  p ( Y=1|X=x,W=w_{( s )} ) ] .\n  \\]\n  And then insert $f$ as\n  \\[ p ( Y=1|X=x,W=w ) =f ( x,w ) , \\]\n  since $Y \\sim \\tmop{Ber} ( f ( x,w ) )$. So, in one word,\n  \\[ p ( Y=1|X=x ) =\\mathbbm{E}_{w_{( s )} \\sim p ( W )} [  f ( x,w_{( s )} )\n     ] . \\]\n\\end{proof}\n\nWhat we want to find is a $x_{\\ast}$, s.t. $p ( Y=1|X=x )$\n($=\\mathbbm{E}_{w_{( s )} \\sim p ( W )} [  f ( x,w_{( s )} ) ]$) is maximized.\nOr say, we are searching\n\\[ x_{\\ast} = \\underset{x}{\\tmop{argmax}} \\{ \\mathbbm{E}_{w_{( s )} \\sim p ( W\n   )} [  f ( x,w_{( s )} ) ] \\} . \\]\nHowever, the only thing we have not known yet is the distribution of $W$. We\nare so humble that know nothing on how to make a good cup of coffee, so we use\na flatten prior of $W$, i.e. $W \\sim \\tmop{Uniform}$, with some support wide\nenough. We can obtain the posterior of $W$ by inserting the data, i.e. a list\nof pairs $( x,y )$, as the value of $Y$ (the taste of a cup of coffee) given\nby some $x$. By feeding the data, we iterative gain the prior of $W$, which is\nthe posterior in the previous iteration, as\n\\[ p_{i+1} ( W=w ) = \\frac{p ( Y=y_{i} ,X=x_{i} |W=w )  p_{i} ( W=w )}{p (\n   Y=y_{i} ,X=x_{i} )} . \\]\n\\begin{theorem}\n  If define $g ( a,b )$ as $b$ if $a=1$ and as $1-b$ if $a=0$, and if\n  initially use flatten prior, i.e. $p_{1} = \\tmop{Const}$, then we have, for\n  data $D \\assign \\{ x_{i} ,y_{i} :i=1,2, \\ldots ,N \\}$,\n  \\[ p_{N} ( W=w ) =c ( D ) \\times \\prod_{i=1}^{N} g ( y_{i} ,f ( x_{i} ,w ) )\n     , \\]\n  or say,\n  \\[ \\ln [ p_{N} ( W=w ) ] = \\sum_{i=1}^{N}   \\ln [ g ( y_{i} ,f ( x_{i} ,w )\n     ) ] + \\ln [ c ( D ) ] , \\]\n  where $c ( D )$ can also be seen as the normalization factor of $p_{N} ( W=w\n  )$ since Bayesian formula always ensures normalization of probability.\n\\end{theorem}\n\n\\begin{proof}\n  By Bayesian formula and the independence between $X$ and $W$,\n  \\[ p ( Y=y_{i} ,X=x_{i} |W=w ) =p ( Y=y_{i} |X=x_{i} ,W=w )  p ( X=x_{i} )\n  \\]\n  and\n  \\[ p ( Y=y_{i} ,X=x_{i} ) =p ( Y=y_{i} |X=x_{i} )  p ( X=x_{i} ) , \\]\n  thus\n  \\[ p_{i+1} ( W=w ) =p_{i} ( W=w )   \\frac{p ( Y=y_{i} |X=x_{i} ,W=w )}{p (\n     Y=y_{i} |X=x_{i} )} ; \\]\n  and since we have known in previous that $p ( Y=1|X=x_{i} )\n  =\\mathbbm{E}_{w_{( s )} \\sim p_{i} ( W )} [  f ( x_{i} ,w_{( s )} ) ]$ and\n  likewise $p ( Y=0|X=x_{i} ) =\\mathbbm{E}_{w_{( s )} \\sim p_{i} ( W )} [ 1- f\n  ( x_{i} ,w_{( s )} ) ]$, we finally get, if $y_{i} =1$\n  \\[ p_{i+1} ( W=w ) =p_{i} ( W=w )   \\frac{f ( x_{i} ,w )}{\\mathbbm{E}_{w_{(\n     s )} \\sim p_{i} ( W )} [  f ( x_{i} ,w_{( s )} ) ]} , \\]\n  else ($y_{i} =0$)\n  \\[ p_{i+1} ( W=w ) =p_{i} ( W=w )   \\frac{1-f ( x_{i} ,w\n     )}{\\mathbbm{E}_{w_{( s )} \\sim p_{i} ( W )} [  1-f ( x_{i} ,w_{( s )} )\n     ]} . \\]\n  \n  \n  After the first iteration, by $x_{1}$ and $y_{1} =1$,\n  \\[ p_{2} ( W=w ) = \\tmop{Const}   \\frac{f ( x_{1} ,w )}{\\mathbbm{E}_{w_{( s\n     )} \\sim \\tmop{Uniform}} [  f ( x_{1} ,w_{( s )} ) ]} =c ( x_{1} ,y_{1} ) \n     f ( x_{1} ,w ) . \\]\n  Then the next iteration, suppose $y_{2} =1$ still,\n  \\[ p_{3} ( W=w ) = \\{ c ( x_{1} ,y_{1} )  f ( x_{1} ,w ) \\}   \\left\\{\n     \\frac{f ( x_{2} ,w )}{\\mathbbm{E}_{w_{( s )} \\sim p_{2} ( W )} [  f (\n     x_{2} ,w_{( s )} ) ]} \\right\\} , \\]\n  and re-define $c ( \\{ ( x_{1} ,y_{1} ) , ( x_{2} ,y_{2} ) \\} ) \\assign c (\n  x_{1} ,y_{1} ) /\\mathbbm{E}_{w_{( s )} \\sim p_{2} ( W )} [  f ( x_{2} ,w_{(\n  s )} ) ]$, thus\n  \\[ p_{3} ( W=w ) =c ( \\{ ( x_{1} ,y_{1} ) , ( x_{2} ,y_{2} ) \\} )  f ( x_{1}\n     ,w )  f ( x_{2} ,w ) . \\]\n  And if $y_{2} =0$,\n  \\[ p_{3} ( W=w ) =c ( \\{ ( x_{1} ,y_{1} ) , ( x_{2} ,y_{2} ) \\} )  f ( x_{1}\n     ,w ) [  1-f ( x_{2} ,w ) ] . \\]\n  So, generally, if define $g ( a,b )$ as $b$ if $a=1$ and as $1-b$ if $a=0$,\n  then for data $D \\assign \\{ x_{i} ,y_{i} :i=1,2, \\ldots ,N \\}$,\n  \\[ p_{N} ( W=w ) =c ( D ) \\times \\prod_{i=1}^{N} g ( y_{i} ,f ( x_{i} ,w ) )\n     , \\]\n  or say,\n  \\[ \\ln [ p_{N} ( W=w ) ] = \\sum_{i=1}^{N}   \\ln [ g ( y_{i} ,f ( x_{i} ,w )\n     ) ] +c ( D ) . \\]\n\\end{proof}\n\n\n\n\\begin{corollary}\n  If data $D= \\{ x_{\\tmop{BEST}} ,y_{i} =1:i=1,2, \\ldots ,N \\}$, then\n  \\[ \\lim_{N \\rightarrow + \\infty}   \\underset{x}{\\tmop{argmax}} \\{\n     \\mathbbm{E}_{w_{( s )} \\sim p_{N} ( W )} [ f ( x,w_{( s )} ) ] \\}\n     =x_{\\tmop{BEST}} . \\]\n\\end{corollary}\n\n\\begin{proof}\n  XXX $p_{N} ( W=w ) =c ( D )   [ f ( x_{\\tmop{BEST}} ,w ) ]^{N}$\n\\end{proof}\n\n{\\algorithm{XXX (init)\n\\begin{tmindent}\n  \\begin{enumeratenumeric}\n    \\item $D \\leftarrow D \\cup ( x_{i} ,y_{i} )$;\n    \n    \\item $\\ln [ p ( W=w ) ] \\leftarrow \\ln [ p ( W=w ) ] +  \\ln [ g ( y_{i}\n    ,f ( x_{i} ,w ) ) ]$;\n    \n    \\item fit $p ( W )$ by variational inference;\n    \n    \\item sample $\\{ w_{s} :s=1,2, \\ldots ,N_{s} \\}$ from $p ( W )$;\n    \n    \\item $x_{\\ast} = \\underset{x}{\\tmop{argmax}} \\{ \\mathbbm{E}_{w_{s}} [ f (\n    x,w_{s} ) ] \\}$;\n    \n    \\item Make a cup of coffee by feature values $x_{\\ast}$;\n    \n    \\item Taste the cupe of coffee;\n    \n    \\item Return your opinion as $y_{\\ast}$;\n    \n    \\item $( x_{i+1} ,y_{i+1} ) \\leftarrow ( x_{\\ast} ,y_{\\ast} )$.\n  \\end{enumeratenumeric}\n\\end{tmindent}}}\n\n\\subsection{An Instant Model}\n\n\n\n\\end{document}\n", "meta": {"hexsha": "ca3a6a840fbc21cdd6a92860110d15b217f17305", "size": 7761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/main.tex", "max_stars_repo_name": "shuiruge/coffee-tuner", "max_stars_repo_head_hexsha": "f27908d2a8cee8ace32568ce42ad64c8452c0cc3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-01-04T06:05:30.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-09T08:44:11.000Z", "max_issues_repo_path": "docs/main.tex", "max_issues_repo_name": "shuiruge/coffee-tuner", "max_issues_repo_head_hexsha": "f27908d2a8cee8ace32568ce42ad64c8452c0cc3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/main.tex", "max_forks_repo_name": "shuiruge/coffee-tuner", "max_forks_repo_head_hexsha": "f27908d2a8cee8ace32568ce42ad64c8452c0cc3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2124352332, "max_line_length": 273, "alphanum_fraction": 0.5108877722, "num_tokens": 3445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4039580821889596}}
{"text": "% ========================================================================================\n\\chapter{Example Section for \\texttt{\\classname}}\\label{ch:ex}\nThis chapter demonstrates the appearance of the thesis. \n% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\\section{Demonstration}\nThis is a Section.\n% ........................................................................................\n\\subsection{Subsection A}\nThis is a subsection. \\kant[1]\n\\paragraph{Paragraph A}\nI am a paragraph. \n\\paragraph{Paragraph B}\nSo am I.\n% ........................................................................................\n\\subsection{Subsection B}\nThis is also a subsection.\n% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\\section{Citation}\nThis sections demonstrates how citations looks like.\nThis is a book \\cite{Evans15}. This is an article \\cite{Ben02}. This is a \nwebsite \\cite{FAUreg}.\n% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\\section{Definitions, Theorems, Remarks}\nThis sections demonstrates how the different theorem environments look like.\n%-----------------------------------------------------------------------------------------\n\\begin{lemma}{Compactness in metric spaces}{compMet}\nLet $X$ be a metric space and $A\\subset X$, then the following statements are equivalent:\n\\begin{enumerate}[label=(\\roman*)]\n\\item $A$ is relatively compact;\n\\item $A$ is sequentially compact;\n\\item $A$ is totally bounded and $\\overline A$ is complete.\n\\end{enumerate}\t\n\\end{lemma}\nThis is an equation\n\\begin{equation}\\label{eq:Gauss}\n\\sum_{i=1}^n=\\frac{n~(n+1)}{2}.\n\\end{equation}\nFrom \\ref{eq:Gauss} we see can deduce something very useful. \nWe can also use \\cref{eq:Gauss} or \\labelcref{eq:Gauss} to refer to an equation.\n%-----------------------------------------------------------------------------------------\n\\begin{remark}{}{}\nIf $X$ is a complete metric space, we know that every closed subset $A\\subset X$ is \ncomplete and thus the last statement in the above lemma reduces to total boundedness, \nsee \\cite[Lem. I.6.7]{Dunf60}.\n\\end{remark}\n%-----------------------------------------------------------------------------------------\n\\begin{proof}\nSee, for example, \\cite[Lem. I.6.15]{Dunf60}.\n\\end{proof}\n% ----------------------------------------------------------------------------------------\nThe main result in the context of the weak$^\\ast$ topology is stated below.\n\\index{topology!weak}\n\\index{topology!weak*}\n\\index{topology!strong}\n% ----------------------------------------------------------------------------------------\n\\begin{definition}{}{}\n\\begin{enumerate}[label=(\\roman*)]\n\\item Given a set $X$ and a family $\\mathcal{F}$ of functions $f_i:X\\rightarrow \\mathcal{Y}_i$ \nassociated with topological spaces $\\mathcal{Y}_i$ we denote by $\\sigma(X,\\mathcal{F})$ \nthe initial topology, i.e., the coarsest topology on $X$ such that each $F_i$ is continuous.\n\\item Let $X$ be a Banach space, then we denote by $\\sigma(X,X^{\\ast})$ the \n\\emph{weak topology} on $X$, while the usual one induced by the norm is referred to as \n\\emph{strong topology}.\n\\item Considering the family $\\mathcal{F}:=\\{X^{\\ast}\\ni\\xi\\mapsto\\xi(x)\\in\\R: x\\in E\\}$ \nwe call $\\sigma(X^{\\ast}, \\mathcal{F}) =:\\sigma(X^{\\ast},X)$ the weak$^\\ast$ topology.\n\\end{enumerate}\n\\end{definition}\n% ----------------------------------------------------------------------------------------\n% ========================================================================================\n\\chapter{Typeface}\nThis chapter demonstrates the typeface.\n\\kant\n", "meta": {"hexsha": "d2d7564e4e55859f8f7ba4b0e512b1f056cd253e", "size": 3650, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mainmatter/02_example.tex", "max_stars_repo_name": "TimRoith/fau-math-thesis", "max_stars_repo_head_hexsha": "6cf900630521ac8ff8b1e47378d1faba25aba7b5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-20T22:28:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-18T23:06:46.000Z", "max_issues_repo_path": "mainmatter/02_example.tex", "max_issues_repo_name": "TimRoith/fau-math-thesis", "max_issues_repo_head_hexsha": "6cf900630521ac8ff8b1e47378d1faba25aba7b5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mainmatter/02_example.tex", "max_forks_repo_name": "TimRoith/fau-math-thesis", "max_forks_repo_head_hexsha": "6cf900630521ac8ff8b1e47378d1faba25aba7b5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.0, "max_line_length": 95, "alphanum_fraction": 0.4953424658, "num_tokens": 810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.40395808218895957}}
{"text": "\\documentclass[fontsize=9pt,letter]{scrartcl}\n\n%----------------------------------------------------------------------------------------\n%\tPACKAGES AND STUFF\n%      If you're reading this, don't...just skip to the equations\n%----------------------------------------------------------------------------------------\n\n\\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs\n\\usepackage[english]{babel} % English language/hyphenation\n\\usepackage{amsmath,amsfonts,amsthm} % Math packages\n\\usepackage[pdftex]{graphicx}\n\\usepackage[margin=0.7in]{geometry}\n\n\\usepackage{sectsty} % Allows customizing section commands\n\\allsectionsfont{\\centering}% \\normalfont} % Make all sections centered, the default font and small caps\n\n\\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)\n\n%----------------------------------------------------------------------------------------\n%\tTITLE SECTION\n%----------------------------------------------------------------------------------------\n\n\\newcommand{\\horrule}[1]{\\rule{\\linewidth}{#1}} % Create horizontal rule command with 1 argument of height\n\n\\title{\n\\horrule{1pt} \\\\[0.2cm]\t\t\t% horrule puts a horizontal line\nViral Assembly Equation List\n%\\horrule{1pt} \\\\[0.2cm]\n}\n\n\\author{Waterloo iGEM}\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle % Print the title\n\\vspace{-20pt}\n\n\\horrule{1pt} %\\\\[0.4cm]\n\\vspace{-20pt}\n\n%-------------------\n\n%----------------------------------------------------------------------------------------\n%\tTHE LIST OF EQUATIONS STARTS HERE\n%----------------------------------------------------------------------------------------\n\n\\section{Equations}\n\n% By the way, the percent sign is used for comments\n\n\\begin{align}\n\n% ----------------------------------\n% 0. RNAi Factor\nf_{RNAi} &= \\frac{L}{(1+exp(-k(P_6 - x_0)))}\n% ----------------------------------\n% 1. Gapped DNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} DNA_{GAP} &= \\text{(out inf pure)} + k_v V (DNA_{max} - DNA_{GAP} - DNA_{gmod} - DNA_{CCC} - DNA_{cmod}) - \\alpha_c (DNA_{GAP}) - k_g (DNA_{GAP}) - \\gamma_{DNA} DNA_{GAP} \\\\\n%\n% ----------------------------------\n% 2. cccDNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} DNA_{CCC} &= \\alpha_c (DNA_{GAP}) - \\gamma_{DNA} (DNA_{CCC}) - k_c (DNA_{CCC}) \\\\\n%\n% ----------------------------------\n% 3. Modified gapped DNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} DNA_{gmod} &= \\text{(out inf mod)} + k_v V_m (DNA_{max} - DNA_{GAP} - DNA_{gmod} - DNA_{CCC} - DNA_{cmod}) - \\alpha_c (DNA_{gmod}) + k_g (DNA_{GAP}) - \\gamma_{DNA} DNA_{gmod} \\\\\n% ----------------------------------\n% 4. Modified cccDNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} DNA_{cmod} &= \\alpha_c (DNA_{gmod}) - \\gamma_{DNA} (DNA_{cmod}) + k_c (DNA_{CCC}) \\\\\n% ----------------------------------\n% 5. 19S RNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} RNA_{19S} &= \\alpha_{19S} (DNA_{CCC}) - \\gamma_{19S} (RNA_{19S}) - f_{RNAi}\\\\\n%\n% ----------------------------------\n% 6. Total pure 35S RNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} RNA_{35S} &= \\alpha_{35S} (DNA_{CCC}) - \\gamma_{35S} (RNA_{35S}) -  k_p P_{4 \\text{,sub}} P_5 (RNA_{35Su}) - f_{RNAi}\\\\\n%\n% ----------------------------------\n% 7. Total modified 35S RNA\n\\frac{\\mathrm{d}}{\\mathrm{d} t} RNA_{35Sm} &= \\alpha_{35S} (DNA_{cmod}) - \\gamma_{35S} (RNA_{35Sm}) -  k_p P_{4 \\text{,sub}} P_5 (RNA_{35Smu}) - f_{RNAi}\\\\\n%\n% ----------------------------------\n% 8. P1\n%add in the stuff to latex\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_1 &= \\beta_1 (1 + \\frac{P_6}{P_6 + E_{p6}}) (((RNA_{35Su}) + (RNA_{35Smu})) - \\delta_1 P_1 \\\\\n%\n% ----------------------------------\n% 9. P2\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_2 &= \\beta_2 (1 + \\frac{P_6}{P_6 + E_{p6}}) ((RNA_{35Su}) + (RNA_{35Smu}) - \\delta_2 P_2 - k_l P_2 \\\\\n%\n% ----------------------------------\n% 10. P3\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_3 &= \\beta_3 (1 + \\frac{P_6}{P_6 + E_{p6}})((RNA_{35S}) + (RNA_{35Sm})) - \\delta_3 P_3 - k_{anchor} P_3 V_{\\text{int} - k_{anchor} P_3 V_{\\text{int_m}} \\\\\n%\n% ----------------------------------\n% 11. P4\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_4 &= \\beta_4 (1 + \\frac{P_6}{P_6 + E_{p6}}) ((RNA_{35S}) + (RNA_{35Sm})) - \\delta_4 P_4 - k_{splice} P_4 \\\\\n%\n% ----------------------------------\n% 12. P4 subunits\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_{4 \\text{,sub}} &= k_{splice} P_4 - \\delta_4 P_{4 \\text{,sub}} - k_p P_{4 \\text{,sub}} P_5 (RNA_{35Su}) - k_p P_{4 \\text{,sub}} P_5 (RNA_{35Smu}) \\\\\n%\n% ----------------------------------\n% 13. P5\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_5 &= \\beta_5 (1 + \\frac{P_6}{P_6 + E_{p6}}) ((RNA_{35S}) + (RNA_{35Sm})) - \\delta_5 P_5 - k_p P_{4 \\text{,sub}} P_5 (RNA_{35Su}) - k_p P_{4 \\text{,sub}} P_5 (RNA_{35Smu}) \\\\\n%\n% ----------------------------------\n% 14. P6\n\\frac{\\mathrm{d}}{\\mathrm{d} t} P_6 &= \\beta_6 (RNA_{19S}) - \\delta_6 P_6 \\\\\n%\n% ----------------------------------\n% 15. Intermediate pure virions\n\\frac{\\mathrm{d}}{\\mathrm{d} t} V_{\\text{int}} &= k_p P_{4 \\text{,sub}} P_5 (RNA_{35Su}) - k_{anchor} P_3 V_{\\text{int}} \\\\\n%\n% ----------------------------------\n% 16. Intermediate impure virions\n\\frac{\\mathrm{d}}{\\mathrm{d} t} V_{int_m} &= k_p P_{4 \\text{,sub}} P_5 (RNA_{35Smu}) - k_{anchor} P_3 V_{int_m} \\\\\n%\n% ----------------------------------\n% 17. Pure virions\n\\frac{\\mathrm{d}}{\\mathrm{d} t} V &= k_{anchor} P_3 V_{\\text{int}} - k_v V (DNA_{max} - DNA_{GAP} - DNA_{gmod} - DNA_{CCC} - DNA_{cmod}) - \\delta_v V - v_{exit} V \\\\\n%\n% ----------------------------------\n% 18. Impure virions\n\\frac{\\mathrm{d}}{\\mathrm{d} t} V_m &= k_{anchor} P_3 V_{int_m} - k_v V_m (DNA_{max} - DNA_{GAP} - DNA_{gmod} - DNA_{CCC} - DNA_{cmod}) - \\delta_v V_m - v_{exit} V_m\n\\end{align}\n\n%----------------------------------------------------------------------------------------\n%\tTHE LIST OF EQUATIONS ENDS HERE\n%----------------------------------------------------------------------------------------\n\n% template:     \\frac{\\mathrm{d}}{\\mathrm{d} t} &= \\text{stuff} \\\\\n\n%------------------------------------------------\n\n\n\\end{document}\n\n", "meta": {"hexsha": "4fcf252ff16035f27e05df852e29692637bba358", "size": 6163, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "models/viralassembly/mathVA Eqn List PR.tex", "max_stars_repo_name": "igem-waterloo/uwaterloo-igem-2015", "max_stars_repo_head_hexsha": "2f5a5779989b0303481931e4b4d97ca81a6c69e1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2015-04-06T15:51:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-16T10:03:18.000Z", "max_issues_repo_path": "models/viralassembly/mathVA Eqn List PR.tex", "max_issues_repo_name": "StarshipG/uwaterloo-igem-2015", "max_issues_repo_head_hexsha": "2f5a5779989b0303481931e4b4d97ca81a6c69e1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 108, "max_issues_repo_issues_event_min_datetime": "2015-03-13T00:53:09.000Z", "max_issues_repo_issues_event_max_datetime": "2015-10-14T18:22:46.000Z", "max_forks_repo_path": "models/viralassembly/mathVA Eqn List PR.tex", "max_forks_repo_name": "StarshipG/uwaterloo-igem-2015", "max_forks_repo_head_hexsha": "2f5a5779989b0303481931e4b4d97ca81a6c69e1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-03-12T01:52:48.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-13T01:05:10.000Z", "avg_line_length": 43.4014084507, "max_line_length": 209, "alphanum_fraction": 0.4742820055, "num_tokens": 2103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.40395807421633195}}
{"text": "% !TEX root=/home/tavant/these/manuscript/src/manuscript.tex\n\n\n\\section{Introduction to plasma models and simulations}\n\\label{sec-simulations}\n% \\addcontentsline{toc}{section}{Plasma models and simulations}\n\n\\subsection{Describing the plasma} \\label{subsec-phy}\n\nDepending on the pressure, energy, and time scale, different models are more suitable to describe the plasma.\nThere are mainly two distinct models.\nThe first is the \\emph{kinetic} description of the species of the plasma, via the Boltzmann equation.\nThe second uses a \\emph{fluid} description of the species, by means of moments.\n% \n% \\begin{figure}[hbt]\n%   \\centering\n%   \\includegraphics[width=\\defaultwidth]{Chart}\n%   \\caption{}\n%   \\label{fig-chart}\n% \\end{figure}\n\n\n\\paragraph{Boltzmann equation \\\\}\nThe Boltzmann equation in \\cref{eq-boltzmann} describes the evolution of the particles (atoms, ions, and electrons) in the phase space.\nThe phase space is the set of each possible position $\\vect{x}$ and velocity $\\vect{v}$ that can be attained by a particle.\nThe evolutions in the phase space are due to forces, diffusion, and collisions.\n\n\\begin{equation} \\label{eq-boltzmann}\n\\deriv{f}{t}  + \\vect{v} \\cdot \\grad_{\\vect{x}} f + \\vect{F} \\cdot  \\grad_{\\vect{v}} f = \\deriv{f}{t} \\at{\\rm coll}\n\\end{equation}\nwhere $f$ is the distribution function of the particle at $\\vect{x}, \\vect{v}$, and $\\deriv{f}{t}\\mid_{\\rm coll}$ denotes the effects of the collisions, $\\grad$ is the gradient in both the positions (subscript $\\vect{x}$) and the velocities (subscript $\\vect{v}$)  and $\\vect{F}$ is the force applied to the particle.\nIn the general electromagnetic case,\n\\begin{equation*} \\label{eq-forceEM}\n  \\vect{F} =  q \\vect{E} + q \\vect{v} \\times \\vect{B}\n\\end{equation*}\nwith $q$ the particle charge, $\\vect{E}$ the electric field, and $\\vect{B}$ the magnetic field.\nThe solution function of the stationary Boltzmann equation without collision, also known as the stationary Vlasov equation, is\n\\begin{equation} \\label{eq-Maxwellian}\n  f(\\vect{v}) = N (\\frac{m}{2 \\pi k_B T})^{3/2} \\exp \\lp - \\frac{q \\phi + m v^2/2}{k_B T } \\rp,\n\\end{equation}\nwith $k_B$ the Boltzmann constant, $T$ is the temperature of the particle population, and $\\phi$ is the electric potential, defined as $\\vect{E} = -\\grad \\phi$, and $N$ is the density at the position where $\\phi = 0$.\n\\cref{eq-Maxwellian} is the Maxwell-Boltzmann distribution function in velocity.\nThe unit of the temperature $T$ is the Kelvin, but in plasma physics, it is usual to use ${\\rm T}$, defined as\n\\begin{equation} \\label{eq-T_def}\n  e {\\rm T} = k_B T.\n\\end{equation}\nThe unit of ${\\rm T}$ is therefore the Volt.\nThe equivalence is $1 \\,\\volt \\simeq 10^4 \\,\\kelvin$.\n\\footnote{It is usual to find in the literature the temperature ${\\rm T}$ expressed in electron-Volt (eV).\nThis is not coherent with the definition \\cref{eq-T_def}, but it highlights the fact that the temperature is related to an energy via $k_B$. Therefore, the reader needs not to be confused by the equivalence between the electron-Volt and the Volt.  }\n\\nomenclature[Q]{\\ensuremath{ \\rm T}}{Temperature in Volt }\n\\nomenclature[Q]{\\ensuremath{ T}}{Temperature in Kelvin }\nWe can write \\cref{eq-Maxwellian} with the particle kinetic energy $\\epsilon = \\frac{1}{2} m v^2$ to define the energy distribution function\n\\begin{equation} \\label{eq-Maxwellina_energy}\n  f_{\\epsilon}(\\epsilon) = N \\frac{2 \\sqrt{\\epsilon}}{{k_B T}^{3/2} \\sqrt{\\pi}} \\exp \\lp- \\frac{q \\phi + \\epsilon}{k_B T} \\rp.\n\\end{equation}\nThe factor $\\sqrt{\\epsilon}$ in \\cref{eq-Maxwellina_energy} appears because of the integration of the velocity distribution function $f$ over the three directions.\nThus, it is convenient to use the energy probability function \n\\begin{equation} \\label{eq-EPF}\n  f_P(\\epsilon) = \\frac{f_{\\epsilon}}{\\sqrt{\\epsilon}}.\n\\end{equation}\n\nWe name the Maxwellian distribution function the distribution\n\\begin{equation} \\label{eq-Maxwelliantwo}\n  f_{\\rm M}(\\vect{v}) = n \\lp \\frac{m}{2 \\pi k_B T}\\rp^{3/2} \\exp \\lp - \\frac{ m v^2/2}{k_B T } \\rp,\n\\end{equation}\nwith $n$ the density.\nOne can show that the Maxwellian distribution function is the solution of the Boltzmann equation with only elastic collisions \\citep{lieberman2005}.\nIn one dimension, the Maxwellian distribution function becomes\n\\begin{equation}\n  f_{\\rm M, 1D}(v) =  n \\lp\\frac{m}{2 \\pi k_B T}\\rp^{1/2} \\exp \\lp - \\frac{ m v^2/2}{k_B T } \\rp,\n\\end{equation}\n\n\\paragraph{Fluid equations \\\\}\nThe description of the plasma in 7 dimensions (3 of space, 3 of velocity, and one of time) can make the resolution of the Boltzmann equation complicated.\nIf the accurate description of $f$ is not needed, we can instead use the first moments of \\cref{eq-boltzmann} on the velocity to obtain a set of simpler equations.\n\nThe first equation is obtained by integrating \\cref{eq-boltzmann} over the velocity space, which gives\n\\begin{align}\n    & \\iiint_{\\vect{v}}  \\deriv{f}{t} d^3v &&+&& \\iiint_{\\vect{v}}  \\vect{v} \\cdot \\grad_{\\vect{x}} f  d^3v &&+&&  \\iiint_{\\vect{v}}  \\vect{F} \\cdot  \\grad_{\\vect{v}} f  d^3v && = && \\iiint_{\\vect{v}}  \\deriv{f}{t} \\at{\\rm coll} \\nonumber  \\\\ \n   \\iff &  \\deriv{n}{t} &&+&&  \\grad_{\\vect{x}}  \\cdot  ( \\vect{u} n) &&+&& 0 &&=&& S_{\\rm iz}   \\label{eq-conc}\n\\end{align} \nwhere $n=\\iiint f d^3v$ is the density, $\\vect{u} = \\frac{1}{n} \\iiint \\vect{v} f d^3v$ is the mean velocity, and $S_{\\rm iz}$ is the source term of particle due to ionization.\n\\Cref{eq-conc} is the continuity equation for a given species.\nIn a similar way, integrating the Boltzmann equation times the velocity or the kinetic energy gives the momentum conservation equation or the energy conservation equation, respectively.\nThis set of equations is simpler, although it relies on additional hypotheses.\n\nOne of them is the closure of the system.\nIndeed, the continuity equation describes the evolution of the density $n$ but needs the mean velocity $\\vect{u}$.\nHowever, the velocity is described by the momentum conservation equation that needs the temperature $T$, and so on.\nTo close the system, one has to make a hypothesis on the higher moment of the distribution function.\nA usual closure is the isothermal hypothesis, that fixes the temperature. \nHence, the energy conservation equation is not needed.\nOther possible closures are the adiabatic hypothesis (no heat flux, the \\nth{3} moment of $f$), the polytropic law linking the evolution of $n$ with $T$, or the Fourier law for heat diffusion.\n\n\nIt is important to note that the set of fluid equations can be written without making any assumption on the distribution function $f$, except for the collisions. \n%Besides, one may be led to believe that the temperature is defined by the Maxwell-Boltzmann distribution \\cref{eq-Maxwellian}, and therefore that the fluid set of equations needs to use the Maxwellian hypothesis $f = f_{\\rm M}$.\nIn this work, the temperature is defined by the second moment of the distribution function\n\\begin{equation} \\label{eq-defTe}\n  e {\\rm T} = k_B T = \\frac{m}{3 n} \\iiint (\\vect{v} - \\vect{u})^2 f(\\vect{v}) d^3v.\n\\end{equation}\nIt happens that in the case of the Maxwell-Boltzmann distribution, the quantity defined by \\cref{eq-defTe} is the denominator of the argument of the exponential in \\cref{eq-Maxwellian}.\nThe integral in \\cref{eq-defTe} can be decomposed over the three directions $x,y$, and $z$ as\n\\begin{equation} \\label{eq-3Te}\n  e {\\rm T} = k_B T = \\frac{m}{3 n} \\sum_{i=x,y,z} \\iiint (v_i - u_i)^2 f(\\vect{v}) d^3v = k_B \\frac{ T_x + T_y + T_z}{3},\n\\end{equation}\nwhich defines the directed temperatures.\nA distribution is said anisotropic if the three temperatures differ.\n\n\\subsection{Plasma simulation models} \\label{subsec-simulations}\nAs there are two different models to describe the plasma, there are two different simulation approaches\\string: the fluid simulations and the kinetic simulations.\nThe fluid simulations solve the moments of the distribution function (the density, mean velocity, and usually the temperature of the species), and the electromagnetic fields.\nDepending on the conditions, the system of equations can be simplified before resolution.\nFor instance, under the electrodynamic conditions, mainly for space plasmas and fusion, the Maxwell equations are coupled to the fluid equations leading to magnetohydrodynamics (MHD).\nIn the case of electrostatic conditions, as it is usual for Low-Temperature (LT) plasmas, the Poisson equation is coupled to the fluid equations.\nIn most of LT plasmas the plasma is quasi-neutral except in a limited near-wall region called the plasma sheath.\nIt is also common to neglect inertia terms and assume a steady-state in the momentum equations, leading to the drift-diffusion approximation.\nThe fluid equations can be solved in \\ac{3D}, \\ac{2D}, or \\ac{1D} for space.\nIn a low dimension model, the effects of the missing dimensions are usually included, for instance, in the source terms as done by \\citet{barral2003a}.\n\n\n\\vspace{1em}\nHowever, some phenomena can only be described via the knowledge of the distribution function.\nAn example of such phenomena is the particle-wave interaction, such as the Landau Damping \\citep{landau1945,malmberg1964}, or the plasma-beam instability \\citep{filippychev1990}, for which the gradient of the distribution function in the velocity space is important.\nIn contrast to the fluid descriptions, \\emph{kinetic} simulations solve the distribution function $f$ for both position and velocities.\nTwo approaches are usually used for kinetic simulations\\string:\n\\begin{itemize}\n  \\item The \\ac{DK} model, that discretizes \\cref{eq-boltzmann} in the full phase space.\n  \\item The \\acl{PIC} (\\acs{PIC}) model, which uses an ensemble of particles to discretize the distribution function.\n\\end{itemize} \nWhile the \\ac{DK} simulations use a Eulerian description of the distribution function, we can see the \\ac{PIC} simulations as a Lagrangian approach.\nThe \\ac{DK} simulations can theoretically better describe the plasma, mostly because there is less numerical noise and we can model binary collisions more easily, especially Coulomb collisions.\nOn the other hand, \\ac{PIC} simulations are much simpler to develop both on a mathematical and a computational perspective.\nFor instance, the kinetic effects of electron emission have been recently studied using \\ac{DK} simulation by \\citet{cagas2019}, while it has been done since the last century in \\ac{PIC} simulations \\citep{boswell1988}.\n\n\n", "meta": {"hexsha": "5e5019eb994cb93e898522c4aa62eda0b9f6600f", "size": 10445, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Context/4_simulations.tex", "max_stars_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_stars_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Context/4_simulations.tex", "max_issues_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_issues_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Context/4_simulations.tex", "max_forks_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_forks_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.6884057971, "max_line_length": 317, "alphanum_fraction": 0.7469602681, "num_tokens": 2906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4039538232195469}}
{"text": "\\documentclass[9pt]{beamer}\n\n%\\usepackage{tikz}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{algorithm2e}\n\\usepackage{color, colortbl}\n\\usepackage{enumerate}\n\\usepackage{arydshln}\n\\usepackage{multirow}\n\n\\usepackage{animate}\n\\usepackage{tabularx}\n\n\\renewcommand{\\figurename}{Fig}\n\\usetheme{uha}\n\n\n\n%\\theoremstyle{plain}\n%  \\newtheorem{theorem}{Theorem}\n%  \\newtheorem{lemma}{Lemma}\n\\newtheorem{corrolary}{Corollary}\n\\newtheorem{claim}{Claim}\n\\newtheorem{proposition}{Proposition}\n\\newtheorem{property}{Property}\n%  \\newtheorem{fact}{Fact}\n%\\theoremstyle{definition}\n%  \\newtheorem{definition}{Definition}\n%  \\newtheorem{example}{Example}\n%\\theoremstyle{remark}\n\\newtheorem{remark}{Remark}\n\\newtheorem{proviso}{Proviso}\n\n\n\\newcommand{\\ccr}[1]{{\\color{red}#1}}\n\\newcommand{\\ccb}[1]{{\\color{blue}#1}}\n\\newcommand{\\ccp}[1]{{\\color{purple}#1}}\n\\newcommand{\\ccm}[1]{{\\color{magenta}#1}}\n\\newcommand{\\cco}[1]{{\\color{orange}#1}}\n\\newcommand{\\ccy}[1]{{\\color{yellow}#1}}\n\\newcommand{\\ccl}[1]{{\\color{lime}#1}}\n\\newcommand{\\ccc}[1]{{\\color{cyan}#1}}\n\\newcommand{\\ccg}[1]{{\\color{gray}#1}}\n\\newcommand{\\ccpk}[1]{{\\color{pink}#1}}\n\\newcommand{\\ccov}[1]{{\\color{olive}#1}}\n\n\n\\begin{document}\n\n%%//////////////////////////////////////////////////////////////////////////////////////////////%%1\n\n\\title{Community Detection}\n\\subtitle{Algorithm Design}\n\\author{Zhemin Huang, Xunjie Wang}\n\\institute{School of Software, Shanghai Jiao Tong University}\n\\date{\\hspace{2em}}\n\\frame{\n\t\\titlepage\n}\n\n%%//////////////////////////////////////////////////////////////////////////////////////////////%%1\n\n\\section{Problem Description}\n\n\\frame{\n\t\\frametitle{Network}\n\t\\begin{definition}\n\t\t[Network]\n\t\tA \\ccp{network} is represented as \\ccb{$G=(V,E,W)$},\\\\\n\t\twhere \\ccb{$V,E$} denote the set of nodes and edges, respectively, and \\ccb{$W$} denotes the corresponding weights of the connections.\n\t\\end{definition}\n\n\t\\bigskip\n\n\t\\centerline{\\includegraphics[width=0.4\\textwidth]{figures/network/network.png}}\n}\n\n\\frame{\n\t\\frametitle{Community}\n\t\\begin{definition}\n\t\t[Community]\n\t\tCommunities are the sub-graphs in a network, where nodes share dense connections. Sparsely-connected nodes cripple communities. \\\\\n\t\tWe use \\ccb{$C=\\{C_1,C_2,...,C_k\\}$} to denote a set of \\ccb{$k$} communities divided from a network \\ccb{$G$}. A node \\ccb{$v$} clustered into the community \\ccb{$C_i$} satisfies the condition that the internal degree of each node inside the community exceeds its external degree. \\\\\n\t\tFor \\ccb{$\\forall i,j, C_i\\in C, C_j\\in C$}, they satisfy the following conditions\n\t\t\\ccb{\n\t\t\t\\begin{equation*}\n\t\t\t\tC_i\\cap C_j=\\varnothing\n\t\t\t\\end{equation*}\n\t\t\t\\begin{equation*}\n\t\t\t\t\\bigcup_{i=1}^{k}C_i=G\n\t\t\t\\end{equation*}\n\t\t}\n\t\\end{definition}\n}\n\n\\frame{\n\t\\frametitle{Community}\n\tA community is a type of sub-graph that represents some real social phenomenon. In order words, a community is a group of people or objects, which \\ccp{share common characteristics}.\n\n\t\\centerline{\\includegraphics[width=0.5\\textwidth]{figures/network/community.png}}\n}\n\n\\frame{\n\t\\frametitle{Modularity}\n\t\\begin{definition}\n\t\t[Modularity]\n\t\tConsider a particular division of a network into \\ccb{$k$} communities. Let us define a \\ccb{$k \\times k$} symmetric matrix \\ccb{$e$} whose element \\ccb{$e_{ij}$} is the fraction of all edges in the network that link vertices in community \\ccb{$i$} to vertices in community \\ccb{$j$}.\\\\\n\t\tWe further define the row sums \\ccb{$a_i=\\sum_{j}e_{ij}$}, which represent the fraction of edges that connect to vertices in community \\ccb{$i$}.\\\\\n\t\tIn a network in which edges fall between vertices who belong to different communities, we would have \\ccb{$e_{ij}=a_ia_j$}. Let \\ccb{$||X||$} indicates the sum of the elements of the matrix \\ccb{$X$}.\n\t\tThus, we define modularity by\n\t\t\\ccb{\n\t\t\t\\begin{equation*}\n\t\t\t\tQ=\\sum_i{e_{ii}-{a_i}^2}=\\sum_i{e_{ii}}-\\sum_i{{a_i}^2}=Trace-||e^2||\n\t\t\t\\end{equation*}\n\t\t}\n\t\\end{definition}\n}\n\n\\frame{\n\t\\frametitle{Modularity}\n\tProposed by Mark Newman, UMich.\n\t\n\t\\noindent He is known for his fundamental contributions to the fields of complex networks and complex systems, for which he was awarded the 2014 Lagrange Prize.\n\t\\vspace{1cm}\t\n\t\\href{http://www-personal.umich.edu/~mejn/}{\n\t\t\\centerline{\\includegraphics[width=0.45\\textwidth]{figures/gn/newman.jpg}}\n\t}\n}\n\n\\frame{\n\t\\frametitle{Modularity}\n\tModularity was designed to measure the strength of division of a network into communities. \n\t\n\t\\noindent If \\ccb{$Q$} is high, we get strong community structure.\n\t\n\t\\noindent In practice, values for such networks typically fall in the range from about \\ccb{0.3} to \\ccb{0.7}.\n\t\\centerline{\\includegraphics[width=0.5\\textwidth]{figures/network/modularity.png}}\n}\n\n\\frame{\n\t\\frametitle{Reformulation of The Modularity}\n\tIn order to raise \\ccp{a spectral algorithm for community detection}, Newman redefined the concept of modularity.\n\t\\begin{definition}\n\t\t[Reformulation of The Modularity]\n\t\tThe modularity of a community partition is a scalar ranging from \\ccb{$-\\frac{1}{2}$} to \\ccb{$1$} that evaluates the density of links inside communities as compared to links between communities. \\\\\n\t\tFor a given graph \\ccb{$G$}. Let \\ccb{$A_{ij}$} be the weight of the edge between \\ccb{$i$} and \\ccb{$j$}, \\ccb{$k_{i}=\\sum_{(i, j) \\in E}A_{ij}$} is the sum of the weights of all the edges attached to vertex \\ccb{$i$},  \\ccb{$m = \\frac{1}{2}\\sum_{ij}A_{ij}$}, the quantity \\ccb{$\\frac{1}{2}(s_is_j+1)$} is \\ccb{1} if \\ccb{$i$} and \\ccb{$j$} are in the same group and \\ccb{0} otherwise, \\\\\n\t\t\\ccb{\n\t\t\t\\begin{equation*}\n\t\t\t\tQ = \\frac{1}{4m}\\sum_{i \\in V, j \\in V}(A_{ij} - \\frac{k_{i}k_{j}}{2m})\\frac{1}{2}(s_is_j+1)\n\t\t\t\\end{equation*}}\n\t\\end{definition}\n\tThe leading factor of \\ccb{$\\frac{1}{4m}$} seems to be confusing. Actually, it is included for compatibility with the previous definition of modularity.\n}\n\n\\frame{\n\t\\frametitle{Community Detection}\n\tFrom the definitions above, we can lead to our goal -- \\ccp{community detection}.\n\t\\begin{definition}\n\t\t[Community detection]\n\t\tCommunity detection is a method to extract communities from large networks when the modularity is optimal.\n\t\\end{definition}\n\tNot all methods are based on modularity, such as \\ccp{Infomap}.\n\t\n\t\\noindent Modularity has its limits, but it is still the most commonly used method for evaluating results.\n}\n\n\\section{Key Properties}\n\n\\frame{\n\t\\frametitle{Modularity}\n\t\\begin{lemma}\n\t\tWe denote the set of all possible communities of a graph \\ccb{$G$} with \\ccb{$A(G)$}, \\ccb{$Q(P)$} refers to the modularity of \\ccb{$P$}. \\\\\n\t\tLet \\ccb{$G$} be an undirected and unweighted graph and \\ccb{$P \\in A(G)$}. \\\\\n\t\tThen \\ccb{$-\\frac{1}{2}\\le Q(P) \\le 1$} holds.\n\t\\end{lemma}\n}\n\n\\frame{\n\t\\frametitle{Proof}\n\t\\ccm{\\em Proof.}\n\tLet \\ccb{$m_i=|E(P)|$} be the number of edges inside community \\ccb{$P$} and \\ccb{$m_e=\\sum_{P\\neq P'\\in P}|E(P, P')|$} be the number of edges having exactly one end-node in \\ccb{$P$}. \\\\\n\tThen we can calculate the contribution of \\ccb{$P$} to \\ccb{$Q(P)$}\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\t\\frac{m_i}{m}-(\\frac{m_i}{m}+\\frac{m_e}{2m})^2=\\frac{-4(m_i)^2+4m_i(m-m_e)-(m_e)^2}{4m^2}\n\t\t\\end{equation*}\n\t}\n\n\tIt is obvious that the only maximum point is at \\ccb{$m_i=\\frac{m-m_e}{2}$}. The contribution of a community is minimized when \\ccb{$m_i$} is zero and \\ccb{$m_e$} is as large as possible. \\\\\n\tSuppose now \\ccb{$m_i=0$}, the upper bound can only be actually attained in the specific case of a graph with no edges, where coverage is defined to be \\ccb{1}. \\\\\n\tBesides, any bipartite graph \\ccb{$K_{a,b}$} with simple communities \\ccb{$C=\\{C_a, C_b\\}$} yields the minimum modularity of \\ccb{$\\frac{1}{2}$}. This proof the lemma.\n}\n\n\\frame{\n\t\\frametitle{Modularity}\n\t\\begin{theorem}\n\t\tModularity is \\ccb{\\textbf{NP-complete}}.\n\t\\end{theorem}\n}\n\n\\frame{\n\t\\frametitle{Proof(1)}\n\tWe formalize the problem of finding modularity, and prove it by \\ccb{\\textbf{reduction}}.\n\n\t\\begin{block}{Problem 1 (Modularity)}\n\t\tGiven a graph \\ccb{$G$} and a number \\ccb{$K$}, is there a community    \\ccb{$P\\in G$}, for which \\ccb{$Q(P)\\ge K$}? (\\ccb{$K\\in [-\\frac{1}{2},1]$}) ?\n\t\\end{block}\n\n\t\\begin{block}{Problem 2 (3-Partition)}\n\t\tGiven \\ccb{$3k$} positive integer numbers \\ccb{$a_1,...,a_{3k}$} such that the sum \\ccb{$\\sum_{i=1}^{3k}a_i=kb$}, and \\ccb{$\\frac{b}{4} < a_i < \\frac{b}{2}$}, for an integer \\ccb{$b$} and for all \\ccb{$i=1,...,3k$}, is there a partition of these numbers into \\ccb{$k$} sets, such that the sum of the numbers in each set equals to \\ccb{$b$}?\n\t\\end{block}\n}\n\n\\frame{\n\\frametitle{Proof(2)}\nIt has been proved that 3-partition problem is a NP-Complete problem.\n\nThen we show that an instance \\ccb{$A={a_1,...,a_{3k}}$} of 3-partition problem can be transformed into an instance \\ccb{$G(A), K(A)$} of modularity problem.\n\nGiven an instance \\ccb{$A$} of 3-partition, we can construct a graph \\ccb{$G(A)$} with \\ccb{$k$} cliques \\ccb{$H_1,...,H_k$} of size \\ccb{$a=\\sum_{i=1}^{3k} a_i$} each. For each element \\ccb{$a_i\\in A$}, we introduce a single element node in graph, and\nconnect it to \\ccb{$a_i$} nodes in each of the \\ccb{$k$} cliques, where each clique member is connected to exactly one element node. Therefore, each clique node has degree \\ccb{$a$}, and the element node corresponding to element \\ccb{$a_i\\in A$} has degree\n\\ccb{$ka_i$}. The number of edges in \\ccb{$G(A)$} is \\ccb{$m=\\frac{k}{2}·a(a+1)$}.\n}\n\n\\frame{\n\t\\frametitle{Proof(3)}\n\tThen we construct \\ccb{$K(A)$}. Since graph \\ccb{$G(A)$} has exactly \\ccb{$k$} cliques, it has exactly \\ccb{$(k-1)a$} inter-community edges, so the edge contribution is given by\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\t\\begin{split}\n\t\t\t\t\\sum_{C\\in P}\\frac{|E(C)|}{m}=\\frac{m-(k-1)a}{m}\n\t\t\t\\end{split}\n\t\t\t\\begin{split}\n\t\t\t\t=1-\\frac{2(k-1)a}{ka(a+1)}=1-\\frac{2k+2}{k(a+1)}\n\t\t\t\\end{split}\n\t\t\\end{equation*}\n\t}\n\tTherefore, communities \\ccb{$P=(C_1,...,C_k)$} with maximum modularity must minimize \\ccb{$d(C_1)^2+d(C_2)^2+...+d(C_k)^2$}, where \\ccb{$d(C_k)$} refers to the degree of \\ccb{$C_k$}. Then the sum of degrees per community should be as small as possible.\n\n\tIn the optimum case, we can assign to each community element nodes corresponding to elements that sum to \\ccb{$b=\\frac{1}{k}·a$}. In each clique, the sum equals to \\ccb{$k·\\frac{1}{k}·a=a$}.\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\td(C_1)^2+...+d(C_k)^2\\ge k(a^2+a)^2 = ka^2(a+1)^2\n\t\t\\end{equation*}\n\t}\n}\n\n\\frame{\n\t\\frametitle{Proof(4)}\n\tHence, if there exist communities \\ccb{$P$} with \\ccb{$Q(P)$}, then\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\tK(A)\\ge 1-\\frac{2k-2}{k(a+1)}-\\frac{ka^2(a+1)^2}{k^2a^2(a+1)^2} = \\frac{(k-1)(a-1)}{k(a+1)}\n\t\t\\end{equation*}\n\t}\n\n\tAs each element node is contained in exactly one community, this yields a solution for the instance of 3-partition. The instance of 3-partition is satisfiable if the instance of modularity is satisfiable.\n\n\tOtherwise, suppose the instance for 3-partition is satisfiable. Then there exists a partition into \\ccb{$k$} sets, where the sum over each set is \\ccb{$\\frac{1}{k}·a$}. If we detect communities by joining the element nodes of each set with a different clique, we get communities of modularity \\ccb{$K(A)$}. Therefore, the instance of modularity is satisfiable if the instance of 3-partition is satisfiable.\n\n\tTherefore, the theorem holds.\n}\n\n\\section{Girvan-Newman Algorithm}\n\n\\frame{\n\t\\frametitle{Edge Betweenness}\n\t\\begin{definition}\n\t\t\\ccp{Edge betweenness} of an edge \\ccb{$(i,j)$} is the number of the shortest paths between pairs of vertices that pass through the edge \\ccb{$(i,j)$}.\n\t\\end{definition}\\pause\n\n\t\\cco{Intuition.}\n\tAn edge with a high edge betweenness score represents a bridge-like connector between two parts of a network, and the removal of which may affect the communication between many pairs of nodes through the shortest paths between them.\n\n\t\\bigskip\n\n\t\\centerline{\\includegraphics[width=0.65\\textwidth]{figures/gn/eb.png}}\n}\n\n\\frame{\n\t\\frametitle{Edge Betweenness}\n\n\t\\begin{itemize}\n\t\t\\item \\ccb{$d_{s, i}$} is the \\ccp{length of the shortest path} between vertex \\ccb{$s$} and vertex \\ccb{$i$}.\n\t\t\\item \\ccb{$w_{s, i}$} is the \\ccp{number of the shortest paths} from vertex \\ccb{$s$} to vertex \\ccb{$i$}.\n\t\t\\item \\ccb{$b_{s, i}$} is the \\ccp{number of the shortest paths} between vertex \\ccb{$s$} to any vertex in graph that pass through vertex \\ccb{$i$}.\n\t\\end{itemize}\\pause\n\n\tEdge betweenness \\ccb{$\\sigma_{i,j}$} of edge \\ccb{$(i,j)$}:\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\t\\sigma_{i,j} = \\sum_{s \\in V}\\sigma_{s,i,j}\n\t\t\\end{equation*}\n\t} where\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\t\\sigma_{s,i,j} = \\begin{cases}\n\t\t\t\t\\frac{w_{s,j}}{w_{s,i}}b_{s,i} & d_{s,i} > d_{s,j} \\\\\n\t\t\t\t\\frac{w_{s,i}}{w_{s,j}}b_{s,j} & d_{s,i} < d_{s,j} \\\\\n\t\t\t\t0                              & d_{s,i} = d_{s,j}\n\t\t\t\\end{cases}\n\t\t\\end{equation*}\n\t}\n}\n\n\\frame{\n\t\\frametitle{Breath First Search}\n\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Breath-First-Search}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E), s$}\n\t\t\t\\BlankLine\n\t\t\t$d_{s,s} \\leftarrow 0, w_{s,s} \\leftarrow 1, b_{s,s} \\leftarrow 0$,\n\t\t\t$Q \\leftarrow \\{s\\}, L \\leftarrow \\{s\\}$\\;\n\t\t\t\\For{each vertex $v \\in V - \\{s\\}$}{\n\t\t\t\t$d_{s,v} \\leftarrow \\infty, w_{s,v} \\leftarrow 0, b_{s,v} \\leftarrow 1$\\;\n\t\t\t}\n\t\t\t\\While{$Q$ is not empty}{\n\t\t\tDequeue $i \\leftarrow Q$\\;\n\t\t\t\\For{each vertex $j$ where $(i,j) \\in E$}{\n\t\t\t\\If{$d_{s,j} \\neq \\infty$ and $d_{s,j} = d_{s,i}+1$}{\n\t\t\t$w_{s,j} = w_{s,j}+w_{s,i}$\\;\n\t\t\t}\n\t\t\t\\If{$d_{s,j}=\\infty$}{\n\t\t\t\t$d_{s,j} = d_{s,i}+1, w_{s,j} = w_{s,i}$, Enqueue $j \\rightarrow Q$, Push $j \\rightarrow L$\\;\n\t\t\t}\n\t\t\t}\n\t\t\t}\n\t\t\t\\Return $(d,w,s,L)$\\;\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Reverse Breath First Search}\n\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Reverse-Breath-First-Search}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E),s,w,d,L$}\n\t\t\t\\BlankLine\n\t\t\t\\While{$L$ is not empty}{\n\t\t\tPop $i \\leftarrow L$\\;\n\t\t\t\\For{each vertex $j$ where $(i,j) \\in E$}{\n\t\t\t\\If{$d_{s,i} < d_{s,i}$}{\n\t\t\t\t$b_{s,i} = 1+\\sum_{j}\\sigma_{s,i,j}$\\;\n\t\t\t}\n\t\t\t\\If{$d_{s,i} > d_{s,j}$}{\n\t\t\t$\\sigma_{s,i,j} = \\frac{w_{s,j}}{w_{s,i}}b_{s,i}$\\;\n\t\t\t}\n\t\t\t}\n\t\t\t}\n\t\t\t\\Return $\\sigma$\\;\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Girvan-Newman Algorithm}\n\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Girvan-Newman}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E)$}\n\t\t\t\\BlankLine\n\t\t\tCalculate edge betweenness for each edge in the graph\\;\n\t\t\t\\While{$E$ is not empty}{\n\t\t\t\tLet $e$ be the edge with highest edge betweenness\\;\n\t\t\t\t$E \\leftarrow E - \\{e\\}$\\;\n\t\t\t\tCalculate edge betweenness for remaining edges\\;\n\t\t\t}\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Review of Modularity}\n\t\\begin{definition}\n\t\t\\ccp{Modularity} of a network is a scalar ranging from \\ccb{$-\\frac{1}{2}$} to \\ccb{$1$} that evaluates the density of links inside communities as compared to links between communities.\n\t\t\\ccb{\n\t\t\t\\begin{equation*}\n\t\t\t\tQ = \\frac{1}{4m}\\sum_{i \\in V, j \\in V, c_i = c_j}[A_{ij} - \\frac{k_{i}k_{j}}{2m}]\n\t\t\t\\end{equation*}\n\t\t}\n\t\\end{definition}\n\n\t\\begin{itemize}\n\t\t\\item \\ccb{$A_{ij}$} is the weight of the edge between \\ccb{$i$} and \\ccb{$j$}.\n\t\t\\item \\ccb{$k_{i} = \\sum_{(i, j) \\in E}A_{ij}$} is the sum of the weights of all the edges attached to vertex \\ccb{$i$}.\n\t\t\\item \\ccb{$m = \\frac{1}{2}\\sum_{ij}A_{ij}$},\n\t\t\\item \\ccb{$c_{i}$} is the community of vertex \\ccb{$i$}.\n\t\\end{itemize}\n\n\t\\bigskip\n}\n\n\\frame{\n\t\\frametitle{Girvan-Newman Algorithm}\n\n\t\\begin{itemize}\n\t\t\\item Girvan-Newman algorithm computes the modularity of current community partition, and determined to terminate when the modularity of the resulting partition reaches a \\ccp{maximum}.\n\t\t\\item In complex networks it is often the case that more edges have the \\ccp{same highest} edge betweenness. We can remove these edges \\ccp{together} to effectively reduce the number of iteration.\n\t\\end{itemize}\n\n\t\\bigskip\n}\n\n\\frame{\n\t\\frametitle{Girvan-Newman Algorithm with Modularity}\n\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Modularity-Girvan-Newman}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E)$}\n\t\t\t\\BlankLine\n\t\t\tCalculate edge betweenness for each edge in the graph\\;\n\t\t\tCalculate modularity $Q$\\;\n\t\t\t\\While{$E$ is not empty}{\n\t\t\t\tLet $E'$ be the set of all edges with the highest edge betweenness\\;\n\t\t\t\tCalculate modularity $Q'$ of $G=(V, E - E')$\\;\n\t\t\t\t\\If{$Q' < Q$}{\n\t\t\t\t\tBreak\\;\n\t\t\t\t}\n\t\t\t\t$E \\leftarrow E - E'$\\;\n\t\t\t\tCalculate edge betweenness for remaining edges\\;\n\t\t\t}\n\t\t\t\\Return{(V, E)}\\;\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n\n\t\\bigskip\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tLet's start with a simple network.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=0.45\\textwidth]{figures/gn/e0.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tStart from vertex \\ccb{$A$} and BFS the network to get the shortest paths.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=1.1\\textwidth]{figures/gn/e1_3.png}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tCalculate the \\ccp{number of the shortest paths} from vertex \\ccb{$A$} that pass through vertex \\ccb{$u$}.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=0.35\\textwidth]{figures/gn/e4.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tReverse BFS to calculate the \\ccp{number of the shortest paths} from vertex \\ccb{$A$} that pass through edge \\ccb{$e$}.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=0.85\\textwidth]{figures/gn/e5.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tReverse BFS to calculate the \\ccp{number of the shortest paths} from vertex \\ccb{$A$} that pass through edge \\ccb{$e$}.\n\n\t\\bigskip\n\n\t\\centerline{\\includegraphics[width=0.55\\textwidth]{figures/gn/e6.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tRepeat for each vertex and sum them up.\n\n\t\\bigskip\n\n\t\\centerline{\\includegraphics[width=0.55\\textwidth]{figures/gn/e7.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tRemove all edges with the highest edge betweenness.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=1\\textwidth]{figures/gn/e8.jpg}}\n\n\tAnd then we can get three communities.\n}\n\n\\section{Louvain Algorithm}\n\n\\frame{\n\t\\frametitle{Louvain Algorithm}\n\t\\begin{itemize}\n\t\t\\item Louvain is a multistep technique based on a \\ccp{local optimization} of Newman-Girvan modularity in the neighborhood of each node.\n\t\t\\item After a partition is identified in this way, communities are replaced by \\ccp{supernodes}, yielding a smaller weighted network.\n\t\t\\item The procedure is then iterated, until modularity does not increase any further.\n\t\\end{itemize}\\pause\n\t\\centerline{\\includegraphics[width=0.9\\textwidth]{figures/louvain/v0.png}}\n}\n\n\\frame{\n\t\\frametitle{Modularity Increment}\n\t\\begin{definition}\n\t\t\\ccp{Modularity increment} \\ccb{$\\Delta{Q}$} of \\ccb{$(i,j)$} is the \\ccp{change of modularity} when removing vertex \\ccb{$i$} from its community and then placing it to the community of its neighbor \\ccb{$j$}.\n\t\\end{definition}\n\t\\pause\n\tThis removing-placing action can be decomposed into two similar actions:\n\t\\begin{itemize}\n\t\t\\item [1)] making vertex \\ccb{$u$} isolated\n\t\t\\item [2)] moving the isolated vertex into a community\n\t\\end{itemize}\n\t\\ccb{$\\Delta{Q}$} is the sum of \\ccb{$\\Delta{Q}'$} of these two actions. These two \\ccb{$\\Delta{Q}'$} can be computed in the same way, for 1) is just the inverse action of 2).\n}\n\n\\frame{\n\t\\frametitle{Modularity Increment}\n\t\\ccb{\n\t\t\\begin{equation*}\n\t\t\t\\Delta{Q}' = \\bigg[\\frac{\\sum_{in} + k_{i, in}}{2m} - \\bigg(\\frac{\\sum_{tot} + k_{i}}{2m}\\bigg)^{2}\\bigg] - \\bigg[\\frac{\\sum_{in}}{2m} - \\bigg(\\frac{\\sum_{tot}}{2m}\\bigg)^{2} - \\bigg(\\frac{k_{i}}{2m}\\bigg)^{2}\\bigg]\n\t\t\\end{equation*}\n\t}\n\twhere\n\t\\ccb{\n\t\t\\begin{itemize}\n\t\t\t\\item $\\sum_{in}$ is the sum of the weights of the internal edges of $c_{j}$\n\t\t\t\\item $\\sum_{tot}$ is the sum of the weights of the links incident to vertices in community $c_{j}$\n\t\t\t\\item $k_{i, in}$ is the sum of the weights of the links from $i$ to vertices in community $c_{j}$\n\t\t\\end{itemize}\n\t}\n}\n\n\\frame{\n\t\\frametitle{Louvain Algorithm}\n\tEach iteration, also named \\ccp{pass} in Louvain, has two phases.\n\t\\begin{itemize}\n\t\t\\item [1)] Modularity Optimization\n\t\t\\item [2)] Community Aggregation\n\t\\end{itemize}\n\n\t\\centerline{\\includegraphics[width=0.65\\textwidth]{figures/louvain/2phase.png}}\n}\n\n\\frame{\n\t\\frametitle{Modularity Optimization}\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Modularity-Optimization}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E)$}\n\t\t\t\\BlankLine\n\t\t\t\\ForEach{$u \\in V$}{\n\t\t\t\tLet $v$ be the neighbor who has the largest modularity increment\\;\n\t\t\t\t\\If{this increment is positive}{\n\t\t\t\t\t$c_{u} \\leftarrow c_{}$\n\t\t\t\t}\n\t\t\t}\n\t\t\t\\Return{c}\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tHere is the visualization of phase 1.\n\t\\bigskip\n\t\\centerline{\\includegraphics[width=1\\textwidth]{figures/louvain/phase1.png}}\n}\n\n\\frame{\n\t\\frametitle{Community Aggregation}\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Community-Aggregation}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E),c$}\n\t\t\t\\BlankLine\n\t\t\t\\ForEach{unmerged vertex $u$}{\n\t\t\t\t\\ForEach{unmerged vertex $v \\in V - \\{u\\}$ and $c_{u} = c_{v}$}{\n\t\t\t\t\tMerge vertex $v$ to $u$\\;\n\t\t\t\t}\n\t\t\t\tUpdate internal and external weights of edges\\;\n\t\t\t}\n\t\t\t\\Return{G,c}\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Example}\n\tHere is the visualization of phase 2.\n\t\\begin{itemize}\n\t\t\\item The weights of edges between two new vertices are determined by sum of the weights of the edges between vertices in the corresponding two communities.\n\t\t\\item The internal edges of a community leads to a self-loop for the corresponding vertex in the new network.\n\t\\end{itemize}\n\t\\centerline{\\includegraphics[width=1\\textwidth]{figures/louvain/phase2.png}}\n}\n\n \\frame{\n\t\\frametitle{Visualization of Louvain Algorithm}\n\t\n\t% \\centerline{\\includemovie{1cm}{1cm}{figures/karoake_louvain.gif}}\n\t% \\animategraphics[width=10cm,height=10cm, autoplay, loop, controls]{24}{figures/louvain/louvain-}\n \t\\centerline{\\animategraphics[width=12cm,height=6cm,autoplay,loop,controls]{36}{figures/louvain_gif/louvain-}{0}{620}}\n }\n\n\\section{Parallelization of Louvain Algorithm}\n\n\n\\frame{\n\t\\frametitle{Parallelization of Louvain Algorithm}\n\t\\begin{itemize}\n\t\t\\item In the original \\ccp{serial} algorithm, each vertex examines the communities of its neighbors and makes a choice to chooses a new community based on a function to maximize the calculated change in modularity.\n\t\t\\item In the \\ccp{distributed} and \\ccp{parallel} version, all vertices make this choice simultaneously rather than in serial order, updating the graph state after each change.\n\t\\end{itemize}\n\t\\vspace{5mm}\n\t\\centerline{\\includegraphics[width=0.4\\textwidth]{figures/louvain/spark.jpeg}}\n\t\n}\n\n\\frame{\n\t\\frametitle{Parallelization of Louvain Algorithm}\n\t\\begin{exampleblock}{}\n\t\t\\begin{algorithm}[H]\n\t\t\t\\SetKwData{x}{x}\\SetKwData{y}{y}\\SetKwData{z}{z}\n\t\t\t\\SetKwFunction{CS}{\\sc Parallel-Louvain}\\SetKwFunction{Return}{\\sc Return}\\SetKwFunction{Init}{\\sc Initialize}\n\t\t\t\\SetKwFunction{Up}{\\sc Update}\\SetKwFunction{Au}{\\sc Augment}\n\t\t\t\\SetKwInOut{Input}{input}\\SetKwInOut{Output}{output}\n\t\t\t\\CS{$G=(V,E)$}\n\t\t\t\\BlankLine\n\t\t\t\\While{True}{\n\t\t\t\t\\ForEach{vertex $u \\in V$}{\n\t\t\t\t\tModularity Optimization on vertex $u$ in parallel to get modularity increment $\\Delta{Q}_{u}$\\;\n\t\t\t\t}\n\t\t\t\t$\\Delta{Q} \\leftarrow \\sum_{u \\in V}\\Delta{Q}_{u}$\\;\n\t\t\t\t\\If{$\\Delta{Q} \\le 0$}{\n\t\t\t\t\tBreak\\;\n\t\t\t\t}\n\t\t\t\tCommunity-Aggregation(G,c)\\;\n\t\t\t}\n\t\t\\end{algorithm}\n\t\\end{exampleblock}\n}\n\n\\frame{\n\t\\frametitle{Parallelization of Louvain Algorithm}\n\tThe flowchart of the parallel Louvain algorithm:\n\t\\centerline{\\includegraphics[width=1\\textwidth]{figures/louvain/p_flowchart.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Parallelization of Louvain Algorithm}\n\tPractically, It is a good choice to implement a parallel algorithm on \\ccp{Spark}, which is a cluster computing framework supporting reusing a working set of data across multiple parallel operations while retaining the scalability and fault tolerance of \\ccp{MapReduce}.\n\n\tTo describe the algorithm using MapReduce framework:\n\t\\begin{itemize}\n\t\t\\item [1)] Get information of adjacent vertices.\n\t\t      \\begin{itemize}\n\t\t\t      \\item [a)] Map: produce information of adjacent vertices \\ccb{$\\text{VertexData}$};\n\t\t\t      \\item [b)] Reduce: get information of adjacent vertices \\ccb{$(\\text{Id}, \\text{Array}[\\text{VertexData}])$}.\n\t\t      \\end{itemize}\n\t\t\\item [2)] Get the new community \\ccb{$(\\text{Id}, \\text{getBestCommunity}(\\text{Array}[\\text{VertexData}]))$}\n\t\t\\item [3)] Update the information in the network and merge vertices to go to next iteration.\n\t\\end{itemize}\n}\n\n\\section{Improvement of Louvain Algorithm}\n\n\\frame{\n\t\\frametitle{Drawbacks of Louvain Algorithm}\n\tIn the Louvain algorithm, a node may be moved to a different community, while it may have acted as a \"bridge\" between different communities. Removing such a node disconnects the nodes in the old community.\n\t\n\t\\vspace{5mm}\n\t\n\t\\centerline{\\includegraphics[width=0.8\\textwidth]{figures/louvain/louvain_drawback.png}}\n}\n\n\\frame{\n\t\\frametitle{Leiden Algorithm}\n\tThe Leiden algorithm is more complex than the Louvain algorithm. It consists of three phases:\n\t\\begin{itemize}\n\t\t\\item [1)] Local moving of nodes.\n\t\t\\item [2)] Refinement of the partition.\n\t\t\\item [3)] Aggregation of the network based on the refined partition, use the non-refined partition to create an initial partition for the aggregate network.\n\t\\end{itemize}\n}\n\n\\frame{\n\t\\frametitle{Leiden Algorithm}\n\n\t\\centerline{\\includegraphics[width=0.5\\textwidth]{figures/louvain/leiden.png}}\n\n\t\\begin{itemize}\n\t\t\\item The Leiden algorithm starts from a singleton partition (\\ccb{$a$}).\n\t\t\\item The algorithm moves individual nodes from one community to another to find a partition (\\ccb{$b$}), which is then refined (\\ccb{$c$}).\n\t\t\\item An aggregate network (\\ccb{$d$}) is created based on the refined partition, using the non-refined partition to create an initial partition for the aggregate network.\n\t\\end{itemize}\n}\n\n\\frame{\n\t\\frametitle{Leiden Algorithm}\n\n\t\\centerline{\\includegraphics[width=0.5\\textwidth]{figures/louvain/leiden.png}}\n\n\t\\begin{itemize}\n\t\t\\item The algorithm then moves individual nodes in the aggregate network (\\ccb{$e$}).\n\t\t\\item In this case, refinement does not change the partition (\\ccb{$f$}).\n\t\t\\item These steps are repeated until no further improvements can be made.\n\t\\end{itemize}\n}\n\n\\frame{\n\t\\frametitle{Comparison Between Louvain and Leiden}\n\n\t\\centerline{\\includegraphics[width=1.05\\textwidth]{figures/louvain/compare.jpg}}\n}\n\n\\section{Applications of Community Detection}\n\n\\frame{\n\t\\frametitle{Applications in social networks}\n\tAn social network is the interaction of people with each other through the web. Community detection has been widely used in this area.\n\n\tVarious studies have utilized different community detection methods to analyze public emotional reaction and visualize relationships and characteristics.\n\t\\centerline{\\includegraphics[width=1\\textwidth]{figures/app/combine.png}}\n}\n\n\\frame{\n\t\\frametitle{Applications in biological networks}\n\tResearchers have proposed an algorithm called \\ccp{disease-gene network detecting algorithm}, based on Principal Component Analysis (PCA), which can extract the communities in a diseasome bipartite network.\n\n\tThis algorithm is aimed at disease prevention and medical diagnosis.\n\t\\centerline{\\includegraphics[width=0.9\\textwidth]{figures/app/bio.png}}\n}\n\n\\frame{\n\t\\frametitle{Applications in economics}\n\tIn the \\ccp{stock market}, each stock can be represented by a vertex and edge represents the correlations of stock values in the market. Researchers have stated the way to construct the network of stock market and detect communities in it.\n\tThey revealed community structure by using modularity \\ccb{$Q$}, which helps to the analysis and decision-making of the stock market.\n\t\n\t\\begin{figure}\n\t\\centerline{\\includegraphics[width=0.75\\textwidth]{figures/app/stock.png}}\n\t\\caption{Several pictures of stock networks. Different node colors represent different communities and node sizes reflect its degree.}\n\t\\end{figure}\n\n}\n\n\\section{Conclusion}\n\n\\frame{\n\t\\frametitle{Future Direction}\n\t\\ccp{Deep learning} --- a promising direction of community detection. Beyond simply examining network topologies for detecting communities, some strategies also explore semantic descriptions as node features in the data.\n\n\t\\centerline{\\includegraphics[width=0.65\\textwidth]{figures/conc/dl.jpg}}\n}\n\n\\frame{\n\t\\frametitle{Open problems}\n\tThere are still so many broad challenges in community detection. For example:\n\t\\begin{itemize}\n\t\t\\item Network \\ccp{dynamics}\n\t\t\\item \\ccp{Large-scale} networks\n\t\t\\item \\ccp{Inaccurate} number of communities\n\t\\end{itemize}\n}\n\n\\frame{\n\t\\frametitle{Network dynamics}\n\tChanging dynamics can affect either the network topology or the node attributes. Topological changes not only cause changes in a local community, but also leads to devastating changes across an entire network.\n\n\tActually, a lot of methods have been used to deal with sequential data in machine learning, such as \\ccp{long short-term memory} (\\ccp{LSTM}). Therefore, deep learning methods for detecting communities with dynamic spatial and temporal properties are very likely to be developed.\n\n\t\\centerline{\\includegraphics[width=0.6\\textwidth]{figures/conc/LSTM.png}}\n}\n\n\\frame{\n\t\\frametitle{Large-scale networks}\n\tNowadays, large-scale networks can contain millions of nodes, edges, and structural patterns, as networks like Twitter and Weibo, which has also brought a lot of problems.\n\n\tFor instance, large-scale networks may have their inherent characteristics, such as \\ccp{scale-free}. There exists lots of mega hubs in the network, which can influence the performance of algorithms in community detection.\n\t\n\t\\vspace{5mm}\n\t\n\t\\centerline{\\includegraphics[width=0.75\\textwidth]{figures/app/scalefree.jpg}}\n\t\n}\n\n\\frame{\n\t\\frametitle{Inaccurate number of communities}\n\tIn fact, most algorithms of the community detection require the \\ccp{number of communities} beforehand as a hyperparameter, including deep learning.\n\n\tTwo common solutions:\n\t\\begin{itemize}\n\t\t\\item Using \\ccp{modularity-based} algorithm, like Girvan-Newman or Louvain\n\t\t\\item Using \\ccp{statistical} interference\n\t\\end{itemize}\n\n\tUnfortunately, both methods have poor performance under large-scale networks.\n}\n\n\n\\end{document}\n", "meta": {"hexsha": "d008647841834f7a6c9f597702191781276367f8", "size": 31509, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/slides.tex", "max_stars_repo_name": "xtommy-1/community-detection", "max_stars_repo_head_hexsha": "c465a03196300e46cc6d1c340779e17d8259c9d8", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/slides.tex", "max_issues_repo_name": "xtommy-1/community-detection", "max_issues_repo_head_hexsha": "c465a03196300e46cc6d1c340779e17d8259c9d8", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/slides.tex", "max_forks_repo_name": "xtommy-1/community-detection", "max_forks_repo_head_hexsha": "c465a03196300e46cc6d1c340779e17d8259c9d8", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3788063337, "max_line_length": 407, "alphanum_fraction": 0.70259291, "num_tokens": 10146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.4039481858718964}}
{"text": "% --- [ Distance ] -------------------------------------------------------------\n\n\\subsection{Distance}\n\nThe distance metric measures the distance in height between the recovered type and the source type in the primitive type lattice (see figure \\ref{fig:primitive_type_lattice}). The calculation of distance is meaningful only for subtypes (e.g. \\texttt{int32} is a subtype of \\texttt{reg32} at distance 2), otherwise the maximum lattice height is used.\n", "meta": {"hexsha": "5c930c26141c99c72febf47e0d1b22e8729ca1e3", "size": 455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/type_analysis/sections/5_evaluation_metrics/1_distance.tex", "max_stars_repo_name": "decomp/doc", "max_stars_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-05-27T10:16:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-16T08:14:04.000Z", "max_issues_repo_path": "report/type_analysis/sections/5_evaluation_metrics/1_distance.tex", "max_issues_repo_name": "decomp/doc", "max_issues_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 48, "max_issues_repo_issues_event_min_datetime": "2019-01-30T19:08:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-29T19:17:53.000Z", "max_forks_repo_path": "report/type_analysis/sections/5_evaluation_metrics/1_distance.tex", "max_forks_repo_name": "decomp/doc", "max_forks_repo_head_hexsha": "fb82b6a5074aa8721afb24a5537bf1964ed20467", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-25T21:15:26.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-09T07:36:14.000Z", "avg_line_length": 75.8333333333, "max_line_length": 349, "alphanum_fraction": 0.6747252747, "num_tokens": 91, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.40394817831044255}}
{"text": "\\documentclass[a4paper, fontsize=9pt, twocolumn]{scrreprt}\n\n\\setlength{\\paperheight}{297mm}\n\\setlength{\\paperwidth}{210mm}\n\\setlength{\\textheight}{252mm}\n\\setlength{\\textwidth}{172mm}\n\\setlength{\\columnsep}{8mm}\n\\setlength{\\headheight}{0mm}\n\\setlength{\\voffset}{-12mm}\n\\setlength{\\hoffset}{0mm}\n\\setlength{\\marginparwidth}{0mm}\n\\setlength{\\parindent}{1pc}\n\\setlength{\\topmargin}{-5mm}\n\\setlength{\\oddsidemargin}{-6mm}\n\\setlength{\\evensidemargin}{-6mm}\n\n\n\\usepackage[utf8]{inputenc}\n\\usepackage[sc]{mathpazo}\n\\linespread{1.05}\n\\usepackage{helvet}\n\\usepackage{fullpage}\n\n\\usepackage{amsmath,amsthm,amssymb}\n\\usepackage[shortlabel]{enumitem}\n\\usepackage{nicefrac}\n\\usepackage{upgreek}\n\\usepackage{graphicx}\n\\graphicspath{{figs/figS02/}}\n\n\n\n\\newcommand{\\vect}[1]{\\mathrm{\\mathbf{#1}}}\n\\newcommand{\\R}{\\mathbb R}\n\\newcommand{\\E}{\\mathbb E}\n\n\\newcommand{\\vx}{\\vect x}\n\\newcommand{\\vr}{\\vect r}\n\\newcommand{\\vu}{\\vect u}\n\\newcommand{\\vv}{\\vect v}\n\\newcommand{\\vS}{\\vect S}\n\\newcommand{\\vX}{\\vect X}\n\\newcommand{\\vC}{\\vect C}\n\\newcommand{\\vR}{\\vect R}\n\\newcommand{\\vW}{\\vect W}\n\\newcommand{\\vomega}{\\boldsymbol{\\upomega}}\n\\newcommand{\\Real}{\\text{Re}}\n\n\\newcommand{\\hvx}{\\hat \\vx}\n\\newcommand{\\hvX}{\\hat \\vX}\n\n\\DeclareMathOperator{\\proj}{proj}\n\\DeclareMathOperator{\\Cov}{Cov}\n\n\\usepackage[]{xcolor}\n\\newcommand{\\todo}[1]{{\\color{red}\\textbf{To do:} #1}}\n\n\\usepackage[backend=biber,style=apa,isbn=false,url=false]{biblatex}\n\\addbibresource{bibliography.bib}\n\\renewcommand*{\\bibfont}{\\footnotesize}\n\\setlength\\bibitemsep{0em}\n\n\\renewcommand*{\\thechapter}{S\\arabic{chapter}}\n\n\\title{%\n    Cosine Contours\\\\%\n    A multipurpose representation \\\\ for melodies\\\\[2em]%\n    \\textsc{supplementary materials}\n}\n\\author{Bas Cornelissen, Willem Zuidema \\& John Ashley Burgoyne}\n\\date{}\n\n\\begin{document}\n\n\\maketitle\n\\newpage\n\n\\pagebreak\n\n\n\n%=============================\n\\chapter{Random walk baseline}\n%=============================\n\n\n\n\\hspace{-2em}\n\\includegraphics[width=.5\\textwidth]{figs/figS01a.pdf}\n\n\\noindent\nWe compared the principal components of phrases to a random walk baseline that was intended to be fairly similar to actual phrase contours.\nFirst, we draw the length (number of notes) $K$ of the random walk from a Poisson distribution with mean $\\lambda=12$ (truncated below 3). The value $12$ was chosen so as to approximate the length distribution of phrases. \nThen we draw an initial pitch $x_0$ uniformly between 60 and 85 (in MIDI pitch space).\nNext, at every step $k$ we draw the size of a step $r_k$ (the interval) from a Binomial distribution with parameters $n=10$ and $p=0.5$, shifted to have mean 0, and let the next pitch be $x_k = x_{k-1}+r_k$.\nWe constrain the step sizes to lie between $-12$ and $+12$, meaning that jumps cannot exceed an octave.\nThis results in small, approximately normally distributed step sizes.\nThis process yields a sequence of pitches $x_0, \\dots, x_{K-1}$.\nAs usual, we interpolate a step function through these pitches and sample $N=100$ equally spaced pitches to obtain a random contour.\nIn the figure above we use $N=50$ for readability.\n\\vfill\\pagebreak\n\n\\hspace{-2em}\n\\includegraphics[width=.5\\textwidth]{figs/figS01b.pdf}\n\n\\noindent\nHere we vary the average length $\\lambda$ of the random walk baseline.\nThis affects the number of notes $K$, but we still have $N=100$ throughout.\nWe generate 10,000 random contours, and compute the covariance matrices (A).\nThe longer the melodies (larger $K$), the more the covariance matrix starts to resemble a Toeplitz matrix, which has constant values along each of its diagonals.\nAs an ad-hoc measure of \\emph{Toeplitzness}, we measure how much every entry of the covariance matrix differs from the mean value on that diagonal. \nFor a Toeplitz matrix, that should be zero everywhere: all diagonals are constant, so every entry also equals the mean of that diagonal.\nColumn (B) makes clear that the covariance matrix differs from a Toeplitz matrix mostly in the upper left corner, which contains the covariance in the first timesteps. \nAll this is also reflected in the principal components (C).\n\n\n\n%===================================\n\\chapter{Analyses of other datasets}\n%===================================\n\n\n\nIn this section we visualize the principal components of melodic material from motifs to songs in different traditions.\nFor every dataset we show:\n\\begin{enumerate}[label={\\textbf{\\textsc{\\alph*.}}}]\n    \\item The first four principal components. The first one is usually a flat line (gray), the second a descending shape (blue), the third a convex shape (orange), and the fourth one undulating (green).\n    The corresponding cosines are shown as thin dashed lines in the same colors.\n    \\item The length distribution of the melodic material, where length is measured in quarter notes. For Gregorian chant we assume all notes are quarter notes.\n    \\item The covariance matrix.\n    \\item A scatterplot showing the representations of 2000 contours in 2d cosine contour space.\n    \\item The reconstruction error using the discrete cosine transform compared to a principal component analysis.\n\\end{enumerate}\nIt is clear that the cosine approximation is most accurate at the phrase level. \nFor very short melodic fragments (such as neumes or syllables), you see clear effects of the typical number of notes.\nFor example, neumes often have only 2 notes, meaning there is a jump in the middle of the contour. You can see this in the principal components, but also in the covariance matrix.\nSuch effects are weaker, but sometimes still visible at the phrase level: German folksongs apparently often have durations of 8 quarter notes, with jumps in the middle, or after 2 of 6 quarter notes.\nFor complete songs, finally, the principal components are often difficult to interpret.\nOnly for a very large number of songs (such as when combining all chants in GregoBase) does a pattern reminiscent of the cosines emerge.\nBut for very small datasets, such as those in the Densmore collection, the principal components are very irregular. \n\n\n\\vfill\n\\pagebreak\n\n\\newcommand{\\showdataset}[2]{%\n    \\subsubsection*{#2}\n    \\includegraphics{#1}\n    \\par\n}\n\n\n%———————————————\n\\section{Motifs}\n%———————————————\n\n\nAll motifs come from Gregorian chant (responsories from  CantusCorpus).\n\\showdataset{motif-responsory-subset-neumes.pdf}{Neumes}\n\\showdataset{{motif-responsory-subset-syllables.pdf}}{Syllables}\n\\showdataset{{motif-responsory-subset-words.pdf}}{Words}\n\\pagebreak\n\n\n%————————————————\n\\section{Phrases}\n%————————————————\n\n\n\\showdataset{{phrase-erk-phrase-contours.pdf}}{German: Erk}\n\\showdataset{{phrase-han-phrase-contours.pdf}}{Chinese: Han}\n\\showdataset{{phrase-liber-antiphons-phrase-contours.pdf}}{Antiphons}\n\\pagebreak\n\n\n%————————————————————————\n\\section{Random segments}\n%————————————————————————\n\n\n\\showdataset{{phrase-erk-random-contours.pdf}}{German: Erk}\n\\showdataset{{phrase-han-random-contours.pdf}}{German: Han}\n\\showdataset{{phrase-liber-antiphons-random-contours.pdf}}{Antiphons}\n\\pagebreak\n\n\n%————————————————————————————\n\\section{Phrases (continued)}\n%————————————————————————————\n\n\n\\showdataset{{phrase-boehme-phrase-contours.pdf}}{German: Boehme}\n\\showdataset{{phrase-shanxi-phrase-contours.pdf}}{Chinese: Shanxi}\n\\showdataset{{phrase-liber-responsories-phrase-contours.pdf}}{Responsories}\n\\pagebreak\n\n\n%————————————————————————————————————\n\\section{Random segments (continued)}\n%————————————————————————————————————\n\n\n\\showdataset{{phrase-boehme-random-contours.pdf}}{German: Boehme}\n\\showdataset{{phrase-shanxi-random-contours.pdf}}{Chinese: Shanxi}\n\\showdataset{{phrase-liber-responsories-random-contours.pdf}}{Responsories}\n\\pagebreak\n\n\n%——————————————\n\\section{Songs}\n%——————————————\n\n\n\\showdataset{song-erk.pdf}{German: Erk}\n\\showdataset{song-han.pdf}{Chinese: Han}\n\\showdataset{song-gregobase.pdf}{All chants in GregoBase}\n\\vfill\\pagebreak\n\n\\section*{~}\n\\showdataset{song-boehme-altdeutsches-liederbuch.pdf}{German: Boehme}\n\\showdataset{song-shanxi.pdf}{Chinese: Shanxi}\n\\vfill\\pagebreak\n\n\n%——————————————————————————\n\\section{Songs (continued)}\n%——————————————————————————\n\n\n\\showdataset{song-densmore-teton-sioux.pdf}{Teton Sioux (Densmore)} \n\\showdataset{song-densmore-nootka.pdf}{Nootka (Densmore)}\n\\showdataset{song-densmore-papago.pdf}{Papago (Densmore)}\n\\showdataset{song-densmore-menominee.pdf}{Menominee (Densmore)}\n\n\n%================================\n\\chapter{Mathematical background}\n%================================\n\n\n\nIn this section we provide some more mathematical background to illustrate why we observe cosine-shaped principal components.\nThe aim is to make some of the key points a bit more accessible; we refer to \\textcite{Jolliffe2002} for a detailed discussion of principal component analysis, to \\textcite{Gray2006} for a rigorous treatment of Toeplitz matrices and their limiting behaviour, and to \\textcite{Rao1990} for the discrete cosine transform.\n\n\n\\paragraph{Notation}\n%-------------------\n\nWe write $N$ for the length of a contour, or the number of steps in a random walk, and $M$ denotes the number of contours.\nConsider a dataset $\\{\\vx_1, \\dots, \\vx_M\\}$ of points $\\vx_m = (x_{m1}, \\dots, x_{MN})$ in $\\R^N$.\nWe denote the sample mean by $\\bar \\vx$ and the centered data points by $\\hat \\vx_m$:\n\\begin{align}\n    \\bar \\vx = \\frac{1}{M} \\sum_{m=1}^M \\vx_m\n    \\qquad \\text{and} \\qquad\n    \\hat \\vx_m= \\vx_m - \\bar \\vx,\n\\end{align}\nand both of course live in $\\R^N$. \nAn $M \\times N$ matrix $\\vX$ has entries $(\\vX)_{m, n} = x_{mn}$, and for $N\\times N$ matrices we generally index rows by $n$ and columns by $k$.\n\n\n%—————————————————————————————\n\\section{Principal components}\n%—————————————————————————————\n\n\n\\paragraph{Maximize projected variance}\n%--------------------------------------\n\nThe goal of a principal component analysis is to find a subspace of lower dimensionality $D < N$ that maximizes the variance of the data when it is projected on this subspace.\nFirst, we project the data on a one-dimensional subspace spanned by the unit vector $\\vu_1 \\in \\R^N$.\nYou can think of the projection of $\\vx_n$ as a point in the $N$-dimensional ambient space, but we rather treat it as the scalar $\\vu_1^T \\vx_n$: the coordinate in the one-dimensional subspace. \nThe projected data then has mean $\\vu_1^T\\bar \\vx$ and variance \n\\begin{align}\n    \\frac{1}{M} \\sum_{m=1}^M \\bigl( \\vu_1^T \\vx_m - \\vu_1^T \\bar\\vx \\bigr)^2\n    =\\vu_1^T \\vS \\vu_1,\n\\end{align}\nwhere $\\vS$ is the $N\\times n$ covariance matrix given by\n\\begin{align}\n    \\vS \n        = \\frac{1}{M} \\sum_{m=1}^M \\vx_m - \\bar\\vx)(\\vx_m - \\bar\\vx)^T\n\\end{align}\nWe want to choose $\\vu_1$ in such a way that it maximizes the projected variance $\\vu_1^T\\vS\\vu_1$. \nIt can be shown, using a Lagrange multiplier, that under the constraint $\\|\\vu_1\\| = 1$, the projected variance is maximized when\n\\begin{align}\n    \\label{eq:pca-eigen-vector}\n    \\vS \\vu_1 = \\lambda_1 \\vu_1\n\\end{align}\n\\parencite[see e.g.~]{Jolliffe2002}.\nLeft-multiplying by $\\vu_1^T$, and using that $\\vu_1^T \\vu_1 = 1$, this is the case when\n\\begin{align}\n    \\label{eq:pca-variance}\n    \\vu_1^T \\vS \\vu_1 = \\lambda_1.\n\\end{align}\nEquation \\eqref{eq:pca-eigen-vector} shows that $\\vu_1$ must be an eigenvector of the covariance matrix $\\vS$ corresponding to eigenvalue $\\lambda_1$, which is exactly the projected variance according to \\eqref{eq:pca-variance}.\n The first principal component, in short, is the eigenvector of the covariance matrix corresponding to the largest eigenvalue.\nThe argument can be extended inductively to identify all principal components as eigenvectors of the covariance matrix, ordered according to their eigenvalues.\n\n\n\\paragraph{Minimize reconstruction error}\n%----------------------------------------\n\nIt should be noted that one can also motivate principal components in another way.\nConsider a dataset $\\{x_m\\in \\R^N\\}_m$ as before, and a set of basis vectors $\\{\\vu_1, \\dots, v_N\\}$ for $\\R^N$ with norm 1.\nAs before, the projection of $\\vx$ on the $\\vu_n$ is $c_n = \\vu_n^T\\vx$, and so we can represent $\\vx$ as a coordinate vector $(c_0, \\dots, c_N)$.\nNow suppose we only use the first $D$ coordinates to represent $\\vx$, so we get the truncated representation:\n\\begin{align}\n    \\tilde\\vx = \\sum_{i=1}^D c_i \\vu_i.\n\\end{align}\nNow measure the \\emph{reconstruction error} as \n\\begin{align}\n    \\textsc{mse} = \\frac{1}{M}\\sum_{m=1}^M (\\vx - \\tilde \\vx)^2\n\\end{align}\nWe ask: how should we choose the basis vectors so that the reconstruction error \\textsc{mse} is minimized? \nThe answer is the same: as the eigenvectors, ranked in descending order \\parencite{Rao1990}.\n\n\n%————————————————————————————————————————\n\\section{Toeplitz and circulant matrices}\n%————————————————————————————————————————\n\n\n\\emph{Toeplitz matrices} are matrices were every diagonal has the same value. \nThey are usually indexed as follows:\n\\begin{align}\n    \\vect T = \n    \\begin{bmatrix}\n    t_0     & t_{-1}    & t_{-2}    &\\dots  & t_{-(N-1)}\\\\\n    t_1     & t_{0}     & t_{-1}    &       & \\\\\n    t_2     & t_1       &t_0        &       & \\vdots\\\\\n    \\vdots  &           &           &\\ddots & \\\\\n    t_{N-1} &           &           &\\dots  &t_0\n    \\end{bmatrix}\n\\end{align}\nThat means that $T_{i, j} = t_{j-i}$.\nBefore we discuss Toeplitz matrices further, let's focus on the special subset of circulant matrices.\nA \\emph{circulant matrix} is a Toeplitz matrix where every row equals the previous row, rotated one step to the right:\n\\begin{align}\n    \\vC = \n    \\begin{bmatrix}\n        c_0     & c_1   & c_2   & \\dots & c_{N-1} \\\\\n        c_{N-1} & c_0   & c_1   &       & c_{N-2} \\\\\n        c_{N-2} & c_{N-1} & c_0 & \\\\\n        \\vdots  &       & \\ddots      &&\\vdots\\\\\n        &&&c_0&c_1\\\\\n        c_1 &&\\dots &c_{N-1}&c_0\n    \\end{bmatrix}\n\\end{align}\nIt is convenient to start indexing at 0 rather than 1, so that we have $\\vC_{n, k} = c_{k-n \\mod N}$.\nWe read the subscripts periodically, so that e.g. $c_{N+3} = c_3$.\nFor circulant matrices, matrix multiplication takes the form of a \\emph{circular convolution}: if $\\vect y = \\vC \\vx$, we have\n\\begin{align}\n    \\label{eq:circular-matrix-multiplication}\n    y_n = \\sum_{k=0}^{N-1} c_{k-n} x_k.\n\\end{align}\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=.5\\textwidth]{figs/suppl-fig-roots-of-unity.pdf}\n    \\caption{The $N$-th roots of unity for $N=5$ are points on the complex unit circle.}\n    \\label{fig:roots-of-unity}\n\\end{figure}\n\n\n\\paragraph{Eigenvectors of circulant matrices}\n%---------------------------------------------\n\nSuprisingly, all circulant matrices have the same eigenvectors.\nThese eigenvectors consist of \\emph{($N$-th) roots of unity}: the complex numbers $z$ satisfying $z^N = 1$.\nThe first complex root of unity is\n\\begin{align}\n    \\omega = e^{\\frac{2\\pi i}{N}},\n\\end{align}\nand its powers $\\omega^k$ are other roots of unity, since $(\\omega^k)^N = (\\omega^N)^k = 1$. \nThe numbers $\\omega^0, \\dots, \\omega^{N-1}$ can be visualized as evenly spaced points on the unit circle in the complex plane (see figure \\ref{fig:roots-of-unity}).\nImportantly, these numbers (like the coefficients $c_k$) are periodical: $\\omega^{N+k} = \\omega^N \\cdot \\omega^k = \\omega^k$. \n\nThis property allows us to show that the $N$ eigenvectors of a circulant matrix are\n\\begin{align}\n    \\vomega_n = (\\omega^{n \\cdot 0}, \\dots, \\omega^{n\\cdot(N-1)}),\n ,\\end{align}\nfor $n=0, \\dots, N-1$.\nYou can verify this directly when $n=0$, since $\\vomega_0$ is then an an all-ones vector, but let's consider the general case.\nWe have to show that $\\vC \\vomega_n = \\lambda_n \\vomega_n$ for some constant $\\lambda_n$. \nUsing \\eqref{eq:circular-matrix-multiplication}, we can show that $k$'the entry of the left hand side indeed equals $\\lambda_n \\omega^{nk}$:\n\\begin{align}\n    (\\vC \\vomega_n)_k \n        &= \\sum_{j=0}^{N-1} c_{j-k} \\cdot \\omega^{n \\cdot j} \\\\\n        &= \\omega^{nk} \\cdot \\sum_{j=0}^{N-1} c_{j-k}  \\cdot \\omega^{n(j-k)} \\\\\n        &= \\omega^{nk} \\cdot \\underbrace{\n            \\sum_{j'=0}^{N-1} c_{j'}  \\cdot \\omega^{n\\cdot j'}\n        }_{\\lambda_n}.\n\\end{align}\nHere we first multiplied by $\\omega^{-nk}/\\omega^{-nk}$ to align the indices of the coefficients and the powers. \nThen we used the periodicity of the roots of unity to reorder the sum,\nso it no longer depends on $k$ and must equal the eigenvalue $\\lambda_n$.\nThe general case is similar.\n\n\nSummarizing, every $N\\times N$ circulant matrix $\\vC$ has the same $N$ eigenvectors $\\vomega_0, \\dots, \\vomega_n$, with (different) corresponding eigenvalues:\n\\begin{align}\n    \\label{eq:eigen-pair-circulant-matrix}\n    \\lambda_n \n        &= c_0 \\omega^0 + c_1 \\omega^{n} \\dots c_{N-1} \\omega^{n(N-1)} \\\\\n        &=\n        \\sum_{j=0}^{N-1} c_j e^{\\frac{2\\pi i \\cdot nj}{N}},\n\\end{align}\nfor $n=0, \\dots, N-1$.\nFrom the second expression one sees that the eigenvalues $(\\lambda_0, \\dots, \\lambda_{N-1})$ are the discrete Fourier transform of $(c_0, \\dots, c_{N-1})$.\n\n\n\\paragraph{Real circulant matrices}\n%----------------------------------\n\nIn the scenario we are interested in, the matrix $\\vC$ is real and symmetric, and such matrices have real eigenvalues and eigenvectors.\nTo see that the eigenvalues are real, first note that a symmetric circulant matrix satisfies the additional constraint $c_k = c_{N-k}$.\nAlso observe that $\\omega^k$ and $\\omega^{N-k} = \\omega^{-k}$ are each others mirror image in the real axis (see figure \\ref{fig:roots-of-unity}).\nThey have the same real part,\n\\begin{equation}\n    \\label{eq:real-part-root-of-unity}\n    \\Real(\\omega^k) = \\cos\\Bigl( \\frac{2\\pi k}{N}\\Bigr),\n\\end{equation}\nand when adding them, the complex part cancels out: $\\omega^k + \\omega^{-k}$ lies on the real axis, at the point $2 \\Real(\\omega^k)$.\nThis means that\n\\begin{align}\n    \\label{eq:sum-symmetric-circulant}\n    c_k \\omega^k + c_{N-k} \\omega^{N-k}\n        = 2c_k \\Real(\\omega^k)\n\\end{align}\nis a real number.\nFrom \\eqref{eq:eigen-pair-circulant-matrix} we see that the eigenvalues $\\lambda_n$ consist of many such sums: all complex parts cancel out and the eigenvalues are real\\footnote{The expression for the eigenvalues is slightly different depending on whether $N$ is odd or even.}\n\n\nNow we can also choose real eigenvectors: the real part of $\\vomega_n$. \nAfter all, if $\\vomega_n$ is an eigenvector for the real eigenvalue $\\lambda_n$, so are $\\vomega_{-n}$ and $\\vv_n = \\nicefrac{1}{2}( \\vomega_n + \\vomega_{-n})$.\nBy the same argument as before, equations \\eqref{eq:sum-symmetric-circulant} and \\eqref{eq:real-part-root-of-unity} show that this is a real eigenvector:\n\\begin{align}\n    \\vv_n = \\Bigl(1, \\; \\cos \\theta, \\; \\dots, \\; \\cos N\\theta\\Bigr), \n    \\quad \\theta = \\frac{2\\pi n}{N}.\n\\end{align}\nThis is a discrete cosine function consisting of $N$ points, where higher $n$ implies in higher frequencies.\nThis is illustrated in figure \\ref{fig:eigenvectors-symmetric-circulant}.\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=.5\\textwidth]{figs/suppl-fig-cosines.pdf}\n    \\caption{The eigenvectors of a symmetric, circulant matrix are discrete cosine functions with different periods.}\n    \\label{fig:eigenvectors-symmetric-circulant}\n\\end{figure}\n\n\n\\paragraph{Toeplitz is asymptotically circulant}\n%-----------------------------------------------\n\nThe reason circulant matrices are interesting here, is that\nToeplitz matrices can be shown to be asymptotically equivalent to circulant matrices, and that eigenvalues are preserved.\nWe refer to \\textcite{Gray2006} for a detailed discussion of that result.\nWhat this implies is that the eigenvectors of large Toeplitz matrices are well approximated by those of circulant matrices: sinusoidal functions.\nThat in turn means that approximately Toeplitz covariance matrices (which are real and symmetric) will have cosine-shaped eigenvectors. \n\n\n%————————————————————————————————\n\\section{PCs of random processes}\n%————————————————————————————————\n\n\nWe want to end by discussing two examples where Toeplitz covariance structures arise, and we thus would expect cosine eigenvectors, at least asymptotically.\n\n\n\\begin{figure}\n    \\centering\n    \\includegraphics[width=.5\\textwidth]{figs/suppl-fig-ar1.pdf}\n    \\caption{The autocovariance matrix for an autoregressive process \\textsc{ar}(1) for two values of $\\rho$. When $\\rho\\to 1$ it approximates the discrete cosine transform.}\n    \\label{fig:ar1}\n\\end{figure}\n\n\n\\paragraph{Weakly stationary process}\n%------------------------------------\n\nToeplitz matrices arise naturally in the study of weakly stationary processes.\nThese are random processes where the mean is constant over time, and where the covariance does not change by shifts in time: it only depends on the distance between two time steps.\nThat is, when $\\Cov(x_i, x_j) = K(j-i)$ is some function of $j-i$, and thus results in a Toeplitz covariance matrix.\n\nOne example of such a process is a first order autoregressive process \\textsc{ar}(1), where\n\\begin{align}\n    x_n = \\rho x_{n-1} + r_n,\n\\end{align}\nwhere $r_n$ is a random step with mean zero and variance $\\sigma^2$, and we assume $x_0 = 0$.\nIt can be shown that this process has mean $E[x_n] = 0$ and variance $\\text{Var}[x_t] = \\nicefrac{1}{1-\\rho^2}$ if $|\\rho| < 1$.\nIn that case, the covariance is\n\\begin{align}\n    \\Cov(x_i, x_j) = \\frac{\\sigma^2}{1-\\rho^2} \\cdot \\rho^{|j-i|}.\n\\end{align}\nThis is actually one of the few cases where an analytic expression for the eigenvectors is known, although it is rather complex \\parencite{Ray1970,Rao1990}.\nInterestingly, one can use this to show that for \\textsc{ar}(1) processes, the discrete cosine transform \\textsc{dct-ii} becomes equivalent to the `principal component transform' (Karhunen-Loève transform) as $\\rho\\to 1$ \\parencite[section~3.3.2]{Rao1990}.\n\n\n\\paragraph{High-dimensional random walk}\n%---------------------------------------\n\nIn the limit $\\rho \\to 1$ one obtains a random walk. \n\\textcite{Antognini2018} analyse the principal components of high-dimensional random walks. \nWe briefly summarise their results.\nConsider a random walk in $\\R^M$ with $N$ steps given by \n\\begin{equation}\n    \\vx_n = \\vx_{n-1} + \\vr_n\n    \\label{eq:random-walk}\n\\end{equation}\nwhere $\\vr_n$ is a random step drawn from a probability distribution with zero mean and a finite, normalized covariance matrix.\nWe start from $\\vx_0 = \\mathbf{0}$ in $\\R^M$.\n\n\nWe can express all this as matrix multiplications.\nCollect the points $\\vx_n$ and steps $\\vr_n$ as the rows of the $N \\times M$ matrices $\\vX$ and $\\vR$ respectively.\nLet $\\vW$ be a $N\\times N$ matrix with $1$'s on the diagonal, $-1$'s on the subdiagonal and zeros elsewhere.\nThis implements the walking mechanism in the sense that $\\vW \\vX = \\vR$, hence\n\\begin{align}\n    \\label{eq:random-walk-matrix}\n    \\vX = \\vW^{-1} \\vR.\n\\end{align}\nTo compute the covariance matrix $\\vS$ we need the centered datapoints $\\hat\\vx_n = \\vx_n - \\bar \\vx_n$.\nThe centering operation be conveniently expressed as multiplication by the $N \\times N$ \\emph{centering matrix} $\\vect C = \\vect I - \\frac{1}{M} \\vect J$, where  $\\mathbf{J}$ is the all-ones matrix.\nThis gives \n\\begin{align}\n    \\label{eq:hat-X}\n    \\hat \\vX = \\vC \\vX = \\vC \\vW^{-1} \\vR\n\\end{align}\nand allows us to express the covariance matrix as $\\vS = \\frac{1}{N} \\hat \\vX^T \\hat \\vX$.\nInstead of finding the eigenvectors of $\\hat \\vX^T\\hat \\vX$, we can look for those of $\\hat \\vX\\hat \\vX^T$. \nAfter all, if $\\vu$ is an eigenvector for $\\hat \\vX^T \\hat \\vX$ with nonzero eigenvalue $\\lambda$, then $\\vect v = \\hat\\vX \\vu$ is the corresponding eigenvector for $\\hat \\vX \\hat\\vX^T$.\n\n\nPutting all this together, \\textcite{Antognini2018} look for the eigenvalues and eigenvectors of \n\\begin{align}\n    \\label{eq:target}\n    \\hat \\vX \\hat \\vX^T\n        = \\vC \\vW^{-1} \\vR \\vR^{T} \\vW^{-T} \\vC  \n\\end{align}\nwhere we used symmetry of $\\vC$.\nNote that this matrix contains the covariance between timesteps, rather than dimensions.\nThey observe that in the limit of infinte dimensionality $M \\to \\infty$, we have that $\\vR\\vR^T$ tends to the $N\\times N$ identity matrix.\nThis allows us to simplify \\eqref{eq:target} to\n\\begin{align}\n    \\label{eq:target-simple}\n    \\hat \\vX \\hat \\vX^T\n        = \\vC \\vW^{-1} \\vW^{-T} \\vC.\n\\end{align}\nSince $\\vW$ is a so called banded Toeplitz matrix, and $\\vC$ is circulant, the whole expression can be shown to be asymptotically equivalent to a circulant matrix, meaning that the eigenvectors are cosines.\nThis analysis can be related to melodic contours, when we consider a collection of $M$ contours of length $N$ as one high-dimensional walk through $\\R^M$.\n\n\n%—————————————————\n\\printbibliography\n%—————————————————\n\n\n\\end{document}", "meta": {"hexsha": "ca0ab5a86443b66cd6d0774e2762396735311654", "size": 24587, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documents/supplements/supplements.tex", "max_stars_repo_name": "bacor/cosine-contours", "max_stars_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-09-07T15:23:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-09T10:13:29.000Z", "max_issues_repo_path": "documents/supplements/supplements.tex", "max_issues_repo_name": "bacor/cosine-contours", "max_issues_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "documents/supplements/supplements.tex", "max_forks_repo_name": "bacor/cosine-contours", "max_forks_repo_head_hexsha": "3de6ea489182bf8bbf58e0d3c4abc7b568878475", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9838998211, "max_line_length": 319, "alphanum_fraction": 0.6891446699, "num_tokens": 7232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4039481707489886}}
{"text": "\\documentclass[serif,xcolor=pdftex,dvipsnames,table,hyperref={bookmarks=false,breaklinks}]{beamer}\r\n\r\n\\input{../config.tex}\r\n\r\n\\settitlecard{9}{Sparse Matrices and Probability 1}\r\n\r\n\\begin{document}\r\n\r\n\\maketitlepage\r\n\r\n\\section{Sparse Matrices}\r\n\\subsection{Foo}\r\n\r\n\\begin{frame}[t]{Sparsity}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item A \\textbf{sparse matrix} is an matrix in which most of the entries are zero. \r\n\t\t\\item This is in contrast to a \\textbf{dense matrix}.\r\n\t\t\\item Sparse matrices naturally appear in many applications:\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item Network adjacency matrices are typically very sparse. For example, you are only Facebook friends with a small percentage of the total Facebook population.\r\n\t\t\t\\item In recommender systems, ratings are often arranged as a sparse matrix. \r\n\t\t\t\\item In NLP, the matrix of word counts in a set of documents is typically sparse.\r\n\t\t\t\\item Multiple parallel event sequences can be arranged as a matrix. If the events are uncommon, then the matrix is sparse.\r\n\t\t\\end{itemize}\r\n\t\t\\item If we know an matrix is sparse, we can take advantage of this structure to speed up computations on the matrix.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Sparsity}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Consider taking the inner product of two length $n$ vectors, $x$ and $y$.\r\n\t\t\\item In general, how many multiplications must we perform?\r\n\t\t\\item What if we know that only 10\\% of the entries in $x$ are non-zero and we know where the are, how many multiplications do we need to perform?\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Sparse Representations}\r\n\tThere are two main strategies for storing sparse matrices:\r\n\t\\begin{enumerate}[<+->]\r\n\t\t\\item Formats that support \\textbf{efficient modifications} include Dictionary of Keys (DOK), List of Lists (LIL), and Coordinate list (COO) formats.\r\n\t\t\\item Formats that support \\textbf{efficient access and operations} include Compressed Sparse Row (CSR) and Compressed Sparse Column (CSC) formats.\r\n\t\\end{enumerate}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Dictionary of Keys Format}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item The DOK format is perhaps the simplest of the formats for efficient modification. \r\n\t\t\\item The DOK format stores the matrix as a dictionary with row/column tuples as keys and one key/value pair per non-zero entry.\r\n\t\t\\item Adding or removing an entry can be done in constant time. \r\n\t\t\\item What is the complexity of row or column slicing?\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t,fragile]{Compressed Sparse Row Format}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item The CSR format stores an $m \\times n$ matrix as three one dimensional arrays \\verb|indices|, \\verb|indptr|, and \\verb|data|.\r\n\t\t\\begin{enumerate}[<+->]\r\n\t\t\t\\item The \\verb|data| array stores the non-zero entries of the matrix in a left-to-right top-to-bottom order (row major order).\r\n\t\t\t\\item The \\verb|indices| array has the same length as the \\verb|data| array and stores the column of each entry.\r\n\t\t\t\\item The \\verb|indptr| array is a length $m$ array. \\verb|indptr[i]| stores the index in \\verb|data| and \\verb|indices| of the first non-zero entry in the $i$th row.\r\n\t\t\\end{enumerate}\r\n\t\t\\item The CSC format is the same as CSR, but \\verb|data| is stored in column major order and \\verb|indices| stores the row of each entry.\r\n\t\\end{itemize}\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Compressed Sparse Row Format: Example}\r\n\t\\centering\r\n\t\\includegraphics[width=\\textwidth]{{../Figures/array_slicing/Slide32}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Compressed Sparse Row Format: Example}\r\n\t\\centering\r\n\t\\includegraphics[width=\\textwidth]{{../Figures/array_slicing/Slide33}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Compressed Sparse Row Format: Example}\r\n\t\\centering\r\n\t\\includegraphics[width=\\textwidth]{{../Figures/array_slicing/Slide34}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Compressed Sparse Row Format: Example}\r\n\t\\centering\r\n\t\\includegraphics[width=\\textwidth]{{../Figures/array_slicing/Slide35}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Compressed Sparse Row Format: Example}\r\n\t\\centering\r\n\t\\includegraphics[width=\\textwidth]{{../Figures/array_slicing/Slide35}.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t,fragile]{Scipy Sparse Matrices}\r\n\tThe module \\verb|scipy.sparse| implements each of these sparse formats.\r\n\t\r\n\t\\begin{lstlisting}\r\n\t\t>>> import scipy.sparse as sps\r\n\t\t>>> import numpy as np\r\n\t\t\r\n\t\t>>> A = np.eye(5)\r\n\t\t>>> identity = np.eye(5)\r\n\t\t>>> sparse_identity = sps.csr_matrix(identity)\r\n\t\t\r\n\t\t>>> sparse_identity.indptr\r\n\t\tarray([0, 1, 2, 3, 4, 5], dtype=int32)\r\n\t\t>>> sparse_identity.indices\r\n\t\tarray([0, 1, 2, 3, 4], dtype=int32)\r\n\t\t>>> sparse_identity.data\r\n\t\tarray([ 1.,  1.,  1.,  1.,  1.])\r\n\t\\end{lstlisting}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t,fragile]{Interactive Demo}\r\n\t\\begin{itemize}\r\n\t\t\\item What linear algebra operations are most sped up by using sparse matrices?\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\section{Probability in Python}\r\n\\subsection{Foo}\r\n\r\n\\begin{frame}[t]{Random Variables}\r\n\t% PDF, PMF, CDF\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Probability and statistics play a central role in data analysis, modeling, and numerical algorithms. \r\n\t\t\\item But first, a quick review.\r\n\t\\end{itemize}\r\n\t\r\n\t\\pause\r\n\t\\begin{block}{Random Variables}\r\n\t\tA random variable, $X$, is a quantity that can take any value from a set of possible values, $\\Omega$, according to a set of probabilities.\r\n\t\\end{block}\r\n\\end{frame}\r\n\t\r\n\\begin{frame}[t]{Random Variables}\r\n\tFor example: Imagine we are flipping a coin. \r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item What is the random variable?\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item The random variable is the outcome of the coin flip.\r\n\t\t\\end{itemize}\r\n\t\t\\item What is the set of possible outcomes?\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item $\\Omega = \\{H,T\\}$\r\n\t\t\\end{itemize}\r\n\t\\end{itemize}\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Discrete Random Variables}\r\n\t% PDF, PMF, CDF\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item A discrete random variable may take its value from a finite or countably infinite set.\r\n\t\t\\item Examples include:\r\n\t\t% Support as a question\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item The outcome of a coin flip can take one of two possible values.\r\n\t\t\t\\item A randomly dealt five card poker hand can take one of $\\approx$2.6 possible million values.\r\n\t\t\t\\item The number of people who log in to Netflix between 1pm and 2pm can be any non-negative integer.\r\n\t\t\t\\item The end of season goal differential for a soccer team can be any integer (positive or negative).\r\n\t\t\\end{itemize}\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Mass Functions}\r\n\t% PDF, PMF, CDF\r\n\tThe probability of each possible outcome is defined by a Probability Mass Function.\r\n\t\r\n\t\\begin{block}{Probability Mass Function}\r\n\t\tFor a discrete random variable $X$ with support $\\Omega$, a Probability Mass Function (PMF) $P:\\Omega\\to [0,1]$ maps possible outcomes to probabilities. A PMF must satisfy two conditions:\r\n\t\t\\begin{enumerate}[<+->]\r\n\t\t\t\\item Probability of any single outcome must be between zero and one (i.e. $P(x) \\in [0,1]$ for all $x \\in \\Omega$).\r\n\t\t\t\\item The probabilities of all possible outcomes must sum to one (i.e. $\\sum_x P(x) = 1$).\r\n\t\t\\end{enumerate}\r\n\t\\end{block}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Mass Functions: Examples}\r\n\t% PDF, PMF, CDF\r\n\tLet $X$ represent the outcome of a six sided dice roll.\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item The set of possible outcomes is $\\Omega = \\{1,2,3,4,5,6\\}$.\r\n\t\t\\item Assuming the dice is fair, then the PMF may look like:\r\n\t\\end{itemize}\r\n\t\\pause\r\n\t% Dice PMF\r\n\t\\centering\r\n\t\\includegraphics[height=2in]{../Figures/uniform_multinomial.pdf}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Mass Functions: Examples}\r\n\t% PDF, PMF, CDF\r\n\tLet $X$ represent the the number of people entering a certain bank between 1pm and 2pm.\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item The set of possible outcomes is the set of all non-negative integers $\\Omega = \\mathbb{Z}_{\\geq 0}$.\r\n\t\t\\item This random variable is a canonical example of a Poisson distributed random variable which has the following PMF:\r\n\t\\end{itemize}\r\n\t\\pause\r\n\t% Poisson PfMF\r\n\t\\centering\r\n\t\\includegraphics[height=1.5in]{../Figures/Poisson_pmf.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Parametric Distributions}\r\n\tThe Poisson distribution is an example of a \\textbf{parametric distribution}, that is, it requires a set of parameter values to fully specify the distribution.\r\n\t\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tf(X=x; \\lambda) = \\frac{\\lambda^x e^{-\\lambda}}{x!},\\, \\lambda > 0\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item In this case the, the distribution has a single parameter $\\lambda$ that must be a positive real number. \r\n\t\t\\item Much of statistics is concerned with inferring these parameters from data.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Continuous Random Variables}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item A continuous random variable takes its value from an uncountably infinite set such as the set of real numbers. \r\n\t\t\\item Examples include:\r\n\t\t\\begin{itemize}[<+->]\r\n\t\t\t\\item The height of a randomly selected person.\r\n\t\t\t\\item Income of a randomly selected household.\r\n\t\t\t\\item The amount of time between hard drive failures in a server.\r\n\t\t\\end{itemize}\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Density Functions}\r\n\tThe distribution over possible values of a continuous random variable is given by a \\textbf{probability density function}.\r\n\t\\begin{block}{Probability Density Function}\r\n\t\tFor a continuous random variable $X$, the probability density function (PDF) $P(x)$ describes the relative likelihood of a continuous random variable taking a given value. A PDF must satisfy the following two conditions:\r\n\t\t\\begin{enumerate}[<+->]\r\n\t\t\t\\item All values must be non-negative. That is, $P(x) \\geq 0$ for all $x \\in \\Omega$.\r\n\t\t\t\\item The area under the PDF must equal one. That is, $\\int_x P(x) dx = 1$.\r\n\t\t\\end{enumerate}\r\n\t\t\\pause\r\n\t\tThe probability of $X$ falling between $a$ and $b$ is given by the integral:\r\n\t\t$$P(a < x < b) = \\int_x p(x) dx$$\r\n\t\\end{block}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Density Functions: Examples}\r\n\t\\begin{itemize}\r\n\t\t\\item Given some range $[a,b]$, the \\textbf{uniform distribution} places equal likelihood on all values in the range.\r\n\t\\end{itemize}\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tp(x;a,b) = \\frac{1}{b - a}\r\n\t\\end{align*}\r\n\t% uniform plot\r\n\t\\centering\r\n\t\\includegraphics[height=1.5in]{../Figures/Uniform_Distribution_PDF_SVG.png}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Probability Density Functions: Examples}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Perhaps the most common distribution in statistics is the \\textbf{Normal} distribution.\r\n\t\t\\item The Normal distribution takes two parameters: a mean parameter $\\mu$ and a variance parameter $\\sigma^2$.\r\n\t\\end{itemize}\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tp(x;\\mu,\\sigma) = \\frac{1}{\\sqrt{2\\pi\\sigma^2}}\\exp\\left(-\\frac{(x-\\mu)^2}{2\\sigma^2}\\right)\r\n\t\\end{align*}\r\n\t% Normal plot\r\n\t\\centering\r\n\t\\includegraphics[height=1.5in]{../Figures/Normal_Distribution_PDF.png}\r\n\\end{frame}\r\n\r\n% \\begin{frame}[t]{Cumulative Mass Function}\r\n% \t\\begin{block}{Cumulative Mass Function}\r\n% \t\tA Cumulative Mass Function (CMF) is\r\n% \t\\end{block}\r\n% \\end{frame}\r\n\r\n\\begin{frame}[t]{Evaluating PMFs, PDFs, and CMFs}\r\n\tThe most fundamental computation necessary when working with probability distributions is evaluating the distribution at different values. This computation can be difficult or costly for a number of reasons:\r\n\t\\pause\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item The PDF, PMF, or CMF involves a difficult to compute special function.\r\n\t\t\\item Normalizing the distribution (ensuring the PDF/PMF integrates to 1) requires a difficult to compute sum or integral.\r\n\t\t\\item Probabilities near zero or near one can cause numerical errors.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Calculating PDFs: The Gamma Function}\r\n\tEvaluating PDFs and PMFs, even common ones, often requires evaluating difficult to compute special functions. A particularly common function for continuous distributions is the Gamma function.\r\n\r\n\t\\pause\r\n\t\\begin{block}{Gamma Function}\r\n\t\tThe gamma function is defined as\r\n\t\t$$\\Gamma(t) = \\int_0^\\infty x^{t-1}e^{-x}dx$$\r\n\t\\end{block}\r\n\r\n\t\\pause\r\n\tThe Gamma function and related Incomplete Gamma and Incomplete Beta functions are necessary/useful for working with the following common distributions (among others).\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Gamma, $Z$, $t$, $\\chi^2$, $F$, binomial, Poisson\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Calculating PDFs: The Gamma Function}\r\n\tAlgorithms for computing the Gamma function have been heavily studied. The most commonly used algorithm is uses the Lanczos approximation.\r\n\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\t\\Gamma(z+1) &= \\sqrt{2\\pi}\\left(z + g + \\frac{1}{2}\\right)^{z+1/2}e^{-(z+g+1/2)}A_g(z)\\\\\r\n\t\tA_g(z) &= c_0 + \\frac{c_1}{z+1} + \\frac{c_2}{z+2} + \\frac{c_3}{z+3} + ... \\\\\r\n\t\\end{align*}\r\n\r\n\t\\pause\r\n\tImportantly, the user can choose $g$ and pre-calculate the constants $c_i$.\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Calculating PMFs: Using Recursion}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Often, when multiple values of a PMF are desired, we can take advantage of recurrence relations to avoid calculating costly special functions.\r\n\t\t\\item The binomial distribution is the distribution for the number of successes in a sequence of $n$ yes/no experiments (e.g. coin flips) with success probability $p$. The binomial PMF is,\r\n\t\\end{itemize}\r\n\t\\pause\r\n\t\\begin{align*}\r\n\t\tP(X = x; n, p) &= {{n}\\choose{x}}p^x(1-p)^{n-x}\r\n\t\\end{align*}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Calculating PMFs: Using Recursion}\r\n\tEvaluating the binomial PMF involves evaluating factorials (a special case of the Gamma function); however, if multiple values are desired, we can take advantage of the following recurrence relation:\r\n\r\n\t\\begin{align*}\r\n\t\tP(X=x) &= {{n}\\choose{x}}p^x(1-p)^{n-x}\\\\\r\n\t\t&= \\frac{n-x}{x+1}\\frac{p}{1-p}\\left[{{n}\\choose{x-1}}p^{x-1}(1-p)^{n-(x-1)}\\right]\\\\\r\n\t\t&= P(X=x-1)\\frac{n-x}{x+1}\\frac{p}{1-p}\r\n\t\\end{align*}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Calculating PMFs: Using Recursion}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Does utilizing this recursion improve the complexity or the constant?\r\n\t\t\\item The complexity of calculating the first $k$ values of the binomial PMF is $\\mathcal{O}(k)$ in both cases; however, we are replacing a special function with arithmetic operations only.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Working in log-space and the Log-Sum-Exp trick}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item As we discussed in a previous lecture, exponentiating even moderate values can result in numerical overflow or underflow.\r\n\t\t\\item Many distributions require exponentiation of intermediate values.\r\n\t\t\\item One common solution is to work in \\textbf{log-space}.\r\n\t\\end{itemize}\r\n\t\r\n\\end{frame}\r\n\r\n\r\n\\begin{frame}[t]{Working in log-space and the Log-Sum-Exp trick}\r\n\tThe multinomial distribution is the standard distribution for finite sets. Consider the following multinomial distribution over $K$ discrete values parameterized by a length $K$ vector of weights $\\alpha$.\r\n\t\r\n\t\\begin{align*}\r\n\t\tP(X=i; \\alpha) &= \\frac{e^{\\alpha_i}}{\\sum_i e^{\\alpha_i}},\\, i = 1,...,K\r\n\t\\end{align*}\r\n\t\r\n\t\\pause\r\n\tRather than evaluate this function directly, risking over/underflow, we can evaluate the log PMF,\r\n\t\r\n\t$$\\log P(X=i;\\alpha) = \\alpha_i - \\log \\sum_i e^{\\alpha_i}$$\r\n\t\r\n\t\\pause\r\n\tWhy does this not completely solve our problem?\r\n\t\r\n\\end{frame}\r\n\r\n\\begin{frame}[t]{Working in log-space and the Log-Sum-Exp trick}\r\n\tCalculating the second term $\\log \\sum_i e^{\\alpha_i}$ (also known as the cumulant function) still requires exponentiating $\\alpha$. Instead, let $\\alpha^* = \\max_i \\alpha_i$. Then, we can use the following trick,\r\n\t\r\n\t\\begin{align*}\r\n\t\t\\log \\sum_i e^{\\alpha_i} &= \\log \\frac{e^{\\alpha^*}}{e^{\\alpha^*}}\\sum_i e^{\\alpha_i}\\\\\r\n\t\t&= \\log \\sum_i e^{\\alpha_i-\\alpha^*} + \\log e^{\\alpha^*}\\\\\r\n\t\t&= \\log \\sum_i e^{\\alpha_i-\\alpha^*} + \\alpha^*\\\\\r\n\t\\end{align*}\r\n\\end{frame}\r\n\t\r\n\\begin{frame}[t,fragile]{Working in log-space and the Log-Sum-Exp trick}\r\n\t\\begin{itemize}[<+->]\r\n\t\t\\item Now we are guaranteed that the largest term in the sum equals one.\r\n\t\t\\item There can be no overflow and, while individual terms in the sum may underflow, this results only in round-off error in the final sum.\r\n\t\t\\item Log-sum-exp is implemented in \\verb|scipy.misc.logsumexp|.\r\n\t\\end{itemize}\r\n\\end{frame}\r\n\r\n% \\begin{frame}[t]{Estimating and Visualizing Distributions}\r\n% \t% PDF, PMF, CDF\r\n% \\end{frame}\r\n%\r\n% \\begin{frame}[t]{Building Histograms}\r\n% \t% PDF, PMF, CDF\r\n% \\end{frame}\r\n%\r\n% \\begin{frame}[t]{Seaborn}\r\n% \\end{frame}\r\n%\r\n% \\begin{frame}[t]{Seaborn}\r\n% \t% Interactive Demo\r\n% \\end{frame}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "b77e0a72e97fdbeafea482c2edd45f67c3007db0", "size": 16670, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Lecture09/lecture.tex", "max_stars_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_stars_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-18T05:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T05:36:19.000Z", "max_issues_repo_path": "src/Lecture09/lecture.tex", "max_issues_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_issues_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Lecture09/lecture.tex", "max_forks_repo_name": "royadams/intro_to_numerical_computing_with_python", "max_forks_repo_head_hexsha": "f31706f691b8a22ad8db19cdb950a0cb1df047f4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:22:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-09T20:22:57.000Z", "avg_line_length": 41.0591133005, "max_line_length": 223, "alphanum_fraction": 0.700479904, "num_tokens": 4943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376236, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.403948168412049}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%   Thesis template by Youssif Al-Nashif\n%\n%   May 2020\n%\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n\n\n\\section{NHTSA Special Crash Investigations}\n\\hspace*{0.3cm} For the NHTSA Special Crash Investigation dataset, a hierarchical clustering was performed on the resulting graph kernel computed from the skip-gram graphs. Since this dataset was small at $N=48$, it served as a good subject to study the interactions between modifying the skip window width, kernel hyper parameters, and number of clusters. This study on these interactions informs decisions made on which hyper parameters to use in final analysis of the NHTSA data as well as the reddit thread data. \\\\\n \nFor the study on these interactions, hyper-parameters were varied and the value of cluster within sum of squares was tracked. Specifically, the values in Figure 4.1 were tested. In Figure 4.1, we see some promising values occurring at more prominent ``elbow\" points in the plots. These points will be further analyzed and compared. The hyper parameters for these points are:\\\\\n \n \\begin{table}\n\\centering\n\\begin{tabular}{c|c|c|c}\nPoint&Skip-gram k& Graph Kernel sigma&No. of Clusters \\\\\n\\hline\nA&3&1000&5\\\\\nB&2&1100&3\\\\\nC&3&1100&5\\\\\nD&3&800&6\\\\\nE&3&900&7\n\\end{tabular}\n\\caption{Hyper-parameter for Variation Study in Figure 4.1}\n\\end{table}\n \n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/hclust_variation.png}\n\\caption{Hierarchical Clustering Variation (NHTSA) for differing hyper-parameters.}\n\\end{figure}\n\nThese hyper-parameter sets, and their corresponding graph kernel matrix, are used in a hierarchical clustering analysis. The results from the analysis perform well, and display prominent clusters, often of comparable sizes. In Figure 4.2, we see the 5 dendrograms produced from hyper-parameter sets A, B, C, D, and E. Upon some examination, one will notice that documents often appear in the same clusters together, regardless of the hyper-parameter sets. This is most encouraging, as it indicates that these clusters are not a result of user-chosen parameters, but that the documents are indeed similar. \\\\\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/5cluster.png}\n\\caption{Five hyper-parameter sets and their corresponding dendrograms.}\n\\end{figure}\n\nTo compare how often this co-membership in groups was appearing, a matrix of co-membership was created. In Figure 4.3, we see that each document has a set of other documents with which it is always clustered with, regardless of hyper-parameter configurations. These small document sets are the document sets which we can expect to have the most in common with one another.\\\\\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/comembers5.png}\n\\caption{Co-membership of documents across hyper-parameter sets A, B, C, D, and E.}\n\\end{figure}\n\nWe can inspect the results by checking some of the co-members' text. For example, document two (which was an ambulance crash in Angola, Delaware), has only 3 other co-members. Document two's co-members are: document 11, document 30, and document 38. Document 11 was an ambulance crash in Sheridan, Indiana. Document 30 was an ambulance crash in Pasadena, California. Document 38 was an ambulance crash in Ocilla, Georgia.\\\\\n\nNow, we can examine some information about these four incidents that may explain their clustering. For example, all of these incidents had fatalities, three of them had roll over events, and these four were all front end collisions to the ambulance where they struck another vehicle, or object, head on. While this is just one example of the clustering methods identifying similarities in the text, we can examine similarities across the dataset through use of term-frequency/inverse document frequency.\\\\\n\n\\begin{equation}\nTF-IDF = \\frac{\\frac{\\text{Term Frequency in Document}}{\\text{Total Words in Document}}}{\\log_2(\\frac{\\text{Total Documents in Corpus}}{Documents with Term})}\n\\end{equation}\n\n\\newpage\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/nhtsa_tf_idf.png}\n\\caption{Term-Frequency/Inverse Document-Frequency for NHTSA reports, using hyper parameter set A.}\n\\end{figure}\n\nIn Figure 4.4, we see that words that appear frequently, and are unique to that cluster appear to be vehicle manufacturers, medical terms, and words that describe a crash situation (e.g. guardrail, tree, interstate). We can use these to get an idea of the crash situation. Alternatively, we can also examine portions of the skip-gram graph produced, which was used for the graph kernel calculation. \\\\\n\nWe can put together some of the ideas and topics discussed in the cluster. For example, in Figure 4.5 we see that ``Front Left Passenger\", ``Rear Facing Seat\", and ``Patient Compartment\" are all skip-grams which appeared frequently in this cluster.\\\\\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/graph_k5_2.png}\n\\caption{Skip-grams which occurred more than 50 times in hierarchical clustering with hyper-parameter set A, in cluster 3.}\n\\end{figure}\n\n\n\\section{reddit Threads}\n\n\\hspace*{0.3cm} For the reddit threads dataset, analysis was focused on the ability of the clusterings to organize threads based on their query words. The words used to query the \\texttt{r/MentalHealth} subreddit (\\texttt{https://www.reddit.com/r/mentalhealth}) all returned threads which were then clustered into new groups. Some of these clusters expressed strong preference for posts that corresponded with specific key words. \\\\\n\nThis data was collected with the \\texttt{\\{redditExtractoR\\}} package \\cite{rivera2015package}, and then we augmented and cleaned with \\texttt{\\{tidytext\\}} \\cite{silge2016tidytext} and other \\texttt{\\{tidyverse\\}} tools \\cite{wickham2019welcome}. These tools made it easy to extract the data from reddit, tidy the data, and perform text processing tasks such as tokenization and parsing for punctuation or numbers. Once the data was in a clean format, it followed the script map to get to a format where it could be analyzed in the same fashion as the NHTSA data was. Since this data was a large set, it utilized the scripts set up with \\texttt{\\{furrr\\}} to speed up computation to under 20 minutes \\cite{bengtsson2020unifying}.\\\\\n\nTo assess how many clusters to use, an ``elbow plot\" was formed similar to those in Figure 4.1, see Figure 4.6. For the reddit threads, the hyper parameters from the NHTSA analysis were used, and the consistently lowest metric parameter set was chosen; skip-grams of $k=3$ and kernel parameter $\\sigma = 1200$ were used in the reddit clustering analysis. In Figure 4.6, we see that 4 clusters is the optimal value, where additional clusters provides diminishing results. \\\\\n\n\\newpage\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/reddit_wss.png}\n\\caption{Within sum of squares as a function of number of clusters}\n\\end{figure}\n\nAfter computing the kernel and using these parameters, four clusters are produced. Examining the dendrogram, in Figure 4.7, we see that we have 2 very distinct groups, which then break into two smaller groups. These groups are very clear and provide confidence in the clustering results. Along side the dendrogram, there is a heat map of what proportion of documents (or threads) in the cluster came from a query word. In Figure 4.7, we see that clusters 3 and 4 collected posts from the ``angry\" query word. Additionally cluster 1 displays a strong amount of its posts coming from the ``sad\" query word. \\\\\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/k4_reddit_clusters.png}\n\\caption{Left - Proportion of cluster's threads coming from each query word. Right - Dendrogram for reddit thread analysis, with 4 clusters.}\n\\end{figure}\n\nThe prominence of some of these query words in the clusters indicates that the tone or language used by the thread authors was picked out by the clustering methods. This is of particular interest, as the goal of these methods was to perform unsupervised text clustering which utilized more of the rich intricacies of language.\\\\\n\n\\begin{figure}\n\\includegraphics[width=6in]{Content/Images/reddit_network.png}\n\\caption{10 Reddit posts and their skip-grams which occurred 8 or more times.}\n\\end{figure}\n\n\\section{Comparative Analysis}\n\n\\hspace*{0.5cm} Looking at the results from both hierarchical clusterings on the graph kernels it is apparent that these methods work much better on larger documents. The performance of the graph kernels being applied to the skip-gram graph and then clustering was much better in the NHTSA dataset than the reddit threads dataset. By measuring within sum of squares, the NHTSA data set performed much better, as its WSS to number of observations ratio was 2.08 at its lowest, whereas the reddit dataset had a WSS to number of observation ratio of 9.\\\\\n \nAs for computational time, the NHTSA dataset took less than 2 minutes to compute, whereas the reddit dataset took just under 20 minutes to compute with the parallel processing. However, the reddit dataset displayed more prominent clusters, which was also indicative of success.\\\\\n\nComparing the elbow plots for both the NHTSA and the reddit threads datasets, it is clear that the optimal number of clusters for these methods will be dependent upon the dataset being analyzed. The results from the NHTSA study that indicated that skip-grams with $k=3$ did seem to apply to the reddit dataset as well. These hyper parameters will need tuning for any new application.\\\\\n\nOverall, the largest difference between the two analyses was that although the reddit threads displayed strong, prominent clusters, the NHTSA dataset was being computed in reasonable amount of time. Since the application of these methods are scaling better for increasing document size instead of increasing document lists, there is a case to be made that aggregating reddit threads into larger documents may be more effective, but to keep the observational unit tied to a reddit thread, this was not completed.\\\\ \n\nThese methods could be applied in any text mining application. Since the methods were able to be parallelized during their most computationally expensive portions of code, the methods could scale with sufficient hardware. In a high performance computing environment, these methods could either be applied in batch/scheduled computations or in a stream/real time application (with some modification). The readiness for HPC environments is important as it allows the code to scale and be used in much larger analytic applications.\n\n\\section{Contributions to the Field}\n\n\\hspace*{0.5cm} Through this work, several new contributions have been made to the field. First, a specific study on the use of graph kernels as preprocessing for hierarchical clustering; the combination of these ideas has not been well documented within the literature reviewed here. Second, the analysis of such differing datasets will bring new perspective to the topic as it relates to the performance of such methods on different types of text data. Thirdly, the workflow developed here was made open for others to use, edit, and analyze for future applications. All of the scripts, notebooks, supplementary materials, and data being made open encourages further development by the community. Lastly, the results of the analysis will go on to inform their respective subfields about the exciting applications of these methods. In the case of NHTSA, edge cases that can be summarized through these methods can lead to more representative simulations being made that can lead to better trained autonomous vehicles. For the reddit mental health data, the work completed here can be used for semi-supervised applications to classify discussion in these type of subreddits. The classification can inform mental health practitioners about the state of mental health within such communities at scale. They can then use those results to drive mental health awareness campaigns, better target what the community is feeling about treatment, or perhaps identify new language or a new subgroup of people dealing with a specific mental health issue. These contributions will support furthering research in this field, as well as the fields from which the data is of interest to. \n\n \n\n \n\n\n", "meta": {"hexsha": "3c4b047752c54334ff4bd48935a21f04cd4d2834", "size": 12212, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis_Tex/Content/02_Chapters/Chapter 04/Sections/01_HClustResults.tex", "max_stars_repo_name": "Levi-Nicklas/GraphDocNLP", "max_stars_repo_head_hexsha": "dec1acb24a2ab42b46d161c92b69ad3a55fcc5ff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-27T02:08:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-27T02:08:34.000Z", "max_issues_repo_path": "Thesis_Tex/Content/02_Chapters/Chapter 04/Sections/01_HClustResults.tex", "max_issues_repo_name": "Levi-Nicklas/GraphDocNLP", "max_issues_repo_head_hexsha": "dec1acb24a2ab42b46d161c92b69ad3a55fcc5ff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2021-02-18T16:07:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-25T14:18:51.000Z", "max_forks_repo_path": "Thesis_Tex/Content/02_Chapters/Chapter 04/Sections/01_HClustResults.tex", "max_forks_repo_name": "Levi-Nicklas/GraphDocNLP", "max_forks_repo_head_hexsha": "dec1acb24a2ab42b46d161c92b69ad3a55fcc5ff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 96.9206349206, "max_line_length": 1671, "alphanum_fraction": 0.7938912545, "num_tokens": 2723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4039481646313221}}
{"text": "\\input{permve-ntnu-latex-assignment.tex}\n\n\\usepackage{float}\n\\usepackage{tabularx}\n\n\\title{\n\\normalfont \\normalsize\n\\textsc{Norwegian University of Science and Technology\\\\IT3105 -- Artificial Intelligence Programming}\n\\horrule{0.5pt} \\\\[0.4cm]\n\\huge Module 6:\\\\ Deep Learning for Game Playing\\\\\n\\horrule{2pt} \\\\[0.5cm]\n}\n\n\\author{Per Magnus Veierland\\\\permve@stud.ntnu.no}\n\n\\date{\\normalsize\\today}\n\n\\newacro{ANN}{Artificial Neural Network}\n\\newacro{SGD}{Stochastic Gradient Descent}\n\n\\begin{document}\n\n\\fancyfoot[C]{}\n\\maketitle\n\n\\newpage\n\\fancyfoot[C]{\\thepage~of~\\pageref{LastPage}} % Page numbering for right footer\n\\setcounter{page}{1}\n\n\\section*{Knowledge Representation}\n\nThe goal of the module is to find a way to train an \\ac{ANN} with supervised learning such that it can beat a random player at the game \\textsc{2048}. The assignment states the difficulty of this task clearly, and heavily suggests preprocessing the board state to expose features in a form which is easier to learn by the network.\n\nBased on this, two preprocessing schemes has been developed to transform a board state into features which are used as inputs to the \\ac{ANN}. To construct the training data for the two schemes, an evaluation function is needed to decide which move to choose for each network input when generating training data.\n\nDuring prototyping, a small reference algorithm was written in Python to find a set of working features upon which to base a heuristic for satisfactory play. An important factor when doing supervised learning is that the answer in training examples must correspond well to the inputs presented in the training example. It was found when building the reference implementation that greedily selecting the move which maximizes the number of open cells will result in a mean score of $\\approx 230$, which significantly beats the mean random play score of $\\approx 110$ (see Table~\\ref{table:results}). This same heuristic is used to produce the correct move for both approaches.\n\nThe first knowledge engineering approach is the most basic of the two and involves feeding the number of possible merges for each row and each column in the current state as inputs to the network; resulting in 8 network inputs. Intuitively this should work well, as the information of how many merges are possible in each direction should be sufficient to correctly chose the optimal move according to the heuristic of maximizing the number of free cells.\n\nThe second knowledge engineering approach is more complex. An obvious solution would be to feed the board state directly into the network. However, this representation is complex and involves a range of different values for each cell. In an effort to simplify the board input, while allowing the network to learn when cells can be merged, a reduction is performed on the input values. For a given board state, the number of distinct non-zero values in the state is first counted. If a row in the board state has the values \\texttt{[0 2 4 2]}, then the row has two distinct non-zero values. After counting the number of non-zero values, each non-zero value on the board is reassigned to be its equal to its index in the sorted list of unique non-zero values. This reduction is meant to make the network blind to the magnitude of values in a board state and only treat values according to mergeability. The number of network inputs for the second approach is 16, corresponding to the reduced board cell values.\n\nAn important detail when producing training examples was to leave out examples where the heuristic was not able to distinguish one move as better than any other move. Unless the heuristic clearly knows that one move is the right move for the given state, it is assumed to not be beneficial to insist that the training examples follows the same ``random'' move that the example generator ends up making.\n\n\\begin{table}\n\\centering\n{\\small\n\\begin{tabular}{ccccccc}\n\\toprule\nPlayer    & Dimensions                          & Hidden $f$    & Output $f$       & $\\varepsilon$ [\\%] & Mean score & $\\sigma~\\text{score}$ \\\\\n\\midrule\nRandom    & N/A                                 & N/A           & N/A              & N/A                & 107.26     &  54.4479              \\\\\nReference & N/A                                 & N/A           & N/A              & N/A                & 231.87     & 125.5831              \\\\\nNetwork A & $8 \\times 4$                        & \\textsc{ReLu} & \\textsc{Softmax} & 0.0000             & 250.56     & 129.0481              \\\\\nNetwork B & $16 \\times 512 \\times 512 \\times 4$ & \\textsc{ReLu} & \\textsc{Softmax} & 0.2563             & 221.31     & 117.8580              \\\\\n\\bottomrule\n\\end{tabular}\n}\n\\caption{Statistics comparing the two chosen networks and the reference implementation. All networks use cross-entropy cost functions and are trained with learning~rate~0.08. Network~A is trained with minibatch size 40 and network~B with minibatch size 50. All scores are based on highest tile present at end of game; averaged over 1000 games. $\\varepsilon~=~\\text{Training set error}$. $\\sigma~=~\\text{standard deviation}$.}\n\\label{table:results}\n\\end{table}\n\n\\section*{Network Design}\n\nThe network inputs chosen for both representations has the same range in each representation. By using the \\textit{rectifier} activation function, scaling the inputs is not required as the activation function cannot be saturated, and because all values will be close to zero already. The \\textit{softmax} function is used for the output nodes to rank the most probable move.\n\nThe first network using the basic knowledge representation scheme does not require any hidden layer. It is able to train to 0\\% error within the first couple of epochs. It is however necessary to provide a large enough number of training examples. With training examples based on 100 games played a training error of 0\\% was not achieved. However, increasing the number of training examples to 1000 games was sufficient to complete optimal training. It is clear that the first knowledge representation scheme requires little ``intelligence'' from the network. This is intuitive, as it should be straightforward to select an optimal move to maximize the number of free cells based on the number of possible merges for each row and column.\n\nThe second network requires a much larger topology. Achieving good training errors required large hidden layers, and the final network uses two hidden layers of 512 nodes each. It is possible to train a network to achieve a training error of 0 since the preprocessing used for the first network is a simple algorithm. However this will likely require more training data and possibly even larger topology.\n\nBoth networks use \\textit{softmax} output nodes and the cross-entropy loss function as these yielded good results for the MNIST dataset in module~5.\n\nRunning each trained network for 1000 games and running a \\textit{Welch}-test produces a $p$-value of 0.0. It is clear that network~A with the much simpler input and topology beats network~B with the more complex input and topology. It is also clear that the choices and reduction algorithm used to produce feature input to the more complex network produces good results which could be improved further with the same input.\n\n\\section*{Play Analysis}\n\nBoth network configurations and their associated preprocessing stages are able to approximate the heuristic function well by achieving a low training error. When the training error is 0, bad moves will either occur because the training set is not large enough for the \\ac{ANN} to capture the information necessary to model the heuristic function -- or because the heuristic function simply made an evaluation with poor results.\n\nDuring observed play bad moves were only seen which were caused by the simplistic heuristic function chosen.\n\n\\begin{figure}[!h]\n\\centering\n\\begin{tabularx}{\\textwidth}{cXc}\n\\includegraphics[scale=0.35]{bad_1} & ~ & \\includegraphics[scale=0.35]{bad_2} \\\\\n\\end{tabularx}\n\\caption{\\textit{Example of poor gameplay:} Instead of moving up to gather the 4-tile, the 8-tile and the 16-tile to the right -- while keeping the 2-tiles to the upper left gathered -- the \\ac{ANN} instead choses to greedily merge two 2-tiles while risking worsening the board state by permitting tiles to spawn at the top of the board.}\n\\label{fig:N1}\n\\end{figure}\n\\begin{figure}[!h]\n\\centering\n\\begin{tabularx}{\\textwidth}{cXc}\n\\includegraphics[scale=0.35]{good_1} & ~ & \\includegraphics[scale=0.35]{good_2} \\\\\n\\end{tabularx}\n\\caption{\\textit{Example of good gameplay:} In this scenario the board state offers the possibility to merge four tile pairs. The greedy heuristic which the \\ac{ANN} models recognizes this possibility and performs four simultaneous merge while at the same time lining up two new merges.}\n\\label{fig:N1}\n\\end{figure}\n\n\\end{document}\n\n", "meta": {"hexsha": "5da3d76ee61ac8872e56df9c12ee0ff9c86e1ac8", "size": 8868, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "module_6/report/permve-ntnu-it3105-module-6.tex", "max_stars_repo_name": "pveierland/permve-ntnu-it3105", "max_stars_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "module_6/report/permve-ntnu-it3105-module-6.tex", "max_issues_repo_name": "pveierland/permve-ntnu-it3105", "max_issues_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module_6/report/permve-ntnu-it3105-module-6.tex", "max_forks_repo_name": "pveierland/permve-ntnu-it3105", "max_forks_repo_head_hexsha": "6a7e4751de47b091c1c9c59560c19a8452698d81", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 89.5757575758, "max_line_length": 1008, "alphanum_fraction": 0.7589084348, "num_tokens": 2027, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4038161872471211}}
{"text": "As early as 1964, Goffman~\\cite{goffman64OnRelevanceAsAMeasure}, a\nmathematical information science pioneer \\cite{harmon08RememberingWG},\nnotes that the relevance of documents in a list has to depend on the\ndocuments preceding it.  More recently, work on\nMMR~\\cite{carbonell98MMR} was one of the first to formalize\ndiversification as a mathematical optimization criterion; MMR has\nproved one of the most popular diversity approaches.  We note that the\nresults as derived in the last section formally motivate much of MMR and now\nwe discuss further connections between optimizing expected $n$-call@$k$ \nand other diversification approaches proposed in the literature.\n\n\\subsection{Greedy Submodular Optimization}\n\n%% SHENGBO: This section is almost entirely about Exp-1-call@k not n-call\n%%          since all of this text predates SIGIR 2012.  Do any of these\n%%          comparisons extend to n-call?  Not all do, but you should\n%%          make any connections where possible -- i.e., a max is allowed.  \n%%          I modified the last item on rank-based objectives to\n%%          mention n-call.\n\n\\cite{agrawal09diversifying} proposes a set-based objective function\nto answer ambiguous web queries in a setting where there exists a\npredefined taxonomy of information, and that both queries and\ndocuments may belong to more than one category according to this\ntaxonomy. The proposed set-based objective function aims at maximizing\nthe probability that the average user finds at least one useful\nresulting document retrieved within the top $k$\nresults. Mathematically, this objective function\nis defined below:\n%% SHENGBO - IA-Select is the greedy algorithm, not the objective \n%\n%% SHENGBO - don't define new notation, c is really equivalent to topics\n%%           t and you should use notation for S_k, S_k^*, s_i, s_i^* defined previously.\n\\begin{align}\n\tP(S_k|\\vec{q}) = \\sum_{t\\in T} P(t|\\vec{q}) \\left( 1 - \\prod_{s_i\\in S}(1-V(r_i| \\vec{q}, s_i))\\right) \n\\label{eq:diversifykObjectiveFunction}\n\\end{align}\nwhere $V(r_i| \\vec{q}, s_i)$ broadly defines the\nlikelihood that a document $s_i$ satisfies the query $\\vec{q}$ given the\ntopics of the query $\\vec{q}$ and the document $s_i$, i.e., $t$ and $t_i$, respectively\\footnote{We \nhave slightly adapted notation in the above equation from the original \nfor consistency with our previous definitions in this article.}.\n%% SHENGBO - learning has nothing to do with this paper - LDA in the\n%%           PLMMR paper was inappropriately applied (it is an admixture model,\n%%           not a mixture model) and we have not proposed any learning in\n%%           approach in this work -- indeed we suggested non-learning similarity \n%%           metrics could be converted to topic probabilities to match MMR.\n%, and note also that the taxonomy of $c$ given the query\n%and document is not learnt by some unsupervised model, but\n%hand-crafted.\n\nThe authors point out that one particular advantage of this set-based objective \nfunction is that it is submodular, hence permitting a $\\left( 1 - \\frac{1}{e} \\right)$\napproximation if optimized greedily as shown in~\\cite{Nemhauser:MathProg1978}.\n\nReferring back to our results shown in Equation~\\ref{eq:partial_simp}~and~\\eqref{eq:diversifykObjectiveFunction} from 1-call@$k$, we note that the objective function in Equation \\eqref{eq:diversifykObjectiveFunction} is related with ours, but it is unclear if Equation \\eqref{eq:diversifykObjectiveFunction} can be derived from the 1-call@$k$ objective, suggesting potential improvements in \\cite{agrawal09diversifying}. \n%writing out the mathematical expectation in terms of the sum over all\n%possible topics (e.g., taxomony in \\cite{agrawal09diversifying}) the\n%weighted relevance where weights are the topic distributions below\n%%% SHENGBO: the following is not correct, look at Eq (7)\n%%%          you need P(t_k=t|s_k) and i={1..k-1}\n%%%\n%%%          This means P(c|q) should be replaced with P(t|\\vec{q}) * P(t_k=t|s_k)\n%%%          if deriving from 1-call@k... it's not clear whether *their* result\n%%%          can be derived from an objective and model and this suggests their\n%%%          approach may be improved.\n%\\begin{align*}\n%    \\ExpOneCall(S_k,\\vec{q}) & = \\mathbb{E} \\left[\\left. \\bigvee_{i=1}^{k}r_i=1 \\right| s_{1},\\dots, s_{k},\\vec{q} \\right], \\\\\n%    \t\t\t\t\t\t\t\t\t\t\t\t & = \\sum_{t\\in T} P(t|\\vec{q}) \\left( 1 - \\prod_{i=1}^{k}(1-p(t_i = t| q, s_i))\\right) \n%\\end{align*}\n%Clearly our proposed objective is equivalent to the objective\n%Equation~\\eqref{eq:diversifykObjectiveFunction} proposed\n%in \\cite{agrawal09diversifying} when one replaces the likelihood\n%function $V(s|\\vec{q}, c)$ by $p(t_i = t| \\vec{q}, s_i)$. \n\nMore recently, \\cite{Vargas:SIGIR2012} introduce several interesting formal probabilistic\nrelevance models to instantiate $V(r_i| \\vec{q}, s_i)$, which are more\nappopriate in modeling the relevance in a probabilistic\nframework. Furthermore, \\cite{Vallet:SIGIR2012} propose to introduce a\nuser as an explicit random variable in state of the art\ndiversification methods, thus developing a generalized framework for\npersonalized diversification.\n\nAnother recent interesting instantiation of $V(r_i|\\vec{q},s_i)$ is proposed\nin \\cite{Zuccon:ECIR2012} motivated by the facilitation location\nproblem~\\cite{Gonzalez:Handbook2007} taken from Operations Research:\nfor a set of customer ``locations\" $D$, one aims at choosing a subset\n$S_k$ in $D$ to open $k$ ``facilities\" that optimize a graph-theoretic\nobjective that depends on the cost of opening a facility at each\nlocation and also the distance between each pair of locations. However\nall of the described methods do not derive their objective\nfunctions from the expected 1-call@$k$ objective as we have achieved.\n\n\\subsection{Portfolio Theory}\n\\cite{wang09PortfolioTheory} motivates\ndiversification in set-based information retrieval by a\nrisk-minimizing portfolio selection approach. Viewing a result set as\nan investment portfolio with the objective to maximize return while\nminimizing risk, the derived result of~\\cite{wang09PortfolioTheory}\nmimics both MMR and Exp-$1$-call@$k$ in that the similarity term may\nbe viewed as \\emph{expected portfolio payoff} (relevance) and the\ndiversity term may be viewed as \\emph{expected portfolio risk}, which\nincreases as the correlations between documents in the result set\nincrease. \n%% SHENGBO -- you used to have math here for Wang09 which you've omitted.\n%%            It's not very clear to say a sum here if you never show it!\n%%            (There was not room in CIKM to display this.)\n%%\n%%            Also I suggest dropping the mention of Shi -- it is not\n%%            clear and it interrupts the flow of discussion about wang\n%%            and the lead-in to the next section.\n%Note that diversification based on portfolio theory is\n%extended in \\cite{Shi:SIGIR2012} by introducing latent factors for\n%collaborative filtering tasks. \n\nOne major difference in the\nframework~\\cite{wang09PortfolioTheory} is that rather than computing\nthe diversity term via a max (MMR) or product (Exp-$1$-call@$k$) the\nportfolio theory derivation uses a summation: \n\\begin{align}\ns_{k}^{*} = \\argmax_{s_{k}} \\left[ \\Sim^{\\text{BM25}}(s_k,\\vec{q}) \\hspace{-.7mm} - \\hspace{-.7mm} \\lambda \\sum_{i=1}^{k-1} \\omega_{i} \\Sim^{\\text{TFIDF}}(s_i,s_k) \\right]\n\\label{eq:wang09PortfolioTheory}\n\\end{align}\nHere, $\\lambda$ is a manually tuned weight parameter, $\\omega_1,\\ldots,\\omega_k$\nare the weights of each position in the result set,\n$\\Sim^{\\text{BM25}}(s_k,\\vec{q})$ is the BM25~\\cite{bm25} probabilistic\nrelevance score of document $s_k$ w.r.t.\\ query $\\vec{q}$ and\n$\\Sim^{\\text{TFIDF}}(s_i,s_k)$ is a TFIDF~\\cite{salton83Introduction}\nsimilarity metric between two documents $s_i$ and $s_k$ represented as term\nfrequency vectors. We examine the implications of using the summation in Equation~\\eqref{eq:wang09PortfolioTheory} next.\n\n\\subsection{Set Covering}\nYue and Joachims~\\cite{yue081224Predicting} propose a set covering\napproach for training SVMs to predict diverse result sets for\ninformation retrieval. In their work, they equate subtopics with\nwords and build a loss function for SVM training that penalizes result\nsets according to the sum of weights of query-relevant words\n\\emph{not} covered by the result set. The proposed loss function is called the weighted subtopic loss $\\text{WSL}(S_k,\n\\vec{q})$, which is the weighted percentage of distinct\nsubtopics in the topic set of query $\\vec{q}$ \\emph{not} covered by the\nretrieved set $S_k$. Denoted by the set of topics for query\n$\\vec{q}$ as $T_{\\vec{q}}$ and denote the set of topics in $T_{\\vec{q}}$ covered\nby $S_k$ as $T_{S_{k}}$, Yue and Joachims define this loss function below:\n\\begin{align}\n    \\text{WSL}(S_k, \\vec{q}) = \\sum_{i \\in T_{\\vec{q}} \\setminus T_{S_{k}}} \\frac{n_{i}}{\\sum_{i \\in T'} n_{i}} \\label{eq:wsl}.\n\\end{align}\nThis loss function function penalizes a result set $S_k$ by the topics\n$T_{\\vec{q}} \\setminus T_{S_{k}}$ according to the sum of their weights, where topic $i$ is weighted according to the count $n_i$ of documents in $D$\ncovered by topic $i$ (normalized by $\\sum_i n_i$).\n\nWhile the approach by Yue and Joachims~\\cite{yue081224Predicting} provides a ``hard'' set-covering view of diversity, we note that an expansion of\n$\\tilde{P}(t | S_{k-1}^*)$ used in the diversity term\nof~\\eqref{eq:1call} provides a ``soft'' latent set-covering\ninterpretation; that is, $s_k$ is chosen so as to best cover (in a\nprobabilistic sense) the latent topic space not already covered by $\\{\ns_1^*,\\ldots,s_{k-1}^* \\}$.  Formally, expanding the product in\n$\\tilde{P}(t | S_{k-1}^*) = \\prod_{i=1}^{k-1} \\left(1 -\nP(t_{i}=t|s_{i}^{*})\\right)$, collecting terms and writing it as a\nseries, we arrive at a form that reflects the inclusion-exclusion\nprinciple applied to the calculation of probability that topic $t$ is\ncovered by $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$:\n\\begin{align}\n& \\prod_{i=1}^{k-1} \\left(1 - P(t_{i}=t|s_{i}^{*})\\right) \\nonumber \\\\\n& = 1 - \\left[ \\sum_{i=1}^{k-1} P(t_{i}= t|s_{i}^{*}) - \\sum_{i=1}^{k-1}\\sum_{j=1}^{k-1}P(t_{i}= t|s_{i}^{*})P(t_{j}= t|s_{j}^{*}) + \\dots - (-1)^{k-1}\\prod_{i=1}^{k-1}P(t_{i}=t|s_{i}^{*})\\right] \\label{eq:setcover}\n\\end{align}\n\nThis result has a natural interpretation: the first summation term\ndetermines the coverage of topic $t$ by each document $s_i$ ($1 \\leq i\n\\leq k-1$) currently in the result set, the second double summation\nterm corrects the first term by removing the joint probability mass\nfrom all pairs of documents that was double counted, and so on\naccording to the principle of inclusion-exclusion.\n\\eqref{eq:setcover} not only provides a probabilistic set covering\nview of Exp-$1$-call@$k$, but it also suggests that a portfolio\napproach to diversity using only the first summation would overcount\neach document's contribution to the diversity metric according to this\nset covering perspective.\n\nThe inclusion-exclusion principle calculation provided by the second\nterm in Equation~\\ref{eq:setcover} is illustrated in~Figure~\\ref{fig:inclusionExclusionPrinciple}. In words, this term\nis calculating the total topic probability coverage of $t$ by all\nselected items $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$ by properly applying the\ninclusion-exclusion principle to ensure that overlapping probability\ncoverage is not double counted. Then referring back to\nEquation~\\ref{eq:partial_simp}, we note that $s_k$ is chosen by\nmaximizing a weighted sum over topics, where each topic weight is\ndetermined by its relevance to the query $\\vec{q}$, the item $s_k$,\nand penalized (i.e., due to the $1 - $) by the topic coverage of $t$\nby the set $\\{ s_1^*,\\ldots,s_{k-1}^* \\}$ to naturally encourage\ndiversity.  We note that this is a soft probabilistic version of the\n``in or out'' topic coverage approach of the weighted subtopic loss function $\\text{WSL}(S_k,\n\\vec{q})$ (Equation~\\eqref{eq:wsl}).\n%% SHENGBO: WSL is not defined!!!\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[t!]\n\\begin{center}\n\\centerline{\\includegraphics[scale = 0.4]{inclusionExclusionPrinciple}}\n\\caption[Inclusion-exclusion principle.]{Inclusion-exclusion principle. The sets represent candidate\nitems $s$ for a query, and the area covered by each set is the\n``information\" covered by that item for query topic $t$. Numbers on different areas\nindicates the number of sets that share these areas. }\n\\label{fig:inclusionExclusionPrinciple}\n\\end{center}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Subtopic Relevance Models} \n\nWe use a subtopic relevance model that is a simplified version of the\nmodel in~\\cite{plmmr} with fewer dependence assumptions.  In other\nwork, Zhai {\\it et al}~\\cite{zhai03Beyond} present an empirical risk\nminimization view of dependent document retrieval from a subtopic\nperspective, where they derive a formalization of the\n\\emph{greedy} selection step that is similar to MMR and to a lesser\nextent, Exp-$1$-call@$k$.\n\n\\subsection{Set-based Relevance Objectives} \n\nChen and Karger~\\cite{chen06Less}, whose derivation we extended,\ndirectly optimize $1$-call@$k$, but their intention is not to\nformalize MMR and instead use na\\\"{i}ve Bayes to directly evaluate\n\\eqref{eq.ncall}.  Agrawal et al~\\cite{agrawal09diversifying}\nand Santos et al (xQuad)~\\cite{santos2010xquad} both specify set-based\ndiversity metrics \\emph{very} similar to Exp-$1$-call@$k$ but do not provide\nformal derivations as we have done in this work. \n\n\\subsection{Ranking Based Objectives} \n\nFinally, returning to our introductory motivation, Wang and\nZhu~\\cite{wangzhu10} have shown that natural forms of result set\ndiversification arise via the optimization of average\nprecision~\\cite{ap} and reciprocal rank~\\cite{mrr}.  Both of these\nmethods share the view of directly optimizing a\n\\emph{ranking-based} objective, whereas this paper proposes a novel\nderivation from the alternate view of optimizing a \\emph{set-based}\nobjective w.r.t.\\ a subtopic model of relevance.  However, even though\nExp-$n$-call@$k$ is a set-based objective, an indirect consequence of\n(and motivation for) greedily optimizing it is that documents added\nearlier yield a greater increase in objective than those added later;\nthis yields a natural rank ordering on the greedy Exp-$n$-call@$k$\nresult set.\n\n%% SHENGBO: I removed the table because you are referring to learning and\n%%          a lot of traits that were relevant to PLMMR in SIGIR 2010 that\n%%          are no longer relevant now.  Either you need to do an entirely\n%%          new analysis relevant to this paper and its objectives, or just\n%%          drop it as I did.\n%%\n%%          Old content is checked in under related_work_unused.tex\n\n", "meta": {"hexsha": "482c2a04e1f3a12ab3d628a6e1c435e5ff28631e", "size": 14713, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/ACM_TIST_diversity/related_work.tex", "max_stars_repo_name": "antoine-tran/diversify", "max_stars_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/ACM_TIST_diversity/related_work.tex", "max_issues_repo_name": "antoine-tran/diversify", "max_issues_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/ACM_TIST_diversity/related_work.tex", "max_forks_repo_name": "antoine-tran/diversify", "max_forks_repo_head_hexsha": "0c9815d515feda7edb504f1ad91dec0a255f9e0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-04T16:27:43.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-04T16:27:43.000Z", "avg_line_length": 58.3849206349, "max_line_length": 421, "alphanum_fraction": 0.7373071433, "num_tokens": 4116, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544085240402, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4038161800083793}}
{"text": "% Created 2020-07-13 lun 12:51\n% Intended LaTeX compiler: pdflatex\n\\documentclass[letterpaper,fleqn]{scrartcl}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{grffile}\n\\usepackage{longtable}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{amssymb}\n\\usepackage{capt-of}\n\\usepackage{hyperref}\n\\usepackage{khpreamble}\n\\usepackage{tabularx}\n\\usepackage{geometry}\n\\usepackage{pgfplots}\n\\pgfplotsset{compat=1.13}\n\\geometry{top=20mm, bottom=20mm, left=24mm, right=18mm}\n\\author{Kjartan Halvorsen}\n\\date{}\n\\title{Polynomial design (RST) exercise}\n\\hypersetup{\n pdfauthor={Kjartan Halvorsen},\n pdftitle={Polynomial design (RST) exercise},\n pdfkeywords={},\n pdfsubject={},\n pdfcreator={Emacs 26.3 (Org mode 9.3.6)}, \n pdflang={English}}\n\\begin{document}\n\n\\maketitle\n\n\\section*{Determine the order of the controller}\n\\label{sec:org6e78179}\n\\begin{center}\n\\includegraphics[width=0.7\\linewidth]{../../figures/2dof-block-explicit}\n\\end{center}\nIn each of the cases determine the order of the feedback controller \\(F_{b}(z)=\\frac{S(z)}{R(z)}\\) and write out the \\(R(z)\\) and \\(S(z)\\) polynomials. Determine also the order of the observer polynomial \\(A_o(z)\\). You don't have to solve for the controller coefficients.\n\n\\subsection*{Case 1}\n\\label{sec:orgb815efe}\nPlant is \\(H(z) = \\frac{b_0z+b_1}{z^3  + a_1z^2 + a_2z}\\),  desired response to reference signal \\(H_c(z) = \\frac{0.2^2}{z(z-0.8)(z-0.8)}\\), observer poles in the origin.\n\n\\vspace*{27mm}\n\n\\subsection*{Case 2}\n\\label{sec:org6948edd}\nPlant is \\(H(z) = \\frac{b_0z+b_1}{z^3  + a_1z^2 + a_2z}\\),  desired response to reference signal \\(H_c(z) = \\frac{0.2^2}{(z-0.8)^3}\\), observer poles in the origin and integral action in the feedback controller (incremental controller).\n\n\n\\vspace*{27mm}\n\n\n\\subsection*{Case 3}\n\\label{sec:orgef90a48}\nPlant is \\(H(z) = \\frac{b_0z+b_1}{z^2  + a_1z + a_2}\\) and there is a delay of 2 sampling periods in the feedback path. The desired response to reference signal \\(H_c(z) = \\frac{0.2^2}{(z-0.8)(z-0.8)}\\), observer poles in the origin and integral action in the feedback controller (incremental controller).\n\\end{document}", "meta": {"hexsha": "51ffd51f7019172c18a9592d226f539b9e200288", "size": 2217, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "polynomial-design/exercises/RST-exercise.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "polynomial-design/exercises/RST-exercise.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "polynomial-design/exercises/RST-exercise.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 36.3442622951, "max_line_length": 305, "alphanum_fraction": 0.7289129454, "num_tokens": 770, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.4037454326622952}}
{"text": "\\documentclass{report}\n\n\\title{AICC II \\\\ Prof. Bixio Rimoldi}\n\\author{Benjamin Bovey}\n\\date{Semester of Spring 2019}\n\n%math packages\n\\usepackage{amsmath}\n\\usepackage{mathtools}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\n\\usepackage{thmtools}\n%\\usepackage{thmbox}\n%\\usepackage{shadethm}\n\n\\usepackage[dvipsnames]{xcolor}\n\n%utility packages\n\\usepackage{cancel}\n\\usepackage{soul}\n\n%margins\n\\usepackage{geometry}\n\\geometry{left=2cm, right=2cm, top = 2cm, bottom=2cm}\n\n\n\\newcommand\\important[1]{\\noindent {\\underline{\\textsc{#1}}} \\ }\n\\DeclareMathOperator{\\supp}{supp}\n\n\\declaretheorem[name=Theorem, style=plain, shaded={rulecolor=Lavender, rulewidth=2pt, bgcolor={rgb}{1,1,1}}]{thm}\n\n\\declaretheorem[name=Definition, sibling=thm, style=definition, shaded={rulecolor={blue!30}, rulewidth=2pt, bgcolor={rgb}{1,1,1}}]{defn}\n\\declaretheorem[name=Example, sibling=thm, style=definition]{exmp}\n\\declaretheorem[name=Summary, numbered=no, style=definition]{summary}\n\n\n\\declaretheorem[name=Remark, numbered=no, style=remark]{remark}\n\n%\\theoremstyle{plain}\n%\\newtheorem{thm}{Theorem}\n%\n%\\theoremstyle{definition}\n%\\newtheorem{exmp}[thm]{Example}\n%\\newtheorem{defn}[thm]{Definition}\n%\\newtheorem*{summary}{Summary}\n%\n%\\theoremstyle{remark}\n%\\newtheorem*{remark}{Remark}\n%\\newtheorem*{question}{Question}\n%\\newtheorem*{answer}{Answer}\n\n% the next 3 lines are for removing section numbering. You may want to comment them out.\n\\makeatletter\n\\renewcommand{\\@seccntformat}[1]{}\n\\makeatother\n\n\\begin{document}\n\\maketitle\n\n\n\\section{19th February 2019}\nAs opposed to the first AICC course, where we were mostly presented with tools, we will now see more applications of these tools for communication and computation. Mainly, we will see 3 applications in the first part of the semester:\n\\begin{itemize}\n\t\\item \\textbf{Source coding} (compressing information)\n\t\\item \\textbf{Cryptography} (authentication / privacy / integrity of information)\n\t\\item \\textbf{Channel Coding} (dealing with noise and loss of information / protecting the information from natural damages)\n\\end{itemize}\nWhat these three have in common is the idea of storing and communicating information. The notion of entropy, which will come up quite often, will also be important.\n\n\\subsection{Basic probability review}\n\\textbf{Special case first}: \\underline{finite} sample space $\\Omega$ and \\underline{uniform distribution}. $\\Omega = \\{\\omega_1, \\omega_2, \\dots, \\omega_n\\}$. Events: $E \\subseteq \\Omega$. Then:\n\\begin{equation}\n\tP(E) = \\dfrac{|E|}{|\\Omega|} \\qquad \\text{(uniform distribution)}\n\\end{equation}\n\n\\begin{defn}[conditional probability]\nLet $E, F$ be two events. Then, the probability that event $E$ occurs knowing that $F$ has occured:\n\\begin{equation}\n\tP(E|F) = \\dfrac{|E \\cap F|}{|F|}\n\\end{equation}\n\\end{defn}\nIntuitively, you restrict the sample space to $F$ only, because you \\emph{know} that $F$ has happened: this translates to the division by the cardinality of $F$ instead of the cardinality of $\\Omega$. The intersection of $E$ and $F$ follows from the fact that the sample space is restricted to $F$: if there exists elements that are in $E$ but not in $F$, they are outside of the new sample space $F$, which means that these elements CANNOT occur in conjunction with $F$. Therefore, we take the intersection of $E$ and $F$ to assure that these elements are not taken into account in the computation.\n\n\\begin{thm}[Law of total probability]\nLet $E$ and $F$ be two events in $\\Omega$, and let $F^C$ denote the complement of $F$. Then:\n\\begin{equation}\n\tP(E) = P(E|F)P(F) + P(E|F^C)P(F^C)\n\\end{equation}\nThis follows quite directly from the fact that $E = (E \\cap F) \\cup (E \\cap F^C)$, so $P(E) = P(E \\cap F) + P(E \\cap F^C)$ \\dots \n\\end{thm}\n\n\\begin{remark}[divide and conquer] You can sometimes create a partition of your sample space, in a way that allows you to better apply the numbers you are given (p.27-28). This method is called \\emph{divide and conquer}.\n\\end{remark}\n\n\\begin{thm}[Bayes]\nBayes' theorem allows you to compute $p(F|E)$, given that you know $p(E|F), p(E)$ and $p(F)$:\n\\begin{equation}\n\tp(F|E) = \\dfrac{p(E|F)p(F)}{p(E)}\n\\end{equation}\n\\end{thm}\n\n\\begin{remark}[application] This is useful, in real scenarios, when either one of $p(E|F)$ and $p(F|E)$ is easily observable, but the other isn't. For example, policemen may observe how many people are driving drunk knowing that they have had an accident (they just test the driver after the accident), but they cannot observe how many people are having an accident knowing that they are driving drunk (they can not really test drivers, and then let them drive drunk just to check if they have an accident or not).\n\\end{remark}\n\n\\begin{defn}\nA \\textbf{random variable} $X$ is a function $X: \\Omega \\to \\mathbb{R}$. It is attached a \\emph{probability distribution function} $p_X(x)$, which represents the probability that $X$ will take on the value $x$, that is, that the following event $E$ occurs:\n\\begin{equation}\n\tE = \\{\\omega \\in \\Omega : X(\\omega) = x\\}\n\\end{equation}\nHence,\n\\begin{equation}\n\tp_X(x) = p(E) = \\sum_{\\omega \\in E} p(\\omega)\n\\end{equation}\nThe set of all possible values of $X$ is sometimes called the \\emph{alphabet} of $X$, written with more curly letters like $\\mathcal A$.\n\\end{defn}\n\n\\begin{defn}[two random variables]\n\tLet $X: \\Omega \\to \\mathbb{R}$ and $Y: \\Omega \\to \\mathbb{R}$ be two random variables. \\\\\n\tThe probability of the event $E = \\{\\omega \\in \\Omega : X(\\omega) = x \\land Y(\\omega) = y\\}$, or, more shortly written, $\\{X = x \\land Y = y\\}$, is\n\t\\begin{equation}\n\t\tp_{X, Y}(x, y) = \\sum_{\\omega \\in E} p(\\omega)\n\t\\end{equation}\n\tWe can compute $p_X$ (or $p_Y$, similarly) from $p_{X, Y}$:\n\t\\begin{equation}\n\t\tp_X(x) = \\sum_y p_{X, Y}(x, y)\n\t\\end{equation}\n\\end{defn}\nIn one sense, we \"fix in place\" the value of $x$ and \"scroll through\" all possible values of $y$, and add their probabilities up. Here, $p_X$ is called the \\textbf{marginal distribution} of $p_{X, Y}(x, y)$ with respect to $x$.\n\n\\section{21st February 2019}\n\n\\begin{defn}[expected value]\nThe \\textbf{expected value}, or \\textbf{mean} of a random variable $X: \\Omega \\to \\mathbb{R}$, can be computed as\n\\begin{equation}\n\tE[X] = \\sum_{x \\in \\mathcal A(X)} x \\cdot p_X(x) \\quad \\text{(requires $p_X$)},\n\\end{equation}\nor as\n\\begin{equation}\n\tE[X] = \\sum_{\\omega \\in \\Omega} X(\\omega) \\cdot p(\\omega).\n\\end{equation}\n\\end{defn}\nOne could say that the first way is ``calculating over the codomain'', and the second way is ``calculating over the domain'' (of $X$). \n\n\\begin{remark} The expected value is a linear operation. Let $X_1, X_2, \\dots, X_n$ be random variables from $\\Omega$ to $\\mathbb{R}$, and let $\\lambda_1, \\lambda_2, \\dots, \\lambda_n$ be real numbers. Then\n\\begin{equation}\n\tE\\underbrace{\\Bigr[\\sum_{i=1}^n \\lambda_i X_i\\Bigl]}_{\\text{random variable}} = \\sum_{i=1}^n \\lambda_i E[X_i]\n\\end{equation}\n\\end{remark}\n\n\\subsection{Extending notions from events to random variables}\nThe notion of independent events extends to random variables. Recall that two events $E$ and $F$ are independent iff $p(E|F) = p(E)$, which is equivalent to saying that $p(E \\cap F) = p(E)p(F)$. \n\nSimilarly, two random variables are independent iff the value taken by one does not influence the value taken by the other.\n\n\\begin{defn}[independent random variables]\n\tWe say that two random variables $X, Y: \\Omega \\to \\mathbb{R}$ are \\textbf{independent} iff \n\t\\begin{equation}\n\t\tp_{X, Y}(x,y) = p_X(x)p_Y(y)\n\t\\end{equation}\n\tMore generally, $n$ random variables are independent iff\n\t\\begin{equation}\n\t\tp_{S_1, \\ldots, S_n} = \\prod_{i=1}^n p_{S_i}\n\t\\end{equation}\n\\end{defn}\n\n\\noindent From there, we can also extend the notion of conditional probability to random variables.\n\\begin{defn}\nWe define the \\textbf{conditional probability of two random variables} $X, Y: \\Omega \\to \\mathbb{R}$ as\n\\begin{equation}\n\tp(X=x | Y=y) = \\dfrac{p(X=x \\land Y=y)}{p(Y=y)},\n\\end{equation}\nor, with simpler notation,\n\\begin{equation}\n\tp_{X|Y} = \\dfrac{p_{X, Y}(x, y)}{p_Y(y)}\n\\end{equation}\n\\end{defn}\n\n\\begin{remark} The following statements are all equivalent to the statement ``$X$ and $Y$ are independent'':\n\\begin{align}\n\tp_{X, Y}(x, y) = p_X(x) \\\\\n\t\\label{eq:condprobtip1}\n\tp_{X|Y}(x|y) = p_X(x) \\\\\n\t\\label{eq:condprobtip2}\n\tp_{Y|X}(y|x) = p_Y(y)\n\\end{align}\n\\end{remark}\n\n\\begin{remark}[useful trick] If you are asked to check the independence of $X$ and $Y$, you don't have to check the equality of \\eqref{eq:condprobtip1} or \\eqref{eq:condprobtip2}. You just have to find the expression for the left-hand side function, and see if it depends on the other variable ($\\implies$ they are NOT independent), or if it is just a function of one variable ($\\implies$ they are independent).\n\\end{remark}\n\n\\begin{thm}[consequence of the independence of random variables] In all cases, $E[X+Y] = E[X] + E[Y]$. However, if $X$ and $Y$ are \\emph{independent}, we also have that\n\\begin{equation}\n\tE[XY] = E[X]E[Y]\n\\end{equation}\n\\end{thm}\n\n\\subsection{Source \\& Entropy}\nThe main object that will interest us when studying source coding is the source itself. The question of the definition of a source took mathematicians and computer scientists a while to answer. We can loosely model a source as a black box that outputs \\emph{information}: we are not really interested in its inner mechanisms, but rather in the information that comes out of it. This information could take many forms, for example sequences of symbols: since we are considering sources from a computer science point of view, we will be interested in sources that shite out sequences of numbers. \\\\\n The notion of \\emph{entropy} comes into the frame when we realize that a symbol that can be \\emph{predicted} before it comes out of the source provides no new information. For example, if the sequence of numbers coming out of the source is \\texttt{1, 1, 5, 5, 3, 3, 19, 19, 5, ...}, we quickly realize that we do not need to store the second number of each pair, as it brings no new information to the table. \\\\\n An important observation that we can make at this point (it was initially made by Hartley in 1929) is that this link between information and entropy can be modeled very elegantly by random variables! If we think about it, the core idea of a random variable is that it gives you a value that you cannot certainly predict until you actually do the experiment that it models and observe its outcome (hence, in fact, the name of \\emph{random} variable). If we choose to use this model, a source can be viewed as outputting a sequence of random variables, where each random variable represents one (or more, as we'll see later) symbol(s) in the sequence of symbols. \\\\\nLet us now consider a source outputting a sequence of random variables, call them $S_1, S_2, S_3, \\dots, S_n$. Another fundamental question we may ask ourselves is: \\ul{how much information is actually conveyed by each individual symbol?} A partial answer was given by Hartley, that is, that this must depend on the \\textbf{alphabet} of the random variable.\n\\begin{defn}\n\tThe \\textbf{alphabet} of a random variable is the codomain of the random variable, that is, the set of all values that the random variable may take.\n\\end{defn}\nIndeed, the bigger the alphabet, the more information it can carry, as there are more possibilities for each symbol, and therefore less predictability. With basic combinatorics, we can see that there are $|\\mathcal A|^n$ possible length-$n$ sequences $(s_1, s_2, \\dots, s_n)$. Therefore, the amount of information carried by $S_i$ is $\\log_b |\\mathcal A|$ \\footnote{We will see later that the value of $b$ determines the unit of information used. Most often, it is 2, which means that the bit is the unit.}.\n\\begin{exmp} Imagine this is the sequence of good days (1) and bad days (0) in London during a year:\n\\begin{equation*}\n\t(s_1, s_2, \\dots, s_{365}) = (0, 1, 1, 0, 1, 0, 0, 0, 1, 0, \\dots, 0, 0, 1).\n\\end{equation*}\n This sequence of numbers is very unpredictable, as there is no constant pattern underlying it. It would therefore be hard to find a better way of storing this information (without losing any) than just storing all the 365 bits individually. When this happens, we will see that what we shall soon define as the \\textbf{entropy} of this random variable is very high. \\par\nNow imagine that in San Diego, the sequence looks like this:\n\\begin{equation*}\n\t(\\overbrace{0, 0, 0, \\dots, 0}^{\\text{24 zeros}}, 1, \\overbrace{0, 0, 0, \\dots, 0, 0}^{\\text{340 zeros}}).\n\\end{equation*}\n This is a very predictable sequence: we could, for example, just store $(24, 1, 340)$ rather than storing all 365 bits. This means we can shrink down how we represent this information without losing any information! Here, the amount of information is much lower than in the case of London, and the entropy is very low.\n\\end{exmp}\n\n\\subsection{Entropy redefined by Shannon}\nShannon, in 1948, gave a new formula for the amount of information carried by a random variable $S$. He found out that the amount of information \\emph{is} in fact the entropy itself\\footnote{Like we saw with the example of London and San Diego weather, when the entropy is very low (which means that the source is very predictable), we can shrink down the information to store it easier. What that really means is that we can cut out unnecessary bits that do not bring any new information. This allows us to observe that when entropy is low, the actual amount of information is low. Similar observations can be made with high entropy and high amounts of information.}, and gave this formula for the entropy $H(S)$:\n\\begin{equation}\n\tH(S) = -\\sum_{\\mathclap{s \\in \\supp (p_S)}} p_S(s) \\cdot \\log_b \\bigl( p_S(s) \\bigr)\n\\end{equation}\n\n\\begin{remark} We may observe some things:\n\t\\begin{itemize}\n\t\t\\item The rather heavy notation $s \\in \\supp (S)$ is needed because $\\log(0)$ is undefined. However, if we accept the common convention $0 \\cdot \\log(0) = 0$, then we can simplify the notation to this: \\begin{equation*}H(S) = - \\sum_{s \\in \\mathcal A} p_S(s) \\log_b \\bigl(p_S(s)\\bigr); \\end{equation*}\n\t\t\\item when $b=2$ then the unit is the bit. By default, $H(S) = H_2(S)$;\n\t\t\\item we may rewrite the formula as\n\t\t\\begin{equation*}\n\t\tH(S) = \\sum\\limits_{s \\in \\mathcal A} p_S(s) \\underbrace{\\Bigr(-\\log_b \\bigl(p_S(s)\\bigl) \\Bigl)}_{\\text{rand. var. $X$}} = E[X],\n\t\t\\end{equation*}\n\t\tbecause this is the expression of the expected value of a random variable $X$.\n\t\t\\item Since the sources that we will study are most often sequences of random variables, it is important to know that \\ul{entropy can extend to any number of random variables}.\n\t\\end{itemize}\n\\end{remark}\n\n\\begin{exmp}\n\tLet us try and give an intuitive example of entropy applied to a sequence of random variables. Let $S_1, S_2, \\ldots, S_n$ be a sequence of coin flips. Then $S_i \\in \\{0, 1\\} = \\mathcal A$, and $P_S(s) = \\frac12$. \\\\\nIntuitively, we are flipping $n$ coins, and it should take $n$ bits to describe the result (a length-$n$ bitstring).\n\\begin{align*}\n\t&\\underbrace{P_{S_1, S_2, \\ldots, S_n}(s_1, s_2, \\ldots, s_n)}_{\\text{abbreviate as } P(s_1, \\ldots, s_n)} = \\prod_{i=1}^n P(s_i) = \\left(\\frac12 \\right)^n \\\\\n\t&H(S_1, S_2, \\ldots, S_n) = \\log\\left(|\\mathcal A|^n \\right) = n \\log 2 = n\n\\end{align*}\n\nRecall that when we write $P(s_1, s_2, \\ldots, s_n)$, we mean the probability of getting the sequence $(s_1, s_2, \\ldots, s_n) \\in \\mathcal A^n$. The cardinality of the alphabet is $|\\mathcal A^n| = |\\mathcal A|^n$.\n\\end{exmp}\n\n\n\n\\section{26th February 2019}\nWe saw last time that a source can mathematically be modeled as one or more random variables, each being described by its probability mass function. We saw that the entropy is a number which represents the ultimate amount of bits (not necessarily, but generally, binary) needed to represent a random variable (and therefore a source).\n\n\\begin{defn}[binary entropy function] When the random variable $S \\in \\{0, 1\\} = \\mathcal A$ with $p_S(0) = P$ represents a Bernouilli trial, that is, its alphabet is of size 2, we may compute the entropy as\n\\begin{align*}\n\tH(S) &= - \\sum_{s \\in \\mathcal A} p_S(0) \\log_b \\bigl(p_S(0)\\bigr) \\\\\n\t&= \\underbrace{-P \\log P - (1-P) \\log(1-P)}_{h(P) \\text{ function of } P}\n\\end{align*}\nThis function $h(P)$ is called the \\textbf{binary entropy function}. \n\\end{defn}\n\nMany results in information theory are the consequence of the following inequality \\ref{thm:it-inequality}.\n\\begin{thm}[IT inequality]\\label{thm:it-inequality}\nLet $r > 0$. Then\n\\begin{equation}\n\t\\log_b(r) \\leq (r-1) \\log_b (e) % WHAT IS e\n\\end{equation}\nwith the equality iff r = 1.\n\\end{thm}\n\n\\begin{thm}[Entropy bounds]\nLet $s \\in \\mathcal A$. Then\n\\begin{equation}\n\t0 \\leq H(s) \\leq \\log_b |\\mathcal A|\n\\end{equation}\nwith the first inequality holding iff $S=\\text{const.}$, and the second inequality holding iff $p_S(s)=\\frac{1}{|\\mathcal A|}$.\n\\end{thm}\n\n\\begin{exmp}\n\tLet $S$ be your 4-digit lock number. Then $S = \\{0, 1, \\ldots, 9999\\}$. Let's say you choose your lock number at random: then $H(S) = \\log 10^4$. However, if your grandma \\ul{always} chooses $0000$, then $S$ is a constant, and $H(S) = 0$. A random (least predictable) choice has the most entropy possible ($\\log_b |\\mathcal A|$), and a constant (most predictable) choice has the least entropy (zero). This makes sense, and it also means that the random lock number carries the most information, and the constant one carries the least information.\n\\end{exmp}\n\n\\noindent Let's apply this to sources.\n\n\\subsection{Source coding}\nThe setup we have is the following: let's say we have a source emitting $S_i \\in \\mathcal A$ towards an encoder with an \\emph{encoding map} (a function $\\mathcal A \\to \\mathcal C$) called $\\Gamma$. We're going to map each element of the alphabet into a codeword, for example, each letter of the word \\texttt{dinner}. For example: d$\\to 000$, i$\\to 010$, \\dots \\\\\nThe encoder is specified by\n\\begin{itemize}\n\t\\item an input alphabet $\\mathcal A$, which is the alphabet of the source\n\t\\item an output alphabet $\\mathcal C$\n\t\\item the encoding map $\\Gamma : \\mathcal A \\to \\mathcal C$\n\\end{itemize}\nThe code is a set of codewords, which are the output of the $\\Gamma$ map. The $\\Gamma$ map is always one-to-one and onto (bijective), but this doesn't mean that we can necessarily go back from the code words to the words, since we usually concatenate the output.\n\n\\begin{exmp}\n Let $\\mathcal A = \\{\\texttt H, \\texttt E, \\texttt L, \\texttt O\\}$ and $\\mathcal C = \\{01, 10, 0, 11\\}$ ($\\Gamma$ maps them in the written order). Then $\\Gamma : \\mathcal A \\to \\mathcal C$ encodes the word \\texttt{HELLO} to the bitstring \\texttt{01100011}. The conversion is easy in this direction, but when trying to decode the message, we run into a difficulty: the bitstring could either be interpreted as \\texttt{01,10,0,0,11}, which would give back the correct message \\texttt{HELLO}, or as \\texttt{0,11,0,0,0,11}, which would give the incorrect message \\texttt{LOLLLO}.\n\\end{exmp}\n\n\\begin{defn}\n\tWe say that a code is \\textbf{uniquely decodable} if each concatenation of codewords has a unique parsing into codewords, that is, if we can be sure of getting the correct message when decoding a sequence of codewords. The kinds of encodings that give uniquely decodable codes are the ones that are most interesting in information encoding. \n\\end{defn}\n\n\\begin{exmp}\\label{exmp:first-codes}\nLet's have a look at a few different $\\Gamma$ mappings, and check whether they are uniquely decodable or not:\n\\begin{center}\n\t\\begin{tabular}{l | l l l l}\n\t\t$\\mathcal A$ & $\\Gamma_O$ & $\\Gamma_A$ & $\\Gamma_B$ & $\\Gamma_C$ \\\\ \\hline\n\t\t\\texttt a & 00 & 0 & 0 & 0 \\\\\n\t\t\\texttt b & 01 & 01 & 10 & 01 \\\\\n\t\t\\texttt c & 10 & 10 & 110 & 011 \\\\\n\t\t\\texttt d & 11 & 11 & 1110 & 0111\n\t\\end{tabular}\n\\end{center}\nThe code $\\Gamma_O$ \\textbf{is} uniquely decodable because of its constant codeword length: we will always group symbols two by two, which means that there is a single possible decoding. \\par\n \\noindent The code $\\Gamma_A$ \\textbf{is not} uniquely decodable: for example, if we have the sequence \\texttt{0110}, we could either decode it as \\texttt{01,10} which would mean ``\\texttt{bc}'', or as \\texttt{0,11,0} which would mean ``\\texttt{ada}''. \\par\n \\noindent The code $\\Gamma_B$ \\textbf{is} uniquely decodable, since 0 acts as a delimiter between codewords (suffix). \\par\n \\noindent The code $\\Gamma_C$ \\textbf{is} uniquely decodable, since 0 acts as a delimiter between codewords (prefix). \n\\end{exmp}\n\n Example \\ref{exmp:first-codes} showed us two cases of codes that have either a suffix or a prefix, and that are uniquely decodable. In fact, using prefixes and suffixes are a way to guarantee that a code is uniquely decodable; however, prefixes do come with a problem which we shall now discover.\n\n\\begin{defn}\n\tA code is said to be \\textbf{prefix-free} if no codeword is the prefix of a longer codeword. Prefix-free codes are preferred in encoding information. They are also called \\textbf{instantaneous codes}, since they allow instantaneous decoding.\n\\end{defn}\n\n Indeed, prefixes may seem like a good idea since they guarantee uniquely-decodable codes. The issue, however, with codes that are not prefix-free, is they are not ``instantaneously'' decodable: if you have only received part of the sequence of codewords, you cannot decode it, since there may be ambiguities. This is illustrated by the next example \\ref{exmp:prefixes-are-not-so-great}.\n\n\\begin{exmp}\\label{exmp:prefixes-are-not-so-great} Here's an example of why prefix codes are not the best in terms of decoding. The following code is uniquely decodable, but it uses a prefix:\n\\begin{center}\n\t\\begin{tabular}{l | l} \n\t\t$\\mathcal A$ & $\\Gamma$ \\\\ \\hline\n\t\t\\texttt a & 0 \\\\\n\t\t\\texttt b & 00001\n\t\\end{tabular}\n\\end{center}\nIf the decoder receives the sequence \\texttt{00}, it cannot instantaneously determine whether this is the start of a \\texttt{b} or two concatenated \\texttt{a}, and so it has to wait until it has the full string of bits to be able guarantee correct decoding. \\par\n In real life, this sort of problem shows up, for example, when streaming video or audio from the Internet, where it may cause unwanted delays. \n\\end{exmp}\n\nTheorem \\ref{thm:kraft-mcmillan-1} comes in very handy when trying to determine whether a code is uniquely decodable or not.\n\n\\begin{thm}[Kraft-McMillan 1]\\label{thm:kraft-mcmillan-1}\n\tIf a $D$-ary code is uniquely decodable, then its codeword lengths $l_1, l_2, \\ldots, l_M$ satisfy the following inequality:\n\\begin{equation}\n\tD^{-l_1} + \\dots + D^{-l_M} \\leq 1 \\quad \\text{(Kraft's inequality)}\n\\end{equation}\n\\begin{remark}\nKraft's sum is only about the lengths of the codewords!\n\\end{remark}\n\\end{thm}\nDo be wary that this theorem is an ``if-then'' theorem, which means that the converse may not be true! Such a case is illustrated by example \\ref{exmp:kraft-mcmillan-1-converse}.\n\n\\begin{exmp}\\label{exmp:kraft-mcmillan-1-converse}\nLet's look at the following code:\n\\begin{center}\n\t\\begin{tabular}{l | r}\n\t$\\mathcal A$ & $\\mathcal C$ \\\\ \\hline\n\t\\texttt a & \\texttt{01} \\\\\n\t\\texttt b & \\texttt{0101}\t\n\t\\end{tabular}\n\\end{center}\n\tThis is a 2-ary (binary) code with lengths 2 and 4, so Kraft's sum gives\n\t\\begin{equation*}\n\t\t2^{-2} + 2^{-4} = \\frac14 + \\frac{1}{16} = \\frac{5}{16} \\leq 1,\n\t\\end{equation*}\n\tand Kraft's inequality is satisfied, however the code is clearly \\textbf{not} uniquely decodable.\n\\end{exmp}\n\n\\section{28th February 2019}\n\nThese following properties are what we aim for with any encoding map $\\Gamma : \\mathcal A \\to \\mathcal C$, in order to optimize transmission and decoding speed:\n\\begin{itemize}\n\t\\item $\\mathcal C$ be uniquely decodable\n\t\\item $\\mathcal C$ be prefix-free\n\t\\item $\\mathcal C$ have its average codeword length be as small as possible\n\\end{itemize}\n\n\\begin{thm}[Kraft-McMillan 2]\nIf $l_1, \\ldots, l_m$ satisfy Kraft's inequality for some positive integer $D$, then there exists a $D$-ary prefix-free code that has codeword  lengths $l_1, \\ldots, l_m$.\n\\end{thm}\n\nThis second part of the Kraft-McMillan theorem guarantees that \\emph{any} uniquely decodable code can be substituted by a prefix-free code of the same codeword lengths.\n\\begin{summary}[Kraft-McMillan] The theorem is in 2 parts:\n\t\\begin{enumerate}\n\t\t\\item If a $D$-ary code is uniquely decodable, then its codeword lenghts $l_1, \\ldots, l_M$ satisfy Kraft's inequality\n\t\t\\begin{equation*}\n\t\tD^{-l_1} + \\dots + D^{-l_M} \\leq 1.\n\t\t\\end{equation*}\n\t\t\\item If the positive integers $l_1, \\ldots, l_M$ satisfy Kraft's inequality for some integer $D$, then there exists a $D$-ary \\ul{prefix-free} code that has those codeword lengths.\n\t\\end{enumerate}\n\\end{summary}\n\n\\begin{defn}\nWe define the \\textbf{average length} $L(S, \\Gamma)$ as\n\t\\begin{equation}\n\t\tL(S, \\Gamma) = \\sum_{S \\in \\mathcal A} p_S(s) \\underbrace{l \\bigl(\\Gamma(s)\\bigr)}_{{\\mathclap{\\text{shorthand } l(s)}}}.\n\t\\end{equation}\n\tSometimes we write\n\t\\begin{equation}\n\t\tL(S, \\Gamma) = \\sum_i p_i l_i.\n\t\\end{equation}\nThis is rather intuitively defined, as the expected length should according to common sense indeed depend on the length of each codeword, and on its probability of appearing in the code. \\\\\nThe units of the average length are \\textbf{code symbols}. When $D = 2$, the units are \\textbf{bits}.\n\\end{defn}\n\nAn interesting question we may now ask ourselves is the following: is there a lower bound to the average length for uniquely decodable codes?\n\n\\begin{thm}[lower bound on average length]\n\tLet $\\Gamma$ be the encoding map of a $D$-ary code for the source $S$. If the $D$-ary code is uniquely decodable, then\n\t\\begin{equation}\n\t\tH_D(S) \\leq L(S, \\Gamma).\n\t\\end{equation}\n\t\\textbf{The entropy is a lower bound to the average length}.\n\\end{thm}\n\n\\begin{remark}\n\tA key observation we may make is that the definition of the average length is somewhat similar to that of the entropy:\n\t\\begin{align*}\n\t\t&L(S, \\Gamma) = \\sum_{s \\in \\mathcal A} p(s) l(\\Gamma(s)) \\\\\n\t\t&H_D(S) = \\sum_{s \\in \\mathcal A} p(s) \\log_D \\left(\\frac{1}{p_S(s)}\\right)\n\t\\end{align*}\nIn fact, the definitions are identical iff $l(\\Gamma(s)) = \\log_D \\left(\\frac{1}{p_S(s)}\\right)$. Unfortunately this equality is often not possible (the $\\log$ is often not an integer). But what if we chose $l(\\Gamma(s)) = \\left\\lceil \\log_D \\left(\\frac{1}{p_S(s)}\\right) \\right\\rceil$? Is it a valid choice for a prefix-free code (is Kraft's inequality satisfied)?\n\\end{remark}\n\n\\begin{defn}[Shannon-Fano code]\n\tA code $\\mathcal C$ for which $l_i = \\left\\lceil -\\log_D \\bigl(P_S(s) \\bigr) \\right\\rceil$ is called a \\textbf{Shannon-Fano code}. Visually, it is constructed by going from the top down when creating the code tree.\n\\end{defn}\n\\begin{remark}\n\tThe Shannon-Fano code is not always optimal, in the sense that its average codeword length is not always the best. This means that it is a lot less used than the Huffman code which we will see later, and which always gives optimal codes.\n\\end{remark}\n\n\n\\begin{defn}\n\tWe say that a probability distribution is \\textbf{diadic} iff\n\t\\begin{equation}\n\t\tp_i = D^{-l_i}\n\t\\end{equation}\n\\end{defn}\n\n\\begin{thm}\n\tIt is possible to make the codewords lengths $l_i$ equal the entropy iff the code is diadic.\n\\end{thm}\n\nCLEAR UP THE THING ABOUT THE $-\\log_D(p_i)$ THAT I DONT UNDERSTAND\n\n\\begin{remark}\n\tMost probability distributions are not diadic. Then, $-\\log_D(p_i)$ is not an integer, and we can't make the length equal that number. \\par\n\tThe only cases where a Shannon-Fano code is optimal is when the probability distribution is diadic (CHECK IF THIS IS CORRECT).\n\\end{remark}\n\n\\begin{defn}[Huffman code]\n Visually, the Huffman code on an alphabet is constructed by going from the bottom up when creating the code tree, and grouping together the least probable symbols.\n\\end{defn}\n\n\\begin{exmp} (COMPLETE WITH THE PROBABILITY DISTRIBUTION) The Huffman code on $\\mathcal A = \\{\\texttt a, \\texttt b, \\texttt c, \\texttt d\\}$ is:\n\t\\begin{center}\n\t\\begin{tabular}{r | l}\n\t\t$\\mathcal A$ & $\\Gamma_H$ \\\\ \\hline\n\t\t\\texttt a & \\texttt{000} \\\\\n\t\t\\texttt b & \\texttt{001} \\\\\n\t\t\\texttt c & \\texttt{01} \\\\\n\t\t\\texttt d & \\texttt{1}\n\t\\end{tabular}\n\t\\end{center}\n We can compute the expected length and the entropy (in bits):\n\t\\begin{align*}\n\t\t&L(S, \\Gamma_H) = 0.15 + 0. 15 + 0.2 + 0.8 = 1.3 \\\\\n\t\t&H_2(S) = \\ldots = 1.022\n\t\\end{align*}\n\\end{exmp}\n\n\\section{5th March 2019}\n\n\\begin{thm}\n\tThe average length can also be computed by adding together the probabilities of all nodes on the code tree, except for the last leaves:\n\t\\begin{equation}\n\t\t\\underbrace{\\sum_{\\substack{i \\in \\\\ \\text{terminal} \\\\ \\text{leaves}}}}_{L(S, \\Gamma)} = \\quad \\sum_{\\mathclap{\\substack{j \\in \\\\ \\text{intermediate} \\\\ \\text{nodes}}}} q_j.\n\t\\end{equation}\n\\end{thm}\n\n\\begin{thm}[optimality of Huffman codes]\n\tLet $\\Gamma_H$ be an encoder of a $D$-ary Huffman code for $S$, and let $\\Gamma$ be another $D$-ary uniquely decodable encoder for $S$. Then\n\t\\begin{equation}\n\t\tL(S, \\Gamma_H) \\leq L(S, \\Gamma).\n\t\\end{equation}\n\tBasically, the Huffman code on $S$ is the optimal code on $S$.\n\\end{thm}\n\n\n\\subsection{}\n\n\\begin{defn}[IID source]\n\tA source is said to be \\textbf{IID} (Independant and Identically Distributed) iff all random variables are mutually independent and have the same probability distribution. \n\\end{defn}\nMost sources are not IDD.\n\n\\begin{exmp}\n\tA sequence of coin flips is an IID source.\n\\end{exmp}\n\n\\begin{exmp}\n\tLet $S_1, S_2 \\in \\{1, 2, \\ldots, 6\\}$ represent dice throws. They are independant and uniformly distributed. Let $(L_1, L_2)$ be the first and second digit of the sum $S_1 + S_2$. We can compute $P_{L_1 | L_2} (1|1) = \\frac{P_{L_1 | L_2}(1, 1)}{P_{L_1}(1)}$. We know that the event $(L_1, L_2) = (1, 1)$ is the same as the event $S_1 + S_2 = 11$, which is the same as saying $(S_1, S_2) \\in \\{(5, 6), (6, 5)\\}$, which has probability $2/36$. Then the conditional probability that we wanted to compute is\n\t\\begin{align*}\n\t\t\\frac{2/36}{3/36 + 2/36 + 1/36} = \\frac13\n\t\\end{align*}\n\\end{exmp}\n\n\\begin{defn}[conditional entropy]\n\tLet $p_X$ be the probability distribution of a random variable $X$. We already know how to compute the entropy $H(x)$ from this probability distribution. Then $p_{X|Y=y}$, which is also a probability distribution, allows us to compute the \\textbf{conditional entropy} $H(X|Y=y)$:\n\t\\begin{equation}\n\t\tH_b(X|Y=y) = - \\sum_{x \\in X} p_{X|Y}(x|y) \\log_b \\bigl(p_{X|Y}(x|y)\\bigr)\n\t\\end{equation} \t\n\\end{defn}\n\n\\begin{exmp}[continuation]\nCOMPLETE THIS FROM THE NOTES :DDDDDDDDDDDDDDD I AM GOING INSANE AND 2 HOURS LEFT :DDDDDDDDDDD\n\\end{exmp}\n\n\\section{7th March 2019}\n\nIS THE ENTROPY EQUAL TO THE AVERAGE LENGTH IFF IT IS A HUFFMAN CODE?\n\n\\begin{thm}\n\tLet $X$ and $Y$ be two random variables. Then\n\t\\begin{equation}\n\t\tH(X|Y) \\leq H(X),\n\t\\end{equation}\n\twith the equality iff $X$ and $Y$ are independent.\n\\end{thm}\n\n\\begin{thm}[chain rule of entropy]\n\tLet $S_1, \\ldots, S_n$ be random variables. Then\n\t\\begin{equation}\n\t\t\\boxed{H(S_1, \\ldots, S_n) = \\sum_{i=1}^n H(S_1 | S_1, \\ldots, S_{i-1})}\n\t\\end{equation}\n\\end{thm}\n\n For this to make a bit more sense, recall that $P_{X, Y}(x, y) = P_X(x)P_{Y|X}(y|x)$ (this follows directly from the definition of conditional probability). More generally, \n \\begin{equation*}\n P_{S_1, \\ldots, S_n}(s_1, \\ldots, s_n) = \\prod_{i=1}^n P_{S_i | S_1, \\ldots, S_{i-1}}(s_i | s_1, \\ldots, s_{i-1}).\n \\end{equation*}\n The chain rule of entropy is very similar. \\par\n This equality will help us in proving many theorems.\n \n \\begin{exmp}[continuation]\n \t$H(l_1) = 0.65$ bits, $H(l_2) = 3.2188$ bits, $H(l_1, l_2) = 3.744$ bits, $H(l_2 | l_1) = H(l_1, l_2) - H(l_1) = 2.624$ bits (as obtained before).\n \\end{exmp}\n \n \\begin{exmp}[continuation]\n \tWe saw that $(S_1, S_2)$ determine $(l_1, l_2)$. Then what is $H(l_1, l_2 | S_1, S_2)$? We can know that $H(l_1, l_2 | (S_1, S_2) = (s_1, s_2)) = 0$. This is because $(S_1, S_2)$ fully determine $(l_1, l_2)$ (they are NOT independent). As such, when we know that $(S_1, S_2) = (s_1, s_2)$, we know exactly and can \\emph{predict} the only possible digits $(l_1, l_2)$ of the sum of $s_1$ and $s_2$, which means that there is no entropy here. \\\\\n \tSuppose we know $H(l_1, l_2)$ and $H(S_1, S_2)$. Then we can compute $H(S_1, S_2 | l_1, l_2)$:\n \t\\begin{align*}\n \t\t&H(S_1, S_2, l_1, l_2) \\overbrace{=}^{\\substack{\\text{chain} \\\\ \\text{rule}}} \\begin{cases} H(S_1, S_2) + \\cancel{H(l_1, l_2 | S_1, S_2)} \\\\\n \t\t\t\t\t\t\t\t\t\t\t\t\t  H(l_1, l_2) + H(S_1, S_2 | l_1, l_2)\n \t\t\t\t\t\t\t\t\t\t\t\t\t  \\end{cases} \\\\\n\t\t&\\implies H(S_1, S_2, | l_1, l_2) = H(S_1, S_2) - H(l_1, l_2), \\quad \\text{which we both know by supposition.}\n \t\\end{align*}\n \\end{exmp}\n \n \\begin{exmp}\n \tLet's say we have a random variable $X$ which takes a value in $\\{0, +1, -1, +2, \\ldots, +13, -13\\}$. Suppose $X$ is uniformly distributed. Any weighing strategy (not yet determined) is an encoding $\\Gamma: \\mathcal A \\to \\mathcal C$ ($|\\mathcal C| = 3$, so this is a $3$-ary code). $\\Gamma$ is a bijective function $x \\leftrightarrow s_1 s_2\\ldots s_L$. So $H_3(x) = H_3(S_1, S_2, \\ldots S_L)$.\n \\end{exmp}\nNOTES: a negative number means \"light\" on the balance, a positive number means it is \"heavy\". At each step of the guessing process, he makes sure that the new balance is independent of previous knowledge, and that it is evenly distributed (even chances of going on each side). Actually the balls are billiard.\n One coould be heavier or lighter, ut not the 0 ball. You have a balance for balls. How many times to weigh to determine if one bakk us fakse and if yes, which one and settle if it is heavier or lighter.\n\n\\section{12th March 2019}\nSo far, we have assumed that we have a random variable over the alphabet $\\mathcal A$, an encoding function $\\Gamma$ which is a map $\\mathcal A \\to \\mathcal C$, from the alphabet to the code (which was assumed to be uniquely decodable), and a source outputting a sequence of $n$ random variables. We saw that if this source is IID, then the total length divided by $n$ will tend to $L(S, \\Gamma)$ as $n \\to \\infty$. We saw that the entropy is a lower bound to the average length. \\par\nWe will now drop the assumption that the source is IID: this is very common, for example, when you try to compress voice, or video, or any kind of \"natural\" information. \n\n\\begin{exmp}\n\tWe reuse the example of the coin flip source: $S_i \\in \\{H, T\\}$. $S_1, S_2, \\ldots, S_n$ are IID. Therefore \n\t\\begin{equation*}\n\tp_{S_1, S_2, \\ldots, S_n}(s_1, s_2, \\ldots, s_n) = \\prod_{i=1}^n p_{S_i}(s_i) = \\bigl(\\frac12\\bigr)^n\n\t\\end{equation*}\n\\end{exmp}\n\n\\begin{defn}\n\tThe source $\\mathcal S = S_1 S_2 \\ldots S_n$ is said to be \\textbf{regular} iff\n\t\\begin{enumerate}\n\t\t\\item $H(\\mathcal S) = \\lim_{i \\to \\infty} H(S_i)$ (the entropy per symbol) exists, and\n\t\t\\item $H^*(\\mathcal S) = \\lim_{i \\to \\infty} H(S_i | S_1, \\ldots, S_{i-1})$ (the entropy rate) exists.\n\t\\end{enumerate}\n\\end{defn}\n\n\\begin{exmp}[cont.]\n\tThe coin flip source is regular:\n\t\\begin{equation*}\n\t\tH(\\mathcal S) = 1 = H^*(\\mathcal S)\n\t\\end{equation*}\n\\end{exmp}\n\n\\label{exmp:sunnyrainymarkov}\\begin{exmp}[Sunny-Rainy source]\n\t$S_i \\in \\{S, R\\}$ represents the weather on day $i$. $S_i$ is uniformly distributed. If the weather one way one day, it will stay the same tomorrow with probability $q$, and change with probability $1-q$.\n\t\\begin{equation*}\n\t\tp_{S_1, \\ldots, S_n} (s_1, \\ldots, s_n) =  p_{S_1}(s_1) \\cdot \\prod_{i = 2}^n p_{S_i | S_{i-1}}(s_i | s_{i-1}).\n\t\\end{equation*}\n\tFor example, $p_{S_1, S_2, S_3, S_4} (RRSR) = \\frac12 \\cdot q \\cdot (1-q) \\cdot (1-q)$. More generally, $p_{S_1, \\ldots, S_n}(s_1, \\ldots, s_n) = \\frac12 \\cdot (1-q)^c \\cdot q^{n-1-c}$, where $c$ is the number of transitions. \\par\n\tWe may also check whether the source is regular or not. $H(S_i) = H(S_1) = 1$, therefore the entropy per symbol exists and equals $1$. Let us also compute $H(S_i | S_{i-1})$. We know that $H(S_i | S_{i-1} = R) = h(q)$ and $H(S_i | S_{i-1} = S) = h(1-q) = h(q)$ (where $h$ is the binary entropy function, that is, the entropy function adapted to binary bernouilli trials, which is intuitively symmetrical with regards to $1/2$). Finally $H(S_i | S_{i-1}) = h(q) = H(S_1 | S_{i-1}, \\ldots, S_1)$ (the outcomes before the previous day do not have any effect). Therefore the entropy rate exists, and is equal to $h(q)$.\n\\end{exmp}\n\n\\begin{defn}\n\tA Markov chain is the simplest kind of source which has some memory: each random variable depends only on the state of the one immediately preceding it.\n\\end{defn}\n\\begin{remark}\n\tThe source in example \\ref{exmp:sunnyrainymarkov} is a Markov chain.\n\\end{remark}\n\n\\begin{defn}\n\tA source $S_1,  S_2 \\ldots, S_i \\in \\mathcal A$, is \\textbf{stationary} if for every $n, k$ positive integers, the statistic of $(S_1, \\ldots, S_n)$ is the same as the statistic of $(S_{k+1}, \\ldots, S_{k+n})$. Formally,\n\t\\begin{equation}\n\t\tp_{S_1, \\ldots, S_n}(s_1, \\ldots, s_n) = P_{S_{k+1}, \\ldots, S_{k+n}}(s_1, \\ldots, s_n).\n\t\\end{equation}\n\\end{defn}\n\n\\begin{thm}\n\tA stationary source is always regular.\n\\end{thm}\n\n\\begin{thm}\n\tFor a stationary source $\\mathcal S$,\n\t\\begin{equation}\n\t\tH^*(\\mathcal S) \\leq H(\\mathcal S),\n\t\\end{equation}\n\twith equality iff the symbols are independent.\n\\end{thm}\n\n\\section{14th March 2019}\n\tWhat if, instead of encoding codewords one at a time, we encoded concatenations of codewords?\n\n\\begin{equation}\n\t\\boxed{H_D(S) \\leq L(S, \\Gamma_H) \\leq L(S, \\Gamma_{SF}) < H_D(S) + 1}\n\\end{equation}\nThis inequation is not directly related but muchho importanto in source coding. We can tho adapt it to block-encoding (idk how it's called):\n\\begin{equation}\n\tH_D(S_1 \\ldots S_n) \\leq L(\\mathcal S, \\Gamma_H) \\leq L(\\mathcal S, \\Gamma_{SF}) < H_D(S_1 \\ldots S_n) + 1\n\\end{equation}\nIf we divide everything by $n$ to get the average codeword length per symbol:\n\\begin{equation}\n\t\\frac{H_D(S1 \\ldots S_n)}{n} \\leq \\frac{L(\\mathcal S, \\Gamma_H)}{n} < \\frac{H_D(S_1 \\ldots S_n)}{n} + \\frac1n\n\\end{equation}\nThe $\\frac1n$ goes to 0 as $n$ grows large. \\par\nOur goals: study the behavior of $\\frac{H_D(S_1 \\ldots S_n)}{n}$ as $n$ grows large and try to relate it to $H_D^*(\\mathcal S)$ (entropy rate).\n\n\\begin{exmp}\n\tConsider a monkey source $S$ that randomly picks one letter at a time from a French book. $H(S) = 3.95$ bit2\ts, so a Huffman code $\\Gamma_H$ approaches $L(S, \\Gamma_H) \\approx 4$ bits/letter when encoding French monkey text. \\par \n\tHowever, a Lempel-Ziv code (used by various compression programs) approaches 1 bit per letter when compressing French text. This is due to the fact that letters in a French text are not completely random, therefore the entropy goes down by quite a bit, and beat the Huffman code. \\par\n\tThis means that as $n$ grows large, $\\frac{H_D(S_1 \\ldots S_n)}{n} \\to 1$. This, rather than $H(S)$, is the important quantity for us. \\par\n\tIf $S_1 \\ldots S_n$ were IID, then\n\t\\begin{equation*}\n\t\t\\frac{H_D(S_1 \\ldots S_n)}{n} = \\frac{H_D(S_1) \\cdot H_D(S_2) \\ldots H_D(S_n)}{n} = H(S_1) \\quad \\forall 1 \\leq i \\leq n\n\t\\end{equation*}\n\tImagine you start with the text from a book, and take the alphabet of that book (all symbols that appear in it). You put these in a table and assign an integer to each (the position in the table), in binary. You then start looking for groups of 2 letters, and if you find some, you add them to the dictionary, so $n$ increases (it has a limit). Same thing for 3 symbols, or groups that appear often. \n\\end{exmp}\n\n\\begin{thm}[Cesàro mean]\n\tConsider a source of real-valued numbers $a_1 \\ldots a_n$. If $\\lim_{n \\to \\infty} a_n = A$, then if $c_n = \\frac{a_1 + a_n}{n}$, we have that $\\lim_{n \\to \\infty} c_n = A$.\n\\end{thm}\n\n\\begin{thm} Let $S$ be a source. Then\n\t\\begin{enumerate}\n\t\t\\item if $S$ is stationary, then $S$ is regular,\n\t\t\\item $\\frac{H_D(S_1 \\ldots S_n)}{n}$ is non-increasing in $n$,\n\t\t\\item $\\lim_{n \\to \\infty} \\frac{H_D(S_1 \\ldots S_n)}{n} = H_D^*(S)$.\n\t\\end{enumerate}\n\\end{thm}\n\n\\begin{summary}\n\tLet $S$ be a stationary source outputting an infinite sequence of symbols $S_1 \\ldots S_n$. By encoding blocks of $n$ keywords at a time using a $D$-ary code, the average codeword length per symbol approaches $H^*(S)$ as $n$ grows large. No uniquely decodable $D$-ary code can do better than $H^*(S)$.\n\\end{summary}\n\n\n\\begin{exmp}[The 20 Questions Game]\n\tWas a very popular game on UK and US TV. You ask questions where the answers are yes or no. Equivalent to a binary search (akinator). \\par\n\tLet $X$ be a random variable. Question: how many YES/NO questions do we need to find the realization of $X$, how should we ask the questions? \\par\n\tThe idea is to build a binary code $\\Gamma$ for $X$. Once $\\Gamma$ is fixed, identify the realization of $X (= \\bar X)$, which is equivalent to finding $\\Gamma(\\bar X)$. The $i$-th question should reveal the $i$-th bit of $\\Gamma(\\bar X)$. The average number of questions should be the average codeword length of $\\Gamma$. If $\\Gamma$ is $\\Gamma_H$, we cannot do better in terms of the average number of questions. \\par\n\tLet us consider a random variable $X$ with $\\mathcal A = \\{a, b, c, d, e\\}$, $p(a) = 0.1, p(b) = 0.1, p(c) = 0.2, p(d) = 0.2, p(e) = 0.4$. After its construction, the Huffman code is $a = 000, b = 001, c = 010, d = 011, e = 1$. Let's ask some questions from the top of the tree:\n\t\\begin{enumerate}\n\t\t\\item is $X = e$ ? NO $\\Rightarrow$ the first bit of $X$ is 0.\n\t\t\\item is $X \\in \\{c, d\\}$ ? NO $\\Rightarrow$ the second bit of $X$ is 0.\n\t\t\\item is $X = b$ ? YES $\\Rightarrow$ the third bit of $X$ is 1.\n\t\\end{enumerate}\n\tTherefore, $X = 001 = b$. \\par\n\tLet us now discuss the optimality of this strategy. We have seen that a binary code (prefix-free) implies a question strategy, and that $\\Gamma_H$ gave the best strategy, since the average number of questions is equal to the average codeword length of $\\Gamma$. \\par\n\tQuestion: does a questioning strategy (YES/NO) as above always lead to a prefix-free code? \\par\n\tWe start with the root: let $X \\in \\mathcal X$ be a random variable. Split $\\mathcal X$ into $\\mathcal A$ and $\\mathcal A^c$ (complement) and suppose that $X \\in \\mathcal A$. When we ask the question, we will know in which of the two it is. Suppose that the answer is yes: then $X \\in \\mathcal A$. Continue by splitting $\\mathcal A$ into $\\mathcal B$ and $\\mathcal B^c$ and repeat the process. By construction, we obtain a prefix-free code.\n\\end{exmp}\n\nENCODING OF INTEGERS: we saw that the Lempel-Ziv code needed to encode integers. Let's think about some binary prefix-free codes for positive integers. \\par\nThe first one is the \"natural\" way, that is, encoding each number into its binary representation. However, this is not good, because it is not prefix-free, and has $l(n) = \\lfloor \\log(n) \\rfloor + 1$. \\par\n The next try (elias code 1) would be adding $l(n) - 1$ zeros in front of each codeword $n$. This is prefix-free, but it is pretty long: $l(n) = 2 \\lfloor \\log(n) \\rfloor + 1$. \\par\n The next try (elias code 2) would be replacing the leading zeros and the following one by $c_1(l(n)$ ($c_1 =$ elias code 1). Then we get a ITS PI DAY PEOPLE \\par\n3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117\\\\ 0679821480132823066470\n\n\\begin{summary}[Source Coding]\n\\begin{itemize}\n\t\\item If a $D$-ary code is UD for source $S$,\n\t\\begin{equation*}\n\t\tH_D(S) \\leq L(S, \\Gamma) < H_D(S) + 1\n\t\\end{equation*}\n\tThe first inequality comes from Kraft's sum and the IT inequality. \\\\\n\tThis also applies to $\\bar S = S_1S_2\\ldots S_n$:\n\t\\begin{align*}\n\t\t&H_D(\\bar S) \\leq L(\\bar S, \\Gamma) < H_D(\\bar S) + 1 \\\\\n\t\t&\\iff \\\\\n\t\t&\\frac{H_D(\\bar S)}{n} \\leq \\frac{L(\\bar S, \\Gamma)}{n} < \\frac{H_D(\\bar S)}{n} + \\frac1n\n\t\\end{align*}\n\t(we divided by $n$ to get the entropy per symbol). The second and last terms (without $\\frac1n$, which tends to 0 as $n \\to \\infty$) tend to $H^*(\\bar S)$ if the source is stationary.\n\t\\item For encoding integers, we saw the Elias code (UD), which encodes $n \\in \\mathbb N$ with $\\approx \\log_2 n + 1$ bits. \n\t\\item Among other things, we have left out what's called \"universal source coding\" (example in the notes), for example Lempel-Ziv and Elias-Willens.\n\\end{itemize}\n\\end{summary}\n\n\\chapter{Cryptography}\n\\section{19th March 2019}\nThe two main goals of Cryptography are \\textbf{authenticity} and \\textbf{privacy}. Authenticity means we should be assured that we are indeed sharing information with the correct person/computer. Privacy means that no other party should be able to see the shared information. \\\\\n Until just about when the internet was invented, criptography was basically only used by generals and diplomats. The advent of public Internet made cryptography into a branch/tool that was used universally and constantly by every person and/or machine on the Internet.\n\n\\subsection{Setup for privacy}\nThe idea is the following: We have two \"private spaces\", one for Alice and one for Bob. Alice wants to send some plain text, call it $t$, to Bob. It goes through an encryption device, which requires a key $k_A$, and which is located in Alice's \"private space\". The encrypted message, $c$, also called cryptogram or ciphertext. is then sent to Bob's private space, but has to go through an unprotected zone called the public channel. \\\\\n The public channel is being eavesdropped by Eve. We cannot block Eve from accessing $c$, therefore our only way of guaranteing privacy is by making $c$ undecryptable by Eve, or rather, only decryptable by Bob.\n \n\\section{Rudiments of Number Theory}\nThe RSA encryption system relies on number theory. We want to work with a finite set of numbers, since this will make everything much easier on a computer. \\par\n\nActually, on second thought, fuck cryptography. I'll meet you again when we're doing channel coding.\n\n\\end{document}\n", "meta": {"hexsha": "c8db438c31038be45d75b26e0a4e643ee51758a3", "size": 45680, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "BA2/aicc2/aicc2-rimoldi-summary.tex", "max_stars_repo_name": "betrisey/almighty-handbook-of-sleep-deprived-student", "max_stars_repo_head_hexsha": "6fbe6f73f9ca438cfd9e9213e4363effe3ceabdd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2018-11-18T22:16:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-22T20:58:19.000Z", "max_issues_repo_path": "BA2/aicc2/aicc2-rimoldi-summary.tex", "max_issues_repo_name": "betrisey/almighty-handbook-of-sleep-deprived-student", "max_issues_repo_head_hexsha": "6fbe6f73f9ca438cfd9e9213e4363effe3ceabdd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "BA2/aicc2/aicc2-rimoldi-summary.tex", "max_forks_repo_name": "betrisey/almighty-handbook-of-sleep-deprived-student", "max_forks_repo_head_hexsha": "6fbe6f73f9ca438cfd9e9213e4363effe3ceabdd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-11-18T22:16:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-12T23:15:43.000Z", "avg_line_length": 62.7472527473, "max_line_length": 714, "alphanum_fraction": 0.7142294221, "num_tokens": 14613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.40364088563467315}}
{"text": "\n\n    \\filetitle{datrange}{Numerically safe way to create a date range}{dates/datrange}\n\n\t\\paragraph{Syntax}\\label{syntax}\n\n\\begin{verbatim}\nRng = datrange(Start,End)\nRng = datrange(Start,End,Step)\n\\end{verbatim}\n\n\\paragraph{Input arguments}\\label{input-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{Start} {[} numeric {]} - Start date of the range.\n\\item\n  \\texttt{End} {[} numeric {]} - End date of the range.\n\\item\n  \\texttt{Step} {[} numeric {]} - Step size in the number of base\n  periods; if omitted, \\texttt{Step = 1}.\n\\end{itemize}\n\n\\paragraph{Output arguments}\\label{output-arguments}\n\n\\begin{itemize}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item\n  \\texttt{Rng} {[} numeric {]} - Date vector\n  \\texttt{Start : Step : End}.\n\\end{itemize}\n\n\\paragraph{Description}\\label{description}\n\nMost of the time, using a colon operator to create a date range works\nfine,\n\n\\begin{verbatim}\nStart : Step : End\n\\end{verbatim}\n\nUnder some rare circumstances, the colon operator may bump into round\nerror difficulties as IRIS serial date numbers are non-integer values.\nIn that case, the function \\texttt{datrange} provides a safe workaround:\n\n\\begin{verbatim}\ndatrange(Start,End,Step)\n\\end{verbatim}\n\nis equivalent (but numerically safer) to\n\n\\begin{verbatim}\nStart : Step : End\n\\end{verbatim}\n\n\\paragraph{Example}\\label{example}\n\nThe date ranges created in this example are identical, and no numerical\ninaccuracies exist:\n\n\\begin{verbatim}\nr1 = qq(2000,1) : qq(2010,4);\nr2 = datrange(qq(2000,1),qq(2010,4));\nformat long\nr1 - r2\n\\end{verbatim}\n\n\n", "meta": {"hexsha": "234d0dec4f715686baa95a7d419d9bd6007ee1aa", "size": 1530, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/dates/datrange.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/dates/datrange.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/dates/datrange.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 22.1739130435, "max_line_length": 85, "alphanum_fraction": 0.7300653595, "num_tokens": 461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.40364087909006924}}
{"text": "\n\n\n\n\\section{CHAPTER 10}\n\n\n\\subsubsection{\n\\subsection{Section 10.1}}\n\n*************\n1.\n*************\n<answer><p> The number of trees are: (a) 1, (b) 3, and (c) 16.  The trees that connect \\(V_c\\) are:\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  \\textit{ Hint:} Use induction on \\(\\left| E\\right|\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) Assume that \\((V,E)\\) is a tree with \\(\\left| V\\right| \\geq 2\\), and all but possibly one vertex in <m>V</m> has degree two or more.\n\n\n\n\\(2\\left| E\\right| =\\sum \\text{\\textit{$\\deg  (v)$}}\\text{\\textit{$\\geq $}}\\text{\\textit{$2\\left| V\\right| $}}\\text{\\textit{$-$}}1\\\\\n\\\\\n\\quad v\\in V\\\\\n\\\\\n\\text{or}\\text{  }\\left| E\\right| \\geq \\left| V\\right| -\\frac{1}{2}\\Rightarrow \\left| E\\right| \\geq \\left| V\\right| \\Rightarrow (V,E) \\text{is} \\text{not}\na \\text{tree}.\\)\n\n</p></li>\n<li><p> The proof of this part is similar to part a in that we get \\(2\\left| E\\right| \\geq 2\\left| V\\right| -1\\), since a tree that is not a chain has\na vertex with degree three or more.\n\n\n\n\n\\subsection{Section 10.2}\n\n*************\n1.\n*************\n<answer><p> It might not be most economical with respect to Objective 1. You should be able to find an example to illustrate this claim. The new system can\nalways be made most economical with respect to Objective 2 if the old system were designed with that objective in mind.\n</p></answer>\n\n\n*************\n3\n*************\n<answer><ol><li><p>Edges in one solution are: \\(\\{8,7\\},\\{8,9\\},\\{8,13\\},\\{7,6\\},\\{9,4\\},\\{13,12\\},\\{13,14\\},\\{6,11\\},\\{6,1\\},\\{1,2\\},\\{4,3\\},\\{4,5\\},\\{14,15\\},\n\\textrm{ and } \\{5,10\\}\\)</p></li>\n<li><p> Vertices 8 and 9 are at the center of the graph. Starting from vertex 8, a minimum diameter spanning tree is \\(\\{\\{8, 3\\}, \\{8, 7\\}, \\{8, 13\\},\n\\{8, 14\\}, \\{8, 9\\}, \\{3, 2\\}, \\{3, 4\\}, \\{7, 6\\}, \\{13, 12\\}, \\{13, 19\\}, \\{14, 15\\}, \\{9, 16\\}, \\{9, 10\\}, \\{6, 1\\}, \\{12, 18\\}, \\{16, 20\\}, \\{16,\n17\\}, \\{10, 11\\}, \\{20, 21\\}, \\{11, 5\\}\\}. \\text{The} \\text{diameter} \\text{of} \\text{the} \\text{tree} \\text{is} 7.\\)\n</p></li></ol></answer>\n\n\n\n\n\\subsection{Section 10.3}\n\n*************\n1.\n*************\n<answer><p> Locate any simple path of length \\textit{ d }and locate the vertex in position \\(\\lceil d/2\\rceil\\)on the path. The tree rooted at that vertex\nwill have a depth of \\(\\lceil d/2\\rceil\\), which is minimal.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\n\n\n\n\n\n\\subsection{Section 10.4}\n\n*************\n1.\n*************\n<answer><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\n\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  \\(\\begin{array}{cccc}\n   &amp; \\text{Preorder}  &amp; \\text{Inorder}\\text{   } &amp; \\text{Postorder} \\\\\n (a)\\text{   } &amp; \\cdot a+\\text{\\textit{bc}}\\text{\\textit{      }} &amp; a\\cdot b+c\\text{   } &amp; \\text{\\textit{abc}}+\\cdot \\text{     } \\\\\n (b)\\text{   } &amp; +\\cdot \\text{\\textit{abc}}\\text{\\textit{      }} &amp; a\\cdot b+c\\text{    } &amp; \\text{\\textit{ab}}\\cdot c+\\text{     } \\\\\n (c)\\text{   } &amp; +\\cdot \\text{\\textit{ab}}\\cdot \\text{\\textit{ac}}\\text{\\textit{$ $}} &amp; a\\cdot b+a\\cdot c\\text{  } &amp; \\text{\\textit{ab}}\\cdot \\text{\\textit{ac}}\\cdot\n+  \\\\\n\\end{array}\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Solution $\\#$1:\n\n\n\nBasis:A binary tree consisting of a single vertex, which is a leaf, satisfies the equation \\(\\text{leaves} = \\text{internal} \\text{vertices}\n+ 1\\),\n\n\n\nInduction:Assume that for some \\(k\\geq 1\\), all full binary trees with <m>k</m> or fewer vertices have one more leaf than internal vertices.\nNow consider any full binary tree with \\(k+1\\) vertices. Let \\(T_A\\text{and} T_B\\) be the left and right subtrees of the tree which, by the definition\nof a full binary tree, must both be full. If \\(i_A\\text{and} i_B\\) are the numbers of internal vertices in \\(T_A\\text{and} T_B\\), and \\(j_A\\text{and}\nj_B\\) are the numbers of leaves, then \\(j_A=i_A+1 \\text{and} j_B=i_B+1\\). Therefore, in the whole tree, the number of leaves \\(=j_A+j_B\\\\\n\\\\\n=\\left(i_A+1\\right)+\\left(i_B+1\\right)\\\\\n\\\\\n=\\left(i_A+i_B+1\\right)+1\\\\\n\\\\\n=(\\text{number} \\text{of} \\text{internal} \\text{vertices})+1\\)\n\n\n\nSolution $\\#$2: Imagine building a full binary tree starting with a single vertex. By continuing to add leaves in pairs so that the tree\nstays full, we can build any full binary tree. Our starting tree satisfies the condition that the number of leaves \\((1)\\) is one more than the number\nof internal vertices \\((0)\\). By adding a pair of leaves to a full binary tree, an old leaf becomes an internal vertex, increasing the number of\ninternal vertices by one. Although we lose a leaf, the two added leaves create a net increase of one leaf. Therefore, the desired equality is maintained.\n\n\n\n\n\\subsection{Supplementary Exercises$---$Chapter 10}\n\n*************\n1.\n*************\n<answer><p> Each of the \\(n-1\\) edges of a tree contributes to the degrees of two vertices. Therefore the sum of all degrees of vertices in an <m>n</m>\nvertex tree is \\(2(n-1)=2n-2\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) \\(G_2\\text{is} \\text{graceful}: v_1=1, v_2+2, v_3=4\\\\\n\\\\\nG_4\\text{is} \\text{graceful}: v_1=2, v_2=1, v_3=3, v_4=4\\)\n\n</p></li>\n<li><p> Starting at either end of the chain label the first vertex \\(S(1)=1\\) and the \\((k+1)\\text{st} \\text{vertex}, k\\geq 1, S(k+1)=S(k)+k\\). The edge\nconnecting the \\(k\\text{th}\\) and \\((k+1)\\text{st}\\) vertex is the \\(\\text{kth}\\) edge and since \\((S(k+1)-s(k))=k\\), the chain is graceful. The\nclosed form expression for \\(S(k) \\text{is} 1+\\left(k\\left(k-\\frac{1}{2}\\right)\\right)\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> First, \\(\\{3,6\\}\\) is added to the edge set, then \\(\\{1,2\\} \\text{and} \\{3,4\\}\\). Then \\(\\{4,6\\}\\) is rejected since it would complete a  cycle.\nThis can be seen from the forest.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\nVertices 4 and 6 have the same root in this tree; hence \\(\\{4,6\\}\\) is rejected. \\(\\{1,5\\} \\text{and} \\{2,3\\}\\) are the final edges that complete\nthe minimal spanning tree. Notice that \\(\\{4,6\\}\\) could have been the second edge selected. In that case, \\(\\{3,4\\}\\) would be rejected.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> The depth of the tree is four.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p><ol label=\"a\">\n<li><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>   \\(\\text{\\textit{aa}}\\cdot 2a\\cdot b\\cdot +b+\\) is the postorder traversal of the tree. This is also the postfix version of the original expression.\n\n\n\\section{CHAPTER 11}\n\n\n\\subsection{Section 11.1}\n\n*************\n1.\n*************\n<answer><p> (a) Commutative, and associative. Notice that zero is the identity for addition, but it is not a positive integer.)\n\n</p></li>\n<li><p> Commutative, associative, and has an  identity (1)\n\n</p></li>\n<li><p> Commutative, associative, has an identity (1), and is idempotent\n\n</p></li>\n<li><p> Commutative, associative, and idempotent\n\n</p></li>\n<li><p>  None. Note:   \\(2 @ (3 @ 3) = 512 \\\\\n\\\\\n (2 @ 3) @ 3 = 64\\)\n\n\n\n        and while \\(a @ 1 = a\\), \\(1 @ a = 1\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  \\(a, b \\in  A \\cap  B\\text{  }\\Rightarrow \\text{  }a, b \\in  A\\text{  }\\text{by} \\text{the} \\text{definition} \\text{of} \\text{intersection}\\\\\n\\\\\n\\quad \\quad \\quad \\Rightarrow  a*b\\in A\\text{   }\\text{by} \\text{the} \\text{closure} \\text{of} A \\text{with} \\text{respect} \\text{to} *\\) \n\n\n\n     Similarly, \\(a, b \\in  A \\cap B\\Rightarrow  a*b\\in B\\). Therefore, \\(a * b \\in  A \\cap  B\\).\n\n\n\nThe set of positive integers is closed under addition, and so is the set of negative integers, but \\(1 + -1 - 0\\). Therefore, their union, the nonzero\nintegers, is not closed under addition.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Let $\\mathbb{N}$ be the set of all nonnegative integers (the natural numbers).\n\n</p></li>\n<li><p> \\(*\\) is commutative since \\(\\left| a-b\\right| =\\left| b-a\\right|\\) for all \\(a, b \\in  \\mathbb{N}\\)\n\n</p></li>\n<li><p> \\(*\\) is not associative. Take \\(a = 1\\), \\(b = 2\\), and \\(c = 3\\), then\n\n\n\n\\((a * b) * c =\\left| \\left| 1-2\\right| -3\\right| =2\\) , and\n\n\n\n\\(a * (b * c) = \\left| 1-\\left| 2-3\\right| \\right| = 0\\).\n\n</p></li>\n<li><p> Zero is the identity for \\(*\\) on $\\mathbb{N}$, since\n\n\n\n\\(a*0=\\left| a+0\\right|  = a = \\left| 0-a\\right| = 0 * a.\\)\n\n</p></li>\n<li><p>  \\(a^{-1}=a\\)  for each a $\\in $ $\\mathbb{N}$, since\n\n\n\n\\(a * a=\\left| a-a\\right|  = 0\\).\n\n</p></li>\n<li><p> \\(*\\) is not idempotent, since, for \\(a\\neq 0\\),\n\n\n\n$\\quad \\quad $\\(a * a =0 \\neq a\\).\n\n\n\\subsection{Section 11.2}\n\n*************\n1.\n*************\n<answer><p> The terms {``}generic{''} and {``}trade{''} for prescription drugs are analogous to {``}generic{''} and {``}concrete{''} algebraic systems. {\n}Generic aspirin, for example, has no name, whereas Bayer, Tylenol, Bufferin, and Anacin are all trade or specific types of aspirins. The same can\nbe said of a generic group \\([G, *]\\) where <m>G</m> is a nonempty set and \\(*\\) is a binary operation on \\(G\\), When examples of typical domain\nelements can be given along with descriptions of how operations act on them, such as $\\mathbb{Q}$* or \\(M_{2\\times 2}(\\mathbb{R})\\), then the system\nis concrete (has a specific name, as with the aspirin). Generic is a way to describe a general algebraic system, whereas a concrete system has a\nname or symbols making it distinguishable from other systems.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  b, d, e, and f.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a)  \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\), \\(\\left(\n\\begin{array}{cc}\n 0 &amp; 1 \\\\\n 1 &amp; 0 \\\\\n\\end{array}\n\\right)\\),  abelian\n\n\n\n    (b)     \\(\\begin{array}{c|c}\n   &amp; \n\\begin{array}{cccccc}\n I &amp; R_1 &amp; R_2 &amp; F_1 &amp; F_2 &amp; F_3 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n I \\\\\n R_1 \\\\\n R_2 \\\\\n F_1 \\\\\n F_2 \\\\\n F_3 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccc}\n I &amp; R_1 &amp; R_2 &amp; F_1 &amp; F_2 &amp; F_3 \\\\\n R_1 &amp; R_2 &amp; I &amp; F_2 &amp; F_3 &amp; F_1 \\\\\n R_2 &amp; I &amp; R_1 &amp; F_3 &amp; F_1 &amp; F_2 \\\\\n F_1 &amp; F &amp; F_2 &amp; I &amp; R_2 &amp; R_1 \\\\\n F_2 &amp; F_1 &amp; F_3 &amp; R_1 &amp; I &amp; R_2 \\\\\n F_3 &amp; F_2 &amp; F_1 &amp; R_2 &amp; R_1 &amp; I \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nThis group is non-abelian since, for example,  \\(F_1F_2=R_2\\) and \\(F_2F_1=R_2\\).\n\n\n\n (c) 4! = 24, n!</p></answer>\n\n\n*************\n7\n*************\n<answer><p>  The identity is <m>e</m>.   \\(a*b = c\\), \\(a*c= b\\),  \\(b*c = a\\), and \\([V, *]\\) is abelian. (This group is commonly called the Klein-4\ngroup.)\n\n\n\\subsection{Section 11.3}\n\n*************\n1.\n*************\n<answer><p> (a)  <m>f</m> is injective: \\(\\text{       }f(x) = f(y) \\Rightarrow  a * x = a * y \\quad \\quad \\Rightarrow  x = y\\text{      }(\\text{by}\n\\text{left} \\text{cancellation})\\)\n\n\n\n         \\textit{ f }is surjective:  For all <m>b</m>,   \\(f(x) = b\\) has the solution \\(a^{-1}*b\\).\n\n\n\n    (b) Functions of the form \\(f(x)\\text{  }= a + x\\), where <m>a</m> is any integer, are bijections\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  Basis: (\\(n = 2\\))   \\(\\left(a_1*a_2\\right){}^{-1}= a_2{}^{-1}*a_1{}^{-1}\\) by Theorem 11.3.4.\n\n\n\nInduction: Assume that for some \\(n \\geq  2\\),\n\n\n\n$\\quad \\quad $\\(\\left(a_1*a_2*\\cdots *a_n\\right){}^{-1}=a_n{}^{-1}*\\cdots * a_2{}^{-1}*a_1{}^{-1}\\)\n\n\n\nWe must show that\n\n\n\n$\\quad \\quad $\\(\\left(a_1*a_2*\\cdots *a_n*a_{n+1}\\right){}^{-1}=a_{n+1}{}^{-1}*a_n{}^{-1}*\\cdots * a_2{}^{-1}*a_1{}^{-1}\\)\n\n\n\nThis can be accomplished as follows:\n\n\n\n\\(\\text{            }\\left(a_1*a_2*\\cdots *a_n*a_{n+1}\\right){}^{-1}=\\left(\\left(a_1*a_2*\\cdots *a_n\\right)*a_{n+1}\\right){}^{-1}\\text{ \n }\\text{by} \\text{the} \\text{associative} \\text{law}\\quad \\quad \\quad \\quad =a_{n+1}{}^{-1}*\\left(a_1*a_2*\\cdots *a_n\\right){}^{-1}\\text{   }\\text{by}\n\\text{the} \\text{basis}\\quad \\quad \\quad \\quad =a_{n+1}{}^{-1}*\\left(a_n{}^{-1}*\\cdots * a_2{}^{-1}*a_1{}^{-1}\\right)\\text{  }\\text{by} \\text{the}\n\\text{induction} \\text{hypothesis}\\quad \\quad \\quad \\quad = a_{n+1}{}^{-1}*a_n{}^{-1}*\\cdots * a_2{}^{-1}*a_1{}^{-1} \\text{by} \\text{the} \\text{associative}\n\\text{law}\\text{   }\\blacksquare\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) Let \\(p(n)\\) be, where <m>a</m> is any element of group \\([G; *]\\). First we will prove that \\(p(n)\\) is true for all \\(n \\geq  0\\).\n\n\n\nFirst, we would need to prove a lemma that we leave to the reader, that if \\(n\\geq 0\\), and <m>a</m> is any group element, \\(a*a^n=a^n*a\\). \n\n\n\nBasis: If \\(n = 0\\), Using the definition of the zero exponent,  \\(\\left(a ^0\\right) ^{-1} = e^{-1} = e\\),  while \\(\\left(a^{-1}\\right)^0= e\\).\nTherefore, \\(p(0)\\) is true.\n\n\n\nInduction: Assume that for some \\(n \\geq  0\\), \\(p(n\\)) is true.\n\n\n\n\\(\\text{               }\\left(a^{n+1}\\right)^{-1}= \\left(a^n*a\\right)^{-1}\\text{   }\\text{by} \\text{the} \\text{definition} \\text{of} \\text{exponentiation}\\quad\n\\quad =a^{-1}*\\left(a^n\\right)^{-1}\\text{     }\\text{by} \\text{Theorem}\\text{  }11.3\\cdot 4\\quad \\quad = a^{-1}*\\left(a^{-1}\\right)^n\\text{   }\\text{by}\n\\text{the} \\text{induction} \\text{hypothesis}\\quad \\quad = \\left(a^{-1}\\right)^{n+1} \\text{by} \\text{the} \\text{lemma}\\)\n\n\n\nIf <m>n</m> is negative, then \\(-n\\) is positive and\n\n\n\n$\\quad \\quad $\\(\\text{   }a^{-n}= \\left(\\left(\\left(a^{-1}\\right)^{-1}\\right)^{-n} \\right)\\text{  }\\quad =\\left(a^{-1}\\right)^{-(-n)}\\text{  }\\text{since}\n\\text{the} \\text{property} \\text{is} \\text{true} \\text{for}\\text{  }\\text{positive} \\text{numbers}\\quad =\\left(a^{-1}\\right)^n\\)\n\n</p></li>\n<li><p> For \\(m > 1\\), let \\(p(m)\\) be \\(a^{n+m}=a^n*a^m\\) for all \\(n\\geq 1\\). The basis for this proof follows directly from the basis for the definition\nof exponentiation.\n\n\n\nInduction: Assume that for some \\(m > 1\\), \\(p(m)\\) is true. Then\n\n\n\n\\(\\text{                }a^{n+(m+1)}= a^{(n+m)+1}\\text{   }\\text{by} \\text{the} \\text{associativity} \\text{of} \\text{integer} \\text{addition}\\quad\n\\quad =a^{n+m}*a^1\\text{  }\\text{by} \\text{the} \\text{definition} \\text{of} \\text{exponentiation}\\quad \\quad =\\left(a^n*a^m\\right)*a^1\\text{  }\\text{by}\n\\text{the} \\text{induction} \\text{hypothesis}\\quad \\quad = a^n*\\left(a^m*a^1\\right)\\text{   }\\text{by} \\text{associativity}\\quad \\quad = a^n*a^{m+1}\\text{\n }\\text{by} \\text{the} \\text{definition} \\text{of} \\text{exponentiation}\\)\n\n</p></li>\n<li><p> Let \\(p(m)\\)be \\(\\left(a^n\\right)^m= a^{n m}\\) for all integers <m>n</m>.\n\n\n\nBasis: \\(\\left(a^m\\right)^0= e\\) and \\(a^{m\\cdot 0}=a^0= e\\) therefore, \\(p(0)\\) is true.\n\n\n\nInduction; Assume that \\(p(m)\\) is true for some \\(m >\\)0,\n\n\n\n\\(\\quad \\left(a^n\\right)^{m+1}=\\left(a^n\\right)^m*a^n\\text{    }\\text{definition} \\text{of} \\text{exponentiation}\\quad \\quad =a^{n m}*a^n\\text{\n      }\\text{by} \\text{the} \\text{induction} \\text{hypothesis}\\quad \\quad =a^{n m + n}\\text{          }\\text{by} \\text{part} (a) \\text{of} \\text{this}\n\\text{problem}\\quad \\quad =a^{n(m+1)}\\text{          }\\)\n\n\n\nFinally, if <m>m</m> is negative, we can verify that \\(\\left(a^n\\right)^m= a^{n m}\\) using many of the same steps as the proof of part (a).\n\n\n\\subsection{Section 11.4}\n\n*************\n1.\n*************\n<answer><p><ol label=\"a\">\n<li><p> 2 (b) 5 $\\quad \\quad $(c) 0\n\n\n\n   </p></li>\n<li><p> 0 (e) 2 $\\quad \\quad $(f) 2 \n\n\n\n   </p></li>\n<li><p> 1 (h) 3</p></answer>\n\n\n*************\n3\n*************\n<answer><p><ol label=\"a\">\n<li><p> 1 (b) 1 $\\quad \\quad $(c) \\(m(4) = r(4)\\), where \\(m = 11 q + r\\), \\(0 \\leq  r < 11\\) .\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Since the solutions, if they exist, must come from \\(\\mathbb{Z}_2\\) , substitution is the easiest approach.\n\n\n\n(a) 1 is the only solution, since  \\(1^2+_21=0\\)   and  \\(0^2+_21=1\\)\n\n\n\n(b) No solutions, since \\(0^2+_20+_21=1\\), and  \\(1^2+_21+_21=1\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Hint: Prove by induction on <m>m</m> that you can divide any positive integer into <m>m</m>, That is, let \\(p(m)\\) be $\\texttt{\"}$For all\n<m>n</m> greater than zero, there exist unique integers <m>q</m> and <m>r</m> such that. . . .$\\texttt{\"}$ In the induction step, divide\n<m>n</m> into \\textit{ m - n}.\n\n\n\\subsection{Section 11.5}\n\n*************\n1.\n*************\n<answer><p>   a and c\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>   \\(\\left\\{I,R_1,R_2\\right\\}\\), \\(\\left\\{I,F_1\\right\\}\\), \\(\\left\\{I,F_2\\right\\}\\), and \\(\\left\\{I,F_3\\right\\}\\) are all the proper subgroups\nof \\(R_3\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p>  <ol label=\"a\">\n<li><p> \\(\\langle 1\\rangle  = \\langle 5\\rangle  = \\mathbb{Z}_6\\)\n\n\n\n\\(\\quad\\)\\(\\langle 2\\rangle \\text = \\langle 4\\rangle  = \\{2, 4, 0\\}\\)\n\n\n\n\\(\\langle 3\\rangle \\text = \\{3, 0\\}\\)\n\n\n\n\\(\\langle 0\\rangle  = \\{0\\}\\)\n\n\n\n     </p></li>\n<li><p> \\(\\langle 1\\rangle  = \\langle 5\\rangle  = \\langle 7\\rangle  = \\langle 11\\rangle  =\\mathbb{Z}_{12}\\)\n\n\n\n\\(\\langle 2\\rangle \\text = \\langle 10\\rangle  = \\{2, 4, 6, 8, 10, 0\\}\\)\n\n\n\n\\(\\langle 3\\rangle \\text = \\langle 9\\rangle  = \\{3, 6, 9, 0\\}\\)\n\n\n\n\\(\\langle 4\\rangle \\text = \\langle  8 \\rangle  = \\{ 4 , 8, 0\\}\\)\n\n\n\n\\(\\langle 6\\rangle  = \\{6, 0\\}\\) \n\n\n\n\\(\\langle 0\\rangle  = \\{0\\}\\)\n\n\n\n   </p></li>\n<li><p>   \\(\\langle 1\\rangle  = \\langle  3\\rangle  = \\langle  5 \\rangle  = \\langle 7\\rangle  = \\mathbb{Z}_8\\)\n\n\n\n\\(\\langle 2\\rangle  = \\langle 6\\rangle  = \\{2, 4, 6, 0\\}\\) \n\n\n\n\\(\\langle 4\\rangle  = \\{4, 0\\}\\)\n\n\n\n\\(\\langle 0\\rangle  = \\{0\\}\\)\n\n\\begin{doublespace}\n\\noindent\\(\\begin{array}{lll}\n  &amp;  &amp;  \\\\\n\\end{array}\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> Based on the ordering diagrams in parts a through c, we would expect to see an ordering diagram similar to the one for divides on \\(\\{1, 2, 3,\n4, 6, 8, 12, 24\\}\\) (the divisors of 24) if we were to examine the subgroups of \\(\\mathbb{Z}_{24}\\). This is indeed the case.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Assume that <m>H</m> and <m>K</m> are subgroups of group <m>G</m>, and that, as in Figure 11.5.1, there are elements \\(x \\in  H --- K\\)\nand \\(y \\in  K --- H\\). Consider the product \\(x * y\\). Where could it be placed in the Venn diagram? If we can prove that it must lie in the outer\nregion, \\(H^c\\cap K^c=(H\\cup K)^c\\), then we have proven that \\(H \\cup  K\\) is not closed under \\(*\\) and can{'}t be a subgroup of <m>G</m>, Assume\nthat  \\(x*y\\in H\\).  Since \\(x\\) is in \\textit{ H,} \\(x^{-1}\\) is in <m>H</m> and so by closure\n\n\n\n\\(x^{-1}*(x * y )= y \\in H\\)\n\n\n\nwhich is a contradiction.   Similarly, \\(x*y \\notin K\\).  $\\blacksquare $ \n\n\n\nOne way to interpret this theorem is that no group is the union of two groups.\n\n\n\\subsection{Section 11.6}\n\n*************\n1.\n*************\n<answer><p> Table of \\(\\mathbb{Z}_2\\times  \\mathbb{Z}_3\\) :\n\n\\begin{doublespace}\n\\noindent\\(\\begin{array}{cc}\n \\text{} &amp;  \\\\\n  &amp;  \\\\\n\\end{array}\\)\n\\end{doublespace}\n\n\n\nThe only two proper subgroups are \\(\\{(0, 0), (1, 0)\\}\\) and \\(\\{(0, 0), (0, 1), (0, 2)\\}\\)</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) (i) \\(a + b\\text{  }\\text{could} \\text{be}\\text{  }(1, 0) \\text{or} (0, 1)\\). \n\n\n\n(ii)  \\(a + b = (1, 1)\\).\n\n</p></li>\n<li><p> (i) \\(a + b = \\text{could} \\text{be}\\text{  }(1, 0, 0), (0, 1, 0), \\text{or}\\text{  }(0, 0, 1)\\). \n\n\n\n(ii) \\(a + b = (1, 1, 1)\\).\n\n</p></li>\n<li><p> (i) \\(a + b\\) has exactly one 1.\n\n\n\n(ii) \\(a + b\\) has all \\(1's\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> </p></li>\n<li><p>  No,  0 is not an element of \\(\\mathbb{Z} \\times \\mathbb{Z}\\).  </p></li>\n<li><p> Yes. </p></li>\n<li><p> No, (0, 0) is not an element of this set.\n\n\n\n     </p></li>\n<li><p> No, the set is not closed: \\((1, 1) + (2, 4) = (3, 5)\\) and \\((3, 5)\\) is not in the set. </p></li>\n<li><p> Yes.\n\n\n\\subsection{Section 11.7}\n\n*************\n1.\n*************\n<answer><p> (a) Yes, \\(f(n, x) = (x, n)\\) for \\((n, x) \\in  \\mathbb{Z} \\times  \\mathbb{R}\\) is an isomorphism. \n\n</p></li>\n<li><p> No, \\(\\mathbb{Z}_2\\times  \\mathbb{Z}\\) has a finite proper subgroup while \\(\\mathbb{Z} \\times  \\mathbb{Z}\\) does not.\n\n</p></li>\n<li><p> No. \n\n</p></li>\n<li><p> Yes.\n\n</p></li>\n<li><p>  No. \n\n</p></li>\n<li><p> Yes,  one isomorphism is defined by \\(f\\left(a_1, a_2,a_3,a_4\\right)=\\left(\n\\begin{array}{cc}\n a_1 &amp; a_2 \\\\\n a_3 &amp; a_4 \\\\\n\\end{array}\n\\right)\\). \n\n</p></li>\n<li><p> Yes, one isomorphism is defined by \\(f\\left(a_1,a_2\\right)=\\left(a_1,10^{a_2}\\right)\\). \n\n</p></li>\n<li><p> Yes. \n\n</p></li>\n<li><p> Yes   \\(f(k) = k(1,1)\\).</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  Consider 3 groups \\(G_1\\), \\(G_2\\), and \\(G_3\\) with operations \\(*, \\diamond , \\text{and} \\square\\), respectively.. We want to show that if\n\\(G_1\\) is isomorphic to \\(G_2\\) , and if \\(G_2\\) is isomorphic to \\(G_3\\) , then \\(G_1\\) is isomorphic to \\(G_3\\).\n\n\n\n\\(G_1 \\text{isomorphic} \\text{to} G_2\\Rightarrow  \\text{there} \\text{exists} \\text{an} \\text{isomorphism} f:G_1\\to G_2\\) \n\n\n\n\\(G_2 \\text{isomorphic} \\text{to} G_3\\Rightarrow  \\text{there} \\text{exists} \\text{an} \\text{isomorphism} g:G_2\\to G_3\\) \n\n\n\nIf we compose <m>g</m> with <m>f</m>, we get the function \\(g\\circ f:G_1\\to G_3\\),  By Theorems 7.3.2 and 7.3.3, \\(g\\circ f\\) is a bijection,\nand if \\(a,b\\in G_1\\),\n\n\n\n\\((g\\circ f)(a*b)=g(f(a*b))\\\\\n\\\\\n\\quad \\quad =g(f(a)\\diamond f(b))\\text{  }\\text{since} f \\text{is} \\text{an} \\text{isomorphism}\\\\\n\\\\\n\\quad \\quad =g(f(a))\\square g(f(b)) \\text{since} g \\text{is} \\text{an} \\text{isomorphism}\\\\\n\\\\\n\\quad \\quad =(g\\circ f)(a) * (g\\circ f)(b)\\)\n\n\n\nTherefore, \\(g\\circ f\\) is an isomorphism from \\(G_1\\) into \\(G_3\\) , proving that {``}is isomorphic to$\\texttt{\"}$ is transitive.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p>  \\(\\mathbb{Z}_8\\), \\(\\mathbb{Z}_2\\times  \\mathbb{Z}_4\\) , and \\(\\mathbb{Z}_2{}^3\\)$|$. One other is the fourth dihedral group, introduced in\nSection 15.3.</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Let <m>G</m> be an infinite cyclic group generated by <m>a</m>. Then, using multiplicative notation,  \\(G=\\left\\{\\left.a^n\\right| n\\in\n\\mathbb{Z}\\right\\}\\).\n\n\n\nThe map \\(T: G ---> \\mathbb{Z}\\) defined by \\(T\\left(a^n\\right)=n\\) is an isomorphism. This is indeed a function, since \\(a^n=a^m\\) implies \\(n =m\\).\nOtherwise, <m>a</m> would have a finite order and would not generate <m>G</m>.\n\n\n\n(a)  T is one-to-one, since \\(T\\left(a^n\\right) = T\\left(a^m\\right)\\) implies \\(n = m\\), so \\(a^n= a^m\\).\n\n\n\n(b)  T is onto, since for any \\(n\\in \\mathbb{Z}\\), \\(T\\left(a^n\\right) = n\\).\n\n\n\n(c)   \\(\\text{          }T\\left(a^n*a^m \\right) = T\\left(a^{n+m}\\right)\\quad \\quad =n + m\\quad \\quad =T\\left(a^n\\right)+T\\left(a^m\\right)\\)\n\n\n\\subsection{Supplementary Exercises$---$Chapter 11}\n\n*************\n1.\n*************\n<answer><p> (a) With respect to <m>V</m> under +, the identity is <m>a</m>; and \\(-a=a\\),  \\(-b=c\\), and \\(-c=b\\).\n\n</p></li>\n<li><p> With respect to <m>V</m> under \\(\\cdot\\), the identity is <m>b</m>. Inverses:  \\(b^{-1}=b\\), \\(c^{-1}=c\\), and <m>a</m> has no inverse,\n\n</p></li>\n<li><p> \\(\\cdot\\) is distributive over + since \\(x \\cdot  (y + z) = x \\cdot y + x\\cdot  z\\) for each of the 27 ways that the variables <m>x</m>, \\textit{\ny}, and <m>z</m> can be assigned values from <m>V</m>.  However, + is not distributive over \\(\\cdot\\) since \\(b + (a \\cdot c) = b\\), while\n\\((b + a) \\cdot  (b + c) = a\\),\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  By Theorem 7.3.4 every bijection has an inverse, so \\(\\circ\\) has the inverse property on <m>S</m>. If \\(f \\in  S\\),\n\n\n\n \\(f\\circ f^{-1}= f^{-1}\\circ f=i\\text{    }\\Rightarrow \\text{  }f \\text{inverts} f^{-1},\\text{   }\\text{or}\\text{     }\\left(f^{-1}\\right)^{-1}=\nf.\\)\n\n\n\nTherefore, inversion of functions has the involution property.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> If <m>a</m> and <m>b</m> are odd integers, \\(a = 2j + 1\\) and \\(b = 2k + 1\\) for \\(j, k \\in  \\mathbb{Z}\\). \\(a b = (2j + 1)(2k + 1) = 2(2j\nk + j + k) + 1\\), which is an odd integer. Since 1 is odd and \\(1 + 1\\) is even, the odds are not closed under addition, The even integers are closed\nunder both addition and multiplication. If <m>a</m> and <m>b</m> are even, \\(a = 2j\\) and \\(b = 2k\\) for some \\(j, k \\in  \\mathbb{Z}\\), \\(a\n+ b = 2j + 2k = 2(j + k)\\), which is even, and \\(a b = (2j)(2k) = 2(2j k)\\), which is also even.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p>  That \\(\\text{GL}(2,\\mathbb{R})\\) is a group follows from laws of matrix algebra. In addition to being associative, matrix multiplication on\ntwo-by-two matrices has an identity <m>I</m>, and if \\(A \\in  \\text{GL} (2,\\mathbb{R})\\), it has an inverse by the definition of \\(\\text{GL} (2,\\mathbb{R})\\).\nThe inverse of A is in GL(2,$\\mathbb{R}$) since it has an inverse: \\(\\left(A^{-1}\\right)^{-1} = A\\).\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> If \\(a, b, c \\in  \\mathbb{R}\\),\n\n\n\n \\(\\text{          }(a * b) * c = (a + b + 5) * c\\quad \\quad =a+b+5+c+5\\quad \\quad =a+b+c+10\\)\n\n\n\n \\(a * (b * c)\\) is also equal to \\(a+b+c+10\\), and so \\(*\\) is associative. To find the identity we solve \\(a * e =\\)a for \\textit{ e:}\n\n\n\n\\(a * e = a\\text{   }\\Rightarrow \\text{  }a + e + 5 = a\\text{   }\\Rightarrow \\text{  }e = ---5\\).\n\n\n\nIf <m>a</m> is a real number, the inverse of <m>a</m> is determined by solving the equation \\(a * x=-5\\);\n\n\n\n\\(a*x=-5\\text{  }\\Rightarrow  a + x + 5 = -5\\text{  }\\Rightarrow  x = -a-10\\)\n\n\n\nSince <m>a</m> is real, \\(-a-10\\) is real, and so \\(*\\) has the inverse property.</p></answer>\n\n\n*************\n11\n*************\n<answer><p> By Supplementary Exercise 2 of this chapter, the identity for \\(*\\) is 2 and \\(*\\) is associative. All that is left to show is that * has the\ninverse property. If \\(a \\in  \\mathbb{Q}^+\\)  , \\(a * x = 2 \\Rightarrow  x = \\frac{4}{a}\\); hence  \\(a^{-1}= \\frac{4}{a}\\), which is also a positive\nrational number.</p></answer>\n\n\n*************\n13\n*************\n<answer><p> Recall that matrix multiplication is the operation on \\(\\text{GL}(2,\\mathbb{R})\\).\n\n\n\n\\(\\text{        }A X B = C\\text{  }\\Rightarrow \\text{  }X B = A^{-1}C\\text{        }\\left(\\text{multiply} \\text{on} \\text{the} \\text{left}\n\\text{by} A^{-1}\\right)\\quad \\quad \\Rightarrow \\text{  }X = A^{-1}C B^{-1} \\left(\\text{multiply} \\text{on} \\text{the} \\text{right} \\text{by} B^{-1}\\right)\\)\n\n\n\n   \\(X=\\left(\n\\begin{array}{cc}\n \\frac{1}{2} &amp; 0 \\\\\n 0 &amp; \\frac{1}{3} \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 2 &amp; 1 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n \\frac{1}{2} &amp; -\\frac{1}{2} \\\\\n -\\frac{1}{2} &amp; 1 \\\\\n\\end{array}\n\\right) = \\left(\n\\begin{array}{cc}\n \\frac{1}{4} &amp; 0 \\\\\n -\\frac{1}{6} &amp; \\frac{1}{3} \\\\\n\\end{array}\n\\right)\\)\n\n</p></answer>\n\n\n*************\n15\n*************\n<answer><p>   </p></li>\n<li><p>  1    (b)  4       </p></li>\n<li><p> 0       </p></li>\n<li><p> 3\n\n</p></answer>\n\n\n*************\n17\n*************\n<answer><p> (a)  \\(\\langle 1\\rangle  = \\{1\\}\\),  \\(\\langle 3\\rangle = \\{1, 3\\}\\),  \\(\\langle 5\\rangle  = \\{1, 5\\}\\), and \\(\\langle 7\\rangle  = \\{1,\n7\\}\\).\n\n\n\n      (b)  No, because no cyclic subgroup equals \\(U\\left(\\mathbb{Z}_8\\right)\\).\n\n</p></answer>\n\n\n*************\n19\n*************\n<answer><p> (a)  \\(A,B \\in  \\text{SL}(2,\\mathbb{R}) \\Rightarrow  \\left| A\\right| =\\left| B\\right| =1\\).\n\n\n\n       \\(\\text{     }\\left| A B\\right|  = \\left| A\\right| \\cdot \\left| B\\right| = 1\\cdot 1 = 1\\text{    }\\Rightarrow \\text{   }A B \\in \\text{SL}(2,\\mathbb{R})\\quad\n\\quad \\quad \\quad \\Rightarrow  \\text{SL}(2,\\mathbb{R}) \\text{is} \\text{closed} \\text{with} \\text{respect} \\text{to} \\text{matrix} \\text{multiplication}\\)\n\n\n\n      (b)  \\(\\left| I\\right| = 1\\text{   }\\Rightarrow \\text{   }I \\in \\text{SL}(2,\\mathbb{R})\\)\n\n\n\n      (c) \\(A \\in \\text{SL}(2,\\mathbb{R})\\text{  }\\Rightarrow  \\left| A\\right| = 1\\)\n\n\n\n\\(\\left\\left| A^{-1}\\right\\right| =\\left| A\\right| ^{-1}=1 \\Rightarrow \\text{  }A^{-1}\\in  \\text{SL}(2,\\mathbb{R})\\)\n\n</p></answer>\n\n\n*************\n21\n*************\n<answer><p> Yes, <m>S</m> is a submonoid of \\(B_{3\\times 3}\\).  The zero matrix is in <m>S</m> since it is the matrix of the empty relation, which\nis symmetric. Furthermore, if <m>A</m> and <m>B</m> are matrices of symmetric relations,\n\n\n\n\\(\\text{            }(A + B)_{\\text{ij}} = A_{\\text{ij}} + B_{\\text{ij}}\\text{   }\\text{definition} \\text{of} \\text{matrix} \\text{addition}\\quad\n\\quad = A_{\\text{ji}} + B_{\\text{ji}}\\text{  }\\text{since} \\text{both} A \\text{and} B \\text{are} \\text{symmetirc}\\quad \\quad = (A+B)_{\\text{ji}}\\text{\n   }\\text{definition} \\text{of} \\text{matrix} \\text{addition}\\)\n\n\n\nTherefore, \\(A + B\\) is symmetric, which means that it is the matrix of a symmetric relation and that relation is in \\(S\\).\n\n</p></answer>\n\n\n*************\n23\n*************\n<answer><p> (a) \\((1,4,20)\\)    (b) \\((-1,0,-1,-1)\\)    (c) \\((1/ 3 , 4)\\)   </p></li>\n<li><p>\\((-2,-3,-5)\\)\n\n</p></answer>\n\n\n*************\n25\n*************\n<answer><p> The groups in parts a and c are abelian, since each factor is abelian. The group in part b is non-abelian, since one of its factors, \\(\\text{GL}(2,\\mathbb{R})\\),\nis non-abelian.\n\n\n\n27, Since \\(\\langle 4\\rangle = \\{0, 4, 8, 12\\}\\) is a cyclic group and has order four, it must be isomorphic to \\(\\mathbb{Z}_4\\),\n\n\n\n29, (a) There exists a {``}dictionary{''} that allows us to translate between the two systems in such a way that any true fact in one is translated\nto a true fact in the other.\n\n\n\n   </p></li>\n<li><p> If one system is familiar to you, the other one should be familiar too.\n\n\n\n   </p></li>\n<li><p> If \\((p \\land  \\neg q) \\Leftrightarrow  0\\), and \\((p\\land  q) \\Leftrightarrow  0\\), then \\(p\\Leftrightarrow 0\\).\n\n</p></answer>\n\n\n*************\n31\n*************\n<answer><p> The key to this exercise is to identify the fact that adding two complex numbers entails adding two pairs of numbers, the real and imaginary\nparts. If we simply rename these parts the first and second parts, then we are doing \\(\\mathbb{R}^2\\) addition. This suggests the function \\(T: \\mathbb{C}\n--->\\mathbb{R}^2\\) where \\(T(a + b i) = (a, b)\\). For any two complex numbers \\(a + b i\\) and \\(c + d i\\),\n\n\n\n\\(\\text{               }T((a + b i) + (c + d i)) = T((a + c) + (b + d) i) \\text \\text{definition} \\text{of} + \\text{in} \\mathbb{C}\\quad\n\\quad \\quad \\quad = \\{a + c, b + d)\\text{  }\\text{definition} \\text{of} T\\quad \\quad \\quad \\quad = (a, b) + (c, d) \\text \\text{definition} \\text{of}\n+ \\text{in} \\mathbb{R}^2\\quad \\quad \\quad \\quad = T(a + b i) + T(c + d i) \\text \\text{definition} \\text{of} T\\)\n\n\n\nSince <m>T</m> has an inverse \\(\\left(T^{-1}(a,b)=a+b i \\right)\\), <m>T</m> is an isomorphism and so the two groups are isomorphic.\n\n\n\nIt should be noted that <m>T</m>' is not the only isomorphism between these two groups. For example \\(U(a + b i) = (b, a)\\) defines an isomorphism.\n\n\n</p></answer>\n\n\n*************\n33\n*************\n<answer><p> The key here is to realize that both groups consist of elements that are constructed from four real numbers and that you operate on elements\nby adding four different pairs of real numbers. An isomorphism from \\(\\mathbb{R}^4\\) into \\(M_{2\\times 2}(\\mathbb{R})\\) is\n\n\n\n$\\quad \\quad $\\(T(a,b,c,d) = \\left(\n\\begin{array}{cc}\n a &amp; b \\\\\n c &amp; d \\\\\n\\end{array}\n\\right)\\)\n\n\n\nThere are an infinite number of isomorphism in this case.  This one is the most obvious.\n\n\n\\subsection{CHAPTER 12}\n\n\n\\subsubsection{Section 12.1}\n\n*************\n1.\n*************\n<answer><p> (a) \\(\\{(4/3, 1/3)\\}\\)\n\n</p></li>\n<li><p> \\(\\left\\{\\left(-3 - 0.5x_3, 11 - 4x_3, x_3 \\right) | x_3\\right\\}\\)\n\n</p></li>\n<li><p> \\(\\{(-5, 14/5, 8/5)\\}\\)\n\n</p></li>\n<li><p> \\(\\left\\{\\left(6.25 - 2.5x_3, -0.75 + 0.5x_3 , x_3\\right) | x_3 \\in  \\mathbb{R}\\right\\}\\)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a)  $\\{$(1.2, 2.6, 4.5)$\\}$\n\n</p></li>\n<li><p> \\(\\left\\{\\left(-6 x_3+ 5, 2 x_3 + 1, x_3 \\right) |\\text{  }x_3 \\in  \\mathbb{R}\\right\\}\\)\n\n</p></li>\n<li><p>\\(\\left\\{\\left(-9 x_3 + 3, 4, x_3 \\right) |\\text{  }x_3 \\in  \\mathbb{R}\\right\\}\\)\n\n</p></li>\n<li><p> \\(\\left\\{\\left(3 x_4 + 1, -2x_4 + 2, x_4 + 1, x_4\\right) | x_4 \\in  \\mathbb{R}\\right\\}\\)</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a)  \\(\\{(3,0)\\}\\)\n\n</p></li>\n<li><p>           \\(\\text{                   }\\left(\n\\begin{array}{cccc}\n 1 &amp; 1 &amp; 2 &amp; 1 \\\\\n 1 &amp; 2 &amp; 4 &amp; 4 \\\\\n 1 &amp; 3 &amp; 3 &amp; 0 \\\\\n\\end{array}\n\\right)\\text{          }\n\\begin{array}{c}\n   \\\\\n \\text{  }-R_1+R_2\\text{     }\\to  \\\\\n -R_1+ R_3 \\\\\n\\end{array}\n\\left(\n\\begin{array}{cccc}\n 1 &amp; 1 &amp; 2 &amp; 1 \\\\\n 0 &amp; 1 &amp; 2 &amp; 3 \\\\\n 0 &amp; 2 &amp; 1 &amp; -1 \\\\\n\\end{array}\n\\right) \\quad \\quad \\quad \n\\begin{array}{c}\n -R_2+ R_1 \\\\\n \\text{                                   }\\to  \\\\\n -2R_2+ R_3 \\\\\n\\end{array}\n\\left(\n\\begin{array}{cccc}\n 1 &amp; 0 &amp; 0 &amp; -2 \\\\\n 0 &amp; 1 &amp; 2 &amp; 3 \\\\\n 0 &amp; 0 &amp; -3 &amp; -7 \\\\\n\\end{array}\n\\right) \\quad \\quad \\quad \n\\begin{array}{c}\n   \\\\\n \\text{                                  }\\to  \\\\\n \\text{     }\\frac{-1}{3}R_3 \\\\\n\\end{array}\n\\left(\n\\begin{array}{cccc}\n 1 &amp; 0 &amp; 0 &amp; -2 \\\\\n 0 &amp; 1 &amp; 2 &amp; 3 \\\\\n 0 &amp; 0 &amp; 1 &amp; \\frac{7}{3} \\\\\n\\end{array}\n\\right) \\text{$\\quad \\quad \\quad $         }\n\\begin{array}{c}\n   \\\\\n \\frac{-1}{2}R_3+R_2\\to  \\\\\n   \\\\\n\\end{array}\n\\left(\n\\begin{array}{cccc}\n 1 &amp; 0 &amp; 0 &amp; -2 \\\\\n 0 &amp; 1 &amp; 2 &amp; 3 \\\\\n 0 &amp; 0 &amp; 1 &amp; \\frac{7}{3} \\\\\n\\end{array}\n\\right)\\)\n\n\n\nThe row reduction can be done with \\textit{ Mathematica}:\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{RowReduce}\\left[\\right]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 0 &amp; 0 &amp; -2 \\\\\n 0 &amp; 1 &amp; 0 &amp; -\\frac{5}{3} \\\\\n 0 &amp; 0 &amp; 1 &amp; \\frac{7}{3} \\\\\n\\end{array}\n\\right)\\)\n\\end{doublespace}\n\n\n\nIn any case, the solution set is \\(\\{(-2, -5/3, 7/3)\\}\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Proof: Since \\(b\\) is the \\(n\\times 1\\) matrix of 0{'}s, let{'}s call it \\pmb{ 0}.  Let S be the set of solutions to \\(A X = 0\\). If \\(X_1\\)\nand \\(X_2\\)  be in \\textit{ S.  } Then\n\n\n\n\\(A\\left(X_1 + X_2 \\right) = A X_1 + A X _2 =\\pmb \\pmb{0}\\pmb +\\pmb \\pmb{0} =\\pmb \\pmb{0}\\)\n\n\n\nso \\(X_1+ X_2 \\in  S\\); that is, <m>S</m> is closed under addition.\n\n\n\nThe identity of \\(\\mathbb{R}^n\\) is \\pmb{ 0}, which is in <m>S</m>.  Finally, let <m>X</m> be in <m>S</m>. Then\n\n\n\n \\(A(-X) = -(A X) = -\\pmb \\pmb{0} =\\pmb \\pmb{0}\\) ,\n\n\n\nand so \\(-X\\) is also in <m>S</m>.\n\n\n\\subsubsection{Section 12.2}\n\n</p></li>\n<li><p>   \\(\\left(\n\\begin{array}{cc}\n \\frac{15}{11} &amp; \\frac{30}{11} \\\\\n \\frac{3}{11} &amp; -\\frac{5}{11} \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>   \\(\\left(\n\\begin{array}{cccc}\n -20 &amp; \\frac{21}{2} &amp; \\frac{9}{2} &amp; -\\frac{3}{2} \\\\\n 2 &amp; -1 &amp; 0 &amp; 0 \\\\\n -4 &amp; 2 &amp; 1 &amp; 0 \\\\\n 7 &amp; -\\frac{7}{2} &amp; -\\frac{3}{2} &amp; \\frac{1}{2} \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>   The inverse does not exist.   When the augmented matrix is row-reduced (see below), the last row of the first half cannot be manipulated\nto match the identity matrix. \n\n</p></li>\n<li><p>    \\(\\left(\n\\begin{array}{ccc}\n 1 &amp; 0 &amp; 0 \\\\\n -3 &amp; 1 &amp; 1 \\\\\n -4 &amp; 1 &amp; 2 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>    The inverse does not exist.   \n\n</p></li>\n<li><p>     \\(\\left(\n\\begin{array}{ccc}\n 9 &amp; -36 &amp; 30 \\\\\n -36 &amp; 192 &amp; -180 \\\\\n 30 &amp; -180 &amp; 180 \\\\\n\\end{array}\n\\right)\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> The solutions are in the solution section of Section 12.1, exercise 1, We illustrate with the outline of the solution to Exercise 1(c) of Section\n12.1.\n\n\n\n\\(\\left(\n\\begin{array}{ccc}\n 1 &amp; 1 &amp; 2 \\\\\n 1 &amp; 2 &amp; -1 \\\\\n 1 &amp; 3 &amp; 1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)\\)\n\n\n\n\\(A^{-1}=\\left(\n\\begin{array}{ccc}\n 1 &amp; 1 &amp; 2 \\\\\n 1 &amp; 2 &amp; -1 \\\\\n 1 &amp; 3 &amp; 1 \\\\\n\\end{array}\n\\right)^{-1}=\\frac{1}{5}\\left(\n\\begin{array}{ccc}\n 5 &amp; 5 &amp; -5 \\\\\n -2 &amp; -1 &amp; 3 \\\\\n 1 &amp; -2 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nand   \\(\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n\\end{array}\n\\right)=A^{-1}\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{14}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)\\)\n\n\n\\subsubsection{Section 12.3}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (b) Yes\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p>  If the matrices are named <m>B</m>, \\(A_1\\), \\(A_2\\) , \\(A_3\\), and \\(A_4\\) , then\n\n\n\n\\(B = \\frac{8}{3}A_1 + \\frac{5}{3}A_2+\\frac{-5}{3}A_3+\\frac{23}{3}A_4\\).\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> (a) If \\(x_1 = (1, 0)\\), \\(x_2= (0, 1)\\), and \\(y = \\left(b_1, b_2\\right)\\), then \n\n\n\n\\(y = b_1x_1+b_2x_2\\). \n\n\n\n         If  \\(x_1 = (3, 2)\\), \\(x_2= (2,1)\\), and \\(y = \\left(b_1, b_2\\right)\\), then\n\n\n\n\\(y =\\left(- b_1+2b_2\\right)x_1+\\left(2b_1-3b_2\\right)x_2\\).\n\n\n\n       The second linear combination can be computed using \\textit{ Mathematica} as follows.\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{Solve}\\left[c_1\\{3,2\\}+c_2\\{2,1\\}==\\left\\{b_1,b_2\\right\\},\\left\\{c_1,c_2\\right\\}\\right]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\left\\{\\left\\{c_1\\to 2 b_2-b_1,c_2\\to 2 b_1-3 b_2\\right\\}\\right\\}\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> If \\(y = \\left(b_1, b_2\\right)\\) is any vector in \\(\\mathbb{R}^2\\) , then\n\n\n\n \\(y =\\left(- 3b_1+4b_2\\right)x_1+\\left(-b_1+b_2\\right)x_2 + (0)x_3\\)\n\n</p></li>\n<li><p> One solution is to add any vector(s) to \\(x_1\\), \\(x_2\\), and \\(x_3\\) of part b.\n\n</p></li>\n<li><p> 2, <m>n</m>\n\n</p></li>\n<li><p> If the matrices are \\(A_1,A_2 ,A_3,\\text{and} A_4\\) , then\n\n\n\n\\(\\left(\n\\begin{array}{cc}\n x &amp; y \\\\\n z &amp; w \\\\\n\\end{array}\n\\right)= x A_1z+y A_2+ z A_3+ w A_4\\)\n\n</p></li>\n<li><p> \\(a_0+a_1x + a_2x^2+ a_3x^3=a_0(1)+a_1(x) + a_2\\left(x^2\\right)+ a_3\\left(x^3\\right)\\).\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p> (a) The set is linearly independent: let <m>a</m> and <m>b</m> be scalars such that \\(a(4, 1) + b(1, 3) = (0, 0)\\), then \n\n\n\n$\\quad \\quad $\\(4a + b = 0\\text{     }\\text{and} \\\\\n\\\\\n a + 3b= 0\\)\n\n\n\nwhich has \\(a = b = 0\\) as its only solutions. The set generates all of \\(\\mathbb{R}^2\\) : let \\((a, b)\\) be an arbitrary vector in \\(\\mathbb{R}^2\\)\n. We want to show that we can always find scalars \\(\\beta _1\\) and \\(\\beta _2\\) such that \\(\\beta _1(4, 1) +\\beta _2 (1,3) = (a, b)\\). This is equivalent\nto finding scalars such that \\(4\\beta _1 +\\beta _2 = a\\) and \\(\\beta _1 + 3\\beta _2 = b\\). This system has a unique solution  \\(\\beta _1=\\text{\n }\\frac{3a - b}{11}\\), and \\(\\beta _2= \\frac{4b --- a}{11}\\). Therefore, the set generates \\(\\mathbb{R}^2\\).\n\n</p></answer>\n\n\n*************\n13\n*************\n<answer><p> (d) They are isomorphic. Once you have completed part (a) of this exercise, the following translation rules will give you the answer to parts\n(b) and (c),\n\n\n\n\\((a,b,c,d) \\leftrightarrow  \\left(\n\\begin{array}{cc}\n a &amp; b \\\\\n c &amp; d \\\\\n\\end{array}\n\\right)\\leftrightarrow  a + b x+c x^2+ d x^2\\)\n\n\n\\subsubsection{Section 12.4}\n\n*************\n1.\n*************\n<answer><p> (a) Any nonzero multiple of \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)\\) is an eigenvector associated with \\(\\lambda =1\\).\n\n</p></li>\n<li><p>  Any nonzero multiple of \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)\\) is an eigenvector associated with \\(\\lambda =4\\).\n\n</p></li>\n<li><p>  Let \\(x_1=\\left(\n\\begin{array}{c}\n a \\\\\n -a \\\\\n\\end{array}\n\\right)\\) and \\(x_2=\\left(\n\\begin{array}{c}\n b \\\\\n 2b \\\\\n\\end{array}\n\\right)\\) .  You can verify that  \\(c_1x_1+ c_2x_2=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\)  if and only if \\(c_1= c_2= 0.\\)  Therefore, \\(\\left\\{x_1,x_2\\right\\}\\) is linearly independent.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (c) You should obtain \\(\\left(\n\\begin{array}{cc}\n 4 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\) or \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 4 \\\\\n\\end{array}\n\\right)\\), depending on how you order the eigenvalues.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a)  If  \\(P=\\left(\n\\begin{array}{cc}\n 2 &amp; 1 \\\\\n 3 &amp; -1 \\\\\n\\end{array}\n\\right)\\), then \\(P^{-1}A P=\\left(\n\\begin{array}{cc}\n 4 &amp; 0 \\\\\n 0 &amp; -1 \\\\\n\\end{array}\n\\right)\\).\n\n</p></li>\n<li><p> If  \\(P=\\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n 7 &amp; 1 \\\\\n\\end{array}\n\\right)\\), then \\(P^{-1}A P=\\left(\n\\begin{array}{cc}\n 5 &amp; 0 \\\\\n 0 &amp; -1 \\\\\n\\end{array}\n\\right)\\).\n\n</p></li>\n<li><p> If  \\(P=\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\), then \\(P^{-1}A P=\\left(\n\\begin{array}{cc}\n 3 &amp; 0 \\\\\n 0 &amp; 4 \\\\\n\\end{array}\n\\right)\\).\n\n</p></li>\n<li><p> If  \\(P=\\left(\n\\begin{array}{ccc}\n 1 &amp; -1 &amp; 1 \\\\\n -1 &amp; 4 &amp; 2 \\\\\n -1 &amp; 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\), then \\(P^{-1}A P=\\left(\n\\begin{array}{ccc}\n -2 &amp; 0 &amp; 0 \\\\\n 0 &amp; 1 &amp; 0 \\\\\n 0 &amp; 0 &amp; 0 \\\\\n\\end{array}\n\\right)\\).\n\n</p></li>\n<li><p> <m>A</m> is not diagonalizable. Five is a double root of the characteristic equation, but has an eigenspace with dimension only 1.\n\n</p></li>\n<li><p>  If  \\(P=\\left(\n\\begin{array}{ccc}\n 1 &amp; 1 &amp; 1 \\\\\n -2 &amp; 0 &amp; 1 \\\\\n 1 &amp; -1 &amp; 1 \\\\\n\\end{array}\n\\right)\\), then \\(P^{-1}A P=\\left(\n\\begin{array}{ccc}\n 3 &amp; 0 &amp; 0 \\\\\n 0 &amp; 1 &amp; 0 \\\\\n 0 &amp; 0 &amp; 0 \\\\\n\\end{array}\n\\right)\\).\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (b) This is a direct application of the definition of matrix multiplication. Let \\(A_{(i)}\\) stand for the \\(i^{\\text{th}}\\) row of <m>A</m>,\nand let \\(P^{(j)}\\) stand for the \\(j^{\\text{th}}\\) column of  <m>P</m>.  Hence the \\(j^{\\text{th}}\\) column of the product \\(A P\\) is\n\n\n\n   $\\quad \\quad $\\(\\left(\n\\begin{array}{c}\n A_{(1)}P^{(j)} \\\\\n A_{(2)}P^{(j)} \\\\\n \\vdots  \\\\\n A_{(n)}P^{(j)} \\\\\n\\end{array}\n\\right)\\)\n\n\n\nHence, \\((\\text{AP})^{(j)}= A\\left(P^{(j)}\\right)\\)  for\\(j =1,2,\\ldots , n\\). Thus, each column of \\(A P\\) depends on <m>A</m> and the \\(j^{\\text{th}}\\)\ncolumn of <m>P</m>.\n\n\n\\subsubsection{Section 12.5}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> If we introduce the superfluous equation \\(1 = 0\\cdot S_{k-1} + 1\\) we have the system \n\n\n\n$\\quad \\quad $\\(\\begin{array}{c}\n S_k =5 S_{k-1}+ 4 \\\\\n 1= 0\\cdot S_{k-1} + 1 \\\\\n\\end{array}\\)\n\n\n\n    which, in matrix form, is:\n\n\n\n$\\quad \\quad $\\(\\text{     }\\left(\n\\begin{array}{c}\n S_k \\\\\n 1 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{cc}\n 5 &amp; 4 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n S_{k-1} \\\\\n 1 \\\\\n\\end{array}\n\\right)\\quad =\\left(\n\\begin{array}{cc}\n 5 &amp; 4 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)^k\\left(\n\\begin{array}{c}\n S_0 \\\\\n 1 \\\\\n\\end{array}\n\\right)\\quad =\\left(\n\\begin{array}{cc}\n 5 &amp; 4 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)^k\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)\\quad\\)\n\n\n\n \n\n\n\nLet \\(\\text{A=}\\left(\n\\begin{array}{cc}\n 5 &amp; 4 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\).  We want to diagonalize <m>A</m>; that is,  find a matrix <m>P</m> such that \\(P^{-1}A P = D\\), where <m>D</m> is a diagonal\nmatrix,  or\n\n\n\n$\\quad \\quad $ \\(A =P D P^{-1} \\Rightarrow \\text{  }A^{k }=P D^kP^{\\text{}^{-1}}\\) \n\n\n\nDiagonalizing <m>A</m>:\n\n\n\n\\(\\left| A-c I\\right| =\\left\\left| \n\\begin{array}{cc}\n 5-c &amp; 4 \\\\\n 0 &amp; 1-c \\\\\n\\end{array}\n\\right\\right| = (5-c)(1-c)\\)\n\n\n\nThe eigenvalues are \\(c = 1\\) and \\(c = 5\\).   If \\(c = 1\\),\n\n\n\n\\(\\left(\n\\begin{array}{cc}\n 4 &amp; 4 \\\\\n 0 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nwhich implies \\(x_1+x_2=0\\), or  \\(x_2= -x_2\\), and so  \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)\\) is an eigenvector associated with 1.\n\n\n\nIf c = 5,\n\n\n\n\\(\\left(\n\\begin{array}{cc}\n 0 &amp; 4 \\\\\n 0 &amp; -4 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\text{  }\\Rightarrow \\text{  }x_2= 0\\).\n\n\n\nTherefore, \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\) is an eigenvector associated with  5. Combining the two eigenvectors, we get\n\n\n\n\\(A= \\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n -1 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 5 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n -1 &amp; 0 \\\\\n\\end{array}\n\\right)^{-1}= \\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n -1 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 5 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 0 &amp; -1 \\\\\n 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nand\n\n\n\n\\(\\text{            }A^k= \\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n -1 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 5 \\\\\n\\end{array}\n\\right)^k\\left(\n\\begin{array}{cc}\n 0 &amp; -1 \\\\\n 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\quad = \\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n -1 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 5^k \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n 0 &amp; -1 \\\\\n 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\text{        }=\\left(\n\\begin{array}{cc}\n 5^k &amp; 5^k-1 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nHence,  \\(\\left(\n\\begin{array}{c}\n S_k \\\\\n 1 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{cc}\n 5^k &amp; 5^k-1 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right) =\\left(\n\\begin{array}{c}\n 5^k-1 \\\\\n 1 \\\\\n\\end{array}\n\\right)\\)  and finally, \\(S_k= 5^{k }-1\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Since   \\(A=A^1= \\left(\n\\begin{array}{ccc}\n 1 &amp; 1 &amp; 0 \\\\\n 1 &amp; 0 &amp; 1 \\\\\n 0 &amp; 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\),  there are 0 paths of length 1 from: node c to node a, node b to node h, and node a to node c; and there is 1 path of length\n1 for every other pair of nodes.\n\n</p></li>\n<li><p> The characteristic polynomial is\n\n\n\n\\(\\left| A-c I\\right|  = \\left\\left| \n\\begin{array}{ccc}\n 1-c &amp; 1 &amp; 0 \\\\\n 1 &amp; -c &amp; 1 \\\\\n 0 &amp; 1 &amp; 1-c \\\\\n\\end{array}\n\\right\\right| = -c^3+2 c^2+c-2\\)\n\n\n\nSolving the characteristic equation \\(-c^3+2 c^2+c-2=0\\) we find solutions 1, 2, and -1.\n\n\n\nIf \\(c=1\\), we find the associated eigenvector by finding a nonzero solution to \n\n\n\n\\(\\left(\n\\begin{array}{ccc}\n 0 &amp; 1 &amp; 0 \\\\\n 1 &amp; -1 &amp; 1 \\\\\n 0 &amp; 1 &amp; 0 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\) \n\n\n\nOne of these, which will be the first column of <m>P</m>, is \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nIf \\(c=2\\), the system \\(\\left(\n\\begin{array}{ccc}\n -1 &amp; 1 &amp; 0 \\\\\n 1 &amp; -2 &amp; 1 \\\\\n 0 &amp; 1 &amp; -1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\)  yields eigenvectors, including \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)\\), which will be the second column of \\textit{ P.}\n\n\n\nIf  \\(c = -1\\), then the system determining the eigenvectors is \n\n\n\n\\(\\left(\n\\begin{array}{ccc}\n 2 &amp; 1 &amp; 0 \\\\\n 1 &amp; 1 &amp; 1 \\\\\n 0 &amp; 1 &amp; 2 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{c}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)\\) \n\n\n\nand we can select \\(\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)\\),  although any nonzero multiple of this vector could be the third column of <m>P</m>. \n\n</p></li>\n<li><p> Assembling the results of (b) we have \\(P=\\left(\n\\begin{array}{ccc}\n 1 &amp; 1 &amp; 1 \\\\\n 0 &amp; 1 &amp; -2 \\\\\n -1 &amp; 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\) .\n\n\n\n\\(A^4= P \\left(\n\\begin{array}{ccc}\n 1^4 &amp; 0 &amp; 0 \\\\\n 0 &amp; 2^4 &amp; 0 \\\\\n 0 &amp; 0 &amp; (-1)^{4 } \\\\\n\\end{array}\n\\right)P^{-1}= P \\left(\n\\begin{array}{ccc}\n 1 &amp; 0 &amp; 0 \\\\\n 0 &amp; 16 &amp; 0 \\\\\n 0 &amp; 0 &amp; 1 \\\\\n\\end{array}\n\\right)P^{-1}\\\\\n\\\\\n\\quad =\\left(\n\\begin{array}{ccc}\n 1 &amp; 16 &amp; 1 \\\\\n 0 &amp; 16 &amp; -2 \\\\\n -1 &amp; 16 &amp; 1 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} &amp; 0 &amp; -\\frac{1}{2} \\\\\n \\frac{1}{3} &amp; \\frac{1}{3} &amp; \\frac{1}{3} \\\\\n \\frac{1}{6} &amp; -\\frac{1}{3} &amp; \\frac{1}{6} \\\\\n\\end{array}\n\\right)\\\\\n\\\\\n\\quad =\\left(\n\\begin{array}{ccc}\n 6 &amp; 5 &amp; 5 \\\\\n 5 &amp; 6 &amp; 5 \\\\\n 5 &amp; 5 &amp; 6 \\\\\n\\end{array}\n\\right)\\)\n\n\n\nHence there are five different paths of length 4 between distinct vertices, and six different paths that start and end at the same vertex.  The\nreader can verify these facts from Figure 12.4.1.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a)  \\(e^A=\\left(\n\\begin{array}{cc}\n e &amp; e \\\\\n 0 &amp; 0 \\\\\n\\end{array}\n\\right)\\) ,  \\(e^B=\\left(\n\\begin{array}{cc}\n 0 &amp; 0 \\\\\n 0 &amp; e^2 \\\\\n\\end{array}\n\\right)\\),  and  \\(e^{A+B}=\\left(\n\\begin{array}{cc}\n e &amp; e^2-e \\\\\n 0 &amp; e^2 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p> Let \\pmb{ 0} be the zero matrix, \\(e^{\\pmb{0}}=I + \\pmb{0}+\\frac{\\pmb{0}^2}{2}+\\frac{\\pmb{0}^3}{6}+\\ldots =I\\) .\n\n</p></li>\n<li><p>  Assume that <m>A</m> and <m>B</m> commute. We will examine the first few terms in the product \\(e^Ae^B\\). The pattern that is established\ndoes continue in general. In what follows, it is important that \\(A B = B A\\). For example, in the last step,   \\((A+B)^2\\) expands to \\(A^2+A\nB + B A + B^2\\), not \\(A^2+ 2 A B + B^2\\),  if we can{'}t assume commutativity.\n\n\n\n\\(e^Ae^B= \\left(\\sum _{k=0}^{\\infty } \\frac{A^k}{k!}\\right) \\left(\\sum _{k=0}^{\\infty } \\frac{B^k}{k!}\\right)\\\\\n\\\\\n\\quad =\\left(I + A+\\frac{A^2}{2\\text{  }}+ \\frac{A^3}{6}+ \\cdots \\right)\\left(I +B+\\frac{B^2}{2\\text{  }}+ \\frac{B^3}{6}+ \\cdots \\right)\\\\\n\\\\\n\\quad = I + A + B+ \\frac{A^2}{2}+ A B + \\frac{B^2}{2}+\\frac{A^3}{6}+ \\frac{A^2B}{2}+\\frac{A B^2}{2}+ \\frac{B^3}{6}+\\cdots \\\\\n\\\\\n\\quad = I + (A+B) + \\frac{1}{2}\\left(A^2+ 2 A B + B^2\\right)+ \\frac{1}{6}\\left(A^3+ 3A^2B+ 3A B^2+ B^3\\right)+\\cdots  \\\\\n\\\\\n\\quad =I + (A+B)+ \\frac{1}{2}(A+B)^2+ \\frac{1}{6}(A+B)^3+\\cdots \\text{  }\\\\\n\\\\\n\\quad =e^{A+B}\\)\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> Since A and \\(-A\\)commute, we can apply part d;\n\n\n\n\\(e^Ae^{-A}= e^{A+(-A)}\\\\\n\\\\\n\\quad =e^{\\pmb{0}}\\\\\n\\\\\n\\quad =I\\text{            }\\text{by} \\text{part} b \\text{of} \\text{this} \\text{problem}.\\)\n\n\n\n\n\n\n\\subsubsection{Supplementary Exercises$---$Chapter 12}\n\n*************\n1.\n*************\n<answer><p> (a)   \\(x_1= x_2=x_3= 1\\)\n\n\n\n    (b)  \\(x_1= \\frac{1}{2}\\), \\(x_2= 0\\), \\(x_{3 }= \\frac{1}{2}\\)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>\\(\\left(\n\\begin{array}{ccc}\n -8 &amp; -4 &amp; 1 \\\\\n 7 &amp; 3 &amp; -1 \\\\\n -5 &amp; -2 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Suppose that \\(A^{-1}\\) exists and that \\(\\alpha _1\\left(A x_1\\right)+\\alpha _2\\left(A x_2\\right)\\) is equal to the zero vector, \\pmb{ 0}. By\napplying several laws of matrix algebra, this implies that\n\n\n\n \\(A\\left(\\alpha _1 x_1+\\alpha _2 x_2\\right)=\\pmb{0}\\pmb{\\text{    }}\\Rightarrow \\text{  }\\alpha _1 x_1+\\alpha _2 x_2=\\pmb{0}\\pmb{\\text{\n      }}\\text{since} A^{-1} \\text{exists}\\pmb{\\text{    }}\\\\\n\\\\\n\\quad \\quad \\quad \\Rightarrow \\text{  }\\alpha _1 =\\alpha _2 =0\\text{              }\\text{since} \\left\\{x_1,x_2\\right\\} \\text{is} a\\text{\\textit{$\n$}}\\text{basis}\\\\\n\\\\\n\\quad \\quad \\quad \\Rightarrow  \\left\\{A x_{1,}A x_2\\right\\}\\text{  }\\text{is} \\text{linearly} \\text{independent}\\)\n\n\n\nTo see that \\(\\left\\{A x_{1,}A x_2\\right\\}\\) also spans \\(\\mathbb{R}^2\\) , let \\(b\\in \\mathbb{R}^2\\), we note that since \\(\\left\\{x_1,x_2\\right\\}\\)\nis a basis, it will span \\(A^{-1}b\\):\n\n\n\n \\(\\alpha _1 x_1+\\alpha _2 x_2=A^{-1}b\\text{     }\\text{for} \\text{some} \\alpha _1,\\alpha _2\\in  \\mathbb{R}\\).\n\n\n\nUsing laws of matrix algebra:\n\n\n\n\\(\\alpha _1 \\left(A x_1\\right)+\\alpha _2 \\left(A x_2\\right)=A\\left(\\alpha _1 x_1+\\alpha _2 x_2\\right)\\\\\n\\\\\n\\quad \\quad \\quad =A\\left(A^{-1}b\\right)\\\\\n\\\\\n\\quad \\quad \\quad = b\\)\n\n\n\nHence, <m>b</m> is a linear combination of \\(A x_1\\text{and} A x_2\\).\n\n\n\nIf A has no inverse, then \\(A x =\\pmb \\pmb{0}\\) has a nonzero solution <m>y</m>, which is spanned by the vectors \\(x_1\\) and \\(x_2\\) :  \\(y\n=\\alpha _1 x_1+\\alpha _2 x_2\\), where not both of the $\\alpha ${'}s are zero.\n\n\n\n\\(A y = 0\\text{  }\\Rightarrow \\text{  }A\\left(\\alpha _1 x_1+\\alpha _2 x_2\\right)= \\pmb{0}\\\\\n\\\\\n\\text{    }\\Rightarrow \\text{  }\\alpha _1\\left(A x_1\\right)+\\alpha _2 \\left(A x_2\\right) = 0\\\\\n\\\\\n\\text{     }\\Rightarrow \\left\\{A x_{1,}A x_2\\right\\}\\text{  }\\text{is} \\text{linearly} \\text{dependent}\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (b)   \\(-X = X\\)\n\n\n\n      (c) \\(2^6 = 64\\), since each entry can take on two possible values.\n\n\n\n 9.   \\(A = P^{-1}D P\\text{     }\\Rightarrow \\text{   }A^{100} = P^{-1}D^{100} P\\)\n\n\n\n\\(\\left(\n\\begin{array}{cc}\n 0.6 &amp; 0.2 \\\\\n 0.4 &amp; 0.8 \\\\\n\\end{array}\n\\text{}\\right)=\\frac{1}{3}\\left(\n\\begin{array}{cc}\n 1 &amp; 2 \\\\\n 2 &amp; -1 \\\\\n\\end{array}\n\\text{}\\right)\\left(\n\\begin{array}{cc}\n 1^{100} &amp; 0 \\\\\n 0 &amp; 0.4^{100} \\\\\n\\end{array}\n\\text{}\\right)\\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n 2 &amp; -1 \\\\\n\\end{array}\n\\text{}\\right)\\approx \\left(\n\\begin{array}{cc}\n \\frac{1}{3} &amp; \\frac{1}{3} \\\\\n \\frac{2}{3} &amp; \\frac{2}{3} \\\\\n\\end{array}\n\\text{}\\right)\\)\n\n\n\nNote:  \\(0.4^{100 }=\\text{1.606938044259001$\\grave $*${}^{\\wedge}$-40}\\approx 0 .\\)</p></answer>\n\n\n*************\n11\n*************\n<answer><p> (a) \\(\\lambda  = 0, \\pm \\sqrt{2}\\)\n\n</p></li>\n<li><p>   \\(B=P D P^{-1}= \\left(\n\\begin{array}{ccc}\n 1 &amp; 0 &amp; 0 \\\\\n 0 &amp; 1 &amp; 1 \\\\\n 0 &amp; 0 &amp; -2 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{ccc}\n 4 &amp; 0 &amp; 0 \\\\\n 0 &amp; 4 &amp; 0 \\\\\n 0 &amp; 0 &amp; 2 \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{ccc}\n 1 &amp; 0 &amp; 0 \\\\\n 0 &amp; 1 &amp; \\frac{1}{2} \\\\\n 0 &amp; 0 &amp; -\\frac{1}{2} \\\\\n\\end{array}\n\\right)\\)\n\n</p></answer>\n\n\n*************\n13\n*************\n<answer><p> (a) Let the vertices be \\(a_1\\), \\(a_2\\), and \\(a_3\\); and use the convenient matrix representation\n\n\n\n  \\(\\begin{array}{cc}\n   &amp; \n\\begin{array}{ccc}\n a_1 &amp; a_2 &amp; a_3 \\\\\n\\end{array}\n \\\\\n \n\\begin{array}{c}\n a_1 \\\\\n a_2 \\\\\n a_3 \\\\\n\\end{array}\n &amp; \\left(\n\\begin{array}{ccc}\n 2 &amp; 1 &amp; 0 \\\\\n 1 &amp; 0 &amp; 3 \\\\\n 1 &amp; 1 &amp; 0 \\\\\n\\end{array}\n\\right) \\\\\n\\end{array}\\)\n\n\n\none sees immediately, for example, that there are 3 different edges from \\(a_2\\) to \\(a_3\\), so that the multigraph is\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>  \\(A^2= \\left(\n\\begin{array}{ccc}\n 5 &amp; 2 &amp; 3 \\\\\n 5 &amp; 4 &amp; 0 \\\\\n 3 &amp; 1 &amp; 3 \\\\\n\\end{array}\n\\right)\\)  and by Theorem 12.5.1, \\(\\left(A^2\\right){}_{i j}\\)  is the number of paths of length 2 from \\(a_i\\) to \\(a_j\\). For example, the\nreader can verify from the graph that there are 3 different paths of length 2 from \\(a_1\\) to \\(a_3\\).\n\n\n\\subsection{CHAPTER 13}\n\n\n\\subsubsection{Section 13.1}\n\n*************\n1.\n*************\n<answer><p> (a) 1, 5  (b) 5 $\\quad \\quad $\n\n\n\n    (c) 30  (d) 30 \n\n</p></li>\n<li><p> See Figure 13.4.1 with  0 = 1, \\(a_1=2\\), \\(a_2 = 3\\), \\(a_3=5\\), \\(b_1=6\\), \\(b_2=10\\), \\(b_3= 15\\), and \\(1=30\\)\n\n\n\n 3. Solution for Hasse diagram (b):\n\n\n\n(a)\n\n\n\n$\\quad \\quad $ \\(\\begin{array}{c|c}\n \\text{lub} &amp; \n\\begin{array}{ccccc}\n a_1 &amp; a_2 &amp; a_3 &amp; a_4 &amp; a_5 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n a_1 \\\\\n a_2 \\\\\n a_3 \\\\\n a_4 \\\\\n a_5 \\\\\n\\end{array}\n &amp; \n\\begin{array}{ccccc}\n a_1 &amp; a_2 &amp; a_3 &amp; a_4 &amp; a_5 \\\\\n a_2 &amp; a_2 &amp; a_4 &amp; a_4 &amp; a_5 \\\\\n a_3 &amp; a_4 &amp; a_3 &amp; a_4 &amp; a_5 \\\\\n a_4 &amp; a_4 &amp; a_4 &amp; a_4 &amp; a_5 \\\\\n a_5 &amp; a_5 &amp; a_5 &amp; a_5 &amp; a_5 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)$\\quad \\quad \\quad $\\(\\begin{array}{c|c}\n \\text{glb} &amp; \n\\begin{array}{ccccc}\n a_1 &amp; a_2 &amp; a_3 &amp; a_4 &amp; a_5 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n a_1 \\\\\n a_2 \\\\\n a_3 \\\\\n a_4 \\\\\n a_5 \\\\\n\\end{array}\n &amp; \n\\begin{array}{ccccc}\n a_1 &amp; a_1 &amp; a_1 &amp; a_1 &amp; a_1 \\\\\n a_1 &amp; a_2 &amp; a_1 &amp; a_2 &amp; a_2 \\\\\n a_1 &amp; a_1 &amp; a_3 &amp; a_3 &amp; a_3 \\\\\n a_1 &amp; a_2 &amp; a_3 &amp; a_4 &amp; a_4 \\\\\n a_1 &amp; a_2 &amp; a_3 &amp; a_4 &amp; a_5 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\n(b)  \\(a_1\\)is the least element and \\(a_5\\) is the greatest element. \n\n\n\n     Partial solution for Hasse diagram (f):\n\n\n\n(a) \\(\\text{lub}\\left(a_2, a_3\\right)\\) and \\(\\text{lub}\\left( a_4,a_5\\right)\\)  do not exist.\n\n\n\n(b) No greatest element exists, but \\(a_1\\) is the least element.</p></answer>\n\n\n*************\n5\n*************\n<answer><p>  If \\(0\\) and \\(0'\\) are distinct least elements, then\n\n\n\n  \\(\\left.\n\\begin{array}{cc}\n 0\\leq 0' &amp; \\text{since} 0 \\text{is} a \\text{least} \\text{element} \\\\\n 0'\\leq 0 &amp; \\text{since} 0' \\text{is} a \\text{least} \\text{element} \\\\\n\\end{array}\n\\right\\}\\Rightarrow \\text{  }0=0' \\text{by} \\text{antisymmetry}, a \\text{contradiction}\\). $\\blacksquare $\n\n\n\\subsubsection{Section 13.2}\n\n*************\n1.\n*************\n<answer><p> Assume to the contrary that <m>a</m> and <m>b</m> have two different greatest lower bounds, and call them <m>g</m> and <m>h</m>. Then\n\\(g \\geq  h\\) since <m>g</m> is a greatest lower bound and \\(h\\geq g\\) since <m>h</m> is a greatest lower bound. Therefore, by antisymmetry\n\\(h = g\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) See Table 13.3.1 for the statements of these laws. Most of the proofs follow from the definition of gcd and lcm. \n\n\n\n (b) (partial) We prove two laws as examples.\n\n\n\nCommutative law of join: Let \\([L, \\lor  , \\land ]\\) be a lattice, \\(a, b \\in L\\). We must prove that \\(a \\lor  b = b \\lor  a\\). \n\n\n\nProof: By the definition of least upper bound, \\(a \\lor  b \\geq  b\\) and \\(a \\lor  b \\geq a\\) therefore, by Exercise 4, part c, \\(a \\lor  b \\geq\n b \\lor  a\\). Similarly, \\(b \\lor  a \\geq  a \\lor  b\\), and by antisymmetry \\(a \\lor  b = b \\lor a\\).  $\\blacksquare $\n\n\n\nIdempotent law (for join): We must prove that for all \\(a \\in  L\\), \\(a \\lor  a = a\\). \n\n\n\nProof: By the reflexive property of $\\leq $, \\(a \\leq  a\\) and hence, by 4(c), \\(a\\leq a\\lor a\\).  But <m>a</m> is an upper bound for \\textit{\na;} hence \\(a\\geq a\\lor a\\).  By antisymmetry, \\(a = a \\lor  a\\).   $\\blacksquare $\n\n\n\\subsubsection{Section 13.3}\n\n*************\n1.\n*************\n<answer><p> \n\n\n\n$\\quad \\quad $\\(\\begin{array}{cc}\n B &amp; \\text{Complement} \\text{of} B \\\\\n\\hline\n \n\\begin{array}{c}\n \\emptyset  \\\\\n \\{a\\} \\\\\n \\{b\\} \\\\\n \\{c\\} \\\\\n \\{a,b\\} \\\\\n \\{a,c\\} \\\\\n \\{b,c\\} \\\\\n A \\\\\n\\end{array}\n &amp; \n\\begin{array}{c}\n A \\\\\n \\{b,c\\} \\\\\n \\{a,c\\} \\\\\n \\{a,b\\} \\\\\n \\{c\\} \\\\\n \\{b\\} \\\\\n \\{a\\} \\\\\n \\emptyset  \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nThis lattice is a Boolean algebra since it is a distributive complemented lattice.</p></answer>\n\n\n*************\n3\n*************\n<answer><p>   a and g.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) \\(S^*:a \\lor  b= a \\text{if} a \\geq  b\\)\n\n</p></li>\n<li><p> \\(S:A\\cap B = A\\text{  }\\text{if}\\text{  }A \\subseteq B\\)\n\n\n\n\\(S^*:A \\cup B = A\\text{  }\\text{if} A \\supseteq B\\)\n\n</p></li>\n<li><p> Yes\n\n</p></li>\n<li><p> \\(S:p \\land q\\Leftrightarrow p\\text{   }\\text{if} p\\Rightarrow q\\)\n\n\n\n\\(S^*:p \\lor q\\Leftrightarrow p \\text{if} q\\Rightarrow p\\)\n\n</p></li>\n<li><p> Yes\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> \\pmb{ Definition: Boolean Algebra Isomorphism.} \\([B, \\land , \\lor , -]\\) is isomorphic to \\(\\left[B',\\land ,\\lor , \\tilde{\\text{  }}\\right]\\)if\nand only if there exists a  function \\(T:B \\to  B'\\) such that \n\n</p></li>\n<li><p> <m>T</m> is a bijection;\n\n</p></li>\n<li><p> \\(T(a\\land b)=T(a)\\land T(b)\\text{  }\\text{for} \\text{all} a,b\\in B\\)\n\n</p></li>\n<li><p> \\(T(a\\lor b)=T(a)\\lor T(b)\\text{  }\\text{for} \\text{all}\\text{  }a, b \\in B\\)\n\n</p></li>\n<li><p> \\(T\\left(\\overset{\\pmb{\\_}}{a}\\right)=\\overset{\\sim }{T(a)}\\text{  }\\text{for} \\text{all} a\\in B\\).\n\n\n\\subsubsubsection{Section 13.4}\n\n*************\n1.\n*************\n<answer><p> (a) For \\(a = 3\\) we must show that for each \\(x \\in  D_{30}\\)  one of the following is true: \\(x\\land 3=3\\) or \\(x\\land 3=1\\).  We do this\nthrough the following table:\n\n\n\n$\\quad \\quad $\\(\\begin{array}{cc}\n x &amp; \\text{verification} \\\\\n\\hline\n \n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 3 \\\\\n 5 \\\\\n 6 \\\\\n 10 \\\\\n 15 \\\\\n 30 \\\\\n\\end{array}\n &amp; \n\\begin{array}{c}\n 1\\land 3=1 \\\\\n 2\\land 3=1 \\\\\n 3\\land 3=3 \\\\\n 5\\land 3=1 \\\\\n 6\\land 3=3 \\\\\n 20\\land 3=1 \\\\\n 15\\land 3=3 \\\\\n 30\\land 3=3 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nFor \\(a=5\\), a similar verification can be performed.\n\n</p></li>\n<li><p>\\(6 = 2 \\lor  3\\), \\(10 = 2 \\lor  5\\), \\(15 = 3 \\lor  5\\), and \\(30 = 2 \\lor  3 \\lor  5\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> If \\(B = D_{30}\\text{}\\) 30 then \\(A = \\{2, 3, 5\\}\\) and \\(D_{30}\\) is isomorphic to \\(\\mathcal{P}(A)\\), where\n\n\n\n\\(\\begin{array}{cc}\n 1\\leftrightarrow \\emptyset \\text{    } &amp; 5\\leftrightarrow  \\{5\\} \\\\\n 2\\leftrightarrow  \\{2\\}\\text{    } &amp; \\text{  }10\\leftrightarrow  \\{2,5\\} \\\\\n 3\\leftrightarrow  \\{3\\}\\text{    } &amp; 15\\leftrightarrow  \\{3,5\\} \\\\\n 6\\leftrightarrow  \\{2,3\\}\\text{  } &amp; 30\\leftrightarrow  \\{2,3,5 \\\\\n\\end{array}\\)   and   \\(\\begin{array}{c}\n \\text{Join} \\leftrightarrow  \\text{Union} \\\\\n \\text{Meet}\\leftrightarrow  \\text{Intersection} \\\\\n \\text{Complement}\\leftrightarrow  \\text{Set} \\text{Complement}  \\\\\n\\end{array}\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Assume that \\(x \\neq  0\\text{  }\\text{or} 1\\) is the third element of a Boolean algebra. Then there is only one possible set of tables for join\nand meet, all following from required properties of the Boolean algebra.\n\n\n\n\\(\\begin{array}{c|c}\n \\lor  &amp; \n\\begin{array}{ccc}\n 0 &amp; x &amp; 1 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 0 \\\\\n x \\\\\n 1 \\\\\n\\end{array}\n &amp; \n\\begin{array}{ccc}\n 0 &amp; x &amp; 1 \\\\\n x &amp; x &amp; 1 \\\\\n 1 &amp; 1 &amp; 1 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)         \\(\\begin{array}{c|c}\n \\land  &amp; \n\\begin{array}{ccc}\n 0 &amp; x &amp; 1 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 0 \\\\\n x \\\\\n 1 \\\\\n\\end{array}\n &amp; \n\\begin{array}{ccc}\n 0 &amp; 0 &amp; 0 \\\\\n 0 &amp; x &amp; x \\\\\n 0 &amp; x &amp; 1 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nNext, to find the complement of <m>x</m> we want <m>y</m> such that \\(x \\land  y = 0\\) and \\(x \\lor  y = 1\\). No element satisfies both conditions;\nhence the lattice is not complemented and cannot be a Boolean algebra. The lack of a complement can also be seen from the ordering diagram from which\n\\(\\land\\) and \\(\\lor\\) must be derived.</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Let <m>X</m> be any countably infinite set, such as the integers. A subset of <m>X</m> is \\textit{ cofinite} if it is finite or its complement\nis finite. The set of all cofinite subsets of <m>X</m> is:\n\n</p></li>\n<li><p> Countably infinite - this might not be obvious, but here is a hint.  Assume \\(X=\\left\\{x_0,x_1,x_2,\\ldots \\right\\}\\).  For each finite subset\n<m>A</m> of <m>X</m>,  map that set to the integer\n\n\n\n\\(\\sum _{i=0}^{\\infty } \\chi _A \\left(x_i\\right)2^i\\)  \n\n\n\nYou can do a similar thing to sets that have a finite complement, but map them to negative integers.  Only one minor adjustment needs to be made\nto accommodate both the empty set and <m>X</m>.  \n\n</p></li>\n<li><p> Closed under union\n\n</p></li>\n<li><p> Closed under intersection, and\n\n</p></li>\n<li><p> Closed under complementation.\n\n\n\nTherefore, if \\(B =\\{A \\subseteq  X : A \\text{is} \\text{cofinite}\\}\\), then <m>B</m> is a countable Boolean algebra under the usual set operations.\n\n\n\\subsubsubsection{Section 13.5}\n\n*************\n1.\n*************\n<answer><p> (a)\n\n\n\n\\(\\quad \n\\begin{array}{c|c}\n \\lor  &amp; \n\\begin{array}{cccc}\n (0,0) &amp; (0,1) &amp; (1,0) &amp; (1,1) \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n (0,0) \\\\\n (0,1) \\\\\n (1,0) \\\\\n (1,1) \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccc}\n (0,0) &amp; (0,1) &amp; (1,0) &amp; (1,1) \\\\\n (0,1) &amp; (0,1) &amp; (1,1) &amp; (1,1) \\\\\n (1,0) &amp; (1,1) &amp; (1,0) &amp; (1,1) \\\\\n (1,1) &amp; (1,1) &amp; (1,1) &amp; (1,1) \\\\\n\\end{array}\n \\\\\n\\end{array}\n\\text{          }\n\\begin{array}{c|c}\n \\land  &amp; \n\\begin{array}{cccc}\n (0,0) &amp; (0,1) &amp; (1,0) &amp; (1,1) \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n (0,0) \\\\\n (0,1) \\\\\n (1,0) \\\\\n (1,1) \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccc}\n (0,0) &amp; (0,0) &amp; (0,0) &amp; (0,0) \\\\\n (0,0) &amp; (0,1) &amp; (0,0) &amp; (0,1) \\\\\n (0,0) &amp; (0,0) &amp; (1,0) &amp; (1,0) \\\\\n (0,0) &amp; (0,1) &amp; (10) &amp; (1,1) \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\n    \\(\\begin{array}{c|c}\n u &amp; \\overset{\\pmb{\\_}}{u} \\\\\n\\hline\n \n\\begin{array}{c}\n (0,0) \\\\\n (0,1) \\\\\n (1,0) \\\\\n (1,1) \\\\\n\\end{array}\n &amp; \n\\begin{array}{c}\n (1,1) \\\\\n (1,0) \\\\\n (0,1) \\\\\n (0,0) \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n</p></li>\n<li><p>  The graphs are isomorphic.\n\n</p></li>\n<li><p>  (0, 1) and (1,0)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) \\((1, 0, 0, 0)\\), \\((0, 1, 0, 0)\\), \\((0, 0, 1, 0)\\), and \\((0, 0, 0, 1)\\) are the atoms. \n\n\n\n   </p></li>\n<li><p> The <m>n</m>-tuples of 0{'}s and 1{'}s with exactly one 1.\n\n\n\\subsubsubsection{Section 13.6}\n\n\n\n1 (a)\n\n\\begin{doublespace}\n\\noindent\\(\\begin{array}{l}\n M_1\\left(x_1,x_2\\right)=0 \\\\\n M_2\\left(x_1,x_2\\right)=\\left(\\overline{x_1}\\land \\overline{x_2}\\right) \\\\\n M_3\\left(x_1,x_2\\right)=\\left(\\overline{x_1}\\land x_2\\right) \\\\\n M_4\\left(x_1,x_2\\right)=\\left(x_1\\land \\overline{x_2}\\right) \\\\\n M_5\\left(x_1,x_2\\right)=\\left(x_1\\land x_2\\right) \\\\\n M_6\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(\\overline{x_1}\\land x_2\\right)\\right)=\\overline{x_1} \\\\\n M_7\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\right)=\\overline{x_2} \\\\\n M_8\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=\\left(\\left(x_1\\land x_2\\right)\\lor\n\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\right) \\\\\n M_9\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\right)=\\left(\\left(x_1\\land \\overline{x_2}\\right)\\lor\n\\left(\\overline{x_1}\\land x_2\\right)\\right) \\\\\n M_{10}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=x_2 \\\\\n M_{11}\\left(x_1,x_2\\right)=\\left(\\left(x_1\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=x_1 \\\\\n M_{12}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\right)=\\left(\\overline{x_1}\\lor\n\\overline{x_2}\\right) \\\\\n M_{13}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=\\left(\\overline{x_1}\\lor\nx_2\\right) \\\\\n M_{14}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=\\left(x_1\\lor\n\\overline{x_2}\\right) \\\\\n M_{15}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\lor \\left(x_1\\land x_2\\right)\\right)=\\left(x_1\\lor\nx_2\\right) \\\\\n M_{16}\\left(x_1,x_2\\right)=\\left(\\left(\\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(x_1\\land \\overline{x_2}\\right)\\lor\n\\left(x_1\\land x_2\\right)\\right)=1 \\\\\n\\end{array}\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>  The truth table for the functions in part (a) are\n\n\\begin{doublespace}\n\\noindent\\(\\begin{array}{llllllllllllllllll}\n x_1 &amp; x_2 &amp; M_1 &amp; M_2 &amp; M_3 &amp; M_4 &amp; M_5 &amp; M_6 &amp; M_7 &amp; M_8 &amp; M_9 &amp; M_{10} &amp; M_{11} &amp; M_{12} &amp; M_{13} &amp; M_{14} &amp; M_{15} &amp; M_{16} \\\\\n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 1 \\\\\n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 0 &amp; 1 &amp; 1 &amp; 0 &amp; 1 &amp; 1 \\\\\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 1 &amp; 1 &amp; 0 &amp; 1 &amp; 1 &amp; 1 \\\\\n 1 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 1 &amp; 1 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 \\\\\n\\end{array}\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>        \\(f_1\\left(x_1,x_2\\right)=M_{15}\\left(x_1,x_2\\right)\\)\n\n\n\n\\(f_2\\left(x_1,x_2\\right)=M_{12}\\left(x_1,x_2\\right)\\)\n\n\n\n\\(f_3\\left(x_1,x_2\\right)=M_1\\left(x_1,x_2\\right)\\)\n\n\n\n\\(f_4\\left(x_1,x_2\\right)=M_{16}\\left(x_1,x_2\\right)\\)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) The number of elements in the domain of <m>f</m> is \\(16=4^2=\\left| B\\right| ^2\\)\n\n</p></li>\n<li><p> With two variables, there are \\(4^3 = 256\\) different Boolean functions. With three variables, there are \\(4^8=65536\\) different Boolean functions.\n\n</p></li>\n<li><p>     \\(f\\left(x_1,x_2\\right)=\\left(1\\land \\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(1\\land \\overline{x_1}\\land x_2\\right)\\lor \\left(1\\land\nx_1\\land \\overline{x_2}\\right)\\lor \\left(0\\land x_1\\land x_2\\right)\\)\n\n</p></li>\n<li><p> Consider \\(f:B^2\\to B\\), defined by \\(f(0,0)=0\\), \\(f(0,1)=1\\), \\(f(1,0)=a\\), \\(f(1,1)=a\\), and \\(f(0,a)=b\\), with the images of all other pairs\nin \\(B^2\\) defined arbitrarily. This function is not a Boolean function.  If we assume that it is Boolean function then <m>f</m> can be computed\nwith a Boolean expression \\(M\\left(x_1,x_2\\right)\\). This expression can be put into minterm normal form:\n\n\n\n\\(M\\left(x_1,x_2\\right)=\\left(c_1\\land \\overline{x_1}\\land \\overline{x_2}\\right)\\lor \\left(c_2\\land \\overline{x_1}\\land x_2\\right)\\lor \\left(c_3\\land\nx_1\\land \\overline{x_2}\\right)\\lor \\left(c_4\\land x_1\\land x_2\\right)\\)\n\n\n\n$\\quad \\quad $\\(f(0,0)=0 \\Rightarrow  M(0,0)=0 \\Rightarrow  c_1= 0\\\\\n\\\\\nf(0,1)=1 \\Rightarrow  M(0,0)=1 \\Rightarrow  c_1= 1\\\\\n\\\\\nf(1,0)=a \\Rightarrow  M(0,0)=a \\Rightarrow  c_1= a\\\\\n\\\\\nf(1,1)=a \\Rightarrow  M(0,0)=a \\Rightarrow  c_1= a\\)\n\n\n\nTherefore, \n\n\n\n\\(M\\left(x_1,x_2\\right)=\\left(\\overline{x_1}\\land x_2\\right)\\lor \\left(a\\land x_1\\land \\overline{x_2}\\right)\\lor \\left(a\\land x_1\\land x_2\\right)\\)\n\n\n\n\\(M(0,a)=\\left(\\bar{0}\\land a\\right)\\lor \\left(a\\land 0\\land \\bar{a}\\right)\\lor (a\\land 0\\land a)=a\\)\n\n\n\nThis contradicts \\(f(0,a)=b\\), and so <m>f</m> is not a Boolean function.\n\n\n\\subsubsubsection{Section 13,7}\n\n*************\n1.\n*************\n<answer><p> (a)\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>   \\(\\text{     }f \\left(x_1,x_2,x_3\\right)= \\overline{\\left(\\left(x_1+x_2\\right)\\cdot x_3\\right)}\\cdot \\left(x_1+x_2\\right)\\quad \\quad =\\left(\\overline{\\left(x_1+x_2\\right)}+\\overline{x_3}\\right)\\cdot\n\\left(x_1+x_2\\right)\\quad \\quad =\\overline{\\left(x_1+x_2\\right)}\\cdot \\left(x_1+x_2\\right)+\\overline{x_3}\\cdot \\left(x_1+x_2\\right)\\quad \\quad =0+\\overline{x_3}\\cdot\n\\left(x_1+x_2\\right)\\quad \\quad =\\overline{x_3}\\cdot \\left(x_1+x_2\\right)\\)\n\n</p></li>\n<li><p> The Venn diagram for the function is:\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\n      We can read off the minterm normal form from this diagram:\n\n\n\n\\(f\\left(x_1,x_2,x_3\\right)=x_1\\cdot \\overline{x_2}\\cdot \\overline{x_3}+x_1\\cdot x_2\\cdot \\overline{x_3}+\\overline{x_1}\\cdot x_2\\cdot \\overline{x_3}\\)\n\n</p></li>\n<li><p>\n\n\n\nSimplified form:\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\nCurrent will flow only when one of the switches \\(x_1\\) or \\(x_2\\) is On and \\(x_3\\) is Off.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>  \\(\\text{   }f \\left(x_1,x_2,x_3\\right)=\\left(\\left(\\left(x_1\\cdot x_2\\right)+x_3\\right)\\cdot \\left(x_2+x_3\\right)\\right)+x_3\\text{$\\quad \\quad\n$        }\\text{placing}\\text{  }( )'s \\text{to} \\text{indicate} \\text{order} \\text{of} \\text{evaluation}\\quad \\quad =\\left(\\left(\\left(x_1\\cdot\nx_2\\right)\\cdot \\left(x_2\\right)\\right)+x_3\\right)+x_3\\text{$\\quad \\quad $            }\\text{by} \\text{the} \\text{distributive} \\text{law} \\text{of}\n+ \\text{over} \\cdot \\text{             }=\\left(x_1\\cdot \\left(x_2\\cdot x_2\\right)\\right)+\\left(x_3+x_3\\right)\\text{$\\quad \\quad $       \n    }\\text{by} \\text{the} \\text{associative} \\text{laws} \\text{of} \\cdot  \\text{and} +\\text{             }=\\left(x_1\\cdot x_2\\right)+x_3\\text{$\\quad\n\\quad $            }\\text{by} \\text{the} \\text{idempotent} \\text{laws} \\text{of} \\cdot  \\text{and} +\\)\n\n\n\n\\\\\n\\hspace*{0.5ex} (c)\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\\subsubsubsection{Supplementary Exercises$---$Chapter 13}\n\n*************\n1.\n*************\n<answer><p><ol label=\"a\">\n<li><p>  The following Sage input generates an ordering diagram.\n\n\n\n   Poset($\\{$1:[2,3,5,7,11],2:[4,6,10],3:[6,9],4:[6,8,12],5:[10],6:[12]$\\}$).plot()\n\n\n\n                          \\(\\includegraphics{Sol_9-16_gr1.eps}\n\n\\)\n\n\n\n      (b)  The ordering diagram for \\(\\leq\\) is a chain\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{                  }}\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) \\(4 \\lor  8 = 8\\), \\(3 \\lor  15 = 15\\), \\(4 \\land  8 = 4\\), \\(3 \\land  15 = 3\\), \\(3 \\land  5 - 15\\).\n\n\n\n    (b)Yes. Let \\(a, b, c \\in P\\) and assume that there are <m>n</m> primes, \\(p_1\\), \\(p_2\\), $\\ldots $, \\(p_n\\) that appear as factors of\n<m>a</m>, <m>b</m> and <m>c</m>. Then we can write\n\n\n\n\\(a = p_1{}^{i_1}p_2{}^{i_2}\\cdots  p_n{}^{i_n}\\)\n\n\n\n \\(b= p_1{}^{j_1}p_2{}^{j_2}\\cdots  p_n{}^{j_n}\\)\n\n\n\n\\(c= p_1{}^{k_1}p_2{}^{k_2}\\cdots  p_n{}^{k_n}\\)\n\n\n\nwhere each exponent is a nonnegative integer. The greatest common divisor and least common multiple of two integers such as <m>a</m> and \\textit{\nb} can be expressed in terms of these exponents.\n\n\n\n\\(a \\land  b = \\gcd (a, b)\\text{  }= p_1{}^{m_1}p_2{}^{m_2}\\cdots  p_n{}^{m_n}\\) \n\n\n\nwhere \\(m_r=\\min \\left(i_r, j_r\\right)\\) and\n\n\n\n\\(a \\lor  b = \\text{lcm}(a, b)\\text{  }= p_1{}^{M_1}p_2{}^{M_2}\\cdots  p_n{}^{M_n}\\) \n\n\n\nwhere \\(M_r=\\max \\left(i_r, j_r\\right)\\).\n\n\n\nBased on this observation, we can compare \\(a \\land  (b \\lor  c )\\) and \\(( a\\land b) \\lor  (a \\land c)\\). The exponent of p, is \\(\\min \\left(i_r,\\max\n\\left(j_r, k_r \\right)\\right)\\) in \\(a \\land  (b \\lor  c )\\) and \\(\\max \\left(\\min \\left(i _r , j_r\\right), \\min \\left(i_r , k _r \\right)\\right)\\)\nin \\((a \\land  b) \\lor  (a \\land  c)\\). These two exponents are equal; this is easiest to verify by checking the possible relative sizes of \\(i_r\\),\n\\(j_r\\) and \\(k_r\\).  Therefore, the lattice is distributive.\n\n</p></li>\n<li><p> The least element is 1. There is no greatest element.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) The ordering diagram is the one-cube in Figure 9.4.5. It is interesting to note that the poset relation is really the logical implication,\n\\(\\Rightarrow\\),  since \\(0\\Rightarrow  0\\),  \\(0 \\Rightarrow 1\\), \\(1 \\Rightarrow  1\\) are all true statements.\n\n</p></li>\n<li><p>From the definitions of lub and glb and part (a) we have the tables\n\n\n\n\\(\\begin{array}{c|c}\n \\land  &amp; \n\\begin{array}{cc}\n 0 &amp; 1 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cc}\n 0 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)     \\(\\begin{array}{c|c}\n \\lor  &amp; \n\\begin{array}{cc}\n 0 &amp; 1 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cc}\n 0 &amp; 1 \\\\\n 1 &amp; 1 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nwhich are the logical tables for the connectives {``}and{''} and {``}or.{''}\n\n</p></li>\n<li><p> \\(L ^2 = L \\times  L = \\{(0, 0), (0, 1), (1, 0), (1, 1)\\}\\) where the poset relation $\\leq $ on \\(L^2\\) and the binary operations $\\land $ and\n$\\lor $ are all defined componentwise so that, for example, \\((0, 1) \\leq  (1, 1)\\), since in the two first coordinates, \\(0\\leq 1\\) and in the two\nsecond coordinates, \\(1\\leq 1\\). Also, for example, \\((0, 1) \\land  (1, 0) = (0 \\land  1, 1 \\land  0) = (0, 0)\\). The operation tables are given\nin the solution of Exercise 1 Section 13.5. The Hasse diagram for \\(L^2\\) is the two-cube.\n\n</p></li>\n<li><p> The Hasse diagram for \\(L^3\\) is the three-cube.  Tables for $\\land $ and $\\lor $ can\n\n\n\neasily be constructed where, for example,\n\n\n\n \\((1, 0, 0) \\lor  (0, 1, 0) = (1 \\lor  0,0\\lor 1,0\\lor 0)=(1,1,0)\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a) No. It is not true that every pair of elements in <m>A</m> has both a \\textit{ lub} and a \\textit{ glb}\n\n\n\nin <m>A</m>.  For example, \\(10 \\lor  4\\) does not exist in \\textit{ A.}\n\n</p></li>\n<li><p>  Yes. For all \\(a, b \\in  A\\), \\(a \\neq b\\),\n\n\n\n \\(a \\lor  b = \\text{the} \\text{maximum} \\text{of} a \\text{and} b\\),\n\n\n\n \\(a \\land  b = \\text{the} \\text{minimum} \\text{of} a \\text{and} b.\\)</p></answer>\n\n\n*************\n9\n*************\n<answer><p> \\(\\text{            }(x + y) \\cdot  \\left(x + \\bar{y}\\right) =x + \\left(y \\cdot \\bar{y}\\right)\\text{   }\\text{by} \\text{the} \\text{distributive}\n\\text{law} \\text{of} + \\text{over} \\cdot \\text{$\\quad \\quad $        }= x + 0\\text{          }\\text{by} \\text{the} \\text{complement} \\text{law}\\quad\n\\quad \\quad = x\\text{                    }\\text{by} \\text{the} \\text{identity} \\text{law}\\)\n\n\n\nThe switching circuit diagram has a single switch labeled <m>x</m>.\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p><ol label=\"a\">\n<li><p>\n\n\n\n\\(\\begin{array}{c|c}\n x &amp; \\text{complement}(s) \\text{of} x \\\\\n\\hline\n \n\\begin{array}{c}\n 0 \\\\\n a_1 \\\\\n a_2 \\\\\n a_3 \\\\\n a_4 \\\\\n a_5 \\\\\n a_6 \\\\\n 1 \\\\\n\\end{array}\n &amp; \n\\begin{array}{c}\n 1 \\\\\n a_2,a_3,a_4,a_6 \\\\\n a_1,a_5 \\\\\n a_1,a_5 \\\\\n a_1,a_5 \\\\\n a_2,a_3,a_4,a_6 \\\\\n a_1,a_5 \\\\\n 0 \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n</p></li>\n<li><p>  No, it is not distributive, for if it were, complements would be unique.</p></answer>\n\n\n*************\n13\n*************\n<answer><p> (a) \\(D _{20} = \\{1, 2, 4, 5, 10, 20\\}\\) contains 6 elements and so cannot be a Boolean algebra by Corollary 13.4.1.\n\n</p></li>\n<li><p>  \\(D_{27}=\\{1,3,9, 27\\}\\) has four elements and so we cannot use Corollary 13.4.1 to rule it out as a Boolean algebra. However, 3 has no complement,\nwhich means that \\(D_{27}\\) is not a Boolean algebra.\n\n</p></li>\n<li><p>  \\(D_{35} = \\{1, 5, 7, 35\\}\\) has \\(4 = 2^2\\) elements, and so that it may be a Boolean algebra by Corollary 13.4.1.  We can confirm through\nthe definition of a Boolean algebra that it is.\n\n</p></li>\n<li><p> Notice that \\(210=2\\cdot 3\\cdot 5\\cdot 7\\), which means that  \\(\\left\\left| D_{210}\\right\\right|  = 16 =2^4\\) and so Corollary 13.4.1 can{'}t\nbe used to rule it out as a Boolean algebra.  Indeed,  \\(D_{210}\\) is a Boolean algebra, which can be confirmed by applying the definition of\na Boolean algebra.\n\n</p></answer>\n\n\n*************\n15\n*************\n<answer><p> (a) First, by definition of subsystem in Section 11.5, a sub-Boolean algebra of a Boolean algebra <m>B</m> is a subset <m>W</m> of \\textit{\nB} which is a Boolean algebra under the same operations as <m>B</m>.  Specifically, W must satisfy the conditions:\n\n</p></li>\n<li><p> The 0 and 1 of <m>B</m> must be in <m>W</m>,\n\n\n\n(ii) \\(a \\in  W \\Rightarrow  \\bar{a} \\in  W\\)\n\n\n\n(iii) \\(a,b\\in W\\Rightarrow a\\lor b\\in W \\text{and} a\\land b\\in W\\). \n\n\n\nHence if <m>W</m> is to contain 4 elements it must be of the form \\(\\left\\{0, \\beta , \\bar{\\beta }, 1\\right\\}\\). \\(W_1 = \\{(0, 0, 0), (0, 1, 1),\n(1, 0, 0), (1,1, 1)\\}\\) is one such set. The 3-cube below illustrates this sub-Boolean algebra.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\n There are two others that are isomorphic to this one, where Corollary 13.4.2, assures us of this isomorphism.\n\n</p></li>\n<li><p>Again, the form of the sub-Boolean algebra with four elements must be \\(\\left\\{0, \\beta , \\overline{\\beta ,} 1\\right\\}\\). Since the \\(2^n\\) elements\nof \\(B_2{}^n\\) can be paired up with their complements to give us \\(2^{n-1}\\) pairs, there are \\(2^{n-1}-1\\)  ways to select the elements $\\beta\n$ and \\(\\bar{\\beta }\\) (0 and its complement, 1, are already selected).  Of course, all of these sub-Boolean algebras are isomorphic.\n\n</p></li>\n<li><p>A sub-Boolean algebra with \\(2^k\\) elements must have <m>k</m> atoms; so the selection of <m>k</m> elements that will act as atoms can be\nconsidered in counting numbers of sub-Boolean algebras of a certain size.  What is the number?  We leave it to the reader in the general case.\n\n</p></answer>\n\n\n*************\n17\n*************\n<answer><p>  \\(\\left(\\overline{x_1}\\land x_2\\land x_3\\right)\\lor \\left(\\overline{x_1}\\land \\overline{x_2}\\land x_3\\right)\\lor \\left(x_1\\land x_2\\land x_3\\right)\\)\n\n</p></answer>\n\n\n*************\n19\n*************\n<answer><p><ol label=\"a\">\n<li><p> Since each of the three variables can be any one of two values there are \\(2^3\\) rows, (See Table 13.6.3 for an example.) For \\textit{\nn} variables there are \\(2^n\\) rows. \n\n</p></li>\n<li><p> For each row, there can be any one of two truth values. Since there are \\(2^3=8\\)  rows there are \\(2^8= 256\\) functions. For <m>n</m> variables\nand \\(m =2^n\\) rows, there are \\(2^m=2^{2^n}\\) functions.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p>   \\(f\\left(x_1,x_2,x_3\\right)=\\left(\\left(x_1+ x_2+x_3\\right)\\cdot \\overline{x_1}+x_1+\\overline{x_2}\\right)\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad =\\left(x_1\\cdot \\overline{x_1}+ x_2\\cdot \\overline{x_1}+x_3\\cdot \\overline{x_1}+x_1+\\overline{x_2}\\right)\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad =\\left(0+ x_2\\cdot \\overline{x_1}+x_3\\cdot \\overline{x_1}+x_1+\\overline{x_2}\\right)\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad =\\left( x_2\\cdot \\overline{x_1}+x_3\\cdot \\overline{x_1}+x_1+\\overline{x_2}\\right)\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad = x_2\\cdot \\overline{x_1}\\cdot x_1\\cdot \\overline{x_3}+x_3\\cdot \\overline{x_1}\\cdot x_1\\cdot \\overline{x_3}+x_1\\cdot x_1\\cdot \\overline{x_3}+\\overline{x_2}\\cdot\nx_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad = x_2\\cdot 0\\cdot \\overline{x_3}+x_3\\cdot 0\\cdot \\overline{x_3}+x_1\\cdot \\overline{x_3}+\\overline{x_2}\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad =x_1\\cdot \\overline{x_3}+\\overline{x_2}\\cdot x_1\\cdot \\overline{x_3}\\\\\n\\\\\n\\quad \\quad =x_1\\cdot \\overline{x_3} \\cdot \\left(1+\\overline{x_2}\\right)\\)\n\n\n\n       Switching and gate diagrams to be added.\n\n</p></answer>\n\n\n*************\n23\n*************\n<answer><p> (a)   \\(z =\\left(\\overline{x_1}+x_2\\right)+ \\overline{x_2\\cdot x_3}\\)\n\n</p></li>\n<li><p>    \\(z=\\left(\\overline{x_1}+x_2\\right)+ \\overline{x_2\\cdot x_3}\\\\\n\\\\\n\\quad =\\left(\\overline{x_1}+x_2\\right)+ \\left(\\overline{x_2}+\\overline{x_3}\\right)\\\\\n\\\\\n\\quad =\\overline{x_1}+\\left(x_2+ \\overline{x_2}\\right)+\\overline{x_3}\\\\\n\\\\\n\\quad =\\overline{x_1}+1+\\overline{x_3}\\\\\n\\\\\n\\quad =1\\)\n\n\n\n     The circuit is always on, no gates are necessary.\n\n\n\\subsection{CHAPTER 14}\n\n\n\\subsubsection{Section 14.1}\n\n*************\n1.\n*************\n<answer><p> (a) \\(S_1\\) is not a submonoid since the identity of \\(\\left[\\mathbb{Z}_8 ,\\times _8\\right]\\), which is 1, is not in \\(S_1\\).   \\(S_2\\) is a\nsubmonoid since \\(1 \\in  S_2\\) and \\(S_2\\) is closed under multiplication; that is, for all \\(a, b \\in  S_2\\), \\(a\\times _8b\\) is in \\(S_2\\).\n\n</p></li>\n<li><p>The identity of \\(\\mathbb{N}^{\\mathbb{N}}\\) is the identity function \\(i:\\mathbb{N}\\to \\mathbb{N}\\) defined by \\(i(a) = a\\), \\(\\forall a\\in \\mathbb{N}\\).\nIf \\(a \\in \\mathbb{N}\\), \\(i(a) = a \\leq  a\\), thus the identity of \\(\\mathbb{N}^{\\mathbb{N}}\\) is in \\(S_1\\). However, the image of 1 under any\nfunction in \\(S_2\\) is 2, and thus the identity of \\(\\mathbb{N}^{\\mathbb{N}}\\) is not in \\(S_2\\), so \\(S_2\\) is not a submonoid. The composition\nof any two functions in \\(S_1\\),  <m>f</m> and <m>g</m>, will be a function in \\(S_1\\):\n\n\n\n  \\(\\text{        }(f\\circ g)(n)= f(g(n)) \\leq g(n)\\text{   }\\text{since} f \\text{is} \\text{in} S_1\\quad \\quad \\quad \\leq n\\text{    }\\text{since}\ng \\text{is} \\text{in} S_1\\)\n\n\n\nThus \\(f\\circ g\\in S_1\\), and the two conditions of a submonoid are satisfied and \\(S_1\\) is a submonoid of  \\(\\mathbb{N}^{\\mathbb{N}}\\) .\n\n</p></li>\n<li><p>  The first set is a submonoid, but the second is not since the null set has a non-finite complement.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> The set of \\(n \\times  n\\) real matrices is a monoid under matrix multiplication. This follows from the laws of matrix algebra in Chapter 5. To\nprove that the set of stochastic matrices is a monoid over matrix multiplication, we need only show that the identity matrix is stochastic (this\nis obvious) and that the set of stochastic matrices is closed under matrix multiplication. Let <m>A</m> and <m>B</m> be \\(n \\times  n\\) stochastic\nmatrices.\n\n\n\n \\((A B)_{i j}= \\sum _{k=1}^n a_{i k} b_{k j}\\)\n\n\n\nThe sum of the \\(j^{\\text{th}}\\) column is\n\n\n\n\\(\\text{           }\\sum _{j=1}^n (A B)_{i j}=\\sum _{k=1}^n a_{1 k} b_{k j}+\\sum _{k=1}^n a_{1k} b_{k j}+\\cdots +\\sum _{k=1}^n a_{n k} b_{k\nj}\\quad \\quad =\\sum _{k=1}^n \\left(a_{1 k} b_{k j}+a_{1k} b_{k j}+\\cdots +a_{n k} b_{k j}\\right)\\quad \\quad =\\sum _{k=1}^n b_{k j}\\left(a_{1 k} +a_{1k}+\\cdots\n+a_{n k} \\right)\\text{  }\\quad \\quad = \\sum _{k=1}^n  b_{k j}\\text{               }\\text{since} A \\text{is} \\text{stochastic}\\quad \\quad = 1\\text{\n                           }\\text{since} B \\text{is} \\text{stochastic}\\)\n\n\n\\subsubsection{Section 14.2}\n\n*************\n1.\n*************\n<answer><p> (a) For a character set of 350 symbols, the number of bits needed for each character is the smallest <m>n</m> such that \\(2^n\\) is greater\nthan or equal to 350.  Since   \\(2^9= 512> 350 > 2^8\\) ,  9 bits are needed, \n\n</p></li>\n<li><p> \\(2^{12}=4096>3500>2^{11}\\); therefore, 12 bits are needed.</p></answer>\n\n\n*************\n3\n*************\n<answer><p> This grammar defines the set of all strings over <m>B</m> for which each string is a palindrome (same string if read forward or backward).\n\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) Terminal symbols: The null string, 0, and 1.\n\n\n\n         Nonterminal symbols: \\textit{ S, E.} \n\n\n\n         Starting symbol: S.\n\n\n\n         Production rules: \\(S\\to 00S\\), \\(S\\to 01S\\),  \\(S\\to 10S\\),  \\(S\\to 11S\\),  \\(S\\to E\\),  \\(E\\to 0\\),  \\(E\\to 1\\)\n\n\n\n         This is a regular grammar.\n\n\n\n    (b)Terminal symbols: The null string,  0,  and 1. \n\n\n\nNonterminal symbols: <m>S</m>, <m>A</m>, <m>B</m>, <m>C</m> \n\n\n\nStarting symbol: <m>S</m>\n\n\n\nProduction rules: \\(S \\to  0A\\), \\(S \\to  1A\\), S $\\to $ $\\lambda $, \\(A \\to  0B\\), \\(A \\to  1B\\), \\(A \\to  \\lambda\\), \\(B \\to  0C\\), \\(B \\to  1C\\),\n\\(B \\to  A\\), \\(C \\to  0\\), \\(C \\to  1\\), \\(C \\to  \\lambda\\) \n\n\n\n This is a regular grammar.\n\n\n\n   </p></li>\n<li><p>See Exercise 3. This language is not regular.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> If <m>s</m> is in \\(A^*\\) and <m>L</m> is recursive, we can answer the question {``}Is s in \\(L^c\\)?{''}  by\n\n\n\nnegating the answer to {``}Is <m>s</m> in <m>L</m>?$\\texttt{\"}$</p></answer>\n\n\n*************\n9\n*************\n<answer><p> (a) List the elements of each set \\(x_i\\)  in a sequence \\(x_{i 1}\\), \\(x_{i 2}\\), \\(x_{i 3}\\), $\\ldots $ .   \n\n\\includegraphics{Sol_9-16_gr2.eps}\n\n\n\nThen draw arrows as shown above and list the elements of the union in order established by this pattern:  \\(x_{11}\\), \\(x_{21}\\), \\(x_{12}\\), \\(x_{13}\\),\n\\(x_{22}\\), \\(x_{31}\\), \\(x_{41}\\), \\(x_{32}\\), \\(x_{23}\\), \\(x_{14}\\), \\(x_{15}\\), $\\ldots $\n\n</p></li>\n<li><p>  Each of the sets \\(A^1\\) , \\(A^2\\) , \\(A^3\\) , $\\ldots $ are countable and \\(A^*\\) is the union of these sets; hence \\(A^*\\) is countable.\n\n\n\\subsubsection{Section 14.3}\n\n\n\n  \\(\\begin{array}{cccc}\n x &amp; s &amp; Z(x,s) &amp; t(x,s) \\\\\n \\text{Deposit} 25\\not{c} &amp; \\text{Locked} &amp; \\text{Nothing} &amp; \\text{Select} \\\\\n \\text{Deposit} 25\\not{c} &amp; \\text{Select} &amp; \\text{Return} 25\\not{c} &amp; \\text{Select} \\\\\n \\text{Press} S &amp; \\text{Locked} &amp; \\text{Nothing} &amp; \\text{Locked} \\\\\n \\text{Press} S &amp; \\text{Select} &amp; \\text{Dispense} S &amp; \\text{Locked} \\\\\n \\text{Press} P &amp; \\text{Locked} &amp; \\text{Nothing} &amp; \\text{Locked} \\\\\n \\text{Press} P &amp; \\text{Select} &amp; \\text{Dispense} P &amp; \\text{Locked} \\\\\n \\text{Press} B &amp; \\text{Locked} &amp; \\text{Nothing} &amp; \\text{Locked} \\\\\n \\text{Press} B &amp; \\text{Select} &amp; \\text{Dispense} B &amp; \\text{Locked} \\\\\n\\end{array}\\)\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  \\(\\{000,011, 101, 110, 111\\}\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) Input:10110, Output: 11011 \\(\\Rightarrow\\) 10110 is in position 27 \n\n\n\n         Input: 00100, Output: 00111 \\(\\Rightarrow\\) 00100 is in position 7 \n\n\n\n         Input:11111, Output: 10101 \\(\\Rightarrow\\) 11111 is in position 21\n\n</p></li>\n<li><p>  Let \\(x=x_1x_2\\ldots  x_n\\) and recall that for \\(n\\geq 1\\),  \\(G_{n+1}=\\left(\n\\begin{array}{c}\n 0G_n \\\\\n 1G_n{}^r \\\\\n\\end{array}\n\\right)\\), where \\(G_n{}^r\\) is the reverse of \\(G_n\\). To prove that the Gray Code Decoder always works, let \\(p(n)\\) be the proposition $\\texttt{\"}$Starting\nin Copy state,  <m>x</m>'s output is the position of <m>x</m> in \\(G_n\\);  and starting in Complement state, <m>x</m>'s output is the\nposition of <m>x</m> in \\(G_n{}^r\\).$\\texttt{\"}$ That p(1) is true is easy to verify for both possible values of <m>x</m>,  0 and 1.  Now\nassume that for some \\(n\\geq 1\\), \\(p(n)\\) is true and consider \\(x=x_1x_2\\ldots  x_nx_{n+1}\\). \n\n\n\nIf \\(x_1=0\\),\n\n\n\n    \\(\\text{            }x's \\text{output}=0 \\text{followed} \\text{by} \\left(x_2\\ldots  x_nx_{n+1}\\right)'s \\text{output} \\text{starting} \\text{in}\n\\text{Copy}\\text{$\\quad \\quad $ }=0 \\text{followed} \\text{by} \\left(x_2\\ldots  x_nx_{n+1}\\right)'s \\text{position} \\text{in} G_n\\text{$\\quad \\quad\n$ }= x's \\text{position} \\text{in} G_{n+1}\\) \n\n\n\nIf  \\(x_1=1\\),\n\n\n\n    \\(\\text{            }x's \\text{output}=1 \\text{followed} \\text{by} \\left(x_2\\ldots  x_nx_{n+1}\\right)'s \\text{output} \\text{starting} \\text{in}\n\\text{Complement}\\text{$\\quad \\quad $ }=1 \\text{followed} \\text{by} \\left(x_2\\ldots  x_nx_{n+1}\\right)'s \\text{position} \\text{in} G_n{}^r\\text{$\\quad\n\\quad $ }= x's \\text{position} \\text{in} G_{n+1}\\) \n\n\n\\subsubsection{Section 14.4}\n\n*************\n1.\n*************\n<answer><p>   \\(\\begin{array}{c|c}\n \\text{Input} \\text{String} &amp; \n\\begin{array}{cccccc}\n \\text{    }a\\text{       } &amp; b\\text{          } &amp; \\text{  }c &amp; \\text{\\textit{       }\\text{aa}\\text{         }} &amp; \\text{\\textit{ab}\\text{      \n }} &amp; \\text{\\textit{ac}} \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccc}\n (a,1) &amp; (a,2) &amp; (c,3) &amp; (a,1) &amp; (a,2) &amp; (c,3) \\\\\n (a,2) &amp; (a,1) &amp; (c,3) &amp; (a,2) &amp; (a,1) &amp; (c,3) \\\\\n (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\n      \\(\\begin{array}{c|c}\n \\text{Input} \\text{String} &amp; \\text{   }\n\\begin{array}{cccccc}\n \\text{\\textit{ba}} &amp; \\text{\\textit{  }\\text{  }\\text{     }\\text{bb}\\text{   }\\text{  }\\text{   }} &amp; \\text{\\textit{bc}\\text{    }\\text{  }\\text{\n  }} &amp; \\text{\\textit{ca}\\text{          }} &amp; \\text{\\textit{cb}\\text{    }} &amp; \\text{\\textit{cc}\\text{      }} \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccc}\n (a,2) &amp; (a,1) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) \\\\\n (a,1) &amp; (a,2) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) \\\\\n (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) &amp; (c,3) \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nWe can see that \\(T_aT_a= T_{\\text{\\textit{aa}}}=T_a\\),  \\(T_aT_b= T_{\\text{\\textit{ab}}}= T_b\\), etc. Therefore, we have the following monoid:\n\n\n\n          \\(\\begin{array}{c|c}\n   &amp; \n\\begin{array}{ccc}\n \\text{   }T_{a\\text } &amp; T_b &amp;  T_b \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n T_a \\\\\n T_b \\\\\n T_c \\\\\n\\end{array}\n &amp; \n\\begin{array}{ccc}\n T_a &amp; T_b &amp; T_c \\\\\n T_b &amp; T_a &amp; T_c \\\\\n T_c &amp; T_c &amp; T_c \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nNotice that \\(T_a\\) is the identity of this monoid.\n\n</p></li>\n<li><p>   \\(\\begin{array}{c|c}\n \\text{Input} \\text{String} &amp; \n\\begin{array}{cccccc}\n \\text{   }1 &amp; \\text{  }2  &amp;  11 &amp; 12 &amp; 21 &amp; 22 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n A \\\\\n B \\\\\n C \\\\\n D \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccc}\n C &amp; B &amp; A &amp; D &amp; D &amp; A \\\\\n D &amp; A &amp; B &amp; C &amp; C &amp; B\\text{} \\\\\n A\\text{} &amp; D\\text{} &amp; C\\text{} &amp; B &amp; B &amp; C \\\\\n B &amp; C &amp; D &amp; A &amp; A &amp; D \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\n        \\(\\begin{array}{c|c}\n \\text{Input} \\text{String} &amp; \n\\begin{array}{cccccccc}\n \\text{   }111 &amp; 112 &amp; 121 &amp; 122 &amp; 211\\text{\\textit{$ $}} &amp; 212 &amp; 221 &amp; 222 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n A \\\\\n B \\\\\n C \\\\\n D \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccccc}\n C\\text{     } &amp; B\\text{     } &amp; B\\text{     } &amp; C\\text{     } &amp; B\\text{     } &amp; C\\text{     } &amp; C\\text{    } &amp; B \\\\\n D\\text{    } &amp; A\\text{    } &amp; A\\text{     } &amp;  D\\text{    } &amp; A\\text{    } &amp; D\\text{     } &amp; D\\text{   } &amp; A \\\\\n B\\text{    } &amp; C\\text{    } &amp; C\\text{    } &amp; B\\text{   } &amp; C\\text{    } &amp; B\\text{    } &amp; B\\text{   } &amp; C \\\\\n B\\text{    } &amp; C\\text{    } &amp; C\\text{    } &amp; B\\text{   } &amp; C\\text{    } &amp; B\\text{    } &amp; B\\text{   } &amp; C \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nWe have the following monoid:\n\n\n\n          \\(\\begin{array}{c|c}\n   &amp; \n\\begin{array}{cccc}\n T_1 &amp;  T_2 &amp; \\text{  }T_{11} &amp;  T_{12} \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n T_1 \\\\\n T_2 \\\\\n T_{11} \\\\\n T_{12} \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccc}\n T_{11} &amp; T_{12} &amp; T_1 &amp; T_2 \\\\\n T_b &amp; T_{11} &amp; T_2 &amp; T_1 \\\\\n T_1 &amp; T_2 &amp; T_{11} &amp; T_{12} \\\\\n T_2 &amp; T_1 &amp; T_{12} &amp; T_{11} \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nNotice that \\(T_{11}\\) is the identity of this monoid.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> Yes, just consider the unit time delay machine of Figure 14.4.2. Its monoid is described by the table at the end of Section 14.4 where the \\(T_{\\lambda\n}\\) row and \\(T_{\\lambda }\\) column are omitted. Next consider the machine in Figure 14.5.3. The monoid of this machine is:\n\n\n\n     \\(\\begin{array}{c|ccccccc}\n   &amp; T_{\\lambda } &amp; T_0 &amp; T_1 &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n\\hline\n T_{\\lambda } &amp; T_{\\lambda } &amp; T_0 &amp; T_1 &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n\\hline\n T_0 &amp; T_0 &amp; T_{00} &amp; T_{01} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n T_1 &amp; T_1 &amp; T_{10} &amp; T_{11} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n T_{00} &amp; T_{00} &amp; T_{00} &amp; T_{01} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n T_{01} &amp; T_{01} &amp; T_{10} &amp; T_{11} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n T_{10} &amp; T_{10} &amp; T_{00} &amp; T_{01} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n T_{11} &amp; T_{11} &amp; T_{10} &amp; T_{11} &amp; T_{00} &amp; T_{01} &amp; T_{10} &amp; T_{11} \\\\\n\\end{array}\\)\n\n\n\nHence both of these machines have the same monoid, however, their transition diagrams are nonisomorphic since the first has two vertices and the\nsecond has seven.\n\n\n\\subsubsection{Section 14.5}\n\n*************\n1.\n*************\n<answer><p> </p></li>\n<li><p>\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n\n\n (b)\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n\n\\subsubsection{Supplementary Exercises$---$Chapter 14}\n\n*************\n1.\n*************\n<answer><p>   Let \\(f, g, h \\in  M\\), and \\(a \\in  B\\).\n\n\n\n\\(((f*g)*h)(a) = (f*g)(a) \\land  h(a)\\\\\n\\\\\n\\quad \\quad = (f(a)\\land g(a))\\land h(a)\\\\\n\\\\\n\\quad \\quad = f(a) \\land ( g(a) \\land  h(a))\\\\\n\\\\\n\\quad \\quad = f(a) \\land  (g * h)(a)\\\\\n\\\\\n\\quad \\quad = (f * (g * h))(a)\\)\n\n\n\nTherefore \\((f * g) * h =f * (g * h) \\Rightarrow  * \\text{is} \\text{associative}\\).\n\n\n\nThe identity for \\(*\\) is the function \\(u \\in  M\\) where \\(u (a) = 1\\) = the {``}one{''} of <m>B</m>. If \\(a \\in  B\\)\n\n\n\n\\((f*u)(a) =f(a)\\land u(a) = f(a)\\land 1 = f(a)\\)\n\n\n\nTherefore \\(f * u - f\\). Similarly\\(u * f =f\\).\n\n\n\nThere are \\(2^2= 4\\) functions in \\(M\\) for \\(B = B _2\\). These four functions are named in the text (see Figure 14.1.1). The table for \\(*\\) is\n\n\n\n          \\(\\begin{array}{c|c}\n   &amp; \n\\begin{array}{cccc}\n z &amp;  i &amp; \\text{  }t &amp;  u \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n z \\\\\n i \\\\\n t \\\\\n u \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccc}\n z &amp; z &amp; z &amp; z \\\\\n z &amp; i &amp; z &amp; i \\\\\n z &amp; z &amp; t &amp; t \\\\\n z &amp; u &amp; t &amp; u \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>   \\(\\{a,\\text{\\textit{$ $}}\\text{\\textit{bb}, \\text{bbb}, \\text{bbbb}}, . . .\\}\\)\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p>    S = start symbol. Nonterminals = \\(\\left\\{S, B_0 , B_1, B_2\\right\\}\\)\n\n\n\n\\(\\text{          }S\\to B_0\\text{        }B_0\\text{-$>$}a B_0\\text{    }B_0\\to b B_1\\quad \\quad B_1\\to a B_1\\text{       }B_1\\to b B_2\\text{\n     }B_1\\to b\\quad \\quad B_2 \\to a B_2\\text{      }B_2\\to a\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> \n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> </p></li>\n<li><p>\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> The possible output sequences are 100, 010, 001, and 111. Note: Output for \\(t = 3\\) is determined by the next state, \\(s(4)\\)). If \\(s(4) =\ns(3)\\), output at \\(t = 3\\) is 0, while if \\(s(4) \\neq  s(3)\\), output at \\(t=3\\) is 1.</p></answer>\n\n\n*************\n11\n*************\n<answer><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\\section{CHAPTER 15}\n\n\n\\subsection{Section 15.1}\n\n*************\n1.\n*************\n<answer><p>  The only other generator is \\(-1\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  If  \\(\\left| G\\right| =m\\)  , \\(m>2\\), and \\(G = \\langle a\\rangle\\), then <m>a</m>, \\(a^2,\\ldots\\), \\(a^{m-1}\\) , \\(a^m=e\\) are distinct\nelements of <m>G</m>. Furthermore, \\(a^{-1}= a^{m-1}\\neq a\\),  If \\(1\\leq k\\leq m\\),  \\(a^{-1}\\) generates \\(a^k\\):\n\n\n\n   \\(\\text{               }\\left(a^{-1}\\right)^{m-k}= \\left(a^{m-1}\\right)^{m-k}= a^{m^2-m-m k + k}\\quad \\quad =\\left(a^m\\right)^{m-k-1}*a^k=\ne*a^k=a^k\\)\n\n\n\nSimilarly, if <m>G</m> is infinite and \\(G = \\langle a\\rangle\\), then \\(a^{-1}\\) generates <m>G</m>.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) No. Assume that \\(q \\in \\mathbb{Q}\\) generates $\\mathbb{Q}$. Then \\(\\langle q\\rangle  = \\{n q : n \\in \\mathbb{Z}\\}\\). But this gives us at\nmost integer multiples of <m>q</m>, not every element in $\\mathbb{Q}$.\n\n</p></li>\n<li><p> No. Similar reasoning to part a.\n\n</p></li>\n<li><p> Yes. 6 is a generator of \\(6\\mathbb{Z}\\).\n\n</p></li>\n<li><p>  No.\n\n</p></li>\n<li><p> Yes, \\((1,1, 1)\\) is a generator of the group.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Theorem 15.1.4 implies that <m>a</m> generates \\(\\mathbb{Z}_n\\) if and only if the greatest common divisor of <m>n</m> and <m>a</m> is\n1 (i. e., <m>n</m> and <m>a</m> are relatively prime). Therefore the list of generators of \\(\\mathbb{Z}_n\\) are the integers in \\(\\mathbb{Z}_n\\)\nthat are relatively prime to <m>n</m>. The generators of \\(\\mathbb{Z}_{25}\\) are all of the nonzero elements except 5, 10, 15, and 20. The generators\nof \\(\\mathbb{Z}_{256}\\) are the odd integers in \\(\\mathbb{Z}_{256}\\)  since 256 is \\(2^8\\).  \\textit{ Mathematica} expression to generate these\nsets are\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{Select}[\\text{Range}[0,24],\\text{Function}[a,\\text{GCD}[25,a]==1]]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\{1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24\\}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{Select}[\\text{Range}[0,255],\\text{Function}[a,\\text{GCD}[256,a]==1]]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255\\}\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> (a)  \\(\\theta :\\mathbb{Z}_{77} \\to  \\mathbb{Z}_7 \\times  \\mathbb{Z}_{11}\\)\n\n\n\n  \\(\\begin{array}{ccc}\n 21 &amp; \\to  &amp; (0,10) \\\\\n 5 &amp; \\to  &amp; (5,5) \\\\\n 7 &amp; \\to  &amp; (0,7) \\\\\n 15 &amp; \\to  &amp; \\underline{(1,4)} \\\\\n \\text{sum}=48 &amp; \\leftarrow  &amp; (6,4)=\\text{sum} \\\\\n\\end{array}\\)\n\n\n\nThe final sum, 48, is obtained by using the facts that \\(\\theta ^{-1}(1,0) =22\\) and \\(\\theta ^{-1}(0,1)=56\\)\n\n\n\n\\(\\theta ^{-1}(6,4)=6 \\times _{77}\\theta ^{-1}(1,0)\\text{  }+ 4 \\times _{77}\\theta ^{-1}(0,1)\\\\\n\\\\\n\\quad \\quad =6\\times _{77}22 +_{77}4\\times _{77}56\\\\\n\\\\\n\\quad \\quad =55 +_{77}70\\\\\n\\\\\n\\quad \\quad =48\\)\n\n</p></li>\n<li><p>  Using the same isomorphism:\n\n\n\n\\(\\begin{array}{ccc}\n 25 &amp; \\to  &amp; (4,3) \\\\\n 26 &amp; \\to  &amp; (5,4) \\\\\n 40 &amp; \\to  &amp; (5,7) \\\\\n   &amp;   &amp; \\text{sum}=(0,3)\\text{            } \\\\\n\\end{array}\\)\n\n\n\n\\(\\text{              }\\theta ^{-1}(0,3)= 3\\times _{77}\\theta ^{-1}(0,1)\\quad \\quad = 3\\times _{77}56\\quad \\quad =14\\)\n\n\n\nThe actual sum is 91. Our result is incorrect, since 91 is not in \\(\\mathbb{Z}_{77}\\).  Notice that 91 and 14 differ by 77. Any error that we get\nusing this technique will be a multiple of 77.\n\n\n\\subsection{Section 15.2}\n\n*************\n1.\n*************\n<answer><p> Call the subsets <m>A</m> and <m>B</m> respectively. If we choose \\(0 \\in A\\) and \\(\\text{5 $\\in $ }\\text{\\textit{$B$}}\\) we get \\(0 +_{10}\n5 =5\\in  B\\). On the other hand, if we choose \\(3 \\in A\\) and \\(8 \\in  B\\), we get \\(3 +_{10}8 = 1 \\in  A\\). Therefore, the induced operation is\nnot well defined on \\(\\{A,B\\}\\).\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) The four distinct cosets in \\(G/H\\) are\n\n\n\n\\(\\text{                 }H = \\{(0, 0), (2, 0)\\}\\)\n\n\n\n  \\((1, 0) + H= \\{(1,0),(3,0)\\}\\)\n\n\n\n \\((0, 1) + H= \\{(0,1),(2,1)\\}\\), \n\n\n\n     and \\((1, 1) +H= \\{(1,1),(3,1)\\}\\) \n\n\n\nNone of these cosets generates \\(G/H\\); therefore \\(G/H\\) is not cyclic. Hence \\(G/H\\) must be isomorphic to \\(\\mathbb{Z}_2\\times \\mathbb{Z}_2\\)\n.\n\n</p></li>\n<li><p> The factor group is isomorphic to \\([\\mathbb{R}; +]\\). Each coset of $\\mathbb{R}$ is a line in the complex plane that is parallel to the x-axis:\n\\(\\tau :\\mathbb{C}/\\mathbb{R}\\to  \\mathbb{R}\\), where \\(T(\\{a + b i|a\\in \\mathbb{R}\\}) = b\\) is an isomorphism.\n\n</p></li>\n<li><p>    \\(\\langle 8\\rangle  = \\{0, 4, 8, 12, 16\\}\\text{  }\\)\\(\\Rightarrow\\)  \\(\\left\\left| \\left.\\mathbb{Z}_{20}\\right/\\langle 8\\rangle \\right\\right|\n=4\\) .\n\n\n\nThe four cosets are: \\(\\bar{0}\\), \\(\\bar{1}\\), \\(\\bar{2}\\), and \\(\\bar{3}\\). 1 generates all four cosets.  The factor group is isomorphic to \\(\\left[\\mathbb{Z}_4,\n+_4\\right]\\)  because \\(\\bar{1}\\) generates it.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> \\(\\text{                        }a \\in b H \\Leftrightarrow  a = b * h\\text{    }\\text{for} \\text{some}h \\in H\\text{$\\quad \\quad $        }\\Leftrightarrow\nb^{-1}*a = h\\text{  }\\text{for} \\text{some}h \\in H\\quad \\quad \\Leftrightarrow  b^{-1}*a \\in  H\\)\n\n\n\\subsection{Section 15.3}\n\n*************\n1.\n*************\n<answer><p> </p></li>\n<li><p>   \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 1 &amp; 4 &amp; 3 &amp; 2 \\\\\n\\end{array}\n\\right)\\)       </p></li>\n<li><p>     \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 4 &amp; 3 &amp; 1 &amp; 2 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>      \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 3 &amp; 4 &amp; 2 &amp; 1 \\\\\n\\end{array}\n\\right)\\)      (d)     \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 3 &amp; 4 &amp; 2 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>      \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 4 &amp; 2 &amp; 1 &amp; 3 \\\\\n\\end{array}\n\\right)\\)      (f)     \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 3 &amp; 1 &amp; 4 &amp; 2 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p>      \\(\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 2 &amp; 1 &amp; 4 &amp; 3 \\\\\n\\end{array}\n\\right)\\)    </p></answer>\n\n\n*************\n3\n*************\n<answer><p>  Yes and no, respectively\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> \\(D_4 = \\left\\{i, r, r^2 , r^3 , f_1 f_2,f_3, f_4\\right\\}\\)\n\n\n\nWhere <m>i</m> is the identity function, \\(r=\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 2 &amp; 3 &amp; 4 &amp; 1 \\\\\n\\end{array}\n\\right)\\), and \n\n\n\n\\(\\begin{array}{cc}\n f_1 =\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 4 &amp; 3 &amp; 2 &amp; 1 \\\\\n\\end{array}\n\\right) &amp; f_2 =\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 2 &amp; 1 &amp; 4 &amp; 3 \\\\\n\\end{array}\n\\right) \\\\\n f_3 =\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 3 &amp; 2 &amp; 1 &amp; 4 \\\\\n\\end{array}\n\\right) &amp; f_4 =\\left(\n\\begin{array}{cccc}\n 1 &amp; 2 &amp; 3 &amp; 4 \\\\\n 1 &amp; 4 &amp; 3 &amp; 2 \\\\\n\\end{array}\n\\right) \\\\\n\\end{array}\\)\n\n\n\nThe operation table for the group is\n\n\n\n\\(\\begin{array}{c|c}\n \\circ  &amp; \\text{   }\n\\begin{array}{cccccccc}\n i  &amp; r  &amp; r^2 &amp; r^3  &amp; f_1 &amp;  f_2\\text{  } &amp; f_3 &amp; f_4 \\\\\n\\end{array}\n \\\\\n\\hline\n \n\\begin{array}{c}\n i \\\\\n r \\\\\n r^2 \\\\\n r^3 \\\\\n f_1 \\\\\n f_2 \\\\\n f_3 \\\\\n f_4 \\\\\n\\end{array}\n &amp; \n\\begin{array}{cccccccc}\n i &amp; r &amp; r^2 &amp; r^3 &amp; f_1 &amp; f_2 &amp; f_3 &amp; f_4 \\\\\n r &amp; r^2 &amp; r^3 &amp; i &amp; f_4 &amp; f_3 &amp; f_1 &amp; f_2 \\\\\n r^2 &amp; r^3 &amp; i &amp; r &amp; f_2 &amp; f_1 &amp; f_4 &amp; f_3 \\\\\n r^3 &amp; i &amp; r &amp; r^2 &amp; f_3 &amp; f_4 &amp; f_2 &amp; f_1 \\\\\n f_1 &amp; f_3 &amp; f_2 &amp; f_4 &amp; i &amp; r^2 &amp; \\square  &amp; r^3 \\\\\n f_2 &amp; f_4 &amp; f_1 &amp; f_3 &amp; r^2 &amp; i &amp; r^3 &amp; r \\\\\n f_3 &amp; f_2 &amp; f_4 &amp; f_1 &amp; r^3 &amp; r &amp; i &amp; r^2 \\\\\n f_4 &amp; f_1 &amp; f_3 &amp; f_2 &amp; r &amp; r^3 &amp; r^2 &amp; i \\\\\n\\end{array}\n \\\\\n\\end{array}\\)\n\n\n\nA lattice diagram of its subgroups is\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n\n\nAll proper subgroups are cyclic except \\(\\left\\{i,r^2,f_1,f_2\\right\\}\\)\\(\\text{}\\text{}\\)and \\(\\left\\{i,r^2,f_3,f_4\\right\\}\\).  Each 2-element\nsubgroup is isomorphic to \\(\\mathbb{Z}_2\\) ; \\(\\left\\{i,r,r^2,r^3\\right\\}\\) is isomorphic to \\(\\mathbb{Z}_4\\) ; and \\(\\left\\{i,r^2,f_1,f_2\\right\\}\\)\\(\\text{}\\text{}\\)and\n\\(\\left\\{i,r^2,f_3,f_4\\right\\}\\) are isomorphic to \\(\\mathbb{Z}_2\\times \\mathbb{Z}_2\\).\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p>  One solution is to cite Exercise 3 at the end of Section 11.3. It can be directly applied to this problem. An induction proof of the problem\nat hand would be almost identical to the proof of the more general statement.\n\n\n\n  \\(\\left(t_1t_2\\cdots  t_r\\right){}^{-1}= t_r{}^{-1}\\cdots  t_2{}^{-1}t_1{}^{-1}\\text{       }\\text{by} \\text{Exercies} 3 \\text{of} \\text{Section}\n11.3\\\\\n\\\\\n\\quad \\quad = t_r\\cdots  t_2t_1\\text{               }\\text{since} \\text{each} \\text{transposition} \\text{inverts} \\text{itself}.\\text{    }\\blacksquare\n\\text{  }\\)\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> Part I: That \\(\\left\\left| S_k\\right\\right|  = k!\\) follows from Exercise 3 of Section 7.3.\n\n\n\nPart II: Let  <m>f</m>  be the function defined on \\(\\{1,2,\\text{...}, n\\}\\) by \\(f(1)=2\\), \\(f(2)=3\\),  \\(f(3)=1\\), and \\(f(j) =j\\)  for\n\\(4\\leq j\\leq n\\); and let <m>g</m> be defined by \\(g(1) = 1\\), \\(g(2) = 3\\), \\(g(3) = 2\\), and \\(g(j) =j\\)  for \\(4\\leq j\\leq n\\).  Note\nthat <m>f</m> and <m>g</m> are elements of \\(S_n\\). Next, \\((f\\circ g)(1) = f(g(1)) = f(1) = 2\\), while \\((g \\circ f)(1) = g(f(1)) = g(2) =\n3\\), hence  \\(f\\circ g\\neq g\\circ f\\) and \\(S_n\\) is non-abelian for any \\(n \\geq  3\\).\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p> (a) Both groups are non-abelian and of order 6; so they must be isomorphic, since only one such group exists up to isomorphism. The function\n\\(\\theta :S_3\\to R_3\\) defined by\n\n\n\n\\(\\begin{array}{cc}\n \\theta (i)=I &amp; \\theta \\left(f_1\\right)=F_1 \\\\\n \\theta \\left(r_1\\right)=R_1 &amp; \\theta \\left(f_2\\right)=F_2 \\\\\n \\theta \\left(r_2\\right)=R_2 &amp; \\theta \\left(f_3\\right)=F_3 \\\\\n\\end{array}\\)\n\n\n\nis an isomorphism,\n\n</p></li>\n<li><p> Recall that since every function is a relation, it is natural to translate functions to Boolean matrices. Suppose that \\(f\\in S_n\\). We will\ndefine its image, \\(\\theta (f)\\), by \n\n\n\n\\(\\theta (f)_{\\text{\\textit{kj}}}=1\\text{   }\\Leftrightarrow \\text{     }f(j)=k\\)\n\n\n\nThat $\\theta $ is a bijection follows from the existence of \\(\\theta ^{-1}\\).   If <m>A</m> is a rook matrix, \n\n\n\n\\(\\text{  }\\theta ^{-1}(A)(j)=k\\text{  }\\Leftrightarrow \\text{   }\\text{The} 1 \\text{in} \\text{column} j \\text{of} A \\text{appears} \\text{in}\n\\text{row} k \\quad \\quad \\Leftrightarrow \\text{  }\\text{\\textit{$A_{\\text{kj}}$}}=1\\) \n\n\n\nFor \\(f,g\\in  S_n\\), \n\n\n\n   \\(\\theta (f\\circ g)_{k j}= 1\\text{  }\\Leftrightarrow \\text{   }(f \\circ g)(j)=k\\\\\n\\\\\n\\quad \\quad \\Leftrightarrow \\text{  }\\exists  l\\text{  }\\text{such} \\text{that}\\text{  }g(j)=l\\text{  }\\text{and} f(l)=k\\\\\n\\\\\n\\quad \\quad \\Leftrightarrow \\text{  }\\exists  l\\text{  }\\text{such} \\text{that}\\text{  }\\theta (g)_{\\text{\\textit{lj}}}=1\\text{   }\\text{and}\\text{\n }\\theta (f)_{k l}=1\\\\\n\\\\\n\\quad \\quad \\Leftrightarrow \\text{  }(\\theta (f)\\theta (g))_{k j}=1\\)\n\n\n\nTherefore,  $\\theta $ is an isomorphism. \\(\\blacksquare\\)\n\n\n\\subsection{Section 15.4}\n\n*************\n1.\n*************\n<answer><p> (a)  Yes, the kernel is\\(\\{1, -1\\}\\)\n\n</p></li>\n<li><p> No, since \\(\\theta _2\\left(2 +_54\\right)= \\theta _2(1)=1\\), but  \\(\\theta _2(2)+_2\\theta _2(4)=0+_20 =0\\)\n\n</p></li>\n<li><p> Yes, the kernel is \\(\\{(a, -a)| a \\in \\mathbb{R}\\}\\)\n\n</p></li>\n<li><p>  No\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p>  \\(\\langle r\\rangle =\\left\\{i,r,r^2,r^3\\right\\}\\) is a normal subgroup of \\(D_4\\). To see you could use the table given in the solution of Exercise\n5 of Section 15.3 and verify that  \\(a^{-1}h a \\in \\langle r\\rangle\\) for all \\(a\\in D_4\\) and \\(h\\in \\langle r\\rangle\\).   A more efficient\napproach is to prove the general theorem that if <m>H</m> is a subgroup <m>G</m> with exactly two distinct left cosets, than <m>H</m> is\nnormal.  \n\n\n\n\\(\\left\\langle f_1\\right\\rangle\\) is not a normal subgroup of \\(D_4\\).  \\(\\left\\langle f_1\\right\\rangle =\\left\\{i,f_1\\right\\}\\) and if we choose\n\\(a = r\\) and \\(h=f_1\\) then \\(a^{-1}h a= r^3f_1r=f_2\\notin \\left\\langle f_1\\right\\rangle\\)</p></answer>\n\n\n*************\n5\n*************\n<answer><p>  \\((\\beta \\circ  \\alpha )\\left(a_1,a_2,a_3\\right) = 0\\)  and so \\(\\beta \\circ \\alpha\\)  is the trivial homomorphism, but a homomorphism\nnevertheless.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> Let \\(x, y \\in G\\).\n\n\n\n\\(\\text{               }q(x * y) = (x * y)^2\\quad \\quad = x*y *x*y\\quad \\quad =x * x*y *y\\text{   }\\text{since} G \\text{is} \\text{abelian}\\quad\n\\quad =x^2*y^2\\quad \\quad = q(x)*q(y)\\)\n\n\n\nHence, <m>q</m> is a homomorphism.\n\n\n\nIn order for \\textit{ q }to be an isomorphism, it must be the case that no element other than the identity is its own inverse.\n\n\n\n              \\(\\text{        }x \\in \\text{Ker} (q) \\Leftrightarrow  q (x) = e \\quad \\quad \\Leftrightarrow  x * x =e \\quad \\quad \\Leftrightarrow\n\\text{  }x^{-1}= x\\)\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> Proof: Recall: The inverse image of \\(H'\\) under $\\theta $ is\n\n\n\n\\(\\theta ^{-1}(H')=\\{g\\in G | \\theta (g)\\in H'\\}\\)\n\n\n\nClosure:   Let \\(g_1g_2\\in \\theta ^{-1}(H')\\), then \\(\\theta \\left(g_1\\right),\\theta \\left(g_2\\right)\\in H'\\).  Since \\(H'\\) is a subgroup\n\n\n\nof \\(G'\\), \n\n\n\n\\(\\theta \\left(g_1\\right)\\diamond \\theta \\left(g_2\\right)=\\theta \\left(g_1*g_2\\right) \\Rightarrow \\text{  }g_1*g_2\\in \\theta ^{-1}(H')\\)\n\n\n\n\n\n\n\nIdentity: By Theorem 15.4.2(a), \\(e \\in \\theta ^{-1}(H')\\).\n\n\n\nInverse: Let \\(a\\in \\theta ^{-1}(H')\\) . Then \\(\\theta (a)\\in H'\\) and by Theorem 15.4.2(b), \\(\\theta (a)^{-1}= \\theta \\left(a^{-1}\\right)\\in H'\\)\nand so \\(a^{-1}\\in \\theta ^{-1}(H')\\).\n\n\n\\subsection{Section 15.5}\n\n*************\n1.\n*************\n<answer><p> (a) Error detected, since an odd number of Is was received; ask for retransmission.\n\n</p></li>\n<li><p> No error detected; accept this block.\n\n</p></li>\n<li><p> No error detected; accept this block.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) Syndrome = \\((1, 0, 1)\\). Corrected message = \\((1, 1, 0)\\).\n\n</p></li>\n<li><p> Syndrome =\\((1, 1,0)\\). Corrected message =\\((0, 0, 1)\\).\n\n</p></li>\n<li><p> Syndrome \\((0,0,0)\\). \\(\\text{Corrected} \\text{message} =\\text{received} \\text{message}\\\\\n\\\\\n\\text{$\\quad \\quad $        }=\\text{   }(0, 1, 1)\\).\n\n</p></li>\n<li><p> Syndrome = \\((1, 1,0)\\). Corrected message =\\((1, 0, 0)\\).\n\n</p></li>\n<li><p> Syndrome = \\((1, 1, 1)\\). This syndrome occurs only if two bits have been switched. No reliable correction is possible.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> Let <m>G</m> be the \\(9\\times 10\\) matrix obtained by augmenting the \\(9\\times 9\\) identity matrix with a column of ones. The function \\(e\n:\\mathbb{Z}_2{}^9\\to \\mathbb{Z}_2{}^{10}\\)  defined by \\(e(a) = a G\\) will allow us to detect single errors, since \\(e(a)\\) will always have an\neven number of ones.\n\n\n\\subsection{Supplementary Exercises$---$Chapter 15}\n\n*************\n1.\n*************\n<answer><p> Theorem 15.1.3 guarantees that all subgroups of any cyclic group can be determined by finding all cyclic subgroups. We can find all cyclic subgroups\nof noncyclic groups but there may be other subgroups.</p></answer>\n\n\n*************\n3\n*************\n<answer><p> First, write 120 as a product of powers of distinct primes: \\(120 = 2^3\\cdot 3\\cdot 5\\). The Chinese Remainder Theorem states that  \\(\\theta\n:\\mathbb{Z}_{120}\\to \\mathbb{Z}_8\\times \\mathbb{Z}_3\\times \\mathbb{Z}_5\\) defined by \\(\\theta (k)=((k \\bmod 8), (k \\bmod 3), (k \\bmod 5))\\)  is\nan isomorphism.  In particular, \\(\\theta (74)=(2,2,4)\\)  and \\(\\theta (85)=(5,1,0)\\).   Therefore,\n\n\n\n\\(\\theta \\left(74+_{120}85\\right)=\\theta (74)+\\theta (85)\\\\\n\\\\\n\\quad \\quad = (2,2,4)+(5,1,0)\\\\\n\\\\\n\\quad \\quad =(7,0,4)\\)\n\n\n\nSince \\(\\theta (105) = (1,0, 0)\\), and \\(\\theta (96) = (0, 0, 1)\\), we can compute\n\n\n\n $\\quad \\quad \\quad $\\(\\text{      }\\theta ^{-1}(7, 0, 4) = 7 \\times _{120} 105\\text{  }+_{120} 4 \\times _{120} 96 \\quad \\quad = 39\\).\n\n\n\n 5.  \\(H= 0 + H = \\{0, 4, 8\\} =4 +H = 8+H\\)\n\n\n\n\\(1+H = \\{1,5, 9\\} = 5 + H = 9 + H\\)\n\n\n\n\\(2+ H = \\{2, 6, 10\\} = 6 + H = 10 + H\\)\n\n\n\n\\(3+ H = \\{3, 7, 11\\} = 7 + H = 11 + H\\)\n\n\n\nThe operation table for this factor group is the same as that of \\(\\left[\\mathbb{Z}_4,+_4\\right]\\) with <m>k</m> replaced with \\(k+ H\\).\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a) \\(\\left\\left| \\mathbb{Z}_8\\right\\right|  = 8\\) and \\(\\left| \\langle 2\\rangle \\right| = 4\\), therefore there are 2 distinct left cosets, and\nthey are:\n\n\n\n\\(0+ \\langle 2\\rangle  = \\{0, 2, 4, 6\\} = 2 + \\langle 2\\rangle  = 4 + \\langle 2\\rangle  = 6 + \\langle 2\\rangle\\)\n\n\n\n\\(1+ \\langle 2\\rangle  = \\{1, 3, 5, 7\\} = 3 + \\langle 2\\rangle  = 5 + \\langle 2\\rangle  = 7 + \\langle 2\\rangle\\)\n\n</p></li>\n<li><p>  \\(\\left\\left| \\mathbb{Z}_{12}\\right\\right|  = 12\\) and \\(\\left| \\langle 2\\rangle \\right|  = 6\\), therefore there are 2 distinct left cosets\nand they are:\n\n\n\n\\(0+ \\langle 2\\rangle  = \\{(), 2, 4, 6, 8, 10\\} = 2 + \\langle 2\\rangle  = 4 + \\langle 2\\rangle  - 6 + \\langle 2\\rangle = 8 + \\langle 2\\rangle\n = 10 + \\langle 2\\rangle\\)\n\n\n\n      and \\(1+ \\langle 2\\rangle  = \\{1, 3, 5, 7, 9, 11\\} = 3 + \\langle 2\\rangle  = 5 + \\langle 2\\rangle  = 7 + \\langle 2\\rangle = 9 + \\langle\n2\\rangle  = 11 + \\langle 2\\rangle\\)\n\n</p></li>\n<li><p>  Since both groups are of order 2 and there is only one group of order 2 up to isomorphism, they are isomorphic. A simpler group is \\(\\mathbb{Z}_2\\).\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p>  Assume  <m>f</m> is even,  \\(f=t_1\\circ t_2\\circ \\cdots \\circ t_{2r}\\)  for some \\(r\\), where each \\(t_i\\) is a transposition. Hence\n\n\n\n\\(f^{-1}=\\left(t_1\\circ t_2\\circ \\cdots \\circ t_{2r}\\right){}^{-1} = t_{2r}\\circ \\cdots \\circ t_2\\circ t_1\\) by Exercise 11 of Section 15.3.\n\n\n\n\nSince the alternative, that <m>f</m> is odd, leads to \\(f^{-1}\\) being odd,  \\textit{ f }is even if and only if \\(f^{-1}\\) is even.\\\\\n\\\\\n11. (a) \\textit{ This following is the {``}standard definition{''} of a Boolean algebra homomorphism}.  \n\n\n\n \\(f:B_1\\to B_2\\) is a Boolean algebra homomorphism if and only if for all \\(a, b, \\in B_1\\).\n\n\n\n(1)  \\(f(a\\land b)=f(a)\\land f(b)\\)\n\n\n\n(2)  \\(f(a\\lor b)=f(a)\\lor f(b)\\) \n\n\n\n(3)   \\(f\\left(\\bar{a}\\right) =\\overline{ f(a)}\\)\n\n</p></li>\n<li><p> (i) \\(f(0) = f\\left(a \\land  \\bar{a}\\right) \\\\\n\\\\\n\\quad = f(a) \\land f\\left(\\overset{\\text{}_{\\_}}{a}\\right) \\\\\n\\\\\n\\quad = f(a) \\land  \\overline{f(a)} \\\\\n\\\\\n\\quad = 0\\)\n\n\n\nand\n\n\n\n \\(f(1) = f\\left(a \\lor  \\bar{a}\\right) \\\\\n\\\\\n\\quad = f(a) \\lor f\\left(\\overset{\\text{}_{\\_}}{a}\\right) \\\\\n\\\\\n\\quad = f(a) \\lor  \\overline{f(a)} \\\\\n\\\\\n\\quad = 1\\)\n\n\n\n      Note : The 0 and 1 of \\(B_1\\) may be different than those of \\(B_2\\). \n\n\n\n(ii)  \\(a\\leq b\\Rightarrow  a=a\\land b\\text{    }\\text{by} \\text{Supplementary} \\text{Exercise} 4 \\text{of} \\text{Chapter} 13\\\\\n\\\\\n\\quad \\Rightarrow  f(a)=f(a\\land b)=f(a)\\land f(b)\\\\\n\\\\\n\\quad \\Rightarrow \\text{  }f(a)\\leq f(b)\\text{   }\\text{by} \\text{the} \\text{same} \\text{exercise} \\text{cited} \\text{above}.\\)\n\n\n\n(iii) See the solution to Exercise 15 of the Supplementary section of Chapter 13 for the definition of Boolean subalgebra. Part (i) of this exercise\nshows that \\(f\\left(B_1\\right)\\) contains the 0 and 1 of \\(B_2\\). The definition in part a shows that\\(f(a) \\in f\\left(B_1\\right)\\) has a complement,\nnamely \\(f\\left(\\bar{a}\\right)\\in f\\left(B_1\\right)\\) , and also that \\(f\\left(B_1\\right)\\) must be closed with respect to both $\\land $ and $\\lor\n$.  For example, if \\(a, b \\in B_1\\), then \\(a \\land  b \\in B_1\\), and since \\(f(a) \\land f(b) = f(a \\land  b)\\),   \\(f(a) \\land f(h) \\in f\\left(B_1\\right)\\).\n\n\n\n\n13 (a)    \\(\\left(\n\\begin{array}{ccccccc}\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 0 \\\\\n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 1 \\\\\n 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 1 \\\\\n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\)\n\n</p></li>\n<li><p> \\(e(1111) = 1111111\\)   and \\(e(1001) = 1001001\\)\n\n</p></li>\n<li><p> (i)  Syndrome = 101 =$>$ Error in second bit, since 101 is the second row of P. \n\n\n\nCorrected message = 0000. \n\n\n\n      (ii) Syndrome = 000 =$>$ No error in transmission. Correct message is 1010.\n\n\n\n      (iii) Syndrome = 001 =$>$ Error in seventh bit, since 001 is the seventh row of P.\n\n\n\nCorrected message = 1011. (Since the error was in a parity bit, the actual message is not corrected.)\n\n</p></li>\n<li><p> The most direct way of proving that all single errors can be corrected is to compute the syndromes of each of the seven possible one-bit errors.\nSince each of them produces a distinct syndrome (the rows of <m>P</m>), single errors can always be corrected.\n\n\n\\subsection{CHAPTER 16}\n\n\n\\subsubsection{Section 16.1}\n\n*************\n1.\n*************\n<answer><p> All but rings c and e are commutative. All of the rings have a unity element. The number 1 is the unity for all of the rings except c and e. The\nunity for \\(M_{2\\times 2}(\\mathbb{R})\\) is the two by two identity matrix; the unity for \\(M_{n\\times n}(\\mathbb{R})\\) is the <m>n</m> by \\textit{\nn }identity matrix. The units are as follows:\n\n\n\n(a)  \\(\\{1, -1\\}\\)$\\quad \\quad \\quad \\quad $\n\n\n\n(b)   \\(\\mathbb{C}^*\\) \n\n\n\n(c)  \\(\\{A | \\left| A\\right| =\\pm 1\\}\\)\n\n\n\n(d)   \\(\\mathbb{Q}^*\\) \n\n\n\n(e)   \\(\\left\\{A \\left| A_{11}A_{22}-A_{12}A_{21}\\neq 0\\right.\\right\\}\\)\n\n\n\n(f)   \\(\\{1\\}\\)</p></answer>\n\n\n*************\n3\n*************\n<answer><p> Hints: (a) Consider commutativity \n\n\n\n   (b) Solve \\(x ^2=3x\\) in both rings.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) We already know that \\(3\\mathbb{Z}\\) is a subgroup of the group \\(\\mathbb{Z}\\); so part 1 of Theorem 16.1.1 is satisfied. We need only show\nthat part 2 of the theorem holds: Let \\(3m, 3n \\in  3\\mathbb{Z}\\).\n\n\n\n\\((3m)(3n) = 3(3m n) \\in  3\\mathbb{Z}\\), since \\(3 m n \\in \\mathbb{Z}\\).  \\(\\blacksquare\\)\n\n</p></li>\n<li><p> The proper subrings are \\(\\{0, 2, 4, 6\\}\\) and \\(\\{0, 4\\}\\); while \\(\\{0\\}\\) and \\(\\mathbb{Z}_8\\) are improper subrings.\n\n</p></li>\n<li><p>  The proper subrings are \\(\\{00, 01\\}\\), \\(\\{00, 10\\}\\), and \\(\\{00,11\\}\\): while $\\{$00$\\}$ and \\(\\mathbb{Z}_2\\times \\mathbb{Z}_2\\) are improper\nsubrings.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a) The left-hand side of the equation factors into the product \\((x-2)(x-3)\\). Since $\\mathbb{Z}$ is an integral domain, \\(x = 2\\) and \\(x =\n3\\) are the only possible solutions.\n\n</p></li>\n<li><p> Over \\(\\mathbb{Z}_{12}\\), 2, 3, 6, and 11 are solutions. Although the equation factors into \\((x-2)(x-3)\\), this product can be zero without\nmaking <m>x</m> either 2 or 3. For example. If <m>x</m> = 6 we get  \\((6-2)\\times _{12}(6-3)=4 \\times _{12}3 = 0\\).  Notice that  4 and\n3 are divisors of zero.\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> Let \\(R_1\\), \\(R_2\\), and \\(R_3\\)  be any rings, then\n\n</p></li>\n<li><p>  \\(R_1\\) is isomorphic to \\(R_1\\) and so {``}is isomorphic to{''} is a reflexive relation on rings,\n\n</p></li>\n<li><p>  \\(R_1\\) is isomorphic to \\(R_2\\text{  }\\Rightarrow\\) \\(R_2\\)is isomorphic to \\(R_1\\), and so {``}is isomorphic to{''} is a symmetric relation\non rings,\n\n</p></li>\n<li><p>  \\(R_1\\) is isomorphic to \\(R_2\\), and \\(R_2\\) is isomorphic to \\(R_3\\) implies that \\(R_1\\) is isomorphic to \\(R_3\\), and so {``}is isomorphic\nto{''} is a transitive relation on rings.\n\n\n\nWe haven{'}t proven these properties here, just stated them.  The combination of these observations implies that {``}is isomorphic to{''} is an\nequivalence relation on rings,\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p> (a) Commutativity is clear from examination of a multiplication table for \\(\\mathbb{Z}_2\\times  \\mathbb{Z}_3\\). More generally, we could prove\na theorem that the direct product of two or more commutative rings is commutative. \\((1, 1)\\) is the unity of \\(\\mathbb{Z}_2\\times  \\mathbb{Z}_3\\).\n\n</p></li>\n<li><p> \\(\\{(m, n) | m = 0\\text{  }\\text{or}\\text{  }n = 0, (m, n) \\neq  (0, 0)\\}\\)\n\n</p></li>\n<li><p>  Another example is \\(\\mathbb{Z} \\times  \\mathbb{Z}\\).  No, since by definition an integral domain D must contain the additive identity {\n}so we always have \\((m, 0) \\cdot  (0, n) = (0, 0)\\) in \\(D \\times  D\\).\n\n</p></answer>\n\n\n*************\n13\n*************\n<answer><p> (a)    \\(\\text{                }(a + b)(c + d) = (a + b)c + (a + b)d \\quad \\quad \\quad = a c + b c + a d + b d\\)\n\n\n\n      (b) \\(\\text{               }(a + b)(a + b )= a a + b a + a b + b b\\text{                  }\\text{by} \\text{part} a\\quad \\quad \\quad =\na a + a b + a b + b b\\text{    }\\text{since} R \\text{is} \\text{commutative}\\quad \\quad \\quad =a^2 + 2a b + b^2\\)\n\n</p></answer>\n\n\n*************\n15\n*************\n<answer><p> Hint: The set of units of a ring is a group under multiplication. Apply a theorem from a group theory.\n\n</p></answer>\n\n\n*************\n17\n*************\n<answer><p>  Proof of Corollary to Theorem 6.1.4: Since p is a prime, all nonzero elements of \\(\\mathbb{Z}_p\\) are relatively prime to <m>p</m>.  By\nTheorem 16.1.4 we are done.\n\n\n\\subsubsection{Section 16.2}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> No, since \\(2^{-1}= 2\\) in \\(\\mathbb{Z}_3\\), but \\(a^{-1}\\neq a\\) and \\(b^{-1}\\neq b\\) in <m>F</m>.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a)  0  (over \\(\\mathbb{Z}_2\\)),  1 (over \\(\\mathbb{Z}_3\\)),  3 (over \\(\\mathbb{Z}_5\\) )\n\n</p></li>\n<li><p> 2 (over \\(\\mathbb{Z}_3\\) ),  3 (over \\(\\mathbb{Z}_5\\))\n\n</p></li>\n<li><p> 2\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a)  0 and 1 </p></li>\n<li><p> 1 </p></li>\n<li><p> 1 </p></li>\n<li><p> none\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> (c) The roots of \\(x ^2 - 2 = 0\\) are \\(\\sqrt{2}\\) and \\(-\\sqrt{2}\\). Both numbers can be expressed in the form \\(a +b\\sqrt{2}\\) where \\(a, b\n\\in  \\mathbb{Q}\\):  \\(\\sqrt{2} = 0 + 1 \\cdot \\sqrt{1}\\) and \\(-\\sqrt{2}= 0 + -1 \\cdot \\sqrt{2}\\).\n\n</p></li>\n<li><p> No, since \\(\\unicode{f39e}\\pm \\sqrt{3}\\) cannot be expressed in the form \\(a + b \\sqrt{2}\\),\\(a, b \\in  \\mathbb{Q}\\).  If there exist rational\nnumbers <m>a</m> and <m>b</m> such that \\(\\sqrt{3}= a + b \\sqrt{2}\\), then clearly \\(b\\neq 0\\) since \\(\\sqrt{3}\\) is irrational and \\(a\\neq\n0\\) for that would imply that \\(\\sqrt{3/2}\\) is rational, which is false.   If we square both sides, of the equation we will get a rational expression\nfor \\(\\sqrt{2}\\) which is also false.\n\n\n\\subsubsection{Section 16.3}\n\n*************\n1.\n*************\n<answer><p> (i) \\(f(x) + g(x) = 2 + 2x + x^2\\) ,   \\(f(x)g(x) =1 +2x +2x^2+x^3\\)\n\n\n\n(ii) \\(f(x)+g(x)=x^2\\),      \\(f(x)g(x) =1+x^3\\)\n\n\n\n(iii) \\(1 + 3x + 4x ^2 + 3x^3 + x^4\\)\n\n\n\n(iv) \\(1 + x + x^3 + x^4\\)\n\n</p></li>\n<li><p>  \\(x^2+ x^3\\)\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) If \\(a, b \\in  \\mathbb{R}\\), \\(a - b\\) and \\(a b\\) are in $\\mathbb{R}$ since $\\mathbb{R}$ is a ring in its own right. Therefore, $\\mathbb{R}$\nis a subring of \\(\\mathbb{R}[x]\\).  The proofs of parts b and c are similar.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) Reducible, \\((x+1)\\left(x^2+ x+1\\right)\\)\n\n</p></li>\n<li><p>Reducible,  \\(x\\left(x^2+x+1\\right)\\)\n\n</p></li>\n<li><p>Irreducible. If you could factor this polynomial, one factor would be either <m>x</m> or \\(x + 1\\), which would give you a root of 0 or 1,\nrespectively. By substitution of 0 and 1 into this polynomial, it clearly has no roots.\n\n</p></li>\n<li><p>Reducible, \\((x+1)^{4\\text{  }}\\)\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> We illustrate this property of polynomials by showing that it is not true for a nonprime polynomial in \\(\\mathbb{Z}_2[x]\\). Suppose that \\(p(x)\n= x^2+ 1\\), which can be reduced to \\((x+1)^2\\) , \\(a(x) = x^2 + x\\), and \\(b(x) = x^3 + x^2\\). Since \\(a(x)b(x) =x^5+x^3= x^3\\left(x^2+1\\right)\\),\n\\(p(x)|a(x)b(x)\\). However, \\(p(x)\\) is not a factor of either \\(a(x)\\) or \\(b(x)\\).\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> The only possible proper factors of \\(x^2- 3\\) are \\(\\left(x - \\sqrt{3}\\right)\\) and \\(\\left(x+\\sqrt{3}\\right)\\), which are not in \\(\\mathbb{Q}[x]\\)\nbut are in $\\mathbb{R}$[x].</p></answer>\n\n\n*************\n11\n*************\n<answer><p> For \\(n \\geq  0\\), let \\(S(n)\\) be the proposition: For all \\(g(x)\\neq 0\\) and \\(f(x)\\) with \\(\\deg  f(x) = n\\), there exist unique polynomials\n\\(q(x)\\) and \\(r(x)\\) such that \\(f(x)=g(x)q(x)+r(x)\\), and either \\(r(x)=0\\) or  \\(\\deg  r(x) < \\deg  g(x)\\).\n\n\n\nBasis: \\(S(0)\\) is true, for if \\(f(x)\\)  has degree 0, it is a nonzero constant, \\(f(x)=c\\neq 0,\\) and so either \\(f(x) =g(x)\\cdot 0 + c\\)  if\n\\(g(x)\\) is not a constant, or \\(f(x) = g(x)g(x)^{-1}+0\\) if \\(g(x)\\) is also a constant.\n\n\n\nInduction: Assume that for some \\(n\\geq 0\\), \\(S(k)\\) is true for all \\(k \\leq  n\\), If \\(f(x)\\) has degree \\(n+1\\), then there are two cases to\nconsider. If \\(\\deg  g(x) > n + 1\\), \\(f(x) = g(x)\\cdot 0 + f(x)\\), and we are done. Otherwise, if \\(\\deg  g(x) =m \\leq  n + 1\\), we perform long\ndivision as follows, where LDT{'}s = various terms of lower degree than \\(n+1\\).\n\n\n\n $\\quad \\quad $\\(\\begin{array}{cc}\n   &amp; f_{n+1}\\cdot g_m{}^{-1}x^{n+1-m}\\text{                  } \\\\\n g_mx^m+ \\text{LDT}'s &amp; \\overline{\\left) f_{n+1}x^{n+1}\\right.+ \\text{LDT}'s\\text{                    }}\\underline{\\text{   }f_{n+1}x^{n+1}+ \\text{LDT}'s}\\text{\n                             }h(x) \\\\\n\\end{array}\\)\n\n\n\nTherefore,\n\n\n\n  \\(h(x) = f(x)-\\left(f_{n+1}\\cdot g_m{}^{-1}x^{n+1-m}\\right) g(x)\\text{  }\\Rightarrow \\text{  }f(x) = \\left(f_{n+1}\\cdot g_m{}^{-1}x^{n+1-m}\\right)\ng(x)+h(x)\\text{  }\\)\n\n\n\nSince \\(\\deg  h (x)\\) is less than \\(n+1\\), we can apply the induction hypothesis:\n\n\n\n\\(h(x) = g(x)q(x) + r(x)\\) with  \\(\\deg  r(x) < \\deg  g(x)\\).\n\n\n\nTherefore,\n\n\n\n\\(f(x) = g(x)\\left(f_{n+1}\\cdot g_m{}^{-1}x^{n+1-m}+ q(x)\\right) + r(x)\\)  with  \\(\\deg  r(x) < \\deg  g(x)\\).\n\n\n\nThis establishes the existence of a quotient and remainder. The uniqueness of \\(q(x)\\) and \\(r(x)\\) as stated in the theorem is proven as follows:\nif \\(f(x)\\) is also equal to \\(g(x)\\bar{q}(x) + \\bar{r}(x)\\) with deg \\(\\bar{r}(x)<\\deg  g(x)\\), then\n\n\n\n\\(g(x)q(x) + r(x) = g(x) \\bar{q}(x) +\\overline{ r}(x) \\Rightarrow \\text{  }g(x) \\left(\\bar{q}(x)-q(x)\\right)= r(x)-\\bar{r}(x)\\)\n\n\n\nSince \\(\\deg  r(x) - \\bar{r}(x) < \\deg  g(x)\\), the degree of both sides of the last equation is less than \\(\\deg  g(x)\\). Therefore, it must be\nthat \\(\\bar{q}(x) - q(x) = 0\\), or \\(q(x) =\\bar{q}(x)\\) And so \\(r(x) = \\bar{r}(x)\\).  $\\blacksquare $ \n\n\n\\subsubsection{Section 16.4}\n\n*************\n1.\n*************\n<answer><p> If \\(a_0+ a_1\\sqrt{2}\\in \\mathbb{Q}\\left[\\sqrt{2}\\right]\\) is nonzero, then it has a multiplicative inverse:\n\n\n\n \\(\\text{            }\\frac{1}{a_0+ a_1\\sqrt{2}}=\\frac{1}{a_0+ a_1\\sqrt{2}}\\frac{a_0- a_1\\sqrt{2}}{a_0- a_1\\sqrt{2}}\\quad \\quad =\\frac{a_0-\na_1\\sqrt{2}}{a_0{}^2- 2a_1{}^2}\\quad \\quad =\\frac{a_0}{a_0{}^2- 2a_1{}^2}-\\frac{ a_1}{a_0{}^2- 2a_1{}^2}\\sqrt{2}\\)\n\n\n\nThe denominator, \\(a_0{}^2- 2a_1{}^2\\), is nonzero since \\(\\sqrt{2}\\) is irrational.  Since \\(\\frac{a_0}{a_0{}^2- 2a_1{}^2}\\) and\\(\\frac{-a_1}{a_0{}^2-\n2a_1{}^2}\\) are both rational numbers, \\(a_0+ a_1\\sqrt{2}\\) is a unit of \\(\\mathbb{Q}\\left[\\sqrt{2}\\right]\\).  The field containing \\(\\mathbb{Q}\\left[\\sqrt{2}\\right]\\)\nis denoted \\(\\mathbb{Q}\\left(\\sqrt{2}\\right)\\) and so \\(\\mathbb{Q}\\left(\\sqrt{2}\\right)=\\mathbb{Q}\\left[\\sqrt{2}\\right]\\) \n\n\n\n 3. \\(x^4 - 5x^2 +6 = \\left(x^2 - 2\\right)\\left(x^2 - 3\\right)\\) has zeros \\(\\pm \\sqrt{2}\\) and \\(\\pm \\sqrt{3}\\). \\(\\mathbb{Q}\\left(\\sqrt{2}\\right)\n= \\left\\{\\left.a + b\\sqrt{2} \\right| a, b \\in  \\mathbb{Q}\\right\\}\\) contains the zeros \\(\\pm \\sqrt{2}\\) but does not contain \\(\\pm \\sqrt{3}\\), since\nneither are expressible in the form \\(a + b\\sqrt{2}\\) . If we consider the set \\(\\left\\{c + d\\sqrt{3} : c,d \\in  \\mathbb{Q}\\left(\\sqrt{2}\\right)\\right\\}\\),\nthen this field contains \\(\\pm \\sqrt{3}\\) as well as \\(\\pm \\sqrt{2}\\), an is denoted  \\(\\left(\\mathbb{Q}\\left(\\sqrt{2}\\right)\\right)\\left(\\sqrt{3}\n\\right)= \\mathbb{Q}\\left(\\sqrt{2}, \\sqrt{3}\\right)\\).  Taking into account the form of <m>c</m> and <m>d</m> in the description above, we\ncan expand to\n\n\n\n\\(\\mathbb{Q}\\left(\\sqrt{2},\\sqrt{3}\\right)= \\left\\{b_0 + b_1\\sqrt{2} + b_2 \\sqrt{3} +b_3\\sqrt{6} |\\text{  }b_i \\in  \\mathbb{Q}\\right\\}\\).\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) \\(f(x) = x^3 + x + 1\\) is reducible if and only if it has a factor of the form \\(x- a\\). By Theorem 16.3.3, \\(x-a\\) is a factor if and only\nif <m>a</m> is a zero. Neither 0 nor 1 is a zero of \\(f(x)\\) over \\(\\mathbb{Z}_2\\).\n\n</p></li>\n<li><p>Since \\(f(x)\\) is irreducible over \\(\\mathbb{Z}_2\\), all zeros of \\(f(x)\\) must lie in an extension field of \\(\\mathbb{Z}_2\\) . Let c be a zero\nof \\(f(x)\\).   \\(\\mathbb{Z}_2(c)\\) can be described several different ways.  One way is to note that since \\(c \\in  \\mathbb{Z}_2(c)\\), \\(c^n\\in\n\\mathbb{Z}_2(c)\\) for all \\textit{ n. }Therefore, \\(\\mathbb{Z}_2(c)\\) includes 0, <m>c</m>, \\(c^2\\), \\(c^3, \\ldots\\). But \\(c^3 = c + 1\\) since\n\\(f(c) = 0\\). Furthermore, \\(c^4 = c^2+ c\\), \\(c^5= c^2+ c +1\\), \\(c^6= c^2+1\\), and \\(c^7=1\\).  Higher powers of <m>c</m> repeat preceding\npowers.  Therefore, \n\n\n\n \\(\\text{     }\\mathbb{Z}_2(c)= \\left\\{0, 1, c, c^2 , c + 1, c^2 + 1, c^2 + c + 1, c ^2 + c\\right\\}\\\\\n\\\\\n\\quad = \\left\\{a_0+ a_1c+a_2c^2| a_i\\in \\mathbb{Z}_2\\right\\}\\). \n\n\n\nThe three zeros of \\(f(x)\\) are <m>c</m>,  \\(c^2\\) and \\(c^2+ c\\).\n\n\n\n  \\(f(x) = (x + c)\\left(x+ c ^2 \\right)\\left(x + c^2 + c\\right)\\).\n\n</p></li>\n<li><p> Cite Theorem 16.2.4, part 3.\n\n\n\\subsubsection{Section 16.5}\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> Theorem 16.5.2 proves that not all nonzero elements in \\(F[[x]]\\) are units.</p></answer>\n\n\n*************\n7\n*************\n<answer><p><ol label=\"a\">\n<li><p>   \\(b_0= 1\\\\\n\\\\\nb_1=(-1)(2\\cdot 1) = -2\\)\n\n\n\n\\(b_2=(-1)(2\\cdot (-2)+4\\cdot 1)= 0\\\\\n\\\\\nb_3= (-1)(2\\cdot 0 + 4\\cdot (-2)+8\\cdot 1)=0\\\\\n\\\\\n\\text{     }\\ldots \\text{   }(\\text{all} \\text{others} \\text{are} \\text{zero})\\)\n\n\n\n           Hence,  \\(f(x)^{-1}= 1-2x\\)\n\n</p></li>\n<li><p>    \\(f(x)=1+2x + 2^2x^2+ 2^3x^3+ \\cdots \\\\\n\\\\\n\\quad =(2x)^0 + (2x)^1 + (2x)^2+ (2x)^3+\\cdots \\\\\n\\\\\n\\quad = \\frac{1}{1-2x}\\)\n\n\n\nThe last step follows from the formula for the sum of a geometric series.\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> (a)  \\(\\text{  }\\left(x^4-2 x^3+x^2\\right)^{-1} =\\left(x^2 \\left(x^2-2 x+1\\right)\\right)^{-1}\\quad \\quad =x^{-2}\\left(1-2x+x^2\\right)^{-1}\\quad\n\\quad =x^{-2}\\left(\\sum _{k=0}^{\\infty } (k+1) x^k\\right)\\text{    }\\text{by} \\text{Example} 2 \\text{of} 16.5\\quad \\quad =\\text{  }\\sum _{k=-2}^{\\infty\n} (k+2) x^k\\)\n\n\n\\subsubsection{Supplementary Exercises$---$Chapter 16}\n\n*************\n1.\n*************\n<answer><p> (a) This ring is not commutative.\n\n\n\n\\((A+B)^2= (A+B)\\cdot (A+B)\\\\\n\\\\\n\\quad \\quad = (A+B)\\cdot A+(A+B)\\cdot B\\\\\n\\\\\n\\quad \\quad = A\\cdot A+B\\cdot A+A\\cdot B+B\\cdot B\\\\\n\\\\\n\\quad \\quad = A^2+ B\\cdot A + A\\cdot B + B^2\\)\n\n\n\n    (b) Yes\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) By Theorem 16.1.1 show:\n\n</p></li>\n<li><p>\\([D +]\\) is a subgroup of the group \\(\\left[M_{2\\times 2}(\\mathbb{R}); +\\right]\\). We leave this to the reader.\n\n</p></li>\n<li><p>  <m>D</m> is closed under multiplication.  To prove this, let \\(\\left(\n\\begin{array}{cc}\n a &amp; 0 \\\\\n 0 &amp; b \\\\\n\\end{array}\n\\right), \\left(\n\\begin{array}{cc}\n c &amp; 0 \\\\\n 0 &amp; d \\\\\n\\end{array}\n\\right)\\in D\\).  Then,\n\n\n\n$\\quad \\quad $\\(\\left(\n\\begin{array}{cc}\n a &amp; 0 \\\\\n 0 &amp; b \\\\\n\\end{array}\n\\right) \\left(\n\\begin{array}{cc}\n c &amp; 0 \\\\\n 0 &amp; d \\\\\n\\end{array}\n\\right)= \\left(\n\\begin{array}{cc}\n a c &amp; 0 \\\\\n 0 &amp; b d \\\\\n\\end{array}\n\\right)\\in D\\)\n\n\n\nsince \\(a c\\) and \\(b d\\) are real numbers and the product is in the form of a typical matrix in \\textit{ D.}\n\n</p></li>\n<li><p>  Since\n\n\n\n\\(\\left(\n\\begin{array}{cc}\n a &amp; 0 \\\\\n 0 &amp; b \\\\\n\\end{array}\n\\right) \\left(\n\\begin{array}{cc}\n c &amp; 0 \\\\\n 0 &amp; d \\\\\n\\end{array}\n\\right)= \\left(\n\\begin{array}{cc}\n a c &amp; 0 \\\\\n 0 &amp; b d \\\\\n\\end{array}\n\\right)=\\left(\n\\begin{array}{cc}\n c &amp; 0 \\\\\n 0 &amp; d \\\\\n\\end{array}\n\\right)\\left(\n\\begin{array}{cc}\n a &amp; 0 \\\\\n 0 &amp; b \\\\\n\\end{array}\n\\right)\\),\n\n\n\n       <m>D</m> is commutative.    The unity for <m>D</m> is \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\).\n\n</p></li>\n<li><p> The product of two nonzero matrices can be equal to zero.  For example,  \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 0 &amp; 0 \\\\\n\\end{array}\n\\right) \\left(\n\\begin{array}{cc}\n 0 &amp; 0 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)= \\left(\n\\begin{array}{cc}\n 0 &amp; 0 \\\\\n 0 &amp; 0 \\\\\n\\end{array}\n\\right)\\).  Therefore, <m>D</m> has divisors of zero and by Theorem 16.1.2 the cancellation law is not true in <m>D</m>.\n\n</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a) \\(2^4 = 16\\)\n\n</p></li>\n<li><p>   The product cited in the solution to 3(c) above shows that \\(M_{2\\times 2}(\\mathbb{R})\\) has divisors of zero.  Therefore, the matrix polynomial\n\\((x-I)(x+I)\\) may have solutions other then \\(\\pm I\\).  If fact you can verify that \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 1 \\\\\n 0 &amp; 1 \\\\\n\\end{array}\n\\right)\\) and \\(\\left(\n\\begin{array}{cc}\n 1 &amp; 0 \\\\\n 1 &amp; 1 \\\\\n\\end{array}\n\\right)\\) satisfy the given equation.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p>   Use \\(T:A\\to \\mathbb{R}\\)  defined by \\(T\\left(\\left(\n\\begin{array}{cc}\n a &amp; 0 \\\\\n 0 &amp; 0 \\\\\n\\end{array}\n\\right) \\right)= a\\)\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> By substitution and the operation tables of Example 16.2.2,\n\n\n\n\\(\\text{       }a^2+ a + 1 = b + a+1 \\quad \\quad = 1+1 = 0\\)\n\n\n\nTherefore, \\(a\\) is a root.  A similar calculation shows that <m>b</m> is a root.   Substitution of 0 and 1 for <m>x</m> shows that they\nare not root.\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p> By Theorem 16.3.3, \\(a \\in  \\mathbb{Q}\\) is a zero of \\(f(x)\\) iff \\((x - a)\\) is a factor of \\(f(x)\\), which also implies <m>a</m> must be\na factor of 9.   Hence, the only possible rational roots are: $\\pm $1, $\\pm $3, and $\\pm $9.  We can verify that \\((x - 3)\\) is a divisor of\n\\(f(x)\\) or that \\(x = 3\\) is a zero of \\(f(x)\\). Dividing \\(f(x)\\) by \\((x - 3)\\) produces \\(q(x) =x^3-3x^2+x -3\\), which has \\(x = 3\\) as a rational\nroot. Dividing \\(q(x\\)) by \\(x-3\\) produces \\(x^2+1\\). Hence, the complete factorization of \\(f(x)\\) in \\(\\mathbb{Q}[x]\\) is \\((x - 3)^2\\left(x^2+\n1\\right)\\).\n\n</p></answer>\n\n\n*************\n13\n*************\n<answer><p>    \\(g(0) = 0\\), \\(g(1) = 1\\), \n\n\n\n\\(g(a) = a^3 + a^2 + a = 1 + b + a=1+1= 0\\), and \n\n\n\n\\(g(b) = b^3+b^2 + b = 1 + a + b\\text{  }= 1 + 1= 0.\\) \n\n\n\n     Hence, 0, <m>a</m>, and <m>b</m> are zeros of \\(g(x)\\) and the \\(g(x) =x(x-a)(x-b) = x(x + a)(x + b)\\).</p></answer>\n\n\n*************\n15\n*************\n<answer><p> (a) \\(\\text{Sum} = (1,0, 1)\\),  \\(\\text{Product} = (0, 1, 1, 1)\\)\n\n</p></li>\n<li><p> \\(\\text{Sum} = (1,0, 0, 0)\\), \\(\\text{Product} = (0, 1, 1, 1, 0, 0, 1)\\)\n\n</p></li>\n<li><p> \\(\\text{Sum} = (1, 1, 1, 0, 0)\\), \\(\\text{Product} = (0, 0, 0, 0, 1, 1, 1, 0, 1)\\)\n\n</p></li>\n<li><p> \\(\\text{Sum} = 010\\),  \\(\\text{Product} = 11011\\)\n\n</p></answer>\n\n\n*************\n16\n*************\n<answer><p> The encoding of a string of bits is based on polynomial division.  Given a four bit message, we make the bits coefficients of a sixth degree\npolynomial,  \\(b_3x^3+b_4x^4+b_5x^5+b_6x^6\\)  which we can also express in \\(\\mathbb{Z}_2{}^6\\)  as \\(\\left(0,0,0,b_3,b_4,b_5,b_6\\right)\\),\nwe divide this polynomial by \\(p(x) =1+x+x^3\\) and add the remainder to the {``}message polynomial.  The quotient is in the division is discarded.\n Thus, if the remainder, which must be a polynomial of degree less than 2, is \\(b_0+ b_1x+b_2x^2\\), the encoded message is the string of bits \\(\\left(b_0,b_1,b_2,b_3,b_4,b_5,b_6\\right)\\).\n\n</p></li>\n<li><p> Encode the following elements of \\(\\mathbb{Z}_2{}^6\\)as described above.\n\n</p></li>\n<li><p>  \\((0, 0,0, 1, 1,0, 1)\\)\n\n</p></li>\n<li><p> \\((0, 0, 0, 1,1, 1, 1)\\)\n\n</p></li>\n<li><p> \\(\\)\\((0, 0,0,0,0,1, 0)\\)\n\n</p></li>\n<li><p> Prove that the encoded message will always represent a polynomial with is evenly divisible by the polynomial \\(p(x)\\) that is used to encode\nthe message.\n\n</p></answer>\n\n\n*************\n17\n*************\n<answer><p> If the message polynomial is \\(m(x) =b_3x^3+b_4x^4+b_5x^5+b_6x^6\\)we divide by \\(p(x)= 1 + x+x^3\\) and get a quotient and remainder:   \\(m(x)\n= p(x)q(x) + r(x)\\), where the degree of \\(r(x)\\) is less than 3.   We transmit  \\(t(x) = m(x) + r(x)= m(x) +(m(x)-p(x)q(x))= p(x)q(x)\\)  since\n\\(m(x)+m(x)=0\\).  Now assume that the error \\(x^k\\) is added and we receive \\(p(x)q(x)+x^k\\).   Since \\(x^k\\), \\(0\\leq k\\leq 6\\), is not a multiple\nof \\(p(x)\\), the received polynomial is also not a multiple of \\(p(x)\\).  The following \\textit{ Mathematica} calculation verifies this last claim.\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\left(\\left\\{x^{\\#},\\text{PolynomialRemainder}\\left[x^{\\#},x^3+x+1,x,\\text{Modulus}\\to 2\\right]\\right\\}\\&amp;\\text{/@}\\text{Range}[0,6]\\right)\\text{//}\\text{Prepend}[\\#,\\{\\text{{``}Monomial{''}},\\text{{``}Remainder{''}}\\}]\\&amp;}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\left(\n\\begin{array}{cc}\n \\text{Monomial} &amp; \\text{Remainder} \\\\\n 1 &amp; 1 \\\\\n x &amp; x \\\\\n x^2 &amp; x^2 \\\\\n x^3 &amp; x+1 \\\\\n x^4 &amp; x^2+x \\\\\n x^5 &amp; x^2+x+1 \\\\\n x^6 &amp; x^2+1 \\\\\n\\end{array}\n\\right)\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n19\n*************\n<answer><p> (a) \\(b(x) = x^5 + x^4+ 1= g(x)\\left(x^2+x+1\\right)+0 \\Rightarrow a = 111\\)\n\n</p></li>\n<li><p>  \\(b(x) = x^5+ x^3+ x^2+1= g(x)x^2+1\\\\\n\\\\\n\\quad \\quad \\Rightarrow  \\text{error} \\text{in} \\text{the} \\text{first} \\text{bit} \\text{of} \\text{\\textit{$b$}}\\\\\n\\\\\n\\quad \\quad \\Rightarrow e(a) = 001101\\\\\n\\\\\n\\quad \\quad \\Rightarrow  a=001\\)\n\n\n\nGetting <m>a</m> from \\(e(a) \\unicode{0008}\\) involves doing this calculation:\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{PolynomialQuotient}\\left[x^5+x^3+x^2,x^3+ x+1,x,\\text{Modulus}\\to 2\\right]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(x^2\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> \\(b(x) = x^5+ x+1= g(x)\\left(x^2+1\\right)+x^2\\\\\n\\\\\n\\quad \\quad \\Rightarrow  \\text{error} \\text{in} \\text{the} \\text{third} \\text{bit} \\text{of} \\text{\\textit{$b$}}\\\\\n\\\\\n\\quad \\quad \\Rightarrow e(a) = 111001\\\\\n\\\\\n\\quad \\quad \\Rightarrow  a=101\\)\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{\\text{PolynomialQuotient}\\left[x^5+x^2+x+1,x^3+ x+1,x,\\text{Modulus}\\to 2\\right]}\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(x^2+1\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> \\(b(x) = x^4+x^3+ x+1= g(x)(x+1)+x^2+x\\\\\n\\\\\n\\quad \\quad \\Rightarrow  \\text{error} \\text{in} \\text{the} \\text{fifth} \\text{bit} \\text{of} \\text{\\textit{$b$}}\\\\\n\\\\\n\\quad \\quad \\Rightarrow e(a) = 110100\\text{   }(\\text{the} \\text{string} \\text{representation} \\text{of} g(x))\\\\\n\\\\\n\\text{                                  }\\Rightarrow  a=100\\)\n\n</p></answer>\n\n\n*************\n21\n*************\n<answer><p> (a) \\(g(x)\\) is irreducible over \\(\\mathbb{Z}_2\\) since \\(g(0) = g(1) = 1\\). Hence, g(x) does not split  in \\(\\mathbb{Z}_2\\). Let \\(\\beta\\)\nbe a zero of \\(g(x)\\), so that \\(\\mathbb{Z}_2[\\beta ]= \\left\\{\\left.a+b \\beta  + c \\beta ^2\\right| a,b,c\\in \\mathbb{Z}_2\\right\\}\\).  This is a\nfield of \\(2^3=8\\) elements which, by Theorem 16.2.4, is isomorphic to \\(\\text{GF}(8)\\).\\\\\n\\\\\n23. \\(1/g(x) = f(x)\\) of Example 16.5.2.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n25\n*************\n<answer><p> (a)  \\(a_0= a_1= 1\\), \\(a_2=2\\), \\(a_3= 3\\), \\(a_4= 5, \\ldots\\)., so \n\n\n\n$\\quad \\quad $\\(f(x)=1 + x +2x^2+ 3x^3+ 5x^4+ \\cdots\\).\n\n\n\n (b)  \\(a_0= a_1= 1\\), \\(a_2= 0\\), \\(a_3= 1\\), \\(a_4= 1\\), \\(a_5= 0\\), $\\ldots $ .  \n\n\n\n\\(g(x) = 1 + x +0 x^2 + x^3+ x^4+ 0x^5+ x^6+x^7+\\cdots \\\\\n\\\\\n\\quad =(1+x) + x^3(1+x) + x^6(1+x) + \\cdots \\\\\n\\\\\n\\quad = (1+x)\\left(1+x^3+ x^6+ \\cdots \\right)\\\\\n\\\\\n\\quad = \\frac{(1+x)}{\\left(1-x^3\\right)}\\)  \n\n\\end{document}\n\\subsection{Supplementary Exercises$---$Chapter 9}\n\n*************\n1.\n*************\n<answer><p> Graphs \\(G_1\\) and \\(G_2\\) are isomorphic. One isomorphism between them is \\(\\{(a,e), (b,h), (c,f), (d,g)\\}\\). To see that \\(G_3\\) is not isomorphic\nto the other two notice that <m>k</m> and <m>j</m> are not connected by an edge while in \\(G_1\\) and \\(G_2\\) every pair of vertices is connected.\n\n</p></answer>\n\n\n*************\n3\n*************\n<answer><p> (a) \\(\\{a,e\\}\\) is a maximal independent set in Figure 9.1.2.\n\n</p></li>\n<li><p> (By contradiction) Assume that <m>W</m> is a maximal independent set in <m>G</m>. If <m>V</m> is not connected to any vertex, \\(W\\cup\n\\{v\\}\\) is independent, and since this is a larger set, <m>W</m> is not maximal.\n\n</p></li>\n<li><p> A single vertex is maximal; no larger set can be independent.</p></answer>\n\n\n*************\n5\n*************\n<answer><p> (a)\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></li>\n<li><p> \\((\\text{Mexico},\\text{Guatemala},\\text{Belize},\\text{Nicaragua},\\text{Costa} \\text{Rica},\\text{Panama})\\)\n\n</p></li>\n<li><p> This path could be a list of the countries that you would go through in your trip.\n\n</p></answer>\n\n\n*************\n7\n*************\n<answer><p> (a) If one source <m>s</m> exists, then \\((s,v)\\) is on the edge of the round-robin tournament graph for each vertex <m>v</m> different\nfrom <m>s</m>. Therefore no other vertex could be a source. By similar reasoning, only one sink can exist. In a round-robin tournament, only one\nteam can be unbeaten and only one can be winless.\n\n</p></li>\n<li><p> If \\(\\left| V\\right| =n\\), \\(\\text{\\textit{outdeg}}(\\text{source}) =\\text{\\textit{$ $}}\\text{\\textit{indeg}}\\text{\\textit{$($}}\\text{sink}) =\nn-1\\)\n\n</p></li>\n<li><p> Let \\(V=\\left\\{v_1,v_2,\\ldots ,v_n\\right\\}\\). The following graph demonstrates that \\(p\\land \\neg q\\) is possible. Similar graphs can be drawn\nfor the other situations.\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n\n\n\n\n</p></answer>\n\n\n*************\n9\n*************\n<answer><p> \\(\\begin{array}{cccccccccc}\n k\\text{                       } &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 &amp; 7 &amp; 8 &amp; 9 \\\\\n V[k].\\text{name} &amp; a &amp; b &amp; c &amp; d &amp; e &amp; f &amp; g &amp; h &amp; i \\\\\n V[k].\\text{found} &amp; T &amp; T &amp; T &amp; T &amp; T &amp; T &amp; T &amp; T &amp; T \\\\\n V[k].\\text{from}\\text{  } &amp; 4 &amp; 1 &amp; 5 &amp; 5 &amp; 1 &amp; 3 &amp; 5 &amp; 5 &amp; 6 \\\\\n \\text{depth} \\text{set}\\text{     } &amp; 3 &amp; 1 &amp; 2 &amp; 2 &amp; 1 &amp; 3 &amp; 2 &amp; 2 &amp; 4 \\\\\n\\end{array}\\)\n\n</p></answer>\n\n\n*************\n11\n*************\n<answer><p> \\(G_1\\) is randomly Eulerian from no vertex, yet it is Eulerian. \n\n\n\n\\(G_2\\) is randomly Eulerian from only vertex 1. \n\n\n\n\\(G_3\\) is randomly Eulerian from only vertices 1 and 2. \n\n\n\n\\(G_4\\) is randomly Eulerian from every vertex.\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n</p></answer>\n\n\n*************\n13\n*************\n<answer><p> Addition of edges to <m>E</m> will certainly not decrease the degrees of each vertex. After adding some edges to <m>E</m> until no more\ncan be added without allowing a Hamiltonian circuit, select \\(e=\\left\\{v_1,v_n\\right\\}\\) not in the new, larger <m>E</m>. Since a Hamiltonian\ncircuit exists in \\((G,E\\cup \\{e\\})\\), there is a path in <m>G</m> that visits every vertex in the order \\(v_1,v_2,\\text{$\\ldots $v}_n\\). Now\nfor \\(2\\leq i\\leq n, \\text{if} \\left\\{v_1,v_i\\right\\}\\in E,\\) then\n\n\\begin{doublespace}\n\\noindent\\(\\pmb{}\\)\n\\end{doublespace}\n\n\n\n\\(\\left\\{v_{i-1},v_n\\right\\}\\notin E\\), for otherwise, \\(\\left(v_1,v_2,\\ldots ,v_{i-1},v_n,v_n,v_{n-1},\\ldots ,v_i,v_1\\right)\\) is a Hamiltonian\ncircuit.\n\n\n\nSince \\(\\left\\{v_1,v_i\\right\\}\\in E\\Rightarrow \\left\\{v_{i-1},v_n\\right\\}\\notin E\\Leftrightarrow \\neg \\left(\\left\\{v_1,v_i\\right\\}\\in E\\right.\\)\nand \\(\\left.\\left\\{v_{i-1},v_n\\right\\}\\in E\\right)\\), no more than \\(n-1\\) of the possible edges that connect \\(v_1\\) and \\(v_n\\) to other vertices\ncould be in <m>E</m>, even after adding edges to <m>E</m>. Therefore, for the original graph, with \\(\\left\\{v_1,v_n\\right\\}\\notin E, \\text{\\textit{$\\deg\n$}} \\text{\\textit{$v$}}_1+\\text{\\textit{$\\deg $}}\\text{\\textit{$ $}}\\text{\\textit{$v$}}_{n }<n\\), a contradiction.\n\n</p></answer>\n\n\n*************\n15\n*************\n<answer><p> (a)  \\(f(b,d)=f(c,d)=f(a,g)=f(y,t)=1, f(d,t)=2, V(f)=3\\).\n\n</p></li>\n<li><p> One flow-augmenting path is \\((s,a,g,t)\\), which increased the flow value by 1, to 4. (A second one is \\((s,b,d,a,g,t)\\).)\n\n</p></li>\n<li><p>  The new flow is maximal since its value is equal to the sum of capacities into the sink.\n\n</p></answer>\n\n\n*************\n17\n*************\n<answer><p>(a) \\((A,D,F,E,C,B,A)\\)\n\n</p></li>\n<li><p> Starting at any city, it would take \\(n-2\\) seconds to decide where to go first. Then it would take \\(n-3\\) seconds from the next step, and so\non. The total time would be\n\n\n\n\\((n-2)+(n-3)+\\cdots +2+1+0=\\frac{1}{2(n-2)(n-1)} \\text{seconds}\\\\\n\\\\\n\\quad \\quad \\approx \\frac{1}{2n^2}\\text{seconds}, \\text{when} n \\text{is} \\text{large}.\\)\n\n</p></answer>\n\n\n*************\n19\n*************\n<answer><p>\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\\begin{doublespace}\n\\noindent\\(\\)\n\\end{doublespace}\n\n\n\n", "meta": {"hexsha": "8f3f22be6e1f2c7209cf5d9592efdd0771ad4df3", "size": 148101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "SolX/Sol_9-16.tex", "max_stars_repo_name": "klevasseur/ads", "max_stars_repo_head_hexsha": "49aa8f9a89f23ee01d64d74d46e33b314d5ef299", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2016-08-09T20:31:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T10:44:44.000Z", "max_issues_repo_path": "SolX/Sol_9-16.tex", "max_issues_repo_name": "klevasseur/ads", "max_issues_repo_head_hexsha": "49aa8f9a89f23ee01d64d74d46e33b314d5ef299", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2016-01-04T17:22:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T19:58:03.000Z", "max_forks_repo_path": "SolX/Sol_9-16.tex", "max_forks_repo_name": "klevasseur/ads", "max_forks_repo_head_hexsha": "49aa8f9a89f23ee01d64d74d46e33b314d5ef299", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2016-12-08T13:55:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-03T06:15:02.000Z", "avg_line_length": 25.3337324666, "max_line_length": 473, "alphanum_fraction": 0.5542231315, "num_tokens": 59996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.7826624738835052, "lm_q1q2_score": 0.4035563588233798}}
{"text": "\\documentclass{article}\n\n\\usepackage{hyperref}\n\\usepackage{amsmath}\n\\begin{document}\n\n\\subsubsection{Sparse-Estimation}\n% Following \\url{https://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm}\n  \\begin{align*}\n    T_{ij} &= P(S_{t+1}=j |S_t=i)\\\\\n    O_j &= \\text{diag}(P(X_t=j | S_t=0), P(X_t=j | S_t=1))\\\\\n    f(t) &= f(t)\\left[TO_{o(t)}\\right]^{L(t)}\\\\\n    f(t) &= \\hat{f}(\\tau_{t+1}-1)= P(\\hat{o}_1,\\hat{o}_2,,,\\hat{o}_{\\tau_{t+1}-1},\\hat{X}_{\\tau_{t+1}-1}|\\pi_0)\\\\\n    b(t) &= \\hat{b}(\\tau_{\\tau_{t+1}}-1) = P(\\hat{o}_{\\tau_{t+1}},\\hat{o}_{\\tau_{t+1}+1},,,\\hat{o}_{\\hat{N}},\\hat{X}_{\\tau_{t+1}-1}|\\pi_0)\\\\\n    b(t-1) &= \\left[TO_t\\right]^{L(t)}b(t)\\\\\n  \\end{align*}\n  \n  \\subsubsection{Xi-sum}\n  \\begin{align*}\n    \\hat{\\xi}_{ij}(\\tau-1) &= \\hat{f}_{i}(\\tau-1)T_{ij}O_{\\hat{o}(\\tau), jj}\\hat{b}_j(\\tau)\\\\\n    \\hat{\\xi}(\\tau-1) &= T_{ij} \\circ (\\hat{b}(\\tau)\\hat{f-1}(\\tau))^TO_{\\hat{o}(\\tau)}\\\\\n    \\sum_{\\tau=1}^{\\hat{N}-1} \\xi_\\tau &= \\sum_{\\tau=1}^{\\hat{N}-1} T_{ij} \\circ (\\hat{b}(\\tau)\\hat{f}(\\tau-1))^TO_{\\hat{o}(\\tau)}\\\\\n    &= T_{ij} \\circ \\sum_{\\tau=1}^{\\hat{N}-1} (\\hat{b}(\\tau)\\hat{f}(\\tau-1))^TO_{\\hat{o}(\\tau)}\\\\\n    &= T_{ij} \\circ \\sum_{k=0}^{N-1} \\sum_{\\tau=t_k}^{t_{k+1}-1} (\\hat{b}(\\tau)\\hat{f}(\\tau-1))^TO_{\\hat{o}(\\tau)}\\\\\n    &= T_{ij} \\circ \\sum_{k=0}^{N-1} \\left[\\sum_{\\tau=t_k}^{t_{k+1}-1} (\\hat{b}(\\tau)\\hat{f}(\\tau-1))^T\\right]O_{o(t_k)}\\\\\n    &= T_{ij} \\circ \\sum_{k=0}^{N-1} \\left[\\sum_{\\tau=t_k}^{t_{k+1}-1} (M_{k}^{t_{k+1}-1-\\tau}\\hat{b}(t_{k+1}-1)\\hat{f}(t_k-1)M_k^{\\tau-t_k})^T\\right]O_{o(t_k)}\\\\\n    &= T_{ij} \\circ \\sum_{k=0}^{N-1} \\left[\\sum_{t=0}^{L(k)-1} (M_{k}^{L(k)-1-t}b(k)f(k-1)M_k^{t})^T\\right]O_{o(k)}\\\\\n  \\end{align*}\n  \\subsubsection{Update}\n  \\begin{align*}\n    \\hat{\\gamma}(\\tau) &= \\hat{f}_{\\tau} \\circ \\hat{b}_{\\tau}^T/(\\hat{f}_{\\tau}\\hat{b}_{\\tau})\\\\\n    \\hat{\\Gamma^\\circ} &= \\text{diagonal}{\\hat\\Gamma}\\\\\n&= \\sum_\\tau \\hat{f}_{\\tau} \\circ \\hat{b}_{\\tau}^T/(\\hat{f}_{\\tau}\\hat{b}_{\\tau})\\\\\n    \\hat{\\Gamma} &= K \\sum_\\tau \\hat{b}_{\\tau}\\hat{f}_{\\tau}\\\\\n    &= K \\sum_t \\sum_{n<L(t)} \\hat{b}_{\\tau_t+n} \\hat{f}_{\\tau_t+n}\\\\\n    &= K\\sum_t \\sum_{n<L(t)}  \\hat{b}_{\\tau_t+n}\\hat{f}_{\\tau_t+n}\\\\\n    &= K\\sum_t \\sum_{n<L(t)} \\left[TO_{o(t)}\\right]^{L(t)-(n+1)}b(t)f(t-1)\\left[TO_{o(t)}\\right]^{n+1}\\\\\n    &= K\\sum_t \\gamma(t)\\\\\n  \\end{align*}\n  \\begin{align*}\n   \\gamma(t) &= \\sum_{n<L(t)} \\left[TO_{o(t)}\\right]^{L(t)-(n+1)}b(t)f(t-1)\\left[TO_{o(t)}\\right]^{n+1}\\\\\n   TO_{o(t)} &= P_{o(t)}D_{o(t)}P_{o(t)}^{-1}\\\\\n   A(t) &= P_{o(t)}^{-1}b(t)f(t-1)P_{o(t)}\\\\\n   \\gamma(t) &= \\sum_{n<L_t}P_{o(t)}D_{o(t)}^{L_t-(n+1)}A(t)D_{o(t)}^{n+1}P_{o(t)}^{-1}\\\\\n   \\gamma(t) &= P_{o(t)}\\sum_{n<L_t}\\left[D_{o(t)}^{L_t-(n+1)}A(t)D_{o(t)}^{n+1}\\right]P_{o(t)}^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^{L-(n+1)} &0\\\\ 0 & d_2^{L-(n+1)}\\\\ \\end{pmatrix} A \\begin{pmatrix} d_1^{n+1} &0\\\\ 0 & d_2^{n+1}\\\\ \\end{pmatrix}\\right]P^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^L & d_1^{L-n-1}d_2^{n+1}\\\\ d_2^{L-n-1}d_1^{n+1} & d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^L & d_1^L(d_2/d_1)^{n+1}\\\\ d_2^L(d_1/d_2)^{n+1} & d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n  &= P\\left[ \\begin{pmatrix} Ld_1^L & (d_2/d_1)\\frac{d_1^{L+1}-d_2^{L+1}}{d_1-d_2}\\\\ (d_1/d_2)\\frac{d_1^{L+1}\n         -d_2^{L+1}}{d_1-d_2} & L d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\ \n  \\end{align*}\n% L+1 prob not right\n  \\begin{align*}\n  \\gamma(t) &= \\sum_{n<L_t}(TO_{o(t)})^{L_t-n}b_{t+1}f_t(TO_{o(t)})^n\\\\\n  \\gamma(t) &= \\sum_{n<L_t}P_{o(t)}D_{o(t)}^{L_t-n}P_{o(t)}^{-1}b_{t+1}P_{o(t)}D_{o(t)}^{n}P_{o(t)}^{-1}\\\\\n  &= P\\sum_{n<L_t}\\left[D^{L_t-n}AD^{n}\\right]P^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^{L-n} &0\\\\ 0 & d_2^{L-n}\\\\ \\end{pmatrix} A \\begin{pmatrix} d_1^n &0\\\\ 0 & d_2^n\\\\ \\end{pmatrix}\\right]P^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^L & d_1^{L-n}d_2^n\\\\ d_2^{L-n}d_1^n & d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n  &= P\\sum_{n<L} \\left[ \\begin{pmatrix} d_1^L & d_1^L(d_2/d_1)^n\\\\ d_2^L(d_1/d_2)^n & d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n  &= P\\left[ \\begin{pmatrix} (L+1)d_1^L & d_1^L\\frac{1-(d_2/d_1)^{L+1}}{1-d_2/d_1}\\\\ d_2^L\\frac{1-(d_1/d_2)^{L+1}}{1-d_1/d_2} & (L+1) d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n  &= P\\left[ \\begin{pmatrix} (L+1)d_1^L & \\frac{d_1^{L+1}-d_2^{L+1}}{d_1-d_2}\\\\ \\frac{d_1^{L+1}\n        -d_2^{L+1}}{d_1-d_2} & (L+1) d_2^L\\\\ \\end{pmatrix} \\circ A \\right]P^{-1}\\\\\n\\end{align*}\n\\end{document}\n", "meta": {"hexsha": "5f17ca519c1affcb08acf97b67eac49399d2544c", "size": 4444, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hmmacs/sparse/sparse_models.tex", "max_stars_repo_name": "knutdrand/hmmacs", "max_stars_repo_head_hexsha": "701515ded737ea77fea7aaa93d8e7b3d85f5bf6f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hmmacs/sparse/sparse_models.tex", "max_issues_repo_name": "knutdrand/hmmacs", "max_issues_repo_head_hexsha": "701515ded737ea77fea7aaa93d8e7b3d85f5bf6f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hmmacs/sparse/sparse_models.tex", "max_forks_repo_name": "knutdrand/hmmacs", "max_forks_repo_head_hexsha": "701515ded737ea77fea7aaa93d8e7b3d85f5bf6f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.3692307692, "max_line_length": 179, "alphanum_fraction": 0.5209270927, "num_tokens": 2365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.4921881357207955, "lm_q1q2_score": 0.40354177249318723}}
{"text": "%!TEX root = main.tex\n\n\\chapter{Modulation}\n\\label{chap:modulation}\n\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[width = 14cm]{img/surface-modulation_3.jpg}\n\t\t\\caption{``Surface Modulation'' by Richard Sweeney}\n\t\t\\label{fig:Surface Modulation}\n\t\\end{center}\n\\end{figure}\n\n\n\\begin{center}\n\\begin{figure}[h!]\n\\tikzset{concept/.append style={fill={none}}}\n\\begin{tikzpicture}\n  \\path[mindmap,concept color=black,text=black]\n    node[concept] {Modulation}\n    [clockwise from=0]\n    child[concept color=red!50!black] {\n      node[concept] {AM}\n      % }\n      [clockwise from=90]\n      child { node[concept] {Envelopes} }\n      child { node[concept] {AM} }\n      child { node[concept] {Ring Modulation} }\n      % child { node[concept] {pro\\-gramming languages} }\n      % child { node[concept] {software engineer\\-ing} }\n    }\n    child[concept color=blue] {\n      node[concept] (fm) {FM}\n      [clockwise from=-30]\n    }\n    child[concept color=red] { node[concept] (pm){Phase Modulation} }\n    child[concept color=orange] { node[concept] (sd) {Sound design Challenge} }\n    child[concept color=green] { node[concept] (conv) {Convolution} };\n\n\n\\begin{pgfonlayer}{background}\n    \\draw [circle connection bar]\n      (fm) edge (sd)\n      (fm) edge (pm);\n  \\end{pgfonlayer}\n\n\\end{tikzpicture}\n\\caption{Lecture Contents}\n\\end{figure}\n\\end{center}\n\n\n% \\section{Notizen}\n\n% kürzer. Modulation als sub einheit einplanen.\n% Sounddesign challg. halbe stunde ok..\n\n% Passt garnicht: (weil eher additive synth)\n% https://www.youtube.com/watch?v=oKv9S6mxnXE\n\n% Convolution anreissen?\n% Notation durchgehen.\n\n% Aliasing besprochen?\n% \\href{https://www.youtube.com/watch?v=GBtHeR-hY9Y}{Water experiment}\n% (youtube \\glqq{}The Secret to Levitation\\grqq{})\n\n% AM, tremolo\n\n% Envelopes in pd\n\n% FM, vibrato\n\n% sounddesign chall.\n\n% Hü\n\n\\section{Convolution}\n\\label{sub:conv}\nBefore talking about modulation, we should quickly look at what's convolution\\footnote{'Faltung' in German}.\\\\\nConvolution is a mathematical operation, widely used in signal processing but also in other fields. Convolution of two functions, say, $x$ and $h$ is typically denoted as $x*h$. \\textbf{Note that $*$ does not mean multiplication here, it means convolving $x$ with $h$}. Obviously this can lead to confusion in some cases, but notation problems are not uncommon in sciences.\\footnote{e.g while mathematicians use $i$ as the imaginary number, electrical engineering folks use $j$ (their $i$ is electrical current.).}\\\\\n\nWe will define Convolution of a function $x$ with a convolution kernel $h$ of length $N$as\\footnote{You will find different definitions online. The given definition seems more intuitive but is not very common. Here is a common one:$y(n) = \\sum_{k=-\\infty}^{\\infty} x(k) h (n-k)$}:\n\n\\begin{equation}\ny(n) = \\sum_{k=0}^{N-1} x(n-k) h (k)\n\\end{equation}\nIn words: for every output sample $y(n)$ take the current input sample $x(n)$ times the first sample of the convolution Kernel $h(0)$ plus take the previous input sample $x(n-1)$ times the second sample of the convolution kernel $h(1)$ plus the third last input sample $x(n-2)$ times the third sample of the convolution kernel $h(2)$ and so on... until the $Nth$ sample of $h$. It can be viewed as a a weighted average of the previous input samples, with weighting coefficients found in $h$.\n\nWe will look at convolution in a later chapter. If you  are eager to know more about convolution can have a look at\n\\href{https://youtu.be/_vyke3vF4Nk?t=25m14s}{this}\\footnote{https://youtu.be/\\_vyke3vF4Nk?t=25m14s}. \\link{http://www.songho.ca/dsp/convolution/convolution2d\\_example.html}{Here} is an example of convolution in 2D. Convolution in 2D is actually a bit easier to understand and is usually done to achieve a blur effect on an image or video. But why mention convolution if it is not explained at this point? Amplitude modulation and convolution just have a very close relationship, an that is:\n\\important{Multiplying two signals in the time domain is equivalent to convolution in the frequency domain and convolution in the time domain is equivalent to multiplication in the frequency domain.\n}\n\n\n\n\\section{AM} % (fold)\n\\label{sub:AM}\nIn this section we will try amplitude modulation. Amplitude modulation is used for radio communication (so you'll need to understand this as a technician, modulation techniques are extremely important and this is maybe the simplest one) but also in sound design. We will try to understand the problem from different perspectives at once:\n\\begin{itemize}\n\t\\item Doing some math\n\t\\item listening to it\n\t\\item brining it in context to beating waves\n\t\\item seeing it as convolution in the frequency domain\n\\end{itemize}\n\nAmplitude modulation means modulating the amplitude of a signal(surprise!). Modulating means changing over time by another signal. So we have some signal, say, a sine wave, and change its amplitude with another signal, say, another sine wave. Taking this concept and reducing it radically, we end up with figure \\ref{fig:simpleAM}.\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics{img/ringNaive.png}\n\t\t\\caption{Simplest form of ``Ring modulation''.}\n\t\t\\label{fig:simpleAM}\n\t\\end{center}\n\\end{figure}\nOf course, we get no sound in figure \\ref{fig:simpleAM} because the frequencies are not initialized, but it shows the general principle. The caption of that figure says ``Ring Modulation''. Let's quickly get some vocabulary straight:\\\\\n\\begin{itemize}\n\t\\item ``Amplitude modulation'' might mean any modulation of amplitude\n\t\\item ``Ring Modulation'' means \\textit{bi-polar} amplitude modulation.\n\t\\item In sound design, ``Amplitude Modulation'' might specifically mean unipolar amplitude modulation.\n\\end{itemize}\n\nAnd some more vocabulary to put what we are doing in a musical context:\n\\begin{itemize}\n\t\\item Modulating the amplitude is called ``Tremolo'' in music \\footnote{sadly, the fender Stratocaster's ``Tremolo Arm'' is used to control the pitch. Ignore Fender, they got it wrong. You can trust that most guitar players are confused because of this.}\n\t\\item Modulating the pitch or frequency (``FM'') is called ``vibrato'' in a musical context.\\footnote{Maybe think about it like this: The F in FM is a bit like the v in vibrato. Just to avoid confusion..}\n\\end{itemize}\n\nEnough words, let's look at what AM looks like, look at figure \\ref{fig:AMViz}.\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{AMviz.png}\n\t\\caption[AM time domain]\n\t{Looking at AM in the time domain}\n\t\\label{fig:AMViz}\n\\end{figure}\n\n\\begin{question}\n\tIf we would listen to the signal depicted in the bottom plot of figure \\ref{fig:AMViz}, what do you think we would hear? Try to imagine! If you can't, use pure data to test it! That's why we are using pd.\n\\end{question}\n\\begin{Answer}\n\tWe would hear a 30Hz sine wave repeatedly rising and falling in amplitude.\n\\end{Answer}\n\n\\begin{question}\n\tNext question, same plot, same signal. So hopefully you found out that we hear a 30 Hz sine with rising and falling amplitude. At what frequency does the amplitude rise and fall? Remember we are modulating with a 1 Hz sine.\n\\end{question}\n\\begin{Answer}\n\tTwo Hertz.\n\\end{Answer}\n\nYou can try out plotting what happens with different frequency settings in \\link{https://colab.research.google.com/drive/1oO3ApcIfvcUoIqv9\\_nDS-HNl8B4Gf5hl}{this Notebook}.\n\nMaybe you remember from the waveshaping chapter that we actually calculated what frequencies should come out of AM. Also maybe you remember that:\n\n\\important{\nAmplitude Modulation produces sum and difference frequencies of the input frequencies.\n\\begin{equation}\n\tcos(a)\\cdot cos(b) = \\frac{cos(a+b) + cos(a-b)}{2}\n\\end{equation}\n}\nBut here we still hear the 30 Hz, just getting louder and softer, so what's wrong?\\\\\nSo, let's calculate this. We have two oscillators, $x_1(t) = cos(30t2\\pi)$ and $x_2(t)=cos(t2\\pi)$. We multiply them, ending up with:\n\n\\begin{equation}\n\ty(t) = cos(30t2\\pi) \\cdot cos(t2\\pi)\n\\end{equation}\nOk, the above formula tells us this means:\n\\begin{equation}\n\ty(t) = \\frac{cos(30t2\\pi+t2\\pi)+cos(30t2\\pi-t2\\pi)}{2}\n\\end{equation}\nWe can now simplify to:\n\\begin{equation}\n\ty(t) = \\frac{cos((30+1)t2\\pi)+cos((30-1)t2\\pi)}{2} = \\frac{cos(31t2\\pi)+cos(29t2\\pi)}{2}\n\\end{equation}\n\nHm, so we get out a 31Hz and 29Hz oscillator. What about that rising and falling in amplitude that we hear \\textit{and} observe in the plot, surely there must be something wrong! Do you have a solution to this?\\\\\n\nLet's use pure data to help us understand. Make two oscillators, one with 29Hz and one with 31Hz, what do you hear?\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics{beating.png}\n\t\\caption[adding two oscillators]\n\t{Adding two oscillators with frequencies very close to each other}\n\t\\label{fig:beating}\n\\end{figure}\n\nIf you listen to what is depicted in figure \\ref{fig:beating}, you will in fact hear the same as if you do the 30Hz /1 Hz amplitude modulation (which indicates that our formula above is correct). What we hear is a phenomenon called beating(``Schwebung''). The phase of the two oscillators is canceling each other out at regular intervals because the frequencies are so close to each other. In fact the frequency of the beating $f_{beat}$ is always\n\\begin{equation}\n\tf{beat}=|f_1-f_2|\n\\end{equation}\nSo the difference of the two frequencies.\n\n\n% \\comm{vline and envelop description missing}\n% \\begin{figure}[H]\n% \t\\begin{center}\n% \t\t\\includegraphics[width = 14cm]{img/simpleEnv.png}\n% \t\t\\caption{caption}\n% \t\t\\label{fig:name}\n% \t\\end{center}\n% \\end{figure}\n\n\\section{FM} % (fold)\n\\label{sub:FM}\n\nFrequency modulation can be used to modulate the frequency, meaning to vary the pitch of a sound, see figure \\ref{fig:fmSlow}. But it can also be used to generate overtones and an overall richer spectrum, see figure \\ref{fig:fmFast}. The two ``different versions'' only differ from each other by different parameter\\footnote{We see which parameters can be adjusted in a minute. But if you want to know them now: modulation frequency, modulation amount and carrier frequency.} values being used.\nWe can think of Frequency Modulation (FM) as something of the form:\n\n\\begin{equation}\n\ty(t) = cos(cos(b))\n\\end{equation}\n\nThis really is a simplification, but the overall structure of the formula is correct.\n% FM is mathematically very similar to phase modulation.\nLooking at figure \\ref{fig:fmIdea} we can see the very basic idea implemented in pure data.\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics{img/FMgeneral.png}\n\t\t\\caption{The General Idea of FM}\n\t\t\\label{fig:fmIdea}\n\t\\end{center}\n\\end{figure}\n\nSince the frequencies of the oscillators are not set, we won't hear anything when building this patcher. But looking at it may reveal that the idea simply is to control the frequency of an oscillator using another oscillator.\\\\\nWe can expand the patcher by adding some math to make it more usable, as in figure \\ref{fig:fmNaive}.\n\nNaive parameters are ${f_c}$ (Carrier Frequency), ${f_m}$ (Modulator Frequency), and ${A_m}$ (modulation Amount).\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics{img/FMnaive.png}\n\t\t\\caption{Naive Implementation with Direct Parametrization.}\n\t\t\\label{fig:fmNaive}\n\t\\end{center}\n\\end{figure}\n\n\\important{\n\nThe output frequencies will be\n\\begin{equation}\n\tf_c \\pm n \\cdot f_m\n\\end{equation}\n\nfor $n$ being all integers. So the carrier frequency plus and minus integer multiples of the modulation frequency. We get many (theoretically infinitely) many overtones with different amplitudes this way.\n}\n\\bgInfo{\n\tThe amplitudes of the different frequencies are determined by Bessel functions which makes it so seemingly random.\n\t\t\\centering\n\t\t\\includegraphics[width=11cm]{bessel}\n}\n\n\nTypically, FM is controlled via \\textit{Index}, \\textit{Ratio}, and fundamental Frequency.\nThe Index, ${I}$ is given by Modulation Depth and Modulator Frequency.\n\n\n% =============Something is wrong with this.============================\n\n% \\begin{mdframed}[backgroundcolor=black!10,rightline=false,leftline=false]\n\\bgInfo{\n\\begin{equation}\nI = \\frac{A_m}{f_m} % verified via http://computermusicresource.com/FM.synthesis.html\n\\end{equation}\n\nA more controllable Implementation will generate the naive parameters from a Ratio, ${R}$, the Carrier Frequency and the Index:\n\\begin{equation}\n\tf_m = \\frac{f_c}{R}\n\\end{equation}\n\n\\begin{equation}\n\tA_m = I \\cdot f_m\n\\end{equation}\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics{img/FMcorrect.png}\n\t\t\\caption{FM with Index and Ratio}\n\t\t\\label{fig:fmComplete}\n\t\\end{center}\n\\end{figure}\n\nBut there are also different implementations such as:\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=5cm]{fmMillerPuckette}\n\t\\caption[miller Puckette FM]\n\t{Fm implementation from \\cite{miller_puckette_theory_2006}}\n\t\\label{fig:label}\n\\end{figure}\n\n% ===========FIND EN EXPLANATION FOR THE ABOVE FM implementations=============\n\n\n% \\end{mdframed}\n% =========================================================================\n}\n\n\\begin{figure}[h!]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{FMslow}\n\t\\caption[FM visualization, low freq]\n\t{Modulator frequency: 1Hz, Crarrier Frequency 50 Hz, Modulation Amount 10. Please ignore the labeling of the Y axis of the spectrum plot($10^0$). It is wrong. The y axis goes from 0 to nyquist=22050Hz.}\n\t\\label{fig:fmSlow}\n\\end{figure}\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=\\textwidth]{FMfast}\n\t\\caption[FM visualization, hi freq]\n\t{Modulator frequency: 100Hz, Crarrier Frequency 1000 Hz, Modulation Amount 0.5. Please ignore the labeling of the Y axis of the spectrum plot($10^0$). It is wrong. The y axis goes from 0 to nyquist=22050Hz.}\n\t\\label{fig:fmFast}\n\\end{figure}\n\n\n\\section{Key Points}\n\\begin{itemize}\n\t\\item Make sure you understand the differences between AM and FM\n\t\\item Make sure you recognize what form of modulation is present if you see a patcher or a simplfied formula (like: $sin(a) \\cdot sin(b)$ what form of modulation is this?)\n\t\\item make sure you could make such a simplified formula if you see a patch and vice versa.\n\t\\item make sure you know what frequencies result from an amplitude modulation\n\t\\item make sure you know what frequencies result from a frequency modulation\n\\end{itemize}\n\n% \\section{Hausübung}\n% \\label{sub:Hausuebung}\n% Andy Farnell, \\href{http://aspress.co.uk/ds/pdf/pd_intro.pdf}{pd intro} chapter 6, lesen\n", "meta": {"hexsha": "9a03f1378c767c4c3598ef01a5f4367a9b72e5d0", "size": 14358, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "modulation.tex", "max_stars_repo_name": "hrtlacek/dspCourse", "max_stars_repo_head_hexsha": "32e251b2e3756a1265fe73596515f58f51c4489f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2018-09-04T22:32:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-10T22:18:47.000Z", "max_issues_repo_path": "modulation.tex", "max_issues_repo_name": "hrtlacek/dspCourse", "max_issues_repo_head_hexsha": "32e251b2e3756a1265fe73596515f58f51c4489f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-01-23T13:42:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-23T13:44:43.000Z", "max_forks_repo_path": "modulation.tex", "max_forks_repo_name": "hrtlacek/dspCourse", "max_forks_repo_head_hexsha": "32e251b2e3756a1265fe73596515f58f51c4489f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-09-05T13:18:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-21T02:42:58.000Z", "avg_line_length": 43.2469879518, "max_line_length": 516, "alphanum_fraction": 0.7408413428, "num_tokens": 4003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.40352566508477267}}
{"text": "\\chapter{FEniCS}\n\nThe \\fenics project started in 2003 and the aim was create software that automates a finite element discretisation and solution of differential equations. The core libraries used within \\fenics are DOLFIN \\cite{LoggWells2010a,LoggWellsEtAl2012a}, FFC \\cite{KirbyLogg2006a,LoggOlgaardEtAl2012a,OlgaardWells2010b}, FIAT \\cite{Kirby2012a,Kirby2004a}, Instant, UFC \\cite{AlnaesLoggEtAl2009a,AlnaesLoggEtAl2012a} and UFL \\cite{AlnaesEtAl2012,Alnaes2012a}. Along the these core packages \\fenics has a few extra optional packages that can be found here \\url{http://fenicsproject.org/applications/}.\n\n\\section{Overview}\n\nOne of the key ideas of \\fenics was to be able to write an easy to use software package for the solution of partial differential equations (PDEs). The main underlying code base for \\fenics is written in C++. and Python\n\n\n\\fenics supports large range of a different finite element function space. Thus allowing \\fenics to be used from electromagnetic problems to fluid. The full list of support elements can be found in table~\\ref{tab:FunctionSpace}.\n\\begin{table}[h!]\n    \\begin{center}\n        \\begin{tabular}{ l  l }\n            Name    &Usage\\\\\n            \\hline\n            Argyris*    &``ARG''\\\\\n            Arnold-Winther* &``AW''\\\\\n            Brezzi-Douglas-Fortin-Marini*   &``BDFM''\\\\\n            Brezzi-Douglas-Marini   &``BDM''\\\\\n            Bubble  &``B''\\\\\n            Crouzeix-Raviart    &``CR''\\\\\n            Discontinuous Lagrange  &``DG''\\\\\n            Hermite*    &``HER''\\\\\n            Lagrange    &``CG''\\\\\n            Mardal-Tai-Winther* &``MTW''\\\\\n            Morley* &``MOR''\\\\\n            Nedelec 1st kind H(curl)    &``N1curl''\\\\\n            Nedelec 2nd kind H(curl)    &``N2curl''\\\\\n            Quadrature  &``Q''\\\\\n            Raviart-Thomas  &``RT''\n        \\end{tabular}\n        \\caption{Avaliable finite element function space (*only partly supported)}\n        \\label{tab:FunctionSpace}\n    \\end{center}\n\\end{table}\n\n\n\nThis breath introduction to \\fenics will go through how to set up a very simple test case, namely the Poisson equation. For this simple problem we will consider both Dirichlet and Neumann boundary conditions and show how to set up the PDE in its variational form.\n\n\n\\section{Poisson example}\n\nFor a simple example to see how FEniCS works consider the Poisson equation. Defining $\\Omega \\subset \\R^n$ to be the domain and the boundary as $\\partial \\Omega = \\Gamma_D \\cup \\Gamma_N$ where $\\Gamma_D$ and $\\Gamma_N$ correspond to the Dirichlet and Neumann boundaries respectively. Thus, the Poisson equation with corresponding boundary conditions reads as:\n\\begin{equation} \\label{eq:poisson}\n \\left. \\begin{aligned}\n-\\Delta u &= f \\quad \\mbox{in } \\Omega\\\\\n u &= 0 \\quad \\mbox{in } \\Gamma_D\\\\\n\\nabla u \\cdot n &= g \\quad \\mbox{in } \\Gamma_N\n    \\end{aligned}\n \\right.\n \\qquad \\text{}\n\\end{equation}\nFor this example we will be considering the following function, domains and boundaries to be:\n\\begin{itemize}\n\\item $f = (x-\\nicefrac{1}{2})^2-4(y-\\nicefrac{1}{2})^4$\n\\item $g = 5x$\n\\item $\\Omega = [0,1]\\times[0,1]$\n\\item $\\Gamma_D = \\{(0,y) \\cup (1,y) \\quad | \\quad  0\\leq y\\leq 1\\}$\n\\item $\\Gamma_N = \\{(x,0) \\cup (x,1) \\quad | \\quad  0\\leq x\\leq 1\\}$\n\\end{itemize}\nDefining the following trial and test function spaces  $\\mathcal{V}$ and $\\bar{\\mathcal{V}}$ as\n\\begin{equation} \\label{eq:PoissonFuncSpace}\n \\left. \\begin{aligned}\n    \\mathcal{V}&=H^1_{u_0}(\\Omega)=\\left\\{\\,{u}\\in H^1(\\Omega)\\,:\\,\\text{${u}=u_{0}$ on $\\partial\\Omega$}\\,\\right\\}, \\\\\n    \\bar{\\mathcal{V}}&=H^1_0(\\Omega)=\\left\\{\\,{u}\\in H^1(\\Omega)\\,:\\,\\text{${u}={0}$ on $\\partial\\Omega$}\\,\\right\\}.\n \\end{aligned}\n \\right.\n \\qquad \\text{}\n\\end{equation}\nThus the variational formulation of (\\ref{eq:poisson}) depends on finding $u \\in \\mathcal{V}$ such that\n\\begin{equation}\n\\label{eq:PoissonWeak}a(u,v) = L(v) \\quad \\forall v\\in\\bar{\\mathcal{V}},\n\\end{equation}\nwhere\n\\begin{equation}\na(u,v) = \\int_{\\Omega} \\nabla u \\cdot \\nabla v \\, dx \\quad \\mbox{and} \\quad L(v) = \\int_{\\Omega} fv dx +\\int_{\\Gamma_N}gv\\,ds.\n\\end{equation}\n\n\\subsection{Defining mesh and function space}\n\nFor this example we want to consider a uniform unit square mesh. This is created by using the following python code\n\\begin{pythoncode}\nmesh = UnitSquareMesh(32,32)\n\\end{pythoncode}\nOnce the mesh is create we no turn to the function space. For this model problem we want to consider the function space $\\mathcal{V}$  and $\\bar{\\mathcal{V}}$ defined by \\eqref{eq:PoissonFuncSpace}. Therefore, the discrete finite element space use is the following space\n$$\\uu{V}_h  = \\{\\, \\uu{u}\\in H_1( \\Omega)\\, :\\, \\uu{u}|_K \\in {\\mathcal P}_{1}(K), \\, K \\in{\\mathcal T}_h \\, \\},$$\nwhere ${\\mathcal T}_h=\\{K\\}$ regular and quasi-uniform triangles. This function space is create in \\fenics using the following command\n\\begin{pythoncode}\nV = FunctionSpace(mesh,'CG',1)\n\\end{pythoncode}\n\n\\subsection{Defining subdomains}\nSeparating different parts of the boundary is easily done within FEniCS. For this our simple Possion model the boundary is split up into two parts. The top and bottom defines the Dirichlet boundary condition whilst the left and right portions of the boundary define the Neumann conditions. Before partitioning the domain into the Dirichlet and Neumann boundaries we need to define the different sections of the boundary. This is done using classes as follows:\n\\begin{pythoncode}\n# Defining boundary classes\nclass Left(SubDomain):\n    def inside(self, x, on_boundary):\n        return near(x[0], 0.0)\n\nclass Right(SubDomain):\n    def inside(self, x, on_boundary):\n        return near(x[0], 1.0)\n\nclass Bottom(SubDomain):\n    def inside(self, x, on_boundary):\n        return near(x[1], 0.0)\n\nclass Top(SubDomain):\n    def inside(self, x, on_boundary):\n        return near(x[1], 1.0)\n\n# Initialize sub-domain instances\nleft = Left()\ntop = Top()\nright = Right()\nbottom = Bottom()\n\\end{pythoncode}\nUsing the classes above we group the Dirichlet and Neumann boundaries together. These can then be used to set up the boundary conditions for our problem.\n\\begin{pythoncode}\nboundaries = FacetFunction(\"size_t\", mesh)\nboundaries.set_all(0)\nleft.mark(boundaries, 1)\nright.mark(boundaries, 1)\ntop.mark(boundaries, 2)\nbottom.mark(boundaries, 2)\n\\end{pythoncode}\n\n\\subsection{Boundary Conditions and weak formulation}\n\nThe boundaries have been split into their separate domains so now we can think about defining the boundary conditions, bilinear and linear (\\ref{eq:PoissonWeak}) forms.\n\nFirst consider the homogeneous Dirichlet boundary:\n$$  u = 0 \\quad \\mbox{in } \\Gamma_D.$$\nThe Dirichlet boundary condition is created by using the  \\code{DirichletBC} class. When defining Dirichlet boundary conditions on separate subdomains we need to use four inputs to the  \\code{DirichletBC} class. The first one is the function space that the boundary condition applies to, the value on the boundary and then the last two arguments define which part of the boundary the boundary condition is defined on.\n\\begin{pythoncode}\nu0 = Constant(0.0)\nbc = DirichletBC(V, u0, boundaries,1)\n\\end{pythoncode}\n\nTo define the variational form of the problem we first need to determine the trial function  \\code{u} and test function  \\code{v} belonging to the function space $\\mathcal{V}$. Furthermore, the source term $f$ and Neumann condition $g$ are required in the linear form $L(v)$. Both are defined using the  \\code{Expression} class. Together with the trial and test functions the variational form can be created using the following code:\n\\begin{pythoncode}\n# Define variational problem\nu = TrialFunction(V)\nv = TestFunction(V)\nf = Expression(\"(pow(x[0]-0.5,2)-4*pow(x[1]-0.5,4))\")\ng = Expression(\"(5*x[0])\")\na = inner(grad(u), grad(v))*dx\nL = f*v*dx + g*v*ds(2)\n\\end{pythoncode}\n\n\n\\subsection{Assembly and solving}\n\nNow the variational  (or weak form) have been stated the next step is to solve the problem. This can be done in two was within FEniCS\n\\begin{itemize}\n    \\item[1.] Assemble system and solve\n    \\item[2.] Solve without assembly.\n\\end{itemize}\nFirst, consider assembling then solve the system. This can be done by using the {\\code{assemble\\_system}} class. This class takes the variational form as the inputs and the Dirichlet boundary condition.\n\\begin{pythoncode}\nA, b = assemble_system(a,L,bc)\n\\end{pythoncode}\nThe final solving step is the same for both ways. To do this we first define a function {\\code{u}} in the corresponding function space ($\\mathcal{V}$) that will represent the solution. Next, calling the \\code{solve} function with either the matrix \\code{A} and vector \\code{b} as the arguments or the variational form will compute the solution using sparse direct solvers which is the  default solving method for \\fenics\n\\begin{pythoncode}\nu = Function(V)\nsolve(A,u.vector(),b)\nsolve(a == L, u, bc)\n\\end{pythoncode}\n\n\\subsubsection{Optional solution parameters}\n\nFor simplicity above the \\code{solve} used \\fenics default parameters. However, this may not necessarily be the most efficient so may want to change these parameters. It is well known for example that multigrid is the most efficient solve for the Poisson problem. Here is how to set this up.\n\\begin{pythoncode}\nsolve(a == L, u, bc,\n            solver_parameters=dict(linear_solver=\"cg\",\n            preconditioner=\"amg\"))\n\\end{pythoncode}\nFor more optional parameters use the following commands:\n\\begin{pythoncode}\nprint list_krylov_solver_methods()\nprint list_krylov_solver_preconditioners()\nprint list_linear_algebra_backends()\nprint list_linear_solver_methods()\nprint list_lu_solver_methods()\n\\end{pythoncode}\n\nInstead of using FEniCS's inbuilt solving function you can use other external packages. For instance you can link you your FEniCS code with Trilinos \\cite{Trilinos-Users-Guide,Trilinos-Overview}, PETSc \\cite{petsc-web-page,petsc-user-ref} or your own code.\n\n\\subsection{Visualisation}\n\nOnce you have solved your problem the next step is to either visualise or save the result. To output the solution in a VTK file you need to create a file with \\code{.pvd} suffix. This enables you to use external software (for example ParaView \\cite{}) to visualise the solution. Alternatively FEniCS's has an interface for the VTK visualisation tools. We do this by using the \\code{plot} command.\n\\begin{pythoncode}\n# Save solution in VTK format\nfile = File(\"poisson.pvd\")\nfile << u\n\n# Plot solution\nplot(u, interactive=True)\n\\end{pythoncode}\n\n\\begin{figure}[h!]\n  \\centering\n    \\includegraphics[scale=.6]{../FEniCS/Figures/dolfin_plot_1}\n\\caption{Numerical solution to (\\ref{eq:poisson})}\n\\end{figure}\n\n\n% \\bibliographystyle{plain}\n% \\bibliography{/home/mwathen/Dropbox/MastersResearch/MHD/THESIS/ref/ref}\n\n", "meta": {"hexsha": "406ccac7054bbe37a90ea6761138c75a8698af94", "size": 10701, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MHD/THESISnew/FEniCS/FEniCS.tex", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/THESISnew/FEniCS/FEniCS.tex", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/THESISnew/FEniCS/FEniCS.tex", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 50.4764150943, "max_line_length": 591, "alphanum_fraction": 0.722362396, "num_tokens": 3064, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.40352565152796216}}
{"text": "\\chapterp{3p}{Offline labelling of SWR segments}\n\\label{ch:offline}\n\nTo quantify the performance of a sharp wave-ripple (SWR) detection algorithm, we need an evaluation or `test' recording, annotated with the segments of time when actual SWR events were present. This section describes how such annotations can be made, and how our data specifically was annotated.\n\nSWR's are an empirical phenomenon of hippocampal area CA1, `defined' by what their voltage traces look like. In other words, there is no ground truth available to know when SWR's occur. Scientists looking to annotate their LFP recordings with SWR segments therefore have to rely either on judgement calls by human labellers, or on an automated, offline SWR detection algorithm. The former could be considered more subjective, and is definitely more labour intensive than the latter -- especially if multiple scientists are consulted to obtain a consensus labelling. Most studies use an automated, offline algorithm to detect SWR segments (see \\cref{apx:offline-detection-algos} for relevant quotes from a collection of such studies).\n\n`Offline' here means that SWR detection happens after the recording has been completed, and that there are thus no real-time constraints on the detection algorithm. This means that 1) there are no hard bounds on algorithm execution time, and 2) that the algorithm can use information `from the future': when deciding whether a recording sample $\\z_t$ belongs to an SWR segment, it can consider samples $\\z_{t_f}$ that occured after $\\z_t$ (i.e. $t_f > t$), instead of considering only past samples $\\z_{t_p}$ (where $t_p \\leq t$).\n\n\n\\begin{figure}\n\\img[1.14]{107_2--107_8}\n\\captionn{Steps for automated, offline SWR labelling}{See text for details. Each vertical scalebar indicates the same voltage range. $H[o_t]$ denotes the Hilbert transform of $o_t$. Note its phase lag of 90\\si{\\degree} with respect to $o_t$. In the second panel from the bottom, note the two threshold crossings of $T\\low$ (marked with black dots) that did not result in a ripple segment, because the second threshold $T\\high$ was not reached. The distribution of the envelope $n_t$ was estimated using the entire dataset (and not just the displayed fragment).}\n\\label{fig:offline-steps}\n\\end{figure}    \n\n\n\\section{Overview of offline ripple detection}\n\nThe main steps of the offline SWR detection algorithm that most studies use -- such as the ones cited in \\cref{apx:offline-detection-algos}, and the one of this thesis -- can be summarized as follows:\n\\begin{enumerate}\n\\item Use a single channel of input data; namely from an electrode in the pyramidal cell layer of CA1, where the ripple part of SWR's is most strongly present. (We will denote this voltage signal with $z_t$);\n\\item Band-pass filter the recording to retain only `ripple' frequencies. (We will denote the filter output as $o_t$);\n\\item Obtain the envelope of the band-pass filtered signal. (We will denote this envelope with $n_t$);\n\\item Calculate a `high' and a `low' threshold ($T\\high$ and $T\\low$) to apply to the envelope $n_t$, based on summary statistics of $n_t$ and two custom multipliers ($\\alpha\\high$ and $\\alpha\\low$);\n\\item Define ripple events as times when the envelope crosses the high threshold (i.e. $n_t > T\\high$);\n\\item Define the start and end time of each such ripple as the closest times where the envelope falls back below the lower threshold (i.e. $n_t < T\\low$).\n\\end{enumerate}\n\n\\Cref{fig:offline-steps} visualizes each step, as applied to a fragment of our dataset.\n\nNote that this procedure only detects ripples, and not sharp waves.\\footnote{Although interestingly, the sharp wave part of sharp wave-ripples was discovered before the ripple part \\cite[p. 1]{Buzsaki2015}.}\n\n\n\n\n\\section{Validating parameter choices}\n\\label{sec:validating-parameter-choices}\n\nSome of the above steps have free parameters (such as the ripple frequency band used for filtering, or the threshold multipliers $\\alpha\\high$ and $\\alpha\\low$). If not mentioned otherwise, our parameter choices were made as follows.\n\nIn a first pass of the offline detection algorithm, ripples were detected using a very broad-band filter and a low detection threshold. This ensured that all `true' SWR's were included in the detected events set (in addition to many spurious detections).\n\nNext, five neuroscientists were independently asked to decide for each detected event whether it was a sharp wave-ripple or not. This was done through a custom-made web app, an example screen of which is shown in \\cref{fig:labelface-UI}. Note that the labellers could factor multiple recording channels into their decision, including stratum radiatum channels displaying sharp wave activity. Only the events that were labelled as an SWR by at least three neuroscientists were retained.\n\nFinally, when setting the parameters of the eventual offline ripple detection algorithm, the algorithm's output was compared to the decisions made by the neuroscientists. The parameters were then adjusted until the output of the algorithm matched the neuroscientists' decisions reasonably well.\n\nThe following subsections describe the detection steps in more detail, and compare our choices of methods and parameters to those made in the literature.\n\n\\begin{figure}\n\\img[1.1]{labelface-UI}\n\\captionn{User interface for SWR labelling}{Each event in the list at the top is represented by two voltage traces: one from an electrode in the pyramidal cell layer (the top trace), and one from an electrode in the stratum radiatum.\nThe large plot at the bottom gives more comprehensive view of the currently active event: all 16 channels are plotted (instead of only two), and the plot ranges from 1000 ms before to 1000 ms after the event.\nIn this large plot, the blue vertical line marks the currently active event. The grey vertical lines correspond to other detected events. (The scalebar at the beginning of this plot represents 1 mV). Users decide whether the currently active event is an SWR by clicking the buttons in the top-right corner or by using keyboard shortcuts. The source code for this labelling web app is available at \\url{https://github.com/tfiers/labelface}.}\n\\label{fig:labelface-UI}\n\\end{figure}\n\n\n\\section{Band-pass filter design}\n\nThe wideband voltage signal $x_t$ was band-pass filtered between 100 and 200 Hz, using a linear time-invariant filter with zero output lag.\n% todo: mention downsampling\n\nMany other studies use a higher left bound, of about 140--150 Hz (see \\cref{tab:bands}). Using such a high bound in our dataset however resulted in ripples that went undetected (even at low detection thresholds), although they were convicingly marked as SWR's by the neuroscientists.\n% todo: plot peak-f distribution of marked SWR's\n\nThe band-pass filter was designed using the windowed-sinc method, with a Kaiser window (using SciPy's \\texttt{firwin} and \\texttt{kaiserord} functions) \\cite{Roelandts2016,Jones2018a}. The transition width was chosen to be 10\\% of the bandwidth (i.e. 10 Hz), and the attenuation to be 40 dB, resulting in an FIR filter of order 150 (at a 1000 Hz sampling frequency).\n\nThe filter was applied bidirectionally, resulting in a zero-lag output, and a total attenuation of 80 dB. \\Cref{fig:offline-steps} shows an example of the filter output in green.\n\n(We cannot easily compare our filter design method with the literature, as most studies do not mention anything about filter design besides the frequency band used).\n\n\n\n\\section{Envelope calculation}\n\nNext, the instantaneous envelope $u_t$ of the filter output $o_t$ was calculated using its Hilbert transform\\footnotemark{} $H[o_t]$:\n%\n\\begin{equation}\n\\label{eq:Hilbert_envelope}\nu_t = \\sqrt{o_t^2 + H[o_t]^2},\n\\end{equation}\n\n\\footnotetext{To be precise, $H$ is a discrete approximation to the continuous Hilbert transform $\\mathcal{H}$. There are multiple ways to make a discrete approximation to $\\mathcal{H}$ \\cite{Oppenheim2009}. Most of them make use of the discrete Fourier transform, which makes computing $H$ an efficient operation. We used SciPy's \\texttt{hilbert} function (which, confusingly, does not return the Hilbert transform of its input, but rather its analytical signal), and zero-padded the input signal to the nearest power of 2 or 3 to benefit from the speedup brought by the fast Fourier transform algorithm.}\n\nThe Hilbert transform delays each frequency component of a signal by 90\\si{\\degree} (see the gray signal in \\cref{fig:offline-steps})  \\cite{Lyons2010}. This means that the envelope of a narrowband signal such as $o_t$ can be easily obtained as the magnitude of the so called `analytic signal' $o_t + j H[o_t]$, as in \\cref{eq:Hilbert_envelope}.\\footnotemark{}\n\n\\footnotetext{To see why, consider a local approximation of the narrowband signal $o_t$ by a sinusoid $a \\cos{\\omega t}$. Its Hilbert transform is then $a \\sin{\\omega t}$. From \\cref{eq:Hilbert_envelope}, the envelope $u_t$ will be locally approximated by the magnitude of the original signal: $u_t = \\sqrt{(a \\cos{\\omega t})^2 + (a \\sin{\\omega t})^2} = \\abs{a}$.}\n\nAfter calculating $u_t$, a final, smoothed envelope $n_t$ was obtained by convolving $u_t$ with a Gaussian kernel ($\\sigma$ = 7.5 ms, support radius of $4 \\sigma$). Compare the blue ($u_t$) and the red signal ($n_t$) in \\cref{fig:offline-steps}.\n\nOther studies (such as \\cite{Nadasdy1999} and \\cite{Csicsvari2000}) use a ``root-mean-square'' approach to calculate the envelope of the filter output $o_t$. In these studies, presumably, the squared signal $o_t^2$ is smoothed using some kernel (of unspecified type and bandwidth) to obtain the ``mean-square'' signal of which the square root is taken.\n\n\n\n\\section{Threshold calculation}\n\nThe two detection thresholds were calculated as follows:\n\\begin{align}\n\\label{eq:thresholds-symbolic}\nT\\high &= \\alpha\\high \\times \\median{n_t} \\\\\nT\\low  &= \\alpha\\low  \\times \\median{n_t}\n\\end{align}\n%\nwhere $\\median{n_t}$ denotes the median of the smoothed envelope $n_t$. As per the procedure described in \\cref{sec:validating-parameter-choices}, we set $\\alpha\\high = 6.2$ and $\\alpha\\low = 3.6$. At a median envelope magnitude $\\median{n_t} = \\SI{17.0}{\\micro\\volt}$, this results in thresholds $T\\high = \\SI{105.4}{\\micro\\volt}$ and $T\\low = \\SI{61.2}{\\micro\\volt}$.\n\nMost studies calculate thresholds as follows: $T\\high = \\mean{n_t} + \\beta\\high \\times \\std(n_t)$. Here $\\mean{n_t}$ denotes the mean of the envelope, $\\std(n_t)$ denotes its standard deviation, and $\\beta\\high$ is a custom multiplier analogous to $\\alpha\\high$. For the non-negative, assymetric distributions of envelope signals, using both a measure of center and a measure of spread to define thresholds seems unnecessary (see the distribution of $n_t$ in \\cref{fig:offline-steps}), which is why we chose to use only one measure (namely the median).\n% One advantage of the median over the mean, is that the former is far less sensitive to outliers of than the latter. Our dataset did not seem to include any outliers, such as erroneous samples with improbably high magnitude, however.\n\nThe detection multiplier $\\beta\\high$ varies wildly between studies: from 1, over 3, 4, and 5, up until 7 (\\cite{Csicsvari2000,Dutta2018,Behrens2005,Sadowski2016,Nadasdy1999}, respectively).\\footnotemark{} It is clear that such different thresholds will give very different sensitivity-precision trade-offs for SWR detection (the lower thresholds yielding more false positive detections, and the higher thresholds yielding more missed true SWR events).\n\n\\footnotetext{Threshold multipliers cannot be compared precisely. Imagine two recordings with equally powerful ripples. Both recordings will then need an equal threshold $T\\high$ to detect the same types of ripples. When one of the recordings has a different background `noise' level or a different ripple incidence rate, it will have different $\\mean{n_t}$ and $\\std(n_t)$ values. This means that $\\beta\\high$ needs to change to maintain an equal threshold $T\\high$.}\n\nTo compare our thresholds to those in the literature, we calculate the $\\beta$ multipliers corresponding to our chosen $\\alpha$ multipliers. Given that our dataset has a mean envelope magnitude of 22.3 \\uV{} and a standard deviation of 22.9 \\uV{}, we find $\\beta\\high = 3.63$ and $\\beta\\low = 1.70$. These values fall near the center of those reported in the literature (see \\cref{apx:offline-detection-algos}).\n% todo: calculate ripple magnitude and background magnitude\n\n\n\n\\section{Segment post-processing}\n\nFinally, two add-hoc rules were applied to the automatically detected ripple segments. First, segments with only a small gap between them (of less than 10 ms) were joined together. Then, segments of too short a duration (less than 25 ms) were eliminated.\n\nThis step is rarely done in other studies. An exception is e.g. \\cite{Dutta2018}, were segments shorter than 15 ms were eliminated.\n\n% todo:\n% - two thresholds is standard (Ji & Wilson 2007, via Ego-Stengel 2009)\n% - Ego-Stengel 2009 also joins small gaps.\n\n% todo: standardized data\n", "meta": {"hexsha": "6d5704e64b35e379a281ec0672d678983c2ca342", "size": 13054, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "modules/Offline-labelling/index.tex", "max_stars_repo_name": "tfiers/master-thesis", "max_stars_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-03-23T01:39:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-23T01:39:24.000Z", "max_issues_repo_path": "modules/Offline-labelling/index.tex", "max_issues_repo_name": "tfiers/master-thesis", "max_issues_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 46, "max_issues_repo_issues_event_min_datetime": "2018-09-18T16:38:12.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-10T22:37:35.000Z", "max_forks_repo_path": "modules/Offline-labelling/index.tex", "max_forks_repo_name": "tfiers/master-thesis", "max_forks_repo_head_hexsha": "3e97128eeb18827b03da90817fe6f6985c84ad80", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 100.4153846154, "max_line_length": 733, "alphanum_fraction": 0.7760073541, "num_tokens": 3195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4035018610490422}}
{"text": "\\chapter{Alternative RL Algorithms}\\label{alternativeRL} \n\n\n\n\\paragraph{Sarsa-Learning}\n\nSarsa Learning is very similar to Q-Learning, and it generalises to Deep Sarsa-Learning just as Q-Learning generalises to Deep Q-Learning. The difference is that unlike Q-Learning, which is an off-policy method, Sarsa is on-policy. This means that in its update equation:\n\n\\begin{equation} \\label{eq:sarsa-learningUpdate}\nQ(s_t,a_t) \\longrightarrow Q(s_t,a_t) + \\alpha[( r_t + Q(s_{t+1}, a')) - Q(s_t,a_t)]\n\\end{equation}\n\n$a'$ is also sampled according to the $\\epsilon$-greedy technique, and it is not chosen greedily to be the best estimate like in Q-Learning. Then, naturally, the next chosen action will be exactly $a'$.\n\nDue to this difference, Sarsa is more stable during training, but also it converges more slowly as it is not directly learning the optimal (greedy) policy, but an $\\epsilon$-greedy policy~\\cite{sutton2018RLbook}. Hence, Sarsa is more suitable when performance during training matters, and bad decisions are penalised (e.g. a valuable robot gets broken), but this is not the case in our protocols.\n\n\\paragraph{Monte Carlo Methods}\n\n\nWhile Q- and Sarsa-Learning update their estimates based on other estimates (from one step ahead), Monte Carlo methods only use actual rewards for the update. This way, initialisation of the estimates doesn't matter that much, so it is more robust. In particular, the update rule in a simple Monte Carlo method is\n\n\\begin{equation} \\label{eq:monte-carloUpdate}\nQ(s_t,a_t) \\longrightarrow Q(s_t,a_t) + \\alpha[G_t - Q(s_t,a_t)]\n\\end{equation}\n\nThe problem with this approach is slow training. The reason is partly that if any exploration action (the case with probability $\\epsilon$) is taken after timestep $t$, then, $Q(s_t,a_t)$ cannot be updated, since the new estimate doesn't necessarily reflect the estimated optimal value. Overall, Monte Carlo methods are rarely used in practice but they can be combined with Q-Learning (see e.g. the recent~\\cite{wang2018montecarloqlearning}), which is an option I do not consider any further.\n\n\\paragraph{Policy Gradient}\n\nPolicy gradient methods are in contrast with the methods outlined above because they do not learn state- or action-value functions, instead they directly learn an optimal (stochastic) policy. Briefly, these algorithms use (another) neural network that represents the policy, and therefore returns probabilities choosing a given action in a given state. This leads to using the outputs of the neural network directly while playing the games during training, not the $\\epsilon$-greedy technique. An advantage of this method is that there is no sharp boundary between the currently best estimated action and the second best, unlike for $\\epsilon$-greedy. \\NOTE{A}{Maybe add an equation. The problem is that it is a bit out of nowhere without derivation, and the derivation is a bit long.}\n\n\n\nFrom the several policy gradient related approaches, I implemented the so-called Actor-Critic method~\\cite{grondman2012actorcritic} and it didn't provide superior results to Deep Q-Learning or Sarsa-Learning. As explained in~\\cite{bhandari2019policygradientconvergence}, policy gradient methods might converge to a local maximum, not the global optimum policy, and they might requires more time to converge. Policy gradient methods are still an active area of research, and while their usecase in unknown environments with state aliasing (where a stochastic strategy is desired) is clear, they are not yet the most widely used in full-knowledge scenarios like ours (i.e.\\ where the exact current state is known).", "meta": {"hexsha": "d08a68c77f30f662631ebfe3f66d3933aa0e8240", "size": 3614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "dissertation/Appendix3/appendix3.tex", "max_stars_repo_name": "varikakasandor/dissertation-balls-into-bins", "max_stars_repo_head_hexsha": "fba69dd5ffd0b4984795c9a5ec119bf8c6f47d9e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dissertation/Appendix3/appendix3.tex", "max_issues_repo_name": "varikakasandor/dissertation-balls-into-bins", "max_issues_repo_head_hexsha": "fba69dd5ffd0b4984795c9a5ec119bf8c6f47d9e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dissertation/Appendix3/appendix3.tex", "max_forks_repo_name": "varikakasandor/dissertation-balls-into-bins", "max_forks_repo_head_hexsha": "fba69dd5ffd0b4984795c9a5ec119bf8c6f47d9e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 106.2941176471, "max_line_length": 785, "alphanum_fraction": 0.7899833979, "num_tokens": 840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.40350184350272356}}
{"text": "% !TeX spellcheck = en_US\n% !TeX root = DynELA.tex\n%\n% LaTeX source file of DynELA FEM Code\n%\n% (c) by Olivier Pantalé 2020\n%\n%\\selectlanguage{french}%\n\n\\chapter*{Notations\\addcontentsline{toc}{chapter}{Notations}\\markboth{Notations}{Notations}}\n\n\\LETTRINE{F}rom a general point of view, it is usual to observe that one of the main difficulties in the field of mechanics, as in other fields, is the non-homogeneity of notations between the various authors. It is then easy to make completely incomprehensible the slightest theory when one decides to change notation. As the notion of universal notation is not yet valid (even if certain conventions can be assimilated to universal concepts), then we present below the set of notations used throughout this document and in a broader way in all the other documents in that series.\n\n\\subsection*{Notations Conventions \\vspace{-1ex}}\n\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$a$ & Scalar\\tabularnewline\n$\\overrightarrow{a}$ & Vector\\tabularnewline\n$\\A$ & $2^{nd}$ order Tensor or matrix\\tabularnewline\n$\\IiA$ & $3^{rd}$ order Tensor\\tabularnewline\n$\\IIA$ & $4^{th}$ order Tensor\\tabularnewline\n\\end{longtable}\n\n\\subsection*{Linear Algebra and Mathematical Operators \\vspace{-1ex}}\n\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$\\overrightarrow{a}\\cdot\\overrightarrow{b}$ & Dot product of the vectors $\\overrightarrow{a}$ and $\\overrightarrow{b}$\\tabularnewline\n$\\overrightarrow{a}\\otimes\\overrightarrow{b}$ & Tensor (or Dyadic) product of the vectors $\\overrightarrow{a}$ and $\\overrightarrow{b}$\\tabularnewline\n$\\overrightarrow{a}\\wedge\\overrightarrow{b}$ & Vectorial product of the vectors $\\overrightarrow{a}$ and $\\overrightarrow{b}$\\tabularnewline\n$\\A:\\B$ & Double contracted product of the two tensors $\\A$ et $\\B$\\tabularnewline\n$\\stackrel{\\bullet}{\\boxempty}$ & Time derivative of quantity $\\boxempty$\\tabularnewline\n$\\stackrel{\\bullet\\bullet}{\\boxempty}$ & Second order time derivative of quantity $\\boxempty$\\tabularnewline\n$\\boxempty_{,\\boxempty}$ & Partial derivative of quantity $\\boxempty$ with respect to $_{\\boxempty}$\\tabularnewline\n$\\boxempty^{T}$ & Transpose of a matrix or a vector $\\boxempty$\\tabularnewline\n$\\tr\\,\\boxempty$ & Trace of a matrix or a tensor $\\boxempty$ ($\\tr\\,\\boxempty=\\sum\\boxempty_{ii}$)\\tabularnewline\n$\\dev\\,\\boxempty$ & Deviatoric part of a tensor $\\boxempty$ ($\\dev\\,\\boxempty=\\boxempty-\\frac{1}{3}\\tr\\,\\boxempty \\Id$)\\tabularnewline\n$\\delta_{ij}$ & Kronecker delta identity\\tabularnewline\n$\\Id$ & Unity matrix or second order tensor\\tabularnewline\n$\\IId$ & Unity fourth order tensor\\tabularnewline\n\\end{longtable}\n\n\\subsection*{Basic Continuum Mechanics\\vspace{-1ex}}\n\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$\\overrightarrow{x}=\\left[\\begin{array}{ccc}\nx & y & z\\end{array}\\right]^{T}$ & Coordinates in the physical domain\\tabularnewline\n$\\overrightarrow{u}=\\left[\\begin{array}{ccc}\nu & v & w\\end{array}\\right]^{T}$ & Displacement field\\tabularnewline\n$\\overrightarrow{\\omega}=\\left[\\begin{array}{ccc}\n\\omega_{x} & \\omega_{y} & \\omega_{z}\\end{array}\\right]^{T}$ & Rotation field\\tabularnewline\n$\\Om$ & Arbitrary body in the current configuration\\tabularnewline\n$\\Gam$ & Boundary of an arbitrary body $\\Om$ in the current configuration\\tabularnewline\n$\\rho$ & Material density\\tabularnewline\n$E$ & Young's modulus of a material\\tabularnewline\n$\\nu$ & Poisson's ratio of a material\\tabularnewline\n$K$ & Bulk modulus of a material\\tabularnewline\n$\\lambda$ & Lamé's first parameter of a material\\tabularnewline\n$\\mu=G$ & Lamé's second parameter / Coulomb's shear modulus\\tabularnewline\n$\\overrightarrow{F}$ & External load vector\\tabularnewline\n$\\overrightarrow{f}$ & External load vector\\tabularnewline\n$\\Eps$ & Green-Lagrange strain tensor\\tabularnewline\n$\\Sig$ & Cauchy stress tensor\\tabularnewline\n$\\Dev$ & Deviatoric part of the Cauchy stress tensor\\tabularnewline\n$\\Alp$ & Backstress tensor\\tabularnewline\n$\\Fi$ & $\\Fi=\\Dev-\\Alp$\\tabularnewline\n\\end{longtable}\n\n\\subsection*{Constitutive laws\\vspace{-1ex}}\n\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$f$ & \\tabularnewline\n$\\n$ & Direction of the plastic flow\\tabularnewline\n$\\q$ & Heredity variables in an elastoplastic behavior\\tabularnewline\n$\\overline{\\sigma}$ & von Mises equivalent stress\\tabularnewline\n$\\overline{\\varepsilon}^{p}$ & Equivalent plastic strain\\tabularnewline\n$\\stackrel{\\bullet}{\\overline{\\varepsilon}^{p}}$ & Equivalent plastic strain rate\\tabularnewline\n$\\Lambda$ & Norm of the plastic strain\\tabularnewline\n$\\sigma^{v}$ & \\tabularnewline\n$\\sigma_{0}^{v}$ & \\tabularnewline\n$\\sigma_{\\infty}^{v}$ & \\tabularnewline\n\\end{longtable}\n\n\\subsection*{Large Deformations\\vspace{-1ex}}\n\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$\\overrightarrow{X}=\\left[\\begin{array}{ccc}\nX & Y & Z\\end{array}\\right]^{T}$ & Coordinates in the reference domain\\tabularnewline\n$\\E$ & Green-Lagrange deformation tensor\\tabularnewline\n$\\F$ & Deformation gradient tensor\\tabularnewline\n$\\U,\\ \\V$ & Right and left pure deformation tensors\\tabularnewline\n$\\R$ & Rotation tensor\\tabularnewline\n$\\iL$ & Deformation speed tensor\\tabularnewline\n$\\D$ &Symmetric part of the $\\iL$ tensor\\tabularnewline\n$\\W$ & Skew-symmetric part of the $\\iL$ tensor\\tabularnewline\n\\end{longtable}\n\n\\subsection*{Finite Element Data Structures\\vspace{-1ex}}\n\\begin{flushleft}\n\\begin{longtable}[l]{>{\\raggedright}p{0.2\\paperwidth}>{\\raggedright}p{0.8\\paperwidth}}\n$\\N$ &Shape functions matrix\\tabularnewline\n$\\overrightarrow{\\xi}=\\left[\\begin{array}{ccc}\n\\xi & \\eta & \\zeta\\end{array}\\right]^{T}$ & Coordinates in the parent domain\\tabularnewline\n$\\B$ & Derivatives of the shape functions\\tabularnewline\n$\\boxempty^{e}$ & Quantity $\\boxempty$ related to element $e$\\tabularnewline\n$\\J$ & Jacobian matrix\\tabularnewline\n$\\M$ & Mass matrix\\tabularnewline\n$\\K$ & Stiffness matrix\\tabularnewline\n$\\overline{\\F}$ & External surfacic load vector\\tabularnewline\n$\\F$ & External load vector\\tabularnewline\n$\\overline{\\f}$ & External volumic load vector\\tabularnewline\n$\\q$ & Nodal unknowns vector\\tabularnewline\n$n_{g}$ & Number of nodes of the current element\\tabularnewline\n$n_{Q}$ & Number of integration points of the current element\\tabularnewline\n\\end{longtable}\n\\par\\end{flushleft}\n\n", "meta": {"hexsha": "cc798e9dd758ebd7a7788de27cd01bd05ff1dea2", "size": 6420, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/NotationsMec.tex", "max_stars_repo_name": "pantale/DynELA", "max_stars_repo_head_hexsha": "f346c0888059784c3f56b853e8593b71fc3dd708", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-12-13T14:12:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-21T18:27:39.000Z", "max_issues_repo_path": "Documentation/NotationsMec.tex", "max_issues_repo_name": "pantale/DynELA", "max_issues_repo_head_hexsha": "f346c0888059784c3f56b853e8593b71fc3dd708", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-28T16:54:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-28T16:54:58.000Z", "max_forks_repo_path": "Documentation/NotationsMec.tex", "max_forks_repo_name": "pantale/DynELA-v3.0", "max_forks_repo_head_hexsha": "f346c0888059784c3f56b853e8593b71fc3dd708", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-03-15T07:13:28.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-28T16:46:26.000Z", "avg_line_length": 54.8717948718, "max_line_length": 581, "alphanum_fraction": 0.753271028, "num_tokens": 1921, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.40350184350272356}}
{"text": "\\documentclass[english]{../thermomemo/thermomemo}\n\n\\usepackage{amsmath, amsthm, amssymb}\n\\usepackage[T1]{fontenc}\n\\usepackage{graphicx}\n\\usepackage{mathtools}\n\\usepackage[utf8]{inputenc}\n\\usepackage{pgf}\n\\usepackage{tikz}\n\\usepackage{url}\n\\usepackage{enumerate}\n\\usepackage[font=small,labelfont=bf]{caption}\n% For appendices\n\\usepackage[toc,page]{appendix}\n\\usepackage{xcolor}\n\\hypersetup{\n  colorlinks,\n  linkcolor={red!50!black},\n  citecolor={blue!50!black},\n  urlcolor={blue!80!black}\n}\n\n\\title{Implementing MBWR and SPUNG equations of state in ThermoPack}\n\\author{Ailo Aasen}\n\n% Package options\n\\usetikzlibrary{arrows,automata,decorations.markings,positioning}\n\n\\newcommand{\\map}[3]{ #1 : #2 \\to #3 }\n\\newcommand{\\ip}[2]{\\left\\langle #1,\\, #2 \\right\\rangle }\n\\newcommand{\\norm}[1]{ \\left\\|{ #1 }\\right\\| }\n\\newcommand{\\R}[0]{ \\mathbb{R} }\n\\newcommand{\\Q}[0]{ \\mathbb{Q} }\n\\newcommand{\\Z}[0]{ \\mathbb{Z} }\n\\newcommand{\\N}[0]{ \\mathbb{N} }\n\\newcommand{\\C}[0]{ \\mathbb{C} }\n\\newcommand{\\unitcircle}[0]{ \\mathbb{S} }\n\\newcommand{\\T}[0]{ \\mathbb{T} }\n\\newcommand{\\dd}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand{\\mbn}[0]{\\mathbf n}\n\n\\newcommand*{\\pd}[2]{\\frac{\\partial #1}{\\partial #2}}\n\\newcommand*{\\pdd}[2]{\\frac{\\partial^2 #1}{\\partial #2^2}}\n\\newcommand*{\\pder}[2]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)}\n\\newcommand*{\\pdder}[2]{\\left(\\frac{\\partial^2 #1}{\\partial #2^2}\\right)}\n\\newcommand*{\\pdersub}[3]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)_{#3}}\n\\newcommand*{\\pddersub}[3]{\\left(\\frac{\\partial^2 #1}{\\partial #2^2}\\right)_{#3}}\n\\newcommand*{\\pdcross}[3]{\\left(\\frac{\\partial^2 #1}{\\partial #2 \\partial #3}\\right)}\n\\newcommand*{\\pdcrosssub}[4]{\\left(\\frac{\\partial^2 #1}{\\partial #2 \\partial #3}\\right)_{#4}}\n\n\\newcommand*{\\hF}[0]{\\hat F}\n\\newcommand*{\\hH}[0]{\\hat H}\n\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\mcE}{ \\mathcal{E}}\n\\newcommand{\\mcF}{ \\mathcal{F}}\n\\newcommand{\\mcO}{ \\mathcal{O}}\n\\newcommand{\\mcU}{ \\mathcal{U}}\n\\newcommand{\\mcT}{ \\mathcal{T}}\n\\newcommand{\\mcL}{ \\mathcal{L}}\n\\newcommand{\\mcS}{ \\mathcal{S}}\n\n\\newcommand{\\paran}[1]{\\left( #1 \\right)}\n\\newcommand{\\lp}{\\left(}\n  \\newcommand{\\rp}{\\right)}\n\n\\newcommand{\\dive}{\\nabla \\cdot}\n\\newcommand{\\curl}{\\nabla \\times}\n\n\\newcommand{\\sgn}{\\operatorname{sgn}}\n\\newcommand{\\sech}{\\operatorname{sech}}\n\\newcommand{\\cn}{\\operatorname{cn}}\n\\newcommand{\\clos}{\\operatorname{clos}}\n\\newcommand{\\id}{\\operatorname{id}}\n\\newcommand{\\ran}{\\operatorname{ran}}\n% \\newcommand{\\dim}{\\operatorname{dim}}\n\\newcommand{\\codim}{\\operatorname{codim}}\n\n\n% Number results section-wise\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{defn}[thm]{Definition}\n\\newtheorem{cor}[thm]{Corollary}\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\n% Number equations section-wise\n\\numberwithin{equation}{section}\n\n% Misc\n\\newtheorem{definition}{Definition}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{case}{Case}\n\\tikzset{->-/.style={decoration={markings,mark=at position #1 with {\\arrow{>}}},postaction={decorate}}}\n\n\\begin{document}\n\\frontmatter\n\\tableofcontents\n\n\\section{Introduction}\nThis memo documents the theory behind and ThermoPack-implementation of\nthe MBWR-19 and the MBWR-32 equations of state for pure fluids, as\nwell as their extension to mixtures via the SPUNG equation of\nstate. ThermoPack is a SINTEF Energy Research in-house thermodynamic library, and is\ndocumented in Skaugen et al. \\cite{ThermoPackDoc13}.\n\nMBWR-19 and MBWR-32 are single-component equations of\nstate, having respectively $19$ and $32$ parameters fitted\nto a specific substance. They are both examples of so-called\n\\textit{multiparameter equations of state}, and generally outperform\ncubic equations of state when it comes to accuracy, but lose to them\nin speed. MBWR-19 was first used by Bender (1970), and is also\nreferred to as the Bender equation. MBWR-32 is due to Jacobsen and\nStewart (1973), and is sometimes called the Jacobsen-Stewart equation,\nor simply \\textit{the MBWR equation}. The MBWR-19 and MBWR-32 have\nbeen fitted to a range of components.\n\nMBWR equations are often used as reference equations for so-called\n\\textit{Corresponding States} equations. The prevously implemented\nLee-Kesler equation of state, documented in Aarnes \\cite{Aarnes13}, is\none example. Another Corresponding States equation is the SPUNG\nequation. SPUNG stands for \\textit{State Research and Development\n  Program for Utilization of Natural Gas}, after the Norwegian state\nprogram which partly financed the equation's development, and is\ndocumented in J{\\o}rstad \\cite{Jorstad93}.\n\n\\subsection{How to implement equations of state in ThermoPack}\nThermoPack is a thermodynamics library which is documented in Skaugen et al.\n\\cite{ThermoPackDoc13}. The library has the convention of using $(T, P, \\mbn)$ as\nindependent variables. For an equation of state to be considered implemented\nin ThermoPack, the following is required: For each of the thermodynamic functions\n\\begin{itemize}\n\\item the compressibility $z$\n\\item the residual entropy $S^R$\n\\item the residual enthalpy $H^R$\n\\item the logarithmic fugacity coefficients $\\ln \\phi_i$\n\\end{itemize}\nthere should be routines which takes in temperature $T$, pressure $P$,\ncomposition $\\mbn$ and phase as input, and returns the values of these functions, as\nwell as the values of their first order partial derivatives when the independent\nvariables are $(T, P, \\mbn)$.\n\nIn addition, a routine for calculating the residual Gibbs energy $G^r$\nand its partial derivatives is usually desired.\n\nWhen it comes to units, ThermoPack mostly uses base SI-units, e.g K\nfor temperature and Pa for pressure. An important exception is\nmolar volume and density, which are measured in\n$\\mathrm{dm}^3/\\mathrm{mol}$ and $\\mathrm{mol}/\\mathrm{dm}^3$.\n\n\n\n\\section{Expressing thermodynamic functions using the reduced Helmholtz energy}\n\n\\subsection{Residual properties}\nAn arbitrary temperature-volume-composition state $(T,V,\\mbn)$ can be reached by mixing\nthe pure fluids at temperature $T_0$ and approximately zero density and\npressure, heating the mixture to the temperature $T$ and then\ncompressing it to the volume $V$. It follows that the calculation of\nan arbitrary thermodynamic property $M(T,V,\\mbn)$ can be split up\naccording to\n\\begin{equation}\n  \\label{M_TVN}\n  M = (\\Delta M^\\star)_{\\text{mixing}} + \\int_{T_0}^T \\lp\n  \\frac{\\partial M^\\star}{\\partial T} \\rp_{V=\\infty,\\mbn} dT +\n  \\int_{\\infty}^V \\lp \\frac{\\partial M}{\\partial V} \\rp_{T,\\mbn} dV\n\\end{equation}\nwhere $M^\\star$ denotes the property at zero density and pressure, and $(\\Delta M^\\star)_{\\text{mixing}}$ denotes the property due to\nmixing at zero density and pressure.\n\nIf instead $(T,P,\\mbn)$ are used as independent variables, the\nequivalent of \\eqref{M_TVN} is\n\\begin{equation}\n  \\label{M_TPN}\n  M = \\Delta M^\\star + \\int_{T_0}^T \\lp \\frac{\\partial M^\\star}{\\partial\n    T} \\rp_{P=0,\\mbn} dT + \\int_{0}^P \\lp \\frac{\\partial M}{\\partial P}\n  \\rp_{T,\\mbn} dP.\n\\end{equation}\nThe right-hand sides of \\eqref{M_TVN} and \\eqref{M_TPN} can be\nrearranged to comprise two terms, one which is the property $M^\\star$\nof the hypothetical perfect gas at the state $(T,V,\\mbn)$ or\n$(T,P,\\mbn)$ over some fixed, chosen zero, and a second term $M^R = M\n- M^\\star$, called the residual. From its definition $M^R = M -\nM^\\star$, we see that the residual $M^R$ must be defined as\n\\begin{equation}\n  \\label{eq:ResDef}\n  \\begin{aligned}\n    M^R(T,V,\\mbn) &= \\int_\\infty^V \\left[ \\lp \\dd{M}{V_1} \\rp_{T,\\mbn} -\n      \\lp \\dd{M^\\star}{V_1} \\rp_{T,\\mbn} \\right] dV_1, \\\\\n    M^R(T,P,\\mbn) &= \\int_0^P \\left[ \\lp \\dd{M}{P_1} \\rp_{T,\\mbn} - \\lp\n      \\dd{M^\\star}{P_1} \\rp_{T,\\mbn} \\right] dP_1.\n  \\end{aligned}\n\\end{equation}\nBeware that in general we have $M^R(T,V,\\mbn) \\neq\nM^R(T,P,\\mbn)$. This may seem strange since the value of a\nthermodynamic property shouldn't depend on which coordinates one\nhappens to use; for example it is of course always true that\n$M(T,P,\\mbn) = M(T,V,\\mbn)$. The reason this equality does not hold\nfor residual properties is that having temperature, volume and\ncomposition $(T,V,\\mbn)$ as a perfect gas state, is not the same the\nsame perfect gas state as having temperature, pressure and composition\n$(T,P,\\mbn)$, because in general $PV \\neq nRT$, and thus $M^\\star(T,V,\\mbn) \\neq\nM^\\star(T,P,\\mbn)$\n\n\\subsection{Relating thermodynamic functions functions to $F$}\nLet\n$$\nA = -PV + \\sum \\mu_i n_i\n$$\ndenote the Helmholtz energy of an arbitrary fluid. We have $dA =\n-SdT-PdV + \\sum_i \\mu_i dn_i$, and the natural variables for $A$ are\n$T, V, \\mbn$, all of which are accessible variables (in contrast to\ne.g. entropy). Let as above $A^R$ denote the residual Helmholtz\nenergy. Then from \\eqref{eq:ResDef} we see that\n\\begin{equation}\n  \\label{eq:1}\n  A^R(T,V,\\mbn) = \\int_\\infty^V \\lp -P(T,V_1,\\mbn) + nRT/V_1 \\rp dV_1.\n\\end{equation}\n\nA quantity of prime importance is the \\textit{reduced} residual\nHelmholtz energy, defined as\n\\begin{equation}\n  \\label{eq:Fdef}\n  F(T,V,\\mbn) = \\frac{A^R(T,V,\\mbn)}{RT}\n\\end{equation}\nIn modern thermodynamic engineering, equations of state are usually\nformulated as an expression for $F$ as a function of temperature and\nvolume. Note that $F$ is written as a function of $(T,V,\\mbn)$, and\nindeed explicit functional expressions for $F$ are usually only\nobtainable in these variables. Thus if one wants to compute $F$ from\nknowledge only of $(T,P,\\mbn)$, one first has to compute $V$. For all\nbut the simplest equations of state (like e.g. cubic equations), this has\nto be done using an iterative solver, and can be a time-consuming part\nof the program. See also section \\ref{sec:density}.\n\nWhen we are dealing with pure fluids, which after all is the setting\nof the MBWR equations, we have $\\mbn = n$, where $n$ is the total\nnumber of moles of the pure fluid, and it is more convenient to\nconsider extensive properties such as $F$ on a per mole (molar)\nbasis. In this setting it is natural to use density $\\rho = n/V$ as a\nvariable (or alternatively, molar volume $v = 1/\\rho$). Indeed, the MBWR\nequations are usually formulated as equations for the pressure $P =\nP(T,\\rho)$. They are easily converted -- using \\eqref{eq:Fdef} -- to\nan equation for the molar Helmholtz energy $\\alpha$ as a function of\n$(T,\\rho)$, where $\\alpha$ is defined as:\n\\begin{align}\n  \\alpha(T,\\rho) &= \\frac{A^R(T,n/\\rho,n)}{nRT} \\\\\n  &= \\frac{F(T,n/\\rho,n)}{n},\n\\end{align}\nwhere the functions on the right hand sides are the ones in equation\n\\eqref{eq:Fdef}. Note that $F$ has units $\\mathrm{mol}$, while\n$\\alpha$ is adimensional.\n% Seeing as the right side expressions in is independent of $n$, one\n% usually thinks of $n$ as being $1$.\n\nIf one has an equation for $F$, it turns out that all thermodynamic\nproperties can be computed from $F$ and its partial\nderivatives. Below, the thermodynamic functions needed in ThermoPack, together with their first\norder partials, are given in terms of $F$ and its first and second\norder partial derivatives.\n\n\\subsubsection*{Compressibility factor}\n\\noindent\nThe compressibility factor $z$ is a dimensionless number which can be\nwritten in several equivalent forms:\n\\begin{equation}\n  \\label{eq:zDef}\n  z = \\frac{PV}{nRT} = \\frac{Pv}{RT} = \\frac{P}{\\rho RT}  = \\frac{v}{v_{ig}}\n\\end{equation}\nIn the equation \\eqref{eq:zDef} $v = V /n$ is the specific molar\nvolume, $\\rho = 1/v$ is the molar density, $v_{ig}$ is the specific\nvolume of an ideal gas, $R$ is the universal gas constant, and $P$,\n$V$, $T$ and $n$ are pressure, volume, temperature and total number of\nmoles of the fluid, respectively. For ideal gases $z=1$ for all $T$\nand $P$ and $n$, wheras for real gases $z$ is a non-constant function\nof $T$ and $P$ and $n$.\n\n\\subsubsection*{Residual entropy}\n\\begin{equation}\n  \\label{eq:Sres}\n  S^R(T,P,n) = nR \\ln z - RF - RT \\lp \\dd{F}{T} \\rp_{V,n}. % Double-checked\n\\end{equation}\n\n\\subsubsection*{Residual enthalpy}\n\\begin{equation}\n  \\label{eq:Hreduced}\n  H^R(T,P,n) = -RT^2 \\lp \\dd{F}{T} \\rp_{V,n} + PV - nRT, % Double-checked\n\\end{equation}\n\n\\subsubsection*{Logarithmic fugacity coefficent}\n\\begin{equation}\n  \\label{eq:lnphireduced}\n  \\ln \\phi_i(T,P,n) = \\lp \\dd{F}{n_i} \\rp_{T,V} - \\ln z. % Double-checked\n\\end{equation}\n\n\\subsection{Partial derivatives of the thermodynamic properties}\nThe following formulas are mostly taken directly from Aarnes\n\\cite{Aarnes13}.\n\\subsubsection*{Pressure}\nTo simplify the notation in the following derivatives, a relation\nbetween the pressure and its derivatives, and the reduced residual\nHelmholtz function is introduced.\n\n\\begin{equation}\n  \\label{def:P}\n  P(T,V,\\textbf{n}) = -RT \\left( \\frac{\\partial F}{\\partial V} \\right)_{T, \\textbf{n}} + \\frac{nRT}{V}\n\\end{equation}\n\nThe partial derivatives of the pressure, with respect to temperature,\nvolume and composition, respectively, are given by:\n\\begin{align}\n  \\label{eq:P_T}\n  & \\pder{P}{T}_{V, \\textbf{n}} = \\frac{P}{T} - RT \\pdcross{F}{T}{V}_{n_i} \\\\\n  \\label{eq:P_V}\n  & \\pder{P}{V}_{T, \\textbf{n}} = -RT \\pdder{F}{V}_{T, \\textbf{n}} - \\frac{nRT}{V^2} \\\\\n  \\label{eq:P_i}\n  & \\pder{P}{n_i}_{T,V} = -RT \\pdcross{F}{n_i}{V}_T + \\frac{RT}{V}\n\\end{align}\n\nFurthermore, the partial derivatives of the volume with respect to\ncomposition and temperature are defined, by the use of the triple\nproduct rule and the derivatives of the pressure:\n\\begin{align}\n  \\label{def:V_i}\n  \\bar{V}_i \\equiv \\pder{V}{n_i}_{T,P} =  - \\frac{\\pder{P}{n_i}_{T,V}}{\\pder{P}{V}_{T,\\textbf{n}}} \\\\\n  \\label{def:V_T}\n  \\bar{V}_T \\equiv \\pder{V}{T}_{P,\\textbf{n}} = -\n  \\frac{\\pder{P}{T}_{V,\\textbf{n}}}{\\pder{P}{V}_{T,\\textbf{n}}}\n\\end{align}\n\nThe following derivatives are all carried out for functions that are\n$(T,P,\\textbf{n})$-states, that is $z = z(T,P,\\textbf{n})$, $S^R =\nS^R(T,P,\\textbf{n})$, $H^R = H^R(T,P,\\textbf{n})$ and $\\ln \\phi_i =\n\\ln \\phi_i(T,P,\\textbf{n})$. Several of these calculations get rather\ninvolved, and only the resulting expressions are presented here.\n\n\\subsubsection*{Compressibility}\n\\begin{align}\n  \\label{eq:z_T}\n  & \\left( \\frac{\\partial z}{\\partial T} \\right)_{P, \\textbf{n}} = -z\\left[\\frac{1}{T} - \\frac{\\bar{V}_T}{V}\\right] \\\\\n  \\label{eq:z_P}\n  & \\left( \\frac{\\partial z}{\\partial P} \\right)_{T, \\textbf{n}} = z \\left[ \\frac{1}{P} + \\frac{1}{V \\pder{P}{V}_{T,\\textbf{n}}} \\right] \\\\\n  \\label{eq:z_i}\n  & \\left( \\frac{\\partial z}{\\partial n_i} \\right)_{T,P} = - z \\left[\n    \\frac{1}{n} - \\frac{\\bar{V}_i}{V} \\right]\n\\end{align}\n\n\\subsubsection*{Entropy}\n\\begin{align}\n  \\label{eq:S^R_T}\n  & \\pder{S^R(T,P,\\textbf{n})}{T}_{P,\\textbf{n}} = \\bar{V}_T \\pder{P}{T}_{V,\\textbf{n}} - R \\left[2\\pder{F}{T}_{V,\\textbf{n}} + T \\pdder{F}{T}_{V,\\textbf{n}} + \\frac{n}{T} \\right] \\\\\n  \\label{eq:S^R_P}\n  & \\pder{S^R(T,P,\\textbf{n})}{P}_{T,\\textbf{n}} = \\frac{nR}{P} - \\bar{V}_T \\\\\n  \\label{eq:S^R_i}\n  & \\pder{S^R(T,P,\\textbf{n})}{n_i}_{T,P} = \\bar{V}_i\n  \\pder{P}{T}_{V,\\textbf{n}} - R\\left[ \\pder{F}{n_i}_{T,V} +\n    T\\pdcross{F}{T}{n_i}_V + 1 - \\ln z \\right]\n\\end{align}\n\n\\subsubsection*{Enthalpy}\n\\begin{align}\n  \\label{eq:H^R_T}\n  & \\pder{H^R}{T}_{P, \\textbf{n}} = \\bar{V}_T T \\pder{P}{T}_{V,\\textbf{n}} - RT \\left[ 2\\pder{F}{T}_{V,\\textbf{n}} + T \\pdder{F}{T}_{V,\\textbf{n}} + \\frac{n}{T} \\right] \\\\\n  \\label{eq:H^R_P}\n  & \\pder{H^R}{P}_{T, \\textbf{n}} = V - T \\bar{V}_T \\\\\n  \\label{eq:H^R_i}\n  & \\pder{H^R}{n_i}_{T,P} = \\bar{V}_i T \\pder{P}{T}_{V,\\textbf{n}}\n  -RT^2 \\pdcross{F}{T}{n_i}_V - RT\n\\end{align}\n\n\\subsubsection*{Fugacity coefficients}\n\\begin{align}\n  \\label{eq:lnphi_T}\n  & \\pder{\\ln \\phi_i}{T}_{P, \\textbf{n}} = \\pdcross{F}{T}{n_i}_V + \\frac{1}{T} - \\frac{\\bar{V}_i}{RT}  \\pder{P}{T}_{V,\\textbf{n}} \\\\\n  \\label{eq:lnphi_P}\n  & \\pder{\\ln \\phi_i}{P}_{T, \\textbf{n}} = \\frac{\\bar{V}_i}{RT} - \\frac{1}{P} \\\\\n  \\label{eq:lnphi_i}\n  & \\pder{\\ln \\phi_i}{n_j}_{T, P} = \\pdcross{F}{n_j}{n_i}_{T,V} +\n  \\frac{1}{n} + \\frac{\\pder{P}{V}_{T,\\textbf{n}}}{RT} \\bar{V}_j\n  \\bar{V}_i\n\\end{align}\n\n\\subsubsection*{Gibbs energy}\nResidual Gibbs energy is not documented in Aarnes \\cite{Aarnes13} and\nis therefore documented here. From Michelsen \\cite{Michelsen07} we\nhave\n$$\nG^R(T,P,\\mbn) = RT F(T,V,\\mbn) + PV - nRT(1 + \\ln z),\n$$\nwhence\n\\begin{align}\n  % \\label{eq:}\n  % & \\pder{G^R}{T}_{P, \\textbf{n}} = R \\lp F + T\n  % \\pdersub{F}{T}{V,\\mbn} + T \\pdersub{F}{V}{T,\\mbn} \\bar{V}_T\n  % -n(1+\\ln z) \\rp + \\lp P - \\frac{nRT}{V} \\rp \\bar{V}_T \\\\\n  % & \\pder{G^R}{T}_{P, \\textbf{n}} = R \\lp F + T\n  % \\pdersub{F}{T}{V,\\mbn} + T \\pdersub{F}{V}{T,\\mbn} \\bar{V}_T + P\n  % \\rp \\\\\n  & \\pder{G^R}{T}_{P, \\textbf{n}} = R \\lp F + T \\pdersub{F}{T}{V,\\mbn} - n \\ln z \\rp + \\lp P - P/z + RT \\pdersub{F}{V}{T,\\mbn} \\rp \\bar{V}_T \\\\\n  % & \\pder{G^R}{P}_{T, \\textbf{n}} = RT \\pdersub{F}{V}{T,\\mbn} \\bar\n  % V_P + P \\bar V_P + V - nRT \\lp \\frac{1}{P} + \\frac{\\bar V_P}{V}\n  % \\rp \\\\\n  & \\pder{G^R}{P}_{T, \\textbf{n}} = V - \\frac{nRT}{P} \\\\\n  % & \\pder{G^R}{n_i}_{T, P} = RT \\pdersub{F}{V}{T,\\mbn} \\bar V_i + P\n  % \\bar V_i + RT \\pdersub{F}{n_i}{T,P} - RT (1+\\ln z) + RT -\n  % \\frac{nRT}{V} \\bar V_i\n  & \\pder{G^R}{n_i}_{T, P} = RT \\lp \\pdersub{F}{n_i}{T,P} - \\ln z \\rp\n\\end{align}\n\n\\subsubsection*{Internal energy}\nResidual internal energy is not documented in Aarnes \\cite{Aarnes13} and\nis therefore documented here. We have\n$$\nU^R(T,P,\\mbn) = nRT \\ln z - RT^2 \\lp \\dd{F}{T} \\rp_{V,n}\n$$\nand thus\n\\begin{align}\n  & \\pder{U^R}{T}_{P, \\textbf{n}} = nR \\left[ \\ln z + \\frac{T \\bar\n      V_T}{V} -1 \\right] - RT\\lp 2 \\pder{F}{T}_{V,\\mbn} + T\\pdder{F}{T}_{V,\\mbn} \\rp \\\\\n  & \\pder{U^R}{P}_{T, \\textbf{n}} = nTR\\left[ \\frac{1}{P} + \\frac{1}{V\n      \\pder{P}{V}_{T,\\mbn}} \\right] - \\frac{RT^2\\pdcross{F}{T}{V}_\\mbn}{\\pder{P}{V}_{T,\\mbn}}\\\\\n  & \\pder{U^R}{n_i}_{T, P} = TR \\left[ \\ln z + \\frac{n\\bar V_i}{V}\n    -1\\right] - RT^2 \\pdcross{F}{T}{n_i}_V\n\\end{align}\n\n\\subsection{Relating $F$-derivatives to $\\alpha$-derivatives}\nIn the case of pure fluids, it is as mentioned more convenient to use\nthe function $\\alpha$ defined by\n\\begin{equation}\n  F(T,V,n) = n \\alpha(T, \\rho).\n\\end{equation}\nThis implies the following relations between the derivatives of $F$\nand the derivatives of $\\alpha$.\n\n\\subsubsection*{$T$-derivatives}\n\\begin{align}\n  \\label{eq:DFDT}\n  & \\pder{F}{T}_{V, n} = n \\pder{\\alpha}{T} \\\\\n  \\label{eq:D2FDT2}\n  & \\pdder{F}{T}_{V, n} = n \\pdder{\\alpha}{T}\n\\end{align}\n\n\\subsubsection*{$V$-derivatives}\n\\begin{align}\n  \\label{eq:DFDV}\n  & \\pder{F}{V}_{T, n} = -\\frac{n^2}{V^2} \\pder{\\alpha}{\\rho} \\\\\n  \\label{eq:D2FDV2}\n  & \\pdder{F}{V}_{T, n} = \\frac{2n^2}{V^3} \\pder{\\alpha}{\\rho} +\n  \\frac{n^3}{V^4} \\pdder{\\alpha}{\\rho}\n\\end{align}\n\n\\subsubsection*{$n$-derivatives}\n\\begin{align}\n  \\label{eq:DFDn}\n  & \\pder{F}{n}_{V, n} = \\alpha + \\frac{n}{V}\\pder{\\alpha}{\\rho} \\\\\n  \\label{eq:D2FDn2}\n  & \\pdder{F}{n}_{V, n} = \\frac{2}{V} \\pder{\\alpha}{\\rho} +\n  \\frac{n}{V^2} \\pdder{\\alpha}{\\rho}\n\\end{align}\n\n\\subsubsection*{Cross-derivatives}\n\\begin{align}\n  \\label{eq:D2FDTV}\n  & \\pdcross{F}{T}{V}_{V} = -\\frac{n^2}{V^2} \\pdcross{\\alpha}{T}{\\rho} \\\\\n  \\label{eq:D2FDTn}\n  & \\pdcross{F}{T}{n}_{V, n} = \\pder{\\alpha}{T} + \\frac{n}{V} \\pdcross{\\alpha}{T}{\\rho} \\\\\n  \\label{eq:D2FDVn}\n  & \\pdcross{F}{V}{n}_{V, n} = -\\frac{2n}{V^2} \\pder{\\alpha}{\\rho} -\n  \\frac{n^2}{V^3} \\pdder{\\alpha}{\\rho}\n\\end{align}\n\n\\section{The MBWR equations of state}\nBoth the MBWR-19 and the MBWR-32 equations of state take the general\nform\n\\begin{equation}\n  \\label{eq:MBWRform}\n  P(T,\\rho) = \\rho R T + \\sum_{k=1}^{I_{\\mathrm{pol}}} a_k T^{t_k} \\rho^{d_k} +\\sum_{k=I_{\\mathrm{pol}}+1}^{I_{\\mathrm{tot}}} a_k T^{t_k} \\rho^{d_k} \\exp \\lp -\\gamma \\rho^2 \\rp.\n\\end{equation}\nThe last sum on the right hand side of \\eqref{eq:MBWRform} side is referred\nto as the exponential part, and the rest is called the polynomial\npart%\n\\footnote{This is somewhat misleading, since not all the $t_k$ are\n  positive integers.}. %\nThe $d_k$ are positive integers and the $t_k$ are rational numbers,\nboth inherent to the equation of state. Their values are given in\nTable 1 for MBWR-19, and in Table 2\nfor MBWR-32. The parameters $a_1,\\ldots,a_{I_{\\mathrm{tot}}}$ are not\ninherent to the equation of state, but are substance-specific and thus have to be fitted to experimental measurements. For MBWR-19 and MBWR-32 we have\n$I_{\\mathrm{tot}}$ equal to $19$ and $32$, respectively. The\nparameter $\\gamma$ usually equals $1/\\rho_{c}^2$, but may have been\nfitted with something else. In any case, even though $\\gamma$ is\ncomponent dependent, it is not optimized in the fitting process, which\nis the reason it is not counted as a bona fide parameter. MBWR-19 is\nhowever only \\textit{our} choice of name, and other sources (e.g.\nJ{\\o}rstad \\cite{Jorstad93}) instead calls it MBWR-$20$.\n\nNote that, for both MBWR-19 and MBWR-32, all the density exponents $d_k$ are positive. This is not coincidental, but a necessity to make it have the desired asymptotic behavior\n$$\n\\lim_{\\rho \\to 0} P(T,\\rho) = 0.\n$$\n\nThe MBWR equations are sometimes written with terms grouped according\nto powers of $\\rho$:\n\\begin{equation}\n  \\label{eq:bpbeform}\n  P(T,\\rho) = \\sum_{i=1}^{BP_\\text{len}}BP_i(T) \\cdot \\rho^i\n  + \\exp(-\\gamma \\rho^2) \\sum_{i=1}^{BE_\\text{len}} BE_i(T) \\cdot \\rho^{2i+1}.\n\\end{equation}\nThis aggregation of the temperature dependents terms is sometimes\nconvenient, because one often wants to evaluate $P(T,\\rho)$ for the same $T$\nbut several different $\\rho$, the prime example being the iterative procedure in the density\nsolver, see section \\ref{sec:density}. In this case it is\ncomputationally efficient to pre-calculate the coefficients $BP_i(T)$\nand $BE_i(T)$.\n\n\\begin{table}\n  \\label{BenderTerms}\n  \\centering\n  \\begin{tabular}{c c c c | c c c c }\n    $k$\t\t& $d_k$\t\t& $t_k$\t\t& type\t\t & k\t\t& $d_k$\t\t& $t_k$\t\t& type\t\t   \\\\\n    \\hline\n    $1$\t\t& $2$       \t&$ 1$\t\t& pol              & $11$\t\t& $5$       \t&$ 1$\t\t&pol                 \\\\\n    $2$\t\t& $2$       \t&$ 0$\t\t&pol               & $12$\t\t& $5$       \t&$ 0$\t\t&pol                  \\\\\n    $3$\t\t& $2$       \t&$-1$\t\t&pol               & $13$\t\t& $6$       \t&$ 0$\t\t&pol                  \\\\\n    $4$\t\t& $2$       \t&$-2$ \t\t&pol               & $14$\t\t& $3$       \t&$ 0$\t\t& exp              \\\\\n    $5$\t\t& $2$       \t&$-3$ \t\t&pol               & $15$\t\t& $3$       \t&$-1$\t\t& exp              \\\\\n    $6$\t\t& $3$       \t&$ 1$\t\t&pol               & $16$\t\t& $3$       \t&$-2$\t\t& exp              \\\\\n    $7$\t\t& $3$       \t&$ 0$\t\t&pol               & $17$\t\t& $5$       \t&$ 0$\t\t& exp              \\\\\n    $8$\t\t& $3$       \t&$-1$\t\t&pol               & $18$\t\t& $5$       \t&$-1$\t\t& exp              \\\\\n    $9$\t\t& $4$       \t&$ 1$\t\t&pol               & $19$\t\t& $5$       \t&$-2$\t\t& exp              \\\\  \n    $10$\t& $4$       \t&$ 0$\t\t&pol               &               &               &               &\n  \\end{tabular}\n  \\caption{Overview of inherent parameters in the MBWR-$19$ model. $I_{\\mathrm{pol}}=13$, $I_{\\mathrm{tot}}=32$.}\n\\end{table}\n\n\\begin{table}\n  \\label{MBWR32Terms}\n  \\centering\n  \\begin{tabular}{c c c c | c c c c }\n    $k$\t\t        & $d_k$\t\t& $t_k$\t\t& type\t\t& k\t\t & $d_k$\t  & $t_k$\t    & type\t       \\\\\n    \\hline\n    $1$\t\t        & $2$       \t&$ 1$\t\t& pol           & $17$\t & $8$       \t  &$-1$\t\t    & pol              \\\\\n    $2$\t\t        & $2$       \t&$ 0.5$\t\t&pol            & $18$\t & $8$       \t  &$-2$\t\t    & pol              \\\\\n    $3$\t\t        & $2$       \t&$ 0$\t\t&pol            & $19$\t & $9$       \t  &$-2$\t\t    & pol              \\\\\n    $4$\t\t        & $2$       \t&$-1$ \t\t&pol            & $20$\t & $3$       \t  &$-2$\t\t    & exp              \\\\\n    $5$\t\t        & $2$       \t&$-2$ \t\t&pol            & $21$\t & $3$       \t  &$-3$\t\t    & exp              \\\\\n    $6$\t\t        & $3$       \t&$ 1$\t\t&pol            & $22$\t & $5$       \t  &$-2$\t\t    & exp              \\\\\n    $7$\t\t        & $3$       \t&$ 0$\t\t&pol            & $23$\t & $5$       \t  &$-4$\t\t    & exp              \\\\\n    $8$\t\t        & $3$       \t&$-1$\t\t&pol            & $24$\t & $7$       \t  &$-2$\t\t    & exp              \\\\\n    $9$\t\t        & $3$       \t&$-2$\t\t&pol            & $25$\t & $7$       \t  &$-3$\t\t    & exp              \\\\\n    $10$\t\t& $4$       \t&$ 1$\t\t&pol            & $26$\t & $9$        \t  &$-2$\t\t    & exp              \\\\\n    $11$\t\t& $4$       \t&$ 0$\t\t&pol            & $27$   & $9$            &$-4$             & exp              \\\\\n    $12$\t\t& $4$       \t&$-1$\t\t&pol            & $28$   & $11$           &$-2$             & exp              \\\\\n    $13$\t\t& $5$       \t&$ 0$\t\t&pol            & $29$   & $11$           &$-3$             & exp              \\\\\n    $14$\t\t& $6$       \t&$-1$\t\t&pol            & $30$   & $13$           &$-2$             & exp              \\\\\n    $15$\t\t& $6$       \t&$-2$\t\t&pol            & $31$   & $13$           &$-3$             & exp              \\\\\n    $16$\t\t& $7$       \t&$-1$\t\t&pol            & $32$   & $13$           &$-4$             & exp              \n  \\end{tabular}\n  \\caption{Overview of inherent parameters in the MBWR-$32$ model. $I_{\\mathrm{pol}}=19$, $I_{\\mathrm{tot}}=32$.}\n\\end{table}\n\n% \\section{Implementation}\n% The component dependent correlated parameters have been fetched from\n% the tplib library, more precisely the text file\n% \\textit{corr.inp}. Instead of reading the parameters from a text\n% file each time an MBWR model is initiated, all the parameters are\n% stored in a compiled module. Since the number of component models\n% was relatively small ($63$ models for MBWR-32 and MBWR-19 combined),\n% the parameter data was copied manually into the code, where it\n% initialises a Fortran TYPE holding the data.\n% \n% It is wise to precalculate the temperature dependent coefficients\n% early on, and don't calculate them again and again. This is done in\n% MBWR_coef\n\n\\section{Database for the MBWR substance-specific parameters}\nThe correlated values of $a_k$ for various substances are stored in\nthe file \\textit{tpmbwrdata.f90}, and have been retrieved from the old\nTPlib thermodynamics library. In the current database $9$ substances\nhave correlations for MBWR-32, while $54$ substances have\ncorrelations for MBWR-19.\n\nIt is important to understand exactly what these coefficients in the\ndatabase mean. Let us first consider the MBWR-32 equation. For\nMBWR-32, each correlation in the database consists of 33 coefficients\n$(a_1,\\ldots,a_{32},\\gamma)$, which fit into the equation as follows (see\nJ{\\o}rstad \\cite{Jorstad93}):\n\\begin{align*}\n  P(T,\\rho) = \\sum_{i=1}^{19} BP_i \\cdot \\rho^i + e^{-\\gamma \\rho^2}\n  \\sum_{i=1}^{6} BE_i \\cdot \\rho^{2i+1}.\n\\end{align*}\nwhere\n\\begin{equation}\n  \\label{eq:BPBE_MBWR32}\n  \\begin{aligned}\n    BP_1 &= RT \\\\\n    BP_2 &= a_1T+a_2T^{1/2}+a_3+a_4/T+a_5/T^2 \\\\\n    BP_3 &= a_6T+a_7+a_8/T+a_9/T^2 \\\\\n    BP_4 &= a_{10}T+a_{11}+a_{12}/T \\\\\n    BP_5 &= a_{13} \\\\\n    BP_6 &= a_{14}/T+a_{15}/T^2 \\\\\n    BP_7 &= a_{16}/T \\\\\n    BP_8 &= a_{17}/T+a_{18}/T^2 \\\\\n    BP_9 &= a_{19}/T^2 \\\\\n    BE_1 &= a_{20}/T^2+a_{21}/T^3 \\\\\n    BE_2 &= a_{22}/T^2+a_{23}/T^4 \\\\\n    BE_3 &= a_{24}/T^2+a_{25}/T^3 \\\\\n    BE_4 &= a_{26}/T^2+a_{27}/T^4 \\\\\n    BE_5 &= a_{28}/T^2+a_{29}/T^3 \\\\\n    BE_6 &= a_{30}/T^2+a_{31}/T^3 + a_{32}/T^4.\n  \\end{aligned}\n\\end{equation}\nHere $P$ is measured in Pascal, $T$ is\nmeasured in Kelvin and $\\rho$ is measured in moles per litre -- the\nconvention in ThermoPack.\n\n\nLet us next consider the MBWR-19 equation. In the database each\nsubstance has associated with it an array of $20$ parameters\n$(a_1,\\ldots,a_{19},\\gamma)$ with the property that (see Polt \\cite{Polt87})\n\\begin{align*}\n  P(T,\\rho) = BP_1 \\rho + \\left[ BP_2 \\rho^2 + BP_3 \\rho^3 + BP_4\n    \\rho^4 + BP_5 \\rho^5 + BP_6 \\rho^6 + (BE_1\\rho^3 + BE_2 \\rho^5)\n    e^{-\\gamma \\rho^2} \\right] \\cdot 10^3,\n\\end{align*}\nwhere\n\\begin{equation}\n  \\label{eq:BPBE_MBWR19}\n  \\begin{aligned}\n    BP_1 &= RT \\\\\n    BP_2 &= a_1T-a_2-a_3/T-a_4/T^2-a_5/T^3 \\\\\n    BP_3 &= a_6T+a_7+a_8/T \\\\\n    BP_4 &= a_9T+a_{10} \\\\\n    BP_5 &= a_{11}T+a_{12} \\\\\n    BP_6 &= a_{13} \\\\\n    BE_1 &= a_{14}/T^2+a_{15}/T^3+a_{16}/T^4 \\\\\n    BE_2 &= a_{17}/T^2+a_{18}/T^3+a_{19}/T^4.\n  \\end{aligned}\n\\end{equation}\nTake note of the factor $10^3$, as well as the sign inversions for\nterms $a_2,a_3,a_4,a_5$. Also for MBWR-19, $P$ is measured in Pascal, $T$ is\nmeasured in Kelvin and $\\rho$ is measured in moles per litre.\n\n\\subsubsection*{No MBWR data set for $CO_2$}\nAlthough there was a data set for $\\mathrm{CO}_2$ for MBWR-19 in the old TPlib\nlibrary, it is wrong. According to this data set, $\\mathrm{CO_2}$ is still\nsubcritical at $310$ K, which is about $5$ K over its measured critical\ntemperature. VLE calculations using SPUNG with $\\mathrm{CO}_2$ as reference\ncomponent also gives absurd results. Although the dissertation by Polt \\cite{Polt87}\nhas been checked, he surprisingly doesn't give a correlation for\n$\\mathrm{CO}_2$. The correlation in the TPlib database has no reference.\n\n\\section{The MBWR density solver} \\label{sec:density}\nWhen the MBWR equations of state are called from ThermoPack, the\ntemperature, pressure and the phase is usually what\nis given as input. However, the independent variables in MBWR\nequations are density and temperature, not temperature and\npressure. Therefore, an algorithm which takes in $T$ and $P$ and\nsolves for $\\rho$ is needed.\n\nThe density solver in the old thermodynamics library, TPlib, was not as robust as\ndesired. Jørstad writes the following in his thesis \\cite{Jorstad93}:\n\\textit{Calculation of the density results sometimes in an incorrect\n  solution or in a few circumstances breaks down (...) Approximately 1\n  out of 500 calculations fails.} A better density solver is therefore\nrequired. This section discusses the theory behind the implementation\nof a new, more robust density solver.\n\nIn this section $T_0$ and $P_0$ will denote arbitrary but fixed\ntemperatures and pressures.\n\n\\subsection{Phases and the correct density root} % Bad title...\nA typical plot of the function $\\rho \\mapsto P(T_0,\\rho)$ is given in\nFigure \\ref{fig:p_ill}. As illustrated by this graph, there will\nfrom a purely mathematical standpoint be several choices of $\\rho$\nwhich satisfies $P(\\rho,T_0) = P_0$. However, not all of these\ndensities correspond to a physically realistic state. A first\ncriterion for the density being a physical solution is that belongs to\nsome interval over which $P(T_0,\\rho)$ is positive and\nincreasing. This is due to the fact that, at a given temperature,\nhigher pressure will always correspond to a higher density. Applying\nthis first criterion, we see that there are two candidates for the\nphysically correct density. To choose the correct one of these two, we\nneed to know what phase, gas or liquid, the fluid is in: the gas phase\ncorresponds to the lowest density, the liquid phase corresponds to the\nhighest density. Let us call the part of the graph corresponding to\nvalid vapor densities the ``vapor hill'', and similarly call the part of the\ngraph corresponding to liquid solutions the ``liquid hill''. Thus,\ngiven the phase, one has to choose the solution lying on the\ncorresponding hill.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/pressureIllustration.eps}\n  \\caption{A log-log plot of the MBWR-19 density-pressure curve for CH$_4$ and a\n    subcritical temperature, and an example input pressure (green) drawn\n    in. Where $P(T_0,\\rho)$ becomes negative we have plotted\n    $|P(T_0,\\rho)$ in red.}\n  \\label{fig:p_ill}\n\\end{figure}\n\nThe choice of root is even easier for supercritical temperatures, $T_0\n> T_c$, as illustrated in Figure \\ref{fig:p_ill_sup}. In this\ncase there is only one interval where $P(T_0,\\rho)$ is increasing, and\nso the density is independent of phase. Physically, this reflects the\nfact that for supercritical temperatures, there is no discontinuous\nphase change.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/pressureIllustrationSupercritical.eps}\n  \\caption{The MBWR-19 density-pressure curve for CH$_4$ and a supercritical temperature, and\n    an example input pressure drawn in.}\n  \\label{fig:p_ill_sup}\n\\end{figure}\n\nA case where it is not so straightforward how choose the physical\ndensity is shown in Figure \\ref{fig:p_ill_meta}. If the user inputs liquid\nphase, the question is whether one should return the solution\ncorresponding to the gas phase, or the density corresponding to the\nliquid phase having minimum pressure.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/pressureIllustrationMeta.eps}\n  \\caption{The MBWR-19 density-pressure curve for CH$_4$ and a\n    temperature below but close to the critical temperature, and an example input pressure drawn in.}\n  \\label{fig:p_ill_meta}\n\\end{figure}\n\nSometimes the user may not want to give the algorithm an input phase,\nbut rather ask that it chooses the phase which corresponds to the physically\nstable solution. This is possible by letting the algorithm search for\nboth the liquid and gas root, and then returning the density\ncorresponding to minimum Gibb's energy.\n\n\\subsection{The density solver algorithm}\nAlthough we tried many algorithms (e.g. the Illonois algorithm, the\nPegasus method, Halley's method), in the end the best method\nproved to be Newton's method. A major reason for its speed is that\nit is cheap to calculate the derivative $\\partial_\\rho P(T_0,\\rho)$ by precalculating the temperature dependent coefficients, and\nthat if one evaluates both $P(T_0,\\rho)$ and its derivative at the\nsame point, much of the computation overlaps, allowing a considerable\nspeedup compared to computing each of them separately. (Of course, the same overlap occurs when computing the second derivative.)\n\nThe never-ending worry with Newton's method is that it may shoot off\nand not converge to the desired root. But there are special cases where\nNewton's method is guaranteed to converge:\n\\begin{enumerate}\n\\item If a function is concave and increasing and the initial guess is\n  smaller than the root, then Newton's method is guaranteed to\n  converge, and the rate of convergence is quadratic.\n\\item If a function is convex and increasing and the initial guess is\n  larger than the root, then Newton's method is guaranteed to\n  converge, and the rate of convergence is quadratic.\n\\end{enumerate}\n\nThis of course requires us to know something about the convexity of $P(T_0,\\rho)$. Interestingly, by plotting\n$\\partial^2P(T_0,\\rho)/\\partial\\rho^2$ and $P(T_0,\\rho)$ together, we have found evidence\nfor the ``gas hill'' being concave and increasing, and the ``liquid\nhill'' being convex and increasing%\n\\footnote{A possible physical interpretation: When density is\n  low, increasing pressure increases density little at first, but then\n  more and more as long-range attraction becomes significant. When\n  density is high, increasing pressure increases density less and less\n  as short-term repulsion becomes dominant.}. %\nAn example is shown in Figure \\ref{convexityPlot}.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/convexity.eps}\n  \\caption{A log-log plot of $P(T_0,\\rho)$ and $\\partial_\\rho^2P(T_0,\\rho)$ for the MBWR-19 equation with component C$3$.}\n  \\label{convexityPlot}\n\\end{figure}\nOf course, these convexity properties have not been checked for all\nsubstances in the database. It has been verified to hold for the most\ncommonly used components, including. C$1$, C$2$, C$3$, N$2$, O$2$,\nH$2$O, R$152$a, R$134$a, HE. Moreover, for some components\n(e.g. NC$7$, benzene), the vapor hill is only concave for pressures\nbelow the saturated vapor pressure. If these convexity properties\nreally demonstrate an inherently physical feature of fluids, rather\nthan simply being numerical artefacts, is not known. E.g. Span\n\\cite{Span03} seems not to mention anything about convexities. In any\ncase, let us from now on call the criterion\n\\begin{equation}\n  \\partial_\\rho^2 P(\\rho_{vap},T_0) < 0, \\qquad \\partial_\\rho^2 P(\\rho_{liq},T_0) > 0\n\\end{equation}\nthe \\textbf{phase convexity test}.\n\nNow, by 1. above, we know that if one is looking for a gas root, then\nNewton's method will always converge if given an initial density lower\nthan the true gas density. Similarly, 2. guarantees that Newton's\nmethod converges to the liquid density if the starting density is a\nlittle higher than the true liquid density. \nOf course, this is only true if there really exists a density solution\nin the required phase. If not, Newton's method may shoot off. To\nprevent this, the density algorithm uses three tests. If the input\nphase is vapor, they are:\n\\begin{enumerate}[i)]\n\\item $\\partial_\\rho P(\\rho_n) > 0$,\n\\item $P(\\rho_{n-1}) < P(\\rho_{n})$,\n\\item $\\lp P(\\rho_{n})-P(\\rho_{n-1}) \\rp / (\\rho_{n}-\\rho_{n-1})\n  < \\partial_\\rho P(\\rho_{n})$.\n\\end{enumerate}\nIf the input phase is liquid, they are the same with the exception of\nii, where the direction of the inequality has to be reversed. If the\ncurrent iterate fails any of these tests, there is no density root\nwith the given input phase. Once again, this assumes that the initial\nguess is an underestimate in the case of vapor phase, and an overestimate in\nthe case of liquid phase.\n\nIf there exists a vapor root, the solver will always find it when\ngiven vapor as input phase, simply because it is very easy to find a\ngood underestimate (see section \\ref{sec:inDens}). Given liquid as\ninput phase, a too large overestimate may result in the density solver\ndiverging. The problem is illustrated in figure \\ref{liqGoesDown} for the MBWR-32\nequation (this problem does not occur with MBWR-19): if the initial liquid\ndensity is too great, we will have negative slope, and Newton's method\nwill diverge. To counter this from happening, a fallback Newton solver\nis implemented which kicks in if the main density solver fails. The\ndifferences between the fallback Newton solver and the main\nsolver are two things: the initial liquid guess is lower, and there\nare less tests for divergence. In fact, the only situation where the\nfallback Newton solver terminates (besides from performing more than\nthe maximum number of iterations), is when $\\partial_\\rho P(\\rho_n)$\nbecomes negative.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/C3_liqGoesDown.eps}\n  \\caption{A density-pressure curve for the MBWR-19 equation with\n    component C$3$. Note how the computed pressure becomes negative\n    for large $\\rho$.}\n  \\label{liqGoesDown}\n\\end{figure}\nA second fallback is also implemented as a last resort, namely the old\nsolver in TPlib, which is described in section \\ref{tplibSolver}.\n\nFinally, some words about the actual code. The density solver is now\ndivided up into three routines. The routine the user actually calls is\nMBWR\\_density. MBWR\\_density generates initial guesses and then calls\nnewton\\_density, which given an initial density on the correct\nside of the root, either determines the root, or outputs $-1$ if no\nroot is found. An optional argument can force the algorithm to choose\nthe metastable extremum if no density exists for the input phase; once\nagain, the routine will only converge if the initial guess is on the\ncorrect side of the density root. If the newton\\_density fails, the\nfunction barenewton is called, and if also this fails the TPlib solver\nis called.\n\n\\subsection{Choosing the initial density} \\label{sec:inDens}\nAs already pointed out, choosing a good initial density is of the utmost\nimportance for the algorithm to converge to the correct root. For the purposes of reaching the correct density in a robust and time-efficient manner, experimentation showed that the following choices were favorable.\n\n\\subsubsection*{Choosing the initial vapor density}\nFor the vapor root, we use the initial guess \n\\begin{itemize}\n\\item $\\rho_{0,\\text{vapor}} = 10^{-6}$ if $P \\ge 100$ Pa,\n\\item $\\rho_{0,\\text{vapor}} = 10^{-12}$ if $P<100$ Pa,\n\\end{itemize}\nThis will be lower than the MBWR vapor density (if it exists), just as we desire. Moreover, experiments show that Newton's method converges quickly even though the initial guess is so low. Another advantage of this method of choosing the initial value is that no computation time is spent.\n\n\\subsubsection*{Choosing the initial liquid density}\nAlthough one might think that analogously to the choice of initial\nvapor density, a really large value (e.g. $10^{2}$\n$\\mathrm{mol}/\\mathrm{L}$) would be a good choice of initial liquid\ndensity, there are two reasons that this is a bad idea. The first is\nthat unlike in the vapor phase, where the MBWR equation is designed to\nhave the correct asymptotic behavior $\\lim_{\\rho \\to 0} P(T,\\rho) = 0$, one has no guarantee of physical behavior for large $\\rho$. Indeed, for MBWR-32, for large enough densities, $P(T,\\rho)$ becomes negative. Interestingly and luckily, however, the MBWR-19 equation has a predictable behavior for large $\\rho$, namely\\footnote{Of course, the two first limits are implied by the last limit.}\n$$\n\\lim_{\\rho \\to \\infty} P_{\\text{MBWR-}19}(T,\\rho) = \\infty,\n\\quad \\lim_{\\rho \\to \\infty} \\partial_\\rho\nP_{\\text{MBWR-}19}(T,\\rho) = \\infty, \\quad \\lim_{\\rho \\to \\infty} \\partial^2_\\rho P_{\\text{MBWR-}19}(T,\\rho) = \\infty\n$$\nNo one in the consulted literature seems to mention this, and although it hasn't been checked for all substances in the MBWR-19 database of substances, it holds in all cases we have encountered.\n\nFor subcritical temperatures, the density computed by\nSoave-Redlich-Kwong is used. For supercritical temperatures, the ideal\ngas equation is used. For temperatures and pressures near the critical\npoint, the critical density is used. In all of these three cases, the\ninitial density is scaled up by up to $50\\%$ or more to ensure that the density is on the right side of the MBWR density. The actual scaling factor varies depending on the situation, guided by experimentation.\n\n\\subsection{The density solver in TPlib} \\label{tplibSolver}\nTPlib uses the second order Newton method, also called Halley's method:\n\\begin{align*}\n  \\Delta x_n &= -\\frac{f'(x_n)}{f''(x_n)} \\pm \\frac{1}{f''(x_n)} \\sqrt{ f'(x_n)^2 - 2 f''(x_n) (f(x_n)-P) } \\\\\n  &= -\\frac{f'(x_n)}{f''(x_n)} \\pm \\sqrt{ \\lp \\frac{f'(x_n)}{|f''(x_n)|}\n    \\rp^2 + 2 \\frac{P+f(x_n)}{f''(x_n) } },\n\\end{align*}\nand if the radicand is negative, one sets $\\Delta x_n = -f'(x_n) /\nf''(x_n)$. \n\nIf the reduced pressure is less than $1$, a so-called Modified Rackett\ntechnique\\footnote{See e.g. \\cite{GasesAndLiquids01}, section 4.11.} is used to estimate the saturated vapor pressure at the given\ntemperature, and from this the saturated vapor density can be\nestimated. This estimate is then scaled by a factor greater than\n$1$.\n\\begin{align*}\n  z_{\\mathrm{rackett}} &= (0.29056 - 0.08775\\omega)^{1 + (1 - T_r)^{2/7}} \\\\\n  \\rho_0 &= \\frac{P_c}{R T_c z_{\\mathrm{rackett}}}\n\\end{align*}\nFor supercritical pressures, the critical density is used\nas the initial value. \n\nThe density solver from TPlib has been copied over to the MBWR module\nin ThermoPack, with the only modification being that it has been given\nthe same initial density guess as the main density algorithm. This\nreimplementation of the TPlib solver is used to compare the\nrobustness and computational time with the new density solver. It is\nalso used as a last fallback routine if the new density algorithm\nfails.\n\n\n\\subsection{Testing the density solver robustness}\nTo optimize and test the density solver, a program which bombards the\ndensity solver with test cases was written. The density solver is\ntested for $1000$ equispaced temperatures between the triple point\ntemperature and $1000$ K; for each of these the pressure input is 1000\nequispaced points from the triple point pressure to $10^7$ Pa. This is\ndone for both the vapor and the liquid phase. All in\nall, the density solver is tested on a grid of $2 \\cdot 10^6$\npoints. Our critieria for convergence are\n\\begin{enumerate}\n\\item $|P_{MBWR}(\\rho)-P_{in}| < 10^{-5}$,\n\\item $\\partial_\\rho P_{MBWR}(\\rho)> 0$,\n\\item the phase convexity criterion is fulfilled.\n\\end{enumerate}\nResults from the robustness tests are presented below.\n\n\\subsubsection*{MBWR-32}\nFor the tested components,\n\\begin{itemize}\n\\item C1,\n\\item C2,\n\\item C3,\n\\item R134a,\n\\item O2,\n\\item N2,\n\\end{itemize}\nthe density solver converges in all cases.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figures/C2.eps}\n  \\caption{Density versus pressure for the MBWR-19 equation, component\n    C2, temperature $99$ K.}\n  \\label{C2}\n\\end{figure}\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.6\\textwidth]{figures/C2_101.eps}\n  \\caption{Density versus pressure for the MBWR-19 equation, component\n    C2, temperature $101$ K.}\n  \\label{C2_101}\n\\end{figure}\n\n\\subsubsection*{MBWR-19}\nFor MBWR-19, we tested 10 components. For the following components the\ndensity solver converges in all cases:\n\\begin{itemize}\n\\item C1,\n\\item C3,\n\\item O2,\n\\item N2,\n\\item R152a,\n\\item HE,\n\\item H2O,\n\\item NH3.\n\\end{itemize}\nWe also tested NC7 and C2. As mentioned above, the NC7 vapor hill becomes convex for\npressures higher than the saturated vapor pressure, and therefore some of the\ncomputed vapor densities can fail the phase convexity test. This is\nindeed what happens -- 175 failed cases -- when testing the solver and giving\n``vapor'' as input phase (using ``liquid'' as input phase always\nyields convergence). If one reruns the tests for NC7 while only using\nthe 1. and 2. convergence criterion, while ignoring the phase\nconvexity tests, we get attain convergence in all cases.\n\nFor C2, the liquid hill looks unusual, see figures \\ref{C2} and \\ref{C2_101}. These\nnonstandard features make it hard for any gradient based solver to\nsolve for the density, as it requires a very accurate initial density\nguess. These problems disappear for temperatures above 100 K, and the\nsolver then chooses as liquid density the root corresponding to the rightmost\nsolution; but in this case it is not clear whether this is really the\ncorrect root. In other words, C$2$ seems to be a difficult component\nfor MBWR-$19$. Although this can be further investigated, and can\nprobably be remedied by tweaking the solver, this has not been done.\n\n\\subsection{Testing the density solver which minimizes the Gibbs energy}\nWe have also implemented a density algorithm which finds the density\nin the phase such that the Gibbs energy is minimized. A quick test using MBWR-19 and water\nshows that for $P = 101325$ Pa it changes from having $\\rho = 53.2$ mol/L to having $\\rho = 0.0331$ mol/L at $373.14$ K. This indeed coincides with the normal boiling point of water.\n\n\\subsection{Speed test}\nWhen the MBWR main density routine converges, it is always faster than\nthe TPlib solver. The speedup depends on the phase, and to a lesser extent on the given temperature and pressure. Typical situations\nare shown in Table 3, for various substances and temperature-pressure states. For this table the MBWR-19 equation has been used, and the cpu-time has been measured for $10^5$ calls to the density solver (to render the inherent inaccuracy in the measurement of CPU-time insignificant).\n\n\\begin{table}\n  \\label{MBWR19times}\n  \\centering\n  \\begin{tabular}{c c c c c c c c }\n    $T$ [K]\t\t        & $P$ [Pa]\t\t& Comp.     & ThermoPack vap. [s] & TPlib vap. [s] & Thermopack liq. [s]  & TPlib liq. [s]  \\\\\n    \\hline\n    $254$\t        & $1.26$e$6$    &$\\mathrm C 3$\t\t&$0.14$            & $0.34$\t & $0.11$        &$0.15$\t    \\\\\n    $143$               & $2.09$e$6$  \t&$\\mathrm O2$\t\t&$0.076$           & $0.21$\t & $0.12$     \t  &$0.16$\t\t        \\\\\n    $129$\t        & $7.46$e$4$   \t&$\\mathrm{HE}$\t\t&$0.065$           & $0.14$\t & $0.059$    \t  &$0.068$\t\t            \\\\\n    $172$               & $5.12$e$5$   \t&$\\mathrm R152 \\mathrm a$\t&$0.12$    & $0.27$\t & $0.10$    \t  &$0.13$\t        \\\\\n    $1000$\t        & $1$e$8$      \t&$\\mathrm C1$ \t\t&$0.087$            & $0.32$\t & $0.087$    \t  &$0.12$\t      \\\\         \n  \\end{tabular}\n  \\caption{Performance of the ThermoPack and TPlib density solvers in various circumstances.}\n\\end{table}\n\n\\subsection{Further improvements}\nIn one sense the density solver converges \\textit{too often}; indeed,\nit often finds a vapor density even though we are far above the saturated vapor\npressure at the given temperature. Ideally, a correlation for the saturated\nvapor pressure should be used in the density routine. This information\ncould stop the density solver from finding nonexistent roots, and\ncould further speed up the density solver by terminating the search\nwhen the pressure at the current density iterate is above/below the\nsaturated vapor pressure (depending on which phase is being solved\nfor).\n\n\\section{Routines for calculating necessary thermodynamic functions}\nTo get a complete program for the MBWR equations, we have also written\na module for calculating the residual entropy, the residual enthalpy,\nthe residual Gibbs energy, the $z$-factor and the logarithmic fugacity\ncoefficients, as well as their first order partial derivatives with\nrespect to $T$ and $P$. Per now the MBWR equations are only used as a\npart of the SPUNG framework, so these thermodynamic functions are\nnever called. The one exception is the routine for calculating Gibbs\nenergy, which is used in the in the density routine which chooses the\nroot having minimal Gibbs energy.\n\n\n\\section{Testing the MBWR models}\nTo validate the implementation of the MBWR-19 and MBWR-32 models,\nvarious tests have been performed.\n\n\\subsection{Thermodynamic identities}\nIn addition to the numerical test of the derivatives, thermodynamic\nidentities and identities found from Euler's theorem, serve as decent\nconsistency tests for the analytical derivatives. The test supplied\nhere are all found in Michelsen \\cite{Michelsen07}. To test the derivatives of the\nreduced residual Helmholtz function, the following identities may be\napplied:\n\\begin{align}\n  \\label{test:1}\n  & F = V \\pder{F}{V}_{T,\\textbf{n}} + \\sum_i n_i \\pder{F}{n_i}_{T,V} \\\\\n  \\label{test:2}\n  & V \\pdcross{F}{V}{n_i}_T + \\sum_j n_j \\pdcross{F}{n_j}{n_i}_{T,V} = 0 \\\\\n  \\label{test:3}\n  & V \\pdder{F}{V}_{T,\\textbf{n}} + \\sum_j n_j \\pdcross{F}{n_j}{V}_T =\n  0\n\\end{align}\n\nWhen these are all satisfied, the fugacity coefficients and their\nderivatives may be tested by the identities:\n\\begin{align}\n  \\label{test:4}\n  & \\left( \\frac{\\partial}{\\partial n_j} \\sum_i n_i \\ln \\phi_i \\right)_{T,P} = \\ln \\phi_j \\\\\n  \\label{test:5}\n  & \\pder{\\ln \\phi_i}{n_j}_{T,P} = \\pder{\\ln \\phi_j}{n_i}_{T,P} \\\\\n  \\label{test:6}\n  & \\sum_i n_i \\pder{\\ln \\phi_i}{n_j}_{T,P} = 0 \\\\\n  \\label{test:7}\n  & \\left( \\frac{\\partial}{\\partial P} \\sum_i n_i \\ln \\phi_i \\right)_{T,\\textbf{n}} = \\frac{(z-1) n}{P} \\\\\n  \\label{test:8}\n  & \\sum_i n_i \\pder{ \\ln \\phi_i}{T}_{P,\\textbf{n}} =\n  -\\frac{H^R(T,P,\\textbf{n})}{RT^2}\n\\end{align}\nOf course, since it is an equation for pure substances, the MBWR\nequations only has one fugacity\ncoefficient. All of these identities have been implemented, and the\ncode seems to fulfill them when tested on a few points.\n\n\\subsection{Comparing numerical and analytical derivatives}\nThe analytical derivatives for the implemented thermodynamic functions\nhave been compared to their finite-difference counterparts, with\nconsistent results.\n\n\\subsection{Comparison with previous MBWR implementations}\nIn the code there is an algorithm which calculates the component-specific coefficients for $\\alpha(T,P)$ using the component-specific coefficients for $P(T,\\rho)$. The coefficents for the Helmholtz energy in the MBWR-32 model with R152a as the substance, checks out with the coefficients computed by an earlier implementation in the NIST thermodynamic library REFPROP.\n\n\\section{Extension to mixtures: The SPUNG equation of state}\n\n\\subsection{Pure fluid scale factors from a cubic equation of state} % Michelsen p. 102\nConsider a generic cubic equation of state,\n$$\nP = \\frac{RT}{v-b}-\\frac{a(T)}{(v+\\delta_1 b)(v+\\delta_2 b)}.\n$$\nFrom an equation for $P$, one can find the residual Helmholtz energy from the integral\n$A^r(T,V,\\mbn) = -\\int_\\infty^V \\lp P - nRT/V' \\rp dV'$, and for the\ngeneric cubic equation we\nget\n\\begin{align}\n  \\frac{A^r(T,v)}{RT} &= -\\ln(1-b/v)-\\frac{a(T)}{RTb}\\frac{1}{\\delta_1-\\delta_2}\\ln \\lp \\frac{1+\\delta_1 b/v}{1+\\delta_2 b/v} \\rp \\\\[1.5pt]\n  &= -\\ln(1-\\beta) - \\frac{\\Gamma}{\\delta_1-\\delta_2} \\ln \\lp\n  \\frac{1+\\delta_1 \\beta}{1+\\delta_2 \\beta} \\rp, \\label{Ar_pure}\n\\end{align}\nwhere we defined the adimensional parameters $\\Gamma = a(T)/bRT$ and\n$\\beta=b/v$.\n\nWe first develop the SPUNG model for pure fluids. Suppose therefore we have two pure fluids called fluid $1$ and fluid $0$. We say they are in \\textbf{corresponding states} when $\\Gamma_1 =\n\\Gamma_0$ and $\\beta_1 = \\beta_0$, i.e. when\n\\begin{equation}\n  \\label{Eq:gammaBetaEquality}\n  \\frac{a_1(T_1)}{b_1 R T_1} = \\frac{a_0(T_0)}{b_0 R T_0}, \\quad \\text{and} \\qquad \\frac{b_1}{v_1} = \\frac{b_0}{v_0}.\n\\end{equation}\nIn particular, this implies that the fluids have the same reduced residual Helmholtz energy. Now, for cubic equations of state like PR and SRK, $a(T)$ and $b$ take the special form\n\\begin{equation}\n  \\label{aForm}\n  a(T) = \\Omega_a (R^2T_c^2/P_c) \\alpha(T), \\quad \\alpha(T) =\\lp 1+m(\\omega)(1-\\sqrt{T/T_c}) \\rp^2 % THIS LAST SENTENCE ONLY TRUE FOR SRK AND PR? WHICH \\omega TO USE FOR MIXTURES?\n\\end{equation}\nand\n\\begin{equation}\n  \\label{bForm}\n  b = \\Omega_b \\cdot RT_c/P_c,\n\\end{equation}\nwhere $\\Omega_a$ and $\\Omega_b$ are substance-independent constants. From equations \\eqref{Eq:gammaBetaEquality} and \\eqref{aForm} and \\eqref{bForm}, we will be able to calculate the pure\nfluid \\textbf{scale factors}, defined as\n$$\nh = v_1/v_0, \\qquad f =\nT_1/T_0. % These are the definitions for PURE substances, not mixtures! For mixtures, we use the BIG letters \\hat H and \\hat F.\n$$\nThe scale factor for volume is\n\\begin{equation}\n  \\label{eq:h1}\n  h = \\frac{v_1}{v_0} = \\frac{b_1}{b_0} = \\frac{T_{c_1}P_{c_0}}{T_{c_0}P_{c_1}},\n\\end{equation}\nwhile the scale factor for temperature can be written\n\\begin{equation}\n  \\label{eq:f1}\n  f = \\frac{T_1}{T_0} = \\frac{a_1(T_1) b_0}{a_0(T_0) b_1} = \\frac{T_{c_1}}{T_{c_0}} \\frac{\\alpha(T_{r_1})}{\\alpha(T_{r_0})},\n\\end{equation}\n\n\\subsubsection*{Explicit temperature scale factor when $\\alpha=\\alpha_{SRK}$ or $\\alpha=\\alpha_{PR}$}\nWhen the ratio of reduced temperatures, $\\theta = T_{r_1}/T_{r_0}$, is\ncalculated from Soave's or Peng-Robinson's correlation for $\\alpha$, we get\n\\begin{equation}\n  \\label{theta_1}\n  \\theta = \\lp \\frac{1+m_1-m_1 \\sqrt{T_{r_1}}}{1+m_0-m_0\n    \\sqrt{T_{r_0}}} \\rp^2,\n\\end{equation}\nIt is possible to solve for $\\theta_1$ as an explicit function of\n$T_{r_1}$. Indeed, taking the square root on both sides of \\eqref{theta_1}\nand substituting $T_{r_0} = T_{r_1}/\\theta$, we get\n$$\n\\sqrt{\\theta} = \\frac{1+m_1-m_1 \\sqrt{T_{r_1}}}{1+m_0-m_0 \\sqrt{(T_{r_1}/\\theta)} },\n$$\nand multiplying both sides with the denominator, we can easily solve for $\\theta$:\n$$\n\\theta = \\lp \\frac{1+m_1}{1+m_0} + \\frac{m_0-m_1}{1+m_0}\n\\sqrt{T_{r_1}} \\rp^2.\n$$\nThe morale is: when obtaining pure fluid scale factors from cubic equations of\nstate, one can get explicit expressions for the scale factors,\ndepending only on the accentric factors and critical parameters, together with the\ntemperature of one of the substances.\n\n\\subsection{Mixtures} % Michelsen p. 105\nThe most interesting application of SPUNG is when one is dealing with a \\textit{mixture} of components, to which we now turn our focus. The idea is to map the thermodynamic state $(T,v)$ for the mixture to some corresponding $(T_0,v_0)$ of a reference fluid. The idea is that if one has a very accurate description (using e.g. a multiparameter equation of state) of the thermodynamics of the pure fluid $0$, then one can use this mapping to get an accurate description of the mixture.\n\nUsing a cubic equation, the expression for the Helmholtz energy for\n$n$ moles of a mixture is (see e.g. Michelsen \\cite[p.105--107]{Michelsen07})\n\\begin{align*}\n  \\frac{A_r(T,V,\\mbn)}{nRT} &= -\\ln(1-B(\\mbn)/V)-\\frac{D(T,\\mbn)}{nRTb}\\frac{1}{\\delta_1-\\delta_2}\\ln \\lp \\frac{1+\\delta_1 B(\\mbn)/V}{1+\\delta_2 B(\\mbn)/V} \\rp \\\\[1.5pt]\n  &= -\\ln(1-\\beta_{mix}) - \\frac{\\Gamma_{mix}}{\\delta_1-\\delta_2} \\ln\n  \\lp \\frac{1+\\delta_1 \\beta_{mix}}{1+\\delta_2 \\beta_{mix}} \\rp,\n\\end{align*}\nwhere we have defined the adimensional mixture parameters\nas $\\Gamma_{mix} = D(T,\\mbn)/bRT$ and $\\beta_{mix}=B(\\mbn)/V$. The quantities\n$D(T,\\mbn)/n^2$ and $B(\\mbn)/n$ are the mixture analogs of the parameters $a(T)$\nand $b$ for a pure fluid.\n\nThe principle of corresponding states allows us to calculate the\nreduced residual energy of a mixture from the reduced residual\nHelmholtz energy of a pure reference fluid $0$, by equating $\\Gamma_{mix} =\n\\Gamma_0$ and $\\beta_{mix} = \\beta_0$, i.e.\n$$\n\\frac{D(T,\\mbn)}{nRTB(\\mbn)} = \\frac{a_0(T_0)}{RT_0b_0} \\qquad \\text{and} \\qquad\n\\frac{B(\\mbn)}{V} = \\frac{b_0}{v_0}.\n$$\nWe thus get the two mixture scale factors $\\hat H$ and $\\hat F$\n$$\n\\hat H = \\frac{V}{v_0} = \\frac{B(\\mbn)}{b_0}, \\qquad \\text{and} \\qquad \\hat\nF = \\frac{nT}{T_0} = \\frac{D(T,\\mbn)}{B(\\mbn)} \\frac{b_0}{a_0(T_0)}.\n$$\nNote that the mixture scale factors are first order homogeneous\nfunctions in the mole numbers. The mixing rules\nadopted for $B(\\mbn)$ and $D(T,\\mbn)$ are optional as long as they give a consistent\nmodel. %The mixing rules for $\\hat H$ and $\\hat F$ are derived from the mixing rules for $D$ and $B$.\n\nAdopting the conventional mixing rules -- also called the van der Waals\none-fluid mixing rules, or the quadratic mixing rules -- for $B(\\mbn)$ and $D(T,\\mbn)$, we get\n$$\n\\hat H n b_0 = nB(\\mbn) = \\sum_{i,j} n_i n_j b_{ij}\n$$\nand\n$$\n\\hat F \\hat H a_0(T_0) = \\hat F \\hat H a_0(nT/\\hat F) = D(T,\\mbn) = \\sum_{i,j}\nn_i n_j a_{ij}(T).\n$$\nFor mixtures involving polar substances, mixture rules based on excess\nGibbs energy models may be more appropriate. The Huron-Vidal mixing\nrule is a prominent example. We mention that the cubic equation of state which is used to calculate the scale\nfactors $\\hH$ and $\\hF$ is called the \\textbf{scale factor equation}\nor the \\textbf{shape factor equation}. $\\hH$ and $\\hF$ are often\ncalled shape factors.\n\nAlthough $\\hH$ is given explicitly in terms of the mixture composition\nas $\\hat H = \\frac{B(\\mbn)}{b_0}$, it is in the general case\nimpossible to give an explicit expression for $\\hF$ in terms of the\nmixture temperature and composition. In certain cases however, this\ncan be done.\n\n\\subsubsection*{Explicit temperature scale factor when $\\alpha=\\alpha_{SRK}$ or $\\alpha=\\alpha_{PR}$}\nIf $a_0(T_0) = a_{0c} (1+m_0-m_0 \\sqrt{T_0/T_{0c}})^2$, it\nturns out that we can solve for $\\hF$ from the implicit expression\n$$\n\\hat F =  \\frac{1}{\\hH} \\frac{D(T,\\mbn)}{a_0(nT/\\hF)}.\n$$\nIndeed, by inserting the form for $a_0$ we get\n$$\n\\hat F = \\frac{D(T,\\mbn)}{\\hH a_{0c} \\lp 1+m_0-m_0 \\sqrt{nT/(\\hF T_{0c})} \\rp^2}\n$$\n$$\n\\sqrt{\\hat F} \\lp 1+m_0-m_0 \\sqrt{\\frac{nT}{\\hF T_{0c}}}\\rp = \\lp\n\\frac{D(T,\\mbn)}{\\hH a_{0c}} \\rp^{1/2}\n$$\n$$\n\\sqrt{\\hat F} (1+m_0) = m_0 \\sqrt{\\frac{nT}{T_{0c}}} +  \\lp\n\\frac{D(T,\\mbn)}{\\hH a_{0c}} \\rp^{1/2}\n$$\n\\begin{equation}\n  \\label{hF_SRK}\n  \\hat F = \\frac{1}{(1+m_0)^2}\\lp m_0 \\sqrt{\\frac{nT}{T_{0c}}} + \\lp\n  \\frac{D(T,\\mbn)}{\\hH a_{0c}} \\rp^{1/2} \\rp^2.\n\\end{equation}\n\n\\subsubsection*{Temperature scale factor when $\\alpha=\\alpha_{TWU}$}\nSuppose now that we use the alpha formulation of Twu-Coon-Cunningham:\n$$\na_0(T_0) = a_{0c} \\cdot T_{0r}^{N(M-1)} \\exp \\lp L - LT_{0r}^{MN} \\rp,\n$$\nwhere the $L$, $M$ and $N$ have been fitted to vapor pressure data for\neach fluid. This alpha correlation is more tailored to specific\ncomponents than $\\alpha_{SRK}$ , seeing as the only component-specific\ninput to $\\alpha_{SRK}$ is the acentric factor and the critical\ntemperature. In the current database the parameters have only been\nstored for the four substances $\\mathrm{CO}_2$, $\\mathrm{CH}_4$,\n$\\mathrm{H}_2\\mathrm{S}$ and $\\mathrm{H}_2\\mathrm{O}$.\n\nLet us find the temperature shape factor using this alpha\nformulation. Using $\\hat F = \\frac{D(T,\\mbn)}{\\hH\n  a_{0c}\\alpha_{TWU}(T_0)}$ and $T_0 = nT/\\hF$, we get\n$$\n\\hat F \\cdot \\lp \\frac{nT}{\\hF T_{0c}} \\rp^{N(M-1)} \\exp \\lp L - L\\lp \\frac{nT}{\\hF T_{0c}} \\rp^{MN} \\rp = \\frac{D(T,\\mbn)}{\\hH\n  a_{0c}},\n$$\nor\n\\begin{equation}\n  \\label{hF_TWU}\n  \\hF^{1+N(1-M)} \\exp \\lp L - L\\lp \\frac{nT}{\\hF T_{0c}} \\rp^{MN} \\rp =\n  \\lp \\frac{T_{0c}}{nT} \\rp^{N(M-1)} \\frac{D(T,\\mbn)}{\\hH a_{0c}}.\n\\end{equation}\nFrom this last expression, it is clear that it is not possible to\nsolve for $\\hF$ using simple functions\\footnote{It is solvable by\n  using the Lambert W function, but this transcendental function is\n  not available from the numerical libraries used by ThermoPack.}.\nThe code therefore solves this using Newton's method, with the $\\hF$\nfactor computed with $\\alpha_{SRK}$, \\eqref{hF_SRK}, as starting value.\n\nA drawback is that these coefficients are only valid for subcritical\ntemperatures $T_{0r}<1$. Skaugen \\cite{Skaugen13} gives a\nmore detailed discussion of the Twu correlation, and what can be done\nfor supercritical temperatures.\n\nFinally, we point out that if one wants to implement other\n$\\alpha$-formulations into the SPUNG code, this is straightforward as\none can simply mirror the code for $\\alpha_{SRK}$ (if an explicit\nexpression for $\\hF$ is available) or $\\alpha_{TWU}$ (if $\\hF$ has to\nbe solved iteratively). \n\n\\subsection{Partial derivatives} % Michelsen, p. 115.\nWe now calculate partial derivatives in the case where we use a cubic\nequation to compute the shape factors, and where we use the\nconventional mixing rules for $D$ and $B$. Note that they choice of\n$\\alpha$ in the cubic equation can be anything.\n\nLet us sum up the relevant formulas once more. The principle of\ncorresponding states tells us that given a mixture in the state\n$(T,V,\\mbn)$, we have that\n\\begin{equation}\n  A^r(T,V,\\mbn) = \\hat F M(T_0,v_0),\n\\end{equation}\nwhere $(T_0,v_0)$ is the reference state, defined as\n\\begin{equation}\n  v_0 = \\frac{V}{\\hat H}, \\qquad T_0 = \\frac{nT}{\\hat F},\n\\end{equation}\nwhere the scale factors $\\hat H$ and $\\hat F$ are given by\n\\begin{equation}\n  \\hat H = \\frac{B}{b_0}, \\qquad \\hat F = \\frac{D}{B} \\frac{b_0}{a_0(T_0)}.\n\\end{equation}\nHere $D$ and $B$ given by the van der Waals mixing rule\n\\begin{equation}\n  nB = \\sum_{i} n_i \\sum_j n_j b_{ij}\n\\end{equation}\n\\begin{equation}\n  D = \\sum_{i} n_i \\sum_j n_j a_{ij}(T)\n\\end{equation}\n$B(\\mbn)$ and $D$ are completely determined from the underlying cubic\nequation of state.\n\nWe again stress the point that $\\hH = \\hH(\\mbn)$ only depends on\ncomposition, while $\\hF = \\hF(T,\\mbn)$ only depends on temperature and\ncomposition.\n\nFirst we calculate the first and second order partial derivatives of\n$A^r(T,V,\\mbn)$ with respect to $T$, $V$ and $n_i$ in terms of the\npartial derivatives of $\\hH$ and $M$ with respect to $T$, $V$ and\n$n_i$.\n\\begin{align}\n  \\pdersub{A^r}{T}{V,\\mbn} &= \\hF_TM+\\hF M_T \\\\\n  \\pdersub{A^r}{V}{T,\\mbn} &= \\hF M_V \\\\\n  \\pdersub{A^r}{n_i}{T,V} &= \\hF_iM + \\hF M_i \\\\\n  \\pddersub{A^r}{T}{V,\\mbn} &= \\hF_{TT}M + 2\\hF_TM_T + \\hF M_{TT} \\\\\n  \\pddersub{A^r}{V}{T,\\mbn} &= \\hF M_{VV} \\\\\n  \\pdcrosssub{A^r}{n_i}{n_j}{T,V} &= \\hF_{ij}M + \\hF_i M_j + \\hF_j M_i + \\hF M_{ij} \\\\\n  \\pdcrosssub{A^r}{T}{V}{\\mbn} &= \\hF_TM_V+\\hF M_{TV} \\\\\n  \\pdcrosssub{A^r}{T}{n_i}{V} &= \\hF_{Ti}M + \\hF_i M_T + \\hF_T M_i + \\hF M_{Ti} \\\\\n  \\pdcrosssub{A^r}{V}{n_i}{T} &= \\hF_i M_V + \\hF M_{Vi}\n\\end{align}\nNext we calculate the first and second order partial derivatives of\n$M$ with respect to $T$, $V$ and $n_i$ in terms of the partial\nderivatives of $M$ with respect to $T_0$, $v_0$ and the derivatives of\n$T_0$ and $v_0$ with respect to $T$, $V$ and $n_i$.\n\\begin{align} % Double-check these.\n  M_T    &= M_{T_0}T_{0,T} \\\\\n  M_V    &= M_{v_0}v_{0,V} \\\\\n  M_i    &= M_{T_0}T_{0,i} + M_{v_0}v_{0,i} \\\\\n  M_{TT}  &= M_{T_0T_0}T_{0,T}^2 + M_{T_0}T_{0,TT} \\\\\n  M_{VV}  &= M_{v_0v_0}v_{0,V}^2 + M_{v_0}v_{0,VV} \\\\\n  M_{ij}  &= M_{T_0T_0}T_{0,i}T_{0,j} + M_{T_0}T_{0,ij} + M_{v_0v_0}v_{0,i}v_{0,j} \\\\\n  &+ M_{v_0}v_{0,ij} + M_{T_0v_0}(T_{0,i}v_{0,j}+T_{0,j}v_{0,i}) \\\\\n  M_{TV}  &= M_{T_0v_0}T_{0,T}v_{0,V} \\\\\n  M_{Ti}  &= M_{T_0T_0}T_{0,T}T_{0,i} + M_{T_0v_0} T_{0,T} v_{0,i} + M_{T_0}T_{0,Ti} \\\\\n  M_{Vi} &= M_{v_0v_0}v_{0,V}v_{0,i} + M_{T_0v_0} T_{0,i} v_{0,V} +\n  M_{v_0}v_{0,Vi}\n\\end{align}\n\\subsection*{Partial derivatives of $B$ with respect to $\\mbn$}\n$$\nB_i = \\frac{\\partial}{\\partial n_i} \\lp \\frac{\\sum_i \\sum_j n_i n_j\n  b_{ij}}{n} \\rp = \\frac{\\lp 2 \\sum_j n_j b_{ij} \\rp n - \\sum_i \\sum_j\n  n_i n_j b_{ij}}{n^2} = \\frac{2 \\sum_j n_j b_{ij} -B}{n}\n$$\n$$\nB_{ij} = \\frac{\\partial^2}{\\partial n_i \\partial n_j} \\lp \\frac{2\n  \\sum_k n_k b_{ik} -B}{n} \\rp = \\frac{\\lp 2b_{ij}-B_j \\rp n - \\lp 2\n  \\sum_k n_k b_{ik} -B \\rp}{n^2} = \\frac{2b_{ij}-B_i-B_j}{n}\n$$\n\\subsection*{Partial derivatives of $\\hH$ with respect to $\\mbn$}\nWe can get the partial derivatives of $\\hH$ can be written in terms of\nthe partial derivatives of $B$:\n\\begin{equation}\n  \\hH_i = \\frac{B_i}{b_0} = \\frac{2 \\sum_j n_j b_{ij} -B}{nb_0}\n\\end{equation}\n\\begin{equation}\n  \\hH_{ij} = \\frac{B_{ij}}{b_0} = \\frac{2b_{ij}-B_i-B_j}{nb_0}\n\\end{equation}\n\\subsection*{Partial derivatives of $v_0$ with respect to $V$ and\n  $\\mbn$}\nWe now find the partial derivatives of $v_0$. To find the derivatives\nwith respect to composition, we use $\\hH v_0 = V$ to get\n$$\n\\hH_i v_0 + \\hH v_{0,i} = 0, \\qquad \\hH_{ij} v_0 + \\hH_i v_{0,j} +\n\\hH_j v_{0,i} + \\hH v_{0,ij} = 0.\n$$\nThus\n\\begin{equation}\n  \\frac{v_{0,i}}{v_0} = - \\frac{\\hH_i}{\\hH} = - \\frac{B_i}{B},\n\\end{equation}\nand\n\\begin{equation}\n  \\frac{v_{0,ij}}{v_0} = -\\frac{\\hH_{ij}}{\\hH} - \\frac{\\hH_i}{\\hH} \\frac{v_{0,j}}{v_0} - \\frac{\\hH_j}{\\hH} \\frac{v_{0,i}}{v_0} = -\\frac{B_{ij}}{B} + 2 \\frac{B_i}{B} \\frac{B_j}{B}\n\\end{equation}\nThe $V$-derivatives of $v_0$ can be found by differentiating $\\hH v_0\n= V$ with respect to $V$. This gives\n\\begin{align}\n  v_{0,V}  &= \\frac{1}{\\hH} \\\\\n  v_{0,VV} &= 0 \\\\\n  v_{0,Vi} &= -\\frac{\\hH_i}{\\hH^2} = -\\frac{B_i b_0}{B^2}\n\\end{align}\n\\subsection*{Partial derivatives of $T_0$ with respect to $T$ and\n  $\\mbn$}\nTo find the derivatives with respect to composition, we use $\\hF T_0 =\nnT$ to get\n$$\n\\hF_i T_0 + \\hF T_{0,i} = T, \\qquad \\hF_{ij} T_0 + \\hF_i T_{0,j} +\n\\hF_j T_{0,i} + \\hF T_{0,ij} = 0.\n$$\nThus\n\\begin{equation}\n  \\label{T_0i}\n  \\frac{T_{0,i}}{T_0} = \\frac{T}{\\hF T_0}- \\frac{\\hF_i}{\\hF} = \\frac1n - \\frac{\\hF_i}{\\hF},\n\\end{equation}\nand similarly we find\n\\begin{equation}\n  \\frac{T_{0,T}}{T_0} = \\frac{1}{T} - \\frac{\\hF_T}{\\hF}\n\\end{equation}\nThe second order partials are given by\n\\begin{align}\n  \\frac{T_{0,ij}}{T_0} &= -\\frac{\\hF_{ij}}{\\hF} - \\frac{\\hF_i}{\\hF} \\frac{T_{0,j}}{T_0} - \\frac{\\hF_j}{\\hF} \\frac{T_{0,i}}{T_0}, \\label{T_0ij} \\\\\n  \\frac{T_{0,Ti}}{T_0} &= -\\frac{\\hF_{Ti}}{\\hF} - \\frac{\\hF_i}{\\hF}\n  \\frac{T_{0,T}}{T_0} - \\frac{\\hF_T}{\\hF} \\frac{T_{0,i}}{T_0} + \\frac{1}{\\hF} \\label{T_0Ti} \\\\\n  \\frac{T_{0,TT}}{T_0} &= -\\frac{\\hF_{TT}}{\\hF} - 2\\frac{\\hF_T}{\\hF}\n  \\frac{T_{0,T}}{T_0}. \\label{T_0TT}\n\\end{align}\nNote that Michelsen \\cite{Michelsen07} has an error in the expression\nfor $T_{0,Ti}/T_0$, as the last term on the right hand side is missing.\n\\subsection*{Partial derivatives of $D$ with respect to $T$ and\n  $\\mbn$}\n\\begin{align}\n  D_i   &= 2 \\sum_j n_j a_{ij} \\\\\n  D_{iT} &= 2 \\sum_j n_j \\lp \\partial a_{ij}/\\partial T \\rp \\\\\n  D_{ij} &= 2a_{ij} \\\\\n  D_{T}  &= \\tfrac12 \\sum_i n_i D_{iT} \\\\\n  D_{TT} &= \\sum_i n_i \\sum_j n_j \\lp \\partial^2 a_{ij}/\\partial T^2\n  \\rp\n\\end{align}\n\\subsection*{Partial derivatives of $\\hF$ with respect to $T$ and\n  $\\mbn$}\nWe now calculate the partial derivatives for $\\hF$ with respect to\ntemperature and composition in terms of the partial derivatives of\n$D$, $\\hH$ and $a_0$. To do this differentiate $\\hF(T,\\mbn) \\hH(\\mbn)\na_0(T_0) = D(T,\\mbn)$ with respect to composition, giving\n$$\n\\hF_i \\hH a_0 + \\hF \\hH_i a_0 + \\hF \\hH a_{0,T_0} T_{0,i} = D_i = 2\n\\sum_j n_j a_{ij},\n$$\nwhich when divided by $D = \\hF \\hH a_0$ becomes\n$$\n\\frac{\\hF_i}{\\hF} + \\frac{\\hH_i}{\\hH} +\n\\frac{a_{0,T_0}}{a_{T_0}}T_{0,i}= \\frac{D_i}{D}.\n$$\nBy using the expression \\eqref{T_0i} to eliminate $T_{0,i}$, we end up\nwith\n$$\n\\frac{\\hF_i}{\\hF} \\lp 1-\\frac{a_{0,T_0}}{a_0} T_0 \\rp +\n\\frac{\\hH_i}{\\hH} + \\frac{a_{0,T_0}}{a_{T_0}}\\frac{T_0}{n} =\n\\frac{D_i}{D},\n$$\nand thus\n\\begin{equation}\n  \\frac{\\hF_i}{\\hF} = \\frac{\\frac{D_i}{D} - \\frac{B_i}{B} - \\frac{a_{0,T_0}}{a_{T_0}}\\frac{T_0}{n}}{1-\\frac{a_{0,T_0}}{a_0} T_0}.\n\\end{equation}\nSimilarly, we find\n\\begin{equation}\n  \\frac{\\hF_T}{\\hF} = \\frac{\\frac{D_T}{D} - \\frac{a_{0,T_0}}{a_{T_0}}\\frac{T_0}{T}}{1-\\frac{a_{0,T_0}}{a_0} T_0}.\n\\end{equation}\nTo derive the second order partial derivative of $\\hF$ with respect to\ncomposition we differentiate $\\hF(T,\\mbn) \\hH(\\mbn) a_0(T_0) =\nD(T,\\mbn)$ twice. This gives\n\\begin{align*}\n  &\\hF_{ij} \\hH a_0 + \\hF_i \\hH_j a_0 + \\hF_i\\hH a_{0,T_0} T_{0,j} + \\\\\n  &\\hF_{j} \\hH_i a_0 + \\hF \\hH_{ij} a_0 + \\hF \\hH_i a_{0,T_0} T_{0,j} + \\\\\n  &\\hF_j \\hH a_{0,T_0} T_{0,i} + \\hF \\hH_j a_{0,T_0} T_{0,i} + \\hF \\hH\n  (a_{0,T_0T_0} T_{0,i} T_{0,j} + a_{0,T_0} T_{0,ij}) = 2 a_{ij},\n\\end{align*}\nand dividing by $D = \\hF \\hH a_0$, we get the cleaner expression\n\\begin{equation}\n  \\label{hF_ij}\n  \\begin{aligned}\n    &\\frac{\\hF_{ij}}{\\hF} + \\frac{\\hF_i}{\\hF}\\frac{\\hH_j}{\\hH} + \\frac{\\hF_i}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,j} + \\\\\n    &\\frac{\\hF_{j}}{\\hF} \\frac{\\hH_i}{\\hH} + \\frac{\\hH_{ij}}{\\hH} + \\frac{\\hH_i}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,j} + \\\\\n    &\\frac{\\hF_j}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,i} +\n    \\frac{\\hH_j}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,i} +\n    \\frac{a_{0,T_0T_0}}{a_0} T_{0,i} T_{0,j} + \\frac{a_{0,T_0}}{a_0}\n    T_{0,ij} = \\frac{D_{ij}}{D}.\n  \\end{aligned}\n\\end{equation}\nWe similarly get\n\\begin{equation}\n  \\label{hF_Ti}\n  \\begin{aligned}\n    &\\frac{\\hF_{Ti}}{\\hF} + \\frac{\\hF_i}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,T} + \\\\\n    &\\frac{\\hF_{T}}{\\hF} \\frac{\\hH_i}{\\hH} + \\frac{\\hH_i}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,T} + \\\\\n    &\\frac{\\hF_T}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,i} +\n    \\frac{a_{0,T_0T_0}}{a_0} T_{0,i} T_{0,T} + \\frac{a_{0,T_0}}{a_0}\n    T_{0,Ti} = \\frac{D_{Ti}}{D},\n  \\end{aligned}\n\\end{equation}\nand\n\\begin{equation}\n  \\label{hF_TT}\n  \\frac{\\hF_{TT}}{\\hF} + \\frac{2\\hF_T}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,T} + \\frac{a_{0,T_0T_0}}{a_0} (T_{0,T})^2 + \\frac{a_{0,T_0}}{a_0} T_{0,TT} = \\frac{D_{TT}}{D}.\n\\end{equation}\n% By using equations \\eqref{T_0ij}, \\eqref{T_0Ti} and \\eqref{T_0TT},\n% we eliminate the derivatives of $T_0$ in the expressions\n% \\eqref{hF_ij}, \\eqref{hF_Ti} and \\eqref{hF_TT}, giving\n% us % for $\\hF_{ij}$, $\\hF_{iT}$ and $\\hF_{TT}$.\nBy substituting the expression for $T_{0,ij}$ into \\eqref{hF_ij}, we\nget\n\\begin{align*}\n  &\\frac{\\hF_{ij}}{\\hF} + \\frac{\\hF_i}{\\hF}\\frac{\\hH_j}{\\hH} + \\frac{\\hF_i}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,j} + \\\\\n  &\\frac{\\hF_{j}}{\\hF} \\frac{\\hH_i}{\\hH} + \\frac{\\hH_{ij}}{\\hH} + \\frac{\\hH_i}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,j} + \\\\\n  &\\frac{\\hF_j}{\\hF}\\frac{a_{0,T_0}}{a_0} T_{0,i} +\n  \\frac{\\hH_j}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,i} +\n  \\frac{a_{0,T_0T_0}}{a_0} T_{0,i} T_{0,j} + \\frac{a_{0,T_0}}{a_0} \\lp\n  -\\frac{\\hF_{ij}}{\\hF} T_0 - \\frac{\\hF_i}{\\hF} T_{0,j} -\n  \\frac{\\hF_j}{\\hF} T_{0,i} \\rp = \\frac{D_{ij}}{D},\n\\end{align*}\nand thus\n\\begin{equation}\n  \\begin{aligned}\n    \\frac{\\hF_{ij}}{\\hF} =& \\frac{ \\frac{D_{ij}}{D} - \\frac{\\hF_i}{\\hF}\\frac{\\hH_j}{\\hH} - \\frac{\\hF_{j}}{\\hF} \\frac{\\hH_i}{\\hH} - \\frac{\\hH_{ij}}{\\hH} }{1-\\frac{a_{0,T_0}}{a_0} T_0} \\\\\n    +& \\frac{-\\frac{\\hH_j}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,i} -\n      \\frac{\\hH_i}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,j} -\n      \\frac{a_{0,T_0T_0}}{a_0} T_{0,i}\n      T_{0,j}}{1-\\frac{a_{0,T_0}}{a_0} T_0}.\n  \\end{aligned}\n\\end{equation}\nWe also get\\footnote{Michelsen \\cite{Michelsen07} has an error in the\n  expression for $\\hF_{Ti}/\\hF$: he is missing the last term in\n  the numerator.}\n\\begin{equation}\n  \\begin{aligned}\n    \\frac{\\hF_{Ti}}{\\hF} =& \\frac{ \\frac{D_{iT}}{D} -\n      \\frac{\\hF_{T}}{\\hF} \\frac{\\hH_i}{\\hH} -\n      \\frac{\\hH_i}{\\hH}\\frac{a_{0,T_0}}{a_0} T_{0,T} -\n      \\frac{a_{0,T_0T_0}}{a_0} T_{0,i} T_{0,T} - \\frac{a_{0,T_0}}{a_0 \\hF}}{1-\\frac{a_{0,T_0}}{a_0} T_0}.\n  \\end{aligned}\n\\end{equation}\nand\n\\begin{equation}\n  \\begin{aligned}\n    \\frac{\\hF_{TT}}{\\hF} =& \\frac{ \\frac{D_{TT}}{D} -\n      \\frac{a_{0,T_0T_0}}{a_0} (T_{0,T})^2}{1-\\frac{a_{0,T_0}}{a_0}\n      T_0}.\n  \\end{aligned}\n\\end{equation}\n\n\\subsubsection*{Relationship between $P_0$ and $P$}\nIn general, we have\n$$\nP = -\\pdersub{A^r}{V}{T,\\mbn} + \\frac{nRT}{V}.\n$$\nUsing that $A^r(T,V,\\mbn) = \\hF M(T_0,v_0)$ we get\n\\begin{align*}\n  P &= -\\partial_V \\lp \\hF(T,\\mbn) M(T_0,v_0) \\rp + \\frac{RT}{v} \\\\\n  &= -\\hF M_{v_0} v_{0,V} + \\frac{nR(\\hF T_0/n)}{\\hH v_0} \\\\\n  &= \\frac{\\hF}{\\hH} \\lp -M_{v_0} + \\frac{RT_0}{v_0} \\rp \\\\\n  &= \\frac{\\hF}{\\hH} P_0.\n\\end{align*}\n\n\\subsubsection*{Expressing $F$ in terms of $M$}\nOften we are more interested in the reduced residual Helmholtz energy\n$F(T,V,\\mbn) = A^r(T,V,\\mbn)/RT$ than in $A^r(T,V,\\mbn)$ itself. First\nnote that since $\\hF = nT/T_0$ we get that $A^r(T,V,\\mbn) = \\hF\nM(T_0,v_0)$ is equivalent with\n$$\nF(T,V,\\mbn) = \\frac{n}{RT_0} M(T_0,v_0).\n$$\n\\begin{align}\n  \\pdersub{F}{T}{V,\\mbn} &= -\\frac{n}{RT_0^2} T_{0,T} M +\\frac{n}{RT_0} M_T \\\\\n  \\pdersub{F}{V}{T,\\mbn} &= \\frac{n}{RT_0} M_V \\\\\n  \\pdersub{F}{n_i}{T,V} &= \\lp \\frac{1}{RT_0} - \\frac{n}{RT_0^2} T_{0,i} \\rp M + \\frac{n}{RT_0} M_i \\\\\n  \\pddersub{F}{V}{T,\\mbn} &= \\frac{n}{RT_0} M_{VV} \\\\\n  \\pdcrosssub{F}{T}{V}{\\mbn} &= -\\frac{n}{RT_0^2} T_{0,T} M_V +\\frac{n}{RT_0} M_{TV} \\\\\n  \\pdcrosssub{F}{V}{n_i}{T} &= \\lp \\frac{1}{RT_0} - \\frac{n}{RT_0^2} T_{0,i} \\rp M_V + \\frac{n}{RT_0} M_{Vi} \\\\\n  \\pddersub{F}{T}{V,\\mbn} &= \\lp \\frac{2n}{RT_0^3} T_{0,T}^2 -\n  \\frac{n}{RT_0^2} T_{0,TT} \\rp M - \\frac{2n}{RT_0^2} T_{0,T} M_T +\n  \\frac{n}{RT_0} M_{TT}\n\\end{align}\n\\begin{align}\n  &\\begin{aligned}\n    \\pdcrosssub{F}{n_i}{n_j}{T,V} &= \\lp -\\frac{1}{RT_0^2} T_{0,j} - \\frac{1}{RT_0^2} T_{0,i} + \\frac{2n}{RT_0^3} T_{0,i} T_{0,j} - \\frac{n}{RT_0^2} T_{0,ij} \\rp M \\\\\n    &+ \\lp \\frac{1}{RT_0} - \\frac{n}{RT_0^2} T_{0,i} \\rp M_j + \\lp \\frac{1}{RT_0} - \\frac{n}{RT_0^2} T_{0,j} \\rp M_i + \\frac{n}{RT_0} M_{ij} \\\\\n  \\end{aligned} \\\\\n  &\\begin{aligned}\n    \\pdcrosssub{F}{T}{n_i}{V} &= \\lp -\\frac{1}{RT_0^2} T_{0,T} + \\frac{2n}{RT_0^3} T_{0,i} T_{0,T} - \\frac{n}{RT_0^2} T_{0,Ti} \\rp M \\\\\n    &+ \\lp \\frac{1}{RT_0} - \\frac{n}{RT_0^2} T_{0,i} \\rp M_T -\n    \\frac{n}{RT_0^2} T_{0,T} M_i + \\frac{n}{RT_0} M_{Ti}\n  \\end{aligned}\n\\end{align}\n\n\\section{Testing the SPUNG model}\nTo validate the implementation of the SPUNG model, various tests have\nbeen performed.\n\n\\subsection{Equivalence of cubic equations vs SPUNG with cubic reference\n  equation}\nUsing SPUNG with SRK as both shape factor equation and reference\nequation should be equivalent to using SRK directly. It is readily\nchecked that this is indeed the for the ThermoPack SPUNG implementation.\n\n\\subsection{Computing phase envelopes}\nWe compare the performance of the ThermoPack SPUNG model against\nthe TPlib SPUNG model, as well as experimental measurements. We use\nSRK as the shape equation and MBWR-32 as the reference equation The\nmixture we consider consists of $\\mathrm{CO}_2$ and $\\mathrm N_2$ at\nfixed temperature $T=240 \\, \\mathrm{K}$. The results are shown in\nFigure \\ref{fig:phaseEnv}.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/phaseEnvelope_regular.pdf}\n  \\caption{Computed and measured points on the phase envelope for the mixture\n    $\\mathrm{CO}_2-\\mathrm N_2$ at $T=240 \\, \\mathrm{K}$.}\n  \\label{fig:phaseEnv}\n\\end{figure}\n\nThe reason why there are no TPlib points on the top of the graph is\nthat the TPlib SPUNG model is not able to close the envelope. This\ndemonstrates the improved robustness of the ThermoPack library\ncompared to TPlib.\n\nSince the model is the same in TPlib and ThermoPack, the computed\npoints for TPlib should lie exactly on the computed curve for\nThermoPack. This is clearly not the case in Figure\n\\ref{fig:phaseEnv}. The reason for this is that in TPlib there is a database of interaction\nparameters $k_{ij}$ that have been optimized for the SPUNG model. They\nare given for SRK, SRK-GD and PR, and for a range of mixtures. In\nFigure \\ref{fig:phaseEnv_opt} we have plotted the same curve as in\nFigure \\ref{fig:phaseEnv}, but using the optimized interaction\nparameters in ThermoPack.\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/phaseEnvelope_optimized.pdf}\n  \\caption{The $\\mathrm{CO}_2-\\mathrm N_2$ phase envelope using\n    optimized interaction parameters.}\n  \\label{fig:phaseEnv_opt}\n\\end{figure}\nThe TPlib points fit perfectly, except one point (the second point\nfrom the left) which is an almost perfect match with with the\nexperimental measurement. The reason for this one anomaly is\nunknown. Fortunately, we have experimental data also for CO$_2$-O$_2$,\nand Figures \\ref{fig:O2reg} and \\ref{fig:O2opt} show that the\nThermoPack implementation is consistent with the TPlib\nimplementation. How much the optimized interaction parameters actually\nimprove the fit, is not known.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/phaseEnvelope_O2_regular.pdf}\n  \\caption{The $\\mathrm{CO}_2-\\mathrm O_2$ phase envelope using\n    regular interaction parameters.}\n  \\label{fig:O2reg}\n\\end{figure}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/phaseEnvelope_O2_optimized.pdf}\n  \\caption{The $\\mathrm{CO}_2-\\mathrm O_2$ phase envelope using\n    optimized interaction parameters.}\n  \\label{fig:O2opt}\n\\end{figure}\n\n\\subsection{Comparing with density measurements}\nWe compare density measurements for a mixture of $98$ \\% CO$_2$ and $2$ \\% CH$_4$ with three models: standard SRK, and SPUNG-SRK with CH$_4$ as reference component, and using respectively MBWR-19 and MBWR-32 as reference equation. The measurements are in the pressure range $2\\cdot 10^6 -- 3.5 \\cdot 10^7$ Pa, and the temperature range $225--350$ K. In Figure \\ref{SRK_density} we have plotted the deviation from the measurements (the line) and the results using SRK (the points). There are two outliers, which is probably due to the SRK density solver choosing the wrong phase. To avoid this from happening to the SPUNG calculations, the density solver which minimizes Gibbs energy was invoked when the density for the reference component was computed. The results for the SPUNG models are shown in Figure \\ref{19_density} and Figure \\ref{32_density}.\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/SRK_density.eps}\n  \\caption{Comparing measured densites with SRK-densities. The vertical distance from point to line is the deviation measured in mol/L.}\n  \\label{SRK_density}\n\\end{figure}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/MBWR19_density.eps}\n  \\caption{Comparing measured densites with SPUNG-MBWR19-densities. The vertical distance from point to line is the deviation measured in mol/L.}\n  \\label{19_density}\n\\end{figure}\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=0.7\\textwidth]{figures/MBWR32_density.eps}\n  \\caption{Comparing measured densites with SPUNG-MBWR32-densities. The vertical distance from point to line is the deviation measured in mol/L.}\n  \\label{32_density}\n\\end{figure}\n\nIt is clear that the SPUNG-MBWR models grossly outperforms SRK, and it seems like SPUNG-MBWR32 is slightly better than SPUNG-MBWR19, as is to be expected. To verify this, the absolute average (relative) deviation was computed for the datasets. The two outliers in the SRK computations were removed before the AAD was computed, as they can probably be remedied by choosing the most stable phase. The results are given in Table 4.\n\n\\begin{table}\n  \\label{aad}\n  \\centering\n  \\begin{tabular}{c | c c c}\n    &  SRK     \t&SPUNG-MBWR19 \t&SPUNG-MBWR32      \\\\\n    \\hline\n    AAD (\\%)\t        &  $6.693$     \t&$1.527$ \t&$0.867$\n  \\end{tabular}\n  \\caption{Absolute average deviation from experimental density measurements.}\n\\end{table}\n\n% \\section{Code specific notes}\n% \\subsection{Using the code}\n% We now list the routines which are publicly available from the modules\n% tpmbwr and tpmbwr\\_derivatives:\n% \\subsubsection{The tpmbwr module}\n% \\begin{itemize}\n% \\item \\textbf{subroutine initializeModel}: initializes an MBWR-19 or MBWR-32 model\n%   with the chosen component.\n% \\item \\textbf{}\n% \\end{itemize}\n% \\subsubsection{The tpmbwr\\_derivatives module}\n\n% \\subsubsection{complist is wrong after csp\\_init is called}\n% Since complist in parameters.f90 is altered each time selectEos is\n% called, it consists only of the reference component after csp\\_init has\n% been called. The reason csp\\_init calls selectEos is to obtain some\n% quantities associated with the cubic shape equation instantiated with\n% the reference component.\n\n\n\\clearpage\n\n\\begin{thebibliography}{11}\n\n\\bibitem{Aarnes13} Aarnes J.R. Implementation and testing of the\n  Lee-Kesler equation of state in ThermoPack. SINTEF Energy Research\n  internal memo, 2013.\n\n\\bibitem{Jorstad93} Jørstad, O. ``Equation of state for hydrocarbon\n  mixtures.'' Dr. Ing. dissertation, Trondheim 1993.\n\n\\bibitem{Michelsen07} Michelsen J.M. and Mollerup\n  M.L. \\textit{Thermodynamic Models: Fundamentals and Computational\n    Aspects, 2nd edition}. Tie-Line Publications, 2007.\n\n\\bibitem{GasesAndLiquids01} Poling B.E., Prausnitz J.M. and O'Connell\n  J.P. \\textit{The Properties of Gases and Liquids, 5th\n    edition}. McGraw-Hill, 2001.\n\n\\bibitem{Polt87} Polt, Axel. \\textit{Zur Beschreibung der\n    thermodynamischen Eigenschaften reiner Fluide mit ``Ertwerterten\n    BWR-Gleichungen''.} Dr. Ing. Dissertation, Kaiserslautern\n  1987. % Is this referenced?\n\n\\bibitem{Press07} Press W.H, Teukolsky S.A, Vetterling W.T and\n  Flannery B.P. \\textit{Numerical Recipes, The Art of Scientific\n    Computing, 3rd edition}. Cambridge University Press, 2007.\n\n\\bibitem{Skaugen13} Skaugen G. Implementation of Cubic EOS -- A note\n  about the alpha-parameter formulation. SINTEF Energy Research\n  internal memo, 2013.\n\n\\bibitem{Span03} Span, Roland. \\textit{Multiparameter equations of\n    state.} Springer, 2003.\n\n\\bibitem{ThermoPackDoc13} Wilhelmsen Ø., Skaugen G. and Hammer\n  M. Flexible thermodynamic workbench for CCS thermodynamics - Update\n  2013. SINTEF Energy Research internal memo, 2013.\n\n\\end{thebibliography}\n\\end{document}", "meta": {"hexsha": "be412e979d47f791a196bad0b41465abf334ad41", "size": 81920, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/memo/SPUNG/spungmemo.tex", "max_stars_repo_name": "SINTEF/Thermopack", "max_stars_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2020-10-14T07:51:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T04:59:23.000Z", "max_issues_repo_path": "doc/memo/SPUNG/spungmemo.tex", "max_issues_repo_name": "SINTEF/Thermopack", "max_issues_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2020-10-26T11:43:43.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T22:06:30.000Z", "max_forks_repo_path": "doc/memo/SPUNG/spungmemo.tex", "max_forks_repo_name": "SINTEF/Thermopack", "max_forks_repo_head_hexsha": "63c0dc82fe6f88dd5612c53a35f7fbf405b4f3f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2020-10-27T13:04:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T04:59:24.000Z", "avg_line_length": 46.6780626781, "max_line_length": 852, "alphanum_fraction": 0.6758178711, "num_tokens": 28709, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102498375401, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4035018434156473}}
{"text": "\\documentclass{emulateapj}\n\n\n% has to be before amssymb it seems\n%\\usepackage{color,hyperref}\n%\\definecolor{linkcolor}{rgb}{0,0,0.5}\n%\\hypersetup{colorlinks=true,linkcolor=linkcolor,citecolor=linkcolor,\n%            filecolor=linkcolor,urlcolor=linkcolor}\n%\\usepackage{amssymb,amsmath}\n\n\\usepackage{color}\n\\usepackage{url}\n\\usepackage{graphicx}\n\\graphicspath{{figures/}}\n\n% For Python code\n\\usepackage{listings}\n\\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}\n\\lstset{language=Python,\n        basicstyle=\\footnotesize\\ttfamily,\n        showspaces=false,\n        showstringspaces=false,\n        tabsize=2,\n        breaklines=false,\n        breakatwhitespace=true,\n        identifierstyle=\\ttfamily,\n        keywordstyle=\\bfseries\\color[rgb]{0.133,0.545,0.133},\n        commentstyle=\\color[rgb]{0.133,0.545,0.133},\n        stringstyle=\\color[rgb]{0.627,0.126,0.941},\n    }\n\n% Draft watermark:\n%\\usepackage{draftwatermark}\n%\\SetWatermarkLightness{0.9}\n%\\SetWatermarkScale{4}\n\n% Some macros\n\\newcommand{\\todo}[1]{{\\color{red} [TODO: #1]}}\n\\newcommand{\\foreign}[1]{{\\it #1}}\n\n\\newcommand{\\apriori}{\\foreign{a priori}}\n\\newcommand{\\adhoc}{\\foreign{ad hoc}}\n\\newcommand{\\etal}{\\foreign{et\\,al.}}\n\\newcommand{\\etc}{\\foreign{etc.}}\n\n\\newcommand{\\Fig}[1]{Figure~\\ref{fig:#1}}\n\\newcommand{\\fig}[1]{\\Fig{#1}}\n\\newcommand{\\figlabel}[1]{\\label{fig:#1}}\n\\newcommand{\\Eq}[1]{Equation~(\\ref{eq:#1})}\n\\newcommand{\\eq}[1]{\\Eq{#1}}\n\\newcommand{\\eqs}[2]{Equations~(\\ref{eq:#1})-(\\ref{eq:#2})}\n\\newcommand{\\eqlabel}[1]{\\label{eq:#1}}\n\\newcommand{\\Sect}[1]{Section~\\ref{sect:#1}}\n\\newcommand{\\sect}[1]{\\Sect{#1}}\n\\newcommand{\\sects}[1]{Sections~#1}\n\\newcommand{\\App}[1]{Appendix~\\ref{sect:#1}}\n\\newcommand{\\app}[1]{\\App{#1}}\n\\newcommand{\\sectlabel}[1]{\\label{sect:#1}}\n\n\\usepackage[normalem]{ulem}\n\\newcommand{\\new}[1]{{\\color{red} #1}}\n\\newcommand{\\old}[1]{{\\sout{#1}}}\n\n\n\\begin{document}\n\n\\title{Periodograms for Multiband Astronomical Time Series}\n\n\\newcommand{\\escience}{1}\n\\newcommand{\\uwastro}{2}\n\\author{Jacob T. VanderPlas\\altaffilmark{\\escience}}\n\\author{{\\v Z}eljko Ivezi{\\'c}\\altaffilmark{\\uwastro}}\n\\altaffiltext{\\escience}{eScience Institute, University of Washington}\n\\altaffiltext{\\uwastro}{Department of Astronomy, University of Washington}\n\n\n\\begin{abstract}\nThis paper introduces the {\\it multiband periodogram}, a general extension of the well-known \nLomb-Scargle approach for detecting periodic signals in time-domain data. In addition to \nadvantages of the Lomb-Scargle method such as treatment of non-uniform sampling and\nheteroscedastic errors, the multiband periodogram significantly improves period finding for randomly \nsampled multiband light curves (e.g., Pan-STARRS, DES and LSST). The light curves in \neach band are modeled as arbitrary truncated Fourier series, with the period and phase \nshared across all bands. The key aspect is the use of Tikhonov regularization which drives\nmost of the variability into the so-called base model common to all bands, while \nfits for individual bands describe residuals relative to the base model and typically require\nlower-order Fourier series. This decrease in the effective model complexity is the\nmain reason for improved performance. After a pedagogical development of the formalism\nof least-squares spectral analysis which motivates the essential features of the multiband model,\nwe use simulated light curves \nand randomly subsampled SDSS Stripe 82 data to demonstrate the superiority of this \nmethod compared to other methods from the literature, and find that this method will be able to\nefficiently determine the correct period in the majority of LSST's bright RR Lyrae stars with\nas little as six months of LSST data, a vast improvement over the years of data\nreported to be required by previous studies.\nA Python implementation of this method, along with code to fully reproduce the results\nreported here, is available on GitHub.\n\\end{abstract}\n\n\\keywords{\n    methods: data analysis ---\n    methods: statistical\n}\n\n\\section{Introduction}\n\\sectlabel{introduction}\n\nMany types of variable stars show periodic flux variability \\citep{EM2008}. Periodic variable stars are important \nboth for testing models of stellar evolution and for using such stars as distance indicators (e.g., Cepheids \nand RR Lyrae stars). One of the first and main goals of the analysis is to detect variability and to estimate the \nperiod and its uncertainty. A number of parametric and non-parametric methods have been proposed to \nestimate the period of an astronomical time series \\citep[e.g.,][and references therein]{Graham13}.\n\nThe most popular non-parametric method is the phase dispersion minimization (PDM) introduced by \\cite{PDM1978}. \nDispersion per bin is computed for binned phased light curves evaluated for a grid of trial periods. The best\nperiod minimizes the dispersion per bin.  A similar and related non-parametric method that has been recently \ngaining popularity is the Supersmoother routine \\citep{Reimann94}. It uses a running mean or running linear \nregression on the data to fit the observations as a function of phase to a range of periods. The best period \nminimizes a figure-of-merit, adopted as weighted sum of absolute residuals around the running mean. \nNeither the Supersmoother algorithm nor the PDM method require \\apriori{} knowledge of the light curve shape. \n\nThe most popular parametric method is the Lomb-Scargle periodogram, which is discussed in detail in \\sect{brief_overview}.\nThe Lomb-Scargle periodogram is related to the $\\chi^2$ for a least-square fit of a single sinusoid to data\nand can treat non-uniformly sampled time series with heteroscedastic measurement uncertainties. \nThe underlying model of the Lomb–Scargle periodogram is nonlinear in frequency and so the likelihood surface in frequency is non-convex.\nThis non-convexity is readily apparent in the many local maxima of the typical periodogram, which makes it difficult to find the maximum via standard numerical optimization routines.\nThus in practice the global \nmaximum of the periodogram is often found by a brute-force grid search \\citep[for details see, e.g.][]{ICVG2014}.\n\nA more general parametric method based on the use of continuous-time autoregressive moving average (CARMA) model\nwas recently introduced by \\citet{Kelly14}. CARMA models can also treat non-uniformly sampled time series with \nheteroscedastic measurement uncertainties, and can handle complex variability patterns. \n\nA weakness of all these standard methods is that they require homogeneous measurements -- for astronomy data, this means \nthat successive measurements must be taken through a single photometric bandpass (filter). This has not been a major\nproblem for past surveys because measurements are generally taken through a single photometric filter \n\\citep [e.g. LINEAR,][]{LINEAR1}, or nearly-simultaneously in all bands at each observation \\citep [e.g. SDSS,][]{Sesar2010}.\nFor the case of simultaneously taken multiband measurements, \\cite{Suveges12} utilized the principal component\nmethod to optimally extract the best period. Their method is essentially a multiband generalization of the well-known\ntwo-band Welch-Stetson variability index \\citep{WelchStetson1993}. Unfortunately, when data in each band are taken at\ndifferent times, such an approach in not applicable. In such cases, past studies have generally relied \non \\adhoc{} methods such as a majority vote among multiple single-band estimates of the \nperiodogram \\citep[e.g.,][]{Oluseyi12}. \n\nFor surveys that obtain multiband data one band at a time, such as Pan-STARRS \\citep{Kaiser2010} and DES \\citep{Flaugher08},\nand for future multicolor surveys such as LSST \\citep{Ivezic08LSST}, this \\adhoc{} approach is not optimal. In order to take \nadvantage of the full information content in available data, it would be desirable to have a single estimate of the periodogram \nwhich accounts for all observed data in a manner independent of assumptions about the underlying spectrum of the object.\nWe propose such a method in this paper. \n\nThe proposed method is essentially a generalization of the Lomb-Scargle method to \nmultiband case. The light curves in  each band are modeled as arbitrary truncated Fourier series, \nwith the period, and optionally the phase, shared across all bands. The key aspect enabling this approach is the use of Tikhonov regularization \n(discussed in detail in \\sect{regularization}) which drives most of the variability into the so-called {\\it base \nmodel} common to all bands, while fits for individual bands describe residuals relative to the base model \nand typically require lower-order Fourier series. This regularization-driven decrease in effective model complexity is the\nmain reason for improved performance. \n\nThe remainder of the paper is organized as follows. \\sects{2-4} offer a review of essential concepts in least squares modeling and least squares spectral analysis, as well as their relationship to common periodogram estimates:\nin \\sect{brief_overview} we provide a brief review of least-squares periodic fitting, and in \\sect{standard_least_squares} derive the matrix-based formalism for single-band least squares spectral analysis used through the rest of this work.\n\\sect{extending_periodogram} introduces several extensions and generalizations to the single-band model that the matrix formalism makes possible, including floating mean models, truncated Fourier models, and regularized models.\n\\sects{5-7} present our new developments:\nin \\sect{multiband}, we use the ideas and formalism of \\sects{2-4} to motivate the {\\it multiband periodogram}, and show some examples of its use on simulated data.\nIn \\sect{stripe82} we apply this method to measurements of 483 RR Lyrae stars first explored by \\citet[][hereafter S10]{Sesar2010}, and in \\sect{LSST} explore the performance of the method for simulated observations from the LSST survey.\nWe conclude in \\sect{discussion}.\n\n\\section{Brief Overview of Periodic Analysis}\n\\sectlabel{brief_overview}\n\nThe detection and quantification of periodicity in time-varying signals is an important area of data analysis within modern time-domain astronomical surveys.\nFor evenly-spaced data, the {\\it periodogram}, a term coined by \\citet{Schuster98}, gives a quantitative measure of the periodicity of data as a function of the angular frequency $\\omega$. For data $\\{y_k\\}_{k=1}^N$ measured at equal intervals $t_k = t_0 + k\\Delta t$, Schuster's periodogram, which measures the spectral power as a function of the angular frequency, is given by\n\\begin{equation}\n  \\eqlabel{Schuster}\n  C(\\omega) = \\frac{1}{N}\\left| \\sum_{k=1}^N y_k e^{i\\omega t_k} \\right|^2,\n\\end{equation}\nand can be computed very efficiently using the Fast Fourier Transform.\n\nBecause astronomical observing cadences are rarely so uniform, many have looked at extending the ideas behind the periodogram to work with unevenly-sampled data. Most famously, \\citet{Lomb76} and \\citet{Scargle82} extended earlier work to define the {\\it normalized periodogram}:\n\\begin{eqnarray}\n  \\eqlabel{LombScargle}\n  P_N(\\omega) = \\frac{1}{2\\,V_y}\n  \\Bigg[&\\frac{\\left[\\sum_k(y_k - \\bar{y})\\cos\\omega(t_k - \\tau)\\right]^2}\n    {\\sum_k \\cos^2\\omega(t_k - \\tau)} +\\nonumber\\\\\n   & \\frac{\\left[\\sum_k(y_k - \\bar{y})\\sin\\omega(t_k - \\tau)\\right]^2}\n    {\\sum_k \\sin^2\\omega(t_k - \\tau)}\\Bigg],\n\\end{eqnarray}\nwhere $\\bar{y}$ is the mean and $V_y$ is the variance of the data $\\{y_k\\}$, and $\\tau$ is the time-offset which orthogonalizes the model and makes $P_N(\\omega)$ independent of a translation in $t$ \\citep[see][for an in-depth discussion]{NumRec}. \\citet{Lomb76} showed that this time-offset has a deeper effect: namely, it gives $P_N$ a similar form to previous extensions of $C(\\omega)$, while leaving $P_N$ identical to the estimate of harmonic content given a least-squares fit to a single-component sinusoidal model,\n\\begin{equation}\n  \\eqlabel{SingleModel}\n  d(t) = A\\sin(\\omega t + \\phi).\n\\end{equation}\nThis long-recognized connection between spectral power and least squares fitting methods was solidified by \\citet{Jaynes87}, who demonstrated that the least-squares periodogram method is a sufficient statistic for inferences about a stationary-frequency signal in the presence of Gaussian noise. Building on this result, \\citet{Bretthorst88} explored the extension of these methods to more complicated models with multiple frequency terms, non-stationary frequencies, and other more sophisticated models within a Bayesian framework.\n\nWhile the important features of least squares frequency estimation via Lomb-Scargle periodograms have been discussed elsewhere, we will present a brief introduction to the subject in the following section.\nIn particular, we re-express the problem in a matrix-based formalism that makes clear how the basic approach motivated by \\citet{Lomb76}, \\citet{Scargle82}, and others can be extended to more sophisticated models, including the multiband periodogram proposed in this work.\n\n\n\\section{Standard Least Squares Spectral Fitting}\n\\sectlabel{standard_least_squares}\nIn this section we present a brief quantitative introduction to the least squares fitting formulation of the normalized periodogram of \\eq{LombScargle}. We denote $N$ observed data points as\n\\begin{equation}\n  D = \\{t_k, y_k, \\sigma_k\\}_{k=1}^N\n\\end{equation}\nwhere $t_k$ is the time of observation, $y_k$ is the observed value (typically a magnitude), and $\\sigma_k$ describes the Gaussian errors on each value. For notational simplicity we will assume without loss of generality that the data $y_k$ are centered such that the measurements within each band satisfy\n\\begin{equation}\n  \\eqlabel{ycentered}\n  \\frac{\\sum_k w_ky_k}{\\sum_k w_k} = 0\n\\end{equation}\nwhere the weights are $w_k = \\sigma_k^{-2}$.\nThough this assumption is essential to the simpler models presented in this section, it will become superfluous with the floating-mean models described in later sections.\n\n\\subsection{Stationary Sinusoid Model}\n\nThe normalized periodogram of \\eq{LombScargle} can be derived from the normalized $\\chi^2$ of the best-fit single-term stationary sinusoidal model given in \\eq{SingleModel}. To make the problem linear, we can re-express the model in terms of the parameter vector $\\theta = [A\\cos\\phi, A\\sin\\phi]$ so that our model is\n\\begin{equation}\n  \\eqlabel{simplemodel}\n  y(t|\\omega,\\theta) = \\theta_1\\sin(\\omega t) + \\theta_2\\cos(\\omega t).\n\\end{equation}\nFor a given $\\omega$, the maximum likelihood estimate of the parameters $\\theta$ can be found by minimizing the $\\chi^2$ of the model, which is given by\n\\begin{equation}\n  \\chi^2(\\omega) = \\sum_k \\frac{[y_k - y(t_k|\\omega,\\theta)]^2}{\\sigma_k^2}.\n\\end{equation}\nFor the single-term Fourier model, it can be shown \\citep[see, e.g.][]{ICVG2014} that\n\\begin{equation}\n  \\eqlabel{chi2PN}\n  \\chi_{min}^2(\\omega) = \\chi^2_0[1 - P_N(\\omega)]\n\\end{equation}\nwhere $P_N(\\omega)$ is the normalized periodogram given in \\eq{LombScargle}\\footnote{An important feature of the Lomb-Scargle approach is the modification of the model with the time-offset $\\tau$ tuned to orthogonalize the harmonic basis across the irregular times $\\{t_i\\}$. This orthogonalization cancels cross-terms in the expression of $\\chi^2$, greatly reducing the complexity of computing $P_N$. As discussed in footnote \\ref{footnote:ortho2}, however, this orthogonalization does not change the resulting periodogram and so it can safely be ignored for the purposes of this work.}\\label{footnote:ortho1}\nand $\\chi^2_0$ is the reference $\\chi^2$ for a constant model, which due to the assumption in \\eq{ycentered} is simply $\\chi^2_0 = \\sum_k (y_k/\\sigma_k)^2$.\n\n\n\\subsection{Matrix Formalism}\n\\sectlabel{matrix_formalism}\nA standard way of compactly expressing least squares models is via matrix expressions \\citep[See e.g.][]{Brandt1970}. Likewise,\nthe expressions related to the stationary sinusoid model can be expressed more compactly by defining the following matrices:\n\\begin{eqnarray}\nX_\\omega = \\left[\n\\begin{array}{cc}\n\\sin(\\omega t_1) & \\cos(\\omega t_1)\\\\\n\\sin(\\omega t_2) & \\cos(\\omega t_2)\\\\\n\\vdots & \\vdots \\\\\n\\sin(\\omega t_N) & \\cos(\\omega t_N)\\\\\n\\end{array}\n\\right]; \\nonumber\\\\\ny = \\left[\n\\begin{array}{c}\ny_1 \\\\\ny_2\\\\\n\\vdots \\\\\ny_N\\\\\n\\end{array}\n\\right];~~\n\\Sigma = \\left[\n\\begin{array}{cccc}\n\\sigma_1^2 & 0 &  \\cdots & 0\\\\\n0 & \\sigma_2^2 &  \\cdots & 0\\\\\n\\vdots & \\vdots &  \\ddots & \\vdots\\\\\n0 & 0 &  \\cdots & \\sigma_N^2\n\\end{array}\n\\right]\n\\end{eqnarray}\nWith these definitions, the model in \\eq{simplemodel} can be expressed as a simple linear product, $y(t|\\omega,\\theta) = X_\\omega\\theta$, and the model and reference $\\chi^2$ can be written\n\n\\begin{eqnarray}\n  \\eqlabel{LS_chi2}\n  \\chi^2(\\omega) &=& (y - X_\\omega\\theta)^T\\Sigma^{-1}(y - X_\\omega\\theta)\\\\\n  \\chi^2_0 &=& y^T \\Sigma^{-1} y\n\\end{eqnarray}\nThe expression for the normalized periodogram can be computed by finding via standard methods the value of $\\theta$ which minimizes $\\chi^2(\\omega)$, and plugging the result into \\eq{chi2PN}. This yields\n\\begin{equation}\n  \\eqlabel{LombScargle2}\n  P_N(\\omega) = \\frac{y^T\\Sigma^{-1}X_\\omega~[X_\\omega^T\\Sigma^{-1}X_\\omega]^{-1}~X_\\omega^T\\Sigma^{-1}y}{y^T\\Sigma^{-1}y}.\n\\end{equation}\nWe note that \\eq{LombScargle2} is equivalent to \\eq{LombScargle} in the homoscedastic case with $\\Sigma \\propto V_y I$.\n\\footnote{For direct comparison to the Lomb-Scargle approach, we need the equivalent of the $\\tau$ parameter which orthogonalizes the basis across the observed times $\\{t_i\\}$.\nSuch an orthogonalization is accomplished via the transformations $X_\\omega \\to X_\\omega V_\\omega$ and $\\theta \\to V_\\omega^T \\theta$, where $V_\\omega$ is the orthogonal matrix of eigenvectors of the covariance $X_\\omega^T \\Sigma^{-1} X_\\omega$.\nThe $V_\\omega$ terms straightforwardly cancel out of \\eqs{LS_chi2}{LombScargle2} and the results of this section are unchanged.\nThe general matrix formalism used here makes clear that this result applies to all the periodogram extensions mentioned in this work.\\label{footnote:ortho2}}\n\n\n\\subsection{Simple Single-band Period Finding}\n\\sectlabel{simple_period}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig01.pdf}\n  \\caption{\n    An illustration of the basic periodogram and its relationship to the single-term sinusoid model. The left panel shows the input data, while the right panels show the fit derived from the data. The upper-right panel shows the periodogram with a clear peak at the true period of 0.622 days, and the bottom-right panel shows the data as a function of the phase associated with this period. Note in the periodogram the presence of the typical aliasing effect, with power located at beat frequencies between the true period and the 1-day observing cadence (see \\sect{simple_period} for further discussion).\n  }\n  \\figlabel{basic_example}\n\\end{figure*}\n\nAs an example of the standard periodogram in action, we perform a simple single-band harmonic analysis of simulated $r$-band observations of an RR Lyrae light curve, based on empirical templates derived in S10 (\\fig{basic_example}). The observations are of a star with a period of 0.622 days, and take place on 60 random nights over a 6-month period, as seen in the left panel.\n\nThe upper-right panel shows the normalized periodogram for this source as a function of period. While the power does peak at the true period of 0.622 days, an aliasing effect is readily apparent near $P=0.38$. This additional peak is due to beat frequency between the true period $P$ and the observing cadence of $\\sim 1$ day. This beat frequency is the first in a large sequence: for nightly observations, we'd expect to find excess power at periods $P_n = P / (1 + nP)$ days, for any integer $n$. The strong alias in \\fig{basic_example} corresponds to the $n=1$ beat period $P_n=0.383$. Though it is possible to carefully correct for such aliasing by iteratively removing contributions from the estimated window function \\citep[e.g.][]{Roberts87}, we'll ignore this detail in the current work.\n\nThe lower-right panel of \\fig{basic_example} shows the maximum likelihood interpretation of this periodogram: it is a measure of the normalized $\\chi^2$ for a single-term sinusoidal model. Here we visualize the data from the left panel, but folded as a function of phase, and overplotted with the best-fit single-term model. This visualization makes it apparent that the single-term model is highly biased: RR Lyrae light curves are, in general, much more complicated than a simple sinusoid. Nevertheless, the simplistic sinusoidal model is able to recover the correct frequency to a high degree of accuracy (roughly related to the width of the peak) and significance (roughly related to the height of the peak; see \\citet{Scargle82} for details). For a more complete introduction to and discussion of the single-term normalized periodogram, refer to, e.g. \\citet{Bretthorst88} or \\citet{ICVG2014}.\n\n\\section{Generalizing the Periodogram Model}\n\\sectlabel{extending_periodogram}\nWe have shown two forms of the classic normalized periodogram: \\eq{LombScargle} and \\eq{LombScargle2}. Though the two expressions are equivalent, they differ in their utility. Because the expression in \\eq{LombScargle} avoids the explicit construction of a matrix, it can be computed very efficiently. Furthermore, through clever use of the Fast Fourier Transform, expressions of the form of \\eq{LombScargle} can be evaluated exactly for $N$ frequencies in $\\mathcal{O}[\\log{N}]$ time \\citep{Press89}.\n\nThe matrix-based formulation of \\eq{LombScargle2}, though slower than the Fourier-derived formulation, is a more general expression and allows several advantages:\n\\begin{enumerate}\n  \\item It is straightforwardly extended to heteroscedastic and/or correlated measurement noise in the data $y_k$ through appropriate modification of the {\\it noise covariance matrix} $\\Sigma$.\n  \\item It is straightforwardly extended to more sophisticated linear models by appropriately modifying the {\\it design matrix} $X_\\omega$.\n  \\item It is straightforwardly extended to include Tikhonov/L2-regularization terms (see \\sect{regularization} for more details)  by adding an appropriate diagonal term to the {\\it normal matrix} $X_\\omega^T\\Sigma^{-1}X_\\omega$.\n\\end{enumerate}\nIn the remainder of this section, we will explore a few of these modifications and how they affect the periodogram and resulting model fits.\n\n\n\\subsection{Stationary Sinusoid with Floating Mean}\n\\sectlabel{floating_mean}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig02.pdf}\n  \\caption{\n    An illustration of the effect of the floating mean model for censored data.\n    The data consist of 80 observations drawn from a sinusoidal model. To mimic a potentially damaging selection effect, all observations with magnitude fainter than 16 are removed (indicated by the light-gray points). The standard and floating-mean periodograms are computed from the remaining data; these fits are shown over the data in the left panel. Because of this biased observing pattern, the mean of the observed data is a biased estimator of the true mean. The standard fixed-mean model in this case fails to recover the true period of 0.622 days, while the floating mean model still finds the correct period.\n  }\n  \\figlabel{floating_mean}\n\\end{figure*}\n\nAs an example of one of these generalizations, we'll consider \nwhat has variously been called the {\\it Date-compensated Discrete Fourier Transform} \\citep{Ferraz-Mello81}, the {\\it floating-mean periodogram} \\citep{Cumming99}, and the {\\it generalized Lomb-Scargle method} \\citep{Zechmeister09}. Here we use the term {\\it floating-mean periodogram}. This method adjusts the classic normalized periodogram by fitting the mean of the model alongside the amplitudes:\n\\begin{equation}\n  y(t~|~\\omega, \\theta) = \\theta_0 + \\theta_1\\sin\\omega t + \\theta_2\\cos\\omega t\n\\end{equation}\nThe periodogram derived from this model can be more accurate than the standard pre-centered periodogram for certain observing cadences and selection functions, and espeically when searching for long-period varaibility or working with very few samples \\citep{Cumming99}. \\citet{Zechmeister09} detail the required modifications to the orthogonalized harmonic formalism of \\eq{LombScargle} to allow the mean to float in the model. In the matrix formalism, the modification is much more straightforward: all that is required is to add a column of ones to the $X_\\omega$ matrix before computing the power via \\eq{LombScargle2}. This column of ones corresponds to a third entry in the parameter vector $\\theta$, and acts as a uniform constant offset for all data points.\n\nFor well-sampled data, there is usually very little difference between a standard periodogram on pre-centered data and a floating-mean periodogram. Where this difference becomes important is if selection effects or observing cadences cause there to be preferentially more observations at certain phases of the light curve: a toy example demonstrating this situation is shown in \\fig{floating_mean}. The data are drawn from a sinusoid with Gaussian errors, and data with a magnitude fainter than 16 are removed to simulate an observational bias (left panel). Because of this observational bias, the mean of the observed data is a poor predictor of the true mean, causing the standard method to poorly fit the data and miss the input period (upper-right panel). The floating-mean approach is able to automatically adjust for this bias, resulting in a periodogram which readily detects the input period of 0.622 days (lower-right panel).\n\n\n\\subsection{Truncated Fourier Models}\n\\sectlabel{multiterm}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig03.pdf}\n  \\caption{\n    The model fits and periodograms for several truncated Fourier models.\n    The data are the same as those in \\fig{basic_example}. Note that\n    in addition to the previously-seen 0.38-day alias, the\n    higher-order models will generally show periodogram peaks at multiples\n    of the true fundamental frequency $P_0$: this is because for integer $n$\n    less than the number of Fourier terms in the model, $P_0$ is a higher\n    harmonic of the model at $P=nP_0$. Additionally, the increased degrees of\n    freedom in the higher-order models let them fit better at any frequency,\n    which drives up the ``background'' level in the periodogram.\n  }\n  \\figlabel{multiterm_example}\n\\end{figure*}\n\nAs mentioned above, the standard periodogram is equivalent to fitting a single-term stationary sinusoidal model to the data. A natural extension is to instead use a multiple-term sinusoidal model, with frequencies at integer multiples of the fundamental frequency \\citep[See e.g.][]{Bretthorst88}. With $N$ Fourier terms, there are $2N + 1$ free parameters, and the model is given by\n\\begin{equation}\n  y(t|\\omega,\\theta) = \\theta_0 + \\sum_{n=1}^N \\left[\\theta_{2n - 1}\\sin(n\\omega t) + \\theta_{2n}\\cos(n\\omega t)\\right].\n\\end{equation}\nBecause this model remains linear in the parameters $\\theta$, it can be easily accommodated into the matrix formalism of \\sect{matrix_formalism}. For example, an $N = 2$-term floating-mean model can be constructed by building a design matrix $X_\\omega$ with $2N + 1 = 5$ columns:\n\\begin{equation}\nX_\\omega^{(2)} = \\left[\n\\begin{array}{ccccc}\n1 & \\sin(\\omega t_1) & \\cos(\\omega t_1) & \\sin(2\\omega t_1) & \\cos(2\\omega t_1)\\\\\n1 & \\sin(\\omega t_2) & \\cos(\\omega t_2) & \\sin(2\\omega t_2) & \\cos(2\\omega t_2)\\\\\n1 & \\sin(\\omega t_3) & \\cos(\\omega t_3) & \\sin(2\\omega t_3) & \\cos(2\\omega t_3)\\\\\n\\vdots & \\vdots & \\vdots & \\vdots & \\vdots \\\\\n1 & \\sin(\\omega t_N) & \\cos(\\omega t_N) & \\sin(2\\omega t_N) & \\cos(2\\omega t_N)\\\\\n\\end{array}\n\\right]\n\\end{equation}\nComputing the power via \\eq{LombScargle2} using $X_\\omega^{(2)}$ will give the two-term periodogram. For larger $N$, more columns are added, but the periodogram can be computed in the same manner. \\fig{multiterm_example} shows a few examples of this multiterm Fourier approach as applied to the simulated RR Lyrae light curve from \\fig{basic_example}, and illustrates several important insights into the subtleties of this type of multiterm fit.\n\nFirst, we see in the right panel that all three models show a clear signal at the true period of $P_0 = 0.622$ days. The higher-order models, however, also show a a spike in power at $P_1 = 2 P_0$: the reason for this is that for and $N>1$-term model, the period $P_0$ is the first harmonic of a model with fundamental frequency $2P_0$, and the higher-order models contain the single-period result.\n\nSecond, notice that as the number of terms is increased, the general ``background'' level of the periodogram increases. This is due to the fact that the periodogram power is inversely related to the $\\chi^2$ of the fit at each frequency. A more flexible higher-order model can better fit the data at all periods, not just the true period.\nThus in general the observed power of a higher-order Fourier model will be everywhere higher than the power of a lower-order Fourier model.\n\nOne might hope that when adding terms, the correct-period model would show more of an improvement than the incorrect-period model (and thus the periodogram maximum would become more pronounced in comparison to the background), but this does not generally hold.\nConsider that in the extreme limit in which the number model parameters is equal to the number of data points, the model has enough flexibility to fit the data perfectly at {\\it every} frequency, and the resulting periodogram would be everywhere unity!\nThis can only be the case if, on average, addition of terms preferentially boosts the background level.\n\n \n\n\\subsection{Regularized Models}\n\\sectlabel{regularization}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig04.pdf}\n  \\caption{\n    The effect of regularization on a high-order model. The data is the same as\n    those in \\fig{basic_example}. We fit a 20-term truncated Fourier model to\n    the data, with and without a regularization term. Without regularization,\n    the model oscillates widely to fit the noise in the data. The\n    regularization term effectively damps the higher-order Fourier modes and\n    removes this oscillating behavior, leading to a more robust model with\n    stronger periodogram peaks.\n  }\n  \\figlabel{regularized_example}\n\\end{figure*}\n\nThe previous sections raise the question: how complicated a model should we use? We have seen that as we add more terms to the fit, the model will more closely describe the observed data.\nFor very high-order models, however, such a close fit {\\it over-fits} the data: that is, the fit is more responsive to statistical noise in the observations than to the underlying signal.\nThis can be addressed by explicitly truncating the series at some number of terms, but we can also use a {\\it regularization} term to mathematically enforce model simplicity.\n\nA regularization term is an explicit penalty on the magnitude of the model parameters $\\theta$, and can take a number of forms. For computational simplicity here we'll use an {\\it L2 regularization} -- also known as Tikhonov Regularization \\citep{Tikhonov1963} or Ridge Regression \\citep{Hoerl1970} -- which is a quadratic penalty term in the model parameters added to the $\\chi^2$. Mathematically, this is equivalent in the Bayesian framework to using a zero-mean Gaussian prior on the model parameters.\n\nWe encode our regularization in the matrix $\\Lambda = {\\rm diag}([\\lambda_1, \\lambda_2 \\cdots \\lambda_M])$ for a model with $M$ parameters, and construct a ``regularized'' $\\chi^2$:\n\\begin{equation}\n  \\eqlabel{chi2reg}\n  \\chi_\\Lambda^2(\\omega) = (y - X_\\omega\\theta)^T\\Sigma^{-1}(y - X_\\omega\\theta) + \\theta^T\\Lambda\\theta\n\\end{equation}\nMinimizing this regularized $\\chi^2$, solving for $\\theta$, and plugging into the expression for $P_N$ gives us the regularized counterpart of \\eq{LombScargle2}:\n\\begin{equation}\n  \\eqlabel{LombScargleReg}\n  P_{N,\\Lambda}(\\omega) = \\frac{y^T\\Sigma^{-1}X_\\omega~[X_\\omega^T\\Sigma^{-1}X_\\omega + \\Lambda]^{-1}~X_\\omega^T\\Sigma^{-1}y}{y^T\\Sigma^{-1}y}.\n\\end{equation}\nNotice that the effect of this regularization term is to add a diagonal penalty to the normal matrix $X_\\omega^T\\Sigma^{-1}X_\\omega$, which has the additional feature that it can correct ill-posed models where the normal matrix is non-invertible. This feature of the regularization will become important for the multiband models discussed below.\n\nIn \\fig{regularized_example}, we compare a regularized and unregularized 20-term truncated Fourier model on our simulated RR Lyrae light curve. We use $\\lambda = 0$ on the offset term, and make the penalty $\\lambda_j$ progressively larger for each harmonic component. The regularization prevents overfitting (left panel), and results in more prominent periodogram peaks (right panel).\n\n\n\\section{A Multiple-Band Model}\n\\sectlabel{multiband}\nIn this section we will combine the ideas of the previous sections to construct the {\\it multiband periodogram} which flexibly accounts for heterogeneous sources of data for a single object.\nTo start with, we might consider one of two na{\\\"i}ve approaches to the multi-band problem:\n\nFirst, we might ignore band labels entirely and simply compute a single standard Lomb-Scargle periodogram over the full dataset. This amounts to the assumption that one global model suitably fits each band, and in practice will perform poorly due to the astrophysical variability between bands: in other words, the model is too simple and under-fits the data.\n\nSecond, we might treat each band entirely independently and compute a standard Lomb-Scargle periodogram on each, and use the additivity of $\\chi^2$ along with \\eq{chi2PN} to construct a multiband periodogram. This amounts to the assumption that the bands have completely independent phases and amplitudes, and has too many free parameters to be useful in most cases of interest. In other words, the model is too complex and over-fits the data (see \\sect{relationship} for further discussion).\n\nTo compute a periodogram which strikes a balance between these two extremes, we will take advantage of the easy extensibility of the matrix formalism which led to our generalizations above.\nThe multiband model presented here contains the following features:\n\\begin{enumerate}\n\\item An $N_{base}$-term truncated Fourier ``base model'' which models the shared variability among all $K$ observed bands. \n  \\item A set of $N_{band}$-term truncated Fourier fits, each of which models the residual within a single band from the shared variability accounted for in the base model.\n\\end{enumerate}\nThe total number of parameters for $K$ bands is then $M_K = (2N_{base} + 1) + K(2N_{band} + 1)$. As a result, for each band $k$ we have the following model of the observed magnitudes:\n\\begin{eqnarray}\n  \\eqlabel{multiband_model}\n  &y_k(t|\\omega,\\theta) =\n  \\theta_0 + \\sum_{n=1}^{N_{base}} \\left[\\theta_{2n - 1}\\sin(n\\omega t) + \\theta_{2n}\\cos(n\\omega t)\\right] +&\\nonumber\\\\ \n  &\\theta^{(k)}_0 + \\sum_{n=1}^{N_{band}} \\left[\\theta^{(k)}_{2n - 1}\\sin(n\\omega t) + \\theta^{(k)}_{2n}\\cos(n\\omega t)\\right].&\n\\end{eqnarray}\nThe important feature of this model is that {\\it all bands} share the same base parameters $\\theta$, while their offsets $\\theta^{(k)}$ are determined individually.\nNote the potential for confusion: $N_{band}$ here is not the number of observed bands, but the number of Fourier components fit to the residuals in each of the $K$ observed bands.\n\nWe can construct the normalized periodogram for this model by building a sparse design matrix with $M_K$ columns. Each row corresponds to a single observation through a single band. Columns corresponding to the base model and the matching observation band will have nonzero entries; all other columns will be filled with zeros. For example, the $(N_{base},N_{band})=(1,0)$ model corresponds to one with a simple single-term periodic base frequency, and an independent constant offset term in each band. The associated design matrix depends on the particular data, but will look similar to this:\n\\begin{equation}\nX_\\omega^{(1,0)} = \\left[\n\\begin{array}{cccccccc}\n1 & \\sin(\\omega t_1) & \\cos(\\omega t_1) & 1 & 0 & 0 & 0 & 0\\\\\n1 & \\sin(\\omega t_2) & \\cos(\\omega t_2) & 0 & 0 & 0 & 0 & 1\\\\\n1 & \\sin(\\omega t_3) & \\cos(\\omega t_3) & 0 & 0 & 0 & 1 & 0\\\\\n\\vdots & \\vdots & \\vdots & & & \\vdots & &\\\\\n1 & \\sin(\\omega t_N) & \\cos(\\omega t_N) & 0 & 0 & 1 & 0 & 0\\\\\n\\end{array}\n\\right]\n\\end{equation}\nHere the nonzero entries of the final five columns are binary flags indicating the $(u, g, r, i, z)$-band of the given observation: for this example, the first row is a $u$-band measurement, the second is a $z$-band, the third is a $i$-band, etc., as indicated by the position of the nonzero matrix element within the row.\n\nOn examination of the above matrix, it's clear that the columns are not linearly independent (i.e. $X_\\omega$ is low-rank), and thus the parameters of the best-fit model will be degenerate.\nIntuitively, this is due to the fact that if we add an overall offset to the base model, this can be perfectly accounted for by subtracting that same offset from each residual model.\nMathematically, the result of this is that the normal matrix $X_\\omega^T\\Sigma^{-1}X_\\omega$ will be non-invertible, and thus the periodogram is ill-defined.\nIn order to proceed, then, we'll either have to use a different model, or use a cleverly-constructed regularization term on one of the offending parameters.\n\nWe'll choose the latter here, and regularize all the band columns while leaving the base columns un-regularized: for the above $X_\\omega$ matrix, this regularization will look like\n\\begin{equation}\n  \\Lambda^{(1,0)} = {\\rm diag}([0, 0, 0, \\lambda, \\lambda, \\lambda, \\lambda, \\lambda])\n\\end{equation}\nwhere $\\lambda$ controls the degree of regularization. As $\\lambda$ grows large, the model will preferentially push power into the base terms, while minimizing the deviations of the model for each individual band.\n\nHere we will choose $\\lambda$ to be some small fraction of the trace of the normal matrix $[X_\\omega^T\\Sigma^{-1}X_\\omega]$.\nThis choice ensures the multiband periodogram is well-defined, while maintaining the flexibility of the model in accounting for independent band-to-band variation. With this regularization in place, the model is well-posed and \\eq{LombScargleReg} can be used to straightforwardly compute the power. The effective number of free parameters for such a regularized $(N_{base}, N_{band})$ model with $K$ filters is\n$M_K^{eff} = 2N_{base}^{eff} + K(2N_{band} + 1)$ where $N_{base}^{eff} = \\max(0, N_{base} - N_{band})$ is the effective number of base terms.\n\nThe final remaining piece to mention is our assumption in \\eq{ycentered} that the data are centered. This is required so that the simple form of the reference $\\chi^2_0$ remains valid. For the multiband model, this assumption requires that the data satisfy \\eq{ycentered} {\\it within each band}: equivalently, we could lift this assumption and compute the reference $\\chi^2_0$ of the multiband model with an independent floating mean within each band; the results will be identical.\n\nThis multiband approach, then, actually comprises a set of models indexed by their value of $N_{base}$ and $N_{band}$. The most fundamental models have $(N_{base}, N_{band}) = (1,0)$ and $(0,1)$, which we'll call the {\\it shared-phase} and {\\it multi-phase} models respectively. In the shared-phase model, all variability is assumed to be shared between the bands, with only the fixed offset between them allowed to float. In the multi-phase model, each band has independent variability around a shared fixed offset.\n\n\\subsection{Relationship of Multiband and Single-band approaches}\n\\sectlabel{relationship}\nWith this formalism in place, we can return briefly to the na{\\\"i}ve models discussed at the beginning of \\sect{multiband}.\nThe first, which ignores band information, is simply a standard Lomb-Scargle over the heterogeneous data.\nThe second, in which each band is fit independently, turns out to be equivalent to the $(N_{base},N_{band})=(0,1)$ model defined above.\nHere the base model is a simple global offset which is degenerate with the offsets in each band, so that the design matrix $X_\\omega$ can be straightforwardly rearranged as block-diagonal.\nA block-diagonal design matrix in a linear model indicates that components of the model are being solved independently: here these independent components amount to the single-band floating-mean model from \\sect{floating_mean}, fit independently for each of the $K$ bands.\n\nFor band $k$, we'll denote the single-band floating-mean periodogram as\n\\begin{equation}\n  P_N^{(k)}(\\omega) = 1 - \\frac{\\chi^2_{min, k}(\\omega)}{\\chi^2_{0,k}}\n\\end{equation}\nThe full multiband periodogram is given by\n\\begin{equation}\n  P_N^{(0,1)}(\\omega) = 1 - \\frac{\\sum_{k=1}^K\\chi^2_{min, k}(\\omega)}{\\sum_{k=1}^K\\chi^2_{0,k}}\n\\end{equation}\nand it can be shown straightforwaredly that $P_N^{(0,1)}$ can be constructed as a weighted sum of $P_N^{(k)}$:\n\\begin{equation}\n  P_N^{(0,1)}(\\omega) = \\frac{\\sum_{k=1}^K\\chi^2_{0,k}P_N^{(k)}}{\\sum_{k=1}^K\\chi^2_{0,k}}.\n\\end{equation}\nThus the $(N_{base},N_{band})=(0,1)$  multiband periodogram is identical to a weighted sum of standard periodograms in each band, where the weights $\\chi^2_{0,k}$ are a reflection of both the number of measurements in each band and how much those measurements deviate from a simple constant reference model.\n\n\\subsection{Multiband Periodogram for Simulated Data}\n\\sectlabel{Simulated}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig05a.pdf}\n  \\includegraphics[width=\\textwidth]{fig05b.pdf}\n  \\caption{\n    An illustration of the performance of the multiband periodogram. The\n    upper panels show simulated $ugriz$ observations of an RR Lyrae light\n    curve in which all 5 bands are observed each night. With 60 observations\n    in each band, a periodogram computed from any single band is sufficient to\n    determine the true period of 0.622 days. The lower panels show the same\n    data, except with only a single $ugriz$ band observed each night (i.e.\n    12 observations per band). In this case, no single band has enough\n    information to detect the period. The shared-phase multiband approach\n    of \\sect{multiband} (lower-right panel) combines the information from\n    all five bands, and results in a significant detection of the true period.\n    This indicates that while methods based on the standard periodogram are\n    suitable for densely-sampled multiband data, the multiband periodogram\n    is superior for sparsely-sampled multiband observations.\n  }\n  \\figlabel{multiband_sim}\n\\end{figure*}\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{fig06.pdf}\n  \\caption{\n    Comparison of the periodograms produced by various multiband models.\n    The data is the same as that used in \\fig{multiband_sim}. $N_{base}$ gives\n    the number of Fourier terms in the base model, and $N_{band}$ gives the\n    number of Fourier terms used to fit the residuals around this model within\n    each band. The characteristics discussed with previous figures are also\n    seen here: in particular, the level of ``background noise'' in the\n    periodogram grows with the model complexity $M$,\n  } \n  \\figlabel{multiband_models}\n\\end{figure}\n\nBefore applying the multiband method to real data, we will here explore its effectiveness on a simulated RR Lyrae lightcurve.\nThe upper panels of \\fig{multiband_sim} show a multiband version of the simulated RR Lyrae light curve from \\fig{basic_example}.\nThe upper-left panel shows 60 nights of observations spread over a 6-month period, and for each night all five bands ({\\it u,g,r,i,z}) are recorded.\nUsing the typical approach from the literature, we individually compute the standard normalized periodogram within each band: the results are shown in the upper-right panel.\nThe data are well-enough sampled that a distinct period of 0.622 days can be recognized within each individual band, up to the aliasing effect discussed in \\sect{simple_period}.\nPrevious studies have made use of the information in multiple bands to choose between aliases and estimate uncertainties in determined periods \\citep[e.g.][]{Sesar2010,Oluseyi12}.\nWhile this approach is sufficient for well-sampled data, it becomes problematic when the multiband data are sparsely sampled.\n\nThe lower panels of \\fig{multiband_sim} show the same 60 nights of data, except with only a {\\it single} band observation recorded each night.\nThe lower-left panel shows the observations as a function of phase, and the lower-right panels show the periodograms derived from the data.\nWith only 12 observations for each individual band, it is clear that there is not enough data to accurately determine the period within each single band. The shared-phase $(N_{base},N_{band})=(1,0)$ multiband approach, shown in the lower-right panel, fits a single model to the full data and clearly recovers the true frequency of 0.622 days. The key result is that while methods based on the standard periodogram are suitable for densely-sampled data, the multiband periodogram is superior for sparsely-sampled multiband observations.\n\nThis shared-phase $(1,0)$ model is only one of the possible multiband options, however: \\fig{multiband_models} compares multiband fits to this data for models with various choices of $(N_{base},N_{band})$.\nWe see here many of the characteristics noted above for single-band models: as discussed in \\sect{multiterm}, increasing the number of Fourier terms leads to power at multiples of the fundamental period, and increased model complexity (roughly indexed by the effective number of free parameters $M^{eff}$) tends to increase the background level of the periodogram, obscuring significant peaks.\nFor this reason, models with $N_{base} > N_{band}$ are the most promising: they allow a flexible fit with minimal model complexity. Motivated by this, in the next section we'll apply the simplest of this class of models, the $(1, 0)$ shared-phase model, to data from the Stripe 82 of the Sloan Digital Sky Survey.\n\n\n\\section{Application to Stripe 82 RR Lyrae}\n\\sectlabel{stripe82}\nStripe 82 is a three hundred square degree equatorial region of the sky which was repeatedly imaged through multiple band-passes during phase II of the Sloan Digital Sky Survey \\citep[SDSS II, see][]{Sesar2007}.\nHere we consider the SDSS II observations of 483 RR Lyrae stars compiled and studied by S10, in which periods for these stars were determined based on empirically-derived light curve templates.\nBecause the template-fitting method is extremely computationally intensive, S10 first determined candidate periods by taking the top 5 results of the Supersmoother \\citep{Reimann94} algorithm applied to the $g$-band; template fits were then performed at each candidate period and the period with the best template fit was reported as the true period. In this section, we make use of this dataset to quantitatively evaluate the effectiveness of the multiband periodogram approach.\n\n\\subsection{Densely-sampled Multiband Data}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig07a.pdf}\n  \\includegraphics[width=\\textwidth]{fig07b.pdf}\n  \\caption{\n    Comparison of the Multiband algorithm and single-band supersmoother algorithm on 483 well-sampled RR Lyrae light curves from Stripe 82.\n    The upper panels show a representative lightcurve and periodogram fits, while the bottom panels compare the derived periods to the template-based periods reported in S10.\n    Shown for reference are the beat aliases (dotted lines) and the first harmonic alias (dashed lines): numbers along the top and right edges of the panels indicate the number of points aligned with each trend.\n    The single-band supersmoother model tends to err toward harmonic aliases, while the multiband model tends to err toward beat frequency aliases.\n    Both methods find the correct period among the top 5 significant peaks around 99\\% of the time.\n    This suggests that for densely-sampled multiband surveys, the multiband periodogram will match the results of standard methods (but see \\fig{compare_periods_reduced}).\n  } \n  \\figlabel{compare_periods}\n\\end{figure*}\n\nThe full S10 RR Lyrae dataset consists of 483 objects with an average of 55 observations in each of the five SDSS $ugriz$ bands spread over just under ten years.\nIn the upper panels of \\fig{compare_periods} we show the observed data for one of these objects, along with the periodogram derived with the single-band supersmoother model\\footnote{The supersmoother ``periodogram'' $P_{SS}$ is constructed from the minimum sum of weighted model residuals $\\bar{r}_{min}$ in analogy with \\eq{chi2PN}: $P_{SS}(\\omega) = 1 - \\bar{r}_{min}(\\omega) / \\bar{r}_0$, where $\\bar{r}_0$ is the mean absolute residual around a constant model.} and the shared-phase $(0, 1)$-multiband model.\nHere we have a case which is analogous to that shown for simulated data in the top panels of \\fig{multiband_sim}: each band has enough data to easily locate candidate peaks, the best of which is selected via the S10 template-fitting procedure.\n\nThe lower panels of \\fig{compare_periods} compare the S10 period with the best periods obtained from the 1-band supersmoother (lower-left) and from the shared-phase multiband model (lower-right). To guide the eye, the figure includes indicators of the locations of beat aliases (dotted lines) and first harmonic aliases (dashed lines) of the S10 period. Numerical results are summarized in the upper rows of Table \\ref{table:results}.\n\nThe best-fit supersmoother period matches the S10 period in 87\\% of cases (421/483), while the best-fit multiband period matches the S10 period in 79\\% of cases (382/483). The modes of failure are instructive: when the supersmoother model misses the S10 period, it tends to land on a harmonic alias (i.e. the dashed line). This is due to the flexibility of supersmoother: a doubled period spreads the points out, leading to fewer constraints in each neighborhood and thus a smaller average residual around model. In other words, the SuperSmoother tends to over-fit data which is sparsely-sampled. On the other hand, when the multiband model misses the S10 period, it tends to land on a beat alias between the S10 period and the 1-day observing cadence (i.e. the dotted lines). This is due to the fact that the single-frequency periodic model is biased, and significantly under-fits the data: it cannot distinguish residuals due to underfitting from residuals due to window function effects.\n\n In both models, the S10 period appears among the top 5 periods 99\\% of the time: $477/483$ for supersmoother, and $480/483$ for multiband.\\footnote{We might expect this correspondence to be 100\\% in the case of the $g$-band supersmoother, which was the model used in the first pass of the S10 computation. This discrepancy here is likely due to the slightly different supersmoother implementations used in S10 and in this work. Objects showing this discrepancy are those with very low signal-to-noise.} This suggests that had S10 used the multiband Lomb-Scargle rather than the supersmoother in the first pass for that study, the final results presented there would be for the most part unchanged.\n\nThe results of this subsection show that the shared-phase multiband approach is comparable to the single-band supersmoother approach for densely-sampled multiband data, although it has a tendency to get fooled by structure in the survey window. Correction for this based on the estimated window power may alleviate this (see \\citet{Roberts87} for an example of such an approach) though in practice selecting from among the top 5 peaks appears to be sufficient.\n\n\\subsection{Sparsely-sampled Multiband Data}\n\n\\begin{figure*}\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig08a.pdf}\n  \\includegraphics[width=\\textwidth]{fig08b.pdf}\n  \\caption{\n    This figure repeats the experiment shown in \\fig{compare_periods} (see caption there for description), but the data is artificially reduced to only a single-band observation on each evening, a situation reflective of the observing cadence of future large-scale surveys.\n    In this case, the single-band SuperSmoother strategy used as a first pass in S10 fails: there is simply not enough data in each band to recover an accurate period estimate. The correct period is among the top 5 candidates in fewer than 50\\% of cases.\n    The shared-phase multiband approach utilizes information from all five bands, and returns much more robust results: even with the greatly-reduced data, the true period is among the top 5 candidates in 93\\% of cases.\n    This suggests that for sparsely-sampled multiband survey data (such as that expected from LSST) the multiband periodogram will produce superior results when compared to standard methods -- see \\fig{LSST_sims}.\n  } \n  \\figlabel{compare_periods_reduced}\n\\end{figure*}\n\nAbove we saw that the multiband model is comparable to methods from the literature for densely-sampled data. Where we expect the multiband approach to gain an advantage is when the data are sparsely sampled, with data through only a single band at each observation time. To simulate this, we reduce the size of the Stripe 82 RR Lyrae dataset by a factor of 5, keeping only a single band of imaging each night: an average of 11 observations of each object per band. This is much closer to the type of data which will be available in future multiband time-domain surveys.\n\nThe upper panels of \\fig{compare_periods_reduced} show an example light curve from this reduced dataset, along with the supersmoother and multiband periodograms derived from this data. Analogously to the lower panels of \\fig{multiband_sim}, the single-band supersmoother model loses the true period within the noise, while the shared-phase multiband model still shows prominent signal near the S10 period.\n\nThe lower panels of \\fig{compare_periods_reduced} show the relationship between the S10 periods (based on the full dataset) and the periods derived with each model from this reduced dataset, and these results are summarized in the lower rows of Table \\ref{table:results}. It is clear that the supersmoother model is simply over-fitting noise with this few data points: the top period matches S10 in only 23\\% of cases (compared to 87\\% with the full dataset), and the top 5 periods contain the S10 period only 45\\% of the time. The failure mode is much less predictable as well: rather than being clustered near aliases, most of the period determinations are scattered seemingly randomly around the parameter space.\n\nWhile the multiband method performed comparably to the S10 method on dense data, it far outperforms S10 on the sparse dataset. Even with an 80\\% reduction in the number of observations, the multiband method matches the S10 period 64\\% of the time (compared to 79\\% with the full dataset), and the top 5 peaks contain the S10 period 94\\% of the time (compared to 99\\% with the full dataset). This performance is due to the fact that the multiband algorithm has relatively few parameters, but is yet able to flexibly accommodate noisy data from multiple observing bands. In particular, this suggests that with the multiterm periodogram, the S10 analysis could have been done effectively with only a small fraction of the available data. This bodes well for future surveys, where data on variable stars will be much more sparsely sampled.\n\n\n\\begin{table*}\n\\centering\n  \\caption{Period Determination from dense and sparse data (483 total)}\n  \\begin{tabular}{|l|l|l|l|l|l|l|}\n  \\hline\n   Data & Method & Match among top 5 & Top peak matches & Beat Aliases & Harmonic Aliases  \\\\\n  \\hline\\hline\n  Dense data (\\fig{compare_periods})\n  & g-band Supersmoother & 477 (98.8\\%) & 421 (87.2\\%)& 31 & 34 \\\\\n  & Multi-band Periodogram & 480 (99.4\\%) & 382 (79.1\\%) & 94 & 5 \\\\\n  \\hline\\hline\n  Sparse data (\\fig{compare_periods_reduced})\n  & g-band Supersmoother & 219 (45.3\\%) & 113 (23.4\\%) & 101 & 4 \\\\\n  & Multi-band Periodogram & 449 (93.0\\%) & 308 (63.8\\%) & 136 & 7 \\\\\n  \\hline\n  \\end{tabular}\n  \\label{table:results}\n\\end{table*}\n\n\\subsection{Potential Improvements to the Multiband Method}\nA well-known (though often unrecognized) difficulty of Lomb-Scargle-type periodograms on unevenly-sampled data is that they do not measure the power of the signal in question, but the power of the signal {\\it convolved with the observing with the survey window function}.\nFor regularly-sampled timeseries, this convolution is the source of the perfect aliasing beyond the Nyquist sampling limit; for non-regular sampling, this aliasing generally happens to some degree at {\\it all} frequencies!\nBecause of this, even a signal with a single well-defined period will result in a Lomb-Scargle periodogram with multiple maxima at locations which depend on both the underlying signal and the precise observing window.\n\nThe multiband periodogram, as a generalization of Lomb-Scargle, shares this difficulty: it tends to respond to frequency structure in the window function as well as frequency structure in the data.\nThis can be viewed as a result of the very model simplicity which causes its success in the case of sparse multiband data: it cannot disentangle bias in the model from bias due to features in the survey window.\n\nThis could potentially be accounted for by correcting for the effect of the estimated window function; one potential method for this involves estimating the deconvolution of the window power and the observed power \\citep{Roberts87}.\nIt may also be possible to propose a multiband extension of, e.g., CARMA \\citep{Kelly14} or another forward-modeling approach to detecting periodicity.\n\nAnother potentially fruitful avenue of research which we do not study here is the adjustment of the regularization terms in the model, and the application of other types of regularization to the higher-order periodogram.\nIn particular, L1 regularization (also known as Lasso regression) could lead to interesting results: L1 regularization is similar in spirit to the Tikhonov regularization discussed in \\sect{regularization}, but tends toward sparsity in the model parameters \\citep[see, e.g.][for a discussion]{ICVG2014}.\nSuch an approach could provide a useful tradeoff between model complexity and bias in the case of higher-order truncated Fourier models, though comes at a higher computational cost.\n\nAnother potentially interesting extension of the multiband case would be to define and make use of physically-motivated priors in the light-curve shape.\nThis approach could allow the model bias to be decreased without a commensurate increase in model complexity, which is what causes poor performance in the case of sparsely-sampled noisy data.\nAs an example of such a physically-motivated prior, consider that the paths of RR Lyrae stars through color-color and color-magnitude space are constrained by known astrophysical processes in the structure of the stars \\citep[e.g., see Fig. 5 in][]{Szabo2014}. Making use of this information could help break degeneracies in period determination with higher-order models.\n\n\\section{Prospects for Multiband Periodograms with LSST}\n\\sectlabel{LSST}\nPreviously, \\citet{Oluseyi12} evaluated the prospects of period finding in early LSST data, and found results which were not encouraging.\nUsing the conservative criterion of a 2/3 majority among the top single-band supersmoother periods in the $g$, $r$, and $i$ bands, they showed that, depending on spectral type, finding reliable periods for the brightest ($g \\sim 20$) RR Lyrae stars will require several years of LSST data, while periods for some of the faintest ($g \\sim 25$) stars will not be reliable with even ten years of data!\n\nOne potential remedy is to move away from general models like supersmoother and lomb-scargle to specific template-fitting methods such as those used in S10.\nIndeed, such methods perform well even for sparsely-sampled multiband data such as those from the PanSTARRS survey; the primary drawback is that such blind template fits are computationally extremely expensive: they involve nonlinear optimizations over each of several hundred candidate templates at each of tens of thousands of candidate frequencies (B. Sesar, private communication).\nThus the template-fitting method, though it can produce accurate periods, in practice requires several hours of CPU time for a well-sampled period grid for a single source (compared to several seconds for the multiband periodogram proposed here).\nNote that several hours per object is orders-of-magnitude too slow in the case of LSST; to estimate periods for a billion stars on a 1000-core machine in a year requires a compute-time budget of only 30 seconds per light curve.\n\nBecause of the computational expense of the pure template-fitting method, when working with SDSS II data S10 performed a first-pass with a single-band supersmoother to establish candidate periods, which were in turn evaluated with template-fitting approach.\nHere we show that such a hybrid strategy combining the multiband periodogram and the S10 template fits will be useful for determining periodicity of variables in early LSST data releases, greatly improving on the outlook presented in \\citet{Oluseyi12}.\n\nWe suggest the following procedure for determining periods in future multiband datasets:\n\\begin{enumerate}\n   \\item As a first pass, find a set of candidate frequencies using the multiband periodogram. This is a fast linear optimization that can be straightforwardly parallelized.\n   \\item Within these candidate frequencies, use the more costly template-fitting procedure to choose the optimal period from among the handful of candidates.\n   \\item Compute a goodness-of-fit statistic for the best-fit template to determine whether the fit is suitable; if not, then apply the template-fitting procedure across the full period range.\n\\end{enumerate}\nHere we briefly explore simulated LSST observations of RR Lyrae stars in order to gauge the effectiveness of the first step in this strategy; the effectiveness of the template-fitting step will be explored further in future work.\nRather than doing the full analysis including the final template fits, we will focus on the ability of the multiband periodogram to quickly provide suitable candidate periods under the assumption that the S10 template algorithm will then select or reject the optimal period from this set.\n\n\\subsection{LSST Simulations}\n\nWe use a simulated LSST cadence \\citep{opsim1, opsim2, opsim3} in 25 arbitrarily chosen fields\nthat are representative of the anticipated main survey temporal coverage.\nWe simulate a set of 50 RR Lyrae observations with the S10 templates, with a range of apparent magnitudes between \n$g=20$ and $g=24.5$, corresponding to bright-to-faint range of LSST main-survey observations, and with expected \nphotometric errors computed using eqs.~4--6  from \\citet{Ivezic08LSST}. \nGiven the capability of template-fitting to choose among candidate periods, we use a more relaxed period-matching criterion than in \\citet{Oluseyi12}: when evaluating the single-band supersmoother, we require that the true period is among the five periods determined independently in the $u, g, r, i, z$ bands; in the multiband case we require that the true period is among the top five peaks in the multiband periodogram.\n\n\\fig{LSST_sims} shows the fraction of stars where this period matching criterion is met as a function of $g$-band magnitude and subset of LSST data.\nThe solid lines show the multiband results; the dashed lines show the single-band supersmoother results; and the shading helps guide the eye for the sake of comparison.\nBecause of our relaxed matching criteria, even the single-band supersmoother results here are much more optimistic than the \\citet{Oluseyi12} results (compare to Figure 15 in that work): the supersmoother result here can be considered representative of a best-case scenario for \\adhoc{} single-band fits.\nWithout fail, the multiband result exceeds this best-case single-band result; the improvement is most apparent for faint stars, where the greater model flexibility of the supersmoother causes it to over-fit the noisy data.\n\nThe performance of the multiband periodogram points to much more promising prospects for science with variable stars than previously reported.\nIn particular, even with only six months of LSST data, we can expect to correctly identify the periods for over 60\\% of stars brighter than $g=22$; with the first two years of LSST observations, this increases to nearly 100\\%; with five years of data, the multiband method identifies the correct period for 100\\% of even the faintest stars.\nPart of this improvement is due to the performance of the shared-phase multiband model with noisy data, and part of this improvement is due to the relaxed period-matching constraints enabled by the hybrid approach of periodogram-based and template-based period determination.\n\n%\\todo{Say more about Brani's template fitting? Zeljko: I don't know. I would guess that fitting templates to\n%these periods will uncover the true period. However, the referee could ask how would you know in practice\n%what template to use. Thus, we'd have to try all $\\sim$400 templates from Branimir's library and hope\n%that the true period would be uncovered. Branimir has code to do that so we could ask him. Or we could \n%add this to Discussion. I am slightly more in favor of closing this question by demonstrating that it\n%can be done. What do you think?}\n\n\n% Shout-out to @OverheardOnAph from @jakevdp. I love your work.\n\n\n\\begin{figure}\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{fig09.pdf}\n  \\caption{\n    Fraction of periods correctly determined for LSST RR Lyrae as a function\n    of the length of the observing season and the mean $g$-band magnitude, for the multiband periodogram approach (method of this work; solid lines)\n    and single-band supersmoother approach \\citep[method of][dashed lines]{Oluseyi12}.\n    The multiband method is superior to the single-band supersmoother approach in all cases, and especially for the faintest objects.\n  } \n  \\figlabel{LSST_sims}\n\\end{figure}\n\n\\section{Discussion and Conclusion}\n\\sectlabel{discussion}\n\nWe have motivated and derived a multiband version of the classic Lomb-Scargle method for detecting periodicity in astronomical time-series.\nExperiments on several hundred RR Lyrae stars from the SDSS Stripe 82 dataset indicate that this method outperforms methods used previously in the literature, especially for sparsely-sampled light curves with only single bands observed each night.\nWhile there are potential areas of improvement involving corrections to window function artifacts and accounting for physically-motivated priors, the straightforward multiband model outperforms previous \\adhoc{} approaches to multiband data.\n\nLooking forward to future variable star catalogs from PanSTARRS, DES, and LSST, there are two important constraints that any analysis method must meet: the methods must be able to cope with heterogeneous and noisy observations through multiple band-passes, and the methods must be fast enough to be computable on millions or even billions of objects.\nThe multiband method, through its combination of flexibility and model simplicity, meets the first constraint: as shown above, in the case of sparsely-sampled noisy multiband data, it out-performs previous approaches to period determination.\nIt also meets the second constraint: it requires the solution of a simple linear model at each frequency, compared to a rank-based sliding-window model in the case of supersmoother, a nonlinear optimization in the case of template-fitting, and a Markov Chain Monte Carlo analysis in the case of CARMA models.\nIn our own benchmarks, we found the multiband method to be several times faster than the single-band supersmoother approach, and several orders of magnitude faster than the template fitting approach.\n\nThe strengths and weaknesses of the multiband method suggest a hybrid approach to finding periodicity in sparsely-sampled multiband data: a first pass with the fast multiband method, followed by a second pass using the more computationally intensive template-fitting method to select among these candidate periods.\nDespite pessimism in previous studies, our experiments with simulated LSST data indicate that such a hybrid approach will successfully identify periods in the majority of RR Lyrae stars brighter than $g\\sim 22.5$ in the first months of the survey, and the majority of the faintest detected stars with several years of data.\nThis finding suggests that the multiband periodogram could have an important role to play in the analysis of variable stars in future multiband surveys.\n\nWe have released a Python implementation of the multiband periodogram on GitHub, along with Python code to reproduce all results and figures in this work; this is described in \\app{gatspy}.\nAs we were finalizing this manuscript, we were made aware of a preprint of an independent exploration of a similar approach to multiband light curves \\citep{Long2014}; we discuss the similarities and differences between these two approaches in \\app{long_comparison}.\n\n{\\it Acknowledgments:} JTV is supported by the University of Washington eScience institute, including grants from the Alfred P. Sloan Foundation, the Gordon and Betty Moore Foundation, and the Washington Research Foundation. The authors thank GitHub for providing free academic accounts which were essential in the development of this work.\n\n\n\\bibliographystyle{apj}\n\\bibliography{paper}\n\n\\appendix\n\\section{Python Implementation of Multiband Periodogram}\n\\sectlabel{gatspy}\nThe algorithm outlined in this paper is available in {\\tt gatspy}, an open-source Python package for general astronomical time-series analysis\\footnote{\\url{http://github.com/astroml/gatspy/}} \\citep{gatspy}. Along with the periodogram implementation, it also contains code to download all the data used in this work. Code to reproduce this paper, including all figures, is available in a separate repository\\footnote{\\url{http://github.com/jakevdp/multiband\\_LS/}}.\n\n{\\tt gatspy} is a pure-Python package written to be compatible with both Python 2 and Python 3, and performs fast numerical computation through dependencies on {\\tt numpy} \\citep{numpy}\\footnote{\\url{http://www.numpy.org}} and {\\tt astroML} \\citep{astroML}\\footnote{\\url{http://www.astroml.org}}, which offer optimized implementations of numerical methods in Python.\n\nThe API for the module is largely influenced by that of the {\\tt scikit-learn} package \\citep{scikit-learn, sklearn_API}\\footnote{\\url{http://scikit-learn.org}}, in which models are Python class objects which can be fit to data with the \\texttt{fit()} method.\nHere is a basic example of how you can use {\\tt multiband\\_LS} to download the data used in this paper, fit a multiband model to the data, and compute the power at a few periods:\n\n\\begin{lstlisting}\nfrom gatspy.periodic import LombScargleMultiband\nimport numpy as np\n\n# Fetch the Sesar 2010 RR Lyrae data\nfrom gatspy.datasets import fetch_rrlyrae\ndata = fetch_rrlyrae()\nt, mag, dmag, filts = data.get_lightcurve(data.ids[0])\n\n# Construct the multiband model\nmodel = LombScargleMultiband(Nterms_base=0, Nterms_band=1)\nmodel.fit(t, mag, dmag, filts)\n\n# Compute power at the following periods\nperiods = np.linspace(0.2, 1.4, 1000) # periods in days\npower = model.periodogram(periods)\n\\end{lstlisting}\n\nOther models are available as well. For example, here is how you can compute the periodogram under the supersmoother model; this implementation of the supersmoother periodogram makes use of the \\texttt{supersmoother} Python package \\citep{Vanderplas2015}.\n\n\\begin{lstlisting}\nfrom gatspy.periodic import SuperSmoother\n\n# Construct the supersmoother model\nmodel = SuperSmoother()\ngband = (filts == 'g')\nmodel.fit(t[gband], mag[gband], dmag[gband])\n\n# Compute power at the given periods\npower = model.periodogram(periods)\n\\end{lstlisting}\n\nThe models in the \\texttt{gatspy} package contain many more methods, and much more functionality that what is shown here. For updates, more examples, and more information, visit \\url{http://github.com/astroml/gatspy/}.\n\n\n\\section{Comparison with Long (2014)}\n\\sectlabel{long_comparison}\nAs we were finishing this study, we learned that another group had released a preprint independently addressing the multiband periodogram case, and come up with a solution very similar to the one presented here \\citep[][hereafter LCB14]{Long2014}.\nThey present two methods, the ``Multiband Generalized Lomb-Scargle'' (MGLS) which is effectively identical to the $(1, 0)$ multi-phase model\nhere, and the ``Penalized Generalized Lomb-Scargle'' (PGLS), which is similar in spirit to our $(0, 1)$ shared-phase model.\n\nIn the PGLS model, they start with a multi-phase model, fitting independent $N=1$ term fits to each band, and apply a nonlinear regularization term which penalizes differences in the amplitude and phase. In terms of the formalism used in this work, the PGLS model minimizes a regularized $\\chi^2$ of the form\n\\begin{equation}\n  \\chi^2_{PGLS} = \\sum_{k=1}^K \\bigg[~\\chi^2_{GLS}(D^{(k)}) + J_A(A^{(k)}) + J_\\phi(\\phi^{(k)})~\\bigg].\n\\end{equation}\nwhere $K$ is the number of bands, $\\chi^2_{GLS}(D^{(k)})$ is the $\\chi^2$ of the standard floating mean model on the single-band data $D^{(k)}$, and $J_A$ and $J_\\phi$ are regularization/penalty terms which are a function of the amplitude $A^{k}$ and phase $\\phi^{(k)}$ of each model. In terms of our linear model parameters $\\theta^{(k)}$, this amplitude and phase can be expressed:\n\\begin{eqnarray}\n A^{(k)} &=& \\sqrt{(\\theta_1^{(k)})^2 + (\\theta_2^{(k)})^2}\\nonumber\\\\\n \\phi^{(k)} &=& \\arctan(\\theta_2^{(k)} / \\theta_1^{(k)})\n\\end{eqnarray}\nThe selected form of these regularization terms penalizes deviations of the amplitude and phase from a common mean between the bands; in this sense the PGLS model can be considered a conceptual mid-point between our shared-phase and multi-phase models.\nWithin the formalism proposed in the current work, such a mid-point may be alternatively attained by suitably increasing the regularization parameter $\\lambda$ used in our shared-phase model, though the precise nature of the resulting regularization will differ.\n\nComputationally, the PGLS model requires a nonlinear optimization at each frequency $\\omega$, and is thus much more expensive than the straightforward linear optimization of our shared-phase model.\nFor this reason, LCB14 proposes a clever method by which nested models are used to reduce the number of nonlinear optimizations used: essentially, by showing that the (linear) MGLS $\\chi^2$ is a lower-bound of the (non-linear) PGLS $\\chi^2$, it is possible to iteratively reduce the number of PGLS computations required to minimize the $\\chi^2$ among a grid of frequencies.\nSuch an optimization could also be applied in the case of our shared-phase model, but is not necessary here due to its already high speed.\nNevertheless, when applying the method to a very large number of light curves, as in e.g.~LSST, such a computational trick may prove very useful.\n\nGiven these important distinctions between the models proposed here and in LCB14, in future work we plan to do a detailed comparison of the two approaches to multiband model regularization.\n\n\\end{document}\n", "meta": {"hexsha": "71a153f769598a17cd42d40ac7ffd9ae5c552337", "size": 75514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "writeup/paper.tex", "max_stars_repo_name": "remram44/multiband_LS", "max_stars_repo_head_hexsha": "75aba85c3c7d47643deeabcfb15a6214cd086d61", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2015-01-17T00:23:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T04:50:34.000Z", "max_issues_repo_path": "writeup/paper.tex", "max_issues_repo_name": "remram44/multiband_LS", "max_issues_repo_head_hexsha": "75aba85c3c7d47643deeabcfb15a6214cd086d61", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2015-02-11T22:42:54.000Z", "max_issues_repo_issues_event_max_datetime": "2015-10-31T04:05:38.000Z", "max_forks_repo_path": "writeup/paper.tex", "max_forks_repo_name": "remram44/multiband_LS", "max_forks_repo_head_hexsha": "75aba85c3c7d47643deeabcfb15a6214cd086d61", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2015-02-11T22:19:32.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-29T04:50:36.000Z", "avg_line_length": 92.5416666667, "max_line_length": 990, "alphanum_fraction": 0.7796435098, "num_tokens": 18549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984445, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.40350183918145066}}
{"text": "\\chapter{The Response to Phenotypic Selection}\n\\marginnote{See \\citet{lewontin1970units}. Note that these\n  requirements are not specific to DNA, i.e. the concept of\n  evolution by natural selection is substrate independent. }\nEvolution by natural selection requires:\n\\begin{enumerate}\n\\item Variation in a phenotype\n\\item That survival is non-random with respect to this phenotypic\nvariation.\n\\item That this variation is heritable.\n\\end{enumerate}\nPoints 1 and 2 encapsulate our idea of Natural Selection, but evolution by natural\nselection will only occur if the 3rd condition is also\nmet. \\sidenote{Some people consider natural selection to only operate on heritable phenotype varation\n  and so require all three conditions to say that natural selection\n  occurs. This is mostly a semantic point, however, it is useful to be\nable to distinguish the action of selection from a possible response.} It is the\nheritable nature of variation that couples change within a generation\ndue to natural selection to change across generations (evolutionary\nchange). \\\\\n\nLet's start by thinking about the change within a generation due\nto directional selection, where selection acts to change the mean\nphenotype within a generation. For example, a decrease in mean height within a\ngeneration, due to taller organisms having a lower chance of surviving\nto reproduction than shorter organisms. Specifically, we'll denote our mean phenotype at\nreproduction by $\\mu_S$, i.e. after selection has acted, and our mean\nphenotype before selection acts by $\\mu_{BS}$. This second quantity may be hard to\nmeasure, as obviously selection acts throughout the life-cycle, so it\nmight be easier to think of this as the mean phenotype if selection\nhadn't acted. So the change in mean phenotype within a generation is $\\mu_{S} - \\mu_{BS}= S$.  \\\\\n\n\\begin{marginfigure}\n\\begin{center}\n\\includegraphics[width=\\textwidth]{figures/Response_to_sel/QT3.pdf}\n\\end{center}\n\\caption{{\\bf Top.} Distribution of a phenotype in the parental population\n  prior to selection, $V_A=V_E=1$. {\\bf Middle.} Only individuals in the top $10\\%$\n  of the phenotypic distribution are selected to reproduce; the resulting shift\n  in the phenotypic mean is $S$. {\\bf Bottom.}  Phenotypic distribution of\n  children of the selected parents; the shift in the mean phenotype is\n$R$. \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/QT3.R}}\n\\end{marginfigure}\n\nWe are interested in predicting the distribution of phenotypes in the next\ngeneration. In particular, we are interested in the mean phenotype in\nthe next generation to understand how directional selection has\ncontributed to evolutionary change. We'll denote the mean phenotype in\noffspring, i.e. the mean phenotype in the next generation before selection acts,\nas $\\mu_{NG}$. The change across generations we'll call the response\nto selection $R$ and put this equal to $\\mu_{NG}- \\mu_{BS}$. \\\\\n\n\nThe mean phenotype in the next generation is\n\\begin{equation}\n\\mu_{NG} = \\E \\left( \\E(X_{kid} | X_{mum},X_{dad}) \\right)\n\\end{equation}\nwhere the outer expectation is over possible pairs of randomly mating individuals\nwho survive to reproduce. We can use eqn. \\ref{predict_kid} to obtain\nan expression for this expectation:\n\\begin{equation}\n\\mu_{NG} = \\mu_{BS} +\n\\beta_{mid,kid} ( \\E(X_{mid}) - \\mu_{BS})\n\\end{equation}\n\n\\begin{marginfigure}\n\\begin{center}\n\\includegraphics[width=\\textwidth]{figures/Response_to_sel/Breeders_eqn.pdf}\n\\end{center}\n\\caption{A visual representation of the Breeder's equation. Regression\n  of child's phenotype on parental mid-point phenotype\n  ($V_A=V_E=1$). The parents and children of all families are shown as\n  grey or red points, However, under truncation selection, only individuals\n  with phenotypes $>1$ (red) are bred. The use of the red families\n  only results in a phenotypic shift $S$ in the parental generation,\n  which drives a shift $R$ in the offspring generation.\n  \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/QT2.R}}\n\\end{marginfigure}\n\nSo to obtain $\\mu_{NG}$ we need to compute $\\E(X_{mid})$, the expected\nmid-point phenotype of pairs of individuals who survive to\nreproduce. Well this is just the expected phenotype in the individuals\nwho survived to reproduce ($\\mu_{S}$), so\n\\begin{equation}\n\\mu_{NG} = \\mu_{BS} +\nh^2 (\\mu_S - \\mu_{BS})\n\\end{equation}\nSo we can write our response to selection as\n\\begin{equation}\nR = \\mu_{NG} -\\mu_{BS}  =\nh^2 (\\mu_S - \\mu_{BS}) = h^2 S \\label{breeders_eqn}\n\\end{equation}\nSo our response to selection is proportional to our selection\ndifferential, and the constant of proportionality is the narrow sense\nheritability. This equation is sometimes termed the Breeder's\nequation. It is a statement that the evolutionary change across\ngenerations ($R$) is proportional to the change caused by directional selection\nwithin a generation ($S$), and that the strength of this relationship is\ndetermined by the narrow sense heritability ($h^2$). \\\\\n\n%\\graham{Lost the barncle question, put it back in.}\n\n\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width= 0.6 \\textwidth]{Journal_figs/Quant_gen/Galen_flower_herit/Galen_corolla_flare.pdf} \n\\end{center}\n\\caption{The relationship between maternal and offspring corolla flare (flower\n  width) in P. viscosum. From \\citeauthor{galen:96}'s data the\n  covariance of mother and child is 1.3, while the variance of the\n  mother is 2.8. Data from \\citet{galen:96}. \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Galen_flower_herit/Gallen_analysis.R}} \\label{fig:Galen_corolla}  \n\\end{figure}\n\n\\begin{marginfigure}\n\\begin{center}\n\\includegraphics[width=0.75\\textwidth]{illustration_images/Quant_gen/Polemonium_viscosum_Galen/Polemonium_viscosum.jpg}\n\\end{center}\n\\caption{Sticky jacob's ladder ({\\it Polemonium viscosum}). \\BHLNC{Flowers of Mountain and\n    Plain (1920). Clements, E.}{https://www.biodiversitylibrary.org/page/40791993\\#page/49/mode/1up}{New York Botanical Garden, Mertz Library}\nCropped from original.}\n\\end{marginfigure}\n\n\n\\begin{question}\n\\citet{galen:96} explored selection on flower shape in\n{\\it Polemonium viscosum}.  She found that plants with larger corolla flare\nhad more bumblebee visits, which resulted in higher seed set and a\n$17\\%$ increase in corolla flare in the plants contributing to the\nnext generation. Based on the data in the caption of Figure \\ref{fig:Galen_corolla}\nwhat is the expected response in the next generation?\n\\end{question}\n\n\\begin{marginfigure}\n\\begin{center}\n\\includegraphics[width=\\textwidth]{Journal_figs/Quant_gen/Illinois_long_term_selection_corn/Illinois_LTS_breeders_eq.pdf}\n\\end{center}\n\\caption{{\\bf Top.} Phenotypic distribution of oil content in corn in\n  1897, and the individuals who were selected to breed for the next\n  generation are marked in blue.   {\\bf Bottom.} The distribution in the next generation. Data from the\n  Illinois selection experiment available \\href{https://www.ideals.illinois.edu/handle/2142/3525}{here}, \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Illinois_long_term_selection_corn/corn_LTS.R}}  \\label{Fig:Illinois_LTS_breeders_eq}\n\\end{marginfigure}\n\nIf we know $R$ and $S$ we can estimate $h^2$. Heritabilities estimated\nlike this are called `realized heritability'. Estimates of the\n`realized heritability' can readily be produced in artificial selection experiments:\n\\begin{question}\n  From the experiment shown in Figure \\ref{Fig:Illinois_LTS_breeders_eq},\n  the mean corn oil content in 1897 was $4.78$, among the $24$ individuals\nchosen to breed to for the next generation the mean was $5.2$. The\noffspring of these individuals had a mean kernel oil content of\n$5.1$. What is the narrow sense realized heritability? \n\\end{question}\n\nTo understand the genetic basis of the response to selection take a\nlook at Figure \\ref{Fig:Response_num_alleles}. The setup is the same as in our previous\nsimulation figures.\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=\\textwidth]{figures/QT3_w_genosums.pdf}\n\\end{center}\n\\caption[][4cm]{{\\bf Top.} Distribution of the number of up alleles in the parental population\n  prior to selection (red), for the selected individuals in the top\n  $10\\%$ phenotypic tail of the population (blue) {\\bf Bottom.}  The same distribution\nfor the offspring of the selected parents in the next generation\n(green). \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/QT3.R}}  \\label{Fig:Response_num_alleles}\n\\end{figure}\n The individuals who are selected to form our next generation carry\n more alleles that increase the phenotype in the current range of\n environments currently experienced by the population. The average\n individual before selection carried 100 of these `up' alleles, while the average\n individual surviving selection carries 108 `up' alleles.\n \\begin{marginfigure}[4cm]\n \\begin{center}\n   \\includegraphics[width = 0.7 \\textwidth]{illustration_images/Genetic_drift/maize/7845339168_66aa3d8ccc_z.jpg}\n \\end{center}\n \\caption{Maize ({\\it Zea mays}.) \\BHLNC{Prof. Dr. Thomé's Flora von\n   Deutschland. 1886. Thomé, O. W.}{https://www.biodiversitylibrary.org/page/12306602\\#page/669/mode/1up}{New York Botanical Garden}} \\label{fig:maize}  %é\n \\end{marginfigure}  %%possible different fig https://peerj.com/preprints/26502.pdf from Jeff's paper\n\n As individuals\n faithfully transmit their alleles to the next generation the average\n child of the selected parents carries $108$ up alleles. Note that the\n variance has changed little, the children have plenty of variation in\n their genotype, such that selection can readily drive evolution in future generations. The average frequency of an `up' allele has changed\n from $50\\%$ to $54\\%$. Gains due to selection will be stably\n inherited to future generations and can be compounded on generation\n after generation if selection pressures were to remain constant.\n\n\n\n \\subsection{The Long-Term Response to Selection}\n   \\begin{marginfigure}\n \\begin{center}\n \\includegraphics[width=\\textwidth]{Journal_figs/Quant_gen/Illinois_long_term_selection_corn/Illinois_LTS_means.pdf} \\end{center}\n \\caption[2cm]{The mean oil content of corn in the Illinois long term\n   selection experiment. Two populations were established in 1896 from\n the same inital population. Two secondary populations were\n established in 1948 where the direction of selection was reversed.\n Linear fit to the up experiment shown as a red line. Data available \\href{https://www.ideals.illinois.edu/handle/2142/3525}{here}, \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Illinois_long_term_selection_corn/corn_LTS.R}}\\label{Fig:Illinois_LTS_means}\n\\end{marginfigure}\n\nIf our selection pressure is sustained over many generations, we can\nuse our breeder's equation to predict the response. If we are willing\nto assume that our heritability does not change and we maintain a constant selection\ndifferential ($S$), then after $n$ generations our phenotype mean will have\nshifted \n\\begin{equation}\nn h^2 S\n\\end{equation}\ni.e. our population will keep up a linear response to selection.\n \\begin{figure}\n \\begin{center}\n   \\includegraphics[width=\\textwidth]{Journal_figs/Quant_gen/Illinois_long_term_selection_corn/Illinois_LTS_ggridges_distribution.pdf}\\end{center}\n \\caption[][5.5cm]{Density plots showing the phenotypic distributions of the\n   up- and down-selection populations of the Illinois long term\n   selection experiment over time. Data available\n   \\href{https://www.ideals.illinois.edu/handle/2142/3525}{here}, \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Illinois_long_term_selection_corn/corn_LTS.R}}\\label{Fig:Illinois_LTS_dists}\n \\end{figure}\nTherefore, long-term, consistent selection can drive impressive\nevolutionary change. One example of this comes from a field experiment\nin Illinois, where plant breeders have systematically selected for\nhigher and lower oil content in corn (see our previous Figure\n\\ref{Fig:Illinois_LTS_breeders_eq} for one generation of up selection). For over a century, they have taking seeds from the plants\nin the extremes of the distribution and using them to form the next\ngeneration. They have achieved impressive long-term responses, pushing\nthe population distributions well beyond their initial range (Figure\n\\ref{Fig:Illinois_LTS_dists}. For example, the oil up-selection line went from a mean oil content of\n$4.7\\%$ in 1896 to $22.1\\%$ in 2004.  They've established\ntwo secondary populations where the selection differential was reversed. In the up-selection population they have maintained an\nimpressively linear increase in oil content, shown by red line in\nFigure \\ref{Fig:Illinois_LTS_means}, but while the\nresponse is linear at first in the down line but they quickly reach\nvery low oil content.\n\n%%single episide of selection in cliff swallows https://www.jstor.org/stable/2411315?mag=driving-evolution-cliff-swallows&seq=1#metadata_info_tab_contents\n% http://mooselab.cropsci.illinois.edu/longterm.html\n% https://www.ideals.illinois.edu/handle/2142/3525\n\n\n\\begin{question} \\label{question:red_deer}\nA population of red deer were trapped on Jersey (an island off of\nEngland) during the last inter-glacial period. From the fossil record \\cite{lister:89}\nwe can see that the population rapidly adapted to their new\nconditions, perhaps due to selection for shorter reproductive times in\nthe absence of predation. Within 6,000 years they evolved from an estimated mean weight of\nthe population of 200kg to an estimated mean weight of 36kg (a 6 fold\nreduction)! You estimate that the generation time\nof red deer is 5 years and, from a current day population, that the narrow sense heritability of the\nphenotype is 0.5.\\\\\n\n \\begin{marginfigure}\n \\begin{center}\n \\includegraphics[width=\\textwidth]{illustration_images/Quant_gen/dwarf_elephant/M_exilis_skeletal.pdf} \\end{center}\n \\caption{It's not just deer that evolve to be small on islands,\n  pygmy mammoths and elephants have evolved from large mainland species\n  on numerous islands. For example, the\n   California Channel Islands were home to a dwarf mammoth until about 13,000 years\n   ago. \\newline \\noindent \\tiny{Santa\n   Rosa {\\it Mammuthus exilis}. \\href{https://en.wikipedia.org/wiki/Pygmy_mammoth\\#/media/File:M._exilis_skeletal.png}{wikimedia}, CC BY 3.0.} }\\label{Fig:Pygmy_mammoth}\n \\end{marginfigure}\n{\\bf A)}\tEstimate the mean change per generation in the mean body weight. \\\\\n\n{\\bf B)}\tEstimate the change in mean body weight caused by\nselection within a generation. State your assumptions.\\\\\n\n{\\bf C)}\tAssuming we only have fossils from the founding population and the population after 6000 years, should we assume that the calculations accurately reflect what actually occurred within our population?\n\\end{question}\n\n\nIn wild populations, selection pressures are likely rarely sustained \nfor large numbers of generations. For example, the Grants' have\nmeasured phenotypic selection in Darwin's Finches over multiple\ndecades on the island of Daphne Major. They have seen that\nselection pressures in the Medium ground-finch ({\\it Geospiza fortis})\nhave reversed a number of times over the years (Figure\n\\ref{fig:Darwins_Finches_unpred}). \n\\graham{change to selection diff}\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width= 0.8 \\textwidth]{Journal_figs/Quant_gen/Darwins_Finches_unpred/Darwins_Finches_unpred.pdf}\n\\end{center}\n\\caption[4cm]{{\\bf Top)} Mean body size of the Medium ground-finch\n  population measured each year. The 1973 $95\\%$ confidence intervals\n  are shown as horizontal bars. {\\bf Bottom)} Standardized\n  selection differentials on body size. The statistical significance of\n  the selection differentials is shown, black points are $p<0.001$ and grey $p<0.05$.\n  Data from \\citet{grant2002unpredictable} \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Darwins_Finches_unpred/Darwins_Finches_unpred.R}} \\label{fig:Darwins_Finches_unpred}  \n\\end{figure}\n\n\\begin{marginfigure}[1cm]\n\\begin{center}\n\\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/Darwins_Finch/Geospiza_fortis.png}\n\\end{center}\n\\caption{Medium ground-finch ({\\it Geospiza fortis}). \\BHLNC{The zoology of\n  the voyage of H.M.S. Beagle. Birds Part 3. (1841) Gould G. Edited by\n  Darwin, C. Illustration by Elizabeth Gould.}{https://www.flickr.com/photos/biodivlibrary/8429528265/in/album-72157632647903291/}{Natural History Museum Library, London\n}} \\label{fig:Geospiza_fortis}  \n\\end{marginfigure}\n%% Gingrich style data https://datadryad.org/resource/doi:10.5061/dryad.1tn7123?show=full\n%% https://datadryad.org/resource/doi:10.5061/dryad.7d580\n\n\n\\paragraph{Patterns of long-term phenotypic change in the wild.}\nLooking across the diversity of plants and animals we see huge changes\nin size and form, can the strengths of selection we can observe over short time periods possibly explain\nthese changes?\n\n\nTo compare phenotypic changes over various time periods we need some measure of the rate of phenotypic\nchange. \\citep{haldane1949suggestions} proposed the rate of change from\n$X_1$ to $X_2$ in time interval $\\Delta t$, measured in Millions of years, be quantified as\n\\begin{equation}\n\\frac{\\log \\left(\\nicefrac{X_2}{X_1} \\right) }{\\Delta t}  = \\frac{\\log\n  \\left(X_2 \\right) -\\log \\left(X_1 \\right)  }{\\Delta t} \n\\end{equation}\nby expressing this the log of the ratio\\sidenote{Note that here, as\n  elsewhere, $\\log$ refers the natural logarithm, i.e. $\\log$ base\n  $e$. We'll make it clear if we using $\\log$ in a different base,\n  e.g. we'll use $\\log_{10}$ for $\\log$ in base 10.}, we are looking at the\nproportional fold change, which makes sense as a\nevolutionary change of 1cm in length is more impressive if you're a\nmouse than an elephant. By putting this on a $\\log$-scale we are\nlooking at the fold relative\nchange \\citeauthor{haldane1949suggestions} called the\nunits of this measure {\\emph`the Darwin'}, with a one Darwin change\ncorresponding to a $e\\approx 2.71$\nfold change in a Million years, a two Darwin change corresponding to a\n$e^2\\approx  7.34$ fold change in a Million years and so on. \n\n\\begin{marginfigure}\n  \\begin{center}\n    \\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/dog_whelks/dog_whelks.jpg}\n\\end{center}\n\\caption{Variation in Atlantic dog whelks ({\\it Nucella lapillus}, synonym {\\it Purrpura lapukkus})\n  along the coast of Great Britain.  \\BHLNC{The Cambridge natural history, Molluscs and Brachiopods\n    (1895). Cooke AH, Shipley AE, Reed FRC.}{https://archive.org/stream/cambridgenatural03har/cambridgenatural03har\\#page/89/mode/1up}{University of Toronto - Earth Sciences Library}} \\label{fig:dg_whelks}  \n\\end{marginfigure}\n\n\n\\begin{question}\nCalculate the rate of change in body size in the Jersey red deer from\nQuestion \\ref{question:red_deer} in Darwins. Do the same for the total\nchange in corn oil content in the up lines in Figure \\ref{Fig:Illinois_LTS_means}.\n  \\end{question}\n\n\\citet{gingerich1983rates} examined the absolute rate of phenotypic\nchange in field study data and the fossil record, a dataset\nconsiderably expanded by \\citet{uyeda2011million}. In Figure\n\\ref{fig:uyeda_gingerich} each point is an observation of phenotype\nevolution. The x-axis shows the time period in years over which the\nevolutionary change was observed, the x-axis is plotted on a\n$\\log_{10}$ scale.  The y-axis shows absolute rate of phenotypic\nchange, measured in Darwins, again on a $\\log_{10}$, \n\n\\begin{figure}\n  \\begin{center}\n    \\includegraphics[width= \\textwidth]{Journal_figs/Quant_gen/Uyeda_evol_rates/Uyeda_evol_rates.pdf}\n\\end{center}\n\\caption[][4cm]{The absolute rate of phenotypic evolution, measured in\n  Darwins, plotted against the time interval over which the evolution\n  was observed. The green points show direct observations of\n  phenotypic change in historical and contemporary populations. The\n  orange dots give changes observed in the fossil record. The three\n  black dots left to right give examples from Dog whelks, our Red deer example, and  {\\it Triceratops}. Based on an original plot by\n  \\citet{gingerich1983rates} using an expanded dataset from\n  \\citet{uyeda2011million}. \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Uyeda_evol_rates/Uyeda_evol_rates.R}} \\label{fig:uyeda_gingerich}  \n\\end{figure}\nOver short timescales we see incredibly rapid evolution, note the high\nrates on the left of Figure \\ref{fig:uyeda_gingerich}.\nFor example, the first black dot from the left is a case of evolution\nover decades in dog whelks. The invasion the green crab ({\\it Carcinus maenas})\ndrove the evolution of more robust shells in Atlantic dog\nwhelk ({\\it Nucella lapillus}) in response to predation\nalong the North American coast \\citep{vermeij1982phenotypic}. The shell lip thickness of dog whelks\nin the St. Andrews, New Brunswick population had changed from 0.94mm\nto 1.44mm in just 25 years. That's a 50\\% increase, and a rate of\n17060 Darwins.  \\graham{is time interval wrong its 1920 to 1963 in\n  Vermeij. }\n\\begin{marginfigure}\n  \\begin{center}\n    \\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/Triceratops/Triceratops_phylo.png}\n\\end{center}\n\\caption{The evolution of {\\it Triceratops} from {\\it Protoceratops},\n  see\n  \\href{https://www.geol.umd.edu/~tholtz/G104/lectures/104margino.html}{here}\n  for a fun updated view of the {\\it Coronosauria} phylogeny. See\n  these\n  \\href{https://www.geol.umd.edu/~tholtz/G104/lectures/104margino.html}{figures}\n  from Holtz for an updated \\& fuller phylogeny. \\IANC{The dinosaur book : the ruling reptiles and their\n    relatives. (1951) Colbert, E.H.}{https://www.biodiversitylibrary.org/ia/bookruli00colb\\#page/86/mode/1up}{American Museum of Natural History Library}} \\label{fig:Triceratops_phyl}  \n\\end{marginfigure}\n%% http://marsh.dinodb.com/marsh/Marsh%201891%20-%20Restoration%20of%20Triceratops%20(and%20Brontosaurus).pdf Marsh original pic of Triceratops\n%https://www.geol.umd.edu/~tholtz/G104/lectures/104margino.html\n\nHowever, when we observe phenotypic evolution over longer time periods\nit is usually much\nslower. For example, the rightmost black dot in Figure\n\\ref{fig:uyeda_gingerich} shows the phenotypic evolution along the\nlineage leading to  {\\it\n  Triceratops}.   {\\it Triceratops} measured in an impressive 25.9–29.5 ft in length. They evolved from a close\nrelative of {\\it Protoceratops}, which was a bit bigger than a sheep\nat $\\sim$5.9 ft in about 7.5 million years\n\\citep{colbert1948evolution}. However, that's only a phenotypic change\nof $0.143$ Darwins, its only a roughly four fold change in millions of\nyears. These rates of change in Dinosaurs have nothing on our dog\nwhelks, or many other examples of evolution on short time scales.    %https://www.geol.umd.edu/~tholtz/G104/lectures/104margino.html\nThus evolutionary changes we can observe over short timescales \nreadily explain long term changes in quantitative phenotypes. \n\n\n\\section{Fitness and the Breeder's Equation.}\nSo directional evolution occurs as selection drives a change in\nthe mean phenotype within a generation. But precisely how does this relate to\nthe natural-selection requirement that organisms vary in their\nfitness? Some different ways of formulating the Breeder's equation\ngive us insight into the conditions for directional selection and the\nrelationship to fitness landscapes.\n\n\\subsection{Directional selection as the covariance between fitness and\nphenotype.}\nTo think more carefully about this change within a\ngeneration, let's think about a simple fitness model where our phenotype affects the\nviability of our organisms (i.e. the probability they survive to\nreproduce). The probability that an individual has a phenotype $X$\nbefore selection is $p(X=x)$, so that the mean phenotype before\nselection is\n\\begin{equation}\n\\mu_{BS} = \\E[X] =  \\int_{-\\infty}^{\\infty} x p(x) dx\n\\end{equation}\nThe probability that an organism with a phenotype $X$ survives to\nreproduce is $w(X)$, and we'll think about this as the fitness of\nour organism. The probability distribution of phenotypes in those who\ndo survive to reproduce is\n\\begin{equation}\n\\P(X | \\textrm{survive}) =  \\frac{p(x) w(x)}{\n\\int_{-\\infty}^{\\infty} p(x) w(x) dx}.\n\\end{equation}\nwhere the denominator is a normalization constant which ensures that\nour phenotypic distribution integrates to one. The denominator also\nhas the interpretation of being the mean fitness of the population,\nwhich we'll call $\\wbar$, i.e.  \n\\begin{equation}\n\\wbar =  \\int_{-\\infty}^{\\infty} p(x) w(x) dx. \\label{eqn:pheno_mean_fitness}\n\\end{equation}\nTherefore, we can write the mean phenotype in those who survive to\nreproduce as\n\\begin{equation}\n\\mu_S = \\frac{1}{\\wbar}\\int_{-\\infty}^{\\infty} x p(x) w(x) dx\n\\end{equation}\n\\begin{marginfigure}\n  \\begin{center}\n    \\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/red_deer/Red_deer.png}\n\\end{center}\n\\caption{Red deer ({\\it Cervus elaphus}). \\BHLCC{British\n    mammals. Thorburn, A. (1920)}{https://www.flickr.com/photos/biodivlibrary/21269550204}{Field Museum of Natural History Library}{2.0}} \\label{fig:red_deer}  \n\\end{marginfigure}\n\nIf we mean center the distribution of phenotypes in our population, i.e. set the phenotype before\nselection to zero, then\n\\begin{equation}\nS=\\mu_S= \\frac{1}{\\wbar}\\int_{-\\infty}^{\\infty} x p(x) w(x) dx = \\frac{1}{\\wbar}\\E \\left (X\n  w(X) \\right)\n\\end{equation}\n% if $\\mu_S=0$. \\erin{do you mean $\\mu_{BS}=0$?}\nwhere the final part follows from the fact that the integral is taking\nthe mean of $X w(X)$ over the population.\n\nAs our phenotype is mean centered ($\\E(X)=0$), we can see that $S$ has\nthe form of a covariance\\sidenote{See our math appendix Equation \\ref{eqn:def_covar} for the\ndefinition of covariance.} between our phenotype $X$ and our relative fitness\n$\\nicefrac{w(X)}{\\wbar} $. \n\\begin{equation}\n  S =  \\E \\left (X\n  \\nicefrac{w(X)}{\\wbar} \\right) =Cov \\left(X, \\nicefrac{w(X)}{\\wbar} \\right) \\label{S_covar}\n\\end{equation}\n\n  Thus our change in mean phenotype is directly a measure of the\n  covariance of our phenotype and our fitness. \n  Rewriting our breeder's\nequation using this observation we see\n\\begin{equation}\nR = \\frac{V_A}{V}  Cov \\left(X, \\nicefrac{w(X)}{\\wbar} \\right)  \n\\end{equation}\n\nwe see that the response to selection is due to the fact that our\nfitness (viability) of our organisms/parents covaries with our phenotype, and\nthat our child's phenotype covaries with our parent's phenotype. \n\n\n\\paragraph{Fitness Gradients and linear regressions}\n\nTo understand this in more detail let imagine that we calculate the\nlinear regression of an individual $i$'s mean-centered phenotype ($X_i$) on fitness ($W_i$), i.e. \n\\begin{equation}\nW_i \\sim \\beta X_i + \\wbar \\label{fitness_regression}\n\\end{equation}  \nThe best fitting slope of this regression ($\\beta$), see math appendix\naround eqn \\ref{eqn:def_linear_regression} for more on linear regression, lets call it the\n`fitness gradient', is given by\n\\begin{equation}\n  \\beta = Cov(X, \\nicefrac{w(X)}{\\wbar} )/ V  \\label{beta_covar}\n\\end{equation}\n\n  i.e. the fitness gradient is the phenotype-fitness\n covariance divided by the phenotypic variance. Using this result we can rewrite the breeder's equation as\n\\begin{equation}\nR= V_A \\beta \\label{eqn:R_beta}\n\\end{equation}\ni.e. we'll see a directional response to selection if there is a linear relationship of phenotype on fitness, and if there is additive genetic variance for the phenotype. As one example of a fitness gradient, in Figure \\ref{fig:red_deer_fitness_grad}  the lifetime reproductive success (LRS) of male Red Deer is plotted against the weight of their antlers. The red line gives the linear regression of fitness (LRS) on antler mass and the slope of this line is the fitness gradient ($\\beta$). \n\\begin{marginfigure}[2cm]\n\\begin{center}\n\\includegraphics[width= \\textwidth]{Journal_figs/Quant_gen/red_deer_selection_gradient/selection_grad_deer.pdf}\n\\end{center}\n\\caption{Lifetime reproductive success (LRS) of male Red Deer as a\n  function of their antler mass. Data from \\citet{kruuk2002antler};\n  see the paper for discussion of the complexities of equating this\n  selection gradient with the evolutionary response. \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/red_deer_selection_gradient/selection_grad_deer.R}. } \\label{fig:red_deer_fitness_grad}  \n\\end{marginfigure}\n\n\\graham{add pic of relationship between slope and S?}\n\n\\paragraph{Fisher's fundamental theorem of natural selection} \nFinally how does the mean fitness of our population evolve? \nIf we choose relative fitness to be our phenotype\n  ($X=\\nicefrac{w(X)}{\\wbar}$), then the response in fitness is\n\\begin{align}\n  R &= \\frac{V_A}{V}  Cov \\left(\\nicefrac{w(X)}{\\wbar} ,\n  \\nicefrac{w(X)}{\\wbar} \\right) = \\frac{V_A}{V} V \\nonumber\\\\\n  &=V_A\n\\end{align}\ni.e. the response to selection is equal to the additive genetic\nvariance for relative fitness. Or as Fisher put it\n\\begin{quote}\n``The rate of increase in fitness of any organism at any time is equal\nto its genetic variance in fitness at that time.'' -\\citet{fisher1930} (pg 37)\n\\end{quote}\nFisher called this `the fundamental theorem of natural\nselection'. Our proof here is just a sketch, and more formal\napproaches are needed to show it in generality. There has been much gnashing of teeth over exactly how broadly this result holds, and exactly what\nFisher meant \\citep[see ][ for a recent overview]{ewens2010gene}. \n% Ruth shaw FFTNS https://www.biorxiv.org/content/biorxiv/early/2019/04/07/601682.full.pdf\n% https://commons.wikimedia.org/wiki/File:A_guide_to_the_wild_flowers_(Plate_CXXV)_BHL23798491.jpg\n\n\\subsection{Directional Selection on Fitness Landscapes.}  \\label{section:pheno_fitness_landscapes}\n\n \\begin{figure*}\n \\begin{center}\n \\includegraphics[width= 0.8 \\textwidth]{figures/Response_to_sel/fitness_landscape_1D.pdf}\n \\end{center}\n \\caption{An example of a fitness landscape, showing the mean fitness\n   of the population ($\\wbar$) as a function of the mean phenotype of the\n   population ($\\bar{x}$. The arrows show the expected direction of movement\nof our population on the fitness landscape, with natural selection moving\nour population toward local fitness optima. The coloured bar shows the\nderivative (slope) of the mean fitness with respect to mean\nphenotype (eqn. \\eqref{eqn:pheno_fitness_landscape}). Red values are positive slopes corresponding to the population evolving\ntowards the right of the page, blue is a negative slope with the\npopulation moving to the left. } \\label{fig:fitness_landscape_1D}  \n\\end{figure*}\n\nOne common metaphor when we talk about evolution is that of a population exploring an adaptive landscape with natural selection pushing a population\ntowards higher fitness states corresponding to peaks in this landscape\n(see e.g. Figure \\ref{fig:fitness_landscape_1D}).  \\graham{Simpson/Wright.}\n\\citet{lande1976natural} found an evocative formulation of the\nBreeder's equation which aids our intuition of phenotypic fitness\nlandscapes. \\graham{need note about when this breaks down}\n\\citeauthor{lande1976natural} showed that,\nif the phenotype is\nnormally distributed, the response to\nselection ($R$) could be written in terms of the gradient (derivative) of the\nmean fitness ($\\wbar$) of the population\\sidenote[][-3cm]{\n  This follows from the fact that we can then move the\n  derivative inside the integral of $\\wbar$, eqn \\eqref{eqn:pheno_mean_fitness}, %$\\nicefrac{\\partial \\log\\wbar}{\\partial \\bar{x}} = \\nicefrac{1}{\\wbar} \\nicefrac{\\partial\\wbar}{\\partial \\bar{x}}$.\nto write the new term in eqn \\eqref{eqn:pheno_fitness_landscape} as \n  \\begin{align}\n\\frac{1}{\\wbar}  \\frac{\\partial \\wbar}{\\partial \\bar{x}} &=\n                                                                   \\frac{1}{\\wbar}\n                                                                   \\int_{-\\infty}^{\\infty}w(x)\n                               \\frac{\\partial p(x)}{\\partial \\bar{x}}  dx \\nonumber\\\\\n& =\\int_{-\\infty}^{\\infty} \\frac{w(x)}{\\wbar}  \\frac{(x-\\bar{x})}{V}  dx  \\nonumber\\\\\n                             & = \\frac{cov(w(x),x) }{var(x)} \\label{eqn:proof_landscape}\n\\end{align}\nwhich is $\\beta$, so that eqns \\eqref{eqn:R_beta} and\n\\eqref{eqn:pheno_fitness_landscape} are equivalent. For this equivalence\nto hold, in the first line we assume that $w(x)$ is not a function\nof $\\bar{x}$, while the middle line is true when $p(x)$ is the normal distribution.\n}\nas a function of the mean phenotype:  \n\\begin{equation}\n  R = \\frac{V_A}{\\wbar} \\frac{\\partial \\wbar}{\\partial \\bar{x}}  \\label{eqn:pheno_fitness_landscape}  %V_A \n % \\frac{\\partial \\log \\left(\\wbar \\right)}{\\partial \\bar{z}}\n\\end{equation}\n\nWhat does this mean? Well $\\nicefrac{V_A}{\\wbar}$ is always positive,\nso the direction our population responds to selection is\npredicted by the sign of the derivative (see Appendix Section\n\\ref{section:calculus} for more on derivatives). If increasing the mean\nphenotype of the population slightly would \nincrease mean fitness ($ \\nicefrac{\\partial \\wbar}{\\partial \\bar{x}}\n>0$) our population will respond that generation by evolving toward\nhigher values of the trait ($R>0$), left panel of Figure \\ref{fig:fitness_landscape_1D_w_wbar}. Conversely, if decreasing the\npopulation mean phenotype slightly would increase the mean fitness ($ \\nicefrac{\\partial \\wbar}{\\partial \\bar{x}}\n<0$) the population will that generation evolve towards lower values\nof the phenotype  (middle panel of Figure\n\\ref{fig:fitness_landscape_1D_w_wbar}). Thus, if selection pressures\nremain constant, we can think of the population as evolving on\nan adaptive landscape where the elevation is given by the population mean\nfitness. Natural selection operates on the basis of individual-level\nfitness, but as a result of this our population is increasing in its\naverage fitness, i.e. our population is becoming better adapted. We'll\ndiscuss the caveats of this hill-climbing interpretation below.\n\n \\begin{figure*}\n \\begin{center}\n \\includegraphics[width= 0.8 \\textwidth]{figures/Response_to_sel/fitness_landscape_1D_w_wbar.pdf}\n \\end{center}\n \\caption{A population evolving on a (guassian) fitness surface. The\n   bottom panel shows the expected individual fitness ($w()$) and mean\n   fitess as a function of phenotype. The red line shows the best\n   fitting linear approximation to the relationship between phenotype\n   and individual fitness, eqn \\eqref{fitness_regression}, whose slope is\n   $\\beta$. The top panel shows the distribution of the phenotype\n   before and after selection. \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/fitness_landscape_1D_animated.R}.} \\label{fig:fitness_landscape_1D_w_wbar}  \n \\end{figure*}\n \n\nWhat happens when it\nreaches the top of a peak? Well at the top of a peak $ \\nicefrac{\\partial\n  \\wbar}{\\partial \\bar{x}}=0$, as it is a local maximum, and so\n$R=0$. Assuming that the relationship between fitness and phenotype\nstays constant, our population will stay at the top of the fitness\npeak. This view of natural selection does not imply that the population\nis evolving to the best possible state. Our population is just\nmarching up the hill of mean fitness (end panel Figure\n\\ref{fig:fitness_landscape_1D_w_wbar}). However, this peak isn't\nnecessarily the highest fitness peak but simply whichever peak was closest. So our population can become trapped\non a local, but not global peak of fitness (see, for example Figure \\ref{fig:fitness_landscape_1D}).\n\n% % \\animategraphics[height=2.8in,autoplay,controls]{12}{/Users/gcoop/Downloads/latex_gif/animate_gall_}{0}{14}\n\n\\begin{marginfigure}[3cm]\n\\begin{center}\n\\includegraphics[width= \\textwidth]{Journal_figs/Quant_gen/Stickleback_fossil_traj/Stickleback_fossil_traj.pdf}\n\\end{center}\n\\caption{{\\bf Top)} A time series of stickleback phenotypic evolution from the\n  fossil record. After a heavily armoured stickleback invades the lake\n  it quickly evolves towards fewer touching pterygiophores (the bones\n  supporting the dorsal spines).  Fossil measurements means are\n  calculated in 250 year bins. {\\bf Bottom)} How our population moves\n  on the Inferred fitness landscape. The arrows show each move made by\n  the population in the 250 intervals. Data from\n  \\citet{bell2006inferring} and \\citet{hunt2008evolution}  \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Stickleback_fossil_traj/Stickleback_traj.R} } \\label{fig:Stickleback_fossil_traj}  \n\\end{marginfigure}\n\nOne dramatic example documenting adaptive evolution to a new\nfitness optimum is offered by a remarkable time-series of\nstickleback evolution from a fossil lake-bed in Nevada \\citep{bell2006inferring}. In this lake\nthe layers of sediment are laid down each year allowing a very detailed\ntime series with over five thousand fossils measured. The time-series\ndocuments the evolution towards a new set of optimum phenotypes in the\nfifteen thousand years after the initial invasion of the lake by a\nheavily armoured stickleback species. In Figure \\ref{fig:Stickleback_fossil_traj} the population mean number of\ntouching pterygiophores, the bones supporting the dorsal spines,\nthrough the fossil record (Figure \\ref{fig:Stickleback_fossil}). Note how quickly the species evolves toward\nits new value, presumably a fitness optimum in their new environment, and the long subsequent time interval over which\nthe population mean phenotype fluctuates about its new value.\n\\begin{marginfigure}\n \\begin{center}\n \\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/Fossil_stickleback/journal.pbio.1001466.g003.eps}\n \\end{center}\n \\caption{Fossil stickleback. Photo by Peter J. Park from \\citet{losos2013evolutionary}, \\PLOSccBY.} \\label{fig:Stickleback_fossil}  \n\\end{marginfigure}\n\n\\citet{hunt2008evolution} fitted a model of a population adapting to a\nfitness landscape, with a single peak, to these time-series data. Their fitted fitness\nsurface is shown in the lower panel of Figure \\ref{fig:Stickleback_fossil_traj} . The arrows show the moves that the\npopulation mean phenotype is making on this inferred fitness\nsurface. The population initially takes large steps up toward the peak\nof this surface and subsequently fluctuates around the peak. Under the\ninterpretation that there is a single stationary peak these\nfluctuations represent genetic drift randomly knocking the population\noff its optimum, with selection acting to restore\nthe population towards this local optimum.\n\n\n\\paragraph{Issues with the interpretation of fitness landscapes.}\nIn practice, fitness landscapes may not be constant. The environment\nmay be constantly changing so our population is constantly forced to change to keep\nup with the fitness peak. Indeed our environment may change so quickly\nthat our population cannot keep up with the peak. Our\npopulation is still trying to increase its mean fitness, to `adapt', but\nthe landscape itself is evolving.%\\sidenote[][1cm]{\n  In\nthe case of very rapid environmental change our population may slide\nfurther and further away the peak, and as a consequence its mean fitness\ndecreases which may drive the population to extinction if our\npopulation drops below $\\wbar<1$ for long enough. The conditions for\nextinction are an active area of research in the field of\n`Evolutionary rescue'. %}\nMore generally, for our fitness landscape result (eqn \\eqref{eqn:pheno_fitness_landscape}) to hold, and\nfor us to be able to talk of our population attempting to evolve to\nhigher mean fitness states,  we need the fitness of our phenotypes to be independent of the\nfrequency of other phenotypes in the population. (This independence allows us to\nassume that the fitness of individuals is not a function of the mean\nphenotype, as needed in eqn \\eqref{eqn:proof_landscape}).  The\nassumption of frequency independence may not hold when there is competition between individuals, e.g. for resources or\nmates, as then the fitness of an individual depends on the strategies pursued\nby other individuals in the populations.\n%A classic example of this is\n%the fact that sexual selection may drive our\n%population towards pursing mate choice strategies that actively lower\n%the mean fitness of the population. \n% \\graham{Thinking of a marble\n% rolling around in the bottom of a bowl\n% You could think about the\n% population phenotype as a marble rolling around  }\n\n%\\paragraph{Different populations potentially sit on top of different peaks in the fitness landscape}\n % https://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1000529\n\n \\subsection{Stabilizing and Disruptive selection}\n\nUp to now we have just looked at directional selection, where\nselection acts to change the mean phenotype. However, we\ncan also use quantitative genetic models to describe other modes of\nselection, extending from effects on the population mean the next\nnatural step is to think about selection which acts on the\npopulation variance. Selection might act more strongly against\nindividuals in the tails of the distribution, with those closer\nto the mean phenotype having higher fitness, which lowers the\nvariance. Selection could also disfavour individuals close to the\npopulation mean, with individuals with extreme phenotypes having\nhigher fitness, which acts to increase the variance of the population. \n\nDirectional selection occurs because of the covariance\nbetween our phenotype and fitness, eqn \\eqref{S_covar}. Just as expressing directional selection as a covariance allowed us to\ncharacterize directional selection as the linear relationship between\nfitness and phenotype, $\\beta$, we can summarize the variance\nreducing selection by including a quadratic term in the regression of\nfitness on phenotype\n\\begin{equation}\nw_i \\sim \\beta x_i + \\nicefrac{1}{2}  \\gamma x_i^2  + \\wbar \\label{fitness_regression_stab}\n\\end{equation}\nThis $\\gamma$, the coefficient of the quadratic term in our model, is the\nquadratic selection gradient: the covariance of fitness and the squared\ndeviation from the phenotypic mean ($\\mu_{BS}$), i.e.\n\\begin{equation}\n\\gamma = \\frac{Cov\\left(w(X), (X-\\mu_{BS})^2 \\right)}{V^2}\n\\end{equation}\nOur $\\gamma$ describes the curvature of the fitness surface around the\nmean. \\marginnote[-1.5cm]{Just like how $\\beta$ could be interpreted\nas the mean gradient of the fitness surface, our $\\gamma$ is the\nmean curvature of the fitness surface\n  \\begin{equation}\n\\gamma = \\E \\left[\\nicefrac{\\partial^2 w(x)}{\\partial x^2}  \\right] =\n\\int \\nicefrac{\\partial^2 w(x)}{\\partial x^2} p(x) dx\n\\end{equation}\nsee Appendix Section \\ref{section:calculus} for more on 2nd derivatives.\n\\graham{Need to straighten out issues with mean fitness vs fitness in\n  these sections}\n}\nValues of $\\gamma<0$  are consistent with stabilizing selection,\nreducing the variance. While values of $\\gamma>0$ are consistent with disruptive\nselection, increasing the variance. \\graham{add refs about this not being sufficient}\n\n%To do this we can think about how selection acts \n\n% https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1469-1809.1951.tb02469.x\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width= 0.6 \\textwidth]{Journal_figs/Quant_gen/birth_weight/Karn_Penrose_birth_weight.pdf}\n\\end{center}\n\\caption{Bars show the total number of births with different birth\n  weights (left axis)  Dots show the mortality probability for different\n  birth-weight bins (right axis), the red line shows a fitted\n  quadratic model to mortality. Data from \\citet{karn1951birth}\n  Table 2, collapsing male and female births, \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/birth_weight/birth_weight_selection.R} } \\label{fig:Birth_weight}  \n\\end{figure}\n\nUnder stabilizing selection the individuals with extreme phenotypes in\neither tail have lower fitness, the result of which is to reduce the\nphenotypic variance within a generation. A classic case of stabilizing selection\nis birth weight in humans \\citep{karn1951birth}. Mary Karn collected\ndata for nearly fourteen thousand pregnancies from 1935-46 for birth\nweight and mortality. These data are replotted in Figure\n\\ref{fig:Birth_weight}. The variance of all births is $1.575$lb$^2$, while in live births this\nwas reduced to $1.26$lb$^2$, a 20\\% reduction in variance due to\nstabilizing selection. It is worth noting that this selection\npressure has been greatly reduced over the decades in societies with\naccess to good prenatal care \\citep{ulizzi1992natural}.  %, a large effect of which has been to\n%reduce the variance in birth weights due to better nutrition\n\n%womb https://www.google.com/search?q=leonardo+da+vinci+baby&tbm=isch&source=iu&ictx=1&fir=pl1GYGee8iN0gM%253A%252CEdMTKcL8foK_hM%252C_&vet=1&usg=AI4_-kRCaAAUfKDX5AEtEm6lUZ5hjWMPlw&sa=X&ved=2ahUKEwjkluyapsniAhVWs54KHX7GBFsQ9QEwA3oECAMQCg#imgrc=W3ZPdyKQE9YkRM:&vet=1\n\n\\begin{marginfigure}\n\\begin{center}\n\\includegraphics[width= \\textwidth]{illustration_images/Quant_gen/Pyrenestes_seedcracker/Pyrenestes_minor.jpg}\n\\end{center}\n\\caption{Lesser seedcracker {\\it Pyrenestes minor} a close relative of\n  the Black-bellied seedcracker, whose beak is about the same size as\n  the smallest Black-bellied individuals. \\BHLNC{The birds of Africa, comprising all the species\n    which occur in the Ethiopian region. (1986) Sclater, W. L Plate by  H. Gr{\\\"o}nvold}{https://archive.org/stream/birdsofafricacom41shel/birdsofafricacom41shel\\#page/n306/mode/1up}{Smithsonian Libraries} }  \n\\end{marginfigure}\nIn Central Africa, Black-bellied seedcrackers ({\\it\n  Pyrenestes ostrinus}) show disruptive selection on a remarkable beak-size polymorphism (Figure \\ref{Black_bellied_seedcrackers_beaks}).  The small-beaked individuals feed on\nsoft  seeds from one species of marsh sedge while the big-beaked\nindividuals feed on hard seeds from another sedge, which\nrequires ten times the force to crack. \\citet{smith1993disruptive}\nrecorded the fates of hundreds of juveniles, and found that\nindividuals with intermediate beak sizes survived at much lower rates\n(Figure \\ref{Black_bellied_seedcrackers_beaks}) because they were not\nwell adapted to either seed resource.  Break length is subject to\ndisruptive selection, as can also be seen by the significant negative quadratic\nterm in the regression of survival probability on break length. The\nvariance of mandible length in the total sample of individuals was\n$0.5$mm$^2$ in the survivors this variance increased by a factor of $2.5$ to $1.3$mm$^2$.  \n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width= \\textwidth]{Journal_figs/Quant_gen/Smith_black_bellied_seed_cracker/Smith_black_bellied.pdf}\n\\end{center}\n\\caption{ {\\bf Left} An illustration of the the remarkable variation\n  in beak size within Black-bellied seedcrackers ({\\it  P.\n    ostrinus}). {\\bf Right} A histogram of a beak size measurement in\n  Black-bellied seedcrackers. All juveniles are shown in grey, while the\n  black bars show the survivors. The red curve shows the best fitting\n  linear and quadratic model to the probability of survival, fitted\n  using a binomial generalized linear model with a logit link function.  \n  \\BHLNC{Left illustration from: Size variation in {\\it Pyrenestes} by\n    Chapin J.P. in the Bulletin of the\n    American Museum of Natural History (Vol. XLIX\n    1923)}{https://archive.org/stream/bulletinofameric49alleuoft/\\#page/417/mode/1up}{Toronto\n    Library}   } \\label{Black_bellied_seedcrackers_beaks}\n\\end{figure}\n\n\nTo illustrate how directional selection and quadratic terms play off\nduring adaptation, lets consider the goldenrod gall fly ({\\it Eurosta solidaginis}), aka the goldenrod\nball gallmaker. See Figure \\ref{gall_size_stab}. As it's wonderful name\nimplies this insect lays its eggs in Goldenrod plants, and the larvae\nrelease chemicals forcing the plant to form a gall that forms a home\nfor the larvae as they develop. While this seems like a pretty sweet\ndeal for the larvae, it is not without its perils. \\begin{marginfigure}[2cm]\n\\begin{center}\n\\includegraphics[width= 0.7 \\textwidth]{illustration_images/Quant_gen/goldenrod_ball_gall_maker/goldenrod_ball_gall_maker.png}\n\\end{center}\n\\caption{The gall formed by the goldenrod\nball gallmaker ({\\it Eurosta solidaginis}) in a goldenrod plant. The\none on the right is cut to show a partial cross-section. \\BHLNC{Annual report of the New York State Museum (1917)}{https://archive.org/stream/annualreport71newy/\\#page/196/mode/1upp}{The LuEsther T Mertz Library, the New York Botanical Garden} }  \n\\end{marginfigure}\nWhen the small, ball galls fall risk of parasitism from parasitoid\nwasps. When all the ball galls are small in the population selection drives strong positive directional selection on\ngall size, with little stabilizing selection. Notice in the left panel\nof Figure \\ref{gall_size_stab} the good\nagreement between the linear selection gradient and the fit including\na linear and quadratic term. However, bigger galls fall under the pall of predation from downy\nwoodpeckers and black-capped chickadees, who seek out the tasty\nlarvae. Thus intermediate size galls are favoured, a fitness peak that\nthe population quickly reaches. Once on this peak,\nas shown in the right panel of Figure \\ref{gall_size_stab} there is no directional selection, i.e. no linear slope, but there\nis strong stabilizing selection, i.e. a quadratic term. Thus the\npopulation will be maintained at this fitness peak indefinitely if the\nenvironment remains unchanged.\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width= \\textwidth]{Journal_figs/Quant_gen/Weis_Gorman_gall_size_stablizing_sel/gall_size.pdf}\n\\end{center}\n\\caption[][4cm]{Fitness surface for gall diameter in goldenrod\nball gallmakers. The dots are the measured survival probabilities of\nbins of different sized galls.The solid line is a fitted individual fitness\n  surface ($w(~)$). Dotted line is $\\wbar$ plotted as a function of\n  the population mean assuming a normal distribution with a standard\n  deviation of $2$mm. Data from \\citet{weis1990measuring}, \\gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Weis_Gorman_gall_size_stablizing_sel/gall_size_fitness_landscape.R}} \\label{gall_size_stab}\n\\end{figure}\n\n\n%%% selection on gall size https://sci-hub.tw/https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1558-5646.1990.tb03807.x\n% https://www.flickr.com/photos/internetarchivebookimages/18429735991/\n%https://archive.org/stream/annualreport71newy/#page/196/mode/1up\n\n\n%black beelied seed cracker\n%https://sci-hub.tw/https://www.nature.com/articles/363618a0\n%https://www.flickr.com/photos/internetarchivebookimages/20416920856/in/photolist-otagrj-xVVxst-wRSxF1-x7b4fQ-x9uxzB\n%https://www.flickr.com/photos/internetarchivebookimages/14755609045/\n \n% Cross bill https://www.google.com/search?q=loxia+curvirostra+biodiversity+heritage+library&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjItfbRm87iAhUyMn0KHZDNDlIQ_AUIECgB&biw=1440&bih=726#imgrc=cfi-GvhZRX1zxM:\n% https://sci-hub.tw/https://www.jstor.org/stable/2937103?seq=1#metadata_info_tab_contents\n\n\n%file:///Users/gcoop/Downloads/calsbeek2008.pdf  disruptive selection\n%on leg length in anoles\n \n", "meta": {"hexsha": "5db213131a9da813fc275ad376f5b121b2f19e57", "size": 51154, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/Response_to_sel.tex", "max_stars_repo_name": "emjosephs/popgen-notes", "max_stars_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/Response_to_sel.tex", "max_issues_repo_name": "emjosephs/popgen-notes", "max_issues_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/Response_to_sel.tex", "max_forks_repo_name": "emjosephs/popgen-notes", "max_forks_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.02787068, "max_line_length": 492, "alphanum_fraction": 0.7826953904, "num_tokens": 13714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341024983754, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4035018259564049}}
{"text": "\\documentclass{article}\n\n\\usepackage{amsmath}\n\\usepackage{graphicx}\n\n\\title{Performance analysis of Statime as compared to LinuxPTP}\n\\author{Dion Dokter \\and Ruben Nijveld \\and David Venhoek}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Introduction}\n\nIn this paper, we present a quantitative comparison of statime synchronization performance as compared to the LinuxPTP implementation of PTP. In particular, we focus on comparing the precision and offset of the time synchronization of both setups.\n\nThe comparison was done over relatively short time intervals of about two hours. Over these periods we find that, due to incomplete support for hardware timestamping, the precision of statime is still $2$ orders of magnitude larger than that of LinuxPTP.\n\n\\section{Measurement setup}\n\nOur measurement setup consists of 3 main parts:\n\\begin{itemize}\n    \\item An endrun ninja ptp grandmaster clock synchronized via GPS.\n    \\item A raspberry pi 4 compute module with an Intel i210 NIC\n    \\item A Basys-3 FPGA development board setup to measure pps pulses.\n\\end{itemize}\n\nThe ptp grandmaster is connected via a direct ethernet cable to the i210 nic, and this connection is used to carry the PTP messages. Both the ptp grandmaster and the intel nic are configured to produce pulse-per-second outputs. Furthermore, the raspberry pi is also configured to produce a pulse-per-second output on its gpio pins.\n\nAll these pulses are measured by the FPGA relative to its internal clock. Although this internal clock is not precise, we can estimate its frequency using the pulse-per-second signal from the ptp grandmaster.\n\nThe grandmaster configuration is the default provided by endrun, and the grandmaster is given time to fully lock onto the GPS signal before start of measurement (specifically, we wait until the clock quality reported by gpsstat is at level 3).\n\nOn the raspberry pi, depending on the run we either start the LinuxPTP stack or statime. We then wait with starting the measurement until the self-reported offset to the grandmaster appears stable.\n\n\\section{Error estimates}\n\nIn our analysis we have included the following 4 main error sources: Cable length differences, fpga input path differences, discretization error, and fpga clock instability. Below we will discuss each, including their contributions to our estimated error.\n\\subsection{Cable length}\nThe setup contains cables of multiple lengths and varying electrical characteristics. We will estimate these errors pessimistically and assume maximum systematic errors up to the propagation delay of our longest possible cable. As all our cables are below 1.5 meters in length, this gives us an estimated 15ns of systematic error.\n\\subsection{FPGA input architecture}\nAlthough care has been taken in the VHDL code the fpga has been programmed with to keep the input path for all of the signals identical, due to the fact that these interact with different pieces of the physical hardware there can still be offsets between processing delays for the inputs. Based on the documentation of the FPGA's architecture, we assume these to contribute 1 fpga clock cycle of systematic error.\n\\subsection{Discretization error}\nThe pulse per second signals arrive at the fpga unsynchronized with the fpga's clock. Due to this, their measured arrival time may be off by up to 1 clock cycle, giving us a statistical error of 1 fpga clock cycle.\n\\subsection{FPGA clock instability}\nThe clock in the fpga is of relatively low quality, and may therefore be somewhat unstable. We will use the pulse-per-second signal measured from the grandmaster clock to estimate the frequency instability of the fpga's clock, which will provide us with an additional statistical error component.\n\n\\section{FPGA clock callibration}\n\nWe callibrate the FPGA clock using the data from the GM pulse-per-second signal. This process purely uses difference between arrival times of these pulses, hence errors from cable length can be ignored in the following analysis. Note that over short time intervals, the clock frequency seems quite stable, with the second interval only varying by 1 clock cycle around a central value over short time periods. To compensate for any longer-term drift of the FPGA clock frequency, we do this calibration on a per-run basis.\n\n\\begin{figure}[h]\n\\includegraphics[width=0.5\\textwidth]{gm_clocks_overtime_ref.pdf}\\includegraphics[width=0.5\\textwidth]{gm_clocks_overtime_statime.pdf}\n\\caption{FPGA clock cycles per second over time, time axis is arbitrary. On the left is data from the LinuxPTP run, on the right from the statime run. Glitch marks points where some seconds of data have been removed due to jiggling of connectors causing spurious edges.}\n\\label{fig:gm_cycles_over_time}\n\\end{figure}\n\n\\begin{figure}[h]\n\\includegraphics[width=0.5\\textwidth]{gm_clocks_per_sec_ref.pdf}\\includegraphics[width=0.5\\textwidth]{gm_clocks_per_sec_statime.pdf}\n\\caption{FPGA clock cycles per second as measured using the GM pulse-per-second output. On the left is data from the LinuxPTP run, on the right from the statime run.}\n\\label{fig:gm_cycles_per_second}\n\\end{figure}\n\nFor the LinuxPTP run, the measurement data are plotted in Figure~\\ref{fig:gm_cycles_per_second}. Analysing this shows the fpga clock ticks $99999599\\pm 1.7 (\\text{stat.}) \\pm 1.0 (\\text{sys.})$ per second. Hence, a single clock tick of the fpga clock takes $10.00004010 \\pm 0.00000017 (\\text{stat.}) \\pm 0.00000010 (\\text{sys.})$ nanoseconds during the LinuxPTP run.\n\nFor the statime run, analysis shows the fpga clock ticks $ 99999638 \\pm 7.8 (\\text{stat.}) \\pm 1.0 (\\text{sys.})$ per second. Hence, a single clock tick of the fpga clock takes $10.00003620 \\pm 0.00000078 (\\text{stat.}) \\pm 0.00000010 (\\text{sys.})$ nanoseconds during the statime run.\n\n\\section {LinuxPTP performance analysis}\n\n\\begin{figure}[h]\n\\includegraphics[width=0.5\\textwidth]{gm_ref_offset_overtime.pdf}\\includegraphics[width=0.5\\textwidth]{gm_ref_offset.pdf}\n\\caption{System clock offset to GM, both overtime and frequency of observations, as synchronized by LinuxPTP. (Negative values indicate that the clock is ahead of the GM.)}\n\\label{fig:ref_sys_offset}\n\\end{figure}\n\nAnalysing the offset data for the system clock synchronized by LinuxPTP, we find that this gives a constant offset $-3576,40\\pm 0.95 (\\text{stat.}) \\pm 25(\\text{sys.})$ nanoseconds, which could be eliminated by tuning the port assymetry. Furthermore, we see 90\\% of all observations fall within $126 \\pm 10 (\\text{stat.})$ nanoseconds of this constant offset.\n\n\\section{Statime performance analysis}\n\n\\begin{figure}[h]\n\\includegraphics[width=0.5\\textwidth]{gm_statime_offset_overtime.pdf}\\includegraphics[width=0.5\\textwidth]{gm_statime_offset.pdf}\n\\caption{System clock offset to GM, both overtime and frequency of observations, as synchronized by Statime. (Negative values indicate that the clock is ahead of the GM.)}\n\\label{fig:statime_sys_offset}\n\\end{figure}\n\nAnalysing the offset data for the system clock synchronized by Statime, we find that this gives a constant offset $-23570\\pm 90(\\text{stat.})\\pm 25 (\\text{sys.})$ nanoseconds, which could be eliminated by tuning the port assymetry. Furthermore, we see 90\\% of all observations fall within $11250 \\pm 10(\\text{stat.})$ nanoseconds of this constant offset.\n\n\\section{Conclusions}\n\nComparing the results of the statime and LinuxPTP, we observe that statime is $2$ orders of magnitude less precise. We think that this is primarily the result of the fact that statime does not yet have support for hardware timestamping.\n\nIn line with the observed decreased precision, we also see an associated increase in fixed offset. This is likely primarily due to assymetry within the linux kernel's networking stack, which becomes more significant when relying on software timestamping.\n\\end{document}\n", "meta": {"hexsha": "ae404469be7fad0d486d6dbd4f7ac33584523491", "size": 7824, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "validation/measurement_report.tex", "max_stars_repo_name": "tweedegolf/statime", "max_stars_repo_head_hexsha": "9fe8b8364c6a5214ee8bbf294fe4dfbb613a5496", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-03-17T16:14:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T23:18:54.000Z", "max_issues_repo_path": "validation/measurement_report.tex", "max_issues_repo_name": "tweedegolf/statime", "max_issues_repo_head_hexsha": "9fe8b8364c6a5214ee8bbf294fe4dfbb613a5496", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2022-02-08T12:03:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T06:18:44.000Z", "max_forks_repo_path": "validation/measurement_report.tex", "max_forks_repo_name": "tweedegolf/statime", "max_forks_repo_head_hexsha": "9fe8b8364c6a5214ee8bbf294fe4dfbb613a5496", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.2340425532, "max_line_length": 520, "alphanum_fraction": 0.7985685072, "num_tokens": 1860, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6297746074044135, "lm_q1q2_score": 0.40345619397098764}}
{"text": "%------------------------------------------------------------------------------\n\\chapter{Orbit Propagation}\n\\label{cha:OrbitPropagation}\n%------------------------------------------------------------------------------\n\n%------------------------------------------------------------------------------\n\\section{Overview}\n%------------------------------------------------------------------------------\n\nOne of the key elements of a space surveillance system is the propagation technique used in the orbit determination process. While the first surveillance systems in the \\acrshort{acr:us} and the Soviet Union \nemployed fast analytical techniques, also known as \\gls{acr:gp} methods, with today's computational limitations virtually non-existing, it is common to use so-called \\gls{acr:sp} techniques, \nwhich perform the numerical integration of a detailed force model. The numerical propagation tool \\neptune (\\acrlong{acr:neptune}) was designed to be used in the context of a space surveillance system and is described in detail in the following. \n\\begin{figure}[h!]\n \\centering\n \\includegraphics[width=0.5\\textwidth]{neptune_logo.png}\n \\caption{\\neptune logo.\\label{fig:neptune-logo}}\n\\end{figure}\nThe first step was to define the required force model and select state-of-the-art methods that would be implemented to meet the need in the intended context. Therefore, besides a 3 \\gls{acr:dof} propagation for the state vector, \\neptune has also \nthe capability to propagate the covariance matrix, which is an essential step in the filtering process within the statistical orbit determination. Finally, the concept of \nincluding time-correlated (coloured) noise into the filtering application was studied in detail and shall be presented here, based on the work of \n\\citet{nazarenko2010}.\n\nThe coordinate and time systems implemented in \\neptune are based on the \\gls{acr:iau} recommendations and will be outlined in \\sect{sec:propagation-coordinates}. Especially the \nconversion from the inertial to the Earth-fixed frame and vice versa is computationally expensive, so that a method has been devised to significantly improve \ncomputation speed without significant performance loss.\n\nIt is possible to define the shape of the satellite used in a \\neptune propagation with a very simple geometry, which shall be described in \n\\sect{sec:propagation-satellite-model}. That approach served as a simple method to simulate box-wing configurations in the validation of \\neptune (see \\cha{cha:validation}).\n\nThe numerical integrator and the force model will be given in detail in \\sect{sec:propagation-state}, while the details for the covariance matrix propagation are provided in \n\\sect{sec:propagation-covariance}.\n\nFinally, the process noise, which results in additional contributions to the covariance propagation due to uncertainties in the force model, will be detailed in \\sect{sec:noise}. \nDifferent methods to incorporate noise into filtering applications shall be described with a focus on coloured noise, as especially the geopotential shows significant time-correlations.\n\n\n%------------------------------------------------------------------------------\n\n\\input{02-Propagation/coordinates}\n\\input{02-Propagation/satmodel}\n\\input{02-Propagation/state}\n\\input{02-Propagation/covariance}\n\\input{02-Propagation/noise}\n\n%------------------------------------------------------------------------------\n%\\bibliographystyle{plain}\n%\\bibliography{wp2report}\n%------------------------------------------------------------------------------", "meta": {"hexsha": "b6d5102059714be644d2c7faa3e8f5c6b1a175d3", "size": 3531, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/01-NEPTUNE/propagation.tex", "max_stars_repo_name": "mmoeckel/neptune", "max_stars_repo_head_hexsha": "6c170d0df7b12fbfa1e92b15337ca8e8df3b48b0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-03-30T08:42:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T10:48:20.000Z", "max_issues_repo_path": "documentation/01-NEPTUNE/propagation.tex", "max_issues_repo_name": "mmoeckel/neptune", "max_issues_repo_head_hexsha": "6c170d0df7b12fbfa1e92b15337ca8e8df3b48b0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-06-11T03:36:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-11T12:34:22.000Z", "max_forks_repo_path": "documentation/01-NEPTUNE/propagation.tex", "max_forks_repo_name": "mmoeckel/neptune", "max_forks_repo_head_hexsha": "6c170d0df7b12fbfa1e92b15337ca8e8df3b48b0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2020-06-10T05:30:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-06T15:13:35.000Z", "avg_line_length": 73.5625, "max_line_length": 247, "alphanum_fraction": 0.6805437553, "num_tokens": 680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.40345619397098753}}
{"text": "%auto-ignore\n\\providecommand{\\MainFolder}{..}\n\\documentclass[\\MainFolder/Text.tex]{subfiles}\n\n\\begin{document}\n\n\\section{Dual cyclic bar complex and cyclic (co)homology\n%for the \\texorpdfstring{$\\IBLInfty$-theory}{IBL-infinity-theory}\n}\n\\allowdisplaybreaks\n\\label{Sec:Alg2}\n\\Correct[caption={DONE Notation for cyclic Hochschild}]{Notation for cyclic Hochschild}\n\\Correct[caption={DONE Reduced is defined wrt. normalized!},inline]{Reduced is defined as coker or ker in normalized and not in the full complex! It is OK because we have the cyclic symmetry!}\n\\Modify[caption={DONE Convention for duals},inline]{The convention for cochain complexes will be as follows. Chain complex will be denoted by $C$ and cochain complex by $C^*$. The components will be denoted by $C_q$ and $C^q$. }\n%\\begin{Notation}[Chain and cochain complexes]\n%If $C$ is a chain complex, we will often denote by $C^*$ the \n%because $*$.\n%$\\H(C)$ and by $\\H^*(C)=\\H(C^*)$ the cohomology of the dual. In fact, \n%\\end{Notation}\n\\begin{Definition}[Bar complexes] \\label{Def:BarComplex}\nLet $V$ be a graded vector space. The \\emph{bar- and dual bar-complex of $V$} are the weight-graded vector spaces defined by \n$$ \\B V\\coloneqq \\RTen(V[1])\\quad\\text{and}\\quad\\DB V \\coloneqq (\\B V)^{\\WGD}, $$\nrespectively, where $\\bar{T}V \\coloneqq \\bigoplus_{k=1}^\\infty V^{\\otimes k}$ is the weight-reduced tensor algebra. For every $k\\in \\N$, let $t_k \\in \\Perm_k$ be the cyclic permutation $t_k : (1,\\dotsc,k) \\mapsto (2,\\dotsc,k,1)$,\nso that for all $v_1$, $\\dotsc$, $v_k \\in V[1]$ we have\n\\begin{equation*}\n%\\label{Eq:tk}\nt_k(v_1 \\otimes \\dotsb \\otimes v_k) = (-1)^{\\Abs{v_k}(\\Abs{v_1} + \\dotsb + \\Abs{v_{k-1}})} v_k \\otimes v_1 \\otimes \\dotsb \\otimes v_{k-1}.\n\\end{equation*}\n%We also let $t_0: V[1]^{\\otimes 0} \\rightarrow V[1]^{\\otimes 0}$ be the identity $\\R[1] \\rightarrow \\R[1]$ and set\nWe set\n$$ t\\coloneqq \\sum_{k=1}^\\infty t_k : \\B V \\longrightarrow \\B V. $$\nThe \\emph{cyclic bar-complex} is defined by \n$$ \\BCyc V \\coloneqq \\B V / \\Im(1-t). $$\n%It can be written as \n%$$ \\BCyc V = \\bigoplus_{\\substack{k\\in \\N \\\\ d\\in \\Z}} (\\BCyc V)^d_k $$ \n%with \n%$$ (\\BCyc V)^d_k \\coloneqq (\\B V)_k^d/\\Im(1-t_k), $$\n%and hence it is a weight-graded vector space.\nWe denote the image of $v_1 \\otimes \\dotsb \\otimes v_k \\in \\B V$ under the canonical projection $\\pi: \\B V \\rightarrow \\BCyc V$ by $v_1\\dots v_k$. If $v_i\\in V[1]$ are homogenous, then $v_1\\dots v_k$ is called a \\emph{generating word}; we have\n\\begin{equation*}\nv_1 \\dots v_k = (-1)^{\\Abs{v_k}(\\Abs{v_1}+\\dotsb + \\Abs{v_{k-1}})} v_k v_1 \\dots v_{k-1}.\n\\end{equation*}\nWe define the section $\\iota: \\BCyc V \\rightarrow \\B V$ of $\\pi$ by\n$$ \\iota(v_1\\dots v_k) \\coloneqq \\frac{1}{k} \\sum_{i=0}^{k-1} \\underbrace{t_k^i}_{\\mathrlap{\\displaystyle \\eqqcolon t_k \\circ \\dotsb \\circ t_k\\ i\\text{-times}}}(v_1\\otimes\\dotsb \\otimes v_k) $$\nand use it to identify $\\BCyc V$ with the subspace $\\Im \\iota = \\Ker(1-t) \\subset \\B V$ consisting of cyclic symmetric tensors.\n\nWe define the \\emph{dual cyclic bar-complex} by \n$$ \\DBCyc V \\coloneqq \\{ \\psi\\in \\DB V \\mid \\psi \\circ t = \\psi \\}. $$\n%and identify it with $(\\BCyc V)^{\\WGD}$ by defining \n%\\begin{equation} \\label{Eq:PairingCyc}\n%\\psi(v_1\\dots v_k) \\coloneqq \\psi(v_1\\otimes \\dotsb \\otimes v_k)\n%\\end{equation}\n%for all $\\psi \\in \\DBCyc V$ and generating words $v_1\\dots v_k\\in \\BCyc V$. \n\\end{Definition}\n\n\\begin{Remark}[Non-weight-reduced bar complex]\\label{Rem:NWG}\nIn fact, our $\\DBCyc V$ is weight-reduced. The non-weight-reduced version would be $\\DBCyc V \\oplus \\R$ with $\\R$ of degree~$0$. This might play a role in the theory of  weak $\\AInfty$-algebras ($\\coloneqq$\\,operation $\\mu_0$ added; c.f., Definition~\\ref{Def:CyclicAinfty}), and it might also be possible to consider $\\IBLInfty$-algebras on non-weight-reduced cyclic cochains (c.f., Section~\\ref{Sec:Alg3}).\n%However, this is outside of the scope of our text.\n\\end{Remark}\n\nNotice that $\\psi \\in \\DB V$ is homogenous of degree $\\Abs{\\psi}\\in \\Z$ if and only if for all homogenous $v_1$,~$\\dotsc$, $v_k \\in V[1]$ the following implication holds:\n\\begin{equation*}\n\\Abs{v_1} + \\dotsb + \\Abs{v_k} \\neq \\Abs{\\psi}\\quad\\Implies\\quad \\psi(v_1\\otimes \\dotsb \\otimes v_k) = 0.\n\\end{equation*}\nThis is the cohomological grading convention.\n\n\\begin{Notation}[Degree shifts of bar complexes] \\label{Def:Notation}\nLet $A\\in \\Z$. In the following, we write $\\DBCyc V$, but the convention applies to all complexes from Definition\\,\\ref{Def:BarComplex}. We denote by $\\Susp_A$ and $\\SuspU$ the formal symbols of degrees \n$$ \\Abs{\\Susp_A} = -A \\quad \\text{and}\\quad\\Abs{\\SuspU} = -1, $$\nrespectively. The degree shift $V \\mapsto V[1]$ will be realized as  multiplication with~$\\SuspU$ and the degree shift $\\DBCyc V\\mapsto \\DBCyc V[A]$ as multiplication with~$\\Susp_A$. In addition, the following notation will be used consistently:\n\\begin{itemize}\n \\item $\\tilde{v}\\in V \\longleftrightarrow v = \\SuspU \\tilde{v} \\in V[1]$\n \n  To clarify this, given $\\tilde{v} \\in V$, then~$v$ automatically means $v = \\SuspU \\tilde{v} \\in V[1]$, and the other way round. Recall that the degree of $\\tilde{v}\\in V$ is denoted by~$\\Deg(\\tilde{v})$ or simply by $\\tilde{v}$ in the exponent, e.g., $(-1)^{\\tilde{v}}$.\n \\item  $\\psi\\in\\DBCyc V\\longleftrightarrow \\Psi = \\Susp_A \\psi\\in \\DBCyc V[A]$.\n \\item A generating word of $\\BCyc V$ of weight $k$ will be denoted by the symbol $w$ and written as $w= v_1 \\dots v_k$, where $v_i = \\SuspU \\tilde{v}_i \\in V[1]$. A generating word of $\\Ext_k \\BCyc V$ is an element $w_1 \\dotsb w_k \\in \\Ext_k \\BCyc V$ such that each~$w_i$ is a generating word of $\\BCyc V$.\n \\item $w\\in \\BCyc V\\longleftrightarrow \\text{\\footnotesize W} = \\Susp_A w \\in \\BCyc V[A]$.\n\\end{itemize}\nWe abbreviate\n$$ \\DBCyc V[A]\\coloneqq (\\DBCyc V)[A]. $$\n%,\\quad \\Ext \\DBCyc V[A]\\coloneqq \\Ext(\\DBCyc V[A]). \nIn contrast to this, we would write $\\DBCyc(V[A])$ for the dual cyclic bar-complex of~$V[A]$. We also identify $(\\DBCyc V[A])[1] = \\DBCyc V[A+1]$ in $\\Ext \\DBCyc V[A]$.\n\\end{Notation}\n\n%and $(\\Ext\\DBCyc V)[A]$ for the degree shift of~$\\Ext\\DBCyc V$ by~$A$.\n\\begin{Definition}[Pairing of tensor powers of bar complexes]\\label{Def:Pairings}\nFor every $A\\in \\Z$ and  $k\\in \\N$, we define the pairing as follows:\n\\begin{equation} \\label{Eq:Pairing}\n\\begin{aligned}\n(\\DB V[A])^{\\otimes k} \\otimes (\\B V[A])^{\\otimes k} & \\longrightarrow \\R \\\\ \n(\\Psi_1 \\otimes \\dotsb \\otimes \\Psi_k, \\W_1 \\otimes \\dotsb \\otimes \\W_k) & \\longmapsto \\underbrace{\\psi_1(w_1) \\dots \\psi(w_k)}_{\\mathllap{\\textstyle{(\\Psi_1 \\otimes \\dotsb \\otimes \\Psi_k)(\\W_1\\otimes \\dotsb\\otimes \\W_k)\\coloneqq}}}.\n\\end{aligned}\n\\end{equation}\nThis means that we evaluate elements from the left-hand side on the elements from the right-hand side in this way without any signs (see the discussion in Remark~\\ref{Rem:BadConvention}). We extend the pairing by $0$ if the number of $\\Psi_i$'s and the number of $\\W_i$'s differ.\n\\end{Definition}\n\n\\begin{Remark}[Dual bar complex and dual of the bar complex] \\label{Rem:Identifications}\nBecause the pairing~\\eqref{Eq:Pairing} is non-degenerate, we can embed the space on the left into the the linear dual of the space on the right.\n%; this is used in the proof of Lemma \\eqref{Lemma:GraphPairing}.\nFrom Definition~\\ref{Def:BarComplex} we have $\\DBCyc V \\subset \\DB V$, and $\\BCyc V$ is identified with $\\Im \\iota \\subset \\B V$. Therefore, we can restrict \\eqref{Eq:Pairing} to obtain the pairing of $\\DBCyc V$ and $\\BCyc V$. It is easy to see that for any $\\psi\\in \\DBCyc V$ and any generating word $v_1\\dots v_k \\in \\BCyc V$, we have\n\\begin{equation*}\n%\\label{Eq:BCycIdent} \n\\psi(v_1\\dots v_k) = \\psi(v_1 \\otimes \\dotsb \\otimes v_k).\n\\end{equation*}\nThe subspace of $(\\BCyc V)^{\\LD}$ corresponding to $\\DBCyc V$ is then precisely $(\\BCyc V)^{\\WGD}$.\n\nMore generally, for every $k\\in \\N$, the spaces $\\Ext_k \\DBCyc V$ and $\\Ext_k \\BCyc V$ are embedded into $(\\DBCyc V[1])^{\\otimes k}$ and $(\\BCyc V[1])^{\\otimes k}$, respectively, using $\\iota$ and $\\pi$ from Definition~\\ref{Def:SymAlgebra}. Therefore, the restriction of~\\eqref{Eq:Pairing} gives the pairing of $\\Ext_k \\DBCyc V$ and $\\Ext_k \\BCyc V$. It is easy to see that for any generating word $w_1\\dotsb w_k \\in \\Ext_k \\BCyc V$ and any $\\psi_1\\dotsb \\psi_k\\in \\Ext_k \\DBCyc V$, we have\n$$ (\\psi_1\\dotsb \\psi_k)(w_1\\dotsb w_k) = \\frac{1}{k!}\\sum_{\\sigma\\in \\Perm_k} \\varepsilon(\\sigma,w) \\psi_1(w_{\\sigma_1^{-1}})\\dotsc \\psi_k(w_{\\sigma_k^{-1}}). $$\nThe subspace of $(\\Ext_k \\BCyc V)^{\\LD}$ corresponding to $\\Ext_k \\DBCyc V$  lies in $(\\Ext_k \\BCyc V)^{\\WGD}$; it is equal to $(\\Ext_k \\BCyc V)^{\\WGD}$, provided that $V$ is finite-dimensional.\\footnote{The problem is that if $\\dim(V) = \\infty$, then $(V\\otimes V)^* \\neq V^* \\otimes V^*$.}\n\\end{Remark}\n\nThe weight-graded vector spaces $\\B V$ and $\\BCyc V$ are canonically filtered by the filtration by weights \\eqref{Eq:FiltrWeights}. Their weight-graded duals $\\DB V$ and $\\DBCyc V$ are filtered by the dual filtrations and the exterior powers $\\Ext_k \\DB V$ and $\\Ext_k \\DBCyc V$ by the induced filtration from Definition~\\ref{Def:Filtrations}. \n\n\\begin{Proposition}[Completed dual cyclic bar complex] \\label{Prop:Compl}\nLet $V$ be a graded vector space and $A\\in \\Z$. The filtration of $\\DBCyc V$ dual to the weight-filtration of $\\BCyc V$ is $\\Z$-gapped, Hausdorff,  decreasing and bounded from above. Moreover, the following holds:\n$$ \\dim(V)<\\infty\\quad\\Implies\\quad (WG1)\\ \\&\\ (WG2)\\text{ are satisfied.} $$\nThe same holds for the induced filtration of $\\Ext_k \\DBCyc V[A]$.\n\nIn the sense of Remark~\\ref{Rem:Identifications}, we have\\Correct[caption={E},noline]{Here should be $A$ instead of $A+1$}\n$$ \\nCDBCyc V \\simeq (\\BCyc V)^{\\GD}\\quad\\text{and}\\quad \\hat{\\Ext}_k \\DBCyc V[A] \\subset (\\Ext_k \\BCyc V[A+1])^{\\GD}, $$\nwhere ``='' holds if $V$ is finite-dimensional.\n\nThe \\emph{filtration degree} of $\\Psi\\in \\hat{\\Ext}_m \\DBCyc V[A]$ satisfies\n$$ \\Norm{\\Psi} = \\min\\{k\\in \\N_0 \\mid \\exists \\W\\in (\\Ext_m \\BCyc V[A])_k: \\Psi(\\!\\W)\\neq 0 \\}.$$\n\\end{Proposition}\n\n\\begin{proof}\nThe proof is clear.\n\\end{proof}\n\n\\begin{Def}[Cyclic $\\AInfty$-algebra] \\label{Def:CyclicAinfty}\nA graded vector space $V$ together with a pairing\\Correct[noline,caption={Degree of pairing}]{This should be standardized with the degree of Poincare duality algebra, canonical dIBL algebra, .... The degree should be probably minus the degree of the pairing on $V$ (not $V[1]$)} \n$$ \\Pair: V[1]\\otimes V[1] \\rightarrow \\R $$\nof degree $d\\in \\Z$ and a collection of homogenous linear maps \n$$\\mu_k: V[1]^{\\otimes k} \\rightarrow V[1]\\quad\\text{for }k\\ge 1$$\nis called a \\emph{cyclic $\\AInfty$-algebra of degree~$d$} if the following conditions are satisfied:\n\\begin{PlainList}\n \\item The pairing $\\Pair$ is non-degenerate and graded antisymmetric; i.e., we have\n  $$ \\Pair(v_1,v_2) = (-1)^{1+\\Abs{v_1}\\Abs{v_2}} \\Pair(v_2,v_1) \\quad\\text{for all }v_1, v_2 \\in V[1]. $$\n \\item The degrees satisfy $\\Abs{\\mu_k}=1$ for all $k\\ge 1$.\n \\item The \\emph{$\\AInfty$-relations} are satisfied: for all $k\\ge 1$, we have\n\\begin{equation} \\label{Eq:AInftyDef}\n \\sum_{\\substack{k_1, k_2 \\ge 1 \\\\ k_1+k_2 = k+1}} \\sum_{p=1}^{k_1} \\mu_{k_1} \\circ_1^p \\mu_{k_2} = 0,\n \\end{equation}\nwhere for all $p=1$, $\\dotsc$, $k$ and $v_1$, $\\dotsc$, $v_{k}\\in V[1]$ we define\n$$(\\mu_{k_1} \\circ_1^p \\mu_{k_2})(v_1, \\dotsc, v_{k}) \\coloneqq \\begin{multlined}[t] (-1)^{\\Abs{v_1} + \\dotsb + \\Abs{v_{p-1}}} \\mu_{k_1}(v_1, \\dotsc, v_{p-1},\\\\ \\mu_{k_2}(v_p,\\dotsc,v_{p+k_2-1}),v_{p+k_2}\\dotsc,v_{k}). \\end{multlined}$$\n\n \\item The operations $\\mu_k^+: V[1]^{\\otimes k+1} \\rightarrow \\R$ defined by \n $$ \\mu_k^+\\coloneqq \\Pair\\circ (\\mu_k \\otimes \\Id) $$\n for all $k\\ge 1$ are cyclic symmetric; i.e., we have\n $$ \\mu_k^+ \\circ t_{k+1} = \\mu_k^+. $$\n\\end{PlainList}\nWe denote by $\\tilde{\\Pair}: V\\otimes V \\rightarrow \\R$ and $\\tilde{\\mu}_k: V^{\\otimes k} \\rightarrow \\R$ the operations before the degree shift; i.e., for all $k\\ge 1$ and $\\tilde{v}_1$, $\\dotsc$, $\\tilde{v}_k \\in V$ with $v_i = \\SuspU \\tilde{v}_i$, we have\n\\begin{align*}\n\\tilde{\\Pair}(\\tilde{v}_1, \\tilde{v}_2) &\\coloneqq (-1)^{\\tilde{v}_1} \\Pair(v_1, v_2)\\quad\\text{and} \\\\[\\jot]\n\\tilde{\\mu}_k(\\tilde{v}_1, \\dotsc, \\tilde{v}_k) &\\coloneqq \\varepsilon(\\SuspU,\\tilde{v}) \\mu_k(v_1,\\dotsc, v_k).\n\\end{align*}\nWe define $\\tilde{\\mu}_k^+: V^{\\otimes k+1}\\rightarrow \\R$ similarly.\n\nIf $\\mu_k \\equiv 0$ for all $k\\ge 2$, then $(V,\\Pair, \\mu_1)$ is called a \\emph{cyclic cochain complex}. If $\\mu_k \\equiv 0$ for all $k\\ge 3$, then $(V,\\Pair,\\mu_1,\\mu_2)$ is called a \\emph{cyclic dga}. We use the same terminology but omit ``cyclic'' if there is no pairing $\\Pair$ and 1) and 4) are thus irrelevant.\n\\end{Def}\n\n\\begin{Remark}[A difference in sign conventions]\\label{Rem:mukplus}\nOur definition of $\\mu_k^+$ differs from the definition of $\\mathrm{m}_k^+$ in~\\cite[Definition 12.1]{Cieliebak2015} by a sign. To compensate this, we have to add this artificial sign in the definitions of Maurer-Cartan elements later; e.g., in Definition~\\ref{Def:CanonMC} or in the formula~\\eqref{Eq:PushforwardMC}.\n\\end{Remark}\n\\Correct[caption={DONE Change sub to sup},noline]{Change $\\Hd^k$ to $\\Hd_k$ and so on. Why are the indices upstairs?}\n\\begin{Definition}[Cyclic (co)homology of an $\\AInfty$-algebra]\\label{Def:CycHom}\nLet $\\mathcal{A}=(V,(\\mu_k))$ be an $\\AInfty$-algebra. For every $k\\ge 1$, we consider the maps $\\Hd'_k$, $R_k: V[1]^{\\otimes k} \\rightarrow \\B V$ given by \n\\begin{equation}\\label{Eq:bRH} \\begin{aligned}\\Hd'_k & \\coloneqq \\sum_{j=1}^k \\sum_{i=0}^{k-j} t^i_{k-j+1}\\circ(\\mu_j \\otimes \\Id^{k-j})\\circ t_k^{-i}\\quad\\text{and}\\\\\nR_k &\\coloneqq \\sum_{j=2}^k \\sum_{i=1}^{j-1} (\\mu_j\\otimes \\Id^{k-j})\\circ t_k^{i}, \\end{aligned}\n\\end{equation}\nrespectively, and define the following maps $\\B V \\rightarrow \\B V$:\n\\begin{equation*}\n\\Hd'\\coloneqq \\sum_{k=1}^{\\infty} \\Hd'_k, \\quad R\\coloneqq \\sum_{k=2}^\\infty R_k\\quad\\text{and}\\quad \\Hd\\coloneqq \\Hd' + R.\n%\\label{Eq:b} \n\\end{equation*}\nWe denote by $\\Hd^*: \\CDB V = (\\B V)^{\\GD} \\rightarrow \\CDB V$ the dual map to $\\Hd: \\B V \\rightarrow \\B V$.  The following holds:\\footnote{The facts~\\eqref{Eq:HH}, in some form, are generally known; see \\cite{Mescher2016} or \\cite{Lazarev2003}. We prove them in our setting in Appendix~\\ref{App:AInfty}.}\n\\begin{equation} \\label{Eq:HH}\n\\Abs{\\Hd} = 1\\ (\\Abs{\\Hd^*}=-1), \\quad \\Hd\\circ \\Hd = 0 \\quad\\text{and}\\quad \\Hd(1-t) = (1-t)\\Hd'.\n\\end{equation} \nFrom the last equation we see that $\\Hd$ restricts to $\\BCyc V = \\B V / \\Im(1-t)$.\n%For all $q\\in \\Z$, we define the vector spaces\n%$$ \\begin{aligned}\n%D_q(V) &\\coloneqq (\\B V)^{-q-1}, & D^q(V) &\\coloneqq (\\CDB V)^{-q-1}, \\\\\n%D^\\lambda_q(V) &\\coloneqq (\\BCyc V)^{-q-1}, & D_\\lambda^q(V) &\\coloneqq (\\CDBCyc V)^{-q-1}\n%\\end{aligned} $$\n%and the corresponding graded vector spaces  \nWe define the following graded vector spaces:\n\\begin{align*}\nD(V) &\\coloneqq r(\\B V)[1], & D^*(V) &\\coloneqq r(\\CDB V)[1], \\\\ D^\\lambda(V) &\\coloneqq r(\\BCyc V)[1], & D_\\lambda^*(V) &\\coloneqq r(\\CDBCyc V)[1], \\end{align*}\nwhere $r$ denotes the grading reversal.\nFor instance, we have\n$$ D_\\lambda^q(V) = r(\\CDBCyc V)^{q+1} = (\\CDBCyc V)^{-q-1}\\quad \\text{for all } q\\in \\Z.$$\nThen $(D(V),\\Hd)$ and $(D^\\lambda(V),\\Hd)$ are chain complexes and $(D^*(V),\\Hd^*)$ and $(D_\\lambda^*(V),\\Hd^*)$ the dual cochain complexes, respectively.\nWe define the following (co)homologies:\n\\begin{align*}\n\\H\\H(\\mathcal{A};\\R)& \\coloneqq \\H(D(V), \\Hd), & \\H\\H^*(\\mathcal{A};\\R) &\\coloneqq \\H(D^*(V),\\Hd^*),\\\\  \n\\H^\\lambda(\\mathcal{A};\\R)& \\coloneqq \\H(D^\\lambda(V), \\Hd), & \\H^*_\\lambda(\\mathcal{A};\\R), &\\coloneqq \\H(D^*_\\lambda(V),\\Hd^*).\n\\end{align*}\nWe call $\\H\\H$ the \\emph{Hochschild homology} and $\\H^\\lambda$ the \\emph{cyclic homology} of the $\\AInfty$-algebra $\\mathcal{A}$. We call $\\H\\H^*$ the \\emph{Hochschild cohomology} and $\\H_\\lambda^*$ the \\emph{cyclic cohomology} of~$\\mathcal{A}$.\n\\end{Definition}\n\nFor a dga $\\mathcal{A} = (V,\\mu_1,\\mu_2)$, we have for all $v_1$, $\\dotsc$, $v_k\\in V[1]$ the formula\n\\begin{align*}\n \\Hd(v_1 \\dots v_k) &= \\sum_{i=1}^k (-1)^{\\Abs{v_1} + \\dotsb + \\Abs{v_{i-1}}} v_1 \\dots \\mu_1(v_i) \\dots v_k  \\\\ \n   &+ \\sum_{i=1}^{k-1} (-1)^{\\Abs{v_1} + \\dotsb + \\Abs{v_{i-1}}} v_1 \\dots \\mu_2(v_i,v_{i+1}) \\dots v_k \\\\\n   &+ (-1)^{\\Abs{v_k}(\\Abs{v_1} + \\dotsb + \\Abs{v_{k-1}})} \\mu_2(v_k,v_1)v_2\\dots v_{k-1}.\n\\end{align*}\n\n\n\\begin{Definition}[Strict units and strict augmentations]\\label{Def:AugUnit}\nLet $\\mathcal{A}= (V, (\\mu_k))$ be an $\\AInfty$-algebra. A non-zero homogenous element $\\NOne \\in V[1]$ with $\\Abs{\\NOne} = -1$ is called a \\emph{strict unit} for $\\mathcal{A}$ if the following holds:\n\\begin{align*} \\mu_2(\\NOne, v) = (-1)^{\\Abs{v} + 1}\\mu_2(v,\\NOne) &= v\\qquad\\forall v\\in V[1], \\\\[\\jot]\n\\mu_k(v_1, \\dotsc, v_{i-1}, \\NOne, v_{i+1}, \\dotsc, v_k) &= 0\\qquad\\forall\\ k\\neq 2,\\ 1\\le i \\le k,\\ v_j \\in V[1]. \\end{align*}\nThe pair $(\\mathcal{A},\\NOne)$ is called a \\emph{strictly unital  $\\AInfty$-algebra.}\n\nA strictly unital $\\AInfty$-algebra $(\\mathcal{A},\\NOne)$ is called \\emph{strictly augmented} if it is equipped with a linear map $\\varepsilon: V[1] \\rightarrow \\R[1]$ which satisfies\n$$ \\varepsilon(\\NOne_V) = \\NOne_\\R, \\quad \\varepsilon \\circ \\mu_1 = 0\\quad\\text{and}\\quad \\varepsilon \\circ \\mu_2 = \\mu_2\\circ(\\varepsilon \\otimes \\varepsilon), $$\nwhere $\\NOne_\\R$ is the strict unit for~$\\R$ endowed with the standard multiplication. The map $\\varepsilon$ is called a \\emph{strict augmentation.}.\n\nIf the \\emph{homological dga} $\\H(\\mathcal{A})\\coloneqq (\\H(V,\\tilde{\\mu}_1), \\mu_1 \\equiv 0, \\mu_2)$ of $\\mathcal{A}$ is strictly unital and strictly augmented, then~$\\mathcal{A}$ is called \\emph{homologically unital} and \\emph{homologically augmented}, respectively. A strictly unital and strictly augmented cochain complex $(V,\\mu_1,\\NOne,\\varepsilon)$ is called just augmented. \n\\end{Definition}\n\nWe denote by $u: \\R[1] \\rightarrow V[1]$ the injective linear map defined by $u(\\NOne_\\R)\\coloneqq \\NOne_V$, and by $u^*: \\DBCyc V \\rightarrow \\DBCyc \\R$ and $\\varepsilon^*: \\DBCyc \\R \\rightarrow \\DBCyc V$ the precompositions with $u^{\\otimes k}$ and $\\varepsilon^{\\otimes k}$ in every weight-$k$ component, respectively. \n\n\\begin{Remark}[On units and augmentations]\\phantomsection\\label{Rem:AugUnit}\n\\begin{RemarkList}\n\\item A strict unit $\\NOne_V$ for $\\mathcal{A}$ induces an $\\AInfty$-morphism $(u_k): \\R \\rightarrow V$ given by $u_1(\\NOne_\\R)\\coloneqq \\NOne_V$ and $u_k \\equiv 0$ for all $k\\ge 2$. A (general) augmentation of $(\\mathcal{A},\\NOne_V)$ is by definition any $\\AInfty$-morphism $(\\varepsilon_k): V \\rightarrow \\R$ such that $(\\varepsilon_k) \\circ (u_k) = \\Id$ as $\\AInfty$-morphisms (see~\\cite{Keller1999}). Strict augmentations are precisely the maps $\\varepsilon_1$ coming from augmentations $(\\varepsilon_k)$ with $\\varepsilon_k \\equiv 0$ for all~$k\\ge 2$.\n\n\\item As for $(V,\\mu_1,\\NOne,\\varepsilon)$, we need the chain map $\\varepsilon$ to provide the splitting of the short exact sequence of chain complexes\n$$\\begin{tikzcd}\n0 \\arrow{r} & \\R[1] \\arrow[hook]{r}{u} & \\arrow[bend left=50]{l}{\\varepsilon} V[1] \\arrow[two heads]{r} & \\coker(u) \\arrow{r} & 0,\n\\end{tikzcd}$$\nso that we get $\\H(V) \\simeq \\H_{\\RedMRM}(V)\\oplus \\R$, where $\\H_{\\RedMRM}(V)\\coloneqq \\H(\\coker(u))$. If $(V,\\mu_1)$ is non-negatively graded and we are given an injective chain map $u: \\R[1] \\rightarrow V[1]$ ($\\eqqcolon$\\,the classical augmentation), then one can show that such $\\varepsilon$ always exists. \\qedhere\n\\end{RemarkList}\n\\end{Remark}\n\n\\begin{Definition}[Reduced dual cyclic bar complex]\\label{Def:ReducedDual}\nLet $(\\mathcal{A}, \\NOne)$ be a strictly unital $\\AInfty$-algebra. Consider the injection $\\iota_{\\NOne}: \\B V \\rightarrow \\B V$, $v_1 \\otimes \\dotsb \\otimes v_k \\mapsto \\NOne \\otimes v_1 \\otimes \\dotsb \\otimes v_k$. We define the \\emph{reduced dual cyclic bar-complex} by\n$$ \\RedDBCyc V \\coloneqq \\{\\psi \\in \\DBCyc V \\mid \\psi\\circ \\iota_{\\NOne} = 0\\}. $$\nUnder the assumption of strict unitality, $\\Hd^*$ preserves $\\RedDBCyc V$, and hence we can consider the reduced cyclic cochain complex\\Correct[caption={DONE Missing red},noline]{Correct missing red in the definition of $D_r$} \n$$ D_{\\lambda,\\RedMRM}^*(V) \\coloneqq r(\\CRedDBCyc V)[1]$$\nand define the \\emph{reduced cyclic cohomology of $\\mathcal{A}$} by\n$$ \\H_{\\lambda, \\RedMRM}^*(\\mathcal{A};\\R)\\coloneqq \\H(D_{\\lambda, \\RedMRM}^*(V), \\Hd^*). $$ \n\\end{Definition}\n\n\\begin{Proposition}[Reduction to the reduced cyclic cohomology]\\label{Prop:Reduced}\nLet $\\mathcal{A}= (V,(\\mu_k))$ be an $\\AInfty$-algebra with a strict unit $\\NOne$ and a strict augmentation $\\varepsilon$. Then the inclusions $\\RedDBCyc V$, $\\varepsilon^*(\\DBCyc \\R) \\subset \\DBCyc V$ induce the decomposition\n\\begin{align*}\n\\H_\\lambda^*(\\mathcal{A};\\R) &\\simeq \\H_{\\lambda, \\RedMRM}^*(\\mathcal{A};\\R) \\oplus \\H_\\lambda^*(\\R;\\R).\n\\end{align*}\nHere we have\n\\begin{equation*}\n%\\label{Eq:Field}\n \\H_\\lambda^{q}(\\R; \\R) = \\begin{cases} \\langle \\NOne^{q+1*} \\rangle & \\text{for }q\\ge 0 \\text{ even}, \\\\\n0 & \\text{for }q> 0 \\text{ odd and }q<0, \\\\\n\\end{cases}\n\\end{equation*}\nwhere $\\NOne^{i*}: \\R[1]^{\\otimes i} \\rightarrow \\R$ is defined by $\\NOne^{i*}(\\NOne^{i}) \\coloneqq 1$.\n\\end{Proposition}\n\\begin{proof}[Sketch of the proof]\nThe maps $\\varepsilon^*: D_\\lambda(\\R) \\rightarrow D_\\lambda(V)$ and $u^*: D_\\lambda(V) \\rightarrow D_\\lambda(\\R)$ are chain maps with $u^*\\circ \\varepsilon^* = \\Id$. Therefore, we have the sequence of cochain complexes\n\\begin{equation}\\label{Eq:UnitAugSS}\n\\begin{tikzcd}\n 0 \\arrow{r} &D_{\\lambda,\\RedMRM}(V) \\arrow[hook]{r} & D_\\lambda(V) \\arrow[two heads]{r}{u^*} & \\arrow[bend left=50]{l}{\\varepsilon^*} D_\\lambda(\\R) \\arrow{r} & 0, \n\\end{tikzcd}\n\\end{equation}\nwhich is exact everywhere except for the middle, and where $\\varepsilon^*$ is a splitting map. The idea of \\cite{LodayCyclic} is to replace these cochain complexes with quasi-isomorphic bicomplexes consisting of normalized Hochschild cochains $\\bar{D}(V)$ such that the sequence becomes exact. The work then reduces to proving that $\\bar{D}(V)$ computes $\\H\\H(\\mathcal{A};\\R)$; a variant of this result for $\\AInfty$-algebras was proven in~\\cite{Lazarev2003}.\nSee Appendix~\\ref{App:AInfty} for the full proof.\n%The version for a dga, which is in fact enough for the examples in this article, also follows directly from \\cite{LodayCyclic} using Lemma \\ref{Lem:DGA} below.\n\\end{proof}\n\nWe will now compare our version of the cyclic cohomology of a dga $(V,\\mu_1, \\mu_2)$ to the version from~\\cite[Section 5]{LodayCyclic}.\nIn order to do this, we have to undo the degree shift~$V[1]$ first since it is not considered in \\cite{LodayCyclic}.\n\nLet $\\tilde{\\Hd}$, $\\tilde{\\delta}: \\bar{T}V \\rightarrow \\bar{T}V$ be the linear maps defined for all $\\tilde{v}_1$, $\\dotsc$, $\\tilde{v}_k \\in V$ by\n\\allowdisplaybreaks\n\\begin{align*}\n   \\tilde{\\Hd}(\\tilde{v}_1\\otimes \\dotsb \\otimes \\tilde{v}_k) & \\coloneqq \\begin{multlined}[t] \\sum_{i=1}^{k-1} (-1)^{i-1} \\tilde{v}_1 \\otimes \\dotsb \\otimes \\tilde{\\mu}_2(\\tilde{v}_i, \\tilde{v}_{i+1}) \\otimes \\dotsb \\otimes \\tilde{v}_k  \\\\ {}+ (-1)^{k-1+ \\tilde{v}_k(\\tilde{v}_1 + \\dotsb + \\tilde{v}_{k-1})}\\tilde{\\mu}_2(\\tilde{v}_k, \\tilde{v}_1)\\otimes\\tilde{v}_2\\otimes\\dotsb\\otimes\\tilde{v}_{k-1}, \n\\end{multlined} \\\\ \n\\tilde{\\delta}(\\tilde{v}_1\\otimes \\dotsb \\otimes \\tilde{v}_k) & \\coloneqq  \\sum_{i=1}^k (-1)^{\\tilde{v}_1 + \\dotsb + \\tilde{v}_{i-1}} \\tilde{v}_1\\otimes\\dotsb \\otimes \\tilde{\\mu}_1(\\tilde{v}_i)\\otimes \\dotsb \\otimes \\tilde{v}_k.\n\\end{align*}\nFor all $q\\ge 0$, we define\n\\begin{equation}\\label{Eq:NDSComplex}\n\\tilde{D}_q(V) \\coloneqq \\bigoplus_{\\substack{k\\ge 1 \\\\ d\\in \\Z \\\\k-d= q + 1}} (V^{\\otimes k})^d\n\\end{equation}\nand $\\tilde{\\Bdd}: \\tilde{D}_{q+1}(V) \\rightarrow \\tilde{D}_{q}(V)$ by   \n$$ \\tilde{\\Bdd}(\\tilde{v}_1\\dotsb \\tilde{v}_k) = \\tilde{\\Hd}(\\tilde{v}_1\\dotsb \\tilde{v}_k) + (-1)^{k+1} \\tilde{\\delta}(\\tilde{v}_1\\dotsb \\tilde{v}_k). $$\nIt can be checked that $\\tilde{\\Bdd}\\circ\\tilde{\\Bdd}=0$ and $\\tilde{\\Bdd}(\\Im(1-\\tilde{t}))\\subset \\Im(1-\\tilde{t})$, so that $\\tilde{\\Bdd}$ induces a boundary operator on\nthe chain complexes \\Correct[caption={DONE Wrong cyclic permutation}]{Here the $t$ is modified i.e. $\\tilde{t}(v_1\\dotsc v_k) = (-1)^{k-1} t(v_1 \\dotsc v_k)$}\n$$ \\tilde{D}(V)\\coloneqq \\bigoplus_{q\\in \\Z} \\tilde{D}_q(V)\\quad\\text{and}\\quad\\tilde{D}^\\lambda(V) \\coloneqq \\tilde{D}(V)/\\Im(1-\\tilde{t}). $$\nHere, we have $\\tilde{t}(\\tilde{v}_1 \\dotsb \\tilde{v}_k) \\coloneqq (-1)^{k + \\Abs{\\tilde{v}_k}(\\Abs{\\tilde{v}_1} + \\dotsb + \\Abs{\\tilde{v}_{k-1}})} \\tilde{v}_k \\tilde{v}_1 \\dotsb \\tilde{v}_{k-1}$.\n\nWe call $(\\tilde{D}(V),\\tilde{\\Bdd})$ the \\emph{non-degree-shifted Hochschild complex} and $(\\tilde{D}^\\lambda(V), \\tilde{\\Bdd})$ the \\emph{non-degree-shifted cyclic complex} of the dga $(V,\\mu_1,\\mu_2)$.\nWe denote their homologies by $\\ClasHH(V)$ and $\\ClasCycH(V)$, respectively.\n\nLooking at \\eqref{Eq:NDSComplex}, the chain complex $(\\tilde{D}(V),\\tilde{\\Bdd})$ is the total complex of the bicomplex\n\\begin{equation}\\label{Eq:TotComplNDS}\n\\begin{tikzcd}\n{} & \\arrow{d} &\\arrow{d} & \\arrow{d} \\\\\n{} &\\arrow{l} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 3})^2 & \\arrow{l}{\\tilde{\\delta}} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 3})^1 & \\arrow{l}{\\tilde{\\delta}} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 3})^{0}  \\\\\n{} &\\arrow{l} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 2})^2 & \\arrow{l}{-\\tilde{\\delta}} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 2})^1 & \\arrow{l}{-\\tilde{\\delta}} \\arrow{d}{\\tilde{\\Hd}} (V^{\\otimes 2})^{0} \\\\\n{} &\\arrow{l} V^2 & \\arrow{l}{\\tilde{\\delta}} V^1 & \\arrow{l}{\\tilde{\\delta}} V^{0}\n\\end{tikzcd}\n\\end{equation}\nwith chain groups being the direct sums of the top-left/right-bottom diagonals.\nThis differs from the bicomplex \\cite[Equation (5.3.2.1)]{LodayCyclic}, whose total complex is used to define the Hochschild homology of $V$ in \\cite{LodayCyclic}, by the reversed grading in degree.\nThe convention of \\cite{LodayCyclic} is namely $\\Abs{\\tilde{\\mu}_1} = -1$, whereas ours is $\\Abs{\\tilde{\\mu}_1}=1$.\nThe total complex of \\cite{LodayCyclic} corresponds to the bottom-left/right-top diagonal in \\eqref{Eq:TotComplNDS}.\nTherefore, the homologies might differ!\n\nWe also warn the careful reader that the degree is called ``weight'' in \\cite{LodayCyclic}.\n\nThe next proposition shows that our $\\CycH(V)$ indeed computes $\\ClasCycH(V)$.\n\n\\begin{Proposition}[Non-degree-shifted case] \\label{Prop:DGA}\nLet $\\mathcal{A} = (V,\\mu_1,\\mu_2)$ be a dga. Then the degree shift map\n\\begin{align*} \n U: \\tilde{D}_q (V) & \\longrightarrow D_q(V), \\\\\n        \\tilde{v}_1 \\otimes \\dotsb \\otimes \\tilde{v}_k & \\longmapsto \\varepsilon(\\SuspU, \\tilde{v}) v_1 \\otimes \\dotsb \\otimes v_k,  \\end{align*}\nwhere we denote $v_i = \\SuspU \\tilde{v}_i$ for a formal symbol $\\theta$ with $\\Abs{\\theta}=-1$, is an isomorphism of the chain complexes $(\\tilde{D}(V),\\tilde{\\Bdd})$ and $(D(V), \\Hd)$, resp.~$(\\tilde{D}^\\lambda(V),\\tilde{\\Bdd})$ and $(D^\\lambda(V),\\Hd)$.\n\\end{Proposition}\n   \n\\begin{proof} \nFirst of all, it holds $\\Abs{\\tilde{\\mu}_j} = 2 - j$ for every $j\\ge 1$. For every $j$, $k$, $l\\ge 1$ such that $j+l \\le k+1$ and for every $\\tilde{v}_1$, $\\dotsc$, $\\tilde{v}_k \\in V$, we compute\n\\begin{align*}\n&\\bigl[U^{-1}(\\Id^{l-1}\\otimes \\mu_j \\otimes \\Id^{k-j-l+1})U\\bigr](\\tilde{v}_1\\dotsb \\tilde{v}_k) \\\\[\\jot] &\\quad = (-1)^{l-1 + (j-2)(\\tilde{v}_1 + \\dotsb + \\tilde{v}_{l-1} + k - l - j +1)} \\tilde{v}_1\\dotsb\\tilde{v}_{l-1}\\tilde{\\mu}_j(\\tilde{v}_l\\dotsb \\tilde{v}_{l+j-1})\\tilde{v}_{l+j}\\dotsb \\tilde{v}_k, \\\\[\\jot]\n& [U^{-1} t_k U](\\tilde{v}_1\\dotsb \\tilde{v}_k) = (-1)^{k-1} \\tilde{v}_1 \\dotsb \\tilde{v}_k,\n\\end{align*}\nwhere we use the Koszul convention $(f_1\\otimes f_2)(v_1\\otimes v_2) = (-1)^{\\Abs{f_2}\\Abs{v_1}} f_1(v_1)\\otimes f_2(v_2)$. Using this, we obtain\n\\begin{align*}\nU^{-1} \\Hd'_k U &= \\sum_{j=1}^k \\sum_{i=0}^{k-1} (-1)^{i+j(i+k+1)} t^i_{k-j+1}(\\tilde{\\mu}_j \\otimes \\Id^{k-j})t_k^{-i}\\quad\\text{and} \\\\\nU^{-1} R_k U &= \\sum_{j=1}^k \\sum_{i=1}^{j-1} (-1)^{(i+j)(k+1)} (\\tilde{\\mu}_j\\otimes \\Id^{k-j})t_k^i.\n\\end{align*}\nIt is now easy to check that $U^{-1}\\circ \\Hd\\circ U = \\tilde{\\Bdd}$.\n\nIf $k\\in \\N$ is a weight and $d\\in\\Z$ a degree such that $k-d-1 = q$ for some $q\\in \\Z$, we have schematically $U: (k,d)\\mapsto (k, d - k) = (k,-q-1)$. Therefore, $U$ preserves the grading of chain complexes. This finishes the proof.\n\\end{proof}\n\n\n\n\\begin{Proposition}[Reduced cochains are complete in $0$,\\,$1$-connected case]\\label{Prop:SimplCon}\nSuppose that $V = \\bigoplus_{d\\ge 0} V^d$ is a non-negatively graded vector space with $V^0=\\langle 1 \\rangle$ for some $1\\in V$ ($\\eqqcolon$\\,$V$ is \\emph{connected}) and $V^1 = 0$ ($\\eqqcolon$\\,$V$ is \\emph{simply-connected}). Then for all $m\\ge 1$, we have\n$$ \\hat{\\Ext}_m \\RedDBCyc V = \\Ext_m \\RedDBCyc V. $$\n\\end{Proposition}\n\\begin{proof}\nLet $\\bar{V}\\coloneqq \\bigoplus_{d\\ge 2} V^d$. We clearly have $\\RedDBCyc V \\simeq \\DBCyc \\bar{V}$. Since $\\bar{V}[1]$ is positively graded, we have $(\\B \\bar{V})_{k}^d = 0$ whenever $k>d$. Therefore, a map $\\Psi\\in \\hat{\\Ext}_m \\bar{V}$, which is non-zero only on finitely many homogenous components of $\\BCyc V[1]^{\\otimes m}$, will be non-zero only on finitely many weights. This implies that $\\Psi\\in \\Ext_m \\bar{V}$.\n\\end{proof}\n\n\\begin{Remark}[Universal coefficient theorem]\\label{Rem:UCT}\nWe have \n$$ \\B V = \\bigoplus_{d\\in\\Z} \\bigoplus_{k=1}^\\infty (V[1]^{\\otimes k})^d\\quad\\text{and}\\quad \\DB V = \\bigoplus_{d\\in \\Z} \\bigoplus_{k=1}^\\infty (V[1]^{\\otimes k})^{d*}, $$\nand hence\n$$ (\\B V)^{\\GD} = \\bigoplus_{d\\in\\Z} \\prod_{k=1}^\\infty (V[1]^{\\otimes k})^{d*} = \\bigoplus_{d\\in \\Z} \\reallywidehat{(\\DB V)^d} = \\CDB V. $$\nTherefore, $(D^*_\\lambda(V), \\Hd^*)$ is dual to $(D^\\lambda(V), \\Hd)$ as a chain complex. Now, because we work over $\\R$, the universal coefficient theorem gives\n\\begin{equation*}\n%\\label{Eq:UCT}\n \\H^q_\\lambda(\\mathcal{A},\\Hd^*) \\simeq [\\H_q^\\lambda(\\mathcal{A},\\Hd)]^*\\quad\\text{for all } q\\in \\Z. \n\\end{equation*}\nSuppose that we have found closed homogenous elements $(w_i)_{i\\in I}\\subset D^\\lambda(V)$ for some index set~$I$ which induce a basis of $\\H^\\lambda(\\mathcal{A}; \\R)$. For every $i\\in I$, we define the linear map $w_i^*: D^\\lambda(V) \\rightarrow \\R$ by prescribing\n$$ w_i^*(w_j) = \\delta_{ij}\\qquad\\text{for all }j\\in I $$\nand $w_i^* \\equiv 0$ on $\\Im \\Hd$ and on a complement \\Correct[caption={DONE Universal coefficient theorem}]{Here is enough an arbitrary complement of $\\Ker)(b)$. That means that for every $i$, we can have a different complement $Z_i$} of $\\Ker(\\Hd)$ in $D^\\lambda(V)$. Then $(w_i^*)_{i\\in I} \\subset D_\\lambda^*(V)$ are closed homogenous elements which generate linearly independent cohomology classes in $\\H_\\lambda^*(\\mathcal{A}; \\R)$; if we denote $I_q \\coloneqq \\{i\\in I \\mid w_i \\in C^\\lambda_q(V)\\}$, then we can write\n\\begin{equation*}\n\\H_\\lambda^q(\\mathcal{A}; \\R) = \\Bigl\\{ \\sum_{i\\in I_q} \\alpha_i w_i^* \\bigMid \\alpha_i\\in \\R \\Bigr\\}\\quad\\text{for all }q\\in\\Z.\\qedhere\n\\end{equation*}\n\\end{Remark}\n\n\\end{document}\n", "meta": {"hexsha": "a45bd41ede733a3ebdd358230678afbed864bf90", "size": 30886, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Subfiles/AlgStr_Cyc.tex", "max_stars_repo_name": "p135246/phd-thesis", "max_stars_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subfiles/AlgStr_Cyc.tex", "max_issues_repo_name": "p135246/phd-thesis", "max_issues_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subfiles/AlgStr_Cyc.tex", "max_forks_repo_name": "p135246/phd-thesis", "max_forks_repo_head_hexsha": "0e124466a3d0ff988c012225400fadb0b170aa9e", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.701897019, "max_line_length": 556, "alphanum_fraction": 0.6682963155, "num_tokens": 11977, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4034561853290477}}
{"text": "\\chapter{Linear algebra\\\\(intuitive approach)}\\label{chapter:linear algebra intuitive}\nLinear algebra is one of the most important and often used fields, both in theoretical and applied mathematics. It brings together the analysis of systems of linear equations and the analysis of linear functions (in this context usually called linear transformations), and is employed extensively in almost any modern mathematical field, e.g. approximation theory, vector analysis, signal analysis, error correction, 3-dimensional computer graphics and many, many more.\n\nIn this book, we divide our discussion of linear algebra into to chapters: the first (this chapter) deals with a wider, birds-eye view of the topic: it aims to give an intuitive understanding of the major ideas of the topic. For this reason, in this chapter we limit ourselves almost exclusively to discussing linear algebra using 2- and 3-dimensional analysis (and higher dimensions when relevant) using real numbers only. This allows us to first create an intuitive picture of what is linear algebra all about, and how to use correctly the tools it provides us with.\n\nThe next chapter takes the opposite approach: it builds all concepts from the ground-up, defining precisely (almost) all basic concepts and proving them rigorously, and only then using them to build the next steps. This approach has two major advantages: it guarantees that what we build has firm foundations and does not fall apart at any future point, and it also allows us to generalize the ideas constructed during the process to such extent that they can be used as foundation to build ever newer tools we can apply in a wide range of cases.\n", "meta": {"hexsha": "4c8b8120dac751e5747c42facb1032af6ecaaa07", "size": 1675, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/linear_algebra_intuitive/preface.tex", "max_stars_repo_name": "barak/maths_book", "max_stars_repo_head_hexsha": "da47454d85ed7c5167d7951bb5c29c28d987b107", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2021-12-25T20:02:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T17:57:59.000Z", "max_issues_repo_path": "chapters/linear_algebra_intuitive/preface.tex", "max_issues_repo_name": "barak/maths_book", "max_issues_repo_head_hexsha": "da47454d85ed7c5167d7951bb5c29c28d987b107", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2022-01-17T05:01:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-20T06:18:24.000Z", "max_forks_repo_path": "chapters/linear_algebra_intuitive/preface.tex", "max_forks_repo_name": "barak/maths_book", "max_forks_repo_head_hexsha": "da47454d85ed7c5167d7951bb5c29c28d987b107", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2022-01-17T10:15:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T10:45:13.000Z", "avg_line_length": 239.2857142857, "max_line_length": 568, "alphanum_fraction": 0.8107462687, "num_tokens": 322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4034561850678579}}
{"text": "\\documentclass[12pt,fleqn]{article}\n\n\\usepackage[paper]{ets-papers}\n\\setcounter{page}{1}\n\n\\input m-defs\n\\def\\TN{450052}\n\\input colordvi\n\n\\title{\n  An EMTP Theory Book Correction\n}\n\\author{\n  \\vbox{\\hsize=5.0in \\baselineskip=12pt\n    E.~T.~Scharlemann\n  }\n\\\\Lawrence Livermore National Laboratory\n\\\\Livermore, California 94550\n}\n\n\\begin{document}\n\n%\\topmargin-1in\n%\\oddsidemargin-1in\n%\\evensidemargin-1in\n%\\textheight792pt\n%\n%\\includegraphics[0,0][612,792]{DC-EMTP.ps}\n%\\thispagestyle{empty}\n%\n%%\\newpage\n%%\\thispagestyle{empty}\n\n\n%\\topmargin30pt\n%\\oddsidemargin0in\n%\\evensidemargin0in\n\n\\showllnl\n\\maketitle\n\\setcounter{page}{1}\n\nIn Carsons' 1926 article ~\\cite{Carson} on wave propagation on a wire above the ground, the impedance of an overhead wire or pair of wires with ground return is derived, and expressed in terms of the integral\n\\[\n   J(p, q) = P + i Q = \\int_0^\\infty \\left( \\sqrt{\\mu^2 + i} - \\mu \\right) e^{-p\\mu} \\cos q\\mu \\; d\\mu\n\\]\nwith\n\\[\n   r = a = \\sqrt{p^2 + q^2}  \\ ,\n\\]\n\\[\n   \\theta = \\phi = \\tan^{-1}(q/p)  \\ .\n\\]\n\nThe EMTP Theory Book~\\cite{EMTP}, pp.~4-7  to 4-9, presents the equations stated to be used by the Alternative Transients Program ATP (or Electromagnetic Transients Program EMTP) for this impedance. The impedance expressions in~\\cite{EMTP} are not the same as the expressions in~\\cite{Carson}, although they are supposed to be. The main correction required to bring~\\cite{EMTP} into agreement with~\\cite{Carson} is to replace\n\\[\n   \\sgn = (-1)^{\\left[\\frac{n - 1}{4} \\bmod 2\\right]} = 1,1, -1, -1, -1, -1, 1, 1\\ldots \\text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \\ldots\n\\]\nas described just below Eq.~(4.12) of~\\cite{EMTP}, with\n\\[\n   \\sgn = (-1)^{\\left[\\frac{n + 1}{2} \\bmod 2\\right]} = 1,1, -1, -1, 1, 1, -1, -1\\ldots \\text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \\ldots  \\ ;\n\\]\ni.e., the sign of the terms in the series for $b$ alternates every two terms rather than every four terms.\n\nThe expressions in~\\cite{EMTP} should be:\n\\[\n   b_1 = \\frac{\\sqrt{2}}{6}\n\\]\n\\[\n   b_2 = \\frac{1}{16}\n\\]\n\\[\n   b_n = \\frac{\\sgn}{n(n + 2)} b_{n - 2}\n\\]\n\\[\n   c_2 = 1.3659315 = \\ln \\frac{2}{\\gamma} + 1 + \\frac{1}{2} - \\frac{1}{4}\n\\]\n($\\gamma$ is defined in~\\cite{Carson} as 1.7811 and is Euler's constant [$\\gamma_E = 0.57722$] exponentiated: $\\gamma = e^{\\gamma_E}$)\n\\[\n   c_n = c_{n-2} + \\frac{1}{n} + \\frac{1}{n + 2}\n\\]\n\\[\n   d_n = \\frac{\\pi}{4} b_n\n\\]\n\\[\n   \\sgn = (-1)^{\\left[\\frac{n + 1}{2} \\bmod 2\\right]} = 1,1, -1, -1, 1, 1, -1, -1\\ldots \\text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \\ldots \\ .\n\\]\n\nOther corrections are simple typographic errors, and have been caught in other references~\\cite{Wang} to Carson's formula. With corrections in red, the  expressions for Carson's $P$ and $Q$ in~\\cite{EMTP} should be\n\\begin{align*}\n   P = & \\frac{\\pi}{8} - b_1 a \\cos\\phi \\\\\n    & + b_2 \\left[ (c_2 - \\ln a) a^2 \\cos 2\\phi + \\Red{\\phi}\\; a^2 \\sin 2\\phi \\right] + b_3 a^3 \\cos 3\\phi  - d_4 a^4 \\cos 4\\phi - b_5 a^5 \\cos 5\\phi \\\\\n    & + b_6 \\left[ (c_6 - \\ln a) a^6 \\cos 6\\phi + \\phi\\; a^6 \\sin 6\\phi \\right] + b_7 a^7 \\cos 7\\phi  - d_8 a^8 \\cos 8\\phi - b_9 a^9 \\cos 9\\phi \\\\\n    & + b_{10} \\left[ (c_{10} - \\ln a) a^{10} \\cos 10\\phi + \\phi\\; a^{10} \\sin 10\\phi \\right] + b_{11} a^{11} \\cos 11\\phi  \\\\\n    & \\text{\\hskip20mm} - d_{12} a^{12} \\cos 12\\phi - b_{13} a^{13} \\cos 13\\phi \\ldots\n\\end{align*}\nrepeating in groups of four.\n\\begin{align*}\n   Q = & \\frac{1}{2}(0.6159315 - \\ln a) + b_{\\Red{1}} a \\cos\\phi - d_2 a^2 \\cos 2\\phi + b_3 a^3 \\cos 3\\phi \\\\\n    & - b_4 \\left[ (c_4 - \\ln a) a^4 \\cos 4\\phi + \\phi a^4 \\sin 4\\phi \\right] + b_5 a^5 \\cos 5\\phi  - d_6 a^6 \\cos 6\\phi + b_7 a^7 \\cos 7\\phi \\\\\n    & - b_8 \\left[ (c_8 - \\ln a) a^8 \\cos 8\\phi + \\phi a^8 \\sin 8\\phi \\right] + b_9 a^9 \\cos 9\\phi  - d_{10} a^{10} \\cos 10\\phi + b_{11} a^{11} \\cos 11\\phi \\\\\n    & - b_{12} \\left[ (c_{12} - \\ln a) a^{12} \\cos 12\\phi + \\phi a^{12} \\sin 12\\phi \\right] + b_{13} a^{13} \\cos 13\\phi  \\\\\n    & \\text{\\hskip20mm} - d_{14} a^{14} \\cos 14\\phi + b_{15} a^{15} \\cos 15\\phi \\ldots\n\\end{align*}\nalso repeating in groups of four. The term 0.6159315 is $1/2 + \\log(2/\\gamma)$, and the $P$ and $Q$ are the terms inside the curly brackets of Eq.~(4.11) of~\\cite{EMTP}. The typographical errors above were corrected in~\\cite{Wang} but not the ordering of signs in the $b$ series.\n\nFor reference, Carson's equations~\\cite{Carson} are (with $r = a$ and $\\theta = \\phi$):\n\\[\n   s_2 = \\frac{1}{1!2!} \\left(\\frac{r}{2}\\right)^2 \\cos 2\\theta\n    -\\frac{1}{3!4!} \\left(\\frac{r}{2}\\right)^6 \\cos 6\\theta\n    +\\frac{1}{5!6!} \\left(\\frac{r}{2}\\right)^{10} \\cos 10\\theta \\ldots\n\\]\n\\[\n   s_2^\\prime = \\frac{1}{1!2!} \\left(\\frac{r}{2}\\right)^2 \\sin 2\\theta\n    -\\frac{1}{3!4!} \\left(\\frac{r}{2}\\right)^6 \\sin 6\\theta\n    +\\frac{1}{5!6!} \\left(\\frac{r}{2}\\right)^{10} \\sin 10\\theta \\ldots\n\\]\n\\[\n   s_4 = \\frac{1}{2!3!} \\left(\\frac{r}{2}\\right)^4 \\cos 4\\theta\n    -\\frac{1}{4!5!} \\left(\\frac{r}{2}\\right)^8 \\cos 8\\theta\n    +\\frac{1}{6!7!} \\left(\\frac{r}{2}\\right)^{12} \\cos 12\\theta \\ldots\n\\]\n\\[\n   s_4^\\prime = \\frac{1}{2!3!} \\left(\\frac{r}{2}\\right)^4 \\sin 4\\theta\n    -\\frac{1}{4!5!} \\left(\\frac{r}{2}\\right)^8 \\sin 8\\theta\n    +\\frac{1}{6!7!} \\left(\\frac{r}{2}\\right)^{12} \\sin 12\\theta \\ldots\n\\]\n\\[\n   \\sigma_1 = \\frac{r \\cos\\theta}{3} - \\frac{r^5 \\cos 5\\theta}{3^2 5^2 7} + \\frac{r^9 \\cos 9\\theta}{3^2 5^2 7^2 9^2 11} \\ldots\n\\]\n\\[\n   \\sigma_3 = \\frac{r^3 \\cos 3\\theta}{3^2 5} - \\frac{r^7 \\cos 7\\theta}{3^2 5^2 7^2 9} + \\frac{r^{11} \\cos 11\\theta}{3^2 5^2 7^2 9^2 11^2 13} \\ldots\n\\]\n\\begin{align*}\n   \\sigma_2 = & \\left( 1 + \\frac{1}{2} - \\frac{1}{4}\\right) \\frac{1}{1! 2!} \\left(\\frac{r}{2}\\right)^2 \\cos 2\\theta \\\\\n   & - \\left( 1 + \\frac{1}{2} + \\frac{1}{3} + \\frac{1}{4} - \\frac{1}{8}\\right) \\frac{1}{3! 4!} \\left(\\frac{r}{2}\\right)^6 \\cos 6\\theta \\\\\n   & + \\left( 1 + \\frac{1}{2} + \\frac{1}{3} + \\frac{1}{4} + \\frac{1}{5} + \\frac{1}{6} - \\frac{1}{12}\\right) \\frac{1}{5! 6!} \\left(\\frac{r}{2}\\right)^{10} \\cos 10\\theta \\ldots\n\\end{align*}\n\\begin{align*}\n   \\sigma_4 = & \\left( 1 + \\frac{1}{2} + \\frac{1}{3} - \\frac{1}{6}\\right) \\frac{1}{2! 3!} \\left(\\frac{r}{2}\\right)^4 \\cos 4\\theta \\\\\n   & - \\left( 1 + \\frac{1}{2} + \\frac{1}{3} + \\frac{1}{4} + \\frac{1}{5} - \\frac{1}{10}\\right) \\frac{1}{4! 5!} \\left(\\frac{r}{2}\\right)^8 \\cos 8\\theta \\\\\n   & + \\left( 1 + \\frac{1}{2} + \\frac{1}{3} + \\frac{1}{4} + \\frac{1}{5} + \\frac{1}{6} + \\frac{1}{7} - \\frac{1}{14}\\right) \\frac{1}{6! 7!} \\left(\\frac{r}{2}\\right)^{12} \\cos 12\\theta \\ldots\n\\end{align*}\n\\[\n   P = \\frac{\\pi}{8}\\left(1 - s_4\\right) + \\frac{1}{2} \\left(\\ln\\frac{2}{\\gamma} - \\ln r\\right)s_2 + \\frac{\\theta}{2} s_2^\\prime - \\frac{1}{\\sqrt{2}}\\sigma_1 + \\frac{1}{2}\\sigma_2 + \\frac{1}{\\sqrt{2}}\\sigma_3  \\ ,\n\\]\n\\[\n   Q = \\frac{1}{4} + \\frac{1}{2} \\left(\\ln\\frac{2}{\\gamma} - \\ln r\\right)\\left(1 - s_4\\right) - \\frac{\\theta}{2} s_4^\\prime - \\frac{\\pi}{8} s_2 + \\frac{1}{\\sqrt{2}}\\sigma_1 + \\frac{1}{\\sqrt{2}}\\sigma_3 - \\frac{1}{2}\\sigma_4  \\ .\n\\]\n\nFig.~\\ref{fig:l} compares the numerical results for $0 < r <= 10$ at  $\\theta = 2\\pi/3$ for the series in~\\cite{Carson} with the corrected series from~\\cite{EMTP}. \n\\begin{figure}[H]\n  \\hbox{\n     \\includegraphics[width=3in]{carson.ps}\n     \\includegraphics[width=3in]{emtp.ps}\n  }\n  \\caption{Comparison of results for Carson's series at $\\theta = 2\\pi/3$ (left) and the corrected EMTP Theory Book series at the same value for $\\phi$ (right). Terms up to and including $r^{23}$ (or $a^{23}$) were retained in the series to get valid results to $a = r = 10$.}\n  \\label{fig:l}\n\\end{figure}\n\nPython programs (and typeset \\LaTeX) to calculate (and display) both Carson's series and the corrected EMTP Theory Book series are available from the author.\n\nComparison of the corrected EMTP Theory Book series and Carson's series with the results of ATP for the impedance of a single wire above\nthe ground plane suggests that ATP in fact uses the correct expressions, and \\emph{not} what is described in the EMTP Theory Book. Regrettably, we have been unable to obtain the source code for ATP to verify this inference.\n\n\\section*{Acknowledgments}\n\nI am happy to acknowledge useful conversations with Barry Kirkendall and Nils Stenvig.\n\nThis work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.\n\n\\vskip5mm\n\\baselineskip=12pt\n\\begin{thebibliography}{9}\n\n\\bibitem{Carson} J.~R.~Carson, ``Wave Propagation in Overhead Wires with Ground Return'', \\emph{Bell System Technical Journal}, {\\bf 5}, 539-554 (1926).\n\n\\bibitem{EMTP} H.~W.~Dommel, ``Electromagnetic Transients Program (EMTP) Theory Book'', Bonneville Power Administration, Portland, OR (1981 or 1986 or 1994 or ?).\n\n\\bibitem{Wang} Y.-J.~Wang and S.-J.~Liu, ``A Review of Methods for Calculation of Frequency-dependent Impedance of Overhead Power Transmission Lines,'' \\emph{Proc.~Natl.~Sci.~Counc.~ROC(A)}, {\\bf 25}, No.~6, pp.~329-338 (2001).\n\n\\end{thebibliography}\n\n\\vskip5mm\n\\hrule\n\\vskip5mm\n\\parindent=0pt\n\n%\\ets\n\n\n\\end{document}\n", "meta": {"hexsha": "99a4e10bcb34ec0a8f1244ccb4305308761b409f", "size": 8975, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/research/line_impedances/EMTP_Theory_Book_Correction/Series.tex", "max_stars_repo_name": "mzy2240/GridCal", "max_stars_repo_head_hexsha": "0352f0e9ce09a9c037722bf2f2afc0a31ccd2880", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 284, "max_stars_repo_stars_event_min_datetime": "2016-01-31T03:20:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:16:52.000Z", "max_issues_repo_path": "src/research/line_impedances/EMTP_Theory_Book_Correction/Series.tex", "max_issues_repo_name": "mzy2240/GridCal", "max_issues_repo_head_hexsha": "0352f0e9ce09a9c037722bf2f2afc0a31ccd2880", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 94, "max_issues_repo_issues_event_min_datetime": "2016-01-14T13:37:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T03:13:56.000Z", "max_forks_repo_path": "src/research/line_impedances/EMTP_Theory_Book_Correction/Series.tex", "max_forks_repo_name": "mzy2240/GridCal", "max_forks_repo_head_hexsha": "0352f0e9ce09a9c037722bf2f2afc0a31ccd2880", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 84, "max_forks_repo_forks_event_min_datetime": "2016-03-29T10:43:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-22T16:26:55.000Z", "avg_line_length": 46.5025906736, "max_line_length": 425, "alphanum_fraction": 0.6139275766, "num_tokens": 3846, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4034386312801357}}
{"text": "\n\\subsection{Isoquants}\n\nIsoquants are indifference curves for firms.\n\nWe have a production function: \\(Q=f(X)\\).\n\nAn isoquant is defined for each \\(c\\) \\(f(X)=c\\), where \\(X\\) is a vector.\n\n\\subsection{Marginal rate of technical substitution}\n\nThis is the marginal rate of substitution, adapted for firms.\n\n\\(MRTS=\\)\n\n\\subsection{Marginal and average costs}\n\n\\subsection{Average total cost}\n\n\\subsection{Long-run average incremental cost}\n\n", "meta": {"hexsha": "7370992a399819c40448b6e6a695b8acc5c9949a", "size": 441, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/intermediate/01-02-isoquant.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/intermediate/01-02-isoquant.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/intermediate/01-02-isoquant.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.0454545455, "max_line_length": 74, "alphanum_fraction": 0.7414965986, "num_tokens": 107, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.40343862510414413}}
{"text": "\\section{Method}\n\\label{sec:method}\n\n\\subsection{The data}\n\\label{sec:the_data}\n\nWe used the publicly available \\kepler-\\gaia\\ DR2 crossmatched\ncatalog\\footnote{Available at gaia-kepler.fun} to combine the \\mct\\ catalog of\nstellar rotation periods, measured from \\kepler\\ light curves, with the \\gaia\\\nDR2 catalog of parallaxes, proper motions and apparent magnitudes.\nReddening and extinction from dust was calculated for each star using the\nBayestar dust map implemented in the {\\tt dustmaps} {\\it Python} package\n\\citep{green2018}, and {\\tt astropy} \\citep{astropy2013, astropy2018}.\n\nFor this work, we used the precise \\textit{Gaia} DR2 photometric color,\n$G_{\\rm BP} - G_{\\rm RP}$, to estimate \\teff\\ for the Kepler rotators.\nTo calibrate this relation, Curtis \\etal\\ (2020, in prep) combined effective\ntemperature measurements for nearby, unreddened field stars in benchmark\nsamples, including FGK stars characterized with high-resolution optical\nspectroscopy \\citep{brewer2016}, M dwarfs characterized with low-resolution\noptical and near-infrared spectroscopy \\citep{mann2015}, and K and M dwarfs\ncharacterized with interferometry and bolometric flux analyses\n\\citep{boyajian2012}.\nThis empirical color--temperature relation is valid over the color range $0.55\n< (G_{\\rm BP} - G_{\\rm RP})_0 < 3.20$, corresponding to $6470 < T_{\\rm eff} <\n3070$~K.\nThe dispersion about the relation implies a high precision of 50~K.\nThese benchmark data enable us to accurately estimate \\teff\\ for cool dwarfs\n\\citep[\\eg][]{rabus2019}, and allows us to correct for interstellar reddening\nat all temperatures\\footnote{The color--temperature relation is described in\ndetail in the Appendix of, and the formula is provided in Table 4 of, Curtis\n\\etal\\ (2020, in prep).}.\nThe equation we used to calculate photometric temperatures from Gaia \\gcolor\\\ncolor is a seventh-order polynomial with coefficients given in table\n\\ref{tab:coeffs}.\n\\begin{table}[h!]\n  \\begin{center}\n      \\caption{\n          Coefficient values for the 7th-order polynomial used to estimate\n      \\teff\\ from \\Gaia\\ \\gcolor\\ color, calibrated in Curtis \\etal\\ (2020, in\n      prep).}\n    \\label{tab:coeffs}\n    \\begin{tabular}{l|c} % <-- Alignments: 1st column left and 2nd middle, with vertical lines in between\n        (\\gcolor\\ ) exponent & Coefficient  \\\\\n      \\hline\n      $0$ & -416.585 \\\\\n      $1$ & 39780.0  \\\\\n      $2$ & -84190.5 \\\\\n      $3$ & 85203.9  \\\\\n      $4$ & -48225.9 \\\\\n      $5$ & 15598.5  \\\\\n      $6$ & -2694.76 \\\\\n      $7$ & 192.865  \\\\\n    \\end{tabular}\n  \\end{center}\n\\end{table}\n\nPhotometric binaries and subgiants were removed from the \\mct\\ sample by\napplying cuts to the color-magnitude diagram (CMD), shown in figure\n\\ref{fig:age_gradient}.\nA 6th-order polynomial was fit to the main sequence and raised by 0.27 dex to\napproximate the division between single stars and photometric binaries (shown\nas the curved dashed line in figure \\ref{fig:age_gradient}).\nAll stars above this line were removed from the sample.\nPotential subgiants were also removed by eliminating stars brighter than 4th\nabsolute magnitude in \\gaia\\ G-band.\nThis cut also removed a number of main sequence F stars from our sample,\nhowever these hot stars are not the focus of our gyrochronology study since\ntheir small convective zones inhibit the generation of a strong magnetic\nfield.\nThe removal of photometric binaries and evolved/hot stars reduced the total\nsample of around 34,000 stars by almost 10,000.\n\nThe rotation periods of the dwarf stars in the \\mct\\ sample are shown on a\n\\gaia\\ color-magnitude diagram (CMD) in the top panel of figure\n\\ref{fig:age_gradient}.\nIn the bottom panel, the stars are colored by their gyrochronal age,\ncalculated using the \\citet{angus2019} gyrochronology relation.\nThe stars with old gyrochronal ages, plotted in purple hues, predominantly lie\nalong the upper edge of the MS, where stellar evolution models predict old\nstars to be, however the majority of these `old' stars are bluer than \\gcolor\\\n$\\sim$ 1.5 dex.\nThe lack of gyrochronologically old M dwarfs suggests that either old M dwarfs\nare missing from the \\mct\\ catalog, or the \\citet{angus2019} gyrochronology\nrelation under-predicts the ages of low-mass stars.\nGiven that lower-mass stars stay active for longer than higher-mass stars\n\\citep[\\eg][]{west2008, newton2017, kiman2019}, and are therefore more likely\nto have measurable rotation periods at old ages, the latter scenario seems\nlikely.\nHowever, it is also possible that the rotation periods of the oldest early M\ndwarfs are so long that they are not measurable with Kepler data.\nGround-based rotation period measurements of mid and late M dwarfs indicate\nthat there is an upper limit to the rotation periods of {\\it late} M dwarfs of\naround 140 days \\citep{newton2016, newton2018}, which is much\nlonger than the longest rotation periods measured in the \\mct\\ sample (around\n70 days).\nThe apparent lack of old gyro-ages for M dwarfs in figure\n\\ref{fig:age_gradient} may be caused by a combination of ages being\nunderestimated by a poorly calibrated model, and rotation period detection\nbias.\nThe \\citet{angus2019} gyrochronology relation is a simple polynomial model,\nfit to the period-color relation of Praesepe.\nInaccuracies at low masses are a typical feature of empirically calibrated\ngyrochronology models since there are no (or at least very few) old M dwarfs\nwith rotation periods and the models are poorly calibrated for these stars.\n\\begin{figure}\n  \\caption{\n      Top: de-reddened MS \\kepler\\ stars with \\mct\\ rotation periods, plotted\n    on a \\gaia\\ CMD.\n    We removed photometric binaries and subgiants from the sample by excluding\n    stars above the dashed lines.\n    Bottom: a zoom-in of the top panel, with stars colored by their\n    gyrochronal age \\citep{angus2019}, instead of their rotation period.\n    A general age gradient is visible across the main sequence.\n    Since the \\citet{angus2019} relation predicts that the oldest stars in\n    the \\mct\\ sample are late-G and early-K dwarfs, it is probably\n    under-predicting the ages of late-K and early-M dwarfs.\n}\n  \\centering\n    \\includegraphics[width=1\\textwidth]{CMD_cuts_double}\n\\label{fig:age_gradient}\n\\end{figure}\n\nThe {\\tt Pyia} \\citep{price-whelan_2018} and {\\tt astropy} \\citep{astropy2013,\nastropy2018} {\\it Python} packages were used to calculate velocities for the\n\\mct\\ sample.\n{\\tt Pyia} calculates velocity samples from the full \\gaia\\ uncertainty\ncovariance matrix via Monte Carlo sampling, thereby accounting for the\ncovariances between \\gaia\\ positions, parallaxes and proper motions.\nStars with negative parallaxes or parallax signal-to-noise ratios less than 10\n(around 3,000 stars), stars fainter than 16th magnitude (200 stars), stars\nwith absolute \\vb\\ uncertainties greater than 1 \\kms\\ (1000 stars), and stars\nwith galactic latitudes greater than 15\\degrees\\ (5500 stars, justification\nprovided in the appendix) were removed from the sample.\nFinally, we removed almost 2000 stars with rotation periods shorter than the\nmain population of periods, since this area of the period-\\teff\\ diagram is\nsparsely populated.\nWe removed these rapid rotators by cutting out stars with gyrochronal ages\nless than 0.5 Gyr \\citep[based on the][gyro-model]{angus2019}, because a 0.5\nGyr gyrochrone\\footnote{A gyrochrone is a gyrochronological isochrone, or a\nline of constant age in period-\\teff, or period-color space.} traces the\nbottom edge of the main population of rotation periods.\nAfter these cuts, around 13,000 stars out of the original $\\sim$34,000 were\nincluded in the sample.\n", "meta": {"hexsha": "6de3085fe1b0321d10939872317e71f641d6d379", "size": 7601, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/method.tex", "max_stars_repo_name": "RuthAngus/kinematics-and-rotation", "max_stars_repo_head_hexsha": "7cad283612bc70ca9d12c79978561b938f527198", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-01-23T18:24:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-15T10:37:05.000Z", "max_issues_repo_path": "paper/method.tex", "max_issues_repo_name": "RuthAngus/kinematics-and-rotation", "max_issues_repo_head_hexsha": "7cad283612bc70ca9d12c79978561b938f527198", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-03-11T16:46:55.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-23T15:10:58.000Z", "max_forks_repo_path": "paper/method.tex", "max_forks_repo_name": "RuthAngus/kinematics-and-rotation", "max_forks_repo_head_hexsha": "7cad283612bc70ca9d12c79978561b938f527198", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-23T14:11:57.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-21T11:51:15.000Z", "avg_line_length": 52.4206896552, "max_line_length": 105, "alphanum_fraction": 0.7680568346, "num_tokens": 2017, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4034386189281524}}
{"text": "\\begin{intro}\n  We can embed finite element methods for the Darcy problem, also for\n  the Maxwell problem, into a common framework based on the de Rham\n  complex. If we wanted to do this in its full mathematical beauty, we\n  would have to spend some time introducing the concept and notation\n  of differential forms. As an alternative, we can use the concrete\n  vector spaces $\\Hdiv(\\domain)$ and $\\Hcurl(\\domain)$. The drawback\n  is, that we have to prove several particular cases, where the\n  abstract theory only knows one common case. Nevertheless, it is\n  worthwhile to begin this way, such that the reader has an easier\n  task reading the full theory\n  in~\\cite{ArnoldFalkWinther06acta,ArnoldFalkWinther10}. As a byproduct,\n  we will prove in generality some of the properties of polynomial\n  spaces in Chapter~\\ref{cha:darcy}.\n\\end{intro}\n\n\\subsection{Excursion to differential forms}\n\n\\input{alt}\n\n\\subsection{Well-posedness of the Maxwell problem}\n\n\\begin{Definition}{hlambda}\n  The space $H\\Lambda^k(\\domain)$ is the closure of $\\Lambda^k(\\domain)$\n  under the norm corresponding to the inner product\n  \\begin{gather}\n    \\scal(u,v)_{H\\Lambda^k}\n    = \\scal(u,v)_{L^2\\Lambda^k}\n    + \\scal(d u, d v)_{L^2\\Lambda^{k+1}}.\n  \\end{gather}\n  The space $H\\Lambda^k_0(\\domain)$ is the closure of\n  $C^{\\infty}_{00}\\Lambda^k(\\domain)$ with respect to the same norm.\n\n  Both spaces are Hilbert spaces and we have\n  \\begin{gather}\n    \\gamma\\omega(v_1,\\dots,v_k) = 0 \\qquad\n    \\forall \\omega\\in H\\Lambda^k_0(\\domain),\n  \\end{gather}\n  and tangential vector fields $v_1,\\dots,v_k$.\n\\end{Definition}\n\n\\begin{Notation}{hlambda}\n  We can summarize the results of the previous section by the notation\n  of the \\define{Hilbert cochain complex}\\index{cochain complex} of\n  differential forms and the corresponding cochain complex for proxy\n  fields\n  \\begin{gather}\\minCDarrowwidth20pt\n    \\label{eq:derham:9}\n    \\begin{CD}\n      \\R\n      @>{d}>> H\\Lambda^0(\\domain)\n      @>{d}>> H\\Lambda^1(\\domain)\n      @>{d}>> H\\Lambda^2(\\domain)\n      @>{d}>> H\\Lambda^3(\\domain)\n      @>>> 0\n      \\\\\n      @.\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      \\\\\n      \\R\n      @>{\\subset}>> H^1(\\domain)\n      @>{\\nabla}>> \\Hcurl(\\domain)\n      @>{\\curl}>> \\Hdiv(\\domain)\n      @>{\\div}>> L^2(\\domain)\n      @>>> 0,\n    \\end{CD}\n  \\end{gather}\n  such that $d=d_k\\colon H\\Lambda^k(\\domain) \\to H\\Lambda^{k+1}(\\domain)$ and\n  \\begin{gather}\n    d^2 = d\\circ d = d_{k+1} \\circ d_k = 0.\n  \\end{gather}\n\\end{Notation}\n\n\\begin{remark}\n  The spaces $H\\Lambda^k(\\domain)$ are Hilbert spaces with values in\n  the spaces of alternating $k$-forms on $\\R^d$. From linear algebra,\n  we know that all alternating $k$-forms are zero if $k$ exceeds the\n  dimension of the vector space.  Therefore, the sequence above is\n  only valid in three dimensions, and it must be shorter by one member\n  in two dimensions. Changing our view back to differential operators,\n  we realize that there are two relevant sequences in two\n  dimensions. In the following diagram, the sequence on top can be\n  used to formulate Maxwell problems in $\\Hcurl$ in two dimensions,\n  while the sequence on the bottom relates to the mixed form of the\n  Laplacian.\n\n  We introduce the sequences in two dimensions and afterwards will\n  focus our arguments on the more general case of three dimensions\n  again. Specialization to two dimensions are straight forward.\n\\end{remark}\n\n\\begin{Notation}{hlambda-2d}\n  In two dimensions, we consider the de Rham sequences\n  \\begin{gather}\\minCDarrowwidth20pt\n    \\label{eq:derham:8}\n    {\\small\n    \\begin{CD}\n      \\R\n      @>{\\subset}>> H^1(\\domain)\n      @>{\\nabla}>> \\Hcurl(\\domain)\n      @>{\\curl}>> L^2(\\domain)\n      @>>> 0\n      \\\\\n      @.\n      @A{\\cong}AA\n      @A{\\cong}AA\n      @A{\\cong}AA\n      \\\\\n      \\R\n      @>{d}>> H\\Lambda^0(\\domain)\n      @>{d}>> H\\Lambda^1(\\domain)\n      @>{d}>> H\\Lambda^2(\\domain)\n      @>>> 0\n      \\\\\n      @.\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      \\\\\n      \\R\n      @>{\\subset}>> H^1(\\domain)\n      @>{\\curl}>> \\Hdiv(\\domain)\n      @>{\\div}>> L^2(\\domain)\n      @>>> 0,\n    \\end{CD}\n    }\n  \\end{gather}\n\\end{Notation}\n\nThe value of this notation lies in the following theorem by de Rham,\nwhich describes the relation between the elements of the sequence. It\nis cited here without proof.\n\n\\begin{Definition}{cohomology-space}\n  The \\define{cohomology group} in $\\Lambda^k(\\domain)$ is defined in\n  differential geometry as\n  \\begin{gather}\n    \\mathcal H_k(\\domain) = \\nicefrac{\\ker{d_k}}{\\range{d_{k-1}}}.\n  \\end{gather}\n  Since we have a Hilbert space structure, we can much more\n  conveniently choose a representative in $\\ker{d_k} \\subset H\\Lambda^k(\\domain)$\n  \\begin{gather}\n    \\mathcal H_k(\\domain) = \\bigl\\{ \\omega\\in \\ker{d_k}\n    \\;\\big|\\;\n    \\form(\\omega,d\\eta) = 0 \\quad\\forall \\eta\\in H\\Lambda^{k-1}(\\domain)\n    \\bigr\\}.\n  \\end{gather}\n  For spaces $H\\Lambda^k_0(\\domain)$ defined below, $\\mathcal H_k$ is\n  defined in an analogous way.\n\\end{Definition}\n\n\\begin{Theorem*}{de-rham-1}{de Rham}\n  The dimension of the cohomology groups is equal to the Betti\n  numbers, which in turn depend only on the topology of the\n  domain. These depend on the number of ``holes of dimension\n  $k$''. For a Lipschitz domain, they are finite. For a simply\n  connected domain, they are all zero.\n\\end{Theorem*}\n\n\\begin{Theorem*}{de-rham}{de Rham for Hilbert complexes}\n  Assume the domain $\\domain$ is Lipschitz.  If $\\domain$ is simply\n  connected, the sequences in equations~\\eqref{eq:derham:9}\n  and~\\eqref{eq:derham:8} are exact, that is, there holds\n  \\begin{gather}\n    \\label{eq:derham:7}\n    \\ker {d_{k+1}} = \\range{d_k}.\n  \\end{gather}\n  If it is not simply connected, the codimension of $\\range{d_k}$ in\n  $\\ker{d_{k+1}}$ is finite and only determined by the topology of\n  $\\domain$. In particular, $\\range{d_k}$ is closed in\n  $H\\Lambda^{k+1}(\\domain)$.\n\\end{Theorem*}\n\n\\begin{Corollary}{de-rham-1}\n  Let\n  \\begin{gather}\n    V_0 = \\bigl\\{ \\omega\\in H\\Lambda^k(\\domain)\n    \\; \\big| \\;\n    \\form(\\omega, d\\eta)_{L^2\\Lambda^k(\\domain)} = 0\n    \\quad\\forall\\eta\\in H\\Lambda^{k-1}(\\domain)\\bigr\\}.\n  \\end{gather}\n  The problem: find $\\omega\\in V_0$ such that\n  \\begin{gather}\n    \\form(d \\omega, d\\mu) = \\form(f,\\mu)\n    \\qquad\\forall \\mu\\in V_0,\n  \\end{gather}\n  has a unique solution on a simply connected domain.\n\\end{Corollary}\n\n\\begin{Example}{de-rham-1}\n  Consider the case $H\\Lambda^0(\\domain) = H^1(\\domain)$. Then, $V_0$\n  is the space of functions orthogonal to constants, and we seek a\n  solution $p\\in  V_0$ such that\n  \\begin{gather}\n    \\form(\\nabla p, \\nabla q) = (f,q) \\qquad\\forall q\\in V_0.\n  \\end{gather}\n\\end{Example}\n\n\\begin{Corollary}{de-rham-2}\n  Let\n  \\begin{gather}\n    V_0 = \\left\\{ \\omega\\in H\\Lambda^k(\\domain)\n        \\; \\middle| \\;\n        \\arraycolsep1pt\n        \\begin{array}{rcll}\n          \\form(\\omega, d\\eta)\n          &=&0\n          &\\;\\forall\\eta\\in H\\Lambda^{k-1}(\\domain)\\\\\n          \\form(\\omega,\\tau)\n          &=&0\n          &\\;\\forall \\tau\\in \\mathcal H_k(\\domain)\n        \\end{array}\n  \\right\\}.\n  \\end{gather}\n  The problem: find $\\omega\\in V_0$ such that\n  \\begin{gather}\n    \\form(d \\omega, d\\mu) = \\form(f,\\mu)\n    \\qquad\\forall \\mu\\in V_0,\n  \\end{gather}\n  has a unique solution.\n\\end{Corollary}\n\n\nSo far, we have not considered boundary conditions. The next lemma,\nwhich is again stated without proof, indicates that the properties of\nthe de Rham complex are inherited, if the appropriate boundary\nconditions are applied to each space, namely, function values in\n$H^1$, tangential traces in $\\Hcurl$, and normal traces in\n$\\Hdiv$. The last restriction from $L^2$ to $L^2_0$ is not a boundary\ncondition, but it is the compatibility condition implied by the Gauss\ntheorem on $\\Hdiv$.\n\n\\begin{Lemma}{hlambda-0}\n  The Hilbert cochain complex with boundary values\n  \\begin{gather}\\minCDarrowwidth20pt\n    {\\small\n    \\begin{CD}\n      0\n      @>{d}>> H\\Lambda^0_0(\\domain)\n      @>{d}>> H\\Lambda^1_0(\\domain)\n      @>{d}>> H\\Lambda^2_0(\\domain)\n      @>{d}>> H\\Lambda^3_0(\\domain)\n      @>>> 0\n      \\\\\n      @.\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      \\\\\n      0\n      @>>> H^1_0(\\domain)\n      @>{\\nabla}>> \\Hcurl_0(\\domain)\n      @>{\\curl}>> \\Hdiv_0(\\domain)\n      @>{\\div}>> L^2_0(\\domain)\n      @>>> 0,\n    \\end{CD}\n    }\n  \\end{gather}\n  has the same properties as stated for the Hilbert complex without\n  boundary conditions.\n\\end{Lemma}\n\n% \\begin{Example}{not-simply-connected}\n\n% \\end{Example}\n\n\\begin{remark}\n  The complex does not start with $\\R$ on the left, but with zero,\n  since the constant functions are not members of $H^1_0(\\domain)$.\n\n  On the other hand, we could have replaced the right end of the\n  complex by\n  \\begin{gather}\n    L^2(\\domain) \\xrightarrow{\\frac1{\\abs{\\domain}}\\int} \\R,\n  \\end{gather}\n  where the arrow is the mean value operator.\n\\end{remark}\n\n\\begin{Lemma}{de-rham-3}\n  The problem: find\n  \\begin{gather}\n    (\\omega,\\eta,\\theta)\n    \\in H\\Lambda^1_0(\\domain)\n    \\times H\\Lambda^{0}_0(\\domain)\n    \\times \\mathcal H_1(\\domain)\n  \\end{gather}\n   such that\n  \\begin{gather}\n    \\arraycolsep1pt\n    \\begin{array}{cccccclll}\n      \\form(d \\omega, d\\mu) &+& \\form(\\mu,d\\eta) &+& \\form(\\theta,\\mu)\n      &=& \\form(f,\\mu)\n      & \\qquad & \\forall \\mu\\in H\\Lambda^1_0(\\domain)\n      \\\\\n      \\form(\\omega,d\\zeta) && && &=&0\n      & \\qquad & \\forall \\zeta\\in H\\Lambda^{0}_0(\\domain)\n      \\\\\n      \\form(\\omega,\\tau) && && &=& 0\n      & \\qquad & \\forall \\tau\\in \\mathcal H_1(\\domain).\n    \\end{array}\n  \\end{gather}\n  is well-posed.\n\\end{Lemma}\n\n\\begin{Theorem}{div-curl-well-posed}\n  Let $\\domain$ be simply connected. Then, the Maxwell problem in\n  \\slideref{Definition}{Maxwell-mixed-0} is well posed.\n\\end{Theorem}\n\n\\begin{proof}\n  We have to show the inf-sup condition and the ellipticity of the\n  curl-curl bilinear form. Let us introduce\n  \\begin{gather}\n    a(u,v) = \\form(\\curl u, \\curl v),\n    \\qquad\n    b(v,q) = \\form(v,\\nabla q).\n  \\end{gather}\n  From the fact that the de Rham complex starts with zero, we obtain\n  that the kernel of the gradient is zero. Thus, for any $q\\in\n  H^1_0(\\domain)\\setminus\\{0\\}$, we have $v = \\nabla q \\neq 0$ and\n  $\\norm{v}_{\\Hcurl} = \\norm{v}_{L^2} \\le \\norm{q}_{H^1}$. Thus, the\n  inf-sup condition holds.\n\n  We show now that $a(.,.)$ is elliptic on $\\ker B$. From the\n  definition of $b(.,.)$, we deduce that\n  $\\ker B \\perp \\nabla H^1_0(\\domain) = \\ker A$. Thus, $A$ is an\n  isomorphism between $\\ker B$ and its dual, and consequently\n  elliptic.\n\\end{proof}\n\n\\begin{Problem}{darcy-derham}\n  Prove well-posedness for the Darcy problem using the de Rham complex\n  for proving \\slideref{Lemma}{darcy-reduced-wellposed} and\n  \\slideref{Lemma}{darcy-infsup}.\n\\begin{solution}\nFrom the last step\n \\begin{gather}\\minCDarrowwidth20pt\n    \\begin{CD}\n      \\Hdiv_0(\\domain)\n      @>{\\div}>> L^2_0(\\domain)\n      @>>> 0,\n    \\end{CD}\n  \\end{gather}\nwe deduce $L_0^2(\\Omega)=\\range{\\nabla\\cdot}$. In particular, this means\nthat for all $q\\in L_0^2(\\Omega)$ there exists $v\\in H_0^{\\text{div}}$ such that\n$\\nabla \\cdot v=q$ and $\\norm{v}_{H^{\\text{div}}}\\leq C \\norm{q}_0$.\nHence, it holds the estimate\n\\begin{align}\n\\inf_{q\\in Q}\\sup_{v\\in V}\\frac{(\\nabla \\cdot v, q)}{\\norm{q}_Q\\norm{v}_V}\n  \\geq \\inf_{q\\in Q} \\frac{\\norm{q}_0}{\\norm{v}_{H^{\\text{div}}}}\\geq C.\n\\end{align}\nwhere $q = \\nabla \\cdot v$. Ellipticity of the bilinear form is obvious\n\\begin{align}\n  \\norm{u}_{H^{\\text{div}}}=\\norm{u}_0 \\quad \\forall u\\in \\ker B.\n\\end{align}\n\\end{solution}\n\\end{Problem}\n\n\\section{Polynomial complexes for simplicial meshes}\n\n\\begin{intro}\n  We have already seen that adding $\\vx\\P_r$ to the space $\\P_r^\\sdim$, we\n  obtain a surjective divergence operator from the Raviart-Thomas\n  element to the pressure space $\\P_k$. In this section, we see that\n  there is a general principle behind this concept and it can be\n  extended to the curl and gradient operators.\n\\end{intro}\n\n\\begin{Notation}{pk-complex}\n  The polynomial complex $\\P_r\\Lambda^k$ consists of $k$-forms with\n  coefficients in the polynomial space $\\P_r$.\n  \n  The homogeneous polynomial spaces $\\breve\\P_k$ and their proxy\n  fields form the cochain complex\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\begin{CD}\n      0\n      @>{d}>> \\breve\\P_r\\Lambda^0\n      @>{d}>> \\breve\\P_{r-1}\\Lambda^1\n      @>{d}>> \\breve\\P_{r-2}\\Lambda^2\n      @>{d}>> \\breve\\P_{r-3}\\Lambda^3\n      @>{d}>> 0\n      \\\\\n      @.\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      @V{\\cong}VV\n      \\\\\n      0\n      @>{\\subset}>> \\breve\\P_r\n      @>{\\nabla}>> \\breve\\P_{r-1}^3\n      @>{\\curl}>> \\breve\\P_{r-2}^3\n      @>{\\div}>> \\breve\\P_{r-3}\n      @>>> 0,\n    \\end{CD}\n  \\end{gather}\n  and $d_{k+1}\\circ d_k = 0$.\n\n  Note the special cases $r=0$ and $r=3$, namely\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\begin{CD}\n      0\n      @>{\\subset}>> \\R\n      @>{\\cong}>> \\breve\\P_0\n      @>{\\nabla}>> 0\\\\\n      0\n      @>{\\subset}>> \\breve\\P_3\n      @>{\\nabla}>> \\breve\\P_{2}^3\n      @>{\\curl}>> \\breve\\P_{1}^3\n      @>{\\div}>> \\breve\\P_{0}\n      @>{\\cong}>> \\R\n      @>>> 0,\n    \\end{CD}\n  \\end{gather}\n\\end{Notation}\n\n\\begin{remark}\n  Since the polynomial space $\\P_r$ is the direct sum\n  \\begin{gather}\n    \\P_r = \\bigoplus_{s=0}^r \\breve\\P_s,\n  \\end{gather}\n  the homogeneous polynomial complex above can be extended to a\n  general polynomial complex in a straightforward way.\n\\end{remark}\n\n\\subsection{The Koszul complex}\n\n\\begin{Definition}{koszul-differential}\n  We define the \\define{Koszul differential} as a map\n  \\begin{gather}\n    \\kappa\\colon \\Lambda^k(\\R^\\sdim) \\to \\Lambda^{k-1}(\\R^\\sdim),\n  \\end{gather}\n  such that\n  \\begin{gather}\n    \\kappa\\omega(\\vx) (v_1,\\dots,v_{k-1})\n    = \\omega(\\vx) (\\vx,v_1,\\dots,v_{k-1}).\n  \\end{gather}\n  As with the exterior differentail, we write $\\kappa_k$ if we want to\n  specify the degree of $\\Lambda^k$.  Application to proxy fields yields\n  \\begin{gather}\n    \\label{eq:derham:13}\n    \\begin{aligned}\n      \\kappa\\omega_1 &\\leftrightarrow \\vx\\cdot\\vu,\\\\\n      \\kappa\\omega_2 &\\leftrightarrow -\\vx\\times\\vu,\\\\\n      \\kappa\\omega_3 &\\leftrightarrow \\vx p.\n    \\end{aligned}\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma}{koszul-differential}\n  There holds\n  \\begin{gather}\n    \\label{eq:derham:14}\n    \\kappa\\circ\\kappa = \\kappa_k\\circ\\kappa_{k+1} = 0.\n  \\end{gather}\n  Furthermore, we have the Leibniz rule for $\\omega\\in \\Lambda^k$ and\n  $\\eta\\in\\Lambda^\\ell$\n  \\begin{gather}\n    \\kappa(\\omega\\wedge\\eta) = \\kappa\\omega\\wedge\\eta\n    + (-1)^k \\omega\\wedge\\kappa\\eta.\n  \\end{gather}\n  If\n  $\\omega(\\vx) = a_\\sigma(\\vx)\n  \\dx_{\\sigma_1}\\wedge\\dots\\wedge\\dx_{\\sigma_k}$, then we have\n  \\begin{gather}\n    \\kappa\\omega(\\vx) = \\sum_{i=1}^k (-1)^{i+1} a_\\sigma(\\vx)x_{\\sigma_i}\n    \\dx_{\\sigma_1}\\wedge\\dots\\wedge\\widehat{\\dx_{\\sigma_i}}\n    \\wedge\\dots\\wedge\\dx_{\\sigma_k}.\n  \\end{gather}\n  Finally, the Koszul differential commutes with the pullback.\n\\end{Lemma}\n\n\\begin{Definition}{Koszul-complex}\n  The homogeneous \\define{Koszul complex} is a polynomial complex of\n  the form\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\label{eq:derham:12}\n    \\begin{CD}\n      0\n      @<<< \\breve \\P_r\\Lambda^0\n      @<{\\kappa_1}<< \\breve \\P_{r-1}\\Lambda^1\n      @<{\\kappa_2}<< \\breve \\P_{r-2}\\Lambda^2\n      @<{\\kappa_3}<< \\breve \\P_{r-3}\\Lambda^3\n      @<<< \\R\n    \\end{CD}.\n  \\end{gather}\n  For $r\\le 3$ we have\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\label{eq:derham:12a}\n    \\begin{CD}\n      0\n      @<<< \\breve \\P_3\\Lambda^{-r}\n      @<{\\kappa_1}<< \\breve \\P_{2}\\Lambda^{1-r}\n      @<{\\kappa_2}<< \\breve \\P_{1}\\Lambda^{2-r}\n      @<{\\kappa_3}<< \\breve \\P_{0}\\Lambda^{3-r}\n      @<<< \\R\n    \\end{CD},\n  \\end{gather}\n  where forms with negative index evaluate to zero.\n\\end{Definition}\n\nNote that the ``Koszul differential'' increases the polynomial order\nand lowers the order of the form, thus acts in the opposite way of the\nusual exterior derivative $d$.\n\n\\begin{Lemma}{kd-plus-dk}\n  For $\\omega\\in \\breve \\P_r\\Lambda^k$ there holds\n  \\begin{gather}\n    \\label{eq:derham:15}\n    \\bigl(d\\kappa+\\kappa d\\bigr)\\omega = (r+k) \\omega.\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  We prove this here\n  for each $k$ directly. The proof for forms is in the video and can be found in ~\\cite{ArnoldFalkWinther06acta}. For $k=0$, we have $\\kappa\\omega = 0$, thus\n  we have to show\n  \\begin{gather}\n    \\kappa d\\omega = r\\omega.\n  \\end{gather}\n  Due to linearity of $\\kappa$ and $d$, it suffices to prove the\n  result for $\\omega = p=x_1^ax_2^bx_3^c$. We note that $dp/d_{x_1} =\n  a/x_1 p$ and $d(x_1 p)/d_{x_1} = (a+1) p$ and analogue for the other\n  coordinates.\n  \\begin{gather}\n    \\kappa_1 d_0\\omega = x\\cdot \\nabla p = x\\cdot\n    \\begin{pmatrix}\n      a/x_1\\\\b/x_2\\\\c/x_3\n    \\end{pmatrix}p\n    = (a+b+c)p.\n  \\end{gather}\n  The second easy case is $k=3$ such that $d\\omega = 0$. Let again\n  $\\omega = p$ to obtain\n  \\begin{gather}\n    d_2\\kappa_3 \\omega = \\div(xp) = \\div\n    \\begin{pmatrix}\n      x_1 p \\\\x_2 p \\\\x_3 p\n    \\end{pmatrix}\n    = (a+1+b+1+c+1) p = (r+3) \\omega.\n  \\end{gather}\n  For the two vector valued cases, we note that it suffices to prove\n  the result for $\\omega = (p,0,0)^\\transpose$ and to note that the results for\n  nonzero second and third component follow suite. Thus, for $k=1$\n  \\begin{multline}\n    \\nabla (x\\cdot \\omega) - x\\times \\curl \\omega\n    = \\nabla(x_1 p) - x\\times\n    \\begin{pmatrix}\n      0\\\\c/x_3 \\\\ -b/x_2\n    \\end{pmatrix}p\n    \\\\\n    =\n    \\begin{pmatrix}\n      a+1 \\\\ bx_1/x_2\\\\ cx_1/x_3\n    \\end{pmatrix}p\n    +\n    \\begin{pmatrix}\n      b+c \\\\ -bx_1/x_2\\\\cx_1/x_3\n    \\end{pmatrix}p\n    =\n    \\begin{pmatrix}\n      a+b+c+1 \\\\0\\\\0\n    \\end{pmatrix}p\n    = (r+1)\\omega.\n  \\end{multline}\n  Finally, for $k=2$\n  \\begin{multline}\n    \\curl(-x\\times \\omega) + x \\div \\omega\n    = \\curl\n    \\begin{pmatrix}\n      0 \\\\ -x_3 \\\\ x_2\n    \\end{pmatrix}p\n    +\n    \\begin{pmatrix}\n      x_1 a/x_1\\\\x_2 a/x_1\\\\x_3 a/x_1\\\\\n    \\end{pmatrix}p\n    \\\\=\n    \\begin{pmatrix}\n      b+1+c+1\\\\-ax_2/x_1 \\\\ -a x_3/x_1\n    \\end{pmatrix}p\n    +\n    \\begin{pmatrix}\n      a\\\\ax_2/x_1\\\\ax_3/x_1\n    \\end{pmatrix}p\n    =\n    \\begin{pmatrix}\n      a+b+c+2\\\\0\\\\0\n    \\end{pmatrix}p\n    = (r+2)\\omega.\n  \\end{multline}\n\\end{proof}\n\n\\begin{Lemma}{d-kappa-injective}\n  The restriction of operator $d$ to $\\range \\kappa$ is injective and\n  vice versa, or equivalently for any polynomial form\n  $\\omega\\in \\breve \\P_r\\Lambda^k$ there holds\n  \\begin{gather}\n    \\label{eq:derham:16}\n    \\begin{aligned}\n      d\\kappa\\omega &= 0 &\\Longrightarrow&& \\kappa\\omega &= 0,\\\\\n      \\kappa d\\omega &= 0 &\\Longrightarrow&& d\\omega &= 0.\n    \\end{aligned}\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  If $r=k=0$, then $\\kappa\\omega = d\\omega = 0$, such that the lemma\n  holds trivially. For $r+k\\neq 0$, we apply $\\kappa$ to\n  equation~\\eqref{eq:derham:15} to obtain\n  \\begin{gather}\n    \\kappa\\omega = \\frac1{r+k}\n    \\bigl(\\kappa d\\kappa\\omega + \\kappa^2d\\omega\\bigr)\n    = \\frac1{r+k}\\kappa d\\kappa\\omega.\n  \\end{gather}\n  Thus, we have proven $d\\kappa\\omega=0$ implies $\\kappa\\omega=0$. The\n  second implication is proven by applying $d$ to~\\eqref{eq:derham:15}.\n\\end{proof}\n\n\\begin{Theorem}{polynomial-exact}\n  The polynomial de Rham complex and the Koszul complex are exact for\n  $r\\ge 1$. Furthermore, for $k,r\\ge 0$ and $k+r>0$, there holds\n  \\begin{gather}\n    \\label{eq:derham:17}\n    \\breve \\P_r\\Lambda^k = \\kappa \\breve\\P_{r-1}\\Lambda^{k+1}\n    \\oplus d\\breve\\P_{r+1}\\Lambda^{k-1}.\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  We already know $\\range{\\kappa_{k-1}} \\subset \\ker{\\kappa_k}$. Thus,\n  it remains to show the opposite inclusion. Let therefore $\\omega\\in\n  \\breve \\P_r\\Lambda^k$ such that $\\kappa\\omega=0$. Then,\n  \\begin{gather}\n    \\omega = \\frac1{r+k} (d\\kappa\\omega+\\kappa d\\omega)\n    = \\frac1{r+k} \\kappa d\\omega =: \\kappa\\eta\n  \\end{gather}\n  with $\\eta \\in \\breve\\P_{r-1}\\Lambda^{k+1}$. Thus,\n  $\\omega\\in \\range{\\kappa_{k-1}}$. Again, the proof for the de Rham\n  complex is obtained by replacing $\\kappa$ by $d$.\n\n  In order to see that $\\breve \\P_r\\Lambda^k$ is the sum of the two\n  spaces, we let for arbitrary $\\omega\\in \\breve \\P_r\\Lambda^k$\n  \\begin{gather}\n    \\eta = \\frac1{r+k} d\\omega \\in \\breve\\P_{r-1}\\Lambda^{k+1},\n    \\qquad\n    \\mu = \\frac1{r+k} \\kappa\\omega \\in \\breve\\P_{k+1}\\Lambda^{k-1}.\n  \\end{gather}\n  By equation~\\eqref{eq:derham:15}, we have\n  $\\omega = \\kappa\\eta + d\\mu$. It remains to show that the\n  intersection of the spaces is zero. Therefore, let $\\omega$ be\n  chosen from the intersection. Then, $\\omega = \\kappa\\eta = d \\mu$\n  and\n  \\begin{gather}\n    (r+k)\\omega = d\\kappa \\omega + \\kappa d \\omega\n    = d \\kappa^2 \\eta + \\kappa d^2 \\mu = 0.\n  \\end{gather}\n\\end{proof}\n\n\\begin{Corollary}{pk-complexes}\n  \\slideref{Theorem}{polynomial-exact} holds as well for the\n  polynomial complexes\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\begin{CD}\n      0\n      @>>> \\P_r\\Lambda^0\n      @>{d}>> \\P_{r-1}\\Lambda^1\n      @>{d}>> \\P_{r-2}\\Lambda^2\n      @>{d}>> \\P_{r-3}\\Lambda^3\n      @>>> 0\n    \\end{CD},\n  \\end{gather}\n  and\n  \\begin{gather}\\minCDarrowwidth15pt\n    \\begin{CD}\n      \\R\n      @<<< \\P_r\\Lambda^0\n      @<{\\kappa}<< \\P_{r-1}\\Lambda^1\n      @<{\\kappa}<< \\P_{r-2}\\Lambda^2\n      @<{\\kappa}<< \\P_{r-3}\\Lambda^3\n      @<<< 0\n    \\end{CD}.\n  \\end{gather}\n\\end{Corollary}\n\n\\begin{proof}\n  This is due to the fact that the polynomial spaces $\\P_r$ are the\n  direct sums of homogeneous polynomial space $\\breve\\P_s$.\n\\end{proof}\n\n\\begin{Definition}{pk-plus}\n  \\index{prpl@$\\P_r+\\Lambda^k$}\n  The polynomial space of $k$-forms $\\P_r^+\\Lambda^k$ is defined as\n  \\begin{gather}\n    \\P_r^+\\Lambda^k = \\P_r\\Lambda^k \\oplus \\kappa \\breve\\P_r\\Lambda^{k+1}.\n  \\end{gather}\n  \\index{prml@$\\P_r-\\Lambda^k$}\n  It is also referred to as $\\P_{r+1}^-\\Lambda^k$. Furthermore,\n  \\begin{gather}\n    \\P_r^+\\Lambda^0 = \\P_{r+1}\\Lambda^0,\n    \\qquad\n    \\P_r^+\\Lambda^\\sdim = \\P_r\\Lambda^\\sdim.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{remark}\n  We have used the construction principle\n  \\begin{gather}\n    \\P_r\\Lambda^k = \\P_{r-1}\\Lambda^k \\oplus \\breve \\P_r\\Lambda^k.\n  \\end{gather}\n  Using its decomposition, we obtain\n  \\begin{gather}\n    \\P_r\\Lambda^k =\n    \\bigoplus_{s=1}^{r-1}\\kappa \\breve\\P_{s-1}\\Lambda^{k+1}\n    \\bigoplus_{s=1}^{r-1} d\\breve\\P_{s+1}\\Lambda^{k-1}\n    \\oplus \\kappa \\breve\\P_{r-1}\\Lambda^{k+1}\n    \\oplus d\\breve\\P_{r+1}\\Lambda^{k-1}.\n  \\end{gather}\n  If we leave out the last factor, we get the new space\n  $\\P_{r-1}^+\\Lambda^k$.\n\\end{remark}\n\n\\begin{Lemma}{pk-plus-d}\n  If $\\omega\\in \\P_r^+\\Lambda^k$ and $d\\omega=0$, then\n  $\\omega\\in\\P_r\\Lambda^k$.\n\\end{Lemma}\n\n\\begin{proof}\n  Let $\\omega = \\omega_1 + \\kappa\\eta$ with $\\omega_1\\in\\P_r\\Lambda^k$\n  and $\\eta\\in \\breve\\P_r\\Lambda^{k+1}$. Then,\n  $d\\omega_1\\in\\P_{r-1}\\Lambda^{k+1}$ and\n  $d\\kappa\\eta\\in \\breve\\P_r\\Lambda^{k+1}$. Therefore,\n  $d\\omega_1 = d\\kappa\\eta = 0$. By\n  \\slideref{Lemma}{d-kappa-injective}, $\\kappa\\eta=0$, such that\n  $\\omega=\\omega_1$.\n\\end{proof}\n\n\\begin{Problem}{rt-bdm-forms}\n  \\begin{enumerate}\n  \\item   Identify the spaces $\\P_r \\Lambda^{\\sdim-1}$ and\n    $\\P_r^+ \\Lambda^{\\sdim-1}$ with finite element spaces for\n    $\\Hdiv$.\n  \\item Where have we stated a special case of\n    \\slideref{Lemma}{pk-plus-d} before?\n  \\item Suggest polynomial spaces for $\\Hcurl$ corresponding to\n    $\\P_r \\Lambda^{1}$ and $\\P_r^+ \\Lambda^{1}$\n  \\end{enumerate}\n\\end{Problem}\n\n% AFW 2006 Lemma 3.8\n\\begin{Lemma}{pr-pr-plus}\n  For $r\\ge 1$ and $0\\le k < n$ there holds\n  \\begin{gather}\n    d\\P_{r}^+\\Lambda^k \\subset d\\P_{r+1}\\Lambda^k\n    \\subset \\P_r\\Lambda^{k+1}\n    \\subset \\P_r^+\\Lambda^{k+1}.\n  \\end{gather}\n  The following four mappings $d$ have the same kernel:\n  \\begin{gather}\n    \\begin{aligned}\n      d\\colon \\P_{r+1}\\Lambda^k &\\to \\P_{r}\\Lambda^{k+1}\n      &\n      d\\colon \\P_r^+\\Lambda^k &\\to \\P_{r}\\Lambda^{k+1}\n      \\\\\n      d\\colon \\P_{r+1}\\Lambda^k &\\to \\P_{r}^+\\Lambda^{k+1}\n      &\n      d\\colon \\P_r^+\\Lambda^k &\\to \\P_{r}^+\\Lambda^{k+1}\n    \\end{aligned}\n  \\end{gather}\n  The following four mappings $d$ have the same range:\n  \\begin{gather}\n    \\begin{aligned}\n      d\\colon \\P_{r+1}\\Lambda^k &\\to \\P_{r}\\Lambda^{k+1}\n      &\n      d\\colon \\P_{r}^+\\Lambda^k &\\to \\P_{r}\\Lambda^{k+1}\n      \\\\\n      d\\colon \\P_{r+1}\\Lambda^k &\\to \\P_{r}^+\\Lambda^{k+1}\n      &\n      d\\colon \\P_{r}^+\\Lambda^k &\\to \\P_{r}^+\\Lambda^{k+1}\n    \\end{aligned}\n  \\end{gather}\n\\end{Lemma}\n\n\n\\begin{Corollary}{pr-sequences}\n  For polynomial forms in $\\R^3$, \n  all four sequences in this diagram are exact:\n  {\\small\n  \\begin{tikzcd}\n    \\R \\arrow[r,hook]\n    & \\P_{r+3}\\Lambda^0 \\arrow[r,\"\\diffd\"]\n    & \\P_{r+2}\\Lambda^1 \\arrow[rd,\"\\diffd\"]\\\\\n    \\R \\arrow[r,hook]\n    & \\P_{r+2}\\Lambda^0 \\arrow[r,\"\\diffd\"]\n    & \\P_{r+1}^+\\Lambda^1 \\arrow[r,\"\\diffd\"]\n    & \\P_{r+1}\\Lambda^2 \\arrow[rdd,\"\\diffd\"]\\\\\n    \\R \\arrow[r,hook]\n    & \\P_{r+2}\\Lambda^0 \\arrow[r,\"\\diffd\"]\n    & \\P_{r+1}\\Lambda^1 \\arrow[rd,\"\\diffd\"]\\\\\n    \\R \\arrow[r,hook]\n    & \\P_{r+1}\\Lambda^0 \\arrow[r,\"\\diffd\"]\n    & \\P_{r}^+\\Lambda^1 \\arrow[r,\"\\diffd\"]\n    & \\P_{r}^+\\Lambda^2 \\arrow[r,\"\\diffd\"]\n    & \\P_{r}\\Lambda^3 \\arrow[r,\"\\diffd\"]\n    & 0\n  \\end{tikzcd}\n  }\n\\end{Corollary}\n\n\\begin{proof}\n  The first statement follows from the inclusions of $\\P_r$ and\n  $\\P_r^+$. The horizontal equality of the second statement follows\n  from \\slideref{Lemma}{pk-plus-d}. The vertical identities from the\n  decomposition~\\eqref{eq:derham:17}. For the last set of identities,\n  we observe that by construction\n  \\begin{gather}\n    \\P_r\\Lambda^k = \\P_{r-1}^+\\Lambda^k \\oplus d \\P_{r+1}\\Lambda^{k-1}.\n  \\end{gather}\n  Thus, $d\\P_r\\Lambda^k = d\\P_{r-1}^+\\Lambda^k\\subset \\P_{r-1}\\Lambda^{k+1}$.\n\\end{proof}\n\n\\begin{Theorem}{dimension-pr-lambda}\n  Let $r\\ge 0$ and $1\\le k \\le \\sdim$. Then,\n  \\begin{gather}\n    \\begin{split}\n      \\dim \\kappa \\breve P_r\\Lambda^k(\\R^\\sdim)\n      & = \\dim d \\breve P_{r+1}\\Lambda^{k-1}(\\R^\\sdim)\n      \\\\\n      &= \\binom{\\sdim+r}{\\sdim-k}\\binom{r+k-1}{k-1}.\n    \\end{split}\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{proof}\n  First, we prove the equality of the two dimensions by applying $\\kappa$\n  to equation~\\eqref{eq:derham:17}, yielding\n  \\begin{gather}\n    \\kappa \\breve P_r\\Lambda^k(\\R^d)\n    = \\kappa \\ediff \\breve P_{r+1}\\Lambda^{k-1}(\\R^\\sdim).\n  \\end{gather}\n  By \\slideref{Lemma}{d-kappa-injective}, the two spaces are\n  isomorphic and the equality holds.\n\n  The dimension formula is proven first for $r=0$ and $k\\ge 1$. The\n  Koszul operator is injective on $\\P_0\\Lambda^K(\\R^\\sdim)$ since the\n  first factor in equation~\\eqref{eq:derham:17} vanishes. It is\n  also injective on $\\breve P_r\\Lambda^\\sdim(\\R^\\sdim)$ for $r\\ge 0$.\n\n  For all other combinations of $r$ and $k$ it is proven by induction\n  over $k$. For $k=\\sdim$,\n  \\begin{gather}\n    \\dim \\breve\\P_r\\Lambda^\\sdim(\\R^\\sdim) = \\dim\\breve\\P_r(\\R^\\sdim)\n    = \\binom{\\sdim+r-1}{\\sdim-1}.\n  \\end{gather}\n  For $k<\\sdim$, we assume the formula proven for $k+1$. We have\n% Move this to an earlier point or an appendix\n  \\begin{gather}\n    \\breve P_r\\Lambda^k(\\R^d) = \\binom{\\sdim+r-1}{\\sdim-1}\\binom{\\sdim}{k}.\n  \\end{gather}\n  Now, the dimension formula\n  \\begin{gather}\n    \\dim \\range \\phi = \\dim V - \\dim \\ker \\phi,\n  \\end{gather}\n  yields\n  \\begin{gather}\n    \\dim\\kappa\\breve \\P_r\\Lambda^k(\\R^\\sdim) =\n    \\dim\\breve \\P_r\\Lambda^k(\\R^\\sdim)\n    - \\dim\\kappa\\breve \\P_{r-1}\\Lambda^{k+1}(\\R^\\sdim),\n  \\end{gather}\n  where we have used the exactness of the Koszul complex.\n  Using the induction hypothesis yields by the binomial identity\n% Olkhovskiy\n  \\begin{align}\n    \\dim\\kappa\\breve \\P_r\\Lambda^k(\\R^\\sdim)\n    &= \\binom{\\sdim+r-1}{\\sdim-1}\\binom{\\sdim}{k} - \\binom{\\sdim+r-1}{\\sdim-k-1}\\binom{r+k-1}{k}\n    \\\\\n    &= \\frac{(\\sdim+r-1)!{\\color{green}\\sdim!}}{{\\color{green}(\\sdim-1)!}{\\color{purple}r!}k!{\\color{blue}(\\sdim-k)!}}\n      - \\frac{(\\sdim+r-1)!{\\color{red}(r+k-1)!}}{{\\color{blue}(\\sdim-k-1)!}\n      {\\color{red}(r+k)!}k!{\\color{purple}(r-1)!}}\n    \\\\\n    &=\n      \\frac{(\\sdim+r-1)!{\\color{green}\\sdim}{\\color{red}(r+k)}-{\\color{blue}(\\sdim-k)}(\\sdim+r-1)!{\\color{purple}r}}\n      {{\\color{purple}r!}k!{\\color{blue}(\\sdim-k)!}{\\color{red}(r+k)}}\n    \\\\\n    &= \\frac{(\\sdim+r-1)!\\bigl(\\sdim(r+k)-(\\sdim-k)r\\bigr)}{r!k!(\\sdim-k)!(r+k)}\n    \\\\\n    &= \\frac{(\\sdim+r)!}{r!(k-1)!(\\sdim-k)!(r+k)}\n    \\\\\n    &= \\binom{\\sdim+r}{\\sdim-k}\\binom{r+k-1}{k-1}.\n  \\end{align}\n\\end{proof}\n\n\\subsection{Degrees of freedom and bases for simplicial meshes}\n\n\\begin{intro}\n  After having studied the properties of the de Rham complex and the\n  Koszul complex of polynomial spaces, we continue like with standard\n  finite elements and define a basis of shape functions and sets of\n  degrees of freedom dual to this basis. Note that the following\n  definition subsumes the definitions of conforming finite elements\n  for $H^1$, $\\Hcurl$ and $\\Hdiv$ in a single statement.\n\\end{intro}\n\n\\begin{Definition}{mesh-pk}\n  Given a space of polynomial forms\n  $\\P_r\\Lambda^k=\\P_r\\Lambda^k(\\R^\\sdim)$, we define the space of finite\n  element polynomial forms on a mesh $\\mesh_h$ covering the domain\n  $\\domain\\subset\\R^\\sdim$ as\n  \\begin{gather}\n    \\P_r\\Lambda^k(\\mesh) = \\bigl\\{\n    \\omega \\in H\\Lambda^k \\big|\n    \\;\\forall \\cell\\in\\T\\colon \\omega_{|\\cell} \\in \\P_r\\Lambda^k\n    \\bigr\\}.\n  \\end{gather}\n  Furthermore, we define $\\Delta_m(\\T_h)$ as the set of all\n  $m$-dimensional subsimplices of the whole mesh, where shared\n  subsimplices of several cells are identified.\n\\end{Definition}\n\n\\begin{intro}\n  The degrees of freedom have to be designed such that they guarantee\n  the necessary continuity between cells. To this end, we have to\n  study the traces of polynomial forms on the boundaries (called\n  subsimplices below) of the simplex $\\cell$. Then, we can start\n  decomposing degrees of freedom and node values such that they can be\n  allocated to these subsimplices.\n\\end{intro}\n\n\\begin{Theorem}{hlambda-continuity}\n  Let $\\omega\\in L^2\\Lambda^k(\\domain)$ be polynomial on each mesh\n  cell $\\cell$ of a mesh $\\mesh_h$ covering $\\domain$. Then, the\n  following statements are equivalent:\n  \\begin{enumerate}\n  \\item $\\omega\\in H\\Lambda^k(\\domain)$\n  \\item $\\gamma_f\\omega$ is single-valued for all $f\\in\\Delta_{\\sdim-1}(\\T_h)$\n  \\item $\\gamma_f\\omega$ is single-valued for all $f\\in\\Delta_{m}(\\T_h)$ for\n    $k\\le m \\le n-1$.\n  \\end{enumerate}\n\\end{Theorem}\n\n\\begin{proof}\n  By the Stokes theorem, every smooth $k$-form on a mesh cell $\\cell$\n  has a well-defined trace $\\gamma_f\\omega$ on\n  $f\\in\\Delta_{n-1}(\\cell)$. Thus, $\\omega\\in H\\Lambda^k(\\domain)$ if\n  and only if these traces coincide from both cells sharing this face.\n\n  Once this is established, it is also clear that the two traces can\n  only be the same if their traces to the boundary of $f$ coincide as\n  well.\n\\end{proof}\n\n\\subsubsection{Geometric decomposition of $\\P_r(\\cell)$}\n\nFor the geometric decomposition of simplices and the consequences on barycentric coordinates, see \\cref{sec:barycentric}\n\n\\begin{remark}\n  When we introduced barycentric coordinates in order to define\n  standard shape functions on simplices, we generated a basis for\n  $\\P_r(\\R^\\sdim)$ by selecting polynomials of the $\\lambda_i$. Closer\n  inspection reveals that these polynomials were\n  homogeneous. Therefore, we defined an isomorphism\n  \\begin{gather}\n    \\breve \\P_k(\\R^{\\sdim+1}) \\cong \\P_k(\\R^\\sdim),\n  \\end{gather}\n  which reads: for every $p\\in \\P_k(\\R^\\sdim)$ there is\n  $q\\in\\breve\\P_k(\\R^{\\sdim+1})$ such that\n  \\begin{gather}\n    p(x_1,\\dots,x_\\sdim) = q(\\lambda_0,\\dots,\\lambda_\\sdim).\n  \\end{gather}\n% Argue why isomorphism: count?\n\\end{remark}\n\n\\begin{Definition}{pr-f}\n  For each $k$-dimensional subsimplex $f_\\sigma$ of $\\cell$ with\n  $\\sigma = \\sigma_0,\\dots,\\sigma_k$, the space\n  $\\P_r(f_\\sigma) \\cong \\breve\\P_r(\\R^{k+1})$ is defined as\n  \\begin{gather}\n    \\P_r(f_\\sigma) = \\bigl\\{\n    q(\\lambda_{\\sigma_0},\\dots,\\lambda_{\\sigma_k})\n    \\;\\big\\vert\\;\n    q\\in\\breve \\P_r(\\R^{k+1})\\bigr\\}.\n  \\end{gather}\n  \n  By $\\overset{\\circ}{\\P}_r(f_\\sigma)$ we denote the space of\n  polynomials in $\\P_r(f_\\sigma)$ which vanish on the boundary $\\d f_\\sigma$.\n\n  The \\putindex{bubble function} associated with $f_\\sigma$ is\n  \\begin{gather}\n    b_{f\\sigma} = \\lambda_{\\sigma_0}\\cdots\\lambda_{\\sigma_k}\n    \\in \\overset{\\circ}{\\P}_{k+1}(f_\\sigma).\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma}{p0-bubble}\n  Let $f$ be a $k$-simplex. Then,\n  \\begin{gather}\n    \\overset{\\circ}{\\P}_r(f) =\n    \\begin{cases}\n      b_f \\P_{r-k-1}(f) &\\text{if } r\\ge k+1\\\\\n      \\{0\\} &\\text{if } r \\le k.\n    \\end{cases}\n  \\end{gather}\n\\end{Lemma}\n\n\n\\begin{Definition}{pr-f-extension}\n  The \\define{extension operator} $E_{f_\\sigma\\to\\cell}$ is defined as\n  \\begin{gather}\n    \\begin{split}\n      E_{f_\\sigma\\to\\cell}\\colon \\P_r(f_\\sigma) &\\to \\P_r(\\R^\\sdim),\\\\\n      p(\\lambda_0,\\dots,\\lambda_\\sdim) &= q(\\lambda_{\\sigma_0},\\dots,\\lambda_{\\sigma_k}),\n    \\end{split}\n  \\end{gather}\n  where $q$ is chosen as in the definition of $\\P_r(f_\\sigma)$.\n\\end{Definition}\n\n\\begin{Lemma}{subsimplex-polynomials}\n  Every function in $\\P_r(f)$ vanishes on every subsimplex\n  $g\\in\\Delta(\\cell)$ which is disjoint from $f$.\n\n  The bubble function $b_f$ vanishes on every subsimplex in\n  $\\Delta(\\cell)$ not containing $f$.\n\\end{Lemma}\n\n\\begin{Problem}{subsimplex-polynomials}\n  Show: $\\P_r(f_\\sigma)$ is isomorphic to $\\P_r(\\R^k)$. Prove\n  \\slideref{Lemma}{subsimplex-polynomials}.\n\\begin{solution}\n  Since $\\P_r(f_\\sigma)$ is isomorphic to $\\breve\\P_r(\\R^{k+1})$ and\n  $\\P_r(f_\\sigma)$ is a vector space\n  all we have to do is to show that the dimensions are equal.\n  In fact, $\\dim \\P_r(\\R^k) = \\binom{r+k}{k}$\n  (show by distributiung separators) and\n  $\\dim \\breve\\P_r(\\R^k) = \\binom{r+k-1}{k-1}$.\n  Thus, $\\dim \\breve\\P_r(\\R^{k+1}) = \\binom{r+k}{k} = \\dim \\P_r(\\R^k)$\n  and the two spaces are isomorphic.\n\n  Let $g$ be a subsimplex that is disjoint from $f$.\n  \\begin{align}\n      f_\\sigma &= \\bigl\\{x\\in\\cell \\big\\vert\n      \\lambda_j=0 \\text{ for } j\\not\\in\\sigma\\bigr\\}.\n      \\\\\n      &= \\biggl\\{ x = \\sum_{i\\in\\sigma}\\lambda_i\\bigg\\vert\n    \\lambda_i \\ge 0,\\quad\\sum_{i\\in\\sigma}\\lambda_i = 1\\biggr\\}.\n  \\end{align}\n  Then $\\sigma_f$ and $\\sigma_g$ are disjoint and in particular\n  $\\lambda_i = 0$ for all $i\\in \\sigma_f$ in the decomposition\n  $g \\ni x = \\sum_i \\lambda_i(x)$. Thus, $p\\in \\P_r(f)$\n  is identified by $q(\\lambda_{\\sigma_0},\\dots,\\lambda_{\\sigma_k})$\n  which vanishes for all $x \\in g$.\n\n  Let $g$ be a subsimplex not containing $f$. Then, $\\sigma_f\\setminus \\sigma_g$ is non-empty.\n  In the decomposition $g\\ni x = \\sum_i\\lambda_i$ such that $\\lambda_i \\ge 0,\\quad\\sum_i\\lambda_i = 1$ at most\n  the $\\lambda_i$ ($i\\in\\sigma_f$) for $i\\in\\sigma_f\\cap\\sigma_g$ are non-zero. Due to to our assumption\n  $\\sigma_f\\cap\\sigma_g$ is a proper subset of $\\sigma_f$ and hence there exist for each $x \\in f\\cap g$\n  a $i \\in \\sigma_f$ such that $\\lambda_i=0$. This implies $b_{f_\\sigma}\\equiv 0$ on $g$.\n\\end{solution}\n\\end{Problem}\n\n\\begin{Example}{h1-moment-dofs}\n  \\begin{center}\n    \\includegraphics[width=.3\\textwidth]{fig/p1-p}\n    \\includegraphics[width=.3\\textwidth]{fig/p2-p}\n    \\includegraphics[width=.3\\textwidth]{fig/p3-p}\n  \\end{center}\n  Unisolvent interpolation conditions for $\\P_r(\\cell)$\n  \\begin{xalignat*}3\n    u(f) &= 0 &&& \\dim f &= 0\\\\\n    \\form(u,q)_f &= 0 & q&\\in \\P_{r-2}(f) & \\dim f &= 1 \\\\\n    \\form(u,q)_f &= 0 & q&\\in \\P_{r-3}(f) & \\dim f &= 2 \\\\\n    &\\vdots && \\vdots && \\vdots\n  \\end{xalignat*}\n\\end{Example}\n\nWe are now generalizing and formalizing this example in order to\nderive a geometric decomposition of $\\P_r(\\cell)$ and its dual.\n\n\\begin{Definition}{v-of-f}\n  For every $f\\in\\Delta(\\cell)$%\n  %with $\\sigma=\\{\\sigma_0,\\dots,\\sigma_k\\}$\n  , we define\n  $V(f) \\subset \\P_r(\\cell)$  for $\\dim f>0$ as\n  \\begin{gather}\n    V(f) = \\bigl\\{ p = E_{f\\to\\cell} b_f q\n    \\;\\big\\vert\\;\n    q \\in \\P_{r-\\dim f -1}(f) \\bigr\\},\n  \\end{gather}\n  and for $\\dim f=0$\n  \\begin{gather}\n    V(f) = \\bigl\\{ \\lambda_i^r\n    \\;\\big\\vert\\;\n    f = \\{x_i\\}\\bigr\\}.\n  \\end{gather}\n  For $r\\le \\dim f$ holds\n  \\begin{gather}\n    V(f) = \\{0\\}.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Definition}{w-of-f}\n  For every $f\\in\\Delta(\\cell)$, we define\n  $W(f) \\subset \\P_r(\\cell)^*$ for $\\dim f>0$ as\n  \\begin{gather}\n    W(f) = \\bigl\\{\\phi(p) = \\form(p,q)_f\\big\\vert\n    \\;q\\in\\P_{r-\\dim f-1}(f) \\bigr\\},\n  \\end{gather}\n  and for $\\dim f=0$\n  \\begin{gather}\n    W(f) = \\bigl\\{\\phi(p)= p(x_i) \\big|\n    \\;f=\\{x_i\\}\n    \\bigr\\}.\n  \\end{gather}\n  For $r \\le \\dim f$ there holds\n  \\begin{gather}\n    W(f) = \\{0\\}.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma}{pr-geometric}\n  There holds\n  \\begin{gather}\n    \\P_r(\\cell) = \\bigoplus_{f\\in\\Delta(\\cell)}V(f),\n    \\qquad\n    \\P_r(\\cell)^* = \\bigoplus_{f\\in\\Delta(\\cell)}W(f).\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  We begin to show that\n  \\begin{gather}\n    \\P_r(\\cell) = \\bigoplus_{f\\in\\Delta(\\cell)}V(f).\n  \\end{gather}\n  First, we note that for any $f\\in\\Delta(\\cell)$ every function in $V(f)$\n  is also in $\\P_r(\\cell)$.  For $\\dim f=0$, that is, $f=\\{x_i\\}$ for some\n  vertex $x_i$, the only homogeneous polynomial of order $r$ is $\\lambda_i^r$.\n\n  For $\\dim f > 0$ we have by the first statement of\n  \\slideref{Lemma}{subsimplex-polynomials}, that the spaces $V(f)$\n  where $f$ is a vertex are disjoint. By the second statement of the\n  same lemma, the spaces $V(f)$ for all $f$ with equal dimension are\n  disjoint. Therefore, the sum\n  \\begin{gather}\n    V_\\sdim(\\cell) = \\sum_{k=0}^{\\sdim-1} \\sum_{f\\in \\Delta_k(\\cell)} V(f),\n  \\end{gather}\n  is direct. But, $V(\\cell) \\cap V_\\sdim(\\cell) = \\{0\\}$, since all elements in\n  $V(\\cell)$ contain a bubble function factor. Therefore,\n  \\begin{gather}\n    \\bigoplus_{f\\in\\Delta(\\cell)}V(f) \\subset \\P_r(\\cell).\n  \\end{gather}\n  We conclude by showing that dimensions on both sides are equal.\n  On the right, we use\n  \\begin{gather}\n    \\dim \\P_r(\\R^\\sdim) = \\binom{r+\\sdim}{r} = \\frac{(r+\\sdim)!}{\\sdim!r!}\n  \\end{gather}\n  On the left, we have\n  \\begin{multline}\n    \\dim \\bigoplus_{f\\in\\Delta(\\cell)}V(f) =\n    \\sum_{k=0}^{\\sdim} \\binom{\\sdim+1}{k+1} \\binom{r+k}{k}\n    \\\\\n    = \\frac{(d+1)!}{r!}\n    \\sum_{k=0}^{\\sdim} \\frac{1}{(k+1)!(d-k)!} \\frac{(r+k)!}{k!}.\n  \\end{multline}\n\n% Finish this!\n\n  It remains to show the decomposition for $\\P_r(\\cell)^*$. To this\n  end, we first notice that for any $f\\in\\Delta(\\cell)$ there holds\n  $\\dim W(f) = \\dim V(f)$ by their definition. Furthermore, for\n  $p\\in V(f)$ there holds\n  \\begin{gather}\n    \\Bigl(\\phi(p) = 0 \\quad\\forall \\phi\\in W(f)\\Bigr)\n    \\quad\\Rightarrow\\quad\n    p=0.\n  \\end{gather}\n  Thus, for $p\\in \\P_r(\\cell)$ there holds\n  \\begin{gather}\n    \\Bigl(\\phi(p) = 0 \\quad\\forall \\phi\\in \\sum W(f)\\Bigr)\n    \\quad\\Rightarrow\\quad\n    p=0.\n  \\end{gather}\n  Consequently,\n  \\begin{gather}\n    \\P_r(\\cell)^* = \\sum W(f).\n  \\end{gather}\n  since we have already proven that\n  \\begin{gather}\n    \\dim \\P_r(\\cell)^* = \\sum \\dim W(f),\n  \\end{gather}\n  the sum on the right must be direct.\n\\end{proof}\n\n\\subsubsection{Results for $\\P_r\\Lambda^k$ and proxy fields}\n\n\\begin{Lemma}{pr-lambda-dimension-decomposition}\n  There holds\n  \\begin{align}\n    \\dim \\P_r\\Lambda^k(\\cell)\n    &= \\sum_{f\\in\\Delta(\\cell)}\n      \\dim \\P_{r+k-\\dim f-1}^+\\Lambda^{\\dim f-k}(f) \\\\\n    \\dim \\P_r^+\\Lambda^k(\\cell)\n    &= \\sum_{f\\in\\Delta(\\cell)}\n      \\dim \\P_{r+k-\\dim f}\\Lambda^{\\dim f-k}(f)\n  \\end{align}\n\\end{Lemma}\n\n% \\begin{Notation}{volume-form}\n%   The \\define{volume form} of a $k$-dimensional subsimplex\n%   $f\\in\\Delta(\\cell)$ is defined by the relation\n%   \\begin{gather}\n%     \\abs{f} = \\int_f \\vol_f.\n%   \\end{gather}\n%   Using the fact that $n! \\abs{T} = \\vol_T(t_1,\\dots,t_n)$ we see\n%   \\begin{gather}\n%     \\dlambda_{\\sigma_1}\\wedge\\dots\\wedge\\dlambda_{\\sigma_k}\n%     = \\pm \\frac1{k! \\abs{f}} \\vol_f.\n%   \\end{gather}\n% \\end{Notation}\n\n\\begin{Lemma}{afw06-4-7}\n  Let $\\omega \\in \\overset{\\circ}{\\P}_r \\Lambda^k(\\cell)$ and assume\n  \\begin{gather}\n    \\int_\\cell\\omega\\wedge\\eta = 0,\n    \\qquad\\forall \\eta\\in\\P_{r-n+k-1}^+\\Lambda^{n-k}(\\cell).\n  \\end{gather}\n  Then, $\\omega = 0$.\n\\end{Lemma}\n\n\\begin{proof}\n  The proof consists of Lemmas 4.5 to 4.7 in\n  \\cite{ArnoldFalkWinther06acta}. It skilfully exploits representations of\n  polynomial forms with zero traces by barycentric coordinates, but is\n  rather technical.\n\\end{proof}\n\n\\begin{Theorem}{pr-lambda-unisolvent}\n  Let $r\\ge 1$ and $0\\le k \\le n$. For $f\\in \\Delta(\\cell)$, define\n  subspaces of $W(f) \\subset \\P_r\\Lambda^k(\\cell)^*$ by\n  \\begin{gather}\n    W(f) = \\left\\{\n      \\nodal_{f,_\\eta}(\\omega) = \\int_f \\gamma_f \\omega\\wedge\\eta,\n      \\;\\middle\\vert\\;\n       \\eta \\in \\P_{r+k-\\dim f-1}^+\\Lambda^{\\dim f-k}(f)\n      \\right\\}.\n  \\end{gather}\n  Then, if $\\omega \\in \\P_r\\Lambda^k(\\cell)$ satisfies\n  \\begin{gather}\n    \\nodal_{f,\\eta}(\\omega) = 0\n    \\qquad \\forall f\\in \\Delta(\\cell)\n    \\quad\\forall \\nodal_{f,\\eta} \\in W(f),\n  \\end{gather}\n  then $\\omega = 0$. Thus, the space $\\P_r\\Lambda^k(\\cell)$ together\n  with the node functionals $\\nodal_{f,\\eta}$ forms a unisolvent\n  finite element.  Furthermore, $\\gamma_f\\omega$ for any subsimplex\n  $f\\in\\Delta(\\cell)$ is uniquely determined by the degrees of freedom\n  in $\\bigoplus_g W(g)$ where $g\\in\\Delta(f)$.\n\\end{Theorem}\n\n\\begin{proof}\n  First we note, that by\n  \\slideref{Lemma}{pr-lambda-dimension-decomposition} the dimensions\n  of the spaces $W(f)$ add up to the dimension of\n  $\\P_r\\Lambda^k(\\cell)$. Thus, if we can show the first statement, we\n  have shown that the sum of the spaces $W(f)$ is a direct sum, and\n  thus unisolvence is obtained by the usual argument.\n\n  Let now $f\\in\\Delta_k(\\cell)$. Then, $\\gamma\\omega$ vanishes on\n  $\\d f$ as a $k$-form on a simplex of dimension $k-1$. Thus, we have\n  $\\gamma_f\\omega\\in \\overset{\\circ}{\\P}_r\\Lambda^k(f)$. Since\n  furthermore by the assumption\n  \\begin{gather}\n    \\int_f \\gamma_f\\omega\\wedge \\eta = 0,\n    \\qquad \\forall \\eta \\in \\P_{r-1}^+\\Lambda^0(f),\n  \\end{gather}\n  \\slideref{Lemma}{afw06-4-7} yields $\\gamma_f\\omega = 0$, which holds\n  for all $f\\in\\Delta_k(\\cell)$.\n\n  Let now $f\\in \\Delta_{k+1}(\\cell)$. Then, by the result of the\n  previous argument,\n  $\\gamma_f\\omega\\in \\overset{\\circ}{\\P}_r\\Lambda^k(f)$, and by the\n  argument itself $\\gamma_f \\omega = 0$. In particular,\n  $\\gamma_f\\omega$ is uniquely determined at this point of the\n  construction process, which proves the last statement of the theorem.\n\n  We can now do induction by the dimension of $f$ until we reach\n  $\\Delta_n(\\cell) = \\{\\cell\\}$ to obtain the result.\n\\end{proof}\n\n\\begin{remark}\n  Note that the space $\\P_s^+\\Lambda^k$ vanishes if $s<0$ or\n  $k<0$. Therefore, the spaces $W(f)$ are nontrivial only if\n  \\begin{gather}\n    k \\le \\dim f \\le r+k-1.\n  \\end{gather}\n  Comparing this to \\slideref{Example}{h1-moment-dofs} for\n  $H^1 = H\\Lambda^0$, we see that one-dimensional subsimplices carry\n  degrees of freedom for $r\\ge 2$ and two-dimensional for $r\\ge 3$.\n\\end{remark}\n\n\\begin{Theorem}{decomp-pr}\n  Let $k,r\\ge 1$. Then, $\\P_r(\\cell)$ admits a geometric decomposition\n  \\begin{gather}\n    \\P_r\\Lambda^k(\\cell) = \\bigoplus_{f\\in\\Delta(\\cell)} V(f),\n  \\end{gather}\n  where\n  \\begin{gather}\n    V(f) \\cong W(f) \\cong\n    \\begin{cases}\n      0 & \\dim f < k\\\\\n      \\P_{r+k-\\dim f-1}^+ \\Lambda^{\\dim f-k}(f) &\\text{else}\\\\\n      0 & \\dim f \\le r+k.\n    \\end{cases}\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{Example}{bdm-complex-decomp}\n  \\begin{gather}\n    \\begin{array}{c|cc|cc}\n      \\dim f\n      & \\P_r\\Lambda^1 & N^{2e}_r\n      & \\P_r\\Lambda^2 & BDM_r \\\\\\hline\n      3 & \\P_{r-3}^+\\Lambda^2 & RT_{r-2} & \\P_{r-1}^+\\Lambda^1 & N^{1e}_{r-1} \\\\\n      2 & \\P_{r-2}^+\\Lambda^1 & RT_{r-1} & \\P_{r}^+\\Lambda^0 & \\P_r \\\\\n      1 & \\P_{r-1}^+\\Lambda^0 & \\P_r & --& --\n%      0 & \\R & \\R & -- & --\n    \\end{array}\n  \\end{gather}\n  The spaces $\\P_r\\Lambda^k$ and their proxy fields and the spaces\n  $W(f)$ of degrees of freedom.\n  \n  \\begin{itemize}\n  \\item [$N^{2e}$] ($\\Hcurl$) Nedelec 2nd family edge element\n  \\item [$BDM$] ($\\Hdiv$) Brezzi-Douglas-Marini (also Nedelec 2nd face in 3D)\n  \\item [$N^{1e}$] ($\\Hcurl$) Nedelec 1st family edge element\n  \\end{itemize}\n\\end{Example}\n\n\\subsubsection{Results for $\\P_r^+\\Lambda^k$ and proxy fields}\n\n\n\\begin{Theorem}{decomp-pr-plus}\n  Let $k,r\\ge 1$. Then, $\\P_r^+(\\cell)$ admits a geometric decomposition\n  \\begin{gather}\n    \\P_r^+\\Lambda^k(\\cell) = \\bigoplus_{f\\in\\Delta(\\cell)} V(f),\n    \\qquad\n    \\P_r^+\\Lambda^k(\\cell)^* = \\bigoplus_{f\\in\\Delta(\\cell)} W(f),\n  \\end{gather}\n  where\n  \\begin{align}\n    V(f) \\cong\n    \\begin{cases}\n      0 & \\dim f < k\\\\\n      \\P_{r+k-\\dim f} \\Lambda^{\\dim f-k}(f) &\\text{else}\\\\\n      0 & \\dim f > r+k.\n    \\end{cases}\n    \\\\\n    W(f) \\cong\n    \\begin{cases}\n      0 & \\dim f < k\\\\\n      \\P_{r+k-\\dim f} \\Lambda^{\\dim f-k}(f) &\\text{else}\\\\\n      0 & \\dim f > r+k.\n    \\end{cases}\n  \\end{align}\n\\end{Theorem}\n\n\\begin{Example}{rt-complex-decomp}\n  \\begin{gather}\n    \\begin{array}{c|cccccc}\n      \\dim f\n      & \\P_r^+\\Lambda^0 & \\P_{r+1}\n      & \\P_r^+\\Lambda^1 & N^{1e}_r\n      & \\P_r^+\\Lambda^2 & RT_r \\\\\\hline\n      3 & \\P_{r-3}\\Lambda^3 & \\P_{r-3} & \\P_{r-2}\\Lambda^2 & BDM_{r-2} & \\P_{r-1}\\Lambda^1 & N^{2e}_{r-1} \\\\\n      2 & \\P_{r-2}\\Lambda^2 & \\P_{r-2} & \\P_{r-1}\\Lambda^1 & BDM_{r-1} & \\P_{r}\\Lambda^0 & \\P_r\\\\\n      1 & \\P_{r-1}\\Lambda^1 & \\P_{r-1} & \\P_{r}\\Lambda^0   & \\P_r  & -- & -- \\\\\n      0 & \\R & \\R & -- & -- & --& --\n    \\end{array}\n  \\end{gather}\n  Geometric decomposition of $\\P_r^+\\Lambda^k$ and their spaces of degrees of freedom.\n  \\begin{itemize}\n  \\item [$N^{1e}$] ($\\Hcurl$) Nedelec 1st family edge element\n  \\item [$RT$] ($\\Hdiv$) Raviart-Thomas (also Nedelec 1st face in 3D)\n  \\item [$N^{2e}$] ($\\Hcurl$) Nedelec 2nd family edge element\n  \\end{itemize}\n\\end{Example}\n\n\\begin{Definition}{k-form-interpolation}\n  By choosing a basis for each of the spaces $W(f)$ with\n  $f\\in\\Delta(\\cell)$, we obtain a finite number of node functionals\n  $\\nodal_{f,i}$ which in turn induces bases $\\{\\omega_{f,i}\\}$ for $V(f)$ by\n  duality.\n  The \\define{canonical interpolation} operators\n  \\begin{gather}\n    \\Pi_k\\colon C\\Lambda^k(\\cell) \\to \\P_r\\Lambda^k(\\cell),\n    \\qquad\n    \\Pi_k^+\\colon C\\Lambda^k(\\cell) \\to \\P_r^+\\Lambda^k(\\cell),\n  \\end{gather}\n  are defined such that for all $\\omega\\in C\\Lambda^k(\\cell)$\n  \\begin{gather}\n    \\Pi_k \\omega, \\Pi_k^+\\omega = \\sum_{f\\in\\Delta(\\cell)}\n  \\sum_{i=1}^{\\dim W(f)} \\nodal_{f,i}(\\omega) \\omega_{f,i},\n\\end{gather}\nwhere the inner sum is determined by the spaces in \\slideref{Theorem}{pr-lambda-unisolvent} and \\slideref{Theorem}{decomp-pr-plus}, respectively.\n\\end{Definition}\n\n\\begin{Theorem}{canonical-commute}\n  The diagram\n  \\begin{center}\n    \\begin{tikzcd}\n      \\Lambda^k(\\cell)\n      \\arrow[r,\"\\diffd\"]\n      \\arrow[d,\"\\Pi\"]\n      & \\Lambda^{k+1}(\\cell)\n      \\arrow[d,\"\\Pi\"]\n      \\\\\n      \\P\\Lambda^k(\\cell) \\arrow[r,\"\\diffd\"]\n      &\\P\\Lambda^{k+1}(\\cell)\n    \\end{tikzcd}\n  \\end{center}\n  commutes for all combinations of the spaces\n  $\\P\\Lambda^k \\in \\{\\P_{r+1}\\Lambda^k,\\P_r^+\\Lambda^k\\}$ and\n  $\\P\\Lambda^{k+1}\\in \\{\\P_r\\Lambda^{k+1}, \\P_r^+\\Lambda^{k+1}\\}$.\n  Namely, the canonical interpolation operators commute with the\n  exterior derivative,\n  \\begin{gather}\n    \\Pi(d\\omega) = d(\\Pi\\omega).\n  \\end{gather}\n\\end{Theorem}\n\n\n\\section{The complex of tensor product polynomial forms}\n\n\\begin{todo}\n  Tensor products of algebraic forms first\n\\end{todo}\n\n\\begin{intro}\n  The other multilinear map we know is the tensor product, which we\n  used to define finite elements on squares and cubes. This section is\n  now concerned with the interplay of alternating and differential\n  forms and tensor products. In particular, we are looking into the\n  construction of $k$-forms on $\\R^\\sdim$ as tensor products of\n  one-dimensional forms.\n\n  We will avoid the functional analysis of tensor products of Hilbert\n  spaces and refer the readers\n  to~\\cite{ReedSimon80,Hackbusch14,Hackbusch19}.\n\n  We focus instead on the finite dimensional construction of\n  polynomial $k$-forms on $\\R^\\sdim$ by tensor products of\n  one-dimensional forms.\n\\end{intro}\n\n\\begin{Definition}{pr-complex-1d}\n  The one-dimensional de Rham complex on the interval $I = [0,1]$ and\n  its polynomial subcomplex are\n  \\begin{gather}\n    \\begin{CD}\n    \\R\n    @>{\\subset}>>\n    H^1(I) = H\\Lambda^0(I)\n    @>{\\tfrac{\\diffd}{\\dx}}>>\n    L^2(I) = H\\Lambda^1(I)\n    @>>> 0\n    \\\\\n    @.\n    @A{\\subset}AA\n    @A{\\subset}AA\n    \\\\\n    \\R\n    @>{\\subset}>>\n    \\P_{r+1} = \\P_{r+1}\\Lambda^0\n    @>{\\tfrac{\\diffd}{\\dx}}>>\n    \\P_r = \\P_r\\Lambda^1\n    @>>> 0\n    \\end{CD}\n  \\end{gather}\n  We also use the simplified notation $\\P\\Lambda^k$, indicating that\n  the polynomial degrees are chosen such that $r+k$ is constant.\n\\end{Definition}\n\n\\begin{remark}\n  The polynomials sequence is exact due to \\slideref{Theorem}{polynomial-exact}.\n\\end{remark}\n\n\\begin{Definition}{pr-1d-basis}\n  The node functionals for $\\P_{r+1}\\Lambda^0$ are\n  \\begin{gather}\n    \\begin{matrix}\n      \\nodal_{0,0}^0(p) = p(1) - p(0),\\\\\n      \\nodal_{0,1}^0(p) = p(1) + p(0),\n    \\end{matrix}\\qquad\n    \\nodal_{1.q}^0(p) = \\int_{I} p' q \\dx,\\quad\\forall q\\in\\nicefrac{\\P_{r}}{\\R}.\n  \\end{gather}\n  The degrees of freedom for $\\P_{r}\\Lambda^1$ are\n  \\begin{gather}\n    \\nodal_{1,q}^1(p) = \\int_{I} p q \\dx,\\quad\\forall q\\in\\P_{r}.\n  \\end{gather}\n  Bases for the shape function spaces are defined by duality.\n\\end{Definition}\n\n\\begin{remark}\n  The degrees of freedom for $\\P_{r+1}\\Lambda^0$ are chosen such that\n  the finite element function on a subdivision of $I$ is continuous,\n  thus in $H^1$. This is true, even if the function values at the end\n  points only appear in linear combinations.\n\n  For $\\P_{r}\\Lambda^1$, we do not require continuity\n  and thus only need interior degrees of freedom.\n\\end{remark}\n\n\\begin{Lemma}{commute-nodal}\n  Let finite element $k$-forms $\\P\\Lambda^k$ on the cell $\\cell\\subset\\R^\\sdim$ be\n  defined by node values $\\nodal_i^k$ for $i=1,\\dots,m_k$. Let the\n  basis for the shape function spaces $\\{\\phi^k_i\\}$ and\n  $\\{\\phi^{k+1}_i\\}$, respectively defined by duality.  Assume for $\\rho=\\dim\\range d$\n  \\begin{gather}\n    \\label{eq:commute-basis}\n      \\begin{aligned}\n          d\\phi^k_i &= \\phi^{k+1}_i & \\qquad i&=1,\\dots,\\rho,\\\\\n          d\\phi^k_i &= 0 & i&=\\rho+1,\\dots,\\dim\\P\\Lambda^{k}(\\cell).\n      \\end{aligned}\n  \\end{gather}\nMoreover, assume for any $\\omega\\in \\Lambda^k(\\cell)$\n  \\begin{gather}\n    \\label{eq:commute-nodal}\n      \\begin{aligned}\n      \\nodal^{k+1}_i(d \\omega) &= \\nodal^k_i(\\omega)& \\qquad i&=1,\\dots,\\rho,\\\\\n      \\nodal^{k+1}_i(d \\omega) &= 0 & i&=\\rho+1,\\dots,\\dim\\P\\Lambda^{k+1}.\n      \\end{aligned}\n  \\end{gather}\n  Then, the \\putindex{canonical interpolation} operators $\\Pi$ commute\n  with the exterior derivative, namely, there holds:\n  \\begin{gather}\n    d_k \\Pi_k \\omega = \\Pi_{k+1} d_k \\omega.\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  By linearity, we have\n  \\begin{gather}\n      d\\Pi_k \\omega = d\\left(\\sum_{i=1}^{\\dim\\P\\Lambda^k}\\nodal^k_i(\\omega) \\phi^k_i\\right)\n      = \\sum_{i=1}^{\\rho}\\nodal^k_i(\\omega) d \\phi^k_i\n      = \\sum_{i=1}^{\\rho}\\nodal^k_i(\\omega) \\phi^{k+1}_i.\n  \\end{gather}\n  On the other hand,\n  \\begin{gather}\n    \\Pi_{k+1} d \\omega = \\sum_{i=1}^{\\dim\\P\\Lambda^{k+1}}\\nodal^{k+1}_i(d \\omega) \\phi^{k+1}_i.\n     = \\sum_{i=1}^{\\rho}\\nodal^{k+1}_i(d \\omega) \\phi^{k+1}_i.\n  \\end{gather}\n  Employing~\\eqref{eq:commute-nodal} concludes the proof.\n\\end{proof}\n\n\n\\begin{Lemma}{pr-1d-commute}\n  Let\n  \\begin{gather}\n    \\begin{split}\n      \\Pi^0_{r+1}\\colon \\Lambda^0(I) &\\to \\P_{r+1}\\Lambda^0(I)\\\\\n      \\Pi^1_{r}\\colon \\Lambda^1(I) &\\to \\P_{r}\\Lambda^1(I).\n    \\end{split}\n  \\end{gather}\n Then, the diagram\n  \\begin{center}\n    \\begin{tikzcd}\n      \\Lambda^0(I)\n      \\arrow[r,\"\\diffd\"]\n      \\arrow[d,\"\\Pi\"]\n      & \\Lambda^{1}(I)\n      \\arrow[d,\"\\Pi\"]\n      \\\\\n      \\P\\Lambda^0(I) \\arrow[r,\"\\diffd\"]\n      &\\P\\Lambda^{1}(I)\n    \\end{tikzcd}\n  \\end{center}\n  commutes.\n\\end{Lemma}\n\n\\begin{proof}\n  We prove that the assumptions of \\slideref{Lemma}{commute-nodal} are\n  fulfilled. To this end, we have to choose a particular basis for the\n  node functional spaces. Let this be the \\putindex{Legendre\n    polynomials} of degrees zero to $r$ for $\\nodal_{1,q}^1$. For\n  $\\nodal_{1,q}^0$, we choose\n  \\begin{gather}\n    q_i = \\plegendre_i,\\qquad i=1,\\dots, r\n  \\end{gather}\n\n  We note that for Legendre polynomials on $[0,1]$ there holds\n  \\begin{gather}\n    2(2m+1) \\int_0^x \\plegendre_m(t)\\dt = \\plegendre_{m+1}(x) - \\plegendre_{m-1}(x).\n  \\end{gather}\n  The basis functions for $\\P_r\\Lambda^0$ are\n  \\begin{gather}\n    \\begin{split}\n      \\phi_{0,0}^0 &= x-\\tfrac12,\\\\\n      \\phi_{1,q_i} &= \\tfrac{1}{2(2i+1)}(\\plegendre_{i+1} - \\plegendre_{i-1}),\n      \\qquad i=1,\\dots,r,\\\\\n      \\phi_{0,1}^0 &= \\tfrac12.\n    \\end{split}\n  \\end{gather}\n  Clearly, the basis functions for $\\P_r\\Lambda^1$ are the Legendre polynomials themselves.\n  Then, we have for $i=1,\\dots,r$\n  \\begin{gather}\n    d \\phi_{1,q_i}^0(x) = \\frac{\\diffd}{\\diffd x} \\phi_{1,q_i}(x)\n    = \\plegendre_i(x)\n    = \\phi_{1,i}(x).\n  \\end{gather}\n  Furthermore, $d\\phi_{0,1}^0(x)=0$ and\n  $d\\phi_{0,0}^0(x)=1 = \\phi_{1,0}^1(x)$. It thus remains to verify\n  that the node functionals commute, which is obvious for\n  $\\nodal_{1,q_i}^0$ for $i=1,\\dots,r$. For the remaining one, this\n  is due to the fundamantal theorem of calculus.\n\\end{proof}\n\n\\begin{Definition}{k-form-tensor-product}\n  Let $\\omega\\in \\Lambda^k$ and $\\eta\\in\\Lambda^\\ell$, then their\n  tensor product $\\omega\\otimes\\eta\\in\\Lambda^{k+\\ell}$ is defined through\n  their basis representations\n  \\begin{gather}\n    \\omega = \\sum_{\\sigma\\in\\Sigma(k,n)} a_\\sigma \\dx_\\sigma,\n    \\qquad\n    \\eta = \\sum_{\\tau\\in\\Sigma(\\ell,n)} b_\\tau \\dx_\\tau,\n  \\end{gather}\n  as\n  \\begin{gather}\n    \\omega\\otimes\\eta = \\sum_{\\sigma\\in\\Sigma(k,n)}\\sum_{\\tau\\in\\Sigma(\\ell,n)}\n    (a_\\sigma\\otimes b_\\tau) \\dx_\\sigma \\wedge \\dx_\\tau.\n  \\end{gather}\n  The space of $n$-fold tensor product polynomial $k$-forms is\n  \\begin{gather}\n    \\Q_r^+\\Lambda^k \\equiv\n    \\left(\\P\\Lambda^{\\otimes n}\\right)^k\n    = \\bigoplus_{\\sigma_\\in\\Sigma(k,n)}\n    \\P_r^+\\Lambda^{\\chi_1} \\otimes \\dots \\otimes \\P_r^+\\Lambda^{\\chi_n},\n  \\end{gather}\n  where $\\chi= \\chi_\\sigma$ is the \\putindex{characteristic vector} of $\\sigma$.\n\\end{Definition}\n\nFrom the study of the one-dimensional complex, we know that\n$\\P_{r+1}\\Lambda^0$ and $\\P_r\\Lambda^1$ form an exact sequence. Thus,\nin more detail, we have\n  \\begin{align}\n    \\left(\\P\\Lambda^{\\otimes n}\\right)^k\n    &= \\bigoplus_{\\sigma_\\in\\Sigma(k,n)}\n      \\P_{r+1-\\chi_1}\\Lambda^{\\chi_1} \\otimes \\dots \\otimes \\P_{r+1-\\chi_n}\\Lambda^{\\chi_n}\n    &= \\bigoplus_{\\sigma_\\in\\Sigma(k,n)}\n      \\P_r^+ \\Lambda^{\\chi_1}\\otimes \\dots \\otimes \\P_r^+\\Lambda^{\\chi_n},\n  \\end{align}\n  where the second line hides the change of polynomial degree in the\n  `$+$' superscript. This is also the idea behind the notation\n  $\\Q_r^+\\Lambda^k$, which leads to the known continuous $\\Q_{r+1}$\n  element for 0-forms.\n  \n  Theoretically, $r$ could be different in each factor, as long as the\n  relation between $\\Lambda^0$ and $\\Lambda^1$ is maintained.\n\n  The tensor product of functions $p_i$ is\n  \\begin{gather}\n    p_1\\otimes \\dots\\otimes p_n(\\vx) = p_1(x_1) p_2(x_2)\\dots p_n(x_n).\n  \\end{gather}\n\n  \n\\begin{todo}\n  Use the form\n  \\begin{gather}\n    \\omega(v_1,\\dots,v_k), \\qquad \\eta(w_1,\\dots,w_\\ell)\\\\\n    \\omega\\otimes \\eta(v_1,\\dots,v_k,w_1,\\dots,w_\\ell).\n  \\end{gather}\n\\end{todo}\n\n\\begin{Lemma}{tensor-product-exterior-derivative}\n  The \\putindex{exterior derviative} of a tensor product $k$-form\n  $\\omega\\otimes\\eta$ with $\\omega\\in\\Lambda^i$,\n  $\\eta\\in\\Lambda^j$, and $i+j=k$ is the $(k+1)$-form obtained by the\n  \\putindex{Leibniz rule}\n  \\begin{gather}\n    d_k(\\omega\\otimes\\eta) = d_i\\omega \\otimes \\eta +  (-1)^i \\omega \\otimes d_j\\eta.\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{example}\n  Let $\\omega_1^0 = p_1 = p_1(x_1)$ and $\\omega_2 = p_2(x_2)$.\n  The two-dimensional tensor product $0$-form $q=p_1\\otimes p_2$ on $[0,1]^2$ is\n  \\begin{gather}\n    q(\\vx) = \\omega_1^0\\otimes \\omega_2^0(\\vx) = p_1(x_1)p_2(x_2).\n  \\end{gather}\n  Its exterior derivative is\n  \\begin{gather}\n    d q(\\vx) = d\\omega_1^0 \\otimes \\omega_2^0 - \\omega_1^0 \\otimes d\\omega_2^0\n    = p_1'(x_1) p_2(x_2) \\dx_1 + p_1(x_1) p_2'(x_2) \\dx_2.\n  \\end{gather}\n  Note that $d^2 = 0$ since $\\dx_i\\wedge \\dx_i=0$.\n  \n  Let $\\omega_1^1 = p_1(x_1)\\dx_1$ and $\\omega_2^1 = p_2(x_2)\\dx_2$. Then, the\n  possible tensor product 1-forms on $[0,1]^2$ are\n  \\begin{align}\n    \\omega_1^1 \\otimes \\omega_2^0 (\\vx) &= p_1(x_1)p_2(x_2) \\dx_1 \\\\\n    \\omega_1^0 \\otimes \\omega_2^1 (\\vx) &= p_1(x_1)p_2(x_2) \\dx_2,\n  \\end{align}\n  Since forms of index 1 are one polynomial degree lower, we see that\n  the tensor product function coefficient in front of $\\dx_i$ is one\n  degree lower in $x_i$ than in $x_j$ for $j\\neq i$.\n\n  Finally, we obtain the 2-form\n  \\begin{gather}\n    \\omega_1^1 \\otimes \\omega_2^1 (\\vx) = p_1(x_1)p_2(x_2) \\dx_1\\wedge\\dx_2.    \n  \\end{gather}\n\\end{example}\n\n\\begin{Definition}{tensor-product-complex}\n  Let there be two complexes $V^k = \\Lambda^k(\\R^n)$ and $W^\\ell = \\Lambda^\\ell(\\R^m)$,\n  \\begin{gather}\n    \\begin{matrix}\n      \\R&\\xrightarrow{\\subset}&V^0&\\xrightarrow{d}&\\cdots&\n      \\xrightarrow{d}&V^n&\\xrightarrow{}& 0\\\\\n      \\R&\\xrightarrow{\\subset}&W^0&\\xrightarrow{d}&\\cdots&\n      \\xrightarrow{d}&W^m&\\xrightarrow{}& 0\n    \\end{matrix}\n  \\end{gather}\n  Then, the tensor product of the two complexes is\n  \\begin{gather}\n    \\R\\xrightarrow{\\subset}(V\\otimes W)^0\n    %\\xrightarrow{d}(V\\otimes W)^1\n    \\xrightarrow{d}\\cdots\\xrightarrow{d}(V\\otimes W)^{m+n},\n  \\end{gather}\n  where\n  \\begin{gather}\n    (V\\otimes W)^k = \\bigoplus_{i+j=k} (V^i\\otimes W^j).\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Lemma}{tensor-product-exact}\n  If the two complexes $\\{V^k\\}$ and $\\{W^k\\}$ are exact, then their tensor product is.\n\\end{Lemma}\n\n\\begin{todo}\n  Make the representation of kernel and range part of the lemma?\n\\end{todo}\n\n\\begin{Corollary}{tensor-power-complex-exact}\n  The tensor product complex\n  \\begin{gather}\n    \\R\n    \\overset{\\subset}{\\longrightarrow}\n    \\left(\\P_r\\Lambda^{\\otimes n}\\right)^0\n    \\overset{d}{\\longrightarrow}    \n    \\left(\\P_r\\Lambda^{\\otimes n}\\right)^1\n    \\overset{d}{\\longrightarrow}\n    \\dots\n    \\overset{d}{\\longrightarrow}    \n    \\left(\\P_r\\Lambda^{\\otimes n}\\right)^n\n    \\longrightarrow 0\n  \\end{gather}\n  is exact.\n\\end{Corollary}\n\n\\begin{Lemma}{qr-complex}\n  The coefficient functions for $(\\P_r^{\\otimes 3})^k$ and thus the\n  polynomial proxy fields are from the spaces\n  \\begin{gather}\n    \\R\n    \\overset{\\subset}{\\longrightarrow} \\Q_{r+1}\n    \\overset{\\nabla}{\\longrightarrow}\n    \\begin{pmatrix}\n      \\Q_{r,r+1,r+1}\\\\\\Q_{r+1,r,r+1}\\\\\\Q_{r+1,r+1,r}\n    \\end{pmatrix}\n    \\overset{\\curl}{\\longrightarrow}\n    \\begin{pmatrix}\n      \\Q_{r+1,r,r}\\\\\\Q_{r,r+1,r}\\\\\\Q_{r,r,r+1}\n    \\end{pmatrix}\n    \\overset{\\div}{\\longrightarrow}\n    \\Q_r\n    \\longrightarrow 0,    \n  \\end{gather}\n\\end{Lemma}\n\n\n\\begin{Theorem}{tensor-product-node-values}\n  Let there be two polynomial tensor complexes $\\{V^k=\\P\\Lambda^k\\}$\n  and $\\{W^k=\\P\\Lambda^k\\}$ with node functionals $\\nodal_{V,i}^k$ and\n  $\\nodal_{W,j}^k$, respectively. Let the node functionals be\n  unisolvent for the spaces $V^{k_1}$ and $W^{k_2}$,\n  respectively. Then, a unisolvent set of node functionals on\n  $V^{k_1}\\otimes W^{k_2}$ is defined on the tensor product by\n  \\begin{gather}\n    \\nodal_{V,i}^{k_1}\\otimes\\nodal_{W,j}^{k_2}(\\omega\\otimes\\eta)\n    = \\nodal_{V,i}^{k_1}(\\omega)\\nodal_{W,j}^{k_2}(\\eta),\n    \\qquad \\omega\\in V^{k_1}, \\eta\\in W^{k_2}\n  \\end{gather}\n\\end{Theorem}\n\n\\begin{Definition}{cube-facets}\n  Let $\\cell$ be the hypercube $[0,1]^\\sdim$ in $\\R^\\sdim$. Then,\n  every combination $\\sigma\\in\\Sigma(j,\\sdim)$ together with a tuple\n  $\\{b_1,\\dots,b_{\\sdim-j}\\}$ defines a $j$-dimensional \\define{facet} of $\\cell$ denoted by\n  \\begin{gather}\n    f_{\\sigma,b_1,\\dots,b_{n-j}} =\n    \\left\\{\n      \\vx\\in\\R^\\sdim \\;\\middle\\vert\\;\n      \\arraycolsep1pt\n      \\begin{array}{rlcrl}\n        x_i &\\in [0,1] &\\text{ for }& i&\\in\\sigma\\\\\n        x_{\\overline\\sigma_i} &= b_i&\\text{ for }& i&\\not\\in\\sigma.\n      \\end{array}\n    \\right\\},\n  \\end{gather}\n  where $\\overline\\sigma\\in\\Sigma(n-j,n)$ is the complement of $\\sigma$.\n\n  The set of all facets of $\\cell$ is denoted by $\\Delta(\\cell)$, the\n  set of all facets of dimension $j$ is $\\Delta_j(\\cell)$.\n\\end{Definition}\n\n\\begin{Lemma}{cube-facets}\n  The number of $j$-dimensional facets of a $\\sdim$-dimensional hypercube is\n  \\begin{gather}\n    \\#\\Delta_j(\\cell) = 2^{\\sdim-j}\\binom{\\sdim}{j}.\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{Lemma}{facets-k-forms}\n  The space of tangential traces\n  $\\gamma_f \\left(\\P_r\\Lambda^{\\otimes n}\\right)^k$ on a facet of $\\cell$ of\n  dimension $j$ is isomorphic to\n  $\\left(\\P_r\\Lambda^{\\otimes {j}}\\right)^k$. In particular, it is zero if $j<k$.\n\\end{Lemma}\n\n\\begin{todo}\n  Connectupper index of node functionals and spaces\n\\end{todo}\n\\begin{Notation}{dual-pr-1d}\n  We denote by $W_r^i$ the dual space of $\\P_r\\Lambda^i(I)$ for\n  $i=0,1$, respectively. We obtain a basis by a transformation and\n  translating~\\slideref{Definition}{pr-1d-basis} into the language of\n  differential forms:\n  \\begin{xalignat}3\n    \\widetilde\\nodal_{0,b}^0(\\omega) &= \\int_b \\omega\n    & \\forall b&\\in\\{0,1\\},\n    & \\forall \\omega&\\in \\P_{r+1}\\Lambda^0,\n    \\\\\n    \\widetilde\\nodal_{1,q}^0(\\omega) &= \\int_I \\diffd\\omega \\wedge q\n    & \\forall q&\\in \\nicefrac{\\P_r\\Lambda^0}{\\R},\n    & \\forall \\omega&\\in \\P_{r+1}\\Lambda^0,\n    \\\\\n    \\widetilde\\nodal_{1,q}^1(\\omega) &= \\int_I \\omega \\wedge q\n    & \\forall q&\\in \\P_r\\Lambda^0,\n    & \\forall \\omega&\\in \\P_{r}\\Lambda^1,\n  \\end{xalignat}\n  The upper index of $\\widetilde\\nodal_{x,y}^i$ corresponds to the space $W_r^i$.\n  \n  Due to \\slideref{Theorem}{tensor-product-node-values},\n  we can write\n  \\begin{gather}\n    \\left(\\left(\\P\\Lambda^{\\otimes n}\\right)^k\\right)^*\n    = \\bigoplus_{\\sigma\\in\\Sigma(k,n)} W_r^{\\chi_1}\\otimes\\dots\\otimes W_r^{\\chi_n}.\n  \\end{gather}\n\\end{Notation}\n\n\\begin{Definition}{facet-nodal}\n  Let $f_{\\sigma,b_1,\\dots,b_{n-j}}$ be a $j$-dimensional facet of the\n  hypercube $T = [0,1]^\\sdim$. Using \\slideref{Notation}{dual-pr-1d},\n  we define the space\n  \\begin{gather}\n    W^k(f_{\\sigma,b_1,\\dots,b_{n-j}}) = \\bigoplus_{\\tau\\in\\Sigma(k,n)} W_\\tau,\n  \\end{gather}\n  where\n  \\begin{gather}\n    W_\\tau = W_{\\tau,1}\\otimes \\dots \\otimes W_{\\tau,n},\n    \\qquad W_{\\tau,i} =\n    \\begin{cases}\n      W_r^1 & \\text{if } i \\in \\sigma \\cap \\tau\\\\\n      W_r^0 & \\text{if } i \\in \\sigma \\cap \\overline\\tau\\\\\n      \\operatorname{span} \\nodal_{0,b_i}^0 & \\text{if } i \\in \\overline\\sigma \\cap \\overline\\tau\\\\\n      \\{0\\} & \\text{if } i \\in \\overline\\sigma \\cap \\tau\n    \\end{cases}\n  \\end{gather}\n  We call these the node values on the facet $f_{\\sigma,b_1,\\dots,b_{n-j}}$.\n\\end{Definition}\n\n\\begin{Theorem}{qr-unisolvence}\n  Let $f\\in\\Delta(\\cell)$. Let\n  $\\omega\\in \\left(\\P\\Lambda^{\\otimes n}(I)\\right)^k$. Then,\n  $\\gamma_f\\omega$ is uniquely determined by the node functionals\n  spanning $W^k(f)$. In particular, the finite element $k$-form with\n  its node functionals is unisolvent.\n\\end{Theorem}\n\n\\section{Commuting quasi-interpolation operators}\n\n\\begin{intro}\n  Quasi-interpolation operators for\n  $H\\Lambda^0(\\domain) = H^1(\\domain)$ are obtained by replacing point\n  values by volume (Clément, Schöberl) or line (Scott/Zhang)\n  averages. We have already seen, that in $\\Hdiv(\\domain)$, we also\n  must replace face integrals by volume averages. Here, we are faced\n  with the commutation property, such that the averages cannot be\n  defined for each facet separately. Instead, we turn the procedure\n  around and use interpolation on whole families of cells and the\n  average over these families.\n  \n  The original version of the quasi-interpolation operators presented\n  here is due to J.~Schöberl. The tensor product construction\n  presented here is from current work of myself and F.~Bonizzoni.\n\\end{intro}\n\n\n\\begin{Lemma}{perturbed-interpolation-1d}\n  Let $I_{a,b} = [a,b]$ Let the node functionals for\n  $\\P_r^+\\Lambda^i(I_{a,b})$ with $i=0,1$ be defined for\n  $\\omega^0\\in\\Lambda^0$ and $\\omega^1\\in\\Lambda^1$, respectively, by\n  \\begin{align}\n    \\nodal_{0,a,b}^0(\\omega^0) &= \\omega^0(b) - \\omega^0(a),\\\\\n    \\nodal_{i,a,b}^0(\\omega^0) &= \\int_a^b \\mu_i\\diffd\\omega^0 ,\n                                 \\quad i=1,\\dots,r,\n    \\\\\n    \\nodal_{r+1,a,b}^0(\\omega^0) &= \\omega^0(b) + \\omega^0(a),\\\\\n    \\nodal_{i,a,b}^1(\\omega^1) &= \\int_a^b \\mu_i\\omega^1 ,\\quad i=0,\\dots,r,\n  \\end{align}\n  where $\\mu_i\\in \\P_i\\Lambda^0$ are from the sequence of orthogonal\n  polynomials on $I_{a,b}$. Then, there holds for $\\omega\\in\\Lambda^0$\n  \\begin{gather}\n    \\nodal_{i,a,b}^0(\\omega) = \\nodal_{i,a,b}^1(\\diffd\\omega), \\qquad i=0,\\dots,r.\n  \\end{gather}\n\\end{Lemma}\n\n\\begin{proof}\n  The proof is trivial for $i=1,\\dots,r$ and elementary for $i=0$.\n\\end{proof}\n\n\\begin{Definition*}{cutoff}{Cutoff functions}\n  A $C^k$-\\define{cutoff function} $\\eta_{x,\\rho}$ for the interval $B_\\rho(x)$ of radius\n  $\\rho$ around $x$ is a function fulfilling the following conditions:\n  \\begin{gather}\n    \\eta_{x,\\rho} \\in C^k\\left(\\R^\\sdim\\right),\\qquad\n    \\operatorname{supp} \\eta_{x,\\rho}  \\subseteq \\overline{B_\\rho(x)},\\qquad\n    \\int \\eta_{x,\\rho} \\dx = 1.\n  \\end{gather}\n  An example for a $C^\\infty$-cutoff function is\n  \\begin{gather}\n    \\eta_{x,\\rho}(y) = \\frac1{\\rho\\int\\tilde\\eta} \\tilde\\eta\\left(\\tfrac{y-x}{\\rho}\\right),\n    \\qquad\n    \\tilde\\eta(t) =\n    \\begin{cases}\n      \\exp\\left(\\tfrac1{t^2-1}\\right) & t\\le 1\\\\\n      0 & t>1.\n    \\end{cases}\n  \\end{gather}\n\\end{Definition*}\n\n\\begin{Definition}{quasi-interpolation-1d}\n  Let $\\rho\\le \\nicefrac13$. Let $\\eta_{0,\\rho}$, and $\\eta_{1,\\rho}$ be cutoff\n  functions. Then, we define quasi-interpolation operators\n  \\begin{align}\n    I^k_\\rho\\colon \\Lambda^k(I_{-\\rho,1+\\rho}) &\\to \\P_r^+\\Lambda^k(I_{0,1}),\n                                     \\qquad k=0,1,\\\\\n    \\omega^k & \\mapsto \\sum_i \\overline{\\nodal_i^k}(\\omega^k) \\phi_i^k,\n  \\end{align}\n  using the node functionals\n  \\begin{gather}\n    \\overline{\\nodal_i^k}(\\omega^k)\n    = \\int_{-\\rho}^\\rho\\int_{-\\rho}^\\rho \\nodal_{i,a,b}^k(\\omega^k)\n    \\eta_{0,\\rho}(a)\\eta_{1,\\rho}(b) \\,\\diffd a\\,\\diffd b,\n  \\end{gather}\n  and the shape functions $\\phi_i^k$ according to \\slideref{Definition}{pr-1d-basis}.\n\\end{Definition}\n\n\\begin{Lemma}{quasi-interpolation-1d}\n  The quasi-interpolation operators $I_\\rho^k$ can be extended to\n  bounded operators on $L^2\\Lambda^k(I_{-\\rho,1+\\rho})$, and thus on\n  $H\\Lambda^k(I_{-\\rho,1+\\rho})$. Furthermore, they commute with the\n  exterior derivative.\n\\end{Lemma}\n\n\\begin{Definition}{quasi-interpolation-tensor}\n  The tensor product quasi-interpolation operator\n  $I^k_{\\rho,\\otimes n}$ is defined formally as\n  \\begin{gather}\n    I^k_{\\rho,\\otimes n}\\colon L^2\\left(\\Lambda^{\\otimes n}\\right)^k\n    \\to \\Q_r^+\\Lambda^k,\n    \\qquad\n    I^k_{\\rho,\\otimes n} = \\sum_{\\sigma\\in\\Sigma(k,n)}\n    I^{\\chi_1}_\\rho \\otimes \\dots \\otimes I^{\\chi_n}_\\rho.\n  \\end{gather}\n  Applied to a rank one tensor $\\omega_1\\otimes \\dots \\otimes \\omega_\\sdim$ with\n  $\\omega_i \\in L^2\\Lambda^{\\chi_i}$, there holds\n  \\begin{gather}\n    I^k_{\\rho,\\otimes n}(\\omega_1\\otimes \\dots \\otimes \\omega_\\sdim)\n    = I^{\\chi_1}_\\rho (\\omega_1)\\otimes \\cdots\\otimes I^{\\chi_n}_\\rho(\\omega_n).\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Theorem}{quasi-interpolation-tensor}\n  Let node functionals for $\\Q_r^+\\Lambda^k(\\cell)$, where\n  $\\cell = [0,1]^\\sdim$ be defined as tensor products of the node\n  functionals in \\slideref{Definition}{quasi-interpolation-1d}. Then,\n  the resulting quasi-interpolation operators $I_{\\rho,\\otimes n}^k$ commute with\n  the exterior derivative. Furthermore, they are bounded operators on\n  $L^2\\Lambda^k(\\overline\\cell$), where $\\overline \\cell = [-\\rho,1+\\rho]^\\sdim$.\n\\end{Theorem}\n\n\\begin{Definition}{tensor-form-shape-functions}\n  Let $\\mesh_h$ be a finite element mesh on $\\domain$ consisting of\n  mesh cells $\\cell$ which are obtained from a reference cell\n  $\\refcell = [0,1]^\\sdim$ by the mapping $\\Phi_\\cell$. We define the\n  \\define{shape function space} $V_\\cell^k$ on each cell $\\cell$ by\n  pullback from the reference cell such that\n  \\begin{gather}\n    V_\\cell^k = \\bigl\\{ \\omega^k\\in \\Lambda^k(\\cell) \\;\\big\\vert\\;\n    \\Phi^* \\omega^k \\in \\Q_r^+\\Lambda^k(\\refcell) \\bigr\\}.\n  \\end{gather}\n  The \\define{finite element space} on the mesh $\\mesh_h$ is\n  \\begin{gather}\n    V_h^k = \\bigl\\{\\omega_h^k \\in H\\Lambda^k(\\domain)\\;\\big\\vert\\;\n    \\omega_h^k \\in V_\\cell^k \\bigr\\}.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Definition}{form-quasi-interpolation-mesh}\n  A quasi-interpolation operator $I_{h,\\rho}^k$ on the mesh $\\mesh$ is defined by\n  choosing the averaged node functionals consistently between mesh\n  cells with averaging length $\\rho = \\nicefrac13 h$.\n\\end{Definition}\n\n\\begin{Corollary}{form-quasi-interpolation-mesh}\n  The quasi-interpolation operators $I_{h,\\rho}^k$ are bounded operators\n  \\begin{gather}\n    I_{h,\\rho}^k \\colon H\\Lambda^k(\\domain) \\to V_h^k,\n  \\end{gather}\n  such that\n  \\begin{gather}\n    d_k \\circ I_{h,\\rho}^k = I_{h,\\rho}^{k+1} \\circ d_k.\n  \\end{gather}\n\\end{Corollary}\n\n\\begin{Lemma}{form-quasi-interpolation-convergence}\n  The restriction of $I_{h,\\rho}^k$ to $V_h^k$ is a continuous function\n  in $\\rho$, and its limit for $\\rho\\to0$ is the identity.\n\n  For sufficiently small $\\rho$ the operator $I_{h,\\rho|V_h^k}^k$ is\n  invertible.\n\\end{Lemma}\n\n\\begin{Definition}{schoeberl-interpolation}\n  The \\define{Schöberl interpolation} operator $S_h^k$ is defined for\n  sufficiently small $\\rho$ as\n  \\begin{gather}\n    S_h^k = \\left(I_{h,\\rho|V_h^k}^k\\right)^{-1} \\circ I_{h,\\rho}^k.\n  \\end{gather}\n  $S_h$ is a bounded operator on $H\\Lambda^k$ which commutes with the\n  exterior derivative and there holds\n  \\begin{gather}\n    \\left(S_h^k\\right)^2 = S_h^k.\n  \\end{gather}\n\\end{Definition}\n\n\\begin{Theorem}{fem-cochain}\n  The finite element cochain complex with spaces $V_h^k$ provides\n  inf-sup stable discretizations for mixed problems of the form: find\n  $\\omega^{k}\\in V_h^k$ for $k=0,\\dots,\\sdim$, such that\n  \\begin{gather}\n    \\arraycolsep1pt\n    \\begin{matrix}\n      \\form(\\diffd\\omega^k,\\diffd \\mu^k)\n      &+& \\form(\\diffd \\omega^{k-1},\\mu^k)\n      &=& \\form(f,\\mu^k)\\\\\n      \\form(\\diffd\\mu^{k-1},\\omega^k) &&&=&0\n    \\end{matrix}\n    \\qquad\\forall \\mu^k\\in V_h^k, \\quad k=0,\\dots,\\sdim.\n  \\end{gather}\n\\end{Theorem}\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End:\n", "meta": {"hexsha": "bafcb2f53c16b30245b7cd083036e3a0e25d422d", "size": 70558, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mixed/derham.tex", "max_stars_repo_name": "arimiftari/notes", "max_stars_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mixed/derham.tex", "max_issues_repo_name": "arimiftari/notes", "max_issues_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-05-24T07:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-31T12:58:14.000Z", "max_forks_repo_path": "mixed/derham.tex", "max_forks_repo_name": "arimiftari/notes", "max_forks_repo_head_hexsha": "737b95ed6a4163bd1d395c0379410513dcb03ef1", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-05-15T19:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-05T19:07:29.000Z", "avg_line_length": 33.9384319384, "max_line_length": 157, "alphanum_fraction": 0.6326284759, "num_tokens": 26178, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4033649147485943}}
{"text": "\\documentclass[a4paper]{article}\n\n\\usepackage[utf8]{inputenc} %- Løser problem med å skrive andre enn engelske bokstaver f.eks æ,ø,å.\n\\usepackage[T1]{fontenc} %- Støtter koding av forskjellige fonter.\n\\usepackage{textcomp} % Støtter bruk av forskjellige fonter som dollartegn, copyright, en kvart, en halv mm, se http://gcp.fcaglp.unlp.edu.ar/_media/integrantes:psantamaria:latex:textcomp.pdf\n\\usepackage{csquotes}\n\\usepackage{url} % Gjør internett- og e-mail adresser klikkbare i tex-dokumentet.\n\\usepackage{hyperref} % Gjør referansene i tex-dokumentet klikkbare, slik at du kommer til referansen i referanselista.\n\\usepackage[english]{babel} % Ordbok. Hvis man setter norsk i options til usepackage babel kan man bruke norske ord.\n\\usepackage{amsmath} \t\t\t\t% Ekstra matematikkfunksjoner.\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{amsthm}\n\\usepackage{mathrsfs}\n\\usepackage{mathtools}\n\\usepackage{geometry}\n\\usepackage{tikz-cd}\n\\usepackage{graphicx}\n\\usepackage{changepage}\n\\usepackage{subcaption}\n\\usepackage{placeins}\n\\usepackage{bm}\n\\usepackage{physics}\n\\usepackage{siunitx}\t\t\t\t\t% Må inkluderes for blant annet å få tilgang til kommandoen \\SI (korrekte måltall med enheter)\n\t\\sisetup{exponent-product = \\cdot}      \t% Prikk som multiplikasjonstegn (i steden for kryss).\n \t\\sisetup{output-decimal-marker  =  {,}} \t% Komma som desimalskilletegn (i steden for punktum).\n \t\\sisetup{separate-uncertainty = true}   \t% Pluss-minus-form på usikkerhet (i steden for parentes). \n\\usepackage{booktabs} % For å få tilgang til finere linjer (til bruk i tabeller og slikt).\n\\usepackage[font=small,labelfont=bf]{caption}\t\t% For justering av figurtekst og tabelltekst.\n\\usepackage[backend=biber]{biblatex}\n\\addbibresource{./ref.bib}\n\n% math stuff\n\\newcommand{\\restr}[2]{\\ensuremath{\\left.#1\\right|_{#2}}}\n\n% my personal commands\n\\newcommand{\\R}{\\mathbb{R}}\n\n%\\clearpage % Bruk denne kommandoen dersom du vil ha ny side etter det er satt plass til figuren.\n% Disse kommandoene kan gjøre det enklere for LaTeX å plassere figurer og tabeller der du ønsker.\n\\setcounter{totalnumber}{5}\n\\renewcommand{\\textfraction}{0.05}\n\\renewcommand{\\topfraction}{0.95}\n\\renewcommand{\\bottomfraction}{0.95}\n\\renewcommand{\\floatpagefraction}{0.35}\n\n% math stuff\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{claim}[theorem]{Claim}\n\\newtheorem{proposition}[theorem]{Proposition}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\newtheorem{corollary}[theorem]{Corollary}\n\\newtheorem{conjecture}[theorem]{Conjecture}\n\\newtheorem*{observation}{Observation}\n\\newtheorem*{example}{Example}\n\\newtheorem*{remark}{Remark}\n\n\\graphicspath{{../}}\n\n\\title{Project for Deep Learning in Scientific Computing}\n\n\\author{Alexander Johan Arntzen }\n\n\\date{\\today}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\n\\maketitle\n\n\\section*{Task 1}\nIn this task a noisy dataset was provided. Attempts to denoise the data did not produce a better cross validation error, so no denoising was used. All the data was then normalized by min-max normalization.\n\nA feed forward fully connected neural network was chosen to approximate the map. Training was then performed to select the optimal hyperparameters using cross validation error as a selection criterion. The final model was trained 10 times, and the lowest validation error was chosen. The resulting approximation is plotted in Figure \\ref{fig:task1}\n\n\\begin{figure}[b]\n\t\\begin{subfigure}[b]{0.5\\textwidth}\n\t  \\centering\n\t  \\includegraphics[width=\\linewidth]{figures/task1/final_tf0.pdf}\n\t  \\caption{$T_f^0$}\n\t  \\label{fig:task1a}\n\t\\end{subfigure}\n\t\\begin{subfigure}[b]{0.5\\textwidth}\n\t  \\centering\n\t  \\includegraphics[width=\\linewidth]{figures/task1/final_ts0.pdf}\n\t  \\caption{$T_s^0$}\n\t  \\label{fig:task1b}\n\t\\end{subfigure}\n\t\\caption{Training points and approximation made by the model}\n\t\\label{fig:task1}\n  \\end{figure}\n\n\\section*{Task 2}\nIn this task both the Sobol points and the transformed points were given. By using linear regression, the parameters of the transformation was found. It was then observed that the points used in the finest mesh solutions also existed in the coarser solutions. Thus, it was possible to use the more accurate $CF$ values where they where available. The $CF$ values where then standardized, since they approximated a normal distribution. \nTraining a feed forward fully connected neural network on the aggregated data gave better results than a multilevel\\cite{lye2020multilevel} approach. Ensemble training was then performed to select the optimal hyperparameters using cross validation error as a selection criterion. The final model was trained 10 times, and the lowest validation error was chosen. A plot of the predicted $CF$ values can be found in Figure \\ref{fig:task2}  \n\\begin{figure}[ht]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{figures/task2/final.pdf}\n    \\caption{Comparison between the predicted $CF$ values from the training set and the actual $CF$ values in the training set}\n    \\label{fig:task2}\n\\end{figure}\n\n\\section*{Task 3}\nIn this task the temperature data was fist normalized using min-max normalization. The temperature data was then structured so that consecutive temperature measurements are given for each starting time index. The training of the models was then done using the start of these sequences as input and the end as labels to approximate. A feed forward fully connected network was first used, but a network with an LSTM layer performed better on both series of temperatures. Ensemble training was then performed to select the optimal hyperparameters among input length, optimizer, learning rate, regularization and neurons. The final model was trained 5 times, and the lowest validation error was chosen. The predictions for each temperature series can be found in Figure \\ref{fig:task3}\n\\begin{figure}[t]\n  \\begin{subfigure}[b]{0.5\\textwidth}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/task3/final_tf0.pdf}\n    \\caption{$T_f^0$}\n    \\label{fig:task3a}\n  \\end{subfigure}\n  \\begin{subfigure}[b]{0.5\\textwidth}\n    \\centering\n    \\includegraphics[width=\\linewidth]{figures/task3/final_ts0.pdf}\n    \\caption{$T_s^0$}\n    \\label{fig:task3b}\n  \\end{subfigure}\n  \\caption{Training points and predictions by the model}\n  \\label{fig:task3}\n\\end{figure}\n\n\\section*{Task 4}\nIn this task the training data $S$ where first normalized to the domain $[0,1]^3$, using min-max scaling. Using the normalized data a feed forward neural network $T^L_{\\theta}(t, u)$ was then trained to approximate the map $T^L(t, u)$. The model depends on several hyperparameters including layers, neurons, activation function, optimization algorithm, learning rate, and regularization. The chosen parameters were chosen with ensemble training using cross validation error as a selection criterion.\n\nWith a model selected, the noisy data $(T_{f,j}^{L,*}, t_j)_{j=1}^{N}$ was used to define the loss function\n\\begin{equation}\n\tG(u) = \\sum_{j=0}^{N}{(T_{f,j}^{L,*} - T_{\\theta}(t_j,u))^2}.\n\\end{equation}\nThe optimization problem was then solved by a line seach algorithm. The resulting data are visualized in Figure \\ref{fig:task4}\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{figures/task4/final.pdf}\n    \\caption{The figure shows training values colored by $u$ and the predictions made by the chosen model. The noisy measurements are also depicted with a blue line noting the approximated curve $(T,t)$ for the given $u$}\n    \\label{fig:task4}\n\\end{figure}\n\n\\section*{Task 5}\nIn this task the control parameters $(v,D)$ in training set $S$ where first normalized to the domain $[0,1]^2$,  with maximum and minimum parameters given as $[2,20]\\times[50,400]$. Using the normalized data a feed forward neural network $CF_{\\theta}(D, v)$ was then trained to approximate the map $CF(D, v)$. The model depends on several hyperparameters including layers, neurons, activation function, optimization algorithm, learning rate, and regularization. The chosen parameters were chosen with ensemble training using cross validation error as a selection criterion.  The final model was trained 5 times, and the lowest validation error was chosen. \n\nOnce a suitable model was selected the loss function\n\\begin{equation}\n\tG(D,v) = (CF_{ref}- CF_{\\theta}(D,v))^2\n\\end{equation}\nwas minimized using SGD with projected gradient 1000 starting points as in the DNNopt\\cite{Lye_2021} procedure. The starting points where chosen as the elements in a Sobol sequence in $\\R^2$ . The optimization algorithm chosen was SGD with projected gradient. To speed up the optimization, loss was summed over all points, which enabled optimization of all the points simultaneously. The final model was trained 5 times, and the lowest validation error was chosen. The curve of optimal points can be viewed in Figure \\ref{fig:task5}\n\n\\begin{figure}[t]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{figures/task5/final_optim_points.pdf}\n    \\caption{Optimal curve of $(D^*,v^*)$ values. The initial Sobol points are also shown with the corresponding $G$ value}\n    \\label{fig:task5}\n\\end{figure}\n\n\\section*{Appendix}\nThe code for this project can be found at \\url{https://github.com/alexarntzen/deepthermal}\n\n\\FloatBarrier\n\\printbibliography\n\\end{document}\n\n\n", "meta": {"hexsha": "cbf43c8444ec4a3ad3a848e8e3039d384866c896", "size": 9273, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/main.tex", "max_stars_repo_name": "alexarntzen/deepthermal", "max_stars_repo_head_hexsha": "3b6627bc6f50009540dd76108a425418bb030343", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-15T14:23:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-15T14:23:17.000Z", "max_issues_repo_path": "report/main.tex", "max_issues_repo_name": "alexarntzen/deepthermal", "max_issues_repo_head_hexsha": "3b6627bc6f50009540dd76108a425418bb030343", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/main.tex", "max_forks_repo_name": "alexarntzen/deepthermal", "max_forks_repo_head_hexsha": "3b6627bc6f50009540dd76108a425418bb030343", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.5962732919, "max_line_length": 781, "alphanum_fraction": 0.7640461555, "num_tokens": 2517, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727231, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.40331352568828366}}
{"text": "%\\subsection{Search strategy for the resonance analysis: the BumpHunter algorithm}\n%\\label{sec:searchstrategy}\n\n%The main statistical test employed in the dijet resonance search is based\n%on the \\BumpHunter\\ algorithm~\\cite{Aaltonen:2008vt,Choudalakis:2011bh} and \n%is used to establish the presence or absence of a resonance in the dijet\n%mass spectrum, as described in greater detail in previous \n%publications~\\cite{EXOT-2010-07,EXOT-2011-07}. \n%The algorithm operates on the binned \\mjj data, comparing the background estimate with the data in mass intervals of \n%varying widths formed by combining neighboring bins. Starting with a two-bin signal window,\n%the algorithm scans across the entire distribution, \n%then steps through successively larger signal windows up to half of the whole fit range. \n%For each point in the scan, it computes the significance of the difference between the data and the background.\n%The most significant departure from the smooth spectrum\n%(``bump'') is defined by the set of bins that have the smallest probability\n%of arising from a Poisson background fluctuation.\n%During this procedure, the background model is not changed or refit to the data\n%outside of the excluded region.\n\n%The \\BumpHunter\\ algorithm accounts for the so-called ``look-elsewhere effect'' \n%~\\cite{lyons2008, Gross2010}, by performing a series of pseudo-experiments\n%drawn from the background estimate to determine the probability that random\n%fluctuations in the background-only hypothesis would create an excess \n%anywhere in the spectrum at least as significant as the one observed.\n%\n%To make practical use of this algorithm, one must ensure the background\n%estimate is not biased by the signal.\n%Therefore, \\BumpHunter\\ is run in two steps.  In the first, the full\n%distribution is fit and passed to \\BumpHunter.\n%If the most significant local excess from the background fit has a $p$-value\n%smaller than 0.01, this region is excluded and a new background fit is\n%performed. The exclusion is then progressively widened bin by bin until\n%the $p$-value of the remaining fitted region is acceptable.  \n%During the 2015 analysis it was found that simply excluding one additional bin on the low mass\n%side of the signal window removed most of the residual bias (if any\n%did exist).  Then the result of this fit is used for the second\n%stage where an unbiased estimate of the global significance of any\n%excess is obtained.\n\nOnce the background is derived, the BumpHunter algorithm ~\\cite{Aaltonen:2008vt,Choudalakis:2011bh} is employed to test the consistency or discrepancy between background and the observed data.\nIt can locate the local excess above the background and quantifies the degree of discrepancy between the observed data and background, based on the frequentist $p$-value from one of three test statistics: $\\chi^{2}$, Log Likelihood and BumpHunter(described below).\n\n%\\subsection{Frequentist $p$-value}\n%\n%In the comparison between observed data and background, if the background comes only from the SM, this is called the background-only hypothesis or null hypothesis, denoted by $H_{0}$. If the null hypothesis is correct, the observed data, denoted $D$, will be the statistical fluctuation of the background. The validity of $H_{0}$ can be tested by determining the probability of obtaining the data spectrum as a fluctuation of the background-only hypothesis.\n%\n%The frequentist probability is commonly used in high energy physics, which is a statement on the frequency of a certain outcome given a large number $N$ of repeated experiments. The frequentist hypothesis test determines the consistency between $H_{0}$ and the observed experimental outcome $x$ by fixing in advance a value of probability $\\alpha$ below which the hypothesis will be rejected as too discrepant. Specifically, if the observation falls in a space of possible outcomes $\\omega$ such that\n%\\begin{equation}\n%P(x \\in \\omega|H_{0}) \\leq \\alpha\n%\\end{equation}\n%then the null hypothesis $H_{0}$ will be rejected, otherwise the data is consider to be consistent with background.\n\n%Define a test statistic $t$ to be any numerical quantity which describes the compatibility\n%between data and background, it usually increases monotonically with decreasing compatibility. The $p$-value of this test statistic is the probability of obtaining a value at least as extreme as the observed $t = t_{0}$ given $H_{0}$:\n%\\begin{equation}\n%p = P(t>t_{0}|H_{0})\n%\\end{equation}\n%where small $p$-value means small consistency between data and background.\n\n\\subsection{Test statistic}\nThree test statistics are employed in the BumpHunter algorithm to quantify the discrepancy between observed data and background: $\\chi^{2}$, Log Likelihood and the BumpHunter. They are represented by a single value which characterises the degree of agreement between the observed data and background and are used in defining $p$-values.\n\n%The $\\chi^{2}$ test statistic is defined as the sum in quadrature of the differences\n%between observations and expectations, normalised to the variance. For a comparison\n%where the observation and prediction are both binned histograms with contents $d_{i}$ and $b_{i}$ in bin $i$:\n%\\begin{equation}\n%\\chi^{2} = \\sum_{i}\\frac{(d_{i}-b_{i})^{2}}{b_{i}}\\,.\n%\\end{equation}\n%The \"reduced $\\chi^{2}$\" value is defined as $\\chi^{2}/\\mathrm{NDF}$, which is often used to test goodness-of-fit, where NDF is the number of degrees of freedom in the fit.\n\n%The Likelihood, $\\mathcal{L}$, test statistic is an effective one in comparison of two binned histograms. In comparison of a mass spectrum, each bin content follows the Poisson distribution, so the Log Likelihood is defined as the product of the Poisson probability in each bin\n%over all bins:\n%\\begin{eqnarray}\n%\\mathcal{L} = \\prod_{i}\\frac{b_{i}^{d_{i}}e^{-b_{i}}}{d_{i}!}.\n%\\end{eqnarray}\n%The  Negative Log Likelihood (NLL), $-2\\ln\\mathcal{L}$ is defined as:\n%\\begin{equation}\n%-2\\ln\\mathcal{L} = -2\\ln\\prod_{i}\\frac{b_{i}^{d_{i}}e^{-b_{i}}}{d_{i}!}.\n%\\end{equation}\n\nBoth $\\chi^{2}$ and log likelihood can quantify the discrepancy between the observed data and background in individual bin.\nHowever, in the comparison of two binned spectra, the discrepancy in the window of neighbouring bins is more meaningful.\nSeveral adjacent bins with large excess in each bin indicate new physics, however three bins with a large excess, a large deficit and a large excess may produce the large $\\chi^{2}$ and NNL but would be of much less physical interest.\n\nThe third test statistic has therefore been defined to quantify the ``bump'' above the background, the ``BumpHunter statistic'', which is the default test statistic in the BumpHunter algorithm.\nFor a set of adjacent bins, a value $t$ is calculated as the Poisson probability of obtaining a result at least as significant as the one observed, define $d$ as the sum of the data and $b$ as the background in these neighbouring bins:\n\\begin{equation}\nt =  \n\\begin{cases}\\displaystyle\n\\sum_{n=0}^{d}\\frac{b^{n}}{n!}e^{-b} \\quad \\mathrm{for} \\quad d<b\\,, \\\\\\displaystyle\n\\sum_{n=d}^{\\infty}\\frac{b^{n}}{n!}e^{-b} \\quad \\mathrm{for} \\quad d \\geq b\\,.\n\\end{cases}\n\\end{equation}\nThe above expression can be represented in terms of gamma functions:\n\\begin{equation}\n t =\n\\begin{cases}\\displaystyle\n\\Gamma(d+1, b) = 1 - \\Gamma(d+1, b) \\quad \\mathrm{for} \\quad d<b\\,, \\\\\n\\Gamma(d, b) \\quad \\mathrm{for} \\quad d \\geq b\\,.\n\\end{cases}\n\\end{equation}\nThis value accounts for the direction of neighbouring fluctuations by looking at the\noverall excess or deficit in the region.\n\nFor every possible window along the mass spectrum, $t$ is calculated. The possible windows are found by looping over all widths between a minimum and a maximum number of bins. The BumpHunter statistic describing the overall spectrum is defined as the negative log of the smallest probability obtained for any window, defined as:\n\\begin{equation}\nt_{0} = -\\log t_\\mathrm{min}\\,.\n\\end{equation}\n\nOnce the test statistic is determined, the $p$-value can be calculated through generating many pseudo-data which can be derived by a randomly draw in each bin from a Poisson distribution with parameter equal to the expected bin content from the background spectrum.\nThe selected test statistic is then calculated for each pseudo-data.\nThe fraction of these cases for which the test statistic is more than that in observed data can be easily computed, $p$-value.\nThe full procedure to calculate the $p$-value obtained from a selected test statistic can be summarised as:\n\\begin{itemize}\n        \\item Calculate the value of the test statistic $t_{0}$ which compares background-only hypothesis to observed data, $t_{0}$,\n        \\item Generate a collection of pseudo-data from background to represent a range of possible experimental outcomes in the case the background-only hypothesis is correct,\n        \\item Compare each pseudo-data with background to calculate the test statistic value for each pseudo data, $t_{i}$,\n        \\item Calculate the fraction of $t_{i}$ for which $T > t_{0}$, this fraction is the $p$-value obtained from the test statistic $t$.\n\\end{itemize}\n\n\\subsection{The BumpHunter algorithm}\nThe BumpHunter algorithm compares the background with the observed data in intervals of varying widths formed by combining neighboring bins. \nIt scans across the entire distribution with the window width varying from 2 up to half of the number of the bins. \nFor each window in the scan, it computes the significance of the difference between the observed data and the background. \nThe most significant departure from the background spectrum is defined by the set of bins that has the smallest probability of arising from a Poisson background fluctuation. \nIf the measured $p$-value obtained from the BumpHunter statistic is less than 0.01, it may mean the existence of new physics. \n\nAs the pseudo-experiments are drawn from the background, the random fluctuations in the background-only hypothesis would create an excess anywhere in the spectrum at least as significant as the one observed, so the BumpHunter algorithm also accounts for the look-elsewhere effect~\\cite{lyons2008, Gross2010}.\n\nThe $p$-value got in BumpHunter is used to quantify the discrepancy between observed data and background. \nThe residual in each bin can also been quantified by a $p$-value and described in detail in \\cite{Choudalakis:2011bh}. \nIn each bin, a measured $p$-value is defined as the probability of measuring a discrepancy between data and background at least as large as the one observed. \nThe $p$-value is then translated into a $z$-value defined as the number of standard deviations to the right of the mean of the normal distribution:\n\\begin{equation}\np\\mathrm{-value} = \\int_{z\\mathrm{-value}}^{\\infty}\\frac{}{\\sqrt{2\\pi}}e^{-\\frac{x^{2}}{2}}dx\\,.\n\\end{equation}\nBins with a $z$-value less than zero show no difference of any interest, while those with a $z$-value of more than two or three indicate a significant discrepancy. \nFor clarity of interpretation, one would like the sign of the $z$-value drawn in residual plots to depend on whether the data falls above or below the hypothesis. \nTherefore, in the plots, any bins with a negative $z$-value are set to zero, while those with a positive $z$-value are drawn positive or negative depending on whether an excess or a deficit is observed.\n", "meta": {"hexsha": "f9959e7f35d30da75def2ad37c6e8a2a60419446", "size": 11368, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "include/oldMaterial/06-SearchStrategy.tex", "max_stars_repo_name": "krybacki/IntNote2", "max_stars_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/oldMaterial/06-SearchStrategy.tex", "max_issues_repo_name": "krybacki/IntNote2", "max_issues_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/oldMaterial/06-SearchStrategy.tex", "max_forks_repo_name": "krybacki/IntNote2", "max_forks_repo_head_hexsha": "45b1a7d88ca7b15f19ec25270b6fbbebd839fa0b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.2, "max_line_length": 501, "alphanum_fraction": 0.7745425757, "num_tokens": 2760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.40331351944882826}}
{"text": "\\documentclass[14pt,letterpaper]{report}\n\\usepackage[utf8]{inputenc}\n\\usepackage[left=1.00in, right=1.00in, top=0.50in, bottom=1.00in]{geometry}\n\n\\usepackage{enumitem}\n\n\\title{BucketVision “Angry Eyes” NetworkTables \\protect\\\\ Interface Control Document v1.0}\n\\makeatletter\n\n\\begin{document}\n\t\\begin{center}\n\t\t{\\LARGE \\@title}\n\t\t\n\t\t{\\textit \\@date}\n\t\\end{center}\n\n\t\\section*{Overview}\n\t\t\n\tThe “Angry Eyes” computer vision pipeline detects and determines the position of the dual-slanted retroreflective targets used in the 2019 FRC game. As this software runs on a separate system from the main robot controls, it publishes the position of detected targets through the NetworkTables interface so other systems may act on that data. This document described the format of that data.\n\t\t\n\t\\section*{Configurable Items}\n\t\n\tThe top-level table under which all items are published (1 level below root) is passed in as an argument to all of the new pipeline components. In the current test code, this is named BucketVision but a table with any name may be passed in here.\n\t\n\t\\noindent Each component of the new pipeline which publishes data in the NetworkTable accepts a parameter for the name, with which it will get or create a table by that name under the top-level table above. In the current test code, this is FrontCamera. While there is no logic to detect differing names, care should be taken to use the same camera name for all relevant components, otherwise data will be published under different tables.\n\t\n\t\n\t\\section*{Published Data}\n\t\n\tas noted above, these items are all published in a camera table which is in a top-level table\n\t\n\t\\begin{itemize}[label={--}]\n\t\t\\item \\textbf{NumTargets} - Number\n\t\t\n\t\tAn integer number representing the number of targets detected. All the following arrays will be this length, and each index will represent a single target.\n\t\t\n\t\t\\item \\textbf{distance} - Number Array\n\t\t\n\t\tThe estimated distance (in meters) between the camera and the target. Do not rely on its accuracy, it is calculated crudely.\n\t\t\n\t\t$$ \\textrm{Average Height}_{px} = \\frac{\\textrm{Height}_L + \\textrm{Height}_R}{2} $$\n\t\t\n\t\t$$ \\textrm{Height}_{deg} = \\frac{\\textrm{Average Height}_{px}}{\\textrm{Camera px per degree}} $$\n\t\t\n\t\t$$ dist = \\frac{\\textrm{Rectangle Height}}{\\textrm{tan}^{-1}(\\textrm{Height}_{deg})} $$\n\t\t\n\t\t\\item \\textbf{pos\\_x} - Number Array\n\t\t\n\t\tThe horizontal location of the target in normalized image-space coordinates, from 0 (left) to 1 (right).\n\t\t\n\t\t\\item \\textbf{pos\\_y} - Number Array\n\t\t\n\t\tThe vertical location of the target in normalized image-space coordinates, from 0 (top) to 1 (bottom).\n\t\t\n\t\t\\item \\textbf{size} - Number Array\n\t\t\n\t\tThe distance between the left and right portions of the target as a fraction of the width of the image.\t\n\t\t\n\t\t\\item \\textbf{parallax} - Number Array\n\t\t\n\t\tScaled left right difference as a fraction of total height: (negative if camera is right of target)\n\t\t\n\t\t$$ \\textbf{parallax} = (1000) \\frac{Height\\_left-Height\\_right}{Height\\_left+Height\\_right} $$\n\t\t \n\t\t\\item \\textbf{angle} - Number Array\n\t\t\n\t\tThe angle (in radians) between the left and right portions of the target.\n\t\t\n\t\\end{itemize}\n\n\\end{document}", "meta": {"hexsha": "022b5fce0856651ab81a70f7176e375be394a88d", "size": 3178, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2019 Pipeline/Angry_Eyes_Pipeline_ICD_V1.0.tex", "max_stars_repo_name": "cpostbitbuckets/BucketVision", "max_stars_repo_head_hexsha": "9184234df48f405a30e5b72296f695da154637d4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-01T00:14:57.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-01T00:14:57.000Z", "max_issues_repo_path": "2019 Pipeline/Angry_Eyes_Pipeline_ICD_V1.0.tex", "max_issues_repo_name": "cpostbitbuckets/BucketVision", "max_issues_repo_head_hexsha": "9184234df48f405a30e5b72296f695da154637d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-01-20T21:43:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-31T22:22:37.000Z", "max_forks_repo_path": "2019 Pipeline/Angry_Eyes_Pipeline_ICD_V1.0.tex", "max_forks_repo_name": "cpostbitbuckets/BucketVision", "max_forks_repo_head_hexsha": "9184234df48f405a30e5b72296f695da154637d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2019-01-12T01:52:55.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-07T19:17:55.000Z", "avg_line_length": 44.7605633803, "max_line_length": 440, "alphanum_fraction": 0.7400881057, "num_tokens": 847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505782, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.40331351944882815}}
{"text": "\n\n    \\filetitle{dat2ttrend}{Construct linear time trend from date range}{dates/dat2ttrend}\n\n\t\\paragraph{Syntax}\\label{syntax}\n\n\\begin{verbatim}\n[TTrend,BaseDate] = dat2ttrend(Range)\n[TTrend,BaseDate] = dat2ttrend(Range,BaseYear)\n[TTrend,BaseDate] = dat2ttrend(Range,Obj)\n\\end{verbatim}\n\n\\paragraph{Input arguments}\\label{input-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{Range} {[} numeric {]} - Date range from which an integer\n  linear time trend will be constructed.\n\\item\n  \\texttt{BaseYear} {[} model \\textbar{} VAR {]} - Base year that will\n  be used to construct the time trend.\n\\item\n  \\texttt{Obj} {[} model \\textbar{} VAR {]} - Model or VAR object whose\n  base year will be used to construct the time trend; if both\n  \\texttt{BaseYear} and \\texttt{Obj} are omitted, the base year from\n  \\texttt{irisget('baseYear')} will be used.\n\\end{itemize}\n\n\\paragraph{Output arguments}\\label{output-arguments}\n\n\\begin{itemize}\n\\item\n  \\texttt{TTrend} {[} numeric {]} - Integer linear time trend, unique to\n  the input date range \\texttt{Range} and the base year.\n\\item\n  \\texttt{BaseDate} {[} numeric {]} - Base date used to normalize the\n  input date range; see Description.\n\\end{itemize}\n\n\\paragraph{Description}\\label{description}\n\nFor regular date frequencies, the time trend is constructed the\nfollowing way. First, a base date is created first period in the base\nyear of a given frequency. For instance, for a quarterly input range,\n\\texttt{BaseDate = qq(baseYear,1)}, for a monthly input range,\n\\texttt{BaseDate == mm(baseYear,1)}, etc. Then, the output trend is an\ninteger vector normalized to the base date,\n\n\\begin{verbatim}\nTTrend = floor(Range - BaseDate);\n\\end{verbatim}\n\nFor indeterminate date frequencies, \\texttt{BaseDate = 0}, and the\noutput time trend is simply the input date range.\n\n\\paragraph{Example}\\label{example}\n\n\n", "meta": {"hexsha": "749137d5a3fb626471f1b818a157742656b03bcb", "size": 1839, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "-help/dates/dat2ttrend.tex", "max_stars_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_stars_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T13:38:38.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T13:38:38.000Z", "max_issues_repo_path": "-help/dates/dat2ttrend.tex", "max_issues_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_issues_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-03-28T08:13:20.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-02T10:40:25.000Z", "max_forks_repo_path": "-help/dates/dat2ttrend.tex", "max_forks_repo_name": "OGResearch/IRIS-Toolbox-For-Octave", "max_forks_repo_head_hexsha": "682ea1960229dc701e446137623b120688953cef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-17T07:06:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-17T07:06:39.000Z", "avg_line_length": 31.1694915254, "max_line_length": 89, "alphanum_fraction": 0.7389885808, "num_tokens": 523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4033135157143815}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{comment}\n\\usepackage{listings}\n\\usepackage{mathtools}\n\\usepackage{hyperref}\n\\usepackage{amsthm}\n\n\\theoremstyle{definition}\n\\newtheorem{definition}{Definition}[section]\n\n\\newtheorem{theorem}{Theorem}[section]\n\n\\DeclarePairedDelimiter \\abs{\\lvert}{\\rvert} % short cut for absolute value\n\n\\setlength{\\parindent}{0em}\n\\setlength{\\parskip}{0.5em}\n\n\\title{Chapter 2: Algorithm Analysis}\n\\author{Yangtao Ge}\n\\date{\\today}\n\n\\begin{document}\n\\maketitle\n\\begin{abstract}\nThis section discusses about:\n\\begin{itemize}\n    \\item how to estimate the time required for a program\n    \\item how to reduce running time of a program\n    \\item The result of careless use of recursion\n    \\item very efficient algorithms to raise a number to a power\n    \\item compute GCD\n\\end{itemize}\n\\end{abstract}\n\\section{Mathematical Background}\nFour definitions of the framework:\n\\begin{definition}[Upper bound]\n    $T(N) = O(f(N))$ if there are positive \\emph{constants} $c$ and $n_0$ such that $T(N) \\leq cf(N)$\n    when $N \\geq n_0$\n\\end{definition}\n\n\\begin{definition}[Lower bound]\n    $T(N) = \\Omega(g(N))$ if there are positive \\emph{constants} $c$ and $n_0$ such that $T(N) \\geq cg(N)$\n    when $N \\geq n_0$\n\\end{definition}\n\n\\begin{definition}[Envelope]\n    $T(N) = \\Theta(h(N))$ iff $T(N) - O(h(N))$ and $T(N) = \\Omega(h(N))$\n\\end{definition}\n\n\\begin{definition}\n    $T(N) = o(p(N))$ if for \\textbf{\\textit{all}} positive constants $c$ there exists an $n_0$ such that\n    $T(N) < cp(N)$ when $N > n_0$.\n\\end{definition}\n\\emph{Ref: p.30 for detail theorem}\n\nTypical growth rates:\\newline\n\\begin{tabular}{|p{3cm}|p{5cm}|}\n    \\hline\n    Function & Name\\\\\n    \\hline\n    \\hline\n    $c$ & Constant \\\\\n    $\\log_{}N$ & Logarithmic \\\\\n    $\\log^2_{}N$ & Log-Squared \\\\\n    $N$ & Linear \\\\\n    $N\\log_{}N$ & \\ \\\\ \n    $N^2$ & Quadratic \\\\\n    $N^3$ & Cubic \\\\\n    $2^N$ & Exponential \\\\ \n    \\hline\n\\end{tabular}\n\nSome Theorem from the definition:\n\\begin{theorem}\n    If $T_1(N) = O(f(N))$ and $T_2(N) = O(g(N))$, then:\n    \\begin{enumerate}\n        \\item $T_1(N) + T_2(N) = O(f(N) + g(N))$\n        \\item $T_1(N) * T_2(N) = O(f(N) * g(N))$\n    \\end{enumerate}\n\\end{theorem}\n\n\\begin{theorem}\n    If $T(N$) is a polynomial of degree $k$, then $T(N) = \\Theta(N^k)$\n\\end{theorem}\n\n\\begin{theorem}\n    $\\log^k_{}N = O(N)$ for any constant $k$, which tell us `Logarithms grow very slowly\n\\end{theorem}\n\nFor big-O notation answers: \\underline{Lower-order terms can generally be ignored}\ne.g. $f(N) = 2N^2 + N$ then its big-O notation is $T(N) = O(N^2)$\n\nFor \\emph{relative growth rates} of two Function, we using `\\emph{L'Hopitals's rule}' to determine it:\n\\begin{theorem}[L'Hopitals's rule]\n    If $\\lim_{N\\to\\infty}f(N) = \\infty$ and $\\lim_{N\\to\\infty}g(N) = \\infty$, \n    then $\\lim_{N\\to\\infty} \\frac{f(N)}{g(N)} = \\lim_{N\\to\\infty} \\frac{f'(N)}{g'(N)}$\n\\end{theorem} \n\nFour possible results:\n\\begin{itemize}\n    \\item Limit is 0: $f(N) = 0(g(N))$\n    \\item Limit is $c\\neq 0$: $f(N) = \\Theta(g(N))$\n    \\item Limit is $\\infty$: $g(N) = o(f(N))$\n    \\item Limit does not exist: No relations\n\\end{itemize}\n\n\\section{Model}\nBasically a normal computer which execute instructions sequentially. And it has inifinite memory\n\n\\section{What to Analyze}\nWhat we focus:\n\\begin{itemize}\n    \\item Input size\n    \\item Running time\n\\end{itemize}\n\nWhat we use:\n\\begin{itemize}\n    \\item $T_{avg}(N)$ : average running time -- reflect typical behaviour.\n    \\item $T_{worst}(N)$: worst running time -- a guarantee for performance on any possible input\n\\end{itemize}\n\\emph{Ref: pp. 33 - 35} (Maximum subsequence Sum Problem)\n\n\\section{Running Time Calculations}\nWe only focus on \\emph{big-O notation} answers.\n\n\\subsection{A simple Example}\nCalculations of $\\sum_{i=1}^N i^3$. The code is as follows:\n\\begin{lstlisting}[language=Java]\n    public static int sum(int n){\n        int partialSum = 0;           // Line 1\n        for(int i = 1; i <= n; i++){  // Line 2\n            partialSum += i * i * i;  // Line 3\n        }\n        return partialSum;            // Line 4\n    }\n\\end{lstlisting}\n\n\\underline{Analysis:}\n\\begin{itemize}\n    \\item Line 1: 1 time for assignment\n    \\item Line 2: 2N + 2 times in total:\n    \\begin{itemize}\n        \\item 1 time for initialization\n        \\item N + 1 times for comparison\n        \\item N times for increment\n    \\end{itemize}\n    \\item Line 3: 4N times in total(2 multiplication, 1 addition, 1 assignment)\n    \\item Line 4: 1 time for return\n\\end{itemize}\nIn total $6N + 4$, so we say that it is a $O(N)$ method \n\n\\subsection{General Rules}\n\\begin{enumerate}\n    \\item `For' loops: $T = T_{statements} * iterations$ (at most)\n    \\item `Nested' loops: $T = T_{statements} * \\prod_{}SizeOfLoop$ (Analysis them inside-out)\n    \\item Consecutive statements: Use `big-O' notation add \\newline \n    e.g. $O(N)$ followed by $O(N^2)$ is still $O(N^2)$\n    \\item `if-else': $T = \\max(T_{Stat1}, T_{Stat2})$ (sometimes overestimate, but never underestimate)\n\\end{enumerate}\n\n\\subsection{Solution for the Problem of Maximum subsequence Sum}\nFour algorithms are provided here (\\emph{Ref: pp.39 - 49})\n\n\\subsection{Logarithms in the Running Time}\nSome Logarithms algorithms:\n\\begin{itemize}\n    \\item \\emph{divide-and-conquer} algorithms: $O(N\\log_{}N)$ time \n    \\item General rules:\n    \\begin{itemize}\n        \\item $O(\\log_{}N)$: takes constant $O(1)$ time to cut the problem size by a fraction (usually $1/2$)\n        \\item $O(N)$: constant time requred to merely reduce the problem by a constant amount\n    \\end{itemize}\n\\end{itemize}\n\nFollowing subsection are some common Logarithmic algorithms:\n\n\\subsubsection{Binary Search}\n\n\\subsubsection{Euclid's Algorithm}\n\n\\subsubsection{Exponentiation}\n\n\\subsection{A Grain of Salt}\nSometimes, Worst case is better than average case:\n\\begin{itemize}\n    \\item average case is very complex\n    \\item Analysis needs to be tightened\n    \\item average running time is less significant than worst case running time\n\\end{itemize}\n\n\n\n\n\n\\end{document}", "meta": {"hexsha": "2479e4f89b1a80173b795a907a641dd5e42b5e7b", "size": 6048, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "AlgoInJava/Chapter2/Chapter2.tex", "max_stars_repo_name": "YangtaoGe518/CompReadingNotes", "max_stars_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "AlgoInJava/Chapter2/Chapter2.tex", "max_issues_repo_name": "YangtaoGe518/CompReadingNotes", "max_issues_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AlgoInJava/Chapter2/Chapter2.tex", "max_forks_repo_name": "YangtaoGe518/CompReadingNotes", "max_forks_repo_head_hexsha": "bdaef22d33e6355ace988c342de2198b4599e86c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7005076142, "max_line_length": 109, "alphanum_fraction": 0.6598875661, "num_tokens": 1955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.40331349453713883}}
{"text": "\\section{Introduction}\n\\label{sec:introduction}\n\nThe trading pit of a stock exchange is often imagined by outsiders as a frenzy place, with telephones constantly ringing and traders shouting orders across the room at a frenetic rhythm. This was probably the reality thirty years ago, when open outcry was still the main communication system between pit traders. Since then the floors have become more and more quiet as the majority of the orders moved to electronic trading systems. Notwithstanding, investment decisions were still made by humans who could now execute their orders without passing through the pit traders. In the last decade, the markets have witnessed the widespread adoption of \\emph{Automated Trading Systems} (ATS), that can make investment decisions in a fully automatized way at speeds with orders of magnitude greater than any human equivalent. In 2014, more than $75\\%$ of the stock shares traded on United States exchanges were originated from ATS orders and this amount kept growing since then. Quantitative hedge funds, such as Renaissance Technologies, D.E. Shaw, Citadel and many others, are employing mathematicians, physicists and other scientists to develop algorithms able to extract trading signals from large amount of data and automatically trade. These algorithms are typically based on advanced statistics, signal processing, machine learning and other fields of mathematics. However, few of these hedge funds publish their profit-generating ``secret sauce'' and not much can be found in the literature. In this project we develop an automated trading algorithm based on \\emph{Reinforcement Learning} (RL), a branch of \\emph{Machine Learning} (ML) which has recently been in the spotlight for being at the core of the system who beat the Go world champion in a 5-match series \\cite{silver2016mastering}.\\\\\nThis document is organized as follows. In Section \\ref{sec:basics_reinforcement_learning} we introduce the basic concepts of RL and present two learning algorithms that allow two determine an approximation for the optimal policy of a sequential decision problem. In section \\ref{sec:application_to_systematic_trading} we discuss the asset allocation problem from a mathematical point of view and show how these learning algorithms can be applied in this setting. In Section \\ref{sec:python_prototype} we start discussing the implementation of the model in Python, which has been used during the prototyping phase. In Section \\ref{sec:c++_implementation} we discuss a more efficient C++ implementation. In Section \\ref{sec:execution_pipeline} we describe the execution pipeline used to run the learning experiment. In Section \\ref{sec:numerical_results} we present the numerical results for a synthetic asset, whose price follows a particular stochastic process. In Section \\ref{sec:conclusion} we conclude with some final remarks and we discuss some future research directions. \n", "meta": {"hexsha": "cf340df300be193eddf30ec01b01ea2a086b8b30", "size": 2924, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Pacs/Report/Sections/1_introduction.tex", "max_stars_repo_name": "AmineAboussalah/Thesis", "max_stars_repo_head_hexsha": "1a3ae97023acff1ee5e2d197a446734117a6fb99", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2016-06-13T15:20:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T23:47:13.000Z", "max_issues_repo_path": "Pacs/Report/Sections/1_introduction.tex", "max_issues_repo_name": "pnecchi/Thesis", "max_issues_repo_head_hexsha": "1a3ae97023acff1ee5e2d197a446734117a6fb99", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Pacs/Report/Sections/1_introduction.tex", "max_forks_repo_name": "pnecchi/Thesis", "max_forks_repo_head_hexsha": "1a3ae97023acff1ee5e2d197a446734117a6fb99", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 34, "max_forks_repo_forks_event_min_datetime": "2017-05-15T07:51:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-21T21:48:53.000Z", "avg_line_length": 487.3333333333, "max_line_length": 1795, "alphanum_fraction": 0.8197674419, "num_tokens": 578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.40322804610922497}}
{"text": "\\documentclass{article}\n\\usepackage{fullpage}\n\\usepackage{nopageno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{enumerate}\n\\allowdisplaybreaks\n\n\\newcommand{\\abs}[1]{\\left\\lvert #1 \\right\\rvert}\n\n\\begin{document}\n\\title{Notes}\n\\date{March 26, 2014}\n\\maketitle\n\\section*{lesson 17}\nthis stuff is like the prototype solution setting up method of characteristic lines, we'll see more of this later.\n\nToday we look at Alembert's solution\n\\begin{align*}\n  &\\text{PDE}&&\\qquad u_{tt}=c^2u_{xx}&c&>0&\\infty<&x<+\\infty&0<&t<\\infty\\\\\n  &\\text{IC}&&\\left.\n  \\begin{aligned}\n    u(x,0)&=f(x)\\\\\n    u_t(x,0)&=g(x)\n  \\end{aligned}\n  \\right\\}&&&\\infty<&x<+\\infty\n\\end{align*}\nchange independent variables\n\\begin{align*}\n  \\xi&=x+ct\\\\\n  \\eta&=x-ct\n\\end{align*}\npoint will get $u_{\\xi\\eta}$\n\nSee page 130(146) for more explanation\n\\end{document}\n", "meta": {"hexsha": "403f43563bbb97840e13e5fcc69e355422758537", "size": 839, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "partial differential equations/pde-notes-2014-03-26.tex", "max_stars_repo_name": "ylixir/school", "max_stars_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "partial differential equations/pde-notes-2014-03-26.tex", "max_issues_repo_name": "ylixir/school", "max_issues_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "partial differential equations/pde-notes-2014-03-26.tex", "max_forks_repo_name": "ylixir/school", "max_forks_repo_head_hexsha": "66d433f2090b6396c8dd2a53a733c25dbe7bc90f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6756756757, "max_line_length": 114, "alphanum_fraction": 0.6936829559, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091671, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.40322804610922497}}
{"text": "\\chapter{Discussion}\n\\label{ch:7}\nIn this chapter, we seek to contextualize the results from the preceding chapter. \nWe apply theory from \\Cref{ch:2} and compare the result to the expected behavior \n% expect from what we know about their theoretical construction/base. \n\n\\section{Similarity Scores}\n\nWe have established that the measures define what makes trajectories similar. \nSome of the measures have a similar base idea, and thus we expect to see this reflected in the results. \nFrom the rankings of most similar pairs, there are a few things that stand out and we will go over them here.\n\n\n%We reiterate this is not the case for all of them, and consequently, not all columns of TABLE can be used in this manner. \n\nFirst of all, EDR with $\\epsilon$ set to 0.203 was the column in \\Cref{tab:top-10-sim-pairs} which had the least number of frequent “most similar pairs”. \nWhen adjusting the parameter down to 0.101, our approximation of the recommend parameter value, all of its eight most pairs were found elsewhere in the table.\nRecall that EDR’s parameter is the threshold distance that determines if points are “matching”. \nThe similarity ranking with the lower parameter value aligns more with the other measures, and this could indicate that the other threshold was set too high.\nWe would presume that EDR would give a similar ranking as the other noise-tolerant edit-distance inspired method, MSM.\nFrom what can be seen in the table, this appears to hold, but it varies with its parameter value too. \n\n%   that would have similar values to the\n\nNext, we note that the Hausdorff distance generated similar pairs which were quite different from the other measures. \nAs the Hausdorff metric is parameter-free, we reckon that the reason its results stood out was that it defined trajectory similarity in a different manner than the rest. \nWe established that the Hausdorff distance does not take into account the direction of a trajectory and the only other measure that is invariant to direction is SSPD. \nIndeed they share many of the top 10 ranked scores, however, SSPD distinguishes itself Hd as it reduces the similarity score to a single element-element pair making altering their internal rankings again. \n\n% Next we observe that the Hausdorff distance contains the second least “frequent pairs” and as it parameter free, we reason that there must be something with how it defines trajectory similarity that makes it stand out. Recall that the Hausdorff distance stood out as the only measure that did not take into account the direction of a trajectory. Furthermore, it stands out as the only measure that reduces the similarity distance to an element-element pair.\n\nThe final observation from \\Cref{tab:top-10-sim-pairs} we noted was that Euclidean distance, ERP, and one of the MSM measures gave the exact same top 10 pairs. \nUpon closer examination, it turned out that their ranking remained the same until the 44th pair, and the similitude between the measures continued beyond that.\nMSM with cost value 1 and the Euclidean distance's ranking match for 9456 of the 10 thousand most similar trajectory pairs. \nWe reason that this occurred as a consequence of the cost of Splits and Merges being set too high, making MSM  default to the Move operation whose cost is the $L_2$ norm between trajectory elements.\nAs for ERP, we reason that setting the reference point, $g$, to the origin, increased the cost for trajectory elements that were far away.\nAgain, making the method depend on the $L_2$ norm between trajectory elements as the cost of an edit.\n\n\n\\section{Davies-Bouldin Results}\n\nThe essence of this thesis is to examine how the definition of similarity varies with different measures.\nClustering is a manner of grouping the trajectories such that traits which are seen as the most defining characteristics under various definitions get highlighted. \n\nAs stated in \\Cref{ch:2}, there are a number of cluster evaluation techniques that aim to numerically rank the quality of clustering results.\nOne of these is the DB-index however we will not an assumption regarding which type of type similarity was the most “correct” one.\nThe ranking created by this criterion is not invalid, but the insight it adds to is limited.\nNevertheless, we have chosen to leave in this stage of the experiment and in the report on the account of the efforts that were put into computing it as well as its natural role as a starting point for analyzing the clusters. \n \nOur version of Davis-Bouldin favors clusterings where each trajectory element differs as little as possible from the mean of all trajectory elements when computed in a. A consequence of this is that the cluster can appear fuzzy since the placement of the surrounding points does not affect the index. \nFrom \\Cref{tab:cluster-dbidx} it appears as if the lock-step method and EDR with threshold parameter $\\epsilon=0.203$ were the best performing methods, and this is as expected. \n\nMoreover, methods that do not take into account order observations, or methods that would reorder the trajectory elements received low DB-index rankings. In \\Cref{fig:cluster-best-worst-db-ap,fig:cluster-best-worst-db-h}  the clusters that were generated by the measures which received highest and lowest DB-indexes are drawn. These figures illustrate the bias of our DB-index implementation. \n\n\n\\begin{figure}[h!]\n  \\centering\n  \\hspace{1em}\n   \\begin{subfigure}[c]{0.37\\linewidth}\n     \\includegraphics[width=\\linewidth]{figs/clusters/CLU_AP_ALL[EDR;e=.203].png}\n    \\caption{EDR;$\\epsilon=0.203$, highest rank}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[c]{0.37\\linewidth}\n    \\includegraphics[width=\\linewidth]{figs/clusters/CLU_AP_ALL[SSPD].png}\n    \\caption{SSPD, lowest rank}\n  \\end{subfigure}\n  \\caption{The AP-clusters of the measures the best and wort Davies-Bouldin indexes.}\n  \\label{fig:cluster-best-worst-db-ap}\n\\end{figure}\n\n\\begin{figure}[h!]\n  \\centering\n  \\hspace{1em}\n   \\begin{subfigure}[c]{0.4\\linewidth}\n     \\includegraphics[width=\\linewidth]{figs/clusters/CLU_H_ALL[ERP;g=0,0].png}\n    \\caption{ERP, $\\epsilon=0.203$, highest rank}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}[c]{0.4\\linewidth}\n    \\includegraphics[width=\\linewidth]{figs/clusters/CLU_H_ALL[SSPD].png}\n    \\caption{SSPD, lowest rank}\n  \\end{subfigure}\n  \\caption{The HCA-clusters of the measures the best and wort Davies-Bouldin indexes.}\n  \\label{fig:cluster-best-worst-db-h}\n\\end{figure}\n\n\n\nAs a consequence of the unreliability of the DB-index, the main tool for examining the clusters will be visual inspection.\nThis will allow us to account for the different aspects of trajectory similarity and formulate conclusions accordingly. \nRe-examining \\Cref{fig:cluster-best-worst-db-ap,fig:cluster-best-worst-db-h} with visual inspection it would appear that SSPD produced cleaner and fewer clusters than both EDR and ERP. \nThis is in stark contrast to the ranking created by the Davies-Bouldin criteria under both HCA and AP analysis. \n\n\nThis evaluation alternative comes with its own drawbacks, one of which is the matter of subjectivity. \nAt the same time, it has been stated that human assessment is an important component for determining the quality of clusters\\cite{79-SilhouetteAnalysis}. \nWe will not be declaring any measure better than the others as our results do not provide support for an accurate ranking.\n\n\n\n% We cannot declare one measure just better than all others from the evaluation that we executed here as it makes no sense. This is in large part due to the inherent bias of using a strict lockstep method to evaluate the final clusters. \n% By visual inspection, SSPD produced cleaner and fewer clusters than EDR, $\\epsilon=0.203$ under AP, despite having a much worse criterion. This pattern repeats itself under HCA when predetermined even with  the amount of final clusters. EDR  as well \\Cref{fig:cluster-best-worst-h-db}.\n\n% Based on those arguments, the main tool for examining the clusters will be visual inspection. This will allow us to account for the different definitions/aspects of similarity and formulate conclusions in an aggregate manner. \n% This method comes with its own drawbacks, one of which is the matter of subjectivity. Yet as brought up in supported previous works[CITATIONS], human assessment key for determining the quality of clusters. \n\n\n\n\n\\section{Cluster Behavior}\n\nFirst, we describe what we expected the clusters to look like based on the properties of the specific similarly distance function. \nFor the methods that operate with a parameter value, we discuss how changing that value would affect the cluster results.\nThen we compare our expectations to the clusters themselves.\nAffinity propagation is a was the parameter-free method, thus its results are weighted more.\nOn the other hand, the number of hierarchical clusters was arbitrarily set, leading us to use its results as a supplementary evaluation. \n\n\n% https://www.wordhippo.com/what-is/another-word-for/foreseeable.html \n\\subsection{Expectations}\nIn general, there are three factors that will affect how we expect the final clusters to appear. \nMeasures that are context-aware should calculate fewer fuzzy clusters.  \nNext, measures that account for local time shifts should group trajectories that have similar sub-sections but with an offset creating a wider band of similarity.\nLastly, we expect the noise-sensitive trajectories to create fuzzier trajectories.  \n\n\n\\textbf{Euclidean Distance} is the only lock-step measure, and trajectories that are in the same region might receive an artificially high similarly score by nature of being near each other. \nA trajectory pair will be rewarded if they have elements at the same index which are near each.\nThis would create fuzzy clusters as each point evaluated isolation and taking the average of the pairwise element-distances will artificially smooth out the distances.\nAn extra amount of fuzziness is expected to come from the fact that this measure is sensitive to noise. \n\n% WE COULD observe that there are trajectories that oscillate around the same region at a similar pace- giving them a lock-step similar score, but the cluster ends up looking fuzzy. \n\n\\clearpage\n\\textbf{Dynamic Time Warping}  optimizes for local shape similarity and warps trajectories to reflect similarity after shape-preserving transformations.\nWe expect the final clusters to appear fuzzy at first glance as the local similarities would be out of sync. \nYet upon closer examination, we should be able to spot bands of cohesive trajectory sections. \nDTW is a noise-sensitive method, so we would expect some level of fuzziness to be present, however, the clusters should be crisper than that of the Ed. \n\n\n\nFrom \\textbf{Hausdorff Distance}, we would expect crisper clusters than both Ed and DTW if we could guarantee the data free of noise.\nThe maximizing over a minimum of all element-element pairings means that the overall shape similarity is weighted in a way that the other measures do not account for. \nIn other words, the global resemblance matters more under this definition. \nHowever, the data set we used is not noise-free so while we expect some crispness, there will be fuzziness of the clusters due to its noise sensitivity.\n\n% All of the trajectories' points have to be near each other for if the pair is to receive a high similarity score.\n% stemming from the reduction of similarity distance to distance between two trajectory elements. \n\nOne of the key features of \\textbf{Symmetrized Segment-Path Distance} is that it accounts for whole trajectory shape similarity. \nThis means that we expect it to generate the crispest looking clusters. \nThe expectation of crisp clusters is further substantiated by its tolerance to noise\nThis method aimed to be invariant to the physical locations, meaning that trajectories of similar shapes with different origins could be grouped together. This could result in some broader bands of similarity.\n\n% All of the parametric measures adapt to local time shifts like in the same manner as DTW, and  therefore we expect the clusters they generate exhibit some of the same type of fuzziness. This, of course, is not the only factor that affects how fuzzy or crisp the clusters become. The choice of parameter, as well as the (internal workings) of the algorithms matter greatly.  \n%SOMETHING ABOUT HOW DTW ERP etc have re-s sim to dtw as noted in \\cite{26}\n\n\nRecall that \\textbf{Edit Distance on Real Sequences} uses the parameter $\\epsilon$ to as the matching threshold for how close how two trajectory elements are.\nDecreasing the parameter value leads to an increase in strictness in how close elements have to be, and in turn, would lead to crisper clusters.\nIt goes without saying that a too restrictive $\\epsilon$ would no longer be accurate; if no trajectory elements are matching, the only basis for similarity would be the trajectory lengths. \nClusters are expected to have some level of fuzziness as EDR considers the trajectory element in isolation. \n\n\n\\textbf{Edit Distance with Real Penalty} was computed with one parameter value.\nWe have established that this metric is sensitive to noise and that it accommodates local time shifts.\nAs EDR, this measure does isolates the trajectory elements when computing the similarity distance. \nThis means that there are three factors that contribute to fuzzy clusters, thus we expect the fuzziest clusters to be generated from this metric.  \n% As it is a measure that handles local time shifts and does not compare a trajectory as a whole, we expect the clusters to appear quite fuzzy. This expectation is further supported by its low tolerance to noise. \n\n\n\\textbf{Move-Split-Merge} handles local time shifts in the same manner as DTW and the other Edit Distance-based measures.\nWe expect to observe trajectory sections that match and create wider bands. \nMSM distinguishes itself by accounting for the values that surround a given element when computing the similarity score. \nThis means that we expect the clusters are crisper than those of generated by EDR and ERP. \nThe parameter of MSM determines to which degree Splits and Merges are favored over Moves. \nAs the cost increases, they will increasingly be evaded in favor of directly substituting the element. \nThe cost of a Move is pairwise element-element distance, and in turn, the clusters would resemble those created by a Euclidean distance based measure. \nOn the other hand, if the parameter is set too low we expect more trajectories that do not resemble each other to get clustered together. \n\n\n%I thin,, it is hard to tell\n\n% Finally we study how we expect the change of the cost of MSM transformations to impact the final clusters. The parameter determines how much splits and merges should be favored over moves. At the extreme end, MSM will resemble DTW as element-element distance would dominate the cost matrix. That is, the higher the value of c, the more the cluster should resemble DTW. For lower values of c, we should see a preference for actively splitting and merging, bringing its cluster results closer to that of ERP. \n\n% Setting the cost to 1, results in similarity scores that are\n\n\n\\subsection{Visual Inspection}\n\nThe visual inspection inspects the apparent fuzziness of the clusters as well as how scatted the trajectories within a cluster are. \nWe will refer to the latter of these characteristics as the \\textit{band} of similarity which describes the general \\textit{trend} of the cluster. \nWhere is it possible, we remark how larger trajectory sections were processed. \nUnfortunately, spotting tendencies like that is not something visual inspection excels at.\n\nIn the case of affinity propagation, we take note of how many clusters it generated. \nThe corresponding evaluation for the hierarchical clusters is taking note of how balanced the final clusters are.\nWith how hierarchical clusters are created, some imbalance is expected as the most distinct trajectories will be connected last.\n\n% contour  \n%  silhouette\n%  hierarchical affinity\n\n\\textbf{Euclidean Distance:}\n\\begin{itemize}\n\\item AP:  In terms of overall shape, the clusters appear very fuzzy. \nThere are some clusters where that have a clearer contour and some where it is possible to spot a trend for the trajectories. \nNevertheless the general impression remains fuzzy; we observe trajectories that seem to oscillate freely around the apparent trajectory band.\nWhile oscillations make the clusters appear fuzzier, the clusters do not come across as randomly grouped observations. \n\n\\medskip\n\\item HCA: There appears to be a bias and clusters are unbalanced. \nSome of the clusters contained a few trajectories while some of them encompassed a large number of them.\nIn those clusters the bands were obvious, but the oscillations were even greater than those observed under AP.\nThis makes sense as the new clusters are created by merging similar sub-clusters. \nWe would expect a clearer band, but a fuzzier contour. \n\\end{itemize}\n\n\\textbf{Dynamic Time Warping:}\n\\begin{itemize}\n\\item AP: We observed two clusters that were very crisp and even more clusters that exhibited clear trends. \nThe trajectories do not seem to oscillate around the band in the clusters as much as they did under Ed. \nWe can spot some trajectory sections that appear as if they have been re-aligned– leading to a less messy expression. \nStill, there are some oscillations and noisy clusters that make it hard to tell exactly why some trajectories were clustered together. \n\\medskip  \n\\clearpage\n\\item HCA: The clusters are unbalanced, however less so than the ones created by Ed. \nThey illustrate how shape similarity is persevered under this measure by displaying a clear trend in the clusters. \nYet, the clusters are fuzzy in that their trajectories still deviate from the central band. \nFrom these clusters it appears as if some of the trajectories are outliers; \nthey appear to be distinct from the rest of the trajectories and are placed in their own clusters. \n\\end{itemize}\n\n\n\\textbf{Hausdorff Distance}\n\\begin{itemize}\n\n\\item AP: Compared to DTW and Ed, the final number of clusters increased and the clusters created were both crisper and fuzzier. \nThe clusters display both the most advantageous and most disadvantageous aspects of the Hausdorff metric. \n% Reducing the similarity score to one element-element distance did indeed  amount\nHowever, the number of crisp clusters outweighs the fuzzy ones, and the contours of the clusters are crisp enough to highlight more intricate trajectory details. \n% This contrasts the other clusters clustered together, rather than a general direction across the grid\n\n\\medskip\n\\item HCA: Again, we see both crisp and intricate clusters as well as very fuzzy ones. \nThe observations from affinity propagation hold for these clusters as well; \nboth the advantages and disadvantages of setting the similarity score as the distance between two trajectory elements are highlighted. \nThere is one cluster that is so fussy that we were quite puzzled by how it was formed.\n% It may be that trajectories with outliers and noise were put together in such a way that they were at some point considered so similar to each other that they were gathered. \n\\end{itemize}\n\n\n\\textbf{Symmetrized Segment-Path Distance:}\n\\begin{itemize}\n\n\\item AP: This measure created fewer clusters than Hd, yet the clusters it created appear to be at least equally as crisp.\nWe observed that the clusters had such tight bands that curves of the trajectories were accentuated.\nIn contrast, DTW clustered the trajectories by their general shape and direction.\nWhereas Hd was sensitive to noise, it becomes clear that SSPD addressed that weakness.\nTwo clusters stand out as more fuzzy than the others, but this is likely due to noisy data.\n\\medskip \n\\item HCA: The clusters are about as balanced as those created by Hd. \nAs was demonstrated in the AP-clustering, there is a trend towards showing the intricacies of shape similarity at a larger scale. \nThe bands of similarity are thinner than both Ed end DTW and more detailed than Hd. \n\\end{itemize}\n\n\n\\textbf{Edit Distance with Real Penalty:}\n\\begin{itemize}\n\n\\item AP:  The clusters created by ERP are significantly more fuzzy than that of Hd and SSPD. \nThis is expected as it gives similarity scores based on edits before and then the distance between trajectory elements.\nHowever, it is unexpected that the resulting clusters were as fuzzy as those created by DTW and Ed, especially as it created far more clusters than either of them did.\nThe increased number of clusters should indicate that we would have more distinguished clusters, but this does not appear to be the case.\nEven still, we observe that clusters were not randomly put together.\nLooking closer at specific clusters, it is possible to spot turns and segments that are just shifted from each other. \n\\medskip\n\\item HCA: These clusters are unbalanced, there is a cluster that only has one trajectory. \nYet, that trajectory does not appear significantly distinct from the ones existing clusters. \nFrom visual inspection it challenging to get more insight. \nThe bands across the clusters are quite general and there is not a consistent show of shifted segments.\n\n\\end{itemize}\n\n\\textbf{Edit Distance on Real Sequence: }\nIn discussing this method, we examine the clusters obtained from both parameter values in parallel.  \n% $\\epsilon = \\{0.101, 0.201\\}$\n\n\n% contour  \n%  silhouette\n%  hierarchical affinity propagation\n\n\\begin{itemize}\n\\item AP: This measure generated the two largest number of AP-clusters. \nThe most restrictive parameter led to 48 clusters while the other value resulted in 39 clusters. \nIn our subjective opinion, both of the parameters resulted in too many clusters for a data set of 300 observations. \nHowever, with fewer trajectories in each cluster analysis through visual inspection becomes is easier.\nWe observed that the clusters contained trajectories whose segments were shifted from each other. \nBoth parameter values resulted in crisp clusters, and our approximation of the recommended value gave seemingly more defined contours. \nWhile increasing the threshold value led to fuzzier clusters, these clusters were crisper than those of ERP. \nThis is an expected result as EDR is noise-tolerant whereas ERP is not.\n\\medskip  \n\\item HCA: For both parameter values, there were bands that obscured the intricacies of shape similarity.\nOnce more we observed that increasing the parameter value resulted in fuzzier clusters. \nHowever, the increase in fuzziness was less than expected. \nThe largest parameter value led to a more unbalanced distribution of trajectories, further signifying that the smaller one remains the most suited value for $\\epsilon$.\n\\end{itemize}\n\n\n\\textbf{Move-Split-Merge:}\n\nAs we did for EDR, the clusters created by MSM and the effect of varying the parameter are discussed in parallel. \nWe first note that the clusters MSM created with the cost was set to 1 and were indistinguishable from those of Ed. \nThis was not an entirely unexpected result given what we know about MSM, and that the two methods had identical rankings of the most similar trajectory pairs. \nBy reason of that cost parameter being set too high and the accompanying clusters already being described, we will focus on the two remaining parameter values. \n\n  % cost$= \\{1, 0.1, 0.01\\}$\n\\begin{itemize}\n\n\\item AP: We observed that the lowest parameter value resulted in fewer clusters, but both of the parameter values led to a larger number of clusters than expected.\nAs with EDR, the large number of clusters makes it easier to visually analyze them. \nGiven that this measure is both moderately noise-tolerant and context-aware we expect the clusters to be crisp.\nIndeed, the majority of the clusters have crisp contours wherein the intricacies of the trajectories are preserved.\nSome clusters contain what appear to be outlier trajectories.\nThis would suggest that the discrimination degree of this measure was high enough to isolate them in a way that no measures did. \nThe smaller parameter value resulted in both fuzzier clusters and an increase in clusters with few trajectories.\nThis may be an indication of that value being too low, suggesting that $0.1$ was the most appropriate cost for this data set. \n\n\\medskip  \n\\item HCA: The clusters created by the lowest cost parameter were more unbalanced and fuzzier than those generated by the middle one. \nThis further supports the argument that the middle of the cost value is the most fitting one. \nInterestingly, there were still trajectories that were clustered by themselves as if they were outliers. \nIt looks as if these trajectories are consistent across both parameter values and clustering techniques. \n\n\\end{itemize}\n\n\n\n\n\n\\section{Reflections}\n% Other Applications write here, but i i think it might belong to \"further work\"\n\nThe measures created clusters whose qualities coincide with the anticipated results. \nWe observed fuzzy clusters where the underlying measure was less tolerant to noise and crisper clusters where the measure accounted for whole trajectory similarity.\nAlmost all of the measures were elastic, and we observed several clusters with trajectories that were time-shifted. \n\nBy visual inspection, it was hard to tell if metricity affected the clusters although this may have been a result of picking clustering techniques that did not require a metric distance function. \n% metricity. \n\nThe clusters' appearance remained consistent between AP and HCA for a given measure, even as the number of clusters changed. \nThis observation was to be expected as the models that created the clusters used the same similarity distances scores. \n\nLastly, we comment on a few algorithm-specific observations. \nThe fuzziness of the clusters created by the Euclidean distance align with its lock-step design just as the crispness of SSPD’s clusters aligns with its design purposes. \nIt was initially unexpected that ERP would have the fuzziest looking clusters. However, upon closer examination, we reasoned that it made sense that a non-context aware, noise sensitive method that adapts to time shifts would lead to quite fuzzy clusters. \n\nThe way MSM could consistently filter out trajectories that did not behave like the others would imply that it would be well suited for outlier detection. \n\n% For \\textbf{MSM} the effects of its parameter, setting $c$ to $0.1$ resulted in AP generating a cluster consisting of just one trajectory and decreasing it $0.01$  lead to 5 of these single trajectory clusters. This could be an indication of poorly chosen parameter values. Looking at the HCA- generated clusters support this assumption. We observed less balanced clusters as the cost parameter decreased. Based on this, we have conclude that MSM with cost parameter $c=1$ best is the most representative for this measure and further analysis will be based on it.  \n\n\n\n\\section{Inconsistencies from Simplifications}\nAs noted in \\Cref{ch:5}, several simplifications were made for this experiment.\nWe close this chapter by reflecting on how these simplifications have affected the results.\n\n% \\clearpage\n\n\\subsection{Data format}\n%  For real life data, it is not reasonable to assume that the trajectories will be of the same length and furthermore, if the trajectories are of the same length this still does not mean the time spent in each location matches up.\n\nThe first simplification that was made was truncating the trajectories to equal length.\nIn doing this we removed the option to study how measures would have handled cases like this.\nThere would be insight to be gained from examining measures at different trajectory lengths. \nIn particular, it is not reasonable to assume that real data would have this property. \nThe clusters could have ended up looking quite different, possibly highlighting the difference between trajectory section and whole trajectory similarity.\n\nOf the algorithms in this thesis, only the Euclidean distance lacked a definition for trajectories of unequal length. \nIt is possible to design a comparative study where lock-step measures can give scores for these trajectories. \nAn option would be to artificially add more trajectories elements by interpolation. \nHowever, we decided against it as we felt confident there would be enough properties to examine after the simplification. \n\nThe next data-format simplification we did was the re-scaling.\nThe manner in which it was done meant that the data would lose its connection to the real world.\nTo exemplify this we refer to \\Cref{fig:sspd_loc_real}. \nThe clusters were created based on the scaled data, thus those clustered were quite crisp. \nHowever, when displaying those same clusters with their raw coordinates it becomes clear how scattered the trajectories are.\nIt becomes clearer that trajectories were clustered together based on shape similarity. \nWe reiterate that the intent was to study measures themselves, thus the data set selection— and thereby the re-scaling was inconsequential. \n\n\n\n\\begin{figure}[h]\n  \\centering\n  \\includegraphics[width=.9\\linewidth,height=.9\\textheight,keepaspectratio]{figs/clusters/CLU_AP_ALL[SSPD]_REAL.png}\n  \\caption{Affinity propagation clusters created with SSPD, but showing the raw trajectory locations}\n  \\label{fig:sspd_loc_real}\n\\end{figure}\n\n\n\\subsection{Distance Computation and Evaluation}\n% Tweaking the format and scale of the data is one thing, but the next line of simplifications mattered more for the evaluations of the measures. \n\nWe tested three measures that required a parameter and we did not do any proper parameter tuning. \nERP would likely have had more agreement with the other measures in \\Cref{tab:top-10-sim-pairs} if different values for the reference point had been tested out. \n\n\n% Next, while we did not  the measues \n\n% The last simplification we would like to bring attention to is also something that potentially affected the final evaluation. \n\nThe application we chose for the similarity distance measures, clustering, is itself an area of active research. \nThe interconnectedness of clustering techniques and distance algorithms could have been studied in more detail before settling on affinity propagation and hierarchical clustering analysis as the evaluation basis.\nWe acknowledge that there may be traits of the selected measures that have been obscured or misrepresented. \n\n", "meta": {"hexsha": "82b7aed3f2aaac075447bfc30baef9ef8711d13f", "size": 30395, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/7-discussion.tex", "max_stars_repo_name": "katrilh/thesis-NTNU", "max_stars_repo_head_hexsha": "9030f0a82524a6f863d8954656193acd9ab89f5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/7-discussion.tex", "max_issues_repo_name": "katrilh/thesis-NTNU", "max_issues_repo_head_hexsha": "9030f0a82524a6f863d8954656193acd9ab89f5f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/7-discussion.tex", "max_forks_repo_name": "katrilh/thesis-NTNU", "max_forks_repo_head_hexsha": "9030f0a82524a6f863d8954656193acd9ab89f5f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 72.5417661098, "max_line_length": 567, "alphanum_fraction": 0.8011844053, "num_tokens": 6401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.40322804550022384}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%                                                                 %\n%  GEANT manual in LaTeX form                              %\n%                                                                 %\n%  Michel Goossens (for translation into LaTeX)                   %\n%  Version 1.00                                                   %\n%  Last Mod. Jan 24 1991  1300   MG + IB                          %\n%                                                                 %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\Origin{G.Tromba, P.Bregant}\n\\Submitted{10.10.89}\\Revised{16.12.93}\n\\Version{Geant 3.16}\\Routid{PHYS251}\n\\Makehead{Simulation of Rayleigh scattering}\n\\Shubr{GRAYL}{}\n \n\\Rind{GRAYL} generates Rayleigh scattering of a photon using \nthe random-number\ncomposition and rejection technique to sample the momentum\nof the scattered photon and the scattering angle, according to the\nform-factor distribution. In this reaction no new particles are\ngenerated and the kinematical quantities of the scattered photon\nreplace the original ones in the \\FCind{/GCTRAK/} common block.\n \nActivation of the Rayleigh scattering is done via the {\\tt FFREAD} data\nrecord {\\tt RAYL}. If this process is activated, \\Rind{GRAYL} is called\nby \\Rind{GTGAMA} when a Rayleigh scattering occurs.\n\\section{ Method }\n \nThe Rayleigh differential cross section as a function of $ q^2 $ is given\nby \\cite{bib-NELS}:\n\\begin{equation}\n\\frac{d \\sigma_R \\left( q^2 \\right) }{ d \\Omega } =\n \\frac{ \\pi r_0^2}{ k^2 } \\left( \\frac{1 + \\mu^2 }{ 2 } \\right)\n \\left| F_T \\left( q \\right) \\right| ^2\n\\end{equation}\nwhere:\\\\\n \n\\[\\begin{array}{LL}\nr_0       & \\mbox{electron radius} \\\\\nk         & \\mbox{incident wave vector} \\\\\nq=2k sin \\frac{ \\theta }{2}  & \\mbox{momentum of scattered\n              photon ($\\theta$ is the scattering angle)} \\\\\n\\mu = cos \\theta  & = 1 - \\frac{q^2 }{ 2 k^2} \\\\\nF_T \\left( q \\right)     & \\mbox{molecular form factor}\n\\end{array} \\]\n \nUnder the assumption that the atoms of a molecule are completely independent,\n$ \\left| F_T \\left( q \\right) \\right| ^2 $ is given by:\n\\begin{equation}\n \\left| F_T \\left( q \\right) \\right| ^2 = \\sum_{i=1}^{N}\n \\frac{W_i}{A_i}  \\left| F_i \\left( q_i , Z_i  \\right) \\right| ^2\n \\sigma_{c_i} \\left( Z_i , E \\right)\n\\end{equation}\nwhere the index $i$ runs on the $N$ atoms in the molecule and:\n \n\\[\\begin{array}{LL}\n W_i        & \\mbox{proportion by weight} \\\\\n Z_i , A_i  & \\mbox{atomic number and weight} \\\\\n F_i        & \\mbox{form factor} \\\\\n\\sigma_{c_i}& \\mbox{total atomic cross section for coherent scattering}\\\\\n\\end{array} \\]\n \nUsing the combined composition and rejection sampling method described in\n\\Rind{GPAIRG} ({\\tt [PHYS211]}) we may set:\n\\begin{equation}\nf \\left( q \\right) = \\sum_{i=1}^{N} \\alpha_i f_i \\left( q \\right)\ng_i \\left( q \\right) = \\sum_{i=1}^{N} A \\left( q_i^2 \\right)\n\\frac{ \\left| F_T \\left( q \\right) \\right| ^2 }{ A \\left( q_n^2 \\right) }\n\\left( \\frac{1+\\mu^2}{2} \\right)\n\\end{equation}\n\nwhere:\n \n\\[\\begin{array}{LL}\n n          & \\mbox{number of energy bins} \\\\\n q_i        & \\mbox{momentum of the photon with energy $ E_i $ of the\n                 $i^{th}$  bin} \\\\\n q_n        & \\mbox{upper limit for the momentum of the scattered photon} \\\\\n \\alpha_i   & A \\left( q_i^2 \\right)  \\\\\n f_i \\left( q \\right )  &\n \\frac{\\left| F_T \\left( q \\right) \\right| ^2}{A \\left( q_n^2 \\right)}  \\\\\n g_i \\left( q \\right )  & = \\frac{1+\\mu^2}{2} \\mbox{\\hspace{0.5cm} \nrejection function.}\n\\end{array} \\]\n \n \nTherefore, for given values of the random numbers $r_1$ and $r_2$, \\Rind{GRAYL}\nsamples the momentum of the scattered photon and the scattering angle\n$\\theta$ via the following steps:\n \n\\begin{enumerate}\n\\item sample $ A \\left( q^2 \\right) = r_1 A \\left( q_n^2 \\right) $\n\\item find the $ \\left (  q_{i-1} , q_i  \\right] $ interval\nwhich gives $ A \\left( q_{i-1}^2 \\right) \\leq A \\left( q^2 \\right)\n\\leq  A \\left( q_i^2 \\right) $\n\\item calculate the linear extrapolation:\n\\begin{equation}\nq = q_{i-1} + \\left( A \\left( q^2 \\right) -  A \\left( q_{i-1}^2 \\right) \\right)\n\\frac{q_i - q_{i-1} }\n{ A \\left( q_i^2 \\right) -  A \\left( q_{i-1}^2 \\right)} \\nonumber\n\\end{equation}\n\\item calculate $\\mu = cos \\theta  = 1 - q^2/(2 k^2) $\n\\item calculate $g_i \\left( q \\right) = (1 + \\mu^2 )/2 $\n\\item if $g_i \\left( q \\right) > r_2 $ the event is accepted, otherwise\ngo back to 1.\n\\end{enumerate}\n", "meta": {"hexsha": "7e985d279fec73970f53c616e3758764783b1a16", "size": 4435, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "geant/phys251.tex", "max_stars_repo_name": "berghaus/cernlib-docs", "max_stars_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-24T12:30:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T12:30:01.000Z", "max_issues_repo_path": "geant/phys251.tex", "max_issues_repo_name": "berghaus/cernlib-docs", "max_issues_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "geant/phys251.tex", "max_forks_repo_name": "berghaus/cernlib-docs", "max_forks_repo_head_hexsha": "76048db0ca60708a16661e8494e1fcaa76a83db7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4485981308, "max_line_length": 79, "alphanum_fraction": 0.581059752, "num_tokens": 1441, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.5117166047041652, "lm_q1q2_score": 0.40319747617487545}}
{"text": "\\section{Optical Tracking}\n\\subsection{Overview}\nThe Optical Tracking System is implemented with three subsystems:\n\\begin{enumerate}\n  \\item Video Extraction\n  \\item Pinhole Camera Model\n  \\item Epipolar Geometry\n\\end{enumerate}\n\\subsection{Video Extraction}\nThe Video Extraction system's function is to extract the location of a patricular object within the video footage. The objects, in this case, are differently colored small balls. The small balls represent sever key points of the Quadcopter. By determining the location of the balls, we will be able to calculate the position and attitude of the Quadcopter.\nThe procedure of video extraction is described as following:\n\\begin{enumerate}\n  \\item Shotting: Get images from camera,\n  \\item Transforming: transform the image to HSV colorspace,\n  \\item Extracting: use tresholding to extract pixels in patricular color range, then use histogram and backprojection to determin the probablity that the pixels belong to the model,\n  \\item Denoising: use opening and closing to denoise,\n  \\item Determining: use \\emph{Lucas-Kanade} and \\emph{CamShift} algorithm to determin the centroid of the extracted pixels.\n\\end{enumerate}\n\\subsubsection{Shooting}\nIn this project, v4l\\footnote{a.k.a. Video For Linux} is the middleware of OpenCV and camera. With \\emph{v4l} and \\emph{OpenCV}, reading an image from camera is as easy as following:\n\\lstset{language=python}\n\\begin{python}\ncap = cv2.VideoCapture(source)\nimg = cap.read()\n\\end{python}\n\\subsubsection{Transforming}\nDifferent from the RGB colorspace, HSV colorspace has a unique character: its V channel represents the brightness. If we remove V channel from tresholding, the same color profile will be able to work in different lighting conditions.\nThe transforming process is described below\\cite{cite4}:\n\\begin{align}\n  M &= \\operatorname{max}(R, G, B) \\\\\n  m &= \\operatorname{min}(R, G, B) \\\\\n  C &= M - m\\\\\n  H^\\prime &=\n    \\begin{cases}\n      \\mathrm{undefined},        &\\mbox{if } C = 0 \\\\\n      \\frac{G - B}{C} \\;\\bmod 6, &\\mbox{if } M = R \\\\\n      \\frac{B - R}{C} + 2,       &\\mbox{if } M = G \\\\\n      \\frac{R - G}{C} + 4,       &\\mbox{if } M = B\n    \\end{cases} \\\\\n  H        &= 60^\\circ \\times H^\\prime\\\\\n  V &= M\\\\\n   S &=\n    \\begin{cases}\n      0,           &\\mbox{if } C = 0 \\\\\n      \\frac{C}{V}, &\\mbox{otherwise}\n    \\end{cases}\n\\end{align}\nThe code used to transform the image is:\n\\begin{python}\nhsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n\\end{python}\nNote that by default, OpenCV uses BGR color space.\n\\subsubsection{Extracting}\nOpenCV's built in treshold function is used to utilize multithreading.\nThe process of tresholding is printed below:\n\\begin{python}\nmask = cv2.inRange( hsv, \n                    np.array((0., 60., 32.)), \n                    np.array((180., 255., 255.))\n                    )\n\\end{python}\nHowever, simply tresholding is often not enough. The object tracked can have a complex color feature. In order to track the entire object, it is necessary to consider all of the features. Histogram is used to model the color distribution of an object, and me can then map the probability of pixels using backprojection.\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.2\\textwidth]{../Pictures/histogram.JPG}\n    \\caption{A sample histogram\\cite{cite5}}\\\\\n\\end{figure}\nBackprojection uses the modeled histogram to find the probability that certain pixel belongs to the model. Consider an image matrix $M$, each pixel can be described as pair $(H_{i,j},S_{i,j})$. We can use the two values to create a 2D histogram that represents the distribution of certain color range in $H$ and $S$. Below is a sample 2D histogram generated by \\emph{OpenCV Python Sample}.\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.3\\textwidth]{../Pictures/2dhist.png}\n    \\caption{A sample 2D histogram}\\\\\n\\end{figure}\nAfter generating the histogram, the probability that a pixel belongs to the model can be expressed by the following steps:\n\\begin{enumerate}\n  \\item Find the pair $(H_{i,j},S_{i,j})$ of a pixel,\n  \\item find the correspondent bin in the histogram,\n  \\item get the relative frequency of the bin.\n\\end{enumerate}\nThen we can use the frequency to map a binary image. In this image, each pixel represents the probability that the correspondent pixel in the original image belongs to the model. Below is an example backproject image:\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.5\\textwidth]{../Pictures/backproject.png}\n    \\caption{A sample backprojrction}\\\\\n\\end{figure}\n\\subsubsection{Denoising}\nAfter calculating the backproject image, we will be able to use morphology transformation to remove noises. In this projcet, we used Opening and Closing to remove small noise pixels and fill black pixel holes in the backprojection.\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.3\\textwidth]{../Pictures/Opening.png}\n    \\caption{Sample Opening operation\\cite{cite7}}\\\\\n\\end{figure}\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.3\\textwidth]{../Pictures/Closing.png}\n    \\caption{Sample Closing operation\\cite{cite6}}\\\\\n\\end{figure}\n\nThe result is significant. A great deal of noises is removed in this process:\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.3\\textwidth]{../Pictures/before.png}\n    \\caption{Befor morphology transformation}\\\\\n\\end{figure}\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.3\\textwidth]{../Pictures/after.png}\n    \\caption{After morphology transformation}\\\\\n\\end{figure}\n\\newpage\n\n\\subsubsection{Extracting}\nThere are two stages of extracting. They are:\n\\begin{enumerate}\n  \\item Detecting\n  \\item Tracking\n\\end{enumerate}\nThe difference between them is that \\emph{Tracking} requires the original location of the object to be known. That information should be fed with \\emph{Detecting} in the \\emph{first} frame of video source.\n\nBy \\emph{Detecting}, we find locations where the image of \\emph{source} is similar to \\emph{template}.\nThe algotighm we used in \\emph{Detecting} is rather simple. It \"shifts\" the \\emph{template} on the \\emph{source}, and find the similarities bewteen the \\emph{template} and the image below.\n\nThe method of template matching is printed below:\n\\begin{minted}[mathescape,\n               linenos,\n               numbersep=5pt,\n               gobble=2,\n               frame=lines,\n               framesep=2mm]{python}\n  import numpy as np\n  import cv2\n  import math\n\n  def match(template, image):\n    '''\n    Match template on image and return the centroid's coord.\n    '''\n\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n    template = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)\n\n    result = cv2.matchTemplate(gray, patch, cv2.TM_CCOEFF_NORMED)\n    result = np.abs(result) ** 3\n    val, result = cv2.threshold(result, 0.01, 0, cv2.THRESH_TOZERO)\n\n    minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(result)\n\n    height, width, depth = template.shape\n    x, y = maxLoc\n    x += width/2\n    y += height/2\n      \n    return (x,y)\n\\end{minted}\n\nIn order to make things clearer, we used a marker from the TV series \\emph{Person of Interest} to mark the point of interest.\nHere's the code we used to mark the object:\n\\begin{minted}[mathescape,\n               linenos,\n               numbersep=5pt,\n               gobble=2,\n               frame=lines,\n               framesep=2mm]{python}\n  import numpy as np\n  import cv2\n  import math\n\n  def draw_machine_mark(size, location, image):\n      '''\n      This function draws a machine mark on the image\n      '''\n      original = cv2.imread(\"assets/machine.png\", -1)\n\n      osize = math.sqrt(original.size)/2\n      ratio = size / osize\n      height, width, depth = image.shape\n      timg = cv2.resize(original, (0,0), fx=ratio, fy=ratio)\n      x, y = location \n\n      image[:] *= 0.8\n\n      x_start = max(0, x - size/2)\n      x_end = min(x_start + size, width)\n      x_start = min(x_end - size, x_start)\n      y_start = max(0, y - size/2)\n      y_end = min(y_start + size, height)\n      y_start = min(y_end - size, y_start)\n      \n      roi = image[y_start : y_end, x_start : x_end]\n      for c in range(0,3):\n          roi[:,:,c] = timg[:,:,c] * (timg[:,:,3] / 255.0) + roi[:,:,c] * (1 - timg[:,:,3] / 255.0) \n      image[y_start : y_end, x_start : x_end] = roi\n\\end{minted}\nBelow is an image of the effect:\\\\\n\\begin{figure}[h!]\n\n  \\centering\n    \\includegraphics[width=0.5\\textwidth]{../Pictures/after.png}\n    \\caption{Example of tracking effect}\\\\\n\\end{figure}", "meta": {"hexsha": "23b20cddef2b59fdf276b860f5a03e62f13aab13", "size": 8507, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Paper/tracking.tex", "max_stars_repo_name": "andyfangdz/ProjectQuad-restored", "max_stars_repo_head_hexsha": "5791ba2f8557a278404de37fb9c13042abe3ae27", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Paper/tracking.tex", "max_issues_repo_name": "andyfangdz/ProjectQuad-restored", "max_issues_repo_head_hexsha": "5791ba2f8557a278404de37fb9c13042abe3ae27", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2016-02-09T09:26:26.000Z", "max_issues_repo_issues_event_max_datetime": "2016-02-09T09:26:28.000Z", "max_forks_repo_path": "Paper/tracking.tex", "max_forks_repo_name": "andyfangdz/ProjectQuad-restored", "max_forks_repo_head_hexsha": "5791ba2f8557a278404de37fb9c13042abe3ae27", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0966183575, "max_line_length": 391, "alphanum_fraction": 0.6928411896, "num_tokens": 2350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4031366176424486}}
{"text": "% !TEX encoding = UTF-8 Unicode\n% !TEX spellcheck = en_US\n\\documentclass{svproc}\n\n\\usepackage{paralist}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{calrsfs} % Für Kalligraphie-F \n\\newcommand{\\bm}[1]{\\boldsymbol{#1}}\n\\DeclareMathOperator{\\arctantwo}{arctan2}\n% Latex-Makros für häufig verwendete Formelzeichen\n\\newcommand{\\ortvek}[4]{{ }_{(#1)}{\\boldsymbol{#2}}^{#3}_{#4} }\n\\newcommand{\\vek}[3]{\\boldsymbol{#1}^{#2}_{#3}}\n\\newcommand{\\rotmat}[2]{{{ }^{#1}\\boldsymbol{R}}_{#2}}\n\\newcommand{\\rotmato}[2]{{{ }^{#1}\\boldsymbol{\\overline{R}}}_{#2}}\n\\newcommand{\\transp}[0]{{\\mathrm{T}}}\n\\newcommand{\\ks}[1]{{\\mathcal{F}}_{#1}}\n\n% Für Deutsche Umlaute\n%\\usepackage{ngerman}\n\\usepackage[utf8]{inputenc}\n\n% Für Bilder\n\\usepackage{graphicx}\n\\usepackage{color}\n\\graphicspath{{./figures/}}\n\n% to typeset URLs, URIs, and DOIs\n\\usepackage{url}\n\\def\\UrlFont{\\rmfamily}\n\n\\begin{document}\n    \n\\mainmatter              % start of a contribution\n%\n\\title{Resolution of Functional Redundancy for 3T2R Robot Tasks using Two Sets of \\\\Reciprocal Euler Angles}\n%\n\\titlerunning{Reciprocal Euler Angles}  % abbreviated title (for running head)\n%                                     also used for the TOC unless\n%                                     \\toctitle is used\n%\n\\author{Moritz Schappler \\and Svenja Tappe \\and Tobias Ortmaier}\n%\n\\authorrunning{Schappler et al.} % abbreviated author list (for running head)\n%\n%%%% list of authors for the TOC (use if author list has to be modified)\n%\\tocauthor{Moritz Schappler, Svenja Tappe, and Tobias Ortmaier}\n%\n\\institute{Institute for Mechatronic Systems, Leibniz University Hannover, Germany,\\\\\n    \\email{moritz.schappler@imes.uni-hannover.de}}\n\n\\maketitle              % typeset the title of the contribution\n\n\n%ABSTRACT\n\\begin{abstract}\nRobotic tasks like welding or drilling with three translational and only two rotational degrees of freedom (``3T2R'') are of high industrial relevance but are ra\\-ther scarcely addressed in scientific publications.\nExisting solutions for the resolution of the functional redundancy of robotic manipulators with more than five axes performing these tasks either expand the full kinematic formulation or reduce it in intermediate steps.\nThis paper presents an approach to reduce the kinematic formulation from the start to solve the problem in a simpler way.\nThis is done by using a set of reciprocal Euler angles to describe the end-effector orientation and the orientation error in inverse kinematics.\n\\end{abstract}\n\n%KEYWORDS\n\\begin{keywords}\nfunctional redundancy, reciprocal Euler angles, \\\\ inverse kinematics, robot manipulators, five-DoF task, 3T2R task\n\\end{keywords}\n\n\\section{Introduction}\n\\label{sec:Intro}\nSince the first papers in the 1980s, the fields of inverse kinematics \\cite{GoldenbergBenFen1985} and the resolution of \\emph{intrinsic} redundancy \\cite{Yoshikawa1984} in robotics have been extensively elaborated upon.\nInverse kinematics for robot manipulators can be solved analytically for some structures and can be approached in general with gradient-based numeric methods at  joint position or joint velocity level.\nDue to the nonlinearity of rotation at position level \\cite{GoldenbergBenFen1985}, the latter is usually preferred.\n\nIntrinsic redundancy is defined as a robot joint space dimension higher than the operational space dimension and functional redundancy is defined as an operational space dimension higher than the task space dimension, implying that there are more independent joint coordinates than task coordinates.\n\nThe kinematics of \\emph{functionally} redundant robots performing tasks with five instead of six degrees of freedom (DoF) has drawn much less attention, even if many industrial relevant tasks only require 5-DoF such as the class of 3T2R-tasks where the tool for the task is axis-symmetric.\nThese tasks comprise amongst others arc welding \\cite{HuoBar2005}, drilling \\cite{ZhuQuCaoYan2013,GuoDonKe2015}, spray-painting \\cite{FromGra2010}, milling \\cite{MousaviGagBouRay2018}, laser-cutting and glueing and are transfered to a greater extend to robotic manipulators in the automotive or aviation industry.\n\nSince standard industrial robots have six DoF, one degree of \\emph{functional} redundancy exists which allows to improve performance characteristics of the robots as a secondary task while reaching a valid pose to perform one of the aforementioned primary tasks.\nTo be able to incorporate performance optimization into inverse kinematics via the well-established gradient projection method \\cite{Yoshikawa1984}, either the joint space can be augmented or the task space can be reduced. % \\cite{Huo2009}.\nAugmenting the joint space is possible by virtually inserting an additional joint for the rotation around the task's axis of symmetry (``tool axis'') \\cite{Baron2000}.\nReducing the task space can be performed by orthogonal decomposition of the end-effector twist \\cite{HuoBar2005}, removing the row of the ``task frame Jacobian'' corresponding to the tool axis \\cite{Zlajpah2017}, the construction of the Jacobian Nullspace based upon geometric properties of the task \\cite{LegerAng2016} or constructing a cone or pyramid resulting from the tool axis with an additional range of tolerance for tilt angles \\cite{FromGra2010}.\n\nAnother possibility for the resolution of the functional redundancy is a cascaded optimization where the inner loop calculates the inverse kinematics with standard methods and the outer loop optimizes the performance index.\nThe optimization can be performed by evaluating the index on a range of rotation angles around the tool axis \\cite{ZhuQuCaoYan2013} or by using the incremental change of the rotation around the tool axis directly to adapt the joint angles  \\cite{GuoDonKe2015}.\n\nThe choice of performance indices aims to improve the task execution with measures such as the joint positions quadratic \\cite{HuoBar2005} or hyperbolic \\cite{ZhuQuCaoYan2013} distances from their limits, singularity avoidance via Frobenius-norm condition number \\cite{ZhuQuCaoYan2013}, squared condition number \\cite{LegerAng2016} or a combination of manipulability and condition number of the Jacobian \\cite{HuoBar2008}, stiffness \\cite{GuoDonKe2015} or milling chatter stability margins \\cite{MousaviGagBouRay2018}.\n\nThe characteristic length required to normalize the Jacobian for the performance indices can be either chosen constant regarding the robot geometry \\cite{ZhuQuCaoYan2013} or as an additional optimization parameter \\cite{LegerAng2016}.\n\nThe existing methods each have drawbacks that are avoided by using the new method presented in this paper:\n\\begin{compactitem}\n    \\item Augmenting the joint space \\cite{Baron2000} increases the computational cost and can lead to an ill-conditioned Jacobian \\cite{HuoBar2008}.\n    \\item Using a nested optimization \\cite{ZhuQuCaoYan2013,GuoDonKe2015} does not allow using the well-proven gradient projection method.\n    \\item In \\cite{Zlajpah2017} the tool-axis rotation of the end-effector has to be calculated and canceled out in the nullspace.\n    \\item Describing the tool axis with two points requires to define a distance between these points, which has to be chosen e.\\,g. as the normalized Jacobian's characteristic length to gain a good conditioning of the optimization \\cite{LegerAng2016}.\n    \\item All methods have a high mathematical level of abstraction e.\\,g. using orthogonal decomposition \\cite{HuoBar2008}, linear matrix inequalities and convex optimization \\cite{FromGra2010}, rotation and component-selection of the vector part of the quaternion orientation error \\cite{Zlajpah2017} or sequential quadratic programming \\cite{LegerAng2016}.\n\\end{compactitem}\n\nThis paper transfers the velocity level approach from \\cite{Zlajpah2017} to the position level and the orientation error is expressed in Euler angles instead of quaternions:\n\nThe absolute orientation of the end-effector and the corresponding orientation error between desired and actual end-effector orientation are expressed with two sets of Euler angles which are mutually reciprocal.\nReciprocity for sets of Euler angles is defined in this paper as successive rotations around intrinsic elementary axes of switched order.\nBy this definition, the rotation component belonging to the tool axis in 3T2R tasks is always the same for the absolute orientation and for the orientation error, respectively.\nThe effect of the tool axis can then be eliminated from the kinematic equations.\nThis allows to express the kinematics equations in minimal form which makes it easy to use the gradient projection method to incorporate performance indices in inverse kinematics.\n\nThe contributions of this paper are\n\\begin{compactitem}\n    \\item a new formulation for the kinematics problem for robot manipulators performing 3T2R-tasks,\n    \\item an application of the formulation leading to an efficient solution for inverse kinematics with functional redundancy,\n    \\item remarks on the implementation of gradients of and w.r.t. rotation matrices and its performance.\n\\end{compactitem}\n\nThe remainder of the paper is structured as follows: The idea of a kinematic description using sets of reciprocal Euler angles is elaborated upon in Sec.\\,\\ref{sec:RecEulAng}.\nTheir application in inverse kinematics of 3T2R tasks and in resolving the functional redundancy is shown in Sec.\\,\\ref{sec:RecEulAng_3T2R_app} and \\ref{sec:ResFuncRed}.\nSec.\\,\\ref{sec:Conclusion} concludes the paper.\n\n\\section{Using Reciprocal Euler Angles for Robot Kinematics}\n\\label{sec:RecEulAng}\n\nThe core of solving the inverse kinematics problem of robot manipulators for tasks with only two rotational degrees of freedom is the nonlinearity of rotation.\nRotation can be described using rotation matrices, Euler angles, rotation angle/axis and its derivations like quaternions or the Rodrigues vector.\nIn contrast to all other notations, consecutive elementary rotations like Euler angles can be reduced to adapt for tasks only requiring two rotatory DoF.\n\n\\subsection{Kinematics Description}\n\\label{sec:RecEulAng_KinDesc}\n\nA serial kinematic chain is described with the joint positions $\\bm{q}$ and the forward kinematics\n\\vspace{-0.2em}\n%\n\\begin{equation}\n\\bm{x} (\\bm{q})\n=\n\\bm{f} (\\bm{q})\n\\label{equ:dirkin}\n\\end{equation}\n%\ngiving the configuration-dependent position and orientation $\\bm{x} (\\bm{q})$ of the actual end-effector (``E'') frame $\\ks{E}$.\nIn the following, the general, joint-independent, pose $\\bm{x}$ of the robot end-effector is defined as the \\emph{desired} (``D'') end-effector pose in the inverse kinematics problem and will be termed with ``$\\bm{x}$'' without further supplements for the sake of compactness of the equations.\nThis general pose\n%\n\\begin{equation}\n\\bm{x}\n=\n\\begin{bmatrix}\n\\bm{x}_{\\mathrm{t}}^\\transp & \\bm{x}_{\\mathrm{r}}^\\transp\n\\end{bmatrix}^\\transp\n\\in {\\mathbb{R}}^{6}\n\\label{equ:x_def}\n\\end{equation}\n%\ndescribes the desired robot end-effector frames $\\ks{D}$ position \n%\n\\begin{equation}\n\\bm{x}_{\\mathrm{t}}\n=\n\\ortvek{0}{r}{}{D}\n\\in {\\mathbb{R}}^{3}\n\\label{equ:xt_def}\n\\end{equation}  \n%\nand orientation \n%\\vspace{-0.5em}\n%\n\\begin{equation}\n\\rotmat{0}{D} (\\bm{x}_{\\mathrm{r}})\n=\n\\begin{bmatrix}\\vek{n}{}{D} & \\vek{o}{}{D} & \\vek{a}{}{D}\\end{bmatrix} \\in \\mathrm{SO(3)}\n\\label{equ:xr_def_rotmat}\n\\end{equation}\n%\nwith respect to the base frame $\\ks{0}$, which is marked with left subscript ``$(0)$'' for vectors and left superscript ``$0$'' for rotation matrices.\nThe rotation (\\ref{equ:xr_def_rotmat}) is expressed without loss of generality with a set $\\bm{\\beta}$ of $X$-$Y$-$Z$-Euler angles\n%\\footnote{Other sets of Euler angles may be used as well.}\n%\n\\begin{equation}\n\\bm{x}_{\\mathrm{r}}\n=\n\\begin{bmatrix}\n\\beta_1  & \\beta_2 & \\beta_3\n\\end{bmatrix}^{\\mathrm{T}}\n\\in {\\mathbb{R}}^{3},\n\\label{equ:xr_def}\n\\end{equation} \n%\n\\begin{equation}\n\\bm{R}(\\bm{\\beta}) = \\bm{R}_x(\\beta_1) \\bm{R}_y(\\beta_2) \\bm{R}_z(\\beta_3) \\in \\mathrm{SO(3)}.\n\\label{equ:def_rmat_xyz}\n\\end{equation}\n%\nThe deviation $\\bm{\\Phi}$ between the desired end-effector frame $\\ks{D}$ expressed with $\\bm{x}$ of (\\ref{equ:x_def}) and the actual robots end-effector frame $\\ks{E}$ expressed with $\\bm{f}(\\bm{q})$ of (\\ref{equ:dirkin}) is defined as\n%\\vspace{-0.5em}\n%\n\\begin{equation}\n\\bm{\\Phi}=\\begin{bmatrix}\n\\bm{\\Phi}_{\\mathrm{t}}^\\transp & \\bm{\\Phi}_{\\mathrm{r}}^\\transp\n\\end{bmatrix}^\\transp \\in {\\mathbb{R}}^{6},\n\\label{equ:Phi_def}\n\\end{equation}\n%\nwhich is the residual vector of the inverse kinematics problem.\nThe vector\n%\n\\begin{equation}\n\\bm{\\Phi}_{\\mathrm{t}}(\\bm{q},\\bm{x})\n=\n- \\ortvek{0}{r}{}{D} + \\ortvek{0}{r}{}{E}(\\bm{q})\n=\n- \\bm{x}_{\\mathrm{t}} + \\ortvek{0}{r}{}{E}(\\bm{q})\n \\in {\\mathbb{R}}^{3}\n\\label{equ:Phit_def}\n\\end{equation}\n%\nfrom the origins of $\\ks{D}$ to $\\ks{E}$ is the translational part and the rotational part\n%\n\\begin{align}\n\\bm{\\Phi}_{\\mathrm{r}}(\\bm{q},\\bm{x}) \n= \\begin{bmatrix}\n\\alpha_1  & \\alpha_2 & \\alpha_3\n\\end{bmatrix}^\\transp\n&=\\bm{\\alpha}\\left(\\rotmat{D}{E}(\\bm{x}_{\\mathrm{r}},\\bm{q})\\right)\\nonumber \\\\\n&=\\bm{\\alpha}\\left(\\rotmat{0}{D}^\\transp (\\bm{x}_{\\mathrm{r}})\\rotmat{0}{E}(\\bm{q})\\right) \\in {\\mathbb{R}}^{3}\n\\label{equ:Phir_def}\n\\end{align}\n%\nis also chosen as a set of Euler angles $\\bm{\\alpha}$ \\cite{GoldenbergBenFen1985}, that is calculated from the rotation matrix in (\\ref{equ:Phir_def}).\nIn the following, ``$\\bm{\\alpha}$'' will always refer to the rotation error/residual and ``$\\bm{\\beta}$'' to an orientation relative to the base frame.\nThe Euler angle convention of $\\bm{\\alpha}$ can be chosen independently of the choice for the orientation representation in  $\\bm{\\beta}$.\nThe intuitive approach of choosing\n%\n\\begin{equation}\n\\bm{R}(\\bm{\\alpha}^*) := \\bm{R}_x(\\alpha_1^*) \\bm{R}_y(\\alpha_2^*) \\bm{R}_z(\\alpha_3^*) \\in \\mathrm{SO(3)}\n\\label{equ:alpha_convention_xyz}\n\\end{equation}\n%\nthe same way as $\\bm{\\beta}$ leads to a set of transformations depicted in Fig.\\,\\ref{fig:frames_5dof_6dof}\\,(a) where the intermediate steps of the single elementary rotations are omitted since they have no technical meaning.\nThe upperscript in $\\bm{\\alpha}^*$ in (\\ref{equ:alpha_convention_xyz}) demarcates this specific example and following elaborations on the calculation of $\\bm{\\alpha}$.\n%\n\n\\subsection{Effect of the Reciprocal Euler Angles}\n\\label{sec:RecEulAng_effect}\n\n\n\\begin{figure}[htb]\n    \\input{./figures/frame_comparison_combined_5dof_6dof.pdf_tex}\n    \\caption{Overview of the different frames (a) for 6-dof tasks with standard Euler angle notation and (b) for 5-dof tasks with reciprocal Euler angle notation.}\n    \\label{fig:frames_5dof_6dof}\n\\end{figure} \n\n\nUsing $\\bm{\\Phi}_{\\mathrm{r}}{=}\\bm{\\alpha}^*$ as defined in (\\ref{equ:alpha_convention_xyz}), all three components of $\\bm{x}_{\\mathrm{r}}{=}\\bm{\\beta}$ affect the rotation matrix $\\rotmat{D}{E}$, which makes it impossible to remove one rotational coordinate from the kinematic description, even if it is not required in the task.\n%\nTo encounter this issue, the Euler angle convention $\\bm{\\alpha}$ for the orientation error $\\bm{\\Phi}_{\\mathrm{r}}$ is now chosen to be\n\\vspace{-0.1em}\n%\n\\begin{equation}\n\\bm{R}(\\bm{\\alpha}) := \\bm{R}_z(\\alpha_1) \\bm{R}_y(\\alpha_2) \\bm{R}_x(\\alpha_3) \\in \\mathrm{SO(3)}\n\\label{equ:def_rmat_zyxr}\n\\end{equation}\n%\ninstead of the definition from (\\ref{equ:alpha_convention_xyz}).\nThis set of $Z$-$Y$-$X$-Euler angles $\\bm{\\alpha}$ is defined in this paper as being \\emph{reciprocal} to the set of $X$-$Y$-$Z$-Euler angles of $\\bm{\\beta}$ for the absolute orientation.\n\nThe reciprocity refers to the switched order of the elementary axes $X$, $Y$ and $Z$ in the combination of the sets $\\bm{\\alpha}$ \\emph{and} $\\bm{\\beta}$.\nOne set of Euler angles alone can not be declared as reciprocal without reference to another set of angles.\n%\nSimilar to the six end-effector operational space coordinates $\\bm{x}$, the task space of 3T2R tasks is defined to have five coordinates\n%\n\\begin{equation}\n\\bm{\\eta}\n=\n\\begin{bmatrix}\n\\bm{\\eta}_{\\mathrm{t}}^\\transp & \n\\bm{\\eta}_{\\mathrm{r}}^\\transp\n\\end{bmatrix}^\\transp\n\\in {\\mathbb{R}}^{5}.\n\\end{equation}  \n%\nThe translational part\n%\\vspace{-0.5em}\n%\n\\begin{equation}\n\\bm{\\eta}_{\\mathrm{t}}\n=\n\\bm{x}_{\\mathrm{t}}\n=\n\\ortvek{0}{r}{}{D}\n\\in {\\mathbb{R}}^{3}\n\\end{equation}  \n%\nremains unchanged and the rotational part\n%\n\\begin{equation}\n\\bm{\\eta}_{\\mathrm{r}}\n=\n\\begin{bmatrix}\n\\beta_1  & \\beta_2\n\\end{bmatrix}^\\transp\n=\n\\underbrace{\\begin{bmatrix}\n1 & 0 & 0  \\\\ \n0 & 1 & 0\n\\end{bmatrix}}_{=\\bm{P}_{\\eta}}\n\\bm{x}_{\\mathrm{r}}\n\\in {\\mathbb{R}}^{2}\n\\label{equ:etar_def}\n\\end{equation}\n%\nis modified compared to $\\bm{x}$.\nThe last rotation $\\beta_3$ around the $z$-axis $\\bm{a}_{D}$ of $\\rotmat{0}{D}$ is excluded from the task space by the selection matrix $\\bm{P}_{\\eta}$, since it corresponds to a rotation around the tool axis in 3T2R tasks and is a DoF of the operational space which can be set arbitrarily (from the kinematic point of view).\n\nThe frames $\\ks{A1}$ and $\\ks{A2}$ result from intermediate elementary rotations, as sketched in Fig.\\,\\ref{fig:frames_5dof_6dof}\\,(b).\nThese intermediate frames are the partial frame rotation to the former 3T3R desired frame $\\ks{D}$\n%\n\\begin{equation}\n\\rotmat{0}{A1} \n= \n\\bm{R}_x(\\beta_1) \\bm{R}_y(\\beta_2)\n=\n\\begin{bmatrix}\n\\vek{n}{}{A1} & \\vek{o}{}{A1} & \\vek{a}{}{A1}\n\\end{bmatrix}\n\\end{equation}\n%\nand the partial frame rotation\n%\n\\begin{equation}\n\\rotmat{0}{A2} \n= \n\\rotmat{0}{E}(\\bm{q})\n\\left(\\bm{R}_y(\\alpha_2) \\bm{R}_x(\\alpha_3)\\right)^\\transp \n=\n\\begin{bmatrix}\n\\vek{n}{}{A2} & \\vek{o}{}{A2} & \\vek{a}{}{A2}\n\\end{bmatrix}\n\\end{equation}\n%\nfrom the actual frame and the $x$- and $y$-axis error components.\n%\nThe frames $\\ks{A1}$, $\\ks{A2}$ and $\\ks{D}$ all share the same $z$-axis\n%\n\\begin{equation}\n\\vek{a}{}{D}\n=\n\\vek{a}{}{A1}\n=\n\\vek{a}{}{A2}\n\\label{equ:z_axis_equal}\n\\end{equation}\n%\nwhich is also the tool axis, since transformations between these frames are only rotations $\\bm{R}_z$ around the $z$-axes from (\\ref{equ:z_axis_equal}).\n\\newpage\nSince the tool axis rotation $\\beta_3$ and the orientation error component $\\alpha_1$ are defined around the same axis, $\\beta_3$ only influences $\\alpha_1$ and not $\\alpha_2$ and $\\alpha_3$, which can be expressed by\n%\n\\begin{align}\n\\begin{bmatrix}\n\\alpha_1 \\\\\n\\alpha_2 \\\\\n\\alpha_3\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n\\alpha_1(\\bm{q},\\beta_1,\\beta_2,\\beta_3) \\\\\n\\alpha_2(\\bm{q},\\beta_1,\\beta_2) \\\\\n\\alpha_3(\\bm{q},\\beta_1,\\beta_2)\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n\\alpha_1(\\bm{q},\\bm{x}) \\\\\n\\alpha_2(\\bm{q},\\bm{\\eta}) \\\\\n\\alpha_3(\\bm{q},\\bm{\\eta}) \n\\end{bmatrix}\n\\label{equ:alpha_dep_beta}.\n\\end{align}\n%\nThis property of the reciprocal sets of Euler angles allows a kinematic description of robots in 3T2R tasks, as elaborated in the next sections.\nIt can be derived by symbolically comparing $\\bm{\\alpha}$ of (\\ref{equ:alpha_def_rotmat_zyx}) for two different desired rotations $\\bm{\\beta}$ which only differ regarding a rotation $\\beta_3$ around the tool axis.\n\n\\section{Application on the Inverse Kinematics of 3T2R Tasks}\n\\label{sec:RecEulAng_3T2R_app}\n\nThe standard methods, introduced in Sec.\\,\\ref{sec:Intro} for solving the inverse kinematics for 3T2R tasks and exploiting the functional redundancy, struggle with the definition of a Jacobian matrix with appropriate dimensions.\n\n\\subsection{Jacobian for Gradient-based Inverse Kinematics}\n\nTo obtain a Jacobian with minimal row dimension, the kinematic condition for the 3T2R problem in the coordinates $\\bm{\\eta}$ is now defined as\n%\n\\begin{equation}\n\\bm{\\Psi}=\\begin{bmatrix}\n\\bm{\\Psi}_{\\mathrm{t}}^\\transp & \\bm{\\Psi}_{\\mathrm{r}}^\\transp\n\\end{bmatrix}^\\transp \\in {\\mathbb{R}}^{5}\n\\end{equation}\n%\nfollowing the definition for $\\bm{\\Phi}$ from (\\ref{equ:Phi_def}).\nThe translational part\n%\n\\begin{equation}\n\\bm{\\Psi}_{\\mathrm{t}}(\\bm{q},\\bm{\\eta}) \n= \n\\bm{\\Phi}_{\\mathrm{t}}(\\bm{q},\\bm{x}) \n=\n- \\bm{\\eta}_{\\mathrm{t}} + \\ortvek{0}{r}{}{E}(\\bm{q}) \\in {\\mathbb{R}}^{3}\n\\end{equation}\n%\nremains unchanged to (\\ref{equ:Phit_def}).\nThe first component of the rotational part from (\\ref{equ:Phir_def}) is omitted by the selection matrix $\\bm{P}_{\\Psi}$, since it corresponds to the orientation error $\\alpha_1$ around the tool axis, leaving\n%\\vspace{-0.5em}\n%\n\\begin{equation}\n\\bm{\\Psi}_{\\mathrm{r}}(\\bm{q},\\bm{\\eta}) = \n\\begin{bmatrix}\n\\alpha_2  & \\alpha_3\n\\end{bmatrix}^\\transp\n=\n\\overbrace{\\begin{bmatrix}\n    0 & 1 & 0  \\\\ \n    0 & 0 & 1\n    \\end{bmatrix}}^{=\\bm{P}_{\\Psi}}\n \\bm{\\Phi}_{\\mathrm{r}} (\\bm{q},\\bm{x})\n \\in {\\mathbb{R}}^{2}.\n\\label{equ:Psir_def}\n\\end{equation}\n%\nThe dependence on $\\bm{\\eta}$ and not on $\\bm{x}$ can be explained by using (\\ref{equ:alpha_dep_beta}) and (\\ref{equ:etar_def}) together with $\\rotmat{A1}{A2}=\\bm{R}_z(\\beta_3+\\alpha_1)$ from Fig.\\,\\ref{fig:frames_5dof_6dof}\\,(b) which results to\n%\n\\begin{align}\n\\bm{\\Psi}_{\\mathrm{r}}(\\bm{q},\\bm{\\eta})\n&=\n\\bm{P}_{\\Psi} \\bm{\\alpha}\\left(\\rotmat{A2}{E}(\\bm{q},\\bm{\\eta}_{\\mathrm{r}},\\alpha_1,\\beta_3)\\right) \\nonumber\\\\\n&=\n\\bm{P}_{\\Psi} \\bm{\\alpha}\\left(\\rotmat{0}{A1}^\\transp (\\bm{\\eta}_{\\mathrm{r}})\\rotmat{0}{E}(\\bm{q})\\right).\n\\end{align}\n\nThe condition $\\bm{\\Phi}=\\bm{0}$ or $\\bm{\\Psi}=\\bm{0}$ leads to a valid configuration of the end-effector position and the complete orientation of the end-effector (using $\\bm{\\Phi}$) or the orientation only of the tool-axis (using $\\bm{\\Psi}$).\n\nFollowing \\cite{GoldenbergBenFen1985}, the inverse kinematics problem for serial link robots in 6-DoF tasks at the iterative step $k+1$ can be derived with the linear approximation of the Taylor series expansion of $\\bm{\\Phi}(\\bm{q},\\bm{x})$ to\n%\n\\begin{equation}\n\\bm{\\Phi}(\\bm{q}^{k+1},\\bm{x}) = \n\\bm{\\Phi}(\\bm{q}^{k},\\bm{x})\n+\n\\frac{\\partial}{\\partial \\bm{q}} \\bm{\\Phi}(\\bm{q},\\bm{x}) \\biggr\\rvert_{\\bm{q}^k} (\\bm{q}^{k+1} - \\bm{q}^k)\n\\label{equ:taylor_phi}\n\\end{equation}\n%\nwhere $\\bm{\\Phi}_{\\partial\\bm{q}}=(\\partial \\bm{\\Phi} / \\partial \\bm{q})$ is called the ``Jacobian matrix corresponding to the residual vector'' ($\\bm{\\Phi}$) in \\cite{GoldenbergBenFen1985} and $\\bm{q}^0$ is assumed as given.\n%\nFor 3T2R tasks\n%\n\\begin{equation}\n\\bm{\\Psi}(\\bm{q}^{k+1},\\bm{\\eta}) = \n\\bm{\\Psi}(\\bm{q}^{k},\\bm{\\eta})\n+\n\\frac{\\partial}{\\partial \\bm{q}} \\bm{\\Psi}(\\bm{q},\\bm{\\eta}) \\biggr\\rvert_{\\bm{q}^k} (\\bm{q}^{k+1} - \\bm{q}^k)\n\\label{equ:taylor_psi}\n\\end{equation}\n%\ncan be defined in the same way with the condition\n%\n\\begin{equation}\n\\bm{\\Psi}(\\bm{q}^{k+1},\\bm{\\eta})=\\bm{0}\n\\end{equation}\n%\nfor solution of the inverse kinematics in the next step $k+1$. The increment \n%\n\\begin{equation}\n\\Delta \\bm{q}^k\n=\n(\\bm{q}^{k+1} - \\bm{q}^k)\n=\n\\left(\\frac{\\partial \\bm{\\Psi}(\\bm{q},\\bm{\\eta})}{\\partial \\bm{q}}\\biggr\\rvert_{\\bm{q}^k}\\right)^{\\dagger}\n(\\bm{0} - \\bm{\\Psi}(\\bm{q}^{k},\\bm{\\eta}))\n\\label{equ:deltaq_psi}\n\\end{equation}\n%\nof the joint angles towards this solution can be used in iterative algorithms like Newton-Raphson together with methods to adapt the step sizes to ensure convergence.\nDepending on the dimension of the matrix, $(\\cdot)^\\dagger$ denotes the matrix inverse or the pseudo-inverse.\n\n\\subsection{Discussion of Singularities}\n\nIn \\cite{Zlajpah2017}, quaternions were used in favor of Euler angles for the orientation error with the reasons that a singularity-free representation of $\\bm{\\Phi}=\\bm{0}$ is needed.\nThis is the case for Tait-Bryan angles\\footnote{Tait-Bryan angles are referred to as $A$-$B$-$C$-Euler angles with axes $A \\ne C$ as opposed to ``proper Euler angles'' with $A = C$. The elementary axes are $A,B,C \\in \\{ X,Y,Z\\}$.} like e.\\,g. the $Z$-$Y$-$X$ notation used here for $\\bm{\\alpha}$.\nFor control purposes it can be assumed that the components of the orientation error $\\bm{\\alpha}$ always stay below $\\pm$90$^\\circ$, which avoids the ``gimbal lock'' representation singularity of Euler angles.\nThis assumption can be justified by the consideration that active and effective position and orientation tracking will only produce small errors.\nA singularity-free representation of the absolute orientation $\\bm{\\beta}$ has to be ensured at the phase of motion planning, as well as avoiding discontinuities of the trajectory.\n\n\\subsection{Remarks on Differentiation and Rotation Matrices}\n\\label{sec:RecEulAng_implement}\n\nThe Jacobians $\\bm{\\Phi}_{\\partial\\bm{q}}$ of (\\ref{equ:taylor_phi}) or $\\bm{\\Psi}_{\\partial\\bm{q}}$ of (\\ref{equ:taylor_psi}) consist of nested non-linear functions and do not use the geometric Jacobian of the serial link manipulator for the rotational part, which is easy to calculate. \n\nHowever, $\\bm{\\Phi}_{\\partial\\bm{q}}$ can be implemented efficiently by exploiting the chain rule and sparsity of the matrices with partial derivatives as shown in the following.\n\nThe column operator $\\overline{\\bm{R}}$ for rotation matrices $\\bm{R}$ to stack the coordinate systems unit vectors $\\bm{n},\\bm{o},\\bm{a} \\in {\\mathbb{R}}^{3}$ vertically instead of horizontally is defined as\n%\n\\begin{equation}\n\\overline{\\bm{R}}(\\bm{R})=\\begin{bmatrix}\n\\bm{n} \\\\ \\bm{o} \\\\ \\bm{a}\n\\end{bmatrix} \\in {\\mathbb{R}}^{9}\n\\quad\n\\mathrm{with}\n\\quad\n\\bm{R}=\\begin{bmatrix}\n\\bm{n} & \\bm{o} & \\bm{a}\n\\end{bmatrix}\n=\n\\begin{bmatrix}\n{n_x}&{o_x}&{a_x} \\\\\n{n_y}&{o_y}&{a_y} \\\\ \n{n_z}&{o_z}&{a_z} \\\\ \n\\end{bmatrix}\n \\in \\mathrm{SO}(3)\n\\label{equ:def_rotmat}\n\\end{equation}\n%\nto avoid differentiating matrices or w.r.t. matrices.\nMatrix multiplication is then expressed with the matrix product operator $\\overline{\\Pi}$\n%\nsuch that\n%\n\\begin{equation}\n\\rotmato{1}{3}\n=\n\\overline{\\prod}\\left( \\rotmato{1}{2}, \\rotmato{2}{3}\\right)\n=\n\\overline{\\bm{R}}(\\rotmat{1}{3})\n\\quad\n\\mathrm{with}\n\\quad\n\\rotmat{1}{3}\n=\n\\rotmat{1}{2}\n\\rotmat{2}{3}.\n\\label{equ:matprod}\n\\end{equation}\n%\nThe transposition operator $\\bm{P}_\\transp$ is a $9 \\times 9$ permutation matrix such that\n%\n\\begin{equation}\n\\rotmato{2}{1}\n=\n\\bm{P}_\\transp \\rotmato{1}{2}\n\\in {\\mathbb{R}}^{9}\n\\enspace\n\\mathrm{with}\n\\enspace\n\\rotmat{2}{1}\n=\n\\rotmat{1}{2}^\\transp\n\\in \\mathrm{SO}(3)\n\\enspace\n\\mathrm{and}\n\\enspace\n\\rotmato{1}{2}=\\overline{\\bm{R}}(\\rotmat{1}{2})\n.\n\\end{equation}\n%\nThe Euler angles can be calculated from the general rotation matrix $\\bm{R}$ of (\\ref{equ:def_rotmat}) in the same way as before\\footnote{Utilizing the sign-aware operator $\\arctantwo(y,x)$ instead of $\\arctan(y/x)$ allows angles to be in $(-\\pi,+\\pi]$, removes ambiguities and provides global differentiability.} using these operators with the notation\n%\n\\begin{equation}\n\\bm{\\alpha}(\\overline{\\bm{R}})\n=\n\\bm{\\alpha}(\\bm{R})\n=\n\\begin{bmatrix}\n\\arctantwo \\left( {n_y} , { n_x} \\right) \\\\ \n\\arctantwo \\left( -{n_z} , \\sqrt {{{a_z}}^{2}+{{ o_z}}^{2}} \\right) \\\\ \n\\arctantwo \\left( {o_z} , {a_z} \\right)\n\\end{bmatrix}\n\\label{equ:alpha_def_rotmat_zyx}\n\\end{equation}\n%\nat the $Z$-$Y$-$X$ example.\nFinally, applying this to the rotational part of the residual vector Jacobian and using the chain rule for differentiation yields\n%\n\\begin{align}\n\\frac{\\partial}{\\partial \\bm{q}}\\bm{\\Phi}_{\\mathrm{r}}\n&=\n\\frac{\\partial}{\\partial \\bm{q}} \\bm{\\alpha}\\left(\\rotmat{0}{D}^\\transp(\\bm{x}) \\rotmat{0}{E}(\\bm{q})\\right) \\label{equ:grad_Phi_q}\\\\\n&=\n\\frac{\\partial}{\\partial \\bm{q}} \\bm{\\alpha}\\left(\\overline{\\prod}\\left( \\rotmato{0}{D}^\\transp(\\bm{x}), \\rotmato{0}{E}(\\bm{q})\\right)\\right) \\nonumber \\\\\n&=\n%underbrace für Geschweifte Klammern drunter, vphantom nur für vertikale Größe des mittleren Terms\n\\underbrace{\\vphantom{\\left(\\frac{\\partial \\overline{\\prod}\\left(\\rotmato{0}{D}^\\transp, \\rotmato{0}{E}\\right)}{\\partial \\rotmato{0}{E}}\\right)}\\left(\\frac{\\partial \\bm{\\alpha}}{\\partial \\overline{\\bm{R}}}\\right)}_{\\mathrm{I} \\in {\\mathbb{R}}^{3 \\times 9}}\n\\underbrace{\\left(\\frac{\\partial \\overline{\\prod}\\left(\\rotmato{0}{D}^\\transp, \\rotmato{0}{E}\\right)}{\\partial \\rotmato{0}{E}}\\right)}_{\\mathrm{II} \\in {\\mathbb{R}}^{9 \\times 9}}\n\\underbrace{\\vphantom{\\left(\\frac{\\partial \\overline{\\prod}\\left(\\rotmato{0}{D}^\\transp, \\rotmato{0}{E}\\right)}{\\partial \\rotmato{0}{E}}\\right)}\\left(\\frac{\\partial \\rotmato{0}{E}(\\bm{q})}{\\partial \\bm{q}} \\right)}_{\\mathrm{III} \\in {\\mathbb{R}}^{9 \\times \\mathrm{dim}(\\bm{q})}}.  \\nonumber\n\\end{align}\n%\nThe first two partial derivatives ``I'' and ``II'' from (\\ref{equ:grad_Phi_q}) are sparse matrices of low complexity where the elements of $\\rotmat{D}{E}$ and $\\rotmat{0}{D}$ have to be inserted.\nThe last partial derivative ``III'' can be derived efficiently with computer algebra systems.\n\nThe translational part $\\bm{\\Phi}_{\\mathrm{t},\\partial\\bm{q}}=\\partial \\bm{\\Phi}_{\\mathrm{t}} / \\partial \\bm{q}=\\bm{\\Psi}_{\\mathrm{t},\\partial\\bm{q}}$ is enclosed in the geometric Jacobian of the manipulator and is not considered at this point to focus on the rotational aspects.\nThe gradient \n$\\bm{\\Psi}_{\\mathrm{r}, \\partial\\bm{q}}=\\partial \\bm{\\Psi}_{\\mathrm{r}} / \\partial \\bm{q}=\\bm{P}_{\\Psi}\\bm{\\Phi}_{\\mathrm{r},\\partial\\bm{q}}$\nis obtained from the results of (\\ref{equ:grad_Phi_q}) with the selection matrix $\\bm{P}_{\\Psi}$ from (\\ref{equ:Psir_def}).\n\nTo account for exchangeable end-effectors or tools, a distinguished frame rotation $\\rotmat{0}{N}(\\bm{q})$ to the last robot link frame and a constant frame rotation $\\rotmat{N}{E}$ to the end-effector frame can be used.\nThe properties of the column-operator allow then to substitute the last term ``III'' in (\\ref{equ:grad_Phi_q}) with\n%\n\\begin{align}\n\\frac{\\partial \\rotmato{0}{E}(\\bm{q})}{\\partial \\bm{q}} \n&=\n\\frac{\\partial}{\\partial \\bm{q}} \\overline{\\prod}\\left( \\rotmato{0}{N}(\\bm{q}), \\rotmato{N}{E}\\right) \\label{equ:ee_rotation_gradq}\\\\\n&=\n\\left(\\frac{\\partial}{\\partial \\rotmato{0}{N}} \\overline{\\prod}\\left( \\rotmato{0}{N}, \\rotmato{N}{E}\\right)\\right)\n\\left(\\frac{\\partial}{\\partial \\bm{q}} \\rotmato{0}{N}(\\bm{q})\\right). \\nonumber\n\\end{align}\n%\n%The gradient ``I'' in (\\ref{equ:ee_rotation_gradq}) matrix with linear entries where $\\rotmat{N}{E}$ can be inserted directly similar to ``II'' in (\\ref{equ:grad_Phi_q}).\n\n\\section{Resolving Functional Redundancy for 3T2R Tasks}\n\\label{sec:ResFuncRed}\n\n%with $\\mathrm{dim}(\\bm{\\Psi})=5$\n\nThe inverse kinematics formalism (\\ref{equ:deltaq_psi}), described in the previous section \\ref{sec:RecEulAng_3T2R_app}, does not take into account the functional redundancy yet.\n\nThe typical scenario for 3T2R tasks in industry is a serial link robot with $\\mathrm{dim}(\\bm{q})>5$.\nMost commonly a classical industrial robot with $\\mathrm{dim}(\\bm{q})=6$ will be used.\nSince $\\mathrm{dim}(\\bm{\\Psi})=5$, at least one DoF is free for optimization of additional criteria.\n\nFor the sake of simplicity, as an additional criterion the summed $\\bm{W}$-weighted quadratic distances\n\\vspace{-0.1em}\n%\n\\begin{equation}\nh(\\bm{q})\n=\n\\frac{1}{2} (\\bm{q}-\\bar{\\bm{q}})^\\transp\\bm{W}(\\bm{q}-\\bar{\\bm{q}})\n\\end{equation}  \n%\nof the joint positions $\\bm{q}$ from their respective reference position $\\bar{\\bm{q}}$ will be used.\nMinimizing $h(\\bm{q})$ avoids the risk of joints reaching their technical limits.\nThe gradient\n\\vspace{-0.1em}\n%\n\\begin{equation}\nh_{\\partial\\bm{q}}\n=\n\\frac{\\partial h}{\\partial \\bm{q}}\n=\n\\bm{W}(\\bm{q}-\\bar{\\bm{q}})\n\\end{equation}\n%\ncan be used to include this additional minimization into the solution of the inverse kinematics.\nThe gradient $h_{\\partial\\bm{q}}$ is projected into the nullspace of $\\bm{\\Psi}_{\\partial\\bm{q}}$ with\n\\vspace{-0.1em}\n%\n\\begin{align}\n{\\Delta}\\bm{q}\n&=\n{\\Delta}\\bm{q}_{\\mathrm{T}} + {\\Delta}\\bm{q}_{\\mathrm{N}} \\nonumber \\\\\n&=\n\\bm{\\Psi}_{\\partial\\bm{q}}^{\\dagger} (-\\bm{\\Psi}) +  (\\bm{1}-\\bm{\\Psi}_{\\partial\\bm{q}}^{\\dagger}\\bm{\\Psi}_{\\partial\\bm{q}}) h_{\\partial\\bm{q}}\n\\label{equ:nullspace}\n\\end{align}\n%\nwhere the nullspace incremental motion ${\\Delta}\\bm{q}_{\\mathrm{N}}$ does not affect the task achievement ensured via ${\\Delta}\\bm{q}_{\\mathrm{T}}$ \\cite{Yoshikawa1984}.\n\nIt is reported in \\cite{GuoDonKe2015} that their optimization does not work for industrial robots where the tool axis is aligned parallel to the last robot joint axis.\nThis ``pointing configuration'' can also not be addressed by the nullspace projection from (\\ref{equ:nullspace}), since the nullspace corresponds to the last robot axis and (in the case of a six-DoF robot)\n\\vspace{-0.1em}\n%\n\\begin{equation}\n\\bm{1}-\\bm{\\Psi}_{\\partial\\bm{q}}^{\\dagger}\\bm{\\Psi}_{\\partial\\bm{q}}\n=\n\\begin{bmatrix}\n\\bm{0}_{5 \\times 5} & \\bm{0}_{5 \\times 1} \\\\\n\\bm{0}_{1 \\times 5} & 1_{1 \\times 1}\n\\end{bmatrix}\n\\end{equation}\n%\nonly projects the gradient $h_{\\partial\\bm{q}}$ of additional criteria onto the last joint.\nTherefore, the method does only work if the tool is mounted in a different configuration (``side'' or ``hanging'' in \\cite{GuoDonKe2015}), which might be unfavorable for some end-effectors or tasks.\n\n\\section{Conclusions}\n\\label{sec:Conclusion}\n\\vspace{-0.2em}\nThis paper presented a novel concept to formulate the inverse kinematics problem of serial kinematic chains using reciprocal sets of Euler angles.\nThis exploits the properties of Euler angles to reduce the number of coordinates required for 3T2R tasks which are of high industrial relevance.\nApplications to the inverse kinematics of serial robots are given.\n%The detailed view on the practical implementation aims at facilitating the understanding of the approach and at reducing the barrier for potential users.\n%\nFuture works will include comparative simulative evaluation against state of the art methods, inquiries on singularities and the relation to the geometric Jacobian and the application to parallel robots.\n\n\\section*{Acknowledgements}\n\\vspace{-0.2em}\nThe financial support from the Deutsche Forschungsgemeinschaft (DFG) under grant number OR 196/33-1 is gracefully acknowledged.\n\\vspace{-0.2em}\n\n% BIBLIOGRAPHY\n\\bibliographystyle{spmpsci_unsrt}\n\\bibliography{ikfr_ref}\n\n\\end{document}\n", "meta": {"hexsha": "a0b970a3e83ec50d166f9d22b957b7b7b81e795d", "size": 33567, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/ikfr_paper.tex", "max_stars_repo_name": "SchapplM/robsynth-paper_iftommwc2019_invkinfuncred", "max_stars_repo_head_hexsha": "134745a19a920b524489740b332dc05741dd2cce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-08T15:20:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-08T15:20:29.000Z", "max_issues_repo_path": "paper/ikfr_paper.tex", "max_issues_repo_name": "SchapplM/robsynth-paper_iftommwc2019_invkinfuncred", "max_issues_repo_head_hexsha": "134745a19a920b524489740b332dc05741dd2cce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/ikfr_paper.tex", "max_forks_repo_name": "SchapplM/robsynth-paper_iftommwc2019_invkinfuncred", "max_forks_repo_head_hexsha": "134745a19a920b524489740b332dc05741dd2cce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.2284482759, "max_line_length": 518, "alphanum_fraction": 0.7255042154, "num_tokens": 10407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.40313661072772894}}
{"text": "\\chapter{Conclusion}\n\\label{chap:conclusion}\n\n% What we did and what others did\nWe have formalised multi-tape Turing machines in Coq.  We developed a framework for programming and proving correctness and time complexity of\nmulti-tape Turing machines.  We have demonstrated the power of this framework by implementing and verifying a multi-tape Turing machine that simulates\nan abstract machine.  This machine is a variation of the heap machine in Kunze et~al.~\\cite{KunzeEtAl:2018:Formal}.  The two variants differ in that\nprograms in our version are linearised lists of commands.  In~\\cite{KunzeEtAl:2018:Formal}, the authors show that their heap machines can simulate\nterms of the programming language $L$, which is a subset of the call-by-value $\\lambda$-calculus.  It should be easy to formalise the reduction from\nthe heap machine in~\\cite{KunzeEtAl:2018:Formal} to our version.  By that, we would formalise the reduction from the halting problem of $L$ to the\nhalting problem of multi-tape Turing machines.  This is, however, beyond the scope of this thesis.  It is an ongoing research\nproject~\\cite{ForsterLOLA2018}, to implement a Coq library of undecidability reductions, and this thesis provides one step towards this goal.  The\nreduction from the halting problem of single-tape Turing machines to the Post correspondence problem (PCP) has already been mechanised in Coq\nin~\\cite{forster2018verification}.\n\n\\paragraph{Differences to other mechanisations of Turing machines}\nWe build on Asperti and Ricciotti`s framework from~\\cite{asperti2015} inside the theorem prover Matita, and initially ported their definitions of\ntapes and Turing machines to Coq.  We find their inductive definition of tapes appealing, because of its symmetric and finite nature.  Because of the\nsymmetric nature of their definition of tapes, it was easy to define an operator $\\MS{Mirror}$ that mirrors the transition function of a machine.\nThis is in contrast to the implementation of tapes in~\\cite{xu2013}, where tapes are split into two halves, and the right half contains the current\nsymbol.  The finite nature made it possible to define an always terminating machine that moves the head to the right (or using $\\MS{Mirror}$ to the\nleft) end of the tape.  This is in contrast to~\\cite{ciaffaglione2016}, where tapes are implemented as infinite streams of symbols.  Our framework\nimplements five major improvements on~\\cite{asperti2015}.  (1) By introducing labelled machines we make it unnecessary to reason about concrete states\nof machines.  The authors in~\\cite{asperti2015} already note that reasoning about internal states is tedious and therefore do not include the\nterminating state in their definition of realisation.  However, they also need a separate definition of realisation that includes the terminating\nstate.  (2) We have introduced a notion of time complexity that relates the inputs to the number of steps needed for the computation.  (3) By\nintroducing an operator $\\Switch$ that generalises sequential composition and conditional, we simplified the verification of both operators and also\nintroduced a useful operator that was used throughout the thesis.  (4) We implemented general lifting operators that make it possible to compose small\nmachines (w.r.t.\\ the alphabet and number of tapes) to fairly complex machines.  At this point, composing compound machines is reasonably easy, but we\n(5) have introduced another layer of abstraction.  We have made it possible to directly manipulate values of encodable types.\n\n% Norrish`s comment about the \"daunting prospect\".\nIn~\\cite{norrish2011mechanised}, Norrish concludes that:\n\\begin{quote}\n  If register machines are unappealing because of their general fiddliness, Turing machines are an even more daunting prospect.\n\\end{quote}\nCertainly, Turing machines are not appealing.  We have spent considerable efforts (ca.\\ one year) to make programming and verifying Turing machines\nfeasible.  Interestingly, we ended up at a point, where programming and verifying Turing machines can be (in some sense) \\textit{easier} than for\nregister machines, because register machines are restricted to natural numbers.  The on-paper design, implementation and verification of the simulator\nwas finished in three weeks.\n\n\n\\paragraph{Duality of realisation and termination}\nWe noted that our concepts for correctness and time complexity are dual in a sense.  The (weak) notion of realisation says that \\textit{if} the\nmachine terminates, then the output is correct w.r.t.\\ a correctness relation $R$.  On the other side, a machine terminates in a termination relation\n$T$, if for all pairs of input tapes $t$ and step numbers $k$ that are in $T$, the machine terminates in $k$ steps given the input $t$.  Realisation\nis monotone (cf.\\ Lemma~\\ref{lem:Realise_monotone}), and termination is anti-monotone (cf.\\ Lemma~\\ref{lem:TerminatesIn_monotone}).  We find it\nremarkable that we use an inductive correctness relation for $\\MS{While}$ (cf.~Lemma~\\ref{lem:While_Realise}) and a co-inductive running time relation\n(cf.\\ Lemma~\\ref{lem:While_TerminatesIn}).\n\n\n\\paragraph{Similarity of realisation and Hoare logic}\nAs already noted in~\\cite{ciaffaglione2016}, the notion of realisation is similar to Hoare logic, that is widely used for program verification.  For\nexample, consider the Hoare proof rule for sequential composition and the corresponding relational rule (for unlabelled machines\n$M_1,M_2 : \\TM_\\Sigma^n$):\n\\[\n  \\inferrule{\\{A\\}~P_1~\\{B\\} \\and \\{B\\}~P_2~\\{C\\}}{\\{A\\}~P_1 \\Seq P_2~\\{C\\}}\n  \\qquad\n  \\inferrule{M_1 \\Realise R_1 \\and M_2 \\Realise R_2}{M_1 \\Seq M_2 \\Realise R_1 \\circ R_2}\n\\]\nSequential composition of machines amounts to relational composition of correctness relations (cf.\\ Lemma~\\ref{lem:Seq_RealiseIn}).  We encode\npreconditions and postconditions inside correctness relations.  This means that if the precondition does not hold for input tapes $t$, this implies\n$R~t~(l,t')$.  We are not aware of a Hoare-style calculus for reasoning about termination in a concrete number of steps related to the input, that is\ndual to Hoare logic, like in our duality between realisation and termination.\n\n\\paragraph{Problems of the framework}\nThe biggest problem of this framework is that encodability of types can be ambiguous.  For example, there are more than three ways how to encode\nnatural numbers on the alphabet of the heap machine simulator (cf.~Section~\\ref{sec:Lookup}).  We had to mentally keep track of in which encoding a\nvalue is encoded on a tape, and to translate values from one encoding to another.  The greatest part of the total compilation time (which is less then\n5~minutes) consists of rewriting tapes.  This could probably be further optimised.\n\n\n\\paragraph{Comparison of proof assistants}\nAsperti and Ricciotti~\\cite{asperti2015} propose the formalisation of Turing machines as a benchmark for comparing proof assistants.  We think that\nthe formalisation and usability of finite sets could be a benchmark for itself.  However, the task ``formalise Turing machines in proof assistant\n$X$'' is rather broad.  There are many mathematical formalisations of Turing machines, and some might be easier to implement in one or the other proof\nassistant.  For example, Isabelle does not support dependent types, so this concrete formalisation of Turing machines in this thesis would not be\npossible in Isabelle.  Dependent types are quite central in our formalisation of Turing machines.  For example, defining $\\Switch$ without them would\nprobably be considerable harder.\n\n\n\n\\paragraph{Future work}\n\n\\enlargethispage{0.5cm}\n\nWhen we defined the notion of value-containment (cf.~Section~\\ref{sec:value-containment}), we had future work in mind where we formalise space-usage\nof machines.  We were careful to avoid memory-leaks in the machines, but have not yet formalised this aspect of correctness.  We can strengthen the\ncorrectness relations with commitments about the space-usage of each tape.  Asperti and Ricciotti`s inductive definition of tapes is very helpful in\nthis regard, because their tapes never decrease the number of symbols.  This means that the total space usage of a tape is just the number of symbols\non the tape.  Our idea is that we parametrise the definition of value-containment over the length $l$ of the ``rest list'' on the left, and write\n$t \\simeq_{l} x$.  Note that, by definition, there are no symbols beyond the stop symbol on the right side of the tape, so the total size of the tape\nonly depends on the length of the encoding and the length of the left rest.  For example, $\\MS{CaseNat}$ does not change the amount of totally\nallocated symbols, but decreases the length of the encoding and increases the length of the rest by one.  On the other side, $\\MS{ConstrS}$\n``consumes'' one rest symbol, i.e.\\ it decreases the length of the rest by one and increases the length of the encoding by one.  Thus, if the rest is\nempty, $\\MS{ConstrS}$ allocates one new symbol.\n\n%\\newpage\n\nFurther future work could be to show that the running time function of the simulator is polynomial w.r.t.\\ the number of steps and the length of the\nencoding of the initial heap machine state, see~\\cite{ForsterLOLA2017}.  We could also formalise the reduction from multi-tape Turing machines to\nsingle-tape Turing machines, and from single-tape Turing machines to single-tape Turing machines with a binary alphabet.  The framework can be used to\nprogram other simulator machines, for example, for the ``naive'' substitution-based machine in~\\cite{KunzeEtAl:2018:Formal}.  We could implement a\nuniversal Turing machines as in~\\cite{asperti2015}, and formalise results of computationally and complexity theory, for example the undecidability of\nthe halting problem and Rice`s theorem.  The opposite reduction from multi-tape Turing machines to $L$, i.e.\\ programming an $L$ expression that\nsimulates multi-tape Turing machines, is also open for future work.  This should be a ``less daunting prospect'', because there is a framework for\nverified extraction of Coq terms to expressions of $L$, see~\\cite{forster2016verified}.\n\n\n%%% Local Variables:\n%%% TeX-master: \"thesis\"\n%%% End:\n", "meta": {"hexsha": "e01ab4c59315aa7a68ef32c0728c9bca53fae630", "size": 10163, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/thesis/Conclusion.tex", "max_stars_repo_name": "mwuttke97/CoqTM", "max_stars_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-08-30T14:58:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-27T15:44:28.000Z", "max_issues_repo_path": "tex/thesis/Conclusion.tex", "max_issues_repo_name": "mwuttke97/CoqTM", "max_issues_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-10T09:16:49.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-10T09:16:49.000Z", "max_forks_repo_path": "tex/thesis/Conclusion.tex", "max_forks_repo_name": "mwuttke97/CoqTM", "max_forks_repo_head_hexsha": "f4d2aab2008e2158e2c7ca88ebb53b42808a0778", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-04-09T19:01:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T15:39:53.000Z", "avg_line_length": 89.9380530973, "max_line_length": 150, "alphanum_fraction": 0.7910065925, "num_tokens": 2452, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.40313661072772894}}
{"text": "\\subsection{Motivation, Landscape and Current Problem}\n\n    As computer processor clock speeds have begun to stagnate in frequency increases per year, manufacturers have begun to shift focus to multiple cores in search of greater performance.\n    Supercomputers for decades have operated around the idea of clusters and massive parallelism.\n    As such, there is now more than ever a need to study the effects of parallelism in computation and to be able to effectively model concurrent communicating systems as they start to become commonplace in all computational applications.\n\n\n\\subsection{Scope and Relevance of Research}\n\n    The following aims to provide a visualisation of the parallel computation of multiple processes within the context of a concurrency calculus.\n    This will be divided into several modular parts that apart demonstrate some challenges on successful implementation, but together form what should prove to be a useful proof-of-concept tool to aid in understanding of calculi of communicating processes.\\\\\n\n    In particular, the project tackles the details of implementation of a computational calculus of communicating mobile processes.\n    This implementation is then further extended to provide an interactive visualisation of computations to aid in the understanding of how such calculi operate.\n    As discussed later in~\\ref{subsec:pi-calculus}, the project aims to provide an improvement over the $\\pi$-calculus described by~\\cite{pi-calculus}, while still remaining functionally equivalent and equally expressive.\n\n\n\\subsection{Project Aims}\n\n    The project seeks to provide an implementation of both the Solo Calculus described by~\\cite{solo-calculus}, for which there exists an encoding of the $\\pi$-calculus within itself, and also of Solo Diagrams described by~\\cite{solo-diagrams}, an intuitively graphical representation of the calculus.\n    These diagrams can then aid in understanding of reductions of process calculi, while maintaining a clean and simple language with strong, provable properties.\n    Furthermore, the design of the Solo Calculus is such that it is fully asynchronous.\n    That is, unlike in the $\\pi$-calculus where processes ‘block’ while waiting for inputs/outputs, it is shown through the construction of the Solo Calculus that no such system is required --- however there still exists a way of building such a system to give the effects of the $\\pi$-calculus should it be desired.\n    For these reasons, the Solo Calculus is found to be an interesting alternative to the more common $\\pi$-calculus.\n\n\n\\subsection{Overview of Dissertation Structure}\n\n    The first section details an in-depth review of the surrounding literature and current state of the art.\n    This includes an examination of various computational calculi, both concurrent and not, and an evaluation of their effectiveness for their given use-cases.\n    Included also are some short examples to give a feel of how each calculus is used.\\\\\n\n    Afterwards follows a short project requirements specification and investigation on technologies planned to be used in this project and justifications as to why each was chosen.\\\\\n\n    Following that is then a breakdown of the development process, description of some simple algorithms involved and the pitfalls which may not be immediately obvious.\n    This section attempts to show both the initial and final forms of the project and what difficulties caused this evolution.\\\\\n\n    Finally, there is a short conclusion on the effectiveness of the design choices made and how a similar project could be conducted differently.\\\\\n", "meta": {"hexsha": "52f79ed28caa3396fd880021ba08206951d62ccf", "size": 3609, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/dissertation/meta/introduction.tex", "max_stars_repo_name": "AdamLassiter/solo-calc", "max_stars_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/dissertation/meta/introduction.tex", "max_issues_repo_name": "AdamLassiter/solo-calc", "max_issues_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/dissertation/meta/introduction.tex", "max_forks_repo_name": "AdamLassiter/solo-calc", "max_forks_repo_head_hexsha": "89139f507b122566292cbf36e7eaa79726a96b9a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 92.5384615385, "max_line_length": 316, "alphanum_fraction": 0.8007758382, "num_tokens": 687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.40313660375702853}}
{"text": "\\section{Price response functions}\\label{sec:response_functions}\n\nIn Sect. \\ref{subsec:response_function_trade} we analyze the responses\nfunctions in trade time scale and in Sect.\n\\ref{subsec:response_function_physical} we analyze the responses functions in\nphysical time scale.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Response functions on trade time scale}\n\\label{subsec:response_function_trade}\n\nThe price response function in trade time scale is defined as\n\\cite{my_paper_response_financial}\n\\begin{equation}\\label{eq:response_functions_trade_scale_general}\n    R^{\\left(\\textrm{t}\\right)}_{i}\\left(\\tau\\right)=\\left\\langle\n    r^{\\left(\\textrm{t}\\right)}_{i}\\left(t-1,\\tau \\right)\n    \\varepsilon_{i}^{\\left(\\textrm{t}\\right)}\n    \\left(t, n\\right)\\right\\rangle _{T}.\n\\end{equation}\nTo compute the response functions on trade time scale, we use both, the trade\nsigns and the returns from the tick-by-tick original data during a week in\nmarket time. Then, the response is averaged by the number of trades.\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]\n    {figures/04_responses_trade_scale.png}\n    \\caption{Price response functions\n             $R^{\\left(\\textrm{t}\\right)}_{i}\\left(\\tau\\right)$ versus time\n             lag $\\tau$ on a logarithmic scale in trade time scale for the\n             years 2008 (top), 2014 (middle) and 2019 (bottom).}\n    \\label{fig:response_function_trade_scale}\n\\end{figure}\n\nThe results of Fig. \\ref{fig:response_function_trade_scale} show the\nprice response functions of the seven foreign exchange major pairs used in the\nanalysis (see Table \\ref{tab:majors}) for three different years. The results\nfound for all the years are entirely in line with price responses seen in other\nfinancial markets, particularly with correlated financial markets. The response\nfunctions have an initial increasing trend to a maximum, that flattens out and\nsaturates at some level, and eventually slowly decrease. This shape is\nexplained by an initial increase caused by autocorrelated transaction flow. The\nflattening out is due to the market liquidity adapting to this flow and\nassuring diffusive prices \\cite{EMH_lillo}. For our selected pairs, a time lag\nof $\\tau = 10^{3} $ trades is enough to see an increase to a maximum followed\nby a decrease. Thus, the trend in the price response functions is eventually\nreversed. The response signal is much more noisier in the year 2008 for the\nfirst seconds in the time lag. This behavior is because of the smaller amount\nof data of the corresponding year. In general, more data was recorded in recent\nyears than in past years. In the three years analyzed, the more liquid currency\npairs have a smaller response in comparison with the non-liquid pairs.  The\nstrength of the response function varies from one year to the other. In 2008\nthe strength of the signal was one order of magnitude stronger than the\nresponse in 2014, but the signals in 2014 have approximately twice the strength\nof the signals of 2019. This behavior can be explained by the fact that in\nrecent times algorithm trading has been used intensively. Thus, many more\ntrades were carried out in the last years, which means, the impact of each\ntrade is reduced, and then the response functions tend to decrease compared\nwith previous years.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Response functions on physical time scale}\n\\label{subsec:response_function_physical}\n\nOne important detail to compute the price response function on physical time\nscale is to define how the averaging of the function will be made, because the\nresponse functions highly differ when we include or exclude\n$\\varepsilon^{\\left(\\textrm{p}\\right)}_j \\left( t\\right) = 0$\n\\cite{Wang_2016_cross}. The price responses including\n$\\varepsilon^{\\left(\\textrm{p}\\right)}_j \\left( t\\right) = 0$ are weaker than\nthe excluding ones due to the omission of direct influence of the lack of\ntrades. However, either including or excluding\n$\\varepsilon^{\\left(\\textrm{p}\\right)}_j \\left( t\\right) = 0$ does not change\nthe trend of price reversion versus the time lag, but it does affect the\nresponse function strength \\cite{Wang_2016_avg}. For a deeper analysis of the\ninfluence of the term\n$\\varepsilon^{\\left(\\textrm{p}\\right)}_j \\left( t\\right) = 0$ in price response\nfunctions, we suggest reviewing Refs. \\cite{Wang_2016_avg,Wang_2016_cross}. We\nwill only take into account the price response functions excluding\n$\\varepsilon^{\\textrm{p}}_j \\left( t\\right) = 0$.\n\nWe define the price response functions on physical time scale, using\nthe trade signs and the returns sampled in seconds from the original data on\nphysical time scale. The price response function on physical time scale is\ndefined as \\cite{my_paper_response_financial}\n\\begin{equation}\\label{eq:response_functions_time_scale_general}\n    R^{\\left(\\textrm{p}\\right)}_{i}\\left(\\tau\\right)=\\left\\langle\n    r^{\\left(\\textrm{p}\\right)}_{i}\\left(t-1, \\tau\\right)\n    \\varepsilon_{i}^{\\left(\\textrm{p}\\right)} \\left(t\\right)\\right\\rangle _{P}\n\\end{equation}\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=\\columnwidth]\n    {figures/04_responses_physical_scale.png}\n    \\caption{Price response functions\n             $R^{\\left(\\textrm{p}\\right)}_{i}\\left(\\tau\\right)$ excluding\n             $\\varepsilon^{\\left(\\textrm{p}\\right)}_{i}\\left(t\\right) = 0$\n             versus time lag $\\tau$ on a logarithmic scale in physical time\n             scale for the years 2008 (top), 2014 (middle) and 2019 (bottom).}\n    \\label{fig:response_function_physical_scale}\n\\end{figure}\nThe results shown in Fig. \\ref{fig:response_function_physical_scale} are the\nprice response functions on physical time scale for three different years. The\nresults show approximately the same behavior observed in currency exchange\npairs in trade time scale, and in correlated financial markets, where we can\nsee that an increase to a maximum is followed by a decrease. Thus again, the\ntrend in the price responses is eventually reversed. An exception occurs in the\nyear 2008, where the response at short time lags seems to decrease, to then\nstart to slightly increase, and finally it decreases again.\n\nThe price response functions on physical time scale are smoother than the\nresponses on trade time scale. As we reduce from trade data all the returns and\ntrade signs in one second to one data point on physical time scale, and as this\nsampling gives the same weight to every data point, the curves look smoother.\n\nCompared with the response functions on trade time scale, the strength of the\nsignal of the response functions on physical time scale are similar in\nmagnitude in the corresponding years. Thus, the strength of the signal in 2008\nfor trade time scale is similar to the strength of the signal in 2008 for\nphysical time scale, and so on. This behavior is different from the one\npresented in correlated financial markets, where the results differ about a\nfactor of two depending on the time scale \\cite{my_paper_response_financial}.\n\nOn physical time scale, we can see that the liquid pairs have a smaller price\nresponse compared with non-liquid pairs. The liquidity of the pairs vary\nregarding the analyzed year. For the years 2008 and 2014, the most liquid pairs\nare the EUR/USD and the GBP/USD. For 2019 the most liquid pairs are EUR/USD and\nUSD/CAD. Therefore, the price response of a foreign exchange pair with large\nactivity is smaller to the small impact of each trade. Also, the former year\nresponses have stronger signals. We consider the same argument of algorithm\ntrading to explain why the signals in recent years are weaker than in older\nyears.\n", "meta": {"hexsha": "dc8515acf1d4eabeee854e83511c5e53b516c981", "size": 7743, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/forex_response_spread_paper/sections/07_response_functions.tex", "max_stars_repo_name": "juanhenao21/forex", "max_stars_repo_head_hexsha": "251ccccfc9a49f546db5e325ea6b594ff035d97f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-01T07:22:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-01T07:22:34.000Z", "max_issues_repo_path": "paper/forex_response_spread_paper/sections/07_response_functions.tex", "max_issues_repo_name": "juanhenao21/forex", "max_issues_repo_head_hexsha": "251ccccfc9a49f546db5e325ea6b594ff035d97f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2020-03-17T09:30:08.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-27T08:43:29.000Z", "max_forks_repo_path": "paper/forex_response_spread_paper/sections/07_response_functions.tex", "max_forks_repo_name": "juanhenao21/forex", "max_forks_repo_head_hexsha": "251ccccfc9a49f546db5e325ea6b594ff035d97f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.7835820896, "max_line_length": 79, "alphanum_fraction": 0.7601704766, "num_tokens": 1904, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.40304841490933746}}
{"text": "\n\\section{Introduction}\n\nThis section describes the problem that we tackle in this thesis (i.e., large-scale patterns prediction over multiple input event streams), followed by a brief overview of our proposed approach.\n\n%For later  an introdcution/motavation  section should be added here %\n\\subsection{Problem Formulation}\n%refine the stream and event pattern %\n%define the pattern we deal formally%\n% include base line 1 batch size in experemintal results%\n\nGiven a set of $K$ real-time streams of events $S = \\{ s_1,s_2, ..., s_k\\}$ as input, which are associated with a set of $K$  objects $O = \\{ o_1, ..., o_k\\}$. Where each stream $s_i=\\langle e_1,e_3...,e_t,...\\rangle$  is a time-ordered sequence of events, these events are connected to a single reference object $o_i \\in O$,  $e_t$  refers to the current time event within the unbounded stream, we give the definition of the input event sample as follows:  \n\\begin{definition}\nEach event is defined as a tuple of attributes $e_i = (type,\\tau,a_1,a_2.....,a_n,id)$:  where $type$ is the event type attribute that takes a value from a set of finite event types/symbols $\\Sigma$, $\\tau$ represents the timestamp of the event tuple,  the  $a_1,a_2,...,a_n$ are spatial or other contextual features (e.g., speed), these features are varying from one application to another, while the $id$ attribute connects the event tuple to the associated domain object.\n\\end{definition}\n\nA user-defined pattern $\\mathcal{P}$ is given in the form of a sequence of event types, while the main goal is to provide predictions about the full matches of $\\mathcal{P}$ within each event stream $s_i\\in S$ in real-time.\n \n\\par The setting that is considered in this thesis is described in the following:\\\\\n  A large-scale patterns prediction over multiple input event streams system that  consists of $K=\\left\\vert{S}\\right\\vert=\\left\\vert{O}\\right\\vert$ distributed predictor nodes $n_1,n_2...,n_k$, each of which consumes an input event stream $s_i\\in S$ and provide an online predication service. Each node $i \\in [K]$ consumes a single event stream $s_i$ associated with a single object $o_i \\in O$, in addition,  it  maintains a local prediction model $f_i$ for the user-defined pattern $\\mathcal{P}$. The online predictions about the full match of  the pattern $\\mathcal{P}$ in $s_i$ is provided for each new arriving event tuple, based on the current received event $ \\ e_t \\in s_i \\ $ and the observed previous events sequence $\\{e_j \\in s_i \\mid  j \\text{ <} t\\}$. In summary, we have multiple running instances of an online prediction algorithm on distributed nodes for multiple input event streams, each instance  provides online predications about a defined pattern of events. As an illustrative application domain, we consider massive event streams that describe trajectories of  moving objects, more specifically, event streams of moving vessels in the context of maritime surveillance.  As shown in Example \\ref{example:maritime}.\n  \n\\begin{example} %change it to example1 and sentances order%\n\tLet us consider a set of possible event types\n\t$$\\Sigma=\\{changeInSpeed,stopMoving,changeInTurn\\}$$\nAnd an example of event tuple structure that describes trajectory of a moving vessel \n$$e_i=(vesselId,type,timestamp,longitude,latitude,speed)$$ such that $type \\in \\Sigma$   \n. Hence, we can define a pattern $\\mathcal{P_j}$ that represents speed change followed by change in turn:  $$P_j=changeInSpeed.changeInTurn$$\n\\label{example:maritime} \n\\end{example}\nThe defined pattern $\\mathcal{P_j}$ is monitored over each event stream $s_i$  by a  predictor nodes  $n_i$  that maintains a local prediction model $f_i$, where there is one node for each vessel's event stream.  The prediction model $f_i$ gives the ability to provide an online predictions about when the pattern will be completed in the form of an expected number of future events before a full match does occur.\n \n \\subsection{The Proposed Approach}\n \\par We aim to design and develop a scalable and distributed patterns prediction system over massive input event streams (e.g., event streams of moving objects). We  exploit the event forecasting with Pattern Markov Chains \\cite{alevizos2017event} as the base prediction model (i.e., $f_i$). We propose to enable the dynamic merge of the prediction models of the input event streams, by adapting the distributed online predication protocol \\cite{kamp2014communication} to synchronize the distributed  models, i.e., Markov transitions probabilities of the Pattern Markov Chain (PMC) predictors.\n \n \\par We propose a $synchronization operation$  for the distributed Pattern Markov Chain (PMC) models based on the maximum-likelihood estimation \\citep{anderson1957statistical} for the transition probabilities matrix of the underlaying Markov Chain described by \n \\begin{equation}\n \\label{eq:pi_estim}\n \\hat{p}_{i,j}=\\frac{\\sum_{k \\in K} n_{k,i,j}}{\\sum_{k \\in K} \\sum_{l \\in L} n_{k,i,l}}\n \\end{equation}\n  \n  \n \\par Our approach relies on enabling the collaborative learning between the prediction models of  the input event streams. By doing so, we assume that the underlying event streams belong to the same  distribution and share the same behavior (e.g., mobility patterns). We claim that assumption is reasonable in many application domains, for instance, in the context of maritime surveillance, vessels travel through defined routes by International Maritime Organization (IMO). Additionally, vessels have similar mobility patterns in specific areas such as moving with low speed and multiple turns near the ports \\cite{pallotta2013vessel,liu2014knowledge}. That allows our system to dynamically construct a coherent global prediction model for all input event streams based on merging its local models. %We will empirically investigate the effect of enabling the distributed online learning over % \n \n  \\par Our proposed approach is expected to impose a speed up in the learning of the prediction models with less training data, in addition, we expect to gain an improvement of the predictive performance compared to the no-distributed  version of event forecasting with Pattern Markov Chains system. \n  %Also it is adaptive to the non-stationary data streams that shows a concept drift by the continuously adjusting the predictions models based on the change of input event stream characteristics (i.e., by the continuous clustering integration with distribute online learning).%\n \n %An outline of our approach is given in $Algorithm$ ~\\ref{alg:our_approach}. \n\n\n%\\begin{algorithm}[h!]\n\n%\t\\caption{Our Approach}\n%\tcheck figure 4 in \\cite{lee2007trajectory}\n%\t\\label{alg:our_approach}\n%\\end{algorithm} \n% add algorthim table describes the whole approach.\n\n% In thesis, we will also consider another research direction concerning the extension of forecasting Markov chain to  higher order by including additional contextual features of the event such as  weather conditions of moving entities. We will empirically evaluate the effect of this extension over the prediction quality. \n%\n\n% pattern defination as sequence or regex of the events types of the input stream\n% group of moving objects \n% adding illistruating figure ", "meta": {"hexsha": "9cc785bba4cb7f4cd0b0d8742241192f41ce968e", "size": 7187, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "presentation2/introduction.tex", "max_stars_repo_name": "ehabqadah/thesis", "max_stars_repo_head_hexsha": "6131d734f4cc48746575221370669da14de5024b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-07-08T03:38:16.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-08T03:38:16.000Z", "max_issues_repo_path": "presentation2/introduction.tex", "max_issues_repo_name": "wsgan001/thesis-8", "max_issues_repo_head_hexsha": "6131d734f4cc48746575221370669da14de5024b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentation2/introduction.tex", "max_forks_repo_name": "wsgan001/thesis-8", "max_forks_repo_head_hexsha": "6131d734f4cc48746575221370669da14de5024b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-09-25T22:44:17.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-25T22:44:17.000Z", "avg_line_length": 114.0793650794, "max_line_length": 1239, "alphanum_fraction": 0.7791846389, "num_tokens": 1664, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4030484071200499}}
{"text": "\\chapter{An Example \\simplesine Simulation}\n\\label{sec:simplesine-sim}\n\nIn the following chapters,\nwe use the \\simplesine model extensively as part of simulations\nto illustrate \\TrickHLA\\ in action.\nIn this chapter, we introduce a non-HLA \\simplesine simulation\nas a way to explain the basics of how the model may be used with Trick,\nand we do so without any \\TrickHLA\\ distractions.\n\n% ----------\n\\section{\\tt SIM\\_simplesine\\_pubsub}\n\nIn this simulation, there are two {\\tt sim\\_object}s:\na {\\em publisher} and a {\\em subscriber}.\\footnote{\nThis publisher/subscriber terminology here is only suggestive.\nThere is no distributed computing going on.\nData only moves from one {\\tt sim\\_object} to another within a single process.\nNevertheless, the simulation is a fair way to introduce how \\simplesine\ndata structure and functions are used in Trick \\sdefine and input files.\n}\nThe publisher generates a sine wave using the analytic equations\nand periodically copies the state to the subscriber.\nThe subscriber propagates the state approximately between updates from\nthe publisher.\nBased on the analytic equations, the subscriber also calculates an error\nin the approximate propagation.\n\nThe motivation for having the publisher and subscriber propagate the state\ndifferently is to illustrate a technique that is useful for HLA simulations.\nThe owner of some data might simulate it at a very high rate but\nsend updates at a lower frequency.\nIn between these updates, a subscriber may use an approximate method to\nextrapolate the data until the next update arrives.\\footnote{\n  Extrapolation alternatives include doing nothing, in which case the\n  data increments in discontinuous steps as the remote data arrive;\n  dead reckoning, in which the data are extrapolated based on derivatives;\n  or numerical integration of an approximate (lower fidelity) model, in\n  which case the discontinuities on the subscriber side are hopefully\n  reduced sufficiently to allow the subscriber's simulation to proceed.\n}\n% ----------\n\\section{\\sdefine}\n\\label{sec:simplesine-pubsub-sdefine}\n\nThe {\\tt SIM\\_simplesine\\_pubsub} \\sdefine file is shown below. It consists of\n\n\\begin{itemize}\n  \\item{\n    Some {\\tt \\#define} statements that set relevant frequencies for\n    state propagation and data copying.\n  }\n  \\item{\n    The {\\tt sim\\_object}s -- the usual Trick {\\tt sys} object and\n    publisher and subscriber objects.\n  }\n  \\item{\n    An {\\tt integrate} statement which enables Trick numerical integration\n    for the subscriber.\n  }\n\\end{itemize}\n\n\\begin{lstlisting}[caption={{\\tt SIM\\_simplesine\\_pubsub} \\sdefine file},label={list:SIM-pubsub-sdefine}]\n#define PROPAGATE_TIMESTEP 0.25\n#define COPY_TIMESTEP 5.0\n\nsim_object\n{\n  sim_services/include: EXECUTIVE exec (sim_services/include/executive.d) ;\n\n  (automatic) sim_services/input_processor:\n    input_processor( INPUT_PROCESSOR* IP = &sys.exec.ip ) ;\n} sys ;\n\n\nsim_object\n{\n  simplesine: simplesine_T simplesine (simplesine/data/simplesine.d);\n\n  (initialization) simplesine:\n    simplesine_calc(\n      simplesine_T* P = &publisher.simplesine,\n      double t = sys.exec.out.time );\n\n  // Propagate the state using the analytic equations.\n  (PROPAGATE_TIMESTEP, scheduled) simplesine:\n    simplesine_calc(\n      simplesine_T* P = &publisher.simplesine,\n      double t = sys.exec.out.time );\n\n  // Copy the propagated state to the subscriber.\n  (COPY_TIMESTEP, scheduled) simplesine:\n    simplesine_copyState(\n      simplesine_state_T* fromP = &publisher.simplesine.state,\n      simplesine_state_T* toP = &subscriber.simplesine.state );\n} publisher ;\n\n\nsim_object\n{\n  sim_services/include: INTEGRATOR integ (simplesine/data/integ.d);\n  simplesine: simplesine_T simplesine (simplesine/data/simplesine.d);\n  simplesine: simplesine_T err (simplesine/data/simplesine.d);\n\n  (initialization) simplesine:\n    simplesine_calc(\n      simplesine_T* P = &subscriber.simplesine,\n      double t = sys.exec.out.time );\n\n  // deriv/integ jobs to propagate the state differential equation\n  (derivative) simplesine:\n    simplesine_deriv( simplesine_T* p = &subscriber.simplesine );\n  (integration) simplesine:\n    simplesine_integ(\n      INTEGRATOR* I = &subscriber.integ,\n      simplesine_T* p = &subscriber.simplesine );\n\n  // calculate the error between the integrated state and the true state\n  (PROPAGATE_TIMESTEP, scheduled) simplesine:\n    simplesine_calcError(\n      double t = sys.exec.out.time,\n      simplesine_T* s = &subscriber.simplesine,\n      simplesine_state_T* err = &subscriber.err.state );\n} subscriber ;\n\nintegrate (PROPAGATE_TIMESTEP) subscriber;\n\\end{lstlisting}\n% ----------\n\\section{Input Files}\n\nThe input files for this simulation are located in the {\\tt RUN\\_1} directory\nand are summarized below.\n\n\\begin{itemize}\n\\item{\n  {\\tt input\\_noCopy\\_noInteg}.\n  In this input file,\n  the publisher never sends data to the subscriber, and\n  the subscriber does not propagate its local state.\n  The motivation here is to illustrate that nothing really happens\n  on the subscriber side until the publisher sends data.\n}\n\\item{\n  {\\tt input\\_noInteg}.\n  This input file illustrates the arrival of data at the subscriber from\n  the publisher.\n  By not propagating the subscriber state, the discrete arrival of\n  updates is readily evident.\n  In some simulations in the subsequent chapter,\n  we will use this technique to illustrate the arrival of HLA data.\n}\n\\item{\n  {\\tt input}.\n  This file illustrates the simulation running as it is intended:\n  the publisher sends data periodically to the subscriber,\n  and the subscriber integrates those data in between updates.\n  In this case the harmonical oscillator is so simple that the numerical\n  integration is a very good approximation to the true system.\n}\n\\end{itemize}\n\nThe first two files illustrate how to disable specific Trick jobs from\nthe input file using the {\\tt JOB} directive.\nIn {\\tt input\\_noCopy\\_noInteg}, the publisher's\npublisher-to-subscriber copy job is disabled\nas well as the subscriber's numerical integration jobs.\nIn {\\tt input\\_noInteg}, the subscriber's numerical integration jobs are\ndisabled.\nThe input files are shown below.\n\n\n\\begin{lstlisting}[caption={{\\tt SIM\\_simplesine\\_pubsub} input file, {\\tt input\\_noCopy\\_noInteg}},label={list:SIM-pubsub-input-noCopy-noInteg}]\n#include \"S_default.dat\"\n#include \"Log_data/states.d\"\n#include \"Modified_data/realtime.d\"\n#include \"Modified_data/publisher.d\"\n#include \"Modified_data/subscriber.d\"\n\nJOB publisher.simplesine_copyState(&publisher.simplesine) = Off;\n\nJOB subscriber.simplesine_deriv(&subscriber.simplesine) = Off;\nJOB subscriber.simplesine_integ(&subscriber.integ) = Off;\n\nstop = 32.5;\n\\end{lstlisting}\n\n\\begin{lstlisting}[caption={{\\tt SIM\\_simplesine\\_pubsub} input file, {\\tt input\\_noInteg}},label={list:SIM-pubsub-input-noInteg}]\n#include \"S_default.dat\"\n#include \"Log_data/states.d\"\n#include \"Modified_data/realtime.d\"\n#include \"Modified_data/publisher.d\"\n#include \"Modified_data/subscriber.d\"\n\nJOB publisher.simplesine_copyState(&publisher.simplesine) = Off;\n\nstop = 32.5;\n\\end{lstlisting}\n\n\\begin{lstlisting}[caption={{\\tt SIM\\_simplesine\\_pubsub} input file, {\\tt input}},label={list:SIM-pubsub-input}]\n#include \"S_default.dat\"\n#include \"Log_data/states.d\"\n#include \"Modified_data/realtime.d\"\n#include \"Modified_data/publisher.d\"\n#include \"Modified_data/subscriber.d\"\n\nstop = 32.5;\n\\end{lstlisting}\n\n% ----------\n\\section{Output}\n\nOutput from the simulation with {\\tt input\\_noCopy\\_noInteg}\nis shown in Figure~\\ref{fig:SIM-pubsub-input-noCopy-noInteg}.\nThe plot shows the evolution of the sine wave for approximately\nten cycles.\nThe publisher state ($x(t)$ and $\\dot{x}(t)$) evolve as expected.\nThe subscriber state is flatlined at its initial conditions,\nsince data never arrive from the publisher and the subscriber's\nnumerical propagation is disabled.\n\n\\begin{figure}[b]\n  \\begin{center}\n    \\includegraphics[width=4.5in]{TrickHLAUser-prelim-SIM-pubsub-input-noCopy-noInteg.png}\n  \\end{center}\n\\caption{Output from {\\tt SIM\\_simplesine\\_pubsub} using input file {\\tt input\\_noCopy\\_noInteg}}\n\\label{fig:SIM-pubsub-input-noCopy-noInteg}\n\\end{figure}\n\n\nOutput from the simulation with {\\tt input\\_noInteg}\nis shown in Figure~\\ref{fig:SIM-pubsub-input-noInteg}.\nIt clearly shows the discrete transfer of data from the publisher to the\nsubscriber.\nBetween the data updates, the subscriber state remains constant,\nsince there is still no numerical intregration on the subscriber side.\nThis manifests itself in errors which grow significantly until the next\nupdate arrives, at which point the errors reset to zero.\n\n\\begin{figure}[b]\n  \\begin{center}\n    \\includegraphics[width=4.5in]{TrickHLAUser-prelim-SIM-pubsub-input-noInteg.png}\n  \\end{center}\n\\caption{Output from {\\tt SIM\\_simplesine\\_pubsub} using input file {\\tt input\\_noInteg}}\n\\label{fig:SIM-pubsub-input-noInteg}\n\\end{figure}\n\n\nOutput from the simulation with {\\tt input}\nis shown in Figure~\\ref{fig:SIM-pubsub-input}.\nIn this case, the subscriber state is ``smoothed'' in between data updates,\nsince the subscriber numerical integration has been enabled.\nNote that there are still errors which grow between updates;\nhowever, in this case the magnitude of those error has diminished by several\norders of magnitude.\n\n\\begin{figure}[b]\n  \\begin{center}\n    \\includegraphics[width=4.5in]{TrickHLAUser-prelim-SIM-pubsub-input.png}\n  \\end{center}\n\\caption{Output from {\\tt SIM\\_simplesine\\_pubsub} using input file {\\tt input}}\n\\label{fig:SIM-pubsub-input}\n\\end{figure}\n\n%\n% print the figures before moving to the next chapter\n%\n\\clearpage\n", "meta": {"hexsha": "8961f3de03e68aefe217cb5b7bb1eddc46a59a38", "size": 9583, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/TrickHLA/LaTeX/TrickHLAUser-SimplesineSimChapter.tex", "max_stars_repo_name": "jiajlin/TrickHLA", "max_stars_repo_head_hexsha": "ae704b97049579e997593ae6d8dd016010b8fa1e", "max_stars_repo_licenses": ["NASA-1.3"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2020-03-04T14:23:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T10:47:21.000Z", "max_issues_repo_path": "docs/TrickHLA/LaTeX/TrickHLAUser-SimplesineSimChapter.tex", "max_issues_repo_name": "jiajlin/TrickHLA", "max_issues_repo_head_hexsha": "ae704b97049579e997593ae6d8dd016010b8fa1e", "max_issues_repo_licenses": ["NASA-1.3"], "max_issues_count": 57, "max_issues_repo_issues_event_min_datetime": "2020-06-04T16:03:44.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-17T20:54:35.000Z", "max_forks_repo_path": "docs/TrickHLA/LaTeX/TrickHLAUser-SimplesineSimChapter.tex", "max_forks_repo_name": "jiajlin/TrickHLA", "max_forks_repo_head_hexsha": "ae704b97049579e997593ae6d8dd016010b8fa1e", "max_forks_repo_licenses": ["NASA-1.3"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2020-08-25T05:51:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-01T18:37:38.000Z", "avg_line_length": 35.7574626866, "max_line_length": 145, "alphanum_fraction": 0.7653135761, "num_tokens": 2394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.403045663213054}}
{"text": "\\newpage\\section{Data | Empirical results}\\label{sec:results}\n\n\\subsection{Subsection}\n\nSome citation: \\citet{Bowman:1997}.\n\nA table:\n\\begin{table}[H]\n\t\\begin{center}\n\t\t\\begin{tabular}{l|rrrr||rr}\\hline\\hline\n\t\t\t&\\multicolumn{4}{c}{L\\'evy}&\\multicolumn{2}{c}{Gaussian} \\\\\n\t\t\t\\hline\n\t\t\t& $b_0$ & $b_1$ & $a_1$ & $a_2$ & $a_1$ & $a_2$\\\\\n\t\t\t\\hline\n\t\t\tEstimate & 1.000 & 74.268 & $-0.192$ &  0.638& $0.686$ &  $-0.154$\\\\\n\t\t\tStd. error & 10.158 & 0.288 & 0.204 & 0.604 & 0.021 &  0.025\\\\\n\t\t\t\\hline\\hline\n\t\t\\end{tabular}\n\t\t\\caption{CARMA(2,1) Coefficient estimates of the CARMA-L\\'{e}vy process), CARMA(2,0) of the Gaussian process} %\\label{tab:CARMAcoef}\n\t\\end{center}\n\\end{table}\n\n\n\n\\subsection{More subsections}\nLink/refer to figures: Figure \\ref{fig:DRP}.\n\nMore citation: \\cite{Weron:2008}", "meta": {"hexsha": "4fad10e5c2a7c64af4ad050bab54551610a3a70a", "size": 787, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Template/ch04.tex", "max_stars_repo_name": "awdesch/Topics_in_Finance", "max_stars_repo_head_hexsha": "aa3e353f2ac506f8122fbce6a4c001c63fd0c46f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Template/ch04.tex", "max_issues_repo_name": "awdesch/Topics_in_Finance", "max_issues_repo_head_hexsha": "aa3e353f2ac506f8122fbce6a4c001c63fd0c46f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Template/ch04.tex", "max_forks_repo_name": "awdesch/Topics_in_Finance", "max_forks_repo_head_hexsha": "aa3e353f2ac506f8122fbce6a4c001c63fd0c46f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1071428571, "max_line_length": 134, "alphanum_fraction": 0.6404066074, "num_tokens": 350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.40304564567922785}}
{"text": "\\documentclass[epsfig,10pt,fullpage]{article}\n\n\\newcommand{\\LabNum}{9}\n\\newcommand{\\CommonDocsPath}{../../../common/docs}\n\\input{\\CommonDocsPath/preamble.tex}\n\n\\begin{document}\n\n\\centerline{\\huge Digital Logic}\n~\\\\\n\\centerline{\\huge Laboratory Exercise \\LabNum}\n~\\\\\n\\centerline{\\large A Simple Processor}\n~\\\\\n\nFigure~\\ref{fig:fig1} shows a digital system that contains a number of 16-bit registers,\na multiplexer, an adder/subtracter, and a control unit (finite state machine).  Information\nis input to this system via the 16-bit {\\it DIN} input, which is loaded into the {\\it IR} \nregister. Data can be transferred through the 16-bit wide multiplexer from one register\nin the system to another, such as from register {\\it IR} into one of the {\\it general \npurpose} registers $r0, \\ldots, r7$.  The multiplexer's output is called {\\it Buswires} \nin the figure because the term {\\it bus} is often used for wiring that allows data to be \ntransferred from one location in a system to another. The FSM controls the {\\it Select} \nlines of the multiplexer, which allows any of its inputs to be transferred to any register\nthat is connected to the bus wires.\n\n~\\\\\nThe system can perform different operations in each clock cycle, as governed by the FSM. \nIt determines when particular data is placed onto the bus wires and controls which of the \nregisters is to be loaded with this data. For example, if the FSM selects $r0$ as the output of the \nbus multiplexer and also asserts $A_{in}$, then the contents of register $r0$ will be loaded on the \nnext active clock edge into register {\\it A}.\n\n~\\\\\nAddition or subtraction of signed numbers is performed by using the multiplexer to first \nplace one 16-bit number onto the bus wires, and then loading this number into register {\\it A}. \nOnce this is done, a second 16-bit number is placed onto the bus, the adder/subtracter\nperforms the required operation, and the result is loaded into register {\\it G}. The\ndata in {\\it G} can then be transferred via the multiplexer to one of the other registers,\nas required.\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale = 0.8]{figures/figure1.pdf}\n\t\\end{center}\n\t\\caption{A digital system.}\n\t\\label{fig:fig1}\n\\end{figure}\n\n\\newpage\n\\noindent\nA system like the one in Figure~\\ref{fig:fig1} is often called a {\\it processor}. It \nexecutes operations specified in the \nform of {\\it instructions}. Table~\\ref{tab:instructions} lists the instructions that this \nprocessor supports. The left column shows the name of an instruction and its operands. \nThe meaning of the syntax {\\it rX} $\\leftarrow$ {\\it Op2} is that the second operand,\n{\\it Op2}, is loaded into register {\\it rX}. The operand {\\it Op2} can be either a\nregister, {\\it rY}, or {\\it immediate data}, \\#{\\it D}.\n\n\\begin{table}[H]\n\\begin{center}\n\\begin{tabular}{rl|c}\n   \\multicolumn{2}{c|}{Instruction} & Function performed \\\\ \\hline \n   \\rule[0.01in]{0in}{0.15in}{\\it mv} & {\\it rX}, $Op2$ & {\\it rX} $\\leftarrow Op2$ \\\\ \n\t\t  \\rule[-0.075in]{0in}{0.2in}{\\it mvt} & {\\it rX,} \\#{\\it D} & {\\it rX$_{15-8}$} $\\leftarrow$ {\\it D$_{15-8}$}\\\\ \n   \\rule[-0.075in]{0in}{0.2in}{\\it add} & {\\it rX}, $Op2$ & {\\it rX} $\\leftarrow$ {\\it rX} + $Op2$ \\\\ \n   \\rule[-0.075in]{0in}{0.2in}{\\it sub} & {\\it rX}, $Op2$ & {\\it rX} $\\leftarrow$ {\\it rX} $-$ $Op2$ \\\\ \n\\end{tabular}\n\\caption{Instructions performed in the processor.}\n\\label{tab:instructions}\n\\end{center}\n\\end{table}\n\n\\noindent\nInstructions are loaded from the external input {\\it DIN}, and stored into the {\\it IR} register, \nusing the connection indicated in Figure~\\ref{fig:fig1}. Each instruction is {\\it encoded} using \na 16-bit format. If $Op2$ specifies a register, then the instruction encoding is \n\\texttt{III0XXX000000YYY}, where \\texttt{III} specifies the instruction, \\texttt{XXX} gives \nthe {\\it rX} register, and \\texttt{YYY} gives the {\\it rY} register. If $Op2$ specifies \nimmediate data \\#{\\it D}, then the encoding is \n\\texttt{III1XXXDDDDDDDDD}, where the 9-bit field \\texttt{DDDDDDDDD} represents the constant data.\nAlthough only two bits are needed to encode our four instructions, we are using three bits because \nother instructions will be added to the processor later. Assume that \\texttt{III} $= 000$ for\nthe {\\it mv} instruction, $001$ for {\\it mvt}, $010$ for {\\it add}, and $011$ for {\\it sub}. \n\n~\\\\\nThe {\\it mv} instruction ({\\it move}) copies the contents of one register into \nanother, using the syntax \\texttt{mv} \\texttt{rX,rY}. It can also be used to initialize a \nregister with immediate data, as in \\texttt{mv} \\texttt{rX,\\#D}.  Since the data {\\it D} \nis represented inside the encoded instruction using only nine bits, the processor has to \n{\\it zero-extend} the data, as in \\texttt{0000000D$_{8-0}$}, before loading it into \nregister~{\\it rX}.  The {\\it mvt} instruction ({\\it move top}) is used to initialize the \nmost-significant byte of a register.  For {\\it mvt}, only eight bits of the {\\it D} field in \nthe instruction are used, so that \\texttt{mvt} \\texttt{rX,\\#D} loads the value \n\\texttt{D$_{15-8}$00000000} into {\\it rX}. As an example, to load register $r0$ with the \nvalue \\texttt{0xFF00}, you would use the instruction \\texttt{mvt r0,\\#0xFF00}.  The instruction \n\\texttt{add} \\texttt{rX,rY} produces the sum {\\it rX} $+$ {\\it rY} and loads the result \ninto {\\it rX}. The instruction \\texttt{add} \\texttt{rX,\\#D} produces the \nsum {\\it rX} $+$ {\\it D}, where {\\it D} is zero-extended to 16 bits, and saves the result \nin {\\it rX}. Similarly, the {\\it sub} instruction generates \neither {\\it rX} $-$ {\\it rY}, or {\\it rX} $-$ \\#{\\it D} and loads the result into {\\it rX}.\n\n~\\\\\nSome instructions, such as an {\\it add} or {\\it sub}, take a few clock cycles to complete, \nbecause multiple transfers have to be performed across the bus. The finite state machine in the \nprocessor ``steps through'' such instructions, asserting the control signals needed in \nsuccessive clock cycles until the instruction has completed.  The processor starts executing \nthe instruction on the {\\it DIN} input when the {\\it Run} signal is asserted and the processor \nasserts the {\\it Done} output when the instruction is finished.  Table~\\ref{tab:control_signals}\nindicates the control signals from Figure~\\ref{fig:fig1} that have to be \nasserted in each time step to implement the instructions in Table~\\ref{tab:instructions}.  The \nonly control signal asserted in time step $T_0$, for all instructions, is {\\it IR}$_{in}$. \nThe meaning of {\\it Select = rY} or {\\it IR} in the table is that the multiplexer selects \neither register {\\it rY} or the immediate data in {\\it IR}, depending on the value of $Op2$.\nFor the {\\it mv} instruction, when {\\it IR} is selected the multiplexer outputs \n\\texttt{0000000DDDDDDDDD}, and for {\\it mvt} the multiplexer outputs \\texttt{DDDDDDDD00000000}.\nOnly signals from Figure~\\ref{fig:fig1} that have to be asserted in each time \nstep are listed in Table~\\ref{tab:instructions}; all other signals are not asserted. The \nmeaning of {\\it AddSub} in step $T_2$ of the {\\it sub} instruction is that this signal is set \nto 1, and this setting causes the adder/subtracter unit to perform subtraction using \n2's-complement arithmetic.\n\n~\\\\\nThe processor in Figure~\\ref{fig:fig1} can perform various tasks by using a sequence of \ninstructions. For example, the sequence below loads the number 28 into register $r0$ and then \ncalculates, in register $r1$, the 2's complement value $-28$.\n\n\\begin{minipage}[t]{15 cm}\n\\begin{lstlisting}\n       mv    r0, #28        // original number = 28\n       mvt   r1, #0xFF00\n       add   r1, #0x00FF    // r1 = 0xFFFF\n       sub   r1, r0         // r1 = 1's-complement of r0\n       add   r1, #1         // r1 = 2's-complement of r0 = -28\n\\end{lstlisting}\n\\end{minipage}\n\n\\begin{table}[H]\n\\begin{center}\n\\begin{tabular}{r|c|c|c|c|}\n\\multicolumn{1}{c}{~} & \\multicolumn{1}{c}{$T_0$} & \\multicolumn{1}{c}{$T_1$} & \\multicolumn{1}{c}{$T_2$} & \\multicolumn{1}{c}{$T_3$} \\rule[-0.075in]{0in}{0.25in}\\\\ \\cline{2-5}\n{\\it mv~} & {\\it IR}$_{in}$ & \\rule[-0.075in]{0in}{0.25in}{\\it Select} = {\\it rY} or {\\it IR}, &  &  \\\\\n~ & ~ & {\\it rX$_{in}$}, {\\it Done} &  &  \\\\ \\cline{2-5}\n{\\it mvt~} & {\\it IR}$_{in}$ & \\rule[-0.075in]{0in}{0.25in}{\\it Select} = {\\it IR}, &  &  \\\\\n~ & ~ & {\\it rX$_{in}$}, {\\it Done} &  &  \\\\ \\cline{2-5}\n\\rule[-0.075in]{0in}{0.25in}{\\it add~} & {\\it IR}$_{in}$ & {\\it Select} = {\\it rX}, & {\\it Select} = {\\it rY} or {\\it IR}, & {\\it Select = G}, {\\it rX$_{in}$}, \\\\\n~ & ~ & {\\it A$_{in}$} &  {\\it G$_{in}$} & {\\it Done} \\\\\n\\cline{2-5}\n\\rule[-0.075in]{0in}{0.25in}{\\it sub~} & {\\it IR}$_{in}$ & {\\it Select} = {\\it rX}, & {\\it Select} = {\\it rY} or {\\it IR}, & {\\it Select = G}, {\\it rX$_{in}$}, \\\\\n~ & ~ & {\\it A$_{in}$} &  {\\it AddSub}, {\\it G$_{in}$} & {\\it Done} \\\\\n\\cline{2-5}\n\\end{tabular}\n\\caption{Control signals asserted in each instruction/time step.}\n\\label{tab:control_signals}\n\\end{center}\n\\end{table}\n\n\\section*{Part I}\n\\addcontentsline{toc}{1}{Part I}\nImplement the processor shown in Figure~\\ref{fig:fig1} using VHDL code, as follows:\n\\begin{enumerate}\n\\item Make a new folder for this part of the exercise. \nPart of the VHDL code for the processor is shown in parts $a$ to $c$ of \nFigure~\\ref{fig:fig2}, and a more complete version of the code is provided with this exercise,\nin a file named {\\it proc.vhd}. You can modify this code to suit your own coding style\nif desired---the provided code is just a suggested solution. Fill in the missing parts of\nthe VHDL code to complete the design of the processor.\n\n\\lstset{language=VHDL,numbers=none,escapechar=|}\n\\begin{figure}[h]\n\\begin{center}\n\\begin{minipage}[t]{15 cm}\n\\begin{lstlisting}[name=proc]\nENTITY proc IS\n    PORT ( DIN                 : IN  STD_LOGIC_VECTOR(15 DOWNTO 0);\n           Resetn, Clock, Run  : IN  STD_LOGIC;\n           Done                : BUFFER  STD_LOGIC);\nEND proc;\n   \nARCHITECTURE Behavior OF proc IS\n    |$\\ldots$| declare components\n   \n    TYPE State_type IS (T0, T1, T2, T3);\n    SIGNAL Tstep_Q, Tstep_D: State_type;\n    |$\\ldots$|\n    CONSTANT mv : STD_LOGIC_VECTOR(2 DOWNTO 0) := \"000\";\n    CONSTANT mvt : STD_LOGIC_VECTOR(2 DOWNTO 0) := \"001\";\n    CONSTANT add : STD_LOGIC_VECTOR(2 DOWNTO 0) := \"010\";\n    CONSTANT sub : STD_LOGIC_VECTOR(2 DOWNTO 0) := \"011\";\n    CONSTANT Sel_R0 : STD_LOGIC_VECTOR(3 DOWNTO 0) := \"0000\";\n    |$\\ldots$|\n    CONSTANT Sel_R7 : STD_LOGIC_VECTOR(3 DOWNTO 0) := \"0111\";\n    CONSTANT Sel_G : STD_LOGIC_VECTOR(3 DOWNTO 0) := \"1000\";\n    CONSTANT Sel_D : STD_LOGIC_VECTOR(3 DOWNTO 0) := \"1001\";\n    CONSTANT Sel_D8 : STD_LOGIC_VECTOR(3 DOWNTO 0) := \"1010\" ;\n             -- Sel_D is immediate data, Sel_D8 is immediate data << 8\nBEGIN\n\\end{lstlisting}\n\\end{minipage}\n\\caption{Skeleton VHDL code for the processor. (Part $a$)}\n\\label{fig:fig2}\n\\end{center}\n\\end{figure}\n\n\\begin{center}\n\\begin{minipage}[t]{15 cm}\n\\begin{lstlisting}[name=proc]\n    III <= IR(15 DOWNTO 13);\n    IMM <= IR(12);\n    rX <= IR(11 DOWNTO 9);\n    rY <= IR(2 DOWNTO 0);\n    decX: dec3to8 PORT MAP (rX, Xreg);\n    \n    statetable: PROCESS(Tstep_Q, Run, Done)\n    BEGIN\n        CASE Tstep_Q IS\n            WHEN T0 =>    -- data is loaded into IR in this time step\n                IF Run = '0' THEN Tstep_D <= T0;\n                ELSE Tstep_D <= T1; END IF;\n            WHEN T1 =>\n            |$\\ldots$|\n        END CASE;\n    END PROCESS;\n\n    controlsignals: PROCESS (Tstep_Q, III, IMM, Xreg, rX, rY)\n    BEGIN\n        Done <= '0'; Ain <= '0'; |$\\ldots$| default values for signals\n        CASE Tstep_Q IS\n            WHEN T0 => -- store DIN in IR as long as Tstep_Q = 0\n                IRin <= '1';\n            WHEN T1 => -- define signals in time step T1\n                CASE III IS\n                    WHEN mv =>\n                        IF IMM = '0' THEN Sel <= '0' & rY;\n                        ELSE Sel <= Sel_D; END IF;\n                        Rin <= Xreg;\n                        Done <= '1';\n                    WHEN mvt =>                         \n                    |$\\ldots$|\n                END CASE;\n            WHEN T2 => -- define signals in time step T2\n                CASE III IS\n                    |$\\ldots$|\n                END CASE;\n            WHEN T3 => -- define signals in time step T3\n                |$\\ldots$|\n        END CASE;\n    END PROCESS;\n\n    fsmflipflops: PROCESS (Clock, Resetn, Tstep_D)\n    BEGIN\n        IF (Resetn = '0') THEN\n            |$\\ldots$|\n    reg_0:  regn PORT MAP (BusWires, Rin(0), Clock, R0);\n    reg_1:  regn PORT MAP (BusWires, Rin(1), Clock, R1);\n    |$\\ldots$|\n    reg_7:  regn PORT MAP (BusWires, Rin(7), Clock, R7);\n    |$\\ldots$| instantiate other registers |and| the adder/subtracter unit\n\\end{lstlisting}\n\\end{minipage}\n\\end{center}\n\n\\begin{center}\nFigure 2: Skeleton VHDL code for the processor. (Part $b$)\n\\end{center}\n\n\\begin{center}\n\\begin{minipage}[t]{15 cm}\n\\begin{lstlisting}[name=proc]\n    -- define the internal bus\n    busmux: PROCESS (Sel, R0, R1, R2, R3, R4, R5, R6, R7, G, IR)\n    BEGIN\n        CASE Sel IS\n            WHEN Sel_R0 => BusWires <= R0;\n            WHEN Sel_R1 => BusWires <= R1;\n            |$\\ldots$|\n            WHEN Sel_R7 => BusWires <= R7;\n            WHEN Sel_G => BusWires <= G;\n            WHEN Sel_D => BusWires <= \"0000000\" & IR(8 DOWNTO 0);\n            WHEN Sel_D8 => BusWires <= IR(7 DOWNTO 0) & \"00000000\";\n            WHEN OTHERS => BusWires <= (OTHERS => '-');\n        END CASE;\n    END PROCESS;   \nEND Behavior;\n\nLIBRARY ieee;\nUSE ieee.std_logic_1164.all;\n\nENTITY dec3to8 IS\n    PORT ( W   : IN   STD_LOGIC_VECTOR(2 DOWNTO 0);\n           Y   : OUT  STD_LOGIC_VECTOR(0 TO 7));\nEND dec3to8;\n\nARCHITECTURE Behavior OF dec3to8 IS\nBEGIN\n    PROCESS (W)\n    BEGIN\n        CASE W IS\n            WHEN \"000\" => Y <= \"10000000\";\n            WHEN \"001\" => Y <= \"01000000\";\n            WHEN \"010\" => Y <= \"00100000\";\n            |$\\ldots$|\n            WHEN \"110\" => Y <= \"00000010\";\n            WHEN \"111\" => Y <= \"00000001\";\n            WHEN OTHERS => Y <= \"00000000\";\n        END CASE;\n    END PROCESS;\nEND Behavior;\n\\end{lstlisting}\n\\end{minipage}\n\\end{center}\n\n\\begin{center}\nFigure 2: Skeleton VHDL code for the processor. (Part $c$)\n\\end{center}\n\n~\\\\\n\\item Set up the required subfolder and files so that your VHDL code can be compiled and \nsimulated using the ModelSim Simulator to verify that your processor works properly. \nAn example result produced by using {\\it ModelSim} for a correctly-designed circuit \nis given in Figure~\\ref{fig:fig3}.  It shows the value \\texttt{0x101C} being loaded into {\\it IR} \nfrom {\\it DIN} at time 30 ns. This pattern represents the instruction \\texttt{mv r0,\\#28}, \nwhere the immediate value $D = 28$ (\\texttt{0x1C}) is loaded into $r0$ on the clock edge at 50 ns. \nThe simulation results then show the instruction \\texttt{mvt~r1,\\#0xFF00} at 70 ns, \n\\texttt{add r0,\\#0xFF} at 110 ns, and \\texttt{sub r1,r0} at 190 ns.\n\nYou should perform a thorough simulation of your processor with the ModelSim simulator. A \nsample VHDL testbench file, {\\it testbench.vht}, execution script, {\\it testbench.tcl}, \nand waveform file, {\\it wave.do} are provided along with this exercise.\n\\end{enumerate}\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale=.95]{figures/figure3.png}\n\t\\end{center}\n\t\\caption{Simulation results for the processor.}\n\t\\label{fig:fig3}\n\\end{figure}\n\\section*{Part II}\n\\addcontentsline{toc}{2}{Part II}\nIn this part we will implement the circuit depicted in Figure~\\ref{fig:fig4}, in which a \nmemory unit and counter are connected to the processor. The\ncounter is used to read the contents of successive locations in the memory, and\nthis data is provided to the processor as a stream of instructions. To simplify the\ndesign and testing of this circuit we have used separate clock signals, {\\it PClock} \nand {\\it MClock}, for the processor and memory. Do the following:\n\n\\begin{enumerate}\n\\item A Quartus project file is provided along with this part of the exercise.  Use the \nQuartus software to open this project, which is called {\\it part2.qpf}.\n\\item A sample top-level VHDL file that instantiates the processor, memory unit, and\ncounter is shown in Figure~\\ref{fig:procmem}. This code is provided in a file named\n{\\it part2.vhd}; it is the top-level file for the Quartus project {\\it part2.qpf}. The \ncode instantiates a memory unit called {\\it inst\\_mem}. You have to create a VHDL file\nthat represents this memory unit by using the Quartus software, as described below.\n\n~\\\\\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[]{figures/figure4.pdf}\n\t\\end{center}\n\t\\caption{Connecting the processor to a memory unit and counter.}\n\t\\label{fig:fig4}\n\\end{figure}\n\\newpage\n\\lstset{language=VHDL,numbers=none,escapechar=|}\n\\begin{figure}[h]\n\\begin{center}\n\\begin{minipage}[t]{15 cm}\n\\begin{lstlisting}[name=proc]\nENTITY part2 IS \nPORT ( KEY   : IN   STD_LOGIC_VECTOR(1 DOWNTO 0);\n       SW    : IN   STD_LOGIC_VECTOR(9 DOWNTO 0);\n       LEDR  : OUT  STD_LOGIC_VECTOR(9 DOWNTO 0));\nEND part2;\n\nARCHITECTURE Behavior OF part2 IS\n   |$\\ldots$| declare components and signals\nBEGIN\n   Resetn <= SW(0);\n   MClock <= KEY(0);\n   PClock <= KEY(1);\n   Run <= SW(9);\n   U1: proc PORT MAP (DIN, Resetn, PClock, Run, Done);\n   LEDR(0) <= Done;\n   LEDR(9) <= Run;\n\n   U2: inst_mem PORT MAP (pc, MClock, DIN);\n   U3: count5 PORT MAP (Resetn, MClock, pc);\nEND Behavior;\n|$\\ldots$|\nENTITY count5 IS \nPORT ( Resetn, Clock   : IN   STD_LOGIC;\n       Q               : OUT  STD_LOGIC_VECTOR(4 DOWNTO 0));\nEND count5;\n\nARCHITECTURE Behavior OF count5 IS\n   SIGNAL Count : STD_LOGIC_VECTOR(4 DOWNTO 0); \nBEGIN\n   PROCESS (Clock, Resetn)\n   BEGIN\n         IF (Resetn = '0') THEN\n            Count <= \"00000\";\n         ELSIF (rising_edge(Clock)) THEN\n            Count <= Count + '1';\n         END IF;\n   END PROCESS;\n   Q <= Count;\nEND Behavior;\n\\end{lstlisting}\n\\end{minipage}\n\\caption{VHDL code for the top-level entity.}\n\\label{fig:procmem}\n\\end{center}\n\\end{figure}\n\n\\item\nA diagram of the memory unit that you need to create is depicted in Figure~\\ref{fig:fig_ROM}.\nSince this memory unit has only a read port, and no write port, it is called a {\\it synchronous \nread-only memory (synchronous ROM)}. Note that the memory unit includes a register for \nsynchronously loading addresses. This register is required due to the design of the memory \nresources in the Intel FPGA chip. \n\nUse the Quartus IP Catalog tool to create the memory unit, by clicking on \n{\\sf Tools} $>$ {\\sf IP Catalog} in the Quartus software. In the IP Catalog window \nchoose the {\\it ROM:~1-PORT} unit,\nwhich is found under the {\\sf Basic Functions $>$  On Chip Memory} category.  \nSelect {\\sf VHDL} as the type of output file to create, and give the file the name \n{\\it inst\\_mem.vhd}.\nFollow through the provided dialogue to create a memory that has one 16-bit \nwide read data port and is 32 words deep. Figures~\\ref{fig:fig5} and ~\\ref{fig:fig6} show the \nrelevant pages and how to properly configure the memory. \n\n\\begin{figure}[t]\n\t\\begin{center}\n\t\t\\includegraphics[]{figures/figure_ROM.pdf}\n\t\\end{center}\n\t\\caption{The 32 {\\sf x} 16 ROM with address register.}\n\t\\label{fig:fig_ROM}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale=1.0]{figures/figure5.png}\n\t\\end{center}\n\t\\caption{{Specifying memory size.}}\n\t\\label{fig:fig5}\n\\end{figure}\n\nTo place processor instructions into the memory, you need to specify {\\it initial values}\nthat should be stored in the memory when your circuit is programmed into the FPGA chip.\nThis can be done by initializing the memory using the contents of a {\\it memory initialization \nfile (MIF)}. The appropriate screen is illustrated in Figure~\\ref{fig:fig7}. We have specified \na file named {\\it inst\\_mem.mif}, which then has to be created in the folder that \ncontains the Quartus project. Clicking \\texttt{Next} two more times will advance to the\n\\texttt{Summary} screen, which lists the names of files that will be created for the memory IP.\nYou should select {\\it only} the VHDL file {\\it inst\\_mem.vhd}. Make sure that none of the \nother types of files are selected, and then click \\texttt{Finish}.\n\nAn example of a memory initialization file is given in \nFigure~\\ref{fig:fig_MIF}. Note that comments (\\% $\\ldots$ \\%) are included in this file as a way of\ndocumenting the meaning of the provided instructions.  Set the contents of\nyour {\\it MIF} file such that it provides enough processor instructions to test your circuit.\n\n\\item The code in Figure~\\ref{fig:procmem}, and the Quartus project, includes the necessary \nport names and pin location assignments to implement the circuit on a DE-series board.\nThe switch {\\it SW}$_{9}$ drives the processor's {\\it Run} input, {\\it SW}$_0$ is\nconnected to {\\it Resetn}, {\\it KEY}$_0$ to {\\it MClock}, and {\\it KEY}$_1$ to {\\it PClock}.\nThe Run signal is displayed on {\\it LEDR}$_{0}$ and {\\it Done} is connected to {\\it LEDR}$_{9}$.\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale=1.0]{figures/figure6.png}\n\t\\end{center}\n\t\\caption{Specifying which memory ports are registered.}\n\t\\label{fig:fig6}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale=1.0]{figures/figure7.png}\n\t\\end{center}\n\t\\caption{Specifying a memory initialization file (MIF).}\n\t\\label{fig:fig7}\n\\end{figure}\n\n\\item Use the ModelSim Simulator to test your VHDL code. Ensure \nthat instructions are read properly out of the ROM and executed by the processor. An example \nof simulation results produced using ModelSim with the MIF file from \nFigure~\\ref{fig:fig_MIF} is shown in Figure~\\ref{fig:fig_sim2}. The corresponding ModelSim \nsetup files are provided along with this exercise.\n\\item Once your simulations show a properly-working circuit, you may wish to download\nit into a DE-series board. The functionality of the circuit on the board can be tested by\ntoggling the switches and observing the LEDs. Since the circuit's clock inputs are controlled \nby pushbutton switches, it is possible to step through the execution of instructions and \nobserve the behavior of the circuit.\n\\end{enumerate}\n\n\\begin{figure}[H]\n\\begin{center}\n\\begin{minipage}[t]{12.5 cm}\n\\begin{tabbing}\n{\\bf DEPTH} = 32;\\\\\n{\\bf WIDTH} = 16;\\\\\n{\\bf ADDRESS\\_RADIX} = HEX;\\\\\n{\\bf DATA\\_RADIX} = BIN;\\\\\n{\\bf CONTENT}\\\\\n{\\bf BEGIN}\\\\\n00\t:\t0001000000011100;~~~~~~\\=\\%~~mv  \\=r0, \\#0xFF00~~\\=\\% \\kill\n00\t:\t0001000000011100;\t\\>\\% mv \\>r0, \\#28\\>\\%\\\\\n01\t:\t0011001011111111; \\>\\% mvt \\>r1, \\#0xFF00\\>\\%\\\\\n02\t:\t0101001011111111;\t\\>\\% add  \\>r1, \\#0xFF\\>\\%\\\\\n03\t:\t0110001000000000;\t\\>\\% sub  \\>r1, r0\\>\\%\\\\\n04\t:\t0101001000000001;\t\\>\\% add  \\>r1, \\#1\\>\\%\\\\\n05\t:\t0000000000000000;\\\\\n$\\ldots$ (some lines not shown)\\\\\n1F :\t0000000000000000;\\\\\n{\\bf END};\n\\end{tabbing}\n\\end{minipage}\n\\end{center}\n\\caption{An example memory initialization file (MIF).}\n\\label{fig:fig_MIF}\n\\end{figure}\n\n\\begin{figure}[H]\n\t\\begin{center}\n\t\t\\includegraphics[scale=.95]{figures/figure8.png}\n\t\\end{center}\n\t\\caption{An example simulation output using the MIF in Figure~\\ref{fig:fig_MIF}.}\n\t\\label{fig:fig_sim2}\n\\end{figure}\n\n\\section*{Enhanced Processor}\n\\addcontentsline{toc}{3}{Enhanced Processor}\nIt is possible to enhance the capability of the processor so that the counter in \nFigure~\\ref{fig:fig4} is no longer needed, and so that the processor has the ability to \nperform read and write operations using memory or other devices. These enhancements involve \nadding new instructions to the processor, as well as other capabilities---they are\ndiscussed in the next lab exercise.\n\n\\end{document}\n", "meta": {"hexsha": "c8b1989ce42b52d7f5277184b99a2c5207a308fb", "size": 23461, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "vhdl/lab9/doc/vhdl_lab9.tex", "max_stars_repo_name": "fpgacademy/Lab_Exercises_Digital_Logic", "max_stars_repo_head_hexsha": "f4119b617a5af228a032f8f0ff27a299b496ad78", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-09T23:21:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T23:21:40.000Z", "max_issues_repo_path": "vhdl/lab9/doc/vhdl_lab9.tex", "max_issues_repo_name": "fpgacademy/Lab_Exercises_Digital_Logic", "max_issues_repo_head_hexsha": "f4119b617a5af228a032f8f0ff27a299b496ad78", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "vhdl/lab9/doc/vhdl_lab9.tex", "max_forks_repo_name": "fpgacademy/Lab_Exercises_Digital_Logic", "max_forks_repo_head_hexsha": "f4119b617a5af228a032f8f0ff27a299b496ad78", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-15T16:44:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-15T16:44:27.000Z", "avg_line_length": 43.3659889094, "max_line_length": 176, "alphanum_fraction": 0.6765696262, "num_tokens": 7159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438502, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.40304564567922785}}
{"text": "%\n% Licensed to the Apache Software Foundation (ASF) under one\n% or more contributor license agreements.  See the NOTICE file\n% distributed with this work for additional information\n% regarding copyright ownership.  The ASF licenses this file\n% to you under the Apache License, Version 2.0 (the\n% \"License\"); you may not use this file except in compliance\n% with the License.  You may obtain a copy of the License at\n%\n%   http://www.apache.org/licenses/LICENSE-2.0\n%\n% Unless required by applicable law or agreed to in writing,\n% software distributed under the License is distributed on an\n% \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n% KIND, either express or implied.  See the License for the\n% specific language governing permissions and limitations\n% under the License.\n%\n\\documentclass{beamer}\n\\usepackage[T1]{fontenc}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{algorithm}\n\\usepackage{varwidth}\n\\usepackage{bm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage{xspace}\n\\usepackage{multirow}\n\\usepackage{xcolor}\n\\DeclareRobustCommand{\\NAME}{Wideskies\\xspace}\n\\newcommand{\\from}{\\rightarrow}\n\n\\algnewcommand{\\algorithmicgiven}{\\textbf{given }}\n\\algnewcommand{\\Given}{\\algorithmicgiven}\n\n\\algnewcommand{\\algorithmicselect}{\\textbf{select }}\n\\algnewcommand{\\Select}{\\algorithmicselect}\n\n\\algnewcommand{\\algorithmicset}{\\textbf{set }}\n\\algnewcommand{\\Set}{\\algorithmicset}\n\n\\algnewcommand{\\algorithmiccompute}{\\textbf{compute }}\n\\algnewcommand{\\Compute}{\\algorithmiccompute}\n\n\\algnewcommand{\\algorithmicgoto}{\\textbf{go to}}\n\\algnewcommand{\\Goto}[1]{\\algorithmicgoto~\\ref{#1}}\n\n\\newcommand{\\Z}{\\ensuremath{\\mathbf{Z}}}\n\\newcommand{\\zmodn}{\\ensuremath{\\Z/N\\Z}}\n\\newcommand{\\zmodntunits}{\\ensuremath{\\left(\\Z/N^{2}\\Z\\right)^{\\times}}}\n\\newcommand{\\lcm}{\\ensuremath{\\text{lcm}}}\n\n\\mode<presentation> { \\usetheme{default} }\n\n\\usepackage{graphicx} \n\\usepackage{booktabs}\n\\usepackage{array}\n\\newcolumntype{L}[1]{>{\\raggedright\\let\\newline\\\\\\arraybackslash\\hspace{0pt}}p{#1}}\n\\newcolumntype{C}[1]{>{\\centering\\let\\newline\\\\\\arraybackslash\\hspace{0pt}}p{#1}}\n\\newcolumntype{R}[1]{>{\\raggedleft\\let\\newline\\\\\\arraybackslash\\hspace{0pt}}p{#1}}\n\n\\makeatletter\n\\DeclareRobustCommand*{\\&}{%\n  \\nfss@text{%\n    \\fontfamily{LinuxBiolinumT-TLF}%\n    \\selectfont\n    \\symbol{`\\&}%\n  }%\n}\n\n\\usepackage{eso-pic}\n\\beamertemplatenavigationsymbolsempty\n\\setbeamertemplate{footline}[frame number]\n\\newcommand\\AtPagemyUpperLeft[1]{\\AtPageLowerLeft{%\n\\put(\\LenToUnit{0.9\\paperwidth},\\LenToUnit{0.9\\paperheight}){#1}}}\n\n\\AtBeginSection[]{\n  \\begin{frame}\n  \\vfill\n  \\centering\n  \\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}\n    \\usebeamerfont{title}\\insertsectionhead\\par%\n  \\end{beamercolorbox}\n  \\vfill\n  \\end{frame}\n}\n\\title[Apache Pirk Math\nWalkthrough]{\\includegraphics[width=2.5in,keepaspectratio]{ApachePirk_1.png}\\\\ \\bigskip Mathematics $\\&$ Algorithms} \n\n\\author{Walter Ray-Dulany} \n\\institute[Apache Pirk] \n{\n\\medskip\n\\textit{raydulany@apache.org} \n}\n% I decided against a date. - Walter\n\\date{} \n\n\\begin{document}\n\n\\begin{frame}\n\\titlepage \n\\end{frame}\n\n\\AddToShipoutPictureFG{\n  \\AtPagemyUpperLeft{{\\includegraphics[width=.5cm,keepaspectratio]{ApachePirkCircle.png}}}\n}\n\n\\section{Introduction} \n\n\\begin{frame}\n\\frametitle{Pirk's Wideskies Algorithm}\n  Pirk uses the Wideskies algorithm to accomplish scalable PIR.\\\\~\\\\\n  This algorithm can be broken down into two distinct conceptual pieces:\n    \\begin{itemize}\n      \\item Paillier Encryption\n      \\item The Query-Response-Result algorithms\n    \\end{itemize}\n    ~\\\\ Before we begin those however, we take a (happily brief) diversion into\n    the language of the mathematics involved in this deck.\n\\end{frame}\n\n\n\\section{Language Preliminaries}\n\\begin{frame}\n  \\frametitle{Language Preliminaries}\n  The Paillier scheme employs a small amount of group theoretic notation. Let's\n  go over that notation briefly.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Language Preliminaries}\n  \\begin{itemize}\n    \\item \\zmodn: This is the group of integers modulo $N$; it can be thought of\n      as all numbers $0\\leq k < N$, with modular addition (e.g.\\ for $N=5$,\n      $1+7 \\equiv 3\\mod N$).\\\\~\\\\ This is a group under addition.\\\\~\\\\\n    \\item $(\\zmodn)^\\times$: This is the multiplicative group of integers modulo\n      $N$, also called the units of $\\zmodn$. Sometimes denoted\n      $(\\mathbf{Z}/N\\mathbf{Z})^*$, this is the set of $0\\leq k < N$ that are\n      relatively prime to $N$ (that is, $k$ and $N$ share no factors, or\n      equivalently the greatest common denominator ($\\gcd$) of $k$ and $N$ is $1$). One\n      can also think of this as the set of $k\\in\\zmodn$ such that there exists\n      a $k^{-1}\\in\\zmodn$ with $k\\cdot k^{-1} \\equiv 1\\mod N$.\\\\~\\\\\n      This is a group under multiplication.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Language Preliminaries}\nUsing the above notation, we can see that \n\\begin{equation*}\n  \\zmodntunits = \\{0\\leq k<N^2: \\gcd(k,N^2) = 1\\}.\n\\end{equation*}~\\\\\nIf $N$ happens to be an RSA modulus,\n$N=pq$, $p$ and $q$ primes, then $\\zmodntunits$ is just all numbers between $0$\n(inclusive) and $N^2$ (exclusive) that are not divisible by either $p$ or\n$q$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Language Preliminaries}\n  \\begin{itemize}\n    \\item Order In \\zmodn: The order of an element $k\\in\\zmodn$ is the least integer $e$\n      such that $e\\cdot k = 0\\mod N$.\n    \\item Order in \\zmodntunits: The order of an element $a\\in\\zmodntunits$ is\n      the least integer $e$ such that $a^e = 1\\mod N^2$.\n  \\end{itemize}\n  In both cases, order is well defined (i.e.\\ it exists and makes sense) for\n  all elements of the groups.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Language Preliminaries}\n  For a more in depth discussion of these, and closely related, terms, please\n  see \n  \\mbox{\\scriptsize \\url{http://www.math.nagoya-u.ac.jp/~richard/teaching/s2015/Group_2.pdf}}\n\\end{frame}\n\n\\section{Paillier Encryption}\n\\begin{frame}\n\\frametitle{Paillier Encryption}\nPaillier encryption is a partially homomorphic public key scheme that relies on\nthe function $$\\mathcal{E}_g:\\zmodn\\times(\\zmodn)^\\times\\rightarrow\n\\zmodntunits$$ given by $$\\mathcal{E}_g(x,y) = g^x y^N \\mod N^2,$$\n$g\\in\\zmodntunits$. Here, $\\zmodn$ is the plaintext space and $\\zmodntunits$ is\nthe ciphertext space.\\\\~\\\\\nWhen the order of $g$ is a non-zero multiple of $N$, $\\mathcal{E}_g$ is a bijection.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Paillier Prerequisites}\n\\begin{itemize}\n  \\item Public key: $(N,g)$, $N$ an RSA modulus $N=pq$, $p$ and $q$ primes of\n    approximately the same bit-length, and $g\\in \\zmodntunits$ such that the\n    order of $g$ is a nonzero multiple of $N$. \n  \\item Private key: $\\lambda(N)$, where $\\lambda$ is the Carmichael function\n    \\begin{align*}\n      \\lambda(N) &= \\lcm(p-1,q-1)\n    \\end{align*}\n  that gives the exponent of $(\\zmodn)^\\times$.\n  \\item Plaintext space: \\zmodn.\n  \\item Ciphertext space: \\zmodntunits.\n\\end{itemize}\n~\\\\\n{\\footnotesize We can also consider the pair $(p,q)$ to be the private key, as $\\lambda(N)$ is\nquickly and easily derived from it. Note that $\\lambda(N)$ is coprime to $N$.}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{What Do We Mean By `Homomorphic Encryption'?}\n  An encryption scheme is fully homomorphic if it is a homomorphism from\n  plaintext space to ciphertext space for arbitrary operations and arbitrary\n  numbers of such operations. If this definition seems squishy and not very\n  mathematical, that's because it is; it's hard to find a proper mathematical\n  definition of this term.\\\\~\\\\\n\n  An encryption scheme is partially homomorphic if it is a homomorphism for\n  only some operations, or for only a few consecutive operations.\\\\~\\\\\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Paillier Encryption is Homomorphic}\n  Paillier encryption is a partial homomorphism between addition in \\zmodn\\ and\n  multiplication in \\zmodntunits.\\\\~\\\\\n\n  Denote Paillier encryption by $\\mathcal{E}_g$ and decryption by $\\mathcal{D}_g$,\n  and let $m$ and $m'\\in \\zmodn$. Then \n    \\begin{align*}\n        D(\\mathcal{E}(m) \\mathcal{E}(m') \\bmod N^2) &= (m + m') \\bmod N \\\\\n        D(\\mathcal{E}(m)^k \\bmod N^2) &= km \\bmod N, \\, k \\in \\mathbf{N}\n    \\end{align*}\n    ~\\\\\n    Note that the second equality follows immediately from the first.\n\\end{frame}\n\n\\section{General Paillier Algorithm}\n\n\\begin{frame}\n\\frametitle{Paillier Supporting Function}\nLet $X=\\{u<N^2 : u = 1 \\mod N\\}$ and let $L:X\\rightarrow \\zmodn$ be\ndefined by \n\\begin{equation*}L(u) = \\frac{u-1}{N} \\mod N.\\end{equation*}\nThis function is well defined over \\zmodntunits.\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{General Paillier Encryption}\nThe general Paillier algorithm differs only slightly from Pirk's version.\n\\begin{algorithm}[H]\n  \\caption{General Paillier encryption and decryption.}\\label{alg.paillier_encrypt_original}\n  \\begin{algorithmic}[1]\n    \\Procedure{Paillier encryption}{}\n    \\State \\begin{varwidth}[t]{\\linewidth}\n      \\Given \\(N\\), a random \\(g \\in \\zmodntunits\\) of order a nonzero\\par\n  multiple of $N$, and a message \\(m\\in\\zmodn\\)\n      \\end{varwidth}\n    \\State \\Select a random value \\(\\zeta\\in \\left(\\zmodn\\right)^{\\times}\\)\n    \\State \\Return \\(\\mathcal{E}(m) = g^m \\zeta^{N}\\bmod{N^{2}}\\)\n    \\EndProcedure\n  \\end{algorithmic}\n  \\begin{algorithmic}[1]\n    \\Procedure{Paillier decryption}{}\n    \\State \\Given \\(N\\), \\(\\lambda(N)\\), \\(g\\), and ciphertext \\(c \\in \\zmodntunits\\)\n    \\State \\Return m = \\(\\frac{L( c^{\\lambda(N)}\\bmod N^{2})}{L( g^{\\lambda(N)}\\bmod N^{2})}\\bmod N\\)\n    \\EndProcedure\n  \\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Paillier Works}\n  It is a straightforward exercise to check that \n  \\begin{itemize}\n    \\item $D(\\mathcal{E}(m)) = m$\n    \\item $D(\\mathcal{E}(m)\\mathcal{E}(m')\\bmod N^2) = (m + m') \\bmod N $\n  \\end{itemize}\n\\end{frame}\n\n\\section{Paillier As Used In \\NAME}\n\\begin{frame}\n\\frametitle{Paillier As Used In \\NAME}\nThe version of Paillier used in \\NAME is a computationally simpler variant of the\nfull Paillier scheme that sacrifices no security over the general case.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Converting Between The Two}\n  Pirk's simplified version of Paillier simply uses\n  \\begin{align*}\n    g &\\equiv 1 + N \\mod N^2\\\\\n    \\implies L(g^{\\lambda(N)} \\mod N^2) &= \\lambda(N),\n  \\end{align*}\n  the proof of which is a straightforward exercise.\n\\end{frame}\n\n\\begin{frame}\n\\frametitle{Paillier As Used In \\NAME}\n\\begin{algorithm}[H]\n  \\caption{Paillier encryption and decryption}\\label{alg.paillier_encrypt}\n  \\begin{algorithmic}[1]\n    \\Procedure{Paillier encryption}{}\n    \\State \\Given \\(N\\) and a message \\(m\\in\\zmodn\\)\n    \\State \\Select a random value \\(\\zeta\\in \\left(\\zmodn\\right)^{\\times}\\)\n    \\State \\Return \\(\\mathcal{E}(m) = (1+mN)\\zeta^{N}\\bmod{N^{2}}\\)\n    \\EndProcedure\n  \\end{algorithmic}\n\n  \\begin{algorithmic}[1]\n    \\Procedure{Paillier decryption}{}\n    \\State \\Given \\(N\\), \\(\\lambda(N)\\), and a ciphertext \\(c\\in\\zmodntunits\\)\n    \\State \\Set \\(\\mu = \\lambda(N)^{-1}\\bmod N\\)\n    \\Comment Recall \\(\\gcd(\\lambda(N), N) = 1\\)\n    \\State \\Set \\(\\hat{c} = c^{\\lambda(N)}\\bmod N^{2}\\)\n    \\State\\label{step.div}\\Set \\(\\hat{m} = L(c^{\\lambda(N)}\\bmod N^{2})\\)\n    \\State \\Return \\(\\hat{m}\\mu\\bmod N\\)\n    \\EndProcedure\n  \\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Paillier Reference}\n  For more on Paillier encryption and the (hypothesized) hard problem upon\n  which it is based, see\\\\~\\\\\n  \\mbox{\\scriptsize \\url{https://pirk.incubator.apache.org/papers/1999_asiacrypt_paillier_paper.pdf}}\\\\~\\\\\n  on Pirk's website.\n\\end{frame}\n\n\\section{Wideskies}\n\n\\begin{frame}\n  \\frametitle{Wideskies Parameters}\n  The algorithm requires the following parameters, which are not independent\n  (see the next slide).\n  \\begin{itemize}\n    \\item $N$, the Paillier modulus\n    \\item $B$, the bit-length of $N$\n    \\item $H$ (or $H_k$), a keyed hash function (with key k)\n    \\item $\\ell$, the bit length of the output of $H$, i.e.\\\n      $H_k:\\mathbf{Z}\\rightarrow (\\mathbf{Z}/2\\mathbf{Z})^\\ell$\n    \\item $\\tau$, the number of search terms\n    \\item $\\delta$, the number of bits of data returned for each search hit\n    \\item $b$ the chunk size, in bits, determining how data is split among\n      responses.\n    \\item $r$, the number of responses that can be returned per query request\n      period per search term\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Parameter Relationships}\n  \\begin{itemize}\n    \\item $2^{b\\tau} < N$: there must be space in the modulus to hold all the\n      data, even if each search term hits as often as possible.\n    \\item $\\tau < 2^\\ell$: Although the paper permits search term hash\n    collisions, Pirk does not permit them. Typically $\\tau \\ll 2^\\ell$\n    \\item $b|\\delta$: Chunk size must evenly divide the data size\n    \\item $\\frac{\\delta}{b} | r$: the number of chunks per returned datum must\n      divide the number of responses, for bandwidth efficiency.\n    \\item $H$: Must be pseudo-random but need not be cryptographically secure.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Public Parameters}\n  All of \\begin{equation*}H, \\ell, N, B, \\delta, b, \\text{and } r\\end{equation*}\n  are public, that is, must be shared between the client and server.\\\\~\\\\\n\n  Note that the fact that $2^{b\\tau} < N$ gives some information on the number\n  of search terms the client is using; the amount of this information can be\n  decreased without bound by choosing $N$ and $\\ell$ to be much larger than\n  would be otherwise necessary; this necessarily causes a performance hit.\n\\end{frame}\n\n\\section{Wideskies Algorithm, Without Encryption}\n\\begin{frame}\n  \\frametitle{Wideskies Without Encryption?}\n  The Wideskies algorithm is of sufficient complexity that it can be useful to\n  go through the algorithm without the encryption and decryption steps first,\n  in order to orient ourselves.\\\\~\\\\\n  After, it will be straightforward to see the\n  changes that using the Paillier encryption requires.\n\\end{frame}\n\n\\section{Query, Without Encryption}\n\\begin{frame}\n  \\frametitle{The Query Algorithm, Without Encryption}\n  Let $T_0,\\ldots,T_{\\tau-1}\\in\\zmodn$ be our search terms.\n  \\begin{algorithm}[H]\n  \\caption{Query Formation Algorithm version\n    1}\\label{alg.plain_form_1}\n\\begin{algorithmic}[1]\n  \\State\\label{step.key}Choose a random key \\(k\\) for \\(H\\).\n  \\State Compute \\(H_{k}(T_{0}),\\ldots,H_{k}(T_{\\tau-1})\\).\n  \\While{\\(\\mathrm{card}\\left(\\{H_{k}(T_{0}),\\ldots,H_{k}(T_{\\tau-1})\\}\\right)\n    < \\tau\\)}\n  \\State \\Goto{step.key}\n  \\Comment If there are hash collisions, pick a new key.\n  \\EndWhile\n  \\For{\\(i=0,\\ldots,2^{\\ell}-1\\)}\n  \\State\\label{step.set}Set \\begin{equation*}\n    E_{i} = \\left\\{\\begin{array}{l l} \n    2^{jb} & \\mbox{ if } i = H_{k}(T_{j}); \\\\\n    0 & \\mbox{otherwise.}\n    \\end{array}\n    \\right.\n  \\end{equation*}\n  \\EndFor\n  \\State\\Return \\(\\{E_{0},\\ldots,E_{2^{\\ell}-1}, H, k, N\\}\\)\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Query Notes, Without Encryption}\n  Since $\\tau \\ll 2^\\ell$, we expect most of the $E_i$ to be zero.\\\\~\\\\\n  We will typically denote $H_k(T)$ by $\\mathcal{T}$ and its associated $E$ by\n  $E_\\mathcal{T}$. If we wish to keep track of a specific $T$ we will write\n  $\\mathcal{T}_j$ and $E_{\\mathcal{T}_j}$.\n\\end{frame}\n\n\\section{Response, Without Encryption}\n\\begin{frame}\n  \\frametitle{Response Initialization, Without Encryption}\n  We must initialize some values before forming the response.\n  \\begin{enumerate}\n    \\item $c_0,\\ldots,c_{2^\\ell - 1} = 0$, counters to keep track of the number\n      of times each $E_\\mathcal{T}$ has been seen.\n    \\item $Y_0,\\ldots,Y_{r-1} = 0$, response vectors.\n  \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Data, Without Encryption}\n  Responder information comes in pairs $(T, D)$ where $T$ is a (potential)\n  search term, and $D$ is $T$'s associated response datum, which will be\n  returned if $T$ is a search term.\\\\~\\\\\n\n  We view $D$ as a $\\delta$-long bit stream $(d_0,\\ldots,d_{\\delta-1})$, and\n  break $D$ up into $\\delta/b$ chunks $D_i$ as \n  \\begin{equation*}\n    D_i = (d_{i\\cdot b}, d_{i\\cdot b+1},\\ldots,d_{(i+1)\\cdot b-1}),\\ i=0,\\ldots,\\delta/b-1.\n  \\end{equation*}\\\\~\\\\\n  For example, if $D=011010$ and $b=3$, then\n  \\begin{align*}\n    D_0 &= 011\\\\\n    D_1 &= 010\n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Algorithm, Without Encryption}\n  \\begin{algorithm}[H]\n  \\caption{Stream processing, plaintext version}\\label{alg.plain_stream}\n\\begin{algorithmic}[1]\n\\State \\textbf{Input}:  $\\mathbf{T} = \\{ (T,D) \\}$\n\\For{$(T,D) \\in \\mathbf{T}$}\n  \\State Compute \\(\\mathcal{T} = H_{k}(T)\\)\n  \\If{\\(c_{\\mathcal{T}} + \\frac{\\delta}{b} > r\\)}\\label{step.if}\n  \\Comment The space allocated for term \\(T\\) is full.\n  \\State \\Return \\label{step.return}\n\\Else\n  \\State Split \\(D\\) into \\(b\\)-bit chunks\n  \\(D_{0},\\ldots,D_{(\\delta/b)-1}\\).\n  \\For{\\(i=0,\\ldots,(\\delta/b)-1\\)}\n  \\State\\label{step.multiply}Set \\(\\mathcal{D}_{i} = D_{i}E_{\\mathcal{T}}\\bmod N\\)\n  \\Comment Nonzero only if \\(E_{\\mathcal{T}}\\neq 0\\).\n  \\State Set \\(Y_{i+c_{\\mathcal{T}}} =\n  Y_{i+c_{\\mathcal{T}}}+\\mathcal{D}_{i}\\bmod N\\)\n  \\EndFor\n  \\State Set \\(c_{\\mathcal{T}} = c_{\\mathcal{T}}+(\\delta/b)\\)\n\\EndIf\n\n\\EndFor\n\\State{\\textbf{Output}}: \\(Y_{0},\\ldots,Y_{r-1}\\)\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example, Without Encryption}\n  Let's look at how the response would look on the first four $(T,D)$ pairs that\n  pass through the algorithm.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example Setup, Without Encryption}\n  Suppose that among our search terms are $T$ and $T'$, with \n  \\begin{align*}\n    H_k(T) &= j\\text{ and}\\\\\n    H_k(T') &= j'.\n  \\end{align*}~\\\\\n\n  \n  Suppose that $T''$, with $H_k(T'')=j''$, is \\emph{not} a search term.\\\\~\\\\\n\n  Let the responder see, in order, the pairs $(T, D^0)$, $(T', D^1)$,\n  $(T'', D^2)$, $(T, D^3)$.\\\\~\\\\\n\n  The $Y_i$ are formed by summing down the columns in following matrices.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example Start, Without Encryption}\n  No terms have yet been evaluated.\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n   {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n {\\footnotesize$j$} & 0                        & $\\cdots$                         & 0                         & 0                         & $\\cdots$                         & 0                         \\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n {\\footnotesize$j'$}  & 0                      & $\\cdots$                           & 0                           & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & 0 & $\\cdots$                           & 0         & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n  $c_{j} = 0$, $c_{j'} = 0$, $c_{j''} = 0$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example: First Term, Without Encryption}\n  $(T, D^0)$ enters and is proccessed; hit:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n     {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize $\\bm{D^0_0} 2^{jb}$}                         & $\\cdots$                         & {\\footnotesize $\\bm{D^0_{\\delta/b-1}} 2^{jb}$}                      & 0                         & $\\cdots$                         & 0                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & 0 & $\\cdots$                           & 0                           & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & 0 & $\\cdots$                           & 0         & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n  $\\bm{c_{j} = \\delta/b}$, $c_{j'} = 0$, $c_{j''} = 0$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example Second Term, Without Encryption}\n  $(T', D^1)$ enters and is proccessed; hit:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n     {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize ${D^0_0} 2^{jb}$}                         & $\\cdots$                         & {\\footnotesize ${D^0_{\\delta/b-1}} 2^{jb}$}                      & 0                         & $\\cdots$                         & 0                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & {\\footnotesize $\\bm{D^1_0} 2^{j'b}$} & $\\cdots$                           & {\\footnotesize $\\bm{D^1_{\\delta/b-1}} 2^{j'b}$}                           & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & 0 & $\\cdots$                           & 0         & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n  $c_{j} = \\delta/b$, $\\bm{c_{j'} = \\delta/b}$, $c_{j''} = 0$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example Third Term, Without Encryption}\n  $(T'', D^2)$ enters and is proccessed; no hit:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n     {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize ${D^0_0} 2^{jb}$}                         & $\\cdots$                         & {\\footnotesize ${D^0_{\\delta/b-1}} 2^{jb}$}                      & 0                         & $\\cdots$                         & 0                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & {\\footnotesize ${D^1_0} 2^{j'b}$} & $\\cdots$                           & {\\footnotesize ${D^1_{\\delta/b-1}} 2^{j'b}$}                           & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & {\\footnotesize $\\bm{D^2_0} \\cdot 0$}  & $\\cdots$                           & {\\footnotesize $\\bm{D^2_{\\delta/b-1}} \\cdot 0$}     & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n$c_{j} = \\delta/b$, $c_{j'} = \\delta/b$, $\\bm{c_{j''} = \\delta/b}$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response Example Fourth Term, Without Encryption}\n  $(T, D^3)$ enters and is proccessed; hit:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n     {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize ${D^0_0} 2^{jb}$}                         & $\\cdots$ & {\\footnotesize ${D^0_{\\delta/b-1}} 2^{jb}$}                      & {\\footnotesize $\\bm{D^3_0} 2^{jb}$}                         & $\\cdots$ & {\\footnotesize $\\bm{D^3_{\\delta/b-1}} 2^{jb}$}                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & {\\footnotesize ${D^1_0} 2^{j'b}$} & $\\cdots$                           & {\\footnotesize ${D^1_{\\delta/b-1}} 2^{j'b}$}                           & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & {\\footnotesize $\\bm{D^2_0} \\cdot 0$}  & $\\cdots$                           & {\\footnotesize $\\bm{D^2_{\\delta/b-1}} \\cdot 0$}     & 0                      & $\\cdots$                           & 0\\\\\n    $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n  $\\bm{c_{j} = 2\\delta/b}$, $c_{j'} = \\delta/b$, $c_{j''} = \\delta/b$.\n\\end{frame}\n\n\\section{Result, Without Encryption}\n\\begin{frame}\n  \\frametitle{Result, Without Encryption}\n  The algorithm for getting the results out of the response return is\n  straightforward. To begin,\\\\~\\\\\n  \\begin{itemize}\n    \\item Write $Y_i = \\sum_{k=0}^{\\tau - 1} 2^{kb}P_{ki}$ in base $2^b$, where\n      $P_{ki}$ is the value of the $k^{\\text{th}}$ row in the\n      $i^{\\text{th}}$ column. Note each $P_{ki}$ is $b$-bits long, and therefore\n      $Y_i < N$.\n    \\item $Y_i$ will have data on search term $T$ if and only if $T$ was\n      seen $i+1$ times before the responder returned.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Result Algorithm, Without Encryption}\n  \\begin{algorithm}[H]\n\n  \\caption{Data recovery, plaintext version}\\label{alg.plain_recover}\n\\begin{algorithmic}[1]\n  \\State Set \\(M = 2^{j b}(2^{b}-1)\\)\n  \\Comment $b$ $1$s left-shifted $jb$ places.\n  \\For{\\(\\eta=1,\\ldots,(rb/\\delta)\\)}\n  \\Comment At most \\(rb/\\delta\\) hits can be returned.\n  \\For{\\(i=0,\\ldots,(\\delta/b)-1\\)}\n  \\Comment Each hit uses \\(\\delta/b\\) chunks.\n  \\State\\label{step.mask}Set \\(D_{i} = Y_{(\\eta-1)(\\delta/b)+i}\\&M\\)\n  \\Comment ``\\(\\&\\)'' denotes bit-wise \\texttt{AND}.\n  \\State\\label{step.shift}Set \\(D_{i} = D_{i}/2^{jb}\\)\n  \\Comment Step \\ref{step.mask} ensures \\(2^{jb}\\mid D_{i}\\)\n  \\EndFor\n  \\State Set \\(X_{\\eta} = D_{0}\\|D_{1}\\|\\ldots\\|D_{(\\delta/b)-1}\\)\n  \\EndFor\n  \\State \\Return \\(X_{1},\\ldots,X_{(rb/\\delta)}\\)\n  \\Comment the data corresponding to selector \\(T_{j}\\)\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\section{Wideskies Algorithm, With Encryption}\n\\begin{frame}\n  \\frametitle{Adding Encryption To The Mix}\n  Adding encryption is straightforward. The following slides have the\n  encryption-enabled algorithms, with the differences from the earlier slides\n  in bold.\n\\end{frame}\n\n\\section{Query, Encrypted}\n\\begin{frame}\n  \\frametitle{Query, Encrypted}\n  \\begin{algorithm}[H]\n  \\caption{Query formation, ciphertext version 1}\\label{alg.cipher_form_1}\n\\begin{algorithmic}[1]\n  \\State\\label{step.key_2}Choose a random key \\(k\\) for \\(H\\).\n  \\State Compute \\(H_{k}(T_{0}),\\ldots,H_{k}(T_{\\tau-1})\\).\n  \\While{\\(\\mathrm{card}\\left(\\{H_{k}(T_{0}),\\ldots,H_{k}(T_{\\tau-1})\\}\\right)\n    < \\tau\\)}\n  \\State \\Goto{step.key_2}\n  \\EndWhile\n  \\For{\\(i=0,\\ldots,2^{\\ell}-1\\)}\n  \\State Set\n  {\n  \\bfseries\\boldmath\n  \\begin{equation*}\n    \\mathcal{E}_{i} = \\left\\{\\begin{array}{l l}\n        \\mathcal{E}(2^{jb}) & \\mbox{ if }i=H_{k}(T_{j})\\mbox{ for some\n        }j\\in\\{0,\\ldots,\\tau-1\\} \\\\\n        \\mathcal{E}(0) & \\mbox{ otherwise.}\n      \\end{array}\n    \\right.\n  \\end{equation*}}\n  \\EndFor\n  \\State \\Return \\(\\{\\mathcal{E}_{0},\\ldots,\\mathcal{E}_{2^{\\ell}-1}, H,\n  k, N\\}\\)\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\section{Response, Encrypted}\n\\begin{frame}\n  \\frametitle{Response Initialization, Encrypted}\n  As before, we must initialize some values before forming the response.\n  \\begin{enumerate}\n    \\item $c_0,\\ldots,c_{2^\\ell - 1} = 0$, counters to keep track of the number\n      of times each {\\boldmath $\\mathcal{E}_\\mathcal{T}$} has been seen.\n    \\item {\\bfseries\\boldmath $Y_0,\\ldots,Y_{r-1} = 1$, response vectors.}\n  \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Response, Encrypted}\n  \\begin{algorithm}[H]\n  \\caption{Stream processing, ciphertext version}\\label{alg.cipher_processing}\n\\begin{algorithmic}[1]\n\\State \\textbf{Input}:  $\\mathbf{T} = \\{ (T,D) \\}$\n\\State \\textbf{Initialize:}\n\\State \\qquad Counters $c_i = 0 \\, , \\, 0 \\leq i \\leq (2^l -1)$\n\\State \\qquad Paillier ciphertext values  $\\mathcal{Y}_{j} = 1 \\, , \\, 0 \\leq j \\leq (r-1)$\n\\For{$(T,D) \\in \\mathbf{T}$}\n  \\State Compute \\(\\mathcal{T} = H_{k}(T)\\)\n  \\If{\\(c_{\\mathcal{T}}+\\frac{\\delta}{b} > r\\)}\n  \\State \\Return\n  \\Else\n  \\State Split \\(D\\) into \\(b\\)-bit chunks,\n  \\(D=D_{0},\\ldots,D_{(\\delta/b)-1}\\) \\label{step.datachunk}\n  \\For{\\(i=0,\\ldots,(\\delta/b)-1\\)}\n  \\State {\\bfseries\\boldmath Set \\(\\mathcal{D}_{i} =\n  \\mathcal{E}_{\\mathcal{T}}^{D_{i}}\\bmod N^{2}\\)}\n  \\State {\\bfseries\\boldmath Set \\(\\mathcal{Y}_{i+c_{\\mathcal{T}}} =\n  \\mathcal{Y}_{i+c_{\\mathcal{T}}}\\mathcal{D}_{i}\\bmod N^{2}\\)}\n  \\EndFor\n  \\State Set \\(c_{\\mathcal{T}} = c_{\\mathcal{T}}+(\\delta/b)\\)\n  \\EndIf\n\\EndFor\n\\State{\\textbf{Output}}: \\(\\mathcal{Y}_{0},\\ldots,\\mathcal{Y}_{r-1}\\)\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\section{Result, Encrypted}\n\\begin{frame}\n  \\frametitle{Result, Encrypted (and then Decrypted)}\n  Actually literally the same algorithm as before is used; the only difference\n  is that we first decrypt the encrypted $\\mathcal{Y}_i$.\n\\end{frame}\n\n\\section{Distributed Version}\n\\begin{frame}\n  \\frametitle{Distributed Version}\n  The paper goes over how to do the distributed version; the change is\n  straightforward, and our earlier example slides make it easy to see how it\n  works.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Distributed Difference:\\\\ Unencrypted Sums, Encrypted Products}\n  Recall our example matrix:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.55cm}  c  C{1.55cm}  C{1.55cm}  c  C{1.55cm}  }\n     {\\scriptsize Index}             & $Y_0$\\qquad            & $\\cdots$\\qquad         & $Y_{\\delta/b-1}$\\qquad & $Y_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $Y_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize ${D^0_0} 2^{jb}$}                         & $\\cdots$ & {\\footnotesize ${D^0_{\\delta/b-1}} 2^{jb}$}                      & {\\footnotesize ${D^3_0} 2^{jb}$}                         & $\\cdots$ & {\\footnotesize ${D^3_{\\delta/b-1}} 2^{jb}$}                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & {\\footnotesize ${D^1_0} 2^{j'b}$} & $\\cdots$                           & {\\footnotesize ${D^1_{\\delta/b-1}} 2^{j'b}$}                           & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & {\\footnotesize $\\bm{D^2_0} \\cdot 0$}  & $\\cdots$                           & {\\footnotesize $\\bm{D^2_{\\delta/b-1}} \\cdot 0$}     & 0                      & $\\cdots$                           & 0\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Distributed Difference:\\\\ Unencrypted Sums, Encrypted Products}\n  When we moved to an encrypted algorithm, all of the $D_i$-long sums of\n  $E_i$ became\n  $\\mathcal{E}_i^{\\mathcal{D}_i}$.\\\\~\\\\\n  In the distributed version, we actually make matrix components rather than\n  the fake matrix of $D_i$ in certain bit-positions we had earlier.\\\\~\\\\\n  \n  In the matrix, rows are indexed by $0 \\leq \\mathcal{T} \\leq 2^\\ell\n  -1$, columns by $0 \\leq j \\leq r-1$.\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Distributed Difference:\\\\ Unencrypted Sums, Encrypted Products}\n  As before, let \n  \\begin{align*}\n    H_k(T) &= j,\\\\\n    H_k(T') &= j',\\text{ and}\\\\\n    H_k(T'') &= j'',\n  \\end{align*}\n  with $T$ and $T'$ search terms and $T''$ not.\\\\~\\\\\n  Notice that this time we won't simply discard the data $D_2$ from $T''$;\n  we no longer multiply it by zero, but use it as the exponent of\n  $\\mathcal{E}_{j''}$, which is an encryption of $0$.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Distributed Difference:\\\\ Unencrypted Sums, Encrypted Products}\n  The matrix in the encrypted setting:\n  \\begin{center}\n  \\begin{tabular}{c  C{1.35cm}  c  C{1.35cm}  C{1.35cm}  c  C{1.35cm}  }\n     {\\scriptsize Index}             & $\\mathcal{Y}_0$\\qquad            & $\\cdots$\\qquad         & $\\mathcal{Y}_{\\delta/b-1}$\\qquad & $\\mathcal{Y}_{\\delta/b}$\\qquad   & $\\cdots$\\qquad         & $\\mathcal{Y}_{2\\delta/b-1}$\\qquad\\\\\\toprule\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j$} & {\\footnotesize $\\mathcal{E}_j^{D^0_0}$} & $\\cdots$ & {\\footnotesize $\\mathcal{E}_j^{D^0_{\\delta/b-1}}$}                      & {\\footnotesize $\\mathcal{E}_j^{D^3_0}$}                         & $\\cdots$ & {\\footnotesize $\\mathcal{E}_j^{D^3_{\\delta/b-1}}$}                         \\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j'$}  & {\\footnotesize $\\mathcal{E}_{j'}^{D^1_0}$} & $\\cdots$                           & {\\footnotesize $\\mathcal{E}_{j'}^{D^1_{\\delta/b-1}}$}                           & 1                      & $\\cdots$                           & 1\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\n     {\\footnotesize$j''$}  & {\\footnotesize $\\mathcal{E}_{j''}^{D^2_0}$} & $\\cdots$                           & {\\footnotesize $\\mathcal{E}_{j''}^{D^2_{\\delta/b-1}}$}                           & 1                      & $\\cdots$                           & 1\\\\\n     $\\vdots$ & \\multicolumn{6}{l}{$\\qquad$}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Algorithm In Matrix Form}\n  \\begin{algorithm}[H]\n  \\caption{Responder -  Matrix Variant}\\label{alg.matrix_processing}\n\\begin{algorithmic}[1]\n  \\State {\\scriptsize \\textbf{Input:}  $\\mathbf{T} = \\{ (T,D) \\}$}\n\\State{\\scriptsize  \\textbf{Initialize:}}\n\\State{\\scriptsize  \\qquad Counters $c_i = 0 \\, , \\, 0 \\leq i \\leq (2^l -1)$}\n\\State{\\scriptsize  \\qquad Paillier ciphertext values  $\\mathcal{Y}_{j} = 1 \\, , \\, 0 \\leq j \\leq (r-1)$}\n\\For{\\scriptsize {$(T,D) \\in \\mathbf{T}$}}\n\\State{\\scriptsize  Compute \\(\\mathcal{T} = H_{k}(T)\\)}\n\\Comment{\\scriptsize  View as the row index of $M: m_{\\mathcal{T}, \\, j}$}\n  \\If{\\scriptsize {\\(c_{\\mathcal{T}}+\\frac{\\delta}{b} > r\\)}}\n  \\State{\\scriptsize  \\Return}\n\\Else{\\scriptsize }\n  \\State{\\scriptsize  Split \\(D\\) into \\(b\\)-bit chunks, \\(D=D_{0}\\|D_{1}\\|\\ldots\\|D_{(\\delta/b)-1}\\)}\n  \\For{\\scriptsize {\\(k=0,\\ldots,(\\delta/b)-1\\)}}\n  \\State{\\scriptsize  Set \\(m_{\\mathcal{T}, \\, c_{\\mathcal{T}}+k} = \\mathcal{E}_{\\mathcal{T}}^{D_{k}}\\bmod N^{2}\\)}\n  \\EndFor{\\scriptsize }\n  \\State{\\scriptsize  Set \\(c_{\\mathcal{T}} = c_{\\mathcal{T}}+(\\delta/b)\\)}\n \\EndIf{\\scriptsize }\n\\EndFor{\\scriptsize }\n\\For{\\scriptsize {$0\\leq j \\leq (r-1)$}:}\n\\State{\\scriptsize  \\qquad \\qquad $\\mathcal{Y}_{j} \\, = \\,  \\prod_{i = 0}^{2^l -1} m_{i,j}$ }\n\\EndFor{\\scriptsize }\n\\State{\\scriptsize {\\textbf{Output}}: \\(\\mathcal{Y}_{0},\\ldots,\\mathcal{Y}_{r-1}\\)}\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Distributed Algorithm}\n  \\begin{algorithm}[H]\n  \\caption{Responder -  Distributed Variant}\\label{alg.dist_processing}\n\\begin{algorithmic}[1]\n  \\State {\\scriptsize \\textbf{Input:}  $\\mathbf{T} = \\{ (T,D) \\}$}\n\\For{\\scriptsize {$(T,D) \\in \\mathbf{T}$} in parallel}\n\\State{\\scriptsize  Compute \\(\\mathcal{T} = H_{k}(T)\\)}\n\\Comment{\\scriptsize  View as the row index of $M: m_{\\mathcal{T}, \\, j}$}\n  \\State{\\scriptsize  Split \\(D\\) into \\(b\\)-bit chunks, \\(D=D_{0}\\|D_{1}\\|\\ldots\\|D_{(\\delta/b)-1}\\)}\n\\State{\\scriptsize  Form $\\mathbf{D} = \\{D_k : 0 \\leq k \\leq (\\delta/b)-1\\}$}\n\\State{\\scriptsize  \\textbf{Emit} $(\\mathcal{T}, \\mathbf{D})$}\n  \\EndFor{\\scriptsize }\n \\For{\\scriptsize  {each $\\mathcal{T}$} in parallel}\n\\State{\\scriptsize  Initialize $c_{\\mathcal{T}} = 0$}\n\\While{\\scriptsize  {$c_{\\mathcal{T}} <  r$}}\n\\For{\\scriptsize {each $(\\mathcal{T}, \\mathbf{D})$} }\n\\For{\\scriptsize  {each $D_k \\in \\mathbf{D} \\, , \\, 0 \\leq k \\leq \\ldots,(\\delta/b)-1$}}\n  \\State{\\scriptsize  Set \\(m_{\\mathcal{T}, \\, c_{\\mathcal{T}}} = \\mathcal{E}_{\\mathcal{T}}^{D_{k}}\\bmod N^{2}\\)}\n\\State{\\scriptsize  \\textbf{Emit} $(c_{\\mathcal{T}}, m_{\\mathcal{T}, \\, c_{\\mathcal{T}}})$}\n\\State{\\scriptsize  $ c_{\\mathcal{T}} = c_{\\mathcal{T}} +  1$}\n\\EndFor{\\scriptsize }\n\\EndFor{\\scriptsize }\n\\EndWhile{\\scriptsize }\n\\EndFor{\\scriptsize }\n\\For{\\scriptsize {$0\\leq j \\leq (r-1)$ in parallel}:}\n\\State{\\scriptsize  \\qquad \\qquad $\\mathcal{Y}_{j} \\, = \\,  \\prod_{i = 0}^{2^l -1} m_{i,j}$ }\n\\EndFor{\\scriptsize }\n\\State{\\scriptsize {\\textbf{Output}}: \\(\\mathcal{Y}_{0},\\ldots,\\mathcal{Y}_{r-1}\\)}\n\\end{algorithmic}\n\\end{algorithm}\n\\end{frame}\n\n\\section{`Actual' Example}\n\\begin{frame}\n  \\frametitle{Actual Example Setup}\nWe run through the above with actual numbers.\\\\~\\\\\nLet\n\\begin{itemize}\n  \\item $N = 35$, $p=5$, $q=7$, $\\lambda(N) = 12$, $B=5$.\n  \\item $\\tau$, the number of terms we'll search for, is $2$. These terms are\n    $T_0 = 0$ and $T_1 = 3$.\n  \\item We won't specify most of $H$; only that $\\ell=4$, $H(T_0) = 0110 = 6$ and\n    $H(T_3) = 0010 = 2$.\n  \\item Our return data are $\\delta=4$ bits long; let $b=2$. We limit ourselves\n    to $r=4$.\n  \\item Let's consult an RNG to choose values of $\\zeta$ for use in Paillier.\n\\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Let's Consult an RNG}\n  \\begin{center}\n  \\includegraphics[width=2.5in,keepaspectratio]{random_number.png}\n\\end{center}\n\\bigskip \\bigskip {\\scriptsize Source:\n  \\url{http://imgs.xkcd.com/comics/random_number.png}, used under\n  \\url{http://www.xkcd.com/license.html}}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Actual Example Setup}\n  Great, we will randomly set $\\zeta = 4$ for all encryptions.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example Query}\n  \\begin{itemize}\n    \\item Since $H(T_0) = 6$, \n      \\begin{align*}\n        \\mathcal{E}_6 &= \\mathcal{E}(2^{0\\cdot2})\\\\\n          &= 639\n      \\end{align*}\n    \\item Similarly, since $H(T_1) = 2$, \n      \\begin{align*}\n        \\mathcal{E}_2 &= \\mathcal{E}(2^{1\\cdot2})\\\\\n          &= 359.\n      \\end{align*}\n    \\item All other terms are encryptions of $0$; we will write these as $1$\n      even though they would in fact be distributed across a wide array of\n      values in \\zmodntunits.\n  \\end{itemize}\n\\end{frame}\n\n\n\\begin{frame}\n  \\frametitle{Example Response}\n  Suppose, as in our example above, that the responder inputs, in order, are\n  $(T_0,D^0)$, $(T_1,D^1)$, $(5, D^2)$, and $(T_0,D^3)$, after\n  which point the responder returns (perhaps another $T_0$ comes in, thus causing\n  $c_{\\mathcal{T}_0}$ to be greater than $r$). Here, \n  \\begin{align*}\n    D^0 &= 0000 = (D^0_0, D^0_1) = (00, 00),\\\\\n    D^1 &= 0110 = (D^1_0, D^1_1) = (01, 10),\\\\\n    D^2 &= 0111 = (D^2_0, D^2_1) = (01, 11),\\\\\n    D^3 &= 0010 = (D^3_0, D^3_1) = (00, 10),\\\\\n  \\end{align*}~\\\\\n\n  Note that since $5$ is not a search term, it will result in raising an\n encrypted zero to $D^2=7$; again, we're just going to write $1$, even though the\n  acutal algorithm may (will) have any encryption of $0$ instead.\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example Response Matrix}\n  The responder forms the matrix\n  \\begin{center}\n  \\begin{tabular}{c  C{2.25cm}  C{2.25cm}  C{2.25cm}  C{2.25cm}  }\n     {\\scriptsize Index}             & $\\mathcal{Y}_0$ & $\\mathcal{Y}_1$ & $\\mathcal{Y}_2$ & $\\mathcal{Y}_{3}$\\\\\\toprule\n     $\\vdots$ & \\multicolumn{4}{l}{$\\qquad$}\\\\\n     {\\footnotesize{\\tiny $2$}} & {\\tiny $\\mathcal{E}_2^{D^1_0}\\mod N^2 = 359$} & {\\tiny $\\mathcal{E}_2^{D^1_1}\\mod N^2 = 256$}      & 1                      & 1\\\\\n     {\\tiny $\\vdots$} & \\multicolumn{4}{l}{{\\tiny $\\qquad$}}\\\\\n     {\\footnotesize{\\tiny $6$}}  & {\\tiny $\\mathcal{E}_6^{D^0_0} \\mod N^2 = 1$} & {\\tiny$\\mathcal{E}_6^{D^0_1}\\mod N^2 = 1$} & {\\tiny $\\mathcal{E}_6^{D^3_0}\\mod N^2 = 1$}    &  {\\tiny $\\mathcal{E}_6^{D^3_1}\\mod N^2 = 396$} \\\\   \n     {\\footnotesize{\\tiny $7$}}  & 1 & 1 & 1                      & 1\\\\\n     {\\tiny $\\vdots$} & \\multicolumn{4}{l}{{\\tiny $\\qquad$}}\\\\\\bottomrule\n  \\end{tabular}\n  \\end{center}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example Responses}\n  The only interesting responses are $\\mathcal{Y}_0 = 359$, $\\mathcal{Y}_1=256$, and $\\mathcal{Y}_3 = 396$ (products are taken down columns).\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example Result}\n  We decrypt to $Y_0=0100$, $Y_1 =8 = 1000 $ and $Y_3 = 2 = 0010$, and then run through the processing algorithm:\n  \\begin{itemize}\n    \\item Data For $T_0$: $M=0011$\n      \\begin{itemize}\n        \\item $X_1 = 0$: \n          \\begin{itemize}\n            \\item $D_0 = (Y_0 \\& 0011)/2^0 = 00$\n            \\item $D_1 = (Y_1 \\& 0011)/2^0 = 00$\n          \\end{itemize} \n        \\item $X_2 = 2$:\n          \\begin{itemize}\n            \\item $D_0 = (Y_2 \\& 0011)/2^0 = 00$\n            \\item $D_1 = (Y_3 \\& 0011)/2^0 = 10$\n          \\end{itemize}\n      \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}\n  \\frametitle{Example Result}\n  We decrypted to $Y_0 = 0100$, $Y_1 =8 = 1000 $ and $Y_3 = 2 = 0010$, and then run through the processing algorithm:\n  \\begin{itemize}\n    \\item Data For $T_1$: $M=1100$.\n      \\begin{itemize}\n        \\item $X_1 = 6$: \n          \\begin{itemize}\n            \\item $D_0 = (Y_0 \\& 1100)/2^2 = 01$\n            \\item $D_1 = (Y_1 \\& 1100)/2^2 = 10$\n          \\end{itemize} \n        \\item $X_2 = 0$:\n          \\begin{itemize}\n            \\item $D_0 = (Y_2 \\& 1100)/2^2 = 00$\n            \\item $D_1 = (Y_3 \\& 1100)/2^2 = 00$\n          \\end{itemize}\n      \\end{itemize}\n  \\end{itemize}\n  These results are precisely the data the responder had.$^*$\\\\~\\\\\n  {\\tiny *: We cannot distinguish the fact that $X_2$ is a non-response\n  from the possibility that $X_2$ represents an actual return of a datum $D=0$\nfrom the responder. In practice, one must avoid using $D=0$ to eliminate this\nambiguity}\n\\end{frame}\n\\end{document} \n", "meta": {"hexsha": "5018ae05bd6fd2b89fc93a04d08827bef0be500b", "size": 41938, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "contrib/math_deck/math_deck.tex", "max_stars_repo_name": "rrockenbaugh/incubator-pirk", "max_stars_repo_head_hexsha": "d17a9f6de3bf77a053b495a225897791d251d295", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 63, "max_stars_repo_stars_event_min_datetime": "2016-06-19T13:47:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-04T21:04:27.000Z", "max_issues_repo_path": "contrib/math_deck/math_deck.tex", "max_issues_repo_name": "rrockenbaugh/incubator-pirk", "max_issues_repo_head_hexsha": "d17a9f6de3bf77a053b495a225897791d251d295", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 109, "max_issues_repo_issues_event_min_datetime": "2016-07-14T13:32:09.000Z", "max_issues_repo_issues_event_max_datetime": "2017-02-09T08:08:07.000Z", "max_forks_repo_path": "contrib/math_deck/math_deck.tex", "max_forks_repo_name": "rrockenbaugh/incubator-pirk", "max_forks_repo_head_hexsha": "d17a9f6de3bf77a053b495a225897791d251d295", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2016-07-14T03:21:17.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-27T16:37:51.000Z", "avg_line_length": 42.4044489383, "max_line_length": 309, "alphanum_fraction": 0.5999809242, "num_tokens": 14758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.40304564567922774}}
{"text": "% declare document class and geometry\n\\documentclass[12pt]{article} % use larger type; default would be 10pt\n\\usepackage[english]{babel} % for hyphenation dictionary\n%\\setdefaultlanguage{english} % polyglossia command for use with XeTeX / LuaTeX\n\\usepackage[margin=1in]{geometry} % handle page geometry\n\n% import packages and commands\n\\input{../header2.tex}\n\n% title information\n\\title{Phys 221A -- Quantum Mechanics -- Lec19}\n\\author{UCLA, Fall 2014}\n\\date{\\formatdate{8}{12}{2014}} % Activate to display a given date or no date (if empty),\n         % otherwise the current date is printed \n         % format: formatdate{dd}{mm}{yyyy}\n\n\\begin{document}\n\\maketitle\n\n\n\\section{More angular momentum}\n\nRecall from last time that we have a complete set of commuting operators in $J_z, \\v J^2$. This set has ``non-rotational'' degrees of freedom. Furthermore we have\n\\begin{gather}\n\\v J^2 = J_z^2 + \\frac{1}{2} (J_+ J_- + J_- J_+), \\\\\n[\\v J^2, J_z] = 0.\n\\end{gather}\nSo we have a set of simultaneous eigenstates $\\ket{a,b}$ with eigenvalues\n\\begin{eqn}\n\\v J^2 \\ket{a,b} = a \\ket{a,b}, \\qquad\nJ_z \\ket{a,b} = b \\ket{a,b}.\n\\end{eqn}\nSince our operators $\\v J^2, J_z$ are Hermitian we know of course that $a,b \\in \\R$. \n\nNow, how can we determine the eigenvalues? We can use the commutation relations\n\\begin{eqn}\n[J_z, J_\\pm] = \\pm \\hbar J_\\pm, \\qquad\n[\\v J^2, J_\\pm] = 0\n\\end{eqn}\nwhere we know that\n\\begin{eqn}\nJ_\\pm \\ket{a,b} \\propto \\ket{a, b \\pm \\hbar}.\n\\end{eqn}\nSo we find that\n\\begin{gather}\nJ_z (J_\\pm \\ket{a,b}) = (b \\pm \\hbar) J_\\pm \\ket{a,b} \\\\\n\\v J^2 (J_\\pm \\ket{a,b}) = a (J_\\pm \\ket{a,b}).\n\\end{gather}\nFurthermore we know that\n\\begin{align}\na &= \\matrixel[0]{a,b}{\\v J^2}{a,b} \\\\\n\t&= b^2 + \\matrixel[0]{a,b}{J_x^2 + J_y^2}{a,b} \\\\\n\t&\\geq b^2\n\\end{align}\nso there must be exist a maximum and minimum $b_\\mathrm{max}, b_\\mathrm{min}$ value of $b$. Then since\n\\begin{eqn}\n0 = \\matrixel[0]{a,b_\\mathrm{max}}{J_\\pm J_\\mp}{a, b_\\mathrm{max}} \n\\end{eqn}\nwe have\n\\begin{eqn}\n0 = a - b_\\mathrm{max}^2 - \\hbar b_\\mathrm{max} = a - b_\\mathrm{min}^2 - \\hbar b_\\mathrm{min}.\n\\end{eqn}\nso that we must have $b_\\mathrm{min} = -b_\\mathrm{max}$. Then due to the ladder operator nature of $J_\\pm$ we have\n\\begin{eqn}\nb_\\mathrm{max} = b_\\mathrm{min} + n \\hbar = \\frac{n\\hbar}{2}, \\qquad\nn \\in \\Z\n\\end{eqn}\nSo, defining $j = b_\\mathrm{max} / \\hbar = n/2$ and $m = b / \\hbar$, we have\n\\begin{gather}\na = b_\\mathrm{max} (b_\\mathrm{max} + \\hbar) = \\hbar^2 j (j+1) = 0, \\frac{1}{2}, 1, \\frac{3}{2}, \\dots, \\\\\nb = \\hbar m = -j, -j+1, \\dots, j-1, j.\n\\end{gather}\n\nIt is convenient and standard to denote the eigenstates by $\\ket{j,m}$ instead of $\\ket{a,b}$. So for each value of $j = 0, \\frac{1}{2}, 1, \\frac{3}{2}, \\dots$ we have a ladder of $2j+1$ states\n\\begin{eqn}\n\\ket{j,j}, \\ket{j,j-1}, \\dots, \\ket{j,-j+1}, \\ket{j,-j}\n\\end{eqn}\neach of which can be obtained from its neighbors by acting upon it with $J_\\pm$, up to a multiplying factor\n\\begin{eqn}\nJ_\\pm \\ket{j,m} = c^\\pm_{jm} \\ket{j, m \\pm 1}.\n\\end{eqn}\nWe can determine these factor sy working out the matrix element\n\\begin{align}\n\\abs[0]{c^\\pm_{jm}}^2 \n\t&= \\matrixel[0]{j,m}{J^\\dagger_\\pm J_\\pm}{j,m} \\\\\n\t&= \\matrixel[0]{j,m}{\\v J^2 - J_z^2 \\mp \\hbar J_z}{j,m} \\\\\n\t&= \\hbar^2 (j \\mp m) (j \\pm m + 1),\n\\end{align}\nthus up to an arbitrary phase we have\n\\begin{eqn}\nc^\\pm_{jm} = \\hbar \\sqrt{(j \\mp m) (j \\pm m + 1)}.\n\\end{eqn}\nFinally, for the general matrix element of $J_\\pm$ we have\n\\begin{eqn}\n\\matrixel[0]{j,m}{J_\\pm}{j',m'} = c^\\pm_{jm} \\delta_{j'j} \\delta_{m',m\\pm1}.\n\\end{eqn}\n\nNow, recall that for $j=1/2$ we have the usual spinor representation\n\\begin{eqn}\nJ_z = \\frac{\\hbar}{2} \\pmat{ 1 & 0 \\\\ 0 & -1}. \n\\end{eqn}\nMore generally, for arbitrary $j$ we have\n\\begin{eqn}\nJ_z = \\hbar \n\\begin{pmatrix}\nj & & & & \\\\\n& j-1 & & & \\\\\n& & \\ddots & & \\\\\n& & & -j+1 & \\\\\n& & & & -j\n\\end{pmatrix}.\n\\end{eqn}\nTo find the eigenstates for the full Hilbert space, we can follow this procedure:\n\\begin{enumerate}\n\\item ``Diagonalize'' $\\v J^2$, collecting eigenkets with the largest possible $J_z$, i.e. find all $\\v J^2$ eigenstates. This gives us all possible $\\ket{j,j}$s. \n\\item Next, orthonormalize them (e.g. using Gram-Schmidt) to generate other quantum numbers $n$ unrelated to $\\v J^2$, giving us kets $\\ket{n,j,j}$. \n\\item Finally, we can obtain the full kets via\n\\begin{eqn}\n\\ket{n,j,m} = \\frac{(J_-)^{j-m} \\ket{n,j,j}}{c^-_{1m} c^-_{2m} \\cdots c^-_{j-m,m}}.\n\\end{eqn}\n[This looks wrong, should be $c^-_{j,j} c^-_{j,j-1} \\cdots c^-_{j,j-m}$ ?]\n\\end{enumerate}\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "f607332c7460e6bede91dfc344a538372bbf9fef", "size": 4527, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "quantum/lec19.tex", "max_stars_repo_name": "paulinearriaga/phys-ucla", "max_stars_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "quantum/lec19.tex", "max_issues_repo_name": "paulinearriaga/phys-ucla", "max_issues_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "quantum/lec19.tex", "max_forks_repo_name": "paulinearriaga/phys-ucla", "max_forks_repo_head_hexsha": "48084dbbac2f8a4748c1fdaaf63a4cebaae16809", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5572519084, "max_line_length": 193, "alphanum_fraction": 0.6392754584, "num_tokens": 1772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.40304564567922774}}
{"text": "\\section{Review of Parallel Computational Models}\n\\label{sec:BackgroundModel}\n\nThe basic computer architecture is known as von Neummann architecture or von Neumman model. This model has the following components: a memory; an arithmetic-logic unit (ALU); a central processing unit (CPU), composed of several registers; and a control unit. New technologies and computational models began to be developed simultaneously with the evolution of the von Neumann model. \n\nIn 1972, Michael Flynn proposed a classification of parallel computing architectures. This classification distinguishes the number of instructions and the number of data that can be computed in parallel~\\citep{flynn1996parallel}. This classification is presented in the Table \\ref{tab:taxFlynn}.\n\n\\begin{table}[htpb]\n\\begin{center}\n\\begin{tabular}{|r|c|c|}\n\\hline\n& \\bf Single Instruction & \\bf Multiple Instruction\\\\\\hline \n\\bf Single Data & SISD & MISD \\\\\\hline \n\\bf Multiple Data & SIMD & MIMD \\\\\\hline \n\\end{tabular}\n\\end{center}\n\\caption{Classification of parallel architectures proposed by Michael Flynn (1972).} \n\\label{tab:taxFlynn}\n\\end{table}\n\nWe can illustrate the table above as follows. A von Neumann model machine that has only one processing core fits the SISD (Single Instruction; Single Data) classification; a machine with multiple processing cores can be classified as MIMD; GPUs are classified on the SIMD architecture, where each thread takes index to perform vector computations, for this the programming model of CUDA is named SIMT (Single Instruction; Multiple Threads).\n\nParallel computing models have been an active research topic since the development of modern computers~\\citep{Gibbons1983:QRQW,Juurlink:1998,Skillicorn:1998:MLP}; their main goal is to provide a standard way of describing and evaluating the performance of parallel applications. For the success of a parallel computing model, it is paramount to also consider the characteristics of the underlying architecture of the hardware being used.\n\n\nMathematical models are simplified abstraction of a real situation. A important area of the computer science is related with the analysis, design and development of algoritmh that are implemented in real machines. A first and general example is the RAM model (Random-Access Memory). This model is an abstraction of a classic computer with a single processor. More and not a few models were created based on the RAM model.\n\nIn computing, granularity is associated with the amount of computation in relation to communication, that is, the ratio of computation to the amount of communication. Parallelism of fine granularity means relatively small amounts of computational work are done between communication events\nLow computation to communication ratio. Coarse and Bulk granularity is the opposite: data transfers are less frequent, and present large amounts of computation. Parallelism of coarse or Bulk granularity means relatively large amounts of computational work are done between communication events, high computation to communication ratio. The finer granularity have greater potential for parallelism and consequently the increase in speed, but the overhead costs of synchronization and communication are expensive in terms of latency.\n\nThe main objective of a parallel computing model is to provide a set of parameters to be considered in the implementation of a parallel algorithm. These parameters can be used to simulate the behavior of applications that will run on different parallel platforms. To facilitate the programming and simulation of these applications, models with specific properties to parallel programming problems have been created~\\citep{Skillicorn:1998:MLP}. The most important parallel models in the litearature are the PRAM (Parallel Random Access Memory), LogP, BSP (Bulk Synchonous Parallel) and CGM (Coarse Grained Multicomputer). They are explained below.\n\n\\subsection{Parallel Random Access Machine Model (PRAM)}\nThe PRAM model was created by~\\cite{Fortune:1978:PRAM}. This model is a simple extension of the RAM model. It consists of an infinite set of processors and a centralized shared memory by all processors. Figure \\ref{fig:Pram} shows graphically the PRAM model\n\n\\begin{figure}[htpb]\n\\centering\n\\includegraphics[scale=.6]{./images/Pram.png}\n\\caption{PRAM  model (\\textit{Parallel Random Access Machine.})}\n\\label{fig:Pram}\n\\end{figure}\n\nThe advantage of the PRAM model is its simplicity and its similarity to the sequential model of von Neumann. The processor can only read or write a memory address in one cycle. The cost of writing is equal to the cost of reading, and is also equal to the cost of any operation performed by the processor. However, in spite of its simplicity, due to the increase in the distance between the processing and the speed of communication, this model has become more and more unrealistic.\n\nDifferent submodels were created from the PRAM model. Researchers have made adaptations varying the way of access to memory, trying to avoid the maximum of conflicts in the communication. The different adaptations have arisen to propose concurrent or exclusive communications at the moment to access to shared memory~\\citep{Gibbons19983:QRQW, Karp:CSD-88-408}. \n\n\\subsection{Bulk Synchronous Parallel Model (BSP)}\nThe BSP model was introduced by~\\cite{Valiant:1990}. The BSP model offers a simple abstraction of parallel architectures, see Figure \\ref{fig:BSP}. In Figure~\\ref{fig:BSP} a set of processors are running local computations in a superstep and before the synchronization, all the messages are delivered and ready to be used in the next superstep.\n\n\\begin{figure}[htpb]\n\\centering\n% \\includegraphics[scale=.7]{./images/bspmodel.eps}\n\\includegraphics[scale=.7]{./images/bspmodel.png}\n\\caption{Superstep in a Bulk Synchronous Parallel Model.}\n\\label{fig:BSP}\n\\end{figure}\n\nThe BSP model bridges the essential characteristics of different kinds of machines as a combination of three attributes:\n\n\\begin{itemize}\n\\item a set of virtual processors, each associated to a local memory;\n\\item a router, that delivers the messages in a point-to-point manner;\n\\item a synchronization mechanism.\n\\end{itemize}\n\nThe execution of a parallel application is organized in a sequence of \\emph{supersteps}, each one divided into three successive---logically disjointed---phases.\nOn the first phase, all processors use their local data to perform local sequential computations in parallel (i.e., there is no communication among the processors). The second phase is a communication phase, where all nodes exchange data performing personalized all-to-all communication. The last phase consists of a global synchronization barrier, that guarantees that all messages were delivered and all processors are ready to start the next superstep. \n\nFigure~\\ref{fig:BSP} depicts the phases of a BSP application. In this figure, a processor distributes tasks to a set of processors that execute local computations and communicate in a global form, if necessary. All processors wait for the others finish their tasks in a synchronization barrier, to be able to execute the next task. Sending and receiving messages between processors is only allowed at the end of each super-step.\n\nOn the BSP model there is no restriction on sending messages, but all of them should be received before the synchronization barrier. According to the execution model, the first and second phase may occur simultaneously. A BSP algorithm consists of an arbitrary number of super-steps. The BSP model has been widely used on different applications contexts. HPC practitioners have been using the BSP model to design algorithms and software that can run on any standard architecture with guaranteed performance \\cite{AlgGPU,Goldberg2004,CamargoGKG06}. Consider a BSP program that runs on $S$ supersteps. Let $g$ be the bandwidth of the network and $L$ the latency---i.e., the minimum duration of a superstep---which reflects not only the latency of the network, but also the overhead of the synchronization step. The cost to execute the $i$-th superstep is then given by:\n\n\\begin{equation}\n  \\label{eq:superstep-cost}\n  w_i + g h_i + l\n\\end{equation}\n\nwhere $w_i$ is the maximum amount of local computations executed, and $h_i$ is the largest number of packets sent or received by any processor during the superstep. If $W = \\sum_{i=1}^{S} w_i$ is the sum of the maximum work executed on all supersteps and $H = \\sum_{i=1}^{S} h_i$ the sum of the maximum number of messages exchanged in each superstep, then the total execution time of the parallel application is given by:\n\\begin{equation}\n  \\label{ec:BSP}\n  T = W + g H + L S\n\\end{equation}\n\nA BSP algorithm, consequently, can be completely modeled by the parameters $(w, h, g, l)$. Using these parameters, the approximate execution time of a BSP algorithm can be characterized. One of the great advantages of the BSP model is that it facilitates to develop parallel programs on different systems and architectures, serving as a bridge between the programmer who develop parallel applications in massively parallel architectures.\n\n\\subsubsection{Multi-BSP model}\nThe Multi-BSP model is an adaptation of the BSP model, the BSP model is commonly used in a distributed memory parallel environment, and multi-BSP is a BSP extension for multi-core processors. ~\\cite{Valiant:2011} created the Multi-BSP model which is used in a parallel shared memory environment. Computational models, such as multi-BSP, allow abstraction of the complexity of the problem in a simplification that is not significantly away from the reality of current computational  architectures.  \n\nMulti-BSP is a multi-level model that has explicit parameters at each level: number of processors $p$, memory/cache sizes $m$, communication latency costs $g$ and synchronization costs $L$. The multi-BSP model of an architecture with depth $d$ will be determined by $4d$ numeric parameters, $(p1, g1, L1, m1), (p2, g2, L2, m2), ( P3, g3, L3, m3), ..., (pd, gd, Ld, md)$. At each level the four parameters quantify, respectively, the number of subcomponents, processors, communication bandwidth, synchronization cost, and memory/cache size~\\citep{BSPMeasures}.\n\nMulti-BSP and BSP are important models that allow bridging the analysis, design and development of parallel algorithms, but they are not useful to design algorithms that are executed in massively parallel architectures. New models of performance prediction of applications that run on GPUs have arisen from adaptations of the models in this literature review.\n\n\\subsection{Coarse Grained Multicomputer Model (CGM)}\n\\cite{Dehne:2002} studied the problem of designing scalable parallel geometric algorithms for coarse grained cases. They called this model as Coarse Grained Multicomputer model (CGM), which is very efficient for a large set of problems of the ratio $\\frac{n}{p}$, with $n$ the size of the problem and $p$ the number of processors. In other words, the CGM model is very good for addressing problems where the problem of size $n$ can be divided between an determined number of processors $p$. A CGM algorithm is a special case of a BSP algorithm where all communication operations of a super-step are done in $h$ relations. A fundamental difference between the BSP model and CGM is that the first captures real machine parameters while the CGM is an abstraction that allows to develop efficient algorithms in parallel machines.\n\nAn algorithm on a CGM machine can be modeled using only two parameters, $N$ and $p$. This algorithm consists of an alternating sequence of computing and communication rounds also separated by a synchronization barrier. A computational/communication round of the CGM model corresponds to a super-step of the BSP model with communication cost $g(N/p)$. A good performance of algorithms with the CGM model is achieved by minimizing the number of super-steps, the total time of local computations and the total size of the messages.\n\n\\subsection{LogP Model}\nSynchronization of a large group of processes or threads is expensive in terms of latency, especially on architectures with classification MIMD. For these cases, parallel computing models without synchronization were created. The most popular of these models is the logP model.\n\nLogP model was proposed by \\citet{Culler:1993:LogP} and received its name exactly for the variables of the model. Culler et. al. perceived that the PRAM model was not realistic due to the lack of parameters to represent communication costs in parallel applications, especially for distributed applications. The parameters used to describe a parallel system according to LogP model are:\n\n\\begin{itemize}\n\\item[L:] \\textit{Latency} - caused by communicating a message from a source to a destiny processor.\n\\item[o:] \\textit{Overhead} - time during which a processor is busy sending or receiving a message, during that time it can not do\ncomputations.\n\\item[g:] \\textit{Gap} - minimum time between consecutive message transmissions or between receiving consecutive messages; the reciprocal of $g$ corresponds to the bandwidth of the system.\n\\item[P:] \\textit{Processors}.\n\\end{itemize}\n\n", "meta": {"hexsha": "4fd59be385b1a16a403405a9f514545738e83de6", "size": 13158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/thesis/sections/models.tex", "max_stars_repo_name": "marcosamaris/svm-gpuperf", "max_stars_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-06-03T18:32:48.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-03T18:32:48.000Z", "max_issues_repo_path": "docs/thesis/sections/models.tex", "max_issues_repo_name": "marcosamaris/svm-gpuperf", "max_issues_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/thesis/sections/models.tex", "max_forks_repo_name": "marcosamaris/svm-gpuperf", "max_forks_repo_head_hexsha": "35b81711089273c775f143ecaeadae03ebf5910a", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 118.5405405405, "max_line_length": 867, "alphanum_fraction": 0.8020215838, "num_tokens": 2840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.40304564567922774}}
{"text": "\\chapter{DERIVATION OF THE $\\Upsilon$ FUNCTION}%\r\n\\label{appendixC}\r\n\r\n%\\clearpage %remove this command if your appendix doesn't start with a landscaped page!!!!!\r\n%\\thispagestyle{plain}\r\n%\\begin{landscape}\r\n%\\begin{figure}\r\n\r\n % \\begin{center}\r\n  %  \\includegraphics[width=6in]{LaTeX2e_logo.eps}\r\n   % \\caption{\\LaTeX 2\\ensuremath{\\epsilon.} logo}\\label{biglogo}\r\n  %\\end{center}\r\n%\\end{figure}\r\n%\\end{landscape}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\r\n%ADD LABEL\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\proposition{The Upsilon Function}\\label{first}\r\n\r\n(1) If $\\beta>0$ and $\\alpha\\neq0$, then for all $n\\geq-1$,\r\n\r\n$$I_{n}(c;\\alpha; \\beta; \\delta) = - \\frac{e^{\\alpha c}}{\\alpha} \\sum_{i=0}^{n}(\\frac{\\beta}{\\alpha})^{n-i} Hh_{i}(\\beta c -\\delta)$$\r\n\r\n$$+ (\\frac{\\beta}{\\alpha})^{n+1} \\frac{\\sqrt{2 \\pi}}{\\beta} e^{\\frac{\\alpha \\delta}{\\beta}+\\frac{\\alpha^{2}}{2\\beta^{2}}} \\phi(-\\beta c + \\delta + \\frac{\\alpha}{\\beta})$$\r\n(2) If $\\beta<0$ and $\\alpha<0$, then for all $x \\geq -1$\r\n\r\n$$I_{n}(c;\\alpha; \\beta; \\delta) = - \\frac{e^{\\alpha c}}{\\alpha} \\sum_{i=0}^{n}(\\frac{\\beta}{\\alpha})^{n-i} Hh_{i}(\\beta c -\\delta)$$\r\n\r\n$$- (\\frac{\\beta}{\\alpha})^{n+1} \\frac{\\sqrt{2 \\pi}}{\\beta} e^{\\frac{\\alpha \\delta}{\\beta}+\\frac{\\alpha^{2}}{2\\beta^{2}}} \\phi(\\beta c - \\delta - \\frac{\\alpha}{\\beta})$$\r\n\r\n\\begin{proof}{Case 1.}\r\n\r\n$\\beta>0$ and $\\alpha\\neq0$. Since, for any constant $\\alpha$ and $n \\geq 0$, $e^{\\alpha x} Hh_{n}(\\beta x - \\delta) \\rightarrow 0$ as $x \\rightarrow \\infty$ thanks to (B4), integration by parts leads to\r\n\r\n$$I_{n}=-\\frac{1}{\\alpha}Hh(\\beta c -\\delta) e^{\\alpha c} + \\frac{\\beta}{\\alpha}\\int_{c}^{\\infty} e^{\\alpha x} Hh_{n-1}(\\beta c - \\delta)dx$$\r\n\r\nIn other words, we have a recursion, for $n \\geq 0$, $I_{n}=-(e^{\\alpha c}{\\alpha})Hh_{n}(\\beta c - \\delta) + (\\frac{\\beta}{\\alpha})I_{n-1}$ with\r\n\r\n$$I_{-1}=\\sqrt{2 \\pi} \\int_{c}{\\infty}e^{\\alpha x}\\varphi(-\\beta x +\\delta)dx$$\r\n\r\n$$=\\frac{\\sqrt{2 \\pi}}{\\beta} e^{\\frac{\\alpha \\delta}{\\beta}+\\frac{\\alpha^{2}}{2 \\beta^{2}}}\\phi(-\\beta c + \\delta +\\frac{\\alpha}{\\beta})$$\r\n\r\nSolving it yields, for $n \\geq -1$,\r\n\r\n$$I_{n}=-\\frac{e^{\\alpha c}}{\\alpha}\\sum_{i=0}^{n}(\\frac{\\beta}{\\alpha})^{i}Hh_{n-i}(\\beta c+\\delta) + (\\frac{\\beta}{\\alpha})^{n+1}I_{-1}$$\r\n\r\n$$=-\\frac{e^{\\alpha c}}{\\alpha}\\sum_{i=0}^{n}(\\frac{\\beta}{\\alpha})^{n-i} Hh_{i}(\\beta c+\\delta)$$\r\n\r\n$$+ (\\frac{\\beta}{\\alpha})^{n+1}\\frac{\\sqrt{2 \\pi}}{\\beta} e^{\\frac{\\alpha \\delta}{\\beta}+\\frac{\\alpha^{2}}{2 \\beta^{2}}}\\phi(-\\beta c + \\delta +\\frac{\\alpha}{\\beta})$$\r\n\r\nwhere the sum over an empty set is defined to be zero.\r\n\\end{proof}\r\n\r\nCase2. $\\beta<0$ and $\\alpha<0$. In this case, we must also have, for $n \\geq 0$ and any constant $\\alpha<0, e^{\\alpha x}Hh_{n}(\\beta x -\\delta) \\rightarrow 0$ as\r\n\r\n$x \\rightarrow \\infty$, thanks to (B5). Using integration by parts, we again have the same recursion, for $n \\geq 0, I_{n}=-(e^{\\alpha c}/\\alpha)Hh_{n}(\\beta c - \\delta)+(\\beta / \\alpha)I_{n-1}$, but with a different initial condition\r\n\r\n$$I_{-1}=\\sqrt{2 \\pi}\\int_{c}^{\\infty}e^{\\alpha x}\\varphi(-\\beta x + \\delta)dx$$\r\n\r\n$$=-\\frac{\\sqrt{2 \\pi}}{\\beta} exp\\{\\frac{\\alpha \\delta}{\\beta}+\\frac{\\alpha^{2}}{2 \\beta^{2}}\\}\\phi(\\beta c - \\delta -\\frac{\\alpha}{\\beta})$$\r\n\r\nSolving it yields (B8), for $n \\geq -1$.\r\n\r\nFinally, we sum the double exponential and the normal random variables\r\n\r\nProposition B.3.\r\n\r\nSuppose $\\{\\xi_{1},\\xi_{2},...\\}$ is a sequence of i.i.d. exponential random variables with rate $\\eta>0$, and Z is a normal variable with distribution $N(0,\\sigma^{2})$. Then for every $ n \\geq 1$, we have: (1) The density functions are given by:\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=(\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}Hh_{n-1}(-\\frac{t}{\\sigma}+\\sigma\\eta)$$\r\n\r\n$$f_{Z-\\sum_{i=1}^{n}\\xi_{i}}(t)=(\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}Hh_{n-1}(\\frac{t}{\\sigma}+\\sigma\\eta)$$\r\n(2) The tail probabilities are given by\r\n\r\n$$P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x) = (\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}I_{n-1}(x;-\\eta,-\\frac{1}{\\sigma},-\\sigma\\eta)$$\r\n\r\n$$P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x) = (\\sigma\\eta)^{n}\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}e^{-t\\eta}I_{n-1}(x;\\eta,\\frac{1}{\\sigma},-\\sigma\\eta)$$\r\n\r\nProof. Case 1. The densities of $Z+\\sum_{i=1}^{n}\\xi_{i}$, and $Z-\\sum_{i=1}^{n}\\xi_{i}$. We have\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=\\int_{-\\infty}^{\\infty}f_{\\sum_{i=1}^{n}\\xi_{i}}(t-x)f_{Z}(x)dx$$\r\n\r\n$$=e^{-t\\eta}(\\eta^{n})\\int_{-\\infty}{t}\\frac{e^{x\\eta}(t-x)^{n-1}}{(n-1)!}\\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-x^{2}/(2\\sigma^{2})}dx$$\r\n\r\n$$=e^{-t\\eta}(\\eta^{n})e^{(\\sigma\\eta)^{2}/(2)}\\int_{-\\infty}{t}\\frac{(t-x)^{n-1}}{(n-1)!}\\frac{1}{\\sigma\\sqrt{2\\pi}}e^{-(x-\\sigma^{2}\\eta)^{2}/(2\\sigma^{2})}dx$$\r\n\r\nLetting $y=(x-\\sigma^{2}\\eta)/\\sigma$ yields\r\n\r\n$$f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)=e^{-t\\eta}(\\eta^{n})e^{(\\sigma\\eta)^{2}/(2)}\\sigma^{n-1}$$\r\n\r\n$$\\times\\int_{-\\infty}^{t/\\sigma-\\sigma\\eta}\\frac{(t/\\sigma - y -\\sigma\\eta)^{n-1}}{(n-1)!}\\frac{1}{\\sqrt{2\\pi}}e^{-y^{2}/2}dy$$\r\n\r\n$$=\\frac{e^{(\\sigma\\eta)^{2}/2}}{\\sqrt{2\\pi}}(\\sigma^{n-1}\\eta^{n})e^{-t\\eta}Hh_{n-1}(-t/\\sigma + \\sigma\\eta)$$\r\n\r\nbecause $(1/(n-1)!)\\int_{-\\infty}{a}(a-y)^{n-1}e^{-y^{2}/2}dy=Hh_{n-1}(a)$. The derivation of $f_{Z+\\sum_{i=1}^{n}\\xi_{i}}(t)$ is similar.\r\n\r\nCase 2. $P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x)$ and $P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x)$. From (B9), it is clear that\r\n\r\n$$P(Z+\\sum_{i=1}^{n}\\xi_{i}\\geq x)=\\frac{(\\sigma\\eta)^{n}e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}\\int_{x}^{\\infty}e^{(-i\\eta)}Hh_{n-1}(-\\frac{t}{\\sigma}+\\sigma\\eta)dt$$\r\n\r\n$$=\\frac{(\\sigma\\eta)^{n}e^{(\\sigma\\eta)^{2}/2}}{\\sigma\\sqrt{2\\pi}}I_{n-1}(x;-\\eta,-\\frac{1}{\\sigma},-\\sigma\\eta)dt$$\r\n\r\nby (B6). We can compute\r\n$P(Z-\\sum_{i=1}^{n}\\xi_{i}\\geq x)$ similarly.\r\n\r\n\\theorem{Theorem} With $\\pi_{n}:= P(N(t)=n)=e^{-\\lambda T}(\\lambda T)^{n}/n!$ and $I_{n}$ in Proposition \\ref{first}.\r\n, we have\r\n\r\n$$P(Z(T)\\geq a)=\\frac{e^{(\\sigma \\eta_{1})^{2} T/2}}{\\sigma \\sqrt{2 \\pi T}} \\sum_{n=1}^{\\infty} \\pi_{n} \\sum_{k=1}^{n} P_{n,k}(\\sigma\\sqrt{T}\\eta_{1})^{k}\\times I_{k-1}(a-\\mu T; -\\eta_{1},-\\frac{1}{\\sigma\\sqrt{T}},-\\sigma\\eta_{1}\\sqrt{T})$$\r\n\r\n$$+\\frac{e^{(\\sigma\\eta_{2})^{2}T/2}}{\\sigma\\sqrt{2\\pi T}}\\sum_{n=1}^{\\infty}\\pi_{n}\\sum_{k=1}^{n}Q_{n,k}(\\sigma\\sqrt{T}\\eta_{2})^{k}$$\r\n\r\n$$\\times I_{k-1}(a-\\mu T; \\eta_{2},\\frac{1}{\\sigma\\sqrt{T}},-\\sigma\\eta_{2}\\sqrt{T})$$\r\n\r\n$$+\\pi_{0}\\phi(-\\frac{a-\\mu T}{\\sigma\\sqrt{T}})$$\r\n\r\nProof by the decomposition (B2)\r\n\r\n$$P(Z(T) \\geq a)= \\sum_{n=0}^{\\infty}\\pi_{n} P(\\mu T +\\sigma\\sqrt{T} Z + \\sum_{j=1}^{n}Y_{j} \\geq a)$$\r\n\r\n$$=\\pi_{0}P(\\mu T +\\sigma\\sqrt{T} Z  \\geq a)$$\r\n\r\n$$+\\sum_{n=1}^{\\infty}\\pi_{n}\\sum_{k=1}^{n}P_{n,k} P(\\mu T +\\sigma\\sqrt{T} Z + \\sum_{j=1}^{n}\\xi_{j}^{+} \\geq a)$$\r\n\r\n$$+\\sum_{n=1}^{\\infty}\\pi_{n}\\sum_{k=1}^{n}Q_{n,k} P(\\mu T +\\sigma\\sqrt{T} Z - \\sum_{j=1}^{n}\\xi_{j}^{-} \\geq a)$$\r\n\r\nThe result now follows via (B11) and (B12) for $\\eta_{1} > 1$ and $\\eta_{2} >0$.\r\n\r\n\r\n", "meta": {"hexsha": "acf300aabeafbc04be6f7c8fd49f2d7e0a120503", "size": 7089, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixC.tex", "max_stars_repo_name": "mshahriarinia/neonDSR", "max_stars_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-12-17T17:00:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-28T14:28:35.000Z", "max_issues_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixC.tex", "max_issues_repo_name": "mshahriarinia/neonDSR", "max_issues_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/matlab/lidar/crown_segmentation/temp/proposal/appendix/appendixC.tex", "max_forks_repo_name": "mshahriarinia/neonDSR", "max_forks_repo_head_hexsha": "1fbb1938637cd3b2b510874b2062c66063e57ad2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-12-13T13:57:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-28T01:36:28.000Z", "avg_line_length": 52.5111111111, "max_line_length": 248, "alphanum_fraction": 0.542671745, "num_tokens": 3083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4030456414914083}}
{"text": "\\par\n\\chapter{{\\tt SubMtx}: Submatrix object}\n\\par\nThe {\\tt SubMtx} object was created to hold the data for and operate\nwith a submatrix of a sparse matrix.\nThe entries in a submatrix can be either double precision \nreal or complex.\n\\par\nFor example, the lower and upper triangular matrices $L$ and $U$\nthat are created during the factorization are stored as\nsubmatrices,\ne.g., $L_{I,I}$ and $L_{J,I}$ where $I$ and $J$ are index sets.\nTo be more precise, $I$ and $J$ are index sets associated with\nfronts {\\tt I} and {\\tt J}.\nWe do not necessarily represent $L_{J,I}$, \nbecause some of the rows in the submatrix may be zero.\nInstead we keep $L_{\\bnd{I}\\cap J,I}$, where\n$\\bnd{I} \\cap J$ are precisely those rows that may have nonzeros.\nThe situation is similar for $U$ where we keep $U_{I,\\bnd{I}\\cap J}$.\n\\par\nThe submatrices for $L$ and $U$ may be dense or sparse.\n(A direct factorization typically generates dense submatrices\nwhile a drop tolerance factorization produces sparse submatrices.)\nWe also use {\\tt SubMtx} objects to represent submatrices of the\n$D$ matrix, where $D$ is either diagonal or has $1 \\times 1$ and\n$2 \\times 2$ blocks on its diagonal.\nIn the latter case, we support $D_{I,I}$ to be either \nreal symmetric, complex symmetric or complex Hermitian.\n\\par\nThe {\\tt SubMtx} object has the following attributes.\n\\begin{itemize}\n\\item\nA {\\tt SubMtx} object has a row id and column id to identify itself\nwithin the context of a larger block matrix.\n\\item\nEach row and column of the block matrix corresponds \nto a certain index set.\nA {\\tt SubMtx} object associated with block row {\\tt J} \nand block column {I} has row indices $J$ and column indices $I$.\n\\item\nMatrix entries stored in one of the following ways.\n\\begin{itemize}\n\\item dense by rows, i.e., dense and row major\n\\item dense by columns, i.e., dense and column major\n\\item sparse using dense subrows\n\\item sparse using dense subcolumns\n\\item sparse using sparse rows\n\\item sparse using sparse columns\n\\item sparse using $(i,j,a_{i,j})$ triples\n\\item a diagonal matrix\n\\item a block diagonal symmetric matrix where the blocks are \n      $1 \\times 1$ or $2 \\times 2$, used in the symmetric\n      indefinite factorization.\n\\item a block diagonal Hermitian matrix where the blocks are \n      $1 \\times 1$ or $2 \\times 2$, used in the hermitian\n      indefinite factorization.\n\\end{itemize}\n\\item\nThe {\\tt SubMtx} object can be self-contained, in the sense that\nits structure contains a {\\tt DV} object that manages a contiguous\nvector of workspace that is used to store all information about the\n{\\tt SubMtx} object --- its scalar parameters, any integer index\nor dimension information, and all matrix entries.\nIn a distributed environment, \nthis allows a {\\tt SubMtx} object to be sent between processors\nas one message, no copying to an internal buffer is needed,\nnor any custom data type needs to be defined as for MPI.\nIn an out-of-core environment,\na {\\tt SubMtx} object can be read from or written to a file \nby a single operation.\n\\end{itemize}\n\\par\nThe {\\tt SubMtx} object is a superset of the {\\tt DenseMtx} object\nin terms of data structure and functionality.\nIf we were working in a language that supports inheritance,\n{\\tt SubMtx} would be an abstract class and {\\tt DenseMtx} would be\na subclass where entries would be stored by dense rows or columns.\nAt some point in the future we may deprecate the {\\tt DenseMtx}\nobject in this library, replacing it with the {\\tt SubMtx} object.\n\\par\nBecause the {\\tt SubMtx} object wears so many hats, i.e., it supports\nnine different storage formats, it has to be flexible in how it\nresponds to its environment.\nFor example, how we access the data is different depending on which\nstorage format.\nInstead of accessing structure fields directly,\ne.g., let {\\tt mtx->entries} point to the start of the matrix entries,\nwe follow a convention that {\\it instance} methods return\ninformation.\nFor example, the function call\n\\begin{verbatim}\n       SubMtx_columnIndices(mtx, &nrow, &rowind) ;\n\\end{verbatim}\nis an instance method that fills {\\tt nrow} with the number of\nrows and {\\tt rowind} with the first location of the row indices.\nA more complex example is for the sparse storage by rows format,\n\\begin{verbatim}\n       SubMtx_sparseRowsInfo(mtx, &nrow, &nent, &sizes, &indices, &entries) ;\n\\end{verbatim}\nwhere the number of rows and entries are returned in {\\tt nrow}\nand {\\tt nent}, the number of nonzero\nentries in each row is contained in {\\tt sizes[]},\nand the column indices and nonzero entries are found in \n{\\tt indices[]} and {\\tt entries[]}, respectively. \nThis convention of using instance methods to return information\nis better than using explicit structure fields.\nFor example, if we want to extend the object by allowing another\nstorage format, we do not need to increase the size of the structure \nat all --- it is only necessary to provide one or more instance methods\nto return the new information.\n", "meta": {"hexsha": "c7a2f86f96008112fa8ad9e6a37e267250b9327a", "size": 4945, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/intro.tex", "max_stars_repo_name": "alleindrach/calculix-desktop", "max_stars_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/intro.tex", "max_issues_repo_name": "alleindrach/calculix-desktop", "max_issues_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-09-21T17:03:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-25T16:08:31.000Z", "max_forks_repo_path": "ccx_prool/SPOOLES.2.2/SubMtx/doc/intro.tex", "max_forks_repo_name": "alleindrach/calculix-desktop", "max_forks_repo_head_hexsha": "2cb2c434b536eb668ff88bdf82538d22f4f0f711", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-08-29T18:41:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-29T18:41:28.000Z", "avg_line_length": 44.5495495495, "max_line_length": 77, "alphanum_fraction": 0.7551061678, "num_tokens": 1278, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.4030263316598962}}
{"text": "\\documentclass[simplex.tex]{subfiles}\n% NO NEED TO INPUT PREAMBLES HERE\n% packages are inherited; you can compile this on its own\n\\begin{document}\n\\subsection{Network Dependence Test via Diffusion Maps and MGC} \n%% Jan\nDeciphering the association between network structures and corresponding\nnodal attributes of interest is a core problem in network science. We\npropose a new nonparametric procedure for testing dependence between\nnetwork topology and nodal attributes, via diffusion maps and\n\\texttt{MGC}. Specifically, under an exchangeable graph, we verify that\nthe diffusion maps provide a set of conditionally independent\nmultivariate coordinates for the nodes, which can be combined with\n\\texttt{MGC} (or in general, any distance-based correlation measures) to\nyield consistent statistic for network dependence testing. In\nsimulation, the new approach achieves superior testing performance under\na variety of common network models than existing benchmarks. The\ndiffusion maps provides a robust metric compared to adjacency matrix or\ngeodesic distance, while \\texttt{MGC} can better capture nonlinear\ndependencies, with their combined advantages shown in\nFigure~\\ref{fig:threeSBM201701}.  \n\n\\begin{figure}[h!]\n\\begin{cframed}\n\t\t\\centering\n\t\t\\includegraphics[width=0.6\\textwidth]{../../figs/ThreeSBM.png}\n\t\t\\caption{Power comparison for all possible combinations of metrics and correlation measure, under the stochastic block model with three blocks. \\texttt{MGC} with the diffusion maps (DM) yields the best power, comparing to using other metrics like adjacency matrix (AM), latent factors (LF), and other test statistics like distance correlation (mcorr), Heller-Heller-Gorfine (HHG) test, or Fosdick and Hoff (FH) method.}\n\t\t\\label{fig:threeSBM201701}\n\t\t\\end{cframed}\n\\end{figure}\n\n%In order to show that \\texttt{MGC} combined with diffusion maps as a network metrics perform better even in the case arbitrary noisy is added to edges or the attributes in real data, we are doing an experiment on brain network with physical locations as nodal attributes. Our proposed method not only detects the dependence between network topology and nodal attributes but also helps us to reveal possibly diverse dependence patterns through multiscale correlation maps or multiscale statistics as a function of diffusion time.\n\nThis month we made significant progress in writing the manuscript and improving the exposition. The current draft was submitted to ASA Nonparametric Statistics Section Student Paper Awards, and we are notified as finalists for awards and special presentation section in the Joint Statistical Meeting this year. \n\n\\clearpage\n\n%% Feb\n\n\n%% March\nDeciphering the association between network structures and corresponding nodal attributes of interest is a core problem in network science. We propose a new nonparametric procedure for testing dependence between network topology and nodal attributes, via diffusion maps and \\texttt{MGC}. Specifically, under an exchangeable graph, we verify that the diffusion maps provide a set of conditionally independent multivariate coordinates for the nodes, which can be combined with \\texttt{MGC} (or in general, any distance-based correlation measures) to yield consistent statistic for network dependence testing. Moreover, our method is computationally inexpensive and robust against parameter mis-specifications, very efficient in capturing a wide variety of nonlinear and high-dimensional relationships, and readily extend-able to testing independence between two graphs. \n\nFigure~\\ref{fig:threeSBM201703} illustrates the advantage of the proposed method on testing dependency between two graphs. The graphs are simulated by the random dot product graph, with the underlying latent variables being related by a quadratic function. By repeatedly generating dependent sample graphs, the testing power equals the percentage of rejection of the independence hypothesis. Although all methods are consistent (having power $1$ as number of vertices increases), the proposed approach using \\texttt{MGC} is able to achieve perfect testing power at a very small size, which is significantly better than other benchmarks.\n\n\\begin{figure}[h!]\n\\begin{cframed}\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\textwidth]{../../figs/twoGraphs1.pdf}\n\t\t\\caption{The power curve with respect to increasing number of vertices for the two-graph dependency testing simulation. The proposed approach quickly attains perfect power at a very small vertex size, while other benchmarks often require a much larger graph for perfect testing. }\n\t\t\\label{fig:threeSBM201703}\n\t\t\\end{cframed}\n\\end{figure}\n\nAn early draft is recently awarded the Best Student Paper Awards by the American Statistical Association Nonparametric Statistics Section, which will be presented in a special section in the Joint Statistical Meeting this year. We collected and addressed feedback from experts in graph inference, and submitted the complete manuscript this month.\n%\n\n\\clearpage\n\\end{document}\n", "meta": {"hexsha": "4899c0ca29020b991e6784558b6638eee902ef5e", "size": 5005, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Reporting/reports/2017-03Q1/multiscaleNetworkTest.tex", "max_stars_repo_name": "openconnectome/SIMPLEX_Q2", "max_stars_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Reporting/reports/2017-03Q1/multiscaleNetworkTest.tex", "max_issues_repo_name": "openconnectome/SIMPLEX_Q2", "max_issues_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Reporting/reports/2017-03Q1/multiscaleNetworkTest.tex", "max_forks_repo_name": "openconnectome/SIMPLEX_Q2", "max_forks_repo_head_hexsha": "f10a6c4b9548670f9bf8e177914aa8d25fa1230b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 83.4166666667, "max_line_length": 868, "alphanum_fraction": 0.8155844156, "num_tokens": 1055, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301064, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.403026331182254}}
{"text": "%\\documentclass{scrartcl}\n%\\usepackage{beamerarticle}\n%%\\usepackage{dtsc-beamer}\n%\\usepackage{fullpage}\n\n\\documentclass[9pt]{beamer}\n\\usetheme{boxes}\n\\usetheme{Boadilla}\n\\usecolortheme{beaver}\n%\\usecolortheme{sidebartab}\n% \\usefonttheme{structurebold}\n\\usefonttheme{serif}\n\n%gets rid of bottom navigation bars\n\\setbeamertemplate{footline}[page number]{}\n\n%gets rid of navigation symbols\n\\setbeamertemplate{navigation symbols}{}\n\n\n% \\usepackage{helvet}\n\\usepackage{amsmath, amssymb}\n\\usepackage{color}\n%\\usepackage{asymptote}\n\\usepackage{mathrsfs}\n\\usepackage{dsfont}\n\\usepackage{url}\n\\usepackage{cancel}\n\\usepackage{tikz}\n\\usetikzlibrary{fit,positioning}\n\\usetikzlibrary{shapes,matrix,decorations.markings,arrows}\n\\usetikzlibrary{graphs}\n\\usepackage{bbm}\n\\def\\ind{\\mathbbm{1}} %Indicator function\n%\n\\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}\n\\definecolor{notsodarkblue}{rgb}{0.0, 0.0, 0.7}\n\\setbeamercolor{title}{fg=darkblue}\n\\setbeamercolor{frametitle}{fg=darkblue}\n\\newcommand{\\myitem}{\\item[$\\bullet$]}\n\\definecolor{darkgreen}{rgb}{0, 0.55, 0}\n\\definecolor{lgray}{rgb}{0.9,0.9,0.9}\n\n\\newcommand{\\LABFIG}[1]{\\label{fig:#1}}%{\\tt [fig:$\\text{$#1$}$]}}\n\n\n\n\n\\newcommand{\\ve}[1]{\\boldsymbol{#1}}\n\\def\\X{\\ve{X}}\n\\def\\x{\\ve{x}}\n\\def\\y{\\ve{y}}\n\\def\\m{\\ve{m}}\n\\def\\Sig{\\ve{\\Sigma}}\n\\def\\E{\\mathbb{E}}\n\\def\\J{\\ve{J}}\n\\def\\h{\\ve{h}}\n\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\def\\sX{\\mc{X}}\n\\def\\N{\\mc{N}}\n\\newcommand{\\mxf}[3]{m^{#3}_{X_{#1}\\rightarrow f_{#2}}(x_{#1})}\n\\newcommand{\\mfx}[3]{m^{#3}_{f_{#2}\\rightarrow X_{#1}}(x_{#1})}\n\n\n\n\\newcommand\\Def[1]{{\\textbf{Definition:}\\\\\\emph{#1}\\\\\\begin{center} ------------------------ \\end{center}}}\n\\newcommand\\Prop[1]{{\\textbf{\\textcolor{red}{Property:}}\\\\\\emph{#1}\\\\\\begin{center} \\textcolor{red}{------------------------} \\end{center}}}\n\n\\newcommand{\\noteB}[1]{\\textbf{\\textcolor{notsodarkblue}{#1}}}\n\n\\newcommand{\\noteR}[1]{\\textbf{\\textcolor{darkred}{#1}}}\n\n\\newcommand{\\noteG}[1]{\\textbf{\\textcolor{darkgreen}{#1}}}\n\n\\newcommand{\\snoteB}[1]{{\\textcolor{darkblue}{#1}}}\n\n\\newcommand{\\snoteR}[1]{{\\textcolor{darkred}{#1}}}\n\n\\newcommand{\\snoteG}[1]{{\\textcolor{darkgreen}{#1}}}\n\n\n\\newcommand{\\fs}[2]{#2}\n\n\\title[]{Gaussian BP}\n\\author[\\textcolor{white}{Advanced Digital Communications}]{Introduction to Graphical Models and Inference for Communications\\\\\\vspace*{3mm}{\\small \\textcolor{black}{UC3M}}\n}\n%\\date[08/02/2016]{{08/02/2016}}\n\\institute{\\textcolor{white}{}}\n\\AtBeginSection[]\n{\n  \\begin{frame}<beamer>{Index}\n    \\tableofcontents[currentsection,currentsubsection]\n  \\end{frame}\n}\n\n\\begin{document}\n\n\\frame{\n\\titlepage\n\\thispagestyle{empty}\n\\begin{center}\n\\includegraphics[scale=0.05]{Figuras/uc3m-logo.pdf}\n\\end{center}\n}\n\n\n\\frame{\n\\frametitle{Today}\n\n\\begin{itemize}\n\\item One particular scenario: we want to perform inference over Gaussian probability distributions that factorize according to a graphical model\n\\item Factor Graphs.\n\\item Belief Propagation naturally extends to this scenario by replacing summations to integrals (\\emph{Gaussian Belief Propagation}).\n\\item GaBP is exact for Gaussian tree factor graphs.\n\\item GaBP computes the exact mean for graphs with cycles, but approximated covariance matrix.\n\\end{itemize}\n\n\n}\n\n\\section{Multivariate Gaussian distribution}\n\n\n\\frame{\n\\frametitle{Multivariate Gaussian distribution}\nLet $\\X$ be a Gaussian random vector ($\\x\\in\\mathbb{R}^n$). \n\\begin{itemize}\n\\item \\textbf{Covariance form:} the probability density function is \n\\begin{align*}\n\\mu(\\x)=\\frac{1}{(2\\pi)^{n/2}|\\Sig|^{1/2}}\\exp\\left\\{-\\frac{1}{2}(\\x-\\m) ^T \\Sig^{-1}(\\x-\\m) \\right\\}\n\\end{align*}\ndenoted as $\\x\\sim\\mathcal{N}(\\m,\\Sig)$ with mean $\\m=\\E[\\x]$ and covariance matrix $\\Sig=\\E[(\\x-\\m)^T(\\x-\\m)]$.\n\\item \\textbf{Natural form:} the probability density function is \n\\begin{align*}\n\\mu(\\x)\\propto \\exp\\left\\{ -\\frac{1}{2} \\x^T \\ve{J} \\x+\\ve{h}^{T}\\x\\right\\}\n\\end{align*}\ndenoted as $\\x\\sim\\mathcal{N}^{-1}(\\ve{h},\\ve{J})$ with potential vector $\\h$ and \\emph{precision matrix} $\\J$.\n\\item Note $\\J=\\Sig^{-1}$ and $\\h=\\J\\m$.\n\\end{itemize}\n\n\\begin{block}{}\nGaussian graphical models typically describe Gaussian joint probability density functions in \\textbf{natural form}.\n\\end{block}\n\n}\n\n\\frame{\n\\frametitle{Product of two Gaussians}\n\n\\begin{align*}\n&\\mathcal{N}(\\m_a,\\Sig_a)\\mathcal{N}(\\m_b,\\Sig_b)\\\\\n=&\\mathcal{N}^{-1}(\\ve{h}_a,\\ve{J}_a)\\mathcal{N}^{-1}(\\ve{h}_b,\\ve{J}_b)\\\\\n=&\\mathcal{N}^{-1}(\\ve{h}_a+\\h_b,\\ve{J}_a+\\J_b)=\\N(\\m,\\Sig)\n\\end{align*}\nwhere\n\\begin{align*}\n\\Sig=\\left(\\ve{J}_a+\\J_b\\right)^{-1}\\qquad \\m=\\Sig(\\ve{h}_a+\\h_b)\n\\end{align*}\n\n\n\n\n}\n\n\\frame{\n\\frametitle{Marginalization via algebraic manipulation}\n\\begin{itemize}\n\\item Let $\\y=\\ve{A} \\x+ \\ve{v}$, where $\\x\\sim\\mathcal{N}(\\m_x,\\Sig_x)=\\mathcal{N}^{-1}(\\h_x,\\J_x)$ and $\\ve{v}\\sim\\mathcal{N}(\\m_v,\\Sig_v)=\\mathcal{N}^{-1}(\\h_v,\\J_v)$, then\n\\begin{align*}\n\\mu(\\y)&=\\int_{-\\infty}^{\\infty}\\mu(\\y|\\x)\\mu(\\x)d\\x?\n\\end{align*}\n\\end{itemize}\n\n\\begin{align*}\n\\mu(\\y|\\x)\\mu(\\x)\\propto &\\exp\\Big\\{\\frac{-1}{2}\\y^T \\J_v \\y+(\\J_v\\m_v)^T\\y +(\\J_v\\ve{A}\\x)^T\\y-\\frac{-1}{2}\\x^T \\J_x \\x+(\\J_x\\m_x)^T\\x \\Big\\}\\\\\n\\propto&\\Big\\{ \\frac{-1}{2} \\left[\\begin{array}{c}\\y \\\\ \\x \\end{array} \\right]^T \\J_* \\left[\\begin{array}{c}\\y \\\\ \\x \\end{array} \\right] +†\\h^T_* \\left[\\begin{array}{c}\\y \\\\ \\x \\end{array} \\right]  \\Big\\}\n\\end{align*}\nwhere\n\\begin{align*}\n\\J_*=\\left[\\begin{array}{cc} \\J_v & -\\J_v\\ve{A} \\\\ -(\\J_v\\ve{A})^T & \\J_x \\end{array}\\right] \\qquad \\h_*=\\left[\\begin{array}{c}\\h_v \\\\ \\h_x \\end{array}\\right]\n\\end{align*}\n\n}\n\n\\frame{\n\\begin{align*}\n\\J_*=\\left[\\begin{array}{cc} \\J_x & -\\J_v\\ve{A} \\\\ -(\\J_v\\ve{A})^T & \\J_v \\end{array}\\right] \\qquad \\h_*=\\left[\\begin{array}{c}\\h_v \\\\ \\h_x \\end{array}\\right]\n\\end{align*}\n\nMarginalization its easy if we obtain the covariance form of the joint distribution. Applying the matrix inversion lemma:\n\\begin{align*}\n\\left[\\begin{array}{cc} \\J_v & -\\J_v\\ve{A} \\\\ -(\\J_v\\ve{A})^T & \\J_x \\end{array}\\right]^{-1}=\n\\left[\\begin{array}{cc} \n\\ve{S}^{-1} & \\ve{S}^{-1}\\J_v\\ve{A}\\J^{-1}_x \\\\  \\J^{-1}_x(\\J_v\\ve{A})^T\\ve{S}^{-1} & \\J^{-1}_x+\\J^{-1}_x(\\J_v\\ve{A})^T\\ve{S}^{-1} \\J_v\\ve{A}\\J^{-1}_x\n\\end{array}\\right]\n\\end{align*}\nwhere $\\ve{S}=\\J_v-\\J_v\\ve{A}\\J_x^{-1}(\\J_v\\ve{A})^T$.\n\n\\begin{block}{Therefore}\n\\begin{align*}\np(\\y)=\\mathcal{N}^{-1}(\\h_y,\\J_y) \n\\end{align*}\nwhere\n\\begin{align*}\n \\J_y=\\J_v-\\J_v\\ve{A}\\Sig_x\\ve{A}^T\\J_v^T \\qquad \\h_y=\\h_v+\\J_v\\ve{A}\\Sig_x\\h_x\n\\end{align*}\n\\end{block}\n\n}\n\n\\section{Gaussian BP over a particular example}\n\n\\frame{\nLet $X_i\\in\\sX$ $i=1,\\ldots,5$ be a collection of real R.V.  with joint distribution of the form\n\\begin{align*}\n\\mu(\\x)=\\frac{1}{Z}f_1(x_1,x_2)f_2(x_2,x_3)f_3(x_2,x_4)f_4(x_4,x_5)\\prod_{i=1}^{5}g(x_i)\n\\end{align*}\nwhere\n\\begin{align*}\nf_1(x_1,x_2)=\\exp\\{F_{1}x_1x_2\\} \\qquad f_2(x_2,x_3)=\\exp\\{F_{2}x_2x_3\\}\\\\\nf_3(x_2,x_4)=\\exp\\{F_{3}x_2x_4\\} \\qquad f_4(x_4,x_5)=\\exp\\{F_{4}x_4x_5\\}\n\\end{align*}\n and \n\\begin{align*}\ng(x_i)=\\exp\\{b_i x_i-\\frac{1}{2}\\pi_i x_i^2\\}\n\\end{align*}\n\n\\begin{figure}\n\\begin{tabular}{c}\n\\includegraphics[scale=0.5]{Figuras/Graph_1.pdf}\n\\end{tabular}\n\\end{figure}\n%\n%\\begin{block}{Assume we want to compute}\n%\\begin{align*}\n%P(x_1)=\\sum_{\\x\\sim x_1}P(x_1,x_2,x_3,x_4,x_5)\n%\\end{align*}\n%\\textbf{\\textcolor{red}{By brute force... $|\\sX|^{5}$ sums.}} \n%\\end{block}\n%\n%\n\n\n}\n\n\\frame{\n\\begin{itemize}\n\\item $\\mu(\\x)$ is a Gaussian distribution defined in natural form!\n\\end{itemize}\n\\begin{align*}\n\\J&=\\left[\\begin{array}{ccccc}\n\\pi_1 & -F_{1} & 0 & 0 & 0 \\\\\n-F_{1} & \\pi_2 & -F_{2} & -F_{3} & 0\\\\\n0 & -F_{2} & \\pi_3 & 0 & 0 \\\\\n0 &  -F_{3} & 0 & \\pi_4 & -F_{4}  \\\\\n0 & 0 & 0 & -F_{4} &  \\pi_5\n\\end{array}\n\\right]\\\\\\\\\n\\h&=\\left[\\begin{array}{ccccc}\nb_1 & b_2 & b_3 & b_4 & b_5\n\\end{array}\n\\right]^T\n\\end{align*}\n\n\\begin{block}{}\nComputing the mean $\\m$ and covariance matrix $\\Sig$ requires computing $\\Sig=\\J^{-1}$ and $\\m = \\J^{-1} \\h$. $O(n^3)$ cost! \n\\end{block}\n\n\\begin{exampleblock}{}\nBP provides a way to exploit graph structure to perform this\ncomputation in $\\mathcal{O}(n)$ time instead of $O(n^3)$. It is only exact when the graph is a tree!\n\\end{exampleblock}\n\n\\begin{alertblock}{}\nIf the Gaussian graphical model has cycles, GBP still computes the exact $\\m$, but only an estimation to $\\Sig$.\n\\end{alertblock}\n\n}\n\n%\\section{Gaussian BP}\n\n\n\\frame{\n\\frametitle{Gaussian BP algorithm}\n\n\\begin{itemize}\n\\item It is described as a \\emph{message-passing algorithm}.\n\\item Messages represent \\emph{local computations} at each node of the graph.\n\\item The FG has leave factors (only connected to one variable) and pairwise factors (connected to two variables).\n\\item Integrals instead of sums. The rest of the algorithm remains unaltered.\n\\end{itemize}\n\n\\begin{figure}\n\\begin{tabular}{c}\n\\includegraphics[scale=0.5]{Figuras/Graph_4.pdf}\n\\end{tabular}\n\\end{figure}\n\n}\n\n\\frame{\n\\frametitle{Iteration 0}\n\\begin{itemize}\n\\item Messages send by variable nodes are initialized by their  leave factors\n\\end{itemize}\nE.g.\n\\begin{align*}\nm^{0}_{x_2\\rightarrow f_2}(x_2)=g(x_2)=\\exp\\{b_2 x_2-\\frac{1}{2}\\pi_2 x_2^2\\}\\sim \\mathcal{N}^{-1}(b_2,\\pi_2) \\quad   \\text{\\color{blue}{Gaussian message!}}\n\\end{align*}\n\\begin{itemize}\n\\item Messages send by the $f_j$ factors are computed as usual but replacing sums by integrals.\n\\end{itemize}\nE.g.\n\\begin{align*}\nm^{0}_{f_1\\rightarrow x_1}(x_1)&=\\int \\exp\\{F_{1}x_1x_2\\}\\exp\\{b_2 x_2-\\frac{1}{2}\\pi_2 x_2^2\\}  dx_2\\\\\n&=\\int \\exp\\Big\\{-\\frac{1}{2} \\left[\\begin{array}{c} x_1 \\\\ x_2 \\end{array}\\right]^T \\left[\\begin{array}{cc} 0 & -F_1 \\\\ -F_1 & \\pi_2\\end{array} \\right] \\left[\\begin{array}{c} x_1 \\\\ x_2 \\end{array}\\right]+\\left[\\begin{array}{c} 0 \\\\b_2 \\end{array}\\right]^T\\left[\\begin{array}{c} x_1 \\\\ x_2 \\end{array}\\right]\\Big\\} dx_2\\\\\n&\\sim \\mathcal{N}^{-1}(F_1\\pi_2^{-1}b_2,F_1^2\\pi_2^{-1})=\\mathcal{N}^{-1}(h^{0}_{f_1\\rightarrow x_1}, J^{0}_{f_1\\rightarrow x_1})\\quad \\text{\\color{blue}{Gaussian message!}}\n\\end{align*}\n}\n\n\\frame{\n\\frametitle{At iteration $\\ell$}\n\n\\begin{itemize}\n\\item \\textbf{Step 1:} Variable nodes multiply their incoming messages to send a new message to factors.\n\\end{itemize}\nE.g.\n\\begin{align*}\nm^{\\ell}_{x_2\\rightarrow f_3}(x_2)&=\\mathcal{N}^{-1}(h^{\\ell-1}_{f_1\\rightarrow x_2}, J^{\\ell-1}_{f_1\\rightarrow x_2})\\mathcal{N}^{-1}(h^{\\ell-1}_{f_2\\rightarrow x_2}, J^{\\ell-1}_{f_2\\rightarrow x_2})\\\\\n&=\\mathcal{N}^{-1}(h^{\\ell-1}_{f_1\\rightarrow x_2}+h^{\\ell-1}_{f_2\\rightarrow x_2}, J^{\\ell-1}_{f_1\\rightarrow x_2}+J^{\\ell-1}_{f_2\\rightarrow x_2})\\\\\n&=\\mathcal{N}^{-1}(h^{\\ell}_{x_2\\rightarrow f_3}, J^{\\ell}_{x_2\\rightarrow f_3}).\n\\end{align*}\n}\n\n\n\\frame{\n\\frametitle{At iteration $\\ell$}\n\\begin{itemize}\n\\item \\textbf{Step 2:} Factor nodes compute the messages to variable nodes by marginalization.\n\\end{itemize}\nE.g.\n\\begin{align*}\n&m^{\\ell}_{f_3\\rightarrow x_4}(x_4)=\\int \\exp\\{F_{3}x_2x_4\\}\\mathcal{N}^{-1}(h^{\\ell}_{x_2\\rightarrow f_3}, J^{\\ell}_{x_2\\rightarrow f_3})  dx_2\\\\\n&=\\int \\exp\\Big\\{-\\frac{1}{2} \\left[\\begin{array}{c} x_2 \\\\ x_4 \\end{array}\\right]^T \\left[\\begin{array}{cc} 0 & -F_3 \\\\ -F_3 & J^{\\ell}_{x_2\\rightarrow f_3}\\end{array} \\right] \\left[\\begin{array}{c} x_2 \\\\ x_4 \\end{array}\\right]+\\left[\\begin{array}{c} 0 \\\\h^{\\ell}_{x_2\\rightarrow f_3} \\end{array}\\right]^T\\left[\\begin{array}{c} x_2 \\\\ x_4 \\end{array}\\right]\\Big\\} dx_2\\\\\n&\\sim \\mathcal{N}^{-1}(\\frac{F_3 h^{\\ell}_{x_2\\rightarrow f_3}}{J^{\\ell}_{x_2\\rightarrow f_3}},\\frac{F_3^2}{J^{\\ell}_{x_2\\rightarrow f_3}})=\\mathcal{N}^{-1}(h^{\\ell}_{f_3\\rightarrow x_4}, J^{\\ell}_{f_3\\rightarrow x_4})\\quad \\text{\\color{blue}{Gaussian message!}}\n\\end{align*}\n\n\\begin{block}{}\nAll messages are Gaussian! The parameters of the Gaussian messages are computed in closed form without doing any integral! \n\\end{block}\n\n\\begin{exampleblock}{}\nConvergence is guaranteed and achieved in a finite number  $\\ell_*$ of iterations. The overall complexity is $\\mathcal{O}(\\ell_*n)$.\n\\end{exampleblock}\n}\n\n\\section{Gaussian Hidden Markov Models}\n\n\\frame{\n\\frametitle{Gaussian Hidden Markov Models}\n\n\\begin{block}{}\n\\begin{itemize}\n\\item Wireless communication channels.\n\\item Speech processing.\n\\item Tracking applications.\n\\end{itemize}\n\\end{block}\n\n\\begin{figure}\n\\begin{tabular}{c}\n\\includegraphics[scale=0.75]{Figuras/HMM.pdf}\n\\end{tabular}\n\\end{figure}\n\n\n\n}\n\n\\frame{\n\\frametitle{Gaussian Hidden Markov Models}\n\\begin{itemize}\n\\item States $\\x_t\\in\\mathbb{R}^{d}$.\n\\item State transition matrix $\\ve{A}\\in\\mathbb{R}^{d\\times d}$.\n\\item Process noise $\\ve{v}_t\\in\\mathbb{R}^{p}$ and $\\sim\\mathcal{N}(\\ve{0},\\Sig_v)$ for some $\\Sig_v\\in\\mathbb{R}^{p\\times p}$.\n\\item Dynamic equations:\n\\begin{align*}\n\\x_{t+1}=\\ve{A}\\x_t+\\ve{B}\\ve{v}_t\\\\\n\\x_0\\sim \\mathcal{N}(0,\\Sig^{0}_{x})\n\\end{align*}\n\\end{itemize}\n\n\\begin{itemize}\n\\item Noisy observation  $\\y_t\\in\\mathbb{R}^{d'}$:\n\\begin{align*}\n\\y_t=\\ve{C}\\x_t+\\ve{w}_t\n\\end{align*}\nwhere $\\ve{C}\\in\\mathbb{R}^{d'\\times d}$ and $\\ve{w}_t\\sim\\mathcal{N}(0,\\Sig_w)$.\n\\end{itemize}\n\n\\begin{figure}\n\\begin{tabular}{c}\n\\includegraphics[scale=0.6]{Figuras/HMM.pdf}\n\\end{tabular}\n\\end{figure}\n\n}\n\n\\frame{\n\\frametitle{Gaussian Hidden Markov Models}\n\\begin{itemize}\n\\item In summary, for $\\Sig_h=\\ve{B}\\Sig_v\\ve{B}^T$ we have\n\\begin{align*}\n\\x_0&\\sim \\mathcal{N}(0,\\Sig^{0}_{x})\\\\\n\\x_{t+1}|\\x_t &\\sim \\mathcal{N}(\\ve{A}\\x_t,\\Sig_h)\\\\\n\\y_t|\\x_t &\\sim \\mathcal{N}(\\ve{C}\\x_t, \\Sig_w)\n\\end{align*}\n\\item Factorization\n\\begin{align*}\n\\mu(\\x,\\y)=\\mu(x_0)\\mu(\\y_0|x_0)\\mu(\\x_1|\\x_0)\\mu(\\y_1|x_1)\\mu(\\x_2|\\x_1)\\mu(\\y_2|x_2)\\ldots\n\\end{align*}\n\\item Gaussian graphical model with no cycles!! GaBP is exact and cheap!\n\\item This factorization can be expanded as the product of leave factors and pairwise factors.\n\\end{itemize}\n\n\n\n}\n\n\\frame{\n\\frametitle{Inference over Gaussian HMMs}\n\n\\begin{block}{Forward/Backward algorithm}\nGiven $\\y_0,\\y_2,\\ldots,\\y_L$, use GaBP to compute the (Gaussian) marginal for each state $\\x_1,\\x_2,\\ldots,\\x_L$.\n\\end{block}\n\n\\begin{block}{Kalman filter}\nGiven the actual observation $\\y_t$ and the observations in the past $\\y_0,\\y_2,\\ldots,\\y_t-1$, use GaBP to compute the mean of $\\x_t$, $\\mathbb{E}[\\x_t]$.\n\\end{block}\n\n\n}\n\n\\section{Extension to any distribution?}\n\n\\frame{\n\\frametitle{BP over any graphical models}\n\\begin{itemize}\n\\item So far, we have applied BP to discrete and Gaussian graphical models. \n\\item In the Gaussian case, we can avoid integration by algebraic manipulation.\n\\item The same update rules can be applied to any Graphical model. However, integrals of the form \n\\begin{align*}\n\\int_{\\x_j\\sim x_i} f_j(\\x_j) \\prod_{u\\in\\N(f_j)}\\m_{x_u\\rightarrow f_j}(x_u) d(\\x_j\\sim x_i)\n\\end{align*}\nare intractable in general! we cannot solve the integrals!!\n\\end{itemize}\n\n\n\n\n}\n\n\\frame{\n\\begin{block}{Approximate message passing (APM)}\nApproximate BP messages by Gaussian distributions:\n\\begin{itemize}\n\\item Compressed sensing \\url{http://people.ee.duke.edu/~lcarin/AMP1.pdf}\n\\item Efficient multiuser detection in CDMA systems \\url{http://arxiv.org/pdf/0810.1729.pdf}\n\\item Communications over Fading ISI channels:\n\\url{http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=04907469}\n\\item $\\ldots$\n\\end{itemize}\n\\end{block}\n\n\\begin{exampleblock}{Alternatives}\nInstead of approximating the BP messages, construct directly a tractable Gaussian approximation to the joint pdf.\n\\begin{itemize}\n\\item Variational Inference and Mean Field.\n\\item Expectation Propagation.\n\\end{itemize}\n\\end{exampleblock}\n\n\n\n}\n\n\\end{document}\n\n", "meta": {"hexsha": "44ee562084f29dfab16fcbcea1da570aeb8e1e74", "size": 15254, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Slides/4- Gaussian BP/Gaussian_BP.tex", "max_stars_repo_name": "olmosUC3M/-Introduction-to-Graphical-Models-and-Inference-for-Communications", "max_stars_repo_head_hexsha": "e0cb3b71f94c466f104b3b27620df936b4ad1c9a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Slides/4- Gaussian BP/Gaussian_BP.tex", "max_issues_repo_name": "olmosUC3M/-Introduction-to-Graphical-Models-and-Inference-for-Communications", "max_issues_repo_head_hexsha": "e0cb3b71f94c466f104b3b27620df936b4ad1c9a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Slides/4- Gaussian BP/Gaussian_BP.tex", "max_forks_repo_name": "olmosUC3M/-Introduction-to-Graphical-Models-and-Inference-for-Communications", "max_forks_repo_head_hexsha": "e0cb3b71f94c466f104b3b27620df936b4ad1c9a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1306122449, "max_line_length": 372, "alphanum_fraction": 0.6758882916, "num_tokens": 5995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4030263280869489}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{amsmath,amssymb,latexsym}\n\\usepackage{verbatim}\n\\usepackage{braket}\n\\usepackage{fullpage}\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{graphicx}\n\n%% disables automatic indentation\n%% sets indent command to allow for manual indentation\n\\newlength\\tindent\n\\setlength{\\tindent}{\\parindent}\n\\setlength{\\parindent}{0pt}\n\\renewcommand{\\indent}{\\hspace*{\\tindent}}\n\n%% User-defined Commands %%\n\t\n\\newcommand{\\cop}[2]{% \\cop{<state index>}{<spin index>}\n\t\\ensuremath{ \\hat{a} _{#1 #2} ^{\\dagger} }}\n\n\\newcommand{\\aop}[2]{% \\aop{<state index>}{<spin index>}\n\t\\ensuremath{ \\hat{a} _{#1 #2} }}\n\n\\newcommand{\\pcop}[1]{% \\pcop{<state index>}\n\t\\ensuremath{ \\cop{#1}{+} \\cop{#1}{-} } }\n\n\\newcommand{\\paop}[1]{% \\paop{<state index>}\n\t\\ensuremath{ \\aop{#1}{-} \\aop{#1}{+} } }\n\n\\newcommand{\\cpm}[1]{% \\cpm{<state index>}\n\t\\ensuremath{\\cop{#1}{+} \\cop{#1}{-} }}\n\n\\newcommand{\\amp}[1]{% \\apm{<state index>}\n\t\\ensuremath{ \\aop{#1}{-} \\aop{#1}{+} } }\n\n\\newcommand{\\sz}[2]{% \\sz{<<state index>}{<spin index>>}\n\t\\ensuremath{ \\frac{1}{2} \\sum_{#1 #2} #2 a _{#1 #2} ^{\\dagger} a _{#1 #2} } }\n\n\\newcommand{\\splus}[1]{% \\splus{<state index>}\n\t\\ensuremath{ \\sum_{#1}  a _{#1 +} ^{\\dagger} a _{#1 -} } }\n\n\\newcommand{\\sminus}[1]{% \\sminus{<state index>}\n\t\\ensuremath{ \\sum_{#1}  a _{#1 -} ^{\\dagger} a _{#1 +} } }\n\t\n\\newcommand{\\hzero}[2]{% \\hzero{<state index>}{<spin index>}\n\t\\ensuremath{ \\sum_{#1 #2} (#1-1) a _{#1 #2} ^{\\dagger} a _{#1 #2} }}\n\n\\newcommand{\\hfull}[4]{% \\hfull{<index 1>}{<index 2>}{<index 3>}{<index 4>}\n\t\\ensuremath{\\sum_{#1 #2} (#1 - 1) \\cop{#1}{#2} \\aop{#1}{#2} - g \\sum_{#3 #4} \\hat{P} ^+ _{#3} \\hat{P} ^- _{#4}  } }\n\n\\newcommand{\\twobody}[2]{% \\twobody{<first index>}{<second index>}\n\t\\ensuremath{ \\sum_{#1 #2} (-g) \\cop{#1}{+} \\cop{#1}{-} \\aop{#2}{-} \\aop{#2}{+}  } }\n\n\\newcommand{\\caop}[2]{% \\caop{<1st indx>}{<2nd indx>}\n\t\\ensuremath{ \\cop{#1}{#2} \\aop{#1}{#2} } }\n\t\n\\newcommand{\\numop}[2]{% \\numop{<state index>}{<spin index>}\n\t\\ensuremath{ \\hat{n} _{#1 #2} }}\n\n\\newcommand{\\nop}[2]{% \\nop{<state index>}{<spin index>}\n\t\\ensuremath{ \\cop{#1}{#2} \\aop{#1}{#2}} }\n\n\\newcommand{\\sop}[1]{% \\sop{<z,+,->}\n\t\\ensuremath{ \\hat{S}_{#1} } }\n\n\\newcommand{\\krondelt}[2]{% \\krondelt{<idx 1>}{<idx 2>}\n\t\\ensuremath{ \\delta _{#1 #2} }}\n\t\n\\newcommand{\\sopz}{\n\t\\ensuremath{ \\hat{S} _{z} } }\n\n\\newcommand{\\sopp}{\n\t\\ensuremath{ \\hat{S} _{+} } }\n\n\\newcommand{\\sopm}{\n\t\\ensuremath{ \\hat{S} _{-} } }\n\t\n\\newcommand{\\hop}{\n\t\\ensuremath{ \\hat{H} _0 }}\n\n\\newcommand{\\ssop}{\n\t\\ensuremath{ \\hat{S} ^2} }\n\n\\newcommand{\\vop}{\n\t\\ensuremath{ \\hat{V} } }\n\n\\newcommand{\\ppop}[1]{% \\ppop{<index>}\n\t\\ensuremath{ \\hat{P} _{#1} ^+ } }\n\n\\newcommand{\\pmop}[1]{% \\ppop{<index>}\n\t\\ensuremath{ \\hat{P} _{#1} ^- } }\n\t\n\\newcommand{\\commutator}[2]{% \\commutator{<1st op>}{<2nd op>}}\n\t\\ensuremath{ \\left [ #1,#2 \\right ] }}\n\n\\newcommand{\\commutatorexp}[2]{% \\commutatorexp{1st op}{<2nd op>}\n\t\\ensuremath{ #1 #2 - #2 #1 } }\n\n\\newcommand{\\ssqr}{% sum form of S^2\n\t\\ensuremath{ \\sopz ^2 + \\frac{1}{2} ( \\sopp \\sopm + \\sopm \\sopp ) } }\n\n\\newcommand{\\vacuumb}{\n\t\\ensuremath{ \\Bra{0} } }\n\n\\newcommand{\\vacuumk}{\n\t\\ensuremath{ \\Ket{0} } }\n\n\\title{Pairing Model}\n\\author{Xingze Mao \\\\ Zachary Matheson \\\\ Thomas Redpath}\n%\\date{}\n\t\n\\begin{document}\n\n\\maketitle\n\n\\section*{\\hop commutation relations}\n\nShow that the unperturbed Hamiltonian commutes with the spin projection \\sop{z}:\n\n\n\\begin{align*}\n\t\\left [ H _0, \\sop{z} \\right ] &=\\\\\n\t&=\\left ( \\hzero{p}{\\sigma} \\right ) \\left ( \\sz{p'}{\\sigma'} \\right ) -\\\\\n\t& \\hspace{5mm} \\left ( \\sz{p''}{\\sigma''} \\right ) \\left ( \\hzero{p'''}{\\sigma'''} \\right )\\\\\n\t&= \\frac{1}{2} \\sum_{p \\sigma p' \\sigma'} (p-1) \\sigma' \\numop{p}{\\sigma} \\numop{p'}{\\sigma'} - \\frac{1}{2} \\sum_{p'' \\sigma'' p''' \\sigma'''} (p'''-1) \\sigma'' \\numop{p''}{\\sigma''} \\numop{p'''}{\\sigma'''}\n\\end{align*}\n\nIn this form it is apparent that these two sums are identical and cancel to give $[\\hat{H}_0,\\sop{z}]=0$.\n\nShow that the unperturbed Hamiltonian commutes with the total spin squared operator $\\hat{S}^2$:\n\n\\begin{align}\n\t\\left [ \\hat{H}_0, \\hat{S}^2 \\right ] &= \\left [ \\hop, \\sop{z} ^2 \\right ] + \\frac{1}{2} \\left [ \\hop,(\\sop{+} \\sop{-} + \\sop{-}\\sop{+}) \\right ]\\\\\n\t&= \\commutator{\\hop}{\\sop{z}} \\sop{z} + \\sop{z} \\commutator{\\hop}{\\sop{z}} +\\frac{1}{2} \\commutator{\\hop}{(\\sop{+}\\sop{-} + \\sop{-}\\sop{+})}\\\\\n\t&= \\frac{1}{2} \\left ( \\commutator{\\hop}{\\sop{+}} \\sop{-} + \\sop{+} \\commutator{\\hop}{\\sop{-}} + \\commutator{\\hop}{\\sop{-}} \\sop{+} + \\sop{-} \\commutator{\\hop}{\\sop{+}} \\right )\n\\end{align}\n\nNow consider the commutators \\commutator{\\hop}{\\sop{+}} and \\commutator{\\hop}{\\sop{-}}.\n\n\\begin{equation}\n\t\\commutator{\\hop}{\\sop{+}} = \\left ( \\hzero{p}{\\sigma} \\right ) \\left ( \\splus{p'} \\right ) - \\left ( \\splus{p''} \\right ) \\left ( \\hzero{p'''}{\\sigma'''} \\right )\n\t\\label{eq:hsplus}\n\\end{equation}\n\nUsing the anti-commutation relations of the creation and annihilation operators, we can show that the first product of sums in eq.~\\ref{eq:hsplus} contains the second and therefore, $ \\commutator{\\hop}{\\sop{+}} =0$. Focusing on the first product of sums in eq.~\\ref{eq:hsplus}:\n\n\\begin{align}\n\t& \\sum_{p \\sigma p'} (p-1) \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{p'}{+} \\aop{p'}{-}\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\cop{p}{\\sigma} \\left (\\krondelt{p}{p'} \\krondelt{\\sigma}{+} -  \\cop{p'}{+} \\aop{p}{\\sigma} \\right ) \\aop{p'}{-}\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\left ( \\krondelt{p}{p'} \\krondelt{\\sigma}{+} \\cop{p}{\\sigma} \\aop{p'}{-} - \\cop{p}{\\sigma}  \\cop{p'}{+} \\aop{p}{\\sigma} \\aop{p'}{-} \\right )\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\left ( \\krondelt{p}{p'} \\krondelt{\\sigma}{+} \\cop{p}{\\sigma} \\aop{p'}{-} - \\cop{p'}{+} \\cop{p}{\\sigma} \\aop{p'}{-} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\left ( \\krondelt{p}{p'} \\krondelt{\\sigma}{+} \\cop{p}{\\sigma} \\aop{p'}{-} - \\cop{p'}{+} \\left ( \\krondelt{p}{p'} \\krondelt{\\sigma}{-} - \\aop{p'}{-} \\cop{p}{\\sigma} \\right ) \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\left ( \\krondelt{p}{p'} \\krondelt{\\sigma}{+} \\cop{p}{\\sigma} \\aop{p'}{-} - \\krondelt{p}{p'} \\krondelt{\\sigma}{-} \\cop{p'}{+} \\aop{p}{\\sigma} + \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\\\\\n%\t&= \\sum_{p}  \\left ( (p-1) \\cop{p}{+} \\aop{p}{-} \\right ) + \\sum_{p} \\left ( (p-1) \\cop{p}{+} \\aop{p}{-} \\right ) + \\sum_{p \\sigma p'} (p-1) \\left ( \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma p'} (p-1) \\left ( \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\n\\end{align}\n\nComparing the results of this calculation with the second product of sums in eq.~\\ref{eq:hsplus}, which, reordering indicies, we can write as\n\n\\begin{align*}\n\t& \\sum_{p'' p''' \\sigma} (p''' -1) \\left ( \\cop{p''}{+} \\aop{p''}{-}\\cop{p'''}{\\sigma'''}\\aop{p'''}{\\sigma'''} \\right )\\\\\n\t&= \\sum_{p \\sigma p' } (p' -1) \\left ( \\cop{p}{+} \\aop{p}{-} \\cop{p'}{\\sigma'} \\aop{p'}{\\sigma'} \\right )\n\\end{align*}\n\n\\noindent we notice that the two terms cancel leaving $ \\commutator{\\hop}{\\sop{+}} =0$.\n\nUsing the same procedure, we can show that $ \\commutator{\\hop}{\\sop{-}} = 0$. With these results, we find that $\\commutator{\\hop}{\\ssop} = 0$.\n\n\\section*{\\vop commutation relations}\n\nShow that \\vop commutes with \\sop{z}:\n\n\\begin{align}\n\\begin{split}\n\t\\commutator{\\vop}{\\sop{z}} &= \\left ( \\twobody{q}{s} \\right ) \\left ( \\sz{p}{\\sigma} \\right )\\\\\n\t& - \\left( \\sz{p'}{\\sigma'} \\right ) \\left ( \\twobody{q'}{s'} \\right )\n\\end{split}\n\\label{eq:comvsz}\n\\end{align}\n\nThe first term may be re-written:\n\n\\begin{align*}\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\cop{p}{\\sigma} \\aop{p}{\\sigma}\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\left ( \\krondelt{s}{p} \\krondelt{+}{\\sigma} - \\cop{p}{\\sigma} \\aop{s}{+} \\right ) \\aop{p}{\\sigma}\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\krondelt{s}{p} \\krondelt{+}{\\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{p}{\\sigma} - \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\cop{p}{\\sigma} \\aop{s}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\krondelt{s}{p} \\krondelt{+}{\\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{p}{\\sigma} - \\sigma \\cop{q}{+} \\cop{q}{-} \\left ( \\krondelt{s}{p} \\krondelt{-}{\\sigma} - \\cop{p}{\\sigma} \\aop{s}{-} \\right ) \\aop{s}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\krondelt{s}{p} \\krondelt{+}{\\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{p}{\\sigma} - \\krondelt{s}{p} \\krondelt{-}{\\sigma} \\sigma \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{p}{\\sigma} + \\sigma \\cop{q}{+} \\cop{q}{-} \\cop{p}{\\sigma} \\aop{s}{-} \\aop{s}{+} \\aop{p}{\\sigma}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( (+) \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} -  (-) \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} + \\sigma \\cop{p}{\\sigma} \\cop{q}{+} \\cop{q}{-} \\aop{p}{\\sigma} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} + \\sigma \\cop{p}{\\sigma} \\cop{q}{+} \\left ( \\krondelt{q}{p} \\krondelt{-}{\\sigma} - \\aop{p}{\\sigma} \\cop{q}{-} \\right ) \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} + \\krondelt{q}{p} \\krondelt{-}{\\sigma} \\sigma \\cop{p}{\\sigma} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\sigma \\cop{p}{\\sigma} \\cop{q}{+} \\aop{p}{\\sigma} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} + (-) \\cop{q}{-} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\sigma \\cop{p}{\\sigma} \\cop{q}{+} \\aop{p}{\\sigma} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} - \\cop{q}{-} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\sigma \\cop{p}{\\sigma} \\left ( \\krondelt{q}{p} \\krondelt{+}{\\sigma} - \\aop{p}{\\sigma} \\cop{q}{+} \\right ) \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} - \\cop{q}{-} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\krondelt{q}{p} \\krondelt{+}{\\sigma} \\sigma \\cop{p}{\\sigma} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\sigma \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{-} - \\cop{q}{-} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\sigma \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\t& \\frac{(-g)}{2} \\sum_{qs p \\sigma} \\left ( \\sigma \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}  \\right )\\\\\n\\end{align*}\n\nComparing this result to the second product of sums in eq.~\\ref{eq:comvsz}, which may be re-written:\n\n\\begin{equation}\n\t\\frac{+g}{2} \\sum_{p \\sigma qs} \\sigma \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\nonumber\n\\end{equation}\n\nthe terms cancel so that $ \\commutator{\\vop}{\\sop{z}} = 0$.\n\nShow that \\vop commutes with \\ssop:\n\n\\begin{align*}\n\t\\commutator{\\vop}{\\ssop} &= \\commutator{\\vop}{\\sop{z} ^2} + \\frac{1}{2} \\left ( \\commutator{\\vop}{\\sop{+} \\sop{-}} + \\commutator{\\vop}{\\sop{-} \\sop{+}} \\right )\\\\\n\t&= \\sop{z} \\commutator{\\vop}{\\sop{z}} +  \\commutator{\\vop}{\\sop{z}} \\sop{z} + \\frac{1}{2} \\left ( \\sop{+} \\commutator{\\vop}{\\sop{-}} + \\commutator{\\vop}{\\sop{+}} \\sop{-} + \\sop{-} \\commutator{\\vop}{\\sop{+}} + \\commutator{\\vop}{\\sop{-}} \\sop{+} \\right )\\\\\n\t&= \\frac{1}{2} \\left ( \\sop{+} \\commutator{\\vop}{\\sop{-}} + \\commutator{\\vop}{\\sop{+}} \\sop{-} + \\sop{-} \\commutator{\\vop}{\\sop{+}} + \\commutator{\\vop}{\\sop{-}} \\sop{+} \\right )\n\\end{align*}\n\nWriting out \\commutator{\\vop}{\\sop{-}}:\n\n\\begin{align}\n\\begin{split}\n\t\\commutator{\\vop}{\\sop{-}} &= \\left ( \\twobody{q}{s} \\right ) \\left ( \\sminus{m} \\right )\\\\\n\t& - \\left ( \\sminus{m'} \\right ) \\left ( \\twobody{q'}{s'} \\right )\n\\end{split}\n\\label{eq:vsminus}\n\\end{align}\n\t\nRe-writing the first prduct of sums using the anti-commutation relations and noting that in \\ref{eq:vsmmk1} and \\ref{eq:vsmmk2} the first terms give zero for the fermionic case since \\aop{s}{+} \\aop{s}{+} would act to remove a particle from an empty state and \\cop{q}{-} \\cop{q}{-} would act to add a particle to an occupied state.\n\n\\begin{align}\n\t& (-g) \\sum _{q s m} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\cop{m}{-} \\aop{m}{+}\\\\\n\t& (-g) \\sum _{q s m} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\cop{m}{-} \\aop{m}{+} \\aop{s}{+}\\\\\n\t& (-g) \\sum _{q s m} \\cop{q}{+} \\cop{q}{-} \\left ( \\krondelt{s}{m} - \\cop{m}{-} \\aop{s}{-} \\right ) \\aop{m}{+} \\aop{s}{+}\\\\\n\t& (-g) \\sum _{q s m} \\krondelt{s}{m} \\cop{q}{+} \\cop{q}{-} \\aop{m}{+} \\aop{s}{+} - \\cop{q}{+} \\cop{q}{-} \\cop{m}{-} \\aop{s}{-} \\aop{m}{+} \\aop{s}{+}\\\\\n\\label{eq:vsmmk1}\t& (-g) \\sum _{q s m} \\cop{q}{+} \\cop{q}{-} \\aop{s}{+} \\aop{s}{+} - \\cop{q}{+} \\cop{q}{-} \\cop{m}{-} \\aop{s}{-} \\aop{m}{+} \\aop{s}{+}\\\\\n\t& (-g) \\sum _{q s m} - \\cop{m}{-} \\cop{q}{+} \\aop{m}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum _{q s m} - \\cop{m}{-} \\left ( \\krondelt{q}{m} - \\aop{m}{+} \\cop{q}{+} \\right ) \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum _{q s m} - \\krondelt{q}{m}\\cop{m}{-} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{m}{-}  \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\\label{eq:vsmmk2}\t& (-g) \\sum _{q s m} - \\cop{q}{-} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} + \\cop{m}{-}  \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\\label{eq:vsmres}\t& (-g) \\sum _{q s m} \\cop{m}{-}  \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\n\\end{align}\n\nComparing the result in \\ref{eq:vsmres} to the second product of sums in eq.~\\ref{eq:vsminus}, re-written here as\n\n\\begin{equation}\n\tg \\sum _{m q s} \\cop{m}{-} \\cop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\nonumber\n\\end{equation}\n\nwe see that $ \\commutator{\\vop}{\\sop{-}} = 0$. Using the same procedure, we can show that $ \\commutator{\\vop}{\\sop{+}} = 0$ and conclude that $ \\commutator{\\vop}{\\ssop} = 0$.\n\n\\section*{Pair creation and annihilation operators}\n\nWe consider the system with total spin $S=0$ (no broken pairs) and define the pair creation and annihilation operators.\n\n\\begin{align*}\n\\begin{split}\n\t\\hat{P} _p ^+ &= \\pcop{p}\\\\\n\t\\hat{P} _p ^- &= \\paop{p}\n\\end{split}\n\\end{align*}\n\nand the full Hamiltonian\n\n\\begin{equation}\n\t\\hat{H} = \\hfull{p}{\\sigma}{q}{s}\n\\label{eq:fullham}\n\\end{equation}\n\nShow that $\\hat{H}$ commutes with the product of the pair creation and pair annihilation operators:\n\n%\\begin{itemize}\n%\t\\item The indices on the pair creation and annihilation operators must be the same since otherwise, this would imply physically chaning the system.\n%\\end{itemize}\n\n\\begin{align}\\label{eq:comhpac}\n\t\\commutator{\\hat{H}}{ \\ppop{r} \\pmop{r}} &= \\commutator{\\hat{H} _0}{ \\ppop{r} \\pmop{r}} + \\commutator{\\vop}{\\ppop{r} \\pmop{r}}\n\\end{align}\n\nTaking the first commutator in eq.~\\ref{eq:comhpac}:\n\n\\begin{align*}\n\t\\commutator{\\hop}{ \\ppop{r} \\pmop{r}} &= \\left ( \\hzero{p}{\\sigma} \\right ) \\left ( \\pcop{r} \\paop{r} \\right ) - \\left ( \\pcop{r} \\paop{r} \\right ) \\left ( \\hzero{p}{\\sigma} \\right )\n\\end{align*}\n\nRe-writing the first product of sums to have the same form as the second product of sums leaves no remaining terms (\\ref{eq:comhzpcap}). Thus $ \\commutator{\\hop}{\\ppop{r} \\pmop{r}}=0$.\n\n\\begin{align}\n\\begin{split}\n\t& \\left ( \\hzero{p}{\\sigma} \\right ) \\left ( \\pcop{r} \\paop{r} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+}\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\cop{p}{\\sigma} \\left ( \\krondelt{p}{r} \\krondelt{\\sigma}{+} - \\cop{r}{+} \\aop{p}{\\sigma} \\right ) \\cop{r}{-} \\aop{r}{-} \\aop{r}{+}\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\krondelt{p}{r} \\krondelt{\\sigma}{+} \\cop{p}{\\sigma} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} - \\cop{p}{\\sigma} \\cop{r}{+} \\aop{p}{\\sigma} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} - \\cop{p}{\\sigma} \\cop{r}{+} \\aop{p}{\\sigma} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{p}{\\sigma} \\left ( \\krondelt{p}{r} \\krondelt{\\sigma}{-} - \\cop{r}{-} \\aop{p}{\\sigma} \\right ) \\aop{r}{-} \\aop{r}{+} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\krondelt{p}{r} \\krondelt{\\sigma}{-} \\cop{r}{+} \\cop{p}{\\sigma} \\aop{r}{-} \\aop{r}{+} - \\cop{r}{+} \\cop{p}{\\sigma} \\cop{r}{-} \\aop{p}{\\sigma} \\aop{r}{-} \\aop{r}{+} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\cop{p}{\\sigma} \\aop{r}{-} \\aop{r}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\left ( \\krondelt{p}{r} \\krondelt{\\sigma}{-} - \\aop{r}{-} \\cop{p}{\\sigma} \\right ) \\aop{r}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\krondelt{p}{r} \\krondelt{\\sigma}{-} \\cop{r}{+} \\cop{r}{-} \\aop{r}{+} \\aop{p}{\\sigma} - \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\cop{p}{\\sigma} \\aop{r}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{+} \\aop{r}{-} - \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\cop{p}{\\sigma} \\aop{r}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} - \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\cop{p}{\\sigma} \\aop{r}{+} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} - \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\left ( \\krondelt{p}{r} \\krondelt{\\sigma}{+} - \\aop{r}{+} \\cop{p}{\\sigma} \\right ) \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} -\\krondelt{p}{r} \\krondelt{\\sigma}{+} \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{p}{\\sigma} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} - \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} + \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\\\\\n\t&= \\sum_{p \\sigma} (p-1) \\left ( \\cop{r}{+} \\cop{r}{-} \\aop{r}{-} \\aop{r}{+} \\cop{p}{\\sigma} \\aop{p}{\\sigma} \\right )\n\\end{split}\n\\label{eq:comhzpcap}\n\\end{align}\n\nWorking out the second commutator from eq.~\\ref{eq:comhpac}:\n\n\\begin{align}\n\\begin{split}\n\t\\commutator{\\vop}{\\ppop{r} \\pmop{t}} &= (-g) \\sum _{qs} \\commutator{ \\ppop{q} \\pmop{s} }{ \\ppop{r} \\pmop{r}}\\\\\n\t&= \\ppop{q} \\commutator{\\pmop{s}}{\\ppop{r}} \\pmop{r} + \\ppop{q} \\ppop{r} \\commutator{\\pmop{s}}{\\pmop{r}} + \\commutator{\\ppop{q}}{\\ppop{r}} \\pmop{s} \\pmop{r} +  \\ppop{r} \\commutator{\\ppop{q}}{\\pmop{r}} \\pmop{s}\n%&= \\left ( -g \\sum_{q s} \\hat{P} ^+ _{q} \\hat{P} ^- _{s} \\right ) \\left ( \\ppop{r} \\pmop{r} \\right ) - \\left ( \\ppop{r} \\pmop{r} \\right ) \\left ( -g \\sum_{q s} \\hat{P} ^+ _{q} \\hat{P} ^- _{s} \\right )\n\\end{split}\n\\label{eq:ctpcom}\n\\end{align}\n\nThe commutation relations between pair creation and annihilation operators were found to be:\n\n\\begin{align*}\n\t\\commutator{\\ppop{p}}{\\pmop{q}} &= \\cop{p}{+} \\cop{p}{-} \\aop{q}{-} \\aop{q}{+} - \\aop{q}{-} \\aop{q}{+} \\cop{p}{+} \\cop{p}{-}\n\\end{align*}\n\nRe-writing the first term\n\n\\begin{align*}\n\t& \\cop{p}{+} \\cop{p}{-} \\aop{q}{-} \\aop{q}{+}\\\\\n\t& \\cop{p}{+} \\left ( \\krondelt{p}{q} - \\aop{q}{-} \\cop{p}{-} \\right ) \\aop{q}{+}\\\\\n\t& \\cop{p}{+} \\aop{p}{+} - \\cop{p}{+} \\aop{q}{-} \\cop{p}{-} \\aop{q}{+}\\\\\n\t& \\cop{p}{+} \\aop{p}{+} - \\aop{q}{-} \\cop{p}{+} \\aop{q}{+} \\cop{p}{-}\\\\\n\t& \\cop{p}{+} \\aop{p}{+} - \\aop{q}{-} \\left ( \\krondelt{p}{q} - \\aop{q}{+} \\cop{p}{+} \\right ) \\cop{p}{-}\\\\\n\t& \\cop{p}{+} \\aop{p}{+} -  \\aop{p}{-} \\cop{p}{-} + \\aop{q}{-} \\aop{q}{+} \\cop{p}{+} \\cop{p}{-}\\\\\n\\end{align*}\n\ncancels the second leaving\n\n\\begin{equation}\n\t\\commutator{\\ppop{p}}{\\pmop{q}} = \\cop{p}{+} \\aop{p}{+} -  \\aop{p}{-} \\cop{p}{-} \\nonumber\n\\end{equation}\n\nGeneralizing the form for the commutation relation between \\ppop{p} and \\pmop{q}\n\n\\begin{align}\n\\begin{split}\n\t\\commutator{\\hat{P} _p ^{\\pm} }{\\hat{P} _q ^{\\mp}} &= \\pm ( \\cop{p}{+} \\aop{p}{+} - \\aop{p}{-} \\cop{p}{-})\\\\\n\t\\commutator{\\hat{P} _p ^{\\pm}}{\\hat{P} _q ^{\\pm}} &= 0\n\\end{split}\n\\label{eq:ppmcom}\n\\end{align}\n\nThese results reduce the four terms in eq.~\\ref{eq:ctpcom} to two, which can be expanded taking into account that the pair creation and annihilation operators act to select terms with their specific state index from the sum over all states.\n\n\\begin{align*}\n\t&\\ppop{q} \\commutator{\\pmop{s}}{\\ppop{r}} \\pmop{r} + \\ppop{q} \\ppop{r} \\commutator{\\pmop{s}}{\\pmop{r}} + \\commutator{\\ppop{q}}{\\ppop{r}} \\pmop{s} \\pmop{r} +  \\ppop{r} \\commutator{\\ppop{q}}{\\pmop{r}} \\pmop{s}\\\\\n\t&= \\ppop{q} \\commutator{\\pmop{s}}{\\ppop{r}} \\pmop{r} +  \\ppop{r} \\commutator{\\ppop{q}}{\\pmop{r}} \\pmop{s}\\\\\n\t&= \\pcop{q} \\left ( \\aop{r}{-} \\cop{r}{-} - \\cop{r}{+} \\aop{r}{+} \\right ) \\paop{r} + \\pcop{r} \\left ( \\cop{r}{+} \\aop{r}{-} - \\aop{r}{-} \\cop{r}{-} \\right ) \\paop{s}\\\\\n\t&= 0\n\\end{align*}\n\nsince the first term contains two \\aop{r}{-} operators, the second term contains two \\aop{r}{+} operators, the third contains two \\cop{r}{+} operators and the fourth contains two \\cop{r}{+} operators, therefore, action of \\commutator{\\vop}{\\ppop{r} \\pmop{t}} on any fermionic state produces 0. Combining this result with that of eq.~\\ref{eq:comhzpcap} shows that the Hamiltonian commutes with the pair creation and annihilation operators.\n\n\\section*{The Hamiltonian Matrix}\n\nRestricting the effective Hilbert space to only the two lowest single-particle states (they are doubly degenerate) and considering only two particles, we can construct a Hamiltonian matrix in the basis of 2-particle Slater determinants (eq.~\\ref{eq:2ptclSD}).\n\n\\begin{align}\n\\begin{split}\n\t\\Ket{\\Phi _1 ^{\\mathrm{SD}}} &= \\pcop{1} \\ket{0}\\\\\n\t\\Ket{\\Phi _2 ^{\\mathrm{SD}}} &= \\pcop{2} \\ket{0}\n\\end{split}\n\t\\label{eq:2ptclSD}\n\\end{align}\n\n Furthermore, our system is considered to have no broken pairs and total spin $S=0$. The matrix elements of the Hamiltonian can be calculated separately for the one- and two-body parts using Wick's theorem. For example, the one-body part of the first matrix element:\n\n\\begin{align*}\n\t& \\Bra{0} \\paop{1} \\left ( \\hzero{p}{\\sigma} \\right ) \\pcop{1} \\Ket{0}\\\\\n\t&= \\Bra{0} \\paop{1} \\left ( 0 \\nop{1}{+} + 0 \\nop{1}{-} + 1 \\nop{2}{+} + 1 \\nop{2}{-} \\right ) \\pcop{1} \\Ket{0}\\\\\n\t&= \\Bra{0} \\paop{1} \\left ( 0 \\nop{1}{+} + 0 \\nop{1}{-} \\right ) \\pcop{1} \\Ket{0}\\\\\n\t&= 0\n\\end{align*}\n\nThe two body part of the first matrix element:\n\n\\begin{align*}\n\t& \\vacuumb \\paop{1} \\left ( \\twobody{p}{q} \\right ) \\pcop{1} \\vacuumk\\\\\n\t&= \\vacuumb \\paop{1} (-g) \\left ( \\cpm{1} \\amp{1} + \\cpm{1} \\amp{2} + \\cpm{2} \\amp{1} + \\cpm{2} \\amp{2} \\right ) \\pcop{1} \\vacuumk\\\\\n\t&= \\vacuumb \\paop{1} (-g) \\left ( \\cpm{1} \\amp{1} \\right ) \\pcop{1} \\vacuumk\\\\\n\t&= -g\n\\end{align*}\n\nThe second matrix element:\n\n\\begin{align*}\n\t& \\vacuumb \\paop{1} \\left ( \\hzero{p}{\\sigma} \\right ) \\pcop{2} \\vacuumk\\\\\n\t&= \\vacuumb \\paop{1} \\left ( 0 \\nop{1}{+} + 0 \\nop{1}{-} + 1 \\nop{2}{+} + 1 \\nop{2}{-} \\right ) \\pcop{2} \\vacuumk\\\\\n\t&= 0\n\\end{align*}\n\n\\begin{align*}\n\t& \\vacuumb \\paop{1} \\left ( \\twobody{p}{q} \\right ) \\pcop{2} \\vacuumk\\\\\n\t&= \\vacuumb \\paop{1} (-g) \\left ( \\cpm{1} \\amp{1} + \\cpm{1} \\amp{2} + \\cpm{2} \\amp{1} + \\cpm{2} \\amp{2} \\right ) \\pcop{2} \\vacuumk\\\\\n\t&= \\vacuumb \\paop{1} (-g) \\left ( \\cpm{1} \\amp{2} \\right ) \\pcop{2} \\vacuumk\\\\\n\t&= -g\n\\end{align*}\n\nThe full $2 \\times 2$ matrix where $d$ is the level spacing\n\n\\begin{equation}\n\tH = \n\t\\begin{pmatrix}\n\t\t-g & -g\\\\\n\t\t-g & 2d - g\n\t\\end{pmatrix}\n\t\\label{eq:2ptclham}\n\\end{equation}\n\nThis matrix is diagonalized to yield eigenenergies (with $d=1$)\n\n\\begin{equation}\n\tE = 1 - g \\pm \\sqrt{1 + g^2}\n\t\\label{eq:2ptcleng}\n\\end{equation}\n\nThe ground state energy, $E_0 = 1 - g - \\sqrt{1 + g^2}$, as $g$ goes from $-1$ to $1$ goes from $\\sim 0.5$ to $\\sim -1.5$. This suggests that when the two-body interaction is attractive ($g$ positive), the one pair two level system has at least one bound state. Our shell model code (see Table~\\ref{tab:1pr2lvl}) reproduces exactly the analytic result.\n\nWhen we have four levels and four particles, the number of basis states is $\\binom{4}{4/2}=6$, and the 6 Slater determinants are\n\n\\begin{align}\n\\begin{split}\n\t& \\cpm{1} \\cpm{2} \\vacuumk\\\\\n\t& \\cpm{1} \\cpm{3} \\vacuumk\\\\\n\t& \\cpm{1} \\cpm{4} \\vacuumk\\\\\n\t& \\cpm{2} \\cpm{3} \\vacuumk\\\\\n\t& \\cpm{2} \\cpm{4} \\vacuumk\\\\\n\t& \\cpm{3} \\cpm{4} \\vacuumk\n\\end{split}\n\\end{align}\n\n%$\\ket{1\\pm2\\pm},\\ket{1\\pm3\\pm},\\ket{1\\pm4\\pm},\\ket{2\\pm3\\pm},\\ket{2\\pm4\\pm},\\ket{3\\pm4\\pm}$.\n\nAction of the Hamiltonian on each Slater determinant results in\n\n\\begin{align*}\n&\\hat{H}\\ket{1\\pm2\\pm}=(2-2g)\\ket{1\\pm2\\pm}-g\\ket{1\\pm3\\pm}-g\\ket{1\\pm4\\pm}-g\\ket{2\\pm3\\pm}-g\\ket{2\\pm4\\pm}+0\\ket{3\\pm4\\pm}   \\\\\n&\\hat{H}\\ket{1\\pm3\\pm}=g\\ket{1\\pm2\\pm}+(4-2g)\\ket{1\\pm3\\pm}-g\\ket{1\\pm4\\pm}-g\\ket{2\\pm3\\pm}+0\\ket{2\\pm4\\pm}-g\\ket{3\\pm4\\pm}   \\\\\n&\\hat{H}\\ket{1\\pm4\\pm}=-g\\ket{1\\pm2\\pm}-g\\ket{1\\pm3\\pm}+(6-2g)\\ket{1\\pm4\\pm}-0\\ket{2\\pm3\\pm}-g\\ket{2\\pm4\\pm}-g\\ket{3\\pm4\\pm}   \\\\\n&\\hat{H}\\ket{2\\pm3\\pm}=-g\\ket{1\\pm2\\pm}-g\\ket{1\\pm3\\pm}-g\\ket{1\\pm4\\pm}+(6-2g)\\ket{2\\pm3\\pm}-g\\ket{2\\pm4\\pm}-g\\ket{3\\pm4\\pm}   \\\\ \n&\\hat{H}\\ket{2\\pm4\\pm}=-g\\ket{1\\pm2\\pm}+0\\ket{1\\pm3\\pm}-g\\ket{1\\pm4\\pm}-g\\ket{2\\pm3\\pm}+(8-2g)\\ket{2\\pm4\\pm}-g\\ket{3\\pm4\\pm}   \\\\\n&\\hat{H}\\ket{3\\pm4\\pm}=0\\ket{1\\pm2\\pm}-g\\ket{1\\pm3\\pm}-g\\ket{1\\pm4\\pm}-g\\ket{2\\pm3\\pm}-g\\ket{2\\pm4\\pm}+(10-2g)\\ket{3\\pm4\\pm}   \n\\end{align*}\n\n\nwhere a short-hand notation $\\ket{p \\pm q \\pm}$ is employed to represent a Slater determinant with one pair in level $p$ and one in level $q$.\n\nSo the Hamiltonian matrix is\n\n\\begin{equation}\n\\begin{bmatrix}\n2-2g   &  -g   &   -g   &   -g    &   -g    &    0    \\\\\n  -g   &4-2g   &   -g   &   -g    &    0    &   -g    \\\\\n  -g   &  -g   & 6-2g   &    0    &   -g    &   -g    \\\\\n  -g   &  -g   &   0   & 6-2g    &   -g    &   -g    \\\\\n  -g   &   0   &   -g   &   -g    & 8-2g    &   -g    \\\\\n   0   &  -g   &   -g   &   -g    &   -g    & 10-2g    \\\\\n\\end{bmatrix}\n\\label{eq:ham6mtx}\n\\end{equation}\n\nWe diagonalize this matrix numerically for $g=\\{ -1.0, -0.5, 0.0, 0.5, 1.0 \\}$ and ensure that our code's output, listed in Table~\\ref{tab:2pr4lvl}, matches the results. This test ensures that our code correctly generates the Hamiltonian matrix. Similarly to the one pair two level case, we note that as $g$ becomes negative (as the two-body interaction becomes repulsive), the system becomes unbound (see Figure~\\ref{fig:ezerovg}).\n\n\\begin{figure}\n\\center\n\t\\includegraphics[width=0.6\\textwidth]{lvl4pr2.png}\n\t\\caption{Ground state energies for five different values of $g$ - calculated by diagonalizing the $6 \\times 6$ Hamiltonian matrix of eq.~\\ref{eq:ham6mtx}. These results match our code's output given in Table~\\ref{tab:2pr4lvl}.}\n\t\\label{fig:ezerovg}\n\\end{figure}\n\n\n\n%Table~\\ref{tab:1pr2lvl} lists the results of our shell model calculation with two particles (1 pair) and two levels.\n\n\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{|r|r|}\n\\hline\n  g   &  $E_{gs}$ \\\\ \\hline\n-1.0  &  0.59 \\\\\n-0.5  &  0.38 \\\\\n 0.0  &  0.0 \\\\\n 0.5  &  -0.62 \\\\\n 1.0  &  -1.41 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Ground state energies as a function of interaction strength $g$ for the case of one pair in 2 single particle levels.}\n\\label{tab:1pr2lvl}\n\\end{table}\n\n\n\\begin{table}[h]\n\\begin{center}\n\t\\begin{tabular}{|r|r|}\n\\hline\n\tg   &  $E_{gs}$ \\\\ \\hline\n\t-1.0  &  3.30 \\\\\n\t-0.5  &  2.78 \\\\\n\t 0.0  &  2.0 \\\\\n\t 0.5  &  -0.64 \\\\\n\t 1.0  &  -1.49 \\\\\n\\hline\n\t\\end{tabular}\n\\end{center}\n\t\\caption{Ground state energies as a function of interaction strength $g$ for the case of two pairs in four levels.}\n\t\\label{tab:2pr4lvl}\n\\end{table}\n\n\n\n\n\nWhen we remove the single particle piece of the Hamiltonian and keep only\nthe two particle interaction, all particles are brought down to the same\ndegenerate energy level, with degeneracy $\\Omega$ and ground state energy\n\\begin{equation}\n\tE_0 = - \\frac{g}{4} n (\\Omega - n +2)\n\t\\label{eq:no1bdy}\n\\end{equation}\n\nOur code reproduces the analytic result eq.~\\ref{eq:no1bdy} for $g>0$ (an attractive two-body interaction). When \n$g$ becomes negative, eq.~\\ref{eq:no1bdy} gives the highest possible energy level due to the two-body interaction\nand the ground state energy becomes 0.\n\nAs we then vary the\ninteraction strength $g$ we observe the following pattern: In the\nnegative $g$ case, the interaction is repulsive, and so the best the\nsystem can do is break even. In this case, the ground state energy is\nzero, regardless of $g$. When $g$ becomes positive, however, the\ninteraction is attractive, and as $g$ becomes more and more positive,\nthe interaction becomes increasingly attractive and the system\ncorrespondingly becomes more and more bound. We illustrate this for\nseveral cases in Table \\ref{tab:data-nosinglepart}.\n\n%%% Tables\n\\begin{table}\n\\begin{center}\n%\\label{tab:data-nosinglepart}\n\\begin{tabular}{|c|c|c|c|}\n\\hline\n   g   &  $E_{gs}$(2,2)  &  $E_{gs}$(6,6)  & $ E_{gs}$(8,8) \\\\ \\hline\n-1.0  &  0  &  0  &  0   \\\\\n-0.5  &  0  &  0  &  0   \\\\\n  0.0  &  0  &  0  &  0   \\\\\n  0.5  &  -1  & -6  &  -10 \\\\\n  1.0  &  -2  & -12 &  -20 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\caption{Ground state energies $E_{gs}(N_l,N_{part})$ for the case with\nthe single-particle Hamiltonian removed. The energies are shown as a\nfunction of interaction strength $g$ for the case of $N_{part}$\nparticles in $N_l=\\frac{\\Omega}{2}$ single particle ``levels.''}\n\\label{tab:data-nosinglepart}\n\\end{table}\n\n\\clearpage\n\n\\definecolor{mygreen}{rgb}{0,0.6,0}\n\\definecolor{mygray}{rgb}{0.5,0.5,0.5}\n\\definecolor{mymauve}{rgb}{0.58,0,0.82}\n\n\\lstset{ %\n  backgroundcolor=\\color{white},   % choose the background color; you must add \\usepackage{color} or \\usepackage{xcolor}\n  basicstyle=\\footnotesize,        % the size of the fonts that are used for the code\n  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace\n  breaklines=true,                 % sets automatic line breaking\n  captionpos=b,                    % sets the caption-position to bottom\n  commentstyle=\\color{mygreen},    % comment style\n  deletekeywords={...},            % if you want to delete keywords from the given language\n  escapeinside={\\%*}{*)},          % if you want to add LaTeX within your code\n  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8\n  frame=single,\t                   % adds a frame around the code\n  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)\n  keywordstyle=\\color{blue},       % keyword style\n  language=Octave,                 % the language of the code\n  otherkeywords={*,...},           % if you want to add more keywords to the set\n  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)\n  numbersep=5pt,                   % how far the line-numbers are from the code\n  numberstyle=\\tiny\\color{mygray}, % the style that is used for the line-numbers\n  rulecolor=\\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))\n  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'\n  showstringspaces=false,          % underline spaces within strings only\n  showtabs=false,                  % show tabs within strings adding particular underscores\n  stepnumber=2,                    % the step between two line-numbers. If it's 1, each line will be numbered\n  stringstyle=\\color{mymauve},     % string literal style\n  tabsize=2,\t                   % sets default tabsize to 2 spaces\n  title=\\lstname                   % show the filename of files included with \\lstinputlisting; also try caption instead of title\n}\n\n\\lstinputlisting{shell_model.py}\n\n%\t&= \\ppop{q} \\left ( \\commutatorexp{\\pmop{s}}{\\ppop{r}} \\right ) \\pmop{r} + \\ppop{r} \\left ( \\commutatorexp{\\ppop{q}}{\\pmop{r}} \\right ) \\pmop{s}\\\\\n%\t&= \\pcop{q} \\left ( \\commutatorexp{\\paop{s}}{\\pcop{r}} \\right ) \\paop{r} + \\pcop{r} \\left ( \\commutatorexp{\\pcop{q}}{\\paop{r}} \\right ) \\paop{s}\\\\\n%\t&= \\pcop{q} \\paop{s} \\pcop{r} \\paop{r} - \\pcop{q} \\pcop{r} \\paop{s} \\paop{r}\\\\\n%\t& \\hspace{4mm} + \\pcop{r} \\pcop{q} \\paop{r} \\paop{s} - \\pcop{r} \\paop{r} \\pcop{q} \\paop{s}\\\\\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\\begin{comment}\n\n%%% SIDE TRACK - UNNECESSARY %%%\n\n\\begin{equation}\n\t\\commutator{\\hop}{\\sop{-}} = 2 \\sum_{p}  \\left ( (p-1) \\cop{p}{-} \\aop{p}{+} \\right )\n\t\\label{eq:hsminusres}\n\\end{equation}\n\n\nWe can now re-write the remaining terms in $ \\left [ \\hat{H}_0, \\hat{S}^2 \\right ]$.\n\n\\begin{align*}\n\t\\commutator{\\hop}{\\sop{+}} \\sop{-} &= 2 \\sum _{pp'} (p-1) \\cop{p}{+} \\aop{p}{-} \\cop{p'}{-} \\aop{p'}{+}\\\\\n\t\\sop{+} \\commutator{\\hop}{\\sop{-}} &= 2 \\sum _{pp'} (p'-1) \\cop{p}{+} \\aop{p}{-} \\cop{p'}{-} \\aop{p'}{+}\\\\\n\t\\commutator{\\hop}{\\sop{-}} \\sop{+} &= 2 \\sum _{pp'} (p-1) \\cop{p}{-} \\aop{p}{+} \\cop{p'}{+} \\aop{p'}{-}\\\\\n\t\\sop{-} \\commutator{\\hop}{\\sop{+}} &= 2 \\sum _{pp'} (p'-1) \\cop{p}{-} \\aop{p}{+} \\cop{p'}{+} \\aop{p'}{-}\n\\end{align*}\n\nTaking \\commutator{\\hop}{\\sop{+}} \\sop{-}:\n\n\\begin{align*}\n\t\\commutator{\\hop}{\\sop{+}} \\sop{-} &= \\sum _{pp'} (p-1) \\cop{p}{+} \\aop{p}{-} \\cop{p'}{-} \\aop{p'}{+}\\\\\n\t&= \\sum _{pp'} (p-1) \\cop{p}{+} \\left ( \\krondelt{p}{p'} -  \\cop{p'}{-} \\aop{p}{-} \\right ) \\aop{p'}{+}\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{+} \\aop{p'}{+} -  \\cop{p}{+} \\cop{p'}{-} \\aop{p}{-} \\aop{p'}{+} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{+} \\aop{p'}{+} -  \\cop{p'}{-} \\cop{p}{+} \\aop{p'}{+} \\aop{p}{-} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{+} \\aop{p'}{+} -  \\cop{p'}{-} \\left ( \\krondelt{p}{p'} - \\aop{p'}{+} \\cop{p}{+} \\right ) \\aop{p}{-} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{+} \\aop{p'}{+} - \\krondelt{p}{p'} \\cop{p'}{-} \\aop{p}{-} - \\cop{p'}{-} \\aop{p'}{+} \\cop{p}{+} \\aop{p}{-} \\right )\\\\\n\t&= \\sum _{p} (p-1) \\cop{p}{+} \\aop{p}{+} - \\sum _{p} (p-1) \\cop{p}{-} \\aop{p}{-} - \\sum _{pp'} (p-1) \\cop{p'}{-} \\aop{p'}{+} \\cop{p}{+} \\aop{p}{-}\\\\\n\t&= \\sum _{p} (p-1) \\numop{p}{+} - \\sum _{p} (p-1) \\numop{p}{-} - \\sum _{pp'} (p-1) \\cop{p'}{-} \\aop{p'}{+} \\cop{p}{+} \\aop{p}{-}\\\\\n\\end{align*}\n\nTaking \\commutator{\\hop}{\\sop{-}} \\sop{+}:\n\n\\begin{align*}\n\t\\commutator{\\hop}{\\sop{-}} \\sop{+} &= \\sum _{pp'} (p-1) \\cop{p}{-} \\aop{p}{+} \\cop{p'}{+} \\aop{p'}{-}\\\\\n\t&= \\sum _{pp'} (p-1) \\cop{p}{-} \\left ( \\krondelt{p}{p'} - \\cop{p'}{+} \\aop{p}{+} \\right ) \\aop{p'}{-}\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{-} \\aop{p'}{-} - \\cop{p}{-} \\cop{p'}{+} \\aop{p}{+} \\aop{p'}{-} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{-} \\aop{p'}{-} -  \\cop{p'}{+} \\cop{p}{-} \\aop{p'}{-} \\aop{p}{+} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{-} \\aop{p'}{-} -  \\cop{p'}{+} \\left ( \\krondelt{p}{p'} - \\aop{p'}{-} \\cop{p}{-} \\right ) \\aop{p}{+} \\right )\\\\\n\t&= \\sum _{pp'} (p-1) \\left ( \\krondelt{p}{p'} \\cop{p}{-} \\aop{p'}{-} - \\krondelt{p}{p'} \\cop{p'}{+} \\aop{p}{+} - \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{-} \\aop{p}{+} \\right )\\\\\n\t&= \\sum _{p} (p-1) \\cop{p}{-} \\aop{p}{-} - \\sum _{p} (p-1) \\cop{p}{+} \\aop{p}{+} - \\sum _{pp'} (p-1) \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{-} \\aop{p}{+}\\\\\n\t&= \\sum _{p} (p-1) \\numop{p}{-} - \\sum _{p} (p-1) \\numop{p}{+} - \\sum _{pp'} (p-1) \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{-} \\aop{p}{+}\\\\\n\\end{align*}\n\nPlugging these results in for their respective terms in the the remnant of $ \\left [ \\hat{H}_0, \\hat{S}^2 \\right ]$:\n\n\\begin{align*}\n\t& \\left [ \\hat{H}_0, \\hat{S}^2 \\right ]\\\\\n\t&= \\frac{1}{2} \\left ( \\commutator{\\hop}{\\sop{+}} \\sop{-} + \\sop{+} \\commutator{\\hop}{\\sop{-}} + \\commutator{\\hop}{\\sop{-}} \\sop{+} + \\sop{-} \\commutator{\\hop}{\\sop{+}} \\right )\\\\\n\t&= \\sum _{p} (p-1) \\numop{p}{+} - \\sum _{p} (p-1) \\numop{p}{-} - \\sum _{pp'} (p-1) \\cop{p'}{-} \\aop{p'}{+} \\cop{p}{+} \\aop{p}{-}\\\\\n\t& + \\sum _{pp'} (p'-1) \\cop{p}{+} \\aop{p}{-} \\cop{p'}{-} \\aop{p'}{+}\\\\\n\t& + \\sum _{p} (p-1) \\numop{p}{-} - \\sum _{p} (p-1) \\numop{p}{+} - \\sum _{pp'} (p-1) \\cop{p'}{+} \\aop{p'}{-} \\cop{p}{-} \\aop{p}{+}\\\\\n\t& + \\sum _{pp'} (p'-1) \\cop{p}{-} \\aop{p}{+} \\cop{p'}{+} \\aop{p'}{-}\n\\end{align*}\n\n\n\n\n\n%%% ALTERNATIVE FOR [V,SS] = 0 %%%\n\nWriting the term \\sop{-} \\commutator{\\vop}{\\sop{+}} explicitly:\n\n\\begin{align}\n\\begin{split}\n\t\\sop{-} \\commutator{\\vop}{\\sop{+}} &= \\left ( \\sminus{m} \\right ) \\left ( \\twobody{q}{s} \\right ) \\left ( \\splus{p} \\right )\\\\\n\t& - \\left ( \\sminus{m'} \\right ) \\left ( \\splus{p'} \\right ) \\left ( \\twobody{q'}{s'} \\right )\n\\end{split}\n\\label{eq:svs}\n\\end{align}\n\nThe first product of sums may be re-written as follows, noting that in \\ref{eq:svsmk1} and \\ref{eq:svsmk2} the first terms are dropped since \\aop{s}{-} \\aop{s}{-} and \\cop{q}{+} \\cop{q}{+} acting on any state will give 0.\n\n\\begin{align}\n\t& (-g) \\sum_{m q s p} \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\cop{p}{+} \\aop{p}{-}\\\\\n\t& (-g) \\sum_{m q s p} \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\left ( \\krondelt{s}{p} -  \\cop{p}{+} \\aop{s}{+} \\right ) \\aop{p}{-}\\\\\n\t& (-g) \\sum_{m q s p} \\krondelt{s}{p} \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{p}{-} - \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-}  \\cop{p}{+} \\aop{s}{+} \\aop{p}{-}\\\\\n\\label{eq:svsmk1}\t& (-g) \\sum_{m q s p} \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{-} - \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-}  \\cop{p}{+} \\aop{s}{+} \\aop{p}{-}\\\\\n\t& (-g) \\sum_{m q s p}  - \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-}  \\cop{p}{+} \\aop{s}{+} \\aop{p}{-}\\\\\n\t& (-g) \\sum_{m q s p}  \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+} \\cop{q}{-} \\aop{p}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum_{m q s p}  \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+} \\left ( \\krondelt{q}{p} -  \\aop{p}{-} \\cop{q}{-} \\right ) \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum_{m q s p} \\krondelt{q}{p} \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+}  \\aop{p}{-} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\\label{eq:svsmk2}\t& (-g) \\sum_{m q s p} \\cop{m}{-} \\aop{m}{+} \\cop{q}{+} \\cop{q}{+} \\aop{s}{-} \\aop{s}{+} - \\cop{m}{+} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+}  \\aop{p}{-} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum_{m q s p} - \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\cop{q}{+}  \\aop{p}{-} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\t& (-g) \\sum_{m q s p} - \\cop{m}{-} \\aop{m}{+} \\aop{p}{-} \\cop{p}{+} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\\\\\n\\label{eq:svsmk3}\t& (-g) \\sum_{m q s p} \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\aop{p}{-} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+}\n\\end{align}\n\nComparing the result from \\ref{eq:svsmk3} to the second product of sums in eq.~\\ref{eq:svs} which we re-write here as\n\n\\begin{equation}\n\tg \\sum _{m p qs} \\cop{m}{-} \\aop{m}{+} \\cop{p}{+} \\aop{p}{-} \\cop{q}{+} \\cop{q}{-} \\aop{s}{-} \\aop{s}{+} \\nonumber\n\\end{equation}\n\nwe find that $ \\sop{-} \\commutator{\\vop}{\\sop{+}} =0$\n\n\n\n\n\n\\end{comment}\n\n\\end{document}", "meta": {"hexsha": "6a587d8e836909ec4d409e70affcbb35b1938638", "size": 39753, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "projects/proj2/p2writeup.tex", "max_stars_repo_name": "redpath11/phy981_thr", "max_stars_repo_head_hexsha": "229e3f9a0c4e3a15ab0f948c328cb758988ae073", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projects/proj2/p2writeup.tex", "max_issues_repo_name": "redpath11/phy981_thr", "max_issues_repo_head_hexsha": "229e3f9a0c4e3a15ab0f948c328cb758988ae073", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-01-31T05:26:47.000Z", "max_issues_repo_issues_event_max_datetime": "2016-01-31T05:26:47.000Z", "max_forks_repo_path": "projects/proj2/p2writeup.tex", "max_forks_repo_name": "redpath11/phy981", "max_forks_repo_head_hexsha": "229e3f9a0c4e3a15ab0f948c328cb758988ae073", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.0122282609, "max_line_length": 438, "alphanum_fraction": 0.5466254119, "num_tokens": 18875, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4030263245140016}}
{"text": "\n\\documentclass[11pt]{scrartcl}\n\\usepackage[sexy]{evan}\n\\usepackage{braket}\n\\usepackage{color}   %May be necessary if you want to color links\n\\usepackage{hyperref}\n\\usepackage{tikz}\n\\usepackage[compat=1.1.0]{tikz-feynman}\n\\usepackage{comment}\n\n\n\\DeclareOldFontCommand{\\bf}{\\normalfont\\bfseries}{\\mathbf}\n\n\\hypersetup{\n\tcolorlinks=true, %set true if you want colored links\n\tlinktoc=all,     %set to all if you want both sections and subsections linked\n\tlinkcolor=blue,  %choose some color if you want links to stand out\n}\n\\usepackage{geometry}\n%\\usepackage{showframe} %This line can be used to clearly show the new margins\n\n\n\\newgeometry{vmargin={30mm}, hmargin={20mm,20mm}}   % set the margins\n\\begin{document}\n\t\\title{Digital Communication Theory} % Beginner\n\t\\date{December 2021}\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\t\\sffamily\\small\n\t\tHere is a collected notes on Digital Communications.\n\t\\end{abstract}\n\t\n\t\\vspace{1em}\n\t\n\t\\tableofcontents\n\t\\newpage\n\n\n\\section{Resources}\n\\begin{itemize}\n\t\\item \\emph{Thomas Cover, Elements of Information Theory}: Anything entropy, shannon capacity, refer to this.\n\t\n\t\\item \\emph{Cioffi notes}:   Each chapter covers the equivalent of a small book.  However lots of practical information nowhere else to be found (especially on equalization).\n\t\\item \\emph{Bane, Vasic}: Surprisingly good chapters on partial response channel capacity, coding (both RS and LDPC), and timing  recovery.\n\t\\end{itemize}\n\n\\section{Foundations}\n\n\\subsection{Information Theory}\n\n\\textbf{Entropy, facts and definitions}:\n\\begin{itemize}\n\t\\item Denote the \\vocab{entropy} of random variable X with probability distribution $p(x)$ to be:\n\t\\[ H(X) = - \\braket{ \\log (p(x)) } \\]\n\t\\item For a continuous random variable $X$ with density $f(x)$, the \\vocab{differential entropy} $h(X)$ is denoted to be:\n\t\\[h(X) = - \\int_S f(x) \\log f(x) dx \\]\n\twhere S is the support of X.\n\t\\item Similarly denote the \\vocab{joint entropy} for 2 random variables X, Y with distributions $p(x, y)$ to be:\n    \\[ H(X, Y) = -\\sum_{x, y} p(x, y) \\log(p(x, y)) = - \\braket{ \\log(p(x, y)) } \\]\n\t\\item  Denote the \\vocab{conditional entropy} of $H(Y | X)$ to be:\n\t\\[ H(Y| X) = \\braket{ \\log( p(y|x)) } \\]\n\t\\[ \\sum_{x \\in \\mathcal{X}} p(x) \\sum_{y \\in \\mathcal{Y}} p(y|x) \\log(p(y | x)) \\]\n\t\\[ \\sum_{x, y} p(x, y) \\log(p(y|x)) \\]\n\t\\item \\vocab{Chain rule}:\n\t\\[H(X, Y) = H(X) + H(Y|X) \\]\n\t\\item The \\vocab{kullback leibler} distance or \\emph{relative entropy} between 2 probability mass distributions p(x) and q(x) is defined as:\n\t\\[D(p || q) = \\sum_x p(x) \\log {p(x) \\over q(x)} = \\braket{\\log {p(x) \\over q(x)}} \\]\n\tIt is always non-negative, but it is not symmetric.\n\t\\item  The \\vocab{mutual information } I(X, Y) is the relative entropy between the joint and product distribution:\n\t\\[ I(X, Y) = \\sum_{x, y} p(x, y) \\log {p(x, y) \\over p(x) p(y)} \\]\n\t\\end{itemize}\n\n\\begin{example}\n\t\\begin{itemize}\n\t\t\\item The differential entropy for uniform $x \\in [0, a]$ is:\n\t\t\\[h(X) - \\int_0^a  dx {1 \\over a} \\log({1 \\over a}) = \\log(a) \\]\n\t\t\\item The differential entropy for gaussian variable with \n\t\t$f(x) = {1 \\over \\sqrt{2 \\pi \\sigma^2}} \\exp \\left( -{x^2 \\over 2 \\sigma^2}\\right)$ is:\n\t\t\\[h(X) = \\frac12 \\log (2 \\pi e \\sigma^2)\\]\n\t\t\\end{itemize}\n\t\\end{example}\n\\begin{lemma}\n\tThe gaussian distribution between 2 random variable x, y maximizes the differential entropy for any given positive semi-definite autocorrelation $R_{x,y}$:\n\t\\[ p_{x, y} = {1 \\over \\sqrt{\\pi \\det(R_{xy})} } \\exp \\left(- {\\mathbf{u}}^T R_{xy}^{-1} \\underbrace{\\mathbf{u}}_{\\equiv (x, y)} \\right) \\]\n\t\\end{lemma}\n\\includegraphics{entropy1.png}\n\n\\begin{definition}\n\tA statistic t(X) of some random variable $X$ is \\vocab{sufficient} \\emph{for underlying parameter $\\theta$}  if the conditional probability distribution of the data $X$ given t(X) does not depend on $\\theta$.  \n\tIt means $I(X, \\theta) = I(t(X), \\theta)$\n\\end{definition}\n\n\\begin{definition}\n\t\\end{definition}\n\n\\begin{theorem}\n\tConsider a signal $Y(t) = X(t) + N(t)$ where $X \\subseteq \\mathcal{L}_2$ with an orthonormal basis $ \\mathcal{S} \\{  \\phi_k \\}$.  Denote N(t) to be a white gaussian noise process with respect to $\\mathcal{S}$.  Then the set of measurements $\\braket{ \\phi_k | X}$ form a set of sufficient statistics for detection of X(t) from Y(t).\n\t\\end{theorem}\n\n\\begin{proof} See 6.451 notes, section 2.4\n\t\\end{proof}\n\n\n\\subsection{Channel Capacity}\ncioffic ch. 2\n\n\\begin{itemize}\n\t\\item The \\vocab{channel capacity} in bits/subsymbol for a channel described by $p(y|x)$ is defined by\n\t\\[  \\mathcal{C} = \\mathrm{max}_{p(x)} I(x, y) \\text{ } bits/subsymbol \\]\n\t\\item A slightly more fancy way to describe capacity is to describe the maximum mutual information with respect to a transmit and receive sequence of subsymbols: $\\bf{x}^n \\equiv (x_1, x_2, ..., x_{n})$ and $\\bf{y}^n = (y_1, ..., y_n)$.\n\t\\[ C = \\lim_{n \\rightarrow \\infty} {1 \\over n} \\mathrm{max}_{p(\\bf{x}^n)} I(\\bf{x}^n, \\bf{y}^n) \\]\n\tThe maximization $p(\\bf{x}^n)$ is taken over all probability density functions $p(\\bf{x}^n)$ which satisfy the symbol energy constraint given by \n\t\\[ \\braket{x_k^2} \\leq E_s \\]\n\t\\item An \\vocab{Additive White Gaussian Noise} channel is a channel where \n\t\\[y(t) = x(t) + n(t) \\]\n\twhere $n(t)$ is white.\n\\end{itemize}\n\n\\begin{theorem} \n\tGiven a channel with capacity $\\mathcal{C}$, then there exists a code with bitrate $b < \\mathcal{C}$ such that \n\t$P_e \\leq \\delta$ for any $ \\delta > 0$.  Furthermore, if $b > \\mathcal{C}$, then $P_e  \\geq \\text{positive constant}$, which is typically large even for b slightly greater than $\\mathcal{C}$.\n\t\\end{theorem}\n\n\\begin{theorem}\n\tGiven an AWGN channel, the channel capacity is\n\t\\[C = {W \\over 2} \\log_2 \\left(1 + {SNR} \\right)\\]\n\t\\end{theorem}\n\nIt's important to notice a few things about this formula:\n\\begin{itemize}\n\t\\item  The channel capacity obviously depends on the constraint on the transmit probability distribution.  The probability $p(x)$ distribution that maximizes capacity and gives the formula ${W \\over 2}  \\log_2 \\left(1 + {SNR} \\right)$ is gaussian.  The capacity when constrained to be different (PAM-2 symbols etc...) is in general a difficult optimization problem with no closed form solution.\n\t\\end{itemize}\n\n\n\\section{Detection and Estimation}\n\\newpage\n\\subsection{Biased SNR}\n\nConsider a signal processing system where we would like to slice an output\n\\[ y =  \\underbrace{\\alpha}_{\\text{adaptive gain}} (\\underbrace{x}_{\\text{symbol}} + \\underbrace{n}_{\\text{uncorrelated noise}})\\]\n\nMaximizing the SNR, or minimizing the MSE will lead to a \\vocab{biased} gain factor $\\alpha$ which is slightly less than 1.  To show this, we just need to minimize the error, defined as:\n\\[ \\text{MSE} = \\braket{(y - x)^2} = (\\alpha - 1)^2 \\epsilon_x + \\alpha^2 \\epsilon_n \\]\n\\[ \\pder{\\alpha}{\\text{MSE}} = 0 \\rightarrow \\alpha = {\\epsilon_x \\over \\epsilon_x + \\epsilon_n} = {SNR \\over 1 + SNR} \\]\n\nIt is straightforward to make the decisions unbiased by scaling $\\alpha$ by ${SNR + 1 \\over SNR}$, which leads to a relation between \\vocab{biased} and \\vocab{unbiased} SNR.\n\\[ SNR = SNR_{U} + 1 \\]\nThe reason why one would care is that a biased decision rule, while maximizing SNR, may not optimize BER.  We will further make rather trivial comments\n\n\\begin{itemize}\n\\item The distinction between biased and unbiased decreases as the SNR improves.  This is why for SERDES links, people rarely care about the distinction.\n\\item  While the analysis was done for a simple gain adaptation loop, all the conclusion remains for FFE adaptation.  In that case, if one uses a MMSE algorithm for adaptation, one will end up with a \\vocab{biased} decision rule, while if one uses a ZF algorithm, one will end up with a \\vocab{unbiased} adaptation.\n\t\\end{itemize}\n\\section{Math}\n\n\n\n\\end{document}", "meta": {"hexsha": "37228c51a0d95f38572e3dac6e4b2260ca474bc4", "size": 7761, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "digital_communications.tex", "max_stars_repo_name": "tranphysics/math-physics", "max_stars_repo_head_hexsha": "556f1fdfb769aa884fc0a144977687f141e3454d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "digital_communications.tex", "max_issues_repo_name": "tranphysics/math-physics", "max_issues_repo_head_hexsha": "556f1fdfb769aa884fc0a144977687f141e3454d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "digital_communications.tex", "max_forks_repo_name": "tranphysics/math-physics", "max_forks_repo_head_hexsha": "556f1fdfb769aa884fc0a144977687f141e3454d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.8113207547, "max_line_length": 395, "alphanum_fraction": 0.6950135292, "num_tokens": 2462, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525098, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.40302632094105434}}
{"text": "\\subsection{Original H.530 protocol description}\\label{subsec:h5301}\nThe H.530 protocol tries to address the problem of the Diffie-Hellman communication protocol authentication. As described in \\cite[p. 19]{sebmod2018}, without the authentication of half-keys, this protocol could lead to a \\textit{man-in-the-middle} attack.\nIn this exercise, the authentication is based on a third entity \\textit{s}, which is trusted by Alice (\\textit{A}) and Bob (\\textit{B}). Both \\textit{A} and \\textit{B} share a secret key with the trusted source \\textit{s}, so this last entity is in charge of signing \\textit{A} and \\textit{B} authenticity in order to ensure both parts that the other part is trustworthy.\n\\begin{figure}[hb]\n\t\\centering\t\n\t\\input{tex/sequence_diagrams/h530_sequence_diagram}\n\t\\caption{H.530 sequence diagram}\n\t\\label{fig:h530trace}\n\\end{figure}\n\\\\\nAs shown in \\textit{Figure \\ref{fig:h530trace}}, the protocol would be as follows:\n\\begin{itemize}\n\t\\item First of all, Alice sends a message to Bob with her half-key. The message is signed so that the trustworthy entity can verify the author of that message as Alice.\n\t\\item Bob asks the trustworthy entity about the authenticity of the message. He also includes his half-key and signs the message so that the trustworthy entity can verify the author of this message as Bob.\n\t\\item If both signatures are correct, the trustworthy entity will respond Bob by sending a message in which it states that \\textit{A} and \\textit{B} are trustworthy. The message will be signed twice in order for both Alice and Bob to be able to verify the third party's verdict. \n\t\\item Finally, when Bob verifies that Alice is trustworthy, he sends her a message with his half-key signed twice, one by the third party entity and the other by Bob himself, using the shared key $g^{XY}$.\n\t\\item If Alice can verify the authenticity of the message, she will be able to send a message to Bob secured by their recently created shared key $g^{XY}$.\n\\end{itemize}\n\\subsection{Original H.530 protocol analysis with OFMC and protocol redefinition}\\label{subsec:h5302}\nAs expected, OFMC \\cite{sebmod2005} detects an attack, which trace can be found in \\textit{Code 1}. This trace describes how a \\textit{man-in-the-middle} attack could be done with this protocol:\n\\begin{itemize}\n\t\\item\tAlice shares her half-key, $g^{X_1}$ , with Bob. However, it is intercepted by an intruder.\n\t\\item\tThe intruder opens the \\textbf{first} session with Bob, pretending that he/she is Alice and making up the half-key ($X_2$ is set to 1, so $g^{X_2}=g$) and Alice's signature.\n\t\\item\tBob asks the trustworthy entity to verify the malicious request, attaching to the message his half-key $g^{Y_1}$, but it is also intercepted by the intruder.\n\t\\item\tThe intruder now reproduces the original message from Alice and sends it to Bob by opening the \\textbf{second} session.\n\t\\item\tBob asks again the trustworthy entity to verify this duplicated request, attaching to his message a new half-key, $g^{Y_2}$. The intruder forwards the message to the trustworthy entity and intercepts its response.\n\t\\item\tThe trustworthy entity confirms that both Alice and Bob can be trusted. However, it does not sign any half-key to be used: Bob does not know that the original key, $g^{X_1}$, is the one that should be trusted.\n\\end{itemize}\n\\textit{Figure \\ref{fig:h530traceattack}} shows a sequence diagram that illustrates the attack.\\\\\n\\begin{figure}[ht!]\n\t\\centering\t\n\t\\input{tex/sequence_diagrams/h530_attack_sequence_diagram}\n\t\\caption{H.530 attack sequence diagram}\n\t\\label{fig:h530traceattack}\n\\end{figure}\nIn \\textit{\"h530-fix.AnB\"}, this issue is solved by making the trustworthy entity to sign not only Alice and Bob's identity but also the half-key $g^{X}$ A have decided to use for this session. With this small change, the security threat disappears: OFMC does not detect any attack.\\\\\nA sequence diagram with the changes made to the protocol is shown in \\textit{Figure \\ref{fig:h530tracefix}}.\n\\begin{figure}[ht!]\n\t\\centering\t\n\t\\input{tex/sequence_diagrams/h530_fix_sequence_diagram}\n\t\\caption{H.530 sequence diagram (fixed)}\n\t\\label{fig:h530tracefix}\n\\end{figure}\n\\subsection{Fixed H.530 protocol with untrustworthy third party entity}\\label{subsec:h5303}\nBy doing that, we are saying that the trustworthy entity cannot be trusted anymore: we cannot determine that an identity verification from S is safe.\nAs expected, once we have changed the entity and examined with OFMC, the simulator detects a potential attack, which steps are shown in \\textit{Figure \\ref{fig:h530traceS}}.\n\\begin{figure}[ht!]\n\t\\centering\t\n\t\\input{tex/sequence_diagrams/h530_fix_sequence_diagram_S}\n\t\\caption{H.530 attack sequence diagram (untrustworthy third party entity)}\n\t\\label{fig:h530traceS}\n\\end{figure}\n\\begin{itemize}\n\t\\item\tAlice shares her half-key, $g^{X}$, with Bob. However, it is intercepted by an intruder.\n\t\\item\tThe intruder pretends to be Bob and the third party entity at the same time, sending to Alice a weak half-key $g^{Y=1}=g$. It reuses the signature provided by Alice in the first message and signs the message with their new insecure shared key $g^{XY}=g^X$, which could be simply extracted from Alice's original message. From the point of view of Alice, the message is legit, as it appears to be signed by the trustworthy entity and by Bob with their recently created shared key.\n\t\\item\tAlice sends an encrypted message to the intruder, believing that the receiver is Bob. The intruder is able to decrypt the message and reads its content.\n\\end{itemize}\nThis attack trace shows that, if the trustworthy server can be substituted by a \\textit{man-in-the-middle} attack, it would be possible for an attacker to open a private, secure session with Alice, pretending that it is Bob the one at the other side.", "meta": {"hexsha": "1d4f09c2062d02b3814c90d15a29391ea2fc8eb4", "size": 5810, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "reports/lab2/tex/sections/1_h530.tex", "max_stars_repo_name": "romancardenas/data_security", "max_stars_repo_head_hexsha": "e46107941ecf4386b860604d20ee8d2a3cb8b195", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "reports/lab2/tex/sections/1_h530.tex", "max_issues_repo_name": "romancardenas/data_security", "max_issues_repo_head_hexsha": "e46107941ecf4386b860604d20ee8d2a3cb8b195", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "reports/lab2/tex/sections/1_h530.tex", "max_forks_repo_name": "romancardenas/data_security", "max_forks_repo_head_hexsha": "e46107941ecf4386b860604d20ee8d2a3cb8b195", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 100.1724137931, "max_line_length": 485, "alphanum_fraction": 0.7776247849, "num_tokens": 1476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.40302632094105423}}
{"text": "\n\\clearpage\n\\subsection{Scalar SM3 Acceleration}\n\\label{sec:scalar:sm3}\n\n\\begin{bytefield}[bitwidth={1.05em},endianness={big}]{32}\n\\bitheader{0-31} \\\\\n\\encsmthreepzero\n\\encsmthreepone\n\\end{bytefield}\n\n\\begin{cryptoisa}\nRV32, RV64\n    sm3p1 rd, rs1\n    sm3p0 rd, rs1\n\\end{cryptoisa}\n\nThese instructions are designed to accelerate the SM3 secure\nhash function\\cite{ietf:sm3}.\nThey are based on work done in \\cite{MJS:LWSHA:20}, and follow\nthe same pattern as the scalar SHA2 instructions\n(Section \\ref{sec:scalar:sha2}).\n\nThe instructions implement versions of the $P_0$ and $P_1$\npermutations, per the SM3 specification \\cite{ietf:sm3}.\nRISC-V Sail model code for each instruction is found in figure\n\\ref{fig:sail:sm3}.\n\n\\begin{figure}[h]\n\\lstinputlisting[language=sail,firstline=98,lastline=106]{../extern/sail-riscv/model/riscv_insts_kext.sail}\n\\caption{RISC-V Sail model specification for the scalar RV32/RV64 SM3 instructions.}\n\\label{fig:sail:sm3}\n\\end{figure}\n", "meta": {"hexsha": "dcaf87efa7606adfd3f3a926791b46ded29fb5d6", "size": 965, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/old-tex/tex/sec-scalar-sm3.tex", "max_stars_repo_name": "dingiso/riscv-crypto", "max_stars_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 199, "max_stars_repo_stars_event_min_datetime": "2020-08-13T15:48:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T13:57:34.000Z", "max_issues_repo_path": "doc/old-tex/tex/sec-scalar-sm3.tex", "max_issues_repo_name": "dingiso/riscv-crypto", "max_issues_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 118, "max_issues_repo_issues_event_min_datetime": "2020-08-13T16:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T20:00:35.000Z", "max_forks_repo_path": "doc/old-tex/tex/sec-scalar-sm3.tex", "max_forks_repo_name": "dingiso/riscv-crypto", "max_forks_repo_head_hexsha": "608f550ea2a791fb091133fe6050321545dfc547", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 56, "max_forks_repo_forks_event_min_datetime": "2020-08-28T16:09:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T10:10:58.000Z", "avg_line_length": 28.3823529412, "max_line_length": 107, "alphanum_fraction": 0.7678756477, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.40296872173751014}}
{"text": "\\documentclass[main_zanardi.tex]{subfiles}\n\n\\begin{document}\n\nZanardi from the University of Southern California.\n\n\\section{Distances over quantum state spaces}\n\n\\paragraph{What we will talk about}\n\nWhat is a metric? \"Trace norm distance\"\n\nInformation theore\ntical protocol\n\nBattacharya distance; its infinitesimal version: the Fischer metric, the Fubini-Study metric: many body physics, Quantum Phase Transitions.\n\nAt zero temperature, we only have the ground state, there is no entropy, so how do transitions work?\n\nThe statements preceded by the word \"claim\" are left as exercises.\n\n\\subsection{Quantum theory recap}\n\nWe have \\emph{states} and \\emph{observables}. We call the system $S$, and its associated Hilbert space \\(\\H\\). (No real quantum system is going to be truly isolated).\n\nA state \\(\\rho\\) is a density matrix, an observable is a Hermitian operator over \\(\\H\\).\n\n\\begin{equation}\n  S(\\H) = \\qty{\\rho |\\, \\rho \\geq 0, \\, \\Tr \\rho = 1}\n\\end{equation}\n\nThen \\(\\forall \\phi \\in \\H: \\ev{\\rho}{\\phi} \\geq 0\\), \\(\\rho = \\rho ^\\dag\\).\n\n\\(\\sigma (\\rho) = \\text{spectrum of } \\rho = \\qty{p_i}_i\\). \\(d = \\dim (\\H)\\).\n\n\\(p_i \\geq 0\\), \\(\\sum_i p_i = 1\\).\n\nSo quantum theory is just noncommutative probability theory.\n\n\\paragraph{Single qubit}.\n\n\\(\\H \\sim \\mathbb{C}^2$, $\\dim \\H = 2$, $\\rho = \\frac{1}{2} \\qty(\\mathbb{1} + \\vec{\\lambda} \\cdot \\vec{\\sigma})\\).\n\n\\(\\vec{\\lambda}\\) is the Bloch vector, \\(\\vec{\\sigma}\\) are the Pauli matrices.\nIf \\(\\abs{\\vec{\\lambda}} = 1\\), we have a pure state.\n\n\\paragraph{Exercise}\nProve that \\(\\rho\\) being a density matrix is equivalent to \\(\\abs{\\lambda}\\leq 1\\), and that \\(\\abs{\\lambda} = 1 \\iff \\rho^2 = \\rho \\iff \\rho = \\ketbra{\\psi}\\).\n\nCreating convex combinations of states should always be allowed,  and we see this in the fact that the space of states is convex.\n\nStates are usually decomposable as probabilistic mixtures, which are convex combinations in \"Bloch space\" (or its generalizations).\n\n\\subsection{Telling states apart} We are given two states \\(\\rho _{1, \\, 2}\\): what is the measurement which maximizes the probability we will be able to tell one from the other?\n\nProbability vectors: \\(\\vec{p} = (p_i)\\), \\(\\vec{q} = (q_i)\\). We can use the \"\\(\\ell_1\\)\" metric:\n\n\\begin{equation}\n  d(p, q) = \\sum_i \\abs{p_i - q_i}\n\\end{equation}\n\nClaim: this is a distance.\n\nCan we do the same for quantum states? In general, \\([\\rho_1,  \\rho_2] \\neq 0\\), we do not have a common eigenbasis. Could we use the Frobenius metric? Eeh, not really.\n\nWe have a map from observables to numbers: \\(A \\rightarrow \\Tr \\qty(\\rho A) = \\langle A \\rangle_\\rho\\).\n\nWe can do \\(\\sup{\\abs{{\\langle A \\rangle_{\\rho_1} - \\langle A \\rangle_{\\rho_2}}}}\\) (Over \\(\\norm{A} = 1\\)).\n\n\\begin{equation}\n  \\norm{A} = \\sup_{\\psi \\neq 0} \\frac{\\norm{A\\psi}}{{\\psi}}\n\\end{equation}\n\nSo our distance is\n\n\\begin{equation}\n  d = \\sup_{\\norm{A}=1} \\abs{\\Tr \\qty[A(\\rho_1 - \\rho_2)]}\n\\end{equation}\n\nWe know that\n\n\\begin{align}\n  \\abs{\\Tr \\qty(AB)} &= \\sum_i b_i \\ev{A}{i} \\\\\n  &\\leq \\sum_i \\abs{b_i} \\ev{A}{i} \\\\\n  &\\leq \\norm{A} \\sum_i \\abs{b_i} \\\\\n  &\\leq \\norm{A} \\Tr \\abs{B}\n\\end{align}\n\nWhere \\(B = \\sum_i b_i \\ketbra{i}\\)),\nand we call \\(\\norm{B}_1 = \\Tr \\abs{B}\\), where the modulus of the operator can be thought of eigenvalue-wise (diagonalizing the operator, and then flipping the sign of all the negative eigenvalues).\n\nSo\n\n\\begin{equation}\n  d \\leq \\norm{A} \\norm{\\rho_1 - \\rho_2}_1 = \\norm{\\rho_1 - \\rho_2}_1\n\\end{equation}\n\nClaim: this in an equality (there \\emph{always} exists an $A$ to do the job).\n\nDo we get back the classical case if the matrices commute? Claim: yes.\n\nWe call \\(D(\\rho_1, \\rho_2) = \\frac{1}{2} \\norm{\\rho_1 - \\rho_2}_1\\). (since the $d$ we used before is upper-bounded by 2, by the triangular inequality).\n\n\"the duals of self-adjoint operators are traceles\"?\n\n\\paragraph{Measurements}\nVon Neumann orthogonal measurement we know about.\n\nGeneralized measurement: we have an ancillary system, mearure this system and then trace over it. This is not described by an orthogonal projection:\n\n\\paragraph{Positive Operator-Valued Measurement}\n\nWe have finitely many \\(\\qty{E_i}_i\\), \\(E_i \\geq 0\\),  \\(\\sum_i E_i = \\mathbb{1}\\).\n\n\\(\\rho \\rightarrow p_i = \\Tr (\\rho E_i)\\).\n\n2-element POVM: \\(E_{1, \\, 2} \\geq 0\\), we have our states \\(\\rho_{1, \\, 2}\\).\n\nSay we get the states with \\(50\\%\\) probability each, and we wish to distinguish them:\n\n\\begin{equation}\n  P(\\text{success}) = \\frac{1}{2} \\qty[\\Tr(E_1 \\rho_1) + \\Tr(E_2 \\rho_2)]\n\\end{equation}\n\n\\begin{equation}\n  P(\\text{error}) = \\frac{1}{2} \\qty[\\Tr(E_1 \\rho_2) + \\Tr(E_2 \\rho_1)]\n\\end{equation}\n\nWe want to maximize \\(P(\\text{success})\\). We can rewrite it as:\n\n\\begin{align}\n  P(\\text{success}) &= \\frac{1}{2} \\qty[\\Tr(E_1 \\rho_1) + \\Tr\\qty((\\mathbb{1} - E_1) \\rho_2)] \\\\\n  &= \\frac{1}{2}\\qty[1 + \\Tr \\qty(E_1 (\\rho_1 - \\rho_2))]\n\\end{align}\n\nto maximize over $E_1$. The optimum (Claim) is\n\n\\begin{equation}\n  P(\\text{success}) = \\frac{1}{2}\\qty[1 + \\frac{1}{2} \\norm{\\rho_1 + \\rho_2}_1]\n\\end{equation}\n\nHellstrom optimal measurement?\nThis is 1 if they are maximally different, $1/2$ if they are indistinguishable.\n\n$E_1$ should be the projection over the positive eigenvalues of the difference between the matrices.\n\n\\paragraph{Bhattacharyya distance}\n\nWe have two probability vectors \\(\\vec{p} = \\qty(p_i)_i\\), \\(\\vec{q} = \\qty(q_i)_i\\).\nNormalized in the euclidean metric, if we take the square root component by component: \\(V_p = \\qty(\\sqrt{p_i})_i\\).\n\n\\begin{equation}\n  d_B (\\vec{p}, \\vec{q}) = \\cos^{-1} (\\vec{V_p}, \\vec{V_q})\n\\end{equation}\n\nClaim: this is a distance.\n\n\\begin{equation}\n  d_B (\\vec{p}, \\vec{q}) = \\cos^{-1} \\qty(\\sum_i \\sqrt{p_i q_i})\n\\end{equation}\n\n\\paragraph{Quantize it!}\n\nLet us focus on the pure state case:\nwe have a POVM \\(\\mathbb{E} = \\qty{E_i}\\), and two probability distributions \\(\\rho = \\ketbra{\\phi}\\), \\(\\sigma = \\ketbra{\\psi}\\)\n\n\\begin{equation}\n  P_\\phi (i) \\defeq \\Tr (E_i \\rho) = \\ev{\\phi}{E_i}\n\\end{equation}\n\nand similarly for \\(\\psi\\).\n\nThe Bhattacharyya distance is\n\n\\begin{equation}\n  d_B (\\phi, \\psi) = \\sup _\\mathbb{E} d_B\\qty(\\vec{P_\\phi}, \\vec{P_\\psi})\n\\end{equation}\n\nTheorem:\n\n\\begin{equation}\n  d_B (\\phi, \\psi) = \\cos^{-1} \\abs{\\braket{\\phi}{\\psi}}\n\\end{equation}\n\nthis is the Fubini-Study metric over a projective Hilbert space.\n\nWe can generalize this to differential geometry.\n\n\\begin{greenbox}\n  In this particular case this can be expressed as\n  \\(\\abs{\\braket{\\phi}{\\psi}} = \\sqrt{\\Tr \\qty(\\rho\\sigma)}\\)\n  but the result does not generalize.\n\\end{greenbox}\n\\end{document}\n", "meta": {"hexsha": "a8f6cafbd472263c0db700747aa30ff8dd0e2853", "size": 6541, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "info_Q/zanardi/zanardi1.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "info_Q/zanardi/zanardi1.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "info_Q/zanardi/zanardi1.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 33.5435897436, "max_line_length": 199, "alphanum_fraction": 0.6719156092, "num_tokens": 2223, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.40296870837071763}}
{"text": "% !TEX root=/home/tavant/these/manuscript/src/manuscript.tex\n\n\n\\section{Objectives of the chapter}\n\\label{sec-ch4objectiv}\n\nIn \\Cref{sec-sheath_validation}, we have seen that the plasma-wall interaction observed in the \\ac{2D} \\ac{PIC} simulations are different from the classical sheath models.\nWe recall here the main observations of \\cref{ch-2}.\nWe have conducted a parametric study on the wall emissivity by varying the crossover energy $\\crover$ in the emission probability\n\\begin{equation*}\n  \\proba = \\sigo + ( 1 - \\sigo) \\frac{\\ek}{\\crover},\n\\end{equation*} \nwith $\\ek$ the electron kinetic energy.\nThe \\ac{SEE} rate (or yield) $\\rate$ is the emission probability $\\proba$ averaged over the electron flux at the wall.\nWith a Maxwellian flux of temperature $\\Te$, we have \n\\begin{equation}  \\label{eq-rate2}\n  \\ratemaxw = \\sigo + ( 1 - \\sigo) \\frac{2 \\Te}{\\crover}.\n\\end{equation}\nThe sheath model with \\ac{SEE} predicts a potential drop between the sheath-edge and the wall of \\citep{goebel2008,hobbs1967}\n\\begin{equation} \\label{eq-dphi2}\n  \\dphi = \\Te \\log \\lp [1 - \\rate] \\sqrt{\\frac{m_i}{2 \\pi m_e}}  \\rp.\n\\end{equation}\n\nIn \\cref{ch-2}, \\cref{fig-seeparamesMaxw} and \\cref{fig-Tevsproba}.{\\bf a} (reproduced here in \\cref{fig-Tevsproba2} to ease the reading of the chapter) show both the plasma potential $\\dphi$ and the \\ac{SEE} rate $\\rate$ measured in the \\ac{PIC} simulations and obtained from \\Cref{eq-rate2,eq-dphi2}.\nWe see that the plasma potential is overestimated for low values of $\\rate$ by around 30\\%.\nMoreover, the \\ac{SEE} rate is also overestimated.\n \n\\begin{figure}[hbt]\n  \\centering\n  \\begin{tabular}{@{} cc}\n    \\includegraphics[width=0.45\\textwidth]{phi_drop_6}\n    &\n    \\subfigure{SEE_rates}{{\\scriptsize b}}{20,18}\n  \\end{tabular}\n  \\caption{({\\bf a}) Plasma potential drop to the wall $\\dphi$ normalized by the electron bulk temperature $\\Te$ as a function of the electron rate (blue) measured in the \\acs{PIC} simulations and (orange) calculated with   \\cref{eq-dphi2}; ({\\bf b})  the \\acs{SEE} rate $\\rate$ (blue) measured in the PIC simulation, and (orange)  calculated with \\cref{eq-rate2}. }\n  \\label{fig-Tevsproba2}\n\\end{figure}\n\nThe discrepancy is most certainly due to the isothermal hypothesis.\nIn \\cref{ch-3}, we have developed a sheath model without the isothermal hypothesis, but instead the polytropic state law.\nThe objective of this chapter is to add to the polytropic sheath model of \\cref{ch-3} the electron emission from the wall, in order to better predict the plasma-wall interaction.", "meta": {"hexsha": "310f6d004b8758fe17913d443dca5285aec9929d", "size": 2542, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/Chapitre4/40-teasing.tex", "max_stars_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_stars_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Chapitre4/40-teasing.tex", "max_issues_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_issues_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Chapitre4/40-teasing.tex", "max_forks_repo_name": "antoinetavant/PhD_thesis_manuscript", "max_forks_repo_head_hexsha": "1fdaf99356f75abc488edf1f30b5dd65f22bcdca", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.0, "max_line_length": 366, "alphanum_fraction": 0.7344610543, "num_tokens": 781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40281780276121015}}
{"text": "\\section{Introduction}\n  Modern online marketplaces can be roughly categorized as centralized and decentralized.\n  Two major examples of each category are \\href{http://www.ebay.com}{ebay} and \\href{https://openbazaar.org/}{OpenBazaar}.\n  The common denominator of established online marketplaces is that the reputation of each vendor and client is either\n  expressed in the form of stars and user-generated reviews that are viewable by the whole network, or not expressed at\n  all inside the marketplace and instead is entirely built on word-of-mouth or other out-of-band means.\n\n  The goal of \"Trust Is Risk\" is to offer a decentralized marketplace where the trust each user gives to the rest of the users\n  is quantifiable, measurable and expressable in monetary terms. The central concept used throughout this paper is that trust\n  is equivalent to risk, or the proposition that $Alice$'s \\textit{trust} to another user $Bob$ is defined to be the\n  \\textit{maximum sum of money} that $Alice$ can lose when $Bob$ is free to choose any strategy he wants. To flesh out this\n  concept, we will use \\textit{lines of credit} as proposed by Washington Sanchez \\cite{loc}, not to be confused with the\n  synonymous financial product. Joining the network will be done by explicitly entrusting a certain amount of money to another\n  user, say $Bob$. If $Bob$ has already entrusted an amount of money to a third user, $Charlie$, then we indirectly trust\n  $Charlie$ since if the latter wished to play unfairly, he could have already stolen the money entrusted to him by $Bob$.\n  Thus we can engage in economic interaction with $Charlie$. The currency used is Bitcoin \\cite{bitcoin}.\n  \\medskip \\ \\\\\n  \\subimport{common/figures/}{simpleexample.tikz} \\smallskip \\ \\\\\n  We thus propose a new kind of wallet where coins are not stored locally, but are placed in 1-of-2 multisigs, a bitcoin\n  construction that permits any one of two pre-designated users to spend the coins contained therein \\cite{masteringbitcoin}.\n  We will use the notation 1/$\\{Alice, Bob\\}$ to represent a 1-of-2 multisig that can be spent by either $Alice$ or $Bob$.\n\n  Our approach changes the user experience in a subtle but drastic way. A user no more has to base her trust towards a store\n  on stars or ratings which are not expressed in financial units. She can simply consult her wallet to decide whether the\n  store is trustworthy and, if so, up to what value, denominated in bitcoin. This system works as follows: Initially $Alice$\n  migrates her funds from her private bitcoin wallet to 1-of-2 multisig addresses shared with friends she comfortably trusts.\n  We call this direct trust. Our system is agnostic to the means players use to determine who is trustworthy for these direct\n  1-of-2 deposits. One novelty of our system is that this dubious kind of trust is confined to the direct neighbourhood of\n  each player; indirect trust towards unknown users is calculated by a deterministic algorithm.  For comparison, systems with\n  global ratings do not distinguish between neighbours and other users, thus offering dubious trust indications for all users.\n\n  Suppose that $Alice$ is viewing the item listings of vendor $Charlie$. Instead of $Charlie$'s stars, $Alice$ will see a\n  positive value that is calculated by her wallet and represents the maximum monetary value that $Alice$ can safely use to\n  complete a purchase from $Charlie$. We examine exactly how this value, known as indirect trust, is calculated in Trust Flow\n  theorem~\\ref{trustflow}. It is important to note here that indirect trust to a specific user is not global but subjective;\n  each user views a personalized indirect trust based on the network topology. The indirect trust reported by our system\n  maintains the following desired security property: If $Alice$ makes a purchase from $Charlie$, then she is exposed to no\n  more risk than she was already taking willingly. The existing willing risk is exactly that which $Alice$ was taking by\n  sharing her coins with her trusted friends. We prove this result in the Risk Invariance theorem~\\ref{riskinv}. Obviously it\n  will not be safe for $Alice$ to buy anything from $Charlie$ or any other vendor if she has entrusted no value to any other\n  user.\n\n  We see that in Trust Is Risk the money is not invested at the time of the purchase and directly to the vendor, but at an\n  earlier point in time and only to parties that are trustworthy for out of band reasons. The fact that this system can\n  function in a completely decentralized fashion will become clear in the following sections. We prove this result in the\n  Sybil Resilience theorem~\\ref{sybil}.\n\n  There are several incentives for a user to join this network. First of all, she can have access to a store that is\n  otherwise inaccessible. Moreover, two friends can formalize their mutual trust by entrusting the same amount to each\n  other. A large company that casually subcontracts other companies to complete various tasks can express its trust\n  towards them using this method. A government can choose to entrust its citizens with money and confront them using a\n  corresponding legal arsenal if they make irresponsible use of this trust. A bank can provide loans as outgoing and\n  manage savings as incoming trust and thus has a unique opportunity of expressing in a formal and absolute way its\n  credence by publishing its incoming and outgoing trust. Last but not least, the network can be viewed as a possible\n  field for investment and speculation since it constitutes a completely new area for financial activity.\n\n  It is worth noting that the same physical person can maintain multiple pseudonymous identities in the same trust network\n  and that multiple independent trust networks for different purposes can coexist. On the other hand, the same\n  pseudonymous identity can be used to establish trust in different contexts.\n", "meta": {"hexsha": "bb6cd52e193d5c3303563c82c0dbac6a0356ba70", "size": 5896, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/introduction.tex", "max_stars_repo_name": "dionyziz/DecentralizedTrust", "max_stars_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 25, "max_stars_repo_stars_event_min_datetime": "2017-03-15T14:33:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-01T14:07:45.000Z", "max_issues_repo_path": "thesis/introduction.tex", "max_issues_repo_name": "dionyziz/DecentralizedTrust", "max_issues_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-03-07T12:25:26.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-31T14:42:20.000Z", "max_forks_repo_path": "thesis/introduction.tex", "max_forks_repo_name": "dionyziz/DecentralizedTrust", "max_forks_repo_head_hexsha": "60f65bff00041e7e940491913bd4ca3f11bf22d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-07T10:49:58.000Z", "max_forks_repo_forks_event_max_datetime": "2017-08-28T06:32:33.000Z", "avg_line_length": 98.2666666667, "max_line_length": 126, "alphanum_fraction": 0.7879918589, "num_tokens": 1281, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4028177944752977}}
{"text": "\\chapter{Methodology}\n\\label{ch:methods}\n\n%This chapter should introduce to the theoretical background of your thesis. Any method you use to obtain the results later should be introduced and explained. \nThis chapter introduces the methods that are applied in this thesis. The first group of methods comprises the used forecasting methods, the second group involves feature selection techniques and the last group covers methods that are used to evaluate forecasts.\\\\\n%This chapter introduces the methods that are applied in this thesis. First, the used forecasting methods are introduced. After that, the used feature selection techniques are explained and also the methods that were applied for error measuring.\\\\\n%In this chapter, the used forecasting methods are explained and why they were used. After that, other methodological aspects of this thesis will be outlined.\\\\\n\n%Using weather data from ECMWF Copernicus Climate Change Service (C3S).\\\\\n%Using load data from \\url{https://data.open-power-system-data.org/}.\\\\\n%First downloaded whole Datasets from 2006-2019, but as the load for germany is properly available since 2015, now reduced dataset to 2015-2019.\\\\\n%Also checked for non-existing values, only 2 last timestamps values for the load are missing.\\\\\n\n%\\section{Data acquisition}\n%\\label{sec:dataq}\n%\n%In order to acquire the needed weather data, \\gls{ecmwf}'s Python-API is used for automated data acquisition. The API has been extended by some functionality recently and allows to download the data with different extensions. The chosen extension is .nc, because Python's xarray library allows performant access to these files.\\\\\n%\n%The used load data has been downloaded from Open Power System Data\\footnote{\\url{https://data.open-power-system-data.org/time_series/}}. As the format of the downloaded data is .csv, it has also been converted to .nc to obtain performant and uniform access to all data.\\\\\n\n\\section{Forecasting Methods}\n\\label{sec:forecastmet}\n\nFor time series forecasting, often used methods are \\eg \\gls{arma} models as mentioned in \\tcite{Hyndman2018}. This sections will introduce the methods that are applied in this thesis to forecast the electricity load.\\\\% Forecasting: Principles and Practice\\footnote{\\url{https://otexts.com/fpp2}}.%, but  also \\gls{nn}, where it is common to reduce the number of input variables in order to speed up computation, which is desirable for the huge amount of grid-based data that grows quadratically with size. There are also some papers that use regression models other than \\gls{arma} such as \\gls{lr}, \\gls{mlr} or \\gls{svm}. \\tcite{Aguiar2016} applies \\gls{nn} to do intra-day solar radiation forecasting with a forecasting horizon of 1-6 hours on Gran Canaria and, as in this thesis, grid-based data from \\gls{ecmwf} is used.\\\\\n\n%\\subsection{Linear Regression}\n\\subsection*{ARMA}\n\nThe \\gls{arma} model is a combination of \\acrfull{ar} and \\gls{ma} terms. The formal description is given by\\\\\n\n\\begin{equation}\ny_t = c+\\sum_{i=1}^{p}\\phi_iy_{t-i}+\\sum_{j=1}^{q}\\rho_j\\epsilon_{t-j}+\\epsilon_t~,\n\\label{eq:arma}\n\\end{equation}\n\nwith $c$ as a constant, $\\epsilon_t$ as noise term with respect to time $t$, $p$ as size of the \\gls{ar} part, $q$ as size of the \\gls{ma} part, $\\phi$ and $\\rho$ for the \\gls{ar} and \\gls{ma} coefficients respectively and $y_t$ as the response variable.\\\\\n\n\\subsection*{ARMAX}\n\nAn extension of \\gls{arma} is \\gls{armax}, which includes an additional term for exogenous variables. This term can be used to include relations to external factors that do not depend on the endogenous data. It is formally described as\\\\\n\n\\begin{equation}\ny_t = c+\\sum_{i=1}^{p}\\phi_iy_{t-i}+\\sum_{j=1}^{q}\\rho_j\\epsilon_{t-j}+\\sum_{k=1}^{n}\\eta_kx_k+\\epsilon_t~.\n\\label{eq:armax}\n\\end{equation}\n\nThe only difference between \\Cref{eq:armax} and \\Cref{eq:arma} is the additional term $\\sum_{k=1}^{n}\\eta_kx_k$ for the \\gls{armax} for $n$ included exogenous variables $x$ with $\\eta$ as the respective coefficients.\\\\\n%\\Cref{eq:armax} almost equals \\Cref{eq:arma} for the \\gls{arma} model, but here, there is an additional term $\\sum_{k=1}^{n}\\eta_kx_k$ for $n$ included exogenous variables $x$ with $\\eta$ as the respective coefficients.\n\n%\\subsubsection{only calendar variables as exogenous inputs}\n%\n%\\subsubsection{additional weather variables as exogenous inputs}\n\n\\section{Feature Selection Techniques}\n\\label{sec:featsel}\n\nBecause the used weather data is grid-based, there are two more dimensions than usual, where only one value per time step exists for a variable. This is why feature selection here is more important in order to obtain a reasonable computation time. In the following, the used methods for feature selection are presented.\\\\\n\n\\subsection*{Naive approach}\n\nFirst, naive techniques are presented, that are used to reduce the huge amount of grid-based weather data. They are reduced along the two spatial dimensions, longitude and latitude, for each step in time, respectively. These are simple functions such as the maximum or the mean. An exemplary formula for reducing the data along longitude and latitude using the mean is given as\\\\\n\n\\begin{equation}\nx_t = \\frac{1}{l \\times m} \\sum_{i=1}^{l}\\sum_{j=1}^{m}x_{ij}~,\n\\end{equation}\n\nwhere $x_t$ is the calculated mean for time $t$, $l$ and $m$ are the size of the data along the axis of the longitude and latitude and $x_{ij}$ is the value of a weather variable at the grid point with longitude $i$ and latitude $j$.\n\n\\subsection*{Using Population Data}\n\nAnother method involves population data from Eurostat\\footnote{\\url{https://ec.europa.eu/eurostat/data/database}}. It contains the population of NUTS 3 level regions. The regions are sorted by population and those with the highest population are used to filter the respective grid points that are then used as exogenous variables.\\\\\n\n%\\subsection{Principal Component Analysis}\n\n\\section{Forecast Evaluation}\n\\label{sec:fceval}\n\nIn order to estimate whether the used model performs well, it is important to apply suitable metrics to evaluate the results. In the following, the four used metrics are introduced, where for each metric, $k$ is the number of forecast values, $y$ the actual values and $\\hat{y}$ the predicted values.\\\\\n\n\\subsection*{Root Mean Squared Error}\n\nThe first metric is the \\gls{rmse}, which is an often used, scale-dependent accuracy measure that calculates the root of the squared mean of the differences between the forecast and the actual values. It is described by\\\\\n\n\\begin{equation}\nRMSE = \\sqrt{\\frac{1}{k} \\sum_{i=1}^{k} (y_i-\\hat{y}_i)^2}~.\n\\label{eq:rmse}\n\\end{equation}\n\n\\subsection*{Mean Absolute Error}\n\nThe second metric is the \\gls{mae}, which is another scale-dependent accuracy measure that averages absolute errors. The equation for the \\gls{mae} is described by\\\\\n\n\\begin{equation}\nMAE = \\frac{1}{k} \\sum_{i=1}^{k} \\left|y_i-\\hat{y}_i\\right|~.\n\\end{equation}\n\n\\subsection*{Mean Percentage Error}\n\nThe third metric is the \\gls{mpe}, which is a relative measure of the prediction accuracy. Since it is multiplied by 100 after dividing it by the size of the predictions, it is called a percentage error. The equation is\\\\\n%The \\gls{mpe} is the computed average of percentage errors by which forecasts of a model differ from actual values of the quantity being forecast\n\n\\begin{equation}\nMPE = \\frac{100}{k} \\sum_{i=1}^{k} \\frac{y_i-\\hat{y}_i}{y_i}~.\n\\end{equation}\n\n\\subsection*{Mean Absolute Percentage Error}\n\nThe fourth metric is the \\gls{mape}, which is similar to the \\gls{mpe}, but takes the absolute value of each single error instead. The equation for the \\gls{mape} is given by\\\\\n\n\\begin{equation}\nMAPE = \\frac{1}{k}\\times 100 \\sum_{i=1}^{k} \\left|\\frac{y_i-\\hat{y}_i}{y_i}\\right|~.\n\\label{eq:mape}\n\\end{equation}\n\n\n%Maybe use Random Forests for variable selection as in Nicoles paper? \\Parencite{Ludwig2015}\\\\\n\n%This is an example for a simple equation without equation numbering.\n%$$\n%\\sum\\limits_{i=1}^{n}{x_i}\n%$$\n\n%You can also use equation numbering if you need to refer to an equation later \\eg \\Cref{eq:ex1}.\n\n\n%\\begin{equation}\n%a^2 + b^2 = c^2\n%\\label{eq:ex1}\n%\\end{equation}\n%\n%Additionally, simple equations can be put inline with the text, for example, $x \\in X$. Remember to set all variables in math font \\ie all $x$, $i$ and so on.\n%\n%\\section{Method 2}\n%\n%\\dots\n\n", "meta": {"hexsha": "22bbd2689a00b3d9058c00285eaf9f75c4842086", "size": 8344, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/sections/methods.tex", "max_stars_repo_name": "maGitty/GISME", "max_stars_repo_head_hexsha": "8d15df4d39c5f49b6b856fd584085c2db0263a2c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/sections/methods.tex", "max_issues_repo_name": "maGitty/GISME", "max_issues_repo_head_hexsha": "8d15df4d39c5f49b6b856fd584085c2db0263a2c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-02T00:49:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-02T00:49:09.000Z", "max_forks_repo_path": "doc/sections/methods.tex", "max_forks_repo_name": "maGitty/GISME", "max_forks_repo_head_hexsha": "8d15df4d39c5f49b6b856fd584085c2db0263a2c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.9051094891, "max_line_length": 829, "alphanum_fraction": 0.7589884947, "num_tokens": 2253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40281779447529764}}
{"text": "\\chapter{The Second Chapter}\n\\label{sec:second}\n\n\\kant[7-11] % Dummy text\n\n\\begin{theorem}[{\\cite[95]{AM69}}]\n    \\label{thm:dedekind}\n    Let \\( A \\) be a Noetherian domain of dimension one. Then the following are equivalent:\n    \\begin{enumerate}\n        \\item \\( A \\) is integrally closed;\n        \\item Every primary ideal in \\( A \\) is a prime power;\n        \\item Every local ring \\( A_\\mathfrak{p} \\) \\( (\\mathfrak{p} \\neq 0) \\) is a discrete valuation ring.\n    \\end{enumerate}\n\\end{theorem}", "meta": {"hexsha": "46c9ed5c53fab4930f22710c88dd4b0d2fca27e7", "size": 499, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chapter2.tex", "max_stars_repo_name": "courses-at-nju-by-hfwei/compilers-book", "max_stars_repo_head_hexsha": "c263340f939a2c09f47cf094c0a823cf56b02c43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2020-03-09T10:45:25.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-16T09:10:45.000Z", "max_issues_repo_path": "starting-kit/sections/chapter2.tex", "max_issues_repo_name": "wo315/Introduction-to-LaTeX", "max_issues_repo_head_hexsha": "dd8f75f678efb5c336e58f62c01637c87b6e684b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "starting-kit/sections/chapter2.tex", "max_forks_repo_name": "wo315/Introduction-to-LaTeX", "max_forks_repo_head_hexsha": "dd8f75f678efb5c336e58f62c01637c87b6e684b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-02-05T08:36:14.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-02T23:57:08.000Z", "avg_line_length": 35.6428571429, "max_line_length": 109, "alphanum_fraction": 0.6392785571, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40281779447529764}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[english]{babel}\n\\usepackage[utf8x]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{parskip}\n\\usepackage{lipsum}\n\\usepackage[a4paper, total={6in, 8in}]{geometry}\n\\usepackage{setspace}\n\\usepackage[superscript]{cite}\n\\usepackage{xcolor}\n\\usepackage{hyperref}\n\\usepackage{enumitem}\n\\usepackage{listings}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{ifsym}\n\\usepackage{tikz}\n\n\n\\begin{document}\n\t\n\t\n\t\\begin{flushright}\n\t\t\\today\n\t\\end{flushright}\n\t{\\Large \\textbf{Assignment 11}}\n\t\n\t{\\large Query Optimization}\n\t\n\t\\textsc{Ilaria Battiston - 03723403} \\\\\n\t\\textsc{Mareva Zenelaj - 03736071}\n\t\n\t\\rule{\\linewidth}{0.5pt}\n\t\n\t\\section{First exercise}\n\t\n\t$m = 3$ \n\t\n\t$n = 2$ \n\t\n\t$N = m * n = 6$ \n\t\n\t$k = 2$ \n\t\n\t$p = \\frac{\\binom{N - k}{k}}{\\binom{N}{k}} = \\frac{\\binom{4}{2}}{\\binom{6}{2}} = \\frac{6}{15}$\n\t\n\t$\\overline{{Yao}}_n^{N,m} (k) = m * {Yao}_n^N (k)$\n\t\n\tsince $k \\leq N - n$ then ${Yao}_2^6 (2) = 1 - p = 1 - 0.4 = 0.6$\n\t\n\t$\\overline{{Yao}}_2^{6,3} (2) = 3 * 0.6 = 1.8$\n\t\n\t\\section{Second exercise}\n\t\n\t$m = 3$ \n\t\n\t$n = 2$ \n\t\n\t$N = m * n = 6$ \n\t\n\t$k = 4$ \n\t\n\tSince the tuples are not necessarily distinct, we use Cheung's formula. \n\t\n\t$\\overline{{Cheung}}_n^{N,m} (k) = m * {Cheung}_n^N (k)$\n\t\n\twhere \n\t\n    ${Cheung}_n^N (k) = [1-\\tilde{p}]$\n    \n    and $\\tilde{p} = \\prod_{i=0}^{k-1} \\frac{N-n+i}{N+i}$\n    \n    $\\tilde{p} = \\prod_{i=0}^{3} \\frac{4+i}{6+i} = \\frac{4}{6} * \\frac{5}{7} * \\frac{6}{8} * \\frac{7}{9} = 0.278$\n    \n    $\\overline{{Cheung}}_2^{6,3} = 3 * (1 - 0.278) = 2.167 $\n    \n    \\section{Third exercise}\n    \n    \\begin{center}\n    \\includegraphics[width=\\textwidth]{yao_bernstein_waters.png}\n    \\end{center}\n    \n    Yao and Waters (red and green) results overlap in the graph.\n    \n    \\section{Fourth exercise}\n    \n    \\begin{center}\n    \\includegraphics[width=\\textwidth]{cheung_cardenas.png}\n    \\end{center}\n    \n    Below we include all results together:\n    \\begin{center}\n    \\includegraphics[width=\\textwidth]{all_approx.png}\n    \\end{center}\n    \n\\end{document}", "meta": {"hexsha": "5c5c545ae2bb8adddcc0b5ef4e778f14643045b1", "size": 2041, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Query Optimization/assignments/Assignment 11.tex", "max_stars_repo_name": "mrahtapot/TUM", "max_stars_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 225, "max_stars_repo_stars_event_min_datetime": "2019-10-02T10:49:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:25:38.000Z", "max_issues_repo_path": "Query Optimization/assignments/Assignment 11.tex", "max_issues_repo_name": "mrahtapot/TUM", "max_issues_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-02-16T12:22:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-31T19:35:57.000Z", "max_forks_repo_path": "Query Optimization/assignments/Assignment 11.tex", "max_forks_repo_name": "mrahtapot/TUM", "max_forks_repo_head_hexsha": "b736fc4ae065612dc988b6cb220fcf2f6119a138", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 69, "max_forks_repo_forks_event_min_datetime": "2019-10-02T21:46:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T19:27:50.000Z", "avg_line_length": 21.0412371134, "max_line_length": 113, "alphanum_fraction": 0.5997060265, "num_tokens": 816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.40281779033234133}}
{"text": "\\section{Derived proof rules}\n\n\\subsection{Base logic}\n\n\\ralf{Give the most important derived rules.}\n\n\\paragraph{Persistent assertions.}\n\\begin{defn}\n  An assertion $\\prop$ is \\emph{persistent} if $\\prop \\proves \\always\\prop$.\n\\end{defn}\n\nOf course, $\\always\\prop$ is persistent for any $\\prop$.\nFurthermore, by the proof rules given above, $t = t'$ as well as $\\ownGGhost{\\mcore\\melt}$ and $\\knowInv\\iname\\prop$ are persistent.\nPersistence is preserved by conjunction, disjunction, separating conjunction as well as universal and existential quantification.\n\nIn our proofs, we will implicitly add and remove $\\always$ from persistent assertions as necessary, and generally treat them like normal, non-linear assumptions.\n\n\\subsection{Program logic}\n\n\\ralf{Sync this with Coq.}\n\nHoare triples and view shifts are syntactic sugar for weakest (liberal) preconditions and primitive view shifts, respectively:\n\\[\n\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask] \\eqdef \\always{(\\prop \\Ra \\wpre{\\expr}{\\lambda\\Ret\\val.\\propB}[\\mask])}\n\\qquad\\qquad\n\\begin{aligned}\n\\prop \\vs[\\mask_1][\\mask_2] \\propB &\\eqdef \\always{(\\prop \\Ra \\pvs[\\mask_1][\\mask_2] {\\propB})} \\\\\n\\prop \\vsE[\\mask_1][\\mask_2] \\propB &\\eqdef \\prop \\vs[\\mask_1][\\mask_2] \\propB \\land \\propB \\vs[\\mask2][\\mask_1] \\prop\n\\end{aligned}\n\\]\nWe write just one mask for a view shift when $\\mask_1 = \\mask_2$.\nClearly, all of these assertions are persistent.\nThe convention for omitted masks is similar to the base logic:\nAn omitted $\\mask$ is $\\top$ for Hoare triples and $\\emptyset$ for view shifts.\n\n\n\\paragraph{View shifts.}~\nThe following rules can be derived for view shifts.\n\n\\begin{mathparpagebreakable}\n\\inferH{vs-update}\n  {\\melt \\mupd \\meltsB}\n  {\\ownGGhost{\\melt} \\vs \\exists \\meltB \\in \\meltsB.\\; \\ownGGhost{\\meltB}}\n\\and\n\\inferH{vs-trans}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB \\and \\propB \\vs[\\mask_2][\\mask_3] \\propC \\and \\mask_2 \\subseteq \\mask_1 \\cup \\mask_3}\n  {\\prop \\vs[\\mask_1][\\mask_3] \\propC}\n\\and\n\\inferH{vs-imp}\n  {\\always{(\\prop \\Ra \\propB)}}\n  {\\prop \\vs[\\emptyset] \\propB}\n\\and\n\\inferH{vs-mask-frame}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB}\n  {\\prop \\vs[\\mask_1 \\uplus \\mask'][\\mask_2 \\uplus \\mask'] \\propB}\n\\and\n\\inferH{vs-frame}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propB}\n  {\\prop * \\propC \\vs[\\mask_1][\\mask_2] \\propB * \\propC}\n\\and\n\\inferH{vs-timeless}\n  {\\timeless{\\prop}}\n  {\\later \\prop \\vs \\prop}\n\\and\n\\inferH{vs-allocI}\n  {\\infinite(\\mask)}\n  {\\later{\\prop} \\vs[\\mask] \\exists \\iname\\in\\mask.\\; \\knowInv{\\iname}{\\prop}}\n\\and\n\\axiomH{vs-openI}\n  {\\knowInv{\\iname}{\\prop} \\proves \\TRUE \\vs[\\{ \\iname \\} ][\\emptyset] \\later \\prop}\n\\and\n\\axiomH{vs-closeI}\n  {\\knowInv{\\iname}{\\prop} \\proves \\later \\prop \\vs[\\emptyset][\\{ \\iname \\} ] \\TRUE }\n\n\\inferHB{vs-disj}\n  {\\prop \\vs[\\mask_1][\\mask_2] \\propC \\and \\propB \\vs[\\mask_1][\\mask_2] \\propC}\n  {\\prop \\lor \\propB \\vs[\\mask_1][\\mask_2] \\propC}\n\\and\n\\inferHB{vs-exist}\n  {\\All \\var. (\\prop \\vs[\\mask_1][\\mask_2] \\propB)}\n  {(\\Exists \\var. \\prop) \\vs[\\mask_1][\\mask_2] \\propB}\n\\and\n\\inferHB{vs-box}\n  {\\always\\propB \\proves \\prop \\vs[\\mask_1][\\mask_2] \\propC}\n  {\\prop \\land \\always{\\propB} \\vs[\\mask_1][\\mask_2] \\propC}\n \\and\n\\inferH{vs-false}\n  {}\n  {\\FALSE \\vs[\\mask_1][\\mask_2] \\prop }\n\\end{mathparpagebreakable}\n\n\n\\paragraph{Hoare triples.}\nThe following rules can be derived for Hoare triples.\n\n\\begin{mathparpagebreakable}\n\\inferH{Ht-ret}\n  {}\n  {\\hoare{\\TRUE}{\\valB}{\\Ret\\val. \\val = \\valB}[\\mask]}\n\\and\n\\inferH{Ht-bind}\n  {\\text{$\\lctx$ is a context} \\and \\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask] \\\\\n   \\All \\val. \\hoare{\\propB}{\\lctx(\\val)}{\\Ret\\valB.\\propC}[\\mask]}\n  {\\hoare{\\prop}{\\lctx(\\expr)}{\\Ret\\valB.\\propC}[\\mask]}\n\\and\n\\inferH{Ht-csq}\n  {\\prop \\vs \\prop' \\\\\n    \\hoare{\\prop'}{\\expr}{\\Ret\\val.\\propB'}[\\mask] \\\\   \n   \\All \\val. \\propB' \\vs \\propB}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n\\and\n\\inferH{Ht-mask-weaken}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask]}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask \\uplus \\mask']}\n\\\\\\\\\n\\inferH{Ht-frame}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask]}\n  {\\hoare{\\prop * \\propC}{\\expr}{\\Ret\\val. \\propB * \\propC}[\\mask]}\n\\and\n\\inferH{Ht-frame-step}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val. \\propB}[\\mask] \\and \\toval(\\expr) = \\bot}\n  {\\hoare{\\prop * \\later\\propC}{\\expr}{\\Ret\\val. \\propB * \\propC}[\\mask]}\n\\and\n\\inferH{Ht-atomic}\n  {\\prop \\vs[\\mask \\uplus \\mask'][\\mask] \\prop' \\\\\n    \\hoare{\\prop'}{\\expr}{\\Ret\\val.\\propB'}[\\mask] \\\\   \n   \\All\\val. \\propB' \\vs[\\mask][\\mask \\uplus \\mask'] \\propB \\\\\n   \\physatomic{\\expr}\n  }\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask \\uplus \\mask']}\n\\and\n\\inferHB{Ht-disj}\n  {\\hoare{\\prop}{\\expr}{\\Ret\\val.\\propC}[\\mask] \\and \\hoare{\\propB}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n  {\\hoare{\\prop \\lor \\propB}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n\\and\n\\inferHB{Ht-exist}\n  {\\All \\var. \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n  {\\hoare{\\Exists \\var. \\prop}{\\expr}{\\Ret\\val.\\propB}[\\mask]}\n\\and\n\\inferHB{Ht-box}\n  {\\always\\propB \\proves \\hoare{\\prop}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n  {\\hoare{\\prop \\land \\always{\\propB}}{\\expr}{\\Ret\\val.\\propC}[\\mask]}\n\\and\n\\inferH{Ht-false}\n  {}\n  {\\hoare{\\FALSE}{\\expr}{\\Ret \\val. \\prop}[\\mask]}\n\\end{mathparpagebreakable}\n\n\\clearpage\n\\section{Derived constructions}\n\nIn this section we describe some derived constructions that are generally useful and language-independent.\n\n\\ralf{Describe at least global monoid and invariant namespaces.}\n% \\subsection{Global monoid}\n\n% Hereinafter we assume the global monoid (served up as a parameter to Iris) is obtained from a family of monoids $(M_i)_{i \\in I}$ by first applying the construction for finite partial functions to each~(\\Sref{sec:fpfunm}), and then applying the product construction~(\\Sref{sec:prodm}):\n% \\[ M \\eqdef \\prod_{i \\in I} \\textdom{GhName} \\fpfn M_i \\]\n% We don't care so much about what concretely $\\textdom{GhName}$ is, as long as it is countable and infinite.\n% We write $\\ownGhost{\\gname}{\\melt : M_i}$ (or just $\\ownGhost{\\gname}{\\melt}$ if $M_i$ is clear from the context) for $\\ownGGhost{[i \\mapsto [\\gname \\mapsto \\melt]]}$ when $\\melt \\in \\mcarp {M_i}$, and for $\\FALSE$ when $\\melt = \\mzero_{M_i}$.\n% In other words, $\\ownGhost{\\gname}{\\melt : M_i}$ asserts that in the current state of monoid $M_i$, the name $\\gname$ is allocated and has at least value $\\melt$.\n\n% From~\\ruleref{FpUpd} and the multiplications and frame-preserving updates in~\\Sref{sec:prodm} and~\\Sref{sec:fpfunm}, we have the following derived rules.\n% \\begin{mathpar}\n% \t\\axiomH{NewGhost}{\n% \t\t\\TRUE \\vs \\Exists\\gname. \\ownGhost\\gname{\\melt : M_i}\n% \t}\n% \t\\and\n% \t\\inferH{GhostUpd}\n%     {\\melt \\mupd_{M_i} B}\n%     {\\ownGhost\\gname{\\melt : M_i} \\vs \\Exists \\meltB\\in B. \\ownGhost\\gname{\\meltB : M_i}}\n%   \\and\n%   \\axiomH{GhostEq}\n%     {\\ownGhost\\gname{\\melt : M_i} * \\ownGhost\\gname{\\meltB : M_i} \\Lra \\ownGhost\\gname{\\melt\\mtimes\\meltB : M_i}}\n\n%   \\axiomH{GhostUnit}\n%     {\\TRUE \\Ra \\ownGhost{\\gname}{\\munit : M_i}}\n\n%   \\axiomH{GhostZero}\n%     {\\ownGhost\\gname{\\mzero : M_i} \\Ra \\FALSE}\n\n%   \\axiomH{GhostTimeless}\n%     {\\timeless{\\ownGhost\\gname{\\melt : M_i}}}\n% \\end{mathpar}\n\n% \\subsection{STSs with interpretation}\\label{sec:stsinterp}\n\n% Building on \\Sref{sec:stsmon}, after constructing the monoid $\\STSMon{\\STSS}$ for a particular STS, we can use an invariant to tie an interpretation, $\\pred : \\STSS \\to \\Prop$, to the STS's current state, recovering CaReSL-style reasoning~\\cite{caresl}.\n\n% An STS invariant asserts authoritative ownership of an STS's current state and that state's interpretation:\n% \\begin{align*}\n%   \\STSInv(\\STSS, \\pred, \\gname) \\eqdef{}& \\Exists s \\in \\STSS. \\ownGhost{\\gname}{(s, \\STSS, \\emptyset):\\STSMon{\\STSS}} * \\pred(s) \\\\\n%   \\STS(\\STSS, \\pred, \\gname, \\iname) \\eqdef{}& \\knowInv{\\iname}{\\STSInv(\\STSS, \\pred, \\gname)}\n% \\end{align*}\n\n% We can specialize \\ruleref{NewInv}, \\ruleref{InvOpen}, and \\ruleref{InvClose} to STS invariants:\n% \\begin{mathpar}\n%  \\inferH{NewSts}\n%   {\\infinite(\\mask)}\n%   {\\later\\pred(s) \\vs[\\mask] \\Exists \\iname \\in \\mask, \\gname.   \\STS(\\STSS, \\pred, \\gname, \\iname) * \\ownGhost{\\gname}{(s, \\STST \\setminus \\STSL(s)) : \\STSMon{\\STSS}}}\n%  \\and\n%  \\axiomH{StsOpen}\n%   {  \\STS(\\STSS, \\pred, \\gname, \\iname) \\vdash \\ownGhost{\\gname}{(s_0, T) : \\STSMon{\\STSS}} \\vsE[\\{\\iname\\}][\\emptyset] \\Exists s\\in \\upclose(\\{s_0\\}, T). \\later\\pred(s) * \\ownGhost{\\gname}{(s, \\upclose(\\{s_0\\}, T), T):\\STSMon{\\STSS}}}\n%  \\and\n%  \\axiomH{StsClose}\n%   {  \\STS(\\STSS, \\pred, \\gname, \\iname), (s, T) \\ststrans (s', T')  \\proves \\later\\pred(s') * \\ownGhost{\\gname}{(s, S, T):\\STSMon{\\STSS}} \\vs[\\emptyset][\\{\\iname\\}] \\ownGhost{\\gname}{(s', T') : \\STSMon{\\STSS}} }\n% \\end{mathpar}\n% \\begin{proof}\n% \\ruleref{NewSts} uses \\ruleref{NewGhost} to allocate $\\ownGhost{\\gname}{(s, \\upclose(s, T), T) : \\STSMon{\\STSS}}$ where $T \\eqdef \\STST \\setminus \\STSL(s)$, and \\ruleref{NewInv}.\n\n% \\ruleref{StsOpen} just uses \\ruleref{InvOpen} and \\ruleref{InvClose} on $\\iname$, and the monoid equality $(s, \\upclose(\\{s_0\\}, T), T) = (s, \\STSS, \\emptyset) \\mtimes (\\munit, \\upclose(\\{s_0\\}, T), T)$.\n\n% \\ruleref{StsClose} applies \\ruleref{StsStep} and \\ruleref{InvClose}.\n% \\end{proof}\n\n% Using these view shifts, we can prove STS variants of the invariant rules \\ruleref{Inv} and \\ruleref{VSInv}~(compare the former to CaReSL's island update rule~\\cite{caresl}):\n% \\begin{mathpar}\n%  \\inferH{Sts}\n%   {\\All s \\in \\upclose(\\{s_0\\}, T). \\hoare{\\later\\pred(s) * P}{\\expr}{\\Ret \\val. \\Exists s', T'. (s, T) \\ststrans (s', T') * \\later\\pred(s') * Q}[\\mask]\n%    \\and \\physatomic{\\expr}}\n%   {  \\STS(\\STSS, \\pred, \\gname, \\iname) \\vdash \\hoare{\\ownGhost{\\gname}{(s_0, T):\\STSMon{\\STSS}} * P}{\\expr}{\\Ret \\val. \\Exists s', T'. \\ownGhost{\\gname}{(s', T'):\\STSMon{\\STSS}} * Q}[\\mask \\uplus \\{\\iname\\}]}\n%  \\and\n%  \\inferH{VSSts}\n%   {\\forall s \\in \\upclose(\\{s_0\\}, T).\\; \\later\\pred(s) * P \\vs[\\mask_1][\\mask_2] \\exists s', T'.\\; (s, T) \\ststrans (s', T') * \\later\\pred(s') * Q}\n%   {  \\STS(\\STSS, \\pred, \\gname, \\iname) \\vdash \\ownGhost{\\gname}{(s_0, T):\\STSMon{\\STSS}} * P \\vs[\\mask_1 \\uplus \\{\\iname\\}][\\mask_2 \\uplus \\{\\iname\\}] \\Exists s', T'. \\ownGhost{\\gname}{(s', T'):\\STSMon{\\STSS}} * Q}\n% \\end{mathpar}\n\n% \\begin{proof}[Proof of \\ruleref{Sts}]\\label{pf:sts}\n%  We have to show\n%  \\[\\hoare{\\ownGhost{\\gname}{(s_0, T):\\STSMon{\\STSS}} * P}{\\expr}{\\Ret \\val. \\Exists s', T'. \\ownGhost{\\gname}{(s', T'):\\STSMon{\\STSS}} * Q}[\\mask \\uplus \\{\\iname\\}]\\]\n%  where $\\val$, $s'$, $T'$ are free in $Q$.\n \n%  First, by \\ruleref{ACsq} with \\ruleref{StsOpen} and \\ruleref{StsClose} (after moving $(s, T) \\ststrans (s', T')$ into the view shift using \\ruleref{VSBoxOut}), it suffices to show\n%  \\[\\hoareV{\\Exists s\\in \\upclose(\\{s_0\\}, T). \\later\\pred(s) * \\ownGhost{\\gname}{(s, \\upclose(\\{s_0\\}, T), T)} * P}{\\expr}{\\Ret \\val. \\Exists s, T, S, s', T'. (s, T) \\ststrans (s', T') * \\later\\pred(s') * \\ownGhost{\\gname}{(s, S, T):\\STSMon{\\STSS}} * Q(\\val, s', T')}[\\mask]\\]\n\n%  Now, use \\ruleref{Exist} to move the $s$ from the precondition into the context and use \\ruleref{Csq} to (i)~fix the $s$ and $T$ in the postcondition to be the same as in the precondition, and (ii)~fix $S \\eqdef \\upclose(\\{s_0\\}, T)$.\n%  It remains to show:\n%  \\[\\hoareV{s\\in \\upclose(\\{s_0\\}, T) * \\later\\pred(s) * \\ownGhost{\\gname}{(s, \\upclose(\\{s_0\\}, T), T)} * P}{\\expr}{\\Ret \\val. \\Exists s', T'. (s, T) \\ststrans (s', T') * \\later\\pred(s') * \\ownGhost{\\gname}{(s, \\upclose(\\{s_0\\}, T), T)} * Q(\\val, s', T')}[\\mask]\\]\n \n%  Finally, use \\ruleref{BoxOut} to move $s\\in \\upclose(\\{s_0\\}, T)$ into the context, and \\ruleref{Frame} on $\\ownGhost{\\gname}{(s, \\upclose(\\{s_0\\}, T), T)}$:\n%  \\[s\\in \\upclose(\\{s_0\\}, T) \\vdash \\hoare{\\later\\pred(s) * P}{\\expr}{\\Ret \\val. \\Exists s', T'. (s, T) \\ststrans (s', T') * \\later\\pred(s') * Q(\\val, s', T')}[\\mask]\\]\n \n%  This holds by our premise.\n% \\end{proof}\n\n% % \\begin{proof}[Proof of \\ruleref{VSSts}]\n% % This is similar to above, so we only give the proof in short notation:\n\n% % \\hproof{%\n% % \tContext: $\\knowInv\\iname{\\STSInv(\\STSS, \\pred, \\gname)}$ \\\\\n% % \t\\pline[\\mask_1 \\uplus \\{\\iname\\}]{\n% % \t\t\\ownGhost\\gname{(s_0, T)} * P\n% % \t} \\\\\n% % \t\\pline[\\mask_1]{%\n% % \t\t\\Exists s. \\later\\pred(s) * \\ownGhost\\gname{(s, S, T)} * P\n% % \t} \\qquad by \\ruleref{StsOpen} \\\\\n% % \tContext: $s \\in S \\eqdef \\upclose(\\{s_0\\}, T)$ \\\\\n% % \t\\pline[\\mask_2]{%\n% % \t\t \\Exists s', T'. \\later\\pred(s') * Q(s', T') * \\ownGhost\\gname{(s, S, T)}\n% % \t} \\qquad by premiss \\\\\n% % \tContext: $(s, T) \\ststrans (s', T')$ \\\\\n% % \t\\pline[\\mask_2 \\uplus \\{\\iname\\}]{\n% % \t\t\\ownGhost\\gname{(s', T')} * Q(s', T')\n% % \t} \\qquad by \\ruleref{StsClose}\n% % }\n% % \\end{proof}\n\n% \\subsection{Authoritative monoids with interpretation}\\label{sec:authinterp}\n\n% Building on \\Sref{sec:auth}, after constructing the monoid $\\auth{M}$ for a cancellative monoid $M$, we can tie an interpretation, $\\pred : \\mcarp{M} \\to \\Prop$, to the authoritative element of $M$, recovering reasoning that is close to the sharing rule in~\\cite{krishnaswami+:icfp12}.\n\n% Let $\\pred_\\bot$ be the extension of $\\pred$ to $\\mcar{M}$ with $\\pred_\\bot(\\mzero) = \\FALSE$.\n% Now define\n% \\begin{align*}\n%   \\AuthInv(M, \\pred, \\gname) \\eqdef{}& \\exists \\melt \\in \\mcar{M}.\\; \\ownGhost{\\gname}{\\authfull \\melt:\\auth{M}} * \\pred_\\bot(\\melt) \\\\\n%   \\Auth(M, \\pred, \\gname, \\iname) \\eqdef{}& M~\\textlog{cancellative} \\land \\knowInv{\\iname}{\\AuthInv(M, \\pred, \\gname)}\n% \\end{align*}\n\n% The frame-preserving updates for $\\auth{M}$ gives rise to the following view shifts:\n% \\begin{mathpar}\n%  \\inferH{NewAuth}\n%   {\\infinite(\\mask) \\and M~\\textlog{cancellative}}\n%   {\\later\\pred_\\bot(a) \\vs[\\mask] \\exists \\iname \\in \\mask, \\gname.\\; \\Auth(M, \\pred, \\gname, \\iname) * \\ownGhost{\\gname}{\\authfrag a : \\auth{M}}}\n%  \\and\n%  \\axiomH{AuthOpen}\n%   {\\Auth(M, \\pred, \\gname, \\iname) \\vdash \\ownGhost{\\gname}{\\authfrag \\melt : \\auth{M}} \\vsE[\\{\\iname\\}][\\emptyset] \\exists \\melt_f.\\; \\later\\pred_\\bot(\\melt \\mtimes \\melt_f) * \\ownGhost{\\gname}{\\authfull \\melt \\mtimes \\melt_f, \\authfrag a:\\auth{M}}}\n%  \\and\n%  \\axiomH{AuthClose}\n%   {\\Auth(M, \\pred, \\gname, \\iname) \\vdash \\later\\pred_\\bot(\\meltB \\mtimes \\melt_f) * \\ownGhost{\\gname}{\\authfull a \\mtimes \\melt_f, \\authfrag a:\\auth{M}} \\vs[\\emptyset][\\{\\iname\\}] \\ownGhost{\\gname}{\\authfrag \\meltB : \\auth{M}} }\n% \\end{mathpar}\n\n% These view shifts in turn can be used to prove variants of the invariant rules:\n% \\begin{mathpar}\n%  \\inferH{Auth}\n%   {\\forall \\melt_f.\\; \\hoare{\\later\\pred_\\bot(a \\mtimes \\melt_f) * P}{\\expr}{\\Ret\\val. \\exists \\meltB.\\; \\later\\pred_\\bot(\\meltB\\mtimes \\melt_f) * Q}[\\mask]\n%    \\and \\physatomic{\\expr}}\n%   {\\Auth(M, \\pred, \\gname, \\iname) \\vdash \\hoare{\\ownGhost{\\gname}{\\authfrag a:\\auth{M}} * P}{\\expr}{\\Ret\\val. \\exists \\meltB.\\; \\ownGhost{\\gname}{\\authfrag \\meltB:\\auth{M}} * Q}[\\mask \\uplus \\{\\iname\\}]}\n%  \\and\n%  \\inferH{VSAuth}\n%   {\\forall \\melt_f.\\; \\later\\pred_\\bot(a \\mtimes \\melt_f) * P \\vs[\\mask_1][\\mask_2] \\exists \\meltB.\\; \\later\\pred_\\bot(\\meltB \\mtimes \\melt_f) * Q(\\meltB)}\n%   {\\Auth(M, \\pred, \\gname, \\iname) \\vdash\n%    \\ownGhost{\\gname}{\\authfrag a:\\auth{M}} * P \\vs[\\mask_1 \\uplus \\{\\iname\\}][\\mask_2 \\uplus \\{\\iname\\}]\n%    \\exists \\meltB.\\; \\ownGhost{\\gname}{\\authfrag \\meltB:\\auth{M}} * Q(\\meltB)}\n% \\end{mathpar}\n\n\n% \\subsection{Ghost heap}\n% \\label{sec:ghostheap}%\n\n% We define a simple ghost heap with fractional permissions.\n% Some modules require a few ghost names per module instance to properly manage ghost state, but would like to expose to clients a single logical name (avoiding clutter).\n% In such cases we use these ghost heaps.\n\n% We seek to implement the following interface:\n% \\newcommand{\\GRefspecmaps}{\\textsf{GMapsTo}}%\n% \\begin{align*}\n%  \\exists& {\\fgmapsto[]} : \\textsort{Val} \\times \\mathbb{Q}_{>} \\times \\textsort{Val} \\ra \\textsort{Prop}.\\;\\\\\n%   & \\All x, q, v. x \\fgmapsto[q] v \\Ra x \\fgmapsto[q] v \\land q \\in (0, 1] \\\\\n%   &\\forall x, q_1, q_2, v, w.\\; x \\fgmapsto[q_1] v * x \\fgmapsto[q_2] w \\Leftrightarrow x \\fgmapsto[q_1 + q_2] v * v = w\\\\\n%   & \\forall v.\\; \\TRUE \\vs[\\emptyset] \\exists x.\\; x \\fgmapsto[1] v \\\\\n%   & \\forall x, v, w.\\; x \\fgmapsto[1] v \\vs[\\emptyset] x \\fgmapsto[1] w\n% \\end{align*}\n% We write $x \\fgmapsto v$ for $\\exists q.\\; x \\fgmapsto[q] v$ and $x \\gmapsto v$ for $x \\fgmapsto[1] v$.\n% Note that $x \\fgmapsto v$ is duplicable but cannot be boxed (as it depends on resources); \\ie we have $x \\fgmapsto v \\Lra x \\fgmapsto v * x \\fgmapsto v$ but not $x \\fgmapsto v \\Ra \\always x \\fgmapsto v$.\n\n% To implement this interface, allocate an instance $\\gname_G$ of $\\FHeap(\\textdom{Val})$ and define\n% \\[\n% \tx \\fgmapsto[q] v \\eqdef\n% \t  \\begin{cases}\n%     \t\\ownGhost{\\gname_G}{x \\mapsto (q, v)} & \\text{if $q \\in (0, 1]$} \\\\\n%     \t\\FALSE & \\text{otherwise}\n%     \\end{cases}\n% \\]\n% The view shifts in the specification follow immediately from \\ruleref{GhostUpd} and the frame-preserving updates in~\\Sref{sec:fheapm}.\n% The first implication is immediate from the definition.\n% The second implication follows by case distinction on $q_1 + q_2 \\in (0, 1]$.\n\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"iris\"\n%%% End:\n", "meta": {"hexsha": "8d8a4ea3607adf4ebe8dd78c3fb1f51b07ffb8f5", "size": 17078, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/derived.tex", "max_stars_repo_name": "amintimany/iris-backup", "max_stars_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/derived.tex", "max_issues_repo_name": "amintimany/iris-backup", "max_issues_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/derived.tex", "max_forks_repo_name": "amintimany/iris-backup", "max_forks_repo_head_hexsha": "9e98ff8be4b4ca516a497d328aaf31cbae186a6c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.7900874636, "max_line_length": 287, "alphanum_fraction": 0.636257173, "num_tokens": 6705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.40263493288248625}}
{"text": "% -*-latex-*-\n\n\\title{Orbiter Technical Notes: Earth Atmosphere Model}\n\\author{Martin Schweiger}\n\\date{March 5, 2009}\n\n\\documentclass[a4paper]{article}\n\\usepackage[dvips]{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{times}\n\\usepackage{cite}\n\n\\begin{document}\n\\bibliographystyle{unsrt}\n\n%\\renewcommand{\\vec}[1]{\\ensuremath{\\mathbf{#1}}}\n\n\\newcommand{\\vR}[1]{\\ensuremath{\\vec{R}_{#1}}}\n\\newcommand{\\nR}[1]{\\ensuremath{|\\vR{#1}|}}\n\\newcommand{\\mat}[1]{\\ensuremath{\\mathsf{#1}}}\n\\newcommand{\\Kelvin}{\\ensuremath{\\mathrm{K}}}\n\n\\maketitle\n\n\\section{Introduction}\nFrom Edition 2009, Orbiter supports a choice of different atmosphere models for Earth. In addition to the Edition 2006 legacy model, the default distribution also contains implementations of the Jacchia model \\cite{jacchia65, jacchia71, jacchia77} and the NRLMSISE-00 model which is based on the MSISE90 model.\n\nThese models address the shortcomings of the 2006 legacy model, in particular the underestimation of density and pressure above 120\\,km. Both new models are valid to significantly higher altitudes (2500\\,km, compared to 200\\,km for the legacy model).\n\nThey provide the temperature, particle density for different molecular constituents, total mass density and molecular weight as a function of altitude, in the range from 90 to 2500\\,km. For the Jacchia model, the only model parameter is the exospheric temperature, $T_\\infty$, which in turn depends on various parameters, such as the relative position of the sun, geomagnetic activity, and solar flux. The NRLMSISE00 model also uses date information to compute variations on different time scales.\n\n\\section{Exospheric temperature}\nCalculation of $T_\\infty$ is required for applying the J77 model. The exospheric temperature is varying with time and position, and must therefore be recalculated for each new density evaluation. The model takes into account solar activity, geomagnetic activity, and a model for the diurnal variations in $T_\\infty$.\n\nThe J71 model gives specifies the nighttime minimum global exosphere temperature, excluding geomagnetic activity, as\n\\begin{equation}\nT_C = 379.0K + 3.24K \\bar{F}_{10.7} + 1.3K(F_{10.7}-\\bar{F}_{10.7})\n\\end{equation}\nwhere $F_{10.7}$ is the daily average solar flux value one day prior, measured at wavelength 10.7\\,cm, and $\\bar{F}_{10.7}$ is the average value over three solar rotations of 27 days. Units for solar flux values are given in Solar Flux Units of $10^{-22}\\,W/(m^2 Hz)$.\n\nIn Orbiter, solar flux values based on observations are not taken into account. Instead, a constant flux of\n\\begin{equation}\nF_{10.7} = \\bar{F}_{10.7} = 140 \\cdot 10^{-22} W/(m^2 Hz)\n\\end{equation}\nis assumed, which reduces the expression for $T_C$ to\n\\begin{equation}\nT_C = 832.6K\n\\end{equation}\nThe diurnal model for $T_\\infty$ takes into account the local hour angle of the sun with respect to the measurement point, as well as the declination of the sun and the geographic latitude of the measurement point. This model is given by\n\\begin{equation}\nT_1 = T_C \\left[ 1 + 0.3 \\left( \\sin^{2.2}|\\theta| + (\\cos^{2.2}|\\eta| - \\sin^{2.2}|\\theta|) \\cos^{3.0}(\\tau/2) \\right) \\right]\n\\end{equation}\nwith\n\\begin{eqnarray}\n\\tau &=& H - 37.0^\\circ + 6.0^\\circ \\sin(H+43.0^\\circ) \\\\\n\\theta &=& \\frac{1}{2} (\\varphi + \\delta_\\odot ) \\\\\n\\eta &=& \\frac{1}{2} (\\varphi - \\delta_\\odot)\n\\end{eqnarray}\nwhere $\\delta_\\odot$ denotes the sun's declination, $\\varphi$ is the geographic latitude and $H$ the hour angle of the sun with respect to the measurement point, given by\n\\begin{equation}\nH = \\alpha - \\alpha_\\odot\n\\end{equation}\nwhere $\\alpha$ and $\\alpha_\\odot$ are the right ascension of the measurement point and the sun, respectively.\n\nFinally, geomagnetic activity is taken into account by the Jacchia model by specifying a modification term $\\Delta T_\\infty$ for $T_\\infty$ in the form\n\\begin{eqnarray}\n\\Delta T^H_\\infty &=& 28.0\\Kelvin \\cdot K_p + 0.03\\Kelvin e^{K_p}\\qquad (z > 350\\,km) \\\\\n\\Delta T^L_\\infty &=& 14.0\\Kelvin \\cdot K_p + 0.02\\Kelvin e^{K_p}\\qquad (z < 350\\,km)\n\\end{eqnarray}\nfor two separate altitude regimes, respectively. $K_p$ is the three-hourly planetary geomagnetic index for a time 6.7 hours previous. To provide continuity at z=350\\,km, a transition function $f$ is introduced:\n\\begin{equation}\nf = \\frac{1}{2} (\\tanh(0.04 (z - 350\\,km)) + 1)\n\\end{equation}\nThe geomagnetic activity correction $\\Delta T_\\infty$ can then be written as\n\\begin{equation}\n\\Delta T_\\infty = f \\Delta T^H_\\infty + (1-f) \\Delta T^L_\\infty\n\\end{equation}\nIn Orbiter, variations in geomagnetic activity are ignored. Instead, a constant geomagnetic index of $K_p = 3.0$ is assumed. This simplifies the correction terms to\n\\begin{eqnarray}\n\\Delta T^H_\\infty &=& 84.6026\\Kelvin \\\\\n\\Delta T^L_\\infty &=& 42.4017\\Kelvin \\\\\n\\Delta T_\\infty &=& (42.2009 f + 42.4017)\\Kelvin\n\\end{eqnarray}\nThe final value for the exospheric temperature is then given by\n\\begin{equation}\nT_\\infty = T_1 + \\Delta T_\\infty\n\\end{equation}\nExamples for global distributions of $T_\\infty$ are shown in Fig.~\\ref{fig:t_infty}, for two different solar declination values ($0^\\circ$ and $20^\\circ$). Note that the maximum of $T_\\infty$ is trailing the Sun's location (indicated by a circle).\n\n\\begin{figure}\n\\includegraphics[width=0.8\\textwidth]{exotemp1.eps}\n\\includegraphics[width=0.8\\textwidth]{exotemp2.eps}\n\\caption{Exospheric temperature distributions as a function of geographic longitude and latitude, for two different declination values of the Sun: $0^\\circ$ (top) and $20^\\circ$ (bottom). The position of the sun is indicated by a circle.}\n\\label{fig:t_infty}\n\\end{figure}\n\n\\section{The Jacchia temperature and density model}\nThe Jacchia model is static and assumes two distinct altitude regimes, where in the lower regime (from 90 to 100\\,km) the atmospheric constituents are mixed, and the density is computed by integrating the barometric equation. At altitudes $> 100$\\,km, the atmosphere is assumed to be in diffusion equilibrium for each of the individual constituents.\n\n\\subsection{Temperature}\nThe temperature profile obtained from the Jacchia code as a function of altitude for three different values of $T_\\infty$ is shown in Fig.~\\ref{fig:jacchia_temp}. As can be seen, the temperature profiles are identical up to an altitude of about 100\\,km, where the standard US atmospheric model is used. At higher altitudes, the temperatures asymdotically approach the prescribed exospheric temperature.\n\n\\begin{figure}\n\\includegraphics[width=0.8\\textwidth]{jacchia_temp.eps}\n\\caption{J77 temperature profiles as a function of altitude for different values of exospheric temperature $T_\\infty$.}\n\\label{fig:jacchia_temp}\n\\end{figure}\n\n\\subsection{Density}\n\nThe Jacchia model requires the integration of a barometric or diffusion equation up to the desired altitude. This method is not computationally efficient if density values at arbitrary altitudes are required. In this case, a reasonable compromise between computational speed and accuracy can be achieved by precomputing lookup tables over the required ranges of altitude $z$ and exospheric temperature $T_\\infty$, and interpolating to the actual parameters. Alternatively, a basis expansion in the two parameters can be used. Gill~\\cite{gill96} has approximated the J71 density model (denoted here by J71G) by a bi-polynomial expansion of the form\n\\begin{equation}\\label{eq:interpol}\n\\log \\rho(z,T_\\infty) = \\sum_{i=0}^m \\sum_{j=0}^n c_{ij} z^i T_\\infty^j\n\\end{equation}\nwhere $c_{ij}$ are the basis coefficients of the expansion obtained by a least-squares optimisation.\n\nTo provide sufficient accuracy while keeping the expansion to a reasonably low order, the temperature and altitude range was divided into sub-regions, and separate basis expansions calculated for each of them. Continuity of the density values and derivatives across region boundaries was ensured by applying appropriate constraints to the least squares fits. The authors present the coefficients for a basis expansion using a 5th degree polynomial in temperature and 6th degree polynomial in altitude for each region.\n\nThe density profiles as a function of altitude for three values of $T_\\infty$ are shown in Fig.~\\ref{fig:dens} for both the J77 and the J71G models.\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{dens_j77.eps}\n\\includegraphics[width=0.5\\textwidth]{dens_j71g.eps}\n\\caption{Density profiles for the J77 (left) and J71G model (right) as a function of altitude, for three different values of the exospheric temperature.}\n\\label{fig:dens}\n\\end{figure}\nThe relative difference between the two models is shown in Fig.~\\ref{fig:denserr}. It can be seen that the models agree well for medium to high values of $T_\\infty$, but diverge significantly for low values. This may be caused by the fact that the interpolated Gill solution is modelling the earlier J71 model rather than J77, so may reflect the difference between the underlying models, rather than an effect of the interpolation approach. As can be seen in the right image, the models only diverge below temperatures of 600\\,K, which are not encountered in Orbiter's model for $T_\\infty$.\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{dens_relerr.eps}\n\\includegraphics[width=0.5\\textwidth]{dens_relerr2.eps}\n\\caption{Relative difference between the J77 and J71G models as a function of altitude, for three different values of the exospheric temperature (left), and for the full temperature range (right).}\n\\label{fig:denserr}\n\\end{figure}\n\n\\subsection{Pressure}\n \nWe obtain atmospheric pressure from density by applying the ideal gas law\n\\begin{equation}\np = \\rho_N k T\n\\end{equation}\nwhere $\\rho_N$ [m$^{-3}$] is the particle density, and $k$ [J/K] is the Boltzmann constant. However, while the original Jacchia model returns $\\rho_N$, the interpolated Jacchia-Gill model instead provides the mass density $\\rho$. The relationship between $\\rho$ and $\\rho_N$ is given by\n\\begin{equation}\n\\rho_N = \\rho \\frac{N_A}{M}\n\\end{equation}\nwhere $N_A$ is Avogadro's constant and $M$ is the molar mass of the gas mixture. The Jacchia model does provide $M$, but as with the density, this requires an expensive numerical integration over altitude. Therefore I present here a polynomial series approximation of $M$ in the parameters $z$ and $T_\\infty$ similar to the density expansion of the Jacchia-Gill model (Eq.~\\ref{eq:interpol}). Instead of a piecewise patched solution, the parameter range of $90\\,km \\leq z \\leq 2500\\,km$ and $500\\,K \\leq T_\\infty \\leq 1900\\,K$ is mapped with a single series of order 8 in $z$ and order 4 in $T_\\infty$. The basis coefficients $c^{(M)}$ were obtained by a least-squares fit and $c$ are listed in Appendix A. The distribution of the interpolation solution of $M$ is shown in Fig.~\\ref{fig:molmass}. Below $z=90$\\,km the value of $M$ is derived from the US standard atmosphere model.\n\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{molmass.eps}\n\\includegraphics[width=0.5\\textwidth]{molmass_err.eps}\n\\caption{Left: Distribution of molar mass as a function of altitude and exospheric temperature, obtained from a polynomial series expansion. Right: relative error of the series solution compared to the original Jacchia model data.}\n\\label{fig:molmass}\n\\end{figure}\nThe atmospheric pressure values calculated with the J77 model and with the J71G model augmented with the molecular weight interpolation as outlined above are shown in Fig.~\\ref{fig:pressure}. The differences between the two models at low values of $T_\\infty$ observed for density naturally also appear for the pressure values. Above 600\\,K the agreement is very good.\n\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{prs_j77.eps}\n\\includegraphics[width=0.5\\textwidth]{prs_j71g.eps}\n\\caption{Pressure profiles for the J77 (left) and the augmented J71G model (right) as a function of altitude, for three different values of the exospheric temperature.}\n\\label{fig:pressure}\n\\end{figure}\n\n\\section{The NRLMSISE-00 atmosphere model}\nA further atmospheric model supported by Orbiter is the NRLMSISE-00 model, developed by Picone, Hedin and Drob, with a C version by D. Brodowski. It is based on the MSISE90 model, adding some further observation data. MSISE90 provides the neutral temperature and density from ground level to thermospheric altitudes. Unlike the Jacchia models, the low-altitude data are not static, but vary with location. They are based on the MAP Handbook (Labitzke et al. 1985) tabulation of zonal average temperature and pressure by Barnett and Corney. Below 20 km these data were supplemented with averages from the National Meteorological Center (NMC). In addition, pitot tube, falling sphere, and grenade sounder rocket measurements from 1947 to 1972 were taken into consideration. Above 72.5 km MSISE-90 is essentially a revised MSIS-86 model taking into account data derived from space shuttle flights and newer incoherent scatter results.\n\nThe input parameters for the NRLMSISE-00 model are altitude, geodetic longitude and latitude, day of year, seconds in day, average and current F10.7 flux, and magnetic index. On output, the model provides temperature at altitude, exospheric temperature, total mass density, and number densities for He, O, N$_2$, O$_2$, Ar, H, N and anomalous oxygen.\n\nThe algorithm for calculating $T_\\infty$ differs between the J71G and the NRLMSISE-00 model. Figure~\\ref{fig:comp_tinfty} compares the $T_\\infty$ profiles over a single day (left) and over a year, at UT=0 and UT=12 hours (right). It can be seen that the daily profile of the NRLMSISE-00 model appears more complex, showing less symmetry and a pronounced minimum. The annual NRLMSISE-00 profile displays a higher amplitude and lower average than the J71G model.\n\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{tinf_daily.eps}\n\\includegraphics[width=0.5\\textwidth]{tinf_annual.eps}\n\\caption{Comparison of $T_\\infty$ values for the J71G and NRLMSISE-00 models. Left: daily profile on 10 March. Right: annual profile, measured daily at UT=0 and UT=12 hours. For all data, a location of longitude=0 and latitude=0 was used.}\n\\label{fig:comp_tinfty}\n\\end{figure}\n\nThe temperature profile as a function of altitude for a given data (MJD 54900.5) at latitude=0, longitude=0) for both models is shown in Fig.~\\ref{fig:comp_t}.\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{j71g_nrlmsise00_cmp1.eps}\n\\caption{Comparison of temperature altitude profiles of J71G and NRLMSISE-00 at MJD=54900.5, longitude=0, latitude=0.}\n\\label{fig:comp_t}\n\\end{figure}\nThe density and pressure altitude profiles for both models at the same time and location are shown in Fig.~\\ref{fig:comp_dns_p}. It can be seen that the models generally agree well.\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{j71g_nrlmsise00_cmp2.eps}\n\\includegraphics[width=0.5\\textwidth]{j71g_nrlmsise00_cmp3.eps}\n\\caption{Comparison of density and pressure altitude profiles of J71G and NRLMSISE-00 at MJD=54900.5, longitude=0, latitude=0.}\n\\label{fig:comp_dns_p}\n\\end{figure}\n\n\\section{Comparison with Orbiter 2006 legacy model}\nThe atmosphere model in Orbiter Edition 2006 (denoted as OB06) uses a simple static, piecewise linear temperature profile. For segments of constant temperature, pressure and density are calculated as\n\\begin{equation}\np(z)=p_1 e^{-[g_0/(RT)](z-z_1)}, \\qquad \\rho(z)=\\rho_1 e^{-[g_0/(RT)](z-z_1)},\n\\end{equation}\nwhere $z_1$ is the base altitude of the segment, $p_1$ and $\\rho_1$ are the corresponding pressure and density, $R$ is the specific gas constant, set to $R=286.91$\\,JK$^{-1}$kg$^{-1}$ for air, and $g_0$ is the gravitational acceleration.\nThe pressure and density in sections of linearly varying temperature are calculated as\n\\begin{equation}\np(z)=p_1\\left[\\frac{T(z)}{T_1}\\right]^{-g_0/(aR)},\\qquad\n\\rho(z)=\\rho_1\\left[\\frac{T(z)}{T_1}\\right]^{-[(g_0/(aR))+1]}\n\\end{equation}\nwhere $a$ is the temperature gradient [K/m].\n\nBecause the gravitational acceleration $g$ cannot be assumed constant over the altitude range, altitude $z$ must be interpreted as a \\emph{geopotential} altitude. Conversion between geometric altiude $z_G$ and geopotential altitude $z$ is given by\n\\begin{equation}\nh = \\frac{R}{R+z_g}z_g\n\\end{equation}\nwhere $R$ is the planet radius.\n\nSimilar to the J71G model, OB06 is based on a static standard atmosphere model at low altitudes (below 105\\,km). Above this altitude, up to 200\\,km, the temperature is assumed to be constant at 225.66\\,K. This is equivalent to a very low value of $T_\\infty$, and consequently the temperature profiles of the two models diverge rapidly between the two models above 120\\,km for more realistic values of $T_\\infty$, as shown in Fig.~\\ref{fig:ob_j71g_temp}, where a value of $T_\\infty=1000$\\,K was chosen for the J71G model.\n\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{ob_j71g_temp.eps}\n\\caption{Comparison of temperature distributions between the Orbiter legacy model and the J71G model for $T_\\infty=1000$\\,K.}\n\\label{fig:ob_j71g_temp}\n\\end{figure}\nLikewise, the pressure and density profiles of the legacy Orbiter model agree well with the J71G model below 120\\,km, while at higher altitudes the Orbiter model continues to follow an exponential decay, while the J71G model maintains significantly higher density and pressure values (Fig.~\\ref{fig:ob_j71g_dens_prs}).\nAs a result, the OB06 model values drop to essentially insignificant values at $z=200$\\,km, the default cutoff altitude of the legacy model, while density and pressure remain significant to much higher altitudes for the J71G model.\n\nThe transition from the OB06 to the J71G model in Orbiter will therefore lead to significantly higher drag effects from altitudes above 120\\,km which will continue substantially above the previous cutoff altitude of 200\\,km.\n\n\\begin{figure}\n\\includegraphics[width=0.5\\textwidth]{ob_j71g_dens.eps}\n\\includegraphics[width=0.5\\textwidth]{ob_j71g_prs.eps}\n\\caption{Comparison of density (left) and pressure distributions (right) between the Orbiter legacy model and the J71G model for $T_\\infty=1000$\\,K.}\n\\label{fig:ob_j71g_dens_prs}\n\\end{figure}\n\n\\section {Computational complexity}\nFor a real-time application like Orbiter, the computational efficiency of the atmosphere model is important. Atmosphere data are queried at each time frame by each vessel within the atmosphere range limit of a given celestial body. For densely populated simulation scenarios, a complex atmosphere model may adversely affect performance.\n\nTiming results for the three atmosphere models are shown in Table~\\ref{tab:timing}. They show the times for 1000 evaluations of model evaluation at different altitudes. It can be seen that the NRLMSISE-00 model is significantly more expensive than the J71G model by approximately an order of magnitude, and both models are substantially more expensive than the trivial Orbiter legacy model.\n\nIt should however be noted that for moderately loaded simulation scenarios, even the more expensive models may not significantly degrade performance. For a test scenario with 50 vessels in the atmosphere, the application of the NRLMSISE-00 model resulted in a drop in frame rate from 130 to 114 frames per second.\n\\begin{table}\n\\begin{tabular}{l|lll}\nAltitude [km] & 50 & 150 & 1000 \\\\ \\hline\n2006 Legacy model & 0.000055 & 0.000056 & - \\\\\nJ71G model & 0.000289 & 0.0015 & 0.0020 \\\\\nNRLMSISE-00 model & 0.00384 & 0.0266 & 0.0146\n\\end{tabular}\n\\caption{Timing comparison between atmosphere models: Times for 1000 model evaluations at different altitudes.}\n\\label{tab:timing}\n\\end{table}\n\n\\bibliography{../ref}\n\n\\section*{Appendix A}\nBasis coefficients $c^{(M)}_{ij}$ for obtaining the logarithmic molar mass $M$ of the atmospheric gas mixture as a function of altitude $z$ (in units of km/1000) and exospheric temperature $T_\\infty$ (in units of K/1000).\n\\begin{equation}\n\\log_{10}(M(z,T_\\infty)) \\approx \\sum_{i=0}^8 \\sum_{j=0}^4 c^{(M)}_{ij} z^i T_\\infty^j\n\\end{equation}\n\\footnotesize\n\\begin{tabular}{r|rrrrr}\ni/j & 0 & 1 & 2 & 3 & 4 \\\\ \\hline\n0 &  3.60906627e+00 & -1.35761290e+01 &  2.55465982e+01 & -1.77204699e+01 &  4.07696683e+00 \\\\\n1 & -1.35606636e+01 &  1.29084956e+02 & -2.84612534e+02 &  2.12822504e+02 & -5.11308350e+01 \\\\\n2 & -1.25207810e+01 & -3.19579690e+02 &  9.77718751e+02 & -8.21851276e+02 &  2.09837747e+02 \\\\\n3 &  6.98268484e+01 &  4.02801988e+02 & -1.69988881e+03 &  1.57164796e+03 & -4.21561534e+02 \\\\\n4 & -8.44186988e+01 & -2.88755547e+02 &  1.67090876e+03 & -1.67274401e+03 &  4.67667119e+02 \\\\\n5 &  4.42735679e+01 &  1.24592950e+02 & -9.68963604e+02 &  1.03850337e+03 & -3.01006087e+02 \\\\\n6 & -7.92712088e+00 & -3.81200493e+01 &  3.34875778e+02 & -3.77385160e+02 &  1.12634338e+02 \\\\\n7 & -1.14988223e+00 &  9.20028301e+00 & -6.52157331e+01 &  7.51024325e+01 & -2.28683127e+01 \\\\\n8 &  4.13670214e-01 & -1.18725773e+00 &  5.60433585e+00 & -6.36983671e+00 &  1.95706136e+00\n\\end{tabular}\n\n\\end{document}\n", "meta": {"hexsha": "eb94474bc62212dfc5eea5caa45c6b09c1ba95f3", "size": 20916, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Doc/Technotes/earth_atm/earth_atm.tex", "max_stars_repo_name": "Ybalrid/orbiter", "max_stars_repo_head_hexsha": "7bed82f845ea8347f238011367e07007b0a24099", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1040, "max_stars_repo_stars_event_min_datetime": "2021-07-27T12:12:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-02T14:24:49.000Z", "max_issues_repo_path": "Doc/Technotes/earth_atm/earth_atm.tex", "max_issues_repo_name": "Ybalrid/orbiter", "max_issues_repo_head_hexsha": "7bed82f845ea8347f238011367e07007b0a24099", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 20, "max_issues_repo_issues_event_min_datetime": "2021-07-27T12:25:22.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-02T12:22:19.000Z", "max_forks_repo_path": "Doc/Technotes/earth_atm/earth_atm.tex", "max_forks_repo_name": "Ybalrid/orbiter", "max_forks_repo_head_hexsha": "7bed82f845ea8347f238011367e07007b0a24099", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 71, "max_forks_repo_forks_event_min_datetime": "2021-07-27T14:19:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T05:51:52.000Z", "avg_line_length": 78.0447761194, "max_line_length": 931, "alphanum_fraction": 0.7683113406, "num_tokens": 6066, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4026349255062286}}
{"text": "\\section{Subroutines for quantum-circuit simulation}\n\\label{sec:update-algorithms}\n\nWe describe algorithms for the four subroutines used in \\autoref{sec:simulation}.\nEach algorithm takes a LIM-QMDD as input.\n\n            \\textbf{\\textsf{PartialExpand}: convert an isomorphism node $\\phi$ to a Shannon node with isomorphism nodes as children (isomorphism group $G \\subseteq \\textsf{DT}$).}\n        Write $\\ket{\\phi} = \\pi_1 \\otimes \\pi_{\\rm rest} \\ket{\\psi}$, where $\\pi_1 \\in G$, $\\pi_{\\rm rest} \\in G^{\\otimes m}$ with $m=\\index(\\phi)$, and where $\\psi$ is a Shannon node $\\ket{\\psi} = \\alpha_0\\ket{0}\\ket{\\psi_0} + \\alpha_1\\ket{1}\\ket{\\psi_1}$.\n       Replace $\\phi$ by a Shannon node with as children isomorphism nodes $\\pi_{\\rm rest}\\ket{\\psi_j}$ and edge labels $\\beta_j = \\bra{j} \\pi_1 (\\alpha_0\\ket{0} + \\alpha_1\\ket{1})$ with subscript $j=0$ (1) indicating the low (high) edge.\n%        The correctness of this algorithm follows directly from Lemma \\todo[inline]{add}, which states that if $G \\subseteq \\textsf{DT}$, the children nodes of $\\phi$ are isomorphic to the children nodes of $\\psi$.\n        The LIM-QMDD grows by two nodes every time \\textsf{PartialExpand} is applied.\n\n\n\n\n               \\textbf{\\textsf{Swap}: move qubit $k$ to the most significant position.}\n               We describe an algorithm \\textsf{SwapAdjacent}$(j, j+1)$ which swaps qubits $j$ and $j+1$. \n               By applying this algorithm to the qubit pairs $(k-1, k), (k-2, k-1), \\dots, (1, 2)$, the qubit with index $k$ will have moved to the most significant position.\n               The algorithm \\textsf{SwapAdjacent}$(j, j+1)$ is applied to all nodes $\\phi$ with $\\index(\\phi)=j$ individually.\nIn case $\\phi$ is a Shannon node and so are its children, then we can write \n        \\[\n\\ket{\\phi} =\n\\alpha_0\\alpha_{00}\\ket{00}\\ket{\\phi_{00}}\n+\n\\alpha_0\\alpha_{01}\\ket{01}\\ket{\\phi_{01}}\n+\n\\alpha_1\\alpha_{10}\\ket{10}\\ket{\\phi_{10}}\n+\n\\alpha_1\\alpha_{11}\\ket{11}\\ket{\\phi_{11}}\n\\]\nso for permuting $\\phi$ and its children we only need to reroute edges corresponding to\n        \\[\n\\ket{\\phi} \\mapsto\n\\alpha_0\\alpha_{00}\\ket{00}\\ket{\\phi_{00}}\n+\n\\alpha_0\\alpha_{10}\\ket{01}\\ket{\\phi_{10}}\n+\n\\alpha_1\\alpha_{01}\\ket{10}\\ket{\\phi_{01}}\n+\n\\alpha_1\\alpha_{11}\\ket{11}\\ket{\\phi_{11}}\n.\n\\]\n        In case either $\\phi$ or one of its children is an isomorphism node, then apply \\textsf{PartialExpand} to those nodes to make them Shannon nodes.\n        \\textsf{SwapAdjacent} adds at most 6 nodes since it calls \\textsf{PartialExpand} at most 3 times, so \\textsf{Swap} increases the size of the LIM-QMDD by at most a factor of 3.\n\n               \\textbf{\\textsf{AddLIMQMDD}: given LIM-QMDDs for two $n$-qubit states $\\ket{\\phi}$ and $\\ket{\\psi}$, construct a LIM-QMDD for $\\ket{\\phi} + \\ket{\\psi}$.}\n               If $\\phi$ and $\\psi$ are both Shannon nodes, write\n               $\\ket{\\phi} = \\alpha_0 \\ket{0}\\otimes\\ket{\\phi_0} + \\alpha_1 \\ket{1}\\otimes\\ket{\\phi_1}$\n               and\n               $\\ket{\\psi} = \\beta_0 \\ket{0}\\otimes\\ket{\\psi_0} + \\beta_1\\ket{1}\\otimes\\ket{\\psi_1}$ and observe that \n               \\[\n               \\ket{\\phi} + \\ket{\\psi}=\n               \\ket{0}\\otimes\\ket{\\eta_0} + \\ket{1}\\otimes\\ket{\\eta_1}\n               \\qquad\\textnormal{ where }\n               \\ket{\\eta_j} = \\alpha_j\\ket{\\phi_j} + \\beta_j\\ket{\\psi_j}\n               \\textnormal{ for $j\\in \\{0, 1\\}$}\n               .\n           \\]\n           Now construct LIM-QMDDs for $\\ket{\\eta_j}$ by calling \\textsf{AddLIMQMDD} on $\\alpha_j\\ket{\\phi_j}$ and $\\beta_j\\ket{\\psi_j}$ for both $j=0$ and $j=1$.\nA LIM-QMDD for $\\ket{\\phi} + \\ket{\\psi}$ is constructed by taking a fresh Shannon node with $\\eta_0$ and $\\eta_1$ as children on the 0-edge and 1-edge, respectively, and setting the weight of both edges to 1.\n        In case at least one of $\\phi$ or $\\psi$ is not an isomorphism node, apply the \\textsf{PartialExpand} procedure to make them into a Shannon node.\n        The \\textsf{AddLIMQMDD} subroutine has exponential runtime in $n$.\n        \n        \n\n\\todo[inline]{Come up with a notation to shorten these algorithms considerably! See my attempt in the parameters of MakeNode. Consider the use of cases in a separate definition or inside the algorithm.}\n\n\n\\textbf{\\textsf{SquaredNorm: }return the squared norm $|\\langle \\psi |\\psi \\rangle|^2$ of a LIM-QMDD node $\\psi$ (unitary isomorphism set $G$).} If $\\psi$ is a Shannon node with $\\ket{\\psi} = \\alpha_0 \\ket{0}\\otimes \\ket{\\psi_0} + \\alpha_1 \\ket{1}\\otimes\\ket{\\psi_1}$, then return $|\\alpha_0|^2\\cdot \\textnormal{\\textsf{SquaredNorm}}(\\psi_0) + |\\alpha_1|^2 \\textnormal{\\textsf{SquaredNorm}}(\\psi_1)$, while if it is an isomorphism node with $\\ket{\\psi} = \\pi\\ket{\\phi}$, with $\\pi$ the isomorphism, then return $|\\langle \\psi|\\psi\\rangle |^2 = |\\langle \\phi|\\pi^{\\dagger} \\pi |\\phi\\rangle|^2 = |\\langle \\phi | \\phi\\rangle|^2$. The algorithm is made efficient by dynamic programming, where the norm of a node is computed once and then stored for potential later re-use.\n", "meta": {"hexsha": "eb6b9cf33829dbf35302750db72807962d2f5472", "size": 5007, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Src/CS/sections/update_algorithms.tex", "max_stars_repo_name": "Katafotic/latex_parsing", "max_stars_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Src/CS/sections/update_algorithms.tex", "max_issues_repo_name": "Katafotic/latex_parsing", "max_issues_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Src/CS/sections/update_algorithms.tex", "max_forks_repo_name": "Katafotic/latex_parsing", "max_forks_repo_head_hexsha": "f00a9547b2034f4592e732a382cdbd34e11e13db", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.5285714286, "max_line_length": 768, "alphanum_fraction": 0.6506890354, "num_tokens": 1596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.40259760385419696}}
{"text": "\\hypertarget{exploring-distributions}{%\n\\chapter{Exploring Distributions}\\label{exploring-distributions}}\n\n\\hypertarget{introduction}{%\n\\section{Introduction}\\label{introduction}}\n\nThis is the second in a series of notebooks that make up a\n\\href{https://allendowney.github.io/PoliticalAlignmentCaseStudy/}{case\nstudy in exploratory data analysis}. This case study is part of the\n\\href{https://allendowney.github.io/ElementsOfDataScience/}{\\emph{Elements\nof Data Science}} curriculum.\n\nIn this notebook, we:\n\n\\begin{enumerate}\n\\def\\labelenumi{\\arabic{enumi}.}\n\\item\n  Look at responses to the variable \\passthrough{\\lstinline!polviews!},\n  which represent political alignment on a 7-point scale from liberal to\n  conservative.\n\\item\n  Compare the distribution of responses in 1974 and 1990.\n\\item\n  Plot the mean and standard deviation of responses over time as a way\n  of quantifying changes in political alignment and polarization.\n\\item\n  Use local regression to plot a smooth line through noisy data.\n\\item\n  Use cross tabulation to compute the fraction of respondents in each\n  category over time.\n\\item\n  Plot the results using a custom color palette.\n\\end{enumerate}\n\nAs an exercise, you will look at changes in political party affiliation\nover the same period.\n\nThe following cell installs the \\passthrough{\\lstinline!empiricaldist!}\nlibrary if necessary.\n\n\\begin{lstlisting}[language=Python,style=source]\ntry:\n    import empiricaldist\nexcept ImportError:\n    !pip install empiricaldist\n\\end{lstlisting}\n\nIf everything we need is installed, the following cell should run\nwithout error.\n\n\\begin{lstlisting}[language=Python,style=source]\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nfrom empiricaldist import Pmf\n\\end{lstlisting}\n\nThe following cell defines a function I use to decorate the axes in\nplots.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef decorate(**options):\n    \"\"\"Decorate the current axes.\n    \n    Call decorate with keyword arguments like\n    decorate(title='Title',\n             xlabel='x',\n             ylabel='y')\n             \n    The keyword arguments can be any of the axis properties\n    https://matplotlib.org/api/axes_api.html\n    \"\"\"\n    ax = plt.gca()\n    ax.set(**options)\n    \n    handles, labels = ax.get_legend_handles_labels()\n    if handles:\n        ax.legend(handles, labels)\n\n    plt.tight_layout()\n\\end{lstlisting}\n\n\\hypertarget{loading-the-data}{%\n\\section{Loading the data}\\label{loading-the-data}}\n\nIn the previous notebook, we downloaded GSS data, loaded and cleaned it,\nresampled it to correct for stratified sampling, and then saved the data\nin an HDF5 file, which is much faster to load. In this and the following\nnotebooks, we'll download the HDF5 file and load it.\n\nThe following cell downloads the file if necessary.\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom os.path import basename, exists\n\ndef download(url):\n    filename = basename(url)\n    if not exists(filename):\n        from urllib.request import urlretrieve\n        local, _ = urlretrieve(url, filename)\n        print('Downloaded ' + local)\n\ndownload('https://github.com/AllenDowney/PoliticalAlignmentCaseStudy/' +\n         'raw/master/gss_eda.3.hdf5')\n\\end{lstlisting}\n\nThis file contains three DataFrames containing resamples of the GSS\ndata. We'll work with the first resampling,\n\\passthrough{\\lstinline!gss0!}, to get started; at the end of this\nnotebook, we'll see the other two as well.\n\n\\begin{lstlisting}[language=Python,style=source]\ndatafile = 'gss_eda.3.hdf5'\ngss = pd.read_hdf(datafile, 'gss0')\ngss.shape\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n(64814, 169)\n\\end{lstlisting}\n\n\\hypertarget{political-alignment}{%\n\\section{Political alignment}\\label{political-alignment}}\n\nThe people surveyed as part of the GSS were asked about their\n``political alignment'', which is where they place themselves on a\nspectrum from liberal to conservative.\n\nThe variable \\passthrough{\\lstinline!polviews!} contains responses to\nthe\n\\href{https://gssdataexplorer.norc.org/projects/52787/variables/178/vshow}{following\nquestion}:\n\n\\begin{quote}\nWe hear a lot of talk these days about liberals and conservatives. I'm\ngoing to show you a seven-point scale on which the political views that\npeople might hold are arranged from extremely liberal--point 1--to\nextremely conservative--point 7. Where would you place yourself on this\nscale?\n\\end{quote}\n\nHere are the valid responses:\n\n\\begin{lstlisting}[style=output]\n1   Extremely liberal\n2   Liberal\n3   Slightly liberal\n4   Moderate\n5   Slightly conservative\n6   Conservative\n7   Extremely conservative\n\\end{lstlisting}\n\nTo see how the responses have changed over time, we'll inspect them at\nthe beginning and end of the observation period.\n\nFirst I'll select the column.\n\n\\begin{lstlisting}[language=Python,style=source]\npolviews = gss['polviews']\n\\end{lstlisting}\n\nThen compute a Boolean Series that's \\passthrough{\\lstinline!True!} for\nresponses from 1974.\n\n\\begin{lstlisting}[language=Python,style=source]\nyear74 = (gss['year'] == 1974)\n\\end{lstlisting}\n\nNow we can select the responses from 1974.\n\n\\begin{lstlisting}[language=Python,style=source]\npolviews74 = polviews[year74]\n\\end{lstlisting}\n\nAs in the previous notebook, we'll use \\passthrough{\\lstinline!values!}\nto plot the values in the series and their frequencies.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef values(series):\n    \"\"\"Count the values and sort.\n    \n    series: pd.Series\n    \n    returns: series mapping from values to frequencies\n    \"\"\"\n    return series.value_counts().sort_index()\n\\end{lstlisting}\n\nHere are the responses from 1974.\n\n\\begin{lstlisting}[language=Python,style=source]\nvalues(polviews74)\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  polviews \\\\\n\\midrule\n1.0 &        31 \\\\\n2.0 &       201 \\\\\n3.0 &       211 \\\\\n4.0 &       538 \\\\\n5.0 &       223 \\\\\n6.0 &       181 \\\\\n7.0 &        30 \\\\\n\\bottomrule\n\\end{tabular}\n\nAnd here are the responses from 2018.\n\n\\begin{lstlisting}[language=Python,style=source]\nyear18 = (gss['year'] == 2018)\npolviews18 = polviews[year18]\nvalues(polviews18)\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  polviews \\\\\n\\midrule\n1.0 &        89 \\\\\n2.0 &       269 \\\\\n3.0 &       265 \\\\\n4.0 &       891 \\\\\n5.0 &       310 \\\\\n6.0 &       342 \\\\\n7.0 &        92 \\\\\n\\bottomrule\n\\end{tabular}\n\n\\hypertarget{pmfs}{%\n\\section{PMFs}\\label{pmfs}}\n\nTo visualize these distributions, we'll use the Probability Mass\nFunction (PMF), which is similar to a histogram. The difference is that\nthe PMF is ``normalized'', which means that it shows the percentage of\npeople who gave each response, rather than the number.\n\nI'll use the \\passthrough{\\lstinline!Pmf!} class from\n\\passthrough{\\lstinline!empiricaldist!} to compute them.\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom empiricaldist import Pmf\n\\end{lstlisting}\n\nHere's the distribution from 1974:\n\n\\begin{lstlisting}[language=Python,style=source]\npmf74 = Pmf.from_seq(polviews74)\npmf74.bar(label='1974', color='C0', alpha=0.7)\n\ndecorate(xlabel='Political view on a 7-point scale',\n         ylabel='Fraction of population',\n         title='Distribution of political views')\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_30_0.pdf}\n\\end{center}\n\nAnd from 2018:\n\n\\begin{lstlisting}[language=Python,style=source]\npmf18 = Pmf.from_seq(polviews18)\npmf18.bar(label='2018', color='C1', alpha=0.7)\n\ndecorate(xlabel='Political view on a 7-point scale',\n         ylabel='Fraction of population',\n         title='Distribution of political views')\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_32_0.pdf}\n\\end{center}\n\nIn both cases, the most common response is \\passthrough{\\lstinline!4!},\nwhich is the code for ``moderate''. And few respondents describe\nthemselves as ``extremely'' liberal or conservative.\n\nSo maybe we're not so polarized after all.\n\nTo make it easier to compare the distributions, I'll plot them side by\nside.\n\n\\begin{lstlisting}[language=Python,style=source]\npmf74.bar(label='1974', width=-0.45, align='edge', alpha=0.7)\n\npmf18.bar(label='2018', width=0.45, align='edge', alpha=0.7)\n\ndecorate(xlabel='Political view on a 7-point scale',\n         ylabel='Fraction of population',\n         title='Distribution of political views')\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_34_0.pdf}\n\\end{center}\n\nNow we can see the changes in the distribution more clearly. It looks\nlike the number of people at the extremes (1 and 7) has increased, and\nthe fraction of liberal (2) and slightly liberal (3) has decreased.\n\n\\textbf{Exercise:} To summarize these changes, we can compare the mean\nand standard deviation of \\passthrough{\\lstinline!polviews!} in 1974 and\n2018.\n\nThe mean of the responses measures the balance of people in the\npopulation with liberal or conservative leanings. If the mean increases\nover time, that might indicate a shift in the population toward\nconservatism.\n\nThe standard deviation measures the dispersion of views in the\npopulation; if it increases over time, that might indicate an increase\nin polarization.\n\nCompute the mean and standard deviation of\n\\passthrough{\\lstinline!polviews74!} and\n\\passthrough{\\lstinline!polviews18!}.\n\nWhat do they indicate about changes over this interval?\n\n\\hypertarget{time-series}{%\n\\section{Time series}\\label{time-series}}\n\nAt this point we have looked at the endpoints, 1974 and 2018, but we\ndon't know what happened in between.\n\nTo see how the distribution changes over time, we can group by year and\ncompute the mean of \\passthrough{\\lstinline!polviews!} during each year.\n\nFirst I'll use \\passthrough{\\lstinline!groupby!} to group the\nrespondents by year.\n\n\\begin{lstlisting}[language=Python,style=source]\ngss_by_year = gss.groupby('year')\ngss_by_year\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n<pandas.core.groupby.generic.DataFrameGroupBy object at 0x7f9b95ac7250>\n\\end{lstlisting}\n\nThe result is a \\passthrough{\\lstinline!DataFrameGroupBy!} object that\nrepresents a collection of groups. We can loop through the groups and\ndisplay the number of respondents in each:\n\n\\begin{lstlisting}[language=Python,style=source]\nfor year, group in gss_by_year:\n    print(year, len(group))\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n1972 1613\n1973 1504\n1974 1484\n1975 1490\n1976 1499\n1977 1530\n1978 1532\n1980 1468\n1982 1860\n1983 1599\n1984 1473\n1985 1534\n1986 1470\n1987 1819\n1988 1481\n1989 1537\n1990 1372\n1991 1517\n1993 1606\n1994 2992\n1996 2904\n1998 2832\n2000 2817\n2002 2765\n2004 2812\n2006 4510\n2008 2023\n2010 2044\n2012 1974\n2014 2538\n2016 2867\n2018 2348\n\\end{lstlisting}\n\nIn many ways the \\passthrough{\\lstinline!DataFrameGroupBy!} behaves like\na \\passthrough{\\lstinline!DataFrame!}. We can use the bracket operator\nto select a column:\n\n\\begin{lstlisting}[language=Python,style=source]\npolviews_by_year = gss_by_year['polviews']\npolviews_by_year\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\n<pandas.core.groupby.generic.SeriesGroupBy object at 0x7f9b95a1e710>\n\\end{lstlisting}\n\nA column from a \\passthrough{\\lstinline!DataFrameGroupBy!} is a\n\\passthrough{\\lstinline!SeriesGroupBy!}. If we invoke\n\\passthrough{\\lstinline!mean!} on it, the results is a series that\ncontains the mean of \\passthrough{\\lstinline!polviews!} for each year of\nthe survey.\n\n\\begin{lstlisting}[language=Python,style=source]\nmean_series = polviews_by_year.mean()\n\\end{lstlisting}\n\nAnd here's what it looks like.\n\n\\begin{lstlisting}[language=Python,style=source]\nmean_series.plot(color='C2', label='polviews')\ndecorate(xlabel='Year', \n         ylabel='Mean (7 point scale)',\n         title='Mean of polviews')\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_46_0.pdf}\n\\end{center}\n\n\\textbf{Exercise:} The standard deviation quantifies the spread of the\ndistribution, which is one way to measure polarization.\n\nPlot standard deviation of \\passthrough{\\lstinline!polviews!} for each\nyear of the survey from 1972 to 2018.\n\nDoes it show evidence of increasing polarization?\n\n\\hypertarget{local-regression}{%\n\\subsection{Local regression}\\label{local-regression}}\n\nIn the previous section we plotted mean and standard deviation of\n\\passthrough{\\lstinline!polviews!} over time. Both plots are quite\nnoisy.\n\nWe can use \\href{https://en.wikipedia.org/wiki/Local_regression}{local\nregression} to compute a smooth line through these data points.\n\nThe following function takes a Pandas Series and uses and algorithm\ncalled LOWESS to compute a smooth line. LOWESS stands for ``locally\nweighted scatterplot smoothing''.\n\n\\begin{lstlisting}[language=Python,style=source]\nfrom statsmodels.nonparametric.smoothers_lowess import lowess\n\ndef make_lowess(series):\n    \"\"\"Use LOWESS to compute a smooth line.\n    \n    series: pd.Series\n    \n    returns: pd.Series\n    \"\"\"\n    y = series.values\n    x = series.index.values\n\n    smooth = lowess(y, x)\n    index, data = np.transpose(smooth)\n\n    return pd.Series(data, index=index) \n\\end{lstlisting}\n\nWe'll use the following function to plot data points and the smoothed\nline.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef plot_series_lowess(series, color):\n    \"\"\"Plots a series of data points and a smooth line.\n    \n    series: pd.Series\n    color: string or tuple\n    \"\"\"\n    series.plot(linewidth=0, marker='o', color=color, alpha=0.5)\n    smooth = make_lowess(series)\n    smooth.plot(label='', color=color)\n\\end{lstlisting}\n\nThe following figure shows the mean of\n\\passthrough{\\lstinline!polviews!} and a smooth line.\n\n\\begin{lstlisting}[language=Python,style=source]\nmean_series = gss_by_year['polviews'].mean()\nplot_series_lowess(mean_series, 'C2')\ndecorate(ylabel='Mean (7 point scale)',\n         title='Mean of polviews',\n         xlabel='Year',\n         xlim=[1972, 2020])\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_53_0.pdf}\n\\end{center}\n\nOne reason the PMFs for 1974 and 2018 did not look very different is\nthat the mean seems to have gone up (more conservative) and then down\nagain (more liberal).\n\nGenerally, it looks like the U.S. has been trending toward liberal for\nthe last 20 years, or more, at least in the sense of how people describe\nthemselves.\n\n\\textbf{Exercise:} Use \\passthrough{\\lstinline!plot\\_series\\_lowess!} to\nplot the standard deviation of \\passthrough{\\lstinline!polviews!} with a\nsmooth line.\n\n\\hypertarget{cross-tabulation}{%\n\\section{Cross tabulation}\\label{cross-tabulation}}\n\nIn the previous sections, we treated \\passthrough{\\lstinline!polviews!}\nas a numerical quantity, so we were able to compute means and standard\ndeviations.\n\nBut the responses are really categorical, which means that each value\nrepresents a discrete category, like ``liberal'' or ``conservative''.\n\nIn this section, we'll treat \\passthrough{\\lstinline!polviews!} as a\ncategorical variable. Specifically, we'll compute the number of\nrespondents in each category for each year, and plot changes over time.\n\nPandas provides a function called \\passthrough{\\lstinline!crosstab!}\nthat computes a\n\\href{https://en.wikipedia.org/wiki/Contingency_table}{cross\ntabulation}.\n\nIt takes two Series as arguments and returns a DataFrame.\n\n\\begin{lstlisting}[language=Python,style=source]\nyear = gss['year']\ncolumn = gss['polviews']\n\nxtab = pd.crosstab(year, column)\n\\end{lstlisting}\n\nHere are the first few lines from the result.\n\n\\begin{lstlisting}[language=Python,style=source]\nxtab.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lrrrrrrr}\n\\toprule\npolviews &  1.0 &  2.0 &  3.0 &  4.0 &  5.0 &  6.0 &  7.0 \\\\\nyear &      &      &      &      &      &      &      \\\\\n\\midrule\n1974 &   31 &  201 &  211 &  538 &  223 &  181 &   30 \\\\\n1975 &   56 &  184 &  207 &  540 &  204 &  162 &   45 \\\\\n1976 &   31 &  198 &  175 &  564 &  209 &  206 &   34 \\\\\n1977 &   37 &  181 &  214 &  594 &  243 &  164 &   42 \\\\\n1978 &   21 &  140 &  255 &  559 &  265 &  187 &   25 \\\\\n\\bottomrule\n\\end{tabular}\n\nIt contains one row for each value of \\passthrough{\\lstinline!year!} and\none column for each value of \\passthrough{\\lstinline!polviews!}. Reading\nthe first row, we see that in 1974, 31 people gave response 1,\n``extremely liberal'', 201 people gave response 2, ``liberal'', and so\non.\n\nThe number of respondents varies from year to year, so we need to\n``normalize'' the results, which means computing for each year the\n\\emph{fraction} of respondents in each category, rather than the count.\n\n\\passthrough{\\lstinline!crosstab!} takes an optional argument that\nnormalizes each row.\n\n\\begin{lstlisting}[language=Python,style=source]\nxtab_norm = pd.crosstab(year, column, normalize='index')\n\\end{lstlisting}\n\nHere's what that looks like for the 7-point scale.\n\n\\begin{lstlisting}[language=Python,style=source]\nxtab_norm.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lrrrrrrr}\n\\toprule\npolviews &       1.0 &       2.0 &       3.0 &       4.0 &       5.0 &       6.0 &       7.0 \\\\\nyear &           &           &           &           &           &           &           \\\\\n\\midrule\n1974 &  0.021908 &  0.142049 &  0.149117 &  0.380212 &  0.157597 &  0.127915 &  0.021201 \\\\\n1975 &  0.040057 &  0.131617 &  0.148069 &  0.386266 &  0.145923 &  0.115880 &  0.032189 \\\\\n1976 &  0.021877 &  0.139732 &  0.123500 &  0.398024 &  0.147495 &  0.145378 &  0.023994 \\\\\n1977 &  0.025085 &  0.122712 &  0.145085 &  0.402712 &  0.164746 &  0.111186 &  0.028475 \\\\\n1978 &  0.014463 &  0.096419 &  0.175620 &  0.384986 &  0.182507 &  0.128788 &  0.017218 \\\\\n\\bottomrule\n\\end{tabular}\n\nTo make the results easier to interpret, I'm going to replace the\nnumeric codes 1-7 with strings. First I'll make a dictionary that maps\nfrom numbers to strings:\n\n\\begin{lstlisting}[language=Python,style=source]\n# recode the 7 point scale with words\nd7 = {1: 'Extremely liberal', \n      2: 'Liberal', \n      3: 'Slightly liberal', \n      4: 'Moderate', \n      5: 'Slightly conservative', \n      6: 'Conservative', \n      7: 'Extremely conservative'}\n\\end{lstlisting}\n\nThen we can use the \\passthrough{\\lstinline!replace!} function like\nthis:\n\n\\begin{lstlisting}[language=Python,style=source]\npolviews7 = gss['polviews'].replace(d7)\n\\end{lstlisting}\n\nWe can use \\passthrough{\\lstinline!values!} to confirm that the values\nin \\passthrough{\\lstinline!polviews7!} are strings.\n\n\\begin{lstlisting}[language=Python,style=source]\nvalues(polviews7)\n\\end{lstlisting}\n\n\\begin{tabular}{lr}\n\\toprule\n{} &  polviews \\\\\n\\midrule\nConservative           &      8495 \\\\\nExtremely conservative &      1770 \\\\\nExtremely liberal      &      1699 \\\\\nLiberal                &      6299 \\\\\nModerate               &     21444 \\\\\nSlightly conservative  &      8864 \\\\\nSlightly liberal       &      6981 \\\\\n\\bottomrule\n\\end{tabular}\n\nIf we make the cross tabulation again, we can see that the column names\nare strings.\n\n\\begin{lstlisting}[language=Python,style=source]\nxtab_norm = pd.crosstab(year, polviews7, normalize='index')\nxtab_norm.head()\n\\end{lstlisting}\n\n\\begin{tabular}{lrrrrrrr}\n\\toprule\npolviews &  Conservative &  Extremely conservative &  Extremely liberal &   Liberal &  Moderate &  Slightly conservative &  Slightly liberal \\\\\nyear &               &                         &                    &           &           &                        &                   \\\\\n\\midrule\n1974 &      0.127915 &                0.021201 &           0.021908 &  0.142049 &  0.380212 &               0.157597 &          0.149117 \\\\\n1975 &      0.115880 &                0.032189 &           0.040057 &  0.131617 &  0.386266 &               0.145923 &          0.148069 \\\\\n1976 &      0.145378 &                0.023994 &           0.021877 &  0.139732 &  0.398024 &               0.147495 &          0.123500 \\\\\n1977 &      0.111186 &                0.028475 &           0.025085 &  0.122712 &  0.402712 &               0.164746 &          0.145085 \\\\\n1978 &      0.128788 &                0.017218 &           0.014463 &  0.096419 &  0.384986 &               0.182507 &          0.175620 \\\\\n\\bottomrule\n\\end{tabular}\n\nWe are almost ready to plot the results, but first we need some colors.\n\n\\hypertarget{color-palettes}{%\n\\section{Color palettes}\\label{color-palettes}}\n\nSeaborn provides a variety of color palettes,\n\\href{https://seaborn.pydata.org/tutorial/color_palettes.html}{which you\ncan read about here}.\n\nTo represent political views, I'll use a diverging palette from blue to\nred.\n\n\\begin{lstlisting}[language=Python,style=source]\npalette = sns.color_palette('RdBu_r', 7)\nsns.palplot(palette)\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_74_0.pdf}\n\\end{center}\n\nThe middle color is white, which won't work when we plot it, so I will\nreplace it with a purple color from another palette.\n\n\\begin{lstlisting}[language=Python,style=source]\nmuted = sns.color_palette('muted', 7)\npurple = muted[4]\nsns.palplot(muted)\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_76_0.pdf}\n\\end{center}\n\nHere's the modified diverging palette with purple in the middle.\n\n\\begin{lstlisting}[language=Python,style=source]\npalette[3] = purple\nsns.palplot(palette)\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_78_0.pdf}\n\\end{center}\n\nA feature of this color map is that the colors are meaningful, at least\nin countries that use blue, purple, and red for these points on the\npolitical spectrum. A drawback of this color map is that some some of\nthe colors are indistinguishable to people who are\n\\href{https://davidmathlogic.com/colorblind}{color blind}.\n\nNow I'll make a dictionary that maps from the responses to the\ncorresponding colors.\n\n\\begin{lstlisting}[language=Python,style=source]\ncolumns = ['Extremely liberal', \n           'Liberal', \n           'Slightly liberal', \n           'Moderate', \n           'Slightly conservative', \n           'Conservative',\n           'Extremely conservative']\n\\end{lstlisting}\n\n\\begin{lstlisting}[language=Python,style=source]\ncolor_map = dict(zip(columns, palette))\n\nfor key, value in color_map.items():\n    print(key, value)\n\\end{lstlisting}\n\n\\begin{lstlisting}[style=output]\nExtremely liberal (0.16339869281045757, 0.44498269896193776, 0.6975009611687812)\nLiberal (0.4206843521722416, 0.6764321414840447, 0.8186851211072664)\nSlightly liberal (0.7614763552479817, 0.8685121107266438, 0.924567474048443)\nModerate (0.5843137254901961, 0.4235294117647059, 0.7058823529411765)\nSlightly conservative (0.9824682814302191, 0.8006920415224913, 0.7061130334486736)\nConservative (0.8945790080738177, 0.5038062283737024, 0.39976931949250283)\nExtremely conservative (0.7284890426758939, 0.15501730103806227, 0.1973856209150327)\n\\end{lstlisting}\n\n\\hypertarget{plotting}{%\n\\section{Plotting}\\label{plotting}}\n\nTo plot the results, I use the following function, which takes a\n\\passthrough{\\lstinline!DataFrame!} and plots each column using\n\\passthrough{\\lstinline!plot\\_series\\_lowess!}.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef plot_columns_lowess(table, columns, colors):\n    \"\"\"Plot the columns in a DataFrame.\n    \n    table: DataFrame with a cross tabulation\n    columns: list of column names, in the desired order\n    colors: mapping from column names to colors\n    \"\"\"\n    for col in columns:\n        series = table[col]\n        plot_series_lowess(series, colors[col])\n\\end{lstlisting}\n\nThe following function sets the position of the figure legend.\n\n\\begin{lstlisting}[language=Python,style=source]\ndef anchor_legend(x, y):\n    \"\"\"Place the upper left corner of the legend box.\n    \n    x: x coordinate\n    y: y coordinate\n    \"\"\"\n    plt.legend(bbox_to_anchor=(x, y), loc='upper left', ncol=1)\n\\end{lstlisting}\n\nHere are the 7 categories plotted as a function of time.\n\n\\begin{lstlisting}[language=Python,style=source]\nplot_columns_lowess(xtab_norm, columns, color_map)\ndecorate(xlabel='Year',\n         ylabel='Proportion',\n         title='Fraction of people with each political view',\n         xlim=[1972, 2020])\n\nanchor_legend(1.02, 1.02)\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_87_0.pdf}\n\\end{center}\n\nThis way of looking at the results suggests that changes in political\nalignment during this period have generally been slow and small.\n\nThe fraction of self-described moderates has not changed substantially.\n\nThe fraction of conservatives increased, but seems to be decreasing now;\nthe number of liberals seems to be increasing.\n\nThe fraction of people at the extremes has increased, but it is hard to\nsee clearly in this figure.\n\nWe can get a better view by plotting just the extremes.\n\n\\begin{lstlisting}[language=Python,style=source]\ncolumns2 = ['Extremely liberal', 'Extremely conservative']\n\nplot_columns_lowess(xtab_norm, columns2, color_map)\ndecorate(xlabel='Year',\n         ylabel='Proportion',\n         title='Fraction of people with extreme political views',\n         xlim=[1970, 2020])\n\nanchor_legend(1.02, 1.02)\n\\end{lstlisting}\n\n\\begin{center}\n\\includegraphics[scale=0.75]{02_polviews_files/02_polviews_89_0.pdf}\n\\end{center}\n\nThis figure shows that the fraction of people who describe themselves as\n``extreme'' has increased from about 2.5\\% to about 4\\%.\n\nIn relative terms, that's a big increase. But in absolute terms these\ntails of the distribution are still small.\n\n\\textbf{Exercise:} Let's do a similar analysis with\n\\passthrough{\\lstinline!partyid!}, which encodes responses to the\nquestion:\n\n\\begin{quote}\nGenerally speaking, do you usually think of yourself as a Republican,\nDemocrat, Independent, or what?\n\\end{quote}\n\nThe valid responses are:\n\n\\begin{lstlisting}[style=output]\n0   Strong democrat\n1   Not str democrat\n2   Ind,near dem\n3   Independent\n4   Ind,near rep\n5   Not str republican\n6   Strong republican\n7   Other party\n\\end{lstlisting}\n\nYou can\n\\href{https://gssdataexplorer.norc.org/projects/52787/variables/141/vshow}{read\nthe codebook for \\passthrough{\\lstinline!partyid!} here}.\n\nHere are the steps I suggest:\n\n\\begin{enumerate}\n\\def\\labelenumi{\\arabic{enumi})}\n\\item\n  If you have not already saved this notebook, you should do that first.\n  If you are running on Colab, select ``Save a copy in Drive'' from the\n  File menu.\n\\item\n  Now, before you modify this notebook, make \\emph{another} copy and\n  give it an appropriate name.\n\\item\n  Search and replace \\passthrough{\\lstinline!polviews!} with\n  \\passthrough{\\lstinline!partyid!} (use ``Edit-\\textgreater Find and\n  replace'').\n\\item\n  Run the notebook from the beginning and see what other changes you\n  have to make.\n\\end{enumerate}\n\nYou will have to make changes in \\passthrough{\\lstinline!d7!} and\n\\passthrough{\\lstinline!columns!}. Otherwise you might get a message\nlike\n\n\\passthrough{\\lstinline!TypeError: '<' not supported between instances of 'float' and 'str'!}\n\nAlso, you might have to drop ``Other party'' or change the color\npalette.\n\nAnd you should change the titles of the figures.\n\nWhat changes in party affiliation do you see over the last 50 years? Are\nthings going in the directions you expected?\n\nWrite a headline (or a couple) that describe the most substantial\nchanges you see.\n\n", "meta": {"hexsha": "c985463db9ab388c98e211e2179e108587fc8d5e", "size": 27176, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "book/02_polviews.tex", "max_stars_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_stars_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2021-05-06T13:57:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-27T18:21:30.000Z", "max_issues_repo_path": "book/02_polviews.tex", "max_issues_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_issues_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "book/02_polviews.tex", "max_forks_repo_name": "AllenDowney/ElementsOfDataScienceBook", "max_forks_repo_head_hexsha": "3b87dfdd81c68ebd17f84a818326ed87da265ddb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-27T10:41:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T10:41:22.000Z", "avg_line_length": 30.742081448, "max_line_length": 143, "alphanum_fraction": 0.725897851, "num_tokens": 7698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.40254747892237036}}
{"text": "\\documentclass[../PHYS306Notes.tex]{subfiles}\n\n\\begin{document}\n\\section{Lecture 33}\n\\subsection{Lecture Notes - Lyapunov Exponents, Bifurcation Diagrams, State-Space orbits, and Poincare Sections}\n\\subsubsection{Period doubling cascade - \"Route to Chaos\"}\nPeriod doubles each time the driving strength of the driven damped pendulum is increased past $\\gamma_n$:\n\\[\\delta = \\lim_{n\\rightarrow\\infty}\\frac{\\gamma_{n-1} - \\gamma_{n-2}}{\\gamma_n - \\gamma_{n-1}} = 4.6692016\\ldots\\]\nThis is the universal \"Feigenbaum number\".\n\\subsubsection{The driven damped pendulum revisisted}\nWe return to the driven damped pendlum from last day. Giving two pendulums driving strengths of $\\gamma = 1.503$, and one with initial phase of $\\phi_0 = 0$ and the other with $\\phi_0 = 0.005$, we can see that after time, the trajectories begin to diverge significantly.\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img1.png}\n\\end{center}\nWith a driving strength of 1.077, and an initial phase shift of $-28$, we see that there is definitely a divergence in the two trajectories, but it looks periodic. \n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img2.png}\n\\end{center}\nWith $\\Delta \\phi = -27$, the difference is different from $\\Delta \\phi = -28$ but still periodic. With $\\Delta \\phi = -29$, we see that we actually reach a constant difference:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img3.png}\n\\end{center}\nWith a slightly different driving strength, we see:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img4.png}\n\\end{center}\nWe recognize that we are slightly further into the chaotic regime; looking at the difference between the two pendulums, we see that there is no repeated pattern (there are slight differneces between cycles, so there doesn't appear to be periodic/perfect repetition).\n\n\\subsubsection{Sensitivity to Initial Conditions \\& Lyapunov Exponents}\n$\\Phi(t) = \\Phi_2(t) - \\Phi_1(t)$ os the difference between two solutions with slightly different initial conditions. For linear oscillations,\n\\[\\Delta \\Phi(t) = D\\exp(-\\beta t)\\cos(\\omega t - \\delta)\\]\nIn general:\n\\[\\Delta \\Phi(t) \\sim K\\exp(\\lambda t)\\]\n$\\lambda$ is the Lyapunov exponent, with periodic motion when it is negative and chaotic motion when it is positive. It is often best to plot $\\log\\abs{\\Delta \\Phi(t)} \\sim \\lambda t + \\text{Const.}$ to see what happens with time.Doing so, we should either see a line with a positive or negative slope, depending on whether the trajectory is divergent (chaotic) or convergent (periodic) respectively. Plotting this for our two driven damped pendulums, we see:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img5.png}\n\\end{center}\nThe peaks follow the linear trend, and the dips correspond to when $\\Delta \\Phi$ becomes negative. For driving of 1.07 (higher), we se that we still have convergence, but the Lyapunov exponent is less negative; it takes longer for the difference between the two osicllators to vanish.\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img6.png}\n\\end{center}\n\nRamping it up to a driving strength of 1.105, we get into the Chaotic regime, where the overall slope is positive:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img7.png}    \n\\end{center}\nBut bringing it up to 1.13, we actually go back to the non-chaotic regime:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img8.png}    \n\\end{center}\n\n\\subsubsection{Bifurcation Diagrams}\nIt gets quite confusing as to when the motion is chaotic, or not! A nice way of visualizing this is with a bifurcation diagram. We plot the driving strength on the $x$ axis and $\\phi(t)$ on the y axis:\n\\begin{center}\n    \\includegraphics[scale=0.6]{Lecture-33/l33-img9.png}\n\\end{center}\nHere, we only plot the phase at specific times. If the motion is periodic and we take pictures at specific intervals, we always end up at the same point (e.g. before $\\gamma_1$). However, past $\\gamma_1$, we get period doubling and hence taking snapshots of the pendulum at the original period, we will now see two periods. Past $\\gamma_2$, we see 4 different values, and so on. Past $\\gamma = 1.0845$ we get into the chaotic regime. There is one more subtlety; once we increase the driving strength past a certain point, the pendulum can roll over the top, so the angle can go to infinity; this is a bit inconvenient! Although we could make the phase $2\\pi$ periodic, another fix is to just plot the velocity as  a function of the driving strength:\n\\begin{center}\n    \\includegraphics[scale=0.6]{Lecture-33/l33-img10.png}\n\\end{center}\nWe can see distint regions of periodicity and chaos; the circled part of $a$ was the period doubling we were studying earlier, $b$ is chaotic, then $c$ goes back to regular/periodic motion, then it gets chaotic for a while $d$, then we have regular motion for a while $e$ and so on. These diagrams can be quite useful to see these regions of chaos and regularity.\n\n\\subsubsection{State Space Orbits}\nVery similar to phase space diagrams we did with Hamiltonian mechanics, but now we plot $\\dot{\\phi}$ versus $\\phi$. Looking at this plot letting it run for a little while, we can see that there are four different cycles. (4 different trajectories); we are in a period 4 scenario. \n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img11.png}\n\\end{center}\nGoing to 1.0826, we see that after the initial transience, looking very carefully we have a period 8 scenario:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img12.png}\n\\end{center}\nAnd for 1.087 we get period 16 and so on.\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img13.png}\n\\end{center}\nAs we increase the driving strength even further, the motion becomes truly aperiodic.But, increasing it back to 1.1, we get back to a periodic region (where the pendulum starts to roll over):\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img14.png}\n\\end{center}\nAnd increasing it further, the motion gets chaotic again:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img15.png}\n\\end{center}\n\\subsubsection{Poincare Sections}\nWe can plot a point per cycle to get a Poincare section:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img16.png}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img17.png}\n\\end{center}\nSo for the 4-period case, we expect to see 4 dots, which is indeed the case (though two are close together in the below plot):\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img18.png}\n\\end{center}\nPictured below is a strange attractor:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img19.png}\n\\end{center}\nThis is actually a fractal; fractals have scale invariance/self-similarity.\n\n\\subsubsection{The Logistic map}\nThe logistic map is defined as $x_{t+1} \\mapsto rx_t(1 - x_t)$, describing the reproduction and starvation of a population. Looking a the bifurcation diagram as we vary $r$, we see a similar development of chaotic behavior as the pendulum, due to the nonlinearity:\n\\begin{center}\n    \\includegraphics[scale=0.7]{Lecture-33/l33-img20.png}\n\\end{center}\n\n\\end{document}", "meta": {"hexsha": "85c14837b86267afbbf088b6e106194a4c829cb7", "size": 7186, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Lecture-33/Lecture-Notes-33.tex", "max_stars_repo_name": "RioWeil/PHYS306-notes", "max_stars_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture-33/Lecture-Notes-33.tex", "max_issues_repo_name": "RioWeil/PHYS306-notes", "max_issues_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture-33/Lecture-Notes-33.tex", "max_forks_repo_name": "RioWeil/PHYS306-notes", "max_forks_repo_head_hexsha": "9394a8cd986722b6fdcb57c8846c6b0d52c23188", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.7924528302, "max_line_length": 749, "alphanum_fraction": 0.7570275536, "num_tokens": 1997, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.4025474760166659}}
{"text": "\\documentclass[thesis.tex]{subfiles}\n\n\\begin{document}\n\\chapter{Background and Related Work}\nThe field of neuroinformatics, despite its recent emergence, has burgeoned rather rapidly, has produced and adopted a wide variety of techniques that can be used for performing white matter integrity and structure research. Since my work has greatly relied on the ideas and methods used in CoBundleMAP and within the FBA, in this chapter an overview of these approaches will be given, together with my reflections on this particular topic.\n\n%=======================================================================================================\n\\section{Diffusion weighted MRI}\n%------------------------------------------------------------------------------------\n\\subsection{General information}\nDiffusion weighted imaging (DWI) is a well-established, noninvasive method of acquiring information about the structure of biological tissues. It is based on the fact that in unrestricted mediums water movement is absolutely random (Brownian movement), while restricted areas force molecules to diffuse in specific directions. These two possibilities are called isotropic diffusion and anisotropic diffusion respectively. Diffusion weighted MRI is capable of measuring the amount of such water motion along any chosen axis. To define the direction of the diffusion in three-dimensional space, observations are made by applying diffusion gradient pulses along several non-collinear orientations \\cite{ChanraudDTI}.\nAnisotropic water diffusion inside of biological tissue is explained as the result of molecular movement being restricted by specific barriers such as cell membranes or axon fibres \\cite{diffusion1990Moseley}. Specifically in the brain white matter fiber tracts, that consist of axon bundles, the presence of myelination forces water to diffuse preferentially along axonal fiber directions \\cite{WMdiffusion} \\cite{Mori1999DiffusionMR}. Existence of such dominant direction is the basis for a wide variety of techniques. Based on diffusion tensor analysis, white matter tractography and calculation of various characteristic metrics can be executed \\cite{Basser1995InferringMF}. Among such measures are Fractional Anisotropy, Mean Diffusivity, Axial Diffusivity and Radial Diffusivity, all of which are used in existing implementation of CoBundleMap pipeline, and will be discussed further in more details.\n\nDWI allows us to perform a noninvasive analysis of the micro-structure of tissue, which is extremely useful in cases of white matter research, where possibility of in vivo investigation is of significant value. DWI has significantly contributed to our understanding of the human brain. The possibility to examine the white matter bundle structures and, when present, find pathological abnormalities has helped us comprehend various neurological diseases and disorders \\cite{dwiDiseases, ChanraudDTI, dtiGeneralGood}, as well as effects of aging on human brain \\cite{moseleyAging} and mechanisms of neuroplasticity \\cite{Tournier2004FODdeconv, dwiDiseases}.\n\n%------------------------------------------------------------------------------------\n\\subsection{Diffusion tensor imaging}\nDiffusion Tensor Imaging (DTI) is a quantitative imaging method that provides the possibility to infer brain micro-structure properties based on data acquired through DWI \\cite{BasserHow}. Common uses of the DTI include: white matter fiber tractography, brain connectivity analysis, and assessment of parameters that describe integrity and general state of both white and grey matter.\n\n% \\begin{figure}\n% \\centering\n% \\includegraphics[width=14cm,height=14cm,keepaspectratio]{thesis_radomskyi/images/dti-scheme-cite-Basser1995InferringMF.png}\n% \\caption{\\textbf{DTI Scheme.} This scheme depicts the basic steps involved in diffusion tensor imaging approach. The output of DTI for each processed voxel is a 3x3 diffusion tensor and a $T_2$-weighted scalar A(0) \\cite{Basser1995InferringMF}.}\n% \\label{fig:dti-scheme}\n% \\end{figure}\n\n\nThe main idea of this approach lies in estimating a symmetric and positive definite tensor $D_{eff}$ -- effective diffusion tensor, within each voxel. This is performed by selecting a local orthogonal coordinate system and calculating three corresponding diffusion coefficients in these directions \\cite{Basser1994DTI}. The diffusion tensor, being a symmetric 3 $\\times$ 3 matrix, can be described by three positive eigenvalues ($\\lambda_1, \\lambda_2, \\lambda_3$) and three orthogonal eigenvectors ($e_1, e_2, e_3$). These eigenvalues represent the magnitude of diffusion within each given voxel, while eigenvectors reflect the corresponding directions. Such tensor may be interpreted as a mathematical representation of three-dimensional ellipsoid \\cite{Basser1995InferringMF}, describing diffusion characteristics in individual voxels (Figure \\ref{fig:dti-scheme}).\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=14cm,height=14cm,keepaspectratio]{thesis_radomskyi/images/dti-scheme-cite-Basser1995InferringMF.png}\n\\caption{\\textbf{DTI Scheme.}}\n\\label{fig:dti-scheme}\n\\end{figure}\n\nFrom the parameters that are contained in DT, a set of scalar quantities that measure fundamental features of diffusion within tissues can be extracted  \\cite{Basser1995InferringMF, Basser1996FA}.\n\nThe most basic of such metrics is eigenvalue average, or trace of DT, referred to as Mean Diffusivity (MD). It is rotationally invariant and reflects the magnitude of overall diffusion within the voxel:\n\\[ MD = \\frac{tr(D)}{3} = \\frac{\\lambda_1 + \\lambda_2 + \\lambda_3}{3} \\]\nHigher values of MD are indicators of isotropic diffusion (possible axon degeneration or demyelination), while lower MD is primarily observed in regions of anisotropic diffusion (high myelination, dense axonal packing). Another rotationally invariant measure extracted from TD is FA. It describes the degree of orientational preference within a voxel, or in other words, amount of anisotropy, and is often used as a measure of white matter integrity. In relation to DT eigenvalues, it defines the extent to which one eigenvalue prevails over other two and is computed based on MD:\n\\[ FA = \\sqrt{\\frac{(\\lambda_1 - MD)^2 + (\\lambda_2 - MD)^2 + (\\lambda_3 - MD)^2}{2(\\lambda_{1}^2 + \\lambda_{2}^2 + \\lambda_{3}^2)}} \\]\n\nExisting implementation of CoBundleMAP also performs computation of two more DT-derived metrics related to analysis of white matter pathologies \\cite{dtiGeneralGood} -- Axial Diffusivity (AD) and Radial Diffusivity (RD). AD reflects axonal integrity and \\cite{RDmyelination} equals to the value of the largest eigenvalue:\n\\[AD = \\lambda_1\\]\nwhile RD is defined by secondary eigenvalues and reflect myelin integrity \\cite{RDmyelination}:\n\\[RD = \\frac{\\lambda_2 + \\lambda_3}{2}\\]\nThough it is worth mentioning that interpretation of AD and RD should be performed with care and preferably in combination with other DTI-derived features \\cite{rd-ad-crit}.\nNevertheless, analysis of diffusion measures and their correlations is a reliable method of gaining valuable insights about the condition of white matter tissue. For example, simultaneous rise in FA combined with lower RD is a sign of dense axonal packing or high myelination, while the mirrored case -- low FA and high RD are signals of either axonal degeneration or demyelination \\cite{fa-fd-correlation}.\n%------------------------------------------------------------------------------------\n\\subsection{Voxel based analysis}\n\nVoxel-based analysis (VBA) is a technique used for voxel-wise analysis of diffusion images across a given population of subjects, capable of identifying local differences and correlations in the structure of brain tissue. It is an important and well-established approach, permitting comparison of the voxels between the same areas of different brains, which in case of significant differences can reveal the presence of a degenerative disease. The essential principle on which VBA is based, is retrieval of anatomical correspondences between the subjects by spatially normalizing images to s a common stereotactic space (usually a brain atlas), using image registration algorithms \\cite{vbaMechelli}. Image registration commonly consists of two distinct steps, which sequentially increase similarity between the input and reference images. First one is computation of the linear transformation, including estimation of the rigid-body transformation, used for rotation and translation of the image, followed by global scaling and skewing. This allows to perform correction of differences in the brain size across the population as well as revision of possible orientation variations. Second step accounts for global nonlinear differences and involves estimation of the coefficients of the basis function, minimizing the residual sum of squared differences between them and simultaneously maximizing the smoothness of the deformation \\cite{vbaAshburner}. Deformation field, derived from image registration, contains information about adjustments made for matching voxels of the input image and the template. One of the important outcomes of the image spatial normalization, is that exact voxel-wise volume fluctuations can be computed from extracted deformation fields as Jacobian determinants. Analysis of Jacobian determinants as well as the deformation fields themselves establishes what is known as tensor-based morphometry or deformation-based morphometry \\cite{vbaKurth}.\n\n\\subsection{Constrained spherical deconvolution}\nSpherical deconvolution is an approach used for estimations of the fiber orientation distribution (FOD) function within the voxels of diffusion-weighted images. Introduction of this approach allowed to perform identification of multiple fiber orientations within a single voxel, as shown on Figure \\ref{fig:sd-is-good}. It is based on several assumptions about the nature of diffusion inside white matter tissue and implies that it is possible to approximate the measured diffusion-weighted signal as a sum of the signals emitted by each of the orientationally distinct fiber population that is present in the sample \\cite{csd1TOURNIER}. Therefore, the signal measured from a single fiber population is expressed as a symmetric response function $R(\\theta)$, where $\\theta$ is elevation angle in spherical coordinates, while the signal originating from multiple incoherently aligned populations is defined as a sum of such functions, aligned with respect to their orientation (via azimuthal angle $\\phi$ in spherical coordinates) and weighted by the share of volume ($f_{i}$), that each population occupies within the voxel \\cite{csd1TOURNIER}: \\[S(\\theta, \\phi) = \\sum_{i}f_{i}A_{i}R(\\theta)\\]\nHere, $A_{i}$ is an operator of rotation onto direction ($\\theta_{i}, \\phi_{i}$). The signal can be then subsequently interpreted as a convolution over spherical coordinates of the FOD function and response function:\n\\[S(\\theta, \\phi) = F(\\theta, \\phi) \\otimes R(\\theta)\\]\nFOD estimation can then be seen as a problem of inferring the distribution from the measured signal, given a suitable response function \\cite{csdDellAcqua2019}. Constrained spherical deconvolution (CSD) is a further development of these ideas. The main improvement of CSD over simple spherical deconvolution is the introduction of a non-negativity constraint on the values in the computed FOD, leading to elimination of the noise caused by high angular frequencies \\cite{dwi2fod2-csd}.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=14cm,keepaspectratio]{thesis_radomskyi/images/sd-is-good.png}\n\\caption{\\textbf{Comparison of DTI and SD.} Diffusion tensor (left) is capable of describing the average diffusion profile in each image voxel, thus capturing only dominant fiber population. Spherical deconvolution (right), on the other hand, is capable of identifying multiple populations. \\cite{csdDellAcqua2019}.}\n\\label{fig:sd-is-good}\n\\end{figure}\n\n%=======================================================================================================\n\\section{Fixel based analysis}\nAlthough VBA of diffusion MRI, namely analysis of tensor-derived FA values, is a rather common approach to researching structure of white matter in the brain, it has some restrictions. Since FA, as well as other diffusion measures, is computed as a value averaged within the whole voxel, it doesn't account for the fact that most white matter voxels (around 90\\% as reported in \\cite{crossingFibers2013}) contain several crossing fibres. Inside such voxels FA is affected by all fiber populations that are present, thus producing values which do not reliably represent any underlying tract. Figure \\ref{fig:percent-of-non-dominant-volume-fraction} shows statistics of affected white matter voxels and degree of their contamination with non-dominant fibre orientations.\nThis could not only affect precision of the whole system, but also prevents us from a more robust and specific analysis of individual fibres.\nA possible solution for this problem could be utilization of diffusion MRI mixture models, which are able to recognise multiple fibre populations within a single voxel. A common name for such a fibre population is \\textit{fixel} \\cite{aboutFixels2015Raffelt}, while commodity of methods that are using this approach is called Fixel-based analysis (FBA). In this section I will make an overview of papers introducing fixel-based approach to white matter analysis, as well new metrics for measuring nervous fibre integrity, density and thickness.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,height=10cm,keepaspectratio]{thesis_radomskyi/images/percent-of-non-dominant-volume-fraction-cite-crossingFibers2013.png}\n\\caption{\\textbf{Non-dominant Volume Fraction of White Matter Voxels} Histogram depicting non-dominant volume fraction measured by CSD over all white matter voxels \\cite{crossingFibers2013}}\n\\label{fig:percent-of-non-dominant-volume-fraction}\n\\end{figure}\n\n\\subsection{Fiber density and cross-section}\nInvestigation of white matter tissue is closely related to estimation of its integrity, ability to connect different regions of the brain and transfer information. The extent to which separate bundles contribute to such connectivity may be characterised by the total number of axons within the bundle, their thickness and degree of myelination. One of the proposed metrics, that is capable of measuring these properties of white matter tracts is Apparent Fiber Density (AFD) \\cite{afd2012Raffelt}. This metric introduces a novel approach to computation of fiber-specific parameters, allowing to perform analysis of individual fiber populations in voxels that contain multiple tracks, by leveraging the information, obtained within image spatial normalization process. The important development of this approach is Fiber density cross-section (FDC) metric \\cite{fdcAndFBA2017Raffelt}. This method further improves the ideas of AFD and defines FDC as a measure of white matter integrity, consisting of two related values -- Fiber density (FD), which is basically AFD, and Fiber cross-section (FC), which describes local volumetric differences within the examined population. Both metrics, similar to AFD, are based on information, contained within deformation fields which are produced by image registration. In addition to allowing computation of fiber-specific parameters, approach adopted within FBA also allows to derive better insights about the structure and integrity of the tissue. As can be observed from the Figure \\ref{fig:difference-fd-fc-fdc}, new metrics allow to distinguish between different types of intra-axonal volume changes, providing important information for deeper analysis of underlying causes.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=10cm,height=10cm,keepaspectratio]{thesis_radomskyi/images/difference-fd-fc-fdc.jpg}\n\\caption{\\textbf{Different types of intra-axonal volume reduction} By performing analysis of both FC and FD values we may achieve better insights about underlying causes\\cite{fdcAndFBA2017Raffelt}}\n\\label{fig:difference-fd-fc-fdc}\n\\end{figure}\n\n\n\n\n\\section{CoBundleMAP}\nSince the main objective of this work is to further extend CoBundleMAP, it is essential to understand its inner mechanisms and the principles upon which it is built. BundleMAP and CoBundleMAP are dMRI image processing tools, developed within the Department of Computer Science, University of Bonn. Results obtained through these pipelines contain, among other things, feature vectors that can be further utilized in machine learning and data processing algorithms, or used for visual analysis of specific white matter areas. Following subsections contain a short overview of steps performed and algorithms used within the scope of CoBundleMAP pipeline. Since CoBundleMAP is an improved, two-dimensional manifestation of BundleMAP, I will start with the overview of ideas implemented in the latter.\n\n\\subsection{BundleMAP overview}\nBundleMAP tries to solve the problem of deriving features, which are specific for an interpretive evaluation of different degenerative white matter diseases, as well as performing research of the tissue structure. The main principle of BundleMAP is to combine joint parametrization and manifold learning for extracting bundle-specific duffusivity measures \\cite{Khatami2017BundleMap}. Joint parametrization can be described as a process of finding anatomical correspondences between specific brain regions among given population of patients. If we know such unambiguous areas, we can perform localised comparisons between subjects and find areas of interest for each given application case. Features that are extracted contain such diffusion measures as FA, MD, RD and AD.\n\n\nThe pipeline can be logically split into four distinct steps (Figure \\ref{fig:bundlemap-steps}): fiber tractography, followed by supervised and unsupervised outlier removal, manifold learning, and feature extraction. Next subsections contain more specific information and explanations about each performed step.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=14cm,height=14cm,keepaspectratio]{thesis_radomskyi/images/bundlemap_steps.jpg}\n\\caption{\\textbf{BundleMAP Main Steps.} BundleMAP consists of four main steps: white matter fiber tractography, outlier removal, joint parametrization, and computation of spatially localised features along the BundleMAP coordinate \\cite{Khatami2017BundleMap}}\n\\label{fig:bundlemap-steps}\n\\end{figure}\n\n\\subsubsection{Image preprocessing and tractography}\nThe first part of the BundleMAP processing pipeline consists of each subject's DWI data processing, extraction of diffusivity measures, and performing tractography for a set of predefined white matter tracts. These steps rely on principles adopted in VBA, namely analysis of subject population by performing registration towards a common template. In the case of BundleMAP, registration is performed by using Montreal Neurological Institute atlas, which represents an average, healthy human brain \\cite{mniAtlasReference}. This introduces the presence of two different spaces -- one that is specific for the each of the subjects being processed (subject space), and the subject-agnostic MNI space. One of the advantages of using this approach, is the ability to predefine regions of interest in the space which is independent from the examined population, and then perform automatical mapping of these areas into the subject space.\nThe first data processing step within the pipeline is computation of fiber orientation distributions of the input dMRI images, using the spherical deconvolution algorithms \\cite{dwi2fod2-csd, dwi2fod2-msmt-csd}, present within MRtrix \\cite{mrtrixGeneral2019} and FSL \\cite{fsl1, fsl2} software packages. This is followed by extraction of diffusion measures and using a registration algorithm to calculate two non-linear warp fields, which establish the spatial correspondence between the image and the MNI template. These steps produce all the data required for performing white matter tractography. Thereafter tractography is performed in the subject space using MRtrix \\cite{mrtrixGeneral2019} implementation of the iFOD2 algorithm \\cite{tckgen} for probabilistic streamlines tractography.\n\n\\subsubsection{Outlier removal}\nExecution of voxelwise statistical analysis on a set of dMRI images is prone to multiple problems due to the imperfections of data and deficiency of registration and tracking algorithms \\cite{voxelwiseImperfections}. In order to improve tracking data resulting from the first pipeline step, two strategies are implemented within the CoBundleMAP. The first one is based on the knowledge of the anatomy of human brain. Since the analysis is performed on a known set of white matter bundles, information about natural constraints of such bundles is applied to cut off any fibers that do not comply with predefined spacial thresholds. Afterwards all remaining fibers from all subjects are combined and processed using a one-class support vector machine (SVM), which identifies the smallest possible area in the input space that contains majority of the samples. Additionally, a parameter $\\nu \\in (0, 1]$ is specified, controlling the fraction of samples to be discarded \\cite{Khatami2017BundleMap}.\n\n\\subsubsection{Manifold learning}\nComputation of the joint fiber bundles parametrization across the whole examined population allows to perform a robust analysis by leveraging the inter-subject spatial correspondence of computed features within specific white matter tracts.\nBundleMAP is based on the idea of representing individual white matter tracts as special cases of a generalized, abstract fiber bundle. Each fiber bundle core is thus regarded as a one-dimensional manifold, which then could be acquired through manifold learning techniques \\cite{Khatami2017BundleMap}, such as ISOMAP \\cite{isomapTenenbaum}. Fibers belonging to the same bundle are first warped to the MNI space using nonlinear transformations computed during image registration. In order to produce a \\textit{joint} parametrization, ISOMAP algorithm needs to be applied to the accumulated data from the tracts of the whole population. Since the combined number of vertices across all subjects is too big for distance matrix calculation, BundleMAP first selects a set of representative streamlines, which will be used for manifold learning by performing \\textit{k-means} clustering on tract fibers. Afterwards, vertices which belong to the selected streamlines are used for ISOMAP input. The values for the vertices that were excluded from the manifold computations, are interpolated as a weighted average of \\textit{k} nearest vertices belonging to the representative fibres in MNI space \\cite{Khatami2017BundleMap}. An example of the joint parametrization, produced by BundleMAP for the left corticospinal tract can be seen on Figure \\ref{fig:bundlemap-parametrisation-results}.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=14cm,height=14cm,keepaspectratio]{thesis_radomskyi/images/bundlemap-parametrisation-results.jpg}\n\\caption{\\textbf{BundleMAP Joint Parametrization Results.} Image depicting results of joint parametrization of the left corticospinal tract, performed with BundleMAP. As can be seen, corresponding anatomical locations of the tract have matching colors, indicating correct parametrization \\cite{Khatami2017BundleMap}}\n\\label{fig:bundlemap-parametrisation-results}\n\\end{figure}\n\n\\subsubsection{Feature extraction}\nThe streamlines and respective vertex values, produced via manifold learning, are represented as a function of ISOMAP coordinate, but since white matter bundles are of different size and proportions across the subjects, the range of ISOMAP coordinate is also varying within the population. In order to achieve a universal correspondence between the tracts, originating from distinct diffusion images, ISOMAP coordinate is normalised to the $[0,1)$ range. This allows to perform the analysis of extracted metrics along the reciprocal parts of the bundles, independent from dissimilarities of their initial size and form. BundleMAP pipeline produces feature vectors by partitioning the whole coordinate range into $n$ equal bins and assigning them an average of computed metrics values belonging to the corresponding segment of the tract.\n\n\\subsection{CoBundleMAP overview}\nAs mentioned before, CoBundleMAP is based on the same principles as the BundleMAP, but contains several important modifications that allow to considerably improve parameterization results. The most important changes are outlined in the corresponding source \\cite{Khatami2019CoBundleMap}, in this subsection a short overview is given based on original paper and personal experience with the pipeline.\n\n\\subsubsection{Hemisphere correspondence}\nOne of the substantial differences of between CoBundleMAP and previous approach is computation of inter-hemisphere correlations between corresponding white matter bundles of individual subjects. This allows to achieve additional coherence between left and right parts of the same tract. This allows to significantly improve joint parametrization and observe additional asymmetries, leading to deeper insights about tissue structure and affected white matter bundles. To achieve this, CoBundleMAP computes registration of the points in the left tract to the corresponding points of the right tract by treating the vertices of the streamlines as point clouds and applying an iterative closest point approach \\cite{Khatami2019CoBundleMap}. Consequently, the manifold learning is performed using streamlines from both hemispheres, producing an idealistic white matter bundle representation, expressing left and right tracts together. This is different from the approach used by BundleMAP, where each produced manifold was a manifestation of either right or left tract.\n\n\\subsubsection{Bundle parameterization}\nAnother prominent improvement of the new pipeline is the way how bundle processing and manifold learning are performed. CoBundleMAP is able to produce two-dimensional parameterization by setting the dimensionality of ISOMAP output. This allows to investigate changes of extracted diffusion parameters along two axis, distinguishing even more specific correlations. CoBundleMAP additionally improves the\nmechanism of ISOMAP coordinate normalization. Instead of directly re-scaling produced result, the ranges of produced ISOMAP coordinates are first divided into discrete sections. Within these sections, number of contributing vertices is computed and compared against a predefined threshold, thus eliminating the sections that do not have enough support. This approach essentially trims the bundle ends, which tend to contain abnormally lower averaged metric values due to low sample count.\n\n\n%\\label{ch:background}\n\n\\end{document}", "meta": {"hexsha": "c400193d622686a430310283dba5bcd83cacaefd", "size": 26849, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis_radomskyi/Background.tex", "max_stars_repo_name": "pelmeshk0/cookiecutter-latex-thesis", "max_stars_repo_head_hexsha": "9a7a1c90dd0583319709a6937b9285643fb6b009", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis_radomskyi/Background.tex", "max_issues_repo_name": "pelmeshk0/cookiecutter-latex-thesis", "max_issues_repo_head_hexsha": "9a7a1c90dd0583319709a6937b9285643fb6b009", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis_radomskyi/Background.tex", "max_forks_repo_name": "pelmeshk0/cookiecutter-latex-thesis", "max_forks_repo_head_hexsha": "9a7a1c90dd0583319709a6937b9285643fb6b009", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 186.4513888889, "max_line_length": 1975, "alphanum_fraction": 0.8106074714, "num_tokens": 5507, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.40254747311096145}}
{"text": "%###############################################################\n%\\section{Theory of Globally Controlled Polyomino Assembly}\\label{sec:Theory}\n\\section{Theory: Polyomino Assembly by Global Control}\\label{sec:Theory}\n%###############################################################\n\nThis section explains how to design factories that build arbitrary-shaped 2D polyominoes.\n We first assign species to individual tiles of the polyomino, second discover a build path, and finally build an assembly line of factory components that each add one tile to a partially assembled polyomino and pass the polyomino to the next component.\n\n\n\n\\subsection{Model}\\label{subsec:model}\nAssume the following rules:\n%\\begin{enumerate}\n1.) A planar  grid \\emph{workspace} $W$ is filled with a number of unit-square particles (each occupying one cell of the grid)  and some fixed unit-square blocks.  Each unit square in the workspace is either  \\emph{free}, which a particle may occupy or \\emph{obstacle} which a particle may not occupy.  Each square in the grid can be referenced by its Cartesian coordinates $\\bm{x}=(x,y)$.\n2.) All particles are commanded in unison: the valid commands are  ``Go Up\" ($u$), ``Go Right\" ($r$), ``Go Down\" ($d$), or ``Go Left\" ($l$).  \n3.) Particles all move until they  hit an obstacle, hit a stationary particle, or share an edge with a compatible particle.\n\t%\\begin{enumerate}\n%\t\t\\item hit an obstacle \n%\t\t\\item hit a stationary particle\n%\t\t\\item share an edge with a compatible particle\n%\t\\end{enumerate}\nIf a particle shares an edge with a compatible particle the two particles bond and from then on move as a unit.\nThis letter uses \\emph{cycles} of movement commands in the order $\\langle r,d,l,u \\rangle$. We assume the area of $W$ is finite and issue each command long enough for the particles to reach their maximum extent.\n%\\end{enumerate}\n\n\n%###############################################################\n\\subsection{Arbitrary 2D shapes require two particle species}\\label{subsec:RobotSpecies}\n%###############################################################\nPolyominoes have \\emph{four-point connectivity}: a 4-connected square is a neighbor to every square that shares an edge with it.\n\n\n\\begin{lemma}\n  Any polyomino can be constructed using just two species\n  \\end{lemma}\n\\begin{proof} \nLabel a grid with an alternating pattern like a checkerboard.  Any desired polyomino can be constructed on this checkerboard, and all joints are between dissimilar species.\n  An example shape is shown in Fig.~\\ref{fig:Grid}. Red and blue colors are used to indicate particles of different species.\n  \\end{proof}\n\n   \\begin{figure}\n   \\centering\n   \\vspace{0.2em}\n\\begin{overpic}[width =.8\\columnwidth]{Grid2.pdf}\n\\end{overpic}\n\\caption{\\label{fig:Grid}Any polyomino can be constructed with two compatible robot species, shown here with red and blue tiles.  \n}\n\\end{figure}\n\n  \n  The sufficiency of two species to construct any shape gives many options for implementation.  The two species could correspond to any gendered connection, \nincluding ionic charge, magnetic polarity, or hook-and-loop type fasteners. Large populations of these two species can then be stored in separate hoppers and, like two-part epoxy,  only assemble when dissimilar particles come in contact.\n\n\n\n\n%###############################################################\n\\subsection{Complexity Handled in This Letter}\\label{sec:ComplexityHandled}\n%###############################################################\n\n2D part geometries vary in difficulty.  Fig.~\\ref{fig:IncreasingDifficulty} shows parts with increasing  complexity. \n\n   \\begin{figure}\n   \\centering\n\\begin{overpic}[width =\\columnwidth]{IncreasingDifficulty3.pdf}\n\\end{overpic}\\vspace{-2em}\n\\caption{\\label{fig:IncreasingDifficulty}Polyomino parts. Assembly difficulty increases from left to right.\n}\n\\end{figure} \nLabel the first particle in the assembly process the \\emph{seed particle}. \n Part 1 is shaped as a `\\#' symbol.  Though it has an interior hole, any of the 16 particles could serve as the seed particle, and the shape could be constructed around it.  The second shape is a spiral, and must be constructed from the inside-out.  If the outer spiral was completed first, there would be no path to add particles to finish the interior because added particles would have to slide past compatible particles.  Increasing the number of species would not solve this problem, because there is a narrow passage through the spiral that forces incoming parts to slide past the edges of all the bonded particles.\nThe third shape contains a loop, and the interior must be finished before the loop is closed.\nShape 4 is the combination of a left-handed and a right-handed spiral.\nAdding one particle at a time in 2D cannot assemble this part, because each spiral must be constructed from the inside-out.  \n Instead, this part must be divided into sub-assemblies that are each constructed, and then combined.\n Shape 5 contains compound overhangs, and may be impossible to construct with additive 2D manufacturing using only two species.\n The algorithms in this letter detect if the desired shape can be constructed one particle at a time.  \n If so, a build order is provided, and a factory layout is designed.\n\n\n% A polyomino is said to be \\emph{column convex} if each column has no holes. Similarly, a polyomino is said to be row convex if each row has no holes. A polyomino is said to be \\emph{convex} if it is row and column convex.\n%\n%\\begin{lemma}\\label{lemma:convexonjectsCanbeConstructedAdditively}\n%Any convex polyomino can be constructed by adding one particle at a time\n%\\end{lemma}\n%\\begin{proof}\n%Select any pixel as the \\emph{seed block}, or root node.  Perform a breadth-first search starting at the seed block, labelling each block in the order they are expanded.  Constructing the shape according to the ordering ensures that the polyomino is convex at every step of construction.\n%\\end{proof}\n\n%The proof of \\ref{lemma:convexonjectsCanbeConstructedAdditively} assumes the existence of fixtures for assembly.\n%\\todo{describe fixtures for adding one particle at a time}\n\n%Some non-convex polynominos cannot be constructed one particle at a time, as illustrated in Fig. ~\\ref{fig:IncreasingDifficulty}.    For instance, a polynomino consisting of a clockwise and a counterclockwise square spiral, joined at the ends with a gap of one unit between the spirals must be constructed by first assembling each spiral, and then combining the sub assemblies.\n\n\n\n\n%###############################################################\n\\subsection{Discovering a Build Path}\n%###############################################################\n\nGiven a polyomino, Alg.~\\ref{alg:FindBuildPath} determines if the polyomino can be built by adding one component at a time.\n The  problem of determining a build order is difficult because there are $O(n!)$ possible build orders, and many of them may  violate the constraints given in Section \\ref{subsec:model}.  \n Each new tile must have a straight-line path to its goal position in the polyomino that does not collide with any other tile, does not slide past an opposite specie tile, and terminates in a mating configuration with an opposite specie tile.\nHowever, as in many robotics problems, the inverse problem of deconstruction is easier than the forward problem of construction.  \n\n\\begin{algorithm}\n\\newcommand\\algotext[1]{\\end{algorithmic}#1\\begin{algorithmic}[1]}\n%\\begin{algorithmic}[1]\n%\\scriptsize \n\\caption{\\sc {FindBuildPath}($\\mathbf{P})$   \\label{alg:FindBuildPath}}\n$\\mathbf{P}$ is the $x,y$ coordinates of a 4-connected polyomino. % that has at least a 1-tile empty border.\nReturns $ \\mathbf{C} $, $ \\mathbf{c} $ and $\\mathbf{m}$ where $ \\mathbf{C} $ contains sequence of polyomino coordinates, $ \\mathbf{c} $ is a vector of color labels, and $\\mathbf{m}$ is a vector of directions for assembly.\n\\begin{algorithmic}[1]\n\n\\State\\hbox{$ \\mathbf{c}\\leftarrow${\\sc{LabelColor}}($\\mathbf{P}$)}\n\\State $\\{\\mathbf{C},\\mathbf{m} \\}= ${\\sc {Decompose}}$(\\mathbf{P},\\mathbf{c})$\n\\State \\Return $\\{ \\mathbf{C},\\mathbf{c}, \\mathbf{m} \\} $ \n\\end{algorithmic}\n\\end{algorithm} \n\n   \\begin{figure}\n   \\centering\n\\begin{overpic}[width =\\columnwidth]{DeconstructionOrderMattersSlide.pdf}\n\\end{overpic}\\vspace{-2em}\n\\caption{\\label{fig:DeconstructionOrderMatters} Deconstruction order matters if loops are present.  Loops occur when the 8-connected freespace has more than one connected component.  In the top row the green tile is removed first, resulting in a polyomino that cannot be decomposed. However, if the bottom right tile is removed first, deconstruction is possible.\n}\n\\end{figure} \n\nAlg.~\\ref{alg:FindBuildPath}  first assigns each tile in the polyomino a color, then calls the recursive function {\\sc {Decompose}}, which returns either a build order of polyomino coordinates and the directions to build, or an empty list if the part cannot be constructed.  \n{\\sc {Decompose}} starts by calling the function {\\sc {Erode}}.  {\\sc {Erode}} first counts the number of components in the 8-connected freespace. An 8-connected square is a neighbor to every square that shares an edge or vertex with it. If there is more than one connected component, the polyomino contains loops.  \n {\\sc {Erode}} maintains an array of the remaining tiles in the polyomino $\\mathbf{R}$. \n In the inner \\textit{for loop} at line  \\ref{alg:line:forloopTotryremovinEachTileERODE}, a temporary array $\\mathbf{T}$ is generated that contains all but the $j$th tile in $\\mathbf{R}$ sorted by the number of neighbors so a tile with one neighbor is checked before tiles with two or three.\nThis \\textit{for loop} simply checks (1) if the $j$th tile can be removed along a straight-line path without  colliding with any other particle or sliding past an opposite specie tile in line \\ref{alg:line:checkpathtileERODE},  (2) that its removal does not fragment the remaining polyomino into more than one piece in line \\ref{alg:line:NumConnectedCompERODE}, and (3) that its removal does not break a loop in line \\ref{alg:line:Num8ConnectedCompERODE}. \nIf no loops are present, this algorithm requires at most  $n/2 (1 + n)$ iterations, because there are $n$ particles to remove, and each iteration considers one less particle than the previous iteration.\n\nPolyominoes with loops require care, because decomposing them in the wrong order can make disassembly impossible, as shown in Fig.~\\ref{fig:DeconstructionOrderMatters}.\nIf loops exist then  {\\sc {Erode}} may return only a partial decomposition, so {\\sc {Decompose}} must then try every possible break point and recursively call {\\sc {Decompose}} until either a solution is found, or all possible decomposition orders have been tested.  The worst-case number of function calls of  {\\sc {Decompose}}  are proportional to the factorial of the number of loops, $O( |\\text{\\sc 8-ConnComp}(\\neg\\mathbf{P})| !)$. Though large, this is much less than $O(n!)$.\n\n\\begin{algorithm}\n\\newcommand\\algotext[1]{\\end{algorithmic}#1\\begin{algorithmic}[1]}\n%\\scriptsize \n\\caption{\\sc {Erode}($\\mathbf{P},\\mathbf{c})$   \\label{alg:Erode}}\n$\\mathbf{P}$ is the $x,y$ coordinates of a 4-connected polyomino  and $ \\mathbf{c} $ is a vector of color labels.\nReturns $ \\mathbf{R} $, $ \\mathbf{C} $, $\\mathbf{m}$, and $\\mathbf{\\ell}$ where $ \\mathbf{R} $  is a list of coordinates of the remaining polyomino, $ \\mathbf{C} $ contains sequence of tile coordinates that were removed,   $\\mathbf{m}$ is a vector of directions for assembly, and $\\mathbf{\\ell}$ if loops were encountered. $\\mathbf{d} \\gets\\{r,d,l,u\\}$\n\\begin{algorithmic}[1]\n%\\State\\hbox{$ \\mathbf{c}\\leftarrow${\\sc{LabelColor}}($\\mathbf{P}$)}\n%\\State $ \\{ \\mathbf{R},\\mathbf{C}, \\mathbf{m}, \\ell \\} \\gets ${\\sc {Erode}}$(\\mathbf{P},\\mathbf{c})$\n\\State\\hbox{$\\mathbf{C} \\leftarrow \\{\\}, \\mathbf{m} \\leftarrow \\{\\}, \\mathbf{\\ell} \\gets \\textrm{\\sc False},  \\mathbf{R}\\leftarrow \\mathbf{P}$}\n\\State $w \\gets |\\text{\\sc 8-ConnComp}(\\neg\\mathbf{R})|$\n\n\\While{$1 <  |\\mathbf{R}|  $}\n\\State  \\emph{successRemove} $\\gets$ {\\sc False}\n\\State\\hbox{$ \\mathbf{R}\\leftarrow${\\sc{Sort}}($\\mathbf{R}$)} \\Comment{sort by number of neighbors}\n\\For{$j\\leftarrow 1, j \\le  |\\mathbf{R}| $}\n\\State $\\mathbf{p} \\gets \\mathbf{R}_j,  \\mathbf{T} \\gets  \\mathbf{R}  \\backslash   \\mathbf{R}_j$\n\n\\For{$ k \\leftarrow 1, k \\le  4$   \\label{alg:line:forloopTotryremovinEachTileERODE} }\n\\If{{\\sc CheckPathTile}($\\mathbf{T},\\mathbf{p}, \\mathbf{d}_k, \\mathbf{c}$) \\label{alg:line:checkpathtileERODE} \\textbf{and}\n\\\\ \\textbf{~~~~~~~~~~~~~~}\n$1 = |\\text{\\sc 4-ConnComp}(\\mathbf{T})|$  \\label{alg:line:NumConnectedCompERODE}}\n\\If{$w = |\\text{\\sc 8-ConnComp}(\\neg\\mathbf{T})|$  \\label{alg:line:Num8ConnectedCompERODE}}\n\\State $ \\mathbf{R}\\leftarrow   \\mathbf{T}$, \\emph{successRemove} $\\gets$ {\\sc True}\n\\State  $\\mathbf{C}_{ 1+|\\mathbf{R}|} \\gets \\mathbf{p},  \\mathbf{m}_{ |\\mathbf{R}|}  \\gets \\mathbf{d}_k$\n\\Else { $  \\mathbf{\\ell} \\gets \\textrm{\\sc True}$}\n\\EndIf\n\\State \\textbf{break}\n\\EndIf\n\\EndFor\n\\EndFor\n\\If {  \\emph{successRemove} $=$ {\\sc False}}\n\\State  \\hbox{$\\mathbf{C} \\leftarrow \\{\\}, \\mathbf{m} \\leftarrow \\{\\}$}\n\\State \\textbf{break}\n\\EndIf\n\\EndWhile \n\\If {$ |\\mathbf{R}| = 1$}\n\\State  $\\mathbf{C}_{ 1} \\gets \\mathbf{R}_1 $\n\\EndIf\n\\State \\Return $\\{ \\mathbf{R},\\mathbf{C}, \\mathbf{m}, \\ell \\}$ \n\\end{algorithmic}\n\\end{algorithm} \n\n\n\n\n\n\n\n\n\\vspace{10em}\n\\begin{algorithm}\n\\newcommand\\algotext[1]{\\end{algorithmic}#1\\begin{algorithmic}[1]}\n%\\scriptsize \n\\caption{\\sc {Decompose}($\\mathbf{P},\\mathbf{c})$   \\label{alg:Decompose}}\n$\\mathbf{P}$ is the $x,y$ coordinates of a 4-connected polyomino and $ \\mathbf{c} $ is a vector of color labels.\nReturns $ \\mathbf{C} $ and $\\mathbf{m}$ where $ \\mathbf{C} $ contains sequence of polyomino coordinates and $\\mathbf{m}$ is a vector of directions for assembly. $\\mathbf{d} \\gets\\{u,d,l,r\\}$\n\\begin{algorithmic}[1]\n\\State $ \\{ \\mathbf{R},\\mathbf{C}, \\mathbf{m}, \\ell \\} \\gets ${\\sc {Erode}}$(\\mathbf{P},\\mathbf{c})$\n\\If {$|  \\mathbf{R} | = 0 \\textbf{ or } \\neg \\ell$}\n\\State \\Return $\\{ \\mathbf{C},\\mathbf{m} \\}$ \n\\EndIf\n\\For{$j\\leftarrow 1, j \\le  |\\mathbf{R}| $}\n\\State $\\mathbf{p} \\gets \\mathbf{R}_j,  \\mathbf{T} \\gets  \\mathbf{R}  \\backslash   \\mathbf{R}_j$\n\\For{$ k \\leftarrow 1, k \\le  4$   \\label{alg:line:forloopTotryremovinEachTileDecompose} }\n\\If{{ ( \\sc CheckPathTile}($\\mathbf{T},\\mathbf{p}, \\mathbf{d}_k, \\mathbf{c}$) \\label{alg:line:checkpathtileDecompose} \\textbf{and }\n\\\\ \\textbf{~~~~~~~~~~~~ }\n$1 = |\\text{\\sc 4-ConnComp}(\\mathbf{T})|$)  \\label{alg:line:NumConnectedCompDecompose}}\n\\State $\\{\\mathbf{C2},\\mathbf{m2} \\}\\gets ${\\sc {Decompose}}$(\\mathbf{T},\\mathbf{c})$\n\\If {$\\mathbf{C2}  \\ne \\{\\}$}\n%\\State  $\\mathbf{C}_{ 1+|\\mathbf{R}|} \\gets \\mathbf{p},  \\mathbf{m}_{ |\\mathbf{R}|}  \\gets \\mathbf{d}_k$\n\\State $\\mathbf{C}_{1:|\\mathbf{C2}|+1} \\gets \\{\\mathbf{C2},\\mathbf{p}\\}$\n\\State $ \\mathbf{m}_{1:|\\mathbf{m2}|+1} \\gets \\{\\mathbf{m2},\\mathbf{d}_k\\}$\n\\State \\Return $\\{ \\mathbf{C}, \\mathbf{m} \\}$ \n\\EndIf\n\\State \\textbf{break}\n\\EndIf\n%\\EndIf\n\\EndFor\n\\EndFor\n%\\State $\\mathbf{C} \\gets \\{\\}, \\mathbf{m} \\gets \\{\\}$\n\\State \\Return $\\{ \\mathbf{C}\\gets \\{\\}, \\mathbf{m}\\gets \\{\\} \\}$ \n\\end{algorithmic}\n\\end{algorithm} \n  \n%###############################################################\n%\\subsection{Assembling Tiles}\n%###############################################################\n\n\n%###############################################################\n\\subsection{Hopper Construction}\\label{subsec:HopperConstruction}\n%###############################################################\nTwo-part adhesives react when components mix.  Placing components in separate containers prevents mixing.  Similarly, storing many particles of a single specie in separate containers allows controlled mixing.\n%WIKI: harden by mixing two or more components which chemically react.\n\nWe can design \\emph{part hoppers}, containers that store similarly labelled particles.  These particles will not bond with each other.  The hopper shown in Fig.~\\ref{fig:HopperCW} releases one particle every cycle. Delay blocks are used to ensure the $n$th part hopper does not start releasing particles until cycle $n$. For ease of exposition, this letter has a unique hopper for each tile position. This enables precise positioning of different materials, but a particle logic system could use just two hoppers, similar to our particle logic systems in [9].\n\n   \\begin{figure}\n  %  \\vspace{-1em}\n   \\centering\n\\begin{overpic}[width =\\columnwidth]{hopperV4.pdf}\n\\end{overpic}\\\\ \\vspace{-1em}\n\\caption{\\label{fig:HopperCW}Hopper with five delays. The hopper is filled with similarly-labelled robots that will not combine.  Every clockwise command cycle releases one robot from the hopper.  %\\textcolor{red}{replace with new hopper design}\n}\n\\end{figure}\n\n\n\\begin{figure}\n   \\centering\n\\begin{overpic}[width =\\columnwidth]{24tilefactory.pdf}\n\\end{overpic}\n\\begin{overpic}[width =\\columnwidth]{Spiraltilefactory.pdf}\n\\end{overpic}\\\\ \\vspace{-1em}\n\\caption{\\label{fig:24Tilefactory}A twenty-four tile factory, step 82 for a `\\#' shape and a twenty-one tile factory, step 66 for a spiral (zoom in for details in this vector graphic).\n}\n\\end{figure}\n\n\n\n%###############################################################\n\\subsection{Part Assembly Jigs}\\label{subsec:PartAssemblyJigs}\n%###############################################################\n\nAssembly is an iterative procedure.  \nA factory layout is generated by  {\\sc{BuildFactory}}($\\mathbf{P}, n_c$), described in Alg.~\\ref{alg:BuildFactory}. This function takes a 2D polyomino $\\mathbf{P}$ and, if $\\mathbf{P}$ has a valid build path, designs an obstacle layout to generate $n_c$ copies of the polyomino. A polyomino is composed of $|\\mathbf{P}| = n$ tiles.  \n\nFor each tile, the function \n {\\sc{FactoryAddTile}} $(n_c,\\mathbf{b}, m,C, c,w)$\n  described in  Alg.~\\ref{alg:FactoryAddTile}\nis called to generate an obstacle configuration $\\mathbf{A}$.\n$\\mathbf{A}$  forms a hopper that releases a particle each iteration and a chamber that temporarily holds the partially-assembled polyomino $\\mathbf{b}$ and guides the new particle $C$ to the correct mating position. A 24-tile factory is shown in  Fig.~\\ref{fig:24Tilefactory}.\n\n\n%\\todo{Sheryl, add the algorithmic environment for Build Factory}\n\\begin{algorithm} \n\\newcommand\\algotext[1]{\\end{algorithmic}#1\\begin{algorithmic}[1]}\n%\\scriptsize\n\\caption{ \\sc{BuildFactory}($\\mathbf{P}, n_c$)\\label{alg:BuildFactory}}\n$\\mathbf{P}$ is the $x,y$ coordinates of a 4-connected polyomino.  $n_c$ is the number of parts desired. \nReturns a two dimensional array $ \\mathbf{F} $ containing the factory obstacles and filled hoppers.\n\\begin{algorithmic}[1]\n\\State$\\mathbf{F} \\leftarrow \\{\\}$ \\Comment{the factory obstacle array} \n\n\\State \\{$\\mathbf{C},\\mathbf{c}, \\mathbf{m}$\\} $  \\leftarrow$ {\\sc{FindBuildPath}}($\\mathbf{P}$)\n \\If{$ \\{\\} = \\mathbf{m}$}\n \\State \\Return  $ \\mathbf{F} $\n \\EndIf \n \\State$\\{ \\mathbf{A}, \\mathbf{b} \\}\\leftarrow${\\sc{FactoryFirstTile}}$(n_c, \\mathbf{c}_i,w)$\n \\For{$i\\leftarrow 2, i \\le  |\\mathbf{c}| )$}\n \\State$\\{\\mathbf{A},\\mathbf{b}\\}\\leftarrow${\\sc{FactoryAddTile}}$(n_c,\\mathbf{b}, \\mathbf{m}_{i-1},\\mathbf{C}_i, \\mathbf{c}_i,w)$\n \\State$ \\mathbf{F} \\leftarrow${\\sc{ConcatFactories}}$(\\mathbf{F},\\mathbf{A})$\n\\EndFor\n\\State \\Return  $ \\mathbf{F} $\n%\\State{\\sc{DisplayFactory}}($factoryLayout$)\n\\end{algorithmic}\n\\end{algorithm} \n \n \n \n\n \n \n\\begin{algorithm} \n\\newcommand\\algotext[1]{\\end{algorithmic}#1\\begin{algorithmic}[1]}\n%\\scriptsize\n\\caption{\\sc {FactoryAddTile}$(n_c,\\mathbf{b}, m,C, c,w)$ \\label{alg:FactoryAddTile}}\n\\begin{algorithmic}[1]\n\\State$\n\\{ \\mathbf{hopper}\\}\\leftarrow${\\sc{Hopper}}$(c,n_c,w)$\n\\If{ $m = d \\textbf{ and } \\left(     C_x  \\le \\max \\mathbf{b}_x   \n                         \\textbf{ or }  C_y     < \\min \\mathbf{b}_y \\right)  }$\n    \n\\State$\\{\\mathbf{A},\\mathbf{b}\\}\\leftarrow${\\sc{downdir}}$(\\mathbf{hopper},\\mathbf{b},\\mathbf{C})$\n\n\\ElsIf{ $m = l \\textbf{ and} \\left(     C_y  \\le \\max \\mathbf{b}_y   \n                         \\textbf{ or }  C_x     > \\max \\mathbf{b}_x \\right)  }$\n    \n\\State$\\{\\mathbf{A},\\mathbf{b}\\}\\leftarrow${\\sc{leftdir}}$(\\mathbf{hopper},\\mathbf{b},\\mathbf{C})$\n\\ElsIf{ $m = l \\textbf{ and} \\left(     C_x  \\ge \\max \\mathbf{b}_x   \n                         \\textbf{ or }  C_y     > \\max \\mathbf{b}_y \\right)  }$\n    \n\\State$\\{\\mathbf{A},\\mathbf{b}\\}\\leftarrow${\\sc{updir}}$(\\mathbf{hopper},\\mathbf{b},\\mathbf{C})$\n\\ElsIf{ $m = r \\textbf{ and } \\left(     C_y     \\ge \\min \\mathbf{b}_y   \n                       \\textbf{ or }  C_x  < \\min \\mathbf{b}_x   \\right)  }$\n\\State$\\{\\mathbf{A},\\mathbf{b}\\}\\leftarrow${\\sc{rightdir}}$(\\mathbf{hopper},\\mathbf{b},\\mathbf{C})$\n\n\n\n\\EndIf\n\n\\State \\Return $\\{ \\mathbf{A}, \\mathbf{b} \\}$ \n\n\\end{algorithmic}\n\\end{algorithm}\n \n \n \n \n \n \n\n", "meta": {"hexsha": "3d2a57f1d16d6e41b3cf61c67048338a2597a559", "size": 20802, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assembly/03Theory.tex", "max_stars_repo_name": "aabecker/particleComputation", "max_stars_repo_head_hexsha": "74ebf02f14a3952614fadd99a6cfa5429db25755", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assembly/03Theory.tex", "max_issues_repo_name": "aabecker/particleComputation", "max_issues_repo_head_hexsha": "74ebf02f14a3952614fadd99a6cfa5429db25755", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assembly/03Theory.tex", "max_forks_repo_name": "aabecker/particleComputation", "max_forks_repo_head_hexsha": "74ebf02f14a3952614fadd99a6cfa5429db25755", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-10-22T07:29:27.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-07T08:58:44.000Z", "avg_line_length": 60.8245614035, "max_line_length": 621, "alphanum_fraction": 0.6869531776, "num_tokens": 6177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.40254459074480453}}
{"text": "\\section{Introduction}\n\nOpenMath~\\cite {BusCapCar:oms04} is a semantic representation format of mathematical objects and formulae. \nIn a nutshell, OpenMath standardizes six basic object types (symbols, variables, numbers, strings, and foreign objects), three ways of building complex objects: (function) application, binding, and management facilities like structure sharing and error reporting. \nThe OpenMath object model underlies Content MathML~\\cite{CarlisleEd:MathML3:on}, making it well-integrated with MathML presentation. \n\nThere are several encodings of OpenMath Objects, most notably the XML and Binary encodings. \nIn this paper we propose another one based on JSON, a lightweight data-interchange format that used heavily in the Web Applications area.\n\nJSON~\\cite{JSON:web}, short for \\textbf{J}ava\\textbf{S}cript \\textbf{O}bject \\textbf{N}otation, is a lightweight data-interchange format.\nWhile being a subset of JavaScript, it is defined independently. \nJSON can represent both primitive types and composite types.\n\nPrimitive JSON data types are strings (e.g. \\lstinline{\"Hello world\"}), Numbers (e.g. \\lstinline{42} or \\lstinline{3.14159265}), Booleans (\\lstinline{true} and \\lstinline{false}) and \\lstinline{null}. \nComposite JSON types are either (non-homogeneous) arrays (e.g. \\lstinline{[1, \"two\", false]}) or key-value pairs called objects (e.g. \\lstinline|{\"foo\": \"bar\", \"answer\": 42}|).\n\nConstructs corresponding to JSON objects are found in most programming languages. \nFurthermore, the syntax is very simple; hence many languages have built-in facilities for translating their existing data structures to and from JSON. \nThe use for an OpenMath JSON encoding is clear: It would enable easy use of OpenMath across many languages.\n\nIn the next Section we survey two existing OpenMath JSON encodings. \nSection~\\ref{sec:encoding} proposes a new encoding that combines the advantages and alleviates their disadvantages. \nWe give a thorough specification of the encoding, present a JSON schema implemented in TypeScript, and provide a web service that validates JSON-encoded OpenMath and transforms OpenMath objects between XML and JSON encodings. \nSection~\\ref{sec:concl} concludes the paper.\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"paper\"\n%%% End:\n\n%  LocalWords:  standardizes textbf textbf cript textbf bject otation sec:concl\n", "meta": {"hexsha": "342f80864214fa6cf9a22b5267c164555f239607", "size": 2364, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/paper/intro.tex", "max_stars_repo_name": "nathancarter/OpenMath-JSON", "max_stars_repo_head_hexsha": "33235846c11dccb56674626693511dc6eeb79934", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-03-20T19:43:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-31T18:28:48.000Z", "max_issues_repo_path": "doc/paper/intro.tex", "max_issues_repo_name": "nathancarter/OpenMath-JSON", "max_issues_repo_head_hexsha": "33235846c11dccb56674626693511dc6eeb79934", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-07-05T22:18:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-26T18:35:08.000Z", "max_forks_repo_path": "doc/paper/intro.tex", "max_forks_repo_name": "nathancarter/OpenMath-JSON", "max_forks_repo_head_hexsha": "33235846c11dccb56674626693511dc6eeb79934", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-07-08T12:45:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-01T20:17:50.000Z", "avg_line_length": 73.875, "max_line_length": 264, "alphanum_fraction": 0.7889170897, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.611381973294151, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.40254458664692}}
{"text": "\\section{Introduction}\n\nCommunity detection is an essential task for cyberspace mining, which has been successfully employed to explore users’ resemblance for retrieval/recommendation enhancement and user behavior analysis. Taking social media and e-commerce as examples, the complex, and often heterogeneous, relations among users and other objects, e.g., products, reviews, and messages, can be encapsulated as bipartite graphs, and the topology can help to synthesize and represent users with a coarser and broader view.\n\nWhile a graph is well-connected, conventional methods, e.g., modularity-based approach \\cite{newman2004fast}, spectral approach \\cite{nascimento2011spectral}, dynamic approach \\cite{peixoto2017modelling} and deep learning approach \\cite{chiang2019cluster}, are able to estimate the internal/external connectivity and generate high-quality communities directly on nodes \\cite{fortunato2016community}.\n \nFor sparse graphs, as mentioned in the Chapter \\ref{ch:intro}, to deal with the lack-of-connection problem, I propose  a novel research task – Cross-Graph Community Detection. The idea is based on the fact that an increasing number of small apps are utilizing the user identity information inherited from giant providers, i.e., users can easily login a large number of new apps by using Facebook and Google ID. In such ecosystem, the main large graph can provide critical information to enlighten the community detection on many small sparse graphs. Note that, in spit of the small sparse graphs can engage with a specific field, the main graph is quite comprehensive and noisy. As Figure \\ref{fig:c4_example} shows, not all the connections in Amazon (shopping graph) can be equally important for the two candidate app graphs. In the example, three mutual users are selected where $u_1$ and $u_2$ mainly share similar shopping interests on cosmetics and $u_1$ and $u_3$ mainly share similar shopping interests on food products in Amazon. Then, with deliberate propagation from main graph, in the Cosmetic graph, $u_1$ and $u_2$ have a better chance to be grouped together, while $u_1$ and $u_3$ are more likely to be assigned the same community ID in the Cooking graph. Therefore, the proposed model should be able to differentiate various kinds of information from the main graph for each candidate sparse graph to enhance its local community detection performance. \n\nAs another challenge, small sparse graphs often suffer from training data insufficiency, e.g., the limited connections in these graphs can hardly tell the community residency information. In this study, I employed a novel data augmentation approach - cross-graph pairwise learning. Given a candidate user and an associated user triplet, the proposed model can detection the community closeness superiority by leveraging main graph and the sparse graph simultaneously. Moreover, the proposed pairwise learning method can cope with the main graph heterogeneity issue and reduce noisy information by taking care of graph local structure. Theoretically, I can offer at most $\\mathcal{O}(N^{3})$ user triplets to learn graph community structure while conventional community detection methods by default can only be applied on $\\mathcal{O}(N)$ users  ($N$ is the number of users in the sparse graph).\n\nTherefore, I propose an innovative \\textit{Pairwise Cross-graph Community Detection} (PCCD) model for enhanced sparse graph user community detection. Specifically, given user $u_i$ and its associated triplet $\\langle u_{i},u_{j},u_{k}\\rangle$, I aim to predict their pairwise community relationship, e.g., compared with user $u_{k}$, user $u_{j}$ should have closer, similar or farther community closeness to user $u_i$. \n", "meta": {"hexsha": "075e3fbfba910d2a170edaf2ea1af9316eae732b", "size": 3714, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter4/chapter4.1.tex", "max_stars_repo_name": "RoyZhengGao/thesis", "max_stars_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter4/chapter4.1.tex", "max_issues_repo_name": "RoyZhengGao/thesis", "max_issues_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter4/chapter4.1.tex", "max_forks_repo_name": "RoyZhengGao/thesis", "max_forks_repo_head_hexsha": "b73b473d5b8a5d948080420edeb899c60d88c9e9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 309.5, "max_line_length": 1467, "alphanum_fraction": 0.8069466882, "num_tokens": 777, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.40254458254903547}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{indentfirst}\n\n\\title{CS131 B1: HW 3}\n\\author{Duy Nguyen}\n\\date{2 October 2016}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{Question 1}\n\\subsection*{a.}\n\\begin{tabular}{l|l}\n    The program has bugs or works correctly. & $B \\lor C$ \\\\\n    The program is bug-free or needs debugging. & $\\neg B \\lor N$ \\\\ \\hline\n    the program works correctly or needs debugging.&$C \\lor N$.\n\\end{tabular}\n\nThis argument is valid since it follows the valid argument form of \\textit{resolution}. \n\\subsection*{b.}\n\\begin{tabular}{l|l}\n    The error is in function A or B. & $A \\lor B$ \\\\ \\hline\n    I need to debug function A & $A$\n\\end{tabular}\n\nWe construct a truth table:\n\n\\begin{tabular}{cc|cc}\n    $A$&$B$&$A \\lor B$&$A$ \\\\ \\hline\n    T&T&T&T\\\\\n    T&F&T&T\\\\\n    \\textbf{F}&\\textbf{T}&\\textbf{T}&\\textbf{F}\\\\\n    F&F&F&F\n\\end{tabular}\n\nWe note that there is one case where a true premise leads to a false conclusion. Thus this argument is invalid. \n\n\\subsection*{c.}\n\\begin{tabular}{l}\n    All integers are rational numbers. \\\\\n    All rational numbers can be represented as $p/q$, \\\\\n    where\np and q are integers. \\\\ \n    There are no such p and q which satisfy $x=p/q$. \\\\ \\hline\n    x is irrational and x is not an integer.\n\\end{tabular}\n\n \n We have: ``all integers are rational numbers\" and ``all rational numbers can be represent as $p/q$\" are both true since this is the definition of rational number. So if the third premise ``there are no such p and q which satisfy $x=p/q$\" is true, then x is not an rational number. And since integers are subset of rational numbers, x is not an integer. Therefore, this argument is valid.\n \n \\subsection*{d.}\n \\begin{tabular}{l}\n     All the planets of the solar system orbit the Sun. \\\\\n     Pluto orbits the Sun. \\\\ \\hline\n     Pluto is a planet of\nthe solar system.\n \\end{tabular}\n\nBoth of the premises are true. However, the conclusion is false. Therefore, this is not a valid argument.\n\n\\section*{Question 2}\n\\subsection*{a. Every CS student knows Python and Java.}\n$\\forall x (C(x) \\rightarrow (P(x) \\land J(x)))$\n\n\\begin{tabular}{ll}\n    Where: & \\textbf{x} are all people. \\\\\n    & \\textbf{C(x)} are those who are a CS student. \\\\\n    & \\textbf{P(x)} is a person who knows Python.\\\\\n    & \\textbf{J(x)} is a person who knows Java.\n\\end{tabular}\n\n\\subsection*{b. Some CS students know C++ or C\\#.}\n$\\exists x (C(x) \\land (P(x) \\lor S(x))$\n\n\\begin{tabular}{ll}\n    Where: & \\textbf{x} are all people. \\\\\n    & \\textbf{C(x)} are those who are a CS student. \\\\\n    & \\textbf{P(x)} is a person who knows C++.\\\\\n    & \\textbf{S(x)} is a person who knows C\\#.\n\\end{tabular}\n\n\\subsection*{c. For every successful person there is someone even more successful, for every unhappy person there is someone more unhappy.}\n\n$\\forall x \\exists y P(x,y)$\n\n\\begin{tabular}{ll}\n    Where: & \\textbf{x} is a successful/unhappy person. \\\\\n    & \\textbf{P(x,y)} is where y is more successful/unhappy than x \n\\end{tabular}\n\n\\subsection*{d. If y=f(x) is a function, then for every x there exists only one y.}\n$ y = f(x) \\rightarrow \\forall x \\exists y $\n\n\\section*{Question 3}\n\\subsection*{2a.}\n$\\neg \\forall x (C(x) \\rightarrow (P(x) \\land J(x)))$\n\n$\\exists x \\neg (C(x) \\rightarrow (P(x) \\land J(x)))$\n\n$\\exists x (C(x) \\land \\neg (P(x) \\land J(x)))$\n\n$\\exists x (C(x) \\land (\\neg P(x) \\lor \\neg J(x)))$\n\nThere exists a person who is a CS student and does not know Python nor Java.\n\n\\subsection*{2b.}\n$\\neg \\exists x (C(x) \\land (P(x) \\lor S(x))$\n\n$\\forall x \\neg (C(x) \\land (P(x) \\lor S(x))$\n\n$\\forall x (\\neg C(x) \\lor \\neg (P(x) \\lor S(x))$\n\n$\\forall x (\\neg C(x) \\lor (\\neg P(x) \\land \\neg S(x))$\n\nFor all people, there is not a CS student or there is not a person who know both C++ and C\\#.\n\n\\end{document}\n", "meta": {"hexsha": "cfec5607ab73743c9fb5feb062683a6e0c53f97d", "size": 3792, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "unnatural_rubber/hw/CS131/hw3.tex", "max_stars_repo_name": "zuik/stuff", "max_stars_repo_head_hexsha": "4bae095f8a857c884b409356a61f56a49b768611", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "unnatural_rubber/hw/CS131/hw3.tex", "max_issues_repo_name": "zuik/stuff", "max_issues_repo_head_hexsha": "4bae095f8a857c884b409356a61f56a49b768611", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "unnatural_rubber/hw/CS131/hw3.tex", "max_forks_repo_name": "zuik/stuff", "max_forks_repo_head_hexsha": "4bae095f8a857c884b409356a61f56a49b768611", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6, "max_line_length": 388, "alphanum_fraction": 0.6547995781, "num_tokens": 1210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926666143434, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4025265401744347}}
{"text": "\\documentclass{subfile}\n\n\\begin{document}\n\t\\section{BuNO}\\label{sec:buno}\n\t\n\t\t\\begin{problem}[$2020$ Day $1$, problem $2$]\n\t\t\tLet $b_{1},\\ldots,b_{n}$ be non-negative integers and $a_{0},a_{1},\\ldots,a_{n}$ be real numbers such that $b_{1}+\\ldots+b_{n}=2$ and $a_{0}=a_{n}=0,|a_{i}-a_{i-1}|\\leq b_{i}$ for $1\\leq i\\leq n$. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\sum_{i=1}^{n}(a_{i}+a_{i-1})b_{i}\n\t\t\t\t\t\t& \\leq 2\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2018$, problem $3$]\n\t\t\tProve that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\left(\\dfrac{6}{5}\\right)^{\\sqrt{3}}\n\t\t\t\t\t\t& > \\left(\\dfrac{5}{4}\\right)^{\\sqrt{2}}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2016$, problem $3$]\n\t\t\tFor positive real numbers $a,b,c$ and $d$, prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\dfrac{a+\\sqrt{ab}+\\sqrt[3]{abc}+\\sqrt[4]{abcd}}{4}\n\t\t\t\t\t\t& \\leq \\sqrt[4]{a\\cdot\\dfrac{a+b}{2}\\cdot\\dfrac{a+b+c}{3}\\cdot\\dfrac{a+b+c+d}{4}}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2009$, problem $6$]\n\t\t\tLet $a_{1},\\ldots,a_{n},b_{1},\\ldots,b_{n}$ be arbitrarily taken real numbers and $c_{1},\\ldots,c_{n}$ be positive real numbers, then\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\left(\\sum_{i,j=1}^{n}\\dfrac{a_{i}a_{j}}{c_{i}+c_{j}}\\right)\\left(\\sum_{i,j=1}^{n}\\dfrac{b_{i}b_{j}}{c_{i}+c_{j}}\\right)\n\t\t\t\t\t\t& \\geq \\left(\\sum_{i,j=1}^{n}\\dfrac{a_{i}b_{j}}{c_{i}+c_{j}}\\right)^{2}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2008$, problem $3$]\n\t\t\tLet $n$ be a natural number and $a_{1},\\ldots,a_{n},b_{1},\\ldots,b_{n}$ be real positive numbers such that $0\\leq a_{1}\\leq\\ldots\\leq a_{n}\\leq\\pi$ and\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\left|\\sum_{i=1}^{n}b_{i}\\cos{ka_{i}}\\right|\n\t\t\t\t\t\t& < \\dfrac{1}{k}\n\t\t\t\t\\end{align*}\n\t\t\tfor all positive integer $k$. Prove that $b_{1}=\\ldots=b_{n}=0$.\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$2007$ Team Selection Test, problem $3$]\n\t\t\tLet $n\\geq2$ be a positive integer. Find the best constant $C(n)$ such that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\sum_{i=1}^{n}x_{i}\n\t\t\t\t\t\t& \\geq C(n)\\sum_{1\\leq j<i\\leq n}(2x_{i}x_{j}+\\sqrt{x_{i}x_{j}})\n\t\t\t\t\\end{align*}\n\t\t\tis true for all $x_i\\in(0,1)$ such that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t(1-x_{i})(1-x_{j})\n\t\t\t\t\t\t& \\geq \\dfrac{1}{4}\n\t\t\t\t\\end{align*}\n\t\t\tfor $1\\leq i<j\\leq n$.\n\t\t\\end{problem}\n\t\n\t\t\\begin{problem}[$1997$, problem $1$]\n\t\t\tLet $a,b,c$ be positive real numbers such that $abc=1$. Prove that\n\t\t\t\t\\begin{align*}\n\t\t\t\t\t\\dfrac{1}{1+b+c}+\\dfrac{1}{1+c+b}+\\dfrac{1}{1+a+b}\n\t\t\t\t\t\t& \\leq \\dfrac{1}{2+a}+\\dfrac{1}{2+b}+\\dfrac{1}{2+c}\n\t\t\t\t\\end{align*}\n\t\t\\end{problem}\n\\end{document}", "meta": {"hexsha": "38f138fd402d08061c93d50030e861445b329957", "size": 2489, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "buno.tex", "max_stars_repo_name": "ineq-tech/inequality", "max_stars_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-06T08:29:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-06T08:29:30.000Z", "max_issues_repo_path": "buno.tex", "max_issues_repo_name": "ineq-tech/inequality", "max_issues_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "buno.tex", "max_forks_repo_name": "ineq-tech/inequality", "max_forks_repo_head_hexsha": "ebf89351c843b6a7516e10e2ebf0d64e3f1f3f83", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.6029411765, "max_line_length": 210, "alphanum_fraction": 0.5729208517, "num_tokens": 1141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.40241258370348676}}
{"text": "\\section{Task 6}\n% Given a n-by-n tori and an n-dimensional hypercube decide things for node\n% count 4, 16, 64, 256\n\n% N   | tori n | cube k\n% 4       2        2\n% 16      4        4\n% 64      8        6\n% 256    16        8\n\\subsection{Task 6.a}\n% At what scale does the hypercube provide (strictly) higher bisection width than the torus?\n\nTable \\ref{tab:task6a1} shows the different dimensions of the two patterns for\nthe specified networks sizes, this is used to calculate the bisection widths\nwhich can be seen in Table \\ref{tab:task6a2}. We can see that at $N=64$ the\nhypercube provides a strictly greater bisection width.\n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{|r|r|r|}\n        \\hline\n        $N$ & Tori $n$ & Cube $k$ \\\\\\hline\n          4 &  2       & 2        \\\\\n         16 &  4       & 4        \\\\\n         64 &  8       & 6        \\\\\n        256 & 16       & 8        \\\\\\hline\n    \\end{tabular}\n    \\caption{The different variables needed for calculating the dimensions of\n        the two patterns.}\n    \\label{tab:task6a1}\n\\end{table}\n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{|l|l|l|}\n        \\hline\n        $N$     & Tori & HyperCube \\\\ \\hline\n        Formula & $2n$ & $2^{k-1}$ \\\\\n        4       &  4   &   2       \\\\\n        16      &  8   &   8       \\\\\n        64      & 16   &  32       \\\\\n        256     & 32   & 128       \\\\ \\hline\n    \\end{tabular}\n    \\caption{My caption}\n    \\label{tab:task6a2}\n\\end{table}\n\n\n\\subsection{Task 6.b}\n% Determine the network diameter and the switch degree for the scale at which the hypercube\n% provides a higher bisection width than the torus.\n\n% Scale: N=64.\n% n/k = 8/6\n% Network Diameter: 8/6\n% Switch degree: 4/6\n\nUsing the formulas from \\cite[slide 38]{l7Interconnect} for scale $N=64$ as\ncalculated in the previus sub task, we have a $8$-by-$8$ tori and a\n$6$-dimensional hypercube, so we have $n=8$ and $k=6$. This gives the tori a\nnetwork diameter of $8$ and the hypercube a network diameter of $6$. The switch\ndegree for the tori is $4$ regardless of the size of the tori, and for the\nhypercube it is $6$.\n\n\\subsection{Task 6.c}\n% What can you say about the relative merits of the two topologies?\n\\begin{itemize}\n    \\item[Hyper-cybe] The high bisection width allows for potential high\n    bandwidth through the many links, however this also comes with a high\n    switching degree, and for higher dimensions hyper-cubes, they layout of the\n    cube itself becomes highly complicated, which makes the hyper-cube a very\n    costly interconnection pattern.\n\n    \\item[Torus] A constant switching degree means that nodes can be added\n    without adding complexity to the rest of the system. The slower growing\n    bisection width means that potential bandwidth doesn't increase as fast as\n    with the hyper-cube.\n\\end{itemize}\n", "meta": {"hexsha": "20f38a50cb651e343c4af97b5d3cafc0051a6ee4", "size": 2816, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Assignment4/report/task6.tex", "max_stars_repo_name": "martinnj/PMPH2015", "max_stars_repo_head_hexsha": "2555ef889fb49e68485775a5ae7fd8b147623d70", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment4/report/task6.tex", "max_issues_repo_name": "martinnj/PMPH2015", "max_issues_repo_head_hexsha": "2555ef889fb49e68485775a5ae7fd8b147623d70", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment4/report/task6.tex", "max_forks_repo_name": "martinnj/PMPH2015", "max_forks_repo_head_hexsha": "2555ef889fb49e68485775a5ae7fd8b147623d70", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6455696203, "max_line_length": 92, "alphanum_fraction": 0.6321022727, "num_tokens": 866, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5195213070736461, "lm_q2_score": 0.7745833737577158, "lm_q1q2_score": 0.40241256677212306}}
{"text": "\\subsection{Type graphs}\n\\label{subsec:formalisations:groove_formalisation:type_graphs}\n\nIn GROOVE, type graphs are used to constrain the valid instance graphs within the grammar. From a type graph follows a set of valid instance graphs that can be used for verification.\n\n\\begin{defin}[Type graph]\n\\label{defin:formalisations:groove_formalisation:type_graphs:type_graph}\nA type graph is modeled as tuple $TG$:\n\\begin{equation}\n    TG = \\langle NT, ET, \\sqsubseteq, abs, \\mathrm{mult}, contains \\rangle\n\\end{equation}\nwith\n\\begin{itemize}\n    \\item $NT \\subseteq Lab_t \\cup Lab_{prim}$ is the set of nodes in the type graph. The nodes can consist of type labels (see \\cref{defin:formalisations:groove_formalisation:definitions:labels}) or primitive type labels (see \\cref{defin:formalisations:groove_formalisation:definitions:primitive_type_labels}).\n    \n    \\item $ET \\subseteq NT \\times (Lab_e \\cup Lab_f) \\times NT$ is the set of (directed) edges in the type graph, which is a set of triples containing the source and target node, as well as the edge label or flag label (see \\cref{defin:formalisations:groove_formalisation:definitions:labels}) used to identify the edge.\n    \n    \\item $\\sqsubseteq\\ \\subseteq NT \\times NT$ is the inheritance relation, the set of tuples of nodes between which an inheritance relation exists.\n    \n    \\item $abs \\subseteq NT$ is the (possibly empty) subset of nodes in the type graph which are considered abstract. An instance graph cannot instantiate abstract nodes.\n    \n    \\item $\\mathrm{mult}: ET \\Rightarrow \\mathbb{M} \\times \\mathbb{M}$ is the function which maps edges to their multiplicity pair. See \\cref{defin:formalisations:groove_formalisation:type_graphs:multiplicity_pair} for the definition.\n    \n    \\item $contains \\subseteq ET$ is the set of edges which identify an containment relation. \n\\end{itemize}\n\n\\isabellelref{type_graph}{GROOVE.Type_Graph}\n\\end{defin}\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\input{images/03_formalisations/03_groove_formalisation/type_graph_example.tikz}\n        \\caption{Type graph in GROOVEs visual notation. Multiplicities are omitted for clarity.}\n    \\end{subfigure}\n    \n    \\begin{subfigure}{\\textwidth}\n        \\centering\n        \\begin{align*}\n            NT_{TG} =\\ & \\{ \n                \\type{House},\n                \\type{PaymentInterval},\n                \\type{PaymentInterval\\$MONTH},\\\\&\n                \\type{PaymentInterval\\$QUARTER},\n                \\type{Person},\n                \\type{Renter},\n                \\type{Room},\n                \\type{int},\n                \\type{string}\n            \\}\\\\\n            ET_{TG} =\\ & \\{ \n                ( \\type{House}, \\type{name}, \\type{string} ),\n                ( \\type{House}, \\type{rooms}, \\type{Room} ),\\\\&\n                ( \\type{Person}, \\type{age}, \\type{int} ),\n                ( \\type{Person}, \\type{name}, \\type{string} ),\\\\&\n                ( \\type{Renter}, \\type{payment\\_interval}, \\type{PaymentInterval} ),\n                ( \\type{Renter}, \\type{rents}, \\type{Room} ),\\\\&\n                ( \\type{Room}, \\type{number}, \\type{int} ),\n                ( \\type{Room}, \\type{renter}, \\type{Renter} )\n            \\}\\\\\n            \\sqsubseteq_{TG}\\: =\\ & \\{ \n                ( \\type{House}, \\type{House} ),\n                ( \\type{PaymentInterval}, \\type{PaymentInterval} ),\\\\&\n                ( \\type{PaymentInterval\\$MONTH}, \\type{PaymentInterval} ),\\\\&\n                ( \\type{PaymentInterval\\$MONTH}, \\type{PaymentInterval\\$MONTH} ),\\\\&\n                ( \\type{PaymentInterval\\$QUARTER}, \\type{PaymentInterval} ),\\\\&\n                ( \\type{PaymentInterval\\$QUARTER}, \\type{PaymentInterval\\$QUARTER} ),\\\\&\n                ( \\type{Person}, \\type{Person} ),\n                ( \\type{Renter}, \\type{Person} ),\n                ( \\type{Renter}, \\type{Renter} ),\n                ( \\type{Room}, \\type{Room} ),\n                ( \\type{int}, \\type{int} ),\n                ( \\type{string}, \\type{string} )\n            \\}\\\\\n            abs_{TG} =\\ & \\{ \n                \\type{PaymentInterval}, \\type{Person}\n            \\}\\\\\n            \\mathrm{mult}_{TG} =\\ & \\big\\{ \n                \\big( ( \\type{House}, \\type{name}, \\type{string} ), ( 0..*, 1..1 ) \\big),\n                \\big( ( \\type{House}, \\type{rooms}, \\type{Room} ), ( 1..1, 1..* ) \\big),\\\\&\n                \\big( ( \\type{Person}, \\type{age}, \\type{int} ), ( 0..*, 1..1 ) \\big),\n                \\big( ( \\type{Person}, \\type{name}, \\type{string} ), ( 0..*, 1..1 ) \\big),\\\\&\n                \\big( ( \\type{Renter}, \\type{payment\\_interval}, \\type{PaymentInterval} ), ( 0..*, 1..1 ) \\big),\\\\&\n                \\big( ( \\type{Renter}, \\type{rents}, \\type{Room} ), ( 0..*, 0..* ) \\big),\\\\&\n                \\big( ( \\type{Room}, \\type{number}, \\type{int} ), ( 0..*, 1..1 ) \\big),\n                \\big( ( \\type{Room}, \\type{renter}, \\type{Renter} ), ( 0..*, 0..1 ) \\big)\n            \\big\\}\\\\\n            contains_{TG} =\\ & \\{ \n                ( \\type{House}, \\type{rooms}, \\type{Room} )\n            \\}\n        \\end{align*}\n        \\caption{Formal definition of the type graph}\n    \\end{subfigure}\n    \\caption{Example of a type graph corresponding with \\cref{defin:formalisations:groove_formalisation:type_graphs:type_graph}}\n    \\label{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}\n\\end{figure}\n\nAn example of a type graph is given in \\cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}. This example is similar to the type model example discussed in \\cref{subsec:formalisations:ecore_formalisation:type_models}. There is a node $\\type{House}$ which contains $\\type{Room}$s. A $\\type{House}$ also has an edge to a primitive type label $\\type{string}$ under edge label $\\type{name}$ which represents the name of the house. Please note that in the visual representation, syntactic sugar is used to represent this edge. Instead of an extra node and edge, it is represented as part of the $\\type{House}$ node. This syntactic sugar can be used for edges to primitive types and are in reality still treated as an edge to a separate node type. A $\\type{Room}$ has an edge $\\type{number}$, targeting the primitive type label $\\type{int}$, which represents the number of the room within the house. A $\\type{Room}$ can be rented by a $\\type{Renter}$. The $\\type{Renter}$s have edges to the $\\type{Room}$s they rented under the edge label $\\type{rents}$, while a $\\type{Room}$ can access its $\\type{Renter}$ through the edge with edge label $\\type{renter}$. A $\\type{Renter}$ extends the abstract $\\type{Person}$ node type, which has 2 edges $\\type{age}$ and $\\type{name}$, targeting the primitive type labels $\\type{int}$ and $\\type{string}$ respectively. These edges represent the age and the name of the $\\type{Person}$. Finally, a $\\type{Renter}$ has an edge under the edge label $\\type{payment\\_interval}$, which points to a $\\type{PaymentInterval}$ node type. This node type is abstract and the edge should therefore point to one of its subtypes, $\\type{PaymentInterval\\$MONTH}$ or $\\type{PaymentInterval\\$QUARTER}$. This represents the interval in which the $\\type{Renter}$ pays the rent. \nNotable from the definition is that the nodes set $N$ can contain primitive type labels. As a consequence, primitive type labels need to be added explicitly to a type graph in order to use primitive type values in an instance graph.\n\nFurthermore, each edge has a multiplicity pair tied to it, which is defined as the $\\mathrm{mult}$ function in the type graph definition. The multiplicity pair consists of an incoming multiplicity and an outgoing multiplicity. The incoming multiplicity determines the allowed amount of nodes that share the same target node with this edge type. On the other hand, the outgoing multiplicity determines the number of edges a single source node may have to its target nodes.\n\n\\begin{defin}[Multiplicity pair]\n\\label{defin:formalisations:groove_formalisation:type_graphs:multiplicity_pair}\nA multiplicity pair is defined as a tuple of two multiplicities, $\\mathbb{M} \\times \\mathbb{M}$, in which the first value denotes the incoming multiplicity and the second value the outgoing multiplicity.\n\nFor any multiplicity pair, we define two functions:\n\\begin{align*}\n    \\mathrm{in}\\!:&\\: \\mathbb{M} \\times \\mathbb{M} \\Rightarrow \\mathbb{M} \\\\\n    \\mathrm{out}\\!:&\\: \\mathbb{M} \\times \\mathbb{M} \\Rightarrow \\mathbb{M}\n\\end{align*}\nThe $\\mathrm{in}$ function being the function which from a multiplicity pair returns the incoming multiplicity and the $\\mathrm{out}$ function being the function that returns the outgoing multiplicity, so:\n\\begin{equation*}\n\\forall m = (m_{in}, m_{out}) \\in \\mathrm{mult}_{TG}: \\mathrm{in}(m) = m_{in} \\land \\mathrm{out}(m) = m_{out}  \n\\end{equation*}\n\n\\isabellelref{multiplicity_pair}{GROOVE.Multiplicity_Pair}\n\\end{defin}\n\nWith all definitions in place, it is possible to define a valid type graph.\nThe definition of a valid type graph introduces some new constraint that should hold for a type graph to be valid.\n\n\\begin{defin}[Type graph validity]\n\\label{defin:formalisations:groove_formalisation:type_graphs:type_graph_validity}\nFor a type graph to be valid, the following properties must hold:\n\\begin{enumerate}\n    \\item There may not be any ambiguity in the use of edges: $\\forall (s_1, l, t_1) \\in ET_{TG}\\,\\land\\, (s_2, l, t_2) \\in ET_{TG}\\!: \\big((s_1, s_2) \\in\\ \\sqsubseteq_{TG} \\lor\\ (s_2, s_1) \\in\\ \\sqsubseteq_{TG}\\!\\!\\big) \\land \\big((t_1, t_2) \\in\\ \\sqsubseteq_{TG} \\lor\\ (t_2, t_1) \\in\\ \\sqsubseteq_{TG}\\!\\!\\big) \\Longrightarrow s_1 = s_2 \\land t_1 = t_2$.\n    \\item Flags should have the same source and target node: $\\forall (s, l, t) \\in ET_{TG}: l \\in Lab_f \\Longrightarrow s = t$.\n    \\item $\\sqsubseteq_{TG}$ is a partial order ($\\sqsubseteq_{TG}$ is reflexive, transitive and anti-symmetric on $N\\!$).\n    \\item The incoming multiplicities of edges that identify a containment relation are valid: $\\forall e \\in contains_{TG}: \\mathrm{in}(\\mathrm{mult}_{TG}(e)) = (0, 1) \\lor \\mathrm{in}(\\mathrm{mult}_{TG}(e)) = (1, 1)$.\n\\end{enumerate}\n\n\\isabellelref{type_graph}{GROOVE.Type_Graph}\n\\end{defin}\n\n\\begin{figure}\n    \\centering\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\input{images/03_formalisations/03_groove_formalisation/edge_ambiguity_example_valid.tikz}\n        \\caption{Valid type graph without ambiguity}\n        \\label{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example:valid}\n    \\end{subfigure}\n    \\begin{subfigure}{0.45\\textwidth}\n        \\centering\n        \\input{images/03_formalisations/03_groove_formalisation/edge_ambiguity_example_invalid.tikz}\n        \\caption{Invalid type graph with an ambiguous edge type labelled $\\type{f}$}\n        \\label{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example:invalid}\n    \\end{subfigure}\n    \\caption{Example of ambiguity within edge types}\n    \\label{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example}\n\\end{figure}\n\nThe last 3 properties presented here are mostly self-explanatory. The first property might be unclear at first. This property prevents type graphs from having ambiguous edge types. \\cref{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example} shows an example of such an ambiguity. In essence, when creating edges within an instance graph, there should be an unique solution for typing the edge. In \\cref{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example:valid}, this is always the case, even though both edges are labelled $\\type{f}$. If an edge labelled $\\type{f}$ references a node of type $\\type{B}$, then the edge type should be $( \\type{Y}, \\type{f}, \\type{B} )$. When an edge labelled $\\type{f}$ references a node of type $\\type{A}$, the edge type should be $( \\type{X}, \\type{f}, \\type{A} )$. There is no ambiguity possible. \n\n\\cref{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example:invalid} shows an example of a type graph where ambiguity is possible. When a node of type $\\type{Y}$ references a node of $\\type{B}$ using an edge labelled $\\type{f}$, it is unclear which edge type was meant. Both $( \\type{Y}, \\type{f}, \\type{B} )$ and $( \\type{X}, \\type{f}, \\type{A} )$ would be valid edge types here. This means there is ambiguity in how edges are typed. The first property of \\cref{defin:formalisations:groove_formalisation:type_graphs:type_graph_validity} excludes this case, since $( \\type{Y}, \\type{f}, \\type{B} )$ and $( \\type{X}, \\type{f}, \\type{A} )$ are both edge types, while $(\\type{Y}, \\type{X}) \\in\\ \\sqsubseteq_{TG}$ and $(\\type{B}, \\type{A}) \\in\\ \\sqsubseteq_{TG}$. Then according to the first property, $\\type{Y}$ should be equal to $\\type{X}$ and $\\type{B}$ should be equal to $\\type{A}$, which is not the case, so \\cref{fig:formalisations:groove_formalisation:type_graphs:ambiguous_edges_example:invalid} violates the first property, hence the example is invalid.", "meta": {"hexsha": "ead5e9101347c28b6fea657cea85970436ebe07c", "size": 13004, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/tex/03_formalisations/03_groove_formalisation/02_type_graphs.tex", "max_stars_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_stars_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/tex/03_formalisations/03_groove_formalisation/02_type_graphs.tex", "max_issues_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_issues_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/tex/03_formalisations/03_groove_formalisation/02_type_graphs.tex", "max_forks_repo_name": "RemcodM/thesis-ecore-groove-formalisation", "max_forks_repo_head_hexsha": "a0e860c4b60deb2f3798ae2ffc09f18a98cf42ca", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 82.8280254777, "max_line_length": 1815, "alphanum_fraction": 0.6781759459, "num_tokens": 3652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.402400752474288}}
{"text": "%%\n%% This is file `./samples/shortsample.tex',\n%% generated with the docstrip utility.\n%%\n%% The original source files were:\n%%\n%% apa6.dtx  (with options: `shortsample')\n%% ----------------------------------------------------------------------\n%% \n%% apa6 - A LaTeX class for formatting documents in compliance with the\n%% American Psychological Association's Publication Manual, 6th edition\n%% \n%% Copyright (C) 2011-2017 by Brian D. Beitzel <brian at beitzel.com>\n%% \n%% This work may be distributed and/or modified under the\n%% conditions of the LaTeX Project Public License (LPPL), either\n%% version 1.3c of this license or (at your option) any later\n%% version.  The latest version of this license is in the file:\n%% \n%% http://www.latex-project.org/lppl.txt\n%% \n%% Users may freely modify these files without permission, as long as the\n%% copyright line and this statement are maintained intact.\n%% \n%% This work is not endorsed by, affiliated with, or probably even known\n%% by, the American Psychological Association.\n%% \n%% ----------------------------------------------------------------------\n%% \n\\documentclass[jou]{apa6}\n\n\\usepackage[american]{babel}\n\n\\usepackage{csquotes}\n\\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}\n\\DeclareLanguageMapping{american}{american-apa}\n\\addbibresource{bibliography.bib}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% Discrete Structures\n%% The start of RBS stuff\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Working internal and external links in PDF\n\\usepackage{hyperref}\n% Extra math symbols in LaTeX\n\\usepackage{amsmath}\n\\usepackage{gensymb}\n\\usepackage{amssymb}\n% Enumerations with (a), (b), etc.\n\\usepackage{enumerate}\n\n\\let\\OLDitemize\\itemize\n\\renewcommand\\itemize{\\OLDitemize\\addtolength{\\itemsep}{-6pt}}\n\n\\usepackage{etoolbox}\n\\makeatletter\n\\preto{\\@verbatim}{\\topsep=3pt \\partopsep=3pt }\n\\makeatother\n\n% These sizes redefine APA for A4 paper size\n\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.27in\n\\headheight 1.0in\n\\topmargin -24pt\n\\headheight 12pt\n\\headsep 12pt\n\\textheight 9.19in\n\n\n\n\\title{Sample Quiz for Week02}\n\\author{Discrete Structures, Fall 2020}\n\\affiliation{RBS}\n\n\\leftheader{Discrete Structures (W2): Sample Quiz}\n\n\\abstract{%\n}\n\n%\\keywords{}\n\n\\begin{document}\n\n\\twocolumn\n\n\\section{Worksheet 2: Predicates}\n\n{\\bf Question 1.} Let $a,b \\in \\mathbb{Z}^{+}$ be two positive integers.\nTranslate into predicate logic: ``$d$ is the greatest common divisor \nof $a,b$.'' (That is, \nthe greatest number that divides both $a$ and $b$).\\\\\n{\\em Note 1.} \"Translate into predicate logic\" means - use\npredicates and quantifiers to express that statement.\n{\\em Note 2.} Use ``infix'' notation for common predicates: write \n$a\\,\\mid\\,b$ whenever $a$ divides $b$; write $x < y$, if $x$ is less than $y$. For example, $3\\,|\\,6$ \\hspace{1ex} \n($3$ divides $6$) is preferred compared to \n``$\\mathtt{divides}(3,6)$''. Also \\hspace{1ex} \n$10 < 17$ is more readable than\n``$\\mathtt{lessThan(10,17)}$''.\n\n\\vspace{10pt}\n{\\bf Question 2.} Use quantifiers to write a \nstatement to tell that a quadratic\nfunction $f(x) = ax^2 +bx+c$ \nhas two different integer roots.\n\n\n\\vspace{10pt}\n{\\bf Question 3.} Assume that for some argument {\\tt x}, \nPython functions {\\tt a(x)} and {\\tt b(x)}\nreturn value {\\tt True}, but other two functions \n{\\tt c(x)} and {\\tt d(x)} return value {\\tt False}. \nWhich functions are called and evaluated, if you run the following conditional statement:\n\\begin{verbatim}\nif (a(x) or b(x)) and (c(x) & d(x)):\n    ## ... some Python code ...\n\\end{verbatim}\n{\\em Note.} Note that Boolean operators {\\tt and}, {\\tt or} \nuse {\\em short-circuit\nevaluation}, but operators {\\tt \\&}, {\\tt |} do not. \n\n\n\\vspace{10pt}\n{\\bf Question 4.} There is a set $C$ of several children and a \nset $H$ of several hats. There is a predicate $W(c,h)$ which is {\\tt True}\niff the child $c \\in C$ has ever worn the hat $h \\in H$.\\\\\n{\\bf (a)} Write the domain set and the range set of the predicate function $W$. \\\\\n{\\bf (b)} Use quantifiers to write a statement: ``Every two \nchildren have at least one hat in common (that is, both of \nthem have worn it).''\n\n\n\\vspace{10pt}\n{\\bf Question 5.}\nLet $\\mathcal{H}$ be the set of all humans, and the predicate $F(x,y)$ is\ntrue iff $x$ is the father of $y$. Express these sentences in plain English:\\\\\n{\\bf (a)} $\\forall y \\in \\mathcal{H}\\;\\exists x \\in \\mathcal{H},\\;F(x,y)$.\\\\\n{\\bf (b)} $\\exists x \\in \\mathcal{H}\\;\\forall y \\in \\mathcal{H},\\;F(x,y)$.\\\\\n{\\bf (c)} Which of the two statements {\\bf (a)}, {\\bf (b)} (if any) \nis true, if we replace the non-empty domain of all humans $\\mathcal{H}$ by an\nempty domain $\\mathcal{Z} = \\emptyset$ of all zombies?\n\n\\vspace{10pt}\n{\\bf Question 6.} We define predicates $P(x,y)$, \n$Q(x,y)$ with two arguments, \nwhere $x,y$ can be any of the three letters: \n$\\mathtt{a},\\mathtt{b},\\mathtt{c}$. \n(The type for all these predicates is \n$\\{ \\mathtt{a},\\mathtt{b},\\mathtt{c} \\}^2 \n\\rightarrow \\{ \\mathtt{T},\\mathtt{F} \\}$.)\n\nThey have these following truth tables:\n\\begin{center}\n\\begin{tabular}{c|ccc}\n$P$ & $a$ & $b$ & $c$ \\\\ \\hline\n$a$ & $\\mathtt{T}$ & $\\mathtt{F}$ & $\\mathtt{T}$ \\\\\n$b$ & $\\mathtt{F}$ & $\\mathtt{F}$ & $\\mathtt{F}$ \\\\\n$c$ & $\\mathtt{T}$ & $\\mathtt{T}$ & $\\mathtt{T}$\n\\end{tabular}\n\\hspace{2ex}\n\\begin{tabular}{c|ccc}\n$Q$ & $a$ & $b$ & $c$ \\\\ \\hline\n$a$ & $\\mathtt{F}$ & $\\mathtt{T}$ & $\\mathtt{F}$ \\\\\n$b$ & $\\mathtt{F}$ & $\\mathtt{F}$ & $\\mathtt{T}$ \\\\\n$c$ & $\\mathtt{T}$ & $\\mathtt{F}$ & $\\mathtt{F}$\n\\end{tabular}\n\\end{center}\nFind the truth values of these statements:\\\\\n{\\bf (a)} $\\exists x \\forall y, P(y,x)$\\\\\n{\\bf (b)} $\\exists x \\forall y, P(x,y)$\\\\\n{\\bf (c)} $\\exists x \\exists y, Q(x,y)$\\\\\n{\\bf (d)} $\\forall x \\exists y, Q(x,y)$\\\\\n{\\em Note.} In all truth tables the first argument is\nrepresented by row, the second is represented by column. \nFor example $P(\\mathtt{b}, \\mathtt{c}) = \\mathtt{F}$ (2nd row\nand 3rd column). Meanwhile \n$P(\\mathtt{c}, \\mathtt{b}) = \\mathtt{T}$ (3rd row and 2nd column). \n\n\n\n\\vspace{10pt}\n{\\bf Question 7.} \nFor a real number $x$ we know that $\\lfloor x \\rfloor \\neq \n\\lfloor x + 0.5 \\rfloor$. Write this statement in \npredicate logic without using any $\\lfloor \\ldots \\rfloor$ \nnotation. (Write instead that $x$ and $x+0.5$ have some integer number \nbetwen $x$  and $x+0.5$.)\\\\\n{\\em Note.} By $\\lfloor x \\rfloor$ we denote the \nlargest integer number that does not exceed $x$. \nFor example $\\lfloor 3.14 \\rfloor = 3$, $\\lfloor 17 \\rfloor = 17$, \n$\\lfloor -4.5 \\rfloor = -5$. \n\n\n\\newpage \n\n\\subsection{Answers}\n\n\n{\\bf Question 1.} Answer:\n$$\\boxed{\\forall k \\in \\mathbb{Z}^{+},\\;\\left(k\\,\\mid\\,a \\wedge \nk\\,\\mid\\,b\\right)\\,\\rightarrow\\,k \\leq d.}$$\n{\\em Recite:} ``For all positive integers $k$, if $k$ divides \nboth $a$ and $b$, then $k$ does not exceed \n$d = \\operatorname{gcd}(a,b)$.''\\\\\nThis also means that $d$ is the largest number among all\ncommon divisors of $a,b$ ({\\em greatest common divisor}, GCD).\\\\\n{\\em Note:} In the above formula $a,b,d$ are ``free variables''\n(they need to be assigned independently; and if \n$d \\neq \\operatorname{gcd}(a,b)$, then the statement is false). \nOn the other hand, $k$ is a ``bound variable''. You can rename\n$k$ into $x$ \\textendash{} and nothing will change.\n\n\\vspace{10pt}\n{\\bf Question 2.} Answer:\n\\begin{align}\n & \\exists x_1 \\in \\mathbb{Z}^{+}\\,\\exists x_2 \\in \\mathbb{Z}^{+}\\,\n\\forall x_3 \\in \\mathbb{Z}^{+}, \\nonumber \\\\\n & \\left( x_1 \\neq x_2 \\wedge f(x_1)=0 \\wedge f(x_2) = 0 \\right) \\wedge \\nonumber \\\\\n\\wedge & \\left( f(x_3) = 0 \\rightarrow x_3 = x_1 \\vee x_3 = x_2 \\right). \n\\nonumber\n\\end{align}\n{\\em Recite:} ``There exist two positive integers $x_1,x_2$ \nsuch that they are different and \nboth of them are roots of $f(x)=0$ and, \nfurthermore, for any other root $x_3$, it \nequals either $x_1$ or $x_2$.''\\\\\n{\\em Note:} The above statement says that there are {\\em exactly}\ntwo roots $x_1$ and $x_2$. You can easily write a modified statement \nsaying that the equation $f(x)=0$ has {\\em at least} two roots \\textendash{}\nin this case you can skip the $x_3$ part. For quadratic equations it\nis the same (since no equation has more than $2$ roots), but \nthe idea expressed here is slightly different:\n\\begin{align}\n & \\exists x_1 \\in \\mathbb{Z}^{+}\\,\\exists x_2 \\in \\mathbb{Z}^{+} \\nonumber \\\\\n & \\left( x_1 \\neq x_2 \\wedge f(x_1)=0 \\wedge f(x_2) = 0 \\right). \\nonumber \n\\end{align}\n\n\n\\vspace{10pt}\n{\\bf Question 3.} Answer:\\\\\n\\underline{The following functions are called: {\\tt a(x)}, \n{\\tt c(x)}, {\\tt d(x)}.}\\\\\nFunction {\\tt b(x)} is not called, because \nshort-circuit operator {\\bf or} \nskips the second argument in ``{\\tt a(x) or b(x)}'', \nif the first argument is {\\tt True}.\n\n\n\n\n\n\n\n\\vspace{10pt}\n{\\bf Question 4.} Answer: {\\bf (a)}\n$$\\boxed{W\\,:\\,C \\times H \\rightarrow \\{ \\mathtt{T}, \\mathtt{F} \\}.}$$\n{\\em Note.} In Coq the set of ``True'' and ``False'' \nis denoted by {\\tt Prop} or $\\{ \\mathtt{T}, \\mathtt{F} \\}$.\\\\\n{\\bf (b)} \n$$\\boxed{\\forall c_1 \\in C \\; \\forall c_2 \\in C \\; \\exists h \\in H,\nW(c_1,h) \\wedge W(c_2,h).}$$\nEvery two\nchildren have at least one hat in common (that is, both\nof them have worn it).\n\n\n\n\\vspace{10pt}\n{\\bf Question 5.} Answers:\\\\\n{\\bf (a)} \\underline{Every human has a father.}\\\\\n{\\bf (b)} \\underline{There exists someone, who is the father of everyone.}\\\\\n{\\bf (c)} \\underline{Both (a) and (b) are false for empty sets.}\\\\\nEvery time we write $\\exists x \\in \\mathcal{Z}$\nregarding anything (where $\\mathcal{Z} = \\emptyset$ \\textendash{}\nan empty set) it is false. \n\nOn the other hand, this statement is {\\tt True}: \n$$\\forall x \\in \\mathcal{Z} \\; \\forall y \\in \\mathcal{Z},\\; F(x,y) \\equiv \\mathtt{True}.$$\n{\\em Recite:} ``In the (empty) set $\\mathcal{Z}$ of all \nzombies, any zomby is a father of any other zomby.''\\\\\n{\\em Note.} For empty domains we do not need to know anything \nabout the predicate values, because their truth tables have\nzero rows and zero columns. You can also safely state the negation:\n``No zomby is a father of another zomby.''\n$$\\forall x \\in \\mathcal{Z} \\; \\forall y \\in \\mathcal{Z},\\; \\neg F(x,y) \\equiv \\mathtt{True}.$$\n\n\n\\vspace{10pt}\n{\\bf Question 6.} Answers:\\\\\n{\\bf (a)} False. In the truth table of $P$, there is NO \ncolumn (denoted by $x$) containing $\\mathtt{T}$ in \nevery row.\\\\\n{\\bf (b)} True. In the truth table of $P$ there is a row $x$ \n(it is the last row $x = \\mathtt{c}$), containing\n$\\mathtt{T}$ in every column.\\\\\n{\\bf (c)} True. We can indeed make $Q(x,y)$ true, if we pick \nrow and column. For example $Q(\\mathtt{c},\\mathtt{a}) = \\mathtt{T}$.\\\\\n{\\bf (d)} True. For any row in the truth table of $Q$, \nwe can find at least one $\\mathtt{T}$ in some column. \n\n\n\\vspace{10pt}\n{\\bf Question 7.} Answer:\\\\\n$$\\exists k \\in \\mathbb{Z}, x < k \\wedge x+0.5 \\geq k.$$\nIn this example $\\lfloor x \\rfloor = k-1$, but\n$\\lfloor x+0.5 \\rfloor = k$, so they are different.\n\n\n\n\n\n\n\\end{document}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%% End of RBS stuff\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n%% \n%% Copyright (C) 2011-2017 by Brian D. Beitzel <brian at beitzel.com>\n%% \n%% This work may be distributed and/or modified under the\n%% conditions of the LaTeX Project Public License (LPPL), either\n%% version 1.3c of this license or (at your option) any later\n%% version.  The latest version of this license is in the file:\n%% \n%% http://www.latex-project.org/lppl.txt\n%% \n%% Users may freely modify these files without permission, as long as the\n%% copyright line and this statement are maintained intact.\n%% \n%% This work is not endorsed by, affiliated with, or probably even known\n%% by, the American Psychological Association.\n%% \n%% \n%% This work is \"maintained\" (as per LPPL maintenance status) by\n%% Brian D. Beitzel.\n%% \n%% This work consists of the file  apa6.dtx\n%% and the derived files           apa6.ins,\n%%                                 apa6.cls,\n%%                                 apa6.pdf,\n%%                                 README,\n%%                                 APAamerican.txt,\n%%                                 APAbritish.txt,\n%%                                 APAdutch.txt,\n%%                                 APAenglish.txt,\n%%                                 APAgerman.txt,\n%%                                 APAngerman.txt,\n%%                                 APAgreek.txt,\n%%                                 APAczech.txt,\n%%                                 APAturkish.txt,\n%%                                 APAendfloat.cfg,\n%%                                 apa6.ptex,\n%%                                 TeX2WordForapa6.bas,\n%%                                 Figure1.pdf,\n%%                                 shortsample.tex,\n%%                                 longsample.tex, and\n%%                                 bibliography.bib.\n%% \n%%\n%% End of file `./samples/shortsample.tex'.\n", "meta": {"hexsha": "6bb5e86342aac883ab7e462c97942e6405812c1c", "size": 12767, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/site/discrete-spring2020/questionbase/quiz-sample-02.tex", "max_stars_repo_name": "kapsitis/math", "max_stars_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/site/discrete-spring2020/questionbase/quiz-sample-02.tex", "max_issues_repo_name": "kapsitis/math", "max_issues_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-07-20T03:40:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T21:50:18.000Z", "max_forks_repo_path": "src/site/discrete-spring2020/questionbase/quiz-sample-02.tex", "max_forks_repo_name": "kapsitis/math", "max_forks_repo_head_hexsha": "f21b172d4a58ec8ba25003626de02bfdda946cdc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5989159892, "max_line_length": 115, "alphanum_fraction": 0.6163546644, "num_tokens": 3997, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.4024007435523378}}
{"text": "% !TEX root = ../zeth-protocol-specification.tex\n\n\\section{Ethereum}\\label{preliminaries:ethereum}\n\nIn a nutshell, \\ethereum~is a distributed deterministic state machine, consisting of a globally accessible singleton state (``the World state'') and a virtual machine that applies changes to that state~\\cite{mastering-eth}.\nState transitions in the state machine are represented by transactions on the system. As such, each transaction represents a change in the global state represented as a Merkle Patricia Tree~\\cite{patricia-tree} whose nodes are objects called ``accounts'' (\\cref{preliminaries:ethereum:eth-account}). The Ethereum Virtual Machine (\\evm) allows state transitions to be specified by creating a type of accounts which are associated with a piece of code (smart-contracts). The code of such accounts, and so, the corresponding state transitions, can be executed to transition to another state in the automata, by creating a transaction that calls the given piece of code (\\cref{preliminaries:ethereum:eth-tx}).\n\nTo prevent unbounded state transitions in the state machine, each instruction executed by the \\evm~is associated with a cost in \\wei, referred to as ``the gas necessary to run the operation''. The ``gas cost'' of a transaction needs to be paid by the transaction originator (deduced from their account balance), and is awarded to the miner (added to their account balance) who successfully mines the block containing the transaction.\nIn addition to the cost of every instruction executed as part of a state transition, every transaction has an intrinsic cost of $\\txDefaultGas$ gas~\\cite[Appendix G]{ethyellowpaper}. Bounding modifications to the $\\ethereum{}$ state by the amount of \\wei~held in the transaction originator's account allows the system to avoid the Halting problem\\footnote{\\url{https://en.wikipedia.org/wiki/Halting\\_problem}} and protects against a range of Denial of Service (\\dos) attacks.\n\n\\subsection{Ethereum account}\\label{preliminaries:ethereum:eth-account}\n\nAn \\ethereum~account~\\cite[Section 4.1]{ethyellowpaper} is an object containing 4 attributes, as represented~\\cref{preliminaries:tab:eth-account}.\nWe distinguish two types of accounts:\n\\begin{itemize}\n    \\item ``Externally Owned Accounts'' (\\eoa), that are created by derivation of an \\ecdsa~secret key; and\n    \\item Smart-contract accounts, that are derived from \\evm~code specifying a state transition on the state machine.\n\\end{itemize}\n\nEach account object is accessible in the Merkle Patricia Tree representing the ``World state'' by a unique $\\addressLen$-bit long identifier called the address.\nIn the context of \\eoa, the address is obtained by generating a new \\ecdsa~\\cite{johnson2001elliptic} key pair $\\smalltuple{\\sk, \\vk}$ over curve \\secpCurve~\\cite{qu1999sec} and taking the rightmost $\\addressLen$ bits of the \\keccak{256} hash of the verification key $\\vk$.\n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{cp{25em}c}\n        Field           & Description & Data type\\\\ \\toprule\n        $\\nonce$        & The nonce of an account is a scalar value representing the number of transactions that have originated from the account, starting at 0. & $\\NN_\\ethWordLen$ \\\\ \\midrule\n        $\\balance$      & The balance of an account is a scalar value representing the amount of \\wei~in the account. & $\\NN_\\ethWordLen$\\\\ \\midrule\n        $\\sroot$        & The storage root is the \\keccak{256} hash representing the storage of the account. & $\\BB^{\\keccakTwoDigestLen}$\\\\ \\midrule\n        $\\codeh$        & The code hash is the hash of the \\evm~code governing the account. If this field is the \\keccak{256} hash of the empty string, then the account is said to be an ``Externally owned Account'' (\\eoa), and is controlled by the corresponding \\ecdsa~private key. If, however, this field is not the \\keccak{256} hash of the empty string, the account represents a smart contract whose interactions are governed by its \\evm~code. & $\\BB^{\\keccakTwoDigestLen}$\\\\ \\bottomrule\n    \\end{tabular}\n    \\caption{Ethereum Account structure}\\label{preliminaries:tab:eth-account}\n\\end{table}\n\n\\begin{notebox}\nIn the rest of this document, we will refer to an \\emph{Ethereum user} $\\eparty{U}$ as a person, modeled as an object, holding \\emph{one}\\footnote{The same physical person may correspond to multiple ``$\\ethereum{}$ users'' and thus control multiple accounts in the Merkle Patricia Tree.} secret key, $\\sk$ (object attribute), associated with an existing \\eoa~in the ``World state''. We denote by $\\eparty{U}.\\addr$ the \\ethereum~address of $\\eparty{U}$ derived from $\\eparty{U}.\\sk$, and which allows $\\eparty{U}$ to access the state of their account $\\wstate[\\eparty{U}.\\addr]$.\n\nWe denote by $\\contractstyle{SmartC}$ a smart-contract instance/object (i.e.~deployed smart-contract with an address,~\\cref{preliminaries:ethereum:eth-tx}), and denote by $\\contractstyle{SmartC}.\\addr$ its address.\n\\end{notebox}\n\n\\subsection{Ethereum transaction}\\label{preliminaries:ethereum:eth-tx}\n\nWe now briefly mention what \\ethereum~transactions~\\cite[Section 4.2]{ethyellowpaper} are, and how they are created, signed and validated. Once more, the reader is highly encouraged to refer to~\\cite{ethyellowpaper} for a detailed presentation.\n%\\subsubsection{Transaction}\nInformally, a transaction object ($\\tx$) is a signed message originating from an \\ethereum~user $\\eparty{U}$ (the \\emph{transaction originator}, or simply \\emph{sender}) that represents a state transition on the distributed state machine (i.e.~a change in the ``World state'' $\\wstate$).\n\n\\subsubsection{Raw transaction}\\label{preliminaries:ethereum:eth-tx:raw}\nIn the following, we define a raw transaction as an unsigned transaction (\\cref{preliminaries:tab:eth-unsigned}).\n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{ccc}\n        Field\t\t\t    & Description & Data type \\\\\\toprule\n        $\\nonce$            & Transaction nonce & $\\NN_{\\ethWordLen}$\\\\\\midrule\n        $\\gasp$\t\t        & gasPrice & $\\NN_{\\ethWordLen}$\\\\\\midrule\n        $\\gasl$\t\t        & gasLimit & $\\NN_{\\ethWordLen}$\\\\\\midrule\n        $\\tto$\t\t        & Recipient's address & $\\BB^{\\addressLen}$\\\\\\midrule\n        $\\val$\t\t        & Value of the transaction in $\\wei$ & $\\NN_{\\ethWordLen}$\\\\\\midrule\n        $\\init$ / $\\data$\t& \\begin{tabular}{@{}c@{}}Contract Creation data $\\init$ \\\\ Message call data $\\data$\\end{tabular} & $\\BB^{*}$\\\\\\bottomrule\n    \\end{tabular}\n    \\caption{Structure of a \\emph{raw transaction data type} $\\txRawDType$}\\label{preliminaries:tab:eth-unsigned}\n\\end{table}\n\n\\subsubsection{Finalizing raw transactions}\\label{preliminaries:ethereum:eth-tx:final}\nA raw transaction needs to be finalized to be accepted. In the context of this document, ``finalizing a raw transaction'' will be a synonym of ``signing a raw transaction''. The transaction structure is represented in~\\cref{preliminaries:tab:eth-signed}.\n\n\\begin{table}[H]\n    \\centering\n    \\begin{tabular}{ccc}\n        Field           & Description & Data type \\\\ \\toprule\n        $\\rawTx$      & Raw transaction object & $\\txRawDType$ \\\\ \\midrule\n        $\\sigv$         & Field $\\sigv$ of $\\ecdsa$ signature used for public key recovery & $\\BB^{\\byteLen}$\\\\ \\midrule\n        $\\sigr$         & Field $\\sigr$ of $\\ecdsa$ signature~\\cite{rfc6979} & $\\FFx{\\rSecp}$\\\\ \\midrule\n        $\\sigs$         & Field $\\sigs$ of $\\ecdsa$ signature~\\cite{rfc6979} & $\\FFx{\\rSecp}$\\\\ \\bottomrule\n    \\end{tabular}\n    \\caption{Structure of a (finalized) \\emph{transaction data type} $\\txDType$}\\label{preliminaries:tab:eth-signed}\n\\end{table}\n\nWe define the transaction generation function, cf.~\\cref{preliminaries:fig:txgen}, as the function taking the sender's \\ecdsa~signing key and the components of a raw transaction as arguments, and returning a signed (or finalized) transaction ($\\finalTx$ or $\\tx$ for short).\n\\begin{align*}\n    \\finalTx &= \\txgen(\\sk_{\\ecdsa}, \\inp{\\nonce}, \\inp{\\gasp}, \\inp{\\gasl}, \\inp{\\tto}, \\inp{\\val}, \\inp{\\init}, \\inp{\\data})\\\\\n    \\finalTx &= \\{ \\\\\n                & \\left.\n                \\begin{array}{l@{}l}\n                    \\nonce & {}: \\inp{\\nonce},\\\\\n                    \\gasp & {}: \\inp{\\gasp},\\\\\n                    \\gasl & {}: \\inp{\\gasl},\\\\\n                    \\tto & {}: \\inp{\\tto},\\\\\n                    \\val & {}: \\inp{\\val},\\\\\n                    \\init/\\data & {}: \\inp{\\init}/\\inp{\\data},\n                \\end{array}\n                \\right\\rbrace~\\rawTx\\\\\n                & \\left.\n                \\begin{array}{l@{}l}\n                    \\sigv & {}: \\sigma_\\ecdsa.\\sigv,\\\\\n                    \\sigr & {}: \\sigma_\\ecdsa.\\sigr,\\\\\n                    \\sigs & {}: \\sigma_\\ecdsa.\\sigs \\\\\n                \\end{array}\n                \\right\\rbrace~\\sigma_\\ecdsa\\\\\n                \\}\n\\end{align*}\n\nTo sign a transaction, the sender first computes the hash of the raw transaction using $\\keccak{256}$, cf.~\\cref{preliminaries:eq:tx-sig-hash}, and then uses their \\ecdsa~signing key, $\\sk_\\ecdsa$, to sign the obtained digest. cf.~\\cref{preliminaries:eq:tx-sig-sig}. The signature is then appended to the raw transaction to obtain a finalized transaction, cf.~\\cref{preliminaries:fig:txgen}.\n\n\\begin{align}\n    \\digest_\\ecdsa &= \\keccak{256}(\\inp{\\nonce}, \\inp{\\gasp}, \\inp{\\gasl}, \\inp{\\tto}, \\inp{\\val}, \\inp{\\init}/\\inp{\\data}) \\label{preliminaries:eq:tx-sig-hash} \\\\\n    \\sigma_{\\ecdsa} &= \\ecdsasigscheme.\\sig(\\sk_\\ecdsa, \\digest_\\ecdsa)\\ (= \\smalltuple{\\sigv, \\sigr, \\sigs}) \\label{preliminaries:eq:tx-sig-sig}\n\\end{align}\n\n\\begin{figure}[H]\n    \\centering\n    \\procedure[linenumbering]{$\\txgen(\\sk_\\ecdsa, \\inp{\\nonce}, \\inp{\\gasp}, \\inp{\\gasl}, \\inp{\\tto}, \\inp{\\val}, \\inp{\\init}, \\inp{\\data})$}{%\n    \\pcif \\inp{\\tto} = \\emptyset \\pcdo\\\\\n    \\t \\rawTx \\gets \\{\\nonce: \\inp{\\nonce}, \\gasp: \\inp{\\gasp}, \\gasl: \\inp{\\gasl}, \\tto: \\inp{\\tto}, \\val: \\inp{\\val}, \\init: \\inp{\\init}\\}; \\\\\n    \\pcelse \\\\\n    \\t \\rawTx \\gets \\{\\nonce: \\inp{\\nonce}, \\gasp: \\inp{\\gasp}, \\gasl: \\inp{\\gasl}, \\tto: \\inp{\\tto}, \\val: \\inp{\\val}, \\data: \\inp{\\data}\\}; \\\\\n    \\pcendif \\\\\n    \\sigma_\\ecdsa \\gets \\ecdsasigscheme.\\sig(\\sk_{\\ecdsa}, \\keccak{256}(\\rawTx)); \\\\\n    \\finalTx \\gets \\{ \\rawTx, \\sigv: \\sigma_\\ecdsa.\\sigv, \\sigr: \\sigma_\\ecdsa.\\sigr, \\sigs: \\sigma_\\ecdsa.\\sigs \\}; \\\\\n    \\pcreturn\\ \\finalTx;\n}\n    \\caption{Transaction generation function \\txgen}\\label{preliminaries:fig:txgen}\n\\end{figure}\n\n\\begin{remark}\\label{preliminaries:recovering-msg-sender}\n    As one can see, there is no ``from'' attribute in a transaction. The sender's \\ethereum~address can be recovered from the \\ecdsa~signature. This method is defined in the \\ethereum~yellow paper as a ``sender function'' $S$~\\cite[Appendix F]{ethyellowpaper} which maps each transaction to its sender.\n\\end{remark}\n\n\\subsubsection{Types of transactions}\\label{preliminaries:ethereum:eth-tx:tx-types}\n\nWhile only two types of transactions are described in~\\cite[Section 4.2]{ethyellowpaper}; namely those which result in message calls and those which result in the creation of new accounts with associated code, we will instead differentiate the types of transactions based on their purpose. The reader is encouraged to read~\\cite{ethyellowpaper} for a formal discussion.\n\n\\medskip\n\nInformally, a transaction can be used to achieve three things: transferring \\wei~from an \\eoa~to another \\eoa, creating a new account with associated code (i.e.~``deploying a smart-contract''), and calling a function of a smart-contract. We will detail here the differences between these usages.\n\\begin{description}\n    \\item[Creating a contract] The $\\tx.\\tto$ address is set to $\\emptyset$ in the transaction. The contract creation data ($\\tx.\\init$) includes the new contract's code. The contract address is computed as the rightmost $\\addressLen$ bits of the \\keccak{256} hash of the \\rlp~encoding~\\cite{ethrlp} of the transaction originator's address and account nonce~\\cite[Section 6]{ethyellowpaper}.\n    \\item[Calling a contract function] The $\\tx.\\tto$ address is set to the address of the contract. The message call data byte array ($\\tx.\\data$) is set to the contract's function address (or \\emph{``Function Selector''}~\\cite{abi-function-selector}) which are the first 4 bytes of the \\keccak{256} hash of the function signature, and the function input arguments ($\\ethWordLen$ bits per input)~\\cite[Section 8]{ethyellowpaper}.\n    \\item[Transferring \\wei~from an \\eoa~to another \\eoa] This corresponds to a ``plain transaction'' spending \\wei~from an address to send them to another. In that case the $\\tx.\\tto$ address corresponds to the recipient's address while the transaction data is left empty.\n\\end{description}\n\n\\begin{notebox}\n    In order to keep notations simple, we assume, in the rest of the document, that smart-contract functions are uniquely determined by their name. As such, we denote by $\\funcSelec{\\cdot} \\colon \\BB^{*} \\to \\BB^{4 \\cdot \\byteLen}$ the function that takes a function name as input and returns its function selector.\n\\end{notebox}\n\n\\subsubsection{Transaction validity}\\label{preliminaries:ethereum:eth-tx:tx-validity}\n\nImportantly, not all finalized transactions constitute valid state transitions on the state machine~\\cite[Section 6]{ethyellowpaper}.\nWe denote by \\ethVerifyTx~the function that takes an \\ethereum~transaction object $\\tx$ as input and return $\\true$ (resp.~$\\false$) if $\\tx$ is valid (resp.~invalid). To be deemed valid, a transaction $\\MUST$ satisfy \\emph{all} the following conditions:\n\\begin{enumerate}\n    \\item The transaction is correctly \\rlp~encoded, with no additional trailing bytes;\n    \\item the transaction signature $\\smalltuple{\\sigv, \\sigr, \\sigs}$ is valid;\n    \\item the transaction nonce ($\\tx.\\nonce$) is valid, i.e.~it is equal to the account nonce of the transaction originator;\n    \\item the gas limit is no smaller than the gas used by the transaction;\n    \\item the transactor has enough funds on his account balance to cover at least the cost $\\tx.\\val + \\tx.\\gasp \\cdot \\tx.\\gasl$.\n\\end{enumerate}\n\n\\subsubsection{Lifecyle of a transaction, and miners' incentives}\\label{preliminaries:ethereum:eth-tx:tx-life}\n\nAfter the creation of an \\ethereum~transaction \\tx~by a user from an \\ethereum~client (machine running a piece of software that enables to be connected to the \\ethereum~network), the transaction is broadcasted to the network and received by a set of peers/nodes.\n\nThe transaction is then stored in each node's transaction pool, which is a data structure containing all transactions that should be validated (pending transactions) by the node and mined. To maximize miners' returns, the transaction pools are ordered according to the gas price of the transactions. As such, transactions with the highest $\\tx.\\gasp$ are subject to be validated and included into a block first.\nOnce \\tx~is selected from the transaction pool, it is validated (fed into \\ethVerifyTx), executed, and included into a block (i.e.~``mined''). The block is then broadcasted to all the nodes of the network and is used as the predecessor for the next block to be mined on the network (i.e.~``it is added to the chain'').\n\n\\subsection{Ethereum events and Bloom filters}\\label{sssec:ethereum-events}\n\nThe \\evm~contains the set of ``LOGX'' instructions enabling smart-contract functions to ``emit events'' (i.e.~log data) when they are executed\\footnote{see~\\url{https://ethgastable.info/}}\n\nAs such, when a block is generated by a miner or verified by the rest of the network, the address of any logging contract, and all the indexed fields from the logs generated by executing those transactions are added to a Bloom filter~\\cite{DBLP:journals/cacm/Bloom70}, which is included in the block header~\\cite[Section 4.3]{ethyellowpaper}. Importantly, the actual logs \\emph{are not included in the block data} in order to save space.\n    As such, when an application wants to find (``consume'') all the log entries from a given contract, or with specific indexed fields (or both), the node can quickly scan over the header of each block, checking the Bloom filter to see if it may contain relevant logs. If it does, \\emph{the node re-executes the transactions from that block, regenerating the logs, and returning the relevant ones to the application}~\\cite{eth-bloom-filters}.\n\n\\begin{notebox}\n    The ability for a smart-contract function to ``emit'' some pieces of data when executed, and for an application to ``consume'' such pieces of data, is used in \\zeth~in order to construct a \\emph{confidential receiver-anonymous channel}~\\cite{DBLP:conf/pet/KohlweissMOTV13}.\n\\end{notebox}\n", "meta": {"hexsha": "9427088a3ab70307799efb54a94c4275f0894396", "size": 16574, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/chap01-sec02.tex", "max_stars_repo_name": "clearmatics/zeth-specifications", "max_stars_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-29T18:22:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-29T18:22:00.000Z", "max_issues_repo_path": "chapters/chap01-sec02.tex", "max_issues_repo_name": "clearmatics/zeth-specifications", "max_issues_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2020-10-27T10:41:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-16T10:57:05.000Z", "max_forks_repo_path": "chapters/chap01-sec02.tex", "max_forks_repo_name": "clearmatics/zeth-specifications", "max_forks_repo_head_hexsha": "ba29c67587395f5c7b26b52ee7ab9cba12f1cc6b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-07-26T04:51:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-26T04:51:29.000Z", "avg_line_length": 94.7085714286, "max_line_length": 705, "alphanum_fraction": 0.7144925787, "num_tokens": 4502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.49218813572079556, "lm_q1q2_score": 0.40240045725065543}}
{"text": "% ------------------------------------------------------------------------\n% bjourdoc.tex for birkjour.cls*******************************************\n% ------------------------------------------------------------------------\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\documentclass{birkjour}\n%\n%\n% THEOREM Environments (Examples)-----------------------------------------\n%\n \\newtheorem{thm}{Theorem}[section]\n% \\newtheorem{cor}[thm]{Corollary}\n% \\newtheorem{lem}[thm]{Lemma}\n% \\newtheorem{prop}[thm]{Proposition}\n% \\theoremstyle{definition}\n \\newtheorem{defn}[thm]{Definition}\n% \\theoremstyle{remark}\n% \\newtheorem{rem}[thm]{Remark}\n% \\newtheorem*{ex}{Example}\n \\numberwithin{equation}{section}\n\n\\usepackage[noadjust]{cite}\n\\usepackage{amsfonts}\n\\usepackage{listings}\n\\usepackage{algorithm}\n\\usepackage{algorithmic}\n\\usepackage{booktabs}\n\\usepackage{float}\n\\usepackage{caption}\n\n\\begin{document}\n\n%-------------------------------------------------------------------------\n% editorial commands: to be inserted by the editorial office\n%\n%\\firstpage{1} \\volume{228} \\Copyrightyear{2004} \\DOI{003-0001}\n%\n%\n%\\seriesextra{Just an add-on}\n%\\seriesextraline{This is the Concrete Title of this Book\\br H.E. R and S.T.C. W, Eds.}\n%\n% for journals:\n%\n%\\firstpage{1}\n%\\issuenumber{1}\n%\\Volumeandyear{1 (2004)}\n%\\Copyrightyear{2004}\n%\\DOI{003-xxxx-y}\n%\\Signet\n%\\commby{inhouse}\n%\\submitted{March 14, 2003}\n%\\received{March 16, 2000}\n%\\revised{June 1, 2000}\n%\\accepted{July 22, 2000}\n%\n%\n%\n%---------------------------------------------------------------------------\n%Insert here the title, affiliations and abstract:\n%\n\n\n\\title[Robust Quaternion Estimation with Geometric Algebra]\n {Robust Quaternion Estimation with \\\\Geometric Algebra}\n\n%----------Author 1\n\\author[Mauricio Cele Lopez Belon]{Mauricio Cele Lopez Belon}\n\\address{Madrid, Spain}\n\\email{mclopez@outlook.com}\n\n%----------classification, keywords, date\n\\subjclass{Parallel algorithms 68W10; Clifford algebras, spinors 15A66}\n\n\\keywords{Geometric Algebra, Quaternion Estimation, Wahba Problem}\n\n\\date{October 21, 2019}\n%----------additions\n%\\dedicatory{To my wife}\n%%% ----------------------------------------------------------------------\n\n\\begin{abstract}\n\nRobust methods for finding the best rotation aligning two sets of corresponding vectors are formulated in the linear algebra framework, using tools like the SVD for polar decomposition or QR for finding eigenvectors. Those are well established numerical algorithms which on the other hand are iterative and computationally expensive. Recently, closed form solutions has been proposed in the quaternion's framework, those methods are fast but they have singularities i.e., they completely fail on certain input data. In this paper we propose a robust attitude estimator based on a formulation of the problem in Geometric Algebra. We find the optimal eigen-quaternion in closed form with high accuracy and with competitive performance respect to the fastest methods reported in literature.\n\n\\end{abstract}\n\n%%% ----------------------------------------------------------------------\n\\maketitle\n%%% ----------------------------------------------------------------------\n%\\tableofcontents\n\\section{Introduction}\n\n\\indent The estimation of rotations has been studied for over half a century \\cite{Wahba1965}. The problem consist on finding the optimal rotation aligning two sets of corresponding vectors. Many effective methods have been developed \\cite{Arun1987, Horn1987, Mortari1996, Shuster1981, Yang2015} using $3\\times3$ matrices and quaternions. Formulations based on quaternions solves a max-eigenvalue problem, while formulations based on linear algebra relies on Singular Value Decomposition (SVD). In the last decade formulations based on geometric algebra \\cite{Perwass2009, Dorst2011} were introduced but they also rely on linear algebra numerical algorithms such as SVD due to the lack of native numerical algorithms. Closed form solutions for finding the optimal quaternion has been proposed \\cite{Yang2013, Wu2017, Wu2018FA3R, Wu2018FS3R} based on analytic formulas for solving the roots of the quartic polynomial associated with eigenvalue problem.\n\nAccuracy and speed of prominent methods have been compared in  \\cite{Eggert1997, Markley1999, Wu2017} evidencing a trade-off between performance and robustness. In particular SVD based methods exhibit the best accuracy but low performance and quaternion based methods are faster but less accurate. Regarding the later methods, the closed form solutions exhibit the best performance so far but they have singularities i.e., they completely fail on certain input data.\n\nIn this paper we propose a robust estimator of the best quaternion aligning two sets of corresponding vectors. We maximize a convex quadratic energy functional formulated in the $\\mathbb{G}_{3,0,0}$ geometric algebra which allow us to find an optimal quaternion in a robust way without resorting to linear algebra numerical algorithms. Geometric algebra rotors are isomorphic to quaternions, we find geometric algebra to be a more natural choice for studying this problem since rotations and subspaces of $\\mathbb R^3$ are treated in the same manner, facilitating meaningful algebraic manipulations. We primarily work with bivectos instead of vectors for the sake of mathematical convenience. Due to mathematical (and geometric) duality of vectors and bivectors in $\\mathbb{G}_3$ our formulation is also valid for vectors.\n\n\\section{Geometric Algebra $\\mathbb{G}_3$}\n\nA geometric algebra $\\mathbb{G}_3$ is constructed over a real vector space $\\mathbb R^3$, with basis vectors $\\{e_1, e_2, e_3\\}$. The associative geometric product is defined on vectors so that the square of any vector $a$ is a scalar $a a = a^2 \\in \\mathbb{R}$ and the geometric product of two vectors $a$ and $b$ is $a b = a \\cdot b + a \\wedge b$ and $b a = b \\cdot a - a \\wedge b$. From the vector space $\\mathbb R^3$, the geometric product generates the geometric algebra $\\mathbb{G}_3$ with elements $\\{ X, R, A...\\}$ called multivectors.\n\nFor a pair of vectors $a$ and $b$, a symmetric inner product $a \\cdot b = b \\cdot a$ and antisymmetric outer product $a \\wedge b = -b \\wedge a$ can be defined implicitly by the geometric product. It is easy to prove that $a \\cdot b = \\frac{1}{2}(a b + b a)$ is a scalar, while the quantity $a \\wedge b = \\frac{1}{2}(a b - b a)$, called a bivector or $2$-vector, is a new algebraic entity that can be visualized as the two-dimensional analogue of a direction i.e., a planar direction. Similar to vectors, bivectors can be decomposed in a bivector basis $\\{ e_{12}, e_{13}, e_{23} \\}$ where $e_{ij} = e_i \\wedge e_j$.\n\nThe outer product of three vectors $a \\wedge b \\wedge c$ generates a $3$-vector also known as the pseudoscalar, because the trivector basis consist of single element $e_{123} = e_1 \\wedge e_2 \\wedge e_3$. Similarly, the scalars are regarded as $0$-vectors whose basis is the number $1$. It follows that the outer product of $k$-vectors is the completely antisymmetric part of their geometric product: $a_1 \\wedge a_2 \\wedge ... \\wedge a_k = \\langle a_1 a_2 ... a_k \\rangle_k$ where the angle bracket means $k$-vector part, and $k$ is its grade. The term grade is used to refer to the number of vectors in any exterior product. This product vanishes if and only if the vectors are linearly dependent. Consequently, the maximal grade for nonzero $k$-vectors is $3$. It follows that every multivector $X$ can be expanded into its $k$-vector parts and the entire algebra can be decomposed into $k$-vector subspaces:\n\\begin{equation*}\n\\mathbb G_3 = \\sum_{k=0}^n{\\mathbb{G}^k_3} = \\{ X = \\sum_{k=0}^n { \\langle X \\rangle_k } \\}\n\\end{equation*}\nThis is called a \\emph{grading} of the algebra. \n\nReversing the order of multiplication is called reversion, as expressed by $(a_1 a_2 ... a_k)\\tilde{} = a_k ... a_2 a_1$ and $(a_1 \\wedge a_2 \\wedge ... \\wedge a_k)\\tilde{} = a_k \\wedge ... \\wedge a_2 \\wedge a_1$, and the reverse of an arbitrary multivector is defined by $\\tilde{X} = \\sum_{k=0}^n { \\langle \\tilde{X} \\rangle_k }$.\n\n\\subsection{Rotors}\n\nRotations are even grade multivectors known as rotors. We denote the subalgebra of rotors as $\\mathbb{G}^{+}_3$. A rotor $R$ can be generated as the geometric product of an even number of vectors. A reflection of any $k$-vector $X$ in a plane with normal $n$ is expressed as the sandwitch product $(-1)^k n X n$. The most basic rotor $R$ is defined as the product of two unit vectors $a$ and $b$ with angle of $\\frac{\\theta}{2}$. The rotation plane is the bivector $L = \\frac{a \\wedge b}{\\| a \\wedge b \\|}$.\n\\begin{equation}\na b = a \\cdot b + a \\wedge b = \\cos\\left( \\frac{\\theta}{2} \\right) + L \\sin\\left( \\frac{\\theta}{2} \\right).\n\\end{equation}\nRotors act on all $k$-vectors using the sandwitch product $X' = R X \\tilde R$, where $\\tilde R$ is the reverse of $R$ and can be obtained by reversing the order of all the products of vectors.\n\n\\subsection{Bivector products}\n\nWe define the commutator product of two bivectors $p_j$ and $q_j$ as $p_j \\times q_j = \\frac{1}{2}(p_j q_j - q_j p _j)$. The commutator product of bivectors in $\\mathbb{G}_3$  can be interpreted as a cross-product of bivectors i.e., the resulting bivector $B = p_j \\times q_j$ is orthogonal to both $p_j$ and $q_j$. The commutator product allow us to define the geometric product of two bivectors as $A B = A \\cdot B + A \\times B$. The inner product of bivectors differs from the inner product of vectors on the sign, since the square of bivectors is negative, the inner product of bivectors is a negative scalar e.g., $(a e_{12} + b e_{13} + c e_{23}) \\cdot (d e_{12} + e e_{13} + f e_{23}) = -a d - b e - c f$.\n\n\\subsection{Quaternions}\n\nA quaternion $Q = w + \\vec v$ consists of two parts: a scalar part $w$ and vector part $\\vec v$ which denotes the axis of rotation. The vector part $\\vec v$ is defined in a basis of complex vectors $\\{ i, j, k \\}$ that squares to $-1$ and anticommute i.e., $i^2 = j^2 = k^2 = -1$ and $i j k = -1$. In geometric algebra they corresponds to bivectors:\n\\begin{eqnarray}\ni = e_{23} \\ \\ \\ j = e_{13} \\ \\ \\  k = e_{12} \\\\\nijk = e_{23} e_{13} e_{12} = -1 \\nonumber\n\\end{eqnarray}\nRotors can easily be transformed to quaternions and vice versa. A rotor $R = w + L$ corresponds with a quaternion $Q = w + \\vec v$, where $L = \\alpha e_{12} + \\beta e_{13} + \\gamma e_{23}$ and $\\vec v = \\gamma i + \\beta j + \\alpha k$.\n\n\\section{Geometric Algebra Rotor Estimation}\n\nGiven two sets of $n$ corresponding bivectors $P = \\{p_j\\}_{j=1}^n$ and $Q = \\{q_j\\}_{j=1}^n$, we attempt to maximize the following energy function:\n\\begin{eqnarray}\n\tE(R) = \\max_{R \\in \\mathbb{G}^{+}_3 } \\sum_j { c_{j} \\|p_j + \\tilde R q_i R \\|^2 }\\\\\n\ts.t. \\ R \\tilde R = 1 \\nonumber\n\\end{eqnarray}\nwhere $\\{c_{j}\\}_{j=1}^n$ are scalar weights such that $\\sum_j^n{c_j} = 1$. It is a quadratic maximization problem with a non-linear constraint in $R$. Notice that the term $\\|p_j + \\tilde R q_i R\\|^2$ is dual to the traditional least squares error $\\|q_j - R p_j \\tilde R\\|^2$. Duality in the sense that the optimal $R$ is a critical point of both energies.\nNotice also that $p_j + \\tilde R q_i R$ is equivalent to $R p_j + q_j R$ by multiplying by $R$ on the left and using the fact that $R \\tilde R = 1$. The equivalent problem is:\n\\begin{eqnarray}\n\t\\label{eqn:max_energy}\n\tE(R) = \\max_{R \\in \\mathbb{G}^{+}_3 } \\sum_j { c_{j} \\|R p_j + q_j R\\|^2 }\\\\\n\ts.t. \\ R \\tilde R = 1 \\nonumber\n\\end{eqnarray}\nwhich exposes the that $R$ is only quadratic in \\ref{eqn:max_energy}.\n\nThe constraint $R p_j + q_j R$ can be rewriten as $(w + L) p_j  + q_j (w + L)$. For some a scalar $w$ and bivector $L$. Expanding the geometric product of bivectors in terms of the inner product and the communtator product we get:\n\\begin{eqnarray}\n\tw  (p_j + q_j) + L \\cdot (p_j + q_j)  + (q_j - p_j) \\times L\n\\end{eqnarray}\n\nIn matrix language we can define the following matrix system $M_j R = 0$:\n\\begin{eqnarray}\n\tM_j R =\n\t\\left[\\begin{array}{cc}\n\t\t0      &       -s_j^T \\\\\n\t\ts_j    &   \\left[ d_j \\right]_\\times \\\\\n\t\\end{array}\\right]\n\t\\left[\\begin{array}{c} \n\t\tw \\\\\n\t\tL\n\t\\end{array}\\right] = \n\t\\left[\\begin{array}{c}\n\t\t-s_j^T L \\\\\n\t\tw s_j + d_j \\times L \n\t\\end{array}\\right]\\\\\n\td_j = q_j - p_j \\ \\ s_j = p_j + q_j  \\nonumber\n\\end{eqnarray}\nwhere $d_j$ and $s_j$ are $3 \\times 1$ column vectors holding bivector's coefficients, $M_j$ is a skew-symmetric $4\\times 4$ real matrix, so that $M_j^T = -M_j$. The rotor $R$ is represented as $4 \\times 1$ column vector made of the scalar $w$ and the $3 \\times 1$ column vector $L$ holding the bivector's components. The $3\\times 3$ matrix $\\left[ d_j \\right]_\\times$ is representing the skew-symmetric cross-product matrix as usually defined for vectors in $\\mathbb R^3$.\n\nWe can express $E(R)$ as the following quadratic form:\n\\begin{eqnarray}\nE(R) = \\max_R R^T M R\\\\\ns.t. \\ R^T R = 1  \\nonumber\n\\end{eqnarray}\nwhere $M = \\sum_j^n { c_j M_j^T M_j}$. Note that since $M_j$ is skew-symmetric, the product $M_j^T M_j$ is symmetric and positive semi-definite.\nConsequently the matrix $M$ is also symmetric positive semi-definite. It follows that all eigenvalues of $M$ are real and $\\lambda_i \\geq 0$.\n\\begin{eqnarray}\n\tM_j^T M_j = \n\t\\left[\\begin{array}{cc}\n\t\t\\| s_j \\|^2       &         (s_j \\times d_j)^T \\\\\n\t\ts_j \\times d_j  &    s_j s_j^T - \\left[ d_j \\right]^2_\\times \\\\\n\t\\end{array}\\right]\\\\\n\td_j = q_j - p_j \\ \\ s_j = p_j + q_j  \\nonumber\n\\end{eqnarray}\n\nBy the spectral theorem the maximizer of $E(R)$ is the eigenvector of $M$ associated with the largest eigenvalue which is a positive number.\n\n\\section{Convexity}\n\nThe convexity of the energy $E(R)$ can be proof by showing that its Hessian matrix of second partial derivatives is positive semi-definite. The Hessian matrix of $E(R)$ is $\\frac{\\partial^2 E(R)}{\\partial R} = \\sum_j^n { c_j M_j^T M_j}$ which is symmetric, moreover since $M_j$ is skew-symmetric matrix, the product $M_j^T M_j$ is symmetric positive semi-definite. Then follows that $\\sum_j^n { c_j M_j^T M_j}$ is positive semi-definite and therefore convex, provided that the sum of weights is convex i.e., $\\sum_j^n { c_j } = 1$.\n\n\\section{Optimal Quaternion using 4D Geometric Algebra}\n\nThe most time consuming task of the estimation is to compute the eigenvector of $M$ associated with the greatest eigenvalue. In this section we show how to find the largest eigenvalue and its corresponding eigenvector i.e., the required quaternion, using the 4D Geometric Algebra $ \\mathbb{G}_4$ which is robust, efficient and accurate.\n\nLet us define four vectors $\\textbf m_1$, $\\textbf m_2$, $\\textbf m_3$, $\\textbf m_4$ corresponding to the columns of matrix $M$:\n\\begin{eqnarray}\n\tM = \\sum_j^n { c_j M_j^T M_j} =\n\t\\left[\\begin{array}{cccc}\n\t\t\\\\\n\t\t\\textbf m_1 & \\textbf m_2 & \\textbf m_3 & \\textbf m_4 \\\\\n\t\t\\\\\n\t\\end{array}\\right]\n\\end{eqnarray}\n\nThe matrix system that we want to solve is $M R = \\lambda R$ for $\\lambda$ corresponding to the largest eigenvalue of $M$. We can write the system in its homogeneous form:\n\\begin{eqnarray}\n\t\\label{eqn:eigensystem}\n\t\\left[\\begin{array}{cccc}\n\t\t\\\\\n\t\t\\textbf m_1 - \\lambda e_1 & \\textbf m_2 - \\lambda e_2 & \\textbf m_3 - \\lambda e_3 & \\textbf m_4- \\lambda e_4 \\\\\n\t\t\\\\\n\t\t\\\\\n\t\\end{array}\\right]\n\t\\left[\\begin{array}{c} \n\t\tw \\\\\n\t\tL_1\\\\\n\t\tL_2\\\\\n\t\tL_3\n\t\\end{array}\\right] = \t\n\t\\left[\\begin{array}{c} \n\t\t0 \\\\\n\t\t0 \\\\\n\t\t0 \\\\\n\t\t0\n\t\\end{array}\\right]\n\\end{eqnarray}\n\nThe matrix in equation~\\ref{eqn:eigensystem}, called \\emph{characteristic matrix}, is of rank $3$ and thus singular i.e., the vectors $(\\textbf m_1 - \\lambda e_1)$, $(\\textbf m_2 - \\lambda e_2)$, $(\\textbf m_3 - \\lambda e_3)$ and $()\\textbf m_4- \\lambda e_4)$ are linearly dependent. It follows that its outer product must be zero:\n\\begin{eqnarray}\n\\label{eqn:characteristic_outer_product}\n(\\textbf m_1 - \\lambda e_1)\\wedge(\\textbf m_2 - \\lambda e_2)\\wedge(\\textbf m_3 - \\lambda e_3)\\wedge(\\textbf m_4- \\lambda e_4) = 0\n\\end{eqnarray}\n\nWhich is called the \\emph{charactetistic outer porduct} and is equivalent to the characteristic polynomial $P(\\lambda) = det(M - \\lambda I)$. A simple way to find the largest eigenvalue is using Newton-Raphson method $\\lambda_{i+1} = \\lambda_i - P(\\lambda) / P'(\\lambda)$. This method is indeed robust given that all eigenvalues are non-negative real numbers, it wasn't however for methods based on Davenport's matrix \\cite{Davenport1968} which eigenvalues can be negative. We found that $Trace(M)$ is a robust guess for Newton-Raphson iteration because it is larger than the largest eigenvalue and is also close enough to converge in few iterations. For the sake of completeness we show the first derivative of \\ref{eqn:characteristic_outer_product}:\n\\begin{eqnarray*}\nP'(\\lambda) = \n- e_1\\wedge(\\textbf m_2 - \\lambda e_2)\\wedge(\\textbf m_3 - \\lambda e_3)\\wedge(\\textbf m_4- \\lambda e_4)\\\\\n- (\\textbf m_1 - \\lambda e_1)\\wedge e_2\\wedge(\\textbf m_3 - \\lambda e_3)\\wedge(\\textbf m_4- \\lambda e_4)\\\\\n- (\\textbf m_1 - \\lambda e_1)\\wedge(\\textbf m_2 - \\lambda e_2)\\wedge e_3\\wedge(\\textbf m_4- \\lambda e_4)\\\\\n- (\\textbf m_1 - \\lambda e_1)\\wedge(\\textbf m_2 - \\lambda e_2)\\wedge(\\textbf m_3 - \\lambda e_3)\\wedge e_4\n\\end{eqnarray*}\n\nFollowing \\cite{DeKeninck2019} we solve the system~\\ref{eqn:eigensystem} using outer products. For a linear system $A \\textbf x = b$ the authors in \\cite{DeKeninck2019} defines $N$ linear equations of the form $A^T_j \\textbf x = b_j$ each of which corresponds to a dual hyper-plane of the form $\\textbf a_j \\equiv A_j - b_j e_0$ where the solution $\\textbf x$ must lie on. The $e_0$ is an \\emph{homogeneous} basis vector needed for enabling projective geometry, enlarging the base space to $N+1$, which interpretation is to be the offset of the hyper-plane. So solution of the linear system is the intersection of $N$ dual hyper-planes, which is given by its outer product.\n\\begin{eqnarray}\n\\alpha (\\textbf x + e_0)^* = \\textbf a_1 \\wedge \\textbf a_2 \\wedge ... \\wedge \\textbf a_N\n\\end{eqnarray}\n\nWhere the symbol $^*$ is the dual operator of the $N+1$ space and $\\alpha$ is a weight factor. After taking the dual of $\\alpha (\\textbf x + e_0)^*$ and divide by the coefficient of $e_0$ (which is $\\alpha$), the solution $\\textbf x$ can be read off the coefficients of the $1$-vector.\n\nWe know that the null space of $(M - \\lambda I)$ is of rank one. Algebraically this means that one of its column vectors is redundant i.e., it can be written in term of the others. In linear algebra this means that the system has infinitely many solutions. The geometric interpretation is that all hyper-planes intersect in a line passing through the origin. Since all solutions lie on the same line and they only differ by a scaling term, a particular solution can be found by fixing the scale. Actually, it is enough to constrain the scale of a single hyper-plane. The homogeneous component $e_0$ can be interpreted as scale of solution (instead of hyper-plane's offset as in \\cite{DeKeninck2019}) since it affects only that aspect of the solution. In linear algebra language it is equivalent to set one value at the right hand side of \\ref{eqn:eigensystem}, however that system can't be solved in linear algebra because it requires to invert a singular matrix.\n\nWe define the dual hyper-planes passing through the origin as:\n\\begin{eqnarray}\n   \\textbf a_i \\equiv \\textbf m_i - \\lambda e_i\n\\end{eqnarray}\n\nAlthough in most cases it is enough to set the scale of a single hyper-plane go get a solution it is inconvenient to do so, as will be explained in Section~\\ref{section:robustness}. It is more robust to set the scale of all hyper-planes to some $\\gamma \\neq 0$ which is a scalar value. Intersection can then be found by taking the outer product as:\n\\begin{eqnarray}\n\\label{eqn:hyperplanes_intersection}\n\\alpha (\\textbf x + 1)^* = (\\textbf a_1 + \\gamma) \\wedge  (\\textbf a_2 + \\gamma) \\wedge  (\\textbf a_3  + \\gamma) \\wedge (\\textbf a_4 + \\gamma)\n\\end{eqnarray}\n\nDistributing the outer product and keeping the terms of grade-$3$ we get:\n\\begin{eqnarray}\n\\alpha (\\textbf x + 1)^* =  \\gamma (\\textbf a_1 \\wedge \\textbf a_3 \\wedge \\textbf a_4\n+ \\textbf a_1 \\wedge \\textbf a_2 \\wedge \\textbf a_4\n+ \\textbf a_1 \\wedge \\textbf a_2 \\wedge \\textbf a_3\n+ \\textbf a_2 \\wedge \\textbf a_3 \\wedge \\textbf a_4)\n\\end{eqnarray}\n\nHere the symbol $^*$ is the dual operator of the $4$D space (not $5$D as in \\cite{DeKeninck2019} which allow us to be more efficient) and $\\alpha$ is a weight factor. After taking the dual of $\\alpha (\\textbf x + 1)^*$ the eigenvector $\\textbf x$ can be read off the coefficients of the $1$-vector. Notice that solution needs to be normalized.\n\n\\section{Optimal Computation of M}\n\nThe symmetric matrix $M_j^T M_j$ has a simple form:\n\n\\begin{eqnarray*}\n\tM_j^T M_j = \n\t\\left[\\begin{array}{cc}\n\t\t\\| s_j \\|^2        &         (s_j \\times d_j)^T \\\\\n\t\ts_j \\times d_j  &    s_j s_j^T - d_j d_j^T + \\| d_j \\|^2 I \\\\\n\t\\end{array}\\right]\\\\\n\td_j = q_j - p_j \\ \\ s_j = p_j + q_j\n\\end{eqnarray*}\n\nWriting it in terms of $p_j$ and $q_j$ we get:\n\n\\begin{eqnarray}\n   \\label{eqn:matrix_fast}\n   \tM_j^T M_j = 2\n\t\\left[\\begin{array}{cc}\n\t\tp_j^T q_j       &         (p_j \\times q_j)^T \\\\\n\t\tp_j \\times q_j  &    p_j q_j^T + q_j p_j^T - p_j^Tq_j I_{3\\times3} \\\\\n\t\\end{array}\\right]\n    + (\\| p_j \\|^2 + \\| q_j \\|^2) I_{4\\times4}\n\\end{eqnarray}\nAll terms of \\ref{eqn:matrix_fast} can be derived from the covariance matrix $B = p_j q_j^T$ plus the quantity $\\| p_j \\|^2 + \\| q_j \\|^2$. Since matrix $B$ is of $3\\times3$ its computation is more efficient than the whole \\ref{eqn:matrix_fast}. Details can be found in Section~\\ref{section:algoritms}.\n\n\\section{Robustness and Singularities}\n\\label{section:robustness}\n\nAs stated before, setting the scale of a single hyperplane is enough to get a valid eigenvector in most cases. However, the choice of which hyper-plane to constraint is problematic. For instance,  assuming input vectors without noise, constraining the hyperplane corresponding to the $w$ component of the rotor won't work because when the angle of rotation is $\\pi$ the $w = \\cos(\\pi/2) = 0$ and so its scale cannot be constrained. Similarly, constraining one of the hyper-planes corresponding to $L_1$, $L_2$ or $L_3$ won't work because when the angle of rotation is $0$ or $4 \\pi$ the $\\sin(2 \\pi) = 0$ and so on. Then, it is complex task to avoid all problematic situations. By constraining all hyper-planes as in \\ref{eqn:hyperplanes_intersection} our geometric algebra method does not suffer from any of those singularities.\n\nSome of the above mentioned singularities are present in classic methods such as QUEST \\cite{Shuster1981} and FOMA \\cite{Markley1993} but also on methods derived from those, including recent descendants based on analytic formulas \\cite{Yang2013, Wu2016, Wu2017, Wu2018FA3R, Wu2018FS3R}. All those methods are based on finding the eigenvector corresponding to largest eigenvalue of Davenport's matrix \\cite{Davenport1968}. Since that is an indefinite matrix, some eigenvalues are positive and some negative, the Newton-Raphson can fail to find the max eigenvalue (which can be negative). So significant effort has been put on finding fast and robust analytic solutions to the quartic polynomial but no advances has been made on improving robustness on finding the associated eigen-vector besides doing \\emph{sequential rotations} i.e., a $\\pi$ angle rotation of input data accomplished by changing the signs of two columns of the covariance matrix of \\cite{Shuster1981}. The QUEST method performs sequential rotations one axis at a time, until an acceptable reference coordinate system is found.\n\n\\section{Algorithms}\n\\label{section:algoritms}\n\nThe pseudo-code of proposed method is shown in Algorithm~\\ref{alg:FastRotorEstimation}. \n\n\\begin{algorithm}\n\\begin{algorithmic}[1]\n\\REQUIRE {$P = \\{p_{j}\\}_{j=1}^n, Q = \\{q_{j}\\}_{j=1}^n, C = \\{c_{j}\\}_{j=1}^n$}\n\\STATE{$S = B = 0, \\gamma = 1$}\n\\FOR{$j = 1$ \\TO $n$}\n\\STATE{$S = S + c_j (p_j \\cdot p_j + q_j \\cdot q_j)$}\n\\STATE{$B = B + c_j p_j q_j^T$}\n\\ENDFOR\n\\STATE{$\\textbf m_1 = (\\frac{1}{2}S + Tr(B)) e_1 + (B_{12} - B_{21}) e_2 + (B_{20} - B_{02}) e_3 + (B_{01} - B_{10}) e_4$}\n\\STATE{$\\textbf m_2 = (B_{12} - B_{21})e_1 + (2 B_{00} + \\frac{1}{2}S - Tr(B)) e_2 + (B_{01} + B_{10}) e_3 + (B_{20} + B_{02}) e_4$}\n\\STATE{$\\textbf m_3 = (B_{20} - B_{02})e_1 + (B_{01} + B_{10}) e_2 + (2 B_{11} + \\frac{1}{2}S - Tr(B)) e_3 + (B_{12} + B_{21}) e_4$}\n\\STATE{$\\textbf m_3 = (B_{01} - B_{10})e_1 + (B_{20} + B_{02} ) e_2 + (B_{12} + B_{21}) e_3 + (2 B_{22} + \\frac{1}{2}S - Tr(B)) e_4$}\n\\COMMENT{Newton-Raphson}\n\\STATE{$\\lambda_0 = 7 S - 3 Tr(B)$}\n\\REPEAT\n\\STATE{$\\lambda_{i+1} = \\lambda_i - P(\\lambda_i) / P'(\\lambda_i)$}\n\\UNTIL{$\\|\\lambda_{i+1} - \\lambda_i\\| < \\epsilon$}\n\\STATE{$\\textbf a_1 = \\textbf m_1 - \\lambda e_1$\n}\n\\STATE{$\\textbf a_2 = \\textbf m_2 - \\lambda e_2$\n}\n\\STATE{$\\textbf a_3 = \\textbf m_3 - \\lambda e_3$\n}\n\\STATE{$\\textbf a_4 = \\textbf m_4 - \\lambda e_4$\n}\n\\STATE{$\\textbf X = \\gamma (\\textbf a_1 \\wedge \\textbf a_3 \\wedge \\textbf a_4\n\t+ \\textbf a_1 \\wedge \\textbf a_2 \\wedge \\textbf a_4\n\t+ \\textbf a_1 \\wedge \\textbf a_2 \\wedge \\textbf a_3\n\t+ \\textbf a_2 \\wedge \\textbf a_3 \\wedge \\textbf a_4)$}\n\\STATE{$R = normalize( \\langle \\textbf X^* \\rangle_1 )$}\n\\RETURN { $R(0) + R(1) e_{12} + R(2) e_{13} + R(3) e_{23}$ }\n\\end{algorithmic}\n\\caption{Fast Rotor Estimation}\\label{alg:FastRotorEstimation}\n\\end{algorithm}\nAn optimized C++ code using the Eigen library \\cite{Eigen} and GAALOP  \\cite{Gaalop} is publicly available on GitHub \\cite{GARotorEstimator}\n\n\\section{Comparisons}\n\nWe selected several representative methods e.g. FLAE \\cite{Wu2017}, SVD \\cite{Arun1987}, QUEST \\cite{Shuster1981}, FA3R \\cite{Wu2018FA3R}, Symbolic \\cite{Wu2018FS3R}, Q-Method \\cite{Shuster1981} and FOMA \\cite{Markley1993} for comparison. The Eigen library \\cite{Eigen} was employed to implement all of them. The tests were ran on a MacBook Pro laptop with Intel Core i7 CPU running at 2,5 GHz. The Clang C++ compiler was used with -Ofast option enabled.\n\nWe first show that some methods fails on producing meaningful rotations when certain input data is provided. Table~\\ref{tab:failure_cases} shows four cases which causes error. First two cases consist of having input vectors rotated $\\pi/2$ and $\\pi$ radians without noise. Other case is when the 3D vectors are projected to the $YZ$-plane and rotated  around the $X$-axis without noise. The last case is similar but projected to the $XZ$-plane. The root mean-squared error (RMSE) is used to describe the difference of accuracy.\n\n \\begin{table} [H]\n \\centering\n \\resizebox{1.0\\textwidth}{!}{ \n \\begin{tabular}{cccccc}\n \\toprule\n {Algo}&{$\\pi/2$}&{$\\pi$}&{$YZ$Plane}&{$XZ$Plane}&{$XY$Plane}\\\\\n \\midrule\n {FLAE}&{$4.41 \\times 10^{-28}$}&{$696$}&{$392$}&{$1328$}&{$3.25 \\times 10^{-28}$}\\\\\n {Symbolic}&{$1.78 \\times 10^{-26}$}&{$1053$}&{$392$}&{$1321$}&{$4.70 \\times 10^{-27}$}\\\\\n {FA3R}&{$4.00 \\times 10^{-28}$}&{$5.41 \\times 10^{-29}$}&{$2.25 \\times 10^{-09}$}&{$2.76 \\times 10^{-08}$}&{$4.98 \\times 10^{-08}$}\\\\\n {Proposed}&{$7.32 \\times 10^{-18}$}&{$1.79 \\times 10^{-18}$}&{$4.05 \\times 10^{-28}$}&{$3.43 \\times 10^{-28}$}&{$2.22 \\times 10^{-24}$}\\\\\n {Q-Method}&{$3.78 \\times 10^{-28}$}&{$2.89 \\times 10^{-29}$}&{$7.10 \\times 10^{-28}$}&{$1.45 \\times 10^{-28}$}&{$9.57 \\times 10^{-29}$}\\\\\n {QUEST}&{$82.6$}&{$2.18 \\times 10^{-29}$}&{$6.09 \\times 10^{-26}$}&{$9.93 \\times 10^{-28}$}&{$8.36 \\times 10^{-29}$}\\\\\n {FOMA}&{$6.08 \\times 10^{-28}$}&{$2.95 \\times 10^{-28}$}&{$3.93 \\times 10^{-26}$}&{$2.13 \\times 10^{-27}$}&{$1.19 \\times 10^{-28}$}\\\\\n {SVD}&{$4.41 \\times 10^{-28}$}&{$7.51 \\times 10^{-29}$}&{$3.35 \\times 10^{-28}$}&{$9.83 \\times 10^{-29}$}&{$1.09 \\times 10^{-28}$}\\\\\n\\bottomrule\n \\end{tabular}}\n \\caption{RMSE of one million vector alignments of a thousand input vectors without noise. Some methods failed when 3D vectors were rotated $\\pi/2$ and $\\pi$  and when vectors are projected to the coordinate planes}  \n \\label{tab:failure_cases}\n \\end{table}\n\nWe also compared the robustness of the methods when input data has extreme noise applied to the length of input vectors. Figure~\\ref{fig:robustness} shows that some methods often fails to find meaningful rotations. We took SVD as reference. Notice that the amount of RMSE is almost the same on successes and on failures, evidencing that almost all methods builds, in essence, the Q-Method's matrix.\n \n\\begin{figure}[H]\n\\centering\n\\includegraphics[width=1.0\\textwidth]{robustness.png}\n\\caption{Sum of RMSE of one million vector alignments of a thousand input vectors. We applied Gaussian random noise to angles and random noise to lengths}\n\\label{fig:robustness}\n\\end{figure}\n\nAmong the compared methods SVD, Q-Method and the ours are the most robust. Performance is shown in Figure~\\ref{fig:time} compared to the other methods. Our experiments shows that when the number of input vectors is up to 1000 our method is faster than Q-Method. Beyond that point the trend shows that Q-Method is faster.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=1.0\\textwidth]{time.png}\n\t\\caption{Performance comparison: number of vectors v.s. execution time ($\\mu$s)}\n\t\\label{fig:time}\n\\end{figure}\n\n\\section{Conclusion}\n\nWe presented a novel method for estimating the best quaternion aligning two sets of corresponding vectors and bivectors. Since we maximize a convex energy functional we only deal with non-negative eigenvalues, which makes Newton-Raphson iteration robust. We find the eigenvector corresponding to the largest eigenvalue intersecting hyper-planes in the language of geometric algebra. Results shows that our method is a good alternative in terms of robustness and accuracy. Its speed is competitive when the number of input vectors is relatively small. \n\n\n\\bibliographystyle{abbrv}\n\\bibliography{rotorestimation}\n\n% ------------------------------------------------------------------------\n\\end{document}\n% ------------------------------------------------------------------------\n", "meta": {"hexsha": "e87e5b177aa131f8aefc7b2b68a04f17336977cb", "size": 29993, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "RotorEstimation/rotorestimation.tex", "max_stars_repo_name": "mauriciocele/fast-rotor-estimation", "max_stars_repo_head_hexsha": "1ee3f5a4aaee83f66e8ced209c2891b6e2045856", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-07-28T15:34:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T06:04:03.000Z", "max_issues_repo_path": "RotorEstimation/rotorestimation.tex", "max_issues_repo_name": "mauriciocele/fast-rotor-estimation", "max_issues_repo_head_hexsha": "1ee3f5a4aaee83f66e8ced209c2891b6e2045856", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RotorEstimation/rotorestimation.tex", "max_forks_repo_name": "mauriciocele/fast-rotor-estimation", "max_forks_repo_head_hexsha": "1ee3f5a4aaee83f66e8ced209c2891b6e2045856", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.512254902, "max_line_length": 1094, "alphanum_fraction": 0.6975627646, "num_tokens": 9243, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.40222616638263176}}
{"text": "\\chapter{Augmenting a Term Rewriting System through Synthesis}\n\\label{chapter:synthesis}\n\nAlthough a Halide-expression term rewriting system is necessarily incomplete, we can strengthen \nit by finding expressions on which the TRS can no longer make progress and creating \nrules that will rewrite them further.\nIn this section, we describe a workflow for automatically augmenting the Halide simplifier TRS with new rules. We evaluate the usefulness of our process by comparing synthesized rules to those written by human programmers; describing some uses of the process by Halide developers; and carrying out a large-scale experiment in synthesizing rules for the simplifier in bulk, which resulted in new rules being merged into the Halide compiler.\n\n\\section{Synthesizing rewrite rules}\n\\label{sec:synthsimplifierrules}\n\n\\begin{figure*}\n%\\includegraphics[width=1.\\columnwidth,natwidth=610,natheight=642]{figures/synthesis-flow.pdf}\n%\\includegraphics[width=1.\\columnwidth]{figures/synthesis-flow.pdf}\n\n% x_1 < select(x_2, c_0, c_1) + x_1 -> !x_2\n\n  \\tikzstyle{stage}=[fill=blue!10, draw=none, minimum height=3em, minimum width=11em]\n  \\tikzstyle{example}=[fill=orange!10, draw=none, minimum height=3em, minimum width=23em]\n  \\tikzstyle{label}=[fill=blue!10, draw=none, minimum height=3em, minimum width=1em]\n  \\begin{tikzpicture}[node distance=1.5cm,auto,>=latex']\n    \\node (s1) [stage] {\\shortstack{Input expression}};\n    \\node (s2) [stage] [below of=s1] {\\shortstack{Generated LHS\\\\patterns (Fig.~\\ref{fig:lhspatterns})}};\n    \\node (s3) [stage] [below of=s2] {\\shortstack{AC matching\\\\(Sec.~\\ref{sec:rhsacmatching})}};\n    \\node (s4) [stage] [below of=s3] {\\shortstack{Superoptimized with\\\\CEGIS (Sec.~\\ref{sec:rhssynthesis})}};\n    \\node (s5) [stage] [below of=s4] {\\shortstack{With symbolic\\\\constants (Sec.~\\ref{sec:generalizing-constants})}};\n    \\node (s6) [stage] [below of=s5] {\\shortstack{Substitute concrete\\\\values of $x_i$}};\n    \\node (s7) [stage] [below of=s6] {Candidate predicate};\n    \\node (s8) [stage] [below of=s7] {\\shortstack{Verify or find new\\\\counterexample}};\n    \\node (s9) [stage] [below of=s8] {Rule with predicate};\n    \\node (s10) [stage] [below of=s9] {Add variants (Sec.~\\ref{sec:filtering})};\n    \\node (l1) [label] [left of=s1,node distance=6em] {(a)};\n    \\node (l2) [label] [left of=s2,node distance=6em] {(b)};\n    \\node (l3) [label] [left of=s3,node distance=6em] {(c)};\n    \\node (l4) [label] [left of=s4,node distance=6em] {(d)};\n    \\node (l5) [label] [left of=s5,node distance=6em] {(e)};\n    \\node (l6) [label] [left of=s6,node distance=6em] {(f)};\n    \\node (l7) [label] [left of=s7,node distance=6em] {(g)};\n    \\node (l8) [label] [left of=s8,node distance=6em] {(h)};\n    \\node (l9) [label] [left of=s9,node distance=6em] {(i)};\n    \\node (l10) [label] [left of=s10,node distance=6em] {(j)};    \n\n    \\draw [line join=miter] (l8.west) -- ([xshift=-1em] l8.west) -- ([xshift=-1em] l6.west) -- ([xshift=-0.9em] l6.west) node {};\n    \\path[->] ([xshift=-1em] l6.west) edge node {} (l6.west);\n        \n    \\path[->] (s1) edge node {} (s2);\n    \\path[->] (s2) edge node {} (s3);\n    \\path[->] (s3) edge node {} (s4);\n    \\path[->] (s4) edge node {} (s5);\n    \\path[->] (s5) edge node {} (s6);\n    \\path[->] (s6) edge node {} (s7);\n    \\path[->] (s7) edge node {} (s8);\n    \\path[->] (s8) edge node {} (s9);\n    \\path[->] (s9) edge node {} (s10);                \n\n    \\node (e1) [example] [right of=s1,node distance=19em]\n          {$(y + 2) < \\hsel(u < z, -3, 4) + (y + 2)$};\n    \\node (e2) [example] [right of=s2,node distance=19em]\n          {\\shortstack{\n              \\color{darkgray}\n              \\tiny{$\\ldots$} \\\\\n              \\color{darkgray}\n              \\tiny{$(x_1 + 2) < x_2 + (x_1 + 2)$} \\\\\n              $x_1 < \\hsel(x_2, -3, 4) + x_1$ \\\\\n              \\color{darkgray}\n              \\tiny{$\\hsel(x_1 < x_2, -3, 4)$} \\\\\n              \\color{darkgray}\n              \\tiny{$\\ldots$}}};\n    \\node (e3) [example] [right of=s3,node distance=19em]\n          {\\shortstack{No reassociated/commuted variants \\\\ match an existing rule.}};\n    \\node (e4) [example] [right of=s4,node distance=19em]\n          {$x_1 < \\hsel(x_2, -3, 4) + x_1 \\rightarrow \\boxed{\\neg x_2}$};\n    \\node (e5) [example] [right of=s5,node distance=19em]\n          {$x_1 < \\hsel(x_2, c_0, c_1) + x_1 \\rewrites \\neg x_2$};\n    \\node (e6) [example] [right of=s6,node distance=19em]\n          {\\shortstack{\n              $0 < \\hsel(\\textit{false}, c_0, c_1) + 0 = \\neg \\textit{false} ~ \\wedge$ \\\\\n              $1 < \\hsel(\\textit{false}, c_0, c_1) + 1 = \\neg \\textit{false} ~ \\wedge$ \\\\\n              $0 < \\hsel(true, c_0, c_1) + 0 = \\neg true$ \n          }};\n    \\node (e7) [example] [right of=s7,node distance=19em]\n        {$0 < c_1 \\wedge c_0 \\le 0 $};\n    \\node (e8) [example] [right of=s8,node distance=19em]\n        {\\shortstack{\n            $\\exists~ x_1, x_2, c_0, c_1 \\;.\\; (0 < c_1 \\wedge c_0 \\le 0) ~\\wedge$ \\\\\n            $(x_1 < \\hsel(x_2, c_0, c_1) + x_1 \\neq \\neg x_2)$ ? \\\\\n            No solutions. Predicate is sufficient.\n        }};\n    \\node (e9) [example] [right of=s9,node distance=19em]\n          {$x_1 < \\hsel(x_2, c_0, c_1) + x_1 \\rewrites \\neg x_2 \\pred 0 < c_1 \\wedge c_0 \\le 0 $};\n    \\node (e10) [example] [right of=s10,node distance=19em]\n          {\\shortstack{\n              $x_1 < \\hsel(x_2, c_0, c_1) + x_1 \\rewrites \\neg x_2 \\pred 0 < c_1 \\wedge c_0 \\le 0 $ \\\\\n              $x_1 < x_1 + \\hsel(x_2, c_0, c_1) \\rewrites \\neg x_2 \\pred 0 < c_1 \\wedge c_0 \\le 0 $\n          }};\n\n\n\n    \\path[->] (e1) edge node {} (e2);\n    \\path[->] (e2) edge node {} (e3);\n    \\path[->] (e3) edge node {} (e4);\n    \\path[->] (e4) edge node {} (e5);\n    \\path[->] (e5) edge node {} (e6);\n    \\path[->] (e6) edge node {} (e7);\n    \\path[->] (e7) edge node {} (e8);\n    \\path[->] (e8) edge node {} (e9);\n    \\path[->] (e9) edge node {} (e10);\n\n  \\end{tikzpicture}\n  \\caption{Overall flow of the synthesis pipeline (in blue) with worked example (in orange). (a) We harvest expressions from real compilations on which the TRS could make no further progress. (b) We enumerate all subtrees of these to generate left-hand sides that would match each expression. Our example will focus on one such pattern. (c) We obtain a right-hand side by first checking if any reassociated or commuted variants of it match an existing TRS rule. (d) If not, we superoptimize the pattern using CEGIS. (e) This rule is specific to the particular values of any constants that appear. We then replace any constants with new variables $c_0, c_1, etc.$, to obtain a more general version of the rule. We must now synthesize a sufficient condition on these new variables under which the rule still holds. (f) To do this, we treat the rewrite as an equality and take the conjunction over a set $S$ of different values for the non-constant variables $x_0, x_1, etc.$ (g) Simplifying the result gives a candidate predicate. This is a \\emph{necessary} condition. (h) We then check if it is also \\emph{sufficient} condition using Z3. (i) If a counterexample is found, we add these new values of $x$ to $S$ to obtain a new candidate predicate and repeat until we have a sufficient condition to serve as our predicate. (j) Finally, we construct variants of the rule in which the LHS has been commuted.}\n\\label{fig:synthesis-flow}\n\\end{figure*}\n\n\nGiven an \\emph{input expression} that the TRS failed to simplify, our goal is to find a rule that\ncan rewrite it. A high-level view of the synthesis pipeline is shown in Figure~\\ref{fig:synthesis-flow}.\nAt a high level, we begin with an expression we would like to be able to further simplify, and use it to choose patterns to act as candidate LHSs for new rules. We then attempt to synthesize RHSs that match those candidates LHSs\n%and Algorithm~\\ref{alg:synthesis-algorithm} shows the corresponding pseudocode.\nWe begin with an expression we will attempt to further simplify; \nfirst, we synthesize rules that contain concrete constants from the input expression. \nNext we generalize those rules by replacing constant values with symbolic constants and synthesizing compile-time \npredicate guards \nthat check the validity of the rule on the values matched by the symbolic constants. If we \nfind such a rule, we know that adding it to the TRS will enable it to simplify the input\nexpression as well as any similar expressions it may encounter.\n\n\n\n\n\n\n\\subsection{Generating LHS Patterns}\n\nUseful input expressions may come from a bug report, or may be gathered from compiler logs. With logging enabled, the compiler records two\nkinds of problematic expression for which new simplifier rules may be helpful:\nnon-monotonic expressions, which can result in over-conservative\nbounds for loops and memory allocations; and proof failures,\nwhich may prevent Halide from performing certain optimizations\n(see Section~\\ref{sec:uses-of-trs}). \nOf course, absent an oracle, it is difficult to know if the TRS has fully simplified \nsome expression or if it lacks the solving power to continue simplification. \nWhen the simplifier is used as a proof engine, its goal is to reduce an expression to true.\nIn this case, we can fuzz-test failed proofs by assigning all variables in an expression\nrandom values and evaluating; if we cannot find an assignment that evaluates to false,\nthe expression may indeed be reducible to true, so we log it as an input expression.\n\n  Our first step is to find LHS terms that could match the input expression, or any portion of it. \nWe can enumerate all such terms through a kind of inverse matching.\nWhen we rewrite an expression with a rule, \nwe match the expression to the rule's LHS by finding a substitution for all variables in\nthe LHS that will unify it with the input expression. Here, we start with an input expression,\nthen fix a substitution by mapping some of its subterms to fresh variables. We \nreplace those subterms with the new variables, constructing a term that can \nbe matched with the input term.\nIf we perform this inverse matching for all sets of subterms, we find \\emph{all possible LHSs} that could match the\ninput expression. \nWhen a subterm occurs more than once in the input expression, we construct a LHS that \nuses the same variable to replace it in multiple places and LHSs that replace its\noccurrences with different variables.\nWe repeat the procedure on all \\emph{subterms} of the input expression.  The result is the set of all \nLHSs that match any part of the input expression. See Figure~\\ref{fig:lhspatterns} for a worked example.\n\n\\begin{figure*}\n\\begin{tabular}{lll}\n\\begin{tikzpicture}[level distance=12mm,baseline=(current bounding box.center)]\n\\tikzstyle{level 1}=[sibling distance=15mm]\n\\tikzstyle{level 2}=[sibling distance=8mm]\n\\tikzstyle{level 3}=[level distance=10mm,sibling distance=5mm]\n\n% tried to label subtrees but positioning looks weird, fix later\n\\node (+) {+}\n  child { node (+2) {+}\n    child { node (z) {z}  } % edge from parent node[left,draw=none] {$v_1$}\n    child { node (2) {2} }}\n  child { node (min) {\\hmin}\n    child { node (x) {x}}\n    child { node (-) {-} %edge from parent node[right,draw=none] {$v_2$}\n      child {node (y) {y}}\n      child {node (z1) {z} } % edge from parent node[right,draw=none] {$v_3$}}\n    }};\n\n\n\\begin{pgfonlayer}{background}\n\\fill[red,opacity=0.3] \\convexpath{x, min, z1, y}{10pt};\n\\fill[blue,opacity=0.3] \\convexpath{y, -, z1}{10pt};\n\\fill[green,opacity=0.3] \\convexpath{z, +2, 2}{10pt};\n\\end{pgfonlayer}\n\\end{tikzpicture} &\n\\begin{tabular}{llll}\n$(z + 2) + \\hmin(x, y - z)$ & $\\hmin(x, y - z)$ & $z + 2$ & $y - z$ \\\\\n$v_1 + \\hmin(x, y - z)$ & $\\hmin(x, v_2)$ & & \\\\\n$v_1 + \\hmin(x, v_3)$ & & & \\\\\n$(z + 2) + \\hmin(x, v_3)$ & & & \\\\\n$v_1 + v_2$ & & &\n\\end{tabular}\n\\end{tabular}\n\\caption{Given the input expression $(z + 2) + \\hmin(x, y - z)$, we find all possible \nLHS patterns by substituting fresh variables for subterms, for all valid combinations. Then, we repeat the process for \neach individual subterm. This process yields the list of candidate LHS terms on the right.}\n\\label{fig:lhspatterns}\n\\end{figure*}\n\nThis number of LHSs is exponential in the size of the input expression, so we use a few heuristics to narrow \nour search. We bound the size of candidate LHSs to have seven or fewer leaves, since longer terms are less likely to \nresult in rules general enough to justify inclusion in the ruleset. \nAdditionally, since we process input expressions in batches, we remove \nduplicate LHSs as well as LHSs that differ only in the values of their constants. \nFinally, we have found it helpful to keep a blacklist of LHSs for which we previously\nfailed synthesize rules; for example, $v_1 + v_3$ \ncannot form a rule, so we filter it out as a candidate.\n\n\\subsection{Synthesizing Right-Hand Sides} \n\\label{sec:synthesizing-candidate-rules}\n%\nGiven a candidate left-hand side, we attempt to \nsynthesize a right-hand side that is semantically equivalent and\nrespects the simplifier reduction order, such that $\\mathit{LHS} > \\mathit{RHS}$.\nWe employ two strategies for synthesizing right-hand sides:\ndelayed AC matching, and counter-example guided inductive synthesis (CEGIS) of \nthe RHS followed by synthesis of the rule predicate guard.\n\n\\subsubsection{Finding Right-Hand Sides through AC Matching}\n\\label{sec:rhsacmatching}\nThe first strategy reflects the Halide design decision not to perform any AC matching in the TRS, for efficiency reasons. \nInstead, AC matching can effectively performed through adding additional rules. It is possible that our candidate LHS, which currently cannot be rewritten by the simplifier rules, could be matched by an existing rule after a suitable application of associativity and commutativity laws to the LHS. \nTo this end, we generate all possible reassociations and commutations of the candidate LHS term and pass them to the existing TRS. \nIf any of them can be simplified, we create a new rule that rewrites \nthe original, untransformed LHS term to the result of the simplification.  Note that this result may include applications of more than one rewriting step, so the new rule is not merely an AC-variant of an existing rule.\n\nFor example, assume our TRS includes the rule $(x + y) - x \\rewrites y$, \nand let $((u + 2) + v) - u$ be a candidate LHS term. The rule does not match the candidate but it matches its variant $(u + (v + 2)) - u$, rewriting it to the result $v + 2$. The candidate and the result give us the rule $((u + 2) + v) - u \\rewrites v + 2$.\n\nWe can consider this procedure a kind of lazy offline AC matching, because if the Halide TRS \nperformed full AC matching while rewriting expressions, it would be able to apply the rule $(x + y) - x \\rewrites  y$ to the candidate expression $((u + 2) + v) - u$ after reassociating it to $(u + (v + 2)) - u$, obtaining the result $v + 2$.  Delaying AC matching to synthesis has the effect of restricting the system to a single, offline round of AC and memoizing the result in the form of a new TRS rule if we are successful. \nNote that the synthesis procedure below could have found this rule, but checking for AC\nvariants of existing rules is far cheaper. About three-quarters of our synthesized rules are generated by this method.\n\n\\subsubsection{Finding Right-Hand Sides through CEGIS}\n\\label{sec:rhssynthesis}\nIf the first method fails, we apply counterexample guided inductive synthesis (CEGIS)~\\citep{DBLP:conf/aplas/Solar-Lezama09} to superoptimize the left-hand side pattern.\nIn superoptimization~\\citep{massalin1987superoptimizer}, we take a program and search \nfor an equivalent program within some grammar that is preferable according \nto some cost function. Here our grammar is that of the Halide expression language, \nthe method for testing program equivalence is the Z3 solver, and we use the node\ncount of the programs as a proxy for our full reduction order. \\newpage\n\nSimilar to prior work in superoptimization~\\citep{regehr2018superoptimization, mangpo2016superoptimization},\nwe search the expression space for an equivalent RHS using a CEGIS loop. This loop alternately calls Z3 as a\nverifier, which checks if a candidate RHS is equivalent to the LHS on all inputs, \nand a learner, which finds a candidate RHS that is equivalent to the LHS on\na limited set of inputs.\nWe begin by choosing a single-op\nRHS and ask the verifier if it is equivalent to the LHS. If it is not, we get back \na counterexample of assignments to the variables for which the right- and left-hand side are \nnot equivalent, which we keep as a set of test inputs. \nWe then ask the learner for a new RHS that is equivalent to the LHS \nonly on the counterexample assignments we found in the last step. \nIf we cannot find an equivalent single-op sequence,\nwe iteratively increase the number of operations, ensuring we find shorter sequences\nfirst.  If CEGIS returns a sequence semantically equivalent to the LHS pattern with fewer\noperations, we use it together with our LHS to form a candidate rule.\n\n The learner portion of the CEGIS loop creates a candidate RHS\n  %expression from a parameterized bytecode\n  %sequence of fixed size that is fed to an interpreter. Each bytecode\n  %instruction takes parameters that select between the possible operators and\n  %operands available to it. Thus,\n  %this bytecode\n  %sequence serves as an SSA representation of an expression tree. The\n  %interpreter is evaluated abstractly on symbolic inputs to produce a\n  %sketch~\\citep{DBLP:conf/aplas/Solar-Lezama09, torlak2014lightweight}, \n  %capable of acting as any Halide expression in our\n  %search space depending on the bytecode values. The learner uses Z3\n  by creating a sketch~\\citep{DBLP:conf/aplas/Solar-Lezama09, torlak2014lightweight}\n  that consists of a small bytecode interpreter that encodes the possible\n  operations and operands the RHS can use, along with a bound on the number of instructions.\n  The learner uses Z3 to query for a sequence of bytecodes within the bound, that, when\n  run through the interpreter, is semantically\n  %solve for the bytecode values that makes the sketch semantically\n  equivalent to the LHS over the test inputs. If a solution is found,\n  substituting the produced bytecode values into the sketch\n  and applying the TRS reduces it to a concrete candidate RHS. One\n  complication arising from this approach is that a bytecode sequence\n  of a fixed number of ops may produce expression trees of a larger\n  size if intermediate values are reused. We reject any such solutions\n  in a post-pass by checking each synthesized RHS against the LHS\n  using the full reduction order. An alternative solution would be\n  introducing let bindings into our search space so that the size of\n  the expression tree could be bounded by the number of ops in its SSA\n  form. However, we could not identify any significant rewrite rules\n  lost to this filtering, so we deemed this an unnecessary\n  complication. \n\nWhile Z3 is a powerful tool for synthesis, there are certain types of expressions \ncontaining division or modulo that Z3 nearly always fails to reason about during the CEGIS process. (We experimented with the SMT solvers Yices2~\\citep{jovanovic2017solving} and MathSAT5~\\citep{mathsat5}, but were not able to obtain appreciably better results.)\nZ3 is better able to reason about expressions containing concrete constants, rather than\nuniversally quantified variables, so we synthesize rules using candidate LHSs with \nconcrete constants from the input expression and generalize them later.\nWe limit the use of division and modulo in our op-codes to be division\nor modulo by 2 only, and rely on the generalization step described next to\nwiden the set of denominators for which a rule applies.  Because of this\nrestriction, our synthesized rules cannot contain non-constants in denominators\nor the right-hand side of a modulo.  As a result, our synthesis system cannot\nconstruct all rules a human can.\n\n\\begin{table*}\n\\caption{Sample rules synthesized by our process. }\n\\small\n\\begin{tabular}{l|l|l}\nLHS & RHS & Predicate \\\\\n\\hline\n$(x*y) - (z + (w*x))$ & $(x*(y - w)) - z $ & \\\\\n$x < (y + x) + z$ &  $0 < (y + z)$ & \\\\\n$\\hmax(x*x, y) + \\hmax(z, w*w) < c_0$ & false & $c_0 <= 0$ \\\\\n$\\hsel(x, c_0, y) < \\hmin(\\hsel(x, c_1, y), c_2)$ & false & $\\hmin(c_1, c_2) <= c_0$ \\\\\n$\\hmin((x + ((y - x)/c_0)*c_0) + c_1, y)$ & $y$ & $1 <= c_1 \\wedge -1 <= (-1/c_0)*c_0 + c_1$ \\\\\n\\end{tabular}\n\\label{tab:samplerules}\n\\end{table*}\n\n\\subsection{Generalizing Constants and Finding Predicate Guards}\n\\label{sec:generalizing-constants}\n\nIf either AC-matching search (section~\\ref{sec:rhsacmatching}) or CEGIS-based synthesis (section~\\ref{sec:rhssynthesis}) were successful, \nwe now have a candidate rewrite\nrule that contains concrete values originating from the input expression.\nTo generalize the rule, we replace such constants with fresh \\emph{symbolic constants} \nand synthesize a guard that is true when the rule is valid. \nRecall that in the Halide TRS, a variable in the LHS matches any subterm, while a \nsymbolic constant matches only a constant value (see section~\\ref{sec:customalgo}); the guards, which are predicates over symbolic constants, can thus be evaluated at compile time. \n\nOur goal is to generalize the equality by synthesizing a guard predicate $\\phi$ \nover the symbolic constants in the LHS and RHS terms such that our rule is valid whenever\n$\\phi$ evaluates to true:\n\\[ \\forall \\vec{c} \\forall \\vec{x} \\;.\\; \\phi(\\vec{c}) \\implies LHS(\\vec{x},\\vec{c}) = RHS(\\vec{x},\\vec{c})\n\\]\n\nFirst, we check to see if this condition is satisfied when $\\phi$ is \nalways true. If it is, then no predicate guard is needed. Otherwise, we need \nto synthesize an expression for $\\phi$. We find candidates for $\\phi$ iteratively \nby first choosing a small set of values $S$ for the variables \nin $\\vec{x}$ and finding the candidate guard $\\phi_S$. We check to see if $\\phi_S$\nis a sufficient predicate guard for all $\\vec{x}$; if it is not, we add\ncounterexamples to the set $S$ and repeat.\n\n\\[ \\forall \\vec{c} \\forall \\vec{x} \\in S \\;.\\; \\phi_S(\\vec{c}) \\implies LHS(\\vec{x},\\vec{c}) = RHS(\\vec{x},\\vec{c})\n\\]\n\nWe initialize $S$ with all basis vectors, which are \nvalues $\\vec{x} = ( 0, \\ldots, 0, 1, 0, \\ldots, 0 )$ that include exactly one unit value,\nplus the zero vector.  \nWe then unwind the right-hand side of the implication and substitute in the concrete values \nfrom $S$ to get:\n\n\\[ \\forall \\vec{c} \\forall \\vec{x} \\in S \\;.\\; \\phi_S(\\vec{c}) \\implies (LHS(\\vec{x_1},\\vec{c}) = RHS(\\vec{x_1},\\vec{c}) \\wedge \\ldots \\wedge\nLHS(\\vec{x_k},\\vec{c}) = RHS(\\vec{x_k},\\vec{c}))\n\\]\n\nWe use the Halide TRS itself to simplify the conjunction on the right-hand side of the\nimplication. Since all occurrences of $\\vec{x}$ have been replaced with concrete\nvalues, we get back an expression that contains only symbolic constants, which we\nuse as our candidate guard $\\phi_S$.\n\nWe test whether $\\phi_S$ is sound on all $\\vec{x}$.\n\\[ \\exists \\vec{c} \\; \\exists \\vec{x} \n   \\;.\\; LHS(\\vec{x},\\vec{c}) \\not= RHS(\\vec{x},\\vec{c})\n\\]\n\nIf this query has a solution $\\vec{x}$, then the guard is unsound.  \nIf so, we add the counterexample $\\vec{x}$ to $S$, and construct a new guard $\\phi_S$.  \nWe repeat this process for several iterations (four, in our experiments) and if \nwe fail to find a sound guard, we switch to an alternative strategy that converts \nthe current (unsound) candidate $\\phi_S$ to disjunctive normal form and tests\neach clause in turn to check if it is a sufficient guard.\nIf it is, that clause becomes the guard.  If no clause is sound, we discard the rule.\nIf the loop terminates with Z3 timing out or returning ``unknown'', we return\nthe current $\\phi_S$, flagging it as requiring a manual proof. \nWe exclude all such cases from our experiments.\n\n\nAs an example, consider the candidate rule:\n%\n\\[ x_0 < \\hsel(x_1, c_0, c_1) + x_0 \\rewrites \\neg x_1\n\\]\nWe initialize $S$ with three basis vectors $\\{(0,\\mathit{false}), (0,\\mathit{true}), (1,\\mathit{false})\\}$ and construct $\\phi_S$:\n%\n\\begin{equation*}\n\\begin{split}\n \\phi_S(\\vec{c}) \\iff \n &  \\forall_{\\vec{x} \\in S} \\;.\\; LHS(\\vec{x},\\vec{c}) = RHS(\\vec{x},\\vec{c}) \\\\\n \\iff & \n 0 < \\hsel(\\mathit{false}, c_0, c_1) + 0 = \\neg\\mathit{false} \\; \\wedge \\\\\n                                                   & 0 < \\hsel(\\mathit{true}, c_0, c_1) + 0 = \\neg \\mathit{true}  \\; \\wedge \\\\\n                                                   & 1 < \\hsel(\\mathit{false}, c_0, c_1) + 1 = \\neg\\mathit{false}\n\\end{split}\n\\end{equation*}\n\nSimplifying the RHS with the TRS, we obtain $\\phi_S$:\n%\n\\[  \\phi_S(\\vec{c}) \\iff 0 < c_1 \\wedge c_0 \\le 0\n\\]\n\nNext we check whether $\\phi_S$ is sound for all $\\vec{x}$.  It is, so we have a completed rule:\n\n\\[ x_0 < \\hsel(x_1, c_0, c_1) + x_0) \\rewrites \\neg x_1 \\;\\pred \\;0 < c_1 \\wedge c_0 \\le 0\n\\]\n\n\n\\subsection{Adding Rule Variants}\n\\label{sec:rulevariants}\nOnce we have a generalized rule with a valid predicate, we eagerly compensate for the lack\nof AC matching in the Halide TRS by adding AC variants of the rule as well. We find \nall commuted variants of the rule's LHS,\nwith respect to the partial commutative canonicalization as described in Section~\\ref{sec:customalgo}.\n (This is exponential in the size of the number \nof commutative operators, which is tractable given our bounds on LHS term size). \nThen, we find all reassociations of the rule's right-hand side. For each variant LHS, \nwe choose a RHS variant by serializing expressions to strings and finding the RHS \nthat has the shortest edit distance from that LHS.\n\nFor example, the LHS of the first rule below has four additions and can be commuted \nto 16 variants. The RHS of the rule can be reassociated in two different ways. For the \ncommuted variant of the LHS on the second line, we choose the other means of reassociating\nthe RHS as it has a smaller edit distance.\n\n\\begin{equation*}\n\\begin{split}\n(x + (y - ((z + (w + x)) + u))) & \\rewrites y - (z + (w + u))) \\\\\n(y - (((w + x) + z) + u)) + x & \\rewrites y - ((z + w) + u)\n\\end{split}\n\\end{equation*}\n\nThe intuition is that there is no a priori reason \nto prefer one reassociated variant to another; they are almost certainly equal in \nterms of our reduction order. Thus, we choose the RHS that perturbs the structure of the \nLHS as little as possible, in order to avoid rewriting common subexpressions in the hopes\nof canceling them out later.\n\n\n\\subsection{Filtering Rule Output}\n\\label{sec:filtering}\nAs a final step, we check each output rule for redundancy with the rule batch found\nby the synthesis pipeline. For each new rule, we check\nthat no earlier rule has precisely the same LHS and predicate; if so, it can be discarded.\nThen, we check that no earlier rule is more general than the current rule: a rule is more \ngeneral than another if they have similar LHSs, but a variable appears in the first rule \nin a place where the second rule has a more specific subterm, or if they have the same LHS\nbut the predicate of the first rule implies the predicate of the second.\n\nFinally, we\ncheck that the candidate rule obeys our reduction order in order to\npreserve our termination guarantee. If the candidate rule passes these\nfilters, and the predicate has not been flagged for human review, the\nrule can be added to the TRS ruleset automatically without any human\nauditing.\n\n\\section{Evaluation of Simplifier TRS Synthesis}\n\\label{sec:evaluation}\n\n% (1186-367)/1186\n\\newcommand{\\PercentPossibleToSynth}{69\\%}\n\\newcommand{\\NumRulesInCorrectnessExperiment}{321}\n\\newcommand{\\PercentRulesResynthesized}{58\\%}\n\nIn evaluating the benefits of the verifier and synthesizer, we answer the following questions:\n\n\\begin{itemize}\n  \\item \\textbf{Does the synthesizer produce better rules than a human expert?} The TRS has been manually extended five times in response to bug reports pointing out limitations of the compiler. We synthesized these five rulesets automatically and found that the human-authored rules were less general and in one case were incorrect. (Section~\\ref{sub:bugfixes})\n \n  \\item \\textbf{What is the best way to use synthesis and verification in development?} We survey several cases from recent Halide development where human experts used the synthesis machinery as an assistant, finding that this hybrid model is more powerful than either the human developer or the synthesizer alone. (Section~\\ref{sub:synthassistant})\n  \\item \\textbf{Can synthesis be used for large-scale improvements of the TRS?} We gather a corpus of over 100,000 expressions on which the TRS can make no progress and iteratively synthesize rules using the corpus as input. We synthesize \\NumRulesSynthesized  rules and add them to the TRS ruleset without a human audit. We find that the enhanced ruleset reduces peak memory usage in compiled code, sometimes dramatically, in 197 of our benchmarks. We also find no significant compile-time slowdown even with this 4.5-fold increase in ruleset size. (Section~\\ref{sub:endtoendexperiment})\n  \\item \\textbf{Could the entire TRS have been synthesized?} Encouraged by the large-scale experiment, we ask how far we are from being able to bootstrap the entire TRS automatically---something that we considered too ambitious originally. First, we find that \\PercentPossibleToSynth~of the existing ruleset is accessible to our current synthesizer in principle; the remaining rules contain operators not yet supported by the tool. % or cannot be reasoned about automatically by our solver. \n  We test the synthesizer's power by removing \\NumRulesInCorrectnessExperiment{} accessible rules from the original ruleset one by one and attempting to synthesize a replacement, successfully finding a replacement rule \\PercentRulesResynthesized{} of the time.  We find this encouraging for future applications of the synthesizer. (Section~\\ref{sub:replacementexperiment})\n\\end{itemize}\n\nWe discuss these findings in more detail below, grouping them into three sections. First we examine bug reports from Halide’s past and evaluate whether the machinery presented in this paper could have fixed them automatically. Second, we examine cases where beta versions of our verifier and synthesizer assisted humans both in fixing bugs and in correctly making larger changes to the compiler. Third, we fuzz the compiler to mine for issues that could be fixed with new simplifier rules, and automatically fix them before they ever appear as a bug in a real program. In this way we demonstrate that this machinery would have been useful in the past, is useful in the present, and will help avoid entire classes of bugs in the future.\n\n\\subsection{Comparing the Synthesizer to Human-Authored Rules}\n\n\\subsubsection{Does the Synthesizer Produce Better Rules than a Human Expert?}\n\\label{sub:bugfixes}\n\n%We expect a human expert to create rules that are as general as possible while also including rules that take advantage of less general situations, such as when special cases allow stronger rewrites.  Can a synthesizer produce rules that are both general and expressive? \n\n%We compared synthesized rules against five sets of rules added manually. We have found that the expert wrote rules that were less general than the synthesized rules, and in some cases were incorrect. Additionally, the synthesizer avoided adding a specialized rule because the TRS could already achieve its effect with rules present in the TRS. We discuss in Section~\\ref{sec:limitations} the limitations of when the synthesizer cannot achieve such general rules. \n\n% AA: I found the two paragraphs above redundant with the summary we just gave in the itemized list.\n\n\n% A) https://github.com/halide/Halide/pull/3719\n% B) https://github.com/halide/Halide/pull/3761\n% C) https://github.com/halide/Halide/pull/3765\n% D) https://github.com/halide/Halide/pull/3770\n% E) https://github.com/halide/Halide/pull/3780\n% F) https://github.com/halide/Halide/pull/4721\n% G) https://github.com/halide/Halide/pull/4772\n% H) https://github.com/halide/Halide/pull/4439\n% I) https://github.com/halide/Halide/pull/4850 \n\n\nWe searched through Halide’s change history and selected the five pull requests that addressed issues by adding new rewrite rules to Halide’s TRS. These pull requests occurred before the Halide developers started routinely using the verifier and synthesizer when changing the TRS, labeled here as $\\mathbb{A}$-$\\mathbb{E}$. These can be found in their original form as patches on the Halide project website\n\\footnote{\n$\\mathbb{A}$: \\url{https://github.com/halide/Halide/pull/3719} \\\\\n$\\mathbb{B}$: \\url{https://github.com/halide/Halide/pull/3761} \\\\\n$\\mathbb{C}$: \\url{https://github.com/halide/Halide/pull/3765} \\\\\n$\\mathbb{D}$: \\url{https://github.com/halide/Halide/pull/3770} \\\\\n$\\mathbb{E}$: \\url{https://github.com/halide/Halide/pull/3780} \n}.\nCreating these rewrite rules as a human is an amount of work disproportionate to the size of the change. The author of the rules must prove them correct on paper, and a second reviewer must check their work. As we will see, bugs can slip through despite this review. \n\nIn each case we take the test expressions committed as part of the change and feed them to our synthesizer to see if it would have produced the same rewrite rules as the humans did. In cases where humans did not check in tests for their new rules, we wrote our own. In total, across these five cases humans added 24 new rules. The synthesizer generated 42, covering all but one of the human rules, while correcting and generalizing others. In cases $\\mathbb{A}$, $\\mathbb{C}$, and $\\mathbb{E}$, the rules generated by the synthesizer are an exact match to the human-generated rules. In case $\\mathbb{B}$ the synthesizer matched the human but also crafted 8 commuted variants of the human rules, making them more widely applicable. \n\nAs an example, for the human-written rule:\n\n\\[\n\\hmax(\\hmax(x, y) + c_0, x) \\rewrites \\hmax(x, y + c_0) \\pred c_0 < 0\n\\]\n\nThe synthesizer produced effectively the same rule, along with a variant:\n\n\\begin{align*}\n& \\hmax((\\hmax(x, y) + c_0), x) \\rewrites \\hmax((y + c_0), x) \\pred c_0 \\leq 0 \\\\\n& \\hmax(x, (\\hmax(x, y) + c_0)) \\rewrites \\hmax(x, (y + c_0)) \\pred c_0 \\leq 0\n\\end{align*}\n\nCase $\\mathbb{D}$ is the most interesting. It contains four rules involving comparisons of $\\hmin$ and $\\hmax$ operations. What happened for each was identical, so we will only discuss the $\\hmin$ rules. The first rule is:\n\n\\[\n\\hmin(x, c_0) < \\hmin(x, c_1) + c_2 \\rewrites \\hfalse \\pred c_0 \\geq c_1 + c_2)\n\\]\n\nThis rule is incorrect (consider $c_0 = c_2 = 1$, $x = c_1 = 0$). It can be fixed by adding the term $c_2 \\leq 0$ to the predicate. The synthesizer produced the correct version of this rule, along with two generalizations of it:\n\n\\begin{align*}\n& \\hmin(x, c_0) < \\hmin(x, c_1) + c_2 \\rewrites  \\hfalse \\pred c_2 \\leq 0 \\wedge c_1 + c_2 \\leq c_0 \\\\\n& \\hmin(x, c_0) < \\hmin(x, y) + c_1 \\rewrites c_0 - c_1 < \\hmin(x, y) \\pred c_1 \\leq 0 \\\\\n& \\hmin(x, c_0) < \\hmin(y, x) + c_1 \\rewrites c_0 - c_1 < \\hmin(y, x) \\pred c_1 \\leq 0\n\\end{align*}\n\nThe second human rule was:\n\\[\n\\hmin(x, c_0) < \\hmin(x, c_1) \\rewrites \\hfalse \\pred c_0 \\geq c_1\n\\]\nThe synthesizer found a more general rule, along with three other commuted variants (elided for space):\n\\[\n\\hmin(x, y) < \\hmin(x, z) \\rewrites y < \\hmin(x, z)\n\\]\nAny expression which matches the human-written rule would also match the synthesized one. The synthesized version does not simplify to the constant false in a single step. However, after applying this rule to the case considered by the human, we get $c_0 < \\hmin(x, c_1)$ where $c_0 \\geq c_1$. The simplifier then reduces this to false in a second step, so the human-written rule becomes unnecessary. The synthesizer considered the human-written rule, but discarded it as less general than the one above.\n\nCase $\\mathbb{D}$ also included the rewrite rule: \n\\[\nx\\; \\%\\; x \\rewrites 0\n\\]\nwhich was the sole rule the synthesizer could not generate, as we did not include modulo by non-constants in our CEGIS interpreter.\n\nWith this one exception, across these five code changes the synthesizer generated more general, more correct rules than the humans, and would clearly have been a useful assistant to the Halide developers if they had had it at the time.\n\n\n\\subsubsection{What Fraction of the Halide Rules Could Have Been Synthesized?}\n\\label{sub:replacementexperiment}\nIf the simplifier ruleset had not yet been written by hand, would it have been possible to synthesize it automatically? Given the space of possible rewrites explored by the synthesizer, we believe that it can currently produce at most \\PercentPossibleToSynth{} of rules that exist in the current TRS. The obstacles to synthesizing all human-written rules include (i)~the inability to automatically verify some rules or preconditions (see Question 3 above); and (ii)~lack of support for some operators in our synthesizer. \n\nWe tested the synthesizer's ability to recreate the original ruleset in the following experiment. We instrumented the ruleset to associate expressions from compilations of Halide's correctness test suite with individual rules invoked when those expressions are rewritten. We gathered a set of rules for which we had at least three expressions that matched the rule, and filtered out those rules that are out of scope for the current synthesizer, because their right-hand sides contain operators we do not support. This gave us a set of \\NumRulesInCorrectnessExperiment{} rules. For each of these rules, we disabled the rule in the TRS, then used its matching expressions as input to the synthesizer. The synthesizer was able to find rules in 186 cases, or about \\PercentRulesResynthesized{} of the rules. Of the other 135 cases, in 43 of them other rules in the existing TRS happened to combine to rewrite the specific input expression even without the target rule; for example, this often occurred when the matching expression contained combinations of constants that could be exploited by other rules. 10 of the 92 failure cases were due to timeouts in the synthesis process, while 15 specifically failed to synthesize a predicate. Given that it was difficult to target the desired rule precisely, we found this to be promising; efforts to synthesize a term rewriting system entirely from scratch are described in chapter~\\ref{chapter:synthfromscratch}.\n\n\n\\subsection{Practical Uses of the Synthesizer and Verifier}\n\n\n\n\n\n\\subsubsection{What is the Best Way to Use Synthesis and Verification in Development?}\n\\label{sub:synthassistant}\n\n% Is the expert equipped with the synthesizer better at developing rules than either the expert alone or the synthesizer alone? The synthesizer can accelerate rule development because it is correct by construction and also faster than a human expert. On average, the expert needed about 30 minutes to develop a rule, including a paper proof and the code review. Our synthesizer typically produces a batch of ten (verified) rules in about 5 minutes.\n\nWe have found that human experts can leverage the strengths of the synthesis tool by using it as an assistant: for example by synthesizing a rule and then generalizing or simplifying it by hand, or by writing a rule and asking the tool to synthesize a valid predicate. Most importantly, this avoids committing new bugs, but it also accelerates rule development. Halide developers report that adding new rules by hand takes about 30 minutes per rule starting from sample input expressions through final review. Starting from the same input expressions, the synthesis tool can produce a batch of 10 verified rules in about 5 minutes.\n\nHere we survey some cases from recent Halide development where the synthesis machinery was used in this way, labeled here as $\\mathbb{F}$ through $\\mathbb{I}$. The diffs are available as  on the Halide project website\\footnote{\n$\\mathbb{F}$: \\url{https://github.com/halide/Halide/pull/4721} \\\\\n$\\mathbb{G}$: \\url{https://github.com/halide/Halide/pull/4772} \\\\\n$\\mathbb{H}$: \\url{https://github.com/halide/Halide/pull/4439} \\\\% these are the div by 0 semantics change fixes\n$\\mathbb{I}$: \\url{https://github.com/halide/Halide/pull/4850}\n}.\n\nIn case $\\mathbb{F}$ a Halide developer encountered expressions that seemed like they could be simpler while working on real code, and rather than inventing a rule from scratch searched the logs of the synthesizer project for a known-correct synthesized rule that handled the case in question. This added four new rules that are variants of:\n\\[\n\\hmax(y, z) < \\hmin(x, y) \\rewrites \\mathit{false}\n\\]\nIn case $\\mathbb{G}$ a developer wrote 24 new rules, proving them on paper, and then checked their work by resynthesizing the predicates using the synthesizer, ensuring that the synthesized predicates agreed with the human’s and that those predicates were as broad as possible. Here the synthesis machinery served as a reviewer of rules rather than an author. Eight of these rules were in fact manual rederivations of the synthesizer’s output on case $\\mathbb{D}$ above. The remaining 16 are generalizations that add constant terms. One example:\n\\[\n\\hmin(y + c_0, z) < \\hmin(y, x) \\rewrites \\hmin(z, y + c_0) < x \\pred c_0 < 0\n\\]\n\nHalide endeavors to be a safe language, meaning that certain things are checked at compile time or runtime rather than being undefined behavior. In case $\\mathbb{I}$, Halide was changed such that instead of asserting that no output value has a dependency on any out-of-bounds input values, it now asserts the stricter condition that no out-of-bounds loads occur on the input, even if those loaded values cannot possibly affect an output.\n\nThis is a harder thing for the compiler to check, and analysis often conservatively found that it was possible for code to read out of bounds, when in fact it would not. The Halide developers ameliorate this in part by minimizing the number of non-monotonic expressions using aggressive simplification. In total 59 new rewrite rules were added as part of this change. Eight of these were synthesized automatically by copy-pasting a non-monotonic expression from a bug report into the synthesis machinery. Another 28 came from generalizing those rules by hand and then verifying the result. Twenty more were written by hand and then verified. Finally, there were three rules that could not be verified, because they involve the interaction of division and modulus. During this process a large number of bugs were found in human-written early versions of these rules. We found that with the verifier and synthesizer in hand, humans work quickly and rely on the machinery to catch their mistakes.\n\nGeneralizing from these four cases, we have found that having the verifier and synthesizer available as tools reduces the number of bugs committed, uncovers and fixes old bugs, and helps developers work more quickly by not only mechanizing correctness checking but also by synthesizing correct code. We also found that the guarantees these tools provide mean that the developers can make large changes to the compiler with confidence. Anecdotally, developers also report that eliminating these classes of bug makes triaging new issues simpler, because they could now not possibly be due to an incorrect rule or an infinite loop in the term rewriting system.\n\n\\subsection{Using the Synthesizer to Prevent Future Issues}\n\\label{ssec:compilationspeed}\n\n\\subsubsection{Can Synthesis be Used for Large-scale Improvements of the TRS?\\nopunct}\n\\label{sub:endtoendexperiment}\n%What improvements are possible when we allow the synthesizer to learn rules from a large body of input, without human supervision? In this experiment, rather than synthesizing a repair to just one incorrect rule, we attempted to synthesize rules for over 100,000 expressions that failed to simplify over thousands of instrumented compilations. We synthesized 4127 rules and added them to the TRS. In evaluating the effects of these improvements, we found 197 benchmarks that were over-allocating memory, sometimes dramatically, due to imprecise bounds reasoning caused by missing rules. Those benchmarks were fixed by the improved TRS. Synthesis allowed us to make this dramatic change to the ruleset without fear of introducing non-terminating behavior, since synthesized rules must satisfy the reduction order (see Section~\\ref{sub:termination}). Satisfying this additional restriction would further complicate manual rule development. \n\n%% AA: I found the above paragraph redundant with the summary at the start of the section and the more detail version below. If we want an intro para here I think it should be shorter.\n\nAlthough we now have a guarantee of soundness, we have no such guarantee of completeness. There are almost certainly Halide compilations for which the addition of some desirable rule would strengthen the TRS enough to unlock some optimization or achieve a tighter bound on some region. However, we don’t know what they are because no human has encountered them yet (or more likely, no human has been sufficiently motivated to submit a bug report for them yet). \n\nWe attempted to probe for such opportunities for improvement using fuzzing. We selected the 12 most complex example applications in the open source repository, and generated 64 random schedules for each using the autoscheduler~\\citep{Adams2019}, which can be configured to generate random likely-good schedules. This produced 768 separate compilations. We also instrumented most of the Halide code at Google for an additional 5032 compilations, this time using the original human-written schedules. Note that this is qualitatively different to randomly-generated schedules: we do not expect Halide users at Google would check in code that behaves poorly due to an issue with the compiler.\n\nWe instrumented these compilations to log expressions that might represent a TRS failure of some kind. From each compilation we log all integer expressions found that are non-monotonic with respect to a containing loop, and all failed proof attempts made during compilation. That is, we log all boolean expressions passed to the TRS in the hope that they will reduce to the constant true so that some optimization can correctly be performed. This resulted in a corpus of roughly one hundred thousand unique expressions.\n\nUsing this corpus as input, we synthesize new rewrite rules, add all rules found back to the ruleset, and rerun all compilations to gather new expressions, repeating this process until convergence. In total we created 4127 new rewrite rules in this way, more than quadrupling the number of rules in the TRS. For some examples, refer to Table \\ref{tab:samplerules}.\n\nWe then generate a fresh set of 256 random schedules per application (to avoid testing on our training set), and compile and run all the generated code, looking for any compilations which behave significantly differently between the baseline condition (compiled using unmodified Halide) and the test condition (compiled with the 4127 additional rewrite rules). The interesting findings are summarized below.\n\n\\paragraph{Adding new rules lowers peak memory usage by up to 50\\%}\nHalide sizes internal allocations using symbolic interval arithmetic,\nwhich (as described in Section~\\ref{sec:synthesizing-candidate-rules})\nis prone to overestimating bounds when\nexpressions do not either monotonically increase or decrease with\nrespect to some containing loop. By extending the TRS, we\nautomatically fix 197 cases where this kind of error increases the\npeak memory usage of an application at runtime by more than 10\\%, including one\ncase where the increase was more than a gigabyte. This represents\nnearly 6\\% of all compilations tested. We believe this captures a\nwidespread problem, as instances of overallocation are a common source\nof complaint from users. See Figure~\\ref{fig:peakmemoryhistogram} for\nthe full distribution. \n\n\\begin{figure*}\n\\centering\n  \\includegraphics[width=4in]{figures/memoryhistogram.pdf}\n\\caption{Reduction in runtime peak memory usage of 3072 pieces of compiled\n  code when 4127 synthesized rules are added to the TRS. The x-axis\n  shows $\\frac{after}{before}$, so below 1.0 means the synthesized rules\n  reduced memory consumption.  In 197 cases,\n  peak memory usage drops by more than 10\\%.}\n\\label{fig:peakmemoryhistogram}\n\\end{figure*}\n\n\\paragraph{Term rewriting systems written without verification have bugs}\nOn our initial run of this experiment, 55 compilations (1.6\\%) crashed\nat runtime with memory corruption errors in the baseline condition (no\nnew rules added). We traced this to an incorrect transformation in the variable solver, which had never been verified (and was not yet implemented as a formal TRS). This\nbug had existed for four years, but had only recently become an\nimportant code path due to change $\\mathbb{I}$ mentioned above. The\nincorrect transformation was $\\hmin(x - y, x - z) \\rewrites x - \\hmin(y, z)$,\nwhich should be $\\hmin(x - y, x - z) \\rewrites x - \\hmax(y, z)$. If this\nsecondary TRS had been written using verification, this bug would\nnever have been introduced. We discuss efforts to replace the current implementation of the variable solver with a correct-by-construction TRS in chapter~\\ref{chapter:synthfromscratch}.\n\n\\paragraph{The TRS scales well with the number of rules}\nRemarkably, more than quadrupling the size of the TRS increased total compile\ntimes by only 0.3\\%. On further examination we found that the\nadditional rules increased the amount of time spent inside the TRS by\n30\\%, and that only 1\\% of the the total compile time of the average\nHalide program is spent inside the TRS.\n\nWe did not find significant effects on runtime of the generated code or code size. We also found no significant differences on any metrics within the Google corpus. This may be because the random schedules we generate are especially complex compared to human-written ones, or simply because humans don't commit code that causes the compiler to misbehave.\n\nWhile adding the synthesized rules does not come at any significant cost we could measure to users of Halide, Halide developers were reluctant to add the full 4,000 rule set for two reasons. One is that adding 4,000 lines of code to the simplifier caused a significant slowdown in the compilation time of the Halide compiler itself, which was burdensome for compiler developers. The other was that while the thousand handwritten rules were difficult for programmers to reason about and maintain, adding 4,000 more rules made it almost completely unreadable. In the summer of 2021, Evan Lee of the University of Waterloo undertook a Google Summer of Code project to analyze which rules were crucial to the performance gains observed above. He found that the AC variants of 11 rules, or 31 rules overall, were sufficient to realize the performance gains on the standard application suite benchmarks. Those rules were merged into the Halide codebase in August 2021\\footnote{\\url{https://github.com/halide/Halide/pull/6174}}.\n\n\nThese results show that having verification and synthesis available as a tool for compiler authors fixes existing bugs, prevents entire classes of new bugs, and even helps compiler writers change the semantics of their language with confidence. Halide developers plan to continue to use verification and synthesis to maintain the TRS, and based on this experience plan to expand its use elsewhere in the compiler.\n\n\\section{Limitations \\& Future Work}\n\\label{sec:limitations}\n\nFor this work, we considered only the subset of the term rewriting system that\nis used to prove properties over infinite integers; the full TRS includes rules\nfor simplifying expressions with floating point values as well as rules for\nfixed-bitwidth integers.  As a result, we do not consider cases where the TRS\nmust also reason about whether overflow can occur.  Extending our improvements\nand automation to such rules could be done in future work.\n\nOne major limitation of the synthesis process we use is that our solver,\nZ3, often cannot reason about expressions with divisions or modulo\nwhere the right operand is a variable.  Though we work around this to\nsynthesize rules with generalized predicates on right hand side constants,\nthe overall synthesis machinery cannot generalize these to non-constants.\nExtending the synthesizer may be more tractable for rules that operate\non integers with finite bitwidths.\n\n\n", "meta": {"hexsha": "30617b55b88f08c2706ceb26e27f6ba9c8d3a412", "size": 52323, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/05-synthesis.tex", "max_stars_repo_name": "jn80842/UWThesis", "max_stars_repo_head_hexsha": "39a2749980fd32fce4ef2a8363a3e10eded55071", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/05-synthesis.tex", "max_issues_repo_name": "jn80842/UWThesis", "max_issues_repo_head_hexsha": "39a2749980fd32fce4ef2a8363a3e10eded55071", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/05-synthesis.tex", "max_forks_repo_name": "jn80842/UWThesis", "max_forks_repo_head_hexsha": "39a2749980fd32fce4ef2a8363a3e10eded55071", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.9404934688, "max_line_length": 1455, "alphanum_fraction": 0.7511419452, "num_tokens": 13662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226292, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.4022261516230589}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{amsmath}\n\n\n\\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}\n%\\topmargin=0cm\n\\topmargin=-2cm\n\\addtolength{\\textheight}{6.5cm}\n\\addtolength{\\textwidth}{2.0cm}\n%\\setlength{\\leftmargin}{-5cm}\n\\setlength{\\oddsidemargin}{0.0cm}\n\\setlength{\\evensidemargin}{0.0cm}\n\n\\newcommand{\\HRule}{\\rule{\\linewidth}{1mm}}\n\n%misc libraries goes here\n\\usepackage{tikz}\n\\usetikzlibrary{automata,positioning}\n\n\\begin{document}\n\n\\noindent\n\\HRule \\\\[3mm]\n\\begin{flushright}\n\n                                         \\LARGE \\textbf{CENG 222}  \\\\[4mm]\n                                         \\Large Statistical Methods for Computer Engineering \\\\[4mm]\n                                        \\normalsize      Spring '2018-2019 \\\\\n                                           \\Large   Homework 4 \\\\\n\\end{flushright}\n\\HRule\n\n\\section*{Student Information }\n%Write your full name and id number between the colon and newline\n%Put one empty space character after colon and before newline\nFull Name : Yavuz Selim Yesilyurt \\\\\nId Number : 2259166 \n\n% Write your answers below the section tags\n\\section*{Answer 9.10}\nThe given information describes that the from a sample of 200 items 24 defective items were found. We can calculate the sample proportion of defective items as follows: \n\\begin{align*}\n\\hat{p} &= \\frac{x}{n} \\\\\n\t\t&= \\frac{24}{200} \\\\\n\t\t&= 0.12\n\\end{align*}\nAlso, for the 96\\% confidence interval we will have a significance level of $\\alpha = 0.04$ and from standard normal table we can check its value which is 2.054. \\\\\n\n\\subsection*{a)}\nWith the information we obtained above, let us construct a 96\\% confidence interval for the proportion of defective items as follows: \n\\begin{align*}\n\\text{96\\% Confidence Interval} &= \\hat{p} +_- Z_{critical}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n}} \\\\\n&= 0.12 +_- 2.054\\sqrt{\\frac{0.12(1-0.12)}{200}} \\\\\n&= 0.12 +_- 0.047 \\\\\n&= (0.073, 0.167)\n\\end{align*}\n\n\\subsection*{b)}\nFirst let us state our hypotheses: \\\\\n\\begin{center}\n$H_0:p\\leq 0.1$ and $H_A:p > 0.1$ \\\\\n\\end{center}\nAnd as level of significance we have $\\alpha = 0.04$ and $\\alpha = 0.15$ values. Let us calculate the test statistic and then find the $p$ value to determine whether to accept or reject the Null hypothesis ($H_0$):\n\\begin{align*}\nZ &= \\frac{\\hat{p}-p}{\\sqrt{\\frac{p(1-p)}{n}}} \\\\\n  &= \\frac{0.12-0.1}{\\sqrt{\\frac{0.1(1-0.1)}{200}}} \\\\\n  &= \\frac{0.02}{0.0212} \\\\\n  &= 0.943\n\\end{align*}\nFind the $p$ value:\n\\begin{align*}\np &= P(Z > Z_0) \\\\\n  &= 1 - P(Z \\leq 0.943) \\\\\n  &= 1 - 0.82716 \\ \\ \\text{(From Std Norm Table)} \\\\\n  &= 0.17284\n\\end{align*}\nIn Conclusion, we see that the $p$ value (0.17284) is greater than the given significance levels (0.04 and 0.15), so we fail to reject the null hypothesis and conclude that there would be sufficient evidence to say that the claim is incorrect.\n\n\\newpage\n\\section*{Answer 9.12}\nWe are given: \\\\\n\\begin{center}\n$\\bar{x} = 0.62$, $\\sigma = 0.2$ and $n = 52$. \n\\end{center}\n\n\\subsection*{a)}\nTo construct a 95\\% confidence interval for the population mean resistance first let us find our level of significance at 95\\% which is $\\alpha = 0.05$ and from Standard Normal table it has value of 1.96.\nSo:\n\\begin{align*}\n\\text{95\\% Confidence Interval} &= \\bar{x} +_- Z_{critical}(\\frac{\\sigma}{\\sqrt{n}}) \\\\\n&= 0.62 +_- 1.96(\\frac{0.2}{\\sqrt{52}})\\\\\n&= 0.62 +_- 0.05436 \\\\\n&= (0.56564 < \\mu < 0.67436)\n\\end{align*}\n\n\\subsection*{b)}\nThe probability that resistance is 0.62 ohms or higher can be found as follows:\n\\begin{align*}\nP(X > 0.62) &= 1-P(Z \\leq 0.62) \\\\\n\t\t\t&= 1-P(Z \\leq \\frac{0.62-0.6}{0.2 / \\sqrt{52}}) \\\\\n\t\t\t&= 1-P(Z \\leq 0.721) \\\\\n\t\t\t&= 1-0.764545 \\ \\ \\text{(From Std Norm Table)} \\\\\n\t\t\t&= 0.235455\n\\end{align*}\n\n\\newpage\n\\section*{Answer 10.3}\nFrom the given random number generator data with $N=100$, after arranging data into increasing order, let us form a continuous type frequency table of the data which is given below:\n\n\\begin{table}[h]\n\\begin{tabular}{|l|l|}\n\\hline\nClass interval & Frequency \\\\ \\hline\nbelow -2.0     & 4         \\\\ \\hline\n-2.0 to -1.5   & 4         \\\\ \\hline\n-1.5 to -1.0   & 15        \\\\ \\hline\n-1.0 to -0.5   & 9         \\\\ \\hline\n-0.5 to 0      & 22        \\\\ \\hline\n0 to 0.5       & 15        \\\\ \\hline\n0.5 to 1.0     & 12        \\\\ \\hline\n1.0 to 1.5     & 11        \\\\ \\hline\n1.5 to 2.0     & 7         \\\\ \\hline\n2.0 and above  & 1         \\\\ \\hline\nTotal          & 100       \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\\subsection*{a)}\nUsing the table of normal distribution; the table of expected, observed frequencies and other required columns comes out to be:\n\n\\begin{table}[h]\n\\begin{tabular}{|l|l|l|l|}\n\\hline\nClass interval & $obs_i$ & $exp_i$ & $\\chi^2$ \\\\ \\hline\nbelow -2.0     & 4      & 3.32   & 0.14                                   \\\\ \\hline\n-2.0 to -1.5   & 4      & 5.32   & 0.33                                   \\\\ \\hline\n-1.5 to -1.0   & 15     & 10.02  & 2.48                                   \\\\ \\hline\n-1.0 to -0.5   & 9      & 15.14  & 2.49                                   \\\\ \\hline\n-0.5 to 0      & 22     & 18.38  & 0.71                                   \\\\ \\hline\n0 to 0.5       & 15     & 17.92  & 0.48                                   \\\\ \\hline\n0.5 to 1.0     & 12     & 14.03  & 0.29                                   \\\\ \\hline\n1.0 to 1.5     & 11     & 8.82   & 0.54                                   \\\\ \\hline\n1.5 to 2.0     & 7      & 4.46   & 1.45                                   \\\\ \\hline\n2.0 and above  & 1      & 2.59   & 0.97                                   \\\\ \\hline\nTotal          & 100    & 100    & 9.88332                                \\\\ \\hline\n\\end{tabular}\n\\end{table}\nNow to test the hypothesis at 5\\% significance level whether the given data follows a normal distribution, we need to calculate the test statistic, which can be calculated as follows:\n\\begin{align*}\n\\chi^2 &= \\Sigma\\frac{(obs_i - exp_i)^2}{exp_i} \\\\\n\t   &= 9.88\n\\end{align*}\nAnd degrees of freedom in this case is:\n\\begin{align*}\nv &= n-1 \\\\\n  &= 10-1 \\\\\n  &= 9\n\\end{align*}\nThe $p$ value for the above value of test statistic at 9 degrees of freedom can be found from table A6 and founded to be between 0.2 and 0.8, which is more than the significance level 0.05. We conclude that there is no evidence against the data follows a normal distribution.\n\n\\subsection*{b)}\nThe pdf of Uniform distribution is given by:\n\\begin{center}\n$f(x) = \\frac{1}{b-a} \\ \\ a \\leq x \\leq b$ \\\\\n\\end{center}\n\nIn this problem we have our $a=-3$, $b=3$. We need to calculate the table of expected, observed frequencies and other required columns again for Uniform distribution, which comes out to be: \n\n\\begin{table}[h]\n\\begin{tabular}{|l|l|l|l|}\n\\hline\nClass interval & $obs_i$ & $exp_i$ & $\\chi^2$ \\\\ \\hline\nbelow -2.0     & 4      & 16.67  & 9.63                                   \\\\ \\hline\n-2.0 to -1.5   & 4      & 8.33   & 2.25                                   \\\\ \\hline\n-1.5 to -1.0   & 15     & 8.33   & 5.33                                   \\\\ \\hline\n-1.0 to -0.5   & 9      & 8.33   & 0.05                                   \\\\ \\hline\n-0.5 to 0      & 22     & 8.33   & 22.41                                  \\\\ \\hline\n0 to 0.5       & 15     & 8.33   & 5.33                                   \\\\ \\hline\n0.5 to 1.0     & 12     & 8.33   & 1.61                                   \\\\ \\hline\n1.0 to 1.5     & 11     & 8.33   & 0.85                                   \\\\ \\hline\n1.5 to 2.0     & 7      & 8.33   & 0.21                                   \\\\ \\hline\n2.0 and above  & 1      & 16.67  & 14.73                                  \\\\ \\hline\nTotal          & 100    & 100    & 62.42                                  \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\nNow to test the hypothesis at 5\\% significance level whether the given data follows a Uniform distribution, we need to calculate the test statistic, which can be calculated as follows:\n\\begin{align*}\n\\chi^2 &= \\Sigma\\frac{(obs_i - exp_i)^2}{exp_i} \\\\\n\t   &= 62.42\n\\end{align*}\nAnd degrees of freedom in this case is:\n\\begin{align*}\nv &= n-1 \\\\\n  &= 10-1 \\\\\n  &= 9\n\\end{align*}\nThe $p$ value for the above value of test statistic at 9 degrees of freedom can be found from table A6 and founded to be $<0.001$, which is much lower than the significance level 0.05. We conclude that there is strong evidence against the data follows a Uniform distribution.\n\n\\subsection*{c)}\nAccording to the central limit theorem, theoretically it is possible that a data follows Normal and Uniform distributions simultaneously for a large sample.\n\n\\section*{Answer 10.9}\nLet us first state our Null and Alternative hypotheses:\n\n\\begin{center}\n$H_0:$ all three section's performance is equal \\\\\n$H_A:$ all three section's performance is not equal \\\\\n\\end{center}\nWe have our level of significance as $\\alpha = 0.05$. Now let us again create a table of expected, observed frequencies and other required columns and perform a Chi-Square test. Note that this time we have 3 samples and we will draw the table in a slightly different fashion. Each column shows a section and each row shows a grade. There are three numbers in each entry which corresponds to:\n\\begin{center}\nObserved \\\\\nObserved - Expected \\\\\n$\\chi^2$\n\\end{center}\n\n\\begin{table}[h]\n\\begin{tabular}{|c|c|c|c|c|}\n\\hline\nGrade & S01                                                        & S02                                                        & S03                                                        & Total                                                      \\\\ \\hline\nA     & \\begin{tabular}[c]{@{}c@{}}40\\\\ 5.71\\\\ 0.95\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}20\\\\ -8.57\\\\ 2.57\\end{tabular} & \\begin{tabular}[c]{@{}c@{}}20\\\\ 2.86\\\\ 0.48\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}80\\\\ 0\\\\ 4\\end{tabular}      \\\\ \\hline\nB     & \\begin{tabular}[c]{@{}c@{}}50\\\\ 2.86\\\\ 0.17\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}40\\\\ 0.71\\\\ 0.01\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}20\\\\ -3.57\\\\ 0.54\\end{tabular} & \\begin{tabular}[c]{@{}c@{}}110\\\\ 0\\\\ 0.73\\end{tabular}  \\\\ \\hline\nC     & \\begin{tabular}[c]{@{}c@{}}20\\\\ -5.71\\\\ 1.27\\end{tabular} & \\begin{tabular}[c]{@{}c@{}}25\\\\ 3.57\\\\ 0.6\\end{tabular}   & \\begin{tabular}[c]{@{}c@{}}15\\\\ 2.14\\\\ 0.36\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}60\\\\ 0\\\\ 2.22\\end{tabular}   \\\\ \\hline\nD     & \\begin{tabular}[c]{@{}c@{}}2\\\\ -1.86\\\\ 0.89\\end{tabular}  & \\begin{tabular}[c]{@{}c@{}}5\\\\ 1.79\\\\ 0.99\\end{tabular}   & \\begin{tabular}[c]{@{}c@{}}2\\\\ 0.07\\\\ 0\\end{tabular}      & \\begin{tabular}[c]{@{}c@{}}9\\\\ 0\\\\ 1.89\\end{tabular}    \\\\ \\hline\nF     & \\begin{tabular}[c]{@{}c@{}}8\\\\ -1\\\\ 0.11\\end{tabular}     & \\begin{tabular}[c]{@{}c@{}}10\\\\ 2.5\\\\ 0.83\\end{tabular}   & \\begin{tabular}[c]{@{}c@{}}3\\\\ -1.5\\\\ 0.5\\end{tabular}    & \\begin{tabular}[c]{@{}c@{}}21\\\\ 0\\\\ 1.44\\end{tabular}   \\\\ \\hline\nTotal & \\begin{tabular}[c]{@{}c@{}}120\\\\ 0\\\\ 3.4\\end{tabular}     & \\begin{tabular}[c]{@{}c@{}}100\\\\ 0\\\\ 5.01\\end{tabular}    & \\begin{tabular}[c]{@{}c@{}}60\\\\ 0\\\\ 1.88\\end{tabular}     & \\begin{tabular}[c]{@{}c@{}}280\\\\ 0\\\\ 10.28\\end{tabular} \\\\ \\hline\n\\end{tabular}\n\\end{table}\nAs can be seen from the last row, last column of our table, $\\chi^2$ of the total is equal to 10.28 and we have a $v = 8$ degrees of freedom. \\\\\n\nThe $p$ value for the above value of test statistic at 8 degrees of freedom can be found from table A6 and founded to be between 0.8 and 0.2, which is greater than the significance level 0.05. \\\\\n\nSo in conclusion, Since, the $p$ value greater than the given significance level 0.05, so we fail to reject the null hypothesis and conclude that the three sections performance is equal.\n\n\\end{document}\n", "meta": {"hexsha": "be3159514957d28ff2f76798f959258befc6a87e", "size": 11639, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "222/hw4/the4.tex", "max_stars_repo_name": "ysyesilyurt/Metu-CENG", "max_stars_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 33, "max_stars_repo_stars_event_min_datetime": "2019-03-19T07:51:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:04:35.000Z", "max_issues_repo_path": "222/hw4/the4.tex", "max_issues_repo_name": "ysyesilyurt/Metu-CENG", "max_issues_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-11-09T18:08:21.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-09T18:08:21.000Z", "max_forks_repo_path": "222/hw4/the4.tex", "max_forks_repo_name": "ysyesilyurt/Metu-CENG", "max_forks_repo_head_hexsha": "a83fcab00f68e28bda307bb94c060f55042a1389", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 13, "max_forks_repo_forks_event_min_datetime": "2019-11-08T06:18:21.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T17:17:38.000Z", "avg_line_length": 49.1097046414, "max_line_length": 391, "alphanum_fraction": 0.5675745339, "num_tokens": 3996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.7981867825403177, "lm_q1q2_score": 0.4022112449568194}}
{"text": "\\documentclass{beamer}\n\n\\usepackage{xcolor}\n\\usepackage{amsmath,amssymb}\n\\usepackage{tikz}\n\\usepackage{tikz-cd}\n\\usepackage{graphicx}\n\n\\usetikzlibrary{shapes.geometric}\n\n\\tikzset{pics/.cd,\nopencube/.style args={#1/#2/#3}{code={\n\\coordinate (O) at (0,0,0);\n\\coordinate (A) at (0,#2,0);\n\\coordinate (B) at (0,#2,#3);\n\\coordinate (C) at (0,0,#3);\n\\coordinate (D) at (#1,0,0);\n\\coordinate (E) at (#1,#2,0);\n\\coordinate (F) at (#1,#2,#3);\n\\coordinate (G) at (#1,0,#3);\n%% Background\n\\draw[black,dotted] (O) -- (A);\n\\draw[black,dotted] (O) -- (C);\n\\draw[black,dotted] (O) -- (D);\n% Forground\n\\draw[black,dashed] (A) -- (E) -- (F) -- (B) -- cycle;\n\\draw[black,dashed] (E) -- (D) -- (G) -- (C) -- (B);\n\\draw[black,dashed] (F) -- (G);\n\n%\\draw[black,dashed, blue] (O) -- (A) -- (E) -- (D) -- cycle;\n%\\draw[black,dashed] (O) -- (A) -- (B) -- (C) -- cycle;\n%\\draw[black,dashed] (D) -- (E) -- (F) -- (G) -- cycle;\n%\\draw[black,dashed] (C) -- (B) -- (F) -- (G) -- cycle;\n%\\draw[black,dashed] (A) -- (B) -- (F) -- (E) -- cycle;\n\n}}}\n\n\\tikzset{pics/.cd,\nlinecube/.style args={#1/#2/#3/#4}{code={\n\\coordinate (OO) at (0,0,0);\n\\coordinate (AA) at (0,#2,0);\n\\coordinate (BB) at (0,#2,#3);\n\\coordinate (CC) at (0,0,#3);\n\\coordinate (DD) at (#1,0,0);\n\\coordinate (EE) at (#1,#2,0);\n\\coordinate (FF) at (#1,#2,#3);\n\n\\coordinate (GG) at (#1,0,#3);\n%% Background\n\\draw[black,dashed] (OO) -- (AA);\n\\draw[black,dashed] (OO) -- (CC);\n\\draw[black,dashed] (OO) -- (DD);\n\n\\node at (0.5*#1,0.5*#2,0.5*#3) {#4};\n\n% Foreground\n\\draw[black] (AA) -- (EE) -- (FF) -- (BB) -- cycle;\n\\draw[black] (EE) -- (DD) -- (GG) -- (CC) -- (BB);\n\\draw[black] (FF) -- (GG);\n\n%\\draw[black,dashed, blue] (O) -- (A) -- (E) -- (D) -- cycle;\n%\\draw[black,dashed] (O) -- (A) -- (B) -- (C) -- cycle;\n%\\draw[black,dashed] (D) -- (E) -- (F) -- (G) -- cycle;\n%\\draw[black,dashed] (C) -- (B) -- (F) -- (G) -- cycle;\n%\\draw[black,dashed] (A) -- (B) -- (F) -- (E) -- cycle;\n\n}}}\n\n\n\\tikzset{pics/.cd,\nshadedcube/.style args={#1/#2/#3/#4/#5}{code={\n\\coordinate (O) at (0,0,0);\n\\coordinate (A) at (0,#2,0);\n\\coordinate (B) at (0,#2,#3);\n\\coordinate (C) at (0,0,#3);\n\\coordinate (D) at (#1,0,0);\n\\coordinate (E) at (#1,#2,0);\n\\coordinate (F) at (#1,#2,#3);\n\\coordinate (G) at (#1,0,#3);\n\\draw[black,fill=#4!80] (O) -- (C) -- (G) -- (D) -- cycle;\n\\draw[black,fill=#4!30] (O) -- (A) -- (E) -- (D) -- cycle;\n\\draw[black,fill=#4!10] (O) -- (A) -- (B) -- (C) -- cycle;\n\\draw[black,fill=#4!20,opacity=0.8] (D) -- (E) -- (F) -- (G) -- cycle;\n\\draw[black,fill=#4!20,opacity=0.6] (C) -- (B) -- (F) -- (G) -- cycle;\n\\draw[black,fill=#4!20,opacity=0.8] (A) -- (B) -- (F) -- (E) -- cycle;\n\\node at (0.5*#1,0.5*#2,0.5*#3) {#5};\n}}}\n\\tikzset{pics/.cd,\ngridcube/.style args={#1/#2/#3/#4/#5/#6/#7}{code={\n\\coordinate (O) at (0,0,0);\n\\coordinate (A) at (0,#2,0);\n\\coordinate (B) at (0,#2,#3);\n\\coordinate (C) at (0,0,#3);\n\\coordinate (D) at (#1,0,0);\n\\coordinate (E) at (#1,#2,0);\n\\coordinate (F) at (#1,#2,#3);\n\\coordinate (G) at (#1,0,#3);\n\n% Foreground\n\\draw[fill=#7!20] (A) -- (E) -- (F) -- (B) -- cycle;\n\\draw[fill=#7!40] (E) -- (F) -- (G) -- (D) -- cycle;\n\\draw[fill=#7!30] (B) -- (F) -- (G) -- (C) -- cycle;\n%\\draw[black] (E) -- (D) -- (G) -- (C) -- (B);\n%\\draw[black] (F) -- (G);\n\n% lines\n\\foreach \\ll in {1,...,#4} {\n    \\draw[black] (#1/#4*\\ll,#2,0) -- (#1/#4*\\ll,#2,#3) -- (#1/#4*\\ll,0,#3);\n}\n\\foreach \\ll in {1,...,#5} {\n    \\draw[black] (0,#2/#5*\\ll,#3) -- (#1, #2/#5*\\ll,#3) -- (#1,#2/#5*\\ll,0);\n}\n\\foreach \\ll in {1,...,#6} {\n    \\draw[black] (0,#2,#3/#6*\\ll) -- (#1,#2,#3/#6*\\ll) -- (#1,0,#3/#6*\\ll);\n}\n\n}}}\n\n%\\pgfmathsetmacro{\\xx}{0.5}\n\n\\mode<presentation>\n% \\setbeameroption{hide notes}\n{\n  %\\usetheme{Madrid}\n  \\usetheme{metropolis}\n% CSU COLORS\n  \\definecolor{csugreen}{HTML}{1C674F}\n  \\definecolor{csugold}{HTML}{B78E00}\n    \\definecolor{csured}{HTML}{E02F11}\n\n  \\definecolor{greenmain}{HTML}{00AF64}\n  \\definecolor{brick}{rgb}{.85,.1,.2}\n  \\colorlet{greenstruct}{greenmain!87.5!black}\n  \\usecolortheme[named=csugreen]{structure}\n  % Change this in order to make the presentation look\n  % different. Works just like a powerpoint template. \n  % Have your RA mess around until it looks nice.\n  \\setbeamercovered{dynamic}\n\n  \\useinnertheme{rectangles}\n  \n %Other colors.\n\n%   \\definecolor{bluemain}{HTML}{0B61A4}\n%   \\definecolor{orangemain}{HTML}{AA6600}\n%   \\definecolor{redmain}{HTML}{E02F11}\n%   \\definecolor{redlight}{HTML}{FF9B73}\n%   \\definecolor{orangelight}{HTML}{FFC373}\n%   \\definecolor{cmugray}{RGB}{104,104,104}\n%   \\definecolor{cmulightgray}{RGB}{238,238,238}\n%   \\setbeamercolor{block body}{bg=cmulightgray}\n%   \\setbeamercolor{talktitle}{bg=csugreen,fg=white}\n%   \\setbeamercolor{block title alerted}{bg=csugold}\n%   \\setbeamercolor{block body alerted}{bg=orangelight}\n\n}\n\\renewcommand{\\footnoterule}{}\n\\renewcommand{\\hat}[1]{\\widehat{#1}}\n\\newcommand{\\sourcenum}[3]{$^{\\textcolor{bluemain} #1}$\\let\\thefootnote\\relax\n  \\footnotetext{\\begin{flush#2}\\textcolor{bluemain}\n      {\\tiny $^{#1}$ #3}\\end{flush#2}}} \n\\newcommand{\\source}[2]{\\let\\thefootnote\\relax\\footnotetext{\\begin{flush#1}\n      \\textcolor{bluemain}{\\tiny Source: #2}\\end{flush#1}}}  \n\n\n\\DeclareMathOperator{\\Span}{Span}\n\\DeclareMathOperator{\\Pres}{Pres}\n\\DeclareMathOperator{\\End}{End}\n\\newcommand{\\bmto}{\\rightarrowtail}\n\n\\usepackage{wasysym} \n\\newcommand{\\den}[1]{\\Leftcircle\\hspace*{-1mm}#1\\hspace*{-1mm} \\Rightcircle}\n\n\\begin{document}\n\n\\title{Reliable Tensor Clusters}\n\\author{CC-BY 2021 James B. Wilson\\\\ Colorado State University}\n%\\date{\\today}\n\n\\maketitle\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Applications}\n\n\\subsection{Data science}\n\\begin{frame} \n    \\begin{block}{Data}\n        Results of measurement \\& computation, e.g.\\\\[5pt]\n        \\centering\n        \\emph{Mercury is 2.5cm high in tube}.\n    \\end{block}\n\n    \\begin{block}{Information}\n        data used to make a decision, e.g.\\\\[5pt]\n        \\centering\n        \\emph{Thermometer reads $38^{\\circ}$F; I'll wear a coat.} \n    \\end{block}\n    \n\n    \\begin{block}{The Data Problem}\n        Turn data into information.\n    \\end{block}\n\n\\end{frame}\n\n\n\\begin{frame}\n    \\frametitle{Nutrition Matrix}\n    Nutrients$\\times$Produce data collected and used on diet problems.\n    \\bigskip \n\n    \\begin{tabular}{c|cccccc|}\n             & Apple & Beef & Egg & Filbert & $\\cdots$ & Strawberry \\\\\n    \\hline\n    Carbs    & 13.8  & 1    & 2    & 4.8    & $\\cdots$  & 7.7 \\\\\n    Protein  & 0.3   & 20.7 & 17.1 & 3.9    &  & 0.7 \\\\\n    Fat      & 0.2   & 7.4  & 14.4 & 1.3    &  & 0.3 \\\\\n    $\\vdots $ & $\\vdots$ & & & & &\\\\\n    \\hline \n    \\end{tabular} \n\n    \\bigskip\n    Substitute other examples\\\\\n     minerals$\\times$ mines, pollutants$\\times$water-source, \n    keywords$\\times$authors\n\\end{frame}\n\n\\begin{frame}[fragile]\n    \\frametitle{Nutrition Tensor}\n    Reality is more complex...\n    \\begin{center}\n        Nutrients $\\times$ Produce $\\times$ Farms $\\times$ Water Source $\\times$ Fertilizer\n    \\end{center}\n    \\centering\n    \\pgfmathsetmacro{\\xx}{0.5}\n    \\begin{tikzpicture}[scale=1.5]\n        \\pic at (1.25,1.25,0) {\n            linecube={3.75/2.5/1.75/{\n                \\begin{tikzpicture}\n                    \\foreach \\x/\\xc in {1/blue,2/red,3/green} {\n                        \\pic at (1.25*\\x,1.25*1,0.25) {gridcube={1/0.75/1/4/3/4/{\\xc}}};\n                    }\n                    \\foreach \\x/\\xc in {1/purple,2/brown,3/teal} {\n                        \\pic at (1.25*\\x,1.25*2,0.25) {gridcube={1/0.75/1/4/3/4/{\\xc}}};\n                    }\n                \\end{tikzpicture}\n            }}        \n        };\n        \\node[rotate=45] at (0.75,0.5,0) {Rain};\n        \\node[rotate=45] at (1.5,0.25,0) {Willamette};\n        \\node[rotate=45] at (2.5,0.25,0) {Deschutes};\n\n        \\node[rotate=-30] at (4.75,1,1) {{\\small Crawford Farms}};\n        \\node[rotate=-30] at (4.75,0.9,0.5) {{\\small Four Pines Ranch}};\n        \\node[rotate=-30] at (4.60,.9,0) {{\\small Schlecter Farms}};\n        \\node[rotate=-30] at (4.75,0.8,-0.5) {{\\small Thistledown Farms}};\n\n        \\node at (4,1.5,-1) {{\\small Phosphate}};\n        \\node at (4,2,-1) {{\\small Nitrogen}};\n        \n        \\node (N) at (-1,2,-0.25) {{\\small Nutrients}};\n        \\node (F) at (2,3,-0.75) {{\\small Produce}};\n        \\draw[thick] (N) -- (1,1.25,0);\n        \\draw[thick] (N) -- (1,2.25,0);\n        \\draw[thick] (F) -- (1.5,2.5,-0.75);\n        \\draw[thick] (F) -- (2 ,2.5,-0.75);\n        \\draw[thick] (F) -- (2.5,2.5,-0.75);\n    \\end{tikzpicture}\n    \n\\end{frame}\n\n\\begin{frame}\n\n    \\frametitle{First Approximation of Tensor}\n        Fox coefficients $K$ and set $[n]=\\{1,\\ldots,n\\}$.\n\\bigskip\n\n        A \\emph{hypermatrix} (some call it a ``tensor'') is a function\n        $\\Gamma:[d_1]\\times \\cdots\\times [d_{\\ell}]\\to K$.\n\n        \\[K^{d_1\\times\\cdots\\times d_{\\ell}} = \\{\\Gamma:[d_1]\\times \\cdots\\times [d_{\\ell}]\\to K\\}.\\]\n\n    Technical matter: For general sets $X_1,\\ldots, X_{\\ell}$\n    $\\Gamma:X_1\\times \\cdots \\times X_{\\ell}\\to K$ has \\emph{finite support} (only finitely many nonzero values).\n    \n\\end{frame}\n\n\\begin{frame} \n    Data collection chooses bases for convenience/practicality/instrumentation/safety/laws/...\n    \\begin{itemize}\n        \\item Measure each fruit, farm, fertilizer  separately\n        \\item Choose nutrients a lab can measure (Carbs, Sugar, Vit. A, Vit. B...)\n    \\end{itemize}\n\n    \\bigskip\n    \\textbf{Data collection is basis dependent;\\\\ \n    Likely some qualities of nutrition are basis independent.}\n\n    \\begin{block}{The Tensor-Data Problem}\n        Find basis invariant properties of tensor data.\\\\\n        (This is now a math problem!)\n    \\end{block}\n    \n\\end{frame}\n\n\n\\begin{frame}\n\n    \\frametitle{Second Approximation of Tensor}\n\n    A function $\\langle \\Gamma |:K^{X_1}\\times \\cdots \\times K^{X_{\\ell}}\\bmto K$ where \n    \\begin{align*}\n        \\langle \\Gamma| u_1,\\ldots, u_{\\ell}\\rangle \n        & = \\sum_{x_1\\in X_1} \\cdots \\sum_{x_{\\ell}\\in X_{\\ell}} \\Gamma_{x_1\\cdots x_{\\ell}} u_{1x_1}\\cdots u_{\\ell x_{\\ell}}.\n    \\end{align*}\n\n    {\\color{magenta} $\\bmto$?}  Just reminds me to tell you this is same ``multi-linear''\n    \\begin{align*}\n        & (\\forall a) & \n        \\langle t|u_a+\\lambda \\tilde{u}_{a},u_{\\bar{a}}\\rangle \n        & = \\langle t|u_a,u_{\\bar{a}}\\rangle \n        + \\lambda \\langle t|\\tilde{u}_{a},u_{\\bar{a}}\\rangle \n    \\end{align*}\n    \n\\end{frame}\n\n\n\n\\begin{frame}\n    \\frametitle{Example: Find change of basis matrices to get clusters}\n    \\pgfmathsetmacro{\\xx}{0.5}\n\t\\begin{tikzpicture}\n\t\t\n\t\t\\node (T) at (-4,0,0) {\\begin{tikzpicture}\n\t\t\t\\pic at (0,0,0) {shadedcube={2*\\xx/2*\\xx/2*\\xx/gray/}};\n\t\t\t%\\draw [->] (0,0,0) -- (5,0,0)\n\t\t\t\\node[rotate=90] at (2*\\xx,0.5*\\xx,-1*\\xx) {{\\small users}};\n\t\t\t\\node[rotate=45] at (-0.7*\\xx,2*\\xx,0) {{\\small time}};\n\t\t\t\\node at (0.2*\\xx,-1*\\xx,0*\\xx) {{\\small words}};\n\t\n\t\t\t\\draw (0*\\xx,2*\\xx,0*\\xx) rectangle (2*\\xx,3.3*\\xx,0*\\xx);\n\t%        \\draw (0*\\xx,2*\\xx,0*\\xx) rectangle (2*\\xx,4*\\xx,0*\\xx);\n\t\t\t\\draw (0*\\xx,0*\\xx,2*\\xx) --++ (0*\\xx,2*\\xx,0*\\xx)\n\t\t\t   --++ (0*\\xx,0*\\xx,2*\\xx) --++ (0*\\xx,-2*\\xx,0*\\xx) -- cycle;\n\t\t\t\\draw (2*\\xx,0*\\xx,0*\\xx) --++ (2*\\xx,0*\\xx,0*\\xx)\n\t\t\t   --++ (0*\\xx,0*\\xx,2*\\xx) --++ (-2*\\xx,0*\\xx,0*\\xx) -- cycle;\n\t\n\t\t\t\\node[rotate=45,xslant=0.5] at (0*\\xx,1*\\xx,3*\\xx) {{\\small X}};\n\t\t\t\\node at (1*\\xx,2.7*\\xx,0) {{\\small Y}};\n\t\t\t\\node[xslant=0.5] at (3*\\xx,0*\\xx,1*\\xx) {{\\small Z}};\n\t\n\t\t\t\\node at (5*\\xx,1*\\xx,0) {$\\overset{?}{=}$};\n\t\t\t\\node at (-5*\\xx,1*\\xx,0) {$(\\exists X)(\\exists Y)(\\exists Z)$};\n\t\t\\end{tikzpicture}};\n\t\n\t\t%% Weird bug, using label (A) arrows go wonky, using label (A0) all good.\n\t\t\\node (A0) at (1,2,0) {\\begin{tikzpicture}\n\t\t\t\\pic at (\\xx,-\\xx,0) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,0,\\xx) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,\\xx,0) {opencube={2*\\xx/-2*\\xx/2*\\xx}};\n\t\t\\end{tikzpicture}};\n\t\t%% Weird bug, using label (A) arrows go wonky, using label (A0) all good.\n\t\t\\node (A1) at (1,0,0) {\\begin{tikzpicture}\n\t\t\t\\pic at (\\xx,-\\xx,0) {shadedcube={\\xx/\\xx/2*\\xx/gray/}};\n\t\t\t\\pic at (0,0,0) {shadedcube={\\xx/\\xx/2*\\xx/gray/}};\n\t\t\t\\pic at (0,\\xx,0) {opencube={2*\\xx/-2*\\xx/2*\\xx}};\n\t\t\\end{tikzpicture}};\n\t\t%% Weird bug, using label (A) arrows go wonky, using label (A0) all good.\n\t\t\\node (A2) at (1,-2,0) {\\begin{tikzpicture}\n\t\t\t\\pic at (\\xx,-\\xx,0) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,-\\xx,\\xx) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,0,0) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (\\xx,0,\\xx) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,\\xx,0) {opencube={2*\\xx/-2*\\xx/2*\\xx}};\n\t\t\\end{tikzpicture}};\n\t\n\t\n\t\\end{tikzpicture}\n\n    Then ask: \\emph{What type?} \\emph{Are they unique?} \\emph{How to find them?}\n\\end{frame}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{The Tensor Product}\n\n\\begin{frame}\n    \\begin{block}{Main Idea}\n        \\centering\n    Data table $\\equiv$ Multiplication Table\n    \\end{block}\n\\bigskip\n\n    So study multiplication tables.\n\\end{frame}\n\n\\begin{frame}\n    For finite sets \n    \\begin{align*}\n        \\boxtimes & : R^m\\times R^n \\bmto R^{m\\times n}\n        &\n        u\\boxtimes v & = u v^{\\dagger} = \\begin{bmatrix} u_1 v_1 & \\cdots & u_1 v_n \\\\ \\vdots & & \\vdots \\\\ u_m v_1 & \\cdots & u_m v_n \\end{bmatrix}.\n    \\end{align*}\n\n    In general possibly infinite matrices, but finite support\n    \\begin{align*}\n        \\boxtimes & : R^X\\times R^Y \\bmto R^{X\\times Y}\n        &\n        (u\\boxtimes v)_{xy} & = u_x v_y.\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}\n    \\frametitle{The Tensor Product}\n\n    A right $R$-modules has a presentation\n    \\[U_R=\\Pres_R\\langle X\\mid S\\rangle =R^X/\\Span S\\]\n\n    A left $R$-module has a presentation\n    \\[{_R V}=\\Pres_R\\langle Y\\mid T\\rangle =R^Y/\\Span T\\]\n\n    Their \\textbf{Tensor Product} is\n    \\[ U\\otimes_R V = R^{X\\times Y}/(R^X\\boxtimes T+S\\boxtimes R^Y)\\]\n    along with the induced function \n    \\begin{align*}\n    \\otimes & :U\\times V \\bmto U\\otimes_R V\n    \\\\\n    x\\otimes y & = x\\boxtimes y+(R^X\\boxtimes T+S\\boxtimes R^Y).\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}[fragile]\n    $U_R=\\Pres_R\\langle X\\mid S\\rangle =R^X/\\Span S$;\n    ${_R V}=\\Pres_R\\langle Y\\mid T\\rangle =R^Y/\\Span T$\n    \\bigskip \n\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            \\Span S \\arrow[d,phantom,\"\\times\"]\\arrow[r, hook] \n                & R^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_R=\\Span X\\arrow[d,phantom,\"\\times\"]  \\\\\n            \\Span T \\arrow[r, hook]\\arrow[d,\"\\boxtimes\",tail] \n                & R^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & {_R V}=\\Span Y\\arrow[d,\"\\otimes\",tail] \\\\            \n            R^X\\boxtimes T+S\\boxtimes R^Y \\arrow[r, hook] \n                 & R^{X\\times Y} \\arrow[r,two heads] \n                     & U\\otimes_R V   \\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n\\end{frame}\n\n\\begin{frame}{Example}\n    \\[(\\mathbb{Z}/2\\mathbb{Z}\\oplus \\mathbb{Z}/6\\mathbb{Z}\\oplus \\mathbb{Z})\\otimes (\\mathbb{Z}/4\\mathbb{Z}\\oplus \\mathbb{Z}/8\\mathbb{Z})\\]\n    \\textbf{Solution.}\n    \\begin{align*}\n        \\left.\n            \\begin{bmatrix}\\mathbb{Z} & \\mathbb{Z}\\\\ \\mathbb{Z} & \\mathbb{Z} \\\\ \\mathbb{Z} & \\mathbb{Z} \\end{bmatrix}\n            \\middle/\n        \\left(\n            \\begin{bmatrix} \\mathbb{Z} \\\\ \\mathbb{Z}\\\\ \\mathbb{Z}\\end{bmatrix}\n        \\begin{bmatrix} 4\\mathbb{Z} & 8\\mathbb{Z}\\end{bmatrix}\n        +\n        \\begin{bmatrix} 2\\mathbb{Z} \\\\ 6\\mathbb{Z}\\\\ 0\\mathbb{Z}\\end{bmatrix}\n        \\begin{bmatrix} \\mathbb{Z} & \\mathbb{Z}\\end{bmatrix}\\right)\n        \\right.\\\\\n        =\n        \\left.\n            \\begin{bmatrix}\\mathbb{Z} & \\mathbb{Z}\\\\ \\mathbb{Z} & \\mathbb{Z} \\\\ \\mathbb{Z} & \\mathbb{Z} \\end{bmatrix}\n            \\middle/\n            \\begin{bmatrix}4\\mathbb{Z}+2\\mathbb{Z} & 8\\mathbb{Z}+2\\mathbb{Z}\\\\ 4\\mathbb{Z}+6\\mathbb{Z} & 8\\mathbb{Z}+6\\mathbb{Z} \\\\ 4\\mathbb{Z}+0\\mathbb{Z} & 8\\mathbb{Z}+0\\mathbb{Z} \\end{bmatrix}\n        \\right.\\\\\n        =\n        \\begin{bmatrix}\\mathbb{Z}/2\\mathbb{Z} & \\mathbb{Z}/2\\mathbb{Z}\\\\ \\mathbb{Z}/2\\mathbb{Z} & \\mathbb{Z}/2\\mathbb{Z} \\\\ \\mathbb{Z}/4\\mathbb{Z} & \\mathbb{Z}/8\\mathbb{Z} \\end{bmatrix}\n    \\end{align*}\n\\end{frame}\n\n\\begin{frame}\n    $\\mathbb{Z}/2\\mathbb{Z}\\otimes \\mathbb{Q}$\n\n    \\begin{block}{Solution}\n    $\\mathbb{Q}=\\left\\langle \\frac{1}{1!},\\frac{1}{2!},\\frac{1}{3!},\\ldots\\right\\rangle =\\langle e_1,e_2,\\ldots \\mid e_n=(n+1)e_{n+1}\\rangle$\n    \\begin{align*}\n        \\left.\n        \\mathbb{Z}^{[1]\\times \\mathbb{N}}\n        \\middle/\n        \\left(2\\mathbb{Z}\\boxtimes \\mathbb{Z}^{\\mathbb{N}}\n        +\\mathbb{Z}\\boxtimes \\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\end{bmatrix} \n        \\right)\n        \\right.\\\\\n        \\only<6>{\n            \\left.\n            \\mathbb{Z}^{1\\times \\mathbb{N}}\\middle/\\mathbb{Z}\\boxtimes \\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\end{bmatrix}\n            \\cong \\mathbb{Q}\n            \\right.\n        }\n    \\end{align*}\n    \\only<1-5>{\n    \\begin{align*}\n        \\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\\\ 2 & 0 \\\\ & 2 & 0 \\\\ & & \\ddots & \\ddots \\end{bmatrix}\n        \\only<2>{\\sim\\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\\\ 0 & 4 \\\\ & 2 & 0 \\\\ & & \\ddots & \\ddots \\end{bmatrix}}\n        \\only<3>{\\sim\\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\\\ 0 & 0 \\\\ & 2 & 0 \\\\ & & \\ddots & \\ddots \\end{bmatrix}}\n        \\only<4>{\\sim\\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\\\ 0 & 0 \\\\ & 0 & 6 \\\\ & & \\ddots & \\ddots \\end{bmatrix}}\n        \\only<5>{\\sim\\begin{bmatrix} 1 & -2 & & \\\\  & 1 & -3 & \\\\  & & \\ddots & \\ddots \\\\ 0 & 0 \\\\ & 0 &  0\\\\ & & \\ddots & \\ddots \\end{bmatrix}}\n    \\end{align*}\n    }\n\n    \\end{block}\n    \n\\end{frame}\n\n\\subsection{Theory}\n\n\\begin{frame}{Theory}\n    \\only<1>{\n    Tensor products are distributive\n    \\begin{align*}\n        (u+\\tilde{u})\\otimes v & = u\\otimes v+\\tilde{u}\\otimes v \n        \\\\\n        u\\otimes (v+\\tilde{v}) & = u\\otimes v+u\\otimes \\tilde{v}\\\\ \n        (U\\oplus \\tilde{U})\\otimes_R V & = U\\otimes_R V\\oplus\\tilde{U}\\otimes_R V \n        \\\\\n        U\\otimes_R (V\\oplus\\tilde{V}) & = U\\otimes_R V\\oplus U\\otimes \\tilde{V}\n    \\end{align*}    \n    }\n    \\only<2>{\n        Tensor products have a 1.\n    \\begin{align*}\n        U\\otimes_R R & \\cong U & R\\otimes_R V \\cong V\n    \\end{align*}\n    }\n    \\only<3>{\n    Sometimes it is said tensor products are associative and commutative, \n    \\emph{that is nonsense}\n    \\begin{align*}\n        \\mathbb{R}^\\otimes \n    \\end{align*}\n    \n    But in special cases, e.g.\\ if $R$ is \\emph{commutative}\n    \\begin{align*}\n        U\\otimes_R (V\\otimes_R W) \\cong (U\\otimes_R V)\\otimes_R W\\\\\n        U\\otimes_R V & \\cong V\\otimes_R U.\n    \\end{align*}\n\n    But be warned $U_1\\otimes \\cdots\\otimes U_n$ is generally not defined!\n    }\n\\end{frame}\n\n\\begin{frame}{Universal Mapping Property}\n    Further fact $ur\\boxtimes v=(ur)v^{\\dagger}=u(rv)^{\\dagger}=u\\boxtimes rv$;\\\\\n    so $ur\\otimes v=u\\otimes r v$.\n    \n    \\begin{block}{Theorem}\n        If $*:U\\times V\\bmto W$ is distributive and $\\forall r\\in R$, $ur*v=u*rv$ then $\\exists ! \\hat{*}:U\\otimes_R V\\to W$ where \n        \\[\n            u*v = \\hat{*}(u\\otimes v).\n        \\]\n        In particular $U\\otimes_R V$ does not depend on choice of presentations.\n    \\end{block}\n\n    \n\\end{frame}\n\n\\begin{frame}{Whitney Tensor Product}\n\n    Every module has its ``regular'' presentation\n    \\[ U_R=\\Pres_R\\langle e_u, u\\in U \\mid e_{u+\\tilde{u}}=e_u+e_{\\tilde{u}}, e_{ur}=e_u r\\rangle\n        \\]\n    \\[ {_R V}=\\Pres_R\\langle e_v, v\\in V\\mid e_{v+\\tilde{v}}=e_v+e_{\\tilde{v}}, e_{rv}=re_v\\rangle\n        \\]\n\n    With these presentations we recover Whitney's definition (i.e. your textbook definition)\n    \\begin{align*}\n        U\\otimes_R V & = \n        \\left.\n        R^{U\\times V}\\middle/\n        \\left\\langle \\begin{array}{c}\n        e_{u+\\tilde{u}}\\otimes e_v=e_u\\otimes e_v+e_{\\tilde{u}}\\otimes e_v,\\\\\n        e_u\\otimes e_{v+\\tilde{v}}=e_u\\otimes e_v+e_u\\otimes e_{\\tilde{v}},\\\\\n        e_{ur}\\otimes e_v=e_u\\otimes e_{rv}\n        \\end{array}\\right\\rangle\n        \\right.\n    \\end{align*}\n    So established methods are a special case.\n\\end{frame}\n\n\\begin{frame}\n    Similar ideas picking up on matrix-vector product $R^{m\\times n}\\times R^n\\bmto R^m$ \n    give rise to \n    \\[U\\oslash V\\times V\\bmto U\\] \n\n    Which behave like fractions, e.g.\\ \n    \\[ A\\oslash K\\cong A\\qquad A\\to K\\oslash (K\\oslash A)\\]\n\n    \\[A\\oslash (B\\otimes C)=A\\oslash B\\oslash C\\] \n    I.e.\n    \\[\\hom(C\\otimes B,A) \\cong \\hom(C,\\hom(B,A))\\]\n\\end{frame}\n\n\\section{Solving for Coordinates}\n\n\\begin{frame}\n    \n    \\begin{block}{Applications}\n        We \\emph{have} a tensor.  Why would we want a tensor product?\n    \\end{block}\n\n\\end{frame}\n\n\\begin{frame}[fragile]\n    What if $R=R_1\\oplus R_2$?\n\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            (R_1\\oplus R_2)^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_R=\\Span X\\arrow[d,phantom,\"\\times\"]  \\\\\n            (R_1\\oplus R_2)^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & {_R V}=\\Span Y\\arrow[d,\"\\otimes\",tail] \\\\            \n            (R_1\\oplus R_2)^{X\\times Y} \\arrow[r,two heads] \n                     & U\\otimes_{R_1\\oplus R_2} V   \\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n\\end{frame}\n\n\\begin{frame}[fragile]\n    What if $R=R_1\\oplus R_2$?\n\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            R_1^X\\oplus R_2^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_1\\oplus U_2\\arrow[d,phantom,\"\\times\"]  \\\\\n            R_1^Y\\oplus R_2^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & V_1\\oplus V_2\\arrow[d,\"\\otimes\",tail] \\\\            \n            R_1^{X\\times Y}\\oplus R_2^{X\\times Y} \\arrow[r,two heads] \n                     & (U_1\\otimes_{R_1} V_1)\\oplus (U_2\\otimes_{R_2} V_2)   \\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n    \n    That's one of these: \n    \\pgfmathsetmacro{\\xx}{0.5}\n    \\begin{tikzpicture}\n\t\t\t\\pic at (\\xx,-\\xx,0) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,0,\\xx) {shadedcube={\\xx/\\xx/\\xx/gray/}};\n\t\t\t\\pic at (0,\\xx,0) {opencube={2*\\xx/-2*\\xx/2*\\xx}};\n\t\t\\end{tikzpicture}\n    ...for which people are hunting!\n\\end{frame}\n\n\n\\begin{frame}[fragile]\n    Solve for \\textbf{universal} $R$!\n\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            (?)^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_?=\\Span X\\arrow[d,phantom,\"\\times\"] \\arrow[r,equal] \n                        & U\\arrow[d,phantom,\"\\times\"] \\\\\n            (?)^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & {_? V}=\\Span Y\\arrow[d,\"\\otimes\",tail] \\arrow[r,equal]\n                    & V\\arrow[d,\"*\",tail]\\\\            \n            (?)^{X\\times Y} \\arrow[r,two heads] \n                     & U\\otimes_{?} V \\arrow[r]\n                        &  W\\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n\n    Solution is the \\textbf{Centroid}\n    \\[\n        C(*)=\\{(X,Y,Z)\\mid Xu*v=Z(u*v)=u*(Yv)\\}\n    \\]\n\\end{frame}\n\n\\begin{frame}{Cluster Algorithm (W. 2008)}\n    $C(*)=\\{(X,Y,Z)\\mid  Xu*v=Z(u*v)=u*(Yv)\\}$\n\n    Random $\\alpha\\in C(*)$, \\\\\n    if $\\min_{\\alpha}(x)=a(x) b(x)$ with $\\deg a(x),\\deg b(x)>0$ and \n    \\[1=\\mathrm{GCD}(a(x),b(x))=s(x)a(x)+t(x)b(x)\\]\n\n    Then $e = s(\\alpha )a(\\alpha)$; $f=t(\\alpha)b(\\alpha)$\\\\\n    Return $U=eU\\oplus fU$, $V=eV\\oplus fV$, $W=eW\\oplus fW$.\\\\\n    \n    Else try another $\\alpha$. \n\n    \\bigskip\n\n    \\textbf{Theorem W.} The resulting clusters are unique.\n\n    %With constant number of trials you have decomposed or proven indecomposability.\n\\end{frame}\n\n\\begin{frame}\n    Other observation:  Writing a product over larger coefficients makes for smaller \n    dimensions.  \n\n    Isomorphism testing speeds up by orders of magnitude.\n\\end{frame}\n\n\n% \\begin{frame}[fragile]\n%     General situation: \n%     \\[\\Omega \\to \\End(U_1)\\times\\cdots\\times \\End(U_n)\\]\n\n%     \\centering\n%     \\begin{tikzpicture}\n%         \\node at (0,0) {\\begin{tikzcd}\n%             \\Omega|_1^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n%                     & U_1=\\Span X\\arrow[d,phantom,\"\\times\"]\\\\\n%                    \\vdots\\arrow[d,phantom,\"\\times\"] & \\vdots\\arrow[d,phantom,\"\\times\"] \\\\ \n%             \\Omega|_n^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \\\\\n%                     & U_n\\arrow[d,\"(\\cdots)\",tail]\\\\            \n%             \\Omega^{X\\times Y} \\arrow[r,two heads] \n%                      & U_0\\\\\n%         \\end{tikzcd}};\n%     \\end{tikzpicture}\n% \\end{frame}\n\n\\begin{frame}{Wakeup Pure Algebra; you're directly useful!}\n    For data science tensors use is still spartan.\n\n    Different decompositions call for solving for different coordinate types, \n    adjoints, nuclei, derivations, ... \n    \n    Such ideas essentially the same arose in \n    \\begin{itemize}\n        \\item Kaplansky and Jacobson non-associative algebras.\n        \\item Mal'cev and Miyasnikov on Groups of finite Morley Rank.\n        \\item Finite Simple groups, e.g.\\ Parker-Norton MeatAxe and Schneider's work\n        \\item W. Direct and central product decomps. of $p$-groups.\n    \\end{itemize}\n\n\\end{frame}\n\n\\subsection{New Tensor Products}\n\n\\begin{frame}[fragile]\n    Look back...did $R$ have to be a ring?\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            \\Span S \\arrow[d,phantom,\"\\times\"]\\arrow[r, hook] \n                & R^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_R=\\Span X\\arrow[d,phantom,\"\\times\"]  \\\\\n            \\Span T \\arrow[r, hook]\\arrow[d,\"\\boxtimes\",tail] \n                & R^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & {_R V}=\\Span Y\\arrow[d,\"\\otimes\",tail] \\\\            \n            R^X\\boxtimes T+S\\boxtimes R^Y \\arrow[r, hook] \n                 & R^{X\\times Y} \\arrow[r,two heads] \n                     & U\\otimes_R V   \\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n\n    This quotient exists because we create a two-sided ideal.  No use \n    of associative ring $R$.\n\\end{frame}\n\n\\begin{frame}[fragile]\n    You can use \\textbf{any non-associative algebra} $A$.\n\n    Assume Lie, e.g. $[a,b]=ab-ba$ in a ring $R$.\n\n    \\centering\n    \\begin{tikzpicture}\n        \\node at (0,0) {\\begin{tikzcd}\n            \\Span S \\arrow[d,phantom,\"\\times\"]\\arrow[r, hook] \n                & A^X\\arrow[d,phantom,\"\\times\"] \\arrow[r,two heads] \n                    & U_A=\\Span X\\arrow[d,phantom,\"\\times\"]  \\\\\n            \\Span T \\arrow[r, hook]\\arrow[d,\"\\boxtimes\",tail] \n                & A^Y\\arrow[d,\"\\boxtimes\",tail] \\arrow[r,two heads] \n                    & {_A V}=\\Span Y\\arrow[d,\"\\otimes\",tail] \\\\            \n            R^X\\boxtimes T+S\\boxtimes R^Y \\arrow[r, hook] \n                 & A^{X\\times Y} \\arrow[r,two heads] \n                     & U\\otimes_a V   \\\\\n        \\end{tikzcd}};\n    \\end{tikzpicture}\n\n    With a lie algebra $ua\\otimes v\\neq u\\otimes av$ but instead\n    \\[ [a,u\\otimes v] = [a,u]\\otimes v+u\\otimes [a,v]\\]\n\\end{frame}\n\n\\begin{frame}{Lie tensor products}\n\\only<1>{\n    \\begin{block}{Definability}\n        Whitney tensor product $U_0\\otimes_{R_1}\\cdots \\otimes_{R_n} U_n$ not \n        generally well-defined (need bimodules or commutativity, i.e. constraints).\n\n        Lie tensor product $\\den{U_1,\\ldots, U_n}_L$ exists for arbitrary numbers of modules.\n    \\end{block}\n}\n\\only<2>{\n    \\begin{block}{Global reach}\n        Whitney tensor product $U_0\\otimes_{R_1}\\cdots \\otimes_{R_n} U_n$ (when defined) \n        compares nearest neighbor relationships.\n\n        Lie tensor product $\\den{U_1,\\ldots, U_n}_L$ compares all modules to all others.\n    \\end{block}\n}\n\\only<3>{\n    \\begin{block}{Size}\n        Whitney Tensor Product\n        \\[\\dim U_0\\otimes_{R_1}\\cdots \\otimes_{R_n} U_n\\approx \n        \\frac{\\dim U_1\\cdots \\dim U_n}{\\dim R_1\\cdots \\dim R_n}\\]\n\n        Lie tensor product \n        \\[\n            \\dim \\den{U_1,\\ldots, U_n}_L\n        \\]\n        given by subtle Clebsch-Gordan formulas, can actually be bounded by \n        a constant while $\\dim U_a$ go to infinity.\n    \\end{block}\n}\n\\end{frame}\n\n\n\\begin{frame}{Universality of Derivation Tensors ``Densors''}\n\n    \\begin{block}{Theorem First-Maglione-W.}\n        If a tensor $T$ factors through a tensor product over any nonassociative algebra $A$\n        then $A$ then the tensor product $\\otimes_A :U\\times V\\bmto U\\otimes_A V$ \n        factors through the Lie tensor product over the derivations of $T$.\n    \\end{block}\n\n    In formally the Lie tensor product over derivations is universal.\n\n\n\\end{frame}\n\n\\begin{frame}{Limits on Associativity}\n\n    \\begin{block}{Theorem FMW}\n        Over fields with some nondegeneracy conditions.  \n        If $\\Omega \\subset \\End(U_1)\\times \\cdots \\times \\End(U_n)$ is \n        closed to composition then the operators in $\\Omega$ are limited to nearest neighbor \n        interactions governed by binomials \n        \\[X^{e_1}-X^{f_1},\\ldots, X^{e_n}-X^{f_n}\\]\n        where the neighborhood is given by the support of $(e_i,f_i)$\n    \\end{block}\n\n    \\includegraphics[width=5in]{graphic.png}\n\n\\end{frame}\n\n\\end{document}", "meta": {"hexsha": "e8197b04c1ec21d61400696843ec4e54114ced43", "size": 29146, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Cluster/Cluster.tex.tex", "max_stars_repo_name": "algeboy/talks", "max_stars_repo_head_hexsha": "0787c45eb8d69ac4bbf5e23a35b9f83d910b5d73", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cluster/Cluster.tex.tex", "max_issues_repo_name": "algeboy/talks", "max_issues_repo_head_hexsha": "0787c45eb8d69ac4bbf5e23a35b9f83d910b5d73", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cluster/Cluster.tex.tex", "max_forks_repo_name": "algeboy/talks", "max_forks_repo_head_hexsha": "0787c45eb8d69ac4bbf5e23a35b9f83d910b5d73", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4923076923, "max_line_length": 195, "alphanum_fraction": 0.5522198586, "num_tokens": 11001, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.40219347296788427}}
{"text": "\\subsection{Rectifier Behavior}\\label{sec:rectifier-behavior}\nA rectenna receives electromagnetic power via antenna and convert it to electric power with rectifier. Diverse configurations are available for energy harvesting, such as \\textit{Schottky} \\cite{Akkermans2005, Boaventura2013}, \\textit{CMOS} \\cite{Stoopman2014, Valenta2014}, \\textit{series} \\cite{Georgiadis2011, Collado2013}, \\textit{shunt} \\cite{McSpadden1998, Guo2012}. It is worth noting that those models favor different input power levels. As reported in \\cite{Valenta2014, Costanzo2016}, low barrier Schottky diodes are commonly used for input power between \\SI{1}{\\uW} and \\SI{1}{\\mW}. Specifically, single diode is preferred for a power below \\SI{500}{\\uW} while multiple diodes are more suitable for power above \\SI{500}{\\uW} \\cite{Clerckx2019}. Hybrid designs as \\cite{Sun2013} may be employed to maintain a high efficiency for a wide power range.\n\nBesides the rectenna model, the shape of the received signal also influences the RF-to-DC efficiency ${e_3}$. It was first demonstrated in \\cite{Trotter2009} that multisine waveform i.e. \\textit{Power-Optimized waveform} (POW) outperforms the single-tone waveform i.e. \\textit{Continuous Wave} (CW) in both operation range and power efficiency. Therefore, multisine is commonly employed in WPT waveform design.\n\nThe expression of a multisine waveform with $N$ subcarriers writes as a summation of $N$ sine waves\n\n\\begin{equation}\\label{eqn:multisine}\n  {V_{{\\text{multisine}}}}(t) = \\sum\\limits_{n = 0}^{N - 1} {\\frac{1}{{\\sqrt N }}} \\sin \\left( {2\\pi \\left( {{f_{\\text{0}}} + n\\Delta f} \\right)t} \\right)\n\\end{equation}\n\nwhere ${{f_{\\text{0}}}}$ is the minimum frequency and ${\\Delta f}$ is the spacing. Fig. \\ref{fig:waveform_comparison} \\cite{Trotter2009} illustrates a three-subcarrier multisine and single sine in time and frequency domains. It can be observed that multisine provides a higher PAPR of ${\\sqrt N }$ and occupies a bandwidth of $(N - 1) \\Delta f$. Compared with the single sine, it has the same average power but equally distributed to the components. The thick lines indicate typical rectifier output voltage.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[Frequency domain]{\n    \\includegraphics[width=0.48\\textwidth]{waveform_frequency_domain}\\label{fig:waveform_frequency_domain}}\n  \\subfigure[Time domain]{\n    \\includegraphics[width=0.48\\textwidth]{waveform_time_domain}\\label{fig:waveform_time_domain}}\n  \\caption{A typical 3-subcarrier multisine and single sine \\cite{Trotter2009}}\n  \\label{fig:waveform_comparison}\n\\end{figure}\n\nThe advantage of multisine is that high PAPR can be exploited to increase the peak output voltage of the rectifier. With a proper signal and circuit design, the high output voltage may be preserved during the cycle if discharging is slow enough (as indicated by the thick blue line in Fig. \\ref{fig:waveform_time_domain}). To enhance the harvested power, a large number of tones may be used to increase PAPR, and the multisine signal will appear as pulses with a period of $1/\\Delta f$. Most of the signal power will be concentrated in those pulses to trigger the diode and charge the capacitor. However, more subbands can lead to smaller frequency gaps and longer charging cycle when the bandwidth is fixed.\n\nIt can be hard to derive an accurate expression of the RF-to-DC efficiency ${e_3}$ on the power and shape of the rectifier input signal, as practical energy harvesting circuits consists of various nonlinear components like diodes, capacitors, and inductors. It is also sensitive to parasitic sources, impedance matching, and harmonic generation \\cite{Strassner2013, Valenta2014}. In this article, we employ the \\textit{diode linear model} and \\textit{diode nonlinear model} proposed in \\cite{Clerckx2016} based on the diode current-voltage (I-V) characteristics to capture the fundamental pattern of the rectifier and investigate its impact on resource allocation and system design. A superposed waveform containing modulated information and multisine power components is optimized according to CSI on top of both models.\n\n\n\n\\subsection{Antenna Model}\\label{sec:antenna-model}\n\nAs illustrated in Fig. \\ref{fig:single_diode_rectifier} \\cite{Clerckx2016}, the rectifier consists of a single diode as the source of nonlinearity and a low-pass filter to store energy.\n\n\\begin{figure}[ht]\n  \\centering\n  \\subfigure[A single diode rectifier]{\n    \\includegraphics[width=0.48\\textwidth]{single_diode_rectifier}\\label{fig:single_diode_rectifier}}\n  \\subfigure[Antenna equivalent circuit]{\n    \\includegraphics[width=0.48\\textwidth]{antenna_equivalent_circuit}\\label{fig:antenna_equivalent_circuit}}\n  \\caption{Rectenna architecture \\cite{Clerckx2016}}\n  \\label{fig:rectenna_architecture}\n\\end{figure}\n\nFig. \\ref{fig:antenna_equivalent_circuit} illustrates the antenna equivalent circuit. It includes a voltage source ${v_{\\text{s}}}(t)$ connected to a series antenna impedance ${Z_{{\\text{ant}}}} = {R_{{\\text{ant}}}} + j{X_{{\\text{ant}}}}$, followed by a combined impedance of the rectifier and the matching network ${Z_{{\\text{in}}}} = {R_{{\\text{in}}}} + j{X_{{\\text{in}}}}$. Assuming lossless, the perfect matching condition is\n\n\\begin{equation}\\label{eqn:perfect_match}\n  {R_{{\\text{in}}}} = {R_{{\\text{ant}}}},{X_{{\\text{in}}}} =  - {X_{{\\text{ant}}}}\n\\end{equation}\n\nWhen \\eqref{eqn:perfect_match} is satisfied, the rectifier input voltage equals\n\n\\begin{equation}\\label{eqn:rectifier_input_voltage}\n  {v_{{\\text{in}}}}(t) = {v_{\\text{s}}}(t)/2 = y(t)\\sqrt {{R_{{\\text{in}}}}}\n\\end{equation}\n\nwhere ${y(t)}$ is the received signal. Therefore, the input power to the rectifier is\n\n\\begin{equation}\\label{eqn:rectifier_input_power}\n  P_{{\\text{rf}}}^r = \\mathbb{E}\\left[ {y{{(t)}^2}} \\right] = \\mathbb{E}\\left[ {{v_{{\\text{in}}}}{{(t)}^2}} \\right]/{R_{{\\text{in}}}}\n\\end{equation}\n\nIt is also assumed that the noise is too small to be harvested.\n\n\n\n\\subsection{Diode Characteristics}\\label{sec:diode-characteristics}\nConsider the single diode rectifier presented in Fig. \\ref{fig:single_diode_rectifier} for simplicity. Without loss of generality, the diode models can be employed for other circuits as voltage doubler and bridge rectifiers \\cite{Clerckx2017}.\n\nDenoting ${v_{{\\text{in}}}}(t)$ and ${v_{{\\text{out}}}}(t)$ as diode input and output voltages, the voltage across the diode is ${v_{\\text{d}}}(t) = {v_{{\\text{in}}}}(t) - {v_{{\\text{out}}}}(t)$. It determines the current flowing through the diode\n\n\\begin{equation}\\label{eqn:diode_characteristics}\n  {i_{\\text{d}}}(t) = {i_{\\text{s}}}\\left( {{e^{\\frac{{{v_{\\text{d}}}(t)}}{{n{v_{\\text{t}}}}}}} - 1} \\right)\n\\end{equation}\n\nwhere ${i_{\\text{s}}}$ is the reverse saturation current, $n$ is the ideality factor, and ${{v_{\\text{t}}}}$ is the thermal voltage. With Taylor expansion around a quiescent point $a = {v_{\\text{d}}}(t)$, \\eqref{eqn:diode_characteristics} rewrites as\n\n\\begin{equation}\\label{eqn:diode_current_expansion}\n  {i_{\\text{d}}}(t) = \\sum\\limits_{i = 0}^\\infty  {k_i^\\prime } {\\left( {{v_{\\text{d}}}(t) - a} \\right)^i}\n\\end{equation}\n\nwith\n\n\\begin{equation}\\label{eqn:diode_k_prime}\n  k_i^\\prime  = \\left\\{ {\n  \\begin{array}{*{20}{c}}\n    {{i_{\\text{s}}}\\left( {{e^{\\frac{a}{{n{v_{\\text{t}}}}}}} - 1} \\right),}&{i = 0} \\\\\n    {{i_{\\text{s}}}\\frac{{{e^{\\frac{a}{{n{v_{\\text{t}}}}}}}}}{{i!{{\\left( {n{v_{\\text{t}}}} \\right)}^i}}},}&{i \\in {\\mathbb{N}^ + }}\n  \\end{array}} \\right.\n\\end{equation}\n\n\n$k_i^\\prime $ depends on the diode parameters and is a constant when $a$ is fixed. Note that the Taylor series expression is a small-signal model that only fits the nonlinear operation region of the diode. Therefore, \\eqref{eqn:diode_current_expansion} is no longer accurate for a large input voltage ${v_{{\\text{in}}}}(t)$, where the diode behavior is dominated by the series resistor and the I-V relationship is linear \\cite{Boaventura2013}.\n\nAlso, we assume an ideal rectifier with steady-state response to deliver a constant output voltage ${v_{{\\text{out}}}}$, whose amplitude is a function of the peaks of the input voltage ${v_{{\\text{in}}}}(t)$ \\cite{Curty2005}. Based on those assumptions, a proper choice of voltage drop would be\n\n\\begin{equation}\\label{eqn:diode_voltage_drop}\n  a = \\mathbb{E}\\left[ {{v_{\\text{d}}}(t)} \\right] = \\mathbb{E}\\left[ {{v_{{\\text{in}}}}(t) - {v_{{\\text{out}}}}} \\right] =  - {v_{{\\text{out}}}}\n\\end{equation}\n\nOn top of \\eqref{eqn:diode_voltage_drop} and \\eqref{eqn:rectifier_input_voltage}, the diode current \\eqref{eqn:diode_current_expansion} can be further expressed as\n\n\\begin{equation}\\label{eqn:diode_current}\n  {i_{\\text{d}}}(t) = \\sum\\limits_{i = 0}^\\infty  {k_i^\\prime } {v_{{\\text{in}}}}{(t)^i} = \\sum\\limits_{i = 0}^\\infty  {k_i^\\prime } R_{{\\text{ant}}}^{i/2}y{(t)^i}\n\\end{equation}\n\nIt reveals an explicit relationship between the received waveform $y(t)$ and the diode current ${i_{\\text{d}}}(t)$. Nevertheless, the waveform varies at every symbol period due to the randomness of the input distribution. Hence, the diode current ${i_{\\text{d}}}(t)$ also fluctuates with time. By taking an expectation over the symbol distribution, the harvested DC current can be modeled as\n\n\\begin{equation}\\label{eqn:diode_current_expectation}\n  {i_{{\\text{out}}}} = \\mathbb{E}\\left[ {{i_{\\text{d}}}(t)} \\right]\n\\end{equation}\n\nand the available power is\n\n\\begin{equation}\\label{eqn:harvested_power}\n  P_{{\\text{dc}}}^r = i_{{\\text{out}}}^2{R_{\\text{L}}} = \\mathbb{E}{\\left[ {{i_{\\text{d}}}(t)} \\right]^2}{R_{\\text{L}}}\n\\end{equation}\n\nTo investigate the fundamental dependency of harvested power on waveform design, a practical strategy is to approximate \\eqref{eqn:diode_current} with truncation to the ${n_o}$-th order\n\n\\begin{equation}\\label{eqn:output_current_truncation}\n  {i_{{\\text{out}}}} \\approx \\sum\\limits_{i = 0}^{{n_o}} {k_i^\\prime } R_{{\\text{ant}}}^{i/2}\\mathbb{E}\\left[ {y{{(t)}^i}} \\right]\n\\end{equation}\n\nThe contribution of odd terms is indeed zero as $\\mathbb{E}\\left[ {y{{(t)}^i}} \\right] = 0$ for odd $i$. Therefore, the approximated rectifier output DC current equals\n\n\\begin{equation}\\label{eqn:output_current_function}\n  {i_{{\\text{out}}}} \\approx \\sum\\limits_{i{\\text{ even,i}} \\geqslant 0}^{{n_o}} {k_i^\\prime \\left( {{i_{{\\text{out}}}}} \\right)} R_{{\\text{ant}}}^{i/2}\\mathbb{E}\\left[ {y{{(t)}^i}} \\right]\n\\end{equation}\n\nRecall from \\eqref{eqn:diode_k_prime} that the diode parameter $k_i^\\prime $ is a function of $a =  - {v_{{\\text{out}}}} =  - {i_{{\\text{out}}}}{R_{\\text{L}}}$. Therefore, ${i_{{\\text{out}}}}$ occur in both sides of \\eqref{eqn:output_current_function}. \\cite{Clerckx2016} suggested an approach to decouple the correlation. Denote\n\n\\begin{equation}\\label{eqn:diode_k_prime_prime}\n  k_0^{\\prime \\prime } = {e^{\\frac{a}{{n{v_{\\text{t}}}}}}} = {e^{ - \\frac{{{R_{\\text{L}}}{i_{{\\text{out}}}}}}{{n{v_{\\text{t}}}}}}}\n\\end{equation}\n\nsuch that $k_0^\\prime  = {i_{\\text{s}}}(k_0^{\\prime \\prime } - 1)$ and \\eqref{eqn:output_current_function} rewrites as\n\n\\begin{equation}\\label{eqn:output_current_rewritten}\n  {e^{\\frac{{{R_{\\text{L}}}{i_{{\\text{out}}}}}}{{n{v_{\\text{t}}}}}}}\\left( {{i_{{\\text{out}}}} + {i_{\\text{s}}}} \\right) \\approx {i_{\\text{s}}} + \\sum\\limits_{i{\\text{ even}},i \\geqslant 2}^{{n_o}} {\\frac{{k_i^\\prime }}{{k_0^{\\prime \\prime }}}} R_{{\\text{ant}}}^{i/2}\\mathbb{E}\\left[ {y{{(t)}^i}} \\right]\n\\end{equation}\n\nNote the r.h.s. of \\eqref{eqn:output_current_rewritten} is independent of ${i_{{\\text{out}}}}$. On the other hand, the l.h.s. is a monotonic increasing function of ${i_{{\\text{out}}}}$. Therefore, we can further write\n\n\\begin{equation}\\label{eqn:diode_k}\n  {k_i} = \\frac{{k_i^\\prime }}{{k_0^{\\prime \\prime }}} = \\frac{{{i_{\\text{s}}}}}{{i!{{\\left( {n{v_{\\text{t}}}} \\right)}^i}}}\n\\end{equation}\n\nTherefore, maximizing ${i_{{\\text{out}}}}$ is equivalent to maximizing the target function\n\n\\begin{equation}\\label{eqn:target_function}\n  {z_{DC}} = \\sum\\limits_{i{\\text{ even,i}} \\geqslant 2}^{{n_o}} {{k_i}} R_{{\\text{ant}}}^{i/2}\\mathbb{E}\\left[ {y{{(t)}^i}} \\right]\n\\end{equation}\n", "meta": {"hexsha": "493d175975482a7e8b347067b35ed2af87003d36", "size": 12050, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/thesis/from-wpt-to-wipt/rectenna-design.tex", "max_stars_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_stars_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2019-07-10T21:31:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T18:01:41.000Z", "max_issues_repo_path": "tex/thesis/from-wpt-to-wipt/rectenna-design.tex", "max_issues_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_issues_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/thesis/from-wpt-to-wipt/rectenna-design.tex", "max_forks_repo_name": "SnowzTail/signal-optimisation-for-wireless-information-and-power-transmission", "max_forks_repo_head_hexsha": "f53382f99610becd8d78ee34cc9c3d49d2c7f61b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2020-06-12T23:20:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T18:01:46.000Z", "avg_line_length": 78.7581699346, "max_line_length": 858, "alphanum_fraction": 0.7126141079, "num_tokens": 3922, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40219346944133555}}
{"text": "% This is part of the TFTB Tutorial.\n% Copyright (C) 1996 CNRS (France) and Rice University (US).\n% See the file tutorial.tex for copying conditions.\n\nUp to this point, we have examined the main solutions proposed to\nthe problem of representing a non-stationary signal in the\ntime-frequency plane. We now consider the problem of the\ninterpretation of the time-frequency image which describes the\nevolution with time of the frequency content of the signal. Even if they\nall tend to the same goal, each representation has to be interpreted\ndifferently, according to its own properties. For example, some of\nthem present important interference terms, other are only positive,\nother are perfectly localized on particular signals\\ldots So the\nextraction of information has to be done with care, from the knowledge\nof these properties. We give in the following some general guide lines\nto profit from a time-frequency image.\n\n\n\\section{Moments and marginals}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  The moments and marginals of some representations provide important\ninformation about the signal, like its amplitude modulation or its\ninstantaneous frequency, for example with the aim of demodulating the\nsignal. \n\n\\subsection{Moments}\n%'''''''''''''''''''\n\\index{moments}\n  The first and second order moments, in time and in frequency, of a\ntime-frequency energy distribution tfr are defined as\n\\begin{eqnarray*}\nf_m(t) &=& \\frac{\\int_{-\\infty}^{+\\infty} f\\ \\mbox{tfr}(t,f)\\ df}\n{\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ df}\\ \n  \\\\\nB^2(t)  &=& \\frac{\\int_{-\\infty}^{+\\infty} f^2\\ \\mbox{tfr}(t,f)\\ df}\n{\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ df}\\  - f_m(t)^2; \n\\end{eqnarray*}\nfor the {\\it time moments}, and as\n%where $E=\\int\\int_{-\\infty}^{+\\infty}\\mbox{tfr}(t,f)\\ dt\\ df$ is the energy \n%of the signal, \n\\begin{eqnarray*}\nt_m(f) &=& \\frac{\\int_{-\\infty}^{+\\infty} t\\ \\mbox{tfr}(t,f)\\ dt}\n{\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ dt}\\\\ \nT^2(f)  &=& \\frac{\\int_{-\\infty}^{+\\infty} t^2\\ \\mbox{tfr}(t,f)\\ dt}\n{\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ dt}\\ - t_m(f)^2; \n\\end{eqnarray*}\nfor the {\\it frequency moments}. They describe the averaged positions and\nspreads in time and in frequency of the signal. For some particular\ndistributions, if the signal is considered in its analytic form, the first\norder moment in time also corresponds to the instantaneous frequency, and\nthe first order moment in frequency to the group delay of the signal. These\nmoments can be obtained numerically thanks to the functions\n\\index{\\ttfamily momttfr}{\\ttfamily momttfr.m} and \\index{\\ttfamily\nmomftfr}{\\ttfamily momftfr.m}.\n  \n\\subsection{Marginals}\n%'''''''''''''''''''''\n\\index{marginals} It can also be interesting to consider the {\\it marginal\ndistributions} of a time-frequency representation. These marginals are\ndefined as\\,:\n\\begin{eqnarray*}\nm_f(t)=\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ df && \\mbox{\\it time\nmarginal}\\\\ \nm_t(f)=\\int_{-\\infty}^{+\\infty} \\mbox{tfr}(t,f)\\ dt && \\mbox{\\it frequency\nmarginal} \n\\end{eqnarray*}\nand express, by integrating the representation along one variable, the\nrepartition of the energy along the other variable. A natural\nconstraint for a time-frequency distribution is that the time marginal\ncorresponds to the instantaneous power of the signal, and that the\nfrequency marginal corresponds to the energy spectral density\\,:\n\\begin{eqnarray*}\nm_f(t)=|x(t)|^2\\ \\ \\mbox{ and }\\ \\ m_t(f)=|X(f)|^2.\t\n\\end{eqnarray*}\nThe M-file \\index{\\ttfamily margtfr}{\\ttfamily margtfr.m} computes the\nmarginal distributions of a given time-frequency representation.\n\n\n\\section{More on interferences\\,: information on phase}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  The interference terms present in any quadratic time-frequency\nrepresentation, even if they disturb the readability of the\nrepresentation, contain some information about the analyzed\nsignal. The precise knowledge of their structure and construction rule\nis useful to interpret the information that they contain. \n\n  For instance, the interference terms contain some information about the\nphase of a signal. Let us consider the pseudo WVD of the superposition of\ntwo constant frequency modulations, with a phase shift between the two\nsinusoids. If we compare the pseudo WVD for different phase shifts, we can\nobserve a time-sliding of the oscillating interferences. The M-file\n\\index{\\ttfamily movpwdph}{\\ttfamily movpwdph.m} illustrates this property\n(see fig. \\ref{Ex1fig1})\\,:\n\\begin{verbatim}\n     >> M=movpwdph(128); movie(M,10);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig1.eps}}\n\\caption{\\label{Ex1fig1}Two simultaneous complex sinusoids analyzed by the\npseudo-WVD\\,: the position of the interferences depends on the phase-shift\nbetween the two components. These phase-shifts are respectively $\\pi/4,\\\n3\\pi/4,\\ 5\\pi/4$ and $7\\pi/4$} \n\\end{figure}\nEach snapshot corresponds to the pseudo WVD with a different phase\nshift between the two components. \n\n  A second example of signature of the phase is given by the influence of a\njump of phase in a signal analyzed by the (pseudo) Wigner-Ville\ndistribution\\,: for instance, if we consider a constant frequency\nmodulation presenting a jump of phase in its middle (see\nfig. \\ref{Ex1fig2})\\,: \n\\begin{verbatim}\n     >> M=movpwjph(128,'C'); movie(M,10);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig2.eps}}\n\\caption{\\label{Ex1fig2}Complex sinusoid presenting a jump of phase in its\nmiddle, analyzed by the pseudo-WVD : the shape of the PWVD-pattern changes\nwith the importance of the jump. These jumps of phase are respectively $\\pi/4,\\\n\\pi/2,\\ 3\\pi/4$ and $pi$}\n\\end{figure}\nthe pseudo WVD presents a pattern around the jump position which is\nall the more important since this jump of phase is close to $\\pi$. This\ncharacteristic can be used to detect a jump of phase in a signal.\n\n\n\\section{Renyi information}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\index{Renyi information}\n  Another interesting information that one may need to know about an\nobserved non-stationary signal is the number of elementary signals\ncomposing this observation. This also leads us to the following question\\,:\nhow much separation between two elementary signals must one achieve in\norder to be able to conclude that there are two signals present rather than\none ? \n\n  A solution to this problem is given by applying an information measure to\na time-frequency distribution of the signal. Unfortunately, the well known\nShannon information, defined as \n\\begin{eqnarray*}\nI_x = -\\int_{-\\infty}^{+\\infty} f(x)\\ \\log_2 f(x)\\ dx\n\\end{eqnarray*}\nwhere $f(x)$ is the probability density function of $x$, can not be applied\nto some time-frequency distributions due to their negative values. The\ngeneralized form of information, which admits negative values in the\ndistribution, will then be used. This information, known as {\\it Renyi\ninformation}, is given by\n\\begin{eqnarray*}\nR_x^{\\alpha} =  \\frac{1}{1-\\alpha}\\ log_2\\left\\{\\int_{-\\infty}^{+\\infty}\nf^{\\alpha}(x)\\ dx\\right\\} \n\\end{eqnarray*}\nin the continuous case, where $\\alpha$ is the order of the\ninformation. First order Renyi information ($\\alpha=1$) reduces to Shannon\ninformation. Third order Renyi information, applied to a time-frequency\ndistribution $C_x(t,nu)$, is defined as\n\\begin{eqnarray*}\nR_C^3 = -\\frac{1}{2}\\\nlog_2\\left\\{\\int_{-\\infty}^{+\\infty}\\int_{-\\infty}^{+\\infty} C_x^3(t,\\nu)\\\ndt\\ d\\nu\\right\\}. \n\\end{eqnarray*}\nThe result produced by this measure is expressed in {\\it bits}\\index{bits\nof information}\\,: if one elementary signal yields zero bit of information\n($2^0$), then two well separated elementary signals will yield one bit of\ninformation ($2^1$), four well separated elementary signals will yield two\nbits of information ($2^2$), and so on. This can be observed by considering\nthe WVD of one, two and then four elementary atoms, and then by applying\nthe Renyi information on them. The file \\index{\\ttfamily renyi}{\\ttfamily\nrenyi.m} computes this information measure\\,:\n\\begin{verbatim}\n     >> sig=atoms(128,[64,0.25,20,1]); \n     >> [TFR,T,F]=tfrwv(sig);\n     >> R1=renyi(TFR,T,F)       ------> -0.2075\n\n     >> sig=atoms(128,[32,0.25,20,1;96,0.25,20,1]); \n     >> [TFR,T,F]=tfrwv(sig);\n     >> R2=renyi(TFR,T,F)       ------>  0.779\n\n     >> sig=atoms(128,[32,0.15,20,1;96,0.15,20,1;...\n                       32,0.35,20,1;96,0.35,20,1]);  \n     >> [TFR,T,F]=tfrwv(sig);\n     >> R3=renyi(TFR,T,F)       ------>  1.8029\n\\end{verbatim}\nWe can see that if {\\ttfamily R} is set to 0 for one elementary atom by\nsubtracting {\\ttfamily R1}, we obtain a result close to 1 for two atoms\n({\\ttfamily R2-R1}=0.99) and close to 2 for four atoms ({\\ttfamily\nR3-R1}=2.01). If the components are less separated in the time-frequency\nplane, the information measure will be affected by the overlapping of the\ncomponents or by the interference terms between them (see \\cite{WIL91} for\nmore details on this analysis). In particular, it is possible to show that\nthe Renyi information measure provides a good indication of the time\nseparation at which the atoms are essentially resolved, with a better\nprecision than with the time-bandwidth product.\n\n\n\\section{Time-frequency analysis\\,: help to decision}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n\\subsection{General considerations}\n%''''''''''''''''''''''''''''''''''\n  The decision problem that one can have to solve when analyzing a\nsignal is threefold\\,:\n\\begin{itemize}\n\\item detect if an observed signal contains a given information (i.e. say,\nfor a given false alarm probability, if {\\it yes} or {\\it no} the\ninformation is present)\\,;\n\\item estimate the parameters of a signal that we know to be present in\nan observation\\,;\n\\item classify a signal in one among different classes.\n\\end{itemize}\nThis problem, well known in theory in the general case, can be\nreconsidered when dealing with non-stationary signals, emphasized by\nthe theory of time-frequency representations. Without going into\ndetails, it has been shown that some of the known optimal strategies\nof decision can be reformulated equivalently in the time-frequency\nplane (like the matched-filter with the WVD for example). This result\nis interesting for two reasons\\,:\n\\begin{itemize}\n\\item on one hand, the time-frequency approach, compared to the\nclassical one (formulated in the time-domain in general), usually\nprovides a simpler interpretation of the decision test\\,;\n\\item on the other hand, when the optimal solution for a given criterion\nis not known in the decision theory, the time-frequency analysis can\nbe useful to formulate a sub-optimal solution based on the better\ncomprehension of the analyzed signal (for example, a time-frequency\ndetector can be easily modified to take into account variations of the\nnon-stationary signal to be detected, in order to improve the\nrobustness of the detector).\n\\end{itemize}\n  The proposed solutions in the literature construct a decision test\n(statistic) \n\\begin{itemize}\n\\item either as a general time-frequency correlation between a\ntime-frequency representation of the analyzed signal and some two\ndimensional template, constructed using the {\\it a priori} information\navailable on the signal,\n\\item or by applying a transform on the TF representation of the\nanalyzed signal, which brings to the fore some characteristic pattern\nof the signal to be detected (or estimated or classified), and by\napplying a test on this new space of decision. We consider in the\nfollowing an example of such approach, for the problem of the\ndetection and estimation of a linear frequency modulated signal\nembedded in some white gaussian noise.\n\\end{itemize}\n\n\n\\subsection{An example\\,: detection and estimation of linear FM signals}\n%''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n  As we have seen in section \\ref{WVD}, the WVD ideally concentrates the\nlinear chirp signals in the time-frequency plane. Thus, the problem of\ndetection and estimation of such a signal, which is not easily recognizable\nin the time-domain, is reduced to the problem of detection and estimation\nof a line in an image, which is a well known and easy-to-solve problem in\npattern recognition. This can be done by using the Hough transform,\ndedicated to the detection of lines (\\cite{BAR95}).\n\n\\subsubsection{The Hough transform for lines}\nConsider the polar parameterization of a line \n\\[x\\ \\cos\\theta+y\\ \\sin\\theta=\\rho\\] \n(this parameterization is much more adapted to this problem than the\nCartesian one). For each point $(x,y)$ of an image $I$, the Hough transform\nassociates a sinusoid in the plane $(\\rho,\\theta)$, whose points have an\namplitude equal to the intensity of the pixel $(x,y)$. So to all the points\nin $I$, the Hough transform associates a pencil of sinusoids which\nintersect themselves in the plane $(\\rho,\\theta)$. In other words, the HT\nperforms integrations along lines on the image $I$, and the value of each\nintegral is affected to the point $(\\rho,\\theta)$ corresponding to the\nparameters of this line. Therefore, if on the image $I$ some pixels with\nhigh intensities are concentrated along a straight line, we will observe in\nthe domain $(\\rho,\\theta)$ a peak whose coordinates are directly related to\nthe parameters of the lines.\n\n  This method can be easily applied to other parametric curves, like\nhyperbola for example. This transform is computed in the file\n\\index{\\ttfamily htl}{\\ttfamily htl.m}.\n\n\\subsubsection{The Wigner-Hough transform}\n\\index{Wigner-Hough transform}\nWhen applying the Hough transform to the Wigner-Ville distribution of the\nsignal\n\\begin{eqnarray*}\nx(t)=e^{j2\\pi(\\nu_0 t+\\beta/2 t^2)} + n(t) \n\\end{eqnarray*}\nobserved during an observation time $T$ ($n(t)$ is a noise assumed white\nand gaussian), we obtain a new transform called the {\\it Wigner-Hough\ntransform} (WHT), whose expression is\n\\begin{eqnarray}\n\\label{WHT}\nWH_x(\\nu_0,\\beta) &=& \\int_T W_x(t,\\nu_0+\\beta t)\\ dt\\\\\n &=& \\int_{-\\infty}^{+\\infty}\\int_T x(t+\\tau/2)\\ x^*(t-\\tau/2)\\ \n\t e^{-j2\\pi(\\nu_0+\\beta t)\\tau}\\ dt\\ d\\tau\\nonumber\n\\end{eqnarray}\n  The comparison of the WHT to a threshold is the proposed detection test,\nand the estimates of the unknown parameters $\\nu_0$ and $\\beta$ are given\nby the coordinates of the detected peak in the space of the parameters\n$(\\nu_0,\\beta)$. Thanks to the unitarity property of the WVD (Moyal's\nformula), it is possible to show that this detection test is {\\it\nasymptotically} the {\\it optimal detector} (i.e. optimal when $T$ tends to\ninfinity). Besides, the {\\it estimators} are {\\it asymptotically efficient}\n(i.e. they asymptotically reach the Cramer-Rao lower bounds).  Compared to\nthe classical decision test usually used in this case, the generalized\nlikelihood ratio test (GLRT), this method presents the following advantages\nin the case of multicomponent signals\\,:\n\\begin{itemize}\n\\item it is free from the estimation of the initial phase and amplitude\nof each component, which usually do not bring any information, and\n\\item its complexity do not increase with the number of components $N_c$,\nunlike the GLRT whose complexity increases linearly with $N_c$.\n\\end{itemize}\n\n  Here is an illustration of this decision test\\,: first, we consider\na linear chirp signal embedded in a white gaussian noise, with a 1\\,dB \nsignal-to-noise ratio\\,:\n\\begin{verbatim}\n     >> N=64; sig=sigmerge(fmlin(N,0,0.3),noisecg(N),1);\n\\end{verbatim}\nNow, if we analyze it with the WVD followed by the Hough transform (see\nfig. \\ref{Ex1fig3} and \\ref{Ex1fig4}),\n\\begin{verbatim}\n     >> tfr=tfrwv(sig); contour(tfr,5); grid\n     >> htl(tfr,N,N,1);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig3.eps}}\n\\caption{\\label{Ex1fig3}WVD of a noisy chirp signal (SNR=1 dB) : while the\nchirp is hardly readable in the time-representation, the line still clearly\nappear in the WVD}\n\\end{figure}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ex1fig4.eps}}\n\\caption{\\label{Ex1fig4}Wigner-Hough transform of the previous noisy\nchirp\\,: the peak corresponds to the chirp signal (and the side-lobes to\nthe noise), and its coordinates give estimators of the chirp\nparameters. The detection test consists in comparing this peak to a\nthreshold (threshold fixed by the chosen criterion)}\n\\end{figure}\nwe obtain, in the parameters' space $(\\rho,\\theta)$, a peak representing\nthe chirp signal, significantly more energetic than the other peaks\ncorresponding to the noise. The decision test is then very simple\\,: it\nconsists in applying a threshold on this representation, positioned\naccording to a detection criterion\\,; if the peak is higher than the\nthreshold, then the chirp is said to be present, and the coordinates of\nthat peak $(\\hat{\\rho},\\hat{\\theta})$ provide estimates of the chirp\nparameters (the change from $(\\hat{\\rho},\\hat{\\theta})$ to\n$(\\hat{\\nu_0},\\hat{\\beta})$ corresponds to the change from polar to\nCartesian coordinates).\n\n  In the case of a multi-component signal, the problem of interference\nterms appear. However, due to the oscillating structure of these terms, the\nintegration (\\ref{WHT}) operated by the Hough transform on the WVD will\nattenuate them. This can be observed on the following example\\,: we\nsuperpose two chirp signals with different initial frequencies and sweep\nrates (see fig. \\ref{Ex1fig5} and \\ref{Ex1fig6})\\,:\n\\begin{verbatim}\n     >> sig=sigmerge(fmlin(N,0,0.4),fmlin(N,0.3,0.5),1);\n     >> tfr=tfrwv(sig); contour(tfr,5); grid\n     >> htl(tfr,N,N,1);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig5.eps}}\n\\caption{\\label{Ex1fig5}WVD of two simultaneous chirp signals :\ninterference terms appear between the two components}\n\\end{figure}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=8cm\n\\centerline{\\epsfbox{figure/ex1fig6.eps}}\n\\caption{\\label{Ex1fig6}Wigner-Hough transform of the two-component chirp\nsignal : two main peaks are present, characterizing the two chirp\ncomponents, while the cross terms present in the WVD only introduce small\nside-lobes in the Wigner-Hough transform}\n\\end{figure}\nWe can see that the components are well separated in the parameter\nspace, in spite of the use of a nonlinearity in the WHT. Again, the\ncoordinates of the two peaks provide estimates of the different\nparameters. \n\n\n\\section{Analysis of local singularities}\n%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\\index{singularity}\\index{Holder exponent}\\index{regularity} If the\ntime-frequency representations are useful to bring to the fore the\nprogression with time of the frequency of a signal, the time-scale\nrepresentations are more adapted to the analysis of irregular structures\nand singularities, or of signals presenting self-similarities (such as\nfractional Brownian motion, \\cite{GON92}). We give in the following such an\nexample with the analysis of {\\it local singularities}, thanks to the\nscalogram and the Unterberger distribution.\n\n  The local regularity of a signal can be characterized by its {\\it Holder}\n(or {\\it Lipschitz} or {\\it scaling}) {\\it exponent}\\,: for a signal $x(t)$\nwhich is {\\it uniformly Holder} $H$, there exists a constant $C$ such that\n\\begin{eqnarray*}\n|x(s)-x(t)|\\ \\ \\leq\\ \\ C\\ |s-t|^H,\\ \\ 0<H<1.\n\\end{eqnarray*}\n$H$ then represents the {\\it exponent of regularity}\\index{exponent of\nregularity} of the signal. If we consider the wavelet transform\n$T_x(t,a;\\Psi)$ of this signal, with an analyzing wavelet $\\Psi$ such that\n$t\\ \\Psi(t)$ is absolutely integrable, then one can show that\n\\begin{eqnarray*}\n|T_x(t,a;\\Psi)|&\\leq& C\\ |a|^{H+1/2}\\ \\int_{-\\infty}^{+\\infty} |t|^H\\\n|\\Psi(t)|\\ dt\\\\ \n &=& O(|a|^{H+1/2})\\ \\ \\forall\\ t,\n\\end{eqnarray*}\nor, in terms of scalogram and behavior when $a$ tends to 0, \n\\begin{eqnarray*}\nE\\left[|T_x(t,a;\\Psi)|^2\\right] \\ \\sim\\ |a|^{2H+1},\\ \\ a\\rightarrow 0.\n\\end{eqnarray*}\nwhere $E[.]$ refers to the expectation. This means that the regularity\nof the signal can be recovered from the behavior of its scalogram at\nsmall scales, and it is possible to show that the reciprocal is true.\n\n  Since they are time-dependent in nature, the wavelet-based\ntechniques also allow an estimation of the local regularity of a\nsignal. In some sense, time-scale methods offer in this respect a\nframework similar to the one provided by time-frequency analysis for\ntracking the time evolution of spectral features. Indeed, if we now\nhave, at a given time $t_0$,\n\\begin{eqnarray}\n\\label{regularity}\n|x(t_0+\\tau)-x(t_0)|\\ \\leq\\ C\\ |\\tau|^{H(t_0)},\\ \\ 0<H(t_0)<1,\n\\end{eqnarray}\nthen we can establish the inequality\n\\begin{eqnarray*}\n|T_x(t,a;\\Psi)|&\\leq& C\\ |a|^{H(t_0)+1/2}\\ \\int_{-\\infty}^{+\\infty}\n|t|^{H(t_0)}\\ |\\Psi(t)|\\ dt \\\\ \n &&+ C\\ |t-t_0|^{H(t_0)}\\ \\int_{-\\infty}^{+\\infty} |\\Psi(t)|\\ dt\\\\ \n &=& O(|a|^{H(t_0)+1/2} + |t-t_0|^{H(t_0)}).\n\\end{eqnarray*}\nWe then obtain an image of the signal's regularity at the small scales\nof its wavelet transform (or scalogram), but accompanied with a time\nlocalization. The reciprocal is also true, which means that an\nappropriate decrease of the wavelet (scalogram) coefficients in a\ncone-shaped region of the time-frequency plane allows one to estimate\nthe local regularity of a signal.\n\n  If we further impose to condition (\\ref{regularity}) that the signal\npresents an asymptotic spectral decrease,\n\\begin{eqnarray*}\nX(\\nu) \\ \\sim\\ |\\nu|^{-(1+2H(t_0))}\\ e^{j2\\pi \\nu t_0}\\ \\ \\mbox{ for }\\ \\\n|\\nu|\\rightarrow\\infty, \n\\end{eqnarray*}\nthen we have the following approximation for the active Unterberger\ndistribution\\,:\n\\begin{eqnarray*}\nU_x(t,a) \\ \\sim\\ |a|^{2(1+H(t_0))}\\ \\delta(t-t_0),\\ \\ a\\rightarrow 0.\n\\end{eqnarray*}\nThus, the Unterberger distribution follows a law along scales which\ngives access to the strength of the singularity ($H$), and along time to\nthe localization of this singularity.\n\n  The file \\index{\\ttfamily holder}{\\ttfamily holder.m} estimates the\nHolder exponent of any signal from an affine time-frequency representation\nof it.\\\\\n\no {\\it Example}\\\\ For instance, we consider a 64-points Lipschitz\n  singularity (see \\index{\\ttfamily anasing}{\\ttfamily anasing.m}) of\n  strength $H=0$, centered at $t_0=32$,\n\\begin{verbatim}\n     >> sig=anasing(64);\n\\end{verbatim}\nand we analyze it with the scalogram (Morlet wavelet with half-length = 4, see\nfig. \\ref{Ex1fig7}),\n\\begin{verbatim}\n     >> [tfr,t,f]=tfrscalo(sig,1:64,4,0.01,0.5,256,1);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig7.eps}}\n\\caption{\\label{Ex1fig7}Scalogram of a Lipschitz singularity at time\n$t=32$, of strength $H=0$}\n\\end{figure}\nThe time-localization of the singularity can be clearly estimated from\nthe scalogram distribution at small scales : \n\\begin{verbatim}\n     >> H=holber(tfr,f,1,256,32)    ------>  H=-0.0381\n\\end{verbatim}\n\nIf we now consider a singularity of strength H=-0.5 (see\nfig. \\ref{Ex1fig8}),\n\\begin{verbatim}\n     >> sig=anasing(64,32,-0.5);\n     >> [tfr,t,f]=tfrscalo(sig,1:64,4,0.01,0.5,256,1);\n\\end{verbatim}\n\\begin{figure}[htb]\n\\epsfxsize=10cm\n\\epsfysize=10cm\n\\centerline{\\epsfbox{figure/ex1fig8.eps}}\n\\caption{\\label{Ex1fig8}Scalogram of a Lipschitz singularity at time\n$t=32$, of strength $H=-0.5$}\n\\end{figure}\nwe notice the different behavior of the scalogram along scales, whose\ndecrease is characteristic of the strength $H$. The estimation of the\nHolder exponent at $t=32$ gives :\n\\begin{verbatim}\n     >> H=holber(tfr,f,1,256,32)    ------>  H=-0.5107\n\\end{verbatim}\nwhich is close to 0.5.\n\nThe same conclusions can be observed from the active Unterberger\ndistribution.\n\n", "meta": {"hexsha": "0f2fed41d0049f37cc4a2d9d0e3bd4fb6506887d", "size": 23608, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tftb/tutorial/extract.tex", "max_stars_repo_name": "sangyoonHan/extern", "max_stars_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2018-03-28T01:50:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T07:24:14.000Z", "max_issues_repo_path": "tftb/tutorial/extract.tex", "max_issues_repo_name": "sangyoonHan/extern", "max_issues_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tftb/tutorial/extract.tex", "max_forks_repo_name": "sangyoonHan/extern", "max_forks_repo_head_hexsha": "a3c874538a7262b895b60d3c4d493e5b34cf81f8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2018-03-28T01:50:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T09:09:40.000Z", "avg_line_length": 46.0194931774, "max_line_length": 79, "alphanum_fraction": 0.7347932904, "num_tokens": 6756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.40219346944133555}}
{"text": "\\section{Introduction}\nVisual tasks, such as object classification and detection, have been successfully approached through the supervised learning paradigm. However, since manually labelled data is costly and not scalable, unsupervised learning is gaining momentum.\\newline\nRecently a new unsupervised learning paradigm is raising: \\emph{self-supervised} learning. The idea is to exploit different labeling that is freely available besides or within visual data, and to use them as intrinsic reward signals to learn general-purpose features.\nFor example, \\cite{context_prediction} uses the relative spatial co-location of patches in images as a label. In \\cite{unsupervised_models_recognition} they use object correspondence obtained through tracking in videos, and \\cite{learning_by_moving} uses ego-motion information obtained by a mobile agent such as the Google car \\cite{landmark_identification}. The features obtained with these approaches have been successfully transferred to classification and detections tasks with encouraging performances when compared to the supervised task.\\newline\nA fundamental difference between \\cite{context_prediction} and \\cite{unsupervised_models_recognition} is that the former method uses single images, while the latter use multiple images related through a temporal or viewpoint transformation. While it is true that biological agents typically make use of multiple images and other information, it is also true that single snapshot may carry more information than the one that has been extracted so far. In \\cite{Noroozi_2016} Noorozi and Favaro worked on a novel supervised task the \\emph{Jigsaw puzzle reassembly} problem, which builds features that yield high performance when transferred to detection and classification task. The experimental evaluations show them that the learned features capture semantically relevant content, and their method outperforms state of the art methods in several transfer learning benchmarks.\\newline\nIn this report we would like to implement the method found in \\cite{Noroozi_2016} and to apply the fine-tuning task to solve the classification task of Food Images \\cite{food_images} competition yielded by Kaggle \\cite{kaggle}. \n\n\n", "meta": {"hexsha": "e5c22335e3f59bbf873d66d86f928342f7c18ded", "size": 2212, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "relazione/sections/introduction.tex", "max_stars_repo_name": "mawanda-jun/NoLabels", "max_stars_repo_head_hexsha": "6861867ad5ab49fc7ae6f562977f60195f9ff216", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-27T09:41:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-27T09:41:58.000Z", "max_issues_repo_path": "relazione/sections/introduction.tex", "max_issues_repo_name": "mawanda-jun/NoLabels", "max_issues_repo_head_hexsha": "6861867ad5ab49fc7ae6f562977f60195f9ff216", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "relazione/sections/introduction.tex", "max_forks_repo_name": "mawanda-jun/NoLabels", "max_forks_repo_head_hexsha": "6861867ad5ab49fc7ae6f562977f60195f9ff216", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 245.7777777778, "max_line_length": 883, "alphanum_fraction": 0.8349909584, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.40219346944133555}}
{"text": "\t%to force start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Astronomy (Celestial Mechanics)}\\label{astronomy}\n\t\\lettrine[lines=4]{\\color{BrickRed}C}elestial mechanics is the consequence of the universal Newton's law of attraction (\\SeeChapter{see page \\pageref{newton gravitational law}}) and of the fundamental principle of mechanics (\\SeeChapter{see section Classical Mechanics page \\pageref{fundamental principle of static}}). Its main objective is the description of the motion of astronomical objects such as stars and planets using physical and mathematical theories.\n\t\n\tIn this section we will approach the subject as always on this book, in the most elementary  possible way (to this day the topics in this section are not technically beyond the level of what was done in the beginning of 20th century in the field of astronomy).\n\t\n\tFirst we will make a warm up with a funny law on the living in the Universe ... (the Drake equation). Once completed this warm up, we will begin to \"enumerate\" Kepler's laws (often referring to the section of Classical Mechanics) and then study in detail the properties of Keplerian orbits thanks to our knowledge on classical mechanics and then to using Special Relativity, which will lead us to find a theoretical procession of studied orbitals. Then we will have fun to model approximately the variation of the duration of the day (or night) on the Earth based on the month and latitude. Finally, to finish in style, we will launch the detailed calculation of the five Lagrangian points!\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/cosmology.jpg}\n\t\\end{figure}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tModern astronomy (that of the end and beginning of the 21st century) makes extensive use of statistical methods (ie Data Science/Data Mining). The reader interested on this topic can have an in-deep look at the page \\pageref{data mining} of this book or an overview in this excellent book \\cite{feigelson2012modern}.\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Drake Equation}\n\tThis equation was invented (...) by F. Drake in the 1960s with the intention to discuss the number of extraterrestrial civilizations in our galaxy with which we might come in contact in the context of the SETI program (Search for ExtraTerrestrial Intelligence). The main purpose of this equation for scientists is to determine its factors, in order to know the likely number and (very) estimated extraterrestrial civilizations.\n\t\n\tThis empirical equation which remains more something funny and provocative than something else... and  whose principle can be applied to a lot of different areas of physics and life is written:\n\t\n\tThe terms of this formula (because it is a formula and not a relation!) are defined as follows (the notation can differs as you can see it in the figure further below):\n\t\\begin{itemize}\n\t\t\\item $N^{*}$ represents the number of stars in a single galaxy\n\t\t\\item $f_p$ is the fraction of stars that would have an orbiting planet (between $0$ and $1$)\n\t\t\\item $n_e$ is the number of planets per star that fulfil the conditions for the development of life\n\t\t\\item $f_l$ is the fraction of planets whose life has emerged (between $0$ and $1$)\n\t\t\\item $f_i$ is the fraction of those where an intelligent life has emerged (between $0$ and $1$)\n\t\t\\item $f_c$ is the fraction of $f_i$ which has implemented radio communication technology (between $0$ and $1$)\n\t\t\\item $f_l$ is the fraction of time during which the fraction $f_i$ civilizations will live (between $0$ and $1$)\n\t\\end{itemize}\n\tIn practice, it should be noted that this formula purpose is to try to determine an unknown amount from other amounts that are also unknown ... But it's a nice and funny formula to evaluate when you discuss with friends at the restaurant...\n\t\n\tThere is therefore no guarantee that we are more knowledgeable after the estimate of this formula than before (method sometimes named in the literature \"garbage in, garbage out\"...).\n\t\n\tThe resulting value can motivate the fact that following mathematical developments are not only applicable to only one solar (star) system in the universe... maybe... (it would make a lot of useless empty space otherwise...).\n\t\n\tLet us talk now about the \"\\NewTerm{Fermi paradox}\\index{Fermi paradox}\"  named after physicist Enrico Fermi, is the apparent contradiction between the lack of evidence and high probability estimates, e.g., those given by the Drake equation, for the existence of extraterrestrial civilizations. The basic points of the argument, made by physicists Enrico Fermi (1901–1954) and Michael H. Hart (born 1932), are:\n\t\\begin{itemize}\n\t\t\\item There are billions of stars in the galaxy that are similar to the Sun, many of which are billions of years older than Earth.\n\t\t\\item With high probability, some of these stars will have Earth-like planets, and if the Earth is typical, some might develop intelligent life.\n\t\t\\item Some of these civilizations might develop interstellar travel, a step the Earth is investigating now.\n\t\t\\item Even at the slow pace of currently envisioned interstellar travel, the Milky Way galaxy could be completely traversed in a few million years.\n\t\\end{itemize}\n\tAccording to this line of reasoning, the Earth should have already been visited by extraterrestrial aliens. In an informal conversation, Fermi noted no convincing evidence of this, leading him to ask, \"Where is everybody?\" There have been many attempts to explain the Fermi paradox, primarily either suggesting that:\n\t\\begin{multicols}{2}\n\t\t\\begin{itemize}\n\t\t\t\\item Extraterrestrial life is rare or non-existent\n\t\t\t\\item No other intelligent species have arisen\n\t\t\t\\item Civilizations lack advanced technology\n\t\t\t\\item It is the nature of intelligent life to destroy itself\n\t\t\t\\item It is the nature of intelligent life to destroy others\n\t\t\t\\item There is periodic extinction by natural events\n\t\t\t\\item Intelligent civilizations are too far apart in space or time\n\t\t\t\\item It is too expensive to spread physically throughout the galaxy\n\t\t\t\\item Human beings have not existed long enough\n\t\t\t\\item Humans are not listening properly\n\t\t\t\\item Civilizations broadcast detectable radio signals only for a brief period of time\n\t\t\t\\item Civilizations tend to isolate themselves\n\t\t\t\\item Everyone is listening, no one is transmitting\t\n\t\t\t\\item Earth is deliberately not contacted\n\t\t\t\\item It is dangerous to communicate\n\t\t\t\\item ...\n\t\t\\end{itemize}\n\t\t\\end{multicols}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/drake_equation.jpg}\t\n\t\t\\caption{Drake equation}\n\t\\end{figure}\n\t\n\t\\pagebreak\n\t\\subsection{Kepler's Laws}\\label{kepler laws}\n\tIn astronomy, Kepler's laws describe the main properties of the motion of planets around a main star, without explaining the reason (at least at the time these laws were developed!). They were discovered by Johannes Kepler based on the observations and measurements (in phenomenal amount) of the position of the planets made by Tycho Brahe, measures that were very accurate for its time.\n\t\n\tThe first two Kepler's law seems to were published in 1609 and the third in 1618. The elliptical orbits, as set out in its first two laws can explain the complexity of the apparent motion of the planets.\n\t\n\tSoon after, in 1687 Isaac Newton discovered the law of gravitational attraction, deducting from it, by calculation, the three Kepler's laws.\n\t\n\tWe will now try to present these laws in the most relevant possible way:\n\t\n\t\\subsubsection{First Kepler's Law (conicity law)}\\label{conicity law}\n\tThe \"\\NewTerm{first law of Kepler}\\index{first law of Kepler}\", sometimes also named \"\\NewTerm{conicity law}\\index{conicity law}\" or \"\\NewTerm{law of orbits}\\index{law of orbits}\" is stated most of time as follow: The orbits of the planets are conics (ellipses) which the Sun (central star) occupies one of the focals.\n\t\n\tIn fact, it should be noted that this is not really a \"law\" in the proper sense, since further below you will see that we can prove that:\n\t\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe reader who has already read the section of Analytical Geometry will not be surprised by this relation...\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Second Kepler's Law (area law)}\n\tThe \"\\NewTerm{Kepler's second law}\\index{Kepler's second law}\\label{kepler second law}\", sometimes also named \"\\NewTerm{area law}\\index{area law}\" tells us that the line joining a planet to the Sun (central start) sweeps out equal areas in equal times (constant areal velocity\\label{constant areal velocity}) as:\n\t\n\t\n\tIt is a relation that arises from the conservation of angular momentum as we have already shown it in the section of Classical Mechanics where we got:\n\t\n\t\n\tSo again, the status of \"law\" is questionable in the language of modern physics!\n\t\n\tThe latter relation is also in scalar form obviously written:\n\t\n\twhere $\\theta$ is the angle between the orbit radius and the tangential velocity vector of the object on its orbit.\n\t\n\tNow let us express this law in another form more conventional in the field of astronomy. Consider for this the movement in the plan in cylindrical coordinates by:\n\t\n\tTherefore:\n\t\n\t\n\tIt comes therefore from the property of linearity of the vector product:\n\t\n\tTherefore taking the norm:\n\t\n\tAnd since it is equal to a constant, it is often customary to write this last equality in a condensed form (and putting the mass in the constant):\n\t\n\tAlso, remember that we also got the result that the movement is and remains in a plane without any outside action!\n\t\n\tWe note also that this law gives us the speed of the planet is variable. It is larger than at perihelion than a the aphelion:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/focus_aphelion_perihelion.jpg}\t\n\t\t\\caption{Representation of surfaces conservation}\n\t\\end{figure}\n\tThis is true for the Earth for example. Indeed, this latter is closer to the Sun in winter (for northern hemisphere) and then has a trajectory speed slightly higher than in summer; the travel time is therefore lower (winter has fewer days than the other seasons).\n\t\n\t\\paragraph{Time of flight}\\mbox{}\\\\\\\\\n\tWe propose now to apply the second Kepler's law to determine the time $t$ from the passage to the perihelion as a function of the \"\\NewTerm{eccentric anomaly}\\index{eccentric anomaly}\" $\\varphi$ in the case of an elliptic orbit  (thus special case!) using its two foci (one of them being assimilable for example to the position of the Sun) and the origin of the \"\\NewTerm{auxiliary circle}\\index{auxiliary circle}\" (also named \"\\NewTerm{apsidal circle}\\index{apsidal circle}\"):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/excentricity_anomaly.jpg}\t\n\t\t\\caption{Schema for the study of eccentric anomaly angle}\n\t\\end{figure}\n\tTo determine the time $t$ between the passage at the perihelion $A$ and the point $P$ of a body following the trajectory of the ellipse of surface $\\pi a b$ (see the Geometric Forms section for the proof of the calculation of the surface of the ellipse) in function of the eccentric anomaly $\\varphi$, we will use the areas law just proved earlier above (second Kepler's law) that give us the right to write:\n\t\n\tBut, the surface of the ellipse is an affine transformation of the surface of the auxiliary circle such that:\n\t\n \tWe have then:\n\t\n \tIf $\\varphi$ is, as it should, expressed in radians, we have of course:\n\t\n \tTherefore:\n\t\n \tFor $S_{F\\text{O}Q}$, we have $\\overline{F\\text{O}}=a$ therefore equal to the radius of the auxiliary circle. The surface of the triangle $S_{F\\text{O}Q}$, knowing its height given by $h=a\\sin(\\varphi)$ is then obtained by:\n\t\n\tTherefore we have:\n\t\n\tBut, by definition of the eccentricity (\\SeeChapter{see section Analytical Geometry page \\pageref{eccentricity}}), we can write:\n\t\n\tFinally, we have:\n\t\n\tTherefore:\n\t\n \twhere the angle taken at the center of the ellipse is for recall named the \"eccentric anomaly\".\n\n\t\\textbf{Definition (\\#\\mydef):} In the description of the Keplerian orbit of a celestial object, the \"\\NewTerm{eccentric anomaly}\\index{eccentric anomaly}\" is the angle between the direction of the periapse and the current position of an object in its orbit, projected on the circle extinct perpendicular to the major axis of the ellipse\n\n\tWhat would interest us now would be to find a relation of passage between this eccentric anomaly and the angle named \"\\NewTerm{true anomaly}\\index{true anomaly}\" $\\theta$ as sometimes it is often more advantageous to use this last angle.\n\n\tFor a relation between the eccentric anomaly $\\varphi$ and the true anomaly $\\theta$, we will reuse our above schema but modified a bit:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/true_cosmology.jpg}\t\n\t\t\\caption{Schema for the study of true-eccentric anomaly angle relation}\n\t\\end{figure}\n\tWe have obviously the $4$ below relations which a deduce from the above figure:\n\t\n\tWe then have already in a first time (relation which will be useful to us a little later):\n\t\n \tWe have also proved in the section of Analytical Geometry that:\n\t\n\tthis relation being valid at any border point of the ellipse. Thus, we also have:\n\t\n \tWhich leads us to write:\n\t\n\tIdeally, we could get rid of the radius in the denominator. For this, we will use the fact that (relations that we have just proved earlier above):\n\t\n\tWe have:\n\t\n \tThe terms to the left of the equality are simplified immediately:\n\t\n\thence:\n\t\n \ttherefore:\n\t\n\tthus finally:\n\t\n\tFinally notice that in the special case of an elliptical orbit, we deduce thanks to the second Kepler's law (see the proof of the calculation of an area of an ellipse in the section Geometric Shapes) the:\n\t\n\t\\pagebreak\n\t\\subsubsection{Third Kepler's Law (periods' law)}\\label{third kepler law}\n\tThe \"\\NewTerm{Kepler's third law}\\index{Kepler's third law}\", sometimes also named  \"\\NewTerm{Periods' law}\\index{Periods' law}\" or \"\\NewTerm{Kepler's harmonic law}\\index{Kepler's harmonic law}\", is stated as follow: The squares of the periods of revolution $T$ are proportional to the cube of the semi-major axes of the orbits $D$:\n\t\n\tThe last ratio is then a constant in practice for all planets (in physics we also speak of \"invariant\") and the reason for this \"harmony\" was difficult to explain before Newton's theory.\n\t\n\tAgain, we will see later that the status of \"law\" is no longer justified in our time as it is possible to prove that this relation, whose expression will be detailed, is in reality:\n\t\n\tand therefore we understand better when we see the term on the right why we had the previous constant ($m$ is the central body mass!).\n\t\n\tThe last relation is more often written as following in the field of astronomy:\n\t\n\twhere as we have seen in the section of Analytical Geometry, $a$ is the traditional notation for the semi major axis of ellipse. It is important to notice that whatever the magnitude of the semi minor axis,  if the semi major axis of multiple ellipses are identical, their periods (and therefore the corresponding total energy) will be identical.\n\t\n\tThe most commonly used rearrangement of this last relation is obviously:\n\t\n\t\t\n\tOf course, Kepler did not immediately published his three laws in this provocative simplicity. Their current presentation order is also not the original one ... They are  in reality to find among  a profusion of physical speculations and reflections on world's harmony.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe Kepler's law are not limit to the gravitation force. They also apply for all acceleration (or force) of the type $1/r^2$. And this is also the case of the Coulomb's law (\\SeeChapter{see section Electrostatics page \\pageref{coulomb force}}). Kepler's law can therefore also be applied to an electron in orbit around a nucleus. The Wilson and Sommerfeld model (\\SeeChapter{see section Quantum Corpuscular Physics page \\pageref{wilson and sommerfled model}}) based also on Kepler's law gives also elliptic trajectories for electrons!\n\t\\end{tcolorbox}\t\n\tHere is an high definition image (you can zoom in a lot!) with some celestial bodies of the solar system, and for many of them, their orbital period $T$ and their distance $a$ to their main attractor:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/bodies_of_the_solar_system.jpg}\n\t\t\\caption[Some celestial bodies of our solar system]{Some celestial bodies of our solar system (author: Antonio Ciccolella)}\n\t\\end{figure}\n\tWe also recommend the reader to carefully look to the orbits structures schematized on the above figure as it will be useful for a critical thinking of the Newton Quantum Gravity that we will introduce later (page \\pageref{newton quantum gravity}).\n\t\n\tAn interesting complementary image is to put side by side some well known planets and dwarf planets by respecting the proportions:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/25_solar_system_objects_smaller_than_Earth.jpg}\n\t\t\\caption[Side by side planets and dwarf planets]{Side by side planets and dwarf planets (source: ?)}\n\t\\end{figure}\n\tThe three Kepler's law can then be summarized by the following small figure:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/keplerslaw.jpg}\t\n\t\t\\caption[Summary of Kepler's laws in image]{Summary of Kepler's laws in image (source: ???)}\n\t\\end{figure}\n\t\n\tThe reader must take precautions with the image above because:\n\t\\begin{enumerate}\n\t\t\\item The planets are most of time in a movement that is not in the same plane. For the Solar system it is the tradition  at high school level to represent the planets in the \"\\NewTerm{ecliptic}\\index{ecliptic}\" plane that is the average plane described by the movement of Jupiter around the Sun:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/cosmology/ecliptic_solar_system.jpg}\t\n\t\t\t\\caption{Planets spin and angle relatively to the ecliptic plane}\n\t\t\\end{figure}\n\t\t\n\t\t\\item The orbits precess around the Sun as shown in the following figure (see further below for the mathematical proof in the case of a 2-body system):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/cosmology/orbit_precession.jpg}\t\n\t\t\t\\caption{Orbit precession example}\n\t\t\\end{figure}\n\t\t\n\t\t\\item The planets have an helicity trajectory \"behind\" the movement of the Sun around the center of our Galaxy and the ecliptic has an angle of approximately $60^\\circ$ ($\\pi/3$ [rad]) relatively to the perpendicular of the Sun movement as visible in the figure below:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/cosmology/solar_system_vortex.jpg}\t\n\t\t\t\\caption{Planets with orbits following the Sun in its movement}\n\t\t\\end{figure}\n\t\tand the planets are therefore sometimes in front of the Sun and sometimes behind.\n\t\t\n\t\t\\item On the very very long term the orbits in a $n$-body system is a chaotic deterministic system that has period of quasi-stability but that sometimes diverges completely. This is great opportunity at the date we write these lines to be in such a period of quasi-stability.\n\t\\end{enumerate}\t\n\t\n\t\\begin{fquote}The Earth is not fitted to us, we are fitted to the Earth.\n \t\\end{fquote}\n\t\t\n\t\\pagebreak\n\t\\subsection{Newton's Gravitational Law}\\label{newton gravitational law}\n\tTo check the accuracy of his hypothesis, Newton (relatively long after Kepler) found Kepler's laws from the law of gravity, giving the explanation of the general movement of the planets.\n\t\n\tNewton considered to determine the law of gravitation a theoretical planet orbiting around the Sun in a circular orbit at a constant speed $v$. During a complete orbit the planet travels a distance equal to the circumference of the circle of radius $R$, or $2\\pi R$, in a time (the period) equal to the distance divided by its velocity, either:\n\t\n\tNewton then relies on the third Kepler's law with always the assumption of a circular orbit.\n\t\n\tWe therefore have:\n\t\n\tbut as:\n\t\n\tThen we get by substitution:\n\t\n\tBy comparing:\n\t\n\tand:\n\t\n\tand now assuming that $4\\pi^2$ is divided by the constant is a new constant (which will be denoted in the same manner as the first although it is not equal to...) we obtain:\n\t\n\tTherefore:\n\t\n\tThen, if we reverse the terms, this expression becomes (while noting that the inverse of the original is constant is, also, a constant):\n\t\n\tBy another calculation, we have already established in the section of Classical Mechanics the expression of centrifugal force:\n\t\n\tby comparing this expression with the previous one:\n\t\n\twe get:\n\t\n\tThere should therefore exist a force opposed to the centrifugal force that keeps the orbital cohesion and which can be written:\n\t\n\tremains to determine the value of the constant!\n\t\n\tIt is trivial that the central mass $M$ of the orbital system has to intervene in one way or another in this constant. If the mass of the secondary body intervenes proportionally in the centrifugal force, the desire is great to do the same with the mass of the central body. So:\n\t\n\tNow there would be a priori more parameters to take into account. The remaining constant is here to meet the dimensional analysis so that we have \"Newtons\" (name given to the unit of force) on both sides of the equality. Scientists have determined with precision this \"\\NewTerm{gravitational constant}\\index{gravitational constant}\" denoted by $G$ that a priori seems universal and which in SI units, the 2014 CODATA-recommended value of the (with standard uncertainty in parentheses) is:\n\t\n\tWhich brings us to write the \"\\NewTerm{Newton's gravitational law}\\index{Newton's gravitational law}\":\n\t\n\tObviously it is not a true rigorous proof because based on experimental Kepler's observations. By cons, from General Relativity it is possible to prove it (under some given assumptions...)!\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! As we will prove it later (result already known at the time of Newton) the three macroscopic spatial dimensions are very special! In particular, in three dimensions gravity obeys an inverse square law, without which stable planetary orbits would not be possible. But keep in mind that since the space-time model is a human invention, so must be the dimensionality of space-time. We choose it to be three because it fits the data. In the M-theory we choose it to be eleven. We use whatever works, but that does not mean reality is exactly that way in one-to-one correspondence.\n\t\\end{tcolorbox}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe equality:\n\t\n\texplains the genius intuition of Galileo: that in vacuum (!) a feather and bowling ball will fall at the same speed (ie with the same acceleration), as that latter depends only on the main body of attraction that has for mass $M$. Only the force on the two objects is not the same! But the acceleration is however the same!\n\t\\end{tcolorbox}\n\tNow some reader may think that there is a singularity in $R=0$ but this is impossible as given to mass particles of radius $r_1$ and $r_2$ we would have the maximum following force:\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tAt the Earth's equator the radius is of $6378$ [km] and at the poles of $6357$ [km]. Therefore we have:\n\t\n\tThen the acceleration at the equator is equal to $9.800/9.865\\cong 99.34 \\%$ to that at the poles.\n\t\\end{tcolorbox}\n\tIt is very important to notice that the mutual forces of attraction acting on two mass spheres are always of equal size!\n\t\n\tUsing Maple 17.00, we can simulate the plane trajectory of a satellite relative to $n$ number of fixed mass (thanks to Forhad Ahmed for his script). Here below is given the basic script that you can customize to your tastes and... feel free to give us your personal work if you have brought significant improvement to this script:\n\t\n\t\\texttt{>restart; with(plots); with(DEtools)\\\\\n\t>G:=1; \\#normalized gravitational constant to simplify\\\\\n\t>poles:=2; \\#number of bodies/masses that we can play with...\\\\\n\t>M[1]:=10;M[2]:=1; \\#mass of the first and second body (in relative values)\\\\\n\t>h[1]:=1;h[2]:=-1; \\#X position of the first and second body X (in astronomical units)\\\\\n\t>k[1] := 1;k[2] := 1; \\#Y position of the first and second bodies (in astronomical units)}\n\t\n\t\\texttt{>\\#differential equation of the satellite acceleration in X\\\\\n\t>Xeq := diff(x(t), t, t) = sum(-G*M[j]*(x(t)-h[j])/((x(t)-h[j])\\string^2\\\\+(y(t)-k[j])\\string^2)\\string^(3/2), j = 1 .. poles);\\\\\n\t>\\#differential equation of the satellite acceleration in X\\\\\n\t>Yeq := diff(y(t), t, t) = sum(-G*M[j]*(y(t)-k[j])/((x(t)-h[j])\\string^2\\\\+(y(t)-k[j])\\string^2)\\string^(3/2), j = 1 .. poles);\\\\\n\t>\\#position and initial velocity of the satellite\\\\\n\t>inits := x(0) = -2, y(0) = 0, (D(x))(0) = 0, (D(y))(0) = 2\\\\\n\t>\\#numerical solution of the differential equation (you can play with the precision of the error as needed!)\\\\\n\t>g:=dsolve({Xeq,Yeq,inits},{x(t),y(t)},type=numeric,method=dverk78,abserr=0.1e-3, output= procedurelist);}\n\t\n\t\\texttt{>n:=50; \\#step of iterations\\\\\n\t>iter:=300; \\#step of iterations}\n\t\n\t\\texttt{>\\#loop that resolves the differential equation at each new iteration\\\\\n\t>for i from 0 to iter do \\\\\n\tpx[i]:=rhs(g(i/n)[2]);\\\\\n\tpy[i]:=rhs(g(i/n)[4]);\\\\\n\tKE[i]:=1/2*(rhs(g(i/n)[3])\\string^2+rhs(g(i/n)[5])\\string^2);\\\\\n\ttemp:=(rhs(g(i/n)[2])-h[j])\\string^2+(rhs(g(i/n)[4])-k[j])\\string^2;\\\\\n\tPE[i]:=sum(-G*M[j]/sqrt(temp), j = 1 .. poles);\\\\\n\tTE[i]:=KE[i]+PE[i]\\\\\n\tend do:}\n\t\n\t\\texttt{>data:=seq(pointplot([px[i], py[i]], color = red), i = 0 .. iter):\\\\\n\t>\\#mettre insequence to true to get an animation\\\\\n\t>Anim:=display(data,insequence=false,scaling=constrained,axes=boxed):\\\\\n\t>stars:=display(seq(pointplot([h[i], k[i]], color = black), i = 1 .. poles))\\\\\n\t>display({Anim,stars},title=`Satellite orbiting a multipolar gravity field`);}\n\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/trajectory_of_a_body_influenced_by_massive_body.jpg}\t\n\t\t\\caption{Configuration for the study of relativistic effects}\n\t\\end{figure}\n\n\t\\texttt{>\\#it is verified that the total energy of the satellite is always constant\\\\\n\t>print(`[Time] -- [Kinetic Energy] - [Potential Energy] - [Net Energy]`);\\\\\n\t>print(`======================================`);\\\\\n\t> for i by 3 to iter do\\\\\n\tprint(evalf(i/n, 6), ` `, KE[i], ` `, PE[i], ` `, TE[i]);\\\\\n\tend do:\\\\\n\t>\\#the last column of the table must always have normally an equal value...}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tEqualizing the centrifugal force and gravitational force, it is quite easy to get an approximation of the speed of rotation of the planets in their orbits. The reader that will do the calculation will see that the value for the planets of our solar system is around a speed of about $100,000\\;[\\text{km}\\cdot \\text{h}^{-1}]$.\n\t\\end{tcolorbox}\t\n\t\n\tFrom this last relation, let us come back briefly on our third Kepler's law and detail it a little bit to show that it is valid for any type of conical orbit and to determine the expression of its constant.\n\t\n\tExpressed in the Frenet coordinate system (\\SeeChapter{see section Differential Geometry page \\pageref{frenet frame}}), and decomposed into its normal (centripetal) and tangential acceleration, the acceleration in respect to a geocentric reference frame (in the case of a referential located at the mass center of the system the expression change a little bit!) is written:\n\t\n\tFrom in previous developments (3rd Kepler's Law):\n\t\n\tand:\n\t\n\tthe constant of Kepler's third law takes for value (it is a formulation sometimes used in practice but not a strictly necessary step in this development):\n\t\n\tbut as we also have:\n\t\n\tthen:\n\t\n\tTherefore:\n\t\n\tFinally, the third Kepler law can be found frequently in the literature as follows:\n\t\n\tBut now let us consider again our figure of the center of mass study (\\SeeChapter{see section Classical Mechanics page \\pageref{center of mass}}):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/atomistic/hydrogenoid_center_of_mass.jpg}\n\t\t\\caption[]{Binary System Center of Mass (profile view)}\n\t\\end{figure}\n\tAnd let us have a look at circular orbits in the center of mass frame! \n\t\n\tFirst we look at the forces acting on body $M$:\n\t\n\tThe forces balance, so:\n\t\n\tWe know that in the simple case of a circular orbit (circular kinematics):\n\t\n\tWe insert this into the previous equation and we get after some algebra:\n\t\n\tWhat is $r_M$? From the definition of center of mass we know that (\\SeeChapter{see section Classical Mechanics page \\pageref{center of mass}}):\n\t\n\tWe plug $r_M$ into our equation and now we get:\n\t\n\tor after rearranging terms:\n\t\n\tSo we can use this 3rd Kepler's law to determine the total mass a binary pair if we know the period $T$!!! As the star masses are well estimated using the HR diagram we better understand how astronomers estimate orbiting planet mass knowing the period (in fact they also use the luminosity variation). In fact it is not as simple as there is no reason why we should be looking directly onto the orbital plane of the binary system. In other words, the apparent orbit is almost never the true orbit (which is what we need to do the calculation).\n\t\n\tThis interlude performed, let us come back on our Newton's gravitation law:\n\t\n\tFrom the law of gravitation, we can find back Kepler's law. Besides, we have already done it for the second and third law of Kepler, since it is these that we used to get this latter relation (however it's a little bit the snake eating its tail...).\n\t\n\tIn vector notation we have therefore:\n\t\n\tIdentically to the electric field (\\SeeChapter{see section Electrostatics page \\pageref{electric force}}), we can develop:\n\t\n\tAs the electric field is derived from an electric potential, identically, the gravitational field derived from a gravitational potential\\index{gravitation potential}\\label{gravitation potential}. By performing exactly the same development as in  our study of electromagnetism for the first Maxwell equation (\\SeeChapter{see section Electrodynamics page \\pageref{first maxwell equation}}), we prove that:\n\t\n\twhere $\\varphi$ is the \"\\NewTerm{gravitational potential}\\index{gravitational potential}\" that varies inversely with the relative distance of the body (this confirms what we had proved in our study of Noether's theorem in the section on Principles) and is therefore equal to:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe often encounter this potential in the section of General Relativity. It is therefore appropriate to remember it if possible!\n\t\\end{tcolorbox}\t\n\tNotation which obviously implies the following relation:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tObviously in the absence of field, we have $\\varphi=c^{te}$ and therefore $\\vec{a}$  will be zero.\n\t\\end{tcolorbox}\n\tAs in the section of Electromagnetism, again, we prove as we did for the first Maxwell equation:\n\t\n\tIf we express this equation in terms of a gravitational potential $\\varphi$ (also often denoted by the letter $U$ as in Electrostatic...), we get:\n\t\n\tthat we write more aesthetically with the scalar Laplacian operator (\\SeeChapter{see section Vector Calculus page \\pageref{scalar laplacian}}):\n\t\n\twhich is nothing else than the \"\\NewTerm{Newton-Poisson equation}\\index{Newton-Poisson equation}\\label{newton-poisson equation}\" that we will  also meet again in our study of General Relativity (it has an important place for validation reasons of Einstein's Gravitation theory)!\n\t\n\tThis equation means that the Newtonian gravitational theory can be resume to say that the gravitational field is described by a single potential $\\varphi$ generated by the volume mass density and determining the acceleration of a test particle immersed in the outfield $\\varphi$.\n\t\n\tWith Newton’s important achievements - building, of course, on the work of the great thinkers who preceded him - civilization reached an extremely high level of knowledge about the universe. Newtonian mechanics and also the optics, astronomy, and mathematics to which Newton contributed were immensely valuable in helping us gain an understanding of the vast and complicated physical world around us. The progress made by Newton and others allowed us to see clearly how planets move and how the force of gravity operates in nature. Newton’s theory of gravity is so profound and so all-encompassing that its laws govern everything from the fall of apples to the ground to the orbiting of the Earth by the Moon; from the revolutions of the planets around the sun to the actions of springs and the trajectories of cannonballs; from the behaviour of billiard balls to the energy of an accelerating car. Newtonian mechanics explains the world to a stunningly accurate degree. In the twentieth century, Einstein would refine Newton’s theories to account for instances where the speed of light is approached or very great mass is involved. But for the time, Newton’s achievements truly opened a new world for physical science. In the following two centuries, science would consolidate its gains, and the church (and religions in general) would have to retreat from its position as the source of truth about how the world works.\n\t\n\tLet's have a little bit fun now with the Newton's gravitation equation to get some interesting and curious results:\n\t\n\t\\subsubsection{Gaussian Formulation of Newtonian Gravity}\n\tAs we have just mentioned it and proved in the section of Electrodynamics, an alternative formulation of Newtonian gravity is: Gauss’s Law for gravity. It states that the acceleration $\\vec{a}$ due to gravity of a mass $m$ (not necessarily a point mass) is given by:\n\t\n\twhere the $-$ sign we have it's purpose of guarantee a positive scalar acceleration.\n\t\n\tFor example, let's use Gauss's law to find the acceleration $a$ due to the gravity of a point mass $m$.\n\n\tWe begin with a point mass $m$ sitting in space. We now need to construct an imaginary closed surface $S$ surrounding $m$. While in theory any surface would do, we should pick a surface that will make the integral easy to evaluate. Such a surface should have these properties:\n\t\\begin{enumerate}\n\t\t\\item[P1.] The gravitational acceleration $vec{a}$ should be either perpendicular or parallel to $S$ everywhere.\n\n\t\t\\item[P2.] The gravitational acceleration $\\vec{a}$ should have the same value everywhere on $S$. (Or it may be zero on some parts of $S$).\n\n\t\t\\item[P3.] The surface $S$ should pass through the point at which you wish to calculate the acceleration due to gravity.\n\t\\end{enumerate}\n\tIf we can find a surface $S$ that has these properties, the integral will be very simple to evaluate. For the point mass, we will choose $S$ to be a sphere of radius $r$ centered on mass $m$. Since we know $\\vec{a}$ points radially inward toward mass $m$, it is clear that $g$ will be perpendicular to $S$ everywhere. Also, by symmetry, it is not hard to see that $\\vec{a}$ will have the same value everywhere on $S$. \n\n\tHaving chosen a surface $S$, let us now apply Gauss’s law for gravity. The law states that for recall that:\n\t\n\tNow everywhere on the sphere $S$, we have $\\vec{a}\\circ\\vec{n}=-g$ (since $\\vec{a}$ and $n$ are anti-parallel $g$ points inward, and $n$ points outward). Since $g$ is a constant for a perfect sphere, the previous relation becomes:\n\t\n\tNow the integral is very simple: it is just $\\mathrm{d}S$ integrated over the surface of a sphere, so it's just the area of a sphere (\\SeeChapter{see section Geometric Shapes page \\pageref{sphere}}):\n\t\n\tor (cancelling $-4\\pi$ on both sides):\n\t\n\tand it's in agreement with the Gravitational Newton law! This result suggests that the gravity of a solid spherical ball to an exterior object can be simplified as that of a point mass in the center of the ball with the same mass!!!\n\t\n\tSo the Flat-Earthers and some believers (following some holy books that we will not mention her) have to explain why everywhere in the world they can measure a falling object which acceleration corresponding to a spheric Earth if that latter is recall flat...\n\n\tAs Flat-Earther sometimes challenge physicists to prove that the Newton law is not the same for a flat Earth (I was also challenged once... and this was a very bad idea from my opponent) here is the proof!\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/flat_earth.jpg}\n\t\t\\caption[]{Schematic idea of a flat planet like... Earth......}\n\t\\end{figure}\n\tIn this case, the appropriate Gaussian surface $S$ is a \"pillbox\" shape - a short cylinder whose flat faces - (of area $A$) are parallel to the plane of mass. In this case, everywhere along the curved surface of $S$, the gravitational acceleration $\\vec{a}$ is perpendicular to the outward normal unit vector $\\vec{n}$, so the curved sides of $S$ contribute nothing to the integral. Only the flat ends of the pillbox-shaped surface S contribute to the integral. On each end, $\\vec{a}$ is anti-parallel to $\\vec{n}$, so $\\vec{a}\\circ\\vec{n}=-g$ on the ends.\n\t\n\tNow apply Gauss's law to this situation:\n\t\n\tHere the integral needs only to be evaluated over the two flat ends of $S$. Since $\\vec{a}\\circ\\vec{n}=-g$, we can bring $-g$ outside the integral to get:\n\t\n\tThe integral in this case is just the area of the two ends of the cylinder, $2A$ (one circle of area $A$ from each end). This gives:\n\t\n\tNow let us look at the right-hand side of this equation. The mass $m$ is the total amount of mass enclosed by surface $S$. Surface $S$ is sort of a \"cookie cutter\" that punches a circle of area $A$ out of the plane. The mass\nenclosed by $S$ is a circle of area $A$ and surfacic density $\\sigma$, so it has mass $\\sigma A$. Then the previous relation becomes:\n\t\n\tNote that this is a constant: the acceleration due to gravity of an infinite plane of mass is independent of the distance from the plane...!\n\n\tSo Flat-Earth have difficulties to only difficulties to explain this but also are not able to find the corresponding value of $g$ in their laboratory or home garage...\n\n\t\\subsubsection{Shell Theorem}\n\tThe shell theorem gives gravitational simplifications that can be applied to objects inside or outside a spherically symmetrical body. This theorem has particular application to astronomy.\n\n\tIsaac Newton proved the shell theorem and stated that:\n\t\\begin{enumerate}\n\t\t\\item A spherically symmetric body affects external objects gravitationally as though all of its mass were concentrated at a point at its center.\n\t\t\\item If the body is a spherically symmetric shell (i.e., a hollow ball), no net gravitational force is exerted by the shell on any object inside, regardless of the object's location within the shell.\n\t\\end{enumerate}\n\tA corollary is that, and we will prove it, that inside a solid sphere of constant density, the gravitational force varies linearly with distance from the center, becoming zero by symmetry at the center of mass.\n\t\n\tGiven an object located outside of the Earth and $r$ is the distance of the object to the center of the Earth, we have:\n\t\n\tit comes:\n\t\n\tIf the object is placed at the surface of the Earth or radius $R$, we have ($r=R$):\n\t\n\tFrom the two previous relations it comes therefore:\n\t\n\tAt the surface we have then well (we expected this result...):\n\t\n\tNow, if the object is located inside the Earth by denoting the distance from the center by the letter $r$ and the central mass by $M'$, we have:\n\t\n\tLet us introduce the density $\\rho$ that we will assume equal everywhere:\n\t\n\tBy combining these last four relations, we get:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/gravity_profile.jpg}\t\n\t\t\\caption{Internal/External gravitational acceleration profile of a mass body}\n\t\\end{figure}\n\n\tFor many people this result is quite counter-intuitive (do a little survey around you, you'll see).\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn addition to gravity, the shell theorem can also be used to describe the electric field generated by a static spherically symmetric charge density, or similarly for any other phenomenon that follows an inverse square law. The derivations below focus on gravity, but the results can easily be generalized to the electrostatic force. \n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Orbital speed}\n\tWe will prove now an obvious property of orbits that will be useful to us later to study of what seem to be an anomaly with structure of the size of galaxies.\n\t\n\tThe orbital speed of a body, generally a planet, a natural satellite, an artificial satellite, or a multiple star, is the speed at which it orbits around the barycenter of a system, usually around a more massive body. It can be used to refer to either the mean orbital speed, i.e. the average speed as it completes an orbit, or the speed at a particular point in its orbit such as perihelion.\n\t\n\tWe have proved above the origin of Newton's law. For planets thus considered as physical points in stable circular orbit, so there is balance between centrifugal and gravitational force. So we have:\n\t\n\twhere we easily deduce:\n\t\n\tWhich is approximately in good agreement with the experimental measurements as shown in the figure below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.55]{img/cosmology/orbital_speed.jpg}\t\n\t\t\\caption{Orbital speed characteristic curve}\n\t\\end{figure}\n\tBut as we will proved it in the section of Aerospace Engineering (Vis-Viva equation) in a more general case that orbital speed is given by:\n\t\n\t\n\t\\subsubsection{Asteroids/Meteors impact velocity}\n\tWe have proved in the section of Classical Mechanics that the escape velocity was given by:\n\t\n\tand was therefore independent of the mass $m$ of the ejected object. Obviously the same relation can be applied for an object of mass $m$ coming from an infinite far distance.\n\t\n\tFor the entry velocity of an asteroid in Earth's atmosphere we can assume that the minimum speed of a colliding asteroid is given by the above escape velocity relation for an asteroid returning to the zero potential of the Earth's gravitational field (a numerical application gives ${11 \\;[\\text{km}\\cdot \\text{s}^{-1}]}$.\n\n\tIn fact, their real entering velocity depends on their direction that will determine their relative speed to Earth (which is ${30  \\;[\\text{km}\\cdot \\text{s}^{-1}]}$) plus eventually that of the Sun (which is around ${200  \\;[\\text{km}\\cdot \\text{s}^{-1}]}$. We can also take into account the escape velocity of the Solar System that is around  ${200  \\;[\\text{km}\\cdot \\text{s}^{-1}]}$.\n\n\tThe sum gives therefore a speed between ${11 \\;[\\text{km}\\cdot \\text{s}^{-1}]}$ (for the optimistic case....) and ${300  \\;[\\text{km}\\cdot \\text{s}^{-1}]}$ (for the pessimistic case....) with a statistical peak that gives most observed entry at ${30 \\;[\\text{km}\\cdot \\text{s}^{-1}]}$.\n\n\tAs we  will prove it in the section of Weather and Marine Engineering that at a height of $600$ [m] we can see at a distance of almost $80$ [km] we better understand why it is a joke in some movie to see huge asteroids entering the Earth atmosphere with people looking at it during $10$-$15$ seconds... and waiting almost $1$ minute before it hits the ground... (this is type of observation available for meteors but not for asteroids coming from very far!!!).\n\n\tA good example is to see all the YouTube videos about the small Chelyabinsk meteor (having a diameter of only $20$ meters) that entered Earth's atmosphere over Russia on 15 February 2013 and that had a speed of only almost  $30 \\;[\\text{km}\\cdot \\text{s}^{-1}]$ and which trajectory was visible during almost $20$ seconds only with the human eyes (so imagine with a speed $10$ times faster...).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.4]{img/cosmology/asteroids_comets.jpg}\t\n\t\t\\caption[All asteroids and comets visited by spacecraft as of November 2010]{All asteroids and comets visited by spacecraft as of November 2010 (source: Montage by Emily Lakdawalla. Ida, Dactyl, Braille, Annefrank, Gaspra, Borrelly: NASA / JPL / Ted Stryk. Steins: ESA / OSIRIS team. Eros: NASA / JHUAPL. Itokawa: ISAS / JAXA / Emily Lakdawalla. Mathilde: NASA / JHUAPL / Ted Stryk. Lutetia: ESA / OSIRIS team / Emily Lakdawalla. Halley: Russian Academy of Sciences / Ted Stryk. Tempel 1, Hartley 2: NASA / JPL / UMD. Wild 2: NASA / JPL)}\n\t\\end{figure}\n\t\n\t\\subsubsection{Spherisation of Celestial Bodies}\n\tThanks to Newton's law, we could answer to a lot of relevant questions in an approximated way and giving us results quite convincing.\n\n\tA first example is to ask ourself at what scale there is a transition in the domain of irregular shapes (comets, asteroids, moons, etc.) to the field of spheres (moons, planets and stars)? Why the moons of Mars, Phobos and Deimos, have a potato shape like while our moon is roughly spherical. We will see below that this is due to the mass that is greater in the case of our moon. Indeed, from a certain mass, arbitrary geometric shapes are not possible anymore.\n\n\tTo address this study, we will first estimate the maximum height of a mountain on a planet. Mount Everest has an altitude of $8.8$ [km] while Mount Olympus on Mars has a height of $27$ [km]. Why such mountains can not exist on Earth?\n\n\tTo take a simplistic approach, we will assume that a mountain must be in hydrostatic equilibrium. We know experimentally the pressure limit in such a rocks lattice beyond which the rocks begin to \"melt\" (given in tables): $P_{\\text{lim}}\\cong 3 \\cdot 10^8\\;\\text{[Pa]}$.\n\n\tWe know from our study of continuum mechanics (\\SeeChapter{see section Continuum Mechanics page \\pageref{fundamental theorem of hydrostatics}}) the pressure at the base of a mountain of height $h$ will be given in the hydrostatic approximation by:\n\t\n\tFor the mountain to be stable, it is necessary that:\n\tFor the mountain to be stable, it is necessary that:\n\t\n\tand therefore:\n\t\n\tTherefore:\n\t\n\tAssuming an average density of $\\rho=3,000\\;[\\text{kg}\\cdot \\text{m}^{-3}]$ (continental crust of the Earth) we get:\n\t\\begin{enumerate}\n\t\t\\item Earth: $h_0\\cong 10\\; [\\text{km}]$\n\t\t\\item Mars: $h_0\\cong 27\\; [\\text{km}]$\n\t\\end{enumerate}\n\tWhat is remarkable as approximate result!!!\n\n\tTo estimate the minimum size $r_m$ of a body, starting the spherical shape becomes predominant compared to the surface deformation (that is to say where gravity has taken over the inter-atomic forces), we will require the size $r_m$ is greater than the maximum height of a mountain $h_0$. We also assume that the density $\\rho$ remains constant through the body. Taking again the relation:\n\t\n\twe have:\n\t\n\thence:\n\t\n\tThe limit $r_m$ can after be estimated by fixing $r=r_m=h_0$ therefore:\n\t\n\tobviously for $r\\gg r_m$ we will be even closer to the spherical shape.\n\n\t\\paragraph{Flattening of Celestial Bodies (rotational flattening)}\\mbox{}\\\\\\\\\\\n\tBecause of the symmetry of the gravitational potential a star or a planet should have a perfectly spherical form starting a given size, as we have just prove it. Now, the fact is... that it is not so for and especially for telluric bodies.\n\t\n\tBecause of the own rotation of the star or planet, a centrifugal term transforms potential. This term depends on the latitude which explains the ellipsoidal shape of most observed celestial bodies.\n\t\n\tLet us recall that:\n\t\n\twhere $R$ is the equatorial radius of the star or planet, acceleration to which we have to add the centrifugal acceleration at a given latitude radius $r$ (\\SeeChapter{see section Classical Mechanics page \\pageref{centrifugal acceleration}}):\n\t\n\tTherefore the total acceleration given by:\n\t\n\texplains why the Earth is flattened at the poles (or depending of the point of view stretched to the equator ...) and that more one empty planet rotates, the more it will be flattened at the poles.\n\t\n\tOn Earth, the equatorial radius is of $6,379$ [km] while the polar radius is of $6.357$ [km]. The difference is $22$ [km]. The \"\\NewTerm{flattening}\\index{flattening}\" of as star or planet is sometimes defines as:\n\t\n\tthus the difference between the equatorial radius and polar radius divided by the equatorial radius.\n\t\n\tAlthough an ellipsoid of revolution is the best description for the shape of a planet:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/earth_with_atmosphere.jpg}\t\n\t\t\\caption{Earth with its atmosphere and oceans}\n\t\\end{figure}\n\tthere are obviously imperfections between the model and the reality for some planets (in particular the terrestrial planets, satellites, and small rocky bodies). The geopotential of real body can be shaped much more complicated because of influences of the visible inhomogeneities on the surface as evidenced by this satellite image of the Earth omitting the liquid parts of it (the deformations are amplified by a factor $100,000$ in the image below!):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/earth_without_atmosphere.jpg}\t\n\t\t\\caption[Earth shape without its atmosphere and oceans]{Earth shape without its atmosphere and oceans (source: Wikipedia)}\n\t\\end{figure}\n\tSo the Earth is obviously not a sphere nor Ostrich egg shaped...\n\t\n\tThe \"\\NewTerm{geoid}\\index{geoid}\" is a particular equipotential surface of the earth's gravity field and serves as a reference for the determination of altitudes. We can imagine the geoid as being the mean sea level extended under the continents.\n\t\n\tConsidered globally, the geoid deviates from a mathematical reference surface (a rotational ellipsoid) by $\\pm 100$ meters at most.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{img/cosmology/geoid_vs_ellispsoid.jpg}\t\n\t\t\\caption[]{Relationship between geoid, ellipsoid and orthometric elevation (source: SwissTopo)}\n\t\\end{figure}\n\tThe specialist of geodesics and topography have to take into account these inhomogeneities!\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/asteroid_spherisation.jpg}\t\n\t\t\\caption{Evolution of asteroids shape in function of the radius}\n\t\\end{figure}\n\t\n\t\\subsubsection{Stability of Atmospheres}\n\tComparing the liberation velocity and the velocities of various gases, we can explain the stability of certain atmospheres and the absence of others. We have proved in the section of Classical Mechanics that the liberation velocity of a spherical star was given by the following relation (on which we will come back in the section of General Relativity):\n\t\n\tFor the Earth, a numerical application gives $v_L=11.2\\cdot 10^3\\;[\\text{m}\\cdot \\text{s}^{-1}]$ and for the Moon $v_L=2.37\\cdot 10^3\\;[\\text{m}\\cdot \\text{s}^{-1}]$.\n\n\tLet us recall that we have proved in the section of Continuum Mechanics during our study of the kinetic temperature the following relation (virial theorem):\n\t\n\tUsing the molar mass (\\SeeChapter{see section Thermochemistry page \\pageref{molar mass}}):\n\t\n\tA numerical application gives for nitrogen $v_\\text{Az}=517\\;[\\text{m}\\cdot \\text{s}^{-1}]$ and for hydrogen $v_\\text{Az}=1,934\\;[\\text{m}\\cdot \\text{s}^{-1}]$ with an arbitrary temperature of $300 [\\text{K}]$.\n\t\n\tSo nitrogen is obviously trapped in the Earth's atmosphere. Hydrogen, light gas, more fast is less trapped. The two gases are even less trapped by the Moon.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn fact, the mean square speed is not the only speed of molecules. There is a distribution of velocities. We have indeed study the Maxwell-Boltzmann distribution of a gas at equilibrium in the section of Statistical Mechanics.\n\t\\end{tcolorbox}\n\tThis below image of Earth’s atmosphere merging with the emptiness of space resembles an abstract painting. It was taken over western China in June 2007 by a Space Shuttle crew member. The thin silvery streaks (named \"noctilucent clouds\") high in the blue area are at a height of about $80$ kilometres. The atmosphere at this altitude is very thin. Air pressure here is less than a thousandth of that at sea level. The thin reddish zone in the lower portion of the image is the densest part of the atmosphere. It is here, in a layer called the troposphere, that practically all weather and cloud formation occur. Ninety percent of Earth’s atmosphere occurs within just $16$ kilometres (10 miles) of the surface.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/earth_atmosphere_side_view.jpg}\t\n\t\t\\caption[Earth's atmosphere side photo]{Earth's atmosphere side photo (source: NASA)}\n\t\\end{figure}\n\t\n\t\\subsubsection{Planetary equilibrium temperature}\\label{planetary equilibrium temperature}\n\tLet us consider a planet orbiting its host star. The star emits radiation isotropically, and some fraction of its emittance reaches the planet. The amount of radiation arriving at the planet is referred to as the incident star radiation, $M_{\\text{star}}$. The planet has an albedo that depends on the characteristics of its surface and atmosphere, and therefore only absorbs a fraction of the emittance. The planet absorbs the emittance that isn't reflected by the albedo, and heats up. One may assume that the planet radiates energy like a black-body at some temperature according to the Stefan–Boltzmann law. Thermal equilibrium exists when the power supplied by the star is equal to the power emitted by the planet. The temperature at which this balance occurs is the \"planetary equilibrium temperature\".\n\t\n\tThe solar flux (ie emittance) absorbed (abs) by the planet from the star is equal to the flux emitted (emit) by the planet:\n\t\n\tAssuming a fraction of the incident starlight is reflected according to the planet's albedo $\\rho$:\n\t\n\twhere $\\bar{M}_{\\text{star}}$ represents the area- and time-averaged incident star flux, and may be expressed as:\n\t\n\tThe factor of $1/4$ in the above formula comes from the fact that only a single hemisphere is lit at any moment in time (creates a factor of $1/2$), and from integrating over angles of incident sunlight on the lit hemisphere (creating another obvious factor of $1/2$).\n\t\n\tAssuming the planet radiates as a black-body according to the Stefan–Boltzmann law (\\SeeChapter{see section Mechanics page \\pageref{stefan boltzmann law}}):\n\t\n\tat some equilibrium temperature ${T}_{\\text{eq}}$, a balance of the absorbed and outgoing fluxes produces:\n\t\n\tRearranging the above equation to find the equilibrium temperature leads to:\n\t\n\tObviously we see that this relation doesn't depends on the distance to the star. So the idea is to rewrite this relation using the temperature at the surface of the star first (using Stefan-Boltzmann law again), to multiply by its surface, and divide it directly afterwards by the surface of the sphere going from the center of the star to the position of the planet at a distance $r$. \n\t\n\tTherefore (we introduce the bolometric intrinsic luminosity $L$):\n\t\n\tThe relation:\n\t\n\tis named the \"\\NewTerm{planetary equilibrium temperature}\\index{planetary equilibrium temperature}\". \n\t\n\tThe equilibrium temperature is neither an upper nor lower bound on actual temperatures on a planet. There are several reasons why measured temperatures deviate from predicted equilibrium temperatures (non-circular orbit, planet precession, etc.).\n\n\t\\pagebreak\t\n\t\\subsection{Roche's Limit}\\label{roche limit}\n\tThe Roche limit is the theoretical distance below which a satellite would begin to break down under the action of tidal forces caused by the celestial body around which it orbit, these forces exceeding the satellite internal cohesion.\n\t\n\tWe can simplify the problem by considering the satellite liquid, not rotating on itself (no spin), and decomposing it into two small masses $m$ of radius $r$ and volumetric density $\\rho_S$.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/roche_limit.jpg}\t\n\t\t\\caption{Configuration for the study of the Roche limit}\n\t\\end{figure}\n\tThe planet is a sphere of radius $R$, mass $M$,  volume density $\\rho_P$, located at a distance $D$ of the satellite axis.\n\t\n\tThe planet exerts on the satellite the gravitational attraction:\n\t\n\tThe difference of forces between the two masses is:\n\t\n\tWe can consider that $r \\ll D$, giving:\n\t\n\tSo the difference in force is\n\t\n\tIf the satellite cohesive force result in the gravitational attraction between the two masses:\n\t\n\tThe satellite is destroyed if the difference in strength between the two masses is greater than the cohesive force:\n\t\n\tBut we have the relations:\n\t\n\tTherefore we get:\n\t\n\tand we deduce of it the \"\\NewTerm{Roche limit}\\index{Roche limit}\":\n\t\n\tDepending on the approach and the approximations they can be a factor $3$ between some results.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tFor example the calculations given on Wikipedia consider only the difference in the primary's gravitational pull on the center of the satellite and on the edge of the satellite closest to the primary. This means that the main mass only apply one force momentum. But in fact this is not accurate as what interest us is the difference between the two extremities. This is why there is a factor $2$ between the Wikipedia calculations and ours (with our result the satellite will break twice the distance of that given by Wikipedia).\n\t\\end{tcolorbox}\n\t\n\tSince in this calculation, we considered a satellite as a two point masses without rotation, and again we have assumed that the satellite's cohesion was provided exclusively by gravitational interactions, this value is an order of magnitude.\n\t\n\t\\pagebreak\n\t\\subsection{Keplerian Orbitals}\\label{keplerian orbitals}\n\tObservation (main tool of the physicist and engineer for recall...) suggests at first glance, that the trajectories of celestial bodies in orbit around stars are indeed conical type (whew!) in the heliocentric reference frame. Knowing this, we can, in order to facilitate the calculation, anticipate the complexity of calculations and express the dynamics directly from a material point in polar coordinates.\n\n\tAs we saw it in the section Vector Calculus, the speed in polar coordinate is expressed by the relation (we changed the angle Greek letter notation to adapt it to the tradition in astronomy):\n\t\n\twhere to recall the first term is the radial velocity component and the second component the tangential (angular) velocity!\n\n\tFor acceleration (the proof is still in the section of Vector Calculus):\n\t\n\tNow that we have the tools, let us get to the case of Keplerian orbits in the case of a static Newtonian field.\n\n\tThere is to our knowledge the two main ways of doing the necessary mathematical developments but that do not gives (to our knowledge) the same level of detail results. The first approach provides finer results but is sometimes a bit do-it-yourself sometimes... is based on the use of the radial velocity and an important relation in astronomy, named the \"first Binet formula\". The second approach is simpler and most elegant, it uses the radial acceleration to approach the problem and a special relation named the \"second Binet formula\".\n\t\n\t\\subsubsection{First Binet Formula}\n\tTo start with this first approach to the problem, recall that we have already shown prove earlier that:\n\t\n\tHowever, it is unlikely that the main body is a perfect and homogeneous sphere ... so Astrophysicists have the habit of noting Newtonian potential $U$ under the form:\n\t\n\twhere $\\mu=GM$ is named \"\\NewTerm{gravitational constant of the star}\\index{gravitational constant of a star}\" (even if it is not always a star...) and where $f$ is a function representing the heterogeneity of the star.\n\t\n\tIf there is one place in the universe where the laws of mechanics are perfectly verifiable, it is space, because the friction or causes of dissipation are extremely small. Within the field of a single force deriving from a potential, the movement satisfies the conservation of mechanical energy.\n\n\tThus we end in the so-named \"\\NewTerm{energy equation}\\index{energy equation}\", wherein $E$ denotes the \"\\NewTerm{specific energy}\\index{specific energy}\" per unit weight (kilogram):\n\t\n\tTherefore:\n\t\n\tThe Newtonian gravitational force is central, thus of having a null torque force at the center O of the main body. This results in the conservation of angular momentum in norm and direction, either:\n\t\n\tThe vector $\\vec{W}$ is the normalized vector of $\\vec{b}$ or of $\\vec{h}$ named the \"\\NewTerm{reduced momentum}\\index{reduced momentum}\". $K$ is the constant of areas (\\SeeChapter{see page \\pageref{constant areal velocity}}) such that:\n\t\n\tWe recall to the reader that the norm of the speed expressed in polar coordinates is given by the relation (remember that the both vectors of the polar base are orthogonal and that we can therefore apply the Pythagorean theorem to calculate the norm as it has been proved in the section of Vector Calculus):\n\t\n\tWhich gives us the possibility to write the area constant $K$ as:\n\t\n\tLet us now put ourselves in the orbital plane, in polar coordinates.\n\t\n\tGiven the relation already proved and known:\n\t\n\tand its squared norm:\n\t\n\tOr in the case of a central force (conservation of angular momentum):\n\t\n\tLet's put this in the prior-previous expression of $v^2$, then we have:\n\tLet us put this in the expression prior-previous expression of $v^2$, then we have:\n\t\n\tThe relation:\n\t\n\tis named \"\\NewTerm{Binet's first formula}\\index{Binet's first formula}\".\n\t\n\tBy equating with the expression of $v^2$ resulting from the conservation of energy that we get earlier above, we have:\n\t\n\tThis gives us a rather complicated differential equation:\n\t\n\tAnd then we wonder how we can get out of such a situation? After some hours of reflection ... we realize that takes to make a substitution. After another hour of neural chaos this ultimately leads to an end.... We decide to put (we have the right to do it!), knowing that $r$ is a function of $u$ and $\\theta$:\n\t\n\tLet us derivate merrily relatively to $\\theta$:\n\t\n\tSubstituting in the differential equation:\n\t\n\tAfter simplification we get:\n\t\n\tWe separate the variables to integrate:\n\t\n\tWe have two solutions according to the sign we choose. However, at the end of the resolution, we notice that the only physically interesting choice is the negative sign. We have proved in the section of Differential and Integral Calculus And in our common derivatives that:\n\t\n\tWe will chose the primitive in cosine and therefore we have:\n\t\n\tWe leave, by approximation, the constant of integration that would involve very small oscillations in the orbit's path (if you do a study or a homework on this topic, you can transfer me your plots with or without the constant, it would interest me as I don't  have time to do it myself).\n\n\tThis allows us to obtain:\n\t\n\tNow we see that our choice of the sign for the integration is fully justified because now, if we do a little recall on conics (\\SeeChapter{see section Analytical Geometry page \\pageref{conics}}), we see that after rearrangement:\n\t\n\tSo finally we have a relation of the form if we choose $\\theta_0=0$:\n\t\n\twhere by analogy with the section of Analytical Geometry $e$ is the eccentricity (let us recall that $e=c/a<1$ with $a$ the semi big axes and $c$ the distance to the center of the ellipse to the focal) and $p$ the focal parameter ($p=b^2/a$) of an ellipse. This corresponds well to the trajectories that follow celestial bodies in orbit.\n\t\n\tWe thus fall back on our the first  Kepler \"law\"... so as we can see it, it can be proven!\n\n\tIn our case, we have after simplification to resume:\n\t\n\twhere (for recall) $K$ is the areas constant :\n\t\n\tand $\\mu$ is the gravitation constant of the celestial body:\n\t\n\tand finally $E$ the specific energy:\n\t\n\tThe reader could be able to check himself as we have seen in the section of Analytical Geometry in our study conical that if:\n\t\\begin{itemize}\n\t\t\\item If $E=0$ such that $e=1$ we have an opened orbit in the form of a parabola\n\n\t\t\\item If $E>0$ such that $e>1$ we have an opened orbit in the form of an hyperbola\n\n\t\t\\item If $E\\leq 0$ such that $0\\geq e <1$ we have a closed orbit in the form of an ellipse or a circle\n\t\\end{itemize}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/orbits.jpg}\t\n\t\t\\caption[]{Reminders of conical but \"orbit\" oriented}\n\t\\end{figure}\n\tFinally, if we inject:\n\t\n\tin the first Binet formula:\n\t\n\tthen we get the velocity in any point of the ellipse based on the primary variable parameter which is therefore the angle.\n\t\n\t\\subsubsection{Second Binet Formula}\n\tLet us now see the approach based on the radial acceleration which, while being more elegant, allows us to get a result less fine-tuned on the ellipse parameters.\n\n\tSo we start from the expression of the acceleration in polar coordinates (\\SeeChapter{see section Vector Calculus page \\pageref{polar coordinates}}):\n\t\n\tWe can simplify the writing of the second term:\n\t\n\tNow we have seen just above that:\n\t\n\tand so:\n\t\n\tThen the acceleration is reduced to:\n\t\n\tWe can eliminate the time by writing:\n\t\n\tand:\n\t\n\tThen we get:\n\t\n\tAnd so it comes to the standard \"\\NewTerm{Binet's second formula}\\index{Binet's second formula}\"\n\t\n\tBut according to Newton's second law and his law of gravitation, we have:\n\t\t\n\tWe then another form of the second Binet formula:\n\t\n\tOr after simplification and choosing the sign of the acceleration at our convenience to get rid of the \"-\" sign, we have:\n\t\n\tBy isolating the constants, we get:\n\t\n\tAfter a change of variables we recognize the particular case of a differential equation of the second order we have already met several times so far in the various sections of this book and we will meet again:\n\t\n\tAs it is customary, however, we will shoe the details of the resolution. The equation without second member is (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{second order differential equations}}):\n\t\n\tWe then have the discriminant that is negative since:\n\t\n\tWe then saw in the section of Differential and Integral Calculus, that in this situation the solution of the homogeneous equation was of the form:\n\t\n\tThus in the situation we are concerned, we have:\n\t\n\tWe inject the solution into the homogeneous differential equation with second member:\n\t\n\tand we see immediately see that for the equality to be satisfied, the general solution is:\n\t\n\tOr after rearrangement:\n\t\n\tAnd choosing the initial angle as zero, so we find well:\n\t\n\tat the difference with the first method of resolution that the value of the constant $A$ is unknown.\n\t\n\tLet us now come back on:\n\t\n\tBy expliciting:\n\t\n\tAnd as (\\SeeChapter{see section Classical Mechanics page \\pageref{kinematics of circular motion}}):\n\t\n\tSo if we choose a particular point of reference of the path (not necessarily circular path), we have:\n\t\n\tThen we have:\n\t\n\tIf we put the phase shift as zero relatively to the reference chosen radius earlier above, the expression simplifies to:\n\t\n\tTo determine the constant $A$, we place ourselves in the case where $\\theta=0$ and imposes that the radius $r$ is the initial radius measured when this angle is zero. Then we have:\n\t\n\tThis implies immediately:\n\t\n\tThus after elementary rearrangements and simplifications:\n\t\n\tAnd therefore we have a direct correspondence:\n\t\n\tAnd as the eccentricity $e$ is known for a circular, parabolic, elliptical or another trajectory of the conical type... it gets us very easy to deduce the velocity at the particular point of the initial radius $r$ of the studied object.\n\n\tThe closest distance of the object orbiting around its central star (focus), will be given by the value that can takes $r$ in the relation:\n\t\n\tif we impose $\\theta=0$.\n\n\tIn the case of an elliptical orbit it is the \"\\NewTerm{perigee}\\index{perigee}\" to be assimilated to the initial radius as the point where the measurement of the radial velocity was the most accurate.\n\n\tThe farthest distance from the focus will be given by putting the angle as being $180^\\circ$ ($\\pi$) and then we name it \"\\NewTerm{apogee}\\index{apogee}\".\n\t\n\t\\pagebreak\n\t\\subsubsection{Keplerian orbital period}\n\tThe Kepler's law of equal areas allows, as we already know, to calculate the Keplerian orbital period $T$. In fact, the area $S$ of the ellipse being equal to $S=\\pi a b$ (\\SeeChapter{see section Geometric Shapes page \\pageref{ellipse}}) and having already determined during our definition of the angular momentum that (\\SeeChapter{see section Classical Mechanics page \\pageref{angular momentum}}):\n\t \n\tIt comes naturally:\n\t\n\tMoreover, the study of conics (\\SeeChapter{see section Analytical Geometry page \\pageref{parameter of the ellipse}}) has showed us that:\n\t\n\tand we have defined above:\n\t\n\tSo we have the relation:\n\t\n\tand then we fall back again on the third Kepler's law:\n\t\n\twhich validates our previous calculations.\n\t\n\tObviously the latter relation is only available for $T$ where the corresponding speed is non relativistic otherwise we have to use General Relativity tools.\n\t\n\tBefore we continue... here are some useful data for this section and for that for Aerospace Engineering (ie \"space dynamics\") relatively to our knowledge in the state of year 2018 (various sources were used for these tables but the main one is Wikipedia):\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Mercury (terrestrial) $\\mercury$}} \\\\ \\hline\n\t\tMass & $3.3011\\cdot 10^{23}$ {[}kg{]} \\\\ \\hline\n\t\tMean density & $5.427\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $2,439.7$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $2,439.7$  {[}km{]} \\\\ \\hline\n\t\tPolar radius & $2,439.7$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $15,239.08$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $3.7 \\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $4.25\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 58.646 d \\\\ \\hline\n\t\tEquatorial rotation velocity & $10.892\\;[\\text{km}\\cdot\\text{h}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $0.034^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $7.00^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $0$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $69,816,900$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $46,001,200$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $57,909,050$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.205630$ \\\\ \\hline\n\t\tOrbital period & $87.969 $ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $47.362\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $363$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $0$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Mercury characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Venus (terrestrial) $\\venus$}} \\\\ \\hline\n\t\tMass & $4.8675\\cdot 10^{24}$ {[}kg{]} \\\\ \\hline\t\t\n\t\tMean density & $5.243\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $6,051.8$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $6,051.8$  {[}km{]} \\\\ \\hline\n\t\tPolar radius & $6,051.8$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $38,019.55$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $8.87 \\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $10.36 \\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & -243.025 d (retrograde) \\\\ \\hline\n\t\tEquatorial rotation velocity & $6.52\\;[\\text{km}\\cdot\\text{h}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $2.64^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $3.39^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $90,000$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $108,939,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $107,477,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $108,208,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.006772$ \\\\ \\hline\n\t\tOrbital period & $224.701$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $35.02\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $737$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $0$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Venus characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Earth (terrestrial) $\\earth$}} \\\\ \\hline\n\t\tMass & $5.97237\\cdot 10^{24}$ {[}kg{]} \\\\ \\hline\t\n\t\tMean density & $5.514\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $6,371.0$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $6,378.1$  {[}km{]} \\\\ \\hline\n\t\tPolar radius & $6,356.8$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $40,075.017$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $9.807\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $11.186\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 23h 56m 4.100s \\\\ \\hline\n\t\tEquatorial rotation velocity & $0.465\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $23.439281^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $0.00005^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $101.325$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $152,100,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $147,095,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $149,598,023$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.0167086$ \\\\ \\hline\n\t\tOrbital period & $365.256363004$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $29.78\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $287$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $1$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Earth characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Mars (terrestrial) $\\mars$}} \\\\ \\hline\n\t\tMass & $6.4171\\cdot 10^{23}$ {[}kg{]} \\\\ \\hline\t\t\n\t\tMean density & $3.9335\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $3,389.5$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $3,396.2$ {[}km{]} \\\\ \\hline\n\t\tPolar radius & $3376.2$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $21296.856$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $3.711\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $5.027 \\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 24h 37m 22s \\\\ \\hline\n\t\tEquatorial rotation velocity & $0.241\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $25.19^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $1.85^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $2-10$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $249,200,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $206,700,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $227,939,200$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.0934$ \\\\ \\hline\n\t\tOrbital period & $686.971$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $24.007\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $213$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $2$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Mars characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Jupiter (gaseous) $\\jupiter$}} \\\\ \\hline\n\t\tMass & $1.8982\\cdot 10^{27}$ {[}kg{]} \\\\ \\hline\n\t\tMean density & $1.326\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $69,911$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $71,492$  {[}km{]} \\\\ \\hline\n\t\tPolar radius & $66,854$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $439,263.76$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $24.79\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $59.5 \\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 9h 55m 30s \\\\ \\hline\n\t\tEquatorial rotation velocity & $12.6\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $3.13^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $1.303^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $-$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $816,620,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $740,520,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $778,570,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.0489$ \\\\ \\hline\n\t\tOrbital period & $4,332.59$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $13.07\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $165$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $69$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Jupiter characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Saturn (gaseous) $\\saturn$}} \\\\ \\hline\n\t\tMass & $5.6834\\cdot 10^{26}$ {[}kg{]} \\\\ \\hline\n\t\tMean density & $0.687\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $58,232$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $60,268$ {[}km{]} \\\\ \\hline\n\t\tPolar radius & $54,364$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $365,882.44$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $10.44\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $35.5 \\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 10h 33m \\\\ \\hline\n\t\tEquatorial rotation velocity & $9.87\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $26.73^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $2.485^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $-$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $1,514,000,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $1,352,550,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $1,433,530,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.0565$ \\\\ \\hline\n\t\tOrbital period & $10,759.22 $ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $9.68\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $100-160$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $62$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Saturn characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Uranus (gaseous) $\\uranus$}} \\\\ \\hline\n\t\tMass & $8.6810\\cdot 10^{25}$ {[}kg{]} \\\\ \\hline\t\n\t\tMean density & $1.27\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $25,362$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $25,559 $ {[}km{]} \\\\ \\hline\n\t\tPolar radius & $24,973$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $159,354.14$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $8.69\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $21.3\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & -17h 14m 24s (retrograde) \\\\ \\hline\n\t\tEquatorial rotation velocity & $2.59\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $97.77^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $0.773^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $-$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $3,008,000,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $2,742,000,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $2,875,000,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.046$ \\\\ \\hline\n\t\tOrbital period & $30,688.5$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $6.80\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $76$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $27$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Uranus characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Neptune (gaseous) $\\neptune$}} \\\\ \\hline\n\t\tMass & $1.0243\\cdot 10^{26}$ {[}kg{]} \\\\ \\hline\n\t\tMean density & $1.638\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $24,622$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $24,764$ {[}km{]} \\\\ \\hline\n\t\tPolar radius & $24,341$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $154,704.58$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $11.15\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $23.5\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 16h 6m 36s \\\\ \\hline\n\t\tEquatorial rotation velocity & $2.68\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $28.32^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $1.767^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $-$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $4,540,000,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $4,460,000,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $4,500,000,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.009$ \\\\ \\hline\n\t\tOrbital period & $60,182$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $5.43\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $72$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $14$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Neptune characteristics}\n\t\\end{table}\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|}\n\t\t\\hline\n\t\t\\multicolumn{2}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Pluto (terrestrial dwarf planet) $\\pluto$}} \\\\ \\hline\n\t\tMass & $1.303\\cdot 10^{22}$ {[}kg{]} \\\\ \\hline\n\t\tMean density & $1.854\\;[\\text{g}\\cdot \\text{cm}^{-3}]$ \\\\ \\hline\n\t\tMean radius & $1,188.3$ {[}km{]} \\\\ \\hline\n\t\tEquatorial radius & $-$ {[}km{]} \\\\ \\hline\n\t\tPolar radius & $-$ {[}km{]} \\\\ \\hline\n\t\tCircumference & $7,466.309$ {[}km{]} \\\\ \\hline\n\t\tSurface gravity & $0.620\\; [\\text{m}\\cdot \\text{s}^{-2}]$ \\\\ \\hline\n\t\tEscape velocity & $1.212\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tSidereal rotation period & 6d 9h 17m 36s \\\\ \\hline\n\t\tEquatorial rotation velocity & $0.013\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAxial tilt & $122.53^\\circ$ \\\\ \\hline\n\t\tEcliptic inclination & $17.16^\\circ$ \\\\ \\hline\n\t\tSurface pressure & $0,01$ {[}hPa{]} (at MSL) \\\\ \\hline\n\t\tAphelion & $7,375,930,000$ {[}km{]} \\\\ \\hline\n\t\tPerihelion & $4,436,820,000$ {[}km{]} \\\\ \\hline\n\t\tSemi-major axis & $5,906,380,000$ {[}km{]} \\\\ \\hline\n\t\tEccentricity & $0.2488$ \\\\ \\hline\n\t\tOrbital period & $90,560$ {[}d{]} \\\\ \\hline\n\t\tAverage orbital speed & $4.67\\;[\\text{km}\\cdot\\text{s}^{-1}]$ \\\\ \\hline\n\t\tAverage Temperature & $44$ {[}K{]} \\\\ \\hline\n\t\tNumber of satellites & $5$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\t\\caption{Some Pluto characteristics}\n\t\\end{table}\n\n\t\\pagebreak\n\t\\subsubsection{Classical deflection of light (light bending)}\\label{classical deflection of light}\n\tThe calculations done previously can be applied to an interesting case: the deflection of light by a star in the Newtonian interpretation (of course!).\n\n\tWarning!!! Newton did not know at its time that the photon was mass-less. The following developments are therefore a wrong approach in our time and should be taken with precaution but are still taught today because it allows students that do not yet studied General Relativity or that will never study it  (in the section on General Relativity, the reader will find the contemporary detailed proof of the deflection of light that is a whole other level) to have a first approach... it's like everything in physics! Until we have reached the level of the university degree, we learn many things \"wrong\" because oversimplified. Then at the Master or PhD level, we learn a little more realistic and valid theories.\n\n\tWell this being recalled (following the remark of one of our reader), so we have proved above for recall that:\n\t\n\tIn the case of a photon, we tend to put that $r\\rightarrow +\\infty$ (thus a hyperbolic trajectory) and therefore this requires that in the previous relation we have (which is equivalent to saying that $e$ is strictly greater than the unit as required by the hyperbolic trajectory):\n\t\n\tby putting $\\varphi=2\\theta-\\pi$ the elementary trigonometric relations (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}) give us:\n\t\n\tand therefore still using trigonometric identities:\n\t\n\tTherefore:\n\t\n\tAnd we know that:\n\t\n\tHence:\n\t\n\tneglecting the potential energy of the photon since $r\\rightarrow +\\infty$ (caution !!! Let us recall that according to what we saw in the section of Special Relativity, the photon has no mass strictly speaking but Newton knew nothing about this at his time!):\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tAfter simplification:\n\t\n\tand as $\\theta$ is assumed to be small, we have using the Taylor expansion (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}) of the tangent function:\n\t\n\tSo it finally comes:\n\t\n\tBut, we have by definition:\n\t\n\tand we know that $v=\\omega r=\\dot{\\theta}r$ (\\SeeChapter{see section Classical Mechanics page \\pageref{kinematics of circular motion}}). Thus we have:\n\t\n\tIf the particle is a photon passing flush with to surface of the Sun then we have for the \"\\NewTerm{classical deflection of light}\\index{deflection of light!Newtonian approach}\":\n\t\n\ta numerical application gives:\n\t\n\tNewtonian theory thus provides a $0.87$ arc seconds deviation for a ray of light passing flush to the Sun's surface. Which is twice less than what can be observed experimentally and that gives the theory of General Relativity (\\SeeChapter{see section General Relativity page \\pageref{general relativity precession of mercury perihelion}})!\n\t\n\tHere is a Flash animation of what a light bulb light rays propagation in vacuum, ON, would look like:\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_vacuum.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575751871}).\n\t\n\tAnd here is an another Flash animation of what a light bulb light rays propagation in vacuum putted in the presence of a punctual mass, ON, would look like:\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_newton.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575750678}).\n\t\n\t\\subsubsection{Classical precession of perihelion}\\label{classical precession of perihelion}\n\tBefore studying the precession of the orbits, we would recall that the gravitational field is a conservative and center field. This implies that the angular momentum (\\SeeChapter{see section Classical Mechanics page \\pageref{angular momentum}}) is constant and that the path is held in a plane whose normal vector to the surface always maintains the same direction (the angular momentum vector is constant in norm and direction for recall!).\n\n\tWe will address here the analysis of the precession of the perihelion taking into account the results of the theory of special relativity (allowing it to be more accurate in the results and be able to apply these results to the orbiting electrons around the nucleus of the atom in the corpuscular model).\n\t\n\tFirst let us recall that:\n\t\\begin{itemize}\n\t\t\\item The \"perihelion\" is the point of the orbit of a celestial body (planet, comet, etc.) that is closest to the star around which it rotates.\n\n\t\t\\item The \"aphelion\" is the point in the orbit of an object (planet, comet, etc.) where it is farthest from the star around which it rotates.\n\n\t\t\\item The \"equinox\" is the moment (time) when the central star crosses the plane of the equator of the object that is in orbit around it.\n\t\\end{itemize}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWhen the Sun passes from the southern hemisphere to the northern hemisphere of the Earth (in other words when the Sun is at the Zenith at midday at the equator), it is the spring equinox (20 or 21 March) in the opposite direction, this is the autumn equinox (22 or 23 September). At these dates, there is equality of day and night all over the Earth from the point of view of the Equator.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\fbox{\\includegraphics[width=0.8\\textwidth]{img/cosmology/sun_paths.jpg}}\n\t\t\\caption[Solstices and Equinoxes depending on the latitude]{Solstices and Equinoxes depending on the latitude (source: ?)}\n\t\\end{figure}\n\t\\end{tcolorbox}\n\tObviously, the result we get will here is not complete, since, as we know, we had to wait the development of General Relativity to give the exact value of the perihelion  precession of Mercury (see will come back on this subject further below).\n\n\tTo calculate the effect of precession, we will seek the equivalent of the Binet formulas seen above in relativistic form (we will see the classical form in the section of General Relativity). For this we proceed as follows:\n\n\tThe relativistic Lagrangian of the system is (\\SeeChapter{see section Special Relativity page \\pageref{mass energy equivalence}}):\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe subtract then energy at rest because only interest us here the study of the kinetic and potential energy. The potential energy is summed in the Lagrangian above (which is not consistent with the practice) but we will reverse the sign later below during the developments.\n\t\\end{tcolorbox}\n\tWith (\\SeeChapter{see section Special Relativity page \\pageref{fitzgerald lorentz factor} and Vector Calculus page \\pageref{polar coordinates}}):\n\t\n\tand the reduce mass for recall:\n\t\n\tThe angular moment:\n\t\n\tin relativistic form and applied to our study is:\n\t\n\tTaking the norm, we have without forgetting that in our study $\\vec{\\omega}\\bot\\vec{r}$ and therefore $(\\vec{\\omega}\\bot\\vec{r})\\bot\\vec{r}$: and let us recall that we have adopted the notation $\\omega=\\dot{\\theta}$ (in case you forget the definition...). Which finally gives us:\n\t\n\tTo establish the relativistic equivalent of the Binet formulas:\n\t\\begin{itemize}\n\t\t\\item We deduce the expression of the angular momentum:\n\t\t\n\n\t\t\\item We seek for a relation of the type $\\dot{r}=\\dot{r}(\\theta)$ (as the trajectory is a conic):\n\t\t\n\t\tIndeed let us recall that in polar coordinates the speed is given by the following expression (\\SeeChapter{see section Vector Calculus page \\pageref{polar coordinates}}):\n\t\t\n\t\tThat is to say, $\\dot{r}=f(r,\\theta)$. The latter expression gives us the possibility to write that:\n\t\t\n\t\t\n\t\t\\item We seek a relation of the type $\\ddot{r}=\\ddot{r}(\\theta)$:\n\t\t\n\t\\end{itemize}\n\tFrom the equations obtained previously, we have successively:\n\t\n\tLet us recall that we have defined in special relativity $\\beta$ and that by using the speed in polar coordinates:\n\t\n\tWith the previous relations, this gives us:\n\tWith the above relations, this gives us:\n\t\n\tOn the other hand:\n\t\n\tBy introducing in the prior previous relationship in the latter:\n\t\n\tBy putting $u=1/r$ and as:\n\t\n\tThe prior-previous relationship becomes with this expression:\n\t\n\tEquating this relation with that of the Lagrangian:\n\t\n\tDifferentiating the latter relation relatively to $\\theta$:\n\t\n\tIndeed, the Lagrangian is constant over time (the system is assumed to be conservative), we then have:\n\t\n\tand also:\n\t\n\tBut if we continue:\n\t\n\tBy referring to:\n\t\n\tSo we get:\n\t\n\tThat gives after a few simplifications:\n\t\t\n\tBy multiplying the latter by $\\mu^2c^2/b^2$:\n\t\n\tIn a gravitational potential:\n\t\n\tThe Binet equation in special relativity is then:\n\t\n\tTo find a solution to this differential equation, we will group the variable $u$ in the left side:\n\t\n\tWe put:\n\t\n\tThe differential equation then can be written:\n\t\n\tWe put:\n\t\n\tBy taking the second derivative:\n\t\n\tWe then get a simple differential equation:\n\t\n\twhose solution is well known to us (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{second order differential equations}}):\n\t\n\tWhat can still be written as $\\Omega^2$ is a constant:\n\t\n\twith $k_1,k_2=c^{te}$.\n\n\tTo determine the constants $k_1,k_2$, we place ourselves first in the situation for which $\\theta=0$, where $r$ is minimal and therefore by $u$ is maximum by definition.\n\t\n\tWe derivate relatively to $\\theta$:\n\t\n\tTherefore $k_2=0$ which makes that the relation:\n\t\n\tbecomes:\n\t\n\tWritten differently (trying to return to a similar notation to that of the study of conic) then:\n\t\n\tAnd the interest to write this in this way is to notice that we fall ultimately on the equation of an ellipse with $p$ being the focal parameter of the conic, focal parameter given for recall by (\\SeeChapter{see section Analytical Geometry page \\pageref{parameter of the ellipse}}):\n\t\n\twhere $a$ is the half major axes of the ellipse.\n\t\n\tNow let us put:\n\t\n\tIn the first passage through the perihelion $\\theta=0$ where:\n\t\n\twe therefore have:\n\t\n\tNow let us put:\n\t\n\tAt the first passage through the perihelion $\\theta=0$ where:\n\t\n\twe have therefore:\n\t\n\tAt the second passage through the perihelion $\\theta=2\\pi$, we have:\n\t\n\twe also have:\n\t\n\tThe trajectory is still an ellipse but the angle $\\Omega\\theta_0$ that was zero initially has become $\\Omega\\theta_1=2\\pi$.\n\n\tThat is, if we have:\n\t\n\tTherefore:\n\t\n\tWhich gives us:\n\t\n\tSince $G^2\\ll c^2$, a development in Taylor series give us (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tBy limiting at the order $2$:\n\t\n\tSo in conclusion, there is an advancement of the perihelion taking place in the satellite's direction of rotation. For a repository located in the satellite's rotation plane, the trajectory is always an ellipse.\n\n\tThis advance is of:\n\t\n\tby period. Either by expliciting the momentum given for reminder by:\n\t\n\tIt comes after simplification:\n\t\n\tWe will now allow us a rough approximation (mixture of relativistic and non-relativistic). If we consider the last relation, we have obtained during our developments of the Keplerian orbital trajectories the relation:\n\t\n\tTherefore, injecting this into the relation of $\\Delta \\alpha$\twe have:\n\t\n\tAnd we have also proved in the section of Analytical Geometry that:\n\t\n\tTherefore:\n\t\n\tUnfortunately, the numerical values for Mercury precession with $G=6.674\\cdot 10^{-11}\\;[\\text{m}^3\\cdot\\text{kg}^{-1}\\cdot \\text{s}^{-2} ]$, $M=1.99\\cdot 10^{30}$ [kg], $e=0.260$, $a=5.787\\cdot 10^{10}$ [m] and $T=88$ [days], gives for a century ($100$ years of $365$ days):\n\t\n\tThus a precession of an angle of $7''$ century, and not the $43''$ as expected (...) there is therefore a lack of a factor $6$ that only the General Relativity (\\SeeChapter{see section General Relativity page \\pageref{general relativity precession of mercury perihelion}}) makes possible to find. It is nevertheless interesting that Special Relativity already gives an orbit that precesses where Newton sees stable ellipse and that this approximation works for all the planets except Mercury (the planet closest to the Sun and undergoing the brunt of curvature of space-time).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tBy applying exactly the same reasoning to corpuscular quantum physics (electrical potential) but with the ad hoc constants seen in the section of Electrostatics, we find:\n\t\n\twith $\\vec{b}=\\mu\\vec{r}\\times\\vec{v}$ being the momentum and in the case of the atom, we will take (\\SeeChapter{see section Corpuscular Quantum Physics page \\pageref{second quantification condition}}):\n\t\n\twith reduced mass equal to:\n\t\n\t\\end{tcolorbox}\n\tIf the positions of the perihelion (and therefore the aphelion) of the Earth-Moon center of gravity  were constant over time, the duration of the different seasons would be constant. But the orbit of the center of gravity Earth-Moon also rotates in its plane in the forward direction at about 12'' per year (a revolution is about $108,000$ years).\n\n\tThe precession of the equinox occurs in the opposite direction (retrograde direction) at about $50''$ per year (then a \"\\NewTerm{precession equinox}\\index{precession equinox}\" revolution is about $26,000$ years). The combination of these two movements permits to calculate the period of the passage of the perihelion of the Earth by the direction of the vernal equinox, this period of about $21,000$ years and is named the \"\\NewTerm{climatic precession}\\index{climatic precession}.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/precession_orbit_earth.jpg}\t\n\t\t\\caption[Effects of precession on the seasons using the Northern Hemisphere terms]{Effects of precession on the seasons using the Northern Hemisphere terms (source: Wikipedia)}\n\t\\end{figure}\n\tIndeed, every $10,500$ years (half period of climatic precession) aphelion changes from summer to winter. But even if the Earth-Sun distance is by far not the predominant factor in the nature of the seasons, the combination of the passage of the Earth in the winter in aphelion gives winters a little bit more harsh. Earth-Sun distance also depends on the variation in the eccentricity of Earth's orbit (due to external and inner planets). Thus, the ice ages are correlated with the minimum eccentricity of Earth's orbit.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/precession_orbit_earth_perspective.jpg}\t\n\t\t\\caption[]{Simplified and perspective point of view of the previous figure (source: Latsis foundation (2001))}\n\t\\end{figure}\n\tThe work of the Celestial Mechanics Institute (France), since the 1970s, would have to definitively confirm the theoretical predictions as what the eccentricity of Earth's orbit undergoes wide variations formed numerous periodicals under which the most important one have periods near $100,000$ years, and for one of them, a period of $400,000$ years. These results confirm the climatic variations of the Earth during the Quaternary (\\SeeChapter{see section Weather \\& Marine Engineering page \\pageref{milankovic cycles}}). The paleoclimatology models indeed show the correlation between changes in the Earth's orbit elements and large quaternary glaciation.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn the case of the hydrogen atom (\\SeeChapter{see section Corpuscular Quantum Physics page \\pageref{wilson and sommerfled model}}), for the case dealing with relativistic model of Sommerfeld, with $n=1,n_\\theta=1,Z=1$ and the fine structure constant approximately equal to $1/137$, we get by applying the above relation by analogy but for the precession of the perihelion of the orbit of the electron:\n\t\n\taccording to a corpuscular point view of matter!\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Duration of the diurnal arc} \n\tA diurnal arc is the time, as expressed in right ascension, it takes a planet, point, or degree to move from its rising point to its setting point. This takes place in many celestial bodies such as the Sun and Moon.\n\t\n\tSo we will study here at the time length of the day, more exactly to the portion of day where we are illuminated by the Sun, as compared to the night when we are in the shade\\footnote{Thanks to Xavier Hubaut for these very friendly developments}.\n\t\n\tIn reality, the Earth revolves around the Sun and describes an almost circular orbit at the same time it turns on itself around its axis that is tilted (actually) by about $23^\\circ 27'$ relatively to its orbital plane (the ecliptic):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/equinox_solstice.jpg}\t\n\t\t\\caption{Representation of the rotation of the Earth on its orbit with its major phases}\n\t\\end{figure}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is obvious that, given the complexity of the problem, we will simplify it by considering a circular orbit without variations (precession, nutation) of the axis of rotation of the Earth. We will assume that the Sun is reduced to a point (no dawn or twilight, etc.).\n\t\\end{tcolorbox}\n\tLet us first recall that the precession is the gradual change in direction of the axis of rotation of an object when a torque (force) is applied to it while the nutation is a periodic balancing of the axis of rotation of the Earth around its mean position in addition to the precession (\\SeeChapter{see section Classical Mechanics page \\pageref{gyroscope}}).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/nutation_precession_earth.jpg}\n\t\\end{figure}\n\tLet us represent the Earth with its vertical axis of rotation. Accordingly the equator will be located in a horizontal plane.\n\n\tSuppose that day, the Earth is in such a position that the Sun's rays form an angle $\\alpha$ with the equatorial plane (or conversely that the axis of the Earth form an angle with the equatorial plane). Notice that this angle $\\alpha$ will always be according to actual measurements  between $-23^\\circ 27'$ and $+23^\\circ 27'$ at least... at a human life time scale...\n\t\n\tFor our example we have chosen to focus our analysis on a day when $\\alpha$ is positive. Thus, in the northern hemisphere, we are close to the summer solstice!\n\n\tWe are looking for the day length at a place located at latitude $\\lambda$! To fix ideas, we place ourselves around Brussels at $50^\\circ$ north latitude.\n\t\n\tLet us now consider the following figures where the first is a view of the side of Earth at a time $t$ of its orbit when $\\alpha>0$ and the second in to a cylindrical cutting of diameter $\\overline{NJ}$ (corresponding to the diameter of the parallel of Brussels) of Earth's volume Earth at this same moment:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/diurnal_arc_duration.jpg}\n\t\\end{figure}\n\tOn the figures above, $C$ denotes the center of the Earth, and O the center of the parallel of Brussels.\n\n\tLet us fix a time $t$ and denote by $M$ (morning) and $S$ (evening) the two points of the parallel of Brussels where the Sun rises and sets (these points will be considered fixed whatever the moment $t$, which is obviously wrong relatively to the reality), while $J$ (day) and $N$ (night) will be the points where it is noon and midnight respectively.\n\n\t$P$ will be the point on the disc corresponding to the Brussels parallel where the meridian noon plane  (the plan which of the sides is $\\overline{NJ}$) cut the line $\\overline{MS}$.\n\n\tFinally, $\\gamma$ designate the angle $\\widehat{M\\text{O}S}$ (where O is the center of the disk generated by the parallel of Brussels) behind the illuminated part by the Sun and $r$ designate the radius $S\\text{O}=M\\text{O}$.\n\n\tTo simplify the problem, let us also assume... that during $24$ hours the Earth rotates on itself without changing the position of its axis of rotation relative to the Sun....\n\n\tThe angle $\\gamma$ can be calculated by noting that $\\overline{\\text{O}P}$ is, in absolute value equal to:\n\t\n\twhere $r$ represents for recall the radius of the parallel of Brussels.\n\t\n\tUsing the properties of trigonometric functions (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}), we have:\n\t\n\tBut we still need to inject the parameter $\\alpha$. Knowing the latitude $\\lambda$ of Brussels, we have:\n\t\n\twhere $R$ is the radius of the Earth.\n\n\tWe have also:\n\t\n\tand in the triangle $C\\text{O}P$:\n\t\n\tFinally, by comparing the values obtained for $\\overline{P\\text{O}}$, we get:\n\t\n\tand as:\n\t\n\tWe finally get:\n\t\n\tand therefore:\n\t\n\tAt the equinoxes (that is to say when the equator coincides with the ecliptic plane for recall...) we have $\\alpha=0$ and therefore:\n\t\n\tHowever, as we have specified it at the beginning, we must take the absolute value thus:\n\t\n\tIn other words, whatever the latitude we take, the angle formed by the night area is equal to the angle formed by the day area at equinoxes (both being equal to $\\pi$).\n\n\tLet us now consider the summer solstice, when $\\alpha=23^\\circ 27'$ still considering the latitude of Brussels $\\lambda=50^\\circ$, we have:\n\t\n\tThis translated into hours by:\n\t\n\tSo the 24-hour day loses $7.9$ hours. Which is equivalent to a day light of approximately $16$ hours.\n\t\n\tIn summary to calculate the duration of a \"day\", it is enough to know two things: the latitude and the angle at which the Sun falls on the plane of the equator to the chosen date. The value of this angle is well known at the equinoxes (it is $0^\\circ$) and to the solstices (it is $+23^\\circ 27'$ and $-23^\\circ 27'$).\n\n\tBut what about the other dates?\n\t\n\tThe answer is quite simple. Let us imagine, sitting on the Sun watching throughout the year towards the center of the Earth.\n\n\tDuring its rotation around the Sun (the binomial centroid in fact), the axis of rotation of the Earth maintains its inclination to the ecliptic. Seen from the Sun, this axis revolve around normal to the plane of the ecliptic and therefore describe a cone whose half apex angle is $23^\\circ27'$ (see figure below).\n\n\tThe angle of attack $\\alpha$ of the sunlight on the equator therefore vary according to the date $\\delta$ (we associate to the date, the angle $\\delta$ travelled by the Earth on its orbit, from its position the spring equinox)\n\n\tTherefore, the angle $\\alpha$ vary according to the date $\\delta$ sinusoidally.\n\n\tFor those who are perhaps not convinced by this semi-intuitive reasoning, here's another approach:\n\n\tFor readability of the diagram, we have greatly exaggerated the angle of the axis of rotation of the Earth with the ecliptic:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/cone_generated_by_earth_rotation.jpg}\n\t\\end{figure}\n\tGiven $C$ the Earth's center, $A$ the end of a unitary vector $\\overrightarrow{CA}$ oriented directed along the axis of rotation of the Earth (ie perpendicular to the plane of the equator) and another unit vector $\\overrightarrow{CS}$ directed toward the Sun. Given now $\\alpha$ the angle of the radius $\\overline{CS}$  with the plane of the equator and $\\beta$ the angle between the unit vectors  $\\overrightarrow{CS}$ and  $\\overrightarrow{CS}$. Then we have:\n\t\n\tIndeed, the vector $\\overrightarrow{CA}$ being perpendicular to the plane of the equator, it forms a right angle with it. Therefore since the angle $\\beta$ is the angle between this vector and the ecliptic, the angle $\\alpha$ is then the complementary angle.\n\t\n\tTherefore we have:\n\t\n\tLet us decompose now $\\overrightarrow{CA}$ in the sum of $\\overrightarrow{CA'}$ directed perpendicular to the ecliptic plane and of $\\overrightarrow{CA''}$ located in the ecliptic plane:\n\t\n\tTherefore:\n\t\n\tBut:\n\t\n\tSo finally:\n\t\n\tand as we have demonstrated that:\n\t\n\tWe finally get:\n\t\n\tNow the problem is solved and the daylight time duration will depend on two variables: the date $\\delta$ and the latitude $\\lambda$.\n\n\tWe just have so now to take again the relation:\n\t\n\tand to inject in it the new result to get a first simple version of \"\\NewTerm{equation of time}\\index{equation of time}\":\n\t\n\tWith computer tools at our disposal, we can easily calculate the value $\\gamma$. For example, we have below the variations in the length of the day over a year at latitudes of $0$ to $90^\\circ$ spread by $10$ by $10^\\circ$:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/equation_of_time.jpg}\n\t\t\\caption{Equation of time plot}\n\t\\end{figure}\n\tFrom the latitude of the Arctic Circle, we see, in summer, periods with uninterrupted Sun (midnight Sun) and in winter whole days of night.\n\n\tFor Brussels (latitude = $50^\\circ$) we see from the figure that the length of the day varies approximately between the values of $16$ [h] (summer solstice) and $8$ (winter solstice).\n\t\n\t\\subsection{Evolution of diurnal arc (ie Earth-Moon distance)}\n\tIn many books or documentaries you can read or listen the following statements:\n\t\\begin{itemize}\n\t\t\\item That the rotational movement of the Earth on itself slows down by the tidal effect\n\t\t\n\t\t\\item As the distance from Earth to Moon increases\n\t\t\n\t\t\\item That these two effects are related\n\t\\end{itemize}\n\tLet us see if we can prove demonstrate this link and verify the orders of magnitude of these observed effects. \n\t\n\tIf we want to describe it completely, the movement of the Moon is a three-body problem (Earth, Moon, Sun) subjected to several hundred periodic or secular disturbances, which makes it very difficult. So the tides on Earth are caused mainly by the Moon, but the Sun also intervenes: the ratio of the gravitational forces exerted by the Moon and by the Sun on a body of water on the surface of the Earth is $2.2$.\n\t\n\tFor what interests us, however, we will consider the Earth-Moon system as isolated in space. This is because we are studying the movement of rotation on itself of this system: in a way we relate the action of the Sun to the Earth-Moon center of mass. In addition, we are not studying how the tides slow down the rotation of the Earth: this slowing down being observed, we want to show how a slowing down of the Moon follows.\n\t\n\tSecond approximation: in the rotational motion, we will confuse the center of mass of the system with the center of the Earth, and the Moon will be assumed to describe an elliptical Keplerian orbit around the center of the Earth.\n\t\n\tThe physical law that must be applied is therefore simple: the angular momentum $\\vec{b}$ of the Earth-Moon system is conserved. However, this total angular momentum $\\vec{b}_{\\text{tot}}$ is, in the Galilean coordinate system of the center of mass, the sum of three terms:\n\t\\begin{enumerate}\n\t\t\\item The angular momentum of rotation of the Earth on itself (considering it as a perfect ball), $\\vec{b}_{\\earth}$. It is directed along the axis of the poles and therefore forms an angle of $23^\\circ 27'$ with the perpendicular to the plane of the ecliptic. In intensity it is:\n\t\t\n\t\twhere $M_{\\earth}\\cong 6\\cdot 10^{24}$ [kg], $R_{\\earth}\\cong 6.4\\cdot 10^{6}$ [m] and $T_{\\earth}=86,164$ [s].\n\t\n\t\t\\item The angular momentum of rotation of the Moon on itself (also considered as a perfect sphere) $\\vec{b}_{\\fullmoon}$ it is directed along the axis of rotation of the Moon, which forms an angle of $6^\\circ$ with the normal to the plane of the lunar orbit, itself inclined by $5^\\circ$ on the plane of the ecliptic. It is worth in intensity:\n\t\t\n\t\twhere $M_{\\fullmoon}\\cong M_{\\earth}/81$ [kg], $R_{\\fullmoon}\\cong R_{\\earth}\\cdot 0.272$ [m].\n\t\n\t\t\\item The angular momentum of rotation of the Moon around the Earth $\\vec{b}_{M-E}$ is perpendicular to the plane of the lunar orbit. In intensity it is (assuming the Moon as punctual otherwise she should apply the Steiner theorem):\n\t\t\n\t\twhere $r$ is the Earth-Moon distance and $v_{\\fullmoon}$ the speed of the moon on its orbit.\n\t\t\n\t\tHere comes another approximation to simplify the calculation. The elliptical orbit of the Moon has actually an eccentricity of $0.055$. We will liken it to a circle for which we will still use Kepler's third law. Then if one notes $\\omega$ the pulsation and $D$ the semi-major axis one has:\n\t\t\n\t\ttherefore:\n\t\t\n\t\tFollowing third Kepler's law (see page \\pageref{third kepler law}) given for recall by:\n\t\t\n\t\tTherefore:\n\t\t\n\t\tSo finally:\n\t\t\n\t\\end{enumerate}\n\tThe total angular momentum is therefore worth, in projection on the perpendicular to the plane of the ecliptic:\n\t\n\tLet's identify the factors that change over time. Earth's own pulsation, $\\omega_{\\earth}$, decreases as the length of the day increases according to all actual experimental evidence; the distance $D$ from the Earth to the Moon increases also according to all actual experimental evidence; on the other hand, we will assume the pulsation $\\omega_{\\fullmoon}$ to be constant (otherwise the problem is unsolvable and anyway the moon is negligible in comparison of Earth...).\n\t\n\tWe therefore write that the variation $\\Delta b_{\\text{tot}}$ of the total angular momentum is zero:\n\t\n\tas $\\Delta \\omega_{\\fullmoon}=0$.\n\t\n\tTherefore:\n\t\n\tBut $\\omega_{\\earth}=2\\pi/T_{\\earth}$ then $\\Delta \\omega_{\\earth}=-2\\pi\\Delta T_{\\earth}/T_{\\earth}^2$. Hence:\n\t\n\tSo finally:\n\t\n\tWe have achieved what we wanted to demonstrate: slowing down of the Earth's own rotation and moving the Moon away are linked. If the Earth slows down, its angular momentum decreases; since that of the Moon on itself is constant, for the total angular momentum to be conserved, the Moon must move away from the Earth, thus increasing its angular momentum.\n\t\n\tKnowing, due to experimental measurements, that $\\Delta T\\cong 1.64\\cdot 10^{-5}\\;[\\text{s}\\cdot\\text{year}^{-1}]$ and that:\n\t\n\tWe get:\n\t\n\tHence $3.3\\cdot 10^{-2}\\;[\\text{cm}\\cdot\\text{year}^{-1}]$ (the measured value is actually of $3\\;[\\text{cm}\\cdot\\text{year}^{-1}]$).\n\t\n\tWhere are we going ? $300$ million years ago, the day lasted $22$ hours, there were $400$ days in the year. When the Earth-Moon coupling will be over, the day will last $50$ hours of our current days. A simple rule of three can say that it will be roughly in $250$ billion years. The Moon will then be at a distance of $1,500$ terrestrial radius, compared to the $60$ today (the distance of the Earth to the Sun is worth $25,000$ terrestrial rays). For sure there will be also no Solar Eclipse anymore in the future as we know them actually!\n\t\n\tBut all this is only a bold extrapolation, because long before these 250 billion years, the Sun will have become a red giant (in 5 billion years) and its crown will have reached the Earth ...\n\t\n\t\\subsection{Trigonometric parallax}\n\tMeasuring distances to objects within our Galaxy is not always a straightforward task – we cannot simply stretch out a measuring tape between two objects and read off the distance. Instead, a number of techniques have been developed that enable us to measure distances to stars without needing to leave the Solar System. One such method is \"\\NewTerm{trigonometric parallax}\\index{trigonometric parallax}\", which depends on the apparent motion of nearby stars compared to more distant stars, using observations made $6$ months apart (corresponding to the measurement of diameter of the apparent approximated circular motion they have in the sky).\n\n\tA nearby object viewed from two different positions will appear to move with respect to a more distant background. This change is named a \"\\NewTerm{parallax}\"\\index{parallax}. A simple demonstration is to hold your finger up in front of your face and look at it with your left eye closed and then your right eye. The position of your finger will appear move compared to more distant objects.\n\n\tBy measuring the amount of the shift of the object's position (relative to a fixed background, such as the very distant stars) with observations made from the ends of a known baseline, the distance to the object can be calculated.\n\t\n\tThe trigonometric parallax method is very simple (but difficult to implement on the surface of our planet for very distant stars). Any amateur astronomer observed the flight of the star it observes with his eye. This movement is named as we have just seen the \"\\NewTerm{diurnal movement}\\index{diurnal movement}\" It is due to the rotation of the Earth itself. The star is also driven in an elliptical motion much less easily detectable: the \"\\NewTerm{parallactic motion}\\index{parallactic motion}\".\n\n\tIt is due, as suggested in the figure below, to the rotation of the Earth around the Sun. So we measure the angle $p$ and we have obviously:\n\t\n\tIf the angle is small (which is very often the case given the distance of stars...) we can take the first term of the Taylor expansion (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}) of the tangent function:\n\t\n\tWhich allow us to write:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/parallax.jpg}\n\t\t\\caption{Trigonometric parallax principle}\n\t\\end{figure}\n\tIf the parallax angle, $p$ is measured in arc-seconds (arcsec), then the distance to the star, $d$ in parsecs (pc) is given by:\n\t\n\tIt is important to notice that in this example we assume that both the Sun and star are not moving with a transverse velocity with respect to each other. If they were this would complicate the picture as presented here. In practice stars with significant proper motions require at least three epochs of observation to accurately separate their proper motions from their parallax. Stars that are members of binaries further complicate the picture.\n\n\tThe only star with a parallax greater than $1$ [arcsec] as seen from the Earth is the Sun - all other known stars are at distances greater than $1$ [pc] and parallax angles less than $1$ [arcsec] ($1/3600$ of degree... we understand better why this what impossible to measure before the 19th century). When measuring the parallax of a star, it is important to \"account for the star's proper motion, and the parallax of any of the fixed\" stars used as references.\n\n\tOver a $4$ year period from 1989 to 1993, the Hipparcos Space Astrometry Mission measured the trigonometric parallax of nearly $120,000$ stars with an accuracy of $0.002$ [arcsec]. The GAIA mission, to be launched in 2010, will be able to measure parallaxes to an accuracy of $10^{-6}$ [arcsec], allowing distances to be determined for more than $200$ million stars.\n\t\n\tIn practice when we measure the parallax we must obviously take in account the obliquity of Earth on it's orbit that is in this beginning of the 21st century equal to $23^\\circ 26'13.3$ otherwise me may think that stars have a huge parallax and therefore and are therefore at a small distance of us as illustrated be the figure below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{img/cosmology/parallax_big_dipper_north_star.jpg}\n\t\t\\caption[]{Shift angle of the Big Dipper that seems huge if we do not subtract the obliquity angle}\n\t\\end{figure}\n\tIn the figure above the \"North star\" may be any fixed star close to either celestial pole of any given planetary body. It might refer to any such star in the Earths remote history or future, situated along the path of the celestial poles in the course of the procession of the Earth's axis.\n\t\n\tThe identity of the pole stars gradually changes over time because the celestial poles exhibit a slow continuous drift through the star field. The primary reason for this is the precession of the Earth's rotational axis, which causes its orientation to change over time. Precession causes the celestial poles to trace out circles on the celestial sphere approximately once every $26,000$ years, passing close to different stars at different times (with an additional slight shift due to the proper motion of the stars).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{img/cosmology/north_star_precession.jpg}\n\t\t\\caption[]{The path of the north celestial pole amongst the stars due to the effect of precession, with dates shown (source: Wikipedia)}\n\t\\end{figure}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThere are some situations in which we can't measure the distance to a single star of some particular spectral type directly because all the stars of that type are just too far away. In these situations, we can fall back upon two techniques which deal with groups of nearly identical stars: statistical parallax and secular parallax.\n\t\\end{tcolorbox}\n\tNotice that the same type of trigonometric technique seems to have been used by Hipparchus to determine the distance to the Moon in 129 BC:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/hipparchus_distance_to_moon.jpg}\n\t\\end{figure}\n\t\t\n\t\\subsection{Planets' Motion}\n\tOn January 7, 1610, Galileo made observations of Jupiter and discovered four of the giant planet's satellites, now named after him as the Galilean moons (Ganymede, Callisto, Europa, and Io). Here were heavenly bodies that clearly orbited an entity other than the Earth, as Galileo concluded over several nights of observation, seeing the moons change sides as they travelled around the planet. This discovery clearly contradicted the Catholic Church’s Ptolemaic belief (and also various statements of the Quran - who by the way as the Bible - doesn't contain any Science but only poor value claims) that every celestial body orbits the Earth.\n\t\n\tBut the coup de grâce came within eight months, in September of 1610, when Galileo observed the planet Venus and noted that it went through complete phases, like our Moon. According to the Ptolemaic model, built on epicycles, we should only be able to see some of Venus’s phases: either thin crescents (if it were on the inside of the orbit of the sun around the earth) or only gibbous and full phases (if it were on the outside of the Sun’s orbit) - but not both. The fact that all phases of Venus are visible, just as we see with our Moon, meant to Galileo that the Ptolemaic model couldn't possibly be right. Rather, Copernicus’s model of the solar system was the one that reflected reality. the Tuscan rulers could not protect Galileo from an order of extradition to face the dreaded Inquisition in Rome - which had already put to death many independent thinkers for ideas contrary to the official Catholic understanding of the universe... Although Pope Urban VIII was sympathetic to him, even the pope could not deter the Inquisition in its persecution of Galileo. The infamous trial took place in February 1633. Under threat of torture, Galileo publicly recanted his heliocentric heresy and was confined for the rest of his days to house arrest in his villa at Arcetri, outside Florence. Galileo’s trial, more than any other event in history, has come to symbolize the sharp split between science and faith, a conflict that continues to rage in our own time as science still continue to debunk irrational and illogic beliefs from various religions.\n\n\tWe will briefly turn our attention to the movements of the planets in ideal and situations simplified in the point of view on an observer on Earth. We consider that all the movements will be in the same plane (coplanar) perfectly circular and constant...\n\n\t\\textbf{Definition (\\#\\mydef):} The planets that are closer to the Sun than the Earth (whose radius is less than one astronomical unit AU\\footnote{defined as an average of $149,597,870,700$ [m] ((about $150$ million kilometres). In ISO 80000-3, the symbol of the astronomical unit is \"ua\".}), that is to say the planets Mercury and Venus are \"\\NewTerm{inferior planets}\\index{inferior planets}\", the other planets (Mars and beyond) are named the \"\\NewTerm{outer planets}\\index{outer planets}\".\n\t\n\t\\subsubsection{Synodic and Sidereal period}\n\tOne of the many tools used in Astronomy are the formulas used to determine Orbital Motion. There are two basic forms of orbit periods:\n\t\\begin{itemize}\n\t\t\\item Sidereal Period\n\t\t\\item Synodic Period\n\t\\end{itemize}\n\tA \"\\NewTerm{sidereal period}\\index{sidereal period}\" is an actual measure of a complete orbit relative to the stars (since the stars are unmoving - or at least moving very slowly). A \"\\NewTerm{synodic period}\\index{synodic period}\" is a rotation of a planet so that it appears to be in the same place in the night sky.\n\t\n\tThe synodic period of a planet (or satellite )is the time needed by this planet to return to the same configuration Earth-Planet-Sun (if we consider this particular case), that is to say in the same place in the sky relatively to the Sun, as seen from Earth. This period differs from the sidereal rotation period of the planet because the Earth itself moves around the Sun. Accordingly, it is the period of apparent revolution, the duration between two conjunctions Planet-Sun as viewed from Earth.\n\n\tThe term generally refers to the time between two identical aspects of the object (opposition, conjunction, etc.) and thus depends on the three bodies involved.\n\t\n\tTo mathematically study the problem in question, let us consider the following diagram with two planets describing a perfectly circular orbit at a constant angular velocity and in the same plane and in the same direction and where we have $\\omega_1>\\omega_2$ (thus the inner planet is faster than the outer planet):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/synodic_period_schema.jpg}\t\n\t\t\\caption{Basic scheme for determining the synodical period}\n\t\\end{figure}\n\twhere $P_1$ and $P_2$ are two planets which we will denote the respective sidereal  periods by $T_1$, $T_2$ and for which we deduce the angular velocities:\n\t\n\tIf we take as zero time, the time when the two planets are both aligned with the $X$ axis and at the same side of this axis (so in \"inferior conjunction\"), then the angle between this axis and each of the planets is:\n\t\n\tWe have respectively:\n\t\n\tWe seek therefore all the instants $t$ where the following relation is satisfied for a fixed $\\alpha_{12}$:\n\t\n\tTherefore it comes:\n\t\n\tIf we look from time zero the first (next) conjunction (\"superior conjunction\"), this is equivalent to put that $\\alpha_{12}=\\pi$ and therefore that:\n\t\n\tIf we look from time zero the first (next) conjunction (\"inferior conjunction\"),  this is equivalent to put that $\\alpha_{12}=2\\pi$ and therefore that:\n\t\n\tIn the case where $\\omega_2>\\omega_1$ (typically Earth and one of its outer planets), the same reasoning leads us to:\n\t\n\tHere are some periods synodic and sidereal planets of the solar system relatively to Earth:\n\t\\begin{table}[H]\n\t\\begin{center}\n\t\t\\definecolor{gris}{gray}{0.85}\n\t\t\t\\begin{tabular}{|c|c|c|}\n\t\t\t\t\\hline\n\t\t\t\t\\multicolumn{1}{c}{\\cellcolor{black!30}\\textbf{Planet}} & \n\\multicolumn{1}{c}{\\cellcolor{black!30}\\textbf{Synodic period [d]}} & \n\\multicolumn{1}{c}{\\cellcolor{black!30}\\textbf{Sidelar period [d]}}  \\\\ \\hline\n\t\tMercury & $115.878$ & $87.969$\\\\ \\hline\n\t\tVenus & $583.921$ & $224.709$\\\\ \\hline\n\t\tMarch & $779.964$ & $686.960$\\\\ \\hline\n\t\tJupiter & $398.861$ & $4,335.355$\\\\ \\hline\n\t\tSaturn & $378.094$ & $10,757.737$\\\\ \\hline\n\t\tUranus & $369.654$ & $30,708.160$\\\\ \\hline\n\t\tNeptune & $367.486$ & $60,224.904$\\\\ \\hline\n\t\\end{tabular}\n\t\\end{center}\n\t\\caption{Various synodic and sidereal periods}\n\t\\end{table}\t\n\tAs we can see from this table, we can make some of empirical observations:\n\t\\begin{enumerate}\n\t\t\\item For the inner planets: The closer we get to the Sun, the more the synodical period is short, indeed in the proved relation above, the more $T_1$ is small more $T$ decreases. So if there was a rotating planet very near the Sun, both sidereal and synodic periods are substantially equal.\n\n\t\t\\item When we approach the Earth, the period increases. If there was a planet near to Earth, we would then have $T_1$ value close to $T_2$ value and the synodical period would be very large.\n\n\t\t\\item For the outer planets: The synodic period decreases when the planet is farther from the Earth and approaches terrestrial sidereal period of $365$ days. We see well for Neptune, if we discovered a planet even further its synodic period would approach even more the $365$ days.\n\t\\end{enumerate}\n\t\n\t\\pagebreak\n\t\\subsubsection{Planet's apparent retrograde motion}\n\tThe \"\\NewTerm{retrograde motion}\\index{retrograde motion}\" of a planet is an apparent motion of this planet which gives the impression that it stop in his path in the \"direct movement\" to start reversing. This phenomenon is the result of the difference between the revolution speed of the planet and the Earth around the Sun.\n\n\tThe example below shows roughly what a terrestrial observer (yellow dot) can be observed by monitoring month after month, the apparent motion of Mars (cyan point):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/retrograde_motion.jpg}\t\n\t\t\\caption[Retrograde motion principle]{Retrograde motion principle (source: Wikipedia)}\n\t\\end{figure}\n\tOr more explicitly:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/retrograde_motion_mars.jpg}\t\n\t\t\\caption[Apparent retrograde motion of Mars in 2003 as seen from Earth]{Apparent retrograde motion of Mars in 2003 as seen from Earth (source: Wikipedia, author: Eugene Alvin Villar)}\n\t\\end{figure}\n\tTo study this phenomenon mathematically, we will consider the following figure:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/retrograde_motion_study_figure.jpg}\t\n\t\t\\caption{Basic scheme for the study of planet's retrograde motion}\n\t\\end{figure}\n\twith two planets describing a perfectly circular orbit at a constant angular velocity and in the same plane and in the same direction and where we have. It is clear that the inner planet will therefore caught up the outer planet and it will seem to have a retrograde motion as shown in the figure below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/retrograde_motion_explicative_sheme_for_time_zero_choice.jpg}\t\n\t\t\\caption[]{Figure to illustrate the choice of zero time}\n\t\\end{figure}\n\tAs the reader can check it in the figure above we see that the retrograde motion with respect to the fixed stars begins when the angle between the two planets is zero and it ends when the angle between the two planets pass through a maximum.\n\n\tTherefore, in the prior previous figure, we have:\n\t\n\tSo to know the time between when the moment where the angle is zero between the two planets, reaches a maximum and decreases again, we simply need determine when occurs the sign of change in the previous function. To do this we just search when the derivative is zero:\n\t\n\tBy applying the derivation rules seen in the section of Differential and Integral Calculus:\n\t\n\tHence after simplification:\n\t\n\tWe develop all this:\n\t\n\tand we simplify a first time:\n\t\n\tand second:\n\t\n\tand finally a third one:\n\t\n\tand after rearrangement:\n\t\n\tWe simplify using trigonometric identities proved in the section  Trigonometry:\n\t\n\tThe values of $t$ that satisfy this relation gives us the sign change we were looking for.\n\n\tIf $t_0$ is the first value of $t$ that satisfies the equation, we have:\n\t\n\tThe next value of $t$ will be such that:\n\t\n\tand therefore:\n\t\n\tIf we introduce the rotation periods, we have:\n\t\n\tTo come back to:\n\t\n\tit may be more convenient to write it in the traditional following form:\n\t\n\tSo far, we have only do geometry. No law of gravitation intervened in the calculations. As the radius are unknown or little known (at least historically), we will use the Kepler's third law (periods law) that is for recall:\n\t\n\twhere for recall $D$ is the semi-major axis of the orbit, and if it is circular, it becomes a simple radius. So we have:\t\n\t\n\tTherefore:\n\t\n\thence:\n\t\n\tA numerical application with for Mercury $T_1\\cong 87.95$ [d] and for Earth $T_2\\cong 365.25$ [d] the value:\n\t\n\tValue we have represented in the diagram below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/retrograde_motion_first_value.jpg}\t\n\t\\end{figure}\n\tand therefore:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/retrograde_motion_second_value.jpg}\t\n\t\\end{figure}\n\tand therefore we have:\n\t\n\tthen a new cycle:\n\t\n\tetc. What gives in schematic form:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/retrogradiation_cycle_diagram_principle.jpg}\n\t\t\\caption[]{Retrogradiation cycle diagram principle}\t\n\t\\end{figure}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAt specific points on Mercury's surface, an observer would be able to see the Sun rise part way, then reverse and set before rising again, all within the same Mercurian day. This apparent retrograde motion of the Sun occurs because, from approximately four Earth days before perihelion until approximately four Earth days after it, Mercury's angular orbital speed exceeds its angular rotational velocity. Mercury's elliptical orbit is farther from circular than that of any other planet in the Solar System, resulting in a substantially higher orbital speed near perihelion.\n\t\\end{tcolorbox}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.45]{img/cosmology/retrograde_motion_mars_saturn.jpg}\n\t\t\\caption[Real sequence of exposures showing Mars and Saturn retrograde motion]{Real sequence of exposures showing Mars and Saturn retrograde motion (author: Tunç Tezel)}\n\t\\end{figure}\n\t\n\t\\pagebreak\n\t\\subsection{Lagrange Points}\n\tA \"\\NewTerm{Lagrange point}\\index{Lagrange point}\" (denoted by L), or \"\\NewTerm{libration point}\\index{libration point}\" is a position in space where the gravitational fields of two bodies in orbit around each other, and of substantial masses, combine to provide an equilibrium point to a third body of negligible mass, such that the relative positions of three bodies are fixed.\n\n\tWe will in the developments that follow take time prove at best that such points are at the number of $5$ rated L1 to L5 respectively.\n\n\tIt may be helpful to make a presentation of these points and their properties before going through the mathematical part. This may help in understanding the subject.\n\n\tWe will immediately consider the following diagram:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points.jpg}\n\t\t\\caption[]{Representation of the five Lagrangian point in the Sun-Earth system}\t\n\t\\end{figure}\n\tThere are five Lagrange points:\n\t\\begin{enumerate}\n\t\t\\item[L1:] On the line defined by the both masses between them (this is the most easy point to interpret intuitively: it is for example the point where the gravitational attraction of the Sun is compensated by that of the Earth).\n\n\t\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\t\tWe consider an object orbiting around the Sun, closer to the latter than the Earth but on the same line. This object undergoes a solar gravity greater than that of Earth, and therefore spins faster around the Sun than does the Earth. But Earth's gravity partially counteracts that of the Sun, which slows it down. The more we approaches this object of the Earth the more this counteract effect is important. At some point, the point L1, the angular speed of the object becomes exactly equal to that of the Earth.\n\t\t\\end{tcolorbox}\n\t\t\n\n\t\t\\item[L2:] On the line defined by the both masses, beyond the smaller (a bit less intuitive as is the point where the cumulative effect of the Sun and Earth will compensate the centrifugal force).\n\n\t\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\t\tThe principle is similar to the previous case, but on the other side of the Earth. The object should rotate more slowly than Earth because the solar gravity is lower, but the extra gravitational field due to the Earth tends to accelerate it. At some point, the point L2, the object rotates at exactly the same angular velocity as the Earth around the Sun.\n\t\t\\end{tcolorbox}\n\t\t\n\t\t\\item[L3:] On the line defined by the two masses, beyond the larger (intuitive based on physical considerations: it is clear that an object diametrically opposite to the Earth relatively to the Sun would have the same orbital period as the Earth and therefore would be fixed relative to the Earth-Sun system).\n\n\t\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\t\tIdentically to the L2 point, there exists a point a little further away than the Earth relatively the Sun, where a negligible mass object would be in equilibrium.\n\t\t\\end{tcolorbox}\n\t\t\n\n\t\t\\item[L4 \\& L5:] On the apexes of two equilateral triangles whose base is formed by the two masses.\n\t\t\n\t\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\t\tThis is a subtle balance between the centripetal force exerted by the two main masses and the centrifugal force of the masses considered at the points of interest. L4 is ahead of the smaller mass in its orbit around the large one, and L5 is late. These two points are sometimes named \"\\NewTerm{triangular Lagrange points}\\index{triangular Lagrange points}\" or \"\\NewTerm{Trojans point}\\index{Trojans point}\".\\\\\n\n\tRemarkably, the last two points do not depend on the relative masses of the two bodies as we will prove it.\n\t\t\\end{tcolorbox}\n\n\t\\end{enumerate}\n\tFor the first three Lagrangian points, stability appears only in the plane perpendicular to the line occupied by the two masses. For example, for the L1 point, if we move an object perpendicular to the line between the two masses, the two gravitational forces will play to bring it back to the starting position. The equilibrium is stable. However, if we move it near to one the two masses, then the field of that latter will prevail over the other and the object will tend to get closer. The equilibrium is unstable. For L4 and L5 points, stability is obtained due to Coriolis forces acting on the objects moving away from the point.\n\t\n\tGiven the stability issues given above, we have no natural object around point L1, L2 and L3 at least in the solar system. However, they still represent an interest in scientific achievements because they allow savings of fuel for orbit control and attitude. This is not valid for point L3, due to its distance from Earth which only application what that utopic one made by Sci-Fi and comic books authors that place an Anti-Earth twin-planet but which mass was too high in relation to the theory stated above. However, space missions use L1 and L2: the case of the probe SOHO since 1995 (Solar and Heliospheric Observatory) a Sun observation station located at L1 (1.5 million kilometres from Earth) or MAP (Wilkinson Microwave Anisotropy Probe) satellite or Planck satellite (to study the cosmic microwave background at $2.7$ [K]) close to the point L2 as will be the James Webb telescope in 2021 (the radiation of Earth there are relatively low and those of the Sun attenuated by the Earth which do a screening effect).\n\t\n\tThe points L4 and L5 being stable, we find many natural celestial objects. In the Sun-Jupiter system, hundreds of asteroids, known as \"Trojan asteroids\", clump there together (around $1,800$ identified in April 2005). We count also  some in the Neptune-Sun systems and Mars-Sun system. Curiously, it seems that the Saturn-Sun system is not be able to accumulate such celestial objects because of the Jovian disruption. We also find objects to these points in the Saturn planetary system of Saturn: Saturn-Tethys with Telesto and Calypso with the L4 and L5 points and Saturn-Dione with Helen to the point L4 and Pollux at the L5 point. In the Sun-Earth system, there is no known large object to the Trojans points, but it was discovered a slight over-abundance of dust in 1950. Slight dust clouds are also present for the system Earth-Moon; this make scientific abandon the idea to place there a space telescope as it was envisaged once.\n\t\n\tStrictly speaking, these 5 points exist only for two bodies in circular rotation one around the other. Once the orbit of the two bodies is elliptical, these points are no longer equilibrium points. In practice, if the orbit is slightly elliptical, as is the case for real planets, we can find stable orbits oscillating not departing too much of the regions corresponding to the Lagrangian points and this is well named a \"\\NewTerm{halo orbit}\\index{halo orbit}\". So halo orbit is a periodic, three-dimensional orbit near the L1, L2 or L3 Lagrange points in the three-body problem of orbital mechanics. Although the Lagrange point is just a point in empty space, its peculiar characteristic is that it can be orbited. The first mission to use a halo orbit was ISEE-3, launched in 1978. It travelled as we already mention to the Sun–Earth L1 point and remained there for several years. The next mission to use a halo orbit was in fact Solar and Heliospheric Observatory (SOHO), a joint ESA and NASA mission to study the Sun, which arrived at Sun–Earth L1 in 1996. It used an orbit similar to ISEE-3.\n\t\n\tSo we will consider in space an isolated system of two bodies $A$ and $B$, of mass $M_A$ and $M_B$ in gravitational interaction. These two bodies are assumed to be in circular orbit (for simplicity!) one around the other, in the manner of a two-star system (binary system) or a planet-satellite like system (Saturn-Titan example). We seek to determine if there are relative equilibrium point to the system of the two rotating body for  a third body also in circular motion in the same plane (of sufficiently low mass to avoid disturbing the motion of the system of the two main bodies).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points_configuraton_study.jpg}\t\n\t\\end{figure}\n\tLet O be the centroid (\\SeeChapter{see section Classical Mechanics page \\pageref{center of mass}}) of these two stars (or celestial objects in general). Let us consider a Galilean reference frame (in rectilinear and uniform motion therefore !) or origin O. Compared to this reference frame, we assume that the axis $AB$ rotates at a constant angular velocity $\\omega$ of fixed axis $\\vec{k}$ (perpendicular to the page in the figure and directed towards the reader) and that the distances $r_A=\\overline{A\\text{O}}$ and $r_B=\\overline{B\\text{O}}$ also remain constant.\n \n We know from our study of Classical Mechanics that a circular motion the centrifugal force is given by:\n\t\n\tSo we have (equilibrium between centrifugal and centripetal forces) to guarantee the equilibrium:\n\t\n\tBy simplifying and summing these two relations:\n\tBy simplifying and summing these two relations:\n\t\n\twith in what will follow $AB=r_A+r_B=R$.\n\t\n\tLet us consider a rotating reference frame $R'$ linked to our stars as shown in figure above: $\\vec{i}$ will be a collinear unit vector to $AB$, $\\vec{j}$ a unit vector perpendicular to $\\vec{i}$ and in the rotating plane of the planets and finally $\\vec{k}=\\vec{i}\\times\\vec{j}$ co-linear to $\\vec{\\omega}$.\n\n\tWe consider in this rotating frame (with stars) a third star $S$ of mass $m$ negligible relatively to $M_A$ and $M_B$, subject to the gravitational attraction of $A$ and $B$.\n\n\tNow let us denote by $\\vec{a}_{R'}$ the acceleration of $S$ with respect to $R'$, $\\vec{v}_{R'}$ its speed and $\\vec{e}_r$ the collinear  unit vector to $\\overrightarrow{\\text{O}S'}$ where $S'$ is the projection of $S$ in the plane O$xy$, and $r=\\overline{\\text{O}S'}$ (in the figure above, we assumed $S$ in the plane O$xy$, so $S$ and $S'$ are indistinguishable).\n\t\n\t$S$ is thus subjected to two forces, one $\\vec{F}_A$ directed along $A$ and the other $\\vec{F}_B$ directed along $B$, forces of respective intensities :\n\t\n\tIn a Galilean reference frame, these two forces apply to $S$ an acceleration given by the law of composition of accelerations in a circular reference frame (\\SeeChapter{see section Classical Mechanics page \\pageref{relative movements and inertial forces}}):\n\t\n\tBut, in our configuration the pulsation (radial velocity) is assumed constant and the drive acceleration is zero since we assumed $R'$ as the main repository. Therefore it comes:\n\t\n\tWe also have:\n\t\n\twhere according to the figure all components are positive. The calculation of the cross product then gives (\\SeeChapter{see section Vector Calculus page \\pageref{cross product}}):\n\t\n\tSo finally:\n\t\n\tLet us rather write this relationship into the form:\n\t\n\tWe then obtain, by projecting on the three axes $x$, $y$ and $z$, the derivatives taken with respect to time $t$ the following system:\n\t\n\twith:\n\t\n\tso that the coordinates $(x,y,z)$ of the point $S$ are those of an equilibrium point, then it is trivial that in the rotating frame with the stars $A$ and $B$ that:\n\t\n\tWe then get the following system:\n\t\n\tIt is also immediately that the third equation has for only solution $z=0$ and thus ultimately the system reduces to:\n\t\n\tThe third equation simply means that the equilibrium positions are in the plane O$xy$ (we could suspect it a bit ...). The other two, we will see it later, lead us to consider five solutions that are our five Lagrangian points L1, ..., L5.\n\n\tIf we draw plot with an appropriate software the acceleration (respectively force) with the isoclines highlighted (curves on which the acceleration is equal) we get:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points_two_bodies_isoclines_plot_3d.jpg}\t\n\t\t\\caption{Isoclines of the two-body system}\n\t\\end{figure}\n\twhere we see that a short distance of the bodies the gravitational potential energy dominates, but that a large distances the centrifugal potential predominates and the shape of the surface is similar to that of a paraboloid.\n\n\tBy requesting the software to plot only the isoclines projected on a plane we get:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points_two_bodies_isoclines_plot_2d.jpg}\t\n\t\t\\caption{Projected isoclines of the two body system on a plane}\n\t\\end{figure}\n\twhere we have highlighted the five Lagrange points and where the stars (or celestial objects) are represented by blue dots and the centroid of the system by a green dot. It seems that isoclines are named in the astronomy field \"\\NewTerm{Roche equipotentials lobes}\\index{Roche equipotentials lobes}\". Otherwise seen:\n\t\\begin{figure}[H]\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points_two_bodies_isoclines_plot_2d.jpg}\t\n\t\t\\caption[]{Projected isoclines of the two body system on a plane}\n\t\\end{figure}\n\twhere we have highlighted the five Lagrange points and where the stars (or celestial objects) are represented by blue dots and the centroid of the system by a green dot. It seems that isoclines are named in the astronomy field \"\\NewTerm{Roche equipotentials lobes}\". Otherwise seen:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lagrange_points_two_bodies_isoclines_plot_2d_and_3d.jpg}\t\n\t\t\\caption[]{Projected isoclines of the two body system on a plane}\n\t\\end{figure}\n\tFor those wishing to reproduce these figures with MATLAB™ here is how first proceed mathematically. From what we got previously, we have explicitly and in writing in a more academic form, the following relation:\n\t\n\tAs the point $S$ is supposedly in equilibrium the last term vanishes (its speeds are zero in the rotating frame!). It then remains:\n\t\n\tWe have proved for recall in the section of Classical Mechanics that:\n\t\n\tThen we have:\n\t\n\tThus taken by unit mass of the satellite:\n\t\n\tThe application of this relations in MATLAB™ 2013a then gives (sorry it's a bit long and its probably possible to do better ...):\n\t\\begin{lstlisting}[language=MATLAB]\n\t\t%We build the grid plot that we will by anticipation densifiate where are the objects of interest\n\t\tx1=linspace(-7E8,-8E5,150);\n\t\tx2=linspace(8E5,1.2E8,150);\n\t\tx3=linspace(1.6E8,7E8,150);\n\t\tx=x1+x2+x3;\n\t\ty=linspace(-7E8,7E8,450);\n\t\t[X,Y]=meshgrid(x,y);\n\t\t%These masses and G are real but the rest is fictitious so that the plot is readable \n\t\tf=@(x,y) -(1.3346E20)./(sqrt((x-450).^2+y.^2))-(1.0038E19)./(sqrt((x-449999550).^2+y.^2))-(6.9E-7.*(x.^2+y.^2));\n\t\tz=f(X,Y);\n\t\t%We eliminate the values that are too big on Z to have an esthetical result to see\n\t\tfor i=1:450;\n\t\t   for j=1:150;\n\t\t      if (z(i,j)<-0.8E12) %to do with meshc a nice plot, limit to  -8E11\n\t\t         z(i,j)=-0.8E12;\n\t\t      end; \n\t\t   end; \n\t\tend; \n\t\tcontour(X,Y,z,100); mesh(X,Y,z); meshc(X,Y,z); \n\t\taz = 100; el = 25; view(az, el);\n\t\taxis([-7E8 7E8 -0.8E9 0.8E9 -8E11 -4E11]);\n\t\tcolorbar; light; camlight('right');\n\t\\end{lstlisting}\n\tThat gives:\n\t\\begin{figure}[H]\n\t\t\\includegraphics[scale=0.8]{img/cosmology/lagrange_points_two_bodies_3d_matlab.jpg}\n\t\t\\caption{Lagrange plot and isoclines with MATLAB™ 2013a}\n\t\\end{figure}\n\tThe reader will notice that it is difficult to intuitively this configuration of the potential. In the rotating frame with the centroid of the two solid bodies, the potential resulting from the combination of rotational and gravitational potentials present 3 extrema L1, L2 and L3 on the right containing the both bodies. One of these maxima is between the two bodies as expected intuitively. The other two maxima are on the line connecting the two objects, but both on either side... which is more surprising. They come from the contribution to the potential of the rotating frame which can be difficult to model intuitively.\n\t\n\t\\subsubsection{Equilibrium points of the first type}\n\tWhat we mean by equilibrium positions of the first type are simply solutions located on the line $\\overline{AB}$ such that $y=0$ which is equivalent to study only:\n\t\n\twith therefore:\n\t\n\tTo this situation, we will consider three possible corresponding sub-cases respectively L1, L2 and L3 as we will immediately see it.\n\t\n\t\\paragraph{L1 Lagrange point}\\mbox{}\\\\\\\\\\\n\tIn this first sub-case, we consider:\n\t\n\tWhat is also equivalent to have:\n\t\n\tThis allows us to write:\n\t\n\tin the following simplified form:\n\t\n\tNow to be able to say something about the possible solutions to this equation derive the left hand side. We then get:\n\t\n\tThis term is strictly increasing from $-\\infty$ to $+\\infty$ when $x$ describes $]-r_A,r_B[$. So there is a unique solution and equilibrium point denoted L1 (first Lagrange point) between $A$ and $B$.\n\n\tIf we typically consider the Sun-Earth case where $M_A>M_B$ and therefore $r_A<r_B$ then on $x=0$ we have:\n\t\n\twhat is immediately negative. The equilibrium position will be obtained for a positive value of $x$ we will have to determine.\n\n\tThis value can be obtained by considering a limit case: when $M_B$ tends to $0$ (corresponding to a massive celestial object $A$ turning around a mass $B$ of a much much smaller celestial object), then $A$ tends to O, $r_A$ tends to $0$ and therefore:\n\t\n\twith $R=\\overline{AB}$. Therefore, in this limit case:\n\t\n\tbecomes in approximation:\n\t\n\tand therefore:\n\t\n\tSo the only value of $x$ satisfying this relation will be $x=R$.\n\n\tIn other words, the equilibrium point L1 we are looking after here is between $A$ and $B$ moves near $B$, that is near the less massive celestial object (which corresponds well to the first figure that we used to show the location of the five Lagrange points).\n\n\tBy this observation we can make the following calculations: \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/l1_point_configuration_study.jpg}\t\n\t\t\\caption[]{Configuration to mathematically determine the position of point L1}\n\t\\end{figure}\n\tWe have from the definition of center of gravity (\\SeeChapter{see section Classical Mechanics page \\pageref{center of mass}}):\n\t\n\tAs our study is done relatively to the centroid we have $\\vec{r}_G=\\vec{0}$ and therefore:\n\t\n\tFrom the above relation by taking the norm, we have obviously:\n\t\n\tThe distance between the two celestial objects $A$ and $B$ remaining constant and being equal to $r=r_A+r_B$ we write:\n\t\n\tWe deduce trivially two relations (the second being obtained by exactly the same reasoning as the first):\n\t\n\tBut since $M_A \\gg M_B$ we can write roughly the first relation in the following approximate form (Taylor series):\n\t\n\tand since:\n\t\n\twe have also:\n\t\n\tSo with $M_A\\gg M_B$:\n\t\n\tAccording to the limiting case studied previously, we can assume $L$ at the neighbourhood of $B$ such that it is possible to write:\n\t\n\twith $\\varepsilon\\ll 1$.\n\t\n\tEither using:\n\t\n\tThen we have:\n\t\n\tby neglecting the infinitely small therm of order $2$.\n\n\tHence:\n\t\n\tNow in the mentioned  configuration the equilibrium is given by:\n\t\n\tTherefore:\n\t\n\n\tNow the third Kepler's law  gives us:\n\t\n\tTherefore:\n\t\n\tAfter simplification:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tSince $1/\\varepsilon^2$ is much greater than $1$ and assuming that $3M_A/M_B$ then we have also:\n\t\n\tThus finally:\n\t\n\tand therefore:\n\t\n\tIf we take the $A$ for the Sun and $B$ for the Earth, then:\n\t\n\tWe find that the distance $\\overline{LB}$ is then equal approximately to:\n\t\n\twhich is the L1 point where was placed the satellite SOHO (since the latter will thus never  have its field of view obscured by the shadow of the Earth or the Moon).\n\n\tA special case of the L1 point to consider is when $M_A=M_B=M$, then $r_A=r_B=r$, then O is the midpoint of $\\overline{AB}$. Then we have:\n\t\n\tTherefore:\n\t\n\tbecomes:\n\t\n\t\n\t\\paragraph{L2 Lagrange point}\\mbox{}\\\\\\\\\\\n\tIn this second sub-case, we consider:\n\t\n\tTherefore we are looking for the equilibrium points beyond $B$.\n\n\tThus we have:\n\t\n\twhich becomes simply:\n\t\n\tThe left side is a strictly increasing function of $x$ from $-\\infty$ to $+\\infty$ when $x$ describes $[r_B,+\\infty]$. So there is a unique solution, and an equilibrium point beyond $B$. This point is denoted: L2.\n\n\tThis value can be obtained by considering a limit case: when $M_B$ tends to $0$ (corresponding to a massive celestial object on $A$ around which a much smaller mass object $B$ turn around), then $A$ tends to O, $r_A$ to $0$ and therefore:\n\t\n\twith $R=\\overline{AB}$. Therefore, in this limit case:\n\t\n\tbecomes approximately:\n\t\n\tand so:\n\t\n\tSo the only value of $x$ satisfying this relation will be $x=R$. The L2 point therefore ends up being merged with $B$.\n\n\tKnowing this limit case, let us do a more detailed study. Consider the following diagram relatively to our previous limit case:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/l2_point_configuration_study.jpg}\t\n\t\t\\caption[]{Configuration to mathematically determine the position of point L2}\n\t\\end{figure}\n\tand let us consider $M_A\\gg M_B$ without forgetting that in this scenario $x>r_B$.\n\n\tWe then have almost the same developments as for L1 but with the difference that:\n\t\n\tbecomes:\n\t\n\tand that instead of having:\n\t\n\tWe have:\n\t\n\tand therefore:\n\t\n\tStill with:\n\t\n\tand therefore:\n\t\n\twhich corresponds to the Lagrange point L2.\n\n\tA special case again about L2 is when $M_A=M_B=M$, then $r_A=r_B=r$, then O is at the midpoint of $\\overline{AB}$. Then we have:\n\t\n\tTherefore:\n\t\n\tbecomes:\n\t\n\tIt is no longer possible to extract the roots here (at least to my knowledge). It must be done through a numerical approximation. In Maple 4.00b, we simply put:\n\n\t\\texttt{>solve(-1/(r+x)\\string^2-1/(x-r)\\string^2=x/(8*r\\string^3),x);allvalues(\");}\n\t\n\tand the only feasible solution in $\\mathbb{R}$ is then $x\\cong 2.8r$ and the others being in $\\mathbb{C}$.\n\t\n\t\\pagebreak\n\t\\paragraph{L3 Lagrange point}\\mbox{}\\\\\\\\\\\n\tIn this third sub-case, we consider:\n\t\n\tSo we look for the equilibrium points beyond $A$.\n\n\tThus we have:\n\t\n\twhich becomes simply:\n\t\n\tThe left side is an increasing function of $x$ from $-\\infty$ to $+\\infty$ when $x$ describes $]-r_A,-\\infty]$. So there is a unique solution, and one equilibrium point beyond $A$. This point is denoted: L3.\n\n\tThis value can be obtained by considering a limit case: when $M_B$ tends to $0$ (corresponding to a massive celestial object $A$ turning around much smaller object $B$), then $A$ tends to O, $r_A$ to 0 and therefore:\n\t\n\twith $R=\\overline{AB}$. Therefore, in this limit case:\n\t\n\tbecomes approximately:\n\t\n\tand therefore:\n\t\n\tSo the only value of $x$ satisfying this relation will be $x=R$. The point L3 will finish to merge with the position diametrically opposite to that of $B$.\n\n\tKnowing this limit case, let us do a more detailed study now. Consider the following diagram relative to our previous limit situation:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/l3_point_configuration_study.jpg}\t\n\t\t\\caption[]{Configuration to mathematically determine the position of point L3}\n\t\\end{figure}\n\tand let us still consider $M_A \\gg M_B$ without forgetting that in this scenario $x<-r_A$.\n\n\tWe will first consider the following approximation:\n\t\n\tand this one also (since $\\overline{\\text{O}A}$ tends to zero as the celestial object $A$ becomes very massive):\n\t\n\tSince then:\n\t\n\tWe have also (...):\n\t\n\twhen at the limit where the celestial object $A$ is really massive, we fall back on the first term ...\n\n\tWith the last two relations, we have:\n\t\n\tif we neglect the terms of the second order.\n\n\tFurthermore, we have also:\n\t\n\tLet us recall the equilibrium condition:\n\t\n\tAnd let us put everything we got until now inside it:\n\t\n\tWhat becomes after simplifications:\n\t\n\tafter a small approximation:\n\t\n\tafter simplification:\n\t\n\tHence:\n\t\n\tand finally:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tForm some Si-Fi authors, for recall... this point L3 opposite to the Earth relatively to the Sun would hide us a hypothetical planet that we would be forever hidden to us by the Sun.\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Equilibrium points of the second type}\n\tThe equilibrium positions of the second type are those for which $y\\neq 0$. In other words the points outside of the line $\\overline{AB}$, but still in the plane $\\text{O}xy$.\n\n\tThus, our system of equations remains:\n\t\n\t\n\t\\paragraph{L4, L5 Lagrange points}\\mbox{}\\\\\\\\\\\n\tTo determine the remaining equilibrium points, we can divide the second equation of the system such that the system becomes:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/l4_l5_point_configuration_study.jpg}\t\n\t\t\\caption[]{Configuration to mathematically determine the position of points L4,L5}\n\t\\end{figure}\n\twhere $\\overline{AB}$ is obviously the distance between $A$ and $B$ and $D$ is the centroid of the system given by (\\SeeChapter{see section Classical Mechanics page \\pageref{center of mass}}):\n\t\n\twhich are the radii of gyration of the bodies $A$ and $B$.\n\n\tIt is easy to verify that the sum of both previous distances is equal to $\\overline{AB}$ and their proportion $M_B/M_A$. Another form of $\\overline{DB}$ (which will be useful) is obtained by dividing the numerator and denominator by $M_A$:\n\t\n\tWe know according to our previous calculations that $\\overline{AS}=\\overline{BS}$ but this is insufficient. We still want to know the angles of the vertices $A$, $B$, $S$, and this is what we will look for now.\n\n\tIn this context, if a satellite $S$ is in equilibrium, there will always remain at the same distance of $A$ or $B$. The center of rotation of the $3$ points is the point $D$, the mass $A$ itself revolves around it. If the satellite, $S$, remains stable, the three bodies have the same orbital period $T$. If $S$ is immobile in this frame in rotation it will not be subject to the Coriolis force but only to centrifugal force of $A$ and of $B$.\n\t\n\tLet us denote by $v_B$ the rotation speed of $B$ and $v_S$ the rotation speed of $S$. Then we have:\n\t\n\tand:\n\t\n\tFrom whose we get that:\n\t\n\tand:\n\t\n\tSo we can equate these two expressions:\n\t\n\tThis merely expresses the well known fact that if two objects rotate together, the furthest one from the centroid is the fastest. Speeds are proportional to the distances from the centroid.\n\n\tThe centrifugal force on $B$ is in equilibrium with the gravitational force of $A$ and it is expressed by:\n\t\n\tThus by simplifying:\n\t\n\tSimilarly, the centrifugal force applied on $S$ is:\n\t\n\tIt is balanced by the forces of attraction $\\vec{F}_A$,$\\vec{F}_B$ of the objects $A$ and $B$. However, only the components of these forces located on the line $R$ oppose efficiently to this centrifugal force. Hence:\n\t\n\t\n\tand as:\n\t\n\tWe then have:\n\t\n\tIn addition, the forces applied to $S$ and perpendicular to $R$ must vanish. If not, the object $S$ would follow the largest mass and would not remain in position and would therefore no longer be in equilibrium. We must then have:\n\t\n\tOr, after substitution and simplification:\n\t\n\tOf all the equations obtained up to now the only that bother us are those containing both speeds and angles $\\alpha$,$\\beta$. This requires that we must arrive to eliminate what is convenient to have only the last two parameters (that is to say: the angles).\n\n\tFor this, we take the square:\n\t\n\tWe multiply both sides by $\\overline{AB}^2$ and we divide by $1+\\dfrac{M_B}{M_A}$:\n\t\n\twhich is similar to:\n\t\n\tThus equating:\n\t\n\tSo we removed the speed of $B$. Now, let us multiply both sides by $\\left(1+\\dfrac{M_B}{M_A}\\right)R$ and divide by $\\overline{AB}^2$:\n\t\n\twhich is similar to:\n\t\n\tTherefore:\n\t\n\tBy dividing by the whole by $GM_A$ we find:\n\t\n\tAnd as we have proved at the beginning $\\overline{AS}=\\overline{BS}$ that we will denote by $R'$, then we have:\n\t\n\tand let us recall that we have:\n\t\n\tTherefore:\n\t\n\tThis allows us to write:\n\t\n\tAnd multiplying by $\\sin(\\beta)$:\n\tWe can now notice a thing (not easy to see...). If $R'=\\overline{AB}$ (that is that the triangle $ABS$ is equilateral) the previous relations simplifies to:\n\t\n\tBut, if the triangle is really equilateral, then we have (\\SeeChapter{see section Geometric Shapes page \\pageref{lateral triangle}}):\n\t\n\tHence:\n\t\n\tWhat can finally write:\n\t\n\tWhich is just the sine theorem for the triangle $SDB$ (\\SeeChapter{see section Trigonometry page \\pageref{law of sines}}) and is therefore certain. Returning back, we can now prove that all previous equations are satisfied if and only if $ABS$ is equilateral. If we had not put $ABS$ as equilateral, we would have gotten a different relation of the sine theorem, without possible verification, and the set of equations required for equilibrium at the point $S$ could not be met.\n\n\tConclusion of the thing ... the system gives as a solution:\n\t\n\t$ABS$ (or $ABL$ regardless the notation), then forms an equilateral triangle. The two equilibrium points are denoted L4 and L5. L4 is located in advance with respect to the less massive celestial object and L5 is late relatively to it.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/l4_l5_final_point_configuration_study.jpg}\t\n\t\t\\caption[]{L4 and L5 equilateral triangle}\n\t\\end{figure}\n\tIn 2000, $385$ asteroids in the L4 point and $188$ asteroids in the L5 point were counted on the orbit of Jupiter, but located precisely in an equilateral triangle with the Sun and Jupiter either side of Jupiter: these are the Trojan planets. It was also observed two objects at the point $L5$ of Mars discovered in 1990 and 1998.\n\t\n\t\\pagebreak\n\t\\subsection{Relativistic Doppler-Fizeau Effect}\n\tThe Doppler effect is the difference between the frequency of the transmitted wave and the received wave when the transmitter and receiver are moving relative to each other (\\SeeChapter{see section Music Mathematics page \\pageref{acoustic doppler effect}}). This is an effect that must be take into account astronomy to calculate the distance of the body assuming its known (or estimated)  emission wavelength and measuring its received wavelength or for measuring the speed of rotation (radial velocity) of stars by observing very precisely and successively their opposite edges and measuring the shift of the spectrum obtained.\n\n\tIn the early 21st century the precision and finesse of the spectra of measures has reached a level that allows to observe even minimal changes in the distance of stars and so speculate on possible planetary satellites (this may work if the plane of the orbit passes through the Earth):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/doppler_effect_radial_velocity.jpg}\n\t\t\\caption[Doppler-Effect radial velocity method]{Doppler-Effect radial velocity method (source: ESO Press Photo 22e/05 2007-04-11)}\n\t\\end{figure}\n\tThe Doppler effect of electromagnetic waves must be discussed independently of the acoustic Doppler effect (also named \"Galilean Doppler effect\") study in the section of Music Mathematics. First, because the electromagnetic waves do not consist of a material movement and therefore the speed of the source relative to the medium does not enter into the discussion, then because their velocity is $c$ (the speed of light) and remains the same for all observers independently of their relative movements. The Doppler effect for electromagnetic waves is thus calculated necessarily using the principle of relativity and is symmetrical with respect to relative movement of the source and the observer (as opposed to acoustic cases).\n\t\n\tFor an observer in an inertial reference frame, a plane and harmonic electromagnetic wave can be described by a function of the form:\n\t\n\tmultiplied by an appropriate amplitude factor. For an observer attached to another inertial frame, the components $x$ and $t$ should be replaced with $x'$ and $t'$, obtained by the Lorentz transformation (\\SeeChapter{see section Special Relativity page \\pageref{lorentz transformations}}), and that latter will therefore write to describing plane wave:\n\t\n\twhere $k'$ and $\\omega'$ are not necessarily the same as that of the another observer (precisely this is what we want to determine). Moreover, the principle of relativity has allowed us to demonstrate in the section of Special Relativity that:\n\t\n\tThis assumes that the expression:\n\t\n\tremains invariant when we move from one inertial observer to the other. We then have:\n\t\n\tUsing the Lorentz transformation relations (\\SeeChapter{see section Special Relativity page \\pageref{lorentz transformations}}), we have immediately:\n\t\n\tHence:\n\t\n\tGrouping we get:\n\t\n\tBy identification, it comes immediately:\n\t\n\tIf we consider that:\n\t\n\tin the case of electromagnetic waves, we can write each of these relation in the form:\n\t\n\tThe ratio visible in the both expression above is named the \"\\NewTerm{radial relativistic doppler redshift}\\index{redshift!radial relativistic doppler redshift}\" and is denoted by:\n\t\n\tfor a movement of the observer relative to the source in the direction of propagation (the range of this function is bounded $[0,1]$. In the other case (opposite direction) we have obviously:\n\t\n\tThat is unbounded and has for range $[1,+\\infty[$. Physicists like to normalized stuffs so that the range is $[0,+\\infty[$, so we write and define the \"\\NewTerm{relativistic doppler redshift}\" for opposite direction as:\n\t\n\tOr more commonly written as:\n\t\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.19]{img/cosmology/hubble_deep_space_redshift.jpg}\n\t\t\\caption[High-redshift galaxy candidates in the Hubble Ultra Deep Field 2012]{High-redshift galaxy candidates in the Hubble Ultra Deep Field 2012 (source: NASA, ESA, R. Ellis (Caltech), and the HUDF Team)}\n\t\\end{figure}\n\tObviously if the source or observer don't move away but approach then we not have a red shift but a \"\\NewTerm{blueshift}\\index{blueshift}\".\n\t\n\tFurthermore, the last relation with the pulsations is most often written in the literature as follows:\n\t\n\tWhich is written most often in the following form (keep in mind that this is in the case when the two referential move in opposite direction!):\n\t\n\tTherefore if we measure the both frequencies (supposing that we know what should be the source), then we can also obviously determine the speed $v$ of the observed object.\n\t\n\tOr in case of wavelength we have similarly:\n\t\n\t\n\tWhen a spectrum can be obtained, determining the red shift is rather straight-forward: if you can localize the spectral fingerprint of a common element, such as hydrogen, then the red shift can be computed using simple arithmetic. But similarly to the case of Star/Quasar classification, the task becomes much more difficult when only photometric observations are available:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/red_shift_spectrum.jpg}\n\t\\end{figure}\n\tIt must be recalled that the pulsation offset (and therefore frequency offset) that takes place here is due to a relative motion of the observer with respect to the source and not to something else (or respectively of the source relatively to the observer). Indeed, in our study of General Relativity (\\SeeChapter{see section General Relativity page \\pageref{shapiro effect}}), we will prove that there is a superposition of a shift because of the gravitational field surrounding the emitter that will be considered as caused by the space-time curvature.\n\n\tFinally, for sceptics who want to check in another way that the Doppler phenomenon is well symmetric unlike the acoustic Doppler effect proved in the section of Music Mathematics, here's another approach:\n\n\tFirst, consider that it is the source moving away. If we calculated by the classical relation proved in the section of Music Mathematics the frequency of the signal at the reception would be:\n\t\n\tand we must take into account the time dilation for $f$ with (\\SeeChapter{see section Special Relativity page \\pageref{relativistic time variation}}):\n\t\n\tbecause the time interval of the fixed observer is longer than that of the source (time is faster for observer at rest).\n\n\tIt comes then:\n\t\n\tand if it is the observer who moves away from the source we proved in the section of Music Mathematics that:\n\t\n\tboth relationships are indeed symmetric in the special relativistic case (as expected for electrodynamics)!\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tCurrently, astronomers have courses in astrophysics and their observations are generally studied in an astrophysical context, so there is less distinction between the two disciplines than before.\n\t\\end{tcolorbox}\n\tA very good example of the application of the Doppler effect is to explore the limits given by measuring the apparent speed. Let's see what it is:\n\t\n\t\\subsubsection{Apparent speed}\n\tBy measuring the apparent speed of movement of very fast objects in the sky (plasma jets, etc.), astrophysicists have obtained apparent displacement speeds exceeding the speed of light in vacuum!\n\n\tIn fact, it is an illusion that can occur if the speed of the object is very close to that of light it emits, so close enough to $c$.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/apparent_speed.jpg}\n\t\t\\caption{Schematic idea behind the apparent speed}\n\t\\end{figure}\n\tThe object emits light at time $t_0$, it does not instantly reach us but must travel a distance to get to us. We get it after the time:\n\t\n\tThe object itself, moves with velocity $v$ at an angle $\\theta$ with the viewing direction, so at time $t$, the object moved of a distance $vt$. The light emitted by the object at time $t$ must travel the distance (application of Pythagoras theorem)\n\t\n\tto reach us (the object has move of a distance $vt\\cos(\\theta)$ in the direction of observation but moved away from the axis of observation of the distance $vt\\sin(\\theta)$), so we receive light that was emitted by the object at time $t$ after a time $t_2$:\n\t\n\tBetween the two positions of the object, it has elapsed the time $t$ but, viewed from the observer, the time interval between the reception of images of these two positions is:\n\t\n\tdifferent from $t$!\n\t\n\tFor a small time interval $t$, we have, by doing a limited Taylor development:\n\t\n\tDuring this time interval, always from the point of view of the observer, the object appears to have moved on the sky plane by a distance of $vt\\sin(\\theta)$.\n\n\tThus, the apparent speed of the object is:\n\t\n\tIf we set the angle $\\theta$ as being very close to a right angle, then we have the second term of the denominator that is very small which allows us with a Taylor expansion to write a relation that can be found quit often in high-school textbooks :\n\t\n\tLet us seek the maximum of this function to understand how such observation is possible by deriving relatively to $\\theta$ and by seeking for what value the derivative is zero:\n\t\n\tand this vanishes after simplification of the denominator for:\n\t\n\tHence:\n\t\n\tThe apparent velocity is then:\n\t\n\tand is equal to or greater than $c$ if:\n\t\n\tTherefore:\n\t\n\tThus we see that it is possible to observe apparent movements faster than light, even though the subject is very fast indeed, but slower than $c$. As it is only an \"illusion\", there is no contradiction with the theory of relativity.\n\n\tKnowing the speed of movement of a celestial object obtained using the Doppler effect and the apparent speed with the observations, it is easy for astrophysicists to determine the angle  $\\theta$ by doing a little bit elementary algebra from the following relation:\n\t\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{80} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 47 votes,  64.68\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\t\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Astrophysics}\\label{astrophysics}\n\t\\lettrine[lines=4]{\\color{BrickRed}A}strophysics is an interdisciplinary branch of astronomy which mainly concerns physics and the study of the properties of objects in the Universe (stars, planets, galaxies, interstellar medium for examples) as their luminosity, density, temperature and their chemical composition. The first scientific approaches in this area date from the early 19th century.\n\t\n\t\\begin{fquote}[Carl Sagan]We have uncovered wonders undreamt by our ancestors who first speculated on the nature of those wondering lights in the night sky. We've crossed the solar system and sent ships to the stars. But we continue to search. We can't help it! A central element of the human future, lies far beyond the Earth. If we crave some cosmic purpose, then let us find ourselves a worthy goal...\n \t\\end{fquote}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tCurrently, astronomers have courses in astrophysics and their observations are generally studied in an astrophysical context, so there is less distinction between the two disciplines than before.\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Stars}\n\tBefore addressing the mathematical formalism on the dynamics of stars, we wanted following readers requests, write a small popularized introduction to complete the general knowledge on this field.\n\t\n\tThe stars are gaseous celestial body whose mass goes from $0.05$ solar mass to more than $100$ solar masses. The brightness of a star (its power radiation) ranges from $10^{-6}$ to $10^6$ times that of the Sun. Roughly, when the mass doubles, brightness is multiplied by. Most of the stars visible to the naked eye in our skies are blue giants of $10^4$-$10^5$ times more luminous than the Sun; they represent only $10\\%$ of stars that inhabit our galaxy, the remaining $90\\%$ being less luminous than the Sun.\n\t\n\tThe Astronomers (of Harvard between 1918-1928) have developed a method of classification of stars based on their position in the spectrum, of the spectral absorption lines (spectroscopy). Formerly classified from A to Q, the evolution of the spectrometry allowed their grouping and organization. Classes are now defined by the letters OBAFGKM, and each is divided into $10$ subclasses, rated from $0$ to $9$. The spectral classification (taken from a continuous spectrum which summarizes only certain lines of the spectrum after passing of light in a given medium) can be crossed with the lighting classes so that we can infer the temperature at the surface of the star\\label{hertzsprung russell diagram}\\index{Hertzsprung-Russell diagram} (we will prove later how to get this information):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.76]{img/cosmology/hertzprung_russel_diagram.jpg}\n\t\t\\caption[Hertzsprung-Russel Diagram example]{Hertzsprung-Russel Diagram example (source: Wikipedia)}\n\t\\end{figure}\n\tAnd the corresponding hypothesized path evolution of our Sun on this same diagram:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.59]{img/cosmology/hertzprung_russel_diagram_sunpath.jpg}\t\n\t\t\\caption{Sun path on Hertzsprung-Russel}\n\t\\end{figure}\n\tWhere the colors and temperature association are based \"obviously\" on the color of a black-body as experimental measurements show that stars behaves almost the same as a perfect black-body\\footnote{This is also why some LED brands have the color given as a temperature} (\\SeeChapter{see section Statistical Mechanics page \\pageref{black body}}).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{img/cosmology/black_body_colors.jpg}\n\t\\end{figure}\n\n\tAs it evolves, each star describes a particular curve on the HR diagram: it begins by following the \"\\NewTerm{Hayashi-path}\\index{Hayashi-path}\" (proto-star and after one of the existing tar) until it reaches the main sequence in which it operates as its core burns hydrogen. When beginning the burning of helium, it goes back up where red giants are concentrated and remains there until nuclear fusion stops; it then collapses on itself to join the white dwarfs or in the case of a certain value of solar masses, neutron stars, Black Holes, or if its mass is very high, exploding as supernovae.\n\t\n\tThe O stars were discovered in the late 19th century. They are hot and their spectra look like nebulae. The B are helium stars, A hydrogen stars. The predominant component of F is calcium. G are of the same type as the Sun and K differ very little bit. M are characterized by titanium oxide and S of zirconium oxide, while R and N contain hydrocarbons and cyanogen.\n\t\n\tTherefore a star of the mass of the Sun after a stint on the main sequence, becomes a red giant, eventually a planetary nebula (ejection of fuel of the star at long distances), before ending his life as a White Dwarf. The end as supernovae cannot be shown in this diagram because of their Luminosity that is to high. Neutron star and Black Holes are in the same path than White Dwarfs (lower on the right than Procyon B).\n\t\n\tA star is initially in hydrostatic equilibrium. Gravitational forces due to its mass are compensated by the internal pressure forces due to the elevated temperature maintained by thermonuclear reactions at low density and to the degeneracy pressure of electrons: \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/star_pressure.jpg}\n\t\\end{figure}\t\n\tA star spends almost $90\\%$ of his life to fuse hydrogen into helium that builds up in the center. During this phase, it evolves into the \"main sequence\" of the Hertzsprung-Russian diagram.\n\t\n\tFor a low mass Main Sequence star, hydrogen fusion is the first energy source that provides radiation pressure to maintain the hydrostatic equilibrium. When hydrogen fusion ends, the star begins to undergo structural changes, and it begins to become a red giant (helium fusion) through what we name a \"\\NewTerm{helium flash}\\index{helium flash}\". At the end of the life of a low mass star, the core collapses until the electrons provide a source of pressure to withstand the collapse, and at this stage the star is a White Dwarf. For higher mass stars, the early stages of life are the same, but the core of these stars reach higher temperatures, so they can burn more massive species, like Carbon, Oxygen, Neon, Magnesium, and Silicon. Towards the end of its life, a high mass star's core will look like the layers of an onion.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.39]{img/cosmology/star_structure.jpg}\n\t\\end{figure}\n\tThe core of a high mass star will eventually create iron, but when the core tries to fuse iron, it will die in a catastrophic explosion. The problem is that unlike Hydrogen, Helium, Carbon, etc., the fusion of iron does not release energy (\\SeeChapter{see section Nuclear Physics page \\pageref{nuclear fusion}}). When the core contains enough iron, the star implodes in seconds, and all of the mass of the outer part of the star hits the core and rebounds, and the rebound sends a shockwave outward pushing all of the material outside of the core into space in a tremendous explosion, named a \"\\NewTerm{supernova}\\index{supernova}\":\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/supernova.jpg}\n\t\t\\caption{Region of the sky before and after the 1987 supernova in visible light}\t\n\t\\end{figure}\n\tWhen the helium mass of a star becomes sufficient, the increase in pressure causes an increase of the temperature thereby initiating the fusion of helium (\"\\NewTerm{helium flash}\\index{helium flash}\") into carbon, oxygen and neon creating a second combustion front inside the first. For a star of one solar mass, reactions stop at this stage. The star radius increase and its surface temperature decrease until stabilization. It becomes a red giant $10^4$ times more luminous than before. It goes through various phases of instability and eventually gradually expel its outer layers, forming a \"\\NewTerm{planetary nebula}\\index{planetary nebula}\" (from a fraction of parsecs like in size like our Solar System to a little bit more of $1$ parsec - approximately $4$ light years - for the biggest known at this date). \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.07]{img/cosmology/planetary_nebula.jpg}\t\n\t\t\\caption[Planetary Nebula gallery]{Planetary Nebula gallery (source: Hubble Space Telescope)}\n\t\\end{figure}\n\tIts core, with a density of several tons per cubic centimetre, cools down slowly: it become a \"\\NewTerm{white dwarf}\\index{white dwarf}\" (we will discuss this process mathematically below). The balance in its core is maintained by the pressure of degeneration of electrons.\n\t\n\tFor a more massive star, the internal temperature becomes quite important so that the carbon and oxygen can fusion into silicon. In turn, if there is enough mass, silicon will fusion into iron. Combustion fronts develop in a pattern said of \"onion skins\" (see prior previous figure). As iron is the most stable nucleotide,  it is at the bottom of the valley of stability (\\SeeChapter{see section Nuclear Physics page \\pageref{valley of stability}}). It can not fusion or split. When the density reaches a critical value (this corresponds to a total mass of the star of more than $8$ solar masses!!!), electron degeneracy pressure can no longer maintain the balance against gravity. In a tenth of a second, the iron core collapses. The other layers of the heart of the star rush towards the collapsed core in the for a wave whose maximum speed corresponds to the sonic radius.\n\t\n\tThe core density then becomes really huge. There occur inverse $\\beta^-$ reactions where protons capture electrons forming neutrons (!!!) and releasing a flow of neutrinos. When the core of the star reaches the nuclear density of approximately $10^{18}\\;[\\text{kg}\\cdot\\text{m}^{-3}]$, the compaction stops roughly (the remaining radius at this stage is about $10$ [km] only!). The outer layers of the core bounce by a super elastic shock and come into expansion. When this reflected shock wave reached the sonic radius, the temperature rises so high that give him a value is almost meaningless. The material undergoes a complete photo-disintegration (all nucleotides are disaggregated into nucleons gas). Finally by an unclear mechanism, all the outer layers of the star are ejected into space: it is a \"\\NewTerm{type II supernovae}\\index{type II supernovae}\".\n\t\n\tThe collapsed core, made almost entirely of neutrons, will be rotating rapidly if the original star had a non-zero angular momentum (conservation of angular momentum oblige!). The magnetic field is also preserved and far exceeds anything that will probably never be feasible a laboratory. This causes a synchrotron beam which gives the illusion that the star flashes. This is why these young \"\\NewTerm{neutron stars}\\index{neutron stars}\" are named \"\\NewTerm{pulsars}\\index{pulsars}\".\n\t\n\tFor very massive stars (above $50$ solar masses), the total mass of the core that collapses could exceed $3$ solar masses. In this case, gravity becomes such that its mass collapses beyond the last repulsive forces and compacted into a singularity. The curvature of space becomes such that almost (without going into the details of some theories that have until now not been verified) no material information or radiation can escape beyond the horizon or a volume named the \"\\NewTerm{Schwarzschild sphere}\\index{Schwarzschild sphere}\". This is a \"\\NewTerm{Black Hole}\\index{black hole}\". Anything that falls inside loses his identity. A Black Hole has only three properties: its mass, angular momentum and electric charge. We say that a Black Hole has \"no hair\". Moreover, such a singularity should always be hidden by a horizon, be: \"dressed\" (for more details see the section of General Relativity).\n\t\n\tTo give an idea of the scales you can see the figure below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{img/cosmology/size_comparison.jpg}\n\t\t\\caption{Comparison of various planets with various Stars}\n\t\\end{figure}\n\tAnd here just for the solar system but without respecting distance but only the proportions of the planets and Sun (high definition image so you can zoom on):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=\\textwidth]{img/cosmology/solar_system.jpg}\n\t\t\\caption{Solar System Proportions}\n\t\\end{figure}\n\tOr the biggest actually known (year 2017) star compared the biggest known Black Hole (\\SeeChapter{see section General Relativity page \\pageref{black hole}}):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/blackhole_vs_star.jpg}\t\n\t\t\\caption{Biggest Black Hole vs Biggest known Star}\n\t\\end{figure} \n\t\n\t\\pagebreak\n\t\\subsubsection{Stellar Physics}\n\tWe will now see how new stars can be born from huge gas clouds that extend between the stars in galaxies. The interstellar medium is a potential source of new stars, which once completed their life (as a red giant or supernova) can inject some of their material in outer space.\n\n\tIn fact, nobody really knows in this beginning of this 21st century the details of how an interstellar cloud leads to a star because it is a very difficult problem, mainly because of the emergence of a hierarchy of structures, sub-structures, etc. in the cloud as it collapses on itself. Turbulent motions appear, which can not be described simply by the hydrodynamic equations (\\SeeChapter{see section Continuum Mechanics page \\pageref{navier stokes equations}}). Further complications arise when we consider the magnetic field on the gas contraction, or supernova explosions in the cloud...\n\n\tAt least, can we give the necessary conditions for a star to form in an interstellar cloud. For this, several barriers must actually be completed. A first thermal barrier. A second rotational barrier is: a protostar that contracts rotates faster and faster and can literally explode if its speed becomes too high (conservation of angular momentum). Let's examine these two effects.\n\t\n\t\n\t\\paragraph{Collapse of an Interstellar Cloud}\\mbox{}\\\\\\\\\\\n\tTwo opposing forces are present in a cloud of mass $M$ and radius $R$: an autogravitation (a force) which tends to contract the cloud, and thermal pressure force, which tends to explode it.\n\t\n\tWe can quantify these two opposite forces in terms of energy: the cloud has a gravitational potential energy (negative) and a kinetic energy (positive) due to thermal agitation of the molecules.\n\n\tWe know (\\SeeChapter{see section Classical Mechanics page \\pageref{gravitational potential energy}}) that the gravitational potential energy of two masses $m$ and $m$ of particles separated from a distance $r$ is written:\n\t\n\tSo the external potential energy of a spherical cloud (...) of mass $M$ and radius $R$ is of the order of:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tSome practitioners (this is our case) prefer for the following developments use the internal potential energy that is given for recall by (see the proof in the section of Classical Mechanics):\n\t\n\t\\end{tcolorbox}\n\tIn a gas in thermodynamic equilibrium, a particle has a kinetic energy (\\SeeChapter{see section Continuum Mechanics page \\pageref{virial theorem}}) of $kT/2$ by degree of freedom (translation, rotation, etc.). So if $\\mu$ is the average mass of a molecule of the cloud, the total kinetic energy of the latter will be expressed:\n\t\n\tThe cloud then collapses if its total mechanical energy is negative, or (according to the previous approximation):\n\t\n\tThe above equation defines the \"\\NewTerm{Jean's mass}\\index{Jean's mass}\" (assuming a spherical and homogeneous distribution). This is the minimum mass (limit) at a given temperature $T$ and density $\\rho$ for a cloud begins to collapse until another physical process may intervene to stop the contraction of the gas.\n\t\n\tBy eliminating the radius with:\n\t\n\tIn the previous relation, we get:\n\t\n\tIf we would not have make the choice of the external potential, but rather the internal one (more accurate in our point of view) and we did not approximate $2/3\\cong 1$ the final result would have been:\n\t\n\tThat is traditionally written as:\n\t\n\tTherefore if $M_\\text{cloud}>M_J$ then the cloud collapse!\n\t\n\tAs they are many approximations, astrophysicists prefer to write this last relation as:\n\t\n\twhere $C$ is obviously a constant without units.\n\t\n\t\\pagebreak\n\t\\subparagraph{Limit Mass Cloud for Ionization (rogue planets)}\\mbox{}\\\\\\\\\\\n\tNow let us come back on the relation:\n\t\n\tA famous question is what is the mass required by a hydrogen cloud to start nuclear fusion and become a star\\footnote{Notice that some astrophysicists thinks that in some special configuration cases, some huge gas clouds may directly collapse in super Black Holes instead of creating a star (or smaller celestial objects).}. For this, we can say in a first approximation that for the fusion, hydrogen atoms must have a distance equal to their radius such that we have for the density:\n\t\n\twhere for comparison, density for iron is $7,874\\;[\\text{kg}\\cdot \\text{m}^{-3}]$. We will also take $\\overline{m}\\cong m_p = 1.6726219\\cdot 10^{-27}$ [kg] (we neglect the mass of electrons as it is almost $1,800$ smaller) and for temperature that of the fusion of hydrogen\\footnote{We have proved that the ionization energy of hydrogen in the section of Corpuscular Quantum Physics was $13.6$ [eV], hence $157,821$ [K] but to avoid re-coupling we take a security factor of $10$.} $T=T_i=10^6$ [K].\n\t\n\tTherefore:\n\t\n\tThis value perfectly match the value given by then french version of Wikipedia (given without proof...).\n\t\n\tWith the $10$ security factor for $T_i$ we would have:\n\t\n\tIn comparison Jupiter is $0.1\\%$ of the mass of the Sun...\n\t\n\tTherefore for an initial mass less than $0.066 M_\\odot $ the gas sphere liquefies or solidifies and stabilized in the form of a planet. Jupiter as we have just see has a mass that is not for very near this limit value and we observed with telescopes that the planet is still very slowly contracting. \n\t\n\tSuch bodies are named \"\\NewTerm{sub-brown dwarfs}\\index{sub-brown dwarfs}\", sometimes referred to as \"\\NewTerm{rogue planets}\\index{rogue planets}\".\n\t\n\t\\pagebreak\n\t\\subparagraph{Limit Mass Cloud for Fusion (black dwarf)}\\mbox{}\\\\\\\\\\\n\tThe name \"\\NewTerm{black dwarf}\\index{black dwarf}\" has also been applied to substellar objects that do not have sufficient mass, less than approximately $0.08 M_\\odot$, to maintain hydrogen-burning nuclear fusion. These objects are now generally named \"\\NewTerm{brown dwarfs}\\index{brown dwarf}\", a term coined in the 1970s. Black dwarfs should not be confused with Black Holes or neutron stars.\n\t\n\tBeyond ionization mass limit, it is an ionized gas ball that will continue gravitational collapse. If during contraction, the temperature of $10^ 7$ [K] is not reached, the nuclear reactions can be triggered and it is the quantum nature of repulsive forces that will oppose gravity. Electrons are fermions (\\SeeChapter{see section Statistical Mechanics page \\pageref{fermi dirac distribution}}), the principle of Pauli exclusion (\\SeeChapter{see section Corpuscular Quantum Physics page \\pageref{pauli exclusion principle}}) prevents the stack of Electron in the same volume of phase space. This is equivalent to a high pressure which is well above the thermal pressure of the atoms.\n\t\n\tThe mass that can be stabilized in this state is still:\n\t\n\tAs $T_f\\cong 10^7$ [K], the electrons are non-relativist. The linear moment is such that:\n\t\n\tFrom the incertitude principle (\\SeeChapter{see section Wave Quantum Physics page \\pageref{second quantum uncertainty relation}}):\n\t\n\tRoughly:\n\t\n\tto compare with the previous $r_0=0.5\\cdot 10^{-10}$ [m]...\n\t\n\tTherefore:\n\t\n\tFor the protons, that are $1,800$ times more massive, the minimum volume is much smaller and can be neglected at this level of our discussion.\n\t\n\tWe use now the same relation as previously but where we take $T_f$ instead of $T_i$ and $\\overline{m}=m_e=9.10938356(11)\\cdot 10^{-31}$ [kg] as the proton mass as plasma experiences and intuition gives that electrons because of their small mass take the most kinetic energy (in comparison to the proton for the same charge... or as in heated liquids where small molecules are much more agitated than big one):\n\t\n\tTherefore theoretically we have so far:\n\t\\begin{itemize}\n\t\t\\item $M_i<0.066M_\\odot$ we have a big gas planet of the style of Jupiter or Saturn (\"\\NewTerm{sub-brown dwarfs}\\index{sub-brown dwarf}\" or \"\\NewTerm{rogue planets}\\index{rogue planets}\" for recall).\n\n\t\t\\item $0.066M_\\odot<M_f<0.92M_\\odot$ we have a ionized hot star at the limit of starting a nuclear fusion it's for recall a \"\\NewTerm{black dwarf}\\index{black dwarf}\" or more suited named a \"\\NewTerm{brown dwarf}\\index{brown dwarf}\".\n\n\t\t\\item For $M_J>0.92M_\\odot$ we have then a star able to initiate thermonuclear fusion.\n\t\\end{itemize}\n\tBrown dwarf seems to be very difficult to observe. It seems as far as we know that the first one was directly observed in 2016 only (HD 4747 B)... because of their low surface energy emitting.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.4]{img/cosmology/brown_dwarf_v2.jpg}\t\n\t\t\\caption{Sun in comparison of various dwarf stars and Jupiter}\n\t\\end{figure}\n\tThe developments above are obviously approximations and depends on many other factors. For example, Proxima Centauri, located just $4.2$ light-years away has $12\\%$ of the mass of the Sun, and it is estimated to be just $14.5\\%$ the size of the Sun with a diameter of  about $200,000$ [km] (just for comparison, the diameter of Jupiter is $143,000$ [km], so Proxima Centauri is only a little larger than Jupiter).\\\\\n\n\tBut that's not the smallest star ever discovered! The smallest known star right now is OGLE-TR-122b that is part of a binary stellar system. This red dwarf has its radius accurately measured!: $0.12$ solar radii. This works out to be $167,000$ [km]. That's only $20\\%$ larger than Jupiter. You might be surprised to know that OGLE-TR-122b has $100$ times the mass of Jupiter.\n\t\n\tIt seems that in July 2017 even a smallest star was observed (but we need confirmation), EBLM J0555-57Ab. It seems that this star has a mass equivalent to $8\\%$ to that of the and is as big as Saturn...\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/eblm_j055_57ab.jpg}\t\n\t\t\\caption[EBLM J0555-57Ab smallest known star]{EBLM J0555-57Ab smallest known star] (source: ?)}\n\t\\end{figure}\n\t\n\t\\paragraph{Nuclear Duration Life}\\mbox{}\\\\\\\\\\\n\tOnce again remember that we have proved in the section of Classical Mechanics that inside a massive body the gravitational potential energy was given by:\n\t\n\tWhat has this have to do with starshine?\n\n\tWell, notice that as $R$ gets smaller, $E_p$ gets more negative then energy is being converted to other forms, like heat. If a star can radiate this heat into space, then gravitational contraction might produce the luminosity of the star.\n\t\n\tHow much of this gravitational energy can be radiated away? \n\t\n\tRemember that we know that radiation is related to heat (\\SeeChapter{see section Statistical Mechanics page \\pageref{black body}}) that is itself related to velocity (\\SeeChapter{see section Continuum Mechanics page \\pageref{virial theorem}}), and that we proved during our study of the virial theorem (\\SeeChapter{see section Continuum Mechanics page \\pageref{virial theorem}}) that:\n\t \n\tBut back to the contracting Sun. The virial theorem says that half the change in gravitational energy stays with the star (it heats the star through the atomic agitation). The other half is radiated away.\n\t\n\tSo, let's say that the Sun has been contracting and was originally much, much bigger.  Initially its gravitational potential energy was tiny (why?), so the change in gravitational energy is:\n\t\n\tNow, half of this energy could have been radiated as the Sun shrank:\n\t\n\tthat gives with our Sun the value: $\\cong 10^{41}\\;[\\text{J}]$. That's a lot of energy! So how long could it sustain the luminosity of the Sun?:\n\t\n\tthis time is named the \"\\NewTerm{Kelvin-Helmholtz timescale}\\index{Kelvin-Helmholtz timescale}\" and with the values of the Sun it gives:\n\t\n\tand as we see the value is quite problematic... As our Earth would be older than our Sun. In fact this problem comes the fact that we don't take into account the fuel of start is the nuclear fusion. So let us see a little bit more accurate model:\n\t\n\tSo the age of the stars is as we will see just now mainly a problem of calculation of nuclear fuel. The resolution of this problem was given by relativity, and in particular by the mass-energy equivalence (\\SeeChapter{see section Special Relativity page \\pageref{mass energy equivalence}}).\n\n\tEven if the detailed description of nuclear reactions in the heart of the Sun was made in the mid-1930s by Hans Bethe, astrophysicists have suspected soon after Albert Einstein's work that the mass-energy equivalence could explain the brightness of the Sun on billions of years, for example through the fusion of ionized hydrogen (proton $p$) into ionized helium (two protons, two neutrons) via a series of steps (the specified energy is the kinetic energy of the different elements):\n\t\n\tThe positron annihilates instantly with one of the electrons of a surrounding hydrogen and their mass-energy is liberated in the form of two gamma photons:\n\t\n\tAfter this the deuterium produced in the first stage can fuse with another hydrogen nucleus to produce an isotope of helium:\n\t\n\tFinally, two isotopes of helium $^3\\mathrm{He}$  may fuse and produce the normal isotope of helium $\\tensor[^{3}_2]{\\mathrm{He}}{}$ and also two hydrogen nuclei that can start again the reaction in three difference ways named PPI (dominant at temperatures of $10$ to $14$ millions Kelvins), PPII (dominant at temperatures of $14$ to $23$ millions Kelvins) and PPIII (dominant above $23$ millions Kelvins):\n\t\n\tAnd these reactions do not occur all with the same probability and at the same temperatures...\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/proton_proton_chain_reaction.jpg}\t\n\t\t\\caption[Diagram of the proton-proton chain reaction in typical Sun size stars]{Diagram of the proton-proton chain reaction\\index{proton-proton chain reaction} in typical Sun size stars (source: Wikipedia)}\n\t\\end{figure}\n\tThe measurement of the mass of the proton gives $m_p\\cong 1.673\\cdot 10^{-27}$ [kg], while the helium mass is   $m_{\\text{He}}\\cong 6.645\\cdot 10^{-27}$ [kg], that is to say a loss in atomic mass (we neglect the mass of positrons which is $10,000$ times smaller than that of the neutrino):\n\t\n\tSo a relative loss of mass by fusion (this is the part of the reactions that escapes from the Sun in the form of kinetic energy):\n\t\n\tWe will prove further below that the Sun emits a power output of:\n\t\n\tTherefore its mass consumption per second is:\n\t\n\ti.e. its mass decreases by $4.4$ million tonnes per second...\n\t\n\tNow we know that this value corresponds to only $0.72\\%$ of the mass put in reaction in a fusion. The total mass reacted  is then (rule of three):\n\t\n\tThus, at every second $627$ million tons of hydrogen 1(ionized) fuse into helium 4 with a weight loss of $4.4$ million tonnes which is converted into energy.\n\t\n\tAssuming that only the center of the Sun fills the thermal conditions for the fusion ($\\cong 10\\%$ of its total mass), this brings us to determine the time of nuclear life of the Sun (or any other Star of the same type whose mass is known):\n\t\n\tTransforming this in years we have:\n\t\n\t\n\t\\paragraph{Internal Temperature}\\mbox{}\\\\\\\\\\\n\tThe stars are assumed to be spherical clusters of hydrogen gas where the interactions between molecules are governed by the gravitational attraction.\n\n\tA star has no wall that delimits it, that is to say that there are no external forces coming from vacuum and therefore:\n\t\n\tand also not any bulk modulus.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.23]{img/cosmology/sun_corona.jpg}\t\n\t\t\\caption[Sun Corona Zoom]{Sun Corona Zoom (source: NASA Goddard Space Flight Center)}\n\t\\end{figure}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{img/cosmology/global_sun.jpg}\t\n\t\t\\caption[Global Sun overview]{Global Sun overview (source: NASA)}\n\t\\end{figure}\n\t\t\n\tUsing the virial theorem in the section of Continuum Mechanics that gives us:\n\t\n\tWe have for a homogeneous spherical gas of radius $R$ and mass $N$ composed of $N$ bodies, the relations the following relations proved for the first one in the section of Continuum Mechanics of the second in the section of Classical Mechanics:\n\t\n\tTherefore:\n\t\n\twhere for recall $k$ is the Boltzmann constant.\n\n\tWhich gives:\n\t\n\tin order to not make the confusion between to constant of ideal gas denoted $R$ and the radius it is more convenient to write the latter relation as (and making the Boltzmann constant more explicit):\n\t\n\tWith for a given star $N$ being the ratio of the total mass of the star on the average mass of a molecule.\n\t\n\tFor the Sun it comes that $T\\cong 10^7$ [K].\n\t\n\tThis is the central temperature of the Sun. Optical measurements measured from Earth only give the surface temperature (chromosphere), thus $6,000$ [K]. The calculated internal temperature is about $1,600$ times higher than at the surface. Independent methods based on nuclear reactions in the center of the Sun (measurement of solar neutrino flux) give the same order of magnitude, but the precise values differ by a factor of $2$-$3$.\n\t\n\t\\paragraph{External temperature}\\mbox{}\\\\\\\\\\\n\tWe have proved in the section of Thermodynamics that the Stefan-Boltzmann law permits to calculate the temperature of a heated body from its emittance or its internal energy in terms of density such as:\n\t\n\twith:\n\t\n\tbeing the Stefan-Boltzmann constant.\n\n\tLet us take an interesting example that concerns us directly:\n\t\n\tThe average emittance also named \"\\NewTerm{average bolometric emittance}\\index{average bolometric emittance}\" received by the Earth outside the atmosphere, also named \"\\NewTerm{solar constant}\\index{solar constant}\" (which is in fact not constant ... on a scale of several billion years), is directly measurable in orbit and is equal to $\\sim 1,373\\;[\\text{Wm}^2]$.\n\t\n\tKnowing the average distance from the Sun to be about $1.496\\cdot 10^{11}\\;[\\text{m}]=1\\;[\\text{UA}]$  (Astronomical Unit), we can calculate the surface of the sphere $S$ at $R=1$ [UA] and thus the solar power $P$. Thus:\n\t\n\tand:\n\t\n\tAssuming known the radius of the Sun as being $r_{\\odot}\\cong 6.9599\\cdot 10^8$ [m], we can calculate its surface $S$ and is solar radiative emittance $M_{\\odot}(T)$. So:\n\t\n\tand:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe radiating surface of a star is named \"\\NewTerm{photosphere}\\index{photosphere}\". Indeed, as stars, excepting neutron stars, have no solid surface, the photosphere is typically used to describe the Sun's or another star's visual surface.\n\t\\end{tcolorbox}\n\tUsing the Stefan-Boltzmann law, we can now calculate approximately the thermodynamic temperature of the photosphere:\n\t\n\twhich is very accurate to direct measurement!!! More generally the previous relation is written:\n\t\n\tor respecting the notation of optical geometry:\n\t\n\tSo since we can estimate the luminosity and the temperature of a star (or something that looks like...) we can also estimate it's radius!\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/photosphere.jpg}\t\n\t\t\\caption[Layer's view of our Sun]{Layer's view of our Sun (source: NASA)}\n\t\\end{figure}\n\n\tPlanck's law (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}}) applied at this temperature allow us to calculate the spectral distribution of solar radiation and then we see that the maximum of the intensity is in the visible range (our visible range!!!) spectrum which is from $400$ [nm] to $700$ [nm].\n\t\n\t\\paragraph{Equation of Hydrostatic Equilibrium}\\mbox{}\\\\\\\\\\\n\tThe absence of changes in most stars over timescales of hours or days indicates that the forces acting on the matter in the stars are essentially perfectly balanced (remember figure showed earlier above). Here we analyse this constraint in more detail.\n\n\tIn the figure above we have represented a piece mass shell in a spherically symmetric star where we consider in reality a very small cylindrical element between radius $r$ and radius $r + \\mathrm{d}r$ hence the fact that the element surface $\\mathrm{dS}$ is considered as being the same (but we can neglect the pressure variation as it can be very big even in a small height difference):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/histrostatic_equilibrium.jpg}\t\n\t\\end{figure}\n\tIf we denote by $M(r)$ the mass of star in the smaller radii and $\\Delta m$ the mass in the cylinder, we get:\n\t\n\tNow for the pressure we have (net force due to difference in pressure between upper and lower faces):\n\t\n\tUsing the definition of the derivative but applied to the pressure:\n\t\n\tTherefore:\n\t\n\tNow we have as mass element that is given as we know by:\n\t\n\tApplying Newton's second law to the cylinder:\n\t\n\tThis sum must be equal to $0$ everywhere if the star is indeed static. Therefore:\n\t\n\tAfter simplification we get the \"\\NewTerm{equation of hydrostatic equilibrium}\\index{equation of hydrostatic equilibrium}\" or \"\\NewTerm{stellar structure equation}\\index{stellar structure equation}\":\n\t\n\tSo far we already estimated roughly the core temperature of the Sun and of the photosphere. Let us now first estimate roughly its average pressure:\n\t\n\tA better estimation is given by using the equation hydrostatic equilibrium:\n\t\n\tand integrate (assuming density is constant):\n\t\n\tSo we have an expression for the central pressure:\n\t\n\tThat is to $6$ times more than the previous roughly approximation and compared to direct measurement method this seems more accurate!\n\t\n\tWe also have for mean density of the Sun:\n\t\n\tto compare with the density of pure water that is $1,000 \\; [\\text{kg}\\cdot \\text{m}^{-3}]$ or to that of iron that is $7,874 \\; [\\text{kg}\\cdot \\text{m}^{-3}]$. So we understand better why space image of the Sun looks like a big liquid sphere of gas as because of the gravity conditions the pressure is such that the gas is reduce to a density greater than that of water in average!!!!!\n\t\n\tHere is a figure of what we think so far as comparison for Jupiter that is like a non-initiated star:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/jupiter_layers.jpg}\t\n\t\\end{figure}\n\t\n\tUsing the equation of hydrostatic equation we can estimate roughly the density of the photosphere:\n\t\n\tSo it is obvious that the density of the Sun decreases continuously outward from the center. The visible surface of the Sun (i.e. the photosphere) is a very thin layer, only about $500$ [km] thick as compared to the radius of the Sun. The density of the photosphere is very, very low, about $0.2\\cdot 10^{-4} \\;[\\text{kg}\\cdot \\text{m}^{-3}]$ as estimated by observations. Therefore the average density of the Sun can only be explained by the density of its core that is very high, about $160,000\\;[\\text{kg}\\cdot\\text{m}^{-3}]$, much higher than any material that we know.\n\n\t\n\t\n\t\\pagebreak\n\t\\paragraph{Brightness}\\mbox{}\\\\\\\\\\\n\tThe \"\\NewTerm{intrinsic bolometric brightness}\\index{intrinsic bolometric brightness}\\label{intrinsic bolometric brightness}\" of a star corresponds to the total power radiated in the entire electromagnetic spectrum in the direction of the observer expressed relatively to the total power radiated by the Sun. Assuming all stars spherical and isotropic, we can express it in solar units:\n\t\n\tThe radiated power $P$ is calculated, as we know, by multiplying the radiative emittance (Stefan-Boltzmann law) by the surface of the star:\n\t\n\tThe intrinsic bolometric luminosity of a star is therefore proportional to the square of its radius and the fourth power of its surface temperature. Taking the Sun as a reference, the constants are simplified. We can the write:\n\t\n\twith $r_{\\odot}\\cong 6.9559\\cdot 10^8$ [m] and $T_{\\odot}\\cong 5,780$ [K] hence $c^{te}\\cong 1.85\\cdot 10^{-33}\\;[\\text{K}^{-4}\\text{m}^2]$.\n\t\n\tIn astrophysics, we also use a logarithmic scale to express the bolometric luminosity of a star: the \"absolute magnitude $M$\". This unit has an empirical origin that will be explained below.\n\t\n\t\\paragraph{Shining (apparent brightness)}\\mbox{}\\\\\\\\\\\t\n\tPerhaps the easiest measurement to make of a star is its apparent brightness. We are purposely being careful about our choice of words. When we say \"apparent brightness\", we mean how bright the star appears to a detector here on Earth.\n\t\n\t\\textbf{Definition (\\#\\mydef):} The \"\\NewTerm{brilliance}\\index{brilliance}\" or \"\\NewTerm{shining}\\index{shining}\" or \"\\NewTerm{apparent brightness}\\index{apparent brightness}\" $b$ of a star is the density of radiation received by the observer, that is to say equal to the flow of energy divided (power of the star at its surface) divided by the sphere surface with the  radius equal to the distance which separates the observer from the star:\n\t\n\tThe brilliance decreases therefore with the square of the distance (as in myna other filed of physics):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/apparent_luminosity_inverse_square.jpg}\n\t\\end{figure}\n\tIt is important to notice that this quantity has no direct relation with the physical intrinsic  properties of the respective star (unlike the bolometric brightness!).\n\t\n\tThus, two identical stars can have the same apparent brightness if (and only if) they lie at the same distance from Earth. However, as illustrated in Figure below, two different stars can appear equally bright if the more luminous one lies farther away. A bright star (that is, a star with large apparent brightness) is a powerful emitter of radiation, is near Earth, or both. A dim star is a weak emitter, is far from Earth, or both:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/apparent_luminosity.jpg}\t\n\t\t\\caption{Apparent luminosity}\n\t\\end{figure}\t\n\t The luminosity of a star, on the other hand, is the amount of light it emits from its surface. The difference between luminosity and apparent brightness depends on distance as we know now. Another way to look at these quantities is that the luminosity is an intrinsic property of the star, which means that everyone who has some means of measuring the luminosity of a star should find the same value. However, apparent brightness is not an intrinsic property of the star; it depends on your location. So everyone will measure a different apparent brightness for the same star if they are all different distances away from that star.\n\t\n\tApparent brightness is the brightness perceived by an observer on Earth and absolute brightness is the brightness that would be perceived if all stars were magically placed at the same standard distance. There can be a great difference between the total amount of radiation a star emits and the amount of radiation measured at the Earth's surface.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.24]{img/cosmology/most_brightest_stars.jpg}\t\n\t\t\\caption{Most brightest stars at night in early 21st century}\n\t\\end{figure}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{img/cosmology/most_brightest_galaxies.jpg}\t\n\t\t\\caption{Most brightest galaxies at night in early 21st century}\n\t\\end{figure}\t\n\tThe figure below (this figure obviously doesn't depict the correct location of each object relative to each other...!) depicts the approximate apparent sizes from Earth of various different deep space objects if they were brighter (this is how they would appear approximately in our night sky). The images are approximately in scale with one another, including the Moon, but not to the Milky Way background (in real life you can forget to see all these objects when the Moon is bright during the night with naked eyes because it will overflow your eyes photoreceptor, you should wait for the new Moon or that the Moon is not visible in during the night!):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1\\textwidth]{img/cosmology/objects_of_sky_at_equal_brightness.jpg}\t\n\t\t\\caption{Approximate sky if important objects had similar brightness}\n\t\\end{figure}\t\t\n\tIn astrophysics, we also use another scale of measurement where the apparent brightness is given by another magnitude of empirical origin: the apparent magnitude, which will be explained immediately below.\n\t\n\t\\paragraph{Apparent magnitude}\\mbox{}\\\\\\\\\\\n\tPtolemy in 137 AD had defined a scale of six magnitudes to express the brightness (shining) of stars, the first for the brightest and the sixth for the stars just visible to the naked eye ($6$ magnitudes and therefore $5$ gaps).\n\n\tDuring the 19th century, with the arrival of new photometric observations techniques (photographic and photoelectric), the scale of magnitude was replaced by that of \"\\NewTerm{apparent magnitude}\\index{apparent magnitude}\" $m$ that has been defined so that this new scale is close to the old one.\n\n\tThe definition is the following:\n\t\\begin{itemize}\n\t\t\\item The scale is logarithmic in base $10$ (for convenience of the magnitude of manipulated quantities)\n\n\t\t\\item There are $5$ magnitude gaps corresponding to an apparent brightness ratio of $1$ for $100$ ($1: 100$)\n\n\t\t\\item The scale is inverse (high magnitude corresponds to a small apparent magnitude/ brightness).\n\t\\end{itemize}\n\tUsing these definitions, we can construct a relative way relating the shining (brilliance) of two stars to their apparent magnitude $m$.\n\n\tFor a star $1$ two hundred times brighter than a star $2$, the star $1$ is $5$ magnitude  units above the star $2$ (remember that the scale is reversed). So a ratio of:\n\t\n\tcorresponds by definition to:\n\t\n\tWe can then put the relations:\n\t\n\tBy applying the rule of three, we build:\n\t\n\tBy simplifying, we find the \"\\NewTerm{Pogson's Formula}\\index{Pogson's Formula}\" which expresses the relation between (visual) apparent  magnitudes and brilliance (shining) of two stars:\n\t\n\tApart from small corrections, the brightness of Vega\\footnote{Brightest star in the constellation Lyra at this day (21st century). It is actually a relatively close star at only $25$ light-years from Earth, and, together with Arcturus and Sirius, one of the most luminous stars in the Sun's neighbourhood} ($\\alpha$ Lyr) still serves as the definition of zero magnitude for visible and near infra-red wavelengths. The brightness of Vega is exceeded by four stars in the night sky at the 21st century at visible wavelengths (and more at infra-red wavelengths) as well as bright planets such as Venus, Mars, and Jupiter, and these must be described by negative magnitudes. For example, Sirius, the brightest star of the celestial sphere, has an apparent magnitude of $-1.4$.\n\t\n\tTo get an idea of the (visual) apparent magnitudes relatively to Vega here are some examples: Sun $m_{\\odot}=-26.74$, full Moon $m=-15$, Venus maximum $m=-4.8$, Sirius $m=-1.4$ (spectral type A1 and distant of $8.6$ light years), limit perceived with the naked eye $6$, perception limit through an amateur telescope of $15$ [cm] at this date (2003) $m=13$ limits of perception Hubble space telescope $m=30$.\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tNow as we know that the apparent magnitude of the Sun is $-26.74$ (brighter), and the mean apparent magnitude of the full Moon is $-12.74$ (dimmer) the difference in apparent magnitude is obviously that $\\delta m=14.00$\\\\\n\n\tWith this information reconsider that the Pogson formula also gives by construction the ratio of the luminosity. So relatively to our example we get:\n\t\n\tAfter rearranging we get therefore:\n\t\n\tOr better to have a nicer number:\n\t\n\tThe Sun appears about $400,000$ times brighter than the full Moon.\n\t\\end{tcolorbox}\n\tIt should be noticed that the (visual) apparent magnitude does not exactly match the real apparent magnitude, because the eye is not equally sensitive to all wavelengths. The blue or red stars seem less bright to the eye than they actually are because some of the radiation is in the ultraviolet, respectively in the infra-red.\n\t\n\tAs one of my friend didn't know it (...) just a remark about the Moon... Many books and Internet websites show the classical following figure (where there is basically not too much to say about)\\label{new moon}:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/moon_phases.jpg}\n\t\t\\caption[Moon phases]{Moon phases (source: ?)}\n\t\\end{figure}\n\tBut this figure is omitting something important for earthlings (even if its implicit)... The Moon in the figure above is represented as seen from above the solar system (perpendicular to the ecliptic plane) or as seen from a viewer at the North Pole. In-between the reality looks like this depending on your latitude:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\textwidth]{img/cosmology/moon_observer.jpg}\n\t\\end{figure}\n\tIt is therefore necessary to clarify whether it is a  visual or bolometric apparent magnitude. In general, astrophysicists use bolometric magnitudes in their publications.\n\t\n\tThe reader must also keep in mind that the Moon isn't aligned on the ecliptic as illustrated below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{img/cosmology/moon_and_ecliptic.png}\n\t\t\\caption{Moon and ecliptic angle}\n\t\\end{figure}\n\tAnd that using the average Moon-Earth distance and basic trigonometry we get that the Moon is:\n\t\n\tkilometres above (and sometimes below) the ecliptic plane! So far above the average radius of the Earth itself ($6,371$ [km])! So the figure above like many similar figures in most textbooks and Internet websites is quite misleading!\n\t\n\t\\paragraph{Absolute magnitude}\\mbox{}\\\\\\\\\\\n\tThe absolute magnitude $M$ (not to be confused with the notation of emittance seen in the section of Geometrical Optics) of a star is also a logarithmic scale , expressing this time the bolometric luminosity $L$!!! It is the quantity presented in ordinate of the Hertzsprung-Russell diagram. The scale of this size is based however on the (visual) apparent magnitude.\n\n\tThe apparent magnitude and absolute magnitude are bound by the distance from the star. At constant intrinsic apparent brightness, the apparent brightness therefore decreases obviously with the square of the distance as we have already seen. In order to establish a relation, we had to choose a reference distance by a new definition.\n\n\t\\textbf{Definition (\\#\\mydef):} The \"\\NewTerm{absolute magnitude}\\index{absolute magnitude}\" $M$ of a star is equal to its apparent magnitude $m$ if it is distant of $10$ parsecs ($32.6$ light years).\n\t\n\tTherefore taking Pogon's formula that is for recall:\n\t\n\tAnd changing the notations to make it correspond the previous definition:\n\t\n\twe get:\n\t\n\tAnd as:\n\t\n\tBut as it is the same star:\n\t\n\tIn our case this becomes:\n\t\n\tTherefore:\n\t\n\tSo finally:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/absolute_apparent_magnitudes.jpg}\t\n\t\t\\caption{Sirius apparent vs absolute magnitudes}\n\t\\end{figure}\n\tAs the Sun-Earth distance in parsec is equal to $4.84814\\cdot 10^{-6}$  we get:\n\t\n\tTherefore:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tFor the absolute magnitude $M$ to be accurate, we need stellar models, and know the temperature of the star as we will immediately see it. In practice, the only readily accessible quantity is obviously the observed magnitude, which is actually the combination of the apparent magnitude and the interstellar absorption.\n\t\\end{tcolorbox}\n\tThe absolute magnitude can be obviously rewritten with respect to the absolute bolometric luminosity of the Sun:\t\n\t\n\tWe put for the Sun that $L_{\\text{bol},\\odot}=1$. Therefore it remains:\n\t\n\t\n\tThis latter relation of comparison of the absolute magnitude with the apparent magnitude (which is the actually magnitude observed on Earth) allows estimation $d$ of the distance of the object in astrophysics.\n\t\n\tUsing the expression of the bolometric luminosity proved earlier above:\n\t\n\tthe absolute magnitude of star being a direct function of its temperature and radius we can then write:\n\t\n\tThis is the result we wanted to prove from the beginning: the absolute bolometric magnitude is directly related to the bolometric luminosity of the star, which is why it is one that most interests astrophysicists.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe distance to nearby stars could be determined by the satellite Hipparcos. By measuring the parallax (measurements of the star position at six-month intervals and applying basic trigonometric rules as seen in the section Astronomy). But beyond a few tens of parsecs, measuring the distance of stars by parallax becomes very imprecise. By studying the spectrum of the star, we can determine its spectral class, its surface temperature and place in the Hertzsprung-Russell diagram. It is therefore possible to estimate its absolute magnitude and roughly calculate its distance.\n\t\\end{tcolorbox}\n\tThis measurement trick is fundamental to cosmology. It is the way we determines the distance to nearby galaxies by measuring the period of some variable stars (we will focus a little bit on that further below).\n\n\tThe distance of distant galaxies is calculated by measuring the apparent magnitude of supernovae that occur in it. Indeed, the absolute magnitudes of Type Ia supernovae (we recognize them by the lack of hydrogen spectrum lines, and by the decrease in brightness) are well calibrated because the energy released by these stellar explosions is relatively constant.\n\t\n\tThe stars of the main sequence of the Hertzsprung-Russell diagram are very stable objects. The gravitational force, which tends to contract the star, is exactly compensated by the internal pressure forces, which tend to dilate it. It's when the star becomes a red giant that sometimes the balance is upset. Thus began a phase of instability which results in significant variations in the brightness of the star.\n\n\tThe breaking of balance is caused by a complex phenomenon that involves variations of transparency of helium layers near the surface of the star. From there, the star begins to experience a series of expansions and contractions controlled by the forces that were formerly balance. When the pressure force prevails, the volume of the star increases. But the gravity slows the movement and eventually cause contraction. The volume of the star will pass below its average value, until the internal pressure opposes the contraction and managed to cause further expansion.\n\n\tIt is not the size changes that cause the variations in brightness, but those of the temperature. Indeed, as we have prove it earlier above, the brightness of a star varies with the fourth power of the temperature, while it varies with the square of the radius following for recall:\n\t\n\tWhen the volume of the star, however, is lower than average, the temperature is slightly higher and the brightness maximum. At the opposite, the temperature is slightly lower than average and the brightness minimum . The brightness of the star thus changes periodically, hence the name of \"variable star\" or \"pulsative variable star\".\n\n\tIt exists in the Hertzsprung-Russell diagram of a band of instability that crosses this diagram almost vertically just to produce the thermal phenomena in question.\n\n\tThe two main types of pulsating variables are the Cepheids and RR Lyrae stars. These bodies play a central role in astrophysics. Cepheids are stars of a few solar masses. They are in the helium burning phase after reaching the red giant stage. The stars of solar mass arrived at this point become RR-Lyrae stars. Their brightness varies with a period of between one day and several weeks. The remarkable property of Cepheids is the existence of a relation between the average brightness and the period of their oscillations. For example, the average brightness is $1,000$ times that of the Sun for a period of days and $10,000$ times that amount for a period of several weeks. It is this relation that makes Cepheids one of the basic tools of astrophysics.\n\t\n\tOk now that we know a few main concepts, it is time to introduce the following interesting data table about a few stars:\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\resizebox{\\textwidth}{!}{\\begin{tabular}{|l|l|c|c|c|c|c|c|c|}\n\t\t\\hline\n\t\t\\rowcolor[HTML]{9B9B9B} \n\t\t\\textbf{Star Name} & \\textbf{Latin Name} & $\\pmb{m}$ & \\textbf{Distance {[}LY{]}} & \\textbf{Spectral Type} & \\textbf{$\\pmb{L}$ {[}$\\pmb{\\text{L}_\\odot}${]}} & \\textbf{$\\pmb{T}$ {[}K{]}} & \\textbf{$\\pmb{M}$ {[}$\\pmb{\\text{M}_\\odot}${]}} & \\textbf{$\\pmb{R}$ {[}$\\pmb{\\text{R}_\\odot}${]}} \\\\ \\hline\n\t\t Sun & & $-26.9$ & $0.000016$ & G2 V & $1$ & $5,800$ & $1$ & $1$   \\\\ \\hline\n\t\t Sirius & $\\alpha$ Canis Majoris & $-1.46$ & $8.6$ & A1 V & $23$ & $10,000$ & $2.5$ & $2.2$ \\\\ \\hline\n\t\tCanopus & $\\alpha$ Carinae & $-0.72$ & $75$ & F0 II & $1,200$ & $8,000$ & $10$ & $15$ \\\\ \\hline\n\t\tArcturus & $\\alpha$ Bootis & $-0.04$ & $34$ & K1 IIIb & $90$ & $4,800$ & $3$ & $15$ \\\\ \\hline\n\t\tRigil Kent & $\\alpha 1$ Centauri & $-0.01$ & $4.3$ & G2 V & $1.4$ & $5,500$ & $1$ & $0.9$ \\\\ \\hline\n\t\tVéga & $\\alpha$ Lyrae & $0.03$ & $25$ & A0 Va & $40$ & $10,500$ & $2.5$ & $1.7$\\\\ \\hline\n\t\tCapella & $\\alpha$ Aurigae & $0.08$ & $41$ & G5 III + G0 III & $120$ & $5,000$ & $3$ & $8$\\\\ \\hline\n\t\tRigel & $\\beta$ Orionis & $0.12$ & $630$ & BS Ia & $55,000$ & $12,000$ & $50$ & $38$\\\\ \\hline\n\t\tProcyon & $\\alpha$ Canis Minoris & $0.38$ & $11$ & F5 IV-V & $7$ & $7,000$ & $1.5$ & $1.4$\\\\ \\hline\n\t\tAchernar & $\\alpha$ Eridani & $0.46$ & $130$ & B3 V & $600$ & $18,500$ & $8$ & $1.9$ \\\\ \\hline\n\t\tBetelgeuse & $\\alpha$ Orionis & $0.5$ & $\\leq 420$ & M1-2 Ia-Iab & $9,000$ & $3,000$ & $30$ & $1,800$\\\\ \\hline\n\t\tHadar & $\\beta$ Centauri & $0.61$ & $\\leq 300$ & B1 III & $3,900$ & $21,500$ & $20$ & $4.3$\\\\ \\hline\n\t\tAltair & $\\alpha$ Aquilae & $0.77$ & $16$ & A7 V & $10$ & $8,000$ & $2$ & $1.5$\\\\ \\hline\n\t\tAldebaran & $\\alpha$ Tauri & $0.85$ & $55$ & K5 III & $110$ & $3,500$ & $4$ & $30$ \\\\ \\hline\n\t\tAntares & $\\alpha$ Scorpii & $0.96$ & $\\leq 500$ & M1,5 Iab Ib & $\\leq 8,800$ & $3,000$ & $25$ & $400$\\\\ \\hline\n\t\tSpica & $\\beta$ Vergini & $\\leq 300$ & $35$ & B1 III-IV+B2 V & $3,000$ & $21,500$ & $18$ & $4$\\\\ \\hline\n\t\tPollux & $\\beta$ Gemini & $1.14$ & $35$ & K0 IIIb & $35$ & $5,000$ & $3$ & $11$\\\\ \\hline\n\t\t\\end{tabular}}\t\t\n\t\t\\caption{Some stars data table}\n\t\\end{table}\n\t\n\t\\pagebreak\n\t\\subsubsection{Pulsative Variable Stars}\n\tThe stars of the main sequence of the Hertzsprung-Russell diagram are very stable objects. The gravitational force, which tends to contract the star, is exactly compensated by the internal pressure forces, which tend to dilate it. It's when the star becomes a red giant that sometimes the balance is upset. Thus began a phase of instability which results in significant variations in the brightness of the star.\n\n\tThe breaking of balance is caused by a complex phenomenon that involves variations of transparency of helium layers near the surface of the star. From there, the star begins to experience a series of expansions and contractions controlled by the forces that were formerly balance. When the pressure force prevails, the volume of the star increases. But the gravity slows the movement and eventually cause contraction. The volume of the star will pass below its average value, until the internal pressure opposes the contraction and managed to cause further expansion.\n\n\tIt is not the size changes that cause the variations in brightness, but those of the temperature. Indeed, as we have prove it earlier above, the brightness of a star varies with the fourth power of the temperature, while it varies with the square of the radius following for recall:\n\t\n\tWhen the volume of the star, however, is lower than average, the temperature is slightly higher and the brightness maximum. At the opposite, the temperature is slightly lower than average and the brightness minimum . The brightness of the star thus changes periodically, hence the name of \"variable star\" or \"pulsative variable star\".\n\n\tIt exists in the Hertzsprung-Russell diagram of a band of instability that crosses this diagram almost vertically just to produce the thermal phenomena in question.\n\n\tThe two main types of pulsating variables are the Cepheids and RR Lyrae stars. These bodies play a central role in astrophysics. Cepheids are stars of a few solar masses. They are in the helium burning phase after reaching the red giant stage. The stars of solar mass arrived at this point become RR-Lyrae stars. Their brightness varies with a period of between one day and several weeks. The remarkable property of Cepheids is the existence of a relation between the average brightness and the period of their oscillations. For example, the average brightness is $1,000$ times that of the Sun for a period of days and $10,000$ times that amount for a period of several weeks. It is this relation that makes Cepheids one of the basic tools of astrophysics.\n\t\n\tIf we know this relationship for a variable star, it is relatively easy, by the determination its period to derive its absolute magnitude $M$. By then measuring its apparent magnitude $m$ we can then calculate the distance in parsec with of the relation proved earlier above:\n\t\n\t\n\tOne of the main reasons for constructing the Hubble Space Telescope (HST) was to measure light curves of Cepheid variables in other galaxies. It is especially important to use Cepheids to measure distances to the galaxies in two nearby clusters: the Virgo Cluster (the nearest rich cluster), and the Fornax Cluster (a somewhat sparser collection of galaxies).\n\n\tHST can zoom in on a small portion of a galaxy to find and measure Cepheids:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/cepheid_hst_galaxy_ngc1365.jpg}\n\t\\end{figure}\n\tand the zoom inside the are of interest:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.62]{img/cosmology/cepheid_hst_galaxy_ngc1365_wfpc2_zoom.jpg}\n\t\t\\caption{Hubble Space Telescope Cepheid Measurement}\n\t\\end{figure}\n\tThe empirical period-luminosity relation for classical Cepheids was discovered in 1908 by Henrietta Swan Leavitt in an investigation of thousands of variable stars in the Magellanic Clouds. She published it in 1912 with further evidence. Once the period-luminosity relationship is calibrated, the luminosity of a given Cepheid whose period is known can be established. Their distance is then found from their apparent brightness. The period-luminosity relationship has been calibrated by many astronomers throughout the twentieth century, beginning with Hertzsprung. Calibrating the period-luminosity relation has been problematic; however, a firm Galactic calibration was established by Benedict et al. 2007 using precise HST parallaxes for 10 nearby classical Cepheids. Also, in 2008, ESO astronomers estimated with a precision within $1\\%$ the distance to the Cepheid RS Puppis, using light echos from a nebula in which it is embedded. However, that latter finding has been actively debated in the literature.\n\n\tThe following relationship between a Population I Cepheid's period $P_T$ (in days) and its mean absolute magnitude $\\bar{M}$ was established from Hubble Space Telescope trigonometric parallaxes for $10$ nearby Cepheids:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/period_cepheid_relation_plot.jpg}\n\t\t\\caption[Cepheid absolute magnitude - period plot]{Cepheid absolute magnitude - period plot (source: Wikipedia)}\n\t\\end{figure}\n\tLet us now try to derive theoretically such a period-luminosity relation! For this, we assume that fluid object (including a star) of radius $R$ has a fundamental pulsation period: \n\t\n\twhere $v_s$ is the sound speed. This is simply the time it takes a sound (or pressure) wave to cross the stellar diameter! But we have proved in the section of Music Mathematics (see page \\pageref{Newton-Laplace speed of sound relation}) that in the case of longitudinal sound waves in an isothermal sound we had the Newton-Laplace speed of sound relation:\n\t\n\tBut we know from virial theorem (\\SeeChapter{see section Continuum Mechanics page \\pageref{virial theorem}})\n\t\n\tOr written according to Astrophysics notation:\n\t\n\tReplacing $E_p$ by the potential gravific energy and $E_c$ by the kinetic of a particle in a gas, we get (we have already seen that also during our study of viriel theorem):\n\t\n\tUsing the relation (also proved during our study of the Newton-Laplace speed of sound relation):\n\t\n\twe get:\n\t\n\twhere we take for the Poisson constant $\\gamma=5/3$ as proved in the section of Thermodynamics (see page \\pageref{Poissons constant}) for an ideal mono-atomic gas.\n\t\n\tThe pulsation period is then:\n\t\n\tPlugging in numbers and normalizing with Solar mass and radius, we get:\n\t\n\tOne can derive the period-luminosity law as follows: Assume a sample of stars of the same mass (classical Cepheids have masses of $5-10$ solar masses), and the same temperature (the instability strip is approximately vertical in the H-R diagram). The bolometric luminosity then scales as $R^2$ as we have proved earlier above:\n\t \n\tThe pulse period scales as $R^{3/2}$ (see above!). Then it follows immediately that:\n\t\n\tAs we know we have also:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tIf we take the logarithm (it is more common in the field of Astrophysics...), we then get the \"\\NewTerm{cepheid period-luminosity relation}\\index{cepheid period-luminosity relation}\" (even if it should be named... \"cepheid period-absolute magnitude relation\" instead):\n\t\n\tAs we can see we are not too far from the experimental relation obtained thanks to Hubble observations given above (where we had $\\log(P_T) \\propto \\cong -0.4\\bar{M}$).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf any reader knows a more robust derivation and result and is in possessions of the detailed developments, don't hesitate to share the corresponding \\LaTeX text with us.\n\t\\end{tcolorbox}\n\t\n\tCepheids aren't perfect distance indicators. For one thing, their brightness and periods of pulsation can vary with their chemical composition. There's also the problem of crowding and confusion: what if our view of a distant galaxy appears to show a single, varying Cepheid star... but is really a combination of light from the Cepheid and several nearby stars, all mixed together?\n\t\n\t\\subsubsection{Neutron Stars (magnetars)}\\label{neutron star}\n\tA \"\\NewTerm{neutron star}\\index{neutron star}\" is the collapsed core of a large star ($10$ to $29$ solar masses). Neutron stars are the smallest and densest stars known to exist. With a radius on the order of $10$ [km], they can, however, have a mass of about twice that of the Sun. They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past the white dwarf star density to that of atomic nuclei (by the process of electron capture see in the section of Nuclear Physics at page \\pageref{electron capture}). Most of the basic models for these objects imply that neutron stars are composed almost entirely of neutrons, which are subatomic particles with no net electrical charge and with slightly larger mass than protons. They are supported against further collapse by neutron degeneracy pressure, a phenomenon described by the Pauli exclusion principle (see further below). If the remnant has too great a density, something which occurs in excess of an upper limit of the size of neutron stars at $2$-$3$ solar masses, it will continue collapsing to form a Black Hole (see proof further below).\n\t\n\t\\paragraph{Chandrasekhar limit}\\mbox{}\\\\\\\\\\\n\tWe have already determined in the section of Classical Mechanics (see page \\pageref{dark star escape velocity}) the Schwarzschild radius (in its classical form) that expresses the critical radius of a body for the release speed to it surface to be equal to that of speed of light. We obtained the following relation which typically expressed the radius that have a given celestial object to have a release speed equal to that of light:\n\t\n\tIn this particular case the star is what we named a \"Black Hole\". However, before the Black Hole, a star passes as we have spoken, by several intermediate steps by which it can also stabilize. Thus, you have often had to read in the literature that for a white dwarf to collapse into a neutron star, its mass must be greater than $1.4$ solar masses but without mathematical proof. Well, that's what we're going to demonstrate now!\n\n\tWe will introduce the subject by studying the influence of the uncertainty principle on the size of an atomic system (it limits the minimum dimension). This example is very powerful because it shows that the uncertainty principle not only governs the process of measurement but also the overall behaviour of quantum systems.\n\t\n\tThe first example that we can give is that of the hydrogen atom, not that we are expecting a new result from this method of analysis, but rather because we can expose the use of the principle of uncertainty and insist on its meaning.\n\t\n\tWe admit that the proton, whose mass far exceeds that of the electron, can be considered fixed. The energy of the electron is written:\n\t\n\tIn classical physics, a system whose energy is given by the previous relation does not have a minimum: if we tend $r$ toward zero by keeping the circular shape of the orbit, it is easy to see $E_\\text{tot}$ tends to $-\\infty$. On the other hand, in quantum physics, this limit has no meaning: the principle of uncertainty opposes to it.\n\n\tIn this case, the search for the minimum $E_1$ of $E_\\text{tot}$ takes a meaning, since a constraint appears which maintains this minimum at a finite value. It is determined in quantum physics (see the Bohr model of the atom in the section of Quantum Corpuscular Physics page \\pageref{bohr model}) and requires:\n\t\n\twhere $n\\in \\mathbb{N}$. However, this relation aside, if the radius $r$ of the atom becomes too small under external constraints (be careful, we get rid of the quantized orbits of the Bohr model of the atom which imposes a constraint on $p$) the linear momentum $p$ of the electron can not be less than the uncertainty $\\Delta p$ imposed by the uncertainty principle of Heisenberg (\\SeeChapter{see section Quantum Wave Mechanics page \\pageref{heisenberg uncertainty principle}}), since $\\Delta x$ is of the order of the radius $r$ of the atom. The shape itself of the preceding relation limits the scope of the method: we cannot expect to determine better than an order of magnitude of the minimum of $E_\\text{tot}$.\n\t\n\tIn order to evaluate the minimum $E_1$ of total energy, which we interpret as the ground state of the hydrogen atom, we calculate the minimum of $E_\\text{tot}$ by eliminating $p$ from the expression:\n\t\n\tby:\n\t\n\tWe get:\n\t\n\tThe radius $r_1$ of the atom in the ground state is the value of $r$ that gives $E(r)$ its minimum value:\n\t\n\twhich is the well-known expression of the Bohr radius seen in the section of Corpuscular Quantum Physics during our study of the Bohr model of the atom. The energy $E_1$ of the ground state is now easily calculable.\n\t\n\tThe purpose of this example is to show that with Heisenberg's uncertainty principle we can by very simple reasoning find the fundamental state of a system. This is exactly how we will proceed to determine the conditions that cause a star to return to its ground state.\n\t\n\tLet us attack now the study of a star. Schematically it consists of a mixture of two gases: one that is formed of nuclei on the one hand, and the electronic gas on the other.\n\t\n\tDuring the life of the star, many fusion processes took place. They each increased the size and mass of the nuclei. The iron ($\\mathrm{Fe}$), which is abundant at the end of a star's life, contains an average of $56$ nucleons (\\SeeChapter{see section Nuclear Physics page \\pageref{nuclear physics}}).\n\t\n\tThese nuclei are of a chemical or isotopic variety. As they are few in comparison with electrons, their pressure is that of a charged conventional gas, neutralized by the presence of electrons: it can be ignored, especially since the temperature is zero.\n\n\tThe electronic charge alone would not allow the electrons to resist the collapse of a star since the stellar matter is neutral. At very low temperatures, when the fuel is exhausted, the only pressure that the electronic gas can oppose to the hydrostatic pressure due to gravity is of quantum origin.\n\t\n\tAs a first approximation, the electrons thus exert on each other an apparent repulsion which is not of Coulomb origin (Pauli exclusion principle). As a first approximation, they obey a relation analogous to that of the atomic electron and which is written in the minimal case (or maximum of pressure):\n\t\n\twhere $d$ is the average distance between two neighbouring electrons.\n\n\tAt the temperature $T=0$ [K] equilibrium is reached when the total energy (the matter of the star) of the system is minimal.\n\t\n\tWhat happens if we try to evaluate the variation of the radius $r_\\text{WD}$ of the White Dwarf as a function of its mass $m_\\text{WD}$?\n\t\n\tThe gravitational potential energy of a star is given in good approximation by (\\SeeChapter{see section Classical Mechanics page \\pageref{gravitational potential energy}}):\n\t\n\tThe mass $m_\\text{WD}$ is approximately given by:\n\t\n\twhere $m_p$ is the mass of the proton and $N$ the number of nucleons contained in the star: the contribution of the electrons to the mass of the star is negligible and there is no need to distinguish between the mass of the neutron and that of the proton, almost identical.\n\t\n\tThe second contribution to energy is essentially that of the degenerate electronic gas (degeneration corresponds for recall to the existence of several states having the same energy), of kinetic origin. We could be tempted to write simply (assuming that the number of electrons is equal to the number of nucleons since we are for recall in the simplified hypothesis of a hydrogen gas):\n\t\n\tThis way of doing things leads to a dead end. If we request that the sum $E_p+E_c$ reaches a minimum value, we arrive at a value of the radius of the star so small that, by application of the relation:\n\t\n\tthe average velocity of the electrons $v$ would exceed that of the light!\n\t\n\tTo avoid this contradiction, we have to use relativistic mechanics that showed us that, in this case (\\SeeChapter{see section Special Relativity page \\pageref{special relativity}}), we can express the total energy as:\n\t\n\tif the numerical value of the kinetic energy significantly outweighs that of the energy at rest, then we have:\n\t\n\tand therefore:\n\t\n\tThe average distance $d$ between electrons is evaluated by assuming that the star is homogeneous, a sufficient approximation when we are looking for the order of magnitude of an average. We further simplify the geometry by admitting that each electron is surrounded by a spherical domain of radius $d$ in which there is no other electron of the same spin and where we can count only one electron of opposite spin. Since then:\n\t\n\tIt remains to evaluate the minimum of the sum:\n\t\n\tgiven the condition:\n\t\n\tThen it comes:\n\t\n\tand then:\n\t\n\tthat we write finally:\n\t\n\tFaced with this result, we are confronted with an unexpected situation. Indeed, if the factor:\n\t\n\tis positive, then the total energy of the White Dwarf is also positive, which means that the system is unbounded: the star is totally unstable (it has not reached its minimum energy threshold). It can only reduce its energy by increasing its radius without limits.\n\t\n\tWe see that the $K$ factor is negative if:\n\t\n\tIf the White Dwarf exceeds this mass then we can no longer deal with the problem with the previous equations. It then satisfies the equations governing a star composed only of neutrons (neutron star) and this is then another problem that we will not tackle here for now.\n\n\tThe (approximate) mass of the famous \"\\NewTerm{Chandrasekhar limit}\\index{Chandrasekhar limit}\" is thus given by:\n\t\n\tIt constitutes the mass beyond which a White Dwarf collapses into a Neutron Star.\n\t\n\tConventionally, astrophysicists associate this limit value with a multiplying factor of the mass of the Sun $M_\\odot$. We actually (numerically):\n\t\n\t\n\tIn the figure below on the left we have schematic slice through a neutron star. Letters N, n, p, e, $\\mu$ refer to the presence of nuclei, fluid neutrons and protons, electrons and muons, respectively. The inner core composition is still uncertain and various exotic possibilities exist, including hyperons and deconfined quark matter. \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/neutron_star_slice.jpg}\t\n\t\t\\caption{Neutron star slice}\n\t\\end{figure}\n\tOn the figure below we have an overview of what we expect to be the composition of the inner crust:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/neutron_star_inner_crust.jpg}\t\n\t\t\\caption{Neutron star inner crust}\n\t\\end{figure}\n\tAt lower densities, a lattice of super-heavy, neutron-rich nuclei is immersed in a fluid of neutrons (which are likely to be superfluid) and a relativistic electron gas. At high enough densities the nuclei might deform and connect along certain directions to form extended tubes, sheets and bubbles of nuclear matter. These nuclear pasta phases might form a layer at the base of the neutron star crust, sometimes referred to as the mantle. Ranges of density and thickness given for each layer represent current uncertainties in the physics of neutron star crusts.\n\t\n\t\\paragraph{Rotation break limit}\\mbox{}\\\\\\\\\\\n\tLet us make the simplifying assumption that the limit speed of rotation of a star (planet or star) is that which balances the centrifugal force and gravitational force on the surface of the star such that we are led to write (\\SeeChapter{see section Classical Mechanics page \\pageref{central force}}):\n\t\n\tWrite this relation supposes obviously that there is no connection other than the gravity which intervenes in the internal cohesion of the star. So the rotational time values we are going to get represent an upper bound (in the sense that the actual value is probably smaller).\n\t\n\tHe then comes from the previous relation:\n\t\n\tTo get the rotation time to which it corresponds it suffices to divide the perimeter at the equator by this speed:\n\t\n\tSo, for the Earth, we have as limit period of rotation before rupture:\n\t\n\tFor the sun:\n\t\n\tLet us now consider the case of the pulsar NP0532 which has a rotation of $33$ milliseconds\\footnote{In the beginning of the 21st century there is a project of NASA of using pulsars as interplanetary GPS.}. We would like to determine its radius. We then have using the previous relations:\n\t\n\tUsing the theoretical relation of the Chandrasekhar mass limit (since a Pulsar is a Neutron Star rotating rapidly on itself):\n\t\n\tWe then have for the radius of the smallest possible Pulsar according to these hypotheses (and approximations...):\n\t\n\tWith the following numerical application:\n\t\n\tWith the pulsar millisecond PSR J1748-2446ad having a period of 1.39 milliseconds we then fall on\\footnote{The slowest know pulsar known at the day we write these lines is PSR J0250+5854 with a rotation period of $23.5$ [s]. The faster pulsar is PSR J1748-2446ad with a rotation period of $0.00139$ [s]}:\n\t\n\twhat is remarkable (even if it is an approximation!) to think that such a quite huge mass can be contained in such a small radius. Note that for the latter it corresponds to respectively a maximum density of:\n\t\n\n\t\\paragraph{Neutron Star Masses and Densities}\\mbox{}\\\\\\\\\\\n\t If a nearly spherical star of mass $M$ and radius $R$ rotates with angular velocity $\\omega=2\\pi/R$ we know obviously that we have then equilibrium of the centrifugal force and gravitational bound a the equator at a given instant such that we are led to write (we make here an obvious classical approximation instead of using General Relativity that should be mandatory when dealing with huge masses):\n\t\n\tHence:\n\t\n\tAfter simplification:\n\t\n\tImplying:\n\t\n\tHence:\n\t\n\tAs the density of a ball is given by:\n\t\n\tWe then have:\n\t\n\tHence:\n\t\n\tThat latter relation gives a conservative lower limit to the mean density because a rapidly spinning star is oblate, which increases the centrifugal acceleration and decreases the gravitational acceleration at its equator.\n\n\tThe first pulsar discovered has a period of $T=1.3$ [s], so its mean density is at least:\n\t\n\tThe fastest known pulsar actually (year 2018), PSR J1748-2446ad, has $T=1.4\\cdot 10^{-3}$ [s] implying $\\rho>10^{14}$, the density of atomic nuclei!!!!! It has been calculated that this neutron star contains slightly less than two times the mass of the Sun, within the typical range of neutron stars. Its radius is constrained to be less than $16$ [km]. At its equator it is spinning at approximately $24\\%$ of the speed of light, or over $70,000$ km per second!!!\n\t\n\t\\paragraph{Neutron star magnetic field}\\mbox{}\\\\\\\\\\\n\tAs the star's core collapses, its rotation rate increases as a result of conservation of angular momentum, hence newly formed neutron stars rotate at up to several hundred times per second. Some neutron stars emit beams of electromagnetic radiation that make them detectable as pulsars. Indeed, the discovery of pulsars in 1967 was the first observational suggestion that neutron stars exist. The radiation from pulsars is thought to be primarily emitted from regions near their magnetic poles. If the magnetic poles do not coincide with the rotational axis of the neutron star, the emission beam will sweep the sky, and when seen from a distance, if the observer is somewhere in the path of the beam, it will appear as pulses of radiation coming from a fixed point in space (the so-called \"lighthouse effect\"). The fastest rotation rate for a neutron star was a rate of $716$ times a second or $43,000$ revolutions per minute, giving a linear speed at the surface on the order of $0.165 c$....\n\t\n\tSo now let us focus on the simplified math approach of the impact of the angular momentum conservation on the magnetic field of the Star. \n\t\n\tFrom the conservation of angular moment as the core collapses we have (\\SeeChapter{see section Classical Mechanics page \\pageref{moment of inertia}}):\n\t\n\tOr,  for a sphere of constant density  (\\SeeChapter{see section Geometric Shapes page \\pageref{inertia momentum ball}}):\n\t\n\tSo the final spin frequency is:\n\t\n\tor the final spin period is:\n\t\n\tThe magnetic flux $\\Phi$ ($\\vec{B}$ multiplied by $S$) through the surface of the core is also conserved in collapse. So roughly (\\SeeChapter{see section Electrodynamics page \\pageref{gauss law for magnetism}}):\n\t\n\tWhich means that:\n\t\n\tThe Sun and many other stars are known to possess approximately dipolar magnetic fields. Stellar interiors are fully ionized and hence good electrical conductors. Charged particles are constrained to move along magnetic field lines, and magnetic field lines are tied to the charged particles. When a star collapses from a radius $\\sim 10^{6}\\; [\\text{km}]$ to $\\sim 10\\; [\\text{km}]$, its cross-sectional area $a$ is divided by $\\sim 10^{10}$, its magnetic flux $\\Phi \\equiv \\int \\vec{B} \\cdot \\hat{n} \\mathrm{d}a$ (where $\\hat{n}$ is the unit vector normal to each infinitesimal surface area $\\mathrm{d}a$ ) is conserved, and the magnetic field strength is multiplied by $\\sim 10^{10}$. An initial magnetic field strength $B \\sim 100$ [G] becomes $B \\sim 10^{12}$ [G] after collapse, so young neutron stars should have very strong dipolar fields. The best models of the core-collapse process show that a dynamo effect can generate even stronger magnetic fields. Such dynamos may be able to produce the $10^{14}-10^{15}$ [G] fields observed in magnetars, which are neutron stars having such strong magnetic fields that their radiation is powered by magnetic field decay. Conservation of angular momentum during collapse increases the rotation rate by about the same factor, $10^{10}$, yielding initial rotation periods in the millisecond range.\n\t\n\t\\paragraph{Spin-Down Luminosity}\\mbox{}\\\\\\\\\\\n\tIf we now consider a neutron star as perfectly symmetric it's moment of inertia will be equal to:\n\t\n\tThe rotational kinetic energy of a canonical neutron star with the rotation period $T=0.033$ [s] of the Crab pulsar is\n\t\n\tAs magnetic dipole radiation extracts rotational energy, it slowly increases the period of a pulsar:\n\t\n\tNote that the period derivative $\\dot{T}$ is a dimensionless (seconds per second) pure number. Combining the observed period $T$ and period derivative $\\dot{T}$ yields an estimate of the rate $\\dot{E}$ at which the rotational energy is changing. The quantity:\n\t\n\tis called the \"\\NewTerm{spin-down luminosity}\". It is not a measured luminosity; it is the measured loss rate of rotational energy, which is presumed to equal the luminosity of magnetic dipole radiation. The spin-down luminosity is usually expressed in terms of the pulse period $T$ :\n\t\n\tand the prior-previous relation becomes:\n\t\n\tThe Crab pulsar has $T=0.033$ [s] and $\\dot{T}=10^{-12.4}$ (notice that the precision is so that pulsars can be used as galactic GPS!). If $I=10^{38}\\; [\\text{kg}\\cdot \\text{m}^{3}]$, its spin-down luminosity is:\n\t\n\tSo the luminosity of the low frequency magnetic dipole radiation from the Crab pulsar is comparable with the entire radio output of our Galaxy...\n\n\tArrived so far in the study of some very common stars models (excepted for black holes that are treated in the section of General Relativity page \\pageref{black hole}) it is maybe the right time to introduce this summary image:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/type_of_stars.jpg}\n\t\t\\caption[Star comparisons from black dwarf to hyper giants]{Star comparisons from black dwarf to hyper giants (author: Karl Garnham)}\n\t\\end{figure}\n\t\n\t\\pagebreak\n\t\\subsection{Galaxies}\n\tA galaxy is a gravitationally bound system of stars, stellar remnants, interstellar gas, dust, and (of the supposed...) dark matter. \n\n\tGalaxies range in size from dwarfs with just a few billion ($10^9$) stars to giants with one hundred trillion ($10^{14}$) stars, each orbiting its galaxy's center of mass. Galaxies are categorized according to their visual morphology as elliptical, spiral or irregular:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/classification_galaxies_spitzer.jpg}\n\t\t\\caption{Apparent stars speed anomaly in galaxies rotations}\n\t\\end{figure}\n\t Many galaxies are thought to have Black Holes at their active centers. \n\n\tIt seems that there is between $2\\cdot 10^{11}$ galaxies in the observable Universe following the actual estimates. Most of the galaxies are $1,000$ to $100,000$ parsecs in diameter and usually separated by distances on the order of millions of parsecs (or megaparsecs). The space between galaxies is filled with a tenuous gas having an average density of less than one atom per cubic meter. The majority of galaxies are gravitationally organized into associations known as galaxy groups, clusters, and superclusters. At the largest scale, these associations are generally arranged into sheets and filaments surrounded by immense voids.\n\t\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\resizebox{\\textwidth}{!}{\\begin{tabular}{|l|c|c|c|c|c|c|}\n\t\t\\hline\n\t\t\\rowcolor[HTML]{C0C0C0} \n\t\t\\textbf{Galaxy} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\textbf{Type}} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\parbox{1.8cm}{\\textbf{Distance ($\\pmb{10^3}$ {[}LY{]})}}} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\parbox{1.8cm}{\\textbf{Diameter ($\\pmb{10^3}$ {[}LY{]})}}} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\parbox{1.8cm}{\\textbf{Mass ($\\pmb{10^9}\\;[\\text{M}_\\odot]$)}}} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\textbf{Abs. Magn.}} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{C0C0C0}\\parbox{2cm}{\\textbf{Radial speed $\\pmb{[\\text{km}\\cdot\\text{s}^{-1}]}$}}} \\\\ \\hline\n\t\tMilky Way & Sb & - & $100$ & $150$ & $-20$ & - \\\\ \\hline\n\t\tLarge Magellanic Cloud & Irr I & $170$ & $23$ & $10$ & $-18.5$ & $+270$ \\\\ \\hline\n\t\tSmall Magellanic Cloud (NGC 292) & Irr I & $200$ & $10$ & $20$ & $-16.8$ & $+170$ \\\\ \\hline\n\t\tAndromeda (NGC 224) & Sb & $2,250$ & $160$ & $300$ & $-21.1$ & $-275$ \\\\ \\hline\n\t\tNGC 221 & E 2 & $2,150$ & $3$ & $3$ & $-16.4$ & $-210$ \\\\ \\hline\n\t\tNGC 205 & E 1 & $2,100$ & $6$ & $10$ & $-16.4$ & $-240$ \\\\ \\hline\n\t\tTriangulum Galaxy (NGC 598) & Sc & $2,250$ & $26$ & $10$ & $-18.9$ & $-190$ \\\\ \\hline\n\t\tNGC 147 & E 5 & $2,150$ & $3$ & $1$ & $-14.9$ & $-250$ \\\\ \\hline\n\t\tNGC 185 & E 5 & $2,150$ & $3$ & $1$ & $-15.2$ & $-300$ \\\\ \\hline\n\t\tIC 1613 & Irr I & $2,400$ & $3$ & $0.3$ & $-14.8$ & $-240$ \\\\ \\hline\n\t\tNGC 6822 & Irr I & $1,500$ & $6$ & $0.4$ & $-15.7$ & $-40$ \\\\ \\hline\n\t\tSculptor Galaxy (NGC 253) & E & $280$ & $3$ & $0.003$ & $-11.7$ &  \\\\ \\hline\n\t\tFornax Dwarf & E & $550$ & $6$ & $0.02$ & $-13.6$ & $+40$  \\\\ \\hline\n\t\tLeo I & E 4 & $750$ & $3$ & $0.003$ & $-11.0$ &  \\\\ \\hline\n\t\tLeo II & E 1 & $750$ & $3$ & $0.001$ & $-9.4$ &  \\\\ \\hline\n\t\tUrsa Minor Dwarf & dwarf & $220$ & $3$ & $0.0001$ & $-8.8$ &  \\\\ \\hline\n\t\tM82 of Ursa Major (NGC 3034) & Irr II & $10$ & $23$ & $30$ & $-19.5$ & $+400$ \\\\ \\hline\n\t\tM81 of Ursa Major (NGC 3031) & Sb & $10$ & $100$ & $200$ & $-21.0$ & $+80$ \\\\ \\hline\n\t\tM51 Whirlpool Galaxy (NGC 5194) & Sc & $13$ & $65$ & $80$ & $-19.7$ & $+550$ \\\\ \\hline\n\t\tNGC 5128 & E 0p & $16$ & $30$ & $1,000$ & $-20.0$ & $+260$ \\\\ \\hline\n\t\tM101 Pinwheel Galaxy  (NGC 5457) & Sc & $20$ & $200$ & $300$ & $-20.0$ & $+400.00$ \\\\ \\hline\n\t\tM83 Southern Pinwheel Galaxy (NGC 5236) & SBc & $26$ & $300$ & $1,000$ & $-20.5$ & $+320.0$ \\\\ \\hline\n\t\tM104 Sombrero Galaxy (NGC 4594) & Sa & $40$ & $30$ & $500$ & $-22.0$ & $+1,050$ \\\\ \\hline\n\t\tM87 Virgo A (NGC 4486) & E 1 & $50$ & $40$ & $300$ & $-22.0$ & $+1,220$ \\\\ \\hline\n\t\t\\end{tabular}}\n\t\t\\caption{Data table of some well known Galaxies}\n\t\\end{table}\n\tSize comparisons of some famous galaxies:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.55\\textwidth]{img/cosmology/galaxies_gallery.jpg}\n\t\t\\caption{Gallery of some galaxies}\n\t\\end{figure}\n\tSize comparisons of some famous galaxies:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/galaxies_size_comparison.jpg}\n\t\t\\caption[Size comparisons of famous galaxies]{Size comparisons of famous galaxies (author: Rhys Taylor)}\n\t\\end{figure}\n\t\n\t\\subsubsection{Probability of collisions in merging galaxies}\n\t\n\tStars collide with each other very rarely. The distance between neighbouring stars (at our position in the Milky Way Galaxy) is approximately equal to 10 million times the diameter of a star. By contrast, galaxies collide with each other quite frequently. The distance between neighbouring galaxies is approximately equal to 20 times the diameter of a galaxy.\n\n\tTo illustrate this difference, consider building a scale model of our galaxy in which the stars are represented by ping-pong balls. In this model, the distance between the Sun and Alpha Centauri will be 1100 kilometres (the distance between Columbus and Jacksonville, Florida). Now consider a scale model of the universe in which individual galaxies are represented by ping-pong balls. In this model, the Milky Way Galaxy and the Andromeda Galaxy will be a pair of ping-pong balls only 1 meter apart.\n\t\n\tLet's see what we get from some back-of-the-envelope estimates.\n\n\tImagine throwing one star (e.g., the Sun) at the other galaxy. How likely is it we'll hit a star in the other galaxy? Well, it's basically proportional to how big a target each star in the other galaxy is (its cross-sectional area) compared to the size of the whole galaxy, multiplied by the total number of stars in the target galaxy.\n\n\tLet's assume it's the Milky Way-Andromeda scenario, so each galaxy has about 100 billion stars, and each star is roughly the same size as the Sun (some are much larger, most are smaller). The actual target area for an individual star is a circle with twice the star's radius (we're counting one star just grazing the other as a collision). Let's also assume the stars are more or less evenly distributed in a circular disk. Since \"100,000 light years\" is a common (and not completely crazy) estimate of the Milky Way's size, that's a circle of radius = 50,000 light years (about $10^{16}$ meters).\n\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/colliding_galaxies_ngc_2207.jpg}\n\t\t\\caption{NGC 2207 is a pair of colliding spiral galaxies (source: NASA/Hubble)}\n\t\\end{figure} \n\t\n\tSo, let us consider two galaxies as perfect discs of $100$ billion ($10^{11}$) stars uniformly distributed in the disc going  in the target galaxy, each with target average radius $\\sim 2 R_{\\odot}$, gives us a total target area of:\n\t\n\tThe cross-section area of the target galaxy is:\n\t\n\t\n\tSo the probability of a typical average hitting a star in the other galaxy is :\n\t\n\tor about one in a trillion.\n\t\n\tThe odds of any star from our galaxy not hitting a star in the other galaxy would be\n\t\n\tSo there's only about a $10\\%$ chance of one (or more) of the galaxy's 100 billion stars hitting a star in the other galaxy. And the chances of any one particular star (like our Sun) hitting a star in the other galaxy is about one in a trillion.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tObviously we could use the binomial law to get the probability (or cumulated probability depending on what we want) that $k$ among $N$ start would get hit:\n\t\n\tor as the probabilities are very small and the population huge we could even use a Poisson distribution instead!\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Radial Speed Anomaly}\n\tIn 1978, Vera Rubin begins to observe that in galaxies, more the stars are distant from the galactic core, the more their angular velocity is high... The initial observation that uniformity of speed was unexpected because the theory of gravity Newton predicted that more distant objects have less speed. For example, the planets of the solar system orbit with a respective speed decreases while growing their respective distance from the Sun. We are left with the same problem: how to explain a point measurement is greater than the theoretical value?\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/apparent_anomaly_star_speed_galaxy_rotation.jpg}\t\n\t\t\\caption{Apparent stars speed anomaly in galaxies rotations}\n\t\\end{figure}\n\tAccording to Newton's laws, in a circular path, there is a as we know balance between the centripetal acceleration and gravitational attraction:\n\t\n\tThe volume of a disk galaxy of radius $R$ and thickness $e$ is (\\SeeChapter{see section Geometric Shapes page \\pageref{cylinder}}):\n\t\n\tIf we consider the mass of the galaxy almost entirely within the radius $R _ {\\max}$, corresponding to the maximum speed, of density $\\rho$ is given then by:\n\t\n\tMaking the approximation that the mass is substantially within the range corresponding to the maximum speed, we can write:\n\t\n\tWhich, introduced into the first equation but rearranged:\n\t\n\t gives:\n\t\n\tthe law that the maximum speed varies as the $1/4$ power of the mass. After that the speed decrease of the stars should decrease following:\n\t\n\tBut we must keep in mind that this is a two body relation! In the facts a galaxy should be considered as an isotropic fluid (like the rest of the universe) and therefore it is quite normal that the two-body assumption does not suite the observations. A galaxy can also not be consider as a solid cylinder otherwise by applying $v=\\omega r$ the speed of the stars should increase in proportion to the distance to the center of the galaxy.\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{90} & \\pbox{20cm}{\\score{4}{5} \\\\ {\\tiny 28 votes,  80.71\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Special Relativity}\\label{special relativity}\n\t\\lettrine[lines=4]{\\color{BrickRed}W}e have always considered until now in all our developments that the  interactions (cause and effect) between the body were instantly and the observation of a phenomenon took place instantly after it had taken place. Now, two physicists (Michelson and Morley) during an experiment discovered something that would change radically all of classical physics: the velocity (speed) of light was invariant (constant) regardless of the movement that we had relatively to it!\n\t\n\tThis observation is even more important that we know that is the light that allows us to perceive and feel things. It should also be taken into consideration that the electrostatic and magnetic fields are, as we have seen in the section of Quantum Field Theory, carried by the vector of interaction that is the photon that moves at the finite speed of light denoted by $c$. This fact also allows us to assume that the gravitational field also has an interaction vector (which would be the \"graviton\" whose existence seems indirectly proven but not yet confirmed) that propagates at the speed of light. It is therefore appropriate to take into account this non-immediacy and the consequences that this entails in the observed phenomena to finally be able to decide what is really of what seems to be.\n\t\n\tBefore we start with the calculations, we need to define a little bit what will be studied in this section (which applies not only to cosmology but... it seemed to us better to put it in this chapter rather than in the chapter of Mechanics or Atomistic).\n\t\n\t\\textbf{Definition (\\#\\mydef):} The \"\\NewTerm{Special Relativity}\\index{special relativity}\" is a theory confined to isolated inertial frames (Galileans), that is to say, the study of animated frames in a uniform (inertial) rectilinear motion. The reason of this will be given in the statement of Special Relativity principle (see below).\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} Restrict the study to inertial frames of course does not does not prohibit that within these, bodies can be animated of a uniform speed or not (an inertial rocket can have bodies inside itself that have a non-uniform movement)!\\\\\n\t\n\t\\textbf{R2.} General relativity's purpose (see corresponding section) is to take into account non-inertial frames and in any coordinate system by making use of the power of the tensor calculus to be applicable in any type of space (other than flat one!).\n\t\\end{tcolorbox}\t\n\tSpecial Relativity is mainly based on three important concepts:\n\t\\begin{enumerate}\n\t\t\\item The invariance postulate of speed of light\n\t\t\\item The cosmological principle (see below)\n\t\t\\item The principle of Special Relativity (see below)\n\t\\end{enumerate}\n\tIt is also important to inform the reader that we will use here many concepts seen in the section of Linear Algebra, Tensor Calculus, Trigonometry, Analytical Mechanics, Classical Mechanics, Electrostatics, Magnetostatics and Electrodynamics. It is therefore strongly advised to have covered these topics before at risk of not understanding what follows.\n\t\n\t\\subsection{Assumptions and Principles}\\label{special relativity assumptions and principles}\n\tPhysics laws express relations between the fundamental physical quantities. If the laws of physics are invariant under Galilean referential change as we have seen in the section of Classical Mechanics, it is not necessarily the same for physical quantities! These can transform from Galilean frame to another according to  simple transformation law as we have seen in the section of Classical Mechanics for velocity for example. It is the same in Special Relativity, but we must now consider what we neglected in our study of Galileo's transformations: the time lag is not the same for two observers if the speed of the light is finite, but the concept of time interval is supposed to be kept invariant!\n\t\n\t\\subsubsection{Postulate of Invariance}\\label{postulate of invariance}\n\tLaboratory measurements (Michelson-Morley experiment as we have already mentioned) have, for a long time, shown that the speed $c$ measured in an inertial frame (straight line and at constant speed) is constant regardless of its speed. Then we are taken to state the postulate of invariance of light: the speed of light (vector for the transport of ) can neither be added nor subtracted, to the drive speed of the frame in which we measure it (more clearly it means that no matter how fast you move, you will always measure the speed of light as being numerically finite and equal to $c=299,792,458\\; [\\text{km}\\cdot  \\text{s}^{-1}]$!).\n\t\n\tAs corollary the principle of Galilean relativity (\\SeeChapter{see section Classical Mechanics page \\pageref{Galilean Relativity Principle}}) according to this premise is completely at fault and then we have to develop a new theory that takes into account of this property of light.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is important to notice that we consider that light, within the framework of Special Relativity, the messenger of information from one body to another, that is to say the speed of causality effect!!!\n\t\\end{tcolorbox}\n\tOn Internet Forums a common and interesting question is: \\textit{Why is there a limit speed for causality and for the speed of light?}\n\t\n\tFirst, if the light speed would be infinite, we would not have light at all! Indeed, to see this, take a look at Maxwell's equations again, Note that in them we have the factor:\n\t\n\tso if we set $c\\rightarrow +\\infty$ then either (or both) of $\\mu_0$ and $\\varepsilon_0$ would have to be zero. This will effectively kill the existence of dynamic magnetic fields.\n\n\tEspecially, for light, it means that:\n\t\n\tSo, magnetic fields would be static (and of zero intensity, remember no magnetic monopoles known so far!). Thus the only thing left of electromagnetism would be simply electrostatics. Physically this also make sense, if $c\\rightarrow +\\infty$ the electric filed response to any rearrangement of charges would be instantaneous, so there is no place (time?) for a magnetic field response.\n\t\n\tThe existence of the speed limit for causality is related to the existence of time itself. Indeed, if there would be no speed limit, everything would happen instantly (as well as distance and consequently space by the way). It is difficult to imagine a Universe that evolve instantaneously. This is why we belong to a Universe where the is speed limit otherwise we would not be here to observe it...\n\t\n\t\\subsubsection{Cosmological Principle}\n\tWe assume that our position in the Universe is typical not only in space as stated in the standard model of the Universe (\\SeeChapter{see section Cosmogony page \\pageref{newtonian cosmological models}}), but also in time. Thus, an astronomer located in a remote galaxy must observe the same general properties of the Universe that we, he lived a billion years ago, or that he observed it in a billion years.\n\t\n\tIn fact, it is quite natural to go further and state that: the Universe looks the same in every point, that is to say, it is homogeneous. This homogeneity is therefore sets as the \"\\NewTerm{Cosmological Principle}\\index{cosmological principle}\".\n\t\n\tThis principle is not based actual 21th century observations because to much fragmentary compared to the huge size of the cosmos so that they can not establish its validity. It constitutes a presupposition for any physical study of our Universe. Its purpose is relative to its character, essential to any scientific cosmology study, and perhaps to a certain reaction to the geocentric or heliocentric old vision: it is assumed now that no place is special in the cosmos!\n\t\n\t\\subsubsection{Special Relativity Principle}\\label{special relativity principle}\n\tLet us recall (\\SeeChapter{see section Classical Mechanics page \\pageref{Galilean Relativity Principle}}) that the Galilean transformations tell us that no reference frame can not be considered as an absolute frame because the relations between the physical quantities are identical in all Galileans repositories (\"Galilean relativity principle\"). The Galilean motion is therefore relative!\n\t\n\tIn the 20th century physicists noted that an important class of physical phenomena violated the Galilean relativity principle: the electromagnetic phenomena!\n\t\n\tBy applying the Galilean transformations to Maxwell's equations, we get a different set of equations depending on whether the observer is in a fixed reference or a mobile reference frame.\n\t\n\tIndeed, we have proved in the section on Electrodynamics that the electric or magnetic field propagation equation could be written in one-dimensional space as the following d'Alembert equation:\n\t\n\twhere $\\psi$ represents any one of the two fields (electric or magnetic). We name this relation sometimes \"\\NewTerm{Hertz equation}\\index{Hertz equation}\".\n\t\n\tWe also saw in the section of Classical Mechanics that an important factor in the validity of a theory is the invariance of the expression of its laws under a Galilean transformation by putting:\n\t\n\tWe have also shown in the section of Differential and Integral Calculus that the total differential of a function was written (example with two variables):\n\t\n\tTherefore:\n\t\n\tWhich brings us to simply write (using the physicist method way of life...):\n\t\n\tAfter elimination of $f$ and using the Schwarz theorem (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{Schwarz theorem}}) and still the physicist way of life:\n\t\n\tIf we write the same with the time variable:\n\t\n\tUltimately the Galilean transformation of the wave equation supposedly have an invariant form becomes:\n\t\n\tTo fix the situation, following this example, we can state at least three assumptions:\n\t\\begin{enumerate}\n\t\t\\item[H1.] Maxwell's equations are false. The correct equations remain to be discovered and must be invariant under a Galilean transformation.\n\t\t\\item[H2.] Galilean invariance is valid for mechanics but not for electromagnetism (this is the historical solution before Albert Einstein, an \"ether\" determines the existence of a kind of absolute repository where Maxwell's equations do not change).\n\t\t\\item[H3.] Galilean invariance is false. There is a more general invariance, it remains to be discovered, which preserves the form of the Maxwell equations. Classical mechanics is to be reformulated so that it is invariant under this new transformation.\n\t\\end{enumerate}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt turns out that the first two assumptions are excluded by the experimental facts. Moreover, Maxwell's equations integrating the speed of light they are implicitly relativistic.\n\t\\end{tcolorbox}\t\n\tAlbert Einstein did not accept the violation of the Galilean relativity principle by electromagnetism. From his perspective, it was necessary to generalize it to all natural laws.\n\t\n\tHe postulated that the laws of physics should be the same in all repositories Galileans, which means, implicitly, that in the point of view of physical laws, it is not possible to distinguish one from another Galilean frame. This result is most commonly formulated as: no reference is privileged. This principle was named \"\\NewTerm{principle of relativity}\\index{principle of relativity}\". Indeed, this relativity is restricted to the case of Galileans frames (also named \"inertial frames\") exclusively.\n\t\n\tIn other words, the physic laws should remain unchanged after a change of reference. We must therefore identify new adequate transformations that will substitute to the Galilean transformations.\n\t\n\tIn the case of non Galileans frames repositories are not indistinguishable anymore. Indeed, imagine a person in a train moving at a constant speed and another person on land. Everyone can then say that it is the other who is in motion (relative) and indiscriminately. By cons, if the train begins to accelerate, although the two individuals can say that this is another speeding, only the one on the train will feel the effect of this acceleration ... and repositories are no more indistinguishable.\n\t\n\tAlbert Einstein abolished as well as the idea that there is an absolute reference point that does not move and on which we can define an absolute time, an absolute length or absolute mass. However, one can define a privileged reference point for every object in the Universe. It is the frame moving at the same speed and in the same direction as the object. The time measured in this privileged reference frame is minimal and is named the \"\\NewTerm{proper time}\\index{proper time}\". Similarly, the size of the object is maximum, it is his \"\\NewTerm{proper dimension}\\index{proper dimension}\" or \"\\NewTerm{proper distance}\\index{proper distance}\", and its mass is minimal, it is its \"\\NewTerm{proper mass}\\index{proper mass}\" (we will do the corresponding detailed mathematical developments further below).\n\t\n\t\t\\subsection{Lorentz Transformations/Boost}\\label{lorentz transformations}\n\t\tFor make possible to $c$ to be invariant (light speed invariance postulate), we must admit that time appears to not flow the same way for the observer $\\text{O}$ that is motionless than for the observer $\\text{O}'$ in a reference frame in uniform translation (i.e.: an inertial frame) in the direction of $x$  with relative velocity (the term \"relative\" is important!) $v$ (caution! the relative speed between the repositories is often denoted in the literature by $u$).\n\n\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\tA special case of disposal of referential frames in which the space axes are parallel leads to what we name the \"\\NewTerm{pure Lorentz transformations}\\index{pure Lorentz transformations}\" or \"\\NewTerm{special Lorentz transformations}\\index{special Lorentz transformations}\" and the relative displacement along a particular axis is often named a \"\\NewTerm{boost}\\index{boost}\".\n\t\t\\end{tcolorbox}\t\n\t\t\n\t\tTo study the behaviour of physic laws, we must bring two clocks that give the times $t$ and $t'$ (the referential frame that contains its clock/measuring instrument is named \"\\NewTerm{proper referential}\\index{proper referential}\" or \"\\NewTerm{proper frame}\\index{proper frame}\").\n\t\t\n\t\tLet's set up the following imaginary experiment:\n\t\t\n\t\tWhen the observers $\\text{O}$ and $\\text{O'}$ are superimposed, we set $t = 0$ and $t' = 0$ (clock time sync) and we emit a bright flash\\footnote{In fact we should consider the emission of \"an element of information\". Using light as an example is just convenient for pedagogical purposes. As we will see the results we will get further below involve a speed limit $c$ that is for sure the speed of light, but in reality we should consider light as a special case of the maximum possible speed of information transfer. The \"$c$\" can then be seen as the \"causality speed\".} in the direction of a point $A$ spotted by respectively $\\vec{r}$ and $\\vec{r}'$:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.9]{img/cosmology/lorentz_pure_transformations_experiment.jpg}\t\n\t\t\t\\caption{Configuration for the study of relativistic effects}\n\t\t\\end{figure}\n\t\tIt is obvious that when the flash arrive in $A$, the observer $\\text{O}$ will measure a time $t$ and $\\text{O}'$ a time $t'$.\n\t\t\n\t\tThe observer $\\text{O}$ therefore concludes:\n\t\t\n\t\tThe observer $\\text{O}'$ therefore concludes:\n\t\t\n\t\tSince the displacement of $\\text{O}'$ is made only along the $\\text{O}x$ axis, we have for the two observers:\n\t\t\n\t\tMoreover, if the path of the light beam coincides within the axe $\\text{Ox}$, we have:\n\t\t\n\t\tThis gives us then:\n\t\t\n\t\tAnd therefore:\n\t\t\n\t\tthese two relations are equal (zero) at any $x, x', t, t'$ between the two observers. These are the first \"relativistic invariant\" (equal values regardless of the frame), especially here is about the \"\\NewTerm{invariant interval}\\index{invariant interval}\" also named \"\\NewTerm{space-time interval}\\index{space-time  interval}\", that we find in a more generalized form when applied to the whole space:\n\t\t\n\t\tNow it should be remembered that in the classical model (Galilean relativity), we would have written that the position of point $A$ for the observer $\\text{O}$ from the information given by $\\text{O}'$ would be given by $x=x'+vt$ and vice versa (\\SeeChapter{see section Classical Mechanics page \\pageref{Galilean Relativity Principle}}) such as:\n\t\t\n\t\tIn the relativistic model, we must admit that time $t$ which is related to $x$ is not the same as $t'$ which is related to $x'$, relativity principle oblige (otherwise it would be difficult to explain the invariance of the speed of light)!\n\t\t\n\t\tWe are then led to try to write the above relation as follows:\n\t\t\n\t\twhere $\\lambda$ would be a numerical value to be determined from a given algebraic expression. Because to explain the constancy of the speed of light one possibility is that the space must constantly adjust according to our velocity $v$. What is revolutionary hypothesis as we have already mentioned!\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tA reader asked us why we could not write the last relation in the following simplified form (using the relation $x = ct$ obtained above) where point $A$ is on the $X$ axis:\n\t\n\tThe only reason is that later we will introduce a vector (matrix) notation of this result showing the concept of quadrivector (four-vector) and that it is in the first form of writing (this making explicit reference to time) that we can clearly make the concept of space-time emerge.\n\t\\end{tcolorbox}\n\tFurthermore, if $t\\neq t'$, we must also be able to express $t'$ as a function of $t$ and $x$ in a similar way:\n\t\n\tLet us summarize the shape of the problem:\n\t\n\twith $\\lambda$ to be determined and after:\n\t\n\twith $a,b$ to be determined.\n\tWe then seek to determine the relation that give us to know the values of the coefficients $a$,$b$ and $\\lambda$ that satisfy simultaneously:\n\t\n\tRemembering the previous developments and bearing in mind that in our special case $y '= y $and $z' = z$, the last equation becomes:\n\t\n\tLet us distribute:\n\t\n\tTo satisfy the relation:\n\t\n\tWe must have:\n\t\n\tIt is easy to solve (2):\n\t\n\tWe then introduce this result in (1) and (3) and we arrive at:\n\t\n\tIf we divide (1') by (2'), we get:\n\t\n\tand introducing this latter result into the relation:\n\t\n\twe obtain the following remarkable result:\n\t\n\tThat we frequently denote by:\n\t\n\tand which we name \"\\NewTerm{Michelson-Morley factor}\\index{Michelson-Morley factor}\\label{michelson morley factor}\" with:\n\t\n\tAlso introducing:\n\t\n\tin:\n\t\n\twe get:\n\t\n\tLet us write now (to comply with the traditional notations in this field):\n\t\n\twith therefore the parameter:\n\t\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! The \"Lorentz transformations\" are sadly sometimes interpreted by scientifically illiterate people and undergraduate students as a physical transformation. But it is not! It's just a mathematical transformation to explain what one reference frame sees in comparison of another one. Nothing more!\n\t\\end{tcolorbox}\n\n\t\\subsubsection{Displacement four-vector}\n\tWe derive the \"\\NewTerm{Lorentz transformation}\\index{Lorentz transformation}\" relations to pass from the values measured by $\\text{O}'$ to those measured in $\\text{O}$ and vice versa:\n\t\n\twho have for property to be covariant (that is to say their relations keep the same structure during a change of a Galilean reference system). We see through these relations that the concept of \"time\" is something individual relating to the movement we have over other (this is the \"\\NewTerm{proper time}\"). This is why it is not possible to define a \"common time\" between two people moving relatively and that don't know their respective relative speed (and even here we do not take into account the gravity that distorts space-time ... that we will study in the section of General Relativity).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf $v$ is much smaller than $c$, we fall back on the Galilean transformation as $\\gamma\\cong 1$ and $v/c^2\\cong 0$\n\t\\end{tcolorbox}\n\tWe can also write the last relations in a more useful way (the reader will notice that this time that for all relations the units of all the terms to the left of equality are the same: it is every time a distance!):\n\t\n\tOf course the difference is that the fourth dimension being the time coordinate of \"space-time\" seems at the contrary of the spatial coordinates to have a privileged direction: the \"\\NewTerm{arrow of time}\\index{arrow of time}\" (you can not go back to a given moment time given in the reality - as least as far as we know today - when it is possible when we traverse a purely spatial distance). The direction of time is imposed by the second law of thermodynamics as entropy can only increase (\\SeeChapter{see section Thermodynamics page \\pageref{entropy}}). If this were not the case then all time could already exist and we could travel in time as we travel on distances and therefore the future should be already written (people that believe in destiny like this...) and we could also go back in time.... However, thermodynamics does not give a particular direction to the time ... so if our time has the direction it has today.... it is because our universe was organized at its creation (so it had a low entropy).\n\t\n\tBy proceeding in a homogenisation of units to be able to use more modern and generalized maths than just simple algebra we can see that in fact when we travel in time we travel in physical point of view a distance $ct$. But because $c$ and $t$ are measured in arbitrary human being units physicists prefer to put $c=1$ we mathematical development become more complicate rather than changing the definition of time.\n\t\n\tNow we can put the Lorentz transformations of coordinate and time in the traditional following matrix form (\\SeeChapter{see section Linear Algebra page \\pageref{linear algebra}}) which defines the \"\\NewTerm{Lorentz matrix}\\index{Lorentz matrix}\" or \"\\NewTerm{Lorentz-Poincare matrix}\\index{Lorentz-Poincare matrix}\" or \"\\NewTerm{Lorentz boost}\\index{Lorentz boost}\\label{lorentz boost tensor}\":\n\t\n\tand reciprocally:\n\t\n\tand the reader can very easily control that with the two previous relations we fall back on:\n\t\n\tWe have also obviously:\n\t\n\tIn index form the matrix formulation is written:\n\t\n\twhich can therefore be written in tensor (\\SeeChapter{see section Tensor Calculus page \\pageref{tensor notation}}) form:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe can see the tensor (the matrix) of Lorentz transformation in some books in the condensed form $L(\\beta)$ and sometimes $L_\\nu^\\mu$ or even $\\Lambda_\\nu^\\mu$.\n\t\\end{tcolorbox}\n\tThe vector\\label{four-vector displacement}:\n\t\n\tis named \"\\NewTerm{space-time four-vector}\\index{space-time four-vector}\" or \"\\NewTerm{four-vector displacement}\\index{four-vector displacement}\".\n\t\n\tNotice that since:\n\t\n\tthe transformation by the matrix $L_\\nu^\\mu$ conserves the norm (Lorentz invariance\\label{lorentz invariance}). In geometric terms it is thus a \"\\NewTerm{isometry}\\index{isometry}\" or an invariance of the dot product by Lorentz transformation.\n\t\n\tLet us prove this explicitly following the request of a reader! We will take again for the proof only a movement along $x$ and we use:\n\t\n\tAs $y'=y$ and $z'=z$ to simplify the development we will ignore these both components.\n\t\n\tWe will also put to simplify $c=1$ and therefore $v$ is expressed in percentage of $c$ and becomes $v=\\beta$:\n\t\n\tNow we calculate:\n\t\n\tand as $\\gamma^2(1-\\beta^2)=1$ we get indeed:\n\t\n\t\n\t\\paragraph{Wave Equation Invariance}\\mbox{}\\\\\\\\\\\n\tNow that we have determined the Lorentz transformations, we can check whether the wave equation is invariant with respect to the latter (remember that we have proven earlier that it was not invariant under a Galilean transformation!!!).\n\t\n\tStarting from the Lorentz transformation written in explicitly:\n\t\n\twe calculate the partial derivatives with respect to $x$ and $t$ (the expression after the second equality has already been proven earlier in this section):\n\t\n\tThese relation can also be written:\n\t\n\tSquared:\n\t\n\tIn the Maxwell's equations, or rather in the propagation equation of the electric or magnetic field in vacuum, we have proven (\\SeeChapter{see section Electrodynamics page \\pageref{electromagnetic wave equation}}) that the following operator appeared:\n\t\n\tSubstituting in it the previous differential expressions:\n\t\n\tWe therefore have well:\n\t\n\twhich shows that a Lorentz transformation leaves invariant this operator (Jackpot!). So we got what we were looking for (the wave equation but in the other reference frame)!\n\n\tThe reader will also have notice that this only works if and only if the wave propagation speed is the speed of light!\n\n\t\\paragraph{Hypergeometric interpretation}\\mbox{}\\\\\\\\\\\n\tNow let us come back to our Lorentz transformations. Let us recall that we have restricted ourselves to the special case where the space axes were parallel (what brought us to define the \"pure Lorentz transformations\"). This special configuration has an interesting geometric property that sometimes many books use.\n\n\tLet us see what this is about:\n\t\n\tWe have seen in the context of the study of the Lorentz transformations of lengths that we had a special transformation (boost) along one axis, ie the $x$-axis, requiring in this case for the other components:\n\t\n\tThis allows us to  reduce the transformation matrix $L_\\nu^\\mu$ ($4\\times 4$ matrix that we obtained earlier above) to a $2\\times 2$ matrix of components $A$, $B$, $C$ and $D$ such that:\n\t\n\tWe notice that the components $A$, $B$, $C$, $D$ respect by construction the following expressions:\n\t\n\tThe first relation can be related with the remarkable identity in hyperbolic trigonometry (\\SeeChapter{see section Trigonometry page \\pageref{hyperbolic trigonometry}}):\n\t\n\tAnd therefore:\n\t\n\tand the second relation that there exists $\\alpha_2$ such that:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe choice of the \"$-$\" sign for $B$ and $C$ is useful because as we always have $\\beta \\geq 0$ (same for $\\gamma$ that is strictly positive) it will impose us at the end of the calculations to have $\\alpha\\geq 0$. Therefore, as $-\\gamma\\beta\\leq 0$ and $\\alpha\\geq 0$ the only way for $C$ (and also for $B$) to be negative is to put a \"$-$\" sign.\n\t\\end{tcolorbox}\t\n\tThe third then gives the remarkable addition relation:\n\t\n\tand therefore the difference $\\alpha_1-\\alpha_2$ that we will denoted more simply by $\\alpha$ is equal zero. Which validate the relations:\n\t\n\tThe matrix is therefore presented as follow:\n\t\n\tThis is (by analogy to the classical one), a \"\\NewTerm{hyperbolic rotation matrix}\\index{hyperbolic rotation matrix}\\label{hyperbolic rotation matrix}\". We will not go further on this analogy as it is not used for practical cases study in this book.\n\t\n\tFinally, the special Lorentz transformation of velocity $v$ along the $x$-axis can also be written:\n\t\n\twhich brings us to write:\n\t\n\tThe dimensionless quantity $\\alpha$ is named \"\\NewTerm{rapidity}\\index{rapidity}\" by those who use physics in high energy. The advantage of working with angles is to make the combination of $2$ boosts easier.\n\n\tWe will stop here regarding the geometric study of Special Relativity finding personally that it has less and less interest to proceed so today (even it is quite funny).\n\t\n\t\\subsubsection{Velocity four-vector}\\label{four vector velocity}\n\tWe can also determine the Lorentz transformations for speed. Let us consider again a particle moving in an inertial reference frame O' such that at time $t'$, its coordinates are $(x ', y', z ').$:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/lorentz_pure_transformations_experiment.jpg}\t\n\t\\end{figure}\n\tTherefore, the components of the velocity $v'$ are:\n\t\n\tSo what are the components of the velocity in O (remember that O' go away at speed $v$!)?\n\t\n\tAgain, we write:\n\t\n\tWe can differentiate by the time the components of the transformation equations we obtained before and thus we can write:\n\t\n\tTherefore we have:\n\t\n\tand also same:\n\t\n\tand:\n\tand also same:\n\t\n\tAnd as the constant speed of reference frame $O'$ is given by $\\beta=v/c$, we then have:\n\t\n\tand vice versa:\n\t\n\tWithin the limit of classical mechanics, where the speed of light was supposed instantaneous and therefore $c\\rightarrow$, we fall back on:\n\t\n\twhich are the Galilean transformations such as we have seen them in the section of Classical Mechanics.\n\n\tAs we can see, the speeds transformations do not follow too much the shape of the Lorentz matrix that we determined above for the coordinates. Physicists, not liking what is inhomogeneous, sought to have the same transformations for both.\n\n\tThus, let us take again the speed transformations and let us rewrite  them as below:\n\t\n\tThese relation can be written differently if we calculate:\n\t\n\tThus simplifying a bit:\n\t\n\tLet us put:\n\t\n\tand:\n\t\n\tand:\n\t\n\twhere the latter equality means that in order to simplify that the inertial speed and thus the study of only a single component is sufficient and that is the one collinear with the axis of movement.\n\n\tWith this notation and simplifying it will be easy to determine the temporal component, indeed the relation:\n\t\n\tis the written:\n\t\n\tThe reader will have perhaps notice that we therefore have three $\\Gamma$: one related to the inertial speed, the second related the norm of the vector of the particle in the reference frame O and the third related to the norm of the vector in the reference frame O'. But actually following our simplification made earlier above we know that in the repository O' the particle is at the origin in $Y'$ and $Z'$.\n\n\tBy doing the same for each of the spatial components, we will get in the end:\n\t\n\tand here we have reached our goal of homogenization that allows us to write if we put:\n\t\n\tthe following system:\n\t\n\tthat is written in tensor form  sometimes as:\n\t\n\tThe vector:\n\t\n\tis itself named the \"\\NewTerm{four-vector velocity}\\index{four-vector velocity}\".\n\t\n\t\\subsubsection{Current four-vector}\\label{four-vector current}\n\tWe have defined naturally during our introduction of the electromagnetic tensor field (\\SeeChapter{see section Electrodynamics}) the four-vector current:\n\t\n\tthat we can write:\n\t\n\tThis means that charge density is related to time, while current density is related to space.\n\t\n\tTherefore, considering $\\rho_0$ as the charge density in the proper frame moving with velocity $v$ relative to reference frame O' and due to length contraction in the direction of the velocity, the volume occupied by a given load will be multiplied by the factor $\\gamma(\\vec{v})$ so that:\n\t\n\twhich is none other than the \"\\NewTerm{four-current}\\index{four-current}\" where we see back the four-vector velocity previously determined.\n\t\n\t\\subsubsection{Acceleration four-vector}\n\tHaving previously obtained a four-vector velocity transformable thanks to the Lorentz matrix let us also look for the equivalent for acceleration.\n\n\tThe four-vector acceleration is naturally expressed as the derivative with respect to the proper time of the four-velocity $u$ such that:\n\t\n\tLet us just recall that the proper time of a particle is the time measured in the coordinate system of the particle, that is to say, in the reference frame where it is motionless. The proper time in the literature is often denoted $\\tau$.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe must be careful and check that the corollary of the assumption of the equivalence principle is true otherwise all General Relativity would collapse (in the early 21st century experiments are still going to try to show a default to this principle)!\n\t\\end{tcolorbox}\t\n\tThe reader must first admit that (we will prove this further below) that:\n\t\n\tTherefore, we have:\n\t\n\tIf we introduce the ordinary acceleration $\\vec{a}=\\mathrm{d}\\vec{v}/\\mathrm{d}t$ we see that:\n\t\n\tthen:\n\t\n\tUsing the vector identity, dual vector product, (\\SeeChapter{see section Vector Calculus page \\pageref{grassman rule}}):\n\t\n\twe then find that the four-vector acceleration can be written:\n\t\n\t\n\tThe vector:\n\t\n\tis named \"\\NewTerm{four-vector acceleration}\\index{four-vector acceleration}\" and therefore also transformed using the Lorentz matrix.\n\t\n\tWe see that if this $v\\ll c$ and $\\vec{a}=\\vec{a}_0$ the last relationship simplifies to:\n\t\n\tWe thus fall back on the classic acceleration.\n\n\tUsing the Minkowski metric (see definition further below), denoted $\\eta_{uv}$, let us calculate the norm of the four-vector acceleration:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt must be well understood that when we write $(\\vec{a}+\\vec{\\beta}\\times(\\vec{\\beta}\\times\\vec{a}))^2$ it is implicit in this case that we do sum of the squares of the components of the calculations in the brackets.\n\t\\end{tcolorbox}\t\n\tAnd as:\n\t\n\tand:\n\t\n\twe put this together to get:\n\t\n\tNow we develop the sum $a_ia^i$ of the big parenthesis that becomes therefore:\n\t\n\tWe simplify:\n\t\n\tHence:\n\t\n\tBut we have the relation:\n\t\n\tand the property of the cross product:\n\t\n\tWhich finally gives us:\n\t\n\tThe relation\\label{norm of relativistic acceleration}:\n\t\n\twill be extremely useful to us when we will study the Abraham-Becker radiation damping force in the section of Electrodynamics (see page \\pageref{Abraham-Becker radiation damping force}).\n\t\n\tNow imagine an object with a uniformly accelerated relative motion $\\vec{}_0^2$ (constant acceleration) in our own repository. If we assume our repository as fixed, we have $\\vec{v}=\\vec{0}\\Leftrightarrow \\vec{\\beta}=\\vec{0}$. Therefore:\n\t\n\tVerbatim after rearranging the terms and taking the square root if the accelerated motion is made only along a single component:\n\t\n\tBut, we also have:\n\t\n\tSo finally, we can write:\n\t\n\tWhich after integration gives:\n\t\n\tWe see that the speed $u$ never reaches $c$ while the force (acceleration implicitly) is always the same!\n\n\tSo we have:\n\t\n\twhich gives us:\n\t\n\tAfter rearranging, we write this:\n\t\n\tWe are far from the relation of uniformly accelerated motion we have proved in the section of Classical Mechanics and that is for recall:\n\t\n\tHowever, for $t$ close to zero, we fall back on the same Classical Mechanics relation by taking the Taylor expansion to the second order of the square root (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tHowever, this does not give us the relations of transformation of acceleration components in a simple form. Let's see how to get them.\n\n\tFirst let us recall that we have obtained for speed:\n\t\n\tThen it comes by differentiating:\n\t\n\ttherefore:\n\t\n\tLet us recall now that we have proved that:\n\t\n\tdifferentiating it comes:\n\t\n\tWe can write:\n\t\n\tAfter simplifying and rearranging we get obviously:\n\t\n\tHence:\n\t\n\thence finally:\n\t\n\tand for the components $y$, $z$:\n\t\n\tand therefore:\n\t\n\tSo finally:\n\tSo finally:\n\t\n\tRemember that these relations apply when the movements of the reference frames are in uniform translation!\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! It is a common misconception that we cannot speak about acceleration in Special Relativity. But that's a wrong belief from scientifically illiterate people and undergraduate students as we have just seen it! What we can't do with acceleration in Special Relativity is to use a simple Lorentz transformation for the acceleration or to found time and space Lorentz boosts that includes acceleration. That's all!!!!\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Relativistic sum of velocities}\n\tAs the speed of light is a speed supposed unsurpassable, we now come to ask ourselves what will be finally the speed of an object launched at a speed close to that of light (for example...) from a reference frame moving also close to that of the speed of light (why not...).\n\n\tWe must then find a relationship that gives the real speed $V$ from the launch speed $v_2$ and speed of the repository $v_1$.\n\n\tWe know that for the object launched:\n\t\n\tAs the one who is concerned does not know the real speed $V$, it should use the Lorentz transformations. Thus, given the expression of $t'$ that we saw earlier it comes:\n\t\n\tand given the prior-previous expression of $x'$ we also have:\n\t\n\ttherefore after rearranging and simplifying a bit:\n\t\n\tHence:\n\t\n\tWe know that $v=x/t$ so we finally the \"\\NewTerm{law of compositions relativistic speeds}\\index{law of compositions relativistic speeds}\" or simply \"\\NewTerm{velocity-addition formula}\\index{velocity-addition formula}\" or \"\\NewTerm{Einstein's velocity addition}\\index{Einstein's velocity addition}\" relation:\n\t\n\twhich is then the speed of a moving body in the moving reference frame relatively to that seen as the rest frame (but that in fact should also move at any speed less then $c$).\n\n\tAnd conversely seen from the other moving frame of reference, we have by the same developments (with reverse signs and speed of course):\n\t\n\twhich is the speed of a moving body in the rest frame relatively to that considered as being in motion (or in other words seen by the moving frame of reference).\n\t\n\tNotice that for small speeds, we fall back obviously on the Galilean addition relation:\n\t\n\tIf we take the speed of light as one of the velocities, we get:\n\t\n\tHence the speed of light cannot be surpassed!\n\t\n\tOn the other hand, if we take two velocities smaller than that of light, we have, with $v_1=c-\\lambda$, $v_2=c-\\mu$ and $\\lambda,\\mu>0$:\n\t\n\tThen it is not possible to reach the speed of light by adding speed less than that of light!\n\t\n\t\\subsubsection{Relativistic lengths variation (length contraction)}\n\tLet us consider now that the length of an object is given by the distance between its two ends $A$ and $B$. Let us consider this object $\\overline{AB}$ motionless in the repository $\\text{O}'$ in uniform translation and oriented along the axis $\\text{O}'X'$:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/lorentz_pure_transformations_experiment.jpg}\t\n\t\\end{figure}\n\tIts length is then the distance between its both ends:\n\t\n\tFor the observer O, the object is moving. The positions $A$ and $B$ should therefore be measured simultaneously:\n\t\n\tSo it comes using the relation proved earlier in this section:\n\t\n\tthe following difference:\n\t\n\thence the remarkable result:\n\t\n\twe also find the relation frequently in the literature as follows:\n\t\n\tThus, the length of an observed rule in a moving frame relatively to the proper frame of the rule is less than its own length (which can assimilate in generality to a \"\\NewTerm{proper length}\\index{proper length}\"). In other words, the length of a moving object measured by the fixed reference frame will be measured shorter than its real proper size. This phenomenon is named \"\\NewTerm{length contraction}\\index{length contraction}\".\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.95]{img/cosmology/start_trek.jpg}\t\n\t\t\\caption[Length contraction principle for straight motion]{Length contraction principle for straight motion (source:?)}\n\t\\end{figure}\n\tDue to superficial application of the contraction formula some paradoxes can occur. Examples are the ladder paradox and Bell's spaceship paradox. However, those paradoxes can simply be solved by a correct application of relativity of simultaneity. Another famous paradox is the Ehrenfest paradox (high relativistic speed \"rigid\" rotating disc\\footnote{Circumference of a rotating disk should contract but not the radius, as radius is perpendicular to the direction of motion.}), which proves that the concept of rigid bodies is not compatible with relativity, reducing the applicability of Born rigidity, and showing that for a co-rotating observer the geometry is in fact non-euclidean and then we need then to use General Relativity.\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! As we already have proved it earlier length contraction when expressed in the formalism of matrix algebra is in fact a rotation in space-time (a hyperbolic rotation as we have seen it earlier!!!)! So physically a object isn't smaller when moving, but is just seen with a different angle (ie in a different perspective angle) than the perpendicular one by default (at $v=0$) in space-time, and hence it looks smaller (however length contraction is also not a visual effect as may make think the last sentence!).\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Relativistic time variation (time dilatation)}\\label{relativistic time variation}\n\tAn event is a phenomenon that occurs in a given place at a given time. The origin of time is difficult to determine, we often prefer to define the concept of time interval as the time elapsed between two events as it is often customary (\\SeeChapter{see section Principia page \\pageref{time}}).\n\t\n\tLet us now consider two consecutive events $A$ and $B$ that occur at the same location $x'$ (!) in the repository in uniform translation:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/lorentz_pure_transformations_experiment.jpg}\t\n\t\\end{figure}\n\tFor the observer in $\\text{O}'$, the time interval is simply:\n\t\n\tTo measure this time interval, the observer O in the fixed reference repository should also require that $x'$ is common to both events. Then using the relation proved earlier above:\n\t\n\twe get:\n\t\n\thence the remarkable result:\n\t\n\twhat we write under traditional condensed form:\n\t\n\tWe also deduce taking an infinitesimal time element:\n\t\n\tSo the observer O (stationary) measures a time interval much larger than that one measured in the moving repository where the phenomenon takes place as it moves quickly. The time in the fixed repository (thus the \"\\NewTerm{proper time}\\index{proper time}\" of the fixed reference frame!) seems like dilated compared to that in occurring in the mobile reference frame (that is to say relatively to the \"proper time\" of mobile reference frame!).\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! A common error in Special Relativity is to think that time dilation is physical/real, ie the people moving will age more slowly. But that's wrong in Special Relativity (but not in General Relativity) and for exactly the same reasons as for the length dilatation (you just have to consider the axis of space $ct$ instead of the axis of pure time $t$).\n\t\\end{tcolorbox}\n\t\n\tLet us see two application examples that are so famous that they have their even a name so that we will consider them as an table of contents entry of our book:\n\t\n\t\\paragraph{Hafele–Keating experiment (special relativity version)}\\label{hafele keating experiment special relativity}\\mbox{}\\\\\\\\\\\n\tIn 1971, direct experimental verification of time dilation was performed. Two airplanes in whose had been placed a cesium atomic clock during their regular commercial flights (one flying to the east, the other to west) compared their clocks to a third  atomic clock remained on the ground. This experiment made famous by time is named today \"\\NewTerm{Hafele-Keating experiment}\\index{Hafele-Keating experiment}\" ( Joseph C. Hafele, a physicist, and Richard E. Keating, an astronomer).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/hafele_keating_experiment.jpg}\n\t\\end{figure}\n\tBecause the Hafele–Keating experiment has been reproduced by increasingly accurate methods, there has been a consensus among physicists since at least the 1970s that the relativistic predictions of gravitational and kinematic effects on time have been conclusively verified. Criticisms of the experiment did not address the subsequent verification of the result by more accurate methods, and have been shown to be in error.\n\n\tThe idea is obviously that in a frame of reference at rest with respect to the center of the Earth, a clock aboard the plane moving eastward, in the direction of the Earth's rotation, has a greater velocity (resulting in a relative time loss) than one that remained on the ground, while a clock aboard the plane moving westward, against the Earth's rotation, had a lower velocity than one on the ground.\n\t\n\tThe plane flying eastward lost $59$ [ns] while the plane flying westward gained $273$ [ns] (the Earth rotates on itself in a day, from West to East. It was therefore measured a total difference:\n\t\n\tbetween the two clocks and this difference is even statistically significantly greater than that the one implied by Special Relativity (see detailed calculations just below).\n\n\tLet us analyse the experience considering that all repositories are inertial (thus eliminating General Relativity).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tStrictly speaking, the effect of General Relativity (slowing of clocks depending on the altitude in accordance with Einstein's effect proved in the section of General Relativity) is absolutely not negligible since it is equivalent in amplitude that of Special Relativity. This is why we will study this experiment again in the section of General Relativity.\n\t\\end{tcolorbox}\n\tLet us consider for our study  three inertial reference points, one at the North Pole, one on Earth (elsewhere apart from the North Pole in the idea!) and one in a plane. The time intervals $t_{\\text{North}},t_{\\text{Earth}}$ and $t_{\\text{plane}}$ respectively (which we will abbreviated $t_N,t_E,t_P$ for the following developments), are connected by the previously proven relations (so the North pole is taken as the reference at rest in this experience and therefore the reference proper time!):\n\t\n\twhere we have:\n\t\n\tThe repository on Earth and in the plane so have equation relative speeds $v_E$ and $v_P$ relative to the North Pole. The time by plane and on Earth are then linked by:\n\t\n\tWe will now rewrite this relation:\n\t\n\tWe will accept the following approximation:\n\t\n\twhere we have assumed that at the denominator:\n\t\n\tFor square roots whose value is anyway close to $1$ (since $c$ is much larger than the considered relative speeds), we can do a Maclaurin expansion to the second order as $x$ approaches zero (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tThen we can write:\n\t\n\tThanks to these tricky successive approximations, we can easily write the difference between the two clocks that is then:\n\t\n\tAccording to the initial assumptions, the cruising speed of the two aircraft from the ground is constant and is denoted $v$. The speed of each plane (!non-relativistic according to the preceding approximations) is then:\n\t\n\tfor the plane going eastwards and:\n\t\n\tfor the aircraft going respectively westward. So:\n\t\n\tWe will consider that (it's pretty rough ...):\n\t\n\tSo it remains:\n\t\n\tWe see well that obviously with the previous approximations we lost the asymmetry of time dilatation between East and West. The reader that this should disturb can then apply directly the numerical values in the prior previous relation.\n\n\tThe previous result that we get we all successive approximations already lead us to see formally and quickly that the sign of the result will be in agreement with experimental results.\n\n\tFor a practical numerical application, we will take the constant speed of the commercial planes at that time that was:\n\t\n\tand the total time travel of planes was of $41$ hours according to the measurement at the ground, thus:\n\t\n\tand a point at equator of the Earth's surface go at the speed:\n\t\n\twhere the Earth's radius being of $6,371$ [km] (this suppose that the plans are above the equator radius). We then have applying all that numerical values:\n\t\n\twhich leads to a result very close to the measurement that was performed.\n\n\tAnd using directly the non-approximate version:\n\t\n\twhere we took this time the speed of the Earth at latitude consistent with the experience in 1971:\n\t\n\tSo we see that the result is therefore not very consistent with the experience! Indeed, we must now consider in that approximated case the time dilatation due to gravity. We'll have to use the Einstein's effect relation proved in the section of General Relativity for approximated locally flat space:\n\t\n\twhich expresses for recall the that at the ground time flows slower than the time at altitude $h$.\n\t\n\tAccording to the records of the experiment, the aircraft flew at $10,000$ [m] above sea level. What gives (the acceleration $g$ is not the same on the ground level than in altitude for recall!) and acceleration of time of:\n\t\n\tBut, we see that the two aircraft were both at the same height, we always have:\n\t\n\tSo either there are other effects, of the order of General Relativity, which should be taken into account to explain the $67$ [ns] of difference to the experience, or it is a accuracy problem of the time accuracy of the time clock at the time of the experiment.\n\n\tIn fact, we will see a detailed study of this experience in the section of General Relativity and see that the theoretical values are in very good agreement with experimental results.\n\t\n\t\\paragraph{Twins paradox}\\mbox{}\\\\\\\\\\\n\tThe twin paradox is a thought experiment in Special Relativity involving identical twins, one of whom makes a journey into space in a high-speed rocket and returns home to find that the twin who remained on Earth has aged more. This result appears puzzling because each twin sees the other twin as moving, and so, according to an incorrect and naive application of time dilation and the principle of relativity, each should paradoxically find the other to have aged more slowly. However, this scenario can be resolved (again contrary to a popular misconception) within the standard framework of Special Relativity: the travelling twin's trajectory involves two different inertial frames, one for the outbound journey and one for the inbound journey, and so there is no symmetry between the space-time paths of the two twins. Therefore, the twin paradox is not a paradox in the sense of a logical contradiction.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.5]{img/cosmology/twin_paradox.jpg}\n\t\\end{figure}\n\tWe can already consider the famous twin paradox in the framework of Special Relativity to show that the twin paradox does not only apply to non inertial systems. This is a rough approach (knowing that will rigorously discussed the subject in the section of General Relativity).\n\n\tLet us consider a rocket taking off at time $t$ zero of the Earth and accelerating to $20$ times the acceleration of Earth's gravity $g$ up to a cruising speed of $90\\%$ the speed of light $c$. Let us suppose that the rocket continues at this speed during a terrestrial year and decelerate with the same intensity to resume its journey to Earth and accelerates again for its approach to the Earth and decelerate once again to its final zero velocity.\n\t\n\t\n\tThus, the total proper time spent for a human remained on Earth is:\n\t\n\tFor the traveller in the rocket, the proper time during the acceleration phase will be given roughly by:\n\t\n\tThus by integrating (using the usual primitive proved in the section of Differential and Integral Calculus page \\pageref{usual primitives}) for one of the phase of acceleration of the rocket it gives:\n\t\n\tAnd the proper time for the part with the constant cruising speed:\n\t\n\tAnd therefore the total proper time in the rocket is:\n\t\n\tSo compared to the person remained on Earth, the one that was in the rocket has aged about half !!! This is a paradox (rather a \"sophism\" in reality) because we can not accurately apply Special Relativity to non-inertial frames. Nevertheless, even with General Relativity, there is a time difference!\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! But we haven't solved the Langevin's paradox here! Because in the framework of Special Relativity both observers can be switched independently. And that's the problem of making the calculations with Special Relativity: the acceleration is relative. That doesn't make sense in real life (even if it's possible on the paper) because in reality, one of the observer will feel an acceleration and deceleration when the other one won't. And that's what General Relativity can deal with: it makes acceleration absolute!\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Apparent relativistic mass}\n\tFirst the reader must take care (!!) the title is misleading by tradition! We will see why a little further below.\n\n\tMeanwhile, imagine a frontal collision between two identical objects $(1)$ and $(2)$ having in the repository $R_0$ equal but opposite speeds. We will assume that the collision is elastic, that is to say that the kinetic energy and momentum are conserved.\n\n\tBefore the shock (collision), the components of objects speeds $(1)$ and $(2)$ are:\n\t\n\tas shown below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/relativistic_mass_collision_01.jpg}\n\t\t\\caption{Configuration for the study of the apparent relativistic mass variation seen from $R_0$}\n\t\\end{figure}\n\tAfter the collision, we have:\n\t\n\tWe will now apply the following Lorentz transformation:\n\t\\begin{itemize}\n\t\t\\item We give ourselves another repository $R$ and assume that the repositories $R_0$ and $R$ are in uniform translation speed $u_1$ along the $x$-axis in the positive direction (that is to say in the same direction and at the same horizontal speed than the particle $(1)$).\n\t\t\n\t\t\\item For our particle $(1)$ its trajectory became such is present not visible speed anymore along the $x$-axis.\n\t\\end{itemize}\n\tLet's go! Let us place ourselves in repository $R$ that moves relative to $R_0$ with the speed $u_1$ following the $x$-axis, the components of the speeds in this repository are ten before the collision:\n\t\n\tand after the collision:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/relativistic_mass_collision_02.jpg}\n\t\t\\caption{Configuration for the study of the apparent relativistic mass variation seen from $R$}\n\t\\end{figure}\n\tSo we have trivially in the reference frame $R$:\n\t\n\tbut by applying the law of composition of speeds proved earlier above:\n\t\n\tfor the components of the horizontal axis we always have in the reference frame $R$\n\t\n\tand for the vertical movement, we have earlier above that:\n\t\n\tTherefore we get:\n\t\n\tPassing from $R_0$ to $R$, the component following $y$ of the total momentum must remain zero (as it was the case in $R_0$ initially). But:\n\t\n\tTo break this deadlock, we must admit that the respective apparent masses $m_1$ and $m_2$ may not be identical in $R$. So that brings us to request that:\n\t\n\twhich leads us to:\n\t\n\tIn $R$, the square of the norm of the two objects speeds gives:\n\t\n\tThe last relation can be written:\n\t\n\tso that after rearrangement and factorization we get:\n\t\n\tTherefore:\n\t\n\tWe thus found:\n\t\n\tIn the case as assumed above where both object are identical we will put $m_1=m_2=m_0$ and therefore:\n\t\n\tAnd we will put them as an apparent relativistic denoted simply by $m$ such that:\n\t\n\tAnd as $V_1^2$ and $U_2^2+V_2^2$ are simply the square norm of the velocity, we can write:\n\t\n\tSo that finally:\n\t\n\tSo we see that when $v=0$, we have $m=m_0$ this is why we name $m_0$ the \"\\NewTerm{rest mass}\" or \"\\NewTerm{invariant mass}\\index{invariant mass}\".\n\t\n\tSince the mass is a function of $v$ (at least in appearance), some physicists note the rest mass as a function, that is to say: $m(0)$. But it is rather more common to use the $m_0$ to not have too much in parentheses in developments...\n\t\n\tAs the Michelson-Morley factor $\\gamma$ tends to infinity when the speed $v$ approaches the speed $c$ of light in a vacuum we have an additional reason to say that $c$ is the upper limit assigned to the speed of any material object otherwise the apparent mass $m$ would be infinite also, which is consistent with both the experience and the consequences already formulated by the Lorentz transformations!!!\n\t\n\tIt already follows an important conclusion: there are therefore two types of particles, those with a mass and will never go to the speed of light (as it then takes an infinite energy to get them there following our previous result), and those having a zero mass and which will therefore necessarily be at the speed of light.\n\t\n\tAs we will see it in the section of Quantum Field Theory interaction forces are short-range precisely because of the uncertainty principle and of the above statement. The greater the distance is between large particles that interacts together, the more time will be longer and therefore the small will be the energy involved. But in the case where the particle of interaction have no mass, the \"force\" is a long range one.\n\t\n\t\\pagebreak\n\t\\paragraph{Mass–Energy equivalence}\\label{mass energy equivalence}\\mbox{}\\\\\\\\\\\n\tUnder the action of a force $F$, the speed of a mass $m$ increases or decreases on each portion of the trajectory. The work of the component $F\\mathrm{d}x$  can then be interpreted into kinetic energy $\\mathrm{d}E_c$.\n\n\tIn the relativistic theory, the mass varies with speed as we have just prove it, therefore:\n\t\n\tThe integration by parts (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{integration by parts}}):\n\t\n\tgive us:\n\t\n\tThe gain of kinetic energy of a particle can be considered as gain in its apparent mass. Since $m_0$ is the rest mass, the quantity $m_0c^2$ is named \"\\NewTerm{rest energy}\\index{rest energy}\" of the particle.\n\n\tWe then have:\n\t\n\twhere $E_c$ represents the energy of motion (kinetic energy).\n\n\tThe sum of:\n\t\n\ttherefore represents the total energy $E$ of the particle in the absence of the potential field. Which brings us to write:\n\t\n\tAnd therefore:\n\t\n\tMany physicists like better to write that latter relation as following:\n\t\n\tSo what you have to understand with this relation is that when for example (special case example!) you heat up an object in everyday life, you are increasing its mass even if it is not perceptible with a domestic balance!\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/eintein_trial.jpg}\n\t\\end{figure}\n\tFinally we could also get the same result in another way using Lagrangian mechanics (\\SeeChapter{see section Analytical Mechanics page \\pageref{lagrangian mechanics}}) as shown below:\n\t\n\t\\paragraph{Relativistic Lagrangian}\\label{relativistic lagrangien}\\mbox{}\\\\\\\\\\\n\tThe following developments will help us in the study of Electrodynamics (if this section has not been read yet), to determine the expression of the tensor of the electromagnetic field and in Relativistic Quantum Physics to determine the Klein-Gordon equation with magnetic field. So be sure to carefully read what follows.\n\n\tIn special relativity, so we want the equations of motion have the same form in all inertial frames. For this, we need the action $S$ (\\SeeChapter{see section Analytical Mechanics page \\pageref{action integral}}) to be invariant with respect to Lorentz transformations. Guided by this principle, trying to get the action of a free particle. Suppose that the action is in the reference frame O':\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} The choice of the minus sign will be evident in our study of electrodynamics.\\\\\n\t\n\t\\textbf{R2.} The notation $L_0$ instead of the $L$ of Lagrangian lets just emphasize that this is a case study where the system is free. This distinction of notation will be useful in our study of General Relativity and determination of the Tensor of the Electromagnetic field in the section of Electrodynamics.\\\\\n\t\n\t\\textbf{R3.} We are not supposed to know what kind of mass we are dealing (inertial rest mass), hence the fact that in the ignorance, we will work with the inertial mass $m$ to perhaps correct this hypothesis later if necessary.\n\t\\end{tcolorbox}\n\tAnd let us recall that:\n\t\n\tIn the repository O, then we have the \"\\NewTerm{Lorentz invariant action}\\index{Lorentz invariant action}\":\n\t\n\tSo according to our initial hypothesis, we have for the relativistic Lagrangian (in the absence of potential field... since the system is assumed to be \"free\"):\n\t\n\tIn the non-relativistic approximation $v\\ll c$, we have following the Maclaurin development of the square root (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tWe thus fall back on the usual Lagrangian of a free system in movement but more a constant $(-mc^2)$ that does not affect the equations of motion we get in Classical Mechanics but that will be absolutely necessary in to us in Electrodynamics.\n\n\tLet us recall now that the generalized momentum (\\SeeChapter{see section Analytical Mechanics page \\pageref{general momentum}}) is defined by:\n\t\n\tWe will now see that this definition is not accidental. Indeed:\n\t\n\tThe Hamiltonian (\\SeeChapter{see section Analytical Mechanics page \\pageref{hamiltonian mechanics}}) is equal to:\n\t\n\tWhich gives:\n\t\n\tThe Hamiltonian is in this case equal to the total energy of the particle. Its expression led us to change somewhat our initial hypothesis and finally to write $m_0$ instead of $m$ in the expression of the action $S$.\n\n\tSo we finally have the Lagrangian of a free relativistic particle\\label{lagrangian free relativistic particle}:\n\t\n\tand the corresponding Hamiltonian:\n\t\n\tIn the non-relativistic approximation $v\\ll c$, $H_0$ becomes with a Maclaurin development (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tWe recognize the usual kinetic energy, plus a constant: the energy at rest. Which corresponds to the calculations we had made before where we got:\n\t\n\n\t\\paragraph{Relativistic (linear) momentum}\\label{relativistic linear momentum}\\mbox{}\\\\\\\\\\\n\tThe total energy $E$ and the (linear) momentum $p=mv$ of a particle can therefore take any positive value (when the speed approaches the limit value $c$, the apparent mass suits for the product $p=mv$ to not be bounded).\n\n\tIn the expression of $E$, we can replace the speed $v^2$ by a function $p^2$:\n\t\n\tintroduced into:\n\t\n\twe have:\n\t\n\tTherefore:\n\t\n\thence (we will come back on that relation of the utmost importance during our proof of Einstein relation):\n\t\n\tWe have not kept the negative part of the previous relation as it has no meaning in classical physics. However, when we will study Relativistic Quantum Physics, it will be essential to preserve it otherwise we will get absurdities.\n\n\tHowever, we can obviously write this last relation also in the following form named \"\\NewTerm{relativistic mass momentum relation}\\index{relativistic mass momentum relation}\\label{relativistic mass momentum relation}\":\n\t\n\tor also (ugly!):\n\t\n\tIn other words, the total energy of a moving particle is equal to its mass energy added to its kinetic energy (basically nothing new).\n\t\n\tThe relation above has two limit cases where we can simplify it:\n\t\\begin{enumerate}\n\t\t\\item For a particle at rest ($p = 0$), we can reduce the expression to:\n\t\t\n\t\tby omitting the negative energy ... at least for now.\n\n\t\t\\item We can apply the equation to a particle without mass to eliminate the first term, which then gives us:\n\t\t\n\t\tA photon, for example, has a zero rest mass but it is never at rest ...by definition, it is a quantum of energy, kinetic energy is never zero and so it has a mass corresponding to its kinetic energy. Thus, a massless particle at rest moves at the speed of light, regardless of the chosen repository frame! Conversely, a particle with a non-zero rest mass can never reach the speed of light in any repository.\n\t\\end{enumerate}\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} As we prove it further below (see the \"Einstein relation\"), from the construction of Planck's law (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}}), we can write $E=pc=h\\nu$.\\\\\n\t\n\t\\textbf{R2.} The mass of the photon can hardly be non-zero! Indeed, quantum theory would be false otherwise. But it has never fail until now (\\SeeChapter{see section Wave Quantum Physics page \\pageref{wave quantum physics}}). We would also have a small change on the Electrostatic force following that it is given by the Yukawa potential (\\SeeChapter{see section Quantum Field Theory page \\pageref{yukawa potential}}) and this would have been observed in laboratory since...\n\t\\end{tcolorbox}\n\tLet us now look after the relations between $p$ and $p'$ and between $E$ and $E'$, to make it possible for O' to write:\n\t\n\tWe then begin to get rid of the square root:\n\t\n\tIf O write:\n\t\n\tO' must be able to write:\n\t\n\tTherefore we have:\n\t\n\tIf we identify:\n\t\n\twe obtain similar expressions to those used for the Lorentz transformations of spatial and temporal components. We can then write, by similarity, that the changes to the (linear) momentum and energy are therefore given by:\n\t\n\tAgain, if we take:\n\t\n\n\tWe therefore have by expressing all previous relations of transformation in the same units by remembering that $E\\equiv pc$ (for a photon!):\n\t\n\tWe can the define a matrix such that:\n\t\n\twhere we fall back on the \"Lorentz matrix\" or \"symmetric Lorentz tensor\" ${L'}_\\mu^\\nu$\n\n\tThe vector:\n\t\n\tis meanwhile, named the \"\\NewTerm{four-vector energy-momentum}\\index{four-vector energy-momentum}\\label{four momentum}\" or just \"\\NewTerm{four-momentum}\\index{four-momentum}\" Its utility is that its value is also conserved and this is especially useful for the study of nuclear reactions. If we add these vectors on all particles (without forgetting the photons as well!!!) before and after the reaction, we should found the same quantities for the $4$ components!\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} The inverse transformation being done obviously with the inverse matrix that we have already outlined earlier above.\\\\\n\t\n\t\\textbf{R2.} We use in Relativistic Optics the four-vector $(\\omega/c,\\vec{k})$, where $\\omega$ is for recall the pulsation of the wave and $\\vec{k}$ the wave vector (\\SeeChapter{see sections Wave Mechanics and Wave Optics page \\pageref{pulsation frequency period wave number}}). This four-vector is the equivalent for an electromagnetic wave of the four-vector $(E/c,\\vec{p})$ for a particle multiplied by the reduced Planck's constant $\\hbar=h/2\\pi$. Indeed, the wave-particle duality (\\SeeChapter{see section Wave Quantum Physics page \\pageref{wave quantum physics}}) attributes to a wave an energy\\label{wave number special relativity} according to the Planck-Einstein relation (\\SeeChapter{see section Corpuscular Quantum Physics page \\pageref{planck einstein relation}}):\n\t\n\tand a linear momentum which norm is:\n\t\n\t\\end{tcolorbox}\n\tNow let us come back on the following relation is central in some areas of quantum physics:\n\t\n\tTherefore:\n\t\n\tWhich can be written in vector form (very common form):\n\t\n\tThis latter relation will be very useful in the section of Relativistic Quantum Physics to calculate the energy of virtual photons exchange.\n\n\tFor photons, since the mass is zero, we have:\n\t\n\tFinally let us also notice that the four-momentum is also related to a another quantity name \"\\NewTerm{four-wave vector}\\index{four-wave vector}\" as following:\n\t\n\tas we know that (for the first component):\n\t\n\tand that for all other components that as:\n\t\n\t\n\t\\subparagraph{Einstein relation}\\mbox{}\\\\\\\\\\\n\tFollowing the principle of relativity, we wish that the relation between the linear momentum and energy of an electromagnetic wave can be written in the same way for two inertial observers in translation relative to the other:\n\n\tIf O writes:\n\t\n\tthen O' must be able to write:\n\t\n\tLet the take the first relation above and put it to the square without forgetting that the photon has a zero rest mass $m_0$. Therefore:\n\t\n\tand as $m_0=0$ for the photon:\n\t\n\tGiven the known Planck's law (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}}):\n\t\n\twe are led to write the famous \"\\NewTerm{Einstein's relation}\\index{Einstein's relation}\\label{Einstein's relation}\" that we will find very often in Quantum Physics and in Thermodynamics:\n\t\t\n\tSo even if the photon has no mass at rest, it has a \"\\NewTerm{relativistic mass}\\index{relativistic mass}\". This relativistic mass is in Special Relativity for the photon the equivalent to the electric charge in Electrodynamics.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that a priori nothing seems to prevent us to write $E=h\\nu=mc^2$. Therefore it means that without mass there is no frequency. By extrapolation in a Universe without mass (made only of radiation) there is no clock and therefore no time and hence no distance. In the late 20th century this is speculative and need to be verified experimentally if it's possible...\n\t\\end{tcolorbox}\n\t\n\t\\subparagraph{Time of flight}\\mbox{}\\\\\\\\\\\n\tSuppose we get a beam made of massive particles. The rest mass  is $m_0$. The particle travels a distance $L$ in its inertial frame. The particle has an energy $E$ in that frame. Therefore, the so-called \"\\NewTerm{time of flight}\\index{time of flight}” from two points at $x=0$ and $x=L$ will be:\n\t\n \twhere we use the relativistic definition of momentum:\n\t\n\tNow, knowing that the relativistic energy is:\n\t\n\tusing the time that a mass-less light beam uses to travel the proper distance $L$, easily calculated to be:\n\t\n\t we get:\n \t\n\tBut we have just proved that:\n\t\n \tTherefore:\n \t\n\tand then:\n \t\n\tThus, the time of flight is finally written as follows:\n \t\n\tThis equation is very important in practical applications. Specially in Astrophysics and baseline beam experiments, like those involving the neutrinos! Indeed, we usually calculate the difference between the photon (or any other massless) time of arrival and that of massive particles, e.g. the neutrinos. Several neutrino experiments can measure this difference using a well designed experimental set-up. The difference between those times of flight (the neutrino time of flight minus the photon time of flight) is:\n\t\n\tor equivalently:\n \t\n\tor as well:\n \t\n\tThis last expression can also be expressed in terms of the speed of light and neutrinos, since:\n\t\n\tso:\n\t\n \tTherefore:\n \t\n\tIn the case of know light left-handed neutrinos, the rest mass is tiny (likely sub-[eV] and next to the [meV] scale), and then we can make a Taylor expansion for $Q$ if:\n \t\n\tThen:\n\t\n\tThen, we would expect, accordingly to Special Relativity, of course, that:\n\t\n \tWe can guess how large it is plugging \"typical\" values for the neutrino mass and energy. For instance, taking $m_\\nu\\cong 1$ [meV] and $E\\cong 1$ [GeV]  the $Q$ value is about $10^{-24}$.\n \n\tNowadays, we have no clock with this precision, so the neutrino mass measurement using this approach is impossible with current technology. However, it is clear that if we could make clocks with that precision, we would measure the neutrino mass with this \"time of flight\" procedure. It is a challenge. We can not do that in these times (circa 2012), and thus we don't measure any time delay in baseline experiments. Then, neutrinos move with $v_\\nu=c$ and since there is no observed delay (beyond the OPERA result, already corrected), neutrinos are, thus, ultra-relativistic particles, and for them $E=pc$ with great accuracy.\n\t\n\t\\subparagraph{Relativistic force}\\mbox{}\\\\\\\\\\\n\tFollowing the principle of relativity, we want that the relation between force and linear momentum to be written in the same way by two inertial observers in translation relative to each other!\n\n\tTherefore if O writes:\n\t\n\tO' must be able to write:\n\t\n\tThe relation between $\\vec{F}$ and $\\vec{F}'$ is quite complicated in the general case. We will limit ourselves here to the particular case where a body is momentarily at rest in O' and therefore where the observer O' will only take into account the force $\\vec{F}'$ that he applies. He will name this the \"\\NewTerm{proper force}\\index{proper force}\" because it has not to worry about other forces (such as centrifugal force, for example).\n\n\tIt is necessary to substitute $p'$ and $t'$ by $p$ and $t$ in:\n\t\n\tSince:\n\t\n\twe will have:\n\t\n\tWe have seen also previously that:\n\t\n\tTherefore it remains:\n\t\n\tThe component of the force is therefore invariant in the direction of the movement.\n\n\tFor the directions $y$ and $z$ perpendicular to the movement:\n\t\n\tSo for summary:\n\t\n\tHowever, to change from one reference frame to another, it is better to use again the \"\\NewTerm{four-vector force}\\index{four-vector force}\" defined as the derivative of the four liner moment vector with respect to the proper time:\n\t\n\tIndeed, let us recall that:\n\t\n\t\n\t\\pagebreak\n\t\\subsubsection{Relativistic electrodynamics}\\label{relativistic electrodynamics}\n\tWith a mass spectrometer we establish that the ratio $m / q$ of the mass $m$ of a particle by its electrical charge $q$ varies in the same way as the mass $m$ when the velocity $v$ of the particle varies:\n\t\n\tThus, it comes that:\n\t\n\tThe charge of a particle is therefore independent of its velocity, as we have proved in the section of Electromagnetism (\\SeeChapter{see section Electrodynamics page \\pageref{charge conservation equation}}) when determining the charge conservation equation.\n\n\tLet us consider now two charges $q$ and $Q$ immobile a reference frame O' in translation at speed $v$ with respect to another one centered on O:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/electric_field_lorenz_transformation.jpg}\n\t\t\\caption{Configuration for the study of transformations of electric and magnetic fields}\n\t\\end{figure}\n\tWe will restrict ourselves to the case where the velocity $\\vec{v}$ is parallel to the O$x$-axis:\n\t\n\tand we write the vector at the horizontal to spare time and paper...\n\n\tThe electric charge $Q$ is place on O' and is therefore fixed for O'. The observer O' makes the conclusions that an electrostatic force:\n\t\n\tact on the reference particle $q$ placed on $\\vec{r}'$:\n\t\n\tThe observer O also sees an electrostatic field $\\vec{E}$ in $\\vec{r}$, but he also sees that $Q$ is in movement along the O$x$-axis. He thus deduces the existence of a magnetic field $\\vec{B}$ on $\\vec{r}$ oriented in the plane $YZ$ plane:\n\t\n\tIt therefore measures the supposedly known Lorentz's force (\\SeeChapter{see section Magnetostatics page \\pageref{lorentz force}}):\n\t\n\tBut:\n\t\n\tTherefore:\n\t\n\tWe have now seen:\n\t\n\tThe comparison of the expressions above gives the relativistic transformations of the electric field:\n\t\n\tAs for the Lorentz transformation of the spatial and temporal components, we have obtained the inverse transformations by exchanging the fields and considering that O' sees O going back away (we therefore replace $v$ by $-v$).\n\n\tThe above relations, sometimes named \"\\NewTerm{Joules-Bernoulli equations of the electric field}\\index{Joules-Bernoulli equations of the electric field}\", make it clear that if, for example, the electric field in one of the reference systems is zero but the magnetic field is not, then an electric field exists from the point of view of the other reference frame !!! It is therefore an absolute victory of relativity in comparison to classical mechanics!\n\n\tTo get the relativistic transformations of the magnetic field, we proceed as follows:\n\t\n\tAfter some small manipulations of very elementary algebra, we get:\n\t\n\tWe do the identically:\n\t\n\tAfter a few simple manipulations of very elementary algebra, we get:\n\tAnd so on. Finally, we get:\n\t\n\tThe above relations, sometimes named \"\\NewTerm{Joules-Bernoulli equations of the magnetic field}\\index{Joules-Bernoulli equations of the magnetic field}\", make it clear that if, for example, the magnetic field in one of the reference frame is zero but the electric field is not, then a magnetic field exists from the point of view of the other reference fame !!! It is therefore once again an absolute victory of relativity in comparison to classical mechanics!\n\n\tLet us now study the behaviour of the electromagnetic field of a moving charge:\n\n\tLet us consider two parallel referentials O and O', in translation at constant velocity $v$ along the axis $XX'$:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/lorentz_configuration_study_for_electromagnetic_transformations.jpg}\n\t\t\\caption{Configuration for the study of electrodynamic transformations}\n\t\\end{figure}\n\twhere a fixed electric charge $Q$ is placed at O '.\n\n\tIt is clear that the observer O measures $\\vec{B}=\\vec{0}$ everywhere and that at the point $P$ of the plane $X 'Y'$, on $\\vec{r}'=(x',y',0)$ he measures the electrostatic field (\\SeeChapter{see section Electrostatics page \\pageref{coulomb force}}):\n\t\n\tIf the observer O is informed of the values of $\\vec{E}'$ and of $\\vec{B}'=\\vec{0}$, he can introduce them into the relativistic transformation giving the electric field $\\vec{E}$ that he observes:\n\t\n\tTo write an expression of the field $\\vec{E}$ at the point $P$, the observer O must determine, at a time $t$ of its local time, the components of the vector $\\vec{r}=(x,y,0)$ which separates the point $P$ from the electric charge $Q$ (by summing the position vectors of the latter two material points).\n\n\tThe coordinates of the point $P$ and of the charge $Q$ that he sees in the plane $XYZ$ are given by the usual Lorentz transformations:\n\t\n\tHe thus easily deduces, by summation, the distances $x$, $y$.\n\n\tAnother simpler possible method is that since the $x$ component is a length, it therefore undergoes Lorentz transformations and:\n\t\n\tSince for recall:\n\t\n\tThe relativistic transformation of the electric field then gives:\n\t\n\tand:\n\t\n\tWritten in vector form:\n\t\n\tWe must also determine how to express $r'$ as a function of $r$:\n\t\n\tas (Pythagorean theorem):\n\t\n\tThe writing is simplified if we use the angle formed by the electric field vector and the $x$-axis. We then denote then $\\theta'$ in O' and the $\\theta$ in O the angles given by:\n\t\n\twith $\\theta\\geq \\theta'$ due to the expansion of the lengths along the $x$-axis.\n\n\tWe eliminate $y$ with:\n\t\n\tThus, the electric field $\\vec{E}$ that sees O is given by:\n\t\n\tThe factor containing $\\sin(\\theta)$ shows that the electric field $\\vec{E}$ of a moving charge no longer has a spherical symmetry!!! It depends on the direction of the vector $\\vec{r}$.\n\n\tAt equal distances, the electric field is more intense in the vertical direction to that of the displacement ($\\theta=\\pi/2$) than in the direction of the displacement of the electric charge ($\\theta=0$).\n\n\tIf $v = 0$, we fall back on the classic known expression:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tLet us recall that we have carried out (and continue in this sense) here a study of an electric charge in uniform rectilinear motion, that is to say at constant speed!\n\t\\end{tcolorbox}\n\tTo find now the expression of the magnetic field $\\vec{B}$, we introduce:\n\t\n\tand:\n\t\n\tin:\n\t\n\tWe therefore get:\n\t\n\tWhich are the components of:\n\t\n\tTo know $\\vec{B}$ as a function of $\\vec{r}$, we substitute the expression obtained for $\\vec{E}$:\n\t\n\tIn the case where the velocity is small, the relativistic term tends to $1$ and the field $\\vec{B}$ of an electric charge $Q$ moving at the velocity $v$ becomes:\n\t\n\tbecause as we have in the section of Electrodynamics: \n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} At each location, the lines of the field $\\vec{B}$ are contained in a plane perpendicular to the direction of motion of the electric charge $Q$ (vector product oblige...!).\\\\\n\t\n\t\\textbf{R2.} If the moving electric charge is seen as a $\\mathrm{d}Q$ attached to the point O', we can interpret its displacement at velocity $v$ as a current $I$ at a point of the referential O where O' is located. Therefore:\n\t\n\tTherefore:\n\t\n\tWe then fall back here the \"Biot and Savart law\" as proved in the section of Electromagnetism. So this a success of the Special Relativity theory again!!!\n\t\\end{tcolorbox}\n\tIt is interesting to remember that an electric charged particle in motion will be seen in the frame of reference of the particle as emitting no electromagnetic field (there will be just an electrostatic field). This is not the case for a repository at rest. There is thus here a sort of flagrant counter-intuitive contradiction.\n\n\tBut this poses another problem, in a fast-moving frame of reference, a charged particle normally emits an acceleration radiation (\\SeeChapter{see section Electrodynamics page \\pageref{bremsstrahlung}}), this radiation in quantum mechanics must necessarily be accompanied by the emission of a quanta, which exists either or does not exist (a medium term does not exist). The very existence of photons would therefore be purely relative. And yet it is! Some particles have only a relative existence!!!! The complicated answer is therefore to know what the photons have become.\n\n\tBut here we reach the limit of what we master perfectly in the physics of the end of the 20th century, because we speak of accelerated references frames (which implies to be in General Relativity and not the special one) and quantum field theory . The rigorous framework for dealing with this (which would encompass Quantum Gravitation) does not yet exist as far as we know. But a first step has been taken with the development of the Quantum Field Theory in curved space.\n\t\n\t\\pagebreak\n\t\\paragraph{Tensor field transformation}\\mbox{}\\\\\\\\\\\n\tWe have seen and proved in the section of Electrodynamics that the whole electromagnetic field was summarized by the tensor of the same name. It would then be good to look at how this tensor transforms itself and if it does so correctly in relation to the results obtained above.\n\n\tLet us consider the transformation (where the tensor of the electromagnetic field is in natural units !!!):\n\t\n\twith the tensor of the electromagnetic field in contravariant components in the Minkowski metric $+---$:\n\t\n\tAnd also by construction:\n\t\n\tLet us take, for example, the velocity parallel to the $x$-axis, then we have proved above that:\n\t\n\tTherefore:\n\t\n\twhere as we can see, it is often customary in the field of Special Relativity and Electrodynamics to number the components of matrices / tensors starting from $0$ (instead of $1$ for most of the other chapters of this book).\n\n\tWe calculate the transformation (remember that the tensor of the electromagnetic field is antisymmetric!):\n\t\n\tWe thus deduce, for the electric field (which corresponds perfectly to what we obtained above):\n\t\n\tWe make a second calculation for the perpendicular component:\n\t\n\thence:\n\t\n\twhich again corresponds perfectly to what we had obtained earlier above (in natural units, do not forget that we then have $\\beta=v$)!\n\n\tThe same applies to the magnetic field:\n\t\n\tand:\n\t\n\tWhich gives (in natural units, again do not forget that we then have $\\beta=v$)! :\n\t\n\tetc.\n\t\n\t\\subsection{Minkowski space-time}\n\t\tWe have proved earlier above that:\n\t\n\tLet us write this in the form:\n\t\n\tLet us multiply the two members by $(ct)^2$:\n\t\n\twhich gives us:\n\t\n\tIf $v=c$ the equation vanishes:\n\t\n\tThis result translates the fact that the dimensions of space and time are as stopped in the relativistic referential, because the relative speed of the object is equal to that of the light!\n\n\tLet us now imagine that a light beam is emitted at the instant $t=0$ and propagates from the origin of a referential. We know that in space-time (application of the Pythagoras theorem in three-dimensional Euclidean space for recall...) the distance travelled by the photon is:\n\t\n\tBy changing $t$ of member and bringing the whole to the square to remove the root, we get:\n\t\n\tTherefore:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe can assimilate this relation to the representation of a spherical wavefront of a light wave propagating at the speed of light (see the equation of a sphere originally centered in the section of Analytical Geometry).\n\t\\end{tcolorbox}\n\tLet us now consider two coordinate events $(x_1,y_1,z_1,t_1)$ and $(x_2,y_2,z_2,t_2)$ and we denote by $\\mathrm{d}s$ the \"\\NewTerm{space-time abscissa}\\index{space-time abscissa}\" (or \"\\NewTerm{proper-distance}\\index{proper-distance}\"). We can then write the spatio-temporal interval as such:\n\t\n\tBy passing to the limit, we get the famous quadratic form of the \"\\NewTerm{interval invariant}\\index{interval invariant}\\label{interval invariant}\":\n\t\n\twhich has the same shape and value regardless of the reference system considered as we have already proved it earlier above. The infinitesimal interval of space-time $\\mathrm{d}s^2$ between two infinitely neighbouring events is therefore a relativistic invariant that we often name the \"\\NewTerm{space-time curvilinear abscissa}\\index{space-time curvilinear abscissa}\" or more simply the \"\\NewTerm{worldline}\\index{worldline}\" (an observer \"riding\" the worldline does not see - or \"feel\" - himself moving through space if he no have any observable reference object visible, only through time or more exactly it's \"proper time\" as we already know it). \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/world_line.jpg}\n\t\t\\caption{Worldline}\t\n\t\\end{figure}\n\tIt is the interval of space-time or, as Albert Einstein simply said, the \"square of distance\" .... The fact that this magnitude may be positive, negative (!) or zero is linked to the absolute character of the speed of light (we will come back to this later).\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tEquivalently we have $\\mathrm{d}s^2=-c^2\\mathrm{d}t^2+(\\mathrm{d}x^2+\\mathrm{d}y^2+\\mathrm{d}z^2)$. That we can rewrite as $\\mathrm{d}s^2=c^2\\mathrm{d}(\\mathrm{i}t)^2+(\\mathrm{d}x^2+\\mathrm{d}y^2+\\mathrm{d}z^2)$. Therefore imaginary times makes space-time Euclidean.\n\t\\end{tcolorbox}\n\n\tWe can also now turn our attention to the relativistic character of this metric. If it is invariant, it must also be invariant by Lorentz transformations. We then say that \"the metric is invariant by Lorentz transformation\". Such a transformation can be found on the basis of that used for the tensor of the electromagnetic field (see above). The reader will readily verify from the detailed example of the electromagnetic field that for the metric tensor we have the relation (as always we can detail on request if necessary):\n\t\n\tThe curvilinear abscissa can also be expressed by the norm of the quadrivector displacement which we defined above as $(ct,x,y,z)$. Indeed, the norm (\\SeeChapter{see section Tensor Calculus page \\pageref{norm tensor notation}}) is written by taking down the indices using the \"\\NewTerm{Minkowski metric}\\index{Minkowski metric}\\label{minkowski metric}\" $\\eta_{\\mu\\nu}$ or \"\\NewTerm{pseudo-Riemannian metric}\\index{Minkowski metric}\":\n\t\n\twith the definition of the \"\\NewTerm{Minkowski's matrix}\\index{Minkowski's matrix}\" (we will return to this in detail at the beginning of our study of General Relativity):\n\t\n\twhere as usual in this book we make the abuse of notation (already mentioned in the section of Tensorial Calculation) not to put $\\eta_{\\mu\\nu}$ in brackets (since a tensor and its matrix form are normally two distinct things in rigorously speaking).\n\n\tIf we put the following two relations in correspondence:\n\t\n\twe then have $\\mathrm{d}s^2=0$ when the two events are connected to the speed of light.\n\n\tMoreover, if we put:\n\t\n\twe can then write:\n\t\n\tThis is nothing more than the equation of a cone (\\SeeChapter{see section Analytical Geometry page \\pageref{cone of revolution}}) of axis of ordinate $c^2\\mathrm{d}t^2$... the famous \"\\NewTerm{light cone of Universe}\\index{light cone of Universe}\" (to which we devote a study further below). Every event is therefore by extension in this cone and the evolution of any system can thus be described (by its spatial and temporal position), by what we name its \"\\NewTerm{line of Universe}\\index{line of Universe}\" or \"\\NewTerm{World line}\\index{World line}\\label{world line}\". The Universe line of a particle is therefore the sequence of events it unfolds during its lifetime.\n\t\n\t\\subsubsection{Four-vectors}\n\tWe have just defined what Minkowski's metric was, we can now correctly define the concept of quadrivector that we have already addressed without always knowing what we were doing.\n\t\n\t\\textbf{Definition (\\#\\mydef):} In a four-dimensional space of Minkowski type, the four quantities:\n\t\n\t(regardless of the order of terms for this definition or whether the indices are numbers or letters corresponding to the four spatio-temporal components) form a covariant \"\\NewTerm{four-vector}\\index{four-vector}\\index{quadrivector}\" if they transform following the Lorentz transformation:\t\n\t\n\tThe \"\\NewTerm{pseudo-norm}\\index{quadrivector pseudo-norm}\\index{four-vector pseudo-norm}\" of a quadrivector in a Minkowski space of metric $\\eta_{\\mu\\nu}$ is then:\n\t\n\twhere we see that the contravariant four-vector multiplied by the metric returns the contravariant four-vector (\\SeeChapter{see section Tensor Calculus page \\pageref{contravariant and covariant components}}).\n\n\tThe following quantity being invariant by change of Galilean referential as we proved it almost at the beginning of this section:\n\t\n\tThis property of invariance by change of Galilean referential of the four-vector is their main property. Thus, two observers in relative motion, which are uniform in relation to each other, must compare the results of the same measure using the norm of the four-vectors. Similarly, the laws they seek to determine to be as general as possible must use these invariant quantities! \n\t\n\tWe can also write the norm of a four-vector in the form:\n\t\n\tand the four-vector themselves:\n\t\n\tSo for summary let us give the list of the four-vectors we have determined so far in this section but by standardizing the notations (and only those four-vectors that will be useful for other sections of this book!):\n\t\\begin{itemize}\n\t\t\\item The space-times four-vector (\"four-position\"):\n\t\t\n\n\t\t\\item The velocity four-vector (\"four-velocity\"):\n\t\t\n\t\t\n\t\t\\item The current four-vector (\"four-current\"):\n\t\t\n\t\t\n\t\t\\item The acceleration four-vector (\"four-acceleration\"):\n\t\t\n\t\t\n\t\t\\item The energy-momentum four-vector (\"four-momentum\"):\n\t\t\n\n\t\t\\item The gradient four-vector (\"four-gradient\") introduced in the section of Tensor Calculus:\n\t\t\n\t\\end{itemize}\n\tObviously we have considered here four-vectors in the context of Special Relativity. Although the concept of four-vectors also extends to General Relativity, some of the results stated above require modification in General Relativity.\n\t\n\t\\subsubsection{Universe light cone}\n\tThe topology of the light cone has its origin in the relations of anteriority and posteriority of relativistic events, which makes it possible to distinguish between an event in the past of another or in the future of it.\n\n\tThe principal objective of the light cones in the popularization works of theoretical physics is to map out the history of light pulses emitted at a point in the space where certain conditions may prevail. The points are represented in space by a series of snapshots at various times $t_1$, $t_2$, $t_3$, etc. (see figure below), the spherical wave front of the light magnifying in space. In space-time, the same event (at the bottom on the figure) is represented by a \"\\NewTerm{light cone}\\index{light cone}\", whose apex is the point of emission.\n\n\tOn a sheet of paper, we have to remove one of the spatial dimensions. The spatial axes are drawn in the horizontal plane and the time axis directed upwards. The cone sections at the instants $t_1$, $t_2$, $t_3$ correspond to the snapshots of the spatial representation: the two-dimensional wavefronts are circles whose radius is that of the spherical wavefront at the instant considered. The light cone shows in a single diagram the continuous history of the wavefront of a light signal.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/light_cone.jpg}\n\t\t\\caption{Idea of light-cone}\t\n\t\\end{figure}\n\tMore precisely, the \"snapshots\" mentioned above are named \"\\NewTerm{punctual events}\" and these appear instantaneous (approximation based on geometric optics) to any observer capable seeing them. A collision between two point particles provides an example of a punctual event. It is quite possible that a non-punctual instantaneous event appears instantaneous to a certain observer but, because of the finite propagation velocity of the light, not instantaneous to another observer.\n\n\t\\textbf{Definitions (\\#\\mydef):}\n\t\\begin{itemize}\n\t\t\\item[D1.] Two punctual events occupy the same \"\\NewTerm{time-space point}\\index{time-space point}\" if they appear simultaneously to any observer able to see them.\n\n\t\t\\item[D2.] The set $M$ of all points of space-time is named the \"\\NewTerm{space-time}\\index{space-time}\".\n\n\t\t\\item[D3.] The boundary defined by the Universe cone is named the \"\\NewTerm{cosmological horizon}\\index{cosmological horizon}\"\n\t\\end{itemize}\n\tLet us recall that if no force acts on a point particle, we say from it that is an \"inertial\" or \"free\" particle. We also say that it is in \"inertial motion\".\n\n\tGiven the point $p$, $N(p)$ is an absolute geometric structure independent of the observer. Its future component will be denoted $N^{+}(p)$; Its past component $N^{-}(p)$ and it will be represented by the following cone:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/past_future_light_cone.jpg}\n\t\t\\caption{Past and future light cones of an event of a worldline}\t\n\t\\end{figure}\n\tIndeed, let us recall that the Minkowski equation is invariant since:\n\t\n\tWe have, when we reduced to three parameters (we remove a spatial dimension to simplify the conceptualisation), if the punctual events are related to the speed of light (see earlier above):\n\t\n\tWhat we can also write in the form:\n\t\n\tto be compared with the equation of a cone (\\SeeChapter{see section Analytical Geometry page \\pageref{cone of revolution}}):\n\t\n\twhen we put $c = 1$ (which is frequent in theoretical physics as we have already mentioned many times).\n\n\tTherefore the Minkowski equation can be indeed presented by a cone.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf we would have keep the three spatial parameters and the time interval constant, the reader will then perhaps have notice that we would fall back neither on the equation of a cone but on that of a sphere. It is the \"\\NewTerm{celestial sphere}\\index{celestial sphere}\" where at a given instant, on its surface, multiple cones of light are created.\n\t\\end{tcolorbox}\n\tThe universe line of any observer which occupies instantly $p$ and whose line of the Universe passes through $p$ itself, is contained within $N(p)$ defined by a single point on its celestial sphere (the one that is described by the information vector - the photon - in all directions of space). This means that there can be, in extenso, as many null rays (foci of cones) passing through $p$ as points on a sphere.\n\n\tThe following example will (we hope) appear more obvious:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/light_cone_associated_universe_line.jpg}\n\t\t\\caption{Universe Line Principle with its associated Cone}\t\n\t\\end{figure}\n\tAs illustrated in the figure above, a light event at the point O of the space-time produces a beam of photons, all in the zero cone of the future O, $N^{+}(\\text{O})$ (these photons have been emitted by atoms in various states of movements whose universe lines $l$ and $l'$ pass through O, but are entirely contained within the $N^{+}(\\text{O})$). The universe line $n$ can only be described by a particle moving at the speed of light because it defines the boundary of the cone (we then say that the line of the Universe is of \"light type\").\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe representation of the Universe lines in the lower part (inverted cone) comes from the fact that an event can also have a past... so the scheme generalizes the particular example.\n\t\\end{tcolorbox}\t\n\tLet $l_p$ be the universe line of a stationary person $P$ (hence the verticality of its Universe line in the figure above) and $n$ that of a light ray having the origin O. Both lie in the four dimension space and they intersect at a single point $P$. The points O and $P$ lie on a zero radius (of a cone of the future), $n$, of $N^{+}(\\text{O})$. In $P$, the person $P$ sees a sudden flash in the direction defined by $n$, for him the direction of the luminous event (described only by its velocity therefore, so a universe line of an inertial particle can be described only by time and speed).\n\t\n\tAn atom whose Universe line cuts $n$ at the point $Q$ absorbs a photon of the luminous event O and re-emits a beam of photons shortly after. These, in turn, form zero rays in $N^{+}(Q)$, but only those of direction $n$ will reach the person $P$ and will be seen by him at the point $P$.\n\n\tIf $P$ is inside $N(\\text{O})$, the zero cone of O, we will say that its universe line is of the \"time type\". In this case, O and $P$ are located on the universe line of an observer or a massive particle. There are, of course, two types of time displacement:\n\t\\begin{enumerate}\n\t\t\\item If $P$ is in the future of O (according to an observer whose universe line passes through O and $P$), we will say that $P$ \"points to the future\".\n\n\t\t\\item If not, we will of course say that it \"points to the past\".\n\t\\end{enumerate}\n\tIf $P$ is on $N(\\text{O})$ - that is to say on the surface of the cone - then we say that it is \"null\" or of \"light type\" and if $P$ is neither zero nor of time, then $P$ is outside of $N(\\text{O})$ and then we say that it is of \"space type\":\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/type_of_universe_lines.jpg}\n\t\t\\caption{Types of universe lines}\t\n\t\\end{figure}\n\tThis is mathematically translated by remembering (see above) that the invariant interval (in the case of the Minkowski metric) is given by:\n\t\n\t\\begin{itemize}\n\t\t\\item $\\mathrm{d}s^2=0$ (then $r^2=c^2\\Delta^2$): The universe line is therefore \"light-like\" and it is that latter which describes the surface of the cone by definition (according to what we have demonstrated previously and whatever the choice of the metric) is such that:\n\t\t\n\t\twhich is the case of a photon (hence the name ...). In other words, the spatial separation is equal to the distance light travels.\n\n\t\t\\item $\\mathrm{d}s^2<0$ (then $r^2<c^2\\Delta^2$: We then say that the Universe line is \"space-like\", therefore such that:\n\t\t\n\t\tTwo events that take place simultaneously but at different places are therefore space-like. In other words, the spatial separation is less than the distance light travels.\n\n\t\t\\item $\\mathrm{d}s^2>0$ (then $r^2>c^2\\Delta^2$: We then say that the Universe line is \"time-like\", therefore such that:\n\t\t\n\t\tIn other words the spatial separation is greater than the distance light travels.\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics{img/cosmology/universe_line_type_with_equation.jpg}\n\t\t\\end{figure}\n\t\t\n\t\t\\item A \"\\NewTerm{causal line}\" is a time-like or light-like line that is always oriented towards the future.\n\t\\end{itemize}\n\tLet us return to our equations after this small interlude ... the equations therefore lead us to several observations. Thus, in the four-dimensional Euclidean Universe of Minkowski, the trajectories of objects in space-time are always straight lines. Indeed, the trivial example consists in considering that the object remains at rest, then only the time then continues to flow. We have therefore:\n\t\n\tby putting $v=0$, this gives us:\n\t\n\ttherefore:\n\t\n\thence:\n\t\n\tand also:\n\t\n\tThe primitive being (integration constant taken as zero):\n\t\n\twhich is indeed a straight line and therefore represents the universe line of the object considered in the universe cone. We can also observe that in this case, the evolution of the phenomenon is purely temporal when the interval is positive (which supports what we said earlier).\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} If the speed of light is infinite, we fall back on the particular case of the Newtonian universe, where a phenomenon can instantly occur. Time is absolute and there is no cosmological horizon because the cone has a maximum aperture (right angle).\\\\\n\t\n\t\\textbf{R2.} If we put that the velocity of light as equal to $1$ (natural units), as we have done it already sometimes, the axis of the ordinate of the cone is named a \"purely temporal axis\".\\\\\n\t\n\t\\textbf{R3.} It is necessary to understand that our Universe has its own cone of Universe (cone... if the space is of Minkowsky-like of course...).\n\t\\end{tcolorbox}\n\tFinally, let us say that the theory of Special Relativity, like that of General Relativity, does not impose a given number of spatial dimensions in order to remain consistent: this is a pity for theoretical physicists who would like a theory which, imposes on itself a finite number of dimensions to remain consistent (that on the other hand the theory of the strings or superstring).\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{95} & \\pbox{20cm}{\\score{4}{5} \\\\ {\\tiny 48 votes,  71.25\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\t\t\n\t%to force start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{General Relativity}\\label{general relativity}\n\t\\lettrine[lines=4]{\\color{BrickRed}A}s we saw it, in the previous section, Special Relativity is a remarkable achievement from a theoretical point of view as well as a practical point of view, forming a continuum of space-time where the space variables and time are given the same physical dimension (that of a distance metric for reminder!). However, this applies only to the Euclidean frames and to inertial/Galileans reference frames(constant speed reminder...). It is therefore appropriate to first generalize the entire mechanic theory by expressing its principles and fundamental results in a generalized form independent of the type of coordinate system chosen (that is to say: independent of the space properties) using for this purpose tensor calculus and then to take into account the non-inertial systems. The equivalence of inertial systems by Special Relativity and the non-equivalence of inertial systems can then shortly be resume (a little bit basically...) saying that speed is relative but the acceleration is absolute. Thus, we can never rest distinguish a uniform motion, but we can distinguish them from an accelerated motion.\n\t\n\tIt should also be consider the fact that Special Relativity applies only to Galileans frames is restrictive because any mass creates a gravitational field whose scope is endless. To find a true Galilean frame, it is therefore necessary to lie infinitely far from any mass. Relativistic mechanics built from Special Relativity therefore constitutes an approximation of the laws of nature, where the gravitational fields or accelerations are low enough. This application limitation is not  more suited to relativistic astrophysics whose activity has intensified in the late 20th century.\n\t\\begin{fquote}[Plato]Let no one ignorant of geometry enter here!\n \t\\end{fquote}\n\t\\subsection{Assumptions and Principles}\n\tAlbert Einstein and some others of his time believed in a physics that not to favour any frame system since that was in their eyes the reality of the Universe (we have already mentioned this point of view). But how can we subtract ourselves to the phenomenon of  acceleration? The brilliant idea was to state the \"\\NewTerm{equivalence postulate}\\index{equivalence postulate}\" below (which still in this early 21st century has not show any default by recent known experiences) plus the \"invariance postulate\" and \"cosmological principle\" we have already stated in the section of Special Relativity and the assumption that the motion of a particle that does not undergo any other interaction that gravitation follows a geodesic line (see below for the detailed proof).\n\t\n\t\\subsubsection{Equivalence Postulates}\n\tAt first, Albert Einstein will improve the equivalence postulate (also named \"equivalence principle\") whose older versions are due to Galileo and Newton:\n\t\n\t\\textbf{Postulate:} The (uniform!) acceleration of a mass (outside gravitational field) due to application of mechanical force and the acceleration of that mass subjected to a gravitational field are supposed completely equivalent. Thus, the results of mathematical analysis in one case may apply to the other (here this is already smart but consistent ... the idea is very good still had to have it...!). \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/equivalence_principle.jpg}\t\n\t\\end{figure}\n\tIn other words, the gravity field has a fundamental property which distinguishes it from all other fields known in nature: the free fall movement of bodies is universal, independent of the mass and composition of the bodies.\n\t\n\tCorollary: The rest mass of a body must be the same whether it is measured in a frame within a gravitational field or outside a gravitational field (we speak then about \"inertial mass\" and of \"gravitational mass\" as we have already study at the beginning of our study in the section of Classical Mechanics).\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe must be careful and check that the corollary of the assumption of the equivalence principle is true otherwise all General Relativity would collapse (in the early 21st century experiments are still going to try to show a default to this principle)!\n\t\\end{tcolorbox}\t\n\t\n\tSo all static and uniform gravitational field is equivalent to an accelerated frame in vacuum. We can consider any physical gravitational field as static and uniform in a relatively small region of space, and for a relatively short period of time to avoid the tides effects. We are thus led to state the \"\\NewTerm{Weak Equivalence Principle}\\index{weak equivalence principle}\" (WEF): For any event in space-time in an arbitrary gravitational field, we can choose a frame named \"\\NewTerm{locally inertial frame}\\index{locally inertial frame}\" such as in the neighbourhood of the event of interest the free movement of all body (which are also in the gravity field!) is straight and uniform as we are able to apply the Lorentz transformations (\\SeeChapter{see section Special Relativity page \\pageref{lorentz transformations}}). In other words, it is not possible to distinguish a system in vacuum space far away from any star (gravitational source) from as system falling in a constant homogeneous gravitational field.\n\t\n\tIf we experimentally show that WEF fails, then we are put into default the equivalence principle itself ... which has never been achieved in the laboratory to this date!\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe concept of \"locality\" is very important because it reality we don't know any natural uniform gravitational field. For example, on Earth, two body distant of a certain length dropped from a certain height will fall to the ground with a shorter distance than the distance between them when they were released. This is what we call in physics the \"tide effect\": the gravitational field is never uniform (as far as we know...).\n\t\\end{tcolorbox}\n\t\n\tSo the postulate of equivalence (which includes the principle of weak equivalence) finally asserts that the Newton's force on inertial mass $m_i$:\n\t\n\tand that of gravitation in the form of the Newton-Poisson law (\\SeeChapter{see section Astronomy page \\pageref{newton-poisson equation}}) with gravitational mass $m_g$:\n\t\n\tare equivalent such as the inertial mass equals the gravitational mass and acceleration equal to gravity and that it is not possible to distinguish the both such that:\n\t\n\tIn what this postulate allows to resolve all the problems therefore? It's simple! The idea is the following:\n\t\n\tWhen we will consider a body in acceleration, we first always equate it to the acceleration due to the fall in a gravitational field (by applying the postulate of equivalence). Then, we will assume, and will have to check (see proof further below) by rediscovering Newton's law, that acceleration due to the gravitational field is not due to the field itself but to the geometry of the deformed space by the presence of the mass (i.e. energy) that creates the gravitational field. Thus, the object is no longer in \"free fall\" but will be seen as sliding on the distorted spatial frame to acquire therefore its acceleration.\n\t\\begin{enumerate}\n\t\t\\item If the tensor calculus gives the possibility to express the laws of classical and relativistic mechanics in any coordinate system, it is then possible to see how the coordinate system (metric) acts on the expression of the laws of the Universe (Albert Einstein did not know that fact as he had not completed its calculations but had a presentiment about this)!\n\t\t\\item If the natural tensor expression of the laws of mechanics shows slippage (i.e. acceleration) on the spatial frame following the (local) considered metric, then the bet is won and then the acceleration can be seen as an effect whose cause is purely geometrical.\n\t\\end{enumerate}\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\t\tSuppose that two rockets, which we denoted by $A$ and $B$ are in a region of space away from any body. Their engines are stopped which physically results in a uniform motion. In each rocket, physicists are making mechanics experiments with objects which they know the inert mass. Suddenly the engine of the rocket $A$ starts and communicates to it an acceleration whose effects felt inside the spaceship is an inertia force that constraint objects going to the floor. For physicists $A$ rocket laws of mechanics are then the same as that observed in a gravitational field. They are logically led to interpret the force of inertia as the manifestation of a gravitational field. Using a balance, they can weigh their objects and assign to them a gravitational mass.\\\\\n\t\t\n\t\tSuppose now that the physicists in rocket $B$ could observe what happens in the rocket $A$. They know what their colleagues interpret as the weight of objects is in fact a force of inertia. The inertial force is proportional to the acceleration and the inertial mass. If the gravitational mass was different from the inertial mass the physicists of the rocket $A$ could distinguish the effects of inertial forces from those of a gravitational field because the measured masses are distinct. We know that the inertial and gravitational mass are equivalent (Galilean principle of equivalence). It follows that the physicists of the rocket $A$ have no way to differentiate between inertial forces resulting from an accelerated motion of their spaceship and the gravitational attraction forces.\\\\\n\t\t\n\t\tHowever, we must temper the conclusions from this experience: the real gravitational fields differ from an accelerated frame since the gravitational acceleration varies with the distance to the main body while in an accelerated reference frame, the acceleration is the same at any point in space. However, \\underline{locally}, a gravitational field and an accelerated frame can not be differentiated!!!\n\t\\end{tcolorbox}\n\t\n\tWe are led now to state the \"\\NewTerm{Einstein's equivalence principle}\\index{Einstein's equivalence principle}\" (EPE) as did Albert Einstein: locally all the laws of physics are the same in a gravitational field and a uniformly accelerated frame.\n\t\n\tThis has a consequence: If the mass (which is equivalent to the energy as we have proved in the section of Special Relativity) of an object is not differentiable that we are in a gravitational field or a uniformly accelerated frame that means that all types of energy (nuclear cohesion energy, electrostatic energy, proper gravitational energy of the object, etc.) of this object are indistinguishable. So the laws of Special Relativity are also valid whatever the considered frame!\n\t\n\tIf the laws are not the same, then EPE (Einstein equivalence principle) is faulted, so verbatim WEF (weak equivalence principle) also and more globally the principle of equivalence in general but this has never happened experimentally as far as we know at this day.\n\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Example:}\\\\\\\\\n\tBy the WEF, it is interesting to note that the gravitational field also acts on the gravitational potential energy of the other bodies. We say then that the gravitational field is a \"coupled field\".\n\t\\end{tcolorbox} \n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! It turns out that in General Relativity, it's very hard to make the notation of \"gravitational potential energy\" precise. For example, you can't talk about the gravitational potential energy density at a point, because you can always go into a freely falling frame there, where the observed gravitational field is zero. For this reason, relativity textbooks generally say that the gravitational potential energy is not defined at all; instead energy (defined as not including this extra ill-defined piece) simply isn't conserved in General Relativity. If the reader may think this is unacceptable, remember that the only reason we elevated conservation of energy to an important principle in the 19th century was that it was observed to work in everyday situations. We never tested it in exotic situations like those with curved space-time, so there's no reason to expect the principle to continue to hold up (but many textbooks on General Relativity do so and we will also do it later ourselves...). At a deeper level, Noether's theorem tells us that energy conservation is related to time translation invariance (ie «our system will work the same if we start it at some other time» to not be confused with time reflection symmetry where «our system will work the same if we run it backwards»), and we don't have that in an expanding universe (indeed the energy carried by radiation decreases as the universe expands since every photon's wavelength increases).\n\t\\end{tcolorbox}\n\t\n\tGiven that in General Relativity, the gravitational field is supposed to be described by the metric $g_{\\mu\\nu}$ (from which the 4-dimensional differentiable manifold that is space-time is supposed to be made), we can see a locally inertial frame as a coordinate system of space-time in which the metric becomes flat (pseudo-Riemannian):\n\t\n\tusing the notation introduce in the section of Tensor Calculus.\n\t\n\tSuch a coordinate system will by hypothesis always exists, indicating the existence, for any gravitational field, of locally inertial frames!\n\t\n\t\\subsubsection{Mach Principle}\n\t\n\tIf the equivalence principle highlights the equality of inert and gravitational mass, it does not enlighten us about the nature of these two masses. Finally, what are the inert and gravitational mass?\n\t\n\tThe deep nature of the inert mass should inform us about the inertia itself. The inertia is manifested in a passive form - the principle of inertia - and an active form - the second Newton's law. In general, it expresses a universal behaviour of bodies to resist to the change of movement. But we know that inertial motion is relative, that is to say that there is no absolute referential frame. Is it the same with the accelerated movement? Consider, to illustrate this question, a rocket in which has taken place a physicist and let us carry two experiments:\n\t\n\t\n\tHowever when the metric is not flat the coordinates are named \"\\NewTerm{Riemann normal coordinates}\\index{Riemann normal coordinates}\" and then describes a Riemann metric space (curved space) and itself depends in a non-trivial way of the coordinates system (\\SeeChapter{see sections Tensor Calculus page \\pageref{curvilinear coordinates tensor calculus} and Non-euclidean Geometry page \\pageref{riemann coordinates}}).\n\t\n\t\\begin{enumerate}\n\t\t\\item First experience: The rocket accelerates and the physicist is subjected to inertia force oriented in the direction opposite to that of acceleration.\n\t\t\n\t\t\\item Second experience. Now assume that we gives to the whole Universe - at the exception of the rocket that moves in an inertial motion - an acceleration exactly opposite to the one of the rocket of the preceding experiment.\n\t\\end{enumerate}\n\tIf the accelerated motion is relative then, for an observer, it is not possible to distinguish the two experiments. In particular, the physicist located inside the rocket must observe the emergence of an inertial force absolutely identical to the one he noted in the first experiment. The inert mass could then has its origin in the interactions of the gravitational mass of bodies with all the gravitational mass of the Universe! It is as if by moving all masses of the Universe, they dragged with them the objects in the rocket, the physicist therefore experienced a force that pulls in the same direction as the acceleration applied to stars.\n\t\n\tFollowing Ernst Mach, physicist and philosopher of the 19th century, the movement whatsoever inertial or accelerated, is relative.\n\t\n\tThis theory was named by Albert Einstein \"\\NewTerm{Mach principle}\\index{Mach principle}\". At this date, Mach's principle has not been confirmed, but no more rejected. It is true that its experimental verification far exceeds actual human capacities!\n\t\n\t\\subsection{Metrics}\n\tAlbert Einstein assumed that gravity was only the manifestation of space-time distortions. To try to illustrate in the more possible simple and illustrated way the idea of Albert Einstein, consider a rolling gear at constant speed (say, one tooth at a second) on a rack. Imagine that we have the power to simultaneously change the pitch of the rack and the wheel when and where we wish. Let us do things such that the pitch of the rack slightly increases from one tooth to another. For fixed observers the gear is then driven with a uniformly accelerated motion as, in effect, at each turn thereof always travels a greater distance. On the other hand, if one chooses the rack as a reference and thereof the pitch as a standard to measure the movement of the wheel is then uniform (one tooth per second). The acceleration of the wheel is the consequence of the increase in the pitch of the rack.\n\t\n\tLet us continue the analogy: the pitch of the rack acts as a local measurement standard in our one-dimensional space that represents the rack. In geometry, it is named the \"metric\". The metric is what determines the distance between two points, it is somehow the standard infinitesimal space unit. In Euclidean geometry, the metric is constant, allowing us to create universal measurement standards. Bernhard Riemann, for example, invented a metric geometry which can vary from one point to another in space, which allowed him to describe curved spaces like the surface of a sphere, for example (\\SeeChapter{see section Non-Euclidean Geometry page \\pageref{non-euclidean geometry}}).\n\t\n\tDuring our study of tensor calculus, non-Euclidean geometries and differential geometry (section that the reading is more than recommended!!!) we have seen that the measurement of the curvilinear distance $ds$ between two points positioned in a two or three dimensions space can be made using a large number of coordinate system by the \"\\NewTerm{metric equation}\\index{metric equation}\" (\\SeeChapter{see section Special Relativity page \\pageref{interval invariant} and section of Non-Euclidean Geometry page \\pageref{geodesic and metric equation}}):\n\t\n\tIn General Relativity, the idea is to make the theoretical model independent of the background and thus build it in a covariant form (which some physicists liken to assimilate to a postulate named the \"\\NewTerm{covariance principle}\\index{covariance principle}\"). An excellent candidate for this type of approach is to use the tensor formalism. This is the reason why the metric equation is therefore one of the pillars.\n\t\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\n\t\\textbf{{\\Large \\ding{45}}Examples:}\\\\\\\\\t\n\tE1. Rectangular coordinates (in $\\mathbb{R}^3$):\n\t\n\tIf the squared distance satisfies this relation then we are in a flat space or at least locally flat (\\SeeChapter{see section Non-Euclidean Geometry page \\pageref{geodesic and metric equation}}).\\\\\n\t\n\tE2. Polar coordinates (in $\\mathbb{R}^2$):\n\t\n\tTherefore:\n\t\n\tTherefore:\n\t\n\tIf the squared distance satisfies this relation then we are in a flat space or at least locally flat (\\SeeChapter{see section Non-Euclidean Geometry page \\pageref{geodesic and metric equation}}).\\\\\n\t\n\tE3. Cylindrical coordinates (in $\\mathbb{R}^3$):\n\t\n\twhen we put this into $\\mathrm{d}s^2=\\mathrm{d}x^2+\\mathrm{d}y^2+\\mathrm{d}z^2$ we get in a similar way as before:\n\t\n\tIf the squared distance satisfies this relation then we are in a curved space (cylindrical type) but that may be locally flat (\\SeeChapter{see section Non-Euclidean Geometry page \\pageref{geodesic and metric equation}}). In fact, to have the metric of the cylinder surface and not simply of the plane expressed in cylindrical coordinates, we must take the following metric:\n\t\n\twhose origin was proved in the section of Differential Geometry and also... just previously...\n\t\\end{tcolorbox}\n\t\n\t\\pagebreak\n\t\\begin{tcolorbox}[colframe=black,colback=white,sharp corners]\t\n\tE4. Spherical coordinates (in $\\mathbb{R}^3$) for which we have:\n\t\n\twhen we put this into $\\mathrm{d}s^2=\\mathrm{d}x^2+\\mathrm{d}y^2+\\mathrm{d}z^2$ we get:\n\t\n\tNow remember that (\\SeeChapter{see section Algebra Calculus page \\pageref{calculus remarkable identities}}):\n\t\n\tTherefore:\n\t\n\tAfter a first set of factorization and basic simplifications of identical terms, we obtain:\n\t\n\tIf the squared  distance satisfies this relation then we are in a curved space (spherical type) but that locally may be flat (\\SeeChapter{see section Non-Euclidean Geometry page \\pageref{geodesic and metric equation}}). In fact, for the metric of the surface of the sphere and not simply of the plane expressed in spherical coordinates, we have to take the following metric:\n\t\n\twhose origin has been proved in the section of Differential Geometry. We also checked in the section of Tensor Calculus, that the Ricci curvature of the spherical prior-previous metric was zero. By cons, we had right after checked that if we took the previous metric of the surface of the sphere, the Ricci curvature was not zero (and it is still happy!).\n\t\\end{tcolorbox}\n\tUntil then, you may be wondering where we are going? In fact, we try to define from these relations, a mathematical being that consistent with the Einstein's hypothesis, expresses the geometric properties of given space.\n\t\n\tHow we will do this?: We first change simply change the notations. Instead of using the symbols $(x,y,z,\\theta,\\phi,r)$ we will write $x^1,x^2,x^3,...$. \n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution! The numbers suffixes are not powers!!! These are dummy values that are only there to symbolize the $x$-th coordinate of a given basis.\n\t\\end{tcolorbox}\n\t\n\tNow let us write again our metric equations with this new notation by considering it is only specific examples that do not necessarily have relevant physical sense (we also mentioned it earlier!):\n\t\\begin{itemize}\n\t\t\\item Rectangular coordinates:\n\t\t\n\t\t\\item Polar coordinates:\n\t\t\n\t\t\\item Cylindrical coordinates:\n\t\t\n\t\t\\item Spherical coordinates:\n\t\t\n\t\\end{itemize}\n\tNow let us recall again that the \"\\NewTerm{metric tensor}\\index{metric tensor}\\label{metric tensor}\" (so named because it calibrates space-time) denoted :\n\t\n\tis involved in the metric equation as follows in the Lorentz invariant (\\SeeChapter{see section Special Relativity page \\pageref{interval invariant}}):\n\t\n\tand notice that the components of the matrix are also dimensionless!\n\t\n\tThis mathematical entity which is a tensor thus contains the parameters of the curvature (we also sometimes say of the \"stress\" or \"tension\") wherein a space is located. But then what contains the metric tensor of space-time for a flat Euclidean space?\n\t\n\tAccording to the summing writing Einstein's convention (\\SeeChapter{see section Tensor Calculus page \\pageref{einstein summation convention}}), for example, for $\\mu=\\nu=2$ we have:\n\t\n\t\\label{metric flat space}So if we return to our tensor for the flat Euclidean space, we already know (\\SeeChapter{see section Vector Calculus page \\pageref{canonical basis}}) that $m$ and $n$ goes from $1$ to $3$ and we have in our tensor $g_{\\mu\\nu}=0$ for $\\mu\\neq \\nu$ and $g_{\\mu\\nu}=1$ for  $\\mu= \\nu$ (symmetrical tensor). So:\n\t\n\tTherefore:\n\t\n\twhich as usual in this book we make usage of the abusive notation (already indicated in the section of Tensor Calculus) to not put $g_{\\mu\\nu}$ (since a tensor and its matrix form are normally two separate things strictly speaking).\n\n\tThis result is remarkable, because the metric tensor will therefore enable us to define the properties of a space from a simple mathematical being that can easily be handled formally as we already seen in the section of Tensor Calculus, Non-Euclidean Geometry and Differential Geometry.\n\n\tIn polar coordinates the tensor $g_{\\mu\\nu}$ is:\n\t\n\tCheck:\n\t\n\tAnd in cylindrical coordinates the tensor $g_{\\mu\\nu}$ is written:\n\t\n\tWe will not do the check as the result is obvious (excepted on reader request).\n\t\n\t\\label{metric spherical space}In spherical coordinates the tensor $g_{\\mu\\nu}$ is a little more complex and is written:\n\t\n\tWe will also not do the check as the result is obvious (excepted as always on reader request). \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAs we have mention it, in the section of Tensor Calculus, $g^{ij}=(g_{ij})^{-1}$ and the reader can quickly verify this with Maple 4.00b as inverting a matrix is always a boring work (here the code is given only for the spherical one but the idea is the same for the others):\\\\\n\t\n\t\\texttt{>with(linalg):\\\\\n\t>A:=array([[1,0,0],[0,r\\string^2,0],[0,0,r\\string^2*sin(theta)\\string^2]]);\\\\\n\t>inverse(A);}\n\t\\end{tcolorbox}\n\t\n\tIn Special Relativity, we have seen that the notions of space and time were implicitly bounded. Thus, to study modern physics (this does not really interest  the pure mathematician), we need to add to our metric tensor a time component  to get what we name the \"\\NewTerm{space-time metric tensor}\\index{space-time metric tensor}\".\n\t\n\tTo determine the writing of this tensor, we will place us at first in a Minkowski space where we have for recall (\\SeeChapter{see section Special Relativity page \\pageref{minkowski metric}})\\label{minkowski metric general relativity}:\n\t\n\twhich is the infinitesimal interval of space-time between two infinitely close events (or considered as it at a given scale...) named as we know the \"interval invariant\\index{interval invariant}\".\n\n\tThus by putting:\n\t\n\tWe have:\n\t\n\twith the \"\\NewTerm{signature}\\index{signature}\":\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tFor all metric tensor that we have determined before, if we express them in space-time (thus adding time component), the spatial components will all have a negative sign!\n\t\\end{tcolorbox}\n\tThe choice of the system of coordinates with which we describe space-time is named a \"\\NewTerm{space-time gauge}\\index{space-time gauge}\". If a quantity is unchanged under a space-time gauge transformation, it is say to be as we already know after our study of Quantum Physics \"gauge invariant\".\n\t\n\tWe will see later other metrics that are much less intuitive (like the Schwarzschild metric, the Friedmann–Lemaître–Robertson–Walker metric, the Kerr metric, the De Sitter/anti-De Sitter metrics, the Alcubierre metric and so on...) once we will have proved far later below the Einstein's fields equation\\footnote{There is at least twenty common metrics used and studied by high level physicists and astrophysicists}.\n\t\n\t\\subsubsection{Schild Criteria (Einstein redshift effect Newtonian approach)}\n\tWe will prove later that gravitation as formulated in Newtonian mechanics is completely describable by a curvature formulation of space-time. But first we want to introduce to the reader with, in our point of view ,the easiest development that can be done \\underline{without} General Relativity to compare it also later with the easiest development that can be done \\underline{with} General Relativity: the gravitational redshift effect!\n\t\n\tImagine first a very height tower of height $h$ built on the surface of the Earth. A man sits at the ground of the tower, and sends a signal of pulsation $\\omega_A$ to a colleague $B$ at the top of the tower. There will be, and we will immediately prove it, that the pulsation $\\omega_B$ of the wave received by $B$ differs of $\\omega_A$ according to the relation:\n\t\n\tHence:\n\t\n\tThis shift of pulsation (frequencies respectively) in a gravitational field is what we name the \"\\NewTerm{Einstein's effect}\\index{Einstein's effect}\", or \"\\NewTerm{gravitational redshift}\\index{redshift!gravitational redshift}\".\n\t\n\tWe will first prove this relation using conventional arguments and now well known to us. Later we will prove that in fact this is only an approximation of a result that we will get later using General Relativity curvature properties.\n\t\n\tA material body sent from the ground to the sky must fight against the gravitational force that pulls it down. So it will lose a certain amount of energy, equivalent to gravitational potential energy gained during the trip. The total energy $E_A$ of the body at the ground level is therefore its mass energy (\\SeeChapter{see section Special Relativity page \\pageref{mass energy equivalence}}) to which we add the potential energy at the height of the tower:\n\t\n\tThe energy of this body when you reach the top of the tower is simply its mass energy:\n\t\n\tbecause he had to spend the energy $mgh$ during the trip to go up. The ratio of energy is then:\n\t\n\tThis ratio being independent of the mass $m$, we can take the limit $m\\rightarrow 0$ in order to have the relation for the photon. We then get:\n\t\n\twhich implies:\n\t\n\tThat is to say the clocks run slower in a gravitational field as seen by a distant observer!\n\t\n\tWe will now study this phenomenon in the context of the Minkowski space-time. We will see then a contradiction, what will motivate the transition to a curved space-time: this is the argument of a curved geometry that was used by Schild.\n\n\tLet us consider again the human experience of a human in $A$ which sends a wave to his friend positioned in $B$. Given $\\Delta t_A$ the time taken by $A$ to emit exactly $1$ cycle of the wave (\\SeeChapter{see section Wave Mechanics page \\pageref{pulsation frequency period wave number}}):\n\t\n\tand $\\Delta t_B$ the time taken for $B$ to receive this cycle:\n\t\n\tBecause of the Einstein's effect just seen previously, we know that $\\omega_A>\\omega_B$ and therefore that $\\Delta t_A<\\Delta t_B$ in proper time! That is to say that time passes more slowly for someone on the ground ($A$) than another person in a mountain top ($B$)!\n\n\tBut as we are in flat geometry and the gravitational field is assumed static, we deduce that space-time trajectories described by the signals must be parallel! This leads to the conclusion that the proper time interval would be $\\Delta t_A=\\Delta t_B$ (according to Special Relativity).\n\t\n\tIf we opt for a curved space, we can preserve the relation $\\Delta t_A<\\Delta_B$, that is to say that time passes more slowly for $A$ than for $B$. This simply results in the fact that in curved geometry, the proper time (!) of an observer depends on the metric.\n\n\tLet us now notice that same developments can be made by assimilating the previous experience with a train that moves with constant acceleration $g$ (horizontal situation of the previous one!). The observer $A$ is in the rear compartment (equivalent to the floor of the Earth in the preceding experiment) sends a wave to his colleague $B$ on the front of the train (at a distance $h$).\n\t\n\tThe observer $B$ receives the wave after a time $\\Delta t=h/c$. During this time, the train has accelerated, and its speed has increased of a value $\\Delta v=g\\Delta t=gh/c$. Therefore, the wave seen by $B$ will be altered by the conventional Doppler effect (\\SeeChapter{see section Music Mathematics page \\pageref{acoustic doppler effect}}):\n\t\n\tWe fall back on the initial results of the Einstein's effect by simply writing:\n\t\n\tgiving gloriously:\n\t\n\tWe find more often this relation in the form below in the literature using the relation between pulsation and frequency and Newton's gravitational force to explicit $g$:\n\t\n\t and putting $h$ as being equal to $r$:\n\t \n\tand after rearranging we also found sometimes in textbooks:\n\t\n\tor even more frequently:\n\t\n\tWe also find this last relation in the following condensed form:\n\t\n\tThe same result can be obtained using the Schwarzschild metric (see further below), hence the name of this effect that can also be obtained from the mathematical tools of Einstein's General Relativity. We will prove later, in a simple way, using this metric that time actually flows more slowly in a gravitational field (assumption we made a few paragraphs above).\n\t\n\tWe see that in all cases:\n\t\n\tsince the right term is positive and not zero. This simply means that the electromagnetic wave in analogy to the color spectrum shifts toward red. Thus, Einstein's effect is indeed a gravitational redshift!\n\n\tThe frequency difference is very small and therefore difficult to measure even with the best spectroscopes. The slightest disturbance can completely mask the Einstein's effect. It will be necessary to wait until 1960 that the experience of Robert Pound and his graduate student Glen A. Rebka Jr. to be capable of measuring a frequency offset with an accuracy of $1\\%$ therefore leaving no doubt as to the reality of this phenomenon.\n\t\n\t\\subsection{Equations of movement}\n\tWe will prove here that the equation of motion of a free particle is constant along its world line by first limiting ourselves to the case of a flat space (Minkowski space type ). Then we will generalize this result in any kind of space using a simple development, to show quite clearly that the equation of motion is independent of the mass and follows the curvature of space !!! Finally, we will present a second proof in any kind of space using the variational principle.\n\n\tSo let us start by proving the equation of motion of a free particle in a flat space.\n\n\tDuring our study of Special Relativity, we proved that the Relativistic Lagrangian of a free particle was given by (\\SeeChapter{see section Special Relativity page \\pageref{lagrangian free relativistic particle}}):\n\t\n\tand for this we started from the action (hypothetical):\n\t\n\tand we came to write:\n\t\n\tNow let us show something interesting! Let us recall that for the Minkowski space-time, we got:\n\t\n\tand restricting ourselves to one spatial dimension, we obtain as relation:\n\t\n\tTherefore:\n\t\n\tand then ... well that's the way, if we put:\n\t\n\twe finally have:\n\t\n\tso we fall back on the same action from a more general form (pure) action that is:\n\t\n\tresult that we had also proved in the section of Electrodynamics !! We can even do better in terms of elegance ...! If we observe well the developments of the previous lines, we observe that in facts the relation:\n\t\n\tand is the special case to one dimension of the relation:\n\t\n\twith as defined earlier above:\n\t\n\tand therefore:\n\t\n\tThus we have the \"\\NewTerm{Fitzgerald-Lorentz factor}\\index{Fitzgerald-Lorentz factor}\\label{fitzgerald lorentz factor}\" or simply \"\\NewTerm{Lorentz factor}\\index{Lorentz factor}\" that is given in general form by:\n\t\n\tas a generalization of Special Relativity!\n\t\n\tTherefore the Lagrangian of a relativistic free particle is in general written:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice, that the Lagrangian above is a homogeneous function of degree one, i.e.\\label{homogeneous lagrangian of relativistic free particle}:\n\t\n\tTherefore as seen in the section of Analytical Mechanics, the Hamiltonian is zero!\n\t\\end{tcolorbox}\n\n\tThis being done, let us come back on our topic... In a space without potential field, we have proved in the section of Analytical Mechanics that the Lagrangian is reduced to the simplest expression of the kinetic energy such that:\n\t\n\tIf we wish to generalize this relation for it to be valid in any type of space (curved or flat), we must introduce the curvilinear coordinates as we have studied them in the section of Tensor Calculus.\n\n\tIn a first time, this gives:\n\t\n\twhere for recall $\\mathrm{d}s$ is the curvilinear abscissa of the path.\n\t\n\tAnd we have proved in the section of Tensor Calculus that:\n\t\n\tThe latter relation is written in the context of relativistic mechanics in a most standard way:\n\t\n\twhere $\\tau$ is a parameter that in relativistic mechanics if for recall the proper time of the particle.\n\t\n\tBefore we focus on curved spaces described by the metric $g_{\\alpha\\beta}$ (which we will do during our proof of the free generalized Lagrangian ), let us restrict us to Euclidean space with the metric (this will be a good exercise to understand) given by the Minkowski matrix (\\SeeChapter{see section Special Relativity page \\pageref{minkowski metric}}):\n\t\n\twhich we denote $\\eta_{\\alpha\\beta}$ to differentiate it from others (because most often used). Finally we in Euclidean space:\n\t\n\tNow let us apply the variational principle:\n\t\n\tThe variation $\\mathrm{d}s$ can be found simply from the variation of $\\mathrm{d}s^2$:\n\t\n\twe find:\n\t\n\tThe factor \"$2$\" is because by symmetry of the Euclidean space, the variations of $\\mathrm{d}x^\\alpha$ and $\\mathrm{d}x^\\beta$ are equal. \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAs we will see later, this relation $\\delta(\\mathrm{d}s)^2$ will not be the same anymore when dealing with curved spaces.\n\t\\end{tcolorbox}\n\tSimplifying a bit, we get:\n\t\n\tWhich is equivalent to write:\n\t\n\tWe can now go back to the action:\n\t\n\tWe rewrite the preceding integral as following (it will be easier to treat):\n\t\n\tIndeed, let check that this form is similar:\n\t\n\tSo let us come back to our integral:\n\t\n\tWe have then two integrals that it will be a bit easier to analyse. The first integral:\n\t\n\tsimply gives an expression evaluated to the temporal extremities $(\\tau_1,\\tau_2)$. Therefore, as the values  $x^\\alpha$ are perfectly known at the time ends, the variational $\\delta x^\\alpha$ is zero at the both extremities and this integral is therefore zero.\n\t\n\tThen we are left only with this integral:\n\t\n\tSo for the variational principle (\\SeeChapter{see section Analytical Mechanics page \\pageref{variational principle}}):\n\t \n\tis respected, we must have:\n\t\n\tNow, we can write this expression explicitly. Indeed, we have:\n\t \n\tRemember also that we have proved earlier above that:\n\t\n\tand that we have:\n\t\n\tTherefore:\n\t\n\tNow, let us recall that during our study of Special Relativity, we have proved the path that led us to define the linear momentum four-vector:\n\t\n\tSo finally, what cancel the variational of the action integral can be written:\n\t\n\tWe thus fall back on the conservation equation of linear momentum (momentum conservation) that we name in the framework of General Relativity \"\\NewTerm{equation of motion}\\index{equation of motion}\". This form of the equation of motion seems dependent on the mass but by digging a bit, we will see that it is fact not.\n\t\n\tMultiplying this relation by $\\eta_{\\mu\\nu}$ we can also write:\n\t\n\tand the same for another observer:\n\t\n\tIn other words, the linear momentum of the particle remains constant along its world line.\n\n\tBut we can also write:\n\t\n\tTherefore:\n\t\n\tAn even more important form of movement equation can be obtained. Indeed using the relations just proved above we can write:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tthis relation is therefore \"massless\" equation of motion in Euclidean space or in other words, in a Minkowski space-time type. In other words, there exists a falling coordinate system wherein the motion of the particle is a uniform movement in space-time.\n\t\n\tIt will be very interesting to compare it later with the equation of motion in a curved space as we will see later (named \"geodesic equation\").\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is equivalent to write the relations of equations of motion with respect to the curvilinear abscissa $\\mathrm{d}s$ or the proper time $\\mathrm{d}t$ (traditionally denoted by $\\mathrm{d}\\tau$ in the field of General Relativity).\n\t\\end{tcolorbox}\n\tWe can now prove that the previous equation of motion, just like the geodesic equation that we will see afterwards, is invariant under Lorentz transformation. Indeed:\n\t\n\tNow let us see a more general form of the equation of motion for any kind of space. The aim is to highlight, and this in a few lines of calculations, that the movement followed by a free particle is independent of its mass (you can already anticipate the interpretation of the path of a photon in a curved space...!).\n\n\tLet us first recall that we have proved in the section of Tensor Calculus (and previously) that:\n\t\n\tgiving us for the generalized Lagrangian of a free particle with $\\mathrm{d}\\alpha=\\mathrm{d}\\tau,u^i=x^\\alpha,u^j=x^\\beta$ (although we fall back on the general expression of the kinetic energy as there is no potential for a free particle):\n\t\n\twhere for recall $\\tau$ is the proper time\\footnote{The proper time is for recall a kind of imaginary clock that travels on the particle and whatever observers watch the clock, they will mathematically agree on the value of the time interval between two \"Tic\" of the clock.} of the particle, it is an invariant!\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis relation is named the \"\\NewTerm{geodesic lagrangian}\\index{geodesic lagrangian}\" by some text book authors.\n\t\\end{tcolorbox}\n\tThis allows us to write (caution! the reader must remember the different relations that we had determined during our study of the Lagrangian formalism in the section dealing with Analytical Mechanics):\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe elimination of the $1/2$ Lagrangian factor results from the symmetry of the metric tensor. If that latter is not symmetric, we can always characterize it by a tensor that is.\\\\\n\n\tIndeed, for recall (\\SeeChapter{see section Tensor Calculus page \\pageref{antisymmetric tensor}}), given $\\vec{x}$ a vector of coordinates $x_1,\\ldots,x_n$ and given:\n\t\n\tThe $T_{ij}$ are not symmetric a priori, but we can write:\n\t\n\tWe put afterwards:\n\t\n\tTherefore:\n\t\n\tAnd the $B_{ij}$ are symmetric.\\\\\n\t\n\tThe quadratic form $q$ can thus always be written with a symmetric matrix, there is even a bijection. The conclusion is that a metric tensor must be symmetric if we want to characterize it by the quadratic form it defines.\n\t\\end{tcolorbox}\n\tThe mathematical interlude having ended, let us continue our physical development. As a consequence of the last relation, the expression of the Hamiltonian obviously becomes:\n\t\n\tsince we consider to be in a space without potential field anymore. Since the square of the velocity is therefore constant over the entire trajectory, we have:\n\t\n\tLet us now establish the equations of motion of any body. We have:\n\t\n\tand as:\n\t\n\tthen:\n\t\n\thence:\n\t\n\tBy putting everything together we get:\n\t\n\tthat we can write identically for the $\\ddot{x}^\\alpha$ by proceeding in the same way as above.\n\n\tThe preceding relation therefore gives the trajectory of a body in motion, in a space without a potential field, as a function of its curvilinear coordinates and of the metric of the space under consideration.\n\n\tWhat is particularly interesting in this result is that mass $m$ (again) is eliminated identically in this equation of motion:\n\t\n\tNotice that we could have used another invariant parameter as well as the proper time $\\tau$ such as the curvilinear abscissa $\\mathrm{d}s$. Hence the preceding equation should be written:\n\t\n\tWe can still simplify this relation, but we will keep this simplification for the second proof of the equation of motion in any space (by making use of the variational principle this time) just further below.\n\n\tIt is very (very) interesting to observe that if we restrict the metric to that of a Euclidean space:\n\t\n\twith:\n\t\n\tWe then have the following simplification:\n\t\n\tThat it remains only:\n\t\n\tBy lowering the indices with the signature it remains:\n\t\n\tWe thus fall back on the first equation of the motion obtained for a flat space! The result is remarkable!\n\n\tThe conclusions is that at the same initial conditions of curvilinear position and velocity in a space (flat or curved) without a potential field (this is what we could think at least according to our initial hypotheses ...), corresponds the same trajectory whatever the mass $m$ of the particle (even for photons - light - whose rest mass is zero!).\n\n\tWe can now study the principle of least action in order to seek the shortest path (both spatially and temporally!) between two points in a given geometric space before addressing the much more complex case of the Lagrangian which takes In account the tensor field...\n\t\n\t\\subsubsection{Geodesic equations}\\label{geodesic equation}\n\tLet us now turn to the same result, but this time using the variational principle. We will fall on the same equation as before for any kind of space with the difference that this time we will take the time to simplify it to arrive at the \"geodesic equation\".\n\n\tStarting from (see previous developments):\n\t\n\twith a parametrization such that $x^i$ and $x^j$ depend of a temporal or spatial parameter.\n\n\tFor a given surface in parametric form, we therefore seek to minimize the length of an arc $\\mathrm{d}s$ by applying the variational principle (not dependent on time) because the photons can not have a faster path in the temporal sense of the term between two points but only a shorter path - in the metric sense of the term!):\n\t\n\tin natural units. Or:\n\t\n\tBy developing, and as the indices have the same range of variation:\n\t\n\thence (we have already multiplied the expression after the second equality by $\\mathrm{d}s/\\mathrm{d}s$ by anticipating the integral that follows):\n\t\n\tThen, we must introduce this development under the integral:\n\t\n\tWorking on the second integral (after the equality), we put:\n\t\n\tSo by integration by part (\\SeeChapter{see section Differential and Integral Calculus}):\n\t\n\tbecomes:\n\t\n\tThus finally:\n\t\n\tThe non-integrated term below:\n\t\n\tis negligible because of the presence of the factor $\\delta \\mathrm{d}x^j$:\n\tTherefore:\n\t\n\tWe make a change of index:\n\t\n\tWhich allows us to factorize $\\delta x^k$:\n\t\n\tAs $\\delta \\mathrm{d}x^k$ and $\\mathrm{d}s$ are different from zero, it is the integrand that must be zero:\n\t\n\tBy developing the second term:\n\t\n\tWhich can also be written (in the physicist way of life...)\n\t\n\tWhich simplifies into:\n\t\n\tWe fall back (again!) on the system of equations which defines the \"\\NewTerm{geodesics}\\index{geodesic}\", that is to say the straight lines of $\\mathcal{E}^n$. These latter then constitute the extremities of the integral which measures the length of a curve arc joining two given points in $\\mathcal{E}^n$.\n\n\tThis last equation is the one which interests us in the case of the free Lagrangian. Indeed, if we take the extreme case of light (or photons if you prefer), the latter will not seek the fastest path at the temporal level. This would totally contradict the postulate of invariance to see the light accelerate according to the path !!! In this context, it means that on the spatio-temporal framework, the only thing that has meaning is the shortest spatial path and not the shortest temporal path! This is why the latter equation is named the \"\\NewTerm{geodesic equation}\\index{geodesic equation}\" or also \"\\NewTerm{generalized Euler-Lagrange equation}\\index{generalized Euler-Lagrange equation}\".\n\n\tHowever, we can write this last equation in a more condensed form by introducing the Christoffel symbols if the metric is a symmetric tensor, that is to say if $g_{\\alpha\\beta}=-g_{\\beta\\alpha}$.\n\t\n\tIndeed:\n\t\n\tAnd as the Christoffel symbol of the first kind (\\SeeChapter{see section Tensor Calculus page \\pageref{christoffel symbols of the first kind}}) is defined by:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is important to remember that this symbol contains almost all information about the space-time metric. We will see an example below as what in a locally inertial frame this Christoffel symbol is equal to zero.\n\t\\end{tcolorbox}\n\tThen the Euler-Lagrange equation is then written:\n\t\n\tThe contracted multiplication (\\SeeChapter{see section Tensor Calculus page \\pageref{tensor calculus}}) of the preceding relation in the canonical basis by $g^{kl}$ gives us:\n\t\n\tHence\n\t\n\tIn the literature a change of index is often carried out in order to at the end (it is still the same expression given that the indices have the same range of variation!):\n\t\n\twith $\\Gamma_{\\alpha\\beta}^\\mu$ being the Christoffel symbol of the second kind (\\SeeChapter{see section Tensor Calculus page \\pageref{Christoffel symbols of the second kind}}) given by:\n\t\n\tand is named in the context of General Relativity the \"\\NewTerm{affine connection}\\index{affine connection}\" or \"\\NewTerm{connection coefficients}\\index{connection coefficients}\" and which makes it possible to find the system of coordinates (through the resolution of a system of differential equations) in free fall in which the particle equation is that of a uniform movement in space-time as a function of a reference system (the two systems are therefore connected by the affine connection).\n\n\tThis relation, of the highest importance, allows us to determine how a moving body will naturally move in a curved space and this perhaps ... regardless of its mass !!! It therefore gives us the metric in which we must set a frame of reference so that it is inertial with respect to the body in question.\n\n\tThe previous equation of geodesics is also the differential equation of the second order which must therefore satisfy the parametric representation of a line on a surface where $s$ is the length along the line so that its total length is extremal!!!\n\n\tAccording to the principle of equivalence, we are therefore entitled to interpret this relation as the equation of motion in any gravitational field of and thus to interpret the second additional term of the equation as the opposite of a gravitational term force per unit mass, that is to say as the opposite of a gravitational field!\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe can also write the equation of the geodesics and using the proper time. Indeed:\n\t\n\tor by using the four-vector velocity:\n\t\n\t\\end{tcolorbox}\n\tAgain, if we restrict ourselves to a flat space-time, we see trivially that we fall back on the first equation of motion that we had obtained since for the Minkowski metric $\\eta_{\\mu\\nu}$ we have immediately $\\Gamma_{\\alpha\\beta}^\\mu=0$:\n\t\n\tbecause the components of the Minkowski metric being constant the Christoffel coefficients are all zero.\n\t\n\tThe solutions of the latter equation are ordinary straight lines given by:\n\t\t\nObviously, in a general curved space-time, the geodesics can not be globally represented by straight lines. However, with a second-order approximation in Taylor's development (\\SeeChapter{see section Sequences and Series}), we fall back on straight lines (which is equivalent to bringing the curved space back to a flat space).\n\n\tThe important thing in all this is that the equation of geodesics makes it possible to observe that the curvature of space determines the trajectories of the bodies which move there whatever their mass, whether they are in uniform motion or not (observe the second derivative in the geodesic equation!). All that remains is then to complete the work and to relate the curvature of space-time with the energy that is there!\n\t\n\tTo fully understand the change of perspective with Newtonian Mechanics, consider yourself falling from a plane without a parachute. From the point of view of General Relativity, you do not undergo any force (!), you are not accelerating, you just follow the curvature of space-time. You follow your normal geodesic trajectory: your acceleration (in the sense of General Relativity!) is zero!\n\t\n\tNow imagine lying on your bed. You are in a gravity field and yet you are not in a free fall. So you are not in the geodesic trajectory following the curvature of space-time. Indeed, you suffer a force that prevents you from following this path: the reaction force of your bed! From the point of view of the General Relativity, if you are static in a gravity field, you undergo an acceleration!\n\t\n\t\\subsubsection{Newtonian Limit}\\label{newtonian limit}\n\tWe have shown above (Shild's argument) that to study gravitation (in particular the Einstein's effect), curved geometry is necessary. We promised also to show that it was enough. Now is the time to do it!\n\n\t\\textbf{Definition (\\#\\mydef):}  The \"\\NewTerm{Newtonian limit}\" is a physical situation where the three conditions below are satisfied:\n\t\\begin{enumerate}\n\t\t\\item[C1.] The particles move slowly with respect to the speed of light. This is expressed as the fact that the variations of the spatial components of their quadrivector are much less than those of the temporal component ($t$ being the proper time):\n\t\t\n\n\t\t\\item[C2.] The gravitational field is static. In other words, any time derivative of the metric is zero!\n\n\t\t\\item[C3.] The gravitational field is weak, that is, it can be seen as a weak perturbation of a flat space:\n\t\t\n\t\twith $|h_{\\mu\\nu}|\\ll 1$ and where $\\eta_{\\mu\\nu}$ is constant (only $h_{\\mu\\nu}$ depends on the coordinates).\n\t\\end{enumerate}\n\tLet us consider the geodesic equation obtained previously:\n\t\n\tThe first condition (C1) leads us to simplify it in the form:\n\t\n\tThe two other conditions (C2 and C3 whose application has been shown in the development below) offer us several simplifications in the expression of the symbol of Christoffel of the second kind:\n\t\n\tThe geodesic equation then becomes:\n\t\n\tand is then equal for the temporal component to ($\\mu=0$):\n\t\n\tBut (recall of the Minkowski metric):\n\t\n\tfor $\\lambda>0$ and for $\\lambda=0$ we have (static metric):\n\t\n\tTherefore, we must conclude that $\\mathrm{d}x^0/\\mathrm{d}t$ is a constant (whatever the choice of the signature of the Minkowski metric).\n\n\tAnd for the spatial components, we know that $\\eta^{\\mu\\nu}$ when reduced to its spatial part is a simple unitary $3\\times 3$ matrix, which gives for each spatial component in the case where we choose (by tradition only!) the signature $(-, +, +, +)$ of the Minkowski metric:\n\t\n\tObviously, the reader can have fun making the development that follows with the inverse signature $(+, -, -, -)$ and he will see that it only changes the sign of potential in the final result of the development):\n\tLet us now rearrange the above relation:\n\t\n\tBy dividing by $(\\mathrm{d}x^0/\\mathrm{d}\\tau)^2$ and restoring $x^0=c\\tau$, we get by making as sequence of simplifications:\n\t\n\tStarting from here we put (because our illustrious predecessors have tried before us):\n\t\n\tsuch as (a relation which will be very useful to us when studying the Schwarzschild metric further below):\n\t\n\twhere $\\varphi$ is the gravitational potential. We fall back here on the expression of the gravitational acceleration (Newton-Poisson equation) of the Newtonian mechanics (\\SeeChapter{see section Astronomy page \\pageref{newton-poisson equation}}):\n\t\n\twith $i=1,2,3$.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThat last equality and analogy for the Newton-Poisson equation may not be obvious for some readers. So another direct analogy (and at the same time a more general result) will be given at the page \\pageref{weak field approximation} using the general Einstein field equations (ie with the cosmological constant)!\n\t\\end{tcolorbox}\n\tThis development, simple but nevertheless remarkable by its interpretation, proves that the curved geometry is sufficient to describe the gravitation (and therefore the theory of Newton)!!!!!!!!!!!! This verification is named by some people the \"\\NewTerm{principle of correspondence}\\index{principle of correspondence}\".\n\t\n\tDemonstrating that a new theory reproduces all the achievements of successful old theories can be extremely difficult. This is because a new theory might use an entirely different mathematical framework that looks nothing like that of the old theory. Finding a way to show that both nevertheless arrive at the same predictions for already-made observations often requires finding a suitable way to reformulate the new theory. This is straightforward in cases where the new theory directly employs the math of the old one, but it can be a big hurdle with entirely new frameworks.\n\n\tEinstein, for example, struggled for years to prove that General Relativity, his new theory of gravity, would reproduce the successes of the predecessor, Newtonian gravity. The problem wasn't that he had the wrong theory; the problem was that he didn't know how to find Newton's gravitational potential in his own theory. Einstein had all the math right, but the identification with the real world was missing. Only after several wrong attempts did he hit on the right way to do it. Having the right math is only part of having the right theory!\n\t\n\t\\subsection{Stress-Energy Tensor}\n\tThe \"\\NewTerm{Stress-Energy Tensor (SET)}\\index{Stress-Energy Tensor}\" (sometimes named \"\\NewTerm{stress–energy–momentum tensor}\\index{stress–energy-momentum tensor}\" or \"\\NewTerm{energy–momentum tensor}\\index{energy-momentum tensor}\\label{energy momentum tensor}\") is a mathematical tool used (in particular) in General Relativity to represent the density and flux of energy and moment in space-time, generalizing the stress tensor of Newtonian physics of mass and energy. It is therefore an attribute of matter, radiation, and non-gravitational force fields. The stress–energy tensor is the source of the gravitational field in the Einstein's field equations of general relativity, just as mass density is the source of such a field in Newtonian gravity\\footnote{The gravitational field is a thing, but it's not an en \"energy field\"! Indeed, a field is one thing; energy is something it can have. But again, as far as we know, there is no such thing as an \"energy field\"! }.\n\t\n\tLet us take for example the SET which considers matter in General Relativity as being able to be approximated by a perfect fluid. In the section Continuum Mechanics we have proved:\n\t\n\twhere $N_i$ has for recall the units of a force and $n_j$ those of a surface. Thus with a more conventional writing:\n\t\n\tIn variational form this gives:\n\t\n\tLet us now calculate:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe do not work with differential elements to avoid being trapped later. It is completely a physicist Do It Yourself approach, but it works well (confirmed by experience...).\n\t\\end{tcolorbox}\n\tAssuming that only the volume and the time makes that the force varies (which assume a constant density and the to be inertial) we then have:\n\t\n\tThis gives simply the tensor product of the velocities (\\SeeChapter{see section Tensor Calculus page \\pageref{tensor product}}):\n\t\n\tIf we generalize this relation to the velocity quadrivectors of Special Relativity with the corresponding notations, then we have by definition the \"\\NewTerm{energy-momentum tensor}\\index{energy-momentum tensor}\" or \"\\NewTerm{Stress–energy tensor}\\index{stress–energy tensor}\":\n\t\n\tor in index form:\n\t\n\tEither in contravariant form (most common form in textbooks):\n\t\n\tThis relation is the justification for which General Relativity is also indicated as a theory of continuous mechanics by some specialists.\n\n\tNow let us prove that the derivative:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWhat we have already pointed out in the section of Tensorial Calculus is written $T^{0j}_{,j}$ in old books or in modern textbooks where the author want to show its technical level...\n\t\\end{tcolorbox}\t\n\tFirst, let us recall that (\\SeeChapter{see section Special Relativity page \\pageref{four vector velocity}}):\n\t\n\tand let us admit that we are in low speeds such as $\\gamma=1$. Then, in a Minkowski metric of type $(+, -, -, -)$ we have:\n\t\n\tBut, we recognize in the parentheses the equation of continuity (conservation of the mass) which we have proved in the section of Thermodynamics and which we know is equal to zero in a system without sources! Therefore:\n\t\n\tLet us also look to what contains the component $T^{00}$ of the stress-energy tensor:\n\t\n\tIn terms of units, this is an energy density (we see directly that this quantity can only be positive).\n\n\tLet us now look at the other components with $i=0$ and $j=1,2,3$:\n\t\n\twhere $p^i$ has the units of linear momentum density.\n\n\tLet us now consider the components of the tensor when $i,j=1\\ldots 3$ (we omit then the first row and the first column):\n\t\n\tWe thus fall back on the components of the stress tensor of a perfect fluid.\n\n\tSo finally, the stress-energy tensor can be written in the form of a symmetric real $4\\times 4$ matrix:\n\t\n\tIn the case where the velocities are small, ie $\\gamma\\rightarrow 1$, we have:\n\t\n\tThis tensor is also sometimes represented as following:\n\t\n\tWe thus fall back in this tensor on the following interpretations of the physical quantities (although rigorously all the components have units which can be seen as density of energy or as a pressure):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.4]{img/cosmology/stress_energy_tensor.jpg}\t\n\t\\end{figure}\n\tThere is another nice and interesting way to get the momentum-flux part of that tensor. \n\t\n\tFirst let us recall the Euler equation of the $1$st form that we get in the section of Continuum Mechanics ($p$ is the pressure and not the linear momentum density!):\n\t\n\tor more explicitly using the material derivative:\n\t\n\twhere for recall $\\vec{f}=-\\vec{\\nabla}U$.\n\t\n\tLet us assume that $\\vec{f}=-\\vec{\\nabla}U=0$. Therefore the latter equation can is reduced to:\n\t\n\tand explicitly to (for $i,k=1,2,3$):\n\t\n\tHence:\n\t\n\tNow let us recall the equation of mass conservation:\n\t\n\tThat we will rearrange and rewrite:\n\t\n\tBut we also have:\n\t\n\tBy injecting in that latter relation the mass conservation equation and the expression we get for $\\partial_t v_i$ then we have:\n\t\n\tTherefore:\n\t\n\tIt appears between the parenthesis are more general writing of the energy-stress tensor for $i,k=1,2,3$, that is the moment flux part:\n\t\n\t\n\tWe then understand better why this matrix is named \"Energy-Momentum Tensor\" or \"Stress-Energy-Momentum Tensor\" since implicitly it is a question of modelling the space by a perfect fluid under shear stresses (tangential forces) and tensions (normal forces).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe sub-matrix of spatial components:\n\t\n\tis the matrix named the \"\\NewTerm{matrix of moments flows}\\index{matrix of moments flows}\" (a name that is quite debatable ...). In Continuum Mechanics (see section of the same name page \\pageref{navier stokes equations}), we have proved that its diagonal corresponds to the pressure, and the other components to the tangential forces due to the dynamic viscosity.\n\t\\end{tcolorbox}\n\tLet us prove that the covariant derivative (\\SeeChapter{see section Tensor Calculus page \\pageref{covariant derivative}}) of the stress-energy tensor is zero such that:\n\t\n\tTherefore:\n\t\n\tLet us begin by developing the first term:\n\t\n\tBut we have:\n\t\n\thence:\n\t\n\tWe find in the squared brackets the equation of continuity which is zero in the absence of sources. On the other hand, the first term in parentheses is non-zero as we saw in our study of the four-accelerator acceleration in the section of Special Relativity:\n\t\n\tBut according to the weak principle of equivalence (WPE), we can always place ourselves in a repository such that locally the acceleration is null, that is to say such that (for recall, we do not put vector arrows for the quadrivectors):\n\t\n\tAnd it comes then:\n\t\n\tSo we now have:\n\t\n\tLet us look at what this last term gives but first recalling that in the section of Special Relativity we had proved that the quadri-acceleration was expressed according to:\n\t\n\tTherefore (we take only the first two components as examples):\n\t\n\tWe will now in fact prove that:\n\t\n\tfor this we start first to prove that:\n\t\n\tFor this we calculate first:\n\t\n\tBut:\n\t\n\tTherefore:\n\t\n\tNow let us prove that:\n\t\n\tthe other components $a^2$, $a^3$ are then verified automatically.\n\n\tFor this we do little bit algebra:\n\t\n\tand therefore we have indeed:\n\t\n\tbut according to the WEP, $a^\\nu=0$ therefore:\n\t\n\tand finally we have indeed under the assumptions stated above:\n\t\n\tWhich is the expression of the conservation of energy in General Relativity (because the components that are energy and momentum are conserved quantities)! By lowering the indices it comes:\n\t\n\t\n\t\\subsubsection{Stress-Energy Tensor for a perfect fluid}\n\tIn physics, a perfect fluid is a fluid that can be completely characterized by its rest frame mass density $\\rho$ isotropic pressure $p$.\n\t\n\tReal fluids are \"sticky\" and contain (and conduct) heat. Perfect fluids are idealized models in which these possibilities are neglected. Specifically, perfect fluids have no shear stresses, viscosity, or heat conduction.\n\t\n\tAccording to these properties, if we rewrite the stress-energy tensor:\n\t\n\tas:\n\t\n\tForm the definition of the perfect fluid, especially the no heat conduction, we have immediately that:\n\t\n\tIndeed, energy can flow only if particles flow. So if they is not heat conduction, there is no particle flow and therefore no momentum density.\n\t\n\tIf there is no viscosity we have also obviously all $\\tau_{ij}$ that are zero.\n\t\n\tTherefore so far we have:\n\t\n\tBut this can be written:\n\t\n\twhere we chooses the signature $(+, -, -, -)$ with for recall:\n\t\n\tand where we assume for the perfect fluid that $\\gamma\\rightarrow 1$ and that we are in the local rest frame such as:\n\t\n\tAs in many cases we consider weak static gravitational field it is common to write the latter boxed relation:\n\t\n\tPerfect fluids are often used in General Relativity to model idealized distributions of matter, such as the interior of a star or an isotropic universe. In the latter case, the equation of state of the perfect fluid may be used in Friedmann–Lemaître–Robertson–Walker equations to describe the evolution of our Universe as we will see it in the next section.\n\t\n\t\\subsubsection{Electromagnetic stress–energy tensor}\n\tIn relativistic physics, the electromagnetic stress–energy tensor is the contribution to the stress–energy tensor due to the electromagnetic field. The stress–energy tensor describes the flow of energy and momentum in space-time. The electromagnetic stress–energy tensor contains the classical Maxwell stress tensor that governs the electromagnetic interactions.\n\t\n\tLet us recall first that in the section of Electrodynamics (\\SeeChapter{see section Electrodynamics page \\pageref{poynting vector}}) we have proved the energy density carried by an electrodynamic wave was:\n\t\n\tAnd also that (\\SeeChapter{see section Electrodynamics page \\pageref{electromagnetic tensor invariant proof}}):\n\t\n\tand that (\\SeeChapter{see section Electrodynamics page \\pageref{equations of motion of a particle in an electromagnetic field}}):\n\t\n\tOk now that we have the necessary tools let's go!\n\t\n\tFrom the previous relation, we get:\n\t\n\tand for the remaining part of the development will take the metric $\\eta_{\\gamma\\sigma}$. Then:\n\t\n\tAs in an inertial frame in which it is at rest where the four-velocity is $u^\\gamma=(c, 0, 0, 0)$, we have then to focus only on $\\gamma=1$. Therefore:\n\t\n\tAs in an inertial frame in which it is at rest where the four-velocity is $u^\\alpha=(c, 0, 0, 0)$, we have then to focus only on $\\alpha=1$. Therefore:\n\t\n\tFurthermore, as:\n\t\n\tWe have:\n\t\n\tSo we have so far:\n\t\n\tPutting these together in :\n\t\n\tThen:\n\t\n\tPutting these together, and inserting a factor of :\n\t\t\n\tgives the energy density:\n\t\n\tSince in general as we have seen just above $u_\\text{tot}=T_{\\alpha\\beta}u^\\alpha u^\\beta$ then the above relation can hold for all rest frames only if:\n\t\n\tThis is the \"\\NewTerm{Electromagnetic stress-energy tensor}\\index{Electromagnetic stress-energy tensor}\\label{electromagnetic stress energy tensor}\".\n\t\n\tBut we should also check that this result is symmetric. Then if we do the calculations (boring elementary algebra but we can give the details on readers request):\n\t\n\twhere for recall:\n\t\n\tand:\n\t\n\tis the \"\\NewTerm{Maxwell stress tensor}\\index{Maxwell stress tensor}\\label{Maxwell stress tensor}\".\n\t\n\t\\pagebreak\n\t\\subsection{Einstein's Field Equations}\\label{einstein field equations}\n\tIt is now time to tackle one of the most beautiful, one of the most famous equations of our time and that shines the eyes of many young students and science passionate: Einstein's field equations. The one that explains why matter (energy) curves space!!! There are several ways to obtain these equations. The two most common ones are either:\n\t\\begin{enumerate}\n\t\t\\item To have an engineer approach: That is to say we proceed by comparison with a known limiting result which is the law of gravitation of Newton (it is the one that we have chosen)\n\n\t\t\\item To have a pure mathematical approach (very elegant but a little fallen from the sky with some circular reasoning): That is to say that we use the Lagrangian formalism and seek by trial and errors a Lagrangian density which allows us to fall back on something known.\n\t\\end{enumerate}\n\tWell this having been said, let us recall before starting some results that we have obtained so far. First, we have succeeded in proving brilliantly that every particle (assumed to be free but left to interpretation ... in a curved space ...) follows the equation of motion of geodesics:\n\t\n\tIn the section of Tensor Calculus, we have proved (not without difficulty...) what we name the \"\\NewTerm{Einstein's tensor}\\index{Einstein's tensor}\" (which is a constant in a given Riemannian space) is given by:\n\t\n\twhere $R^{\\mu\\nu}$ is for recall the Ricci tensor (\\SeeChapter{see section Tensor Calculus page \\pageref{Ricci tensor}}).\n\t\n\tSince the covariant derivative of the Einstein's tensor is zero (\\SeeChapter{see section Tensor Calculus page \\pageref{einstein tensor}}) and we have proved that the covariant derivative of stress-energy tensor is also, then it is tempting to put:\n\t\n\twhere $\\kappa$ is a normalization constant and must satisfy the relation so that it is homogeneous at the level of the units. So it comes (we should better say: \"we think we can write...\") after simplification:\n\t\n\tTo find the expression of the constant, we will place ourselves in the Newtonian limit and request that the preceding relation reproduce the Newton-Poisson equation for the gravitational potential $\\varphi$ (\\SeeChapter{see section Astronomy page \\pageref{gravitation potential}}):\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis relation shows that the gravitational potential is connected to the matter density linearly through its second derivatives. Albert Einstein thought, therefore, that the first member of the equations of the field in General Relativity, member supposed to describe the geometry of space-time, must therefore somehow include the second derivatives, not of the gravitational potential, but of the potentials of the metric. In fact, Albert Einstein tried to generalize the right-hand side of the Poisson equation: the desired quantity must include not only the density of matter but also the momentum (as soon as the body is moving, its energy increases and therefore its mass). To evaluate the gravitational effect of a body, it was therefore necessary to combine its mass at rest with its momentum. It was finally the stress-energy tensor of rank $2$ which is the generalization of the quadrivector momentum of Special Relativity.\n\t\\end{tcolorbox}\n\tWe have proved earlier above that in the Newtonian limit (weak field approximation):\n\t\n\tand in our definition of stress-energy tensor, for a distribution of matter at rest (or in a coordinate frame according to...) only the following component is non-zero:\n\t\n\tIt follows that the Poisson equation can be written (notice that this assumes that the density is calculated from a three dimensional sphere of volume $V=4/3\\pi r^3$...):\n\t\n\tNow let us return to the relation:\n\t\n\tBy contracting the two members of the preceding relation, it comes:\n\t\n\tthat is to say more explicitly (\\SeeChapter{see section Tensor Calculus page \\pageref{einstein tensor}}):\n\t\n\tBut, the Ricci scalar (\\SeeChapter{see section Tensor Calculus page \\pageref{ricci scalar}}) is given by:\n\t\n\tIt comes therefore:\n\t\n\tNow in the special case of the Minkowski metric (with the signature $(-, +, +, +)$) it is immediate that:\n\t\n\tTherefore (implicitly we continue with the Minkowski metric!):\n\t\n\tUsing this last relation, the equation:\n\t\n\tcan finally be written:\n\t\n\tLet us focus on the component $\\rho=\\sigma=0$ (not to be confused with the notation of shear stress and density!!!) such that the preceding relation is written:\n\t\n\tLet us write explicitly this last relation by using the definition of the Ricci tensor (\\SeeChapter{see section Tensor Calculus page \\pageref{Ricci tensor}}) that is for recall:\n\t\n\tThen it comes:\n\t\n\tBut, the Riemann-Christoffel tensor developed in this particular case is given for recall by (\\SeeChapter{see section Tensor Calculus page \\pageref{Riemann-Christoffel symbols}}):\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn the absence of a gravitational field and in Cartesian coordinates, it is logical that all the Christoffel symbols are null. Indeed, the Christoffel symbols translate nothing more than the forces of inertia. But when we have a field of gravitation, the trajectories followed are no longer straight lines, even in the Newtonian case, then the Christoffel symbols are non-zero.\n\t\\end{tcolorbox}\n\tIn the approximation of the weak field slowly variable over time, the Christoffel symbols are of order $\\mathcal{O}^1$ and their products are of order $\\mathcal{O}^2$ and the temporal derivatives are negligible in front of the spatial derivatives. It therefore remains only the terms of order $\\mathcal{O}^1$ such that:\n\t\n\tBut, we have proved in the section of Tensor Calculus that:\n\t\n\tSince then:\n\t\n\tBut in the weak field approximation, the variation of the metric with respect to time is negligible compared to the spatial variation (the approximation is somewhat pulled by the hair it must be said ...):\n\t\n\tTherefore, equating the both relations:\n\t\n\tbecomes (after the simplification by $2$):\n\t\n\tand we immediately notice that we fall back on:\n\t\n\tif and only if:\n\t\n\tConstant which is sometimes named \"\\NewTerm{Einstein's constant}\\index{Einstein's constant}\". It follows immediately that the Ricci scalar is positive and therefore that we are locally in a spherical curvature space.\n\n\tThe \"\\NewTerm{Einstein's field equations}\\index{Einstein's field equations}\" (EFE) is therefore in definitive form:\n\t\n\tor more conventionally:\n\t\n\tOr in explicit form:\n\t\n\tThe left-hand part represents the curvature of space-time as determined by the metric and the right-hand expression represents a modelization of the space-time content of mass / energy. This equation can then be interpreted as a set of equations describing how the curvature of space-time is related to the mass-energy content of the Universe. These equations, as well as the geodesic equation, form the core of the mathematical formulation of General Relativity.\n\t\n\tThe EFE is therefore a dynamic equation describing how matter and energy modify the geometry of space-time. This curvature of the geometry around a source of matter is then interpreted as the gravitational field of this source. The movement of objects in this field is described very precisely by the equation of its geodesic.\n\t\n\tSimilar to the way that electromagnetic fields are determined using charges and currents via Maxwell's equations, the EFE are used to determine the space-time geometry resulting from the presence of mass–energy and linear momentum, that is, they determine the metric tensor of space-time for a given arrangement of stress–energy in the space-time. \n\t\n\tThe mainstream metrics that we will study in this book will be (the first one is already knows to us): the Minkowski metric for flat static space, the Schwarschild metric for curved static space, the Friedmann-Lemaître-Robertson-Walker to describe the Universe metric, the Kerr metric for dynamic curve space and the Morris-Thorne metric for worm-holes:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.45]{img/cosmology/types_of_metrics.jpg}\t\n\t\t\\caption[Some mainstream metrics used in General Relativity]{Some mainstream metrics used in General Relativity}\n\t\\end{figure} \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tKeep in mind that the perceived \"force\" of gravity is a manifestation of space-time curvature, not gravity itself! Gravity is what causes space-time to curve due to energy/mass, and the hypothesized gravitons could be the mechanism for this. In some Quantum Gravitation theories gravity is still a force, it's just the force that causes space-time curvature and not what causes gravitational attraction (not directly anyway)!\n\t\\end{tcolorbox}\n\tOn the other hand, we have just seen that Einstein's equation reduces to the laws of Newton's gravity by using the approximation of weak fields and slow movements. \n\t\n\tThese differential equations are in general a nightmare to solve, the Ricci scalars and tensors are contractions of the Riemann tensor, which include the derivatives and products of the Christoffel symbols, which are themselves constructed on the inverse metric tensor and on the derivatives of it. To compute the whole, it is possible to construct energy-momentum tensors that can invoke the metric as well. It is therefore very difficult to solve the Albert Einstein equations of fields in the general case. Exact solutions for the EFE can only be found under simplifying assumptions such as symmetry. Special classes of exact solutions are most often studied as they model many gravitational phenomena, such as rotating Black Holes and the expanding universe. Further simplification is achieved in approximating the actual space-time as flat space-time with a small deviation, leading to the linearised EFE. These equations are used to study phenomena such as gravitational waves.\n\n\tSince the stress-energy tensor has $4\\cdot 4=16$ components, $10$ of which are actually unique (independent) since the tensor is symmetric (triangle + diagonal), we can see the Einstein equation of the fields as $10$ second-order differential equations coupled on field tensor metric $g_{ij}$.\n\t\n\tSome people are confused about how the curvature of space-time and gravity are related. I am going to explain mainly that starting with simpler examples, and moving to more complicated ones.\n\n\tOkay, let's say we have a sheet of rubber. This is the classic example of space-time. Let's say we take a bowling ball, and set it on the taut sheet of rubber. It has a large mass (compared to what else we'll be putting on the sheet), therefore the sheet curves a lot for the bowling ball. We now have an image in our head like the one below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/general_relativity_2d_space_curvature.jpg}\t\n\t\t\\caption{2D naive representation of space curve near Earth}\n\t\\end{figure}\n\tSo mass leads to curvature. Then, let us take a baseball, say, and set it near the bowling ball. It rolls toward the bowling ball, right? This occurs because of the curvature of the sheet. So, then, curvature leads to gravity. So, if an object has large mass, it will curve space-time dramatically, leading to strong gravity.\n\n\tThis is, of course, an overly simplistic example. It is 2D, and it doesn't take into account other factors. Let us move to 3D (keeping in mind the Universe is accepted to be at 4D, ignoring the holographic principle). The mass of a bowling ball now sucks in space around it, sort of like in the picture below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/general_relativity_3d_space_curvature.jpg}\t\n\t\t\\caption{3D naive representation of space curve near Earth}\n\t\\end{figure}\n\tAnd now, in this case, we can see (or understand) that more mass still leads to more curvature. The greater the mass, the more space-time will \"contract\" around the object. So we still think that mass leads to curvature. Now, if we set an object near this massive object (like the Moon next to Earth) it is \"sucked in\" sort of, by the curvature of space-time, though of course the Moon contracts space-time around it as well. At this point, we can reasonably still conclude that in 3D, mass leads to curvature which leads to gravity.\n\t\n\tA quick glance at the constant of proportionality in the Einstein field equations gives one a rough feeling of much stress-energy is needed to curve space. In SI units, the gravitational constant $G$ is about $6.67\\cdot 10^{-11}\\;[\\text{m}^3\\cdot\\text{kg}^{-1}\\cdot\\text{s}^{-2}]$ while the speed for light $c$ is approximately $3.00\\cdot 10^8\\;[\\text{m}\\cdot \\text{s}^{-1}]$. The Einstein's field equation is then in explicit numerical value given by:\n\t\n\tThe Sun has an average mass-energy density (the dominant component of the stress-energy tensor) of $T^{00}\\cong 1.27\\cdot 10^{20}\\;[\\text{kg}\\cdot\\text{m}^{-1}\\cdot\\text{s}^{-2}]$. The corresponding component of the Einstein Tensor is therefore $G_{00}\\cong 2.64\\cdot 10^{-23}\\;[\\text{m}^{-2}]$. By comparison the Einstein tensor for the flat Minkowski metric is identically zero. So to see a curvature we need to look at hyper-energetic phenomena, like a collapsing star, to fin an Einstein tensor component appreciable greater than this. Even though the space-time metric $g_{\\mu\\nu}$ is not generally flat, throughout most of the universe it is flat enough to be considered as small perturbation of a flat background metric:\n\t\n\tBut, as I said earlier, the Universe is generally thought of as 4D. What does our picture look like when we add time? Well, the time dimension is contracted around a massive object. So let us picture our previous example but that the fabric of space-time has a few clocks embedded in it occasionally. As the space stretches and contracts, so will the clocks (the \"time\") and so the time on those clocks will be \"wrong\" - it'll differ from the other clocks. And in this case, as the Earth contracts space and time around it, it changes the time and space (it curves space-time) and so when another object enters our region of space-time, it is \"sucked in\" still, but so is it's time. This is, of course, a very extreme example, but I hope this shows that we can conclude that mass leads to curvature which leads to gravity. \n\t\n\t\\pagebreak\n\t\\subsubsection{Cosmological Constant (CC)}\n\tAlbert Einstein modified his original field equations to include a cosmological constant term $\\Lambda$ proportional to the metric that led afterwards the Universe model to be static (\\SeeChapter{see section Cosmogony page \\pageref{einstein static universe model}}).\n\t\n\tTo see how this constant was introduced let us recall that we have proved so far that:\n\t\n\tor more explicitly:\n\t\n\tThat is to say:\n\t\n\tBut we have proved in the section of Tensor Calculus that the covariant derivative kills the metric, that is to say for recall:\n\t\n\tTherefore if we choose a constant $\\Lambda$ the latter relation can also we written:\n\t\n\tObviously:\n\t\n\tSo nothing avoid us to put this covariant derivative in:\n\t\n\tas we can write:\n\t\n\tand replacing the $0$ by the covariant derivative of the metric:\n\t\n\tAfter factorization we get:\n\t\n\tAnd simplifying we get the \"\\NewTerm{general Einstein's field equation}\\index{general Einstein's field equation}\":\n\t\n\twhere $\\Lambda$ is the so named \"\\NewTerm{cosmological constant}\\index{cosmological constant}\" (a.k.a. \"dark energy\\index{dark energy}\" in contemporary physics).\n\t\n\tThe cosmological constant may be thought as the energy density associated with vacuum, the space absolutely void of particles. This could be a kind of \"ground level energy\", which often appears in quantum physics. In fact, some theories of elementary particles predict cosmological constant but, unfortunately, of much higher value compared to the actual observations (but the actual observation may be not accurate!). Given this association, the term \"dark energy\" is often used to describe the origin of the cosmological constant.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tSo General Relativity doesn't tell us anything about the value of the CC. In\nquantum field theory, however, we can calculate the vacuum energy density and it comes out to be infinitely large. But in the absence of gravity this doesn't matter: we never measure absolute energies anyway, we merely measure energy \\underline{differences}.\n\t\\end{tcolorbox}\n\t\n\tThe latter relation can be found also in many textbooks in natural units (\\SeeChapter{see section Principia page \\pageref{natural system units}}) and rearranged a little bit as following:\n\t\n\tThe effort from Albert Einstein to introduce this constant was unsuccessful because:\n\t\\begin{itemize}\n\t\t\\item The universe described by this theory was unstable\n\t\t\\item Observations by Edwin Hubble confirmed that our Universe is expanding\n\t\\end{itemize}\n\tSo, Albert Einstein abandoned $\\Lambda$, calling it the \"biggest blunder [he] ever made\".\n\n\t\tDespite Albert Einstein's motivation for introducing the cosmological constant term, there is nothing inconsistent with the presence of such a term in the equations. For many years the cosmological constant was almost universally considered to be $0$. However, recent improved astronomical techniques have found that a positive value of $\\Lambda$  is needed to explain observations that seems to give an accelerating universe.\t\n\t\t\n\tLet us now rearrange the Einstein Field Equations with the cosmological by rearranging it a bit:\n\t\n\tHence the expression of the stress-impulsion tensor for vacuum (ie the energy density for recall!):\n\t\n\tIf we compare this expression with that of a perfect obtained earlier above:\n\t\n\tWe may assimilate vacuum to the pressure term, hence as a fluid of pressure:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/einstein_efe_leiden.jpg}\t\n\t\t\\caption[]{Diagram of gravitational lensing with formula of Albert Einstein on a wall of Museum Boerhaave, Leiden in Netherlands (source: Wikipedia, author: Stichting Tegenbeeld,  photograph: Vysotsky)}\n\t\\end{figure}\n\tWe can also trace invert the Einstein Field Equations (in some cases it helps to solve problems in an easier way!). We start from the EFE:\n\t\n\tand let us recall that:\n\t\n\tSo multiplying the EFE both sides by $g^{\\mu\\nu}$ leads us to:\n\t\n\tMultiplying both sided by $-\\frac{1}{2}g_{\\mu\\nu}$ we get:\n\t\n\tSubtracting the EFE give us finally:\n\t\n\tIf you had the courage (...) to read all the book so far in details, then now you can  really understand the famous Internet illustration below as you have seen all the proofs of the relations visible on it:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/main_physiques_equations.jpg}\t\n\t\\end{figure}\n\t\n\t\\subsubsection{Weak field approximation with cosmological constant}\\label{weak field approximation}\n\tAs we have promised earlier above, we will see now how to fall back on the Newton-Poisson equation directly from the general Einstein's field equation. Obviously that means we just do the inverse reasoning that gave us the opportunity the build the classical Einstein's field equation!!! But they will however be a small difference... we will include the cosmological constant and see how it change the Newton-Poisson equation.\n\t\n\tFor this, we start obviously from:\n\t\n\tLet us write these equations in the equivalent form:\n\t\n\tIn weak field and low speed we know that $T_{00}=\\rho c^2$. But we will also assume that $R=T=\\rho c^2$, so that we can write\\footnote{In the weak field approximation the Ricci scalar should be equal to zero... but we do physics and not maths...}:\n\t\n\tBut as we proved earlier during our introduction of the Newtonian approximation, we have:\n\t\n\tTherefore:\n\t\n\tHence (still using the $-,+,+,+$ metric signature):\n\t\n\tWith the traditional Newtonian approximation:\n\t\n\tIt gives :\n\t\n\tMultiplying both sides by $c^2$ we get after simplification:\n\t\n\tHence:\n\t\n\tin the approximation:\n\t\n\tit gives the following Newtonian approximation:\n\t\n\tAs $\\lambda \\cdot c^2$ as we will see later is also very very small we shall also put it as equal to zero be we don't just for the fun of seeing how it change the gravitation potential.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAnd inverse calculation the gives the following potential:\n\t\n\tObviously and conclusion depends on the fact that experimental data gives $\\Lambda=0$, $\\Lambda<0$ or $\\Lambda>0$! What we still don't really know in the beginning of the 21st century as its values is very near zero (order of $10^{-52}$)!\n\t\\end{tcolorbox}\n\tThe interesting thing is that a the Galaxy scale (ie with galactical input numerical values), that latter results shows that if $\\Lambda>0$, the potential become positive and hence repulse objects (the Universe seems then to expand faster), and when $\\Lambda>0$ the gravitation becomes very strong again at very far distances from the source! Anyway so far, experimental observation seems to reject that in this approximation we are authorized to keep $\\Lambda$ in the final expression.\n\t\n\tIf the reader is asking himself: how can we derive the Lorentz transformation from General Relativity? This is really asking: how is the Minkowski metric a solution of the vacuum Einstein equation? Because Special Relativity is just the geometry defined by the Minkowski metric.\n\n\tIf we take the Einstein equation and turn off gravity we get the vacuum Einstein equation $G_{ab}=0$. The Minkowski metric is a solution of this equation, but of course there are lots of others. From this question we may be hoping that the Einstein equation will simplify in the absence of gravity, and this will make it obvious how Special Relativity emerges. Sadly this isn't the case, because even in the absence of mass gravity waves are still allowed!\n\n\tWe don't think there is any way to simplify the Einstein equation to make the Minkowski metric the only solution. We can require that the first derivatives of the metric vanish, but this is really getting the flat space solution by requiring that space not be curved, which is a bit of a tautology. The problem is that in Special Relativity the Minkowski metric is an assumption i.e. it's where you start from. In General Relativity the Minkowski metric is just one among many solutions so there's nothing fundamental about it.\n\t\n\t\\subsubsection{Einstein-Maxwell equations}\n\tIf the energy-momentum tensor $T^{\\alpha\\beta}$ is that of an electromagnetic field in free space, i.e. if the electromagnetic stress–energy tensor (see page \\pageref{electromagnetic stress energy tensor}):\n\t\n\tis used, then the Einstein field equations are called the Einstein–Maxwell equations (with cosmological constant $\\Lambda$, taken to be zero in conventional relativity theory):\n\t\n\tor written more commonly:\n\t\n\t\n\t\\pagebreak\n\t\\subsubsection{Schwarzschild Solution}\n\tThe \"\\NewTerm{Schwarzschild metric}\\index{Schwarzschild metric}\" is an approximate solution of the EFE  in the case of an isotropic non-rotating gravitational field, without electric charge, zero universal cosmological constant  and at a great distance from the source. It provides the three main proofs of General Relativity: the shift of clocks, the deviation of light by a dense celestial body and the advance of the perihelion of Mercury. These three proofs are very important because Einstein's equation was not experimentally demonstrated at the time.  The solution is a useful approximation for describing slowly rotating astronomical objects such as many stars and planets, including Earth and the Sun. The solution is named after Karl Schwarzschild, who first published the solution in 1916.\n\n\tTo introduce this metric, let us imagine a source (for example the Sun) which produces a gravitational field by means of its mass $M$. We seek, in order to compare with the experiment, the solutions of Einstein's equation (in other words: the metric) outside the source (of the Sun therefore ...) of mass $M$.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThere are several mathematical techniques to introduce the Schwarzschild metric. The reader will be able to search, for example, in the literature or on the Internet the one using a gauge transformation (\"Einstein gauge\" with the \"harmonic gauge\") for the local perturbation constraint. This method is very elegant but very math oriented and we prefer as the reader already know it the \"engineer\" method...\n\t\\end{tcolorbox}\n\tIn other words, this is like assuming to have in the region of space that interests us (considering that there is only the star in question and nothing else around, not even the energy / mass specific to the gravitational field) the following property:\n\t\n\tSo the EFE proved just above without cosmological constant:\n\t\n\tthen becomes:\n\t\n\tBut we proved above that this last relation can also be written using the definition of the Ricci scalar that is given for recall by:\n\t\n\tas following:\n\t\n\tand since the parenthesis is not null since we have proved above that in the Minkowski metric:\n\t\n\tit remains:\n\t\n\tand therefore in extenso the scalar of Ricci is also null. This last relation is named the \"\\NewTerm{vacuum field equations}\\index{vacuum field equations}\".\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/einstein_coin_vacuum_equation.jpg}\t\n\t\t\\caption{Swiss commemorative coin showing the vacuum field equations with zero cosmological constant (top) and action minimization}\n\t\\end{figure}\n\tWe must therefore find the metric that satisfies this relation (in other words, a metric that far from the source corresponds to a flat space since the Ricci tensor is zero). As there are several possibilities let us focus on a particularly elegant case with as the physicists like it ... full of symmetries.\n\n\tThe idea is therefore to find a metric, if possible independent of time (therefore the gravitational field as well will be independent of time!) and ... with spherical symmetry (a star or planet being itself of this form), taking into account the mass of the star (this is the major objective!) and such that far enough from the source (...) or when the mass is zero we fall back on the classical metric known and see earlier above:\n\t\n\tBut this is not totally accurate! Indeed, we work in space-time. But, we have seen that the equation of the curvilinear metric is given in a flat space-time by:\n\t\n\tby passing in spherical coordinates we then have:\n\t\n\tAnd it is on this equation of the metric that we must fall back when we are far from the source or that the mass is extremely small ($M=0$). That is to say the Schwarzschild metric must therefore be asymptotically flat, that is to say corresponding to the flat space of Minkowski.\n\n\tSo let's get to the task. First, we start from what we know (it's better if we can...!). Which means:\n\t\n\tAnd in spherical coordinates including time we have the components $r,\\theta,\\phi,t$. Rigorously, we denote by:\n\t\n\tthe \"\\NewTerm{Schwarzschild coordinates}\\index{Schwarzschild coordinates}\".\n\t\n\tOn a total of $16$ terms implied by the prior-previous relation, we finally retain $10$ namely: the $4$ terms of the diagonal and the $6$ other terms of interaction so as to obtain:\n\t\n\twhere $A$, $B$, $C$, ... are coefficients to be determined.\n\n\tBefore tackling this work, we know that according to one of our starting constraints, when the mass is weak or we are far from a  non high-speed rotating source, we must therefore fall back on:\n\t\n\ttherefore intuitively we can already write:\n\t\n\twhat we must admit it ... is a clear progress ...!\n\n\tIf as we have imposed it to ourselves at the beginning, the equation of the metric is independent of time, we can by symmetry of time (hypothesis ...) make the following change of variable:\n\t\n\twithout this changing anything in our $\\mathrm{d}s^2$. But, we realize very quick that this will not be the case. Immediately, for this to be satisfied we see that we must have:\n\t\n\tWhich brings us (it's already better!) to:\n\t\n\tNow if the system is indeed spherical, the equation of the metric must be invariant by the transformation $\\mathrm{d}\\phi=-\\mathrm{d}\\phi$ (the opposite would be known for a long time if this were not the case experimentally) and/or also for the transformation $\\mathrm{d}\\theta=-\\mathrm{d}\\theta$.\n\n\tSo for this to be correct, we see immediately that in the preceding relation we must impose:\n\t\n\tSo finally it only remains:\n\t\n\twhere $A$, $B$, $C$, $D$ will obviously be independent of time (the opposite would contradict our initial constraint) but may by symmetry of the sphere may be dependent of $r$ such that:\n\t\n\tNow, let us imagine on the sphere (rigorously it is a hypersphere but it helps anyway...) at a fixed distance $r$ from the center of the source of the field at a given instant $t$ fixed. We then only have:\n\t\n\tsince $\\mathrm{d}t$ is zero (fixed time) and $\\mathrm{d}r$ also (fixed distance $r$).\n\n\tWe have also on the way removed the sign $-$ because we anticipated that it will be eliminated in the third equality that will follow and we will put it then back.\n\n\tNow, let imagine we close to the north pole of the sphere ($\\theta=0$) we then only have in first approximation:\n\t\n\tand at equator ($\\theta=\\pi/2$):\n\t\n\tBy symmetry of the field, an infinitesimal angular displacement in each of these two particular zones must, however, be equal. From then on, we can only put (by spherical symmetry):\n\t\n\tHence the equation of the metric is reduced to:\n\t\n\tLet us now show that we can choose a system of coordinates for which $C(r)=1$.\n\n\tLet us introduce for this a distance defined by:\n\t\n\thence:\n\t\n\tTherefore it comes:\n\t\n\thence:\n\t\n\tThis is further simplified by:\n\t\n\tLet's put it all to the square and divide it by left and right by $C(r)r^2=\\bar{r}^2$:\n\t\n\tTherefore after rearranging a bit:\n\t\n\thence:\n\t\n\thence:\n\t\n\tHence the equation of the metric is written:\n\t\n\tIt is therefore as if $C(r)=1$:\n\t\n\tTherefore:\n\t\n\tTherefore:\n\t\n\tand the corresponding contravariant metric tensor (that we will further below):\n\t\n\tsuch that for recall (\\SeeChapter{see section Tensor Calculus page \\pageref{metric tensor euclidean space}}):\n\t\n\tNow, to determine the remaining coefficients (that is, $A$ and $B$) we are going to use the relation that must satisfy metric if it is locally of the Minkowski type:\n\t\n\tand therefore the first Bianchi's identity (\\SeeChapter{see section Tensor Calculus page \\pageref{first bianchi identity}}) will be automatically satisfied.\n\n\tEither in a developed form (\\SeeChapter{see section Tensor Calculus page \\pageref{Riemann-Christoffel symbols}}):\n\t\n\twith obviously (\\SeeChapter{see section Tensor Calculus page \\pageref{first Christoffel identity}}):\n\t\n\tThat is to say that we have quite a lot of work to do... OK! First since the metric is simple the only non-zero derivatives are:\t\n\t\n\tWe then simply deduce the $9$ non-zero elements of the connection (the details are given following the request of a reader):\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\tTo summarize (we have taken the results with the signature $(-, +, +, +)$ of the metric instead of $(+, -, -, -)$ to conform ourselves to the tradition but this does not change the final result):\n\t\n\tNow that we have these terms of the connection, we have to calculate their derivative in order to be able to express the first two terms of:\n\t\n\tThere are then $10$ non-zero terms which are:\n\t\n\tWe finally have for each component of the Ricci tensor:\n\t\n\tThe only elements directly non-zero are then:\n\t\n\tIn a more conventional form (according to the literature) we can simplify a little and moreover keep only the first three equations:\n\t\n\tIf we add the first two equations, we have:\n\t\n\twhich equals:\n\t\n\tAnd this also gives us:\n\t\n\tWe have therefore:\n\t\n\twhich becomes:\n\t\n\tWhere we have divide by $2A$ when passing from the second to the third line.\n\n\tThe reader can verify that a solution of the differential equation is (we can provide the details on request):\n\t\n\tWhere $S$ is a non-zero real constant. Consequently, the metric for a static solution, symmetrically spherical and in the vacuum (...), is written:\n\t\n\tIt remains for us to determine a coefficient. But as:\n\t\n\tIt comes:\n\t\n\tHence:\n\t\n\tFinally:\n\t\n\tLet us notice that the space-time represented by this metric is asymptotically flat, or, in other words, when $r\\rightarrow +\\infty$ the metric approaches that of Minkowski and the space-time variety resembles to that of the Minkowski's space.\n\n\tTo calculate the constants $K$ and $S$, we use the weak field approximation. In other words, we place ourselves far from the center, where the gravitational field is weak. In this case, the component $g_{tt}$ of the metric can be calculated.\n\n\tIndeed, we had studied the Newtonian limit earlier above (see page \\pageref{newtonian limit}) and obtained the following relation:\n\t\n\tSo in extenso we can put without too much fear:\n\t\n\tTherefore:\n\t\n\tFinally we have for the \"\\NewTerm{Schwarzschild metric}\\index{Schwarzschild metric}\":\n\t\n\tThat is to say in natural units:\n\t\n\tWhat ultimately gives the Schwarzschild metric tensor in natural units:\n\t\n\tOr in SI units:\n\t\n\tNotice that when $M=0$ we fall back on the Minkowski metric!\n\t\n\t\\begin{tcolorbox}[colback=red!5,borderline={1mm}{2mm}{red!5},arc=0mm,boxrule=0pt]\n\t\\bcbombe Caution!!! Some reference books have the Schwarzschild metric with different signs because they take the metric $(-, +, +, +)$ instead of the metric $(+, -, -, -)$.\n\t\\end{tcolorbox}\n\t\n\tThe Schwarzschild metric is a solution of Einstein's field equations in \\underline{empty space}, meaning that it is valid only outside the gravitating body. That is, for a spherical body of radius $R$ the solution is valid for $r > R$. To describe the gravitational field both inside and outside the gravitating body the Schwarzschild solution must be matched with some suitable interior solution at $r = R$, such as the \"\\NewTerm{interior Schwarzschild solution}\\index{interior Schwarzschild solution}\".\n\n\tAnd all (physically) apparent singularity appears when (this leads also the time component $g_{11}$ to freeze - time is infinitely dilated - as it is then equal to zero!):\n\t\n\tThis leads indeed the component $g_{22}$ to be equal to infinity! Or in other words, this is equivalent to the coordinate of the radius $r$ to be equal to:\n\t\n\tThis radius, which we had already determined during our study of Classical Mechanics, is named the \"\\NewTerm{Schwarzschild radius}\\index{Schwarzschild radius}\\label{schwarzschild radius}\".\n\n\tTherefore the Schwarzschild solution appears to have singularities at $r = 0$ and $r = 2GM/c^2$; some of the metric components \"blow up\" at these radii. Since the Schwarzschild metric is only expected to be valid for radii larger than the radius $R$ of the gravitating body, there is no problem as long as $R > 2GM/c^2$. For ordinary stars and planets this is always the case. For example, the radius of the Sun is approximately $700'000$ [km], while its Schwarzschild radius is only $3$ [km].\n\t\n\tThe Schwarzschild radius is defined as the critical radius provided by the Schwarzschild geometry, below which nothing can escape: if a Star or other object reaches a radius equal to or less than its Schwarzschild radius then it becomes a \"\\NewTerm{Black Hole}\\index{black hole}\", and any object approaching at a distance from it less than the Schwarzschild's ray will not escape from it. The term is used in physics and astronomy to give an order of magnitude of the characteristic size to which general relativity effects become necessary for the description of objects of a given mass. The only objects that are not Black Holes and whose size is of the same order as their Schwarzschild radius are neutron stars (or pulsars), thus, curiously, also the observable Universe as a whole...\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} The singularity in the metric when the Schwarzschild radius is reached is apparent because it is only an effect of the coordinate system used. It is an instance of what is named a \"\\NewTerm{coordinate singularity}\\index{coordinate singularity}\". As the name implies, the singularity arises from a bad choice of coordinates or coordinate conditions. When changing to a different coordinate system (for example Lemaître coordinates, Eddington–Finkelstein coordinates, Kruskal–Szekeres coordinates, Novikov coordinates, or Gullstrand–Painlevé coordinates) the metric becomes regular at $r=2GM/c^2$\\\\\n\t\n\t\\textbf{R2.} A remarkable theorem states that the Schwarzschild metric is the only solution to Einstein's equations in vacuum possessing spherical symmetry. As the Schwarzschild metric is also static, this shows that in fact in vacuum any spherical solution is automatically static. One interesting consequence of this theorem is that any pulsating star that remains spherically symmetrical can not generate gravitational waves (since the space-time region outside the star must remain static).\\\\\n\t\n\t\\textbf{R3.} As the previous developments are based on the assumption of mathematical tools (Bianchi's identity) that requires a zero torsion tensor (\\SeeChapter{see section Tensor Calculus page \\pageref{torsion tensor}}), there are more complete models that can not by extension use the Einstein equation of fields.\n\t\\end{tcolorbox}\t\n\tNow that we have the Schwarzschild metric we come back to the Schild criterion that we saw in our classical study of the Einstein effect.\n\n\tIf we rewrite the Schwarzschild metric for an static body, we have the metric which is simplified into:\n\t\n\tBy using the gravitational potential (\\SeeChapter{see section Astronomy page \\pageref{gravitation potential}}):\n\t\n\tThe metric is written:\n\t\n\thence by introducing the proper time:\n\t\n\thence:\n\t\n\tTherefore:\n\t\n\tMaclaurin's second-order expansion in series (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}) of the negative root gives:\n\t\n\tTherefore we have:\n\t\n\tThus, this proof that the curvature (gravitation) generates a larger time dilation (in the sense that it flows faster) that the field of gravity is intense (mass $M$ is large) or that we are close to the body under the influence of the field (small radius $r$).\n\n\tFor the Earth, the term:\n\t\n\tis relatively small. But for a Black Hole or a Neutron star, this is no longer the case and the dilation becomes important and the effects accessible to the measure.\n\t\n\t\\subsection{Experimental Tests}\t\n\tWe will now review the $4$ classical experimental checks of the $20$th century of the General Relativity theory which are:\n\t\\begin{enumerate}\n\t\t\\item The precession of the perihelion which, in terms of numerical results, posed a problem for us with the tools of Classical Mechanics (\\SeeChapter{see section Astronomy page \\pageref{classical precession of perihelion}}).\n\n\t\t\\item The deflection of electromagnetic waves (light) passing close to a massive stellar body which in the numerical results also posed a problem to us with the tools of Classical Mechanics (\\SeeChapter{see section Astronomy page \\pageref{classical deflection of light}}).\n\n\t\t\\item The proof of the Schild criterion (already made in the preceding paragraphs) as the only way to explain rigorously the gravitational redshift and the hypothesis of slowing down time in a gravitational field.\n\n\t\t\\item The delay of electromagnetic signals propagating near dense bodies. Delay referred to as \"Shapiro effect\" whose numerical applications are used for the operation of the G.P.S and which will be discussed later.\n\t\t\n\t\t\\item The detection of Gravitational waves in the early 21st century.\n\t\\end{enumerate}\n\t\\subsubsection{Gravitational Redshift}\n\tWe know very good that in the non inertial Earth's referential frame, the space time line element between the two events can be written as:\n\t\n\tBut as the observer is at rest in his own referential, the only non null coordinates is $x_0$, so that the square of the line element can be simplified to:\n\t\n\tIf our observer is at rest in his own referential, we know also how to express the space time distance with respect to the proper time $\\tau$:\n\t\n\tAnn therefore:\n\t\n\tThat is:\n\t\n\tBut we have also proved earlier that in the weak static field approximation:\n\t\n\tTherefore:\n\t\n\tWe can therefore write:\n\t\n\tThis equation tells us that clocks run slower in a gravitational field as seen by a distant observer, this effect is known as \"\\NewTerm{gravitational time dilation}\\index{gravitational time dilation}\" or \"\\NewTerm{gravitational redshift}\\index{gravitational redshift}\"!\n\t\n\tAs a direct consequence, because frequency is the reciprocal of the period (time interval), we have:\n\t\n\t \n\twhere $f_{\\infty}$ is the frequency of the wave as measured by a distant observer of a static and weak gravitational source and $f_g$ is the frequency of the wave measured at the point where the is a gravitational source.\n\t\n\tThis equation tells us that the frequency of a wave as recorded by a distant observer is less than the frequency recorded by an observer located where the events occurred in the gravitational field. This phenomenon is known as the \"\\NewTerm{gravitational redshift}\\index{gravitational redshift}\", because a reduction in frequency means a shift toward the longer wavelengths or red end of the electromagnetic spectrum.\n\t\n\tWe can think of the photons losing energy as they climb out of the gravitational field - loss of energy equating to drop in frequency.\n\t\n\tA more realistic scenario is that the second observer is itself under the effect of the gravitational field.\n\n\tLet's assume that the observer $A$ pointing the torch stands at the surface of the Earth at a distance $r_a$ from the center of the Earth and that the second observer $B$ stands by example at the top of a tower at the distance $r_b = r_a + \\delta h$ with $\\delta h$ very small in comparison to $r_a$.\n\t\n\tWe can then write:\n\t\n\tTherefore:\n\t\n\tLet us now use the Schwarzschild radius notation:\n\t\n\tIf we suppose as it is the case on Earth that $R_S\\ll r_a$ and so that $R_S\\ll r_b$,  the redshift can be approximated by a Maclaurin first order expansion (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tthen:\n\t\n\tTherefore:\n\t\n\tFinally:\n\t\n\tAlso written sometimes (according to $\\Phi=GM/r$):\n\t\n\tThe effect is now considered to have been definitively verified by the experiments of Pound, Rebka and Snider between 1959 and 1965. The Pound–Rebka experiment of 1959 measured the gravitational redshift in spectral lines using a terrestrial $^{57}\\mathrm{Fe}$ gamma source over a vertical height of $22.5$ [m].\n\t\n\tA numerical application gives therefore for this experiment:\n\t\n\twhile Pound and Rebka have found: \n\t\n\t\n\tSo first wee see that $f_B<f_A$ so there is indeed a shift to the red. Secondly we have an average shift of the frequency to the red!\n\t\n\t\\subsubsection{Precession of Mercury's Perihelion}\\label{general relativity precession of mercury perihelion}\n\tLet us now treat one of the most famous examples of General Relativity: the precession of the Mercury's perihelion. We had already dealt with this case in the Astronomy section, but we had mentioned that the theoretical numerical result did not correspond to the experimental observations. We shall see in the equivalent of almost ten A4 pages of detailed developments how General Relativity makes it possible to reconcile theory and experience.\n\n\tTo study this case, we will use the Lagrangian formalism seen in the section of Analytical Mechanics.\n\n\tFirst, let us recall that we obtained for the metric of Schwarzschild:\n\t\n\tWhat we will write by dividing by $\\mathrm{d}s^2$:\n\t\n\tAnd to abbreviate the notations, we put $l=GM/c^2$ such that:\n\t\n\tNow let us recall that (\\SeeChapter{see section Analytical Mechanics page \\pageref{action integral}}) in natural units:\n\t\n\tSo (it's very rude but it works ... This is physics!...):\n\t\n\tFinally it means that the Lagrangian is:\n\t\n\tThe equations of Lagrange give us for the $\\theta$ coordinate \\SeeChapter{see section Analytical Mechanics page \\pageref{euler lagrange}}):\n\t\n\twith therefore:\n\t\n\tHence:\n\t\n\tand:\n\t\n\tFrom where finally for the coordinate $\\theta$:\n\t\n\tLet us do the same for $\\phi$. First, we have:\n\t\n\tand:\n\t\n\tAnd it comes immediately from the application of the Euler-Lagrange equation:\n\t\n\tLet us do the same for $t$:\n\t\n\tAnd it comes here also immediately:\n\t\n\tTherefore:\n\t\n\tNow let us assume that the motion of Mercury is in the equatorial plane such as $\\theta=\\pi/2$. Hence, the relation obtained above:\n\t\n\tsimplifies into:\n\t\n\thence:\n\t\n\tWe have, therefore, the expression of the Universe line, which, for recall, is:\n\t\n\tWhich since $\\theta=\\pi/2$ (which is therefore a constant) is simplified into:\n\t\n\tLet us now do the following replacement:\n\t\n\tWhich is therefore a constant as we have proved just above and also the following replacement (which is also a constant as we proved just above):\n\t\n\tIn the universe line element and we get:\n\t\n\tLet us consider also $r$ as a function of $\\phi$ then:\n\t\n\thence:\n\t\n\tThus, we can rewrite the universe line in the form:\n\t\n\tLet us make a change of variable by putting:\n\t\n\thence:\n\t\n\tWhich gives for our universe line:\n\t\n\tor:\n\t\n\tBy differentiating:\n\t\n\tOr written differently:\n\t\n\tWhich simplifies and factorize itself into:\n\t\n\tThe first possible solution is obviously:\n\t\n\tHence as $r=1/u$:\n\t\n\tThe circular motion is thus also a solution of Kepler's problem in general relativity in a Schwarzschild field (ouf!).\n\n\tThe other solution will be:\n\t\n\tOr written differently:\n\t\n\tit corresponds to the orbit of Kepler's problem.\n\n\tLet us do the comparison by considering in Newton's mechanics the motion of a particle of mass $m$ in a potential $V$. The Lagrangian (\\SeeChapter{see section Analytical Mechanics page \\pageref{free lagrangian}}) is then:\n\t\n\tIn polar coordinates we have already seen in different section (Vector Calculus and Astronomy) that the speed is then written:\n\t\n\tUsing the Euler-Lagrange equation we have the equation of motion:\n\t\n\tWhich give:\n\t\n\thence:\n\t\n\tAnd as we have seen in the section Astronomy:\n\t\n\tIs the constant of areas. Let us introduce:\n\t\n\tHence:\n\t\n\tand therefore:\n\t\n\tSo:\n\t\n\tThe equation:\n\t\n\ttherefore becomes:\n\t\n\tBut:\n\t\n\thence:\n\t\n\ttherefore:\n\t\n\twhere:\n\t\n\tIt is therefore the \"\\NewTerm{non-relativistic Binet formula}\\index{non-relativistic Binet formula}\" which gives the relation between $u = 1 / r$ and $\\phi$ for a central force (\\SeeChapter{see section Classical Mechanics page \\pageref{central force}}). In the case of a Newtonian potential:\n\t\n\tHence:\n\t\n\twith for recall:\n\t\n\tNow let us recall the form of that which we had obtained just before with the General Relativity:\n\t\n\tThus, we see that the analogous term in relativity is:\n\t\n\tand that general relativity adds the term $3lu^2$. Now, as in General Relativity:\n\t\n\tThen:\n\t\n\tHowever, in the case of the approximation of weak fields:\n\t\n\thence:\n\t\n\tSo finally:\n\t\n\tThat said, it is really interesting to note that the equation for General Relativity:\n\t\n\tcan be interpreted as Binet's equation for Classical Mechanics:\n\t\n\twith the potential:\n\t\n\twith $\\gamma=lK^2$.\n\t\n\tLet us now return to our equation:\n\t\n\tWe would like to know if the second term on the right of the equality is negligible or not with respect to the first term on the right of the equality in order to be able to apply the theory of perturbations.\n\n\tWe will first put with the help of the weak field approximation given above:\n\t\n\tNow let us calculate the ratio:\n\t\n\tRecall that in polar coordinates (\\SeeChapter{see section Vector Calculus page \\pageref{polar coordinates}}):\n\t\n\tIn approximation, we can roughly put that:\n\t\n\tTherefore for Mercury ...:\n\t\n\tSo we see immediately that we can apply the variational theories to the term $3lu^2$. Thus, let us put:\n\t\n\tThe equation:\n\t\n\ttakes the shape:\n\t\n\tTo solve this differential equation, we will use the perturbation theory approach (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{regular methods of perturbations}}). We will therefore focus on a solution of the form of a Taylor expansion in second order only in $\\varepsilon$:\n\t\n\twhere $u_0$, $u_1$ are obviously dependent on $\\phi$ and will have to be determined! To do this, we know that we must replace the previous expression in the differential equation such that:\n\t\n\tWhich simplifies into:\n\t\n\twhere let us recall that:\n\t\n\tis the classical equation obtained earlier above:\n\t\n\tLet us consider the solution of the type:\n\t\n\twhere $D$ is an arbitrary constant. Now, as we have seen in the section of Astronomy in the case of the precession of perihelion:\n\t\n\tis actually an ellipse. Which means that any solution of the form:\n\t\n\tis also an ellipse!\n\t\n\tFor the equation in $\\varepsilon$:\n\t\n\twhich is simplifies into:\n\t\n\tSince (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}):\n\t\n\tIt comes:\n\t\n\tTo determine $u_1$, let us decompose it into three terms:\n\t\n\tThis gives us immediately (by injecting the three terms respectively into the second derivative and the term alone):\n\t\n\tSo finally:\n\t\n\tThe solution sought is finally:\n\t\n\tIt is therefore with:\n\t\n\tthat it is necessary to calculate the displacement of the perihelion (we arrive soon... pfiuuuuu...).\n\t\n\tWe see relatively quickly by observing the preceding relation that the only term whose amplitude is not constant is $\\varepsilon D\\phi\\sin(\\phi)$.\n\n\tLet us then recall that (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}):\n\t\n\tThis can also be roughly written as a first approximation using Maclaurin's first-order expansion (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tWe know that the zero order orbit is:\n\t\n\tThe effect of the last term:\n\t\n\tis therefore to introduce a small periodic variation in the radial distance. This term does not affect the displacement of the perihelion. This is the term $\\varepsilon\\phi$ in:\n\t\n\twhich introduces a non-periodicity which can be non-negligible in the case where $\\phi$ is large.\n\t\n\tThe perihelion (the point closest to the Sun for recall) therefore appears when $r$ is the minimum therefore $u=1/r$ maximum. But, $u$ is maximum when the term which interests us is maximum, that is to say:\n\t\n\tWe have approximately:\n\t\n\tFor two successive perihelions, we have an interval:\n\t\n\tinstead of $2\\pi$. Thus, the displacement for a revolution is:\n\t\n\twhere $K$ is therefore the constant of the areas and $M$ the mass of the central star and since:\n\t\n\tFinally we have in the end:\n\t\n\tRelation to be compared with that obtained in the section of Astronomy with a Classical Newtonian treatment:\n\t\n\tWe thus fall back at the perfection on the factor $6$ which was lacking in the conventional treatments!\n\n\tFor Mercury a numerical application gives:\n\t\n\tand the experiment gives $\\delta\\phi\\cong 42.5''\\pm 1.0''$. By Albert Einstein's own admission, in obtaining this result he had palpitations and the impression of grazing a heart attack and satisfied with his Herculean effort which had exhausted him he took a long period of rest.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is perhaps useful for the reader to know that Albert Einstein and Michele Besso took almost $2$ years (!!!) by trials and errors to find the good result above. The first time they had an error of $4000\\%$ in comparison to the experimental observed value, the second time an error of $400\\%$ and finally the value above (after that Albert Einstein had identified that he choose the wrong Tensor for his theory).\n\t\\end{tcolorbox}\n\tTo conclude on this subject, let us mention a second frequent writing in the literature concerning the result obtained. Indeed, we have proved in the section of Astronomy that the focal parameter was given by:\n\t\n\tIt therefore remains:\n\t\n\tand we have also proved in the section of Analytical Geometry that:\n\t\n\tIt thus comes in the end the most classic form:\n\t\n\t the numerical values for Mercury precession with $G=6.674\\cdot 10^{-11}\\;[\\text{m}^3\\cdot\\text{kg}^{-1}\\cdot \\text{s}^{-2} ]$, $M=1.99\\cdot 10^{30}$ [kg], $e=0.260$, $a=5.787\\cdot 10^{10}$ [m] and $T=88$ [days], gives for a century ($100$ years of $365$ days):\n\t\n\tThus a precession of an angle of $43,00415''$. This is a reaaaaallllly good result!\n\t\n\tNow there is a curious exercise to be play here with the relation of $\\Delta \\alpha$, let's compute the relativistic size of the perihelion for various astrophysics systems.\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|l|l|c|c|c|}\n\t\t\\hline\n\t\t\\rowcolor[HTML]{9B9B9B} \n\t\t\\multicolumn{1}{|c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{System}} & \\multicolumn{1}{c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Central Mass}} & \\multicolumn{1}{c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{$\\pmb{a}$}} & \\textbf{$\\pmb{e}$} & \\textbf{$\\pmb{P_\\text{orb}}$} & \\textbf{$\\pmb{\\Delta \\alpha}$} \\\\ \\hline\n\t\tMercury-Sun & $1\\; M_{\\odot}$ & $5.70\\cdot 10^{10}$ [m] & $0.2056$ & $87.969$ days & $0.4299''$ /yr \\\\ \\hline\n\t\tPSR J0737-3039 & $1.35+1.24\\; M_{\\odot}$ & $8.66\\cdot 10^8$ [m] & $0.09$ & $2.4$ hours & $17.6^\\circ$ /yr \\\\ \\hline\n\t\tEarth-Moon & $1.35+1.24\\; M_{\\oplus}$ & $3.84\\cdot 10^8$ [m] & $0.0549$ & $27.32$ days & $0.00027''$ /yr \\\\ \\hline\n\t\tJupiter-Io & $1.899 \\cdot 10^{27}$ [kg] & $4.33\\cdot 10^8$ [m] & $0.0041$ & $1.769$ days & $2.68''$ /yr \\\\ \\hline\n\t\tJupiter-Europa & $1.899 \\cdot 10^{27}$ [kg] & $6.71\\cdot 10^8$  [m] & $0.094$ & $3.551$ days & $0.84''$ /yr \\\\ \\hline\n\t\tJupiter-Amalthea & $1.899 \\cdot 10^{27}$ [kg] & $1.81\\cdot 10^8$  [m] & $0.0032$ & $43.043$ [s] & $22.15''$ /yr \\\\ \\hline\n\t\t\\end{tabular}\n\t\\end{table}\n\t\n\t\\subsubsection{Deflection of Light (light bending)}\n\tWe have just proved that:\n\t\n\tBy replacing the factors by their respective values, we have:\n\t\n\tBut we have seen above that:\n\t\n\tand as $K$ is the areas constant given by the conservation of the momentum itself constant (\\SeeChapter{see section Classical Mechanics page \\pageref{angular momentum}}):\n\t\n\tWe then have for a photon $m\\rightarrow 0\\Rightarrow K\\rightarrow +\\infty$.\n\t\n\tLet us put now to simplify the notations:\n\t\n\tThen:\n\t\n\tThe term to the right of the equality is small (considering the constants that intervene therein) so that an approximate form of the differential equation is:\n\t\n\tof which a particular solution, which we know in advance, is interesting:\n\t\n\tWe carry this approximated solution in the initial differential equation and we get:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tWhat follows is going to be very subtle (how to guess something like that ...?). First we will create a new differential equation:\n\t\n\tThe trick is to multiply this equation by $\\mathrm{i}$ and sum it to the original differential equation:\n\t\n\tWhat we will denote by:\n\t\n\tAnother trick is to look for a particular solution of the previous relation in the form:\n\t\n\tThen we have:\n\t\n\tThis injected into our new differential equation gives:\n\t\n\tWe deduce immediately:\n\t\n\tA particular solution of the original differential equation is thus:\n\t\n\tEither by using the remarkable trigonometric relations (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}):\n\t\n\tIt comes:\n\t\n\tThe general solution is:\n\t\n\tIf we admit that the light is very weakly deviated by the Sun, the radius of curvature ($1/r$) of its trajectory will be very small.\n\n\tTherefore:\n\t\n\tsuch that:\n\t\n\tThe first term is predominant relatively to the second because of the factor $r_g$ that is very small on the second. For what will follows, we will proceed as in the in the section Astronomy (only the notations change) for the study of the deflection angle (if you don't come back to it, it can be difficult to understand the justification of what will follow!). We put without loosing in generality:\n\t\n\tTherefore:\n\t\n\tand as:\n\t\n\tit comes:\n\t\n\tUsing trigonometric identities again:\n\t\n\tIt comes:\n\t\n\t$\\theta$ being supposed as very small we do a Maclaurin development (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}) to the first order of the trigonometric functions:\n\t\n\tWhich gives:\n\t\n\tTherefore after a series of approximation... and of hypothesis at the limit of what is acceptable..., we then get for the \"\\NewTerm{deflection of light}\\footnote{Also sometimes named \"depiction of light\".}\\index{deflection of light!General Relativity}\" ($R$ is sometimes named the \"\\NewTerm{impact parameter}\", that is to say he distance of nearest approach of the light-beam to the center of mass):\n\t\n\tinstead of the result that we get following the Newtonian approach in the section Astronomy (see page \\pageref{classical deflection of light}):\n\t\n\tWe thus founded the factor $2$ that was missing in the classical treatment, relatively to experimental observations, that we have proved in the section of Astronomy:\n\t\n\tWhat is often pictured in the media by the following drawing:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1.5]{img/cosmology/light_deflexion.jpg}\t\n\t\\end{figure}\n\tThis deviation have been observed experimentally by measuring the position of stars in the vicinity of the solar disk during the 1919 eclipse by Arthur Eddington and his team. After the advance of the perihelion of Mercury, this was the second test successfully passed by the General Relativity. It was this event that made Albert Einstein famous among the general public. Today, the deviation of light rays can be measured with much greater precision by considering radio signals emitted by extra-galactic sources (quasars, AGN, etc.): the prediction of the General Relativity has been confirmed to the nearest thousandth.\n\n\tThe deviation of light rays is today very important in observational cosmology. Since it is at the origin of the phenomenon of gravitational mirage, also named \"gravitational lens\".\n\n\tIt is interesting to notice that the whole theory of gravitational mirages is based on the relation:\n\t\n\tat least for a point detector. It is the only ingredient of General Relativity used in the calculation of images.\n\t\n\tFor recall is a Flash animation of what a light bulb light rays propagation in vacuum, ON, would look like:\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_vacuum.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575751871}).\n\t\n\tAnd here is also for recall a Flash animation of what a light bulb light rays propagation in vacuum putted in the presence of a punctual mass, ON, would looks like:\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_newton.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575750678}).\n\t\n\tAnd here is a Flash animation of what a light bulb light rays propagation in vacuum putted in the presence of a punctual mass but taking into account General Relativity, ON, would looks like (wee can see in gray the Schwarzschild radius of the punctual mass):\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_schwarzschild.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575751098}).\n\t\n\tAnd here is a Flash of what a light bulb light rays propagation in vacuum putted in the presence of a rotating mass but taking into account General Relativity, ON, would looks like (wee can see in dark gray the Schwarzschild radius and in light gray the ergosphere radius of the rotating mass):\n\t\\begin{center}\n\t\\centering\n\t\t\\includemedia[activate=pageopen,width=250pt,height=250pt,\n\t]{}{swf/deflection_kerr.swf}\n\t\\end{center}\n\tThe animation above will run for people having a PDF reader with Adobe Flash player installed and activated (otherwise see here: \\url{https://vimeo.com/575750255}).\n\t\n\tIn observational astronomy an \"\\NewTerm{Einstein ring}\\index{Einstein ring}\", also known as an \"\\NewTerm{Einstein-Chwolson ring}\\index{Einstein-Chwolson ring}\" or \"\\NewTerm{Chwolson ring}\\index{Chwolson ring}\", is the deformation of the light from a source (such as a galaxy or star) into a ring through gravitational lensing of the source's light by an object with an extremely large mass (such as another galaxy or a Black Hole). This occurs when the source, lens, and observer are all aligned.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.55]{img/cosmology/einstein_ring_lrg_3_757.jpg}\t\n\t\t\\caption{Einstein Ring LRG 3 757}\n\t\\end{figure}\n\tWhen it comes to the distant universe, even the keen vision of NASA's Hubble Space Telescope can only go so far. Teasing out finer details requires clever thinking and a little help from a cosmic alignment with a gravitational lens.\n\n\tBy applying a new computational analysis to a galaxy magnified by a gravitational lens, astronomers have obtained images ten times sharper than what Hubble could achieve on its own. The results show an edge-on disk galaxy studded with brilliant patches of newly formed stars.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.45]{img/cosmology/hubble_lens_gravitational_magnification.jpg}\t\n\t\t\\caption[]{SGAS J111020.0+645950.8 arc magnified by the galaxy cluster SDSS J1110+6459 (source: NASA, ESA, and T. Johnson (University of Michigan))}\n\t\\end{figure}\n\tIn the above Hubble photograph of a distant galaxy cluster, a spotty blue arc stands out against a background of red galaxies. That arc is actually three separate images of the same background galaxy. The background galaxy has been gravitationally lensed, its light magnified and distorted by the intervening galaxy cluster. On the right: How the galaxy would look to Hubble without distortions.\n\t\n\t\"\\textit{When we saw the reconstructed image we said, 'Wow, it looks like fireworks are going off everywhere}\", said astronomer Jane Rigby of NASA's Goddard Space Flight Center in Greenbelt, Maryland.\n\n\tThe galaxy in question is so far away that we see it as it appeared $11$ billion years ago, only $2.8$ billion years after the Big Bang. It is one of more than $70$ strongly lensed galaxies studied by the Hubble Space Telescope, following up targets selected by the Sloan Giant Arcs Survey, which discovered hundreds of strongly lensed galaxies by searching Sloan Digital Sky Survey imaging data covering one-fourth of the sky.\t\n\t\n\tThe gravity of a giant cluster of galaxies between the target galaxy and Earth distorts the more distant galaxy's light, stretching it into an arc and also magnifying it almost 30 times. The team had to develop special computer code to remove the distortions caused by the gravitational lens, and reveal the disk galaxy as it would normally appear.\n\t\n\tThe resulting reconstructed image revealed two dozen clumps of newborn stars, each spanning about $200$ to $300$ light-years. This contradicted theories suggesting that star-forming regions in the distant, early universe were much larger, $3,000 $light-years or more in size.\n\t\n\t\\subsubsection{Shapiro Effect (delay)}\\label{shapiro effect}\n\tIn 1964,  Irwin Shapiro demonstrated that a ray of light was not only deflected by passing near a mass, but also that the duration of its path was lengthened in relation to a Euclidean geometry. He calculated that the delay should be about $200$ microseconds, therefore perfectly measurable, for a line of sight shaving the Sun. He then suggested systematically measuring the time taken by a radar signal to make the round trip between the Earth and a planet passing behind the Sun (so that the effect is maximal). This was first accomplished with radar echoes on Mars, Venus or Mercury, with an accuracy of the order of $20\\%$. The result was very clear: the time required for a radar signal to make the go and come back between the Earth and the other Planet increases suddenly just before the planet passes behind the Sun and decreases just as suddenly when it reappears.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe sometimes also talk of \"slowing down of the light\" near the Sun to describe the Shapiro effect, but it is an awkward and erroneous expression. As we have already been mention it, the speed of light is constant in General Relativity as well as in Relativity for all observers (but for recall this doesn't mean that the speed of light in constant during the life of our Universe!). In the case of the Shapiro effect (and in other similar cases), what changes is the flow of time where the light passes, in relation to what it is where the observer is located.\n\t\\end{tcolorbox}\n\tAlthough this is a weak effect, it has been verified precisely since the arrival of the Viking probes on Mars in 1976, using signals sent from Earth to Mars and reflecting on the latter by the probes (see the principle of the experiment in the figure further below). In addition, there is now even an increasingly common object for which the Shapiro effect must be taken into account: the \"G.P.S.\" (Global Positioning System). Indeed, despite the weakness of the field of gravitation, a geographical precision of a few meters requires such details in the calculation! However, a satellite has recently been launched to verify in the Earth's gravitational field an even lower effect predicted by General Relativity and which does not even intervene in GPS: the drag over of space also known as the \"\\NewTerm{Lense-Thirring effect}\" due to the rotation of Earth.\n\t\n\tLet us point out for the GPS that two phenomena of error are known within the framework of the Relativity:\n\t\\begin{enumerate}\n\t\t\\item The satellites rotating around the Earth at a speed of approximately $14,000$ kilometres per hour then delay $7$ millionths of a second per day (Relativity).\n\n\t\t\\item At an altitude of $20,200$ kilometres, that of the satellite orbit, the lower gravitational field advances the satellite clocks by $45$ millionths of a second per day.\n\t\\end{enumerate}\n\tThe sum of the two corrections gives a drift of $38$ millionths of a second per day, a staggering figure for a GPS system whose precision must be $50$ billionths of a second per day!!!\n\n\tLet us make the calculation for a ray touching the surface of the Sun. For this, we take up our Schwarzschild's metric given for recall by:\n\t\n\twith:\n\t\n\tFor a photon, we know that $\\mathrm{d}s=0$ and therefore the equation of the Schwarzschild's metric is then written:\n\t\n\tThe trajectory of the photon taking place in the equatorial plane of the Sun, we put:\n\t\n\twhich simplifies even more the equation of the metric by:\n\t\n\tTo simplify even more, we make the hypothesis that the trajectory (in polar coordinates) of the photon shaving the Sun is rectilinear such that (for one of the polar components of the plane):\n\t\n\twhere $r_\\odot$ is the ray of the Sun. We will use this assumption to simplify the equation of the metric. For this we rearrange:\n\t\n\tWe derive (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{usual derivatives}}):\n\t\n\tIf we square everything:\n\t\n\thence:\n\t\n\tWe can now rewrite the equation of the metric:\n\t\n\tTaking the square root:\n\t\n\tSince $r>r_\\odot$ and $r_g\\ll 0$ then:\n\t\n\tTherefore, we have using the Maclaurin developments (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}) to the first order:\n\t\n\tWe have then:\n\t\n\tFinally, we get once condensed:\n\t\n\tWhat it is traditional to write (we take out the $1 / c$ of the different terms):\n\t\n\tIf there is no mass then space-time is flat and $r_g=0$. Therefore:\n\t\n\tWe can thus distinguish the classical time from the extra time generated by the curved space. The \"delay\" will therefore be given by:\n\t\n\tThen, to integrate the four functions of $r$, we must place ourselves in a repository placed if possible at the center of the main body (the Sun typically) since the Schwarzschild metric is based on this hypothesis for recall. Thus, to know the delay of a luminous ray starting from the Sun and travelling to the Earth, we logically choose as the radius of departure that of the Sun itself and as the radius of arrival, the distance Sun-Earth (this will correspond once the primitives computed at the integration terminals).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/shapiro_effect.jpg}\t\n\t\t\\caption{Round-trip time of a signal as a function of the position of Mars}\n\t\\end{figure}\n\tWell that says it's nice to know the notations of use, but it's even better to do a numerical application! We will therefore first determine the primitive of each of the terms below:\n\t\n\tThe first two primitives are simple because they are usual primitives proved in detail in the section of Differential and Integral Calculus (see page \\pageref{usual primitives}):\n\t\n\twhere for the last primitive we have preserved the constant of integration (contrary to what was done in the section of Differential and Integral Calculus because $r_\\odot\\neq 1$).\n\n\tNow it remains to us the last two integrals. Let's start in the order by:\n\t\n\tBy putting:\n\t\n\tand using the results proved in the section of Differential and Integral Calculus, we then have:\n\t\n\tSince we have (\\SeeChapter{see section Trigonometry page \\pageref{remarkable trigonometric identities}}):\n\t\n\tThen:\n\t\n\tFinally, it remains the last primitive:\n\t\n\tWe put for what will follow:\n\t\n\tTherefore it comes:\n\t\n\tIn the section of Differential and Integral Calculus we have proved that:\n\t\n\tand that:\n\t\n\tTherefore:\n\t\n\tTo return to the integral of the beginning we remember that $r=\\dfrac{r_\\odot}{x}$. Therefore:\n\t\n\tWe thus finally have by taking all the primitives calculated above and by choosing a starting and finishing terminal for the calculation:\n\t\n\tWe see in the Newtonian limit case where $r_g=0$ that this relation is reduced to:\n\t\n\tSo for a round trip (between planet and satellite for example), then it comes in this simplified case:\n\t\n\tIn November 1976, when the two Viking spacecraft were operating on the surface of Mars, the planet went\nbehind the Sun as seen from Earth (see figure below). Scientists had preprogrammed Viking to send a radio wave toward Earth that would go extremely close to the outer regions of the Sun. According to General Relativity there would be a delay because the radio wave would be passing through a region where time ran more slowly. The experiment was able to confirm Einstein’s theory to within $0.1\\%$.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/shapiro_effect_viking.jpg}\t\n\t\t\\caption[Delayed Radio signals from the Viking lander on Mars]{Radio signals from the Viking lander on Mars were delayed when they passed near the Sun (source: OpenStax)}\n\t\\end{figure}\n\tIn 2003, with the space probe Cassini an accuracy of $0.0012\\%$ was achieved!\n\t\n\t\\subsubsection{Hafele–Keating experiment (general relativity version)}\n\tThe Hafele–Keating experiment was a test of the theory of relativity as we already know (\\SeeChapter{see section Special Relativity page \\pageref{hafele keating experiment special relativity}}). In October 1971, Joseph C. Hafele, a physicist, and Richard E. Keating, an astronomer, took four cesium-beam atomic clocks aboard commercial airliners. They flew twice around the world, first eastward, then westward, and compared the clocks against others that remained at the United States Naval Observatory. When reunited, the three sets of clocks were found to disagree with one another, and their differences were consistent with the predictions of special and General Relativity (GR).\n\t\n\tIt is therefore a macroscopic realization of the famous \"twins paradox\". We propose in the following to establish the predictions of General Relativity with respect to the relative aging of clocks, based on A simplified aircraft trajectory.\n\n\tGeneral Relativity predicts an additional effect, in which an increase in gravitational potential due to altitude speeds the clocks up. That is, clocks at higher altitude tick faster than clocks on Earth's surface. This effect has been confirmed in many tests of general relativity, such as the Pound–Rebka experiment and Gravity Probe A. In the Hafele–Keating experiment, there was a slight increase in gravitational potential due to altitude that tended to speed the clocks back up. Since the aircraft flew at roughly the same altitude in both directions, this effect was approximately the same for the two planes, but nevertheless it caused a difference in comparison to the clocks on the ground.\n\t\n\tThe results were published in Science in 1972:\n\t\\begin{table}[H]\n\t\t\\centering\n\t\t\\begin{tabular}{|l|c|c|c|l|l|}\n\t\t\\hline\n\t\t\\rowcolor[HTML]{9B9B9B} \n\t\t & \\multicolumn{3}{c|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Nanoseconds ([ns]) gained, predicted}} &  &  \\\\ \\hline\n\t\t\\rowcolor[HTML]{9B9B9B} \n\t\t & \\textbf{Gravitational (GR)} & \\multicolumn{1}{l|}{\\cellcolor[HTML]{9B9B9B}\\textbf{Kinematic (SR)}} & \\textbf{Total} & \\parbox{2cm}{\\textbf{[ns] gained measured}} & \\multicolumn{1}{c|}{\\cellcolor[HTML]{9B9B9B}$\\pmb{\\Delta}$} \\\\ \\hline\n\t\t\\cellcolor[HTML]{9B9B9B}\\textbf{Eastward} & $+144 \\pm 14$ & $-184 \\pm 18$ & $-40 \\pm 23$ & \\multicolumn{1}{c|}{$-59 \\pm10$} & $0.76 \\sigma$ \\\\ \\hline\n\t\t\\cellcolor[HTML]{9B9B9B}\\textbf{Westward} & $+179\\pm 18$ & $+96 \\pm 10$ & $+275 \\pm 7$ & \\multicolumn{1}{c|}{$+273 \\pm 7$} & $0.09 \\sigma$ \\\\ \\hline\n\t\t\\end{tabular}\n\t\\end{table}\n\tThe published outcome of the experiment was consistent with special and general relativity. The observed time gains and losses were different from zero to a high degree of confidence, and were in agreement with relativistic predictions to within the $\\sim 10\\%$ precision of the experiment.\t\n\t\n\tIt is assumed that in the vicinity of the Earth, the metric tensor is given the Schwarzschild metric is to say that there exists a system of coordinates $(x^\\mu)=(ct,r,\\theta,\\phi)$, named Schwarzschild coordinates, such that:\n\t\n\tFor what will follow, by tradition, we will take the $(- + + +)$ metric:\n\t\n\twhere we will take $G \\cong 6.67\\cdot 10^{-11}\\;[\\text{m}^3\\cdot \\text{kg}^{-1}\\cdot \\text{s}^{-2}]$ and $c \\cong 3 \\cdot 10^8\\;[\\text{m}\\cdot \\text{s}^{-1}]$ and $M = 5.972\\cdot 10^{24}\\; [\\text{kg}]$.\n\t\n\tOk now we need two results, first the $4$-vector speed:\n\t\n\tsince $u^0=c$.\n\t\n\tNow before we continue, consider the following result (with the $(-, +, +, +)$ metric):\n\t\n\tBut:\n\t\n\tEquating we get obviously:\n\t\n\tExplicitly:\n\t\n\tBut as:\n\t\n\tThus:\n\t\n\tAfter a first simplification:\n\t\n\tAfter another simplification and little notation simplification:\n\t\n\tThat is:\n\t\n\tThat is:\n\t\n\tThat we will write as:\n\t\n\tNow as $r>R_{\\oplus}$ (we take $R=6.4\\cdot 10^6$ [m]), we have $GM/c^2r\\cong 7\\cdot 10^{-10}$. That means globally, we have also if the planes are not at a relativistic speed:\n\t\n\tThen as all the terms in the square brackets are much more small than $1$ we will use the Maclaurin development (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tThen:\n\t\n\tWe will also put $\\left(1-\\dfrac{GM}{2c^2r}\\right)^{-1}\\cong 1$. Therefore:\n\t\n\tThat is more convenient to write as:\n\t\n\tTherefore:\n\t\n\tThen using the Maclaurin development (\\SeeChapter{see section Sequences and Series page \\pageref{usual maclaurin developments}}):\n\t\n\tWe have:\n\t\n\tFor the observer who remains on the ground, we have:\n\t\n\tTherefore:\n\t\n\tNow for the airplane we have:\n\t\n\tand we assume non-relativistic speed of the airplane and the Newtonian addition of speed such that:\n\t\n\tTherefore:\n\t\n\tNow let us calculate the ratio:\n\t\n\tObviously, we see that the $\\Delta t$ will vanish! We us also again (...):\n\t\n\tThen:\n\t\n\tIf we neglect all terms in $1/c^4$ it will remain:\n\t\n\tNeglecting the terms involving $\\Omega^2$ that are very small, it remains:\n\t\n\tNow if $R\\gg h$ we can write:\n\t \n\tLet us subtract $-1$ on both side of equality:\n\t \n\tThat is:\n\t \n\tThat is more often written:\n\t \n\tThe first term (with $h=10,000$ [m] and $R=6,371$ [km] and $c=299,792,458\\;[\\text{m}\\cdot\\text{s}^{-1}]$):\n\t\n\tis a pure gravitational effect, always positive, that we already know under the name \"gravitational time dilatation\", implies that the observer in the aircraft ages faster than the observer on the ground, the latter being deeper in the gravitational field of the Earth. This term is here because of our General Relativity approach! \n\t\n\tThe second term:\n\t\n\tCorresponds to the dilatation of the times of the moving bodies in Special Relativity.\n\t\n\tFor a practical numerical application we will take again (\\SeeChapter{see section Special Relativity page \\pageref{hafele keating experiment special relativity}}):\n\t\n\tand the total flight also of $41$ hour according to measurement on the ground:\n\t\n\tand latitude of $38^\\circ$ (Washington airport) corresponding to a colatitude $\\theta=52^\\circ$. Then we have for the flight to the East ($v_\\text{airplane}\\cong +220\\;[\\text{m}\\cdot\\text{s}^{-1}]$):\n\t\n\tand for the flight to the West ($v_\\text{airplane}\\cong -220\\;[\\text{m}\\cdot\\text{s}^{-1}]$):\n\t\n\tThus we have:\n\t\n\tTo estimate $\\Delta \\tau_\\text{East}$ and $\\Delta\\tau_\\text{West}$ we just have to multiply the relative values above by the total duration of the flight:\n\t\n\tComparing with the data in the statement, and the result we get with this experiment treatment in the Special Relativity section we draw two conclusions:\n\t\\begin{enumerate}\n\t\t\\item The above results, based on the very simplified trajectories of the airplanes (their altitude not being constant and their speed either) are in relatively good agreement with the theoretical predictions based on the real trajectories, that is to say using:\n\t\t\n\t\trather than the very very very (...) approximate relation:\n\t\t\n\t\t\n\t\t\\item The results we get just here are less accurate relatively to measurement than the results we get using Special Relativity. Indeed, measurement give $\\Delta \\tau_\\text{West}=+273 \\pm 7$ [ns], our Special Relativity treatment $\\Delta \\tau_\\text{West}=+265$ [ns] and we get here $\\Delta \\tau_\\text{West}=+253$ [ns], so we lost accuracy with the above approximation for the West. The measurement give $\\Delta \\tau_\\text{East}=-59 \\pm10$ [ns], our Special Relativity treatment $\\Delta \\tau_\\text{West}=+156$ [ns] and we get here $\\Delta \\tau_\\text{West}=+10.48$ [ns], so we gain accuracy with the above approximation for the East. \n\t\t\n\t\\end{enumerate}\n\t\n\t\\pagebreak\n\t\\subsubsection{Black Holes}\\label{black hole}\n\tAlways staying focused on our Schwarzschild metric ...., a radial trajectory of light-type implies:\n\t\n\ttherefore:\n\t\n\tand in a direct radial trajectory (by definition!) we also have:\n\t\n\ttherefore:\n\t\n\tTherefore:\n\t\n\thence:\n\t\n\tso that:\n\t\n\tLet us change to natural units $c=1$. It then comes:\n\t\n\tWhen $r\\rightarrow 2GM$ the right-hand side of this equality tends to $\\pm \\infty$, then the evolution of time $t$ (external observer) as a function of $r$ tends to infinity with respect to the proper time of light.\n\n\tThe sphere given by the radius:\n\t\n\tdefines the \"\\NewTerm{horizon}\\index{horizon}\" of a \"\\NewTerm{Schwarzschild Black Hole}\\index{black hole}\".\n\t\n\tTowards this limit boundary, the light seems to put an infinite time compared to an external observer to move when approaching a Black Hole. It therefore never really reaches it in relation to the observer, hence the fact that the Black Holes can be surrounded according to their environment by a luminous halo near the Schwarzschild radius. Moreover, since time seems to be stopped, the frequency of the light surrounding the Black Hole tends towards zero and therefore towards the infra-red.\n\n\tA Black Hole is therefore a region of space-time exhibiting such strong gravitational effects that nothing—not even particles and electromagnetic radiation such as light—can escape from inside it. The theory of general relativity predicts that a sufficiently compact mass can deform space-time to form a Black Hole. The boundary of the region from which no escape is possible is named the \"event horizon\". \n\n\tObjects whose gravitational fields are too strong for light to escape were first considered in the 18th century by John Michell and Pierre-Simon Laplace. The first modern solution of general relativity that would characterize a Black Hole was found by Karl Schwarzschild in 1916, although its interpretation as a region of space from which nothing can escape was first published by David Finkelstein in 1958. Black Holes were long considered a mathematical curiosity; it was during the 1960s that theoretical work showed they were a generic prediction of general relativity. The discovery of neutron stars sparked interest in gravitationally collapsed compact objects as a possible astrophysical reality.\n\n\tBlack Holes of stellar mass are expected to form when very massive stars collapse at the end of their life cycle. After a Black Hole has formed, it can continue to grow by absorbing mass from its surroundings. By absorbing other stars and merging with other Black Holes, supermassive Black Holes of millions of solar masses may form. There is general consensus that supermassive Black Holes exist in the centers of most galaxies.\n\n\tDespite its invisible interior, the presence of a Black Hole can be inferred through its interaction with other matter and with electromagnetic radiation such as visible light. Matter that falls onto a Black Hole can form an external accretion disk heated by friction, forming some of the brightest objects in the universe. If there are other stars orbiting a Black Hole, their orbits can be used to determine the Black Hole's mass and location. Such observations can be used to exclude possible alternatives such as neutron stars. In this way, astronomers have identified numerous stellar Black Hole candidates in binary systems, and established that the radio source known as Sagittarius A*, at the core of our own Milky Way galaxy, contains a supermassive Black Hole of about $4.3$ million solar masses. \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf the Sun or any other celestial object collapse into a Black Hole, this doesn't affect its orbiting element as the Black Holes still have the same mass (only the density change) and Newton's law still remains valid at a quite significant distant of it. So it is wrong to imagine that if the Sun collapse into a Black Hole of $6$ [km] diameter it would exert a more big gravitational force and that all planets turning around it will be sucked in.\n\t\\end{tcolorbox}\n\tA common question that should perhaps arise to some readers now is... : how does gravity escape a Black Hole? The answer to this questions should first make a distinction between gravitational field and gravitational waves that are perturbations of space-time and that can't indeed escape from the inside of the Black Hole but that are mathematically also generated outside of the latter. For the gravitational field... it must be understood that gravity does not \"travel\". In fact, gravity is the result of space-time distortion, it is space itself and isn't a thing that travels through space, and Black Holes distort space-time not only inside but outside their event horizon. Gravitational waves (see further below) by cons, travel a the speed of light and emerge when the distortion changes over time.\n\t\n\tOn 11 February 2016, the LIGO collaboration announced the first observation of gravitational waves; because these waves were generated from a Black Hole merger it was the first ever direct detection of a binary Black Hole merger. On 15 June 2016, a second detection of a gravitational wave event from colliding Black Holes was announced.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/black_hole.jpg}\t\n\t\t\\caption[2D naive representation of space curve near some celestial objects]{2D naive representation of space curve near some celestial objects (source: OpenStax)}\n\t\\end{figure}\n\tThe Galactic Center Group members have been measuring the positions of thousands of stars in the vicinity of the Galactic Center for more than $20$ years. This unique data set allowed us to measure directly short-period orbits of stars. In particular, a full phase coverage has been measured for two stars: S0-2 with an orbital period of $15.56$ years, and S0-102 with $11.5$ years. At the closest approach, S0-2 is only $17$ light hours away from the center of the Galaxy, about four times the distance of Neptune from the Sun. From these orbital data, we can determine the mass of the central Black Hole in our own Galaxy.\n\n\tThe Milky Way Galaxy center is the best candidate to what seems to a Black Hole, and especially and example of the closest supermassive Black Holes (SMBH), located at $\\sim 25,000$ light years away from us and corresponds with the location of Sagittarius A* a bright and very compact astronomical radio source at the center of the Milky Way. Its mass is estimated to be $4$ million times the mass of the Sun, which implies that the Schwarzschild radius is about $17$ times that of Sun's radius. As a comparison, Mercury's orbit is located at a distance of $\\sim 83$ solar radii. Because the Galactic Center is the site of the closest supermassive Black Hole by a factor of $100$, it is a unique laboratory for solving some of the greatest mysteries associated with the fundamental physics of supermassive Black Holes and the role that they play in the formation and evolution of galaxies. Furthermore, it is the only galactic nucleus in which direct measurements of stellar orbits is possible, with either the current or the next-generation instruments.\n\t\n\tObservations of stellar orbits around the Galactic Black Hole also yields precision measurement of the distance to the Galactic Center, which is important as it affects almost all questions not only of Galactic structure, dynamics and mass, but those of extragalactic distance scales and the value of Hubble's constant as well.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/galactic_black_hole_center.jpg}\t\n\t\t\\caption[Orbits of stars within the central 1.0 X 1.0 arcseconds of our Galaxy]{Orbits of stars within the central 1.0 X 1.0 arcseconds of our Galaxy (source: Galactic Group Center)}\n\t\\end{figure}\n\tThe origin of supermassive Black Holes and also the assumption that each galaxy center is a Black Hole remains an open field of research. Astrophysicists agree that once a Black Hole is in place in the center of a galaxy, it can grow by accretion of matter and by merging with other Black Holes this is why some observations gives for example for the hyperluminous quasar S5 0014+81 a weight of approximately $40\\cdot 10^10$ times the mass of the Sun.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe Schwarzschild radius scales with mass as $R_S = 2GM/c^2$. What might be defined as a \"Schwarzschild volume\" would then be $V_S = 4\\pi R_S^3/3 = (32/3)\\pi(GM/c^2)^3$. So the density of matter defined by the horizon is $\\rho_S = (3/32)(c^2/G)^3M^{-2}$. So the Schwarzschild density scales as the inverse square of the mass. A 10 billion solar mass Black Hole (like the estimation of the one at the center of our Galaxy) has a radius estimated about $1,010$ [km], or a Schwarzschild volume of $V_S \\cong 10^{39}\\;[\\text{m}^3]$. A solar mass is $10^{30}$ [kg] and the Schwarzschild  density defined by the horizon is then $\\rho_S = 10^{-9}\\;[\\text{kg}\\cdot\\text{m}^{-3}]$. That is actually quite small. However this may be misleading. \"Density\" suggests that the mass is distributed more or less uniformly within the Black Hole, and this is non-sense. The Black Hole is mostly empty, and all the mass is concentrated within a tiny region (classically a point) in the center of the Black Hole.\n\t\\end{tcolorbox}\n\t\n\tAre there any other magnitudes we should note or calculate in Black Hole physics and thermodynamics! Yes, there are Assuming spherical symmetry, we can calculate the Schwarzschild area or event horizon/surface area of the Schwarzschild's Black Hole simple by:\n   \n\tWe can also calculate the surface gravity $\\kappa$, if the gravitational field of the Black Hole reads:\n\t\n\tthen, at the Schwarzschild radius it becomes the mentioned surface gravity $\\kappa=g(R=R_S)$:\n\t\n\tInterestingly, this surface gravity is $1/M$ the maximal force $c^4/4G$ allowed by natural units... What else? Surface tides, or more precisely, the tidal acceleration at the Black Hole surface. The tidal acceleration is calculated with (the reader notice that we take the version of the tidal force with the factor $2$ instead of factor $4$ as discusses during the proof of this relation in the section of Astronomy):\n\t\n\tIf it is evaluated at $R_S$ we get:\n\t\n\t\n\t\\paragraph{Black Hole innermost stable orbit}\\mbox{}\\\\\\\\\\\n\tThe title of this subsection a bit a misnomer. Indeed, the results that we will see also applies to any other object that Black Holes!\n\t\n\tMuch of the modern folklore about Black Holes is misleading. One idea you may have heard is that Black Holes go about sucking things up with their gravity. Actually, it is only very close to a Black Hole that the strange effects we have been discussing come into play. The gravitational attraction far away from a Black Hole is the same as that of the star that collapsed to form it.\n\n\tRemember that the gravity of any star some distance away acts as if all its mass were concentrated at a point in the center, which we call the center of gravity. For real stars, we merely imagine that all mass is concentrated there; for Black Holes, all the mass really is concentrated at a point in the center.\n\n\tSo, if you are a star or distant planet orbiting around a star that becomes a Black Hole, your orbit may not be significantly affected by the collapse of the star (although it may be affected by any mass loss that precedes the collapse). If, on the other hand, you venture close to the event horizon, it would be very hard for you to resist the \"pull\" of the warped space-time near the Black Hole. You have to get really close to the Black Hole to experience any significant effect.\n\n\tIf another star or a spaceship were to pass one or two solar radii from a Black Hole, Newton's laws would be adequate to describe what would happen to it. Only very near the event horizon of a Black Hole is the gravitation so strong that Newton's laws break down. The Black Hole remnant of a massive star coming into our neighbourhood would be far, far safer to us than its earlier incarnation as a brilliant, hot star.\n\n\tA Black Hole with it's accretion disk ray-traced with Python\\footnote{Source code available on  \\url{http://rantonels.github.io/starless}} by  Riccardo Antonelli:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.25]{img/cosmology/black_hole_python_raytrace.jpg}\n\t\t\\caption{Black Hole ray-traced }\n\t\\end{figure}\n\t\n\tTo begin, let us recall first that we have just seen that Schwarzschild metric is an exact solution to the Einstein vacuum equation given by the line element:\n\t\n\twhich written as a matrix consequently becomes:\n\t\n\tNow let us introduce a special mathematical vector in General Relativity. \n\t\n\t\\textbf{Definition (\\#\\mydef):} If all components of a metric are independent of some particular $x^\\nu$, then we have the \"\\NewTerm{Killing vector}\\index{Killing vector}\" $\\vec{K}$, named after Wilhelm Killing, with components $K^\\mu=\\delta_\\nu^\\mu$. That is, the contravariant form just has a constant in the appropriate slot and zeros elsewhere. As we will see, as Noether's theorem tells us (\\SeeChapter{see section Analytical Mechanics page \\pageref{noether theorem}}) that for every symmetry there is a conserved quantity, Killing vectors are a powerful way to find those conserved quantities.\n\t\n\tThe Schwarzschild metric has a few interesting properties, it is clear that it is independent explicitly of $t$ and $\\phi$ and hence there exist Killing vectors that we will denote $K_1^\\mu=(1,0,0,0)$ (often denoted $\\xi^\\mu$) and $K_2^\\mu=(0,0,0,1)$ (often denote $\\eta^\\mu$) which both lie along directions in which the metric doesn't change\\footnote{There are actually four Killing vectors for the Schwarzschild metric since it is invariant under time translations and rotations. But we will only need two of them for our purpose.}.\n\t\n\tWe define the velocity four-vector $v^\\mu$ as:\n\t\n\twhere we let indices run over the coordinates $(t,r,\\theta,\\phi)$ and $\\tau$ is the proper time. Now, since the metric is independent of $t$, forming the scalar product between $K_1^\\mu$ and $u_\\mu=g_{\\mu\\nu}u^\\nu$ gives the quantity:\n\t\n\tBut we know from our study of Special Relativity that:\n\t\n\tTherefore:\n\t\n\tNow let us recall that we have proved earlier that the geodesic lagrangian was given by:\n\t\n\tTherefore:\n\t\n\tWe see that the Lagrangian doesn't depend explicitly on $t$ and $\\phi$ so these two parameters implies conservation of energy.\n\t\n\tBut now we know from our study of Analytical Mechanics that:\n\t \n\tThat in our case will be written (as there is conservation according to component $t$):\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tThat we will denote with the lowercase letter $e$:\n\t\n\tand is an energy per unit rest mass.\n\t\n\tSimilarly since the metric is independent of $\\phi$ we form:\n\t\n\tBut we also know from our study of Analytical Mechanics that:\n\t\n\tAnd as our Lagrangian above is explicitly independent of $\\phi$, we have:\n\t\n\tTherefore we denote with the lowercase letter $l$:\n\t\n\tthe angular momentum per unit rest mass that.\n\t\n\tThis is exactly the kind of useful thing we need to consider particle orbits! The conserved energy and angular momentum are one of the fundamental descriptors for orbits from Classical Mechanics as we know!\n\t\n\tNow before we continue, consider the following result (with the $(+, -, -, -)$ metric):\n\t\n\tthat is for our geodesic observer a normalization constraint.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn textbooks this relation is often given with the $(-, +, +, +)$ signature and in natural units, thus:\n\t\n\t\\end{tcolorbox}\n\t\n\tHence:\n\t\n\tWe are free to choose $\\theta=\\pi/2$, exploiting the spherical symmetry of Schwarzschild metric, to simplify the calculations (as $\\sin(\\pi/2)=1$) and since we fix that value, we also have $u^\\theta=0$. Therefore the previous relation reduce to:\n\t\n\tNow we exploit the relations:\n\t\n\tThat we inject in the previous one and we get:\n\t\n\tOr (this is the form as we found it the most often in textbooks):\n\t\n\tMultiplying both side by $-\\left(1-\\frac{2GM}{rc^2}\\right)^{-1}$ we get first:\n\t\n\tRearranging:\n\t\n\tDividing by $2$ and developing:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tSometimes we have the notation:\n\t\n\t\\end{tcolorbox}\n\tThat is more often written:\n\t\n\twhich is the radial equation in the Schwarzschild geometry with the corresponding effective potential\\index{effective potential}:\n\t\n\tThus, a system of four coupled differential equations in four variables has, with the help of three constants of the motion, been reduced to a single differential equation in one variable.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe prior-previous relation should be written more explicitly:\n\t\n\t\\end{tcolorbox}\n\tIt also a very useful quantity to consider here because it is completely analogous to the effective potential from orbital theory in\nclassical mechanics.\n\n\tIndeed, consider a particle of mass m orbiting a much heavier object of mass M. Assuming Newtonian mechanics can be used, and the motion of the larger mass is negligible, then the conservation of energy and angular momentum give two constants $E$ and $L$, with values in polar coordinates:\n\t\n\tAs the angular momentum is given by:\n\t\n\tOnly two variables are needed, since the motion occurs in a plane. Substituting the second expression into the first and rearranging gives:\n\t\n\tHence\\index{effective potential}\n\t\n\tThat is:\n\t\n\tTherefore we see the analogy now! We have therefore indeed:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\twe therefore understand why in General Relativity the difference $\\mathcal{E}-U_\\text{eff}(r)$ is therefore interpreted as the kinetic energy.\n\t\\end{tcolorbox}\n\tSo what do the extra correction from general relativity? Look at a graph for $l/M = 4.5$, below:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/effective_potential_general_relativity.jpg}\n\t\t\\caption{Effective potential profile accord to Newtonian and General Relativity mechanics}\n\t\\end{figure}\n\tSo what do we notice right away?\n\t\n\tThere is a minimum in the effective potential, just as in the Newtonian case. For a particle bound in this potential, there is a \"\\NewTerm{stable circular orbit}\\index{stable circular orbit}\" at the minimum of the potential (it can be shown that this orbit is perfectly circular). At large distances we see that our effective potential tends to the Newtonian one!\n\t\n\tHowever, when $r\\rightarrow 0$ our effective potential is dominated by the $r^{-3}$ term, which diverges temporarily. Then, there is a maximum in the effective potential, unlike in the Newtonian case (we then say that the \"centrifugal barrier is not impenetrable\"). There is an \"\\NewTerm{unstable circular orbit}\\index{unstable circular orbit}\" at the maximum in the potential and it can be show that then the orbit is elliptical and precess like Mercury do (the orbit is not closed).\n\t\n\tThe shape of this potential is controlled by the magnitude of the angular momentum $l$.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/newtonian_effective_potential.jpg}\n\t\t\\captionsetup{width=0.7\\linewidth}\n\t\t\\caption[]{Newtonian effective potential for a test particle moving in the gravitational field of a central body with mass, for different values of angular momentum. Solid circles show position of minima corresponding to stable circular orbits.}\n\t\\end{figure}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/schwarzschild_effective_potential.jpg}\n\t\t\\captionsetup{width=0.7\\linewidth}\n\t\t\\caption[]{Effective potential (per unit particle rest mass) for motion in Schwarzschild metric. Maxima of potential are shown by circles, and minima are shown by solid circles.}\n\t\\end{figure}\n\t\n\tWe can find the min/max of the potential by constructing a radial derivative:\n\t\n\tHence:\n\t\n\tWe multiply both sides by $r^4$:\n\t\n\tThis is a simple second degree polynomial, the solution is obviously (\\SeeChapter{see section Calculus page \\pageref{double root}}):\n\t\n\tThe absolute minimum value for this occurs when\\footnote{Notice that if we put $G=c=1$ we then have $l/M=\\sqrt{12}=2\\sqrt{3}$}:\n\t\n\tthen:\n\t\n\twhere for recall $R_S$ is the Schwarzschild radius.\tThat latter relation is known as the ISCO, the \"\\NewTerm{innermost stable circular orbit}\\index{innermost stable circular orbit}\" or \"\\NewTerm{marginally stable circular orbit}\\index{marginally stable circular orbit}\" for the Schwarzschild geometry. We can see that it is equal to three times the Schwarzschild radius (hence, three times the even horizon radius of a Black Hole)!\n\t\n\tThe effective potential in this case looks like:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/innermost_stable_circular_orbit.jpg}\n\t\t\\caption{Relativistic effective potentials for various values of $l/M$ with $M=1$}\n\t\\end{figure}\n\tThere are no stable circular orbits at radii smaller than $r_\\text{ISCO}$. This has important astrophysical consequences when considering phenomena such as accretion — material slowly works its way down the gravitational potential, giving up energy and angular momentum until it accretes onto the central, compact object. If there is a minimum radius at which material (gas, in the accretion case) can stably orbit for example a Black Hole, it will plunge at all smaller radii for a given angular momentum. This bounds the amount of gravitational binding energy that can be extracted by a particle.\n\t\n\tSo wee see this is a huge difference with Newtonian gravity where stable circular orbits are available at all $R$!\n\t\n\tThis artist's conception below shows the region hypothesised immediate surrounding a supermassive Black Hole (the black spot near the center). The Black Hole is orbited by a thick disk of hot gas. The center of the disk glows white-hot, while the edge of the disk is shown in dark silhouette. Magnetic fields channel some material into a jet-like outflow - the greenish wisps that extend to upper right and lower left. A dotted line marks the innermost stable circular orbit, which is the closest distance that material can orbit before becoming unstable and plunging into the Black Hole:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.7]{img/cosmology/black_hole_innermost_stable_orbit.jpg}\n\t\t\\captionsetup{width=0.6\\linewidth}\n\t\t\\caption[Black Hole innermost circular stable orbit illustration]{Black Hole innermost circular stable orbit illustration (source: Chris Fach, Perimeter Institute \\& University of Waterloo)}\n\t\\end{figure}\n\tBelow the first direct photo of a Black Hole (in fact... of its surrounding), at the center of M87 the 2019-04-10 (National Science Foundation) using a planet-scale array of eight ground-based radio telescopes forged through international collaboration named the Event Horizon Telescope (EHT):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/m87_blackhole.jpg}\n\t\t\\caption[First direct photo of a Black Hole]{First direct photo of a Black Hole, M87 the 2019-04-10 (source: National Science Foundation)}\n\t\\end{figure}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tA quite legitimate question would be at this state: If photons can't escape a black hole, how come gravitons can? The answer is that as a force mediating particle, gravitons would come as virtual gravitons, just like virtual photons are the force exchange particles of the electromagnetic force. Virtual particles cannot be said to \"travel\" anywhere (no virtual photons move in between two interacting charged particles either). That is, they aren't created at one particle just to travel to another and 'exchange' forces between them. So one answer to your question is that nothing comes out of the black hole at all. No gravitons move from the black hole to the outside world. Unfortunately it's difficult to explain how virtual particles work, as they don't act like normal particles at all. They are better described as transient fluctuations of an underlying field that happen to be described by the same math that describes real particles. Furthermore the graviton is a hypothetical particle in theory of quantum gravity. General Relativity says nothing about gravitons, it just rather describes space-time as continuum.\n\t\\end{tcolorbox}\n\t\n\t\\paragraph{Black Hole photon sphere}\\mbox{}\\\\\\\\\\\n \tAs photons approach the event horizon of a Black Hole, those with the appropriate energy avoid being pulled into the Black Hole (or possibly an \"ultra-compact\" neutron star) by travelling in a nearly tangential direction known as an \"\\NewTerm{exit cone}\". A photon on the boundary of this cone does not possess the energy to escape the gravity well of the Black Hole. Instead, it orbits the Black Hole! These orbits are rarely stable in the long term.\n\n\tThe \"\\NewTerm{photon sphere}\\index{photon sphere}\\label{photon sphere}\" is as we will see located farther from the center of a Black Hole than the event horizon, but however nearest that the innermost stable orbit. Within a photon sphere, it is possible to imagine a photon that begins at the back of your head, orbiting the black hole, only then to be intercepted by your eyes, allowing you to see the back of your head.\n\n \tIn the previous development, if we focus of the innermost stable orbit, if we focus on a photon (denoted $\\gamma$) universe line, we have $\\mathrm{d}s^2=0$, and then the result simplifies to:\n \t\n \tThen following the same reasoning we get to find the min/max of the potential by constructing a radial derivative:\n\t\n\tHence:\n\t\n\tAnd rearranging gives:\n\t\n\tTherefore, for non-rotating Black Holes, the photon sphere is a sphere of radius $3/2 R_S$, outside the event horizon but inside the innermost circular stable orbit.\n\t\n\tAnd here is a summary of what we have seen so far (the summary is not perfect but it the best we have found so far):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/black_holes_infographic.jpg}\n\t\t\\caption[Black Hole summary ]{Black Hole summary (source: Event Horizon Telescope)}\n\t\\end{figure}\n\t\n\t\\pagebreak\n\t\\paragraph{Black Hole free fall proper time to singularity}\\mbox{}\\\\\\\\\\\n\tSuppose we fall into a Schwarzschild black hole. According to general relativity, we can compute the (finite) free fall time in which we travel from the Schwarzschild radius to the singularity (we assume by the moment General Relativity holds, the point is to what extend is this valid both in General Relativity and the real world, but we can do it as an exercise):\n\t\n\tThat latter relation is the is the free fall radial path time to singularity for a non-rotating Black Hole!\n\t\n\tLet us prove that:\n\t\n\t\n\tFor this let us substitute:\n\t\n\tThen:\n\t\n\tTherefore:\n\t\n\tSo now we have to solve:\n\t\n\tBut we recognize here the primitive of:\n\t\n\tThat we have already proved in the section of Differential and Integral Calculus (see page \\pageref{black hole primitive}) and that lead us to:\n\t\n\tTherefore:\n\t\n\tUndo substitution:\n\t\n\tWe get:\n\t\n\tThe problem is then solved:\n\t\n\tTherefore (ignoring the constant):\n\t\n\tBut for the second parentheses we see we should better take the limit. Then we have:\n\t\n\tTherefore:\n\t\n\t\t\n\t\\pagebreak\n\t\\subsubsection{Gravitational waves}\n\tBefore we focus on the maths, let us do a simple introduction.\n\t\n\t\"\\NewTerm{Gravitational waves}\\index{gravitational waves}\" are ripples in the curvature of space-time that propagate as waves at the speed of light, generated in certain gravitational interactions that propagate outward from their source. The possibility of gravitational waves was discussed in 1893 by Oliver Heaviside using the analogy between the inverse-square law in gravitation and electricity. In 1905 Henri Poincaré first proposed gravitational waves emanating from a body and propagating at the speed of light as being required by the Lorentz transformations. Predicted in 1916 by Albert Einstein on the basis of his theory of General Relativity, gravitational waves transport energy as gravitational radiation, a form of radiant energy similar to electromagnetic radiation. Gravitational waves cannot exist in the Newton's law of universal gravitation, since that law is predicated on the assumption that physical interactions propagate at infinite speed.\n\t\n\tGravitational-wave astronomy is an emerging branch of observational astronomy which aims to use gravitational waves to collect observational data about sources of detectable gravitational waves such as binary star systems composed of white dwarfs, neutron stars, and Black Holes; and events such as supernovae, and the formation of the early universe shortly after the Big Bang.\n\t\n\tOn February 11, 2016, the LIGO Scientific Collaboration and Virgo Collaboration teams announced that they had made the first observation of gravitational waves, originating from a pair of merging Black Holes using the Advanced LIGO detectors. On June 15, 2016, a second detection of gravitational waves from coalescing Black Holes was announced. Besides LIGO, many other gravitational-wave observatories (detectors) are under construction.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{img/cosmology/ligo_measurements.jpg}\t\n\t\t\\caption[LIGO measurement of the gravitational waves at the Hanford and Livingston detectors]{LIGO measurement of the gravitational waves at the Hanford (left) and Livingston (right) detectors}\n\t\\end{figure}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{img/cosmology/ligo.jpg}\n\t\\end{figure}\n\tIn real life it looks like this:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.95]{img/cosmology/ligo_washington.jpg}\n\t\t\\caption[Hanford LIGO detector Washington state]{Hanford LIGO detector - October 30, 2000 - Washington state (source: LIGO)}\n\t\\end{figure}\n\tThe most typical illustration that we can see of gravitational wave of newspapers are that generated by the special case of a high speed dynamic gravitation field due to the rotation of two massive object around each other. Otherwise, and it is obvious, a collapsing Star at the end of its life also generated a variational gravitational field but that is quite difficult to detect with actual existing instruments as a star alone is not massive enough to generate detectable gravitation waves:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/gravitational_wave.jpg}\t\n\t\t\\caption{Pseudo-3D (wrong) common visualization of gravitational wave of a binary system}\n\t\\end{figure}\n\tBut obviously gravitational waves don't make things go up and down like ocean waves as illustrated above, and they're definitely not like that planet on a trampoline — after all, there's nothing \"below\" to pull things downward so there can't be a dent.  And gravitational waves don't do spirals, much...\n\t\n\tIn a gravitational wave, space itself is compressed and stretched.  A particle caught in a gravitational wave doesn't get pushed back and forth.  Instead, it shrinks and expands in place. If you encounter a gravitational wave, you and all your calibrated measurement gear (yardsticks, digital rangers, that slide rule you're so proud of) shrink and expand together.  You would only notice the experience if you happened to be comparing two extremely precise laser rangers set perpendicular to each other (LIGO!).  One would briefly register a slight change compared to the other one.\n\t\n\tNow let us deal with the maths. As almost always in science there are multiple ways to introduce a new tool. In this book, as most of times, we will use what we consider the most easy one and that is \"physicist\" or \"engineer\" oriented...\n\t\n\tSo first, remember that earlier we have proved under some assumptions that:\n\t\n\tThat what we have seen afterwards can be written more generally as:\n\t\n\tIf we explicit it by keeping in mind Classical Mechanics it would be written in 3D:\n\t\n\tor a bit better:\n\t\n\tBut... but...! We are in General Relativity and we have to introduce the 4-th dimensions:\n\t\n\tThis is better but now let us explicit this using in cartesian coordinates using the metric $(-, +, +, +)$. We then get:\n\t\n\tAssuming that we a observing a piece (volume) of space where there is no matter and no radiation in any form, then $T_{\\mu\\nu}=0$ and we get:\n\t\n\tUsing the d'Alembertian already introduced in the section of Electrodynamics but now in its General Relativity form named \"\\NewTerm{flat-space d'Alembertian}\\index{flat-space d'Alembertian}\":\n\t\n\tthat latter relation is commonly written in textbooks:\n\t\n\tTaking back and rearranging the explicit relation we get (we see that this equation also give us that space transmits gravitational waves at the speed of light!):\n\t\n\tand named the \"\\NewTerm{gravitational wave equation}\\index{gravitational wave equation}\", \"\\NewTerm{gravitational propagation equation}\\index{gravitational propagation equation}\" or \"\\NewTerm{gravitational d'Alembert's equation}\\index{gravitational d'Alembert's equation}\".\n\t\n\tWe know that a simple solution to:\n\t\n\tcan be typically be:\n\t\n\tThe amplitude $\\hat{A}_{\\mu\\nu}$ and the wave vector $k_\\rho$ must satisfy the differential equation, therefore:\n\t\n\t\n\tGravitational waves pass through boundaries that light cannot! They can transport information about what happens inside the event horizons of Black Holes, and they can pass through the cosmic background (CMB) radiation (\\SeeChapter{see section Cosmogony page \\pageref{cosmic microwave background}}), the barrier of light that prevent us from seeing our Universe before it turned $380,000$ years old!\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/gravitational_wave_cmb.jpg}\t\n\t\t\\caption{Gravitational cosmic background \"radiation\"}\n\t\\end{figure}\n\t\n\tSo for summary General Relativity has successfully with high accuracy pass the following experimental tests in order of verification (top oldest):\n\t\\begin{enumerate}\n\t\t\\item Mercury perihelion precession\n\t\t\\item Light deviation\n\t\t\\item Black Holes\n\t\t\\item Universe expansion\n\t\t\\item Time Dilatation\n\t\t\\item Gravitational waves\n\t\\end{enumerate}\t\n\n\tLet us point out once again a very important point. Before Albert Einstein, geometry was considered an integral part of the laws. Albert Einstein has shown that the geometry of space evolves in time according to other, even deeper, laws. It is important to understand this point. The geometry of space is not part of the laws of nature (this was criticized at his time by many French physicists). Therefore, nothing that we can find in these laws tells us what geometry of space we are working in. Thus, before we begin to solve the equations of Einstein's General Relativity, we have absolutely no idea what geometry we ear dealing with. We only discover it once the equations are solved!\n\t\n\tIn extenso, the choice of $4$ dimensions is part of the background. Could it be possible that another deeper theory does not require presupposing the number of dimensions? \n\n\tTo sum up, the idea of independence relatively to the background, in its most general formulation, is a wise way of making physics: made up of better theories, in which the things which before were postulated, will be explained in allowing such things to evolve over time according to new laws.\n\n\tThis is also a difficulty of Quantum Theory, that latter is essentially background dependent at the opposite of General Relativity that is \"\\NewTerm{background independent}\\index{background independent}\".\n\t\n\t\\subsection{Einstein-Hilbert action}\n\tThe \"\\NewTerm{Einstein-Hilbert action}\\index{Einstein-Hilbert action}\" (also referred to as \"\\NewTerm{Hilbert action}\") in General Relativity is the action that yields the Einstein field equations through the principle of least action (\\SeeChapter{see section Analytical Mechanics page \\pageref{variational principle}}). With the $(- + + +)$ metric signature, the gravitational part of the action is given as:\n\t\n\tThe derivation of equations from an action has several advantages. First of all, it allows for easy unification of general relativity with other classical field theories (such as Maxwell theory), which are also formulated in terms of an action (this is especially why we were obliged to introduced this action in this book!).\n\t\n\tThere are multiple ways to make to the proof of that action, but we will use the one that is the easiest in our point of view and that is more \"engineer way of life\" oriented rather than \"theoretical physicist way of life\"... So let's go!\n\t\\begin{dem}\n\tWe know that the classical action in mechanics is given for recall by:\n\t\n\tIn this expression, the Lagrangian $L$ is homogeneous to an energy. In gravitation as in electromagnetism, the energy-stress tensor $T$ is homogeneous to a density energy $\\mathcal{L}$, which oblige us to introduce this density in the action by integrating on the volume as following:\n\t\n\tThe search of an action invariant by change of reference frame impose us an element of volume $\\mathrm{d}\\Omega$ quadridimensional that is also invariant by change of reference frame. And we have proved in the section of Tensor Calculus that such an element was given by the Riemmanian volume (\\SeeChapter{see section Tensor Calculus page \\pageref{Riemannian volume}}):\n\t\n\tThen we deduce the new form of the action:\n\t\n\tBut as we look the units, as $x^0=ct$ the units are note homogeneous to an energy any more. Then we must divide by $c$:\n\t\n\tNow we need to find a scalar for $R$ that is invariant has for units a density of energy. For this, let us recall that during our proof of the Einstein's field equation earlier above (page \\pageref{einstein field equations}), we get the relation:\n\t\n\tThat obviously can be simplified as:\n\t\n\tand as $g^{\\rho\\sigma}T_{\\rho\\sigma}$ is often denoted simple $T$, we get:\n\t\n\tAnd as the left term is a well known scalar implicitly involving $g^{ij}$ (as for recall $R=g^{ij}R_{ij}$), what may be quite useful intuitively, it is a good candidate! But...\n\t\\begin{itemize}\n\t\t\\item it doesn't have the units of a density energy\n\t\t\\item it seems to be negative as $T$ is positive (at least as far as we know...)\n\t\\end{itemize}\n\tThen if we write:\n\t\n\tWe get a very good candidate four our Lagrangian density. Then we will try with:\n\t\n\t\\begin{flushright}\n\t\t$\\blacksquare$  Q.E.D.\n\t\\end{flushright}\n\t\\end{dem}\n\tOk the derivation is quite based on trial and errors reasoning. So it may be a good practice to check if this action lead us back to the Einstein Field questions (or something similar) by applying the variational principle!\n\t\n\tAssuming that all conditions are satisfied to the variation to pass through the integral, we have:\n\t\n\tAs the determinant $|g|$ of the $g_{ij}$ is negative, at least in the most common cases (Minkowski, Schwarzschild, Robertson-Walker, Kerr, etc.), we write:\n\t\n\tThis expression is differentiate as the product of three term:\n\t\n\tThat can be written:\n\t\n\tThe non-obvious idea is to make appear $\\delta g^{ij}$ as a factor in the integral of the variation $\\delta S$ and we will request a always that $\\delta S=0$ and conclude/check if the result we get is interesting or not!?\n\t\n\tIn the differential above the first term $\\delta(g^{ij})R_{ij}\\sqrt{-g}$ naturally makes appear $\\delta(g^{ij})$, and therefore doesn't need any treatment.\n\t\n\tFor the other two terms instead, we will have to express $\\delta(R_{ij})$ and $\\delta (\\sqrt{-g})$ in function of the $\\delta (g_{ij})$, or show that their contribution is equal to zero. It is not an easy work, it needed a great mathematician like David Hilbert to achieve this work. So here is the procedure that as you will see... is quit a pain in the a**...\n\t\n\t\\begin{itemize}\n\t\t\\item First we focus on the term $\\sqrt{-g}$. For this let us consider a matrix with the following form:\n\t\t\n\t\tThe trace of this matrix, as for any matrix, is the sum of the elements of the main diagonal, so:\n\t\t\n\t\tSo that:\n\t\t\n\t\tIf we consider the exponential matrix $e^A$ (\\SeeChapter{see section Linear Algebra page \\pageref{exponential of a matrix}}) as:\n\t\t\n\t\tThen the determinant of this diagonal matrix is (\\SeeChapter{see section Linear Algebra page \\pageref{determinant of two by two matrix}}):\n\t\t\n\t\tSo that finally we can write:\n\t\t\n\t\tIf we no put $B=e^A$ we have obviously:\n\t\t\n\t\tSo as $\\text{det}(e^A)=e^{\\text{tr}(A)}$, we have:\n\t\t\n\t\tTherefore:\n\t\t\n\t\tHence:\n\t\t\n\t\tTaking the differential of both side:\n\t\t\n\t\tOr written in a more condensed way:\n\t\t\n\t\tIf we now relate this last result to the metric $g_{ij}$, we set $B=g_{ij}$, $B^{-1}=g^{ij}$ and $\\text{det}(B)=g$ leading to:\n\t\t\n\t\tOr written in the physics way:\n\t\t\n\t\tand rearranged a bit:\n\t\t\n\t\tNow let us take the differential of $\\sqrt{-g}$ (or in other words, the \"\\NewTerm{variational of the metric determinant}\"):\n\t\t\n\t\tand injecting the prior-previous relation:\n\t\t\n\t\tWe can still write this relation in a slightly different style! We know that the metric and its inverse are related in the following way (\\SeeChapter{see section Tensor Calculus page \\pageref{metric and signature}}):\n\t\t\n\t\twhich leads to:\n\t\t\n\t\tTherefore\n\t\t\n\t\tHence:\n\t\t\n\t\tFinally we can write:\n\t\t\n\t\tAnd this is the first result we were looking for that we will keep for later to re-inject in the action integral variational $\\delta S$.\n\t\t\n\t\t\\item Now we focus on the term $\\delta(R_{ij})$. For this, let us recall (\\SeeChapter{see section Tensor Calculus page \\pageref{Ricci tensor}}):\n\t\n\tThen varying it, gives:\n\t\n\tThe first two terms of this expression suggest that it could be the difference between two covariant derivatives. Let us prove that it is the case.\n\t\n\tWe have by applying the definition of the second order covariant derivative\\footnote{The Christoffel coefficients are not tensors, but their variations have the character of a tensor.}:\n\t\n\tWe cans thus verify that:\n\t\n\tThe relation:\n\t\n\tis named the \"\\NewTerm{Palatini identity}\\index{Palatini identity}\".\n\t\\end{itemize}\n\tNow we can rewrite the action:\n\t\n\tLet us focus on the term (we will use the property that the covariant derivative of the metric is equal to zero a proven in the section of Tensor Calculus):\n\t\n\tWhen considering the expression in brackets, we notice that the $\\mu$ and $\\nu$ indices cancel out, so that we are left with a tensor rank $1$ tensor (very not obvious!):\n\t\n\tSo that we are left with the following integral expression:\n\t\n\tUsing the divergence theorem (\\SeeChapter{see section Vector Calculus page \\pageref{gauss ostrogradsky theorem}}):\n\t\n\tAs the variational are assumed to vanish on the hypersurface $\\mathcal{S}$ of the hypervolume $\\Omega$, we have:\n\t\n\tTherefore our action variational reduces to:\n\t\n\tFor the action to be stationary, the last expression must be equal to zero whatever he variations of the coefficients of the metric $\\delta g^{ij}$, which imposes that the expression between braces is null:\n\t\n\tWe recognize here the Einstein's field equation without matter! So it seems that our Lagrangian was a good candidate (but it needs more verification, especially, experimental tests!).\n\t\n\t\\subsubsection{Einstein-Hilbert action with cosmological constant}\n\tLet us try now:\n\t\n\twhere $\\lambda$ is a constant that we add to the curvature scalar $R$. The latter relation will obviously be written more explicitly as:\n\t\n\tWe already know the result of the first integral as it is simply the previous result we have get. Hence we need to focus only on the second integral!\n\t\n\tIf we apply as before the variation:\n\t\n\tand using the fact that we have proved just earlier that:\n\t\n\tWe then get:\n\t\n\tHence the global variation is:\n\t\n\tAs before, for the action to be stationary, the last expression must be equal to zero whatever he variations of the coefficients of the metric $\\delta g^{ij}$, which imposes that the expression between braces is null:\n\t\n\tWe recognize here the Einstein's field equation without matter and cosmological constant!\n\t\n\tIt is because of the shape of that result that the first relation we started with is finally written traditionally (in the purpose to be in agreement with the notation of the General Einstein's field equation):\n\t\n\t\n\t\\subsubsection{Einstein-Hilbert action with matter}\n\tWe see that the above result gives use the Einstein's field equation without matter. Ok good but... we want a bit more generalize result. Especially the result we already know:\n\t\n\tSo to deduce the corresponding form of the action and corresponding Lagrangian density we will proceed by reverse engineering.\n\t\n\tWe know that the previous relations will in fact be:\n\t\n\tAnd if we compare with the previous result:\n\t\n\tBy reverse engineering we will put:\n\t\n\tOk the variational was very easy to reverse engineer. But for the action and the Lagrangian we are looking for something such that (as we know the origin of the first two terms):\n\t\n\tSo we will try:\n\t\n\tSo let see what we get by developing $\\delta\\left(T_{ij}g^{ij}\\right)$. First we must recall that the variational principle request to evaluate the variation of the action in function of the variation of the metric $\\delta(g^{ij})$. Therefore:\n\t\n\tAnd that's it! So the corresponding action is finally:\n\t\n\tHence the density Lagrangian:\n\t\n\tObviously we can add the Cosmological constant to get:\n\t\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThere are different ways to derive the above results. Some, as above, use awful and simple reverse engineering reasoning. Others - like the one available on the Wikipedia page of the Einstein-Hilbert action - use circular reasoning about the Stress-Energy tensor and therefore leads to a slightly different expression of the Lagrangian density (implying some constant factor) with the advantage of having a beautiful technical mathematical development (at the opposite of the reverse engineering method...).\n\t\\end{tcolorbox}\t\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{90} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 33 votes,  61.82\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\t\n\t%to force start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Cosmogony}\n\t\\lettrine[lines=4]{\\color{BrickRed}C}osmogony is concerned with understanding the (hypothetical) birth and evolution of the Universe by the scientific method. It is only through this game between physical theories, models and observations that we will discuss this issue here. We will try to avoid carefully any metaphysical digression. The specific problems of cosmogony fit in its definition: Statistics that are one of the great scientific methods are apparently poorly efficient for study Universe theories as we have only one Universe visible to us at this day. Furthermore, we can only observe the past of our Universe (and furthermore only the observable part...). Can we speak about \"predictions\" in these conditions? The theories, however, are reliable since they predict behaviours that can be tested by observations.\n\t\n\tCosmogony mainly uses the arsenal of mathematics, theoretical physics, particle physics, nuclear physics, physics of detectors and astrophysics. It is interdisciplinary! Cosmogony deals with scales larger than the size of a galaxy to the scales defined as itself as \"Horizon\". Even if the limit is deliberately vague, cosmology does not address the internal details of the birth and evolution of astrophysical objects (such as galaxies, globular clusters, and clusters of galaxies) that fall more into the study field of \"\\NewTerm{cosmogony}\\index{cosmogony}\".\n\t\\begin{fquote}If you can explain a god without a creator, you can explain a Universe without a creator...\n \t\\end{fquote}\n\tBy the way... before we start with the maths..., for the answer to the question \\textit{Why does the Universe exist?} the reader should know first that the Universe has no obligation to make sense to us! Secondly, the \"First Cause Argument\" is human bias! Indeed, through modern science, specifically physics, natural phenomena have been discovered whose causes have not yet been discerned or are non-existent!! The best known example - among many others (!) is radioactive decay! Although decay follows statistical laws and it's possible to predict the amount of a radioactive substance that will decay over a period of time, it is impossible according to our current understanding of physics to predict when a specific atom will disintegrate as we have proved it in the section of Nuclear Physics. The spontaneous disintegration of radioactive nuclei is stochastic and might be uncaused, providing an arguable counterexample to the assumption that everything must have a cause.  An objection to this counterexample is that knowledge regarding such phenomena is limited and there my be hidden variables presently unknowns. But this latter objection has been mathematically eliminated (Bell Theorem).\n\t\n\tThe Universe wasn't created obviously for us Homo Sapiens! The fact that we can't survive anywhere else easily outside of the tiny ball of rock and metal - largely inhabitable for us and where most water isn't even pure drinkable water... -  we are travelling on without cost-prohibitive and high level technologies just for a one way trip, plus the fact that our little ball of rock and metal has an unstable orbit (perturbed by travelling stars in our galaxies), periodically bombarded of extinction level asteroids coming from the Oort cloud or bombarded by gamma rays bursts from potential dying stars, with a unstable long term climate and unstable supervolcano dynamics, and an unstable kernel, and an unstable main star is an obvious evidence! We can also consider as supplementary evidence that all other worlds (planets) we have been able to observed actually that are at a respectable distance for a one-way trip of thousands of years are inhabitable for us... Claiming the opposite is so naive that it is similar as putting a fish in a tiny aquarium in the middle of the desert and listening to the fish claiming the desert was made especially for him...\n\t\n\tAlso keep in mind that while reading what will follow that the Big Bang theory only tell how matter and energy expanded from the initial dense state to what we observe now. It doesn't state that matter and energy were created during the Big Bang, nor does it tell us where they're coming from (that's more related to the study of quantum cosmology\\footnote{There are actually (early 21st century) seven theoretical models giving possible answers to what was existing before the Big Bang: Spontaneous Symmetry Break (SSB-Ex nihilo), Quantum tunnelling fluctuation from WdW equation (WdWE), Conformal Cyclic Cosmology (CCC), String Gas Cosmology (SGC), Hartle-Hawking no-boundary measure (HHNBM), Loop Quantum Gravity pre-Big-Bang (LQGpBB), Quantum tunnelling fluctuation from Loop Quantum Gravity (QTFLQG)}).\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tLet us recall the following fact that we have already pointed out in the section of Probabilities: Some scientific illiterate people may argue that Roger Penrose calculated (on the assumption that our Universe is in a Black Hole a with very rough approximations and assumptions...) that for our Universe to be in the low entropy like now is $10^{10^{123}} =10^{123}$ to $1$. Hence it is impossible that our Universe is not created by a deity (passing under silence the question of who created that complex deity...). But it is irrelevant! Even if what he said is $100\\%$ accurate or off by a factor of a googol, it's irrelevant!! Indeed, if run a computer program that emulates a coin flipped one billion times and writes the sequence of heads and tails to a file. Great. What we just produced is a sequence more than a trillion trillion trillion times rarer!!  In fact, you could run that same computer program until the end of human existence and it would likely never produce that same string of outcomes. And yet it occurred nonetheless...\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Newtonian (ie non-relativistic) Cosmological Models}\\label{newtonian cosmological models}\\index{Newtonian cosmological models}\n\tA cosmological model is a mathematical representation of the Universe that seeks to explain the reasons for its present appearance, and describe its evolution over time (named \"\\NewTerm{cosmological time}\\index{cosmological time}\") but not its creation!\n\t\n\tThe Newtonian model applies under the assumptions of Newtonian mechanics (instantaneous action for example). The results we are going to study here were discovered before the development of General Relativity but published after! But this Newtonian model has the advantage, even if sometimes the mathematical assumptions and manipulations are very quite wrong, of simplicity while being able to identify and discuss the dynamics of the Universe and to prepare for the study of the Universe models making use of the results of General Relativity afterwards. Its disadvantage, besides the fact that it is not quite fit the experimental results, it is to be no longer valid under extreme conditions and therefore cannot be extrapolated to the instant of the Big Bang.\n\t\n\tBefore we begin, we must define the \"\\NewTerm{cosmological principle}\\index{cosmological principle}\" consisting of the following two assumptions (basically, it ensures that we are not privileged observers, and that what we are seeing is a representative of the whole of the Universe):\n\t\n\t\\begin{itemize}\n\t\t\\item[H1.] The space (the Universe) is homogeneous, that is to say, it has the same properties in all its regions. This must be at a very large scale, beyond the thousand Mpc (megaparsecs). It is clear that small-scale inhomogeneities exist... we for example... \\Winkey\n\t\t\n\t\t\\item[H2.] The space (Universe) is isotropic\\footnote{There is a disagreement in the beginning of the 21st century about this assumption that need more precise studies. Some physicists have a statistical evidence of a \"dark flow\" in the CMB - providing at the same time a possible argument for Multiverse model - some say it is only a noise. To follow...} at large scales, that is to say, there is no specific direction in space, such as flattening a direction or an overall movement on a Universal scale for example and all its physical properties are almost identical in any point.\n\t\\end{itemize}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis hypothesis of the isotropy of the Universe and that works relatively well in theoretical models (see below) requires an interesting fact if we admit a beginning to the Universe. This fact implies that the Universe had a phase in its history where it did not leave the time to the matter to clump together to form from its beginnings inhomogeneous and anisotropic material groups that are visible today in our telescopes. From this it follows that at a moment of its history, the Universe had an non-quasistatique expansion rate that we could make match with the speed of light (this is badly formulated but I hope it is still acceptable in the idea).\n\t\\end{tcolorbox}\n\tThe figure below shows the Automated Plate Measurement (APM) Galaxy Survey. Over $2$ million galaxies are depicted in a region of $100$\ndegrees across centered toward the Milky Way's south pole:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.55]{img/cosmology/apm_galaxy_survey.jpg}\t\n\t\t\\caption{Automated Plate Measurement (APM) Galaxy Survey}\n\t\\end{figure}\n\tWe will also request other working assumptions/hypothesis:\n\t\\begin{itemize}\n\t\t\\item[H1.] The Universe is a non viscous gaseous fluid whose particles are galaxies. Assuming the cosmological principle, the movement of galaxies, constituents in-fine of this \"fluid\" by construction, are statistically at rest.\n\t\t\n\t\t\\item[H2.] The Universe is a thermodynamically closed system, without work and adiabatic (no heat exchange with the outside).\n\t\t\n\t\t\\item[H3.] The Universe in a homothetic expansion (in uniform expansion in all its dimensions) is taken as having a spherical shape with a center (at least in the Newtonian model...).\n\t\t\n\t\t\\item[H4.] Its density is only a function of time and there is mass conservation (and therefore energy). Therefore the amount of material is constant (yes this is always the Newtonian model...)!\n\t\t\n\t\t\\item[H5.] We accept the Newtonian dynamics (approximation of General Relativity) to build the Newtonian models that will follow.\n\t\t\n\t\t\\item[H6.] The origin of time is treated as the origin of creation (horizon) of the Universe and repository of study is comoving with the particles (and therefore moves with the galaxies placed on the space-time pattern) and named \"\\NewTerm{reference material}\\index{reference material}\" (galaxies are stationary in this repository!).\n\t\\end{itemize}\n\n\t\\pagebreak\n\t\\subsubsection{Hubble's Law}\n\tAssuming the cosmological principle and the above assumptions, the distance from an origin point O to any point $M$ of the universe can vary in function of time (in a undetectable way to the human scale) in the form:\n\t\n\twhere $F(t)$ is the \"\\NewTerm{scaling factor}\\index{scaling factor}\" (denoted by $R(t)$ or even $a(t)$ depending on the context...). \n\t\n\tNotice that we can't have $\\overrightarrow{\\text{O}M}(t_0)=0$ otherwise, whatever the value of $F(t)$, $\\overrightarrow{\\text{O}M}(t)$ would always be equal zero... (this eliminate the theoretical possibility that the Universe may have had one day no size!). Also notice that $F(t)\\in \\mathbb{R}^+\\backslash\\{0\\}$, ie that means that the size of the Universe may decrease or increase in size but never come to a size equal to zero!\n\t\n\tIn writing this relation, we consider that the points O and $M$ are on a plane of zero curvature. Indeed, if we imagine two points on a circular curved surface (e.g. the surface of a sphere) let us see what happens:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/newtonian_universe_model.jpg}\t\n\t\t\\caption{Illustration of the validity limit of the model}\n\t\\end{figure}\n\tThe distance between two points on the circle (i.e. spherical space) is given by (\\SeeChapter{see section Trigonometry page \\pageref{spherical trigonometry}}):\n\t\n\tWe see very well in this relation that if the radius (of the spherical Universe) changes by a factor $F$, then the change in the distance between the two points is not linearly proportional to this factor!! Which is not the case in a zero curvature plane!\n\t\n\tConsequence: Our Newtonian model is valid only in a flat universe where General Relativity or purely classical energy approach (see further below) can take into account different types of curvature!\n\t\n\tWe see immediately that the relation:\n\t\n\tis independent of the chosen origin, in fact, if we apply it on any two points $A, B$ we have:\n\t\n\tThen by difference:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAt the time $t_0$ it is obvious that the above equation is:\n\t\n\tand imposes $F(t_0)=F(0)=1$. This is important and we will come back on it many times during the developments that will follow.\n\t\\end{tcolorbox}\n\tThe law above therefore applies to any segment $\\overline{AB}$ in the Universe. This is why the Universe has no geometrical center (at least as far as we know) and that we can represent ourselves the expansion of the frame of the Universe: consider a half-inflated balloon on whose surface we draw two marks (eg: two crosses drawn with ink). Inflating the balloon more we find that these two cross diverge from each other and therefore the distance between them will increase. This is what we are seeing with the galaxies:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/inflated_universe.jpg}\t\n\t\t\\caption{Illustration of the inflated balloon Universe model}\n\t\\end{figure}\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} If the Universe is expanding, why aren't we? The reason for this is that there are other physical phenomena at play besides the Universe's expansion. On small scales, like animal-sized and below, electromagnetism and nuclear forces dominate. On larger scales, like that of planets, solar systems and galaxies, gravitational forces dominate. On the largest scales of all, the expansion wins. But there are also smaller scales, where the expansion has been overcome, at least locally. The Virgo cluster itself will remain gravitationally bound. The Milky Way and all the local group galaxies will stay bound together, and eventually merge under their own gravity. It's only on the largest scales of all, where all the binding forces between objects are too weak to defeat the speedy Hubble rate, that expansion occurs at all.\\\\\n\t\n\t\\textbf{R2.} If the Universe expands, then where it expands to? The Universe isn't expanding into anything. If there is something \"beyond\" the Universe, that would, by construction, also be part of the Universe. Our limited human intuition usually fails us on this concept because we think of the Big Bang as an explosion and explosions expand into their surrounding space. The Universe, however, is not surrounded by more space. The analogy with the inflating balloon in the figure above helps to grasp the concept. Not the 3D volume of the balloon, but the 2D surface of the balloon is our Universe. And as you can see, it's expanding itself and does not have any border!\n\t\\end{tcolorbox}\n\tDeriving with respect to time the relation:\n\t\n\tThe first member then gives the particle velocity (or other any object) to the point $\\vec{r}(t)=\\overrightarrow{\\text{O}M}(t)$:\n\t\n\tTherefore eliminating $\\overrightarrow{\\text{O}M}(t_0)$ (we see that if we have $F(t)=0$ we have indeed an issue or a... \"singularity\"...):\n\t\n\tWe put to simplify the notations:\n\t\n\tTherefore we have:\n\t\n\tThis relation is known as the \"\\NewTerm{Hubble law}\\index{Hubble law}\" or \"\\NewTerm{velocity-distance relation}\\index{velocity-distance relation}\" and which, according to historical research should have for paternity rather Georges Lemaître... That's why it is sometimes named the \"\\NewTerm{Hubble-Lemaître law}\\index{Hubble-Lemaître law}\". However... (!) although widely attributed to Edwin Hubble or Georges Lemaître, the notion of the universe expanding at a calculable rate was first derived from general relativity equations in 1922 by Alexander Friedmann and five year afters in a very different shape ($\\mathrm{d}\\lambda/\\lambda =r/R_0\\sqrt{3}$) by Lemaître. But that effect was already known experimentally and modelized in 1914 by Vesto Slipher and written for the first time in it's modern shape in 1928 by Howard P. Robertson (see \\cite{smith1979origins} for all the details).\n\t\n\tBefore going further, it is necessary to pause on this equation for the present moment:\n\t\n\tThis equation says that the object of the Universe recede with a speed proportional to their distance in all points of the Universe without special repository (no galaxy seems to be fixed while they are in the material repository!).\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis relation allows for speeds higher than those of light... But this is not a violation of Special Relativity regarding the constancy of the speed of light! Indeed, we must not forget that the Hubble law takes into account the expansion of the \"frame\" of space-time on which light moves. Also Special Relativity deal with speed of light and not with speed of space itself. Keep in mind that the expansion of the Universe doesn't have a \"speed\" (typical error of amateur scientists!). Therefore if the frame extends along an expansion factor $F$ greater than one, it gives the impression that light travels faster than $c$, and this is what gives sometimes a redshift value of $4$ or $5$ or even $11.09$ (the actual record)!\\\\\n\t\n\tThe idea of even talking about \"the expansion velocity of the universe\" is bizarre and never should have been entertained in the first place in massmedia and especially because there is no well-defined notion of \"the velocity of distant objects\" in General Relativity (there is simply no such thing as the \"velocity\" between two objects that aren't in a first approximation located in the same place!). Sot give people the impression that what's special about the so named \"inflation\" is that the Universe is expanding faster than light is a crime against comprehension and good taste (what's special about inflation is that the universe is accelerating).\n\t\\end{tcolorbox}\n\t\n\n\tThe constant $H(t_0)=H_0$ being of course being identifiable to the \"\\NewTerm{Hubble constant\\footnote{We should rather speak of \"Hubble parameter\\index{Hubble parameter}\" as it is not constant through time (since there are dynamical forces acting on the particles in the Universe which affect the expansion rate).}}\\index{Hubble constant}\" (that is not a constant...) as currently measured in the early 2000s as being about\\footnote{The last value (2018-07-18) gives $67.66\\pm 0.42 \\; [\\text{km s}^{-1} \\text{Mpc}^{-1}]$} $\\sim 67.66\\; [\\text{km s}^{-1} \\text{Mpc}^{-1}]$. That means that for every million parsecs of distance from an observer, the rate of expansion increases by about $67.66$ kilometres par second.\n\t\n\tIn the IS (International System) units, since one megaparsec is almost equal to $\\sim 3.085\\cdot 10^{22}\\; [\\text{m}]$ then we have:\n\t\n\tThus, a current estimate of the age (horizon) of the Universe could be interpreted as the inverse of the Hubble parameter that gives the \"\\NewTerm{Hubble time}\\index{Hubble time}\":\n\t\n\tthat is to say about 13 billion years ago (we will see further below a better approach).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.8\\textwidth]{img/cosmology/hubble_parameter_estimations.jpg}\t\n\t\t\\caption[Evolution of Hubble parameter estimations]{Evolution of Hubble parameter estimations (source: Robert P. Kirshner)}\n\t\\end{figure} \n\tConversely, we can have fun to calculate the distance from which we (ie the observed galaxies) can reach the speed  thanks to the equation:\n\t\n\tand a numerical application gives roughly $13$ billion light years. This is the distance of the \"\\NewTerm{cosmological horizon}\\index{cosmological horizon}\".\n\t\n\tIn cosmology, a \"\\NewTerm{Hubble volume}\\index{Hubble volume}, or \"\\NewTerm{Hubble sphere}\\index{Hubble sphere}\", is a spherical region of the Universe surrounding an observer beyond which objects recede from that observer at a rate greater than the speed of light due to the expansion of the Universe. Regarding the relation we get above, the corresponding radius today is given by (assuming that the Hubble parameter has always been constant):\n\t\n\thence almost equal to $14$ billion light-years. As observations seems to indicate that our Universe is accelerating, some objects that we can currently exchange signals with, will one day cross our Hubble limit!\n\t\n\tBut... it's takes almost $14$ billion light-years under these assumptions to reach us so it could have moved another $14$ billion light years... (still under the same assumptions!). So the \"comobile radius\" would be $28$ billion light years away! Then the diameter of the Universe (or \"comobile diameter\") under these assumptions is:\n\t\n\t\n\tIn other words, knowing that the huge majority of galaxies are escaping from our Milky Way, this result has a quite important conclusion: in a far future, the sky as seen from our galaxy (or what will remain of it...), will be completely dark as (almost) everything will be moving away at a speed greater than that of light! So we are \"lucky\" to observe the Universe at it is today as otherwise the cosmological model would have been much more harder to establish without the observation of other galaxies... (and keep in mind that this is an effect strictly relative to the observer!).\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/hubble_horizon.jpg}\t\n\t\t\\caption{An artistic concept of the Hubble Horizon (source: ?)}\n\t\\end{figure}\n\t\n\t\\subsection{Friedmann Equations (Newtonian derivation)}\n\tConsider now a spherical ring of material of radius $r$ and of constant mass $m$ expanding at velocity $v$, and containing a ball of material of mass $M$ (also in expansion at speed $v$).\n\t\n\twhere $k_1$ is a constant. By dividing by $m$ and replacing each member $M$ by its expression as a function of the density, we obtain:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf it can help the reader to understand what we did with the term of the potential energy, he can refer to section Classical Mechanics when we developed the calculations of the potential energy of a material sphere.\n\t\\end{tcolorbox}\n\t\n\tand:\n\t\n\tWe get:\n\t\n\tThat we simplify in:\n\t\n\tHowever, $k_1,m,r_0$ are constants. We introduce a new constant $k$ defined by (to simplify the notations):\n\t\n\tSo we get the equation:\n\t\n\twhich is none other than the \"\\NewTerm{Friedmann's first equation}\\index{Friedmann's first equation}\" that we frequently find in the literature as follows (among others notations...):\n\t\n\tIt is possible to obtain the same equation, but in a much more general and rigorous way, from Einstein's field equations (\\SeeChapter{see section General Relativity page \\pageref{einstein field equations}}) and the metric of Friedmann-Lemaître-Robertson-Walker (see further below page \\pageref{Friedmann-Lemaître-Robertson-Walker Cosmological Models}).\n\t\n\tLet us still notice a very common form of that relation. When using Einstein's mass and energy equivalence ($E=mc^2$) the above density $\\rho$ is no longer a mass density but an energy density, we will have to divide it again by the squared speed of light to have a mass density again. It is the same if at the denominator of the constant $k$, the mass $m$ is replaced by energy, then we will have to multiply $k$ by the squared speed of light to fall back on a mass. We then have, denoting now the scale factor by $a$ (as it is often customary in the literature) and redistributing the terms, the following form of the first Friedmann equation:\n\t\n\twhere $a$ is also known as the \"\\NewTerm{cosmic scale factor}\\index{cosmic scale factor}\" or sometimes the \"\\NewTerm{Robertson-Walker scale factor}\\index{Robertson-Walker scale factor}\".\n\t\n\tThe latter relation is also commonly written:\n\t\n\tor:\n\t\n\tThese equations were derived in 1922 by Friedmann, seven years before Hubble's discovery, when Albert Einstein did not believe in his own equations because they did not allow the universe to be static. Also Friedmann's equation did not gain recognition until after his death, when they were confirmed by an independent derivation by Georges Lemaître in 1927.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tAlbert Einstein added to this equation for personal and quasi-religious beliefs a cosmological constant equation that allowed him to make static the scale factor of the Universe. I (as the main redactor of the book) reject this arbitrary constant (at least until this date), even if in the contemporary physics, it has become a trendy constant (its value was defined more mathematically rather than religiously) because it would explain the origin of a supposed \"dark matter\" that seem to accelerate the expansion of our Universe (this acceleration could also be a \"local\" departure of the Hubble parameter from its globally averaged value perhaps caused by a local void in the mass density of our space neighbourhood named a \"\\NewTerm{Hubble bubble}\\index{Hubble bubble}\"), the current laws of our Universe, the inflationary period of our universe and its geometry. Thus, the first Friedmann equation with the cosmological constant, which is a total artifice of work, is then: \n\t\n\twith:\n\t\n\tThis is Andrei Sakharov who defined the value of the above cosmological constant, which supposedly corresponds to the quantum energy of vacuum (depending on the Higgs fields).\\\\\n\t\n\tIn quantum physics the equations of the field associated with elementary particles that are used to define the Big Bang theory are one of the main flow of the beginning of this 21st century. The famous Einstein's field equation tells us that energy creates a gravitational field like the electron in motion causes an electromagnetic field. It follows from these two observations that by measuring the gravitational field we have a way to determine the energy of vacuum. The gravitational field is no longer about the matter but about the energy density of vacuum. But the cosmological constant is directly proportional to the constant of gravity $G$. Its measurement is a quite very dangerous game because its value depends on several fundamental laws of physics and of significant properties on the dynamics of our Universe. The debate remains completely open and if I (the main redactor of this book) find a valid and rigorous proof of this constant, we will provide to the reader the  consequences of this constant on the models that we will see below.\n\t\\end{tcolorbox}\n\tLet us now use the first law of thermodynamics (\\SeeChapter{see section Thermodynamics page \\pageref{first law of thermodynamics}}) for a system by definition that will be closed and isolated, which the sum of kinetic and potential energy is constant (and therefore the amount of total energy variation is zero for these two energies). We then have that the change in total energy is only given by the variation of internal energy (the most common case in thermodynamics for macroscopic objects):\n\t\n\tand we have also proven in the section of Thermodynamics the characteristic equation of a fluid in equilibrium:\n\t\n\tIf the system is adiabatic (no heat transfer between the system and outside), then we have also proven in the section of Thermodynamics that the variation of entropy was:\n\t\n\tThen:\n\t\n\tAssuming the universe being spherical (...), we have:\n\t\n\tand in the material repository where galaxies (cosmic fluid particles) are immobile:\n\t\n\tTherefore:\n\t\n\twhich simplifies in:\n\t\n\ttaking the derivative with respect to the cosmic time $t$:\n\t\n\ttherefore we get the \"\\NewTerm{Universe fluid equation}\\index{Universe fluid equation}\" or \\NewTerm{Universe continuity equation}\\index{Universe continuity equation}\" (for a spherical universe!):\n\t\n\tof denoted in textbooks:\n\t\n\tThere is another way (more beautiful but much more technical) to derive the above equality. Indeed, we have proved earlier above:\n\t\n\tTherefore:\n\t\n\tBefore plugging in to Einstein's equations, it is educational to consider the zero component of the conservation of energy equation:\n\t\n\tAs we have seen in the section of Tensor Calculus during our study of the covariant derivative (see page \\pageref{covariant derivative}) that:\n\t\n\tand also remember that\\footnote{The read must notice here that we take the special case of a flat Minkowski metric because otherwise we have no conservation of energy! That's why physically in General Relativity, asymptotically flat space-times represent isolated systems}:\n\t\n\twe have then (keep in mind that one of the stress-energy tensor index is lowered thanks to the metric hence the change of signs below after the second equality):\n\t\n\tLet's finally simplify the last equality by dividing both sides by $c$ to fall back on:\n\t\n\tNow let us take again the first Friedmann equation, obtained earlier above, in the form:\n\t\n\tand let us write it as follows:\n\t\n\tIf we differentiate:\n\t\n\tThen we get:\n\t\n\tLet us inject:\n\t\n\tin the relation:\n\t\n\tThen we get:\n\t\n\tThus:\n\t\n\tThe following relation:\n\t\n\tis the \"\\NewTerm{Friedmann's second equation}\\index{Friedmann's second equation}\" that is also sometimes named \"\\NewTerm{Raychaudhuri equation}\\index{Raychaudhuri equation}\".\n\t\n\tIn general, in the field of cosmogony, any relation of the type $H^2=(\\dot{R}/R)^2=\\ldots$ is named \"\\NewTerm{velocity equation}\\index{velocity equation}\" and any relation of the type $\\ddot{R}/R=\\ldots$  is named \"\\NewTerm{acceleration equation}\\index{acceleration equation}\".\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t Notice that when $\\rho>0$ and $P>0$ we have that $\\ddot{R}<0$. This was the reason that had led Einstein to introduce his \"cosmological term\". Indeed, we see that otherwise we must have $\\rho< -3P/c^2$ so that the right term remains positive...\n\t\\end{tcolorbox}\n\t\t\n\t\\subsubsection{Critical Density and Density parameters}\\label{critical density}\n\tLet us come back to our first Friedmann equation without cosmological constant. So we have shown above that:\n\t\n\tWe obtained then by injecting the latter relation in the first Friedmann equation the following relation:\n\t\n\twhich rearranges with:\n\t\n\tinto:\n\t\n\tThe exponent of the left term requires that the right term is positive or zero as:\n\t\n\tRecall that the initial conditions impose us that at time $t_0=0$ we have:\n\t\n\tIndeed:\n\t\n\tThen it comes:\n\t\n\tThis term should be accessible to observation, sadly $H_0^2$ is very poorly known and $\\rho_0$ even more. In other words, given the \"$-$\" sign in the expression of $k$, we do not even know today the sign of this constant.\n\t\n\tHowever, it may be important to notice that there is a value $\\rho_0$ named \"\\NewTerm{critical density}\\index{critical density}\" that cancels the $k$ above and therefore also (see above):\n\t\n\tas it is also equal to $k$. This imply that the total Energy of the Universe would be zero (following considerations of quantum cosmology).\n\n\tThis value $\\rho_0$ is given immediately by:\n\t\n\tFor $H_0=67.80\\pm 0.7\\;[\\text{km} \\cdot\\text{s}^{-1}\\cdot\\text{Mpc}^{-1}]$ we get:\n\t\n\tIn comparison, a hydrogen atom weighs $1.7\\cdot 10^{-27}\\;[\\text{kg}]$, the critical density would therefore correspond to six hydrogen atoms per cubic meter.\n\n\tPhysicists have defined a constant (time-varying... so therefore not so constant...) denoted by the Greek letter $\\Omega$ and named \"\\NewTerm{cosmological density parameter}\\index{cosmological density parameter}\" and given by the ratio of the mass density (or energy densities since the ratio will be the same!):\n\t\n\tastrophysicists often break the cosmological density parameter into three terms (notice the lower case indexes!):\n\t\n\testimated experimentally in this early 21st century at $\\Omega=1.00\\pm0.02$. We can even found decomposition in more terms (radiation, relativistic matter, non-relativist matter, dark energy, dark matter and vacuum, etc.).\n\t\n\tIt is interesting to work with this constant because in the case:\n\t\\begin{itemize}\n\t\t\\item $\\Omega=1$\\\\\n\t\tWe have:\n\t\t\n\t\twhich gives by replacing in the Friedmann $k=0$ (flat and infinite Universe as we shall see in our study of the relativistic model).\n\n\t\t\\item $\\Omega>1$ (ie $\\rho_0>\\rho_c$)\\\\\n\t\tBy performing the same reasoning, and still using inequality, we have then: $k>0$ (a Universe with positive curvature (closed) as we shall see in our study of the relativistic model).\n\n\t\t\\item $\\Omega<1$ (ie $\\rho_0<\\rho_c$)\\\\\n\t\tBy performing the same reasoning, and still using inequality, we have then: $k<0$ (a Universe with negative curvature (open) as we shall see in our study of the relativistic model).\n\t\\end{itemize}\n\tThese three situations can be summarized geometrically by the following well known figure:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.4]{img/cosmology/type_universe.jpg}\t\n\t\t\\caption[Illustration of the different types of curvature]{Illustration of the different types of curvature (source: Wikipedia)}\n\t\\end{figure}\n\tAll measurement which have been made so far have failed to show a curvature of the Universe (anisotropy). The measurements of the microwave background (see mathematical details further below) by the BOOMERANG balloon and COBE satellite however, tend to support the hypothesis of a relatively flat Universe validating therefore numerical simulations\\footnote{We will show in the future that the mathematics of the CMB involve spherical harmonics and Fourier transform on a sphere.}:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/anisotropy_boomerang.jpg}\t\n\t\t\\caption{Illustration of what would give observations depending on the curvature type}\n\t\\end{figure}\n\tAlso satellites sensibility don't stop to increase as how the figure below but it's still hard to conclude anything about the temperature background anisotropy:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.11]{img/cosmology/anisotropy_performance.jpg}\t\n\t\t\\caption[Comparison of CMB results from COBE, WMAP and Planck]{Comparison of CMB results from COBE, WMAP and Planck – 2013-03-21 (source: Wikipedia)}\n\t\\end{figure}\n\tThe Planck CMB seems to give evidence of fluctuations on the order of $1$ part in $100,000$ across the sky (root mean square variations are only $18\\;[\\mu \\text{K}]$). So according to some cosmologist this may be an evidence that the Universe was quite homogeneous at its beginning (hence the use of the Friedmann-Robertson-Walker-Lemaître metric in many Quantum Cosmology models).\n\t\n\tAnd an another interesting figure that shows our Universe density fluctuations at different scales:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.9]{img/cosmology/universe_density_fluctuations.jpg}\t\n\t\t\\caption[Universe fluctuation density scales]{Universe fluctuation density scales (source: ?)}\n\t\\end{figure}\n\tNow remember that we have proved earlier that:\n\t\n\tRearranging:\n\t\n\tThen according to what we have defined just above the relation can be rewritten:\n\t\n\twhere:\n\t\n\tThat are other well known density parameters is cosmology!\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe concept of Universe topology and openness are actually normally two separate concepts. When we speak of \"open\" or \"closed\" Universe we do not normally talk about its topology but his destiny! Thus, an \"open\" Universe is expanding indefinitely and a \"closed\" Universe recontracts on itself after a given time. That said, in the models that we study in this section (cosmological constant equal to zero), the curvature is directly related to the density, and thus to its openness.\n\t\\end{tcolorbox}\n\tLet us come back to the relation:\n\t\n\tWe can write:\n\t\n\tBy adopting the notation:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe actual measurement gives (year 2007): $A\\cong 0.2793923067\\cdot 10^{-35}$.\n\t\\end{tcolorbox}\n\tTherefore:\n\t\n\tIt is now appropriate for us to consider three situations:\n\t\n\tthus correspond respectively to the cosmological density parameters:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe can't put $\\rho_0=0$ because our initial assumptions was the principle of conservation of energy.\n\t\\end{tcolorbox}\n\t\n\t\\pagebreak\t\n\t\\subsection{Friedmann-Lemaître Cosmological Models}\\label{Friedmann-Lemaitre Cosmological Models}\n\tThe Euclidean cosmological models of Friedmann-Lemaître consist in the Newtonian  limit to study the  \"\\NewTerm{fundamental equation of Friedmann models}\\index{fundamental equation of Friedmann models}\":\n\t\n\tconsidering the three situations:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt is possible within the framework of General Relativity to rigorously find a solution to Einstein's field equations named the \"\\NewTerm{Friedmann-Lemaître-Robertson-Walker metric}\" which in the case of a Newtonian approximation gives us the Friedmann equations obtained in the present text (often these are the approximations that are used in the literature because the exact solution is out of the  framework of the traditional universities courses of the 21st century). For the general treatment see further below page \\pageref{Friedmann-Lemaître-Robertson-Walker Cosmological Models}.\n\t\\end{tcolorbox}\n\t\\subsubsection{Flat spaces ($k=0$)}\n\tThe flat (Euclidean) space model consist to assume that $k=0$. In other words, we are in a Universe whose density is named \"\\NewTerm{critical density}\\index{critical density}\" or also simply \"\\NewTerm{flat}\\index{flat}\" (as we will see with the relativistic model).\n\n\tThen we have the following equation:\n\t\n\tBy arranging appropriately the terms:\n\t\n\tand by integrating, it comes (there is obviously a constant of integration that we will add at then end!):\n\t\n\tWhich simplifies in (we raise to the square, hence the removal of the double sign $\\pm$):\n\t\n\tSo we have in this model the relation:\n\t\n\tto which we must add now the constant of integration for the condition corresponding to today:\n\t\n\tthat remains satisfied. Therefore:\n\t\n\tThis gives us a plot function that looks like this (do not trust the values shown on the horizontal axis as they are arbitrary):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/friedmann_flat_space.jpg}\t\n\t\t\\caption{Evolution of the scale factor for a zero curvature space}\n\t\\end{figure}\n\tWe put the area where $F(t)<1$ in evidence to remember that this part of the solution is to reject.\n\n\tSo we have a model of Universe in which the scale factor is growing exponentially and this indefinitely.\n\t\n\tNotice also that in this case:\n\t\n\tThat means with this model that the Universe had already a non-zero size at the beginning of time. This is a good point as we have already presented at the beginning that we should have $F(t)\\in \\mathbb{R}^+\\backslash\\{0\\}$.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tMore $\\rho_0$ is big, more the scale factor increase fast (meaning that the slope is obviously larger).\n\t\\end{tcolorbox}\n\t\n\t\\pagebreak\n\t\\paragraph{Flat space dominated by matter}\\mbox{}\\\\\\\\\\\n\tThere is also another approach much more elegant and subtle from my point of view than the previous proof (I have discovered that many years after writing the previous version). It has the benefit of highlighting a hypothesis that does not appear with previous developments.\n\n\tWe start from the first Friedmann equation:\n\t\n\tPutting $k$ as being equal to zero and using the trick that consist to start from the relation proved also earlier above (used to proved the second Friedmann equation):\n\t\n\tto require that the fluid pressure $P$ (whatever it is: gas or radiation) is zero. We then say that the Universe is a universe dominated by matter and we deduce:\n\t\n\twhich gives us (in this situation $\\rho$ is often denoted $\\rho_{\\text{mat}}$ in many textbooks):\n\t\n\tHence the important relation for matter dominated Universe:\n\t\n\tUnder these conditions, the first Friedmann equation becomes:\n\t\n\trearranging and simplifying, we then have:\n\t\n\twhich gives:\n\t\n\tAt the time $t=0$ of the \"Big Bang\", many textbooks assume the scale factor is equal to $R=0$ (only in the purpose to simplify the notations!!!) and thus the constant is zero (don't forget that in reality we should rather assume that it is equal to $-3/2$ instead to have after rearranging a $+1$ on the right side of the equality when $t=0$). Then we have:\n\t\n\tBy putting that at time $t=0$, the scaling factor $R_0$ was unitary, the latter relation simplifies to:\n\t\n\tUsing the common notation in theoretical cosmology we get the famous relation often given without proof:\n\t\n\tNotice also that in this case, with this simplified notation (that doesn't take into account the integration constant), we have the misleading limit:\n\t\n\tBut in fact, if we take into consideration the constant, we have indeed:\n\t\n\tthat means (for recall) that at beginning of the time, the Universe didn't have zero dimensions (otherwise applying a non-null scale factor on a zero value wouldn't have any effect), but had already a given unknown size.\n\t\n\tIf we assume that the scale factor is today taken as unitary, then it comes:\n\t\n\tand by replacing in it the numerical values currently known of the Hubble parameter, it follows that the universe is now aged about $8.6$ billion years (compared to $13$ billion of the Hubble time obtained earlier above!).\n\t\n\t\\paragraph{Flat space dominated by radiation}\\mbox{}\\\\\\\\\\\n\tWe have proved in the section of Thermodynamics during our study of the Stefan-Boltzmann law that the pressure of radiation was related to the energy density by the following equation:\n\t \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn many textbooks the authors define:\n\t\n\t\\end{tcolorbox}\n\tIn a universe dominated by radiation, the relation:\n\t\n\t proved earlier, expressed with a density of energy and not a density of mass becomes:\n\t\n\tTherefore:\n\t\n\tand using the relationship between radiation pressure and energy density, we get:\n\t\n\tAfter a little rearrangement, we get:\n\t\n\tfrom which we get that:\n\t\n\tHence the important relation for radiation dominated Universe:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tUsing the previous results notice that we have so far:\n\t\n\t\\end{tcolorbox}\n\t\n\tUnder these conditions, the first Friedmann equation:\n\t\n\tbecomes first by changing into energy density and with $k$ being put as equal to zero:\n\t\n\tand so we can replace the energy density by the result we get just before:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe prior-previous relation is often denoted:\n\t\n\twhere:\n\t\n\tis sadly (because it hasn't the units of a mass and it's not related to the different famous Planck values) named the \"\\NewTerm{reduced Planck mass}\\index{reduced Planck mass}\" ).\n\t\\end{tcolorbox}\n\tThen we have:\n\t\n\thence:\n\t\n\tThe primitive is obvious and is immediate:\n\t\n\tAt the time $t=0$ of the \"Big Bang\", many textbooks assume the scale factor is equal to $R=0$ (only in the purpose to simplify the notations!!!) and thus the constant is zero (don't forget that in reality we should rather assume that it as equal to $-2$ instead to have after rearranging a $+1$ on the right side of the equality when $t=0$). Then we have:\n\t\n\tBut assuming that at $t=0$ we had $R_0=1$ then we have:\n\t\n\tTherefore:\n\t\n\tThus after simplification it remains only:\n\t\n\tUsing the common notation in theoretical cosmology we get the famous relation often given without proof:\n\t\n\tThen a flat universe dominated by radiation has a scaling factor that is growing slightly more slowly than a flat universe dominated by matter.\n\n\tNotice also that in this case:\n\t\n\tBut in fact, if we take into consideration the integration constant, we have indeed:\n\t\n\tthat means (for recall) that at beginning of the time, the Universe didn't have zero dimensions (otherwise applying a non-null scale factor on a zero value wouldn't have any effect), but had already a given unknown size.\n\t\n\tIn comparison with Maple 4.00b (blue: flat universe dominated by matter, in red: flat universe dominated by radiation):\n\n\t\\texttt{>plot([t\\string^(2/3),t\\string^(1/2)],t=0..2*Pi,0..3,color=[blue,red]);}\\\\\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/universe_scale_factor_evolution_flat_matter_radiation_maple.jpg}\t\n\t\t\\caption[]{Evolution of $R$ for a zero curvature space dominated by matter or radiation.}\n\t\\end{figure} \n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe have seen that for a Universe dominated by matter we had:\n\t\n\tthat reduces to\n\t\n\tand for a universe dominated by radiation:\n\t\n\tSo we see that the two previous relations are respectively a special case of the first one that if we rewrite as:\n\t\n\twith $P=\\omega(T)\\rho c^2$, that is to say a barotropic fluid assumption (linear relation between $\\rho$ and $P$), we fall back on the first radiation one when $\\omega(T)=1/3$ and colisionless matter when $\\omega(T)=0$ and vacuum energy when $\\omega(T)=-1$.\\\\\n\t\n\tWe also have by integrating the last relation above:\n\t\n\tNotice that we can often found in various textbooks and even in the present book, the following notation for the energy density (...):\n\t\n\twith $\\rho_{\\omega 0}$ being the value of energy density at present time.\n\t\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Spherical spaces ($k>0$)}\n\tIn this model (also sometimes named \"elliptical model\"), we consider $k>0$. So the equation to deal with remains:\n\t\n\tWhich can also be written:\n\t\n\tLet us recall that we have assumed that for $t=t_0$ we had $F(t_0)=1$, if we make the change of variable $U=1/F(t)$, we get the following integral:\n\t\n\tSo we are looking of a primitive of:\n\t\n\tand we will discuss the sign $\\pm$ after having found the primitive.\n\n\tWe still carry a change of variable:\n\t\n\tthus:\n\t\n \twhich gives us the following primitive to calculate:\n\t\n\tby doing again a change of variable:\n\t\n\tTherefore to a given multiplicative constant $2Ak^{-3/2}$ we have finally the following integral:\n\t\n\tIn the section of Differential and Integral Calculus we proved that this form of primitive is resolved by (we add the constant of integration at the end because we do physics and we must satisfy to some initial conditions at which are not necessarily interested to in mathematics):\n\t\n\twith:\n\t\n\thence:\n\t\n\tWe still have to calculate $I_1$ (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{usual primitives}}):\n\t\n\tFinally:\n\t\n\tby inverting all the changes of variables and introducing the multiplicative constant again, we have finally in the case where $k>0$:\n\t\n\tBetween the two terminals of integration $(1/F,1)$ we therefore have (the integration constant cancels and we take back the $\\pm$ which was originally in the primitive):\n\t\n\twhere for recall the theory request that $\\Delta t>0$ (otherwise it's pure speculation and philosophy...).\n\t\n\tWe see that as expected (!!!), if we $F=1$ in the above relation we have indeed $\\Delta t=0$ (that means that at the moment in time we take the Universe actual size as reference, the time variation is indeed equal to $0$ as expected). In other words, we also have for this model (changing to the other typical notation for the scale factor):\n\t\n\tIf we plot this function for a fixed value $k>0$. We have the following  animated plot Maple in 17.00 for the negative sign:\n\t\n\t\\texttt{>restart:\\\\\n\t>f:=(A,k,F)->-[(F*sqrt(A/F-k)/k+A/k\\string^(3/2)*arctan(sqrt(A/f-k)/sqrt(k)))\\\\\n\t-(sqrt(A-k)/k+A/k\\string^(3/2)*arctan(sqrt(A-k)/sqrt(k)))]:\\\\\n\t>plots:-animate(plot3d,[f(A,k,F),k=0.1..1,F=0..10,],A=0..1)\n\t}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/spherical_universe_maple_animation_minus_sign_solution.jpg}\n\t\\end{figure}\n\tWe can see with this solution that as time increase the Universe reach an asymptote size whatever the value of $k$, but the bigger is $k$ the faster the asymptote is reached. In other words... we must be lucky not to be in a Universe with a to big positive curvature...\n\t\n\tAnd for the positive sign:\\\\\n\t\n\t\\texttt{>restart:\\\\\n\t>f:=(A,k,F)->+[(F*sqrt(A/F-k)/k+A/k\\string^(3/2)*arctan(sqrt(A/f-k)/sqrt(k)))\\\\\n\t-(sqrt(A-k)/k+A/k\\string^(3/2)*arctan(sqrt(A-k)/sqrt(k)))]:\\\\\n\t>plots:-animate(plot3d,[f(A,k,F),k=0.1..1,F=0..10,],A=0..1)\n\t}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/spherical_universe_maple_animation_plus_sign_solution.jpg}\n\t\\end{figure}\n\tWe can see with that this solution see to be the symmetric one of the above plot. That means as time reached back to the zero value, the Universe contracts on single point back and once again this effect is slower as $k$ is big! \n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe time $\\Delta t$ in the above plots is always represented on the vertical axis and also for all the following charts further below (you have to turn your head a little if as usually you want to put the time on the horizontal axis...).\n\t\\end{tcolorbox}\n\tBy fixing a small value of $A$ and for $k$, we get the following two-dimensional plot first for the negative sign:\n\t\n\t\\texttt{>k:=0.0001;A:=1;\\\\\n\t >plot([-(F*sqrt(A/F-k)/k+A/k\\string^(3/2)*arctan(sqrt(A/F-k)/sqrt(k)))-(sqrt(A-k)/k\\\\\n\t+A/k\\string^(3/2)*arctan(sqrt(A-k)/sqrt(k)))],F=1..10000,labels=[F,t])}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/universe_factor_evolution_for_constant_A_negative_sign.jpg}\n\t\\end{figure}\n\twhere we as have already mention, the reader must keep in mind that the values below $1$ must be rejected!\n\t\n\tAnd for the positive sign:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/universe_factor_evolution_for_constant_A_positive_sign.jpg}\n\t\\end{figure}\n\tBy looking at the both plots above it is obvious to see that we have after a rotation and putting each one next to the other (we also could change the time reference to have a logical time axis):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.49]{img/cosmology/universe_big_bang_big_crunch.jpg}\n\t\t\\caption{Big Bang and Big Crunch plot side by side}\n\t\\end{figure}\n\tand what we see here is the Big Bang and the Big Crunch!\n\t\n\tNow let us recall that to build the previous model we started from:\n\t\n\tA limit condition (condition of integration) is that the right term to be positive. That is:\n\t\n\tor:\n\t\n\tSo for our previous $2$D plots this limit is locate at $F=k/A=10,000$ and this is according to the maximum value before the Universe turn into a Big Crunch.\n\t\n\tSo if $F^{-1}$ is smaller than $F_{\\lim}^{-1}$, we are not in a valid (real) domain model anymore.\n\t\n\tIn fact, beyond the time limit $t_{\\lim}$ corresponding to this $F_{\\lim}$, what does not know the computer that has drawn our function plot is that it should switch to the scaling function with the \"$+$\". So when we execute the plot of both functions we should get the previous figure.\n\t\n\tWe see then that for $t<t_{\\lim}$ the Universe is entering a phase of contraction that we commonly name the \"\\NewTerm{Big Crunch}\\index{Big Crunch}\". After this phase of contraction, it is possible that either the Universe disappears completely in a singularity or that it re-enters a cyclical dynamic phase (mathematically the two outcomes seems to be possible).\n\t\n\t\\paragraph{Spherical space dominated by matter}\\mbox{}\\\\\\\\\\\n\tJust as the model for flat space, there is also another approach much more elegant and subtle for my taste than the previous proof (I have also discovered that many years after writing the previous text). It also has the advantage of highlighting a hypothesis that has not appear with previous developments and allows to plot more simply in Maple 4.00b the behaviour of the scale factor of the Universe. We thus find exactly the famous plot representing the evolution of the scale factor of the Universe available in almost all popular books on the subject (without proofs obviously...)\n\n\tWe start again from the first Friedmann equation:\n\t\n\tIt is customary for this model equation to put $k=+1$ (even take any positive number at least pick one that is friendly...) and we have shown that when matter dominates, we had:\n\t\n\tSince then:\n\t\n\tand it comes immediately:\n\t\n\tTherefore:\n\t\n\tIf we move now to the comoving time also named \"\\NewTerm{conformal time}\\index{conformal time}\" (already introduced at the beginning of this section) defined mathematically by (don't forget that $R$ is note a radius but a ratio of two radius!):\n\t\n\tThen we have:\n\t\n\tLet us write that in the form:\n\t\n\twhere $A$ is strictly positive. Let us do the substitution:\n\t\n\tThen we have:\n\t\n\tand we have proved in the section of Differential and Integral Calculus that the primitive is:\n\t\n\tTherefore:\n\t\n\tAs at time $\\eta=0$ we have $R=0$, it is necessary that the constant is such that:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tNow, let us recall that:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tand as we must have at time $t=0$ the comoving time that is also zero, the constant is then zero. Therefore we have the following parametric system in the end (something very strange with this result... it is that we fall back on the parametric equations of the brachistochrone curve\\footnote{See section Classical Mechanics page \\pageref{brachistrochrone}}!!!!):\n\t\n\tHence it is periodic and we assimilated that to a Universe, having a \"Big Bang\", after a given time a \"Big Crunch\" and restarting the process as a \"\\NewTerm{Big Bounce}\\index{Big Bounce}\". The idea is more or less (...) the following:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/big_bounce.jpg}\n\t\t\\caption[Big Bounce artistic illustration]{Big Bounce artistic illustration (source: ?)}\n\t\\end{figure}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that for $\\eta=0$, we have $t=0$ but $R\\neq 1$ and this wrong value results simply because earlier before we have assumed that for $\\eta=0$, $R$ was also equal to zero (but this was obviously an abusive simplification)!\n\t\\end{tcolorbox}\n\tWith Maple 4.00b we then have by comparing the flat Universe dominated by matter (blue), the flat Universe dominated by radiation (red) and finally the positive curvature Universe dominated by matter (green) and putting artificial coefficients to better distinguish the plots:\n\t\n\t\\texttt{>plot([t\\string^(2/3),t\\string^(1/2),[0.5*(t-sin(t)),0.5*(1-cos(t)),t=0..2*Pi]],\\\\\n\tt=0...Pi,0..2.5,color=[blue,red,green]);}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/universe_models_01_maple_plot.jpg}\n\t\t\\caption[]{Evolution of the $R$ factor for the resulting space configurations studied so far with Maple 4.00b}\n\t\\end{figure}\n\t\n\t\\paragraph{Spherical space dominated by radiation}\\mbox{}\\\\\\\\\\\n\tLet us now consider a universe dominated by radiation. We have proved earlier above that in this situation we had:\n\t\n\tand:\n\t\n\tIn this case the Friedmann equation in terms of energy density can be written by putting $k=+1$:\n\t\n\tWhat becomes:\n\t\n\tBy injecting $R^4\\rho_E=R_0^4\\rho_{E,0}$, it comes:\n\t\n\tTherefore:\n\tTherefore:\n\t\n\tLet us write this in the form:\n\t\t\n\tIf we change to the comoving time again:\n\t\n\tThen we have:\n\t\t\n\tIn the section of Differential and Integral Calculus we have proved how to determine exactly the same primitive (because it is a usual primitive). We have:\n\t\n\tFor at time $\\eta=0$ we have $R=0$, it is necessary that the constant is such that:\n\t\n\tHence:\n\t\n\tNow, remember that:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tand as at time $t=0$ the comoving time $\\eta$ is also zero, the constant is therefore equal to $\\sqrt{A}$. Therefore we have finally the following parametric system:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that for $\\eta=0$, we have $t=0$ but $R\\neq 1$ and this wrong value results simply because earlier before we have assumed that for $\\eta=0$, $R$ was also equal to zero (but this was obviously an abusive simplification)!\n\t\\end{tcolorbox}\n\tWith Maple 4.00b we then comparing the flat Universe dominated by matter (blue), the flat Universe dominated by radiation (red), the Universe with positive curvature dominated by matter (green), the Universe with positive curvature dominated by radiation (black):\\\\\n\t\n\t\\texttt{>plot([t\\string^(2/3),t\\string^(1/2),[0.5*(t-sin(t)),0.5*(1-cos(t)),t=0..2*Pi],[0.5*\\\\(1-cos(t)),0.5*sin(t),t=0..2*Pi]],t=0...Pi,0..3,color=[blue,red,green,black]);}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/universe_models_02_maple_plot.jpg}\n\t\t\\caption[]{Evolution of the $R$ factor for the resulting space configurations studied so far with Maple 4.00b}\n\t\\end{figure}\n\t\n\t\\subsubsection{Hyperbolic spaces ($k<0$)}\n\tIn this model, we consider $k<0$. So the equation to be treated can be written:\n\t\n\tWhich is also written:\n\t\n\tLet us recall that we assumed that $t=t_0$ that $F(t_0)=1$. If we make the change of variable $U=1/F(t)$, we get the following integral:\n\t\n\tSo we are looking for a primitive of:\n\t\n\tand we will discuss the sign $\\pm$ after finding the primitive.\n\n\tWe still carry a change of variable by putting:\n\t\n\t therefore:\n\t\n\twhich gives us the following primitive to calculate:\n\t\n\tDoing again a change of variable:\n\t\n\thence to a given multiplicative constant:\n\t\n\tWe have:\n\t\n\tIn the section of Differential and Integral Calculus we saw that this form of primitive is resolved by the relation (we added the constant of integration in the end because we do physics and must satisfy the initial conditions to which we were not interested to in pure mathematics):\n\t\t\n\twith:\n\t\n\thence:\n\t\n\thence:\n\tWe still need to calculate $I_1$:\n\t\n\tFinally:\n\t\n\tby putting back all the changes of variables and introducing the multiplicative constant again, we have therefore in the case $k>0$:\n\t\n\tBetween the two terminals of integration $(1/F,1)$ so we have (the integration constant is zero):\n\t\n\tWe must obviously have (we take back the $\\pm$ which was originally in the integral):\n\t\n\tIf we plot this function for a fixed value $k>0$. We have the following  animated plot Maple in 17.00 for the negative sign (as the positive one has no physical meaning):\n\t\n\t\\texttt{>restart:\\\\\n\t>f:=(A,k,F)->-(((-F(sqrt(A/F+abs(k)))/k+A/2(2*abs(k)\\string^(3/2))*ln(abs(((sqrt(\\\\\n\tabs(k))+sqrt(A/F+abs(k)))/(sqrt(abs(k))-sqrt(A/F+abs(k))))/((sqrt(abs(k))\\\\\n\t+sqrt(A+abs(k)))/(sqrt(abs(k))-sqrt(A+abs(k))))))))):\\\\\n\t>plots:-animate(plot3d,[f(A,k,F),k=0.1..1,F=0..10,],A=0.1..1)\n\t}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/hyperbolic_universe_maple_animation_minus_sign_solution.jpg}\n\t\\end{figure}\n\tWe see that the smallest is the constant $A$ is, the fastest the Universe increases indefinitely quickly. Furthermore for a fixed value of $k$, some values of $A$ are prohibited (it is in fact still the integration condition).\n\n\tAgain we see that the in the equation above the criterion $F(t_0)=F(0)=1$ is naturally fully respected. All values $F (t) $ below $1$ are to be rejected! Hence using again the one of the traditional notation:\n\t\n\tSo we have in this hyperbolic model a Universe that grows indefinitely in an exponential away (as the flat Friedmann-Lemaître model) because since $k<0$, there is no integration condition limit anymore (unlike the previous spherical model).\n\t\n\t\\paragraph{Hyperbolic space dominated by matter}\\mbox{}\\\\\\\\\n\tJust as for the models for flat and spherical space, there is also another approach much more elegant and subtle for my taste than the previous proof (I have also discovered that one many years after writing the previous version). It also has the advantage of highlighting a hypothesis that has not occurred with previous developments and allows to draw more simply in Maple 4.00b the behaviour of the scale factor of the Universe. We thus find exactly the famous plot representing the evolution of the scale factor of the Universe available in almost all popular books on the subject but without proof.\n\n\tWe always start from the first Friedmann equation:\n\t\n\tIt is customary for this model to put $k=-1$ (as we have to choose any negative number at least we pick one that is friendly ...) and we have proved that when the radiation dominates, we had:\n\t\n\tIn this case the Friedmann equation in terms of energy density can be written by putting $k=-1$:\n\t\n\tThe first Friedmann equation then becomes:\n\t\n\tThen we have:\n\t\n\tHence:\n\t\n\tThis is exactly the same integral than that of the spherical Universe dominated by matter at the difference that in the root, we $+1$ instead of $-1$. We will proceed in the same manner using the time comoving time:\n\t\n\tIt comes then:\n\t\n\tLet us write that in the form:\n\t\n\twhere $A$ is strictly positive. Let us make the substitution:\n\t\n\tThen we have:\n\t\n\tUsing the usual primitive proved in the section of Differential and Integral Calculus it comes:\n\tthen we have:\n\t\n\tUsing the usual primitive proved in the section of Differential and Integral Calculus it comes:\n\t\n\tOr redoing the change of variables:\n\t\n\tTherefore:\n\t\n\tSo that at time $\\eta=0$ we have $R=0$ , it is necessary that the constant is such that:\n\t\n\tWhich brings us to that the constant is zero and thus:\n\t\n\tTherefore:\n\t\n\tHence:\n\t\n\tand as:\n\t\n\tWe have:\n\t\n\tWhich gives:\n\t\n\tAs at time $t=0$, we must have $\\eta=0$, it follows that the constant must be zero. So finally, we have:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that for $\\eta=0$, we have $t=0$ but $R\\neq 1$ and this wrong value results simply because earlier before we have assumed that for $\\eta=0$, $R$ was also equal to zero (but this was obviously an abusive simplification)!\n\t\\end{tcolorbox}\n\tWith Maple 4.00b we then have by comparing the flat Universe dominated by matter (blue), the flat Universe dominated by radiation (red), the Universe with positive curvature dominated by matter (green), the Universe with positive curvature dominated by radiation (black), the negatively curved Universe dominated by matter (gray):\n\t\n\t\\texttt{>plot([t\\string^(2/3),t\\string^(1/2),[0.5*(t-sin(t)),0.5*(1-cos(t)),t=0..2*Pi],}\\\\\n\t\\texttt{[0.5*(1-cos(t)),0.5*sin(t),t=0..2*Pi],[0.5*(sinh(t)-t),0.5*(cosh(t)-1)}\n\t\\texttt{,t=0..2*Pi]],t=0...Pi,0..3,color=[blue,red,green,black,gray]);}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/universe_models_03_maple_plot.jpg}\n\t\t\\caption[]{Evolution of the $R$ factor for the resulting space configurations studied so far with Maple 4.00b}\n\t\\end{figure}\n\tWe can therefore observe that for a negative curvature (hyperbolic type), expansion is growing significantly faster than for a flat Universe and this without end.\n\t\n\t\\paragraph{Hyperbolic space dominated by radiation}\\mbox{}\\\\\\\\\n\tLet us now consider a Universe dominated by radiation. We have proved that in this situation we had:\n\t\n\tand:\n\t\n\tThe first Friedmann equation the becomes:\n\t\n\tThen we have:\n\t\n\thence:\n\t\n\tThis is exactly the same integral than that of the spherical universe dominated by matter at the difference that in the root, we have $+1$ instead of $-1$. We will proceed in the same manner using the comoving time:\n\t\n\tIt comes then:\n\t\n\tLet us write this in the form:\n\t\n\twhere $A$ is strictly positive.In the section of Differential and Integral Calculus we have proved how to determine exactly the same primitive (because it is a usual primitive). We have:\n\t\n\tSo that at time $\\eta=0$ we have $R=0$ , it is necessary that the constant is zero. Therefore:\n\t\n\tHence:\n\t\n\tand as:\n\t\n\tWe have:\n\t\n\tWhich gives:\n\t\n\tAs at the time $t=0$, we must have $\\eta=0$, it follows that the constant must be equal to $-\\sqrt{A}$. So finally, we have:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that for $\\eta=0$, we have $t=0$ but $R\\neq 1$ and this wrong value results simply because earlier before we have assumed that for $\\eta=0$, $R$ was also equal to zero (but this was obviously an abusive simplification)!\n\t\\end{tcolorbox}\n\tWith Maple 4.00b we then have by comparing the flat Universe dominated by matter (blue), the flat Universe dominated by radiation (red), the Universe with positive curvature dominated by matter (green), the Universe with positive curvature dominated by radiation (black), the Universe with negative curvature dominated by matter (gray), the negative curvature Universe dominated by radiation (brown):\n\t\n\t\\texttt{>plot([t\\string^(2/3),t\\string^(1/2),[0.5*(t-sin(t)),0.5*(1-cos(t)),t=0..2*Pi],}\\\\\n\t\\texttt{[0.5*(1-cos(t)),0.5*sin(t),t=0..2*Pi],[0.5*(sinh(t)-t),0.5*(cosh(t)-1)}\\\\\n\t\\texttt{t=0..2*Pi],[0.5*(cosh(t)-1),0.5*(sinh(t)),t=0..2*Pi]],t=0...Pi,0..3\n,color=[blue,red,green,black,grey,brown]);}\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/universe_models_04_maple_plot.jpg}\n\t\t\\caption[]{Evolution of the $R$ factor for the resulting space configurations studied so far with Maple 4.00b}\n\t\\end{figure}\n\tWe can therefore observe that for a negative curvature (hyperbolic type), the expansion of a Universe dominated by radiation grows slower than a universe dominated by matter (it's a bit intuitive...).\n\n\tFinally to summarize a little better all this with captions it we get the following important plot (its important to be implicated by this plot as the Universe affects us all ...):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=1]{img/cosmology/summary_newtonian_universe.jpg}\n\t\t\\caption{Summary of Newtonian Universe models}\n\t\\end{figure}\n\t\n\t\\subsection{Observable Universe}\n\tWe have determined previously a possible interpretation of the current estimate of the age (horizon) of our Universe as being as the inverse of the Hubble parameter that has given us for recall the following value (Hubble time):\n\t\n\tand the corresponding radius for the Hubble sphere (radius of the observable observer for which every observer is the center)\n\t\n\tAnd afterwards, under the same strong assumptions\\footnote{Don't forget that we will see further below a method to estimate the comobile diameter using General Relativity!}, we have calculated the comobile diameter:\n\t\n\t\n\tThe illustration below typically depicts the fact that the observable Universe is centered on us (assimilated to our Sun) and that bound of this observable Universe is highly shifted to red.\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.35]{img/cosmology/observable_universe_logarithmic_illustration.jpg}\n\t\t\\caption[Artist's logarithmic scale conception of the observable Universe]{Artist's logarithmic scale conception of the observable Universe (source: Wikipedia, author: ?)}\n\t\\end{figure}\n\t\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} It is important to know that popular research articles in cosmology  often use the term \"Universe\" in the sense of \"observable Universe\".\\\\\n\t\n\t\\textbf{R2.} There should be more rigorous in fact when we speak of the Universe \"age\". In fact, we should rather say that the \"horizon of the Universe\" is $13$ billion years. In other words, it's time that someone would have measure if he has remained an inertial observer (in free fall: not subjected to any force other than gravity) throughout the evolution of the Universe and in a repository such that he would always perceived this Universe as homogeneous and isotropic.\n\t\\end{tcolorbox}\n\tThe word \"observable\" used in this sense does not depend on whether modern technology actually permits detection of radiation from an object in this region (or indeed on whether there is any radiation to detect). It simply indicates that it is possible in principle for light or other signals from the object to reach an observer on Earth. In practice, we can see light only from as far back as the time of photon decoupling in the recombination epoch. That is when particles were first able to emit photons that were not quickly re-absorbed by other particles. Before then, the Universe was filled with a plasma that was opaque to photons. The detection of gravitational waves indicates there is now a possibility of detecting non-light signals from before the recombination epoch.\n\t\n\tAt the beginning of the early 21st century, we do still do not know if the Universe is finite or infinite, although the majority of theorists currently favour an infinite universe.\n\n\tThe observable Universe is thus composed of all locations that could have affected us since the Big Bang (beware!... despite its name, the Big Bang theory has nothing to say on its start! It merely describes the evolution and the expansion of the Universe).\n\n\tThe current size (the \"\\NewTerm{comoving distance}\\index{comoving distance}\") of the observable Universe is larger as we have calculated just earlier before and the corresponding sphere is named the \"\\NewTerm{cosmological sphere}\\index{cosmological sphere}\".\n\n\tThis value can be obtained by taking the actual most distant visible object which is $13.39$ billion years of Earth. This will therefore have needed $13.39$ billion years to get away from us, its light will have needed $13.39$ billion years to reach us and during the time of light travel, it will have move away of $13.39$ billion years (since objects at cosmological horizon are going at the speed of light). Thus a total of about $40$ billion years.\n\t\n\tThis observable Universe contains according to today's heuristics  estimates (year 2011) about $7\\cdot 10^{22}$ stars, distributed in approximately $10^{10}$ galaxies, themselves organized into clusters and super-clusters of galaxies. The number of galaxies may be even larger, as the \"Hubble Ultra-Deep Field\" observed with the Hubble space telescope seems to indicate us. \n\t\n\tThe Hubble Ultra-Deep Field is an image of a region of the observable universe (equivalent sky area size shown in bottom left corner), near the constellation Fornax. Each spot is a galaxy, consisting of billions of stars. The light from the smallest, most red-shifted galaxies originated nearly $14$ billion years ago.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.19]{img/cosmology/hubble_deep_space.jpg}\n\t\t\\caption[Hubble Ultra-Deep field]{Hubble Ultra-Deep field (source: Wikipedia, author: NASA and ESA)}\n\t\\end{figure}\n\tHowever it is difficult to imagine what that represents. As we found on the Internet some wonderful series of illustrations we would like to share them with the reader before the disappear from the Internet.\n\n\tFirst here is a high-resolution summary of various structures you can found at different scales of our Universe (you can considerably zoom in!):\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.09]{img/cosmology/universe_scales.jpg}\n\t\t\\caption[Universe scales]{Universe scales (source: Wikipedia, author: Andrew Z. Colvin)}\n\t\\end{figure}\n\tAnd a more detailed way to discover its structure:\n\t\\begin{enumerate}\n\t\t\\item The universe to $14$ billion light years (the visible Universe as we approximately know it today):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_0.jpg}\n\t\t\t\\caption[Simplified illustration of the observable Universe]{Simplified illustration of the observable Universe (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThis illustration attempts to show the entire visible Universe. The galaxies in the universe tend to collect into vast sheets and \"supercluster\" of galaxies surrounding large vacuums zones, giving the universe a cellular appearance. Because light in the Universe only travel a finite speed, we see objects at the edge of the Universe as when it was very young, there is $14$ billion years ago\n\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of superclusters in the visible universe: $10$ million\n\t\t\t\\item Number of galaxy groups in the visible universe: $25$ billion\n\t\t\t\\item Number of large galaxies in the visible universe: $350$ billion\n\t\t\t\\item Number of dwarf galaxies in the visible universe: $7$ trillion\n\t\t\t\\item Number of stars in the visible universe: $30$ billion trillion  ($3\\cdot 10^{22}$)\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 14$ zoom we get the Universe withing a $1$ billion light years, that is the neighboring superclusters:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_1.jpg}\n\t\t\t\\caption[Simplified illustration of the neighboring superclusters]{Simplified illustration of the neighboring superclusters (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tGalaxies and clusters of galaxies are not distributed uniformly in the Universe. Instead, they gathered in large clusters, sheets and walls of galaxies separated by large gaps in which few galaxies appear to be. The illustration above shows a number of these super-clusters including the Virgo - a rather small super-cluster of which our galaxy is part of. The entire map is approximately $7\\%$ of the diameter of the visible universe. The galaxies are too small to appear individually on this map, each point there is a group of galaxies.\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of super-clusters within $1$ billion light years: $100$\n\t\t\t\\item Number of galaxy groups within $1$ billion light years: $240,000$\n\t\t\t\\item Number of large galaxies within $1$ billion light years: $3$ million\n\t\t\t\\item Number of dwarf galaxies within $1$ billion light years: $60$ million\n\t\t\t\\item Number of stars within $1$ billion light years: $250,000$ trillion\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 10$ zoom we get the Universe within $100$ million light years or the Virgo super-cluster:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_2.jpg}\n\t\t\t\\caption[Simplified illustration of the Virgo supercluster]{Simplified illustration of the Virgo supercluster (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tOur galaxy is just one of thousands that lie within $100$ million light years. The above illustration shows how galaxies tend to gather in groups, the largest nearby cluster is the Virgo cluster (Virgo), a concentration of several hundred galaxies which dominates the surrounding groups of galaxies. Collectively, all of these groups is known to supercluster Virgo. The second richest cluster in this volume is the Fornax cluster (Fornax), but it is as rich as that of the Virgin. Only bright galaxies are drawn here, our galaxy is the point at center.\t\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of galaxy groups within $100$ million light years: $200$\n\t\t\t\\item Number of large galaxies within $100$ million light years: $2,500$\n\t\t\t\\item Number of dwarf galaxies within $100$ million light years: $50,000$\n\t\t\t\\item Number of stars within $100$ million light years: $200$ trillion\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 20$ zoom we get the Universe within $5$ million Light Years, that is the Local Group of Galaxies:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_3.jpg}\n\t\t\t\\caption[Simplified illustration of our Local Group]{Simplified illustration of our Local Group (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThe Milky Way is one of three large galaxies in the group named \"\\NewTerm{Local Group}\\index{local group}\" which also contains several dozen of dwarf galaxies. Most of these galaxies are plotted on the illustration above, but note that many of these dwarf galaxies a very small magnitude, so that there are certainly more to discover.\t\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of large galaxies within $5$ million light years: $3$\n\t\t\t\\item Number of dwarf galaxies within $5$ million light years: $46$\n\t\t\t\\item Number of stars within $5$ million light years: $700$ billion\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 10$ zoom we get the Universe within $500,000$ light years, that is the Satellite Galaxies:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_4.jpg}\n\t\t\t\\caption[Simplified illustration of Satellite Galaxies]{Simplified illustration of Satellite Galaxies (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThe Milky Way is surrounded by several dwarf galaxies, each containing tens of millions of stars, which is insignificant compared to the population of the Milky Way itself. The map above shows all of the nearest dwarf galaxies that are gravitationally bound to the Milky Way, and revolve around it in a few billion years.\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of large galaxies within $500,000$ light years: $1$\n\t\t\t\\item Number of dwarf galaxies within $500,000$ light years: $12$\n\t\t\t\\item Number of stars within $500,000$ light years: $225$ billion billion\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 10$ zoom we get the Universe within $50,000$ light years, that is the Milky Way Galaxy:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_5.jpg}\n\t\t\t\\caption[Simplified illustration of the Milky Way Galaxy]{Simplified illustration of the Milky Way Galaxy (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThis map shows the Milky Way as a whole - a spiral galaxy of at least two hundred billion stars. Our Sun is buried deep within the Orion Arm about $26,000$ light years from the center. Toward the center of the galaxy, stars are much closer to each other than at the periphery where we live. Also notice the presence of small globular clusters far outside the galactic plane, and the presence of a neighbouring dwarf galaxy - named \"Sagittarius\" - which is slowly being swallowed by our own Galaxy.\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of stars within $50,000$ light years: $200$ billion billion\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 10$ zoom we get the Universe within $5,000$ light years, that is to say the Orion Arm:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_6.jpg}\n\t\t\t\\caption[Simplified illustration of the Orion Arm]{Simplified illustration of the Orion Arm (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThis is a map of our corner of the Milky Way. The Sun is located in the Orion Arm - a fairly small arms compared to the Sagittarius Arm, which is closer to the galactic center. The map shows several stars visible to the naked eye, located far away in the Orion arm. The most notable group of stars is composed of the main stars of the constellation of Orion - from which the spiral arm gets its name. All these stars are bright giant and supergiant stars, thousands of times more luminous than the Sun. The brightest star of the map is Rho Cassiopeia - to $4,000$ light-years from us is just barely visible to the naked eye star, but in reality it is a supergiant $100,000$ times brighter than our Sun.\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of stars within $5,000$ light years: $600$ million\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 20$ zoom we get the Universe within $250$ light years, that is to say the solar neighbourhood:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_7.jpg}\n\t\t\t\\caption[Simplified illustration of the solar neighbourhood]{Simplified illustration of the solar neighbourhood (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThis map shows the $1,500$ most luminous stars within $250$ light years. All these stars are much more luminous than the Sun, and most are visible to the naked eye. About a third of the stars visible to the naked eye are within $250$ light years, even though that area represents only a small part of our galaxy.\n\t\t\n\t\tSome numbers (estimates):\n\t\t\\begin{itemize}\n\t\t\t\\item Number of stars within $250$ light years: $260,000$\n\t\t\\end{itemize}\n\t\t\n\t\t\\item After a $\\times 20$ zoom we get the Universe within $12.5$ light years (the nearest stars):\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_8.jpg}\n\t\t\t\\caption[Simplified illustration of the nearest stars]{Simplified illustration of the nearest stars (source: \\url{http://atunivers.free.fr}, author: Richard Powell)}\n\t\t\\end{figure}\n\t\tThis map shows some stars up to a distance of $12.5$ light years from our Sun (there would be $33$ identified to this date). Most of these stars are red dwarfs - stars with a tenth of the mass of the Sun and a hundred times less bright. About $80\\%$ of stars in the Universe are red dwarfs, and the nearest star - Proxima Centaure - is a typical example.\n\t\t\n\t\tThe map below show all known stars within $20$ light years. There are a total of $77$ systems containing $110$ stars:\n\t\t\\begin{figure}[H]\n\t\t\t\\centering\n\t\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_9.jpg}\n\t\t\\end{figure}\n\t\tThe distances between stars are huge. The distance from the Sun to Proxima Centauri is $4.22$ light years, or $40$ trillion kilometres. Walk this distance would take a billion years. Even the fastest space probes in this early 21st would need $6,000$ years to make the trip. There are currently four probes leaving the solar system - Pioneer 10 and 11 and Voyager 1 and 2 but we will likely lose contact with them within the next two years (if it's not already done when the reader see these lines). The following diagram attempts to show these distances by broadening the scope from the inner solar system to Alpha Centauri:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.75]{img/cosmology/universe_zoom_10.jpg}\n\t\t\\end{figure}\n\t\\end{enumerate}\n\tAnd also a beautiful infographics from National Geographic:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/universe_map.jpg}\n\t\t\\caption[Universe Map]{Universe Map (source: National Geographic)}\n\t\\end{figure}\n\tAnd finally an artist's logarithmic scale conception of the observable universe with the Solar System at the center, inner and outer planets, Kuiper belt, Oort cloud, Alpha Centauri, Perseus Arm, Milky Way galaxy, Andromeda galaxy, nearby galaxies, Cosmic Web, Cosmic microwave radiation and the Big Bang's invisible plasma on the edge.\n\t\n\t\n\t\\pagebreak\n\t\\subsection{Cosmic Microwave Background (CMB)}\\label{cosmic microwave background}\n\tWe have already mention the cosmic microwave background earlier above and we have given numerous illustrations of it and the corresponding satellites names and observations related to its experimental study. But let us now give a more detailed picture of cosmic microwave background to show to the reader that the latter is isotropic to a high degree. \n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.65]{img/cosmology/cmb.jpg}\n\t\t\\caption[Cosmic microwave background according to WMAP $5$-year results]{Cosmic microwave background according to WMAP $5$-year results (source: NASA/WMAP Science Team)}\n\t\\end{figure}\n\tThis tells us that the early Universe was rather homogeneous at the decoupling time the CMB was formed.\n\t\n\tThe purpose now here is to have a mathematical approach of the  cosmic microwave background.\n\t\n\t\\subsubsection{Decoupling time}\\label{decoupling time}\n\tThe existence and properties of the cosmic radiation discovered experimentally by Arno Penzias and Robert Woodrow Wilson in 1964 but theoretically by Ralph Apher  in 1948 were mainly due to the two physical phenomena that we will now describe in broad outline.\n\n\tThe expansion of the Universe has for consequence in its gradual cooling. From the fantastically high values that have reigned immediately after the Big Bang that created the Universe, the temperature gradually decreased. When it reaches about $3,000$ [K] occurs the first of two crucial phenomena that interest us here: the radiation, which until then was in thermal equilibrium with the material particles practically ceases to interact with them and became independent. In the \"standard model\" of evolution of the Universe, we calculate that this crucial moment is situated $300,000$ years after the Big Bang (see the proofs further below).\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.35]{img/cosmology/planck_history_of_universe.jpg}\n\t\t\\caption[2D illustration of (speculated) Universe past history following 21st century hypothesis]{2D illustration of (speculated) Universe past history following 21st century hypothesis (source: ESA)}\n\t\\end{figure}\n\tWe can first qualitatively understand the physical reasons for this (further below we will approach this with maths stuff!). Shortly before, when for example the temperature was $100,000$ [K], the Universe contained mostly photons, electrons and bare atomic nuclei (mostly protons, and, to a lesser extent, $\\alpha$ particles, helium $4$ nuclei). The temperature was too high so that the electrons and nuclei may form stable atoms. The interaction between the photons and charged particles (mainly electrons, the lighter of them) is sufficiently intense, and the density of the latter was then sufficiently strong, so that the photons were continuously diffused, transmitted and absorbed . Despite its expansion, the Universe was at every moment at equilibrium; its temperature $T$ was consistently well defined, although decreasing over time, the photon energy, that is to say the pulse of radiation, was therefore distributed according to Planck's law for this temperature $T$ (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}})!\n\t\n\tThe temperature decrease then permit the formation of atoms from the electrons and nuclei. This process led to a rapid drop in average cross section of interaction between photons and material particles (mainly due to the disappearance of free electrons), so that the Universe became transparent to photons. A quantitative assessment of the characteristics of the phenomenon is this decoupling occurred when the temperature dropped to $3,000$ [K] (see the simple mathematical approach further below).\n\n\tAt the moment of decoupling, the volume density of the radiation energy is distributed in the pulsations spectrum according to Planck's law (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}}):\n\t\n\twhere we assume that $T$ is the temperature ($3,000$ [K] approximately - ionization temperature of the simplest atoms\\footnote{we will see further the detail treatment of where this value comes from.}) at the moment of decoupling. This distribution will then evolve under the influence of the expansion of the Universe.\n\n\tLet us consider the photons located at time $t$ in the volume $4/3r^3\\cong r^3$, and whose pulsation $\\omega$ with a variation $\\mathrm{d}\\omega$. Their number is then using previous relation equal to:\n\t\n\twhere we assume that $T$ is the temperature ($3,000$ [K] approximately - ionization temperature of the simplest atoms) at the moment of decoupling. This distribution will then evolve under the influence of the expansion of the Universe.\n\t\n\tAs there is no absorption or emission of photons at this temperature (it is a hypothesis but as experimental measurements seem to confirm this model...), this number will remain constant. But because of the expansion of the Universe, these photons constant number will occupy a larger volume, and gain greater wavelength $\\lambda$ (following the expansion of the structure of space due to the positive value of the Hubble parameter) that is to say, a rather smaller pulsation $\\omega$ (the equivalent of the Doppler effect). To clarify, let consider the situation at time a further time $t'$. All lengths of the Universe have increased between, between $t$ and $t'$, by the same scaling factor $F$ following the Hubble's law: the chosen radius $r$ of our previous selected sphere volume has become obviously:\n\t\n\tand the wavelength of the photons considered:\n\t\n\tso that their pulsation is equal at the instant $t'$ to:\n\t\n\tSo the energy contained at this time in the volume $V\\cong {r'}^3$ and in the pulsation range $(\\omega',\\omega'+\\mathrm{d}\\omega')$ that is given obviously by:\n\t\n\tis given by:\n\t\n\tThe volumetric energy density $R'(\\omega',T')\\mathrm{d}\\omega'$ at time $t'$, for the pulsation range $(\\omega',\\omega'+\\mathrm{d}\\omega')$, is then written:\n\t\n\tIt follows that the spectral energy distribution is still at the instant $t'$ that of the black-body:\n\t\n\twhere the corresponding temperature $T'$ is immediately such that:\n\t\n\tthat is more often written:\n\t\n\tThus, after decoupling with matter, the cosmic radiation evolves maintaining the distribution of a black-body whose temperature decreases regularly in the same proportion as the distances are increased during the expansion of the Universe.\n\n\tFrom the moment of decoupling, the $F$ factor of scale is very close to $1,000$ since from to the estimated $3,000$ [K] to go to the $2.7$ [K] measured today there is a factor of:\n\t\n\talso named \"\\NewTerm{recombination redshift}\\index{redshift!recombination redshift}\".\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.8]{img/cosmology/cmb_various_resolutions.jpg}\n\t\t\\caption[]{Radiation is isotropic to $10^{-5}$ in temperature}\n\t\\end{figure}\n\t\n\t This value of approximately $1,000$ allows us from the Friedmann-Lemaître model we have introduced earlier above to easily calculate at what time (horizon) of the Universe this decoupling occurred.\n\t \n\t If we consider a radiation dominate flat Universe we have proved roughly that the scale factor $R(t)$ was proportional to the $t^{2/3}$:\n\t\n\tSo clearly we have the age ratio on:\n\t\n\tThat is:\n\t\n\tSo to get the age of the universe at $z=1100$ we would therefore have to divide the age now, by the factor $36482$. This gives:\n\t\n\tOr more generally:\n\t\n\t Thus we find a value of approximately $380,000$ years. This is according to what most textbooks gives without proof.\n\t \n\tLet us focus now on a special and important needed value for the next sub-section (recombination temperature)!\n\t\n\tThe energy density associated with the blackbody radiation of temperature $T$ is as we know given by the Stefan-Boltzmann law (\\SeeChapter{see section Thermodynamics page \\pageref{stefan boltzmann law}}):\n\t\n\tand the mean energy per photon is given by $\\sim kT$. Therefore, the number density of blackbody photons for $T=2.7$ [K] is given by: \n\t\n\tThe number density of baryons can be expressed by $\\rho_{m} / m_{p}$, where $\\rho_m$ is the mass density of the observed Universe and $m_p$ is the mass of the proton $\\left(1.66 \\cdot 10^{-24} [\\mathrm{g}]\\right)$ . CMB measurements show that the baryonic mean density is $\\rho_{m}\\cong 4.2 \\cdot 10^{-31} [\\text{g} \\cdot\\text{cm}^{-3}]$ (roughly $5\\%$ of the critical density). This leads to the value of $\\sim 2 \\cdot 10^{-7}$ for the number density of baryons.\n\t\n\tThen we have the photon to baryon\\footnote{A baryon is a composite subatomic particle made up of three quarks (a triquark, as distinct from mesons, which are composed of one quark and one antiquark). Baryons and mesons belong to the hadron family of particles, which are the quark-based particles.} ratio\\label{photon to baryon ratio}\\index{photon to baryon ratio} (that is sometimes defined as the opposite ratio depending on the textbook...):\n\t\n\tIn other words, for each baryon in the Universe there is $10^{10}$ photons. This estimate is in agreement with the precise value of the photon to baryon ratio $1.64 \\times 10^{9}$ derived with the WMAP. Since the photon number and the baryon number seems to be conserved, the photon-baryon ratio stays constant as the Universe expands.\n\t\n\tThe Planck satellite $95\\%$ confidence interval (year 2017) for $\\eta$ is given by:\n\t\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe photon to baryon ratio is estimated and measured. It's partially measured/estimated from the observation of the numbers and average sizes of galaxies and stars, and the density of interstellar matter, and some other baryon if matter. The number density of photons is very well estimated, at about $413$ photons per $\\text{cm}^3$.\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Matter/Photon decoupling (recombination temperature)}\\label{Cosmological Microwave Background decoupling}\n\tNow let us see how we can get an approximation of the famous $3,000$ [K] that we see in almost all textbooks for the recombination temperature!\n\t\n\tAs we have seen above, the early universe may have been hot. So hot maybe that nuclei boiled. The great thermal energy of the universe overwhelmed the confining efforts of the nuclear and electromagnetic forces, and droves of fundamental particles—quarks, gluons, leptons, photons—bounced and jostled in a tightly-coupled plasma. The Universe, however, has a built-in cooling mechanism: expansion. Matter particles dilute and photon wavelengths stretch as the universe expands in a process called redshift. Soon, protons and neutrons condense out of the plasma as the strong force overcomes the waning thermal wanderings of quarks and gluons. Over the next ten minutes, these nucleons join to form nuclei of deuterium, helium, and other light elements. The protons and nuclei, however, are naked - it's still too hot for electrons to join them in the formation of neutral atoms. The universe will remain in this ionized state for the next few hundred thousand years\\footnote{The text that will follow is based on the work of Brian Powell PhD Physics. Who kindly answered to our questions and authorized us to reproduce his work and improve it. Original text may be found here \\url{https://www.physicsforums.com/insights/poor-mans-cmb-primer-part-1-birth-cosmic-background-radiation/}}.\n\t\n\tThe thing about ionized plasma, is that photons have a hard time getting around: there is no shortage of charged particles ready for a collision. The average distance travelled by a photon before collisions is the mean free path (\\SeeChapter{see section Continuum Mechanics page \\pageref{mean free path}}):\n\t\n\tdetermined by the number density of the charge-carriers, $n$, and the scattering cross-section, $\\sigma$. To get a feel for just how waded up everything was maybe in the early Universe, let's find the mean free path of photons when the universe was one second old, at a torrid $T=10^{10}$ [K]. This is the epoch of said of \"nucleosynthesis\", when protons and neutrons are supposed to fused to form the light nuclei. Though we are technically in the realm of Compton scattering (\\SeeChapter{see section Atomistic page \\pageref{compton scattering}}), $T>m_e$, the Thomson scattering cross-section (\\SeeChapter{see section Atomistic page \\pageref{Thomson scattering}}) will suffice for an order-of-magnitude estimate: $\\sigma_T\\cong 6.652\\cdot 10^{-29}\\;[\\text{m}^2]$, where $\\sigma_T$ for reminder is proportional to $e^4/m_e^4$. As for the charge-carrier density, we can safely ignore everything except the electrons: though the supposed charge neutrality of the universe requires that the densities of free electrons and protons balance, $n_e=n_p$, scattering off the much heavier protons is suppressed by a factor of a million relative to electrons (owing to the factor $1/m_e^4$ in $\\sigma_T$)\\footnote{And the even heavier and more dilute deuterium, helium, and lithium nuclei can be likewise ignored.}\n\t\n\tIt's safe to treat the electrons as radiation (they are still quite hot, about the temperature of a supernova). To get the number density, we need to integrate the Fermi-Dirac distribution function (\\SeeChapter{see section Statistical Mechanics page \\pageref{fermi dirac distribution}}):\n\t\n\tover the full phase space in the relativistic limit, ($T\\gg \\mu,m$). For this we will use a similar approach to that we used during our study of semi-conductors that had lead us to (see page \\pageref{non degenerated statistic density of negative electric charge carriers}):\n\t\n\tBut however with an important difference. Instead of taking:\n\t\n\tas we did for the semi-conductor. We take now:\n\t\n\tWhat lead us to (still see page \\pageref{non degenerated statistic density of negative electric charge carriers}):\n\t\n\tAnd therefore:\n\t\n\tAnd if $E\\gg m_e$ then:\n\t\n\tHence the above integral becomes (changing to lower boundary to the case that concerns us here):\n\t\n\tand in the approximation $T\\gg \\mu,m$:\n\t\n\tIntegral that can be found in some textbooks in natural units. Therefore:\n\t\n\tBack S.I. units that lead us finally to:\n\t\n\twhere $g_e=2$ is the fermion degeneracy.\n\t\n\tThe integral:\n\t\n\tcan be solved via geometric series expansion and some low-level tricks. First, substitute $x=E/kT$ giving:\n\t\n\tThe idea is to use the binomial theorem for negative integer exponents (\\SeeChapter{see section Calculus page \\pageref{binomial theorem for negative integer exponents}}) involving the exponential:\n\t\n\tAfter another change of variables, $y=(k+1)x$:\n\t\n\tThe keen eye might recognize $\\int\\limits_0^{+\\infty} y^2e^{-y}\\mathrm{d}y$ as the gamma function (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{gamma euler function}}), $\\Gamma(3)=(3-1)!=2$. This, together with a slight nudge to the bottom limit of the summation we can rewrite things as:\n\t\n\tTo get rid of the annoying $(-1)^k$ term, we break the summation up into an even and an odd part, and then rework things to get two full summations back:\n\t\n\tAfter the dust settles, we see that two copies of the Riemann zeta function have emerged, $\\zeta(3) = \\sum_k 1/k^3$ (\\SeeChapter{see section Sequences and Series page \\pageref{zeta function}}), allowing us to write:\n\t\n\tTherefore:\n\t\n\twhere $\\zeta(3)\\cong 1.2$ is the Riemann zeta function of $3$. The mean free path is found after plug-in all numerical values to (remember that we take $T=10^{10}$ [K]):\n\t\n\t or about the size of a typical virus. So, yeah: tiny. The Universe is effectively opaque!\n\t\n\tAs the Universe continues to cool we eventually expect neutral hydrogen to form and the free charge-carrier density to decline rapidly in a process confusingly called recombination (there's nothing \"re-\" about it).Naively, we might expect this transition to occur as the universe cools through $T=10^5$ [K], which corresponds dimensionally to the ionization energy of hydrogen, $E=13.6$ [eV]. \n\t\n\tIndeed, if we consider that the first atoms absorbing photons and avoiding the transparency of the Universe were Hydrogen atoms. As electrons \"orbiting\" the hydrogen proton never had by assumption the time to \"relax\" (reached their fundamental state) because of the density of the early Universe we can assume that all absorbed photons were for electrons between the first and second main quantum number. But as we have proved in the section of Corpuscular Quantum Physics:\n\t\n\tand for Hydrogen:\n\t\n\tSo that's where the $13.605\\;[\\text{eV}]$ comes from!\n\t\n\tAt this energy the reaction $p\\, +\\, e^{-}\\longleftrightarrow \\mathrm{H}\\, +\\, \\gamma$ should begin to fall out of chemical equilibrium because background photons won't be able to re-ionize the newly formed hydrogen.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/recombination.jpg}\n\t\t\\caption{Big Bang recombination}\n\t\\end{figure}\t\n\tWith enough electrons locked away in hydrogen atoms, photons will propagate relatively unimpeded across the cosmos. This event, the corollary of recombination called decoupling, is important because these are the very photons that make up today's cosmic microwave background. Let us see if this is indeed what happens by finding the photon mean free path when the Universe has cooled down below $13.6$ [eV] to a tepid $1$ [eV], corresponding to a temperature of roughly $T=10^4$ [K] (around the temperature of a white dwarf, or a really hot habanero). At these temperatures the electrons are no longer relativistic (since $T \\ll m_e$) and so the number density assumes the classical Boltzmann (\\SeeChapter{see section Electrokinetics page \\pageref{maxwell-boltzmann density states}}) form:\n\t\n\tThat we will rewrite here:\n\t\n\tIndeed, as photons do not interact with each other, hence they can not achieve a thermodynamic equilibrium by themselves, therefore their chemical potential is zero.\n\t\n\tAgain... the reader may often found this relation in natural units in some textbooks leading to:\n\t\n\tHowever we can't solve $n_e$ directly because we don't know $\\mu_e(T)$ in general. So the idea is to use the Saha ionization equation (\\SeeChapter{see section Continuum Mechanics page \\pageref{Saha ionization equation}}):\n\t\n\twhere for recall $x_{e}=n_{e} / n_{b}$ is the ionization fraction, $B$ the ionization of the first level of Hydrogen atom $B= 13.6$ [eV] and where we know (assuming equal charge density) that the photon to baryon ratio is given by $\\eta=n_\\gamma/n_b\\cong 1.85\\cdot 10^{9}$ with $n_\\gamma\\cong 370\\cdot 10^{6}$ photons by cubic meter and $n_b\\cong 0.2$ baryons by cubic meter.\n\t\n\tSo we found at $T=10^4$ [K] after putting all numerical values in the previous relation :\n\t\n\tand solving for $n_e$ (keeping only the positive solution):\n\t\n\tThe mean free path is found after plug-in all numerical values to $\\lambda_\\gamma=(n_e\\sigma_T)^{-1}\\cong 4.07\\cdot 10^{19}$ [m] or around $1,300$ parsecs. That's quite a distance—significantly longer than the mean free path during nucleosynthesis—but still only a sliver of the observable universe at that time. Hardly \\og across the cosmos \\fg{}. Apparently the universe is still quite ionized even at $E=1$ [eV]. What's going on?\n\t\n\tFor one, there are hugely many more photons than charge-carriers per unit volume. The hugeness of this disparity is the result of the tiny and mysterious matter-antimatter asymmetry in the early universe: most of the matter and all of the antimatter annihilated to create a glut of photons, leaving only a tiny residual matter density. All told, there are roughly 10 billion photons for every electron in the universe. With so many more photons than electrons, even at $T=10^{4}$ [K] there were enough photons all they way out in the ultraviolet tail of the blackbody spectrum with energies greater than $13.6$ [eV] to keep hydrogen relatively well-ionized. To find out just how many let us recall that he have seen during our derivation of the Planck's law (\\SeeChapter{see section Thermodynamics page \\pageref{planck law}}), that:\n\t\n\tAnd therefore the photons cubic density in our case is given by:\n\t\n\tBy multiplying by $h^3/h^3$, we get:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn natural units the latter relation can be found in the following form in some textbooks:\n\t\n\t\\end{tcolorbox}\n\tSadly it seems that this definite integral has no analytical expression. So we will have to compute numerically. As actual softwares can't deal with such small values (because $13.6$ [eV] is equal to $2.17896\\cdot 10^{-18}$ [J]) we will need to do a change of variable. We put $u=E/(kT)$ that lead us to:\n\t\n\tIn a mathematical computing software like Maple, this lead us to:\n\t\n\tResult to compare with the $n_{e} \\cong 370\\cdot 10^{6}\\;[\\text{electrons}\\cdot \\text{m}^{-3}]$ (at the same temperature of  $T=10^{4}$ [K]) determined above. Then there are around one millions photons with an energy greater than $E=13.6$ [eV] for every electron! This means that for every neutral hydrogen atom that forms, there are schools of high-energy photons available to re-ionize it.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/cmb_matter_photon_decoupling_photon_distribution.jpg}\n\t\\end{figure}\n\t So then when does recombination happen? To find out, we'll need to do a more careful accounting of the electron and baryon number densities. In particular, we're going to track the ionization fraction, $x_{e}=n_{e} / n_{b},$ where the baryon density includes the protons and neutral hydrogen, $n_{b}=n_{p}+n_{\\mathrm{H}}$. We assume that the electrons, baryons, and photons are all in thermal equilibrium, which is true so long as the reaction $p+e \\rightleftharpoons \\mathrm{H}+\\gamma$ proceeds rapidly relative to the expansion rate of the universe. In equilibrium, the chemical potentials balance $\\mu_{e}+\\mu_{p}=\\mu_{\\mathrm{H}}$ : this condition is our starting point. We know from our earlier results that we are well inside the non-relativistic regime when recombination finally does happen, so all equilibrium abundances have the Boltzmann form. Writing the condition $\\mu_{e}+\\mu_{p}=\\mu_\\mathrm{H}$ in terms of $n_{e}, n_{p},$ and $n_\\mathrm{H}$ gives as proved during our study of the Saha Equation (\\SeeChapter{see section Continuum Mechanics page \\pageref{Saha ionization equation}}):\n\t\n\twith:\n\t\n\tThe last integral can also be solved via geometric series expansion and some low-level tricks. The idea is again to use the binomial theorem for negative integer exponents (\\SeeChapter{see section Calculus page \\pageref{binomial theorem for negative integer exponents}}) involving the exponential:\n\t\n\tAfter another change of variables, $y=(k+1)x$:\n\t\n\tThe keen eye might recognize $\\int\\limits_0^{+\\infty} y^2e^{-y}\\mathrm{d}y$ as the gamma function (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{gamma euler function}}), $\\Gamma(3)=(3-1)!=2$. This, together with a slight nudge to the bottom limit of the summation we can rewrite things as:\n\t\n\tNow notice that:\n\t\n\tThus:\n\t\n\tTherefore:\n\t\n\tSo finally:\n\t\n\tHence:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe above relation can be found in natural units in some textbooks as following:\n\t\n\tor inverted:\n\t\n\t\\end{tcolorbox}\n\tKnowing that the actual measured baryon to photon ratio is equal to $\\eta\\cong 1.85 \\cdot 10^{9}$, then for example at $T= 4,000$ [K] ($\\approx 0.33$ [eV] a full two orders of magnitude below the hydrogen binding energy), we get:\n\t \n\tTherefore solving for $x_e$ we get $x_e\\cong 87.88\\%$.\n\t\n\tIt may strike the reader as curious that recombination happens at all. Think about it: even without hordes of hot, ionizing photons flying around, a single recombination directly to the ground state releases a photon with an energy $E>13.6$ [eV]. Unless the plasma density is sufficiently low (it isn't), these photons will readily re-ionize any neutral hydrogen atoms they happen upon. In fact, any recombination-even those to excited states of hydrogen-release photons capable of re-ionizing other neutral hydrogen atoms in the same excited state. Evidently, recombination must proceed via very particular transitions through the excited states of hydrogen; for example, the decay from $2s$ to $1s$ proceeds via the emission of two photons, neither of which\nhas sufficient energy to excite hydrogen out of the ground state. The other pathway is through Lyman $\\alpha$ decay (a $10.2$ [eV] photon from $2p$ to $1s$ ): while absorption of a Lyman $\\alpha$ photon will excite neutral hydrogen to a readily-ionizable state (a mere $3.5$ [eV] away), as the hydrogen density decreases with the expansion the Lyman $\\alpha$ photon redshifts just enough to render it harmless. These transitions work; the problem is that they are slow, and they get slower as the ionization fraction falls. Recall that thermal equilibrium is maintained when reactions proceed at a faster rate than the expansion. As recombination proceeds and the ionization fraction falls, these key transitions to the hydrogen ground state are too slow to maintain equilibrium and are therefore no longer adequately described by the Saha Equation. As a result, the Saha Equation predicts a more rapid recombination process than actually occurs through these slow, out-of-equilibrium decays. It is possible to do a proper job of this, taking into account out-of-equilibrium interactions involving the excited states of hydrogen. The Saha Equation is sufficient for our purposes -it illustrates the physics and gives an order of magnitude estimate of the temperature of recombination.\n\n\tPutting this all together, we revisit the photon mean free path. With $n_{e}=x_{e} n_{b}=x_{e}n_{\\gamma}/\\eta$ giving:\n\t\n\tWe can observe the mean free path of the photon grow as the formation of neutral hydrogen really gets going in the below figure where $\\lambda_{\\gamma}$ is the mean free path (solid line), $x_{e}$  ionization fraction (dashed line), vs temperature:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\textwidth]{img/cosmology/cmb_matter_photon_decoupling_photon.jpg}\n\t\t\\caption{Ionization factor and mean free path in function of temperature}\n\t\\end{figure}\n\t Photons traverse the whole of the visible universe unimpeded only when the ionization fraction has dropped below $x_{e}<0.01$. These are the CMB photons.\nOnly when the universe is mostly hydrogen-99 hydrogen atoms for every electron-does it become effectively transparent to photons. These photons, ladies and gentleman, are the cosmic background radiation: the CMB is born!\n\t\n\tObviously this result (as most results in this book) is just an approximation, but not a bad one. It's an approximation because it is a simplification of what is actually going on. In 1968, Jim Peebles (who had done the work in the 1965 Dicke etal. paper) and, independently, Yakov Zel’dovich (of the Sunyaev-Zel’dovich effect) in the USSR, worked out a more complete theory where the hydrogen has three energy levels, rather than what we have done here where we assume the free electrons go straight into the ground-state (i.e. only two energy levels). Their third level was the $n=2$ state, the energy level just above the ground state. This is an important energy level for hydrogen, as it is transitions down to the $n=2$ level which give rise to visible-light photons. Using this more complicated $3$-level model gives a Universe which is $90\\%$ neutral at a a temperature of $T=3000$ [K], which is why this temperature is most often quoted.\n\t\n\t\\subsubsection{Background radiation temperature}\n\tWe have determined all lot of relations so far. Let us take now back the first Friedmann equation:\n\t\n\tand the Universe fluid equation:\n\t\n\tNow for flat space we have $k=0$ so the first Friedmann equation becomes:\n\t\n\tand as now we are interested by the radiation, we will not focus on mass density but rather on radiation (energy) density. Then that latter will be written:\n\t\n\tBut we have also proved during our study of the flat Universe dominated by radiation that:\n\t\n\tThen changing the notation and rearranging, we get:\n\t\n\tFilling that latter relation inside:\n\t\n\tgives immediately:\n\t\n\tWe write $\\dot{\\rho}_E=\\mathrm{d}\\rho_E/\\mathrm{d}t$ and integrate the previous relation (obviously such an integration is a non-sense but the idea is to have a first approach!):\n\t\n\tThis gives:\n\t\n\tNow we square, rearrange:\n\t\n\tWe also know the Stefan-Boltzmann law (\\SeeChapter{see section Thermodynamics page \\pageref{stefan boltzmann law}}):\n\t\n\tTherefore equating both relations:\n\t\n\tAfter rearranging we then have for a flat Universe dominated by radiation that is given by:\n\t\n\tSo when it comes to the observable age of the Universe $t_H\\cong 13\\cdot 10^9$, this will give:\n\t\n\tTo compare with the $2.728$ [K] observed today there is a huge difference. But whatever this give us the information that the Universe should have a quite cold background radiation and experimentation confirms this!\n\t\n\tNow according to Wien's second law we have (\\SeeChapter{see section Thermodynamics page \\pageref{wien displacement law}}):\n\t\n\tTo compare with the $282$ [GHz] measured actually... So we are indeed in the range of the microwave. Hence the word \"microwave\" in the CMB...\n\t\n\t\\pagebreak\n\t\\subsection{Friedmann-Lemaître-Robertson-Walker Cosmological Models}\\label{Friedmann-Lemaître-Robertson-Walker Cosmological Models}\n\tOk... We have seen a lot of stuff and all this without involving General Relativity! Let us see now a more robust way to derivate a more complete version of Friedmann equations using a special metric AND General Relativity. The result will be what we name the \"\\NewTerm{standard cosmological model}\\index{standard cosmological model}\" or the \"\\NewTerm{$\\Lambda$CDM}\"\\index{$\\Lambda$CDM} (Lambda cold dark matter) or \"\\NewTerm{Lambda-CDM model}\\index{Lambda-CDM model}\" that is a parametrization of the Big Bang cosmological model in which the Universe contains the cosmological constant $\\Lambda$, associated with dark energy, and cold dark matter.\n\t\n\t\\subsubsection{Robertson-Walker metric}\n\tWe will now introduce an important metric for General Relativity and Cosmology that is the \"\\NewTerm{Friedmann–Lemaître–Robertson–Walker (FLRW) metric}\\index{Friedmann–Lemaître–Robertson–Walker metric}\\index{Friedmann–Lemaître–Robertson-Walker metric}\\index{Robertson-Walker metric}\". This metric is the basis of the Einstein cosmological model!\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tContrary to a popular misconception, and as already mentioned in the Chronology section of this book (see page \\pageref{chronology}), it was not Georges Lemaître who first developed a dynamic model of a Universe with a beginning in his 1927 publication \\cite{lemaitre1927univers} but Alexander Friedmann in his 1922 publication \\cite{friedman1922krummung} (and Lemaître nor Friedman created the expression \"Big Bang\" but the astronomer Fred Hoyle in 1949). Lemaître just rediscovered independently what Friedman already published before him but backed it up by a possible observational evidence trick! The fact that most people retain Georges Lemaître is mainly for two reasons: the first one is that he was a catholic priest and therefore it adds some spice to the legend (...) and the second is that Einstein knew already the paper of Friedmann but was hesitating and started really to change his mind about a static Universe when he saw that even a second scientist was able to fall back on the result of a dynamic Universe. For more, see \\cite{frenkel1994einstein} and \\cite{nussbaumer2014einstein}.\n\t\\end{tcolorbox}\n\t\n\tTo see how we derive this metric with first consider the elementary distance on a $2$D hypersurface:\n\t\n\ton if the $2$D hypersurface is a sphere, we have:\n\t\n\tFor that latter relation if $R=c^{te}$ we have:\n\t\n\tAfter simplification:\n\t\n\tTherefore:\n\t\n\tWe see that if $R\\rightarrow +\\infty$, then:\n\t\n\tNow let us consider a $3$D hypersurface in a $4$D space such that:\n\t\n\tThe trick that explain with we put ourselves on the $\\mathcal{S}^3$ sphere is that we anticipate in advance that by doing a change of variable we will reduce this metric to three coordinates only!\n\t\n\tWe have also obviously:\n\t\n\tIf we assume $R=c^{te}$ we get by differentiation:\n\t\n\tAfter simplification:\n\t\n\tThat is:\n\t\n\tNow we use spherical coordinates (\\SeeChapter{see section Vector Calculus page \\pageref{spherical coordinates}}):\n\t\n\tBut as we know that in the general:\n\t\n\tTherefore having all this, we can rewrite:\n\t\n\tas following:\n\t\n\tWe will denote obviously $\\|\\vec{r}\\|$ as $r$, and $||\\mathrm{d}\\vec{r}\\|$ as $\\mathrm{d}r$, and as they are collinear, we have $\\cos(\\alpha)=1$, therefore:\n\t\n\tIt is traditional to put:\n\t\n\tand name it the \"unit three-sphere metric\" (also sometimes denoted $\\mathrm{d}\\Omega^2_3$). Therefore:\n\t\n\tAs for the comoving time introduce earlier before, let us introduce the \"\\NewTerm{comoving coordinates}\\index{comoving coordinates}\" as being:\n\t\n\tTherefore:\n\t\n\tIf we had made the same development but with the hyperbolic metric (\\SeeChapter{see section Differential Geometry page \\pageref{curvature parameter}}), we would have obtain:\n\t\n\tThis is why we write more generally:\n\t\n\twith:\n\t\\begin{itemize}\n\t\t\\item If $k=0$ we fall back on the flat Euclidean space (but don't forget we are on comoving coordinates!)\n\t\t\n\t\t\\item If $k=+1$ we are on a spherical space\n\t\t\n\t\t\\item If $k=-1$ we are in a hyperbolic space\n\t\\end{itemize}\n\tThen the metric tensor including time coordinates with $(-,+,+,+)$ signature is given by:\n\t\n\tSo that we can write obviously if $x^\\mu=(ct,x^i)$:\n\t\n\tBut $R$ can be an arbitrary function of time so we write traditionally:\n\t\n\tand as we have seen earlier it usage to denote the radius $a$ so therefore:\n\t\n\tand this is the final form of the Friedmann–Lemaître–Robertson–Walker (FLRW) metric.\n\t\n\tOr also written with another signature:\n\t\n\tSometimes denoted:\n\t\n\twhere $\\mathrm{d}\\Omega^2_3$ is sometimes named the \"hyperboloid metric\" and $N(t)$ is chosen sometimes as an arbitrary lapse function. \n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn a more general framework that $\\mathrm{d}\\Omega^2_3$ is defined as:\n\t\n\t\\end{tcolorbox}\n\t\n\tIt is important to remember that $x$ has no units and is often denoted in textbooks with the following letter $\\chi$ and that rigorously the scale factor $a(t)$ is defined by $a(t)/a(t_0)$. Keep also in mind that one of the main idea is to determine the explicit expression of $a(t)$ (Universe models) to inject it afterwards in the FLRW metrics to make further investigation on the properties of the visible Universe.\n\n\tThe main results of the FLRW model were first derived by the Soviet mathematician Alexander Friedmann in 1922 and 1924. Although his work was published in the prestigious physics journal \\textit{Zeitschrift für Physik}, it remained relatively unnoticed by his contemporaries. Friedmann was in direct communication with Albert Einstein, who, on behalf of \\textit{Zeitschrift für Physik}, acted as the scientific referee of Friedmann's work. Eventually Einstein acknowledged the correctness of Friedmann's calculations, but failed to appreciate the physical significance of Friedmann's predictions.\n\t\n\tFriedmann died in 1925. In 1927, Georges Lemaître, a Belgian priest,\tastronomer and periodic professor of physics at the Catholic University of Leuven, arrived independently at similar results as Friedmann had and published them in \\textit{Annals of the Scientific Society of Brussels}. In the face of the observational evidence for the expansion of the universe obtained by Edwin Hubble in the late 1920s, Lemaître's results were noticed in particular by Arthur Eddington, and in 1930–31 his paper was translated into English and published in the \\textit{Monthly Notices of the Royal Astronomical Society}.\n\n\tHoward P. Robertson from the US and Arthur Geoffrey Walker from the UK explored the problem further during the 1930s. In 1935 Robertson and Walker rigorously proved that the FLRW metric is the only one on a space-time that is spatially homogeneous and isotropic (as noted above, this is a geometric result and is not tied specifically to the equations of General Relativity, which were always assumed by Friedmann and Lemaître).\n\n\tBecause the dynamics of the FLRW model were derived by Friedmann and Lemaître, the latter two names are often omitted by scientists outside the US. Conversely, US physicists often refer to it as simply \"\\NewTerm{Robertson–Walker metric}\"\\index{Robertson–Walker metric}. The full four-name title seems to be the most democratic. Often the \"Robertson–Walker\" metric, so-called since they proved its generic properties, is distinguished from the dynamical \"Friedmann-Lemaître\" models, specific solutions for $a(t)$ which assume that the only contributions to stress-energy are cold matter (\"dust\"), radiation, and a cosmological constant.\n\t\n\t\\pagebreak\n\t\\subsubsection{Cosmological Redshift}\\label{cosmological redshift}\n\tBefore dealing with Universe models dealing with the FLRW metric, let us consider two points in space participating in the expansion of the Universe. At one point we have a source of light and at the other an observer (us). Let us use spherical coordinates centered on the observer, so that the comoving coordinate of the observer is $c = 0$ and the comoving coordinate of the source is $\\chi=0$. Let us analyse the propagation of a photon emitted by the source at time $t_e$ and received at time $t_0$. As the photon propagates radially towards the observer, along its trajectory in space, and hence along its worldline in space-time we have $\\theta=c^{te}$ and $\\phi =c^{te}$. Moreover, along the worldlines of photons (Friedmann–Lemaître–Robertson–Walker metric):\n\t\n\tHence:\n\t\n\tNotice that we know how to calculate the three possible integrals depending on the value of $k$ (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{usual primitives}}):\n\t\n\t \\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tUsing the notation of the conformal time defined earlier above, this latter relation is sometimes written:\n\t\n\tIf we put $c=1$ we see that time and distance may be interchanged as:\n\t\n\t\\end{tcolorbox}\n\tFor an observer observing the crest of a light wave at a position $r = 0$ and time $t = t_\\text{now}$, the crest of the light wave was emitted at a time $t = t_\\text{then}$ in the past and a distant position $r = R$. Integrating over the path in both space and time that the light wave travels yields:\n\t\n\tIn general, the wavelength of light is not the same for the two positions and times considered due to the changing properties of the metric. When the wave was emitted, it had a wavelength $\\lambda_\\text{then}$. The next crest of the light wave was emitted at a time:\n\t\n\tThe observer sees the next crest of the observed light wave with a wavelength $\\lambda_\\text{now}$ to arrive at a time:\n\t\n\tSince the subsequent crest is assumed approximately again emitted from $r = R$ and is observed at $r = 0$, the following equation can be written:\n\t\n\tThe right-hand side of the two integral equations above are supposed as approximately equal given the small time variation, which means:\n\t\n\tUsing the following manipulation:\n\t\n\twe find that:\n\t\n\tFor very small variations in time (over the period of one cycle of a light wave), we assume that the scale factor is essentially a constant ($a = a_\\text{now}$ today and $a = a_\\text{then}$ previously). This yields:\n\t\n\twhich can be rewritten as:\n\t\n\tIn analogy with the doppler redshift provided earlier above, the relation:\n\t\n\tdefines the \"\\NewTerm{cosmological redshift}\\index{redshift!cosmological redshift}\" or\"\\NewTerm{expansion redshift}\\index{redshift!cosmological redshift}\" . Remarkably, with these approximations, the curvature of space does not appear in the final result.\n\t\n\tIn an expanding universe, the scale factor is monotonically increasing as time passes, thus, $z$ is positive and distant galaxies appear redshifted. it follows that as a photon travels across our expanding Universe its wavelength increases and its frequency decreases. Thus, the energy of the photon also decreases!\n\t\n\tThe previous relations shows that the redshift of a distant source is a measure of the total expansion of the Universe that has occurred while the light was travelling between the source and the observer. It does not tell us the distance to the source or how long ago the light was emitted. These quantities depend on the precise nature of the Universe expansion between the instances of emission and observation. In different cosmological models we obtain different results for the same redshift!\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe existence of the cosmological redshift explains the \"\\NewTerm{Olbers' paradox}\\index{Olbers' paradox}\" (named after the German astronomer Heinrich Wilhelm Olbers) or also known as the \"\\NewTerm{dark night sky paradox}\". The darkness of the night sky is one of the pieces of evidence for a dynamic Universe, such as the Big Bang model. In the hypothetical case that the Universe is static, homogeneous at a large scale, and populated by an infinite number of stars, then any line of sight from Earth must end at the (very bright) surface of a star and hence the night sky should be completely illuminated and very bright. The Swiss mathematician Jean Philippe Loys de Cheseaux explains this paradox mathematically in 1746 by calculating that the light energy falling on Earth should be $180,000$ times more intense than that of the Sun. In 1823, Olbers refine this reasoning by observing that in a uniformly filled universe of stars, the stars are hidden from each other and deduces that the brightness of the night sky can not be infinite but at most equal to the surface brightness of a star.\\\\\n\t\n\tThis contradicts obviously the observed darkness and non-uniformity of the night as many stars are above the cosmological horizon and also a significant fraction of stars have their light that is redshifted and hence invisible to human eyes!\\\\\n\t\n\tNotice that while dark clouds could obstruct the light, these clouds would heat up, until they were as hot as the stars, and then radiate the same amount of light.\n\t\\end{tcolorbox}\n\t\n\t\\pagebreak\n\t\\subsubsection{Comobile Universe Diameter}\n\tAs promised earlier, it is now time for us to determine the comobile Universe diameter using General Relativity and especially with the special case of the FLRW metric!\n\t\n\tFor this purpose we start again from the same assumption as for the cosmological redshift, ie:\n\t\n\t\n\tThe horizon $d_H(t_1, t_2)$ is defined as the physical distance at time $t_2$ between two particles emitted at the same point but in opposite directions at time $t_1$, and travelling at the speed of light. If the origin of spherical comobile coordinates is chosen to coincide with the point of emission, the physical distance at time $t_2$ can be computed by integrating over small distance elements $\\mathrm{d}l$ between the origin and the position $r_2$ of one particle, and multiplying by two:\n\t\n\tIn addition, the geodesic equation for ultra-relativistic particles gives $\\mathrm{d}s = 0$, i.e.:\n\t\n\twhich can be integrated along the trajectory of the particles:\n\t\n\tWe can now replace in the expression of $d_H$ and get:\n\t\n\tUsually, the result is presented in this form. However, for the following discussion, it is be particularly useful to eliminate the time from the integral by remembering that:\n\t\t\n\tHence:\n\t\n\twhere the Hubble parameter is seen now as a function of $a$. Let us assume that $t_1$ and $t_2$ are two times during radiation domination. We know from the Friedmann equation that during radiation domination one has:\n\t\n\tso we can parametrize the Hubble rate as:\n\t\n\tWe get:\n\t\n\tIf the time $t_2$ is much after $t_1$ so that $a_2 \\gg a_1$, the expression for the horizon does not depend on $a_1$:\n\t\n\tSo, the horizon equals twice the Hubble (comobile) radius at time $t_2$:\n\t\n\tThis relation (that can be derived using some other ways more or less approximative but all assuming the radiation dominated era!) can lead us to a quite interesting result.\n\t\n\t Indeed, during our basic study of the CMB we have determined the original decoupling time $t_\\text{dec}$. That latter relation can we be injected in the previous relation that lead us to:\n\t\n\tThat means simply that at the time we write these lines, two points that were connected at the decoupling time, are today separated from a comobile distance (radius) of approximately $255 \\;[\\text{Mpc}]$ (assuming all assumptions are verified...!) on our Hubble sphere. As we have multiplied by the speed of light, this calculation assumes that today such points are causally disconnected regions of space! So this comobile distance represents like a lower-limit of two causally disconnected regions of space after the decoupling time.\n\t\n\t Since we know this comobile radius and the comobile distance to our Hubble sphere center, this corresponds approximately to an angle of:\n\t\n\t\n\t\\subsubsection{General Friedmann equations}\n\tIt follows now, that using the second signature and changing $x$ to $r'$ we get:\n\t\n\tFor later we need to calculate the Christoffel symbols (arrrgh!!!!). So let us do that for the non-null one only.\n\n\tFirst let us recall that (\\SeeChapter{see section Tensor Calculus page \\pageref{fundamental theorem of Riemannian geometry}}) that:\n\t\n\tAnd let's go for the boring part!\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\tLet us now calculate the Ricci tensor only for the non-null terms:\n\t\n\tThen (pffff...!):\n\t\n\tSo finally:\n\t\n\tAnd next:\n\t\n\tTherefore:\n\t\n\tSo finally:\n\t\n\t\n\tTherefore:\n\t\n\tAlso identically (sorry but we no have the energy anymore to detail the calculation...):\n\t\n\tNow let us calculate the scalar curvature (Ricci scalar). Let us recall (\\SeeChapter{see section Tensor Calculus page \\pageref{ricci scalar}}), that it is given by:\n\t\n\tTherefore using previous results:\n\t\n\tSo finally:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe latter equality relates spatial curvature (usually denoted $k$) and space-time curvature (usually denoted $R$). Space-time curvature $R$ has a contribution $6k/a^2$ from spatial curvature $k$, but it also has two terms that come just from the spatial expansion over time, $a$.\\\\ \n\t\n\tRemember that space-time curvature is coordinate-independent. Spatial curvature depends on the \"slicing\" (into constant-time slices) imposed by coordinates; for example de Sitter is spatially flat in one slicing and spatially curved in another, but always has uniform positive space-time curvature.\n\t\\end{tcolorbox}\n\t\n\tNow let us recall that we have proved:\n\t\n\tAnd therefore:\n\t\n\tSo don't forget that only diagonal elements are non-null and that $u_i=(c,0,0,0)$.\n\t\n\tTherefore:\n\t\n\tNow let us recall the Einstein Field Equations (\\SeeChapter{see section General Relativity page \\pageref{einstein field equations}}):\n\t\n\tLet us start with:\n\t\n\tSo we get after injecting the previous results:\n\t\n\tAfter elementary simplification we get immediately:\n\t\n\tAnd now with:\n\t\n\tSo we get after injecting the previous results:\n\t\n\tAfter elementary simplification we get immediately:\n\t\n\t\n\tAnd now with:\n\t\n\tSo we get after injecting the previous results:\n\t\n\tAfter elementary simplification we get immediately (same result as before! this is a consequence of space isotropy assumption):\n\t\n\t\n\tAnd finally with:\n\t\n\twe get also exactly the same result as the two previous one!\n\t\n\tThe both relations:\n\t\n\tare the \"\\NewTerm{general Friedmann equations}\\index{general Friedmann equations}\\label{general Friedmann equations}\".\n\t\n\tIt is very common to found them in the literature into the form of the velocity and acceleration equations (often write the cosmological constant in terms of a vacuum energy density as $\\Lambda=8\\pi G\\rho_\\text{vac}/c^4$):\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tNotice that if we assume that $\\rho$ and $P$ depends on $a$ (which seems quite logical if the energy in the Universe is indeed conservative), typically the decrease with the expansion (intuitive!), then is seems that the only term that does not contain the scale factor $a$ is $\\Lambda c^2$. Hence the fact that some scientists assume that $\\Lambda$ behave like constant whatever the age of the Universe.\n\t\\end{tcolorbox}\n\tNow let us rewrite the first one as following:\n\t\n\tand let us notice that for $k=0$ and $\\Lambda=0$ we get for that latter:\n\t\n\tand then we define the critical density that we already know:\n\t\n\tAnd let us recall also $\\frac{\\dot{a}}{a}=H$. Therefore:\n\t\n\tLet us now define the following parameters of energy density (matter energy density, curvature energy density and radiation energy density):\n\t\n\tTherefore our equality:\n\t\n\tcan be rewritten:\n\t\n\tDividing both side by $H^2$ we get:\n\t\n\tRearranging:\n\t\n\tand injecting the density parameters we get:\n\t\n\tNotice that is also quite common to see in textbooks:\n\t\n\twhere obviously we have the matter density, the radiation density, the curvature density and the constant energy density (there is a one to one correspondence with energy density given above but only with a $c^2$ factor difference as we know that $E= mc^2$).\n\t\n\t\n\t\\subsubsection{Einstein (static) Universe model}\\label{einstein static universe model}\n\tLike most scientists of his time, Albert Einstein considered that the Universe was globally static and homogeneous (1917). He also imagines it closed mainly for reasons related to Mach's principle, to which he believes very much. He thus constructs a model of a spherical Universe capable of accounting for the essential physical conditions he thinks it must respect.\n\n\tHowever, he quickly finds that his equations do not admit static solutions and so it is to satisfy what he considers as an experimental requirement (immobile universe) that he is forced to slightly modify his equations by adding as we already know an additional term: the cosmological constant.\n\n\tThis constant behaves like a repulsive force to exactly counterbalance the gravitational force due to matter, the whole being now able to be balance.\n\t\n\tSo if we take a closed universe ($k=+1$), static\\footnote{For a stationary Universe the scaling factor $a(t)$ must be constant (typically equal to $1$!) and hence all its time derivatives must vanish.} ($a=c^{te}$) and made of a gas of dust of negligible pressure ($P\\cong 0$), the general Friedmann equations, given for recall by:\n\t\n\treduce immediately to:\n\t\n\tTherefore injecting the second relation into the first one, and rearranging the second one, we get:\n\t\n\tSo if $k=+1$ and $a=c^{te}$ with $P\\cong 0$ we have that also $\\Lambda = c^{te}$!\n\t\n\tMore explicitly:\n\t\n\tSo for the universe to be really static we should have $a=1$ and therefore $\\Lambda=1$. Sadly (for Albert Einstein...), actual experimental measurement give us for $\\rho_m\\cong 10^{-26}\\;[\\text{kg}\\cdot\\text{m}^{-3}]$, a value of the scale factor equal to $a_\\text{Einstein}=1.03\\cdot 10^{26}\\;[\\text{m}]$ that is to say approximately $1\\cdot 10^9$ light years, and hence $\\Lambda_\\text{Einstein}=9.31\\cdot 10^{-53}\\;[\\text{m}^{-2}]$.\n\t\n\t\\subsubsection{Friedmann Universe models}\n\tNow to continue with the Friedmann Universe model (1922-1924) we need first an important relation. Let us recall the general Friedmann equations we get just earlier:\n\t\n\tMultiplying the second one by $3$ and adding the second one we get immediately:\n\t\n\tTherefore:\n\t\n\twe fall back here on a generalization of one of the Friedmann equation\\footnote{The so named \"Friedmann's second equation\" that is also sometimes named \"Raychaudhuri equation\" or \"acceleration equation\"} we used during our study of the Newtonian model of the Universe!\n\t\n\tThat latter relation is also commonly written in many textbooks as:\n\t\n\tor:\n\t\n\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe question now is how this the cosmological constant produce a repulsive force? Identifying the force from:\n\t\n\twe get\\label{cosmological repuslive force}:\n\t\n\tThis is supposed to be the cosmological force on a particle (galaxy) in a Universe with non-zero $\\Lambda$.\n\t\\end{tcolorbox}\n\t\t\t\t\n\tNow we will use the latter relation to consider three situation: $\\Lambda=0$, $\\Lambda>0$, $\\Lambda<0$ and for each of the latter case $k=0$, $k>0$ and $k<0$. That is a total of $9$ scenarii (if we include for each scenario the case where respectively matter or radiations dominates... we have a total of $18$ scenarii to study...!!!).\n\n\tLet's start!:\n\t\\begin{itemize}\n\t\t\\item With $\\Lambda=0$ we have:\n\t\t\t\n\t\t\tthat becomes:\n\t\t\t\n\t\t\tTherefore:\n\t\t\t\n\t\t\tand:\n\t\t\t\n\t\t\tbecomes:\n\t\t\t\n\t\t\tThat is to say:\n\t\t\t\n\t\t\tSo whatever happens and whatever the value of $k$, the Universe expansion is decelerating.\n\t\t\t\n\t\t\tLet us now see how this Universe behave according to the values of $k$:\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item For $k=0$ (flat Universe) we get the \"\\NewTerm{Einstein-De Sitter Universe model}\\index{Einstein-De Sitter Universe model}\" proposed jointly by Albert Einstein and Willem De Sitter in 1932!\n\t\t\t\t\n\t\t\t\tSo for $k=0$ and $\\Lambda=0$ we have:\n\t\t\t\t\n\t\t\t\tthat obviously becomes:\n\t\t\t\t\n\t\t\t\tBut $\\rho$ depends on $R$. We have already introduced earlier (obvious) during our study of Newtonian models that:\n\t\t\t\t\n\t\t\t\tAnd it is common to take $R_0=1$ for the first time. Injecting into the Friedmann equation, we get:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tor explicitly:\n\t\t\t\t\n\t\t\t\tIntegrating:\n\t\t\t\t\n\t\t\t\tThis gives:\n\t\t\t\t\n\t\t\t\tWe simplify a bit:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tIt is therefore an open Universe whose expansion will stop after an infinite time!\n\t\t\t\t\n\t\t\t\tBut let us recall that for $k=0$ and $\\Lambda=0$ we have:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\t\t\t\t\n\t\t\t\tNow we can estimate the age of the Universe according to this model. So for to get the time since the beginning of our Universe we have by construction to pout $R_{\\Lambda=0,k=0}=1$. Therefore the above relation after rearranging becomes:\n\t\t\t\t\n\t\t\t\tThis model of Universe as we already know has been abandoned because in contradiction with the ages of certain old stars whose age is estimated to be more than $10$ billion years.\n\n\t\t\t\t\\item Now, for the second sub-case (spherical), we have $k=+1$ (seems to have been developed first in 1922):\n\t\t\t\t\n\t\t\t\tthat obviously becomes:\n\t\t\t\t\n\t\t\t\tBut $\\rho$ depends on $R$. We have already introduced earlier (obvious) during our study of Newtonian models that:\n\t\t\t\t\n\t\t\t\tAnd it is common to take $R_0=1$ for the first time. Injecting into the Friedmann equation, we get:\n\t\t\t\t\n\t\t\t\tTherefore after rearranging and simplifying:\n\t\t\t\t\n\t\t\t\tHence:\n\t\t\t\t\n\t\t\t\tThat we will rewrite as following for the purpose of notations simplifications and some future clever change of variables:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tNow before we continue let us recall that with $k=+1$ and $\\Lambda=0$ one of the Friedmann equations becomes:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tBut as (still with the convention to take $R_0=1$):\n\t\t\t\t\n\t\t\t\tThe previous relation is then written:\n\t\t\t\t\n\t\t\t\tAs we have necessarily $\\dot{R}^2>0$, then:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tAnd as $R>0$ and $K>0$ we have in fact:\n\t\t\t\t\n\t\t\t\tNow let us do the change of variable (since $0<\\sin^2(\\theta)<1$):\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tcan be rewritten:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tUsing trigonometric identities:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tFor $t=0$, we assume $R=0$ and therefore $\\theta=0$. This bring us that $c^{te}=0$.\n\t\t\t\t\n\t\t\t\tWe have then:\n\t\t\t\t\n\t\t\t\tLet us put $\\theta'=2\\theta$. Then:\n\t\t\t\t\n\t\t\t\twe recognize here the parametric equations of a cycloid (\\SeeChapter{see section Analytical Geometry page \\pageref{cycloid curve}}). Therefore this is a bouncing cyclic Universe model!\n\t\t\t\t\n\t\t\t\tWe see that $a$ will be maximum for $\\theta=\\pi$, then:\n\t\t\t\t\n\t\t\t\tand the final state of the Big Crunch will occur when $\\theta=2\\pi$, where we then have $a=0$ and then:\n\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\\item Now the third and last sub-case, we choose $k=-1$ (hyperbolic model that seems to have been developed in 1924).\n\t\t\t\t\n\t\t\t\tThe development are very similar to the previous case as just the sign change. We then also start from:\n\t\t\t\t\n\t\t\t\tthat obviously becomes:\n\t\t\t\t\n\t\t\t\tBut $\\rho$ depends on $R$. We have already introduced earlier (obvious) during our study of Newtonian models that:\n\t\t\t\t\n\t\t\t\tAnd it is common to take $R_0=1$ for the first time. Injecting into the Friedmann equation, we get:\n\t\t\t\t\n\t\t\t\tTherefore after rearranging and simplifying:\n\t\t\t\t\n\t\t\t\tHence:\n\t\t\t\t\n\t\t\t\tThat we will rewrite as following for the purpose of notations simplifications and some future clever change of variables:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tNow before we continue let us recall that with $k=-1$ and $\\Lambda=0$ one of the Friedmann equations becomes:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tBut as (still with the convention to take $R_0=1$):\n\t\t\t\t\n\t\t\t\tThe previous relation is then written:\n\t\t\t\t\n\t\t\t\tAs we have necessarily $\\dot{R}^2>0$ (because of the square!), then:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tBut as $R>0$ and $K>0$ we have in fact:\n\t\t\t\t\n\t\t\t\tNow let us do the change of variable (since $\\sinh^2(\\theta)>0$):\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tcan be rewritten:\n\t\t\t\t\n\t\t\t\tTherefore:\n\t\t\t\t\n\t\t\t\tUsing trigonometric identities:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\tFor $t=0$, we assume $R=0$ and therefore $\\theta=0$. This bring us that $c^{te}=0$.\n\t\t\t\t\n\t\t\t\tWe have then:\n\t\t\t\t\n\t\t\t\tLet us put $\\theta'=2\\theta$. Then:\n\t\t\t\t\n\t\t\t\tSo this is just an unbounded Universe!\n\t\t\\end{itemize}\n\t\n\t\t\\item $\\Lambda<0$\n\t\t\tFirst let us start with a general behaviour analysis. Once again we start from the following Friedmann equations:\n\t\t\t\n\t\t\tThen for $\\Lambda <0$ we can write:\n\t\t\t\n\t\t\tas you can see by the \"$+$\" in front of the $\\Lambda$ term we can already make the conclusion that when $\\Lambda<0$ it acts like an attractive force to the Universe.\n\t\t\t\n\t\t\t$R(t)$ is then monotonically increasing and therefore there exist a $\\dot{R}(t)$ that will be equal to zero. So the Universe re-collapse happens even earlier due to \"attractive force\"!\n\t\t\n\t\t\t\\StickyNote[2.5cm]{\\LARGE To finish depending on donations}[6.5cm]\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item $k=0$\n\t\t\t\t\\item $k>0$\n\t\t\t\t\\item $k<0$\n\t\t\t\\end{itemize}\n\t\n\t\t\\item $\\Lambda>0$\n\t\t\tFirst let us start also with a general behaviour analysis. Once again we start from the following Friedmann equations:\n\t\t\t\n\t\t\tThen for $\\Lambda >0$ we can write:\n\t\t\t\n\t\t\tas you can see by the \"$-$\" in front of the $\\Lambda$ term we can already make the conclusion that when $\\Lambda>0$ it acts like an repulsive force to the Universe.\n\t\t\t\n\t\t\t$R(t)$ is then forever expanding. Notice also that $\\rho$ drops as $\\Lambda$ is assumed to remain constant...\n\t\t\t\n\t\t\t\n\t\t\t\\begin{itemize}\n\t\t\t\t\\item For $k=0$ we then have obviously:\n\t\t\t\t\n\t\t\t\tafter rearranging:\n\t\t\t\t\n\t\t\t\tAnd now let us consider that $\\rho$ is small enough (universe without mass nor radiation but just a cosmological constant) so that we can write:\n\t\t\t\t\n\t\t\t\twhich yields the solution:\n\t\t\t\t\n\t\t\t\tThus, the Universe expands exponentially! Some physicists (and astrophysicists/cosmologists) associate this to the \"\\NewTerm{inflation}\\index{inflation}\" period of the Universe. There is also a solution on the negative side of the time axis that most textbooks ignore...\n\t\t\t\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\t\t\t\tNotice that there is not constant of integration, otherwise the equality would not hold! So an interesting result (even if it's a priori not realistic to consider $\\rho$ as small...) is that when $t=0$, $R\\neq 0$ (ie that Universe existed before the creation of time).\n\t\t\t\t\\end{tcolorbox}\n\t\t\t\tThis model of universe is named the \"\\NewTerm{De Sitter Universe model}\\index{De Sitter Universe model}\" (not to be confuse with the Einstein-De Sitter Universe model seen earlier!).\n\t\t\t\t\n\t\t\t\tObviously we have then that the Hubble parameter is then constant as by definition:\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tNow let us consider the case where $\\rho$ cannot be neglected, as we have proved earlier that in a flat universe dominated by matter we had:\n\t\t\t\t\n\t\t\t\tthen:\n\t\t\t\t\n\t\t\t\tcan be rewritten:\n\t\t\t\t\n\t\t\t\tHence:\n\t\t\t\t\n\t\t\t\tThus:\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tSo:\n\t\t\t\t\n\t\t\t\tLet us do the following change of variable:\n\t\t\t\t\n\t\t\t\tHence:\n\t\t\t\t\n\t\t\t\tSo:\n\t\t\t\t\n\t\t\t\tSo we want to take the primitive of:\n\t\t\t\t\n\t\t\t\tas we know from our study of usual derivatives (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{usual derivatives}}) the integral is simply given by:\n\t\t\t\t\n\t\t\t\tFor simplification purposes we will assume that for $t=0$, we have $R=0$ hence $c^{te}=0$ and we can write:\n\t\t\t\t\n\t\t\t\tSo:\n\t\t\t\t\n\t\t\t\tSo finally:\n\t\t\t\t\n\t\t\t\tPlotting such a function with Maple 4.00b we get:\\\\\n\t\t\t\t\n\t\t\t\t\\texttt{>plot((cosh(x)-1)\\string^(1/3),x=0..10);}\n\t\t\t\t\n\t\t\t\t\\begin{figure}[H]\n\t\t\t\t\t\\centering\n\t\t\t\t\t\\includegraphics[scale=0.8]{img/cosmology/universe_scale_factor_evolution_flat_positive_cosmological_constant_maple.jpg}\n\t\t\t\t\t\\caption[]{Evolution of $R$ for a zero curvature space with positive cosmological constant}\n\t\t\t\t\\end{figure}\n\t\t\t\tthe quick divergent part of that curve is commonly named \"\\NewTerm{big chill}\\index{big chill}\" or \"\\NewTerm{big rip}\\index{big rip}\" depending on the textbooks (ie authors and teachers).\n\t\t\t\t\n\t\t\t\tLooking at the plot it is quite obvious that there is somewhere and inflection point (\\SeeChapter{see section Differential and Integral Calculus page \\pageref{inflection point}}). Let us determine its position using again the Friedmann equation with $k=0$ (and still assuming $\\Lambda>0$):\n\t\t\t\t\n\t\t\t\tThat as we know, in a matter dominate Universe can be written as:\n\t\t\t\t\n\t\t\t\tand if we differentiate with respect to time, we get:\n\t\t\t\t\n\t\t\t\tThe inflection point occurs as we know when $\\ddot{R}=0$, therefore we get by dividing both sides by $\\dot{R}$ and after rearranging :\n\t\t\t\t\n\t\t\t\tEquating with the previous result that was for recall:\n\t\t\t\t\n\t\t\t\tWe then have:\n\t\t\t\t\n\t\t\t\tAfter simplification we get:\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\\item Now for the second sub-case (spherical), where we have $k=+1$, let us first recall that we have already treated the case $k=+1$ with $\\Lambda>0$ and assuming $R=0$. This is the Einstein (static) Universe model already treated on page \\pageref{einstein static universe model}.\n\t\t\t\t\n\t\t\t\t\\item $k<0$\n\t\t\t\\end{itemize}\n\t\\end{itemize}\n\tFinally here is a summary of most earlier developed models depending on $k$ and $\\Lambda$ canonical values:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/cosmological_models_summary.jpg}\n\t\t\\caption[Cosmological models summary]{Cosmological models summary (source: \\cite{d1992introducing})}\n\t\\end{figure}\n\t\n\t\\StickyNote[2.5cm]{\\LARGE To finish depending on donations}[6.5cm]\n\t\n\tThe Uchuu (meaning \"Outer Space\" in Japanese) 2021 simulation is the largest and most detailed simulation of the universe ever made. It contains $2.1$ trillion \"particles\" in a space $9.6$ billion light-years across. The simulation models the evolution of the universe across more than $13$ billion years. It doesn't focus on the formation of stars and planets but instead looks at the behaviour of dark matter within an expanding universe. The detail of Uchuu is high enough that the team can identify everything from galaxy clusters to the dark matter halos of individual galaxies. Since dark matter makes up most of the matter in the universe, it is the main driver of galaxy formation and clustering. It takes a tremendous amount of computational power and storage to create such a detailed model. The team ( from Japan, Spain, U.S.A., Argentina, Australia, Chile, France, and Italy) used over $40,000$ computer cores and $20$ million computer hours to generate their simulation, and it produced more than $3$ Petabytes of data. Using high-density compression, however, the team was able to compress their results into a mere 100 Terabytes of storage that can be downloaded and analysed with Python.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/universe_simulation.jpg}\n\t\t\\caption[Uchuu 2021 Universe simulation]{Uchuu 2021 Universe simulation (source: \\cite{ishiyama2021uchuu})}\n\t\\end{figure}\n\t\n\t\\pagebreak\n\t\\subsection{The Black Hole Universe}\n\tA recent hypothesis in the history of cosmology (since the 1970 as far as we know...) which is at the heart of many theoretical research (Stephen Hawking, Roger Penrose and others) is the possibility of assimilating our Universe to a Black Hole (\\SeeChapter{see section General Relativity page \\pageref{black hole}}).\n\n\tThe origin of the idea can be made from a very simple calculation:\n\n\tWe know that approximately the radius of the (current) Universe is given according to our previous calculations by:\n\t\n\tBut we have proved in the section of General Relativity (and Classical Mechanics) that the Schwarzschild radius is given by:\n\t\n\tWhat we can write for the Universe in the following form (under many assumptions: isotropy, homogeneity, spherical, etc.):\n\t\n\twhich with the values of the critical density and the radius of the cosmological horizon calculated earlier above gives:\n\t\n\tSo, roughly speaking, knowing all the uncertainties that we have accumulated in particular that on the Hubble parameter we see that the Schwarzschild radius is not very far from the radius of the present Universe.\n\n\tAs curious as it may seem, this question is not so far-fetched and is very seriously studied. It is therefore theoretically possible that our whole universe is encapsulated in a gigantic Black Hole (therefore of very large mass and very low density as we see it with our numerical values) of another inaccessible Universe ...\n\n\tWhat is certain is that if this were the case, the expansion of the Universe (now observed) could not continue beyond the horizon of this super Black Hole because nothing coming from within can cross this horizon. However, recent observations seem to show that the expansion of the Universe is far from slowing and tends to accelerate with time, which is in contradiction with such a Black Hole Universe...\n\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{90} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 17 votes,  70.59\\%}} \n\t\\end{tabular} \n\t\\end{flushright}\n\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{Quantum Gravity/Cosmology}\\label{quantum Gravity}\n\tQuantum gravity\\index{quantum gravity} (QG) and Cosmology\\index{quantum cosmology} are two fields of theoretical physics that seeks to describe respectively gravity and the universe according to the principles of quantum mechanics, and where quantum effects cannot be ignored, such as near compact astrophysical objects where the effects of gravity are strong or the beginning of the universe.\n\t\n\tTo start this section we think it is good to recall that the reader to refer first to the Okun cube (\\SeeChapter{see section Principia page \\pageref{okun cube}}). Once this done, here is another restricted version of the cube below (but not really accurate)  that highlights an interesting field that does not appear in the Okun cube and that is the Newtonian quantum gravity that we will see first. But this figure is interesting as it highlights well the different models we will deal with in this section:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/okun_wheel.jpg}\t\n\t\t\\caption[Okun wheel]{Okun wheel (source: ?)}\n\t\\end{figure}\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe above figure is especially not accurate (same problem for the Okun cube) for the arrow that links together Quantum Field Theory and Quantum Mechanics as there is not obvious and unique way that really links them together.\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Newton Quantum Gravity}\\label{newton quantum gravity}\\index{Newton quantum gravity}\n\tA Newtonian approach to quantum gravity is studied. At least for weak gravitational fields it should be a valid approximation. Such an approach could be used to point out problems and prospects \tinherent in a more exact theory of quantum gravity, yet to be discovered. Newtonian quantum gravity, e.g., shows promise for prohibiting Black Holes altogether (which would eliminate singularities and also solve the Black Hole information paradox), breaks the equivalence principle of general relativity, and \tsupports non-local interactions (quantum entanglement). Its predictions should also be testable at length scales well above the \"Planck scale\", by high-precision experiments feasible even with existing technology. It turns out that, e.g., the solar system, superficially, can be described as a quantum gravitational system, provided that the $l$ quantum number has its maximum value, $n-1$. This results exactly in Kepler's third law. If also the $m$ quantum number has its maximum value ($\\pm l$) the \tprobability density has a very narrow torus-like form, centered around the classical planetary orbits. However, as the probability density is independent of the azimuthal angle $\\phi$ there is, from quantum gravity arguments, no reason for planets to be located in any unique place along the orbit (or even \\textit{in} an orbit for $m \\neq \\pm l$). This is, in essence, a reflection of the \"measurement problem\" inherent in all quantum descriptions.\n\t\n\tThe greatest fundamental challenge facing theoretical physics has for many years been to reconcile gravity with quantum physics. There have been numerous attempts to do so, but so far there is no established and experimentally/observationally tested theory of \"quantum gravity\", the two main contenders presently being string theory and loop quantum gravity, with \"outsiders\" like twistor theory, non-commutative geometry, etc.\n\t\n\tThe motivations for studying newtonian quantum gravity are:\n\t\\begin{itemize}\n\t\t\\item Quantum theory is supposed to be universal, i.e., it should be valid on all length scales and for all objects, as there in principle exists no size/charge/mass-limit to its applicability. In atomic physics the practical restriction comes about due to the\tfact that there is a limit to arbitrarily large atomic nuclei as, i) the Coulomb force between protons is repulsive, eventually overpowering the strong nuclear force trying to hold the nucleus together, ii) the additional weak force makes neutron-rich nuclei decay before they grow too large. Also, the electric charge comes in both positive and negative, and as a result a big lump of matter is almost always electrically neutral\\footnote{The same also applies for e.g. the strong force, as the three different color charges (\"red\", \"green\", \"blue\") always combine to produce color-neutral hadrons and bulk matter.}. Neither of these effects are present in \"pure\" quantum gravity.\n\t\n\t\t\\item  For weak gravitational fields the newtonian theory should be sufficient. The weak-field newtonian limit is even used for determining the constant $\\kappa$ in Einstein's field equations of general relativity $G_{\\mu \\nu} = \\kappa T_{\\mu \\nu}$. The newtonian limit is also almost always sufficient for practical purposes in non-quantum gravity, except for a handful of extreme cases (notably Black Holes and the very early universe), although high-precision experiments in e.g. the solar system can and do show deviations from the newtonian theory, always in favour of general relativity.\n\t\n\t\t\\item  Even for strong gravitational fields the newtonian picture gives the same prediction as general relativity for the Schwarzschild radius of a spherically symmetric, non-rotating Black Hole, and correct order of magnitude results for neutron stars and cosmology. This could make it possible to deduce at least qualitative results about strongly coupled quantum gravity, as the newtonian viewpoint should give reliable first order quantum gravitational results.\n\t\\end{itemize}\n\t\n\tOn the other hand would any \"absurd\" results obtained from\tnewtonian quantum gravity, deviating from observations, implicate\teither that:\n\t\\begin{itemize}\n\t\t\\item General relativity cannot be quantized\\footnote{This is an automatic consequence of \"emergent\" gravity, e.g. Sakharov's \ttheory, where gravity is a non-fundamental interaction and rather a macroscopic consequence of other forces and fields.}. An unsuccessful special case (the weak field limit) would disprove the general case, whereas the opposite is not true. (A vindicated weak field limit will not prove that the general theory is also correct.)\n\t\n\t\t\\item Quantum mechanics fails at \"macroscopic\" distances and for macroscopic objects. This would mean that we in gravity have a unique opportunity to understand the \"measurement problem\" in quantum mechanics, as proposed by e.g. K\\'{a}rolyh\\'{a}zy and Penrose. In that case we can use gravity to probe the transition between quantum $\\rightarrow$ classical behaviour in detail, i.e. get experimental facts on where, how and when the inherently undecided, subjective quantum world of superpositions turns into the familiar objective classical everyday world around us. One could, at least in principle, envisage a test carried out in a free-falling (e.g.\tsatellite) environment where one alters $m$ (the gravitational \"test-charge\") and $M$ (the gravitational \"source-charge\") until\tthe expected quantum gravity results are observed, to obtain a limit of where the quantum mechanical treatment breaks down, hence making an experimental determination of the border between \"quantum\" and \"classical\", i.e. solving the quantum mechanical measurement problem. Fundamental quantum gravity and the quantum mechanical measurement problem may well be intertwined and might need to be resolved simultaneously in a successful approach.\n\t\\end{itemize}\n\t\n\tIn newtonian quantum gravity, at least as long as the system can be approximately treated as a 2-body problem, it is possible to use the mathematical identity between the electrostatic Coulomb\tforce in the hydrogen atom, and Newton's static gravitational force under the substitution $e^2 / 4 \\pi \\varepsilon_0 \\rightarrow GmM$. Therefore all analytical results from elementary quantum physics directly lifts over to the quantum gravity case. For weak electromagnetic fields, as in the hydrogen atom, the electrodynamic corrections to the static Coulomb field are very small, making the approximation excellent. The same applies to quantum gravity, dynamical effects from general relativity are negligible to a very high degree for weak gravitational fields. A gravitationally bound 2-body system should then exhibit exactly the same type of \"spectrum\" as a hydrogen atom, but emitted in (unobservable) hypothesized graviton form instead of photons (easily detectable as atomic spectra already in the 19th century).\n\t\n\tFor a free-falling 2-body system, e.g. in a satellite experiment enclosed in a spherical vessel, it should in principle be possible to measure the excitation energies for a suitable system. An analogous result has seemingly already been accomplished for neutrons in the gravitational field of the Earth, although there are some quantum gravity ambiguities as noted below.\n\t\n\tFor hydrogen-like (one electron) atoms, in the dominant Coulomb central-field approximation, the energy levels depend only on the principal quantum number, $n = 1, 2, 3, ...$:\n\t\n\twhere $E_H \\simeq 13.6$ [eV] is the ionization energy, i.e. the energy required to free the electron from the proton, and $Z$ the number of protons in the nucleus.\n\t\n\tThe Bohr-radius, $a_0$, the innermost radius of circular orbits in the old semi-classical Bohr-model, and also the distance $r$ for which the probability density of the Schrödinger equation for the Hydrogen ground-state peaks, is:\n\t\n\twhereas the expectation value for the electron-nucleus separation is:\n\t\n\tA comparison between the Coulomb potential in Hydrogen-like atoms:\n\t\n\tand the Newtonian gravitational potential between two masses $m$ and $M$:\n\t\n\tallows us to obtain all results of the gravitational case by the simple substitution:\n\t\n\tin the well-known formulas for the Hydrogen atom.\n\t\n\tFor instance, the gravitational \"Bohr-radius\", $b_0$, becomes:\n\t\n\tand the quantum-gravitational energy levels are:\n\t\n\there again $E_g = G^2 m^3 M^2/ 2 \\hbar^2$ is the energy required to totally free the mass $m$ from $M$ in analogy to the Hydrogen case, whereas the expectation value for the separation is:\n\t\n\tAlso all the analytical solutions to the Schrödinger equation, the hydrogen wave-functions, carry over to the gravitational case with the simple substitution $a_0 \\rightarrow b_0$:\n\t\n\twhere $N_{nlm}$ is the normalization constant, $R_{nl}$ the radial wavefunction, and $Y_{lm}$, the spherical harmonics, contain the angular part of the wavefunction.\n\t\n\tLet us examine some concrete cases to obtain a feeling for these relations: For a two-body problem composed of proton and electron $b_0 \\simeq 10^{29}$ [m], several orders of magnitude larger than the size of the observable universe ($\\simeq 10^{26}$ [m]), whereas $E_g \\simeq 10^{-78}$ [eV]. For two neutrons $b_0 \\simeq 10^{22}$ [m], $E_g \\simeq 10^{-68}$ [eV]. For the Earth and Sun (approximated as a two-body problem for illustrative reasons) one gets $b_0 \\simeq 10^{-138}$ [m], an absurdly small ground state separation, and $E_g\t\\simeq 10^{182}$ [J], which is unphysical as the binding energy $E_g \\gg mc^2 \\simeq 10^{42}$ [J]. We will see below how to deal with\tthese \"unphysical\" cases and how the physical picture somewhat surprisingly is connected to the Schwarzschild radius. For a better 2-body application, let us consider a binary neutron star system (one solar mass each), $b_0 \\simeq 10^{-148}$ [m], $E_g\t\\simeq 10^{198}$ [J] $\\gg mc^2 \\simeq 10^{47}$ [J], again unphysical. One could also ask how much $m$ would have to be in a gravitational binary system (taking $m = M$) in order for $b_0$ to be, for example, one meter: $m \\simeq 10^{-19}$ [kg], or the mass of a small virus. For a pair of \"Planck-objects\" $m = M \\simeq\t10^{-8}$ [kg], we get, maybe not surprisingly, $b_0 \\simeq 10^{-35}$ [m] (the \"Planck length\") and $E_g \\simeq 10^{9}$ [J] (the \"Planck energy\") which also happens to be equal to $mc^2$. We could also ask for the binary system mass (again taking $m=M$) giving exactly the same numerical energy spectrum as for the Hydrogen atom, i.e. taking $E_g = E_H = 13.6$ [eV], resulting in $m \\simeq 10^{-13}$ [kg], the mass of one human cell, and $b_0 \\simeq 10^{-19}$ [m].\n\t\n\tOne could ask for the mass, $m$, required to produce exactly the quantum gravitational energy spectrum of hydrogen in a \tgravitational field like that of Earth, $M = M_{\\oplus} \\simeq 6 \\cdot 10^{24}$ [kg]. This turns out to be $m \\simeq 10^{-38}$ [kg], or an equivalent mass-energy of $\\sim 10^{-3}$ [eV], comparable to the conjectured mass of neutrinos. As $b_0 \\sim 1\\;[\\mu\\text{m}]$ in this case, only very highly excited states would be possible above the \tEarth surface. The matter would of course be quite different around cosmic compact objects, for example the conjectured \"preon stars\" with masses comparable to the Earth's and radii $\\sim b_0$.\n\t\n\tWe notice (e.g. through $b_0$) that the planets in the solar system must be in very highly excited quantum gravitational states. In that sense they are analogous to electrons in \"Rydberg atoms\" in atomic physics. To obtain a good two-body approximation, let us study the Sun-Jupiter system in a little more detail.\n\t\n\tFor excited states with $l \\neq 0$, and very large $n$ and $l$,\tthe expectation value of the distance is:\n\t\n\thowever as that is for an ensemble (average over many measurements), for a single state it is in principle more appropriate to use the most probable radial distance (\"radius\" of orbital):\n\t\n\tas a measure for the expected separation. However, for $n$ large and $l=l_{\\max} = n-1$ the two coincide so that $\\langle r \\rangle\t= \\tilde{r}$.\n\t\n\tThe angular momentum for Jupiter around the Sun is $L \\simeq 2 \\cdot 10^{43}\\;[\\text{J}\\cdot \\text{s}]$, giving an $l$-quantum number of $l = L/\\hbar \\simeq 2 \\cdot 10^{77}$. The most probable Sun-Jupiter distance is given by $\\tilde{r} = n^2 b_0 \\geq l^2 b_0 \\simeq 7.6 \\cdot 10^{11}$ [m], which is the same as the actual separation. $E_n =-E_g/n^2 \\simeq - 1.6 \\cdot 10^{35}$ [J], so the magnitude of the binding energy is much less than $mc^2 \\simeq 1.8 \\cdot 10^{44}$ [J], making it physically allowed, and also of the same order of magnitude as its classical counterpart $-GmM/r \\simeq - 3.4 \\cdot 10^{35}$ [J]. The Sun-Jupiter system can thus seemingly be treated as a quantum gravitational 2-body system, provided that it is taken to have its maximally allowed value for its angular momentum ($l \\simeq n$).\n\t \\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[width=1.0\\textwidth]{img/cosmology/mass_distance_discovered_planet.jpg}\n\t\t\\caption[Mass-period diagram of confirmed discovered exoplanets in 2015]{A mass-period diagram. Each dot marks the mass and orbital period of a confirmed exoplanet in 2015 (author: Stefano Meschiari)}\n\t\\end{figure}\n\tIn fact, it is easy to show that for Kepler's law to apply, $l$ must be very close to $n$.\n\t\n\tThe period of revolution can be written:\t\n\t\n\tand assuming maximality for the angular momentum, $l \\simeq n$,\n\tgives:\t\n\t\n\tSolving for $n$ gives:\n\t\n\tso that:\n\t\n\twhich exactly is Kepler's law. So, the conclusion is that all the planets in the solar system are in maximally allowed angular momentum states quantum mechanically. The $l \\simeq n$ quantum\tnumbers are as follows: $l_{\\text{Sun}} \\simeq 2 \\cdot 10^{75}$, $l_{\\text{mercury}} \\simeq 8 \\cdot 10^{72}$, $l_{\\text{venus}} \\simeq 2 \\cdot \t10^{74}$, $l_{\\text{Earth}} \\simeq 3 \\cdot 10^{74}$, $l_{\\text{Mars}} \\simeq 4 \t\\cdot 10^{73}$, $l_{\\text{jupiter}} \\simeq 2 \\cdot 10^{77}$, $l_{\\text{saturn}} \\simeq 8 \\cdot 10^{76}$, $l_{\\text{uranus}} \\simeq 2 \\cdot 10^{76}$, $l_{\\text{neptune}} \\simeq 2 \\cdot 10^{76}$, $l_{\\text{pluto}} \\simeq 3 \\cdot 10^{72}$. Even though the maximality of $L$ and $L_z$ are automatic from the classical description, it is far from obvious why the same should result from the more fundamental quantum treatment, as noted below.\n\t\n\tFor states with $l = l_{\\max} = n-1$ and $m = \\pm l$: i) There is only one peak, at $r = \\tilde{r}$, for the radial probability density, and the \"spread\" (variance) in the $r$-direction is given by\\footnote{The hydrogen wavefunctions for the gravitational case give $\\langle r^2 \\rangle = [5n^2 + 1 -3l(l+1)] n^2 b_0^2 /2$ and $\\langle r \\rangle = [3n^2 - l(l+1)]b_0 /2$ .} $\\Delta r =\\sqrt{\\langle r^2 \\rangle - \\langle r \\rangle^2} \\simeq n^{3/2}\tb_0 /2$. For the Earth-Sun system it means $\\Delta r \\simeq 10^{-26}$ [m], ii) The angular $\\theta$-part of the wavefunction for maximal $m$-quantum number $|m| = l$, is $\\propto \\sin^{l}\\theta$. The probability density thus goes as $\\sin^{2l} \\theta$ in the $\\theta$-direction, meaning that only $\\theta = \\pi /2$ is non-vanishing for large $l$. The azimuthal ($\\phi$) part of the angular wavefunction $Y_{lm}$ is purely imaginary, making it drop out of the probability density, so that \\textit{all} values of $\\phi$ are equally likely. (This $\\phi$-symmetry is a consequence\tof conservation of angular momentum in a central potential.) The total planetary probability density is thus \"doughnut\" (torus-like) shaped, narrowly peaking around the classical trajectory.\n\t\n\tSo, at first sight, it seems like the solar system is perfectly described as a quantum gravitational system. It even seems reasonable. Gravity totally dominates as all other forces, especially the only other known force with infinite reach, the electromagnetic, cancel due to charge neutrality. The solar system could thus be seen as a test-vehicle for quantum gravity. In the\tsolar system the Sun totally dominates the gravitational field, making the central field approximation an excellent one, even though it in principle is an N-body problem. Contrast this to the case of multi-electron atoms in atomic physics where all electrons\tcarry the same charge ($1/N$ of the charge of the nucleus), making the central field approximation a very bad one.\n\t\n\tHowever, from a quantum gravity standpoint, the system could be in any and all of the degenerate states, and usually at the same time, so typical for quantum mechanical superposition. Even for given energy and angular momentum there is no reason for the planets to be in any particular eigenstate at all of the $2l +1$\tallowed, and certainly not exclusively $m = \\pm l$. The radial\tprobability distribution in general has $n-l$ maxima. Thus, only for $l = l_{\\max} = n-1$ has it got a unique, highly peaked maximum. The degeneracy for a given $n$ is $n^2$. Whenever $l < l_{\\max}$, the radial wave function is highly oscillatory in $r$ as it has $n-l$ nodes. The same goes for the angular distribution as there in general are $l-m$ nodes in the $\\theta$-direction. For a general $R_{nl} Y_{lm}$ the planets could be \"all over the place\", and if this weren't bad enough, according to quantum mechanics the solar system more probable than not should be in simultaneous, co-existing superposed states with different quantum numbers as is generic in atomic physics. Consequently, Newtonian quantum gravity cannot solve the quantum mechanical measurement problem, perhaps because it lacks the non-linear terms conjectured to be needed.\n\t\n\tTo get the innermost allowed physical orbit for any \"test-particle\", $m$, we must impose the physical restriction that the binding energy cannot exceed the test particle energy, thus:\n\t\n\tAs $E_g$ can be written:\n\t\n\twe get:\n\t\n\twhere $R_S = 2GM/c^2$ is the Schwarzschild radius. The expression $b_0 (\\min)$ gives a limit for $b_0$ of the system to be physically attainable. It is amusing to see how close $b_0 (\\min)$ is to $R_S$ and one cannot help speculate that a more complete theory of quantum gravity could ensure that $r> R_S$ always, and thus forbid Black Holes altogether\\footnote{For the hydrogen atom the corresponding value is $a_0 (\\min) \\simeq 1.4 \\cdot 10^{-15}$ [m], or one-half the \"classical electron radius\", whereas $R_S \\simeq 10^{-53}$ [m], so that $a_0 (\\min) \\gg R_S$. But we implicitly already knew that. The Coulomb force does not turn atoms into Black Holes.}. The object $M$ must be put together somehow, but if $r_{\\min} > R_S$ it can never accrete enough matter to become a Black Hole, as the in-falling mass (energy) instead will be radiated away in its totality (in gravitons if they exist...), making a Black Hole state impossible\\footnote{For the classical case, the relation is even closer, $GmM/r_{\\min} = mc^2$, giving $r_{\\min} = R_S /2$, but then\tone cannot really speak of energy being carried away by gravitons.}. This would, in an unexpected way, resolve the Black Hole information loss paradox. Even though $r=R_S$ represents no real singularity, as it can be removed by a coordinate transformation, anything moving inside $r < R_S$ will, according to classical general relativity, in a (short) finite proper time reach the true singularity at $r=0$. If quantum\tgravity could ensure that $r > R_S$ always, gravity would of course be singularity free.\n\t\n\tLet us also briefly look at radiative transitions. From the dipole \tapproximation in atomic physics an elementary quantum (photon) transition requires $\\Delta l = \\pm 1$. A quadrupole (graviton) approximation in quantum gravity instead requires $\\Delta l = \\pm 2$. So, a typical elementary energy transfer in a highly excited, gravitationally bound 2-body quantum gravitational system is:\n\t\n\tFor the Earth-Sun system this means $\\Delta E \\simeq 2 \\cdot 10^{-20}$ [eV], carried by a graviton with frequency $\\nu \\simeq 5 \\cdot 10^{-6}$ [Hz], and wavelength $\\lambda \\simeq 6 \\cdot 10^{13}$ [m] $\\simeq 400$ [AU] ($1$ AU being for recall the mean distance between the Earth and Sun).\n\t\n\tThe average time required for each elementary quantum gravity transition to take place can be estimated roughly by $\\Delta t\\sim \\hbar/\\Delta E \\simeq 3 \\cdot 10^4$ [s] $\\simeq$ 8h 20min.\tThus the power radiated by a spontaneously emitted individual graviton is very roughly $\\sim 10^{-43}$ [W], compared to the\nprediction from the usual quadrupole formula (first non-vanishing contribution) in classical general relativity of $\\simeq 300$ [W] for the total power. We also see that the gravitational force is not really conservative, even in the static Newtonian approximation, but the difference is exceedingly small in the\tSun-Earth system. The changes in kinetic and potential energies do not exactly balance, $\\Delta K \\neq \\Delta U$, the difference being carried away by gravitons in steps of $\\Delta l = 2$. Also,\tin quantum gravity there is gravitational radiation even in the spherically symmetric case, which is forbidden according to the classical general relativistic description.\n\t\n\tLet us now return to the experiment with neutrons in the gravitational field of the Earth, claiming to have seen, for the first time, quantum gravitational states in the potential well formed by the approximately linear gravitational\tpotential near the Earth surface and a horizontal neutron mirror. An adjustable vertical gap between the mirror and a parallel neutron absorber above was found to be non-transparent for traversing neutrons for separations less than $\\sim 15\\;[\\mu \\text{m}]$ (essentially due to the fact that the neutron ground state wavefunction then overlaps the absorber). As the neutron in such a well, from solving the Schr\\\"{o}dinger equation, has a ground state wavefunction peaking at $\\sim 10 \\;[\\mu \\text{m}]$, with a corresponding energy of $\\simeq 1.4 \\cdot 10^{-12}$ [eV], the experimental result is interpreted to implicitly having verified, for the first time, a gravitational quantum state.\n\t\n\tIf we instead analyse the experiment in the framework of the present article, the same experimental setup gives $b_0 \\simeq 9.5 \\cdot 10^{-30}$ [m], $E_g \\simeq 2.2 \\cdot 10^{35}$ [eV]. Close to the Earth's surface, $\\tilde{r} \\simeq R_{\\oplus} \\simeq 6.4 \\cdot 10^6$ [m], the radius of the earth, giving $n \\simeq 8.2 \\cdot 10^{17}$, resulting in a typical energy for an elementary quantum gravity transition $\\Delta E \\simeq 4 E_g /n^3 \\simeq 1.6 \\cdot 10^{-18}$ [eV]. For a cavity of $\\Delta \\tilde{r} = 15 \\;[\\mu \\text{m}]$, and $n \\gg \\Delta n \\gg 1$, one gets $\\Delta E = E_g b_0 \\Delta \\tilde{r} /\\tilde{r}^2 \\simeq 0.7 \\cdot 10^{-12}$ [eV] $=0.7$ [peV], to be compared to the value $1.4$ [peV]. Even though the present treatment gives a similar value for the required energy, it need \\textit{not} be the result of a \\textit{single} quantum gravity state, but rather $\\leq 10^6$ gravitons can be emitted/absorbed. From the treatment in this article it is thus \tnot self-evident to see why the experimental apparatus should be non-transparent to neutrons for\n\tvertical separations $\\Delta h < 15 \\;[\\mu \\text{m}]$.\n\t\n\tTo appreciate the potential importance of this, let us digress briefly on the equivalence principle, the main conceptual pillar of general relativity. A classic example for illustrating it\tinvolves two rockets: One rocket stands firmly on the surface of the Earth, while the other accelerates constantly in empty space\twith $a = g$. According to the equivalence principle there is no \tway to, locally, distinguish one from the other if one is not allowed/able to make outside observations, meaning that acceleration and gravity are equivalent. However, in the quantum\tgravity case, for example considering a neutron inside each rocket, there certainly \\textit{is} a difference: For the rocket standing on the Earth the potential in the Schr\\\"{o}dinger equation is $V = -GmM/r$, resulting in normal quantization as\telaborated above. For the rocket accelerating in space, however, $V = 0$ and the energy levels are non-quantized (the neutron being a free particle until it hits the floor of the rocket). So the conclusion is that Newtonian quantum gravity breaks the equivalence principle. Furthermore, to understand why a\tfree-falling object classically accelerates radially downward in, e.g., the Earth's gravitational field, the gravitons must, by conservation of momentum, be emitted in the direction opposite to\tthe acceleration (at least the probability for emission must peak\tin that direction). Also, the quantum states with given $n,l,m$ are in principle inherently stable, an outside perturbation being needed for the transition rate to be different from zero, just\tlike in atomic physics. For macroscopic bodies this poses no problem as there in that case are abundant backgrounds of both\tgravitational and non-gravitational disturbances. For an elementary quantum gravity interaction, however, this problem seems much more severe, as the notion of free-fall loses its meaning as the quantum states become practically stable to spontaneous graviton emission. In fact, a bound quantum gravitational object does not fall at all as it is described by a stationary wavefunction, or a superposition of such.\n\t\n\tThus, the difference regarding quantized energy levels for an experiment with neutrons \"falling\" under the influence of Earth's gravity \\textit{with} mirror or \\textit{without} (above) shows that Newtonian quantum gravity is dependent on global boundary conditions, where the boundary in principle can lie arbitrarily far away. This comes as no surprise, as the Schrödinger equation models the gravitational interaction as instantaneous, contrasted with the case in general relativity where the behaviour in free-fall only depends on the local properties of mass-energy and the resulting space-time\tcurvature (out of which the mirror is not part due to its\tinherently non-gravitational interaction with the neutron) and causal connection as the gravitational interaction propagates with\tthe speed of light. However, as several experiments on entangled quantum states, starting with Clauser/Freedman and Aspect et al. , seem to be compatible with a non-local connection between quantum objects, this property of the Schr\\\"{o}dinger equation does not, at least for\tthe moment, seem to be a serious drawback for a theory of quantum gravity. One could even envisage a \"delayed choice\" experiment\t\\'{a} la Wheeler, where the mirror is removed/inserted before the\tneutron reaches its position, meaning that we could alter the \tenergy of the gravitons \\textit{after} they have been emitted.\n\t\n\t\\pagebreak\n\t\\subsection{Wheeler-DeWitt Quantum Cosmology}\n\tIn this subsection we will discuss some of the most interesting, profound, and topical speculations - and our stage of knowledge in this beginning of the 21st century... - about the earliest moments of the Universe. \n\t\n\t\"Why are we here?\" \"Where did it all come from?\" These two questions are perhaps the most fundamental to be asked by our species. In recent years, a number of physicists and cosmologists have begun to develop a new description of the ultimate system, the universe as a whole. Although the first question still lies beyond the purview of physics, \"quantum cosmology,\" an amalgam of quantum theory and classical relativistic cosmology, now offers a scientific answer to the second.\n\t\n\tBecause the underlying physics is still cloudy, it is not clear how (or even whether) one should approach the beginning time of the Universe. In spite of the fact that the underlying physics is not yet well formulated, we will attempt to give the reader a taste for some of the most exciting and potentially important research being pursued at present. The reader should understand that we are fishing in murky waters, and that the ideas we shall discuss here are both highly speculative and not yet unambiguously formulated. The faint-hearted reader may wish to skip to the Finale.\n\t\n\t\"\\NewTerm{Quantum cosmology}\\index{Quantum cosmology}\" is the attempt in theoretical physics to develop a quantum theory of the Universe. It employs a particular (and highly speculative) approach to the unification of Quantum Physics and General Relativity that was pioneered by John Wheeler and Bryce DeWitt in the 1960s. This approach attempts to answer open questions of classical physical cosmology, particularly those related to the first phases of the universe  Unfortunately, their theory is difficult to interpret as it does not refer directly to evolution in time, but rather to other properties of the Universe, such as its size. Remarkably, the Wheeler-DeWitt theory can be used to calculate the probability that the Universe came into being from nothing (ex-nihilo), though doing so involves making a number of assumptions. James Hartle and Stephen Hawking attempted this in 1983, basing their thinking on the assumption that the Universe should have no boundary in time or space. Others, using different assumptions have found a different answer and it is not clear which, if any, is correct. However it is interesting that one can make progress by assuming that the laws of physics are somehow beyond the Universe itself and can describe its creation. This is in distinct contrast to the philosophy of chaotic inflation, where it is assumed that the laws of physics are very much within the Universe, and may vary from place to place. \n\t\n\t\\begin{fquote}[Lawrence M. Krauss]Nothing can create something all the time due to the laws of quantum mechanics, and it's fascinatingly interesting!\n \t\\end{fquote}\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThe Wheeler-DeWitt quantum cosmology models mathematically described a Universe out of nothing (in the quantum sense of \"nothing\" obviously!) and without cause. But other models give mathematical possible answers of Universe without cause like the Einstein Cyclic Universe (the Universe always existed and cycles through a sequences of Big-Bang and Big-Crunch so there is no questioning about it's beginning), The Conformal Cyclic Cosmology (the Universe also always existed but finishes with an exponential expansion destructing matter to the states of photons and therefore cancels the concept of time and dimension!), the String Gas Cosmology in which there were cosmic Strings preceding the Big Bang due to Non-singular Ekpyrotic Cosmology, the Hartle-Hawking no-boundary proposal, the Loop Quantum Gravity in which there were spin foams producing a pre-Big-Bang branch to our Universe with Black Holes remnants, etc.\n\t\\end{tcolorbox}\n\n\tThe classical cosmology is based on General Relativity which describes the evolution of the Universe very well, as long as we do not approach the Big Bang. It is the gravitational singularity and the Planck time where relativity theory fails to provide what must be demanded of a final theory of space and time. Therefore, a theory is needed that integrates relativity theory and quantum theory. Such an approach is attempted for instance with the Loop Quantum Gravity, the String Theory and the Causal Set Theory.\n\t\n\tIn what follows we will attempt to determine the Wheeler–DeWitt equation that is a field equation. It is part of a theory that attempts to combine mathematically the ideas of Quantum Mechanics and General Relativity, a step towards a theory of Quantum Gravity. As always in this book we will start with a naive approach base on the Newtonian case, after we will complexify the method to apply it to FLRW metrics, finally we will generalize to the metric of any minisuperspace metric. \n\t\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tA universe which originated as a vacuum fluctuation must have as we know a zero total energy. A simple semi-Newtonian argument is that the positive mass-energy of matter is balanced by their negative gravitational potential, to within a factor of order unity. However actual observations of our observable Universe with our actual technologies seems to not corroborate this hypothesis.\n\t\\end{tcolorbox}\n\t\n\t\\subsubsection{Wheeler-Dewitt equation for Newtonian Universe}\n\tWe will use the Lagrangian formalism of Analytical Mechanics and some assumptions to obtain the cosmological differential equations analogous to Friedmann and Einstein equations, obtained from the theory of General Relativity. This method can be used to a Universe constituted of incoherent matter, that is, the cosmologic substratum is comprised of dust. It will help us to understand a more complex model that we will introduce further below for the FLRW Universe.\n\t\n\tQuantum Newtonian cosmology is the theoretical framework within which it is possible to find the wave function which predicts the behaviour of the Newtonian universe. This wave function for Newtonian cosmology is obtained in non-relativistic quantum mechanics, and thus, all we need is to solve the Schrödinger equation for the system under consideration.\n\t\n\tThe kinetic energy for the motion of a galaxy expressed in fixed rectangular coordinates (comoving) is a function only of  and, if the galaxy moves in a conservative force field, the potential energy is a function only of $\\dot{R}$. Thus, we can write using the notation of Analytical Mechanics:\n\t\n\tWith the usual expressions for the kinetic and gravitational potential energies, the Lagrangian $L(q,\\dot{q})$ for the motion of a galaxy of mass $m$ in the expansion is:\n\t\n\twhere we choose the generalized coordinates $q=R$ and $\\dot{q}=\\dot{R}$. In the relation above $M$ is the total mass of the universe, that we assume to be distributed in a sphere of radius $R$.\n\t\n\tIf we assume that there is a cosmological force on a particle (galaxy) of the gas, given as seen earlier above (page \\pageref{cosmological repuslive force}) by:\n\t\n\twe have an additional potential energy given by:\n\t\n\tThis implies that the Lagrangian changes to:\n\t\n\tNow, using the Euler-Lagrange equation far a conservative system, namely:\n\t\n\twe have:\n\t\n\tSubstituting the both relations above into the Euler-Lagrange, we obtain the equation of motion:\n\t\n\tSince the mass of the sphere is given by:\n\t\n\tthen the equation of motions becomes:\n\t\n\tTherefore, this is the Newtonian cosmological equation for the scale parameter $R$ that governs the universe expansion. This is a nice intermediate result as this equation is analogous to Einstein equation obtained from theory of General Relativity , in the case $P=0$, that is, dust cloud.\n\t\n\tAccording our previous assumption the time is homogeneous within an inertial reference frame. Therefore, the Lagrangian that describes a closed system, i.e., a system not interacting with anything outside the system, cannot depend explicitly on the time. In our case, the Lagrangian is likewise independent of the time, because the system is under the action of a uniform force field. Thus, the constant quantity of the motion is $H$, the Hamiltonian of the system, which is for recall given by:\n\t\n\tAs re-parametrization invariance implies vanishing Hamiltonian (\\SeeChapter{see section Analytical Mechanics page \\pageref{vanishing Hamiltonian}}) we must have:\n\t\n\tTherefore:\n\t\n\tRegrouping we get:\n\t\n\tWritten in term of the momentum:\n\t\n\twe get:\n\t\n\tLet us transform now that latter relation into an Hermitian operator such that we can build something of the form:\n\t\n\tFor this purpose we make the famous replacement:\n\t\n\tThen the \"\\NewTerm{Hamiltonian operator for a particle (or galaxy or whatever) moving in a Newtonian Universe}\" is given by :\n\t\n\tTherefore $H(a)\\Psi(a)=0$ will be written under the form of the \"\\NewTerm{Wheeler-DeWitt equation for a Newtonian Universe}\":\n\t\n\twhere we will consider that the wave function depends only on the scale factor $R$.\n\t\n\tIf we rewrite the above relation as:\n\t\n\twe recognise here a one-dimensional time-independent Schrödinger where the potential energy is given by:\n\t\n\t\n\t\\subsubsection{Wheeler-Dewitt equation for FLRW Universe}\n\tPresented below is a derivation of the Wheeler-DeWitt equation in the minisuperspace approximation\\footnote{An approximation which is sometimes taken is to only consider the largest wavelength modes of the order of the size of the Universe when studying cosmological models. This is the \"\\NewTerm{minisuperspace approximation}\\index{minisuperspace approximation}.} which also includes matter and radiation and arbitrary values of $k$.\n\n\tLet us recall that we have derived earlier above the following form of \nthe general Friedmann equations assuming a Friedmann-Lemaître-Robertson-Walker (FLRW) Universe:\n\t\n\tLet us also recall the Euler-Lagrange equation for a conservative system (\\SeeChapter{see section Analytical Mechanics page \\pageref{equations of movement}}):\n\t\n\tNow let suppose we put empirically (trial and error) a density Lagrangian (remember that the Hilbert-Einstein action deals with density Lagrangian!) for the FLRW Universe of the following form\\footnote{In facts it can be derived from the Einstein-Hilbert action with matter and cosmological constant and using the FLRW Ricci scalar.}:\n\t\n\twhere:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn some textbooks and simplified version of the above density Lagrangian can be found. First by choosing $k=1$ and distributing $-a^3$ in the square brackets and defining $1/a_0=\\frac{8\\pi G}{9c^2}\\left(\\rho+\\rho_\\text{vac}\\right)$:\n\t\n\tand in the worst case where the author write it in natural units, it simplifies to:\n\t\n\t\\end{tcolorbox}\n\tWith this the Lagrangian density has the unit of energy. Just let check that by rewriting the relation above but expliciting the units:\n\t\n\tSo to transform that into an energy $\\kappa$ must have the units of $[\\text{kg}\\cdot \\text{m}^{-1}]$ and this is exactly the units of $3\\pi c^2/4G$ (remember that the units of $G$ are $[\\text{m}^3\\cdot \\text{kg}^{-1}\\cdot \\text{s}^{-2}]$).\n\t\n\tWe have for the momentum:\n\t\n\tAnd:\n\t\n\tSubstituting into the Euler-Lagrange equation we get:\n\t\n\ti.e. (we see that we can eliminate the unit normalisation constant and the scale factor):\n\t\n\tWe assume that there is no time dependant variable (is one of the many plausible weakness of this model). Therefore:\n\t\n\tIf we divide both side by $a^2$ and rearrange we get:\n\t\n\tSo we fall back on the velocity equation \\eqref{velocity equation dewitt frw} and this justifies our initial choice!\n\t\n\tNow let us recall the hamiltonien (\\SeeChapter{see section Analytical Mechanics page \\pageref{hamiltonian function}}):\n\t\n\tTherefore in the case of one variable:\n\t\n\tThat is written in the current context:\n\t\n\tAs re-parametrization invariance implies vanishing Hamiltonian (\\SeeChapter{see section Analytical Mechanics page \\pageref{vanishing Hamiltonian}}) we have:\n\t\n\tWritten in term of the momentum and dividing both sides by $-\\kappa a^3$:\n\t\n\tWe get:\n\t\n\tLet us simplify it a bit more:\n\t\n\tLet us also transform now that latter relation into an Hermitian operator such that we can build something of the form:\n\t\n\tFor this purpose we make the famous replacement:\n\t\n\tThen the \"\\NewTerm{Hamiltonian operator for a particle (or galaxy or whatever) moving in a FLRW Universe}\" is given by :\n\t\n\tTherefore $\\mathcal{H}(a)\\Psi(a)=0$ will be written under the form of the \"\\NewTerm{Wheeler-DeWitt equation for a FLRW Universe}\":\n\t\n\twhere we will consider that the wave function depends only on the scale factor $a$.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn some papers or textbooks the above relation can be found in the following shape:\n\t\n\tLet us consider the expression for the energy density introduced earlier:\n\t\n\twhere for recall $A_{\\omega}=\\rho_{\\omega 0} a_{0}^{3(\\omega+1)}$ with $\\rho_{\\omega 0}$ being the value of $\\rho_{\\omega}$ at present time, and $\\omega$ is such that:\n\t\n\tThe energy density of the vacuum, $\\rho_{\\text{vac}}$, can be expressed, in terms of the cosmological constant, in the following form:\n\t\n\tNow, substituting all this in the WdW equation above we get:\n\t\n\twhere:\n\t\n\t\\end{tcolorbox}\n\t\n\tIf we rewrite the above relation as:\n\t\n\twe recognise here a one-dimensional time-independent Schrödinger equation for a particle with $1/2$ of the unit mass and where:\n\t\n\tNote that for small values of $a$ we can neglect the terms proportional to $a^4$ and therefore:\n\t\n\tIn this case, the solution of the WdW equation is given in terms of Bessel functions and the wave function approaches a constant for $a\\rightarrow 0$. On the other hand, for arbitrary values of $a$, the potential is not so simple, and as a consequence, the solutions of the WdW equation are more complicated and given in terms of Heun functions (see \\cite{ronveaux1995heun}).\n\t\n\tNote that when $a=0$ the universe corresponds to a quantum FRW universe with zero radius. In this case, the solution of the WdW equation approaches a constant and describes a state called \"nothing\\footnote{As we already know it from our study of Probabilities and we will see now form the Quantum Physics point of view the nothingness in the philosophical sense is a physical impossibility. So, a scientist who talks about \"nothingness\" is actually talking about a quantum vacuum.}\" in some literature. This state can be created by quantum mechanically  tunnelling\\index{quantum tunnelling} through the potential barrier that appears at $a=a_{0} \\neq 0$. And the reader must really keep in mind that quantum tunnelling can be crudely understood as a quantum effect that result from the Heisenberg uncertainty principle: a temporary upward fluctuation in the particle's energy sends it over the barrier.\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tFor the readers interested in further reading, we strongly recommend the following references: \\cite{vieira2016class} and \\cite{kolb2018early} and finally \\cite{vieira2015quantum}.\n\t\\end{tcolorbox}\n\tNow let us investigate a very simple special case of:\n\t\n\tFocusing on the potential energy term for $k=+1$ (closed three-sphere Universe) and in natural units:\n\t\n\tWith a slight change of notation (we discard the factor $4$ on the way...):\n\t\n\tThe shape of the potential is shown in the figure below, where, for convenience. The quantized FRWL universe is thus mathematically equivalent to a simple one-dimensional problem in non-relativistic quantum mechanics-the \"particle\" at position $a$ represents a universe with that value scale factor.\n\n\tThe region beneath the barrier, $0<a<a_0$, is classically forbidden to the zero-energy particle; the region $a\\geq a_0$ is classically allowed.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[scale=0.6]{img/cosmology/frwl_potential_close_universe.jpg}\n\t\\end{figure}\n\tIn principle any solution of the Wheeler-deWitt equation corresponds to a possible quantum state of the universe. It is also clear that the effects of the boundary conditions on the wave-function will act to severely restrict the class of possible solutions. In ordinary quantum mechanics these are determined by the physical context of the problem and some set of external conditions. In the case of the universe as a whole the situations is less clear, and in many approaches some suitable set of boundary conditions are postulated instead, based on general arguments involving concepts such as simplicity or economy.\n\t\n\tWe will go further in the topic the day we will have a gentle introduction to Heun's differential equations in this book.\n\n\t%to make section start on odd page\n\t\\newpage\n\t\\thispagestyle{empty}\n\t\\mbox{}\n\t\\section{String Theory}\\label{string theory}\n\t\\lettrine[lines=4]{\\color{BrickRed}I}t must be considered in this section that \"\\NewTerm{String Theory}\\index{String Theory}\" (and verbatim Superstring Theory) is currently - early 21st century - speculative and could not be verified (confirmed) or falsified by experience following the scientific method\\footnote{Notice that the name is also misleading. \"String Theory\" is not a theory actually but a \"Model\". Such a similar vocabulary issue also exist with the \"Standard Model\" that is not a model anymore since decades but a \"Theory\"!}. We should therefore take with caution the developments that follow and to be the most critical possible!\n\t\n\tIt is also a theory (we can not talk currently about \"model\") of unification of the forces that is not new since it soon have over thirty years and is trying to bridge the issues of the standard model of particles and also to unite General Relativity and quantum physics (which is not without difficulty since the latter is dependent on the background unlike General Relativity). It is one of the many theories that exist in modern physics and is trying in the early 21st century this unification (there are dozens of other more or less known).\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIf this subject is covered in the Cosmology chapter and not Atomistic one it is only for an pedagogical reason. Indeed, the basic formalism of string theory is much closer to relativistic mechanics (special and General Relativity) than that of the wave quantum physics or quantum physics fields. It seemed therefore more suited to this day (!), to provide continuity in the mathematical formalism and its interpretation rather than a thematic continuity with a relatively different approach than the usual formalism of quantum physics.\n\t\\end{tcolorbox}\n\t\n\tWell, string theory is a theoretical framework in which the point-like particles of particle physics are replaced by one-dimensional objects named \"\\NewTerm{strings}\\index{strings}\" as its name suggest it... It describes how these strings propagate through space and interact with each other. On distance scales larger than the string scale, a string looks just like an ordinary particle, with its mass, charge, and other properties determined by the vibrational state of the string. In string theory, one of the many vibrational states of the string corresponds to the (hypothesized) graviton, a quantum mechanical particle that maybe carries gravity. Thus string theory is a theory of quantum gravity.\n\n\tString theory is a broad and varied subject that attempts to address a number of deep questions of fundamental physics. String theory has been applied to a variety of problems in Black Hole physics, early universe cosmology, nuclear physics, and condensed matter physics, and it has stimulated a number of major developments in pure mathematics. Because string theory potentially provides a unified description of gravity and particle physics, it is a candidate for a theory of everything, a self-contained mathematical model that describes all fundamental forces and forms of matter. Despite much work on these problems, it is not known to what extent string theory describes the real world or how much freedom the theory allows to choose the details.\n\t\n\tThe undeniable advantage of string theory, besides the fact that mathematically it is quite indigestible but not really worse than General Relativity, is that it avoids in a certain order... many singularities in the calculations unlike other contemporary theories that consider the objects as points (so zero volume and length...).\n\t\n\tThe undeniable advantage of string theory, besides the fact that mathematically it is quite indigestible but not really worse than General Relativity, is that it avoids in a certain order ... many singularities in the calculations unlike other contemporary theories that consider the objects as points (so zero volume and length...).\n\t\n\tThis theory, although aesthetic and remarkable in that it uses for its calculations bases foundations that have over 200 years, is lacking in our opinion to work with successive analogies, as we shall see, with current relativistic and quantum theories. While this is not dramatic in itself, the theory may seem to lose a little of its own autonomy even though the fact it is not. The reader should therefore not be badly surprised in the development that will follow...\n\t\n\tThe main particularity of string theory is that his ambition does not stop to this reconciliation, but it claims to successfully unify the four known elementary interactions, we speak therefore about \"theory of everything\", while staying on two hypothesis/assumptions:\n\t\n\t\\begin{enumerate}\n\t\t\\item[H1.] The fundamental building blocks of the universe would not be point particles, but a variety of vibrating string having a given stress in the manner of an elastic. What we perceive as particles with special characteristics (mass, charge, etc.) are merely distinct strings vibrating differently. With this assumption, string theories admit a minimum scale and make it easy to avoid the emergence of some infinite amounts that are inevitable in usual quantum field theories.\n\t\t\\item[H2.] The Universe could contain more than three spatial dimensions. Some of them, folded on themselves, being invisible to our scales (by a procedure named \"\\NewTerm{dimensional reduction}\\index{dimensional reduction}\").\n\t\\end{enumerate}\n\t\n\tDespite promising first partial promising results and also remarkable rich mathematical background the string theory remains however incomplete. On the one hand, a multitude of solutions to string theory equations exist, which poses a selection problem for our Universe and, secondly, even if many similar models were obtained, none of them allows to reproduce accurately the standard model of particle physics...\n\t\n\tThat said ... let us begin our initiation:\n\t\n\t\\subsection{Wave equation of a transversal string}\n\tThe aim here will be in a first step to determine the non-relativistic wave equation of a string excited transversely using calculations that we made in the section of Wave Mechanics. Once this work done, we will pass to the study of relativistic strings and see their wave equation, as well as the non-relativistic version, can be assimilated to the current conservation equation we had proved in the section of Electrodynamics.\n\t\n\tWe begin by recalling the form of the action that we proved in the section of Wave Mechanics for a non-relativistic string:\n\t\n\twith:\n\t\n\tNow, in the same way as we did in section of Analytic Mechanics (and in that of Quantum Field Theory), we will define a notation by an analogy to the canonical moments of the string:\n\t\n\twith $y'=\\partial y/\\partial x$. It is simply the derivatives from the Lagrangian density with respectively the first and second argument. More explicitly, we get then directly by doing the calculation (\\SeeChapter{see section Wave Mechanics page \\pageref{lagrangian desnity of a string}}):\n\t\n\tSo if we rewrite the variational of the action we obtained in the section of Wave Mechanics with this canonical notation, we get:\n\t\n\tMaking use of the same methods as in the section of Wave Mechanics, our variational can be express after simplification again in the form of three terms:\n\t\n\tThe conditions to find the extreme value (according to the principle of least action) are the same as those seen in the section of Wave Mechanics. Thus, for the third term, we therefore have the wave equation of a transversely excited string with the canonical form given by:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIt obviously should be noted that this form of writing will greatly facilitate our work!\n\t\\end{tcolorbox}\n\tIt must be observed (as it is remarkable!) also that as in the section of Analytical Mechanics, the canonical moment $\\mathcal{P}^t$ as defined above, coincides perfectly (the hazard makes things well) with the density momentum that we obtained in the section of Wave Mechanics. Effectively:\n\t\n\tThus, by analogy with the Analytical Mechanics (where we recall, the derivative of the Lagrangian with respect to the speed gives the momentum), $\\dot{y}$ plays well the role of speed and thus the derivative of the Lagrangian density by this latter gives the momentum density $\\mathcal{P}^t$!!!\n\t\n\tRemember also another point that has been seen in the section of Wave Mechanics, the extremum of the action ($\\delta S=0$) imposes use the Neumann boundary conditions, which leads us to write $\\mathcal{P}^x=0$.\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tIn the context of string theory to relativistic with more than 3 dimensions, it is possible to generalize the concept of boundary conditions considering the constraints in space like hypersurfaces named Dp-branes with $p$ dimensions. The usual Dirichlet boundary conditions then correspond to the situation where the ends of a strings are constraint by a 0-brane. The Neumann condition for a free string in $p$ dimensions corresponds to a constraint on a Dp-brane.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/dp_brane.jpg}\t\n\t\t\\caption[]{Illustration of Dp-branes}\n\t\\end{figure}\n\t\\end{tcolorbox}\n\t\n\t\\subsection{Non-relativistic Wave equation of a transversal string}\n\tWe will now determine the action of a relativistic string. We can, to lay the foundations of our study, remember that a point particle draws a line in space-time (each point on the line is marked by a time coordinate and three space coordinates). Therefore, by extension, a string that is a two-dimensional element (if we consider it with no thickness) plots a surface in the space-time.\n\t\n\tThus, just like the line that draw a point particle in space-time is named a \"world line\" (\\SeeChapter{see section Special Relativity page \\pageref{world line}}), the surface traced by a string will by analogy be named a \"\\NewTerm{surface Universe}\\index{surface Universe}\".\n\t\n\tA string in a closed space-time Minkowski trace, for example, a tube, while an open string trace a band:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/open_closed_string.jpg}\t\n\t\t\\caption{Universe surface generated by respectively an open/closed string}\n\t\\end{figure}\n\tin the figure above, with two spatial dimensions and one implicit temporal dimension, the string is motionless in our current space. It moves in space-time (as time goes on the vertical axis) but not in space in the example above (it would take an additional spatial component to see such a movement).\n\t\\begin{tcolorbox}[title=Remarks,colframe=black,arc=10pt]\n\t\\textbf{R1.} Remember that the diagram above is in three dimensions while the space-time has four dimensions.\\\\\n\t\n\t\\textbf{R2.} Remember also that the time vector of the orthogonal basis is always perpendicular to all other spatial components (this remark will be useful during our proof of the Nambu-Goto action).\n\t\\end{tcolorbox}\n\t\n\tDuring our proof of the equation of motion in the section of General Relativity, we reparameterized the particle's Universe line with a parameter that was the proper time of the particle $t$. Indeed, you only have to remember parametric equations that represent curves. For example with Maple 4.00b:\n\t\n\t\\texttt{>with(plots):}\\\\\n\t\\texttt{>spacecurve([cos(t),sin(t),t],t=0..4*Pi,axes=boxed);}\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/curve_parametrization.jpg}\t\n\t\t\\caption{Elementary illustrated refresh of a parametric curve}\n\t\\end{figure}\n\tand the same procedure is valid for a line in four dimensions (time + space).\n\t\n\tWe were thus arrived to construct the expression of the action $S$ of it before applying the variational principle.\n\t\n\tWe will do the same for a relativistic string with the difference that we will re-parametrized the surfaces generated by the strings this time. The constraints we impose are that the chosen parameters will also have to be (in reference to the case of the particle) relativistic invariants.\n\t\n\tAs we have therefore seen in the section of General Relativity, a world line can be re-parametrized naturally using only one parameter (curvilinear abscissa). A surface in space, however, is a two-dimensional object, we assume by extension that it requires two parameters $\\zeta^1,\\zeta^2$ (one more) to be described completely.\n\t\n\tIndeed, we guess, that one of the two parameters will be the proper time (to make the surface evolve in the time), the second parameter will give a \"thickness\" of what would be only a Universe line if it did not exist. It would be sufficient in a three-dimensional space that the second parameter had, to generate a surface, the dimensions of length but in the four dimension space-time the second parameter must have the units of a surface.\n\t\n\tGiven a parametrized surface, we can draw on them isolines of the parameters (lines where the two parameters $\\zeta_,\\zeta_2$ are constant over the entire surface). These contours cover the surface as a grid (see figure a little bit further below).\n\t\n\tThe parametric equation of a volume in space requires three parameters as we saw in the section of Analytical Geometry. Thus, if a parametrized area in Euclidean space can be represented by a vector of the type:\n\t\n\tduring a re-parametrization and making use of the tensor notation of Minkowski space-time as seen in the section of General Relativity, we have (by restricting for the moment to the particular case of two spatial dimensions and one of time):\n\t\n\tThus, the surface is the image of the parameters $(\\xi^1,\\xi^2)$. Alternatively, we can see the components $(\\xi^1,\\xi^2)$ as the time and space coordinates of the surface, at least locally!\n\t\n\tWe now want to calculate the area of an element of any type of space in the same way as we did for the curvilinear abscissa of any world line in the section of General Relativity. This raises the question of the form of the differential surface element??? Should we take the multiplication of the differential of the two previously selected parameters as being a square, rectangle, circle, or other?\n\t\n\tIn fact, we will put our choice on a parallelogram! This choice may seem completely arbitrary for now but as we'll see a few lines later, this choice coincides for mathematical reasons with that we name the \"\\NewTerm{induced metric}\\index{induced metric}\" of the surface itself (rather remarkable result!).\n\t\n\tThus, let us denote by $\\mathrm{d}\\vec{v}_1$ and $\\mathrm{d}\\vec{v}_2$ the sides of the parallelogram. They are the image by $\\vec{x}$ of the couples $(\\xi^1,0)$ and $(0,\\xi^2)$ respectively:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/elementary_surface_study_configuration.jpg}\t\n\t\t\\caption{Configuration for the study of an elementary surface element}\n\t\\end{figure}\n\tTherefore we can write:\n\t\n\tand then:\n\t\n\tNow let us calculate the surface $\\mathrm{d}A$ (we will not take the letter $S$ to avoid confusion with the variable representing the action in this section) of the parallelogram (\\SeeChapter{see section Vector Calculus page \\pageref{cross product as surface parallelogram}}):\n\t\n\tusing the dot product, this can be rewritten as:\n\t\n\tusing the previously established relations this can be written:\n\t\n\tthe latter relation is the general shape of a surface element of a parametrized pattern. The total surface is obviously given by:\n\t\n\tJust as in the framework of the study of the principle of least action (\\SeeChapter{see section Analytical Mechanics page \\pageref{variational principle}}) we searched the optimum path for a particle browsing a universe line, for a string, we have to search for the optimum of the surface $A$ by minimizing the function $\\vec{x}=\\left(\\xi^1,\\xi^2\\right)$.\n\t\n\tThis latter form is, however, a little heavy and does not show anything known particularly or is not similar to any form already known in another field of physics. We will see, however that by digging a little bit however it is possible to get something pretty interesting.\n\t\n\tConsider now a vector $\\mathrm{d}\\vec{x}$ and its squared length (norm) given by the scalar product:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis approach of separating the wave function into the composition of a wave function of the center of mass and the relative movement is also used in the context of the study of poly-electronic atoms, but with one difference: as the nucleus is much more massive than the processing electrons (in approximation ...), the center of mass is assimilated to the nucleus of the atom and the relative motion to the entire electron cloud. This approximate approach is well known under the designation \"\\NewTerm{Born-Oppenheimer approximation}\\index{Born-Oppenheimer approximation}\".\n\t\\end{tcolorbox}\n\tCareful in the future not to \"see\" the $s$ as squared in the $\\mathrm{d}s$ (as it is the case in Special and General Relativity) but remember well that it is the $\\mathrm{s}$ that is squared (the notation may lead to confusion...).\n\t\n\tThus, the squared length of $\\mathrm{d}\\vec{x}$ can be expressed in tensor form:\n\t\n\twhat we will note by convention in the future:\n\t\n\tThe quantity $g_{ij}(\\xi)$  is named the \"\\NewTerm{induced metric of the parametrized area}\\index{induced metric of the parametrized area}\" (because contains a scalar product which quite generally uses a metric... hence the term \"induced\") and is therefore a matrix of dimension $2 \\times 2$. It is obvious that the choice of this name comes from the resemblance with the usual metric as we have defined in our study of tensor calculus and from its use in special and General Relativity.\n\t\n\tThe matrix $g_{ij}(\\xi)$ has therefore by design and definition the form:\n\t\n\tNow let us come back to our expression of the surface generated by the string:\n\t\n\tand let us quickly calculate the determinant (\\SeeChapter{see section Linear Algebra page \\pageref{determinant}}) of the matrix $g_{ij}(\\xi)$:\n\t\n\tand so what? Well here it is! $A$ can now been expressed as:\n\t\n\tThus, the choice of the parallelogram as elementary surface is best explained here!\n\t\n\tNow we will adopt the traditional notations of string theory in relation to the expression of the surface. Thus, just as the time-space coordinates are described in Special Relativity the space-time four-vector:\n\t\n\twe will describe the surfaces Universe by (we now turn to the notation making use of the four dimensions of space-time):\n\t\n\tThis notation will save us in the future to have to confuse, if the theory leads us there, the traditional space-time coordinates $x^\\mu$ with the image function of the surface Universe $x^\\mu(\\tau,\\sigma)$  and this especial because physicists being sometimes a little lazy shorten this latter $x^\\mu$... hence the choice of the capital letter.\n\t\n\tIt is then much more appropriate and wise to change the notation.\n\t\n\tFrom now on we will name \"\\NewTerm{string coordinates}\\index{string coordinates}\" the surface Universe described by $X^\\mu$.\n\t\n\tThis small change in notation obviously not change the interpretation of the image of the function. Given a couple $(\\tau,\\sigma)$ involving proper-time element and surface element of the pre-image, this point is projected onto a surface element of the space-time coordinates of the string:\n\t\n\t\n\t\\subsubsection{Nambu-Goto Action}\n\tThe Nambu–Goto action is the simplest invariant action in bosonic string theory, and is also used in other theories that investigate string-like objects (for example, cosmic strings). It is the starting point of the analysis of zero-thickness (infinitely thin) string behaviour, using the principles of Lagrangian mechanics. Just as the action for a free point particle is proportional to its proper time—i.e., the \"length\" of its world-line—a relativistic string's action is proportional to the area of the sheet which the string traces as it travels through space-time.\n\t\n\tIn the case of a Universe surface the parameters are then by convention $\\tau$ and $\\sigma$, where as in special and General Relativity, the proper time may be in the range:\n\t\n\tthe second can only be positive since this is a surface:\n\t\n\tand the coordinates of this surface corresponding to the parameter space is therefore:\n\t\n\twhere once again, for recall, the parameter $\\tau$ is considered as the variable describing the time (there must be one!), and $\\sigma$ the variable describing the spatial extension of a string (that is to say that the condition $\\sigma\\in]0,\\sigma_1[$ involving the finite length of the string).\n\n\tThe parameters $(\\tau,\\sigma)$ describe therefore a surface in the space of pre-images:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/space_time_surface_parametrization.jpg}\t\n\t\t\\caption{Parametrization of a space-time surface}\n\t\\end{figure}\n\tThe ends of the string have a constant value $\\sigma$. However, as time passes and that the ends of the string on the Universe surface move we must notice an essential condition of the Universe surface concerning the both ends of an open string:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis condition is made on the component $X^0$ because it corresponds to the component $x^0$ of the space-time four-vector which is nothing else, in natural units, $t$ (the proper time). Therefore, time passes and is never constant, this is why we  impose this derivative as being non-zero.\n\t\\end{tcolorbox}\n\tAnd using the standard conventions in physics for writing the derivatives with respect to time or space components, we agree to adopt also now the following notations:\n\t\n\tsince as:\n\t\n\tthen:\n\t\n\tThe surface is therefore written:\n\t\n\tHowever, there is a problem here! Indeed, let us look if the radicand (term under the root) has a tangible physical reality ...\n\n\tFor this, we must first consider the left side of the figure below representing the surface patch described by an open string:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/surface_patch_for_study_radicand_string_action.jpg}\t\n\t\\end{figure}\n\tAt each point $P$ of this surface patch (assumed differentiable at every point) there are endless tangents, all in the same plane, which we will denote for example by $\\vec{v}$ and thus form a surface tangent at $P$.\n\n\tNow, as the space in which the surface patch of the string held in a spatial and temporal orthonormal basis, the tangent vectors $\\vec{v}$ can then in turn be decomposed into a two-dimensional spatial and temporal local orthogonal base at the point $P$ such that the vectors of the base are two vectors (see our study of surface patches in the section of Differential Geometry):\n\t\n\tall other tangent vectors expressing as a linear combination thereof.\n\t\n\tHowever, a problem remains in our decomposition (...): the unit vectors of the local orthogonal basis at $P$ have units that differ... For this let us add a dimensional factor  to the spatial component (this is arbitrary because the conclusion will be the same regardless of the component on which you put the sizing factor) as we did in Special Relativity with the time axis:\n\t\n\tThis dimensional factor can also be used to get all the tangent vectors such as:\n\t\n\tIndeed, if $\\lambda\\in [-\\infty,+\\infty]$, then for $\\lambda=0$ we get the vector $\\partial X^\\mu/\\partial \\tau$ and for $\\lambda=+\\infty$ the vector $\\partial X^\\mu/\\partial \\sigma$ . And all intermediate values, we get all the tangent vectors as shown on the left side of the previous figure.\n\n\tNow, let us recall that we saw in the section of Special Relativity that there exist according to the curvilinear abscissa:\n\t\n\tof the Universe line of the light type ($\\mathrm{d}s^2$), space ($\\mathrm{d}s^2<0$) or time ($\\mathrm{d}s^2>0$) if we consider the four-vectors $x^\\mu$.\n\n\tIt must be true by analogy the same for the tangent vectors to the surface and given by:\n\t\n\tTherefore:\n\t\n\tthat corresponds to an equation of the second degree on $\\lambda$, and that must, to have negative values (Universe surface patch of the type of space) or positive (Universe surface type of the type time) have at least two roots (see the right part of the previous figure ). This brings us back to the condition that the discriminant is strictly positive (\\SeeChapter{see section Calculus page \\pageref{discriminant}}):\n\t\n\tTherefore:\n\t\n\tInto condensed form this is equivalent as writing:\n\t\n\tThe surface must therefore be written as:\n\t\n\tif we want the radicand has a physical sense.\n\t\n\tBy analogy with the Lagrangian of General Relativity we write the latter:\n\t\n\tthat we will justify a little more robustly further below.\n\t\n\tRecall now that the action $S$ of a point particle is proportional to its world line (proper time). Thus by analogy, the action $S$ of string will be proportional to the Universe area:\n\t\n\twhich gives:\n\t\n\tWhich brings us very frequently in the literature to find the action of a string in the following form:\n\t\n\tor more stylized:\n\t\n\tRelation to compare with the Lagrangian of a free particle (\\SeeChapter{see section Analytical Mechanics page \\pageref{free lagrangian}}) and with the Lagrangian density of a field (\\SeeChapter{see section Quantum Field Theory page \\pageref{lagrangian density}}):\n\t\n\tThe functional $S$ has for units the one of a surface. This because the $X^\\mu$ have a unit of length and inside the root each is at the fourth power and the units of $\\tau,s\\sigma$ cancel between the inner root and the differential that are outside it.\n\t\n\tNow, by definition of the action, the units that we have to get should match that of energy multiplied by time. That is to say joules [J] or using the international system of units $[\\text{kg}\\cdot\\text{m}^2\\cdot s^{-1}]$. For now, we have:\n\t\n\t\tTo get to the action units we want, then we have to multiply the expression of the surface $A$ by a quantity whose units are $[\\text{kg}\\cdot\\text{s}^{-1}]$. To chose these quantities, we will inspire us from our study of Wave Mechanics. When we worked with (non-relativistic) strings we saw that the properties to be considered were the stress and the velocity of string wave propagation. We'll try to take the following stress/speed ratio:\n\t\n\twhere appears therefore that the stress of the string at rest $T_0$ and the speed of light $c$. \n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tThis is similar to the point material physics where in the action we find the rest mass (equivalent to the tension at rest of the string) and the speed of light (\\SeeChapter{see section Special Relativity page \\pageref{postulate of invariance}}).\n\t\\end{tcolorbox}\n\tThus, the \"\\NewTerm{Nambu-Goto action}\\index{Nambu-Goto action}\" can now be written:\n\t\n\t\\begin{tcolorbox}[title=Remark,colframe=black,arc=10pt]\n\tWe will prove later why we put a factor \"$-$\". However, a small analogy with the action of a point particle, for which we also have a \"$-$\" sign (\\SeeChapter{see section Special Relativity page \\pageref{relativistic lagrangien}}), can easily be done...\n\t\\end{tcolorbox}\n\tLet us define for what will follow:\n\t\n\tWhat we can also write in matrix form:\n\t\n\tusing the determinant of the matrix, it comes:\n\t\n\tSo we can then write the action of a relativistic string in the final following condensed form:\n\t\n\twhich is nothing else than the \"\\NewTerm{Nambu-Goto condensed form}\\index{Nambu-Goto condensed form}\" form of a relativistic string.\n\t\n\tWe will now obtain the equation of motion by varying the action. For this, we will exactly inspire us of the methods seen when determining the non-relativistic wave equation of string in the section of Wave Mechanics.\n\n\tThus, we rewrite the Nambu-Goto action by defining a Lagrangian density $\\mathcal{L}$ such that:\n\t\n\twhere $\\mathcal{L}$ is therefore defined by:\n\t\n\tWe will now apply the variational principle on the action in order to get the equation of movement of a string. The development and approximation are perfectly similar to those seen at the beginning of this section for the non-relativistic string. Let us recall that we obtained as Lagrangian density and as an expression of the action:\n\t\n\tand that the application of variational gave us:\n\t\n\tBut what we did not see in the section Wave Mechanics is that the latter relation could easily be written also from the Lagrangian density:\n\t\n\tTherefore, for the relativistic string, we have an identical form by applying developments in all points similar (even if the Lagrangian density has a different form):\n\t\n\tand as we did at the beginning of this section for non-relativistic strings, we will introduce the canonical momentum (pulse density/momentum if you prefer) of the string by choosing for the notation:\n\t\n\twhere in the details, we get very easily (it's a simple derivative but if you wish by contacting us, we can detail the developments as always in this book) the longitudinal and transverse momentum:\n\t\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/atomistic/string_momentum_density.jpg}\t\n\t\\end{figure}\n\tby making use of this notation, we can then write:\n\t\n\tMaking use once again of exactly the same methods as those seen in the section Wave Mechanics, our variational can be written, after simplification, again in the form of three terms:\n\t\n\tThe conditions to find the extremum (according to the principle of least action) remain the same as in Wave Mechanics. Thus, for the third term, we have well the wave equation of a transversely excited string with the following canonical form:\n\t\n\tAs far as we know this equation is horribly difficult to solve but choosing an appropriate parametrization can nevertheless simplify the task.\n\t\n\t\\subsection{Lagrangian of a String}\n\tLet us recall that we have:\n\t\n\tand that with this choice, we have:\n\t\n\tNow let use what we have seen in section of Differential Geometry with the Frenet's triad:\n\t\n\twhere $\\vec{T}$ is the tangent to the Universe surface at a time $t$ at the  of a given point. We had also notice in this same section that by definition: where $\\vec{T}$ is the tangent to the Universe surface at a time $t$ at the neighbourhood of a given point. We had also notice in this same section that by definition:\n\t\n\tBut we can write:\n\t\n\twhere it should be remembered that $\\partial \\vec{X}/\\partial \\sigma$ is taken at a fixed time $t$. As the lines of the surface Universe of constant $ $t describe the string, then $\\partial \\vec{X}/\\partial \\sigma$ is tangent to the string.\n\n\tAnd as:\n\t\n\tThen $\\mathrm{d}\\vec{X}/\\mathrm{d}s$ is collinear to $\\partial \\vec{X}/\\partial \\sigma$ and thus also tangential to the string (information that we did not have a few lines before!). These small discovers being made, let us go back to:\n\t\n\tit already gets a little more interesting!\n\n\tNow let consider the following figure:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics{img/cosmology/recall_dot_product.jpg}\t\n\t\t\\caption[]{Illustrated recall of the dot product}\n\t\\end{figure}\n\twhere $\\vec{u}$ is any vector and $\\vec{n}$ a unit (dimensionless) vector and $\\vec{v}$, the orthogonal projection of $\\vec{u}$ on $\\vec{n}$. We then have (\\SeeChapter{see section Vector Calculus page \\pageref{dot product}}):\n\t\n\tNow if we seek for the vector $\\vec{v}$ we will have to multiply  the whole $\\vec{n}$:\n\t\n\tFinally, if we seek the expression of the vector $\\vec{}$ it comes immediately:\n\t\n\tThen by similarity, we can write:\n\t\n\twhere $\\vec{w}$ is perpendicular to $\\partial\\vec{X}/\\partial s$ and as the unit of speed. By construction, $\\vec{w}$ is therefore the transverse velocity of the speed at a time $t$ t since $\\partial\\vec{X}/\\partial s$ is tangent thereto. We will denote then:\n\t\n\tLet us now take, for future needs, the square norm of this last relation (be careful we process the components of the vectors directly by generalizing the vector notation!):\n\t\n\tand if we now go back to:\n\t\n\tThe associated Lagrangian is then directly (not to be confused with the Lagrangian density!):\n\t\n\tas:\n\t\n\tThe Lagrangian of the prior-previous relation is considered by the specialists in string theory as a natural generalization of the Lagrangian of the free particle as we get it in the section of Special Relativity and that was for recall given by:\n\t\t\n\t\n\t\\begin{flushright}\n\t\\begin{tabular}{l c}\n\t\\circled{20} & \\pbox{20cm}{\\score{3}{5} \\\\ {\\tiny 37 votes,  80\\%}} \n\t\\end{tabular} \n\t\\end{flushright}", "meta": {"hexsha": "5f8337f4eb8a4619b6f1f63e66f057259a60eee9", "size": 779123, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter_Cosmology.tex", "max_stars_repo_name": "vincentisoz/Opera_Magistris", "max_stars_repo_head_hexsha": "ea6789f995abe5fc364e6b271b2f0cb9b4ee1bf2", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-07-24T16:37:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-04T23:02:18.000Z", "max_issues_repo_path": "Chapter_Cosmology.tex", "max_issues_repo_name": "vincentisoz/Opera_Magistris", "max_issues_repo_head_hexsha": "ea6789f995abe5fc364e6b271b2f0cb9b4ee1bf2", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter_Cosmology.tex", "max_forks_repo_name": "vincentisoz/Opera_Magistris", "max_forks_repo_head_hexsha": "ea6789f995abe5fc364e6b271b2f0cb9b4ee1bf2", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.6356664402, "max_line_length": 2112, "alphanum_fraction": 0.7661267861, "num_tokens": 191486, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5698526514141572, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.40219346591478683}}
{"text": "%% THEORY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Theory}\n\\label{section:theory}\n\n% TODO:\n% - Add a citation (e.g. van Kampen) for Chapman-Kolmogorov?\n% - Add a section on validation using Chapman-Kolmogorov?\n\nSome discussion of the stochastic model of kinetics considered here and the theory underlying the method is appropriate before describing the algorithmic implementation in detail.\nFirst, in Section \\ref{section:theory:markov-model-introduction}, we review Markov chain and master equation models of conformational dynamics.\nNext, in Section \\ref{section:theory:construction-from-simulation-data}, we describe their construction from equilibrium molecular dynamics trajectories given any state partitioning.\nSection \\ref{section:theory:requirements-for-markovian-behavior} enumerates a number of requirements for a useful state partitioning.\nFinally, Section \\ref{section:theory:validation} discusses possible methods for validating a given state decomposition.\nThe actual implementation of the algorithm used here is described in detail in Section \\ref{section:methods}.\n\n\\subsection{Markov chain and master equation models of conformational dynamics.}\n\\label{section:theory:markov-model-introduction}\n\nConsider the dynamics of a macromolecule immersed in solvent, where the solvent is at equilibrium at some particular temperature of interest.\nWe presume that all of configuration space has already been decomposed into a set of nonoverlapping regions, or \\emph{states}, which together form a complete decomposition of configuration space.\nThe method by which these states are identified is described in subsequent sections.\n\nIf we observe the evolution of this system at times $t = 0, \\tau, 2 \\tau, \\ldots$, where $\\tau$ denotes the observation interval, we can represent this sequence of observations in terms of the state the system visits at each of these discrete times.\nThe sequence of states produced is a realization of a \\emph{discrete-time stochastic process}.\nFor this process to be described by a Markov chain, it must satisfy the \\emph{Markov property}, whereby the probability of observing the system in any state in the sequence is independent of all but the previous state.\nFor a stationary process on a finite set of $L$ states, this process can be completely characterized by an $L \\times L$ \\emph{transition matrix}\\footnote{We adopt the notation for a \\emph{column-stochastic} transition matrix, in which the columns sum to unity.  This differs from the notation in some previously-cited references, which use a \\emph{row stochastic} transition matrix, equal to the transpose of the column stochastic matrix used here.} $\\bfm{T}(\\tau)$ dependent only on the observation interval, or \\emph{lag time}, $\\tau$.\nThe element $T_{ji}(\\tau)$ denotes the probability of observing the system in state $j$ at time $t$ given that it was previously in state $i$ at time $t-\\tau$.\nIf this process satisfies detailed balance (which we will assume to be the case for physical systems of the sort we consider here \\cite{vankampen}) we additionally have the requirement\n\\begin{eqnarray}\nT_{ji} p_{\\mathrm{eq},i} = T_{ij} p_{\\mathrm{eq},j}\n\\end{eqnarray}\nwhere $p_{\\mathrm{eq},i}$ denotes the equilibrium probability of state $i$.\n\nThe vector of probabilities of occupying any of the $L$ states at time $t$ (here also referred to as the vector of state populations, such as in an experiment involving a population of noninteracting macromolecules) can be written as $\\bfm{p}(t)$.\nIf the initial probability vector is given by $\\bfm{p}(0)$, we can write the probability vector at some later time $t=n\\tau$ as\n\\begin{eqnarray}\n\\bfm{p}(n \\tau) \\: = \\: \\bfm{T}(n \\tau) \\bfm{p}(0) \\: = \\: [\\bfm{T}(\\tau)]^n \\bfm{p}(0) . \\label{equation:chapman-kolmogorov}\n\\end{eqnarray}\nThis is a form of the \\emph{Chapman-Kolmogorov equation}.\n\nAlternatively, the process can be characterized in {\\em continuous} time by a matrix of phenomenological rate constants $\\bfm{K}$, where the element $K_{ji}$, $j \\ne i$ denotes the nonnegative phenomenological rate from state $i$ to state $j$.\nThe diagonal elements are determined by $K_{ii} = - \\sum_{j \\ne i} K_{ji}$ to ensure the columns sum to zero so as to conserve probability mass.\nTime evolution is then governed by the equation\n\\begin{eqnarray}\n\\dot{\\bfm{p}}(t) &=& \\bfm{K} \\bfm{p}(t) \\label{equation:master-equation}\n\\end{eqnarray}\nwhere the dot represents differentiation with respect to time.\nThis evolution equation has formal solution\n\\begin{eqnarray}\n\\bfm{p}(t) &=& e^{\\bfm{K} t} \\bfm{p}(0) \\label{equation:master-equation-evolution} ,\n\\end{eqnarray}\nwhere the exponential denotes the formal matrix exponential.\nEq.\\ \\ref{equation:master-equation} is often referred to as a \\emph{master equation} \\cite{vankampen,oppenheim:1977a} describing evolution among a discrete set of states in continuous time.\nIt is important to note that, despite the fact that $\\bfm{p}(t)$ is formally defined for all times $t$, we do not expect Eq.\\ \\ref{equation:master-equation-evolution} to hold for \\emph{all} times $t$ for physical systems of the sort we consider here.\nIn particular, for states of finite extent in configuration space, there exists a corresponding limit for the time resolution for which dynamics will appear Markovian; processes that occur on timescales shorter than this will be be incorrectly described by the master equation.\nWe will return to this topic in detail in subsequent sections.\n\nThere is an obvious relationship between the transition matrix $\\bfm{T}(\\tau)$ and the rate matrix $\\bfm{K}$ evident from comparison of Eqs. \\ref{equation:chapman-kolmogorov} and \\ref{equation:master-equation-evolution}:\n\\begin{eqnarray}\n\\bfm{T}(\\tau) &=& e^{\\bfm{K} \\tau} . \\label{equation:relation-between-transition-and-rate-matrices}\n\\end{eqnarray}\nIf the process can be described by a continuous-time Markov process at all times, then this process can be equivalently described at discrete time intervals by the corresponding transition matrix.\nThe converse may not always be true due to sampling errors in $\\bfm{T}(\\tau)$, though methods exist to recover rate matrices $\\bfm{K}$ consistent with the observed data and the requirements of detailed balance and nonnegativity rates \\cite{grubmueller:1994a,sriraman:2005a}.\n\nThe transition and rate matrices have eigenvalues $\\mu_k(\\tau)$ and $\\lambda_k$, respectively, and share corresponding right eigenvectors $\\bfm{u}_k$.\nThe detailed balance requirement additionally ensures that all eigenvalues are real, and we here presume them to be sorted in descending order.\n%The transition and rate matrices have related eigenvalue decompositions\n%\\begin{eqnarray}\n%\\bfm{K} = \\bfm{U} \\, \\bfm{\\Lambda} \\, \\bfm{U}^{-1} \\: &;& \\: \\bfm{T(\\tau)} = \\bfm{U} \\, \\bfm{M}(\\tau) \\, \\bfm{U}^{-1}\n%\\end{eqnarray}\n%where the diagonal matrix $\\bfm{\\Lambda}$ contains the eigenvalues $\\lambda_k$ of $\\bfm{K}$, the diagonal matrix $\\bfm{M}(\\tau)$ contains the eigenvalues $\\mu_k(\\tau)$ of $\\bfm{T(\\tau)}$, and $\\bfm{U}$ contains the eigenvectors as column vectors.\n$\\mu_k(\\tau)$ and $\\lambda_k$ are related by\n\\begin{eqnarray}\n\\mu_k(\\tau) &=& e^{\\lambda_k \\tau} . \\label{equation:implied-timescales}\n\\end{eqnarray}\n%For indecomposable Markov chains, for which the transition matrix is ergodic, there will be exactly one eigenvalue $\\mu_1$ of unity (or equivalently $\\lambda_1 = 0$), and its corresponding right eigenvector $\\bfm{u}_1$ will contain the invariant equilibrium distribution (when properly normalized such that $\\bfm{1}^\\T \\bfm{u}_1 = 1$).\n%As the dynamical evolution of the system in continuous time can be expanded in terms of the eigenvectors as\n%\\begin{eqnarray}\n%\\bfm{p}(t) &=& \\sum_{k=1}^M (\\bfm{u}_k, \\bfm{p}(0)) \\, e^{\\lambda_k t} \\, \\bfm{u}_k\n%\\end{eqnarray}\n%where $(\\bfm{a},\\bfm{b}) = \\sum_i p_{\\mathrm{eq},i}^{-1} \\, a_i \\, b_i$ denotes the inner product \\cite{vankampen}\nThe eigenvalues each imply a timescale corresponding to an inverse aggregate rate\n\\begin{eqnarray}\n\\tau_k = - \\lambda_k^{-1} = - \\tau [ \\ln \\mu_k(\\tau) ]^{-1} \\label{equation:implied-timescales}\n\\end{eqnarray}\nand the associated eigenvector gives information about the aggregate conformational transitions that are associated with this timescale \\cite{schuette-thesis,schuette:1999a,huisinga-thesis,schuette:2002a}.\nIn particular, the components of $\\bfm{u}_k$ sum to zero for each $k \\ge 2$, and the aggregate dynamical mode can be identified with transitions from microstates with positive eigenvector components interconverting with the set of microstates with negative components, and vice-versa, with the degree of participation in the mode governed by the magnitude of the eigenvector component.\nThis fact can be useful in deducing the conformational transitions among aggregated regions of configuration space that govern relaxation to equilibrium, which is achieved once all processes have exponentially damped out.\n\nFor the remainder of this manuscript, we will refer exclusively to the discrete-time Markov chain model picture without loss of generality (Eq.\\ \\ref{equation:chapman-kolmogorov}), except for use of the timescales implied by the transition matrix, as described above.\n% JDC: Add reference to Mori-Zwanzig paper, if finished in time, discussing addition properties that K and T must have for physical systems, as a consequence of the projection operator formalism.\n\n\\subsection{Construction from simulation data given a state partitioning.}\n\\label{section:theory:construction-from-simulation-data}\n\nOnce a statistical-mechanical ensemble describing equilibrium and a microscopic model describing dynamical evolution in phase space have been selected, the transition matrix $\\bfm{T}(\\tau)$ can be estimated from molecular dynamics simulations.\nFor a system in which dynamical evolution is Newtonian and, at equilibrium, configurations are distributed according to a canonical distribution at a given temperature, Swope \\emph{et al.}\\cite{swope:2004a} show that the transition probability $T_{ji}(\\tau)$ can be written as the following ratio of canonical ensemble averages:\n\\begin{eqnarray}\nT_{ji}(\\tau) \n%&\\equiv& \\int d\\bfm{z}(0) \\, p_i(\\bfm{z}(0)) \\, \\chi_j(\\bfm{z}(\\tau)) \\label{equation:transition-element-conditional-probability} \\\\\n&=& \\frac{\\int d\\bfm{z}(0) \\, e^{-\\beta H(\\bfm{z}(0))} \\, \\chi_j(\\bfm{z}(\\tau)) \\, \\chi_i(\\bfm{z}(0))}{\\int d\\bfm{z}(0) \\, e^{-\\beta H(\\bfm{z}(0))} \\, \\chi_i(\\bfm{z}(0))} \\label{equation:transition-element-phase-space-integrals} \\\\\n&=& \\frac{\\expect{\\chi_j(\\tau) \\chi_i(0)}}{\\expect{\\chi_i}} \\label{equation:transition-element-correlation-functions}\n\\end{eqnarray}\nwhere $\\bfm{z(t)}$ denotes a point in phase space visited by a trajectory at time $t$, \n$\\chi_i(\\bfm{z})$ denotes the indicator function for state $i$ (which assumes a value of unity if $\\bfm{z}$ is in state $i$, and zero otherwise),\n%$p_i(\\bfm{z})$ the equilibrium distribution confined within state $i$, \n$\\beta \\equiv (k_B T)^{-1}$ the inverse temperature, $H(\\bfm{z})$ the Hamiltonian, and $\\left< A \\right>$ the canonical ensemble expectation of a phase function $A(\\bfm{z})$ at inverse temperature $\\beta$.\n\nGiven a set of simulations initiated from an equilibrium distribution, the expectations in Eq.\\ \\ref{equation:transition-element-correlation-functions} can be computed independently by standard analysis methods \\cite{allen:1991a}.\nEstimation of the correlation function in the numerator can make use of both the stationarity of an equilibrium distribution (by considering overlapping intervals of time $\\tau$), and the microscopic reversibility (by considering also time-reversed versions of the simulations) \nof Newtonian trajectories.\nAlternatively, if an equilibrium distribution within each state can be prepared, one can also directly estimate a column of transition matrix elements by computing the fraction of trajectories initially at equilibrium within state $i$ that terminate in state $j$ a time $\\tau$ later.\nMore elaborate methods based on equilibrium ensembles prepared within special \\emph{selection cells} that are not coincident with the states \\cite{swope:2004a,swope:2004b} or \\emph{partition of unity} restraints \\cite{weber-thesis:2006a} can also be used to compute transition matrix elements efficiently.\n\n\\subsection{Requirements for a useful Markov model.}\n\\label{section:theory:requirements-for-markovian-behavior}\n% JDC: In light of Bill's change of the focus of this section, we should change its title to something like \"Further requirements for chemical insight..\"?\n\nFor any given state partitioning, the dynamics of the system will be Markovian on some time scale.\nFor example, if the lag time $\\tau$ is so long as to approach the time for the system to relax to an equilibrium distribution from any arbitrary nonequilibrium starting distribution, a single application of the transition matrix $\\bfm{T}(\\tau)$ carries any arbitrary initial probability distribution directly to the invariant equilibrium distribution.\nHowever, if this $\\tau$ exceeds the timescale of the process of interest, our model is not useful\\footnote{Equilibrium probabilities can still be extracted from the stationary eigenvector (the eigenvector of corresponding to an eigenvalue of unity) of such a transition matrix, which may have some utility if one had constructed the transition matrix from trajectories not initiated from distributions at equilibrium globally.} for describing it, and therefore it is advantageous to attempt to find a state decomposition that is Markovian on a shorter timescale in order to extract useful dynamical information about this process. \n\nFor a given state $i$, we will define its internal equilibration time, $\\tau_{\\mathrm{int},i}$, as the characteristic time one must wait before the system, initially in a configuration within state $i$, generates a new \\emph{uncorrelated} configuration within the state by dynamical evolution.\nThis internal equilibration time, or \\emph{memory time}, closely related to the molecular relaxation timescale $\\tau_\\mathrm{mol}$ in Chandler's reactive flux formulation of transition state theory \\cite{chandler:1978a}, depends, of course, on the choice of state decomposition.\nWe can denote the longest of these times over all states by $\\tau_\\mathrm{int}$.\nThis is not to be confused with the time it takes an arbitrary nonequilibrium distribution to relax to global equilibrium, but rather, the minimum lag time for which dynamics will appear to be Markovian using this particular state decomposition.  If the lag time is longer than $\\tau_\\mathrm{int}$, we will expect the system to have lost memory of its previous location within {\\em any} state it may have been in, either remaining within that state or transitioning to a new one, and for dynamics on this set of states to be independent of history.\nOn the other hand, for lag times shorter than $\\tau_\\mathrm{int}$, we cannot guarantee that transition probabilities are independent of history everywhere.\nThis suggests a way in which the utility of various decompositions can be measured.\nFor a fixed number of states, the most useful model will partition configuration space to yield the shortest $\\tau_\\mathrm{int}$, as this model can be used to study the widest range of dynamical processes.\n% JDC: Add something about how a lower bound on tau_int could be estimated from restrictions of Markov chains.  Cite Schuette papers on this.\n\n%In order for the dynamical evolution of a macromolecule to resemble a Markov process, \n%we expect a number of conditions to be met.\n%Mathematically, the only true requirement is history independence, \n%but a model that satisfies only this criteria may not be useful for the study of dynamical processes; \n%pathological cases can be constructed in which history dependence is strictly satisfied but the \n%resulting states have no physical meaning.\n% JDC: I have Nina's example in the following sentence, but it may be too confusing to include.\n% For example, if each state consisted of a large number of randomly assigned regions of phase space, \n%the resulting model will likely be Markovian at short times, but a single application of the \n%transition matrix will carry the system to equilibrium and the states would be meaningless.\nIn addition to producing transition probabilities that are history independent at a relevant lag time, we impose additional conditions on our states to ensure the resulting model also provides physical and chemical insight.\nBecause we are primarily interested in macromolecular dynamical motion such as protein folding, we first require that states be consistent with a chemical intuition for a macromolecular {\\em conformational} substate and, therefore, exist as constructs exclusively in the configuration space of the macromolecule.\nIn solvated systems, we expect relaxation and decorrelation of momenta to be much faster than any of the dynamical behaviors of interest, and so we ignore momenta in defining our states.  \nFurthermore, we presume reorganization of the solvent is faster than processes of interest, and therefore ignore coordinates associated with the surrounding solvent\\footnote{We recognize that solvent coordinates may be critical in some phenomena, but dealing with solvent degrees of freedom would also require accounting for the indistinguishability of solvent molecules upon their exchange.  We leave this to further iterations of the algorithm.}.\n\n%The fundamental assumption leading macromolecular dynamics to resemble a discrete-state Markov model \n%is the existence of a \\emph{separation of timescales}.\nAlso, we seek conformational states that exhibit a {\\em separation of timescales}.\nIf states can be constructed where the timescale for equilibration \\emph{within} each state is much shorter than the timescale for transitions \\emph{among} the states, we would expect interstate dynamics to be well-modeled by a Markov chain after sufficiently long observation intervals.\nConsider, for example, the isomerization of butane, which has three main metastable conformational states (\\emph{gauche-plus}, \\emph{gauche-minus}, and \\emph{trans}).\nAt sufficiently low temperature, dynamics is dominated by long dwell times \\emph{within} each of these three states, punctuated by infrequent transitions between them.  \nThe slow interstate transition process is well-described by first order reaction kinetics for observation intervals longer than the fast molecular relaxation time for intrastate dynamics due to the presence of a separation of timescales \\cite{chandler:1978a}.\n\nIn order for the states to be defined such that equilibration within a state is rapid, we further require that the region of configuration space defining each state be \\emph{compact} and \\emph{connected}.\n% JDC: Nina had a concern regarding states that consist of unconnected regions related by symmetry, \n%but I can't quite recall the argument.  We may need to think about this some more.\nA state composed of two or more unconnected regions of phase space defies the assumption that equilibration within the state is much faster than the characteristic time to leave it.\n%While it may still be possible to construct cases where states are not contiguous yet the \n%resulting model is Markovian, we feel that this contiguity requirement is essential for the \n%states to be endowed with chemical or physical meaning.\n\n%Another consequence of requiring rapid intrastate equilibration is that the probability of \n%transitioning to another state must be independent of the initial microscopic configuration within the state.\n%In the Markov chain literature, this condition is called \\emph{lumpability} \\cite{kemeney:1960a}.\n%While this could be directly tested by initiating many trajectories with random initial velocities \n%from each of a number of points within the state, this approach is impractical.\n% JDC: Is more needed here?  Does this paragraph serve a specific purpose?\n\n% JDC: We might add something about 'best' decomposition giving the slowest rates, by analogy with \n%variational TST.  To do this, we first need to introduce the concept of implied timescales, which \n%we do below in the Validation section.  This would require a bit of rewriting to introduce earlier.\n\n% JDC: Metastable states appear relatively invariant with lag time tau (cite ZIB?) though use of \n%long enough tau will actually wipe out weakly metastable states.  Suggests we want to use a tau \n%less than or equal to the timescale of the processes of interest.  This tau does not have to \n%correspond to tau_eq, since this will be estimated in a separate step after the partitioning has \n%been selected (see Validation).\n\n%To summarize, we have the following requirements:\n%[WS: including this list seems redundant.]\n%\\begin{description}\n%  \\item [Compactness and connectivity.]  States consist of connected, compact regions in the configuration \n%space of the macromolecule.\n%  \\item [Separation of timescales.]  For each state, the internal equilibration time $\\tau_\\mathrm{eq}$ \n%is much shorter than the characteristic state lifetime $\\tau_\\mathrm{lifetime}$.  Maximizing the \n%metastability (Eq. \\ref{equation:metastability}) may provide an inexpensive way to attempt to \n%achieve a separation of timescales.\n%  \\item [Utility.]  The internal equilibration time for the entire system, $\\tau_\\mathrm{eq}$, must be \n%shorter than the timescale of the fastest phenomenon of interest, $\\tau^*$.\n%\\end{description}\n\n\\subsection{Validation of Markov models.}\n\\label{section:theory:validation}\n\nOnce a decomposition of configuration space is chosen, we are faced with the task of determining the observation time interval $\\tau$ at which dynamics in this state space appears Markovian.\nUnfortunately, we cannot directly compute the internal macrostate equilibration times, though examination of the eigenvalues of the transition matrix restricted to a state may give a lower bound on this time in the absence of statistical uncertainty \\cite{meerbach:2004a}.\nThe most rigorous test for Markovian behavior would be a direct test for history independence.\nThe simplest test of this type is to compute second order transition probabilities and compare them to the appropriate products of the first order transition probabilities to see if their disagreement is statistically significant, though this would miss possible yet unlikely higher order history dependencies.\nWhile it is possible to estimate these from the simulation data, this requires the estimation of three-time correlation functions, which often possess statistical uncertainties so large as to render them useless for this kind of test \\cite{chodera:jpcb:2006}.\n\nRaising the transition matrix to a power $n$ (hence summing over the intermediate states) and comparing with the observed transition probabilities for a lag time of $n\\tau$, such that one is effectively determining whether the Chapman-Kolmogorov equation (Eq.\\ \\ref{equation:chapman-kolmogorov}) is satisfied, helps to reduce the uncertainty so that the test becomes practical.\nThis is equivalent to propagating the population in time out of a probability distribution confined to each state $i$ initially, and comparing the model evolution with the observed transition probabilities over times much longer than $\\tau_{\\mathrm{int}}$.\nThis serves as a check to ensure that the model is at least consistent with the dataset from which it was constructed, to within the statistical uncertainty of the transition matrices obtained from the dataset.\nThis method was employed, for example, in Refs.\\ \\cite{swope:2004a,chodera:mms:2006}.\n\nAnother approach, from Park, \\emph{et al.}, \\cite{park:2006a} uses concepts from information theory to compute the \\emph{conditional mutual information} conveyed by the second-to-last state, which quantifies the discrepancy between observed second-order transition probabilities and the estimate modeled from first-order transition probabilities.\nThe result of this analysis is a scalar that quantifies the degree of history dependence.  \nFor a pure first-order Markov process, the mutual information will be zero, as no additional information is gained by including additional history.\nWhile this method also requires computing three-time correlation functions, which may individually have substantial uncertainties, the weighted combination of these into a single value reduces the uncertainty in the resulting metric.\nUnfortunately, there is no rigorous criteria for how small this measure must be in order for the model to be considered acceptably Markovian.\n\nSwope, \\emph{et al.}, \\cite{swope:2004a} suggested a number of additional tests for signatures of Markov behavior, the most sensitive of which appears to be examining the behavior of the \\emph{implied timescales} of the transition matrix $\\bfm{T}(\\tau)$, which can be computed from the eigenvalues of the transition matrix by Eq.\\ \\ref{equation:implied-timescales}, as a function of increasing lag time $\\tau$ \\cite{chodera:jpcb:2006}.\nAt sufficiently large $\\tau$, the implied timescales will be independent of $\\tau$, implying that exponentiation of the transition matrix is nearly identical to constructing the transition matrix using longer observation time intervals (Eq.\\ \\ref{equation:chapman-kolmogorov}).\n% JDC: One primary criticism of Marcus Weber and the ZIB folks is that this is formally incorrect for our dynamical model, since repeated application of T(\\tau) introduces a velocity randomization every \\tau, whereas T(n\\tau) only has a velocity randomization at time zero.  We note that it will only appear to be the case under particular conditions that permit such a model to describe kinetics.\nThe shortest observation time interval for which this holds can be correlated with the internal equilibration time $\\tau_\\mathrm{int}$, and descriptions of the behavior of the system using that state decomposition should be Markovian for all lag times $\\tau \\ge \\tau_\\mathrm{int}$.\nThis is also a test of whether the Chapman-Kolmogorov equation holds, but as it computes only $L$ numbers and orders them by timescale, it allows emphasis to be placed on the longest timescales in the system.\n\nUnfortunately, this method has some drawbacks.  \nFirst, small uncertainties in the eigenvalues of the transition matrix can induce very large uncertainties in the implied timescales.  \nWith increasing lag time $\\tau$, the number of statistically independent observed transitions, from which $\\bfm{T}(\\tau)$ is estimated, diminishes, and the statistical uncertainty in the implied timescales $\\tau_k$ will grow.\nSecond, while stability of the implied timescales with respect to lag time is a \\emph{necessary} consequence of history independence, it is not itself \\emph{sufficient} to guarantee history independence, though we may be unlikely to encounter physical systems for which this is problematic.\n% NS: Another possible drawback is that since we calculate the implied time scales for increasing lag times, the end effects (especially when we have few trajectories that visit given states) may affect the results.  I think comparing only consecutive lag times are less sensitive to this, but we never really proved that this was why our timescales for low population states occasionally kept increasing\n% JDC: Good point.  We need to get a handle on these end effects, if they are real.  Perhaps we should only be allowed to compute the timescales up to a lag time of half the longest trajectory length?  What if we have trajectories of a distribution of lengths?\nHowever, tests on simple models indicate that the information theoretic metric suggests the emergence of Markovian behavior on similar lag times to this method, suggesting some degree of fundamental equivalence \\cite{park:2006a}.\n\nIn this work, the analysis of implied timescales as a function of lag time will be our primary test for the emergence of Markovianness.\n\n%From tests on simple models, comparison of analyses based on implied timescales and the information theoretic based metric appears to indicate the emergence of Markovian behavior at approximately the same lag time \\cite{park:2006a}, and, so, the primary validation tests used in this work will be based on the analysis of implied timescales.\n\n%Instead of testing for one- or two-time history independence of the transition probabilities, in some cases, it is also possible to test the statistical time evolution out of each state over longer times.\n%An ensemble of starting conformations representative of some nonequilibrium condition could be prepared, and numerous simulations conducted to examine the statistical time evolution over long times.  \n%The temporal behavior of the state populations as this ensemble relaxes to equilibrium should be consistent with that predicted by the model through repeated application of the transition matrix to the initial state probabilities.  \n%%This would be of interest in the study of protein (un)folding experiments, such as laser temperature-jump experiments, in which a short laser pulse rapidly heats the solvent, taking the population of macromolecules out of equilibrium with respect to the higher temperature.\n%%Although the models described in this work are constructed from equilibrium data characteristic of a particular temperature, we would expect to capture the dynamics of systems thermally perturbed in this way.\n%% JDC: What about systems perturbed in other (non-thermal) ways?  My point was to stress that the model is only useful for particular perturbations away from equilibrium, and not ANY arbitrary perturbation from equilibrium.  I think we need to make this point.\n%In this work, among other tests, we monitor the evolution of various ensembles of trajectories, selected from equilibrium but all started from a single state.\n%We compare their evolution with a model constructed from trajectories at equilibrium.\n%% JDC: What do we do here?\n", "meta": {"hexsha": "ae8fd19a11b2f93aa0b889986243677b49c032c1", "size": 29895, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/automatic-state-decomposition/theory.tex", "max_stars_repo_name": "jchodera/jdcthesis", "max_stars_repo_head_hexsha": "bc238b4023fa0ee3433d711188c59f3cf791eb90", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/automatic-state-decomposition/theory.tex", "max_issues_repo_name": "jchodera/jdcthesis", "max_issues_repo_head_hexsha": "bc238b4023fa0ee3433d711188c59f3cf791eb90", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/automatic-state-decomposition/theory.tex", "max_forks_repo_name": "jchodera/jdcthesis", "max_forks_repo_head_hexsha": "bc238b4023fa0ee3433d711188c59f3cf791eb90", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 124.5625, "max_line_length": 631, "alphanum_fraction": 0.7920388025, "num_tokens": 6840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.40219346238823794}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{Thu Dec 19 2019}\n\nWe found the equation \n%\n\\begin{align}\n\\dot{\\rho}  + 3 \\frac{\\dot{a}}{a} \\rho (1 + w)=0\n\\,,\n\\end{align}\n%\nwhere \\(w = p / \\rho \\), and we found that for\nvacuum energy, with constant \\(\\rho \\), we get \\(w = -1\\). \n\nNow we will derive the fact that \\(w = 1/3\\) for radiation.\nThis can be derived from Maxwell's equations, but it also can come from a more illustrative argument: we consider photons in a box. \n\nIf they travel along the \\(x\\) axis, they have wavevectors \\(k^{\\mu } = (\\omega ,  \\omega , 0, 0)\\) and momenta \\(p^{\\mu } = \\omega \\hbar (1, 1, 0, 0,)\\).\n\nIn general they will travel in a different direction, of course, but we treat this case. \nEach photon hits a wall every \\(\\Delta t = 2L\\), and transfers momentum equal to \\(2 \\hbar \\omega \\). So, the average force exerted is \\(\\Delta p / \\Delta t = \\hbar \\omega /L\\). \n\nIn the cavity there is an energy \\(\\rho V = \\rho AL\\), where \\(\\rho \\) is the photons' energy density, \\(L\\) is the length along \\(x\\) while \\(A\\) is the area normal to the \\(x\\) direction. \n\nEach photon has energy \\(\\hbar \\omega \\), so there are \\(\\rho A L / \\hbar \\omega \\). We assume for simplicity (but it gives the exact correct answer) that \\(1/3\\) of the photons travel along each spatial direction. \n\nSo there are \\(\\rho A L / 3 \\hbar \\omega \\) photons travelling in the \\(x\\) direction. So the average force exerted on the wall is given by \n%\n\\begin{align}\nF_{x} = \\frac{\\hbar \\omega }{L} \\times \\frac{\\rho A L}{3 \\hbar \\omega } = \\frac{\\rho A}{3}\n\\,,\n\\end{align}\n%\nso the average pressure is \\(\\rho /3\\), so \\(w = 1/3\\). \n\nNow let us consider nonrelativistic particles: if \\(v \\ll 1\\) then the 4-momentum looks like \n%\n\\begin{align}\np^{\\mu } = (m, mv, 0, 0)\n\\,,\n\\end{align}\n%\nso the force along the \\(x\\) axis is given by \n%\n\\begin{align}\nF_{\\text{one particle}} = \\frac{\\Delta p_{x}}{\\Delta t} = \\frac{2mv}{2L / v} = \\frac{mv^2}{L}\n\\,,\n\\end{align}\n%\nand as before the total energy is \\(\\rho L A\\), so the number of particles travelling along the \\(x\\) direction is \\(\\rho L A /3 m\\), since the momentum contribution to the particle's energy is negligible: therefore \n%\n\\begin{align}\nF_{x, \\text{tot}} = \\frac{mv^2}{L} \\times \\frac{\\rho LA}{3m} \n= \\frac{\\rho A v^2}{3} \\approx 0\n\\,,\n\\end{align}\n%\nwhich we can neglect since it is quadratic in \\(v\\) which is very small. So we say that for relativistic matter \\(w = 0\\). \n\nWe have the differential equation \n%\n\\begin{align}\n\\dv{\\rho }{t} + 3 \\frac{1}{a} \\dv{a}{t} (1+w)\\rho =0\n\\,,\n\\end{align}\n%\nso we can integrate: \n%\n\\begin{align}\n\\int \\frac{ \\dd{\\rho }}{\\rho } = - 3 (1+w) \\int \\frac{ \\dd{a}}{a}\n\\,,\n\\end{align}\n%\nwihch is readily solved by integrating from \\(\\rho =\\rho_0 \\) and \\(a=a_0 \\):\n%\n\\begin{align}\n\\rho = \\rho_0 \\qty(\\frac{a_0 }{a})^{3 (1+w)}\n\\,.\n\\end{align}\n%\n\nFrom the square root of the 00 EFE we get: \n%\n\\begin{align}\n\\frac{\\dot{a}}{a} = \\frac{1}{\\sqrt{3}M_P} \\rho^{1/2}\n\\,,\n\\end{align}\n%\ninto which we can put the solution we found: \n%\n\\begin{align}\n\\frac{\\dot{a}}{a} = \\frac{1}{\\sqrt{3}M_P} \\rho_0^{1/2} \\qty(\\frac{a_0 }{a})^{\\frac{3(1+w)}{2}}\n\\,,\n\\end{align}\n%\nand if we define \\(x = a / a_0 \\) this becomes: \n%\n\\begin{align}\n\\dv{x}{t} x^{\\frac{3(1+w)}{2} - 1} = \\frac{\\rho_0 ^{1/2}}{\\sqrt{3}M_P}\n\\,,\n\\end{align}\n%\nso we integrate: \n%\n\\begin{align}\n\\int_{1}^{a / a_0 } \\dd{x} x^{\\frac{3(1+w)}{2}} = \n\\frac{\\rho_0^{1/2}}{\\sqrt{3}M_P} (t-t_0 )\n\\,,\n\\end{align}\n%\nso we need to integrate \\(\\int x^{\\alpha } \\dd{x}\\): this can be \\(\\log x\\) if \\(\\alpha = -1\\) or \\(x^{\\alpha +1} / (\\alpha +1)\\) if \\(\\alpha \\neq -1\\). \n\nWe get the logarithm when \\(w = -1\\): then \n%\n\\begin{align}\n\\log \\frac{a}{a_0 }  = \\frac{\\rho_0}{\\sqrt{3}M_P} \\qty(t - t_0 )\n\\,,\n\\end{align}\n%\nwhich means \n%\n\\begin{align}\na = a_0 \\exp(\\frac{\\rho_0^{1/2}}{\\sqrt{3}M_P} \\qty(t - t_0 ))\n\\,,\n\\end{align}\n%\nwhich is called \\emph{De Sitter spacetime}. Notice that in this case \\(\\rho \\equiv \\rho_0 \\) since the density of vacuum energy is constant. In all other cases \n%\n\\begin{align}\n\\frac{2}{3 (1+w)} \\qty(\\qty(\\frac{a}{a_0 })^{3\\frac{1+w}{2}} -1) = \\frac{\\rho_0^{1/2}}{\\sqrt{3}M_P} \\qty(t - t_0 )\n\\,,\n\\end{align}\n%\nand notice that \\(t_0 \\) is an arbitrary choice: we usually choose \n%\n\\begin{align}\nt_0 = \\frac{2}{3 (1+w)} \\frac{\\sqrt{3}M_P}{\\rho_0^{1/2}}\n\\,,\n\\end{align}\n%\nwhich then gives: \n%\n\\begin{align}\n\\qty(\\frac{a}{a_0 })^{\\frac{3 (1+w)}{2}} = \\frac{3 (1+w)}{2} \\frac{\\rho_0^2 }{\\sqrt{3}M_P} t = \\frac{t}{t_0 }\n\\,.\n\\end{align}\n%\nThen we get an ``easy'' answer: \n%\n\\begin{align}\n\\frac{a}{a_0 } = \\qty(\\frac{t}{t_0 })^{\\frac{2}{3 (1+w)}} \n\\,.\n\\end{align}\n\nSome cases are: \n\\begin{enumerate}\n    \\item Matter: \\(w=0\\) implies \\(\\rho \\sim a^{-3}\\), \\(a \\sim t^{2/3}\\);\n    \\item Radiation: \\(w=1/3\\) implies \\(\\rho \\sim a^{-4}\\) and \\(a \\sim t^{1/2}\\);\n    \\item Vacuum energy: \\(w = -1\\) implies \\(\\rho = \\const\\) and \\(a \\sim \\exp t\\).\n\\end{enumerate}\n\nIf \\(a = \\overline{a} \\equiv \\const\\) then we can rescale the spatial coordinated \\(\\vec{x} \\rightarrow \\overline{a} \\vec{x}\\), so we recover Minkowski spacetime. \n\nThis implies that, in a flat Friedmann - Robertson - Lemaître - Walker universe, the normalization of the scale factor is unphysical. \n\nThis can be noticed from the equations: only the \\emph{logarithmic} derivative of the scale factor enters them. \n\nIf we have a universe which is \\emph{not} flat, we get an additional factor \\(k / a^2\\), with \\(k = \\pm 1\\) in the Friedmann equations: then the normalization of the scale factor becomes physical. \n\nLet us characterize expansion: let us consider two galaxies, one at the spatial coordinates \\(\\vec{x}_{1} = \\vec{0}\\) and the other at \\(\\vec{x}_{1} = (\\overline{x}, 0,0)\\). \n\nThe distance between them is given  by \n%\n\\begin{align}\nd_{P} (t) = \\int_{0}^{\\overline{x}} \\dd{x} \\sqrt{g_{11} } = a(t) \\overline{x}\n\\,.\n\\end{align}\n\nHow much does the distance change between two times \\(t_1 \\) and \\(t_2 \\)? Their ratio is \n%\n\\begin{align}\n\\frac{  d_{P}(t_1 )}{d_{P}(t_2 )} = \\frac{\\overline{x} a(t_1 )}{\\overline{x} a(t_2 )} = \\frac{a(t_1 )}{a(t_2 )}\n\\,.\n\\end{align}\n\nThese are called \\emph{comoving coordinates}: the coordinates on a grid which is expanding. \n\nSo the distance can change both because of this comoving expansion, and because of \\emph{proper motion}: things actually moving through the grid. \n\nWe can write the FRLW metric with respect to spherical coordinates: \n%\n\\begin{align}\n\\dd{s^2} = - \\dd{t^2} + a^2(t) \\qty(\\dd{r^2} + r^2 \\dd{\\Omega^2})\n\\,.\n\\end{align}\n\nA photon moves with \\(\\dd{s^2} =0\\), which implies \n%\n\\begin{align}\n\\dd{r} = \\frac{ \\dd{t}}{a(t)}\n\\,.\n\\end{align}\n\nSay we have an emitter Alice and an observer Bob, both at fixed radial coordinates. Alice sends two photons (or wavecrests, whatever) at a time difference  \\(\\Delta t_A\\) apart, and Bob receives them at a time difference \\(\\Delta t_B\\) apart. \n\nIn general \\(\\Delta t_A \\neq \\Delta t_B\\). We have \n%\n\\begin{align}\n\\int_{r_A}^{r_B} \\dd{r} = \\int_{t_A}^{t_B}  \\frac{ \\dd{t}}{a(t)} \n= \\int_{t_A + \\Delta t_A}^{t_B + \\Delta t_B}  \\frac{ \\dd{t}}{a(t)} \n\\,.\n\\end{align}\n\nThis then implies that \n%\n\\begin{align}\n\\int_{ t_A }^{ t_A + \\Delta t_A} \\frac{ \\dd[]{t}}{a(t)} = \n\\int_{ t_B }^{ t_B  + \\Delta t_B} \\frac{ \\dd[]{t}}{a(t)} \n\\,.\n\\end{align}\n\nThe \\(\\Delta t\\) are \\emph{very} small with respect to the total times: then this means \n%\n\\begin{align}\n\\frac{\\Delta t_A}{a(t_A)} \\approx \\frac{ \\Delta t_B}{ a(t_B)}\n\\,,\n\\end{align}\n%\nwhich can be written as \n%\n\\begin{align}\n\\Delta t_B = \\Delta t_A \\frac{a(t_B)}{a(t_A)}\n\\,,\n\\end{align}\n%\nor, equivalently, \n%\n\\begin{align}\n\\omega_{B} = \\omega_{A} \\frac{a(A)}{a(B)}\n\\,,\n\\end{align}\n%\nor \n%\n\\begin{align}\n\\lambda_{B} = \\lambda_{A} \\frac{a(B)}{a(A)}\n\\,,\n\\end{align}\n%\nsince \\(\\omega \\lambda = 2 \\pi \\). Since \\(a(B) > a(A)\\) we get \\(\\lambda_{B} > \\lambda_{A}\\): this is a \\emph{redshift}. \n\nSince \\(E_{\\gamma } = \\hbar \\omega \\propto a^{-1}\\), while the volume density \\(N_{\\gamma } \\propto a^{-3}\\), we get the global effect of \\(\\rho_{\\gamma } \\propto a^{-4}\\). \n\nWe define \n%\n\\begin{align}\nz = \\frac{\\lambda_{B}}{\\lambda_{A}} - 1 = \\frac{a(t_{B})}{a(t_{A})} - 1\n\\,,\n\\end{align}\n%\nfixing \\(t_B = \\text{now} = t_0 \\). \n\n\\emph{Hubble's law} is a relation between redshift and distance of nearby objects. \n\nSince we are nearby, we Taylor expand the scale factor: we say \n%\n\\begin{align}\na(t) = a_0 + \\dot{a}_{0} (t - t_0 ) + \\mathcal{O}(t^2)\n\\,,\n\\end{align}\n%\nwhere by \\(\\dot{a}_{0}\\) we mean the derivative of the scale factor computed at the present time.\n\nWe have \n%\n\\begin{align}\nd_{P}(t) = a(t) \\int_{A}^{B} \\dd{r} = a(t) \\int_{t_A}^{t_B} \\frac{ \\dd{\\widetilde{t}}}{a (\\widetilde{t})}\n\\,,\n\\end{align}\n%\nso this, at the time \\(t_0\\) gives us \n%\n\\begin{align}\nd_P (t_0 ) = a_0 \\int \\frac{\\dd{t}}{a_0 } = t_B - t_A + \\mathcal{O}(t^2)\n\\,,\n\\end{align}\n%\nif we consider the lowest possible order (at which the universe is not expanding).\nWe can identify \\(B = 0\\), that is, we observe now.\n\nWe can write the first order expansion of the scale factor as \n%\n\\begin{align}\na_0 - a(t_A) = \\dot{a}_{0} (t_0 - t_A) \\implies\nt_{0} - t_A = \\frac{a_0 - a(t_A)}{\\dot{a}_{0}}\n\\,,\n\\end{align}\n%\nso we get \n%\n\\begin{align}\nd_P = t_0 - t_A = \\frac{a_0 }{\\dot{a}_{0}} \\qty(1 - \\frac{a(t_A)}{a_0 }) \n= \\frac{a_0 }{\\dot{a}_{0}} \\qty(1 - \\frac{1}{1+z})\n\\approx \\frac{a_0 }{ \\dot{a}_{0}} z + \\mathcal{O} (z^2)\n\\,,\n\\end{align}\n%\nsince \\(z / (1+z) \\sim z \\) if \\(z \\sim 0\\). \n\nThe (inverse of the) constant multiplying \\(z\\) is called the \\emph{Hubble Constant}: \n%\n\\begin{align}\nH_0 = \\frac{\\dot{a}_{0}}{a_0 }\n\\,.\n\\end{align}\n\nThere is also the fact we neglected: what is actually measurable is not the comoving distance but the luminosity distance. \nThe value of this constant is around \n%\n\\begin{align}\nH_0 \\approx \\SI{70}{km s^{-1} Mpc^{-1}}\n\\,.\n\\end{align}\n\nThere is a disagreement between the measurement of \\(H_0 \\) from the CMB and the one using standard candels. \n\nWe finish off the topic by discussing the relationship between time and energy. We discuss the present age of the universe and the time of the Big Bang nucleosynthesis. \n\nAs long as \\(w \\neq 1\\) we can immediately derive a relation for \\(\\dot{a} / a \\) by differentiating: \n%\n\\begin{align}\n\\frac{\\dot{a}}{a} = \\frac{2 }{3 (1+w) t}\n\\,,\n\\end{align}\n%\nso the ratio does depend on \\(w\\), but the \\(t\\)-dependence is always \\(H \\sim 1/t\\). To get an order of magnitude, we can use a matter-dominated universe, so the prefactor becomes \\(2/3\\): \n%\n\\begin{align}\nt_0 \\sim \\frac{1}{H_0} \\approx  \\SI{4.4e17}{s} \\sim \\SI{1.4e10}{yr}\n\\,.\n\\end{align}\n%\n\nAt which time did the universe have a temperature of \\SI{1 }{MeV}? We know that the energy density looks like \n%\n\\begin{align}\n\\rho_{\\gamma } = c (k_B T)^{4}\n\\,,\n\\end{align}\n%\nwhich follows from integrating the Planck distribution. \n\nIn natural units (\\(c = \\hbar = k_B =1\\)), an energy density has dimensions of an energy to the fourth power, since it is energy divided by length cubed, but lengths are inverse energies. Then, \n%\n\\begin{align}\n\\rho_{\\gamma } \\propto T^{4}\n\\,,\n\\end{align}\nand the proportionality constant is approximately equal to 1: in fact, \n%\n\\begin{align}\n\\sigma_{\\text{stefan-boltzmann}} \\frac{c^2 \\hbar^3}{k_B^{4}}\\approx \\num{.1645}\n\\,.\n\\end{align}\n\nWe know that \n%\n\\begin{align}\nH^2 = \\frac{1}{3 M_P^2} \\rho \n\\,,\n\\end{align}\n%\nwhich  means that, neglecting the order-1 factor of 3:\n%\n\\begin{align}\nH = \\frac{T^2}{M_P}\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{align}\nt \\sim \\frac{M_P}{T^2}\n\\,,\n\\end{align}\n%\nwhich is the relation between time and temperature in a radiation-dominated universe. In natural units, \\(M_P \\sim \\SI{2e19 }{GeV}\\), so \n%\n\\begin{align}\nt \\sim \\frac{\\SI{2e19}{GeV}}{\\qty(\\SI{1}{MeV})^2} = \\SI{2e24}{GeV^{-1}}\n\\,,\n\\end{align}\n%\nso this can be transformed in seconds by multiplying by \n%\n\\begin{align}\n\\hbar = \\SI{6.6e25}{GeV s}\n\\,,\n\\end{align}\n%\nso \\(\\SI{}{GeV^{-1}} = \\SI{6.6e-25}{s}\\): then \n%\n\\begin{align}\nt  = \\SI{2e24}{GeV^{-1}} \\times \\SI{6.6e-25}{GeV s} \\approx \\SI{1.2}{s}\n\\,.\n\\end{align}\n\nThis holds for a radiation-dominated universe. \n\n\\end{document}", "meta": {"hexsha": "21b85c6c15e42f0842b157d728373403cdb4543b", "size": 12050, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/19dec.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/19dec.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/19dec.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 29.3187347932, "max_line_length": 243, "alphanum_fraction": 0.6275518672, "num_tokens": 4499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.7799929002541068, "lm_q1q2_score": 0.40217987349357304}}
{"text": "\\documentclass[11pt,a4paper]{report}\n\\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}\n\\usepackage{enumitem}\n\\usepackage{changepage}\n\\usepackage{graphicx}\n\\usepackage{caption}\n\\usepackage{listings}\n\\usepackage{color}\n\\theoremstyle{plain}\n\\newtheorem{thm}{Theorem}[section]\n\\newtheorem{lem}[thm]{Lemma}\n\\newtheorem{prop}[thm]{Proposition}\n\\newtheorem*{cor}{Corollary}\n\\theoremstyle{definition}\n\\newtheorem{defn}{Definition}[section]\n\\newtheorem{conj}{Conjecture}[section]\n\\newtheorem{exmp}{Example}[section]\n\\newtheorem{exercise}{Exercise}[section]\n\\theoremstyle{remark}\n\\newtheorem*{rem}{Remark}\n\\newtheorem*{note}{Note}\n\\def\\changemargin#1#2{\\list{}{\\rightmargin#2\\leftmargin#1}\\item[]}\n\\let\\endchangemargin=\\endlist \n\n\\definecolor{codegreen}{rgb}{0,0.6,0}\n\\definecolor{codegray}{rgb}{0.5,0.5,0.5}\n\\definecolor{codepurple}{rgb}{0.58,0,0.82}\n\\definecolor{backcolour}{rgb}{0.95,0.95,0.92}\n\n\\lstdefinestyle{mystyle}{\n\tbackgroundcolor=\\color{backcolour},   \n\tcommentstyle=\\color{codegreen},\n\tkeywordstyle=\\color{magenta},\n\tnumberstyle=\\tiny\\color{codegray},\n\tstringstyle=\\color{codepurple},\n\tbasicstyle=\\footnotesize,\n\tbreakatwhitespace=false,         \n\tbreaklines=true,                 \n\tcaptionpos=b,                    \n\tkeepspaces=true,                 \n\tnumbers=left,                    \n\tnumbersep=5pt,                  \n\tshowspaces=false,                \n\tshowstringspaces=false,\n\tshowtabs=false,                  \n\ttabsize=2\n}\n\n\\lstset{style=mystyle}\n\\begin{document}\n\n\\section*{Problem} Suppose that a random integer is generated between 1 and 1000\n(inclusive).  What is the probability that one of the digits in the number is a\n2?\n\n\\section*{Bonus} What about the other digits?  Are any of them different from 2?\nWhich ones and what are their probabilities of occurrence?\n\n\\section*{Bonus$^2$} Write a simple program to verify your answers.\n\n\\section*{Solution} There are 271 numbers in the given range that have\n2 as one of their digits.  Here is one way to count them.  There is one 1-digit\nnumber containing 2.  The 2-digit ones are 20, ... , 29 and 12, ... , 92.  That\nwould make 19, but 22 is counted twice in those lists, so that makes 18 of\nthese.  The 3-digit ones are all of the 200's plus the 2-digit ones preceded by\na different digit, with the slight augmentation that in each case, there is one\nmore - the one starting with 0 (e.g. 302).  So there are $100 + 8 \\times 19 =\n252$ 3-digit numbers containing 2.  So the total is $1 + 18 + 252 = 271.$\nTherefore the probability is $271 / 1000 = .271$. \\section*{Bonus Solution} The\nsame argument above works for 3, 4, ..., 9.  Since 1000 itself includes a 1,\nthat digit is slightly more likely - $272/1000 = .272.$  Now for 0, the counting\nmethod above does not work, because 01 is the same as 1, etc.  The 2-digit ones\nare 10,20,30...,90 and the 3-digit ones are each of these with a 1, up to 9 in\nfront (81 of these) multiplied by 2 (because the 0 could be in either place)\nplus 100, ..., 900, 1000.  This makes $9 + 2 \\times 81 + 10 = 181$ so the\nprobability of 1 is just $.181.$\n\n\n\\section*{Bonus$^2$ Solution}\nHere is some simple Java code to do this:\n\\newpage\n\\begin{lstlisting}[language=Java]\nimport java.util.Arrays;\n\npublic class Counter {\n\t\n\tpublic static void main(String[] args) {\n\t\tfinal int[] counts = new int[10];\n\t\tfor (int i = 1; i < 1001; i++) {\n\t\t\tfor (int j = 0; j < 10; j++) {\n\t\t\t\tif (contains(i, j)) {\n\t\t\t\t\tcounts[j]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(Arrays.toString(counts));\n\t}\n\t\n\t/**\n\t* Returns true iff the string representation of y is a substring of\n\t* the string representation of x.\n\t*\n\t* @param x integer to search\n\t* @param y integer sought as substring\n\t* @return true if the digits of y occur as a subsequence of the digits of x\n\t*/\n\tprivate static boolean contains(int x, int y) {\n\t\tfinal String xString = String.valueOf(x);\n\t\tfinal String yString = String.valueOf(y);\n\t\treturn xString.contains(yString);\n\t}\n\t\n}\n\n\\end{lstlisting}\n\n \n\\end{document}\n\n", "meta": {"hexsha": "fb56169baaef510d02d501c66dfb129d780171fc", "size": 3983, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "digits/digits.tex", "max_stars_repo_name": "psteitz/problems", "max_stars_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "digits/digits.tex", "max_issues_repo_name": "psteitz/problems", "max_issues_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-03T21:08:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T21:08:11.000Z", "max_forks_repo_path": "digits/digits.tex", "max_forks_repo_name": "psteitz/problems", "max_forks_repo_head_hexsha": "c231561593ef7de6264c21d2c78d736866c1b341", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1916666667, "max_line_length": 80, "alphanum_fraction": 0.7002259603, "num_tokens": 1198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.4021798708565912}}
{"text": "\\chapter{Block Diagram}\r\n\\label{chapter:blockDiagram}\r\n\r\n\\newcounter{blockDiagram}\r\n\\setcounter{blockDiagram}{0}\r\n\\stepcounter{blockDiagram}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\r\n\\begin{figure}[h]\r\n\t\\centering\r\n\t\\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,auto] \r\n\t\r\n\t%Automata states\r\n\t\\node[state,initial] (q_0)   {$\\cfrac{0 \\xrightarrow[]{a,b} 1}{a,b}$}; \r\n\t\\node[state] (q_1) [right=3cm of q_0] {$\\cfrac{1 \\xrightarrow[]{c,d} 1}{c,d}$}; \r\n\t\\node[state,accepting] (q_2) [below=3cm of q_1] {$\\cfrac{1 \\xrightarrow[]{e,f} 2}{e,f}$}; \r\n\t\r\n\t%Automata Paths\r\n\t\\path[-latex] \r\n\t(q_0) edge \t\t\t\tnode \t    {$u_Q$} (q_1)\r\n\tedge\t\t\t\tnode [swap] {$u_Q$} (q_2)\r\n\t(q_1) edge \t\t\t\tnode \t\t{$u_Q$} (q_2)\r\n\tedge [loop right] node \t\t{$u_Q$} ();\r\n\t\r\n\t\\end{tikzpicture}\r\n\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,auto] \r\n\t\t\r\n\t\t%Automata states\r\n\t\t\\node[state,initial] (q_0)   {$0$}; \r\n\t\t\\node[state] (q_1) [above right=of q_0] {$1$}; \r\n\t\t\\node[state,accepting] (q_2) [below right=of q_0] {$2$}; \r\n\t\t\\node[state] (q_6) [right=of q_2] {$6$};\r\n\t\t\\node[state] (q_3) [above =of q_6] {$3$};\r\n\t\t\\node[state] (q_4) [right=of q_6] {$4$};\r\n\t\t\\node[state] (q_5) [right=4cm of q_1] {$5$};\r\n\t\t\r\n\t\t%Automata paths\r\n\t\t\\path[-latex] \r\n\t\t(q_0) edge \t\t\t\tnode \t\t{$a$} (q_1)\r\n\t\t(q_1) edge \t\t\t\tnode \t\t{$g$} (q_5)\r\n\t\tedge \t\t\t\tnode [swap]\t{$a$} (q_3)\r\n\t\tedge \t\t\t\tnode \t\t{$b$} (q_2)\r\n\t\t(q_3) edge [bend right]\tnode \t\t{$b$} (q_4)\r\n\t\t(q_4) edge [loop right] node \t\t{$g$} ()\r\n\t\tedge [bend right] node [swap]\t{$a$} (q_3)\r\n\t\t(q_6) edge\t\t\t\tnode \t\t{$a$} (q_3)\r\n\t\tedge \t\t\t\tnode \t\t{$a$} (q_2)\r\n\t\t(q_2) edge \t\t\t\tnode \t\t{$g$} (q_0);\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Lines separiting the two plots\r\n\t\t\\draw[-] (0,0) coordinate -- (0,-7.0) coordinate;\r\n\t\t\r\n\t\t%Continuous-time equations\r\n\t\t\\node (continuosTime) at (-3.5,0) [text centered]{\\textit{Continuos-time:}};\r\n\t\t\r\n\t\t\\node (rettangoloContinuo) at (-3.5,-1.5) []{\r\n\t\t\t\r\n\t\t\t\\boxed{\r\n\t\t\t\t\\begin{array}{cc}\r\n\t\t\t\t\\dot{x}(t)=Ax(t)+Bu(t)\\\\\r\n\t\t\t\t\\hspace{-1.4cm}y(t)=Cx(t)\r\n\t\t\t\t\\end{array}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t%The reference system\r\n\t\t\\draw[-latex] (-3.5,-5.0) coordinate node[below]{\\footnotesize{$0$}} -- (-3.5,-3.0) \r\n\t\tcoordinate;\r\n\t\t\\draw[-latex] (-3.5,-5.0) coordinate -- (-1.5,-5.0) coordinate;\r\n\t\t\\draw[-latex] (-3.5,-5.0) coordinate -- (-4.5,-6.0) coordinate;\r\n\t\t\r\n\t\t%Smooth curve\r\n\t\t\\draw [black] plot [smooth] coordinates {(-3.5,-5.0) (-3.2,-4.7) (-2.8,-4.2) (-2.5,-4.0)};\r\n\t\t\r\n\t\t%Line\r\n\t\t\\draw (-2.0,-4.2) coordinate -- (-2.5,-3.0) coordinate;\r\n\t\t\r\n\t\t%Arrows\r\n\t\t\\draw[-latex] (-2.5,-4.0) coordinate -- (-2.125,-3.9) coordinate;\r\n\t\t\\draw[-latex] (-2.5,-4.0) coordinate -- (-2.2,-3.7) coordinate;\r\n\t\t\\draw[-latex] (-2.5,-4.0) coordinate -- (-2.3,-3.5) coordinate;\r\n\t\t\\draw[-latex] (-2.5,-4.0) coordinate -- (-2.42,-3.2) coordinate;\r\n\t\t\r\n\t\t%Arrows with x\r\n\t\t\\draw[-latex] (-2.3,-4.25) coordinate node[below]{\\footnotesize{$x(t)$}} -- (-2.5,-4.0) \r\n\t\tcoordinate;\r\n\t\t\r\n\t\t%Callygraphic X\r\n\t\t\\draw (-3.0,-3.0) coordinate node[below]{$\\mathcal{X}$};\r\n\t\t\r\n\t\t%Xdot depicting\r\n\t\t\\draw (-2.2,-3.8) node[right]{\\footnotesize{$\\dot{x}(t)$}};\r\n\t\t\r\n\t\t\r\n\t\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\t\t%Discre-time equations\r\n\t\t\\node (discreteTime) at (3.5,0) [text centered]{\\textit{Discrete-time:}};\r\n\t\t\r\n\t\t\\node (rettangoloContinuo) at (3.5,-1.5) []{\r\n\t\t\t\r\n\t\t\t\\boxed{\r\n\t\t\t\t\\begin{array}{cc}\r\n\t\t\t\tx(k+1)=Ax(k)+Bu(k)\\\\\r\n\t\t\t\t\\hspace{-0.8cm}y(k)=Cx(k)\r\n\t\t\t\t\\end{array}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t%Reference systems\r\n\t\t\\draw[-latex] (3.5,-5.0) coordinate node[below]{\\footnotesize{$0$}} -- (3.5,-3.0) \r\n\t\tcoordinate;\r\n\t\t\\draw[-latex] (3.5,-5.0) coordinate -- (5.5,-5.0) coordinate;\r\n\t\t\\draw[-latex] (3.5,-5.0) coordinate -- (2.5,-6.0) coordinate;\r\n\t\t\r\n\t\t%Smooht curve\r\n\t\t\\draw[black] plot coordinates {(3.5,-5.0) (3.8,-4.7) (4.2,-4.2) (4.5,-4.0)};\r\n\t\t\\filldraw (3.5,-5.0) circle (1pt);\r\n\t\t\\filldraw (3.8,-4.7) circle (1pt);\r\n\t\t\\filldraw (4.2,-4.2) circle (1pt);\r\n\t\t\\filldraw (4.5,-4.0) circle (1pt);\r\n\t\t\r\n\t\t%Line\r\n\t\t\\draw (5.0,-4.2) coordinate -- (4.5,-3.0) coordinate;\r\n\t\t\r\n\t\t%Callygraphics x\r\n\t\t\\draw (3.0,-3.0) coordinate node[below]{$\\mathcal{X}$};\r\n\t\t\r\n\t\t%Depecting xk+a\r\n\t\t\\draw (4.9,-3.8) node[right]{\\footnotesize{$x(k+1)$}};\r\n\t\t\r\n\t\t%Arrow with x\r\n\t\t\\draw[-latex] (4.7,-4.25) coordinate node[below]{\\footnotesize{$x(k)$}} -- (4.5,-4.0) \r\n\t\tcoordinate;\r\n\t\t\r\n\t\t%Arrows representation\r\n\t\t\\draw[-latex] (4.5,-4.0) coordinate -- (4.88,-3.9) coordinate;\r\n\t\t\\draw[-latex] (4.5,-4.0) coordinate -- (4.8,-3.7) coordinate;\r\n\t\t\\draw[-latex] (4.5,-4.0) coordinate -- (4.7,-3.5) coordinate;\r\n\t\t\\draw[-latex] (4.5,-4.0) coordinate -- (4.58,-3.2) coordinate;\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\t\\begin{tikzpicture}[node distance=2cm]\r\n\t\t\t\r\n\t\t\t%Blocks\r\n\t\t\t\\node (virtualReality) at (2.5,0) [rectangle, draw, text centered, minimum width=2.5cm, \r\n\t\t\tminimum height=1cm] {Virtual Reality};\r\n\t\t\t\\node (classifier) at (-2,0) [rectangle, draw, text centered, minimum width=2.5cm, \r\n\t\t\tminimum height=1cm] {Classifier};\r\n\t\t\t\\node (computing) at (-3,3)  [rectangle, draw, text centered, minimum width=2.5cm, \r\n\t\t\tminimum height=1cm] {Computing};\r\n\t\t\t\\node (controller) at (0.5,3) [rectangle, draw, text centered, minimum \r\n\t\t\twidth=2.5cm,minimum height=1cm] {Controller};\r\n\t\t\t\\node (car) at (7.8,-0.25) [rectangle, draw, text centered, minimum width=2.5cm, \r\n\t\t\tminimum height=1cm] {Car};\r\n\t\t\t\\node (drone) at (4.0,3) [rectangle, draw, text centered, minimum width=2.5cm, minimum \r\n\t\t\theight=1cm] {Drone};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw [-latex] (virtualReality.west) -- (classifier.east);\r\n\t\t\t\\draw [-latex] (classifier.west) -- (-5.0,0) -- (-5.0,3) -- (computing.west);\r\n\t\t\t\\draw [-latex] (computing.east) -- (controller.west);\r\n\t\t\t\\draw [-latex] (controller.east) -- (drone.west);\r\n\t\t\t\\draw [-latex] (car.west) -- (3.9,-0.25);\r\n\t\t\t\\draw [-latex] (drone.east) -- (6.0,3) -- (6.0,0.255) -- (3.9,0.255);\r\n\t\t\t\\draw [-latex] (5.7,3) -- (5.7,4.5) -- (0.5,4.5) -- (controller.north);\r\n\t\t\t\\node (circle) at (5.7,3) [circle, draw, scale=0.4, fill=black] {};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Reference system\r\n\t\t\\draw[dashed] (0,0) coordinate -- (0,1) coordinate;\r\n\t\t\\draw[-latex] (0,1) coordinate -- (0,3) coordinate node[above left]{$y$};\r\n\t\t\\draw[dashed] (0,0) coordinate -- (1,0) coordinate;\r\n\t\t\\draw[-] (1,0) coordinate -- (3,0) coordinate node[above right]{$-x$};\r\n\t\t\\draw[dashed] (0,0) coordinate -- (-1.2,0) coordinate;\r\n\t\t\\draw[-latex] (-1.2,0) coordinate -- (-3,0) coordinate node[above left]{$x$};\r\n\t\t\\node (circle) at (0,0) [circle, draw, dashed, minimum size=0.5cm]{};\r\n\t\t\\node[circle,draw,black,scale=0.3, fill=black] at (0,0) {};\r\n\t\t\\draw (0,-0.25) coordinate node[below left]{$z$};\r\n\t\t\r\n\t\t%Camera\r\n\t\t\\draw[-, line width=1.25pt] (1,1) coordinate -- (-1,1) coordinate;\r\n\t\t\\draw[-, line width=1.25pt] (1,-1) coordinate -- (-1,-1) coordinate;\r\n\t\t\\draw[-, line width=1.25pt] (1,-1) coordinate -- (1,1) coordinate;\r\n\t\t\\draw[-, line width=1.25pt] (-1,-1) coordinate -- (-1,1) coordinate;\r\n\t\t\r\n\t\t\\draw[-, line width=1.25pt] (-1,-1) coordinate -- (-1.2,-1.2) coordinate;\r\n\t\t\\draw[-, line width=1.25pt] (-1,1) coordinate -- (-1.2,1.2) coordinate;\r\n\t\t\\draw[-, line width=1.25pt] (-1.2,1.2) coordinate -- (-1.2,-1.2) coordinate;\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.8}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Computing block\r\n\t\t\t\\node (computing) at (-4.2,0) [draw, rectangle, text centered, minimum width=1cm, \r\n\t\t\tminimum height=2cm]{Computing};\r\n\t\t\t\r\n\t\t\t%Reference generator\r\n\t\t\t\\node (referenceGenerator) at (-0.7,0) [draw, rectangle, minimum width=1cm, text \r\n\t\t\twidth=5em, minimum height=2cm, text centered]{References\\\\ Generator};\r\n\t\t\t\r\n\t\t\t%Trajectory controller\r\n\t\t\t\\node (trajectoryController) at (2.7,0) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=2cm, text centered, text width=5em]{Dynamics\\\\ Control};\r\n\t\t\t\r\n\t\t\t%Drone\r\n\t\t\t\\node (drone) at (6.2,0) [draw, rectangle, minimum width=1cm, minimum height=2cm, text \r\n\t\t\tcentered, text width=5em]{Drone};\r\n\t\t\t\r\n\t\t\t%Matlab virtual world\r\n\t\t\t\\node (virtualWorld) at (10.4,0) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=2cm, text centered, text width=5em]{Matlab \\\\Virtual World};\r\n\t\t\t\r\n\t\t\t%Links among blocks\r\n\t\t\t\\draw[-latex] (computing.east) node[above right]{$e_x,\\,e_y$} node[below \r\n\t\t\tright]{$area_m$}-- (referenceGenerator.west);\r\n\t\t\t\\draw[-latex] (referenceGenerator.east) -- (trajectoryController.west) node[below \r\n\t\t\tleft]{$z_r,\\,\\psi_r$} node[above left]{$x_r,\\,y_r$};\r\n\t\t\t\\draw[-latex] (trajectoryController.east) -- (drone.west) node[above \r\n\t\t\tleft]{$\\dot{z}_c,\\,\\dot{\\psi}_c$} node[below left]{$\\phi_c,\\,\\theta_c$};\r\n\t\t\t\\draw[-latex] (drone.-20) node[below right]{$\\phi_d,\\,\\theta_d,\\,\\psi_d$} node[above \r\n\t\t\tright]{$x_d,\\,y_d,\\,z_d$} -- (virtualWorld.200);\r\n\t\t\t\\draw[-latex] (virtualWorld.east) -- (11.9,0) coordinate -- (11.9,-2.0) coordinate \r\n\t\t\t--(-5.8,-2.0) coordinate -- (-5.8,0) coordinate -- (computing.west);\r\n\t\t\t\\draw (2.35,-2.0) coordinate node[above right]{$IMG$};\r\n\t\t\t\r\n\t\t\t%Link for connecting the car block\r\n\t\t\t\\draw[-latex] (7.75,1.45) coordinate node[left]{$Auto$}-- (8.52,1.45) coordinate -- \r\n\t\t\t(8.52,0.4) coordinate -- (9.31,0.4) coordinate;\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.7}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Initial links\r\n\t\t\t\\draw[-latex] (-5.5,1.5) coordinate node[left]{$U_1$} -- (-4.5,1.5) coordinate;\r\n\t\t\t\\draw[-latex] (-5.5,0.7) coordinate node[left]{$U_2$} -- (-4.5,0.7) coordinate;\r\n\t\t\t\\draw[-latex] (-5.5,-0.7) coordinate node[left]{$U_3$} -- (-4.5,-0.7) coordinate;\r\n\t\t\t\\draw[-latex] (-5.5,-1.5) coordinate node[left]{$U_3$} -- (-4.5,-1.5) coordinate;\r\n\t\t\t\r\n\t\t\t%Omega qr calculator block\r\n\t\t\t\\node (omegaQRCalculator) at (-3.5,0) [draw, rectangle, minimum height=5cm, minimum \r\n\t\t\twidth=2cm, text centered, label={[align=center]below:Omega qr\\\\computation}]{};\r\n\t\t\t\r\n\t\t\t%Variables - omega qr calculator\r\n\t\t\t\\draw (-3.8, 1.5) coordinate node[left]{$U_{1}$};\r\n\t\t\t\\draw (-3.8, 0.7) coordinate node[left]{$U_{2}$};\r\n\t\t\t\\draw (-3.8, -0.7) coordinate node[left]{$U_{3}$};\r\n\t\t\t\\draw (-3.8, -1.5) coordinate node[left]{$U_{4}$};\r\n\t\t\t\r\n\t\t\t\\draw (-2.5, 2.0) coordinate node[left]{$\\Omega$};\r\n\t\t\t\\draw (-2.5, 1.0) coordinate node[left]{$U_{1_{2}}$};\r\n\t\t\t\\draw (-2.5, 0.0) coordinate node[left]{$U_{2_{2}}$};\r\n\t\t\t\\draw (-2.5, -1.0) coordinate node[left]{$U_{3_{2}}$};\r\n\t\t\t\\draw (-2.5, -2.0) coordinate node[left]{$U_{4_{2}}$};\r\n\t\t\t\r\n\t\t\t%Links between the omega and angles blocks\r\n\t\t\t\\draw[-latex] (-2.5,2.0) coordinate -- (-1.75,2.0) coordinate -- (-1.75,-3.0) \r\n\t\t\tcoordinate -- (-1,-3.0) coordinate;\r\n\t\t\t\\draw[-latex] (-2.5,1.0) coordinate -- (-1.95,1.0) coordinate -- (-1.95,4.0) coordinate \r\n\t\t\t-- (6.5,4.0) coordinate -- (6.5,-1.5) coordinate -- (7,-1.5) coordinate;\r\n\t\t\t\\draw[-latex] (-2.5,0.0) coordinate -- (-1,0.0) coordinate;\r\n\t\t\t\\draw[-latex] (-2.5,-1.0) coordinate -- (-1,-1.0) coordinate;\r\n\t\t\t\\draw[-latex] (-2.5,-2.0) coordinate -- (-1,-2.0) coordinate;\r\n\t\t\t\r\n\t\t\t%Angles block\r\n\t\t\t\\node (anglesBlock) at (0,0) [draw, rectangle, minimum height=7cm, minimum width=2cm, \r\n\t\t\ttext centered, label={[align=center]below:Angles}]{};\r\n\t\t\t\r\n\t\t\t%Variables - angles\r\n\t\t\t\\draw (-0.5,3.0) coordinate node[left]{$\\dot{\\phi}$};\r\n\t\t\t\\draw (-0.5,2.0) coordinate node[left]{$\\dot{\\theta}$};\r\n\t\t\t\\draw (-0.5,1.0) coordinate node[left]{$\\dot{\\psi}$};\r\n\t\t\t\\draw (-0.3,0.0) coordinate node[left]{$U_2$};\r\n\t\t\t\\draw (-0.3,-1.0) coordinate node[left]{$U_3$};\r\n\t\t\t\\draw (-0.3,-2.0) coordinate node[left]{$U_4$};\r\n\t\t\t\\draw (-0.4,-3.0) coordinate node[left]{$\\Omega$};\r\n\t\t\t\r\n\t\t\t\\draw (1.0, 2.5) coordinate node[left]{$\\ddot{\\phi}$};\r\n\t\t\t\\draw (1.0, 0.0) coordinate node[left]{$\\ddot{\\theta}$};\r\n\t\t\t\\draw (1.0, -2.5) coordinate node[left]{$\\ddot{\\psi}$};\r\n\t\t\t\r\n\t\t\t%First integrator block - angles\r\n\t\t\t\\node (integrator1) at (3,0) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{\\theta}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator2) at (3,2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{\\phi}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator3) at (3,-2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{\\psi}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\r\n\t\t\t%Links between the angles and integrator blocks\r\n\t\t\t\\draw[-latex] (1.0,2.5) coordinate -- (1.5,2.5) coordinate -- (1.5,2.0) coordinate -- \r\n\t\t\t(integrator2.west);\r\n\t\t\t\\draw[-latex] (1.0,0.0) coordinate -- (integrator1.west);\r\n\t\t\t\\draw[-latex] (1.0,-2.5) coordinate -- (1.5,-2.5) coordinate -- (1.5,-2.0) coordinate \r\n\t\t\t-- (integrator3.west);\r\n\t\t\t\r\n\t\t\t%Second integrators block - angles\r\n\t\t\t\\node (integrator4) at (5,0) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\theta$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator5) at (5,2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\phi$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator6) at (5,-2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\psi$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\r\n\t\t\t%Circle on the connection links\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (4,0){};\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (4.2,-2){};\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (3.8,2){};\r\n\t\t\t\r\n\t\t\t%Links among blocks\r\n\t\t\t\\draw[-latex] (4,0) coordinate -- (4,4.2) coordinate -- (-1.55,4.2) coordinate -- \r\n\t\t\t(-1.55,2.0) coordinate -- (-1.0,2.0);\r\n\t\t\t\\draw[-latex] (4.2,-2) coordinate -- (4.2,3.8) coordinate -- (-1.35,3.8) coordinate -- \r\n\t\t\t(-1.35,1.0) coordinate -- (-1.0,1.0);\r\n\t\t\t\\draw[-latex] (3.8,2) coordinate -- (3.8,4.4) coordinate -- (-1.15,4.4) coordinate -- \r\n\t\t\t(-1.15,3.0) coordinate -- (-1.0,3.0);\r\n\t\t\t\r\n\t\t\t%Links among integrators blocks\r\n\t\t\t\\draw[-latex] (integrator1.east) -- (integrator4.west);\r\n\t\t\t\\draw[-latex] (integrator2.east) -- (integrator5.west);\r\n\t\t\t\\draw[-latex] (integrator3.east) -- (integrator6.west);\r\n\t\t\t\r\n\t\t\t%Connection links between the integrators and displacement blocks\r\n\t\t\t\\draw[-latex] (integrator5.east) -- (6.3,2) coordinate -- (6.3,1.5) coordinate -- \r\n\t\t\t(7.0,1.5) coordinate;\r\n\t\t\t\\draw[-latex] (integrator4.east) -- (6.7,0.0) coordinate -- (6.7,0.5) coordinate -- \r\n\t\t\t(7.0,0.5) coordinate;\r\n\t\t\t\\draw[-latex] (integrator6.east) -- (6.1,-2) coordinate -- (6.1,-0.5) coordinate -- \r\n\t\t\t(7.0,-0.5) coordinate;\r\n\t\t\t\r\n\t\t\t%Displacement block\r\n\t\t\t\\node (bloccoDisplacement) at (8,0) [draw, rectangle, minimum height=4cm, minimum \r\n\t\t\twidth=2cm, text centered, label={[align=center]below:Displacements}]{};\r\n\t\t\t\r\n\t\t\t%Variables - displacement\r\n\t\t\t\\draw (7.5,1.5) coordinate node[left]{$\\phi$};\r\n\t\t\t\\draw (7.5,0.5) coordinate node[left]{$\\theta$};\r\n\t\t\t\\draw (7.5,-0.5) coordinate node[left]{$\\psi$};\r\n\t\t\t\\draw (7.65,-1.5) coordinate node[left]{$U_1$};\r\n\t\t\t\r\n\t\t\t\\draw (8.9,1.25) coordinate node[left]{$\\ddot{x}$};\r\n\t\t\t\\draw (8.9,0.0) coordinate node[left]{$\\ddot{y}$};\r\n\t\t\t\\draw (8.9,-1.25) coordinate node[left]{$\\ddot{z}$};\r\n\t\t\t\r\n\t\t\t%First integrators block - displacement\r\n\t\t\t\\node (integrator7) at (11,0) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{y}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator8) at (11,2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{x}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator9) at (11,-2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered, label={[align=center]below:$\\dot{z}$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\r\n\t\t\t%Links for the displacement block\r\n\t\t\t\\draw[-latex] (9,1.25) coordinate -- (10.1,1.25) coordinate -- (10.1,2) coordinate -- \r\n\t\t\t(integrator8.west);\r\n\t\t\t\\draw[-latex] (9,0.0) coordinate -- (integrator7.west);\r\n\t\t\t\\draw[-latex] (9,-1.25) coordinate -- (10.1,-1.25) coordinate -- (10.1,-2) coordinate \r\n\t\t\t-- (integrator9.west);\r\n\t\t\t\r\n\t\t\t%Second block of integrators - displacement\r\n\t\t\t\\node (integrator10) at (13,0) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered,label={[align=center]below:$y$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator11) at (13,2) [draw, rectangle, minimum height=1cm, minimum width=1cm, \r\n\t\t\ttext centered,label={[align=center]below:$x$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\\node (integrator12) at (13,-2) [draw, rectangle, minimum height=1cm, minimum \r\n\t\t\twidth=1cm, text centered,label={[align=center]below:$z$}]{$\\cfrac{1}{s}$};\r\n\t\t\t\r\n\t\t\t%Connections between the two integrators blocks\r\n\t\t\t\\draw[-latex] (integrator7.east) -- (integrator10.west);\r\n\t\t\t\\draw[-latex] (integrator8.east) -- (integrator11.west);\r\n\t\t\t\\draw[-latex] (integrator9.east) -- (integrator12.west);\r\n\t\t\t\r\n\t\t\t%Final interconnections\r\n\t\t\t\\draw[-latex] (integrator10.east) -- (15,0) coordinate node[right]{$y$};\r\n\t\t\t\\draw[-latex] (integrator11.east) -- (15,2) coordinate node[right]{$x$};\r\n\t\t\t\\draw[-latex] (integrator12.east) -- (15,-2) coordinate node[right]{$z$};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.85}{\r\n\t\t\t\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\\node (feedbackController) at (0,1.25) [draw, ellipse, text centered, minimum \r\n\t\t\theight=1cm, fill=yellow!25, text width=10em]{\\textbf{ROS NODE}\\\\Feedback Controller in \r\n\t\t\tSimulink};\r\n\t\t\t\\node (robotSimulator) at (0,-4.25) [draw, ellipse, text centered, minimum \r\n\t\t\theight=2cm,fill=yellow!25, text width=10em]{\\textbf{ROS NODE}\\\\Robot Simulator};\r\n\t\t\t\r\n\t\t\t\\node (odom) at (-4,-1.5) [draw, rectangle, text centered, text width=19em, minimum \r\n\t\t\theight=2cm, rounded corners=5pt]{\\textbf{Topic}: /odom\\\\\\textbf{Message type}: \r\n\t\t\tnav\\_msgs/Odometry};\r\n\t\t\t\\node (mobileBase) at (4,-1.5) [draw, rectangle, text centered, text width=19em, \r\n\t\t\tminimum height=2cm, rounded corners=5pt]{\\textbf{Topic}: \r\n\t\t\t/mobile\\_base/commands/velocity\\\\\\textbf{Message type}: geometry\\_msgs/Twist};\r\n\t\t\t\r\n\t\t\t\\draw[-latex, line width=1.25pt] (feedbackController) [out=0, in=90] to (mobileBase);\r\n\t\t\t\\draw[-latex, line width=1.25pt] (mobileBase) [out=270, in=0] to (robotSimulator);\r\n\t\t\t\\draw[-latex, line width=1.25pt] (robotSimulator) [out=180, in=270] to (odom);\r\n\t\t\t\\draw[-latex, line width=1.25pt] (odom) [out=90, in=180] to (feedbackController); \r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Nodes in the first part of the scheme\r\n\t\t\\node (firstTransformation) at (-2,0.5) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1cm, text centered]{$T_1$};\r\n\t\t\r\n\t\t\\node (firstPD) at (0.75,0.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$PD$};\r\n\t\t\r\n\t\t\\node (firstK) at (3.45,0.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$K_1$};\r\n\t\t\r\n\t\t\\draw [decorate,decoration={brace, mirror, amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t(4.2,1) -- (0,1) node [black,midway,yshift=0.8cm] {\\footnotesize $PID$};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (-4,0.5) coordinate node[above]{$e_{area}$} -- (firstTransformation.west);\r\n\t\t\r\n\t\t\\draw[-latex] (firstTransformation.east) -- (0,0.5) coordinate node[above left]{$\\Delta \r\n\t\tx_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (firstPD.east) -- (2.7,0.5) coordinate node[above left]{$v_{{x}_R}$};\r\n\t\t\r\n\t\t\\draw[-latex] (firstK.east) -- (5.45,0.5) coordinate node[above]{$\\theta_d$};\r\n\t\t\r\n\t\t\r\n\t\t%Nodes in the second part of the scheme\r\n\t\t\\node (secondTransformation) at (-2,-1.5) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1cm, text centered]{$T_2$};\r\n\t\t\r\n\t\t\\node (secondPD) at (0.75,-1.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$PD$};\r\n\t\t\r\n\t\t\\node (secondK) at (3.45,-1.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$K_2$};\r\n\t\t\r\n\t\t\\draw [decorate,decoration={brace, mirror, amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t(4.2,-1.0) -- (0,-1.0) node [black,midway,yshift=0.8cm] {\\footnotesize\r\n\t\t\t$PID$};\r\n\t\t\r\n\t\t%Links among blocks\r\n\t\t\\draw[-latex] (-4,-1.5) coordinate node[above]{$e_x$} -- (secondTransformation.west);\r\n\t\t\r\n\t\t\\draw[-latex] (secondTransformation.east) -- (0,-1.5) coordinate node[above left]{$\\Delta \r\n\t\ty_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (secondPD.east) -- (2.7,-1.5) coordinate node[above left]{$v_{{y}_R}$};\r\n\t\t\r\n\t\t\\draw[-latex] (secondK.east) -- (5.45,-1.5) coordinate node[above]{$\\phi_d$};\r\n\t\t\r\n\t\t\r\n\t\t%Nodes in the third part of the scheme\r\n\t\t\\node (thirdTransformation) at (-2,-3.0) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1cm, text centered]{$T_3$};\r\n\t\t\r\n\t\t\\node (thirdPD) at (0.75,-3.0) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$\\frac{d}{dt}$};\r\n\t\t\r\n\t\t%Links among blocks\r\n\t\t\\draw[-latex] (-3.35, -1.5) coordinate --  (-3.35,-3.0) coordinate -- \r\n\t\t(thirdTransformation.west);\r\n\t\t\r\n\t\t\\draw[-latex] (thirdTransformation.east) -- (0,-3.0) coordinate node[above left]{$\\Delta \r\n\t\t\\psi_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (thirdPD.east) -- (2.7,-3.0) coordinate node[above left]{$\\dot{\\psi}_d$};\r\n\t\t\r\n\t\t\r\n\t\t%Nodes of the fourth part of the scheme\r\n\t\t\\node (fourthTransformation) at (-2,-4.5) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1cm, text centered]{$T_4$};\r\n\t\t\r\n\t\t\\node (fourthPD) at (0.75,-4.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$\\frac{d}{dt}$};\r\n\t\t\r\n\t\t%Links among blocks\r\n\t\t\\draw[-latex] (-4,-4.5) coordinate node[above]{$e_y$} -- (fourthTransformation.west);\r\n\t\t\r\n\t\t\\draw[-latex] (fourthTransformation.east) -- (0,-4.5) coordinate node[above left]{$\\Delta \r\n\t\tz_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (fourthPD.east) -- (2.7,-4.5) coordinate node[above left]{$\\dot{z}_d$};\r\n\t\t\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Attitude controller\r\n\t\t\t\\node (attitudeController) at (-3.40,-1.25) [rectangle, label=Attitude Control, text \r\n\t\t\tcentered, minimum height=6cm, minimum width=7.3cm]{};\r\n\t\t\t\r\n\t\t\t\\draw[dashed, gray, line width=1.25pt] (-6.75,1.75) coordinate -- (-6.75,-4.25) \r\n\t\t\tcoordinate -- (0.2,-4.25) coordinate -- (0.2,1.75) coordinate -- (-6.75,1.75) \r\n\t\t\tcoordinate;\r\n\t\t\t\r\n\t\t\t%Position controller\r\n\t\t\t\\draw[dashed, gray, line width=1.25pt] (0.5, 1.75) coordinate -- (7.7, 1.75) coordinate \r\n\t\t\t-- (7.7, -7.3) coordinate --  (-6.75,-7.3) coordinate -- (-6.75,-4.6) coordinate --  \r\n\t\t\t(0.5,-4.6) coordinate -- (0.5,1.75) coordinate;\r\n\t\t\t\r\n\t\t\t\\node (positionController) at (4.15,-1.25) [label=Position Control, text centered, \r\n\t\t\tminimum width=2.65cm, minimum height=6cm, rectangle]{};\r\n\t\t\t\r\n\t\t\t%Blocks in the first part of the scheme\r\n\t\t\t\\node (adder1) at (-4.5,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (pi1) at (-2.5,0) [draw, rectangle, text centered, minimum height=1.0cm, minimum \r\n\t\t\twidth=1.5cm]{$\\text{PI}_{\\psi_d}$};\r\n\t\t\t\r\n\t\t\t\\node (adder2) at (-0.25,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (adder20) at (1.6,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (pi2) at (3.5,0) [draw, rectangle, text centered, minimum height=1cm, minimum \r\n\t\t\twidth=1.5cm]{$\\text{PI}_{y_d}$};\r\n\t\t\t\r\n\t\t\t\\node (adder6) at (5.9,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t%Links among blocks\r\n\t\t\t\\draw[-latex] (-6.0,0) coordinate node[above]{$x_{img}$} -- (adder1.west);\r\n\t\t\t\\draw[-latex] (-4.5,-1.5) coordinate node[above left]{$x_{bb}$} -- (adder1.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder1.east) -- (pi1.west);\r\n\t\t\t\\draw[-latex] (pi1.east) -- (adder2.west);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-0.25,-1.5) coordinate node[above left]{$\\psi_{init}$}-- (adder2.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (1.6,-1.5) coordinate node[above left]{$\\psi_\\mathrm{ref}$} -- \r\n\t\t\t(adder20.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder2.east) -- (adder20.west);\r\n\t\t\t\\draw[-latex] (adder20.east) -- (pi2.west);\r\n\t\t\t\\draw[-latex] (pi2.east) -- (adder6.west);\r\n\t\t\t\\draw (4.5,0.05) node[above right]{$\\Delta y_d$};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (5.9,-1.5) coordinate node[above left]{$y_{init}$} -- (adder6.south);\r\n\t\t\t\\draw[-latex] (adder6.east) -- (6.9,0) coordinate node[above right]{$y_d$};\r\n\t\t\t\r\n\t\t\t%Signs\r\n\t\t\t\\draw (-4.5,0.15) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-4.5,-0.25) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\draw (-0.25,0.15) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-0.25,-0.25) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t\\draw (1.6,0.15) coordinate node[above left]{$-$};\r\n\t\t\t\\draw (1.6,-0.25) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t\\draw (5.9,0.15) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (5.9,-0.25) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t%Errors\r\n\t\t\t\\draw (-3.8,0.55) coordinate node[below]{$e_x$};\r\n\t\t\t\\draw (-1.25,0.55) coordinate node[below]{$\\Delta \\psi_d$};\r\n\t\t\t\\draw (0.85,0.55) coordinate node[below]{$\\psi_d$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t%Blocks in the second part of the scheme\r\n\t\t\t\\node (adder3) at (-4.5,-2.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (pi3) at (-2.5,-2.5) [draw, rectangle, text centered, minimum height=1.0cm, \r\n\t\t\tminimum width=1.5cm]{$\\text{PI}_{\\theta_d}$};\r\n\t\t\t\r\n\t\t\t\\node (adder4) at (-0.25,-2.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (adder50) at (1.6,-2.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (pi4) at (3.5,-2.5) [draw, rectangle, text centered, minimum height=1cm, minimum \r\n\t\t\twidth=1.5cm]{$\\text{PI}_{z_d}$};\r\n\t\t\t\r\n\t\t\t\\node (adder7) at (5.9,-2.5) [draw, circle, text centered, minimum size=0.5cm]{}; \r\n\t\t\t\r\n\t\t\t%Links among blocks\r\n\t\t\t\\draw[-latex] (-6.0,-2.5) coordinate node[above]{$y_{img}$} -- (adder3.west);\r\n\t\t\t\\draw[-latex] (-4.5,-4.0) coordinate node[above left]{$y_{bb}$} -- (adder3.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder3.east) -- (pi3.west);\r\n\t\t\t\\draw[-latex] (pi3.east) -- (adder4.west);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-0.25,-4.0) coordinate node[above left]{$\\theta_{init}$} -- \r\n\t\t\t(adder4.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (1.6,-4.0) coordinate node[above left]{$\\theta_\\mathrm{ref}$} -- \r\n\t\t\t(adder50.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder4.east) -- (adder50.west);\r\n\t\t\t\\draw[-latex] (adder50.east) -- (pi4.west);\r\n\t\t\t\\draw[-latex] (pi4.east) -- (adder7.west); \r\n\t\t\t\\draw (4.5,-2.45) coordinate node[above right]{$\\Delta z_d$};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (5.9,-4.0) node[above left]{$z_{init}$} -- (adder7.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder7.east) -- (6.9,-2.5) coordinate node[above right]{$z_d$};\r\n\t\t\t\r\n\t\t\t%Sings\r\n\t\t\t\\draw (-4.5,-2.35) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-4.5,-2.65) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\draw (-0.25,-2.35) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-0.25,-2.65) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t\\draw (1.6,-2.35) coordinate node[above left]{$-$};\r\n\t\t\t\\draw (1.6,-2.65) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t\\draw (5.9,-2.35) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (5.9,-2.65) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t%Errors\r\n\t\t\t\\draw (-3.8,-1.95) coordinate node[below]{$e_y$};\r\n\t\t\t\\draw (-1.25,-1.95) coordinate node[below]{$\\Delta \\theta_d$};\r\n\t\t\t\\draw (0.85,-1.95) coordinate node[below]{$\\theta_d$};\r\n\t\t\t\r\n\t\t\t%Blocks in the third part of the scheme\r\n\t\t\t\\node (adder5) at (-4.5,-5.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (pi5) at (-2.5,-5.5) [draw, rectangle, text centered, minimum height=1.0cm, \r\n\t\t\tminimum width=1.5cm]{$\\text{PI}_{x_d}$};\r\n\t\t\t\r\n\t\t\t\\node (adder8) at (-0.25,-5.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (-6.0,-5.5) coordinate node[above]{$area_{\\mathrm{ref}}$} -- \r\n\t\t\t(adder5.west);\r\n\t\t\t\\draw[-latex] (-4.5,-7.0) coordinate node[above left]{$area_{\\mathrm{mes}}$} -- \r\n\t\t\t(adder5.south);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder5.east) -- (pi5.west);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (pi5.east) -- (adder8.west);\r\n\t\t\t\\draw (-1.25,-5.5) coordinate node[above]{$\\Delta x_d$};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-0.25,-7.0) coordinate node[above left]{$x_{init}$} -- (adder8.south);\r\n\t\t\t\r\n\t\t\t%Signs\r\n\t\t\t\\draw (-4.5,-5.35) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-4.5,-5.65) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\draw (-0.25,-5.35) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-0.25,-5.65) coordinate node[below right]{$+$};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (adder8.east) -- (1.8,-5.5) coordinate node[above right]{$x_d$};\r\n\t\t\t\r\n\t\t\t%Errors\r\n\t\t\t\\draw (-3.8,-4.95) coordinate node[below]{$e_{area}$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}[node distance=2cm]\r\n\t\t\t\r\n\t\t\t%Nodes\r\n\t\t\t\\node (adder) at (0,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (regulator) at (3,0) [draw, rectangle, text centered, minimum width=2.2cm, \r\n\t\t\tminimum height=1cm]{Regulator};\r\n\t\t\t\r\n\t\t\t\\node (robot) at (7,0) [draw, rectangle, text centered, minimum width=2cm, minimum \r\n\t\t\theight=1cm]{Robot};\r\n\t\t\t\r\n\t\t\t\\node (camera) at (7,-2) [draw, rectangle, text centered, minimum width=2cm, minimum \r\n\t\t\theight=1cm]{Camera};\r\n\t\t\t\r\n\t\t\t\\node (observer) at (3,-2) [draw, rectangle, text centered, minimum width=2cm, minimum \r\n\t\t\theight=1cm]{Observer};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (adder) --  (regulator);\r\n\t\t\t\\draw[-latex] (camera) -- (observer);\r\n\t\t\t\\draw[-latex] (regulator) -- (robot);\r\n\t\t\t\\draw[-latex] (observer.west) -- (0,-2) coordinate -- (adder.south);\r\n\t\t\t\\draw[-latex] (robot.east) -- (10,0) coordinate;\r\n\t\t\t\\draw[-latex] (9,0) coordinate -- (9,-2) coordinate -- (camera.east);\r\n\t\t\t\\draw[-latex] (-1,0) coordinate -- (adder.west);\r\n\t\t\t\r\n\t\t\t%Variables\r\n\t\t\t\\draw (9, 0.5) coordinate node[below]{$y$};\r\n\t\t\t\\draw (1, 0.5) coordinate node[below]{$e$};\r\n\t\t\t\\draw (-1.4,0.35) coordinate node[below]{$rif$};\r\n\t\t\t\\draw (0,0.55) coordinate node[below left]{$+$};\r\n\t\t\t\\draw (0,-0.55) coordinate node[above right]{$-$};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.72}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Yaw angle\r\n\t\t\t\\node (yawAngle) at (0,0) [draw, rectangle, minimum height=2cm, minimum width=2cm, text \r\n\t\t\tcentered]{};\r\n\t\t\t\\draw (1,1) coordinate -- (1.2,1.2) coordinate;\r\n\t\t\t\\draw (1,-1) coordinate -- (1.2,-1.2) coordinate;\r\n\t\t\t\\draw (1.2,-1.2) coordinate -- (1.2,1.2) coordinate;\r\n\t\t\t\r\n\t\t\t%Drawing the angle\r\n\t\t\t\\draw (1.8,0) coordinate -- (2.2,0) coordinate;\r\n\t\t\t\\draw[-latex, line width=1.0pt] (2.0,0) coordinate -- (2.0, -1) coordinate node[above \r\n\t\t\tright]{$\\psi_d$};\r\n\t\t\t\r\n\t\t\t%Reference system\r\n\t\t\t\\draw[-latex] (-4,2) coordinate -- (-4,-1) coordinate node[above left]{$z$};\r\n\t\t\t\\draw[-latex] (-4,2) coordinate -- (-2,2) coordinate node[above]{$x$};\r\n\t\t\t\\node (circle) at (-4,2) [circle, draw, minimum size=0.5cm]{};\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (-4,2) {};\r\n\t\t\t\\draw (-4.25,2) coordinate node[above left]{$y$};\r\n\t\t\t\r\n\t\t\t%Dividing line among schems\r\n\t\t\t\\draw[dashed, draw=gray] (-6,-2) coordinate -- (6,-2) coordinate;\r\n\t\t\t\r\n\t\t\t%Roll angle\r\n\t\t\t\\node (rollAngle) at (0,-5) [draw, rectangle, minimum height=2cm, minimum width=2cm, \r\n\t\t\ttext centered]{};\r\n\t\t\t\\draw (1,-4) coordinate -- (1.2,-3.8) coordinate;\r\n\t\t\t\\draw (1,-6) coordinate -- (1.2,-6.2) coordinate;\r\n\t\t\t\\draw (1.2,-3.8) coordinate -- (1.2,-6.2) coordinate;\r\n\t\t\t\r\n\t\t\t%Roll angle drawing\r\n\t\t\t\\draw (1.8,-5) coordinate -- (2.2,-5) coordinate;\r\n\t\t\t\\draw[-latex, line width=1.0pt] (2.0,-5) coordinate -- (2.0, -6) coordinate node[above \r\n\t\t\tright]{$\\phi_d$};\r\n\t\t\t\r\n\t\t\t%Reference system\r\n\t\t\t\\draw[-latex] (-4,-3) coordinate -- (-2,-3) coordinate node[above]{$x$};\r\n\t\t\t\\draw[-latex] (-4,-3) coordinate -- (-4,-6) coordinate node[above left]{$z$};\r\n\t\t\t\\node (circle) at (-4,-3) [circle, draw, minimum size=0.5cm]{};\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (-4,-3) {};\r\n\t\t\t\\draw (-4.25,-3) coordinate node[above left]{$y$};\r\n\t\t\t\r\n\t\t\t%Diving line among schemes\r\n\t\t\t\\draw[dashed, draw=gray] (-6,-7) coordinate -- (6,-7) coordinate;\r\n\t\t\t\r\n\t\t\t%Pitch angle\r\n\t\t\t\\node (rollAngle) at (0,-9) [draw, rectangle, minimum height=2cm, minimum width=2cm, \r\n\t\t\ttext centered]{};\r\n\t\t\t\\draw (1,-8) coordinate -- (1.2,-7.8) coordinate;\r\n\t\t\t\\draw (1,-10) coordinate -- (1.2,-10.2) coordinate;\r\n\t\t\t\\draw (1.2,-7.8) coordinate -- (1.2,-10.2) coordinate;\r\n\t\t\t\r\n\t\t\t%Drawing the angle\r\n\t\t\t\\draw (0,-10.8) coordinate -- (0,-11.2) coordinate;\r\n\t\t\t\\draw[-latex, line width=1.0pt] (0,-11) coordinate -- (1.0, -11) coordinate node[above \r\n\t\t\tright]{$\\theta_d$};\r\n\t\t\t\r\n\t\t\t%Reference system\r\n\t\t\t\\draw[-latex] (-4,-10.5) coordinate -- (-2,-10.5) coordinate node[above]{$x$};\r\n\t\t\t\\draw[-latex] (-4,-10.5) coordinate -- (-4,-8) coordinate node[above left]{$y$};\r\n\t\t\t\\node (circle) at (-4,-10.5) [circle, draw, minimum size=0.5cm]{};\r\n\t\t\t\\node[circle,draw,black,scale=0.2, fill=black] (A) at (-4,-10.5) {};\r\n\t\t\t\\draw (-4.25,-10.5) coordinate node[above left]{$z$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.95}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Drawing first rectangle\r\n\t\t\\node (firstRectangle) at (0,0) [draw, rectangle, text centered, text width=1em, minimum \r\n\t\twidth=1cm, minimum height=2cm, label={Angles}]{$\\phi$ \\\\ $\\dot{\\phi}$ \\\\ \r\n\t\t$\\theta$ \\\\ $\\dot{\\theta}$ \\\\ $\\psi$ \\\\ $\\dot{\\psi}$};\r\n\t\t\r\n\t\t%Drawing second rectangle\r\n\t\t\\node (secondRectangle) at (3,2) [draw, rectangle, text centered, text width=1em, minimum \r\n\t\twidth=1cm, minimum height=2cm, label={Translation}]{$x$ \\\\ $\\dot{x}$ \\\\ $y$ \\\\ \r\n\t\t$\\dot{y}$ \\\\ $z$ \\\\ $\\dot{z}$};\r\n\t\t\r\n\t\t%First arrow\r\n\t\t\\draw[-latex] (0.5,1) coordinate -- (2.5,1) coordinate;\r\n\t\t\\draw (1.5,0.8) coordinate node[below, text width=1em]{$\\phi$ \\\\ $\\theta$ \\\\ $\\psi$};\r\n\t\t\\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt},yshift=0pt]\r\n\t\t(1.45,0.7) -- (1.45,-0.9) node [black,midway,xshift=0.8cm] {};\r\n\t\t\\draw [decorate,decoration={brace,amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t(1.40,0.7) -- (1.40,-0.9) node [black,midway,xshift=0.8cm] {};\r\n\t\t\r\n\t\t%Second arrow\r\n\t\t\\draw[latex-] (-0.5,0) coordinate -- (-2.5,0) coordinate;\r\n\t\t\\draw (-2.8,0) coordinate node[left, text width=1em]{$U_2$ \\\\ $U_3$ \\\\ $U_4$};\r\n\t\t\\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt},yshift=0pt]\r\n\t\t(-3.2,1) -- (-3.2,-1) node [black,midway,xshift=0.8cm] {};\r\n\t\t\\draw [decorate,decoration={brace,amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t(-3.05,1) -- (-3.05,-1) node [black,midway,xshift=0.8cm] {};\r\n\t\t\r\n\t\t%Third arrow\r\n\t\t\\draw[-latex] (0.5,3) coordinate -- (2.5,3) coordinate;\r\n\t\t\\draw (0.5,3) coordinate node[left]{$U_1$};\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Blocks of the scheme\r\n\t\t\t\\node (attitudePID) at (3.5,0) [draw, rectangle, minimum width=1cm, minimum height=1cm, \r\n\t\t\ttext centered, text width=5em]{Attitude PID\\\\250Hz};\r\n\t\t\t\\node (ratePID) at (7.25,0) [draw, rectangle, minimum width=1cm, minimum height=1cm, \r\n\t\t\ttext centered, text width=5em]{Rate PID\\\\Controller\\\\500Hz};\r\n\t\t\t\\node (actuators) at (10.25,0) [draw, rectangle, minimum width=1cm, minimum height=1cm, \r\n\t\t\ttext centered, text width=5em]{Actuator\\\\(motors)};\r\n\t\t\t\\node (gyroscope) at (10.25,-1.5) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=1cm, text centered]{Gyroscope};\r\n\t\t\t\\node (accelerometer) at (10.25,-3) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=1cm, text centered]{Accelerometer};\r\n\t\t\t\\node (sensorFusion) at (3.5,-1.5) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=1cm, text centered]{Sensor Fusion};\r\n\t\t\t\r\n\t\t\t%Adders\r\n\t\t\t\\node (adder1) at (1.75,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\\node (adder2) at (5.5,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t%Bubblies\r\n\t\t\t\\node (coordinates1) at (5.51,-1.5) [circle, draw, scale=0.4, fill=black]{};\r\n\t\t\t\r\n\t\t\t%Linx\r\n\t\t\t\\draw[-latex] (0.5,0) coordinate node[above]{$\\theta_c$, $\\phi_c$} -- (adder1);\r\n\t\t\t\\draw[-latex] (adder1)   -- (attitudePID);\r\n\t\t\t\\draw[-latex] (attitudePID) -- node[above]{$p_c$} node[below]{$q_c$} (adder2);\r\n\t\t\t\\draw[-latex] (adder2) -- (ratePID);\r\n\t\t\t\\draw[-latex] (ratePID) -- (actuators);\r\n\t\t\t\\draw[-latex] (gyroscope) -- node[below]{$500Hz$} (sensorFusion);\r\n\t\t\t\\draw[-latex] (accelerometer) -| (sensorFusion);\r\n\t\t\t\\draw[-latex] (sensorFusion) -| (adder2);\r\n\t\t\t\\draw[-latex] (sensorFusion) -| node[below left]{$250Hz$} (adder1);\r\n\t\t\t\\draw[-latex] (5.5,1.25) coordinate node[above]{$\\dot{\\psi}_c$} -- (adder2);\r\n\t\t\t\\draw[-latex] (10.25,1.25) coordinate node[above]{$\\dot{z}_{mc}$} -- (actuators);\r\n\t\t\t\r\n\t\t\t%Senros fusion's outputs\r\n\t\t\t\\draw (1.75,-0.45) coordinate node[below]{$\\theta_k$ $\\phi_k$};\r\n\t\t\t\\draw (5.5,-0.45) coordinate node[below]{$p_k$ $q_k$};\r\n\t\t\t\\draw (5.3,-0.8) coordinate node[below]{$r_k$};\r\n\t\t\t\r\n\t\t\t%Signs\r\n\t\t\t\\draw (1.5,0) coordinate node[right]{$+$};\r\n\t\t\t\\draw (5.25,0) coordinate node[right]{$+$};\r\n\t\t\t\r\n\t\t\t%Comments\r\n\t\t\t\\node (Crazyflie) at (10.25,-1.5) [dashed, gray, rectangle, minimum width=3cm, \r\n\t\t\tminimum height=5cm, draw, line width=1.25pt]{};\r\n\t\t\t\\draw (10.25,-4.75) coordinate node[above]{Crazyflie};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Blocks\r\n\t\t\t\\node (ReferenceGenerator) at (-2.1,0) [draw, rectangle, minimum height=1.5cm, minimum \r\n\t\t\twidth=1cm, text centered, text width=5em]{Reference\\\\Generator};\r\n\t\t\t\r\n\t\t\t\\node (OnboardCrazyflie) at (1.05,0) [draw, rectangle, minimum height=1.5cm, minimum \r\n\t\t\twidth=1cm, text centered, text width=5em]{On-board\\\\Control \\\\\\& \\\\Motors Dynamics};\r\n\t\t\t\r\n\t\t\t\\node (Crazyflie) at (4.35,0) [draw, rectangle, minimum height=1.5cm, minimum \r\n\t\t\twidth=1cm, text centered, text width=5em]{Crazyflie 2.0\\\\ Physical Model};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (ReferenceGenerator)  -- node[above]{$\\theta_c$, $\\phi_c$} \r\n\t\t\tnode[below]{$\\dot{z}_c$, $\\dot{\\psi}_c$} (OnboardCrazyflie) ;\r\n\t\t\t\\draw[-latex] (OnboardCrazyflie) -- node[above]{$\\omega_1$, $\\omega_2$} \r\n\t\t\tnode[below]{$\\omega_3$, $\\omega_4$}(Crazyflie);\r\n\t\t\t\\draw[-latex] (-5.2,0.18)  -- (-3.2,0.18);\r\n\t\t\t\\draw[-latex] (-5.2,-0.18) -- (-3.2,-0.18);\r\n\t\t\t\\draw[-latex] (-2.1,-2.1) coordinate -- (ReferenceGenerator);\r\n\t\t\t\\draw[-latex] (1.05,-2.1) coordinate -- (OnboardCrazyflie);\r\n\t\t\t\\draw (0.85,-1.65) coordinate node[below]{$r_k$};\r\n\t\t\t\r\n\t\t\t%Variables\r\n\t\t\t\\draw (-5.7,0.18) node[above right]{$x_r$, $y_r$, $z_r$, $\\psi_r$};\r\n\t\t\t\\draw (-5.7,-0.18) node[below right]{$x_d$, $y_d$, $z_d$, $\\psi_k$};\r\n\t\t\t\\draw (1.05,-1.7) node[above]{$p_k$ $q_k$};\r\n\t\t\t\\draw (-2.1,-1.5) node[above]{$u_d$ $v_d$};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.825}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Nodes\r\n\t\t\\node (highGUI) at (0,0) [rectangle, draw, minimum width=2cm, minimum height=1.8cm, \r\n\t\talign=center, text width=10em, rounded corners]{HighGUI \\\\ image \\& video IO};\r\n\t\t\r\n\t\t\\node (CV) at (-4.5,0) [rectangle, draw, minimum width=2cm, minimum height=1cm, \r\n\t\talign=center, text width=10em, rounded corners]{CV \\\\ image processing \\\\ vision \r\n\t\talgorithms};\r\n\t\t\r\n\t\t\\node (MLL) at (4.5,0) [rectangle, draw, minimum width=2cm, minimum height=1cm, \r\n\t\talign=center, text width=10em, rounded corners]{MLL \\\\ statistical classifiers \\\\ \r\n\t\tclustering tools};\r\n\t\t\r\n\t\t\\node (CXCORE) at (0,-3) [rectangle, draw, minimum width=13cm, minimum height=1cm, \r\n\t\talign=center, text width=10em, rounded corners]{CXCore \\\\ basic structures \\\\ algorithms \r\n\t\tdrawing};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (CV) to [out=180, in=180] (CXCORE);\r\n\t\t\\draw[-latex] (highGUI.south) -- (CXCORE.90);\r\n\t\t\\draw[-latex] (MLL) to [out=0, in=0] (CXCORE);\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t}\r\n\t\\end{center}\r\n\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Trajectory controller\r\n\t\t\t\\node (trajectoryController) at (-4,0) [draw, rectangle, minimum width=2cm, minimum \r\n\t\t\theight=5cm, text centered, label={[align=center]below:Trajectory\\\\ Control}]{};\r\n\t\t\t\r\n\t\t\t%Variables\r\n\t\t\t\\draw (-4.1,2.0) coordinate node[left]{$x_\\mathrm{ref}$};\r\n\t\t\t\\draw (-4.0,1.0) coordinate node[left]{$x_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (-4.1,0.0) coordinate node[left]{$y_\\mathrm{ref}$};\r\n\t\t\t\\draw (-4.0,-1.0) coordinate node[left]{$y_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (-4.3,-2.0) coordinate node[left]{$U_1$};\r\n\t\t\t\r\n\t\t\t\\draw (-3.0,1.5) coordinate node[left]{$U_x$};\r\n\t\t\t\\draw (-3.0,-1.5) coordinate node[left]{$U_y$};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (-6,2.0) coordinate node[left]{$x_\\mathrm{ref}$} -- (-5,2.0) coordinate;\r\n\t\t\t\\draw[-latex] (-6,1.0) coordinate node[left]{$x_{\\mathrm{mes}}$} -- (-5,1.0) coordinate;\r\n\t\t\t\\draw[-latex] (-6,0.0) coordinate node[left]{$y_\\mathrm{ref}$} -- (-5,0.0) coordinate;\r\n\t\t\t\\draw[-latex] (-6,-1.0) coordinate node[left]{$y_{\\mathrm{mes}}$} -- (-5,-1.0) \r\n\t\t\tcoordinate;\r\n\t\t\t\\draw[-latex] (-6,-2.0) coordinate node[left]{$U_1$} -- (-5,-2.0) coordinate; \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t%Attitude controller\r\n\t\t\t\\node (attitudeController) at (0,0) [draw, rectangle, minimum width=2cm, minimum \r\n\t\t\theight=7cm, text centered, label={[align=center]below:Attitude\\\\ Control}]{};\r\n\t\t\t\r\n\t\t\t%Curly brackets\r\n\t\t\t\\draw [decorate,decoration={brace,mirror, amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t\t(-5,-4.4) -- (1,-4.4) node [black,midway,xshift=0.0cm,yshift=-0.8cm] {Pose Control};\r\n\t\t\t\r\n\t\t\t%Variables\r\n\t\t\t\\draw (-0.17,3.1) node[left]{$\\theta_\\mathrm{ref}$};\r\n\t\t\t\\draw (-0.1,2.2) node[left]{$\\theta_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (-0.15,1.3) node[left]{$\\phi_\\mathrm{ref}$};\r\n\t\t\t\\draw (-0.08,0.4) node[left]{$\\phi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (-0.1,-0.4) node[left]{$\\psi_\\mathrm{ref}$};\r\n\t\t\t\\draw (-0.04,-1.3) node[left]{$\\psi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (-0.17,-2.2) node[left]{$z_\\mathrm{ref}$};\r\n\t\t\t\\draw (-0.08,-3.1) node[left]{$z_{\\mathrm{mes}}$};\r\n\t\t\t\r\n\t\t\t\\draw (1.0,2) node[left]{$U_1$};\r\n\t\t\t\\draw (1.0,1) node[left]{$U_2$};\r\n\t\t\t\\draw (1.0,-1) node[left]{$U_3$};\r\n\t\t\t\\draw (1.0,-2) node[left]{$U_4$};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (-3.0,1.5) coordinate -- (-2.4,1.5) coordinate -- (-2.4,3.1) coordinate  \r\n\t\t\t-- (-1.0,3.1) coordinate;\r\n\t\t\t\\draw[-latex] (-3,-1.5) -- (-2.2,-1.5) coordinate -- (-2.2,1.3) coordinate -- \r\n\t\t\t(-1.0,1.3) coordinate;\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-2.0,2.2) coordinate node[above right]{$\\theta_{\\mathrm{mes}}$} -- \r\n\t\t\t(-1.0,2.2) coordinate;\r\n\t\t\t\\draw[-latex] (-2.0,0.4) coordinate node[above right]{$\\phi_{\\mathrm{mes}}$} -- \r\n\t\t\t(-1.0,0.4) coordinate;\t\t\t\t\r\n\t\t\t\\draw[-latex] (-2.0,-0.4) coordinate node[above right]{$\\psi_\\mathrm{ref}$} -- \r\n\t\t\t(-1.0,-0.4) coordinate;\r\n\t\t\t\\draw[-latex] (-2.0,-1.3) coordinate node[above right]{$\\psi_{\\mathrm{mes}}$} -- \r\n\t\t\t(-1.0,-1.3) coordinate;\t\r\n\t\t\t\\draw[-latex] (-2.0,-2.2) coordinate node[above right]{$z_\\mathrm{ref}$} -- (-1.0,-2.2) \r\n\t\t\tcoordinate;\r\n\t\t\t\\draw[-latex] (-2.0,-3.1) coordinate node[above right]{$z_{\\mathrm{mes}}$} -- \r\n\t\t\t(-1.0,-3.1) \r\n\t\t\tcoordinate;\t\r\n\t\t\t\r\n\t\t\t%Drone model block\r\n\t\t\t\\node (droneMOdel) at (3.5,0) [draw, rectangle, minimum width=2cm, minimum \r\n\t\t\theight=6cm, text centered, label={[align=center]below:Drone\\\\ Dynamics}]{};\r\n\t\t\t\r\n\t\t\t%variables\r\n\t\t\t\\draw (3.2,2) coordinate node[left]{$U_1$};\r\n\t\t\t\\draw (3.2,1) coordinate node[left]{$U_2$};\r\n\t\t\t\\draw (3.2,-1) coordinate node[left]{$U_3$};\r\n\t\t\t\\draw (3.2,-2) coordinate node[left]{$U_4$};\r\n\t\t\t\r\n\t\t\t\\draw (4.5,2.6) coordinate node[left]{$\\phi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (4.5,1.6) coordinate node[left]{$\\theta_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (4.5,0.6) coordinate node[left]{$\\psi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (4.5,-0.6) coordinate node[left]{$x_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (4.5,-1.6) coordinate node[left]{$y_{\\mathrm{mes}}$};\r\n\t\t\t\\draw (4.5,-2.6) coordinate node[left]{$z_{\\mathrm{mes}}$};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (1.0,2) coordinate -- (2.5,2) coordinate;\r\n\t\t\t\\draw[-latex] (1.0,1) coordinate -- (2.5,1) coordinate;\r\n\t\t\t\\draw[-latex] (1.0,-1) coordinate -- (2.5,-1) coordinate;\r\n\t\t\t\\draw[-latex] (1.0,-2) coordinate -- (2.5,-2) coordinate;\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (4.5,2.6) coordinate -- (5.5,2.6) coordinate \r\n\t\t\tnode[right]{$\\phi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.5,1.6) coordinate -- (5.5,1.6) coordinate \r\n\t\t\tnode[right]{$\\theta_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.5,0.6) coordinate -- (5.5,0.6) coordinate \r\n\t\t\tnode[right]{$\\psi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.5,-0.6) coordinate -- (5.5,-0.6) coordinate \r\n\t\t\tnode[right]{$x_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.5,-1.6) coordinate -- (5.5,-1.6) coordinate \r\n\t\t\tnode[right]{$y_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.5,-2.6) coordinate -- (5.5,-2.6) coordinate \r\n\t\t\tnode[right]{$z_{\\mathrm{mes}}$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\t\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%A different way to draw a block diagram\r\n\t\t\\bXInput[$\\theta_d$]{Reference}               \t\t\t\r\n\t\t\\bXComp*[2]{Comparator}{Reference}              \t\t\r\n\t\t\\bXLink{Reference}{Comparator}                  \t\t\t\r\n\t\t\r\n\t\t\\bXBloc[3]{Integrator}{$I$}{Comparator}  \t\t\t\t\t\r\n\t\t\\bXLink{Comparator}{Integrator} \t\t\t\t\t\t\t\r\n\t\t\\bXComp*[4]{Comparator1}{Integrator}\t\t\t\t\t\t\r\n\t\t\\bXLink{Integrator}{Comparator1}\t\t\t\t\t\t\t\r\n\t\t\\bXBloc[2]{Proportional}{$P$}{Comparator1}\t\t\t\t\r\n\t\t\\bXLink{Comparator1}{Proportional}\t\t\t\t\t\t\r\n\t\t\\bXSuma*[4]{Comparator2}{Proportional}\t\t\t\t \r\n\t\t\\bXLink{Proportional}{Comparator2}\t\t\t\t\t\t\r\n\t\t\\bXBloc[2]{Integrator1}{$\\dfrac{1}{s}$}{Comparator2}\t\t\r\n\t\t\\bXLink{Comparator2}{Integrator1}\t\t\t\t\t\t\t\r\n\t\t\\bXBloc[3]{Integrator2}{$\\dfrac{1}{s}$}{Integrator1}\t\t\r\n\t\t\\bXLink[$\\dot{\\theta}$]{Integrator1}{Integrator2}\t\t\t\r\n\t\t\\bXOutput{Uscita}{Integrator2}\t\t\t\t\t\t\t\t\r\n\t\t\\bXLink[$\\theta$]{Integrator2}{Uscita}\t\t\t\t\t\t\r\n\t\t\\bXReturn[5]{Integrator2-Uscita}{Comparator}{}\t\t\t\r\n\t\t\\bXReturn{Integrator1-Integrator2}{Comparator1}{}\t    \r\n\t\t\\bXBranchy[-4]{Comparator-Integrator}{Proportional2}\t\r\n\t\t\\bXChain[1.5]{Proportional2}{p/$P$}\t\t\t\t\t\t\r\n\t\t\\bXLinkyx{Comparator-Integrator}{p}\t\t\t\t\t\t\r\n\t\t\\bXLinkxy{p}{Comparator2}\t\t\t\t\t\t\t\t\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.75}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\t\t\t\r\n\t\t\t\\node (pd1) at (0,0) [draw, rectangle, text centered, minimum width=1.5cm, minimum \r\n\t\t\theight=1cm]{$\\text{PD}_\\theta$};\r\n\t\t\t\r\n\t\t\t\\node (adder1) at (-2,0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-2,-1.5) coordinate node[below]{$\\theta_{\\mathrm{mes}}$} -- \r\n\t\t\t(adder1.south);\r\n\t\t\t\\draw[-latex] (adder1.east) node[above right]{$e_\\theta$} -- (pd1.west);\r\n\t\t\t\\draw[-latex] (-3,0) coordinate node[left]{$\\theta_\\mathrm{ref}$}-- (adder1.west);\r\n\t\t\t\r\n\t\t\t\\draw (-2.05,0.15) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-2.05,-0.25) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\node (pd2) at (0,-3.0) [draw, rectangle, text centered, minimum width=1.5cm, minimum \r\n\t\t\theight=1cm]{$\\text{PD}_\\phi$};\r\n\t\t\t\r\n\t\t\t\\node (adder2) at (-2,-3.0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-2,-4.5) coordinate node[below]{$\\phi_{\\mathrm{mes}}$} -- (adder2.south);\r\n\t\t\t\\draw[-latex] (adder2.east) node[above right]{$e_\\phi$} -- (pd2.west);\r\n\t\t\t\\draw[-latex] (-3,-3) coordinate node[left]{$\\phi_\\mathrm{ref}$} -- (adder2.west);\r\n\t\t\t\r\n\t\t\t\\draw (-2.05,-2.85) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-2.05,-3.25) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\node (pd3) at (0,-6.0) [draw, rectangle, text centered, minimum width=1.5cm, minimum \r\n\t\t\theight=1cm]{$\\text{PD}_\\psi$};\r\n\t\t\t\r\n\t\t\t\\node (adder3) at (-2,-6.0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-2,-7.5) coordinate node[below]{$\\psi_{\\mathrm{mes}}$} -- (adder3.south);\r\n\t\t\t\\draw[-latex] (adder3.east) node[above right]{$e_\\psi$} -- (pd3.west);\r\n\t\t\t\\draw[-latex] (-3,-6) coordinate node[left]{$\\psi_\\mathrm{ref}$} -- (adder3.west);\r\n\t\t\t\r\n\t\t\t\\draw (-2.05,-5.85) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-2.05,-6.25) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\\node (pd4) at (0,-9.0) [draw, rectangle, text centered, minimum width=1.5cm, minimum \r\n\t\t\theight=1cm]{$\\text{PD}_z$};\r\n\t\t\t\r\n\t\t\t\\node (adder4) at (-2,-9.0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (-2,-10.5) coordinate node[below]{$z_{\\mathrm{mes}}$} -- (adder4.south);\r\n\t\t\t\\draw[-latex] (adder4.east) node[above right]{$e_z$} -- (pd4.west);\r\n\t\t\t\\draw[-latex] (-3,-9) coordinate node[left]{$z_\\mathrm{ref}$} -- (adder4.west);\r\n\t\t\t\r\n\t\t\t\\draw (-2.05,-8.85) coordinate node[above left]{$+$};\r\n\t\t\t\\draw (-2.05,-9.25) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\node (droneModel) at (3,-4.5) [draw, rectangle, minimum height=11cm, minimum \r\n\t\t\twidth=2cm, text centered, text \t\t\r\n\t\t\twidth=1em]{D\\\\R\\\\O\\\\N\\\\E\\\\$\\hspace{0.1cm}$\\\\M\\\\O\\\\D\\\\E\\\\L\\\\};\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (pd1.east) node [above right]{$U_3$} -- (2.0,0.0) coordinate;\r\n\t\t\t\\draw[-latex] (pd2.east) node [above right]{$U_2$} -- (2.0,-3.0) coordinate;\r\n\t\t\t\\draw[-latex] (pd3.east) node [above right]{$U_4$} -- (2.0,-6.0) coordinate;\r\n\t\t\t\\draw[-latex] (pd4.east) node [above right]{$U_1$} -- (2.0,-9.0) coordinate;\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (4.0,0) coordinate -- (5,0) coordinate \r\n\t\t\tnode[right]{$\\theta_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.0,-3) coordinate -- (5,-3) coordinate \r\n\t\t\tnode[right]{$\\phi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.0,-6) coordinate -- (5,-6) coordinate \r\n\t\t\tnode[right]{$\\psi_{\\mathrm{mes}}$};\r\n\t\t\t\\draw[-latex] (4.0,-9) coordinate -- (5,-9) coordinate node[right]{$z_{\\mathrm{mes}}$};\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.8}{\r\n\t\t\t\\begin{tikzpicture}[node distance=2cm]\r\n\t\t\t\r\n\t\t\t%Nodes\t\r\n\t\t\t\\node (queryImage) at (-3.5, 0) [rectangle, draw, text centered, minimum width=2cm, \r\n\t\t\tminimum height=1cm] {Query Image};\r\n\t\t\t\r\n\t\t\t\\node (image) at ( 3.5, 0) [rectangle, text centered, draw, minimum width=2cm, minimum \r\n\t\t\theight=1cm] {Image};\r\n\t\t\t\r\n\t\t\t\\node (featureExtraction) at ( 0,-2) [rectangle, draw, text centered, minimum \r\n\t\t\twidth=5cm, minimum height=1cm] {Feature Extraction};\r\n\t\t\t\r\n\t\t\t\\node (queryFeature) at (-4,-4.5) [rectangle, draw, text centered, minimum width=3cm, \r\n\t\t\tminimum height=1cm] {Query Feature};\r\n\t\t\t\r\n\t\t\t\\node (matching) at ( 0,-4.5) [rectangle, draw, text centered, minimum width=2cm, \r\n\t\t\tminimum height=1cm] {Matching};\r\n\t\t\t\r\n\t\t\t\\node (featureDatabase) at ( 4,-4.5) [rectangle, draw, text centered, minimum \r\n\t\t\twidth=3cm, minimum height=1cm] {Feature Database};\r\n\t\t\t\r\n\t\t\t\\node (retreivedImages) at ( 0,-6.5) [rectangle, draw, text centered, minimum \r\n\t\t\twidth=3cm, minimum height=1cm] {Retreived Images};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw [-latex] (queryFeature.east) -- (matching.west);\r\n\t\t\t\\draw [-latex] (featureDatabase.west) -- (matching.east);\r\n\t\t\t\\draw [-latex] (matching.south) -- (retreivedImages.north);\r\n\t\t\t\\draw [-latex] (queryImage) to [out=270,in=180] (featureExtraction);\r\n\t\t\t\\draw [-latex] (image) to [out=270,in=0] (featureExtraction);\r\n\t\t\t\\draw [-latex] (featureExtraction) to [out=270,in=90] (queryFeature);\r\n\t\t\t\\draw [-latex] (featureExtraction) to [out=270,in=90] (featureDatabase);\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.95}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Blocks\r\n\t\t\\node (CrazyflieControl) at (0.2,0) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1.5cm, text centered, text width=5em]{Crazyflie Control};\r\n\t\t\\node (GazeboControllerInterface) at (-2.5,-2.2) [draw, rectangle, minimum width=1.5cm, \r\n\t\tminimum height=1.5cm, text centered, text width=5em]{Gazebo Controller\\\\Interface};\r\n\t\t\\node (SimulatedExternalInfluence) at (-7.15,-4.2) [draw, rectangle, minimum \r\n\t\twidth=1.5cm, minimum height=1.5cm, text centered, text width=5em]{Simulated \r\n\t\tExternal\\\\Influences};\r\n\t\t\\node (SimulatedCrazyflieDynamics) at (-7.15,-2.2) [draw, rectangle, minimum \r\n\t\twidth=1.5cm, minimum height=1.5cm, text centered, text width=5em]{Simulated \r\n\t\tCrazyflie\\\\Dynamics};\r\n\t\t\\node (SimulatedSensor) at (-7.15,0) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1.5cm, text centered, text width=5em]{Simulated Sensors};\r\n\t\t\\node (StateEstimator) at (0.2,2.2) [draw, rectangle, minimum width=1.5cm, minimum \r\n\t\theight=1.5cm, text centered, text width=5em]{State Estimator};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (CrazyflieControl) |- node[below right]{Control Commands} \r\n\t\t(GazeboControllerInterface);\r\n\t\t\\draw[-latex] (GazeboControllerInterface) -- node[above]{Desired Motor} \r\n\t\tnode[below]{Velocities} (SimulatedCrazyflieDynamics);\r\n\t\t\\draw[-latex] (SimulatedExternalInfluence) -- (SimulatedCrazyflieDynamics);\r\n\t\t\\draw[-latex] (SimulatedSensor) |- node[above right]{IMU \\& Pose Measurements} \r\n\t\t(StateEstimator);\r\n\t\t\\draw[-latex] (StateEstimator) -- node[right]{Odometry Estimates} (CrazyflieControl);\r\n\t\t\\draw[-latex] (SimulatedCrazyflieDynamics) -- node[right] {Dynamics} (SimulatedSensor);\r\n\t\t\\draw[-latex, dashed] (SimulatedSensor) -- node[above]{Odometry} \r\n\t\tnode[below]{Measurements} (CrazyflieControl) ;\r\n\t\t\r\n\t\t%Gazebo's group\r\n\t\t\\draw[dashed, gray, draw, line width=1.25pt] (-1.25,1) coordinate -- (-1.25,-5.25) \r\n\t\tcoordinate -- (-8.3,-5.25) coordinate -- (-8.3,1) coordinate -- (-1.25,1) coordinate; \r\n\t\t\\draw (-2,-5.2) coordinate node[above]{Gazebo};\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.9}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Attitude controller\r\n\t\t\t\\node (attitudeController) at (-3,0) [draw, rectangle, text centered, line width=1.0pt, \r\n\t\t\tminimum height=2cm, minimum width=1cm, text width=5em]{Attitude\\\\ control};\r\n\t\t\t\r\n\t\t\t%baseline Integral Backstepping\r\n\t\t\t\\node (baselineIntegralBackstepping) at (-3,-1.50) [draw, line width=1.0pt, fill=black, \r\n\t\t\trectangle, minimum height=0.5cm, minimum width=1cm, text centered, text \r\n\t\t\twidth=5em]{\\footnotesize{\\color{white}{Integral\\\\ Backstepping}}}; \r\n\t\t\t\r\n\t\t\t%PositionController\r\n\t\t\t\\node (positionController) at (0,0) [draw, rectangle, line width=1.0pt, text centered, \r\n\t\t\tminimum height=2cm, minimum width=1cm, text width=5em]{Position\\\\ control};\r\n\t\t\t\r\n\t\t\t%Baseline Integral Backstepping\r\n\t\t\t\\node at (0,-1.50) [draw, line width=1.0pt, fill=black, rectangle, minimum \r\n\t\t\theight=0.5cm, minimum width=1cm, text centered, text \r\n\t\t\twidth=5em]{\\footnotesize{\\color{white}{Integral\\\\ Backstepping}}}; \r\n\t\t\t\r\n\t\t\t%Altitude controller\r\n\t\t\t\\node (altitudeController) at (3,0) [draw, rectangle, line width=1.0pt, text centered, \r\n\t\t\tminimum height=2cm, minimum width=1cm, text width=5em]{Altitude\\\\ control};\r\n\t\t\t\r\n\t\t\t%Baseline Integral Backstepping\r\n\t\t\t\\node at (3,-1.50) [draw, line width=1.0pt, fill=black, rectangle, minimum \r\n\t\t\theight=0.5cm, minimum width=1cm, text centered, text \r\n\t\t\twidth=5em]{\\footnotesize{\\color{white}{Integral\\\\ Backstepping}}}; \r\n\t\t\t\r\n\t\t\t%Motors controller\r\n\t\t\t\\node (motorsController) at (-3,-4) [draw, rectangle, line width=1.0pt, text \r\n\t\t\tcentered, minimum height=2cm, minimum width=1cm, text width=5em]{Motors velocity \r\n\t\t\tcontrol};\r\n\t\t\t\r\n\t\t\t%Baseline PID\r\n\t\t\t\\node at (-3,-5.28) [draw, line width=1.0pt, fill=black, rectangle, minimum \r\n\t\t\theight=0.5cm, minimum width=1cm, text centered, text \r\n\t\t\twidth=5em]{\\footnotesize{\\color{white}{PID}}}; \r\n\t\t\t\r\n\t\t\t%Hexarotor\r\n\t\t\t\\node (hexarotor) at (-6,-4) [draw, rectangle, line width=1.0pt, text centered, \r\n\t\t\tminimum height=2cm, minimum width=1cm, text width=5em]{Hex-rotor};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex, line width=1.0pt] (motorsController.west) -- (hexarotor.east);\r\n\t\t\t\\draw[-latex, line width=1.0pt] (altitudeController.west) -- (positionController.east);\r\n\t\t\t\\draw[-latex, line width=1.0pt] (positionController.west) -- (attitudeController.east);\r\n\t\t\t\\draw[-latex, line width=1.0pt] (baselineIntegralBackstepping.south) -- \r\n\t\t\t(motorsController.north);\r\n\t\t\t\r\n\t\t\t\\draw[-latex, line width=1.0pt] (1.5,0) coordinate -- (1.5,2.6) coordinate -- (-3,2.6) \r\n\t\t\tcoordinate -- (attitudeController.north);\r\n\t\t\t\r\n\t\t\t%Reference signals\r\n\t\t\t\\draw[-latex, line width=1.0pt] (5,0) coordinate node[right]{$z_r,\\,z_d$}-- \r\n\t\t\t(altitudeController.east);\r\n\t\t\t\\node[above] at (-3.5,1.8) [text centered]{$\\sum\\limits_i T_r$};\r\n\t\t\t\\draw[-latex, line width=1.0pt] (0,2) coordinate node[above]{$x_d,\\,y_d$} -- \r\n\t\t\t(positionController.north);\r\n\t\t\t\\node[above] at (-1.5,0) [text centered]{$\\theta_r$};\r\n\t\t\t\\node[below] at (-1.5,0) [text centered]{$\\phi_r$};\r\n\t\t\t\\draw[-latex, line width=1.0pt] (-5.0,0) coordinate \r\n\t\t\tnode[below]{$\\phi_d,\\,\\theta_d,\\,\\psi_d$} -- (attitudeController.west);\r\n\t\t\t\\draw[-latex, line width=1.0pt] (-5.0,0) coordinate \r\n\t\t\tnode[above]{$\\dot{\\phi}_d,\\,\\dot{\\theta}_d,\\,\\dot{\\psi}_d$} -- \r\n\t\t\t(attitudeController.west);\r\n\t\t\t\\node at (-1.5,-2.7) [left, text centered]{$\\omega_{1,\\dots,6}$}; \r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\t\r\n\t\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}[node distance=2cm]\r\n\t\t\r\n\t\t%Creo i nodi del diagramma di flusso\t\t\r\n\t\t\\node (allSubWindow) at (-3,1) [ellipse, draw, text centered, text width=6em] {All \r\n\t\tsub-windows};\r\n\t\t\r\n\t\t\\node (furtherProcessing) at (3,1) [ellipse, draw, text centered, text width=6em] {Further \r\n\t\tElaboration};\r\n\t\t\r\n\t\t\\node (1) at (-3,-1.25) [circle, draw, text centered, minimum size=1.2cm] {1};\r\n\t\t\r\n\t\t\\node (2) at (0,-1.25) [circle, draw, text centered, minimum size=1.2cm] {2};\r\n\t\t\r\n\t\t\\node (3) at (3,-1.25) [circle, draw, text centered, minimum size=1.2cm] {3};\r\n\t\t\r\n\t\t\\node (rejectSubWindows) at (0,-4.25) [ellipse, draw, text centered, text width=6em] \r\n\t\t{Sub-windows rejection};\r\n\t\t\r\n\t\t\\draw[-latex] (1) -- node[above]{T} (2);\r\n\t\t\\draw[-latex] (2) -- node[above]{T} (3);\r\n\t\t\\draw[-latex] (2) -- node[above left]{F} (rejectSubWindows);\r\n\t\t\\draw[-latex] (1) -- node[above right]{F} (rejectSubWindows);\r\n\t\t\\draw[-latex] (3) -- node[above left]{F} (rejectSubWindows);\r\n\t\t\\draw[-latex] (allSubWindow) to [out=200,in=180] (1);\r\n\t\t\\draw[-latex] (3) to [out=0, in=340] (furtherProcessing);\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Nodes\r\n\t\t\\node (BackStepping) at (-4,1.5) [draw, rectangle, minimum height=1cm, minimum width=5cm, \r\n\t\ttext centered, rounded corners]{Backstepping};\r\n\t\t\\node (integralAction) at (4,1.5) [draw, rectangle, minimum height=1cm, minimum width=5cm, \r\n\t\ttext centered, rounded corners]{Integral Action};\r\n\t\t\r\n\t\t%Rappresento il nodo centrale\r\n\t\t\\node (integralBackStepping) at (0,0) [draw, rectangle, minimum height=1cm, minimum \r\n\t\twidth=5cm, text centered, rounded corners]{Integral Backstepping};\r\n\t\t\r\n\t\t%Rappresento il blocco caratteristiche\r\n\t\t\\node (features) at (0,-2.3) [draw, rectangle, minimum height=1cm, minimum \r\n\t\twidth=1cm, text centered, rounded corners, text width=12em]{Robustness w.r.t. model \r\n\t\tuncertainities\\\\ \\& \\\\Disturbace rejection};\r\n\t\t\r\n\t\t%Control system results\r\n\t\t\\node (results) at (0,-4.6) [draw, rectangle, minimum height=1cm, minimum width=5cm, text \r\n\t\tcentered, rounded corners]{Attitude \\& Position Controller};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (BackStepping.270) -- (-4,0) coordinate -- (integralBackStepping.180);\r\n\t\t\\draw[-latex] (integralAction.270) -- (4,0) coordinate -- (integralBackStepping.0);\r\n\t\t\\draw[-latex] (integralBackStepping.south) -- (features.north);\r\n\t\t\\draw[-latex] (features.south) -- (results.north);\r\n\t\t\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.8}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%System nodes\r\n\t\t\\node [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em] \r\n\t\t(start) at (0,0) {START};\r\n\t\t\r\n\t\t\\node [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, \r\n\t\tbelow of=init] (vrMatlab) at (0,-1.5) {VR MATLAB};\r\n\t\t\r\n\t\t\\node [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, \r\n\t\tbelow of=identify] (detection) at (0,-4.0) {DETECTION};\r\n\t\t\r\n\t\t\\node [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, \r\n\t\tleft of=evaluate, node distance=3cm] (update) at (-1.5,-5) {UPDATE UAV POSE};\r\n\t\t\r\n\t\t\\node [diamond, draw, text width=5.5em, text badly centered, node distance=3cm, inner \r\n\t\tsep=0pt, below of=evaluate] (decide) at (0,-5.5) {CAR DETECTED?};\r\n\t\t\r\n\t\t\r\n\t\t%Links\r\n\t\t\\path [draw, -latex'] (start) -- (vrMatlab);\r\n\t\t\\path [draw, -latex'] (vrMatlab) -- (detection);\r\n\t\t\\path [draw, -latex'] (detection) -- (decide);\r\n\t\t\\path [draw, -latex'] (decide) -| (update);\r\n\t\t\\path [draw, -latex'] (update) |- (vrMatlab);\r\n\t\t\\path [draw, -latex'] (decide.east) -- (4.5,-8.5) coordinate -- (4.5,-2.5) coordinate -- \r\n\t\t(vrMatlab.east);\r\n\t\t\r\n\t\t%Decisions\r\n\t\t\\node at (2.5,-8.5)  [above] {NO};\r\n\t\t\\node at (-2.5,-8.5) [above] {YES};\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Nodes\r\n\t\t\t\\draw (0,1.5) ellipse (1.8cm and 0.5cm) node[] {/hovering\\_example};\r\n\t\t\t\\draw (5,3) ellipse (2.5cm and 0.6cm);\r\n\t\t\t\\draw (5.7,3) node[text width=15em]{/position\\_controller\\_node};\r\n\t\t\t\\draw (0,5.5) ellipse (0.75cm and 0.5cm) node[]{/gazebo};\r\n\t\t\t\r\n\t\t\t%Topics\r\n\t\t\t\\node (commandTrajectory) at (5,1.5) [draw, text centered, rectangle, minimum \r\n\t\t\theight=1cm]{/command/trajectory};\r\n\t\t\t\\node (odometrySensor) at (0,3) [draw, rectangle, minimum height=1cm, text centered, \r\n\t\t\tminimum width=2cm]{/odometry};\r\n\t\t\t\\node (motorSpeed) at (10.6,3) [draw, rectangle, minimum height=1cm, text \r\n\t\t\tcentered]{/command/motor\\_speed};\r\n\t\t\t\r\n\t\t\t%Links\r\n\t\t\t\\draw[-latex] (1.8,1.5) coordinate -- (commandTrajectory);\r\n\t\t\t\\draw[-latex] (odometrySensor) -- (2.5,3) coordinate;\r\n\t\t\t\\draw[-latex] (7.5,3) coordinate -- (motorSpeed.west);\r\n\t\t\t\\draw[-latex] (commandTrajectory) -- (5,2.4) coordinate;\r\n\t\t\t\\draw[-latex] (0,5) coordinate -- (odometrySensor.north);\r\n\t\t\t\\draw[-latex] (motorSpeed.north) .. controls (9,5.25) .. (0.755,5.5);\r\n\t\t\t\r\n\t\t\t%Crazyflie 2.0 box\r\n\t\t\t\\node (crazyflie) at (5.63,2.7) [draw, rectangle, line width=1.25 pt, minimum \r\n\t\t\theight=3.8cm, minimum width=15cm]{};\r\n\t\t\t\\draw (5,4.15) coordinate node[]{\\textbf{crazyflie2}};\r\n\t\t\t\r\n\t\t\t%Rettangolo che raffigura gazebo\r\n\t\t\t\\node (gazeboBox) at (0,5.7) [draw, rectangle, line width=1.25 pt, minimum \r\n\t\t\theight=1.8cm, minimum width=2cm]{};\r\n\t\t\t\\draw (0, 6.25) coordinate node[]{\\textbf{gazebo}};\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure} \r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.75}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Nodes\r\n\t\t\\node (firstPID) at (-2,0.5) [draw, rectangle, minimum width=1.5cm, minimum height=1cm, \r\n\t\ttext centered]{$PID$};\r\n\t\t\r\n\t\t\\node (secondPID) at (0.75,0.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$PID$};\r\n\t\t\r\n\t\t\\node (adder) at (0.75,-1) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (-4,0.5) coordinate node[above]{$e_{area}$} -- (firstPID.west);\r\n\t\t\r\n\t\t\\draw[-latex] (firstPID.east) -- (0,0.5) coordinate node[above left]{$\\Delta x_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (secondPID.east) -- (2.7,0.5) coordinate node[above left]{$\\theta_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (-0.45,0.5) coordinate -- (-0.45,-1) coordinate -- (adder.west);\r\n\t\t\r\n\t\t\\draw[-latex] (adder.east) -- (2.7,-1) coordinate node[above left]{$x_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (0.75,-2.0) coordinate node[above left]{$x_{d_{init}}$} -- (adder.south);\r\n\t\t\r\n\t\t%Signs\r\n\t\t\\draw (0.75,-1) coordinate node[above left]{$+$};\r\n\t\t\\draw (0.75,-1) coordinate node[below right]{$+$};\r\n\t\t\r\n\t\t%Names into the second part of the scheme\r\n\t\t\\node (thirdPID) at (-2,-3.0) [draw, rectangle, minimum width=1.5cm, minimum height=1cm, \r\n\t\ttext centered]{$PID$};\r\n\t\t\r\n\t\t\\node (fourthPID) at (0.75,-3.0) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$\\frac{d}{dt}$};\r\n\t\t\r\n\t\t\\node (adder1) at (0.75,-4.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\r\n\t\t%Links among blocks\r\n\t\t\\draw[-latex] (-4,-3.0) coordinate node[above]{$e_y$} -- (thirdPID.west);\r\n\t\t\r\n\t\t\\draw[-latex] (thirdPID.east) -- (0,-3.0) coordinate node[above left]{$\\Delta y_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (fourthPID.east) -- (2.7,-3.0) coordinate node[above left]{$\\dot{y}_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (-0.45,-3.0) coordinate -- (-0.45,-4.5) coordinate -- (adder1.west);\r\n\t\t\r\n\t\t\\draw[-latex] (adder1.east) -- (2.7,-4.5) coordinate node[above left]{$y_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (0.75,-5.5) coordinate node[above left]{$y_{d_{init}}$} -- (adder1.south);\r\n\t\t\r\n\t\t%Signs\r\n\t\t\\draw (0.75,-4.5) coordinate node[above left]{$+$};\r\n\t\t\\draw (0.75,-4.5) coordinate node[below right]{$+$};\r\n\t\t\r\n\t\t%Third part of the scheme\r\n\t\t\\node (fifthPID) at (-2,-6.5) [draw, rectangle, minimum width=1.5cm, minimum height=1cm, \r\n\t\ttext centered]{$PID$};\r\n\t\t\r\n\t\t\\node (sixthPID) at (0.75,-6.5) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$\\frac{d}{dt}$};\r\n\t\t\r\n\t\t\\node (adder2) at (0.75,-8.0) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\r\n\t\t%Links among blocks\r\n\t\t\\draw[-latex] (-4,-6.5) coordinate node[above]{$e_x$} -- (fifthPID.west);\r\n\t\t\r\n\t\t\\draw[-latex] (fifthPID.east) -- (0,-6.5) coordinate node[above left]{$\\Delta \\psi_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (sixthPID.east) -- (2.7,-6.5) coordinate node[above left]{$\\dot{\\psi}_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (-0.45,-6.5) coordinate -- (-0.45,-8.0) coordinate -- (adder2.west);\r\n\t\t\r\n\t\t\\draw[-latex] (adder2.east) -- (2.7,-8.0) coordinate node[above left]{$\\psi_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (0.75,-9.0) coordinate node[above left]{$\\psi_{d_{init}}$} -- \r\n\t\t(adder2.south);\r\n\t\t\r\n\t\t%Signs\r\n\t\t\\draw (0.75,-8.0) coordinate node[above left]{$+$};\r\n\t\t\\draw (0.75,-8.0) coordinate node[below right]{$+$};\r\n\t\t\r\n\t\t\r\n\t\t%Signs\r\n\t\t\\node (seventhPID) at (-2,-10) [draw, rectangle, minimum width=1.5cm, minimum height=1cm, \r\n\t\ttext centered]{$PID$};\r\n\t\t\r\n\t\t\\node (eighthPID) at (0.75,-10) [draw, text centered, minimum width=1.5cm, minimum \r\n\t\theight=1cm]{$PID$};\r\n\t\t\r\n\t\t\\node (adder3) at (0.75,-11.5) [draw, circle, text centered, minimum size=0.5cm]{};\r\n\t\t\r\n\t\t%Links\r\n\t\t\\draw[-latex] (-3.25,-6.5) coordinate -- (-3.25,-10) coordinate -- (seventhPID.west);\r\n\t\t\r\n\t\t\\draw[-latex] (seventhPID.east) -- (0,-10) coordinate node[above left]{$\\Delta z_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (eighthPID.east) -- (2.7,-10) coordinate node[above left]{$\\phi_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (-0.45,-10) coordinate -- (-0.45,-11.5) coordinate -- (adder3.west);\r\n\t\t\r\n\t\t\\draw[-latex] (adder3.east) -- (2.7,-11.5) coordinate node[above left]{$z_d$};\r\n\t\t\r\n\t\t\\draw[-latex] (0.75,-12.5) coordinate node[above left]{$z_{d_{init}}$} -- (adder3.south);\r\n\t\t\r\n\t\t%Signs\r\n\t\t\\draw (0.75,-11.5) coordinate node[above left]{$+$};\r\n\t\t\\draw (0.75,-11.5) coordinate node[below right]{$+$};\r\n\t\t\\end{tikzpicture}\r\n\t}\r\n\t\\end{center}\r\n\t\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t%Layer architecture\r\n\t\t\\node (user) at (0,0) [rectangle, draw, rounded corners=1.25pt, text centered, minimum \r\n\t\twidth=2cm, minimum height=0.5cm]{User};\r\n\t\t\r\n\t\t\\node (application) at (0,-1) [rectangle, draw, rounded corners=1.25pt, text centered, \r\n\t\tminimum width=2cm, minimum height=0.5cm]{Application};\r\n\t\t\r\n\t\t\\node (middleware) at (0,-2) [rectangle, draw, rounded corners=1.25pt, text centered, \r\n\t\tminimum width=2cm, fill=red!25, minimum height=0.5cm]{Middleware};\r\n\t\t\r\n\t\t\\node (OS) at (0,-3) [rectangle, draw, rounded corners=1.25pt, text centered, minimum \r\n\t\twidth=2cm, minimum height=0.5cm]{OS};\r\n\t\t\r\n\t\t\\node (hardware) at (0,-4) [rectangle, draw, rounded corners=1.25pt, text centered, minimum \r\n\t\twidth=2cm, minimum height=0.5cm]{Hardware};\r\n\t\t\r\n\t\t%RLinks\r\n\t\t\\draw[-latex] (-0.5, -0.25) to (-0.5,-0.73);\r\n\t\t\\draw[latex-] (0.5, -0.25) to (0.5,-0.73);\r\n\t\t\r\n\t\t\\draw[-latex] (-0.5,-1.28) to (-0.5,-1.75);\r\n\t\t\\draw[latex-] (0.5,-1.28) to (0.5,-1.75);\r\n\t\t\r\n\t\t\\draw[-latex] (-0.5,-2.25) to (-0.5,-2.75);\r\n\t\t\\draw[latex-] (0.5,-2.25) to (0.5,-2.75);\r\n\t\t\r\n\t\t\\draw[-latex] (-0.5,-3.25) to (-0.5,-3.75);\r\n\t\t\\draw[latex-] (0.5,-3.25) to (0.5,-3.75);\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.9}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Rectangles\r\n\t\t\t\\node (launchFile) at (0,0) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{crazyflie2\\_hovering\\_example.launch};\r\n\t\t\t\\node (spawnMav) at (0,-1.5) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{spawn\\_mav\\_crazyflie.launch};\r\n\t\t\t\\node (crazyflieBase) at (0,-3) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{crazyflie\\_base.xacro};\r\n\t\t\t\\node (componentSnippets) at (0,-4.5) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{component\\_snippets.xacro};\r\n\t\t\t\\node (crazyflieXacro) at (0,-6) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{crazyflie2.xacro};\r\n\t\t\t\\node (crazyflieDae) at (0,-7.5) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{crazyflie2.dae};\r\n\t\t\t\\node (gazebo) at (0,-9) [rectangle, draw, minimum width=6.4cm, minimum \r\n\t\t\theight=1cm]{Gazebo};\r\n\t\t\t\r\n\t\t\t%Links among blocks\r\n\t\t\t\\draw[-latex] (launchFile) -- (spawnMav);\r\n\t\t\t\\draw[-latex] (spawnMav) -- (crazyflieBase);\r\n\t\t\t\\draw[-latex] (crazyflieBase) -- (componentSnippets);\r\n\t\t\t\\draw[-latex] (componentSnippets) -- (crazyflieXacro);\r\n\t\t\t\\draw[-latex] (crazyflieXacro) -- (crazyflieDae);\r\n\t\t\t\\draw[-latex] (crazyflieDae) -- (gazebo);\r\n\t\t\t\r\n\t\t\t%Curly brackets\r\n\t\t\t\\draw [decorate,decoration={brace,amplitude=10pt,raise=4pt},yshift=0pt]\r\n\t\t\t(3.3,-1) -- (3.3,-5) node [black,midway,xshift=2.2cm, text centered, text width=10em] \r\n\t\t\t{\\footnotesize\r\n\t\t\t\tSimulate the on-board sensors and configure simulation features};\r\n\t\t\t\\draw [decorate,decoration={brace,amplitude=10pt, mirror, raise=4pt},yshift=0pt]\r\n\t\t\t(-3.3,-5.5) -- (-3.3,-8) node [black,midway,xshift=-2cm, text width=10em, text \r\n\t\t\tcentered] {\\footnotesize\r\n\t\t\t\tSimulate dynamics and geometry};\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%Scheme blocks\r\n\t\t\t\\node (outerLoop) at (-0.25,0) [draw, rectangle, minimum width=1cm,\tminimum \r\n\t\t\theight=1.5cm, text centered, text width=5em]{Outer loop\\\\controller};\r\n\t\t\t\\node (innerController) at (2.6,-0.75) [draw, rectangle, minimum width=1cm, \r\n\t\t\tminimum height=1.5cm, text centered, text width=5em]{Inner loop\\\\controller};\r\n\t\t\t\\node (controlMixer) at (5.9,0) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=1.5cm, text centered, text width=5em]{Control\\\\Mixer};\r\n\t\t\t\\node (bebopModel) at (10,0) [draw, rectangle, minimum width=1cm, minimum \r\n\t\t\theight=1.5cm, text centered, text width=5em]{Aircraft\\\\+ \\\\ Motors};\r\n\t\t\t\r\n\t\t\t%Links between blocks\r\n\t\t\t\\draw[-latex] ($ (outerLoop.160) - (1,0) $) -- node[above]{$\\xi_r$} (outerLoop.160);\r\n\t\t\t\\draw[-latex] ($ (outerLoop.200) - (1,0) $) -- node[above]{$\\psi_r$} (outerLoop.200);\r\n\t\t\t\\draw[fill=black] (-1.88,-0.4) arc(-180:180:0.03);\r\n\t\t\t\r\n\t\t\t\\draw[-] (-1.85,-0.425) -- (-1.85, -1.155) -- (-0.35, -1.155);\r\n\t\t\t\\draw[-] (-0.35,-1.155) arc (180:0:0.1);\r\n\t\t\t\\draw[-latex]($ (innerController.200) - (1.65,0) $) -- node[below]{$\\psi_r$} \r\n\t\t\t(innerController.200);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] ($ (outerLoop.south) - (0,0.75) $) node[left]{$\\xi_d$} -- \r\n\t\t\t(outerLoop.south);\r\n\t\t\t\\draw[-latex] (outerLoop.20) node[above right]{$u_T$} -- (controlMixer.160);\r\n\t\t\t\\draw[-latex] ($ (innerController.160) - (0.67,0) $) node[above right]{$\\varphi_r$} \r\n\t\t\tnode[below right]{$\\theta_r$} -- (innerController.160); \r\n\t\t\t\\draw[-latex] ($ (controlMixer.201) - (1.11,0) $) -- node[above]{$u_\\varphi$, \r\n\t\t\t$u_\\theta$} node[below]{$u_\\psi$} (controlMixer.201);\r\n\t\t\t\\draw[-latex] ($ (innerController.south) - (0,0.45) $) node[left]{$\\eta_d$} -- \r\n\t\t\t(innerController.south);\r\n\t\t\t\\draw[-] ($ (innerController.south) - (0,0.45) $) -- ++(9.25,0) --  ++(0,1.58);\r\n\t\t\t\\draw[fill=black] (11.83,-0.39) arc(-180:180:0.02);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\draw[-] ($ (outerLoop.south) - (0,0.5) $) -- ++(0,-0.87) -- ++\t(11.5,0) --  \r\n\t\t\t++(0,1.675);\r\n\t\t\t\\draw[-] (11.245,-0.45) arc(-90:90:0.1) -- ++(0,0.64);\r\n\t\t\t\\draw[fill=black] (11.23,0.40) arc(-180:180:0.02);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (controlMixer) -- node[above]{$\\Omega_{1}^\\mathrm{ref}$, \r\n\t\t\t$\\Omega_{2}^\\mathrm{ref}$} node[below]{$\\Omega_{3}^\\mathrm{ref}$, \r\n\t\t\t$\\Omega_{4}^\\mathrm{ref}$} (bebopModel);\r\n\t\t\t\\draw[-latex] (bebopModel.20) -- node[above]{$\\xi_d$} ($(bebopModel.20) + \r\n\t\t\t(1.2,0)$);\r\n\t\t\t\\draw[-latex] (bebopModel.-20) --  node[above]{$\\eta_d$} ($(bebopModel.-20) + \r\n\t\t\t(1.2,0) $);\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,auto] \r\n\t\t\r\n\t\t%Automata states\r\n\t\t\\node[state] (q_1)   {$x_1$}; \r\n\t\t\\node[state] (q_2) [below left=of q_1] {$x_2$}; \r\n\t\t\\node[state] (q_3) [below right=of q_1] {$x_3$};\r\n\t\t\\node[state] (q_4) [below=of q_2] {$x_4$};\r\n\t\t\r\n\t\t%Paths\r\n\t\t\\path[->] \r\n\t\t(q_1) edge              node        {$\\sigma_1$}  (q_3)\r\n\t\tedge              node [swap] {$\\sigma_1$}  (q_2)\r\n\t\t(q_2) edge [bend left]  node [swap] {$\\sigma_2$}  (q_3)\r\n\t\tedge [loop left]  node        {$\\sigma_1$}  ()\r\n\t\tedge [bend right] node [swap] {$\\sigma_2$}  (q_4)\r\n\t\t(q_3) edge [bend left]  node        {$\\sigma_1$}  (q_2)\r\n\t\tedge [loop right] node        {$\\sigma_2$}  ()\r\n\t\t(q_4) edge [bend right] node        {$\\sigma_1$}  (q_2)\r\n\t\tedge [loop right] node        {$\\sigma_1$}  ();\r\n\t\t\r\n\t\t%Automata states\r\n\t\t\\node[state] (q_5)  at (6,0)  {$x_1$}; \r\n\t\t\\node[state] (q_6) [below left=of q_5] {$x_2$}; \r\n\t\t\\node[state] (q_7) [below right=of q_5] {$x_3$};\r\n\t\t\r\n\t\t%Paths\r\n\t\t\\path[->] \r\n\t\t(q_5) edge              node        {$\\sigma_1$}  (q_7)\r\n\t\tedge              node [swap] {$\\sigma_1$}  (q_6)\r\n\t\t(q_6) edge [bend left]  node [swap] {$\\sigma_2$}  (q_7)\r\n\t\tedge [loop left]  node        {$\\sigma_1$}  ()\r\n\t\tedge [loop below] node        {$\\sigma_2$}  ()\r\n\t\t(q_7) edge [bend left]  node        {$\\sigma_1$}  (q_6)\r\n\t\tedge [loop right] node        {$\\sigma_2$}  ();\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t[>=stealth',shorten >=1pt,node distance=2cm,on grid,auto] \r\n\t\t\t\r\n\t\t\t%Automata states\r\n\t\t\t\\node[state] (q_0) {$p,\\,r$}; \r\n\t\t\t\\node[state] (q_1) [above right= of q_0] {$r$}; \r\n\t\t\t\\node[state] (q_2) [above left= of q_0] {$p,\\,q$};\r\n\t\t\t\\node[state] (q_3) [below of= q_1] {$p$};\r\n\t\t\t\\node[state] (q_4) [below left= of q_0] {$p$};\r\n\t\t\t\\node[state] (q_5) [below left of= q_3] {$p,\\,q$};\r\n\t\t\t\r\n\t\t\t\\path[->] \r\n\t\t\t(q_0) edge [bend right] node        {} (q_1)\r\n\t\t\tedge [bend right] node [swap] {} (q_2)\r\n\t\t\tedge [bend right] node        {} (q_4)\r\n\t\t\t(q_1) edge [bend left]  node [swap] {} (q_3)\r\n\t\t\t(q_2) edge [bend right]  node [swap] {} (q_0)\r\n\t\t\t(q_3) edge [bend left]  node        {} (q_5)\r\n\t\t\tedge [bend left]  node [swap] {} (q_0)\r\n\t\t\t(q_5) edge [bend left]  node [swap] {} (q_0)\r\n\t\t\t(q_4) edge [bend right] node [swap] {} (q_5);\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t% Nodes\r\n\t\t\\node (MIL) at (0,0) [draw, rectangle, text centered, minimum width=1cm]{MIL};\r\n\t\t\\node (SIL) at (0,-2) [draw, rectangle, text centered, minimum width=1cm]{SIL};\r\n\t\t\\node (HIL) at (0,-4) [draw, rectangle, text centered, minimum width=1cm]{HIL};\r\n\t\t\r\n\t\t\\node (testModel) at (-3,0) [draw, rectangle, text centered, minimum width=1cm]{Test Model};\r\n\t\t\\node (code) at (-3,-2) [draw, rectangle, text centered, minimum width=1cm]{Code};\r\n\t\t\r\n\t\t\\node (testSignal) at (-6,-1) [draw, rectangle, text centered, minimum width=1cm]{Test \r\n\t\t\tSignal};\r\n\t\t\r\n\t\t\\node (compareResults) at (3,-2) [draw, rectangle, text centered, minimum width=1cm, text \r\n\t\twidth=5em]{Compare\\\\results};\r\n\t\t\r\n\t\t% Links\r\n\t\t\\draw[-latex] (code) -- (SIL);\r\n\t\t\\draw[-latex] (testModel) -- (MIL);\r\n\t\t\\draw[-latex, dashed] (testModel.south) -- node[right, text width=5em, text centered] \r\n\t\t{Code\\\\generation} (code.north);\r\n\t\t\\draw[-latex] (testSignal) -| ($ (testModel) - (1.5,0)$) -- (testModel);\r\n\t\t\\draw[-latex] (testSignal) -| ($ (code) - (1.5,0)$) -- (code);\r\n\t\t\\draw[-latex] (code) |- (HIL);\r\n\t\t\r\n\t\t\\draw[-latex] (HIL) node at ($ (HIL) + (1,0.5)$) [text centered] \r\n\t\t{\\includegraphics[scale=0.05]{figure/hardware}} -| \r\n\t\t(compareResults);\r\n\t\t\\draw[-latex] (SIL) node at ($ (SIL) + (1,0.5)$) [text centered] \r\n\t\t{\\includegraphics[scale=0.075]{figure/PC}}-- (compareResults);\r\n\t\t\\draw[-latex] (MIL) node at ($ (MIL) + (1,0.5)$) [text centered] \r\n\t\t{\\includegraphics[scale=0.075]{figure/PC}} -| (compareResults);\r\n\t\t\r\n\t\t\\draw[-latex] (compareResults) -- ( $(compareResults) + (2,0)$ );\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\\end{center}\r\n\\end{figure}\t\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\t\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.825}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t% Feedback Linearization block\r\n\t\t\t\\node (feedbackLinearization) at (0,0) [draw, minimum height=2cm, minimum \r\n\t\t\twidth=1cm, text width=4em, text centered]{Feedback\\\\Lineariz.};\r\n\t\t\t\r\n\t\t\t% Virtual inputs\r\n\t\t\t\\node (virtualInputs) at (-3,1.25) [draw, minimum height=2cm, minimum \r\n\t\t\twidth=1cm, text width=4em, text centered]{Virtual\\\\Inputs};\r\n\t\t\t\r\n\t\t\t% Outputs and derivatives\r\n\t\t\t\\node (outputDerivatives) at (-5.5,-2) [draw, minimum height=2cm, minimum \r\n\t\t\twidth=1cm, text width=4em, text centered]{Outputs\\\\\\&\\\\Derivativ.};\r\n\t\t\t\r\n\t\t\t% Dynamical model\r\n\t\t\t\\node (dynamicalSystem) at (4.85,0) [draw, minimum height=2cm, minimum \r\n\t\t\twidth=1cm, text width=4em, text centered]{Dynamic \\\\System};\r\n\t\t\t\r\n\t\t\t% Add blocks\r\n\t\t\t\\node (sum1) at ($ (outputDerivatives.60) + (0,2) $) [draw, circle, text centered, \r\n\t\t\tminimum size=0.5cm]{};\r\n\t\t\t\\draw ($ (sum1) + (0.15,0.15) $) coordinate node[above left]{$+$};\r\n\t\t\t\\draw ($ (sum1) + (-0.05,-0.1) $) coordinate node[below right]{$-$};\r\n\t\t\t\\node (sum2) at ($ (outputDerivatives.120) + (0,2.75) $) [draw, circle, text centered, \r\n\t\t\tminimum size=0.5cm]{};\r\n\t\t\t\\draw ($ (sum2) + (0.15,0.15) $) coordinate node[above left]{$+$};\r\n\t\t\t\\draw ($ (sum2) + (-0.05,-0.1) $) coordinate node[below right]{$-$};\r\n\t\t\t\r\n\t\t\t% Integrators\r\n\t\t\t\\node (integrator1) at (1.86,-0.25) [draw, text centered]{$\\int$};\r\n\t\t\t\\node (integrator2) at (3,-0.25) [draw, text centered]{$\\int$};\r\n\t\t\t\r\n\t\t\t%%%%%%% Links\r\n\t\t\t% Virtual Inputs\r\n\t\t\t\\draw[-latex]{} (virtualInputs.-40) -- node[above, text centered, yshift=-0.1cm] \r\n\t\t\t{$\\mathbf{v}_2$} ($ (virtualInputs.-40) + (1.05,0) $);\r\n\t\t\t\\draw[-latex]{} (virtualInputs.-25) -- node[above, text centered, yshift=-0.1cm] \r\n\t\t\t{$\\mathbf{v}_1$} ($\t(virtualInputs.-25) + (1.05,0) $);\r\n\t\t\t\\draw[-latex] ($ (virtualInputs.70) + (0,1) $) -- \r\n\t\t\tnode[right]{$\\bm{\\varphi}^{d(4)}$} (virtualInputs.70);\r\n\t\t\t\\draw[-latex] ($ (virtualInputs.110) + (0,1) $) -- \r\n\t\t\tnode[left]{${^B\\mathbf{\\ddot{f}}}_L^d$} \r\n\t\t\t(virtualInputs.110);\r\n\t\t\t\\draw[-latex] (sum1) -- node[above]{$\\mathbf{e}_{f_L}$} ($ (sum1) + (0.95,0)$);\r\n\t\t\t\\draw[-latex] (sum2) -- node[above]{$\\mathbf{e}_{\\varphi}$} ($ (sum2) + (2.08,0)$);\r\n\t\t\t\\draw[-latex] ($ (sum2) - (1,0)$) -- (sum2);\r\n\t\t\t\\draw ($ (sum2) - (1.35,0)$) coordinate node [above]{$\\bm{\\varphi}^d$, \\dots, \r\n\t\t\t\t$\\bm{\\dddot{\\varphi}}^d$};\r\n\t\t\t\\draw[-latex] ($ (sum1) - (1,0)$) -- (sum1);\r\n\t\t\t\\draw ($ (sum1) - (0,0)$) node[below, text width=5em]{$\\Scale[1]{{^B\\mathbf{f}}^d_L}$,\\\\\r\n\t\t\t\t$\\Scale[1]{{^B\\mathbf{\\dot{f}}}^d_L}$};\r\n\t\t\t\r\n\t\t\t% Integrators\r\n\t\t\t\\draw[-latex] ($ (integrator1) - (0.89,0) $) -- (integrator1);\r\n\t\t\t\\draw ($ (integrator1) - (0.6,0) $) \r\n\t\t\tnode[above]{$\\Scale[0.8]{{^B\\mathbf{\\ddot{f}}}_R}$};\r\n\t\t\t\\draw[-latex] (integrator1) -- node[above]{$\\Scale[0.8]{{^B\\mathbf{\\dot{f}}}_R}$} \r\n\t\t\t(integrator2);\r\n\t\t\t\\draw[-latex] (integrator2) -- node[above]{$\\Scale[0.8]{{^B\\mathbf{f}}_R}$} ($ \r\n\t\t\t(integrator2) + (0.88,0) $);\r\n\t\t\t\r\n\t\t\t% From integrators to Outputs and Derivatives\r\n\t\t\t\\draw[-latex] ($ (integrator1) - (0.65,0) $) |- (outputDerivatives.-25);\r\n\t\t\t\\draw[fill=black] ($ (integrator1) - (0.69,0) $) arc(-180:180:0.04);\r\n\t\t\t\\draw[-latex] ($ (integrator2) + (0.45,0) $) |- (outputDerivatives.-40);\r\n\t\t\t\\draw[fill=black] ($ (integrator2) + (0.41,0) $) arc(-180:180:0.04);\r\n\t\t\t\r\n\t\t\t% Dynamic System\r\n\t\t\t\\draw[-latex] (feedbackLinearization.30) -- node[above, text centered, yshift=-0.1cm] \r\n\t\t\t{$^B\\bm{\\tau}_R$} (dynamicalSystem.150);\r\n\t\t\t\r\n\t\t\t% From Outputs & Derivatives to Add blocks\r\n\t\t\t\\draw[-latex] (outputDerivatives.60) node at ($ (outputDerivatives.60) + (0,0.75) $) \r\n\t\t\t[right]{${^B\\mathbf{f}}_L$, ${^B\\mathbf{\\dot{f}}}_L$} \r\n\t\t\t-- (sum1);\r\n\t\t\t\\draw[-latex] (outputDerivatives.120) node at ($ (outputDerivatives.120) + (0,0.75) \r\n\t\t\t$)[left]{$\\bm{\\varphi}$, \\dots, $\\bm{\\dddot{\\varphi}}$} -- (sum2);\r\n\t\t\t\\draw[-latex] ($ (outputDerivatives.0) + (1,0) $) -- node[above]{$\\mathbf{x}$} \r\n\t\t\t(outputDerivatives.0);\r\n\t\t\t\r\n\t\t\t% To Feedback Linearization block\r\n\t\t\t\\draw[-latex] ($ (feedbackLinearization.290) + (0,-1.46) $) --  \r\n\t\t\t(feedbackLinearization.290);\r\n\t\t\t\\draw[fill=black] ($ (feedbackLinearization.290) + (-0.04,-1.46) $) arc(-180:180:0.04);\r\n\t\t\t\\draw[-latex] ($ (feedbackLinearization.250) + (0,-1.82) $) --  \r\n\t\t\t(feedbackLinearization.250);\r\n\t\t\t\\draw[fill=black] ($ (feedbackLinearization.250) + (-0.04,-1.82) $) arc(-180:180:0.04);\r\n\t\t\t\\draw[-latex] ($ (feedbackLinearization.200) + (-1,0) $) -- node[above]{$\\mathbf{x}$} \r\n\t\t\t(feedbackLinearization.200);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n\\newpage\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\t\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{0.9}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%%%% Blocks\r\n\t\t\t% Reference trajectory generator\r\n\t\t\t\\node (referenceTrajectory) at (-5.6,0) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{Trajectory\\\\Generator};\r\n\t\t\t\r\n\t\t\t% Controller algorithm\r\n\t\t\t\\node (controller) at (0,-1.75) [draw, rectangle, text centered, minimum height=1.25cm, \r\n\t\t\tminimum width=1cm, text width=6em]{Feed. Linea.\\\\Controller};\r\n\t\t\t\r\n\t\t\t% PID Controller\r\n\t\t\t\\node (pidController) at (0,1.75) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{PD \\\\Controller};\r\n\t\t\t\r\n\t\t\t% Dynamic system + rotor dynamics\r\n\t\t\t\\node (dynamicSystem) at (5,0) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{Syst. \\& Rot.\\\\Dynamics};\r\n\t\t\t\r\n\t\t\t% State observer\r\n\t\t\t\\node (stateObserver) at (0,-4.25) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{State\\\\Observer};\r\n\t\t\t\r\n\t\t\t% Odometry sensor\r\n\t\t\t\\node (odometrySensor) at (4.25,-4.25) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{Odometry\\\\Sensor};\r\n\t\t\t\r\n\t\t\t% State observer2\r\n\t\t\t\\node (stateObserver2) at (0,4.25) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{State\\\\Observer};\r\n\t\t\t\r\n\t\t\t% Odometry sensor\r\n\t\t\t\\node (odometrySensor2) at (4.25,4.25) [draw, rectangle, text centered, minimum \r\n\t\t\theight=1.25cm, minimum width=1cm, text width=6em]{Odometry\\\\Sensor};\r\n\t\t\t\r\n\t\t\t\\node (dashedBoxGazebo1) at (5,0) [draw, dashed, rectangle, text centered, \r\n\t\t\tminimum height=1.75cm, minimum width=3.5cm]{};\r\n\t\t\t\r\n\t\t\t\\node (dashedBoxGazebo) at (4.25,-4.25) [draw, dashed, rectangle, text centered, \r\n\t\t\tminimum height=1.75cm, minimum width=3.25cm]{};\r\n\t\t\t\r\n\t\t\t\\node (dashedBoxGazebo) at (4.25,4.25) [draw, dashed, rectangle, text centered, \r\n\t\t\tminimum height=1.75cm, minimum width=3.25cm]{};\r\n\t\t\t\r\n\t\t\t% Gazebo text\r\n\t\t\t\\draw (4.25,5.4) coordinate node [text centered]{Gazebo}; % Odometry sensor2\r\n\t\t\t\\draw (4.25,-3.1) coordinate node [text centered]{Gazebo}; % Odometry sensor1\r\n\t\t\t\\draw (5,1.15) coordinate node [text centered]{Gazebo};\r\n\t\t\t\r\n\t\t\t%%%% Links\r\n\t\t\t\\draw[-latex] (referenceTrajectory) -- ($ (referenceTrajectory) + (3.85,0) $) |-  \r\n\t\t\t(controller);\r\n\t\t\t\\draw[-latex] ($ (referenceTrajectory) + (3.85,0) $) |-  (pidController);\r\n\t\t\t\\draw ($ (referenceTrajectory) + (2.65,0) $) coordinate node[above, text centered, text \r\n\t\t\twidth=5em]{$\\bm{\\varphi}^d$, $\\dots$, \\\\ $\\bm{\\varphi}^{(4)d}$};\r\n\t\t\t\\draw ($ (referenceTrajectory) + (2.65,0) $) coordinate \r\n\t\t\tnode[below, text width=5em, text centered]{${^B\\mathbf{f}}_L^d$, \r\n\t\t\t\t${^B\\mathbf{f}}_L^{(1)d}$, \\\\ ${^B\\mathbf{f}}_L^{(2)d}$};\r\n\t\t\t\\draw[fill=black] ($ (referenceTrajectory) + (3.81,0) $) arc(-180:180:0.04);\r\n\t\t\t\r\n\t\t\t\\draw[-] (controller) -- ($ (controller) + (2.35,0)$) -- node[left]{${^B\\bm{\\tau}}_R$} \r\n\t\t\tnode[right]{${^B\\mathbf{f}}_R$} ($ (controller) + (2.35,1)$);\r\n\t\t\t\\draw[-] (pidController) -- ($ (pidController) + (2.35,0)$) -- \r\n\t\t\tnode[left]{${^B\\bm{\\bar{\\tau}}}_R$} node[right]{${^B\\mathbf{\\bar{f}}}_R$} ($ \r\n\t\t\t(pidController) + (2.35,-1)$);\r\n\t\t\t\\draw[latex-] ($(controller) + (2.35,1)$) to [bend left ]($(pidController) + \r\n\t\t\t(2.35,-1)$);\r\n\t\t\t\\draw[-latex] ($ (pidController) + (0.85,-1.75)$) -- node[above]{$\\bar{A}$} \r\n\t\t\t($ (pidController) + (2.1,-1.75)$);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (stateObserver) -- node[left]{$\\bm{\\hat{\\varphi}}$, \r\n\t\t\t\t$\\bm{\\dot{\\hat{\\varphi}}}$} node[right]{$\\bm{\\hat{\\vartheta}}$, \r\n\t\t\t\t$\\bm{\\dot{\\hat{\\vartheta}}}$} (controller);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (stateObserver2) -- node[left]{$\\bm{\\hat{\\varphi}}$, \r\n\t\t\t\t$\\bm{\\dot{\\hat{\\varphi}}}$} node[right]{$\\bm{\\hat{\\vartheta}}$, \r\n\t\t\t\t$\\bm{\\dot{\\hat{\\vartheta}}}$} (pidController);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] ($ (controller) + (0,1.5)$) -- node[left]{$\\bar{A}$}(controller);\r\n\t\t\t\\draw[-latex] ($ (pidController) - (0,1.5)$) -- node[left]{$A$}(pidController);\r\n\t\t\t\r\n\t\t\t\\draw[-] ($ (pidController) + (2.35,-1)$) -- ($ (pidController) + (2.95,-1.75)$);\r\n\t\t\t\\draw[-latex] ($ (pidController) + (2.95,-1.75)$) -- (dynamicSystem);\r\n\t\t\t\\draw[fill=black] ($ (pidController) + (2.31,-1)$) arc(-180:180:0.04);\r\n\t\t\t\\draw[fill=black] ($(controller) + (2.31,1)$) arc(-180:180:0.04);\r\n\t\t\t\r\n\t\t\t\\draw[-latex] (odometrySensor) -- node[above]{${^W\\mathbf{r}}_B$} \r\n\t\t\tnode[below]{$\\bm{\\vartheta}$} (stateObserver);\r\n\t\t\t\\draw[-latex] (odometrySensor2) -- node[above]{${^W\\mathbf{r}}_B$} \r\n\t\t\tnode[below]{$\\bm{\\vartheta}$} (stateObserver2);\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\t\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\\scalebox{0.9}{\r\n\t\t\\begin{tikzpicture}\r\n\t\t\r\n\t\t% Nodes\r\n\t\t\\node (STLSpecifications) at (0,0) [text centered, draw, rectangle, minimum \r\n\t\twidth=4.5cm]{STL Specification};\r\n\t\t\\node (ControlSTL) at (0,-1) [text centered, draw, rectangle, minimum \r\n\t\twidth=4.5cm]{High-level Control for STL};\r\n\t\t\r\n\t\t% Links\r\n\t\t\\draw[-latex] (STLSpecifications) -- node[right]{$\\varphi$} (ControlSTL);\r\n\t\t\r\n\t\t% Multi-robots box\r\n\t\t\\node (MultiRobots-Box) at (0,-0.5) [draw, dashed, gray, minimum height=2cm, minimum \r\n\t\twidth=5.5cm]{}; \r\n\t\t\\draw[fill=black] ($ (ControlSTL.south) - (0.03,0.35) $) arc(-180:180:0.03);\r\n\t\t\r\n\t\t% Dots\r\n\t\t\\node (Dots1) at (-1.35,-4.0) [text centered]{\\dots};\r\n\t\t\\node (Dots2) at (1.40,-4.0) [text centered]{\\dots};\r\n\t\t\r\n\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t% Drone 1\r\n\t\t\\node (TrajectoryGenerator1) at (-2.75,-2.6) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Trajectory\\\\Generator};\r\n\t\t\\node (DroneController1) at (-2.75,-3.95) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Drone\\\\Controller};\r\n\t\t\\node (UAVDynamics1) at (-2.75,-5.35) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{UAV\\\\Dynamics};\r\n\t\t\\node (Drone-Box1) at (-2.75,-3.95) [draw, dashed, gray, minimum height=4.1cm, minimum \r\n\t\twidth=2.35cm]{}; \r\n\t\t\\node (Drone-Box1-Text) at (-2.75,-6.35) [text centered]{$1$-quadrotor};\t\r\n\t\t\r\n\t\t% Drone 1 - Links\r\n\t\t\\draw[-latex] (TrajectoryGenerator1) -- node[left]{$\\pmb{\\xi}_1$} \r\n\t\tnode[right]{$\\pmb{\\eta}_1$} (DroneController1);\r\n\t\t\\draw[-latex] (DroneController1) -- node[left]{$\\pmb{\\Omega}_1$} (UAVDynamics1);\t\r\n\t\t\\draw[-latex] (ControlSTL.south) -- ($ (ControlSTL.south) - (0,0.35) $) -- ($ \r\n\t\t(ControlSTL.south) - (2.75,0.35) $) -- node[above left]{$^W\\mathbf{r}_1$, $\\psi_1$} \r\n\t\t(TrajectoryGenerator1.north);\r\n\t\t\r\n\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t% Drone 2\r\n\t\t\\node (TrajectoryGenerator2) at (0,-2.6) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Trajectory\\\\Generator};\r\n\t\t\\node (DroneController2) at (0,-3.95) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Drone\\\\Controller};\r\n\t\t\\node (UAVDynamics2) at (0,-5.35) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{UAV\\\\Dynamics};\r\n\t\t\\node (Drone-Box2) at (0,-3.95) [draw, dashed, gray, minimum height=4.1cm, minimum \r\n\t\twidth=2.35cm]{};\r\n\t\t\\node (Drone-Box2-Text) at (0,-6.35) [text centered]{$2$-quadrotor};\t\t\r\n\t\t\r\n\t\t% Drone 2 - Links\r\n\t\t\\draw[-latex] (TrajectoryGenerator2) -- node[left]{$\\pmb{\\xi}_2$} \r\n\t\tnode[right]{$\\pmb{\\eta}_2$} (DroneController2);\r\n\t\t\\draw[-latex] (DroneController2) -- node[left]{$\\pmb{\\Omega}_2$}(UAVDynamics2);\t \r\n\t\t\\draw[-latex] ($ (ControlSTL.south) - (0,0.35) $) -- node[left]{$^W\\mathbf{r}_2$, $\\psi_2$} \r\n\t\t(TrajectoryGenerator2.north);\r\n\t\t\r\n\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t% Drone N\r\n\t\t\\node (TrajectoryGeneratorN) at (2.75,-2.6) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Trajectory\\\\Generator};\r\n\t\t\\node (DroneControllerN) at (2.75,-3.95) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{Drone\\\\Controller};\r\n\t\t\\node (UAVDynamicsN) at (2.75,-5.35) [draw, rectangle, text centered, text \r\n\t\twidth=5em]{UAV\\\\Dynamics};\t\r\n\t\t\\node (Drone-BoxN) at (2.75,-3.95) [draw, dashed, gray, minimum height=4.1cm, minimum \r\n\t\twidth=2.35cm]{}; \t\r\n\t\t\\node (Drone-BoxN-Text) at (2.75,-6.35) [text centered]{$n$-quadrotor};\r\n\t\t\r\n\t\t% Drone N - Links\r\n\t\t\\draw[-latex] (TrajectoryGeneratorN) -- node[left]{$\\pmb{\\xi}_n$} \r\n\t\tnode[right]{$\\pmb{\\eta}_n$} (DroneControllerN);\r\n\t\t\\draw[-latex] (DroneControllerN) -- node[left]{$\\pmb{\\Omega}_n$} (UAVDynamicsN);\t\r\n\t\t\\draw[-latex] ($ (ControlSTL.south) - (0,0.35) $) -- ($ (ControlSTL.south) + (2.75,-0.35) \r\n\t\t$) -- node[above right]{$^W\\mathbf{r}_n$, $\\psi_n$} (TrajectoryGeneratorN.north);\r\n\t\t\r\n\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\section{Example \\theblockDiagram}\r\n\\stepcounter{blockDiagram}\t\r\n\r\n\\begin{figure}[h]\r\n\t\\begin{center}\r\n\t\t\\scalebox{1}{\r\n\t\t\t\\begin{tikzpicture}\r\n\t\t\t\r\n\t\t\t%%%%%%%%%%%%%%%%%%%%% Motion Planner\r\n\t\t\t% Ground station block\r\n\t\t\t\\node (MultiRobots-Box) at (0,0.2) [fill=gray!3,rounded corners, draw=black!70, densely \r\n\t\t\tdotted, minimum height=1.7cm, minimum width=2.75cm]{}; \r\n\t\t\t\r\n\t\t\t% Motion Planner\r\n\t\t\t\\node (MotionPlanner) at (0,0) [text centered, fill=white, draw, rectangle, minimum \r\n\t\t\twidth=1.5cm, text width=5.5em]{Motion\\\\Planner};\r\n\t\t\t\r\n\t\t\t% Links\r\n\t\t\t\\draw[-latex] ($(MotionPlanner) - (1.5,0)$) -- node[above]{$\\varphi$} (MotionPlanner);\r\n\t\t\t\r\n\t\t\t% Multi-robots box\r\n\t\t\t\\draw[fill=black] ($ (MotionPlanner.east) + (0.5,0) $) arc(-180:180:0.03);\r\n\t\t\t\\node (GroundStation) at (0,0.75) [text centered]{\\small Ground Station};\r\n\t\t\t\r\n\t\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t\t% Drone 1\r\n\t\t\t\\node (Drone-Box1) at (5.15,2.15) [fill=gray!3,rounded corners, draw=black!70, densely \r\n\t\t\tdotted, minimum height=1.7cm, minimum width=5.45cm]{}; \r\n\t\t\t\\node (TrackingController1) at (3.65,1.95) [fill=white, draw, rectangle, text centered, \r\n\t\t\ttext width=5em]{Tracking\\\\Controller};\r\n\t\t\t\\node (UAVPlant1) at (6.65,1.95) [fill=white, draw, rectangle, text centered, text \r\n\t\t\twidth=5em]{UAV\\\\Plant};\r\n\t\t\t\\node (Drone-Box1-Text) at (5.1,2.7) [text centered]{\\small $1$\\textsuperscript{st} \r\n\t\t\t\tquad-rotor};\t\r\n\t\t\t\r\n\t\t\t% Drone 1 - Links\r\n\t\t\t\\draw[-latex] (TrackingController1) -- node[above]{$\\omega_{d_1}$} \r\n\t\t\tnode[below]{$T_{d_1}$} \r\n\t\t\t(UAVPlant1);\r\n\t\t\t\\draw[-latex] (MotionPlanner.east) -- ($ (MotionPlanner.east) + (0.525,0) $) \r\n\t\t\t-- ($ (MotionPlanner.east) + (0.525,1.95) $) -- node[above]{$\\mathbf{x}^\\star_1, \r\n\t\t\t\t\\mathbf{u}^\\star_1$} node[below]{$\\psi_1$} (TrackingController1.west);\r\n\t\t\t\r\n\t\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t\t% Drone 2\r\n\t\t\t\\node (Drone-Box2) at (5.15,0.2) [fill=gray!3,rounded corners, draw=black!70, densely \r\n\t\t\tdotted, minimum height=1.7cm, minimum width=5.45cm]{};\r\n\t\t\t\\node (TrackingController2) at (3.65,0) [fill=white, draw, rectangle, text centered, \r\n\t\t\ttext \r\n\t\t\twidth=5em]{Tracking\\\\Controller};\r\n\t\t\t\\node (UAVPlant2) at (6.65,0) [fill=white, draw, rectangle, text centered, text \r\n\t\t\twidth=5em]{UAV\\\\Plant};\r\n\t\t\t\\node (Drone-Box2-Text) at (5.15,0.75) [text centered]{\\small $2$\\textsuperscript{nd} \r\n\t\t\t\tquad-rotor};\t\t\r\n\t\t\t\r\n\t\t\t% Drone 2 - Links\r\n\t\t\t\\draw[-latex] (TrackingController2) -- node[above]{$\\omega_{d_2}$} \r\n\t\t\tnode[below]{$T_{d_2}$} \r\n\t\t\t(UAVPlant2);\t \r\n\t\t\t\\draw[-latex] ($ (MotionPlanner.east) + (0.525,0) $) -- \r\n\t\t\tnode[above]{$\\mathbf{x}^\\star_2, \\mathbf{u}^\\star_2$} node[below]{$\\psi_2$} \r\n\t\t\t(TrackingController2.west);\r\n\t\t\t\r\n\t\t\t%%%%%%%%%%%%%%%%%%%\r\n\t\t\t% Drone J\r\n\t\t\t\\node (Drone-BoxN) at (5.15,-1.75) [fill=gray!3,rounded corners, draw=black!70, densely \r\n\t\t\tdotted, minimum height=1.7cm, minimum width=5.45cm]{};\r\n\t\t\t% Dots\r\n\t\t\t\\node (Dots2) at (5.15,-0.8) [text centered]{\\dots};\r\n\t\t\t\\node (TrackingControllerN) at (3.65,-1.95) [fill=white, draw, rectangle, text \r\n\t\t\tcentered, \r\n\t\t\ttext width=5em]{Tracking\\\\Controller};\r\n\t\t\t\\node (UAVPlantN) at (6.65,-1.95) [fill=white, draw, rectangle, text centered, text \r\n\t\t\twidth=5em]{UAV\\\\Plant}; \t\r\n\t\t\t\\node (Drone-BoxN-Text) at (5.15,-1.2) [text centered]{\\small $q$\\textsuperscript{th} \r\n\t\t\t\tquad-rotor};\r\n\t\t\t\r\n\t\t\t% Drone J - Links\r\n\t\t\t\\draw[-latex] (TrackingControllerN) -- node[above]{$\\omega_{d_q}$} \r\n\t\t\tnode[below]{$T_{d_q}$} \r\n\t\t\t(UAVPlantN);\r\n\t\t\t\\draw[-latex] ($ (MotionPlanner.east) + (0.525,0) $) -- ($ \t\r\n\t\t\t(MotionPlanner.east) + (0.525,-1.95) $) -- node[above]{$\\mathbf{x}^\\star_q, \r\n\t\t\t\t\\mathbf{u}^\\star_q$} node[below]{$\\psi_q$} (TrackingControllerN.west);\r\n\t\t\t\r\n\t\t\t\\end{tikzpicture}\r\n\t\t}\r\n\t\\end{center}\r\n\\end{figure}", "meta": {"hexsha": "10f4cf3380720dd0d3632b3bc6959eca7e1a6c5f", "size": 99678, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "blockDiagrams.tex", "max_stars_repo_name": "gsilano/drawingExampleLaTeX", "max_stars_repo_head_hexsha": "892cebbc750e66c985f12ae7ebd9803eb0cf23c6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-09-21T09:51:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T11:32:43.000Z", "max_issues_repo_path": "blockDiagrams.tex", "max_issues_repo_name": "gsilano/drawingExampleLaTeX", "max_issues_repo_head_hexsha": "892cebbc750e66c985f12ae7ebd9803eb0cf23c6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "blockDiagrams.tex", "max_forks_repo_name": "gsilano/drawingExampleLaTeX", "max_forks_repo_head_hexsha": "892cebbc750e66c985f12ae7ebd9803eb0cf23c6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-21T09:52:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-10T15:06:40.000Z", "avg_line_length": 40.176541717, "max_line_length": 101, "alphanum_fraction": 0.5810810811, "num_tokens": 36789, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.40215639754437976}}
{"text": "\\setlength{\\parindent}{0pt}\n\\clearpage\n\n\\section{More DFA Examples}\n(Prepared by Jai Arora)\n\\vspace{0.3cm}\n\n\\subsection{Common Subexpression Elimination}\n\n\nIn this analysis, the property that we want to know at a program point is all the expressions available at that point.\n\\begin{itemize}\n    \\item The idea is to maintain a set of available expressions and the temporary in which they are stored, for every program point\n    \\item If a subexpression is available in the set of available expressions just before the statement that computes that subexpression, then replace it by the corresponding temporary (the precomputed value)\n\\end{itemize}\n\nA step-by-step example for this analysis can be found in \\href{https://www.youtube.com/watch?v=g3msUTH45Hg&list=PLf3ZkSCyj1tf3rPAkOKY5hUzDrDoekAc7&index=84}{this video}.\\\\\n\n\\subsection{Available expressions DFA}\nIn this analysis, the DFA value that we will deal with is a \\underline{set of available expressions}, where each element in this set is a tuple of the register and the expression stored in that register.\n\nSo $(x, y+z)$ denotes that the value of the subexpression $y+z$ is stored in the temporary $x$.\n\n\\vspace{0.5cm}\nHere also we will set a partial ordering in the values as follows:\\\\\n$$s_2 \\leqslant s_1 \\textbf{ iff } s_2 \\subseteq s_1$$\n\nThe lowest value in this ordering is $\\{\\}$, the empty set. This is a conservative value as it denotes that there is no subexpression available, hence no optimization would be done.\n\nOnce this ordering has been established, we can easily see that $glb(s_1,s_2) = s_1 \\cap s_2$.\n\n\\subsection{Transfer Function for Available Expressions}\nThis happens to be a forward dataflow analysis, so we will have 2 types of rules:\n\n\\begin{itemize}\n    \\item \\textbf{Case 1:} A statement $s$ has one or more predecessor program points. So in this case, the $in$ value of the statement $s$ is expressed as a function of $out$ values of the predecessor program points.\n    \\item \\textbf{Case 2:} For a given statement $s$, the $out$ value is a function of the $in$ value of that statement.\n\\end{itemize}\n\nDefine $set_{in}(s)$ be the set of available expressions before the statement $s$, and $set_{out}(s)$ be the set of available expressions after the statement $s$. The transfer function has the following rules:\n\n\\begin{itemize}\n    %insert images\n    \\item If $s$ is $x := y + z$, then remove all the set elements that refer to $x$ (all the expressions stored in $x$ and using $x$) from $set_{in}(s)$. This is because now $x$ stores a new expression in it, so all the previous mappings of $x$ would have to be removed. Also, all those mappings in which $x$ is used in the expression would also have to be removed because the value of the expression has now changed.\\\\\n    Then after this, add $(x,y+z)$ to $set_{out}(s)$.\n    \\item For a statement $s$ and it's predecessors, $set_{in}(s) = glb\\{set_{out}(p_i)~|~p_i~\\in~{\\tt predecessor}(s)\\}$\n\\end{itemize}\n\nAlso if $s$ is the starting statement, then the boundary condition for this algorithm would be $set_{in}(s) = \\{\\}$.\n\n\\subsection{Copy Propagation}\nCopy Propagation can be easily modelled as a DFA analysis very similar to Available Expressions DFA, except that we will be limiting ourselves to statements of the form $x := y$. The transformation logic will also be similar.\\\\\n\nThis optimisation creates oppurtunities for other global optimizations such that Global Constant Propagation and Liveness Analysis, so it works well in tandem with them.\n\n", "meta": {"hexsha": "2317631fa72e54213dfba99103cac4e8ecf05461", "size": 3497, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "module84.tex", "max_stars_repo_name": "arpit-saxena/compiler-notes", "max_stars_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "module84.tex", "max_issues_repo_name": "arpit-saxena/compiler-notes", "max_issues_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module84.tex", "max_forks_repo_name": "arpit-saxena/compiler-notes", "max_forks_repo_head_hexsha": "af3788cde815a5b1d19f206ec8605c0e372c1833", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-02-16T08:32:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-12T19:11:33.000Z", "avg_line_length": 62.4464285714, "max_line_length": 420, "alphanum_fraction": 0.7532170432, "num_tokens": 914, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.4019191623632954}}
{"text": "\\documentclass[]{article}\n\\usepackage[margin=1.0in]{geometry}\n\\usepackage{amssymb}\n\n%title material\n\\title{Astronomy 400B Homework \\#2}\n\\author{Please Show Your Work for Full Credit}\n\\date{Due Feb 26, 2015 by 9:35am}\n\n\n%include latex definitions\n\\input{astro400B_definitions.tex}\n\n%begin the document\n\\begin{document}\n\n%make the title, goes after document begins\n\\maketitle\n\n\\section{Sparke \\& Gallagher Problem 2.20}\n\nConsider the spherical density distribution $\\rho_H(r)$ with\n\\begin{equation}\n4\\pi G\\rho_H(r) = \\frac{V_H^2}{r^2 +a_H^2},\n\\end{equation}\nwhere $V_H$ and $a_H$ are constants; what is the mass $M(<r)$ contained within\na radius $r$? Use the equation\n\\begin{equation}\nM(<R) = RV^2/G\n\\end{equation}\nto show that the speed $V(r)$ of a circular orbit at radius $r$\nis given by\n\\begin{equation}\nV^2(r) = V_H^2[1-(a_H/r)\\arctan(r/a_H)],\n\\end{equation}\n\\noindent\nand sketch $V(r)$ as a function of radius. This density law is sometimes\nused to represent the mass of a galaxy's dark halo -- why?\n\n\\section{Sparke \\& Gallagher Problem 2.24}\n\nWe can estimate the size of an HII region around a massive star that radiates $S_\\star$ photons with energy above 13.6eV each second. Assume that the\ngas within radius $r_\\star$ absorbs all these photons, becoming almost\ncompletely ionized so that $n_e \\approx n_H$, the density of H nuclei. In a\nsteady state atoms recombine as fast as they are ionized, so the star ionizes\na mass of gas $M_g$, where\n\\begin{equation}\nS_\\star = (4r_\\star^3/3)n_H^2\\alpha(T_e) = (M_g/m_p)n_H\\alpha(T_e).\n\\end{equation}\nUse the equation\n\\begin{equation}\n-\\frac{dn_e}{dt} = n_e^2 \\alpha(T_e)~~\\mathrm{with}~~\\alpha(T_e) \\approx 2\\times 10^{-13}\\left(\\frac{T_e}{10^4~\\K}\\right)^{-3/4}~\\cm^3~\\s^{-1}\n\\end{equation}\n\\noindent\nto show that a mid-O star radiating $S_\\star=10^{49}~\\s^{-1}$ into gas of\ndensity $10^{3}~\\cm^{-3}$ creates an HII region of radius $0.67~\\pc$,\ncontaining $\\sim30\\Msun$ of gas (assume that $T_e=10^4\\K$). What\nis $r_\\star$ if the density is ten times larger? Show that only a tenth\nas much gas is ionized. How large is the HII region around a B1\nstar with $n_H=10^3 \\cm^{-3}$ but only $S_\\star = 3\\times10^{47}~\\s^{-1}$?\n\n\\pagebreak\n\n\\section{Sparke \\& Gallagher Problem 3.7}\n\nThe {\\it Navarro-Frenk-White} (NFW) model describes the\nhalos of cold dark matter that form in cosmological simulations.\nShow that the potential corresponding to the density\n\\begin{equation}\n\\rho_{NFW}(r) = \\frac{\\rho_N}{(r/a_N)(1+r/a_N)^2}~\\mathrm{is}~\\Phi_{NFW}(r) = -\\sigma_N^2\\frac{\\ln(1+r/a_N)}{(r/a_N)},\n\\end{equation}\n\\noindent\nwhere $\\sigma_N^2 = 4\\pi G \\rho_N a_N^2$. The density rises steeply\nat the center, but less so than in the singular isothermal sphere;\nat large radii $\\rho(r)\\propto r^{-3}$. Show that the speed\n$V$ of a circular orbit at radius $r$ is given\nby\n\\begin{equation}\nV^2(r) = \\sigma_N^2\\left[\\frac{\\ln(1+r/a_N)}{(r/a_N)} - \\frac{1}{(1+r/a_N)}\\right].\n\\end{equation}\n\n\\section{Sparke \\& Gallagher Problem 3.12}\n\nShow that for the Plummer sphere model with density profile\n\\begin{equation}\n\\rho_P(r) = \\frac{3a_P^2}{4\\pi}\\frac{M}{(r^2 + a_P^2)^{5/2}}\n\\end{equation}\n\\noindent\nand potential\n\\begin{equation}\n\\Phi_P(r) = -\\frac{GM}{\\sqrt{r^2 +a_P^2}}\n\\end{equation}\n\\noindent\nthe potential energy is\n\\begin{equation}\nPE = - \\frac{3\\pi}{32} \\frac{GM^2}{a_P}.\n\\end{equation}\n\n\n\\end{document}", "meta": {"hexsha": "23fe51362e2ab1032ddcf953da26b6f3ed6fc0d9", "size": 3344, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "homework_2.tex", "max_stars_repo_name": "brantr/astro400B", "max_stars_repo_head_hexsha": "95cd675c23b9c44242f428516ed3e0fca54d3b4f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-05-03T23:30:58.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-03T23:30:58.000Z", "max_issues_repo_path": "homework_2.tex", "max_issues_repo_name": "brantr/astro400B", "max_issues_repo_head_hexsha": "95cd675c23b9c44242f428516ed3e0fca54d3b4f", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homework_2.tex", "max_forks_repo_name": "brantr/astro400B", "max_forks_repo_head_hexsha": "95cd675c23b9c44242f428516ed3e0fca54d3b4f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.44, "max_line_length": 149, "alphanum_fraction": 0.7087320574, "num_tokens": 1189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.4019127042314167}}
{"text": "\\chapter{Cost-sensitive logistic regression}\\label{ch:7}\n\n\\begin{remark}{Outline}\nIn this chapter, we propose a cost-sensitive logistic regression algorithm. The model consists in \na new logistic regression cost function, one that takes into account the real costs due to \nmisclassification and correct classification. First, in Section \\ref{sec:7:logistic}, we give the \nbackground behind logistic regression. Then, in Section \\ref{sec:7:cslr}, we describe the \ncost-sensitive logistic regression. For this, we carry a deep analysis of the \nlogistic regression implicit misclassification costs in Section \\ref{sec:7:log_cost_analysis}. Then \nin Section \\ref{sec:7:cscostfunction}, we give a new version of the logistic regression cost \nfunction. Finally, in Section \\ref{sec:7:results}, we compare the results of the proposed \nalgorithm against state-of-the-art methods, using the five real-world cost-sensitive databases \npresented in \\partname{~\\textsc{\\ref{part:2}}}.\n\\end{remark}\n\n\n\\section{Logistic regression}\n\\label{sec:7:logistic}\n\nLogistic regression is a classification model that, in the specific context of binary \nclassification, estimates the posterior probability of the positive class, as the logistic sigmoid \nof a linear function of the feature vector \\citep{Bishop2006}. The estimated probability  is \nevaluated as \n\\begin{equation}\n  \\hat p_i = P(y=1 \\vert \\mathbf{x}_i) = h_{\\theta}(\\mathbf{x}_i) = \n  g\\bigg(\\sum_{j=1}^{k}{\\theta^jx_i^j}\\bigg),\n\\end{equation}\nwhere $h_\\theta(\\mathbf{x}_i)$ refers to the hypothesis of $i$ given the parameters $\\theta$, the \nfeature vector $\\mathbf{x}_i$ for example $i$ and  $g(\\cdot)$ is the logistic sigmoid function \ndefined as\n\\begin{equation}\n  g(z)=\\frac{1}{(1+e^{-z})} .\n\\end{equation}\nIn \\figurename{~\\ref{fig:ch7:1}}, the logistic sigmoid function is shown.\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics{ch7_fig1}\n  \\caption{Sigmoid function}\n  \\label{fig:ch7:1}\n\\end{figure}\n\nThe problem then becomes on finding the right parameters that minimize a given cost function.   \nUsually, in the case of logistic regression, the cost function $J(\\theta)$ refers to the negative   \nlogarithm of the likelihood, such that\n\\begin{equation}\n  J(\\theta)=\\frac{1}{N}\\sum_{i=1}^{N} J_i(\\theta),\n\\end{equation}\nwhere\n\\begin{align}\\label{eq:7:lrcost}\n  J_i(\\theta) =  -y_i\\log(h_\\theta(\\mathbf{x}_i)) -(1-y_i)\\log(1-h_\\theta(\\mathbf{x}_i)).\n\\end{align}\nTherefore, the parameters are estimated by minimizing (\\ref{eq:7:lrcost})\n$\n  \\hat \\theta = \\argmin_\\theta J(\\theta).\n$\n\nThere are several methods used to estimate the logistic regression, in particular, maximum \nlikelihood \\citep{Hastie2009}, Newton, coordinate descent \\citep{Murphy2012} and dual coordinate \ndescent \\citep{Yu2011}. Nevertheless, all these methods rely on the assumption of convexity of the \nlogistic regression cost function $J(\\theta)$. \n\n\n\\section{Cost-sensitive logistic regression}\n\\label{sec:7:cslr}\n\nIn this section we present our cost-sensitive logistic regression algorithm.\nFirst, we motivate the need to modify the logistic regression, as we \nanalyze the implicit costs that the logistic regression assigned to each misclassification error \nduring the estimation of the parameters $\\theta$. Then, we show our proposed algorithm.\n\n\n\\subsection{Implicit costs of the logistic regression}\n\\label{sec:7:log_cost_analysis}\n\nThe logistic regression cost function, as described in (\\ref{eq:7:lrcost}), implicitly assume that \nfalse positives and false negatives have the same costs, i.e. $C_{{FP}_i} = C_{{FN}_i}$ $\\forall \ni \\in \\{1,\\cdots,N\\}$. This can be easily shown by analyzing the logistic cost function for both \nvalues of $y_i$ and the algorithm prediction $h_\\theta(\\mathbf{x}_i))$:\n\n\\begin{itemize}\n\\item If $y_i=0$ and $h_\\theta(\\mathbf{x}_i) \\approx 0$, then\n\\begin{align*}\n J_i(\\theta) &= -y_i\\log(h_\\theta(\\mathbf{x}_i)) -(1-y_i)\\log(1-h_\\theta(\\mathbf{x}_i)) \\nonumber \\\\\n &\\approx -(0)\\log((0)) -(1-(0))\\log(1-(0)) \\nonumber \\\\\n &\\approx 0.\n\\end{align*}\n\n\\item If $y_i=0$ and $h_\\theta(\\mathbf{x}_i) \\approx 1$, then\n\\begin{align*}\n J_i(\\theta) &\\approx -(0)\\log((1)) -(1-(0))\\log(1-(1)) \\nonumber \\\\\n &\\approx \\infty.\n\\end{align*}\n\n\\item If $y_i=1$ and $h_\\theta(\\mathbf{x}_i) \\approx 0$, then\n\\begin{align*}\n J_i(\\theta) &\\approx -(1)\\log((0)) -(1-(1))\\log(1-(0)) \\nonumber \\\\\n &\\approx \\infty.\n\\end{align*}\n\n\\item If $y_i=1$ and $h_\\theta(\\mathbf{x}_i) \\approx 1$, then\n\\begin{align*}\n J_i(\\theta) &\\approx -(1)\\log((1)) -(1-(1))\\log(1-(1)) \\nonumber \\\\\n &\\approx 0.\n\\end{align*}\n\\end{itemize}\n\n\\noindent Then, we collect the previous results in a cost matrix:\n  \\begin{table}[htbp]\n    \\centering\n    \\footnotesize\n    \\begin{tabular}{c|c|c}\n      \\multicolumn{3}{c}{}\\\\\n      \\multicolumn{1}{c|}{}  & Actual Positive& Actual Negative \\\\\n      \\multicolumn{1}{c|}{} & $y_i=1$& $y_i=0$ \\\\\n      \\hline\n      Predicted Positive    & \\multirow{ 2}{*}{$C_{{TP}_i}\\approx 0$} & \n      \\multirow{2}{*}{$C_{{FP}_i}\\approx \\infty$} \\\\\n      $c_i=1$ & &\\\\\n      \\hline\n      Predicted Negative    & \\multirow{ 2}{*}{$C_{{FN}_i}\\approx \\infty$} & \\multirow{ \n      2}{*}{$C_{{TN}_i}\\approx 0$} \\\\\n      $c_i=0$ & &\\\\\n    \\end{tabular}\n    \\caption{Logistic regression cost matrix}\n    \\label{tab:7:1}\n  \\end{table} \n  \nThis confirms that the logistic regression cost function implicitly assume that \nfalse positives and false negatives have the same costs. However, as discussed in \nChapter~\\ref{ch:4} and Chapter~\\ref{ch:5}, this is not the case in several real-world \napplications.\n\n  \n\\subsection{Cost-sensitive logistic regression cost function}\n\\label{sec:7:cscostfunction}\n\nIn order to incorporate the different real costs, as showed in \n\\tablename{~\\ref{tab:3:cost_matrix}}, into the logistic regression, we start by analyzing the \nexpected costs that a modified logistic regression cost function should make for each \nmisclassification and correct classification case.\n\n\\begin{equation*}\n  J^c_i(\\theta) = \n  \\begin{cases}\n    C_{TP_i}    & \\text{if} \\phantom{-}  y_i = 1 \\text{ and } h_\\theta(\\mathbf{x}_i) \\approx 1  \\\\\n    C_{TN_i}    & \\text{if} \\phantom{-}  y_i = 0 \\text{ and } h_\\theta(\\mathbf{x}_i) \\approx 0  \\\\\n    C_{FP_i}    & \\text{if} \\phantom{-}  y_i = 0 \\text{ and } h_\\theta(\\mathbf{x}_i) \\approx 1  \\\\\n    C_{FN_i}    & \\text{if} \\phantom{-}  y_i = 1 \\text{ and } h_\\theta(\\mathbf{x}_i) \\approx 0 .\n  \\end{cases}\n\\end{equation*}\n\nThen, as we already have the real costs, we create a new cost-sensitive logistic regression cost \nfunction, by including the different costs into the logistic function,\n\n\\begin{align}\\label{eq:CSLR}\n  J^c(\\theta)=\\frac{1}{N} \\sum_{i=1}^{N} \\bigg( y_i(h_\\theta(\\mathbf{x}_i) C_{TP_i} + \n  (1-h_\\theta(\\mathbf{x}_i))C_{FN_i})  \\nonumber\\\\ \n  +(1-y_i)(h_\\theta(\\mathbf{x}_i) C_{FP_i} + (1-h_\\theta(\\mathbf{x}_i))C_{TN_i}) \\bigg).\n\\end{align}\n\nSince this  new cost function is not convex, we estimate the parameters $\\theta$ with genetic \nalgorithms, as this optimization heuristic does not require the underlying function to be \ndifferentiable or convex \\citep{Haupt2004}. \n\n\\section{Experiments}\n\\label{sec:7:results}\n\nFor the experiments we use five datasets from four different real world example-dependent \ncost-sensitive problems: Credit card fraud detection (see Section~\\ref{sec:4:fraud}), credit \nscoring (see Section~\\ref{sec:4:creditscoring}), churn modeling (see Section~\\ref{sec:5:churn}) and \ndirect marketing (see Section~\\ref{sec:5:directmarketing}). The different datasets are summarized \nin \\tablename{~\\ref{tab:4:databases}} and \\tablename{~\\ref{tab:5:databases}}.\n\nIn particular, we are interested in comparing the results of the different logistic regression \nmodels. First we train a logisitc regression ($LR$) using the training ($t$), under-sampled \n($u$), cost-proportionate rejection-sampling  ($r$) \\citep{Zadrozny2003}  and  cost-proportionate \nover-sampling ($o$) \\citep{Elkan2001} datasets. Afterwards,  we evaluate the results of  the \nalgorithms using $BMR$, see Chapter~\\ref{ch:6}. Lastly, we calculate the cost-sensitive \nlogistic  regression ($CSLR$). We use the logistic regression implementation of\n\\textit{Scikit-learn} \\citep{Pedregosa2011}, and the \\textit{CostCla} library, see \nAppendix~\\ref{ch:A}, for the cost-sensitive algorithms. Unless otherwise stated, the random \nselection of the training set was repeated 50 times, and in each time the models were trained and \nresults collected, this allows us to measure the stability of the results.\n  \nIn \\tablename{~\\ref{tab:7:results_savings}}, we show the results of each algorithm in the different \ndatabases measured by savings. Firstly, the proposed $CSLR$ has the highest savings in the \nfraud, churn and credit 1 databases, moreover, in the credit 2 and marketing databases, it \nis the second best model. It is interesting to see how different the results from a standard \nlogistic regression and the cost-sensitive logistic \nregression are. Moreover, we also calculate the results of the $F_1Score$ for each model, as \nshown in \\tablename{~\\ref{tab:7:results_fscore}}. It is observed that the $CSLR$ algorithm is not \nthe one that gives the best results measured by $F_1Score$. In fact, there is not a clear relation \nbetween the results measured by savings or  $F_1Score$.\n  \nFinally, we compute the perBest statistic  for the savings and the $F_1Score$. This statistic is \ncalculated as the average result of each algorithm compared with the best in each set. The results \nare shown in \\figurename{~\\ref{fig:7:comparison_per_best}}. On average, the $CSLR$ is the best \nmodel, as it yield to 95.5\\% of the best model in the different databases. Nevertheless, when \nmeasured by $F_1Score$, it only yield to 74.7\\% of the best model. This leads to the conclusion \nof the importance of using a cost-sensitive measure such as savings when evaluating real-world \nexample-dependent cost-sensitive problems. \n\n\\begin{figure} \n  \\centering\n  \\includegraphics{ch7_fig3}\n  \\caption{\\textbf{Comparison of the average savings and $F_1Score$ of the algorithms versus the \n    the best model.} The models that perform the best measured by $F_1Score$ are not the best \n  in terms of savings.}\n  \\label{fig:7:comparison_per_best}\n\\end{figure}\n\nMoreover, it is observed that the standard logistic regression trained using the training set is \nthe model that performs the worst measured by both savings and $F_1Score$. This is related not only \nto the cost-sensitivity of the problems, but also to the highly unbalanced distribution of positive \nand negatives presented in all the databases. This is the reason why by using an under-sampling \nprocedure, the results are improved by both measures.\n\n\\begin{sidewaystable}\n\n    \\centering\n    \\footnotesize\n    \\begin{tabular}{l l r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip \n    0in}c@{\\hskip 0in}l  r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip 0in}c@{\\hskip 0in}l} %sum 7.7\n    \\hline\n    \\bf{Family} & \\bf{Algorithm} & \\multicolumn{3}{c}{\\bf{Fraud}} & \n    \\multicolumn{3}{c}{\\bf{Churn}} & \\multicolumn{3}{c}{\\bf{Credit 1}}\n    &  \\multicolumn{3}{c}{\\bf{Credit 2}} & \\multicolumn{3}{c}{\\bf{Marketing}} \\\\ \n    \\hline\nCI&LR-t & 0.0092 &$\\pm$& 0.0002 & -0.0001 &$\\pm$& 0.0002 & 0.0177 &$\\pm$& 0.0126& 0.0039 &$\\pm$& 0.0012 & -0.2931 &$\\pm$& 0.0602\\\\ \n&LR-u & 0.1243 &$\\pm$& 0.0387 & 0.0039 &$\\pm$& 0.0492 & 0.4118 &$\\pm$& 0.0313& 0.1850 &$\\pm$& 0.0231 & 0.2200 &$\\pm$& 0.0376\\\\ \n\\hline \nCPS&LR-r & 0.3077 &$\\pm$& 0.0301 & 0.0484 &$\\pm$& 0.0375 & 0.3965 &$\\pm$& 0.0263& 0.2650 &$\\pm$& 0.0115 & 0.4210 &$\\pm$& 0.0267\\\\ \n&LR-o & 0.2793 &$\\pm$& 0.0185 & 0.0316 &$\\pm$& 0.0228 & 0.3301 &$\\pm$& 0.0109& 0.2554 &$\\pm$& 0.0090 & 0.3129 &$\\pm$& 0.0277\\\\ \n\\hline \nBMR&LR-t-BMR & 0.4552 &$\\pm$& 0.0203 & 0.1082 &$\\pm$& 0.0316 & 0.2189 &$\\pm$& 0.0541& \\bf{0.3148} &\\bf{$\\pm$}& \\bf{0.0094} & \\bf{0.4973} &\\bf{$\\pm$}& \\bf{0.0084}\\\\ \n\\hline \nCST&CSLR-t & \\bf{0.6113} &\\bf{$\\pm$}& \\bf{0.0262} & \\bf{0.1118} &\\bf{$\\pm$}& \\bf{0.0484} & \n\\bf{0.4554} &\\bf{$\\pm$}& \\bf{0.1039}& 0.2748 &$\\pm$& 0.0069 & 0.4484 &$\\pm$& 0.0072\\\\ \n\\hline\n  \\multicolumn{17}{c}{(Models with the highest savings are marked in bold)}\n  \\end{tabular}\n    \\caption{Results of the algorithms measured by savings}\n    \\label{tab:7:results_savings}\n\n\\bigskip\\bigskip\\bigskip  % provide some separation between the two tables\n\n    \\begin{tabular}{l l r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip \n    0in}c@{\\hskip 0in}l  r@{\\hskip 0in}c@{\\hskip 0in}l r@{\\hskip 0in}c@{\\hskip 0in}l} %sum 7.7\n    \\hline\n    \\bf{Family} & \\bf{Algorithm} & \\multicolumn{3}{c}{\\bf{Fraud}} & \n    \\multicolumn{3}{c}{\\bf{Churn}} & \\multicolumn{3}{c}{\\bf{Credit 1}}\n    &  \\multicolumn{3}{c}{\\bf{Credit 2}} & \\multicolumn{3}{c}{\\bf{Marketing}} \\\\ \n    \\hline\nCI&LR-t & 0.1531 &$\\pm$& 0.0045 & 0.0000 &$\\pm$& 0.0000 & 0.0494 &$\\pm$& 0.0277& 0.0155 &$\\pm$& 0.0037 & 0.2702 &$\\pm$& 0.0125\\\\ \n&LR-u & 0.0241 &$\\pm$& 0.0163 & 0.1222 &$\\pm$& 0.0098 & 0.3160 &$\\pm$& 0.0314& \\bf{0.3890} &\\bf{$\\pm$}& \\bf{0.0053} & 0.3440 &$\\pm$& 0.0083\\\\ \n\\hline \nCPS&LR-r & 0.1846 &$\\pm$& 0.0123 & 0.1258 &$\\pm$& 0.0111 & 0.3597 &$\\pm$& 0.0156& 0.3793 &$\\pm$& 0.0049 & 0.3374 &$\\pm$& 0.0101\\\\ \n&LR-o & 0.1776 &$\\pm$& 0.0117 & 0.1085 &$\\pm$& 0.0203 & \\bf{0.3769} &\\bf{$\\pm$}& \\bf{0.0067} & 0.3804 &$\\pm$& 0.0044 & \\bf{0.3568} &\\bf{$\\pm$}& \\bf{0.0102}\\\\ \n\\hline \nBMR&LR-t-BMR & 0.1384 &$\\pm$& 0.0044 & \\bf{0.1370} &\\bf{$\\pm$}& \\bf{0.0150} & 0.1915 &$\\pm$& \n0.0340& 0.3572 &$\\pm$& 0.0045 & 0.2954 &$\\pm$& 0.0079\\\\ \n\\hline \nCST&CSLR-t & \\bf{0.2031} &\\bf{$\\pm$}& \\bf{0.0065} & 0.1134 &$\\pm$& 0.0151 & 0.1454 &$\\pm$& 0.0517& 0.3363 &$\\pm$& 0.0045 & 0.2339 &$\\pm$& 0.0051\\\\ \n\\hline\n  \\multicolumn{17}{c}{(Models with the highest $F_1Score$ are marked in bold)}\n  \\end{tabular}\n    \\caption{Results of the algorithms measured by $F_1Score$}\n    \\label{tab:7:results_fscore}\n    \n\\end{sidewaystable}", "meta": {"hexsha": "d02de35abc4de34923f968e30ac794cc1f7492b5", "size": 13866, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/chapters/chapter07.tex", "max_stars_repo_name": "albahnsen/phd-thesis", "max_stars_repo_head_hexsha": "8aedb00cba939b6f8a2f891f453a37206db1f635", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2015-10-07T13:31:49.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-09T12:02:27.000Z", "max_issues_repo_path": "tex/chapters/chapter07.tex", "max_issues_repo_name": "albahnsen/phd-thesis", "max_issues_repo_head_hexsha": "8aedb00cba939b6f8a2f891f453a37206db1f635", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/chapters/chapter07.tex", "max_forks_repo_name": "albahnsen/phd-thesis", "max_forks_repo_head_hexsha": "8aedb00cba939b6f8a2f891f453a37206db1f635", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-01-25T17:16:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-11T13:47:21.000Z", "avg_line_length": 51.3555555556, "max_line_length": 164, "alphanum_fraction": 0.6890956296, "num_tokens": 4894, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.401912703427509}}
{"text": "\\documentclass[10pt,letter]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{graphicx}\n\\usepackage{setspace}\n\\usepackage{stmaryrd}\n\\def\\fatbar{\\talloblong}\n\\onehalfspacing\n\\usepackage{fullpage}\n\\newcommand{\\R}{\\mathbb{R}}\t\n\\newcommand{\\inner}{\\langle\\cdot,\\cdot\\rangle}\n\\newcommand{\\inr}[2]{\\langle #1, #2\\rangle}\n\\newcommand\\norm[1]{\\left\\lVert#1\\right\\rVert}\n\n\\graphicspath{ {images/} }\n\n\\begin{document}\n\n\n\\title{CS142 Homework Set \\#5 Solutions}\n\n\\author{Timur Kuzhagaliyev}\n\n%\\date{7th November, 2017}\n \n\\maketitle \n\n\\section*{Problem 1}\n\n\\paragraph{a)} I'll use an algorithm based on a concept of a diffusing computation similar to gossip algorithm in Sivilotti 6.5, modified to pass the total number of children $+ 1$ to the parent. I'll use the same specification and definitions as in Sivilotti 6.4, with 2 changes. I will adjust the definitions of $msg(x, y)$ and $done$ to fit our problem:\n\\begin{align*}\nmsg(x, y)\\quad \\equiv \\quad &\\textrm{tuple value $(p, c)$ of the message in the channel from $x$ to $y$,}\n\\\\\n& \\textrm{where $p$ is the parent of the sender (if any) and $v$ is some integer}\n\\\\\ndone\\quad \\equiv \\quad &(\\; \\forall\\; v : v\\; nbr\\; I : msg(v, I) \\land (msg(v, I).p = I \\Rightarrow  msg(v, I).c = -1)\\;\\; )\n\\end{align*}\n\nNote about notation: When $msg(x, y)$ is used on its own (without accessing the values in the tuple), its interpreted as \"there is a message in channel from x to y\".\n\nFirst, we define a UNITY program for the agent $I$ that initiates the diffusing computation. Its task is to send the initial gossip messages to all of its neigbours. Once it gets a message back, it checks that it's the parent of the sender and increments the vertex count by the reported value.\n\\begin{align*}\n\\textrm{\\textbf{Program}} \\qquad & \\textrm{Initiator}\\; I\n\\\\\n\\textrm{\\textbf{var}} \\qquad & vertex\\_count\\; \\textrm{:\\; int}\n\\\\ & msg(a, b)\\; \\textrm{:\\; channel from $a$ to $b$}\n\\\\\n\\textrm{\\textbf{initially}} \\qquad & vertex\\_count = 1\n\\\\\n\\land\\; & (\\; \\forall\\; v : v\\; nbr\\; I : \\neg\\, msg(v, I) \\land \\neg\\, msg(I, v)\\; )\n\\\\\n\\textrm{\\textbf{assign}} \\qquad &\n(\\, \\fatbar\\, v : v\\; nbr\\; I : \\neg\\, msg(I, v) \\longrightarrow msg(I, v) := (-1, -1)\\; )\n\\\\\n\\fatbar\\quad & (\\, \\fatbar\\, v : v\\; nbr\\; I : msg(v, I) \\land msg(v, I).p = I \\land msg(v, I).c \\neq -1 \\longrightarrow \n\\\\\n& \\qquad \\qquad vertex\\_count,\\; msg(v, I).c := vertex\\_count + msg(v, I).c,\\; -1\\; )\n\\end{align*}\n\nI will refer to actions as $I1$ and $I2$. The action $I2$ of program \\texttt{Initiator} checks whether $I$ is the parent of the incoming message. If it is, it adds the count passed in the message to $vertex\\_count$ and resets the value in the message to $-1$. If the value in the message is already $-1$, it is ignored. By definition of $done$, $done$ will hold when $I$ has received a message from each of its neighbours and processed them using the logic I just described.\n\nNow we define a UNITY program for all other agents which will be spreading the gossip. It's a modified version of the Gossip program in Sivilotti 6.5. The middle action executes the same logic as described in the paragraph above, but applied to \\texttt{Gossip} program instead.\n\\begin{align*}\n\\textrm{\\textbf{Program}} \\qquad & \\textrm{Gossip}\\; u\n\\\\\n\\textrm{\\textbf{var}} \\qquad & vertex\\_count_u\\; \\textrm{:\\; int}\n\\\\ & parent_u\\; \\textrm{:\\; process}\n\\\\ & state_u\\; \\textrm{:\\;} \\{idle, active, complete\\}\n\\\\ & msg(a, b)\\; \\textrm{:\\; channel from $a$ to $b$}\n\\\\\n\\textrm{\\textbf{initially}} \\qquad & vertex\\_count = 1\n\\\\\n\\land\\; & state_u = idle\n\\\\\n\\land\\; & (\\; \\forall\\; v : v\\; nbr\\; u : \\neg\\, msg(u, v)\\; )\n\\\\\n\\textrm{\\textbf{assign}} \\qquad &\n(\\, \\fatbar\\, v : v\\; nbr\\; u : state_u = idle \\land msg(v, u) \\longrightarrow\n\\\\\n& \\qquad \\qquad parent_u := v\\; \n\\\\\n& \\qquad \\qquad \\lVert\\;\\; state_u := active\\;\n\\\\\n& \\qquad \\qquad \\lVert\\;\\; (\\; \\forall\\; w : w\\; nbr\\; u \\land w \\neq v : msg(u, w) := (v, -1)\\; ) )\n\\\\ &\n\\fatbar (\\, \\fatbar\\, v : v\\; nbr\\; u : state_u = active \\land msg(v, u) \\land msg(v, u).p = u \\land msg(v, u).c \\neq -1 \\longrightarrow\n\\\\\n& \\qquad \\qquad vertex\\_count_u,\\; msg(v, u).c := vertex\\_count + msg(v, u).c,\\; -1\\; )\n\\\\ &\n\\fatbar state_u = active \\land (\\, \\forall\\, v : v\\; nbr\\; u \\land v \\neq parent_u : msg(v, u) \\land (msg(v, u).p = u \\Rightarrow  msg(v, u).c = -1)\\;) \\longrightarrow\n\\\\\n& \\qquad \\qquad msg(u, parent_u) := (parent_u,\\, vertex\\_count_u)\\; \n\\\\\n& \\qquad \\qquad \\lVert\\;\\; state_u := complete\\;\n\\end{align*}\n\nI will refer to the actions as $A1$, $A2$ and $A3$ respectively. The action $A3$ in my definition of \\texttt{Gossip} is similar to that in Sivilotti 6.5, except I also check that for all incoming messages which defined $u$ as their parent the count $c$ is set to $-1$. That is, I make sure that all relevant counts were added to $vertex\\_count_u$ before reporting it to the parent process.\n\nNote that both \\texttt{Initiator} and \\texttt{Gossip} programs start out with $vertex\\_count$ equal to $1$ because they automatically count themselves as a vertex.\n\n\\paragraph{b)} The proof for termination of diffusing computations can be found in Sivilotti 6.6. My algorithm is a modified version of the gossip algorithm Sivilotti uses.\n\n\\paragraph{c)} To prove that $I.vertex\\_count$ has the correct counts at termination, we can define and prove another safety property: $\\textrm{\\textbf{invariant}} (done \\Rightarrow I.vertex\\_count = C)$ where $C$ is the true vertex count in the graph.\n\nTo prove that this new safety property holds I will extend the proof given in Sivilotti 6.6. There, he defines $T_1$ and $T_2$, proving the invariant that both are trees. We also know that the diffusing computation terminates, so eventually the \"gossip\" reaches all of the vertices, and each vertex eventually receives counts from its children and reports its count to its parent. Similar to Sivilotti 6.6.1, action $A3$ can delete a vertex from $T_2$, and it can be shown by contradiction that the deleted vertex must be a leaf in $T_2$.\n\nWe can show that when $T_2$ shrinks back to the state where it just contains $I$, $I.vertex\\_count$ will be the correct count, by considering subtrees of $T_2$, when $T_2$ has all of the vertices from the original graph (i.e. right before it begins to shrink).\n\nWe know that $done$ will only hold after $I$ has received messages from all of its neighbours and action $I2$ has been executed on every incoming message, for which $I$ is the parent of the sender. This means $I$ would have taken the counts from these messages and added them to its $vertex\\_count$. Since $vertex\\_count$ starts out as $1$, after $done$ holds $I$ will hold the correct counts given that each child of $I$ in $T_2$ has reported the correct counts for the subtree this child is a root of.\n\nWe can show that the same condition applies to all vertices in $T_2$ that are a root of some subtree of $T_2$, apart from leaf vertices of $T_2$. This is true because action $A3$ only sends out a message once it received a message from all of its non-parent neighbours and the messages have been processed, that is $A_2$ has been applied to all incoming messages for which the current vertex is the parent of the sender. Again, if all children have reported the correct counts, the root of the subtree will have the correct $vertex\\_count_u$ and report it to its parent.\n\nFinally, the leaf vertices in $T_2$ would have no children by definition of $T_2$ - if they would have children they would not be leaves when $T_2$ contains all vertices from the original graph. This means that action $A2$ will never run and will never increment $vertex\\_count_u$, so its value will just remain $1$. If the leaf has no other neighbours but the parent, it will simply report $1$ to the parent, which is the correct count since the subtree only has 1 vertex. If the leaf node has other neighbours, we know that a diffusing computation eventually reaches all vertices, so eventually current vertex will receive a message from all of its non-parent neighbours and finally report $1$ to its parent.\n\nFrom 3 points above we can conclude that $I.vertex\\_count$ would have the correct counts since each of its children would report the counts of its respective subtrees, and these counts will be correct given every subtree under a particular child reports the correct counts. The base case is a leaf node, and we've shown that a leaf node would report a correct count of $1$. Building up, this shows that every subtree would report the correct count, hence $I$ would receive the correct counts from its children.\n\n\\section*{Problem 2}\n\n\\paragraph{a)} To show that the provided property is required, let's consider a modified version of Lamport's mutual exclusion algorithm where the agent just needs to receive a message from every other agent after sending the request, but the logical time on these messages need not be larger than requested access time $t_i$. We will show that this modified version does not satisfy the safety property.\n\nConsider the execution path where processes $P_1$ and $P_2$ have already communicated before, and $P_1$ has successfully entered the critical section (CS). In the beginning of timeline below, $P_1$ is just about to leave the CS and notify $P_2$ about it. As you can see at logical time $7$ on $P_2$, its queue still contains that older request from $P_1$.\n\n\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{hw5_problem2}\n\n\\paragraph{Explaining the diagram:} At time $7$ $P_2$ sends out a message requesting access to the critical section. At time $8$, it receives a message from $P_1$ saying that it has left the critical section. In our modified version of Lamport's algorithm, even though the timestamp on the message from $P_1$ is $5$ and hence smaller than local logical time, we still treat it as an $ACK$ and enter the critical section.\n\nProcess $P_1$ sends out its own request for access at local time $6$, and waits for any messages from $P_2$. At local time $8$, it receives a request $<P2, 7>$ from $P_2$, but the time of the request is larger than $P_1$'s own request. $P_2$'s request goes to the end of the queue. Now, $P_1$ has received a message from $P_2$ and its request is in the head of the queue - hence it enters the CS, by our modified version of Lamport's algorithm.\n\nNow we have 2 processes in the critical section at the same time, so using \\textit{any} messages as ACKs instead of messages with larger logical clock value is not sufficient.\n\n\\pagebreak\n\n\\paragraph{b)} Consider the following timeline:\n\n\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{hw5_problem2_b}\n\nAt the beginning of the timeline, we assume that all processes have already communicated before. $P_2$ is in the CS, $P_1$ is waiting for $P_2$ to leave the CS and $P_3$ simply maintains a queue without requesting access to CS. Once $P_2$ exits CS, it broadcasts a release message which gets delivered to $P_1$ sooner than to $P_3$. Since $P_1$'s request is now at the head of the queue and its request timestamp is smaller than all known times, it will now enter the CS. This can happen before $P_3$ will receive the release message, so $P_1$ will be in CS without being at the head of the queue for all agents.\n\\\\\n\nThis cannot happen when there are no messages in transit. By definition of Lamport's algorithm, if there are no messages in transit, either all agents are in the non-critical section (NC) of code or there is a single agent that is currently inside CS with zero or more agents waiting for it to exit the CS. In the first case, since all agents are in NC, there is no reason for them to communicate so there are no messages in transit. In the second case, all agents have already exchanged requests and ACKs, and now are just waiting for the agent inside CS to exit and notify all other agents so next process can enter it.\n\nWe're interested in the second case. Let's denote the process that's currently in CS as $P_{CS}$. $P_{CS}$ could've entered CS by either being the first process to request access and receive ACKs from all other agents OR by being the second process in the queue and popping the head of the queue after the previous process exits CS.\n\nWe know that there are no requests with timestamps lower than $P_{CS}$'s request because all messages were already delivered and there are no messages in transit. If $P_{CS}$ was the very first process to request access, by now it would have received ACKs from all other agents and will now be in CS. At the same time, we know that it's at the head of every other agent's queue because it has the smallest request time and all messages have been delivered.\n\nIf $P_{CS}$ was the second (earliest) process to request access and have now popped the head of the queue to become first, it must have received a release message from the previous process in CS. Since no messages are in transit, all other processes would have also received the same notification and popped the previous process of their queues. Now, $P_{CS}$ has the smallest request time and all other agents have $P_{CS}$'s request on their queue since all messages were delivered. This means $P_{CS}$ is at the head of the queue for every agent when it enters CS.\n\nTherefore, if there are no messages in transit and $P_{CS}$ is inside the CS, $P_{CS}$'s request must be at the head of queue for all agents.\n\n\\section*{Problem 3}\n\nDescription of the problem suggests that the algorithm does not involve agents sending ACKs back when they receive a request, so I will assume that this is indeed the case. Also assuming there is only one FIFO channel (in each direction) between any 2 agents.\n\nThe question doesn't bound the value of $\\tau$ above, so I will assume that $\\tau$ is finite, i.e. \\texttt{my-time} will be broadcast eventually. The question also suggests that no release or request messages are sent at time $n*\\tau$ - I will assume that request and release messages are timestamped with the time at which they have been sent, and not at the time they have been queued. That is, if the request message was about to be sent but it was time to broadcast \\texttt{my-time}, the timestamp on the request message once its sent will be larger than reported \\texttt{my-time}.\n\n\\paragraph{Proving safety:} We need to show that multiple agents cannot be in CS at the same time. We can prove that this is the case by contradiction.\n\nAssume we have 2 agents, $P_1$ and $P_2$ in CS at the same time. For this to be true, their corresponding request times $z_1$ and $z_2$ must be the smallest timestamps in their lists $L$.\n\nAssume, wlog, that $z_1 < z_2$. For $P_2$ to be in CS, it must be true that $z_2 < \\textrm{REMOTE\\_TIMES}[P_1]$. Since message channels are FIFO and $\\textrm{REMOTE\\_TIMES}$ is updated on any received message, $P_1$'s request must be in $P_2$'s list $L$, and hence $P_2$ will know $z_1 < z_2$ and cannot enter the CS. This is a contradiction.\n\n\\paragraph{Proving progress:} For a particular agent $P_i$ in $TRY$ state, as our metric we can use the number of elements in the array $P_i.\\textrm{REMOTE\\_TIMES}$ that have known time values $z_j$ smaller than $P_i$'s request time $z_i$. Clearly this value is bound below by $0$, and since the clocks on every agent can only tick forward, this number is guaranteed to not increase.\n\nTo show  that the metric is guaranteed to decrease we can consider some agent $P_j$ such that\\linebreak[4]\\mbox{$P_i.\\textrm{REMOTE\\_TIMES}[P_j] < z_i$}. By the definition of our algorithm, the clock on each agent always ticks forward and every agent transmits its local time at some interval $\\tau$. This means that eventually $P_i$ will receive a message from $P_j$ with timestamp greater than $z_i$, decreasing our metric by 1. This execution will be repeated until our metric reaches zero.\n\nWe can also show that eventually any process in $TRY$ state will receive a release message for all the requests in its $L$ that have timestamps $z_j$ smaller than $z_i$, hence allowing it to enter CS. If $z_i$ is not the smallest timestamp in $L$ and there are no messages in transit, there must exist some other agent $P_k$ with request timestamp $z_k$ such that $z_k < z_i$. Note that our chosen metric for $P_k$ will eventually decrease to $0$ allowing it to enter CS. It will later leave CS and broadcast a release message. This can be repeated for all agents with request timestamps smaller than $z_i$ until we reach a state where it is $P_i$'s turn to enter CS.\n\nRemark: If there is a significant time difference between $P_i$ and $P_k$ (e.g. $P_i$'s time is $250$ seconds greater than $P_k$'s time) it is true that $P_k$ can enter and exit CS multiple times before $P_i$ gets it turn, but eventually the time on $P_k$ will exceed $z_i$ and $P_i$ will be able to enter CS.\n\nTherefore the safety and progress properties are satisfied and the algorithm is correct.\n\n\\end{document}", "meta": {"hexsha": "d8aec0e8539c02ded471c6122d4c3787db09fa41", "size": 16878, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Timur_Kuzhagaliyev_CS142_HW5.tex", "max_stars_repo_name": "TimboKZ/caltech-cs142", "max_stars_repo_head_hexsha": "819f5491bd71b6cc4cfe3b73df9dfe10c9814f48", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-01-11T04:21:37.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-11T04:21:37.000Z", "max_issues_repo_path": "Timur_Kuzhagaliyev_CS142_HW5.tex", "max_issues_repo_name": "TimboKZ/caltech-cs142", "max_issues_repo_head_hexsha": "819f5491bd71b6cc4cfe3b73df9dfe10c9814f48", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Timur_Kuzhagaliyev_CS142_HW5.tex", "max_forks_repo_name": "TimboKZ/caltech-cs142", "max_forks_repo_head_hexsha": "819f5491bd71b6cc4cfe3b73df9dfe10c9814f48", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 98.1279069767, "max_line_length": 710, "alphanum_fraction": 0.7401943358, "num_tokens": 4637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5774953506426082, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.40191270058962636}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Monday\\\\ 2020-4-27, \\\\ compiled \\\\ \\today}\n\n% We discussed the Fluctuation Dissipation Theorem last time:\n% we have qualitative arguments, if by equipartition each DoF has energy \\(1/2 k_B T\\) and it is dissipative there must be some forcing mechanism.\n\nLet us consider a lossy harmonic oscillator, whose equation of motion is \n%\n\\begin{align}\nm_0 \\ddot{x} + m_0 \\gamma_0 \\dot{x} + k_0 x = F\n\\,,\n\\end{align}\n%\nso in Fourier space the force can be expressed as \n%\n\\begin{align}\nF(\\omega ) &= m_0 \\qty(-\\omega^2 - i \\omega \\gamma_0 + \\frac{k_0}{m_0 }) x(\\omega )  \\\\\n&= \\underbrace{\\frac{i m_0 }{\\omega} \\qty(-\\omega^2 - i \\omega \\gamma_0 + \\omega_0^2)}_{Z(\\omega )}\n\\dot{x}(\\omega )\n\\,,\n\\end{align}\n%\nwhich means that we can write the impedance as \n%\n\\begin{align}\nZ(\\omega ) = \\underbrace{m_0 \\gamma_0}_{\\Re{Z}} + i \\frac{m_0}{\\omega } \\qty(\\omega_0^2 - \\omega^2)\n\\,.\n\\end{align}\n%\n\nSo, the thermal noise PSD of the reverse-engineered signal will be  \n%\n\\begin{align}\nS_x (\\omega ) = \\frac{4 k_B T}{\\omega^2}\n\\frac{m_0 \\gamma_0 }{m_0^2 \\gamma_0^2 + \n\\qty( \\frac{m_0}{\\omega } \\qty(\\omega_0^2 - \\omega^2))^2}\n= S_F (\\omega ) \\abs{H_{F \\to x} (\\omega )}^2\n\\,.\n\\end{align}\n\nFor \\textbf{structural damping} \\(\\delta \\), we have \\(\\Re{Z(\\omega )} = m_0 \\delta \\omega_0^2/ \\omega \\), so the force PSD is \n%\n\\begin{align}\nS_F (\\omega ) =4 k_B T m_0 \\delta \\frac{\\omega_0^2}{\\omega }\n\\,.\n\\end{align}\n\n\\subsubsection{Thermal noise for the resonant bar}\n\nWhat does the noise look like in the bar-transducer system?\nWe need to compare the generic \\(Z(\\omega )\\) we wrote for the harmonic oscillator to the transfer function we found for the fundamental mode of the resonant bar, \\(H_{h \\to \\xi_0  } (\\omega )\\): we find that they are related by \n%\n\\begin{align}\nH_{h \\to \\xi_0 } (\\omega ) = - \\frac{2L}{\\pi^2} m_0 \\omega i \\frac{1}{Z(\\omega )}\n\\,,\n\\end{align}\n%\nwhich, together with the fact that \\(\\Re{Z} = m_0 \\gamma_0 \\), means that the noise PSD for the fundamental mode will read \n%\n\\begin{align}\nS_{\\xi_0 } \n&= \\frac{4k_BT}{\\omega^2} \\frac{\\Re{Z(\\omega )}}{\\abs{Z(\\omega )}^2}  \n= \\frac{4k_BT}{\\omega^2 } \\frac{m_0 \\gamma_0 }{\\abs{ \\frac{2L}{\\pi^2} m_0 \\omega_0  \\frac{1}{H}}^2}\n\\\\\n&= \\frac{4 k_B T \\gamma_0 }{m_0 \\omega^{4}} \n\\qty(\\frac{\\pi^2}{2L})^2 \\abs{H_{h \\to \\xi_0 } (\\omega )}^2\n\\,.\n\\end{align}\n\nIf we try to reverse-engineer the original GW input, we must divide by the absolute value of the transfer function, which cancels out: so, we find \n%\n\\begin{align}\nS_{h, \\text{th}} = \\frac{S_{\\xi_0 }}{\\abs{H_{h \\to \\xi_0 } (\\omega )}^2}\n= \\frac{4 k_B T \\gamma_0 }{m_0 \\omega^{4}} \n\\qty(\\frac{\\pi^2}{2L})^2\n= \\frac{\\pi}{Q_0 } \\frac{k_B T}{M v_s^2} \\frac{f_0^3}{f^{4}}\n\\,,\n\\end{align}\n%\nwhere we used the relations \\(\\gamma_0 = \\omega_0 / Q_0 \\), \\(m_0 = M / 2\\) and \\(L = \\pi v_s / \\omega_0 \\).\nSo, a large quality factor reduces thermal noise.\n\n\\subsubsection{Thermal noise for the transducer}\n\nTo treat the thermal noise for the bar-transducer system, we assume that both of them are at equilibrium at a certain temperature \\(T\\), but their damping factors are independent: \n%\n\\begin{align}\nS_{F_0 } = 4 k_B T m_0 \\gamma_0 \\qquad \\text{and} \\qquad\nS_{F_t} = 4 k_B T m_t \\gamma_{t}\n\\,.\n\\end{align}\n\nThe displacement of the transducer due to the two stochastic forces is given by \n%\n\\begin{align}\n\\xi_{t} (\\omega ) = \\frac{\\pi^2}{2L} \\frac{H_{h \\to \\xi_{t} } (\\omega )}{\\omega^2} \\qty(\\frac{F_0 }{m_0 } - \\frac{F_t (\\omega )}{m_t} \\frac{\\omega^2 - \\omega_0^2 + i \\omega \\gamma_0 }{\\omega_0^2})\n\\,.\n\\end{align}\n\nUsing these two relations we can compute the transducer's power spectral density: \n%\n\\begin{align}\nS_{\\xi_{t}} (\\omega ) = \\frac{\\pi^{4}}{4 L^{2}} \n\\frac{\\abs{H_{h \\to \\xi_{t}}^2} (\\omega )}{\\omega^{4}} \n4 k_B T \\qty(\\frac{\\gamma_0}{m_0 } + \\frac{\\gamma_{t}}{m_t} \\frac{(\\omega^2- \\omega_0^2)^2 + \\omega \\gamma_0^2}{\\omega_0^2})\n\\,.\n\\end{align}\n\n\\todo[inline]{Missing square modulus of the transfer function in the notes! See \\cite[eq.\\ 8.134]{maggioreGravitationalWavesVolume2007}.}\n\nIn terms of the input, this will look like: \n%\n\\begin{align}\nS _{h, \\text{th}} = \\pi \\frac{k_B T}{M v_s^2} \n\\frac{f_0^3}{f^{4}} \\qty( \\frac{1}{Q_0} + \\frac{1}{\\mu Q_t} \\frac{\\qty(f^2-f_0^2)^2 + \\qty(f f_0 / Q_0 )^2}{f_0^{4}})\n\\,.\n\\end{align}\n\nWhile \\(Q_0 \\) is quite large, both \\(Q_t\\) and \\(\\mu \\) are rather small: this might seem like a big issue, since it means that the thermal noise contribution from the transducer is quite large. \n\nFortunately, near resonance (\\(f \\approx f_0 \\)) the first term in the numerator goes to zero; while the second term always stays small since it is suppressed by a factor \\(Q_0^{-2}\\).\nThis means that, while far from resonance the thermal noise from the transducer dominates, near resonance it is quite small and the thermal noise from the bar dominates.\n% The noise by the transducer is very small at resonance, the noise of the bar does not have features there: the PSD is \n\n% \\todo[inline]{Missing bit\\dots still to understand}\nA qualitative explanation for this behavior is that since the response of the system is resonant even an oscillation with a large amplitude corresponds to a small GW amplitude when we reconstruct the signal. \n\n\\subsection{Readout noise}\n\nWithout getting into the specifics of the electronic setup, we try to construct a system so that small displacements of the bar are mapped linearly to voltages which we can measure: \n%\n\\begin{align}\nV _{\\text{out}} = \\alpha \\xi_{t}\n\\,,\n\\end{align}\n%\nand, since the PSD is 2-homogeneous, if we have some readout noise whose PSD is \\(S_{V _{\\text{out}}}\\), then the effective PSD of the noise for the reconstructed displacement signal will be \n%\n\\begin{align}\nS_{\\xi_{t}} = \\frac{1}{\\alpha^2} S_{V _{\\text{out}}}\n\\,.\n\\end{align}\n\nThis means that we can interpret the readout noise as an effective displacement. If we go further and consider the effective GW signal modification, we will see \n%\n\\begin{align}\nS_{h, \\text{ro}} = \\frac{1}{\\abs{H_{h \\to \\xi_{t}}}^2}\nS_{\\xi_{t}} = \\frac{1}{\\abs{H_{h \\to \\xi_{t}}}^2 \\alpha^2} S_{V _{\\text{out}}}\n\\,.\n\\end{align}\n\nUsually, the spectral shape of the readout noise is quite uniform, but since the transfer function is featured the effective GW PSD due to readout will be featured as well. \n\n\\subsection{Effective temperature}\n\nWe want to find out how much energy the GW must carry in order to be visible above the noise. \n\nFor \\textbf{thermal noise}, we have seen that the characteristic time for the decay of the decay of a fundamental mode oscillation is \\(\\tau_0 = 1/ \\gamma_0 = Q_0 / \\omega_0 \\), of the order of several minutes. \nThis characterizes \\emph{all} the mode's interactions with the thermal bath, so the time it takes for the bath to spoil the oscillation is \\(\\tau_0 \\) as well: this means that, while we might naïvely expect the noise threshold for the detection of a GW to be \\(E_{GW} \\geq k_B T\\), it is in fact much lower. \nSpecifically, if \\(\\Delta t\\) is our sampling time, then the noise threshold is actually \\(E_{GW} \\geq k_B T \\Delta t / \\tau_0 \\). \n\nAs for the \\textbf{readout noise}, if our bandwidth (the inverse of the sampling time) is \\(\\Delta f\\), then the variance of the readout noise in terms of displacement of the transducer can be recovered from the PSD by\n%\n\\begin{align}\n\\expval{\\xi_{t}^2} &= \\int_{f_0 - \\Delta f / 2}^{f_0 + \\Delta f / 2}\nS_{\\xi_{t} , \\text{ro}} \\dd{f} \\sim S_{\\xi_{t} , \\text{ro}} \\Delta f\n\\,,\n\\end{align}\n%\nwhich corresponds to an energy of \\(E_{\\text{ro}} \\sim m_t \\omega_0 \\expval{\\xi_{t}^2} \\sim m_t \\omega_0  S_{\\xi_{t} , \\text{ro}} \\Delta f\\).\n\nThe interesting thing to note is that the dependence of the thermal noise threshold energy on the sampling time is \\textbf{direct} (if we sample for a long time the bath has a long time to interact with the oscillator), while the corresponding quantity for the readout noise has an \\textbf{inverse dependence} on \\(\\Delta t\\) (sampling very fast is error-prone since we are exposed to more high-frequency noise): \n%\n\\begin{align}\n\\Delta E _{\\text{min}} \\sim k_B T \\frac{\\Delta t}{\\tau_0 }\n+ \\frac{m_t \\omega_0 S_{\\xi_{t}, \\text{ro}}}{\\Delta t}\n\\,.\n\\end{align}\n\nWe need to trade off these two contributions; the minimum can be found by differentiating and it comes out to be \n%\n\\begin{align}\n\\Delta f _{\\text{opt}} = \\frac{1}{\\Delta t _{\\text{opt}}} \\approx\n\\pi \\frac{f_0 }{Q \\sqrt{\\Gamma }}\n\\qquad \\text{where} \\qquad\n\\Gamma = \\frac{m_t \\omega_0^3  S_{\\xi_t, \\text{ro}}}{4Q k_B T} \n\\,.\n\\end{align}\n%\n\nAn important distinction to make is the one between the useful bandwidth \\(\\Delta f _{\\text{opt}}\\), which is quite large (tens of Hertz), and the width of the resonance peak \\emph{of the transfer function}, which is \\(\\Delta f _{\\text{res}} \\sim f_0 / Q \\sim \\SI{1}{mHz}\\). \nThe detector's actual resonance peaks are \\textbf{broad}, with a bandwidth comparable to \\(\\Delta f _{\\text{opt}}\\).\n\nAt the optimal sampling rate, the two contributions to the \\(\\Delta E\\) are equal, therefore we have \n%\n\\begin{align}\n\\Delta E _{\\text{opt}} \\sim 2 k_B T \\frac{\\Delta t _{\\text{opt}}}{\\tau_0 }\n\\sim 2 k_B T \\frac{\\omega_0}{Q \\Delta f} \n= k_B \\underbrace{T \\frac{4 \\pi f_0 }{Q \\Delta f}}_{T _{\\text{eff}}}\n\\,,\n\\end{align}\n%\nwhich can be interpreted as a new effective temperature at which the oscillator is immersed: substituting in we can find that it is given by \n%\n\\begin{align}\nT _{\\text{eff}} \\sim 4 \\sqrt{\\Gamma } T\n\\,,\n\\end{align}\n%\nwhich can be much lower than the real temperature of the object, since \\(\\Gamma \\) can be made to be of the order \\num{e-8} to \\num{e-9}: this means that the effective temperature can be three orders of magnitude lower than the thermodynamic one.\n\nThe definitive formula for the sum of these contributions can be found in Maggiore \\cite[eq.\\ 8.150]{maggioreGravitationalWavesVolume2007}; it is interesting to compare the shape of the PSD at varying values of \\(\\Gamma \\): if it is rather high (\\(\\sim \\num{e-7}\\)) then the PSD is quite high as well with two conspicuous drops at \\(\\omega_0 \\pm \\omega_{p}\\). Here, the transducer thermal noise dominates almost everywhere.\n\nIf \\(\\Gamma \\) becomes lower, of the order of \\num{e-9}, then the PSD becomes uniformly low in the range \\([\\omega_0 - \\omega_{p}, \\omega_0 + \\omega_{p}]\\).\n\n\\section{Gravitational Wave Interferometry}\n\n\\subsection{Mach-Zender interferometer}\n\nThe setup here is the following: the laser impacts onto a first beamsplitter, is split onto two orthogonal paths which are made to converge onto a second beamsplitter through two mirrors. After this second beamsplitter, the signal is measured. Depending on the phase, the interference is either constructive or destructive at the second beamsplitter. \n\nThe laser's electric field will be given by\n%\n\\begin{align}\n\\vec{E} _{\\text{in}} = \\vec{E}_{0} \\exp(-i \\qty(\\omega_{l} t - k_l t))\n\\,,\n\\end{align}\n%\nwhere the subscript \\(l\\) means ``laser'', we include it in order to distinguish these parameters from the GW ones.\n\nIn general: \n\\begin{enumerate}\n    \\item at reflection the beam picks up a phase \\(\\pi \\);\n    \\item at transmission the beam picks up no phase;\n    \\item between the two paths there is a phase difference due to their different lengths: \\(\\Delta \\phi \\). \n\\end{enumerate}\n\nSo, the fields incoming to the second beamsplitter are:\n%\n\\begin{align}\nE_T = \\frac{E _{\\text{in}}}{\\sqrt{2}} e^{i \\pi }\n\\qquad \\text{and} \\qquad\nE_R = \\frac{E _{\\text{in}}}{\\sqrt{2}} e^{i \\Delta \\phi } \n\\,.\n\\end{align}\n\nAt the second beamsplitter there are two outputs: the outgoing fields are \n%\n\\begin{align}\nE _{\\text{out, }1} &= \\frac{E_{T}}{\\sqrt{2}} e^{i \\pi }\n+ \\frac{E_{R}}{\\sqrt{2}} = \\frac{E_{\\text{in}}}{2} \\qty(1 + e^{i \\Delta \\phi })  \\\\\nE _{\\text{out, }2} &= \\frac{E_{T}}{\\sqrt{2}}\n+ \\frac{E_{R}}{\\sqrt{2}} e^{i \\pi } = \\frac{E_{\\text{in}}}{2} \\qty(- 1 - e^{i \\Delta \\phi }) \n\\,,\n\\end{align}\n%\nso the initial power is multiplied by \\((1 + \\cos( \\Delta \\phi )) / 2 \\). \nSo, is energy not conserved? This output is the same on both ends of the beamsplitter, and these two do not sum to the initial power.\n\nThis result is due to an oversight: the phase of \\(\\pi \\) is actually picked up only if the index of refraction increases along the path of the beam. Correcting for this, we find \n%\n\\begin{align}\nE _{\\text{out, }2}= \\frac{E_{\\text{in}}}{2} \\qty(-1 + e^{i \\Delta \\phi })\n\\,,\n\\end{align}\n%\nso \n%\n\\begin{align}\n\\abs{E _{\\text{out, }2}}^2 = \\frac{\\abs{E _{\\text{in}}}^2}{2} \\qty(1 - \\cos(\\Delta \\phi))\n\\,,\n\\end{align}\n%\nso we recover energy conservation: \\(\\abs{E _{\\text{out, }1}}^2 + \\abs{E _{\\text{out, }2}}^2 = \\abs{E _{\\text{in}}}^2\\).\n\n\\subsection{Michelson-Morley interferometer}\n\nNow the setup is different: the first and second beamsplitters are the same one, and the mirrors reflect the laser directly backwards. \n\nThe electric fields in the path from the beamsplitter to either mirror are denoted as \\(E_x\\) and \\(E_y\\); they are given by \n%\n\\begin{align}\nE_{x} &= \\frac{E_0 }{\\sqrt{2} \\sqrt{2}}\n\\exp(i \\qty(kx - \\omega_{l}t + \\phi_{x})) \\\\\nE_{y} &= \\frac{E_0 }{\\sqrt{2} \\sqrt{2}}\n\\exp(i \\qty(ky - \\omega_{l}t + \\phi_{y}))\n\\,,\n\\end{align}\n%\nwhere the double \\(\\sqrt{2}\\) factor is due to the fact that each beam goes through the beamsplitter twice; while the factors \\(\\phi_{x, y}\\) are the phases picked up upon reflection on each side. \n\nThe output electric field (for either output of the beamsplitter --- we will distinguish between them by varying \\(\\phi \\)) is given by \n%\n\\begin{align}\nE _{\\text{out}} = E_{x} + E_{y}\n= \\frac{E_0}{2} \\qty(\\exp(i \\qty(kx - \\omega_{l}t + \\phi_{x})) + \\exp(i \\qty(ky - \\omega_{l}t + \\phi_{y})))\n\\,,\n\\end{align}\n%\nso the output intensity is \n%\n\\begin{align}\nI _{\\text{out}} &= \\abs{E _{\\text{out}}}^2 \n= \\frac{E_0^2}{4} \\qty(2 + \\Re{\\exp(i(k(x-y) - (\\phi_{x} - \\phi_{y}) ))})  \\\\\n&= \\frac{E_0^2}{2} \\qty(1 + \\cos(k(x-y) + (\\phi_{x} - \\phi_{y})))\n\\,.\n\\end{align}\n\nNow, for output 1 (perpendicular to the original laser beam) we have \\(\\phi_{x1} = \\pi \\) and \\(\\phi_{y1} = 2\\pi \\), which can be gathered by counting the number of times the \\(x\\) (\\(y\\)) beam is reflected, and adding a \\(\\pi \\) for each. \nSimilarly, for output 2 we have \\(\\phi_{x2} = \\pi \\) and \\(\\phi_{y2} = 3 \\pi \\). \nSo, we have \\(\\Delta \\phi_{1} = -\\pi \\) and \\(\\Delta \\phi_{2} = - 2 \\pi \\). \n\nPlugging this in, and using the fact that \\(\\cos(x + \\pi ) = - \\cos(x)\\), we find \n%\n\\begin{align}\nI _{\\text{out, 1}} &= \\frac{E_0^2}{2} \\qty(1 - \\cos(k(x-y))) = E_0^2 \\sin^2 \\qty(\\frac{k}{2} (x-y)) \\\\\nI _{\\text{out, 2}} &= \\frac{E_0^2}{2} \\qty(1 + \\cos(k(x-y))) \n= E_0^2 \\sin^2 \\qty(\\frac{k}{2} (x-y) + \\frac{\\pi}{2})\n\\,.\n\\end{align}\n\nSo, both of the outputs heavily depend on the path length difference between the two beams. \n\n\\subsection{GW interactions in the detector frame}\n\nIn the detector frame we can treat the GW as a Newtonian force acting on the mirrors, and we can compute it using the TT-gauge perturbation \\(h_{xx}^{TT} = h_0 \\cos(\\omega_{GW}t)\\) since the Riemann tensor is invariant in linearized gravity:\n%\n\\begin{align}\nF_{x} \\approx \\frac{m}{2} x_0 \\ddot{h}_{xx}^{TT} \n\\,,\n\\end{align}\n%\nsince the perturbation is really small, we can treat \\(x_0 \\) as a constant.\nThis means that the length of the arm changes according to the differential equation\n%\n\\begin{align}\n\\ddot{x} = \\frac{1}{2} x_0 \\ddot{h}^{TT}_{xx}\n\\,.\n\\end{align}\n\nThis only holds in the short arm approximation: \\(x \\ll \\lambda_{GW}\\), which means \\(f_{GW} \\ll c/ L  \\approx \\SI{100}{kHz} (L / \\SI{3}{km} )\\) --- fortunately this is not a great constraint, since modern GW interferometers are only sensitive up to a few \\SI{}{kHz} anyway. \n\nLet us consider a plus-polarized GW travelling along the \\(z\\) axis, and let us assume that the beamsplitter is the origin. \nThen, let us analyze the motion of the two test masses which are in free-fall: the two mirrors, one for each arm. Their positions will be, respectively, \\((x_{XTM}, y_{XTM}, z_{XTM})\\) and \\((x_{YTM}, y_{YTM}, z_{YTM})\\). Because of the polarization of the wave, the only coordinates which will evolve in time will be \n%\n\\begin{align}\nx_{XTM} (t ) &= L_x + \\frac{h_0 L_x}{2} \\cos(\\omega_{GW} t) \\\\\ny_{YTM} (t ) &= L_y - \\frac{h_0 L_y}{2} \\cos(\\omega_{GW} t)\n\\,.\n\\end{align}\n%\n\n\nIf we insert the displacement for the mirrors, assuming \\(L_x \\sim L_y \\sim L\\) we find \n%\n\\begin{align}\nI _{\\text{out}} \n&= E_0^2 \\sin^2(k(x-y))  \\\\\n&= E_0^2 \\sin^2 \\qty(k \\qty[L_x + \\frac{h_0 L_x}{2} \\cos(\\omega_{GW} t) - L_y + \\frac{h_0 L_y}{2} \\cos(\\omega_{GW} t)]) \\\\\n&= E_0^2 \\sin^2 \\qty(k \\qty(L_x - L_y + h_0 L \\cos(\\omega_{GW} t)))\n\\,.\n\\end{align}\n\nOne might think that we should not be able to see any effect, since the GW also stretches the wavelength of the light: this is not the case, since each wavefront will still be travelling at \\(c\\) and so its travel time will change for a change in the spatial components of the metric. \n\nHowever, this detector-frame approach is not great, since it neglects all time-of-flight effects. Let us consider the problem in the TT-gauge. \n\n\\end{document}\n", "meta": {"hexsha": "f251fafd8579e161fdaf68730c33a3c1022e377b", "size": 17023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/gravitational_physics/apr27.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/gravitational_physics/apr27.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/gravitational_physics/apr27.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 45.884097035, "max_line_length": 423, "alphanum_fraction": 0.6765552488, "num_tokens": 5722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.40191269978571836}}
{"text": "% !TEX root = ./bursty_transcription.tex\n\\section{Bursty promoter models - generating function solutions and numerics}\n\\label{sec:gen_fcn_appdx}\n\n\\subsection{Constitutive promoter with bursts}\n\n\\subsubsection{From master equation to generating function}\n\nThe objective of this section is to write down the steady-state mRNA\ndistribution for model 5 in Figure~\\ref{fig2:constit_cartoons}. Our claim is\nthat this model is rich enough that it can capture the expression pattern of\nbacterial constitutive promoters. Figure~\\ref{figS1:bursty_one_state} shows two\ndifferent schematic representations of the model.\nFigure~\\ref{figS1:bursty_one_state}(A) shows the promoter cartoon model with\nburst initiation rate $k_i$, mRNA degradation rate $\\gamma$, and mean burst size\n$b$. For our derivation of the chemical master equation we will focus more on\nFigure~\\ref{figS1:bursty_one_state}(B). This representation is intended to\nhighlight that bursty gene expression allows transitions between mRNA count $m$\nand $m'$ even with $m - m' > 1$.\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics{../figures/si/figS0X_bursty_states.pdf}\n\\caption{\n\\textbf{Bursty transcription for unregulated promoter.}\n(A) Schematic of the one-state bursty transcription model. Rate $k_i$ is the\nbursty initiation rate, $\\gamma$ is the mRNA degradation rate, and $b$ is the\nmean burst size. (B) Schematic depiction of the mRNA count state transitions.\nThe model in (A) allows for transitions of $> 1$ mRNA counts with probability\n$G_{m-m'}$, where the state jumps from having $m'$ mRNA to having $m$ mRNA in a\nsingle burst of gene expression.}\n\\label{figS1:bursty_one_state}\n\\end{figure}\n\nTo derive the master equation we begin by considering the possible state\ntransitions to ``enter'' state $m$. There are two possible paths to jump from an\nmRNA count $m' \\neq m$ to a state $m$ in a small time window $\\Delta t$:\n\\begin{enumerate}\n        \\item By degradation of a single mRNA, jumping from $m+1$ to $m$.\n        \\item By producing $m-m'$ mRNA for $m' \\in \\{0, 1, \\ldots, m-1\\}$.\n\\end{enumerate}\nFor the ``exit'' states from $m$ into $m' \\neq m$ during a small time window\n$\\Delta t$ we also have two possibilities:\n\\begin{enumerate}\n        \\item By degradation of a single mRNA, jumping from $m$ to $m-1$.\n        \\item By producing $m'-m$ mRNA for $m'-m \\in \\{1, 2, \\ldots\\}$.\n\\end{enumerate}\nThis implies that the probability of having $m$ mRNA at time $t + \\Delta t$ can\nbe written as\n\\begin{equation}\n\\begin{split}\np(m, t + \\Delta t) = &p(m, t)\n+ \\overbrace{\\gamma \\Delta t (m + 1) p(m + 1, t)}^{m + 1 \\rightarrow m}\n- \\overbrace{\\gamma \\Delta t m p(m, t)}^{m \\rightarrow m - 1} \\\\\n&+ \\overbrace{k_i \\Delta t \\sum_{m'=0}^{m-1} G_{m-m'} p(m', t)}^\n{m'\\in \\{0, 1, \\ldots m-1\\} \\rightarrow m}\n- \\overbrace{k_i \\Delta t \\sum_{m'=m + 1}^{\\infty} G_{m'-m} p(m, t)}^\n{m \\rightarrow m'\\in \\{m+1, m+2, \\ldots\\}},\n\\end{split}\n\\label{eq:si_master_deltat}\n\\end{equation}\nwhere we indicate $G_{m'-m}$ as the probability of having a burst of size\n$m'-m$, i.e. when the number of mRNAs jump from $m$ to $m' > m$ due to a single\nmRNA transcription burst. We suggestively use the letter $G$ as we will assume\nthat these bursts sizes are geometrically distributed with parameter $\\theta$.\nThis is written as\n\\begin{equation}\nG_{k} = \\theta (1 - \\theta)^k\\; \\text{for } k \\in \\{0, 1, 2, \\ldots \\}.\n\\end{equation}\nIn Section~\\ref{sec:beyond_means} of the main text we derive this functional\nform for the burst size distribution. An intuitive way to think about it is that\nfor transcription initiation events that take place instantaneously there are\ntwo competing possibilities: Producing another mRNA with probability $(1 -\n\\theta)$, or ending the burst with probability $\\theta$. What this implies is\nthat for a geometrically distributed burst size we have a mean burst size $b$ of\nthe form\n\\begin{equation}\nb \\equiv \\left\\langle m' - m \\right\\rangle \n= \\sum_{k=0}^\\infty k \\theta (1 - \\theta)^k = {1 - \\theta \\over \\theta}.\n\\end{equation}\n\nTo clean up Equation~\\ref{eq:si_master_deltat} we can send the first term on the\nright hand side to the left, and divide both sides by $\\Delta t$. Upon taking\nthe limit where $\\Delta t \\rightarrow 0$ we can write\n\\begin{equation}\n{d \\over dt}p(m, t) = (m + 1) \\gamma p(m + 1, t)\n- m \\gamma p(m, t)\n+ k_i \\sum_{m'=0}^{m-1} G_{m-m'} p(m', t) \n- k_i \\sum_{m'=m + 1}^{\\infty} G_{m'-m} p(m, t).\n\\end{equation}\nFurthermore, given that the timescale for this equation is set by the mRNA\ndegradation rate $\\gamma$ we can divide both sides by this rate, obtaining\n\\begin{equation}\n{d \\over d\\tau}p(m, \\tau) = (m + 1) p(m + 1, \\tau)\n- m p(m, \\tau)\n+ \\lambda \\sum_{m'=0}^{m-1} G_{m-m'} p(m', \\tau) \n- \\lambda \\sum_{m'=m + 1}^{\\infty} G_{m'-m} p(m, \\tau),\n\\label{eq:si_master_ode}\n\\end{equation}\nwhere we defined $\\tau \\equiv t \\times \\gamma$, and $\\lambda \\equiv k_i/\\gamma$.\nThe last term in Eq.~\\ref{eq:si_master_ode} sums all burst sizes except for a \nburst of size zero. We can re-index the sum to include this term, obtaining\n\\begin{equation}\n\\lambda \\sum_{m'=m + 1}^{\\infty} G_{m'-m} p(m, \\tau) = \\lambda p(m, t) \\left[\n\\underbrace{\\sum_{m'={m}}^{\\infty}G_{m'-m}}\n_{\\text{re-index sum to include burst size zero}} -\n\\underbrace{G_0}_{\\text{subtract extra added term}}\\right].\n\\end{equation}\nGiven the normalization constraint of the geometric distribution, adding the\nprobability of all possible burst sizes -- including size zero since we\nre-indexed the sum -- allows us to write\n\\begin{equation}\n\\sum_{m'=m}^{\\infty}G_{m'-m} - G_0 = 1 - G_0.\n\\end{equation}\nSubstituting this into Eq.~\\ref{eq:si_master_ode} results in\n\\begin{equation}\n{d \\over d\\tau}p(m, \\tau) = (m + 1) p(m + 1, \\tau)\n- m p(m, \\tau)\n+ \\lambda \\sum_{m'=0}^{m-1} G_{m-m'} p(m', \\tau) \n- \\lambda p(m, \\tau) \\left[ 1 - G_0 \\right].\n\\label{eq:si_master_ode_2}\n\\end{equation}\nTo finally get at a more compact version of the equation notice that the third\nterm in Eq.~\\ref{eq:si_master_ode_2} includes burst from size $m'-m = 1$ to size\n$m' - m = m$. We can include the term $p(m, t) G_0$ in the sum which allows\nbursts of size $m' - m = 0$. This results in our final form for the chemical\nmaster equation\n\\begin{align}\n{d \\over d\\tau}p(m, \\tau) = \n(m + 1) p(m+1, \\tau)\n- m p(m, \\tau) - \n\\lambda p(m, \\tau)\n+ \\lambda \\sum_{m^\\prime=0}^m G_{m-m^\\prime} p(m^\\prime, \\tau).\n\\label{eq:si_master_unreg}\n\\end{align}\n\nIn order to solve Eq.~\\ref{eq:si_master_unreg} we will use the generating\nfunction method~\\cite{vanKampen2007}. The probability generating function\nis defined as\n\\begin{align}\nF(z,t) = \\sum_{m=0}^\\infty z^m p(m,t),\n\\end{align}\nwhere $z$ is just a dummy variable that will help us later on to obtain the\nmoments of the distribution. Let us now multiply both sides of\nEq.~\\ref{eq:si_master_unreg} by $z^m$ and sum over all $m$\n\\begin{equation}\n\\sum_m z^m {d \\over d\\tau} p(m, \\tau) = \n\\sum_m z^m \\left[ \n- m p(m, \\tau) \n+ (m + 1) p(m + 1, \\tau) \n+ \\lambda \\sum_{m' = 0}^m G_{m-m'} p(m', \\tau) - \\lambda p(m, \\tau)\n\\right],\n\\end{equation}\nwhere we use $\\sum_m \\equiv \\sum_{m=0}^\\infty$. We can distribute the sum and\nuse the definition of $F(z, t)$ to obtain\n\\begin{equation}\n{d F(z, \\tau) \\over d\\tau} =\n- \\sum_m z^m m p(m, \\tau)\n+ \\sum_m z^m (m + 1) p(m + 1, \\tau)\n+ \\lambda \\sum_m z^m \\sum_{m'=0}^m G_{m-m'} p(m', \\tau)\n- \\lambda F(z, \\tau).\n\\label{eq:si_generating_01}\n\\end{equation}\nWe can make use of properties of the generating function to write everything in\nterms of $F(z, \\tau)$: the first term on the right hand side of\nEq.~\\ref{eq:si_generating_01} can be rewritten as\n\\begin{align}\n\\sum_{m} z^{m} \\cdot m \\cdot p(m, \\tau) &=\n\\sum_{m} z \\frac{\\partial z^{m}}{\\partial z} p(m, \\tau), \\\\\n&=\\sum_{m} z \\frac{\\partial}{\\partial z}\\left(z^{m} p(m, \\tau)\\right), \\\\\n&=z \\frac{\\partial}{\\partial z}\\left(\\sum_{m} z^{m} p(m, \\tau)\\right), \\\\\n&= z {\\partial F(z, \\tau) \\over \\partial z}.\n\\end{align}\nFor the second term on the right hand side of Eq.~\\ref{eq:si_generating_01} we\ndefine $k \\equiv m + 1$. This allows us to write\n\\begin{align}\n\\sum_{m=0}^{\\infty} z^{m} \\cdot(m+1) \\cdot p(m+1, \\tau) &=\n\\sum_{k=1}^{\\infty} z^{k-1} \\cdot k \\cdot p(k, \\tau), \\\\\n&=z^{-1} \\sum_{k=1}^{\\infty} z^{k} \\cdot k \\cdot p(k, \\tau), \\\\\n&=z^{-1} \\sum_{k=0}^{\\infty} z^{k} \\cdot k \\cdot p(k, \\tau), \\\\\n&=z^{-1} \\left(z \\frac{\\partial F(z)}{\\partial z}\\right), \\\\\n&=\\frac{\\partial F(z)}{\\partial z}.\n\\end{align}\n\n\\begin{figure}[h!]\n\\centering\n\\includegraphics[width=5cm]{../figures/si/figS0X_reindex_sum.pdf}\n\\caption{\\textbf{Reindexing double sum.} Schematic for reindexing the sum\n$\\sum_{m=0}^\\infty \\sum_{m'=0}^m$. Blue circles depict the 2D grid of\nnonnegative integers restricted to the lower triangular part of the $m, m'$\nplane. The trick is that this double sum runs over all $(m, m')$ pairs with\n$m'\\le m$. Summing $m$ first instead of $m'$ requires determining the\nboundary: the upper boundary of the $m'$-first double sum becomes the\nlower boundary of the $m$-first double sum.}\n\\label{figS2:sum_reindex}\n\\end{figure}\n\nThe third term in Eq.~\\ref{eq:si_generating_01} is the most trouble. The trick\nis to reverse the default order of the sums as\n\\begin{equation}\n\\sum_{m=0}^{\\infty} \\sum_{m'=0}^{m} = \\sum_{m'=0}^{\\infty} \\sum_{m=m'}^{\\infty}.\n\\end{equation}\nTo see the logic of the sum we point the reader to\nFigure~\\ref{figS2:sum_reindex}. The key is to notice that the double sum\n$\\sum_{m=0}^\\infty \\sum_{m'=0}^m$ is adding all possible pairs $(m, m')$ in the\nlower triangle, so we can add the terms vertically as the original sum\nindexing suggests, i.e.\n\\begin{equation}\n\\sum_{m=0}^{\\infty} \\sum_{m'=0}^{m} x_{(m, m')}= \nx_{(0, 0)} + x_{(1, 0)} + x_{(1, 1)} + x_{(2, 0)} + x_{(2, 1)} + x_{(2, 2)} + \n\\ldots,\n\\end{equation}\nwhere the variable $x$ is just a placeholder to indicate the order in which the\nsum is taking place. But we can also add the terms horizontally as\n\\begin{equation}\n\\sum_{m'=0}^{\\infty} \\sum_{m=m'}^{\\infty} x_{(m, m')} =\nx_{(0, 0)} + x_{(1, 0)} + x_{(2, 0)} + \\ldots + x_{(1,1)} + x_{(2, 1)} + \\ldots,\n\\end{equation}\nwhich still adds all of the lower triangle terms. Applying this reindexing\nresults in\n\\begin{align}\n\\lambda \\sum_m z^m \\sum_{m'=0}^m G_{m-m'} p(m', \\tau) =\n\\lambda \\sum_{m'=0}^{\\infty} \\sum_{m=m'}^{\\infty} z^m \n\\theta (1 - \\theta)^{m-m'} p(m', \\tau),\n\\end{align}\nwhere we also substituted the definition of the geometric distribution $G_{k} =\n\\theta (1 - \\theta)^k$. Redistributing the sums we can write\n\\begin{align}\n\\lambda \\sum_{m'=0}^{\\infty} \\sum_{m=m'}^{\\infty} z^m \n\\theta (1 - \\theta)^{m-m'} p(m', \\tau) = \n\\lambda \\theta \\sum_{n=0}^{\\infty}(1-\\theta)^{m'} P(m', \\tau) \n\\sum_{m=m'}^{\\infty} \\left[z (1-\\theta)\\right]^{m}.\n\\label{eq:si_generating_02}\n\\end{align}\n\nThe next step requires us to look slightly ahead into what we expect to obtain.\nWe are working on deriving an equation for the generating function $F(z, \\tau)$\nthat when solved will allow us to compute what we care about, i.e. the\nprobability function $p(m, \\tau)$. Upon finding the function for $F(z, \\tau)$,\nwe will recover this probability distribution by evaluating derivatives\nof $F(z, \\tau)$ at $z=0$, whereas we can evaluate derivatives of\n$F(z, \\tau)$ at $z=1$ to instead recover the moments of the\ndistribution. The point here is that when the dust settles we\nwill evaluate $z$ to be less than or equal to one.\nFurthermore, we know that the parameter of the geometric distribution $\\theta$\nmust be strictly between zero and one. With these two facts we can safely state that\n$| z (1 - \\theta) | < 1$. Defining $n \\equiv m - m'$ we rewrite the last sum in\nEq.~\\ref{eq:si_generating_02} as\n\\begin{align}\n\\sum_{m=m'}^{\\infty} \\left[z (1-\\theta)\\right]^{m} &= \n\\sum_{n=0}^{\\infty} \\left[z (1-\\theta)\\right]^{n + m'} \\\\\n&= \\left[ z (1 - \\theta) \\right]^{m'} \n\\sum_{n=0}^{\\infty} \\left[ z (1 - \\theta) \\right]^{n} \\\\\n&= \\left[ z (1 - \\theta) \\right]^{m'} \n\\left( {1 \\over 1 - z (1 - \\theta)} \\right),\n\\end{align}\nwhere we use the geometric series since, as stated before, $| z (1 - \\theta) | <\n1$. Putting these results together, the PDE for the generating function is\n\\begin{equation}\n{\\partial F \\over \\partial \\tau} = \n{\\partial F \\over\\partial z}\n- z {\\partial F \\over \\partial z} - \\lambda F\n+ \\frac{\\lambda\\theta F}{1-z(1-\\theta)}.\n\\end{equation}\nChanging variables to $\\xi=1-\\theta$ and simplifying gives\n\\begin{align}\n{\\partial F \\over \\partial \\tau} + (z - 1) {\\partial F \\over \\partial z} = \n\\frac{(z-1)\\xi}{1-z\\xi}\\lambda F.\n\\label{eq:1state_unreg_015}\n\\end{align}\n\n\\subsubsection{Steady-state}\n\nTo get at the mRNA distribution at steady state we first must solve\nEq.~\\ref{eq:1state_unreg_015} setting the time derivative to zero. At\nsteady-state, the PDE reduces to the ODE\n\\begin{align}\n\\deriv[F]{z} = \\frac{\\xi}{1-z\\xi}\\lambda F,\n\\end{align}\nwhich we can integrate as\n\\begin{align}\n\\int \\frac{dF}{F} = \\int \\frac{\\lambda\\xi dz}{1-\\xi z}.\n\\end{align}\nThe initial conditions for generating functions can be subtle and confusing. The\nkey fact follows from the definition\n$F(z,t) = \\sum_m z^m p(m,t)$.\nClearly normalization of the distribution requires that\n$F(z=1, t) = \\sum_m p(m,t) = 1$.\nA subtlety is that sometimes the generating function may be undefined\n\\textit{at} $z=1$, in which case the limit as $z$ approaches $1$ from\nbelow suffices to define the normalization condition.\nWe also warn the reader that, while it is frequently convenient to change\nvariables from $z$ to a different independent variable, one must\ncarefully track how the normalization condition transforms.\n\nContinuing on, we evaluate the integrals (producing a constant $c$) which gives\n\\begin{align}\n\\ln F &= -\\lambda \\ln(1-\\xi z) + c\n\\\\\nF &= \\frac{c}{(1-\\xi z)^\\lambda}.\n\\end{align}\nOnly one choice for $c$ can satisfy initial conditions, producing\n\\begin{align}\nF(z) = \\left(\\frac{1-\\xi}{1-\\xi z}\\right)^\\lambda\n        = \\left(\\frac{\\theta}{1 - z(1-\\theta)}\\right)^\\lambda,\n\\label{eq:gen_fn}\n\\end{align}\n\n\\subsubsection{Recovering the steady-state probability distribution}\n\nTo obtain the steady state mRNA distribution $p(m)$ we are aiming for we need to\nextract it from the generating function\n\\begin{equation}\nF(z) = \\sum_m z^m p(m).\n\\end{equation}\nTaking a derivative with respect to $z$ results in\n\\begin{equation}\n{d F(z) \\over dz} = \\sum_m m z^{m - 1} p(m).\n\\end{equation}\nSetting $z = 0$ leaves one term in the sum when $m = 1$ \n\\begin{equation}\n\\left.\\frac{d F(z)}{d z}\\right|_{z=0} = \n\\left(0 \\cdot 0^{-1} \\cdot p(0) \n+ 1 \\cdot 0^0 \\cdot p(1) \n+ 2 \\cdot 0^1 \\cdot p(2)\n+ \\cdots \\right) = p(1),\n\\end{equation}\nsince in the limit $\\lim_{x \\rightarrow 0^+} x^x = 1$. A second derivative of\nthe generating function would result in\n\\begin{equation}\n\\frac{d^{2} F(z)}{d z^{2}} = \\sum_{m=0}^{\\infty} m(m-1) z^{m-2} p(m).\n\\end{equation}\nAgain evaluating at $z = 0$ gives \n\\begin{equation}\n\\left.\\frac{d^{2} F(z)}{d z}\\right|_{z=0} = 2 p(z).\n\\end{equation}\nIn general any $p(m)$ is obtained from the generating function as\n\\begin{equation}\np(m) = {1 \\over m!} \\left. {d^m F(z) \\over dz} \\right\\vert_{z=0}.\n\\label{eq:prob_from_gen}\n\\end{equation}\n\nLet's now look at the general form of the derivative for our generating function\nin Eq.~\\ref{eq:gen_fn}. For $p(0)$ we simply evaluate $F(z=0)$ directly, \nobtaining\n\\begin{equation}\np(0) = F(z=0) = \\theta^{\\lambda}.\n\\end{equation}\nThe first derivative results in\n\\begin{equation}\n\\begin{aligned}\n\\frac{d F(z)}{d z} &=\\theta^{\\lambda} \\frac{d}{d z}(1-z(1-\\theta))^{-\\lambda} \\\\\n&=\\theta^{\\lambda}\\left[-\\lambda(1-z(1-f))^{-\\lambda-1} \\cdot(\\theta-1)\\right]\\\\\n&=\\theta^{\\lambda}\\left[\\lambda(1-z(1-\\theta))^{-\\lambda-1}(1-\\theta)\\right].\n\\end{aligned}\n\\end{equation}\nEvaluating this at $z=0$ as required to get $p(1)$ gives\n\\begin{equation}\n\\left.\\frac{d F(z)}{d z}\\right|_{z=0}=\\theta^{\\lambda} \\lambda(1-\\theta)\n\\end{equation}\nFor the second derivative we find\n\\begin{equation}\n\\frac{d^{2} F(z)}{d z^{2}} = \\theta^{\\lambda}\n\\left[\\lambda(\\lambda+1)(1-z(1-\\theta))^{-\\lambda-2}(1-\\theta)^{2}\\right].\n\\end{equation}\nAgain evaluating $z = 0$ gives\n\\begin{equation}\n\\left.\\frac{d^{2} F(z)}{d z^{2}}\\right|_{z=0} = \n\\theta^{\\lambda} \\lambda(\\lambda+1)(1-\\theta)^{2}.\n\\end{equation}\nLet's go for one more derivative to see the pattern. The third derivative of the\ngenerating function gives\n\\begin{equation}\n\\frac{d^{3} F(z)}{d z^{3}} = \n\\theta^{\\lambda} \n\\left[\\lambda(\\lambda+1)\n(\\lambda+2)(1-z(1-\\theta))^{-\\lambda-3}(1-\\theta)^{3}\\right],\n\\end{equation}\nwhich again we evaluate at $z=0$\n\\begin{equation}\n\\left.\\frac{d^{3} F(z)}{d z^{3}}\\right|_{z=1} =\n\\theta^{\\lambda}\\left[\\lambda(\\lambda+1)(\\lambda+2)(1-\\theta)^{3}\\right].\n\\end{equation}\nIf $\\lambda$ was an integer we could write this as\n\\begin{equation}\n\\left.\\frac{d^{3} F(z)}{d z^{3}}\\right|_{z=0} = \n\\frac{(\\lambda+2) !}{(\\lambda-1) !} \\theta^{\\lambda}(1-\\theta)^{3}.\n\\end{equation}\nSince $\\lambda$ might not be an integer we can write this using Gamma functions\nas\n\\begin{equation}\n\\left.\\frac{d^{3} F(z)}{d z^{3}}\\right|_{z=0} = \n\\frac{\\Gamma(\\lambda+3)}{\\Gamma(\\lambda)} \\theta^{\\lambda}(1-\\theta)^{3}.\n\\end{equation}\nGeneralizing the pattern we then have that the $m$-th derivative takes the form\n\\begin{equation}\n\\left.\\frac{d^{m} F(z)}{d z^{m}}\\right|_{z=0} =\n\\frac{\\Gamma(\\lambda+m)}{\\Gamma(\\lambda)} \\theta^{\\lambda}(1-\\theta)^{m}.\n\\end{equation}\nWith this result we can use Eq.~\\ref{eq:prob_from_gen} to obtain the desired\nsteady-state probability distribution function\n\\begin{equation}\np(m) = \\frac{\\Gamma(m+\\lambda)}{\\Gamma(m+1)\\Gamma(\\lambda)}\n        \\theta^\\lambda (1-\\theta)^m.\n\\end{equation}\nNote that the ratio of gamma functions is often expressed as a binomial\ncoefficient, but since $\\lambda$ may be non-integer, this would be ill-defined.\nRe-expressing this exclusively in our variables of interest, burst rate\n$\\lambda$ and mean burst size $b$, we have\n\\begin{equation}\np(m) = \\frac{\\Gamma(m+\\lambda)}{\\Gamma(m+1)\\Gamma(\\lambda)}\n        \\left(\\frac{1}{1+b}\\right)^\\lambda\n        \\left(\\frac{b}{1+b}\\right)^m.\n\\label{eq:nbinom_deriv_final}\n\\end{equation}\n\n\\subsection{Adding repression}\n\\subsubsection{Deriving the generating function for mRNA distribution}\n\nLet us move from a one-state promoter to a two-state promoter, where one state\nhas repressor bound and the other produces transcriptional bursts as above.\nA schematic of this model is shown as model 5 in\nFigure~\\ref{fig1:means_cartoons}(C). Although now we have an equation for each\npromoter state, otherwise the master equation reads similarly to the one-state\ncase, except with additional terms corresponding to transitions between promoter\nstates, namely\n\\begin{align}\n{d\\over dt}p_R(m,t) =& \nk_R^+ p_A(m,t) - k_R^- p_R(m,t)\n        + (m+1)\\gamma p_R(m+1,t) - m\\gamma p_R(m,t)\n\\\\\n\\begin{split}\n{d\\over dt}p_A(m,t) =& - k_R^+ p_A(m,t) + k_R^- p_R(m,t)\n        + (m+1)\\gamma p_A(m+1,t) - m\\gamma p_A(m,t) \n\\\\\n&- k_i p_A(m,t) + k_i \\sum_{m^\\prime=0}^m \\theta(1-\\theta)^{m-m^\\prime} p_A(m^\\prime,t),\n\\end{split}\n\\end{align}\nwhere $p_R(m,t)$ is the probability of the system having $m$ mRNA copies and\nhaving repressor bound to the promoter at time $t$, and $p_A$ is an analogous\nprobability to find the promoter without repressor bound. $k_R+$ and $k_R^-$\nare, respectively, the rates at which repressors bind and unbind to and from the\npromoter, and $\\gamma$ is the mRNA degradation rate. $k_i$ is the rate at which\nbursts initiate, and as before, the geometric distribution of burst sizes has\nmean $b=(1-\\theta)/\\theta$.\n\nInterestingly, it turns out that this problem maps exactly onto the three-stage\npromoter model considered by Shahrezaei and Swain in~\\cite{Shahrezaei2008}, with\nrelabelings. Their approximate solution for protein distributions amounts to the\nsame approximation we make here in regarding the duration of mRNA synthesis\nbursts as instantaneous, so their solution for protein distributions also solves\nour problem of mRNA distributions. Let us examine the analogy more closely. They\nconsider a two-state promoter, as we do here, but they model mRNA as being\nproduced one at a time and degraded, with rates $v_0$ and $d_0$. Then they model\ntranslation as occurring with rate $v_1$, and protein degradation with rate\n$d_1$ as shown in Figure~\\ref{fig:shahrezaei}. Now consider the limit where\n$v_1, d_0\\rightarrow\\infty$ with their ratio $v_1/d_0$ held constant. $v_1/d_0$\nresembles the average burst size of translation from a single mRNA: these are\nthe rates of two Poisson processes that compete over a transcript, which matches\nthe story of geometrically distributed burst sizes. In other words, in our \nbursty promoter model we can think of the parameter $\\theta$ as determining one\ncompeting process to end the burst and $(1 - \\theta)$ as a process wanting to\ncontinue the burst. So after taking this limit, on timescales slow compared to\n$v_1$ and $d_0$, it appears that transcription events fire at rate $v_0$ and\nproduce a geometrically distributed burst of translation of mean size $v_1/d_0$,\nwhich intuitively matches the story we have told above for mRNA with variables\nrelabeled.\n\n\\begin{figure}\n\\centering\n\\includegraphics{../figures/si/figS0X_Shahrezaei_promoter.pdf}\n\\caption{\\textbf{Schematic of three-stage promoter from~\\cite{Shahrezaei2008}.}\nAdapted from Shahrezaei \\& Swain~\\cite{Shahrezaei2008}. In their paper they\nderive a closed form solution for the protein distribution. Our two-state bursty\npromoter at the mRNA level can be mapped into their solution with some\nrelabeling.}\n\\label{fig:shahrezaei}\n\\end{figure}\n\nTo verify this intuitively conjectured mapping between our problem and the\nsolution in~\\cite{Shahrezaei2008}, we continue with a careful solution for the\nmRNA distribution using probability generating functions, following the ideas\nsketched in~\\cite{Shahrezaei2008}. It is natural to nondimensionalize rates in\nthe problem by $\\gamma$, or equivalently, this amounts to measuring time in\nunits of $\\gamma^{-1}$. We are also only interested in steady state, so we set\nthe time derivatives to zero, giving\n\\begin{align}\n0 =& k_R^+ p_A(m) - k_R^- p_R(m) + (m+1) p_R(m+1) - m p_R(m)\n\\\\\n\\begin{split}\n0 =& - k_R^+ p_A(m) + k_R^- p_R(m) + (m+1) p_A(m+1) - m p_A(m) \n\\\\\n&- k_i p_A(m) + k_i \\sum_{m^\\prime=0}^m \\theta(1-\\theta)^{m-m^\\prime} p_A(m^\\prime),\n\\end{split}\n\\end{align}\nwhere for convenience we kept the same notation for all rates, but these are\nnow expressed in units of mean mRNA lifetime $\\gamma^{-1}$.\n        \nThe probability generating function is defined as before in the constitutive\ncase, except now we must introduce a generating function for each promoter\nstate,\n\\begin{align}\nf_A(z) = \\sum_{m=0}^\\infty z^m p_A(m),\n\\;\nf_R(z) = \\sum_{m=0}^\\infty z^m p_R(m).\n\\end{align}\nOur real objective is the generating function $f(z)$ that generates the mRNA\ndistribution $p(m)$, independent of what state the promoter is in. But since\n$p(m) = p_A(m) + p_R(m)$, it follows too that $f(z) = f_A(z) + f_R(z)$.\n\nAs before we multiply both equations by $z^m$ and sum over all $m$. Each\nindividual term transforms exactly as did an analogous term in the constitutive\ncase, so the coupled ODEs for the generating functions read\n\\begin{align}\n0 =& k_R^+ f_A(z) - k_R^- f_R(z) + \\pderiv{z} f_R(z) - z \\pderiv{z} f_R(z)\n\\\\\n\\begin{split}\n0 =&  - k_R^+ f_A(z) + k_R^- f_R(z) + \\pderiv{z} f_A(z) - z \\pderiv{z} f_A(z)\n\\\\\n&- k_i f_A(z) + k_i \\frac{\\theta}{1-z(1-\\theta)} f_A(z),\n\\end{split}\n\\end{align}\nand after changing variables $\\xi = 1 - \\theta$ as before and rearranging, we\nhave\n\\begin{align}\n0 &= k_R^+ f_A(z) - k_R^- f_R(z) + (1-z) \\pderiv{z} f_R(z)\n\\\\\n0 &=  - k_R^+ f_A(z) + k_R^- f_R(z) + (1 - z) \\pderiv{z} f_A(z)\n+ k_i \\frac{(z-1)\\xi}{1-z\\xi} f_A(z),\n\\end{align}\nWe can transform this problem from two coupled first-order ODEs to a single\nsecond-order ODE by solving for $f_A$ in the first and plugging into the second,\ngiving\n\\begin{align}\n\\begin{split}\n0 = (1&-z) \\pderiv[f_R]{z}\n+ \\frac{1-z}{k_R^+}\n        \\left(k_R^- \\pderiv[f_R]{z} + \\pderiv[f_R]{z} +(z-1) \\psecderiv[f_R]{z}\\right)\n\\\\\n&+ \\frac{k_i}{k_R^+} \\frac{(z-1)\\xi}{1-z\\xi}\n        \\left(k_R^- f_R + (z-1) \\pderiv[f_R]{z}\\right),\n\\end{split}\n\\end{align}\nwhere, to reduce notational clutter, we have dropped the explicit $z$ dependence\nof $f_A$ and $f_R$. Simplifying we have\n\\begin{align}\n0 = \\psecderiv[f_R]{z}\n        - \\left(\\frac{k_i\\xi}{1-z\\xi}\n                + \\frac{1 + k_R^- + k_R^+}{1-z}\n        \\right)\\pderiv[f_R]{z}\n        + \\frac{k_i k_R^- \\xi}{(1-z\\xi)(1-z)}f_R.\n\\end{align}\nThis can be recognized as the hypergeometric differential equation, with\nsingularities at $z=1$, $z=\\xi^{-1}$, and $z=\\infty$. The latter can be verified\nby a change of variables from $z$ to $x=1/z$, being careful with the chain rule,\nand noting that $z=\\infty$ is a singular point if and only if $x=1/z=0$ is a\nsingular point.\n\nThe standard form of the hypergeometric differential equation has its\nsingularities at 0, 1, and $\\infty$, so to take advantage of the standard form\nsolutions to this ODE, we first need to transform variables to put it into a\nstandard form. However, this is subtle. While any such transformation should\nwork in principle, the solutions are expressed most simply in the neighborhood\nof $z=0$, but the normalization condition that we need to enforce corresponds to\n$z=1$. The easiest path, therefore, is to find a change of variables that maps 1\nto 0, $\\infty$ to $\\infty$, and $\\xi^{-1}$ to 1. This is most intuitively done\nin two steps.\n\nFirst map the $z=1$ singularity to 0 by the change of variables $v=z-1$, giving\n\\begin{align}\n0 = \\psecderiv[f_R]{v}\n        + \\left(\\frac{k_i\\xi}{(1+v)\\xi - 1}\n                + \\frac{1 + k_R^- + k_R^+}{v}\n        \\right)\\pderiv[f_R]{v}\n        + \\frac{k_i k_R^- \\xi}{((1+v)\\xi - 1)v}f_R.\n\\end{align}\nNow two singularities are at $v=0$ and $v=\\infty$. The third is determined by\n$(1+v)\\xi -1 = 0$, or $v=\\xi^{-1} - 1$. We want another variable change that\nmaps this third singularity to 1 (without moving 0 or infinity). Changing\nvariables again to $w=\\frac{v}{\\xi^{-1} - 1} = \\frac{\\xi}{1-\\xi} v$ fits the\nbill. In other words, the combined change of variables\n\\begin{align}\nw = \\frac{\\xi}{1-\\xi} (z-1)\n\\end{align}\nmaps $z = \\{1, \\xi^{-1}, \\infty\\}$ to $w =\\{0, 1, \\infty\\}$ as desired. Plugging\nin, being mindful of the chain rule and noting\n$(1 + v)\\xi - 1 = (1 - \\xi)(w - 1)$ gives\n\\begin{align}\n0 = \\left(\\frac{\\xi}{1-\\xi}\\right)^2 \\psecderiv[f_R]{w}\n+ \\left(\n        \\frac{\\xi k_i}{(1-\\xi)(w-1)} + \\frac{\\xi(1 + k_R^- + k_R^+)}{(1-\\xi)w}\n\\right) \\frac{\\xi}{1-\\xi} \\pderiv[f_R]{w}\n+ \\frac{k_i k_R^- \\xi^2}{(1-\\xi)^2 w(w-1)}f_R.\n\\end{align}\nThis is close to the standard form of the hypergeometric differential equation,\nand some cancellation and rearrangement gives\n\\begin{align}\n0 = w(w-1)\\psecderiv[f_R]{w}\n+ \\left(k_i w + (1 + k_R^- + k_R^+)(w-1)\\right) \\pderiv[f_R]{w}\n+ k_i k_R^- f_R.\n\\end{align}\nand a little more algebra produces\n\\begin{align}\n0 = w(1-w)\\psecderiv[f_R]{w}\n+ \\left(1 + k_R^- + k_R^+\n        - (1 + k_i + k_R^- + k_R^+)w\n\\right) \\pderiv[f_R]{w}\n- k_i k_R^- f_R,\n\\end{align}\nwhich is the standard form. From this we can read off the solution in terms of\nhypergeometric functions ${_2F_1}$ from any standard source,\ne.g.~\\cite{Abramowitz1964}, and identify the conventional parameters in terms of\nour model parameters. We want the general solution in the neighborhood of $w=0$\n($z=1$), which for a homogeneous linear second order ODE must be a sum of two\nlinearly independent solutions. More precisely, \n\\begin{align}\nf_R(w) = C^{(1)} {_2F_1}(\\alpha, \\beta, \\delta; w)\n+ C^{(2)} w^{1-\\delta}{_2F_1}(1+\\alpha-\\delta, 1+\\beta-\\delta, 2-\\delta; w)\n\\end{align}\nwith parameters determined by\n\\begin{align}\n\\begin{split}\n\\alpha\\beta &= k_i k_R^-\n\\\\\n1+\\alpha+\\beta &= 1+k_i+k_R^-+k_R^+\n\\\\\n\\delta &= 1 + k_R^- + k_R^+\n\\end{split}\n\\end{align}\nand constants $C^{(1)}$ and $C^{(2)}$ to be set by boundary conditions. Solving for\n$\\alpha$ and $\\beta$, we find\n\\begin{align}\n\\begin{split}\n\\alpha &= \\frac{1}{2}\n\\left(k_i+k_R^-+k_R^+ + \\sqrt{(k_i+k_R^-+k_R^+)^2 - 4k_i k_R^-}\\right)\n\\\\\n\\beta &= \\frac{1}{2}\n\\left(k_i+k_R^-+k_R^+ - \\sqrt{(k_i+k_R^-+k_R^+)^2 - 4k_i k_R^-}\\right)\n\\\\\n\\delta &= 1 + k_R^- + k_R^+.\n\\end{split}\n\\end{align}\nNote that $\\alpha$ and $\\beta$ are interchangeable in the definition of\n${_2F_1}$ and differ only in the sign preceeding the radical.\nSince the normalization condition requires that $f_R$ be finite at $w=0$,\nwe can immediately set $C^{(2)}=0$ to discard the second solution.\nThis is because all the rate constants are strictly positive,\nso $\\delta>1$ and therefore $w^{1-\\delta}$ blows up as $w\\rightarrow0$.\nNow that we have $f_R$, we would like to find the generating function\nfor the mRNA distribution, $f(z) = f_A(z) + f_R(z)$.\nWe can recover $f_A$ from our solution for $f_R$, namely\n\\begin{align}\nf_A(z) = \\frac{1}{k_R^+}\\left(k_R^- f_R(z) + (z-1) \\pderiv[f_R]{z}\\right)\n\\end{align}\nor\n\\begin{align}\nf_A(w) = \\frac{1}{k_R^+}\\left(k_R^- f_R(w) + w \\pderiv[f_R]{w}\\right),\n\\end{align}\nwhere in the second line we transformed our original relation between\n$f_R$ and $f_A$ to our new, more convenient, variable $w$.\nPlugging our solution for $f_R(w) = C^{(1)}{_2F_1}(\\alpha, \\beta, \\delta; w)$\ninto $f_A$, we will require the differentiation rule for ${_2F_1}$,\nwhich tells us\n\\begin{align}\n\\pderiv[f_R]{w} = C^{(1)}\\frac{\\alpha\\beta}{\\delta}\n                {_2F_1}(\\alpha+1, \\beta+1, \\delta+1; w),\n\\end{align}\nfrom which it follows that\n\\begin{align}\nf_A(w) = \\frac{C^{(1)}}{k_R^+}\n\\left(\nk_R^- {_2F_1}(\\alpha, \\beta, \\delta; w)\n+ w\\frac{\\alpha\\beta}{\\delta} {_2F_1}(\\alpha+1, \\beta+1, \\delta+1; w)\n\\right)\n\\end{align}\nand therefore\n\\begin{align}\nf(w) = C^{(1)}\\left(1 + \\frac{k_R^-}{k_R^+}\\right)\n        {_2F_1}(\\alpha, \\beta, \\delta; w)\n+ w \\frac{C^{(1)}}{k_R^+} \\frac{\\alpha\\beta}{\\delta}\n        {_2F_1}(\\alpha+1, \\beta+1, \\delta+1; w).\n\\end{align}\nTo proceed, we need one of the (many) useful identities known for\nhypergeometric functions, in particular\n\\begin{align}\nw\\frac{\\alpha\\beta}{\\delta} {_2F_1}(\\alpha+1, \\beta+1, \\delta+1; w)\n=\n(\\delta-1)\\left(\n{_2F_1}(\\alpha, \\beta, \\delta-1; w) - {_2F_1}(\\alpha, \\beta, \\delta; w)\n\\right).\n\\end{align}\nSubstituting this for the second term in $f(w)$, we find\n\\begin{align}\nf(w) = \\frac{C^{(1)}}{k_R^+}\n\\left[\n        \\left(k_R^+ + k_R^-\\right)\n        {_2F_1}(\\alpha, \\beta, \\delta; w)\n+ (\\delta-1)\\left(\n        {_2F_1}(\\alpha, \\beta, \\delta-1; w) - {_2F_1}(\\alpha, \\beta, \\delta; w)\n        \\right)\n\\right],\n\\end{align}\nand since $\\delta-1 = k_R^+ + k_R^-$, the first and third terms cancel,\nleaving only\n\\begin{align}\nf(w) = C^{(1)}\\frac{k_R^+ + k_R^-}{k_R^+} {_2F_1}(\\alpha, \\beta, \\delta-1; w).\n\\end{align}\nNow we enforce normalization, demanding $f(w=0) = f(z=1) = 1$.\n${_2F_1}(\\alpha, \\beta, \\delta-1; 0) = 1$, so we must have\n$C^{(1)} = k_R^+ / (k_R^+ + k_R^-)$ and consequently\n\\begin{align}\nf(w) =  {_2F_1}(\\alpha, \\beta, k_R^+ + k_R^-; w).\n\\end{align}\nRecalling that the mean burst size $b = (1-\\theta)/\\theta = \\xi/(1-\\xi)$\nand $w = \\frac{\\xi}{1-\\xi} (z-1) = b (z-1)$,\nwe can transform back to the original variable $z$ to find the tidy result\n\\begin{align}\nf(z) =  {_2F_1}(\\alpha, \\beta, k_R^+ + k_R^-; b(z-1)),\n\\end{align}\nwith $\\alpha$ and $\\beta$ given above by\n\\begin{align}\n\\begin{split}\n\\alpha &= \\frac{1}{2}\n\\left(k_i+k_R^-+k_R^+ + \\sqrt{(k_i+k_R^-+k_R^+)^2 - 4k_i k_R^-}\\right)\n\\\\\n\\beta &= \\frac{1}{2}\n\\left(k_i+k_R^-+k_R^+ - \\sqrt{(k_i+k_R^-+k_R^+)^2 - 4k_i k_R^-}\\right).\n\\end{split}\n\\end{align}\nFinally we are in sight of the original goal. We can generate the steady-state\nprobability distribution of interest by differentiating the generating function,\n\\begin{align}\np(m) = m! \\left.\\frac{\\partial^m}{\\partial z^m} f(z) \\right|_{z=0},\n\\end{align}\nwhich follows easily from its definition. Some contemplation reveals that\nrepeated application of the derivative rule used above will produce products of\nthe form $\\alpha(\\alpha+1)(\\alpha+2)\\cdots(\\alpha+m-1)$ in the expression for\n$p(m)$ and similarly for $\\beta$ and $\\delta$. These resemble ratios of\nfactorials, but since $\\alpha$, $\\beta$, and $\\delta$ are not necessarily\ninteger, we should express the ratios using gamma functions instead. More\nprecisely, one finds\n\\begin{align}\np(m) = \\frac{\n        \\Gamma(\\alpha + m)\\Gamma(\\beta + m)\\Gamma(k_R^+ + k_R^-)\n        }\n        {\n        \\Gamma(\\alpha)\\Gamma(\\beta)\\Gamma(k_R^+ + k_R^- + m)\n        }\n\\frac{b^m}{m!}{_2F_1}(\\alpha+m, \\beta+m, k_R^++k_R^-+m; -b)\n\\label{eq:p_m_bursty+rep_appdx}\n\\end{align}\nwhich is finally the probability distribution we sought to derive.\n\n\\subsection{Numerical considerations and recursion formulas}\n\\subsubsection{Generalities}\nWe would like to carry out Bayesian parameter inference on FISH data\nfrom~\\cite{Jones2014}, using~\\eq{eq:p_m_bursty+rep_appdx} as our\nlikelihood. This requires accurate (and preferably fast)\nnumerical evaluation of the hypergeometric function ${_2F_1}$,\nwhich is a notoriously hard problem~\\cite{Pearson2017, Gil2007},\nand our particular needs here present an especial challenge as we show below.\n\nThe hypergeometric function is defined by its Taylor series as\n\\begin{align}\n{_2F_1}(a,b,c;z) \n= \\sum_{l=0}^\\infty\n\\frac{\\Gamma(a + l)\\Gamma(b + l)\\Gamma(c)}\n        {\\Gamma(a)\\Gamma(b)\\Gamma(c + l)}\n\\frac{z^l}{l!}\n\\end{align}\nfor $|z|<1$, and by analytic continuation elsewhere.\nIf $z\\lesssim1/2$ and $\\alpha$ and $\\beta$ are not too large\n(absolute value below 20 or 30),\nthen the series converges quickly and an accurate numerical representation is\neasily computed by truncating the series after a reasonable number of terms.\nUnfortunately, we need to evaluate ${_2F_1}$ over mRNA copy numbers fully out\nto the tail of the distribution, which can easily reach 50, possibly 100.\nFrom~\\eq{eq:p_m_bursty+rep_appdx}, this means evaluating ${_2F_1}$\nrepeatedly for values of $a$, $b$, and $c$ spanning the full range\nfrom $\\mathcal{O}(1)$ to $\\mathcal{O}(10^2)$,\neven if $\\alpha$, $\\beta$, and $\\delta$\nin~\\eq{eq:p_m_bursty+rep_appdx} are small,\nwith the situation even worse if they are not small.\nA naive numerical evaluation of the series definition will be\nprone to overflow and, if any of $a,b,c<0$, then some successive terms in the\nseries have alternating signs which can lead to catastrophic cancellations.\n\nOne solution is to evaluate ${_2F_1}$ using arbitrary precision arithmetic\ninstead of floating point arithmetic,\ne.g., using the \\texttt{mpmath} library in Python.\nThis is accurate but incredibly slow computationally.\nTo quantify how slow, we found that\nevaluating the likelihood defined by~\\eq{eq:p_m_bursty+rep_appdx} $\\sim50$ times\n(for a typical dataset of interest from~\\cite{Jones2014},\nwith $m$ values spanning 0 to $\\sim50$)\nusing arbitrary precision arithmetic is 100-1000 fold slower than\nevaluating a negative binomial likelihood for the corresponding\nconstitutive promoter dataset.\n\nTo claw back $\\gtrsim30$ fold of that slowdown, we can exploit\none of the many catalogued symmetries involving ${_2F_1}$.\nThe solution involves recursion relations originally explored by Gauss,\nand studied extensively in~\\cite{Pearson2017, Gil2007}.\nThey are sometimes known as contiguous relations and relate the values\nof any set of 3 hypergeometric functions whose arguments differ by integers.\nTo rephrase this symbolically, consider a set of hypergeometric functions\nindexed by an integer $n$,\n\\begin{align}\nf_n = {_2F_1}(a+\\epsilon_i n, b+\\epsilon_j n, c+\\epsilon_k n; z),\n\\end{align}\nfor a fixed choice of $\\epsilon_i, \\epsilon_j, \\epsilon_k \\in \\{0,\\pm 1\\}$\n(at least one of $\\epsilon_i, \\epsilon_j, \\epsilon_k$ must be nonzero,\nelse the set of $f_n$ would contain only a single element).\nThen there exist known recurrence relations of the form\n\\begin{align}\nA_n f_{n-1} + B_n f_{n} + C_n f_{n+1} = 0,\n\\end{align}\nwhere $A_n, B_n$, and $C_n$ are some functions of $a,b,c$, and $z$.\nIn other words, for fixed $\\epsilon_i, \\epsilon_j, \\epsilon_k, a, b,$ and $c$,\nif we can merely evaluate ${_2F_1}$ twice, say for $n^\\prime$ and $n^\\prime-1$,\nthen we can easily and rapidly generate values for arbitrary $n$.\n\nThis provides a convenient solution for our problem: we need repeated\nevaluations of ${_2F_1}(a+m, b+m, c+m; z)$\nfor fixed $a,b$, and $c$ and many integer values of $m$.\nThey idea is that we can use arbitrary precision arithmetic to evaluate\n${_2F_1}$ for just two particular values of $m$ and then generate\n${_2F_1}$ for the other 50-100 values of $m$ using the recurrence\nrelation.\nIn fact there are even more sophisticated ways of utilizing the recurrence\nrelations that might have netted another factor of 2 speed-up, and\npossibly as much as a factor of 10, but the method described here had\nalready reduced the computation time to an acceptable\n$\\mathcal{O}(\\text{1 min})$, so these more sophisticated approaches did\nnot seem worth the time to pursue.\n\nHowever, there are two further wrinkles.\nThe first is that\na naive application of the recurrence relation is numerically unstable.\nRoughly, this is because the three term recurrence relations,\nlike second order ODEs, admit two linearly independent solutions.\nIn a certain eigenbasis, one of these solutions dominates the other\nas $n\\rightarrow\\infty$, and as $n\\rightarrow-\\infty$,\nthe dominance is reversed.\nIf we fail to work in this eigenbasis, our solution of the recurrence relation\nwill be a mixture of these solutions and rapidly accumulate numerical error.\nFor our purposes, it suffices to know that the authors of~\\cite{Gil2007}\nderived the numerically stable solutions (so-called \\textit{minimal solutions})\nfor several possible choices of $\\epsilon_i, \\epsilon_j, \\epsilon_k$.\nRunning the recurrence in the proper direction using a minimal solution\nis numerically robust and can be done entirely in floating point arithmetic, \nso that we only need to evaluate ${_2F_1}$ with arbitrary precision arithmetic\nto generate the seed values for the recursion.\n\nThe second wrinkle is a corollary to the first.\nThe minimal solutions are only minimal for certain ranges of the argument $z$,\nand not all of the 26 possible recurrence relations\nhave minimal solutions for all $z$.\nThis can be solved by using one of the many transformation formulae for\n${_2F_1}$ to convert to a different recurrence relation that has\na minimal solution over the required domain of $z$, although\nthis can require some trial and error to find the right transformation,\nthe right recurrence relation, and the right minimal solution.\n\n\\subsubsection{Particulars}\nLet us now demonstrate these generalities for our problem of interest.\nIn order to evaluate the probability distribution of our\nmodel,~\\eq{eq:p_m_bursty+rep_appdx}, we need to evaluate hypergeometric functions\nof the form ${_2F_1}(\\alpha+m, \\beta+m, \\delta+m; -b)$\nfor values of $m$ ranging from $0$ to $\\mathcal{O}(100)$.\nThe authors of~\\cite{Gil2007} did not derive a recursion relation\nfor precisely this case. We could follow their methods and do so ourselves,\nbut it is much easier to convert to a case that they did consider.\nThe strategy is to look through the minimal solutions tabulated\nin~\\cite{Gil2007} and search for a transformation we could apply to\n${_2F_1}(\\alpha+m, \\beta+m, \\delta+m; -b)$ that would place the $m$'s\n(the variable being incremented by the recursion)\nin the same arguments of ${_2F_1}$ as the minimal solution.\nAfter some ``guess and check,'' we found that the transformation\n\\begin{align}\n{_2F_1}(\\alpha+m, \\beta+m, \\delta+m; -b)\n=\n(1+b)^{-\\alpha-m}\n        {_2F_1}\\left(\\alpha+m, \\delta-\\beta, \\delta+m; \\frac{b}{1+b}\\right),\n\\label{eq:rec_euler_pretransform}\n\\end{align}\nproduces a ${_2F_1}$ on the right hand side that closely resembles\nthe minimal solutions $y_{3,m}$ and $y_{4,m}$ in Eq.~4.3 in~\\cite{Gil2007}.\nExplicitly, these solutions are\n\\begin{align}\ny_{3,m}\n&\\propto\n{_2F_1}\\left(-\\alpha^\\prime + \\delta^\\prime - m,\n                -\\beta^\\prime + \\delta^\\prime,\n                1-\\alpha^\\prime-\\beta^\\prime+\\delta^\\prime-m;\n                1-z\\right)\n\\\\\ny_{4,m}\n&\\propto\n{_2F_1}\\left(\\alpha^\\prime + m,\n                \\beta^\\prime,\n                1+\\alpha^\\prime+\\beta^\\prime-\\delta^\\prime+m;\n                1-z\\right),\n\\label{eq:minimal_soln_sans_prefac}\n\\end{align}\nwhere we have omitted prefactors which are unimportant for now.\nWhich of these two we should use depends on what values $z$ takes on.\nEquating $1-z=b/(1+b)$ gives $z=1/(1+b)$, and since $b$ is strictly positive,\n$z$ is bounded between 0 and 1.\nFrom Eq.~4.5 in~\\cite{Gil2007}, $y_{4,m}$ is the minimal solution\nfor real $z$ satisfying $0<z<2$, so this is the only minimal solution we need.\n\nNow that we have our minimal solution,\nwhat recurrence relation does it satisfy?\nConfusingly, the recurrence relation of which $y_{4,m}$ is a solution\nincrements different arguments of ${_2F_1}$ that does $y_{4,m}$:\nit increments the first only, rather than first and third.\nThis recurrence relation can be looked up, e.g., Eq.~15.2.10\nin~\\cite{Abramowitz1964}, which is\n\\begin{align}\n(\\delta^\\prime - (\\alpha^\\prime + m)) f_{m-1}\n+\n(2(\\alpha^\\prime+m) - \\delta^\\prime + (\\beta^\\prime - \\alpha^\\prime)z)f_m\n+ \\alpha^\\prime(z-1) f_{m+1} = 0.\n\\label{eq:chosen_rec_rel}\n\\end{align}\nNow we must solve for the parameters appearing in the recurrence relation\nin terms of our parameters, namely by setting\n\\begin{align}\n\\begin{split}\n\\alpha^\\prime &= \\alpha\n\\\\\n\\beta^\\prime &= \\delta - \\beta\n\\\\\n1 + \\alpha^\\prime + \\beta^\\prime - \\delta^\\prime &= \\delta\n\\\\\n1 - z &= \\frac{b}{1+b}\n\\end{split}\n\\end{align}\nand solving to find\n\\begin{align}\n\\begin{split}\n\\alpha^\\prime &= \\alpha\n\\\\\n\\beta^\\prime &= \\delta - \\beta\n\\\\\n\\delta^\\prime &= 1 + \\alpha - \\beta\n\\\\\nz &= \\frac{1}{1+b}\n.\n\\end{split}\n\\end{align}\nFinally we have everything we need. The minimal solution\n\\begin{align}\ny_{4,m}\n=\n\\frac{\\Gamma(1+\\alpha^\\prime-\\delta^\\prime+m)}\n        {\\Gamma(1+\\alpha^\\prime+\\beta^\\prime-\\delta^\\prime+m)}\n\\times\n{_2F_1}\\left(\\alpha^\\prime + m,\n                \\beta^\\prime,\n                1+\\alpha^\\prime+\\beta^\\prime-\\delta^\\prime+m;\n                1-z\\right),\n\\end{align}\nwhere we have now included the necessary prefactors,\nis a numerically stable solution of the recurrence\nrelation~\\eq{eq:chosen_rec_rel} if the recursion is run\nfrom large $m$ to small $m$.\n\nLet us finally outline the complete procedure as an algorithm to be implemented:\n\\begin{enumerate}\n\\item Compute the value of ${_2F_1}$ for the two\nlargest $m$ values of interest using arbitrary precision arithmetic.\n\\item Compute the prefactors to construct\n$y_{4,\\text{max}(m)}$ and $y_{4,\\text{max}(m)-1}$.\n\\item Recursively compute $y_{4,m}$ for all $m$ less than $\\text{max}(m)$ down\nto $m=0$.\n\\item Cancel off the prefactors of the resulting values of\n$y_{4,m}$ for all $m$ to produce ${_2F_1}$ for all desired $m$ values.\n\\end{enumerate}\n\nWith ${_2F_1}$ computed, the only remaining numerical danger in computing\n$p(m)$ in~\\eq{eq:p_m_bursty+rep_appdx} is overflow of the gamma functions.\nThis is easily solved by taking the log of the entire expression\nand using standard routines to compute the log of the gamma functions,\nthen exponentiating the entire expression at the end if $p(m)$\nis needed rather than $\\log p(m)$.", "meta": {"hexsha": "c12719de15082779a6b151c8c0b985e94a1aad1f", "size": 43032, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/appendix_02_bursty.tex", "max_stars_repo_name": "RPGroup-PBoC/bursty_transcription", "max_stars_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/appendix_02_bursty.tex", "max_issues_repo_name": "RPGroup-PBoC/bursty_transcription", "max_issues_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/appendix_02_bursty.tex", "max_forks_repo_name": "RPGroup-PBoC/bursty_transcription", "max_forks_repo_head_hexsha": "cd3082c567168dfad12c08621976ea49d6706f89", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.5987841945, "max_line_length": 88, "alphanum_fraction": 0.69299591, "num_tokens": 14174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.40186262440436027}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage{amsfonts}\n\\usepackage{bm}\n\n% bold math italic font\n\\newcommand{\\mbf}[1]{\\mbox{\\boldmath $#1$}}\n\n% symbol used for sqrt(-1)\n\\newcommand{\\Ci}{{\\rm i}}\n\n\\newcommand{\\C}{\\mathbb{C}}\n\\newcommand{\\R}{\\mathbb{R}}\n\n\\newcommand{\\var}{\\rm Var}\n\\newcommand{\\trace}{\\rm Tr}\n\n\\newcommand{\\code}[1]{{\\tt{#1}}}\n\n\\newcommand{\\rotation}[3]{{\\ensuremath{ {\\bf R}^{#3}_{#1}({#2}) }}}\n\\newcommand{\\rotat}[1][\\bm{\\hat{n}}]{\\rotation{#1}{\\phi}{ }}\n\n\\newcommand{\\boost}[1][m]{{\\ensuremath{ {\\bf B}_{\\bm{\\hat {#1}}}(\\beta) }}}\n\n\\newcommand{\\pauli}[1]{\\ensuremath{ {\\bm\\sigma}_{\\rm #1} }}\n\\newcommand{\\para}[1][ ]{\\ensuremath{ {\\Phi}_{{\\rm PA}{#1}} }}\n\n\\newcommand{\\model}[1][ ]{\\ensuremath{{\\bm\\rho}_j({{\\bf T}_{#1}};{\\mbf{a}}) }}\n\\newcommand{\\obs}{\\ensuremath{ {\\bm\\rho}_{j,i} }}\n\n\\begin{document}\n\n\\section{Introduction}\n\nThe document discusses the general problem of determining the\npolarimetric response of a system using a number of unknown input\npolarization states.  In the case of pulsar observations, the unknown\ninput states are any number of the on-pulse phase bins of the\npolarimetric pulse profile.\n\nLet $M$ be the number of polarization states under consideration.  The\nunknown input states, $\\{\\bm\\rho_j; 1\\le j\\le M\\}$, are transformed by\nboth a known transformation, {\\bf T}, and the unknown transformation\nof the system response, {\\bf J}.  In the case of pulsar observations\nat multiple parallactic angles, the known transformation, {\\bf T}, is\nequal to a rotation about the Stokes V axis by the parallactic angle,\n\\para.\n\nLet $N$ be the number of observations made, each at a different epoch.\nFor each observation, there exists a known transformation, ${\\bf\nT}_i$, and a set of measured output states, $\\{\\obs; 1\\le j\\le M\\}$.\n\nThe model to be fitted must predict the value for each of the measured\noutput states, given the known transformation, {\\bf T}.  Let this model\nbe represented by\n\\begin{equation}\n\\model; \\;\\; 1\\le j\\le M\n\\end{equation}\nwhere $\\bm{a}$ is a vector of scalar model parameters describing both\nthe system response and the set of $M$ input states.  This\nparameterization will be discussed in the next section.  The best-fit\nmodel will minimize the $\\chi^2$ merit function\n\\begin{equation}\n\\chi^2(\\bm{a}) = \\sum_{i=1}^N {1\\over\\sigma_i^2} \\sum_{j=1}^M\n\t{\\var[\\obs - \\model[i])]}\n\\end{equation}\nwhere \\obs\\ is the $i$th observation of the $j$th\npolarization state, and $\\var({\\bf M})$ is the square of the Frobenius\nnorm, given by\n\\begin{equation}\n\\var({\\bf M})=\\trace({\\bf M}{\\bf M}^\\dagger).\n\\end{equation}\nHere, $\\trace({\\bf M})$ is the matrix trace and ${\\bf M}^\\dagger$ is the\nHermitian transpose.  The gradient of $\\chi^2$ with respect to the\nparameters $\\bm{a}$ has components\n\\begin{equation}\n{\\partial\\chi^2\\over\\partial a_k} = -2 \\sum_{i=1}^N {1\\over\\sigma_i^2}\n\t\\sum_{j=1}^M \\trace\\left( [\\obs - \\model[i]]\n\t{\\partial\\model[i]\\over\\partial a_k} \\right)\n\\end{equation}\n(Note that $\\bm\\rho=\\bm\\rho^\\dagger$, $\\trace({\\bf A}+{\\bf B})=\\trace({\\bf\nA})+\\trace({\\bf B})$, and $\\trace({\\bf AB})=\\trace({\\bf BA})$.)\nTaking an additional partial derivative gives\n\\begin{equation}\n{\\partial^2\\chi^2\\over\\partial a_l\\partial a_k} = \n\t2 \\sum_{i=1}^N {1\\over\\sigma_i^2} \\sum_{j=1}^M \\trace({\\bf D}_{i,j})\n\\end{equation}\nwhere\n\\begin{equation}\n{\\bf D}_{i,j} = \n{\\partial\\model[i]\\over\\partial a_l} {\\partial\\model[i]\\over\\partial a_k}\n\t- [\\obs - \\model[i]] {\\partial^2\\model[i]\\over\\partial a_l\\partial a_k}\n\\end{equation}\nReferring to the discussion in Numerical Recipes, $\\S 15.5$\n(hereafter, NR), it is conventional to ignore the second derivatives\nof \\model[i].  Furthermore, by adopting the NR notation, wherein\n\\begin{equation}\n\\beta_k = \\sum_{i=1}^N {1\\over\\sigma_i^2}\\sum_{j=1}^M \\trace\\left(\n\t[\\obs - \\model[i]] {\\partial{\\bm\\rho}\\over\\partial a_k}\\right)\n\\end{equation}\nand\n\\begin{equation}\n\\alpha_{lk} = \\sum_{i=1}^N {1\\over\\sigma_i^2}\\sum_{j=1}^M\n\t\\trace\\left( {\\partial\\model[i]\\over\\partial a_l}\n\t\t{\\partial\\model[i]\\over\\partial a_k} \\right) = \\alpha_{kl}\n\\end{equation}\nthe least-squares minimization problem may be reduced to that of\nfinding the partial derivatives of the matrix function, \\model, with\nrespect to its scalar parameters $a_k$.\n\n\n\n\\section{Parameterization of the Model}\n\nLet the model of the system response be represented by the $2\\times2$\ncomplex Jones matrix, ${\\bf J}$, and the model of each of the input states\nbe represented by the set of coherency matrices, $\\{\\bm\\rho_j; 1\\le j\\le M\\}$,\nso that\n\\begin{equation}\\label{eqn:model}\n\\model = {\\bf JT}{\\bm\\rho}_j{\\bf T}^\\dagger{\\bf J}^\\dagger\n\\end{equation}\nAn arbitrary matrix, ${\\bf J}$, may be represented by its polar decomposition,\n\\begin{equation}\n{\\bf J} = J \\; \\boost \\rotat\n\\end{equation}\nwhere $J=(\\det{\\bf J})^{1/2}$, \\boost\\ is a Hermitian matrix (or boost\ntransformation) and \\rotat\\ is a unitary matrix (or rotation\ntransformation).  As shown by Euler, any rotation about an arbitrary\naxis may be decomposed into a series of rotations about three\nperpendicular axis.  Furthermore, it can be trivially shown that if\n{\\bf J} satisfies Equation~\\ref{eqn:model}, then so does\n${\\bf J}^\\prime = e^{i\\phi}{\\bf J}$.  Therefore, the phase information of the\ncomplex-valued $J$ may be arbitrarily chosen, and $J$ may be replaced by the\nreal-valued gain, $G=|J|$, so that the system response may be\nparameterized by\n\\begin{equation}\n{\\bf J} = G \\; \\boost \\prod_{i=1}^3 \\rotation{i}{\\phi_i}{ }.\n\\label{eqn:polar_decomposition}\n\\end{equation}\nReferring to Britton (2000) or Hamaker (2000):\n\\begin{eqnarray}\\label{eqn:boost}\n\\boost &=& \\bm{\\sigma}_0\\cosh\\beta + \\bm{\\hat{m}\\cdot\\sigma}\\sinh\\beta, \\\\\n\\rotation{i}{\\phi_i}{ } &=& \\bm{\\sigma}_0\\cos\\phi_i + i\\bm{\\sigma}_i\\sin\\phi_i.\n\\label{eqn:rotation}\n\\end{eqnarray}\nThe coherency matrix of each input polarization state is given by\n\\begin{equation}\\label{eqn:stokes}\n{\\bm\\rho}_j = {1\\over2}\\sum_{i=0}^3 S_{i,j}\\bm{\\sigma}_i\n\\end{equation}\nwhere $S_i$ are the Stokes parameters.\nBy defining $\\bm{b}=(b_1,b_2,b_3)=\\bm{\\hat{m}}\\sinh\\beta$, the model of\nthe receiver and source polarization states is completely specified by $G$,\n$b_{1-3}$, $\\phi_{1-3}$, and $\\{S_{0-3}\\}_j$.\n\n\n\\subsection{Partial Derivatives}\nReferring to Equations~\\ref{eqn:boost} to~\\ref{eqn:stokes} and the definition\nof $\\bm{b}$, the partial derivatives of the model may be derived without\nany ``small value'' approximations:\n\\begin{equation}\n{\\partial\\boost\\over\\partial b_i} =\n\t\\bm{\\sigma}_0{b_i\\over\\sqrt{1+|\\bm{b}|}} + \\bm{\\sigma}_i\n\\end{equation}\n\n\\begin{equation}\n{\\partial\\rotation{i}{\\phi_i}{ }\\over\\partial \\phi_i} = \n\t-\\bm{\\sigma}_0\\sin\\phi_i + i\\bm{\\sigma}_i\\cos\\phi_i.\n\\end{equation}\n\n\\begin{equation}\n{\\partial{\\bm\\rho}_j\\over\\partial S_{i,j}} = {\\bm{\\sigma}_i\\over2}\n\\end{equation}\n\n\n\\section{Degeneracy under Commutation}\n\nUsing the multiplication rule\n\\begin{equation}\n\\bm{AB}=(a\\bm{\\sigma}_0+\\bm{a\\cdot\\sigma})(b\\bm{\\sigma}_0 + \\bm{b\\cdot\\sigma})\n= ab + \\bm{a\\cdot b} + (a\\bm{b} + b\\bm{a} + \\Ci \\bm{a\\times b})\\bm{\\cdot\\sigma}\n\\end{equation}\nit can be seen that $\\bm{A}$ and $\\bm{B}$ commute\n(ie. $\\bm{AB}=\\bm{BA}$) when $\\bm{a}$ and $\\bm{b}$ are parallel (so\nthat $\\bm{a\\times b}=0$).  This observation enables simple statements to\nbe made regarding the uniqueness of any solution.\n\nConsider the observation of source polarization states at multiple\nparallactic angles.  In this case, the transformation, {\\bf T}, is\ngiven by a rotation about the V-axis:\n\\begin{equation}\n{\\bf T}=\\rotation{3}{\\Phi_{\\rm PA}}{ } = \\bm{\\sigma}_0\\cos\\Phi_{\\rm PA}\n\t + i\\bm{\\sigma}_3\\sin\\Phi_{\\rm PA}.\n\\end{equation}\nAn arbitrary matrix of the form, ${\\bf U}_3= u_0\\bm{\\sigma}_0 +\nu_3\\bm{\\sigma}_3$ commutes freely with $\\rotation{3}{\\Phi_{\\rm PA}}{\n}$.  If ${\\bf U}_3$ has unit determinant, and if {\\bf J} and\n${\\bm\\rho}_j$ satisfy Equation~\\ref{eqn:model}, namely\n\\begin{equation}\n{\\bm\\rho}^\\prime_j = {\\bf J}\\rotation{3}{\\Phi_{{\\rm PA},i}}{ }{\\bm\\rho}_j{\\rotation{3}{\\Phi_{{\\rm PA},i}}{ }}^\\dagger{\\bf J}^\\dagger\n\\end{equation}\nthen \n\\begin{equation}\n{\\bf J}_u = {\\bf JU}_3 \\hspace{1cm} {\\rm and} \\hspace{1cm}\n{\\bm\\rho}_{j,u} = {\\bf U}^{-1}_3{\\bm\\rho}_j{\\bf U}^{\\dagger-1}_3\n\\end{equation}\nare also solutions to this equation.  This degeneracy exists\nregardless of the parameterization of {\\bf J} or ${\\bm\\rho}_j$,\nproving that there is no unique solution to the pulsar\nself-calibration problem based solely on observations of the pulsar at\nmultiple parallactic angles.\n\n\\subsection{Additional Constraints}\n\nThe arbitrary matrix, ${\\bf U}_3$, may also be decomposed into a boost\nalong the Stokes V axis and a rotation about this axis.  As shown by\nHamaker, an observation of an unpolarized source may be used to\ncompletely constrain the boost component of the system response.  In\naddition to constraining the boost along Stokes V, such additional\ninformation may also be used to allow the system gain (and\ndifferential gain) to vary from observation to observation.\n\nThe rotation about the Stokes V axis will remain unconstrained unless\na source with a well-known position angle (and rotation measure) can\nbe observed.\n\n\\end{document}\n\n", "meta": {"hexsha": "1cf3900976324f2cba84ed5b7eb89532b8b60ba0", "size": 9094, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "More/Polarimetry/ReceptionModel.tex", "max_stars_repo_name": "xuanyuanstar/psrchive_CDFT", "max_stars_repo_head_hexsha": "453c4dc05b8e901ea661cd02d4f0a30665dcaf35", "max_stars_repo_licenses": ["AFL-2.1"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "More/Polarimetry/ReceptionModel.tex", "max_issues_repo_name": "xuanyuanstar/psrchive_CDFT", "max_issues_repo_head_hexsha": "453c4dc05b8e901ea661cd02d4f0a30665dcaf35", "max_issues_repo_licenses": ["AFL-2.1"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "More/Polarimetry/ReceptionModel.tex", "max_forks_repo_name": "xuanyuanstar/psrchive_CDFT", "max_forks_repo_head_hexsha": "453c4dc05b8e901ea661cd02d4f0a30665dcaf35", "max_forks_repo_licenses": ["AFL-2.1"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-02-13T20:08:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-13T20:08:14.000Z", "avg_line_length": 40.0616740088, "max_line_length": 132, "alphanum_fraction": 0.7015614691, "num_tokens": 3053, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4018626189245779}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\marginpar{Monday\\\\ 2021-6-14, \\\\ compiled \\\\ \\today}\n\nLast time we discussed the STF decomposition as a way to do spherical harmonics in Cartesian coordinates. \n\nThe very nice thing is that the general solutions we find in this way are not only valid for flat spacetime: if we substitute the stress-energy tensor appropriately (including the Isaacson tensor), we can apply them to any background. \n\n\\section{Multipolar expansion and tensor spherical harmonics}\n\nThe TT expression is \n%\n\\begin{align}\nh_{ij}^{TT} = \\frac{G}{c^{4}} \\frac{1}{r} \\Lambda_{ij}^{kl} \\sum _{a=0} \\frac{1}{a!} \\partial_{t}^{a} S^{kl i_1 \\dots i_a} (u) n_{i_1 } \\dots n_{i_a}\n\\,,\n\\end{align}\n%\nwhere \n%\n\\begin{align}\nS^{kl i_1 \\dots i_a} \\sim \\int \\dd[3]{x} T^{kl} x^{i_1 } \\dots x^{i_a}\n\\,.\n\\end{align}\n\nThere is a STF formula which we discussed last time. \n\nFinally, there is a tensor spherical harmonics expression: \n%\n\\begin{align}\nh_{ij}^{TT} = \\frac{G}{c^{4}} \\frac{1}{r} \\sum _{\\ell=2} sum_{m= - \\ell}^{\\ell} \\qty[\n    u_{\\ell m} (n) \\qty(Y^{E2}_{\\ell m})_j (\\theta , \\varphi )\n    + \n    v_{\\ell m} (n) \\qty( Y^{B2}_{\\ell m})_{ij} (\\theta , \\varphi )\n]\n\\,,\n\\end{align}\n%\nwhere the \\(Y\\) are called tensor spherical harmonics, of electric and magnetic type, while the \\(u\\) and \\(v\\) are coefficients. \n\nThe relation between these three expression is as follows: using the orthogonality property of the \\(Y_{\\ell m}\\) we can extract the coefficients. \nA sketch of the calculation is as follows, if \\(1a\\), \\(1b\\) and \\(1c\\) are the three alternative expressions: \n%\n\\begin{align}\n\\int (1a) \\qty(Y^{E2}_{\\ell m})_{ij}^{*} \\dd{\\Omega } = \n\\int (1c) \\qty(Y^{E2}_{\\ell m})_{ij}^{*} \\dd{\\Omega } = u_{\\ell m}\n\\,,\n\\end{align}\n%\nwhose first component will read \n%\n\\begin{align}\n\\sum _{a=0} \\frac{1}{a!} \\partial^{a}_{t} S^{k \\ell i_1 \\dots i_a} \n\\underbrace{\\int \\dd{\\Omega } \\qty(Y^{E2}_{\\ell m})^{*}_{ij} \\Lambda_{ij}^{k \\ell} n_{i_1 } \\dots n_{i_a}}_{= \\mathcal{Y}_{i_1 \\dots i_a}^{\\ell m *} + \\order{c^{-2}}}\n\\,,\n\\end{align}\n%\nwhere the brace identification is the result of a long calculation. \n\nThe result is then \n%\n\\begin{align}\n\\sum _{a=0} \\frac{1}{a!} \\partial_{t}^{a} S^{k \\ell i_1 \\dots i_a} \\mathcal{Y}^{\\ell m *}_{i_1 \\dots i_ a} = \n\\dv[\\ell]{u} M^{i_1 \\dots i_\\ell} \\mathcal{Y}^{\\ell m *}_{i_1 \\dots i_\\ell} \\sim\n\\int \\dd[3]{x} r^{\\ell} T^{00} Y_{\\ell m}^{*}\n\\,.\n\\end{align}\n\nThinking ``quantum mechanically'', we have \\(\\vec{J} = \\vec{L} + \\vec{S}\\). We define the Tensor Spherical Harmonics \\(Y\\) of a field of spin \\(s\\) as the simultaneous eigenfunctions of these operators: neglecting indices for the moment, we have\n%\n\\begin{align}\nJ^2 Y &= j (j+1) Y \\\\\nJ_z Y &= j_z Y \\\\\nL^2 Y &= L (L+1) Y \\\\\nS^2 Y &= s (s+1) Y\n\\,.\n\\end{align}\n\nIn the spin-\\(1/2\\) case this is a spinor.\n\nThese objects read \n%\n\\begin{align}\n\\ket{j j_z} = \\sum _{L_z = -L}^{L} \\sum _{s_z = -s}^{s} \\braket{L L_z s s_z}{j s_z} \\ket{L L_z s s_z}\n\\,,\n\\end{align}\n%\nand the total angular momentum obeys \\(\\abs{L -s} \\leq j \\leq L + s\\). \n\nHow do we construct these eigenfunctions? We take the scalar eigenfunctions of the angular momentum \n%\n\\begin{align}\nL^2 Y_{L L_z} = L (L+1) Y_{L L_z}\n\\,,\n\\end{align}\n%\nand the spin eigenfunctions (ignoring indices)\n%\n\\begin{align}\nS^2 X_{s s_z} = s (s+1) X_{s s_z}\n\\,,\n\\end{align}\n%\nwe can make use of the Clebsh-Gordan coefficients: \n%\n\\begin{align}\nY = \\sum _{L_z} \\sum _{s_z} \\braket{L L_z s s_z}{j s_z} Y_{L L_z} X_{S S_z}\n\\,.\n\\end{align}\n\nLet us particularize to the spin-\\(1/2\\) case, in which \\(X_{1/2} = \\qty{ (0,1)^{\\top}, (1, 0)^{\\top}}\\). \nThe vector spherical harmonics are \n%\n\\begin{align}\nX_{1 \\pm 1} = \\mp \\frac{1}{\\sqrt{2}} \\qty(\\hat{x} \\pm i \\hat{y})\n\\,,\n\\end{align}\n%\nwhile \\(X_{10} = \\hat{z}\\). \n\nThe solutions of \\(\\square v^{i} = 0\\) can be represented as an expansion in \\(Y_{s=1}\\). \nThese harmonics are usually combined in a new orthonormal basis: \n%\n\\begin{align}\nY^{R}_{j j_z} &= \\sqrt{2 j + 1} \\qty[ j^{1/2} Y^{j-1}_{j j_z} - (j+1)^{1/2} Y^{j+1}_{j j_z}] = Y_{j j_z} \\hat{n} \\\\\nY^{E}_{j j_z} &= \\sqrt{2j+1} \\qty[ (j+1)^{1/2} Y^{j-1}_{j j_z} + j^{1/2} Y^{j+1}_{j j_z}] = \\sqrt{j (j+1)} r \\cdot \\nabla Y_{j j_z} \\\\\nY^{B}_{j j_z} &= i Y^{j}_{j j_z} = \\hat{n} \\times Y^{E}_{j j_z}\n\\,.\n\\end{align}\n\nThe direction along the propagation direction \\(\\hat{n}\\) is longitudinal, and orthogonal to it we have electric and magnetic types. \nUnder parity the electric type transforms as \\((-)^{\\ell}\\), the magnetic type transforms as \\((-)^{\\ell +1}\\).\n\nIn terms of notation, we move from \\((j, j_z)\\) to \\(\\ell, m\\). \n\nThe solution of the vector wave operator reads \n%\n\\begin{align}\nV^{i} (t, r, \\theta , \\varphi ) = \\sum _{\\ell = 0} \\sum _{m=- \\ell}^{\\ell} R_{\\ell m}(t, r) \\qty(Y^{R}_{\\ell m} (\\theta , \\varphi ))^{i}\n+ \\sum _{\\ell} \\sum _{m} E_{\\ell m}(t, r) \\qty(Y^{E}_{\\ell m}(\\theta , \\varphi ))^{i} +  \n\\sum _{\\ell} \\sum _{m} B_{\\ell m} \\qty(Y^{B}_{\\ell m}(\\theta , \\varphi ))^{i} \n\\,.\n\\end{align}\n\nHow do we use this for electromagnetism?\nThe vector potential \\(A^{i}\\) is described by such a vector SH decomposition, with \\(R_{\\ell m} = 0\\), while  \\(E_{\\ell m}\\) and \\(B_{\\ell m}\\) are the components of the electromagnetic field. \n\nFor the spin-2 case we have harmonics going from \\(Y^{j-2}\\) to \\(Y^{j + 2}\\). \nThese can be used to make a new orthornormal basis: \n%\n\\begin{align}\nY^{S0}_{\\ell m}, \nY^{E1}_{\\ell m}, \nY^{E2}_{\\ell m}, \nY^{B1}_{\\ell m}, \nY^{B2}_{\\ell m}, \n\\,.\n\\end{align}\n\nThe generic 2-tensor is a combination of these, but since the graviton is massless only the two transverse ones matter --- E2 and B2. \n\nGW have a \\(h_+\\) and \\(h_\\times \\) polarization --- these are precisely related to these two fundamental transverse modes. \n\nIn alternative theories of gravity this might not be the case; there can be up to 6 multipole polarizations. \n\nThe geodesic deviation equation reads \n%\n\\begin{align}\n\\ddot{x}_{i} = - R_{0i0j}x^{j} =  S_{ij} x^{i} =\n\\left[\\begin{array}{ccc}\nA_S + A_+ & A_\\times  & A_1 \\\\ \n0 & A_S - A_+ & A_2 \\\\ \n0 & 0 & A_L\n\\end{array}\\right] x^{j}\n\\,.\n\\end{align}\n\nIn the regular GR case we only have \\(A_+\\) and \\(A_\\times \\); in an alternative metric theory of gravity the other 4 polarizations may be nonzero. \n\nThis is something which can be tested with a network of interferometers! \n\n\\end{document}\n", "meta": {"hexsha": "6768094ea499ff20a722402203769f99eb48b0dc", "size": 6319, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "phd_courses/gravitational_waves/jun14.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "phd_courses/gravitational_waves/jun14.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "phd_courses/gravitational_waves/jun14.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 34.5300546448, "max_line_length": 245, "alphanum_fraction": 0.6301630005, "num_tokens": 2376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4018626189245779}}
{"text": "% easychair.tex,v 3.5 2017/03/15\n\n\\documentclass{easychair}\n%\\documentclass[EPiC]{easychair}\n%\\documentclass[EPiCempty]{easychair}\n%\\documentclass[debug]{easychair}\n%\\documentclass[verbose]{easychair}\n%\\documentclass[notimes]{easychair}\n%\\documentclass[withtimes]{easychair}\n%\\documentclass[a4paper]{easychair}\n%\\documentclass[letterpaper]{easychair}\n\\usepackage{fullpage}\n\\usepackage[]{minted}\n\\usepackage{amsmath,amsthm}\n\n\n\\newmintinline[icoq]{coq}{}\n\\setminted[coq]{escapeinside=\\#\\#,mathescape=true} %,fontsize=\\footnotesize}\n\\newtheorem{example}{Example}\n\n%\n\\title{À la Nelson-Oppen Combination for \\icoq{congruence}, \\icoq{lia} and \\icoq{lra}}\n%\n\\author{ Frédéric Besson}\n\n% Institutes for affiliations are also joined by \\and,\n\\institute{Inria, Rennes, France}\n\n\\authorrunning{F. Besson}\n\n\\titlerunning{À la Nelson-Oppen Combination for \\icoq{congruence}, \\icoq{lia} and \\icoq{lra}}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n  We propose a tactic for combining decision procedures using a\n  black-box Nelson-Oppen scheme.\n  %\n  The tactic is instantiated for \\icoq{congruence} and either \\icoq{lia} or \\icoq{lra}.\n  %\n  The development is available at \\url{https://gitlab.inria.fr/fbesson/itauto}.\n\\end{abstract}\n\n\n\\section{Introduction}\n\\label{sect:introduction}\n\nThe Coq proof-assistant provides decision procedures for various logic\nfragments. In practice, most of the goals do not fall in those\nrestricted fragments and, in that case, an interactive proof is\nrequired.\n%\nHowever, there is sometimes a sweet spot when the goal can be solved by a\ncollaboration of decision procedures.\n%\nFor instance, \\icoq{intuition tac} enhances the expressive power of a\ntactic \\icoq{tac} by providing support for propositional logic.  Our\nrecent \\icoq{itauto tac}~\\cite{Itauto} shares the same goal but aims at improving the\ncompleteness and efficiency of the combination.\n%\n\nUnfortunately, there is currently no support for solving goals that are\nexpressed in the combined decidable logic fragments of EUF~\\cite{Ackermann} (Equality Logic with\nUninterpreted Functions) and LIA~\\cite{presburger} (Linear Integer Arithmetic).\n%\nYet, \\icoq{congruence}\\footnote{\\url{https://coq.inria.fr/distrib/V8.13.0/refman/proofs/automatic-tactics/logic.html\\#coq:tacn.congruence}}~\\cite{Corbineau06} subsumes EUF and \\icoq{lia}\\footnote{\\url{https://coq.inria.fr/distrib/V8.13.0/refman/addendum/micromega.html\\#coq:tacn.lia}}~\\cite{BessonCP11,Besson06} solves LIA.\nMoreover, Nelson and Oppen~\\cite{NelsonO79} propose a combination scheme which is complete for the combination EUF+LIA.\n\nIn the following, we present our \\icoq{smt}\ntactic\\footnote{\\url{https://gitlab.inria.fr/fbesson/itauto}} which implements the Nelson-Oppen combination scheme in a black-box manner.\n\n\\section{Motivating Example}\nThe crux of the Nelson-Oppen scheme is that equality sharing is\nsufficient\\footnote{Under technical conditions that are not detailed here} for\na complete combination of two decidable theories  when\nthe unique shared symbol is equality. The following example\nillustrates a somewhat painful interactive proof that is automated by our\n\\icoq{smt} tactic.\n\\begin{example}\n  \\label{exa:motivating}\n  Consider the following goal.\n\\begin{minted}{coq}\nGoal #$\\forall$# (x y: Z) (P:Z -> Prop), x :: nil = y + 1 :: nil -> P (x - y) -> P 1.\n\\end{minted}\nNeither \\icoq{congruence} nor \\icoq{lia} solves the goal. Yet, it can\nbe solved by only asserting equalities that are solved by either \\icoq{congruence} or \\icoq{lia}.\nThis is illustrated by the following proof script.\n\\begin{minted}{coq}\nProof. intros. assert (x = y+1) by congruence. assert (x-y = 1) by lia. congruence. Qed.\n\\end{minted}\n\\end{example}\n\n\\section{Nelson-Oppen Algorithm}\nThe first task of the \\icoq{smt} tactic is the so-called\n\\emph{purification} phase which identifies terms that are shared across\ntheories. The second task consists in propagating equalities between\n\\emph{pure} terms until the goal is solved. These two phases are implemented\nas an OCaml plugin.\n\n\\paragraph{Purification}\nThe \\emph{purification} introduces fresh variables and\nequations so that every term belongs to one and only one theory.\nFor Example~\\ref{exa:motivating}, we would obtain the following goal.\n\\begin{minted}{coq}\n  hpr1 : 1 = pr1,  hpr3 : y + pr1 = pr3,  hpr2 : x - y = pr2\n  H  : x :: nil = pr3 :: nil,  H0 : P pr2\n  ==========================================================\n  P pr1\n\\end{minted}\nThe set of potential equations is then defined as\n$\n\\{ x = y \\mid (x,y) \\in \\mathit{Var} \\times \\mathit{Var} \\}\n$\nwhere $\\mathit{Var} = \\{\\icoq{pr1},\\icoq{pr2}, \\icoq{pr3}, \\icoq{x} \\}$.\n%\nThe set of variables contains fresh variables but also the existing\nvariables that are at the interface between the two theories.  Here,\nthe variable \\icoq{x} is an arithmetic variable using as argument of\nthe constructor \\icoq{::}.\n\n\\paragraph{Theory Description} In order to perform the purification\nphase, it is necessary to have the signature of the theory that is combined with EUF\n\\emph{i.e.}, the set of arithmetic types and operators.\n%\nThis is done by declaring instances of the two following type-classes.\n\\begin{minted}{coq}\nClass TheoryType(Tid:Type)(T:Type):Type. Class TheorySig(Tid:Type){T:Type}(Op:T):Type.\n\\end{minted}\nNote that the type-classes are parametrised by an uninterpreted type\n\\icoq{Tid} that only used to identify a theory. In our case, \\icoq{ZarithThy} is associated to\n\\icoq{lia} and \\icoq{RarithThy} is associated to \\icoq{lra}.\n\n\\paragraph{Equality Sharing} Our current Nelson-Oppen tactic is binary and can combine\n\\icoq{congruence} with either \\icoq{lia} or \\icoq{lra}.\n%\nAfter purification, we recursively try to prove one of the equality\nusing either \\icoq{congruence} or the arithmetic tactic.  If tactic\n$T_1$ succeeds at asserting an equation, we try to solve the goal\nusing tactic $T_2$. If $T_2$ fails, we iterate the process until none\nof the equation can be proved.\n%\nAs there is a quadratic number of possible equations, the combination\nrequires, in the worst case, a cubic number of calls to the decision\nprocedures.\n\n\\section{Conclusion and Limitations}\nOur \\icoq{smt} tactic improves automation and has the advantage of\nreusing the existing tactics \\icoq{congruence}, \\icoq{lia} and \\icoq{lra} in a\nblack-box manner. More experiments are needed to assess to what extent \nautomation is increased in practice and whether efficiency is satisfactory.\n%\nImproving efficiency would require to adapt the decision procedures so\nthat they either prove a goal or assert equations.\n%\nThough this might not be a problem in practice, our implementation is\nnot complete. LIA is a so-called \\emph{non-convex} theory which\nrequires propagating not only equalities but disjunctions of\nequalities. Moreover, \\icoq{lia} is first running \\icoq{zify}. It is\ncurrently unclear how this impacts the Nelson-Oppen scheme. \n\n\\label{sect:bib}\n\\bibliographystyle{plain}\n%\\bibliographystyle{alpha}\n%\\bibliographystyle{unsrt}\n%\\bibliographystyle{abbrv}\n\\bibliography{biblio}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-engine: default\n%%% TeX-master: t \n%%% TeX-command-extra-options: \"-shell-escape\"\n%%% mode: flyspell\n%%% ispell-local-dictionary: \"british\"\n%%% End:", "meta": {"hexsha": "3e319191a94abde396aa34bb75363a9ab600b0f0", "size": 7225, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/no.tex", "max_stars_repo_name": "proux01/itauto", "max_stars_repo_head_hexsha": "40b66e957de9a7ca075133345cbc9af4f2eadb93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/no.tex", "max_issues_repo_name": "proux01/itauto", "max_issues_repo_head_hexsha": "40b66e957de9a7ca075133345cbc9af4f2eadb93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/no.tex", "max_forks_repo_name": "proux01/itauto", "max_forks_repo_head_hexsha": "40b66e957de9a7ca075133345cbc9af4f2eadb93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-31T20:41:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T20:41:04.000Z", "avg_line_length": 40.3631284916, "max_line_length": 323, "alphanum_fraction": 0.7593079585, "num_tokens": 2089, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.603931819468636, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.4018626174519851}}
{"text": "\\documentclass[12]{scrartcl}\n\\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}\n\\usepackage{float}\n\\restylefloat{table}\n\\makeatletter\n\\newcommand\\Aboxed[1]{\n   \\@Aboxed#1\\ENDDNE}\n\\def\\@Aboxed#1&#2\\ENDDNE{%\n   &\n   \\settowidth\\@tempdima{$\\displaystyle#1{}$}\n   \\setlength\\@tempdima{\\@tempdima+\\fboxsep+\\fboxrule}\n   \\kern-\\@tempdima\n   \\boxed{#1#2}\n}\n\\makeatother\n\n\\begin{document}\n\n\\title{Homework 29, Section 5.4 2, 7, 10, 14, 18 (a formula answer is sufficient), 20, and the problem below.}\n\\author{Alex Gordon}\n\\date{\\today}\n\\maketitle\n\\section*{Homework}\n\\subsection*{2. A)}\n$C(8,6) = 28 possibilities$\n\\subsection*{2. B)}\n$Same question, so 28$\n\\subsection*{2. C)}\n$2^8 - C(8,1) = 247$\n\\subsection*{7.}\n$C(4,4) \\cdot C(7,3) \\cdot C(10,3) = 4,200$\n\\subsection*{10.}\n$C(11,2) \\cdot C(9,2) \\cdot 5 \\cdot C(7,2) = 9,989,600$\n\\subsection*{14.}\n\\begin{table}[H]\n    \\begin{tabular}{|l|l|l|}\n    \\hline\n    Fruit  & Equation        & Binary Sequence \\\\ \\hline\n    5a, 5b & 5 + 5 + 0 = 10  & 000001000001    \\\\ \\hline\n    5a, 5p & 5 + 5 + 0 = 10  & 000001100000    \\\\ \\hline\n    1a, 9p & 1 + 0 + 9 = 10  & 011000000000    \\\\ \\hline\n    10 b   & 0 + 10 + 0 = 10 & 100000000001    \\\\ \\hline\n    \\end{tabular}\n\\end{table}\n\\subsection*{18.}\n$C(49,20) =$ Some really big number I'm too lazy to copy. \n\\subsection*{The \"Problem below\" A)}\n$C(13,6) =1716$\n\\subsection*{The \"Problem below\" B)}\n$C(19,12) =50,388$\n\\subsection*{The \"Problem below\" C)}\n$C(31,24) = Some big number$\n\\subsection*{The \"Problem below\" D)}\n$C(11,4) = 330$\n\\subsection*{The \"Problem below\" E)}\n$C(15,9) = 5005$\n\\end{document}", "meta": {"hexsha": "f99e4d8fcec41bfbe0c6bfebbd314321ab1911fe", "size": 1605, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DiscreteMath/Homework29.tex", "max_stars_repo_name": "alexggordon/latex", "max_stars_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DiscreteMath/Homework29.tex", "max_issues_repo_name": "alexggordon/latex", "max_issues_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DiscreteMath/Homework29.tex", "max_forks_repo_name": "alexggordon/latex", "max_forks_repo_head_hexsha": "7dd945f33490e6585e26cff39d9cf6ad8f582a0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1578947368, "max_line_length": 110, "alphanum_fraction": 0.6261682243, "num_tokens": 700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4018626149173877}}
{"text": "\\documentclass{article}\n    % General document formatting\n    \\usepackage[margin=0.7in]{geometry}\n    \\usepackage[parfill]{parskip}\n    \\usepackage[utf8]{inputenc}\n    \\usepackage{amsmath}\n    \\usepackage{amssymb}\n    \\usepackage{tikz}\n    \\usepackage{fancyhdr}\n    \\usepackage{listings}\n\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Edgar Jacob Rivera Rios - A01184125}\n\n\\begin{document}\n\\begin{titlepage}\n\n    \\newcommand{\\HRule}{\\rule{\\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here\n\n    \\center % Center everything on the page\n\n    %----------------------------------------------------------------------------------------\n    %\tHEADING SECTIONS\n    %----------------------------------------------------------------------------------------\n\n    \\textsc{\\LARGE Tecnológico de Monterrey}\\\\[1.5cm] % Name of your university/college\n    \\textsc{\\Large Fundamentos de computación}\\\\[0.5cm] % Major heading such as course name\n    %\\textsc{\\large Minor Heading}\\\\[0.5cm] % Minor heading such as course title\n\n    %----------------------------------------------------------------------------------------\n    %\tTITLE SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\HRule \\\\[0.4cm]\n    { \\huge \\bfseries Homework 6}\\\\[0.4cm] % Title of your document\n    \\HRule \\\\[1.5cm]\n\n    %----------------------------------------------------------------------------------------\n    %\tAUTHOR SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\begin{minipage}{0.4\\textwidth}\n    \\begin{flushleft} \\large\n    \\emph{Student:}\\\\\n    Jacob \\textsc{Rivera} % Your name\n    \\end{flushleft}\n    \\end{minipage}\n    ~\n    \\begin{minipage}{0.4\\textwidth}\n    \\begin{flushright} \\large\n    \\emph{Professor:} \\\\\n    Dr. Hugo \\textsc{Terashima} % Supervisor's Name\n    \\end{flushright}\n    \\end{minipage}\\\\[2cm]\n\n    % If you don't want a supervisor, uncomment the two lines below and remove the section above\n    %\\Large \\emph{Author:}\\\\\n    %John \\textsc{Smith}\\\\[3cm] % Your name\n\n    %----------------------------------------------------------------------------------------\n    %\tDATE SECTION\n    %----------------------------------------------------------------------------------------\n\n    {\\large \\today}\\\\[2cm] % Date, change the \\today to a set date if you want to be precise\n\n    %----------------------------------------------------------------------------------------\n    %\tLOGO SECTION\n    %----------------------------------------------------------------------------------------\n\n    \\includegraphics[width=0.4\\textwidth,height=\\textheight,keepaspectratio]{logo-tec-negro.png} % Include a department/university logo - this will require the graphicx package\n\n    %----------------------------------------------------------------------------------------\n\n    \\vfill % Fill the rest of the page with whitespace\n\n\\end{titlepage}\n\n\n\\section{Problems}\nSolve the following problems:\n\\begin{enumerate}\n    \\item For the selection algorithm, analyze and discuss the resulting complexity when the initial list is divided into groups of 19 elements (instead of 15). Derive the proper conclusions.\\\\\n    The base equations are changed ass follows:\n    \\begin{align*}\n        T(n) &= 58\\frac{n}{19} + T'(n)\\\\\n        T'(n) &= T(\\frac{n}{19}) + 3(\\frac{n}{19}) + 19(\\frac{1}{2})(\\frac{n}{38}) + T'(\\frac{3}{4}n)\\\\\n        T'(n) &= 58\\frac{n}{19^2} + T'(\\frac{n}{19}) + 3(\\frac{n}{19}) + 19(\\frac{1}{2})(\\frac{n}{38}) + T'(\\frac{3}{4}n)\\\\\n        T'(n) &= 0.16066n +0.15789n + 0.25n + T'(\\frac{n}{19}) + T'(\\frac{3}{4}n)\\\\\n        T'(n) &= 0.56855n + T'(\\frac{n}{19}) + T'(\\frac{3}{4}n)\\\\\n        \\alpha n &=0.56855n + \\alpha \\frac{n}{19} + \\alpha \\frac{3}{4}n\\\\\n        \\alpha &=0.56855 + \\frac{\\alpha}{19} + \\alpha \\frac{3}{4}\\\\\n        \\alpha &= 2.88\\\\\n        T'(n) &\\leq 2.88n\\\\\n        T(n) &= 3.05n + 2.88n = 5.93n\n    \\end{align*}\n    We can see that when the groups are contain 19 elements, the total complexity is reduced by a slight margin when compared to groups of 15 elements. We can also observe that in the 19 case, the way it's composed is different than in the 15 one. When you have 19 items in the group, the number of comparisons needed to find the quartile after broken and sorted is bigger, but the number of comparisons needed to find the $k^{th}$ quartile is smaller. This is clearly because the quartiles are bigger and for that, there are less groups to check.\n\n    \\item Given  a  set  of $n$ numbers,  we  want  to  find  the $i$ largest  in  sorted  order  using  a  comparison-based algorithm. Analyze and compare the following methods in terms of $n$ and $i$:\n    \\begin{enumerate}\n        \\item Sort the numbers, and list the $i$ largest.\\\\\n        $O(nlog(n) + i )$\n        \\item Build a max-priority queue (like a heap) with the numbers and extract the minimum $i$ items.\\\\\n        $O(nlog(n) + log(n) * i)$\n        \\item Use the k-max (session 06) to find the $i$-th largest, partition around that number, and sort the $i$ largest.\n        $O(nlog(n) + (n-i)log(n - i))$\n    \\end{enumerate}\n\n    \\item For $n$ distinct elements $x_1, x_2, ..., x_n$ with positive weights $w_1, w_2, ..., w_n$ such that $\\sum^{n}_{i=1} w_i= 1$, the weighted (lower) median is the element $x_k$ satisfying $\\sum_{x_i<x_k}w_i < \\frac{1}{2}$ and $\\sum_{x_i>x_k}w_i \\leq \\frac{1}{2}$\n\n    For example, if the elements are 0.1, 0.35, 0.05, 0.1, 0.15, 0.05, 0.2 and each element equals its weight then the median is 0.1, but the weighted median is 0.2.\n    \\begin{enumerate}\n        \\item Argue that the median of $x_1, x_2, ..., x_n$ is the weighted median of the $x_i$ with weights $w_i= 1/n$ for $i=1,2, ..., n$\\\\\n        This is true, given that the median of a set of numbers is defined as the item in the middle when the set is sorted. This means that each one of the elements is as important as the next, ignoring its value or any other metric. This means that the weight of each one would be considered as $1/n$ and using the weighted sorted algorithm with this weight would yield the same result than the classical median.\n        \\item Show how to compute the weighted median of $n$ elements in $O(nlog(n))$ worst-case using sorting.\\\\\n        For this, we would simply order the array, which gives us the term of $O(nlog(n))$ after which we would just add the weights until we find the one in which the sum surpasses 0.5, that would be the weighted median. That would take us at worst $O(n)$ time, and so the final result is that the complexity is $O(nlog(n))$.\n        \\item Show how to compute the weighted median of $n$ elements in $O(n)$ worst-case.\\\\\n        First, you have to find the lower median, using the selection algorithm, it takes $O(n)$, then you partition the array in two parts split by the median which also costs $O(n)$. Then, you sum the weights of each part and check if the results meet the criteria layed above, again $O(n)$. If true, that's the weighted median, if not, you add the accumulated cost of the lighter part to the cost of the selected median and add it to the other part. Then apply the algorithm recursively in that partition. This all adds to a complexity of $O(n)$.\n    \\end{enumerate}\n\n    \\item Investigate on how the adversary argument concept can be used to determine the lower bound of merging two ordered lists.\\\\\n    If we assume that there exists two sorted lists of size $n$, we can say that exists an algorithm $A$ that runs in $2n-2$ comparisons which merges the two lists correctly. Then, we say a list called $X$ contains the elements $x_i= 2i -1$ for $i=1$ to $n$ or odd numbers and a list $Y$ with elements $_i= 2i $ for $i=1$ to $n$ or even numbers. When we apply the algorithm $A$ in $X$ and $Y$. Because of the number of comparisons, we know that there exists an element of $X$, $x_i$ which was not compared to $y_i$ and $y_{i + 1}$. As such, there are two cases, that it was compared to $y_i$ or to $y_{i +1}$. In the first case, if we switch $x_i$ to $y_i$, the order of the lists will not be affected, but if we run the algorithm again, the resulting list will be wrong. Thus, there cannot exist any correct comparison-based algorithm that merges two sorted lists of size $n$ in less than $2n-1$ comparisons.\n\\end{enumerate}\n\\end{document}", "meta": {"hexsha": "f7e9ab65b567e3ad3c306dbdac84d562b094bda8", "size": 8340, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FirstPart/Homework6.tex", "max_stars_repo_name": "edjacob25/ComputationalFundaments", "max_stars_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FirstPart/Homework6.tex", "max_issues_repo_name": "edjacob25/ComputationalFundaments", "max_issues_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FirstPart/Homework6.tex", "max_forks_repo_name": "edjacob25/ComputationalFundaments", "max_forks_repo_head_hexsha": "6945f257eb7ed22a97350a0f3af9153ff9caf0ec", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.2580645161, "max_line_length": 909, "alphanum_fraction": 0.5924460432, "num_tokens": 2275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.4018134842966149}}
{"text": "\\documentclass{article}\n%\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath, hyperref}\n\\usepackage{fancyhdr}\n\\usepackage[title]{appendix}\n\\usepackage{enumitem}\n\\pagestyle{fancy}\n\\fancyhf{}\n\\rhead{Math - 6373}\n\\lhead{Project 2}\n\\chead{Autoencoders}\n\\rfoot{Page \\thepage}\n\\lfoot{A. Radillo}\n\\usepackage{graphicx}\n\\usepackage{xcolor}\n\\title{Autoencoders training for handwritten digits classification {\\color{blue}(version 2)} \\\\ {\\large Project 2 - Math-6373 - Prof. Azencott}}\n\\author{Adrian Radillo - PSID: 1328335}\n\\newcommand{\\bi}{\\begin{itemize}}\n\\newcommand{\\ei}{\\end{itemize}}\n\\makeatletter\n\\g@addto@macro\\@floatboxreset\\centering\n\\makeatother\n\n\\usepackage{tabularx,ragged2e,booktabs,caption}\n\\newcolumntype{C}[1]{>{\\Centering}m{#1}}\n\\renewcommand\\tabularxcolumn[1]{C{#1}}\n\n\n\\usepackage{listings}\n\\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white\n\\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue\n\\definecolor{mylilas}{RGB}{170,55,241}\n\\newcommand{\\lp}{\\left(}\n\\newcommand{\\rp}{\\right)}\n%\\usepackage{mdframed}\n\\begin{document}\n\n\n\\lstset{language=Matlab,%\n    %basicstyle=\\color{red},\n    breaklines=true,%\n    morekeywords={matlab2tikz},\n    keywordstyle=\\color{blue},%\n    morekeywords=[2]{1}, keywordstyle=[2]{\\color{black}},\n    identifierstyle=\\color{black},%\n    stringstyle=\\color{mylilas},\n    commentstyle=\\color{mygreen},%\n    showstringspaces=false,%without this there will be a symbol in the places where there is a space\n    numbers=left,%\n    numberstyle={\\tiny \\color{black}},% size of the numbers\n    numbersep=9pt, % this defines how far the numbers are from the text\n    emph=[1]{for,end,break},emphstyle=[1]\\color{red}, %some words to emphasise\n    %emph=[2]{word1,word2}, emphstyle=[2]{style},    \n}\n\n\\maketitle\n{\\color{blue}\n\\begin{description}\n\\item[Remarks:] Everything that is in blue has been added in version 2.\\\\\n\\item[GitHub:] This whole project is available at the public repository,\\\\ \\url{https://github.com/aernesto/autoencoders_MATLAB}\n\\end{description}\n}\n\n% -----------------------------------------------------------------------------------------\n% DATABASE\n% -----------------------------------------------------------------------------------------\n\\section{Database}\nI use the task and data as in project 1. This is a set of\n60,000 14x14 grayscale images of handwritten digits for the training set and\n10,000 images for the test set, all taken from the MNIST database and pre-processed by myself\nin project 1.\n% -----------------------------------------------------------------------------------------\n% Autoencoder ARCHITECTURE\n% -----------------------------------------------------------------------------------------\n\\section{Autoencoder architecture}\n\\begin{itemize}\n\\item The input and output layers have $14\\times14=196$ units. The range of each one of these units  \nis $[0,1]$ as the initial pixel intensities ranging from 0 to 255 were rescaled by 1/255.\n\\item My tentative values for $h$ are $50,100,150$ for the $h<n_1$ case, and $h=250,300,350$ for the $h>n_1$ case.\n\\end{itemize}\n% -----------------------------------------------------------------------------------------\n% FIRST EXPERIMENT\n% -----------------------------------------------------------------------------------------\n\\section{First experiment}\n\\begin{itemize}\n\\item My {\\color{blue}Software Tool (}ST{\\color{blue})} is MATLAB, and more specifically, the Neural Network Toolbox from the R2015b version. I created custom neural networks for the three small {\\color{blue}($h<n_1$)} autoencoders with the function create\\_NN() presented in appendix~\\ref{app:create}.\n\\item {\\color{blue}Below} are short and non-exhaustive descriptions of the options available in this toolbox:\n\\begin{description}\n\\item[learning] A neural network object has a property called trainFcn. This object property can be set to many \ndifferent values, which correspond to a variety of learning algorithms {\\color{blue}(see figure~\\ref{fig:trainFcn})}. The backpropagation gradient descent\nalgorithm corresponds to the name `traingd'. However, in order to update the weights after the presentation of a whole batch I believe that the name `trainb' is more appropriate. But I really struggled to find clear documentation on this\npoint. Below is a list of all the other options offered by the ST:\n\\begin{figure}[bth!]\n\\centering\n\\fbox{\\includegraphics[width=\\textwidth]{trainFcn.png}}\n\\caption{Existing built-in training functions in my ST. Taken from~\\cite{Demuth2006}}\\label{fig:trainFcn}\n\\end{figure}\n\\item[initialization] I used the `rands' initFcn property value for both the weights and the biases. This samples \nindependent values from the uniform distribution over the interval $[-1,1]$ for each weight and bias. {\\color{blue}See figure~\\ref{fig:initFcn} for a list of the other available options.}\n\\begin{figure}[bth!]\n\\centering\n\\fbox{\\includegraphics[width=\\textwidth]{initFcn.png}}\n\\caption{Existing built-in initializing functions in my ST. Taken from~\\cite{Demuth2006}. This picture only concerns the inputWeights property but `rands' exists as well for the layerWeights and biases properties.}\\label{fig:initFcn}\n\\end{figure}\n\\item[batch learning] The ideal batch learning option that would have suited my needs in the MATLAB Neural Network Toolbox is the `trainingOptions' function called for a convolutional neural network object with the stochastic gradient descent with momentum (`sgdm') solver in the R2016b release of MATLAB. However, my version of MATLAB didn't have this option,\nso I set out to produce my training batches myself (as in project 1).\n\nI produced 3,000 batches containing 500 cases each {\\color{blue}(this is the batch size)}, taken from the 60,000 cases in the training set. Consecutive\nbatches were constructed with an overlap of 100 cases, and the whole training set was used 20 times in order to \nproduce the batches. Each sweep through the training set was preceded by a shuffling of its elements order.\nI refer you to the make\\_batches.m function in the appendix of my project 1 to see the source code of this function. \nIn appendix~\\ref{app:train_diabolo} I show how the train() function from my ST was called sequentially for each batch\nin order to train my autoencoder.\n\\item[step size] The step size is controlled by the `lr' property of trainFcn property. The ST offered a learning algorithm\nbased on gradient descent with adapting learning rate (`traingda'), but I was not sure that this corresponded to \nthe equations seen in class. The `traingd' learning function, that I used, uses a fixed learning rate.\nSince I called the train() function sequentially on each batch, I only set the number of Epochs in the training properties to 1, for each iteration. Then, in between iterations, I wasn't sure whether I should change the learning rate manually, or\nif the training algorithm would do it for me. This is why there are a lot of commented lines in appendix~\\ref{app:train_diabolo}. {\\color{blue}In any case, in my code, I used the default value of 0.01 for the learning rate property `lr'.}\n\\item[{\\color{blue}stop training}] {\\color{blue} When training the `diabolo' autoencoders, my criterion to stop the training was simply to stop after the 20$^\\text{th}$sweep through the training set, or in other words, after the presentation of the last batch, \\# 3,000. For the sparse autoencoders with $h>n_1$, I used the `trainscg' function, for which the training was stopped as soon as one of the following criterion was met\\footnote{\\href{https://www.mathworks.com/help/nnet/ref/trainscg.html?searchHighlight=trainscg&s_tid=doc_srchtitle}{{\\color{blue}MATLAB manual reference}}}:\n\\renewcommand{\\labelitemii}{$\\bullet$}%options for bullet symbol\n\\begin{itemize}\n\\item The maximum number of epochs (sweeps) is reached (I set it to 20).\n\\item The maximum amount of time is exceeded (I left it at its default value, which is $\\infty$)\n\\item Performance is minimized to the goal (I set it to $MSE=0$).\n\\item The performance gradient falls below min\\_grad (I left it at its default value, which is $\\|\\text{grad}(MSE(W)) \\|=10^{-6}$).\n\\item Validation performance has increased more than max\\_fail times since the last time it decreased (irrelevant for me as I didn't use validation).\n\\end{itemize}}\n\\end{description}\n\\end{itemize}\n% -----------------------------------------------------------------------------------------\n% Training `small' autoencoders\n% -----------------------------------------------------------------------------------------\n\\section*{Training {\\color{blue}`diabolo'} autoencoders}\n{ \\color{blue}\n\\subsection*{Training autoencoders and plotting RMSEn}\nAs mentioned above, \nappendix~\\ref{app:create} contains the code used to create custom autoencoders with respective hidden layer sizes: 50, 100, 150 (recall that $n_1=196$). Each one of these neural network was subsequently trained according to the source code contained in appendix~\\ref{app:train_diabolo}.\n\nFigure~\\ref{fig:mse_diabolo} shows the resulting RMSE as a function of the batch number for the three distinct hidden layer sizes. \nThe three curves are very similar I am therefore quite doubtful about the correctness of my algorithm in appendix~\\ref{app:train_diabolo}.\n\n\\subsection*{RMSE$^*$ of trained autoencoders}\nThe RMSE for the trained autoencoders was computed by taking the square root of the output of the script presented in appendix~\\ref{app:msemat}. The results are presented in figure~\\ref{fig:rmse_global}, together with the results from the sparse autoencoders ($h>n_1$). Once again, values of the RMSE$^*$ above 0.5 indicate that my training was inefficient for the `diabolo' autoencoders. Such inefficient training might have come from an erroneous algorithm, or from a too small number of sweeps during training, or from a too low learning rate. Also, I obtained very similar RMSE values for the three hidden layer sizes. This probably indicates that my training algorithm was erroneous.\n}\n\\begin{figure}[bth!]\n\\centering\n\\fbox{\\includegraphics[width=0.65\\textwidth]{mse_diabolo.png}}\n\\caption{{\\color{blue}Evolution of the RMSE through training, for the three distinct hidden layer sizes. The abscissa has the same unit for all plots.}}\\label{fig:mse_diabolo}\n\\end{figure}\n\n\\subsection*{{\\color{blue}Explicit mathematical expression to compute $\\text{grad}(MSE(W))$}}\nBelow is a list of mathematical notation that I used to derive the retro-propagation rule by hand.\nThe final result is expressed in equations~\\eqref{one} and~\\eqref{two}.\n\\begin{itemize}\n\\item Matrix of weights between input and hidden layer:\n\\[\nW=\\left(w_{ij}^{(1)}\\right)_{ij}, \\quad 1\\leq i\\leq n_2; \\quad1\\leq j \\leq n_1+1,\n\\]\nwhere $w_{in_1+1}^{(1)}$ is always the threshold of unit $i$.\n\\item Matrix of weights between hidden and output layer:\n\\[\nW=\\left(w_{ij}^{(2)}\\right)_{ij}, \\quad 1\\leq i\\leq n_3; \\quad1\\leq j \\leq n_2+1,\n\\]\nwhere $w_{in_2+1}^{(1)}$ is always the threshold of unit $i$.\n\\item The total number of cases in the training set or in the batch is denoted by $M$.\n\\item The state of input unit $i$ under presentation of case $m$ is denoted $x_i$. \n\\item The state of hidden unit $j$ under presentation of case $m$ is denoted $h_j(W,m)$.\n\\item The state of unit $k$ on the output layer under presentation of case $m$ is denoted $o_k(W,m)$.\nHence, the output units states are: $o_1(W,m),\\ldots,o_{n_3}(W,m)$.\n\\item Linear output of hidden unit $i$:\n\\[\nA_i^{(1)}(W,m)=\\sum_{j=1}^{n_1+1}x_jw_{ij}^{(1)}\n\\]\n\\item Logistic function is denoted $\\sigma$. We have:\n\\[\n\\sigma(v)=\\frac{1}{1+e^{-v}}\\qquad \\sigma'(v)=\\frac{e^{-v}}{\\lp1+e^{-v}\\rp^2}\n\\]\n\\item Output of unit $j$ in hidden layer, under presentation of case $m$:\n\\[\nh_j(W,m)=\\sigma\\lp A_j^{(1)}(W,m) \\rp\n\\]\n\\item Linear output of the output layer unit $i$:\n\\[\nA_i^{(2)}(W,m)=\\sum_{j=1}^{n_2+1}h_j(W,m)w_{ij}^{(2)}\n\\]\n\\item Output of unit $i$ in output layer, under presentation of case $m$:\n\\[\no_i(W,m)=\\sigma\\lp A_i^{(2)}(W,m) \\rp\n\\]\n\\item Denote by $\\delta_{x,y}$ the Kronecker delta which is 1 only when $x=y$ and zero otherwise.\n\\item Also, define $\\iota$ to be the function that maps each case $m$ to the output unit index $\\iota(m)$\nwhich codes for the correct label of this case. Hence, if case 36 represents a 4, then unit $o_5$ will code\nfor it in $\\text{OUT}_{36}$ and therefore $\\iota(36)=5$.\n\\item We denote the MSE function by the letter $f$:\n\\begin{align}\nf(W)&=\\frac{1}{M}\\sum_{m=1}^{M}\\left |\\left| \\widehat{\\text{OUT}}_m-\\text{OUT}_m \\right |\\right |_2^2\\\\\n\t&=\\frac{1}{M}\\sum_{m=1}^M \\sum_{k=1}^{n_3}\\lp o_{k}(W,m)-\\delta_{k,\\iota(m)}\\rp^2\n\\end{align}\n\\item The update rule for the weights is:\n\\[\n\\Delta W_n=-\\text{grad} \\lp f(W)\\rp\\cdot \\frac{\\gamma}{\\epsilon_n}\n\\]\n\\end{itemize}\nThe formula for the partial derivative of the MSE with respect to a weight from the H-OUT layer, $w^{(2)}_{ij}$, is:\n\\begin{equation}\n\\frac{\\partial f}{\\partial w^{(2)}_{ij}}(W)=\\frac{2}{M}\\sum_{m=1}^M\\sigma'\\left(A_i^{(2)}(W,m)\\right)h_j(W,m)\\left[o_i(W,m)-\\delta_{\\iota(m),i}\\right] \\label{one}\n\\end{equation}\nAnd when it is with respect to a weight from the IN-to-H layer, $w^{(1)}_{ij}$, we get:\n\\begin{equation}\n\\frac{\\partial f}{\\partial w^{(1)}_{ij}}(W)=\\frac{2}{M}\n\\sum_{m=1}^M\\left[\\sigma'\\left(A_i^{(1)}(W,m)\\right)x_j\n\\sum_{k=1}^{n_3}\\sigma'\\left(A_k^{(2)}(W,m)\\right) w^{(2)}_{ki}\\left[o_k(W,m)-\\delta_{\\iota(m),k}\\right] \\right]\\label{two}\n\\end{equation}\n% -----------------------------------------------------------------------------------------\n% SECOND EXPERIMENT: `large' autoencoders with sparsity\n% -----------------------------------------------------------------------------------------\n\\section{Second experiment: `large' autoencoders with sparsity}\nI trained the `large autoencoders' with the code presented in appendix~\\ref{app:sparse}\n\\subsection{Results}\nThe following table {\\color{blue}in figure~\\ref{fig:rmse_global}} was generated with the script presented in appendix~\\ref{app:msemat} after training the 9 autoencoders. {\\color{blue}We observe that the RMSE of the trained sparse autoencoders is generally smaller than half the magnitude of the RMSE for the `diabolo' autoencoders. \n\nFor the sparsity target $\\rho=5$\\% we observe no difference in RMSE across hidden layer size (h=250, 300, 350). This might be due to the relatively small number of sweeps used in training (20). \nFor the sparsity target $\\rho=15$\\%, the RMSE of the trained autoencoders decreases slightly as the hidden layer size increases.}\n\\begin{figure}[bth!]\n\\centering\n{\\color{blue}\n\\begin{tabular}{|l | c  cc|ccc|ccc|}\n\\hline\n$h$& $50$&$100$&$150$&\n$250$&$300$&$350$&\n$250$&$300$&$350$\\\\ \n$\\rho$& &&&\n$ 0.05$&$0.05$&$ 0.05$&\n$ 0.15$&$0.15$&$0.15$\\\\ \n\\hline\ntraining & 0.59   & 0.58  &  0.58  &  0.27    &0.27  &  0.27&    0.27 &   0.26   &0.25\\\\\n                                    \ntest &  0.59&0.58&0.58&0.27&0.27&0.27&0.27&0.26&0.25\\\\\n\\hline\n\\end{tabular}}\n\\caption{{\\color{blue}RMSE (bottom two rows) for the nine \\emph{trained} autoencoders (one per column), computed over both the training and the test set. The first two rows of the table designate the hidden size $h$ and the sparsity target $\\rho$ of each autoencoder.}}\\label{fig:rmse_global}\n\\end{figure}\n\\section{Detailed analysis of hidden layer structure and efficiency}\nI did not have time to do this part of the homework.\n{\\color{blue}The activations of the hidden layer of each trained autoencoder was computed and projected onto the first three Principal Components, using the scripts presented in appendix~\\ref{app:pca}. The 3D scatter plots of these projections are presented in figure~\\ref{fig:pca}.}\n\\begin{figure}[bth!]\n\\centering\n\\fbox{\\includegraphics[width=\\textwidth]{pca.png}}\n\\caption{{\\color{blue}Projection of the activations of the hidden layers of each of the 9 autoencoders, onto the first three principal components. Hidden layer size is h and k represents the smallest number of PCA dimensions required to explain 90\\% of the variance of the hidden layer activations. Top row of plots is for the cases $h<n_1$. Middle row is for the cases $h>n_1$ AND $\\rho=5$\\%. Bottom row is for $\\rho=15$\\%.}}\\label{fig:pca}\n\\end{figure}\n{\\color{blue}\nFor each network, let $k$ be the smallest number of eigenvalues that, jointly, explain more than 90\\% of the variance in the activations of the hidden layer.\n\nI do not know why $k$ could  not be computed for the two sparse autoencoders having hidden layer sizes $h=250$ and $300$, and sparsity target $\\rho=5$\\%.\n\nI observe that the value of $k$ varies greatly between the `diabolo' and the sparse autoencoders. \n\nI do not observe any clustering of the points in the PCA projection space. I hypothesize that none of my networks was sufficiently trained.}\n{\\color{blue}\n\\section{Autoencoding efficiency}\nI did not have time to address this question.}\n\\bibliographystyle{plain}\n\\bibliography{auto}\n\\begin{appendices}\n% -----------------------------------------------------------------------------------------\n% MATLAB code\n% -----------------------------------------------------------------------------------------\n\\section{MATLAB code}\n\\subsection{Custom network with NN Toolbox in MATLAB}\n\\label{app:create}\n\\lstinputlisting{create_NN.m}\n\\subsection{Training the `diabolo'-autoencoders}\n{\\color{blue}When training the networks with hidden layer sizes 100 and 150, the string `net\\_50' below was replaced by\n`net\\_100' and `net\\_150' respectively. Also, the commented lines were never used in my final results, they are merely vestiges of my trials and errors.}\n\\label{app:train_diabolo}\n\\lstinputlisting{train_autoencoder.m}\n\\subsection{Training autoencoders with sparsity constraint}\n\\label{app:sparse}\n\\lstinputlisting{train_sparse.m}\n\\begin{center}\n\\line(1,0){250}\n\\end{center}\n\\lstinputlisting{train_sparse_UH.m}\n\\subsection{Generating matrix of MSE on training and test sets for all autoencoders}\n\\label{app:msemat}\n\\lstinputlisting{mse_perf_small.m}\n\\subsection{PCA on hidden layers}\n\\label{app:pca}\n\\lstinputlisting{pca_hidden.m}\n\\begin{center}\n\\line(1,0){250}\n\\end{center}\n\\lstinputlisting{create_IH.m}\n\\begin{center}\n\\line(1,0){250}\n\\end{center}\n{\\color{blue}The following is the script used to produce figure~\\ref{fig:pca}.}\n\\lstinputlisting{pca_global.m}\n\\end{appendices}\n\\end{document}\n", "meta": {"hexsha": "283a2b981cbd768ed86ed9050df5a913ce1fcdcb", "size": 18251, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Proj2.radillo.v2.tex", "max_stars_repo_name": "aernesto/autoencoders_MATLAB", "max_stars_repo_head_hexsha": "536aed7bafa5027bf8f17d3e5c4663d990d9f3fb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Proj2.radillo.v2.tex", "max_issues_repo_name": "aernesto/autoencoders_MATLAB", "max_issues_repo_head_hexsha": "536aed7bafa5027bf8f17d3e5c4663d990d9f3fb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Proj2.radillo.v2.tex", "max_forks_repo_name": "aernesto/autoencoders_MATLAB", "max_forks_repo_head_hexsha": "536aed7bafa5027bf8f17d3e5c4663d990d9f3fb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.634551495, "max_line_length": 688, "alphanum_fraction": 0.6997972714, "num_tokens": 5122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4018134811852093}}
{"text": "\\documentclass{article}\n\n\\usepackage{fancyhdr}\n\\usepackage{extramarks}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\usepackage{amsfonts}\n\\usepackage{tikz}\n\\usepackage{physics}\n\\usepackage{amssymb}\n\\usepackage[plain]{algorithm}\n\\usepackage{algpseudocode}\n\n\\usetikzlibrary{automata,positioning}\n\n% Basic Document Settings\n%\n\n\\topmargin=-0.45in\n\\evensidemargin=0in\n\\oddsidemargin=0in\n\\textwidth=6.5in\n\\textheight=9.0in\n\\headsep=0.25in\n\n\\linespread{1.1}\n\n\\pagestyle{fancy}\n\\lhead{\\hmwkAuthorName}\n\\chead{\\hmwkClass\\ : \\hmwkTitle}\n\\rhead{\\firstxmark}\n\\lfoot{\\lastxmark}\n\\cfoot{\\thepage}\n\n\\renewcommand\\headrulewidth{0.4pt}\n\\renewcommand\\footrulewidth{0.4pt}\n\n\\setlength\\parindent{0pt}\n\n%\n% Create Problem Sections\n%\n\\newcommand{\\be}{\\begin{equation}}\n\\newcommand{\\ee}{\\end{equation}}\n\\newcommand{\\bes}{\\begin{equation*}}\n\\newcommand{\\ees}{\\end{equation*}}\n\\newcommand{\\bea}{\\begin{flalign*}}\n\\newcommand{\\eea}{\\end{flalign*}}\n\n\\newcommand{\\enterProblemHeader}[1]{\n    \\nobreak\\extramarks{}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n}\n\n\\newcommand{\\exitProblemHeader}[1]{\n    \\nobreak\\extramarks{Problem \\arabic{#1} (continued)}{Problem \\arabic{#1} continued on next page\\ldots}\\nobreak{}\n    \\stepcounter{#1}\n    \\nobreak\\extramarks{Problem \\arabic{#1}}{}\\nobreak{}\n}\n\n\\setcounter{secnumdepth}{0}\n\\newcounter{partCounter}\n\\newcounter{homeworkProblemCounter}\n\\setcounter{homeworkProblemCounter}{1}\n\\nobreak\\extramarks{Problem \\arabic{homeworkProblemCounter}}{}\\nobreak{}\n\n%\n% Homework Problem Environment\n%\n% This environment takes an optional argument. When given, it will adjust the\n% problem counter. This is useful for when the problems given for your\n% assignment aren't sequential. See the last 3 problems of this template for an\n% example.\n%\n\\newenvironment{homeworkProblem}[1][-1]{\n    \\ifnum#1>0\n        \\setcounter{homeworkProblemCounter}{#1}\n    \\fi\n    \\section{Problem \\arabic{homeworkProblemCounter}}\n    \\setcounter{partCounter}{1}\n    \\enterProblemHeader{homeworkProblemCounter}\n}{\n    \\exitProblemHeader{homeworkProblemCounter}\n}\n\n%\n% Homework Details\n%   - Title\n%   - Due date\n%   - Class\n%   - Section/Time\n%   - Instructor\n%   - Author\n%\n\n\\newcommand{\\hmwkTitle}{Assignment\\ \\#3}\n\\newcommand{\\hmwkDueDate}{Due 5th October 2018}\n\\newcommand{\\hmwkClass}{Classical Mechanics}\n\\newcommand{\\hmwkClassTime}{}\n\\newcommand{\\hmwkClassInstructor}{Prof.Manas Kulkarni}\n\\newcommand{\\hmwkAuthorName}{\\textbf{Aditya Vijaykumar}}\n\n%\n% Title Page\n%\n\n\\title{\n    %\\vspace{2in}\n    \\textmd{\\textbf{\\hmwkClass:\\ \\hmwkTitle}}\\\\\n    \\normalsize\\vspace{0.1in}\\small{\\hmwkDueDate\\ }\\\\\n%    \\vspace{3in}\n}\n\n\\author{\\hmwkAuthorName}\n\\date{}\n\n\\renewcommand{\\part}[1]{\\textbf{\\large Part \\Alph{partCounter}}\\stepcounter{partCounter}\\\\}\n\n%\n% Various Helper Commands\n%\n\n% Useful for algorithms\n\\newcommand{\\alg}[1]{\\textsc{\\bfseries \\footnotesize #1}}\n\n% For derivatives\n\\newcommand{\\deriv}[1]{\\frac{\\mathrm{d}}{\\mathrm{d}x} (#1)}\n\n% For partial derivatives\n\\newcommand{\\pderiv}[2]{\\frac{\\partial}{\\partial #1} (#2)}\n\n% Integral dx\n\\newcommand{\\dx}{\\mathrm{d}x}\n\n% Alias for the Solution section header\n\\newcommand{\\solution}{\\textbf{\\large Solution}}\n\n% Probability commands: Expectation, Variance, Covariance, Bias\n\\newcommand{\\E}{\\mathrm{E}}\n\\newcommand{\\Var}{\\mathrm{Var}}\n\\newcommand{\\Cov}{\\mathrm{Cov}}\n\\newcommand{\\Bias}{\\mathrm{Bias}}\n\n\\begin{document}\n\\maketitle\n\\begin{homeworkProblem}[1]\t\\textbf{Part (a)}\\\\\n\tFor $ m=constant $\n\t\\begin{align*}\n\tT &= \\dfrac{m \\va{v} \\vdot \\va{v} }{2}\\\\\n\t\\dv{T}{t} &= m \\dot{\\va{v}}  \\vdot \\va{v}\n\t= \\va{F} \\vdot \\va{v}\n\t\\end{align*}\n\t\n\tIf $ m $ varies with time,\n\t\\begin{align*}\n\tmT &= \\dfrac{m^2 \\va{v} \\vdot \\va{v} }{2}\\\\\n\t\\dv{(mT)}{t} &= m^2 \\dot{\\va{v}}  \\vdot \\va{v} + m \\dot{m} \\va{v} \\vdot \\va{v}\\\\\n\t&= (m {\\va{v}}) \\vdot (m \\dot{\\va{v}} + \\dot{m} {\\va{v}})\\\\\n\t\\dv{(mT)}{t}&= \\va{p}\\vdot \\va{F}\n\t\\end{align*}\n\t\n\t\\textbf{Part (b)}\\\\\n\tWe know that,\n\t\\begin{equation*}\n\tM_1 \\dv[2]{\\va{r_1}}{t} + M_2 \\dv[2]{\\va{r_2}}{t} = \\va{F}^{ext} + \\va{F}_{12}^i + \\va{F}_{21}^i\n\t\\end{equation*}\n\twhere $ \\va{F}^{ext} $ and $ \\va{F}^i $ are the external and interaction forces respectively. But we also know that,\n\t\\begin{equation*}\n\tM_1 \\dv[2]{\\va{r_1}}{t} + M_2 \\dv[2]{\\va{r_2}}{t} = M \\dv[2]{\\va{R}}{t} = \\va{F}^{ext}\n\t\\end{equation*}\n\t\n\tComparing the preceding equations, we get,\n\t\\begin{equation*}\n\t\\va{F}_{12}^i + \\va{F}_{21}^i = 0 \\implies \\va{F}_{12}^i = - \\va{F}_{21}^i \n\t\\end{equation*}\n\tThis is the weak form of Newton's third law.\n\t\n\tOn similar lines,\n\t\\begin{equation*}\n\tI_1 \\va{r}_1 \\cross \\dot{\\va{p}}_1 + I_2 \\va{r}_2 \\cross \\dot{\\va{p}}_2 = \\va{\\tau}^{ext} + \\va{\\tau}_{12}^i + \\va{\\tau}_{21}^i \\qq{and} I_1 \\va{r}_1 \\cross \\dot{\\va{p}}_1 + I_2 \\va{r}_2 \\cross \\dot{\\va{p}}_2 = I \\va{R} \\cross \\dot{\\va{p}} = \\va{\\tau}^{ext} \n\t\\end{equation*}\n\t\\begin{align*}\n\t\\implies \\va{\\tau}_{12}^i + \\va{\\tau}_{21}^i &= 0\\\\\n\t\\va{r}_1 \\cross \\va{F}_{12}^i + \\va{r}_2 \\cross \\va{F}_{21}^i &= 0 \\\\\n\t\\va{r}_1 \\cross \\va{F}_{12}^i - \\va{r}_2 \\cross \\va{F}_{12}^i &= 0 \\\\\n\t(\\va{r}_1-\\va{r}_2) \\cross \\va{F}_{12}^i  &= 0 \n\t\\end{align*}\n\tThis means that the action-reaction pair acts along the line joining the two particles. This proves the strong form of the third law.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[2]\n\tLet $ R $ be the radius of the disc. The generalized coordinates for the motion are the planar coordinates $ x , y$ and angular coordinate $ \\theta $ of the disc. For rolling, we have,\n\t\\begin{equation*}\n\tR \\dot{\\theta} = v \n\t\\end{equation*}\n\tLet's assume that the velocity vector makes an angle $ \\phi $ with the positive $ x $-axis. We then have,\n\t\\begin{align*}\n\t\\dot{x} = v \\cos \\phi \\qq{and} \\dot{y} = v \\sin \\phi\n\t&\\implies \\dot{x} = \tR \\dot{\\theta} \\cos \\phi \\qq{and} \\dot{y} = \tR \\dot{\\theta} \\sin \\phi\\\\\n\t\\therefore d{x} - \tR d{\\theta} \\cos \\phi = 0  &\\qq{and} d{y} - R d{\\theta} \\sin \\phi = 0 \\\\\n\t\\therefore d{x} +  dy &- R (\\cos \\phi + \\sin \\phi)d\\theta = 0  \n\t\\end{align*}\n\tIt is straightforward to see that the above equations are specific instances of an equation of the form,\n\t\\begin{equation*}\n\t\\sum_{i=1}^{n} g_i(x_1,x_2,\\ldots, x_n) d x_i = 0\n\t\\end{equation*}\n\tFor the constraint to be holonomic there should be an integrating factor $ f = f(x,y,\\theta,\\phi) $ which satisfies,\n\t\\begin{equation*}\n\t\\pdv{fg_i}{x_j} = \\pdv{fg_j}{x_i}\n\t\\end{equation*}\n\tLet's say $ f(x,y,\\theta,\\phi)= X(x) Y(y) \\Theta(\\theta) \\Phi(\\phi) $. Consider the following,\n\t\\begin{align*}\n\t\\pdv{fg_x}{\\theta} &= \\pdv{fg_\\theta}{x}\\\\\n\t\\dfrac{1}{f}\\pdv{f}{\\theta} &= -\\dfrac{1}{f} R \\sin \\phi \\pdv{f}{x}\\\\\n\t\\dfrac{1}{\\Theta}\\pdv{\\Theta}{\\theta} &= -\\dfrac{1}{X} R \\sin \\phi \\dv{X}{x}\n\t\\end{align*}\n\tThe RHS is a function of $ x $ multiplied by $ \\sin \\phi $, while the LHS is purely a function of $ \\theta $. They can never be equal, and hence an integrating factor $ f $ never exists.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[3]\n\t\\textbf{Part (a)}\\\\\n\tLet $ r, \\theta, \\phi $ be the generalized coordinates in their usual polar form, and $ l_0 $ be the equilibrium length of the spring. The Lagrangian of the problem $ L $ can be written as,\n\t\\begin{equation*}\n\tL = \\dfrac{m(\\dot{r}^2 + r^2\\dot{\\theta}^2 + r^2 \\sin^2 \\theta \\dot{\\phi}^2)}{2} + mgr\\cos \\theta - \\dfrac{k(r - l_0)^2}{2}\n\t\\end{equation*}\n\tThe equations of motion are,\n\t\\begin{align*}\n\tm\\ddot{r} &= mr\\dot{\\theta}^2 + mr \\sin^2 \\theta \\dot{\\phi}^2 + mg \\cos \\theta  - k(r - l_0)\\\\\n\tm r^2 \\ddot{\\theta} + 2 m r \\dot{r} \\dot{\\theta} &= mr^2 \\sin \\theta \\cos \\theta \\dot{\\phi}^2 - mgr \\sin \\theta\\\\\n\tmr^2 \\sin^2 \\theta \\ddot{\\phi} + 2 m r \\sin^2 \\theta \\dot{r} \\dot{\\phi} + 2 m r^2 \\sin \\theta \\cos \\theta \\dot{\\theta} \\dot{\\phi} &= 0\n\t\\end{align*}\n\tConstraining the motion in a plane implies using $ \\phi = constant \\implies \\dot{\\phi} = \\ddot{\\phi} = 0$. \\textcolor{red}{Is constraining possible? - yes, one just needs to give it initial velocity in the plane}. Our equations then reduce to,\n\t\\begin{align*}\n\tm\\ddot{r} &= mr\\dot{\\theta}^2 + mg \\cos \\theta  - k(r - l_0)\\\\\n\tm r^2 \\ddot{\\theta} + 2 m r \\dot{r} \\dot{\\theta} &= - mgr \\sin \\theta\n\t\\end{align*}\n\tThe equilibrium positions can be found by substituting all time derivatives of $ r $ and $ \\theta $ as zero. This gives the equilibrium $ r_0 = l_0 + \\dfrac{mg}{k} $ and $ \\theta_0 = 0 $.\n\tWe need to solve the above for small stretching in $ r $ and small angular displacements $ \\theta $. Let's substitute $ r = r_0 + \\epsilon x $ and $ \\theta = \\epsilon \\alpha $ in the equations. We get,\n\t\\begin{align*}\n\tm\\epsilon \\ddot{x} &= m(r_0 + \\epsilon x) \\epsilon^2 \\dot{\\alpha}^2 + mg \\left( 1 - \\dfrac{\\alpha^2}{2} \\epsilon^2 + \\ldots\\right)   - k(\\epsilon x + r_0 - l_0)\\\\\n\tm ( r_0 + \\epsilon x)^2 \\epsilon \\ddot{\\alpha} + 2 m \\epsilon^2 ( r_0 + \\epsilon x) \\dot{x} \\dot{\\alpha} &= - mg( r_0 + \\epsilon x ) \\left(\\epsilon \\alpha + \\ldots \\right)\n\t\\end{align*}\n\tUsing only $ \\order{\\epsilon} $ terms,\n\t\\begin{align*}\n\t\\ddot{x} &= -\\dfrac{k}{m} x\\\\\n\t\\ddot{\\alpha} &= - \\dfrac{g}{r_0}\\alpha \n\t\\end{align*}\n\t\n\t\\textbf{Part (b)}\\\\\n\tThe Lagrangian is given as,\n\t\\begin{equation*}\n\tL = e^{\\gamma t}\\qty(\\dfrac{m\\dot{q}^2}{2} - \\dfrac{k q^2}{2})\n\t\\end{equation*}\n\tWriting down the equations of motion for hte generalized coordinate $ q $,\n\t\\begin{align*}\n\t\\derivative{t}\\qty(e^{\\gamma t}m \\dot{q}) &= -e^{\\gamma t} k {q}\\\\\n\t\\implies e^{\\gamma t} \\qty(\\gamma m \\dot{q} + m \\ddot{q}) &= -e^{\\gamma t} k {q}\\\\\n\t\\implies   \\ddot{q} + \\gamma  \\dot{q}+ \\dfrac{k}{m}q &= 0 \n\t\\end{align*}\n\tThis is the equation of motion for a damped harmonic oscillator. \n\t\n\tLet's perform the transformation $ s = e^{\\gamma t} q \\implies \\dot{s} = e^{\\gamma t} (\\gamma q + \\dot{q}) = \\gamma s + e^{\\gamma t} \\dot{q} $. Inverting these, we have the following,\n\t\\begin{align*}\n\tq &= e^{-\\gamma t} s\\\\\n\t\\dot{q} &= e^{-\\gamma t}(\\dot{s} - \\gamma s)\n\t\\end{align*}\n\tSubstituting this back into the expression for $ L $,\n\t\\begin{equation*}\n\tL = e^{-\\gamma t}\\qty(\\dfrac{m\\dot{s}^2}{2} + \\dfrac{(m\\gamma^2 - k) s^2}{2} - m\\gamma s \\dot{s})\n\t\\end{equation*}\n\tWriting the equations of motion for $ s $,\n\t\\begin{align*}\n\t\\derivative{t}\\qty(e^{-\\gamma t}(m \\dot{s} - m\\gamma s)) &= -e^{-\\gamma t} ((k - m\\gamma^2) {s} - m\\gamma \\dot{s})\\\\\n\tm \\ddot{s} - m\\gamma \\dot{s} -\\gamma (m \\dot{s} - m \\gamma s) &=  (k - m \\gamma^2) {s} - m\\gamma \\dot{s}\\\\\n\t\\ddot{s} -\\gamma \\dot{s} + \\qty(2  \\gamma^2-\\dfrac{k}{m}) s &=  0 \n\t\\end{align*}\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[4]\n\t\\textbf{Part (a)}\\\\\n\tAs given, we take $ y = at + bt^2 \\implies \\dot{y} = a + 2bt$. The Lagrangian $ L $ can be written as follows,\n\t\\begin{align*}\n\tL &= \\dfrac{m \\dot{y}^2}{2} - mgy = \\dfrac{m (a+2bt)^2}{2} - mg (at + bt^2)\\\\\n\t&= \\dfrac{ma^2 }{2}+ (2mab - mga)t + (2mb^2 - mgb)t^2\n\t\\end{align*}\n\tLet's evaluate $ \\int L dt $,\n\t\\begin{align*}\n\t\\int_0^{t_0} L dt &= \\int_0^{t_0} [\\dfrac{ma^2}{2} + (2mab - mga)t + (2mb^2 - mgb)t^2] dt\\\\\n\t& = \\dfrac{ma^2}{2} t_0 + \\dfrac{2mab - mga}{2}t_0^2 + \\dfrac{2mb^2 - mgb}{3}t_0^3\\\\\n\t& = \\dfrac{ma^2}{2} \\sqrt{\\dfrac{2y_0}{g}} + \\dfrac{2mab - mga}{2}\\dfrac{2y_0}{g} + \\dfrac{2mb^2 - mgb}{3}\\dfrac{2y_0}{g}\\sqrt{\\dfrac{2y_0}{g}}\\\\\n\t&= 0 \\impliedby \\left(a=0 \\qq{and} b = \\dfrac{g}{2}\\right)\n\t\\end{align*}\n\t\\textit{Hence Proved.}\n\t\\\\\n\t\n\t\\textbf{Part (b)}\n\tGiven, $ L = L(q_i, \\dot{q_i}, \\ddot{q_i},t) $, and we know that $ S = \\int_{t_i}^{t_f} L(q_i, \\dot{q_i}, \\ddot{q_i},t) dt  $. Variation of the action can be written as,\n\t\\begin{align*}\n\t\\delta S &= \\int_{t_i}^{t_f} \\delta L dt = 0\\\\\n\t&= \\int_{t_i}^{t_f} \\sum_{i} \\qty(\\pdv{L}{q_i} \\delta q_i+ \\pdv{L}{\\dot{q_i}} \\delta \\dot{q_i} + \\pdv{L}{\\ddot{q_i}} \\delta \\ddot{q_i})dt\\\\\n\t&= \\int_{t_i}^{t_f} \\sum_{i} \\qty(\\pdv{L}{q_i} \\delta q_i+ \\qty(\\pdv{L}{\\dot{q_i}} - \\dv{t}\\pdv{L}{\\ddot{q_i}} ) \\delta \\dot{q_i} + \\dv{t} \\qty(\\pdv{L}{\\ddot{q_i}} \\delta \\dot{q_i}))dt\\\\\n\t&= \\int_{t_i}^{t_f} \\sum_{i} \\qty[ \\qty{\\pdv{L}{q_i} - \\dv{t}\\qty(\\pdv{L}{\\dot{q_i}} - \\dv{t}\\pdv{L}{\\ddot{q_i}} )} \\delta q_i + \\dv{t}\\qty(\\qty(\\pdv{L}{\\dot{q_i}} - \\dv{t}\\pdv{L}{\\ddot{q_i}} ) \\delta {q_i}) + \\dv{t} \\qty(\\pdv{L}{\\ddot{q_i}} \\delta \\dot{q_i})]dt\n\t\\end{align*}\n\tAs the variation of $ q_i $ and $ \\dot{q_i} $ at the endpoints is zero, the total derivative terms vanish. Accounting for the fact that all $ q_i $'s are independent, one can write the equation of motion as,\n\t\\begin{equation*}\n\t\\boxed{\\pdv{L}{q_i} - \\dv{t}\\pdv{L}{\\dot{q_i}} + \\dv[2]{t}\\pdv{L}{\\ddot{q_i}} = 0}\n\t\\end{equation*}\n\tTaking $ L = -\\dfrac{m}{2}q \\ddot{q} - \\dfrac{k}{2}q^2$, we can write,\n\t\\begin{equation*}\n\tkq + \\dfrac{m}{2}\\ddot{q} = 0 \\implies \\ddot{q} + \\dfrac{2k}{m}q  = 0\n\t\\end{equation*}\n\tThis turns out to be the equation of the simple harmonic oscillator.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[5]\n\tIn all the parts, time translation is an implied conserved quantity, and energy is the corresponding conserved quantity.\\\\\n\t\\textbf{Part (a)} -\nThe potential energy in this case will only be a function of z. Hence, the $ x $ and $ y $ momenta will be conserved. \n\n\\textbf{Part (b)} -\nLet's consider the half-plane in a way that only the part with $ x>0 $ has uniform mass distribution. Here, only $ y $-translations are symmetries and Hence, only $ p_y $ will be conserved.\n\n\\textbf{Part (c)} -\nAn infinite cylinder possesses $ z $-translation and $ z $-rotation symmetry, and hence $ p_z $ and $ L_z $ will be conserved.\n\n\\textbf{Part (d)} -\nA finite cylinder only has $ z $-rotation symmetry. So, only $ L_z $ is the conserved quantity.\n\n\\textbf{Part (e)} - \nThe infinite right elliptical cylinder only has $ z $-translation symmetry. So, only $ p_z $ is the conserved quantity.\n\n\\textbf{Part (f)} - \nThe dumbell only has $ z $-translation symmetry. So, only $ p_z $ is the conserved quantity.\n\n\\textbf{Part (g)} - \nThe infinite helical solenoid has$ z $-translation and $ z $-rotation symmetries, and hence $ p_z$ and $ L_z $ are the conserved quantities.\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[6]\n\tThe Lagrangian for the problem is,\n\t\\begin{equation*}\n\tL = \\dfrac{m(\\dot{r}^2 + r^2 \\dot{\\theta}^2 )}{2} - V(r)\n\t\\end{equation*}\n\tThe equations of motion for this Lagrangian, with $ V(r) = -V_0 e^{-\\lambda^2 r^2} $, are,\n\t\\begin{align*}\n\tm r^2 \\dot{\\theta} &= constant = L_0 \\qq{and}\\\\\n\tm \\ddot{r} &= m r \\dot{\\theta}^2 + (2 \\lambda^2 r) V(r)\\\\\n\t\\implies m\\ddot{r}&= \\dfrac{L_0^2}{m r^3} + (2 \\lambda^2 r) V(r)\n\t\\end{align*}\n\tFor stable circular orbit, $ \\dot{r} = \\ddot{r} = 0 $. Let $ r_0 $ be radius of stable circular orbit. We can see that $ r_0 $ will be given by the root of the equation,\n\t\\begin{equation*}\n\t\\dfrac{L_0^2}{m r_0^3} - 2 \\lambda^2 r_0 V_0 e^{-\\lambda^2 r_0^2} = 0\\\\\n\t\\implies {L_0^2} = 2 \\lambda^2 m r_0^4 V_0 e^{-\\lambda^2 r_0^2}\n\t\\end{equation*}\n\tNote that $ L_0^2 $ has a functional dependence on $ r_0 $ $ (\\sim r_0^4 e^{-\\lambda^2 r_0^2}) $. This functional dependence has a maxima at $ r_0^2 = \\dfrac{2}{\\lambda^2} $, where the value of the function is $\\dfrac{4}{\\lambda^2 e^2}$. $ L_0^2 $ should be lesser than this maximum value for it to be realizable. Hence,\n\t\\begin{equation*}\n\tL_0^2 \\le \\dfrac{8mV_0}{e^2} \\implies L_0 \\le \\dfrac{\\sqrt{8mV_0}}{e}\n\t\\end{equation*}\n\n\tSo, $ L_0 $ cannot exceed $ \\dfrac{\\sqrt{8mV_0}}{e} $.\n\t\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[7]\n\tThe radius of the circle $ r $ and the angle covered around the circle $ \\theta $ are the generalized coordinates. The Cartesian coordinates of the particle are,\n\t\\begin{equation*}\n\tx = r \\cos \\theta, y = r \\sin \\theta, z = r \\cot \\alpha \\implies v^2 = \\dot{r}^2 \\csc^2 \\alpha + r^2 \\dot{\\theta}^2\n\t\\end{equation*}The Lagrangian $ L $ can be written as,\n\t\\begin{equation*}\n\tL =  \\dfrac{m (\\dot{r}^2 \\csc^2 \\alpha + r^2 \\dot{\\theta}^2)}{2}- mg r \\cot \\alpha\n\t\\end{equation*}\n\tThe equations of motion are,\n\t\\begin{align*}\n\tr^2 \\dot{\\theta} &= constant = L_0\\\\\n\t\\ddot{r}\\csc^2 \\alpha &= r\\dot{\\theta}^2 - g\\cot \\alpha \\implies \\ddot{r} \\csc^2 \\alpha = \\dfrac{L_0^2}{r^3} - g\\cot \\alpha\n\t\\end{align*}\n\t\n\t\\textbf{Part (b)}\\\\\n\tIf $ r = r_0 $, $ \\ddot{r} =0 $ and,\n\t\\begin{equation*}\n\tL_0^2 = r_0^4 \\omega^2 =   g r_0^3 \\cot \\alpha \\implies \\boxed{\\omega = \\sqrt{\\frac{g \\cot \\alpha}{r_0}}} \\implies L_0 = r_0^3 g \\cot \\alpha\n\t\\end{equation*}\n\t\n\t\\textbf{Part (c)}\\\\\n\t\n\tWe consider perturbations along the surface of the cone ie $ l = r_0 \\csc \\alpha + \\epsilon x $. This in turn corresponds to a radial perturbation of the form $ r = r_0 + \\epsilon x \\sin \\alpha $, $ \\epsilon \\ll 1 $. Substituting this into the equation of motion for $ r $,\n\t\\begin{align*}\n\t\\epsilon \\ddot{x} \\csc \\alpha &= \\dfrac{L_0^2}{(r_0 + \\epsilon x \\sin \\alpha)^3} - g \\cot \\alpha\\\\\n\t&=\\dfrac{L_0^2}{r_0^3}\\qty(1 - \\dfrac{3 \\epsilon x \\sin \\alpha}{r_0} + \\ldots) - g \\cot \\alpha\\\\\n\t\\epsilon \\ddot{x} \\csc \\alpha &=\\dfrac{L_0^2}{r_0^3}\\qty(- \\dfrac{3 \\epsilon x \\sin \\alpha}{r_0} + \\ldots) \\\\\n\t\\end{align*}\n\tChoosing only the term first order in $ \\epsilon $,\n\t\\begin{equation*}\n\t\\ddot{x} = -\\dfrac{3 g \\cot \\alpha}{r_0}(\\sin^2 \\alpha) x \\implies \\boxed{\\Omega = \\sqrt{\\dfrac{3 g \\cot \\alpha\t}{r_0}}\\sin \\alpha}\n\t\\end{equation*}\n\tFor $ \\Omega = \\omega $, we can see that,\n\t\\begin{equation*}\n\t\\sin \\alpha = \\dfrac{1}{\\sqrt{3}} \\implies \\alpha = \\sin[-1](\\dfrac{1}{\\sqrt{3}})\n\t\\end{equation*}\n\\end{homeworkProblem}\n\n\\begin{homeworkProblem}[8]\n\tLet $ \\theta_1 $ and $ \\theta_2 $ be the angles that the sticks make with the vertical. Each stick is of length $ 2r $. $ \\theta_1 $ (lower stick) and $ \\theta_2 $ (upper stick) are the generalized coordinates. The position coordinates of the lower and upper masses are,\n\t\\begin{equation*}\n\t(x_1,y_1) = (r \\sin \\theta_1, r \\cos \\theta_1) \\qq{and} (x_2,y_2) = (2r \\sin \\theta_1 + r \\sin \\theta_2, 2r \\cos \\theta_1 + r \\cos \\theta_2)\n\t\\end{equation*}\n\t\\begin{equation*}\n\t\\implies v_1^2 = r^2 \\dot{\\theta}_1^2 \\qq{and} v_2^2 = 4r^2 \\dot{\\theta}_1^2 + r^2 \\dot{\\theta}_2^2 + 4r^2 \\cos (\\theta_1 - \\theta_2) \\dot{\\theta}_1 \\dot{\\theta}_2\n\t\\end{equation*}\n\t\n\tThe Lagrangian can be written as,\n\t\\begin{equation*}\n\tL = \\dfrac{ mr^2 }{2}\\dot{\\theta}_1^2 + \\dfrac{ m(4r^2 \\dot{\\theta}_1^2 + r^2 \\dot{\\theta}_2^2 + 4r^2 \\cos (\\theta_1 - \\theta_2) \\dot{\\theta}_1 \\dot{\\theta}_2) }{2} - mgr \\cos \\theta_1 - mg (2r\\cos \\theta_1 + r \\cos \\theta_2) \n\t\\end{equation*}\n\tThe equations of motion are,\n\t\\begin{align*}\n\tmr^2 \\ddot{\\theta}_1 + 4mr^2 \\ddot{\\theta}_1 + 2mr^2 \\cos (\\theta_1 - \\theta_2) \\ddot{\\theta}_2 +  2mr^2 \\cos (\\theta_1 - \\theta_2) \\dot{\\theta}_2 (\\dot{\\theta}_2 - \\dot{\\theta}_1)  =\\\\ - 2mr^2 \\sin (\\theta_1 - \\theta_2)\\dot{\\theta}_1 \\dot{\\theta}_2 + mgr\\sin \\theta_1 + 2mgr \\sin \\theta_1\n\t\\end{align*}\n\t\\begin{equation*}\n\tmr^2 \\ddot{\\theta}_2 + 2mr^2 \\cos (\\theta_1 - \\theta_2) \\ddot{\\theta}_1 +  2mr^2 \\cos (\\theta_1 - \\theta_2) \\dot{\\theta}_1 (\\dot{\\theta}_2 - \\dot{\\theta}_1) = 2mr^2 \\sin (\\theta_1 - \\theta_2)\\dot{\\theta}_1 \\dot{\\theta}_2 + mgr \\sin \\theta_2\n\t\\end{equation*}\n\tIn the above equations of motion, we substitute, $ \\theta_1 = 0, \\theta_2 = \\epsilon \\ll 1, \\dot{\\theta}_1 = \\dot{\\theta}_2 = 0 $,\n\t\\begin{align*}\n\t5mr^2 \\ddot{\\theta}_1 + 2mr^2 \\ddot{\\theta}_2  &= 0 \\qq{and}\\\\\n\tmr^2 \\ddot{\\theta}_2 + 2mr^2 \\ddot{\\theta}_1 &= mgr  \\epsilon\n\t\\end{align*}\n\t\\begin{equation*}\n\t\\boxed{\\ddot{\\theta}_1 = -\\dfrac{2g \\epsilon}{r} \\qq{and} \\ddot{\\theta}_2 = \\dfrac{5g \\epsilon}{r}}\n\t\\end{equation*}\n\\end{homeworkProblem}\n\n\\end{document}\n", "meta": {"hexsha": "024fb43daf94aeddc2562aa57044c39961ca7aa1", "size": 19359, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sem1/cmech/assign_4/cmech_assign_4.tex", "max_stars_repo_name": "adivijaykumar/courses", "max_stars_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sem1/cmech/assign_4/cmech_assign_4.tex", "max_issues_repo_name": "adivijaykumar/courses", "max_issues_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sem1/cmech/assign_4/cmech_assign_4.tex", "max_forks_repo_name": "adivijaykumar/courses", "max_forks_repo_head_hexsha": "c0aebb67332ccf0b116a3348923ab2631b586dac", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.7090069284, "max_line_length": 321, "alphanum_fraction": 0.6377395527, "num_tokens": 7869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.4018134811852093}}
{"text": "\\subsection{Six-class Single-moment Bulk Scheme (Tomita 2008)}\nSix-class single-moment bulk scheme in the SCALE was developed by \\citet{tomita_2008}.\nThis scheme predicts mass exchange among six categories of water substances (water vapor, cloud water, rain, cloud ice, snow, and graupel), which is largely based on the method of \\citet{lin_etal_1983}.\nHowever, there are some modifications from the original method of \\citet{lin_etal_1983}: Both cloud water and cloud ice are generated only by a saturation adjustment process, and wet growth process of graupel is omitted.\nAccording to \\citet{tomita_2008}, these modifications result in 20\\% reduction in computational cost compared to \\citet{lin_etal_1983} without significant changes on physical performance.\nIn this subsection, the formulations of the microphysical scheme of \\citet{tomita_2008} are described.\nMass concentrations of water vapor, cloud water, rain, cloud ice, snow, and graupel are indicated by $q_{v}$, $Q_{W}$, $Q_{R}$, $Q_{I}$, $Q_{S}$, and $Q_{G}$ respectively.\n\nIn \\citet{tomita_2008}, cloud microphysics processes except for the saturation adjustment process consist of auto-conversion, accretion, evaporation, sublimation, deposition, melting, freezing, and Bergeron process. When $T < T_{0}$ (= 273.15 K), the tendency of each water substance by these processes can be written as follows:\n\\begin{align}\n  \\frac{\\partial Q_{W}}{\\partial t} &= -P_{RAUT}-P_{RACW}-P_{SACW}-P_{GACW}-P_{SFW}, \\\\\n  \\frac{\\partial Q_{I}}{\\partial t} &= -P_{SAUT}-P_{RACI}-P_{SACI}-P_{GACI}-P_{SFI}, \\\\\n  \\frac{\\partial Q_{R}}{\\partial t} &= P_{RAUT}+P_{RACW}-P_{IACR}-P_{SACR}-P_{GACR}-P_{GFRZ}-P_{REVP}, \\\\\n  \\frac{\\partial Q_{S}}{\\partial t} &= P_{SAUT}-P_{GAUT} \\nonumber \\\\\n  &+P_{SACW}+P_{SACI}+(1-\\delta_{1})P_{RACI}+(1-\\delta_{1})P_{IACR}+\\delta_{2}P_{SACR}-(1-\\delta_{2})P_{RACS}-P_{GACS} \\nonumber \\\\\n  &-(1-\\delta_{3})P_{SSUB}+\\delta_{3}P_{SDEP}+P_{SFW}+P_{SFI}, \\\\\n  \\frac{\\partial Q_{G}}{\\partial t} &= P_{GAUT} \\nonumber \\\\\n  &+P_{GACW}+P_{GACI}+P_{GACR}+P_{GACS}+\\delta_{1}P_{RACI}+\\delta_{1}P_{IACR}+(1-\\delta_{2})P_{SACR}+(1-\\delta_{2})P_{RACS} \\nonumber \\\\\n  &-(1-\\delta_{3})P_{GSUB}+\\delta_{3}P_{GDEP}+P_{GFRZ}, \\\\\n  \\frac{\\partial q_{v}}{\\partial t} &= P_{REVP}+(1-\\delta_{3})P_{SSUB}+(1-\\delta_{3})P_{GSUB}-\\delta_{3}P_{SDEP}-\\delta_{3}P_{GDEP},\n\\end{align}\nwhere $P_{*}$ in the right hand sides are conversion terms listed in Table \\ref{table-tomita08-1}, and $\\delta_{1}$, $\\delta_{2}$, and $\\delta_{3}$ are defined as\n\\begin{align}\n\\delta_{1} &=\n\\begin{cases}\n  1, &{\\rm for\\ } Q_{R} \\geq 10^{-4} {\\rm \\ kg/kg}\\\\\n  0, &{\\rm otherwise}\\\\\n\\end{cases},\n\\\\\n\\delta_{2} &=\n\\begin{cases}\n  1, &{\\rm for\\ } Q_{R} \\leq 10^{-4} {\\rm \\ kg/kg\\ and\\ } Q_{S} \\leq 10^{-4} {\\rm \\ kg/kg}\\\\\n  0, &{\\rm otherwise}\\\\\n\\end{cases},\n\\\\\n\\delta_{3} &=\n\\begin{cases}\n  1, &{\\rm for\\ } S_{ice} \\geq 1\\\\\n  0, &{\\rm otherwise}\\\\\n\\end{cases},\n\\end{align}\nwhere $S_{ice}$ is saturation ratio over ice. When $T \\geq T_{0}$, the tendencies of each water substance can be written as follows:\n\\begin{align}\n  \\frac{\\partial Q_{W}}{\\partial t} &= -P_{RAUT}-P_{RACW}-P_{SACW}-P_{GACW}, \\\\\n  \\frac{\\partial Q_{I}}{\\partial t} &= 0, \\\\\n  \\frac{\\partial Q_{R}}{\\partial t} &= P_{RAUT}+P_{RACW}+P_{SACW}+P_{GACW}+P_{SMLT}+P_{GMLT}-P_{REVP}, \\\\\n  \\frac{\\partial Q_{S}}{\\partial t} &= -P_{GACS}-P_{SMLT}, \\\\\n  \\frac{\\partial Q_{G}}{\\partial t} &= P_{GACS}-P_{GMLT}, \\\\\n  \\frac{\\partial q_{v}}{\\partial t} &= P_{REVP}.\n\\end{align}\nFormulation of each term is described later.\n\\begin{table}[tbh]\n\\begin{center}\n\\caption{List of conversion terms used in six-class single-moment bulk scheme of \\citet{tomita_2008}}\n\\label{table-tomita08-1}\n\\scalebox{0.7}{\n\\begin{tabular}{llll}\n\\hline\nNotation&Description&Direction&Conditions \\\\ \\hline \\hline\n$P_{RAUT}$&Auto-conversion rate of cloud water to form rain&$Q_{W} \\longrightarrow Q_{R}$& \\\\ \\hline\n$P_{SAUT}$&Auto-conversion rate of cloud ice to form snow&$Q_{I} \\longrightarrow Q_{S}$&$T < T_{0}$ \\\\ \\hline\n$P_{GAUT}$&Auto-conversion rate of snow to form graupel&$Q_{S} \\longrightarrow Q_{G}$&$T < T_{0}$ \\\\ \\hline\n$P_{RACW}$&Accretion rate of cloud water by rain&$Q_{W} \\longrightarrow Q_{R}$& \\\\ \\hline\n$P_{SACW}$&Accretion rate of cloud water by snow&$Q_{W} \\longrightarrow Q_{S}$&$T < T_{0}$ \\\\\n&&$Q_{W} \\longrightarrow Q_{R}$&$T \\geq T_{0}$ \\\\ \\hline\n$P_{GACW}$&Accretion rate of cloud water by graupel&$Q_{W} \\longrightarrow Q_{G}$&$T < T_{0}$ \\\\\n&&$Q_{W} \\longrightarrow Q_{R}$&$T \\geq T_{0}$ \\\\ \\hline\n$P_{RACI}$&Accretion rate of cloud ice by rain&$Q_{I} \\longrightarrow Q_{S}$&$T < T_{0}$ and $Q_{R} < 10^{-4}$ kg/kg \\\\\n&&$Q_{I} \\longrightarrow Q_{G}$&$T < T_{0}$ and $Q_{R} \\geq 10^{-4}$ kg/kg \\\\ \\hline\n$P_{SACI}$&Accretion rate of cloud ice by snow&$Q_{I} \\longrightarrow Q_{S}$&$T < T_{0}$ \\\\ \\hline\n$P_{GACI}$&Accretion rate of cloud ice by graupel&$Q_{I} \\longrightarrow Q_{G}$&$T < T_{0}$ \\\\ \\hline\n$P_{IACR}$&Accretion rate of rain by cloud ice&$Q_{R} \\longrightarrow Q_{S}$&$T < T_{0}$ and $Q_{R} < 10^{-4}$ kg/kg \\\\\n&&$Q_{R} \\longrightarrow Q_{G}$&$T < T_{0}$ and $Q_{R} \\geq 10^{-4}$ kg/kg \\\\ \\hline\n$P_{SACR}$&Accretion rate of rain by snow&$Q_{R} \\longrightarrow Q_{S}$&$T < T_{0}$, $Q_{R} \\leq 10^{-4}$ kg/kg, and $Q_{S} \\leq 10^{-4}$ kg/kg \\\\\n&&$Q_{R} \\longrightarrow Q_{G}$&$T < T_{0}$ and ($Q_{R}$ or $Q_{S}$) $> 10^{-4}$ kg/kg \\\\ \\hline\n$P_{GACR}$&Accretion rate of rain by graupel&$Q_{R} \\longrightarrow Q_{G}$&$T < T_{0}$ \\\\ \\hline\n$P_{RACS}$&Accretion rate of snow by rain&$Q_{S} \\longrightarrow Q_{G}$&$T < T_{0}$ and ($Q_{R}$ or $Q_{S}$) $> 10^{-4}$ kg/kg \\\\ \\hline\n$P_{GACS}$&Accretion rate of snow by graupel&$Q_{S} \\longrightarrow Q_{G}$& \\\\ \\hline\n$P_{REVP}$&Evaporation rate of rain&$Q_{R} \\longrightarrow q_{v}$& \\\\ \\hline\n$P_{SSUB}$&Sublimation rate of snow&$Q_{S} \\longrightarrow q_{v}$&$S_{ice} < 1$ \\\\ \\hline\n$P_{GSUB}$&Sublimation rate of graupel&$Q_{G} \\longrightarrow q_{v}$&$S_{ice} < 1$ \\\\ \\hline\n$P_{SDEP}$&Deposition rate of water vapor for snow&$q_{v} \\longrightarrow Q_{S}$&$S_{ice} \\geq 1$ \\\\ \\hline\n$P_{GDEP}$&Deposition rate of water vapor for graupel&$q_{v} \\longrightarrow Q_{G}$&$S_{ice} \\geq 1$ \\\\ \\hline\n$P_{SMLT}$&Melting rate of snow&$Q_{S} \\longrightarrow Q_{R}$&$T \\geq T_{0}$ \\\\ \\hline\n$P_{GMLT}$&Melting rate of graupel&$Q_{G} \\longrightarrow Q_{R}$&$T \\geq T_{0}$ \\\\ \\hline\n$P_{GFRZ}$&Freezing rate of rain to form graupel&$Q_{R} \\longrightarrow Q_{G}$&$T < T_{0}$ \\\\ \\hline\n$P_{SFW}$&Growth rate of snow by Bergeron process from cloud water&$Q_{W} \\longrightarrow Q_{S}$& 243.15 K $\\leq T < T_{0}$ \\\\ \\hline\n$P_{SFI}$&Growth rate of snow by Bergeron process from cloud ice&$Q_{I} \\longrightarrow Q_{S}$& 243.15 K $\\leq T < T_{0}$ \\\\ \\hline\n\\end{tabular}\n}\n\\end{center}\n\\end{table}\n\n\\subsubsection{The saturation adjustment}\nMass exchange among water vapor, cloud water, and cloud ice is controlled by the saturation adjustment.\nIn the SCALE, the saturation adjustment is calculated after the aforementioned conversion processes of the microphysics.\nTo calculate the adjustment process, saturated mass concentration of water vapor is defined as follows:\n\\begin{equation}\n  q^{*}_{v}(T) = q^{*}_{vl}(T)+[1-\\alpha (T)]q^{*}_{vi}(T)\\label{eq:satuqv},\n\\end{equation}\nwhere $q^{*}_{vl}(T)$ is saturated mass concentration of water vapor against liquid phase, $q^{*}_{vi}(T)$ is that for ice phase, and $\\alpha (T)$ is a continuous function which satisfies\n\\begin{align}\n\\begin{cases}\n  \\alpha (T) = 1, & {\\rm \\ for\\ } T \\geq {\\rm \\ 273.15 \\ K} ,\\\\\n  \\alpha (T) = \\frac{T-233.15}{40.0}, & {\\rm \\ for\\ 233.15\\ K \\ } < T < {\\rm \\ 273.15 \\ K},\\\\\n  \\alpha (T) = 0, & {\\rm \\ for\\ } T \\leq {\\rm \\ 233.15 \\ K}.\n\\end{cases}\n\\end{align}\nIf it is supersaturated, water vapor is converted into cloud water and cloud ice.\nIf it is unsaturated, cloud water and cloud ice are converted into water vapor.\nAs a conserved quantity for the adjustment process, the moist internal energy is also defined as follows:\n\\begin{align}\n  U_{0}&=[q_{d}c_{vd}+q_{v}c_{vv}+(Q_{W}+Q_{R})c_{l}+(Q_{I}+Q_{S}+Q_{G})c_{s}]T \\nonumber \\\\ \n  &+q_{v}L_{v}-(Q_{I}+Q_{S}+Q_{G})L_{f},\n\\end{align}\nwhere $L_{v}$ is the latent heat between water vapor and liquid water, $L_{f}$ is that between liquid water and solid water. In addition, the sum of the mass concentration of water vapor, cloud water, and cloud ice\n\\begin{equation}\n  q_{sum}=q_{v}+Q_{W}+Q_{I},\n\\end{equation}\ndoes not change through the saturation adjustment.\n\nFirst, it is assumed that all of the cloud water $Q_{W}$ and cloud ice $Q_{I}$ evaporate.\nIn this case, the mass concentration of water vapor becomes equal to $q_{sum}$ and the temperature decreases due to the evaporation.\nThe moist internal energy can be written as\n\\begin{align}\n  U_{1}&=[q_{d}c_{vd}+q_{sum}c_{vv}+Q_{R}c_{l}+(Q_{S}+Q_{G})c_{s}]T_{1} \\nonumber \\\\ \n  &+q_{sum}L_{v}-(Q_{S}+Q_{G})L_{f}.\n\\end{align}\nSince the moist internal energy does not change through the saturation adjustment, we can obtain the new temperature value $T_{1}$ easily by solving $U_{0}=U_{1}$. Then, if $q_{sum}$ is less than saturated mass concentration of water vapor at this temperature (i.e. $q_{sum}<q^{*}_{v} (T_{1})$), no saturation occurs and the new values of water vapor $q^{\\prime}_{v}$, cloud water $Q^{\\prime}_{W}$, cloud ice $Q^{\\prime}_{I}$, and temperature $T^{\\prime}$ are determined as\n\\begin{align}\n\\begin{cases}\n  q^{\\prime}_{v} &= q_{sum}, \\\\\n  Q^{\\prime}_{W} &= 0, \\\\\n  Q^{\\prime}_{I} &= 0, \\\\\n  T^{\\prime} &= T_{1}.\n\\end{cases}\n\\end{align}\n\nIf $q_{sum}$ exceeds $q^{*}_{v} (T_{1})$, saturation occurs. In this case, new temperature value $T_{2}$ should be determined by satisfying the equations of\n\\begin{align}\n  U_{0}&=[q_{d}c_{vd}+q^{*}_{v}(T_{2})c_{vv}+(Q_{W2}+Q_{R})c_{l}+(Q_{I2}+Q_{S}+Q_{G})c_{s}]T_{2} \\nonumber \\\\ \n  &+q^{*}_{v}(T_{2})L_{v}-(Q_{I2}+Q_{S}+Q_{G})L_{f}\\label{eq:newu}, \\\\\n  Q_{W2}&=[q_{sum}-q^{*}_{v}(T_{2})]\\alpha (T_{2})\\label{eq:newqw}, \\\\\n  Q_{I2}&=[q_{sum}-q^{*}_{v}(T_{2})](1-\\alpha (T_{2}))\\label{eq:newqi}.\n\\end{align}\nEqs. (\\ref{eq:satuqv}) and (\\ref{eq:newu}-\\ref{eq:newqi}) are solved numerically and the new values are determined as\n\\begin{align}\n\\begin{cases}\n  q^{\\prime}_{v} &= q^{*}_{v}(T_{2}), \\\\\n  Q^{\\prime}_{W} &= Q_{W2}, \\\\\n  Q^{\\prime}_{I} &= Q_{I2}, \\\\\n  T^{\\prime} &= T_{2}.\n\\end{cases}\n\\end{align}\n\n\\subsubsection{Fundamental characteristics of precipitation particles}\nIn the reminder of this subsection, the formulations of all conversion terms listed in Table \\ref{table-tomita08-1} are shown.\nBefore that, however, it is necessary to clarify assumptions about the characteristics of precipitation particles (rain, snow, and graupel).\nIn \\citet{tomita_2008}, it is assumed that seizes of precipitation particles obey the Marshall-Palmer exponential size distribution:\n\\begin{equation}\n  n_{[R,S,G]}(D) = N_{0[R,S,G]}\\exp(-\\lambda_{[R,S,G]}D)\\label{eq:size_dist},\n\\end{equation}\nwhere $D$ is the diameter of particle, $N_{0}$ is an intercept parameter, and $\\lambda$ is a slope parameter. The subscriptions of $R$, $S$, and $G$ denote rain, snow, and graupel, respectively. In the SCALE, each intercept parameter has values of\n\\begin{align}\n\\begin{cases}\n  N_{0R}&=8.0\\times 10^{6}{\\rm \\ m^{-4}}, \\\\ \n  N_{0S}&=3.0\\times 10^{6}{\\rm \\ m^{-4}}, \\\\ \n  N_{0G}&=4.0\\times 10^{6}{\\rm \\ m^{-4}}.\n\\end{cases}\n\\end{align}\nThe mass and terminal velocity of each particle are described as\n\\begin{align}\n  m_{[R,S,G]}(D) &= a_{[R,S,G]}D^{b_{[R,S,G]}}\\label{eq:particle_mass} \\\\\n  v_{t[R,S,G]}(D) &= c_{[R,S,G]}D^{d_{[R,S,G]}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}\n\\end{align}\nwhere $\\rho_{0}$ ($=1.28\\rm \\ kg/m^{3}$) is a reference density, and $a$, $b$, $c$, and $d$ are coefficients depending on the particle shape. All precipitation particles are treated as spherical, thus\n\\begin{align}\n  &a_{R}=\\pi \\rho_{w}/6,\\quad a_{S}=\\pi \\rho_{S}/6,\\quad a_{G}=\\pi \\rho_{G}/6, \\\\\n  &b_{R}=b_{S}=b_{G}=3,\n\\end{align}\nwhere $\\rho_{w}=1000 {\\rm \\ kg/m^{3}}$, $\\rho_{S}=100 {\\rm \\ kg/m^{3}}$, $\\rho_{G}=400 {\\rm \\ kg/m^{3}}$. The coefficients $c$ and $d$ are determined empirically. In the SCALE, their values are\n\\begin{align}\n  c_{R}=130.0,\\quad c_{S}=4.84,\\quad c_{G}=82.5, \\\\\n  d_{R}=0.5,\\quad d_{S}=0.25,\\quad d_{G}=0.5,\n\\end{align}\nThe slope parameters are determined from Eqs. (\\ref{eq:size_dist}) and (\\ref{eq:particle_mass}) as\n\\begin{equation}\n  \\lambda=\\left[\\frac{aN_{0}\\Gamma (b+1)}{\\rho Q}\\right]^{1/(b+1)}\\label{eq:lambda},\n\\end{equation}\nwhere $\\Gamma$ is the gamma function. The bulk terminal velocities are derived as\n\\begin{equation}\n  V_{T}=c\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}\\frac{\\Gamma(b+d+1)}{\\Gamma(b+1)\\lambda^{d}}\\label{eq:tvelocity}.\n\\end{equation}\nNote that subscription $R$, $S$, and $G$ in Eqs. (\\ref{eq:lambda}) and (\\ref{eq:tvelocity}) are omitted for simplicity.\n\n\\subsubsection{Auto-conversion terms}\nThe auto-conversion rate of cloud water to form rain ($P_{RAUT}$) is given as\n\\begin{equation}\n  P_{RAUT}=\\frac{1}{\\rho}\\left[16.7\\times(\\rho Q_{W})^{2}\\left(5+\\frac{3.6\\times10^{-5}N_{d}}{D_{d}\\rho Q_{W}}\\right)^{-1}\\right],\n\\end{equation}\nwhere $N_{d}$ is the number concentration of cloud water ($N_{d}=50 {\\rm \\ cm^{-3}}$ in the SCALE) and $D_{d}$ is given as\n\\begin{equation}\n  D_{d}=0.146-5.964\\times10^{-2}\\ln{\\frac{N_{d}}{2000}}.\n\\end{equation}\nThe auto-conversion rate of cloud ice to form snow ($P_{SAUT}$) is given as\n\\begin{equation}\n  P_{SAUT}=\\beta_{1}(Q_{I}-Q_{I0}),\n\\end{equation}\nwhere $Q_{I0}$ is set to 0 kg/kg and $\\beta_{1}$ is formulated as\n\\begin{equation}\n  \\beta_{1}=\\beta_{10}\\exp[\\gamma_{SAUT}(T-T_{0})].\n\\end{equation}\n$\\beta_{10}$ and $\\gamma_{SAUT}$ are set to 0.001 and 0.025, respectively, in \\citet{tomita_2008}. In the SCALE, however, they are set to 0.006 and 0.06 as default settings. The auto-conversion rate of snow to form graupel ($P_{GAUT}$) is given as\n\\begin{equation}\n  P_{GAUT}=\\beta_{2}(Q_{S}-Q_{S0}),\n\\end{equation}\nwhere $Q_{S0}$ is set to $6\\times10^{-4}$ kg/kg and $\\beta_{2}$ is formulated as\n\\begin{equation}\n  \\beta_{2}=\\beta_{20}\\exp[\\gamma_{GAUT}(T-T_{0})].\n\\end{equation}\n$\\beta_{20}$ and $\\gamma_{GAUT}$ are set to 0.001 and 0.09, respectively, in \\citet{tomita_2008}. In the SCALE, however, $\\beta_{20} = 0$ as a default setting, which means that auto-conversion of snow to graupel is turned off.\n\n\\subsubsection{Accretion terms}\nAccretion of cloud particles by precipitation particles ($P_{RACW}$, $P_{SACW}$, $P_{GACW}$, $P_{RACI}$, $P_{SACI}$, and $P_{GACI}$) can be derived as\n\\begin{align}\n  P_{RACW} &=E_{RW}Q_{W}\\int_{0}^{\\infty}\\frac{\\pi}{4}D^{2}v_{tR}(D)n_{R}(D)dD \\nonumber \\\\\n  &=\\frac{\\pi E_{RW}N_{0R}c_{R}Q_{W}\\Gamma(3+d_{R})}{4\\lambda^{3+d_{R}}_{R}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}, \\\\\n  P_{SACW} &=\\frac{\\pi E_{SW}N_{0S}c_{S}Q_{W}\\Gamma(3+d_{S})}{4\\lambda^{3+d_{S}}_{S}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}, \\\\\n  P_{GACW} &=\\frac{\\pi E_{GW}N_{0G}c_{G}Q_{W}\\Gamma(3+d_{G})}{4\\lambda^{3+d_{G}}_{G}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}, \\\\\n  P_{RACI} &=\\frac{\\pi E_{RI}N_{0R}c_{R}Q_{I}\\Gamma(3+d_{R})}{4\\lambda^{3+d_{R}}_{R}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}, \\\\\n  P_{SACI} &=\\frac{\\pi E_{SI}N_{0S}c_{S}Q_{I}\\Gamma(3+d_{S})}{4\\lambda^{3+d_{S}}_{S}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2}, \\\\\n  P_{GACI} &=\\frac{\\pi E_{GI}N_{0G}c_{G}Q_{I}\\Gamma(3+d_{G})}{4\\lambda^{3+d_{G}}_{G}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2},\n\\end{align}\nwhere $E_{RW}$, $E_{SW}$, $E_{GW}$, $E_{RI}$, $E_{SI}$, and $E_{GI}$ are collection efficiency of each accretion process. In the SCALE, $E_{RW} = E_{SW} = E_{GW} = E_{RI} = 1$, $E_{GI} = 0.1$, and $E_{SI}$ is formulated as\n\\begin{equation}\n  E_{SI}=\\exp[\\gamma_{SACI}(T-T_{0})],\n\\end{equation}\nwhere $\\gamma_{SACI}$ is set to 0.025.\nWhen the accretion of cloud ice by rain occurs, rain freezes to become snow or graupel.\nThus, the conversion term from rain to these particles ($P_{IACR}$) should be considered.\nIt is derived as\n\\begin{align}\n  P_{IACR}&=\\frac{1}{\\rho}\\int_{0}^{\\infty}N_{I}E_{RI}\\frac{\\pi}{4}D^{2}v_{tR}(D)m_{R}(D)n_{R}(D)dD \\nonumber \\\\\n  &=\\frac{\\pi a_{R}E_{RI}Q_{I}N_{0R}c_{R}\\Gamma(6+d_{R})}{4M_{I}\\lambda^{6+d_{R}}_{R}}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/2},\n\\end{align}\nwhere $N_{I}$ is the number concentration of cloud ice, and $M_{I}$ ($=4.19\\times10^{-13}$ kg) is mass of cloud ice particle.\n\nAccretion of precipitation particles ($P_{SACR}$, $P_{GACR}$, and $P_{GACS}$) can be derived as\n\\begin{align}\n  P_{SACR}&= \\frac{1}{\\rho}\\int_{0}^{\\infty}E_{SR}m_{R}(D_{R})n_{R}(D_{R})\\left[\\int_{0}^{\\infty}\\frac{\\pi}{4}(D_{S}+D_{R})^{2}|V_{TS}-V_{TR}|n_{S}(D_{S})dD_{S}\\right]dD_{R} \\nonumber \\\\\n  &=\\frac{\\pi a_{R}|V_{TS}-V_{TR}|E_{SR}N_{0S}N_{0R}}{4\\rho} \\nonumber \\\\\n  &\\times\\left[\\frac{\\Gamma(b_{R}+1)\\Gamma(3)}{\\lambda^{b_{R}+1}_{R}\\lambda^{3}_{S}}+2\\frac{\\Gamma(b_{R}+2)\\Gamma(2)}{\\lambda^{b_{R}+2}_{R}\\lambda^{2}_{S}}+\\frac{\\Gamma(b_{R}+3)\\Gamma(1)}{\\lambda^{b_{R}+3}_{R}\\lambda_{S}}\\right], \\\\\n  P_{GACR}&=\\frac{\\pi a_{R}|V_{TG}-V_{TR}|E_{GR}N_{0G}N_{0R}}{4\\rho} \\nonumber \\\\\n  &\\times\\left[\\frac{\\Gamma(b_{R}+1)\\Gamma(3)}{\\lambda^{b_{R}+1}_{R}\\lambda^{3}_{G}}+2\\frac{\\Gamma(b_{R}+2)\\Gamma(2)}{\\lambda^{b_{R}+2}_{R}\\lambda^{2}_{G}}+\\frac{\\Gamma(b_{R}+3)\\Gamma(1)}{\\lambda^{b_{R}+3}_{R}\\lambda_{G}}\\right], \\\\\n  P_{GACS}&=\\frac{\\pi a_{S}|V_{TG}-V_{TS}|E_{GS}N_{0G}N_{0S}}{4\\rho} \\nonumber \\\\\n  &\\times\\left[\\frac{\\Gamma(b_{S}+1)\\Gamma(3)}{\\lambda^{b_{S}+1}_{S}\\lambda^{3}_{G}}+2\\frac{\\Gamma(b_{S}+2)\\Gamma(2)}{\\lambda^{b_{S}+2}_{S}\\lambda^{2}_{G}}+\\frac{\\Gamma(b_{S}+3)\\Gamma(1)}{\\lambda^{b_{S}+3}_{S}\\lambda_{G}}\\right],\n\\end{align}\nwhere $E_{SR}$, $E_{GR}$, and $E_{GS}$ are collection efficiency of each accretion process. Note that terminal velocity for each particle size is approximated by the bulk terminal velocity (e.g. $|v_{tS}(D_{S})-v_{tR}(D_{R})| \\simeq |V_{TS}-V_{TR}|$). In the SCALE, $E_{SR} = E_{GR} = 1$, and $E_{GS}$ is formulated as\n\\begin{equation}\n  E_{GS}=\\min(1,\\exp[\\gamma_{GACS}(T-T_{0})]),\n\\end{equation}\nwhere $\\gamma_{GACS}$ is set to 0.09.\nWhen the accretion of rain by snow occurs under the condition of $Q_{R} > 10^{-4}$ kg/kg or $Q_{S} > 10^{-4}$ kg/kg, graupel particle is generated.\nThus, the conversion term from snow to graupel ($P_{RACS}$) should be also considered.\nIt can be written as\n\\begin{align}\n  P_{RACS}&=\\frac{\\pi a_{S}|V_{TR}-V_{TS}|E_{SR}N_{0R}N_{0S}}{4\\rho} \\nonumber \\\\\n  &\\times\\left[\\frac{\\Gamma(b_{S}+1)\\Gamma(3)}{\\lambda^{b_{S}+1}_{S}\\lambda^{3}_{R}}+2\\frac{\\Gamma(b_{S}+2)\\Gamma(2)}{\\lambda^{b_{S}+2}_{S}\\lambda^{2}_{R}}+\\frac{\\Gamma(b_{S}+3)\\Gamma(1)}{\\lambda^{b_{S}+3}_{S}\\lambda_{R}}\\right].\n\\end{align}\n\n\\subsubsection{Evaporation, sublimation, and deposition}\nEvaporation rate of rain ($P_{REVP}$) is described as\n\\begin{align}\n  P_{REVP}&=\\frac{2\\pi N_{0R}(1-\\min(S_{liq},1))G_{w}(T)}{\\rho} \\nonumber \\\\\n  &\\times\\left[f_{1R}\\frac{\\Gamma(2)}{\\lambda^{2}_{R}}+f_{2R}c^{1/2}_{R}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/4}\\nu^{-1/2}\\frac{\\Gamma(\\frac{5+d_{R}}{2})}{\\lambda^{\\frac{5+d_{R}}{2}}_{R}}\\right],\n\\end{align}\nwhere $S_{liq}$ is saturation ratio over liquid, coefficients $f_{1R}$ and $f_{2R}$ are 0.78 and 0.27 respectively, $\\nu$ is the kinematic viscosity of air, and $G_{w}(T)$ is the thermodynamic function for liquid water given as\n\\begin{equation}\n  G_{w}(T)=\\left[\\frac{L_{v}}{K_{a}T}\\left(\\frac{L_{v}}{R_{v}T}-1\\right)+\\frac{1}{\\rho q^{*}_{vl}(T)K_{d}}\\right]^{-1},\n\\end{equation}\nwhere $K_{a}$ is the thermal diffusion coefficient of air and $K_{d}$ is the diffusion coefficient of water vapor in air. $P_{REVP}$ works only when $S_{liq}$ is less than 1 (i.e. unsaturated condition).\n\nSublimation and deposition rates for snow ($P_{SSUB}$ and $P_{SDEP}$) are described by the same equation:\n\\begin{align}\n  P^{*}_{SSUB,SDEP}&=\\frac{2\\pi N_{0S}(1-S_{ice})G_{i}(T)}{\\rho} \\nonumber \\\\\n  &\\times\\left[f_{1S}\\frac{\\Gamma(2)}{\\lambda^{2}_{S}}+f_{2S}c^{1/2}_{S}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/4}\\nu^{-1/2}\\frac{\\Gamma(\\frac{5+d_{S}}{2})}{\\lambda^{\\frac{5+d_{S}}{2}}_{S}}\\right],\n\\end{align}\nwhere coefficients $f_{1S}$ and $f_{2S}$ are 0.65 and 0.39 respectively, and $G_{i}(T)$ is the thermodynamic function for ice water given as\n\\begin{equation}\n  G_{i}(T)=\\left[\\frac{L_{s}}{K_{a}T}\\left(\\frac{L_{s}}{R_{v}T}-1\\right)+\\frac{1}{\\rho q^{*}_{vi}(T)K_{d}}\\right]^{-1},\n\\end{equation}\nwhere $L_{s}$ is the latent heat between water vapor and solid water. If it is unsaturated ($S_{ice} < 1$), the sublimation rate of snow is given as\n\\begin{equation}\n  P_{SSUB}=P^{*}_{SSUB,SDEP}.\n\\end{equation}\nIf it is supersaturated ($S_{ice} \\geq 1$), the deposition rate of water vapor for snow is given as\n\\begin{equation}\n  P_{SDEP}=-P^{*}_{SSUB,SDEP}.\n\\end{equation}\nAlso sublimation and deposition rates for graupel ($P_{GSUB}$ and $P_{GDEP}$) are described by\n\\begin{align}\n  P^{*}_{GSUB,GDEP}&=\\frac{2\\pi N_{0G}(1-S_{ice})G_{i}(T)}{\\rho} \\nonumber \\\\\n  &\\times\\left[f_{1G}\\frac{\\Gamma(2)}{\\lambda^{2}_{G}}+f_{2G}c^{1/2}_{G}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/4}\\nu^{-1/2}\\frac{\\Gamma(\\frac{5+d_{G}}{2})}{\\lambda^{\\frac{5+d_{G}}{2}}_{G}}\\right],\n\\end{align}\nwhere coefficients $f_{1G}$ and $f_{2G}$ are 0.78 and 0.27 respectively. If it is unsaturated ($S_{ice} < 1$), the sublimation rate of graupel is given as\n\\begin{equation}\n  P_{GSUB}=P^{*}_{GSUB,GDEP}.\n\\end{equation}\nIf it is supersaturated ($S_{ice} \\geq 1$), the deposition rate of water vapor for graupel is given as\n\\begin{equation}\n  P_{GDEP}=-P^{*}_{GSUB,GDEP}.\n\\end{equation}\n\n\\subsubsection{Melting and freezing}\nWhen $T \\geq T_{0}$, snow particle melts to become rain. The melting rate of snow is described as\n\\begin{align}\n  P_{SMLT}&=\\frac{2\\pi K_{a}(T-T_{0})N_{0S}}{\\rho L_{f}} \\nonumber \\\\\n  &\\times\\left[f_{1S}\\frac{\\Gamma(2)}{\\lambda^{2}_{S}}+f_{2S}c^{1/2}_{S}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/4}\\nu^{-1/2}\\frac{\\Gamma(\\frac{5+d_{S}}{2})}{\\lambda^{\\frac{5+d_{S}}{2}}_{S}}\\right] \\nonumber \\\\\n  &+\\frac{c_{l}(T-T_{0})}{L_{f}}(P_{SACW}+P_{SACR}).\n\\end{align}\nThe last term indicates that the accretions of cloud water and rain promote snow melting. Similarly, the melting rate of graupel is described as\n\\begin{align}\n  P_{GMLT}&=\\frac{2\\pi K_{a}(T-T_{0})N_{0G}}{\\rho L_{f}} \\nonumber \\\\\n  &\\times\\left[f_{1G}\\frac{\\Gamma(2)}{\\lambda^{2}_{G}}+f_{2G}c^{1/2}_{G}\\left(\\frac{\\rho_{0}}{\\rho}\\right)^{1/4}\\nu^{-1/2}\\frac{\\Gamma(\\frac{5+d_{G}}{2})}{\\lambda^{\\frac{5+d_{G}}{2}}_{G}}\\right] \\nonumber \\\\\n  &+\\frac{c_{l}(T-T_{0})}{L_{f}}(P_{GACW}+P_{GACR}).\n\\end{align}\n\nWhen $T < T_{0}$, rain particle freezes to become graupel. The freezing rate of rain is described as\n\\begin{equation}\n  P_{GFRZ}=20\\pi^{2}B^{\\prime}N_{0R}\\frac{\\rho_{w}}{\\rho}\\frac{\\exp[A^{\\prime}(T_{0}-T)]-1}{\\lambda^{7}_{R}},\n\\end{equation}\nwhere $A^{\\prime}=0.66 {\\rm \\ K^{-1}}$ and $B^{\\prime}=100 {\\rm \\ m^{-3} \\ s^{-1}}$.\n\n\\subsubsection{Bergeron process}\nWhen cloud water and cloud ice coexist under the condition of $T < T_{0}$, supercooled cloud water evaporates and diffuses to cloud ice because the saturated vapor pressure over liquid water is higher than that for solid water. This process is called Bergeron process. Through this process, cloud ice particle grows to become precipitating snow particle. Thus, mass conversion from cloud water and cloud ice to snow occurs. Conversion rates of cloud water ($P_{SFW}$) and cloud ice ($P_{SFI}$) are formulated as\n\\begin{align}\n  P_{SFW}&=N_{I50}(a_{1}m^{a_{2}}_{I50}+\\pi E_{IW}\\rho Q_{W}R^2_{I50}U_{I50}), \\\\\n  P_{SFI}&=Q_{I}/\\Delta t_{1},\n\\end{align}\nwhere $m_{I50}$ ($=4.8\\times10^{-10} {\\rm \\ kg}$) and $U_{I50}$ ($=1{\\rm \\ m/s}$) denotes mass and terminal velocity of ice particle having a radius of 50 ${\\rm \\mu m}$ ($\\equiv R_{I50}$), and $E_{IW}=1$ is collection efficiency of cloud ice for cloud water. The values of $a_{1}$ and $a_{2}$ is determined from a laboratory experiment by \\citet{koenig_1971}. $\\Delta t_{1}$ is the time during which an ice particle of 40 ${\\rm \\mu m}$ grows to 50 ${\\rm \\mu m}$, which is formulated as\n\\begin{equation}\n  \\Delta t_{1}=\\frac{1}{a_{1}(1-a_{2})}\\left[m^{1-a_{2}}_{I50}-m^{1-a_{2}}_{I40}\\right],\n\\end{equation}\nwhere $m_{I40}=2.46\\times10^{-10} {\\rm \\ kg}$. $N_{I50}$ is the number concentration of 50 ${\\rm \\mu m}$ ice particle which is formulated as\n\\begin{equation}\n  N_{I50}=q_{I50}/m_{I50}=\\frac{Q_{I}\\Delta t}{m_{I50}\\Delta t_{1}}.\n\\end{equation}\nIn the SCALE, the Bergeron process occurs only when 243.15 K $\\leq T<T_{0}$.\n\n\\subsubsection{Optional schemes in the SCALE}\nThere are some optional schemes which can be applied to the six-class single-moment bulk microphysics. Cloud ice generation can be explicitly solved as the original method of \\citet{lin_etal_1983}, instead of the saturation adjustment process. Conversion terms of cloud water to rain ($P_{RAUT}$ and $P_{RACW}$) can be replaced with those used in \\citet{khairoutdinov_and_kogan_2000}. Intercept parameters of particle size distribution ($N_{0R}$, $N_{0S}$, $N_{0G}$) can be diagnostically derived by using the equation of \\citet{wainwright_etal_2014}, instead of the constant values. Bimodal particle size distribution can be applied to snow following \\citet{roh_and_satoh_2007}, instead of the Marshall-Palmer exponential size distribution.\n", "meta": {"hexsha": "ea55f8f7599e18ffc0e5616b3e0ce9d135979b88", "size": 25097, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/descriptions/microphysics_tomita08.tex", "max_stars_repo_name": "slayoo/scale", "max_stars_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-06-14T11:12:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T05:29:55.000Z", "max_issues_repo_path": "doc/descriptions/microphysics_tomita08.tex", "max_issues_repo_name": "slayoo/scale", "max_issues_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-07-29T03:38:05.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-30T05:08:47.000Z", "max_forks_repo_path": "doc/descriptions/microphysics_tomita08.tex", "max_forks_repo_name": "slayoo/scale", "max_forks_repo_head_hexsha": "ca4b476ad55cb728b2009f0427ce3f7161ecfcf7", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-07-10T10:39:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-28T22:20:41.000Z", "avg_line_length": 71.2982954545, "max_line_length": 741, "alphanum_fraction": 0.6569311073, "num_tokens": 9755, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.5, "lm_q1q2_score": 0.40158689346713117}}
{"text": "We now enhance our heat equation example from Section \\ref{sec:HeatEq_1}.\nBelow is an outline of how we will proceed.  Each of these sections contains an \naccompanying tutorial code that builds upon the previous example.\n\\begin{itemize}\n\n\\item In Section \\ref{Sec:Boundary Conditions} we develop the\n  capability to handle other (non-periodic) boundary condition types.\n\n\\item In Section \\ref{Sec:Refinement} we develop the capability to\n  have multiple levels of refinement using a fixed, multilevel grid\n  structure.\n\n\\item In Section \\ref{Sec:AMR} we develop the capability to adaptively\n  change the multilevel grid structure.\n\n\\item In Section \\ref{Sec:Linear Solvers} we develop the capability to\n  solve the equation implicitly, using the linear solver libraries.\n\n\\end{itemize}\n\n\\section{Boundary Conditions}\\label{Sec:Boundary Conditions}\nIn order to understand how to implement boundary conditions, we shall\nfirst describe the general principles behind working with boundary\nconditions.  The {\\tt BoxLib/Tutorials/HeatEquation\\_EX2\\_F/} tutorial\ncontinues our heat equation example, but now with some non-periodic\nboundary condition support.  The boundary condition modules in {\\tt\n  BoxLib/Src/F\\_BaseLib/define\\_bc\\_tower.f90} and {\\tt\n  multifab\\_physbc.f90} can be used as a springboard for developing\nyour own customized boundary conditions.\n\n\\subsection{General Principles}\nThe basic idea is that every grid has knowledge of the\nboundary condition type at the low and high side edge in each direction.\nThe ``physical'' boundary condition types supported by default are {\\tt INLET}, {\\tt OUTLET},\n{\\tt SYMMETRY}, {\\tt SLIP\\_WALL}, {\\tt NO\\_SLIP\\_WALL}, and {\\tt PERIODIC}.\nThere is also an {\\tt INTERIOR} boundary condition type, which \nwill be explained below.  We use an integer mapping that is \ncontained in {\\tt BoxLib/Src/F\\_BaseLib/bc.f90}:\n\\begin{lstlisting}[backgroundcolor=\\color{light-green}]\ninteger, parameter, public :: PERIODIC     = -1\ninteger, parameter, public :: INTERIOR     =  0\n\ninteger, parameter, public :: INLET        = 11\ninteger, parameter, public :: OUTLET       = 12\ninteger, parameter, public :: SYMMETRY     = 13\ninteger, parameter, public ::    SLIP_WALL = 14\ninteger, parameter, public :: NO_SLIP_WALL = 15\n\\end{lstlisting}\n\n{\\bf Examples:}\n\\begin{itemize}\n\\item Consider grid 1 in Figure \\ref{fig:bc_example1}.  The low-x\n  boundary condition is {\\tt INLET}, and the high-y boundary condition\n  is {\\tt NO\\_SLIP\\_WALL}.  The high-x and low-y boundary conditions\n  are {\\tt INTERIOR}, which means that the ghost cells share the same\n  physical space as cells in the valid region of another grid.  Note\n  that for grids 6, 7, 10, and 11, the boundary condition type for\n  every side is {\\tt INTERIOR}.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=4in]{./F_AdvancedTopics/bc_example1}\n\\caption{\\label{fig:bc_example1}Two-dimensional example with 16 -\n  4$^2$grids with {\\tt INLET}, {\\tt OUTLET}, and {\\tt NO\\_SLIP\\_WALL}\n  boundary conditions.  The numbers refer to the grid number.}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\item Figure \\ref{fig:bc_example2} demonstrates a problem with\n  periodicity in the x-direction.  In this case, the low-x boundary\n  condition for grid 1 is {\\tt PERIODIC}.  Note there are some\n  similarities between {\\tt PERIODIC} and {\\tt INTERIOR} boundary\n  conditions when it comes to filling ghost cells in that ghost cell\n  values are simply copied in from the valid region of another grid.\n  In fact, one can think of {\\tt PERIODIC} as just a special type of\n  {\\tt INTERIOR} boundary condition.  For the other boundary\n  conditions types, the user can write custom boundary conditions\n  routines to fill ghost cells, which can involve setting ghost cell\n  values directly, or using interior points and/or physical boundary\n  conditions in some stencil operation.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=4in]{./F_AdvancedTopics/bc_example2}\n\\caption{\\label{fig:bc_example2}Two-dimensional example with 16 - 4$^2$grids with\n{\\tt PERIODIC} and {\\tt NO\\_SLIP\\_WALL} boundary conditions.\nThe numbers refer to the grid number.}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\item Now, consider an example with refined grids.  Figure\n  \\ref{fig:bc_example3} contains three grids at the next level of\n  refinement.  In this case, for grid 1, all of the boundary condition\n  types are {\\tt INTERIOR}, even though the neighboring valid region\n  data is at a coarser level of refinement.  For grid 2, the low-y\n  boundary condition is {\\tt NO\\_SLIP\\_WALL}, and the other three\n  walls are {\\tt INTERIOR}.\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[tb]\n\\centering\n\\includegraphics[width=4in]{./F_AdvancedTopics/bc_example3}\n\\caption{\\label{fig:bc_example3}Two-dimensional example with 3 grids at a finer\nresolution than the base grid.}\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{itemize}\n\n\\subsection{Implementation}\nTypically, we read in integer values from the inputs file for {\\tt\n  bc\\_x\\_lo}, {\\tt bc\\_x\\_hi}, {\\tt bc\\_y\\_lo}, etc., that correspond\nto the physical boundary condition types.  We then build a {\\tt\n  bc\\_tower} object which is an array of {\\tt bc\\_level} objects, one\nfor each level of refinement.  The {\\tt bc\\_level} contains several\ninteger array data structures, as can be seen in {\\tt\n  BoxLib/Src/F\\_BaseLib/define\\_bc\\_tower.f90}:\n\\begin{lstlisting}[backgroundcolor=\\color{light-green}]\ntype bc_level\n\n   ! 1st index is the grid number (grid \"0\" corresponds to the prob domain)\n   ! 2nd index is the direction (1=x, 2=y, 3=z)\n   ! 3rd index is the side (1=lo, 2=hi)\n   ! 4th index is the variable (only assuming 1 variable here)\n   integer, pointer :: phys_bc_level_array(:,:,:) => Null()\n   integer, pointer ::  adv_bc_level_array(:,:,:,:) => Null()\n   integer, pointer ::  ell_bc_level_array(:,:,:,:) => Null()\n\nend type bc_level\n\\end{lstlisting}\nEach level has a {\\tt phys\\_bc\\_level\\_array(0:ngrids,dim,2)} array,\nwhere {\\tt ngrids} is the number of grids on that level, {\\tt dim} is\nthe dimensionality of the simulation, and the third index refers to\nthe lower or upper edge of the grid in that coordinate direction.\nThis stores the {\\it physical description} of the boundary type ({\\tt\n  INLET}, {\\tt OUTLET}, etc.), which is independent of the variables\nthat live on the grid.  The {\\tt phys\\_bc\\_level\\_array(0,:,:)} refers\nto the entire domain.  If an edge of a grid is not a physical\nboundary, then it is set to a default value, typically {\\tt INTERIOR}.\nThese boundary condition types are used to interpret the actual method\nto fill the ghost cells for each variable, as described in {\\tt\n  adv\\_bc\\_level\\_array} and {\\tt ell\\_bc\\_level\\_array}.\n\nWhereas {\\tt phys\\_bc\\_level\\_array} provides a physical description\nof the type of boundary, the array {\\tt adv\\_bc\\_level\\_array}\ndescribes the action to be taken (e.g. reflect, extrapolate, etc.) for\neach variable when filling physical ghost cells on domain boundaries.\nThe prefix ``{\\tt adv\\_}'' is somewhat of a misnomer, as this data\nstructure was originally intended to tell advection (or hyperbolic)\nsolvers how to fill ghost cells, but now is generally used to fill\nphysical domain boundary ghost cells in any instance where the user\nneeds to set them.  The form of this array is {\\tt\n  adv\\_bc\\_level\\_array(0:ngrids,dim,2,nvar)} where the additional\ncomponent, nvar, allows for different state variable that lives on a\ngrid to have different boundary condition actions associated with it.\nFor example, you could have {\\tt nvar=1} correspond to the x-velocity,\n{\\tt nvar=2} correspond to density, and {\\tt nvar=3} correspond to\npressure.  In the {\\tt BoxLib/Tutorials/HeatEquation\\_EX2\\_F/}\ntutorial, there is only one variable, $\\phi$, so obviously {\\tt\n  nvar=1} shall correspond to $\\phi$.  When we build the {\\tt\n  adv\\_bc\\_level\\_array}, we first set all values to {\\tt INTERIOR},\nand then overwrite any physical domain boundary condition types, as\ngiven in {\\tt phys\\_bc\\_level\\_array}.  The {\\tt\n  adv\\_bc\\_level\\_array} types supported by default are (as listed in\n{\\tt BoxLib/Src/F\\_BaseLib/bc.f90}):\n\\begin{lstlisting}[backgroundcolor=\\color{light-green}]\ninteger, parameter, public :: INTERIOR     =  0\n\ninteger, parameter, public :: REFLECT_ODD  =  20\ninteger, parameter, public :: REFLECT_EVEN =  21\ninteger, parameter, public :: FOEXTRAP     =  22\ninteger, parameter, public :: EXT_DIR      =  23\ninteger, parameter, public :: HOEXTRAP     =  24\n\\end{lstlisting}\n\nTo manually fill ghost cells, we call {\\tt multifab\\_physbc}, passing\nin the state multifab along with the {\\tt adv\\_bc\\_level\\_array}.  The\nsubroutines {\\tt physbc\\_1d/2d/3d} in {\\tt\n  BoxLib/Src/F\\_BaseLib/multifab\\_physbc.f90}, indicate how to fill\nghost cells.  For example,\n\\begin{lstlisting}[backgroundcolor=\\color{light-green}]\n  subroutine multifab_physbc(s,start_scomp,start_bccomp,ncomp, &\n                             the_bc_level,time_in,dx_in, &\n                             prob_lo_in,prob_hi_in)\n\n    integer        , intent(in   )           :: start_scomp,start_bccomp\n    integer        , intent(in   )           :: ncomp\n    type(multifab) , intent(inout)           :: s\n    type(bc_level) , intent(in   )           :: the_bc_level\n    real(kind=dp_t), intent(in   ), optional :: time_in,dx_in(:)\n    real(kind=dp_t), intent(in   ), optional :: prob_lo_in(:),prob_hi_in(:)\n\n    ! Local\n    integer                  :: lo(get_dim(s)),hi(get_dim(s))\n    integer                  :: i,ng,dm,scomp,bccomp\n    real(kind=dp_t)          :: time,dx(get_dim(s))\n    real(kind=dp_t)          :: prob_lo(get_dim(s)),prob_hi(get_dim(s))\n    real(kind=dp_t), pointer :: sp(:,:,:,:)\n    \n    ! set optional arguments\n    time    = 0.d0\n    dx      = 0.d0\n    prob_lo = 0.d0\n    prob_hi = 0.d0\n    if (present(time_in))       time = time_in\n    if (present(dx_in))           dx = dx_in\n    if (present(prob_lo_in)) prob_lo = prob_lo_in\n    if (present(prob_hi_in)) prob_hi = prob_hi_in\n\n    ng = nghost(s)\n    dm = get_dim(s)\n    \n    do i=1,nfabs(s)\n       sp => dataptr(s,i)\n       lo = lwb(get_box(s,i))\n       hi = upb(get_box(s,i))\n       select case (dm)\n       case (2)\n          do scomp=start_scomp,start_scomp+ncomp-1\n             bccomp = start_bccomp + scomp - start_scomp\n             call physbc_2d(sp(:,:,1,scomp), lo, hi, ng, &\n                          the_bc_level%adv_bc_level_array(i,:,:,bccomp), &\n                          time, dx, prob_lo, prob_hi)\n          end do\n...\n\n  subroutine physbc_2d(s,lo,hi,ng,bc,time,dx,prob_lo,prob_hi)\n\n    use bl_constants_module\n    use bc_module\n\n    integer        , intent(in   ) :: lo(:),hi(:),ng\n    real(kind=dp_t), intent(inout) :: s(lo(1)-ng:,lo(2)-ng:)\n    integer        , intent(in   ) :: bc(:,:)\n    real(kind=dp_t), intent(in   ) :: time,dx(:),prob_lo(:),prob_hi(:)\n\n    ! Local variables\n    integer :: i,j\n\n    !!!!!!!!!!!!!\n    ! LO-X SIDE\n    !!!!!!!!!!!!!\n\n    if (bc(1,1) .eq. EXT_DIR) then\n       ! set all ghost cell values to a prescribed dirichlet\n       ! value; in this example, we have chosen 1\n       do j = lo(2)-ng, hi(2)+ng\n          s(lo(1)-ng:lo(1)-1,j) = 1.d0\n       end do\n    else if (bc(1,1) .eq. FOEXTRAP) then\n       ! set all ghost cell values to first interior value\n       do j = lo(2)-ng, hi(2)+ng\n          s(lo(1)-ng:lo(1)-1,j) = s(lo(1),j)\n       end do\n...\n\\end{lstlisting}\n\nNote that the optional arguments allow for the use of space and/or\ntime-dependent boundary conditions.\n\n{\\tt ell\\_bc\\_level\\_array} is the analog to {\\tt\n  adv\\_bc\\_level\\_array} for the linear solvers in \\BoxLib.  These\nwill be described in Section \\ref{Sec:Linear Solvers}.\n\n\\section{Multiple Levels of Refinement}\\label{Sec:Refinement}\nIn the {\\tt BoxLib/Tutorials/HeatEquation\\_EX3\\_F/} tutorial, we have\nexpanded our example to the cases of multiple levels of refinement,\nwith the grids fixed in space.  In this example we advance all the\ngrids with the same time step, and perform synchronization operations\nbetween levels.\\\\\n\nThe big change for this tutorial is that we use a \"multilevel layout\"\n{\\tt ml\\_layout} rather than a {\\tt layout}, and also {\\tt multifab\n  phi} and {\\tt dx} are now {\\tt nlevs} sized arrays.  After\ninitializing or updating $\\phi$, we must fill all ghost cell and\nsynchronize the solution between levels.  After we make the fluxes, we\nmust synchronize the fluxes to maintain conservation.\\\\\n\nThere are three key subroutines for filling ghost cells and\nsynchronizing data in multilevel applications.  Each of these involves\na coarse level and a fine level:\n\\begin{itemize}\n\n\\item {\\tt ml\\_cc\\_restriction} sets coarse cell-centered values equal\n  to the average of the fine cells covering it.\n\n\\item {\\tt ml\\_edge\\_restriction} sets coarse edge-centered values\n  (such as fluxes) equal to the average of the fine edges covering it.\n\n\\item {\\tt multifab\\_fill\\_ghost\\_cells} fills fine ghost cells using\n  interpolation from the underlying coarse data.  Note that this\n  operation does not affect ghost cells that would be filled by {\\tt\n    multifab\\_fill\\_boundary} or {\\tt multifab\\_physbc}.\n\n\\end{itemize}\n\n\\section{Adaptive Mesh Refinement}\\label{Sec:AMR}\nNow fully implemented in {\\tt BoxLib/Tutorials/HeatEquation\\_EX4\\_F/}.\nThe basic idea is to ``tag'' the cells you with to refine in {\\tt\n  BoxLib/Src/F\\_BaseLim\\b/tag\\_boxes.f90}.  To write your own\ncustomized tagging criteria, copy {\\tt tag\\_boxes.f90} into your local\ndirectory and modify it, since this copy will take precedence over the\nversion in the \\BoxLib~source.\n\nThere are several new\nparameters that can be set via an inputs file:\n\\begin{itemize}\n\\item {\\tt amr\\_buf\\_width}: radius (in cells) of tagged cells in\n  addition to those already tagged due to the criteria in {\\tt\n    tag\\_boxes.f90}.\n\\item {\\tt cluster\\_minwidth}: any newly created grids must be at\n  least this many cells in each direction.\n\\item {\\tt cluster\\_blocking\\_factor}: any newly created grids must\n  have an integer multiple of this many cells in each direction.\n\\item {\\tt cluster\\_min\\_eff}: This is a real number between 0 and 1\n  that controls how tightly the newly created grids match the tagged\n  cells.  As this value approaches 1, you will have more, smaller\n  grids.  Another way to think of this is that during the grid\n  creation process, at least 100$\\times${\\tt cluster\\_min\\_eff}\n  percent of the cells in each grid at which the grid creation occurs\n  must be tagged cells.\n\\item {\\tt regrid\\_int}: frequency, in time steps, on when to regrid\n  the simulation.\n\\end{itemize}\nIt is worth playing around with the inputs files to see what effect\nthese parameters have on the grid structure.\n\n\\section{Linear Solvers}\\label{Sec:Linear Solvers}\nThe tutorial code {\\tt BoxLib/Tutorials/HeatEquation\\_EX5\\_F/}\ncontains an implicit version of the heat equation example.  Fortran90\n\\BoxLib\\ contains a ``cell-centered'' multigrid solver that solves\nlinear systems of the form:\n\\begin{equation}\n(\\alpha\\mathcal{I} - \\nabla\\cdot\\beta\\nabla)\\phi = \\text{RHS},\n\\end{equation}\nwhere $\\alpha, \\phi$, and RHS are cell-centered \\MultiFab~s, and\n$\\beta$ is an array of \\MultiFab~s that are nodal in exactly one\ndirection (i.e., one face-centered \\MultiFab for each spatial\ndirection).  The Laplacian-like term in the left-hand-side can be\ndiscretized in several ways.  The simplest discretization option is\nsimilar to a 5-point (7-point in 3D) Laplacian:\n\\begin{eqnarray}\n\\nabla\\cdot\\beta\\nabla\\phi_{ij} &=&\n\\frac{1}{\\Delta x} \\left[\\beta_{i+\\myhalf,j}\\frac{\\phi_{i+1,j} - \\phi_{ij}}{\\Delta x} - \\beta_{i-\\myhalf,j}\\frac{\\phi_{ij} - \\phi_{i-1,j}}{\\Delta x}\\right]\\nonumber\\\\\n&&+ \\frac{1}{\\Delta y} \\left[\\beta_{i,j+\\myhalf}\\frac{\\phi_{i,j+1} - \\phi_{ij}}{\\Delta y} - \\beta_{i,j-\\myhalf}\\frac{\\phi_{ij} - \\phi_{i,j-1}}{\\Delta y}\\right].\n\\end{eqnarray}\nA fully implicit discretization of the heat equation,\n\\begin{equation}\n\\frac{\\phi^{n+1} - \\phi^n}{\\Delta t} = \\left[\\nabla\\cdot(\\nabla\\phi)\\right]^{n+1},\n\\end{equation}\nis equivalent to\n\\begin{equation}\n(\\mathcal{I} - \\Delta t\\nabla\\cdot\\nabla)\\phi^{n+1} = \\phi^n.\n\\end{equation}\nThus, we will set $\\alpha=1$, each $\\beta=\\Delta t$, and RHS = $\\phi^n$.\n\n\\section{Subcycling in Time}\\label{Sec:Subcycling}\nIn {\\tt BoxLib/Tutorials/AMR\\_Adv\\_Diff\\_F} we have expanded the\nexplicit version of the heat equation example in \n{\\tt BoxLib/Tutorials/HeatEquation\\_EX4\\_F/} to include an example of\nsubcycling in time.  In the previous examples, which did not use\nsubcycling in time, each level was advanced with the same time step,\nwhich was determined by imposing the CFL criterion at the finest\nlevel.  In the example in {\\tt BoxLib/Tutorials/AMR\\_Adv\\_Diff\\_F},\nwe use both temporal and spatial refinement; \n$\\Delta t$ decreases as $\\Delta x$ decreases so\nthat each level is running at a different time step.  For explicit\nsolution of advection or hyperbolic equations, $\\Delta t / \\Delta x$\nis constant across levels; for explicit solution of parabolic equations, \n$\\Delta t / \\Delta x^2$ is held constant.  This strategy\nrequires fewer steps to be taken at all but the finest levels relative\nto the non-subcycling algorithm, but requires a more sophisticated\nsynchronization algorithm between levels.  Overall, the use of\nsubycling for explicit methods usually reduces runtime despite the\nsynchronization overhead.\n\nWith subycling in time, the advance of each level is called\nrecursively from coarsest to finest,  with interlevel synchronization \nas shown in Figure~\\ref{fig:subcycling_algorithm}. \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{figure}[tb]\n\\centering\n\\includegraphics{./F_AdvancedTopics/subcycling_algorithm}\n\\caption{\\label{fig:subcycling_algorithm} Subcycling algorithm with 3 levels of refinement. \n        $num\\_substeps=2$ is assumed here for clarity. }\n\\end{figure}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%During the single global time step, the algorithm performs\n%${(num\\_substeps)}^{\\ell-1}$ steps at each level $\\ell$ according to\n%the predefined sequence presented in\n%Figure~\\ref{fig:subcycling_algorithm}. The main rule is that coarser\n%levels are always updated before the finer ones. \nTo advance the solution at level $\\ell,$ where we assume $0 < \\ell < \\ell_{max},$\nthe following steps are taken:\n\\begin{itemize}\n\\item Ghost cells at level $\\ell$ are filled, either \nusing interpolation from level $\\ell-1$, physical boundary conditions, or \ncopying from other grids at level $\\ell$. \n\\item Face-based fluxes are computed at level $\\ell$ and used to update the solution at level $\\ell$.\n\\item Fluxes are stored in order to correct cells on the coarse side of any\ncoarse-fine interface.   Level $\\ell$ and (the temporal and spatial average of) \nlevel $\\ell+1$ fluxes will be stored and used to correct level $\\ell$ cells \nadjacent to the interface of levels $\\ell$ and $\\ell+1.$   Similarly, both\n$\\ell-1$ fluxes and (the temporal and spatial average of) level $\\ell$ fluxes\nwill be stored and used to correct level $\\ell-1$ cells \nadjacent to the interface of levels $\\ell-1$ and $\\ell.$ \n\\item This procedure is called recursively $num\\_substeps$ times for level $\\ell+1.$\n\\item The solution at level $\\ell+1$ is averaged down onto level $\\ell$.\n\\end{itemize}\n\n", "meta": {"hexsha": "6b3201e7b90e9d3ae903945d9a80ab19b24c13db", "size": 19276, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Docs/UsersGuide/F_AdvancedTopics/F_AdvancedTopics.tex", "max_stars_repo_name": "BoxLib-Codes/BoxLib", "max_stars_repo_head_hexsha": "330b14363148ebb0b85d1ffd59d07874ddc79e6d", "max_stars_repo_licenses": ["BSD-3-Clause-LBNL"], "max_stars_count": 79, "max_stars_repo_stars_event_min_datetime": "2015-08-03T18:29:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:42:40.000Z", "max_issues_repo_path": "Docs/UsersGuide/F_AdvancedTopics/F_AdvancedTopics.tex", "max_issues_repo_name": "BoxLib-Codes/BoxLib", "max_issues_repo_head_hexsha": "330b14363148ebb0b85d1ffd59d07874ddc79e6d", "max_issues_repo_licenses": ["BSD-3-Clause-LBNL"], "max_issues_count": 22, "max_issues_repo_issues_event_min_datetime": "2016-06-15T20:46:49.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-10T21:33:10.000Z", "max_forks_repo_path": "Docs/UsersGuide/F_AdvancedTopics/F_AdvancedTopics.tex", "max_forks_repo_name": "BoxLib-Codes/BoxLib", "max_forks_repo_head_hexsha": "330b14363148ebb0b85d1ffd59d07874ddc79e6d", "max_forks_repo_licenses": ["BSD-3-Clause-LBNL"], "max_forks_count": 48, "max_forks_repo_forks_event_min_datetime": "2015-08-05T02:19:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-18T12:33:14.000Z", "avg_line_length": 47.1295843521, "max_line_length": 166, "alphanum_fraction": 0.7102095871, "num_tokens": 5285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6001883735630722, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4014541516189151}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsection{Gauge symmetries in QED}\n\n\\marginpar{Tuesday\\\\ 2020-4-7, \\\\ compiled \\\\ \\today}\n\nLast time we wrote the Lagrangian of QED: \n%\n\\begin{align}\n\\mathscr{L}_{QED} = - \\frac{1}{4} F^{\\mu \\nu } F_{\\mu \\nu } \n+ \\overline{\\psi} \\qty(i \\gamma^{\\mu } \\DD_{\\mu } -m) \\psi \n\\,,\n\\end{align}\n%\nwhere \\(\\DD_{\\mu } = \\partial_{\\mu } + i e A_{\\mu }\\).\n\nThis possesses several symmetries: Lorentz (actually, Poincaré) invariance, \\(P\\) (parity), \\(C\\) (charge conjugation), \\(T\\) (time inversion). \n\nWe are also interested in the \\emph{internal} symmetries of this Lagrangian: all the aforementioned symmetries were spacetime ones.\n\nWe know that \\(\\overline{\\psi} = \\psi ^\\dag \\gamma^{0}\\), so if we transform \\(\\psi \\to e^{i \\theta } \\psi \\) the Lagrangian is unchanged, since we also have \\(\\overline{\\psi} \\to e^{-i \\theta } \\overline{\\psi} \\).\nHere, we are taking a \\emph{constant} phase angle \\(\\theta \\): it comes out of the derivative unchanged. \nThis is called a \\(U(1)\\) \\textbf{global} symmetry, since it is the same everywhere in space and since a phase is the same as a \\(1 \\times 1 \\) unitary matrix.\n\nThe following section differs from the notes. \nLet us ignore the interactions of electrons with the EM fields in QED. \nOur world is made of electrons, and we want to describe these free propagating electrons. \nWe take the Lagrangian \n%\n\\begin{align}\n\\mathscr{L}_{\\text{Dirac}} = \\overline{\\psi} \\qty(i \\gamma^{\\mu } \\partial_{\\mu }  -m) \\psi \n\\,,\n\\end{align}\n%\nwhich still has the symmetry \\(\\psi \\to e^{i \\alpha } \\psi \\). \n\nIs this invariant also with respect to a \\emph{local} \\(U(1)\\) symmetry? This looks like \\(\\psi (x) \\to e^{i \\alpha (x)} \\psi (x)\\), where \\(\\alpha (x)\\) is a continuous spacetime scalar function. \n\nThis is a ``promotion'' of the symmetry: why? It seems like a global symmetry is a more general thing\\dots However, the global symmetry is a special case of the local one. \n\nThis local symmetry is called a \\(U(1)\\) \\emph{gauge} symmetry. \nProperly speaking, the global symmetry is also a gauge one but it is commonly called just a global symmetry. \n\nSubstituting in, we get \n%\n\\begin{align}\ne^{-i \\alpha (x)} \\overline{\\psi} \\qty[i \\partial_{\\mu } \\gamma^{\\mu } - m] e^{i \\alpha (x)} \\psi  \n&= \n\\overline{\\psi} \\qty[i \\partial_{\\mu } \\gamma^{\\mu } - m] \\psi  \n + \\overline{\\psi} \\psi i \\gamma^{\\mu }\\partial_{\\mu } \\alpha \n\\,,\n\\end{align}\n%\nso we see that the Lagrangian is \\emph{not} invariant under this gauge symmetry in general. \n\nIf we want the symmetry to hold, we need to introduce a \\emph{compensating} field to cancel out the term.\n\nThe answer is that the thing to add is a vector field \\(A_{\\mu }\\). \nThen, if we transform \n%\n\\begin{align}\nA_{\\mu } \\to A_{\\mu } - \\frac{1}{e} \\partial_{\\mu } \\alpha \n\\,\n\\end{align}\n%\nthis compensates the change, as long as the vector is coupled to the fermion with a term \\(\\overline{\\psi} e \\gamma^{\\mu } A_{\\mu } \\psi \\) in the Lagrangian. \nThis is a profound result: if we wanted to describe a world with only electrons, and we want to have this electron be symmetric with respect to the \\(U(1)\\) gauge symmetry \\(e \\to e^{i \\alpha (x)} e\\) then we \\emph{must} have a vector coupled to it. \n\nThen, we should also insert a term describing the propagation of the free vector \\(A_{\\mu }\\), the kinetic term \\(\\propto F^{\\mu \\nu } F_{\\mu \\nu }\\).\n\nA quote: ``And she said `let there be symmetry', and there was light''.\n\nWe could have just proven that the QED Lagrangian is invariant with respect to \\(U(1)\\) symmetry: however, this reasoning illustrates the point that the symmetry requires the insertion of photons. \n\nOne might ask: how do you know that this is the correct symmetry? \nThe method is trial and error. \n\nCould we have something which is more complicated than a spin 1 mediator? It is basically a guessing game, we see what works. \n\n\\section{QCD}\n\nThis section can also be followed from Peskin \\cite[sec.\\ II.11]{peskinConceptsElementaryParticle2019}.\n\nThis \\(U(1)\\) gauge symmetry is an abelian symmetry, but we also have non-abelian ones: we denote by \\(T^{a}\\) the generators of the group, their Lie algebra is defined by \n%\n\\begin{align}\n\\qty[T^{a}, T^{b}] = if^{abc} T^{c}\n\\,.\n\\end{align}\n\nThe \\emph{structure coefficients} \\(f^{abc}\\) are manifestly antisymmetric in their first two indices. It can also be shown that they are fully antisymmetric. If the group is abelian, we have \\(f^{abc}\\) identically, but this need not be the case.\n\nTo say that these are generators means that any infinitesimal transformation can be written as \n%\n\\begin{align}\n\\Phi \\to \\qty(1 + i \\alpha^{a} t^{a}_{R}) \\Phi \n\\,,\n\\end{align}\n%\nwhere \\(\\alpha^{a}\\) are the parameters of the infinitesimal transformation, while \\(t^{a}_{R}\\) are Hermitian matrices of dimension \\(d_R\\) which make up the representation of the group. There are \\(d_G\\) of them, where \\(d_G\\) is the dimension of the group.\n\nThe finite unitary transformation mapping \\(\\Phi \\to U(\\alpha ) \\Phi \\) can be recovered from here by \n%\n\\begin{align}\nU(\\alpha ) = e^{i \\alpha^{a} t^{a}_{R}} \n\\,.\n\\end{align}\n\nWe will be interested in Lie groups \\(SU(n)\\) with \\(N\\geq 2\\), which are \\(N \\times N\\) unitary matrices with determinant \\(1\\).\n\nFor example, recall that \\(SU(2)\\) has a 2-to-1 correspondence with \\(SO(3)\\). \\(SU(2)\\) describes the rotation of spinors, the generators of their rotation are \\(\\sigma^{i} / 2\\). \n\nLast time we discussed the annihilation  of \\(e^{+} e^{-}\\) into hadrons: we can get protons and neutrons, pions, kaons\\dots\n\nHowever we can simplify by discussing only the creation of quarks. \n\nWhen we compute the cross sections, our calculation seems to be wrong by a factor 3. If we multiply it by 3 we get the correct result. \nSo there are three types of quarks: we categorize them by ``color'', even though it has nothing to do with colors. \n\nWe associated QED  with \\(U(1)\\): is there a group corresponding to Quantum Chromo Dynamics?\nCan we do this with the weak interaction as well? \n\nSince there are three quarks, we are drawn to represent them as triplets. \nSince we know that unitary matrices are nice, we try \\(SU(3)\\). \nWe call this symmetry \\(SU(3)_{\\text{color}}\\). \n\nWe start by giving some general results for \\(N\\)-dimensional groups \\(SU(N)\\): we normalize their representation by imposing\n%\n\\begin{align}\n\\Tr \\qty[t^{a}_{N} t^{b}_{N}] = \\frac{1}{2} \\delta^{ab}\n\\,,\n\\end{align}\n%\nwhere \\(t^{a}_{N}\\) are the Hermitian generators of an \\(N\\)-dimensional unitary representation. If we generalize to an \\(R\\)-dimensional representation, we will have \n%\n\\begin{align}\n\\Tr \\qty[t^{a}_{G} t^{b}_{G}] = C(R) \\delta^{ab}\n\\,,\n\\end{align}\n%\nwhere \\(C(R)\\) is some constant depending only on the dimension of the representation. \n\nA special representation we can choose is the \\textbf{adjoint} representation, which is the one under which the generators of the Lie algebra transform; it is defined by: \n%\n\\begin{align} \\label{eq:adjoint-representation-definition}\n\\qty(t^{a}_{G})^{bc} \\overset{\\text{def}}{=} i f^{abc}\n\\,.\n\\end{align}\n\nBy making use of the Jacobi identities we can show that this is indeed a valid representation of the group, its dimension is that of the group and we have:\n%\n\\begin{align}\n\\Tr \\qty[t^{a}_{G} t^{b}_{G}] = f^{acd} f^{bcd} = C(G) \\delta^{ab}\n\\,,\n\\end{align}\n%\nwhere the constant \\(C(G)\\) is just the dimension \\(N\\) for the adjoint representation.\nFor \\(SU(N)\\) the dimension is \\(N^2 - 1\\): the representation consists of \\(N^2-1\\) matrices, each \\(N \\times N\\).\n\n\\subsection{Non-abelian gauge theory: Yang-Mills}\n\nConsider the Lagrangian \n%\n\\begin{align}\n\\mathscr{L} = \\overline{\\psi} i \\gamma^{\\mu } \\partial_{\\mu }  \\psi \n\\,.\n\\end{align}\n\nThis can describe an electron. Now, let us add an index \\(j\\) in the group \\(G\\), according to which the particle transforms in the \\(R\\)-dimensional (in our case \\(R=3\\)) representation:\n\\begin{align}\n\\mathscr{L} = \\overline{\\psi}_{j} i \\gamma^{\\mu } \\partial_{\\mu } \\psi_{j}\n\\,.\n\\end{align}\n\nUnder the local action of a group \\(G\\) the particle transforms like \n%\n\\begin{align}\n\\psi_{j} (x) \\overset{G}{\\to} \n\\psi^{'}_{j} (x)\n= \\qty(1 + i \\alpha^{a}(x) t^{a}_{R})_{jk} \\psi_{k} \n\\,,\n\\end{align}\n%\nwhere \\(a\\) is an index going from 1 to \\(N^2-1\\). \n\nWe have the same problem we had with \\(U(1)_{\\text{em}}\\): we need to cancel the term coming from the derivative of \\(\\alpha (x)\\), with a one-index object.\nThe variation in the Lagrangian is\n%\n\\begin{align}\n\\delta \\mathscr{L} = \\overline{\\psi}_{j} i \\gamma^{\\mu } \\qty(i \\partial_{\\mu } \\alpha^{a} (x) t^{a}_{R, jk}) \\psi_{k}\n\\,.\n\\end{align}\n\nThe solution is the same: we introduce a coupling to the derivative, which takes the form\n%\n\\begin{align}\n\\DD_{\\mu } \\to \\partial_{\\mu } - i g A_{\\mu }^{a} t^{a}_{R}\n\\,,\n\\end{align}\n%\nwhere \\(g\\) is the strength of the interaction, which is also written as \\(g_{s}\\) in the case of the strong force. \nThe index \\(a\\) goes from \\(1\\) to \\(N^2-1 = 8\\): we must introduce a vector field \\(A\\) for each \\emph{generator} of the required symmetry. \n\nThe beautiful thing is the fact that starting only from the symmetry requirement we can get a full theory. \n\nWe now attribute actual \\emph{existence} to these quantum fields: they are interaction bosons. \nThey must transform like \n%\n\\begin{align}\nA^{a}_{\\mu }(x) &\\to  A^{a}_{\\mu } (x) + \\frac{1}{g} \\partial_{\\mu } \\alpha^{a} (x) + \\overbrace{A^{b}_{\\mu } f^{abc} \\alpha^{c} (x)}^{\\text{new nonabelian term}} \n \\\\\n&=  A^{a}_{\\mu } (x) + \\frac{1}{g} \\DD_{\\mu } \\alpha^{a}(x)\n\\,.\n\\end{align}\n\nThis is derived making use of the adjoint representation definition \\eqref{eq:adjoint-representation-definition}: we are equating \n%\n\\begin{align}\nA^{b}_{\\mu } f^{abc} \\alpha^{c} &= -i A^{b}_{\\mu } t^{b}_{R} \\alpha^{a}  \\\\\nA^{b}_{\\mu } f^{abc} \\alpha^{c} &= -i A^{b}_{\\mu } (i f^{bca}) \\alpha^{c} \\\\\nA^{b}_{\\mu } f^{abc} \\alpha^{c} &= + A^{b}_{\\mu } f^{abc} \\alpha^{c} \n\\marginnote{We can do cyclic permutations of the indices of \\(f^{abc}\\).}\n\\,.\n\\end{align}\n\nIf we assign physical reality to these fields we must give them kinetic terms in the Lagrangian, which will then be \n%\n\\boxalign{\n\\begin{align}\n\\mathscr{L} =\n- \\frac{1}{4} F^{\\mu \\nu a} F^{a}_{\\mu \\nu } + \\overline{\\psi}\n\\qty(i \\gamma^{\\mu } \\DD_{\\mu }-m) \\psi \n\\,,\n\\end{align}}\n%\nwhich looks the same as the QED Lagrangian, but we must be careful: what is \\(F_{\\mu \\nu }^{a}\\)?\nWe might think it is \n%\n\\begin{align}\nF^{a}_{\\mu \\nu } = 2 \\partial_{[\\mu } A^{a}_{\\nu ]}\n\\,,\n\\end{align}\n%\nbut this is not enough: inside the covariant derivative in \\(\\DD_{\\mu } \\alpha \\) in the transformation law we also have \\(A_{\\mu }\\), so we get an additional term, and the final formula looks like \n%\n\\begin{align}\nF^{a}_{\\mu \\nu } = 2 \\partial_{[\\mu } A^{a}_{\\nu ]} + g f^{abc} A^{b}_{\\mu } A^{c}_{\\nu }\n\\,.\n\\end{align}\n\nThis corresponds to the fact that, while there is no photon-photon interaction since \\(U(1)\\) is abelian,  \\(SU(3)\\) is not: so, we do have gluon-gluon interaction. \nNotice that this expression has abelian symmetries as a special case: the term \\(fAA\\) is antisymmetric in the two bosons, so if they commute it vanishes. \nThe square of this field strength is then both Lorentz and gauge invariant.\n\nThis field strength can be interpreted as the Riemann tensor of the Lie group manifold: \n%\n\\begin{align}\n\\qty[\\DD_\\mu , \\DD_\\nu] = -ig F^{a}_{\\mu \\nu } t^{a}_{R}\n\\,.\n\\end{align}\n\nThis is crucial in very high energy situations, such as in the early universe. The dynamics of the field are now more complicated than the ones we find in electrodynamics due to the nonlinear terms.\n\nThe wavefunction \\(\\psi\\) which appears in the Lagrangian will transform in some \\(d\\)-di\\-men\\-sio\\-nal representation of \\(G = SU(3)_c\\). \nIt will have indices like \\(\\psi_{\\alpha , i}\\): \\(\\alpha \\) is a four-dimensional spinorial index, while \\(i\\) is a three-dimensional color index. \n\nThe strong-interaction coupling constant \\(g_s \\) is dimensionless, we also define the parameter\n%\n\\begin{align}\n\\alpha_{s} = \\frac{g_s^2}{4 \\pi }\n\\,.\n\\end{align}\n\nThe coupling term of the gluons with the fields can be made explicit as \n%\n\\begin{align}\n\\overline{\\psi}_{\\alpha, i} \\gamma^{\\mu }_{\\alpha \\beta } A^{a}_{\\mu } \\qty(t^{a})_{ij} \\psi_{\\beta, j}\n\\,,\n\\end{align}\n%\nwhere \\(\\mu \\) is a Lorentz index, \\(i\\) and \\(j\\) are color indices, while \\(\\alpha \\) and \\(\\beta \\) are spinorial indices.\n\n\\end{document}\n", "meta": {"hexsha": "622316b7591d3f3a9b9da80997bf3fe62d54921e", "size": 12390, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/astroparticle_physics/apr07.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/astroparticle_physics/apr07.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/astroparticle_physics/apr07.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 43.4736842105, "max_line_length": 259, "alphanum_fraction": 0.6788539144, "num_tokens": 3888, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4014541460136143}}
{"text": "\\section{Method}\n\\label{sec:method}\n\nIn this section we describe how we calculate full 3D velocities for stars in\nthe Kepler field.\nAround 1 in 3 Kepler targets have an RV from either Gaia, LAMOST, or APOGEE.\nFor these \\nrv\\ stars we calculated 3D velocities using the {\\tt coordinates}\nlibrary of {\\tt astropy} \\citep{astropy2013, astropy2018}.\nThis library performs a series of matrix rotations and translations to convert\nstellar positions and velocities in equatorial\n% , or International Celestial Reference System (ICRS)\ncoordinates into positions and velocities in Galactocentric coordinates.\nIt converts positions, proper motions, parallaxes/distances, and RVs into \\x,\n\\y, \\z, \\vx, \\vy, \\vz.\nWe adopted a Solar position of $r_\\odot = 8.122$ kpc \\citep{gravity2018} and\n$z_\\odot = 20.8$ pc \\citep{bennet2019}, and a Solar velocity of $v\\odot =\n(12.9, 245.6, 7.78)$ \\kms \\citep{drimmel2018}.\nFor stars {\\it without} RVs, we inferred their velocities by marginalizing\nover their RVs using the method described below.\n\n% It has been demonstrated that the dispersion in vertical velocity, \\vz, of a\n% population of stars increases with the age of that population,\n% \\citep[\\eg][]{stromberg1946, wielen1977, nordstrom2004, holmberg2007,\n% holmberg2009, aumer2009, casagrande2011, ting2019, yu2018}.\n% Most AVRs are calibrated using velocities in Galactocentric coordinates, \\vx,\n% \\vy\\ and \\vz, which can only be calculated with full 6-D position and velocity\n% information, \\ie\\ proper motions, position and radial velocity.\n% In \\citet{angus2020} we explored rotational evolution using velocity\n% dispersion as an age proxy, however we used velocity in the direction of\n% Galactic latitude, \\vb, instead of \\vz.\n% This is because \\vb\\ can be calculated without an RV measurement but is a\n% close approximation to \\vz\\ for \\kepler\\ stars due to the orientation of the\n% Kepler field.\n% The \\kepler\\ field lies at low Galactic latitudes, ($\\sim 5-20$\\degrees), so\n% the ${\\bf z}$-direction is similar to the ${\\bf b}$-direction for \\kepler\\\n% stars.\n% However, even at such low latitudes, kinematic ages calculated with \\vb\\\n% instead of \\vz\\ are likely to be systematically larger because of mixing\n% between \\vz, \\vx\\ and \\vy.\n% A direct measurement or precise estimate of \\vz\\ is necessary to calculate\n% accurate kinematic ages.\n\n\\subsection{Inferring 3D velocities (marginalizing over missing RV\nmeasurements)}\n\\label{sec:inference}\n\n% Three-dimensional velocities in galactocentric coordinates: \\vx, \\vy, and \\vz\\\n% can only be directly computed via a transformation from 3D velocities in\n% another coordinate system, like the equatorial coordinates provided by \\gaia:\n% \\mura, \\mudec, and RV.\n% For stars with no measured RV in \\gaia\\ DR2, \\vx, vy, and \\vz\\ can still be\n% inferred from positions and proper motions alone, by marginalizing over\n% missing RV measurements.\nFor each star in our sample without an RV measurement, we inferred \\vx, \\vy,\nand \\vz\\ from the 3D positions -- RA (\\ra), dec (\\dec), and parallax\n(\\parallax), and 2D proper motions (\\mura\\ and \\mudec) provided in the \\gaia\\\nEDR3 catalog \\citep{gaia_edr3}.\nWe also simultaneously inferred distance (instead of using inverse-parallax)\nto model velocities \\citep[see \\eg][]{bailer-jones2015, bailer-jones2018}.\n\nUsing Bayes rule, the posterior probability of the velocity parameters given\nthe Gaia data can be written:\n\\begin{equation}\n    p({\\bf v_{xyz}}, D | \\mu_{\\alpha}, \\mu_{\\delta}, \\alpha, \\delta, \\pi) =\n    p(\\mu_{\\alpha}, \\mu_{\\delta}, \\alpha, \\delta, \\pi | {\\bf v_{xyz}}, D)\n    p({\\bf v_{xyz}}) p(D),\n\\end{equation}\nwhere $D$ is distance and ${\\bf v_{xyz}}$ is the 3D vector of velocities.\nTo evaluate the likelihood function, our model predicts observable data from\nmodel parameters, \\ie\\ it converts \\vx, \\vy\\, \\vz\\ and $D$ to \\pmra, \\pmdec\\\nand \\parallax.\nIn the first step of the model evaluation, cartesian coordinates, \\x, \\y, and\n\\z\\, are calculated from \\ra, \\dec, and $D$ by applying a series of matrix\nrotations, and a translation to account for the Solar position.\nThe cartesian Galactocentric velocity parameters, \\vx, \\vy, and \\vz, are then\nconverted to equatorial coordinates, \\pmra\\ and \\pmdec\\ via another rotation.\nThe posterior PDFs of the parameters \\vx, \\vy, \\vz, and $\\ln(D)$ are sampled\nby evaluating this model over a range of parameter values which are chosen by\nvia the No U-Turns Sampler (NUTS) algorithm in {\\tt PyMC3}.\nAt each set of model parameters the likelihood is calculated via a Gaussian\nlikelihood function, and multiplied by a prior (described below) to produce\nthe posterior probability: the probability of those model parameters given the\ndata.\n\nFor computational efficiency, we used {\\tt PyMC3} to sample the posterior PDFs\nof stellar velocities \\citep{pymc3}.\nThis required that we rewrite the {\\tt astropy} coordinate transformation code\nusing {\\tt numpy} and {\\tt Theano} \\citep{numpy, theano}.\nThe series of rotations and translations required to convert from equatorial\nto Galactocentric coordinates is described in the astropy\ndocumentation\\footnote{\n    https://docs.astropy.org/en/stable/coordinates/galactocentric.html }\n\\citep{astropy2018}.\nFor each star in the \\kepler\\ field, we explored the posteriors of the four\nparameters, \\vx, \\vy, \\vz, and $\\ln(D)$ using the {\\it PyMC3} No U-Turn\nSampler (NUTS) algorithm, and the {\\tt exoplanet} \\python\\ library\n\\citep{exoplanet}.\nWe tuned the {\\it PyMC3} sampler for 1500 steps, with a target acceptance\nfraction of 0.9, then ran four chains of 1000 steps for a total of 4000 steps.\nThis resulted in a $\\hat{r}$-statistic (the ratio of intra-chain to\ninter-chain variance) of around unity, indicating convergence.\nUsing PyMC3 made this inference procedure exceptionally fast -- taking just a\nfew seconds per star on a laptop.\n\n\\subsection{The prior}\n\\label{sec:prior}\n\nAs mentioned previously, the positioning of the \\kepler\\ field at low Galactic\nlatitude allows \\vz\\ to be well-constrained from proper motion measurements\nalone.\nThis also happens to be the case for \\vx, because the direction of the\n\\kepler\\ field is almost aligned with the \\y-axis of the Galactocentric\ncoordinate system and is almost perpendicular to both the \\x\\ and \\z-axes (see\nfigure \\ref{fig:kepler_field}).\nFor this reason, the \\y-direction is similar to the radial direction for\nobservers near the Sun, so \\vy\\ will be poorly constrained for \\kepler\\ stars\nwithout RV measurements.\nOn the other hand, \\vx\\ and \\vz\\ are almost perpendicular to the radial\ndirection and can be precisely inferred with proper motions alone.\n\\begin{figure}[ht!]\n\\caption{\n\\x, \\y\\ and \\z\\ positions of stars observed by \\kepler, showing the\n    orientation of the \\kepler\\ field.\nThe Sun's position is indicated with a Solar symbol.\nThe direction of the field is almost aligned with the \\y-axis and almost\n    perpendicular to the \\x\\ and \\z-axes, which is why \\vx\\ and \\vz\\ can be\n    tightly constrained for \\kepler\\ stars without RVs, but \\vy\\ cannot.\n}\n  \\centering\n    \\includegraphics[width=.7\\textwidth]{kepler_field}\n\\label{fig:kepler_field}\n\\end{figure}\n\nWe constructed a multivariate Gaussian prior PDF over distance and 3D velocity\nusing the Kepler targets {\\it which have RV measurements}.\nWe calculated the means and covariances of the \\vx, \\vy, \\vz\\ and $\\ln(D)$\ndistributions of stars with measured RVs and then used these means and\ncovariances to construct a multivariate Gaussian prior over the velocity and\ndistance parameters for stars {\\it without} RVs.\nVelocity and distance outliers greater than 3-$\\sigma$ were removed before\ncalculating the means and covariances of the distributions.\nThe distance and velocity distributions of Kepler targets with RVs are\ndisplayed in figure \\ref{fig:prior_distributions_2D}.\nThese are the distributions we used to construct the prior.\nThe 1- and 2-$\\sigma$ contours of the multivariate Gaussian prior is shown in\neach panel in red.\nThis figure shows that Gaussian functions only approximately reproduce\nthe true velocity distributions, and do not capture the substructure.\nWe could have chosen a more complex prior that would fit these data better,\nfor example, a mixture of Gaussians, which would capture the moving groups in\nthe Solar neighborhood.\nThis may result in slightly more accurate inferred velocities.\nHowever, since our goal is kinematic age dating, we only need to resolve the\nvertical velocity component to a sufficient precision that will accurately\nallow for calculations of vertical velocity dispersions, so the minor gain in\nprecision will not have a large affect on the end results.\nIn addition, since this prior is constructed using stars with RVs, which may\nhave a slightly different velocity distribution to stars without RVs, we opted\nfor the more uninformative, simple Gaussian prior.\n\n\\begin{figure}[ht!]\n\\caption{\nThe velocity and distance distributions for stars with RV measurements,\n    used to construct a multivariate Gaussian prior over velocity and\n    distance parameters for stars {\\it without} RVs.\nThe 1- and 2-D distributions of the data are shown in black and the prior is\n    indicated in red.\n}\n  \\centering\n    \\includegraphics[width=.8\\textwidth]{prior_distributions_2D}\n\\label{fig:prior_distributions_2D}\n\\end{figure}\n\nOur goal was to infer the velocities of stars {\\it without} RV measurements\nusing a prior calculated from stars {\\it with} RV measurements.\nHowever, stars with and without RVs are likely to be quite different\npopulations, determined by the Gaia, LAMOST and APOGEE selection functions.\nIn particular, stars without RV measurements are more likely to be fainter,\nless luminous, cooler and potentially older.\nFigure \\ref{fig:CMD} shows the populations of stars with and without RVs on\nthe CMD -- stars with RVs are more likely to be upper-main-sequence and red\ngiant stars, and stars without RVs are more likely to be mid and lower\nmain-sequence dwarfs.\n% Lower-mass stars are, on average, older, and have larger velocity dispersions,\n% plus stars in different locations in the Galaxy have different orbital\n% velocities.\nFor this reason, a prior based on the velocity distributions of stars {\\it\nwith} RVs will not necessarily reflect the velocities of those without.\nWe could have opted to construct a prior that depends on CMD position,\nhowever, in practice, this would require making a number of arbitrary choices,\nso we instead opted for a simpler approach.\nIn addition, we find that the \\vx\\ and \\vz\\ velocities we infer are not\nstrongly influenced by the prior, as described below.\n% However, given that \\vx\\ and \\vz\\ are strongly informed by proper motion\n% measurements, and therefore likely to be relatively prior-insensitive, the\n% prior may not significantly impact our final vertical velocities.\n\nWe tested the influence of the prior on the velocities we inferred.\nOne of the main features of the RV selection functions is brightness: Gaia DR2\nRVs are only available for stars brighter than around 14th magnitude, and\nLAMOST DR5 and APOGEE DR16 RVs for stars brighter than around 16th magnitude.\nFor this reason, we tested priors based on stellar populations with different\napparent magnitudes.\nThree priors were tested: one calculated from the velocity distributions of\nthe brightest half of the RV sample (\\gaia\\ $G$-band apparent magnitude $<$\n13), one from the faintest half ($G$ $>$ 13), and one from {\\it all} stars\nwith RVs.\nFigure \\ref{fig:prior_distributions} shows the distributions of the faint\n(blue) and bright (orange) halves of the RV sample as kernel density estimates\n(KDEs).\nThe distributions are different because bright stars are typically more\nmassive, younger, more evolved, and/or closer to the Sun on average than faint\nstars.\nAs a result, these stars occupy slightly different Galactic orbits.\nThe multivariate Gaussian, fit to these distributions, which was used as a\nprior PDF, is shown as single-dimension projections in figure\n\\ref{fig:prior_distributions}.\nThe Gaussian fit to the bright and faint star distributions are shown as\ndashed orange and blue lines, respectively.\nThe Gaussian fit to {\\it all} the data, both bright and faint, is shown as a\nblack solid line.\nThe means of the faint and bright distributions differ by 6 \\kms, 5 \\kms, 1\n\\kms\\ and 0.21 kpc, for \\vx\\, \\vy, \\vz\\ and $\\ln(D)$, respectively.\nThe \\vx, \\vy, and distance distributions of the bright stars are slightly\nnon-Gaussian -- more so than the faint stars.\nThis highlights the inadequacy of using a Gaussian distribution as the prior\n-- a Gaussian is only an approximation of the underlying distribution of stars\nin our sample.\nAs a result of this approximation, inferred velocities that are strongly\nprior-dependent -- (\\ie\\ especially those in the \\y-direction) may inherit\nsome inaccuracies from the Gaussian prior, which is not a perfect\nrepresentation of the underlying data.\nHowever, given that the populations of stars with and without RV measurements\nare different, it may be inappropriate to use a more complex, more\ninformative prior anyway.\n\n\\begin{figure}[ht!]\n\\caption{\n    Velocity and distance distributions of faint (blue) and bright (orange)\n    stars with RVs, shown as KDEs.\n    Gaussian fits to these distributions are shown as dashed lines in\n    corresponding colors.\n    The solid black line shows the Gaussian fit to all data (bright and faint\n    combined) and is the prior we ended up using in our model.\n    This figure highlights the differences between the velocities and\n    distances of bright and faint stars (with RVs) in our sample.\n}\n  \\centering\n    \\includegraphics[width=1\\textwidth]{prior_distributions}\n\\label{fig:prior_distributions}\n\\end{figure}\nWe inferred the velocities of 1000 stars chosen at random from the\nRV Kepler sample using each of these three priors and compared the\ninferred velocity distributions.\nIf the inferred velocities were highly prior-dependent, the resulting\ndistributions, obtained from different priors, would look very different.\nThe results of this test are shown in figure \\ref{fig:prior_comparison}.\nFrom left to right, the three panels show the distributions of inferred \\vx,\n\\vy, \\vz, and log-distance.\nThe blue dashed line shows a KDE representing the distributions of velocities\ninferred using the prior calculated from the faint half of the RV sample.\nSimilarly, the solid orange line shows the distribution of inferred velocities\nusing the prior calculated from the bright half of the RV sample, and the\nsolid black line shows the results of the prior calculated from {\\it all}\nstars with measured RVs.\nIn all but the \\vy\\ panel (second from the left), the blue, orange,\nand black lines lie on top of each other, indicating that different priors do\nnot significantly influence the resulting velocities.\n\nThe median values of the \\vy\\ distributions resulting from the faint and\nbright priors differ by around 4 \\kms.\nThis is similar to the difference in means of the faint and bright populations\n(5 \\kms, as quoted above).\nThe inferred \\vx\\ and \\vz\\ distributions differ by 2 \\kms\\ and 0.3 \\kms,\nrespectively.\nRegardless of the prior choice, the \\vx\\ and \\vz\\ distributions are similar\nbecause velocities in the \\x\\ and \\z-directions are not strongly prior\ndependent: they are tightly constrained with proper motion measurements alone.\nHowever, the distribution of inferred \\vy\\ velocities {\\it does} depend on the\nprior.\nThis is because the \\y-direction is close to the radial direction for \\kepler\\\nstars (see figure \\ref{fig:kepler_field}), and \\vy\\ cannot be tightly\nconstrained without an RV measurement.\nThe distributions of stellar distances are almost identical, irrespective of\nthe prior.\nThis is because distance is very tightly constrained by Gaia parallax and is\nrelatively insensitive to the prior.\n% It is therefore highly dependent on the prior.\n\\begin{figure}[ht!]\n\\caption{\nThe distributions of velocity and distance parameters, inferred using three\n    different priors.\nThe orange line is a KDE that represents the distribution of parameters\n    inferred with a Gaussian prior, estimated from the bright half of the RV\n    sample ($G < $ 13).\nThe blue dashed line shows the results from a prior estimated from the faint\n    half of the RV sample ($G > 13$)).\nThe black line shows the results from a prior calculated from all stars with\n    RV measurements and is the prior we adopt in our final analysis.\n    This figure shows that all parameters except \\vy\\ are relatively\n    insensitive to the three priors that were tested.\n    }\n  \\centering\n    \\includegraphics[width=1\\textwidth]{prior_comparison}\n\\label{fig:prior_comparison}\n\\end{figure}\n\n% Fainter stars have smaller y-velocities than brighter stars because they are,\n% on average, further from the Sun\n\nAlthough this test was performed on stars with RV measurements, which are\nbrighter overall than the sample of stars without RVs (\\eg\\ figure\n\\ref{fig:rv_histogram}), figure \\ref{fig:prior_comparison} nevertheless\nindicates that \\vx\\ and \\vz\\ are not strongly prior-dependent.\nSince this work is chiefly motivated by kinematic age-dating, which mostly\nrequires vertical velocities (\\vz), we are satisfied with these results.\n% The difference in the dispersions of \\vz\\ velocities, calculated with the\n% three different priors tested above was smaller than 0.5 \\kms.\nWe conclude that the \\vx\\ and \\vz\\ velocities we infer are relatively\ninsensitive to prior choice, and we adopt a prior calculated from the\ndistributions of all stars with RV measurements (black Gaussians in figure\n\\ref{fig:prior_distributions}).\nThe \\vy\\ velocities are more strongly prior dependent and should be used with\ncaution.\n\n{\\bf\nA better prior for the velocity distribution would be a phase-space\ndistribution function that takes into account asymmetric drift and other\nnontrivial aspects of the local velocity distribution.\nHowever, priors of this form would require a model for the phase-space\ndistribution function, $f(x,y,z,v_x,v_y,v_z)$, which would require a\nhierarchical model that takes into account covariances between the spatial and\nkinematic properties of stars \\citep[\\eg][]{trick2016, hagen2019,\nanguiano2020}.\nWe consider this to be outside of the scope of this work, and instead argue\nthat our assumed isotropic velocity prior is a conservative choice because it\ndoes not impose any covariant structure between velocity components or\ndependencies on Galactic position.\nHowever, in general, to extend this Kepler-field-specific analysis to other\npopulations of stars in different parts of the Galaxy, alternative priors will\nhave to be constructed.\nWe leave this for a future exercise.\n}\n\nFigure \\ref{fig:posterior} shows the posterior PDF over velocity and distance\nparameters for a randomly selected Kepler target with an RV measurement, KIC\n\\kicstar.\nThe blue lines in each panel indicate star's velocities, directly calculated\nusing the RV measurement, and the distributions indicate the probability\ndensity of the parameters inferred {\\it without} the RV measurement.\nThe velocity parameters are correlated because the lack of RV introduces a\nslight degeneracy: the star's proper motion can be equally well described with\na range of different velocities.\nThe star's posterior PDF is particularly elongated in \\vy, which is the\nvelocity most similar to RV.\nThe star's distance is not tightly correlated with its velocity parameters\nbecause it is precisely determined by parallax.\n\\begin{figure}[ht!]\n\\caption{\nThe posterior PDF over parameters \\vx, \\vy, \\vz\\ and $\\ln$(distance) for a\n    Kepler target chosen at random: KIC \\kicstar.\n    {\\bf\n    Blue lines show the location of the star's `true' parameters, based on a\n    calculation that includes the RV measurement.\n    }\nThis figure shows that the velocity parameters are correlated and the star's\n    posterior is elongated in \\vy.\n    }\n  \\centering\n    \\includegraphics[width=.7\\textwidth]{posterior}\n\\label{fig:posterior}\n\\end{figure}\n", "meta": {"hexsha": "7c5a5dbb87e6911994bcb19228f9f2a25482fac0", "size": 19932, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/method.tex", "max_stars_repo_name": "RuthAngus/kepler_kinematics", "max_stars_repo_head_hexsha": "cd8d3d0f9bc74ce2a39266ed2bac6a8f10499f64", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper/method.tex", "max_issues_repo_name": "RuthAngus/kepler_kinematics", "max_issues_repo_head_hexsha": "cd8d3d0f9bc74ce2a39266ed2bac6a8f10499f64", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper/method.tex", "max_forks_repo_name": "RuthAngus/kepler_kinematics", "max_forks_repo_head_hexsha": "cd8d3d0f9bc74ce2a39266ed2bac6a8f10499f64", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.436997319, "max_line_length": 80, "alphanum_fraction": 0.7803030303, "num_tokens": 4830, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5078118642792044, "lm_q1q2_score": 0.4014406748928811}}
{"text": "\\documentclass[letter,12pt]{article}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\t\\usepackage{graphicx}\n%\t\\usepackage{amsmath}\n%\t\\usepackage{array}\n%\t\\usepackage{amssymb}\n%\t\\usepackage{setspace}\n%\t%\\usepackage[margin=1.5cm,vmargin={0pt,1cm},nohead]{geometry}\n%\t\\usepackage[margin=1in,vmargin={1in,1in}]{geometry}\n%\t% Package that has the symbol for ``:=''\n%\t\\usepackage{txfonts}\n%\t% Create fancy headers and footers for this document\n%\t\\usepackage{fancyhdr}\n%\t%\\usepackage{cite}\n%\t% The ``cite'' package causes the hyperlinks for the in-text references/citations to fail. I believe it is because this package overrides the default package for referencing. Hence, only use the ``cite'' package with the IEEE format.\n%\t% Package for ``turnstile'' binary relations, where letters are defined above and below symbols\n%\t\\usepackage{turnstile}\n%\t\\usepackage{extarrows}\n%\t% Package that provides the cross symbol\n%\t\\usepackage{ifsym}\n%\t\\usepackage{marvosym}\n%\t% Commands for using the package for hyperlinks - \n%\t\\usepackage[pdftex,\n%\t\tpdftitle={Graphics and Color with LaTeX},\n%\t\tpdfauthor={Patrick W Daly},\n%\t\tpdfsubject={Importing images and use of color in LaTeX},\n%\t\tpdfkeywords={LaTeX, graphics, color},\n%\t\tpdfpagemode=UseOutlines,bookmarks, bookmarksopen,\n%\t\tpdfstartview=FitH, colorlinks, linkcolor=blue, citecolor=blue, urlcolor=red,\n%\t]{hyperref}\n%\t\\hypersetup{colorlinks, linkcolor=blue}\n%\t% Concatenate references\n%\t\\usepackage{cite}\n\n\n%\t% Package for tyepsetting algorithms and heuristics\n%\t\\usepackage{listings}\n%\t\\lstset{language=[GNU]C++}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\tAdditional packages\n\\input{/data/others/grappanotes/others/preamble}\n%\tAMS theorem package\n\\usepackage{amsthm}\n\n\n\n\n% definition of new \\LaTeX command for the citation: \\cite{Cimatti08} and \\cite{Barrett09}\n% This allows mathematical/logic symbols to be typeset with the font ``Zapf Chancery'' in ``\\LaTeX\\ math mode''. To typeset symbols in such font, try: \\mathpzc{ABCdef123}\n\\DeclareMathAlphabet{\\mathpzc}{OT1}{pzc}{m}{it}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Start of document\n\\begin{document}\n\\title{Scribed Notes for Week 2: September 17, 2013}\n\\date{\\today}\n\\author{Zhiyang Ong\n\t\\thanks{Email correspondence to: \\href{mailto:ongz@acm.org}{ongz@acm.org}}\n}\n\\maketitle\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Declaration}\n\\label{sec:declaration}\n\nI did this assignment on my own without any collaborators. The mathematical programming package that I have used is \\cite{Makhorin2012}. \n\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Finding the Perfect Diet}\n\\label{sec:findingperfectdiet}\n\nQ1.1) and Q1.2): See printouts. \\\\\n\nQ1.3) The minimal cost from CPLEX is 92.5, and the minimal cost from GLPK is about 80.69. Since GLPK yields a lower cost that CPLEX, it gives a better solution to the linear programming problem.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Finding the Optimal Volume Mix of Two Types of Liquid}\n\\label{sec:optimalliquidmix}\n\nQ2.1) Mathematical formulation for finding the optimal volume mix of two types of liquid. \\\\\n\nLet $x_{1}$ and $x_{2}$ represent the volume of liquid types 1 and 2 in cm$^{3}$. \\\\\n\nObjective function:\n\nmaximize $F(x) = \\$2/{\\rm cm}^{3} \\times x_{1} + \\$3/{\\rm cm}^{3} \\times x_{2} $ \\\\\n\nDecision variables:\n\n$\\underline{x}_{\\varepsilon} s$ \\\\\n\nSubject to these constraints:\n\n$x_{1} + x_{2} \\leq 2000 $ (since 2 $l = 2000$ cm$^{3}$)\n\n$1 g/cm^{3} \\times x_{1} + 2 g/cm^{3} \\times x_{2} \\leq 3000 $ (since 3 kg $ = 3000$ g)\n\n$x_{1} \\geq 0$\n\n$x_{2} \\geq 0$\n\\ \\\\\n\\ \\\\\nHere, I define density $\\rho$ = $\\frac{{\\rm mass}\\ m}{{\\rm volume}\\ v}$. \\\\\n\n$\\therefore m = \\frac{\\rho}{v}$\n\n\nQ2.2) See printout.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Nonlinear Programming}\n\\label{sec:nonlinearprogramming}\n\nQ3) Attachment\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Traveling Salesperson Problem}\n\\label{sec:tspquestion}\n\n%For the asymmetric traveling salesperson problem (TSP), the distance, $d$, between any pair of cities $i$ and $j$ is not equivalent. That is, $d(i,j) \\neq d(j,i)$).\n\n%The number of tours for asymmetric TSP is: $(n-1)!$ \\cite[\\S6.1.1, pp. 224]{Punnen2007}. Therefore, the cardinality for $N_{2}(t)$ is: $\\frac{1}{2}(n-2)!$ % $\\frac{1}{2}(n-2)!$\n\nQ4.1) The cardinality for $N_{2}(t)$ is: n. \\\\\n\\ \\\\\nQ4.2) $N_{2}(t) = \\{ t: t \\in T \\& t can be obtained by removing 2 edges from the tour and then replacing them with 2 edges \\}$\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{\\linespread{1}\n\\bibliographystyle{plain}\n\\bibliography{/data/research/antipastobibtex/references}\n}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\end{document}", "meta": {"hexsha": "a82f9ea11f28338aef9a5898dfa3b74645c2893e", "size": 4694, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "clean_bibtex/dir1/dir1-1/dir1-1a/zhiyang_ong_discrete_optimization_homework_1.tex", "max_stars_repo_name": "eda-ricercatore/python-sandbox", "max_stars_repo_head_hexsha": "741d23e15f22239cb5df8af6e695cd8e3574be50", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "clean_bibtex/dir1/dir1-1/dir1-1a/zhiyang_ong_discrete_optimization_homework_1.tex", "max_issues_repo_name": "eda-ricercatore/python-sandbox", "max_issues_repo_head_hexsha": "741d23e15f22239cb5df8af6e695cd8e3574be50", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "clean_bibtex/dir1/dir1-1/dir1-1a/zhiyang_ong_discrete_optimization_homework_1.tex", "max_forks_repo_name": "eda-ricercatore/python-sandbox", "max_forks_repo_head_hexsha": "741d23e15f22239cb5df8af6e695cd8e3574be50", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4484848485, "max_line_length": 235, "alphanum_fraction": 0.6418832552, "num_tokens": 1418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5078118642792043, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.40144067238681413}}
{"text": "% !TeX spellcheck = <none>\n\\documentclass[./\\jobname.tex]{subfiles}\n\n\\begin{document}\n\\definecolor{light-gray}{gray}{0.9}\n\n\\chapter{Task Description}\n\nThis project is about constructing and building a 3-axis robot. The robot is equipped with two cameras and a red laser-pointer. The user can take a green laser-pointer to direct the robot into a different position. In order to avoid permanent sight-damage, the robot should avoid shining the laser into faces of surrounding humans. The following list contains the main working steps:\n\n\\begin{itemize}\n\t\\item design and construct the 3-axis robot \n\t\\item manufacture and assemble the robot parts \n\t\\item develop the backwards kinematic \n\t\\item implement the backwards kinematic in C and compile to DLL \n\t\\item find green laser point in 3D stereo image with OpenCV in Python \n\t\\item drive the red laser point of the robot to the green laser point of the human\n\t\\item planned but optional: \n\t\\begin{itemize}\n\t\t\\item plan path from current position to green laser position \n\t\t\\item implement controller to correct deviance between red and green laser point \n\t\t\\item avoid human faces along the way\n\t\\end{itemize}\n\t\n\\end{itemize}\n\n\n\\chapter{Design}\n\nThe robot consists of 3 Dynamixel MX-64AT motors, 2 Microsoft HD 3000 lifecam and a laser module DB635-1-3-FA(14x45)-ADJ from Picotronic. Aluminium frames are attached to the motors to build the framework of the robot. The cameras and laser-pointer are connected with aluminium brackets to the robot. The design of the robot and its components is established with SolidWords. The whole robot is mounted on aluminium profiles to improve the handling and to store of the electrical hardware. Beside the cables, a power supply for the motors and laser pointer, an emergency stop button and communication components for the motors are required. The cameras are directly connected to the laptop or computer via the USB ports. This means that the laptop requires 3 USB sockets. A connection via a USB-Hub failed as the OpenCV library could not find the cameras. \\\\\nThe table \\ref{tab:camera_before_after} shows how the cameras were modified in order to properly attach them to the robot tool. \\\\\nThe table \\ref{tab:3d_rander} displays a 3D render of the completely assembled robot.\\\\\nFinally, the finished robot can be seen in figure \\ref{fig:final_assemgly}\n\n\\begin{table}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\begin{tabular}{c c}\n\t\t\t\\includegraphics[width=0.6\\textwidth]{img/foto/camera_with_stand.jpg}\n\t\t\t\\includegraphics[width=0.49\\textwidth]{img/foto/camera_without_stand.jpg}\n\t\t\\end{tabular}\n\t}\n\t\\unterschrift{comparison of the cameras before and after modification}{}{}\n\t\\label{tab:camera_before_after}\n\\end{table}\n\n\n\\begin{table}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\begin{tabular}{c c}\n\t\t\t\\includegraphics[width=0.75\\textwidth]{../img/pdf/robot_3d_side.pdf}\n\t\t\t\\includegraphics[width=1\\textwidth]{../img/pdf/robot_3d_front.pdf}\n\t\t\\end{tabular}\n\t}\n\t\\unterschrift{3D render of the assembled robot in SolidWorks}{}{}\n\t\\label{tab:3d_rander}\n\\end{table}\n\n\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.8\\textwidth]{img/foto/final_robot_photo.jpg}\n\t}\n\t\\unterschrift{final assembly of the robot}{}{}\n\t\\label{fig:final_assemgly}\n\\end{figure}\n\n\n\\chapter{Calculation}\nThis chapter describes the mathematical formulations that are needed to control the robot. This includes the backwards kinematics as well as the formulas for setting $\\theta_{0,1,2}$. \n\n\\section{Backwards Kinematic}\n\nThe following figure \\ref{fig:robot_coord} shows the coordinate systems that are used to get the link parameters shown in table \\ref{tab:link_params} below. The link parameters are established using the Deviant Hartenberg convention mentioned in \\cite[p. 70- 79]{Craig2018}.\n\nWith the knowledge of the link parameters, the transformation matrices are generated in the next step. The full matrix can be seen in equation \\ref{eq:transformationmatrix}\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.4\\textwidth]{img/pdf/robot_axis_coord.pdf}\n\t}\n\t\\unterschrift{robot axis coordinate systems used to calculate the link parameters}{}{}\n\t\\label{fig:robot_coord}\n\\end{figure}\n\n\n\n\n\n\\begin{table}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\begin{tabular}{|c|c|c|c|c|}\n\t\t\t\\hline\n\t\t\t$i$ & $\\alpha_{i-1}$ & $a_{i-1}$ & $d_i$ & $\\theta_{i-1}$\\\\ \n\t\t\t\\hline\n\t\t\t1 & 0 & 0 & 100 & $\\theta_0$\\\\  \n\t\t\t2 & -90 & 50 & 0 & $\\theta_1 - 90$\\\\ \n\t\t\t3 & 0 & 100 & 0 & $\\theta_2 + 180$\\\\ \n\t\t\tF & 90 & 0 & 68 & $0$ \\\\\n\t\t\t\\hline\n\t\t\\end{tabular}\n\t}\n\t\\unterschrift{table of link parameters}{}{}\n\t\\label{tab:link_params}\n\\end{table}\n\n\n\n\\begin{equation}\n\\label{eq:transformationmatrix}\n\\begin{split}\n& T =  \\\\\n& \\begin{bmatrix}\n-c0c1s2 -c0c2s1 & -s0 & c0c1c2 - c0s1s2 & a2c0 + dF (c0c1c2 - c0s1s2) + a3c0s1 \\\\\n-c1s0s2 -c2s0s1 &  c0 & c1c2s0 - s0s1s2 & a2s0 + dF (c1c2s0 - s0s1s2) + a3s0s1 \\\\\ns1s2 - c1c2     &   0 & -c1s2 - c2s1 & d1 + a3c1 + dF(-c1s2 - c2s1) \\\\\n0               &   0 & 0 & 1 \\\\\n\\end{bmatrix}\\\\\n\\end{split}\n\\end{equation}\n\n\n\\subsection{Implementation}\nFor controlling the robot, several functions are written in C and compiled to a DLL. The functions are built on the Dynamixel library \\cite{Robotis2019}. The DLL provides the following methods: \n\\begin{itemize}\n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|int robot_start();|} \\\\\n\tSets up the communication with the robot by returning the port number. This number must be provided in every other function. Further this function sets up the main parameters of every motor like the velocity limits.\n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|void robot_stop(int port_num);|} \\\\ \n\tStops the robot by driving to the home position and freeing the device with the port number. \n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|void robot_home(int port_num);|} \\\\\n\tSeparate function for driving the robot to the home position. \n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|int robot_drive(float z, float alpha, float beta, int port_num);|} \\\\\n\tTells the robot to drive to a specific position specified by $\\alpha$, $\\beta$ and z. The motion towards this position is not planned. \n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|int robot_reached_target(float z, float alpha, float beta, \\ \\ \\ \\ \\ int port_num);|} \\\\\n\tThis function checks if the robot is at the specified $\\alpha$, $\\beta$ and z position and returns 1 if it reached the target (otherwise 0).\n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|void robot_set_theta(float theta0, float theta1, float theta2, \\ \\ \\ \\ \\ int port_num);|} \\\\\n\tInstead of specifying a global position, this function allows to set the axis angle $\\theta$ by its own. \n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|float robot_get_theta0(int port_num);|} \\\\\n\tReturns the angle $\\theta_0$ that the robot is at that time.\n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|float robot_get_theta1(int port_num);|} \\\\\n\tReturns the angle $\\theta_1$ that the robot is at that time.\n\t\\item \\colorbox{light-gray}{\\lstinline[basicstyle=\\ttfamily\\color{black}]|float robot_get_theta2(int port_num);|} \\\\ \n\tReturns the angle $\\theta_2$ that the robot is at that time.\n\\end{itemize}\nThe functions \\textit{robot\\textunderscore drive} as well as the function \\textit{robot\\textunderscore set\\textunderscore theta} are non-blocking. This means that the function returns, before the robot reached the target. Blocking functions can be easily created outside the DLL by simply polling the functions \\textit{robot\\textunderscore reached\\textunderscore target} or \\textit{robot\\textunderscore get\\textunderscore theta}.  \n\n\n\n\\section{Goal Robot Configuration}\n\\label{sec:calc_robot_config}\n\nThe laser point on the wall can be described by only to 2 DOF, vertical and horizontal coordinates. To track the laser point, the robot has to change 2 DOF likewise. Even though the robot has 3 rotation axis, it only satisfy 2 DOF, because $theta_1$ and $theta_2$ directly depend to each other. Therefore, one of these angles can be set to any arbitrary angle. In this case $theta_1$ is constantly set to 0°. With the 2 cameras and the knowledge of the transformation matrices of the robot, the vertical and horizontal coordinates of the laser point are received and transformed into 3D coordinates of the robot base coordinate system.\n\nAs a result, the rotation angle of the motors can be calculated. $\\theta_0$ is a simple geometric problem and can be easily calculated with trigonometric functions (see figure \\ref{fig:3d_point_base}). The equation \\ref{eq:theta_2} for $\\theta_2$ is slightly more advanced. Additionally, the length and height of the robot components have to be taken in consideration.\n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.8\\textwidth]{img/pdf/robot_3d_point_base.pdf}\n\t}\n\t\\unterschrift{camera calibration app flowchart}{}{}\n\t\\label{fig:3d_point_base}\n\\end{figure}\n\n\\begin{equation}\n\\label{eq:theta_0}\n\\theta_0 = arctan \\left( \\frac{Y_0}{X_0} \\right) \n\\end{equation}\n\n\\begin{equation}\n\\label{eq:theta_2}\n\\theta_2 = -1 \\cdot arctan \\left( \\frac{ Z_0 - 100 - 100 cos(\\theta_1)}{\\sqrt{X_{0}^{2} + Y_{0}^{2}} - 50 - 100 sin(\\theta_1)} \\right)\n\\end{equation}\n\n\\chapter{Stereo Vision}\n\nThe idea of this project is to drive directly to the correct point, without using a closed loop controller of any sort. This is done by measuring the 3D point with a stereo camera and calculating back to the desired robot configuration (as shown in \\ref{sec:calc_robot_config}). In order to measure the correct point, the cameras need to be calibrated. Further, a reliable method for finding the laser-point is needed. All vision related tasks are done with \\cite{2014opencv}\n\n\\section{Camera Calibration}\nAt first a camera calibration application is written, that allows to take images, calculate the two single camera matrices and estimates the translation and rotation between the two cameras. The flowchart in figure \\ref{fig:cam_cal_app_flowchart} shows the main outline of the camera calibration app. \n\nThree quality measures are deployed to verify that the matrices are correct: \n\\begin{itemize}\n\t\\item measuring a known 3D structure with the calibrated stereo camera tool\n\t\\item using the same pictures of the chessboard in MATLAB and comparing the calculated matrices\n\t\\item plausibility check for the translation vector and the rotation matrix between the cameras\n\\end{itemize}\n\nBesides the camera calibration towards each other, the main camera (left) must also be calibrated to the TCP. This is called the hand-eye calibration. The following matrix \\ref{eq:HE} shows the hand-eye calibration. Although there are more complex methods to generate this transformation matrix, it can also be measured from the real tool. The figure \\ref{fig:hand_eye_coord} shows the rotation between the TCP coordinate system and the camera coordinate system.\n\n\\begin{equation}\n\\label{eq:HE}\nHE = \n\\begin{bmatrix}\n0.0  & 1.0 & 0.0 & -28.5 \\\\ \n-1.0 & 0.0 & 0.0 & 45.0 \\\\\n0.0  & 0.0 & 1.0 & 28.0 \\\\ \n0.0  & 0.0 & 0.0 & 1.0 \\\\\n\\end{bmatrix}\n\\end{equation}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.4\\textwidth]{img/png/hand_eye_coord.png}\n\t}\n\t\\unterschrift{hand-eye coordinate system transformation}{}{}\n\t\\label{fig:hand_eye_coord}\n\\end{figure}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.6\\textwidth]{img/pdf/camera_calibration_app_flowchart.pdf}\n\t}\n\t\\unterschrift{camera calibration app flowchart}{}{}\n\t\\label{fig:cam_cal_app_flowchart}\n\\end{figure}\n\n\\section{Laser Point Detection}\nThe second part is about detecting the laser point in an image. To make the task simpler, the laser point may only be projected onto a white flip board chart. \\\\\nTwo methods for detecting the laser point are tested. \n\n\\subsection{Method 1: HSV Threshold}\nAs lasers are monochromatic one could think about looking for a certain colour. The idea is to define a threshold in HSV-colour space and only look at the pixels that are within this band. By applying a dilation function to the binary image, the weakly connected pixels are morphed together and form blobs. Then the function \\textit{findCountours} is deployed to detect the connected areas of white pixels. Finally, the first (biggest) area contour is taken and the centre of mass is calculated. This is the 2D point in one image. \\\\\nThis method did not work very well. Some problems have been identified: \n\\begin{itemize}\n\t\\item Taking the biggest area is not very sensible. More constraints could be helpful like: size threshold, convexity or previous point.\n\t\\item As the automatic mode of the camera is not deactivated the colour of the laser point might change with different lighting scenarios. \n\t\\item The definition of the colour threshold is not trivial: Either too many pixels or too few are taken. Especially with a colourful surrounding this trade-off is hard to control. \n\\end{itemize}\n\n\\subsection{Method 2: Template Matching}\n\nThe second method uses template matching to find the green laser point. The process outline as follows: a template slides over the image and at every pixel they are compared. The comparison results a scalar value which are then stacked together to create something like a `heat-map'. The larger the scalar is at an index, the better is the correspondence between the image and the template. \\\\\nThere are many different methods for comparing two images defined in OpenCV. The utilize method was found to work best for this sort of object detection. The formula is shown in equation \\ref{eq:template_matching}. \\\\\nThe templates are created before every run. In order to make that process as user-friendly as possible, a GUI based configuration app is created. The templates can be seen in the table \\ref{tab:laser_template_comp}. \\\\\nThe main characteristics of this method are: \n\\begin{itemize}\n\t\\item This method works much better with different lighting scenarios than the HSV-threshold.\n\t\\item Motion blurring results in an unstable detection of the laser point. Thus, fast movements with the robot and by hand should be avoided. \n\t\\item Whenever there is no green laser point in the image, the red laser is detected as green, since this is now the best match. \n\t\\item This method only works with the background (e.g. white flip board) specified in the template. \n\\end{itemize} \n\n\\begin{equation}\nR(x,y) = \\frac{\\sum_{x',y'} (T'(x',y') \\cdot I'(x + x', y + y'))}{\\sqrt{\\sum_{x',y'} T'(x',y')^{2} \\cdot \\sum_{x',y'} I'(x + x', y + y')^{2}}}\n\\label{eq:template_matching}\n\\end{equation}\n\n\n\\begin{table}[h]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\begin{tabular}{c c}\n\t\t\t\\includegraphics[width=0.295\\textwidth]{img/png/green_laser_template.png}\n\t\t\t\\includegraphics[width=0.3\\textwidth]{img/png/red_laser_template.png}\n\t\t\\end{tabular}\n\t}\n\t\\unterschrift{laser point template as created by the configuration app}{}{}\n\t\\label{tab:laser_template_comp}\n\\end{table}\n\n\n\\chapter{Main App}\nThis chapter describes the algorithmic steps taken in the main application as seen in the flowchart \\ref{fig:main_app_flowchart}. The action \\textit{transform 3D point to robot base} consists of multiple steps itself: \n\n\\begin{itemize}\n\t\\item Multiply the 3D point with the hand-eye calibration to transform the point into the TCP frame, as seen in \\ref{eq:HE} \n\t\\item Transform the point to the robot base coordinate system by multiplying with the backwards kinematic in \\ref{eq:transformationmatrix}. \n\\end{itemize}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.5\\textwidth]{img/pdf/main_app_flowchart.pdf}\n\t}\n\t\\unterschrift{camera calibration app flowchart}{}{}\n\t\\label{fig:main_app_flowchart}\n\\end{figure}\n\n\n\\chapter{Conclusion}\n\nWe find, that template matching method is better suited to detect small objects in a constantly changing image rather than searching the images for a specific colour.\n\nThe resting distance between green and red laser point, as seen in figure \\ref{fig:resting_offset} results from the offset of the laser pointer to the robot tool centre. That can be easily adjusted with a new bracket. To avoid any systematic errors, the laser pointer has to be mounted colinear with the z-axis of the robot tool.  \n\nAnother current problem is the high energy consumption of the laser pointer. Within a half an hour, the intensity of the laser pointer dropped significantly. In the next step, a more appropriate power supply should be installed.\n\nAn additional option could be to specify $theta_1$ as a variable instead of a constant and find a more advanced system of equations.   \n\n\\begin{figure}[H]\n\t\\centering\n\t\\noindent\\adjustbox{max width=\\linewidth}{\n\t\t\\includegraphics[width=0.5\\textwidth]{img/foto/resting_ofset.png}\n\t}\n\t\\unterschrift{resting offset between laser points}{}{}\n\t\\label{fig:resting_offset}\n\\end{figure}\n\n\n\\end{document}\n", "meta": {"hexsha": "b2e0f22365da5d6d7a31c0a3e3675992e01f125f", "size": 17281, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documentation/tex/MainPart.tex", "max_stars_repo_name": "nicolai-schwartze/LaB3R", "max_stars_repo_head_hexsha": "3ba1ed7b2cd151d1ee3b4fb9da12662cf2ecc726", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Documentation/tex/MainPart.tex", "max_issues_repo_name": "nicolai-schwartze/LaB3R", "max_issues_repo_head_hexsha": "3ba1ed7b2cd151d1ee3b4fb9da12662cf2ecc726", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Documentation/tex/MainPart.tex", "max_forks_repo_name": "nicolai-schwartze/LaB3R", "max_forks_repo_head_hexsha": "3ba1ed7b2cd151d1ee3b4fb9da12662cf2ecc726", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.925566343, "max_line_length": 858, "alphanum_fraction": 0.7629766796, "num_tokens": 4684, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4013711598340391}}
{"text": "\\chapter{Hyperparameters}\n\\label{chap:hyperparameters}\n\nHere I present the hyperparameters used for experiments in the following chapter. I run a rough hyperparameter search to use reasonably good enough parameters, and the algorithm does not diverge. As the goal of this thesis is to evaluate the execution time of the algorithm rather than its quality or performance, these parameters may not be optimal for the given problem at hand. I recommend the available literature for a more appropriate hyperparameter selection. \n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameter} & \\textbf{Value} \\\\\n        \\hline\n        Selection & Tournament \\\\\n        \\quad Number of parents & $2$ \\\\\n        Crossover & Uniform \\\\\n        \\quad Probability to inherit gene from 1st parent & $40\\%$ \\\\\n        \\quad Offspring & $80\\%$ \\\\\n        \\hline\n        Replace mutation & \\\\\n        \\quad Mutation rate & $20\\%$ \\\\\n        \\quad Position clipping & no \\\\\n        Normal mutation & \\\\\n        \\quad Mutation rate & $20\\%$ \\\\\n        \\quad Standard deviation & $0.005$ \\\\\n        \\quad Position clipping & no \\\\\n        Cauchy mutation & \\\\\n        \\quad Mutation rate & $20\\%$ \\\\\n        \\quad Scale & $0.003$ \\\\\n        \\quad Position clipping & yes \\\\\n        Adaptive step mutation & \\\\\n        \\quad Starting deviation & $0.01$ \\\\\n        \\quad Deviation increase & $1.3$ \\\\\n        \\quad Deviation decrease & $0.2$ \\\\\n        \\quad Fraction of better to increase deviation & $30\\%$ \\\\\n        \\quad Minimum deviation & $0.00001$ \\\\\n        \\quad Maximum deviation & $1.0$ \\\\\n        \\quad Position clipping & no \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Hyperparameters of mutation experiments}\n    \\label{tab:esmutationhyperparmarameters}\n\\end{table}\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameter} & \\textbf{Value} \\\\\n        \\hline\n        Selection & Tournament \\\\\n        \\quad Number of parents & $2$ \\\\\n        Crossover & One--point \\\\\n        \\quad Mutated individuals & $40\\%$ \\\\\n        Mutation & Bit--Flip \\\\\n        \\quad Mutated individuals & $60\\%$ \\\\\n        \\quad Mutation probability & $0.1\\%$ \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{\\acrlong*{acc:ga} hyperparameters}\n    \\label{tab:gahyperparameters}\n\\end{table}\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameter} & \\textbf{Value} \\\\\n        \\hline\n        Selection & Tournament \\\\\n        \\quad Number of parents & $2$ \\\\\n        Mutation & Normal \\\\\n        \\quad Mutation rate & $20\\%$ \\\\\n        \\quad Standard deviation & $0.005$ \\\\\n        \\hline\n        Uniform crossover & \\\\\n        \\quad Offspring & $80\\%$ \\\\\n        \\quad Probability to inherit gene from 1st parent & $40\\%$ \\\\\n        One--point crossover & \\\\\n        \\quad Offsprign & $80\\%$ \\\\\n        Two--point crossover & \\\\\n        \\quad Offsprign & $80\\%$ \\\\\n        Arithmetic crossover & \\\\\n        \\quad Offsprign & $40\\%$ \\\\\n        Blend crossover & \\\\\n        \\quad Offsprign & $70\\%$ \\\\\n        \\quad $\\alpha$ & $0.5$ \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Hyperparameters of crossover experiments}\n    \\label{tab:escrossoverhyperparmarameters}\n\\end{table}\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l|c|}\n        \\hline\n        \\textbf{Parameter} & \\textbf{Value} \\\\\n        \\hline\n        Selection & Tournament \\\\\n        \\quad Number of parents & $2$ \\\\\n        Crossover & Uniform \\\\\n        \\quad Probability to inherit gene from 1st parent & $40\\%$ \\\\\n        Mutation & Normal \\\\\n        \\quad Mutation rate & $20\\%$ \\\\\n        \\quad Standard deviation & $0.005$ \\\\\n        \\hline\n        Standard mutation & \\\\\n        \\quad Offspring & $80\\%$ \\\\\n        Plus schema & \\\\\n        \\quad Offspring & $150\\%$ \\\\\n        Comma schema & \\\\\n        \\quad Offspring & $200\\%$ \\\\\n        \\hline\n    \\end{tabular}\n    \\caption{Hyperparameters of crossover schemes experiments}\n    \\label{tab:esschemehyperparmarameters}\n\\end{table}\n\n\\begin{table}[ht]\n    \\centering\n    \\begin{tabular}{|l r|c|}\n        \\hline\n        \\multicolumn{2}{|l|}{\\textbf{Parameter}} & \\textbf{Value} \\\\\n        \\hline\n        Cognitive acceleration coefficient & $c_l$ & 1.5 \\\\\n        Social acceleration coefficient  & $c_g$ & 1.5 \\\\\n        Inertia weight & $\\omega$ & 0.8 \\\\\n        Velocity clip value & & 2 \\\\\n        \\hline \\hline\n        \\textbf{Neighborhood} & & \\textbf{Relative size} \\\\\n        \\hline\n        Circle & & 0.26 \\\\\n        Grid & & \\\\\n        \\quad Linear & & 0.02 \\\\\n        \\quad Compact & & 0.05 \\\\\n        \\quad Diamond & & 0.06 \\\\\n        Nearest neighbors & & 0.13 \\\\\n        Random & & \\\\\n        \\quad PSO2006 & & 0.13 \\\\\n        \\quad PSO2011 & & 0.2 \\\\ \n        \\hline\n    \\end{tabular}\n    \\caption{\\acrlong*{acc:pso} hyperparameters}\n    \\label{tab:psohyperparameters}\n\\end{table}", "meta": {"hexsha": "e78e10a15204f787e3a04641b53d4844dd6a536d", "size": 4936, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis/chap_hyperparameters.tex", "max_stars_repo_name": "PatrikValkovic/MasterThesis", "max_stars_repo_head_hexsha": "6e9f3b186541db6c8395ebc96ace7289d01c805b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thesis/chap_hyperparameters.tex", "max_issues_repo_name": "PatrikValkovic/MasterThesis", "max_issues_repo_head_hexsha": "6e9f3b186541db6c8395ebc96ace7289d01c805b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis/chap_hyperparameters.tex", "max_forks_repo_name": "PatrikValkovic/MasterThesis", "max_forks_repo_head_hexsha": "6e9f3b186541db6c8395ebc96ace7289d01c805b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2777777778, "max_line_length": 467, "alphanum_fraction": 0.5611831442, "num_tokens": 1365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.40134982536318625}}
{"text": "\\documentclass{article}\n\n\\usepackage[T1]{fontenc}\n\\usepackage[osf]{libertine}\n\\usepackage[scaled=0.8]{beramono}\n\\usepackage[margin=1.5in]{geometry}\n\\usepackage{url}\n\\usepackage{booktabs}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{nicefrac}\n\\usepackage{microtype}\n\\usepackage{subcaption}\n\\usepackage{bm}\n\n\\usepackage{amsthm}\n\\newtheorem{defn}{Definition}\n\n\\usepackage{sectsty}\n\\sectionfont{\\large}\n\\subsectionfont{\\normalsize}\n\n\\usepackage{titlesec}\n\\titlespacing{\\section}{0pt}{10pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\\titlespacing{\\subsection}{0pt}{5pt plus 2pt minus 2pt}{0pt plus 2pt minus 0pt}\n\n\\usepackage{pgfplots}\n\\pgfplotsset{\n  compat=newest,\n  plot coordinates/math parser=false,\n  tick label style={font=\\footnotesize, /pgf/number format/fixed},\n  label style={font=\\small},\n  legend style={font=\\small},\n  every axis/.append style={\n    tick align=outside,\n    clip mode=individual,\n    scaled ticks=false,\n    thick,\n    tick style={semithick, black}\n  }\n}\n\n\\pgfkeys{/pgf/number format/.cd, set thousands separator={\\,}}\n\n\\usepgfplotslibrary{external}\n\\tikzexternalize[prefix=tikz/]\n\n\\newlength\\figurewidth\n\\newlength\\figureheight\n\n\\setlength{\\figurewidth}{12cm}\n\\setlength{\\figureheight}{6cm}\n\n\\newlength\\squarefigurewidth\n\\newlength\\squarefigureheight\n\n\\setlength{\\squarefigurewidth}{4cm}\n\\setlength{\\squarefigureheight}{4cm}\n\n\\newlength\\smallsquarefigurewidth\n\\newlength\\smallsquarefigureheight\n\n\\setlength{\\smallsquarefigurewidth}{3.25cm}\n\\setlength{\\smallsquarefigureheight}{3.25cm}\n\n\\newlength\\smallfigurewidth\n\\newlength\\smallfigureheight\n\n\\setlength{\\smallfigurewidth}{6.25cm}\n\\setlength{\\smallfigureheight}{4cm}\n\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1ex}\n\n\\newcommand{\\acro}[1]{\\textsc{\\MakeLowercase{#1}}}\n\\newcommand{\\given}{\\mid}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\data}{\\mc{D}}\n\\newcommand{\\intd}[1]{\\,\\mathrm{d}{#1}}\n\\newcommand{\\inv}{^{-1}}\n\\newcommand{\\trans}{^\\top}\n\\newcommand{\\mat}[1]{\\bm{\\mathrm{#1}}}\n\\renewcommand{\\vec}[1]{\\bm{\\mathrm{#1}}}\n\\newcommand{\\R}{\\mathbb{R}}\n\\renewcommand{\\epsilon}{\\varepsilon}\n\\newcommand{\\Exp}{\\mathbb{E}}\n\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\cov}{cov}\n\\DeclareMathOperator{\\diag}{diag}\n\\DeclareMathOperator*{\\argmin}{arg\\,min}\n\\DeclareMathOperator*{\\argmax}{arg\\,max}\n\n\\begin{document}\n\n\\section*{Gaussian Process Classification}\n\nJust as we could use the kernel trick to extend Bayesian linear\nregression to Gaussian processes for general-purpose nonlinear\nregression, we may also extend Bayesian linear classification in the\nsame way.  In Gaussian process classification, we assume there is a\nlatent function $f\\colon \\mc{X} \\to \\R$ that is commensurate with the\nprobability of a positive observation; higher latent function values\ncorrespond to higher probabilities of positive observations.  In\nBayesian linear classification, we assumed a parametric (linear) form\nfor this latent function:\n\\[\n  f(\\vec{x}) = \\vec{x}\\trans \\vec{w}.\n\\]\nIn Gaussian process classification, rather than choosing a parametric\nform for $f$, we instead place a Gaussian process prior on $f$:\n\\[\n  p(f) = \\mc{GP}(f; \\mu, K).\n\\]\nNote that a Gaussian prior on the weight vector $\\vec{w}$ above\ninduces a Gaussian process prior on $f$ with mean function\n\\[\n  \\mu(\\vec{x}) = \\vec{x}\\trans \\vec{\\mu}\n\\]\nand covariance function\n\\[\n  K(\\vec{x}, \\vec{x}') = \\vec{x}\\trans \\mat{\\Sigma} \\vec{x},\n\\]\nwhere $p(\\vec{w}) = \\mc{N}(\\vec{w}; \\vec{\\mu}, \\mat{\\Sigma})$. The\nGaussian process formalism allows us to model arbitrary nonlinear\nclassification boundaries by using any desired mean and covariance\nfunction for $f$.\n\n\\subsection*{Likelihood}\n\nSuppose we have made binary observations at a set of values $\\mat{X}$,\nand define $\\vec{f} = f(\\mat{X})$ to be the associated set of latent\nfunction values.  As in Bayesian linear classification, we assume\nthe following likelihood for a given binary observation $y_i$\nassociated with $\\vec{x}_i$:\n\\[\n  p(y_i = 1 \\given f_i)\n  =\n  \\sigma(f_i),\n\\]\nwhere $\\sigma\\colon \\R \\to (0, 1)$ is a monotonically increasing\nsigmoid function such as the logisitic function or the standard normal\n\\acro{CDF}.  We again assume the observations are conditionally\nindependent given the latent function values:\n\\[\n  p(\\vec{y} \\given \\vec{f})\n  =\n  \\prod p(y_i \\given f_i).\n\\]\n\n\\subsection*{Inference}\n\nGiven our prior $p(f) = \\mc{GP}(f; \\mu, K)$ and a set of observations\n$\\data = (\\mat{X}, \\vec{y})$, we wish to find the posterior\ndistribution of the latent function values $\\vec{f} = f(\\mat{X})$.\nNote that if we had a Gaussian posterior $\\vec{f}$, this would induce\na Gaussian process posterior for the function $f$ given $\\data$.\nThe posterior is\n\\[\n  p(\\vec{f} \\given \\data)\n  =\n  \\frac{1}{Z}\n  p(\\vec{f} \\given \\mat{X})\n  p(\\vec{y} \\given \\vec{f})\n  =\n  \\mc{N}\\bigl(\\vec{f}; \\mu(\\mat{X}), K(\\mat{X}, \\mat{X})\\bigr)\n  \\prod_i p(y_i \\given f_i).\n\\]\nUnfortunately, the sigmoid likelihood coupled with the Gaussian prior\ndo not couple to form a tractable posterior.  Instead, we must\napproximate this posterior in some way.  Previously we described the\nLaplace approximation, which approximates the unnormalized log\nposterior with a second-order Taylor expansion, resulting in a\nGaussian approximate posterior centered at the posterior mode\n\\[\n  \\hat{\\vec{f}} = \\argmax_{\\vec{f}} p(\\vec{f} \\given \\data).\n\\]\n\nHere we will consider two more general-purpose approximation\ntechniques for approximating intractable posterior distributions.\nThese techniques are useful when the likelihood factorizes into\none-dimensional terms, as in \\acro{GP} classification.\n\n\\section*{Assumed Density Filtering}\n\nConsider a posterior distribution of the form\n\\[\n  p(\\vec{\\theta} \\given \\data)\n  =\n  \\frac{1}{Z}\n  p_0(\\vec{\\theta})\n  \\prod_{i = 1}^N\n  t_i(\\vec{\\theta}),\n\\]\nwhere the $t_i$ are typically likelihood terms, for example our $p(y_i\n\\given f_i)$ above.  We assume the prior $p_0(\\vec{\\theta})$ has been\nchosen to be some nice form, for example a Gaussian, and we will use\nthe Gaussian case to illustrate the idea below.\n\nIn \\emph{assumed density filtering} (\\acro{ADF}), we assume that the\nposterior has the same form as the prior $p_0$, and we seek an\napproximating distribution\n\\[\n  q(\\vec{\\theta}) \\approx p(\\vec{\\theta} \\given \\data)\n\\]\nfrom the same family as $p_0$ that approximates the true posterior\n``as well as possible.''\n\nMechanically, ensuring that our approximate distribution $q$ remains\nin the same family as $p_0$ is achieved by selecting an (unnormalized)\nmember $\\tilde{t}_i$ from the likelihood conjugate to the prior for\neach of the likelihood terms $t_i$.  The result is\n\\[\n  q(\\vec{\\theta})\n  =\n  p_0(\\vec{\\theta})\n  \\prod_{i = 1}^N \\tilde{Z}_i \\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i),\n\\]\nand this product will belong to the desired family by conjugacy.  Here\nthe constants $\\tilde{Z}_i$ and the local parameter vectors\n$\\{\\tilde{\\vec{\\theta}}_i\\}$ are free parameters, called \\emph{site\n  parameters}, we may choose for each of the approximating\ndistributions $\\tilde{t}_i$ to try to improve the fit of the\napproximating distribution.\n\nFor example, the Gaussian distribution is self-conjugate, so the\n\\acro{ADF} approximation will in this case take the form\n\\[\n  q(\\vec{\\theta})\n  =\n  p_0(\\vec{\\theta})\n  \\prod_{i=1}^N t_i(\\vec{\\theta})\n  \\approx\n  \\mc{N}(\\vec{\\theta}; \\vec{\\mu}, \\mat{\\Sigma})\n  \\prod_{i=1}^N\n  \\tilde{Z}_i\n  \\mc{N}(\\vec{\\theta}; \\tilde{\\vec{\\mu}}_i, \\tilde{\\mat{\\Sigma}}_i),\n\\]\nwhere the site parameters are the constants $\\{\\tilde{Z}_i\\}$ (chosen\nso that the approximation normalizes) as well as the local mean\nvectors $\\{\\tilde{\\vec{\\mu}}_i\\}$ and covariance matrices\n$\\tilde{\\mat{\\Sigma}}_i$.\n\nNote that in the \\acro{GP} classification case, the likelihood terms\nin the product are in fact one dimensional, because the likelihood for\n$y_i$ only depends on $f_i$:\n\\[\n  q(\\vec{f})\n  =\n  \\mc{N}(\\vec{f}; \\vec{\\mu}, \\mat{\\Sigma})\n  \\prod_{i=1}^N\n  \\tilde{Z}_i\n  \\mc{N}(f_i; \\tilde{\\mu}_i, \\tilde{\\sigma}^2_i).\n\\]\n\nConsider just the first two terms in this product:\n\\[\n  p(\\vec{\\theta} \\given \\data_1)\n  \\propto\n  p_0(\\vec{\\theta})\n  t_1(\\vec{\\theta}).\n\\]\nThis product will not have the same nice form of the prior, but has\nonly been warped ``slightly'' away from the prior via a single\nlikelihood term.  In many cases, this distribution will be at least\npartially manageable.  Perhaps there will not be a nice closed\nexpression, but we might still be able to compute the normalizing\nconstant or the moments of the posterior.\n\nIn assumed density filtering, we will approximate this product with a\nmember of the desired family:\n\\[\n  q_1(\\vec{\\theta})\n  =\n  \\tilde{Z}_1\n  p_0(\\vec{\\theta})\n  \\tilde{t}_1(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_1)\n  \\approx\n  p(\\vec{\\theta} \\given \\data_1)\n  \\propto\n  p_0(\\vec{\\theta})\n  t_1(\\vec{\\theta}).\n\\]\nThis approximation is done by matching the moments between the\napproximation $q_1(\\vec{\\theta})$ and the true posterior\n$p(\\vec{\\theta} \\given \\data_1)$.\n\nFor example, consider $p_0(\\vec{\\theta}) = \\mc{N}(\\vec{\\theta};\n\\vec{\\mu}, \\mat{\\Sigma})$.  We select the site parameters\n\\[\n  \\tilde{Z}_1^{-1}\n  \\qquad\n  \\tilde{\\vec{\\mu}}_1 \\qquad\n  \\tilde{\\mat{\\Sigma}}_1\n\\]\nsuch that\n\\begin{align*}\n  \\int q_1(\\vec{\\theta}) \\intd{\\vec{\\theta}} &= 1 \\\\\n  \\mathbb{E}\\bigl[q_1(\\vec{\\theta})\\bigr] &= \\mspace{14.5mu} \\mathbb{E}\\bigl[ p(\\vec{\\theta} \\given \\data_1) \\bigr] \\\\\n  \\cov\\bigl[q_1(\\vec{\\theta})\\bigr] &= \\cov\\bigl[ p(\\vec{\\theta} \\given \\data_1) \\bigr].\n\\end{align*}\nNow the approximate distribution is in the desired density family\n(Gaussians) and matches the true posterior up to the second moment.\n\nNow consider the first three terms of the product:\n\\[\n  p(\\vec{\\theta} \\given \\data_1, \\data_2)\n  \\propto\n  p_0(\\vec{\\theta})\n  t_1(\\vec{\\theta})\n  t_2(\\vec{\\theta})\n  \\propto\n  p(\\vec{\\theta} \\given \\data_1)\n  t_2(\\vec{\\theta}).\n\\]\nThe idea in assumed density filtering is to substitute in our\napproximation $q_1(\\vec{\\theta})$, giving:\n\\[\n  p(\\vec{\\theta} \\given \\data_1, \\data_2)\n  \\stackrel{\\propto}{\\sim}\n  q_1(\\vec{\\theta})\n  t_2(\\vec{\\theta}).\n\\]\nNow we are in the same situation we were in before!  We have a nice\n``prior'' distribution $q_1$ multiplied by a single likelihood term\n$t_2$.  We proceed as before, replacing the true likelihood term $t_2$\nwith an approximate (conjugate) term $\\tilde{Z}_2\n\\tilde{t}_2(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_2)$, where we again\nchoose the site parameters $(\\tilde{Z}_2, \\tilde{\\vec{\\theta}}_2)$ to\nmatch the moments between our new approximation\n\\[\n  q_2(\\vec{\\theta})\n  =\n  \\tilde{Z}_2\n  q_1(\\vec{\\theta})\n  \\tilde{t}_2(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_2)\n  =\n  \\tilde{Z}_1\n  \\tilde{Z}_2\n  p_0(\\vec{\\theta})\n  \\tilde{t}_1(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_1)\n  \\tilde{t}_2(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_2).\n\\]\nand the ``less-approximate'' posterior\n$q_1(\\vec{\\theta})t_2(\\vec{\\theta})$.  We proceed in this fashion\nuntil we have processed all the local likelihood terms, resulting\nin the final approximation\n\\[\n  q(\\vec{\\theta})\n  =\n  p_0(\\vec{\\theta})\n  \\prod_{i = 1}^N \\tilde{Z}_i \\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i).\n\\]\n\n\\section*{Expectation Propagation}\n\nOne thing to note about assumed density filtering is that our final\napproximation is dependent on the sequence in which we process the\nlikelihood terms $\\{t_i\\}$.  Note that we are always matching the\nmoments between\n\\[\n  q_{i-1}(\\vec{\\theta})t_i(\\vec{\\theta}),\n\\]\nthe approximation using data up to the $i$th term as well as the true\n$i$th likelihood term, and the new approximation\n\\[\n  q_i(\\vec{\\theta})\n  =\n  \\tilde{Z}_i\n  q_{i-1}(\\vec\\theta)\n  \\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i).\n\\]\nThis moment matching at time $i$ therefore never considers data that\nappears in future terms.  For this reason, we might accumulate errors\nand/or wish to later ``revisit'' a particular term and update the site\nparameters $(\\tilde{Z}_i, \\tilde{\\vec{\\theta}}_i)$ in light of future\ndata.  This idea leads to \\emph{expectation propagation,} a refinement\nof assumed density filtering that can address some of these issues.\n\nThe idea is simple.  Once we have processed each of the likelihood\nterms, resulting in the approximation above\n\\[\n  q(\\vec{\\theta})\n  =\n  p_0(\\vec{\\theta})\n  \\prod_{i = 1}^N \\tilde{Z}_i \\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i),\n\\]\nwe repeatedly revisit each term and update its site parameters.  The\nmechanism for doing so is quite simple.  First, we select a site $1\n\\leq i \\leq N$ to update, then form the so-called \\emph{cavity\n  distribution,} which is our approximation using all but the $i$th\nterm in the product:\n\\[\n  q_{-i}(\\vec{\\theta})\n  =\n  p_0(\\vec{\\theta})\n  \\prod_{j \\neq i} \\tilde{Z}_j \\tilde{t}_j(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_j),\n\\]\nwhere we have divided by the old site term $\\tilde{Z}_i\n\\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i)$.  Now we replace\nthe removed site term with the true likelihood term $t_i$, forming the\n\\emph{tilted distribution}\n\\[\n  q_{-i}(\\vec{\\theta})\n  t_i(\\vec{\\theta}).\n\\]\nFinally, we select new site parameters to (re)match the moments\nbetween the tilted distribution and our new approximation:\n\\[\n  q_{\\text{new}}(\\vec{\\theta})\n  =\n  \\tilde{Z}_i\n  q_{-i}(\\vec{\\theta})\n  \\tilde{t}_i(\\vec{\\theta}; \\tilde{\\vec{\\theta}}_i).\n\\]\nWe proceed continually updating site parameters in this manner until\nwe reach convergence (i.e., none of the site parameters changes very\nmuch) or we expend a chosen computational budget.\n\n\\subsection*{Theoretical motivation}\n\nWe conclude with one brief note about the theoretical motivation\nbehind the moment matching used in assumed density filtering and\nexpectation propagation.  The Kullback--Leibler (\\acro{KL}) divergence\n(also called \\emph{relative entropy}) is a notion of ``distance''\nbetween probability distributions, defined by\n\\[\nd_{\\text{\\acro{KL}}}\\bigl(p(\\vec{\\theta}) \\parallel q(\\vec{\\theta})\\bigr)\n  =\n  \\int\n  p(\\vec{\\theta})\n  \\log\n  \\frac{p(\\vec{\\theta})}{q(\\vec{\\theta})}\n  \\intd{\\vec{\\theta}}.\n\\]\nNotice that \\acro{KL} divergence is not a true distance, as it is not\nsymmetric, but it does satisfy $d_{\\text{\\acro{KL}}}(p \\parallel q)\n\\geq 0$ with $d_{\\text{\\acro{KL}}}(p \\parallel q) = 0$ if and only if\n$p(\\vec{\\theta}) = q(\\vec{\\theta})$ almost everywhere.\n\nA well-known result is that the \\acro{KL} divergence between an\narbitrary probability distribution $p(\\vec{\\theta})$ and a\nmultivariate Gaussian distribution $q(\\vec{\\theta})$ (in the direction\n$d_{\\text{\\acro{KL}}}(p \\parallel q)$) is minimized when $q$ is chosen\nto match the moments of $p$.  Therefore, in the case of Gaussian\napproximations, these methods can be seen as iteratively building up\nan approximate posterior in the desired family by minimizing the\n\\acro{KL} divergence at every step.\n\nMinimizing \\acro{KL} divergence in ``the other direction,''\n$d_{\\text{\\acro{KL}}}(q \\parallel p)$, gives rise to another family of\napproximation techniques known as \\emph{variational Bayesian\n  inference.}\n\n\\end{document}\n", "meta": {"hexsha": "4583929fe29cbd021d975a1897cce2afd472f431", "size": 14958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "lecture_notes/Expectation Propagation/notes.tex", "max_stars_repo_name": "Aahana1/cse515t", "max_stars_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 80, "max_stars_repo_stars_event_min_datetime": "2015-01-12T22:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-22T13:35:22.000Z", "max_issues_repo_path": "lecture_notes/Expectation Propagation/notes.tex", "max_issues_repo_name": "Aahana1/cse515t", "max_issues_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-01-18T00:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-25T22:00:05.000Z", "max_forks_repo_path": "lecture_notes/Expectation Propagation/notes.tex", "max_forks_repo_name": "Aahana1/cse515t", "max_forks_repo_head_hexsha": "2a7c9657ede4664e080e2914be402de85a8e3c6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2015-01-14T23:29:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-02T09:12:54.000Z", "avg_line_length": 32.8026315789, "max_line_length": 118, "alphanum_fraction": 0.7108570665, "num_tokens": 4712, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4013498178503709}}
{"text": "%! TEX program = xelatex\n%! TEX root = lecture3_slide.tex\n\n\\usepackage{listings}\n\\title{Programming Language Theory}\n\\subtitle{Primitive Recursion, General Recursion, and Polymorphism}\n\\begin{document}\n\n{\\usebackgroundtemplate{\\includegraphics[width=\\paperwidth]{image.png}}\n\\begin{frame}\\maketitle\\end{frame}}\n\n%\\begin{frame}[fragile]{Polymorphism}\n%  \\emph{Abstraction principle~\\cite{Pierce2002}}:\n%  \\begin{quotation}\n%    Each significant piece of functionality in a program should be implemented\n%    in just one place in the source code. Where similar functions are carried\n%    out by distinct pieces of code, it is generally beneficial to combine them\n%    into one by abstracting out the varying parts.\n%  \\end{quotation}\n%\n%  In Haskell\n%  \\begin{semiverbatim}\n%    head :: [a] -> a\n%    head (x:_) = x\n%  \\end{semiverbatim}\n%\\end{frame}\n\n\\section{G\\\"odel's \\textbf{T}: Simply typed $\\lambda$-calculus with naturals\nand primitive recursion}\n\\begin{frame}{The un defineability of $\\lambda_\\to$}\n  Can you write this in $\\lambda_\\to$ using Church numerals?\n  \\begin{align*}\n    \\mathit{sum}(0)     & = 0 \\\\\n    \\mathit{sum}(1 + n) & = (1 + n) + \\mathit{sum}(n)\n  \\end{align*}\n  It is not definable in $\\lambda_\\to$, since fixpoint operator is not allowed any more. \n\n  But, this is definable via \\emph{primitive recursion}:\n  for some $c$ and function $g$\n  \\begin{align*}\n    \\mathit{prec}(0, c, g(x, y))       &= c \\\\\n    \\mathit{prec}(1 + n, c, g(x, y))   &= g(n, \\mathit{prec}(n, c, g(x, y)))\n  \\end{align*}\n\n  $\\lambda_\\to$ with primitive recursion is called G\\\"odel's \\textbf{T}.\n\\end{frame}\n\n\\begin{frame}{\\textbf{T}: Types and terms}\n  \\begin{definition}[Types]\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$B \\in \\mathbb{V}$}\n        \\RightLabel{(tvar)}\n        \\UIC{$B : \\type$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{B}$}\n        \\RightLabel{(nat)}\n        \\UIC{$\\mathbb{N} : \\type$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\sigma : \\type$}\n        \\AXC{$\\tau   : \\type$}\n        \\RightLabel{(fun)}\n        \\BIC{$\\sigma \\to \\tau : \\type$}\n      \\end{prooftree}\n    \\end{multicols}\n  \\end{definition}\n  \\begin{definition}[Terms]\n    Additional term formation rules are added to $\\lambda_\\to$ as follows.\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{M}$}\n        \\UIC{$\\zero : \\term_{\\textbf{T}}$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$M$}\n        \\UIC{$\\suc\\;M : \\term_{\\textbf{T}}$}\n      \\end{prooftree}\n    \\end{multicols}\n      \\begin{prooftree}\n        \\AXC{$L : \\term_{\\textbf{T}}$}\n        \\AXC{$M : \\term_{\\textbf{T}}$}\n        \\AXC{$N : \\term_{\\textbf{T}}$}\n        \\AXC{$x \\in V$}\n        \\AXC{$y \\in V$}\n        \\QuinaryInfC{$\\mathtt{rec}(M; x.\\,y.\\,N)\\; L : \\term_{\\textbf{T}}$}\n      \\end{prooftree}\n  \\end{definition}\n\\end{frame}\n\n\\begin{frame}{\\textbf{T}: Typing rules}\n  \\begin{definition}\n    Additional term typing rules are added to $\\lambda_\\to$ as follows.\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{\\Gamma}$}\n        \\UIC{$\\Gamma \\vdash \\zero : \\mathbb{N}$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\Gamma \\vdash M : \\mathbb{N}$}\n        \\UIC{$\\Gamma \\vdash \\suc\\;M : \\mathbb{N}$}\n      \\end{prooftree}\n    \\end{multicols}\n    \\begin{prooftree}\n      \\AXC{$\\Gamma \\vdash L : \\mathbb{N}$}\n      \\AXC{$\\Gamma \\vdash M : \\tau$}\n      \\AXC{$\\Gamma, x : \\mathbb{N}, y : \\tau \\vdash N : \\tau$}\n      \\TrinaryInfC{$\\Gamma \\vdash \\mathtt{rec}(M; x.\\,y.\\,N)\\;L : \\tau$}\n    \\end{prooftree}\n  \\end{definition}\n  \\begin{itemize}\n    \\item Substitution for \\textbf{T} is defined similarly.\n    \\item Substitution respects typing judgements, i.e.\\ \n      $\\Gamma \\vdash N : \\tau$ and $\\Gamma, x : \\tau \\vdash M : \\sigma$, then \n      $\\Gamma \\vdash M\\subst{N}{x} : \\sigma$.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{\\textbf{T}: Dynamics}\n  $\\beta$-conversion for \\textbf{T} is extended with two rules\n  \\begin{align*}\n    \\mathtt{rec}(M, x.\\,y.\\, N)\\;\\zero & \\longrightarrow_\\beta M \\\\\n    \\mathtt{rec}(M, x.\\,y.\\, N)\\;\\suc\\;L & \\longrightarrow_\\beta N\\subst{L , \\mathtt{rec}(M; x.\\,y.\\,N)\\;L}{x, y}\n  \\end{align*}\n  Similarly, a $\\beta$-reduction $\\onereduce$ extends $\\longrightarrow_\\beta$ to all parts of a term and $\\reduce$ indicates finitely many $\\beta$-reductions.\n  \n  \\mode<presentation>{\\vfill}\n  \\begin{theorem}\n    \\textbf{T} enjoys the strong and weak normalisation properties as well as type safety.\n  \\end{theorem}\n\\end{frame}\n\n\\begin{frame}{Example: Addition and summation}\n  $\\mathtt{add} : \\mathbb{N} \\to \\mathbb{N} \\to \\mathbb{N}$ can be defined in \\textbf{T} as\n  \\[\n    \\lambda n.\\,\\lambda m.\\,\\mathtt{rec}\\;(m; x.\\,y.\\, \\suc\\;y)\\;n\\;m\n  \\]\n\n  $\\mathtt{sum} : \\mathbb{N} \\to \\mathbb{N}$ can be defined in \\textbf{T} as\n  \\[\n    \\lambda n.\\, \\mathtt{rec}\\;(\\zero; x.\\,y.\\, \\add\\;(\\suc\\;x)\\;y)\\;n\n  \\]\n\\mode<presentation>{\\vfill}\n  \\begin{block}{Exercise}\n    Evaluate $\\mathtt{sum}\\;(\\suc\\;\\zero)$.\n  \\end{block}\n\\end{frame}\n\n\\section{\\PCF --- System of Recursive Functions}\n\n\\begin{frame}{\\textbf{PCF}: $\\lambda_\\to$ with naturals and general recursion}\n  \\textbf{T} does not include all computable functions, since all terms terminate eventually. \n  Programming language in reality allows us to do \\emph{general recursion}\n  including \\emph{infinite loops}. \n\n  \\textbf{PCF} has the same class of types as \\textbf{T}.\n\n  \\begin{definition}[Terms]\n    Additional term formation rules are added to $\\lambda_\\to$ as follows.\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{M}$}\n        \\UIC{$\\zero : \\term_{\\PCF}$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$M : \\term_{\\PCF}$}\n        \\UIC{$\\suc\\;M : \\term_{\\PCF}$}\n      \\end{prooftree}\n    \\end{multicols}\n      \\begin{prooftree}\n      \\color{red}\n        \\AXC{$L : \\term_{\\PCF}$}\n        \\AXC{$M : \\term_{\\PCF}$}\n        \\AXC{$N : \\term_{\\PCF}$}\n        \\AXC{$x \\in V$}\n        \\QuaternaryInfC{$\\ifz(M; x.\\,N)\\; L$}\n      \\end{prooftree}\n      \\begin{prooftree}\n      \\color{red}\n        \\AXC{$M : \\term_{\\PCF}$}\n        \\AXC{$x \\in V$}\n        \\BIC{$\\fix\\,x.\\,M : \\term_{\\PCF}$}\n      \\end{prooftree}\n  \\end{definition}\n\\end{frame}\n\n\\begin{frame}{\\textbf{PCF}: Typing rules}\n  \\begin{definition}\n    Additional term typing rules are added to $\\lambda_\\to$ as follows.\n    \\begin{multicols}{2}\n      \\begin{prooftree}\n        \\AXC{$\\vphantom{\\Gamma}$}\n        \\UIC{$\\Gamma \\vdash \\zero : \\mathbb{N}$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\Gamma \\vdash M : \\mathbb{N}$}\n        \\UIC{$\\Gamma \\vdash \\suc\\;M : \\mathbb{N}$}\n      \\end{prooftree}\n    \\end{multicols}\n    \\begin{prooftree}\n      \\color{red}\n      \\AXC{$\\Gamma \\vdash L : \\mathbb{N}$}\n      \\AXC{$\\Gamma \\vdash M : \\tau$}\n      \\AXC{$\\Gamma, x : \\mathbb{N} \\vdash N : \\tau$}\n      \\TrinaryInfC{$\\Gamma \\vdash \\ifz(M; x.\\,N)\\;L : \\tau$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\color{red}\n      \\AXC{$\\Gamma, x : \\tau \\vdash M : \\tau$}\n      \\UIC{$\\Gamma \\vdash \\fix\\,x.\\,M : \\tau$}\n    \\end{prooftree}\n  \\end{definition}\n  \\begin{itemize}\n    \\item Substitution for \\textbf{PCF} is defined similarly.\n    \\item Substitution respects typing judgements, i.e.\\ \n      $\\Gamma \\vdash N : \\tau$ and $\\Gamma, x : \\tau \\vdash M : \\sigma$, then \n      $\\Gamma \\vdash M\\subst{N}{x} : \\sigma$.\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{\\textbf{PCF}: Dynamics}\n  $\\beta$-conversion for \\textbf{PCF} is extended with three rules\n  \\begin{align*}\n    \\fix\\,x.\\,M & \\longrightarrow_\\beta M\\subst{\\fix\\,x.\\,M}{x} \\\\\n    \\ifz(M; x.\\, N)\\;\\zero & \\longrightarrow_\\beta M \\\\\n    \\ifz(M; x.\\, N)\\;(\\suc M) & \\longrightarrow_\\beta N\\subst{M}{x}\n  \\end{align*}\n  Similarly, a $\\beta$-reduction $\\onereduce$ extends $\\longrightarrow_\\beta$ to all parts of a term and $\\reduce$ indicates finitely many $\\beta$-reductions.\n  \n  \\mode<presentation>{\\vfill}\n  \\begin{theorem}\n    \\textbf{PCF} enjoys type safety. \n  \\end{theorem}\n\\end{frame}\n\n\\begin{frame}{Example}\n  A term which never terminates can be defined easily.\n  \\begin{align*}\n             & \\fix\\,x.\\,x & \\onereduce x\\subst{\\fix\\,x.\\,x}{x} \\\\\n    \\equiv{} & \\fix\\,x.\\,x & \\onereduce x\\subst{\\fix\\,x.\\,x}{x} \\\\\n    \\equiv{} & \\fix\\,x.\\,x & \\onereduce x\\subst{\\fix\\,x.\\,x}{x} \\\\\n    \\equiv{} & \\dots\n  \\end{align*}\n\\end{frame}\n\n\\begin{frame}{Example: Predecessor and negation}\n  \\begin{align*}\n    \\pred & \\defeq \\lambda n : \\mathbb{N}.\\,\\ifz(\\zero; x.\\, x)\\;n & : \\mathbb{N} \\to \\mathbb{N} \\\\\n               \\mathtt{not} & \\defeq \\lambda n : \\mathbb{N}.\\, \\ifz(\\suc\\;\\zero; x.\\, \\zero)\\; n & : \\mathbb{N} \\to \\mathbb{N}\n  \\end{align*}\n  \\begin{block}{Exercise}\n    Evaluate the following terms to their normal forms.\n    \\begin{enumerate}\n      \\item $\\pred\\;\\zero$\n      \\item $\\pred\\;(\\suc\\;\\suc\\;\\suc\\;\\zero)$\n      \\item $\\mathtt{not}\\;(\\suc\\;\\suc\\;\\zero)$\n    \\end{enumerate}\n    \n  \\end{block}\n\\end{frame}\n\n\\section{\\textbf{F} --- Polymorphic Typed $\\lambda$-Calculus}\n\\begin{frame}{Polymorphic types}\n    Given type variables~$\\mathbb{V}$, $\\tau : \\type$ is defined by\n    defined by\n      \\begin{prooftree}\n        \\AXC{$t \\in \\mathbb{V}$}\n        \\RightLabel{(tvar)}\n        \\UIC{$t : \\type$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\sigma : \\type$}\n        \\AXC{$\\tau   : \\type$}\n        \\RightLabel{(fun)}\n        \\BIC{$\\sigma \\to \\tau : \\type$}\n      \\end{prooftree}\n      \\begin{prooftree}\n        \\AXC{$\\sigma : \\type$}\n        \\AXC{$t   \\in \\mathbb{V}$}\n        \\RightLabel{(poly)}\n        \\BIC{$\\forall t.\\, \\sigma : \\type$}\n      \\end{prooftree}\n  where $t$ may or may not appear in~$\\sigma$.\n\n  The polymorphic type $\\forall t.\\, \\sigma$ provides a generic type for every\n  instance $\\sigma[\\tau/t]$ whenever $t$ is instantiated by an actual type $\\tau$.\n\n%For example, the type $\\forall t.\\, t \\to t$ corresponds to a type variable\n%universally quantified in GHC with extension \\texttt{RankNType}\n%\\begin{semiverbatim}\n%  forall a. a -> a\n%\\end{semiverbatim}\n%or simply \n%\\begin{semiverbatim}\n%  a -> a\n%\\end{semiverbatim}\n\\end{frame}\n\n\\begin{frame}{Examples}\n\n  \\begin{itemize}\n    \\item $\\mathtt{id} : \\forall t.\\, t \\to t$\n\n    \\item $\\mathtt{proj}_1 : \\forall t.\\,\\forall u.\\, t \\to u \\to t$\n\n    \\item $\\mathtt{proj}_2 : \\forall t.\\,\\forall u.\\, t \\to u \\to u$\n\n    \\item $\\mathtt{length} : \\forall t.\\, \\List\\;t \\to \\nat$\n\n    \\item $\\mathtt{singleton} : \\forall t. t \\to \\List(t)$\n  \\end{itemize}\n  \n\\end{frame}\n\n\\begin{frame}{Free and bound variables, again}\n\\begin{definition}\n  The \\emph{free variable} $\\FV(\\tau)$ of $\\tau$ is defined inductively by\n  \\begin{align*}\n    \\FV(t) & {} = t \\\\\n    \\FV(\\sigma \\to \\tau) & {} = \\FV(\\sigma) \\cup \\FV(\\tau) \\\\\n    \\FV(\\forall t.\\, \\sigma) & {} = \\FV(\\sigma) - \\{t\\}\n  \\end{align*}\n  For convenience, the function extends to contexts:\n  \\[\n    \\FV(\\Gamma) = \\set{ t \\in \\mathbb{V}}{ \\exists (x : \\sigma) \\in \\Gamma\n      \\wedge t \\in \\FV(\\sigma) }.\n  \\]\n\\end{definition}\n  \\begin{enumerate}\n    \\item $\\FV(t_1) = \\{t_1\\}$.\n    \\item $\\FV(\\forall t.\\, (t \\to t) \\to t \\to t) = \\emptyset$.\n    \\item $\\FV(x : t_1, y : t_2, z : \\forall t.\\,t)\n      = \\{t_1, t_2\\}$.\n  \\end{enumerate}\n\\end{frame}\n\\begin{frame}{Capture-avoiding substitution for type}\n  \\begin{definition}\n  The \\emph{(capture-avoidance) substitution} of a type $\\rho$ for the free\n  occurrence of a type variable~$t$ is defined by \n  \\begin{align*}\n    t\\subst{\\rho}{t} & = \\rho \\\\\n    u\\subst{\\rho}{t} & = u && \\text{if $u \\neq t$}\\\\\n    (\\sigma\\to\\tau)\\subst{\\rho}{t} & =\n    \\sigma\\subst{\\rho}{t} \\to\n    \\tau\\subst{\\rho}{t} \\\\\n    (\\forall t.\\sigma)\\subst{\\rho}{t} & = \\forall t.\\sigma \\\\\n    (\\forall u.\\sigma)\\subst{\\rho}{t} & = \\forall u.\\sigma\\subst{\\rho}{t}\n                                      &&\n    \\text{if $u \\neq t, u \\not\\in \\FV(\\rho)$} \n  \\end{align*}\n  \\end{definition}\n  Recall that $u \\not\\in \\FV(\\rho)$ means that $u$ is \\emph{fresh} for $\\rho$. \n\\end{frame}\n\n\\begin{frame}{Typed terms}\n\\begin{definition}\n  On top of $\\lambda_\\to$, \\textbf{F} has additional term formation rules as follows.\n    \\begin{prooftree}\n      \\AXC{$M : \\term_F$}\n      \\AXC{$t : \\mathbb{V}$}\n      \\RightLabel{(gen)}\n      \\BIC{$\\Lambda\\, t.\\; M : \\term_F$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$M : \\term_F$}\n      \\AXC{$\\tau : \\type$}\n      \\RightLabel{(inst)}\n      \\BIC{$M\\;\\tau : \\term_F$}\n    \\end{prooftree}\n\\end{definition}\n\n  \\begin{enumerate}\n    \\item $\\Lambda t.\\, M$ for type abstraction, or \\emph{generalisation}.\n    \\item $M\\;\\tau$ for type application, or \\emph{instantiation}.\n  \\end{enumerate}\n%\\framebreak\n%GHC with the extension \\texttt{ScopedTypeVariables} allows you to use type\n%variables. \n%\\begin{semiverbatim}\n% f :: forall a. [a] -> [a]\n%\n% f = \\\\(xs :: [a]) -> reverse xs\n%\\end{semiverbatim}\n%GHC with the extension \\texttt{TypeApplications} allows you to apply a type\n%argument.\n%\\begin{semiverbatim}\n%  Prelude> :t id\n%\n%  id :: a -> a\n%\n%  Prelude> :t id @Int\n%\n%  id @Int :: Int -> Int\n%\\end{semiverbatim}\n%\n%\\framebreak\n%  Can you see the corresponding untyped/simply typed $\\lambda$-terms of the\n%  following $\\lambda$-terms in System F? \n%\n%  \\begin{enumerate}\n%    \\item $\\Lambda t.\\,\\lambda (x : t).\\, x$\n%    \\item $\\Lambda t.\\, \\lambda (x : t)(y : t).\\, x$\n%    \\item $(\\Lambda t.\\, \\lambda (x : t)(y : t).\\, x)\\;\\sigma\\;M\\;N$\n%     where  $M, N$ are terms and $\\sigma$ a type.\n%    \\item $\\Lambda t.\\, \\lambda (f : t \\to t)(x : t).\\, f\\;(f\\;x)$\n%  \\end{enumerate}\n%System $F$ is more expressive than simply typed lambda calculus.\n\\end{frame}\n\\begin{frame}{Example}\n  Suppose $\\mathtt{length} : \\forall t.\\,\\List\\;t \\to \\nat$. \n\n  Then, \n  \\begin{enumerate}\n    \\item $\\mathtt{length}\\;\\nat$\n    \\item $\\mathtt{length}\\;\\bool$\n    \\item $\\mathtt{length}\\;(\\nat \\to \\nat)$\n  \\end{enumerate}\n  are instances of $\\mathtt{length}$ with types\n  \\begin{enumerate}\n     \\item $\\List\\; \\nat \\to \\nat$\n     \\item $\\List\\;\\bool \\to \\nat$\n     \\item $\\List\\;(\\nat \\to \\nat) \\to \\nat$\n  \\end{enumerate}\n\\end{frame}\n\n\\begin{frame}{System F: Typing judgement}\n  A \\emph{type context} is a sequence of type variable \n  \\[\n    t_1, t_2, \\dots, t_n\n  \\]\n\n  \\textbf{F} has two kinds of typing judgements.\n  \\begin{itemize}\n    \\item $\\Delta \\vdash \\tau$ for $\\tau$ for a valid type under the type context $\\Delta$\n    \\item $\\Delta; \\Gamma \\vdash M : \\tau$ for a well-typed term under the context $\\Gamma$ and the type context~$\\Delta$.\n  \\end{itemize}\n  For example,\n    \\[\n      t \\vdash t \\to t\n    \\]\n    is a judgement that $t \\to $ is a valid type under the type context, $t$.\n\n\\end{frame}\n\n\\begin{frame}{System F: Type formation}\n  The justification of $\\Delta \\vdash \\tau$ is constructed inductively by following rules.\n  \\begin{multicols}{2}\n    \\begin{prooftree}\n      \\AXC{$t$ occurs in $\\Delta$}\n      \\UIC{$\\Delta \\vdash t$}\n    \\end{prooftree}\n    \\begin{prooftree}\n      \\AXC{$\\Delta \\vdash \\tau_1$}\n      \\AXC{$\\Delta \\vdash \\tau_2$}\n      \\BIC{$\\Delta \\vdash \\tau_1 \\to \\tau_2$}\n    \\end{prooftree}\n    \\columnbreak\n    \\begin{prooftree}\n      \\AXC{$\\Delta, t \\vdash \\tau$}\n      \\UIC{$\\Delta \\vdash \\forall t.\\, \\tau$}\n    \\end{prooftree}\n  \\end{multicols}\n\n  \\begin{block}{Exercise}\n    Derive the judgement \n    \\[\n        t : \\tau \\vdash t \\to t\n    \\]\n  \\end{block}\n\\end{frame}\n\n\\begin{frame}{System F: Typing rules}\n  \n  The justification of $\\Delta; \\Gamma \\vdash M : \\sigma$ is defined inductively by following rules.\n  \\begin{multicols}{2} \n  \\begin{prooftree}\n    \\AXC{$x : \\sigma \\in \\Gamma$}\n    \\UIC{$\\Delta ; \\Gamma \\vdash x : \\sigma$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Delta; \\Gamma \\vdash M : \\sigma \\to \\tau$}\n    \\AXC{$\\Delta; \\Gamma \\vdash N : \\sigma$}\n    \\BIC{$\\Delta; \\Gamma \\vdash M\\;N : \\tau$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{{\\color{red}$\\Delta \\vdash \\sigma$}}\n    \\AXC{$\\Delta; \\Gamma, x : \\sigma \\vdash M : \\tau$}\n    \\BIC{$\\Delta; \\Gamma \\vdash \\lambda x : \\sigma.\\; M : \\sigma \\to \\tau$}\n  \\end{prooftree}\n  \\color{red}\n  \\begin{prooftree}\n    \\AXC{$\\Delta, t; \\Gamma \\vdash M : \\sigma$}\n    \\RightLabel{($\\forall$-intro)}\n    \\UIC{$\\Delta; \\Gamma \\vdash \\Lambda t.\\;M : \\forall t.\\, \\sigma$}\n  \\end{prooftree}\n  \\begin{prooftree}\n    \\AXC{$\\Delta; \\Gamma \\vdash M : \\forall t.\\, \\sigma$}\n    \\AXC{$\\Delta \\vdash \\tau$}\n    \\RightLabel{($\\forall$-elim)}\n    \\BIC{$\\Delta; \\Gamma \\vdash M\\;\\tau : \\sigma\\subst{\\tau}{t}$}\n  \\end{prooftree}\n  \\end{multicols}\n\n  For convenience, \n  $\\vdash M : \\tau$ stands for $\\cdot ; \\cdot \\vdash M : \\tau$.\n\n\\end{frame}\n\n\\begin{frame}{Typing derivation}\n\nThe typing judgement ${}\\vdash\\Lambda t.\\, \\Lambda u.\\, \\lambda (x : t)(y : u).\\, x : \\forall\nt.\\;t \\to u \\to t$ is derivable from the following derivation:\n\\begin{prooftree}\n  \\AXC{}\n  \\UIC{$t , u \\vdash t$}\n  \\AXC{}\n  \\UIC{$t , u \\vdash u$}\n  \\AXC{}\n  \\UIC{$t , u ; x : t, y : u \\vdash x : t$}\n  \\BIC{$t , u ; x : t \\vdash \\lambda (y : u).\\; x : u \\to t$}\n  \\BIC{$t , u ; \\cdot \\vdash \\lambda (x : t)(y : u).\\; x : t \\to u \\to t$}\n  \\UIC{$t ; \\cdot \\vdash \\Lambda u.\\,\\lambda (x : t)(y : u).\\; x :\\forall u.\\,t \\to u \\to\n    t$}\n  \\UIC{$\\vdash \\Lambda t.\\, \\Lambda u.\\, \\lambda (x : t)(y : u).\\; x : \\forall t.\\,\\forall u.\\,\n  t \\to u \\to t$}\n\\end{prooftree}\n  \n\\end{frame}\n\n\\begin{frame}{Exercise}\n  Derive the following judgements:\n  \\begin{enumerate}\n    \\item ${}\\vdash\\Lambda t.\\,\\lambda (x : t).\\, x : \\forall t.\\;t\\to t$\n    \\item $\\sigma ; a : \\sigma\n      \\vdash (\\Lambda t.\\, \\lambda (x : t)(y : t).\\, x)\\;\\sigma\\;a\n      : \\sigma \\to \\sigma$\n    \\item ${}\\vdash\\Lambda t.\\, \\lambda (f : t \\to t)(x : t).\\, f\\;(f\\;x) :\n      \\forall t.\\;(t\\to t) \\to t\\to t$\n    \\end{enumerate}\n  Hint. \\textbf{F} is syntax-directed, so the type inversion holds. \n  \n\\end{frame}\n\n\\begin{frame}{System F: $\\beta$-reduction}\n  \nThe $\\beta$-conversion has two rules\n\\[\n  (\\lambda (x : \\tau).\\, M)\\,N \\longrightarrow_{\\beta}\n  M\\subst{x}{N}\n  \\quad\\text{and}\\quad\n  \\color{red} (\\Lambda t.\\, M)\\;\\tau \\longrightarrow_{\\beta} M \\subst{\\tau}{t}\n\\]\n\nFor example, \n\\[\n  (\\Lambda t.\\lambda x : t.\\, x)\\; \\tau\\; a\n  \\longrightarrow_\\beta \n  (\\lambda x : t.\\, x)\\subst{\\tau}{t}\\;a\n  \\equiv \n  (\\lambda x : \\tau.\\, x)\\;a\n  \\longrightarrow_\\beta \n  x\\subst{a}{x}\n  \\equiv a\n\\]\n\nSimilarly, $\\beta$-conversion extends to subterms of a given term, introducing symbols $\\onereduce$ and $\\reduce$ in the same way.\n\\end{frame}\n\n%\\begin{frame}{System F: Evaluation}\n%  \n%The full $\\beta$-reduction is a relation on $\\lambda$-terms defined by\n%\\begin{multicols}{2}\n%    \\begin{prooftree}\n%      \\AXC{$M_1 \\longrightarrow_{\\beta} M_2$}\n%      \\UIC{$M_1 \\onereduce M_2$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$M_1 \\onereduce M_2$}\n%      \\UIC{$\\lambda (x:\\tau).\\, M_1 \\onereduce \\lambda (x:\\tau).\\, M_2$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{{\\color{red}$M_1 \\onereduce M_2$}}\n%      \\UIC{{\\color{red}$\\Lambda t.\\, M_1 \\onereduce \\Lambda t.\\, M_2$}}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$M_1 \\onereduce M_2$}\n%      \\UIC{$M_1\\,N \\onereduce M_2\\,N$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{$N_1\\onereduce  N_2$}\n%      \\UIC{$M\\,N_1 \\onereduce M\\,N_2$}\n%    \\end{prooftree}\n%    \\begin{prooftree}\n%      \\AXC{{\\color{red}$M_1 \\onereduce M_2$}}\n%      \\UIC{{\\color{red}$M_1\\,\\tau \\onereduce M_2\\,\\tau$}}\n%    \\end{prooftree}\n%\\end{multicols}\n%If $M \\onereduce N$, then $M$ and $N$ \\alert{denotes} the same value. So, \n%\\[\n%  M =_\\beta N\n%\\]\n%where $=_\\beta$ is the congruence and equivalence closure of\n%$\\longrightarrow_\\beta$.\n%\\end{frame}\n\n\\begin{frame}{Self application}\nSelf-application is not typable in simply typed $\\lambda$-calculus. \n  \\[\n    \\lambda (x : t).\\, x\\; x\n  \\]\n  However, self-application is possible in System F. \n  \\[\n    \\lambda (x : \\forall t. t\\to t).\\, x\\;(\\forall t. t\\to t)\\;x\n  \\]\n\\mode<presentation>{\\vfill}\n  \\begin{block}{Exercise}\n    Instantiate the first $t$ with the type $\\forall t.\\, t \\to t$.  \n  \\end{block}\n\\end{frame}\n\n\\begin{frame}{Sum type}\n\n\\begin{definition}\n  The \\emph{sum type} is defined by\n  \\[\n    \\sigma + \\tau \\defeq \\forall t. (\\sigma \\to t) \\to (\\tau \\to t) \\to t\n  \\]\n\\end{definition}\nIt has two injection functions: the first injection is defined by\n\\begin{align*}\n  \\mathtt{left}_{\\sigma + \\tau} & \\defeq \\lambda (x : \\sigma).\\;\\Lambda t.\\,\\lambda (f : \\sigma\\to\n  t)(g : \\tau\\to t).\\, f\\;x \\\\\n  \\mathtt{right}_{\\sigma + \\tau} & \\defeq \\lambda (y : \\tau).\\;\\Lambda t.\\,\\lambda (f : \\sigma\\to\n  t)(g : \\tau\\to t).\\, g\\;y\n\\end{align*}\n\n%With the sum type, we can implement the usual construct \\texttt{either}:\n%\\[\n%  \\mathtt{either} : \\forall\\,t.\\;(\\sigma \\to t) \\to (\\tau \\to t)\n%  \\to (\\sigma + \\tau) \\to t\n%\\]\n%which corresponds to the Haskell function\n%{\\small\n%\\begin{semiverbatim}\n%  either :: (a -> c) -> (b -> c) -> Either a b -> c\n%\n%  either f g (Left  a) = f a \n%\n%  either f g (Right b) = g b\n%\\end{semiverbatim}}\n\n\\mode<presentation>{\\vfill}\n\\begin{block}{Exercise}\n  Define \n  \\[\n    \\mathtt{either} : \\forall u.\\, (\\sigma \\to u) \\to (\\tau \\to u) \\to \\sigma + \\tau \\to u\n  \\] \n\\end{block}\n\\end{frame}\n\n\\begin{frame}{Product type}\n\\begin{definition}[Product Type]\n  The product type is defined by\n  \\[\n    \\sigma \\times \\tau \\defeq \\forall t. (\\sigma \\to \\tau \\to t) \\to t\n  \\]\n\\end{definition}\nThe pairing function is defined by\n\\begin{align*}\n  \\left< \\_, \\_\\right> \\defeq \\lambda (x : \\sigma)(y : \\tau).\\,\\Lambda t.\\,\\lambda (f : \\sigma \\to \\tau \\to t).\\,\n  f\\;x\\;y\n\\end{align*}\n\\begin{block}{Exercise}\nDefine projections \n\\[\n  \\mathtt{proj}_1 : \\sigma \\times \\tau \\to \\sigma\n  \\quad\\text{and}\\quad\n  \\mathtt{proj}_2 : \\sigma\\times \\tau \\to \\tau\n\\]\n\\end{block}\n\\end{frame}\n\\begin{frame}[allowframebreaks]{Natural Numbers}\nThe type of Church numerals is defined by \n\\[\n  \\nat \\defeq \\forall t.\\, (t\\to t)\\to t\\to t\n\\]\n  \\begin{description}\n    \\item[Church numerals]\n      \\begin{align*}\n        \\bc_n & : \\nat \\\\\n        \\bc_n & \\defeq \\Lambda t.\\,\\lambda (f:t \\to t)\\,(x:t).\\,\n        f^n\\;x\n      \\end{align*}\n    \\item[Successor]\n      \\begin{align*}\n        \\suc & : \\nat \\to \\nat \\\\\n        \\suc & \\defeq \\,\\lambda (n : \\nat).\\,\\Lambda t.\\,\\lambda\n        (f : t \\to t)\\,(x:t)\\,.\\;f\\;(n\\;t\\;f\\;x) \n      \\end{align*}\n    \\item[Addition]\n      \\begin{align*}\n        \\add & : \\nat \\to \\nat \\to \\nat \\\\\n        \\add & \\defeq \\lambda (n : \\nat)\\,(m:\\nat)\\,&& \\Lambda t.\\, \\lambda\n        (f:t\\to t)\\,(x: t).\\\\\n        &&& (m\\;t\\;f)\\;(n\\;t\\;f\\;x) \n      \\end{align*}\n    \\item[Multiplication] \n      \\begin{align*}\n       \\mul & : \\nat\\to \\nat \\to\\nat\\\\\n       \\mul & \\defeq\\,?\n      \\end{align*}\n    \\item[Conditional]\n      \\begin{align*}\n       \\ifz & : \\forall t.\\,\\nat \\to t \\to t \\to t \\\\\n       \\ifz & \\defeq\\,?\n      \\end{align*}\n  \\end{description}\nSystem $F$ allows us to define \\emph{iterator} like \\texttt{fold} in Haskell.\n\\begin{align*}\n  \\mathtt{fold}_{\\nat} & : \\forall t.\\, (t \\to t) \\to t \\to \\nat \\to t  \\\\\n  \\mathtt{fold}_{\\nat} & \\defeq \\Lambda t.\\, \\lambda (f : t \\to t)(e_0 : t)(n : \\nat). \n  n\\;t\\;f\\;e_0\n\\end{align*}\n\n%In Haskell, the above $\\lambda$-term can be given as\n%\\begin{semiverbatim}\n%  fold :: (a -> a) -> a -> [()] -> a\n%\n%  fold f e []            = e\n%\n%  fold f e (():xs) = f () (fold f e xs)\n%\\end{semiverbatim}\n%\n\\begin{block}{Exercise}\n  Define $\\add$ and $\\mul$ using $\\mathtt{fold}_{\\nat}$ and justify your\n  answer.\n  \n  \\begin{enumerate}\n    \\item $\\add'\\defeq \\;? : \\nat\\to\\nat\\to\\nat$\n    \\item $\\mul'\\defeq \\;? : \\nat\\to\\nat\\to\\nat$\n  \\end{enumerate}\n\\end{block}\n\\end{frame}\n\n\\begin{frame}{Lists}\n\\begin{definition}\n  For any type $\\sigma$, the type of lists over $\\sigma$ is \n\\[\n  \\List\\,\\sigma\\defeq \\forall t.\\, t \\to (\\sigma \\to t \\to t) \\to t \n\\]\n\\end{definition}\nwith ``list constructors'':\n\\[\n  \\mathtt{nil}_\\sigma \\defeq \\Lambda t.\\lambda (h : t)(f : \\sigma\\to t \\to t).\\,\n  h\n\\]\nand  \n\\[\n  \\mathtt{cons}_\\sigma \\defeq \\lambda (x : \\sigma)(xs : \\List\\,\n  \\sigma).\\,\\Lambda t.\\lambda(h : t)(f : \\sigma\\to t \\to t).f\\,x\\,(xs\\; t\\;\n  h\\; f)\n\\]\nof type $\\sigma \\to \\List\\;\\sigma \\to \\List\\;\\sigma$.\n\n\n\\end{frame}\n\n%\\begin{frame}[allowframebreaks]{Existential Type}\n%  Abstraction can be described by an \\emph{existential type}.\n%  \\[\n%    \\exists t.\\, \\tau\n%  \\]\n%  where $\\tau$ is a type in which $t$ may appear as a free variable.\n%  A term $(\\sigma, M)$ of type $\\exists t.\\, \\tau$ consists of a \\emph{type}\n%  $\\sigma$ and a term $M$ of type $\\tau\\subst{t}{\\sigma}$. \n%\n%\n%  \\begin{example}\n%    A \\emph{stack} is a data structure with two operations:\n%    \\begin{itemize}\n%      \\item \\texttt{push}\n%      \\item \\texttt{pop}\n%    \\end{itemize}\n%    Any implementation satisfying $\\mathtt{pop} \\circ (\\mathtt{push}\\, n\\, st) =\n%    (n, st)$ can be seen as a stack. \n%  \\end{example}\n%\n%  \\begin{example}\n%    The type of stacks over natural numbers can be defined by\n%    \\[\n%      \\exists t. (t \\times \\nat \\to t) \\times (t \\to 1 + \\nat \\times t) \n%    \\]\n%    \\begin{enumerate}\n%      \\item The first component is the \\text{push} function.\n%      \\item The second component is the \\text{pop} function.\n%    \\end{enumerate}\n%    An instance of a stack is an element $(\\sigma, M)$ of the above type\n%    \\begin{enumerate}\n%      \\item $\\sigma$ is a type\n%      \\item $\\mathtt{proj}_1\\, M \\colon \\sigma \\times \\nat \\to \\sigma$\n%      \\item $\\mathtt{proj}_2\\, M \\colon \\sigma \\to 1 + \\nat \\times\n%          \\sigma$. \n%    \\end{enumerate}\n%  \\end{example}\n%\\end{frame}\n%\n%%\\begin{frame}[fragile]{Encoding of Existential Type in Haskell}\n%%  A limited form of existential type can be defined by \n%%  \\begin{semiverbatim}\n%%    data Exists t where\n%%      Ex :: t a -> Exists t\n%%  \\end{semiverbatim}\n%%  and another version for typeclass\n%%  \\begin{semiverbatim}\n%%    data Exists' c where\n%%      Ex' :: c a => a -> Exists' c\n%%  \\end{semiverbatim}\n%%  in GHC with extensions \\texttt{GADTs} and \\texttt{ConstraintKinds}. \n%%\n%%\\mode<presentation>{\\vfill}\n%%  \\begin{block}{Exercise}\n%%    Define the top type $\\top$ which contains every typable term.\n%%  \\end{block}\n%%\\end{frame}\n%\n%\\begin{frame}{Encoding of Existential Type in System F}\n%  The existential type can also be encoded in System F as \n%  \\[\n%    \\exists t.\\, \\tau \\defeq \\forall u.\\; (\\forall t.\\; \\tau \\to u) \\to u\n%  \\]\n%%  using continuation passing style.\\footnote{Recall that $\\exists x.\\,\\varphi\n%%  = (\\forall x.\\, (\\varphi \\to \\bot)) \\to \\bot$ classically.  }\n%\\mode<presentation>{\\vfill}\n%  A witeness $(\\sigma, M)$ of $\\exists t.\\, \\tau$ is encoded as\n%  \\[\n%    \\Lambda u.\\,\\lambda (f : \\forall t.\\, \\tau \\to u).\\, f\\;\\sigma\\;M\n%  \\]\n%\n%  \\begin{block}{Exercise}\n%    Check that the above terms do make sense. How to use a term of some existential\n%    type? \n%  \\end{block}\n%  \n%\\end{frame}\n\n\n\\begin{frame}{Type erasure}\n\\begin{definition}\n  The \\emph{erasing map} is a function defined by\n  \\begin{align*}\n    |x| & = x \\\\\n    |\\lambda (x : \\tau).\\,M| & = \\lambda x.\\, |M| \\\\\n    |M\\;N| & = (|M|\\;|N|) \\\\\n    |\\Lambda t.\\, M| & = |M| \\\\\n    |M\\;\\tau| & = |M|\n  \\end{align*}\n\\end{definition}\n\n\\begin{proposition}\n  Within System F, if ${}\\vdash M : \\sigma$ and $|M|\n  \\onereduce N'$, then there exists a well-typed term~$N$ with\n  ${}\\vdash N : \\sigma$ and $|N| = N'$.\n\\end{proposition}\n\\end{frame}\n\n\\begin{frame}{Type safety and normalisation}\n  \\begin{theorem}[Type safety]\n    Suppose $\\vdash M : \\sigma$. Then, \n    \\begin{enumerate}\n      \\item $M \\onereduce N$ implies $\\vdash N : \\sigma$; \n      \\item $M$ is in normal form or there exists $N$ such that $M \\onereduce N$\n    \\end{enumerate}\n  \\end{theorem}\n  Type safety is proved by induction on the derivation of $\\vdash M : \\sigma$.\n\n  \\begin{theorem}[Normalisation properties]\n    \\textbf{F} enjoys the weak and strong normalisation properties.\n  \\end{theorem}\n  Proved by Girard's \\emph{reducibility candidates}.\n\\end{frame}\n\n\\begin{frame}{Undecidability of type inference}\n  \\begin{theorem}\n     It is undecidable whether, given a closed term $M$ of the untyped\n     $lambda$-calculus, there is a well-typed term $M'$ in System F such that\n     $|M'| = M$.  \n  \\end{theorem}\n\n  \\begin{description}\n    \\item[Arbitrary Rank Polymorphism] $\\forall$ can appear\n      anywhere {\\small (GHC with \\texttt{-XRankNType})}. \n    \\item[Rank-1 Polymorphism]\n      $\\forall$ only appear in the outermost position.\n  \\end{description}\n  \\emph{Hindley-Milner type system} adapted by Haskell 98, Standard ML, etc.\n  supports only rank-1 polymorphism, so type inference is still decidable.\n\\end{frame}\n\n\\begin{frame}{Parametricity}\n  What functions can you write for the following type?\n  \\[\n    \\forall t.\\,t \\to t \n  \\]\n  Since $t$ is arbitrary, we cannot inspect the content of $t$. What we can do\n  with $t$ is simply return it.\n  \\begin{theorem}\n    Every term $M$ of type $\\forall t.\\, t \\to t$ is \\emph{observationally equivalent}%\n    \\footnote{The notion of observational equivalence is beyond the scope of this lecture.}\n      to $\\Lambda t.\\, \\lambda x : t.\\, x$. \n  \\end{theorem}\n\\end{frame}\n\n\\begin{frame}{Parametricity: Theorems for free\\footnote{Philip Wadler. 1989. Theorems for free! In \\emph{Proceedings of the fourth international conference on Functional programming languages and computer architecture (FPCA ’89)}. ACM, New York, NY, USA, 347–359.}}\n  Assume \\textbf{F} extended with the list type~$\\List\\;\\tau$ for $\\tau$ and\n  the type $\\mathbb{N}$ of naturals, denoted $\\mathbf{F}_{\\List, \\mathbb{N}}$.\n\n  Then $\\mathtt{head} \\circ \\mathtt{map}\\; f = f \\circ \\mathtt{head}$\n      for any $f : \\tau \\to \\sigma$ where $\\mathtt{head} : \\forall t.\\, \\List\\;t \\to t$\n  can be proved by just reading the type of $\\mathtt{head}$ and $\\mathtt{tail}$!\n  \\begin{theorem}\n    For any type $\\sigma$ in \\textbf{F} (with lists) and $\\cdot  \\vdash M : \\sigma$, then \n    \\[\n      M \\sim M : \\mathcal{R}_{\\sigma, \\sigma}\n    \\]\n  \\end{theorem}\n\\end{frame}\n\n%\\begin{frame}\n%  $M \\sim N : \\mathcal{R}_{\\sigma, \\tau}$ is defined as follows.\n%\n%  \\begin{enumerate}\n%    \\item $M \\sim M : \\mathcal{R}_{\\mathbb{N}, \\mathbb{N}}$ for every $M :\n%      \\mathbb{N}$.\n%\n%    \\item For any $\\mathcal{R}_{\\tau, \\sigma}$, \n%      \\[\n%        M_i \\sim N_i : \\mathcal{R}_{\\sigma, \\tau} \\; \\text{for any $M_i : \\sigma$ and $N_i : \\tau$}\n%        \\iff \n%        [ M_1, \\dots, M_k ] \\sim [ N_1, \\dots, N_k ] : \\mathcal{R}_{\\List\\;\\sigma, \\List\\;\\tau}\n%      \\]\n%\n%    \\item For any $\\mathcal{R}_{\\sigma, \\sigma'}$ and $\\mathcal{S}_{\\tau, \\tau'}$,\n%      $M \\sim M' : \\mathcal{R}_{\\sigma, \\sigma'} \\implies L\\; M\n%      \\sim L'\\;M' : \\mathcal{S}_{\\tau, \\tau'}$ for any $M$ and $M'$\n%      if and only if \n%      $L \\sim L' : \\mathcal{R}\\to\\mathcal{S}_{\\sigma \\to \\tau, \\sigma' \\to \\tau'}$\n%\n%    \\item Assume $\\mathcal{F}$ which sends $\\mathcal{R}_{\\sigma, \\tau}$ to\n%      $\\mathcal{F}\\mathcal{R}_{F\\sigma, F\\tau}$. Then\n%      $f\\;\\sigma \\sim g\\;\\tau : \\mathcal{F}\\mathcal{R}$ for all $\\mathcal{R}_{\\sigma, \\tau}$\n%      if and only if $f \\sim g : \\forall \\mathcal{X}_{t, u}.\\, {\\mathcal{F}\\mathcal{X}}_{Ft, Fu}$\n%  \\end{enumerate}\n%\\end{frame}\n\n%\\begin{frame}{System $F_\\omega$}\n%  Recall that for $\\sigma, \\tau \\in \\type$ the sum type of $\\sigma$ and $\\tau$\n%  is \n%  \\[\n%    \\sigma + \\tau \\defeq \\forall t. (\\sigma \\to t) \\to (\\tau \\to t) \\to t\n%  \\]\n%  Can we internalise this \\alert{type construction}? \n%  \\vfill\n%  \\alert{\\emph{Kinds}} are like \\emph{classes} in set theory:\n%  \\begin{enumerate}\n%    \\item $*$ : the kind of types \n%    \\item $* \\Rightarrow *$ : the kind of type operators, e.g., \n%      $a \\mapsto [a]$ \n%    \\item \\ldots \n%  \\end{enumerate}\n%  System $F_\\omega$ is an extension of System $F$ with type-level functions and\n%  kinds. See \\cite{Pierce2002} for further detail. \n%\\end{frame}\n%\n%\\begin{frame}[allowframebreaks]{Impredicativity}\n%  A definition is \\alert{\\emph{impredicative}} if it has a quantifier whose\n%  domain includes itself (which is being defined). \n%  \\begin{block}{Russell's Paradox}\n%    \\[\n%      R \\defeq \\set{x}{ x \\not\\in x }\n%    \\]\n%  \\end{block}\n%  Recall the self-application ...\n%  \\[\n%    (\\Lambda t.\\,\\lambda (x: t). x)\\;{\\color{red}(\\forall t.\\,t \\to t)}\\;\n%    (\\Lambda t.\\, \\lambda (x: t). x) \n%  \\]\n%  which is actually impredicative! \n%  This form of polymorphism is called \\alert{\\emph{impredicative polymorphism}}. \n%  \\begin{block}{Girard's Paradox}\n%    An encoding of Russell's paradox in extensions of\n%    System F. \n%  \\end{block}\n%\n%  Martin-L\\\"of's type theory (on which Agda is based) was inconsistent, as it\n%  included an axiom\\footnote{It is only a simplified story...}:\n%  \\[\n%    \\mathsf{Set} : \\mathsf{Set}\n%  \\]\n%\n%  \\begin{block}{Inconsistency of Haskell}\n%    Impredicativity $+$ Injectivity $+$ Type Case Analysis\n%    $=$ Inconsistency (Russell paradox)\n%    \\footnote{\\url{http://okmij.org/ftp/Haskell/impredicativity-bites.html}}\n%    \n%  \\end{block}\n%\\end{frame}\n%\\section{Parametricity}\n%Polymorphism in System F is \\emph{parametric} in the sense that every\n%instance is uniformly defined. To put it differently, it cannot depend on any\n%specific type. It is different from the \\emph{ad hoc} polymorphism adopted in\n%programming languages like C++ where programmers are allowed to give a\n%specific implementation for some type.\n%\n%Why is a uniform definition important? Not only we can assure ourselves that a\n%polymorphic function has a uniform result for each instance, but also it\n%automatically satisfies certain properties which only depends on its type (not\n%its instance).\n%\n%In the end of this lecture, we state a powerful result informally, originally\n%called \\emph{Abstraction Theorem} by Reynolds~\\cite{Reynolds1983} and nowadays\n%known as \\emph{parametricity}. After that, we apply this theorem to characterise\n%some data types introduced so far.\n%\n%\\begin{proposition}\n%  Let $\\sigma$ be a type without any free variable and $\\sigma^+$ the relation\n%  on~$\\sigma$ lifted from~$\\sigma$ (defined below). Then, \n%  \\[\n%    \\vdash F : \\sigma\n%    \\implies (F, F) \\in \\sigma^+.\n%  \\]\n%\\end{proposition}\n%\n%To decode this proposition, we introduce a new notation: a relation $R_\\sigma\n%\\subset \\sigma_1 \\times \\sigma_2$ is denoted by $R_\\sigma\\colon \\sigma_1\n%\\not\\to\\sigma_2$. For each type in System F, we define its lifted relation\n%$\\sigma^+$\n%\\begin{definition}\n%  For each type formation (construct), we define its corresponding formation of\n%  relations \n%  \\begin{enumerate}\n%    \\item For $f_i:\\sigma_i \\to \\tau_i$, $(f_1, f_2) \\in R_\\sigma \\to S_\\tau$ if\n%      and only if for every $(M_1, M_2) \\in R_\\Sigma$ we have $(f_1\\;M_1,\n%      f_2\\;M_2) \\in S_\\tau$.\n%  \\end{enumerate}\n%\\end{definition}\n%\n%\n%\n%\\subsection*{Exercise}\n\n\\begin{frame}{Homework}\n  \\begin{enumerate}\n    \\item (25\\%) Extend {\\PCF} with the type $\\mathbb{B}$ of boolean values with\n      $\\mathtt{ifz}(M; N)\\;\\true =_\\beta M$ and $\\mathtt{ifz}(M; N)\\;\\false\n      =_\\beta N$ including term formation rules, typing rules, and dynamics for\n      $\\mathbb{B}$.\n\n    \\item (25\\%) Define \\textbf{pred} in {\\textbf{T}} such that $\\pred\\;\\zero =\\zero$\n      and $\\pred\\;(\\suc\\;n) = n$.\n\n    \\item (25\\%) Define \\textbf{even} in {\\PCF} such that $\\mathbf{even}\\;n =\n      \\suc\\;\\zero$ if $n$ is an even number; $\\mathbf{even}\\;n = \\zero$\n      otherwise. \n\n    \\item (25\\%) Define $\\mathtt{length}_\\sigma : \\List\\;\\sigma \\to \\nat$ calculating the length of a list.\n    \\item (0\\%) Read the paper by Wadler (1989).\n    \n  \\end{enumerate}\n  \n\\end{frame}\n\n%\\begin{frame}{References}\n%\\bibliographystyle{amsalpha}\n%\\bibliography{library} \n%\\end{frame}\n\n\\end{document}\n", "meta": {"hexsha": "17e191702fe9617c06dd5a780ed8e3699c75334d", "size": 35516, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/lecture3.tex", "max_stars_repo_name": "L-TChen/Type-Theory", "max_stars_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2018-06-11T04:47:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T12:16:55.000Z", "max_issues_repo_path": "tex/lecture3.tex", "max_issues_repo_name": "xcycl/FLOLAC16-Lambda", "max_issues_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-06-14T20:57:59.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-15T10:10:37.000Z", "max_forks_repo_path": "tex/lecture3.tex", "max_forks_repo_name": "L-TChen/Type-Theory", "max_forks_repo_head_hexsha": "58da4f5851b4257dc858d0ee4329ea44997880d2", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-09T02:37:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-15T05:34:52.000Z", "avg_line_length": 32.9156626506, "max_line_length": 265, "alphanum_fraction": 0.5977306003, "num_tokens": 12841, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4013498178503709}}
{"text": "\\documentclass[9pt, a4paper, oneside]{amsart}\n\n\\usepackage[final]{pdfpages}\n\\usepackage{wrapfig}\n\n\\usepackage{enumitem}\n\\usepackage{parskip}\n\\usepackage{fancyhdr}\n\\usepackage{color}\n\\usepackage{multicol}\n\\renewcommand{\\thefootnote}{\\fnsymbol{footnote}}\n\n\n\\newcommand{\\hint}[1]{\\footnote{\\raggedleft\\rotatebox{180}{Hint: #1\\hfill}}}\n\n\\pagestyle{fancy}\n\n\\newlist{questions}{enumerate}{1}\n\\setlist[questions, 1]{label = \\bf Q.\\arabic*., itemsep=1em}\n\n\\lhead{\\scshape Apurva Nakade}\n\\rhead{\\scshape Honors Single Variable Calculus}\n\\renewcommand*{\\thepage}{\\small\\arabic{page}}\n\\title{Problem Set 08}\n\n\\begin{document}\n\n\\maketitle\n\\thispagestyle{fancy}\n\n\n\\section*{Part 1 - Fundamental Theorem of Calculus}\n\\begin{questions}\n\t\\item  Compute $ F'(x)$ for the following functions\\hint{Don't forget the chain rule!}\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}\n\t\t\t\\item $ \\int \\limits_ a ^{x^3} \\sin^3 t dt$\n\t\t\t\\item $ \\int \\limits_ x ^{b} \\dfrac{1}{1 + t^2 + \\sin^2 t} dt$\n\t\t\t\\item $ \\int \\limits_ a ^{b} \\dfrac{x}{1 + t^2 + \\sin^2 t} dt$\n\t\t\t\\item $ \\int \\limits_ a ^{x} \\left( \\int \\limits_ b ^{y} \\dfrac{1}{1 + t^2 + \\sin^2 t} dt \\right) dy\\qquad$\n\t\t\t\\item $ \\int \\limits _ 0 ^ x \\dfrac{1}{1+t^2} dt + \\int \\limits _ 0 ^ {1/x} \\dfrac{1}{1+t^2} dt$\n\t\t\t\\item $ \\int \\limits _ {-\\cos x}^ {\\sin x} \\dfrac{1}{\\sqrt{1 - t^2}} dt $\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\t\\item Find $ (f^{-1})'(0)$ if\n\t\\begin{multicols}{2}\n\t\t\\begin{enumerate}\n\t\t\t\\item $ f(x) = \\int \\limits _ 0 ^ x 1 + \\sin (\\sin t) dt$\n\t\t\t\\item $ f(x) = \\int \\limits _ 1 ^ x \\cos (\\cos t) dt$\n\t\t\\end{enumerate}\n\t\\end{multicols}\n\n\t\\item Suppose $ f$ is differentiable with $ f(0) = 0$ and $ 0 < f'(x) \\le 1$. Show that for all $ x \\ge 0$\n\t\\begin{align*}\n\t\t\\int _0 ^ x f^3 \\le \\left ( \\int_0^x f\\right)^2\n\t\\end{align*}\n\n\t\\item \\begin{enumerate}\n\t\\item Find $ F'(x)$ if $ \\quad F(x) = \\int \\limits_0^x x.f(t) dt \\qquad$(Be careful: it's not $ x.f(x)$).\n\t\\item Prove that\\hint{Differentiate both sides with respect to $ x$.}\n\t\\begin{align*}\n\t\t\\int _0^x f(t)(x - t) dt & = \\int_0^x \\left(\\int_0^u f(t) dt\\right) du\n\t\\end{align*}\n\t\\item Prove that\n\t\\begin{align*}\n\t\t\\int _0^x f(t)(x - t)^2 dt & = 2\\int_0^x \\left(\\int_0^{u_1} \\left(\\int_0^{u_2} f(t) dt\\right) du_2\\right) du_1\n\t\\end{align*}\n\t\\end{enumerate}\n\n\t\\item\n\t\\begin{enumerate}\n\t\t\\item Suppose $ G'(x)=g(x)$ and $ F'(x)=f(x)$. Prove that the function $ y(x)$ satisfies the differential equation (\\emph{a separable differential equation}) $$ g(y).y' = f(x)$$ for all $ x$ in some interval, if and only if there is a number $ c$ such that $$ G(y) = F(x) + c$$\n\t\t\\item `Solve' the following differential equations\n\t\t      \\begin{multicols}{2}\n\t\t      \t\\begin{enumerate}\n\t\t      \t\t\\item $ y' = \\dfrac{1 + x^2}{1+y}$\n\t\t      \t\t\\item $ y' = \\dfrac{-1}{1+5y^4}$\n\t\t      \t\\end{enumerate}\n\t\t      \\end{multicols}\n\t\\end{enumerate}\n\\end{questions}\n\n\n\n\n\n\n\n\n\\newpage\n\\section*{Part 2 - Improper Integrals}\n\\begin{questions}[resume]\n\t\\item The limit $ \\lim \\limits_{x \\rightarrow \\infty} \\int \\limits_{a}^x f$, if it exists, is denoted by $\\int \\limits_{a}^ \\infty f $ and called an `improper integral'. Similarly for the improper integral $\\int \\limits_{-\\infty}^ a f $.\n\t\\begin{enumerate}\n\t\t\\item Find $\\int \\limits_{1}^\\infty t^r dt$, when $ r < -1$.\n\t\t\\item Using $\\int \\limits_{1}^a t^{-1} \\: dt + \\int \\limits_{1}^b t^{-1}  \\: dt = \\int \\limits_{1}^{ab} t^{-1}  \\: dt $, show that $\\int \\limits_{1}^\\infty t^{-1}  \\: dt$ does not exist. \\hint{What can you say about $\\int \\limits_{1}^{2^n} t^{-1}  \\: dt$?}\n\t\\end{enumerate}\n\n\t\\item Assume the following the statement:\n\t\\begin{quote}\n\t\tSuppose that $ f(x) \\ge 0$ for $ x \\ge 0$ and that $\\int \\limits_{a}^ \\infty f $ exists. If $ 0 \\le g(x) \\le f(x)$ for all $ x \\ge 0$ and $ g$ is integrable on the interval $ [0,N]$ for all $ N > 0$ then $\\int \\limits_{0}^ \\infty g $ exists.\n\t\\end{quote}\n\t\\renewcommand\\labelitemi{$\\vcenter{\\hbox{\\tiny$\\bullet$}}$}\n\t\\begin{itemize}\n\t\t\\item (Optional) Prove the above statement.\n\t\t\\item For which of the following functions does the integral $\\int \\limits_{0}^ \\infty f $ exist?\\hint{You might have to break $ [0,\\infty)$ into multiple intervals and analyze each interval separately.}\n\t\t\t      \\begin{multicols}{2}\n\t\t\t      \t\\begin{enumerate}\n\t\t\t      \t\t\\item $ \\dfrac{1}{1+x^2}$\n\t\t\t      \t\t\\item $ \\dfrac{1}{\\sqrt{1+x^{3}}}$\n\t\t\t      \t\t\\item $ \\dfrac{x}{{1+x^{3/2}}}$\n\t\t\t      \t\t\\item $ \\dfrac{1}{\\sqrt{1+x}}$\n\t\t\t      \t\\end{enumerate}\n\t\t\t      \\end{multicols}\n\t\t\\end{itemize}\n\n\t\t\\item The improper integral $\\int \\limits_{-\\infty}^ {\\infty} f $ is defined as $\\int \\limits_{-\\infty}^ 0 f + \\int \\limits_{0}^ \\infty f $ if both the integrals exist.\n\t\t\\begin{enumerate}\n\t\t\t\\item Show that $ \\int \\limits_{-\\infty}^ {\\infty} \\dfrac{1}{1+x^2} dx$ exists.\n\t\t\t\\item Determine the limit $ \\lim \\limits_{N \\rightarrow \\infty} \\int \\limits_{-N}^ {N} x \\: dx$.\n\t\t\t\\item Show that $ \\int \\limits_{-\\infty}^ {\\infty} x \\: dx$ does not exist.\n\t\t\\end{enumerate}\n\n\t\t\\item It is possible to have another kind of improper integral, one where the function itself is unbounded but the limits are finite.\n\n\t\tFor $ -1 < r < 0$ draw the graph of $ x^r $ and determine $ \\lim \\limits_{\\epsilon \\rightarrow 0^+} \\int \\limits_\\epsilon^a x^r dx$. \\\\(This limit is written as $\\int \\limits_0^a x^r dx$.)\n\t\\end{questions}\n\n\n\n\n\n\n\n\n\\end{document}\n", "meta": {"hexsha": "248b44dce8bbf6209a83f281aa62266aa824511d", "size": 5299, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2017/PSet08.tex", "max_stars_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_stars_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2017/PSet08.tex", "max_issues_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_issues_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2017/PSet08.tex", "max_forks_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_forks_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3985507246, "max_line_length": 279, "alphanum_fraction": 0.6199282884, "num_tokens": 2039, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4013179750112387}}
{"text": "\\documentclass[../report/main.tex]{subfiles}\n \n\\begin{document}\n\n% The asterix after \\subsection disables section numbering\n\\subsection*{Algorithm Description}\n\nThe 2-opt algorithm is a simple local search algorithm that has application to solve the Traveling Salesman Problem. The main idea behind it is to take a route that crosses over itself and reorder that route so that it no longer overlaps. We first encountered K-optimal tours in ~\\cite{skiena2008} and learned more through it's Wikipedia article ~\\cite{wikipedia2opt} .  This is the only algorithm which we implemented in C.  We chose C over Python for the speed improvement.\n\n\\subsection*{Algorithm Discussion}\n\nWe decided on this algorithm because it was easy to implement conceptually, it's fairly fast, and it provides the most optimum tour lengths of any algorithm we implemented. Also the algorithm is relatively efficient to compute the path improvement for a given path swap which provides for a favorable runtime. The other algorithms we wrote up were constructive while 2-OPT is a local search heuristic meaning it improves on an exisiting path.  Because 2-OPT is a local search heuristic it needs to be combined with an efficient constructive algorithm which we choose nearest neighbor.  For the three example cases 2-opt found routes between 4\\% and 6\\% over optimal.\n\n\\subsection*{Algorithm Pseudo-code}\n\n\\begin{verbatim}\nTSP_2OPT_SEARCH(adj_matrix, tour, tour_length, file_name, num_pts):\n    improved = true\n    old_tour_length = tour_length\n\n    while improved:\n        improved = false\n        exit_early = false\n\n        for i = 1 to num_pts - 1 and not exit_early:\n            for j = i + 1 to num_pts - 1 and not exit_early:\n                old_tour_length = tour_length\n                TSP_2OPT_SWAP_EFFICIENT(adj_matrix, tour, tour_length, num_pts, i, j)\n                if tour_length < old_tour_length:\n                    improved = true\n                    exit_early = true\n\n                    write the improved tour to file\n\nTSP_2OPT_SWAP(new_tour, tour, num_pts, nodeA, nodeB):\n    min_node = MIN(nodeA, nodeB)\n    max_node = MAX(nodeA, nodeB)\n    new_tour_idx = 0\n\n    for i = 0 to min_node:\n        new_tour[new_tour_idx] = tour[i]\n        new_tour_idx++\n\n    for i = max_node to min_node:\n        new_tour[new_tour_idx] = tour[i]\n        new_tour_idx++\n\n    for i = max_node + 1 to num_pts:\n        new_tour[new_tour_idx] = tour[i]\n        new_tour_idx++\n\nTSP_2OPT_SWAP_EFFICIENT(adj_matrix, tour, tour_length, num_pts, nodeA, nodeB):\n    min_node = MIN(nodeA, nodeB)\n    max_node = MAX(nodeA, nodeB)\n    new_tour_idx = 0\n\n    removed_path_length = 0\n    added_path_length = 0\n\n    new_tour[num_pts]\n\n    if max_node + 1 < num_pts:\n        removed_path_length = adj_matrix[tour[min_node - 1]][tour[min_node]] + \n            adj_matrix[tour[max_node]][tour[max_node + 1]]\n        added_path_length = adj_matrix[tour[min_node - 1]][tour[max_node]] + \n            adj_matrix[tour[min_node]][tour[max_node + 1]]\n    else:\n        removed_path_length = adj_matrix[tour[min_node-1]][tour[min_node]] + \n        adj_matrix[tour[max_node]][tour[0]];\n\n        added_path_length = adj_matrix[tour[min_node-1]][tour[max_node]] + \n        adj_matrix[tour[min_node]][tour[0]];\n\n    path_delta = removed_path_length - added_path_length\n\n    if path_delta > 0:\n        for i = 0 to min_node - 1:\n            new_tour[new_tour_idx] = tour[i]\n            new_tour_idx++\n\n        for i = max_node to min_node:\n            new_tour[new_tour_idx] = tour[i]\n            new_tour_idx++\n\n        for i = max_node + 1 to num_pts - 1:\n            new_tour[new_tour_idx] = tour[i]\n            new_tour_idx++\n\n        tour_length -= path_delta\n\\end{verbatim}\n\n\\end{document}", "meta": {"hexsha": "69dc847045a81b9212a521a8d8ded4cbca0b46cd", "size": 3741, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Alg02_2OPT/alg02.tex", "max_stars_repo_name": "OSU-CS-325/Project_Four_TSP", "max_stars_repo_head_hexsha": "c88e496b755fa5dfc3220f68a3daa3eba2e57e2e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Alg02_2OPT/alg02.tex", "max_issues_repo_name": "OSU-CS-325/Project_Four_TSP", "max_issues_repo_head_hexsha": "c88e496b755fa5dfc3220f68a3daa3eba2e57e2e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Alg02_2OPT/alg02.tex", "max_forks_repo_name": "OSU-CS-325/Project_Four_TSP", "max_forks_repo_head_hexsha": "c88e496b755fa5dfc3220f68a3daa3eba2e57e2e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.6630434783, "max_line_length": 666, "alphanum_fraction": 0.6824378508, "num_tokens": 955, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.4013179715310472}}
{"text": "\\chapter{Fortran Programs}\n\n%%%%%%%\n%  Section\n%%%%%%%\n\\section{Example Programs}\n\nTo do parallel programming using OpenMP or MPI (Message passing interface), we typically need to use a lower level language than Matlab such as Fortran. Another possible choice of language is C, however Fortran has superior array handling capabilities compared to C, and has a similar syntax to Matlab, so is typically easier to use for scientific computations which make heavy use of regular arrays. It is therefore useful to introduce a few simple programs in Fortran before we begin studying how to create parallel programs. A good recent reference on Fortran is Metcalf, Reid and Cohen~\\cite{MetReiCoh11}.  We recognize that most people will be unfamiliar with Fortran and probably more familiar with Matlab\\footnote{Although Matlab is written in C, it was originally written in Fortran and so has a similar style to Fortran.}, C or C++, but we expect that the example codes will make it easy for anyone with some introductory programming background.   A recent guide which describes how to write efficient parallel Fortran code is Levesque and Wagenbreth\\cite{LevWag11}. Our programs are written to be run on the Flux cluster at the University of Michigan. More information on this cluster can be found at \\url{http://cac.engin.umich.edu/resources/systems/flux/} and at \\url{http://cac.engin.umich.edu/started/index.html}. Below are four files you will need to run this.\n\n\\begin{enumerate}\n\\item[1)] A makefile to compile the Fortran code on Flux in listing \\ref{lst:MakefileHeat}. This should be saved as {\\it makefile}. Before using the makefile to compile the code, you will need to type\\\\\n\\texttt{module load fftw/3.2.1-intel}\\\\\nat the command line prompt once logged into Flux. Then place the makefile and heat.f90 in the same directory, the example files below assume this directory is\\\\\n\\texttt{\\${HOME}/ParallelMethods/Heat}\\\\\n and type\\\\\n\\texttt{make}\\\\\nto compile the file. Once the file is compiled type\\\\\n\\texttt{qsub fluxsubscript}\\\\\nto get the cluster to run your program and then output the results. The programs that follow use the library FFTW to do the fast Fourier Transforms. More information on this library can be found at \\url{http://www.fftw.org/}.\n\n\\lstinputlisting[style=make_style,language=make,label=lst:MakefileHeat,caption={An example makefile for compiling a Fourier spectral Fortran heat equation program.}]{./FortranPrograms/Programs/FortranHeatEquation/makefile}\n\n\\item[2)] The Fortran program in listing \\ref{lst:FortranHeat} -- this should be saved as {\\it heat.f90}\n\\lstinputlisting[style=fortran_style,language=Fortran,label=lst:FortranHeat,caption={A Fortran Fourier spectral program to solve the heat equation using backward Euler timestepping.}]{./FortranPrograms/Programs/FortranHeatEquation/heat.f90}\n\n\\item[3]) An example submission script to use on the cluster in Listing \\ref{lst:Fluxsubheat} -- this should be saved as {\\it fluxsubscript}. More examples can be found at \\url{http://cac.engin.umich.edu/resources/software/pbs.html}. To use it, please change the email address from \\url{your_uniqname@umich.edu} to an email address at which you can receive notifications of when jobs start and are finished. \n\n\\lstinputlisting[style=bash_style,language=bash,label=lst:Fluxsubheat,caption={An example submission script for use on Flux.}]{./FortranPrograms/Programs/FortranHeatEquation/fluxsubscript}\n\n\\item[4)] A Matlab plotting script\\footnote{For many computational problems, one can visualize the results with 10-100 times less computational power than was needed to generate the results, so for problems which are not too large, it is much easier to use a high level language like Matlab to post-process the data.} to generate Fig.\\ \\ref{fig:FortranHeat} is in listing \\ref{lst:PlotMatlab}.\n\n\\lstinputlisting[style=matlab_style,label=lst:PlotMatlab,caption={A Matlab program to plot the computed results.}]{./FortranPrograms/Programs/FortranHeatEquation/plotcreate.m}\n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[scale=.35]{./FortranPrograms/heatPlot.jpg}\n\\caption{The solution to the heat equation computed by Fortran and post-processed by Matlab.} \\label{fig:FortranHeat}\n\\end{center}\n\\end{figure}\n\n\\end{enumerate}\n\n\n%%%%%%%\n%  Section\n%%%%%%%\n\\section{Exercises}\n\\begin{enumerate}\n\\item[1)] Please read the resources on the web page \\url{http://cac.engin.umich.edu/started/index.html} to learn how to use the Flux cluster.\n\\item[2)] Modify the Fortran program for the 1-D heat equation to solve the Allen-Cahn equation, with your choice of time stepping scheme. Create a plot of the output of your run. Include the source code and plot in your solutions.\n\\item[3)] Modify the Fortran program for the 1-D heat equation to solve the  2-D heat equation with your choice of time stepping scheme. Your program should save the field at each time step rather than putting all the fields in a single large array. Create a plot of the initial and final states of your run. Include the source code and plots in your solutions.\n\\end{enumerate}\n\n", "meta": {"hexsha": "2582f7941f28894bd4b1a33ed4869c6cdf3da03c", "size": 5076, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FortranPrograms/FortranPrograms.tex", "max_stars_repo_name": "bcloutier/PSNM", "max_stars_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_stars_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2015-01-05T14:22:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T23:51:25.000Z", "max_issues_repo_path": "FortranPrograms/FortranPrograms.tex", "max_issues_repo_name": "bcloutier/PSNM", "max_issues_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_issues_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-12-29T12:35:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-01T07:31:32.000Z", "max_forks_repo_path": "FortranPrograms/FortranPrograms.tex", "max_forks_repo_name": "bcloutier/PSNM", "max_forks_repo_head_hexsha": "1cd03f87f93ca6cb1a3cfbe73e8bc6106f497ddf", "max_forks_repo_licenses": ["CC-BY-3.0", "BSD-2-Clause"], "max_forks_count": 34, "max_forks_repo_forks_event_min_datetime": "2015-01-05T14:23:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T06:55:01.000Z", "avg_line_length": 94.0, "max_line_length": 1375, "alphanum_fraction": 0.7878250591, "num_tokens": 1257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4013179646302218}}
{"text": "%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"program-analysis\"\n%%% End:\n\n\\chapter{Prerequisites}\n\\begin{chapquote}{H.G. Rice [1953], \\textit{paraphrased by Anders Moller}}\n  ``Everything interesting about the behaviour of programs is\n  undecidable.''\n\\end{chapquote}\n\nThe goal of \\textit{static program analysis} is to verify certain\n\\textsl{properties} (or \\textsl{behaviours}, or\n\\textsl{specifications}, or \\textsl{statements}, ...) of the target\nprogram \\textbf{without its execution}.\n\nFor program \\textsl{P} and property \\textsl{S},\n\n\\begin{itemize}\n\\item $ \\SEM{P} $: Formal semantics of program \\textsl{P}.\n\n\\item \\textsl{S}: Semantic properties that we're interested in. This\n  could be defined in various level, such as ``Division-by-zero will\n  \\textbf{never} occur'' or ``The variable \\textit{i} is always 3''.\n\n\\item Soundness: $ analysis(P) = true \\implies S $\n\n\\item Completeness: $ S \\implies analysis(P) = true $\n\n\\item Scalability: Time complexity.\n\\end{itemize}\n\n\n\\textbf{No analysis} can be sound and complete at the same time. If an\nanalysis is sound, then it is also incomplete, and vice versa.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newpage\n\\section{Relation Theory}\nThis note originates from\nProofwiki\\footnote{https://proofwiki.org}.\n\n\\subsection{Relation}\n\nLet $S \\times T$ be the Cartesian product of two sets $S$ and $T$.A\n\\textbf{relation} on $S \\times T$ is an ordered triple\n$ \\mathcal{R} = (S, T, R) $ where $R \\subseteq S \\times T$ is a subset\nof the Cartesian product of $S$ and $T$.\n\nWhat this means is that a \\textbf{relation} \\textit{relates} (certain)\nelements of one set or class $S$ with (certain) elements of another,\n$T$. Not all elements of $S$ need to be related to every (or even any)\nelement of $T$.\n\n\\paragraph{Notation}\n\nIf $(x, y)$ is an ordered pair such that $(x, y) \\in \\mathcal{R}$, we\nuse the notation: $ s \\mathcal{R} t$ or $ \\mathcal{R}(s, t)$ and can\nsay:\n\\begin{itemize}\n\\item $s$ \\textbf{bears} $\\mathcal{R}$ to $t$\n\\item $s$ \\textbf{stands in} the relation $\\mathcal{R}$ to $t$\n\\end{itemize}\n\n\\paragraph{General Definition}\n\nLet\n$\\mathbb{S} = \\displaystyle \\prod_{i=1}^n S_i = S_1 \\times S_2 \\times ... \\times S_n $\nbe the Cartesian product on $n$ sets $S_1, ..., S_n$.\n\nAn \\textbf{$n$-ary relation on} $\\mathbb{S}$ is an ordered\n$n+1$-tuple $\\mathcal{R}$ defined as\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathcal{R} := (S_1, S_2, ..., S_n, R)\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nwhere $\\mathcal{R}$ is an arbitrary subset\n$\\mathcal{R} \\subseteq \\mathbb{S}$.\n\nTo indicate that $(s_1, s_2, ..., s_n) \\in R$, we write:\n$\\mathcal{R}(s_1, s_2, ..., s_n)$\n\n\n\\paragraph{Unary Relation}\n\nAs a special case of an $n$-ary relation on $S$, note that when $n=1$\nwe define a \\textbf{unary relation} on $S$ as\n$\\mathcal{R} \\subseteq S$. That is, a \\textbf{unary relation} is a\nsubset of $S$.\n\n\n\n\\subsection{Domain}\n\\label{sec:domain}\n\nLet $\\mathcal{R} \\subseteq S \\times T$ be a relation. The\n\\textbf{domain} of $\\mathcal{R}$ is defined and denoted as:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Dom}(\\mathcal{R}) := \\{ s \\in S: \\exists t \\in T: (s, t) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\paragraph{General Definition}\n\nLet $\\displaystyle \\prod_{i=1}^n S_i$ be the Cartesian product of sets\n$S_1$ to $S_n$. Let\n$\\mathcal{R} \\subseteq \\displaystyle \\prod_{i=1}^n S_i$ be an $n$-ary\nrelation on $\\displaystyle \\prod_{i=1}^n S_i$.\n\nThe \\textbf{domain of $\\mathcal{R}$} is the set defined as:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Dom}(\\mathcal{R}) := \\{ (s_1, s_2, ..., s_{n-1}) \\in \\displaystyle \\prod_{i=1}^{n-1} S_i : \\exists s_n \\in S_n : (s_1, s_2, ..., s_n) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThe concept is usually encountered when $\\mathcal{R}$ is an\nendorelation on $S$:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Dom}(\\mathcal{R}) := \\{ (s_1, s_2, ..., s_{n-1}) \\in S^{n-1} : \\exists s_n \\in S : (s_1, s_2, ..., s_n) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Codomain}\n\\label{sec:codomain}\n\nThe \\textbf{codomain} of a relation $\\mathcal{R} \\subseteq S \\times T$\nis the set $T$. It can be denoted as $\\mathtt{Cdm}(\\mathcal{R})$.\n\n\n\\subsection{Image}\n\\label{sec:image}\n\nLet $\\mathcal{R} \\subseteq S \\times T$ be a relation. The\n\\textbf{image} of $\\mathcal{R}$ is the set:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Img}(\\mathcal{R}) := \\mathcal{R}[S] = \\{ t \\in T: \\exists s \\in S: (s, t) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\paragraph{General Definition}\n\nLet $\\displaystyle \\prod_{i=1}^n S_i$ be the Cartesian product of sets\n$S_1$ to $S_n$. Let\n$\\mathcal{R} \\subseteq \\displaystyle \\prod_{i=1}^n S_i$ be an $n$-ary\nrelation on $\\displaystyle \\prod_{i=1}^n S_i$.\n\nThe \\textbf{image of $\\mathcal{R}$} is the set defined as:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Img}(\\mathcal{R}) := \\{ s_n \\in S_n: \\exists (s_1, s_2, ..., s_{n-1} \\in \\displaystyle \\prod_{i=1}^{n-1} S_i: (s_1, s_2, ..., s_n) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThe concept is usually encountered when $\\mathcal{R}$ is an\nendorelation on $S$:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{Img}(\\mathcal{R}) := \\{ s_n \\in S: \\exists (s_1, s_2, ..., s_{n-1}) \\in S^{n-1}: (s_1, s_2, ..., s_n) \\in \\mathcal{R} \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Endorelation}\n\\label{sec:endorelation}\nLet $S \\times S$ be the Cartesian product of a set or class $S$ with\nitself. Let $\\mathcal{R}$ be a \\textbf{relation} on $S \\times S$. Then\n$\\mathcal{R}$ is referred to as an \\textbf{endorelation on} $S$.\n\n\nThe term \\textbf{endorelation} is rarely seen. Once it is established\nthat the \\textit{domain} and \\textit{codomain} of a given relation are\nthe \\textbf{same set}, further comment is rarely needed.\n\n\nAn \\textbf{endorelation} is also called a \\textbf{relation in} $S$, or\na \\textbf{relation on} $S$. The latter term is discouraged, though,\nbecause it can also mean a left-total relation, and confusion can\narise.\n\nSome sources use the term \\textbf{binary relation} exclusively to\nrefer to a \\textbf{binary endorelation}.\n\n\n\\subsection{Many-to-One Relation}\n\\label{sec:many-to-one}\n\nA relation $\\mathcal{R} \\subseteq S \\times T$ is \\textbf{many-to-one}\nif and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in \\mathtt{Dom}(\\mathcal{R}): \\forall y_1, y_2 \\in \\mathtt{Cdm}(\\mathcal{R}): (x, y_1) \\in \\mathcal{R} \\land (x, y_2) \\in \\mathcal{R} \\implies y_1 = y_2 \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, every element of the domain of $\\mathcal{R}$ relates to no\nmore than one element of its codomain.\n\n\\subsection{One-to-Many Relation}\n\\label{sec:one-to-many}\n\nA relation $\\mathcal{R} \\subseteq S \\times T$ is \\textbf{one-to-many}\nif and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall y \\in \\mathtt{Img}(\\mathcal{R}): (x_1, y) \\in \\mathcal{R} \\land (x_2, y) \\in \\mathcal{R} \\implies x_1 = x_2 \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, every element of the image of $\\mathcal{R}$ relates to by\nexactly one element of its domain. Note that the condition concerns\nthe elements in the \\textit{image}, not the\n\\textit{codomain}\\footnote{Thus, a one-to-many relation may leave some\n  element(s) of the codomain unrelated}.\n\nAlso called as \\textit{injective relation}\\ref{sec:injection}.\n\n\\subsection{One-to-One Relation}\n\\label{sec:one-to-one}\n\nA relation $\\mathcal{R} \\subseteq S \\times T$ is \\textbf{one-to-one}\nif it is both many-to-one and one-to-many. That is, every element of\nthe domain of $\\mathcal{R}$ relates to no more than one element of its\ncodomain, and every element of the image is related to by exactly one\nelement of its domain.\n\n\n\\subsection{Left-Total Relation}\n\\label{sec:left-total}\n\nLet $S$ and $T$ be sets, and $\\mathcal{R} \\subseteq S \\times T$ be a\nrelation in $S$ to $T$. Then $\\mathcal{R}$ is \\textbf{left-total} if\nand only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall s \\in S: \\exists t \\in T: (s, t) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, if and only if every element of $S$ relates to some element\nof $T$, i.e., the domain of $\\mathcal{R}$ equals to $S$.\n\n\n\\subsection{Right-Total Relation}\n\\label{sec:right-total}\n\nLet $S$ and $T$ be sets, and $\\mathcal{R} \\subseteq S \\times T$ be a\nrelation in $S$ to $T$. Then $\\mathcal{R}$ is \\textbf{right-total} if\nand only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall t \\in T: \\exists s \\in S: (s, t) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, if and only if every element of $T$ relates to by some\nelement of $S$, i.e., the image of $\\mathcal{R}$ equals to $T$.\n\n\n\\subsection{Mapping}\n\\label{sec:mapping}\n\nLet $S$ and $T$ be sets, and $S \\times T$ be their Cartesian product.\n\n\n\\paragraph{Definition 1}\n\nA \\textbf{mapping} from $S$ to $T$ is a binary relation on\n$S \\times T$ which associates each element of $S$ with exactly one\nelement of $T$.\n\n\\paragraph{Definition 2}\n\nA \\textbf{mapping $f$ from $S$ to $T$}, denoted $f: S \\to T$, is a\nrelation $f = (S, T, G)$ where $G \\subseteq S \\times T$ such that:\n\n\\begin{math}\n  \\begin{array}{l}\n    \\\\\n    \\forall x \\in S: \\forall y_1, y_2 \\in T: (x, y_1) \\in G \\land (x, y_2) \\in G \\implies y_1 = y_2 \\\\\n    \\text{and} \\\\\n    \\forall x \\in S: \\exists y in T: (x, y) \\in G \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\paragraph{Definition 3}\n\nA \\textbf{mapping $f$ from $S$ to $T$}, denoted $f: S \\to T$, is a\nrelation $f = (S, T, R)$ where $R \\subseteq S \\times T$ such that:\n\n\\begin{math}\n  \\begin{array}{l}\n    \\\\\n    \\forall (x_1, y_1), (x_2, y_2) \\in \\mathcal{R}: y_1 \\neq y_2 \\implies x_1, x_2 \\\\\n    \\text{and} \\\\\n    \\forall x \\in S: \\exists y \\in T: (x, y) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\paragraph{Definition 4}\n\nA \\textbf{mapping from $S$ to $T$} is a relation on $S \\times T$ which is:\n\n\\begin{itemize}\n\\item Many-to-one\n\\item Left-total, that is, defined for all elements in $S$\n\\end{itemize}\n\n\\paragraph{Self-Map}\n\\label{sec:self-map}\n\nLet $S$ be a set. A \\textbf{self-map on $S$} is a \\textbf{mapping}\nfrom $S$ to itself: $f: S \\to S$.\n\n\\paragraph{Defined}\n\\label{sec:defined}\n\nA mapping $f \\subseteq S \\times T$ is \\textbf{defined} at $x \\in S$ if\nand only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\exists y \\in T: (x, y) \\in f\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nIf for some $x \\in S$, one has:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall y \\in T: (x, y) \\notin f\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nthen $f$ is \\textbf{not defined} or \\textbf{undefined} at $x$, and\nindeed, $f$ is not technically a mapping at all.\n\n\n\\subsection{Injection}\n\\label{sec:injection}\n\nA mapping $f$ is an \\textbf{injection} or \\textbf{injective} if and\nonly if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x_1, x_2 \\in \\mathtt{Dom}(f): f(x_1) = f(x_2) \\implies x_1 = x_2 \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, an injection is a mapping such that the output\n\\textit{uniquely determines} its input.\n\n\\subsection{Surjection}\n\\label{sec:surjection}\n\nLet $S$ and $T$ be sets and $f : S \\to T$ be a mapping from $S$ to\n$T$. $f$ is a \\textbf{subjection} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall y \\in T: \\exists x \\in \\mathtt{Dom}(f) : f(x) = y\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, if and only if $f$ is right-total.\n\nAlso called as \\textbf{onto mapping}, or just \\textbf{onto}\\footnote{A\n  mapping which is not surjective is hence described as \\textbf{into}}.\n\n\n\\subsection{Bijection}\n\\label{sec:bijection}\n\nA mapping $f: S \\to T$ is a \\textbf{bijection} if and only if both\n\\begin{itemize}\n\\item $f$ is an injection\n\\item $f$ is a surjection\n\\end{itemize}\n\n\n\n\\subsection{Symmetry}\n\\label{sec:symmetry}\nThe word \\textit{symmetry} comes from Greek symmetria meaning\n\\textbf{measure together}.\n\n\\paragraph{Definition}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation in $S$.\n\n\\subsubsection{Symmetric}\n\n$\\mathcal{R}$ is \\textbf{symmetric} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    (x, y) \\in \\mathcal{R} \\implies (y, x) \\in \\mathcal{R}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsubsection{Asymmetric}\n\n$\\mathcal{R}$ is \\textbf{asymmetric} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    (x, y) \\in \\mathcal{R} \\implies (y, x) \\notin \\mathcal{R}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsubsection{Antisymmetric}\n\n$\\mathcal{R}$ is \\textbf{antisymmetric} if and only if\n\n\\begin{math}\n  \\begin{array}{ll}\n    \\\\\n    &(x,y) \\in \\mathcal{R} \\land (y, x) \\in \\mathcal{R} \\implies x = y\\\\\n    \\text{i.e., } & \\{(x, y), (y, x) \\} \\subseteq \\mathcal{R} \\implies x = y \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\nAntisymettry eliminates uncertain cases when both $a$ precedes $b$ and\n$b$ precedes $a$.\n\n\\subsubsection{Non-symmetric}\n\n$\\mathcal{R}$ is \\textbf{non-symmetric} if and only if it is neither\n\\textit{symmetric} nor \\textit{asymmetric}.\n\n\\paragraph{Antisymmetric and Asymmetric}\n\nNote the difference between:\n\\begin{itemize}\n\\item An \\textit{asymmetric relation}, in which the fact that\n  $(x, y) \\in \\mathcal{R}$ means that $(y, x)$ is defintely\n  \\textbf{not} in $\\mathcal{R}$\n\\item An \\textit{antisymmetric relation}, in which there \\textit{may}\n  be instances of both $(x, y) \\in \\mathcal{R}$ and\n  $(y, x) \\in \\mathcal{R}$, but if there are, then it means that $x$\n  and $y$ have to be the same object.\n\\end{itemize}\n\n\n\\subsection{Reflexivity}\n\\label{sec:reflexivity}\n\n\\paragraph{Definition}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation in $S$.\n\n\\subsubsection{Reflexive}\n\n$\\mathcal{R}$ is \\textbf{reflexive} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S : (x, x) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsubsection{Coreflexive}\n\n$\\mathcal{R}$ is \\textbf{coreflexive} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S : (x, y) \\in \\mathcal{R} \\implies x = y\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsubsection{Antireflexive}\n\n$\\mathcal{R}$ is \\textbf{antireflexive} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S: (x, x) \\notin \\mathcal{R}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsubsection{Non-reflexive}\n\n$\\mathcal{R}$ is \\textbf{non-reflexive} if and only if it is neither\n\\textit{reflexive} nor \\textit{antireflexive}.\n\n\n\\subsection{Transitivity}\n\\label{sec:transitivity}\n\n\\paragraph{Definition}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation in $S$.\n\n\\subsubsection{Transitive}\n\n$\\mathcal{R}$ is \\textbf{transitive} if and only if\n\n\\begin{math}\n  \\begin{array}{ll}\n    \\\\\n    & (x, y) \\in \\mathcal{R} \\land (y, z) \\in \\mathcal{R} \\implies (x, z) \\in \\mathcal{R}\\\\\n    \\text{i.e., } & \\{(x, y), (y, z)\\} \\subseteq \\mathcal{R} \\implies (x, z) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsubsection{Antitransitive}\n\n$\\mathcal{R}$ is \\textbf{antitransitive} if and only if\n\n\\begin{math}\n  \\begin{array}{ll}\n    \\\\\n    & (x, y) \\in \\mathcal{R} \\land (y, z) \\in \\mathcal{R} \\implies (x, z) \\notin \\mathcal{R}\\\\\n    \\text{i.e., }& \\{ (x, y), (y, z) \\} \\subseteq \\mathcal{R} \\implies (x, z) \\notin \\mathcal{R}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsubsection{Non-transitive}\n\n$\\mathcal{R}$ is \\textbf{non-transitive} if and only if it is neither\n\\textit{transitive} nor \\textit{antitransitive}.\n\n\n\\subsubsection{Transitive Closure}\n\\label{sec:transitive-closure}\n\nLet $\\mathcal{R}$ be a relation on a set $S$. The \\textbf{transitive\n  closure of $\\mathcal{R}$} is defined as the smallest transitive\nrelation on $S$ which contains $\\mathcal{R}$ as a subset.\n\nOr, the \\textbf{transitive closure of $\\mathcal{R}$} is defined as the\nintersection of all transitive relations on $S$ which contains\n$\\mathcal{R}$.\n\nOr, the \\textbf{transitive closure of $\\mathcal{R}$} is the relation\n$\\mathcal{R}^+$ defined as follows:\n\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S, x \\mathcal{R}^+ y \\iff \\exists n \\in \\mathbb{N}_{>0} : \\exists s_0, s_1, ..., s_n \\in S: s_0 = x, s_n = y \\\\\n    \\\\\n    s_0 \\mathcal{R} s_1\\\\\n    s_1 \\mathcal{R} s_2\\\\\n    \\vdots\\\\\n    s_{n-1} \\mathcal{R} s_n \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Total Relation}\n\\label{sec:total-relation}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation on a set\n$S$. Then $\\mathcal{R}$ is defined as \\textbf{total} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall a, b \\in S : (a, b) \\in \\mathcal{R} \\lor (b, a) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, if and only if every pair of elements is related.\n\nAlso called as \\textbf{strictly connected}, or \\textbf{complete\n  relation}.\n\n\\subsection{Connected Relation}\n\\label{sec:connected-relation}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation on a set\n$S$. Then $\\mathcal{R}$ is \\textbf{connected} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall a, b \\in S: a \\neq b \\implies (a, b) \\in \\mathcal{R} \\lor (b,a) \\in \\mathcal{R} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\nThat is, if and only if every pair of \\textit{distinct} elements is\nrelated.\n\n\nA relation having the \\textbf{connexivity} means that any pair of\nelements in the set of the relation are comparable under the\nrelation. This also means that the set can be diagrammed as a line of\nelements, giving it the name \\textit{linear}. The connexivity also\nimplies reflexivity, i.e., $a \\leq a$.\n\nAlso called as \\textbf{weakly connected}, while \\textit{strictly\n  connected} refers to \\textit{total\n  relation}\\ref{sec:total-relation}.\n\n\n\\subsection{Relation Compatible with Operation}\n\\label{sec:compatibility}\n\nLet $(S, \\circ)$ be a magma. Let $\\mathcal{R}$ be a relation on $S$.\n\nThen $\\mathcal{R}$ is \\textbf{compatible with $\\circ$} if and only if:\n\n\\begin{itemize}\n\\item $\\forall x, y, z \\in S: x \\mathcal{R} y \\implies (x \\circ z) \\mathcal{R} (y \\circ z)$\n\\item $\\forall x, y, z \\in S: x \\mathcal{R} y \\implies (z \\circ x) \\mathcal{R} (z \\circ y)$\n\\end{itemize}\n\n\n\\subsection{Relational Structure}\n\\label{sec:relational-structure}\n\nA \\textbf{relational structure} is an ordered pair $(S, \\mathcal{R})$,\nwhere:\n\n\\begin{itemize}\n\\item $S$ is a set\n\\item $\\mathcal{R}$ is an endorelation\\ref{sec:endorelation} on $S$\n\\end{itemize}\n\nAlso called as a \\textbf{relational system}.\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{Binary Operation}\n\\label{sec:binary-operation}\n\nA \\textbf{binary operation} is a mapping $\\circ$ from the Cartesian\nproduct of two sets $S \\times T$ to a universe $\\mathbb{U}$:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\circ: S \\times T \\to \\mathbb{U} : \\circ(s, t) = y \\in \\mathbb{U} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nIf $S = T$ , then $\\circ$ can be referred to as a \\textbf{binary\n  opeation on $S$}.\n\nSome authors specify that a binary operation is defined such that\n\\textit{codomain} of $\\circ$ is the same underlying set as that which\nforms the \\textit{domain}, that is: $\\circ: S \\times S \\to S$.\n\n\n\\subsection{Algebraic Structure}\n\\label{sec:algebraic-structure}\n\nAn \\textbf{algebraic structure} is an ordered tuple:\n\n\\begin{math}\n  \\begin{array}{c}\n    (S, \\circ_1, \\circ_2, ..., \\circ_n)\n  \\end{array}\n\\end{math}\n\nwhere $S$ is a set which has one or more binary operations\n$\\circ_1, \\circ_2, ..., \\circ_n$ defined on all the elements of\n$S \\times S$.\n\nAn algebraic structure with one (binary) operation is thus an ordered\npair which can be denoted as $(S, \\circ)$ or $(T, *)$ or\n$\\pair{S, \\circ}$, and so on.\n\nThe set $S$ is called \\textbf{underlying set}.\n\n\n\\subsection{Closure}\n\\label{sec:closure}\n\nLet $(S, \\circ)$ be an algebraic structure. Then $S$ has the property\nof \\textbf{closure under $\\circ$} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall (x, y) \\in S \\times S : x \\circ y \\in S\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n$S$ is said to be \\textbf{closed under $\\circ$}, or just that\n$(S, \\circ)$ \\textbf{is closed}.\n\n\\subsection{Magma}\n\\label{sec:magma}\n\nA \\textbf{magma} is an algebraic structure $(S, \\circ)$ such that $S$\nis closed unser $\\circ$.\n\nThat is, a magma is a pair $\\pair{S, \\circ}$ where:\n\n\\begin{itemize}\n\\item $S$ is a set\n\\item $\\circ: S \\times S \\to S $ is a binary operation on $S$.\n\\end{itemize}\n\n\n\n\n\\subsection{Commutativity}\n\\label{sec:commutativity}\n\nLet $(S, \\circ)$ be an algebraic structure. Then $\\circ$ is\n\\textbf{commutative on $S$} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S: x \\circ y = y \\circ x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\subsection{Absorption Law}\n\\label{sec:absorption}\n\nLet $(S, \\circ, *)$ be an algebraic structure. Let both $\\circ$ and\n$*$ be commutative.\n\nThen $\\circ$ \\textbf{absorbs} $*$ if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall a, b \\in S: a \\circ (a * b) = a\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThis equality is called the \\textbf{absorption law of $\\circ$ for\n  $*$}.\n\n\n\n\\subsection{Associativity}\n\\label{sec:associativity}\n\nLet $(S, \\circ)$ be an algebraic structure. Then $\\circ$ is\n\\textbf{associative on $S$} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y, z \\in S: (x \\circ y) \\circ z = x \\circ (y \\circ z)\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Idempotence}\n\\label{sec:idempotence}\n\n\\paragraph{Idempotent Element}\nLet $(S, \\circ)$ be a magma. Let $x \\in S$ have the property that\n$ x \\circ x = x$.\n\nThen $x \\in S $ is described as \\textbf{idempotent (element) under the\n  operation $\\circ$}.\n\n\\paragraph{Idempotent Operation}\nLet $(S, \\circ)$ be a magma.\n\n\nIf \\textit{all} the elements of $S$ are \\textit{idempotent} under\n$\\circ$, then the term can be applied to the operation itself. Thus, a\nbinary operation $\\circ$ is \\textbf{idempotent} if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S: x \\circ x = x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nExamples are: set union, set intersection, ...\n\n\n\n\\subsection{Identity}\n\\label{sec:identity}\n\nLet $(S, \\circ)$ be an algebraic structure.\n\n\n\\paragraph{Left Identity}\nAn element $e_L \\in S$ is called a \\textbf{left identity} if and only\nif:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S: e_L \\circ x = x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\paragraph{Right Identity}\nAn element $e_R \\in S$ is called a \\textbf{right identity} if and only\nif:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S: x \\circ e_R = x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\paragraph{Identity}\nAn element $e \\in S$ is called an \\textbf{identity (element)} if and\nonly if it is both a \\textit{left identity} and \\textit{right\n  identity}\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x \\in S: e \\circ x = x \\circ e =  x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\paragraph{Uniqueness of Identity}\n\nSuppose $e_1$ and $e_2$ are both identity elements of $(S, \\circ)$.\n\nThen by the definition of identity elements:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall s \\in S: s \\circ e_1 = s = e_2 \\circ s\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThen:\n\n\\begin{math}\n  \\begin{array}{c}\n    e_1 = e_2 \\circ e_1 = e_2 \\\\\n    \\therefore e_1 = e_2\n  \\end{array}\n\\end{math}\n\n\n\n\\subsection{Semigroup}\n\\label{sec:semigroup}\n\nLet $(S, \\circ)$ be a magma. Then this magma is a \\textbf{semigroup}\nif and only if $\\circ$ is \\textit{associative} on $S$.\n\n\nThat is, a \\textbf{semigroup} is an algebraic structure which is\n\\textit{closed} and whos operation is \\textit{associative}.\n\n\n\\subsection{Monoid}\n\\label{sec:monoid}\n\nA \\textbf{monoid} is a \\textit{semigroup} with an \\textit{identity\n  element}.\n\n\\paragraph{Monoid is not Empty}\n\nLet $(S, \\circ)$ be a monoid. By definition:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\text{Identity: } \\exists e_S \\in S : \\forall a \\in S: a \\circ e_S = a = e_S \\circ a\n  \\end{array}\n\\end{math}\n\nSo a monoid must \\textit{at least} have an identity.\n\nTherefore $e_S \\in S $ and so $S$ is not the empty set.\n\n\n\\subsection{Inverse}\n\\label{sec:inverse}\n\nLet $(S, \\circ)$ be a monoid whose identity is $e_S$.\n\n\\paragraph{Left Inverse}\nAn element $x_L \\in S$ is called a \\textbf{left inverse} of $x$ if and\nonly if:\n\n\\begin{math}\n  \\begin{array}{c}\n    x_L \\circ x = e_S\n  \\end{array}\n\\end{math}\n\n\n\\paragraph{Right Inverse}\nAn element $x_R \\in S$ is called a \\textbf{right inverse} of $x$ if and\nonly if:\n\n\\begin{math}\n  \\begin{array}{c}\n    x \\circ x_R = e_S\n  \\end{array}\n\\end{math}\n\n\\paragraph{Inverse}\n\nLet $x , y \\in S $ be elements. The element $y$ is an \\textbf{inverse\n  of $x$} if and only if $y$ is both a \\textit{left inverse} and\n\\textit{right inverse}.\n\n\n\\subsection{Group}\n\\label{sec:group}\n\nA \\textbf{group} is a \\textit{semigroup} with an \\textit{identity}\n(that is, a \\textit{monoid}) in which every element has an\n\\textit{inverse}.\n\n\\begin{itemize}\n\\item G0: Closure. $ \\forall a, b \\in G: a \\circ b \\in G$\n\\item G1: Associativity. $ \\forall a, b, c \\in G: a \\circ (b \\circ c) = (a \\circ b) \\circ c $\n\\item G2: Identity. $\\exists e in G : \\forall a in G: e \\circ a = a = a \\circ e $\n\\item G3: Inverse. $\\forall a in G: \\exists b in G: a \\circ b = e = b \\circ a$\n\\end{itemize}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newpage\n\\section{Set Theory}\n\\label{sec:set-theory}\n\n\\subsection{Set Equivalence}\n\\label{sec:set-eq}\n\nLet $S$ and $T$ be sets. Then $S$ and $T$ are \\textbf{equivalent} if\nand only if there exists a \\textbf{bijection} $f : S \\to T$ between\nthe elements of $S$ and those of $T$. That is, if they have the\n\\textbf{same cardinality}. This can be written as $S \\sim T$.\n\n\n\\subsection{Finite Set}\n\\label{sec:finite-set}\n\nA set $S$ is defined as \\textbf{finite} if and only if\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\exists n \\in \\mathbb{N}: S \\sim \\mathbb{N}_{< n}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nwhere $\\sim$ denotes \\textit{set equivalence}.\n\nThat is, if there exists an element $n$ of the set of natural numbers\n$\\mathbb{N}$ such that the set of all elements of $\\mathbb{N}$ less\nthan $n$ is equivalent to $S$.\n\nEquivalently, a finite set is a set with a count.\n\n\\subsection{Topology}\n\\label{sec:topology}\n\nLet $S$ be a set such that $S \\neq \\emptyset$. A \\textbf{topology on\n  $S$} is a subset $\\tau \\subseteq \\mathcal{P}(S)$ of the power set of\n$S$ that satisfies the open set axioms:\n\\begin{itemize}\n\\item O1: The union of an arbitrary subset of $\\tau$ is an element of\n$\\tau$\n\\item O2: The intersection of any two elements of $\\tau$ is an element\nof $\\tau$\n\\item O3: $S$ is an element of $\\tau$\n\\end{itemize}\n\nIf $\\tau$ is a topology on $S$, then $(S, \\tau)$ is called a\n\\textit{topological space}. The elements of $\\tau$ are called the open\nsets of $(S, \\tau)$.\n\n\\subsection{Open Set}\n\\label{sec:open-set}\n\nLet $T = (S, \\tau)$ be a topological space. Then the elements of\n$\\tau$ are called the \\textbf{open sets of $T$}. Thus, both are\nequivalent statements:\n\n\\begin{math}\n  \\begin{array}{l}\n    \\\\\n    U \\in \\tau \\\\\n    U \\text{ is open in } T\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\paragraph{Open Set Axioms}\n\\label{sec:open-set-axioms}\n\nLet $S$ be a set. The \\textbf{open set axioms} are the conditions\nunder which elements of a subset $\\tau \\in \\mathcal{P}(S)$ of the\npower set of $S$ need to satisfy in order to be open sets of the\ntopology $\\tau$ on $S$:\n\n\\begin{itemize}\n\\item O1: The union of an arbitrary subset of $\\tau$ is an element of\n$\\tau$\n\\item O2: The intersection of any two elements of $\\tau$ is an element\nof $\\tau$\n\\item O3: $S$ is an element of $\\tau$\n\\end{itemize}\n\n\n\n\\subsection{Closed Set}\n\\label{sec:closed-set}\n\nLet $T = (S, \\tau)$ be a topological space. Let $H \\subseteq S$. H is\n\\textbf{closed (in $T$)} if and only if its complements\n$S \\setminus H$ is open in $T$.\n\nThat is, $H$ is closed if and only if $(S \\setminus H) \\in \\tau$,\ni.e., $S \\setminus H$ is an element of the topology of $T$.\n\n\n\\paragraph{Closed Set Axioms}\n\nLet $S$ be a set. The \\textbf{closed set axioms} are the conditions\nunder which a subset $F \\subseteq \\mathcal{P}(S)$ of the power set $S$\nconsists of the closed sets of a topology on $S$:\n\n\\begin{itemize}\n\\item C1: The intersection of an arbitrary subset of $F$ is an element\n  of $F$\n\\item C2: The union of any two elements of $F$ is an element of $F$\n\\item C3: $\\emptyset$ is an element of $F$\n\\end{itemize}\n\n\n\n\\subsection{Upper Set}\n\\label{sec:upper-set}\n\nLet $(S, \\preceq)$ be an ordered set, and $U \\subseteq S$. $U$ is an\n\\textbf{upper set} in $S$ if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall u \\in U : \\forall s \\in S: u \\preceq s \\implies s \\in U\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\subsection{Lower Set}\n\\label{sec:lower-set}\n\nLet $(S, \\preceq)$ be an ordered set, and $L \\subseteq S$. $U$ is an\n\\textbf{lower set} in $S$ if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall l \\in L : \\forall s \\in S: s \\preceq l \\implies s \\in L\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Sequence}\n\\label{sec:sequence}\n\nA \\textbf{sequence} is a mapping\\ref{sec:mapping} whose domain is a\nsubset of the set of natural numbers $\\mathbb{N}$. It can be seen that\na sequence is an instance of a family of elements indexed by\n$\\mathbb{N}$.\n\nInformally, a \\textbf{sequence} is a set of objects which is listed in\na \\textbf{specific order}.\n\n\\paragraph{Notation}\n\nIf $f : A \\to S$ is a \\textbf{sequence}, then a symbol (e.g. $a$) is\nchosen to represents elements of this sequence. Then, for each\n$k \\in A$, $f(k)$ is denoted as $a_k$, and $f$ itself is denoted as\n$\\pair{a_k}_{k \\in A}$ or $(a_k)_{k \\in A}$.\n\nAny expression can be used to denote the \\textit{domain} of $f$ in\nplace of $k \\in A$.\n\nAlso, a seqeunce itself may be defined by a simple formula, and so for\nexample:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    (k^3)_{2 \\leq k \\leq 6} \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nis the same as :\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    (a_k)_{2 \\leq k \\leq 6} \\text{ where } \\forall k \\in {2,3, ..., 6}: a_k = k^3\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newpage\n\\section{Ordering}\n\\label{sec:ordering}\n\n\\paragraph{Definition}\n\nLet $S$ be a set. An \\textbf{ordering on} $S$ is a relation\n$\\mathcal{R}$ on $S$ such that:\n\n\\begin{itemize}\n\\item $\\mathcal{R}$ is \\textbf{reflexive}\\ref{sec:reflexivity}, i.e.,\n  $\\forall a \\in S: a \\mathcal{R} a$.\n\\item $\\mathcal{R}$ is \\textbf{transitive}\\ref{sec:transitivity},\n  i.e.,\n  $\\forall a, b, c \\in S: a \\mathcal{R} b \\land b \\mathcal{R} c\n  \\implies a \\mathcal{R} c$.\n\\item $\\mathcal{R}$ is \\textbf{antisymmetric}\\ref{sec:symmetry}, i.e.,\n  $\\forall a \\in S : a \\mathcal{R} b \\land b \\mathcal{R} a \\implies a\n  = b$.\n\\end{itemize}\n\nIt is not demanded for an ordering $\\preceq$, defined in its most\ngeneral form on a set $S$, that \\textit{every} pair of elements of $S$\nis related by $\\preceq$. They may be, or they may not be, depending on\nthe specific nature of both $S$ and $\\preceq$.\n\nIf it \\textit{is} the case that $\\preceq$ is a \\textbf{connected\n  relation}, that is, that every pair of distinct elements is related\nby $\\preceq$, then $\\preceq$ is called a \\textbf{total ordering}.\n\nIf it is \\textit{not} the case that $\\preceq$ is connected, then\n$\\preceq$ is called a \\textbf{partial ordering}.\n\n\n\\paragraph{Notation}\n\nSymbols used to denote a general \\textbf{ordering relation} are\nusually variants on $\\preceq$, $\\leq$, and so on.\n\nThus, $a \\preceq b$ can be read as:\n\\begin{itemize}\n\\item $a$ \\textbf{precedes, or is the same as} $b$.\n\\item $b$ \\textbf{succeeds, or is the same as} $a$.\n\\end{itemize}\n\n\\paragraph{Smaller and Larger}\n\nAn \\textbf{ordering} can often be considered to be a comparison of the\n\\textbf{size} of objects, perhaps in some intuitive sense. This is\nparticularly applicable in the context of numbers. Thus the expression\n$A \\preceq B$ can in such contexts be interpreted as:\n\\begin{itemize}\n\\item $A$ is \\textbf{smaller than} $B$\n\\item $A$ is \\textbf{less than} $B$\n\\item $B$ is \\textbf{larger than} $A$\n\\item $B$ is \\textbf{greater than} $A$\n\\end{itemize}\n\nIn natural language, such terms are called \\textbf{comparative\n  adjectives}, or just \\textbf{comparatives}.\n\nDepending on the nature of the set being ordered, and depending on the\nnature of the ordering relation, this interpretation of an ordering as\na comparison of size may not be intellectually sustainable.\n\n\\subsection{Ordered Set}\n\\label{sec:ordered-set}\n\nAn \\textbf{ordered set} is a relational structure $(S, \\preceq)$ such\nthat the relation $\\preceq$ is an ordering.\n\n\n\\subsection{Ordered Structure}\n\\label{sec:ordered-structure}\n\nAn \\textbf{ordered structure} $(S, \\circ, \\preceq)$ is a set $S$ such\nthat:\n\n\\begin{itemize}\n\\item $(S, \\circ)$ is an algebraic structure\n\\item $(S, \\preceq)$ is an ordered set\n\\item $\\preceq$ is \\textit{compatible}\\ref{sec:compatibility} with\n  $\\circ$\n\\end{itemize}\n\n\n\\subsection{Monotone}\n\n\\paragraph{Increasing}\n\\label{sec:increasing}\n\nLet $(S, \\preceq_1)$ and $(T, \\preceq_2)$ be ordered sets. Let\n$\\phi: S \\to T$ be a mapping. Then $phi$ is \\textbf{increasing} if and\nonly if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S: x \\preceq_1 y \\implies \\phi(x) \\preceq_2 \\phi(y) \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nNote that this definition also holds if $S = T$.\n\nIt is also called as \\textbf{order-preserving}, \\textbf{isotone}, and\n\\textbf{non-decreasing}.\n\n\\paragraph{Decreasing}\n\\label{sec:decreasing}\n\nLet $(S, \\preceq_1)$ and $(T, \\preceq_2)$ be ordered sets. Let\n$\\phi: S \\to T$ be a mapping. Then $phi$ is \\textbf{decreasing} if and\nonly if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S: x \\preceq_1 y \\implies \\phi(y) \\preceq_2 \\phi(x) \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nNote that this definition also holds if $S = T$.\n\nIt is also called as \\textbf{order-inverting},\n\\textbf{order-reversing}, \\textbf{anitone}, and\n\\textbf{non-increasing}.\n\n\n\\paragraph{Monotone}\n\\label{sec:monotone}\n\n\nLet $(S, \\preceq_1)$ and $(T, \\preceq_2)$ be ordered sets. Let\n$\\phi: S \\to T$ be a mapping. Then $phi$ is \\textbf{monotone} if and\nonly if it is either \\textit{increasing} or \\textit{decreasing}.\n\nNote that this definition also holds if $S = T$.\n\n\n\n\n\\subsection{Upper Bound}\n\\label{sec:upper-bound}\n\nLet $(S, \\preceq)$ be an ordered set. Let $T \\subseteq S$. An\n\\textbf{upper bound for $T$ in $S$} is an element $m \\in S$ such that:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall t \\in T : t \\preceq m\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, $m$ \\textit{succeeds} every elements of $T$.\n\n\n\n\\subsection{Supremum}\n\\label{sec:supremum}\n\nLet $(S, \\preceq)$ be an ordered set. Let $T \\subseteq S$. An element\n$c \\in S$ is the \\textbf{supremum of $T$ in $S$} if and only if:\n\n\\begin{itemize}\n\\item $c$ is an \\textit{upper bound} of $T$ in $S$\n\\item $c \\preceq d$ for all upper bounds $d$ of $T$ in $S$\n\\end{itemize}\n\nIf there exists a \\textbf{supremum} of $T$, we say that:\n\n\\begin{itemize}\n\\item $T$ admits a supremum (in $S$)\n\\item $T$ has a supremum (in $S$)\n\\end{itemize}\n\n\nParticularly in the field of analysis, the supremum of a set $T$ is\noften referred to as the \\textbf{least upper bound of $T$} and denoted\n$\\mathtt{lub}(T)$.\n\n\n\\paragraph{Uniqueness of Supremum}\n\nLet $c$ and $c'$ both be suprema of $T$ in $S$. From the definition of\nsupremum, $c$ and $c'$ are upper bounds of $T$ in $S$.\n\nBy that definition:\n\n\\begin{itemize}\n\\item $c$ is an upper bound of $T$ in $S$, and $c'$ is a supremum of\n  $T$ in $S$ implies that $c' \\preceq c$.\n\\item $c'$ is an upper bound of $T$ in $S$, and $c$ is supremum of $T$\n  in $S$ implies that $c preceq c'$.\n\\end{itemize}\n\nTherefore,\n\n\\begin{math}\n  \\begin{array}{ll}\n    \\\\\n    c' \\preceq c \\land c \\preceq c'\\\\\n    \\therefore c = c' & \\because \\preceq \\text{ is antisymmetry}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nQ.E.D.\n\n\n\\subsection{Join}\n\\label{sec:join}\n\nLet $(S, \\preceq)$ be an ordered set. Let $a, b \\in S$. Let their\nsupremum $\\mathtt{sup} \\{a, b\\}$ exist in $S$.\n\nThen the \\textbf{join of $a$ and $b$}\\footnote{some sources refer to\n  this as the \\textbf{union} of $a$ and $b$} is defined as:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    a \\vee b = \\mathtt{sup} \\{ a, b \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nExpanding the definition of supremum, one sees that $c = a \\vee b$ if\nand only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    a \\preceq c\\text{ and }b \\preceq c\\text{ and }\\forall s \\in S: a \\preceq s \\land b \\preceq s \\implies c \\preceq s\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsection{Lower Bound}\n\\label{sec:lower-bound}\n\nLet $(S, \\preceq)$ be an ordered set. Let $T \\subseteq S$. A\n\\textbf{lower bound for $T$ in $S$} is an element $m \\in S$ such that:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall t \\in T: m \\preceq t\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, $m$ \\textit{precedes} every elements of $T$.\n\n\n\\subsection{Infimum}\n\\label{sec:infimum}\n\nLet $(S, \\preceq)$ be an ordered set. Let $T \\subseteq S$. An element\n$c \\in S$ is the \\textbf{infimum of $T$ in $S$} if and only if:\n\n\\begin{itemize}\n\\item $c$ is a \\textit{lower bound} of $T$ in $S$\n\\item $d \\preceq c$ for all lower bounds $d$ of $T$ in $S$\n\\end{itemize}\n\nIf there exists an \\textbf{infimum} of $T$, we say that:\n\n\\begin{itemize}\n\\item $T$ admits an infimum (in $S$)\n\\item $T$ has an infimum (in $S$)\n\\end{itemize}\n\n\nParticularly in the field of analysis, the infimum of a set $T$ is\noften referred to as the \\textbf{greatest lower bound of $T$} and\ndenoted as $\\mathtt{glb}(T)$.\n\n\n\\subsection{Meet}\n\\label{sec:meet}\n\nLet $(S, \\preceq)$ be an ordered set. Let $a, b \\in S$. Let their\ninfimum $\\mathtt{inf} \\{a, b\\}$ exist in $S$.\n\nThen the \\textbf{meet of $a$ and $b$}\\footnote{some sources refer to\n  this as the \\textbf{intersection} of $a$ and $b$} is defined as:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    a \\wedge b =\\mathtt{inf} \\{ a, b \\}\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\nExpanding the definition of infimum, one sees that $c = a \\wedge b$ if\nand only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    c \\preceq c\\text{ and }c \\preceq b\\text{ and } \\forall s \\in S: s \\preceq a \\land s \\preceq b \\implies s \\preceq c\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Semilattice}\n\\label{sec:semilattice}\n\nA semigroup $(S, \\circ)$ is called a \\textbf{semilattice} if and only\nif $\\circ$ is a \\textit{commutative} and \\textit{idempotent}\noperation.\n\nThus, an algebraic structure is a \\textbf{semilattice} if and only if\nit satisfies the semilattice axioms:\n\n\\begin{itemize}\n\\item SL0: Closure for $\\circ$. $\\forall a, b \\in S: a \\circ b \\in S$\n\\item SL1: Associativity of $\\circ$.\n  $\\forall a, b, c \\in S: (a \\circ b) \\circ c = a \\circ (b \\circ c)$\n\\item SL2: Commutativity of $\\circ$.\n  $\\forall a, b \\in S: a \\circ b = b \\circ a$\n\\item SL3: Idempotence of $\\circ$. $\\forall a \\in S: a \\circ a = a$\n\\end{itemize}\n\n\n\\subsubsection{Join Semilattice}\n\nLet $(S, \\vee, \\preceq)$ be an ordered structure and $\\vee$ is join\noperator. Suppose that $\\forall a, b \\in S: a \\vee b \\in S$ where\n$a \\vee b$ is the join of $a$ and $b$ with respect to $\\preceq$.\n\nThen the ordered structure $(S, \\vee, \\preceq)$ is called a\n\\textbf{join semilattice}.\n\n\n\\subsubsection{Meet Semilattice}\n\nLet $(S, \\wedge, \\preceq)$ be an ordered structure and $\\wedge$ is\nmeet operator. Suppose that $\\forall a, b \\in S: a \\wedge b \\in S$\nwhere $a \\wedge b$ is the meet of $a$ and $b$ with respect to\n$\\preceq$.\n\nThen the ordered structure $(S, \\wedge, \\preceq)$ is called a\n\\textbf{meet semilattice}.\n\n\n\\paragraph{Semilattice Induces Ordering}\n\\label{sec:semilattice-induces-ordering}\n\nLet $(S, \\circ)$ be a semlilattice. Let $\\preceq$ be the relation on\n$S$ defined by $\\forall a, b \\in S: a \\preceq b \\iff a \\circ b = b$.\n\nThen $\\preceq$ is an ordering.\n\n\\subparagraph{Proof}\n\nLet's verify that $\\preceq$ satisfies the three conditions for an\nordering.\n\n\\subparagraph{Reflexivity}\n\nSince $\\circ$ is \\textit{idempotent},\n$\\forall a \\in S: a \\circ a = a$. Hence $a \\preceq a$. Thus $\\preceq$\nis \\textit{reflexive}.\n\n\\subparagraph{Antisymmetry}\n\nSuppose that $a \\preceq b$ and $b \\preceq a$. Then from the first\nrelation: $a \\circ b = b$ and from the second: $b \\circ a =a$.\n\nSince $\\circ$ is \\textit{commutative}, it follows that $a = b$. Hence\n$\\preceq$ is \\textit{antisymmetric}.\n\n\\subparagraph{Transitivity}\n\nSuppose that $a \\preceq b$ and $b \\preceq c$.\n\nThen:\n\n\\begin{math}\n  \\begin{array}{lcll}\n    a \\circ c & = & a \\circ (b \\circ c) & \\because b \\preceq c \\\\\n              & = & (a \\circ b) \\circ c & \\because \\circ \\text{ is associative} \\\\\n              & = & b \\circ c & \\because a \\preceq b \\\\\n              & = & c & \\because b \\preceq c \\\\\n    \\therefore a \\preceq c\n  \\end{array}\n\\end{math}\n\nThus, $\\preceq$ is \\textit{transitive}.\n\n\n\\subsection{Lattice}\n\\label{sec:lattice}\n\n\\paragraph{Definition 1}\n\nLet $(S, \\preceq)$ be an ordered set. Suppose that $S$ admits all\nfinite non-empty suprema and finite non-empty infima. Denote with\n$\\wedge$ and $\\vee$ the join and meet operations on $S$, respectively.\n\nThen the ordered structure $(S, \\wedge, \\vee, \\preceq)$ is called a\n\\textbf{lattice}.\n\n\\paragraph{Definition 2}\n\nLet $(S, \\wedge, \\vee, \\preceq)$ be an ordered structure.\n\nThen $(S, \\wedge, \\vee, \\preceq)$ is called a \\textbf{lattice} if and\nonly if:\n\n\\begin{itemize}\n\\item $(S,\\vee, \\preceq)$ is a join semilattice\n\\item $(S,\\wedge, \\preceq)$ is a meet semilattice\n\\end{itemize}\n\n\\paragraph{Definition 3}\n\nLet $(S, \\vee)$ and $(S, \\wedge)$ be semilattices on a set $S$.\n\nSuppose that $\\vee$ and $\\wedge$ satisfy the \\textit{absorption laws}, that is,\n\n\\begin{itemize}\n\\item $\\forall a, b \\in S: a \\vee (a \\wedge b) = a$\n\\item $\\forall a, b \\in S: a \\wedge (a \\vee b) = a$\n\\end{itemize}\n\nLet $\\preceq$ be the ordering on $S$ defined by:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\forall a, b \\in S: a \\preceq b \\iff a \\vee b = b\n  \\end{array}\n\\end{math}\n\nas on Semilattice Induces\nOrdering\\ref{sec:semilattice-induces-ordering}.\n\nThen the ordered structure $(S, \\vee, \\wedge, \\preceq)$ is called a\n\\textbf{lattice}.\n\n\n\\subsection{Complete Lattice}\n\\label{sec:complete-lattice}\n\nLet $(S, \\preceq)$ be a lattice. Then, $(S, \\preceq)$ is a\n\\textbf{complete lattice} if and only if:\n\n\\begin{math}\n  \\begin{array}{ll}\n    \\\\\n    & \\forall T \\subseteq S: T \\text{ admits both a \\textit{supremum} and an \\textit{infimum}} \\\\\n    \\text{or} & \\forall T \\subseteq S: \\mathtt{inf}T, \\mathtt{sup}T \\in S \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nThat is, if and only if all subsets $T$ of $S$ have both a supremum\nand an infimum.\n\nAlso called as \\textbf{complete ordered set}\n\n\n\\subsection{Pre-Ordering}\n\\label{sec:pre-ordering}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation on a set\n$S$. $\\mathcal{R}$ is a \\textbf{pre-ordering} if and only if:\n\n\\begin{itemize}\n\\item \\textbf{Reflexive}: $\\forall a \\in S: a \\mathcal{R} a $\n\\item \\textbf{Transitive}:\n  $\\forall a,b,c \\in S: a \\mathcal{R} b \\land b \\mathcal{R} c \\implies\n  a \\mathcal{R} c $\n\\end{itemize}\n\n\\paragraph{Pre-Ordered Set}\n\nLet $S$ be a set, and $\\precsim$ be a \\textbf{preordering} on\n$S$. Then the relational structure $(S, \\precsim)$ is called a\n\\textbf{preordered set}.\n\n\n\\paragraph{Partial vs. Total}\n\nNote that this definition of preordering does not demand that\n\\textit{every} pair of elements of $S$ is related by $\\precsim$. The\nway we have defined a preordering, they may be, or they may not be,\ndepending on the context.\n\nIf it \\textit{is} the case that $\\precsim$ is a \\textit{connected\n  relation}\\ref{sec:connected-relation}, i.e., that \\textit{every\n  pair} of elements is related by $\\precsim$, then $\\precsim$ is\ncalled a total preordering.\n\nIf it is \\textit{not} the case that $\\precsim$ is connected, then\n$\\precsim$ is called a partial preordering.\n\n\n\\subsection{Directed Set}\n\\label{sec:directed-set}\n\nLet $(S, \\precsim)$ be a preordered set. Then $(S, \\precsim)$ is a\n\\textbf{directed set} if and only if every pair of elements of $S$ has\nan \\textbf{upper bound}\\ref{sec:upper-bound} in $S$:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S: \\exists m \\in S: x \\precsim m \\land y \\precsim m \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nAlso called as a \\textbf{directed preorder}, \\textbf{filtered set}, or\n\\textbf{upward directed set}.\n\n\\paragraph{Directed Subset}\n\\label{sec:directed-subset}\n\nLet $(S, \\precsim)$ be a preordered set. Let $H$ be a non-empty subset\nof $S$. Then $H$ is a \\textbf{directed subset} of $S$ if and only if:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in H: \\exists m \\in H: x \\precsim m \\land y \\precsim m\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\n\\subsection{Well-Ordering}\n\\label{sec:well-ordering}\n\nLet $(S, \\preceq)$ be an ordered set.\n\nThe ordering $\\preceq$ is a \\textbf{well-ordering} on $S$ if and only\nif \\textbf{every} non-empty subset of $S$ has a smallest element under\n$\\preceq$. That is,\n\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall T \\subseteq S: \\exists a \\in T : \\forall x \\in T : a \\preceq x\n    \\\\\n  \\end{array}\n\\end{math}\n\n\\subsection{Strict Ordering}\n\\label{sec:strict-ordering}\n\nLet $\\mathcal{R}$ be a relation on a set $S$. Then $\\mathcal{R}$ is a\n\\textbf{strict ordering} on $S$ if and only if:\n\n\\subsubsection{Definition 1}\n\n\\begin{itemize}\n\\item \\textbf{Asymmetry}:\n  $\\forall a, b \\in S : a \\mathcal{R} b \\implies \\neg b \\mathcal{R} a$\n\\item \\textbf{Transitivity}:\n  $\\forall a, b, c \\in S: a \\mathcal{R} b \\land b \\mathcal{R} c\n  \\implies a \\mathcal{R} c$\n\\end{itemize}\n\n\\subsubsection{Definition 2}\n\n\\begin{itemize}\n\\item \\textbf{Antireflexivity}:\n  $\\forall a \\in S: \\neg (a \\mathcal{R} a) $\n\\item \\textbf{Transitivity}:\n  $\\forall a, b, c \\in S: a \\mathcal{R} b \\land b \\mathcal{R} c\n  \\implies a \\mathcal{R} c$\n\\end{itemize}\n\nSymbols used to denote a general strict ordering are usually variants\non $\\prec$, $<$, and so on.\n\n\n\\subsection{Total Ordering}\n\\label{sec:total-ordering}\n\nLet $\\mathcal{R} \\subseteq S \\times S$ be a relation on a set $S$.\n\n$\\mathcal{R}$ is a \\textbf{total ordering} on $S$ if and only if:\n\n\\begin{itemize}\n\\item $\\mathcal{R}$ is an ordering\\ref{sec:ordering} on $S$\n\\item $\\mathcal{R}$ is connected\\ref{sec:connected-relation}\n\\end{itemize}\n\nThat is, $\\mathcal{R}$ is an ordering with no non-comparable pairs:\n\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall x, y \\in S: x \\mathcal{R} y \\lor y \\mathcal{R} x\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nAlso called as a \\textbf{linear ordering}, or a \\textbf{simple\n  ordering}.\n\nIf it is necessary to emphasises that a total ordering is \\textbf{not\n  strict}, then the term \\textbf{weak total ordering} may be used.\n\n\\subsubsection{Chain}\n\\label{sec:chain}\n\nLet $(S, \\preceq)$ be an ordered set. A \\textbf{chain in $S$} is a\ntotally ordered subset of $S$. Thus, a totally ordered set is itself a\nchain in its own right.\n\n\n\\subsection{Partial Ordering}\n\\label{sec:partial-ordering}\n\nLet $(S, \\preceq)$ be an ordered set. Then the ordering $\\preceq$ is a\n\\textbf{partial ordering} on $S$ if and only if $\\preceq$ is\n\\textbf{not connected}\\ref{sec:connected-relation}.\n\nThat is, if and only if $(S, \\preceq)$ has at least one pair which is\nnon-comparable:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\exists x, y \\in S : x \\npreceq y \\land y \\npreceq x \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\nIt it is necessary to emphasizes that a partial ordering is\n\\textbf{not strict}\\ref{sec:strict-ordering}, then the term\n\\textbf{weak partial ordering} may be used.\n\n\n\\subsection{Partially Ordered Set}\n\\label{sec:poset}\n\nA \\textbf{partially ordered set} is a relational structure\n$(S, \\preceq)$ such that $\\preceq$ is a partial ordering.\n\nThe partially ordered set $(S, \\preceq)$ is said to be\n\\textbf{partially ordered by $\\preceq$}.\n\n\n\n\\subsection{Complete Partial Ordering}\n\\label{sec:cpo}\n\nA \\textbf{complete partial order} abbreviated \\textbf{cpo} can,\ndepending on context, refer to any of the following concepts:\n\n\\begin{itemize}\n\\item A partially ordered set is a \\textbf{directed-complete partial\n    order (dcpo)} if each of its \\textit{directed\n    subsets}\\ref{sec:directed-subset} has a supremum.\n\\item A partially ordered set is a \\textbf{point directed-complete\n    partial order} if it is a dcpo with a \\textit{least element}.\n\\item A partially ordered set is a \\textbf{$\\omega$-complete partial\n    order ($\\omega$-cpo)} if it is a poset in which every\n  $\\omega$-chain $(x_1 \\leq x_2 \\leq x_3 \\leq ...)$ has a supremum\n  that belongs to the underlying set of the poset. Every dcpo is an\n  $\\omega$-cop, since every $\\omega$-chain is a directed set, but the\n  converse is not true.\n\\end{itemize}\n\n\n\\paragraph{Properties}\n\nAn ordered set $P$ is a pointed dcpo if and only if every chain has a\nsupremum in $P$, i.e., $P$ is chain-complete. Alternatively, an\nordered set $P$ is an pointed dcpo if and only if every\norder-preserving self-map of $P$ has a least fixpoint. Every set $S$\ncan be turned into a pointed dcpo by adding a least element $\\bot$ and\nintroducing a flat order with $\\bot \\leq s$ and $s \\leq s$ for every\n$s \\in S$ and no other order relations.\n\n\n\\subsubsection{(Scott) Continuous}\n\\label{sec:scott-continuous}\n\nA function $f$ between two dcpos $P$ and $Q$ is called \\textbf{(Scott)\n  continuous} if it maps directed sets to directed sets while\npreserving their suprema:\n\n\\begin{itemize}\n\\item $f(D) \\subseteq Q$ is directed for every directed $D \\subseteq P$\n\\item $f(\\mathtt{sup}D) = \\mathtt{sup} f(D)$ for every directed $D subseteq P$\n\\end{itemize}\n\nNote that every continuous function between dcpos is a\n\\textit{monotone function}\\ref{sec:monotone}.\n\n\n\\subsubsection{Kleene Fixpoint Theorem}\n\\label{sec:fixpoint-theorem}\n\nSuppose $(L, \\sle)$ is directed-complete partial order with a least\nelement, and $f: L \\to L$ be a Scott-continuous (and therefore\nmonotone) function. Then $f$ has a least fixed point, which is the\nsupremum of the ascending Kleene chain of $f$.\n\nThe \\textbf{ascending Kleene chain} of $f$ is the chain\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\bot \\sle f(\\bot) \\sle f(f(\\bot)) \\sle ... \\sle f^n(\\bot) \\sle ...\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nobtained by iterating $f$ on the least element $\\bot$ of $L$. The\ntheorem states that\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\mathtt{lfp}(f) = \\mathtt{sup}( \\{ f^n(\\bot) | n \\in \\mathbb{N}\\})\\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\nwhere $\\mathtt{lfp}$ denotes the least fixed point.\n\n\nEvery \\textit{order-preserving}\\ref{sec:monotone}\n\\textit{self-map}\\ref{sec:self-map} $f$ of a cpo $(P, \\bot)$ has a\nleast fixpoint. If $f$ is continuous, then this fixpoint is equal to\nthe supremum of the iterates $(\\bot, f(\\bot), f(f(\\bot)), ...)$ of\n$\\bot$.\n\n\n\\subsection{Linear Extension}\n\\label{sec:linear-extension}\n\nGiven any partial orders $\\preceq$ and $\\preceq^*$ on a set $X$,\n$\\preceq^*$ is a \\textbf{linear extension of $\\preceq$} if and only if:\n\n\\begin{itemize}\n\\item $\\preceq^*$ is a \\textit{total order}\\ref{sec:total-ordering}\n\\item $\\forall x, y in X: x \\preceq y \\implies x \\preceq^* y$\n\\end{itemize}\n\nIt is that second property that leads to describe $\\preceq^*$ as\n\\textbf{extending} $\\preceq$.\n\n\n\\subsection{Weak Topological Ordering}\n\\label{sec:wto}\n\n\\footnote{This origiates from\n  https://en.wikipedia.org/wiki/Topological\\_sorting}\n\nA \\textbf{topological sort}, or \\textbf{(weak) topological ordering}\nof a directed graph is a \\textbf{linear\n  ordering}\\ref{sec:total-ordering} of its vertices such that for\nevery directed edge $uv$ from $u$ to $v$, $u$ comes before $v$ in the\nordering.\n\nFor example, the vertices may represent \\textit{tasks} to be\nperformed, and the edges may represent \\textit{constrains} that one\ntask must be performed before another; in this application, a\n\\textit{topological ordering} is just a \\textbf{valid sequence} for\nthe tasks.\n\nA topological ordering is possible if and only if the graph has\n\\textbf{no directed cycles}, that is, if it is a directed acyclic\ngraph (DAG). Any DAG has at least one topological ordering, and\nalgorithms are known for constructing a topological ordering of any\nDAG in linear time.\n\nTopological orderings are closely related to the concept of a\n\\textit{linear extension}\\ref{sec:linear-extension} of a\n\\textit{partial order}\\ref{sec:partial-ordering}.\n\nA partially ordered set is just a set of objects together with a\ndefinition of $\\preceq$ inequality relation, satisfying the axioms of\nreflexivity\\ref{sec:reflexivity}, antisymmetry\\ref{sec:symmetry}, and\ntransitivity\\ref{sec:transitivity}. A total order is a partial order\nwith connexivity. Total orders are familiar in computer science as the\ncomparison operators needed to perform comparison sorting\nalgorithms. For finite sets, total orders may be identified with\nlinear sequences of objects, where $\\preceq$ relation is \\texttt{true}\nwhenever the first object precedes the second object in the order; a\ncomparison sorting algorithm may be used to convert a total order into\na sequence in this way. A linear extension of a partial order is a\ntotal order that is compatible with if $x \\preceq y$ in the partial\norder, then $x \\preceq y$ in the total order as well.\n\n\nOne can define a partial ordering from any DAG by letting the set of\nobjects be the vertices of the DAG, and defining $x \\preceq y$ to be\ntrue for any two vertices $x$ and $y$ whenever there exists a directed\npath from $x \\to y$; that is, whenever $y$ is \\textit{reachable} from\n$x$. With these definitions, a topological ordering of the DAG is the\nsame thing as a \\textbf{linear extension of this partial\n  order}. Conversely, any partial ordering on a finite set may be\ndefined as the \\textit{reachability relation} in a DAG. One way of\ndoing this is to define a DAG that has a vertex for every object in\nthe partially ordered set, and an edge $xy$ for every pair of objects\nfor which $x \\preceq y$. An alternative way of doing this is to use\n\\textit{transitive reduction} of the partial ordering; in general,\nthis produces DAGs with fewer edges, but the reachability relation in\nthese DAGs is still the same partial order. By using these\nconstructions, one can use topological ordering algorithms to find\nlinear extensions of partial orders.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newpage\n\n\\section{Graph Theory}\n\\label{sec:graph-theory}\n\n\\subsection{Directed Graph}\n\\label{sec:digraph}\n\nA \\textbf{directed graph}, or just \\textbf{digraph} $D$ is a non-empty\nset $V$ together with an \\emph{antireflexive\n  relation}\\ref{sec:reflexivity} $E$ on $V$. The elements of $E$ are\nthe \\textbf{arcs}\\ref{sec:arc}.\n\n\\subsubsection{Arc}\n\\label{sec:arc}\n\nLet $G = (V, E)$ be a digraph. The \\textbf{arcs} are the elements of\n$E$. If $e \\in E$ is an \\textbf{arc} joining the vertex $u$ to the\nvertex $v$, it is denoted as $uv$.\n\n\n\\subsection{Directed Walk}\n\\label{sec:directed-walk}\n\nLet $G = (V, A)$ be a directed graph. A \\textbf{directed walk} in $G$\nis a finite or infinite \\textit{sequence}\\ref{sec:sequence} $\\pair{x_k}$\nsuch that:\n\n\\begin{math}\n  \\begin{array}{c}\n    \\\\\n    \\forall k \\in \\mathbb{N}: k+1 \\in \\mathtt{Dom}( \\pair{x_k} ): (x_k, x_{k+1} ) \\in A \\\\\n    \\\\\n  \\end{array}\n\\end{math}\n\n\n\\subsection{Reachability}\n\\label{sec:reachability}\n\nLet $G = (V, A)$ be a directed graph.\n\n\\paragraph{Definition 1}\n\nLet $u, v \\in V$. The $v$ is \\textbf{reachable} from $u$ if and only\nif there exists a \\textit{directed walk} from $u$ to $v$.\n\n\n\\paragraph{Definition 2}\n\nThe \\textbf{reachability relation} of $G$ is the \\textit{transitive\n  closure}\\ref{sec:transitive-closure} of $A$.\n\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\newpage\n\\section{Soundness and Completeness}\n\n\\subsection{Soundness}\n\n\nIt is called \\textbf{sound} if an analysis for program \\textsl{P} says\nthat it satisfies property \\textsl{S}, then the program will truly\nsatisfy that property.\n\n\\textbf{Sound} but \\textbf{incomplete} analysis have \\textbf{false\n  positive}. In other words, it does \\textbf{not prove} programs that\nsatisfy the property.\n\n\\begin{figure}[h]\n  \\includegraphics[width=\\textwidth]{sound}\n  \\caption{Sound Analysis}\n  \\label{fig:sound}\n\\end{figure}\n\nFigure \\ref{fig:sound} shows a sound analysis (the blue area). It\nproves correctly for the programs $ p_1 $ and $ p_2 $ that satisfy the\nspecification ($S(P)$). However, since this analysis is\n\\textit{incomplete}, it has \\textbf{false positives}: it \\textbf{does\n  not prove} for programs $ p_3 $ and $ p_4 $ that satisfy $S$. In\nother words, it proves that $ p_3 $ and $ p_4 $ satisfy $ \\neg S(P) $\nby emiting \\textbf{alarms}, even though they are actually satisfy\n$ S(P) $. False positives are also called as \\textbf{false alarms}.\n\n\\subsection{Completeness}\n\nAn analysis is called \\textbf{complete} when a program satisfies a\nproperty \\textsl{S}, the analysis for that program says that it will\nsatisfy that property.\n\n\n\\textbf{Complete} but \\textbf{unsound} analysis have \\textbf{false\n  negative}. In other words, it \\textbf{wrongly proves} programs that\ndoes not satisfy the property.\n\n\n\\begin{figure}[h]\n  \\includegraphics[width=\\textwidth]{complete}\n  \\caption{Complete Analysis}\n  \\label{fig:complete}\n\\end{figure}\n\nFigure \\ref{fig:complete} shows a complete analysis (also the blue\narea). It proves all the programs. In other words, it \\textbf{wrongly\n  proves} for programs $ p_5 $ and $ p_6 $ that actually do not\nsatisfy $ S(P) $ by accepting those programs (i.e., emitting no\nalarms), thus it is \\textit{unsound}. Those programs are \\textbf{false\n  negatives}.\n\n\nThe table \\ref{tab:summary} shows the summary of soundness and\ncompleteness.\n\n\\begin{table}[ht]\n  \\centering\n  \\caption{Sound \\& Complete Summary}\n  \\label{tab:summary}\n\n  \\begin{tabular}[t]{l>{\\raggedright}p{0.3\\linewidth}>{\\raggedright\\arraybackslash}p{0.3\\linewidth}}\n    \\hline\n    & $ S(P) $ & $ \\neg S(P) $ \\\\\n    \\hline\n    Prove \\texttt{(accept)} & \\textbf{True negative} (\\textsl{correct inference}) & False negative \\\\\n    Not prove \\texttt{(reject, alarm)} & False positive & \\textbf{True positive} (\\textsl{correct inference}) \\\\\n    \\hline\n  \\end{tabular}\n\\end{table}%\n", "meta": {"hexsha": "30f4a2241aa3e98917e93ab2d7d1b27441a6f3da", "size": 57885, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "theory/pre.tex", "max_stars_repo_name": "skicombinator/nirvana", "max_stars_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2022-01-21T06:14:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-21T06:14:51.000Z", "max_issues_repo_path": "theory/pre.tex", "max_issues_repo_name": "sangwoo-joh/bible-raw-data", "max_issues_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theory/pre.tex", "max_forks_repo_name": "sangwoo-joh/bible-raw-data", "max_forks_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8358831711, "max_line_length": 170, "alphanum_fraction": 0.6635397771, "num_tokens": 19703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.40121065071510964}}
{"text": "\\section{Full proofs}\n\n\\begin{lemma}[Semantic security]\n\\end{lemma}\n\n\\begin{proof}\n    We will prove that if the scheme is not semantically secure, then it is\n    necessarily not reflection secure. Assume that the scheme is not\n    semantically secure. Then there will exist a PPT adversary $\\mathcal{A}$\n    such that for all PPT simulators $\\mathcal{S}$ we have that $\\mathcal{A}$\n    has non-negligible advantage to $\\mathcal{S}$ in the semantic security game.\n\n    We will now construct an adversary $\\mathcal{A'}$ for the reflection\n    security game. $\\mathcal{A'}$ operates as follows: It makes one query to\n    the reflection oracle setting $r_0 = \\epsilon$ and receives a response $c_0\n    = K_k(s, r_0) = K_k(s) = c$. It then passes that $c$ to the semantic\n    security adversary $\\mathcal{A}$. It answers all encryption and decryption\n    queries of the semantic security adversary by relaying them to its own\n    encryption and decryption oracle. Finally, when the semantic security\n    adversary outputs $y = y'$, this $y'$ is output by the reflection security\n    adversary. Note that $\\mathcal{A}$ cannot distinguish whether they are\n    playing against the actual semantic security game or being simulated by the\n    reflection security adversary, as their view is identical. Therefore:\n\n    \\begin{equation}\n        Pr[Game_{REF-SEC}^{\\mathcal{A'}} = 1] = Pr[Game_{SEM-SEC}^{\\mathcal{A}} = 1]\n    \\end{equation}\n\n    It remains to prove that $\\mathcal{A'}$ has significant advantage against\n    any reflection simulator $\\mathcal{S'}$. Indeed let $\\mathcal{S'}$ be any\n    reflection game simulator. We will construct a simulator $\\mathcal{S}$ for\n    the semantic security game. Initially, the simulator $\\mathcal{S}$ receives\n    the length of the ciphertext $|c|$. They then simulate the reflection game\n    simulator $\\mathcal{S'}$ as follows. Upon receiving query $r_i$ from the\n    reflection game simulator, they answer with $|c| + |r_i|$. When the\n    reflection security adversary outputs $y' = y$, this $y$ is output by the\n    semantic security simulator. We observe that the reflection game simulator\n    $\\mathcal{S'}$ cannot distinguish whether they are playing against the\n    actual simulated reflection game or being simulated by the semantic\n    security simulator. To see this, note that from the length preservation\n    assumption we have that $|c| + |r_i| = |K(s, r_i)| = |K(s', r_i)| =\n    |K(0^{|s|}, r_i)|$. Therefore:\n\n    \\begin{equation}\n        Pr[Game_{SEM-SIM}^{\\mathcal{S}} = 1] = Pr[Game_{REF-SIM}^{\\mathcal{S'}} = 1]\n    \\end{equation}\n\n    From the assumption that the scheme is not semantically insecure, we know\n    that:\n\n    \\begin{align*}\n        |Pr[Game_{SEM-SEC}^{\\mathcal{A}} = 1] - Pr[Game_{SEM-SIM}^{\\mathcal{S}} = 1]| =\\\\\n        Adv_{\\mathcal{A}, \\mathcal{S}} = \\text{non-negl}\n    \\end{align*}\n\n    And therefore, replacing both probabilities with their equals:\n\n    \\begin{align*}\n        |Pr[Game_{REF-SEC}^{\\mathcal{A'}} = 1] -\n        Pr[Game_{REF-SIM}^{\\mathcal{S'}} = 1]| =\\\\\n        Adv_{\\mathcal{A'}, \\mathcal{S'}} = \\text{non-negl}\n    \\end{align*}\n\\end{proof}\n\n\\begin{lemma}[Good compression is detectable]\n\\end{lemma}\n\n\\begin{proof}\nWe model our plaintext input to the compression function as the usual pair $(s,\nr)$ consisting of the secret string $s$ and reflection string $r$. When $(s, r)$\nare encoded by a compression function $\\mathcal{K}$ ideal under some plaintext\ndistribution $\\bar{\\mathcal{M}}$, a simple predicate allows the distinction\nbetween two secrets $s_1$ and $s_2$ using a reflection pair $(r_1, r_2)$.  We\nmake the assumption that the resulting reflection pair $(r_1, r_2)$ is\nefficiently computable.\n\n\\begin{align*}\n    \\Pr[r = r_1|s = s_1] < \\Pr[r = r_2|s = s_1]&\\land\\\\\n    \\Pr[r = r_1|s = s_2] > \\Pr[r = r_2|s = s_2]&\n\\end{align*}\n\nUsing the fact that $\\mathcal{K}$ is ideal with respect to this distribution,\nwe deduce that:\n\n\\begin{align*}\n    |\\mathcal{K}(s_1, r_1)| > |\\mathcal{K}(s_1, r_2)|&\\land\\\\\n    |\\mathcal{K}(s_2, r_1)| < |\\mathcal{K}(s_2, r_2)|&\n\\end{align*}\n\nWe then define $Q(s)$ to be the predicate ``$s = s_1$\". This partitions\n$\\mathcal{M}$ into the distributions $\\mathcal{M}_Q$ and\n$\\mathcal{M}_{\\lnot Q}$ both of which are non-empty, as $\\mathcal{M}_Q$\ncontains $s_1$ and $\\mathcal{M}_{\\lnot Q}$ contains $s_2$. From the fact that\n$Q$ is not trivial, we deduce that $\\pi < 1$.\n\nObserve, then, that letting $\\bar{r} = (r_1, r_2)$ we obtain:\n\n\\begin{align*}\n    \\Pr[cpr^Q_{\\mathcal{K}}(s_1, \\bar{r}, \\mathcal{K}, \\mathcal{M})\n    \\land\n    cpr^Q_{\\mathcal{K}}(s_2, \\bar{r}, \\mathcal{K}, \\mathcal{M})] = 1\n\\end{align*}\n\nThis completes the proof.\n\n\\end{proof}\n\n\\begin{lemma}[Compression attack]\n\\end{lemma}\n\n\\begin{proof}\n\nLet $g$ be the boolean function $Q$ on the plaintext. Define the adversary\n$\\mathcal{A}$ as follows:\n\n\\begin{lstlisting}[texcl,mathescape,basicstyle=\\small]\ndef $\\mathcal{A}(1^\\lambda)$:\n    $(r_1, r_2) \\leftarrow \\mathcal{O}_R(1^\\lambda)$\n\n    $l_1 = |\\text{Reflect}^{k}_s(r_1)|$\n    $l_2 = |\\text{Reflect}^{k}_s(r_2)|$\n\n    if $l_1 < l_2$:\n        return True\n    else:\n        return False\n\\end{lstlisting}\n\nLet $\\mathcal{S}$ be an arbitrary simulator. Then we have:\n\\begin{align*}\n    \\Pr[\\text{Game}_{\\text{REF-SIM}}^{\\mathcal{SE},\\mathcal{S}}\n        (\\lambda) = 1] &=\\\\\n    \\Pr_{x \\leftarrow \\mathcal{M}, b \\leftarrow \\mathcal{S}(1^\\lambda)}\n        [Q(x) = b]\n\\end{align*}\n\nLetting the random variables $b$ and $x$:\n\\begin{align*}\n    x &\\leftarrow \\mathcal{M}\\\\\n    b &\\leftarrow \\mathcal{S}(1^\\lambda)\n\\end{align*}\n\nDue to the independence of the simulator's output with the choice of $x$ we have:\n\\begin{align*}\n    Pr[b = Q(x)] &=\\\\\n    Pr[\\lnot b|\\lnot Q(x)]Pr[\\lnot Q(x)] + Pr[b|Q(x)]Pr[Q(x)] &=\\\\\n    Pr[\\lnot b]Pr[\\lnot Q(x)] + Pr[b]Pr[Q(x)] &=\\\\\n    (1 - Pr[b])(1 - Pr[Q]) + Pr[b]Pr[Q(x)] &=\\\\\n    1 - Pr[Q(x)] - Pr[b] + 2Pr[b]Pr[Q(x)]\n\\end{align*}\n\nFor a given $\\Pr[Q]$, this function is monotonic in $\\Pr[b]$ and therefore has\npotential extrema at $\\Pr[b] = 0$ or $\\Pr[b] = 1$, for which cases the function\ntakes the values $1 - \\Pr[Q(x)]$ and $\\Pr[Q(x)]$ respectively. Therefore, the\nmaximum $\\Pr[b]$ of the simulator is:\n\\begin{equation*}\n    \\Pr[Q(x) = b] = max(\\Pr[Q(x)], 1 - \\Pr[Q(x)]) = \\pi\n\\end{equation*}\n\nAnd therefore:\n\\begin{align*}\n    \\forall \\mathcal{S}:\\\\\n    \\Pr[\n        \\text{Game}_{\\text{REF-SIM}}^{\\mathcal{SE},\\mathcal{S}}\n        (\\lambda) = 1\n    ]\n    \\leq\\\\\n    max(Pr[Q(x)], 1 - Pr[Q(x)])\n\\end{align*}\n\nFrom the compression detectability of Q we know that:\n\\begin{align*}\n    \\exists \\alpha \\text{ non-negl}:\\\\\n    \\Pr_{s_1 \\leftarrow \\mathcal{M}_Q,\n         s_2 \\leftarrow \\mathcal{M}_{\\lnot Q}}\n         [cpr^Q_{\\kappa}(s_1, \\overbar{r}) \\land\n          cpr^Q_{\\kappa}(s_2, \\overbar{r})]\n    \\geq\\\\\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nTherefore:\n\\begin{align*}\n    \\Pr_{s_1 \\leftarrow \\mathcal{M}_Q}\n         [cpr^Q_{\\kappa}(s_1, \\overbar{r})]\n    \\geq\n    \\pi + \\alpha(\\lambda) \\land\\\\\n    \\Pr_{s_2 \\leftarrow \\mathcal{M}_{\\lnot Q}}\n         [cpr^Q_{\\kappa}(s_2, \\overbar{r})]\n    \\geq\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nAnd so:\n\\begin{align*}\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n         [cpr^Q_{\\kappa}(s, \\overbar{r})]\n    =\\\\\n    \\Pr[cpr^Q_{\\kappa}(s, \\overbar{r})|Q(s)]\\Pr[Q(s)]\n    +\\\\\n    \\Pr[cpr^Q_{\\kappa}(s, \\overbar{r})|\\lnot Q(s)]\\Pr[\\lnot Q(s)]\n    \\geq\\\\\n    (\\pi + \\alpha(\\lambda))(\\Pr[Q(s)] + (1 - \\Pr[Q(s)))\n    =\\\\\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nLet us now examine the event of $\\mathcal{A}$ being successful, denoted Succ,\nwhen $cpr^Q_{\\kappa}(s, \\overbar{r})$. Assuming $Q(s)$:\n\\begin{align*}\n    \\Pr[|\\mathcal{K}(s, r_1)| < |\\mathcal{K}(s, r_2)||Q(s)]\n    = \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nAnd from the strict length monotonicity of $\\textrm{Enc}$ it follows that:\n\\begin{align*}\n    \\Pr[&|\\textrm{Enc}(\\mathcal{K}(s, r_1))| <\\\\&|\\textrm{Enc}(\\mathcal{K}(s, r_2))||Q(s)]\n        \\geq \\pi + \\alpha(\\lambda)\\\\\n    \\Rightarrow \\Pr[&\n        |\\text{Reflect}^{k}_s(r_1)|\n        <\n        |\\text{Reflect}^{k}_s(r_2)||Q(s)\n    ]\n        \\geq \\pi + \\alpha(\\lambda)\\\\\n    \\Rightarrow \\Pr[&l_1 < l_2|Q(s)]\n        \\geq \\pi + \\alpha(\\lambda)\\\\\n    \\Rightarrow \\Pr[&\\text{Succ}|Q(s)]\n        \\geq \\pi + \\alpha(\\lambda)\\\\\n\\end{align*}\n\nThe case for $\\lnot Q(s)$ is the same, but with a different inequality direction:\n\\begin{align*}\n    \\Pr[|\\mathcal{K}(s, r_1)| > |\\mathcal{K}(s, r_2)||\\lnot Q(s)]\n        \\geq\\\\\n        \\pi + \\alpha(\\lambda)\\\\\n    \\Rightarrow \\Pr[\\text{Succ}|\\lnot Q(s)] \\geq\\\\\n    \\pi + \\alpha(\\lambda)\\\\\n\\end{align*}\n\nAnd so the probability of success is given:\n\\begin{align*}\n    \\Pr[\\text{Succ}] =\\\\\n    \\Pr[\\text{Succ}|Q(s)]\\Pr[Q(s)]\n    +\n    \\Pr[\\text{Succ}|\\lnot Q(s)]\\Pr[\\lnot Q(s)] \\geq\\\\\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nTherefore,\n\\begin{align*}\n    \\forall PPT \\mathcal{S}:\n    \\text{Adv}_{\\mathcal{SE}(\\textrm{Enc}, \\textrm{Com}), \\mathcal{A}, \\mathcal{S}}\n        (1^\\lambda)\n    \\geq\\\\\n    |\\pi + \\alpha(\\lambda) - \\pi| = \\alpha(\\lambda)\n\\end{align*}\n\nWhich is non-negligible.\n\n\\end{proof}\n\n\\begin{lemma}[Amplification]\n\\end{lemma}\n\n\\begin{proof}\n\nFrom the fact that $Q$ is compression-detectable and from the Compression Attack Theorem, we have that:\n\\begin{align*}\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n         [cpr^Q_{\\kappa}(s, \\overbar{r})]\n    =\\\\\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nSome elements $s \\in \\mathcal{M}$ allow for better compression detectability than others under the fixed\nreflection vector $\\overbar{r}$. Call these elements \\textit{amplifiable} and define predicate:\n\\begin{align*}\n    Amp(s) \\defeq\n    \\Pr[cpr^Q_{\\kappa}\n     (s, \\overbar{r})]\n    \\geq\n    \\frac{1}{2} + \\frac{\\alpha(\\lambda)}{2}\n\\end{align*}\n\nWe will now obtain a lower bound on the probability of an element being amplifiable.\n\nLet:\n\n% B derivation: (where \\beta(\\lambda) = \\alpha(\\lambda) / 2)\n% B + (\\frac{1}{2} + \\alpha(\\lambda)/2)(1 - B) = \\pi + \\alpha(\\lambda)\n% B + \\frac{1}{2} + \\alpha(\\lambda)/2 - B(\\frac{1}{2} + \\beta(\\lambda)) = \\pi + \\alpha(\\lambda)\n% \\frac{1}{2} + \\beta(\\lambda) + B(\\frac{1}{2} - \\beta(\\lambda)) = \\pi + \\alpha(\\lambda)\n% B(\\frac{1}{2} - \\beta(\\lambda)) = \\pi + \\alpha(\\lambda) - \\frac{1}{2} - \\beta(\\lambda)\n% B = (\\pi + \\alpha(\\lambda) - \\frac{1}{2} - \\beta(\\lambda)) / (\\frac{1}{2} - \\beta(\\lambda))\n% B = (\\pi + \\alpha(\\lambda) - \\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2}) / (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2})\n% B = (\\pi - \\frac{1}{2} + \\frac{\\alpha(\\lambda)}{2}) / (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2})\n% B = \\pi / (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2}) - (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2}) / (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2})\n% B = \\pi / (\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2}) - 1\n\\begin{align*}\n    B = \\frac{\\pi}{\\frac{1}{2} - \\frac{\\alpha(\\lambda)}{2}} - 1\n\\end{align*}\n\n$B$ is non-negligible in $\\lambda$.\n\nAssume, for the sake of contradiction, that:\n\\begin{align*}\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n    [Amp(s)] < B\n\\end{align*}\n\nThen we have:\n\\begin{align*}\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n         [cpr^Q_{\\kappa}(s, \\overbar{r})]\n    =\\\\\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n         [cpr^Q_{\\kappa}(s, \\overbar{r})|Amp(s)]\\Pr[Amp(s)]\n    +\\\\\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n         [cpr^Q_{\\kappa}(s, \\overbar{r})|\\lnot Amp(s)]\\Pr[\\lnot Amp(s)]\n    <\\\\\n    B + (\\frac{1}{2} + \\frac{\\alpha}{2})(1 - B)\n\\end{align*}\n\nBut then:\n\\begin{align*}\n    B + (\\frac{1}{2} + \\frac{\\alpha(\\lambda)}{2})(1 - B) =\n    \\pi + \\alpha(\\lambda)\n\\end{align*}\n\nAnd this contradicts the assumption that $Q$ is compression-detectable. Therefore:\n\\begin{align*}\n    \\Pr_{s \\leftarrow \\mathcal{M}}\n    [Amp(s)] \\geq B\n\\end{align*}\n\nIt remains to show that the advantage of the adversary can be\narbitrarily large, i.e. that for some negligible $C$ we have:\n\\begin{align*}\n    \\text{Adv}_{\\mathcal{SE}(\\textrm{Enc}, \\textrm{Com}), \\mathcal{A}, \\mathcal{S}_{Amp}}\n    (1^\\lambda) = 1 - \\pi - C\n\\end{align*}\n\nIndeed, observe that the amplifying adversary performs a repeated Bernoulli\ntrial with $k$ repetitions and extracts a majority. Let $X$ be the number of\nrepetitions that are successful for the adversary. $X$ is defined:\n\\begin{align*}\n    X \\defeq |\\{ i: cpr^Q_{\\kappa}(s, \\overbar{r}) \\}|\n\\end{align*}\n\n$X$ follows the binomial distribution, and therefore its expected value is:\n\\begin{align*}\n    E[X] = \\frac{k}{2} + \\frac{\\alpha k}{2}\n\\end{align*}\n\nLet Succ denote the event of the amplified adversary succeeding. Then Succ\nis equivalent to $X > \\frac{k}{2}$.\n\nBecause $\\alpha$ is non-negligible and due to the tail bounds of the binomial\ndistribution, we have:\n\\begin{align*}\n    Pr[Succ] = 1 - C(k)\n\\end{align*}\n\nWhere $C$ is a negligible function.\n\\end{proof}\n\n\\begin{lemma}[Reflection-independent security]\n    Let $E$ be a length-preserving semantically secure encryption schema and\n    $Com$ be any function. Then $E(s)$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    Let $\\mathcal{A}$ be a reflection security adversary for $E(s)$. We will\n    construct a semantic security adversary $\\mathcal{A'}$ for $E$. Our semantic\n    security adversary will break semantic security for \\textit{multiple\n    messages}. Let $\\mathcal{M}$ be the distribution that $\\mathcal{A}$\n    attacks. Because $\\mathcal{A}$ is a probabilistic polynomial-time\n    adversary, there is a polynomial bound $t(\\lambda)$ for its execution time.\n    The number of reflection queries conducted by $\\mathcal{A}$ is then also\n    bound by $t(\\lambda)$.\n\n    Define $\\mathcal{M'}$ by the following procedure: First, $s$ is chosen\n    out of the distribution $\\mathcal{M}$. Then that same $s$ is repeated\n    $t(\\lambda)$ times to obtain the vector of plaintexts $\\overbar{s}$.\n\n    Upon execution, $\\mathcal{A'}$ receives from its challenger the encrypted\n    vector $\\overbar{c}$ where the same plaintext has been independently\n    encrypted $t(\\lambda)$ times.\n    $\\mathcal{A'}$ answers encryption and decryption queries of $\\mathcal{A}$\n    by forwarding them to its own encryption and\n    decryption oracles. For reflection queries, because the schema trivially\n    ignores $r$ since $E(s)$ is independent of $r$, the semantic security\n    adversary is able to answer each query $r_i$ with $c_i$.\n\n    Clearly, the view of the simulated reflection adversary is the same as if\n    it were run in an actual reflection game. Therefore we have:\n\n    \\begin{align*}\n        Pr[\\text{Game}_{\\text{REF-SEC}}^{\\mathcal{A}}(1^{\\lambda})\n        = 1]\n        =\n        Pr[\\text{Game}_{\\text{SEM-SEC}}^{\\mathcal{A'}}(1^{\\lambda})\n        = 1]\n    \\end{align*}\n\n    We now prove that the adversary $\\mathcal{A'}$ obtains a non-negligible gap\n    against any semantic security simulator $\\mathcal{S'}$. Indeed let\n    $\\mathcal{S'}$ be any semantic security simulator. We will construct a\n    reflection security simulator $\\mathcal{S}$. $\\mathcal{S}$ works as\n    follows: It obtains $|Com(s)|$ from its challenger which it ignores. It\n    then issues a single reflection query $r_1 = \\epsilon$, to which the\n    challenger responds with $c = E(s')$. But $|c| = |E(s')| = |s'| =\n    |0^{|s|}| = |s| = |E(s)| = |c|$ due to length preservation. This $|c|$ is\n    then used to start the semantic security simulator.\n\n    The view of the simulated semantic simulator is the same as if it were run\n    in an actual semantic simulation game. Therefore we have:\n\n    \\begin{align*}\n        Pr[\\text{Game}_{\\text{REF-SIM}}^{\\mathcal{S}}(1^{\\lambda})\n        = 1]\n        =\n        Pr[\\text{Game}_{\\text{SEM-SIM}}^{\\mathcal{S'}}(1^{\\lambda})\n        = 1]\n    \\end{align*}\n\n    Because there exists a non-negligible advantage between $\\mathcal{A}$ and\n    any simulator $\\mathcal{S}$, this gap will also exist between the\n    constructed simulator $\\mathcal{S}$. Therefore, we have:\n\n    \\begin{align*}\n        \\text{non-negl} = \\text{Adv}_{\\text{REF} \\mathcal{A}, \\mathcal{S}}\\\\\n        =\n        Pr[\\text{Game}_{\\text{REF-SEC}}^{\\mathcal{A}}\n        = 1] -\n        Pr[\\text{Game}_{\\text{REF-SIM}}^{\\mathcal{S}}\n        = 1]\\\\\n        =\n        Pr[\\text{Game}_{\\text{SEM-SEC}}^{\\mathcal{A'}}\n        = 1]\n        -\n        Pr[\\text{Game}_{\\text{SEM-SIM}}^{\\mathcal{S'}}\n        = 1]\\\\\n        =\n        \\text{Adv}_{\\text{SEM} \\mathcal{A'}, \\mathcal{S'}}\n    \\end{align*}\n\n    For clarity, we have omitted the security parameters from the games.\n    This completes the proof.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions, $E(s) || r$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    The construction is identical to the previous proof. However, the\n    reflection queries of the reflection adversary $\\mathcal{A}$ must be\n    answered correctly. As $r_i$ is known to the semantic security adversary,\n    this can be done in the obvious way by setting $c_i' = c_i || r_i$.\n\n    The reflection security simulator is not affected, as it receives $|c| =\n    |Enc(s) || \\epsilon| = |Enc(s)|$.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions and letting $Com$ be a deterministic\n    efficiently computable function, $E(s)$ $||$ $Com(r)$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    The construction is the same as before. Because the semantic security\n    adversary has access to the $Com$ function, it can calculcate $Com(r_i)$\n    upon receiving the query $r_i$. Then setting $c_i = E(s) || Com(r_i)$ it\n    responds as usual.\n\n    The reflection simulator on the other hand will be affected by this\n    construction. Indeed $|c| = |E(s') || Com(\\epsilon)|$. However,\n    $|Com(\\epsilon)|$ can be computed by the simulator, and therefore the value\n    given to the semantic simulator can be obtained as $|c'| = |E(s)| = |E(s')|\n    = |c| - |Com(\\epsilon)|$.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions and additionally requiring that $Com$ is a\n    bijection which is also efficiently reversible, $E(Com(s))$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    This construction is slightly more complicated. Assuming $\\mathcal{A}$ is a\n    reflection-security adversary which works against the distribution\n    $\\mathcal{M}$ we will construct a multiple messages semantic security\n    adversary as before. However, the distribution $\\mathcal{M'}$ will now be\n    obtained by the following procedure: Initially, $s$ is chosen out of\n    $\\mathcal{M}$. Then $Com(s)$ is calculated. This value is then repeated\n    $t(\\lambda)$ times. Our semantic security adversary will work against\n    $\\mathcal{M'}$.\n\n    When the challenger produces the encrypted vector $\\overbar{c}$, it will\n    contain $t(\\lambda)$ encryptions of the plaintext $Com(s)$. These can\n    readily now be passed to the reflection adversary as reflection query\n    responses as before.\n\n    The reflection security simulator now makes use of the $|Com(s)|$ input,\n    which it uses to start up the semantic security simulator.\n\n    We now argue that the advantage obtained pertains to a valid predicate on\n    the compressed plaintexts space. Indeed, without loss of generality assume\n    that $g$ is a predicate. Then $g$ partitions the plaintext space into two\n    partitions. Due to $Com$ being a bijection, these partitions are preserved\n    after compression and the plaintext predicate $g$ is isomorphic to a\n    compressed text predicate $g'$. Therefore, the semantic security adversary\n    is able to obtain a non-negligible advantage for a different predicate.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions, $E(Com(s)) || r)$, \\break$E(Com(s)) || E(r))$, and\n    $E(Com(s)) || E(Com(r))$ are all reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    The proofs for the above schemas can be combined in the obvious way to\n    obtain the result needed.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions, $E(s || r)$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    We provide a sketch of this proof.\n\n    To obtain this proof, we construct a semantic security adversary which\n    works against a distribution $\\mathcal{M'}$ defined as follows. First, $s$\n    is chosen out of $\\mathcal{M}$. Because the reflection security adversary\n    is bounded in time by $t(\\lambda)$, therefore each of the reflection\n    queries $r_i$ must be $|r_i| < t(\\lambda)$. The distribution $\\mathcal{M'}$\n    then will contain $t(\\lambda)$ different vectors, each of dimension\n    $t(\\lambda)$. We require that the $j$-th $t$-dimensional vector contains\n    the same secret text $s$ and an independently chosen reflection text $r$\n    with $|r| = j$.\n\n    Then the semantic security adversary $\\mathcal{A'}$ works as follows: Upon\n    receiving the reflection query $r_i$ from the reflection adversary, it\n    responds with a fresh element from the $i$-th vector, which contains the\n    encryption of an incorrect reflection string chosen uniformly at random. We\n    call these \\textit{mock} reflections, and notice that the mock reflection\n    has the same length as the actual reflection query.\n\n    We now argue that either this semantic security adversary is able to obtain\n    a valid predicate for $s$, or that we have obtained a distinguisher for the\n    value $r$.\n\n    To do this, invoke a hybrid argument on the sequence of adversaries $B_i$\n    such that the $i$-th adversary works as follows: It responds to the\n    reflection queries $r_1, r_2, \\cdots, r_i$ as $\\mathcal{A'}$ would,\n    using the mock reflections, but responds to the queries $r_{i+1},\n    \\cdots, r_{t(\\lambda)}$ using the correct reflections. Clearly,\n    $\\mathcal{A'} = B_{t(\\lambda)}$. If for all $j$ we have that $B_j$'s output\n    is computationally indistinguishable from $B_{j+1}$'s output, we are done,\n    since this would allow the construction of $\\mathcal{A'}$ that obtains a\n    non-negligible advantage. However, if for some $j$ we have that $B_j$'s\n    output is computationally distinguishable from $B_{j+1}$, then this\n    directly allows the construction of a semantic security adversary which is\n    able to distinguish between different $r$ values. The intuition behind this\n    is that since the mock and actual reflection queries have the same length,\n    the assumption of semantic security should not allow the reflection\n    adversary to tell apart the two reflection responses.\n\\end{proof}\n\n\\begin{lemma}\n    Under the above assumptions, $E(Com(s)$ $||$ $Com(r))$ is reflection secure.\n\\end{lemma}\n\n\\begin{proof}\n    The above lemma follows directly from the fact that $E(s || r)$ is\n    reflection secure using the techniques previously used to obtain the\n    reflection security of $E(Com(s))$ and $E(Com(s))$ $||$ $E(Com(r))$. For the\n    compression of the secret, the key intuition is that the reflection\n    adversary has access to $|Com(s)|$, that the predicate attacked will be an\n    isomorphic predicate on compression space instead of plaintext space, and\n    that the distribution attacked will be the compression distribution instead\n    of the plaintext distribution. This is readily obtained from the fact that\n    $Com$ is a bijection. For the $Com(r)$ portion, the only\n    requirement is that the compression function is accessible to both the\n    semantic security adversary as well as the reflection security simulator,\n    which is true under the assumption that $Com(r)$ is deterministic.\n\\end{proof}\n", "meta": {"hexsha": "52328d582024a39d5be69fe5b12918cdea41f1ee", "size": 23245, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "etc/theory/sections/appendix.tex", "max_stars_repo_name": "Cancelll/rupture", "max_stars_repo_head_hexsha": "cd87481717b39de2654659b7ff436500e28a0600", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 184, "max_stars_repo_stars_event_min_datetime": "2016-03-31T04:19:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-26T21:37:12.000Z", "max_issues_repo_path": "etc/theory/sections/appendix.tex", "max_issues_repo_name": "Cancelll/rupture", "max_issues_repo_head_hexsha": "cd87481717b39de2654659b7ff436500e28a0600", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 212, "max_issues_repo_issues_event_min_datetime": "2016-03-31T04:32:06.000Z", "max_issues_repo_issues_event_max_datetime": "2017-02-26T09:34:47.000Z", "max_forks_repo_path": "etc/theory/sections/appendix.tex", "max_forks_repo_name": "Cancelll/rupture", "max_forks_repo_head_hexsha": "cd87481717b39de2654659b7ff436500e28a0600", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 38, "max_forks_repo_forks_event_min_datetime": "2016-03-31T09:09:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-26T21:37:13.000Z", "avg_line_length": 39.3983050847, "max_line_length": 141, "alphanum_fraction": 0.6491718649, "num_tokens": 7312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.40121064735034023}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage{reduce}\n\\usepackage{fancyhdr}\n\\usepackage{amsmath}\n\n\\title{ A new exp-log limits package for \\REDUCE}\n\\author{Neil Langmead \\\\\n        Konrad-Zuse-Zentrum f\\\"ur Informationstechnik (ZIB) \\\\ \n        Takustrasse 7  \\\\\n        D- 14195 Berlin Dahlem \\\\\n        Berlin\n        Germany}\n\\date{January 1997}\n\n\\def\\foottitle{Limits}\n\\pagestyle{fancy}\n\\lhead[]{{\\footnotesize\\leftmark}{}}\n\\rhead[]{\\thepage}\n\\renewcommand{\\headrulewidth}{0.6pt}\n\\renewcommand{\\footrulewidth}{0.6pt}\n\\addtolength{\\oddsidemargin}{-20 mm}\n\\addtolength{\\textwidth}{25 mm}\n\\pagestyle{fancy}\n\\setlength{\\headheight}{14pt}\n\\setlength{\\topmargin}{1 mm}\n\\setlength{\\footskip}{10 mm}\n\\setlength{\\textheight}{220 mm}\n\\cfoot{}\n\\rfoot{\\small\\foottitle}\n\n\\begin{document}\n\\maketitle\n\\pagebreak\n\\tableofcontents\n\\pagebreak\n\\section{The Exp-Log Limits package}\nThis package  arises from the PhD thesis of Dominik Gruntz, of the ETH  Z\\\"{u}rich. He developed a new algorithm to compute limits of \"exp-log\" functions. Many of the examples he gave were unable to be computed by the present limits package in \\REDUCE, the simplest example being the following, whose limit is obviously $0$:\n\\begin{verbatim}\nload limits;\n\nlimit(x^7/e^x,x,infinity);\n\n        7\n       x\nlimit(----,x,infinity)\n        x\n       e\n\\end{verbatim}\n\nThis particular problem arises, because L'Hopital's rule for the computation of indefinite forms (such as $0/0$, or $\\frac{\\infty}{\\infty}$) can only be applied in a CAS a finite number of times, and in \\REDUCE~\\cite{Red36}, this number is 3. Applied 7 times to the above problem would have yielded the correct answer 0. \nThe new algorithm solves this particular problem, and enables the computation of many more limit calculations in \\REDUCE. We first define the domain in which we work, and then give a statement of the main algorithm that is used in this package. \\\\[\\baselineskip]\nDefinition: \\\\\nLet $\\Re[x]$ be the ring of polynomials in $x$ with real coefficients, and let $f$ be an element in this ring. The field which is obtained from $\\Re[x]$ by closing it under the operations $f \\rightarrow \\exp(f)$ and $f$ $\\rightarrow\\log |f|$ is called the $L$- field (or logarithmico-exponential field, or field of exp-log functions for short).\n\\\\[\\baselineskip]\nHardy proved that every $L$ function is ultimately continuous, of constant sign, monotonic, and tends to $\\pm \\infty$ or to a finite real constant as $x\\rightarrow +\\infty.$\n\nHere are some examples of exp-log functions, which the package is able to deal with: \n\\begin{align*}\n f(x) &=e^{x}*\\log(\\log(x)) \\\\\n f(x) &=\\frac{\\log(\\log(x+e^{-x}))}{e^{x^{2}}+\\log(\\log(x))}  \\\\\n f(x) &=\\log(x)^{\\log(x)}  \\\\\n f(x) &=e^{x*\\log(x)} \n\\end{align*}\n\n\\section{The Algorithm}\nA complete statement of the algorithm now follows:\nLet $f$ be a log-exp function in $x$, whose limit we wish to compute as $x\\rightarrow x_0.$ The main steps of the algorithm to do this are as follows:\n\\begin{itemize}\n\\item{Determine the set $\\Omega$ of the most rapidly varying subexpressions of $f(x)$. Limits may have to be computed recursively at this stage.}\n\\item{Choose an expression $\\omega$ such that $\\omega>0$, $\\lim_{x \\rightarrow \\infty} \\omega=0 $ and $\\omega$ is in the same comparability class as any element of $\\Omega$. Rewrite the other expressions in $\\Omega$ as $A(x)\\omega^{c}$, where $A(x)$ only contains subexpressions in lower comparability classes than $\\Omega$.}\n\\item{Let $f(\\omega)$ be the function obtained from $f(x)$ by replacing all elements of $\\Omega $ by their representation in terms of $\\omega$. Consider all expressions independent of $\\omega$ as constants and compute the leading term of the power series of f($\\omega$) around $\\omega=0^{+}$ }\n\\item{If the leading exponent $e_0>0$, then the limit is 0, and we stop. If the leading exponent $e_0<0$ then the limit is $\\pm \\infty$. The sign is defined by the sign of the leading coefficient $c_0$. If the leading exponent $e_0=0$ then the limit is the limit of the leading coeficient $c_0$. If $c_0$ $\\not \\in C$, where $C=\\text{Const}(L)$, the set of exp-log constants, we apply the same algorithm recursively on $c_0$.}\n\\end{itemize}\n%}}\nThe algorithm to compute the most rapidly varying subset (the mrv set) of a function f is given below:\n%\\vspace{5 mm}\n\\begin{tabbing}      \nprocedure mrv(f) \\= \\\\ % f an exp log function in $x$ \\\\\n  if (not (depend(f,$x$)))  $\\rightarrow$ return (\\{\\}) \\\\\n  \\> else if $f=x \\rightarrow$   return(\\{$x$\\}) \\\\\n \\> else if $f=gh$  $\\rightarrow$   return(max(mrv(g),mrv(h))) \\\\\n  else if $f=g+h$ $\\rightarrow$   return(max(mrv(g),mrv(h))) \\\\\n  else if $f=g^{c}$ and c $\\in C \\rightarrow$   return(mrv(g)) \\\\\n  else if $f=log(g)$ $\\rightarrow$   return(mrv(g)) \\\\\n  else if \\= $f=e^{g}$ $\\rightarrow$  \\\\\n   \\>   if $\\lim_{x \\rightarrow \\infty} g=\\pm\\infty \\rightarrow$ \\\\\n   \\>        return(max(\\{$e^{g}$\\}, mrv(g))) \\\\\n    \\>  else $\\rightarrow $ return mrv(g) \\\\\n\\bf{end}\n\\end{tabbing}\n\n%\\vspace{5 mm}\nThe function max() computes the maximum of the two sets of expressions. Max() compares two elements of its argument sets and returns the set which is in the higher comparability class or the union of both if they have the same order of variation. \\\\[\\baselineskip]\n%\nFor further details, proofs and explanations of the algorithm, please consult~\\cite{Grn96}.\n\\pagebreak\n\nFor example, we have\n\\begin{align*}\n&\\text{mrv}(e^{x})=\\{e^x\\} \\\\\n&\\text{mrv}(log(log(log(x+x^2+x^3))))=\\{x\\}  \\\\\n&\\text{mrv}(x)=\\{x\\} \\\\\n&\\text{mrv}(e^x+e^{-x}+x^2+x \\log(x))= \\{e^x,e^{-x} \\} \\\\\n&\\text{mrv}(e^{e^{-x}})=\\{e^{-x} \\} \n\\end{align*}\n\n\\subsection{Mrv\\_limit Examples}\nConsider the following in \\REDUCE:\n\\begin{verbatim}\nmrv_limit(e^x,x,infinity);\n\ninfinity\n\nmrv_limit(1/log(x),x,infinity);\n\n0\n\nb:=e^x*(e^(1/x-e^-x)-e^(1/x));\n\n\n           -1        - x\n      x + x      - e\nb := e       *(e         - 1)\n\n\nmrv_limit(b,x,infinity);\n\n\n-1\n\n\n                                       -1\n  ex:=  - log(log(log(log(x))) + log(x))  *log(x)\n\n                       *(log(log(x)) - log(log(log(x)) + log(x)));\n\n\n            - log(x)*(log(log(x)) - log(log(log(x)) + log(x)))\nex:=     -----------------------------------------------------\n                    log(log(log(log(x))) + log(x))\n\noff mcd;\n\nmrv_limit(ex,x,infinity);\n\n1\n\n\n(log(x+e^-x)+log(1/x))/(log(x)*e^x);\n\n  - x       -1       -1          - x\ne    *log(x)  *(log(x  ) + log(e     + x));\n\nmrv_limit(ws,x,infinity);\n\n0\n\nmrv_limit((log(x)*e^-x)/e^(log(x)+e^(x^2)),x,infinity);\n\n0\n\n\\end{verbatim}\n\\normalsize\n\\section{The tracing facility}\nThe package provides a means of tracing the $mrv\\_limit$ function at its main steps, and is intended to help the user if he encounters problems. Messages are displayed informing the user which Taylor expansion is being computed, all recursive calls are listed, and the value returned by the $mrv$ function is given. This information is displayed when  a switch $tracelimit$ is on. This is off by default, but can be switched on with the command\n\\begin{verbatim}\non tracelimit;\n\\end{verbatim}\nFor a more complete examination of the workings of the algorithm, the user could also try the command\n\\begin{verbatim}\ntr mrv_limit;\n\\end{verbatim}\nThis is not recommended, as the amount of information returned is often huge and difficult to wade through.\nHere is a simple example in \\REDUCE:\n\\begin{verbatim}\n\nLoading image file: /silo/cons/reduce35/Alpha/binary/redu37a.img\nREDUCE Development Version,  4-Nov-96 ...\n\n1: load mrvlimit;\n\n2: on tracelimit;\n\n3: mrv_limit(e^x,x,infinity);\n\nmrv_f is {x}\n\n                     x\nAfter move_up, f is e\n\n                        -1\nperforming taylor on: ww\n\n                      -1\nseries expansion is ww\n\n            -1\nseries is ww\n\nexponent list is {expt,-1}\n\nleading exponent e0 is {expt,-1}\n\n           x\nmrv_f is {e }\n\nh is x\n\nmrv_f is {x}\n\n                     x\nAfter move_up, f is e\n\n                        -1\nperforming taylor on: ww\n\n                      -1\nseries expansion is ww\n\n            -1\nseries is ww\n\nexponent list is {expt,-1}\n\nleading exponent e0 is {expt,-1}\n\n                            - x\nsmall has been changed to e\n\n                                 -1\nAfter substitution to ww, f is ww\n\n                        -1\nperforming taylor on: ww   \n\n                      -1\nseries expansion is ww\n\n            -1\nseries is ww\n\nexponent list is {expt,-1}\n\nleading exponent e0 is {expt,-1}\n\ninfinity\n\\end{verbatim}\n\\vspace{10 mm}\nNote that, due to the recursiveness of the functions $mrv$ and $mrv\\_limit$, many calls to each function are made, and information is given on all calls when the \\emph{tracelimit} switch is on.\n\n\\section{Comments, Bug reports and Suggestions}\nThis package was written when the author was a placement student at ZIB Berlin. Please address all comments, bugs and suggestions to Winfried Neun, ZIB, Takustrasse 7, D-14195 Berlin Dahlem, Germany, or e/mail neun@zib.de. \n\\pagebreak\n\\begin{thebibliography}{99}\n\\normalsize\n\n\\bibitem[Grn96]{Grn96} Gruntz, Dominik,\n\\textit{On Computing Limits in a Symbolik Manipulation System}, \\\\\nPhD Thesis, ETH Z\\\"urich\n\n\\bibitem[Red36]{Red36} Hearn, Anthony C. and Fitch, John F.\n\\textit{REDUCE User's Manual 3.6}, \\\\ RAND Corporation, 1995\n\n\\end{thebibliography}\n\\end{document}\n", "meta": {"hexsha": "ffe2a86d389f2342af0c2719fb9c095fea9d0ab0", "size": 9250, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "packages/mrvlimit/mrvlimit.tex", "max_stars_repo_name": "arthurcnorman/general", "max_stars_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/mrvlimit/mrvlimit.tex", "max_issues_repo_name": "arthurcnorman/general", "max_issues_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/mrvlimit/mrvlimit.tex", "max_forks_repo_name": "arthurcnorman/general", "max_forks_repo_head_hexsha": "5e8fef0cc7999fa8ab75d8fdf79ad5488047282b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6441947566, "max_line_length": 444, "alphanum_fraction": 0.6577297297, "num_tokens": 2724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.40121064398557077}}
{"text": "\\documentclass{article}\n\\usepackage[section]{placeins}\n\\usepackage{graphicx, wrapfig, amsmath, amssymb, physics, hyperref}\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    filecolor=magenta,      \n    urlcolor=cyan,\n    }\n\n\\author{Yaghoub Shahmari}\n\\title{Report - Problem Set No 5}\n\\date{\\today}\n\\graphicspath{ {../Figs/} }\n\n\\begin{document}\n    \\maketitle\n    \\section*{Problem 1}\n    \\textbf{Basic description:}\n\n    In this problem, we're going to discuss 2D Random Walkers.\n    As the lecture notes described, we expect our results to show these relations:\n\n    \\begin{gather*}\n        \\langle r^{2}\\rangle =2dDt,D=\\dfrac{l^{2}}{2dr}\\\\\n        R_{g}=\\sqrt{\\langle r^{2}\\rangle },\\tau =l=1,d=2\\\\\n        \\Rightarrow R_{g}=\\sqrt{t}\n    \\end{gather*}\n    \n    The simulation creates a list of random choices of steps\n    and calculates the sum of total changes of location of the random walker.\n    The number of chosen random steps is equal to $t$.\n    We repeat the simulation for different $t$ many times\n    and calculate the gyration radius of the all of final positions of each $t$.\n\n    \\textbf{Results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q1/Q1-Rg(t)}\n        \\label{fig:1.1}\n        \\caption{Gyration radius of each time step.}\n    \\end{figure}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q1/Q1-2DHist1}\n        \\label{fig:1.2}\n        \\includegraphics[scale = 0.4]{/Q1/Q1-2DHist2}\n        \\label{fig:1.3}\n        \\includegraphics[scale = 0.4]{/Q1/Q1-2DHist3}\n        \\label{fig:1.4}\n        \\caption{2D Histogram, Shows distribute of Random Walkers in 10th, 100th, and 1000th time step.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 2}\n    \\textbf{Basic description:}\n\n    In this problem, we're going to simulate Diffusion-Limited Aggregation and apply some limitations on 2D Random Walkers.\n    We consider a network that has a periodic boundary from sides,\n    a fixed floor, and a non-fixed boundary on top.\n    We continue to release particles until the roof reaches a specific location.\n    \n    \\textbf{Results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q2/Q2-HM}\n        \\label{fig:2.1}\n        \\caption{Distribution of Diffusion-Limited Aggregation. An animation is provided in Figs folder.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 3}\n    \\textbf{Basic description:}\n\n    In this problem,\n    we're going to count the number of Self-Avoiding Walks of a Random walker.\n    A normal random walker has a $4^N$ possible way to navigate $N$ step on a surface.\n    It is a simple permutation of 4 choices.\n    To find every possible way of navigation using an algorithm,\n    we need N fors to check every way.\n    Instead of using N fors we can just call a rescue function\n    that calls itself within itself exactly N times.\n    If we check avoidance then call the function,\n    we can count the number of Self-Avoiding Walks.\n    \n    \\textbf{Results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.25]{/Q3/Q3-1}\n        \\label{fig:3.1}\n        \\includegraphics[scale = 0.25]{/Q3/Q3-2}\n        \\label{fig:3.2}\n        \\includegraphics[scale = 0.5]{/Q3/Q3-3}\n        \\label{fig:3.3}\n        \\caption{Plots (log-log and normal scale plot and ratio plot) that shows the growth of the count of ways.}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 4}\n    \\textbf{Basic description:}\n\n    In this problem, we're going to study the Random number generator.\n    Initially, we make a sample of random numbers in [0,9] and show the distribution.\n    Then check the coefficient of variation and its relation to the value of N.\n    \n    \\textbf{Results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q4/Q4-Hist}\n        \\label{fig:4.1}\n        \\includegraphics[scale = 0.4]{/Q4/Q4-Scat}\n        \\label{fig:4.2}\n        \\caption{As you can see, the data shows the distribution of Numbers follows the $Y = \\frac{N}{10}$ and for CV we have $\\frac{\\sigma}{N}~N^{-0.5}$}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\section*{Problem 5}\n    \\textbf{Basic description:}\n\n    In this problem, we do the same thing we have done for the previous Question,\n    but instead of analyzing the sample we gathered from the random generator,\n    we sample the numbers. We only choose the numbers came before the 4.\n\n    \\textbf{Results:}\n\n    \\begin{figure}[!htb]\n        \\centering\n        \\includegraphics[scale = 0.4]{/Q5/Q5-Hist}\n        \\label{fig:5.1}\n        \\includegraphics[scale = 0.4]{/Q5/Q5-Scat}\n        \\label{fig:5.2}\n        \\caption{As you can see, the data shows the distribution of Numbers follows the $Y = \\frac{N}{10}$ and for CV we have $\\frac{\\sigma}{N}~N^{-0.5}$}\n    \\end{figure}\n\n    \\pagebreak\n\n    \\centering\n    \\textbf{The whole data I gathered is in \\href{https://github.com/shahmari/ComputationalPhysics-Fall2021/tree/main/ProblemSet5/Data}{this link}}\n    \n    \\textbf{Also check \\href{https://www.youtube.com/watch?v=dQw4w9WgXcQ}{this link}}\n\n    Thanks for watching :)\n\\end{document}", "meta": {"hexsha": "f6eb04e968bc2b9405a50bc32e9888e7b7cd23f2", "size": 5151, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProblemSet5/TEXfiles/report.tex", "max_stars_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_stars_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ProblemSet5/TEXfiles/report.tex", "max_issues_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_issues_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProblemSet5/TEXfiles/report.tex", "max_forks_repo_name": "shahmari/ComputationalPhysics-Fall2021", "max_forks_repo_head_hexsha": "f1681e32258c55697d11009e1702eb86d5f119d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-21T11:07:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-21T11:07:08.000Z", "avg_line_length": 33.8881578947, "max_line_length": 154, "alphanum_fraction": 0.6540477577, "num_tokens": 1538, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5583269796369905, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.40121064015293323}}
{"text": "%\\nomenclature[]{VRP}{Vehicle Routing Problem}\n\n\\section{Scene Surveying}\\label{sec:SceneSurveying}\nThis section outlines the algorithms that were explored to generate a set of routes for the RAVs that will be used to record sensor data at each of the grid points generated in the region of interest. We gave a high-level description of this problem at the beginning of Chapter \\ref{chapter:SceneSurveying}:\n\"\\textit{Find a set of routes for each of $K$ RAVs to be used in the data-gathering process, such that these sets partition $R$ and the cost of the system of RAVs traversing these points is minimized}\".\n%which are generated using Algorithm \\ref{alg:GridGeneration} described in the preceding section. \nWe make some assumptions related to the solution of this problem:\n\\note{This list might not cover everything, come back to it}\n\\begin{itemize}\n    \\item Each RAV is assumed to have the same internal representation of the region of interest, namely the set of uniformly spaced grid points generated by Algorithm \\ref{alg:GridGeneration}.\n    \\item Each RAV is assumed to have the ability to move between any pair of grid points unobstructed using the shortest possible path.\n    \\item RAVs are assumed to move with a fixed operational velocity, which can vary between RAVs.\n    \\item Each RAV may be equipped with different sensors to the others and it is assumed that sensing times may vary among the RAVs.\n    \\item Each RAV has a finite battery capacity which implies they have a finite amount of time that they can fly for before they need to recharge.\n\\end{itemize}\n\n%Talk about how problem was transformed to TSP problem, took that and then divided up soln for mTSP.\n\nThe scene surveying problem that we would like to solve can be treated as an instance of the \\textit{Vehicle Routing Problem} (VRP), which was first described in a paper by \\citeauthor{Dantzig1959TheProblem} \\cite{Dantzig1959TheProblem}. This problem is a generalisation of the classic \\textit{Travelling Salesman problem} (TSP). There are many variants and extensions to this problem, but the VRP essentially asks for a set of routes to be assigned to the RAVs such that each point in the graph is visited exactly once, which minimises the total time taken to \"service\" each of the points \\cite{Dantzig1959TheProblem}. In our case, the service time is the time taken to record a sensor reading. We are interested in solving this problem where the graph is defined by the grid of points that is generated using Algorithm \\ref{alg:GridGeneration}. A formal definition of the VRP and its variants can be found in \\cite{Toth2002TheProblem}.\n\n\\subsection{Simplified Problem}\\label{subsec:SimplifiedVRP}\n\\note{maybe change this to constrained problem or something similar}\nWe began by taking a simplified version of the full vehicle routing problem in order to explore possible solutions. This section expands on our published work in \\cite{Smyth2018UsingDrones}, which summarises how this simplified problem was tackled. Rather than concern ourselves with the details of sensor sampling times and battery constraints, we first focused on designing a solution that can assign a set of routes to a homogeneous set of RAVs. \n%We assumed that service times add a fixed constant to the total time taken to perform the survey (and can hence be ignored) and we ignore the time added that the RAVs might need to recharge. \nThe problem can be described as follows:\n\\\\\n\\textit{Given a fully connected graph, $G$, to visit and $n$ RAV agents, find a subtour for each agent such that each point in $P \\in G$ is visited exactly once by any agent in the system, with the objective of minimizing the longest time taken for any individual agent subtour, in order to minimize the time taken to carry out the survey.}\n\\\\\nThis is the \\textit{multiple Travelling Salesman Problem} (mTSP). \n\n%According to the number of distribution centers: single distribution center and multi-distribution center problem;\n%According to the type of vehicle: single-vehicle type and multi-vehicle type problem;\n%According to the characteristics of the task: pure send (take) cargo problems and loading and unloading mixing problem;\n%According to whether the time constraints: no time window problem and time window problem;\n%By vehicle loading: And the problem of non-full load;\n%According to the optimization of the number of goals: a single objective and multi-objective problem;\n%Vehicle and vehicle by the ownership of the points: the vehicle open problem and vehicle closure problems;\n%By mastering the information of certainty: Sexual VRP and non-deterministic VRP problems;\n%As can be seen from these classifications, solutions to the VRP problem are varied, each category \n\n\\subsection{Proposed Solution for the Simplified Problem}\n\\note{Again maybe use constrained instead of simplified}\nDue to the fact that the mTSP is at least as hard as the TSP, since it is a generalisation of the TSP, finding a polynomial time solution to the mTSP is not feasible. We explored a number of sub-optimal solutions that take advantage of the highly structured nature of the uniformly spaced grid that we use in our instance of the problem. The usual trade-off between solution quality vs. time taken to find the solution motivated our choice of implemented algorithm, as we anticipated that the time taken to execute the planned routes may be comparable to the time taken to generate some solutions (the order of minutes or hours). For example, \\citeauthor{Hungerlander2018TheGrids} shows the results of using a Mixed Integer Linear Program (MILP) took hours to run for grid sizes that could be considered relatively small in many real-world domains \\cite{Hungerlander2018TheGrids}.\n%which would exceed the amount of time taken to perform even a random solution. %General details of solutions that can be applied to solve the mTSP and VRP can be found in Section <> of the literature review (this will be filled in).\n\n\\subsection{Nearest Neighbour Algorithm}\nThere are four common heuristic algorithms that form the basis of most solutions to TSP and mTSP problems, as stated in \\cite{Johnson1997TheOptimization}: the \\textit{nearest neighbour} algorithm, the \\textit{greedy algorithm}, the \\textit{Clarke-Wright} algorithm and the \\textit{Christofides} algorithm. We began by implementing an algorithm which is a modification of a TSP solution based on the nearest-neighbour heuristic. Our reasoning is based on the following premises:\n\\begin{enumerate}\n    \\item The nearest-neighbour heuristic is a well-known heuristic that is straightforward to implement. It is known to provide good results to the TSP when the cost is defined as the Euclidean distance between points \\cite{Johnson1997TheOptimization}, as in our use case.\n    \\item The nearest-neighbour solution to the TSP can be very easily modified to be applied to the mTSP by implementing it in a round-robin manner, as detailed in Algorithm \\ref{alg:NNHeuristic}.\n    \\item The nearest-neighbour heuristic is known to have a running time which is O($n^2$) \\cite{Rosenkrantz1977AnProblem}, which means it can scale well to reasonably large problem instances compared to other algorithms which have a far worse performance complexity. For example, the Christofides algorithm is known to be within a factor of $\\frac{3}{2}$ of the optimal solution, but its running time is O($n^3$) \\cite{Christofides1976WORST-CASEPROBLEM}, which quickly becomes prohibitively long.\n    %\\item Partitioning a TSP solution can give very good mTSP solutions on the same graph.\n\\end{enumerate}\n\nThe nearest-neighbour (NN) heuristic algorithm for the multiple Travelling Salesman problem is shown in Algorithm \\ref{alg:NNHeuristic}.\n\n\n\\begin{algorithm}[h]\n\\caption{The Nearest-Neighbour Solution to the mTSP Problem}\n\\label{alg:NNHeuristic}\n\\begin{algorithmic}[1]\n\\renewcommand{\\algorithmicrequire}{\\textbf{Input:}}\n\\renewcommand{\\algorithmicensure}{\\textbf{Output:}}\n\n\\REQUIRE$ \\newline k: \\quad \\text{ The number of RAVs in the mTSP }\n\\newline way\\_points: \\quad \\text{ The set of points the RAVs must visit }\n\\newline cost(i,j): \\quad \\text{ The function giving the cost of travelling from node i to node j }\n$\n\\ENSURE $ \\newline RAV\\_routes: \\quad \\text{A key-value data structure mapping RAVs to their corresponding routes.}\n$\n\n\\hfill\\pagebreak\n\n%\\noindent\\textbf{\\textit{\\noindent Initialization} :}\\\\\n\\STATE RAV\\_routes$\\leftarrow$empty key-value container\n\\STATE visited\\_points$\\leftarrow$empty array\n\\STATE remaining\\_points\\_to\\_visit$\\leftarrow$way\\_points\n\\FOR{each agent in agents:}\n%\\quad \n\\STATE Initialise path of agent as empty array in RAV\\_routes\n\\ENDFOR\n\ncurrent\\_agent\\_index$\\leftarrow$0\\\\\n%current\\_agent$\\leftarrow$agents.get(current\\_agent\\_index)\\\\\n\\hfill\\pagebreak\n\\WHILE {pointsToVisit is not empty}\n\\STATE agent\\_position $\\leftarrow$ last value in agent\\_paths.get(current\\_agent\\_index)\n\\STATE nearest\\_neighbour$\\leftarrow$\\(\\displaystyle \\min_{neighbour \\in points\\_to\\_visit}\\)cost(agent\\_position, neighbour)\n\\STATE Update current\\_agent value in agent\\_paths to include nearest\\_neighbour\n\\STATE Add nearest\\_neighbour to visited\\_points.\n\\STATE Remove nearest\\_neighbour from remaining\\_points\\_to\\_visit.\n\\STATE current\\_agent\\_index$\\leftarrow$(currentAgentIndex+1) $\\mathbf{mod}$$\\vert$List of Agents$\\vert$\n\n%\\STATE currentAgent$\\leftarrow$agents.get(currentAgentIndex)\n\n\n\\ENDWHILE\n\\RETURN RAV\\_routes\n\\end{algorithmic} \n\\end{algorithm}\n\n\\begin{figure}[h]\n\\centering\n\\includegraphics[width=0.5\\textwidth]{Chapters/MultiAgentCoverage/Figs/RAVRoutingNUIGCropped.png}\n\\caption{NN heuristic encourages the creation of optimal sub-tours, which are assigned to each RAV}\n\\label{fig:NNPartitioning}\n\\end{figure}\n\nThe algorithm can be seen to be a very straightforward extension of the single agent NN algorithm. The while loop iteratively cycles through the list of RAVs and assigns the nearest non-assigned neighbour to the next RAV's partially assembled route.\n\nSince we run this algorithm over a uniformly-spaced grid, it builds agent routes in a lawn-cutting pattern, which provides good results as long as the routes do not begin to overlap. The idea is to take the NN algorithm TSP solution and apply it exhaustively in a round-robin manner, so that each RAV is encouraged to find a non-overlapping optimal sub-tour. These non-overlapping optimal sub-tours partition the region and therefore offer a solution to the mTSP. Section 4 of \\cite{Hungerlander2018TheGrids} gives an insight to how optimal solutions can be found for a uniformly spaced rectangular grid when RAVs are assumed to start in the corners of the rectangle, which provides further motivation to using Algorithm \\ref{alg:NNHeuristic}. In practice non-overlapping optimal sub-tours are not found, but solutions may come close, as illustrated in Figure \\ref{fig:NNPartitioning}.\n\n%Since sometimes the solutions found by the algorithm are not always well-balanced, we propose to iteratively re-run the algorithm after a set interval in order to update the solution to ensure that no RAV is idle while others are doing work. This also ensures redundancy in the system - if a RAV stops operating, its uncompleted work will be re-assigned to the others.\n\n%\\note{Not sure if worth mentioning lower bound of cost for this algo is 1/noRAVs}\n%\\note{might be worth mentioning that it would be ideal to add the next grid point to whichever agent has the shortest route so far}\n\n\n\n\\subsection{Analysis of the NN algorithm}\n%\\note{The justification behind this choice of algo is a bit weak, might be worth running tests on file:///C:/Users/13383861/Downloads/graphsOR18.pdf}\n\n\nThe results and analysis of applying the NN heuristic algorithm to the symmetric Euclidean TSP and mTSP are well documented and we will not go into great detail repeating the results here. Instead, we refer the reader to the chapter ``The travelling salesman problem: A case study'' of \\cite{Aarts:1997:LSC:549160}, written by \\citeauthor{Johnson1997TheOptimization}, which provides a comparison of the NN heuristic to other heuristic algorithms. They compare solutions with the standard Held-Karp lower bound \\cite{Held1962AProblems} using a standardised library of Travelling Salesman Problems, TSPLIB \\cite{TSPLIB}. Rather than provide tables of results showing the performance of the NN heuristic algorithm on standard benchmark data sets such as TSPLIB, we instead focus on the results for the domain we are most interested in, which is a connected graph defined by a uniformly spaced set of grid points. We found that the algorithm performed best when the RAVs used regions that have multiple axes of symmetry. Rectangular regions in particular yield scalable, high-quality solutions, as shown in the figures in Table \\ref{table:NNAlgoResultsRect}. This corresponds to the optimal performance configuration suggested in \\cite{Hungerlander2018TheGrids}. We evaluated solutions both qualitatively and  quantitatively. We focused on the qualitative results of the experiments, which were designed to show that the system can partition the in the region to give a reasonably balanced amount of work to each agent for regular polygons with a number of axes of symmetry. This was a proof-of-concept, with the intention for future work to provide a more thorough analysis on performance. We found that RAV starting points are a critical factor in solution quality, which again is in line with the findings in \\cite{Hungerlander2018TheGrids}. Tables \\ref{table:NNAlgoResultsRect}, \\ref{table:NNAlgoResultsTri} and \\ref{table:NNAlgoResultsHex} %\\ref{table:NNAlgoResultsIrregular} \nillustrate some of the results, with the configuration of each listed below. The experiments are intended to demonstrate practical use cases where the NN algorithm will provide qualitatively good results.\n\n\\pagebreak\n\\subsection{Qualitative Behaviour of the NN Algorithm with a Rectangular Grid}\nWe set up this experiment with the aim of showing that if the RAVs can be placed in the configuration suggested by \\citeauthor{Hungerlander2018TheGrids}, they will partition the region in a close to optimal fashion \\cite{Hungerlander2018TheGrids}, minimising the longest distance any one RAV needs to travel to complete its mission. We ran the experiment using 1-4 RAVs, placing them in the corners of the rectangles. This was done in an approximate fashion by manually dragging the RAVs to their starting position using the UI mentioned in Section \\ref{subsec:SceneSurveyingUI}. The results in Table \\ref{table:NNAlgoResultsRect} show that the amount of work done by each RAV is approximately evenly balanced. Theoretically, the minimum amount of work done by each RAV would be $\\frac{1}{2}$, $\\frac{1}{3}$ and $\\frac{1}{4}$ of the total work done by a single RAV when using 2, 3 and 4 RAVs respectively.\n\\par The results show that when using 2, 3 and 4 RAVs, the solutions found by the NN algorithm were 2.701\\%, 4.500\\% and 17.315\\% less efficient than evenly splitting up the solution for a single RAV ( $\\frac{1}{2}$, $\\frac{1}{3}$ and $\\frac{1}{4}$ of 3576.6m of the single-RAV route length, respectively). This was partly due to the extra distance added from the starting positions. Note that when using 4 RAVs, there was some overlap in the routes which added a significantly higher overhead to the cost of the route in relation to that given by even splitting the solution found for a single RAV.\n\n\nWe used the following configuration to run the experiment:\n\\\\Spacing between grid points: 23m in latitude, 25m in longitude.\n\\\\Bounding rectangle coordinates: (53.2781933786, -9.0671226391), (53.2803800539, -9.067182416), (53.2804392784, -9.0611222377), (53.2782526061, -9.0610624609)\n\\\\\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{ | c | m{5cm} | }\n    \\hline\n    Planned RAV Routes & Route Lengths (metres) \\\\\n    \\hline\n    \n    %single RAV\n    \\begin{minipage}[c][53mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=51mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Rectangle/SingleAgent.PNG}\n\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n      \\item[] RAV 1 (blue): 3576.6\n    \\end{itemize}\n    \\\\\n    \\hline\n    %two RAV\n    \\begin{minipage}[c][53mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=51mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Rectangle/TwoAgent.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n        \\item[] RAV 1 (blue): 1836.3\n        \\item[] RAV 2 (green): 1825.8\n    \\end{itemize}\n    \\\\\n    \\hline\n    \n    %three RAV\n    \\begin{minipage}[c][53mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=51mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Rectangle/ThreeAgent.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n    \\item[] RAV 1 (blue): 1245.6\n    \\item[] RAV 2 (green): 1235.1\n    \\item[] RAV 3 (red): 1215.9\n    \\end{itemize}\n    \\\\\n    \\hline\n    \n    %Four RAV\n    \\begin{minipage}[c][53mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=51mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Rectangle/FourAgent.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n    \\item[] RAV 1 (blue): 1048.8\n    \\item[] RAV 2 (green): 1038.3\n    \\item[] RAV 3 (red): 994.5\n    \\item[] RAV 4 (yellow): 990.5\n    \\end{itemize}\n\n    \\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Results of applying NN algorithm to a rectangular region}\\label{table:NNAlgoResultsRect}\n\\end{table}\n\n\n\n\n\\pagebreak\n\\subsection{Qualitative Behaviour of the NN Algorithm with a Triangular Grid}\nThis experiment was set up in a similar manner to the first, where the RAVs were dragged to an initial starting position that should allow the NN algorithm to take advantage of the axes of symmetry of the triangle.\nThe results in Table \\ref{table:NNAlgoResultsTri} show that the amount of work done by each RAV is approximately evenly balanced when using two RAVs, but not three. \n\nThe results show that when using two and three RAVs, the solutions found by the NN algorithm were 0.155\\% and 36.565\\% less efficient than that given by even splitting the solution for a single RAv ( $\\frac{1}{2}$ and $\\frac{1}{3}$ of 1940.6, respectively). This can be explained by the corresponding figures displaying the agents' routes in Table \\ref{table:NNAlgoResultsTri}. Clearly, the NN algorithm takes advantage of the symmetry down the vertical centre axis when two RAVs are used, but when three RAVs are used, the solution the RAV beginning at the top of the triangle skips the grid points that require a \"diagonal\" move, instead moving down to the closer grid point. These points are picked up by the second RAV (green) once it meets the third (red), adding a relatively large cost.\n\nWe used the following configuration to run the experiment:\n\\\\Spacing between grid points: 23m in latitude, 25m in longitude.\n\\\\Bounding rectangle coordinates: (53.2781933786, -9.0671226391), (53.2782526061, -9.0610624609), (53.2803800539, -9.06409255)\n\\\\\n\n%\\\\Spacing between grid points: 23m in latitude, 25m in longitude.\n%\\\\Bounding rectangle coordinates: (53.2781933786, -9.0671226391), (53.2782526061, -9.0610624609), (53.2803800539, -9.06409255)\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{ | c | m{5cm} | }\n    \\hline\n    Planned RAV Routes & Route Lengths (metres) \\\\\n    \\hline\n    \n    %single RAV\n    \\begin{minipage}[c][57mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=55mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Triangle/OneRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n      \\item[] RAV 1 (blue): 1940.6\n    \\end{itemize}\n    \\\\\n    \\hline\n    %two RAV\n    \\begin{minipage}[c][57mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=55mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Triangle/TwoRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n        \\item[] RAV 1 (blue): 971.8\n        \\item[] RAV 2 (green): 930.7\n    \\end{itemize}\n    \\\\\n    \\hline\n    \n    %three RAV\n    \\begin{minipage}[c][57mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=55mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Triangle/ThreeRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n    \\item[] RAV 1 (blue): 621.6\n    \\item[] RAV 2 (green): 812.7\n    \\item[] RAV 3 (red): 883.4\n    \\end{itemize}\n    \\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Results of applying NN algorithm to a triangular region}\\label{table:NNAlgoResultsTri}\n\\end{table}\n\n\n%\\textbf{Hexagonal Region}\n%\\\\Spacing between grid points: 32m in latitude, 38m in longitude.\n%\\\\Bounding rectangle coordinates: (53.2782526061, -9.0610624609), (53.2803800539, -9.06409255), (53.2781933786, -9.0671226391), (53.27621, -9.0671226391), (53.27402, -9.06409255), (53.27615, -9.0610624609)\n%\\\\\n\n\n\n\\pagebreak\n\\subsection{Qualitative Behaviour of the NN Algorithm with a Hexagonal Grid}\nThis experiment was again set up in a similar manner to the first, where the RAVs were dragged to starting positions that should allow the NN algorithm to take advantage of the axes of symmetry of the hexagon. In this case, we had to vary their starting locations depending on the number of RAVs used in order to encourage the generation of non-overlapping solutions. We found that the NN algorithm could find (approximately) symmetrical solutions using two or four RAVs, shown in Table \\ref{table:NNAlgoResultsHex}.\n\n\n\nThe results show that when using two RAVs, the longest route is 2.191\\% shorter than half the length of the route found using just one RAV. When two RAVs are used, they move horizontally to the nearest grid location, meet in the middle of the hexagon and then move back to the outer edge. Once the reach the lower third of the hexagon, they move down diagonally and then back across horizontally. This behaviour is the same when using a single RAV. The key difference is when they move to the top third of the hexagon, they exhibit the same behaviour, whereas the single agent skips some of the \"diagonal\" grid points, as in the case of the triangular region using three RAVs. It must go back to visit them at a relatively large cost, since the points that it missed on each from range from both the left and right sides of the upper hexagon. This can be seen in the first figure in Table \\ref{table:NNAlgoResultsHex}.\n\n\nWhen using four RAVs, the longest route was 36.565\\% longer than $\\frac{1}{4}$ of the length of the route found for a single RAV. This was mainly due to the slight imbalance in the number of points in the upper third and lower third of the hexagon and the middle third. There are 79 points in both the upper and lower third and 147 points in the middle third. This means that the two RAVs that sweep back and across the middle move to the upper and lower third to \"help\". This results in large jumps to finish of the final few grid points, visible in the third figure of Table \\ref{table:NNAlgoResultsHex}. \n\nWe used the following configuration to run the experiment:\n\\\\\nSpacing between grid points: 32m in latitude, 38m in longitude.\nBounding coordinates: (53.2782526061, -9.0610624609), (53.2803800539, -9.06409255), (53.2781933786, -9.0671226391), (53.27621, -9.0671226391), (53.27402, -9.06409255), (53.27615, -9.0610624609)\n\n\n\n\n\n\\begin{table}[H]\n  \\centering\n  \\begin{tabular}{ | c | m{4.5cm} | }\n    \\hline\n    Planned RAV Routes & Route Lengths (metres) \\\\\n    \\hline\n    \n    %single RAV\n    \\begin{minipage}[c][74mm][c]{.5\\textwidth}\n      \\includegraphics[width=\\linewidth, height=72mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Hexagon/OneRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n      \\item[] RAV 1 (blue): 7247.2\n    \\end{itemize}\n    \\\\\n    \\hline\n    %two RAV\n    \\begin{minipage}[c][74mm][c]{.5\\textwidth}\n      \\includegraphics[width=\\linewidth, height=72mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Hexagon/TwoRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n        \\item[] RAV 1 (blue): 3587.4\n        \\item[] RAV 2 (green): 3544.2\n    \\end{itemize}\n    \\\\\n    \\hline\n    \n    %three RAV\n    \\begin{minipage}[c][69mm][c]{.6\\textwidth}\n      \\includegraphics[width=\\linewidth, height=67mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/Hexagon/FourRAV.PNG}\n    \\end{minipage}\n    &\n    \\begin{itemize}[leftmargin=*]\n    \\item[] RAV 1 (blue): 2435.6\n    \\item[] RAV 2 (green): 1629.6\n    \\item[] RAV 3 (red): 2412.0\n    \\item[] RAV 4 (yellow): 2245.9\n    \\end{itemize}\n    \\\\\n    \\hline\n  \\end{tabular}\n  \\caption{Results of applying NN algorithm to a hexagonal region}\\label{table:NNAlgoResultsHex}\n\\end{table}\n\n\n%\\textbf{Irregular Region}\n%\\\\Spacing between grid points: 20m in latitude, 20m in longitude.\n%\\\\Bounding rectangle coordinates: (53.28048,-9.069021), (53.28189,-9.066017), (53.28009,-9.065223), (53.28192,-9.064128), (53.28026,-9.061725), (53.27923,-9.063957), (53.27846,-9.063721), (53.27712,-9.063721), (53.27626,-9.060159), (53.27516,-9.061124), (53.27412,-9.061425), (53.27362,-9.061425), (53.2735,-9.062562), (53.27456,-9.06327), (53.27416,-9.064794), (53.27495,-9.06754), (53.27456,-9.067841), (53.27354,-9.067605), (53.27346,-9.06857), (53.27466,-9.06872), (53.2752,-9.06827), (53.27583,-9.070008), (53.27571,-9.07093), (53.27545,-9.074385), (53.27581,-9.074149), (53.27609,-9.07445), (53.2788,-9.069986), (53.27951,-9.069793), (53.28116,-9.071081), (53.28148,-9.069686)\n%\\\\\n\n%\\textbf{Irregular Region}\n%\\\\Spacing between grid points: 20m in latitude, 20m in longitude.\n%\\\\Bounding rectangle coordinates: (53.28048,-9.069021), (53.28189,-9.066017), (53.28009,-9.065223), (53.28192,-9.064128), (53.28026,-9.061725), (53.27923,-9.063957), (53.27846,-9.063721), (53.27712,-9.063721), (53.27626,-9.060159), (53.27516,-9.061124), (53.27412,-9.061425), (53.27362,-9.061425), (53.2735,-9.062562), (53.27456,-9.06327), (53.27416,-9.064794), (53.27495,-9.06754), (53.27456,-9.067841), (53.27354,-9.067605), (53.27346,-9.06857), (53.27466,-9.06872), (53.2752,-9.06827), (53.27583,-9.070008), (53.27571,-9.07093), (53.27545,-9.074385), (53.27581,-9.074149), (53.27609,-9.07445), (53.2788,-9.069986), (53.27951,-9.069793), (53.28116,-9.071081), (53.28148,-9.069686)\n%\\\\\n\n%\\begin{table}[H]\n%  \\centering\n%  \\begin{tabular}{ | c | m{5cm} | }\n%    \\hline\n%    Planned RAV Routes & Route Lengths (metres) \\\\\n%    \\hline\n    \n    %single RAV\n%    \\begin{minipage}[c][68mm][c]{.6\\textwidth}\n%      \\includegraphics[width=\\linewidth, height=66mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/IrregularRegion/TwoRAV.PNG}\n%    \\end{minipage}\n%    &\n%    \\begin{itemize}[leftmargin=*]\n%       \\item[] RAV 1 (blue): 14268.6\n%        \\item[] RAV 2 (green): 13393.6\n%    \\end{itemize}\n %   \\\\\n%    \\hline\n    %two RAV\n%    \\begin{minipage}[c][68mm][c]{.6\\textwidth}\n%      \\includegraphics[width=\\linewidth, height=66mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/IrregularRegion/ThreeRAV.PNG}\n%    \\end{minipage}\n%    &\n%    \\begin{itemize}[leftmargin=*]\n%        \\item[] RAV 1 (blue): 8879.8\n%        \\item[] RAV 2 (green): 9596.4\n%        \\item[] RAV 3 (green): 9433.4\n%    \\end{itemize}\n%    \\\\\n%    \\hline\n    \n    %three RAV\n%    \\begin{minipage}[c][68mm][c]{.6\\textwidth}\n%      \\includegraphics[width=\\linewidth, height=66mm]{Chapters/MultiAgentCoverage/MultipleTravellingSalesman/Figs/IrregularRegion/FourRAVSecondAttempt.PNG}\n%    \\end{minipage}\n%    &\n%    \\begin{itemize}[leftmargin=*]\n%    \\item[] RAV 1 (blue): 7673.2\n%%    \\item[] RAV 2 (green): 6354.0\n %   \\item[] RAV 3 (red): 6860.6\n%    \\item[] RAV 4 (yellow): 6368.8\n%    \\end{itemize}\n%    \\\\\n%    \\hline\n%  \\end{tabular}\n%  \\caption{Results of applying NN algorithm to an irregular region}\\label{table:NNAlgoResultsIrregular}\n%\\end{table}\n%\\pagebreak\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n%\\subsubsection{Proof of Lower Bound of Nearest Neighbour Solution}\n%Let O be a tour that is an optimal solution to the Travelling Salesperson Problem (TSP) for  a graph G(V, E), where E $\\subseteq$ V $\\times$ V, with a cost function c$(p_i, p_j)$ defined for all $(p_i, p_j)$ $\\in$ E and an induced cost function \n%C($T$) = $\\sum\\limits_{(p_i, p_j)\\in }$C$(p_i, p_j)$ defined for any tour $T$ of G.\n%The optimal tour O is an ordered tuple (($p_i, p_j$), ($p_j, p_k$),..., ($p_m, p_n$)) $\\subseteq$ E which satisfies:\n%\\[\n%Cost(O) =  \\min_{e \\subseteq E}\\sum_{(p_i, p_j) \\in e} c(p_i, p_j) \n%\\]\n%with the constraint that each $p_i \\in$ V must be visited exactly once. This means that O is a Hamiltonian tour of G of minimal cost. \n%\\\\\n%For any partition ($T_1, T_2, ..., T_m$) of an arbitrary tour T', we find:\n\n%\\[\\text{Cost}(T')=\\sum\\limits_{k=1}^{m}\\sum\\limits_{(p_i, p_j)\\in T_k} \\text{cost}(p_i, p_j) \\leq m \\times \\max_{T_k \\in T}\n%\\sum\\limits_{(p_i, p_j)\\in T_k}c(p_i, p_j) = \n%m \\times \\max_{T_k \\in T} \\text{Cost}(T_k)\n%\\]\n\n%\\noindent Since Cost(O) $\\leq$ Cost(T'), for the partition determined by any solution to the TSP, we find that for any solution S to mTSP consisting of the partition ($S_1, S_2, ...,S_m$) for each of the m agents:\\\\\n\n%\\[\n%Cost(T)\n%\\leq Cost(S) \\leq  m \\times\n%\\max_{S_k \\in S}\n%\\sum\\limits_{(p_i, p_j)\\in S_k}C(p_i, p_j)) = Cost of MTS solution, S.\n%\\]\n%This means we can use a solution of the standard Traveling Salesperson problem as a lower bound for comparison with Algorithm \\ref{alg:agentRoutesEdited}. For example, the Held-Karp algorithm gives a well-known lower bound when dealing with a metric space \\cite{VALENZUELA1997157}.\n\n%We explored a number of solutions to this \n\n", "meta": {"hexsha": "860e70af6e29b966db0573323ded63653a2dc590", "size": 29660, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/MultiAgentCoverage/MultipleTravellingSalesman/MultipleTravellingSalesman.tex", "max_stars_repo_name": "DavidLSmyth/ResearchMScThesis", "max_stars_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/MultiAgentCoverage/MultipleTravellingSalesman/MultipleTravellingSalesman.tex", "max_issues_repo_name": "DavidLSmyth/ResearchMScThesis", "max_issues_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-06-18T11:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-18T11:59:42.000Z", "max_forks_repo_path": "Chapters/MultiAgentCoverage/MultipleTravellingSalesman/MultipleTravellingSalesman.tex", "max_forks_repo_name": "DavidLSmyth/ResearchMScThesis", "max_forks_repo_head_hexsha": "754d975535e0da9a8e99cf31b651021698155c5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.9015317287, "max_line_length": 1977, "alphanum_fraction": 0.7462913014, "num_tokens": 8447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6334102636778403, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.40120856213243106}}
{"text": "% To compile single chapters put a % symbol in front of \"\\comment\" and \"}%end of comment\" below \r\n%    and take off the % symbol from \"\\end{document\" at the bottom line. Undo before compiling\r\n%    the complete thesis\r\n%%Note: You can only use \\section command, you are not allowed, per TTU Graduate School, use\r\n%%\\subsection command for ghigher level subheadings. At most level 2 subheadings are allowed.\r\n\r\n\\chapter{Conclusions and Future Work}\r\n\\label{Conclusions and Future Work}\r\n\r\nURE can provide valuable device classification and characterization insights for many applications from NILM to condition-based maintenance. URE processing algorithms often require subject matter expertise to tailor transforms and feature extractors for the specific electrical device of interest.  DASP was presented as a method for projecting aligned signal dimensions, such as frequency harmonics, frequency spacings, signal modulations, that are inherent to the physical implementation of the vast majority of commercial electronic devices, thus removing the need for an intimate understanding of the underlying physical circuitry and the URE generation mechanism. In addition, methods for processing DASP images, extracting statistical features from DASP images, and direct learning from DASP images using CNNs were detailed and tested using a data set of URE captures from commercial electronic devices.\r\n\r\nThe ability to classify an electronic device's URE using DASP generated features was demonstrated with one-versus-all accuracies approaching $100\\%$ for the LDA and k-NN learning methods using statistical-based features, as well as using CNNs to learn directly from DASP images.  The LDA and CNN learning methods were adapted to multi-class all-versus-all classification and although the accuracies did not exceed $66.7\\%$, precisions greater than $90\\%$ were attained by several DASP trained CNNs with the combination of CNN learners reaching  a $97\\%$ precision.  The multi-class CNNs were also tested against DASP images derived from clutter device URE and were able to correctly assign clutter to a clutter class at an accuracy of $80\\%$ using the combination of DASP CNN learners.  Finally, analysis of the overall testing results showed that the utilization of the unprocessed DASP arrays exceeded their respective scatter, edge, and radon transformed arrays in terms of accuracy and precision, except for the CMASP edge array which exceeded the performance of the unprocessed CMASP array.\r\n\r\nAlthough the utilization of statistical-based features with the LDA and k-NN learning methods performed well, the ability to learn directly from the DASP images with CNNs provided significantly improved results.  With the simplest of CNN architectures, using only $6$ layers, one-versus-all classification accuracies across all DASP-trained CNN learners reached an average accuracy of $99\\%$, however the $6$ layer architecture did not translate well to multi-class applications.  A slightly more complicated CNN with $13$ layers demonstrated the ability of using DASP images to separate multiple classes and to properly identify clutter devices.  Further research in to CNN architectures for DASP image processing is warranted, especially as it pertains to multi-class and clutter classification problem sets.  For instance, a CNN architecture that allows for simultaneous training on all DASP images in multiple parallel streams would significantly improve performance, as demonstrated by \\cite{Ciregan2012, Li2015}, and alleviate the need for voting schemes across individual learners.  Additionally, the ability to handle multiple labels per image would allow for more tailored and thorough training with overlapping confounders, devices, and clutter to provide better performance in more realistic commercial or residential URE environments; however, research in multi-label CNNs is relatively new \\cite{Wei2016, Wu2015, Gong2013} and primarily focuses on social media image annotation.  \r\n\r\nThe DASP algorithms presented in Chapter \\ref{DASP Algorithm Development Chapter} were not all-encompassing and the continued exploration and development of dimensional alignment algorithms is warranted given the performance of the HASP, MASP, CMASP, FASP, and SCAP algorithms.  Dimensional alignments of phase, wavelet, or chirp-based features have not been fully explored and could provide further insights into URE characteristics and provide additional features for class separation in multi-class classification applications.  Finally, optimization of the DASP parameter values, such as frequencies and bandwidths, should be explored for different devices or classes of devices.  DASP parameter optimization could be accomplished with a supervisory learner, such as a genetic algorithm, wrapped around the CNN learner; however, training and testing would require a significant amount of time and compute resources.\r\n\r\n\r\n", "meta": {"hexsha": "43635c66bed22065b6c2024b3d09715c055c9d48", "size": 4922, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "research/dissertation/Conclusions.tex", "max_stars_repo_name": "argodev/learn", "max_stars_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "research/dissertation/Conclusions.tex", "max_issues_repo_name": "argodev/learn", "max_issues_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 15, "max_issues_repo_issues_event_min_datetime": "2020-01-28T22:25:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-11T23:21:02.000Z", "max_forks_repo_path": "research/dissertation/Conclusions.tex", "max_forks_repo_name": "argodev/learn", "max_forks_repo_head_hexsha": "d815beb9c1f8fa3dd8cd917640ebcca5822205c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 259.0526315789, "max_line_length": 1494, "alphanum_fraction": 0.8173506705, "num_tokens": 958, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.40120856213243056}}
{"text": "%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"program-analysis\"\n%%% End:\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Data Flow Analysis}\n\\label{chap:data-flow-analysis}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Prerequisites}\n\n\\subsubsection{While-programs}\n\n\\begin{math}\n  \\begin{array}{lll}\n    a & = & x \\blank|\\blank n \\blank|\\blank a_1 \\mathtt{op}_a a_2 \\\\\n    b & = & \\mathtt{true} \\blank|\\blank \\mathtt{false} \\blank|\\blank \\mathtt{not} b \\blank|\\blank b_1 \\mathtt{op}_b b_2 \\blank|\\blank a_1 \\mathtt{op}_r a_2 \\\\\n    S & = & [x := a]^l \\blank|\\blank [skip]^l \\blank|\\blank S_1; S_2 \\blank|\\blank \\mathtt{if} \\blank [b]^l \\mathtt{then} \\blank S_1 \\blank \\mathtt{else} \\blank S_2 \\blank|\\blank \\mathtt{while}\\blank [b]^l \\blank \\mathtt{do} \\blank S\n  \\end{array}\n\\end{math}\n\n\n\\begin{itemize}\n\\item Label $l$ denotes the program point (location of code).\n\\item $init(S)$ is the label of the first elementary bloc of $S$.\n\\item $final(S)$ is the set of labels of the last elementary blocks of\n  $S$.\n\\item $labels(S)$ is the entire set of labels in the statement $S$.\n\\item Flows $flow(S)$ is the forward representation of how control\n  flows in $S$.\n\\item Reverse flows $flow^R(S)$ is the backward representation of how\n  control flows in $S$.\n\\item A statement consists of a set of \\textit{elementary blocks}\n  where $blocks : Stmt \\to \\mathcal{P}(Blocks)$\n\\item A statement $S$ is \\textit{label consistent} iff any two\n  elementary statements $[S_1]^l$ and $[S_2]^l$ with the same label in\n  $S$ are equal: $S_1 = S_2$\n\\item A statement where all labels are unique is automatically label\n  consistent.\n\n\\end{itemize}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Intra-procedural Analysis}\n\n\\subsection{Available Expressions Analysis}\n\nFor each program point, which expressions must have already been\ncomputed, and not later modified, on all paths to the program point?\n\n\n\\subsection{Reaching Definitions Analysis}\n\nFor each program point, which assignments may have been made and not\noverwritten, when program execution reaches this point along some\npath?\n\n\\subsection{Very Busy Expressions Analysis}\n\nAn expression is \\textit{very busy} at the exit from a label if, no\nmatter what path is taken from the label, the expression is always\nused before any of the variables occurring in it are re-defined.\n\nThe aim of the analysis is to determine for each program point, which\nexpressions must be very busy at the exit from the point.\n\n\\subsection{Live Variables Analysis}\n\nA variable is \\textit{live} at the exit from a label if there is a\npath from the label to a \\texttt{use} of the variable that does not\nre-define the variable.\n\nThe aim of the analysis is to determine for each program point, which\nvariables may be live at the exit from the point.\n\n\\subsection{Derived Data Flow Information}\n\n\\begin{itemize}\n\\item Use-Def Chains: each \\texttt{use} of a variable is linked to all\n  \\textbf{assignments} that reach it.\n\\item Def-Use Chains: each \\texttt{assignment} to a variable is linked\n  to all \\texttt{use}s of it.\n\\end{itemize}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Monotone Frameworks}\n\nEach of the four classical analyses take the form\n\n\\begin{math}\n  \\begin{array}{lcl}\n    \\mathit{Analysis}_i(l) & = &\n                                 \\begin{cases}\n                                   i & \\mathtt{if} \\blank l \\in E \\\\\n                                   \\join \\{ \\mathit{Analysis}(l') | (l', l) \\in F \\} & otherwise\n                                 \\end{cases} \\\\\n    \\\\\n    \\mathit{Analysis}(l) & = & f_l(\\mathit{Analysis}_i(l)) \\\\\n  \\end{array}\n\\end{math}\n\nwhere\n\n\\begin{itemize}\n\\item $\\join$ is $\\cap$ or $\\cup$ (and $\\meet$ is $\\cup$ or $\\cap$)\n\\item $F$ is either $flow(S_*)$ or $flow^R(S_*)$\n\\item $E$ is $\\{ init(S_*) \\}$ or $final(S_*)$\n\\item $i$ specified the initial or final analysis information\n\\item $f_l$ is the transfer function associated with $B^l \\in blocks(S_*)$\n\\end{itemize}\n\n\\subsection{The Principles}\n\nForward vs. Backward\n\n\\begin{itemize}\n\\item \\textbf{Forward analyses} have $F$ to be $flow(S_*)$ and then\n  $\\mathit{Analysis}_i$ concerns entry conditions and\n  $\\mathit{Analysis}$ concerns exit conditions; the equation system\n  pre-supposes that $S_*$ has isolated entries.\n\\item \\textbf{Backward analyses} have $F$ to be $flow^R(S_*)$ and then\n  $\\mathit{Analysis}_i$ concerns exit conditions and\n  $\\mathit{Analysis}$ concerns entry conditions; the equation system\n  pre-supposes that $S_*$ has isolated exits.\n\\end{itemize}\n\n\nUnion vs. Intersection\n\n\\begin{itemize}\n\\item When $\\join$ is $cap$, we require the \\textbf{greatest sets}\n  that solve the equations and we are able to detect properties\n  satisfied by \\textit{all execution paths} reaching (or leaving) the\n  entry (or exit) of a label; the analysis is called a\n  \\textbf{must}-analysis.\n\\item When $\\join$ is $\\cup$, we require the \\textbf{smallest sets}\n  that solve the equations and we are able to detect properties\n  satisfied by \\textit{at least one execution path} to (or from) the\n  entry (or exit) of a label; the analysis is called a\n  \\textbf{may}-analysis.\n\\end{itemize}\n\n\n\\subsection{Transfer Functions}\n\nThe set of transfer functions $\\mathcal{F}$ is a set of\n\\textbf{monotone functions} over $L$, meaning that\n\n\\begin{math}\n  \\begin{array}{lcl}\n    l \\sle l' & \\implies & f_l(l) \\sle f_l(l')\n  \\end{array}\n\\end{math}\n\nand furthermore they fulfill the following conditions:\n\n\\begin{itemize}\n\\item $\\mathcal{F}$ contains \\textit{all} the transfer functions $f_l : L \\to L $ in question (for $l \\in Lab_* $ )\n\\item $\\mathcal{F}$ contains the \\textit{identity function}\n\\item $\\mathcal{F}$ is \\textit{closed} under \\textit{composition} of\n  functions\n\\end{itemize}\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Equation Solving}\n\n\\subsection{The MFP Solution}\n\nMFP stands for ``Maximum'' (actually least) Fixed Point.  The key idea\nis to iterate until stabilisation.\n\n\n\n\n\n\\subsection{The MOP Solution}\n\nMOP stands for ``Meet'' (actually join) Over all Paths.  The key idea\nis to propagate analysis information along paths.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Inter-procedural Analysis}\n\n\n\\subsection{The MVP Solution}\n\nMVP stands for ``Meet'' over Valid Paths.\n\nWe need to match procedure entries and exits:\n\nA \\textit{complete path} from $l_1$ to $l_2$ in $P_*$ has proper\nnesting of procedure entries and exits; and a procedure returns to the\npoint where it was called.\n\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Sensitivity}\n\\label{sec:sensitivity}\n\n\\subsection{Flow Sensitive}\n\\label{sec:flow-sensitive}\n\nA \\textbf{flow-sensitive} analysis takes into account the\n\\textit{order of statements} in a program.\n\n\\subsection{Path Sensitive}\n\\label{sec:path-sensitive}\n\nA \\textbf{path-sensitive} analysis computes different pieces of\nanalysis information dependent of the \\textit{predicates} at\nconditional branch instructions.\n\n\\subsection{Context Sensitive}\n\\label{sec:context-sensitive}\n\nA \\textbf{context-sensitive} analysis is an \\textit{inter-procedural}\nanalysis that considers the \\textit{calling context} when analyzing\nthe target of a function call. In particular, using context\ninformation, one can \\textit{jump back} to the original call site,\nwhereas without that information, the analysis information has to be\npropagated back to all possible call sites, potentially losing\nprecision.\n", "meta": {"hexsha": "96e81e53b4b71fbe2f7be325fbafa4e58d4120a0", "size": 7808, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "theory/dfa.tex", "max_stars_repo_name": "skicombinator/nirvana", "max_stars_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2022-01-21T06:14:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-21T06:14:51.000Z", "max_issues_repo_path": "theory/dfa.tex", "max_issues_repo_name": "sangwoo-joh/bible-raw-data", "max_issues_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theory/dfa.tex", "max_forks_repo_name": "sangwoo-joh/bible-raw-data", "max_forks_repo_head_hexsha": "d120744c0179b4c69c0c7ddc8b461e62486510f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8008658009, "max_line_length": 233, "alphanum_fraction": 0.652920082, "num_tokens": 2021, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.40118581849840484}}
{"text": "%!TEX root = ../thesis.tex\n%*******************************************************************************\n%*********************************** First Chapter *****************************\n%*******************************************************************************\n\n\\chapter{Introduction}\n\\label{chapter1}\n\nWe are surrounded by intractable problems, and that is even when we consider simplified models of reality. The transverse field Ising model is an example of a simple lattice model that displays very rich physics. Its basic constituents are not particles in continuous space, but spins confined to a grid that only interact with their immediate neighbours and the transverse field. The dynamics of the Ising model can be described by a single vector, but its dimension grows as $2^N$ with the number $N$ of particles, quickly putting us out of our depth. \n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=0.25\\linewidth]{Chapter1/ising_passive0}\n\t\\caption[A configuration of the Ising model.]{\\textbf{A configuration of the Ising model.}}\n\t\\label{fig:isingpassive0}\n\\end{figure}\nThis exponential explosion can be avoided by using stochastic methods, where our goal is to efficiently sample from the probability distribution of spin configurations, which allows us to calculate properties of the system. Some quantum lattice models lend themselves more naturally to stochastic methods than others. Stoquastic Hamiltonians, which have positive ground state amplitudes, belong right on the border between statistical and quantum mechanics, and this is precisely where we will operate.\n\nThe main objective of this thesis is to use concepts from probabilistic machine learning, optimal control, and stochastic processes to devise a method that will be able to learn the Feynman-Kac trajectory distribution in quantum lattice models. Such a method would provide one with the ability to perform optimal importance sampling if a perfect representation of the distribution was found, and a significant reduction in variance for near-optimal representations. \n\n\\section{Thesis Structure}\n\\label{sec:structure}\nThe thesis is structured as follows, Chapter~\\ref{chapter2} briefly introduces the quantum many-body problem before focusing on numerical solution approaches to it. In addition to standard methods, recent applications of Machine Learning are highlighted. In the first half of Chapter~\\ref{chapter3} the focus is turned towards mathematical fundamentals of stochastic processes, which underpin most other parts of the thesis. The rest of the chapter is dedicated to introducing the Feynman-Kac formula and the derivation of the $\\log \\text{RN}$ loss, which is the variance of the logarithm Radon-Nikodym derivative between the Feynman-Kac path measure and its variational approximation, over trajectories with fixed endpoints. The derivation includes necessary background in optimal control and an analogous derivation in continuous state space. Chapter~\\ref{chapter4} describes the methodology and implementation of the method, and Chapter~\\ref{chapter5} describes training and sampling experiments conducted. Chapter~\\ref{chapter6} contains concluding remarks.\n\n%********************************** %Chapter 1 Nomenclature **************************************\n\n% Latin expressions and shorthands\n\\nomenclature[z-0pbc]{p.b.c}{Periodic boundary condition}\n\\nomenclature[z-0eg]{e.g.}{Exempli gratia (\"for the sake of an example\")}\n\\nomenclature[z-0ie]{i.e.}{Id est (\"it is\")}\n\\nomenclature[z-0iid]{i.i.d}{Independent and identically distributed}\n\\nomenclature[z-0st]{s.t.}{Such that}\n\\nomenclature[z-0wrt]{w.r.t}{With respect to}\n\n% Other symbols\n\\nomenclature[x-expectation]{$\\mathbb{E}$}{Expectation}\n\\nomenclature[x-variance]{$\\operatorname{Var}$}{Variance}\n\\nomenclature[x-covariance]{$\\operatorname{Cov}$}{Covariance}\n\n% Machine Learning Shorthands\n\\nomenclature[Z-ML]{ML}{Machine Learning}\n\\nomenclature[Z-DL]{DL}{Deep Learning}\n\\nomenclature[Z-NN]{NN}{Neural Network}\n\\nomenclature[Z-DNN]{DNN}{Deep Neural Network}\n\\nomenclature[Z-CNN1]{CNN}{Convolutional Neural Network}\n\\nomenclature[Z-CNN]{pCNN}{Periodic Convolutional Neural Network}\n\n% Models Shorthand\n\\nomenclature[Z-TFIM]{TFIM}{Transverse Field Ising Model}\n\n% Monte Carlo Shorthands\n\\nomenclature[Z-DFT]{DFT}{Density Functional Theory}\n\\nomenclature[Z-DMFT]{DMFT}{Dynamical Mean Field Theory}\n\\nomenclature[Z-DMRG]{DMRG}{Density Matrix Renormalization group}\n\\nomenclature[Z-MC]{MC}{Monte Carlo}\n\\nomenclature[Z-QMC]{QMC}{Quantum Monte Carlo}\n\\nomenclature[Z-VMC]{VMC}{Variational Quantum Monte Carlo}\n\\nomenclature[Z-DMC]{DMC}{Diffusion Quantum Monte Carlo}\n\\nomenclature[Z-GFMC]{GFMC}{Green's function Quantum Monte Carlo}\n\n% Other Shorthands\n\\nomenclature[z-0pdf]{pdf}{Probability density function}\n\\nomenclature[Z-PDE]{PDE}{Partial Differential Equation}\n\\nomenclature[Z-QM]{QM}{Quantum Mechanics}\n\n\\nomenclature[Z-RN]{RN}{Radon-Nikodym}\n\\nomenclature[Z-FP]{FP}{Fokker-Planck}\n\\nomenclature[Z-FK]{FK}{Feynman-Kac}\n\\nomenclature[Z-SDE]{SDE}{Stochastic Differential Equations}\n\\nomenclature[Z-0cdf]{cdf}{Cumulative density function}\n\\nomenclature[Z-0stochprocs]{s.p.}{Stochastic process}\n\\nomenclature[Z-DTMC]{DTMC}{Discrete time Markov Chain}\n\\nomenclature[Z-CTMC]{CTMC}{Continuous time Markov Chain}\n\\nomenclature[Z-SEP]{SEP}{Symmetric Exclusion Process}\n\\nomenclature[Z-KL]{KL}{Kullback Liebler}\n\\nomenclature[Z-0mdp]{mdp}{Markov Decision Process}\n\n\\nomenclature[x-ratematrix]{$\\Gamma$}{Rate matrix}\n\\nomenclature[x-ratematrix]{$P$}{Transition matrix}\n\\nomenclature[x-kldiv]{$D_{\\mathrm{KL}}$}{Kullback-Liebler divergence}\n\\nomenclature[x-statespace]{S}{State space of a Markov process}\n\\nomenclature[x-reals]{$\\mathbb{R}$}{The set of real numbers}\n\\nomenclature[x-normal]{$\\mathcal{N}$}{The Gaussian distribution}\n\\nomenclature[x-measure]{$\\mathbb{P}$}{Measure}\n\\nomenclature[x-filtration]{$\\mathbb{F}$}{Filtration}\n\\nomenclature[x-field]{\"$\\mathcal{F}$\"}{$\\sigma$-field (algebra)}\n\\nomenclature[x-stochprocs]{$\\{X_t\\}$}{Stochastic process}\n\\nomenclature[x-randomvariable]{$\\{X\\}$}{Random variable}\n\\nomenclature[x-wiener]{$W_t$}{Wiener process, mathematical Brownian motion}\n\n\\nomenclature[x-gel]{$\\mathfrak{g}$}{Group element}\n\\nomenclature[x-group]{$\\mathfrak{G}$}{Group}\n\\nomenclature[z-MCMC]{MCMC}{Markov Chain Monte Carlo}\n\\nomenclature[z-MLP]{MLP}{Multilayer Perceptron}\n\\nomenclature[z-AD]{AD}{Automatic Differentiation}\n\\nomenclature[z-gCNN]{G-CNN}{Group Equivariant Convolutional Neural Network}", "meta": {"hexsha": "59ab5d12d1d2252e5f12ca965f1b02e400858826", "size": 6492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapter1/chapter1.tex", "max_stars_repo_name": "BlazStojanovic/MPhil_Thesis", "max_stars_repo_head_hexsha": "682aa0448efe563a8a8aee87d979628a890ce150", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/chapter1.tex", "max_issues_repo_name": "BlazStojanovic/MPhil_Thesis", "max_issues_repo_head_hexsha": "682aa0448efe563a8a8aee87d979628a890ce150", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/chapter1.tex", "max_forks_repo_name": "BlazStojanovic/MPhil_Thesis", "max_forks_repo_head_hexsha": "682aa0448efe563a8a8aee87d979628a890ce150", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 68.3368421053, "max_line_length": 1061, "alphanum_fraction": 0.7540049291, "num_tokens": 1618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4011858098188898}}
{"text": "\\documentclass[a4paper]{article}\n\n\\def\\npart{III}\n\n\\def\\ntitle{Analytic Number Theory}\n\\def\\nlecturer{T.\\ F.\\ Bloom}\n\n\\def\\nterm{Lent}\n\\def\\nyear{2019}\n\n\\input{header}\n\n\\usepackage{cancel}\n\n\\newtheorem*{fact}{Fact}\n\\theoremstyle{definition}\n\\newtheorem*{conjecture}{Conjecture}\n\n\\begin{document}\n\n\\input{titlepage}\n\n\\tableofcontents\n\n\\setcounter{section}{-1}\n\n\\section{Introduction}\n\nAnalytic number theory is the study of numbers using analysis. In particular it answers quantitative questions. ``Numbers'' means natural numbers in this course, which excludes \\(0\\).\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item How many primes are there? We know there are infinitely many but can we have a more precise answer? Let \\(\\pi(x)\\) be the number of primes smaller than or equal to \\(x\\). Then by the famous prime number theorem, \\(\\pi(x) \\sim \\frac{x}{\\log x}\\).\n  \\item How may twin primes are there? It is not known whethere there are infinitely many. From 2014 Zhang, Maynard, Polymath, there are infinitely many primes at most \\(246\\) apart. It's been conjectured that the asymptotic bound is \\(\\sim \\frac{x}{(\\log x)^2}\\).\n  \\item How many primes are there congruent to \\(a\\) mod \\(q\\) where \\((a, q) = 1\\)? There are infinitely many by Dirichlet's theorem. The guess is \\(\\frac{1}{\\varphi(q)}\\frac{x}{\\log x}\\). This is known for small \\(q\\).\n  \\end{enumerate}\n\\end{eg}\n\nThe course is divided into four parts:\n\\begin{enumerate}\n\\item elementary techniques (using real analysis),\n\\item sieve methods,\n\\item Riemann zeta function/Prime number theorem (using complex analysis),\n\\item primes in arithmetic progression.\n\\end{enumerate}\n\n\\section{Elementary techniques}\n\nReview of asymptotic notations:\n\\begin{itemize}\n\\item Landau notation: \\(f(x) = O(g(x))\\) if there is \\(C > 0\\) such that \\(|f(x)| \\leq C|g(x)|\\) for all large enough \\(x\\).\n\\item Vinogradov notation: \\(f \\ll g\\) is the same as \\(f = O(g)\\).\n\\item \\(f \\sim g\\) if \\(\\lim_{x \\to \\infty} \\frac{f(x)}{g(x)} = 1\\), i.e.\\ \\(f = (1 + o(1)) g\\).\n\\item \\(f = o(g)\\) if \\(\\lim_{x \\to \\infty} \\frac{f(x)}{g(x)} = 0\\).\n\\end{itemize}\n\n\\subsection{Arithmetic functions}\n\nThese are just functions \\(f: \\N \\to \\C\\). An important operation for multiplicative number theory is \\emph{multiplicative convolution}\\index{multiplicative convolution}\n\\[\n  f * g(n) = \\sum_{ab = n} f(a)g(b)\n\\]\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(1(n) = 1\\) for all \\(n\\). Caution: this is not identity on \\(\\N\\).\n  \\item \\emph{Möbius function}\\index{Möbius function}\n    \\[\n      \\mu(n) =\n      \\begin{cases}\n        (-1)^k & \\text{ if } n = p_1 \\dots p_k \\\\\n        0 & \\text{ if \\(n\\) is divisible by a square}\n      \\end{cases}\n    \\]\n  \\item \\emph{Liouville function}\n    \\[\n      \\lambda(n) = (-1)^k\n    \\]\n    if \\(n = p_1 \\dots p_k\\) where \\(p_i\\)'s are not necessarily distinct.\n  \\item \\emph{divisor function}\n    \\[\n      \\tau(n) = \\#d \\text{ such that } d \\divides n = \\sum_{ab = n} 1 = 1 * 1(n).\n    \\]\n    This is sometimes also denoted by \\(d(n)\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{definition}[multiplicative function]\\index{multiplicative function}\n  An arithmetic function \\(f\\) is \\emph{multiplicative} if\n  \\[\n    f(nm) = f(n)f(m)\n  \\]\n  whenever \\((n, m) = 1\\).\n\\end{definition}\n\nIn particular a multiplicative function is determined by its values on prime powers \\(f(p^k)\\).\n\n\\begin{fact}\n  If \\(f\\) and \\(g\\) are multiplicative then so is \\(f * g\\).\n\\end{fact}\n\n\\begin{eg}\n  \\(1, \\mu, \\lambda, \\tau\\) are multiplicative. \\(\\log n\\) is not multiplicative.\n\\end{eg}\n\n\\begin{fact}[Möbius inversion]\\index{Möbius inversion}\n  \\(1 * f = g\\) if and only if \\(\\mu * g = f\\). That is,\n  \\[\n    \\sum_{d \\divides n} f(d) = g(n)\n  \\]\n  if and only if\n  \\[\n    \\sum_{d \\divides n} g(d) \\mu(\\frac{n}{d}) = f(n).\n  \\]\n\n  For example\n  \\[\n    \\sum_{d \\divides n} \\mu(d) =\n    \\begin{cases}\n      1 & n = 1 \\\\\n      0 & \\text{otherwise}\n    \\end{cases}\n    = 1 * \\mu (n)\n  \\]\n  is multiplicative so enough to check the identity for prime powers. If \\(n = p^k\\) then \\(\\{d: d \\divides n\\} = \\{1, p, \\dots, p^k\\}\\) so LHS equals to \\(1 - 1 + 0 + \\dots = 0\\) unless \\(k = 1\\) when LHS equals to \\(\\mu(1) = 1\\).\n\\end{fact}\n\nOur goal is to study primes. Our first might be that we shall work with\n\\[\n  1_p(n) =\n  \\begin{cases}\n    1 & n \\text{ prime} \\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n\\]\nas then \\(\\pi(x) = \\sum_{1 \\leq n \\leq x} 1_p(n)\\). But this is very awkward to work with, as to begin with, this is not multiplicative. Instead, we are going to work almost exclusively with \\emph{von Mangoldt function}\\index{von Mangoldt function}\n\\[\n  \\Lambda(n) =\n  \\begin{cases}\n    \\log p & n = p^k \\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n\\]\n``assign weight \\(\\log p\\) to prime power \\(n\\)''\n\n\\begin{lemma}\n  \\[\n    1 * \\Lambda = \\log.\n  \\]\n  and\n  \\[\n    \\mu * \\log = \\Lambda.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  The second part follows from Möbius inversion. Thus if \\(n = p_1^{k_1} \\dots p_r^{k_r}\\),\n  \\begin{align*}\n    1 * \\Lambda(n)\n    &= \\sum_{d \\divides n} \\Lambda(d)\n    = \\sum_{i = 1}^r \\sum_{j = 1}^{k_i} \\Lambda(p_i^j) \\\\\n    &= \\sum_{i = 1}^r \\sum_{j = 1}^{k_i} \\log(p_i)\n    = \\sum_{i = 1}^r k_i \\log p_i \\\\\n    &= \\sum_{i = 1}^r \\log (p_i^{k_i})\n    = \\log n\n  \\end{align*}\n\\end{proof}\n\nTherefore\n\\begin{align*}\n  \\Lambda(n)\n  &= \\sum_{d \\divides n} \\mu(d) \\log(\\frac{n}{d}) \\\\\n  &= \\log n \\sum_{d \\divides n} \\mu(d) - \\sum_{d \\divides n} \\mu(d) \\log d \\\\\n  &= - \\sum_{d \\divides n} \\mu(d) \\log d\n\\end{align*}\nFor example\n\\[\n  \\sum_{1 \\leq n \\leq x} \\Lambda(n)\n  = - \\sum_{1 \\leq n \\leq x} \\sum_{d \\divides n} \\mu(d) \\log d\n  = - \\sum_{d \\leq x} \\mu(d) \\log d \\left(\\sum_{1 \\leq n \\leq x, d \\divides n} 1\\right)\n\\]\nby reversing summation. But now the term in the inner summation is very easy to understand:\n\\[\n  \\sum_{1 \\leq n \\leq x, d \\divides n} 1 = \\floor*{\\frac{x}{d}} = \\frac{x}{d} + O(1).\n\\]\nThus\n\\[\n  \\sum_{1 \\leq n \\leq x} \\Lambda(n)\n  = -x \\sum_{d \\leq x} \\mu(d) \\frac{\\log d}{d} + O\\left(\\sum_{d \\leq x} \\mu(d) \\log d\\right).\n\\]\nWe'll see more of these examples.\n\n\\subsection{Summation}\n\nGiven an arithmetic function \\(f\\), we can ask for estimates of \\(\\sum_{1 \\leq n \\leq x} f(n)\\). We say that \\(f\\) has \\emph{average order}\\index{average order} \\(g\\) if\n\\[\n  \\sum_{1 \\leq n \\leq x} f(n) \\sim x g(x).\n\\]\n``average size of \\(f\\) is \\(g\\)''.\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(f = 1\\) then\n    \\[\n      \\sum_{1 \\leq n \\leq x} f(x) = \\floor{x} = x + O(1) \\sim x\n    \\]\n    so average order of \\(1\\) is \\(1\\).\n  \\item \\(f(n) = n\\):\n    \\[\n      \\sum_{1 \\leq n \\leq x} n \\sim \\frac{x^2}{2}\n    \\]\n    so average of \\(n\\) is \\(\\frac{n}{2}\\).\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{lemma}[partial summation]\\index{partial summation}\n  If \\((a_n)\\) is a sequence of complex numbers and \\(f\\) is such that \\(f'\\) is continuous. Then\n  \\[\n    \\sum_{1 \\leq n \\leq x} a_n f(n) = A(x) f(x) - \\int_1^x A(t)f'(t) dt\n  \\]\n  where \\(A(x) = \\sum_{1 \\leq n \\leq x} a_n\\).\n\\end{lemma}\n\nThis is the discrete analogus of integration by parts.\n\n\\begin{proof}\n  Suppose \\(x = N\\) is an integer. Note that \\(a_n = A(n) - A(n - 1)\\), so\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq N} a_nf(n)\n    &= \\sum_{1 \\leq n \\leq N} f(n) (A(n) - A(n - 1)) \\\\\n    &= A(N)f(N) - \\sum_{n = 1}^{N - 1} A(n) (f(n + 1) - f(n))\n  \\end{align*}\n  Now\n  \\[\n    f(n + 1) - f(n) = \\int_n^{n + 1} f'(t) dt\n  \\]\n  so\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq N} a_n f(n)\n    &= A(N)f(N) - \\sum_{n = 1}^{N - 1} A(n) \\int_n^{n + 1} f'(t) dt \\\\\n    &= A(N)f(N) - \\int_1^N A(t) f'(t) dt\n  \\end{align*}\n  where the last step is because \\(A(n) = A(t)\\) for \\(t \\in [n, n + 1)\\).\n\n  If \\(N = \\floor x\\) then\n  \\[\n    A(x)f(x)\n    = A(N)f(x)\n    = A(N) f(N) + \\int_N^x f'(t) dt.\n  \\]\n\\end{proof}\n\nAs a simple application\n\n\\begin{lemma}\n  \\[\n    \\sum_{1 \\leq n \\leq x} \\frac{1}{n} = \\log x + \\gamma + O(\\frac{1}{x}).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Partial summation with \\(f(x) = \\frac{1}{x}\\) and \\(a_n = 1\\), so \\(A(x) = \\floor x\\). Therefore\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq x} \\frac{1}{n}\n    &= \\frac{\\floor x}{x} + \\int_1^x \\frac{\\floor t}{t^2} dt\n    \\intertext{Write \\(\\floor t= t - \\{t\\}\\),} \\\\\n    &= 1 + O(\\frac{1}{x}) + \\int_1^x \\frac{1}{t} dt - \\int_1^x \\frac{\\{t\\}}{t^2} dt \\\\\n    &= 1 + O(\\frac{1}{x}) + \\log x - \\int_1^\\infty \\frac{\\{t\\}}{t^2} dt + \\underbrace{\\int_x^\\infty \\frac{\\{t\\}}{t^2} dt}_{\\leq \\int_x^\\infty \\frac{1}{t^2} dt \\leq \\frac{1}{x}} \\\\\n    &= \\gamma + O(\\frac {1}{x}) + \\log x + O(\\frac{1}{x}) \\\\\n    &= \\log x + \\gamma + O(\\frac{1}{x})\n  \\end{align*}\n\\end{proof}\n\nThis is an amazing result and the only thing we did is to replace the discrete summation by the continuous analogue to it. In essence this is the whole reason analytic number theory works.\n\n\\(\\gamma\\) can be seen as a measure of the difference between between \\(\\log\\) and its discrete approximation. It is called \\emph{Euler-Mascheroni constant}\\index{Euler-Mascheroni constant}.\nSurprisingly little is known about \\(\\gamma\\). It is approximately \\(0.577\\dots\\). We don't even know if \\(\\gamma\\) is rational or not.\n\n\\begin{lemma}\n  \\[\n    \\sum_{1 \\leq n \\leq x} \\log n = x \\log x - x + O(\\log x).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Partial summation with \\(f(x) = \\log x, a_n = 1\\) so \\(A(x) = \\floor{x}\\). As a side note, in the previous example, most error comes from the integral term (the mass is evenly distributed). By constrast in this example most error comes from the ``sum'' term.\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq x} \\log n\n    &= \\floor{x} \\log x - \\int_1^x \\frac{\\floor{t}}{t} dt \\\\\n    &= x \\log x + O(\\log x) - \\int_1^x dt + O(\\int_1^x \\frac{1}{t}dt) \\\\\n    &= x \\log x + O(\\log x) - x + O(\\log x)\n  \\end{align*}\n\\end{proof}\n\n\\subsection{Divisor function}\n\nRecall that\n\\[\n  \\tau(n) = 1 * 1(n) = \\sum_{ab = n} 1 = \\sum_{d \\divides n} 1.\n\\]\n\n\\begin{theorem}\n  \\[\n    \\sum_{1 \\leq n \\leq x} \\tau(n) = x \\log x + (2 \\gamma - 1) x + O(x^{1/2})\n  \\]\n  so in particular average order of \\(\\tau\\) is \\(\\log\\).\n\\end{theorem}\n\n\\begin{proof}\n  First attempt:\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq x} \\tau(n)\n    &= \\sum_{1 \\leq n \\leq x} \\sum_{d \\divides n} 1\n    = \\sum_{1 \\leq d \\leq x} \\sum_{1 \\leq n \\leq x, d \\divides n} 1 \\\\\n    &= \\sum_{1 \\leq d \\leq x} \\floor*{\\frac{x}{d}} \\\\\n    &= \\sum_{1 \\leq d \\leq x} \\frac{x}{d} + O(x)\n    = x \\sum_{1 \\leq d \\leq x} \\frac{1}{d} + O(x) \\\\\n    &= x\\log x + \\gamma x + O(x)\n  \\end{align*}\n  This is not a very good bound (the error might be as large as one of the terms!) but shows that at least the first term is correct. The main drawback is we used the estimate\n  \\[\n    \\sum_{1 \\leq d \\leq x} O(1) = O(x).\n  \\]\n\n  To reduce the error term, we use \\emph{(Dirichlet's) hyperbola trick}\\index{hyperbola trick}\n  \\[\n    \\sum_{1 \\leq n \\leq x} \\tau(n)\n    = \\sum_{1 \\leq n \\leq x} \\sum_{ab = n} 1\n    = \\sum_{ab \\leq x} 1\n    = \\sum_{a \\leq x} \\sum_{b \\leq x/a} 1\n  \\]\n  The intuition is like this: \\(\\sum_{1 \\leq n \\leq x} \\tau(n)\\) counts the number of integral points below the hyperbola \\(k_1k_2 = x\\) in the first quadrant. The old methods amounts to an estimation by integral, while in the new method we count the number of points lying below the line \\(k_2 = x^{1/2}\\), add the number of points to the left of \\(k_1 = x^{1/2}\\), and finally subtract those points in the box \\([0, x^{1/2}]^2\\) which are double counted.\n\n  Thus when summing over \\(ab \\leq x\\), we can sum over \\(a \\leq x^{1/2}\\) and \\(b \\leq x^{1/2}\\) respectively, and then minus pairs \\(a, b \\leq \\sqrt x\\). Thus\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq x} \\tau(n)\n    &= \\sum_{a \\leq x^{1/2}} \\sum_{b \\leq x/a} 1 + \\sum_{b \\leq x^{1/2}} \\sum_{a \\leq x/b} 1 - \\sum_{a, b \\leq x^{1/2}} 1 \\\\\n    &= 2 \\sum_{a \\leq x^{1/2}} \\floor*{\\frac{x}{a}} - \\floor{x^{1/2}}^2 \\\\\n    &= 2 \\sum_{a \\leq x^{1/2}} \\frac{x}{a} + O(x^{1/2}) - x + O(x^{1/2}) \\\\\n    &= 2x\\log x^{1/2} + 2 \\gamma x - x + O(x^{1/2}) \\\\\n    &= x \\log x + (2\\gamma - 1) x + O(x^{1/2})\n  \\end{align*}\n\\end{proof}\n\n\\begin{remark}\n  Improving this \\(O(x^{1/2})\\) error term is a famous and hard problem. Probably \\(O(x^{1/4 + \\varepsilon})\\)? The best result so far is \\(O(x^{0.3149})\\).\n\\end{remark}\n\nA note on average order: \\(\\tau\\) has average order \\(\\log\\) does not mean \\(\\tau(n) \\ll \\log n\\), i.e.\\ average order does not imply individual values.\n\n\\begin{theorem}\n  For all \\(n\\)\n  \\[\n    \\tau(n) \\leq n^{O(\\frac{1}{\\log \\log n})}.\n  \\]\n  In particular \\(\\tau(n) \\ll_\\varepsilon n^\\varepsilon\\) for all \\(\\varepsilon > 0\\) where \\(\\ll_\\varepsilon\\) means that \\(|\\tau(n)| \\leq C_\\varepsilon |n^\\varepsilon|\\) eventually where \\(C_\\varepsilon\\) is a constant depending on \\(\\varepsilon\\).\n\\end{theorem}\n\nAs a side note, asymptotic bounds such as \\(\\log \\log n\\) are quite common in analytic number theory and here is how to reason with them: as \\(n \\to \\infty\\), \\(\\log n\\) grows slower than any polynomial, so \\(\\log \\log n\\) grows slower than \\(\\log P(n)\\) for any polynomial. Another way is to write \\(n = e^{\\log n}\\) and then\n\\[\n  n^{O(\\frac{1}{\\log \\log n})} = \\exp (O(\\frac{\\log n}{\\log \\log})).\n\\]\n\n\\begin{proof}\n  \\(\\tau\\) is multiplicative so enough to calculate at prime powers. \\(\\tau(p^k) = k + 1\\) so if \\(n = p_1^{k_1} \\cdots p_r^{k_r}\\) then \\(\\tau(n) = \\prod_{i = 1}^r (k_i + 1)\\). Let \\(\\varepsilon > 0\\) to be chosen later and consider the ratio\n  \\[\n    \\frac{\\tau(n)}{n^\\varepsilon}\n    = \\prod_{i = 1}^r \\frac{k_i + 1}{p^{k_i\\varepsilon}}.\n  \\]\n  Now entering the trick: split into big and small cases. Note as \\(p\\) goes large, \\(\\frac{k + 1}{p^{k \\varepsilon}} \\to 0\\). In particular if \\(p \\geq 2^{1/\\varepsilon}\\) then\n  \\[\n    \\frac{k + 1}{p^{k\\varepsilon}} \\leq \\frac{k + 1}{2^k} \\leq 1.\n  \\]\n  What about small \\(p\\)? It is important to remind ourselves that we're dealing with primes and \\(p\\) can't run below \\(2\\). In this case\n  \\[\n    \\frac{k + 1}{p^{k\\varepsilon}} \\leq \\frac{k + 1}{2^{k\\varepsilon}} \\leq \\frac{1}{\\varepsilon}\n  \\]\n  this is because \\(x + \\frac{1}{2} \\leq 2^x\\) for \\(x \\geq 0\\) so \\(\\varepsilon h + \\varepsilon \\leq 2^{k \\varepsilon}\\) if \\(\\varepsilon \\leq \\frac{1}{2}\\) (the details are not so important compared to the conclusion that this can be bounded). Therefore\n  \\[\n    \\frac{\\tau(n)}{n^\\varepsilon}\n    \\leq \\prod_{i = 1, p_i < 2^{1/\\varepsilon}}^r \\frac{k_i + 1}{p^{k_i \\varepsilon}}\n    \\leq \\left( \\frac{1}{\\varepsilon} \\right)^{\\pi(2^{1/\\varepsilon})}\n    \\leq \\left( \\frac{1}{\\varepsilon} \\right)^{2^{1/\\varepsilon}}\\footnote{Behold what a wasteful bound we give in the last inequality! But that almost has no effect in the final result.}.\n  \\]\n  Now we need to choose an optimal \\(\\varepsilon\\). Another trick: if we want to minimise \\(f(x) + g(x)\\), choose \\(x\\) such that \\(f(x) = g(x)\\). Have\n  \\[\n    \\tau(n)\n    \\leq n^\\varepsilon \\varepsilon^{-2^{1/\\varepsilon}}\n    = \\exp (\\varepsilon \\log n + 2^{1/\\varepsilon} \\log (1/\\varepsilon)).\n  \\]\n  Choose \\(\\varepsilon\\) such that \\(\\log n \\approx 2^{1/\\varepsilon}\\) (again, only a rough guess is needed), i.e.\\ \\(\\varepsilon \\approx \\frac{1}{\\log \\log n}\\) and get\n  \\begin{align*}\n    \\tau(n)\n    &\\leq n^{\\frac{1}{\\log \\log n}} (\\log \\log n)^{2^{\\log \\log n}} \\\\\n    &= n^{\\frac{1}{\\log \\log n}} \\exp ((\\log n)^{\\log 2} \\log \\log \\log n) \\\\\n    &\\leq n^{O(\\frac{1}{\\log \\log n})}.\n  \\end{align*}\n\\end{proof}\n\n\\subsection{Estimates for the primes}\n\nRecall that\n\\begin{align*}\n  \\pi(x) &= \\# \\{\\text{primes } \\leq x\\} = \\sum_{1 \\leq n \\leq x} 1_p(n) \\\\\n  \\psi(x) &= \\sum_{1 \\leq n \\leq x} \\Lambda(n)\n\\end{align*}\nThe second one is sometimes known as \\emph{Chebyshev's function}\\index{Chebyshev's function}. Prime number theorem asserts that \\(\\pi(x) \\sim \\frac{x}{\\log x}\\) or equivalently \\(\\psi(x) \\sim x\\) (this equivalence will be shown later).\n\nAlthough Euclid's prove in 300 BC the infinitude of prime, It was 1850 before the correct magnitude of \\(\\pi(x)\\) was proved. Chebyshev showed that\n\\[\n  \\pi(x) \\asymp \\frac{x}{\\log x}\n\\]\nwhere \\(f \\asymp g\\) means that \\(g \\ll f \\ll g\\).\n\n\\begin{theorem}[Chebyshev]\n  \\[\n    \\psi(x) \\asymp x.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  First we'll prove the lower bound, i.e.\\ \\(\\psi(x) \\gg x\\). Recall that \\(1 * \\Lambda = \\log\\). Here comes in a genuine\\footnote{Read unmotivated.} trick: find something that equals \\(1\\). Then \\(\\psi(x) = \\sum_{1 \\leq n \\leq x} \\Lambda(n) \\cdot 1\\) can be rearranged. We'll use the identity\n  \\[\n    \\floor{x} = 2 \\floor*{\\frac{x}{2}} + 1\n  \\]\n  for \\(x \\geq 0\\). Either see it directly or a simple verification: if \\(\\frac{x}{2} = n + \\theta\\) where \\(\\theta \\in [0, 1)\\) then \\(\\floor*{\\frac{x}{2}} = n\\) and \\(\\floor{x} = \\floor{2n + 2\\theta} = 2n \\text{ or } 2n + 1\\). Then\n  \\begin{align*}\n    \\psi(x)\n    &\\geq \\sum_{1 \\leq n \\leq x} \\Lambda(x) \\left( \\floor*{\\frac{x}{n}} - 2 \\floor*{\\frac{x}{2n}} \\right)\\\\\n    \\intertext{Note that \\(\\floor*{\\frac{x}{n}} = \\sum_{m \\leq x/n} 1\\),}\n    &=\\sum_{n \\leq x} \\Lambda(n) \\sum_{m \\leq x/n} 1 - 2 \\sum_{n \\leq x} \\Lambda(n) \\sum_{m \\leq x/2n} 1 \\\\\n    &=  \\sum_{nm \\leq x} \\Lambda(n) - 2 \\sum_{nm \\leq x/2} \\Lambda(n) \\\\\n    \\intertext{Write \\(d = nm\\),}\n    &= \\sum_{d \\leq x} 1 * \\Lambda(d) - 2 \\sum_{d \\leq x/2} 1 * \\Lambda(d) \\\\\n    &= \\sum_{d \\leq x} \\log d - 2 \\sum_{d \\leq x/2} \\log d \\\\\n    &= x \\log x - x + O(\\log x) - 2 \\left( \\frac{x}{2} \\log \\frac{x}{2} - \\frac{x}{2} + O(\\log x) \\right) \\\\\n    &= (\\log 2) x + O(\\log x) \\\\\n    &\\gg x\n  \\end{align*}\n\n  For the upper bound,\n  \\[\n    \\floor{x} = 2 \\floor*{\\frac{x}{2}} + 1\n  \\]\n  for \\(x \\in (1, 2)\\) so\n  \\begin{align*}\n    \\psi(x) - \\psi(\\frac{x}{2})\n    &= \\sum_{x/2 < n < x} \\Lambda(n) \\\\\n    &\\leq \\sum_{1 \\leq n \\leq x} \\Lambda(n) \\left( \\floor*{\\frac{x}{n}} - 2 \\floor*{\\frac{x}{2n}} \\right) \\\\\n    & \\leq (\\log 2) x + O(\\log x)\n  \\end{align*}\n  Thus\n  \\begin{align*}\n    \\psi(x)\n    &= (\\psi(x) - \\psi(x/2)) + (\\psi(x/2) - \\psi(x/4)) + \\dots \\\\\n    &\\leq \\log 2 \\cdot (x + x/2 + x/4 + \\dots ) \\\\\n    &= 2 \\log 2 \\cdot x\n  \\end{align*}\n  Thus we have shown\n  \\[\n    (\\log 2) x \\leq \\psi(x) \\leq (\\log 4) x.\n  \\]\n\\end{proof}\n\n\\begin{lemma}\n  \\[\n    \\sum_{p \\leq x} \\frac{\\log p}{p} = \\log x + O(1).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Recall that \\(\\log = 1 * \\Lambda\\) so\n  \\begin{align*}\n    \\sum_{n \\leq x} \\log n\n    &= \\sum_{ab \\leq x} \\Lambda(a)\n    = \\sum_{a \\leq x} \\Lambda(a) \\sum_{b \\leq x/a} 1 \\\\\n    &= \\sum_{a \\leq x} \\Lambda(a) \\floor*{\\frac{x}{a}} \\\\\n    &= x \\sum_{a \\leq x} \\frac{\\Lambda(a)}{a} + O(\\psi(x)) \\\\\n    &= x \\sum_{a \\leq x} \\frac{\\Lambda(a)}{a} + O(x) \\\\\n  \\end{align*}\n  Note where we used Chebyshev's bound. Since\n  \\[\n    \\sum_{n \\leq x} \\log x = x\\log x - x + O(\\log x),\n  \\]\n  have\n  \\[\n    \\sum_{n \\leq x} \\frac{\\Lambda(n)}{n}\n    = \\log x - 1 + O(\\frac{\\log x}{x}) + O(1)\n    = \\log x + O(1)\n  \\]\n  Remain to note the contribution from prime powers \\(\\geq 2\\) are ``small'':\n  \\begin{align*}\n    \\sum_{p \\leq x} \\sum_{n = 2}^\\infty \\frac{\\log p}{p^n}\n    &= \\sum_{p \\leq x} \\log p \\sum_{n = 2}^\\infty \\frac{1}{p^n} \\\\\n    &= \\sum_{p \\leq x} \\frac{\\log p}{p^2 - p} \\\\\n    &\\leq \\sum_{p = 2}^\\infty \\frac{1}{p^{3/2}} \\\\\n    &= O(1)\n  \\end{align*}\n  so\n  \\[\n    \\sum_{n \\leq x} \\frac{\\Lambda(n)}{n} = \\sum_{p \\leq x} \\frac{\\log p}{p} + O(1).\n  \\]\n\\end{proof}\n\n\\begin{lemma}\n  \\[\n    \\pi(x) = \\frac{\\psi(x)}{\\log x} + O(\\frac{x}{(\\log x)^2}).\n  \\]\n  In particular \\(\\pi(x) \\asymp \\frac{x}{\\log x}\\) and prime number theorem \\(\\pi(x) \\sim \\frac{x}{\\log x}\\) is equivalent to \\(\\psi(x) \\sim x\\).\n\\end{lemma}\n\n\\begin{proof}\n  Idea is to use partial summation: let\n  \\[\n    \\theta(x)\n    = \\sum_{p \\leq x} \\log p\n    = \\pi(x) \\log x - \\int_1^x \\frac{\\pi(t)}{t} dt.\n  \\]\n  First problem: \\(\\psi(x)\\) sums over not only primes but also prime powers. We can use a previous trick to remove contributions from prime powers:\n  \\begin{align*}\n    \\psi(x) - \\theta(x)\n    &= \\sum_{k = 2}^\\infty \\sum_{p^k \\leq x} \\log p\n    = \\sum_{k = 2}^\\infty \\theta(x^{1/k}) \\\\\n    &\\leq \\sum_{k = 2}^{\\log x} \\psi(x^{1/k})\n    \\leq \\sum_{k = 2}^{\\log x} x^{1/k} \\\\\n    &\\leq x^{1/2} \\log x\n  \\end{align*}\n  Therefore\n  \\begin{align*}\n    \\psi(x)\n    &= \\pi(x) \\log x + O(x^{1/2} \\log x) - \\int_1^x \\frac{\\pi(t)}{t} dt \\\\\n    \\intertext{As \\(\\pi(t) \\leq \\frac{t}{\\log t}\\),}\n    &= \\pi(x) \\log x + O(x^{1/2} \\log x) + O(\\int_1^x \\frac{1}{\\log t} dt) \\\\\n    &= \\pi(x) \\log x + O(\\frac{x}{\\log x})\n  \\end{align*}\n  For \\(\\pi(t) < \\frac{t}{\\log t}\\), note the trivial bound \\(\\pi(t) \\leq t\\) so\n  \\[\n    \\psi(x) = \\pi(x) \\log x + O(x^{1/2} \\log x) + O(x)\n  \\]\n  so \\(\\pi(x)\\log x = O(x)\\). Thus we used the trivial bound to get a better bound and use that to do actual work.\n\\end{proof}\n\n\\begin{lemma}\n  \\[\n    \\sum_{p \\leq x} \\frac{1}{p} = \\log \\log x + b + O(\\frac{1}{\\log x})\n  \\]\n  where \\(b\\) is some constant.\n\\end{lemma}\n\nCompare to \\(\\sum_{1 \\leq n \\leq x} \\frac{1}{n}\\).\n\n\\begin{proof}\n  Partial summation. Let\n  \\[\n    A(x) = \\sum_{p \\leq x} \\frac{\\log p}{p} = \\log x + R(x)\n  \\]\n  where \\(R(x) = O(1)\\). Then (summing from \\(2\\) to prevent \\(\\log t = 0\\))\n  \\begin{align*}\n    \\sum_{2 \\leq p \\leq x} \\frac{1}{p}\n    &= \\frac{A(x)}{\\log x} + \\int_2^x \\frac{A(t)}{t (\\log t)^2} dt \\\\\n    &= 1 + O(\\frac{1}{\\log x}) + \\int_2^x \\frac{1}{t \\log t} dt + \\int_2^x \\frac{R(t)}{t(\\log t)^2} dt\n  \\end{align*}\n  Note that \\(\\int_2^\\infty \\frac{R(t)}{t (\\log t)^2} dt\\) exists, say \\(C\\). Then\n  \\begin{align*}\n    \\sum_{2 \\leq p \\leq x} \\frac{1}{p}\n    &= 1 + C + O(\\frac{1}{\\log x}) + \\log \\log x - \\log \\log 2 + O(\\int_x^\\infty \\frac{1}{t (\\log t)^2} dt) \\\\\n    &= \\log \\log x + b + O(\\frac{1}{\\log x})\n  \\end{align*}\n  It turns out \\(b\\) can be expressed in terms of \\(\\gamma\\).\n\\end{proof}\n\n\\begin{theorem}[Chebyshev]\n  If \\(\\pi(x) \\sim c \\frac{x}{\\log x}\\) then \\(c = 1\\).\n\\end{theorem}\n\nNote that this does not prove prime number theorem. Historically this is a surprise: a following corollary says that if \\(\\pi(x) \\sim \\frac{x}{\\log x - A(x)}\\) then \\(A \\sim 1\\). But Legendre and Gauss et al have conjectured that \\(A \\approx 1.08 \\dots\\), just by looking up the prime table.\n\n\\begin{proof}\n  Partial summation on \\(\\sum_{p \\leq x} \\frac{1}{p}\\):\n  \\begin{align*}\n    \\sum_{p \\leq x} \\frac{1}{p}\n    &= \\frac{\\pi(x)}{x} + \\int_1^x \\frac{\\pi(t)}{t^2} dt \\\\\n    \\intertext{If \\(\\pi(x) = (c + o(1)) \\frac{x}{\\log x}\\) then}\n    &= \\frac{c}{\\log x} + o(\\frac{1}{\\log x}) + (c + o(1)) \\int_1^x \\frac{1}{t \\log t} dt \\\\\n    &= O(\\frac{1}{\\log x}) + (c + o(1)) \\log \\log x\n  \\end{align*}\n  But\n  \\[\n    \\sum_{p \\leq x} \\frac{1}{p} = (1 + o(1)) \\log \\log x\n  \\]\n  so \\(c = 1\\).\n\\end{proof}\n\n\\begin{lemma}\n  \\[\n    \\prod_{p \\leq x} \\left( 1 - \\frac{1}{p} \\right)^{-1} = c\\log x + O(1)\n  \\]\n  where \\(c\\) is some constant.\n\\end{lemma}\n\n\\begin{proof}\n  We have only dealt with summations so far so take \\(\\log\\),\n  \\begin{align*}\n    \\log \\prod_{p \\leq x} \\left( 1 - \\frac{1}{p} \\right)^{-1}\n    &= - \\sum_{p \\leq x} \\log (1 - \\frac{1}{p}) \\\\\n    &= \\sum_{p \\leq x} \\sum_k \\frac{1}{k p^k} \\\\\n    &= \\sum_{p \\leq x} \\frac{1}{p} + \\sum_{k \\geq 2} \\sum_{p \\leq x} \\frac{1}{kp^k} \\\\\n    &= \\log \\log x + c' + O(\\frac{1}{\\log x}).\n  \\end{align*}\n  using \\(\\log (1 - t) = - \\sum_k \\frac{t^k}{k}\\).\n\n  To undo the \\(\\log\\), note that \\(e^x = 1 + O(x)\\) for \\(|x| \\leq 1\\) so\n  \\begin{align*}\n    \\prod_{p \\leq x} \\left( 1 - \\frac{1}{p} \\right)^{-1}\n    &= c \\log x \\exp (O(\\frac{1}{\\log x})) \\\\\n    &= c \\log x (1 + O(\\frac{1}{\\log x})) \\\\\n    &= c \\log x + O(1)\n  \\end{align*}\n  It turns out that \\(c = e^\\gamma \\approx 1.78 \\dots\\).\n\\end{proof}\n\n\\subsubsection{Aside: Why is prime number theorem so hard?}\n\nIt seems that we've made quite a progress without too much effort. But how far are we from prime number theorem and if the answer is ``quite far'', what makes it so resistant to elementary methods?\n\nProbabilistic heuristic: fix \\(p\\) prime, ``probability'' that a random \\(n\\) satisfies \\(p \\divides n\\) is \\(\\frac{1}{p}\\). What is the ``probability'' that \\(n\\) is prime then? \\(n\\) is a prime if and only if \\(n\\) has no prime divisors \\(p \\leq n^{1/2}\\). Guess that the events ``divisble by \\(p\\)'' are independent, then ``probability'' that \\(n\\) is prime is roughly\n\\[\n  \\prod_{p \\leq n^{1/2}} \\left( 1 - \\frac{1}{p} \\right)\n  \\approx \\frac{1}{c \\log n^{1/2}}\n  = \\frac{2}{c} \\frac{1}{\\log n}.\n\\]\nThus use some questionable squiggles,\n\\[\n  \\pi(x)\n  = \\sum_{n \\leq x} 1_{n \\text{ prime}}\n  \\approx \\frac{2}{c} \\sum_{n \\leq x} \\frac{1}{\\log n}\n  \\approx \\frac{2}{c} \\frac{x}{\\log x}\n  \\approx 2e^{-\\gamma} \\frac{x}{\\log x}\n\\]\nThis constant is approximately \\(1.122\\dots\\), which contradicts Chebyshev's theorem. Therefore somehow the heuristics is wrong: it gives 12\\% more prime than should.\n\nOne reason is that the error terms are so close to the main term that when we do \\(\\approx\\) they accummulate and excees the main term. Another reason is of course that the ``independence'' of primes are completely false. From an analytic point of view, this can be seen as saying that the ``interference terms'' are not so small that they can be ignored.\n\nThis may explain why heuristics don't work. But can we bound \\(\\pi\\) by elementary methods? Recall that \\(\\mu * \\log = \\Lambda\\) so\n\\begin{align*}\n  \\psi(x)\n  &= \\sum_{n \\leq x} \\Lambda(n) \\\\\n  &= \\sum_{ab \\leq x} \\mu(a) \\log b \\\\\n  &= \\sum_{a \\leq x} \\mu(a) \\left( \\sum_{b \\leq x/a} \\log b \\right)\n\\end{align*}\nRecall that\n\\[\n  \\sum_{m \\leq x} \\log m = x \\log x - x + O(\\log x),\n\\]\nbut if we just plug this in we will get a trouble. Instead use another trick: consider\n\\[\n  \\sum_{m \\leq x} \\tau(m) = x \\log x + (2 \\psi - 1) x + O(x^{1/2}).\n\\]\nThus\n\\[\n  \\psi(x)\n  = \\sum_{a \\leq x} \\mu(a) \\left( \\sum_{b \\leq x/a} \\tau(b) - 2\\gamma \\frac{x}{a} + O(\\frac{x^{1/2}}{a^{1/2}}) \\right).\n\\]\nThe first term is (essentially \\(\\mu * \\tau = 1\\))\n\\begin{align*}\n  \\sum_{ab \\leq x} \\mu(a)\\tau(b)\n  &= \\sum_{abc \\leq x} \\mu(a) \\\\\n  &= \\sum_{b \\leq x} \\sum_{ac \\leq x/b} \\mu(a) \\\\\n  &= \\sum_{b \\leq x} \\sum_{d \\leq x/b} \\mu * 1(d) \\\\\n  &= \\floor x \\\\\n  &= x + O(1)\n\\end{align*}\nand the first error term is\n\\[\n  -2\\gamma \\sum_{a \\leq x} \\mu(a) \\frac{x}{a} = O(x\\sum_{a \\leq x} \\frac{\\mu(a)}{a})\n\\]\nso still need to show that\n\\[\n  x \\sum_{a \\leq x} \\frac{\\mu(a)}{a} = O(1).\n\\]\nWell it turns out that this is equivalent to prime number theorem! This constant can be shown to be \\(1/\\zeta(1)\\). As \\(\\zeta\\) has a pole at \\(z = 1\\), this is indeed true.\\label{proof:attempted elementary proof of PNT}\n\n\\subsection{Selberg's identity and on elementary proof of prime number theorem}\n\nDefine Selberg's function\n\\[\n  \\Lambda_2(n) = \\mu* (\\log )^2(n) = \\sum_{ab = n} \\mu(a) (\\log b)^2.\n\\]\nThe idea is to prove ``prime number theorem for \\(\\Lambda_2\\)'' with elementary methods. The intuition is that \\(\\Lambda_2\\) is like \\(\\Lambda\\) multiplied by \\(\\log\\) and if we do the same expansion as before, hopefully we can get\n\\[\n  \\sum_{n \\leq x} \\Lambda_2(n) = \\text{main term} + O(x),\n\\]\nbut now this is now an acceptable error!\n\n\\begin{lemma}\\leavevmode\n  \\begin{enumerate}\n  \\item \\(\\Lambda_2(n) = \\Lambda(n) \\log n + \\Lambda * \\Lambda (n)\\).\n  \\item \\(0 \\leq \\Lambda_2(n) \\leq (\\log n)^2\\).\n  \\item If \\(\\Lambda_2(n) \\neq 0\\) then \\(n\\) has at most 2 distinct prime divisors.\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\\leavevmode\n  \\begin{enumerate}\n  \\item Use Möbius inversion suffices to show\n    \\[\n      \\sum_{d \\divides n} (\\Lambda(d) \\log d + \\Lambda * \\Lambda(d)) = (\\log n)^2.\n    \\]\n    Start by expanding out,\n    \\begin{align*}\n      \\sum_{d \\divides n} (\\Lambda(d) \\log d + \\Lambda * \\Lambda(d))\n      &= \\sum_{d \\divides n} \\Lambda(d) \\log d + \\sum_{ab \\divides n} \\Lambda(a) \\Lambda(b) \\\\\n      &= \\sum_{d \\divides n} \\log d + \\sum_{a \\divides n} \\Lambda(a) \\underbrace{\\sum_{b \\divides \\frac{n}{a}} \\Lambda(b)}_{= \\log (n/a)} \\\\\n      &= \\sum_{d \\divides n} \\log d + \\sum_{d \\divides n} \\Lambda(d) \\log \\frac{n}{d} \\\\\n      &= \\log n \\sum_{d \\divides n} \\Lambda(d) \\\\\n      &= (\\log n)^2\n    \\end{align*}\n  \\item \\(\\Lambda_2(n) \\geq 0\\) since both terms on RHS in 1 are nonnegative. Since\n    \\[\n      \\sum_{d \\divides n} \\Lambda_2(d) = (\\log n)^2,\n    \\]\n    \\(\\Lambda_2(n) \\leq (\\log n)^2\\).\n  \\item Note that if \\(n\\) is divisible by 2 distinct primes then \\(\\Lambda(n) = 0\\), and\n    \\[\n      \\Lambda * \\Lambda(n) = \\sum_{ab \\divides n} \\Lambda(a) \\Lambda(b) = 0\n    \\]\n    since at least one of \\(a\\) or \\(b\\) has \\(\\geq 2\\) distinct prime divisors.\n  \\end{enumerate}\n\\end{proof}\n\nAs such while \\(\\Lambda\\) can be thought as the indicator function for numbers with exactly 1 prime divisor, weighted by \\(\\log\\), \\(\\Lambda_2\\) can be thought as the indicator function for numbers with a pair of prime divisors, weighted by \\((\\log)^2\\).\n\n\\begin{theorem}[Selberg]\n  \\[\n    \\sum_{n \\leq x} \\Lambda_2(n) = 2x \\log x + O(x).\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  \\begin{align*}\n    \\sum_{n \\leq x} \\Lambda_2(n)\n    &= \\sum_{n \\leq x} \\mu * (\\log)^2 (n) \\\\\n    &= \\sum_{ab \\leq x} \\mu(a) (\\log b)^2 \\\\\n    &= \\sum_{a \\leq x} \\mu(a) \\left( \\sum_{b \\leq x/a} (\\log b)^2 \\right)\n  \\end{align*}\n  By partial summation,\n  \\[\n    \\sum_{m \\leq x} (\\log m)^2\n    = x (\\log x)^2 - 2x \\log x + 2x + O((\\log x)^2).\n  \\]\n  We want to use the same trick and substitute sum of divisor function for the leading term. First we have to manufacture a \\(x (\\log x)^2\\) term. By partial summation with\n  \\[\n    A(t) = \\sum_{n \\leq t} \\tau(n) = t \\log t + Ct + O(t^{1/2}),\n  \\]\n  have\n  \\begin{align*}\n    \\sum_{m \\leq x} \\frac{\\tau(m)}{m}\n    &= \\frac{A(x)}{x} + \\int_1^x \\frac{A(t)}{t^2} dt \\\\\n    &= \\log x + C + O(x^{-1/2}) + \\int_1^x \\frac{\\log t}{t} dt + C \\int_1^x \\frac{1}{t} dt + O(\\int_1^x \\frac{1}{t^{3/2}} dt) \\\\\n    &= \\frac{(\\log x)^2}{2} + C_1 \\log x + C_2 + O(x^{-1/2})\n  \\end{align*}\n  Since we dislike \\(\\log\\), we replace it by \\(\\sum_{m \\leq x} \\tau(m)\\) to get\n  \\[\n    \\frac{x (\\log x)^2}{2}\n    = \\sum_{m \\leq x} \\tau(m) \\frac{x}{m} + C_1' \\sum_{m \\leq x} \\tau(m) + C_2'x + O(x^{1/2}).\n  \\]\n  Substituting back,\n  \\[\n    \\sum_{m \\leq x} (\\log m)^2\n    = 2 \\sum_{m \\leq x} \\tau(m) \\frac{x}{m} + C_3 \\sum_{m \\leq x} \\tau(m) + C_4 x + O(x^{1/2})\n  \\]\n  so\n  \\begin{align*}\n    \\sum_{n \\leq x} \\Lambda_2(n)\n    &= 2 \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a} \\frac{\\tau(b)x}{ab} + C_5 \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a} \\tau(b) \\\\\n    &+ C_6 \\sum_{a \\leq x} \\mu(a) \\frac{x}{a} + O(\\sum_{a \\leq x} \\frac{x^{1/2}}{a^{1/2}}).\n  \\end{align*}\n  We analyse the error terms one by one, starting from the back. First note that\n  \\[\n    x^{1/2} \\sum_{a \\leq x} \\frac{1}{a^{1/2}} = O(x).\n  \\]\n  Secondly\n  \\begin{align*}\n    x \\sum_{a \\leq x} \\frac{\\mu(a)}{a}\n    &= \\sum_{a \\leq x} \\mu(a) \\floor*{\\frac{x}{a}} + O(x) \\\\\n    &= \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a} 1 + O(x) \\\\\n    &= \\sum_{d \\leq x} \\mu * 1(d) + O(x) \\\\\n    &= 1 + O(x) \\\\\n    &= O(x)\n  \\end{align*}\n  Thirdly, (again essentially \\(\\mu * \\tau = 1\\))\n  \\begin{align*}\n    \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a} \\tau(b)\n    &= \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a}\\sum_{cd = b} 1 \\\\\n    &= \\sum_{a \\leq x} \\mu(a) \\sum_{cd \\leq x/a} 1 \\\\\n    &= \\sum_{acd \\leq x} \\mu(a)\n    = \\sum_{d \\leq x} \\sum_{ac \\leq x/d} \\mu(a) \\\\\n    &= \\sum_{d \\leq x} \\sum_{e \\leq x/d} \\mu * 1(e) \\\\\n    &= \\sum_{d \\leq x} 1 \\\\\n    &= O(x)\n  \\end{align*}\n  Collecting what we've done,\n  \\begin{align*}\n    \\sum_{n \\leq x} \\Lambda_2(n)\n    &= 2 \\sum_{a \\leq x} \\mu(a) \\sum_{b \\leq x/a} \\frac{\\tau(b) x}{ab} + O(x) \\\\\n    &= 2x \\sum_{d \\leq x} \\frac{1}{d} \\mu * \\tau(d) + O(x) \\\\\n    \\intertext{Recall that \\(\\tau = 1 * 1\\) so \\(\\mu * \\tau = \\mu * 1 * 1 = 1\\),}\n    &= 2x \\sum_{d \\leq x} \\frac{1}{d} + O(x) \\\\\n    &= 2x \\log x + O(x)\n  \\end{align*}\n\\end{proof}\n\n\\subsubsection{*A 14-point plan to prove prime number theorem from Selberg's identity}\n\nLet\n\\[\n  r(x) = \\frac{\\psi(x)}{x} - 1.\n\\]\nThen prime number theorem is the statement that\n\\[\n  \\lim_{x \\to \\infty} |r(x)| = 0.\n\\]\nWe will demonstrate how to count from 1 to 14 below. When you finished counting, you will get prime number theorem as a byproduct.\n\n\\begin{enumerate}\n\\item[1] Show that Selberg's identity implies\n  \\[\n    r(x) \\log x = - \\sum_{n \\leq x} \\frac{\\Lambda(n)}{n} r (\\frac{x}{n}) + O(1).\n  \\]\n\\item[2] Consider 1 with \\(x\\) replaced by \\(\\frac{x}{m}\\), summing over \\(m\\), show\n  \\[\n    |r(x)| (\\log x)^2 \\leq \\sum_{n \\leq x} \\frac{\\Lambda_2(n)}{n} \\left|r(\\frac{x}{n})\\right| + O(\\log x).\n  \\]\n\\item[3]\n  \\[\n    \\sum_{n \\leq x} \\Lambda_2(n) = 2 \\int_1^{\\floor x} \\log t dt + O(x).\n  \\]\n\\item[4 - 6]\n  \\[\n    \\sum_{n \\leq x} \\frac{\\Lambda_2(n)}{n} |r(\\frac{x}{n})|\n    = 2 \\int_1^x \\frac{r(x/2)}{t \\log t} dt + O(\\log x).\n  \\]\n\\item[7] Let \\(V(u) = r(e^u)\\). Show that\n  \\[\n    u^2 |V(u)| \\leq 2 \\int_0^u \\int_0^v |V(t)| dt dv + O(u).\n  \\]\n\\item[8] Show\n  \\[\n    \\alpha = \\limsup_{x \\to \\infty} |r(x)| \\leq \\limsup_{u \\to \\infty} \\frac{1}{u} \\int_0^u |V(t)| dt = \\beta.\n  \\]\n\\item[9 - 14] If \\(\\alpha > 0\\) then can show from 7 that \\(\\beta < \\alpha\\), contradiction. So \\(\\alpha = 0\\). Prime number theorem.\n\\end{enumerate}\n\n\\section{Sieve methods}\n\nSieve of Eratosthenes: given natural numbers below \\(20\\), let's cross out all multiples of \\(2\\) to get\n\\[\n  \\begin{array}{cccccccccc}\n    1 & \\cancel 2 & 3 & \\cancel 4 & 5 & \\cancel 6 & 7 & \\cancel 8 & 9 & \\cancel{10} \\\\\n    11 & \\cancel{12} & 13 & \\cancel{14} & 15 & \\cancel{16} & 17 & \\cancel{18} & 19 & \\cancel{20}\n  \\end{array}\n\\]\nNext we cross out all multiples of \\(3\\) to get\n\\[\n  \\begin{array}{cccccccccc}\n    1 & \\cancel 2 & \\bcancel 3 & \\cancel 4 & 5 & \\xcancel 6 & 7 & \\cancel 8 & \\bcancel 9 & \\cancel{10} \\\\\n    11 & \\xcancel{12} & 13 & \\cancel{14} & \\bcancel{15} & \\cancel{16} & 17 & \\xcancel{18} & 19 & \\cancel{20}\n  \\end{array}\n\\]\nAs \\(\\sqrt{20} < 5\\), we know that the numbers left on the list are prime (with the exception of \\(1\\)). Our interest is in using the sieve to \\emph{count} things: we can find how many numbers are left, which by definition are those primes below \\(20\\) that are not used as sieves, by inclusion-exclusion principle:\n\\begin{align*}\n  \\pi(20) + 1 - \\pi(\\sqrt{20})\n  &= 20 - \\floor*{\\frac{20}{2}} - \\floor*{\\frac{20}{3}} + \\floor*{\\frac{20}{6}} \\\\\n  &= 20 - 10 - 6 + 3 \\\\\n  &= 7\n\\end{align*}\nBy the way if there are more sieves then we naturally include more terms in the inclusion-exclusion expansion. Note that the coefficient/sign in front of each term is precisely the Möbius function of the denominator.\n\n\\subsection{Setup}\n\nConsider \\(A \\subseteq \\N\\) finite, which is the set to be sifted. Let \\(P\\) be a set of primes, which are those we sift out by. Usually \\(P\\) is the set of all primes. Let \\(z\\) be a sifting limit: we sift all primes in \\(P\\) that are smaller than \\(z\\). A \\emph{sifting function}\n\\[\n  S(A, P; z) = \\sum_{n \\in A} 1_{(n, P(z)) = 1}\n\\]\nwhere \\(P(z) = \\prod_{p \\in P, p < z} p\\). The goal is to estimate \\(S(A, P; z)\\).\n\nFor \\(d\\), let\n\\[\n  A_d = \\{n \\in A: d \\divides n\\}.\n\\]\nWrite\n\\[\n  |A_d| = \\frac{f(d)}{d} X + R_d\n\\]\nwhere \\(f\\) is completely multiplicative (\\(f(mn) = f(m)f(n)\\) for all \\(m, n\\)) and \\(f(d) \\geq 0\\) for all \\(d\\). Note that\n\\[\n  |A| = \\frac{f(1)}{1} X + R_1 = X + R_1\n\\]\nThink of \\(R_1\\) as the remainder term, \\(X\\) is roughly the size of \\(A\\). Extending this analogy, for general \\(d\\), \\(R_d\\) is the ``error'' term and \\(\\frac{X}{d}\\) measures the number of elements in the \\(0\\) residue class of \\(d\\), assuming they are distributed uniformly. Then \\(f(d)\\) is a factor that says how the residue class is actually distributed.\n\nWe choose \\(f\\) so that \\(f(p) = 0\\) if \\(p \\notin P\\) (so \\(R_p = |A_p|\\)). Finally let\n\\[\n  W_P(z) = \\prod_{\\substack{p \\in P \\\\ p < z}} \\left( 1 - \\frac{f(p)}{p} \\right),\n\\]\nthe probability that it is not divisible by any of the \\(p\\).\n\n\\begin{eg}\\leavevmode\n  \\begin{enumerate}\n  \\item Sieve of Eratosthenes: \\(A = (x, x + y] \\cap \\N\\) and \\(P\\) is the set of all primes. Then\n    \\[\n      |A_d|\n      = \\floor*{\\frac{x + y}{d}} - \\floor*{\\frac{x}{d}}\n      = \\frac{x + y}{d} - \\frac{x}{d} + O(1)\n      = \\frac{y}{d} + O(1)\n    \\]\n    so \\(f(d) = 1\\) and \\(R_d = O(1)\\). Have\n    \\[\n      S(A, P; z) = \\#\\{x < n \\leq x + y: p \\divides n \\implies p \\geq z\\}.\n    \\]\n    For example if \\(z \\approx (x + y)^{1/2}\\) then\n    \\[\n      S(A, P; z) = \\pi(x + y) - \\pi(x) + O((x + y)^{1/2}).\n    \\]\n  \\item Let \\(A = \\{1 \\leq n \\leq y: n = a \\mod q\\}\\). Then\n    \\[\n      A_d = \\{1 \\leq m \\leq \\frac{y}{d}: dm = a \\mod q\\}.\n    \\]\n    The congruence has solutions if and only if \\((d, q) \\divides a\\). Thus\n    \\[\n      |A_d| =\n      \\begin{cases}\n        \\frac{(d, q)}{dq} y + O((d, q)) & (d, q) \\divides a \\\\\n        O((d, q)) & \\text{otherwise}\n      \\end{cases}\n    \\]\n    So here \\(X = \\frac{y}{q}\\) and\n    \\[\n      f(d) =\n      \\begin{cases}\n        (d, q) & (d, q) \\divides a \\\\\n        0 & \\text{otherwise}\n      \\end{cases}\n    \\]\n  \\item Count twin primes: let \\(A = \\{n (n + 2): 1 \\leq n \\leq x\\}\\) and let \\(P\\) be all primes except \\(2\\). So \\(p \\divides n(n + 2)\\) if and only if \\(n = 0 \\text{ or } 2 \\mod p\\). Thus\n    \\[\n      |A_p| = \\frac{2x}{p} + O(1).\n    \\]\n    Thus \\(f(p) = 2\\). By complete multiplicity, \\(f(d) = 2^{\\omega(d)}\\) if \\(2 \\ndivides d\\). Have\n    \\begin{align*}\n      S(A, P; x^{1/2})\n      &= \\#\\{1 \\leq p \\leq x: p, p + 2 \\text{ both primes}\\} + O(x^{1/2}) \\\\\n      &= \\pi_2(x) + O(x^{1/2})\n    \\end{align*}\n    We would expect \\(\\pi_2(x) \\approx \\frac{x}{(\\log x)^2}\\). We'll prove upper bound using sieves.\n  \\end{enumerate}\n\\end{eg}\n\n\\begin{theorem}[sieve of Eratosthenes-Legendre]\n  \\[\n    S(A, P; z) = XW_P(z) + O(\\sum_{d \\divides P(z)} |R_d|).\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  \\begin{align*}\n    S(A, P; z)\n    &= \\sum_{n \\in A} 1_{(n, P(z)) = 1} \\\\\n    &= \\sum_{n \\in A} \\sum_{d \\divides (n, P(z))} \\mu(d) \\\\\n    &= \\sum_{n \\in A} \\sum_{\\substack{d \\divides n \\\\ d \\divides P(z)}} \\mu(d) \\\\\n    &= \\sum_{d \\divides P(z)} \\mu(d) \\sum_{n \\in A} 1_{d \\divides n} \\\\\n    &= \\sum_{d \\divides P(z)} \\mu(d) |A_d| \\\\\n    &= X \\sum_{d \\divides P(z)} \\frac{\\mu(d) f(d)}{d} + \\sum_{d \\divides P(z)} \\mu(d) R_d \\\\\n    &= X \\prod_{p \\in P, p < z} \\left(1 - \\frac{f(p)}{p} \\right) + O(\\sum_{d \\divides P(z)} |R_d|)\n  \\end{align*}\n\\end{proof}\n\n\\begin{corollary}\n  \\[\n    \\pi(x + y) - \\pi(x) \\ll \\frac{y}{\\log \\log y}.\n  \\]\n\\end{corollary}\nBy taking \\(x = 0\\) we see this is much worse bound in \\(y\\) than Chebyshev. On the other hand, however, we get a uniform bound independent of \\(x\\)!\n\n\\begin{proof}\n  In example 1, \\(X = y, f = 1\\) and \\(|R_d| \\ll 1\\). Thus\n  \\[\n    W_P(z)\n    = \\prod_{p < z} \\left( 1 - \\frac{1}{p} \\right)\n    \\ll (\\log z)^{-1}\n  \\]\n  and\n  \\[\n    \\sum_{d \\divides P(z)} |R_d| \\ll \\sum_{d \\divides P(z)} 1 \\leq 2^z\n  \\]\n  so\n  \\[\n    \\pi(x + y) - \\pi(x) \\ll \\frac{y}{\\log z} + 2^z \\ll \\frac{y}{\\log \\log y}\n  \\]\n  by letting \\(z = \\log y\\).\n\\end{proof}\n\n\\subsection{Selberg's sieve}\n\nUsing sieve of Eratosthenes-Legendre, we only get \\(\\frac{y}{\\log\\log y}\\) instead of the expected \\(\\frac{y}{\\log y}\\). What prevents us from getting the result is that we can't take \\(z = y\\) --- otherwise the error term will be \\(O(2^z) = O(2^y)\\), which is much bigger than the main term.\n\nThe problem is that we have to consider \\(2^z\\) many divisors of \\(P(z)\\) so get \\(2^z\\) many error terms. However, we can design a different sieve, and only consider those divisors which are small, say \\(\\leq D\\). The key part of Eratosthenes-Legendre sieve is\n\\[\n  1_{(n, P(z)) = 1} = \\sum_{d \\divides (n, P(z))} \\mu(d).\n\\]\nHowever, for an upper bound, it is enough to use \\emph{any} function \\(F\\) such that\n\\[\n  F(n) \\geq\n  \\begin{cases}\n    1 & n = 1 \\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n\\]\nSelberg's observation was that if \\((\\lambda_i)\\) is any sequence of reals with \\(\\lambda_1 = 1\\) then\n\\[\n  F(n) = \\left( \\sum_{d \\divides n} \\lambda_d \\right)^2\n\\]\nworks.\n\nWe assume that \\(0 < f(p) < p\\) for \\(p \\in P\\), which is a reasonable assumption for the sieve to be ``nontrivial'' (if \\(f(p) = 0\\) then the sieve does nothing and we may well just remove \\(p\\) from \\(P\\). If \\(f(p) = p\\) then it sifts out everything!) The let us define a new multiplicative function \\(g\\) such that\n\\[\n  g(p) = \\left( 1 - \\frac{f(p)}{p} \\right)^{-1} - 1 = \\frac{f(p)}{p - f(p)}.\n\\]\n\n\\begin{theorem}[Selberg's sieve]\\index{Selberg's sieve}\n  \\label{thm:Selberg's sieve}\n  For all \\(t\\),\n  \\[\n    S(A, P; z) \\leq \\frac{X}{G(t, z)} + \\sum_{\\substack{d \\divides P(t) \\\\ d < t^2}} 3^{\\omega(d)} |R_d|\n  \\]\n  where\n  \\[\n    G(t, z) = \\sum_{\\substack{d \\divides P(z) \\\\ d < t}} g(d).\n  \\]\n\\end{theorem}\n\nRecall that \\(W_P = \\prod_{\\substack{p \\in P \\\\ p < z}} (1 - \\frac{f(p)}{p})\\) so expected size of \\(S(A, P; z)\\) is \\(XW_P\\). Note that as \\(t \\to \\infty\\),\n\\[\n  G(t, z)\n  \\to \\sum_{d \\divides P(z)} g(d)\n  = \\prod_{p < z} (1 + g(p))\n  = \\prod_{p < z} \\left( 1 - \\frac{f(p)}{p} \\right)^{-1}\n  = \\frac{1}{W_P}.\n\\]\n\nLet's apply our new machinery:\n\\begin{corollary}\n  For all \\(x, y\\),\n  \\[\n    \\pi(x + y) - \\pi(x) \\ll \\frac{y}{\\log y}.\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Let \\(A = \\{x < n \\leq x + y\\}, f(p) = 1, R_d = O(1)\\) and \\(X = y\\). As \\(g(p) = \\frac{1}{p - 1} = \\frac{1}{\\varphi(p)}\\) so \\(g(d) = \\frac{1}{\\varphi(d)}\\),\n  \\begin{align*}\n    G(z, z)\n    &= \\sum_{\\substack{d \\divides P(z) \\\\ d < z}} \\prod_{p \\divides d} (p - 1)^{-1} \\\\\n    &= \\sum_{d = p_1 \\cdots p_r < z} \\prod_{i = 1}^r \\sum_{k = 1}^\\infty \\frac{1}{p_i^k} \\\\\n    &= \\sum_{\\substack{p_1 \\cdots p_r < z \\\\ 1 \\leq i \\leq r}} \\sum_{k_i = 1}^\\infty \\frac{1}{p_1^{k_1} \\cdots p_r^{k_r}} \\\\\n    &= \\sum \\frac{1}{n} \\quad \\text{square-free part of \\(n\\) \\(< z\\)} \\\\\n    &\\geq \\sum_{d < z} \\frac{1}{d} \\\\\n    &\\gg \\log z\n  \\end{align*}\n  so the main term \\(\\ll \\frac{y}{\\log z}\\). Note that\n  \\[\n    3^{\\omega(d)} \\leq \\tau_3(d) \\ll_\\varepsilon d^\\varepsilon\n  \\]\n  from example sheet 1 so the error term is\n  \\[\n    \\sum_{\\substack{d \\divides P(t) \\\\ d < t^2}} 3^{\\omega(d)} |R_d|\n    \\ll_\\varepsilon t^\\varepsilon \\sum_{d < t^2} 1\n    \\ll t^{2 + \\varepsilon} = z^{2 + \\varepsilon}\n  \\]\n  by setting \\(t = z\\). Thus\n  \\[\n    S(A, P; z) \\ll \\frac{y}{\\log z} + z^{2 + \\varepsilon} \\ll \\frac{y}{\\log y}\n  \\]\n  by taking \\(z = y^{1/3}\\).\n\\end{proof}\n\n\\begin{proof}[Proof of \\nameref{thm:Selberg's sieve}]\n  Let \\((\\lambda_i)\\) be a sequence of reals with \\(\\lambda_1 = 1\\), to be chosen later. Then\n  \\begin{align*}\n    S(A, P; z)\n    &= \\sum_{n \\in A} 1_{(n, P(z)) = 1} \\\\\n    &\\leq \\sum_{n \\in A} \\left( \\sum_{d \\divides (n, P(z))} \\lambda_d \\right)^2 \\\\\n    &= \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e \\sum_{n \\in A} 1_{d \\divides n, e \\divides n} \\\\\n    &= \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e |A_{[d, e]}| \\\\\n    &= X \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e \\frac{f([d, e])}{[d, e]} + \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e R_{[d, e]}\n  \\end{align*}\n  We'll choose \\(\\lambda_d\\) such that \\(|\\lambda_d| \\leq 1\\) and \\(\\lambda_d = 0\\) if \\(d \\geq t\\). Then\n  \\[\n    \\left| \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e R_{[d, e]} \\right|\n    \\leq \\sum_{\\substack{d, e < t \\\\ d, e \\divides P(z)}} |R_{[d, e]}|\n    \\leq \\sum_{\\substack{n \\divides P(z) \\\\ n < t^2}} |R_n| \\sum_{d, e} 1_{[d, e] = n}\n  \\]\n  and since \\(n\\) is square-free,\n  \\[\n    \\sum_{d, e} 1_{[d, e] = n} = 3^{\\omega(n)}\n  \\]\n  so the error term is settled.\n\n  Now to the main term. Let\n  \\[\n    V = \\sum_{d, e \\divides P(z)} \\lambda_d \\lambda_e \\frac{f([d, e])}{[d, e]}.\n  \\]\n  Write \\([d, e] = acb\\) where \\(d = ac, e = bc\\) and \\((a, b) = (b, c) = (a, c) = 1\\). We also require \\(\\lambda_d = 0\\) if \\(d\\) is not square-free so the last two conditions are automatically satisfied, leaving the notations a bit clearer.\n  \\begin{align*}\n    V\n    &= \\sum_{c \\divides P(z)} \\frac{f(c)}{c} \\sum_{\\substack{ab \\divides P(z) \\\\ (a, b) = 1}} \\frac{f(a)f(b)}{ab} \\lambda_{ac} \\lambda_{bc} \\\\\n    &= \\sum_{c \\divides P(z)} \\frac{f(c)}{c} \\sum_{ab \\divides P(z)} \\frac{f(a)}{a} \\frac{f(b)}{b} \\sum_{d \\divides a, d \\divides b} \\mu(d) \\lambda_{ac} \\lambda_{bc} \\\\\n    &= \\sum_{c \\divides P(z)} \\frac{f(c)}{c} \\sum_{d \\divides P(z)} \\mu(d) \\left( \\sum_{d \\divides a \\divides P(z)} \\frac{f(a)}{a} \\lambda_{ac} \\right)^2 \\\\\n    &= \\sum_{d \\divides P(z)} \\mu(d) \\sum_{c \\divides P(z)} \\frac{c}{f(c)} \\left( \\sum_{cd \\divides n \\divides P(z)} \\frac{f(n)}{n} \\lambda_n \\right)^2 \\quad \\text{write \\(ac = n\\)} \\\\\n    &= \\sum_{d \\divides P(z)} \\mu(d) \\sum_{c \\divides P(z)} \\frac{c}{f(c)} y^2_{cd} \\\\\n    &= \\sum_{k \\divides P(z)} \\left( \\sum_{cd = k} \\mu(d) \\frac{c}{f(c)} \\right) y_k^2\n  \\end{align*}\n  The term in the brackets is a convolution so we want to simply it. Note that both functions are multiplicative so suffice to work out the primes. For prime \\(p\\),\n  \\[\n    \\sum_{cd = p} \\mu(d) \\frac{c}{f(c)}\n    = -1 + \\frac{p}{f(p)} = \\frac{1}{g(p)}\n  \\]\n  and thus for all \\(k \\divides P(z)\\),\n  \\[\n    \\sum_{cd = k} \\mu(d) \\frac{c}{f(c)} = \\frac{1}{g(k)}.\n  \\]\n  Note that if \\(k \\geq t\\) then \\(y_k = 0\\). Thus\n  \\[\n    V = \\sum_{\\substack{k \\divides P(z) \\\\ k < t}} \\frac{y_k^2}{g(k)}.\n  \\]\n  We want to choose \\(V\\) as small as possible. The idea is to find a lower bound for \\(V\\) and use Cauchy-Schwarz to find the condition on the summands.\n\n  Note that we have now expressed \\(V\\) in terms of \\(y_k\\), which is determined by \\(\\lambda_d\\):\n  \\[\n    y_k = \\sum_{k \\divides n \\divides P(z)} \\frac{f(n)}{n} \\lambda_n.\n  \\]\n  We would like to invert the relation, so that we can directly control \\(y_k\\). Use a Möbius inversion heuristics, for a fixed \\(d\\),\n  \\begin{align*}\n    \\sum_{d \\divides k \\divides P(z)} \\mu(k) y_k\n    &= \\sum_{k \\divides P(z)} \\mu(k) \\sum_{n \\divides P(z)} \\frac{f(n)}{n} \\lambda_n 1_{d \\divides k} 1_{k \\divides n} \\\\\n    &= \\sum_{n \\divides P(z)} \\frac{f(n)}{n} \\lambda_n 1_{d \\divides n} \\sum_{d \\divides k \\divides n} \\mu(k)\n  \\end{align*}\n  For the last summation, note that \\(k = de\\) is square-free so\n  \\[\n    \\sum_{d \\divides k \\divides n} \\mu(k)\n    = \\mu(d) \\sum_{e \\divides \\frac{n}{d}} \\mu(e)\n    =\n    \\begin{cases}\n      \\mu(d) & n = d \\\\\n      0 & n > d\n    \\end{cases}\n  \\]\n  by multiplicativity. Thus\n  \\[\n    \\sum_{d \\divides k \\divides P(z)} \\mu(k) y_k\n    = \\mu(d) \\frac{f(d)}{d} \\lambda_d\n  \\]\n  Thus instead of choosing \\(\\lambda_d\\), we can choose \\(y_k\\) to make \\(V\\) small.\n\n  Recall that \\(\\lambda_1 = 1\\) so must have\n  \\[\n    \\sum_{k \\divides P(z)} \\mu(k) y_k = 1.\n  \\]\n  Thus\n  \\begin{align*}\n    1\n    &= \\left( \\sum_{\\substack{k \\divides P(z) \\\\ k < t}} \\mu(k) y_k g(k)^{1/2} \\cdot \\frac{1}{g(k)^{1/2}} \\right)^2 \\\\\n    &\\leq \\left( \\sum_{\\substack{k \\divides P(z) \\\\ k < t}} g(k) \\right) \\left( \\sum_{\\substack{k \\divides P(z) \\\\ k < t}} \\frac{y_k^2}{g(k)} \\right) \\\\\n    &= GV\n  \\end{align*}\n  where \\(G = G(t, z)\\) by Cauchy-Schwarz, with equaility if and only if there exists \\(c\\) such that for all \\(k\\),\n  \\[\n    \\frac{\\mu(k) y_k}{g(k)^{1/2}} = c g(k)^{1/2}\n  \\]\n  i.e.\n  \\[\n    y_k = c \\mu(k) g(k)\n  \\]\n  for \\(k < t\\). To find \\(c\\), use the normalisation condition\n  \\[\n    1 = c \\sum_{\\substack{k \\divides P(z) \\\\ k < t}} \\mu(k)^2 g(k) = cG\n  \\]\n  so choose \\(c = \\frac{1}{G}\\). Check that\n  \\begin{enumerate}\n  \\item \\(\\lambda_1 = 1\\),\n  \\item \\(\\lambda_d = 0\\) if \\(d \\geq t\\),\n  \\item \\(\\lambda_d = 0\\) if \\(d\\) is square-free (lecturer said this condition is actually not necessary).\n  \\item \\(|\\lambda_d| \\leq 1\\). Can be checked as follow:\n    \\begin{align*}\n      \\lambda_d\n      &= \\mu(d) \\frac{d}{f(d)} \\sum_{d \\divides k \\divides P(z)} \\mu(k) y_k \\\\\n      &= \\frac{d}{f(d)} \\frac{1}{G} \\sum_{d \\divides k \\divides P(z)} g(k).\n    \\end{align*}\n    Note that\n    \\begin{align*}\n      G\n      &= \\sum_{\\substack{e \\divides P(z) \\\\ e < t}} g(e) \\\\\n      &= \\sum_{k \\divides d} \\sum_{\\substack{e \\divides P(z) \\\\ e < t \\\\ (d, e) = k}} g(e) \\quad \\text{for fixed \\(d\\)} \\\\\n      &= \\sum_{k \\divides d} g(k) \\sum_{\\substack{m \\divides P(z) \\\\ (m, d) = 1 \\\\ m < t/k}} g(m) \\\\\n      &\\geq \\sum_{k \\divides d} g(k) \\sum_{\\substack{m \\divides P(z) \\\\ (m, d) = 1 \\\\ m < t/d}} g(m)\n    \\end{align*}\n    Note that for prime \\(p\\),\n    \\[\n      \\sum_{k \\divides p} g(k)\n      = 1 + \\frac{f(p)}{p - f(p)}\n      = \\frac{p}{p - f(p)}\n      = \\frac{p}{f(p)} g(p)\n    \\]\n    so\n    \\[\n      G\n      \\geq \\frac{d}{f(d)} g(d) ( \\sum_{\\substack{m \\divides P(z) \\\\ (m, d) = 1 \\\\ m < t/d}} g(m))\n      = \\frac{d}{f(d)} \\sum_{d \\divides k \\divides P(z)} g(k)\n      = |\\lambda_d| G\n    \\]\n    so \\(|\\lambda_d| \\leq 1\\).\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{theorem}[Brun]\n  Let \\(\\pi_2(x) = \\#\\{1 \\leq n \\leq x: n, n + 2 \\text{ are prime}\\}\\). Then\n  \\[\n    \\pi_2(x) \\ll \\frac{x}{(\\log x)^2}.\n  \\]\n\\end{theorem}\n\n\\begin{proof}\n  Let \\(A = \\{n (n + 2): 1 \\leq n \\leq x\\}\\), \\(P\\) be the the set of all primes except \\(2\\). Have\n  \\[\n    |A_d| = \\#\\{1 \\leq n \\leq x: d \\divides n (n + 2)\\}\n  \\]\n  If \\(d = p_1 \\cdots p_r\\) is odd and square-free then \\(d \\divides n(n + 2)\\) if and only if \\(p_i \\divides n(n + 1)\\) for all \\(i\\), if and only if \\(n = 0 \\text{ or } -2 \\mod p_i\\) for all \\(i\\), and Chinese remainder theorem, if and only if \\(n\\) lies in one of \\(2^{\\omega(d)}\\) many residue classes mod \\(d\\). Thus\n  \\[\n    |A_d| = \\frac{2^{\\omega(d)}}{d} X + O(2^{\\omega(d)})\n  \\]\n  so \\(f(d) = 2^{\\omega(d)}\\) and \\(R_d \\ll 2^{\\omega(d)}\\) for \\(d\\) odd square-free. By \\nameref{thm:Selberg's sieve}, with \\(t = z = x^{1/4}\\),\n  \\begin{align*}\n    \\pi_2(x)\n    &\\leq \\#\\{1 \\leq n \\leq x: p \\divides n(n + 2) \\implies p = 2 \\text{ or } p \\geq x^{1/4}\\} + O(x^{1/4}) \\\\\n    &= S(A, P; x^{1/4}) + O(x^{1/4}) \\\\\n    &\\leq \\frac{x}{G(z, z)} + O(\\sum_{\\substack{d \\divides P(z) \\\\ d < z^2}} 6^{\\omega(d)})\n  \\end{align*}\n  As before\n  \\[\n    \\sum_{d < z^2} 6^{\\omega(d)} \\leq z^{2 + O(1)} = x^{1/2 + O(1)}.\n  \\]\n  To finish the proof need to show \\(G(z, z) \\gg (\\log z)^2\\). Note that \\(g(2) = 2\\) and\n  \\[\n    g(p) = \\frac{f(p)}{p - f(p)} = \\frac{2}{p - 2} \\geq \\frac{2}{p - 1},\n  \\]\n  so if \\(d\\) is odd and square-free then\n  \\[\n    g(d) \\geq \\frac{2^{\\omega(d)}}{\\varphi(d)}.\n  \\]\n  so\n  \\begin{align*}\n    G(z, z)\n    &\\geq \\sum_{\\substack{d < z \\\\ d \\text{ odd, square-free}}} \\frac{2^{\\omega(d)}}{\\varphi(d)} \\\\\n    &= \\sum_{d = p_1 \\cdots p_r < z} 2^{\\omega(d)} \\prod_{i = 1}^r \\left( \\frac{1}{p_i} + \\frac{1}{p_i^2} + \\cdots \\right) \\\\\n    &\\geq \\sum_{d < z} \\frac{2^{\\omega(d)}}{d}\n  \\end{align*}\n  By partial summation, it's enough to show \\(\\sum_{d < z} 2^{\\omega(d)} \\gg z \\log z\\). Recall that to show\n  \\[\n    \\sum_{d < z} \\tau(d) \\gg z \\log z\n  \\]\n  we used \\(\\tau = 1 * 1\\). So we need to write \\(2^{\\omega(n)}\\) as a convolution of multiplicative functions. Suppose\n  \\[\n    2^{\\omega(n)} = \\sum_{d \\divides n} f(d) g(\\frac{n}{d})\n  \\]\n  where \\(f, g\\) are multiplicative. We can actually write down values of \\(f\\) at prime powers:\n  \\begin{enumerate}\n  \\item[\\(1\\)]: \\(f(1) = g(1) = 1\\)\n  \\item[\\(p\\)]: \\(2 = f(p) + g(p)\\)\n  \\item[\\(p^2\\)]: \\(2 = g(p^2) + f(p^2) + f(p)g(p)\\).\n  \\end{enumerate}\n  Let's say try \\(f = \\tau\\), so \\(g(p) = 0\\), \\(g(p^2) = -1\\), \\(g(p^k) = 0\\) for \\(k \\geq 3\\). Therefore\n  \\[\n    g(n) =\n    \\begin{cases}\n      0 & n \\text{ not a square} \\\\\n      \\mu(d) & n = d^2\n    \\end{cases}\n  \\]\n  and\n  \\[\n    2^{\\omega(n)} = \\sum_{d \\divides n} \\tau(d) g(\\frac{n}{d}).\n  \\]\n  Therefore\n  \\begin{align*}\n    \\sum_{d < z} 2^{\\omega(d)}\n    &= \\sum_{a < z} g(a) \\sum_{b \\leq z/a} \\tau(b) \\\\\n    &= \\sum_{a < z} g(a) \\left( \\frac{z}{a} \\log \\frac{z}{a} + (2\\gamma - 1) \\frac{z}{a} + O(\\sqrt{z/a}) \\right) \\\\\n    &= \\sum_{a < z} g(a) \\frac{z}{a} \\log \\frac{z}{a} + C \\sum_{a < z} g(a) \\frac{z}{a} + O(\\underbrace{z^{1/2} \\sum_{a < z} \\frac{1}{a^{1/2}}}_{\\ll z}) \\\\\n    &= \\sum_{d < z^{1/2}} \\mu(d) \\frac{z}{d^2} \\log z - \\underbrace{2 \\sum_{d < z^{1/2}} \\mu(d) \\frac{z}{d^2} \\log d}_{\\ll z \\sum_{d < z^{1/2}} \\frac{\\log d}{d^2} \\ll z} + O(z)\n  \\end{align*}\n  Note\n  \\begin{align*}\n    \\sum_{d < z^{1/2}} \\frac{\\mu(d)}{d^2}\n    &= \\sum_{d = 1}^\\infty \\frac{\\mu(d)}{d^2} - \\sum_{d \\geq z^{1/2}} \\frac{\\mu(d)}{d^2} \\\\\n    &\\geq c + \\sum_{d \\geq z^{1/2}} \\frac{1}{d^2} \\\\\n    &= c + O(\\frac{1}{z^{1/2}})\n  \\end{align*}\n  so\n  \\[\n    \\sum_{d < z} 2^{\\omega(d)} = c z \\log z + O(z) \\gg z \\log z.\n  \\]\n  Remains to show \\(c > 0\\). Either note LHS can't be \\(O(z)\\), or calculate the first couple of terms in the series, or note that \\(c = \\frac{6}{\\pi^2} > 0\\).\n\\end{proof}\n\n\\subsection{Combinatorial sieve}\n\nSelberg's sieve is an upper bound sieve, while sieve of Eratosthenes uses the inclusion-exclusion principle\n\\[\n  S(A, P; z) = |A| - \\sum_p |A_p| + \\sum_{p \\neq q} |A_{pq}| - \\dots\n\\]\nto get a precise number. However this requires us to keep track of every term, thus resulting in an accummulation of error. The idea of a combinatorial sieve is to ``truncate'' the sieve process.\n\n\\begin{lemma}[Buchstab formula]\\index{Buchstab formula}\n  \\[\n    S(A, P; z) = |A| - \\sum_{p \\divides P(z)} S(A_p, P; p).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Rearrange, required to show\n  \\[\n    |A|\n    = S(A, P; z) + \\sum_{p \\divides P(z)} S(A_p, P; p)\n    = S_1 + \\sum_{p \\divides P(z)} S_p\n  \\]\n  where\n  \\begin{align*}\n    S_1 &= \\#\\{n \\in A: p \\divides n, p \\in P \\implies p \\geq z\\} \\\\\n    S_p &= \\#\\{n \\in A: n = mp, q \\divides n, q \\in P \\implies q \\geq p\\}\n  \\end{align*}\n\n  Every \\(n \\in A\\) is either in the set counted by \\(S_1\\) or has some prime divisors from \\(P(z)\\). If \\(p\\) is the least such prime divisor then \\(n \\in S_p\\). The \\(S_p\\)'s are disjoint.\n\\end{proof}\n\nSimilarly,\n\n\\begin{lemma}\n \\[\n   W(z) = 1 - \\sum_{p \\divides P(z)} \\frac{f(p)}{p} W(p)\n \\]\n where recall that\n \\[\n   W(z) = \\prod_{p \\divides P(z)} \\left( 1 - \\frac{f(p)}{p} \\right).\n \\]\n\\end{lemma}\n\n\\begin{proof}\n  Exercise.\n\\end{proof}\n\n\\begin{corollary}\n  For any \\(r \\geq 1\\),\n  \\[\n    S(A, P; z) = \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) |A_d| + (-1)^r \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} S(A_d, P; \\ell(d))\n  \\]\n  where \\(\\ell(d)\\) is the least prime divisor of \\(d\\).\n\\end{corollary}\n\n\\begin{proof}\n  Induction on \\(r = 1\\). When \\(r = 1\\) this is just Buchstab's formula. For inductive step, use\n  \\[\n    S(A_d, P; \\ell(d))\n    = |A_d| - \\sum_{\\substack{p \\in P \\\\ p < \\ell(d)}} S(A_{dp}, P; p)\n  \\]\n  so\n  \\begin{align*}\n    &\\phantom{= } (-1)^r \\sum_{\\substack{d \\divides P(z) \\\\\\omega(d) = r}} \\left( |A_d| - \\sum_{\\substack{p \\in P \\\\ p < \\ell(d)}} S(A_{pd}, P; p) \\right) \\\\\n    &= \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\mu(d) |A_d| + (-1)^{r + 1} \\sum_{\\substack{e \\divides P(z) \\\\ \\omega(e) = r + 1}} S(A_e, P; \\ell(e))\n  \\end{align*}\n\\end{proof}\n\nIn particular, if \\(r\\) is even then\n\\[\n  S(A, P; z) \\geq \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) |A_d|\n\\]\nand similarly if \\(r\\) is odd we get an upper bound.\n\n\\begin{theorem}[Brun's pure sieve]\\index{Brun's pure sieve}\n  If \\(r \\geq 6 \\log \\frac{1}{W(z)}\\) then\n  \\[\n    S(A, P; z) = XW(z) + O(2^{-r} X + \\sum_{\\substack{d \\divides P(z) \\\\ d \\leq z^r}} |R_d|).\n  \\]\n\\end{theorem}\n\nBrun's pure sieve has the same main term as sieve of Erathosthenes, but the error term is split into the fixed bit \\(2^{-r}X\\) and an accummulation part truncated at \\(2^r\\).\n\n\\begin{proof}\n  Recall that from iterating Buchstab's formula\n  \\begin{align*}\n    S(A, P; z)\n    &= \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) |A_d| + (-1)^r \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} S(A_d, P; \\ell(d)) \\\\\n    &= X \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) \\frac{f(d)}{d} + \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) R_d + (-1)^r \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} S(A_d, P; \\ell(d))\n  \\end{align*}\n  By the trivial bounds\n  \\[\n    0 \\leq S(A_d, P; \\ell(d)) \\leq |A_d|\n  \\]\n  have\n  \\begin{align*}\n    S(A, P; z)\n    &= X \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) \\frac{f(d)}{d} + O(\\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} |R_d| + \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} |A_d|)\n  \\end{align*}\n  By Buchstab again, applied to \\(W(z)\\),\n  \\[\n    W(z)\n    = \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} \\mu(d) \\frac{f(d)}{d} + (-1)^r \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\mu(d) \\frac{f(d)}{d} W(\\ell(d))\n  \\]\n  so\n  \\[\n    S(A, P; z) = XW(z) + O(\\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} |R_d| + \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} |A_d| + X\\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\frac{f(d)}{d})\n  \\]\n  The error term is\n  \\begin{align*}\n    &\\phantom{=} \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) < r}} |R_d| + \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} |A_d| + X \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\frac{f(d)}{d} \\\\\n    &\\ll X \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\frac{f(d)}{d} + \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) \\leq r}} |R_d| \\\\\n    &\\leq X \\sum_{\\substack{d \\divides P(z) \\\\ \\omega(d) = r}} \\frac{f(d)}{d} +\\sum_{\\substack{d \\divides P(z) \\\\ d \\leq z^r}} |R_d| \\quad \\text{as }\n    d \\divides P(z) = \\prod_{\\substack{p \\in P \\\\ p < z}} P\n  \\end{align*}\n  Remains to show\n  \\[\n    \\sum_{\\substack{d \\divides P(z) \\\\\\omega(d) = r}} \\frac{f(d)}{d} \\ll 2^{-r}\n  \\]\n  We need the condition on \\(r\\). Note that\n  \\begin{align*}\n    \\sum_{\\substack{d \\divides P(z) \\\\\\omega(d) = r}} \\frac{f(d)}{d}\n    &= \\sum_{\\substack{p_1 \\cdots p_r \\\\ p_i \\in P \\\\ p_i < z}} \\frac{f(p_1) \\cdots f(p_r)}{p_1 \\cdots p_r} \\\\\n    &\\leq \\frac{1}{r!} \\left( \\sum_{p \\divides P(z)} \\frac{f(p)}{p} \\right)^r \\\\\n    &\\leq \\left( \\frac{e}{r} \\sum_{p \\divides P(z)} \\frac{f(p)}{p} \\right)^r \\\\\n  \\end{align*}\n  Furthermore\n  \\[\n    \\sum_{p \\divides P(z)} \\frac{f(p)}{p}\n    \\leq \\sum_{p \\divides P(z)} - \\log(1 - \\frac{f(p)}{p})\n    = - \\log W(z)\n  \\]\n  so if \\(r \\geq 2 e |\\log W(z)|\\) then\n  \\[\n    \\sum_{\\substack{d \\divides P(z) \\\\\\omega(d) = r}} \\frac{f(d)}{d}\n    \\leq \\left( \\frac{e}{r} |\\log W(z)| \\right)^r\n    \\leq 2^{-r}\n  \\]\n  Finally note that \\(2e < 6\\).\n\\end{proof}\n\nRecall that Selberg's sieve shows that \\(\\pi_2(x) \\ll \\frac{x}{(\\log x)^2}\\). In the twin prime seive setting, \\(W(z) \\asymp \\frac{1}{(\\log z)^2}\\). So in Brun's sieve, need to take \\(r \\gg 2 \\log \\log z\\). If \\(r = C \\log \\log z\\) for \\(C\\) large enough then\n\\[\n  \\frac{X}{(\\log z)^{100}}.\n\\]\nThe main term is \\(\\gg \\frac{x}{\\log z}^2\\). As \\(|R_d| \\ll 2^{\\omega(d)} = d^{o(1)}\\). Thus\n\\[\n  \\sum_{\\substack{d \\divides P(z) \\\\ d \\leq z^r}}\n  \\ll z^{r + o(1)}\n  \\ll z^{2 \\log \\log z + o(1)}\n\\]\nso we need to choose a \\(z\\). For this to be \\(o(\\frac{x}{(\\log z)^2}\\), need to choose \\(z \\approx \\exp((\\log x)^{1/4})\\). So far so good. Now we need to establish the relation between \\(\\pi_2(x)\\) and\n\\[\n  S(A, P; z) = \\{1 \\leq n \\leq x: p \\divides n(n + 2) \\implies p > z\\}\n\\]\nso \\(p \\gg x^{1/2}\\), so this counts only ``large'' primes\n\n\\begin{corollary}\n  For any \\(z \\leq \\exp (o(\\frac{\\log x}{\\log \\log x}))\\),\n  \\[\n    \\#\\{1 \\leq n \\leq x: p \\divides n \\implies p \\geq z\\} \\sim e^{-\\gamma} \\frac{x}{\\log z}.\n  \\]\n\\end{corollary}\n\n\\begin{remark}\\leavevmode\n  \\begin{enumerate}\n  \\item In particular, \\(z = (\\log x)^A\\) is allowed for any \\(A\\), but \\(z = x^c\\) for any \\(c > 0\\) is not allowed.\n  \\item In particular, we can't count primes like this as \\(z = x^{1/2}\\). Recall heuristic from before says if this asymptotic were correct for primes, then\n    \\[\n      \\pi(x) \\sim 2e^{-\\gamma} \\frac{x}{\\log x}\n    \\]\n    which contradicts prime number theorem.\n\n    This is telling us that for primes, the error term is genuinely large, not because of the estimates. Or in other words, \\(W(z)\\) is not a very good bound, intrinsic\n  \\end{enumerate}\n\\end{remark}\n\n\\begin{proof}\n  Again use \\(A = \\{1 \\leq n \\leq x\\}\\) so \\(f(d) = 1, |R_d| \\ll 1\\). Then\n  \\[\n    W(z)\n    = \\prod_{p < z} (1 - \\frac{1}{p})\n    = \\frac{e^{-\\gamma}}{\\log z} + o(\\frac{1}{\\log z})\n  \\]\n  so\n  \\begin{align*}\n    S(A, P; z)\n    &= \\#\\{1 \\leq n \\leq x: p \\divides n \\implies p \\geq z\\} \\\\\n    &= e^{-\\gamma} \\frac{x}{\\log z} + o(\\frac{x}{\\log z} + O(2^{-r} x + \\sum_{\\substack{d \\divides P(z) \\\\ d < z^r}} |R_d|)\n  \\end{align*}\n  if \\(r \\geq 6 |\\log W(z)|\\), so \\(r \\geq 100 \\log \\log z\\) is fine. Have\n  \\[\n    2^{-r} x \\leq (\\log z)^{- (\\log 2) 100} x = o(\\frac{x}{\\log z})\n  \\]\n  and, choose \\(r = \\ceil{100 \\log \\log z}\\),\n  \\[\n    \\sum_{\\substack{d \\divides P(z) \\\\ d < z^r}} |R_d|\n    \\ll \\sum_{d \\leq z^r} 1\n    \\ll 2^r\n    \\leq 2^{500 (\\log \\log z) \\log z}\n  \\]\n  Remains to note that if\n  \\[\n    \\log z = o(\\frac{\\log x}{\\log \\log x}) = \\frac{\\log x}{\\log \\log x} F(x)\n  \\]\n  then this is\n  \\begin{align*}\n    \\log z \\log \\log z\n    = o( \\frac{\\log x}{\\log \\log x} \\log \\log x)\n    = o(\\log x)\n  \\end{align*}\n  so\n  \\[\n    2^{500 (\\log \\log z) \\log z} \\leq x^{1/10} = o(\\frac{x}{\\log z})\n  \\]\n  if \\(x\\) is large enough.\n\\end{proof}\n\n\\section{The Riemann zeta function}\n\nAs a tradition, in analytic number theory we write \\(s = \\sigma + it\\) for a complex number \\(s\\) where \\(\\sigma\\) and \\(t\\) are the real and imaginary part respectively. First, a trivial remark: if \\(n \\in \\N\\) then\n\\[\n  n^s = e^{s \\log n} = n^\\sigma \\cdot e^{it \\log n}.\n\\]\n\nThe \\emph{Riemann zeta function}\\index{Riemann zeta function} is defined for \\(\\sigma > 1\\) by\n\\[\n  \\zeta(s) = \\sum_{n = 1}^\\infty \\frac{1}{n^s}.\n\\]\n\n\\subsection{Dirichlet series}\n\nFor any arithmetic \\(f: \\N \\to \\C\\), we have a \\emph{Dirichlet series}\\index{Dirichlet series}\n\\[\n  L_f(s) = \\sum_{i = 1}^\\infty \\frac{f(n)}{n^s},\n\\]\nat least formally.\n\n\\begin{lemma}\n  For any \\(f\\) there is an \\emph{abscissa of convergence} \\(\\sigma_c\\) such that\n  \\begin{enumerate}\n  \\item if \\(\\sigma < \\sigma_c\\) then \\(L_f(s)\\) diverges,\n  \\item if \\(\\sigma > \\sigma_c\\) then \\(L_f(s)\\) converges uniformly in some neighbourhood of \\(s\\). In particular \\(L_f(s)\\) is holomorphic at \\(s\\).\n  \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n  It is enough to show that if \\(L_f(s)\\) converges at \\(s_0\\) and \\(\\sigma = \\sigma_0\\) then there is a neighbourhood of \\(s\\) on which \\(L_f\\) converges uniformly, as then we can take\n  \\[\n    \\sigma_c = \\inf \\{\\sigma: L_f(s) \\text{ converges}\\}.\n  \\]\n  Let\n  \\[\n    R(u) = \\sum_{n > u} f(n) n^{-s_0}.\n  \\]\n  By partial summation\n  \\[\n    \\sum_{M < n \\leq N} f(n) n^{-s}\n    = R(M) M^{s_0 - s} - R(N) N^{s_0 - s} - (s_0 - s) \\int_M^N R(u) u^{s_0 - s - 1} du.\n  \\]\n  If \\(|R(u)| \\leq \\varepsilon\\) for all \\(u \\geq M\\) then\n  \\[\n    \\left| \\sum_{M < n \\leq N} f(n) n^{-s} \\right|\n    \\leq 2\\varepsilon + \\varepsilon |s_0 - s| \\int_M^N u^{\\sigma_0 - \\sigma - 1} du\n    \\leq (2 + \\frac{|s_0 - s|}{|\\sigma_0 - \\sigma|}) \\varepsilon.\n  \\]\n  Note that there is a neighbourhood of \\(s\\) in which \\(\\frac{|s_0 - s|}{|\\sigma_0 - \\sigma|} \\ll_s 1\\) so \\(\\sum \\frac{f(n)}{n^s}\\) converges uniformly here.\n\\end{proof}\n\n\\begin{lemma}\n  If\n  \\[\n    \\sum \\frac{f(n)}{n^s} = \\sum \\frac{g(n)}{n^s}\n  \\]\n  for all \\(s\\) in some half plane \\(\\sigma > \\sigma_0 \\in \\R\\) then \\(f(n) = g(n)\\) for all \\(n\\).\n\\end{lemma}\n\n\\begin{proof}\n  Enough to consider \\(\\sum \\frac{f(n)}{n^s} = 0\\) for all \\(\\sigma > \\sigma_0\\). Suppose exists \\(n\\) such that \\(f(n) \\neq 0\\). Let \\(N\\) be the least such that \\(f(N) \\neq 0\\). Since \\(\\sum_{n \\geq N} \\frac{f(n)}{n^\\sigma} = 0\\), have\n  \\[\n    f(N) = - N^\\sigma \\sum_{n > N} \\frac{f(n)}{n^\\sigma}\n  \\]\n  so \\(|f(n)| \\ll n^\\sigma\\) and so the series\n  \\[\n    \\sum_{n > N} \\frac{f(n)}{n^{\\sigma + 1 + \\varepsilon}}\n    \\]\n    is absolutely convergent. So since \\(\\frac{f(n)}{n^\\sigma} \\to 0\\) as \\(\\sigma \\to \\infty\\), RHS also converges to \\(0\\) so \\(f(N) = 0\\).\n\\end{proof}\n\n\\begin{lemma}\n  If \\(L_f(s)\\) and \\(L_g(s)\\) are both absolutely convergent at \\(s\\) then\n  \\[\n    L_{f * g} (s) = \\sum_{n = 1}^\\infty \\frac{f * g (n)}{n^s}\n    \\]\n    is also absolutely convergent at \\(s\\) and equals to \\(L_f(s) L_g(s)\\).\n\\end{lemma}\n\n\\begin{proof}\n  Because of absolute convergence we can simply multiply them term-by-term:\n  \\[\n    \\left( \\sum_{n = 1}^\\infty \\frac{f(n)}{n^s} \\right) \\left( \\sum_{n = 1}^\\infty \\frac{g(n)}{n^s} \\right)\n    = \\sum_{n, m = 1}^\\infty \\frac{f(n) g(m)}{(nm)^s} = \\sum_{k = 1}^\\infty \\frac{1}{k^s} \\left( \\sum_{nm = k} f(n) g(m) \\right).\n  \\]\n\\end{proof}\n\n\\begin{lemma}[Euler product]\\index{Euler product}\n  If \\(f\\) is multiplicative and \\(L_f(s)\\) is absolutely convergent at \\(s\\) then\n  \\[\n    L_f(s) = \\prod_p \\left( 1 + \\frac{f(p)}{p^s} + \\frac{f(p^2)}{p^{2s}} + \\dots \\right).\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Informally we just multiply everything and apply fundamental theorem of arithmetics. However, we have to be more careful when dealing with this infinite product. Let \\(y\\) be arbitrary,\n  \\[\n    \\prod_{p < y} \\left( 1 + \\frac{f(p)}{p^s} + \\dots \\right)\n    = \\sum_{\\substack{n \\\\ \\forall p \\divides n, p < y}} \\frac{f(n)}{n^s}.\n  \\]\n  Then\n  \\[\n    \\phantom{=} \\left| \\prod_{p < y} \\left( 1 + \\frac{f(p)}{p^s} + \\dots \\right) - \\sum_{n = 1}^\\infty \\frac{f(n)}{n^s} \\right|\n    \\leq \\sum_{\\substack{n \\\\ \\exists p \\divides n, p \\geq y}} \\frac{|f(n)|}{n^\\sigma}\n    \\leq \\sum_{n \\geq y} \\frac{|f(n)|}{n^\\sigma}\n    \\to 0\n  \\]\n  as \\(n \\to \\infty\\).\n\\end{proof}\n\nFor \\(\\sigma > 1\\),\n\\[\n  \\zeta(s) = \\sum_{n = 1}^\\infty \\frac{1}{n^s}\n\\]\ndefines a holomorphic function and converges \\emph{absolutely} for \\(\\sigma > 1\\). A word of caution: this series is only define for \\(\\sigma > 1\\). We'll in later part of the course analytically extend \\(\\zeta\\) beyond the line. Also note that for general Dirichlet series, uniform convergence and absolute convergence near a point do \\emph{not} imply each other, although for this particular series they do. Because of uniform convergence this function has derivative\n\\[\n  \\zeta'(s) = - \\sum \\frac{\\log n}{n^s}.\n\\]\n\nSince \\(1\\) is completely multiplicative, we may apply Euler product\n\\[\n  1 + \\frac{1}{p^s} + \\frac{1}{p^{2s}} + \\dots = \\frac{1}{1 - p^{-s}} = \\left( 1 - \\frac{1}{p^s} \\right)^{-1}\n\\]\nso\n\\[\n  \\zeta(s) = \\prod_p \\left( 1 - \\frac{1}{p^s} \\right)^{-1}.\n\\]\nThus\n\\begin{align*}\n  \\frac{1}{\\zeta(s)} &= \\prod_p \\left( 1 - \\frac{1}{p^s} \\right) = \\sum_n \\frac{\\mu(n)}{n^s} \\\\\n  \\log \\zeta(s) &= - \\sum_p \\log (1 - \\frac{1}{p^s}) = \\sum_p\\sum_k \\frac{1}{k p^{ks}} = \\sum \\frac{\\Lambda(n)}{\\log n} \\frac{1}{n^s} \\\\\n  \\frac{\\zeta'(s)}{\\zeta(s)} &= - \\sum \\frac{\\Lambda(n)}{n^s}\n\\end{align*}\nWe can write many functions and identities in terms of \\(\\zeta(s)\\). For example\n\\[\n  \\frac{\\zeta'(s)}{\\zeta(s)} \\cdot \\zeta(s) = \\zeta'(s)\n\\]\ncorresponds to\n\\[\n  \\Lambda * 1 = \\log,\n\\]\nand the equivalence\n\\[\n  L_f \\cdot \\zeta = L_g \\iff L_f = \\frac{1}{\\zeta} \\cdot L_g\n\\]\ncorresponds to Möbius inversion.\n\nA callback to a previous discussion on elementary proof of prime number theorem: recall on page~\\pageref{proof:attempted elementary proof of PNT}, if we can show\n\\[\n  \\frac{1}{\\zeta(s)} = \\prod_p \\left( 1 - \\frac{1}{p^s} \\right) = \\sum_n \\frac{\\mu(n)}{n^s}\n\\]\nconverges to \\(0\\) at \\(s = 1\\) then we can prove prime number theorem. We can show that if it converges at \\(0\\) then it does converge to \\(0\\), but the difficulty is to show it converges at all!\n\n\\begin{lemma}\n  For \\(\\sigma > 1\\),\n  \\[\n    \\zeta(s) = 1 + \\frac{1}{s - 1} - s \\int_1^\\infty \\frac{\\{t\\}}{t^{s + 1}} dt.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  By partial summation,\n  \\begin{align*}\n    \\sum_{1 \\leq n \\leq x} \\frac{1}{n^s}\n    &= \\frac{\\floor{x}}{x^s} + s \\int_1^x \\frac{\\floor t}{t^{s + 1}} dt \\\\\n    &= \\frac{\\floor{x}}{x^s} + s \\int_1^x \\frac{1}{t^s} dt - s \\int_1^x \\frac{\\{t\\}}{t^{s + 1}} dt \\\\\n    &= \\frac{\\floor{x}}{x^s} + \\frac{s}{s - 1} [t^{-s + 1}]_1^x - s \\int_1^x \\frac{\\{t\\}}{t^{s + 1}} dt \\\\\n    &\\to \\frac{s}{s - 1} - s \\int_1^\\infty \\frac{\\{t\\}}{t^{s + 1}} dt \\quad \\text{as } x \\to \\infty\n  \\end{align*}\n\\end{proof}\n\nThe integral converges absolutely for \\(\\sigma > 0\\), so this gives\n\\[\n  \\zeta(s) = \\frac{1}{s - 1} + F(s)\n\\]\nwhere \\(F(s)\\) is holomorphic in \\(\\sigma > 0\\). Thus we \\emph{define}\\index{Riemann zeta function}\n\\[\n  \\zeta(s) = 1 + \\frac{1}{s - 1} - s \\int_1^\\infty \\frac{\\{t\\}}{t^{s + 1}} dt\n\\]\nfor \\(\\sigma > 0\\).\n\n\\(\\zeta(s)\\) is meromorphic in \\(\\sigma > 0\\), with only a simple pole at \\(s = 1\\). It is possible to analytically continue \\(\\zeta\\) to the entire complex plane, with only a single pole at \\(1\\). But for the purpose of this course our definition suffices as all interesting things we study happen on this half plane.\n\n\\begin{corollary}\n  For \\(0 < \\sigma < 1\\),\n  \\[\n    \\frac{1}{\\sigma - 1} < \\zeta(\\sigma) < \\frac{\\sigma}{\\sigma - 1}.\n  \\]\n  In particular, \\(\\zeta(\\sigma) < 0\\) for \\(0 < \\sigma < 1\\) (in particular nonzero).\n\\end{corollary}\n\n\\begin{proof}\n  Write\n  \\[\n    \\zeta(\\sigma) = 1 + \\frac{1}{\\sigma - 1} + \\sigma \\int_1^\\infty \\frac{\\{t\\}}{t^{\\sigma + 1}} dt\n  \\]\n  and note\n  \\[\n    0 < \\int_1^\\infty \\frac{\\{t\\}}{t^{\\sigma + 1}} dt < \\frac{1}{\\sigma}.\n  \\]\n\\end{proof}\n\n\\begin{corollary}\n  For \\(0 < \\delta \\leq \\sigma \\leq 2, |t| \\leq 1\\),\n  \\[\n    \\zeta(s) = \\frac{1}{s - 1} + O_\\delta(1)\n  \\]\n  uniformly.\n\\end{corollary}\n\n\\begin{proof}\n  \\begin{align*}\n    \\zeta(s) - \\frac{1}{s - 1}\n    &= 1 - s \\int_1^\\infty \\frac{\\{t\\}}{t^{s + 1}} dt \\\\\n    &= O(1) + O_\\delta(\\int_1^\\infty \\frac{1}{t^{\\sigma + 1}} dt) \\\\\n    &= O(1) + O_\\delta(1)\n  \\end{align*}\n\\end{proof}\n\n\\begin{lemma}\n  \\(\\zeta \\neq 0\\) for \\(\\sigma > 1\\).\n\\end{lemma}\n\n\\begin{proof}\n  For \\(\\sigma > 1\\),\n  \\[\n    \\zeta(s) = \\prod_p \\left( 1 - \\frac{1}{p^s} \\right)^{-1}\n  \\]\n  and the infinite product converges, and no factors are zero.\n\\end{proof}\n\nAgain we stress that the Euler product is only valid for \\(\\sigma > 1\\).\n\n\\begin{conjecture}[Riemann hypothesis]\\index{Riemann hypothesis}\n  If \\(\\zeta(s) = 0\\) and \\(\\sigma > 0\\) then \\(\\sigma = \\frac{1}{2}\\).\n\\end{conjecture}\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\fill[blue!5] (0, -2) rectangle (1, 2);\n    \\draw [red!50, ultra thick] (0, 0) -- (1, 0);\n    \\fill[red!50] (1, -2) rectangle (3, 2);\n\n    \\draw [->] (-3, 0) -- (3.5, 0);\n    \\draw [->] (0, -2.2) -- (0, 2.2);\n\n    \\draw [thick, dashed] (1, -2.2) -- (1, 2.2);\n\n\n    \\node at (1, 0) {\\(\\times\\)};\n    \\node at (1, 0) [anchor = north east] {\\(1\\)};\n\n    \\draw [blue, dashed] (0.5, -2.2) -- (0.5, 2.2);\n\n    \\node at (0.5, -2) [anchor = north] {\\(\\sigma = \\frac{1}{2}\\)};\n  \\end{tikzpicture}\n\\end{center}\n\n\\subsection{Prime number theorem}\n\nLet \\(\\alpha(s) = \\sum \\frac{a_n}{n^s}\\). Partial summation lets us write \\(\\alpha(s)\\) in terms of \\(A(x) = \\sum_{n \\leq x} a_n\\). If \\(\\sigma > \\max (0, \\sigma_c)\\) then\n\\[\n  \\alpha(s) = s \\int_1^\\infty \\frac{A(t)}{t^{s + 1}} dt\n\\]\nThis is \\emph{Mellin transform}\\index{Mellin tranform}.\n\nWhat about the converse? As a particular case, if \\(\\alpha(s) = -\\frac{\\zeta'(s)}{\\zeta(s)}\\) then \\(a_n = \\Lambda(n)\\) so\n\\[\n  A(x) = \\sum_{n \\leq x} \\Lambda(n) = \\psi(x).\n\\]\nThe point of analytic number theory is to study Dirichlet series using analytic methods and convert them back to statements about arithmetic functions.\n\nThe converse is given by Perron's formula, which roughly says that\n\\[\n  A(x) = \\frac{1}{2\\pi i} \\int_{\\sigma - i \\infty}^{\\sigma + i \\infty} \\alpha(s) \\frac{x^s}{s} ds\n\\]\nfor \\(\\sigma > \\max (0, \\sigma_c)\\).\n\nBefore we prove the formula, we see how this leads to prime number theorem. By Perron's formula,\n\\[\n  \\psi(x) = \\frac{1}{2\\pi i} \\int_{\\sigma - i \\infty}^{\\sigma + i \\infty} -\\frac{\\zeta'(s)}{\\zeta(s)} \\frac{x^s}{s} ds\n\\]\nfor \\(\\sigma > 1\\).\n\nWe see that the integrand has two poles, on at the origin and the other at \\(1\\). Our first attempt would be to integrate to the right of the critical line as there is no singularity.\n\\begin{center}\n  \\begin{tikzpicture}\n    \\draw [->] (-3, 0) -- (3, 0);\n    \\draw [->] (0, -2.2) -- (0, 2.2);\n\n    \\draw [dashed] (1, -2.2) -- (1, 2.2);\n\n    \\node at (0, 0) {\\(\\times\\)};\n    \\node at (1, 0) {\\(\\times\\)};\n\n    \\draw[->, blue, thick] (1.5, 2) -- (1.5, -2) -- (2.5, -2) -- (2.5, 2) -- (1.5, 2);\n\n    \\node at (1, 0) [anchor=north east] {\\(1\\)};\n  \\end{tikzpicture}\n\\end{center}\n\nHowever we quickly run into problems. As the integrand is holomorphic in this region, by Cauchy's theorem \\(\\psi(x)\\) equals to the contribution of the other segments (up to a sign). The best we can do is \\(\\psi(x) = O(x^{1 + \\varepsilon})\\), which, in view of what we have done, totally trivial. Thus we can't simply consider a contour in \\(\\sigma > 1\\).\n\nInstead we have to cross the critial line, whih gives \\(O(x^{1 - \\varepsilon})\\), which is what we need. But now we need to understand \\(\\zeta\\) on/to the left of the critial line.\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\draw [->] (-3, 0) -- (3, 0);\n    \\draw [->] (0, -2.2) -- (0, 2.2);\n\n    \\draw [dashed] (1, -2.2) -- (1, 2.2);\n\n    \\node at (0, 0) {\\(\\times\\)};\n    \\node at (1, 0) {\\(\\times\\)};\n\n    \\draw[->, blue, thick] (1.5, 2) -- (1.5, -2) -- (0.9, -2) -- (0.9, 2) -- (1.5, 2);\n\n    \\node at (1, 0) [anchor=north east] {\\(1\\)};\n  \\end{tikzpicture}\n\\end{center}\n\nWe can summarise this intuition with the slogan ``prime number theorem is equivalent to the statment that there is no zeroes on \\(\\sigma = 1\\)''.\n\n\\begin{lemma}\n  If \\(\\sigma_0 > 0\\) then\n  \\[\n    \\frac{1}{2\\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\frac{y^s}{s} ds =\n    \\begin{cases}\n      1 & y > 1 \\\\\n      0 & y < 1\n    \\end{cases}\n    + O(\\frac{y^{\\sigma_0}}{T |\\log y|})\n  \\]\n\\end{lemma}\nNote that we omit the case \\(y = 1\\).\n\n\\begin{proof}\n  Use a rectangular contour that lies either to the left or to the right of the line \\(\\sigma = \\sigma_0\\) depending on \\(y\\), which then determines whether the residue at \\(0\\) is picked up. The details are left as an exercise.\n\\end{proof}\nThis gives a way to express indicator function in integral form.\n\n\\begin{theorem}[Perron's formula]\\index{Perron's formula}\n  Suppose \\(\\alpha(s) = \\sum \\frac{a_n}{n^s}\\) is absolutely convergent for \\(\\sigma > \\sigma_a\\). If \\(\\sigma_0 > \\max (0, \\sigma_a)\\) and \\(x\\) is not an integer then\n  \\begin{align*}\n    \\sum_{n < x} a_n\n    &= \\frac{1}{2 \\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\alpha(s) \\frac{x^s}{s} ds \\\\\n    &+ O(\\frac{2^{\\sigma_0}x}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{|a_n|}{|x - n|} + \\frac{x^{\\sigma_0}}{T} \\sum_{n = 1}^\\infty \\frac{|a_n|}{n^{\\sigma_0}}).\n  \\end{align*}\n\\end{theorem}\n\n\\begin{proof}\n  Since \\(\\sigma_0 > 0\\) we can write\n  \\[\n    1_{n < x}\n    = \\frac{1}{2\\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\frac{(x/n)^s}{s} ds + O(\\frac{(x/n)^{\\sigma_0}}{T |\\log \\frac{x}{n}|})\n  \\]\n  so\n  \\begin{align*}\n    \\sum_{n < x} a_n\n    &= \\sum_n a_n 1_{n < x} \\\\\n    &= \\frac{1}{2\\pi i} \\sum_n a_n \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\frac{(x/n)^s}{s} ds + \\underbrace{O(\\frac{x^{\\sigma_0}}{T} \\sum_n \\frac{|a_n|}{n^{\\sigma_0} |\\log \\frac{x}{n}|})}_E \\\\\n    &= \\frac{1}{2\\pi i} \\int_{\\sigma_0 + iT}^{\\sigma_0 - iT} \\frac{x^s}{s} \\sum_n \\frac{a_n}{n^s} ds + E \\quad \\text{absolute convergence} \\\\\n    &= \\frac{1}{2 \\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\alpha(s) \\frac{x^s}{s} ds + E\n  \\end{align*}\n  For the error term \\(E\\), there is\n  \\begin{enumerate}\n  \\item contribution from \\(n \\leq \\frac{x}{2}\\) or \\(n \\geq 2x\\), where \\(|\\log \\frac{x}{n}| \\gg 1\\), is\n    \\[\n      \\ll \\frac{x^{\\sigma_0}}{T} \\sum_n \\frac{|a_n|}{n^{\\sigma_0}}.\n    \\]\n  \\item contribution from \\(\\frac{x}{2} < n < 2x\\), we write\n    \\[\n      |\\log \\frac{x}{n}| = |\\log (1 + \\frac{n - x}{x})|\n    \\]\n    and \\(|\\log (1 + \\delta)| \\asymp |\\delta|\\) uniformly for \\(- \\frac{1}{2} \\leq \\delta \\leq 1\\). So\n    \\[\n      \\frac{x^{\\sigma_0}}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{|a_n|}{n^{\\sigma_0} |\\log \\frac{x}{n}|}\n      \\ll \\frac{x^{\\sigma_0}}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{|a_n| x}{n^{\\sigma_0} |x - n|}\n      \\ll \\frac{2^{\\sigma_0}}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{|a_n| x}{|x - n|}\n    \\]\n  \\end{enumerate}\n\\end{proof}\n\nWe will now prove a strong form of the prime number theorem, assuming\n\\begin{enumerate}\n\\item there exists \\(c > 0\\) such that if \\(\\sigma > 1 - \\frac{c}{\\log (|t| + 4)}\\) and \\(|t| \\geq \\frac{7}{8}\\) then \\(\\zeta(s) \\neq 0\\) and\n  \\[\n    \\frac{\\zeta'(s)}{\\zeta(s)} \\ll \\log (|t| + 4).\n  \\]\n\\item \\(\\zeta(s) \\neq 0\\) for \\(\\frac{8}{9} \\leq \\sigma \\leq 1, |t| \\leq \\frac{7}{8}\\).\n\\item Whenever \\(|t| \\leq \\frac{7}{8}\\) and\n  \\[\n    1 - \\frac{c}{\\log (|t| + 4)} < \\sigma \\leq 2\n  \\]\n  have\n  \\[\n    \\frac{\\zeta'(s)}{\\zeta(s)} = - \\frac{1}{s - 1} + O(1).\n  \\]\n\\end{enumerate}\n\n\\begin{center}\n  \\begin{tikzpicture}\n    \\draw [red!50, ultra thick] (0, 0) -- (2, 0);\n    \\fill [red!50] (2, -0.5) rectangle (4, 0.5);\n\n    \\path [fill=red!50] (2, 0.5) to [bend right=30] (3.5, 2) -- (3.5, -2) to [bend right=30] (2, -0.5) -- (2, 0.5);\n\n    \\draw [->] (-1, 0) -- (5, 0);\n    \\draw [->] (0, -2.2) -- (0, 2.2);\n\n    \n    \\draw [dashed] (4, -2.2) -- (4, 2.2);\n\n    \\node at (0, 0) {\\(\\times\\)};\n    \\node at (4, 0) {\\(\\times\\)};\n    \n    \\draw[->, blue, thick] (4.3, -2) -- (4.3, 2) -- (3.5, 2) -- (3.5, -2) -- (4.3, -2);\n\n    \\node at (4, 0) [anchor=north east] {\\(1\\)};\n    \\node at (4.3, -2) [anchor=north west] {\\(\\sigma_0 - iT\\)};\n    \\node at (3.5, -2) [anchor=north east] {\\(\\sigma_1 - iT\\)};\n    \\node at (4.3, 2) [anchor=south west] {\\(\\sigma_0 + iT\\)};\n    \\node at (3.5, 2) [anchor=south east] {\\(\\sigma_1 + iT\\)};\n\n  \\end{tikzpicture}\n\\end{center}\n\n\\begin{theorem}[prime number theorem]\\index{prime number theorem}\n  There exists \\(c > 0\\) such that\n  \\[\n    \\psi(x) = x + O(\\frac{x}{\\exp(c \\sqrt{\\log x})}).\n  \\]\n  In particular \\(\\psi(x) \\sim x\\).\n\\end{theorem}\n\nThis error is better than \\(\\frac{x}{\\log x}\\) but worse than \\(x^{1 - \\varepsilon}\\) for any \\(\\varepsilon > 0\\), which is precisely because we can't find an absolute bound on the zero-free region near the critical line.\n\n\\begin{proof}\n  Assume that \\(x = N + \\frac{1}{2}\\) for some \\(N\\). By Perron's formula, for any \\(1 < \\sigma_0 \\leq 2\\),\n  \\begin{align*}\n    \\psi(x)\n    &= \\sum_{n \\leq x} \\Lambda(n) \\\\\n    &= \\frac{1}{2\\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} - \\frac{\\zeta'(s)}{\\zeta(s)} \\frac{x^s}{s} ds \\\\\n    &+ O(\\underbrace{\\frac{x}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{\\Lambda(n)}{|x - n|}}_{R_1} + \\underbrace{\\frac{x^{\\sigma_0}}{T} \\sum_{n = 1}^\\infty \\frac{\\Lambda(n)}{n^{\\sigma_0}}}_{R_2})\n  \\end{align*}\n  In the error term,\n  \\[\n    R_1\n    \\ll \\log x \\cdot \\frac{x}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{1}{|x - n|}\n    \\ll \\log x \\cdot \\frac{x}{T} \\sum_{1 \\leq m \\leq 4x} \\frac{1}{m}\n    \\ll \\frac{x}{T} (\\log x)^2\n  \\]\n  and using assumption 3,\n  \\[\n    R_2\n    \\ll \\frac{x^{\\sigma_0}}{T} \\frac{1}{|\\sigma_0 - 1|}\n    \\ll \\frac{x}{T} \\log x\n  \\]\n  if \\(\\sigma_0 = 1 + \\frac{1}{\\log x}\\).\n\n  Let \\(C\\) be the rectangular contour with vertices \\(\\{\\sigma_0 \\pm iT, \\sigma_1 \\pm iT\\}\\) where \\(\\sigma_1 < 1\\) is to be chosen later. Then\n  \\[\n    \\frac{1}{2\\pi i} \\int_C - \\frac{\\zeta'(s)}{\\zeta(s)} \\frac{x^s}{s} ds = x\n  \\]\n  by residue theorem and assumption 1 and 2.\n\n  Remains to bound the other components of the integral.\n  \\[\n    \\int_{\\sigma_0 + iT}^{\\sigma_1 + iT} - \\frac{\\zeta'(s)}{\\zeta(s)} \\frac{x^s}{s} ds\n    \\ll \\log T \\int_{\\sigma_0}^{\\sigma_1} \\frac{x^u}{T} du\n    \\ll \\frac{\\log T}{T} x^{\\sigma_1} (\\sigma_1 - \\sigma_0) \\ll \\frac{x}{T}\n  \\]\n  where the last step is because we assumed \\(\\sigma_1 = 1 - \\frac{c}{\\log T}\\) (?)\n\n  For the other term,\n  \\begin{align*}\n    \\int_{\\sigma_1 - iT}^{\\sigma_1 + iT} - \\frac{\\zeta'(s)}{\\zeta(s)} \\frac{x^s}{s} ds\n    &\\ll \\log T \\int_{\\sigma_1 - iT}^{\\sigma_1 - iT} \\frac{x^u}{u} du + \\int_{\\sigma_1 - iT}^{\\sigma_1 + iT} x^{\\sigma_1} \\frac{1}{|\\sigma_1 - 1|} \\\\\n    &\\ll x^{\\sigma_1} \\log T + \\frac{x^{\\sigma_1}}{1 - \\sigma_1} \\\\\n    &\\ll x^{\\sigma_1} \\log T\n  \\end{align*}\n\n  Thus\n  \\begin{align*}\n    \\psi(x)\n    &= x + O(\\frac{x}{T} (\\log x)^2 + x^{1 - \\frac{c}{\\log T}} (\\log T)) \\\\\n    &= x + O(\\frac{x}{\\exp(c \\sqrt{\\log x})}) \\quad \\text{if } T = \\exp(c \\sqrt{\\log x})\n  \\end{align*}\n  If you are curious how we chose \\(T\\), it is the same trick as in chapter 1: want to have \\(\\frac{x}{T} \\approx x^{1 - \\frac{c}{\\log T}}\\) so\n    \\[\n      \\log T \\approx \\frac{\\log x}{\\log T},\n    \\]\n    i.e.\\ \\(\\log T \\approx \\sqrt{\\log x}\\).\n\\end{proof}\n\n\\subsection{Zero-free region}\n\nFirstly, near \\(s = 1\\), things are easy because of the pole.\n\n\\begin{theorem}\n  If \\(\\sigma > \\frac{1 + t^2}{2}\\) then \\(\\zeta(s) \\neq 0\\). In particular, \\(\\zeta(s) \\neq 0\\). If \\(\\frac{8}{9} \\leq \\sigma \\leq 1, |t| \\leq \\frac{7}{8}\\).\n\n  Also\n  \\begin{align*}\n    \\zeta(s) &= \\frac{1}{s - 1} + O(1) \\\\\n    - \\frac{\\zeta'(s)}{\\zeta(s)} &= \\frac{1}{s - 1} + O(1)\n  \\end{align*}\n  uniformly in \\(\\frac{8}{9} \\leq \\sigma \\leq 1, |t| \\leq \\frac{7}{8}\\).\n\\end{theorem}\n\n\\begin{proof}\n  Recall that\n  \\[\n    \\zeta(s) = \\frac{s}{s - 1} + s \\int_1^\\infty \\frac{\\{u\\}}{u^{s + 1}} du\n  \\]\n  so\n  \\[\n    \\Big| \\zeta(s) - \\frac{s}{s - 1} \\Big| \\leq |s| \\int_1^\\infty \\frac{1}{u^{\\sigma + 1}} du \\leq \\frac{|s|}{\\sigma}\n    \\]\n    so if \\(\\sigma > |s - 1|\\), \\(\\zeta(s) \\neq 0\\), i.e.\\ if \\(\\sigma < \\frac{1 + t^2}{2}\\). Also\n    \\[\n      |\\zeta(s) - \\frac{1}{s - 1}| \\leq 1 + |s| \\int_1^\\infty \\frac{1}{u^{\\sigma + 1}} du = O(1)\n    \\]\n    so same holds for \\(- \\frac{\\zeta'}{\\zeta}\\), by general theory of holomorphic functions.\n\\end{proof}\n\nFor \\(|t|\\) large, we need a different idea. How do we show that there aren't zeros on \\(\\sigma = 1\\)? Suppose there is a zero, of order \\(m\\), at \\(1 + it\\). Then\n\\[\n  - \\frac{\\zeta'}{\\zeta} (1 + \\delta + it) \\sim \\frac{m}{\\delta}\n\\]\nso\n\\[\n  \\sum \\frac{\\Lambda(n)}{n^{1 + \\delta + it}} \\sim -\\frac{m}{\\delta}.\n\\]\nAbsolute value of LHS\n\\[\n  \\leq \\sum \\frac{\\Lambda(n)}{n^{1 + \\delta}}\n  = - \\frac{\\zeta'}{\\zeta} (1 + \\delta) \\sim \\frac{1}{\\delta}\n\\]\nso this shows \\(m \\leq 1\\). If there is a zero, it is a simple zero.\n\nThis also tells us\n\\[\n  \\sum_p \\frac{\\log p}{p^{1 + \\delta}} e^{i t \\log p} \\sim - \\sum \\frac{\\log p}{p^{1 + \\delta}}\n\\]\nso\n\\[\n  \\cos (t \\log p) \\approx -1\n\\]\nfor almost all \\(p\\), so \\(p^{it} \\approx -1, p^{2it} \\approx 1\\) for almost all \\(p\\), so there exists a pole at \\(1 + 2i t\\), which is a contradiction.\n\nWe now present a rigorous proof. Before that we need to take a detour in complex analysis.\n\n\\begin{lemma}[Borel-Carathéodory lemma]\\index{Borel-Carathéodory lemma}\n  If \\(f\\) is holomorphic on \\(|z| \\leq R\\) and \\(f(0) = 0\\). If \\(\\Re f(z) \\leq M\\) for all \\(|z| \\leq R\\), then for any \\(r < R\\),\n  \\[\n    \\sup_{|t| \\leq r} (|f(z)|, |f'(z)|) \\ll_{r, R} M.\n  \\]\n\\end{lemma}\nIf we replace \\(\\Re f(z)\\) by \\(|f(z)|\\) then this is just maximum value principle.\n\n\\begin{proof}\n  Let\n  \\[\n    g(z) = \\frac{f(z)}{z (2M - f(z))}.\n  \\]\n\n  This is holomorphic in \\(|z| \\leq R\\). If \\(|z| = R\\) then\n  \\[\n    |2M - f(z)| \\geq |f(z)|\n  \\]\n  and so\n  \\[\n    |g(z)| \\leq \\frac{|f(z)|}{R |f(z)|} \\leq \\frac{1}{R}.\n  \\]\n  So for all \\(|z| \\leq r < R\\), by maximum modules,\n  \\[\n    |g(z)| = \\frac{|f(z)|}{|z| |2m - f(z)|} < \\frac{1}{R}\n  \\]\n  so\n  \\[\n    R |f(z)| \\leq r |2M - f(z)| \\leq 2M r + r |f(z)|\n  \\]\n  so\n  \\[\n    |f(z)| \\leq \\frac{2M r}{R - r} \\ll M.\n  \\]\n\n  For \\(f'(z)\\), we use Cauchy's formula\n  \\[\n    f'(z) = \\frac{1}{\\pi i} \\int_{|w| = r'} \\frac{f(w)}{(z - w)^2} dw\n  \\]\n  for \\(r < r' < R\\). (coefficient 2?)\n\\end{proof}\n\n\\begin{lemma}\n  If \\(f\\) is holomorphic on a domain including \\(|z| \\leq 1\\), \\(|f(z)| \\leq M\\) in that disc, and \\(f(0) \\neq 0\\). If \\(0 < r < R < 1\\) then for \\(|z| \\leq r\\)\n  \\[\n    \\frac{f'}{f} (z) = \\sum_{k = 1}^K \\frac{1}{z - z_k} + O_{r, R} (\\log \\frac{M}{|f(0)|})\n  \\]\n  where \\(z_k\\) ranges over all zeros of \\(f\\) in \\(|z| \\leq R\\).\n\\end{lemma}\nc.f. fundamental theorem of algebra, and holomorphicity. This depends crucially on \\(\\C\\) being algebraically closed.\n\n\\begin{proof}\n  Suppose wlog \\(f(0) = 1\\). Say first there are no zeros. Consider \\(h(z) = \\log f(z)\\) and\n  \\[\n    \\Re h(z) = \\log |f(z)| \\leq \\log M\n  \\]\n  so by Borel-Carathéodory lemma,\n  \\[\n    |h'(z)| = |\\frac{f'}{f(z)}| \\ll \\log M\n  \\]\n  so done.\n\n  In general, we define an auxillary function \\(g\\) with no zeros. Let\n  \\[\n    g(z) = f(z) \\prod_{k = 1}^K \\frac{R^2 - z \\conj z_k}{(z - z_k) R}.\n  \\]\n  The \\(k\\)th factor has a pole at \\(z = z_k\\) and on \\(|z| = R\\), has modulus \\(1\\) so on \\(|z| \\leq R\\), \\(|g(z)| \\leq M\\). In particular, \\(|g(0)| = \\prod_{k = 1}^K \\frac{R}{|z_k|} \\leq M\\). Now let\n  \\[\n    h(z) = \\log \\frac{g(z)}{g(0)}\n  \\]\n  and\n  \\[\n    \\Re h(z) = \\log |g(z)| - \\log |g(0)| \\leq \\log M\n  \\]\n  for \\(|z| \\leq R\\). By Borel-Carathéodory lemma,\n  \\[\n    |h'(z)| = |\\frac{f'}{f} (z) - \\sum_{k = 1}^K \\frac{1}{z - z_k} + \\sum_{k = 1}^K \\frac{1}{z - R^2/\\conj z_k} \\ll \\log M\n  \\]\n  so\n  \\[\n    \\frac{f'}{f} (z) = \\sum_{k = 1}^K \\frac{1}{z - z_k} - \\sum_{k = 1}^K \\frac{1}{z - R^2/\\conj z_k} + O(\\log M)\n  \\]\n  and if \\(|z| \\leq r\\),\n  \\[\n    |z - \\frac{R^2}{\\conj z_k}| \\geq \\frac{R^2}{z_k} - |z| \\geq R - r \\gg 1\n  \\]\n  and \\(K \\ll \\log M\\).\n\\end{proof}\n\n\\begin{corollary}\n  If \\(|t| \\geq \\frac{7}{8}\\) and \\(\\frac{5}{6} \\leq \\sigma \\leq 2\\) then\n  \\[\n    \\frac{\\zeta'}{\\zeta}(s) = \\sum_\\rho \\frac{1}{s - \\rho} + O(\\log |t|)\n  \\]\n  where \\(\\rho\\) is over all zeros in\n  \\[\n    |\\rho - (\\frac{3}{2} + it)| \\leq \\frac{5}{6}.\n  \\]\n\\end{corollary}\n\n\\begin{theorem}\n  There exists \\(c > 0\\) such that \\(\\zeta(s) \\neq 0\\) if \\(\\sigma \\geq 1 - \\frac{c}{\\log t}\\).\n\\end{theorem}\n\n\\begin{proof}\n  Assume \\(\\zeta(\\rho) = 0\\) where \\(\\rho = \\sigma + it\\). Let \\(\\delta > 0\\) be chosen later.\n  \\[\n    \\frac{\\zeta'}{\\zeta} (1 + \\delta + i t)\n    = \\frac{1}{1 + \\delta + it - \\rho} + \\sum_{\\rho' \\neq \\rho} \\frac{1}{1 + \\delta + it - \\rho'} + O(\\log t)\n  \\]\n  (assuming that \\(\\sigma\\) is sufficiently close to \\(1\\)). Then\n  \\begin{align*}\n    \\Re \\frac{\\zeta'}{\\zeta} (1 + \\delta + i t)\n    &= \\Re \\frac{1}{1 + \\delta + it - \\rho} + \\Re \\sum_{\\rho' \\neq \\rho} \\frac{1}{1 + \\delta + it - \\rho'} + O(\\log t) \\\\\n    &= \\frac{1}{1 + \\delta - \\sigma} + O(\\log t) + (> 0)\n  \\end{align*}\n  since \\(\\Re \\rho' \\leq 1\\), \\(\\Re \\frac{1}{1 + \\delta + it - \\rho'} > 0\\). Thus\n  \\[\n    \\Re \\frac{\\zeta'}{\\zeta} (1 + \\delta + i t)\n    > \\frac{1}{1 + \\delta - \\sigma} + O(\\log t)\n  \\]\n  Similarly\n  \\[\n    \\Re \\frac{\\zeta'}{\\zeta} (1 + \\delta + 2 it) > O(\\log t).\n  \\]\n  Also\n  \\[\n    \\frac{\\zeta'}{\\zeta} (1 + \\delta) = - \\frac{1}{\\delta} + O(1).\n  \\]\n\n  Here comes the clever bit:\n  \\begin{align*}\n    \\Re(-3 \\frac{\\zeta'}{\\zeta} (1 + \\delta) - 4 \\frac{\\zeta'}{\\zeta} (1 + \\delta + it) - \\frac{\\zeta'}{\\zeta} (1 + \\delta + 2it))\n    &< \\frac{3}{\\delta} - \\frac{4}{1 + \\delta - \\sigma} + O(\\log t)\n      \\tag{\\dagger}\n  \\end{align*}\n  As \\(\\delta \\to 0\\), \\(\\dagger\\) is going to be negative. On the other hand, it is a a Dirichlet series\n  \\begin{align*}\n    \\dagger\n    &= \\Re( 3 \\sum_n \\frac{\\Lambda(n)}{n^{1 + \\delta}} + 4 \\sum_n \\frac{\\Lambda(n)}{n^{1 + \\delta + it}} + \\sum_n \\frac{\\Lambda(n)}{n^{1 + \\delta + 2it}} ) \\\\\n    &= \\sum_n \\frac{\\Lambda(n)}{n^{1 + \\delta}} (3 + 4 \\cos (t \\log n) + \\cos (2t \\log n))\n  \\end{align*}\n  Note\n  \\[\n    3 + 4 \\cos \\theta + \\cos (2\\theta) = 2 (1 + \\cos \\theta)^2 \\geq 0\n  \\]\n  so \\(\\dagger \\geq 0\\).\n\n  So\n  \\[\n    \\frac{3}{\\delta} > \\frac{4}{1 + \\delta - \\sigma} + O(\\log t).\n  \\]\n  Choose \\(\\delta = \\frac{C}{\\log t}\\) for large enough \\(C\\), so get a contradiction if \\(\\sigma \\geq 1 - \\frac{c}{\\log t}\\) for some \\(c > 0\\).( so\n  \\[\n    \\frac{4}{1 + \\delta - \\sigma} < \\frac{10}{\\delta}\n  \\]\n  so \\(\\sigma \\geq 1 - \\frac{c}{\\log t}\\).)\n\\end{proof}\n\nIt's essentially what we are able to do nowadays. Best known to date is\n\\[\n  \\sigma \\geq 1 - \\frac{c (\\log \\log t)^{1/3}}{(\\log t)^{2/3}}.\n\\]\n\n\\begin{lemma}\n  If \\(\\sigma > 1 - \\frac{c}{2 \\log t}\\) and \\(|t| \\geq \\frac{7}{8}\\) then\n  \\[\n    |\\frac{\\zeta'}{\\zeta}(s)| \\ll \\log t.\n  \\]\n\\end{lemma}\n\n\\begin{proof}\n  Let \\(s_1 = 1 + \\frac{1}{\\log t} + it = \\sigma_1 + it\\). Here\n  \\[\n    |\\frac{\\zeta'}{\\zeta}(s_1)|\n    \\ll \\sum_{n = 1}^\\infty \\frac{\\Lambda(n)}{n^{\\sigma_1}}\n    \\ll \\frac{1}{\\sigma_1 - 1}\n    \\ll \\log t.\n  \\]\n  Use the corollary\n  \\[\n    \\frac{\\zeta'}{\\zeta}(s_1) = \\sum_\\rho \\frac{1}{s_1 - \\rho} + O(\\log t)\n  \\]\n  so therefore\n  \\[\n    \\Re \\sum_\\rho \\frac{1}{s_1 - \\rho} \\ll \\log t.\n  \\]\n  Now if \\(s = \\sigma + it\\), where \\(\\sigma > 1 - \\frac{c}{2 \\log t}\\) then\n  \\[\n    \\frac{\\zeta'}{\\zeta}(s) - \\frac{\\zeta'}{\\zeta}(s_1)\n    = \\sum_\\rho (\\frac{1}{s - \\rho} - \\frac{1}{s_1 - \\rho}) + O(\\log t)\n  \\]\n  Also \\(|s - \\rho| \\asymp |s_1 - \\rho|\\) so\n  \\[\n    |\\frac{1}{s - \\rho} - \\frac{1}{s_1 - \\rho}|\n    \\ll \\frac{1}{|s_1 - \\rho|^2 \\log t}\n    \\ll \\Re \\frac{1}{s_1 - \\rho}\n  \\]\n  as \\(\\Re \\frac{1}{z} = \\frac{\\Re z}{|z|^2}\\). Then\n  \\[\n    \\sum_\\rho |\\frac{1}{s - \\rho} - \\frac{1}{s_1 - \\rho}|\n    \\ll \\Re \\sum_\\rho \\frac{1}{s_1 - \\rho}\n    \\ll \\log t.\n  \\]\n\\end{proof}\n\nAssuming the Riemann hypothesis, we can show\n\\[\n  \\psi(x) = x + O(x^{1/2} (\\log x)^2).\n\\]\nSee example sheet. Using partial summation, we can deduce that\n\\[\n  \\pi(x) = \\operatorname{Li} (x) + O_\\varepsilon(x^{1/2 + \\varepsilon})\n\\]\nwhere\n\\[\n  \\operatorname{Li} (x)\n  = \\int_2^x \\frac{1}{\\log t} dt\n  = \\frac{x}{\\log x} + O(\\frac{x}{(\\log x)^2}).\n\\]\nThus if we write \\(\\pi(x) = \\frac{x}{\\log x} + E(x)\\) then\n\\[\n  E(x) \\gg \\frac{x}{(\\log x)^2}\n\\]\njust because of \\(\\operatorname{Li}\\).\n\n\\subsection{Error terms}\n\nIndeed if we assume Riemann hypothesis then we could get the error term as above. Can we do better? In this section we will show that\n\\[\n  |\\psi(x) - x| \\gg x^{1/x}\n\\]\n``often''. Thus apart from the factor \\((\\log x)^2\\) we are getting the best possible error term. The reason is basically that there are many zeros of \\(\\zeta\\) on the critical line. Actually, we will show that\n\\[\n  \\psi(x) = x + \\Omega_{\\pm} (x^{1/2}),\n\\]\ni.e.\n\\begin{align*}\n  \\limsup_{x \\to \\infty} \\frac{\\psi(x) - x}{x^{1/2}} &> 0 \\\\\n  \\liminf_{x \\to \\infty} \\frac{\\psi(x) - x}{x^{1/2}} &< 0\n\\end{align*}\n\nFor contradiction, suppose that \\(\\psi(x) - x \\leq cx^{1/2}\\) for all large \\(x\\), so \\(cx^{1/2} - \\psi(x) = x \\geq 0\\). Take Mellin transform of this,\n\n\\begin{lemma}[Landau]\n  Let \\(A(x)\\) be intergrable and boundedon any finite interval and \\(A(x) \\geq 0\\) for all \\(x \\geq X\\). Let\n  \\[\n    \\sigma_c = \\inf \\{\\sigma: \\int_X^\\infty A(x) x^{-\\sigma} dx < \\infty\\}.\n  \\]\n  Then if\n  \\[\n    F(s) = \\int_1^\\infty A(x) x^{-s} dx\n  \\]\n  then \\(F\\) is analytic for \\(\\Re s > \\sigma_c\\) and \\emph{not} at \\(s = \\sigma_c\\).\n\\end{lemma}\nGeneral fact about poles of Dirichlet series with positive coefficients.\n\n\\begin{proof}\n  Divide integrand into \\([1, X]\\) and \\([X, \\infty)\\) , corresponding partition of \\(F = F_1 + F_2\\). \\(F_1\\) is entire. If \\(\\Re s > \\sigma_c\\), the integral converges absolutely so \\(F_2\\) is analytic.\n\n  By contradiction, suppose \\(F_2\\) is analytic at \\(s = \\sigma_c\\). Write \\(F_2\\) as a Taylor series around \\(\\sigma_c + 2\\)\n  \\[\n    F_2(s) = \\sum_{k = 0}^\\infty c_k (s - \\sigma_c - 1)^k\n  \\]\n  where\n  \\[\n    c_k = \\frac{F_2^{(k)}(\\sigma_c + 1)}{k!} = \\frac{1}{k!} \\int_x^\\infty A(x) (-\\log x)^k x^{- \\sigma_c - 1} dx.\n  \\]\n  This power series has a radius of convergence, which must be \\(1 + \\delta\\) for some \\(\\delta > 0\\). So\n  \\[\n    F_2(s) = \\sum_{k = 0}^\\infty \\frac{(1 - \\sigma_c - s)^k}{k!} \\int_x^\\infty A(x) (\\log x)^k x^{-1 - \\sigma_c} dx\n  \\]\n  Evaluate the series at \\(s = \\sigma_c - \\frac{\\delta}{2}\\), we can intercahnge the integral and summation so\n  \\[\n    F_2(\\sigma_c - \\frac{\\delta}{2})\n    = \\int_x^\\infty A(x) x^{-1 - \\sigma_c} \\exp((1 + \\sigma_c - s) \\log x) dx\n    = \\int_x^\\infty A(x) s^{-s} dx\n  \\]\n  so the integral converges at \\(\\sigma_c - \\frac{\\delta}{2}\\), contradicting the definition of \\(\\sigma_c\\).\n\\end{proof}\n\n\\begin{theorem}[Landau]\n  If \\(\\sigma_0\\) is the supremum of the real parts of\n  \\[\n    \\{\\rho: \\zeta(\\rho) = 0\\}\n  \\]\n  then\n  \\begin{enumerate}\n  \\item for any \\(\\sigma < \\sigma_0\\),\n    \\[\n      \\psi(x) - x = \\Omega_\\pm (x^\\sigma),\n    \\]\n  \\item if there is zero \\(\\rho\\) with \\(\\sigma = \\sigma_0\\) then\n    \\[\n      \\psi(x) - x = \\Omega_\\pm (x^{\\sigma_0}).\n    \\]\n  \\end{enumerate}\n\\end{theorem}\n\n\\begin{corollary}\n  (Assuming there is a zero with \\(\\sigma = \\frac{1}{2}\\), which is indeed true)\n  \\[\n    \\psi(x) - x = \\Omega_\\pm (x^{1/2}).\n  \\]\n\\end{corollary}\nProof by splitting into cases Riemann hypothesis is true/false.\n\n\\begin{corollary}\n  \\label{cor:RH equivalent to bound on PNT}\n  Riemann hypothesis is equivalent to\n  \\[\n    \\psi(x) = x + O(x^{1/2 + o(1)}).\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  Let \\(c > 0\\) be chosen later and suppose that \\(\\psi(x) - x \\leq c x^\\sigma\\) for all \\(x \\geq X\\). Consider\n  \\[\n    F(s) = \\int_1^\\infty (cx^\\sigma - \\psi(x) + x) x^{-s - 1} dx.\n  \\]\n  Recall that by partial summation, for \\(\\Re s > 1\\),\n  \\begin{align*}\n    \\frac{\\zeta'}{\\zeta}(s) &= -s \\int_1^\\infty \\psi(x) x^{-s - 1} dx \\\\\n    \\int_1^\\infty x^{-s} &= \\frac{1}{s - 1}\n  \\end{align*}\n  so\n  \\[\n    F(s) = \\frac{c}{s - \\sigma} + \\frac{\\sigma'(s)}{s \\zeta(s)} + \\frac{1}{s - 1}.\n  \\]\n  This has a pole at \\(s = \\sigma\\) and is analytic for \\(\\Re s > \\sigma\\). By Landau's lemma, in fact this integral converges for all \\(s\\) with \\(\\Re s > \\sigma\\). This proves 1 because if \\(\\sigma < \\sigma_0\\) then there is a zero of \\(\\zeta\\) with \\(0 < \\Re \\rho < \\sigma_0\\) and at \\(\\rho\\) \\(F\\) has a singularity since \\(\\rho \\notin \\R\\).\n\n  Suppose there is \\(\\rho = \\sigma_0 + it_0\\). Repeat the above with \\(\\sigma = \\sigma_0\\). Consider instead\n  \\[\n    G(s) = F(s) + \\frac{e^{i\\theta} F(s + it_0) + e^{-i\\theta} F(s - it_0)}{2}\n  \\]\n  where \\(\\theta \\in \\R\\) is to be chosen later. \\(G(s)\\) is still analytic for \\(\\Re s > \\sigma\\), and has a pole at \\(s = \\sigma_0\\). From \\(F(s)\\), have residue. From \\(F(s + it_0)\\), have residue \\(\\frac{m}{\\rho}\\) where \\(m\\) is the order of \\(\\rho\\). From \\(F(s - it_0)\\) have residue \\(\\frac{m}{\\conj \\rho}\\). So \\(G(s)\\) has a pole at \\(s = \\sigma_0\\) with residue\n  \\[\n    c + \\frac{e^{i\\theta} m}{2 \\rho} + \\frac{e^{-i\\theta}m}{2 \\conj \\rho} = c - \\frac{m}{|\\rho|}\n  \\]\n  by choosing appropriate \\(\\theta\\). In particular if \\(c < \\frac{m}{|\\rho|}\\) then this residue is negative. As \\(s \\to \\sigma_0\\) from right along \\(\\R\\), \\(G(s) \\to - \\infty\\). But for \\(\\Re s > \\sigma_0\\),\n  \\[\n    G(s) = \\int_1^\\infty (c x^{\\sigma_0} - \\psi(x) = x) x^{-s - 1} \\underbrace{(1 + \\frac{e^{i\\theta} x^{-it_0}}{2} +  \\frac{e^{-i\\theta} x^{it_0}}{2})}_{1 + \\cos (\\theta - t_0 \\log x) \\geq 0} dx\n  \\]\n  so splitting the integral into \\([1, X]\\) and \\([X, \\infty)\\), \\(G(s) = G_1(s) + G_2(s)\\) where \\(G_1\\) is entire and \\(G_2(s) \\geq 0\\) as \\(s \\in \\R, \\Re s > \\sigma_0\\). Absurd. This proves\n  \\[\n    \\psi(x) - x = \\Omega_+(x^\\sigma).\n  \\]\n  \\(\\Omega_-\\) is the same.\n\\end{proof}\n\n\\subsection{Functional equation}\n\nRecall that for \\(\\sigma > 0\\), we defined\n\\[\n  \\zeta(s) = 1 + \\frac{1}{s - 1} - s \\int_1^\\infty \\frac{\\{t\\}}{t^{s + 1}} dt.\n\\]\nHow does it behave in the negative half plane?\n\nFirst define \\(f(t) = \\frac{1}{2} - \\{t\\}\\), so\n\\[\n  \\zeta(s) = \\frac{1}{s - 1} + \\frac{1}{2} + s \\int_1^\\infty \\frac{f(t)}{t^{s + 1}} dt\n\\]\nwhich actually converges when \\(\\sigma > -1\\). To see this, let\n\\[\n  F(x) = \\int_0^x f(t) dt\n\\]\nso\n\\[\n  \\int_X^Y \\frac{f(t)}{t^{s + 1}} dt\n  = \\frac{F(t)}{t^{s + 1}} \\Big|_X^Y + (s + 1) \\int_X^Y \\frac{F(t)}{t^{s + 1}} dt\n\\]\nand note that \\(F(t)\\) is bounded (as seen from the graph of \\(f\\)). Therefore\n\\[\n  \\int_1^\\infty \\frac{f(t)}{t^{s + 1}} dt\n\\]\nconverges when \\(\\sigma > -1\\). We can take this as the definition of \\(\\zeta(s)\\) for \\(\\sigma > -1\\). At this point, we can do (perfectly sensible) things such as\n\\[\n  \\zeta(0) = -\\frac{1}{2} = 1 + 1 + 1 + \\cdots\n\\]\nIt is evident that we by iterating the process we may extend \\(\\zeta(s)\\) to arbitrary \\(\\sigma < 0\\), but there is a more elegant way to do this. First let's simplify the integral. Note that for \\(-1 < \\sigma < 0\\),\n\\[\n  s \\int_0^1 \\frac{f(t)}{t^{s + 1}}\n  = \\frac{s}{2} \\int_0^1 \\frac{1}{t^{s + 1}} dt - s \\int_0^1 \\frac{1}{t^s} dt\n  = \\frac{1}{2} + \\frac{1}{s - 1}\n\\]\nso in the strip \\(-1 < \\sigma < 0\\), have\n\\[\n  \\zeta(s) = s \\int_0^\\infty \\frac{f(t)}{t^{s + 1}} dt.\n\\]\nBy Fourier analysis, \\(f(t)\\) has a Fourier seires\n\\[\n  f(t) = \\sum_{n = 1}^\\infty \\frac{\\sin (2n \\pi t)}{n \\pi}\n\\]\nwhich converges whenver \\(t \\notin \\Z\\). In the region \\(-1 < \\sigma < 0\\), we get (by a standard argument exchanging summation and integration)\n\\begin{align*}\n  \\zeta(s)\n  &= s \\int_0^\\infty \\frac{1}{t^{s + 1}} \\sum_{n = 1}^\\infty \\frac{\\sin (2n \\pi t)}{n \\pi} dt \\\\\n  &= s \\sum_{n = 1}^\\infty \\frac{1}{n\\pi} \\int_0^\\infty \\frac{\\sin(2n \\pi t)}{t^{s + 1}} dt \\\\\n  &= s \\sum_{n = 1}^\\infty \\frac{(2n\\pi)^s}{n\\pi} \\int_0^\\infty \\frac{\\sin y}{y^{s + 1}} dy \\quad y = 2n\\pi t\n\\end{align*}\nHere\n\\[\n  \\sum_{n = 1}^\\infty \\frac{(2n\\pi)^s}{n\\pi} = 2^s \\pi^{s - 1} \\zeta(1 - s)\n\\]\nand\n\\[\n  \\int_0^\\infty \\frac{\\sin y}{y^{s + 1}} dy\n  = \\frac{1}{2i} \\left( \\int_0^\\infty \\frac{e^{iy}}{y^{s + 1}} dy - \\int_0^\\infty \\frac{e^{-iy}}{y^{s + 1}} dy \\right)\n  = - \\sin \\left( \\frac{s\\pi}{2} \\right) \\Gamma(-s)\n\\]\nwhere\n\\[\n  \\Gamma(s) = \\int_0^\\infty t^{s - 1}e^{-t} dt\n\\]\nfor \\(\\sigma > 0\\) is the \\emph{gamma function}\\index{gamma function}. We do a sanity check that the Dirichlet series and gamma function makes sense in the region.\n\nLet's have a digression about gamma function. The first identity is\n\\[\n  \\Gamma(s + 1)\n  = \\int_0^\\infty t^s e^{-t} dt\n  = -t^s e^{-t} \\big|_0^\\infty + s \\int_0^\\infty t^{s - 1} e^{-t} dt\n  = s \\Gamma(s).\n\\]\nIn particular, since \\(\\Gamma(1) = 1\\),\n\\[\n  \\Gamma(n) = (n - 1)!\n\\]\nwhich generalises factorial\\footnote{As a side remark, really we should have \\(t^s\\) in the integrand in the definition of gamma function so it is more consistent and things look nicer on the whole, at least from a number theory point of view. There were people in the 19th century using this notation but unfortunately a huge literature war ensued and obviously it didn't catch up.}. Also note \\(\\Gamma(s + 1) = s \\Gamma(s)\\) allows us to extend \\(\\Gamma(s)\\) to \\(\\C\\) with poles at \\(s = 0, -1, -2, \\cdots\\).\n\nBack to the zeta function. This mean that for \\(-1 < \\sigma < 0\\),\n\\begin{align*}\n  \\zeta(s)\n  &= s 2^s \\pi^{s - 1} \\zeta(1 - s) (- \\sin \\left( \\frac{\\pi s}{2} \\right) \\Gamma(-s)) \\\\\n  &= 2^s \\pi^{s - 1} \\sin \\left( \\frac{s \\pi}{2} \\right) \\Gamma(1 - s) \\zeta(1 - s)\n\\end{align*}\nRHS is defined for all \\(\\sigma < 0\\), so we define\n\\[\n  \\zeta(s) = 2^s \\pi^{s - 1} \\sin \\frac{s \\pi}{2} \\Gamma(1 - s) \\zeta(1 - s)\n\\]\nfor \\(\\sigma < 0\\). This gives an analytic continuation of \\(\\zeta(s)\\) to the negative half plane. Together with the integral expression for \\(\\sigma > -1\\), this gives a meromorphic zeta function on \\(\\C\\).\n\n\\begin{theorem}[functional equation]\n  For all \\(s \\in \\C\\),\n  \\[\n    \\zeta(s) = 2^s \\pi^{s - 1} \\sin \\left( \\frac{\\pi s}{2} \\right) \\Gamma(1 - s) \\zeta(1 - s).\n  \\]\n\\end{theorem}\n\nWe can poke around the equation and do some reality check:\n\\begin{itemize}\n\\item At \\(s = 1\\),\n  \\[\n    \\zeta(1) = 2 \\gamma(0) \\zeta(0)\n  \\]\n  and as \\(\\zeta(0) = -\\frac{1}{2}\\), \\(\\Gamma\\) has a pole at \\(0\\), this makes sense.\n\\item Does \\(\\zeta(s)\\) have any other poles? Since\n  \\[\n    \\zeta(s) = \\underbrace{2^s \\pi^{s - 1} \\sin \\left( \\frac{\\pi s}{2} \\right)}_{\\text{entire}} \\underbrace{\\Gamma(1 - s) \\zeta(1 - s)}_{\\text{entire for } \\sigma < 0}\n  \\]\n  \\(\\zeta(s)\\) is analytic everywhere in \\(\\C\\) except for a simple pole at \\(s = 1\\).\n\\item At \\(s = 2\\),\n  \\[\n    \\zeta(2) = 4 \\pi \\cdot 0 \\cdot \\Gamma(-1) \\zeta(-1).\n  \\]\n  The zero and pole of \\(\\Gamma\\) at \\(-1\\) cancels and we get a constant \\(\\frac{\\pi^2}{6}\\).\n\\item At \\(s = -1\\),\n  \\[\n    \\zeta(-1)\n    = \\frac{1}{2} \\cdot \\frac{1}{\\pi^2} \\cdot (-1) \\cdot \\Gamma(2) \\zeta(2)\n    = -\\frac{1}{12}.\n  \\]\n  Of course to physicists, this implies that\n  \\[\n    -\\frac{1}{12} = 1 + 2 + 3 + \\cdots\n  \\]\n\\end{itemize}\n\nWhat about zeros of zeta function? At a zero we have\n\\[\n  0 = \\zeta(s) = \\text{nonzero term} \\cdot \\sin \\left( \\frac{\\pi s}{2} \\right) \\Gamma(1 - s) \\zeta(1 - s).\n\\]\nIf \\(\\sigma < 1\\), \\(\\zeta(1 - s) \\neq 0, \\Gamma(1 - s) \\neq 0\\) except \\(s = -2n\\) where \\(n \\in \\N\\). This is a necessary and sufficient condition so \\(\\zeta(s)\\) has zeros at \\(-2, -4, \\cdots\\). We knew that \\(\\zeta(s)\\) has no zeros for \\(\\sigma \\geq 1\\) and \\(\\sigma = 0\\). Thus except for the trivial zeros, \\(\\zeta(s)\\) only has zeros in the critical strip \\(0 < \\sigma < 1\\).\n\nIn the region \\(0 < \\sigma < 1\\),\n\\[\n  0 = \\zeta(s) = \\text{nonzero term} \\cdot \\underbrace{\\Gamma(1 - s)}_{\\neq 0} \\zeta(1 - s)\n\\]\nso \\(\\zeta(1 - s) = 0\\). Also because \\(\\zeta(\\conj s) = \\conj{\\zeta(s)}\\), zeros appear in quadruples. The dream that they actually come in pairs leads to, of course, the Riemann hypothesis.\n\nNow we can fully justify \\cref{cor:RH equivalent to bound on PNT}, which states that Riemann hypothesis is equivalent to\n\\[\n  \\psi(x) = x + O(x^{1/2 + o(1)}).\n\\]\n\n\\begin{proof}\\leavevmode\n  \\begin{itemize}\n  \\item \\(\\implies\\): contour integration\n  \\item \\(\\impliedby\\): we know if \\(\\sigma_0 = \\sup \\{\\Re \\rho: \\zeta(\\rho) = 0\\}\\) then\n    \\[\n      \\psi(x) = x + \\Omega_\\pm (x^\\sigma)\n    \\]\n    for all \\(\\sigma < \\sigma_0\\). If Riemann hypothesis is false then there exists a zero \\(\\rho\\) with \\(0 < \\sigma < 1, \\sigma \\neq \\frac{1}{2}\\). By symmetry, we have\n    \\[\n      \\sigma_0 \\geq \\max (\\sigma, 1 - \\sigma) > \\frac{1}{2}\n    \\]\n    so\n    \\[\n      \\psi(x) = x + \\Omega_\\pm(x^{\\sigma'})\n    \\]\n    where \\(\\frac{1}{2} < \\sigma' < \\sigma\\).\n  \\end{itemize}\n\\end{proof}\n\n\\section{Primes in arithmetic progressions}\n\nIn this last chapter we will introduce Dirchlet characters and use them to prove Dirichlet's theorem, which says that any arithmetic progression satisfying obviously necessary conditions contains infinitely many primes.\n\n\\subsection{Dirichlet characters and \\(L\\)-functions}\n\n\\begin{definition}[Dirichlet character]\\index{Dirichlet character}\n  Fix \\(q \\in \\N\\). A \\emph{Dirichlet character} of modulus \\(q\\) is a group homomorphism \\(\\chi: (\\Z/q\\Z)^\\times \\to \\C^\\times\\).\n\\end{definition}\n\n\\((\\Z/q\\Z)^\\times\\) is a finite abelian group of order \\(\\phi(q)\\), so the set of Dirichlet characters of modulus \\(q\\) forms a finite abelian group of order \\(\\phi(q)\\).\n\nWe can also think of \\(\\chi\\) as defining a function \\(\\chi: \\Z \\to \\C\\), given by\n\\[\n  \\chi(a) =\n  \\begin{cases}\n    \\chi(a \\bmod q) & (a, q) = 1 \\\\\n    0 & \\text{otherwise}\n  \\end{cases}\n\\]\nNote that this \\(\\chi\\) is periodic with period \\(q\\) and is totally multiplicative.\n\nIf \\(\\chi\\) is the trivial homomorphism on \\((\\Z/q\\Z)^\\times\\), we call it the \\emph{principal Dirichlet character}\\index{Dirichlet character!principal} modulus \\(q\\) and usually denote it as \\(\\chi_0\\).\n\n\\begin{lemma}\\leavevmode\n  \\begin{enumerate}\n  \\item Let \\(\\chi\\) be a Dirichlet character of modulus \\(q\\). Then\n    \\[\n      \\sum_{a \\in (\\Z/q\\Z)^\\times} \\chi(a)\n      = \\sum_{1 \\leq a \\leq q} \\chi(a)\n      =\n      \\begin{cases}\n        \\phi(q) & \\chi = \\chi_0 \\\\\n        0 & \\chi \\neq \\chi_0\n      \\end{cases}\n    \\]\n  \\item Let \\(a \\in (\\Z/q\\Z)^\\times\\). Then\n    \\[\n      \\sum_\\chi \\chi(a) =\n      \\begin{cases}\n        \\phi(q) & q = 1 \\bmod q \\\\\n        0 & a \\neq 1 \\bmod q\n      \\end{cases}\n    \\]\n  \\end{enumerate}\n\\end{lemma}\nFor those of you familiar with representation theory, this is the row and column orthogonality for character table of the abelian group \\((\\Z/q\\Z)^\\times\\).\n\n\\begin{proof}\n  We treat 2. If \\(a = 1 \\bmod q\\) then \\(\\chi(a) = 1\\) for all \\(\\chi\\) so\n  \\[\n    \\sum_\\chi \\chi(a) = \\sum_\\chi 1 = \\phi(q).\n  \\]\n  If \\(q \\neq 1 \\bmod q\\) then there exists \\(\\psi: (\\Z/q\\Z)^\\times \\to \\C^\\times\\) such that \\(\\psi(a) \\neq 1\\). The map \\(\\chi \\mapsto \\chi \\psi\\) is a permutation of the set of Dirichlet characters mod \\(q\\). Hence\n  \\[\n    \\sum_\\chi \\chi(a)\n    = \\sum_\\chi (\\chi \\psi) (a)\n    = \\psi(a) \\sum_\\chi \\chi(a)\n  \\]\n  so \\(\\sum_\\chi \\chi(a) = 0\\).\n\\end{proof}\n\nLet \\(a \\in \\Z, (a, q) = 1\\). Consider \\(1_{x = a \\bmod q}: \\Z \\to \\C\\). The the lemma says that\n\\[\n  1_{x = a \\bmod q} (x) = \\frac{1}{\\phi(q)} \\sum_\\chi \\chi(a)^{-1} \\chi(x).\n\\]\nIt follows that\n\\[\n  \\sum_{\\substack{p \\leq x \\\\ p = a \\bmod q}} 1\n  = \\sum_{p \\leq x} 1_{x = a \\bmod q}(p)\n  = \\frac{1}{\\phi(q)} \\sum_{p \\leq x} \\sum_\\chi \\chi(a)^{-1} \\chi(p).\n\\]\nEstimating this is closely related to estimating \n\\[\n  \\frac{1}{\\phi(q)} \\sum_{n \\leq x} \\sum_\\chi \\chi(a)^{-1} \\chi(n) \\Lambda(n)\n  = \\sum_\\chi \\frac{\\chi(a)^{-1}}{\\phi(q)} \\sum_{n \\leq x} \\chi(n) \\Lambda(n).\n\\]\nThe strategy to prove Dirichlet's theorem is to consider the contribution of each character \\(\\chi\\) separately. We will do this using the \\emph{Dirichlet \\(L\\)-function}\\index{Dirichlet \\(L\\)-function}\n\\[\n  L(s, \\chi) = \\sum_{n \\geq 1} \\chi(n) n^{-s}.\n\\]\nThis series converges absolutely in the region \\(\\sigma > 1\\) and defines an analytic function there.\n\n\\begin{lemma}\n  If \\(\\chi \\neq \\chi_0\\) then \\(\\sum_{n \\geq 1} \\chi(n) n^{-s}\\) converges in \\(\\sigma > 0\\).\n\\end{lemma}\n\n\\begin{proof}\n  Use partial summmation,\n  \\[\n    \\sum_{n \\leq x} \\chi(n) n^{-s} = A(x) x^{-s} - \\int_1^x A(t) f'(t) dt\n  \\]\n  where \\(A(x) = \\sum_{n \\leq x} \\chi(n)\\). Note that by the lemma \\(\\sum_{1 \\leq n \\leq q} \\chi(n) = 0\\) as \\(\\chi \\neq \\chi_0\\). Hence \\(A(n)\\) is periodic and \\(|A(x)| \\leq \\phi(q)\\) for all \\(x\\). Thus \\(|A(x)x^{-s}| \\leq \\phi(q) x^{-\\sigma}\\) and the integral is absolutely convergent.\n\\end{proof}\nThus \\(L(s, \\chi)\\) is analytic in the same region and in particular does not have a pole at \\(s = 1\\).\n\nSince \\(\\chi(n)\\) is multiplicative, we have an Euler product identity\\index{Euler product}\n\\[\n  L(s, \\chi) = \\prod_p (1 - \\chi(p) p^{-s})^{-1}\n\\]\nvalid in the region \\(\\sigma > 1\\). This implies that when \\(\\chi = \\chi_0\\),\n\\[\n  L(s, \\chi_0) = \\zeta(s) \\prod_{p \\divides q} (1 - p^{-s})\n\\]\nso \\(L(s, \\chi_0)\\) has a meromorphic continuation to all \\(s \\in \\C\\) and a simple pole at \\(s = 1\\). We can show that\n\\[\n  \\log L(s, \\chi) = \\sum_p \\sum_{k \\geq 1} \\chi(p)^k p^{-ks}/k\n\\]\nand hence\n\\[\n  \\frac{L'}{L}(s, \\chi)\n  = \\sum_p \\sum_{k \\geq 1} \\chi(p)^k (-\\log p) p^{-s}\n  = -\\sum_{n \\geq 1} \\chi(n) \\Lambda(n) n^{-s}\n\\]\nvalid in \\(\\sigma > 1\\).\n\nFix \\(a \\in \\N, (a, q) = 1\\). We combine this with the identity valid for any \\(n \\in \\N\\)\n\\[\n  1_{n = a \\bmod q} (n) = \\frac{1}{\\phi(q)} \\sum_\\chi \\chi(a^{-1})\\chi(n)\n\\]\nwe get\n\\[\n  \\sum_{n \\geq 1} 1_{n = a \\bmod q}(n)  \\Lambda(n)n^{-s}\n  = - \\frac{1}{\\phi(q)} \\sum_\\chi \\chi(a^{-1}) \\frac{L'(s, \\chi)}{L(s, \\chi)}\n\\]\nagain valid in \\(\\sigma > 1\\).\n\n\\subsection{Dirichlet's theorem}\n\n\\begin{theorem}\n  Given \\(q \\in \\N, (a, q) = 1\\), there are infinitely many primes \\(p\\) such that \\(p = a \\bmod q\\).\n\\end{theorem}\n\nAs \\(L(s, \\chi_0)\\) has a simple pole at \\(s = 1\\), we can write\n\\[\n  \\sum_{n \\geq 1} 1_{n = a \\bmod q} (n) \\Lambda(n) n^{-s}\n  = \\frac{1}{\\phi(q)} \\frac{1}{s - 1} + O(1) - \\frac{1}{\\phi(q)} \\sum_{\\chi \\neq \\chi_0} \\chi(a^{-1}) \\frac{L'(s, \\chi)}{L(s, \\chi)}.\n\\]\nAssume the unknown term is convergent, so RHS has a pole at \\(s = 1\\) so diverges there. If there were finitely many prime \\(p = a \\bmod q\\), LHS would be bounded as \\(s \\to 1\\), absurd. Thus to show Dirichlet's theorem it is enough to show that for all \\(\\chi \\neq \\chi_0\\), \\(\\frac{L'}{L} (s, \\chi)\\) is analytic at \\(s = 1\\). This is equivalent to show that if \\(\\chi \\neq \\chi_0\\) then \\(L(1, \\chi) \\neq 0\\).\n\n\\begin{theorem}\n  If \\(\\chi \\neq \\chi_0\\) then \\(L(1, \\chi) \\neq 0\\).\n\\end{theorem}\n\n\\begin{proof}\n  In \\(\\sigma > 1\\), by choosing a branch of logarithm\n  \\begin{align*}\n    \\prod_\\chi L(s, \\chi)\n    &= \\exp \\sum_\\chi \\log L(s, \\chi) \\\\\n    &= \\exp \\sum_\\chi \\sum_p \\sum_{k \\geq 1} \\chi(p)^k p^{-ks}/k \\\\\n    &= \\exp \\sum_\\chi \\sum_{n \\geq 1} \\frac{\\chi(n) n^{-s} \\Lambda(n)}{\\log n} \\\\\n    &= \\exp \\sum_{n \\geq 1} \\frac{n^{-s} \\Lambda(n)}{\\log n} \\sum_\\chi \\chi(n) \\quad \\text{absolute convergence}\n  \\end{align*}\n  We have\n  \\[\n    \\sum_\\chi \\chi(n) =\n    \\begin{cases}\n      0 & (q, n) > 1 \\text{ or } (q, n) = 1 \\text{ and } n \\neq 1 \\bmod q \\\\\n      \\phi(q) & n = 1 \\bmod q\n    \\end{cases}\n  \\]\n  so\n  \\[\n    \\prod_\\chi L(s, \\chi)\n    = \\exp \\sum_{\\substack{n \\geq 1 \\\\ n = 1 \\bmod q}} \\frac{n^{-s} \\Lambda(n)}{\\log n} \\phi(q)\n  \\]\n  valid in \\(\\sigma > 1\\). For \\(s\\) real, \\(s > 1\\), the exponent is a non-negative real numbur. Thus for \\(s \\in (1, \\infty)\\),\n  \\[\n    \\prod_\\chi L(s, \\chi) \\in [1, \\infty).\n  \\]\n  Note that \\(L(s, \\chi_0)\\) has a simple pole at \\(s = 1\\). If there are at least two distinct characters \\(\\psi, \\psi'\\) of modulus \\(q\\) such that \\(L(1, \\psi) = L(1, \\psi') = 0\\) then \\(\\prod_\\chi L(s, \\chi)\\) would be analytic in a neighbourhood of \\(s = 1\\), and vanish at \\(s = 1\\). This cannot happen so there is at most one character \\(\\psi\\) such that \\(L(1, \\psi) = 0\\).\n\n  Note also that for any \\(\\chi\\),\n  \\[\n    L(1, \\conj \\chi) = \\conj{L(1, \\chi)}.\n  \\]\n  If \\(L(1, \\chi) = 0\\) then \\(L(1, \\conj \\chi) = 0\\). Hence if \\(L(1, \\chi) = 0\\) then \\(\\chi = \\conj \\chi\\). In other words, \\(\\chi\\) takes values in \\(\\{\\pm 1\\}\\). We call such characters \\emph{quadratic}\\index{Dirichlet character!quadratic},\n\n  Suppose for contradiction there exists a non-principal quadratic character \\(\\psi: (\\Z/q\\Z)^\\times \\to \\{\\pm 1\\}\\) such that \\(L(1, \\psi) = 0\\). We consider the product \\(L(s, \\psi) \\zeta(s)\\). This function is analytic in \\(\\sigma > 0\\). In \\(\\sigma > 1\\) we have the expressoin\n  \\[\n    L(s, \\psi) \\zeta(s)\n    = \\left( \\sum_{n \\geq 1} \\psi(n) n^{-s} \\right) \\left( \\sum_{n \\geq 1} n^{-s} \\right)\n    = \\sum_{n \\geq 1} r(n) n^{-s}\n  \\]\n  where \\(r(n) = \\sum_{d \\divides n} \\psi(d)\\). Note that \\(r(n)\\) is multiplicative and \\(r(n) \\geq 0\\):\n  \\[\n    r(p^k) = \\psi(1) + \\psi(p) + \\dots + \\psi(p^k) =\n    \\begin{cases}\n      k + 1 & \\psi(p) = 1 \\\\\n      1 & \\psi(p) = 0 \\text{ or } \\psi(p) = -1, k \\text{ is even} \\\\\n      0 & \\psi(p) = -1, k \\text{ is odd}\n    \\end{cases}\n  \\]\n  Note also that \\(r(n^2) \\geq 1\\) by the same argument.\n\n  We now use Landau's lemma\n  \\begin{lemma}\n    Let \\(f(s) = \\sum_{n \\geq 1} a_n n^{-s}\\) where \\(a_n\\) are non-negative real numbers. Suppose given \\(\\sigma_0 \\in \\R\\) such that \\(f(s)\\) is convergent in \\(\\sigma > \\sigma_0\\). Suppose that \\(f(s)\\) admits an analytic continuation to the disk \\(\\{|s - \\sigma_0| < \\varepsilon\\}\\). Then \\(f(s)\\) is convergent in \\(\\sigma > \\sigma_0 - \\varepsilon\\).\n  \\end{lemma}\n  Let\n  \\[\n    f(s) = L(\\psi, s) \\zeta(s) = \\sum_{n \\geq 1} r(n)n^{-s},\n  \\]\n  valid in \\(\\sigma > 1\\). Then we can use Landau's lemma, together with the fact that \\(f(s)\\) is analytic in \\(\\sigma > 0\\), to conclude that \\(f(s)\\) is convergent in \\(\\sigma > 0\\). But\n  \\[\n    f\\left(\\frac{1}{2}\\right)\n    = \\sum_{n \\geq 1} r(n) n^{-1/2} \\geq \\sum_{n \\geq 1} r(n^2)/n \n    \\geq \\sum_{n \\geq 1} \\frac{1}{n}\n  \\]\n  and this series diverges, absurd. Thus \\(L(1, \\psi) \\neq 0\\).\n\\end{proof}\n\n\\subsection{Zero-free region}\n\nWe have proved there are infinitely many primes congruent to \\(a\\) mod \\(q\\) if \\((a, q) = 1\\), using\n\\[\n  -\\frac{L'}{L}(s, \\chi) = \\sum_n \\frac{\\Lambda(n) \\chi(n)}{n^s}.\n\\]\nWe want to prove a prime number theorem for such primes. To do this, we'll use Perron's formula just as the case for Riemann zeta function. We need more information about the zeros of \\(L(s, \\chi)\\). (roughly speaking \\(L(1, \\chi) \\neq 0\\) is the statement there are infinitely many primes. Specialising to \\(\\chi = 1\\) (Riemann zeta function) we get a pole so it is particularly easy to prove there are infinitely many primes).\n\nSimilarities to zero-free region for \\(\\zeta(s)\\), but important difference: \\(\\zeta(s)\\) has a pole at \\(s = 1\\), while \\(L(s, \\chi)\\) has \\emph{no} poles for \\(\\sigma > 0\\) for \\(\\chi \\neq \\chi_0\\).\n\nSome shorthands: let \\(\\tau = |t| + 4\\). Recall\n\\begin{lemma}\n  If \\(f(z)\\) is analytic on a region containing \\(|z| \\leq 1\\) and \\(f(0) \\neq 0\\) and \\(|f(z)| \\leq M\\) for \\(|z| \\leq 1\\), then for \\(0 < r < R < 1\\), for \\(|z| \\leq r\\),\n  \\[\n    \\frac{f'}{f}(z) = \\sum \\frac{1}{z - z_k} + O(\\log \\frac{M}{|f(0)|})\n  \\]\n  where \\(z_k\\) ranges over zeros of \\(f\\) in \\(|z| \\leq R\\).\n\\end{lemma}\n\n\\begin{lemma}\n  If \\(\\chi \\neq \\chi_0\\) and \\(\\frac{5}{6} \\leq \\sigma \\leq 2\\) then\n  \\[\n    \\frac{L'}{L}(s, \\chi) = \\sum_\\rho \\frac{1}{s - \\rho} + O(\\log qt)\n  \\]\n  over \\(\\rho\\) with \\(|\\rho - (\\frac{3}{2} + it)| \\leq \\frac{5}{6}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Follows from the lemma with \\(f(z) = L(z + \\frac{3}{2} + it, \\chi), R = \\frac{5}{6}, r = \\frac{2}{3}\\). Verify that\n  \\[\n    |f(0)|\n    = |L(\\frac{3}{2} + it, \\chi)|\n    = \\prod_p \\left| 1 - \\frac{\\chi(p)}{p^{3/2 + it}} \\right|\n    \\geq \\prod_p \\left( 1+ \\frac{1}{p^{3/2}} \\right)^{-1}\n    \\gg 1.\n  \\]\n  By partial summation, if \\(F(t) = \\sum_{1 \\leq n \\leq t} \\chi(n)\\) for \\(\\sigma > 0\\) then\n  \\[\n    L(s, \\chi) = s\\int_1^\\infty \\frac{F(t)}{t^{s + 1}} \\d t\n  \\]\n  so\n  \\[\n    |L(s, \\chi)|\n    \\ll |s| q \\int_1^\\infty \\frac{1}{t^{\\sigma + 1}} \\d t\n    \\ll q \\tau.\n  \\]\n\\end{proof}\n\n\\begin{theorem}\n  Let \\(\\chi\\) be a non-quadratic character\\index{Dirichlet character!quadratic}. Then there is an absolute constant \\(c > 0\\)  such that \\(L(s, \\chi) \\neq 0\\) if \\(\\sigma > 1 - \\frac{c}{\\log (q\\tau)}\\)\n\\end{theorem}\n\n\\begin{proof}\n  Since\n  \\[\n    L(s, \\chi_0) = \\zeta(s) \\prod_{p \\divides q} (1 - p^{-s}),\n  \\]\n  in this region \\(\\sigma > 0\\), zeroes of \\(L(s, \\chi_0)\\) are the same as those of \\(\\zeta(s)\\) so done.\n\n  Suppose \\(\\chi\\) is non-principal. Let \\(\\rho = \\sigma + it\\) be such that \\(L(\\rho, \\chi) = 0\\). The idea is to compare\n  \\[\n    \\frac{L'}{L}(1 + \\delta + it, \\chi),\n    \\frac{L'}{L}(1 + \\delta + 2it, \\chi^2),\n    \\frac{L'}{L}(1 + \\delta, \\chi_0)\n  \\]\n  as \\(\\delta \\to 0\\). Note that\n  \\begin{align*}\n    &\\Re(-3 \\frac{L'}{L}(1 + \\delta, \\chi_0) - 4 \\frac{L'}{L}(1 + \\delta + it, \\chi) - \\frac{L'}{L}(1 + \\delta + 2it, \\chi^2)) \\\\\n    =& \\sum_{\\substack{n \\geq 1 \\\\ (n, q) = 1}} \\frac{\\Lambda(n)}{n^{1 + \\delta}} \\Re(3 + 4 \\chi(n) n^{-it} + \\chi(n)^2 n^{-2it})\n  \\end{align*}\n  and for all \\(\\theta\\),\n  \\[\n    3 + 4 \\cos \\theta + \\cos 2\\theta = \\Re (3 + 4e^{i\\theta} + e^{i2\\theta}) \\geq 0.\n  \\]\n  By the lemma,\n  \\begin{align*}\n    -\\Re \\frac{L'}{L}(1 + \\delta, \\chi_0) &= \\frac{1}{\\delta} + O(\\log q) \\\\\n    -\\Re \\frac{L'}{L}(1 + \\delta + it, \\chi) &\\leq - \\frac{1}{1 + \\delta - \\sigma} + O(\\log q\\tau) \\\\\n    \\Re \\frac{L'}{L}(1 + \\delta + 2it, \\chi^2) &\\ll \\log(q\\tau)\n  \\end{align*}\n  Note that the last step depends crucially on \\(\\chi\\) being non-quadratic so that \\(\\chi^2 \\neq \\chi_0\\). Thus\n  \\[\n    \\frac{3}{\\delta} - \\frac{4}{1 + \\delta - \\sigma} + O(\\log q\\tau) \\geq 0,\n  \\]\n  contradiction if \\(\\delta \\approx \\frac{c'}{\\log q\\tau}\\) and \\(\\sigma \\geq 1 - \\frac{c}{\\log q\\tau}\\).\n\\end{proof}\n\n\\begin{theorem}\n  \\label{thm:zero-free region of quadratic character}\n  If \\(\\chi\\) is a quadratic character, there exists \\(c > 0\\) such that \\(L(s, \\chi) \\neq 0\\) if \\(\\sigma > 1 - \\frac{c}{\\log q\\tau}\\) and \\(t \\neq 0\\).\n\\end{theorem}\nIn other words, we \\emph{cannot} rule out a zero \\(\\rho\\) of \\(L(s, \\chi)\\) with \\(\\rho \\in \\R\\) close to \\(1\\). However,\n\n\\begin{theorem}\n  \\label{thm:zero of non-quadratic character}\n  Let \\(\\chi\\) be a quadratic character. Then there is an absolute constant \\(c > 0\\) such that \\(L(s, \\chi)\\) has at most one zero \\(\\rho \\in (0, 1)\\) such that \\(\\rho \\geq 1 - \\frac{c}{\\log q}\\).\n\\end{theorem}\nThese are called \\emph{exceptional zeroes} or \\emph{Siegel zeroes}\\index{Siegel zeroes}.\n\nFirst we need a lemma for \\(L(s, \\chi_0)\\).\n\\begin{lemma}\n  If \\(\\frac{5}{6} \\leq \\sigma \\leq 2\\) then\n  \\[\n    -\\frac{L'}{L}(s, \\chi_0) = \\frac{1}{s - 1} - \\sum_\\rho \\frac{1}{s - \\rho} + O(\\log q \\tau)\n  \\]\n  over zeroes \\(\\rho\\) with \\(|\\rho - (\\frac{3}{2} + it)| \\leq \\frac{5}{6}\\).\n\\end{lemma}\n\n\\begin{proof}\n  Follows from\n  \\[\n    -\\frac{\\zeta'}{\\zeta}(s) = - \\sum_\\rho \\frac{1}{s - \\rho} + O(\\log \\tau) + \\frac{1}{s - 1}\n  \\]\n  since\n  \\begin{enumerate}\n  \\item \\(\\sigma > 0\\), zeroes of \\(\\zeta(s)\\) is the same as zeroes of \\(L(s, \\chi_0)\\), and\n  \\item by the Euler product,\n    \\[\n      \\frac{L'}{L}(s, \\chi_0)\n      = \\frac{\\zeta'}{\\zeta}(s) + \\sum_{p \\divides q} \\frac{\\log p}{p^s - 1}\n      \\ll \\omega(q)\n      \\ll \\log q\n    \\]\n  \\end{enumerate}\n\\end{proof}\n\nQuick sketch of proof:\n\\begin{enumerate}\n\\item theorem 1: for \\(t\\) large, same as previous proof (\\(\\chi^2 = \\chi_0\\) but no pole). For \\(t\\) small, \\(0 < |t| \\ll \\frac{1}{\\log q\\tau}\\). Instead of comparing \\(\\chi_0, \\chi, \\chi^2\\) we compare \\(\\rho\\) and \\(\\conj \\rho\\).\n\\item theorem 2: compare two such real zeroes.\n\\end{enumerate}\n\n\\begin{proof}[Proof of \\Cref{thm:zero-free region of quadratic character}]\n  As before let \\(\\rho = \\sigma + it\\) be a zero of \\(L(s, \\chi)\\). Let \\(\\delta > 0\\). Then by lemma 1 (expansion of \\(L\\)-function for non-principal character)\n  \\[\n    -\\frac{L'}{L}(1 + \\delta + it, \\chi) = - \\sum_{\\rho'} \\frac{1}{1 + \\delta + it - \\rho'} + O(\\log q\\tau)\n  \\]\n  so\n  \\begin{align*}\n    -\\Re \\frac{L'}{L} (1 + \\delta + it, \\chi)\n    &\\leq - \\frac{1}{1 + \\delta + it - \\rho} + O(\\log q\\tau) \\\\\n    &= - \\frac{1}{1 + \\delta - \\sigma} + O(\\log q\\tau)\n  \\end{align*}\n  Also by lemma 2 (expansion of \\(L\\)-function for principal character)\n  \\[\n    -\\Re \\frac{L'}{L} (1 + \\delta, \\chi_0) \\leq \\frac{1}{\\delta} + O(\\log q\\tau).\n  \\]\n\n  First suppose \\(\\tau \\geq C(1 - \\sigma)\\). Here\n  \\begin{align*}\n    -Re \\frac{L'}{L} (1 + \\delta + 2it, \\chi^2)\n    &= -\\Re \\frac{L'}{L}(1 + \\delta + 2it, \\chi_0) \\\\\n    &\\leq \\Re \\frac{1}{\\delta + 2it} + O(\\log q\\tau) \\\\\n    &\\leq \\frac{\\delta}{\\delta^2 + 4t^2} + O(\\log q\\tau)\n  \\end{align*}\n  As before,\n  \\[\n    \\Re(-3 \\frac{L'}{L} (1 + \\delta, \\chi_0) - 4 \\frac{L'}{L} (1 + \\delta + it, \\chi) - \\frac{L'}{L} (1 + \\delta + 2it, \\chi^2))\n  \\]\n  But\n  \\[\n    LHS \\leq \\frac{3}{\\delta} - \\frac{4}{1 + \\delta - \\sigma} + \\frac{\\delta}{\\delta^2 + 4t^2} + O(\\log q\\tau).\n  \\]\n  If \\(\\sigma = 1\\) then contradiction as \\(\\delta \\to 0\\).\n\n  For \\(\\sigma \\neq 1\\), if we chhose \\(\\delta = 1 - \\sigma\\), then this is (\\(\\tau \\gg 1 - \\sigma \\gg \\delta\\))\n  \\[\n    0 \\leq \\frac{3}{c(1 - \\sigma)} - \\frac{4}{(c + 1)(1 - \\sigma)} + \\frac{c'}{1 - \\sigma} + O(\\log q\\tau).\n  \\]\n  Can choose \\(c, C\\), hence \\(c'\\) such that this is \\(\\leq - \\frac{c''}{1 - \\sigma} + O(\\log q\\tau)\\) and so \\(\\sigma \\leq 1 - \\frac{c'''}{\\log q\\tau}\\).\n\n  For small \\(\\tau\\) we need a distinct argument. Since \\(L(\\rho, \\chi = L(\\conj \\rho, \\chi) = 0\\), it follows that\n  \\[\n    -\\Re \\frac{L'}{L}(1 + \\delta + it, \\chi)\n    \\leq -\\Re \\frac{1}{1 + \\delta - \\rho} - \\Re \\frac{1}{1 + \\delta - \\conj \\rho} + O(\\log q\\tau)\n  \\]\n  (assuming that \\(|t| \\leq c(1 - \\sigma)\\), in particular \\( |t| \\leq c'\\) for some small constant, so both \\(\\rho\\) and \\(\\rho'\\) are both picked up) RHS is\n  \\[\n    \\frac{-2(1 + \\delta - \\sigma)}{(1 + \\delta - \\sigma)^2 + t^2} + O(\\log q\\tau).\n  \\]\n  As before\n  \\[\n    - \\frac{L'}{L}(1 + \\delta, \\chi_0) \\leq \\frac{1}{\\delta} + O(\\log q\\tau).\n  \\]\n  Now\n  \\begin{align*}\n    &\\quad -\\Re \\frac{L'}{L}(1 + \\delta, \\chi_0) - \\Re \\frac{L'}{L} (1 + \\delta + it, \\chi) \\\\\n    &= \\sum_{\\substack{n \\geq 1 \\\\ (n, q) = 1}} \\frac{\\Lambda(n)}{n^{1 + \\delta}} (1 + \\Re (\\underbrace{\\chi(n) n^{it}}_{|z| = 1})) \\\\\n    &\\geq 0\n  \\end{align*}\n  so putting these together,\n  \\[\n    \\frac{1}{\\delta} - \\frac{2 (1 + \\delta - \\sigma)}{(1 + \\delta - \\sigma)^2 + t^2} + O(\\log q\\tau) \\geq 0.\n  \\]\n  If we choose \\(\\delta = c(1 - \\sigma)\\), LHS is \\(\\leq - \\frac{c'}{1 - \\sigma} + O(\\log q\\tau)\\) so \\(\\sigma \\leq 1 - \\frac{c''}{\\log q\\tau}\\).\n\\end{proof}\n\n\\begin{proof}[Proof of \\Cref{thm:zero of non-quadratic character}]\n  Suppose \\(\\rho_0 < \\rho_1 \\leq 1\\) are zeroes of \\(L(s, \\chi)\\). Then for \\(\\sigma \\in (0, 1)\\)\n  \\begin{align*}\n    -\\Re \\frac{L'}{L}(\\sigma, \\chi)\n    &\\leq -\\Re \\frac{1}{\\sigma - \\rho_0} - \\Re \\frac{1}{\\sigma - \\rho_1} + O(\\log q) \\quad \\text{for \\(\\sigma \\geq 1 - 10^{-6}\\), say} \\\\\n    &\\leq - \\frac{2}{\\sigma - \\rho_0} + O(\\log q)\n  \\end{align*}\n  so\n  \\[\n    \\frac{1}{\\sigma - 1} - \\frac{2}{\\sigma - \\rho_0} + O(\\log q)\n    \\geq - \\Re \\frac{L'}{L}(\\sigma, \\chi_0) - \\Re \\frac{L'}{L}(\\sigma, \\chi)\n    \\geq 0.\n  \\]\n  Hence \\(\\rho_0 < 1 - \\frac{c}{\\log q}\\).\n\\end{proof}\n\n\\begin{lemma}\n  If \\(\\chi \\neq \\chi_0\\) and \\(\\sigma \\geq 1 - \\frac{c}{\\log q\\tau}\\) (some absolute \\(c > 0\\)) then\n  \\begin{itemize}\n  \\item either \\(\\chi\\) has no exceptional zero,\n  \\item or \\(\\chi\\) has an exceptional zero at \\(\\beta\\). But \\(|s - \\beta| \\geq \\frac{1}{\\log q}\\) so\n    \\[\n      \\frac{L'}{L}(s, \\chi) \\ll \\log q\\tau.\n    \\]\n  \\end{itemize}\n\\end{lemma}\n\n\\begin{proof}\n  If \\(\\sigma > 1\\), note\n  \\[\n    \\left|\\frac{L'}{L(s, \\chi)} \\right|\\leq \\sum_{\\substack{n \\geq 1 \\\\ (n, q) = 1}} \\frac{\\Lambda(n)}{n^\\sigma} \\ll \\frac{1}{\\sigma - 1}.\n    \\]\n    In particular, if \\(s = \\sigma + it\\) and \\(s_1 = 1 + \\frac{1}{\\log q\\tau} + it\\),\n    \\[\n      \\left|\\frac{L'}{L}(s_1, \\chi)\\right| \\ll \\log q\\tau.\n    \\]\n    By lemma 1,\n    \\[\n      \\frac{L'}{L}(s, \\chi) = \\sum_\\rho \\frac{1}{s - \\rho} + O(\\log q\\tau)\n    \\]\n    for all zeroes \\(\\rho\\). \\(|s - \\rho| \\asymp |s_1 - \\rho|\\) so\n    \\begin{align*}\n      \\left| \\frac{L'}{L}(s, \\chi) - \\frac{L'}{L}(s, \\chi)\\right|\n      &\\ll \\left| \\sum_\\rho \\frac{1}{s - \\rho} - \\frac{1}{s_1 - \\rho} \\right| + O(\\log q\\tau) \\\\\n      &\\ll \\Re \\sum_\\rho \\frac{1}{s_1 - \\rho} + O(\\log q\\tau) \\\\\n      &\\ll \\log q\\tau\n    \\end{align*}\n\\end{proof}\n\n\\begin{theorem}\n  If \\(\\chi_1, \\chi_2\\) are distinct quadratic characters modulo \\(q\\) then \\(L(s, \\chi_1) L(s, \\chi_2)\\) has at most one real zero \\(\\beta\\) with \\(1 - \\frac{c}{\\log q} < \\beta < 1\\).\n\\end{theorem}\nThis justifies ``the exceptional zero of \\(q\\)''.\n\n\\begin{proof}\n  Say \\(\\beta_i\\) is a real zero of \\(L(s, \\chi_i\\) for \\(i = 1, 2\\). wlog \\(\\frac{5}{6} \\leq \\beta_1 \\leq \\beta_2 < 1\\). Fix \\(\\delta > 0\\).\n  \\begin{enumerate}\n  \\item \\(- \\Re \\frac{L'}{L}(1 + \\delta, \\chi_i) = - \\frac{1}{1 + \\delta - \\beta_i} + O(\\log q)\\), \\(i = 1, 2\\).\n  \\item \\(- \\Re \\frac{L'}{L}(1 + \\delta, \\chi_1 \\chi_2) \\leq O(\\log q)\\). Here we used \\(\\chi_1 \\chi_2 \\neq \\chi_0\\).\n  \\item \\(- \\frac{\\zeta'}{\\zeta}(1 + \\delta) \\leq \\frac{1}{\\delta} + O(1)\\) (or equivalently using \\(-\\Re \\frac{L'}{L}(1 + \\delta, \\chi_0)\\)).\n  \\end{enumerate}\n  Therefore\n  \\begin{align*}\n    &\\quad \\sum \\frac{\\Lambda(n)}{n^{1 + \\delta}} \\Re(1 + \\chi_1(n) + \\chi_2(n) + \\chi_1\\chi_2(n)) \\\\\n    &= - \\frac{\\zeta'}{\\zeta}(1 + \\delta) - \\frac{L'}{L}(1 + \\delta, \\chi_1) - \\frac{L'}{L}(1 + \\delta, \\chi_2) - \\frac{L'}{L}(1 + \\delta, \\chi_1\\chi_2) \\\\\n    &\\leq \\frac{1}{\\delta} - \\frac{2}{1 + \\delta - \\beta_1} + O(\\log q)\n  \\end{align*}\n  Choose \\(\\delta = c(1 - \\beta_1)\\), and therefore \\(\\beta_1 \\leq 1 - \\frac{c}{\\log q}\\).\n\\end{proof}\n\n\\subsection{Prime number theorem for arithmetric progressions}\n\nRecall that\n\\[\n  \\sum_{\\substack{1 \\leq n \\leq x \\\\ n = a \\bmod q}} \\Lambda(n)\n  = \\frac{1}{\\varphi(q)} \\sum_\\chi \\conj{\\chi(a)} \\sum_{1 \\leq n \\leq x} \\Lambda(n) \\chi(n)\n  = \\frac{1}{\\varphi(q)} \\sum_\\chi \\conj{\\chi(a)} \\psi(x, \\chi)\n\\]\n\n\\begin{theorem}\n  If \\(q \\leq \\exp(O(\\sqrt{\\log x}))\\) then\n  \\begin{enumerate}\n  \\item \\(\\psi(x, \\chi_0) = x + O(x \\exp(-c \\sqrt{\\log x}))\\).\n  \\item If \\(\\chi \\neq \\chi_0\\) and \\(\\chi\\) has no exceptional zero then\n    \\[\n      \\psi(x, \\chi) = O(x \\exp(-c \\sqrt{\\log x})).\n    \\]\n  \\item If \\(\\chi \\neq \\chi_0\\) and \\(\\chi\\) has an exceptional zero at \\(\\beta\\) then\n    \\[\n      \\psi(x, \\chi) = - \\frac{x^\\beta}{\\beta} + O(x \\exp(-c \\sqrt{\\log x})).\n    \\]\n  \\end{enumerate}\n\\end{theorem}\n\nRecall that\n\\[\n  1_{n = a \\bmod q} = \\frac{1}{\\varphi(q)} \\sum_\\chi \\conj{\\chi(a)} \\chi(n)\n\\]\nso\n\\[\n  \\chi(x; q, a) = \\sum_{\\substack{n \\leq x \\\\ n = a \\bmod q}} \\Lambda(n) = \\frac{1}{\\varphi(q)} \\sum_\\chi \\conj{\\chi(a)} \\psi(x, \\chi).\n\\]\n\n\\begin{corollary}\n  If \\((a, q) = 1\\), \\(q \\leq \\exp (O(\\sqrt{\\log x}))\\) then if \\(q\\) has no exceptional zero then\n  \\[\n    \\psi(x; q, a) = \\frac{x}{\\varphi(q)} + O(x \\exp (-c \\sqrt{\\log x})),\n  \\]\n  and if \\(q\\) has an exceptional zero at \\(\\beta\\) and \\(\\chi_1\\) then\n  \\[\n    \\psi(x; q, a) = \\frac{x}{\\varphi(q)} - \\frac{\\chi_1(a)}{\\varphi(q)} \\frac{x^\\beta}{\\beta} + O(x \\exp(-c \\sqrt{\\log x})).\n  \\]\n\\end{corollary}\n\n\\begin{proof}\n  We give a sketch as the proof is similar to that of zeta function. By Perron's formula (given \\(\\sigma_0 > 1\\), \\(T \\geq 1\\)),\n  \\[\n    \\psi(x, \\chi) = -\\frac{1}{2\\pi i} \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} \\frac{L'}{L}(s, \\chi) \\frac{x^s}{s} \\d s + O(\\frac{x}{T} \\sum_{\\frac{x}{2} < n < 2x} \\frac{\\Lambda(n)}{|x - n|} + \\frac{x}{T} \\sum_{n \\geq 1} \\frac{\\Lambda(n)}{\\sigma^{\\sigma_0}}).\n  \\]\n  By the same argument as for \\(\\zeta(s)\\), the error term is \\(\\ll \\frac{x(\\log x)^2}{T}\\) (choosing \\(\\sigma_0 = 1 + \\frac{1}{\\log x}\\)). Take \\(C\\) to be the rectangular contour with corners at \\(\\sigma_0 \\pm iT, \\sigma_1 \\pm iT\\). So\n  \\[\n    \\psi(x, \\chi) = \\frac{1}{2\\pi i} \\int_C + O(\\int_{\\sigma_1 \\pm iT} + \\int_{\\sigma_0 + iT}^{\\sigma_1 + iT} + \\int_{\\sigma_0 - iT}^{\\sigma_0 + iT} + \\frac{x (\\log x)^2}{T})\n  \\]\n  Error terms are bound as for \\(\\zeta(s)\\), so in total,\n  \\[\n    \\psi(x, \\chi) = - \\frac{1}{2\\pi i} \\int_C \\frac{L'}{L}(s, \\chi) \\frac{x^s}{s} \\d s + \\underbrace{O(\\frac{x (\\log x)^2}{T} + x^{1 - q \\sigma_1})}_{\\ll \\exp{-c \\sqrt{\\log x}}, T = \\exp(o(\\sqrt{\\log x}))}\n  \\]\n  as we take \\(\\sigma_1 = 1 - \\frac{c}{\\log qT}\\) so \\(x^{\\sigma_1} \\ll x \\exp(-c \\sqrt{\\log x})\\) if \\(q \\ll T \\approx \\exp (O(\\sqrt{\\log x}))\\).\n\n  For the main term, if \\(\\chi = \\chi_0\\) then take \\(\\sigma_1\\) as above, so no zeroes of \\(L(s, \\chi_0)\\) so \\(\\frac{L'}{L}\\) has just a simple pole at \\(s = 1\\), and the main term is \\(x\\).\n\n  If \\(\\chi \\neq \\chi_0\\) and there is no exceptional zero then there is no zero of \\(L(s, \\chi)\\) with \\(\\sigma \\geq \\sigma_1\\) so no poles of \\(\\frac{L'}{L}(s, \\chi)\\), so the main term is \\(0\\).\n\n  Finally if \\(\\chi\\) has an exceptional zero at \\(\\beta\\), then inside \\(C\\), \\(\\frac{L'}{L}\\) has a pole at \\(\\beta\\). Thus \\(\\frac{L'}{L}(s, \\chi) \\frac{x^s}{s}\\) has residue \\(\\frac{x^\\beta}{\\beta}\\) at this pole, so the main term is \\(\\frac{x^\\beta}{\\beta}\\).\n\\end{proof}\n\n\\subsection{Siegel-Walfisz theorem}\n\n\\begin{theorem}[Siegel-Walfisz]\\index{Siegel-Walfisz theorem}\n  For all \\(A > 0\\), if \\((a, q) = 1\\) and \\(q \\leq (\\log x)^A\\) then\n  \\[\n    \\psi(x; q, a) = \\frac{x}{\\varphi(q)} + O_A(x \\exp(-c \\sqrt{\\log x})).\n  \\]\n\\end{theorem}\n\nThis follows from\n\\begin{theorem}\n  \\label{thm:theorem 2}\n  If \\(q \\leq (\\log x)^A\\) and \\(x\\) is large enough (depending on \\(A\\)) and if \\(\\chi \\neq \\chi_0\\) then\n  \\[\n    \\psi(x, \\chi) = O_A(\\exp (-c \\sqrt{\\log x})).\n  \\]\n\\end{theorem}\n\nThis in turn follows from\n\\begin{theorem}\n  \\label{thm:theorem 3}\n  For all \\(\\varepsilon > 0\\), there exists \\(C_\\varepsilon\\) such that if \\(\\chi\\) is a quadratic character modulo \\(q\\) and \\(\\beta\\) is a real zero then\n  \\[\n    \\beta < 1 - C_\\varepsilon q^{-\\varepsilon}.\n  \\]\n\\end{theorem}\nTherefore even if \\(q\\) has an exceptional zero, it is not too close to \\(1\\).\n\n\\begin{proof}\n  Omitted.\n\\end{proof}\n\nA curious fact is that the constant \\(C_\\varepsilon\\) is \\emph{ineffective} --- the proof gives no way to calculate \\(C(\\varepsilon)\\). It follows that the big \\(O\\) (actually the constatnt \\(c\\)) in the statement of Siegel-Walfisz is also ineffective.\n\n\\begin{proof}[Proof that \\Cref{thm:theorem 3} implies \\Cref{thm:theorem 2}]\n  If there is an exceptional zero then \\(\\beta < 1 - C_\\varepsilon q^\\varepsilon\\) for all \\(\\varepsilon > 0\\). Thus\n  \\begin{align*}\n    \\psi(x, \\chi)\n    &= O(\\frac{x^\\beta}{\\beta} + x \\exp (-c \\sqrt{\\log x})) \\\\\n    &= x o(\\exp(-C_\\varepsilon q^\\varepsilon \\log x) + \\exp(-c \\sqrt{\\log x}))\n  \\end{align*}\n  since \\(q \\leq (\\log x)^A\\), this is \\(O(\\exp(C_\\varepsilon'(\\sqrt{\\log x})))\\) by choosing \\(\\varepsilon = \\frac{1}{3A}\\), say.\n\\end{proof}\n\n\\begin{corollary}\n  If \\((a, q) = 1\\) then\n  \\[\n    \\pi(x; q, a) = \\frac{\\operatorname{Li}(x)}{\\varphi(q)} + O(x \\exp (-c \\sqrt{\\log x}))\n  \\]\n  and if \\(q \\leq (\\log x)^A\\) (unconditionally) or if \\(q \\leq \\exp(O(\\sqrt{\\log x})\\) (if \\(q\\) has no exceptional zero)\n\\end{corollary}\nNote that assuming GRH, the bound on \\(q\\) when \\(q\\) has no exceptional zero can be improved to \\(q \\leq x^{\\frac{1}{2} - o(1)}\\).\n\n\\begin{proof}\n  Let\n  \\[\n    F(x)\n    = \\sum_{\\substack{p \\leq x \\\\ p = a \\bmod q}} \\log p\n    = \\psi(x; q, a) + O(x^{1/2})\n  \\]\n  and so\n  \\begin{align*}\n    \\pi(x; q, a)\n    &= \\sum_{\\substack{p \\leq x \\\\ p = a \\bmod q}} 1 \\\\\n    &= \\frac{F(x)}{\\log x} + \\int_x^x \\frac{F(t)}{t (\\log t)^2} \\d t \\\\\n    &= \\frac{1}{\\varphi(q)} \\left(\\frac{x}{\\log x} + \\underbrace{\\int_2^x \\frac{1}{(\\log t)^2} \\d t}_{= \\operatorname{Li}(x)}\\right) + O(x \\exp(-c \\sqrt{\\log x}))\n  \\end{align*}\n\\end{proof}\n\nTwo applications of Siegel-Walfisz:\n\\begin{application}\n  For fixed \\((a, q) = 1\\), how large is the smallest prime congurent to \\(a\\) modulo \\(q\\)? Call this prime \\(P_{a, q}\\).\n  \\begin{corollary}\n    For all \\(\\varepsilon > 0\\),\n    \\[\n      P_{a, q} \\ll_\\varepsilon \\exp(q^\\varepsilon).\n    \\]\n  \\end{corollary}\n  \\begin{proof}\n    Let \\(x < P_{q, a}\\) so \\(\\psi(x; q, a) = 0\\). Thus if \\(q \\leq (\\log x)^A\\), must have by Siegel-Walfisz\n  \\[\n    \\frac{x}{\\varphi(q)} = O_A(x \\exp(-c \\sqrt{\\log x})).\n  \\]\n  Thus\n  \\[\n    \\exp(c \\sqrt{\\log x}) = O_A(q)\n  \\]\n  so\n  \\[\n    \\log x \\leq (\\log q)^2 + O_A(1),\n  \\]\n  contradicting \\(q \\leq (\\log x)^A\\). Thus if \\(q\\) is large enough, \\(q \\leq (\\log P_{a, q})^A\\).\n  \\end{proof}\n\n  Similarly\n  \\begin{corollary}\n    If \\(q\\) has no exceptional zero then\n    \\[\n      P_{a, q} \\leq q^{O(\\log q)}.\n    \\]\n  \\end{corollary}\n  It has been conjectured that\n  \\[\n    P_{a, q} \\leq q^{1 + o(1)}.\n  \\]\n  On GRH, we have \\(P_{a, q} \\leq q^{2 + o(1)}\\). Amazingly, we have an unconditional result\n  \\begin{theorem}\n    There exists \\(L\\) constant such that\n    \\[\n      P_{a, q} \\ll q^L.\n    \\]\n  \\end{theorem}\n  So far the best known result is \\(L = 5\\), by Xylouris 2011.\n\\end{application}\n\n\\begin{application}\n  \\begin{theorem}[Walfisz]\n    For any \\(n\\), let \\(r(n)\\) be the number of ways of writing \\(n\\) as the sum of a prime a square-free natural number. Then\n    \\[\n      r(n) \\sim c_n \\operatorname{Li}(n),\n    \\]\n    where\n    \\[\n      c_n = \\prod_{p \\divides n} (1 + \\frac{1}{p^2 - p - 1}) \\prod_p (1 - \\frac{1}{p (p - 1)}).\n    \\]\n  \\end{theorem}\n  The second term is a constant, which is approximately \\(0.3739 \\dots\\).\n\n  \\begin{proof}\n    Note that\n    \\[\n      1_{\\text{square-free}}(m) = \\sum_{d^2 \\divides m} \\mu(d),\n    \\]\n    easily checked since both sides are multiplicative. Thus\n    \\begin{align*}\n      r(n)\n      &= \\sum_{p < n} 1_{\\text{square-free}}(n - p) \\\\\n      &= \\sum_{p < n} \\sum_{d^2 \\divides (n - p)} \\mu(d) \\\\\n      &= \\sum_{d < \\sqrt n} \\mu(d) \\sum_{\\substack{p < n \\\\ p = n \\bmod d^2}} 1 \\\\\n      &= \\sum_{d < \\sqrt n} \\mu(d) \\pi(n - 1; d^2, n)\n    \\end{align*}\n    If \\((n, d) > 1\\) then\n    \\[\n      \\pi(n - 1; d^2, n) = O(1)\n    \\]\n    so in total this contributes \\(O(n^{1/2})\\) to \\(r(n)\\). If \\((d, n) = 1\\) and \\(d \\leq (\\log n)^A\\) then\n    \\[\n      \\pi(n - 1; d^2, n) = \\frac{\\operatorname{Li}(x)}{\\varphi(d^2)} + O(n \\exp(-c \\sqrt{\\log n})).\n    \\]\n    Thus the contribution is\n    \\[\n      \\sum_{\\substack{d < (\\log n)^A \\\\ (d, n) = 1}} \\mu(d) \\pi(n - 1; d^2, n)\n      = \\operatorname{Li}(n) \\sum_{\\substack{d < (\\log n)^A \\\\ (d, n) = 1}} \\frac{\\mu(d)}{\\varphi(d^2)} + O(n \\exp(-c \\sqrt{\\log n})).\n    \\]\n    Note that \\(\\varphi(d^2) = d \\varphi(d)\\) so\n    \\[\n      \\sum_{(d, n) = 1} \\frac{\\mu(d)}{d \\varphi(d)}\n      = \\prod_{\\p \\ndivides}(1 - \\frac{1}{p(p - 1)}) = c_n.\n    \\]\n    The tail term of this estimation is\n    \\[\n      \\sum_{\\substack{d > (\\log n)^A \\\\ (d, n) =1 }} \\frac{\\mu(d)}{d \\varphi(d)}\n      \\leq \\sum_{d > (\\log n)^A} \\frac{1}{d^{3/2}}\n      \\ll \\frac{1}{(\\log n)^{A/2}}\n      = o(1)\n    \\]\n    as \\(n \\to \\infty\\).\n\n    For \\(d > (\\log n)^A\\), use the trivial bound\n    \\[\n      \\pi(x; q, a) \\ll 1 + \\frac{x}{q}\n    \\]\n    so\n    \\[\n      \\sum_{\\substack{(\\log n)^A < d < n^{1/2} \\\\ (d, n) = 1}} \\mu(d) \\pi(n - 1; d^2, n)\n      \\ll \\sum_{(\\log n)^A < d < n^{1/2}} (1 + \\frac{n}{d^2})\n      \\ll n^{1/2} + n \\sum_{d > (\\log n)^A} \\frac{1}{d^2}\n      \\ll \\frac{n}{(\\log n)^A}\n    \\]\n    where in the first step we simply through away the condition \\((d, n) = 1\\) and the term \\(\\pi(d)\\).\n\n    Thus in conclusion,\n    \\begin{align*}\n      r(n)\n      &= c_n \\operatorname{Li}(n) + O(n^{1/2} + \\frac{\\operatorname{Li}(n)}{(\\log n)^{A/2}} + \\frac{n}{(\\log n)^A} + n\\exp (-c \\sqrt{\\log n})) \\\\\n      &= (1 + o(1))c_n \\operatorname{Li}(n)\n    \\end{align*}\n    as \\(\\operatorname{Li}(n) = (1 + o(1)) \\frac{n}{\\log n}\\).\n  \\end{proof}\n\\end{application}\n\n\\section{Highlights of Analytic Number Theory*}\n\n\\subsection{Gaps between primes}\n\nNote that prime number theory implies that \\(p_n \\sim n \\log n\\) so\n\\[\n  p_{n + 1} - p_n \\sim (n + 1) \\log(n + 1) - n \\log n \\sim \\log n.\n\\]\nThis is the average behaviour and we may ask how small or how big it can get. Twin prime conjecture says \\(p_{n + 1} - p_n = 2\\) infinitely often. Goldeston-Pintz-Yildirim (2005) proved that\n\\[\n  \\liminf_{n \\to \\infty} \\frac{p_{n + 1} - p_n}{\\log n} = n.\n\\]\nZhang (2013) proved that\n\\[\n  p_{n + 1} - p_n = O(1)\n\\]\ninfinitely often. The bound given by Zhang is \\(70,000,000\\). Over the next few months Polymath project managed to improve the bound gradually. Coincidentally, Maynard proved in the same year, six months after ZHang, using a different method, that \\(p_{n + 1} - p_n \\leq 600\\) infinitely often. By combining these two approaches, the current best bound is \\(246\\).\n\nAs for large gaps, Westzynthius (1931) prove that\n\\[\n  \\limsup_{n \\to \\infty} \\frac{p_{n + 1} - p_n}{\\log n} = \\infty.\n\\]\nRankin (1938) used an improved version to prove the quantitative result\n\\[\n  p_{n + 1} - p_n \\gg \\log n \\left( \\frac{\\log\\log n \\log\\log\\log\\log n}{(\\log\\log\\log n)^2} \\right)\n\\]\ninfinitely often. Erdos offter a prize of \\$10,000, the largest ever, that the bound goes to infinity (?). In 2014, this is cracked by Ford-Green-Konyagin-Maynard-Tao that\n\\[\n  p_{n + 1} - p_n \\gg \\log n \\left( \\frac{\\log\\log n \\log\\log\\log\\log n}{\\log\\log\\log n} \\right)\n\\]\ninfinitely often. It has been conjectured that \\(p_{n + 1} - p_n \\gg (\\log n)^2\\) infinitely often. However this is way out of reach at this moment, even more so than twin prime conjecture. To have an idea, the best upper bound so far is \\(p_{n + 1} - p_n \\ll n^{0.525}\\) for every \\(n\\). If we assume GRH then the result is \\(\\leq n^{1/2 + o(1)}\\).\n\n\\subsection{Digits of primes}\n\nMauduit-Rivat looked at sum of binary digits of primes and showed it is even half the time and odd half the time. Maynard (2016) showed there are infintely primes without, say, a \\(1\\) in base \\(10\\). The result would be much harder for smaller base. For example for base \\(2\\) this is equivalent to the statement that there are infintely many primes of the form \\(2^n - 1\\).\n\n\\subsection{Arithmetic progressions}\n\nIn 1930s (Vinogradov, Estermann et al) people proved there are infinitely many \\(3\\)-APs of primes, e.g.\\ \\((3, 5, 7), (11, 17, 23), \\dots\\). However, for any \\(k > 4\\) this is much more difficult. Green-Tao (2004) showed that for any \\(k\\), there are infinitely many \\(k\\)-APs of primes, using tools of additive combinatorics. Another important theorem is Szemerédi (1975), that if\n\\[\n  \\liminf_{N \\to \\infty} \\frac{|A \\cap \\{1, \\dots, N\\}|}{N} > 0\n\\]\nthen \\(A\\) has infinitely many \\(k\\)-APs.\n\n\\subsection{Sieve theorey success}\n\nChen (1973) showed that there are inifinitely many primes \\(p\\) such that \\(p + 2\\) is either prime or the product of \\(2\\) primes. Iwaniec (1978) showed there are infinitely many \\(n\\) such that \\(n^2 + 1\\) is either prime or the product of two primes.\n\n\\subsection{Number theory without zeta zeros}\n\nPeople have wondered if we can develop analytic number theory without knowing the zeros of zeta function. Instead of Perrons's formula, Halsesz in 1960s proved that (informally) if \\(\\sum_{n \\leq x} a_n\\) behaves randomly then \\(a_n\\) behaves like \\(\\chi(n)\\) or \\(n^{it}\\). Granville-Soundararajan resurrected this approach to study functions ``pretending'' to be \\(\\chi(n)\\). The official name of this subject is \\emph{pretentious number theory}, and fantastic notes can be found on Granville's website when he taught the course a few years ago.\n\n\\subsection{Circle method: additive number theory}\n\nDevelped by Hardy and Littlewood in 1920s,\n\\begin{enumerate}\n\\item Golbach conjecture: every even number is the sum of two primes.\n\\item partition function \\(p(n)\\).\n\\item Waring's problesm: all integers are sum of \\(4\\) squares, all (large) integers are sum of \\(4\\) cubes (this is still open, best known bound \\(7\\).\n\n  Let \\(G(k)\\) be the minimum \\(s\\) such that every large \\(n\\) is the sum of \\(x_1^k, \\dots, x_s^k\\). The only result we know is\n  \\[\n    G(2) = 4, 4 \\leq G(3) \\leq 7, G(4) = 16.\n  \\]\n\n  Wooley (1996) proved\n  \\[\n    G(k) \\leq (1 + o(1)) k \\log k.\n  \\]\n  It's been conjectured that \\(G_k) \\ll k\\).\n\\end{enumerate}\n\n\\printindex\n\\end{document}\n\n% www.thomasbloom.org/ant.html\n", "meta": {"hexsha": "31addc5e9dab018484d2dd11381596a2e57a37ac", "size": 136115, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "III/analytic_number_theory.tex", "max_stars_repo_name": "geniusKuang/tripos", "max_stars_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2018-01-15T05:02:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T15:48:31.000Z", "max_issues_repo_path": "III/analytic_number_theory.tex", "max_issues_repo_name": "geniusKuang/tripos", "max_issues_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-11T20:43:21.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T21:29:15.000Z", "max_forks_repo_path": "III/analytic_number_theory.tex", "max_forks_repo_name": "geniusKuang/tripos", "max_forks_repo_head_hexsha": "127e9fccea5732677ef237213d73a98fdb8d0ca0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2017-11-08T16:16:20.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T17:20:19.000Z", "avg_line_length": 39.9281314168, "max_line_length": 547, "alphanum_fraction": 0.5526797194, "num_tokens": 55812, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784220301065, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4011471728705643}}
{"text": "% Manual_MILP_BH_cyclic_ec_vector_en.txt\n% ver1: Jan 12, 2021\n\n\\documentclass[11pt, titlepage, dvipdfmx, twoside]{article}\n\\linespread{1.1}\n\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}[theorem]{Lemma}\n\\usepackage{enumitem}\n\\usepackage{geometry}\n\\geometry{left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm}\n\n\\usepackage{mathtools}\n\\usepackage{comment}\n\\usepackage[dvipdfmx]{graphicx}\n\\usepackage{float}\n\\usepackage{framed}\n\\usepackage{graphicx}\n\\usepackage{subcaption}\n\\usepackage{listings}\n\\usepackage{color}\n\\usepackage{url}\n \n\\definecolor{codegreen}{rgb}{0, 0.6, 0}\n\\definecolor{codegray}{rgb}{0.5, 0.5, 0.5}\n\\definecolor{codepurple}{rgb}{0.58, 0, 0.82}\n\\definecolor{backcolour}{rgb}{0.95, 0.95, 0.92}\n\n\\newcommand{\\tname}{6Hc} \n%%  target name used for the example \n\n\\newcommand{\\dist}{\\mathrm{dist}}\n\n\\title{\\Huge{Module 3: Inferring a 2-Lean Cyclic Chemical Graph with Bounded Branch-Height\n\t\t\t  from a Trained ANN Using MILP}}\n\n\\begin{document}\n\n% The following makeatletter must be after begin{document}\n\\makeatletter \n\\let\\c@lstlisting\\c@figure\n\\makeatother\n\n\\date{\\today}\n\n\\maketitle\n\n% \\cleardoublepage\n\n\\thispagestyle{empty}\n\\tableofcontents\n\\clearpage\n\n\\pagenumbering{arabic}\n\n\n\\section{Outline}\n\\label{sec:Intro}\n\nThis note explains how to use an implementation of a mixed-integer\nlinear programming (MILP) formulation that can infer\na vector of graph descriptors given a target value and the \nweights and bias values of a trained artificial neural network (ANN).\n\nThe MILP is implemented in Python, \nusing the PuLP modeling module of the \nCOIN-OR package~\\cite{PuLP1,PuLP2,PuLP3,PuLP4}.\n\nTo begin with, we give a list of the files that accompany this note.\n\n\\begin{itemize}\n\n\\item Folder {\\tt source\\_code}\\\\\nA folder containing four Python scripts that implement\nan MILP formulation for inferring feature vectors\nof cyclic chemical graphs from a trained ANN,\nand files containing minimum and maximum values\nof each descriptor\nin the MILP formulation.\n\n\\begin{itemize}\n\n\\item {\\tt ann\\_inverter.py}\\\\\nAn implementation of an MILP formulation \nfor the Inverse problem on  ANNs~\\cite{AN19}.\n\n\\item {\\tt cyclic\\_graphs\\_MILP\\_ec\\_id\\_vector.py}\\\\\nA Python script that contains functions to initialize the variables and prepare \nthe constraints for an MILP\nformulation for inferring cyclic chemical graphs with \na prescribed topological structure~\\cite{cyclic_BH_arxiv}.\n\n\\item {\\tt infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py}\\\\\nA Python script that prepares the data and executes \nthe MILP formulation for given input data.\nFurther details on the use of this script\nare given in Section~\\ref{sec:Exp}.\n\n\\item {\\tt read\\_instance\\_BH\\_cyclic\\_v05.py}\\\\\nA Python script that contains necessary functions\nto read the topological specification from a given textual file.\n\n\\item Folder {\\tt topological\\_description}\\\\\nA folder containing six textual files each giving a chemical specification as detailed \nin~\\cite{cyclic_BH_arxiv}.\n%\n\\begin{itemize}\n \\item {\\tt instance\\_a.txt} \n \\item {\\tt instance\\_b1.txt} \n \\item {\\tt instance\\_b2.txt} \n \\item {\\tt instance\\_b3.txt}\n \\item {\\tt instance\\_b4.txt}  \n \\item {\\tt instance\\_c.txt} \n \\item {\\tt instance\\_d.txt} \n\\end{itemize}\n\n\\item Folder {\\tt ANN}\\\\\nA folder containing information on trained artificial neural networks (ANNs) for three target properties:\nFlash point (closed cup) (Fp), Lipophilicity (Lp), and Solubility (Sl).\nFor each of the above three properties, ${\\tt property} \\in \\{{\\tt FP, LP, SL}\\}$ three files are provided:\n%\n\\begin{itemize}\n\\item {\\tt property\\_desc.csv}\\\\\nA comma-separated value file containing descriptors\nused in the training of the ANN.\n\n\\item {\\tt property\\_biases.txt}\\\\\nA file containing the values of the biases of a trained ANN.\n\n\\item {\\tt property\\_weights.txt}\\\\\nA file containing the values of the weights of a trained ANN.\n\\end{itemize}\n%\nFor each of the files, the data format is explained in Section~\\ref{sec:InOut},\nand an actual example is given in Section~\\ref{sec:Exp}.\n\n\\item {\\tt fv4\\_cyclic\\_stdout.cpp}\\\\\nA C++ program that calculates the feature vector of \na chemical graph stored in SDF format.\nThe input and output of this program are customized to work with \nthe Python script {\\tt infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py}\nin order to verify the descriptor values\nof the graph inferred as a solution to the MILP (if one exists).\nThis source file should be compiled into an executable file\nwith the name {\\tt fv}.\n\n\\item {\\tt fv}\\\\\nAn executable binary file of the above C++ program.\nThis executable has been compiled \nby {\\tt gcc} version 5.4.0\non a PC running the Linux Mint 18.3 operating system.\n%\n\\end{itemize}\n\\end{itemize}\n\n\n\nThe remaining of this note is organized as follows.\nSection~\\ref{sec:Pre} gives an explanation \nof the used terms and notation.\n%\nSection~\\ref{sec:InOut} explains the \ninput and output data of the program,\nand Section~\\ref{sec:Exp} gives a concrete\nexample of input data and the results form the computation.\n\n% \\newpage\n\n\\section{Terms and Notation}\n\\label{sec:Pre}\n%\nThis section explains the terms and notation used in this note.\n\n\n\\begin{itemize}\n\n\\item {\\bf Feature vector}\\\\\n%\nA {\\em feature vector} stores numerical values of certain parameters,\ncalled {\\em descriptors}.\nIn this work, we choose graph-theoretical descriptors, such as number of \nnon-hydrogen atoms, number of vertices of certain degree, etc.\n\n\\item {\\bf Artificial neural network - ANN}\\\\\n%\nArtificial neural networks are one of the methods in machine learning.\nThey provide a means to construct a correlation function between \npairs of feature vectors as input and target data as output.\n\n\n\\item {\\bf Input, hidden, and output layer}\\\\\n%\nWe deal with the multilayer perceptron model \nof feed-forward neural networks.\nThese neural networks are constructed of several {\\em layers}.\nFirst comes the \\emph{input layer}, where each neuron takes as input\none value of the feature vector.\nNext come the \\emph{hidden layers}, where the \nvalues from the input layer are propagated in a feed-forward manner,\nsuch that each node in one layer is connected to all the nodes of the next layer. \nFinally, the output is delivered at the \\emph{output layer}.\nWe deal with predicting the value of a single target,\nand hence we assume that the output layer comprises a single node.\n\n\\item {\\bf Weights}\\\\\n%\nEach edge connecting two nodes in an ANN is assigned a real value,\ncalled a \\emph{weight}.\nPart of the \\emph{learning} process of ANNs is to determine values for each of the weights\nbased on known pairs of feature vectors and target values.\n\n\\item {\\bf Biases}\\\\\nEach node of an ANN except for the nodes in the input layer\nis assigned a real value, called a {\\em bias},\nwhich, just like the edge weights, is determined through the learning process.\n\n\n\\item {\\bf Activation function}\\\\\n%\nIn an ANN, each node produces an output as a function, called the \\emph{activation function}, \nof its input.\nWe assume that each node has the Rectified Linear-Unit (ReLU) function \nas its activation function,\nwhich can be expressed exactly in the MILP formulation\nfor the inverse problem on ANNs~\\cite{AN19}.\n%https://scikit-learn.org/stable/modules/generated/sklearn.neural\\_network.MLPRegressor.html\n\n\\item {\\bf Mixed-Integer Linear Programming (MILP)}\\\\\n%\nA type of a mathematical programming problem\nwhere all the constraints are given as linear expressions, and\nsome of the decision variables are required to take\nonly integer values.\nFor more details, see any standard reference, e. g.~\\cite{LP}.\n\n\n\\item {\\bf Graph} \\\\\nAn abstract combinatorial construction comprising\na finite set of {\\em vertices}, and a finite set of {\\em edges},\nwhere each edge is a pair of vertices.\nWe treat {\\em undirected} graphs,\ni. e., graphs where edges are unordered pairs of vertices.\nFor more information, see e. g.~\\cite{graph}.\n\n\\end{itemize}\n\n% \\newpage\n\n\\section{The Program's Input and Output}\n\\label{sec:InOut}\n\nThis section explains the format of the input and the output of the program.\nSection~\\ref{sec:section3_1} illustrates an example of the program's input format,\nand Section~\\ref{sec:section3_2} gives a concrete computational example.\nFollowing, Section~\\ref{sec:section3_3} illustrates an example of the program's output format,\nand Section~\\ref{sec:section3_4} gives a concrete computational example.\n\n\n\\subsection{Program Input}\n\\label{sec:section3_1}\n\nThis section gives an explanation of the input to the program.\n\nFirst\nthe input requires three textual files containing \\\\\n~~~~- the descriptor names, in csv format \\\\\n~~~~- the weights and biases of a trained ANN in textual format.\\\\\nFor a common prefix {\\tt TT} which the program accepts as a command-line parameter,\nthese files must be saved with file names {\\tt TT\\_desc.csv}, \n{\\tt TT\\_weights.txt} and {\\tt TT\\_biases.txt} for the files containing\nthe descriptor names, the weights, and the biases of a trained ANN, respectively.\n%\nNext, comes the target value for which we wish to infer \na chemical graph based on the trained ANN given above.\nFollowing is a chemical specification given in a textual file,\nas described in~\\cite{cyclic_BH_arxiv}, \nas well as a filename prefix for the output files,  which are described in Section~\\ref{sec:section3_4}. \n\nFinally, comes a choice of MILP solver program to be used.\nWe can choose \\\\\n~~~~- 1: CPLEX, a commercial MILP solver~\\cite{cplex}. \\\\\n(Note, in this case the parameter {\\tt CPLEX\\_PATH} in the file {\\tt infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py}\nmust be set to the correct path of the CPLEX program executable file.) \\\\\n~~~~- 2: CBC, a free and open-source MILP solver. It comes together with the PuLP package for Python~\\cite{PuLP1}.\n\n\n\n\n\\subsection{Input Data Format}\n\\label{sec:section3_2}\n\nThis section presents an actual example of an input instance of the program.\nIn particular, we give a concrete example of the three input files\nmentioned in Section~\\ref{sec:section3_1}.\n\nThe purpose of this program is to calculate a feature vector that will produce a desired output from a \ngiven trained ANN.\nFigure~\\ref{fig:sample} gives an example of a trained ANN.\n\n\n\\begin{figure}[H]\n  \\centering\n  \\includegraphics[width=0.5\\textwidth]{./fig/ANN_sample_en}\n  \\caption{An example of a trained ANN.\n\t\t      The ANN's weights are given in red numbers, and\n\t\t      its biases in blue.\n\t\t    }\n  \\label{fig:sample}\n\\end{figure}\n\n\nThe information on the trained ANN is written in two text files, containing the information\non the ANN's weights and biases, respectively.\nFirst, we give the structure of the file that contains the information on the ANN's weights.\nThe first line of this text file contains the information on the ANN's architecture, i. e., \nthe number of nodes in each of its layers.\nFrom the second row and onward\nfollows the information on the \nweights in the ANN.\nEach row contains the weights of the edges that are incident to one node of the ANN,\nfirst of the nodes in the input layer, and then for the nodes of the hidden layers.\nFollowing is a textual example for the ANN given in Fig.~\\ref{fig:sample}.\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf Organization of the text file containing weight data}\\\\\\\\\n%\\bigskip\\bigskip\n3 2 1\\\\\n1.1 2.3\\\\\n-0.4 0.8\\\\\n1.8 3.1\\\\\n2.6\\\\\n1.5\\\\\n\\end{oframed}\n\n\\bigskip\n\n\nNext, comes the text file with the information on the ANN's biases.\nThe bias values from Fig.~\\ref{fig:sample} are given below.\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf Bias values}\\\\\\\\\n%\\bigskip\\bigskip\n0.7\\\\\n-1.2\\\\\n2.1\\\\\n\\end{oframed}\n\n\\bigskip\n\nLast comes a text file containing data on the feature vector.\nThe first line of this file contains the names of the descriptors used in the feature vectors.\nFollowing form the second row onward, are the numerical values of the descriptors for each chemical graph\nin the training dataset, one row per chemical graph.\nFor an example, please check one of the files  {\\tt TT\\_desc.csv},  in the folder {\\tt ANN},\nwhere ${\\tt property} \\in \\{{\\tt FP, LP, SL}\\}$.\n\n\n\n\\subsection{Program Output}\n\\label{sec:section3_3}\n\nThis section gives an explanation of the output of the program.\nIf there exists an acyclic chemical graph with a feature vector that\nwould result with the given target value as a prediction of\nthe given trained ANN, the program will output the feature vector.\nIn case such a chemical graph does not exist, the program will report this.\nThe next section gives an explanation of the output of the program.\n\n\n\\subsection{Output Data Format}\n\\label{sec:section3_4}\n\nThis section describes the output data of the program as\nobtained on a personal computer.\n\nOnce invoked, the program will print some messages to the standard error\nstream, which appear on the terminal.\nOnce the MILP solver completes the computation,\nthe status of the computation is printed on the terminal.\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf Text output on the terminal}\\\\\\\\\n%\\bigskip\\bigskip\n\\begin{tabular}{l l}\n Initializing Time: 0.809                &         \\# Written to {\\tt stderr} \\\\\nStart Solving Using CPLEX...      &       \\# Written to {\\tt stderr} \\\\\nStatus: Feasible \t\t\t\t&       \\# Solution status \\\\\nMILP y*: 197.922 \t\t\t\t&      \\# Calculated target value in the MILP  \\\\\nANN propagated y*: 197.922     &      \\# Target value calculated by the trained ANN  \\\\\nAll descriptors match    \t\t&      \\# Descriptor values due to the MILP and the inferred  graph \\\\\nSolving Time: 16.711                     &      \\# Time taken by the MILP solver \\\\\n\\end{tabular}\n\n\n\n\\end{oframed}\n\nFinally, if there exists a feasible solution the program writes to disk two text files.\nRecall that as a part of the input the program requires a filename\nused for the output files. \nAssume that the supplied parameter is {\\tt filename}.\nThen, the resulting two text files are named \\\\\n- {\\tt filename.sdf} \\\\\n- {\\tt filename\\_partition.sdf}. \n\n\\noindent\nThe file {\\tt filename.sdf} contains information\non the inferred chemical graph in the SDF (Structure Data File)\nformat.\nFor more information see the official documentation (in English) \\\\\n\\url{http://help.accelrysonline.com/ulm/onelab/1.0/content/ulm_pdfs/direct/reference/}\\\\\n\\phantom{\\url{http://}} \\url{ctfileformats2016.pdf} \\\\\nfor detail.\n\n\\noindent\nThe file {\\tt filename\\_partition.sdf} contains a \ndecomposition of the cyclic graph from the \nfile {\\tt filename.sdf} into acyclic subgraphs,\nas described in~\\cite{cyclic_BH_arxiv}.\n\n\n\n\\section{Invoking the Program and a Computational Example}\n\\label{sec:Exp}\n\nThis section explains how to invoke the program\nand explains a concrete computational example.\nFollowing is an example of invoking the\nprogram {\\tt infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py}.\n\n \n\n\n\\subsection{Executing the Program}\n\\label{sec:Exp_1}\n\nFirst make sure that the terminal is \ncorrectly directed to the location\nof the {\\tt source\\_code} folder, as described in Section~\\ref{sec:Intro}. \\\\\n\n\\noindent\n{\\tt \n python  infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py \ntrained\\_ann\\_filename\\_prefix\ntarget\\_value \\\\\n \\phantom{python } \n chemical\\_specification\noutput\\_file\\_name\nsolver\\_type\n }\\\\\n\n\nAs an example we use the target property Flash Point (closed cup), \nthat is, the files from the trained ANN with filename prefix {\\tt FP},\ntarget value 200,\nthe file {\\tt instance\\_a.txt} for a chemical specification,\nand CPLEX~\\cite{cplex} as an MILP solver (parameter value 1).\n\n{\\tt \n python infer\\_cyclic\\_graphs\\_ec\\_id\\_vector.py \nANN/FP\n200 \\\\\n \\phantom{python } \nchemical\\_specification/instance\\_a.txt\nresult\n1\n }\\\\\n\n\nBy executing the above command, the following text should appear on the terminal prompt.\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf Text output on the terminal}\\\\\\\\\n%\\bigskip\\bigskip\n Initializing Time: 0.809  \\\\\nStart Solving Using CPLEX...\\\\\nStatus: Feasible \t\t\\\\\nMILP y*: 197.922 \t\t\\\\\nANN propagated y*: 197.922 \\\\\nAll descriptors match    \t\\\\\nSolving Time: 16.711       \n\\end{oframed}\n\nThe contents of the output files {\\tt result.sdf} and\n{\\tt result\\_partition.txt} are as follows.\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf File {\\tt result.sdf}}\\\\\\\\\n\\begin{verbatim}\n 1\nMILP_cyclic\nec_id_vector\n 43 46  0  0  0  0  0  0  0  0999 V2000 \n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  2  0  0  0  0\n  1 24  1  0  0  0  0\n  2 25  1  0  0  0  0\n  2 41  1  0  0  0  0\n  3  4  1  0  0  0  0\n  3 23  2  0  0  0  0\n  3 38  1  0  0  0  0\n  4  5  2  0  0  0  0\n  4 33  1  0  0  0  0\n  5 24  1  0  0  0  0\n  6 12  1  0  0  0  0\n  6 18  1  0  0  0  0\n  7  9  1  0  0  0  0\n  7 11  2  0  0  0  0\n  7 28  1  0  0  0  0\n  8  9  1  0  0  0  0\n  8 10  1  0  0  0  0\n 10 11  1  0  0  0  0\n 11 12  1  0  0  0  0\n 12 17  1  0  0  0  0\n 13 14  1  0  0  0  0\n 13 17  1  0  0  0  0\n 13 19  1  0  0  0  0\n 14 15  1  0  0  0  0\n 14 16  1  0  0  0  0\n 17 18  2  0  0  0  0\n 18 22  1  0  0  0  0\n 19 20  1  0  0  0  0\n 19 21  1  0  0  0  0\n 19 23  1  0  0  0  0\n 22 23  1  0  0  0  0\n 24 25  1  0  0  0  0\n 25 26  1  0  0  0  0\n 25 27  1  0  0  0  0\n 28 29  1  0  0  0  0\n 28 30  1  0  0  0  0\n 30 31  1  0  0  0  0\n 30 32  1  0  0  0  0\n 33 34  1  0  0  0  0\n 34 35  1  0  0  0  0\n 35 36  1  0  0  0  0\n 35 37  1  0  0  0  0\n 38 39  1  0  0  0  0\n 39 40  3  0  0  0  0\n 41 42  1  0  0  0  0\n 42 43  3  0  0  0  0\nM  END\n$$$$\n\\end{verbatim}    \n\\end{oframed}\n\n\\bigskip\n\n\\begin{oframed}\n{\\bf File {\\tt result\\_partition.txt}}\\\\\\\\\n\\begin{verbatim}\n12\n9\n0 1\n10\n0 0\n11\n0 0\n12\n0 0\n13\n1 3\n17\n0 0\n18\n0 1\n19\n0 1\n22\n0 0\n23\n0 1\n24\n0 2\n25\n0 4\n15\n9 7 11\n1 3\n9 8 10\n0 3\n10 11\n0 0\n11 12\n0 0\n12 6 18\n0 1\n12 17\n0 0\n13 17\n0 0\n13 19\n0 0\n17 18\n0 0\n18 22\n0 0\n19 23\n0 0\n22 23\n0 0\n23 3 4 5 24\n4 6\n24 1 2 25\n3 5\n24 25\n0 2\n\\end{verbatim}    \n\\end{oframed}\n\n\n\\begin{thebibliography}{99}\n  \\bibitem{AN19} \n    T.~Akutsu and H.~Nagamochi.\n    A Mixed Integer Linear Programming Formulation to Artificial Neural Networks,\n    in Proceedings of the 2019 2nd International Conference on Information Science and Systems,\n    pp.~215--220, https://doi.org/10.1145/3322645.3322683.\n    \n  \\bibitem{cyclic_BH_arxiv}\n\t  T.~Akutsu and H.~Nagamochi.\n\t  A Novel Method for Inference of Chemical Compounds with Prescribed Topological Substructures Based on Integer Programming.\n\t  Arxiv preprint, arXiv:2010.09203\n\t  \n%   \\bibitem{graph} 茨木俊秀，永持仁，石井利昌．グラフ理論ー連結構造とその応用ー．朝倉書店，2010． \n%   \n%   \\bibitem{LP} 福島雅夫．数理計画入門．朝倉書店，2012． \n  \\bibitem{LP} J.~Matousek and B.~G\\\"{a}rtner.\n\t\t\t      Understanding and Using Linear Programming. Springer, 2007.\n\t\t\t      \n  \\bibitem{graph} M.~S.~Rahman.\n\t\t\t      Basic Graph Theory. Springer, 2017.\n  \n  \\bibitem{PuLP1} A Python Linear Programming API, \\url{https://github.com/coin-or/pulp}.\n  \n  \\bibitem{PuLP2} Optimization with PuLP, \\url{http://coin-or.github.io/pulp/}.\n  \n  \\bibitem{PuLP3} The Python Papers Monograph, \\url{https://ojs.pythonpapers.org/index.php/tppm/article/view/111}.\n  \n  \\bibitem{PuLP4} Optimization with PuLP, \\url{https://pythonhosted.org/PuLP/}.\n  \n  \\bibitem{cplex}\n{IBM ILOG CPLEX Optimization Studio~12.8 User Manual}.\n\\newblock\n  \\url|https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.studio.help/pdf/usrcplex.pdf|.\n  \n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "05b696e914e46fb63e5ce23b67a66d14b8bbb602", "size": 22051, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Cyclic_improved/Module_3/Manual_Module_3_Cyclic_improved_en.tex", "max_stars_repo_name": "CitrusAqua/mol-infer", "max_stars_repo_head_hexsha": "6d5411a2cdc7feda418f9413153b1b66b45a2e96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-14T02:16:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T20:39:26.000Z", "max_issues_repo_path": "Cyclic_improved/Module_3/Manual_Module_3_Cyclic_improved_en.tex", "max_issues_repo_name": "CitrusAqua/mol-infer", "max_issues_repo_head_hexsha": "6d5411a2cdc7feda418f9413153b1b66b45a2e96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cyclic_improved/Module_3/Manual_Module_3_Cyclic_improved_en.tex", "max_forks_repo_name": "CitrusAqua/mol-infer", "max_forks_repo_head_hexsha": "6d5411a2cdc7feda418f9413153b1b66b45a2e96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2021-07-03T02:41:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T09:05:41.000Z", "avg_line_length": 31.2780141844, "max_line_length": 125, "alphanum_fraction": 0.6829168745, "num_tokens": 8437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934765, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.40114716986801224}}
{"text": "\\documentclass[]{article}\n\\usepackage{amsmath}\n\n%opening\n\\title{Engineering Statistics Lectures XVII}\n\\author{Notes by Jonathan Bender}\n\\date{November 14, 2019}\n\n\\begin{document}\n\t\n\t\\maketitle\n\t\n\t\\begin{abstract}\n\t\tOpportunity \\#1 given November 26, 2019 and due November 27, 2019 at 6:00 PM.\n\t\tFinal opportunity given sometime during the week of December 10, 2019.\n\t\tLCCC community dinner on November 27, 2019 from 5:00 PM to 7:00 PM, room AT134.\n\t\t\n\t\tOpportunity \\#1 Questions due Sunday November 24, 2019 by 8:00 PM by email. Questions can range from any section, focusing on material from Lecture 16 onward (Chapter 5).\n\t\\end{abstract}\n\n\t\\section{Hypergeometric Functions?}\n\t\n\t\t3 conditions:\n\t\t\\begin{enumerate}\n\t\t\t\\item Population is a finite set of some size N.\n\t\t\t\\item Members of the population are either a success or failure; there are a fixed number of successes K in the population.\n\t\t\t\\item Take a sample of size n from the population -- Each sample of size n is equally \"likely\". Let X be the number of successes in this sample set.\n\t\t\t\\item X is bounded: $max(0,\\ n-[N-k]) \\leq X \\leq min(n,\\ k)$ such that \"n-[N-k]\" is the minimum number of possible failures among the sample set.\n\t\t\t\\item $\\mu_X = \\dfrac{k}{N}(n)$\n\t\t\t\\item Finite population correction factor = $\\dfrac{N-n}{N-1}$\n\t\t\t\\item $\\sigma_X^2 = \\dfrac{n * k}{N} * (1-\\dfrac{k}{N}) * (\\dfrac{N-n}{N-1}) = \\mu_X * P(Fail) * (Finite\\ population\\ correction\\ factor)$\n\t\t\\end{enumerate}\n\t\n\t\tSuppose that N = 16, k = 4, n = 7: The bounds are $max(0,7-[16-4]),min(4,7)$, which simplifies to [0, 4].\n\t\t\n\t\n\t\\pagebreak\n\t\\section{Noah has raccoons?}\n\t\t\n\t\tSpoz Noah wants to yell at North Ridgeville metropolis about his raccoon problem. Suppose there are 30 raccoons near his house. Noah captures and tags 11 raccoons, then he sets them free. Later, Noah captures a sample set of size 6. Let's define a success as one of the previously-tagged raccoons being currently captured.\n\t\t\n\t\t\\subsection{A. Mean?}\n\t\t\t$\\mu_X = \\dfrac{11}{30}*6 = \\dfrac{22}{10} = 2.2$ successes on average.\n\t\t\n\t\t\\subsection{B. Bounds?}\n\t\t\tMinimum bound is the maximum of 0 and the number of failures, or 0 and 6-19. So, 0. Maximum bound is the minimum of the sample size and the number of successes, which is the sample size. So, [0,6].\n\t\t\n\t\t\\subsection{C. P(more than two, no more than four) being tagged?}\n\t\t\n\t\t\tP($2<X\\leq 4$) = P($X=3 \\cap X=4$) = $P(X=3) \\cup P(X=4)$\n\t\t\t\n\t\t\tP(3) = $\\dfrac{\\binom{11}{3} * \\binom{19}{3}}{\\binom{30}{6}}$\n\t\t\t\n\t\t\tP(4) = $\\dfrac{\\binom{11}{4} * \\binom{19}{2}}{\\binom{30}{6}}$\n\t\t\t\n\t\t\tResult is left as an exercise in arithmetic: $\\dfrac{545}{1496}$\n\t\t\n\t\t\\subsection{D. Variance?}\n\t\t\t$\\sigma_X^2 = \\mu_X * P(Fail) * (Finite\\ population\\ correction\\ factor)$\n\t\t\t$ = \\dfrac{22}{10} * (\\dfrac{19}{30}) * (\\dfrac{30-6}{30-1})$\n\t\t\n\t\n\t\n\t\\section{Ian has skunks?!}\n\t\tSpoz we have N skunks; Ian captures and tags 5. He then captures 10 at another time. Because the number of untagged skunks is 8, we know that there are at least 13 skunks in circulation, but this is ultimately an inconclusive way of estimating the value. Still -- valuable for the future.\n\t\n\t\tWe assume that, if $\\mu_X = 2 = (\\dfrac{k}{N})n = (\\dfrac{5}{N})10$, then $N = \\dfrac{50}{2} = 25$. This can be used for estimating animal populations.\n\t\n\\end{document}", "meta": {"hexsha": "f7c7bb96acfa14f095dbcc2aa9a6d8fb2cd546a9", "size": 3291, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LaTeX/JonsStatsNotes.tex", "max_stars_repo_name": "joey-kilgore/playground", "max_stars_repo_head_hexsha": "2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LaTeX/JonsStatsNotes.tex", "max_issues_repo_name": "joey-kilgore/playground", "max_issues_repo_head_hexsha": "2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-12-10T01:37:23.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-10T01:37:23.000Z", "max_forks_repo_path": "LaTeX/JonsStatsNotes.tex", "max_forks_repo_name": "joey-kilgore/playground", "max_forks_repo_head_hexsha": "2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-03-26T03:20:41.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-09T23:22:40.000Z", "avg_line_length": 47.6956521739, "max_line_length": 324, "alphanum_fraction": 0.6803403221, "num_tokens": 1098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.69925440852404, "lm_q1q2_score": 0.4011471554862178}}
{"text": "% Created 2019-10-17 jue 19:04\n\\documentclass[presentation,aspectratio=169]{beamer}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{fixltx2e}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{float}\n\\usepackage{wrapfig}\n\\usepackage{rotating}\n\\usepackage[normalem]{ulem}\n\\usepackage{amsmath}\n\\usepackage{textcomp}\n\\usepackage{marvosym}\n\\usepackage{wasysym}\n\\usepackage{amssymb}\n\\usepackage{hyperref}\n\\tolerance=1000\n\\usepackage{khpreamble}\n\\usepackage{amssymb}\n\\DeclareMathOperator{\\shift}{q}\n\\DeclareMathOperator{\\diff}{p}\n\\usetheme{default}\n\\author{Kjartan Halvorsen}\n\\date{\\today}\n\\title{Computerized Control - Polynomial design}\n\\hypersetup{\n  pdfkeywords={},\n  pdfsubject={},\n  pdfcreator={Emacs 25.3.50.2 (Org mode 8.2.10)}}\n\\begin{document}\n\n\\maketitle\n\n\n\\section{Intro}\n\\label{sec-1}\n\n\n\\section{2-dof controller}\n\\label{sec-2}\n\n\\begin{frame}[label=sec-2-1]{Two-degree-of-freedom controller}\n\\begin{center}\n\\includegraphics[width=0.8\\linewidth]{../../figures/2dof-block-explicit-no-delay}\n\\end{center}\n\\end{frame}\n\n\\section{Problem 5.3}\n\\label{sec-3}\n\\begin{frame}[label=sec-3-1]{Åström \\& Wittenmark problem 5.3}\nConsider the system given by the pulse-transfer function\n\\[ H(z) = \\frac{z+0.7}{z^2 -1.8z + 0.81} \\]\nUse polynomial design (RST) to determine a controller such that the closed-loop system from command input to output has the characteristic polynomial\n\\[ A_c(z) = z^2 - 1.5z + 0.7. \\]\nLet the observer polynomial have as low order as possible, and place all observer poles in the origin (deadbeat observer). Consider three cases\n\\begin{description}\n\\item[{(a)}] Positional control with cancellation of the process zero\n\\item[{(b)}] Positional control with no cancellation of the zero\n\\item[{(c)}] Incremental controller with  no cancellation of the zero\n\\end{description}\n\\end{frame}\n\n\\begin{frame}[label=sec-3-2]{Why cancel the process zero?}\nBode plots of closed-loop systems (from reference signal to output) with and without cancellation of the process zero:\n\n\\begin{center}\n\\includegraphics[width=0.6\\linewidth]{../../figures/aw5_3_bode}\n\\end{center}\n\\end{frame}\n\n\\begin{frame}[label=sec-3-3]{Preliminary exercise}\nWhich of the closed-loop responses below  corresponds to (I) Positional control with zero cancellation (II), Positional control without zero cancellation, (III) Incremental control without zero cancellation.\n\\begin{center}\n\\includegraphics[width=0.45\\linewidth]{../../figures/aw5_3_refstep}\n\\includegraphics[width=0.45\\linewidth]{../../figures/aw5_3_diststep}\n\\end{center}\n\\end{frame}\n% Emacs 25.3.50.2 (Org mode 8.2.10)\n\\end{document}", "meta": {"hexsha": "4572c3d50f28b4f3cd32e865dd1406f48d4b0f1c", "size": 2598, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "polynomial-design/slides/lecture-polynomial-design-incremental.tex", "max_stars_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_stars_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-07T05:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-22T09:46:13.000Z", "max_issues_repo_path": "polynomial-design/slides/lecture-polynomial-design-incremental.tex", "max_issues_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_issues_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-06-12T20:44:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-12T20:49:00.000Z", "max_forks_repo_path": "polynomial-design/slides/lecture-polynomial-design-incremental.tex", "max_forks_repo_name": "kjartan-at-tec/mr2007-computerized-control", "max_forks_repo_head_hexsha": "16e35f5007f53870eaf344eea1165507505ab4aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-03-14T03:55:27.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-14T03:55:27.000Z", "avg_line_length": 32.475, "max_line_length": 207, "alphanum_fraction": 0.759430331, "num_tokens": 807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398979, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.40111760198398166}}
{"text": "\n% JuliaCon proceedings template\n\\documentclass{juliacon}\n\\setcounter{page}{1}\n\\usepackage{verbatim}\n\\usepackage{svg}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\input{header}\n\n\\maketitle\n\n\\begin{abstract}\n\nData from various fields have their suitable structure. Nowadays, applicable data in\nartificial intelligence are images, text and speech. These data can be represented as vector\nor matrix structure. However, some data are not suitable for matrix structure or it can be\nsparse to fit in matrix structure. For example, social network in social science, biological\nnetwork in biology and traffic network represent their data in graph or network structure.\nUsually, measurement of these data lies in non-Euclidean space. To utilize network\nrepresentation as input for deep learning model, geometric deep learning, or its subfield\ncalled graph neural network, learns topological information provided by network structure\nand latent information from input features simultaneously. A geometric deep learning\nframework in Julia is proposed, GeometricFlux.jl. GeometricFlux.jl is a Julia package for\ngeometric deep learning on graph. It extends Flux.jl, a well-known machine learning\nframework in Julia, to accept network structure as model input. Some well-known and key\ngraph convolutional layers are implemented in GeometricFlux.jl. It relies on Zygote.jl for\nautomatic differentiation engine. ScatterNNlib.jl acted as independent package contains\nessential scatter/gather operations and their gradient for GeometricFlux.jl. To leverage\nexisting JuliaGraphs ecosystem, GeometricFlux.jl accepts graph data structure constructed\nfrom JuliaGraphs. Layers implemented in GeometricFlux.jl are compatible with Flux.jl layers.\nThus, dropout, batch normalization and dense layers are applicable when using Flux and\nGeometricFlux.jl together. GPU computation is necessary and is supported by CUDA.jl as well.\nStatic and variable graphs are supported for efficiency and various network structure input,\nrespectively. Message-passing scheme \\cite{gilmer2017} and graph network block \\cite{battaglia2018}\nare implemented as flexible and integrated framework. The performance of scatter operations\nare benchmarked and it outperforms pytorch-scatter on cuda. I propose a novel and competitive\ngeometric deep learning library in Julia.\n\n\\end{abstract}\n\n\\section{Introduction}\n\nGeometric deep learning emerges as a subfield of deep learning. It learns with irregular\nstructured data and features. Topological information from graph is embedded with features\nthrough the whole neural network. Graph neural network provides a generic approach \\cite{gilmer2017,battaglia2018}\nfor learning topological information together with features to get precisely prediction.\nHowever, integration of scientific computing, software architecture, graph representation\nand dataset preparation is challenging. GPU computation on irregular data struture is not\ncommonly supported. A well-defined graph neural network framework is needed for researchers\nto operate with. I proposed GeometricFlux, a geometric deep learning extension of a deep learning\nlibrary, Flux, in Julia. Graph convolutional layers are organized in the design of message\npassing scheme. Graph network block is implemented as a generic version of message passing\nscheme. Leveraging Julia ecosystem, operations on CPU and GPU are optimized with SIMD and\nCUDA.jl, respectively. Graph representations are supported with general array or graphs from\nJuliaGraph ecosystem.\nA github repository is available in https://github.com/yuehhua/GeometricFlux.jl.\n\n\\begin{figure*}[t]\n\\resizebox{180mm}{!}{\\input{figures/scatter_add.pdf_tex}}\n\\caption{Benchmark for scatter add on CPU and GPU.}\n\\label{fig:scatter_add}\n\\end{figure*}\n\n\\begin{figure*}[ht]\n\\resizebox{180mm}{!}{\\input{figures/scatter_mean.pdf_tex}}\n\\caption{Benchmark for scatter mean on CPU and GPU.}\n\\label{fig:scatter_mean}\n\\end{figure*}\n\n\\begin{figure*}[ht]\n\\resizebox{180mm}{!}{\\input{figures/scatter_max.pdf_tex}}\n\\caption{Benchmark for scatter max on CPU and GPU.}\n\\label{fig:scatter_max}\n\\end{figure*}\n\n\\section{Extending Framework}\n\nAn extending framework is designed to integrate message-passing scheme and graph network (GN)\nblock in GeometricFlux. Message-passing scheme is defined in two functions: message function\nand update function. Message function passes states on node itself and its neighbors or edges\nand give messages. Aggregate function is used to aggregate messages into single outcome.\nUpdate function takes node state and aggregated message, and then update the result as new\nnode state. Precisely, message-passing scheme can be described as follow:\n\n\\[\n    \\begin{aligned}\n    m_i^{(t+1)} &= agg_{j \\in \\mathcal{N}(i)}(M(x_i^{(t)}, x_j^{(t)}, e_{ij})) \\\\\n    x_i^{(t+1)} &= U(x_i^{(t)}, m_i^{(t+1)})\n    \\end{aligned}\n\\]\n\nMessage function $M$ and update function $U$ are predefined by a network layer or users.\nA message for node $i$ is calculated for $t+1$-th layer, which is denoted as $m_i^{(t+1)}$,\nand aggregated in elementwise manner by operation $agg$ with neighbors of $i$. A new node $i$\nstate $x_i^{(t+1)}$ is computed for $t+1$-th layer as an outcome from update function.\n\nGN block defines a more general operations on graph. It updates edge, node and global states\nindividually. Aggregate functions are applied after updating states and merge states from edges\nto nodes, from edges to global and from nodes to global. GN is implemented as an abstract\ntype in Julia and coupled with a series of update functions and aggregate functions as API\nfor overriding. As a special case of GN, message-passing network is defined as subtype of GN.\nUpdate functions are defined as follow:\n\n\\[\n    \\begin{aligned}\n    e_k' &= \\phi^e (e_k, v_i, v_j, g) \\\\\n    v_i' &= \\phi^v (\\bar{e}_i', v_i, g) \\\\\n    g' &= \\phi^g (\\bar{e}', \\bar{v}', g)\n    \\end{aligned}\n\\]\n\nand aggregate functions are\n\n\\[\n    \\begin{aligned}\n    \\bar{e}_i' &= \\rho^{e \\rightarrow v} (\\{e_k', i, j\\}_{j \\in \\mathcal{N}(i),k = (i, j)}) \\\\\n    \\bar{e}' &= \\rho^{e \\rightarrow g} (\\{e_k\\}_{k \\in E}) \\\\\n    \\bar{v}' &= \\rho^{v \\rightarrow g} (\\{v_i\\}_{i \\in V})\n    \\end{aligned}\n\\].\n\nNew states for edges, nodes and global graph are updated by $\\phi^e$, $\\phi^v$ and $\\phi^g$,\nrespectively. $\\phi^e$ takes edge state $e_k$, corresponding node state $v_i$, $v_j$ and\nglobal state $g$, and then outputs a new edge state $e_k'$ for edge $k$.\n$\\rho^{e \\rightarrow v}$ aggregates states of edge incident to node $i$.\n$\\rho^{e \\rightarrow g}$ and $\\rho^{v \\rightarrow g}$ functions aggregate all edge states and\nnode states into a global state, respectively. It is designed as a whole in single layer\nsuch that a GN block can be use as an unit of a neural network.\n\n\\section{Static and Variable Graph Support}\n\nIn graph neural network, static graph structure is required for computation efficiency;\nwhile variable graph carried by input features is used to train neural network on various\ngraph topology. Static graph should be given during constructing GNN layers; while variable\ngraph is packed within FeaturedGraph data structure as input of GNN layer. Static graphs are\nprocessed for efficiency in prior during constructing GNN layer and variable graphs are\nprocessed during network training time. In this framework, graph network block is designed as\nfundamental layers. Each layer accepts input of node features, edge features, global features\nand graph. Graph structures from Graphs.jl, SimpleWeightedGraphs.jl and MetaGraphs.jl\nare accepted. FeaturedGraph is designed as generic data structure for containing different\nkinds of features and graph structure.\n\n\\section{Compatible with Flux Layers}\n\nIn general, the layer design of graph neural network is different from regular layer of\nneural network. The layer of graph neural network accepts at least features and graph as input.\nIn our architecture, we accept node features, edge features, global features and graph as input.\nTo make layer design compatible with regular neural network needs complicated design in\neach GNN layer. GNN layers are designed with two version, one for FeaturedGraph input and\nthe other for normal feature input. GNN layers are designed to be consistent with input type\nand output type. Output of regular feature will be the input of regular Flux layer.\nConclusively, layers implemented in GeometricFlux are compatible with regular Flux layers.\n\n\\section{Integration with JuliaGraphs}\n\nJuliaGraphs already forms a whole ecosystem for graph operations, graph visualization and\nsolving problems in graph theory. Graphs.jl and SimpleWeightedGraphs.jl provides the\ngraph construction and representation in unweighted and weighted graphs.\nMetaGraphs.jl provides user the chance to assign properties on nodes, edges or global graph.\nIntegration with JuliaGraphs ecosystem provides more ways to assign graph to model and\nreduce the effort of transformation between data types. Graph representation constructed\nfrom Graphs.jl, SimpleWeightedGraphs.jl and MetaGraphs.jl are accepted in construction\nof geometric deep learning model in GeometricFlux. Under construction of graph convolutional\nlayer, a static graph is accepted as one of arguments of neural network layer during\nconfiguring model. In the context of using variable graph, FeaturedGraph also accepts graph\nrepresentation constructed from Graphs.jl, SimpleWeightedGraphs.jl and MetaGraphs.jl\nand can be fed as sample directly to model. This feature accepts graph representations\nfrom JuliaGraphs ecosystem to geometric deep learning model.\n\n\\section{Performance Evaluation}\n\nJulia community is always interested to performance issues of all kinds of computation.\nScatter functions are benchmarked to show the fundamental operations in graph neural network\nmodel. Matrix addition and multiplication is to convolutional neural network as scatter\noperations is to graph neural network. I compared time consumption on scatter add function\nbetween pytorch geometric and GeometricFlux. The functionality of scatter operations are\nseparated as independent packages of pytorch scatter and ScatterNNlib for pytorch geometric\nand GeometricFlux, respectively. Benchmark are performed on Intel i7-8700K machine with a\nNvidia Titan XP and Ubuntu 20.04 64-bit. Software of ScatterNNlib.jl v0.1.1 and CUDA.jl v1.2.1\nwith Cuda version of 10.1 is used. For pytorch, Pytorch v 1.6.0 and Pytorch-scatter v 2.0.5\nare tested. I benchmarked on both CPU and GPU with scatter add (\\autoref{fig:scatter_add}), mean (\\autoref{fig:scatter_mean})\nand max (\\autoref{fig:scatter_max}).\n\n\\section{Datasets Preparation}\n\nDatasets are preprocessed and prepared by GraphMLDatasets.jl. Currently, the citation graphs\nCora, CiteSeer, PubMed and Cora-Full datasets \\cite{sen2008,bojchevski2018deep} are\nprovided. Scientific datasets such as molecule datasets QM7b \\cite{montavon2013} and\nprotein-protein interaction graphs \\cite{hamilton2017} are also provided.\n\n\\section{Conclusion}\n\nI introduced GeometricFlux for deep learning on graph. An extending framework is designed\nto be the core of GeometricFlux and it also supports of static and variable graph.\nJuliaGraph ecosystem is also integrated to provide more graph representations.\nEffective scatter operations are implemented to accelerate model training and inference.\nThese make GeometricFlux as a prototype of playground for geometric deep learning in Julia.\nFinally, I will keep working to implement more network layers on graph and more prepared\ndatasets.\n\n\\section{Acknowledgments}\n\nI personally thank Ching-Wen Cheng for suggestions on scatter operation implementation.\n\n\\input{bib.tex}\n\n\\end{document}\n\n% Inspired by the International Journal of Computer Applications template\n", "meta": {"hexsha": "13c1a7a2206e6486f43dde31c61caf523037c4f7", "size": 11715, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "paper/paper.tex", "max_stars_repo_name": "jarbus/GeometricFlux.jl", "max_stars_repo_head_hexsha": "9cd21d26237afeecd40f6df6d12d096f2d5272be", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 94, "max_stars_repo_stars_event_min_datetime": "2021-04-01T02:58:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T12:25:50.000Z", "max_issues_repo_path": "paper/paper.tex", "max_issues_repo_name": "jarbus/GeometricFlux.jl", "max_issues_repo_head_hexsha": "9cd21d26237afeecd40f6df6d12d096f2d5272be", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2021-03-31T16:42:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T03:16:12.000Z", "max_forks_repo_path": "paper/paper.tex", "max_forks_repo_name": "jarbus/GeometricFlux.jl", "max_forks_repo_head_hexsha": "9cd21d26237afeecd40f6df6d12d096f2d5272be", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2021-03-31T16:39:12.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-21T11:29:26.000Z", "avg_line_length": 55.0, "max_line_length": 125, "alphanum_fraction": 0.7961587708, "num_tokens": 2720, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6406358548398982, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.40111759751458204}}
{"text": "\\subsection{Example: A simple activated sludge model: } \n creation of a simple activated sludge model for BOD removal using GIFMod is demonstrated. Figure \\ref{fig:21} shows the schematic of the activated sludge system. A two component model with substrate identified by $S$ and biomass identified by $X$ will be created. The parameters of the model are listed in table \\ref{table:ASM}.  \n \n\\begin{figure}[!ht]\\label{fig:21}\n\\begin{center}\n\\includegraphics[width=8cm]{Images/Figure21.png} \\\\\n\\caption{Activated Sludge System schematic} \n\\end{center}\n\\end{figure}\n \n \n\\begin{table}\n\\caption{Parameters of the activated sludge model example}\n\\begin{tabular}{l l}\\label{table:ASM}\nparameter & value \\\\\n\\hline\nVolume of aeration tank & 8468$m^3$ \\\\\nVolume of the clarifier & 60$m^3$ \\\\\nmaximum growth rate ($\\mu_{max}$) & 6$day^{-1}$ \\\\\nSubstrate half saturation constant ($k_s$) & 20mg-COD/L \\\\\nBiomass decay rate ($k_d$) & 0.12$day^{-1}$ \\\\\nYield coefficient for heterotrophic growth ($Y$) & 0.4  mgVSS/mgCOD. \\\\\nInflow flow rate ($Q_{in})$ & 22464$m^3/day$ \\\\\nInflow substrate concentration ($S_{in}$) & 224$mgCOD/L$ \\\\\nWasting flow rate ($Q_{WAS}$) & 300 $m^3/day$ \\\\\nReturn flow rate ($Q_{RAS}$) & 13478 $m^3/day$ \\\\\nArea of the clarifier & 3000$m^2$ \\\\\nDepth of the clarifier & 2m \\\\\nSettling velocity of biomass & 100$m/day$ \\\\\n \\end{tabular}\\\\\n\\end{table}\n\nSteps to create the simple activated sludge model:\n\\begin{itemize}\n\\item \\textbf{Start GIFMod}\n\\item \\textbf{Setting the duration of the simulation: } We want the simulation to run for 20 days so a \nsteady-state solution is achieved. In order to do so go to \\textbf{Project Explorer}$\\rightarrow$\\textbf{Project Setting} and from the \\textbf{Properties} window set the simulation end date to January 20, 1900. This result in a period of simulation from 0 to 20days. \n\\item \\textbf{Add Aeration Tank: } We will use the \\textbf{Pond} block to create the components of the model including the aeration tank, the clarifier and the reservoirs to hold the effluent and waste flow. Other blocks types could also be used as we will use the \\textbf{quasi steady-state} method to calculate flows. \\\\\n- Add a pond to represent the aeration pond. \\\\\n- Set the following properties: \n- \\textbf{Name: } \\textit{Aeration Tank} \\\\\n- \\textbf{Bottom area: }\\textit{8468$m^2$} \\\\\n- \\textbf{Initial water depth: }\\textit{1m} \\\\\n\\textbf{Note: } As long as a depth and area result in the required volume of 8468$m^3$, the depth and bottom area will not influence the results. If aeration was to be considered, then the area could determine the rate of dissolved oxygen flux into the pond depending on the external flux model (See section \\ref{sssec:ExtFlux}).\\\\ \n\\item \\textbf{Adding other ponds: } The clarifier will be modeled using two vertically connected ponds and two additional ponds will be used to retain waste and effluent flow. A larger number of layers could be used to represent the clarifier but to keep this example simple, it is limited to two ponds. \\\\\nAdd the following pond blocks:\\\\\\\\\n\\textbf{Clarifier top: }\\\\\n- \\textbf{Name: } \\textit{Clarifier top} \\\\\n- \\textbf{Bottom area: }\\textit{30$m^2$} \\\\\n- \\textbf{Initial water depth: }\\textit{1m} \\\\\\\\\n\\textbf{Clarifier Bottom: }\\\\\n- \\textbf{Name: } \\textit{Clarifier bottom} \\\\\n- \\textbf{Bottom area: }\\textit{3000$m^2$} \\\\\n- \\textbf{Initial water depth: }\\textit{1m} \\\\\n- \\textbf{Bottom elevation: }\\textit{-1m}\\\\\n\\textbf{Note: } The bottom elevation of the lower compartment of the clarifier need to be below the bottom elevation of the top compartment for the settling of biomass to be appropriately calculated in the clarifier.\\\\\\\\ \n\\textbf{Waste Storage: }\\\\\n- \\textbf{Name: } \\textit{Waste Storage} \\\\\n- \\textbf{Bottom area: }\\textit{3000$m^2$} \\\\\n- \\textbf{Initial water depth: }\\textit{0} \\\\\\\\\n\\textbf{Effluent Storage: }\\\\\n- \\textbf{Name: } \\textit{Effluent Storage} \\\\\n- \\textbf{Bottom area: }\\textit{3000$m^2$} \\\\\n- \\textbf{Initial water depth: }\\textit{0} \\\\\n\\item \\textbf{Adding Connections: } Connect the following pond blocks together: \\\\\n- \\textbf{Aeration Tank} to \\textbf{Clarifier top}\\\\\n- \\textbf{Clarifier Top} to \\textbf{Clarifier bottom}\\\\\n- \\textbf{Clarifier Top} to \\textbf{Effluent Storage}\\\\\n- \\textbf{Clarifier Bottom} to \\textbf{Waste Storage}\\\\\n- \\textbf{Clarifier Bottom} to \\textbf{Aeration Tank}\\\\\n- Enter a length of 1 for all the connectors. \n\n\\textbf{Note: } The length that is entered for the connectors is not actually used in calculations of flow because the quasi-steady state approach will be used. But GIFMod does not allow connectors with zero lengths so the value must be entered. After adding the connectors the model configuration should look like figure \\ref{fig:22}.\n- Select the connector from \\textbf{Clarifier top} to \\textbf{Clarifier bottom} and set the \\textbf{Settling} property to \\textbf{Yes}. This forces the model to consider settling advective transport in this connector. \n\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=10cm]{Images/Figure22.png} \\\\\n\\caption{Activated sludge model configuration in GIFMod}\\label{fig:22}\n\\end{center}\n\\end{figure}\n\\item \\textbf{Adding constituents: } Two constituents  including substrate (S) and biomass (X) will be considered in the model.\n- Add two constituents by right-clicking on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Constituents} and then choose \\textbf{Add Constituents} from the drop-down menu. Change the name of the first constituent to \\textbf{S} and the second one to \\textbf{X}. \n- Change the settling velocity of the \\textbf{X} constituent to 100m/day. \n\\item \\textbf{Inflow rate and characteristics: } The inflow characteristics input file looks like figure \\ref{fig:23}. Create this file or upload it from the example folder and save it in a folder on your hard drive as inflow.csv or any other names you desire. \n//- Click on the aeration tank and from the \\textbf{Inflow time-series} property in the properties window select the file containing the inflow time series. Note that only to time-point are needed because the flow rate and characteristics are assumed to be constant throughout the simulation. \n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=5cm]{Images/Figure23.png} \\\\\n\\caption{Inflow input file for the activated sludge example}\\label{fig:23}\n\\end{center}\n\\end{figure}\nThe quasi steady state hydraulics mode solve the flow rates in each connector by assuming that the summation of inflows and outflows are equal. At this point if we consider a quasi-steady state flow there are 5 connectors while the inflow=outflow condition can only be applied to the three blocks that have more than one connectors connected to them (i.e. Aeration tank, Clarifier top, and Clarifier bottom) and so there is only three equations for five unknowns. However, in activated sludge systems typically the waste and return flows are controlled. We impose the flow rates in the RAS and WAS connectors using prescribed flow. The input prescribed flow files for the two connectors are shown in figure \\ref{fig:24}. Create the files and save them respectively as return.csv and waste.csv. \n\\begin{figure}\n\\begin{center}\n\\begin{tabular}{c c}\na) \\includegraphics[width=5cm]{Images/Figure24.png} & b) \\includegraphics[width=5cm]{Images/Figure24b.png}\\\\\n\\end{tabular}\n\n\\caption{a) return and b) waste flow input file for the activated sludge example}\\label{fig:24}\n\\end{center}\n\\end{figure}\nNote that the heading line for the prescribed flow input files are not necessary, so deleting the first line in the files will not affect the output. \\\\\\\\\n- Click on connector connecting \\textbf{Clarifier bottom} to the \\textbf{Aeration tank} (i.e. return activated sludge connector). \\\\\\\\\n- From the properties window, set \\textbf{Use prescribed flow} to \\textbf{Yes} and choose return.csv as the \\textbf{Prescribed flow time series}. \\\\\\\\\n- Do the same for the connector from \\textbf{Clarifier bottom} to {Waste Storage} and pick waste.csv as the \\textbf{Prescribed flow time series}. \\\\\n\\item \\textbf{Biomass Settling in the clarifier: } In order to force the biomass in the clarifier the settling property of the connector connecting the top clarifier compartment to the lower clarifier compartment should be set to \\textbf{Yes}. Click on the connector connecting \\textbf{Clarifier top} to \\textbf{Clarifier bottom} and from the properties window look for the \\textbf{Settling} option and set it to \\textbf{Yes}. \n\\item \\textbf{Biomass initial condition: } The should be some biomass in the clarifier initially for the biomass growth to be possible. We will start from a small (1$mg/L$) concentration of biomass. Click on the aeration tank and click on the box in front of \\textbf{Constituent Initial Concentration}. From the window that will pop up, select X as the constituent and enter the value 1 under the value column and then close the window (Figure \\ref{fig:26}). \n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=8cm]{Images/Figure26.png} \\\\\n\\caption{Setting initial biomass concentration in the simple activated sludge model}\\label{fig:26} \n\\end{center}\n\\end{figure}\n\n\\item \\textbf{Entering reaction parameters: }\\\\\n- Right-click on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Reactions}$\\rightarrow$\\textbf{Reaction parameters} and click on \\textbf{Add reaction parameter} item from the drop-down menu. \\\\\n- Type \"$\\sim mu\\_max$\" in the name field and enter a value of 6. \n- Similarly add the other reaction parameters including $k_d$, $Y$ and $K_s$ with values of respectively 0.12, 0.4, and 20. \n\\item \\textbf{Setting up reactions: }\\\\\n- Right-click on \\textbf{Project Explorer}$\\rightarrow$\\textbf{Water Quality}$\\rightarrow$\\textbf{Reactions}$\\rightarrow$\\textbf{Reaction network} and click on \\textbf{Open Reaction Network Window}. \\\\\n- Enter the processes names, rate expressions and stoichiometric constants as see in figure \\ref{fig:27}.\n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=8cm]{Images/Figure27.png} \\\\\n\\caption{Reaction network for the simple activated sludge model}\\label{fig:27}\n\\end{center}\n\\end{figure}\n\\item \\textbf{Turning off reactions in clarifier and waste and effluent storage blocks}: In most activated sludge models the reactions in claifier is neglected. Also in order to use the waste storage and effluent storage to gain information about the characteristics of effluent and storage it may be desirable to preserve the mass balance in these two blocks by turning off reactions in them. \\\\\n- Turn off reactions in \\textbf{Clarifier top}, \\textbf{Clarifier bottom}, \\textbf{Waste Storage}, and \\textbf{Effluent Storage} blocks by clicking on them and switching the value of \\textbf{Conduct reactions} to \\textbf{No}. \\\\\n\\item \\textbf{Running the simulation} Now the model is ready. Click on the \\textbf{forward run} icon icon \\includegraphics[width=0.5cm]{Icons/run_icon.png} on the tool bar on the left side of the screen and wait for the simulation to end. \n\\textbf{Inspecting the results: } Right-click on the \\textbf{aeration tank} and click \\textbf{Water quality results}$\\rightarrow$\\textbf{S} to see the variation of substrate in the aeration tank. Do the same thing for \\textbf{X}. Similar to the previous example you can copy the two graphs unto each other (Figure \\ref{fig:32}). \n\\begin{figure}\n\\begin{center}\n\\includegraphics[width=8cm]{Images/Figure32.png} \\\\\n\\caption{S and X variation in the simple ASM model}\\label{fig:32}\n\\end{center}\n\\end{figure}\n\n\\end{itemize}\n", "meta": {"hexsha": "fbdd1d58c07aa38e8f3da6a099b03544cea525ee", "size": 11527, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "GIFMod User's Manual/ASM_ex.tex", "max_stars_repo_name": "ArashMassoudieh/GIFMod_", "max_stars_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-11-20T19:32:27.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-28T06:08:45.000Z", "max_issues_repo_path": "GIFMod User's Manual/ASM_ex.tex", "max_issues_repo_name": "ArashMassoudieh/GIFMod_", "max_issues_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-07-04T05:40:30.000Z", "max_issues_repo_issues_event_max_datetime": "2017-07-04T05:43:37.000Z", "max_forks_repo_path": "GIFMod User's Manual/ASM_ex.tex", "max_forks_repo_name": "ArashMassoudieh/GIFMod_", "max_forks_repo_head_hexsha": "1fa9eda21fab870fc3baf56462f79eb800d5154f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-11-09T22:00:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-30T10:56:08.000Z", "avg_line_length": 81.7517730496, "max_line_length": 794, "alphanum_fraction": 0.7600416414, "num_tokens": 3102, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635841117624, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.40111758892273436}}
{"text": "\\documentclass[a4paper,11pt]{article}\n\n\\usepackage[francais]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[official]{eurosym}\n\\usepackage{hyperref}\n\\usepackage{graphicx}\n\\usepackage{float}\n\\usepackage{amsmath,amsfonts,amssymb,amsthm}\n\\usepackage{algorithmic, algorithm}\n\n\\begin{document}\n\\hskip-2.7cm\n  \\begin{minipage}[c]{17cm}\n  \\vskip-2cm\n    \\begin{minipage}[c]{2cm}\n      \\includegraphics[width=2cm]{img/logo-telecom-paristech.png}\n    \\end{minipage}\n    \\begin{center}\n      \\vspace*{2cm}\n\n      {\\LARGE Project Report}\n\n      {\\LARGE \\textbf{Turing's Morphogenesis}}\n\n      \\vspace*{1cm}\n\n      {\\large \\textbf{Olivier Le Floch},} code written with Thomas Deniau,\n      March 20, 2009\n    \\end{center}\n  \\end{minipage}\n\n\\section{Introduction}\n\nThe phenotypes of multicellular living organisms such as mammals exhibit many\nspecific and complex shapes and textures. Since they have a rather limited\nnumber of genes -- about 20.000 for humans \\cite{human_genome} -- the\nmechanics that generate these shapes must be very simple. In particular, this\nmeans that they very probably use a limited number of chemicals that interact\ntogether in a chaotic manner to form emergent complex patterns. In 1952,\nTuring \\cite{turing} proposed a simple diffusion-reaction model to try to\naccount for the observed genesis of planar patterns with only two chemicals :\n$A$ is a pigmented catalytic molecule, and $B$ destroys $A$. The creation of\n$B$ and $A$ is catalyzed by $A$. Additionally, both $A$ and $B$ follow a\nstandard diffusion differential equation. Our program solved the following\ndifferential equation system based on Turk's \\cite{turk} work on texture\ngeneration :\n\n\\begin{eqnarray}\n  A(t) &=& F(A, B) + D_A \\nabla^2 A \\\\\n  B(t) &=& G(A, B) + D_B \\nabla^2 B\n\\end{eqnarray}\n\nwhere $F(A, B) = D_s (16 - A B)$ and $G(A, B) = A B - B - \\beta$. $D_A$ and\n$D_B$ are diffusion speeds for both chemicals, $D_S$ is the reaction speed,\nand $\\beta$ is the decay rate of $B$.\n\n\\section{Technical solutions and challenges}\n\nAs can be seen in the \\verb|README| file for \\verb|PyMoprhogenesis|, we\nimplemented this solution in a graphical application based on Qt and OpenGL\nusing python bindings. The application can also be launched from the command\nline in order to be able to easily specify parameters for automated batch\nruns.\n\nWe encountered two problems in implementing this project : poor performance\nfor mathematical calculations in python, and sensitivity of the output to\nsmall changes in the input parameters ($D_A$, $D_B$, $D_s$, $\\beta$).\n\nTo improve performance, we used Blitz++ \\cite{weave} \\cite{performancepython}.\nThis allowed us to manipulate NumPy arrays in python when speed wasn't an\nissue, i.e. for glue code : passing the image to OpenGL as a texture was coded\npurely in python, for instance. On the other hand, when performance was\nrequired, for instance for the diffusion calculations, we were able to\nseamlessly manipulate the same arrays in C++ code directly embedded in our\npython code, and compiled and cached at run-time so as to have no explicit\ncompilation phase and near-native performance. We didn't do any rigourous\nbenchmarks, but the performance improvement was by several orders of\nmagnitude, going from more than a second per iteration to less than a\nhundredth of a second.\n\nTo find adequate values for the parameters, we added an option to\nautomatically run the program from a set of given parameter values, and coded\na script that outputted 80 images obtained from these values at iteration\n1000. We then compared the images, and be exploring values around the most\ninteresting image outputs, obtained some results summed up in section\n\\ref{sec:results}.\n\n\\section{Results} % (fold)\n\\label{sec:results}\n\nOur goal was to produce textures that were as close as possible to real world\nanimal skin patterns. As we were using only one pigmented chemical, and since\nthe parameter space is very large, the results we obtained were not perfect.\nWe did however obtain the following series of pictures, with accompanying\nparameter ranges.\n\n\\subsection{Stripes} % (fold)\n\\label{sub:stripes}\n\nWe obtained stripes with $D_a > 10 * D_b$. The width of the stripes decreases when $D_s$ increases.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=5cm]{img/stripes.png}\n\\end{figure}\n\n% subsection stripes (end)\n\n\\subsection{Dots} % (fold)\n\\label{sub:dots}\n\nWe obtained dots with $5 * D_b > D_a > 3 * D_b$. The contrast of the dots\nrelative to the background decreases when $D_s$ increases.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=5cm]{img/dots.png}\n\\end{figure}\n\n% subsection dots (end)\n\n\\subsection{Spots} % (fold)\n\\label{sub:spots}\n\nWe obtained relatively large spots with $D_a >> D_b$. The spots' intensity decreases when $D_s$ increases.\n\n\\begin{figure}[!ht]\n  \\centering\n  \\includegraphics[width=5cm]{img/spots.png}\n\\end{figure}\n\n% subsection dots (end)\n\n% section results (end)\n\n\\section{Future work}\n\nThis work can be improved in the future by using machine learning algorithm\ntrained on local shape and texture features, extracted using wavelet\napproaches for instance, to search more efficiently for interesting values of\nthe input parameters.\n\nAdditionally, as not all textures seem to be reachable through this model when\nstarting with a purely random, white-noise, isotropic initial distribution for\nboth chemicals, we may need to add an anisotropic initialisation to allow us\nto generate more zebra like, strongly anisotropic textures.\n\n\\section{Conclusion}\n\nIn conclusion, we produced a python program reproducing results that show that\nvery simple chemical reactions can account for the creation of shape in living\nbeings. Our program also provides an interesting technological overview of\nsimple to deploy technologies to quickly develop applications in python with\nperformance sufficient for time-consuming numerical calculations.\n\n\\begin{thebibliography}{99} % (fold)\n\n\\bibitem{turing}\n  Alan Turing,\n  The Chemical Basis of Morphogenesis,\n  \\emph{Transactions of the Royal Society B}, Vol. 237, pp. 37-72 (August 14, 1952).\n\n\\bibitem{turk}\n  Greg Turk,\n  Generating Textures on Arbitrary Surfaces Using Reaction-Diffusion,\n  \\emph{Computer Graphics}, Vol. 25, No. 4, (SIGGRAPH 91), pp. 289-298, July 1991.\n\n\\bibitem{human_genome}\n  International Human Genome Sequencing Consortium,\n  Finishing the euchromatic sequence of the human genome.\n  \\emph{Nature}, 431 (7011): 931-45, 2004.\n\n\\bibitem{lawlor}\n  Orion Sky Lawlor,\n  Reaction-Diffusion Textures, \\\\\n  \\url{http://charm.cs.uiuc.edu/users/olawlor/projects/2003/rd/}\n\n\\bibitem{jennings}\n  Christopher G. Jennings, \\\\\n  Turing's Reaction-Diffusion Model of Morphogenesis, \\\\\n  \\url{http://www.sfu.ca/~cjenning/toybox/turingmorph/}\n\n\\bibitem{performancepython}\n\tPrabhu Ramachandran et al.,\n  A comparison of weave with NumPy, Pyrex, Psyco, Fortran and C++ for solving Laplace's equation, \\\\\n\t\\url{http://www.scipy.org/PerformancePython}\n\n\\bibitem{weave}\n\tWeave, a python package allowing the inclusion of C/C++ code within python code,\n\t\\url{http://www.scipy.org/Weave}\n\n\\end{thebibliography}% (end)\n\n\\end{document}\n", "meta": {"hexsha": "8adf4d86b13c3b9d6fabfa99afad4c1b49d89244", "size": 7126, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/report.tex", "max_stars_repo_name": "thomasdeniau/pyfauxfur", "max_stars_repo_head_hexsha": "7862bf1a6f7a3302c3cc0bb2547e586ccead98f1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-02-28T21:38:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T01:14:44.000Z", "max_issues_repo_path": "report/report.tex", "max_issues_repo_name": "thomasdeniau/pyfauxfur", "max_issues_repo_head_hexsha": "7862bf1a6f7a3302c3cc0bb2547e586ccead98f1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-03-11T16:41:46.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-14T20:30:57.000Z", "max_forks_repo_path": "report/report.tex", "max_forks_repo_name": "thomasdeniau/pyfauxfur", "max_forks_repo_head_hexsha": "7862bf1a6f7a3302c3cc0bb2547e586ccead98f1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3571428571, "max_line_length": 106, "alphanum_fraction": 0.7615773225, "num_tokens": 1892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4011175889227343}}
{"text": "\\chapter{Objectives} \\label{ch-2}\n\n\\section{Problem Statement}\n\nThe overarching research objective can be expressed with the following statement:\n\n\\begin{statement*}\nThe primary research subject of this thesis will be to study algorithms for operations on non-commutative algebraic structures. In particular, the following problems will be considered:\n\n\\begin{itemize}\n    \\item Computing the minimal polynomial of Drinfeld modules of rank $r > 2$.\n    \\item Multiplication algorithms for Ore polynomials where $\\delta \\neq 0$.\n    \\item Algorithms for linear algebra over coefficient rings consisting of skew polynomials.\n\\end{itemize}\n\n\\end{statement*}\n\nThere are three major outcomes of this thesis that we anticipate:\n\n\\begin{enumerate}\n    \\item Provide sharper complexity bounds for existing algorithms.\n\n    \\item Develop new algorithms related to non-commutative structures on finite fields that are competitive with the current theory.\n    \n    \n    \\item Develop concrete implementations of both new and existing algorithms to provide empirical verification of the theoretically derived complexities.\n\\end{enumerate}\n\nWith regards to point 1, algebraic complexity is the more widely used model for performing complexity analysis of algorithms over finite fields. This is related to another issue, namely that computing the action of a map on an element of a finite field is often assigned $O(1)$ complexity regardless of the cost of computing the map for the first time. To provide a more consistent framework within which to analyze algorithms, we aim to convert a number of these bounds to a bit-complexity model.\n\n\n", "meta": {"hexsha": "120d0b792c5d496312bbfe1820b75c377031fb91", "size": 1628, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MainText/chapter2.tex", "max_stars_repo_name": "DocTrivial/Research-Proposal", "max_stars_repo_head_hexsha": "cf988f64aa400d4c398fe4cb6738a4b90264359d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MainText/chapter2.tex", "max_issues_repo_name": "DocTrivial/Research-Proposal", "max_issues_repo_head_hexsha": "cf988f64aa400d4c398fe4cb6738a4b90264359d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MainText/chapter2.tex", "max_forks_repo_name": "DocTrivial/Research-Proposal", "max_forks_repo_head_hexsha": "cf988f64aa400d4c398fe4cb6738a4b90264359d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.875, "max_line_length": 497, "alphanum_fraction": 0.7948402948, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4011175889227343}}
{"text": "\\chapter{Introduction}\n\nThis document is part of package\n{\\tt ffr-ElectronicStructure.jl} using plane wave basis set.\n\n{\\color{red} WARNING: This document is under heavy construction}\n\n\\section{Outline}\n\nFirst, I will describe the top level description about what\nthe a typical electronic structure calculation based on density functional\ntheory is carried out. After that, I will break it apart into\nsmaller pieces which are hopefully easier to implement and be understood.\n\nIn a typical DFT calculation we are trying to solve the so-called Kohn-Sham\nequations:\n\\begin{equation}\nH_{KS} \\psi_{KS} = e_{KS} \\psi_{KS}\n\\end{equation}\n\nTasks:\n\\begin{itemize}\n\\item Setting up data structure for PW basis set\n\\item Solving Poisson equation using FFT\n\\item Solving Schrodinger equation: diagonalization, energy minimization\n\\item Solving KS equation: SCF and energy minimzation\n\\end{itemize}\n", "meta": {"hexsha": "8a4b8bc6ea30f256fef96c96469c9efec508808c", "size": 886, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "PW/Doc/intro.tex", "max_stars_repo_name": "f-fathurrahman/ffr-ElectronicStructure.jl", "max_stars_repo_head_hexsha": "35dca9831bfc6a3e49bb0f3a5872558ffce4b211", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2018-01-03T02:19:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-29T13:30:20.000Z", "max_issues_repo_path": "PW/Doc/intro.tex", "max_issues_repo_name": "f-fathurrahman/ffr-ElectronicStructure.jl", "max_issues_repo_head_hexsha": "35dca9831bfc6a3e49bb0f3a5872558ffce4b211", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PW/Doc/intro.tex", "max_forks_repo_name": "f-fathurrahman/ffr-ElectronicStructure.jl", "max_forks_repo_head_hexsha": "35dca9831bfc6a3e49bb0f3a5872558ffce4b211", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-03-23T06:58:47.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-03T00:54:28.000Z", "avg_line_length": 31.6428571429, "max_line_length": 75, "alphanum_fraction": 0.7945823928, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5273165233795672, "lm_q1q2_score": 0.40110365767618644}}
{"text": "\\chapter{Lists}\n\nA list\\index{List} is an object consisting of a sequence of other objects\n(including lists themselves), separated by commas and surrounded by\nbraces.  Examples of lists are:\n\\begin{verbatim}\n        {a,b,c}\n\n        {1,a-b,c=d}\n\n        {{a},{{b,c},d},e}.\n\\end{verbatim}\nThe empty list is represented as\n\\begin{verbatim}\n\t{}.\n\\end{verbatim}\n\n\\section{Operations on Lists}\\index{List operation}\n\nSeveral operators in the system return their results as lists, and a user\ncan create new lists using braces and commas.  Alternatively, one can use\nthe operator LIST to construct a list.  An important class of operations\non lists are MAP and SELECT operations.  For details, please refer to the\nchapters on MAP, SELECT and the FOR command.  See also the documentation\non the ASSIST package.\n\nTo facilitate the use of\nlists, a number of operators are also available for manipulating\nthem. {\\tt PART(<list>,n)}\\ttindex{PART} for example will return the\n$n^{th}$ element of a list. {\\tt LENGTH}\\ttindex{LENGTH} will return the\nlength of a list.  Several operators are also defined uniquely for lists.\nFor those familiar with them, these operators in fact mirror the\noperations defined for Lisp lists.  These operators are as follows:\n\n\\subsection{LIST}\n\nThe operator LIST is an alternative to the usage of curly brackets. LIST\naccepts an arbitrary number of arguments and returns a list\nof its arguments. This operator is useful in cases where operators\nhave to be passed as arguments. E.g.,\n\\begin{verbatim}\nlist(a,list(list(b,c),d),e);       ->  {{a},{{b,c},d},e}\n\\end{verbatim}\n\n\\subsection{FIRST}\n\nThis operator\\ttindex{FIRST} returns the first member of a list.  An error\noccurs if the argument is not a list, or the list is empty.\n\n\\subsection{SECOND}\n\n{\\tt SECOND}\\ttindex{SECOND} returns the second member of a list.  An error\noccurs if the argument is not a list or has no second element.\n\n\\subsection{THIRD}\n\nThis operator\\ttindex{THIRD} returns the third member of a list.  An error\noccurs if the argument is not a list or has no third element.\n\n\\subsection{REST}\n\n{\\tt REST}\\ttindex{REST} returns its argument with the first element\nremoved.  An error occurs if the argument is not a list, or is empty.\n\n\\subsection{$.$ (Cons) Operator}\n\nThis operator\\ttindex{. (CONS)} adds (``conses'') an expression to the\nfront of a list.  For example:\n\\begin{verbatim}\n        a . {b,c}     ->   {a,b,c}.\n\\end{verbatim}\n\n\\subsection{APPEND}\n\nThis operator\\ttindex{APPEND} appends its first argument to its second to\nform a new list.\n{\\it Examples:}\n\\begin{verbatim}\n        append({a,b},{c,d})     ->     {a,b,c,d}\n        append({{a,b}},{c,d})   ->     {{a,b},c,d}.\n\\end{verbatim}\n\n\\subsection{REVERSE}\n\nThe operator {\\tt REVERSE}\\ttindex{REVERSE} returns its argument with the\nelements in the reverse order.  It only applies to the top level list, not\nany lower level lists that may occur.  Examples are:\\index{List operation}\n\\begin{verbatim}\n        reverse({a,b,c})        ->     {c,b,a}\n        reverse({{a,b,c},d})    ->     {d,{a,b,c}}.\n\\end{verbatim}\n\n\\subsection{List Arguments of Other Operators}\n\nIf an operator other than those specifically defined for lists is given a\nsingle argument that is a list, then the result of this operation will be\na list in which that operator is applied to each element of the list.  For\nexample, the result of evaluating {\\tt log\\{a,b,c\\}} is the expression\n{\\tt \\{LOG(A),LOG(B),LOG(C)\\}}.\n\nThere are two ways to inhibit this operator distribution.  Firstly, the\nswitch {\\tt LISTARGS},\\ttindex{LISTARGS} if on, will globally inhibit\nsuch distribution.  Secondly, one can inhibit this distribution for a\nspecific operator by the declaration {\\tt LISTARGP}.\\ttindex{LISTARGP} For\nexample, with the declaration {\\tt listargp log}, {\\tt log\\{a,b,c\\}} would\nevaluate to {\\tt LOG(\\{A,B,C\\})}.\n\nIf an operator has more than one argument, no such distribution occurs.\n\n\\subsection{Caveats and Examples}\n\nSome of the natural list operations such as {\\it member} or {\\it delete}\nare available only after loading the package {\\it ASSIST}.\n\nPlease note that a non-list as second argument to CONS\n(a \"dotted pair\" in LISP terms) is not allowed\nand causes an \"invalid as list\" error.\n\\begin{verbatim}\n a := 17 . 4;\n\n***** 17 4 invalid as list\n\\end{verbatim}\nAlso, the initialization of a scalar variable is not the empty list --\none has to set list type variables explicitly, as in the following\nexample:\n\\begin{verbatim}\n load_package assist;\n\n procedure lotto (n,m);\n  begin scalar list_1_n, luckies, hit;\n     list_1_n := {};\n     luckies := {};\n     for k:=1:n do list_1_n := k . list_1_n;\n     for k:=1:m do\n       << hit := part(list_1_n,random(n-k+1) + 1);\n          list_1_n := delete(hit,list_1_n);\n          luckies := hit . luckies >>;\n     return luckies;\n  end;                             % In Germany, try lotto (49,6);\n\\end{verbatim}\n\n{\\it Another example:} Find all coefficients of a multivariate\npolynomial with respect to a list of variables:\n\n\\begin{verbatim}\nprocedure allcoeffs(q,lis); % q : polynomial, lis: list of vars\n   allcoeffs1 (list q,lis);\n\nprocedure allcoeffs1(q,lis);\n  if lis={} then q else\n    allcoeffs1(foreach qq in q join coeff(qq,first lis),rest lis);\n\n\\end{verbatim}\n\n", "meta": {"hexsha": "7a9c3cdb75d7a725f3053dd41b21cd487a7d2549", "size": 5250, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "atomic_Decomp/Redlog/reduce.doc/list.tex", "max_stars_repo_name": "Korosensei42/AtomicDecomposition", "max_stars_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "atomic_Decomp/Redlog/reduce.doc/list.tex", "max_issues_repo_name": "Korosensei42/AtomicDecomposition", "max_issues_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "atomic_Decomp/Redlog/reduce.doc/list.tex", "max_forks_repo_name": "Korosensei42/AtomicDecomposition", "max_forks_repo_head_hexsha": "ca10f97c2cef1a258a4e9fade0a3133d1389d08e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8709677419, "max_line_length": 75, "alphanum_fraction": 0.7087619048, "num_tokens": 1396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.4011036576761863}}
{"text": "\\chapter*{Abstract}\nDifferent algorithms have been trained by the ATLAS collaboration to separate true hadronically decaying taus from QCD jets. The efficiency of these algorithms is compared in simulation and data and correction factors are derived to account for the differences that may arise from the simulation limitations. Our study makes use of $Z\\to\\tauh l$ events highly boosted in the transverse plane, where $l=e,\\mu$,  to evaluate the performance of the tau-ID algorithms for high-$\\pt$ taus. The scale factors are defined as\n\\begin{equation}\n\tC_{\\text{ID}}=\\frac{\\mathcal{E}_{\\text{MC}}}{\\mathcal{E}_{\\text{Data}}},\\nonumber\n\\end{equation}\nwhere $\\mathcal{E}$ is the efficiency of the algorithms measured in the data and the simulation. In this report we present the value obtained for the scale factors for the classifier \\textit{tight-ID} working point. The values are $C_{\\text{Tight-ID}}=0.989\\pm 0.012\\text{(stat)}\\pm 0.024\\text{(lumi)}\\pm 0.028\\text{(sys)}$ for the muon-tau final state and $C_{\\text{Tight-ID}}=0.974\\pm 0.014\\text{(stat)}\\pm 0.023\\text{(lumi)}\\pm 0.029\\text{(sys)}$ for the electron-tau final state.\n\n\n", "meta": {"hexsha": "058ab13f72b243827268ae62960d9c6dc0d14be9", "size": 1139, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/0_2-abstract.tex", "max_stars_repo_name": "diegobaronm/1st-Year-Report", "max_stars_repo_head_hexsha": "5089e6bb20e018637116c454ceb9016fa30e5b90", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/0_2-abstract.tex", "max_issues_repo_name": "diegobaronm/1st-Year-Report", "max_issues_repo_head_hexsha": "5089e6bb20e018637116c454ceb9016fa30e5b90", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/0_2-abstract.tex", "max_forks_repo_name": "diegobaronm/1st-Year-Report", "max_forks_repo_head_hexsha": "5089e6bb20e018637116c454ceb9016fa30e5b90", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 126.5555555556, "max_line_length": 517, "alphanum_fraction": 0.7576821773, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.4011036576761863}}
{"text": "\\section{Trajectory Optimization Framework}\\label{sec:framework}\nIn addition to providing standardized multi-sensor data, we have created a framework for developing and testing algorithms that aid navigation, where ``navigation'' is defined as continuous self-localization relative to a local or global frame. This framework supports our own data sets as well as user-supplied data. It serves two major purposes: i) To facilitate the development of new trajectory optimization algorithms with a focus on alternative sensors other than GPS; and ii) To assist system integrators who must test a variety of sensors and algorithms on a level playing field and combine them to achieve desired accuracy. Our approach is to define the broad structure of the navigation problem while leaving the details to be implemented differently for each application.\n\nThe framework consists of four interfaces (abstract classes) that divide the navigation problem into manageable components, as illustrated in Figure \\ref{fig:components}. A \\texttt{\\small{DynamicModel}} is an algorithm that relates a set of generic parameters to the rigid-body trajectory of a physical system such as a car or airplane. It also generates ``costs'', which are discussed later in this section. Sensor data comes into the system through a customizable hardware abstraction class labeled \\texttt{\\small{DataContainer}}. Each \\texttt{\\small{Measure}} relates sensor data to a trajectory hypothesis and generates additional costs. Finally, at the core of the framework is the \\texttt{\\small{Optimizer}}, which is an algorithm that minimizes a combination of costs by intelligently generating and modifying the parameters of one or more \\texttt{\\small{DynamicModel}} instances and passing them through zero or more \\texttt{\\small{Measure}} instances.\n\n\\begin{figure}[!htp]\n  \\begin{center}\n  \\includegraphics[width=0.97\\linewidth]{SimpleBlockDiagram.png}\n  \\caption{\\label{fig:components}Block diagram of framework components.}\n  \\end{center}\n  \\vspace{-15pt}\n\\end{figure}\n\nA user interacts with the framework by specifying a set of components that derive from the framework classes. These components represent the physical system and define ``optimal'' for a specific application. The framework then sets up a scalar objective function to be evaluated and optimized. Further details of this approach are provided below, and framework code is available in both MATLAB and C++ online \\cite{functionalnavigation}.\n\n\\subsection{Dynamic Model}\\label{sec:dynamics}\nConsider the following canonical state transition models for continuous and discrete nonlinear systems:\n\n\\begin{equation}\n\\underbrace {{\\mathbf{\\dot x}}_t  = {\\mathbf{f}}\\left( {{\\mathbf{x}}_t ,{\\mathbf{u}}_t ,{\\mathbf{v}}_t } \\right)}_{{\\text{continuous}}}\\quad \\quad \\underbrace {{\\mathbf{x}}_{n + 1}  = {\\mathbf{f}}\\left( {{\\mathbf{x}}_n ,{\\mathbf{u}}_n ,{\\mathbf{v}}_n } \\right)}_{{\\text{discrete}}}.\n\\end{equation}\n\nThese equations have been established to model the dynamics of numerous physical systems, from Brownian particles to holonomic ground vehicles, fighter jets, and even animals. They are typically placed in an integration loop, such that the state $\\mathbf{x}$ is computed incrementally at increasing time instants $t$, given an initial condition. The symbols $\\mathbf{x}$, $\\mathbf{u}$, and $\\mathbf{v}$ all represent vector-valued functions indexed by time. The input $\\mathbf{u}$ represents data that is known, and the input $\\mathbf{v}$ represents parameters whose probability distributions are known. If an interpolation method is specified, then both the continuous and discrete models can be written in \\emph{functional} form as follows:\n\n\\begin{equation}\n{\\mathbf{x}} = {\\mathbf{F}}\\left( {{\\mathbf{v}};{\\mathbf{u}}} \\right).\n\\end{equation}\n\nOur \\texttt{\\small{DynamicModel}} class standardizes the interface to $\\mathbf{F}$. It requires that $\\mathbf{x}$ contain a $C^1$ continuous $6$-DOF rigid-body trajectory relative to an Earth-Centered Earth-Fixed (ECEF) frame. It accesses the data $\\mathbf{u}$ implicitly, a detail that we notate using a semicolon ($;$) in the argument list. It requires that each parameter vector $\\mathbf{v}_n$ consist of logical and/or integer parameters. And, it defines an indexing system that allows the domain of $\\mathbf{x}$ to grow with the domain of $\\mathbf{v}$ in a consistent manner as time moves forward. Finally, assuming that each parameter vector $\\mathbf{v}_n$ is independently distributed, the \\texttt{\\small{DynamicModel}} associates a cost function $r$ with the negative log likelihood of the normalized probability density of $\\mathbf{v}_n$ as follows\n\n\\begin{equation}\nc_n = r\\left(\\mathbf{v}_n\\right) = -\\operatorname{ln}\\left(\\frac{\\operatorname{pdf}\\left(\\mathbf{v}_n\\right)}{\\left\\| {\\operatorname{pdf}\\left( { \\mathbf{v}_n } \\right)} \\right\\|_\\infty}\\right).\n\\end{equation}\n\n\\subsection{Measure}\\label{sec:measures}\nMany sensors can be modeled by the canonical form\n\n\\begin{equation}\n\\mathbf{y}_n  = {\\mathbf{g}}\\left( {\\mathbf{x}_n ,\\mathbf{u}_n ,\\mathbf{w}_n } \\right)\n\\label{eqn:function_measurement}\n\\end{equation}\n\n\\noindent where each measurement $\\mathbf{y}_n$ arises from the instantaneous state $\\mathbf{x}_n$, the known data $\\mathbf{u}_n$, and the stochastic vector-valued function $\\mathbf{w}_n$. However, some measurements of interest cannot be accurately modeled in this form, because they are not inherently instantaneous. A prime example is a feature match between two images that were acquired at different times. Regardless of whether one uses Optical Flow \\cite{Lucas1981}, SIFT \\cite{SIFT}, normalized cross-correlation \\cite{Lewis1995}, or another technique, the computed feature displacement will depend on the position and orientation of the sensor at each time. Another sensor example is a gyroscope, which can be modeled as if it measures instantaneous rotation rates, but is most accurately modeled as measuring changes in orientation over discrete time periods.\n\nOne approach to dealing with sensors of the type described above is to create a combining function $\\mathbf{\\psi}_{ab} = \\mathbf{\\gamma}\\left(\\mathbf{y}_a,\\mathbf{y}_b\\right)$, where the pair of indices labeled $ab$ indicate a measurement arising from two times, $n=a$ and $n=b$, sorted such that $a \\leq b$. This implies an indexing system that has a graph structure instead of a simple linear index. Each discrete time is associated with a node (or vertex), and each node pair forms an edge. In general, not all of the nodes are connected, making it an incomplete graph. This idea can be incorporated into Equation \\ref{eqn:function_measurement} by rewriting it in \\emph{functional} form\n\n\\begin{equation}\n\\mathbf{y}_{ab}  = {\\mathbf{g}}\\left( {\\mathbf{x},ab,\\mathbf{u},\\mathbf{w}} \\right)\n\\label{eqn:functional_measurement}\n\\end{equation}\n\n\\noindent where the sensor accesses its arguments as functions. The functional $\\mathbf{g}$ can evaluate the body trajectory at any time in its domain, which we assume includes the span $t\\in\\left[t_a,t_b\\right]$. Likewise, it can evaluate its other arguments within their valid domains. As a generalization of Equation \\ref{eqn:function_measurement}, it can also be used to simulate measurements. However, for the purpose of trajectory optimization, simulated measurements may not be necessary, as long as there is a function that can test a hypothetical trajectory against a set of sensor data. Therefore, we define a cost \\emph{functional} $s$ associated with data from each algorithm or sensor $m$ as follows:\n\n\\begin{equation}\nc_{m,ab} = s_m\\left(\\mathbf{x},ab;\\mathbf{u}\\right) = -\\operatorname{ln}\\left(\\frac{\\operatorname{pdf}_m\\left(\\mathbf{u}|\\mathbf{x},ab\\right)}{\\left\\|{\\operatorname{pdf}_m\\left( \\mathbf{u} |\\mathbf{x},ab\\right)}\\right\\|_\\infty}\\right).\n\\end{equation}\n\nOur \\texttt{\\small{Measure}} class standardizes the interface to each $s_m$ without requiring explicit computation of $\\mathbf{y}$ or $\\mathbf{w}$. This not only has the potential to reduce processor burden, but it also makes it possible to wrap a wide variety of sensors and algorithms with a uniform interface. For example, suppose $s_1$ represents a ``smart camera'' running a sparse feature tracker, and $s_2$ represents a GPS unit. Since they both posess the same interface, they can be tested and their performance can be compared objectively, a property that is especially helpful to system integrators.\n\n\\subsection{Optimizer}\\label{sec:optimizer}\nOnce cost functions have been defined, putting together the overall objective is straightforward. All costs are additive by definition, which implies the assumption of independent distributions for each parameter vector in the \\texttt{\\small{DynamicModel}} and for each edge contributed by each \\texttt{\\small{Measure}}. Therefore, the optimization problem boils down to the composition\n\n\\begin{align}\\label{eqn:objective}\n{\\mathbf{v}}^ * &= \\mathop {\\operatorname{argmin} }\\limits_{\\mathbf{v}} \\left\\lbrace \\sum\\limits_n {c_n }  + \\sum\\limits_m {\\sum\\limits_{ab} {c_{m,ab} } } \\right\\rbrace \\\\\n \\nonumber &= \\mathop { \\operatorname{argmin} }\\limits_{\\mathbf{v}} \\left\\lbrace \\sum\\limits_n {r\\left( {{\\mathbf{v}}_n } \\right)}  + \\sum\\limits_m {\\sum\\limits_{ab} {s_m \\left( {{\\mathbf{F}}\\left( {{\\mathbf{v}};{\\mathbf{u}}} \\right),ab;{\\mathbf{u}}} \\right)} } \\right\\rbrace\n\\end{align}\n\n\\noindent where the solution ${\\mathbf{v}}^{*}$ is an optimal parameter hypothesis. To find the optimal trajectory ${\\mathbf{x}}^{*}$, this needs to be inserted back through the dynamic model as follows:\n\n\\begin{equation}\n{\\mathbf{x}}^{*} = {\\mathbf{F}}\\left( {{\\mathbf{v}}^{*};{\\mathbf{u}}} \\right).\n\\end{equation}\n\nOur \\texttt{\\small{Optimizer}} class wraps algorithms that query $r$ and $s$ in order to search for global minima in Equation \\ref{eqn:objective}. In general, neither convexity nor uniqueness of solution are guaranteed; however, specific sets of components can be designed to offer these guarantees. To facilitate efficient optimization, the costs can be computed individually before the summation takes place. This formulation suggests automated learning of the relationship between time indexed parameters and time indexed graphs of costs, a subject beyond the scope of this paper. In future work, we plan to demonstrate that our framework generalizes a wide range of trajectory optimization techniques including EKF, UKF, gradient descent, genetic algorithm, simplex, and the pose graph method \\cite{OlsonGraph2006}.\n", "meta": {"hexsha": "7de887f8bf50f937c6b18e485c72101763adf8ca", "size": 10494, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/PLANS2010/working/ssci.tex", "max_stars_repo_name": "dddvision/functionalnavigation", "max_stars_repo_head_hexsha": "1e2e9688072418ab441669ff8a09ae33e60cd9e1", "max_stars_repo_licenses": ["Unlicense", "MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-09-06T03:09:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-20T06:03:50.000Z", "max_issues_repo_path": "docs/PLANS2010/working/ssci.tex", "max_issues_repo_name": "dddvision/functionalnavigation", "max_issues_repo_head_hexsha": "1e2e9688072418ab441669ff8a09ae33e60cd9e1", "max_issues_repo_licenses": ["Unlicense", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/PLANS2010/working/ssci.tex", "max_forks_repo_name": "dddvision/functionalnavigation", "max_forks_repo_head_hexsha": "1e2e9688072418ab441669ff8a09ae33e60cd9e1", "max_forks_repo_licenses": ["Unlicense", "MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-03-14T21:55:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-02T19:34:52.000Z", "avg_line_length": 139.92, "max_line_length": 960, "alphanum_fraction": 0.7710120069, "num_tokens": 2601, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.523420348936324, "lm_q1q2_score": 0.40109368605174}}
{"text": "\\documentclass[10pt,a4paper]{article}\n\\usepackage{amsmath,amssymb,bm,makeidx,subfigure}\n\\usepackage[italian,english]{babel}\n\\usepackage[center,small]{caption}[2007/01/07]\n\\usepackage{fancyhdr}\n\\usepackage{color}\n\\usepackage{graphicx}\n\n\\definecolor{blu}{rgb}{0,0,1}\n\\definecolor{verde}{rgb}{0,1,0}\n\\definecolor{rosso}{rgb}{1,0,0}\n\\definecolor{viola}{rgb}{1,0,1}\n\\definecolor{arancio}{rgb}{1,0.5,0}\n\\definecolor{celeste}{rgb}{0,1,1}\n\\definecolor{rosa}{rgb}{1,0.3,0.5}\n\n\\oddsidemargin = 12pt\n\\topmargin = 0pt\n\\textwidth = 440pt\n\\textheight = 650pt\n\n\\makeindex\n\n\\begin{document}\n\n\\section{Structure of the observables}\n\nLet us start from Eq.~(2.6) of Ref.~\\cite{Scimemi:2017etj}, that is\nthe fully differential cross section for lepton-pair production in the\nregion in which the TMD factorisation applies, $i.e.$ $q_T \\ll\nQ$. After some minor manipulations, it reads:\n\\begin{equation}\\label{eq:crosssection}\n  \\frac{d\\sigma}{dQ dy dq_T} =\n  \\frac{16\\pi\\alpha^2q_T}{9 Q^3} H(Q,\\mu) \\sum_q C_q(Q)\n  \\int\\frac{d^2\\mathbf{b}}{4\\pi} e^{i \\mathbf{b}\\cdot \\mathbf{q}_T} \\overline{F}_q(x_1,\\mathbf{b};\\mu,\\zeta) \\overline{F}_{\\bar{q}}(x_2,\\mathbf{b};\\mu,\\zeta)\\,,\n\\end{equation}\nwhere $Q$, $y$, and $q_T$ are the invariant mass, the rapidity, and\nthe transverse momentum of the lepton pair, respectively, while\n$\\alpha$ is the electromagnetic coupling, $H$ is the appropriate QCD\nhard factor that can be perturbatively computed, and $C_q$ are the\neffective electroweak charges. In addition, the variables $x_1$ and\n$x_2$ are functions of $Q$ and $y$ and are given by:\n\\begin{equation}\\label{eq:Bjorkenx12}\n  x_{1,2} = \\frac{Q}{\\sqrt{s}}e^{\\pm y}\\,,\n\\end{equation}\nbeing $\\sqrt{s}$ the centre-of-mass energy of the collision. In\nEq.~(\\ref{eq:crosssection}) we are using the short-hand notation:\n\\begin{equation}\n\\overline{F}_q(x,\\mathbf{b};\\mu,\\zeta) \\equiv xF_q(x,\\mathbf{b};\\mu,\\zeta)\\,,\n\\end{equation}\nthat is convenient for the implementation. The scales $\\mu$ and\n$\\zeta$ are introduced as a consequence of the removal of UV and\nrapidity divergences in the definition of the TMDs. Despite these\nscales are arbitrary scales, they are typically chosen\n$\\mu=\\sqrt{\\zeta}=Q$. Therefore, for all practical purposes their\npresence is fictitious.\n\nThe computation-intensive part of Eq.(\\ref{eq:crosssection}) has the\nform of the integral:\n\\begin{equation}\\label{eq:integral}\nI_{ij}(x_1,x_2,q_T;\\mu,\\zeta)=\\int\\frac{d^2\\mathbf{b}}{4\\pi} e^{i \\mathbf{b}\\cdot \\mathbf{q}_T} \\overline{F}_i(x_1,\\mathbf{b};\\mu,\\zeta) \\overline{F}_{j}(x_2,\\mathbf{b};\\mu,\\zeta)\\,.\n\\end{equation}\nwhere $\\overline{F}_{i(j)}$ are combinations of evolved TMD PDFs. At\nthis stage, for convenience, $i$ and $j$ do not coincide with $q$ and\n$\\bar{q}$ but they are linked through a simple linear\ntransformation. The integral over the bidimensional impact parameter\n\\textbf{b} has to be taken. However, $\\overline{F}_{i(j)}$ only depend\non the absolute value of \\textbf{b}, therefore Eq.~(\\ref{eq:integral})\ncan be written as:\n\\begin{equation}\\label{eq:integral2}\nI_{ij}(x_1,x_2,q_T;\\mu,\\zeta)=\\frac12\\int_0^\\infty db\\,b J_0(bq_T)  \\overline{F}_i(x_1,b;\\mu,\\zeta) \\overline{F}_{j}(x_2,b;\\mu,\\zeta)\\,.\n\\end{equation}\nwhere $J_0$ is the zero-th order Bessel function of the first kind\nwhose integral representation is:\n\\begin{equation}\nJ_0(x) = \\frac1{2\\pi}\\int_0^{2\\pi} d\\theta e^{ix\\cos(\\theta)}\\,.\n\\end{equation}\nThe evolved quark TMD PDF $\\overline{F}_i$ at the final scales $\\mu$\nand $\\zeta$ is obtained by multiplying the same distribution at the\ninitial scales $\\mu_0$ and $\\zeta_0$ by a single evolution factor\n$R_q$(\\footnote{Note that in Eq.~(\\ref{eq:crosssection}) the gluon TMD\n  PDF $\\overline{F}_g$ is not involved. If also the gluon TMD PDF was\n  involved, it would evolve by means of a different evolution factor\n  $R_g$.}).  that is:\n\\begin{equation}\\label{eq:evolution}\n  \\overline{F}_i(x,b;\\mu,\\zeta) = R_q(\\mu_0,\\zeta_0\\rightarrow \\mu,\\zeta;b)\n  \\overline{F}_i(x,b;\\mu_0,\\zeta_0)\\,.\n\\end{equation}\n\nThe initial scale TMD PDFs at small values $b$ can be written as:\n\\begin{equation}\\label{eq:LOconv}\n\\overline{F}_i(x,b;\\mu_0,\\zeta_0) = \\sum_{j=g,q(\\bar{q})}x\\int_x^1\\frac{dy}{y}C_{ij}(y;\\mu_0,\\zeta_0)f_j\\left(\\frac{x}{y},\\mu_0\\right)\\,,\n\\end{equation}\nwhere $f_j$ are the collinear PDFs (including the gluon) and $C_{ij}$\nare the so-called matching functions that are perturbatively\ncomputable and are currently known to NNLO, $i.e.$\n$\\mathcal{O}(\\alpha_s^2)$. If we define:\n\\begin{equation}\n\\overline{f}_i\\left(x,\\mu_0\\right) = xf_i\\left(x,\\mu_0\\right)\\,,\n\\end{equation}\nEq.~(\\ref{eq:LOconv}) can be written as:\n\\begin{equation}\\label{eq:LOconvMod}\n\\overline{F}_i(x,b;\\mu_0,\\zeta_0) =\n\\sum_{j=g,q(\\bar{q})}\\int_x^1dy\\,C_{ij}(y;\\mu_0,\\zeta_0)  \\overline{f}_i\\left(\\frac{x}{y},\\mu_0\\right)\\,.\n\\end{equation}\nPutting Eqs.~(\\ref{eq:evolution}) and~(\\ref{eq:LOconvMod}), one finds:\n\\begin{equation}\\label{eq:pertTMD}\n  \\overline{F}_i(x,b;\\mu,\\zeta) = R_q(\\mu_0,\\zeta_0\\rightarrow \\mu,\\zeta;b)\n  \\sum_{j=g,q(\\bar{q})}\\int_x^1dy\\,C_{ij}(y;\\mu_0,\\zeta_0)  \\overline{f}_i\\left(\\frac{x}{y},\\mu_0\\right)\\,.\n\\end{equation}\n\nMatching and evolution are affected by non-perturbative effects that\nbecome relevant at large $b$. In order to account for such effects,\none usually introduces a phenomenological function $f_{\\rm NP}$. In\nthe traditional approach (CSS~\\cite{Collins:2011zzd}), the $b$-space\nTMDs get a multiplicative correction that does not depend on the\nflavour. In addition, the perturbative content of the TMDs is smoothly\ndamped away at large $b$ by introducing the so-called\n$b_*$-prescription:\n\\begin{equation}\\label{eq:LOconvNP1}\n  \\overline{F}_i(x,b;\\mu,\\zeta) \\rightarrow \\overline{F}_i(x,b_*(b);\\mu,\\zeta) f_{\\rm NP}(x,b,\\zeta)\\,,\n\\end{equation}\nwhere $b_*\\equiv b_*(b)$ is a monotonic function of the impact\nparameter $b$ such that:\n\\begin{equation}\n  \\lim_{b\\rightarrow 0}\n  b_*(b) = b_{\\rm min}\\quad\\mbox{and}\\quad\\lim_{b\\rightarrow \\infty}\n  b_*(b) = b_{\\rm max}\\,,\n\\end{equation}\nbeing $b_{\\rm min}$ and $b_{\\rm max}$ constant values both in the\nperturbative region. Including the non-perturbative function,\nEq.~(\\ref{eq:integral2}) becomes:\n\\begin{equation}\\label{eq:integral3}\n\\begin{array}{l}\n\\displaystyle I_{ij}(x_1,x_2,q_T;\\mu,\\zeta) = \\displaystyle \\int_0^\\infty db\\,J_0(bq_T)\\left[\\frac{b}2 \n\\overline{F}_i(x_1,b_*(b);\\mu,\\zeta) \\overline{F}_{j}(x_2,b_*(b);\\mu,\\zeta) f_{\\rm NP}(x_1,b,\\zeta)\n  f_{\\rm NP}(x_2,b,\\zeta) \\right]\\\\\n\\\\\n\\displaystyle =\\frac{1}{q_T}\\int_0^\\infty d\\bar{b}\\,J_0(\\bar{b})\\left[\\frac{\\bar{b}}{2q_T} \n\\overline{F}_i(x_1,b_*\\left(\\frac{\\bar{b}}{q_T}\\right);\\mu,\\zeta) \\overline{F}_{j}(x_2,,b_*\\left(\\frac{\\bar{b}}{q_T}\\right);\\mu,\\zeta) f_{\\rm NP}\\left(x_1,\\frac{\\bar{b}}{q_T},\\zeta\\right)\n  f_{\\rm NP}\\left(x_2,\\frac{\\bar{b}}{q_T},\\zeta\\right) \\right]\n\\,.\n\\end{array}\n\\end{equation}\nEq.~(\\ref{eq:integral3}) is a Hankel tranform and can be efficiently\ncomputed using the so-called Ogata quadrature~\\cite{Ogata:quadrature}.\nEffectively, the computation of the integral in\nEq.~(\\ref{eq:integral}) is achieved through a weighted sum:\n\\begin{equation}\\label{eq:ogataquadrature}\n\\begin{array}{rcl}\nI_{ij}(x_1,x_2,q_T;\\mu,\\zeta) &\\simeq& \\displaystyle\n                                                     \\frac1{q_T}\\sum_{n=1}^N\n                                                     \\frac{w_n^{(0)}z_n^{(0)}}{2q_T} \n\\overline{F}_i\\left(x_1,b_*\\left\n                                       (\\frac{z_n^{(0)}}{q_T}\\right);\\mu,\\zeta\\right) \\overline{F}_j\\left(x_2,b_*\\left (\\frac{z_n^{(0)}}{q_T}\\right);\\mu,\\zeta\\right)\\\\\n\\\\\n&\\times&\\displaystyle f_{\\rm NP}\\left(x_1,\\frac{z_n^{(0)}}{q_T},\\zeta\\right)\n  f_{\\rm NP}\\left(x_2,\\frac{z_n^{(0)}}{q_T},\\zeta\\right)\\,,\n\\end{array}\n\\end{equation}\nwhere the unscaled coordinates $z_n^{(0)}$ and the weights $w_n^{(0)}$\ncan be precomputed in terms of the zero's of the Bessel function $J_0$\nand one single parameter (see Ref.~\\cite{Ogata:quadrature} for more\ndetails, specifically Eqs.~(5.1) and~(5.2) or\nAppendix~\\ref{app:OgataQuadrature} for the relevant formula to compute\nthe unscaled coordinates and the weights)\\footnote{The superscript 0\n  in $z_n^{(0)}$ and $w_n^{(0)}$ indicates that here we are performing\n  a Hankel tranform that involves the Bessel function of degree zero\n  $J_0$. This is useful in view of the next section in which the\n  integration over $q_T$ will give rise to a similar Hankel transform\n  with $J_0$ replaced by $J_1$. Also in that case the Ogata quadrature\n  algorithm can be applied but coordinates and weights will be\n  different.}. Based on the (empirically verified) assumption that the\nabsolute value of each term in the sum in the r.h.s. of\nEq.~(\\ref{eq:ogataquadrature}) is smaller than that of the preceding\none, the truncation number $N$ is chosen dynamically in such a way\nthat the $(N+1)$-th term is smaller in absolute value than a\nuser-defined cutoff relatively to the sum of the preceding $N$ terms.\n\nEq.~(\\ref{eq:ogataquadrature}) factors out the non-perturbative part\nof the calculation represented by $f_{\\rm NP}$ from the perturbative\ncontent. This is done on purpose to devise a method in which the\nperturbative content is precomputed and numerically convoluted with\nthe non-perturbative functions \\textit{a posteriori}. This is\nconvenient in view of a fit of the function $f_{\\rm NP}$.\n\nAs customary in QCD, the most convenient basis for the matching in\nEq.~(\\ref{eq:LOconv}) is the so-called ``evolution'' basis\n(\\textit{i.e.} $\\Sigma$, $V$, $T_3$, $V_3$, etc.). In fact, in this\nbasis the operator matrix $C_{ij}$ is almost diagonal with the only\nexception of crossing terms that couple the gluon and the singlet\n$\\Sigma$ distributions. As a consequence, this is the most convenient\nbasis for the computation of $I_{ij}$. On the other hand, TMDs in\nEq.~(\\ref{eq:crosssection}) appear in the so-called ``physical'' basis\n(\\textit{i.e.} $d$, $\\bar{d}$, $u$, $\\bar{u}$, etc.). Therefore, we\nneed to rotate $F_{i(j)}$ from the evolution basis, over which the\nindices $i$ and $j$ run, to the physical basis. This is done by means\nof an appropriate constant matrix $T$, so that:\n\\begin{equation}\\label{eq:lumiInterRot}\n\\overline{F}_{q}(x_1,b;\\mu,\\zeta)= \\sum_{i}T_{qi}F_{i}(x_1,b;\\mu,\\zeta)\\,,\n\\end{equation}\nand similarly for $\\overline{F}_{\\bar{q}}$. Putting all pieces\ntogether, one can conveniently write the cross section in\nEq.~(\\ref{eq:crosssection}) as:\n\\begin{equation}\\label{eq:fastdiffxsec}\n  \\frac{d\\sigma}{dQ dy dq_T} \\simeq\\sum_{n=1}^N w_n^{(0)} \\frac{z_n^{(0)}}{q_T}S\\left(x_1,x_2,\\frac{z_n^{(0)}}{q_T};\\mu,\\zeta\\right) f_{\\rm NP}\\left(x_1,\\frac{z_n^{(0)}}{q_T},\\zeta\\right) f_{\\rm NP}\\left(x_2,\\frac{z_n^{(0)}}{q_T},\\zeta\\right)\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:pertfact}\nS(x_1,x_2,b;\\mu,\\zeta) =\\frac{8\\pi\\alpha^2}{9 Q^3}\n    H(Q,\\mu) \\sum_q C_q(Q) \\left[\n\\overline{F}_q\\left(x_1,b_*(b);\\mu,\\zeta \\right)\\right] \\left[\n\\overline{F}_{\\bar{q}}\\left(x_2,b_*(b);\\mu,\\zeta \\right)\\right]\\,.\n\\end{equation}\nEq.~(\\ref{eq:fastdiffxsec}) allows one to precompute the weights $S$\nin such a way that the differential cross section in\nEq.~(\\ref{eq:crosssection}) can be computed as a simple weighted sum\nof the non-perturbative contribution. A misleading aspect of\nEq.~(\\ref{eq:pertfact}) is the fact that $S$ has five arguments. In\nactual facts, $S$ only depends on three independent variables. The\nreason is that $\\mu$ and $\\zeta$ are usually taken to be proportional\nto $Q$ by a constant factor. In addition $x_1$ and $x_2$ depend on $Q$\nand $y$ through Eq.~(\\ref{eq:Bjorkenx12}). Therefore, the full\ndependence on the kinematics of the final state of\nEq.~(\\ref{eq:crosssection}) can be specified by $Q$, $y$ and $q_T$.\n\n\\section{Integrating over the final-state kinematic variables}\n\nDespite Eq.~(\\ref{eq:fastdiffxsec}) provides a powerful tool for a\nfast computation of cross sections, it is often not sufficient to\nallow for a direct comparison to experimental data. The reason is that\nexperimental measurements of differential distributions are usually\ndelivered as integrated over finite regions of the final-state\nkinematic phase space. In other words, experiments measure quantities\nlike:\n\\begin{equation}\\label{eq:Intcrosssection}\n\\widetilde{\\sigma}=\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ \\int_{y_{\\rm min}}^{y_{\\rm max}}dy \\int_{q_{T,\\rm min}}^{q_{T,\\rm max}}dq_T\\left[\\frac{d\\sigma}{dQ dy dq_T} \\right]\\,.\n\\end{equation}\nAs a consequence, in order to guarantee performance, we need to\ninclude the integrations above in the precomputed factors. \n\n\\subsection{Integrating over $q_T$}\n\nThe integration over bins in $q_T$ can be carried out analytically\nexploiting the following property of Bessel's function:\n\\begin{equation}\n\\frac{d}{dx}\\left[x^mJ_m(x)\\right]=x^mJ_{m-1}(x)\\,,\n\\end{equation}\nthat leads to:\n\\begin{equation}\\label{eq:besselproperty}\n\\int dx\\,x J_0(x) = xJ_1(x)\\quad\\Rightarrow\\quad \\int_{x_1}^{x_2}\ndx\\,x J_0(x) = x_2J_1(x_2) - x_1J_1(x_1)\\,.\n\\end{equation}\nTo see it, we observe that the differential cross section in\nEq.~(\\ref{eq:crosssection}) has the following structure:\n\\begin{equation}\n  \\frac{d\\sigma}{dQ dy dq_T} \\propto \\int_0^\\infty db\\, q_T  J_0(bq_T)\\dots\n\\end{equation}\nwhere the ellipses indicate terms that do not depend on\n$q_T$. Therefore, using Eq.~(\\ref{eq:besselproperty}) we find:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle \\int_{q_{T,\\rm min}}^{q_{T,\\rm\n  max}}dq_T\\left[\\frac{d\\sigma}{dQ dy dq_T} \\right] \\propto \\int_0^\\infty db\\,\n  \\int_{q_{T,\\rm min}}^{q_{T,\\rm\n  max}} dq_T\\,   q_T J_0(bq_T)\\dots= \\\\\n\\\\\n\\displaystyle \\int_0^\\infty \\frac{db}{b^2}\\,\n  \\int_{bq_{T,\\rm min}}^{bq_{T,\\rm\n  max}} dx\\,   x J_0(x)\\dots=\\int_0^\\infty \\frac{db}{b}\\left[q_{T,\\rm\n  max}J_1(bq_{T,\\rm max}) - q_{T,\\rm\n  min}J_1(bq_{T,\\rm min})\\right]\\dots\\,.\n\\end{array}\n\\end{equation}\nTherefore, defining:\n\\begin{equation}\nK(q_T) \\equiv \\int dq_T\\left[\\frac{d\\sigma}{dQ dy dq_T} \\right]\n\\end{equation}\nas the indefinite integral over $q_T$ of the cross section in\nEq.~(\\ref{eq:crosssection}), we have that:\n\\begin{equation}\\label{eq:primitive}\n\\int_{q_{T,\\rm min}}^{q_{T,\\rm\n  max}}dq_T\\left[\\frac{d\\sigma}{dQ dy dq_T} \\right] = K(Q,y,q_{T,\\rm max})\n- K(Q,y,q_{T,\\rm min})\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:Kexplicit}\n\\begin{array}{l}\n \\displaystyle K(Q,y,q_T) =\n  \\frac{8\\pi\\alpha^2q_T}{9 Q^3} H(Q,\\mu) \\\\\n\\\\\n\\displaystyle \\times\n  \\int_0^\\infty db\\, J_1(bq_T) \\sum_q C_q(Q)\\overline{F}_q(x_1,b;\\mu,\\zeta) \\overline{F}_{\\bar{q}}(x_2,b;\\mu,\\zeta) f_{\\rm NP}(x_1,b,\\zeta)\n  f_{\\rm NP}(x_2,b,\\zeta)\\,,\n\\end{array}\n\\end{equation}\nthat can be computed using the Ogata quadrature as:\n\\begin{equation}\n  K(Q,y,q_T) \\simeq \\sum_{n=1}^N w_n^{(1)} S\\left(x_1,x_2,\\frac{z_n^{(1)}}{q_T};\\mu,\\zeta\\right) f_{\\rm NP}\\left(x_1,\\frac{z_n^{(1)}}{q_T},\\zeta\\right) f_{\\rm NP}\\left(x_2,\\frac{z_n^{(1)}}{q_T},\\zeta\\right)\\,,\n\\end{equation}\nwith $S$ defined in Eq.~(\\ref{eq:pertfact}). The unscaled coordinates\n$z_n^{(1)}$ and the weights $w_n^{(1)}$ can again be precomputed and\nstored in terms of the zero's of the Bessel function\n$J_1$. Eq.~(\\ref{eq:primitive}) reduces the integration in $q_T$ to a\ncalculation completely analogous to the unintegrated cross\nsection. This is particularly convenient because it avoids the\ncomputation a numerical integration.\n\n\\subsubsection{Kinematic cuts}\\label{sec:kincuts}\n\nIn the presence of kinematic cuts, such as those on the final-state\nleptons in Drell-Yan, the analytic integration over $q_T$ discussed\nabove cannot be performed. The reason is that the implementation of\nthese cuts effectively introduces a $q_T$-dependent function\n$\\mathcal{P}$(\\footnote{In fact, $\\mathcal{P}$ also depends on the\n  invariant mass $Q$ and the rapidity $y$ of the lepton pair that also\n  need to be integrated over.}) in the integral:\n\\begin{equation}\n  \\frac{d\\sigma}{dQ dy dq_T} \\propto \\int_0^\\infty db\\, q_T  J_0(bq_T)\\mathcal{P}(q_T)\\dots\\,,\n\\end{equation}\nthat prevents the direct use of Eq.~(\\ref{eq:besselproperty}).\n% However, integrating by parts, we can write(\\footnote{Notice that the\n%   lower bound of the integral in the r.h.s., that is 0 here, is\n%   actually arbitrary because the final result does not depend on\n%   it.}):\n% \\begin{equation}\n%   \\int_{q_{T,\\rm min}}^{q_{T,\\rm\n%       max}} dq_T\\, q_T J_0(bq_T) \\mathcal{P}(q_T)= \\frac{1}{b}\\left[q_T J_1(bq_T) \\mathcal{P}(q_T)- \\int_{0}^{q_{T}} d\\bar{q}_T\\, \\bar{q}_T J_1(b\\bar{q}_T) \\mathcal{P}'(\\bar{q}_T)\\right]\\Bigg|_{q_{T,\\rm min}}^{q_{T,\\rm\n%       max}}\\,.\n% \\end{equation}\n% Now, if we assume that $\\mathcal{P}$ is a slowly-varying function of\n% $q_T$ (\\textit{i.e.} $\\mathcal{P}'$ is small), we could, in first\n% approximation, neglect the second term in the r.h.s. of the equation\n% above. Unfortunately, despite $\\mathcal{P}$ is an actual\n% slowly-varying function of $q_T$, the contribution of the integral in\n% the r.h.s. is still large, particularly at large $q_T$. This is mostly\n% due to the fact that the integral over $b$ of $J_1(bq_T)$,\n% particularly for large values of $q_T$, is numerically large.\nSince $\\mathcal{P}$ is a slowly-varying function of $q_T$ over the\ntypical bin size, we can approximate the integral over the bins in\n$q_T$ as:\n\\begin{equation}\\label{eq:intbyparts}\n\\begin{array}{rcl}\n\\displaystyle  \\int_{q_{T,\\rm min}}^{q_{T,\\rm\n      max}} dq_T\\, q_T J_0(bq_T) \\mathcal{P}(q_T)&\\simeq&\\displaystyle\n  \\mathcal{P}\\left(\\frac{q_{T,\\rm max}+q_{T,\\rm min}}2\\right)\\int_{q_{T,\\rm min}}^{q_{T,\\rm\n      max}} dq_T\\, q_T J_0(bq_T) \\\\\n\\\\\n&=& \\displaystyle\\mathcal{P}\\left(\\frac{q_{T,\\rm max}+q_{T,\\rm\n    min}}2\\right) \\frac{1}{b}\\left[q_{T,\\rm max} J_1(bq_{T,\\rm max}) - q_{T,\\rm min} J_1(bq_{T,\\rm min}) \\right]\\,.\n\\end{array}\n\\end{equation}\nUnfortunately, this structure is inconvenient because it mixes\ndifferent bin bounds and prevents a recursive computation.\nHowever, we can try to go further and, assuming that the bin width is\nsmall enough, we can expand $\\mathcal{P}$ is the following ways:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle\\mathcal{P}\\left(\\frac{q_{T,\\rm max}+q_{T,\\rm\n    min}}2\\right)= \\mathcal{P}\\left(q_{T,\\rm min}+\\Delta q_T\\right) =\n  \\mathcal{P}\\left(q_{T,\\rm min}\\right) + \\mathcal{P}'\\left(q_{T,\\rm\n  min}\\right)\\Delta q_T +\\mathcal{O}\\left(\\Delta q_T^2\\right)\\,,\\\\\n\\\\\n\\displaystyle\\mathcal{P}\\left(\\frac{q_{T,\\rm max}+q_{T,\\rm\n    min}}2\\right)= \\mathcal{P}\\left(q_{T,\\rm max}-\\Delta q_T\\right) =\n  \\mathcal{P}\\left(q_{T,\\rm max}\\right) - \\mathcal{P}'\\left(q_{T,\\rm\n  max}\\right)\\Delta q_T +\\mathcal{O}\\left(\\Delta q_T^2\\right)\\,,\n\\end{array}\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:halfqTinterval}\n\\Delta q_T = \\frac{q_{T,\\rm max}- q_{T,\\rm min}}2\\,.\n\\end{equation}\nTherefore:\n\\begin{equation}\\label{eq:lastexpP}\n\\begin{array}{rcl}\n  \\displaystyle  b\\int_{q_{T,\\rm min}}^{q_{T,\\rm\n  max}} dq_T\\, q_T J_0(bq_T) \\mathcal{P}(q_T)&\\simeq&\\displaystyle\n                                                      q_{T,\\rm\n                                                      max}\n                                                      J_1(bq_{T,\\rm\n                                                      max})\\left[\n                                                      \\mathcal{P}\\left(q_{T,\\rm\n                                                      max}\\right)\n                                                      - \n                                                      \\mathcal{P}'\\left(q_{T,\\rm\n                                                      max}\\right)\\Delta\n                                                      q_T\\right]\\\\\n\\\\\n&-&\\displaystyle q_{T,\\rm\n                                                      min}\n                                                      J_1(bq_{T,\\rm\n                                                      min})\\left[\n                                                      \\mathcal{P}\\left(q_{T,\\rm\n                                                      min}\\right)\n                                                      +\n                                                      \\mathcal{P}'\\left(q_{T,\\rm\n                                                      min}\\right)\\Delta\n                                                      q_T\\right]\\,.\n\\end{array}\n\\end{equation}\nThe advantage of this formula as compared to Eq.~(\\ref{eq:intbyparts})\nis that each single term depends on one single bin-bound in $q_T$\nrather than on a combination of two consecutive bounds. Therefore, in\nthe presence of kinematic cuts, the actual form of the primitive\nfunction $K$ defined in Eq.~(\\ref{eq:primitive}) and given explicitly\nin Eq.~(\\ref{eq:Kexplicit}) is:\n\\begin{equation}\\label{eq:KexplicitCuts}\n\\begin{array}{l}\n \\displaystyle K(Q,y,q_T) =\n  \\frac{8\\pi\\alpha^2q_T}{9 Q^3} H(Q,\\mu)\n  \\left[\\mathcal{P}\\left(Q,y,q_{T}\\right) \\pm\n  \\mathcal{P}'\\left(Q,y,q_{T}\\right)\\Delta q_T\\right]\\\\\n\\\\\n\\displaystyle \\times\n  \\int_0^\\infty db\\, J_1(bq_T) \\sum_q C_q(Q)\\overline{F}_q(x_1,b;\\mu,\\zeta) \\overline{F}_{\\bar{q}}(x_2,b;\\mu,\\zeta) f_{\\rm NP}(x_1,b,\\zeta)\n  f_{\\rm NP}(x_2,b,\\zeta)\\,,\n\\end{array}\n\\end{equation}\nwhere I have explicitly reinstated the dependence of the function\n$\\mathcal{P}$ and its derivative with respect to $q_T$,\n$\\mathcal{P}'$, on $Q$ and $y$. In the square bracket in\nEq.~(\\ref{eq:KexplicitCuts}), the minus sign applies when $q_T$ is the\nupper bound of the bin and the plus sign when it is the lower bound\n(see Eq.~(\\ref{eq:lastexpP})). As discussed below, when integrating\nover bins in $Q$ and $y$, one should also integrate the functions\n$\\mathcal{P}$ and $\\mathcal{P}'$. However, we will argue that, in the\ninterpolation procedure discussed below, these functions can be\nextracted from the integrals in $Q$ and $y$ in a proper manner in such\na way to avoid computing the expensive function $\\mathcal{P}$ many\ntimes and, moreover, simplify enormously the structure of the\nresulting interpolation tables.\n\n\\subsection{On the position of the peak of the $q_T$ distribution}\n\nIt is interesting at this point to take a short detour to discuss the\nposition of the peak on the distribution in $q_T$ of the cross section\nin Eq.~(\\ref{eq:crosssection}). The peak can be located by setting the\nderivative in $q_T$ of the cross section equal to zero. To do so, we\nuse another property of Bessel's functions:\n\\begin{equation}\n\\frac{dJ_0(x)}{dx} = -J_1(x)\\,.\n\\end{equation}\nUsing this relation, it is easy to see that:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle 0 = \\frac{d}{dq_T}  \\left[\\frac{d\\sigma}{dQ dy dq_T}\\right]\n  =\\\\\n\\\\\n\\displaystyle  \\frac{8\\pi\\alpha^2}{9 Q^3} H(Q,\\mu) \n  \\int_0^\\infty db\\,b \\left[J_0(bq_T) -bq_TJ_1(bq_T)\\right] \n\\sum_q C_q(Q)\\overline{F}_q(x_1,b_*(b);\\mu,\\zeta)\n  \\overline{F}_{\\bar{q}}(x_2,b_*(b);\\mu,\\zeta)\\\\\n\\\\\n\\displaystyle \\times f_{\\rm NP}(x_1,b,\\zeta)\n  f_{\\rm NP}(x_2,b,\\zeta)\\,,\n\\end{array}\n\\end{equation}\nthat is equivalent to require that:\n\\begin{equation}\n  \\int_0^\\infty db\\,b \\left[J_0(bq_T) -bq_TJ_1(bq_T)\\right] \n  \\sum_q C_q(Q)\\overline{F}_q(x_1,b_*(b);\\mu,\\zeta) \\overline{F}_{\\bar{q}}(x_2,b_*(b);\\mu,\\zeta) f_{\\rm NP}(x_1,b,\\zeta)\n  f_{\\rm NP}(x_2,b,\\zeta) = 0\\,.\n\\end{equation}\nThe integral above can be solved numerically using the technique\ndiscussed above and the value of $q_T$ that satisfies this equation\nrepresents the position of the peak of the $q_T$ distribution.\n\n\\subsection{Integrating over $Q$ and $y$}\\label{sec:QyInt}\n\nAs a final step, we need to perform the integrals over $Q$ and $y$\ndefined in Eq.~(\\ref{eq:Intcrosssection}). To compute these integrals\nwe can only rely on numerical methods. Having reduced the integration\nin $q_T$ to the difference of the two terms in the r.h.s. of\nEq.~(\\ref{eq:primitive})(\\footnote{For the moment we ignore the\n  complication introduced by the presence of cuts on the final state\n  discussed in Sect.~\\ref{sec:kincuts}. We will come back on this\n  issue at the end of the section.}), we can concentrate on\nintegrating the function $K$ over $Q$ and $y$ for a fixed value of\n$q_T$:\n\\begin{equation}\n\\widetilde{K}(q_T)=\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ \\int_{y_{\\rm\n    min}}^{y_{\\rm max}}dy\\,K(Q,y,q_T)\\,,\n\\end{equation}\nsuch that:\n\\begin{equation}\n  \\widetilde{\\sigma} = \\widetilde{K} (q_{T,\\rm max})- \\widetilde{K} (q_{T,\\rm min})\\,.\n\\end{equation}\nTo this purpose, it is convenient to make explicit the dependence of\n$x_1$ and $x_2$ on $Q$ and $y$ using Eq.~(\\ref{eq:Bjorkenx12}). In\naddition, for the sake of simplicity we will identify the scales $\\mu$\nand $\\sqrt{\\zeta}$ with $Q$ (possible scale variations can be easily\nreinstated at a later stage) and thus drop one of the arguments from\nthe TMD distributions $\\overline{F}$ and from the hard factor $H$.\nThis yields:\n\\begin{equation}\\label{eq:finalintegral}\n\\begin{array}{rcl}\n\\displaystyle  \\widetilde{K}(q_T) &=& \\displaystyle \\frac{8\\pi q_T}{9} \\int_0^\\infty db\\, J_1(bq_T)\n  \\int_{Q_{\\rm min}}^{Q_{\\rm max}}\n  dQ \\int_{e^{y_{\\rm\n    min}}}^{e^{y_{\\rm max}}}\\frac{d\\xi}{\\xi}\\\\\n\\\\\n&\\times& \\displaystyle \n                         \\frac{1}{Q^3} \\alpha^2(Q) H(Q)\\sum_q C_q(Q)\\overline{F}_q\\left(\\frac{Q}{\\sqrt{s}}\\xi,b_*(b);Q\\right)\n                         \\overline{F}_{\\bar{q}}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b_*(b);Q\\right) \\\\\n\\\\\n&\\times& \\displaystyle f_{\\rm NP}\\left(\\frac{Q}{\\sqrt{s}}\\xi,b;Q\\right)\n  f_{\\rm NP}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b;Q\\right)\\,,\n\\end{array}\n\\end{equation}\nwhere we have performed the change of variable $e^{y} = \\xi$. Now we\ndefine one grid in $\\xi$, $\\{\\xi_\\alpha\\}$ with\n$\\alpha=0,\\dots,N_\\xi$, and one grid in $Q$, $\\{Q_\\tau\\}$ with\n$\\tau=0,\\dots,N_Q$, each of which with a set of interpolating\nfunctions $\\mathcal{I}$ associated. In addition, the grids are such\nthat: $\\xi_0 = e^{y_{\\rm min}}$ and $\\xi_{N_\\xi} = e^{y_{\\rm max}}$,\nand $Q_0 = Q_{\\rm min}$ and $Q_{N_Q} = Q_{\\rm max}$. More details on\nthe interpolation procedure are presented in\nAppendix~\\ref{app:LagrangeInterpolation}. This allows us to interpolate\nthe pair of functions $f_{\\rm NP}$ in Eq.~(\\ref{eq:finalintegral}) for\ngeneric values of $\\xi$ and $Q$ as:\n\\begin{equation}\\label{eq:interpolation}\nf_{\\rm NP}\\left(\\frac{Q}{\\sqrt{s}}\\xi,b;Q\\right) f_{\\rm NP}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b;Q\\right) \\simeq \\sum_{\\alpha=0}^{N_\\xi}\\sum_{\\tau=0}^{N_Q}\\mathcal{I}_\\alpha(\\xi)\\mathcal{I}_\\tau(Q) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\xi_\\alpha,b;Q_\\tau\\right) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\frac1{\\xi_\\alpha},b;Q_\\tau\\right)\\,.\n\\end{equation}\nPlugging the equation above into Eq.~(\\ref{eq:finalintegral}) we\nobtain:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle  \\widetilde{K}(q_T) &\\simeq& \\displaystyle \\frac{8\\pi q_T}{9} \\int_0^\\infty db\\, J_1(bq_T)\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_\\xi}\\Bigg[\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\mathcal{I}_\\tau(Q)\\, \n  \\frac{1}{Q^3} \\alpha^2(Q) H(Q) \n  \\\\\n\\\\\n&\\times& \\displaystyle \n                         \\int_{e^{y_{\\rm\n    min}}}^{e^{y_{\\rm max}}}d\\xi\\,\\mathcal{I}_\\alpha(\\xi)\\,\\frac{1}{\\xi} \\sum_q C_q(Q)\\overline{F}_q\\left(\\frac{Q}{\\sqrt{s}}\\xi,b_*(b);Q\\right)\n                         \\overline{F}_{\\bar{q}}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b_*(b);Q\\right)\\Bigg] \\\\\n\\\\\n&\\times& \\displaystyle f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\xi_\\alpha,b;Q_\\tau\\right) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\frac1{\\xi_\\alpha},b;Q_\\tau\\right)\\,.\n\\end{array}\n\\end{equation}\nFinally, the integration over $b$ can be performed using the Ogata\nquadrature as discussed above, so that:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle  \\widetilde{K}(q_T) &\\simeq& \\displaystyle \\sum_{n=1}^N\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_\\xi}\\Bigg[\\frac{8\\pi}{9} w_n^{(1)}\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\mathcal{I}_\\tau(Q)\\, \n  \\frac{1}{Q^3} \\alpha^2(Q) H(Q) \n\\\\\n\\\\\n&\\times& \\displaystyle \n                         \\int_{e^{y_{\\rm\n    min}}}^{e^{y_{\\rm max}}}d\\xi\\,\\mathcal{I}_\\alpha(\\xi)\\,\\frac{1}{\\xi} \\sum_q C_q(Q)\\overline{F}_q\\left(\\frac{Q}{\\sqrt{s}}\\xi,b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\n                         \\overline{F}_{\\bar{q}}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\\Bigg] \\\\\n\\\\\n&\\times& \\displaystyle f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\xi_\\alpha,\\frac{z_n}{q_T};Q_\\tau\\right) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\frac1{\\xi_\\alpha},\\frac{z_n}{q_T};Q_\\tau\\right)\\,.\n\\end{array}\n\\end{equation}\nIn conclusion, if we define:\n\\begin{equation}\\label{eq:weights}\n\\begin{array}{rcl}\n  \\displaystyle  W_{n\\tau\\alpha}(q_T) & \\equiv & \\displaystyle w_n^{(1)}\\frac{8\\pi}{9} \\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\mathcal{I}_\\tau(Q)\\, \n                                            \\frac{\\alpha^2(Q)}{Q^3} H(Q) \n                                            \\\\\n  \\\\\n                                 &\\times& \\displaystyle \n                                          \\int_{e^{y_{\\rm\n                                          min}}}^{e^{y_{\\rm max}}}d\\xi\\,\\mathcal{I}_\\alpha(\\xi)\\,\\frac{1}{\\xi} \\sum_q C_q(Q)\\overline{F}_q\\left(\\frac{Q}{\\sqrt{s}}\\xi,b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\n                                          \\overline{F}_{\\bar{q}}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\\,,\n\\end{array}\n\\end{equation}\nthe quantity $\\widetilde{K}(q_T)$ can be computed as:\n\\begin{equation}\\label{eq:finalinterpolated}\n\\widetilde{K}(q_T) \\simeq \\sum_{n=1}^N\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_\\xi} W_{n\\tau\\alpha}(q_T) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\xi_\\alpha,\\frac{z_n}{q_T};Q_\\tau\\right) f_{\\rm NP}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\frac1{\\xi_\\alpha},\\frac{z_n}{q_T};Q_\\tau\\right)\\,.\n\\end{equation}\nThe advantage of Eq.~(\\ref{eq:finalinterpolated}) is that the weights\n$W_{n\\alpha\\tau}$, that clearly depend on $q_T$ but also on the\nintervals $[Q_{\\rm min}:Q_{\\rm max}]$ and $[y_{\\rm min}:y_{\\rm max}]$,\ncan be precomputed once and for all for each of the experimental\npoints included in a fit and used to determine the function\n$f_{\\rm NP}$.  This provides a fast tool for the computation of\npredictions that makes the extraction of the non-perturbative part of\nthe TMDs much easier.\n\nIt is now time to discuss how the weights defined in\nEq.~(\\ref{eq:weights}) are affected by the presence of cuts as\ndiscussed in Sect.~\\ref{sec:kincuts}. In principle, the function\nbetween square brackets in Eq.~(\\ref{eq:KexplicitCuts}) should be\ninside the integrals in Eq.~(\\ref{eq:weights}) and integrated over the\nvariable $Q$ and $\\xi=e^y$. However, this turns out to be numerically\nproblematic because the phase-space-reduction function $\\mathcal{P}$\nis expensive to compute. On top of this, the fact that the factor\nbetween square brackets in Eq.~(\\ref{eq:KexplicitCuts}) depends on\nwhether $q_T$ is a lower or an upper integration bound would lead to a\nduplication of the weights to compute. In order to simplify the\ncomputation, we assume that the function $\\mathcal{P}$ and its\nderivative $\\mathcal{P}'$ are slowly varying functions of $Q$ and $y$\nover the typical grid interval of the grids in $Q$ and $\\xi$. In\naddition, the interpolating functions $\\mathcal{I}_\\tau(Q)$ and\n$\\mathcal{I}_\\alpha(\\xi)$ are strongly peaked at $Q_\\tau$ and\n$\\xi_\\alpha$, respectively. These considerations allow us to avoid\nintegrating explicitly $\\mathcal{P}$ and $\\mathcal{P}'$ over $Q$ and\n$\\xi$ and to replace the weights in Eq.~(\\ref{eq:weights}) with:\n\\begin{equation}\\label{eq:weightswithcuts}\n  \\displaystyle  W_{n\\tau\\alpha}(q_T) \\rightarrow \\left[\\mathcal{P}\\left(Q_\\tau,\\ln(\\xi_\\alpha),q_{T}\\right) \\pm\n  \\mathcal{P}'\\left(Q_\\tau,\\ln(\\xi_\\alpha),q_{T}\\right)\\Delta q_T\\right] W_{n\\tau\\alpha}(q_T)\\,.\n\\end{equation}\nAt the end of the day, the only additional information required to\nimplement cuts on the final state is the value of the\nphase-space-reduction function $\\mathcal{P}$ and its derivative\n$\\mathcal{P}'$ on all points of the bidimensional grid in $Q$ and\n$\\xi$ for all $q_T$ bin bounds. Eq.~(\\ref{eq:weightswithcuts}) will\nthen allow one to use the weights computed over the full phase space.\nWe will check the accuracy of this procedure by comparing it to the\nexplicit integration.\n\n\\subsection{Cross section differential in $x_F$}\n\nIn some cases, the Drell-Yan differential cross section may be\npresented as differential in the invariant mass of the lepton pair $Q$\nand, instead of the rapidity $y$, of the Feynman variable $x_F$\ndefined as:\n\\begin{equation}\n  x_F = \n  \\frac{Q}{\\sqrt{s}}\\left(e^{y} - e^{-y}\\right) =\n  \\frac{2Q}{\\sqrt{s}}\\sinh y = x_1-x_2\\,,\n\\end{equation}\nso that:\n\\begin{equation}\n\\frac{dx_F}{dy} = \\frac{2Q}{\\sqrt{s}}\\cosh y=x_1+x_2\\,.\n\\end{equation}\nTherefore:\n\\begin{equation}\n  \\frac{d\\sigma}{dQ dx_F dq_T} =\n  \\frac{dy}{dx_F}\\frac{d\\sigma}{dQ dy dq_T}=\n\\frac{\\sqrt{s}}{2Q\\cosh y}\\frac{d\\sigma}{dQ dy dq_T}=\\frac1{x_1+x_2}\\frac{d\\sigma}{dQ dy dq_T}\n\\end{equation}\nwith:\n\\begin{equation}\n  y(x_F,Q) =\n  \\sinh^{-1}\\left(\\frac{x_F\\sqrt{s}}{2Q}\\right) =\n  \\ln\\left[\\frac{\\sqrt{s}}{2Q}\\left(x_F+\\sqrt{x_F^2 + \\frac{4Q^2}{s}}\\right)\\right]\\,,\n\\end{equation}\nso that:\n\\begin{equation}\\label{eq:x12ofxFQ}\nx_1 = \\frac12\\left(x_F+\\sqrt{x_F^2 +\n    \\frac{4Q^2}{s}}\\right)\\quad\\mbox{and}\\quad x_2 = \\frac{Q^2}{sx_1}\\,.\n\\end{equation}\nTherefore, we can compute the integral:\n\\begin{equation}\n\\widetilde{I}(q_T)=\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ \\int_{x_{F,\\rm\n    min}}^{x_{F,\\rm max}}dx_F\\,I(Q,x_F,q_T)\\,,\n\\end{equation}\nwhere $I$ is the primitive in $q_T$ of the cross section differential\nin $x_F$:\n\\begin{equation}\nI(Q,x_F,q_T) = \\int dq_T\\left[\\frac{d\\sigma}{dQ dx_F dq_T}\\right]\\,,\n\\end{equation}\nfollowing the same steps of Sect.~\\ref{sec:QyInt}. This leads to:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle  \\widetilde{I}(q_T) &\\simeq& \\displaystyle \\sum_{n=1}^N\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_x}\\overline{W}_{n\\tau\\alpha}(q_T) f_{\\rm NP}\\left(x_{1,\\alpha\\tau},\\frac{z_n}{q_T};Q_\\tau\\right) f_{\\rm NP}\\left(x_{2,\\alpha\\tau},\\frac{z_n}{q_T};Q_\\tau\\right)\\,,\n\\end{array}\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:xFtens}\n\\begin{array}{rcl}\n\\displaystyle  \\overline{W}_{n\\tau\\alpha}(q_T) &\\equiv& \\displaystyle w_n^{(1)}\\frac{8\\pi}{9} \\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\mathcal{I}_\\tau(Q)\\, \n  \\frac{1}{Q^3} \\alpha^2(Q) H(Q) \n\\\\\n\\\\\n&\\times& \\displaystyle \n                         \\int_{x_{F,\\rm\n    min}}^{x_{F,\\rm max}}dx_F\\,\\mathcal{I}_\\alpha(x_F)\\,\\frac{1}{x_1+x_2} \\sum_q C_q(Q)\\overline{F}_q\\left(x_1,b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\n                         \\overline{F}_{\\bar{q}}\\left(x_2,b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\\,,\n\\end{array}\n\\end{equation}\nwhere $x_1$ and $x_2$ are functions of $x_F$ and $Q$ through\nEq.~(\\ref{eq:x12ofxFQ}). In addition, we have defined a grid in $x_F$,\n$\\{x_{F,\\alpha}\\}$ with $\\alpha = 0,\\dots,N_x$, that allowed us to\ndefine $x_{1(2),\\alpha\\tau}\\equiv x_{1(2)}(x_{F,\\alpha},Q_\\tau)$.\n\n\\subsection{Flavour dependence}\n\nIt may be advantageous to introduce a flavour dependence of the\nnon-perturbative contributions to TMDs. This can be easily done by\nobserving that the tensor $W_{n\\tau\\alpha}$ defined in\nEq.~(\\ref{eq:weights}) can be decomposed as\\footnote{The same\n  procedure applies to the tensor $\\overline{W}_{n\\tau\\alpha}$ defined\nin Eq.~(\\ref{eq:xFtens}).}:\n\\begin{equation}\nW_{n\\tau\\alpha}(q_T) = \\sum_q W_{n\\tau\\alpha}^{(q)} (q_T)\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:weightsfl}\n\\begin{array}{rcl}\n  \\displaystyle  W_{n\\tau\\alpha}^{(q)}(q_T) & \\equiv & \\displaystyle w_n^{(1)}\\frac{8\\pi}{9} \\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\mathcal{I}_\\tau(Q)\\, \n                                            \\frac{\\alpha^2(Q)}{Q^3} H(Q) C_q(Q)\n                                            \\\\\n  \\\\\n                                 &\\times& \\displaystyle \n                                          \\int_{e^{y_{\\rm\n                                          min}}}^{e^{y_{\\rm max}}}d\\xi\\,\\mathcal{I}_\\alpha(\\xi)\\,\\frac{1}{\\xi} \\overline{F}_q\\left(\\frac{Q}{\\sqrt{s}}\\xi,b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\n                                          \\overline{F}_{\\bar{q}}\\left(\\frac{Q}{\\sqrt{s}}\\frac1{\\xi},b_*\\left(\\frac{z_n}{q_T}\\right);Q\\right)\\,.\n\\end{array}\n\\end{equation}\nThis allows for an independent parameterisation of the\nnon-perturbative contribution such that\nEq.~(\\ref{eq:finalinterpolated}) can be written as:\n\\begin{equation}\\label{eq:finalinterpolatedfl}\n\\widetilde{K}(q_T) \\simeq \\sum_q\\sum_{n=1}^N\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_\\xi} W_{n\\tau\\alpha}^{(q)}(q_T) f_{\\rm NP}^{(q)}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\xi_\\alpha,\\frac{z_n}{q_T};Q_\\tau\\right) f_{\\rm NP}^{(q)}\\left(\\frac{Q_\\tau}{\\sqrt{s}}\\frac1{\\xi_\\alpha},\\frac{z_n}{q_T};Q_\\tau\\right)\\,,\n\\end{equation}\nwhere $f_{\\rm NP}^{(q)}$ parametrises the non-perturbative component\nof the TMD with flavour $q$.\n\n\\subsection{Gradient with respect to the free parameters}\n\nA very appealing implication of the computation of cross section in\nterms of precomputed table as in Eqs.~(\\ref{eq:finalinterpolated})\nand~(\\ref{eq:finalinterpolatedfl}) is the fact that it exposes the\nfree parameters of the non-perturbative functions. To be more\nspecific, the non-perturbative function $f_{\\rm NP}$, on top of being\na function of $x$, $b$, and $\\zeta$, depends parameterically on a set\nof $N_p$ parameters $\\{\\theta_k\\}$, $k=1,\\dots,N_p$, that are\ntypically determined by fits to data, in other words:\n\\begin{equation}\nf_{\\rm NP}\\equiv f_{\\rm NP}\\left(x,b,\\zeta;\\{\\theta_k\\}\\right)\\,.\n\\end{equation}\nNow, when performing a fit, it is very useful to be able to compute\nthe derivative of the figure of merit (usually the $\\chi^2$) with\nrespect to the parameters to be determined. In turn, this immediately\nimplies being able to compute the derivative of the\nobservables. Referring to Eq.~(\\ref{eq:finalinterpolated}), the\nrelevant quantity is:\n\\begin{equation}\n\\frac{d\\widetilde{K}}{d\\theta_k}=\n\\sum_{n=1}^N\n  \\sum_{\\tau=0}^{N_Q}\\sum_{\\alpha=0}^{N_\\xi} W_{n\\tau\\alpha}(q_T) \\left[\\frac{d f_{\\rm NP}^{(1)}}{d\\theta_k} f_{\\rm NP}^{(2)}+f_{\\rm NP}^{(1)}\\frac{d f_{\\rm NP}^{(2)}}{d\\theta_k} \\right]\\,,\n\\end{equation}\nwhere $f_{\\rm NP}^{(1)}$ and $f_{\\rm NP}^{(2)}$ refer to the\nnon-perturbative function $f_{\\rm NP}$ computed in $x_1$ and $x_2$,\nrespectively. It is thus clear that the derivatives w.r.t. the free\nparameters penetrates the observable. Since in most cases the\nderivative of $f_{\\rm NP}$ can be computed analytically, this allows\none to compute the gradient of the figure of merit analytically. This\npotentially makes any fit much simpler.\n\n\\subsection{Narrow-width approximation}\n\nA possible alternative to the numerical integration in $Q$ when the\nintegration region includes the $Z$-peak region is the so-called\nnarrow-width approximation (NWA). In the NWA one assumes that the\nwidth of the $Z$ boson, $\\Gamma_Z$, is much smaller than its mass,\n$M_Z$. This way one can approximate the peaked behaviour of the\ncouplings $C_q(Q)$ around $Q=M_Z$ with a $\\delta$-function,\n\\textit{i.e.}  $C_q(Q)\\sim \\delta(Q^2-M_Z^2)$. Therefore, the\nintegration over $Q$ can be done analytically. The exact structure of\nthe electroweak couplings is the following:\n\\begin{equation}\\label{eq:fullcoup}\nC_q(Q) = e_q^2 - 2 e_q V_q V_e \\chi_1(Q) + (V_e^2 + A_e^2)(V_q^2 + A_q^2)\\chi_2(Q)\\,,\n\\end{equation}\nwith:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle \\chi_1(Q) = \\frac{1}{4 \\sin^2\\theta_W \\cos^2\\theta_W } \\frac{Q^2 ( Q^2 -  M_Z^2 )}{ (Q^2 - M_Z^2)^2 + M_Z^2 \\Gamma_Z^2} \\,,\\\\\n\\displaystyle \\chi_2(Q) = \\frac{1}{16 \\sin^4\\theta_W\\cos^4\\theta_W} \\frac{Q^4}{ (Q^2 - M_Z^2)^2 + M_Z^2 \\Gamma_Z^2} \\,.\n\\end{array}\n\\end{equation}\nIn the limit $\\Gamma_Z/M_Z\\rightarrow 0$, the leading contribution to\nthe coupling in Eq.~(\\ref{eq:fullcoup}) comes from the region\n$Q\\simeq M_Z$ and is that proportional to $\\chi_2$:\n\\begin{equation}\\label{eq:partlead}\nC_q(Q) \\simeq (V_e^2 + A_e^2)(V_q^2 + A_q^2)\\chi_2(Q)\\,,\\quad Q\\simeq M_Z\\,.\n\\end{equation}\nIn addition, in this limit one can show that:\n\\begin{equation}\\label{eq:breitwigner}\n\\frac{1}{ (Q^2 - M_Z^2)^2 + M_Z^2 \\Gamma_Z^2}\\rightarrow\n\\frac{\\pi}{M_Z\\Gamma_Z}\\delta(Q^2-M_Z^2) = \\frac{\\pi}{2M_Z^2\\Gamma_Z}\\delta(Q-M_Z)\\,.\n\\end{equation}\nTherefore, considering that:\n\\begin{equation}\n\\Gamma_Z = \\frac{\\alpha M_Z}{\\sin^2\\theta_W \\cos^2\\theta_W}\\,,\n\\end{equation}\nthe electroweak couplings in the NWA have the following form:\n\\begin{equation}\\label{eq:partlead}\n  C_q(Q) \\simeq \\frac{\\pi M_Z (V_e^2 + A_e^2)(V_q^2 + A_q^2) }{32 \\alpha\n    \\sin^2\\theta_W\\cos^2\\theta_W} \\delta(Q-M_Z)=\\widetilde{C}_q(Q) \\delta(Q-M_Z)\\,.\n\\end{equation}\nTherefore, using Eq.~(\\ref{eq:partlead}) the integral of the cross\nsection over $Q$ under the condition that\n$Q_{\\rm min}<M_Z<Q_{\\rm max}$ has the consequence of adjusting the\ncouplings and of setting $Q=M_Z$ in the computation. This yields:\n\\begin{equation}\n\\int_{Q_{\\rm min}}^{Q_{\\rm max}}dQ\\,\\frac{d\\sigma}{dQ dy dq_T} =\n \\frac{16\\pi\\alpha^2q_T}{9 M_Z^3} H(M_Z,M_Z) \\sum_q \\widetilde{C}_q(M_Z)\n  I_{q\\bar{q}}(x_1,x_2,q_T;M_Z,M_Z^2)\\,,\n\\end{equation}\nwhere we are also assuming that $\\mu=\\sqrt{\\zeta}=M_Z$. As a final\nstep, one may want to let the $Z$ boson decay into leptons. At leading\norder in the EW sector and assuming an equal decay rate for electrons,\nmuons, and tauons, this can be done by multiplying the cross section\nabove by three times the branching ratio for the $Z$ decaying into any\npair of leptons, $3\\mbox{Br}(Z\\rightarrow \\ell^+\\ell^-)$.\n\n\\appendix\n\n\\section{Ogata quadrature}\\label{app:OgataQuadrature}\n\nIn this section we limit ourselves to write the formulas for the\ncomputation of the unscaled coordinates $z_n^{(\\nu)}$ and weights\n$w_n^{(\\nu)}$ required to compute the following integral:\n\\begin{equation}\\label{eq:OgataQuadMast}\nI_\\nu(q_T)=\\int_0^\\infty db J_\\nu(bq_T) f\\left(b\\right) =\n\\frac1{q_T}\\int_0^\\infty d\\bar{b} J_\\nu(\\bar{b})\nf\\left(\\frac{\\bar{b}}{q_T}\\right) \\simeq\n\\frac{1}{q_T}\\sum_{n=1}^\\infty\nw_n^{(\\nu)}f\\left(\\frac{z_n^{(\\nu)}}{q_T}\\right)\\quad \\nu =0,1,\\dots\\,,\n\\end{equation}\nusing the Ogata-quadrature algorithm. More details can be found in\nRef.~\\cite{Ogata:quadrature}. There relevant formulas are:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle z_n^{(\\nu)} = \\frac{\\pi}{h}  \\psi\\left(\\frac{h\\xi_{\\nu\n  n}}{\\pi}\\right)\\,,\\\\\n\\\\\n\\displaystyle w_n^{(\\nu)}  = \\pi\\frac{Y_\\nu(\\xi_{\\nu\n  n})}{J_{\\nu+1}(\\xi_{\\nu n})}  J_\\nu(z_n^{(\\nu)})  \\psi'\\left(\\frac{h\\xi_{\\nu\n  n}}{\\pi}\\right)\\,.\n\\end{array}\n\\end{equation}\nwhere:\n\\begin{itemize}\n\\item $h$ is a free parameter of the algorithm that has to be\n  typically small (we choose $h = 10^{-3}$),\n\\item $\\xi_{\\nu n}$ are the zero's of $J_\\nu$, \\textit{i.e.}\n  $J_\\nu(\\xi_{\\nu n}) = 0$ $\\forall\\, n$,\n\\item $J_\\nu$ and $Y_\\nu$ are the Bessel functions of first and second\n  kind, respectively, of degree $\\nu$,\n\\item $\\psi$ is the following function:\n\\begin{equation}\n\\psi(t) = t\\tanh\\left(\\frac{\\pi}{2}\\sinh t\\right)\n\\end{equation}\nand its derivative:\n\\begin{equation}\n\\psi'(t) =  \\frac{\\pi t \\cosh t + \\sinh( \\pi \\sinh t ) }{1 +\n  \\cosh( \\pi \\sinh t  ) }\\,.\n\\end{equation}\n\\end{itemize}\n\n\\section{Lagrange interpolation}\\label{app:LagrangeInterpolation}\n\nJust for the record, it is useful to derive a general expression for\nthe Lagrange interpolating functions $\\mathcal{I}$ introduced in\nEq.~(\\ref{eq:interpolation}) and used to interpolate the\nnon-perturbative functions $f_{\\rm NP}$. More, importantly, we need to\nunderstand how these functions behave upon integration.\n\nSuppose one wants to interpolate the test function $g$ in the point\n$x$ using a set of Lagrange polynomials of degree $k$ of. This\nrequires a subset of $k+1$ consecutive points on an interpolation\ngrid, say $\\{x_{\\alpha},\\dots,x_{\\alpha+k}\\}$. The relative position\nbetween the point $x$ and the subset of points used for the\ninterpolation is arbitrary. It is convenient to choose the subset of\npoints such that $x_\\alpha < x \\leq x_{\\alpha+k}$.\\footnote{In fact,\n  it is not even necessary to impose the constraint\n  $x_\\alpha < x \\leq x_{\\alpha+k}$.  In case this relation is not\n  fulfilled one usually refers to \\textit{extrapolation} rather than\n  \\textit{interpolation}. If not necessary, this option is typically\n  not convenient because it may lead to a substantial deterioration in\n  the accuracy with which $g(x)$ is determined.}  However, the\nambiguity remains because there are $k$ possible choices according to\nwhether $x_\\alpha < x \\leq x_{\\alpha+1}$, or\n$x_{\\alpha+1} < x \\leq x_{\\alpha+2}$, and so on.\n\nIn order to determine the exact form of the interpolation functions\n$\\mathcal{I}$, let us see how to derive\neq.~(\\ref{eq:interpolation}). Using the standard Lagrange\ninterpolation procedure, we can approximate the function $g$ in $x$\nas:\n\\begin{equation}\\label{particularCase}\ng(x) = \\sum_{i=0}^k\\ell_i^{(k)}(x)g(x_{\\alpha+i})\\,,\n\\end{equation}\nwhere $\\ell_i^{(k)}$ is the $i$-th Lagrange polynomial of degree $k$\nwhich can be written as:\n\\begin{equation} \\ell_i^{(k)}(x) = \\prod^{k}_{m=0,m\\ne\ni}\\frac{x-x_{\\alpha+m}}{x_{\\alpha+i}-x_{\\alpha+m}}\\,.\n\\end{equation}\nWe now assume that:\n\\begin{equation}\\label{eq:assumption1}\nx_{\\alpha} < x \\leq x_{\\alpha+1}\\,,\n\\end{equation}\nEq.~(\\ref{particularCase}) becomes:\n\\begin{equation}\\label{particularCaseTheta}\n  g(x) =\n  \\theta(x-x_{\\alpha})\\theta(x_{\\alpha+1}-x)\\sum_{i=0}^k\n  g(x_{\\alpha+i})\\prod^{k}_{m=0,m\\ne\n    i}\\frac{x-x_{\\alpha+m}}{x_{\\alpha+i}-x_{\\alpha+m}}\\,.\n\\end{equation}\n\nIn order to make Eq.~(\\ref{particularCaseTheta}) valid for all values\nof $\\alpha$, one just has to sum over all $N_x$ intervals of the\n\\textit{global} interpolation grid $\\{x_0,\\dots,x_{N_x}\\}$, that is:\n\\begin{equation}\\label{generalCase}\n  g(x) =\n  \\sum_{\\alpha=0}^{N_x-1}\\theta(x-x_{\\alpha})\\theta(x_{\\alpha+1}-x)\\sum_{i=0}^k\n  g(x_{\\alpha+i})\\prod^{k}_{m=0,m\\ne\n    i}\\frac{x-x_{\\alpha+m}}{x_{\\alpha+i}-x_{\\alpha+m}}\\,,\n\\end{equation}\n\nDefining $\\beta=\\alpha+i$, we can rearrange the equation above as:\n\\begin{equation}\\label{generalCase2}\n  g(x) =\n  \\sum_{\\beta=0}^{N_x+k-1}\\mathcal{I}_\\beta^{(k)}(x) g(x_{\\beta})\\,,\n\\end{equation}\nthat leads us to the definition of the interpolating functions:\n\\begin{equation}\\label{eq:intfunc}\n  \\mathcal{I}_\\beta^{(k)}(x) = \\sum_{i=0,i\\leq\\beta}^k\n  \\theta(x-x_{\\beta-i})\\theta(x_{\\beta-i+1}-x) \\prod^{k}_{m=0,m\\ne\n    i}\\frac{x-x_{\\beta-i+m}}{x_{\\beta}-x_{\\beta-i+m}}\\,,\n\\end{equation}\nwhere the condition $i\\leq\\beta$ comes from the condition\n$\\alpha\\geq 0$. It is important to observe that the sum in\nEq.~(\\ref{generalCase2}) extends up to the $(N_x+k-1)$-th\nnode. Therefore, the original grid needs to be extended by $k-1$\nnodes. However, the range of validity of the interpolation remains\nthat defined by the original grid, \\textit{i.e.}\n$x_0 \\leq x \\leq x_{N_x}$. Finally, it is crucial to realise that the\ninterpolation function $\\mathcal{I}_\\beta^{(k)}(x)$ is different from\nzero only over a limited interval, specifically:\n\\begin{equation}\\label{eq:limits}\n\\mathcal{I}_\\beta^{(k)}(x) \\neq 0\\quad \\Leftrightarrow\\quad\nx_{\\beta-k}<x < x_{\\beta+1}\\,.\n\\end{equation}\n\nIn the rest of this document we will stick to the assumption in\nEq.~(\\ref{eq:assumption1}). However, before going further, it is\ninteresting to generalise Eq.~(\\ref{eq:assumption1}) to:\n\\begin{equation}\\label{IntAssumptionGen}\n  x_{\\alpha+t} < x \\leq\n  x_{\\alpha+t+1}\\quad\\mbox{with}\\quad t = 0,\\dots,k-1\\,,\n\\end{equation}\nsuch that the interpolation formula becomes:\n\\begin{equation}\\label{MoreGeneralCase}\n  g(x) =\n  \\sum_{\\alpha=-t}^{N_x-t-1}\\theta(x-x_{\\alpha+t})\\theta(x_{\\alpha+t+1}-x)\\sum_{i=0}^k\n  g(x_{\\alpha+i})\\prod^{k}_{m=0,m\\ne\n    i}\\frac{x-x_{\\alpha+m}}{x_{\\alpha+i}-x_{\\alpha+m}}\\,,\n\\end{equation}\nthat can be rearranged as:\n\\begin{equation}\\label{generalCase3} g(x) =\n\\sum_{\\beta=-t}^{N_x+k-t-1}\\mathcal{I}_{\\beta,t}^{(k)}(x) g(x_{\\beta})\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:generalisedintfuncs}\n\\mathcal{I}_{\\beta,t}^{(k)}(x) = \\sum_{i=0,i\\leq\\beta}^k\n\\theta(x-x_{\\beta-i+t})\\theta(x_{\\beta-i+t+1}-x) \\prod^{k}_{m=0,m\\ne\ni}\\frac{x-x_{\\beta-i+m}}{x_{\\beta}-x_{\\beta-i+m}}\\,,\n\\end{equation}\nbeing the ``generalised'' interpolation functions.  The generalised\ninterpolation functions can be used to overcome the ``drawback'' of\nrequiring $k-1$ additional nodes on the interpolation grid. In\npractice, given the grid $\\{x_0,\\dots,x_{N_x}\\}$, one can tune $t$\naccording to the position of $x$ on the grid. More specifically, one\ncan choose $t$ in such a way that $\\beta+t$ in\nEq.~(\\ref{eq:generalisedintfuncs}) never exceeds $N_x$.\n\nNow suppose we want to compute the following intergral:\n\\begin{equation}\nI_1 = \\int_{x_0}^{x_{N_x}}dx\\,g(x)f(x)\\,,\n\\end{equation}\nwhere $f$ is some other function that we don't want to\ninterpolate. Using Eqs.~(\\ref{generalCase2}) and~(\\ref{eq:limits}) we\nfinally have that:\n\\begin{equation}\n  I_1 = \\sum_{\\beta=0}^{N_x+k-1} W_\\beta g(x_{\\beta})\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:monodim}\nW_\\beta = \\int_{x_{{\\rm max}(0,\\beta-k)}}^{x_{{\\rm min}(N_x,\\beta+1)}}dx \\,\\mathcal{I}_\\beta^{(k)}(x)f(x)\\,.\n\\end{equation}\nThe equation above can be easily generalised to a bidimensional\nintegral as:\n\\begin{equation}\nI_2 = \\int_{x_0}^{x_{N_x}}dx \\int_{y_0}^{y_{N_y}}dy\\,g(x,y)f(x,y) = \\sum_{\\alpha=0}^{N_x+k-1} \\sum_{\\beta=0}^{N_y+l-1} W_{\\alpha\\beta} g(x_{\\alpha},y_{\\beta})\\,,\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:bidim}\nW_{\\alpha\\beta} = \\int_{x_{{\\rm max}(0,\\alpha-k)}}^{x_{{\\rm\n      min}(N_x,\\alpha+1)}}dx \\int_{y_{{\\rm max}(0,\\beta-k)}}^{y_{{\\rm\n      min}(N_y,\\beta+1)}}dy \\,\\mathcal{I}_\\alpha^{(k)}(x)\\,\\mathcal{I}_\\beta^{(l)}(y)\\,f(x,y)\\,.\n\\end{equation}\nThis formalism nicely applies to the integral in $Q$ and $\\xi=e^{y}$\ndiscussed above in Eq.~(\\ref{eq:weights}). In view of a numerical\nimplementation, it is worth noticing that the functions $\\mathcal{I}$\nare piecewise. In particular, while these functions are continuos in\ncorrespondence of the nodes of the grid, their first derivative is\nnot. As a consequence, the result of the numerical integrals in\nEqs.~(\\ref{eq:monodim}) and~(\\ref{eq:bidim}) may be inaccurate. To\novercome this problem, it is sufficient to split the integrals in\nsub-integrals over the intervals delimited by two consecutive\nnodes. Using Eq.~(\\ref{eq:limits}), it is easy to see that, for an\ninterpolation of degree $k$, one needs to do $k+1$ integrals over the\nintervals included between the $(\\beta-k)$-th and the $(\\beta+1)$-th\nnode.\n\n\\section{Cuts on the final-state leptons}\n\nIn this section we derive explicitly the phase-space reduction factor\n$\\mathcal{P}$ introduced in Sect.~\\ref{sec:kincuts}. This factor is\ndefined as:\n\\begin{equation}\\label{eq:PSredDef}\n\\mathcal{P}(Q,y,q_T) = \\mathcal{P}(q) = \\frac{\\displaystyle \\int_{\\mbox{\\footnotesize fid.\n    reg.}}d^4p_1 d^4p_2 \\,\\delta(p_1^2) \\delta(p_2^2)\\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) g_{\\mu\\nu}L^{\\mu\\nu}(p_1,p_2)}{\\displaystyle \\int d^4p_1 d^4p_2\\, \\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) g_{\\mu\\nu}L^{\\mu\\nu}(p_1,p_2)}\\,,\n\\end{equation}\nwhere $p_1$ and $p_2$ are the four-momenta of the outgoing leptons\nand $L^{\\mu\\nu}$ is the leptonic tensor that, assuming massless\nleptons, reads:\n\\begin{equation}\\label{eq:lepttens}\nL^{\\mu\\nu}(p_1,p_2) = 4(p_1^{\\mu}p_2^{\\nu}+p_2^{\\mu}p_1^{\\nu}-g^{\\mu\\nu}p_1p_2)\\,,\n\\end{equation}\nso that:\n\\begin{equation}\ng_{\\mu\\nu}L^{\\mu\\nu}(p_1,p_2) = -8(p_1p_2) = -4(p_1+p_2)^2\\,.\n\\end{equation}\nIn the last step we have used the on-shell-ness of the leptons\n($p_1^2=p_2^2=0$). The integral in the denominator of\nEq.~(\\ref{eq:PSredDef}) is restricted to some \\textit{fiducial\n  region}. Finally, we find:\n\\begin{equation}\\label{eq:PSredDef2}\n\\mathcal{P}(q) = \\frac{\\displaystyle \\int_{\\mbox{\\footnotesize fid.\n    reg.}}d^4p_1 d^4p_2 \\,\\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) (p_1+p_2)^2}{\\displaystyle \\int d^4p_1 d^4p_2\\, \\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) (p_1+p_2)^2}\\,.\n\\end{equation}\nThe effect of integrating over the fiducial region can be implemented\nby defining a generalised $\\theta$-function, $\\Phi(p_1,p_2)$, that is\nequal to one inside the fiducial region and zero outside. This allows\none to integrate also the numerator of Eq.~(\\ref{eq:PSredDef2}) over\nthe full phase-space of the two outgoing leptons:\n\\begin{equation}\\label{eq:PSredDef3}\n\\mathcal{P}(q) = \\frac{\\displaystyle \\int d^4p_1 d^4p_2 \\,\\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) \\Phi(p_1,p_2) (p_1+p_2)^2}{\\displaystyle \\int d^4p_1 d^4p_2\\, \\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) (p_1+p_2)^2}\\,.\n\\end{equation}\nNow we can integrate over one of the outgoing momenta, say $p_2$,\nexploiting the momentum-conservation $\\delta$-function both in the\nnumerator and in the denominator. Specifically, the numerator of\nEq.~(\\ref{eq:PSredDef3}) gives:\n\\begin{equation}\n\\begin{array}{c}\n\\displaystyle \\int d^4p_1 d^4p_2\\, \\delta(p_1^2)\n\\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q)\n  \\Phi(p_1,p_2) (p_1+p_2)^2 = \\\\\n\\\\\n\\displaystyle Q^2 \\int d^4p_1 \\delta(p_1^2)\n\\delta((q-p_1)^2) \\theta(p_{1,0})\n  \\theta(q_0-p_{1,0})\\Phi(p_1,q-p_1)\\,,\n\\end{array}\n\\end{equation}\nand likewise in the denominator setting $\\Phi(p_1,p_2)=1$. Finally,\nrenaming $p_1=p$, the phase-space reduction factor reads:\n\\begin{equation}\\label{eq:PSredDef4}\n  \\mathcal{P}(q) = \\frac{\\displaystyle \\int d^4p \\delta(p^2) \\delta((q-p)^2) \\theta(p_{0})\n    \\theta(q_0-p_{0})  \\Phi(p,q-p)}{\\displaystyle \\int d^4p \\delta(p^2) \\delta((q-p)^2) \\theta(p_{0})\n    \\theta(q_0-p_{0})  }\\,.\n\\end{equation}\nThe $\\delta$-functions can now be used to constrain two of the four\ncomponents of the momentum $p$. The first, $\\delta(p_2^2)$, is usually\nused to set the first component of $p$, the energy, to the on-shell\nvalue. Since the leptons are assumed to be massless, this\nproduces:\n\\begin{equation}\\label{eq:phasespacemeasure}\n\\int d^4p\\delta(p^2)\\theta(p_0) = \\int d^4p\\delta(E^2-|\\mathbf{p}|^2)\\theta(E)=\\int\\frac{dEd^3\\mathbf{p}}{2|\\mathbf{p}|}\\delta(E-|\\mathbf{p}|)=\\int\\frac{d^3\\mathbf{p}}{2|\\mathbf{p}|}\\,.\n\\end{equation}\nOf course, the four-momentum $p$ appearing in the rest of the\nintegrand has to be set on shell ($E=|\\mathbf{p}|$). Now we express\nthe three-dimensional measure $d^3\\mathbf{p}$ in spherical coordinates\nas:\n\\begin{equation}\nd^3\\mathbf{p} = |\\mathbf{p}|^2d|\\mathbf{p}|d(\\cos\\theta) d\\phi\\,.\n\\end{equation}\nThen we make a change of variable from $(|\\mathbf{p}|,\\cos\\theta)$ to\n$(|\\mathbf{p}_T|,\\eta)$: the second set of variables are exactly those\non which kinematic cuts are imposed. We do so by knowing that:\n\\begin{equation}\n\\left\\{\n\\begin{array}{l}\n|\\mathbf{p}| = |\\mathbf{p}_T|\\cosh\\eta\\,,\\\\\n\\cos\\theta =\\tanh\\eta\\,.\n\\end{array}\n\\right.\n\\end{equation}\nThis leads to:\n\\begin{equation}\n\\int\\frac{d^3\\mathbf{p}}{2 |\\mathbf{p}|} = \\frac12\\int|\\mathbf{p}|d|\\mathbf{p}|d(\\cos\\theta) d\\phi=\\frac12\\int|\\mathbf{p}_T|d|\\mathbf{p}_T|d\\eta d\\phi=\\frac12\\int d^2\\mathbf{p}_T d\\eta\\,.\n\\end{equation}\n\nNow we consider the second $\\delta$-function:\n\\begin{equation}\\label{eq:integralyeah!}\n\\frac12\\int d^2\\mathbf{p}_T d\\eta\\,\\delta((q-p)^2)\\theta(q_0-p_0)=\\frac12\\int_{-\\infty}^\\infty d\\eta\n\\int_0^{2\\pi} d\\phi \\int_0^\\infty|\\mathbf{p}_T|d|\\mathbf{p}_T|\\,\\delta(Q^2-2p\\cdot q) \\theta(q_0-p_0)\\,,\n\\end{equation}\nbeing $q^2=Q^2$ and $p^2=0$. It is convenient to express the\nfour-vector $q$ in terms of $Q$, $y$, and $\\mathbf{q}_T$:\n\\begin{equation}\\label{eq:qexplicit}\nq=\\left(M\\cosh y,\\mathbf{q}_T,M\\sinh y\\right)\\,.\n\\end{equation}\nwith $M=\\sqrt{Q^2+|\\mathbf{q}_T|^2}$. While:\n\\begin{equation}\\label{eq:pexplicit}\np=\\left(|\\mathbf{p}_T|\\cosh\\eta,\\mathbf{p}_T,|\\mathbf{p}_T|\\sinh\\eta\\right)\\,,\n\\end{equation}\nso that:\n\\begin{equation}\np\\cdot q=|\\mathbf{p}_T|M\\left(\\cosh\\eta \\cosh y-\\sinh\\eta\\sinh\n  y\\right)-\\mathbf{p}_T\\cdot\n\\mathbf{q}_T=|\\mathbf{p}_T|M\\cosh\\left(\\eta - y\\right)-\\mathbf{p}_T\\cdot \\mathbf{q}_T\\,.\n\\end{equation}\nWe can now assume that the two-dimensional vector $\\mathbf{q}_T$ is\naligned with the $x$ axis so that\n$\\mathbf{p}_T\\cdot \\mathbf{q}_T =\n|\\mathbf{p}_T||\\mathbf{q}_T|\\cos\\phi$(\\footnote{In\n  the general case in which $\\mathbf{q}_T$ forms an angle $\\beta$ with\n  the $x$ axis, the scalar product would result in\n  $|\\mathbf{p}_T||\\mathbf{q}_T|\\cos(\\phi-\\beta)$. However, the angle\n  $\\beta$ could always be reabsorbed in a redefinition of the\n  integration angle $\\phi$ in\n  Eq.~(\\ref{eq:integralyeah!}).}). Therefore, the argument of the\n$\\delta$-function in Eq.~(\\ref{eq:integralyeah!}) becomes:\n\\begin{equation}\\label{eq:deltaargument}\nf(|\\mathbf{p}_T|,\\eta,\\phi) = Q^2-2 |\\mathbf{p}_T|\\left[M\\cosh\\left(\\eta - y\\right)-|\\mathbf{q}_T|\\cos\\phi\\right]\\,.\n\\end{equation}\nand that of the $\\vartheta$-function\n$M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta$. It thus appears convenient to\nintegrate Eq.~(\\ref{eq:integralyeah!}) over $|\\mathbf{p}_T|$ first:\n\\begin{equation}\\label{eq:firstintegral}\n\\frac12\\int_0^\\infty|\\mathbf{p}_T|d|\\mathbf{p}_T|\\,\\delta(Q^2-2p\\cdot q) \\theta(q_0-p_0)=\\frac{\\overline{p}_T^2}{2Q^2}\\vartheta(M\\cosh y-\\overline{p}_T\\cosh\\eta)=\\frac{\\overline{p}_T^2}{2Q^2}\\,,\n\\end{equation}\nwith(\\footnote{Notice that the $\\vartheta$-function has no effect. I\n  have verified it numerically but I cannot see it analytically.}):\n\\begin{equation}\\label{eq:overpT}\n\\overline{p}_T(\\cos\\phi) = \\frac{Q^2}{2 \\left[M\\cosh\\left(\\eta - y\\right)-|\\mathbf{q}_T|\\cos\\phi\\right]}=\\frac{Q^2}{2 |\\mathbf{q}_T|}\\frac1{\\left[\\frac{M\\cosh\\left(\\eta - y\\right)}{|\\mathbf{q}_T|}-\\cos\\phi\\right]}\\,.\n\\end{equation}\nNow we turn to consider the integral in $d\\phi$. To this end, the\nfollowing relations are useful:\n\\begin{equation}\\label{eq:intoverphi}\n\\int_0^{2\\pi}d\\phi\\, f(\\cos\\phi) = \\int_{-1}^1\\frac{dx}{\\sqrt{1-x^2}}\\left[f(x)+f(-x)\\right]\\,.\n\\end{equation}\nand:\n\\begin{equation}\\label{eq:complicatedintegral}\n\\int \\frac{dx}{(a\\pm\n  x)^2\\sqrt{1-x^2}}=\\frac{\\sqrt{1-x^2}}{(a^2-1)(x\\pm\n  a)}\\pm\\frac{a}{(a^2-1)^{3/2}}\\tan^{-1}\\left(\\frac{1\\pm ax}{\\sqrt{a^2-1}\\sqrt{1-x^2}}\\right)\\,.\n\\end{equation}\nThe last integral is such that:\n\\begin{equation}\\label{eq:defintoverphi}\n\\int_{-1}^{1} \\frac{dx}{(a\\pm x)^2\\sqrt{1-x^2}}=\\frac{\\pi a}{(a^2-1)^{3/2}}\\,.\n\\end{equation}\nWe now use Eqs.~(\\ref{eq:intoverphi})-(\\ref{eq:defintoverphi}) to\ncompute:\n\\begin{equation}\n\\begin{array}{rcl}\n&&\\displaystyle\n  \\frac{1}{2Q^2}\\int_0^{2\\pi}d\\phi\\,[\\overline{p}_T(\\cos\\phi)]^2 =\n                                                                    \\displaystyle\n                                                                    \\frac{Q^2}{4\n                                                                    |\\mathbf{q}_T|^2}\\int_0^{2\\pi}\\frac{d\\phi}{\\left[\\frac{M\\cosh\\left(\\eta\n                                                                    -\n                                                                    y\\right)}{|\\mathbf{q}_T|}-\\cos\\phi\\right]^2}\\\\\n\\\\\n&=&\\displaystyle \\frac{Q^2}{8|\\mathbf{q}_T|^2}\\int_{-1}^{1}\\frac{dx}{\\sqrt{1-x^2}}\\left[\\frac{1}{\\left(\\frac{M\\cosh\\left(\\eta- y\\right)}{|\\mathbf{q}_T|}-x\\right)^2}+\\frac{1}{\\left(\\frac{M\\cosh\\left(\\eta- y\\right)}{|\\mathbf{q}_T|}+x\\right)^2}\\right]\\\\\n\\\\\n&=&\\displaystyle \\frac{Q^2}{8}\\Bigg\\{\\frac{|\\mathbf{q}_T|^2 x\\sqrt{1-x^2}}{(M ^2\\cosh ^2\\left(\\eta- y\\right)-|\\mathbf{q}_T|^2)(x^2 |\\mathbf{q}_T|^2-\n  M ^2\\cosh ^2\\left(\\eta- y\\right))}\\\\\n\\\\\n&-&\\displaystyle \\frac{M\\cosh\\left(\\eta-\n    y\\right)}{(M^2\\cosh^2\\left(\\eta-\n    y\\right)-|\\mathbf{q}_T|^2)^{3/2}}\\Bigg[\\tan^{-1}\\left(\\frac{|\\mathbf{q}_T|-\n    xM\\cosh\\left(\\eta-y\\right)}{\\sqrt{(M^2\\cosh^2\\left(\\eta-y\\right)-|\\mathbf{q}_T|^2)}\\sqrt{1-x^2}}\\right)\\\\\n\\\\\n&-&\\displaystyle\\tan^{-1}\\left(\\frac{|\\mathbf{q}_T|+\n    xM\\cosh\\left(\\eta-y\\right)}{\\sqrt{(M^2\\cosh^2\\left(\\eta-y\\right)-|\\mathbf{q}_T|^2)}\\sqrt{1-x^2}}\\right)\\Bigg]\\Bigg\\}_{-1}^{1}\\\\\n\\\\\n&=&\\displaystyle \\frac{\\pi\n  Q^2M\\cosh\\left(\\eta -\n    y\\right)}{4(M^2\\cosh^2\\left(\\eta -\n    y\\right)-|\\mathbf{q}_T|^2)^{3/2}}\n\\end{array}\n\\end{equation}\nWe can go further and solve also the integral in $\\eta$:\n\\begin{equation}\\label{eq:remarkableintegral}\n\\begin{array}{l}\n  \\displaystyle \\int d^4p \\delta(p^2) \\delta((q-p)^2) \\theta(p_{0})\n  \\theta(q_0-p_{0})=\\int_{-\\infty}^\\infty\n  d\\eta\\frac{\\pi Q^2M\\cosh(\\eta-y)}{4(M^2\\cosh^2(\\eta-y)-|\\mathbf{q}_T|^2)^{3/2}}= \\\\\n  \\\\\n  \\displaystyle\\frac{\\pi }{4}\\frac{Q^2}{M^2}\\int_{-\\infty}^\\infty\n  \\frac{d(\\sinh\\eta)}{\\left(\\sinh^2(\\eta-y)+\\frac{Q^2}{M^2}\\right)^{3/2}}= \\frac{\\pi}{4} \\frac{Q^2}{M^2}\\left[\\frac{M^2}{Q^2}\\frac{\\sinh\\eta}{\\sqrt{\\sinh^2\\eta+\\frac{Q^2}{M^2}}}\\right]_{-\\infty}^{\\infty}= \\frac{\\pi}{2}\\,.\n\\end{array}\n\\end{equation}\nRemarkably, this result gives us the denominator of\nEq.~(\\ref{eq:PSredDef4}). We now need to compute the numerator by\ninserting the appropriate function $\\Phi$. In our case, the kinematic\ncuts are identical for the outgoing leptons and read:\n\\begin{equation}\n\\eta_{\\rm\n  min} < \\eta_{1(2)} < \\eta_{\\rm max}\\quad\\mbox{and}\\quad |\\mathbf{p}_{T,1(2)}| > p_{T,\\rm min}\\,.\n\\end{equation}\nTherefore, the function $\\Phi$ factorises into two identical functions\nas:\n\\begin{equation}\n\\Phi(p_1,p_2) = \\Theta(p_1)\\Theta(p_2)\\,,\n\\end{equation}\nwith:\n\\begin{equation}\n  \\Theta(p) = \\vartheta(\\eta - \\eta_{\\rm min})\\vartheta(\\eta_{\\rm max}-\\eta) \\vartheta(|\\mathbf{p}_{T}| - p_{T,\\rm min}) \\,. \n\\end{equation}\nRegerring to Eq.~(\\ref{eq:PSredDef4}), and considering that:\n\\begin{equation}\nq-p=\\left(M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta,\\mathbf{q}_T-\\mathbf{p}_T,M\\sinh y-|\\mathbf{p}_T|\\sinh\\eta\\right)\\,.\n\\end{equation}\nwe thus have:\n\\begin{equation}\\label{eq:intdomain}\n\\begin{array}{ll}\n&\\Phi(p,q-p) = \\Theta(p) \\Theta(q-p)=\\\\\n\\\\\n&\\displaystyle \n\\vartheta(\\eta - \\eta_{\\rm min}) \\vartheta(\\eta_{\\rm max}-\\eta)\n  \\times\\\\\n\\\\\n&\\displaystyle \\vartheta(|\\mathbf{p}_{T}| - p_{T,\\rm min})\\times\\\\\n\\\\\n&\\displaystyle \\vartheta\\left(\\frac12\\ln\\left(\\frac{M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta+M\\sinh y-|\\mathbf{p}_T|\\sinh\\eta}{M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta-M\\sinh y+|\\mathbf{p}_T|\\sinh\\eta}\\right)-\\eta_{\\rm min}\\right)\\times\\\\\n\\\\\n&\\displaystyle \\vartheta\\left(\\eta_{\\rm\n  max}-\\frac12\\ln\\left(\\frac{M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta+M\\sinh\n  y-|\\mathbf{p}_T|\\sinh\\eta}{M\\cosh y-|\\mathbf{p}_T|\\cosh\\eta-M\\sinh\n  y+|\\mathbf{p}_T|\\sinh\\eta}\\right)\\right)\\times\\\\\n\\\\\n&\\vartheta(|\\mathbf{q}_{T}-\\mathbf{p}_{T}| - p_{T,\\rm min})=\\\\\n\\\\\n1):\\quad&\\displaystyle \\vartheta(\\eta-\\eta_{\\rm min}) \\times\\vartheta(\\eta_{\\rm max}-\\eta) \\times\\\\\n\\\\\n2):\\quad&\\displaystyle \\vartheta(\\overline{p}_T - p_{T,\\rm min})\\times\\\\\n\\\\\n3):\\quad&\\displaystyle \n  \\vartheta\\left(\\frac12\\ln\\left(\\frac{Me^y-\\overline{p}_Te^\\eta}{Me^{-y}-\\overline{p}_Te^{-\n\\eta}}\\right)-\\eta_{\\rm min}\\right)\\times\\vartheta\\left(\\eta_{\\rm max}-\\frac12\\ln\\left(\\frac{Me^y-\\overline{p}_Te^\\eta}{Me^{-y}-\\overline{p}_Te^{-\n\\eta}}\\right)\\right)\\times\\\\\n\\\\\n4):\\quad&\\displaystyle \\vartheta(\\sqrt{|\\mathbf{q}_T|^2+\\overline{p}_T^2-2 |\\mathbf{q}_T|\\overline{p}_T\\cos\\phi} - p_{T,\\rm min})\\,,\n\\end{array}\n\\end{equation}\nwhere in the last step we have replaced $|\\mathbf{p}_T|$ with\n$\\overline{p}_T$ defined Eq.~(\\ref{eq:overpT}). Now the question is\nidentifying the integration domain defined by $\\Phi(p,q-p)$ on the\n$(\\eta,\\cos\\phi)$-plane. Since the $\\theta$-functions in\nEq.~(\\ref{eq:PSredDef4}) will be used inside a double nested integral\nover $x=\\cos\\phi$ first and $\\eta$ second, it is convenient to rewrite\nthe function $\\Phi(p,q-p)$ in Eq.~(\\ref{eq:intdomain}) as follows:\n\\begin{equation}\\label{eq:almostfinal}\n\\begin{array}{rcl}\n\\Phi(p,q-p) &=&\\displaystyle \\vartheta(\\eta-\\eta_{\\rm min}) \\times\n\\vartheta(\\eta_{\\rm max}-\\eta) \\\\\n\\\\\n&\\times& \\vartheta(x - f^{(2)}(\\eta,\n                p_{T,\\rm min})) \\\\\n\\\\\n&\\times&\\displaystyle\n         \\vartheta(f^{(3)}(\\eta,\\eta_{\\rm min})-x) \\times \\vartheta(f^{(3)}(\\eta,\\eta_{\\rm max})-x)\\\\\n\\\\\n&\\times&\\vartheta(f^{(4)}(\\eta,\n         p_{T,\\rm min})-x)\n         \n         \\,,\n\\end{array}\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:relevantfuncs}\n\\begin{array}{rcl}\nf^{(2)}(\\eta, p_{T,\\rm cut}) & = &\\displaystyle \\frac{2M p_{T,\\rm min}\\cosh(\\eta-y) \n                    - Q^{2}}{2p_{T,\\rm cut}\n                    |\\mathbf{q}_T|}\\,, \\\\\n\\\\\nf^{(3)}(\\eta,\\eta_{\\rm cut}) & = &\\displaystyle \\frac{M \\cosh(\\eta-y)}{|\\mathbf{q}_T|\n                    }-\\frac{Q^{2} \\left(\\sinh(\\eta\n                                   -y)\\coth(y-\\eta_{\\rm cut})+\\cosh(\\eta-y)\\right)}{2|\\mathbf{q}_T|  M}\\,,\\\\\n\\\\\nf^{(4)}(\\eta, p_{T,\\rm cut}) & = &\\displaystyle \\frac{M \\cosh(\\eta-y)(Q^2 - 2\n                    p_{T,\\rm cut}^{2} + 2 |\\mathbf{q}_T|^2)- Q^{2} \\sqrt{M^{2} \\sinh ^{2} (\\eta-y) + p_{T,\\rm min}^{2} }}{2 |\\mathbf{q}_T| \\left(M^{2} - p_{T,\\rm min}^{2}\\right)}\\,.\n\\end{array}\n\\end{equation}\nConsidering that $1\\leq\\cos\\phi\\leq 1$, the integration domain is\nlimited to this region. Therefore, Eq.~(\\ref{eq:almostfinal}) can be\nwritten in an even more convenient way as:\n\\begin{equation}\\label{eq:final}\n\\begin{array}{rcl}\n\\Phi(p,q-p) &=& \\vartheta(\\eta-\\eta_{\\rm min})\\vartheta(\\eta_{\\rm\n  max}-\\eta)  \\\\\n\\\\\n&\\times&\\vartheta(x -\n  \\mbox{max}[f^{(2)}(\\eta,p_{T,\\rm min}),-1])\\\\\n\\\\\n&\\times&\\vartheta(\\mbox{min}[f^{(3)}(\\eta,\\eta_{\\rm min}),f^{(3)}(\\eta,\\eta_{\\rm\n         max}), f^{(4)}(\\eta,p_{T,\\rm\n         min}),1]-x)\n\\end{array}\n\\end{equation}\nsuch that a double integral over $\\eta$ and $x$ would read:\n\\begin{equation}\n\\int_{-\\infty}^{\\infty}d\\eta\\int_{-1}^{1}dx\\,\\Phi(p,q-p)\\dots =\n\\int_{\\eta_{\\rm min}}^{\\eta_{\\rm\n    max}}d\\eta\\,\\vartheta(x_2(\\eta)-x_1(\\eta))\\int_{x_1(\\eta)}^{x_2(\\eta)}dx\\dots\\,.\n\\end{equation}\nwith:\n\\begin{equation}\nx_1(\\eta) = \\mbox{max}[f^{(2)}(\\eta,p_{T,\\rm min}),-1]\n\\end{equation}\nand:\n\\begin{equation}\nx_2(\\eta) = \\mbox{min}[f^{(3)}(\\eta,\\eta_{\\rm min}),f^{(3)}(\\eta,\\eta_{\\rm\n         max}),f^{(4)}(\\eta,p_{T,\\rm\n         min}),1]\\,.\n\\end{equation}\n\n\\begin{figure}[t]\n  \\begin{centering}\n    \\includegraphics[width=0.8\\textwidth]{plots/IntDomain}\n    \\caption{The red area indicates the integration domain of the\n      numerator in of the phase-space reduction factor\n      Eq.~(\\ref{eq:PSredDef4}) for $p_{T,\\rm min}=20$ GeV and\n      $-\\eta_{\\rm min}=\\eta_{\\rm max}=2.4$ at $Q=91$ GeV, $|\\mathbf{q}_T|=10$ GeV and\n      $y=1$.\\label{fig:IntDomain}}\n  \\end{centering}\n\\end{figure}\nAs an example, Fig.~\\ref{fig:IntDomain} shows the integration domain\nof the numerator in of the phase-space reduction factor\nEq.~(\\ref{eq:PSredDef4}) for $p_{T,\\rm min}=20$ GeV and\n$-\\eta_{\\rm min}=\\eta_{\\rm max}=2.4$ at $Q=91$ GeV,\n$|\\mathbf{q}_T|=10$ GeV and $y=1$.  The gray band corresponds to the\nregion $1\\leq\\cos\\phi\\leq 1$. The $\\theta$-function 1) in\nEq.~(\\ref{eq:intdomain}) limits the region to the vertical stip\ndefined by $\\eta_{\\rm min} < \\eta < \\eta_{\\rm max}$ (black vertical\nlines), the $\\theta$-function 2) gives the red lines, the\n$\\theta$-functions 3) the blue lines , and the $\\theta$-function 4)\nthe green lines.\n\nGathering all pieces, the final expression for the phase-space\nreduction factor reads:\n\\begin{equation}\\label{eq:finalformula}\n  \\mathcal{P}(Q,y,q_T)=\\displaystyle \\int_{\\eta_{\\rm\n      min}}^{\\eta_{\\rm\n      max}}d\\eta\\,\\vartheta(x_2(\\eta)-x_1(\\eta))\\left[F(x_2(\\eta),\\eta)-F(x_1(\\eta) ,\\eta)\\right]\n\\end{equation}\nwith:\n\\begin{equation}\\label{eq:integrandF}\n\\begin{array}{rcl}\n\\displaystyle F(x ,\\eta)&=&\\displaystyle \\frac{1}{4\\pi}\\frac{Q^2}{E_q^2-q_T^2}\\Bigg\\{\\frac{q_T^2 x\\sqrt{1-x^2}}{x^2 q_T^2-\n  E_q^2}\\\\\n\\\\\n&-&\\displaystyle \\frac{E_q}{\\sqrt{E_q^2-q_T^2}}\\left[\\tan^{-1}\\left(\\frac{q_T-\n    xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right)-\\displaystyle\\tan^{-1}\\left(\\frac{q_T+\n    xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right)\\right]\\Bigg\\}\\\n\\end{array}\n\\end{equation}\nwhere we have defined $E_q = M\\cosh(\\eta-y)$ and\n$q_T=|\\mathbf{q}_T|$.\n\nLet us consider the case $y=q_T=0$. For simplicity, we also take\n$\\eta_{\\rm min} = -\\eta_{\\rm max}$. In these conditions,\nEq.~(\\ref{eq:integrandF}) reduces to:\n\\begin{equation}\\label{eq:F00}\nF(x,\\eta)=\\displaystyle \\frac{1}{4\\pi}\\frac{1}{\\cosh^2(\\eta)}\\left[\\tan^{-1}\\left(\\frac{\n    x}{\\sqrt{1-x^2}}\\right)-\\displaystyle\\tan^{-1}\\left(-\\frac{\n    x}{\\sqrt{1-x^2}}\\right)\\right]\\,.\n\\end{equation}\nAs evident from Eq.~(\\ref{eq:relevantfuncs}), for $q_T=0$ all\nfunctions $f^{(2)}$, $f^{(3)}$, and $f^{(4)}$ diverge. The relevant\nquestion, though, is whether they go to plus or minus infinity\ndepending on the value of $Q$. Of course, $q_T$ will tend to zero\npositively so we find:\n\\begin{equation}\n\\begin{array}{l}\n\\displaystyle f^{(2)}(\\eta,p_{T,\\rm min})\\rightarrow \\infty\\times\\mbox{sign}\\left[2 p_{T,\\rm min}\\cosh(\\eta)-Q\\right]\\,,\\\\\n\\\\\n\\displaystyle f^{(3)}(\\eta,\\eta_{\\rm min}= -\\eta_{\\rm max}) \\rightarrow +\\infty\\\\\n\\\\\n\\displaystyle f^{(3)}(\\eta,\\eta_{\\rm max}) \\rightarrow -\\infty\\,,\\\\\n\\\\\n\\displaystyle f^{(4)}(\\eta,p_{T,\\rm min}) \\rightarrow \\infty\\times\\mbox{sign}\\left[\\frac{\\cosh(\\eta)(Q^2 - 2\n                    p_{T,\\rm min}^{2})- Q\\sqrt{Q^{2} \\sinh^{2}(\\eta) + p_{T,\\rm min}^{2} }}{Q^{2} - p_{T,\\rm min}^{2}}\\right]\\,, \n\\end{array}\n\\end{equation}\nTherefore, $f^{(3)}$ never actually contributes. In addition, for the\n$\\theta$-function in Eq.~(\\ref{eq:finalformula}) to be different from\nzero, we need $f^{(2)}(\\eta)\\rightarrow -\\infty$ and\n$f^{(3)}(\\eta)\\rightarrow \\infty$. These both translate into\n$Q\\geq 2 p_{T,\\rm min}\\cosh(\\eta)$. This inequality is satisfied only\nif $Q\\geq 2p_{T,\\rm min}$ for:\n\\begin{equation}\\label{eq:etabardef}\n-\\overline{\\eta}\\leq\\eta\\leq \\overline{\\eta}\\quad\\mbox{with}\\quad \\overline{\\eta} =\\cosh^{-1}\\left(\\frac{Q}{2p_{T,\\rm min}}\\right)\\,.\n\\end{equation}\nTherefore, the phase-space reduction factor eventually becomes:\n\\begin{equation}\n\\begin{array}{rcl}\n  \\mathcal{P}(Q,0,0)&=&\\displaystyle\\frac12\\vartheta(Q- 2p_{T,\\rm min})\\displaystyle \\int_{-\\eta_{\\rm\n      max}}^{\\eta_{\\rm\n      max}}\\frac{d\\eta}{\\cosh^2\\eta}\\,\\vartheta(\\eta+\\overline{\\eta})\n  \\vartheta(\\overline{\\eta}-\\eta)\\\\\n\\\\\n&=&\\displaystyle\\vartheta(Q- 2p_{T,\\rm\n    min})\\tanh(\\mbox{max}[\\eta_{\\rm max},\\overline{\\eta}])\\,.\n\\end{array}\n\\end{equation}\nThis result can be written more explicitly as:\n\\begin{equation}\\label{eq:partcase}\n\\mathcal{P}(Q,0,0) = \n\\left\\{\n\\begin{array}{ll}\n0 & \\quad Q< 2p_{T,\\rm min}\\,,\\\\\n\\displaystyle \\tanh(\\overline{\\eta})=\\left(1+\\frac{2p_{T,\\rm min}}{Q}\\right)\\sqrt{1-\\frac{4 p_{T,\\rm min}}{Q+2p_{T,\\rm min}}}& \\quad 2p_{T,\\rm min} \\leq Q < 2p_{T,\\rm min}\\cosh\\eta_{\\rm max}\\,,\\\\\n\\tanh(\\eta_{\\rm max}) & \\quad Q \\geq 2p_{T,\\rm min}\\cosh\\eta_{\\rm max}\\,.\n\\end{array}\n\\right.\n\\end{equation}\nThis differs from Eq.~(24) of Ref.~\\cite{Scimemi:2017etj}. Despite the\nthree different regions coincide, the behavior of the phase-space\nreduction factor for all regions but for $Q< 2p_{T,\\rm min}$ is\ndifferent. In favour of our result there is the fact that\n$\\mathcal{P}(Q,0,0)$ in Eq.~(\\ref{eq:partcase}) is continuous at\n$Q = 2p_{T,\\rm min}\\cosh\\eta_{\\rm max}$ while that of\nRef.~\\cite{Scimemi:2017etj} is not. In addition, when setting\n$p_{T,\\rm min} = 0$ and $\\eta_{\\rm max}=\\infty$, \\textit{i.e.} no\ncuts, our result tends to $\\mathcal{P}(Q,0,0)=\\tanh(\\infty)=1$, as it\nshould. While the result in Eq.~(24) of Ref.~\\cite{Scimemi:2017etj}\nactually diverges in this limit.\n\nThe integrand of Eq.~(\\ref{eq:finalformula}), due to the behaviour of\n$x_1$ and $x_2$ as functions of $\\eta$, a piecewise\nfunction. Therefore, its numerical integration is problematic in that\nquadrature algorithms assume the integrand be continuos over the\nintegration range. The solution is to identify the discontinuity\npoints and integrate the function separately over the resulting\nranges. However, the complexity of the integration region\n(\\textit{e.g.} see Fig.~\\ref{fig:IntDomain}) makes the analytical\nidentification of the discontinuity points very hard to achieve.\n\n\\subsection{Contracting the leptonic tensor with $g_\\perp^{\\mu\\nu}$}\n\nThe calculation done in the previous section holds when contracting\nthe leptonic tensor $L_{\\mu\\nu}$ with the metric tensor $g^{\\mu\\nu}$\nassociated with the Lorentz structure of the hadronic tensor. However,\nat small values of $|\\mathbf{q}_T|$, the leading-power Lorentz\nstructure that one needs to multiply the leptonic tensor for is:\n\\begin{equation}\ng_\\perp^{\\mu\\nu} = g^{\\mu\\nu}+z^\\mu z^\\nu-t^\\mu t^\\nu\n\\end{equation}\nwhere the vectors $z^\\mu$ and $t^\\mu$ in the Collins-Soper (CS) frame\nare defined as:\n\\begin{equation}\\label{eq:auxvects}\n\\begin{array}{l}\n\\displaystyle z^\\mu = (\\sinh y,\\mathbf{0},\\cosh y)\\,,\\\\\n\\\\\n\\displaystyle t^\\mu = \\frac{q^\\mu}{Q}\\,,\n\\end{array}\n\\end{equation}\nand they are such that $z^2=-1$, $t^2=1$ and $zq = 0$. if we use the\non-shell-ness of $p_1$ and $p_2$ ($p_1^2=p_2^2=0$) and the momentum\nconservation ($p\\equiv p_1$, $p_2=q-p$), we find that\n$t^\\mu t^\\nu L_{\\mu\\nu}=0$ and the quantity above reduces to:\n\\begin{equation}\\label{eq:LT}\n  L_\\perp = g_\\perp^{\\mu\\nu}L_{\\mu\\nu} = 4\\left[\\frac12q^2 + 2(zp)^2\\right] = 2Q^2\\left[1+4 \\sinh^2(y-\\eta)\\frac{|\\mathbf{p}_T|^2}{Q^2}\\right]\\,.\n\\end{equation}\nTherefore, we need to introduce this factor in both the numerator and\nthe denominator of Eq.~(\\ref{eq:PSredDef4}). Following the same steps\nof the previous section, up to a factor $2Q^2$, this leads us to\nreplace the integral in Eq.~(\\ref{eq:firstintegral}) with(\\footnote{We\n  removed the $\\theta$-function as we know it does not have any\n  effect.}):\n\\begin{equation}\\label{eq:firstintegralNew}\n  \\frac12 \\int_0^\\infty|\\mathbf{p}_T|\\left[1+4\\sinh^2(y-\\eta)\n  \\frac{|\\mathbf{p}_T|^2}{Q^2}\\right]d|\\mathbf{p}_T|\\,\\delta(Q^2-2p\\cdot\n  q) =\\frac{2\\overline{p}_T^2}{Q^2}+\n  2\\sinh^2(y-\\eta)\\frac{\\overline{p}_T^4} {Q^4}\\,.\n\\end{equation}\nWe can still use Eq.~(\\ref{eq:complicatedintegral}) for the first term\nin the r.h.s. of the equation above. For the second, instead we need\nto use:\n\\begin{equation}\\label{eq:complicatedintegral2}\n\\begin{array}{rcl}\n\\displaystyle\\int \\frac{dx}{(a\\pm\n  x)^4\\sqrt{1-x^2}}&=&\\displaystyle\\frac{\\sqrt{1-x^2}\\left[(11a^2+4)x^2\\pm\n                       3 a(9a^2+1)x + (18a^4-5a^2+2)\\right]}{6(a^2-1)^3(x\\pm\n  a)^3}\\\\\n\\\\\n&\\pm&\\displaystyle\\frac{a(2a^2+3)}{2(a^2-1)^{7/2}}\\tan^{-1}\\left(\\frac{1\\pm\n      ax}{\\sqrt{a^2-1}\\sqrt{1-x^2}}\\right)\\,,\n\\end{array}\n\\end{equation}\nthat is such that:\n\\begin{equation}\n\\int_{-1}^{1} \\frac{dx}{(a\\pm\n  x)^4\\sqrt{1-x^2}}=\\frac{\\pi a(2a^2+3)}{2(a^2-1)^{7/2}}\\,.\n\\end{equation}\nIn our particular case, the integrand we are considering is the second\nterm in the r.h.s. term of Eq.~(\\ref{eq:firstintegralNew}):\n\\begin{equation}\\label{eq:integralmmm}\n\\begin{array}{l}\n\\displaystyle\n  \\frac{2\\sinh^2(y-\\eta)}{Q^4}\\int_{-1}^{1}d(\\cos\\phi)\\overline{p}_T^4(\\cos\\phi)=\\\\\n\\\\\n\\displaystyle\\frac{Q^4}{8q_T^4} \\sinh^2(y-\\eta) \\int_{-1}^{1} \\frac{dx}{\\sqrt{1-x^2}}\\left[\\frac{1}{(a+\n      x)^4}+\\frac1{(a-\n      x)^4}\\right]= \\frac{\\pi Q^4}{8q_T^4}\\sinh^2(y-\\eta) \\frac{\n  a(2a^2+3)}{(a^2-1)^{7/2}}\\,.\n\\end{array}\n\\end{equation}\nwith:\n\\begin{equation}\na =\\frac{M}{q_T}\\cosh(y-\\eta)\\,.\n\\end{equation}\nNow we need to integrate Eq.~(\\ref{eq:integralmmm}) over $\\eta$:\n\\begin{equation}\n  \\frac{\\pi Q^4}{8q_T^4} \\int_{-\\infty}^{\\infty}d\\eta\\sinh^2(y-\\eta)\\frac{\n    a(2a^2+3)}{(a^2-1)^{7/2}}\\,.\n\\end{equation}\nIf we make the following change of variable in the integral above:\n\\begin{equation}\nz=\\frac{M}{q_T}\\sinh(y-\\eta)\n\\end{equation}\nsuch that:\n\\begin{equation}\na^2 = z^2+\\frac{M^2}{q_T^2}\\quad\\mbox{and}\\quad dz = -ad\\eta\\,,\n\\end{equation}\nthe integral above becomes:\n\\begin{equation}\n\\frac{\\pi Q^4}{4M^2 q_T^2} \\int_{-\\infty}^{\\infty}dz\\frac{\n  z^2\\left(z^2+\\frac{M^2}{q_T^2}+\\frac32\\right)}{\\left(z^2+\\frac{M^2}{q_T^2}-1\\right)^{7/2}}=\\frac{\\pi}{6}\\,.\n\\end{equation}\nPutting this result together with Eq.~(\\ref{eq:remarkableintegral})\nand taking into account the factor $2Q^2$ in Eq.~(\\ref{eq:LT}), we find\nthat:\n\\begin{equation}\\label{eq:normalisation}\n\\begin{array}{l}\n  \\displaystyle \\int d^4p \\delta(p^2) \\delta((q-p)^2) \\theta(p_{0})\n  \\theta(q_0-p_{0})L_\\perp = \\frac{4\\pi}{3}Q^2\\,.\n\\end{array}\n\\end{equation}\nThis result agrees with Eq.~(2.38) of Ref.~\\cite{Scimemi:2017etj}, up\nto a factor four. This provides the denominator of the\nphase-space-reduction factor $\\mathcal{P}$. The structure of\n$\\mathcal{P}$ will be exactly like that in\nEq.~(\\ref{eq:finalformula}), the only thing we need to do is to\nidentify the correct function $F(x,\\eta)$. To this end, we need to\nmake the following replacement for the function $F$ given in\nEq.~(\\ref{eq:integrandF}) with:\n\\begin{equation}\\label{eq:FGcombination}\nF(x,\\eta)\\rightarrow \\overline{F}(x,\\eta) = \\frac34 F(x,\\eta)+ \\frac14 G(x,\\eta)\\,,\n\\end{equation}\nwhere:\n\\begin{equation}\\label{eq:integrandG}\n\\begin{array}{rcl}\n\\displaystyle G(x ,\\eta)&=&\\displaystyle \n                            \\frac{1}{16\\pi }\\sinh^2(y-\\eta)\\frac{Q^4}{(E_q^2-q_T^2)^3}\n                            \\Bigg\\{\\sqrt{1-x^2}q_T\\\\\n\\\\\n&\\times&\\displaystyle\\Bigg[\\frac{(11E_q^2q_T^2+4q_T^4)x^2+\n                       3 E_qq_T(9E_q^2+q_T^2)x + (18E_q^4-5E_q^2q_T^2+2q_T^4)}{(xq_T+\n  E_q)^3}\\\\\n\\\\\n&+&\\displaystyle\\frac{(11E_q^2q_T^2+4q_T^4)x^2-\n                       3 E_qq_T(9E_q^2+q_T^2)x + (18E_q^4-5E_q^2q_T^2+2q_T^4)}{(xq_T-\n  E_q)^3}\\Bigg]\\\\\n\\\\\n&-&\\displaystyle\\frac{6E_q (2E_q^2+3q_T^2)}{\\sqrt{E_q^2-q_T^2}}\\left[\\tan^{-1}\\left(\\frac{q_T-\n      xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right)-\\tan^{-1}\\left(\\frac{q_T+\n      xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right)\\right]\n\\Bigg\\}\\,.\n\\end{array}\n\\end{equation}\nFinally, combining the functions $F$ and $G$ given in\nEqs.~(\\ref{eq:integrandF}) and~(\\ref{eq:integrandG}), respectively,\naccording to Eq.~(\\ref{eq:FGcombination}) to obtain $\\overline{F}$,\nand replacing $F$ with $\\overline{F}$ in Eq.~(\\ref{eq:finalformula})\ngives the phase-space-reduction factor $\\mathcal{P}(Q,y,q_T)$ when the\nleptonic tensor $L_{\\mu\\nu}$ is contracted with the transverse metrics\n$g_\\perp^{\\mu\\nu}$.\n\nAs a final check, it is interesting to compute $\\mathcal{P}$ when\n$y=q_T=0$, again assuming $\\eta_{\\rm min} = -\\eta_{\\rm max}$. In this\nlimit $F$ reduces to the expression in Eq.~(\\ref{eq:F00}), while $G$\nbecomes:\n\\begin{equation}\n\\begin{array}{rcl}\n\\displaystyle G(x ,\\eta)&=&\\displaystyle \n                            \\frac{3}{4\\pi }\\frac{\\sinh^2(\\eta)}{\\cosh^4(\\eta)}\n                            \\Bigg\\{\\left[\\tan^{-1}\\left(\\frac{\n      x}{\\sqrt{1-x^2}}\\right)-\\tan^{-1}\\left(-\\frac{\n      x}{\\sqrt{1-x^2}}\\right)\\right]\n\\Bigg\\}\\,,\n\\end{array}\n\\end{equation}\nsuch that:\n\\begin{equation}\n\\begin{array}{rcl}\n  \\mathcal{P}(Q,0,0)&=&\\displaystyle\\frac38\\vartheta(Q- 2p_{T,\\rm min})\\displaystyle \\int_{-\\eta_{\\rm\n      max}}^{\\eta_{\\rm\n      max}}d\\eta\\left[\\frac{\\cosh^2(\\eta)+\\sinh^2(\\eta)}{\\cosh^4(\\eta)}\\right]\\,\\vartheta(\\eta+\\overline{\\eta})\n  \\vartheta(\\overline{\\eta}-\\eta)\\\\\n\\\\\n&=&\\displaystyle\\vartheta(Q- 2p_{T,\\rm\n    min})\\tanh(\\mbox{max}[\\eta_{\\rm max},\\overline{\\eta}])\\left[1-\\frac{1}{4\\cosh^2(\\mbox{max}[\\eta_{\\rm max},\\overline{\\eta}])}\\right]\\,,\n\\end{array}\n\\end{equation}\nwith $\\overline{\\eta}$ defined in Eq.~(\\ref{eq:etabardef}). The\nrelation above can be written more explicitly as:\n\\begin{equation}\\label{eq:partcase2}\n{\\footnotesize\n\\mathcal{P}(Q,0,0) = \n\\left\\{\n\\begin{array}{ll}\n0 & \\quad Q< 2p_{T,\\rm min}\\,,\\\\\n \\tanh(\\overline{\\eta})\\left[1-\\frac{1}{4\\cosh^2(\\overline{\\eta})}\\right]=\\left(1-\\frac{p_{T,\\rm min}^2}{Q^2}\\right)\\sqrt{1-\\frac{4 p_{T,\\rm min}^2}{Q^2}}& \\quad 2p_{T,\\rm min} \\leq Q < 2p_{T,\\rm min}\\cosh\\eta_{\\rm max}\\,,\\\\\n \\tanh(\\eta_{\\rm max})\\left[1-\\frac{1}{4\\cosh^2(\\eta_{\\rm max})}\\right] & \\quad Q \\geq 2p_{T,\\rm min}\\cosh\\eta_{\\rm max}\\,.\n\\end{array}\n\\right.}\n\\end{equation}\n\nThe reason why we kept $\\eta_{\\rm min} \\neq -\\eta_{\\rm max}$ is that\nin some cases it may be required to implement an asymmetric cut,\n$\\eta_{\\rm min}<\\eta<\\eta_{\\rm max}$. This is the case, for example,\nof the LHCb experiment that delivers data only in the forward region\n($2 < \\eta < 4.5$).\n\\begin{figure}[t]\n  \\begin{centering}\n    \\includegraphics[width=0.8\\textwidth]{plots/IntDomainAsy}\n    \\caption{Same as Fig.~\\ref{fig:IntDomain} for the asymmetric\n      rapidity cut $2<\\eta < 4.5$ at $y=3$.\\label{fig:IntDomainAsy}}\n  \\end{centering}\n\\end{figure}\nAs an example, Fig.~\\ref{fig:IntDomainAsy} shows the integration\ndomain of the phase-space reduction factor Eq.~(\\ref{eq:PSredDef4})\nfor $p_{T,\\rm min}=20$ GeV and $2<\\eta < 4.5$ at $Q=91$ GeV,\n$|\\mathbf{q}_T|=10$ GeV and $y=3$.\n\n\\subsection{Parity-violating contribution}\n\nIn the presence of cuts on the final-state leptons and for invariant\nmasses around the $Z$ mass, parity-violating effects arise. As we will\nshow below, these effects integrate to zero when removing the leptonic\ncuts. This contribution stems from interference of the antisymmetric\ncontributions to the lepton tensor, proportional to $p_1^{\\mu}\np_2^{\\nu}\\epsilon_{\\mu\\nu\\rho\\sigma}$, and the hadronic tensor,\nproportional to $\\epsilon_{\\perp}^{\\mu\\nu}$ defined as:\n\\begin{equation}\n\\epsilon_{\\perp}^{\\mu\\nu}\\equiv \\epsilon^{\\mu\\nu\\rho\\sigma}t_\\rho z_\\sigma\\,,\n\\end{equation}\nwhere $t^\\mu$ and $z^\\mu$ are given in Eq.~(\\ref{eq:auxvects}).\nTherefore, the contribution we are after results from the contraction\nof the following Lorentz structures:\n\\begin{equation}\nL_{\\rm PV}\\equiv p_1^{\\mu}\np_2^{\\nu}\\epsilon_{\\mu\\nu\\rho\\sigma}\\epsilon_{\\perp}^{\\rho\\sigma}\\,.\n\\end{equation}\nAfter some manipulation, one finds:\n\\begin{equation}\\label{eq:pvphasespace}\n\\begin{array}{rcl}\n\\displaystyle L_{\\rm PV}&=& \\displaystyle\np_1^{\\mu}\np_2^{\\nu}\\epsilon_{\\mu\\nu\\rho\\sigma}\\epsilon^{\\rho\\sigma\\alpha\\beta}t_\\alpha\nz_\\beta= -2 p_1^{\\mu}\np_2^{\\nu}\\delta_\\mu^\\alpha \\delta_\\nu^\\beta t_\\alpha \\\\\n\\\\\n&=&\\displaystyle -2 (p_1 t)(p_2 z) = -2 (pt)\\left[(qz)-(pz)\\right] = 2(pt)(pz)\\\\\n\\\\\n&=&\\displaystyle \\frac{2|\\mathbf{p}_T|^2}{Q}\\sinh(y-\\eta)\\left[M\\cosh(y-\\eta)-|\\mathbf{q}_T|\\cos\\phi\\right]\\,,\n\\end{array}\n\\end{equation}\nwhere I have defined $p_1\\equiv p$ and used the equalities\n$p_2 = q - p$, and $zq=0$. To compute the third line I have used the\nexplicit parameterisation of $q$ and $p$ given in\nEqs.~(\\ref{eq:qexplicit}) and~(\\ref{eq:pexplicit}), respectively. The\npresence of $\\sinh(y-\\eta)$ in Eq.~(\\ref{eq:pvphasespace}) is such\nthat integrating over the full range in the lepton rapidity $\\eta$\nnullifies this contribution:\n\\begin{equation}\\label{eq:noPVcontr}\n\\int_{-\\infty}^{\\infty} d\\eta\\,L_{\\rm PV} = 0\\,.\n\\end{equation}\nTherefore, it turns out that, for observables inclusive in the lepton\nphase space, the parity violating term does not give any\ncontribution. Conversely, the presence of cuts on the final-state\nleptons may prevent Eq.~(\\ref{eq:noPVcontr}) from being satisfied\nleaving a residual contribution. In order to quantify this effect, we\ntake the same steps performed in the previous sections to integrate\n$L_{\\rm PV}$ over the fiducial region. As above, we start integrating\nover the full range in $|\\mathbf{p}_T|$ using the on-shell-ness\n$\\delta$-function:\n\\begin{equation}\n\\begin{array}{c}\n\\displaystyle \\int_0^\\infty d|\\mathbf{p}_T||\\mathbf{p}_T|\\,L_{\\rm PV}=\\frac{\\sinh(y-\\eta)}{Q}\\left[M\\cosh(y-\\eta)-|\\mathbf{q}_T|\\cos\\phi\\right]\n\\int_0^\\infty d|\\mathbf{p}_T||\\mathbf{p}_T|^3\\delta(Q^2-2pq)\\\\\n\\\\\n\\displaystyle = \\frac{\\overline{p}_T^4}{Q^3}\\sinh(y-\\eta)\\left[M\\cosh(y-\\eta)-|\\mathbf{q}_T|\\cos\\phi\\right]\\,,\n\\end{array}\n\\end{equation}\nwith $\\overline{p}_T$ defined in Eq.~(\\ref{eq:overpT}). Now we compute\nthe indefinte integral over $\\cos\\phi$. To do so, we need to use\nEq.~(\\ref{eq:intoverphi}) along with the equality:\n\\begin{equation}\\label{eq:complicatedintegral3}\n\\int \\frac{dx}{(a\\pm\n  x)^3\\sqrt{1-x^2}}=\\frac{\\sqrt{1-x^2}\\left[3ax\\pm(4a^2-1) \\right]}{2(a^2-1)^2(x\\pm\n  a)^2}\\pm\\displaystyle\\frac{(2a^2+1)}{2(a^2-1)^{5/2}}\\tan^{-1}\\left(\\frac{1\\pm\n      ax}{\\sqrt{a^2-1}\\sqrt{1-x^2}}\\right)\\,.\n\\end{equation}\nThis allows us to compute the integral(\\footnote{The factor\n  $\\left(\\frac {4\\pi Q^2}{3}\\right)^{-1}$ in\n  Eq.~(\\ref{eq:Hdefinition}) corresponds to the full phase-space in\n  integral of $L_\\perp$ in Eq.~(\\ref{eq:normalisation}) that provides\n  the natural normalisation.}):\n\\begin{equation}\\label{eq:Hdefinition}\n\\begin{array}{rcl}\n\\displaystyle H(x,\\eta)&=&\\displaystyle\\left(\\frac {4\\pi Q^2}{3}\\right)^{-1}\\frac{\\sinh(y-\\eta)}{Q^3}\\left[M\\cosh(y-\\eta) \\int\n  d(\\cos\\phi)\\overline{p}_T^4(\\cos\\phi)- |\\mathbf{q}_T|\n  \\int d(\\cos\\phi) \\cos\\phi\\,\\overline{p}_T^4(\\cos\\phi)\\right]\\\\\n\\\\\n&=&\\displaystyle\\frac{3Q^3 \\sinh(y-\\eta)}{64\\pi |\\mathbf{q}_T|^4}\\left[M\\cosh(y-\\eta) \\int\n  \\frac{d(\\cos\\phi)}{\\left(a-\\cos\\phi\\right)^4}-|\\mathbf{q}_T|\\int\n  \\frac{\\cos\\phi \\,d(\\cos\\phi)}{\\left(a-\\cos\\phi\\right)^4}\\right]\\\\\n\\\\\n&=&\\displaystyle\\frac{3Q^3 \\sinh(y-\\eta)}{64\\pi q_T^3} \\int\n  \\frac{dx}{\\sqrt{1-x^2}}\\left[\\frac{1}{(a-x)^3}+\\frac{1}{(a+x)^3}\\right]\\\\\n\\\\\n&=&\\displaystyle\\frac{3Q^3 \\sinh(y-\\eta)}{128\\pi q_T^3}\\Bigg\\{\\frac{\\sqrt{1-x^2}}{(a^2-1)^2}\\left[\\frac{3ax-(4a^2-1) }{(x-\n  a)^2}+\\frac{3ax+(4a^2-1) }{(x+\n  a)^2}\\right]\\\\\n\\\\\n&-&\\displaystyle\\frac{(2a^2+1)}{(a^2-1)^{5/2}}\\left[\\tan^{-1}\\left(\\frac{1-\n      ax}{\\sqrt{a^2-1}\\sqrt{1-x^2}}\\right) -\\tan^{-1}\\left(\\frac{1+\n      ax}{\\sqrt{a^2-1}\\sqrt{1-x^2}}\\right)\\right]\\Bigg\\}\n\\end{array}\n\\end{equation}\nwith $E_q=M\\cosh\\left(\\eta - y\\right)$, $q_T=|\\mathbf{q}_T|$, and:\n\\begin{equation}\n  a = \\frac{E_q}{q_T}\\,,\n\\end{equation}\nso that:\n\\begin{equation}\\label{eq:Hfinal}\n\\begin{array}{rcl}\n\\displaystyle H(x,\\eta)&=&\\displaystyle\\frac{3Q^3 \\sinh(y-\\eta)}{128\\pi (E_q^2-q_T^2)^{2}}\\Bigg\\{\\sqrt{1-x^2}q_T\\left[\\frac{3E_qq_Tx-(4E_q^2-q_T^2) }{(xq_T-\n  E_q)^2}+\\frac{3E_qq_Tx+(4E_q^2-q_T^2) }{(q_Tx+\n  E_q)^2}\\right]\\\\\n\\\\\n&-&\\displaystyle\\frac{(2E_q^2+q_T^2)}{\\sqrt{E_q^2-q_T^2}}\\left[\\tan^{-1}\\left(\\frac{q_T-\n      xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right) -\\tan^{-1}\\left(\\frac{q_T+\n      xE_q}{\\sqrt{E_q^2-q_T^2}\\sqrt{1-x^2}}\\right)\\right]\\Bigg\\}\\,.\n\\end{array}\n\\end{equation}\nFinally, using the definition of $H$ in Eq.~(\\ref{eq:Hfinal}), one can\nperform the integral over the fiducial phase space as discussed\nabove in Eq.~(\\ref{eq:finalformula}):\n\\begin{equation}\\label{eq:finalformulaH}\n  \\mathcal{P}_{\\rm PV}(Q,y,q_T)=\\displaystyle \\int_{\\eta_{\\rm\n      min}}^{\\eta_{\\rm\n      max}}d\\eta\\,\\vartheta(x_2(\\eta)-x_1(\\eta))\\left[H(x_2(\\eta),\\eta)-H(x_1(\\eta) ,\\eta)\\right]\\,.\n\\end{equation}\nThis allows one to estimate the impact of the parity-violating\ncontribution to the phase-space reduction factor.\n\nIn order to quantify numerically the impact of\nEq.~(\\ref{eq:finalformulaH}), Fig.~\\ref{fig:PhaseSpaceRedFactor}\ndisplays the size $\\mathcal{P}_{\\rm PV}$ relative to the\nparity-conserving phase-space reduction factor as a function of $y$\nfor three different values of $q_T$ at $Q=M_Z$ and for the following\nlepton cuts: $p_{T,\\ell}>20$ GeV and $-2.4 < \\eta_\\ell < 2.4$.\n\\begin{figure}[t]\n  \\begin{centering}\n    \\includegraphics[width=0.8\\textwidth]{plots/PhaseSpaceRedFactor}\n    \\caption{Ratio between the parity-violating phase-space reduction\n      factor $\\mathcal{P}_{\\rm PV}$ in Eq.~(\\ref{eq:finalformulaH})\n      and the respective parity-conserving factor as a function of the\n      $Z$ rapidity $y$ at $Q=M_Z$ and for three different values of\n      $q_T$, with lepton cuts equal to $p_{T,\\ell}>20$~GeV and\n      $-2.4 < \\eta_\\ell < 2.4$.\\label{fig:PhaseSpaceRedFactor}}\n  \\end{centering}\n\\end{figure}\nIt turns out that the size of $\\mathcal{P}_{\\rm PV}$ relative to\n$\\mathcal{P}$ is never larger than $2\\times10^{-6}$. In addition, the\nrapid oscillations with $y$ contribute to suppress even more the\nintegral over realistic bins in $y$. One can thus conclude that, for\nrealistic kinematic configurations, the impact of parity violating\neffects is completely negligible.\n\n% To conclude this section we try to compute analytically the behaviour\n% of $\\mathcal{P}_{\\rm PV}$ in a particular kinematic configuration. For\n% $q_T = y = 0$ one has that:\n% \\begin{equation}\n% \\displaystyle H(x,\\eta)=-\\frac{3\n%                            \\sinh(\\eta)}{64\\pi \\cosh^3(\\eta)}\\displaystyle \\left[\\tan^{-1}\\left(\\frac{x}{\\sqrt{1-x^2}}\\right) -\\tan^{-1}\\left(\\frac{-x}{\\sqrt{1-x^2}}\\right)\\right]\\,.\n% \\end{equation}\n\n\n\\section{Differential cross section in the leptonic variables}\n\nThe calculation of the phase-space reduction factor carried out in the\nprevious section can be used to express the Drell-Yan cross section in\nEq.(\\ref{eq:crosssection}) as differential in the kinematic variables\nof the single leptons. Loosely speaking, this amounts to removing the\nintegral sign in the numerator in Eq.~(\\ref{eq:PSredDef}) but taking\ninto account kinematic constraints. Using the transverse metric tensor\n$g_\\perp^{\\mu\\nu}$, one finds:\n\\begin{equation}\nd\\mathcal{P} = \\frac{\\displaystyle d^4p_1 d^4p_2 \\,\\delta(p_1^2) \\delta(p_2^2)\\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) L_\\perp(p_1,p_2)}{\\displaystyle \\int d^4p_1 d^4p_2\\, \\delta(p_1^2) \\delta(p_2^2) \\theta(p_{1,0}) \\theta(p_{2,0})\\delta^{(4)}(p_1+p_2-q) L_\\perp(p_1,p_2)}\\,,\n\\end{equation}\nFrom Eq.~(\\ref{eq:normalisation}), we know the value of the\ndenominator. In the numerator, we can make use of the\nmomentum-conservation and one of the on-shell-ness\n$\\delta$-functions. Using the r.h.s. of\nEq.~(\\ref{eq:firstintegralNew}), but integrating over $\\phi$ rather\nthan $|\\mathbf{p}_T|$, leads to:\n\\begin{equation}\n\\frac{d\\mathcal{P}}{d|\\mathbf{p}_T|d\\eta} = \\frac {3 |\\mathbf{p}_T|}{4\\pi}\\left[1+4 \\sinh^2(y-\\eta)\\frac{|\\mathbf{p}_T|^2}{Q^2}\\right]\n \\int_0^{2\\pi} d\\phi\\,\\delta(Q^2-2 |\\mathbf{p}_T|\\left[M\\cosh\\left(\\eta - y\\right)-|\\mathbf{q}_T|\\cos\\phi\\right])\\,,\n\\end{equation}\nwhere we have used\nEqs.~(\\ref{eq:phasespacemeasure})-(\\ref{eq:integralyeah!}) and\nEq.~(\\ref{eq:deltaargument}). Finally, to perform the integral over\n$\\phi$ we use Eq.~(\\ref{eq:intoverphi}) to get:\n\\begin{equation}\n\\frac{d\\mathcal{P}}{d|\\mathbf{p}_T|d\\eta} = \\frac {3|\\mathbf{p}_T|}{2\\pi Q^2}\n \\frac{Q^2+4 |\\mathbf{p}_T|^2 \\sinh^2(\\eta-y)}{\\sqrt{4|\\mathbf{p}_T|^2|\\mathbf{q}_T|^2-(2|\\mathbf{p}_T|M\\cosh(\\eta-y)-Q^2)^2}}\\,.\n\\end{equation}\nGetting rid of the absolute value of the transverse vectors, this\nallows one to get the Drell-Yan cross section differential in the\nleptonic variables $|\\mathbf{p}_T|$ and $\\eta$:\n\\begin{equation}\n\\frac{d\\sigma}{dQ dy dq_T d\\eta dp_T} =\n                                                          \\left[\\frac\n                                                          {3p_T^2}{\\pi\n                                                          Q^2 M}\\frac{\\left(\\frac{Q^2}{4 p_T^2}-1\\right)+\\cosh^2(\\eta-y)}{\\sqrt{\\frac{q_T^2}{M^2}-\\left(\\cosh(\\eta-y)-\\frac{Q^2}{2p_TM}\\right)^2}}\\right]\\frac{d\\sigma}{dQ dy dq_T}\\,.\n\\end{equation}\nDue to the square root in the denominator, for fixed values of $Q$,\n$q_T$, and $y$, the expression above is defined for values of $p_T$\nand $\\eta$ such that:\n\\begin{equation}\\label{eq:kinconstr}\n\\frac{Q^2}{2p_TM}-\\frac{q_T }{M}< \\cosh(\\eta-y) < \\frac{Q^2}{2p_TM}+\\frac{q_T}{M}\\,.\n\\end{equation}\n\nIn order to focus on the $p_T$ dependence of the cross section, one\nmay want to integrate of the lepton rapidity $\\eta$. Using the\nanalogous of Eq.~(\\ref{eq:intoverphi}) for $\\cosh(\\eta)$:\n\\begin{equation}\\label{eq:intovereta}\n\\int_{-\\infty}^{\\infty}d\\eta\\, f(\\cos\\eta) = \\int_{1}^{\\infty}\\frac{dx}{\\sqrt{x^2-1}}\\left[f(x)+f(-x)\\right]\\,,\n\\end{equation}\nand taking into account the constraint in Eq.~(\\ref{eq:kinconstr}),\none finds:\n\\begin{equation}\\label{eq:LeptonicModulation}\n\\begin{array}{l}\n\\displaystyle \\frac{d\\sigma}{dQ dy dq_T dp_T} =\\frac{d\\sigma}{dQ dy\n  dq_T} \\times\\\\\n\\\\\n\\displaystyle\\frac\n                                                          {3p_T}{2\\pi\n                                                          Q^2}\\int_{-\\frac{q_T}{M}}^{\\frac{q_T}{M}}\n  \\frac{dy}{\\sqrt{\\frac{q_T^2}{M^2}-y^2}}\\left(\\frac{\\left(\\frac{Q^2}{4\n  p_T^2}-1\\right)+\\left(y+\\frac{Q^2}{2p_TM}\\right)^2}{\\sqrt{\\left(y+\\frac{Q^2}{2p_TM}\\right)^2-1}}+\\frac{\\left(\\frac{Q^2}{4\n  p_T^2}-1\\right)+\\left(y-\\frac{Q^2}{2p_TM}\\right)^2}{\\sqrt{\\left(y-\\frac{Q^2}{2p_TM}\\right)^2-1}}\\right)\\,.\n\\end{array}\n\\end{equation}\nFor fixed values of $Q$, $q_T$, and $y$, the integral above can be\nsolved numerically a plotted as a function of $p_T$. The result is\nshown in Fig.~\\ref{fig:LeptonicModulation}.\n\\begin{figure}[t]\n  \\begin{centering}\n    \\includegraphics[width=0.8\\textwidth]{plots/LeptonicModulation}\n    \\caption{Behaviour of the second line of\n      Eq.~(\\ref{eq:LeptonicModulation}) at $Q=M_Z$ and $y=0$ as a\n      function of the lepton transverse momentum\n      $p_{T,\\ell}$.\\label{fig:LeptonicModulation}}\n  \\end{centering}\n\\end{figure}\n\n\\section{Convolution in transverse-momentum space}\n\nThe ``transverse-momentum'' version of Eq.~(\\ref{eq:crosssection}) reads:\n\\begin{equation}\\label{eq:crosssectionkt}\n\\begin{array}{rcl}\n  \\displaystyle \\frac{d\\sigma}{dQ dy dq_T} &=&\\displaystyle \n  \\frac{16\\pi\\alpha^2q_T}{9 Q^3} H(Q,\\mu) \\sum_q C_q(Q)\\\\\n\\\\\n&\\times&\\displaystyle \n  \\int d^2\\mathbf{k}_{T,1}d^2\\mathbf{k}_{T,2}\n  \\overline{F}_q(x_1,\\mathbf{k}_{T,1};\\mu,\\zeta)\n  \\overline{F}_{\\bar{q}}(x_2,\\mathbf{k}_{T,2};\\mu,\\zeta)\\delta^{(2)}(\\mathbf{q}_{T}-\\mathbf{k}_{T,1}-\\mathbf{k}_{T,2})\\,,\n\\end{array}\n\\end{equation}\nwhere, with abuse of notation, we used the same symbol for the\ndistributions $F$ both in $k_T$ and $b_T$ space. We can make use of\nthe $\\delta$-function to reduce the expression above to:\n\\begin{equation}\\label{eq:crosssectionkt2}\n\\frac{d\\sigma}{dQ dy dq_T} =\\frac{16\\pi\\alpha^2q_T}{9 Q^3} H(Q,\\mu) \\sum_q C_q(Q)\\int d^2\\mathbf{k}_{T}\n  \\overline{F}_q(x_1,\\mathbf{k}_{T};\\mu,\\zeta)\n  \\overline{F}_{\\bar{q}}(x_2,\\mathbf{q}_{T}-\\mathbf{k}_{T};\\mu,\\zeta)\\,.\n\\end{equation}\nSince the distributions $F$ only depend on the absolute value of their\nargument (be it $k_T$ or $b_T$), the expression above can be further\nreduced to:\n\\begin{equation}\\label{eq:crosssectionkt3}\n\\begin{array}{rcl}\n\\displaystyle \\frac{d\\sigma}{dQ dy dq_T} &=&\\displaystyle\n                                             \\frac{16\\pi\\alpha^2q_T}{9\n                                             Q^3} H(Q,\\mu) \\sum_q\n                                             C_q(Q)\\\\\n\\\\\n&\\times&\\displaystyle \\int_0^\\infty dk_{T}\\,k_{T}\\int_0^{2\\pi}d\\theta\\,\n  \\overline{F}_q(x_1,k_T;\\mu,\\zeta)\n  \\overline{F}_{\\bar{q}}(x_2,\\sqrt{q_{T}^2+k_{T}^2\n  -2q_{T}k_{T}\\cos\\theta};\\mu,\\zeta)\\,,\n\\end{array}\n\\end{equation}\nwhere, without loss of generality, we are assuming that the vector\n$\\mathbf{q}_T$ is directed along the $x$ axis. Knowing the functions\n$F$ in $k_T$ space, the formula above can be implemented numerically.\n\n\\newpage\n\n\\begin{thebibliography}{alp}\n\n%\\cite{Scimemi:2017etj}\n\\bibitem{Scimemi:2017etj}\n  I.~Scimemi and A.~Vladimirov,\n  %``Analysis of vector boson production within TMD factorization,''\n  arXiv:1706.01473 [hep-ph].\n  %%CITATION = ARXIV:1706.01473;%%\n  %2 citations counted in INSPIRE as of 24 Oct 2017\n\n%\\cite{Collins:2011zzd}\n\\bibitem{Collins:2011zzd}\n  J.~Collins,\n  %``Foundations of perturbative QCD,''\n  Camb.\\ Monogr.\\ Part.\\ Phys.\\ Nucl.\\ Phys.\\ Cosmol.\\  {\\bf 32} (2011) 1.\n  %%CITATION = CMPCE,32,1;%%\n  %327 citations counted in INSPIRE as of 21 Oct 2018\n\n\\bibitem{Ogata:quadrature}\n  H.~Ogata,\n  ``A Numerical Integration Formula Based on the Bessel Functions,''\n  \\texttt{http://www.kurims.kyoto-u.ac.jp/$\\sim$okamoto/paper/Publ\\_RIMS\\_DE/41-4-40.pdf}\n\n\\end{thebibliography}\n\n\\end{document}\n", "meta": {"hexsha": "e7e348e59fea4d38c8d325d4bfb57b7d2510528a", "size": 94573, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/src/DrellYanTMD.tex", "max_stars_repo_name": "intrepid42/apfelxx", "max_stars_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/src/DrellYanTMD.tex", "max_issues_repo_name": "intrepid42/apfelxx", "max_issues_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/src/DrellYanTMD.tex", "max_forks_repo_name": "intrepid42/apfelxx", "max_forks_repo_head_hexsha": "34b0bb4f134ddf42aa7eccceaa6c3b91b5414cd6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.498974359, "max_line_length": 340, "alphanum_fraction": 0.6595011261, "num_tokens": 35725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5312093733737563, "lm_q1q2_score": 0.40101791712441026}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\subsubsection{Geodesic deviation in the proper detector frame}\n\n\\marginpar{Monday\\\\ 2020-3-23, \\\\ compiled \\\\ \\today}\n\n% We were discussing the proper detector frame: it is defined by rigid rulers around one point in free fall.\n\nWhat happens in this frame? The equation of geodesic deviation can be calculated from \\eqref{eq:geodesic-deviation-equation-slow-objects}:\n%\n\\begin{subequations}\n\\begin{align}\n0 &= \\dv[2]{\\xi^{i}}{\\tau}\n+ 2 \\Gamma^{i}_{\\nu \\rho } \\dv{x^{\\nu }}{\\tau } \\dv{x^{\\rho }}{\\tau }\n+ \\xi^{\\sigma } \\qty( \\partial_{\\sigma } \\Gamma^{i}_{\\nu \\rho } ) \\dv{x^{\\nu }}{\\tau } \\dv{x^{\\rho }}{\\tau }  \\\\\n&=\\dv[2]{\\xi^{i}}{\\tau}\n+ \\xi^{j} \\qty(\\partial_{j} \\Gamma^{j}_{00}) \\qty(\\dv{x^{0}}{\\tau })^2\n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhere we made the nonrelativistic approximation where the spacelike components of the four-velocity are negligible, and accounted for the fact that in this frame we have  \n%\n\\begin{align}\n\\Gamma^{\\mu }_{\\nu \\rho } = 0\n\\qquad \\text{and} \\qquad\n\\partial_0 \\Gamma^{i}_{0j} =0 \n\\implies \nR^{i}_{0j0} = \\partial_{j} \\Gamma^{i}_{00} \n\\,,\n\\end{align}\n%\nso we can write the geodesic equation in terms of the Riemann tensor as:\n%\n\\begin{align}\n0= \\dv[2]{\\xi^{i}}{\\tau } + R^{i}_{0j0} \\xi^{j} \\qty(\\dv{x^{0}}{\\tau })^2\n\\,,\n\\end{align}\n%\nand since in linearized gravity the Riemann tensor is \\emph{invariant} (rather than covariant) under coordinate transformations\\footnote{This can be seen by plugging the transformation law which is allowed in linearized gravity, \\(h_{\\mu \\nu } \\to h_{\\mu \\nu } + \\partial_{(\\mu } h_{\\nu )}\\), into the LIF expression for the Riemann tensor, \n%\n\\begin{align}\nR_{\\mu \\nu \\rho \\sigma } = -2 g_{[\\mu | [\\rho | , |\\nu ] \\sigma] }\n\\,,\n\\end{align}\n%\nwhich yields no change (the expression is a compact way to write that the indices to antisymmetrize are both \\(\\mu \\nu \\) and \\(\\rho \\sigma \\)). This is discussed by Maggiore \\cite[below eq.\\ 1.13]{maggioreGravitationalWavesVolume2007}.}\nsuch as those we used to move between the TT gauge and the detector frame, \nwe can compute it in the TT gauge starting from equation \\eqref{eq:riemann-tensor-LIF}: \n%\n\\begin{align}\nR^{i}_{0j0} &= \\frac{1}{2} \\qty(\n  \\partial_{j} \\partial_0 h^{i}_{0}\n  + \\partial_0 \\partial^{i} h_{0j} \n  - \\partial_{j} \\partial^{i} h_{00} \n  - \\partial_0 \\partial_0 h^i_{j}\n) = R_{i0j0} \\\\\n&= - \\frac{1}{2} \\partial_0 \\partial_0 h_{ij} = - \\frac{1}{2} \\ddot{h}_{ij}^{TT}\n\\,,\n\\end{align}\n%\nso our final result for the geodesic deviation equation in the detector frame is:\n%\n\\boxalign{\n\\begin{align} \\label{eq:geodesic-deviation-detector-frame}\n\\ddot{\\xi}^{i} = \\frac{1}{2} \\ddot{h}^{TT}_{ij} \\xi^{j}\n\\,,\n\\end{align}}\n%\nwhich is physically significant since we can interpret the effect of the GW as that of a Newtonian force, given by\n%\n\\begin{align}\nF^{i} = \\frac{m}{2} \\ddot{h}^{TT}_{ij} \\xi^{j}\n\\,.\n\\end{align}\n\nThis seems great! We can have particles move under the influence of the GW, work with \\(h_{ij}\\) in the simple TT gauge, while still being in almost flat spacetime.\n\nHowever, to get here we made some approximations, and we need to check whether they are justified.\n% How do we decide whether these approximations are justified?\nWe imposed \\(r^2 / L_B^2 \\ll 1 \\), where \\(L_B\\) is the scale of the variations of the metric while \\(r\\) is the scale of our detector. \nFor ground-based detectors which are \\(\\sim \\SI{3}{km}\\) long and sensitive in the \\(\\sim \\SI{100}{Hz}\\) range (corresponding to \\(\\lambda \\sim \\SI{3000}{km}\\)) this is perfectly fine. \nFor space-based detectors like LISA it is not!\n\nWhat we have calculated applies to proper distances as well, which are the same as coordinate distances up to first order in our coordinates.\nSo, since proper distances are invariant, we have an approximate expression which we can use in general, by substituting \\(s\\) for \\(\\xi \\) in the differential equation. \n\n\\subsubsection{Effects of GW}\n\nThis result allows us to see that the GWs are \\textbf{transverse}: for a wave along the \\(z\\) direction the equation reads \n%\n\\begin{align}\n\\ddot{\\xi}^{3} = \\frac{1}{2} \\ddot{h}_{3j}^{TT} \\xi^{j} = 0\n\\,,\n\\end{align}\n%\nso the particle does not move along the direction of propagation;\non the other hand we can do the calculations for particles starting out with small separations along \\(x\\) or \\(y\\).\n\nWe consider an initial displacement vector \\(\\xi_{i} (t = 0) = (x_0, y_0 , 0)\\), allow it to vary denoting it as \\(\\xi_i (t) = (x_0 + \\delta x, y_0 + \\delta y, 0) = \\xi_i (t=0) + \\delta \\xi_i (t)\\) and compute: \n%\n\\begin{align}\n\\ddot{x}_{i} = \\delta \\ddot{\\xi}_{i} = \\frac{1}{2} \\ddot{h}_{ij}^{TT} (\\xi_{j} + \\delta \\xi_j)\n\\approx \\frac{1}{2} \\ddot{h}_{ij}^{TT} \\xi_{j}\n\\,,\n\\end{align}\n%\nsince the variation \\(\\delta \\xi \\) is of the same perturbative order as \\(h_{ij}\\), making the term containing it second order. \n\nSo, after we take the real part of the exponential in \\(h_{ij}\\) and ignore the \\(z\\) dependence (which just gives a constant phase, since \\(z\\) is fixed) we get\n%\n\\begin{align}\n\\dv[2]{}{t} \\left[\\begin{array}{c}\n\\delta x \\\\ \n\\delta y\n\\end{array}\\right]\n&= \\frac{1}{2} \\left[\\begin{array}{cc}\nh_+ & h_{ \\times } \\\\ \nh_{ \\times } & - h_+\n\\end{array}\\right]\n\\dv[2]{}{t} \\qty(\\cos(\\omega t))\n\\left[\\begin{array}{c}\nx_0 \\\\ \ny_0 \n\\end{array}\\right]  \\\\\n&= \\frac{1}{2} \\left[\\begin{array}{cc}\nh_+ & h_{ \\times } \\\\ \nh_{ \\times } & - h_+\n\\end{array}\\right]\n\\left[\\begin{array}{c}\nx_0 \\\\ \ny_0 \n\\end{array}\\right]\n\\qty(- \\omega^2 \\cos(\\omega t))\n\\,.\n\\end{align}\n\nWhen we integrate to get \\(\\delta x\\) and \\(\\delta y\\) the factor \\(- \\omega^2 \\) gets reabsorbed. \n\nFor the plus polarization \\(h_+\\) (setting \\(h_{ \\times } = 0\\)) we find \n%\n\\begin{subequations}\n\\begin{align}\n  \\delta x &= \\frac{1}{2} h_{+} x_0 \\cos(\\omega t)  \\\\\n  \\delta y &= - \\frac{1}{2} h_{+} y_0 \\cos(\\omega t)  \n\\,,\n\\end{align}\n\\end{subequations}\n%\nwhile for the cross polarization \\(h_{ \\times }\\) (setting \\(h_{+} = 0\\)) we get \n%\n\\begin{subequations}\n\\begin{align}\n\\delta x &= \\frac{1}{2} h_{ \\times } y_0 \\cos(\\omega t)  \\\\\n\\delta y &= \\frac{1}{2} h_{ \\times } x_0 \\cos(\\omega t)  \n\\,.\n\\end{align}\n\\end{subequations}\n\n\\todo[inline]{There is a wrong sign in the slides here.}\n\n% We can also have circular polarizations, like \\(h_+ \\pm i h_{  \\times }\\). \n\nAre these considerations valid for \\textbf{Earth-based detectors}? \nThey are definitely not free-falling, in fact: \n\\begin{enumerate}\n  \\item at zeroth order the metric is flat;\n  \\item at first order we have the Newtonian forces, such as the Earth's gravity, the Coriolis force, the centrifugal force and such;\n  \\item at second order we get the curvature contributions from GW and the background metric.\n\\end{enumerate}\n\nSo, how do we distinguish these second-order GW effects from other second-order effects?\nWe can isolate them by Fourier analysis: we only look at the Fourier window in which they are dominant. \n\n% How do we know that our ``free-falling'' mass is moving because of the GW and not because of other noises?\n% We can bound the mass and distance of a source of GW we detect in a certain frequency region. \n\n% At the low frequencies, we have objects on the Earth making noise. \n\n% Now, let us move towards GW \\emph{generation}.\n\n\\section{GW generation}\n\nThe assumptions we will make are \n\\begin{enumerate}\n  \\item expanding around flat spacetime;\n  \\item consider nonrelativistic systems;\n  \\item assume the stress energy tensor is conserved: to first order, this reads \n  %\n  \\begin{align}\n  \\partial^{\\mu} T_{\\mu \\nu } = 0\n  \\,.\n  \\end{align}  \n\\end{enumerate}\n\nIf the system we consider is self-gravitating (like a binary), then being nonrelativistic means that it is also large with respect to its Schwarzschild radius:\n%\n\\begin{align}\nE _{\\text{kin}} = \n- \\frac{1}{2} U \\implies \n\\frac{1}{2} \n\\mu v^2 = \n\\frac{1}{2} G \\frac{\\mu M}{r} \n\\implies \\frac{v^2}{c^2} \n= \\frac{GM}{c^2 r} \n= \\frac{R_S}{r} \\ll 1\n\\,.\n\\end{align}\n\nThe expression of the gravitational force is that since, by the definition of the reduced mass, we have \\(m_1 m_2 = \\mu M \\). \n\nRecall the \\(\\Lambda_{ij, kl}\\) tensor \\eqref{eq:lambda-projection-tensor}, which can be used to project a rank-two spacelike tensor to the TT gauge. \n\nWe will proceed as section 17.6 in Hobson \\cite[]{hobsonGeneralRelativityIntroduction2006a}.\nIn order to solve the linearized equations \\eqref{eq:linearized-wave-equations}, we use Green's functions, which are defined by: \n%\n\\begin{align}\n\\square_x G(x -y) = \\delta^{(4)} (x-y)\n\\,,\n\\end{align}\n%\nwhere \\(x\\) is our variable, while \\(y\\) is a coordinate which will span the positions in the source.\nThe operator \\(\\square_x\\) is the Dalambertian with respect to the \\(x\\) coordinates. \n\nThe idea of this method is to calculate the wave response to a single impulsive source, and then superimpose the effects of many of these. \nWe introduce \\(\\kappa = 1/ M_P^2\\) for simplicity, multiply the previous equality by \\(T_{\\mu \\nu } (y)\\) and integrate in \\(\\dd[4]{y}\\) so we get\n%\n\\begin{align}\n-2 \\kappa \\int \\dd[4]{y} \\square_x G(x-y) T_{\\mu \\nu } (y) &= -2\\kappa  \\int \\dd[4]{y} \\delta^{(4)} (x-y) T_{\\mu \\nu }(x)  \n\\marginnote{The argument of the right \\(T_{\\mu \\nu }\\) can be switched to \\(x\\) because of the delta.}\n\\\\\n-2 \\kappa \\square_x \\qty(\\int \\dd[4]{y} G(x-y) T_{\\mu \\nu } (y))\n&= - 2 \\kappa T_{\\mu \\nu }(x) = \\square_x \\overline{h}_{\\mu \\nu } (x)\n\\,,\n\\end{align}\n%\nso we will have as a solution a superposition of the homogeneous solution and the source term:\n%\n\\begin{align} \\label{eq:green-function-solution-linearized-EFE}\n\\overline{h}_{\\mu \\nu } (x) = \\underbrace{\\overline{h}^{(0)}_{\\mu \\nu }(x)}_{\\square \\overline{h}^{(0)}_{\\mu \\nu } = 0}\n- 2\\kappa  \\int \\dd[4]{y} G(x-y) T_{\\mu \\nu }(y)\n\\,.\n\\end{align}\n\nIn order to make the Green's function explicit, we write it as centered around the origin:\n%\n\\begin{align}\n\\partial_{\\mu } \\partial^{\\mu } G(x^{\\sigma }) = \\delta^{(4)} (x^{\\sigma })\n\\,,\n\\end{align}\n%\nand we integrate this equality over a hypercylinder \\(V\\) (the product of a 3-sphere of radius \\(r = \\abs{\\vec{x}}\\) and an interval \\([-ct, ct]\\subset \\mathbb{R}\\), where \\(ct > r\\)) we have \n%\n\\begin{subequations}\n\\begin{align}\n\\int_V \\dd[4]{x} \\delta^{(4)} (x^{\\sigma }) &= 1  = \\int_{V} \\dd[4]{x} \\partial_{\\mu } \\partial^{\\mu } G(x^{\\sigma })  \\\\\n&= \\int \\dd{S} \\qty(\\partial_{\\mu } G(x^{\\sigma })) n^{\\mu } \n\\,,\n\\end{align}\n\\end{subequations}\n%\nbut the only points which can contribute are in the future light-cone because of causality, so the dependence of \\(G\\) upon \\(x^{\\sigma }\\) must be in the form \\(G(x^{\\sigma }) = f(r) \\delta (ct - r) [ct \\geq 0]\\).\\footnote{The bracket is an Iverson bracket \\cite[]{knuthTwoNotesNotation1992}, it evaluates to 1 or 0 depending on whether the expression inside it is true or false.}\n\nWe write \\(\\dd{S} = c \\dd{t} r^2 \\dd{\\Omega }\\),\\footnote{The \\(r^2\\) is missing in Hobson \\cite[pag.\\ 477]{hobsonGeneralRelativityIntroduction2006a} as well, but it should be there.} and we call \\(n^{\\mu } \\partial_{\\mu } = \\partial_{r}\\): \n%\n\\begin{subequations}\n\\begin{align}\n1 &= \\int \\dd{S} \\qty(\\partial_{\\mu } G(x^{\\sigma })) n^{\\mu }  \\\\\n&= 4 \\pi r^2 \\int_0^{ \\infty } \\dd{t} \\partial_{r} \\qty(f(r) \\delta (ct-r) )c  \\\\\n&= 4 \\pi r^2 \\partial_{r} f(r) c + 4 \\pi r^2 f(r) \\underbrace{\\int_{0}^{ \\infty }  \\partial_{r} \\delta (ct - r) c \\dd{t}}_{= 0}\n\\marginnote{The derivative of the delta evaluates the derivative of the thing it multiplies, which is a constant.}\n\\,,\n\\end{align}\n\\end{subequations}\n%\nso we can get an explicit expression for the function \\(f(r)\\):\n%\n\\begin{align}\n4 \\pi r^2 \\partial_{r} f(r) = 1 \\implies \nf(r) = - \\frac{1}{4 \\pi r}\n\\implies G(x^{\\sigma }) = - \\frac{ \\delta (x^{0} - \\abs{\\vec{x}})}{4 \\pi \\abs{\\vec{x}}} \\theta_H (x^{0})\n\\marginnote{The integration constant is set to zero so that the Green function vanishes at infinity.}\n\\,.\n\\end{align}\n\nWe can then plug this into the general solution \\eqref{eq:green-function-solution-linearized-EFE} to find\n%\n\\begin{align}\n\\overline{h}_{\\mu \\nu } \n(t, \\vec{x}) \n&= (-)^2 2 \\kappa \\int \\dd[4]{y} \\frac{ \\delta (x^{0} - y^{0} - \\abs{\\vec{x} - \\vec{y}})}{4 \\pi \\abs{\\vec{x} - \\vec{y}}} \\theta_H (x^{0} - y^{0}) T_{\\mu \\nu } (y)  \\\\\n&= \\frac{4G}{c^{4}} \\int \\dd[4]{y}  \\frac{ \\delta (y^{0} - (ct - \\abs{\\vec{x} - \\vec{y}}))}{\\abs{\\vec{x} - \\vec{y}}} T_{\\mu \\nu } (y^{0}, \\vec{y})\n\\marginnote{\\(\\kappa = 8 \\pi G / c^{4}\\).}\n\\\\ &=\n\\frac{4G}{c^{4}}\n\\int \\dd[3]{y} \\frac{T_{\\mu \\nu } (ct - \\abs{\\vec{x}-\\vec{y}}, \\vec{y})}{\\abs{\\vec{x} - \\vec{y}}}\n\\,.\n\\end{align}\n\nAs long as we are outside the source we can move to the TT gauge, since there the equation \\(\\square \\overline{h}_{\\mu \\nu }\\) satisfies the EFE, so we can do the required gauge change of variables with \\(\\square \\xi^{\\mu \\nu } = 0\\). \nNow, in order to move to the TT gauge we can use the \\(\\Lambda \\) tensor. It is equivalent to apply it to the trace-reversed \\(\\overline{h}_{ij}\\) or to \\(h_{ij}\\), since the tensor is projected into the space of traceless tensors anyways.\\footnote{Formally, this is shown as \n%\n\\begin{align}\n\\Lambda_{ij, kl} \\overline{h}_{kl} = \\Lambda_{ij, kl} \\qty(h_{kl} - \\frac{1}{2} \\eta_{kl} h) = \\Lambda_{ij, kl} h_{kl} - \\underbrace{\\frac{1}{2} \\Lambda_{ij, kk}}_{= 0} h = \\Lambda_{ij, kl} h_{kl} \n\\,.\n\\end{align}\n}\n\nSo, the general expression for our TT-gauge tensor measured at a position \\(\\vec{x}\\) outside the source, with \\(\\hat{n} = \\vec{x} / \\abs{x}\\):\n%\n\\boxalign{\n\\begin{align}\nh_{ij}^{TT} (ct, \\vec{x}) =  \\Lambda_{ij, kl} (\\hat{n}) \\overline{h}_{kl}\n= \\frac{4G}{c^{4}} \\Lambda_{ij, kl} (\\hat{n}) \\int \\dd[3]{y} \\frac{T_{kl } (ct - \\abs{\\vec{x} - \\vec{y}}, \\vec{y})}{\\abs{\\vec{x} - \\vec{y}}}\n\\,.\n\\end{align}}\n\nFar from the source, \\(\\abs{\\vec{x}} \\gg \\abs{\\vec{y}}\\) for any \\(\\vec{y}\\) inside the source.\nSo, we can expand:\\footnote{\n  The full calculation goes as follows: \n  %\n  \\begin{align}\n  \\abs{x - y} &= \\sqrt{(x - y)^2} = \\sqrt{x^2 + y^2 - 2 x \\cdot y} = r \\sqrt{1 - 2 \\frac{\\hat{n} \\cdot y}{r} + \\frac{y^2}{r^2}}  \\\\\n  &\\approx r \\qty(1 - \\frac{\\hat{n} \\cdot y}{r} + \\order{\\frac{d^2}{r^2}} )\n  \\,,\n  \\end{align}\n  %\n  where \\(d\\) is the length scale of the source, such that \\(\\abs{y} \\leq d\\).\n}\n%\n\\begin{align}\n\\abs{\\vec{x} - \\vec{y}} = r \\qty(1 - \\frac{\\vec{y} \\cdot \\hat{n}}{r} + \\order{\\frac{d^2}{r^2}})\n\\,.\n\\end{align}\n\nKeeping only the terms at \\(\\order{1/r}\\) we get\\footnote{At this point we change the first argument of the stress-energy tensor's dimensionality from a space \\(ct\\) to a time \\(t\\); this is just a matter of convention, it makes it easier to write the Taylor expansion later. }\n%\n\\begin{align}\nh_{ij}^{TT} (t, \\vec{x}) = \\frac{1}{r} \\frac{4G}{c^{4}}\n\\Lambda_{ij, kl} \\int \\dd[3]{y} \nT_{kl} \\qty(t - \\frac{r}{c} + \\frac{\\vec{y} \\cdot \\hat{n}}{c}, \\vec{y})\n\\,.\n\\end{align}\n\nIf the object is moving periodically with frequency \\(\\omega_s \\), then we will have \n%\n\\begin{align}\n\\frac{1}{\\omega_s } \\sim \\frac{d}{v}\n\\,,\n\\end{align}\n%\nand we assume \\(d/c \\ll d/v\\), which is equivalent to \\(v \\ll c\\): the characteristic velocities of the source should be nonrelativistic. \nUnder these assumptions we can expand the stress-energy tensor in powers of \\(\\xi = \\vec{y} \\cdot \\hat{n} / c \\sim d/c \\ll d/v\\): \n%\n\\begin{align}\nT_{kl} \\qty(t - \\frac{r}{c} + \\xi, \\vec{y}) &= T_{kl} \\qty(t - \\frac{r}{c}, \\vec{y}) + \\eval{\\pdv{T_{kl}}{\\xi }}_{\\xi = 0} \\xi  + \\frac{1}{2} \\eval{\\pdv[2]{T_{kl}}{\\xi }}_{\\xi = 0} \\xi^2 + \\order{\\xi^3}  \\\\\n&\\approx T_{kl} \\qty(t - \\frac{r}{c}, \\vec{y}) + \n\\xi \\partial_0 T_kl + \\frac{\\xi^2}{2} \\partial_{0} \\partial_0 T_{kl}  \\\\\n&= T_{kl} \\qty(t - \\frac{r}{c}, \\vec{y}) + \n\\frac{y^{i}n^{i}}{c} \\partial_0 T_kl + \\frac{y^{i}n^{i}y^{j}n^{j}}{2 c^2} \\partial_{0} \\partial_0 T_{kl}\n\\,.\n\\end{align}\n\nInserting this into the expression we get\n%\n\\begin{align}\nh_{ij}^{TT} (t, \\vec{x}) = \\frac{1}{r} \\frac{4G}{c^{4}} \\Lambda_{ij, kl} \\int \\dd[3]{y}\\qty[T_{kl} + \\frac{y^{m} n^{m}}{c} \\partial_0 T_{kl}  + \\frac{y^{m} y^{p} n^{m} n^{p}}{2c^2} \\partial_0^2 T_{kl} + \\order{\\xi^3}]_{\\text{ret}}\n\\,,\n\\end{align}\n%\nwhere ``ret'' means that the stress-energy tensor should be computed at a retarded time: \\(t - r/c\\) instead of \\(t\\).\n\nWe define the multipole moments: they are tensors with an arbitrary amount of indices,\n%\n\\begin{align}\nS^{ij, m_1 m_2 \\dots} (t) = \\int \\dd[3]{y} T^{ij}(t, y) \\prod_\\alpha  y^{m_\\alpha }\n\\,.\n\\end{align}\n\nIn terms of these, the expression for \\(h_{ij}^{TT}\\) can be written as \n%\n\\begin{align}\nh_{ij}^{TT} (t, \\vec{x}) = \\frac{1}{r} \\frac{4G}{c^{4}} \\Lambda_{ij, kl} \n\\qty(S^{kl} + \\frac{1}{c} n_{m} \\dot{S}^{kl, m} + \\frac{1}{2 c^2} n_m n_p \\ddot{S}^{kl, mp} + \\order{\\xi^3})_{\\text{ret}}\n\\,.\n\\end{align}\n\nAs we go up a perturbative order, we insert a factor \\(1/c\\), we add an index to the multipole, which corresponds to a multiplication by \\(y \\sim d\\), and we differentiate, corresponding to a division by a timescale \\(t\\) of the evolution of the system: so, the \\(n\\)-th order perturbative term is of order \\((d/ct)^{n} \\sim (v/c)^{n}\\).\nSince the system is nonrelativistic, \\(v/c\\) is small compared to 1, so we can stop at the first order and still get a good result:\n%\n\\begin{align}\nh_{ij}^{TT} (t, \\vec{x}) \\approx \\frac{1}{r} \\frac{4G}{c^{4}}\n\\Lambda_{ij, kl} \\qty( S^{kl} + \\frac{1}{c} n_m \\dot{S}^{kl, m})_{\\text{ret}}\n\\,.\n\\end{align}\n\nLet us define the moments of the energy and momentum densities: \n%\n\\begin{align}\nM &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{00}(t, \\vec{y}) \\sim \\frac{1}{c^2} S^{00} \\\\ \nM^{i} &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{00}(t, \\vec{y})y^{i} \\sim \\frac{1}{c^2} S^{00,i} \\\\ \nM^{ij} &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{00}(t, \\vec{y})y^{i}y^{j} \\sim \\frac{1}{c^2} S^{00,ij} \\\\ \nP^{i} &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{0i} (t, \\vec{y}) \\sim \\frac{1}{c^2} S^{0i} \\\\  \nP^{i,j} &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{0i} (t, \\vec{y}) y^{j} \\sim \\frac{1}{c^2} S^{0i,j} \\\\  \nP^{i,jk} &= \\frac{1}{c^2} \\int \\dd[3]{y} T^{0i} (t, \\vec{y}) y^{j}y^{k} \\sim \\frac{1}{c^2} S^{0i,jk}\n\\,,\n\\end{align}\n%\nwhere we have an analogy (\\(\\sim\\)) instead of an equality because the \\(S^{ij,m_1 m_2 \\dots}\\) are defined only with spatial indices. \n\nWe might want to compute the \\textbf{backreaction} of the GW emission onto the system, the energy lost per unit time: since \\(M\\) corresponds to the total energy, we could try to compute \\(\\dot{M}\\).\\footnote{A small technical note: since we are bothering to keep the \\(c\\)s, we should recall that the time derivative denoted by a dot is actually a derivative with respect to \\(ct\\).}\nLet us try to do this, recalling that by the stress-energy tensor's conservation we have \\(\\partial_{\\mu } T^{\\mu \\nu } = 0\\), which means \\(\\partial_{0} T^{00} = - \\partial_{i} T^{0i}\\): \n%\n\\begin{align}\nc\\dot{M} = \\int_{V} \\dd[3]{y} \\partial_{0} T^{00}\n= - \\int_{V} \\dd[3]{y} \\partial_{i} T^{0i}\n= - \\int_{\\partial V} \\dd{S}_i T^{0i} \\to 0\n\\,,\n\\end{align}\n%\nsince the flux is computed in a region outside the source, where its stress-energy tensor vanishes. \nWhat this means is that the leading order is too low to see the energy loss. \nIf we move up an order we find \n%\n\\begin{align}\nc \\dot{M}^{i} &= \\int_{V} \\dd[3]{y} y^{i} \\underbrace{\\partial_{0} T^{00}}_{= - \\partial_{j} T^{0j}}\n= + \\int_{V} \\dd[3]{y} \\qty(\\partial_{j} y^{i}) T^{0j} = cP^{i}\n\\,,\n\\end{align}\n%\nwhich means that the time derivative of the center of mass \\(M^{i}\\) gives the total linear momentum.\nLike the total energy, this is conserved: it can be shown like \n%\n\\begin{align}\n\\dot{P}^{i} = \\int_V \\dd[3]{y} \\partial_{0} T^{0i} = -\\int_V \\dd[3]{y} \\partial_{j} T^{ji} = - \\int_{\\partial V} \\dd{S_j} T^{ji}  \\to 0 \n\\,.\n\\end{align}\n\nWe also can show that \\(\\dot{M}^{ij} = 2 P^{(i, j)}\\), \\(\\dot{M}^{ijk} = P^{i,jk} + P^{j, ik} + P^{k, ij}\\) and \\(\\dot{P}^{i,j} = 2 S^{ij}\\), which means \\(\\ddot{M}^{ij} = 2 S^{ij}\\).\nThe computation is done by repeatedly applying integration by parts and the continuity equation: \n%\n\\begin{align}\n\\ddot{M}^{kl} &= \\int \\partial_0 \\partial_0 T^{00}(t, \\vec{y}) y^{k}y^{l}  \\\\\n&= - \\int \\partial_0 \\qty(\\partial_{i} T^{i0}) y^{k}y^{l}  \n= \\int \\partial_0 T^{i0} \\partial_{i} \\qty(y^{k}y^{l})  \\\\\n&= \\int \\partial_0 T^{i0} \\qty(\\delta_i^k y^{l} + \\delta_{i}^{l} y^{k})  \n= -\\int \\partial_{j} T^{ij} \\qty(\\delta_i^k y^{l} + \\delta_{i}^{l} y^{k})  \\\\\n&= \\int T^{ij} \\qty(\\delta_{i}^{k} \\delta^{l}_{j} + \\delta_{i}^{l} \\delta^{k}_{j})\n= \\int T^{kl} + T^{lk} = 2 S^{kl}\n\\,.\n\\end{align}\n\nTo give a physical intuition: the spatial components \\(S^{kl}\\) describe the \\emph{pressure} and \\emph{shears} in the source --- they make up the stress tensor. On the other hand, \\(M^{kl}\\) is the second moment of the mass density; its second derivative is somewhat analogous to a mass times an acceleration. So, this equation is a way to relate the forces and the accelerations inside the source.\n\n\\subsubsection{Quadrupole radiation}\n\nIf we only keep the first order in the expression for \\(h^{TT}_{ij} \\) we get: \n%\n\\begin{align}\nh_{ij}^{TT} (t, \\vec{x}) \\approx \\frac{1}{r} \\frac{4G}{c^{4}} \\Lambda_{ij, kl} S^{kl}\n= \\frac{1}{r} \\frac{2G}{c^{4}} \\Lambda_{ij,kl} \\ddot{M}^{kl}\n\\,.\n\\end{align}\n\nThe quadrupole moment is defined as the traceless part of the moment \\(M^{ij}\\):\n%\n\\begin{align}\nQ^{kl} = M^{kl} - \\frac{1}{3} \\delta^{kl} M_{ii} \n= \\int \\dd[3]{x} \\rho (t, \\vec{x}) \\qty(x^{i} x^{j} - \\frac{1}{3} r^2 \\delta_{ij})\n\\,.\n\\end{align}\n\nSince \\(\\Lambda_{ij, kl} \\delta^{kl} =0 \\), we can substitute \\(Q^{kl}\\) for \\(M^{kl}\\):\n%\n\\begin{align} \\label{eq:traceless-transverse-amplitude-from-quadrupole}\nh_{ij}^{TT} (t, \\vec{x}) = \\frac{1}{r} \\frac{2G}{c^{4}}\n\\Lambda_{ij, kl} \\ddot{Q}^{kl} \\qty(t - \\frac{r}{c})\n= \\frac{1}{r} \\frac{2G}{c^{4}} \\ddot{Q}^{TT}_{ij} \\qty(t - \\frac{r}{c})\n\\,.\n\\end{align}\n\nIf a wave is propagating along the \\(\\hat{n} = \\hat{z}\\) direction, we get \n%\n\\begin{subequations}\n\\begin{align}\n\\Lambda_{ij, kl} \\ddot{M}_{kl} = \\frac{1}{2} \\left[\\begin{array}{ccc}\n\\qty(\\ddot{M}_{11} - \\ddot{M}_{22}) / 2 &  \\ddot{M}_{12} & 0 \\\\ \n\\ddot{M}_{12} & \\qty(\\ddot{M}_{22} - \\ddot{M}_{11}) / 2 & 0 \\\\ \n0 & 0 & 0\n\\end{array}\\right]\n\\,,\n\\end{align}\n\\end{subequations}\n%\nsince the projection tensor \\(P_{ij}\\) is \\(P_{ij} = \\diag{1, 1, 0}\\), while \n%\n\\begin{align}\n\\Lambda_{ij, kl} \\ddot{M}_{kl} = \\qty(P \\ddot{M}P)_{ij} - \\frac{1}{2} P_{ij} \\Tr \\ddot{M}\n\\,.\n\\end{align}\n\n\\end{document}\n", "meta": {"hexsha": "e2c83f1723e5ba571d1bb24c546354758c06352c", "size": 22247, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_second_semester/gravitational_physics/mar23.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_second_semester/gravitational_physics/mar23.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_second_semester/gravitational_physics/mar23.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 44.1408730159, "max_line_length": 398, "alphanum_fraction": 0.6326246235, "num_tokens": 8274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.40100392892694914}}
{"text": "\\chapter{R$^5$RS compatibility}\n\\label{r5rscompatchapter}\n\nThe features described in this chapter are exported from the\n\\defrsixlibrary{r5rs} library and provide some functionality of the\npreceding revision of this report~\\cite{R5RS} that was omitted from\nthe main part of the current report.\n\n\\begin{entry}{%\n\\proto{exact->inexact}{ z}{procedure}\n\\proto{inexact->exact}{ z}{procedure}}\n\nThese are the same as the {\\cf inexact} and {\\cf exact}\nprocedures; see report section~\\extref{report:inexact}{Generic conversions}.\n\\end{entry}\n\n\\begin{entry}{%\n\\proto{quotient}{ \\vari{n} \\varii{n}}{procedure}\n\\proto{remainder}{ \\vari{n} \\varii{n}}{procedure}\n\\proto{modulo}{ \\vari{n} \\varii{n}}{procedure}}\n\nThese procedures implement number-theoretic (integer)\ndivision.  \\varii{N} must be non-zero.  All three procedures\nreturn integer objects.  If \\vari{n}/\\varii{n} is an integer object:\n\\begin{scheme}\n    (quotient \\vari{n} \\varii{n})   \\ev \\vari{n}/\\varii{n}\n    (remainder \\vari{n} \\varii{n})  \\ev 0\n    (modulo \\vari{n} \\varii{n})     \\ev 0\n\\end{scheme}\nIf \\vari{n}/\\varii{n} is not an integer object:\n\\begin{scheme}\n    (quotient \\vari{n} \\varii{n})   \\ev \\var{n$_q$}\n    (remainder \\vari{n} \\varii{n})  \\ev \\var{n$_r$}\n    (modulo \\vari{n} \\varii{n})     \\ev \\var{n$_m$}\n\\end{scheme}\nwhere \\var{n$_q$} is $\\vari{n}/\\varii{n}$ rounded towards zero,\n$0 < |\\var{n$_r$}| < |\\varii{n}|$, $0 < |\\var{n$_m$}| < |\\varii{n}|$,\n\\var{n$_r$} and \\var{n$_m$} differ from \\vari{n} by a multiple of \\varii{n},\n\\var{n$_r$} has the same sign as \\vari{n}, and\n\\var{n$_m$} has the same sign as \\varii{n}.\n\nConsequently, for integer objects \\vari{n} and \\varii{n} with\n\\varii{n} not equal to 0,\n\\begin{scheme}\n     (= \\vari{n} (+ (* \\varii{n} (quotient \\vari{n} \\varii{n}))\n           (remainder \\vari{n} \\varii{n})))\n                                 \\ev  \\schtrue%\n\\end{scheme}\nprovided all number object involved in that computation are exact.\n\n\\begin{scheme}\n(modulo 13 4)           \\ev  1\n(remainder 13 4)        \\ev  1\n\n(modulo -13 4)          \\ev  3\n(remainder -13 4)       \\ev  -1\n\n(modulo 13 -4)          \\ev  -3\n(remainder 13 -4)       \\ev  1\n\n(modulo -13 -4)         \\ev  -1\n(remainder -13 -4)      \\ev  -1\n\n(remainder -13 -4.0)    \\ev  -1.0%\n\\end{scheme}\n\n\\begin{note}\n  These procedures could be defined in terms of {\\cf div} and {\\cf\n    mod} (see report section~\\extref{report:div}{Arithmetic operations}) as follows (without checking of the\n  argument types):\n\\begin{scheme}\n(define (sign n)\n  (cond\n    ((negative? n) -1)\n    ((positive? n) 1)\n    (else 0)))\n\n(define (quotient n1 n2)\n  (* (sign n1) (sign n2) (div (abs n1) (abs n2))))\n\n(define (remainder n1 n2)\n  (* (sign n1) (mod (abs n1) (abs n2))))\n\n(define (modulo n1 n2)\n  (* (sign n2) (mod (* (sign n2) n1) (abs n2))))\n\\end{scheme}\n\\end{note}\n\\end{entry}\n\n\\begin{entry}{%\n\\proto{delay}{ \\hyper{expression}}{\\exprtype}}\n\nThe {\\cf delay} construct is used together with the procedure \\ide{force} to\nimplement \\defining{lazy evaluation} or \\defining{call by need}.\n{\\tt(delay~\\hyper{expression})} returns an object called a\n\\defining{promise} which at some point in the future may be asked (by\nthe {\\cf force} procedure) to evaluate\n\\hyper{expression}, and deliver the resulting value.\nThe effect of \\hyper{expression} returning multiple values\nis unspecified.\n\n\\end{entry}\n\n\\begin{entry}{%\n\\proto{force}{ promise}{procedure}}\n\n{\\var{Promise} must be a promise.}\nThe {\\cf force} procedure forces the value of \\var{promise}.  If no value has been computed for\nthe promise, then a value is computed and returned.  The value of the\npromise is cached (or ``memoized'') so that if it is forced a second\ntime, the previously computed value is returned.\n\n\\begin{scheme}\n(force (delay (+ 1 2)))   \\ev  3\n(let ((p (delay (+ 1 2))))\n  (list (force p) (force p)))  \n                               \\ev  (3 3)\n\n(define a-stream\n  (letrec ((next\n            (lambda (n)\n              (cons n (delay (next (+ n 1)))))))\n    (next 0)))\n(define head car)\n(define tail\n  (lambda (stream) (force (cdr stream))))\n\n(head (tail (tail a-stream)))  \n                               \\ev  2%\n\\end{scheme}\n\nPromises are mainly intended for programs written in\nfunctional style.  The following examples should not be considered to\nillustrate good programming style, but they illustrate the property that\nonly one value is computed for a promise, no matter how many times it is\nforced.\n\n\\begin{scheme}\n(define count 0)\n(define p\n  (delay (begin (set! count (+ count 1))\n                (if (> count x)\n                    count\n                    (force p)))))\n(define x 5)\np                     \\ev  {\\it{}a promise}\n(force p)             \\ev  6\np                     \\ev  {\\it{}a promise, still}\n(begin (set! x 10)\n       (force p))     \\ev  6%\n\\end{scheme}\n\nHere is a possible implementation of {\\cf delay} and {\\cf force}.\nPromises are implemented here as procedures of no arguments,\nand {\\cf force} simply calls its argument:\n\n\\begin{scheme}\n(define force\n  (lambda (object)\n    (object)))%\n\\end{scheme}\n\nThe expression\n\n\\begin{scheme}\n(delay \\hyper{expression})%\n\\end{scheme}\n\nhas the same meaning as the procedure call\n\n\\begin{scheme}\n(make-promise (lambda () \\hyper{expression}))%\n\\end{scheme}\n\nas follows\n\n\\begin{scheme}\n(define-syntax delay\n  (syntax-rules ()\n    ((delay expression)\n     (make-promise (lambda () expression))))),%\n\\end{scheme}\n\nwhere {\\cf make-promise} is defined as follows:\n\n\\begin{scheme}\n(define make-promise\n  (lambda (proc)\n    (let ((result-ready? \\schfalse)\n          (result \\schfalse))\n      (lambda ()\n        (if result-ready?\n            result\n            (let ((x (proc)))\n              (if result-ready?\n                  result\n                  (begin (set! result-ready? \\schtrue)\n                         (set! result x)\n                         result))))))))%\n\\end{scheme}\n\\end{entry}\n\n\\begin{entry}{%\n\\proto{null-environment}{ n}{procedure}}\n\n\\domain{\\var{N} must be the exact integer object 5.}  The {\\cf\n  null-environment} procedure returns an\nenvironment specifier suitable for use with {\\cf eval} (see\nchapter~\\ref{evalchapter}) representing an environment that is empty except\nfor the (syntactic) bindings for all keywords described in\nthe previous revision of this report~\\cite{R5RS}, including bindings\nfor {\\cf =>}, {\\cf ...}, {\\cf else}, and {\\cf\\_} that are the same as those in\nthe \\rsixlibrary{base} library.\n\\end{entry}\n\n\\begin{entry}{%\n\\proto{scheme-report-environment}{ n}{procedure}}\n\n\\domain{\\var{N} must be the exact integer object 5.}  The {\\cf scheme-report-environment} procedure returns\nan environment specifier for an environment that is empty except for\nthe bindings for the identifiers described in the previous\nrevision of this report~\\cite{R5RS}, omitting {\\cf load}, {\\cf\n  interaction-environment}, {\\cf\n  transcript-on}, {\\cf transcript-off}, and {\\cf char-ready?}.  The\nvariable bindings have as values the procedures of the same names described in\nthis report, and the keyword bindings, including\n{\\cf =>}, {\\cf ...}, {\\cf else}, and {\\cf\\_} are the same as those described\nin this report.\n\\end{entry}\n\n\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"r6rs-lib\"\n%%% End: \n", "meta": {"hexsha": "9f39a023b303bc948439e96f0316cda88cdda065", "size": 7186, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "r6rs/r5rscompat.tex", "max_stars_repo_name": "schemedoc/rnrs-metadata", "max_stars_repo_head_hexsha": "2f998d354177dc41a8d3147fd15c056a14ffabda", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-04T17:38:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-04T17:38:19.000Z", "max_issues_repo_path": "r6rs/r5rscompat.tex", "max_issues_repo_name": "schemedoc/scheme-rnrs-metadata", "max_issues_repo_head_hexsha": "2f998d354177dc41a8d3147fd15c056a14ffabda", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-03-27T22:24:05.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-26T17:56:02.000Z", "max_forks_repo_path": "r6rs/r5rscompat.tex", "max_forks_repo_name": "schemedoc/scheme-rnrs-metadata", "max_forks_repo_head_hexsha": "2f998d354177dc41a8d3147fd15c056a14ffabda", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4491525424, "max_line_length": 108, "alphanum_fraction": 0.6392986362, "num_tokens": 2103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863695, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.40100392892694914}}
{"text": "\\section{Algorithms\\label{sec:algo}}\n\nWe now detail a set of algorithms to solve the integral equation in \\cref{eq:int-eq} and evaluate the solution via the double layer integral in \\cref{eq:double_layer} at a given target point $\\vx \\in \\Omega$.\nAs described in the previous section, both solving \\cref{eq:int-eq} and evaluating \\cref{eq:double_layer} require accurate evaluation of singular/near-singular integrals of functions defined on the surface $\\Gammah$.\nWe first outline our unified singular/near-singular integration scheme, \\qbkix, its relation to existing approximation-based quadrature methods and geometric problems that can impede accurate solution evaluation.\nWe then describe two geometry preprocessing algorithms, \\textit{admissibility refinement} and \\textit{adaptive upsampling}, that address these issues to obtain the sets of patches $\\Pcoarse$ and $\\Pfine$ used by \\qbkix.\n\n\\subsection{Singular and Near-Singular Evaluation \\label{sec:singular-eval}}\n%We start with describing our (near-) singular integration algorithm, identifying conditions that the patches need to satisfy for the algorithm to achieve a target accuracy $\\etrg$.\n\n%We start with the informal idea of the algorithm. As in all QBX-style algorithms, we take advantage of the fact that while the integrand may be (near-)singular, the solution of the PDE given by the integral is not, and can be extrapolated from points where it can be computed reliably to points close to the surface or on the surface. \nWe begin with an outline of the algorithm.\n%As with all \\qbx-style algorithms, we observe that while the integrand may be singular/near-singular for a particular choice of $\\vx$, the solution of the PDE given by \\cref{eq:double_layer} is well-defined. \n%This allows us to extrapolate the solution to $\\vx$ from nearby points where the integrand is smooth and standard quadrature rules are accurate.\n%Specifically, for a quadrature sample $x_j$ on a patch $P$ from $\\Pcoarse$, where we need to evaluate the singular integral  to solve \\cref{eq:int-eq}, we compute the values for extrapolation at points $c_{j,s}$ (check points) sampled along the normal to the surface at $\\vy_j$.  Suppose we fix the placement of points $c_{j,s}$ in the interior of $\\Omega$.  We can always refine $\\Pfine$  so for evaluation of integrals at these points $c_{j,s}$ the smooth quadrature rules using denser quadrature points $\\tilde{x}_j$  on $\\Pfine$ are sufficiently accurate. Then extrapolation to $\\vy_j$ can be applied to these accurate values.  In practice, we perform refinement to obtain  $\\Pcoarse$,  not just $\\Pfine$ (admissibility refinement). For $\\Pcoarse$, we use a heuristic error estimate to place check points for every $x_j$,  and refine patches to ensure that they are away from patches other than $P$. In this way, the amount of refinement needed for $\\Pfine$ is reduced.  \nFor a point $\\vsx \\in \\Gammah$ on a patch $\\vP$ from $\\Pcoarse$ that is closest to $\\vx$, we first upsample the density $\\phi$ from $\\Pcoarse$ to $\\Pfine$ and compute the solution at a set of points $\\vc_s$, $s = 1, \\hdots p$ called \\emph{check points}, sampled along the surface normal at $\\vsx$ away from $\\Gammah$. \nWe use \\cref{eq:double_layer_disc} to approximate the solution at the check points.\nWe then extrapolate the solution to $\\vx$.\n%The placement of check points relative to $\\Pcoarse$ is critical to ensuring the accuracy of the overall method. \n%In \\cref{sec:admissible}, we list the geometric criteria that $\\Pcoarse$ must satisfy in order to solve \\cref{eq:int-eq} accurately; we enforce these criteria by a sequence of quadrisection algorithms called \\emph{admissibility refinement}. \n%The resulting set of patches determines a set of check points $\\{\\vc_{I,s}\\}$ in $\\Omega$, which are used to extrapolate the solution to each of the quadrature samples $\\vy_I$ in the discretization of $\\Pcoarse$.\n%Once we fix a set of check points, we further refine $\\Pcoarse$ to produce a set of patches $\\Pfine$ such that \\cref{eq:double_layer_disc} can be evaluated accurately at each $\\vc_{I,s}$. \n%The algorithm to construct $\\Pfine$ from $\\Pcoarse$ is called \\emph{adaptive upsampling}.\n%We use empirical heuristics to place check points in admissibility refinement and trigger refinement in adaptive upsampling to reduce the overall amount number of quadrature patches in $\\Pfine$.\n\n\nFor a given surface or quadrature patch $\\vP: \\I^2 \\rightarrow \\mathbb{R}^3$,  we define the \\textit{characteristic length} $L(P)$ as the square root of the surface area of $\\vP$, i.e., $L(\\vP) = \\sqrt{\\int_{\\vP}d\\vy_{\\vP}}$.\nWe use  $L = L(\\vP)$ or $L_\\vy$ for $\\vy \\in \\vP(D)$ to denote the characteristic length when $\\vP$ is clear from context.\nFor a point $\\vx \\in \\Omega$, we assume that there is a single closest point $\\vsx \\in \\Gammah$ to $\\vx$; all points to which the algorithm is applied will have this property by construction.  \nNote that $\\vn(\\vsx)$, the vector normal to $\\Gammah$ at $\\vsx$, is chosen to point outside of $\\Omega$.\n%We assume that two sets of patches are defined:  $\\Pcoarse$, which serves as the discretization of $\\Gamma$, and $\\Pfine$, which is obtained from $\\Pcoarse$ by refinement.\n%We will provide a detailed discussion regarding this refinement in \\cref{sec:adaptive_upsampling}.\n\n%Expanding \\cref{eq:double_layer_disc}, we obtain the following approximation of $u$ with respect\n%to discretization on a collection of patches $\\qP$:\n%\\begin{equation}\n%  \\hat{u}(\\vx; \\qP) = \\sum_{P \\in \\qP}\\sum_{\\ell \\in I(P)} \\frac{\\partial G(\\vx,\\vy_\\ell)}{\\partial n}\\cdot \\phi_\\ell w_\\ell.\n%\\label{eq:double_layer_disc}\n%\\end{equation}\n%We want to compute $\\hat{u}$ such that $\\|u(\\vx) - \\hat{u}(\\vx)\\|_2 \\leq \\etrg$.\n\n%Recall \\cref{eq:double_layer_disc}, in which we defined $\\hat{u}(\\vx;\\Pcoarse)$ as the discretization of \\cref{eq:double_layer} with a quadrature rule for smooth funcitons. \n%\\edittxt{We define three zones in $\\Omega$, in terms of \\cref{eq:double_layer_disc}, for which \\cref{eq:double_layer} is evaluated differently.}{We define three zones in $\\Omega$ for which \\cref{eq:double_layer} is evaluated differently in terms of \\cref{eq:double_layer_disc} and the desired solution accuracy $\\etrg$ .}\nWe define three zones in $\\Omega$ for which \\cref{eq:double_layer} is evaluated differently in terms of \\cref{eq:double_layer_disc} and the desired solution accuracy $\\etrg$ .\nThe \\emph{far field}  $\\Omega_F = \\{\\vx \\in \\Omega \\,|\\, \\|u(\\vx) - \\hat{u}(\\vx;\\Pcoarse)\\|_2 \\leq \\etrg\\}$, where the quadrature rule corresponding to $\\Pcoarse$ is sufficiently accurate, and the \\emph{intermediate field}  $\\Omega_I= \\{\\vx \\in \\Omega \\,|\\, \\|u(\\vx) - \\hat{u}(\\vx;\\Pfine)\\|_2 \\leq \\etrg\\}$, where quadrature over $\\Pfine$ is sufficiently accurate.\nThe remainder of $\\Omega$ is the \\emph{near field} $\\Omega_N = \\Omega \\setminus \\Omega_I$.\n\n%In a large portion of $\\Omega$, computing $\\hat{u}(\\vx, \\Pcoarse)$ or $\\hat{u}(\\vx, \\Pfine)$ with \\cref{eq:double_layer_disc} directly is sufficient.\n\n%We'll refer to $\\Omega_F$ as the \\textit{far field} of $\\Pcoarse$ and $\\Omega_I$ as the \\textit{intermediate field} of $\\Pcoarse$.\n\n%When $\\vx$ is not in $\\Omega_I$, special treatment is required to approximate the potential.\n\n\\paragraph*{Non-singular integration}\nTo compute the solution at points $\\vx$ in $\\Omega_F$, \\cref{eq:double_layer_disc} is accurate to $\\etrg$, so we can simply compute $\\hat{u}(\\vx, \\Pcoarse)$ directly.\nSimilarly for points in $\\Omega_I \\setminus \\Omega_F$, we know by definition that $\\hat{u}(\\vx, \\Pfine)$ is sufficiently accurate, so it can also be applied directly. \n\n\\paragraph*{Singular/near-singular integration algorithm}\n\n\n\\begin{figure}[!htb]\n  %\\setlength\\figureheight{1.9in}\n  %\\setlength\\figurewidth{2.1in}\n  \\begin{minipage}{\\textwidth}\n  \\centering\n      \\includegraphics[width=.85\\linewidth]{figs/qbkix_schematic.pdf}\n  \\end{minipage}\\hfill\n  \\mcaption{fig:qbkix-schematic}{Schematic of singular/near-singular\n  evaluation}{A small piece of a boundary $\\Gammah$ is shown, along with the set of\n  patches $\\Pcoarse$ (patch boundaries are drawn in black). The target point $\\vx$, in this\n  case on $\\Gammah$, is shown in green. The solution is evaluated\n  at the check points $\\vc_s$ (gray points off-surface) using the fine\n  discretization $\\Pfine$ (small dots on-surface). The distance from the first\n  check point $\\vc_0$ to $\\Gammah$ is $R$ and the distance between consecutive\n  check points $\\vc_i$ and $\\vc_{i+1}$ is $r$. In this example, $\\Pfine$ is computed\n  from $\\Pcoarse$ with two levels of uniform quadrisection, producing 16 times\n  more patches. The patch length $L$ is roughly proportional to the average edge\n  length of the patch.}\n\\end{figure}\n\nFor the remaining points in $\\Omega_N$, we need an alternative means of evaluating the solution.\nIn the spirit of the near-singular evaluation method of \\cite{YBZ},  we construct a set of \\textit{check points} $\\vc_0, \\hdots, \\vc_p$ in $\\Omega_I$ along a line intersecting $\\vx$ to approximate the solution near $\\vx$. \nHowever, instead of interpolating the solution as in \\cite{YBZ}, we instead extrapolate the solution from the check points to $\\vx$.\n%We first place check points in $\\Omega_I$, compute $\\hat{u}(\\vc_i, \\Pfine)$ for each $i$, then extrapolate the approximate values at the check points to $\\vx$.  \\note[MJM]{kill sentence}\nWe define two distances relative to $\\vsx$: $R(\\vsx) =b L_\\vsx = \\|\\vc_0 - \\vsx\\|_2$, the distance from the first check point $\\vc_0$ to $\\Gammah$,  and $r(\\vsx) =a L_\\vsx = \\|\\vc_i - \\vc_{i+1}\\|_2$, the distance between consecutive check points.\nWe assume  $0<a,b <1$.\n%The points are placed along the surface normal $\\vn(\\vsx)$. \n\nThe overall algorithm for the unified singular/near-singular evaluation scheme is as follows.\nA schematic for \\qbkix is depicted in \\Cref{fig:qbkix-schematic}.\n\n\n\\begin{enumerate}\n  \\item Find the closest point $\\vsx$ on $\\Gammah$ to $\\vx$.\n  \\item Given values $a$ and $b$, generate check points $C = \\{\\vc_0, \\hdots, \\vc_{p}\\}$ \n    %distance $R(\\vy)$ away from the $\\Gamma$ and equispaced in $\\vr(\\vy)$ along the inward-pointing normal:\n    \\begin{equation}\n      \\vc_s = \\vsx -(R(\\vsx) +s r(\\vsx)) \\vn(\\vsx), \\quad s=0, \\hdots, p\n      \\label{eq:check}\n    \\end{equation}\n    The center of mass of these check points $\\vhc$ is called the \\textit{check center} for $\\vx$.\n    Note that $\\Pfine$ must satisfy the condition that $\\vc_s$ are in $\\Omega_I$ for a given choice of $a$ and $b$.\n\\item Upsample $\\phi$. \n  We interpolate the density values $\\phi_I$ at $x_I$ on patches in $\\Pcoarse$ to quadrature points $\\tilde{x}_J$ on patches in $\\Pfine$ \n  with global indices $I$ and $J$ on $\\Pcoarse$ and $\\Pfine$ respectively.\n  If a patch $\\vP_i$ in $\\Pcoarse$ is split into $m_i$ patches in $\\Pfine$, we are interpolating from $q^2$ points to $m_iq^2$ points.\n  %Let $\\wfine$ and $\\phifine$ be the vector quadrature weights and interpolated density values at $\\tilde{x}_J$ of $\\Pfine$.\n  \\item Evaluate the potential at check points via smooth quadrature with the upsampled density, i.e. evaluate $\\hat{u}(\\vc_s) = \\hat{u}(\\vc_s, \\Pfine)$ for $s=0,\\hdots, p$.\n  \\item Compute a Lagrange interpolant $\\tilde{u}$ through the check points $\\vc_0,\\hdots, \\vc_p$ and values \\linebreak $\\hat{u}(\\vc_0), \\hdots, \\hat{u}(\\vc_{p})$ and evaluate at the interpolant at $\\vx$:\n      \\begin{equation}\n          \\tilde{u}(\\vx) = \\sum_{s=0}^p \\hat{u}(\\vc_s)\\ell_s(t_\\vx),\n      \\end{equation}\n        where $\\ell_s(\\vx)$ is the $s$th Lagrange basis function through the points $\\vc_0,\\hdots, \\vc_p$, and $t_\\vx\\in \\mathbb{R}$ is such that $\\vx = \\vsx - t_\\vx\\vn(\\vsx)$ (see \\cref{fig:extrap-err-setup} for a schematic of the check points).\n    Since $\\vx$ lies between $\\vc_0$ and $\\Gammah$, we are extrapolating when computing $\\tilde{u}(\\vx)$.\n\\end{enumerate}\n\n%\\begin{algorithm}\n%    \\KwData{A set of surface patches $\\Pcoarse$, a set of quadrature patches $\\qPfine$, a target point $\\vx$, extrapolation order $p$, quadrature order $q$, }\n%  \\KwResult{The closest point $\\vsx$ on $\\qP$ to $\\vx$}\n%\n%  \\DontPrintSemicolon\n%  Construct an AABB tree $T_T$ from a fine triangle mesh of the quadrature patches of $\\qP$\\;\n%  Construct an AABB tree $T_B$ from bounding boxes of quadrature patches in $\\qP$.\\;\n%    $\\tau_0 = $ closest triangle to $\\vx$ computed with $T_T$ \\;\n%  \n%    $P_{i_0} = $ patch corresponding to $\\tau_0$\\;\n%    Find the closest point $\\vector{s}_{\\vector{\\vx},0}$ on $P_{i_0}$ to $\\vx$ with \\cref{app:closest_point}.\\;\n%    $d_{i_0} = \\|\\vx - \\vector{s}_{\\vector{\\vx},0}\\|_2$\\;\n%    $B_{d_{i_0}}(\\vx)=$ a box centered a $\\vx$ with edge length $2d_{i_0}$\\;\n%    Find the boxes $B_{i_1}, \\hdots B_{i_k}$ in $T_B$ that intersect $B_{d_{i_0}}(\\vx)$\\;\n%    \n%    \\For{$B_{i_j} \\in B_{i_1}, \\hdots B_{i_k}$}{\n%      $P_{i_j} =$ quadrature patch corresponding to $B_{i_j}$ \\;\n%      Find the closest point $\\vector{s}_{\\vector{\\vx},j}$ on $P_{i_j}$ to $\\vx$ with \\cref{app:closest_point} to precision $\\err{opt}$.\\;\n%      $d_{i_j} = \\|\\vx - \\vector{s}_{\\vector{\\vx},j}\\|_2$\\;\n%    }\n%    $j^* = \\mathrm{argmin}_j\\{d_{i_j}\\}$ \\;\n%    \\Return{$\\vector{s}_{\\vector{x},j^*}$}\n%  \\mcaption{alg:singular_eval}{Evaluate the singular/near-singular layer potential at $\\vx$}{}\n%\\end{algorithm}\n%The parameters involved in this scheme are the number of check points $p$ and the relative spacing parameters of the check points $a$ and $b$.\n%A critical aspect of the scheme is ensuring that the check points are in the intermediate field, i.e., $\\Pfine$ is chosen to satisfy this condition.\n%We use the error discussion in \\cref{sec:error} and the algorithms of \\cref{sec:adaptive_upsampling} to compute values of $a$, $b$ and  $\\Pfine$ for a given $\\etrg$.\n\n\\paragraph*{Ill-conditioning of the discrete integral operator}\n%This scheme is used to compute singular integrals needed in the iterative solver for the solution of \\cref{eq:int-eq}.\nThis evaluation scheme can be used directly to extrapolate all the way to the surface and obtain the\nvalues of the singular integral in \\cref{eq:int-eq}.\nHowever, in practice, due to a distorted eigenspectrum of this approximate operator, \\gmres tends to stagnate at a level of error corresponding to the accuracy of \\qbkix when it is used to compute the matrix-vector product.\nThis is a well-known phenomenon of approximation-based singular quadrature schemes; \\cite[Section 3.5]{KBGN}\\cite[Section 4.2]{RBZ} present a more detailed study.\nTo address this, we average the interior and exterior limits of the solution at the quadrature nodes, computed via \\qbkix, to compute the on-surface potential and add $\\frac{1}{2}I$ to produce the interior limit.\nThis shifts the clustering of eigenvalues from around zero to around $\\frac{1}{2}$, which is ideal from the perspective of \\gmres.\nWe call this \\textit{two-sided} \\qbkix, while the standard version described above is called \\textit{one-sided} \\qbkix.\nWe observe stable and consistent convergence of \\gmres when two-sided \\qbkix is used to evaluate the matrix-vector multiply to solve \\cref{eq:linear_system}. \nIn light of this, we always use two-sided \\qbkix within \\gmres and set the stopping tolerance for \\gmres to $\\err{\\gmres}=10^{-12}$, regardless of the geometry, boundary condition or  quadrature order. \n\n\\subsection{Geometric criteria for accurate quadrature\\label{sec:geom_criteria}}\nThe accuracy of the method outlined above is controlled by two competing error terms: \\textit{quadrature error} incurred from approximating the layer potential \\cref{eq:double_layer} with \\cref{eq:double_layer_disc} in Step 4 and \\textit{extrapolation error} due to approximating the singular integral with an extratpolated value in Step 5.\nBoth errors are determined by the location of check points relative to the patches in $\\Pcoarse$ and $\\Pfine$ (see \\Cref{heuristic:error_quad_high_order,thm:extrap_error}). \n\n\\begin{figure}[!htb]\n  \\centering\n  %\\setlength\\figureheight{1.9in}\n  %\\setlength\\figurewidth{2.1in}\n  \\begin{minipage}{.33\\textwidth}\n      \\includegraphics[width=\\linewidth]{figs/admissibility_motivation2.pdf}\n  \\end{minipage}\\hfill\n  \\begin{minipage}{.33\\textwidth}\n    \\includegraphics[width=\\linewidth]{figs/admissibility_motivation1.pdf}\n  \\end{minipage}\\hfill\n  \\begin{minipage}{.33\\textwidth}\n    \\includegraphics[width=\\linewidth]{figs/admissibility_motivation3.pdf}\n  \\end{minipage}\\hfill\n  \\mcaption{fig:admissibility-motivation}{Possible check point configurations}{A \\twod  example depicting three choices of $a$ and $b$ in \\cref{eq:check}. \n Shown is the boundary $\\Gammah$, with black tick marks denoting patch boundaries of $\\Pcoarse$, green tick marks denoting patch boundaries of $\\Pfine$, the target point (red dots), its check points (blue dots) along the normal closest to the target point, and the medial axis of $\\Gammah$ (gray dotted line).\nLarge (left) and small (middle) values of $a$ and $b$ can cause clustering of check points near to $\\Gammah$, which requires large amounts of upsampling to compute the potential accurately. Using the medial axis as a heuristic to for admissibility (right), we can minimize the amount of adaptive upsampling required.}\n\\end{figure}\nIn \\Cref{fig:admissibility-motivation}, we show three examples of different choices of check point locations to evaluate the potential at a point with \\qbkix. \n%Suppose that we have chosen extrapolation parameters $a$ and $b$ such that the extrapolation accuracy is less then $\\etrg$, following the discussions in \\cref{sec:extrap_error,sec:parameter-selection}. From an accuracy perspective, each choice of parameters is are equally valid. \n%However, each choice will require a different set $\\Pfine$ in order to ensure accurate integration in \\cref{eq:double_layer_disc}.\nIn \\cref{fig:admissibility-motivation}-left, $\\vc_0$ is placed close to the target point, while in \\cref{fig:admissibility-motivation}-middle, $\\vc_0$ is far from the target point, but $\\vc_p$ is close to a non-local piece of $\\Gammah$. \nBoth cases will require excessive refinement of $\\Pcoarse$ in order to resolve \\cref{eq:double_layer_disc} accurately with $\\Pfine$.\nOn the other hand, in \\cref{fig:admissibility-motivation}-right, we can either perform one refinement step on $\\Pcoarse$ or adjust $a$ and $b$, which will result in fewer patches in $\\Pfine$, and therefore provide a faster integral evaluation, while maintaining accuracy.\n\nIn an attempt to strike this balance between speed and accuracy, we need certain constraints on the geometry of $\\Gammah$ to ensure the efficient and accurate application of \\qbkix, which we impose on the patch sets $\\Pcoarse$ and $\\Pfine$.\nWe will first outline our constraints on the quadrature patch sets $\\Pcoarse$ and $\\Pfine$ which allow for accurate evaluation with \\qbkix.\n\n\\edit{}{We note here that this is largely a consequence of the global nature of our method.\nWe compute accurate potentials at each check point with a single large quadrature evaluation over the boundary.\nAlternatively, one could use a \\textit{local} approach which performs a local correction to an inaccurate \\fmm evaluation of a singular/near-singular integral.\nThe net effect of this is a faster \\fmm evaluation without much concern for where check points are placed, but many small quadratic computations on individual patches. \nWe explore this tradeoff by comparing \\qbkix with a competing approach in \\cref{sec:results-compare}.\n}\n\\subsubsection{Admissibility criteria\\label{sec:admissible}}\nA set of patches $\\qP$ is \\textit{admissibile} if the following statements are satisfied on each quadrature patch in $\\qP$:\n\\begin{criteria}\n  \\item The error of a surface patch $\\vP_i$ approximating an embedding $\\gamma_r$ is below some absolute target accuracy $\\err{g}$ \\label{criteria:1}\n  \\item The interpolation error of the boundary condition $f$ is below some absolute target accuracy $\\err{f}$ \\label{criteria:2}\n  \\item For each check center $\\vhc_j$ corresponding to the quadrature point $\\vy_j$ on the surface, the closest point on $\\hat{\\Gamma}$ to $\\vhc_j$ is $\\vy_j$. \\label{criteria:3}\n%  \\item Each patch has characteristic length $L \\geq L_\\lbl{min}$.\\label{criteria:4}\n\\end{criteria}\n\n\\Cref{criteria:1} is required to ensure that $\\Gammah$ approximates $\\Gamma$ with sufficient accuracy to solve the integral equation.\nWe discuss how to choose $\\err{g}$ in \\cite[Section 6]{morse2020bsupplementary}; for the tests in this paper, we simply choose $\\err{g} < \\err{target}$.\n\\Cref{criteria:2} guarantees that $f$ can be represented at least as accurately as the desired solution accuracy.\nWe therefore similarly choose $\\err{f} < \\etrg$. \n%The parameters $a$ and $b$ in \\cref{eq:check} are chosen to place check points to balance the extrapolation error, which grows as $a$ and $b$ increase, and smooth quadrature error, which grows as $a$ and $b$ decrease, while attempting to minimize cost.\n\\Cref{criteria:3}  balances the competing geometric constraints of cost and accuracy by flexibly placing check points as far as possible from $\\Gammah$ without causing too much upsampling on other patches.\n%Rather than checking all check point locations individually, we use the check center $\\vhc$ as a proxy.\nIf a check point $\\vc$ constructed from a surface patch $\\vP$ is too close to another surface patch $\\vP'$, \\Cref{criteria:3} will indicate that $\\vP$ is inadmissible. \nIf $\\vP$ is subdivided into its children, new check points $\\vc^\\prime$ generated from these children of $\\vP$ will be closer to $\\vP$ and further from $\\vP'$.\nSince check points are placed at distances proportional to $L(\\vP)$, repeated refinement of $\\vP$ will eventually satisfy \\Cref{criteria:3}. \n\n\\subsubsection{Upsampling criteria\\label{sec:adaptive_upsampling}}\nOnce we have a set of admissible surface patches satisfying \\Cref{criteria:1,criteria:2,criteria:3}, we need to determine the upsampled quadrature patches $\\Pfine$ that ensure that the check points generated from $\\Pcoarse$ are in $\\Omega_I$, i.e., $\\|u(\\vc) - \\hat{u}(\\vc, \\Pfine)\\| < \\etrg$.\n%Once the set of admissible surface patches $\\Pcoarse$ is computed, we need to determine the upsampled quadrature patches $\\Pfine$ that ensure that the check points generated from $\\Pcoarse$ are in $\\Omega_I$, i.e., $\\|u(\\vc) - \\hat{u}(\\vc, \\Pfine)\\| < \\etrg$.\nTo achieve this, we need a criterion to determine which patches are ``too close'' to a given check point for the error to be below $\\err{target}$.\nWe make the following assumption about the accuracy of our smooth quadrature rule: \\textit{\\cref{eq:double_layer_disc} is accurate to $\\err{target}$ at points further than  $L(\\vP)$ from $\\vP$, for $\\err{target} > 10^{-12}$}.\nThis is motivated by \\cite{aT2,barnett2014evaluation}, which demonstrate the rapid convergence of the layer potential quadrature error with respect to $\\|\\vx - \\vsx\\|_2$.  \nFor sufficiently high quadrature orders, such as $q=20$, this assumption seems to hold in practice.\nWe say that a point $\\vx$ is \\textit{near} to $\\vP$ if the distance from $\\vx$ to $\\vP$ is less than $L(\\vP)$; otherwise, $\\vx$ is \\textit{far} from $\\vP$.\nWe would like all check points required for the singular/near-singular evaluation of the discretization of \\cref{eq:double_layer} using \\qbkix to be far from all patches in $\\Pfine$.\nIf this is satisfied, then we know that the Clenshaw-Curtis quadrature rule will be accurate to $10^{-12}$ at each check point.\n\n\\subsection{Refinement algorithm preliminaries}\nComputing the distance from a check point to a given patch is a fundamental step in verifying the constraints on $\\Pcoarse$ and $\\Pfine$ from \\cref{sec:admissible,sec:adaptive_upsampling}. \nBefore detailing our refinement algorithms to enforce these criteria, we introduce several geometric algorithms and data structures that will be used to compute the closest point on piecewise polynomial surfaces.\n\n\\subsubsection{\\aabb trees\\label{sec:aabb_trees}} \nIn order to implement our algorithms to enforce admissibility efficiently, we use a fast spatial data structure to find the patches that are close to a query point $\\vx$.\nIn \\cite{RKO, wala20193d}, the quadtree and octree within an \\fmm is extended to support the geometric queries needed for a fast \\qbx  algorithm.\nIn this work, we use an axis-aligned bounding box (\\aabb) tree, which is a type of bounding volume hierarchy \\cite{samet2006foundations}, implemented in \\texttt{geogram} \\cite{geogram}.\nAn \\aabb is a tree with nodes corresponding to bounding boxes and leaves corresponding to bounding boxes containing single objects. \nA bounding box $B_0$ is a child of another box $B_1$ if $B_0 \\subset B_1$; the root node is a bounding box of the entire domain of interest.\nOperations supported by \\aabb trees include: (i) finding all bounding boxes containing a query point, (ii) finding all bounding boxes that intersect another query box, (iii) finding the closest triangle to a query point (because triangles have trivial bounding boxes). \nBy decoupling geometric queries from fast summation, the individual algorithms can be more thoroughly optimized, in exchange for the additional memory overhead of maintaining two distinct data structures.\nThe query algorithm presented in \\cite{lu2019scalable} likely has better parallel scalability, but \\aabb trees are faster for small to medium problem sizes on a single machine due to less redundant computation.\n\nTo define an \\aabb tree for our patch-based surface $\\Gammah$, we make use of the following fact: the control points of a B\\'ezier surface ($\\vector{a}_{\\ell m}$'s from \\cref{eq:tensor-product}) form a convex hull around the surface that they define \\cite{F}.\nAs a result, we can compute a bounding box of a surface or quadrature patch $\\vP$ directly from the B\\'ezier coefficients simply by computing the maximum and minimum values of each component of the $\\vector{a}_{\\ell m}$'s, as shown in \\cref{fig:patch-coeffs-bbox}-middle.\nThis bounding box can then be inserted into the \\aabb tree as a proxy for a surface or quadrature patch.\n\\begin{figure}[!htb]\n  \\centering\n  %\\setlength\\figureheight{1.9in}\n  %\\setlength\\figurewidth{2.1in}\n  \\begin{minipage}{.33\\textwidth}\n      \\includegraphics[width=\\linewidth]{figs/patch_with_coeffs.png}\n  \\end{minipage}\\hfill\n  \\begin{minipage}{.33\\textwidth}\n    \\includegraphics[width=\\linewidth]{figs/patch_with_coeffs_bbox.png}\n  \\end{minipage}\\hfill\n  \\begin{minipage}{.33\\textwidth}\n    \\includegraphics[width=\\linewidth]{figs/patch_with_coeffs_near_bbox.png}\n  \\end{minipage}\\hfill\n  \\mcaption{fig:patch-coeffs-bbox}{Relationship between control points and\n  bounding boxes}{Left: a patch in the tensor product B\\'ezier basis, with control\n      points ($\\vector{a}_{\\ell m}$'s from \\cref{eq:tensor-product}) plotted. The convex hull of the control points of a patch are guaranteed\n      to contain the patch. Center: The patch bounding box, computed from the control\n      points. Right: The near-zone bounding box of the patch from\n      \\cref{sec:adaptive_upsampling_algo} computed by\n      inflating the bounding box by $L(\\vP)$.\n}\n\\end{figure}\n\n\n\n\\subsubsection{Computing the closest point to a patch\\label{sec:closest_point_algo}}\n\nTo find a candidate closest patch $\\vP_{i_0}$ to $\\vx$, we construct a fine triangle mesh and bounding boxes of each patch in $\\Pcoarse$ and insert them into an \\aabb tree.\nWe can query the \\aabb tree for the nearest triangle to $\\vx$ with the \\aabb tree, which corresponds to $\\vP_{i_0}$.\nWe then compute the accurate true distance $d_{i_0}$ to $\\vP_{i_0}$ using a constrained Newton method, presented in detail in \\cref{app:closest_point}.\n\nHowever, there may be other patches whose distance to $\\vx$ is less than $d_{i_0}$, as shown in \\cref{fig:candidate-near-patch}.\nTo handle this case, we then query the \\aabb tree for all patches $\\vP_{i_1}, \\hdots, \\vP_{i_k}$ that are distance at most $d_{i_0}$ from $\\vx$.\nThis is achieved by forming a query box centered at $\\vx$ with edge length $2d_{i_0}$ and querying the \\aabb tree for all intersection bounding boxes. \nThe precise distance is then computed for each patch  $\\vP_{i_1}, \\hdots, \\vP_{i_k}$ with \\cref{app:closest_point} and the smallest distance is chosen.\nWe summarize this process in \\cref{alg:closest_point}.\n\n\n\\begin{algorithm}[!htp]\n    \\KwData{A set of quadrature patches $\\qP$, a query point $\\vx$, Newton method tolerance $\\err{opt}$}\n  \\KwResult{The closest point $\\vsx$ on $\\qP$ to $\\vx$}\n\n  \\DontPrintSemicolon\n  Construct an AABB tree $T_T$ from a fine triangle mesh of the quadrature patches of $\\qP$\\;\n  Construct an AABB tree $T_B$ from bounding boxes of quadrature patches in $\\qP$.\\;\n    $\\tau_0 = $ closest triangle to $\\vx$ computed with $T_T$ \\;\n  \n    $\\vP_{i_0} = $ patch corresponding to $\\tau_0$\\;\n    Find the closest point $\\vector{s}_{\\vector{\\vx},0}$ on $\\vP_{i_0}$ to $\\vx$ with \\cite[Section 2]{morse2020bsupplementary}.\\;\n    $d_{i_0} = \\|\\vx - \\vector{s}_{\\vector{\\vx},0}\\|_2$\\;\n    $B_{d_{i_0}}(\\vx)=$ a box centered a $\\vx$ with edge length $2d_{i_0}$\\;\n    Find the boxes $B_{i_1}, \\hdots B_{i_k}$ in $T_B$ that intersect $B_{d_{i_0}}(\\vx)$\\;\n    \n    \\For{$B_{i_j} \\in B_{i_1}, \\hdots B_{i_k}$}{\n      $\\vP_{i_j} =$ quadrature patch corresponding to $B_{i_j}$ \\;\n      Find the closest point $\\vector{s}_{\\vector{\\vx},j}$ on $\\vP_{i_j}$ to $\\vx$ with \\cite[Section 2]{morse2020bsupplementary} to precision $\\err{opt}$.\\;\n      $d_{i_j} = \\|\\vx - \\vector{s}_{\\vector{\\vx},j}\\|_2$\\;\n    }\n    $j^* = \\mathrm{argmin}_j\\{d_{i_j}\\}$ \\;\n    \\Return{$\\vector{s}_{\\vector{x},j^*}$}\n  \\mcaption{alg:closest_point}{Compute the closest point to $\\vx$}{}\n\\end{algorithm}\n\n\\begin{figure}[!htb]\n  \\centering\n  %\\setlength\\figureheight{1.9in}\n  %\\setlength\\figurewidth{2.1in}\n  \\hfill\n  \\begin{minipage}{.3\\textwidth}\n      \\includegraphics[width=\\linewidth]{figs/candidate_near_patch_trimesh.pdf}\n  \\end{minipage}\\hfill\n  \\mcaption{fig:candidate-near-patch}{A \\twod schematic of near-patch candidate selection}{\n      A visual depiction of the quantities defined in lines 3-7 of \\cref{alg:closest_point} (shown here in \\twod for simplicity), with notation matching \\cref{alg:point_marking}.\n      The triangle-mesh proxy is drawn in as black lines and patches are drawn as gray curves.\n      We have found an initial closest triangle $\\tau_0$ to $\\vx$ corresponding to patch $\\vP_{i_0}$ and computed $d(\\vx, \\vP_{i_0}) = d_{i_0}$.\n      We then query the \\aabb tree for all patches that intersect box $B_{d_{i_0}}$ with edge length $2d_{i_0}$, shown in blue.\n      There is clearly a patch that is closer to $\\vx$ than $\\vP_{i_0}$ that will be returned from the query, which will be distance $d_\\lbl{min}$ from $\\vx$.\n}\n\\end{figure}\n\n\\subsection{Admissibility algorithm\\label{sec:admissible_algo}}\nOur algorithm to enforce \\cref{criteria:1,criteria:2,criteria:3} proceeds as follows:\n\\begin{itemize}\n    \\item To enforce \\Cref{criteria:1}, we adaptively fit a set of surface patches to the embeddings $\\gamma_r$ representing $\\Gamma$.\nWe construct a bidegree $(n,n)$ piecewise polynomial least-squares approximation $\\vP_i$ in the form of \\cref{eq:tensor-product} to $\\gamma_r$ on $I^2$.\n        If $\\vP_i$'s domain $\\mathcal{D}_i$ is obtained by refinement of $E_r$, we fit $\\vP_i \\circ \\eta_i$ to $\\gamma_r$ on $\\I^2$, using $4n \\times 4n$ samples on $\\I^2$. \n        If the pointwise error of $\\vP_i$ and its partial derivatives is greater than $\\err{g}$, then it is quadrisected and the process is repeated. \n\n\\item  Once the embeddings are resolved, we resolve $f$ on each surface patch produced from the previous step in a similar fashion to enforce \\Cref{criteria:2}.\n  However, rather than a least-squares approximation in this stage, we use piecewise polynomial interpolation.\n \n\\item To enforce \\Cref{criteria:3}, we construct the set of check centers $\\vhc_I$ which correspond to the check points required to evaluate the solution at the quadrature nodes $\\vy_I$.\n    For each check center $\\vhc_I$, we find the closest point $\\vector{s}_{\\vhc_I} \\in \\Gammah$.\n    If $ \\|\\vector{s}_{\\vhc_I} - \\vy_I\\| \\geq \\err{opt}$, we split the quadrature patch $\\vP$ containing $\\vy_I$.\n        The tolerance $\\err{opt}$ is used in the Newton's method in \\cite[Section 2]{morse2020bsupplementary}; we usually choose $\\err{opt}=10^{-14}$.\nSince $d(\\vhc_I,\\Gammah)$ is proportional to $L_{\\vy_I}$, the new centers $\\vhc_I$ for the refined patches  will be closer to the surface. \n    We use \\cref{alg:closest_point} to compute $\\vector{s}_{\\vhc_I}$.\n        However, in the case of check points, we can skip lines 1-6 to compute $d_{i_0}$,  since $\\vhc_I$ is $R + r(p+1)/2$ away from $\\vy_I \\in \\vP(D)$ by construction.\n        We can apply lines 7-14 of \\cref{alg:closest_point} with $d_{i_0} = R + r(p+1)/2$ to compute $\\vector{s}_{\\vhc_I}$.\n\\end{itemize}\n\nWe summarize the algorithm to enforce \\Cref{criteria:3} in \\cref{alg:admissibility}.\nAt each refinement iteration, the offending patches are decreased by quadrisection, which reduces the distance from the quadrature point $\\vy_I$ to its checkpoints.\nThis eventually satisfies \\Cref{criteria:3} and the algorithm terminates. \n\n\\begin{algorithm}[!ht]\n  \\KwData{A set of quadrature patches $\\qP$, optimization tolerance $\\err{opt}$}\n  \\KwResult{An admissible set of quadrature patches $\\qP$}\n\n  \\DontPrintSemicolon\n  $\\qP = \\Pcoarse$\\;\n  Mark all patches in $\\qP$ as inadmissible.\\;\n  \n  \\While{any patch in $\\qP$ is inadmissible}{\n    Construct an AABB tree $T$ as described in \\cref{sec:closest_point_algo} from $\\qP$\\;\n    \\For{$\\vP \\in \\qP$}{\n        \\If{$\\vP$ is inadmissible}{\n            Construct a set of check centers $C_\\vP$ for each $\\vy_J \\in \\vP(D)$ \\;\n\n            \\For{$\\vhc \\in C_\\vP$}{\n                $d_{i_0} = R + r(p+1)/2$\\;\n                Compute $\\vector{s}_\\vhc$ with lines 7-14 of \\cref{alg:closest_point} with precision $\\err{opt}$ and $d_{i_0}$.\\;\n                %Construct a box $B(\\vhc)$ with edge length $2R + r(p+1)$ centered at $\\vhc$.\\;\n                %$B_{i_1}, \\hdots B_{i_k}$ = \\texttt{query\\_bbox\\_intersections}($T$, $B(\\vhc)$\\texttt)\\;\n                %$P_{i_1}, \\hdots P_{i_k}$ =  patches corresponding to $B_{i_1}, \\hdots B_{i_k}$\\;\n                %\\eIf{$P \\in \\{P_{i_1}, \\hdots P_{i_k}\\}$}{\n                %    Compute candidate closest points $\\vector{s}_\\vhc^{(1)}, \\hdots \\vector{s}_\\vhc^{(k)}$ on $P_{i_1}, \\hdots P_{i_k}$ to $\\vhc$ with \\cref{app:closest_point} to accuracy $\\err{opt}.$\\;\n                %    $\\vector{s}_\\vhc = \\mathrm{argmin}_i \\|\\vector{s}_\\vhc^{(i)}, - \\vhc\\|_2$\\;\n                \\eIf{$\\|\\vector{s}_\\vhc -\\vy_J\\|_2 < \\err{opt}$}{\n                    Mark $\\vP$ as admissible.\\;\n                } {\n                    Mark $\\vP$ as inadmissible.\\;\n                    break   \\tcp{only need one bad check center to mark $\\vP$ for refinement}\n                }\n            }\n        }\n    }\n    \\For{$\\vP \\in \\qP$}{\n      \\If{$\\vP$ is inadmissible}{\n        Split $\\vP$ into its four child patches, mark each as inadmissible, and replace $\\vP$ with its children in $\\qP$.\n      }\n    }\n  }\n  \\Return{$\\qP$}\n  \\mcaption{alg:admissibility}{Enforce admissibility \\Cref{criteria:3} on a set of quadrature patches}{}\n\\end{algorithm}\n\n\\subsection{Adaptive upsampling algorithm \\label{sec:adaptive_upsampling_algo}}\n%Simply applying the point marking algorithm detailed \\cref{app:point_marking} to each check point is not sufficient.\nBefore detailing our upsampling algorithm to satisfy the criteria outlined in \\cref{sec:adaptive_upsampling}, we must define the notion of a \\textit{near-zone bounding box} of a quadrature patch $\\vP$, denoted $B_\\lbl{near}(\\vP)$.\nThe near-zone bounding box of $\\vP$ is computed as described in \\cref{sec:aabb_trees}, but then is inflated by $2L(\\vP)$, as shown in \\cref{fig:patch-coeffs-bbox}-right.\nThis inflation guarantees that any point $\\vx$ that is near $\\vP$ is contained in $B_\\lbl{near}(\\vP)$ and, for an admissible set of quadrature patches $\\Pcoarse$, that any $\\vx\\in \\Omega_N$ must be contained in some quadrature patch's near-zone bounding box.\nThis means that by forming $B_\\lbl{near}(\\vP)$ for each quadrature patch in $\\Pfine$, a check point is in $\\Omega_I$ if it is not contained in any near-zone bounding boxes.\n\nTo compute the upsampled patch set from $\\Pcoarse$, we initially set $\\Pfine = \\Pcoarse$, compute the near-zone bounding boxes of each patch in $\\Pfine$ and insert them into an \\aabb tree.\nWe also construct the set of check points $C$ required to evaluate our discretized layer-potential with \\qbkix (\\cref{sec:singular-eval}).\nFor each check point $\\vc \\in C$, we query the \\aabb tree for all near-zone bounding boxes that contain $\\vc$.\nIf there are no such boxes, we know $\\vc$ is far from all quadrature patches and can continue.\nIf, however, there are near-zone bounding boxes $B_{i_0},\\hdots, B_{i_k}$ containing $\\vc$, we compute the distances $d_{i_k}$ from $\\vc$ to $\\vP_{i_1},\\hdots,\\vP_{i_k}$ using \\cref{app:closest_point}.\nIf $d_{i_k} < L(\\vP_{i_k})$, we replace $\\vP_{i_k}$ in $\\Pfine$ with its four children produced by quadrisection.\n\n\nTo improve the performance of this refinement procedure, we allow for the option to skip the Newton method in \\cref{alg:closest_point} and immediately refine all patches $\\vP_{i_0},\\hdots \\vP_{i_k}$.\nThis is advantageous in the early iterations of the algorithm, when most check points are near to patches by design.\nWe allow for a parameter $n_\\lbl{skip}$ to indicate the number of iterations to skip the Newton optimization and trigger refinement immediately.\nWe typically set $n_\\lbl{skip}=2$.\nWe summarize our algorithm in \\cref{alg:adaptive_upsampling}.\n%We first use the error estimate of \\cref{sec:quad_error_heuristic} to determine the distance from the intermediate field $\\Omega_I$ to the patch $P$,  which we will call $d_\\lbl{near}(P)$.\n%We compute a bounding box of $P$ as described in \\cref{sec:mark_near}.\n%We compute a bounding box of each patch $P$ in $\\Pfine$ as described in \\cref{sec:aabb_trees}.\n%We then inflate the box size by $2d_\\lbl{near}$ to produce the \\textit{near-zone bounding box} of $P$, denoted $B_\\lbl{near}(P)$, as shown in \\cref{fig:patch-coeffs-bbox}-right. \n%We then inflate the each boxes' size by $2L(P)$ to produce the \\textit{near-zone bounding box} of $P$, denoted $B_\\lbl{near}(P)$, as shown in \\cref{fig:patch-coeffs-bbox}-right. \n\n%However, we need to still determine if a point $\\vc$ in $B_\\lbl{near}(P)$ is actually near to $P$, which requires computing the distance from $\\vc$ to $\\Gammah$.\n\n%To check this efficiently, we insert all the near-zone bounding boxes into an \\aabb tree. \n%Let $C$ be the set of all check points required to evaluate our discretized layer potential.\n%For each check point $\\vc \\in C$, we query the tree for all boxes containing $\\vc$.\n%The set of quadrature patches corresponding to the returned set of boxes are candidate patches for upsampling.\n%We can now check the distance from $\\vc$ to each of these quadrature patches using \\cref{app:closest_point} and trigger refinement if the distance between $\\vc$ and a given patch is less than $L$.\n%Alternatively, one can also simply trigger refinement on all of the patches returned by the \\aabb tree query without explicitly checking the distance.\n%This is a cheaper operation that avoids the Newton iterations of \\cref{app:closest_point}, but is less accurate and can cause over-refinement.\n%One can either trigger upsampling on all of these patches or explicitly compute the distance from $\\vc$ to each quadrature patch using .\n%The former is a cheaper condition to check but less accurate; the latter is more precise and triggers less upsampling overall, but more expensive.\n%This bounding box proxy is an over-approximation of $\\Omega_N$; there are many cases in which a check point is contained in a near-zone bounding box, but strictly in $\\Omega_I$.\n%In these cases, the true distance from $\\vc$ to each quadrature patch is more accurate.\n%We strike a balance by triggering upsampling for all returned quadrature patches for the first iteration or two of upsampling and explicitly check distance to patches for the remaining iterations.\n\n%The set $C$ is determined by $\\Pcoarse$ and therefore fixed. \n%The average size of near-zone bounding boxes decreases after each step of refinement until the algorithm terminates; eventually no near-zone bounding boxes will contain check points.\n%We summarize in \\cref{alg:adaptive_upsampling}.\n\n\\begin{algorithm}[!htp]\n    \\KwData{An admissible patch set $\\qP$, number of iterations $n_\\lbl{skip}$ before using \\cite[Section 2]{morse2020bsupplementary}}\n  \\KwResult{An upsampled set of quadrature patches}\n  \n  \\DontPrintSemicolon\n  Compute inflated near-zone bounding boxes $B_1, \\hdots,  B_N$ of each $\\vP \\in \\qP$.\\;\n  Construct an AABB tree $T$ from the near-zone bounding boxes.\\;\n  Construct all check points $C$ required to evaluate the \\cref{eq:int-eq} on $\\qP$.\\;\n\n  $\\qP_\\lbl{fine} = \\qP$\\;\n  Mark all check points in $C$ as near.\\;\n  $i=0$\n\n  \\While{any $\\vc \\in C$ is marked near}{\n    \\For{$\\vc \\in C$}{\n        \\If{$\\vc$ is marked near}{\n            Query $T$ for all bounding boxes $B_{i_1}, \\hdots B_{i_k}$ containing $\\vc$.\\;\n            $\\vP_{i_1}, \\hdots \\vP_{i_k} = $ patches corresponding to boxes $B_{i_1}, \\hdots B_{i_k}$\\;\n            Mark $\\vc$ as far\\;\n            \\For{$\\vP \\in \\vP_{i_1}, \\hdots \\vP_{i_k}$}{\n                \\eIf{$i > n_\\lbl{skip}$}{\n                    Find the closest point $\\vector{s}_{\\vc}$ on $\\vP$ to $\\vc$ with \\cref{alg:closest_point}.\\;\n                    %\\If{The error estimate in \\cref{sec:quad_error_heuristic} is greater than $\\eps$ with $d = \\|\\vy - \\vc\\|_2$}{\n                    \\If{ $\\|\\vector{s}_{\\vc} - \\vc\\|_2 < L(\\vP)$}{\n                        Split $\\vP$ and replace it in $\\qP_\\lbl{fine}$ with its children. \\;\n                        Mark $\\vc$ as near\\;\n                    }\n                } {\n                    Split $\\vP$ and replace it in $\\qP_\\lbl{fine}$ with its children.\\;\n                    Mark $\\vc$ as near\\;\n                }\n \n            }\n       }\n    }\n    $i=i+1$\\;\n\n  }\n    \\mcaption{alg:adaptive_upsampling}{Adaptively upsample to accurately evaluate \\cref{eq:double_layer_disc} at check points}{}\n\\end{algorithm}\n\n%In \\cite{RKO}, the panel size of the quadrature rule was tied to the distance of the \\qbx expansion center from the boundary.\n%This design choice produces an artificial dependence of the quadrature and expansion error, since the global upsampling factor for the fine discretization is determined by the closest expansion to the boundary.\n%\\cite{wala20193d} first presented an approach that decouples the coarse and fine discretizations; we follow a similar approach here.\n%However, their approach does not explicitly depend on surface curvature, which has a dramatic impact on quadrature accuracy, which can lead to unnecessary upsampling.\n%By taking advantage of the error heuristic in \\cref{sec:error}, we are able to accurately determine quadrature accuracy at a given check point.\n\n\\subsection{Marking target points for evaluation\\label{app:point_marking}}\n\nOnce we have solved \\cref{eq:linear_system} for $\\phi$ on $\\Gammah$, we need the ability to evaluate \\cref{eq:double_layer} at an arbitrary set of points in the domain.\nFor a target point $\\vx$, in order apply the algorithm in \\cref{sec:singular-eval}, we need to determine whether or not $\\vx \\in \\Omega$ and, if so, whether $\\vx $ is in $\\Omega_N, \\Omega_I$ or $\\Omega_F$.\nBoth of these questions can be answered by computing the closest point $\\vsx$ on $\\Gammah$ to $\\vx$. % with \\cref{app:closest_point_opt}.\nIf $\\vn(\\vsx)\\cdot(\\vx - \\vsx) < 0$, then $\\vx \\in \\Omega$. \nAs we have seen in \\cref{sec:adaptive_upsampling}, the distance $\\|\\vx - \\vsx\\|$ determines whether $\\vx \\in \\Omega_N,\\Omega_I$ or $\\Omega_F$.\nHowever, for large numbers of target points, a brute force calculation of closest points on $\\Gammah$ to all target points is prohibitively expensive.\nWe present an accelerated algorithm combining \\cref{alg:closest_point} and an \\fmm evaluation to require only constant work per target point. \n\n\n\\subsubsection{Marking and culling far points \\label{sec:mark_far}}\nA severe shortcoming of \\cref{alg:closest_point} is that its performance deteriorates as the distance from $\\vx$ to $\\Gammah$ increases. \nConsider the case where $\\Gammah$ is a sphere with radius $r$ with $\\vx$ at its center.\nThe first stage of \\cref{alg:closest_point} returns a single quadrature patch that is distance $r$ from $\\vx$; the next stage will return all quadrature patches.\nThis will take $O(N)$ time to check the distance to each patch.\nEven on more typical geometries, we observe poor performance of \\cref{alg:closest_point} when $\\vx$ is far from $\\Gammah$.\n\n%It's important that we can mark points in $\\Omega_F$ and mark points as inside or outside $\\Omega$ without using \\cref{sec:mark_near}.\nTo address this, we use an additional \\fmm-based acceleration step to mark most points far from $\\Gammah$ before using applying \\cref{alg:closest_point}. \nOur approach is based on computing the generalized winding number \\cite{jacobson2013robust} of $\\Gammah$ at the evaluation points. \nFor closed curves in $\\mathbb{R}^2$, the \\textit{winding number} at a point counts the number of times the curve travels around that point. \nThe \\textit{generalized winding number} of a surface $\\Gammah$ at a point $\\vx \\in \\mathbb{R}^3$ can be written as \n%\\begin{equation}\n%\\omega_{\\Gammah}(\\vx) = %\\frac{1}{4\\pi} W_S(\\vx) =\n%  \\frac{1}{4\\pi}\\iint_{\\Gammah} sin(\\phi)d\\phi d\\theta, \\quad (\\text{when }\\vx =0).\n%  \\label{eq:gen_winding}\n%\\end{equation}\n%%where $W(\\vx)$ is the solid angle subtended by $S$. \n%%This is the projection of $S$ onto the unit sphere centered at $\\vx$.\n%The integrand can be interpreted as the signed differential solid angle subtended by an infinitesimal surface patch centered at $\\vx$.\n%\n%In our case, $\\Gammah$ is composed of a collection of surface patches with independent parametrizations, and can be computed patch by patch.\n%%It's clear that the solid angle of $\\Gammah$ with respect to $\\vx$ is the sum of the solid angles of the surface patches:\n%\\begin{equation}\n%  \\omega_{\\Gammah}(\\vx) = \\frac{1}{4\\pi}\\sum_i \\iint_{\\gamma_i} sin(\\phi)d\\phi d\\theta.\n%  \\label{eq:gen_winding_patch}\n%\\end{equation}\n%By a change of variables to Cartesian coordinates, we can rewrite \\cref{eq:gen_winding} as \n\n\n\\begin{equation}\n  \\omega_{\\Gammah}(\\vx) = -\\frac{1}{4\\pi}\\int_{\\Gammah} \\frac{(\\vx - \\vy) \\cdot \\vn}{\\|\\vx - \\vy\\|^3} d\\vy_{\\Gammah}\n  \\label{eq:gen_winding2}\n\\end{equation}\nWe recognize this integral as the double-layer potential in \\cref{eq:double_layer} for a Laplace problem with $\\phi = 1$. \nIts values in $\\mathbb{R}^3$ are  \\cite{K}:\n\\begin{equation}\n  \\omega_{\\Gammah}(x) =\n  \\begin{cases}\n    1 & \\vx \\in \\Omega \\setminus \\Gammah\\\\\n    1/2 & \\vx \\in \\Gammah\\\\\n    0 &  \\vx \\in \\mathbb{R}^3 \\setminus \\overline{\\Omega}\n  \\end{cases}\n  \\label{eq:const-density}\n\\end{equation}\n\\cref{eq:gen_winding2} can be evaluated using the same surface quadrature in \\cref{eq:double_layer_disc} using an \\fmm in $O(N)$ time.\nWhile the quadrature rule is inaccurate close to the surface, $\\Omega_F$ is defined precisely as the zone where the quadrature rule is sufficiently accurate. \n%The rule is accurate far from $\\Gamma$, which is exactly where we want to mark target points.\nFor this reason, we use\n\\begin{equation}\n  |\\omega_{\\Gammah}(\\vx) -1| < \\etrg\n  \\label{eq:marking-far}\n\\end{equation}\nto mark points $\\vx \\in \\Omega_F \\subset \\Omega$ and a similar relation\n\\begin{equation}\n  |\\omega_{\\Gammah}(\\vx)| < \\etrg\n  \\label{eq:marking-out}\n\\end{equation}\nto mark points $\\vx \\not \\in \\Omega$.\nThis approach is similar in spirit to the spectrally accurate collision detection scheme of \\cite[Section 3.5] {QB}.\nUnlike \\cite{QB}, however, we do \\textit{not} use singular integration to mark all points. \nThis isn't possible since at this stage since we do not yet know which target points require singular integration. \nWe use the \\fmm evaluation purely as a culling mechanism before applying the full marking algorithm.\n\n\\noindent\\textbf{Remark:} Since the quadrature rule may be highly inaccurate for points close to the surface, due the near-singular nature of the integrand, $\\omega_{\\Gammah}(\\vx)$ may happen to be close to one or zero. \nWe highlight that it is possible that points outside $\\Omega_F$ may be mismarked, although we have not observed this in practice. \n\n%We use \\cref{eq:const-density} simply as a filter for far target points and mark the remaining points as described in \\cref{sec:mark_near}.\n\n\\subsubsection{Full marking algorithm}\nWe combine the algorithms of the previous two sections into a single marking pipeline for a general set of target points in $\\mathbb{R}^3$, by first applying the algorithm of \\cref{sec:mark_far} to mark all points satisfying  \\cref{eq:marking-far} then passing the remaining points to \\cref{alg:closest_point}.\nThe full marking algorithm is summarized as \\cref{alg:point_marking}.\n\n\\begin{algorithm}\n  \\KwData{An admissible set of quadrature patches $\\qP, \\etrg$, target points $\\vX$}\n  \\KwResult{A marked set of target points $\\vX$}\n  \n  \\DontPrintSemicolon\n  $\\phi_0 = 1$\\;\n  $\\omega_{\\Gammah} =$ \\texttt{Laplace\\_FMM}($\\qP$, $\\vX$, $\\phi_0$)\\;\n\n  \\For{$\\vx \\in \\vX$}{\n    \\uIf{$|\\omega_{\\Gammah}(\\vx) - 1| < \\etrg$}{\n      Mark $\\vx$ as inside $\\Omega$.\\;\n      Mark $\\vx$ as in $\\Omega_\\lbl{F}$.\\;\n    }\n    \\uElseIf{$|\\omega_{\\Gammah}(\\vx)| < \\etrg$}{\n      Mark $\\vx$ as outside $\\Omega$.\\;\n      %Mark $\\vx$ in $\\Omega_\\lbl{F}$.\\;\n    } \n  }\n  \\For{$\\vx \\in \\vX$}{\n    \\If{$\\vx$ is unmarked}{\n      %Find the closest triangle $\\tau_0$ to $\\vx$ using $T_T$. \\;\n      %$P_{i_0} = $ patch corresponding to $\\tau_0$\\;\n      %Compute the distance $d_{i_0}$ from $\\vx$ to $P_{i_0}$.\\;\n      %$B_{d_{i_0}}(\\vx)=$ a box centered a $\\vx$ with edge length $2d_{i_0}$\\;\n      %Find the boxes $B_{i_1}, \\hdots B_{i_k}$ in $T_B$ that intersect $B_{d_{i_0}}(\\vx)$\\;\n      \n      %\\For{$B_{i_j} \\in B_{i_1}, \\hdots B_{i_k}$}{\n      %  $P_{i_j} =$ quadrature patch corresponding to $B_{i_j}$ \\;\n      %  Compute the distance $d_{i_j}$ from $\\vx$ to $P_{i_j}$.\n      %}\n      %$d_\\lbl{min} = \\min_j\\{d_{i_j}\\}$ \\;\n        Compute the closest point $\\vsx$ to $\\vx$ with \\cref{alg:closest_point}\\;\n        $d_\\lbl{min} = \\|\\vsx -\\vx\\|_2$\\;\n        \\eIf{$d_\\lbl{min} \\leq L_{\\vsx}$}{\n            Mark $\\vx$ as in $\\Omega_N$\\;\n        }{\n            Mark $\\vx$ as in $\\Omega_I$\\;\n        }\n        \\If{$\\vn(\\vsx)\\cdot(\\vx-\\vsx) < 0$}{\n            Mark $\\vx$ as inside $\\Omega$\\;\n        }{\n            Mark $\\vx$ as outside $\\Omega$\\;\n        }\n    }\n  }\n  \\mcaption{alg:point_marking} {Mark points in regions $\\Omega_F$, $\\Omega_I$ and $\\Omega_N$}{}\n\n\\end{algorithm}\n\n\n%\\subsection{Comparison with \\cite{wala20193d,wala2019optimization} \\label{app:comp_wala}}\n%\\note[MJM]{move to aux doc}\n%Our work most closely resembles the advancements presented in \\cite{wala20193d, wala2019optimization}. \n%We have presented a \\textit{global} singular/near-singular quadrature method, i.e., the potential values at the check points are computed with a quadrature rule from the entire boundary.\n%\\cite{wala20193d} proposed a global \\qbx method that computes \\qbx expansion coefficients via \\fmm translation operators from within an \\fmm tree.\n%Our method is \\textit{target-specific} as in \\cite{ST}, creating one set of check points for each target point.\n%\\cite{wala20193d} was further refined to include target-specific \\qbx expansions in \\cite{wala2019optimization}.\n%\n%Our admissibility algorithm is similar to the Stage-1 refinement of \\cite{wala20193d}.\n%Both approaches first resolve the boundary data and input geometry, then enforce a criteria that will guarantee accurate smooth quadrature rules at prescribed point locations.\n%The improvement in our approach is the decoupling of the spatial data structure for the required geometry queries to enforce admissibility and the data structure for \\fmm acceleration.\n%This allows for less memory overhead and faster spatial queries and \\fmm evaluations by leveraging existing software packages.\n%Additionally, our algorithm is formulated in terms of patches and bounding boxes rather than in terms of quadrature point locations.\n%This allows us to perform fewer spatial queries on a smaller data structure to enforce our criteria and make guarantees about the proximity of a patch to a check point that is independent of the quadrature order.\n%As in \\cite{wala20193d}, we also fix the check point location before upsampling, which decouples the coarse and upsampled discretization.\n%We both compute upsampled discretizations based on empirical heuristics to approximate quadrature error behavior.\n%\n%However, the primary improvement of \\qbkix over \\cite{wala20193d} is \\textit{algorithmic simplicity}.\n%Our only requirement is a standard point \\fmm without modifications.\n%This allows us to utilize existing optimized algorithms for spatial queries and fast summation, which have been extensively optimized.\n%Most importantly, it prevents the \\qbx-\\fmm error coupling handled carefully in \\cite{wala20193d,wala2019optimization}. %with the target confinement rule, which constrains a \\qbx expansion to reside within an appropriately sized \\fmm box to prevent error accumulation due to numerical differentiation.\n%The price we must pay for this simplicity is a larger point \\fmm evaluation, since we are using the discretization of $\\Pfine$ as source points.\n%Since we are using the kernel-independent \\fmm, we must use a higher multipole order to counteract the accumulation of translation operator error inherent in this approach \\cite{ying2004kernel}.\n%A standard \\fmm method would not have this downside, but we believe that \\pvfmm's impressive performance optimizations make this is reasonable trade-off.\n%\n", "meta": {"hexsha": "addb60a944ef912199ca9f07c726370a1d4ca9f7", "size": 53936, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hedgehog/algorithms.tex", "max_stars_repo_name": "mmorse1217/nyu-thesis-template", "max_stars_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hedgehog/algorithms.tex", "max_issues_repo_name": "mmorse1217/nyu-thesis-template", "max_issues_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hedgehog/algorithms.tex", "max_forks_repo_name": "mmorse1217/nyu-thesis-template", "max_forks_repo_head_hexsha": "dbbef3f00a1e91d6f481b4c6cb480d40960b13c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.275, "max_line_length": 976, "alphanum_fraction": 0.7243028775, "num_tokens": 15310, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4010039244150179}}
{"text": "\\section{Methods and Implementation}\n\\label{sec:methods}\n\\fred implements a minimal user interface, Figure \\ref{fig:surgery_fred}, to demonstrate registration of a pre-operative image to intra-operative space. At startup a target is placed at a random location within the pre-operative image, shown as a red circle. The standard deviation of the \\gls{FLE} is randomly sampled from a uniform distribution \nbetween 0.5 and 5.0 pixels \\footnote{All units are in pixels, as the concepts being explored do not depend on the units used. Figure \n\\ref{fig:surgery_fred} shows a brain MRI 458x512 pixels, by design SciKit-SurgeryFRED should work with other images \nof arbitrary dimensions.}. By default the \\gls{FLE} is modelled as an isotropic (in 3 dimensions), normally distributed, and independent random variable, though this can be easily changed. \nThe variance of the \\gls{FLE} is shown to the right of the intra-operative image (as expected value), along with the number of fiducial markers. \n\n\\begin{figure}\n\t\\begin{center}\n\t\\includegraphics[width=\\linewidth]{scikit-surgeryfred_gui.eps}\n\t\t\\caption{\\label{fig:surgery_fred}SciKit-SurgeryFRED graphical user interface after 6 fiducial markers placed. The red circle in the pre-operative image (left) represents a clinical target, which is located in the\n\t\tintra-operative space (middle) by fiducial based registration, using the fiducial markers (also red). FLE is added to each marker in the intra-operative image, this is more clearly visible on the zoomed in image at the right. The resulting registration results in a TRE, shown by the misalignment of the red circle and crosshair \n\t\ton the enlarged image at right. TRE and other statistics are shown in boxes to the right of the intra-operative image.}\n\t\\end{center}\n\\end{figure}\n\nClicking either image adds a fiducial marker to both images. By default the marker is added to the pre-operative image \nwith no \\gls{FLE}. \\gls{FLE} is added to the marker location in the intra-operative image, visualised as the misalignment\nbetween the red circle centre and the cross-hair. Once sufficient markers are placed ($>2$) the two sets of markers are registered using least squares fitting as described by Arun et al.\\cite{Arun1987}. The expected values (variance) of the \\gls{FRE} and \\gls{TRE} are calculated \nusing equations described by Fitzpatrick et al.\\cite{Fitzpatrick1998}. The student can use this interface together with an \nonline tutorial \nto explore the relationships between the various statistics and error measures. The\nuser can keep adding as many fiducial markers as they like for a given target. \nPressing the ``New Target'' button will place a new target at a random position \nwithin the pre-operative image and randomly sample a new standard deviation for the\n\\gls{FLE}.\n\nIt is straightforward to explore how both \\gls{TRE} and \\gls{FRE} change in response to \nboth the number and geometry of the fiducial markers as is well established in the literature\\cite{1295074, Fitzpatrick1998}. \nIt is\nalso simple and instructive to create degenerate marker geometries, for example \na linear arrangement can produce low \\gls{FRE} but extreme values of \\gls{TRE}.\n\nDuring use the registration results are \nstored in the browser. At any time the user can press the ``Plot Results'' button to quickly create a set of \nplots showing the relationship between the actual \\gls{TRE} and the various statistics. \nAn example plot is shown in Figure \\ref{fig:correlation}. \nThe student is usually able to see first hand that, as expected, \\gls{FRE} is uncorrelated with \\gls{TRE}. \n\n\\begin{figure}\n\t\\begin{center}\n\t\\includegraphics[width=0.9\\linewidth]{images/default.eps}\n\t\t\\caption{\\label{fig:correlation}Plots of TRE against various error measures, generated by \n\t\t205 user registrations.}\n\t\\end{center}\n\\end{figure}\n\n\\fred does not implement tests of statistical significance to avoid excessive software dependencies, so it is often \nuseful for the students to download the registration results and perform some statistical analysis. This is facilitated by the \n``Download Results'' button which allows the user to get the results as a file in comma separated variable format. \nFor example the results in Figure \\ref{fig:correlation} may prompt some students to ask if there is in fact a correlation \nbetween \\gls{FRE} and \\gls{TRE}, as there is an apparent though slight increase in \\gls{TRE} with \\gls{FRE}. This can quickly \nbe dispelled by asking the student to download the results and perform a test of significance on the data. \n\n\\subsection{Game Based Registration Study}\n\\label{sec:game_method}\nOnce the students have an understanding of what statistics can be used to estimate \\gls{TRE}, we wanted to test \nhow knowledge of a particular statistic affects optimal treatment planning. We designed a serious game to \ndo this. During this game the students are asked to perform a registration with a maximum of \n6 fiducial markers, then set a treatment margin and ablate the target. The goal is \nto treat 100\\% of the target with minimal ablation of surrounding tissue.\nA score of 1000 was awarded for complete ablation and 0 \nfor anything less. From this starting score 10 times the percentage volume of any\nsurrounding tissues ablated is subtracted. \nSuccessful treatments (100\\% ablation) should therefore score between 0 and 1000, with a larger margin giving a lower score.\nThe optimum (minimum successful) treatment\nmargin is the actual \\gls{TRE} for a given registration. \nAny treatment that fails to treat 100\\% of the target will receive a negative score. \n\nEach student participated in the game, performing 20 simulated ablations. For the first four ablations they were told the \nactual \\gls{TRE} for training and to supply baseline data. After that they performed 16 more ablations and were shown one of four randomly selected statistics on which to base their decision,\nthe expected values of the \\gls{TRE}/\\gls{FRE}, the actual \\gls{FRE}, the expected value of the \\gls{FLE}. These statistics\nwere chosen as these are either known or can be estimated for a clinical procedure. Each statistic was shown 4 times, though\nthe order was randomised for each participant. The scores for each ablation were recorded,  yielding 20 data points for \neach participant.\n\n\\subsection{Software Implementation}\n\\fred is part of the \\sksurgery\\cite{PMID:32436132} family of libraries. In common with \\sksurgery the majority of \\fred is implemented in Python. Python was chosen as it combines sufficient features for clinical\napplications such as the SmartLiver system\\cite{PMID:32780240}, whilst remaining easy enough for students to learn and contribute to. \nIn contrast, although platforms built using {C\\raisebox{0.5ex}{\\tiny\\textbf{++}}} provide power and \nflexibility, the choice of language creates a barrier to learning the key concepts of image guided surgery \\cite{surgineering}. A key design goal of \n\\sksurgery is to keep individual libraries compact and orthogonal\\cite{pragmaticprog}, simplifying dependency structures. Based on \nanalysis using cloc\\footnote{\\href{https://github.com/AlDanial/cloc}{https://github.com/AlDanial/cloc} [v1.82]} \\fred consists of 1479 lines of Python \ncode. The user interface is implemented in HTML5 and JavaScript, enabling multiple simple deployment \noptions. Again, using cloc, there are 957 lines of HTML5 and JavaScript. These numbers are similar to the other \\sksurgery libraries which typically have around 2000 lines of code \\cite{PMID:32436132}. \n%In comparison, this paper consists of 431 lines of Latex code.\n\nFigure \\ref{fig:dependencies} shows the direct dependencies of \\fredns. The key functional dependency is\n\\core\\cite{matt_clarkson_2020_3965731}. \\core implements matched point based registration \\cite{Arun1987} together \nwith the calculation of expected \\gls{FLE} and \\gls{TRE}\n(equations 10 and 31 from Fitzpatrick et al.\\cite{Fitzpatrick1998}). \n{NumPy} \\cite{2020NumPy-Array} is used for array handling.\nFlask\\footnote{\\href{https://palletsprojects.com/p/flask/}{https://palletsprojects.com/p/flask/}  [v1.1.2]} provides the web application framework \nto enable the browser based user interface to communicate with the Python based back end. The user\ninterface communicates with the back end with a series of {POST} requests. All state information is stored in the \nbrowser front end, allowing the back end to remain stateless, simplifying deployment. \nIncluding the Google Cloud FireStore API\\footnote{\\href{https://pypi.org/project/google-cloud-firestore/}{https://pypi.org/project/google-cloud-firestore/} [v2.0.1]} \nenables the optional storage of results in a remotely hosted database. Plotting functionality is implemented\nusing Chart.js\\footnote{\\href{https://www.chartjs.org/}{https://www.chartjs.org/} [v2.9.4]}\n\n\\begin{figure}\n\t\\begin{center}\n\t\\includegraphics[width=0.7\\linewidth]{dependency_graph.eps}\n\t\t\\caption{\\label{fig:dependencies}Software dependencies of SciKit-SurgeryFRED. The registration algorithms and statistical measures of {TRE} are imported from SciKit-SurgeryCore and are shared with clinical applications built on SciKit-Surgery. The user interface is a Flask based web application, using Chart.js for plotting functionality.}\n\t\\end{center}\n\\end{figure}\n\nIn common with the rest of \\sksurgery \\fred utilises extensive testing and software process \\cite{1398621} to \nensure the application is robust, reusable, and sustainable\\cite{VENTERS2018174}. Change control and issue tracking is managed\non GitHub\\footnote{\\href{https://github.com/UCL/scikit-surgeryfred}{https://github.com/UCL/scikit-surgeryfred}} and continuous integration is managed using\nGitHub Actions.\n\n\\subsection{Availability and Usage}\nFor those who want to quickly try \\fredns, we currently maintain a running instance hosted at \\href{https://scikit-surgeryfred.ew.r.appspot.com/}{https://scikit-surgeryfred.ew.r.appspot.com/}. This should be accessible from most modern web browsers.\n\nIf you want to run a locally hosted instance, or modify the code for your needs, you can download the source code. \\fred is entirely open source software and is tested on Linux, MacOS, and Windows. The latest version can be obtained from Github. Alternatively, archived releases can be retrieved via Zenodo\\cite{stephen_thompson_2021_4462897}.\n\n\\begin{lstlisting}[language=bash]\n\tgit clone https://github.com/UCL/scikit-surgeryfred\n\\end{lstlisting}\n\nOnce installed the dependencies can be installed on a local virtual machine using tox. The application can then be run with as follows. This should output a web address that you can open in a browser to run the software. \n\n\\begin{lstlisting}[language=bash]\n\tcd scikit-surgeryfred\n\ttox\n\tsource .tox/py37/bin/activate\n\tpython main.py\n\\end{lstlisting}\n\n\\subsection{Extension to Anisotropic Errors}\n\\label{sec:anis_method}\nIn many cases {FLE} cannot be properly modelled as an isotropic, independent, random variable. In the case of optical tracking systems for example \\cite{10.1117/12.536128} the errors normal to the camera plane are approximately 3 times those parallel to the camera plane. It is straightforward to implement such an anisotropic \\gls{FLE} in SciKit-SurgeryFRED and test the effect on registration outcomes.\nThe following code snippet is taken from  main.py. Line 66 defines the ratio of \\gls{FLE} in three directions. By default they are all equal.\n\n\\begin{lstlisting}[language=python, firstnumber = 57]\n@app.route('/getfle', methods=['POST'])\ndef getfle():\n    \"\"\"\n    Returns values for fiducial localisation errors\n    Values are randomly selected from a uniform\n    distribution from 0.5 to 5.0 pixels\n    \"\"\"\n    fle_sd = np.random.uniform(low=0.5, high=5.0)\n    #change fle_ratio if you want anisotropic fle\n    fle_ratio = np.array([1.0, 1.0, 1.0], dtype=np.float64)\n    anis_scale = math.sqrt(3.0 / (np.linalg.norm(fle_ratio) ** 2))\n    fixed_fle = fle_ratio * fle_sd * anis_scale\n\n    moving_fle = np.array([0., 0., 0.], dtype=np.float64)\n    fixed_fle_eavs = expected_absolute_value(fixed_fle)\n    moving_fle_eavs = expected_absolute_value(moving_fle)\n\n    returnjson = jsonify({\n            'fixed_fle_sd': fixed_fle.tolist(),\n            'moving_fle_sd': moving_fle.tolist(),\n            'fixed_fle_eav': fixed_fle_eavs.tolist(),\n            'moving_fle_eav': moving_fle_eavs.tolist()\n            })\n    return returnjson\n\\end{lstlisting}\n\nChanging line 66 to;\n\\begin{lstlisting}[language=python, firstnumber=66]\n    fle_ratio = np.array([3.0, 1.0, 1.0], dtype=np.float64)\n\\end{lstlisting}\nsets the error in the x direction to 3 times that in the y and z directions.  \n\n\\subsection{Addition of Systematic Errors}\n\\label{sec:sys_method}\nA second significant source of error that is usually overlooked is the presence of systematic errors. For example when using a tracked pointer for fiducial localisation, \nany pointer calibration error will be be added to all fiducial markers.\nSimilarly some optical tracking systems can introduce a systematic error on \nthe tracking markers \\cite{6294449}. \\fred allows systematic error to \nbe added to each fiducial. The fiducial localisation error is set within \nthe JavaScript function init{\\textunderscore}fles()\n(defined in static/main.js) each time a new target is set. \n\\begin{lstlisting}[language=java, firstnumber = 496]\n/**\n * Sets the global fiducial localisation error (FLE)\n */\nfunction init_fles() {\n  fetch(\"/getfle\", {\n      method: \"POST\",\n    })\n    .then(resp => {\n      if (resp.ok)\n        resp.json().then(data => {\n\n        let preOpFLEStdDev = data.moving_fle_sd;\n        let intraOpFLEStdDev = data.fixed_fle_sd;\n        let preOpFLEEAV = data.moving_fle_eav;\n        let intraOpFLEEAV = data.fixed_fle_eav;\n\n        let preOpSysError = [0.0, 0.0, 0.0];\n        let intraOpSysError = [0.0, 0.0, 0.0];\n\n        FLE = { preOpFLEStdDev, intraOpFLEStdDev,\n                preOpFLEEAV, intraOpFLEEAV,\n                preOpSysError, intraOpSysError };\n\n        expectedFLEText.innerHTML = Math.round(Math.sqrt(FLE.intraOpFLEEAV)*100)/100;\n      });\n    })\n    .catch(err => {\n      console.log(\"An error occured setting fles\", err.message);\n    });\n}\n\\end{lstlisting}\nBy default there is no systematic error, (lines 512 and 513). We can \nadd a systematic interoperative error at line 513 as; \n\n\\begin{lstlisting}[language=java, firstnumber = 513]\n        let intraOpSysError = [1.0 * (Math.random() - 0.5), \n                               1.0 * (Math.random() - 0.5), \n                               1.0 * (Math.random() - 0.5)];\n\\end{lstlisting}\n\nIn this case the error is an isotropic uniform random variable, in the range\n-0.5 to 0.5. This error will be applied to all fiducial markers for a \ngiven registration. \n\n\n", "meta": {"hexsha": "80f29d7483c9d3110adda1405a3fdbaa4dd624db", "size": 14708, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "methods.tex", "max_stars_repo_name": "SciKit-Surgery/scikit-surgeryfred-paper", "max_stars_repo_head_hexsha": "bc72551650facf1adf0e5954810f6ac2aec81080", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "methods.tex", "max_issues_repo_name": "SciKit-Surgery/scikit-surgeryfred-paper", "max_issues_repo_head_hexsha": "bc72551650facf1adf0e5954810f6ac2aec81080", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "methods.tex", "max_forks_repo_name": "SciKit-Surgery/scikit-surgeryfred-paper", "max_forks_repo_head_hexsha": "bc72551650facf1adf0e5954810f6ac2aec81080", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.3688888889, "max_line_length": 404, "alphanum_fraction": 0.7676774544, "num_tokens": 3683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.596433160611502, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.40100091248903347}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{homework 4, task 2}\n\\author{Alexander Smirnov}\n\\date{March 2019}\n\n\\usepackage{natbib}\n\\usepackage{graphicx}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{What to do}\nProve that $S\\:K\\:K = I: $\n\n$$(\\lambda x\\:y\\:z.x\\:z\\:(y\\:z))\\:(\\lambda x\\:y.x)\\:(\\lambda x\\:y.x)=\\lambda x.x$$\n\n\\section{Solution}\n\n$$(\\lambda x\\:y\\:z.x\\:z\\:(y\\:z))\\:(\\lambda x\\:y.x)\\:(\\lambda x\\:y.x)$$\n\n$$(\\lambda x.\\lambda y\\:z.x\\:z\\:(y\\:z))\\:(\\lambda x\\:t.x)\\:(\\lambda x\\:y.x)$$\n\n$$(\\lambda y\\:z.(\\lambda x\\:t.x)\\:z\\:(y\\:z))\\:(\\lambda x\\:y.x)$$\n\n$$(\\lambda y\\:z.z)\\:(\\lambda x\\:y.x)$$\n\n$$(\\lambda y.\\lambda z.z)\\:(\\lambda x\\:y.x)$$\n\n$$\\lambda z.z$$\n\n\n\\end{document}", "meta": {"hexsha": "f00f9ed9a20718855688392cb0c83aad4e9e0b27", "size": 688, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ProofSKKI/proofSKKI.tex", "max_stars_repo_name": "SmirnovAlexander/FSharpTasks", "max_stars_repo_head_hexsha": "09fa2618a9c162bb4781c4aa9117f034d0c18e4e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ProofSKKI/proofSKKI.tex", "max_issues_repo_name": "SmirnovAlexander/FSharpTasks", "max_issues_repo_head_hexsha": "09fa2618a9c162bb4781c4aa9117f034d0c18e4e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ProofSKKI/proofSKKI.tex", "max_forks_repo_name": "SmirnovAlexander/FSharpTasks", "max_forks_repo_head_hexsha": "09fa2618a9c162bb4781c4aa9117f034d0c18e4e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.6571428571, "max_line_length": 82, "alphanum_fraction": 0.5697674419, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4010009106749433}}
{"text": "%% LyX 2.3.4.2 created this file.  For more info, see http://www.lyx.org/.\n%% Do not edit unless you really know what you are doing.\n\\documentclass[english]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[latin9]{inputenc}\n\\usepackage{amstext}\n\\usepackage{graphicx}\n\n\\makeatletter\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.\n\\usepackage{tabularx}\n\n\\usepackage{authblk}\n\n\\makeatother\n\n\\usepackage{babel}\n\\begin{document}\n\\title{Bayesian ODE/Convolution Models for Estimating Underlying Growth of\nCOVID-19 and its Uncertainty }\n\\author{Douglas Mason\\thanks{Koyote Science LLC and Nexus iR\\&D Laboratory, San Francisco, CA},\nRobert Martinez\\thanks{Harvard University, Cambridge College, and Nexus iR\\&D Laboratory,\nBoston, MA}}\n\\date{May 8, 2020}\n\n\\maketitle\nWe model universal curves of reported COVID-19 daily reported infections\nand related deaths using a modified epidemiological Susceptible-Exposed-Infectious-Recovered\n(SEIR) Model\\cite{original-SEIR-model,more-SEIR,even-more-SEIR}.\nUsing currently available data, we determine optimized constants and\napply this framework to reproducing the infection and death curves\nfor California (the state with the largest population), New York (the\nstate with highest population density), and U.S. totals, and provide\nsupplementary results for the remaining 50 states and Washington D.C.\nSource code used to produce these results can be found at the companion\nwebsite\\cite{companion}. Data is sourced from the New York Times\\cite{nyt-data}. \n\n\\section{Model Definition}\n\nIt is helpful to define various sets that appear in the model as time-dependent\nvariables. In the early stages of an epidemic or pandemic, the vast\nmajority of individuals are susceptible to infection, while few individuals\nhave recovered from an infection, and for this reason we can approximate\nthe S and R values to 100\\% and 0\\% respectively. In addition, the\nSEIR model treats transitions from one group to the next as emissions\nwith fixed (or possibly time-varying rates), which may be accurate\nover long time periods, but does not reflect the dynamics we attempt\nto model. Rather, while the growth of contagious individuals is well-described\nby time-varying growth rates (which can be solved by integrating a\nsingle ordinary differential equation), the transition to other measurable\nstates (such as being tested and confirmed positive, or subsequently\ndying) likely exhibits an average time-delay with a measurable variance\nand an overall multiplier. For example, a person who has just become\ncontagious will likely not show symptoms for up to a week, and then\nshow symptoms, and then go to the hospital and be tested, and then\nhave a probability of being confirmed positive. \n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{static_figures/delayed_gaussian_diagram}\n\n\\caption{\\label{fig:Delayed-gaussian-diagram}The convolution kernel (defined\nonly for t > 0) provides a time delay, width, and multiplier describing\nthe transition from the contagious pool to the confirmed and the deceased\npools with different parameter values.}\n\\end{figure}\nAll transitions can be modeled by the three numbers, as shown in Figure\n\\ref{fig:Delayed-gaussian-diagram}: \n\\begin{itemize}\n\\item Average time delay ($\\mu$) \n\\item Variance in time delay ($\\sigma^{2}$) \n\\item Overall multiplier ($M$), i.e., how many people in total transition\nfrom one state to the next)\n\\end{itemize}\nNote that in a usual system of ODEs (as in the SIR/SEIR models), each\ntransition is modeled not by three by just one single parameter, the\ntransition rate. This means that our system of parameters is over-determined\ncompared to a system of ODEs (see below for how we address those concerns\nusing domain knowledge). However, these ODE systems are better-suited\nto the assumptions of molecular dynamics rather than disease spread\nover short time scales. For example, a person who becomes contagious\nhas zero chance of being immediately tested and confirmed positive,\nbut this is possible in a rate-based model. Moreover, to account for\nthe shapes of the data that we have, such systems need to postulate\nat least one intermediate stage between Contagious and Positive or\nDeceased, rendering them unjustifiably complex, to allow people to\ntransmit from the contagious pool and aggregate in intermediate pools\nbefore emitting into the positive and deceased pools. \n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{static_figures/state_transitions}\n\n\\caption{\\label{fig:State-flow}Diagram of the states modeled: people enter\nthe contagious and emit to the Positive and to the Deceased state\nby delayed-Guassian emission with different delays, widths, and multipliers.\nHowever, the Contagious pool itself grows with instantaneous emissions\ndependent on the total size of the pool. We model emission to the\nRecovered pool as having the same delay and width as the learned parameters\nfor emission to the Deceased pool, with a multiplier set so all members\nof the Contagious pool either recover or die. While the Recovered\nand Deceased pool are mutually exclusive, the Positive pool overlaps\nwith both. Our model only concerns itself with new Positive and Deceased\nentrants, rather than their cumulative numbers.}\n\\end{figure}\nWe describe our model according to Figure \\ref{fig:State-flow} based\non two observables (confirmed positive cases and deaths) and one non-observable\n(the number of newly contagious individuals). Because our model is\na directed acyclic graph, we can start with a hypothetical profile\nof the newly Contagious pool and use convolution to determine the\nPositive and Deceased pools. To obtain the Contagious profile, we\nintegrate the simple ODE below. \n\n\\[\n\\frac{dC}{dt}=\\alpha(t)C\n\\]\n\n\\[\n\\alpha(t)=\\frac{\\alpha_{2}-\\alpha_{1}}{1+\\exp(t_{0}-t)}+\\alpha_{2}\n\\]\n\nTo define $\\alpha(t)$, we use a logistic function in time with fixed\nwidth parameter set to 1 day to interpolate between two extremal constant\nvalues 1 and 2 for the infectivity rate before and after a Shelter-in-\nPlace order $t_{0}$. The difference in the two infection rates indicates\nthe effectiveness of the order on reducing the growth of new infections.\nThe above ODE produces a profile of C(t) that has two growth rates\nconnected using a fixed-width logistic transition between the two\ngrowth rates. \n\nThe transition of a single individual from the Contagious to Positive\nand Deceased pools is modeled by a different gaussian kernel for each\ntransition: \n\n\\[\nK(t,t')=\\theta(t,t')\\frac{M}{\\sigma\\sqrt{(2\\pi}}\\exp\\left[-\\left(\\frac{t-t'-\\mu}{\\sigma}\\right)^{2}\\right]\n\\]\nwhere $\\theta(t,t')$ is a step function returning 1 for $t'>t$ and\n0 otherwise. The kernel is normalized to unit area so that M gives\nthe total number of people who transition from one state to the next.\nThe value provides the average delay between one state and the next,\nand the value indicates the variance in time delays between one state\nand the next. \n\n\\section{Handling Transient Perturbations Around Shelter-in-Place }\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{\\string\"/Users/kayote/Downloads/COVID-19 Model/images/image27\\string\".png}\n\n\\caption{\\label{fig:Convolution-diagram}Diagram describing the convolution\nprocess. A function with a disjoint derivative (blue, on left), when\nconvolved with a delayed Gaussian kernel (black, middle) produces\na smooth curve that will be shifted to the right and be changed in\nmagnitude (green, right).}\n\\end{figure}\nOur model explicitly does not model the Recovered pool, which means\nthat the initial and final growth rates $\\alpha_{1}$ and $\\alpha_{2}$\nare effective growth rates that account for emission into the Recovered\npool. In fact, the growth rate drawing new people into the Contagious\npool (the \\textquotedblleft leading front\\textquotedblright ) is slightly\nhigher than the effective growth rate, since it must compensate against\nthe loss of individuals to the Recovered pool. In Figure \\ref{fig:Convolution-diagram},\nwe show an example of how this works: Individuals enter the Contagious\npool, then emit either into the Recovered or Deceased pools with a\ndelayed Gaussian probability with values for the delay, width, and\nmultiplier based on fits to the Deceased curve for U.S. totals ($\\mu=19$,\n$\\sigma=10$, $M=0.01$). On the other hand, new individuals enter\nthe Contagious pool in proportion to the total size of the pool and\nthis occurs with an instantaneous growth rate without delay. \n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{static_figures/transients}\n\n\\caption{\\label{fig:Effective-growth-rate}Example solution showing the Contagious,\nPositive, and Deceased curves for a model incorporating the Recovered\nemissions. We find that considering the Recovered pool pulls down\nthe \\textquotedblleft leading front\\textquotedblright{} growth rate\ninto effective growth rates that match the growth rates in our data.\nDetails about emission may or may not produce a visible hump in the\nunobserved Contagious pool around the time of shelter-in-place, which\nis then smoothed out through emissions into the Positive and Deceased\npools. This is how pools which have reached a flat effective growth\nrate continue to draw in new individuals, since the raw growth rate\nfor new Contagious individuals is actually slightly higher than what\nwe observe to compensate for loss to the Recovered pool.}\n\\end{figure}\nAs shown in Figure \\ref{fig:Effective-growth-rate}, the effective\ngrowth is demonstrated to be less than the original growth by a fixed\namount related to the emission parameters, with an artifact occuring\nduring the change in growth rates that appears as a temporary hump.\nHowever, after that hump has been smoothed out by the Gaussian emission\ninto the Positive and Deceased pools, it is no longer visible. The\nparameters we describe in this document refer to the solid blue curve,\nwhich we approximate without the transient artifacts around shelter-in-place.\nWe provide an example solution in Figure 3 against the U.S. totals. \n\n\\section{Reducing Model Parameters Using Domain Knowledge }\n\nThe following parameters are determined by the data:\n\\begin{itemize}\n\\item The slope of positive cases at the beginning and at the end of the\nshelter-in-place order (after a delay, of course) determine the two\ngrowth rates 1 and 2. The value of 2 may not be precisely known until\nmore time has passed to collect more data. \n\\item The change in the slope of positive cases indicates the likely delay\nbetween becoming contagious and testing positive. However, if the\ntransition width is sufficiently large, this delay may become ambiguous. \n\\item Similar arguments apply for the parameters describing transitions\nfrom the Contagious to the Deceased pools. \n\\end{itemize}\nIn addition, there are also ambiguities in the model since it is overdetermined.\nIn particular, two parameters together describe the relative magnitude\nof the Contagious and Positive curves. Therefore, we recommend fixing\none of these two values:\n\\begin{itemize}\n\\item The initial conditions (hypothetical \\# of newly contagious people)\nat time ($t_{0}$) (Note, this can also be equivalently described\nas the time in the past that the first individual entered the Contagious\npool.)\n\\item The contagious-to-positive multiplier \n\\end{itemize}\nSince there is no means of knowing the initial conditions, we recommend\nfixing the contagious-to- positive multiplier to an approximate value\nsupported by evidence, and set the value to 10\\%. Note that the degeneracy\nin describing initial conditions (number of newly contagious individuals\nat a fixed date, or the time in the past that the first individual\nbecame contagious) imply that the fraction of contagious individuals\nwho are tested and confirmed necessarily goes down the earlier in\nthe past that the first individual became contagious. \n\nAnother ambiguity arises regarding the three parameters:\n\\begin{itemize}\n\\item The contagious-to-positive delay width \n\\item The contagious-to-positive delay \n\\item The final contagious growth rate\n\\end{itemize}\nThis is because the data supports two groups of solutions: \n\\begin{itemize}\n\\item Ones with shorter delays and delay widths and with a more-positive\nfinal growth rate \n\\item Ones with longer delays and delay widths and with a more-negative\nfinal growth rate\n\\end{itemize}\nwhich is also true for the contagious-to-deceased transition, where\nthe lower data counts (and therefore greater measurement ambiguity)\nsupport the second solution more strongly. However, we can use domain\nknowledge to identify that since the values supporting the first hypothesis\nare more-closely aligned with realistic numbers (we doubt that the\ndelay is over a month or that there is over 20 days of variance in\nthe delay). \n\nThere are three approaches for handling this ambiguity: \n\\begin{enumerate}\n\\item Fix some parameters to reduce the expressivity of the model (and increase\nspeed of optimization)\n\\item Apply priors that rule out undesirable solutions\n\\item Add terms to the loss function to penalize undesirable solutions\n\\end{enumerate}\nWe apply all three techniques (see the next section) and, in particular,\nfix the contagious-to-positive and contagious-to-deceased emission\nwidths to the approximate values for the U.S. totals: 7 days, or 1\nweek, for both.\n\n\\section{Likelihood Approximation and Incorporating Prior Beliefs }\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_1000_bootstraps_100000_likelihood_samples/total/bootstrap_solutions_with_priors}\n\n\\caption{\\label{fig:US-curves-with-spread}Model Curves and Experimental Data\nof U.S. COVID-19 Daily Reported Cases and Related Deaths in the U.S.}\n\\end{figure}\nWe utilize two approximations to the full likelihood distribution\nacross our parameters, given our observations. The first approximates\nthe likelihood as the distribution of maximum-likelihood-estimates\n(MLEs) of the parameters on bootstraps of our data, using least-squares\nerror on the difference in the expected and measured log values of\nconfirmed cases and casualties. We consider measurement uncertainty\nby noting that we expect newly reported cases and deaths to vary up\nto $\\sqrt{N}$ from their underlying values since such counts can\nbe modeled as a Poisson process, whose variance is equal to its measured\nmean, although the resulting variance ignores other systematic influences\non our data such as time-varying testing rates or imperfect tests.\nThus, we sample training data with replacement and add samples from\na normal distribution with a standard deviation of $\\sqrt{N}$ to\nthe recorded values, run our simulation using a discrete ODE solver\nand convolution library, and minimize the least-squares error over\nnewly confirmed cases and deaths after the 100th case and death has\nbeen identified, respectively. We show an example set of solutions\nfor U.S. totals in Figure \\ref{fig:US-curves-with-spread}. From the\nresulting parameter estimates, the bootstrapping technique has been\nshown to accurately describe the distributions up to second-order\nstatistics (and possibly higher)\\cite{efron2003,efron1979,rubin1981}.\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_100_bootstraps_100000_likelihood_samples/total/MVN_random_walk_actual_vs_predicted_vals}\n\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_100_bootstraps_100000_likelihood_samples/total/MVN_samples_actual_vs_predicted_vals}\n\n\\caption{\\label{fig:US-MVN-approx}Actual vs. predicted values for the likelihood\nfunction for U.S. totals as modeled by a multivariate normal distribution,\nas sampled using the MCMC algorithm (top) and direct likelihood samples\n(bottom). The two sources of likelihood samples in the bottom figure\nare apparent in the two ``comet tails'' emerging from the most-likely\npoints at the upper-right. The MCMC algorithm discards roughly 90\\%\nof proposed samples resulting in the thinner cloud of points.}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_100_bootstraps_100000_likelihood_samples/total/MVN_random_walk_correlation_matrix}\n\n\\caption{\\label{fig:US-MVN-approx-correlation-matrix}Correlation matrix for\nmodel parameters for U.S. totals after being fit to a multivariate\nnorm with a full covariance matrix. We see that $\\alpha_{1}$ is strongly\nanti-correlated with the two delays.}\n\\end{figure}\nIn the second approximation method, we sample the likelihood function\nat many points, then resample based on the propensity of those choices\nand their likelihood, and finally compute aggregate statistics (means\nand covariance matrix) on the resampled parameters, as well as highest\nprobability density credibility intervals. We also have two methods\nfor generating our samples: the first samples from a normal distribution\naround the MLE with corresponding propensities coming from the multivariate\nnorm probability density function (PDF), and the second employs the\nrandom walk Markov chain Monte Carlo Metropolis-Hastings algorithm\\cite{metropolois-hastings}\nwith constant propensity, since the resulting distribution should\nmatch the underlying probability density directly. This likelihood\nfunction is calculated as the product of the PDF of norms centered\nat each observed data point ($N$), with standard deviation $\\sqrt{N}$,\nevaluated at the values returned by our simulation. From these samples,\nwe then re-sample based on the likelihood values (normalized to one\nover all samples) multiplied by their inverse propensities, and run\naggregate statistics on the resampled points to create a multivariate\nnorm (MVN) distribution that is representative of our data. In Figure\n\\ref{fig:US-MVN-approx}, we show the predicted and actual values\nof the likelihood for U.S. totals and show that the MVN and MCMC approximations\ndemonstrate reasonable accuracy. Moreover, adding the additional parameters\nby going from a diagonal to a full covariance matrix further improves\nthe fit. In Figure \\ref{fig:US-MVN-approx-correlation-matrix}, we\nshow the full correlation matrix for the model parameters. We see\nthat $\\alpha_{1}$ is strongly correlated with the two delays, which\nwill explain deviation from the bootstrap approximation in subsequent\nanalysis.\n\nBoth approximation methods contribute hyperparameters to our models:\nthe number of bootstraps (100), the number of likelihood samples (20k),\nthe number of likelihood re-samples (20k), the number of MCMC samples\n(16k), and the number of burn-in (discarded) MCMC samples (4k).\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_1000_bootstraps_100000_likelihood_samples/total/bootstrap_param_distro_with_priors}\n\n\\caption{\\label{fig:US-params}Model Parameter Estimates for U.S. totals after\nincorporating priors}\n\\end{figure}\nOnce the likelihood distribution has been approximated, according\nto Bayes theorem,\n\n\\[\n\\text{posterior}\\propto\\text{likelihood}\\times\\text{prior}\n\\]\nincorporating priors on our parameters is as easy as multiplying the\ntwo functions element-wise and normalizing a posteriori. In Figure\n\\ref{fig:US-params}, we show the full likelihood approximation (or,\nequivalently, the posterior with uniform priors), and discuss the\nphysicality of parts of the distributions, which the reader can either\nincorporate or discount based on their intuition. Updates to the distributions\nof all parameters based on assumed priors can be obtained by weighted\nsampling of the bootstraps according to those individual priors on\neach parameter, since, for example, ruling out overly long delays\nbetween becoming contagious and being confirmed positive will also\nrule out other parameter distributions, such as overly long variances\nin the delay. We employ the following priors, using uniform distributions\n(so their shapes don\\textquoteright t affect the posterior distribution)\nwith the following bounds: \n\\begin{itemize}\n\\item 0 < $\\alpha_{1}$< 1.0 \n\\item -0.5 < $\\alpha_{2}$ < 0.5 \n\\item 0 < contagious-to-positive delay < 20 \n\\item 5 < contagious-to-deceased delay < 40\n\\item 0 < contagious-to-deceased multiplier < 0.1\n\\end{itemize}\nNote that if we rely on using our priors to filter out undesirable\nsolutions, we can waste a substantial amount of computational resources\nproducing undesirable candidates in our approximations which we only\nlater discard. Worse, it is possible to create unphysical results\nwith our simulations, and these unphysical results can be reached\nthrough the optimization methods we employ even when they start with\nvalid parameters. In particular, unphysical results occur when the\nparameters can produce negative numbers of confirmed cases and deaths,\nand when the parameters give a later contagious-to-positive than contagious-to-deceased\ndelay. To avoid computing such solutions, we add a term to our loss\nfunction which sums the negative value of all predicted values that\nare below zero, and another term which provides the difference between\nthe contagious-to-positive and contagious-to-deceased delays when\nthe former is larger than the latter. These loss functions have a\nzero derivative when parameters are valid and push parameters back\nto the valid range when they are invalid, thus avoiding skewing our\nresults while enforcing physicality. The remaining contributors to\nthe loss function remain the same, however we only contribute terms\nwhen the simulation provides positive counts, since the loss function\nis based on distances from the log results of our simulations, which\nis undefined for negative values. \n\n\\section{Results}\n\nExamining the parameter estimates in Figures \\ref{fig:US-params},\n\\ref{fig:NY-params}, and \\ref{fig:Cali-params}, we see that California\nshows a much greater response delay to the shelter-in-place order\nthan in New York (March 19th and 20th, respectively) at 12 days compared\nto 4.2 days (with U.S. totals in the middle at 9.2 days). In addition,\nthe relative ordering of the original growth rates (California = 22.7\\%\n< U.S. = 27.8\\% < New York = 36.9\\%) reflect the strong population\ndensity in New York. However, this ordering is reversed in the final\ngrowth rates (New York = +0.435\\% < California = 1.01\\% == U.S. =\n1.01\\%) suggesting that New York has dramatically reduced spread.\n\nAll three datasets show a similar relative delay between being a case\nbeing positively confirmed and a resulting death at approximately\none week (7-8 days). When looking at the relative multiplier between\nthe positive and deceased numbers, which acts as an analog to the\ncase fatality rate, we find that California's estimates are much lower\n(4.7\\% for California vs. 6.21\\% for the U.S. and 6.45\\% for New York).\nIf tests are limited and reserved only for the most severely ill,\nwe would expect the relative multiplier to increase, suggesting that\nNew York and the U.S. may be capping testing more severely than California. \n\nIn Figures \\ref{fig:State-Report-Alpha-2} and \\ref{fig:State-Report-CFR}\nwe provide results for all 50 states, Washington D.C., and U.S. totals\nfor the final growth rate and the relative multiplier between the\npositive and deceased pools, and for both the bootstrapping and MCMC\napproximations. We find agreement between the two approximations in\nmost cases, and see a wide disparity among the different regions,\nwhich the reader is encouraged to interpret.\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_100_bootstraps_100000_likelihood_samples/boxplot_for_alpha_2_without_direct_samples}\n\n\\caption{\\label{fig:State-Report-Alpha-2}Model parameter estimates for $\\alpha_{2}$\n(the current growth rate of COVID-19) for each of 50 U.S. states,\nWashington D.C., and U.S. totals with 5\\%, 25\\%, 50\\%, 75\\%, and 95\\%\npercentiles, ranked from highest to lowest median, and shown with\nboth the bootstrap and the MCMC approximations. We find that both\napproximation methods agree with each other. We see strongest growth\nin Nebraska, Minnesota, and Iowa, and lowest growth in Alaska, Montana,\nand Hawaii.}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_100_bootstraps_100000_likelihood_samples/boxplot_for_positive_to_deceased_mult_without_direct_samples}\n\n\\caption{\\label{fig:State-Report-CFR}Model parameter estimates for the positive-to-deceased\nmultiplier, which is an analog to the case fatality rate and an indicator\nof testing restrictions when the value is high. We provide results\nfor each of 50 U.S. states, Washington D.C., and U.S. totals with\n5\\%, 25\\%, 50\\%, 75\\%, and 95\\% percentiles, ranked from highest to\nlowest median, and shown with both the bootstrap and the MCMC approximations.\nWe find that the bootstrap method gives us larger variances, and fails\nto find variance for states with very low death counts (Wyoming, Alaska,\nMontana, and Hawaii) and only returns the initial value (10\\%). Overall,\nwe see a strong skew towards East Coast states with higher estimations. }\n\\end{figure}\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_1000_bootstraps_100000_likelihood_samples/new_york/bootstrap_param_distro_with_priors}\n\n\\caption{\\label{fig:NY-params}Model Parameter Estimates for New York after\nincorporating priors}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[width=1\\textwidth]{state_plots/2020_05_06_date_1000_bootstraps_100000_likelihood_samples/california/bootstrap_param_distro_without_priors}\n\n\\caption{\\label{fig:Cali-params}Model Parameter Estimates for California after\nincorporating priors}\n\\end{figure}\n\n\\bibliographystyle{plain}\n\\bibliography{covid_biblio}\n\n\\end{document}\n", "meta": {"hexsha": "dab884d51612cbc3c3284632c021460b1b13ab81", "size": 25514, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "covid.tex", "max_stars_repo_name": "Nexus-iR-D-Laboratory/bayes_covid_model", "max_stars_repo_head_hexsha": "a79236d43f1e043a9717182ce5d6cd8d34f83acf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-06-02T17:35:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-09T01:47:49.000Z", "max_issues_repo_path": "covid.tex", "max_issues_repo_name": "Nexus-iR-D-Laboratory/bayes_covid_model", "max_issues_repo_head_hexsha": "a79236d43f1e043a9717182ce5d6cd8d34f83acf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-06-02T12:13:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-02T12:13:23.000Z", "max_forks_repo_path": "covid.tex", "max_forks_repo_name": "Nexus-iR-D-Laboratory/bayes_covid_model", "max_forks_repo_head_hexsha": "a79236d43f1e043a9717182ce5d6cd8d34f83acf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-05-29T19:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-31T02:58:34.000Z", "avg_line_length": 53.4884696017, "max_line_length": 166, "alphanum_fraction": 0.8062240339, "num_tokens": 5954, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.40084487069778074}}
{"text": "\\documentclass[nofootinbib,notitlepage,11pt]{revtex4-2}\n\n%%% linking references\n\\usepackage{hyperref}\n\\hypersetup{\n  breaklinks=true,\n  colorlinks=true,\n  linkcolor=blue,\n  filecolor=magenta,\n  urlcolor=cyan,\n}\n\n%%% header / footer\n\\usepackage{fancyhdr} % easier header and footer management\n\\pagestyle{fancy} % page formatting style\n\\fancyhf{} % clear all header and footer text\n\\renewcommand{\\headrulewidth}{0pt} % remove horizontal line in header\n\\usepackage{lastpage} % for referencing last page\n\\cfoot{\\thepage~of \\pageref{LastPage}} % \"x of y\" page labeling\n\n\n%%% symbols, notations, etc.\n\\usepackage{physics,braket,bm,amssymb} % physics and math\n\\renewcommand{\\t}{\\text} % text in math mode\n\\newcommand{\\f}[2]{\\dfrac{#1}{#2}} % shorthand for fractions\n\\newcommand{\\p}[1]{\\left(#1\\right)} % parenthesis\n\\renewcommand{\\sp}[1]{\\left[#1\\right]} % square parenthesis\n\\renewcommand{\\set}[1]{\\left\\{#1\\right\\}} % curly parenthesis\n\\newcommand{\\bk}{\\Braket} % shorthand for braket notation\n\\renewcommand{\\v}{\\bm} % bold vectors\n\\newcommand{\\uv}[1]{\\bm{\\hat{#1}}} % unit vectors\n\\newcommand{\\av}{\\vec} % arrow vectors\n\\renewcommand{\\d}{\\text{d}} % for infinitesimals\n\\renewcommand{\\c}{\\cdot} % inner product\n\n\\usepackage{dsfont} % for identity operator\n\\newcommand{\\1}{\\mathds{1}}\n\n\\newcommand{\\up}{\\uparrow}\n\\newcommand{\\dn}{\\downarrow}\n\n\\newcommand{\\x}{\\text{x}}\n\\newcommand{\\y}{\\text{y}}\n\\newcommand{\\z}{\\text{z}}\n\n\\newcommand{\\B}{\\mathcal{B}}\n\\newcommand{\\D}{\\mathcal{D}}\n\\newcommand{\\E}{\\mathcal{E}}\n\\renewcommand{\\H}{\\mathcal{H}}\n\\newcommand{\\I}{\\mathcal{I}}\n\\newcommand{\\J}{\\mathcal{J}}\n\\newcommand{\\M}{\\mathcal{M}}\n\\newcommand{\\N}{\\mathcal{N}}\n\\renewcommand{\\O}{\\mathcal{O}}\n\\renewcommand{\\P}{\\mathcal{P}}\n\\newcommand{\\Q}{\\mathcal{Q}}\n\\newcommand{\\R}{\\mathcal{R}}\n\\newcommand{\\T}{\\mathcal{T}}\n\\renewcommand{\\S}{\\mathcal{S}}\n\\newcommand{\\V}{\\mathcal{V}}\n\\newcommand{\\X}{\\mathcal{X}}\n\\newcommand{\\Z}{\\mathcal{Z}}\n\n\\newcommand{\\EE}{\\mathbb{E}}\n\\renewcommand{\\SS}{\\mathbb{S}}\n\\newcommand{\\ZZ}{\\mathbb{Z}}\n\n\\newcommand{\\PS}{\\text{PS}}\n\\newcommand{\\col}{\\underline}\n\n\\DeclareMathOperator{\\sign}{sign}\n\\DeclareMathOperator{\\cov}{cov}\n\\let\\var\\relax\n\\DeclareMathOperator{\\var}{var}\n\\DeclareMathOperator{\\even}{even}\n\n\\def\\obra#1{\\mathinner{({#1}|}}\n\\def\\oket#1{\\mathinner{|{#1})}}\n\\def\\obk#1{\\mathinner{({#1})}}\n\\def\\oop#1#2{\\oket{#1}\\!\\obra{#2}}\n\n\\usepackage[inline]{enumitem} % in-line lists and \\setlist{} (below)\n\\setlist[enumerate,1]{label={(\\roman*)}} % default in-line numbering\n\\setlist{nolistsep} % more compact spacing between environments\n\n%%% text markup\n\\usepackage{color} % text color\n\\newcommand{\\red}[1]{{\\color{red} #1}}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{document}\n\\thispagestyle{fancy}\n\n\\title{Multilevel generalizations of collective spin dynamics and\n  squeezing}%\n\\author{Michael A. Perlin}%\n\\date{\\today}\n\n\\maketitle\n\n\\tableofcontents\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Collective SU($n$)-symmetric interactions}\n\\label{sec:int}\n\nWe consider a collection of $n$-level fermions on a 1-D lattice, with\na single-particle Hamiltonian\n\\begin{align}\n  H_{\\t{lat}} = -t \\sum_{q,\\mu} \\cos\\p{qa} c_{q\\mu}^\\dag c_{q\\mu},\n  \\label{eq:H_lat}\n\\end{align}\nwhere $t$ is the nearest-neighbor tunneling rate, $a$ is the spacing\nbetween neighboring lattice sites, and $c_{q\\mu}$ is the fermionic\nannihilation operator for a particle in quasi-momentum mode $q$ with\ninternal state (e.g.~nuclear spin) $\\mu$.  Under the frozen-mode\napproximation, collective two-body SU($n$)-symmetric interactions\nbetween these fermions take form\n\\begin{align}\n  H_{\\t{int}} = \\f{u}{2} \\sum_{p,q,\\mu,\\nu}\n  \\p{c_{p\\mu}^\\dag c_{q\\nu}^\\dag c_{q\\nu} c_{p\\mu}\n    + c_{q\\mu}^\\dag c_{p\\nu}^\\dag c_{q\\nu} c_{p\\mu}},\n\\end{align}\nwhere $u\\equiv fU/N$ with $U$ the two-body on-site interaction energy,\n$f$ the filling fraction of lattice sites, and $N$ the total number of\nfermions.  Defining the spin operators\n$S_{\\mu\\nu}^{(p)}\\equiv c_{p\\mu}^\\dag c_{p\\nu}$ for each\nquasi-momentum $p$, we can alternately write\n\\begin{align}\n  H_{\\t{int}} = \\f{u}{2} \\sum_{p,q,\\mu,\\nu}\n  \\p{S_{\\mu\\mu}^{(p)} S_{\\nu\\nu}^{(q)} - S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}}\n  = \\f{u}{2}\\p{N^2 - \\sum_{p,q,\\mu,\\nu}\n    S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}},\n\\end{align}\nwhere $N$ is the total number of particles.  In the absence of\ncoherence between sectors of different particle number, we can neglect\nthe $\\sim N^2$ term and simply write\n\\begin{align}\n  H_{\\t{int}}\n  = - \\f{u}{2} \\sum_{p,q,\\mu,\\nu} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}.\n\\end{align}\nIn the case of SU(2), at this point we would expand the spin operators\n$S_{\\mu\\nu}^{(p)}$ in terms of Pauli operators in order to convert\n$H_{\\t{int}}$ into an SU(2) spin Hamiltonian \\cite{he2019engineering}.\nTo generalize this procedure to the case of SU($n$), we first define a\nvector $\\v S^{(p)}$ of all spin operators $S_{\\mu\\nu}^{(p)}$, and\nwrite\n\\begin{align}\n  H_{\\t{int}}\n  = - \\f{u}{2} \\sum_{p,q} {\\v S^{(p)}}^\\dag \\c \\v S^{(q)}\n  = - \\f{u}{2} \\v\\S^\\dag \\c \\v\\S,\n  &&\n  \\v\\S\\equiv \\sum_p \\v S^{(p)}.\n  \\label{eq:H_int_spin}\n\\end{align}\nIn the bulk of this section, we identify various bases for the space\nof linear operators on the Hilbert space $\\H_n$ of an $n$-level\nsystem.  For brevity, we denote this space of operators by\n$\\B\\p{\\H_n}$, and note that $\\B\\p{\\H_n}$ is itself an\n$n^2$-dimensional Hilbert space equipped with a trace\n(Hilbert-Schmidt) inner product\n\\begin{align}\n  \\obk{\\O|\\Q} \\equiv \\tr\\p{\\O^\\dag Q},\n\\end{align}\nwhere $\\oket{\\Q}$ and $\\obra{\\O}$ respectively denote vectors in\n$\\B\\p{\\H_n}$ and its dual space $\\B\\p{\\H_n}^*$.  Similarly to the set\nof all spin operators $S_{\\mu\\nu}\\equiv\\op{\\mu}{\\nu}$ on the\nsingle-particle Hilbert space at each quasi-momentum, all of the bases\nwe consider will be orthonormal with respect to the trace inner\nproduct.  As we show in Appendix \\ref{sec:changing_bases}, the\ncollective SU($n$)-symmetric interaction Hamiltonian in\n\\eqref{eq:H_int_spin} takes an identical form in any orthonormal basis\nfor $\\B\\p{\\H_n}$.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Generalized Gell-Mann (GGM) operators}\n\\label{sec:ggm_ops}\n\nThe most obvious generalization of Pauli operators to the case of\nSU($n$) are the {\\it generalized Gell-Mann (GGM) operators}\n\\cite{hioe1981level, bertlmann2008bloch}, defined for\n$j,k,\\ell\\in\\set{0,1,\\cdots,n-1}$ with $j<k$ and $\\ell>0$ by\n\\begin{align}\n  \\lambda_0 \\equiv \\sqrt{\\f{2}{n}}~ \\1,\n  &&\n  \\lambda_\\ell \\equiv \\sqrt{\\f{2}{\\ell\\p{\\ell+1}}}\n  \\p{\\sum_{n=0}^{\\ell-1}\\op{n} - \\ell \\op{\\ell}},\n  \\label{eq:GGM_diag}\n\\end{align}\n\\begin{align}\n  \\lambda_{jk,\\x} \\equiv \\op{j}{k} + \\op{k}{j},\n  &&\n  \\lambda_{jk,\\y} \\equiv i\\p{\\op{j}{k} - \\op{k}{j}},\n  \\label{eq:GGM_off_diag}\n\\end{align}\nwhere $\\1$ is the identity operator.  The self-adjoint GGM operators\nin \\eqref{eq:GGM_diag} and \\eqref{eq:GGM_off_diag} provide a complete\nbasis for the space of operators on the Hilbert space $\\H_n$ of an\n$n$-level system, coincide exactly with the Pauli operators in the\ncase of $n=2$, and satisfy the orthonormality condition\n\\begin{align}\n  \\obk{\\lambda_a|\\lambda_b} = 2\\delta_{ab},\n  \\label{eq:GGM_inner}\n\\end{align}\nwhere $a,b$ index any GGM operator in \\eqref{eq:GGM_diag} or\n\\eqref{eq:GGM_off_diag}.  Denoting a vector of all GGM operators by\n$\\v\\lambda$, we can therefore write (see Appendix\n\\ref{sec:changing_bases})\n\\begin{align}\n  H_{\\t{int}}\n  = -\\f{u}{4} \\sum_{p,q} \\v\\lambda^{(p)} \\c \\v\\lambda^{(q)}\n  = -\\f{u}{4} \\v\\Lambda \\c \\v\\Lambda,\n  &&\n  \\v\\Lambda \\equiv \\sum_p \\v\\lambda^{(p)}.\n  \\label{eq:H_int_GGM}\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Transition operators}\n\\label{sec:trans_ops}\n\nThe GGM operators in \\eqref{eq:GGM_diag} and \\eqref{eq:GGM_off_diag}\nprovide a convenient operator basis to describe dynamics obeying\nSU($n$) symmetry.  An external driving field addressing $n$-level\nnuclear spins, however, will generally violate SU($n$) symmetry, and\ninstead obeys the symmetries of the {\\it polarization} or {\\it\n  transition operators} defined by \\cite{kryszewski2006alternative,\n  bertlmann2008bloch}\n\\begin{align}\n  T_{LM}\n  \\equiv \\sqrt{\\f{2L+1}{2I+1}} \\sum_{\\mu,\\nu}\n  \\bk{I\\mu;LM|I\\nu} \\op{\\nu}{\\mu},\n  \\label{eq:trans_ops}\n\\end{align}\nwhere $L\\in\\set{0,1,\\cdots,n-1}$ and $M\\in\\set{-L,-L+1,\\cdots,L}$\nindex a total spin and its projection onto a quantization axis;\n$I\\equiv\\p{n-1}/2$ is the maximal angular momentum of an $n$-level\nspin; $\\mu,\\nu\\in\\set{-I,-I+1,\\cdots,I}$ index projections of an\n$n$-level nuclear spin onto a quantization axis; and\n$\\bk{I\\mu;LM|I\\nu}$ is a Clebsch-Gordan coefficient.  The transition\noperator $T_{LM}$ is closely related to the associated Legendre\npolynomial $P_{LM}\\p{x}$ for $x\\in\\sp{-1,1}$.  Operationally, $T_{LM}$\nis proportional to the transition induced on a nuclear spin by the\nabsorption of a spin-$L$ boson with spin projection $M$ onto a\nquantization axis.\n\nSimilarly to the GGM operators in \\eqref{eq:GGM_diag} and\n\\eqref{eq:GGM_off_diag}, the transition operators in\n\\eqref{eq:trans_ops} provide a complete basis for the space of\noperators on the Hilbert space $\\H_n$ of an $n$-level system, and\nsatisfy the orthonormality condition\n\\begin{align}\n  \\obk{T_{LM}|T_{L'M'}} = \\delta_{LL'} \\delta_{MM'},\n\\end{align}\nwhich implies\n\\begin{align}\n  H_{\\t{int}} = -\\f{u}{2} \\sum_{p,q} {\\v T^{(p)}}^\\dag \\c \\v T^{(q)}\n  = -\\f{u}{2} \\v\\T^\\dag \\c \\v\\T,\n  &&\n  \\v\\T \\equiv \\sum_p\\v T^{(p)},\n  \\label{eq:H_int_trans}\n\\end{align}\nwhere $\\v T$ is a vector of all transition operators in\n\\eqref{eq:trans_ops}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Drive operators}\n\\label{sec:drive_ops}\n\nUnlike the GGM operators in \\eqref{eq:GGM_diag} and\n\\eqref{eq:GGM_off_diag}, the transition operators in\n\\eqref{eq:trans_ops} are not self-adjoint.  In order to express\nHamiltonians in terms of self-adjoint operators, we define the {\\it\n  drive operators}\n\\begin{align}\n  D_{LM} \\equiv \\f{\\eta_M}{\\sqrt{2}}\n  \\sp{T_{LM} + \\sign\\p{M} T_{LM}^\\dag},\n  &&\n  \\eta_M \\equiv\n  \\begin{cases}\n    \\sqrt{2} & M = 0 \\\\\n    \\p{-1}^M & M > 0 \\\\\n    i & M < 0\n  \\end{cases},\n  \\label{eq:drive_ops}\n\\end{align}\nfor integer $M$ with $\\abs{M}\\le L$.  The drive operator $D_{LM}$ is\nproportional to the Hamiltonian induced on a nuclear spin by an\nexternal classical field of spin-$L$ particles with spin projection\n$M$ onto a quantization axis.  Similarly to the GGM operators in\n\\eqref{eq:GGM_diag} and \\eqref{eq:GGM_off_diag}, the drive operators\nare proportional to the Pauli operators in the case of $n=2$, and\nsatisfy the orthonormality condition\n\\begin{align}\n  \\obk{D_{LM}|D_{L'M'}} = \\delta_{LL'}\\delta_{MM'},\n\\end{align}\nwhich implies\n\\begin{align}\n  H_{\\t{int}} = -\\f{u}{2} \\sum_{p,q} \\v D^{(p)}\\c\\v D^{(q)}\n  = -\\f{u}{2} \\v\\D \\c \\v\\D,\n  &&\n  \\v\\D \\equiv \\sum_p \\v D^{(p)},\n  \\label{eq:H_int_drive}\n\\end{align}\nwhere $\\v D$ is a vector of all drive operators in\n\\eqref{eq:drive_ops}.\n\nThe drive operators $D_{1,0}$ and $D_{1,\\pm1}$ are proportional to the\nHamiltonians induced on an $n$-level spin by an external magnetic\nfield and a classical spin-polarized driving laser; loosely speaking,\none can associate\n$\\p{D_{1,0},D_{1,1},D_{1,-1}}\\sim\\p{S_\\z,S_\\x,S_\\y}$, where $S_\\alpha$\nis a collective SU(2) spin-$\\alpha$ operator for $\\p{n-1}$ 2-level\nspins \\cite{perlin2020shorttime}.  More concretely, we can embed the\nHilbert space of a single $n$-level spin into the\npermutationally-symmetric (Dicke) manifold of states for $\\p{n-1}$\n2-level spins via\n\\begin{align}\n  \\ket{\\mu}_{\\t{single}} \\to \\ket{I+\\mu}_{\\t{collective}}\n  \\propto S_+^{I+\\mu} \\ket\\dn^{\\otimes\\p{n-1}},\n  \\label{eq:collective_embedding}\n\\end{align}\nwhere $I\\equiv\\p{n-1}/2$ is a total spin,\n$\\mu\\in\\set{-I,-I+1,\\cdots,I}$ indexes a state of the single $n$-level\nspin, and $S_+$ is a collective spin-raising operator for $\\p{n-1}$\n2-level spins.  This embedding takes\n\\begin{align}\n  \\xi_1 \\times \\p{D_{1,0}, D_{1,1}, D_{1,-1}}\n  \\to \\p{S_\\z, S_\\x, S_\\y},\n  \\label{eq:spin_ops}\n\\end{align}\nwhere\n\\begin{align}\n  \\xi_L\n  \\equiv \\sqrt{2L+1}\\, \\f{L!}{\\p{2L+1}!}\n  \\sp{\\prod_{\\ell=-L}^L\\p{n+\\ell}}^{1/2},\n  \\label{eq:scale_fac}\n\\end{align}\nis a scale factor that will appear frequently in the theory of drive\noperators.  Some other useful relations between drive and spin\noperators are\n\\begin{align}\n  \\xi_2 D_{2,0} \\to -\\f12\\p{S_\\x^2 + S_\\y^2} + \\f{n^2-1}{12},\n  \\label{eq:spin_ops_2_0}\n\\end{align}\n\\begin{align}\n  \\sqrt{3}\\, \\xi_2 D_{2,2} \\to \\f12\\p{S_\\x^2 - S_\\y^2},\n  &&\n  \\sqrt{3}\\, \\xi_2 D_{2,1} \\to \\f12\\p{S_\\z S_\\x + S_\\x S_\\z}.\n  \\label{eq:spin_ops_2_12}\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Weyl operators}\n\nWeyl operators \\cite{bertlmann2008bloch} and self-adjoint linear\ncombinations thereof \\cite{asadian2016heisenbergweyl} also provide an\ninteresting basis of operators for finite-dimensional Hilbert spaces.\nThese operators are related to the notions of position, momentum, and\nphase-space displacement in a discrete space.  As our present work is\nmotivated by multilevel systems that are realized with nuclear spin\n(angular momentum) degrees of freedom, however, the transition and\ndrive operators are more natural to use than the Weyl operators, so we\nwill not discuss Weyl operators any further.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Subsystem permutations and the permutationally symmetric\n  manifold}\n\\label{sec:perm_ops}\n\nFor our final re-expression of collective SU($n$)-symmetric\ninteractions, we abandon the use of single-spin operators entirely to\nexpress the interaction Hamiltonian $H_{\\t{int}}$ in terms of\noperators that permute tensor factors (subsystems) of a Hilbert space\nwith an $N$-fold tensor product structure (e.g.~an array of nuclear\nspins).  Specifically, we denote the Hilbert space of an $n$-level\nsystem by $\\H_n$, denote its $N$-fold tensor product by\n$\\H_n^{\\otimes N}$, and identify the set $\\Pi\\equiv\\set{\\Pi_s}$ of\noperators that permute tensor factors of $\\H_n^{\\otimes N}$ according\nto elements $s\\in\\SS_N$ of the symmetric group of order $N$.  We then\nexpand\n\\begin{align}\n  H_{\\t{int}}\n  = -\\f{u}{2} \\sum_{p,q,\\mu,\\nu} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}\n  = -u\\sum_{\\substack{p<q\\\\\\mu,\\nu}} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}\n  - \\f{u}{2} \\sum_{p,\\mu,\\nu} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(p)},\n  \\label{eq:H_int_perm_start}\n\\end{align}\nwhere the first sum,\n\\begin{align}\n  \\sum_{\\substack{p<q\\\\\\mu,\\nu}} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(q)}\n  = \\sum_{\\substack{p<q\\\\\\mu,\\nu}} \\op{\\mu}{\\nu}^{(p)} \\op{\\nu}{\\mu}^{(q)}\n  = \\sum_{\\substack{p<q\\\\\\mu,\\nu}} \\op{\\mu\\nu}{\\nu\\mu}^{(p,q)}\n  = \\sum_{p<q} \\Pi_{pq}\n  \\label{eq:spin_perm}\n\\end{align}\nis simply a sum over all permutations $\\Pi_{pq}$ of subsystems $p$ and\n$q$; and the second sum,\n\\begin{align}\n  \\sum_{p,\\mu,\\nu} S_{\\mu\\nu}^{(p)} S_{\\nu\\mu}^{(p)}\n  = \\sum_{p,\\mu,\\nu} \\op{\\mu}{\\nu}^{(p)} \\op{\\nu}{\\mu}^{(p)}\n  = n \\sum_{p,\\mu} \\op{\\mu}{\\mu}^{(p)}\n  = n \\sum_p \\1^{(p)}\n  = n N,\n  \\label{eq:spin_const}\n\\end{align}\nis merely a constant.  Substituting \\eqref{eq:spin_perm} and\n\\eqref{eq:spin_const} into \\eqref{eq:H_int_perm_start} yields\n\\begin{align}\n  H_{\\t{int}} = -u \\sum_{p<q} \\Pi_{pq} - \\f12 N n u\n  \\simeq -u\\sum_{p<q} \\Pi_{pq},\n  \\label{eq:H_int_perm}\n\\end{align}\nwhere $\\simeq$ denotes equality up to an overall constant with no\nphysical consequence.  The form of the interaction Hamiltonian\n$H_{\\t{int}}$ makes it evident that its ground-state manifold\n$\\M_{\\PS}$ is the set of {\\it permutationally symmetric} (PS) states\nthat have eigenvalue 1 with respect to all pairwise permutation\noperators $\\Pi_{pq}$.  The PS manifold $\\M_\\PS$ is spanned by a basis\n$\\set{\\ket{\\v m}}$ of PS states that can be uniquely identified by a\nlist of integers $\\v m\\equiv\\p{m_0,m_1,\\cdots,m_{n-1}}\\in\\ZZ_{N+1}^n$,\nwhere $m_s$ indicates the total occupation number of subsystem state\n$s$, and $\\sum_sm_s=N$.  In the case of $n=2$, the PS manifold\n$\\M_\\PS$ is precisely the Dicke manifold \\cite{dicke1954coherence} of\n$N$ qubits, spanned by Dicke states $\\set{\\ket{m_0,m_1}}$ for which\n$m_0+m_1=N$ and the integer $m_0$ ($m_1$) indicates the total\noccupation number of qubit state $\\ket{0}$ ($\\ket{1}$).  The dimension\nof PS manifold $\\M_\\PS$ is determined by the number of ways to assign\n$N$ subsystems to $n$ states, which is ${N+n-1 \\choose n-1}$.  The\nenergy of any PS state $\\ket{\\psi_\\PS}\\in\\M_\\PS$ with respect to the\ninteraction Hamiltonian $H_{\\t{int}}$ in \\eqref{eq:H_int_perm} is\n$-u{N \\choose 2}=-\\p{1/2}N\\p{N-1}u$.\n\nIn addition to the fact that the PS manifold $\\M_\\PS$ is ground-state\nmanifold of the interaction Hamltonian $H_{\\t{int}}$, an important\nfeature of $\\M_\\PS$ is its closure under the action of collective\noperators of the form $\\Q=\\sum_pQ^{(p)}$, as well as linear\ncombinations and products thereof.  Closure of $\\M_\\PS$ under\ncollective the action of collective operators, and in particular under\ncollective dynamics, is a straightforward consequence of the\npermutational symmetry obeyed by these operators.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{External drive and spin-orbit coupling}\n\\label{sec:drive_SOC}\n\nA driving laser addressing spin-1/2 fermions on a 1-D lattice will\ninduce the Hamiltonian\n\\begin{align}\n  \\left. H_{\\t{drive}}^{(\\phi)} \\right|_{n=2}\n  = \\f12 \\Omega \\sum_j\n  \\p{e^{i\\phi j} c_{j,\\up}^\\dag c_{j,\\dn}\n    + e^{-i\\phi j} c_{j,\\dn}^\\dag c_{j,\\up}},\n  \\label{eq:H_drive_2}\n\\end{align}\nwhere $\\Omega$ is a (real) driving amplitude, $j\\in\\mathbb{Z}$ indexes\na lattice site, and $\\phi$ is the relative phase of the drive between\nadjacent lattice sites.  The multilevel analogue of\n\\eqref{eq:H_drive_2} is\n\\begin{align}\n  H_{\\t{drive}}^{(\\phi)}\n  = -\\f12 \\tilde\\Omega \\sum_j \\p{e^{i\\phi j} T_{1,1}^{(j)}\n    + e^{-i\\phi j} T_{1,1}^{(j)\\dag}}\n  = \\Omega \\D_{1,1}^{(\\phi)},\n  &&\n  \\Omega \\equiv \\tilde \\Omega \\xi_1,\n  \\label{eq:H_drive}\n\\end{align}\nwhere we define the re-scaled driving amplitude $\\tilde\\Omega$ for\nconvenience, and\n\\begin{align}\n  \\D_{LM}^{(\\phi)}\n  \\equiv \\sum_j \\sp{\\cos\\p{M\\phi j} D_{LM}^{(j)}\n    - \\sin\\p{M\\phi j} D_{L,-M}^{(j)}},\n  \\label{eq:drive_rot}\n\\end{align}\nis an inhomogeneously rotated collective drive operator.  We can make\nthis drive spatially homogenous via the gauge transformation\n$c_{j\\mu}^\\dag \\to e^{-i\\mu\\phi j} c_{j\\mu}^\\dag$, which takes\n \\begin{align}\n   H_{\\t{drive}}^{(\\phi)} \\to H_{\\t{drive}} = \\Omega \\D_{1,1},\n   &&\n   \\D_{LM} \\equiv \\D_{LM}^{(0)} = \\sum_j D_{LM}^{(j)}.\n\\end{align}\nThe SU($n$) symmetry of collective interactions considered in this\nwork implies that the interaction Hamiltonian $H_{\\t{int}}$ in\n\\eqref{eq:H_int_perm} is unaffected by this gauge transformation.  The\nsingle-particle Hamiltonian $H_{\\t{lat}}$ in \\eqref{eq:H_lat},\nhowever, transforms as (see Appendix \\ref{sec:lat_drive})\n\\begin{align}\n  H_{\\t{lat}}\n  \\to H_{\\t{lat}}^{(\\phi)}\n  = -t \\sum_{q,\\mu} \\cos\\p{qa+\\mu\\phi} c_{q\\mu}^\\dag c_{q\\mu}\n  = \\sum_{q,L} B_L^{(\\phi,q)} D_{L,0}^{(q)},\n  \\label{eq:H_lat_SOC_B}\n\\end{align}\nwith effective inhomogeneous driving field amplitudes\n\\begin{align}\n  B_L^{(\\phi,q)} = -t w_L\\p{qa} A_L^{(\\phi)},\n  \\label{eq:B_L_phi}\n\\end{align}\nwhere\n\\begin{align}\n  w_L\\p{\\theta} \\equiv\n  \\begin{cases}\n    \\cos\\theta & L~\\t{even} \\\\\n    \\sin\\theta & L~\\t{odd}\n  \\end{cases},\n  &&\n  A_L^{(\\phi)} \\equiv \\p{-1}^L \\sqrt{\\f{2L+1}{2I+1}}\n  \\sum_\\mu \\bk{I\\mu;L,0|I\\mu} w_L\\p{\\mu\\phi}.\n  \\label{eq:A_L_phi}\n\\end{align}\nThe multilevel spin-orbit coupling (SOC) exhibited by the\nsinge-particle Hamiltonian $H_{\\t{lat}}^{(\\phi)}$ thus allows for the\nsimulation of synthetic gauge fields with large spin ($L>1$).  As we\nwill see in Section \\ref{sec:drive_raman}, multi-laser drives can also\nsimulate synthetic large-spin fields with non-zero spin projection\n($M\\ne0$) onto a quantization axis.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Perturbative treatment of spin-orbit coupling}\n\\label{sec:pert_SOC}\n\nThe single-particle Hamiltonian $H_{\\t{lat}}^{(\\phi)}$ breaks\npermutational symmetry, thereby coupling states within the PS manifold\n$\\M_\\PS$ to states outsides it.  If SOC is sufficiently weak, however,\ntransitions outside the PS manifold $\\M_\\PS$ are energetically\nsuppressed by interactions, and we can account for the effect of SOC\nperturbatively.  In the regime of weak SOC with $\\abs{\\phi}\\ll1$, by\nconsidering\n\\begin{enumerate*}\n\\item all $L\\le12$ for arbitrary $n$, and\n\\item all $L<n$ for all $n\\le25$\n\\end{enumerate*}\n(and conjecturing the same functional form for all $L$ and $n$), we\nfind that\n% expand Clebsch-Gordan coefficients in a power series according to\n% \\url{functions.wolfram.com/07.38.06.0008.01}\n\\begin{align}\n  A_L^{(\\phi)}\n  = \\p{-1}^{L+\\lfloor L/2\\rfloor} \\xi_L \\phi^L + O\\p{\\phi^{L+2}},\n  \\label{eq:A_L_phi_small}\n\\end{align}\nwhere $\\xi_L$ is a scale factor defined in \\eqref{eq:scale_fac}.  A\nperturbative treatment of SOC through second order in the SOC angle\n$\\phi$ yields the following effective Hamiltonian in the fully\nsymmetric manifold $\\M_\\PS$ (see Appendix \\ref{sec:SOC_pert}):\n\\begin{align}\n  H_{\\t{eff}} = H_{\\t{eff}}^{(1)} + H_{\\t{eff}}^{(2)},\n\\end{align}\n\\begin{align}\n  H_{\\t{eff}}^{(1)}\n  &= \\phi t \\, \\EE_p\\sp{\\sin\\p{pa}} \\xi_1 \\D_{1,0}\n  + \\phi^2 t \\, \\EE_q\\sp{\\cos\\p{qa}} \\xi_2 \\D_{2,0}\n  + O\\p{\\phi^3},\n  \\label{eq:H_eff_1_phi} \\\\\n  H_{\\t{eff}}^{(2)}\n  &= \\f{\\phi^2 t^2}{\\p{N-1}fU} \\var_q\\sp{\\sin\\p{qa}}\n  \\p{\\xi_1^2 \\D_{1,0}^2 - 2 N \\xi_2 \\D_{2,0}}\n  + O\\p{\\phi^3},\n  \\label{eq:H_eff_2_phi}\n\\end{align}\nwhere\n\\begin{align}\n  \\EE_q\\sp{X_q} \\equiv \\f1N \\sum_q X_q,\n  &&\n  \\var_q\\sp{X_q} \\equiv \\EE_q\\sp{\\p{X_q-\\EE_k\\sp{X_k}}}\n  = \\EE_q\\sp{X_q^2}-\\EE_k\\sp{X_k}^2,\n\\end{align}\nare the mean and variance of $X_q$ over all occupied quasi-momenta\n$q$.  In the case of SU(2), the effective Hamiltonians in\n\\eqref{eq:H_eff_1_phi} and \\eqref{eq:H_eff_2_phi} reduce to the\nspin-squeezing Hamiltonians derived in Ref.~\\cite{he2019engineering}.\nTo facilitate comparison, we note that in the case of SU(2) the\nre-scaled drive operator $\\xi_1\\D_{1,0}$ is precisely the collective\nspin-$z$ operator $S_\\z$ that appears in\nRef.~\\cite{he2019engineering}.  Furthermore, drive operators $D_{LM}$\nvanish when $L\\ge n$, so in the case of SU(2) the operator $\\D_{2,0}$\nhas no contribution to the effective Hamiltonians in\n\\eqref{eq:H_eff_1_phi} and \\eqref{eq:H_eff_2_phi}.\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Raman drive}\n\\label{sec:drive_raman}\n\nRather than coupling the states of a multilevel system directly with a single driving laser, as in Section \\ref{sec:drive_SOC}, we now consider coupling through an off-resonant Raman transition to a highly excited state.\nSpecifically, we consider a three-laser drive of the form\n\\begin{align}\n  H_{\\t{Raman,bare}}^{(\\phi)}\n  = \\sum_j \\sum_{m\\in\\set{1,0,-1}} \\Omega_m \\p{e^{i\\phi_m j}\n    T_{1,m}^{(j)} \\otimes \\op{\\up}{\\dn} + \\t{h.c.}}\n  + \\f{\\Delta}{2} \\1 \\otimes \\p{\\op{\\up} - \\op{\\dn}},\n  \\label{eq:raman_bare}\n\\end{align}\nwhere $j$ indexes a lattice site, $\\Omega_m$ is a (real) driving amplitude; $\\phi_m$ is the relative phase of drive $m$ between adjacent lattice sites; $\\op{r}{s}$ for $r,s\\in\\set{\\up,\\dn}$ is a pseudo-spin operator for the auxiliary degree of freedom that is off-resonantly addressed by the lasers; $\\Delta$ is a detuning of the lasers from the energy of an excited state; and $\\1$ is the identity operator.\nIf the detuning is large, $\\abs{\\Delta}\\gg\\abs{\\Omega_m}$, then at second order in perturbation theory the effective action of $H_{\\t{Raman,bare}}^{(\\phi)}$ within the $\\ket{\\dn}$-state manifold takes the form\n\\begin{align}\n  H_{\\t{Raman}}^{(\\phi)}\n  = \\sum_{\\tau\\in\\set{0,1,2}} H_{\\t{Raman},\\tau}^{(\\phi)}\n\\end{align}\nwhere $H_{\\t{Raman},\\tau}^{(\\phi)}$ generates nuclear spin transitions $\\mu\\to\\mu\\pm\\tau$:\n\\begin{align}\n  H_{\\t{Raman},0}^{(\\phi)}\n  &= -\\sum_j\\sum_m \\f{\\Omega_m^2}{\\Delta}\n  T_{1,m}^{(j)\\dag} T_{1,m}^{(j)},\n  \\label{eq:raman_0} \\\\\n  H_{\\t{Raman},1}^{(\\phi)}\n  &= -\\sum_j\\sum_{s\\in\\set{\\pm1}}\n  \\f{\\Omega_0\\Omega_s}{\\Delta} e^{i\\p{\\phi_s-\\phi_0} j}\n  T_{1,0}^{(j)\\dag} T_{1,s}^{(j)} + \\t{h.c.},\n  \\\\\n  H_{\\t{Raman},2}^{(\\phi)}\n  &= -\\sum_j\\sum_{s\\in\\set{\\pm1}}\n  \\f{\\Omega_+\\Omega_-}{\\Delta} e^{i\\p{\\phi_s-\\phi_{-s}}j}\n  T_{1,-s}^{(j)\\dag} T_{1,s}^{(j)}.\n  \\label{eq:raman_2}\n\\end{align}\nIn terms of the drive operators, we can expand\n\\begin{align}\n  H_{\\t{Raman}}^{(\\phi)}\n  = \\sum_j \\sum_{\\substack{L\\le2\\\\\\abs{M}\\le L}}\n  \\Omega_{LM}^{(\\phi,j)} D_{LM}^{(j)},\n  \\label{eq:raman_drive}\n\\end{align}\nwhere the coefficients $\\Omega_{LM}^{(\\phi,j)}$ are provided in Appendix \\ref{sec:drive_raman_coeff}.\nIf the driving lasers are phase-matched with $\\phi_m=m\\phi$, such that a nuclear spin transition $\\mu\\to\\mu+m$ on site $j$ imprints the phase $m\\phi j$, then the drive $H_{\\t{Raman}}^{(\\phi)}$ takes the form\n\\begin{align}\n  \\left. H_{\\t{Raman}}^{(\\phi)} \\right|_{\\phi_m=m\\phi}\n  = \\sum_{\\substack{L\\le2\\\\0\\le M\\le L}}\n  \\Omega_{LM} \\D_{LM}^{(\\phi)},\n  \\label{eq:drive_raman_matched}\n\\end{align}\nwith rotated collective drive operators $\\D_{LM}^{(\\phi)}$ defined in \\eqref{eq:drive_rot} and uniform driving amplitudes $\\Omega_{LM}$ provided in Appendix \\ref{sec:drive_raman_coeff}.\nSimilarly to the case of a direct drive considered in Section \\ref{sec:drive_SOC}, the Raman drive $H_{\\t{Raman}}^{(\\phi)}$ in \\eqref{eq:drive_raman_matched} can be made homogenous through the gauge transformation $c_{j\\mu}^\\dag \\to e^{-i\\mu\\phi j} c_{j\\mu}^\\dag$, which takes\n\\begin{align}\n  \\left. H_{\\t{Raman}}^{(\\phi)} \\right|_{\\phi_m=m\\phi}\n  \\to H_{\\t{Raman}}\n  = \\sum_{\\substack{L\\le2\\\\0\\le M\\le L}} \\Omega_{LM} \\D_{LM}.\n\\end{align}\nWriting $H_{\\t{Raman}} = \\sum_j H_{\\t{Raman}}^{\\t{single},j}$, where $H_{\\t{Raman}}^{\\t{single},j}$ denotes the action of $H_{\\t{Raman}}^{\\t{single}}$ on spin $j$, we can expand\n\\begin{align}\n  H_{\\t{Raman}}^{\\t{single}} \\times \\Delta\n  = h_+ h_- S_\\z + h_0 h_+ S_\\x\n  + h_0 h_- \\p{S_\\z S_\\x  + S_\\x S_\\z}\n  + \\p{h_0^2 - h_-^2} S_\\x^2 + \\p{h_0^2 - h_+^2} S_\\y^2,\n\\end{align}\nwhere $\\v S = \\p{S_\\z,S_\\x,S_\\y} \\equiv \\xi_1\\times\\p{D_{1,0},D_{1,1},D_{1,-1}}$ is the standard $\\mathfrak{su}(2)$ subalgebra of the operators on a single $n$-level spin, and\n\\begin{align}\n  h_0 \\equiv \\xi_1^{-1}\\, \\Omega_0,\n  &&\n  h_\\pm \\equiv \\xi_1^{-1}\\, \\f{\\Omega_+\\pm\\Omega_-}{\\sqrt{2}}.\n\\end{align}\nTuning the amplitudes $\\Omega_0,\\Omega_+,\\Omega_-$, or equivalently $h_0,h_+,h_-$, enables us to implement various drive Hamiltonians, several of which are shown in Table \\ref{tab:drives}.\n\n\\begin{table}\n  \\centering\n  \\caption{Drive Hamiltonians that can be implemented with various amplitude-matching conditions.}\n  \\begin{tabular}{c|c|c}\n    Condition & $\\p{h_0,h_+,h_-}/h$\n    & $H_{\\t{Raman}}^{\\t{single}}/\\p{h^2/\\Delta}$\n    \\\\ \\hline\\hline\n    $\\Omega_0=\\pm\\Omega_+=\\pm\\Omega_-$ & $\\p{1,\\pm\\sqrt{2},0}$\n    & $\\pm\\sqrt{2} S_\\x + \\p{S_\\x^2 - S_\\y^2}$\n    \\\\ \\hline\n    $\\Omega_0=\\pm\\Omega_+=\\mp\\Omega_-$ & $\\p{1,0,\\pm\\sqrt{2}}$\n    & $\\pm\\sqrt{2}\\p{S_\\z S_\\x + S_\\x S_\\z} - \\p{S_\\x^2-S_\\y^2}$\n    \\\\ \\hline\n    $\\Omega_0=\\Omega_\\mp=0$ & $\\p{0,1,\\pm1}$\n    & $\\pm S_\\z + S_\\z^2 - \\v S^2$\n    \\\\ \\hline\n    $\\sqrt{2}\\Omega_0=\\pm\\Omega_+=\\pm\\Omega_-$\n    & $\\p{1,\\pm1,0}$ & $\\pm S_\\x + S_\\x^2$\n    \\\\ \\hline\n    $\\sqrt{2}\\Omega_0=\\pm\\Omega_+=\\mp\\Omega_-$\n    & $\\p{1,0,\\pm1}$ & $\\pm\\p{S_\\z S_\\x+S_\\x S_\\z} + S_\\y^2$\n    \\\\ \\hline\n    $\\Omega_+=\\Omega_-=0$ & $\\p{1,0,0}$ & $-S_\\z^2 + \\v S^2$\n    \\\\ \\hline\n    $\\Omega_0=0$,  $\\Omega_+=+\\Omega_-$ & $\\p{0,1,0}$ & $-S_\\y^2$\n    \\\\ \\hline\n    $\\Omega_0=0$,  $\\Omega_+=-\\Omega_-$ & $\\p{0,0,1}$ & $-S_\\x^2$\n  \\end{tabular}\n  \\label{tab:drives}\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Periodic drive}\n\nWe now consider the effect of applying periodic drive of the form\n\\begin{align}\n  H_{\\t{pd}}\\p{t} = \\sum_p \\chi_p \\omega \\cos\\p{\\omega t} S_\\z^{(p)},\n\\end{align}\nwhere $\\omega$ is a driving frequency, $\\chi_p$ is a dimensionless\ndriving amplitude for spin $p$, and\n$S_\\z^{(p)} \\equiv \\xi_1 D_{1,0}^{(p)}$ with $\\xi_1$ defined in\n\\eqref{eq:scale_fac}.  The periodic drive $H_{\\t{pd}}\\p{t}$ can be\nimplemented directly using external magnetic fields or driving lasers.\nTransition operators $T_{LM}$ transform under rotations generated by\nthe drive operator $S_\\z$ as\n\\begin{align}\n  e^{i\\phi S_\\z} T_{LM} e^{-i\\phi S_\\z} = e^{iM\\phi} T_{LM}.\n\\end{align}\nIf we move into the rotating frame of the drive, then the interaction\nHamiltonian transforms as\n\\begin{align}\n  H_{\\t{int}} \\to \\tilde H_{\\t{int}}\n  \\equiv U_{\\t{pd}}\\p{t}^\\dag H_{\\t{int}} U_{\\t{pd}}\\p{t}\n\\end{align}\nwhere\n\\begin{align}\n  U_{\\t{pd}}\\p{t} \\equiv \\exp\\sp{-i\\int_0^td\\tau\\,H_{\\t{pd}}\\p{\\tau}}\n  = \\prod_p \\exp\\sp{-i \\chi_p \\sin\\p{\\omega t} S_\\z^{(p)}}.\n\\end{align}\nExpanding the interaction Hamiltonian $H_{\\t{int}}$ in terms of\ntransition operators $T_{LM}$, we find that\n\\begin{align}\n  \\tilde H_{\\t{int}}\n  = -\\f{u}{2} \\sum_{p,q,L,M} e^{iM\\p{\\chi_q-\\chi_p}\\sin\\p{\\omega t}}\n  T_{LM}^{(p)\\dag} T_{LM}^{(q)}\n  = -\\f{u}{2} \\sum_{p,q,L,M,n}\n  \\J_n\\p{M\\sp{\\chi_q-\\chi_p}} e^{in\\omega t}\n  T_{LM}^{(p)\\dag} T_{LM}^{(q)},\n\\end{align}\nwhere $\\J_n$ is the $n$-th order Bessel function of the first kind.\nIf the drive frequency $\\omega$ is much larger than the interaction\nstrength $u$, i.e.~$\\omega\\gg u$, then we can neglect oscillating\nterms with $n\\ne0$, arriving at\n\\begin{align}\n  \\tilde H_{\\t{int}} \\approx -\\f{u}{2} \\sum_{p,q,L,M}\n  \\J_0\\p{M\\sp{\\chi_q-\\chi_p}}\n  T_{LM}^{(p)\\dag} T_{LM}^{(q)}.\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Possible future directions}\n\n\\begin{itemize}\n\\item Visualization of multilevel states\n  \\begin{itemize}\n  \\item Single-particle eigenstates of drive operators\n  \\item Single-particle dynamics induced by drive operators\n  \\item Collective states and dynamics\n  \\end{itemize}\n\\item Implications of SOC\n  \\begin{itemize}\n  \\item Special angles $\\phi$?\n  \\end{itemize}\n\\item Different (more realistic / general) drives\n\\item Generalizations of squeezing beyond SU(2)?\n\\item Consider different interactions\n  \\begin{itemize}\n  \\item Include electronic states\n  \\item Super-exchange regime\n  \\item Non-uniform (local / disordered) interactions\n  \\end{itemize}\n\\end{itemize}\n\n\\appendix\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Changing operator bases for SU($n$)-symmetric interactions}\n\\label{sec:changing_bases}\n\nHere we show that the collective interaction Hamiltonian in\n\\eqref{eq:H_int_spin} takes an identical form in any orthonormal basis\nfor $\\B\\p{\\H_n}$, i.e.~the space of linear operators on the Hilbert\nspace $\\H_n$ of an $n$-level system, equipped with the trace\n(Hilbert-Schmidt) inner product\n\\begin{align}\n  \\obk{\\O|\\Q} \\equiv \\tr\\p{\\O^\\dag \\Q}.\n\\end{align}\nTo maintain generality, we choose an arbitrary basis\n$X\\equiv\\set{X_j}$ for $\\B\\p{\\H_n}$ that satisfies the orthonormality\ncondition\n\\begin{align}\n  \\obk{X_j|X_k} = \\N_X \\delta_{jk},\n\\end{align}\nfor $j\\in\\set{0,1,\\cdots,n^2-1}$.  This orthonormality condition\nimplies that we can resolve the identity (super-)operator $\\I$ with\n$\\I\\oket{\\O}=\\oket{\\O}$ for any $\\oket\\O\\in\\B\\p{\\H_n}$ as\n\\begin{align}\n  \\I = \\f1{\\N_X} \\sum_j \\oop{X_j}{X_j}\n  = \\f1{\\N_X} \\sum_j \\oop{X_j^\\dag}{X_j^\\dag},\n\\end{align}\nwhere we used the fact that $X^\\dag\\equiv\\set{X_j^\\dag}$ is also an\northonormal basis for $\\B\\p{\\H_n}$, satisfying the same orthonormality\ncondition as $X$; these two bases are transformed into each other by\nunitary $\\sum_j\\oop{X_j^\\dag}{X_j}/\\N_X$.\n\nThe collective interaction Hamiltonian in \\eqref{eq:H_int_spin} takes\nthe form\n\\begin{align}\n  H = \\sum_{p,q,j} X_j^{(p)} X_j^{(q)\\dag},\n\\end{align}\nwhich essentially consists of single-body terms ($p=q$) and two-body\ninteractions ($p\\ne q$) of the form\n\\begin{align}\n  \\sum_j X_j X_j^\\dag,\n  &&\n  \\sum_j X_j \\otimes X_j^\\dag.\n\\end{align}\nChoosing an arbitrary orthonormal basis $Y\\equiv\\set{Y_j}$ for\n$\\B\\p{\\H_n}$ with corresponding norm $\\N_Y$, we can expand\n\\begin{align}\n  X_j = \\f1{\\N_Y} \\sum_k Y_k \\obk{Y_k|X_j},\n  &&\n  X_j^\\dag = \\f1{\\N_Y} \\sum_k Y_k^\\dag \\obk{Y_k^\\dag|X_j^\\dag}\n  = \\f1{\\N_Y} \\sum_k Y_k^\\dag \\obk{X_j|Y_k},\n\\end{align}\nwhere we used the fact that\n\\begin{align}\n  \\obk{Y_k^\\dag|X_j^\\dag}\n  = \\tr\\p{Y_k X_j^\\dag}\n  = \\tr\\p{X_j^\\dag Y_k}\n  = \\obk{X_j|Y_k}.\n\\end{align}\nDenoting an arbitrary bilinear operation by $\\odot$, by resolution of\nthe identity we therefore find\n\\begin{align}\n  \\sum_j X_j \\odot X_j^\\dag\n  = \\f1{\\N_Y^2} \\sum_{j,k,\\ell} Y_k \\obk{Y_k|X_j}\n  \\odot Y_\\ell^\\dag \\obk{X_j|Y_\\ell}\n  = \\f{\\N_X}{\\N_Y^2} \\sum_{k,\\ell} Y_k \\odot Y_\\ell^\\dag\n  \\obk{Y_k|\\I|Y_\\ell}\n  = \\f{\\N_X}{\\N_Y} \\sum_k Y_k \\odot Y_k^\\dag,\n\\end{align}\nwhich in particular implies that\n\\begin{align}\n  \\sum_j X_j X_j^\\dag\n  = \\f{\\N_X}{\\N_Y} \\sum_k Y_k Y_k^\\dag,\n  &&\n  \\sum_j X_j \\otimes X_j^\\dag\n  = \\f{\\N_X}{\\N_Y} \\sum_k Y_k \\otimes Y_k^\\dag,\n\\end{align}\nand in turn\n\\begin{align}\n  H = \\f{\\N_X}{\\N_Y} \\sum_{p,q,j} Y_j^{(p)} {Y_j^{(q)}}^\\dag.\n\\end{align}\nThe collective interaction Hamiltonian in \\eqref{eq:H_int_spin} thus\ntakes an identical form in any orthonormal basis for the space\n$\\B\\p{\\H_n}$ of linear operators on the Hilbert space $\\H_n$ of an\n$n$-level system, up to appropriate rescaling factors $\\N_X/\\N_Y$.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Spin-orbit coupling with drive operators}\n\\label{sec:lat_drive}\n\nHere we derive the drive-operator ($D_{LM}$) expansion of the\nspin-orbit coupled Hamiltonian $H_{\\t{lat}}^{(\\phi)}$ in\n\\eqref{eq:H_lat_SOC_B}.  In the basis of spin operators\n$S_{\\mu\\mu}^{(q)} \\equiv c_{q\\mu}^\\dag c_{q\\mu}$, this Hamiltonian\ntakes the form\n\\begin{align}\n  H_{\\t{lat}}^{(\\phi)}\n  = -t \\sum_{q,\\mu} \\cos\\p{qa+\\mu\\phi} S_{\\mu\\mu}^{(q)}\n  \\label{eq:H_lat_spin}\n\\end{align}\nDefining the diagonal operators\n\\begin{align}\n  \\tilde d_{\\phi+} \\equiv \\sum_\\mu \\cos\\p{\\mu\\phi} S_{\\mu\\mu},\n  &&\n  \\tilde d_{\\phi-} \\equiv \\sum_\\mu \\sin\\p{\\mu\\phi} S_{\\mu\\mu},\n\\end{align}\nwhich are respectively even and odd under spin inversion\n($\\mu\\to-\\mu$), we can expand\n\\begin{align}\n  \\sum_\\mu \\cos\\p{qa+\\mu\\phi} S_{\\mu\\mu}\n  = \\cos\\p{qa} \\tilde d_{\\phi+} - \\sin\\p{qa} \\tilde d_{\\phi-},\n\\end{align}\nand resolve the identity (super-)operator $\\I$ with\n$\\I \\tilde d_{\\phi\\pm} = \\tilde d_{\\phi\\pm}$ in the basis of the drive operators\n$D_{LM}$ (see Appendix \\ref{sec:changing_bases}), finding\n\\begin{align}\n  \\sum_\\mu \\cos\\p{qa+\\mu\\phi} S_{\\mu\\mu}\n  = \\cos\\p{qa} \\f12 \\sum_{L,M} \\obk{\\tilde d_{\\phi+}|D_{LM}} D_{LM}\n  - \\sin\\p{qa} \\f12 \\sum_{L,M} \\obk{\\tilde d_{\\phi-}|D_{LM}} D_{LM}.\n\\end{align}\nWe now note that the drive operators $D_{LM}$ are strictly\noff-diagonal for $M\\ne0$, and furthermore that $D_{L,0}$ with even\n(odd) $L$ is even (odd) under spin inversion, which implies\n\\begin{align}\n  \\sum_{L,M} \\obk{\\tilde d_{\\phi+}|D_{LM}} D_{LM}\n  = \\sum_{L\\,\\t{even}} \\obk{\\tilde d_{\\phi+}|D_{L,0}} D_{L,0},\n\\end{align}\nand likewise with $\\tilde d_{\\phi-}$ and odd $L$.  In total, we can\nwrite\n\\begin{align}\n  \\sum_\\mu \\cos\\p{qa+\\mu\\phi} S_{\\mu\\mu}\n  = \\cos\\p{qa} \\f12 \\sum_{L\\,\\t{even}}\n  \\obk{\\tilde d_{\\phi+}|D_{L,0}} D_{L,0}\n  - \\sin\\p{qa} \\f12 \\sum_{L\\,\\t{odd}}\n  \\obk{\\tilde d_{\\phi-}|D_{L,0}} D_{L,0},\n\\end{align}\nor, more compactly,\n\\begin{align}\n  \\sum_\\mu \\cos\\p{qa+\\mu\\phi} S_{\\mu\\mu}\n  = \\sum_L w_L\\p{qa} A_L^{(\\phi)} D_{L,0},\n  &&\n  w_L\\p{\\theta} \\equiv\n  \\begin{cases}\n    \\cos\\theta & L~\\t{even} \\\\\n    \\sin\\theta & L~\\t{odd}\n  \\end{cases},\n  \\label{eq:compact_SOC_drive}\n\\end{align}\nwith effective driving field amplitudes\n\\begin{align}\n  A_L^{(\\phi)}\n  \\equiv \\p{-1}^L \\f12 \\obk{\\tilde d_{\\phi,\\p{-1}^L}|D_{L,0}}\n  = \\p{-1}^L \\sqrt{\\f{2L+1}{2I+1}}\n  \\sum_\\mu \\bk{I\\mu;L,0|I\\mu} w_L\\p{\\mu\\phi}.\n\\end{align}\nSubstituting the result in \\eqref{eq:compact_SOC_drive} into the\nsingle-particle Hamiltonian in \\eqref{eq:H_lat_spin} yields\n\\begin{align}\n  H_{\\t{lat}}^{(\\phi)} = \\sum_{q,L} B_L^{(\\phi,q)} D_{L,0}^{(q)},\n  &&\n  B_L^{(\\phi,q)} \\equiv -J\n  w_L\\p{qa} A_L^{(\\phi)}.\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Transition operator product expansion}\n\\label{sec:trans_prod}\n\nHere we derive multiplication rules for transition operators on an $n$-dimensional Hilbert space, which allows us to expand\n\\begin{align}\n  T_{\\ell_1 m_1} T_{\\ell_2 m_2}\n  = \\sum_{L,M} f_{\\ell_1 m_1;\\ell_2 m_2}^{LM} T_{LM},\n\\end{align}\nwith structure constants\n\\begin{align}\n  f_{\\ell_1 m_1;\\ell_2 m_2}^{LM}\n  \\equiv \\obk{T_{LM} | T_{\\ell_1 m_1} T_{\\ell_2 m_2}}\n  = \\tr\\p{T_{LM}^\\dag T_{\\ell_1 m_1} T_{\\ell_2 m_2}}.\n  \\label{eq:trans_struct_start}\n\\end{align}\nFor reference, the transition operators $T_{LM}$ are defined for\nintegers $L,M$ with $0\\le L<n$ and $\\abs{M}\\le L$ in terms of\nClebsch-Gordan coefficients $\\bk{\\ell_1 m_1;\\ell_2 m_2|\\ell_3 m_3}$ by\n\\begin{align}\n  T_{LM} \\equiv \\sqrt{\\f{2L+1}{2I+1}}\n  \\sum_{\\mu,\\nu} \\bk{I\\mu;LM|I\\nu} \\op{\\nu}{\\mu},\n  &&\n  I \\equiv \\f{n-1}{2}.\n\\end{align}\nUsing the symmetry properties of Clebsch-Gordan coefficients, namely\n\\begin{align}\n  \\bk{\\ell_1 m_1; \\ell_2 m_2| \\ell_3 m_3}\n  &= \\p{-1}^{\\ell_2+m_2} \\sqrt{\\f{2\\ell_3+1}{2\\ell_1+1}}\n  \\bk{\\ell_3,-m_3; \\ell_2 m_2| \\ell_1,-m_1} \\\\\n  \\bk{\\ell_1 m_1; \\ell_2 m_2| \\ell_3 m_3}\n  &= \\p{-1}^{\\ell_1+\\ell_2-\\ell_3}\n  \\bk{\\ell_1,-m_1; \\ell_2,-m_2| \\ell_3,-m_3},\n\\end{align}\nwe can find that\n\\begin{align}\n  T_{LM}^\\dag\n  = \\sqrt{\\f{2L+1}{2I+1}}\n  \\sum_{\\mu,\\nu} \\p{-1}^M \\bk{I\\nu;L,-M|I\\mu} \\op{\\mu}{\\nu}\n  = \\p{-1}^M T_{L,-M}.\n\\end{align}\nSubstituting this result into \\eqref{eq:trans_struct_start} and\nexpanding Clebsch-Gordan coefficients in terms of Wigner 3-$j$ symbols\nas\n\\begin{align}\n  \\bk{\\ell_1 m_1; \\ell_2 m_2| \\ell_3 m_3}\n  = \\p{-1}^{-\\ell_1+\\ell_2-m_3} \\sqrt{\\p{2\\ell_3+1}}\n  \\begin{pmatrix}\n    \\ell_1 & \\ell_2 & \\ell_3 \\\\\n    m_1 & m_2 & -m_3\n  \\end{pmatrix},\n\\end{align}\nwe find that\n\\begin{multline}\n  f_{\\ell_1 m_1;\\ell_2 m_2}^{LM}\n  = \\delta_{M,m_1+m_2}\n  \\p{-1}^M \\sqrt{\\p{2L+1}\\p{2\\ell_1+1}\\p{2\\ell_2+1}} \\\\\n  \\times \\sum_{\\mu,\\nu,\\rho} \\p{-1}^{-3I+L+\\ell_1+\\ell_2-\\mu-\\nu-\\rho}\n  \\begin{pmatrix}\n    I & L & I \\\\\n    \\mu & -M & -\\nu\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    I & \\ell_1 & I \\\\\n    \\nu & m_1 & -\\rho\n  \\end{pmatrix}\n  \\begin{pmatrix}\n    I & \\ell_2 & I \\\\\n    \\rho & m_2 & -\\mu\n  \\end{pmatrix},\n\\end{multline}\nwhere we can evaluate the sum and introduce Wigner 6-$j$ symbols to\nget\n\\begin{align}\n  f_{\\ell_1 m_1;\\ell_2 m_2}^{LM}\n  &= \\delta_{M,m_1+m_2} \\p{-1}^{2I+M}\n  \\sqrt{\\p{2L+1}\\p{2\\ell_1+1}\\p{2\\ell_2+1}}\n  \\begin{pmatrix}\n    L & \\ell_1 & \\ell_2 \\\\\n    M & -m_1 & -m_2\n  \\end{pmatrix}\n  \\begin{Bmatrix}\n    L & \\ell_1 & \\ell_2 \\\\\n    I & I & I\n  \\end{Bmatrix} \\\\\n  &= \\delta_{M,m_1+m_2} \\p{-1}^{2I+L}\n  \\sqrt{\\p{2\\ell_1+1}\\p{2\\ell_2+1}}\n  \\bk{\\ell_1 m_1; \\ell_2 m_2| LM}\n  \\begin{Bmatrix}\n    \\ell_1 & \\ell_2 & L \\\\\n    I & I & I\n  \\end{Bmatrix}.\n  \\label{eq:trans_struct}\n\\end{align}\nThe Wigner 6-$j$ symbol is symmetric under any permutation of its\ncolumns, while Clebsch-Gordan coefficients satisfy\n\\begin{align}\n  \\bk{\\ell_1 m_1; \\ell_2 m_2| \\ell_3 m_3}\n  &= \\p{-1}^{\\ell_1+\\ell_2-\\ell_3}\n  \\bk{\\ell_1,-m_1; \\ell_2, -m_2| \\ell_3 m_3} \\\\\n  &= \\p{-1}^{\\ell_1+\\ell_2-\\ell_3}\n  \\bk{\\ell_2 m_2; \\ell_1 m_1| \\ell_3 m_3},\n\\end{align}\nwhich implies that\n\\begin{align}\n  f_{\\ell_1 m_1;\\ell_2 m_2}^{LM}\n  &= \\p{-1}^{\\ell_1+\\ell_2-L} f_{\\ell_1,-m_2;\\ell_2,-m_2}^{L,-M} \\\\\n  &= \\p{-1}^{\\ell_1+\\ell_2-L} f_{\\ell_2 m_2;\\ell_1 m_1}^{LM}.\n\\end{align}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Drive operator product expansions}\n\\label{sec:drive_prod}\n\nThe drive operators are defined by\n\\begin{align}\n  D_{LM} \\equiv \\f{\\eta_M}{\\sqrt{2}}\n  \\sp{T_{LM} + \\sign\\p{M} T_{LM}^\\dag},\n  &&\n  \\eta_M \\equiv\n  \\begin{cases}\n    \\sqrt{2} & M = 0 \\\\\n    \\p{-1}^M & M > 0 \\\\\n    i & M < 0\n  \\end{cases},\n\\end{align}\nor, equivalently,\n\\begin{align}\n  D_{LM} \\equiv \\f{\\eta_M}{\\sqrt{2}}\n  \\sum_{s\\in\\set{\\pm1}} \\epsilon_{Ms} T_{L,sM},\n  &&\n  \\epsilon_{Ms} \\equiv\n  \\begin{cases}\n    1 & s = +1 \\\\\n    \\p{-1}^M \\sign\\p{M} & s = -1\n  \\end{cases},\n\\end{align}\nwhich implies that\n\\begin{align}\n  T_{LM} = \\f{\\tau_M}{\\sqrt{2}}\n  \\sum_{s\\in\\set{\\pm1}} \\sqrt{s} D_{L,sM},\n  &&\n  \\tau_M \\equiv\n  \\begin{cases}\n    \\sqrt{2}/\\p{1+i} & M = 0 \\\\\n    \\eta_M^* & M \\ne 0\n  \\end{cases},\n\\end{align}\nwhere $\\eta_M^*$ is the complex conjugate of $\\eta_M$.  In order to\nevaluate the product of two drive operators, we can thus expand them\nin terms of transition operators, evaluate the corresponding products\nof transition operators (see Appendix \\ref{sec:trans_prod}), and\nfinally expand the result in terms of drive operators.  The product of\ntwo drive operators is thus\n\\begin{align}\n  D_{\\ell_1 m_1} D_{\\ell_2 m_2}\n  = \\sum_{L,M} g_{\\ell_1m_1;\\ell_2m_2}^{LM} D_{LM}\n  \\label{eq:drive_prod}\n\\end{align}\nwhere\n\\begin{align}\n  g_{\\ell_1m_1;\\ell_2m_2}^{LM}\n  &\\equiv \\f{\\eta_{m_1}\\eta_{m_2}}{2\\sqrt2}\n  \\sum_{r,s_1,s_2\\in\\set{\\pm1}} \\epsilon_{m_1s_1} \\epsilon_{m_2s_2}\n  \\times f_{\\ell_1,s_1m_1;\\ell_2,s_2m_2}^{L,rM}\n  \\times \\tau_{s_1m_1+s_2m_2} \\times \\sqrt{r}.\n\\end{align}\nRedefining $\\p{s_1,s_2}\\to\\p{rs_1,rs_2}$ and using the facts that\n\\begin{align}\n  f_{\\ell_1,rs_1m_1;\\ell_2,rs_2m_2}^{L,rM}\n  = r^{\\ell_1+\\ell_2+L} f_{\\ell_1,s_1m_1;\\ell_2,s_2m_2}^{LM},\n  &&\n  \\tau_{rM} \\sqrt{r} &= \\tau_M \\, \\sigma_{Mr} \\, r^M,\n\\end{align}\nwith\n\\begin{align}\n  \\sigma_{Mr} \\equiv\n  \\begin{cases}\n    \\sqrt{r} & M = 0 \\\\\n    \\sign\\p{M}^{\\frac{1-r}{2}} & M \\ne 0\n  \\end{cases},\n  &&\n  0^0 \\equiv 1,\n\\end{align}\nwe can simplify\n\\begin{align}\n  g_{\\ell_1m_1;\\ell_2m_2}^{LM}\n  = \\f{\\eta_{m_1}\\eta_{m_2}\\tau_M}{\\sqrt2}\n  \\sum_{s_1,s_2\\in\\set{\\pm1}} f_{\\ell_1,s_1m_1;\\ell_2,s_2m_2}^{LM}\n  \\times \\f12 \\sum_{r\\in\\set{\\pm1}}\n  \\epsilon_{m_1,r s_1} \\epsilon_{m_2,r s_2} \\,\n  \\sigma_{Mr} \\, r^{\\ell_1+\\ell_2+L+M}.\n  \\label{eq:drive_struct}\n\\end{align}\nIn the case that $m_1=0$, we can simplify\n\\begin{align}\n  g_{\\ell_1,0;\\ell_2,m}^{LM}\n  \\stackrel{m\\ne 0}{=} f_{\\ell_1,0;\\ell_2 m}^{Lm}\n  \\times \\delta_{\\abs{M},\\abs{m}} \\times\n  \\begin{cases}\n    \\sp{\\sp{\\ell_1+\\ell_2+L~\\t{is even}}} & M = +m, \\\\\n    i \\sp{\\sp{\\ell_1+\\ell_2+L~\\t{is odd}}} & M = -m,\n  \\end{cases}\n\\end{align}\n\\begin{align}\n  g_{\\ell_1,0;\\ell_2,0}^{LM} = f_{\\ell_1,0;\\ell_2,0}^{LM}.\n\\end{align}\nHere $\\sp{\\sp{X}}\\equiv1$ if $X$ is true and $0$ otherwise.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Finding drive operator sub-algebras}\n\nHere we identify conditions under which the drive operator structure\nconstants $g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ vanish, which will help us\nidentify subsets of all drive operators that are relevant in a\nparticular physical scenario.  First, we note that\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ is guaranteed to be zero unless\n\\begin{align}\n  M = s_1 m_1 + s_2 m_2 ~~ \\t{for some} ~~ s_1,s_2\\in\\set{\\pm1}.\n\\end{align}\nEven if this condition is satisfied, the structure constant\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ can still vanish if the two terms in\nthe sum over $r$ in \\eqref{eq:drive_struct} have opposite sign.  For\nbrevity, we define\n\\begin{align}\n  z_{\\ell_1m_1;\\ell_2m_2}^{LM;s_1s_2r}\n  \\equiv \\epsilon_{m_1,r s_1} \\epsilon_{m_2,r s_2} \\,\n  \\sigma_{Mr} \\, r^{\\ell_1+\\ell_2+L+M}.\n\\end{align}\nIf $M=0$, then $\\p{\\sigma_{M,+1},\\sigma_{M,-1}}=\\p{1,i}$ and the\nremaining factors in $z_{\\ell_1m_1;\\ell_2m_2}^{LM;s_1s_2r}$ are real,\nso the sum over $r$ cannot vanish.  For the case of $M\\ne0$, we can\nwrite\n\\begin{align}\n  \\epsilon_{ms} = \\p{-1}^{\\frac{1-s}{2}m} \\sign\\p{m}^{\\frac{1-s}{2}},\n  &&\n  0^0 \\equiv 1,\n\\end{align}\nwhich allows us to expand\n\\begin{align}\n  z_{\\ell_1m_1;\\ell_2m_2}^{LM;s_1s_2r}\n  \\stackrel{M\\ne0}{=} \\p{-1}^{\\frac{m_1+m_2}{2}-r\\frac{M}{2}}\n  \\sign\\p{m_1}^{\\frac{1-rs_1}{2}} \\sign\\p{m_2}^{\\frac{1-rs_2}{2}}\n  \\sign\\p{M}^{\\frac{1-r}{2}} r^{\\ell_1+\\ell_2+L+M}.\n\\end{align}\nWe then consider the dependence of each factor in this expansion on\n$r$:\n\\begin{enumerate}\n\\item $\\p{-1}^{\\frac{m_1+m_2}{2}-r\\frac{M}{2}}$ changes sign with $r$\n  if and only if $M$ is odd,\n\\item $\\sign\\p{m_1}^{\\frac{1-rs_1}{2}}$ changes sign with $r$ if and\n  only if $m_1<0$,\n\\item $\\sign\\p{m_2}^{\\frac{1-rs_2}{2}}$ changes sign with $r$ if and\n  only if $m_2<0$,\n\\item $\\sign\\p{M}^{\\frac{1-r}{2}}$ changes sign with $r$ if and only\n  if $M<0$, and finally\n\\item $r^{\\ell_1+\\ell_2+L+M}$ changes sign with $r$ if and only if\n  $\\ell_1+\\ell_2+L+M$ is odd.\n\\end{enumerate}\nAltogether, the structure factor $g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ is\nguaranteed to be zero unless an even number of the following six\nconditions are satisfied:\n\\begin{align}\n  \\ell_1 ~ \\t{odd},\n  &&\n  \\ell_2 ~ \\t{odd},\n  &&\n  L ~ \\t{odd}, \\label{eq:L_conds} \\\\\n  m_1 < 0,\n  &&\n  m_2 < 0,\n  &&\n  M < 0. \\label{eq:M_conds}\n\\end{align}\nWe now consider the structure factors\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm}$ for (anti-)commutators of drive\noperators:\n\\begin{align}\n  \\sp{D_{\\ell_1 m_1}, D_{\\ell_2 m_2}}_\\pm\n  = \\sum_{L,M} g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm} D_{LM}.\n\\end{align}\nThe drive operators all self-adjoint, which implies that\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm}$ must be purely real ($+$) or\nimaginary ($-$).  As a consequence, $g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm}$\nis {\\it zero} unless $g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ is purely real\n($+$) or imaginary ($-$).  These conditions under which\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ is purely real or imaginary turn out to\nbe easy to determine by examination of the general product in\n\\eqref{eq:drive_prod}, together with the fact that the drive operator\n$D_{LM}$ is purely real (imaginary) for $M\\ge0$ ($M<0$).  It follows\nthat $g_{\\ell_1m_1;\\ell_2m_2}^{LM}$ must be purely real (imaginary) if\nan even (odd) number of $m_1,m_2,M$ are negative.  Altogether,\n$g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm}$ can only be nonzero for an even\n($+$) or odd ($-$) number of $m_1,m_2,M$ are negative, which implies\nthat an even ($+$) or odd ($-$) number of conditions in {\\it each} of\n\\eqref{eq:L_conds} and \\eqref{eq:M_conds} must be satisfied in order\nto have $g_{\\ell_1m_1;\\ell_2m_2}^{LM,\\pm}\\ne0$.\n\n\n\n\\red{todo: finish section}\n\n\\vspace{2cm}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Weak SOC in the PS manifold}\n\\label{sec:SOC_pert}\n\nHere we derive the first- and second-order effective Hamiltonians\ninduced on the PS manifold $\\M_\\PS$ by the single-particle weak-SOC\nHamiltonian\n\\begin{align}\n  H_{\\t{lat}}^{(\\phi)}\n  = \\sum_{q,L} B_L^{(\\phi,q)} D_{L,0}^{(q)},\n\\end{align}\nwhere $D_{L,0}^{(q)}$ is a drive operator that acts on spin $q$, and\n$B_L^{(\\phi,q)}$ is an effective inhomogeneous driving field amplitude\ndefined in \\eqref{eq:B_L_phi} and \\eqref{eq:A_L_phi}.  A perturbative\ntreatment of $H_{\\t{lat}}^{(\\phi)}$ yields the effective\nHamiltonians[\\red{TODO: cite perturbation theory notes}]\n\\begin{align}\n  H_{\\t{eff}}^{(1)}\n  &\\equiv \\sum_L \\EE_q\\sp{B_L^{(\\phi,q)}} \\D_{L,0},\n  \\\\\n  H_{\\t{eff}}^{(2)}\n  &\\equiv \\sum_{J,K}\n  \\f{\\cov_q\\sp{B_J^{(\\phi,q)}, B_K^{(\\phi,q)}}}{u\\p{N-1}}\n  \\p{\\D_{J,0} \\D_{K,0} - N \\sum_L g_{JKL} \\D_{L,0}},\n\\end{align}\nwhere $\\EE_q\\sp{X_q} \\equiv \\sum_q X_q / N$ is the mean of $X_q$ over\nall occupied quasi-momenta $q$;\n\\begin{align}\n  \\cov_q\\sp{X_q,Y_q}\n  \\equiv \\EE_q\\sp{\\p{X_q-\\EE_k\\sp{X_k}}\\p{Y_q-\\EE_\\ell\\sp{Y_\\ell}}}\n  = \\EE_q\\sp{X_q Y_q} - \\EE_k\\sp{X_k} \\EE_\\ell\\sp{Y_\\ell},\n  \\label{eq:cov}\n\\end{align}\nis the covariance of $X_q$ and $Y_q$ over all occupied quasi-momenta\n$q$; and $g_{JKL} \\equiv g_{J,0;K,0}^{L,0}$ is a structure constant of\nthe transition operator algebra, defined in \\eqref{eq:trans_struct}.\nSubstituting the form of $B_L^{(\\phi,q)}$ in \\eqref{eq:B_L_phi}, we\nget\n\\begin{align}\n  H_{\\t{eff}}^{(1)}\n  &= -t \\sum_L \\EE_q\\sp{w_L\\p{qa}} A_L^{(\\phi)} \\D_{L,0},\n  \\label{eq:H_eff_1}\n  \\\\\n  H_{\\t{eff}}^{(2)}\n  &\\equiv \\f{t^2}{fU\\p{N-1}} \\sum_{J,K}\n  \\cov_q\\sp{w_J\\p{qa}, w_K\\p{qa}} A_J^{(\\phi)} A_K^{(\\phi)}\n  \\p{\\D_{J,0} \\D_{K,0} - N \\sum_L g_{JKL} \\D_{L,0}}.\n  \\label{eq:H_eff_2}\n\\end{align}\nwhere $t$ is the nearest-neighbor tunneling rate, $a$ is the spacing\nbetween neighboring lattice sites, $f$ is the filling fraction of\nspatial modes, $U$ is the two-body on-site interaction energy, and\n$w_L$ is cosine (sine) for even (odd) $L$.  Note that as the spatial\nfilling fraction $f\\to1$, the sums over occupied quasi-momenta $q$\nbecome sums over nearly all angles $q\\in\\ZZ_N\\times2\\pi/N$.  In this\ncase, when both $J,K$ are even or odd (i.e.~$J=K~\\t{mod}~2$) the\ncovariance in \\eqref{eq:H_eff_2} becomes\n$\\cov_p\\sp{\\sin\\p{p},\\sin\\p{p}}\\to1/2$ or\n$\\cov_p\\sp{\\cos\\p{p},\\cos\\p{p}}\\to1/2$, whereas when one of $J,K$ is\neven and the other is odd (i.e.~$J\\ne K~\\t{mod}~2$), this covariance\nbecomes $\\cov_p\\sp{\\cos\\p{p},\\sin\\p{p}}\\to0$.  In the case of SU(2),\nthe effective Hamiltonian $H_{\\t{eff}}^{(2)}$ in \\eqref{eq:H_eff_2}\nreduces to the one-axis twisting Hamiltonian derived in\nRef.~\\cite{he2019engineering}.\n\nThe effective Hamiltonians in \\eqref{eq:H_eff_1} and\n\\eqref{eq:H_eff_2} are respectively first and second order in the SOC\nHamiltonian $H_{\\t{lat}}^{(\\phi)}$.  We can extract the leading and\nnext-to-leading order dependence of these effective Hamiltonians on\nthe SOC angle $\\phi$ by using the expansions of $A_L^{(\\phi)}$ in\n\\eqref{eq:A_L_phi_small}, which gives us\n\\begin{align}\n  H_{\\t{eff}}^{(1)}\n  &= \\phi t \\, \\EE_p\\sp{\\sin\\p{pa}} \\xi_1 \\D_{1,0}\n  + \\phi^2 t \\, \\EE_q\\sp{\\cos\\p{qa}} \\xi_2 \\D_{2,0}\n  + O\\p{\\phi^3},\n  \\label{eq:H_eff_1_phi_apndx} \\\\\n  H_{\\t{eff}}^{(2)}\n  &= \\f{\\phi^2 t^2}{\\p{N-1}fU} \\var_q\\sp{\\sin\\p{qa}}\n  \\p{\\xi_1^2 \\D_{1,0}^2 - 2 N \\xi_2 \\D_{2,0}}\n  + O\\p{\\phi^3},\n  \\label{eq:H_eff_2_phi_apndx}\n\\end{align}\nwhere the factors $\\xi_L$ are defined in \\eqref{eq:scale_fac},\n\\begin{align}\n  \\var_q\\sp{X_q} \\equiv \\cov_p\\sp{X_p,X_p}\n  = \\EE_p\\sp{\\p{X_p-\\EE_q\\sp{X_q}}^2}\n  = \\EE_p\\sp{X_p^2} - \\EE_q\\sp{X_q}^2\n\\end{align}\nis the variance of $X_q$ over all occupied quasi-momenta $q$, and we\nhave neglected scalar terms $\\sim\\D_{0,0}\\propto\\1$ that have no\nphysical consequence.  Note that in the case of SU(2), the re-scaled\ndrive operator $\\xi_1\\D_{1,0}$ is precisely the collective spin-$z$\noperator $S_\\z$ that appears in Ref.~\\cite{he2019engineering}.\nFurthermore, drive operators $D_{LM}$ vanish when $L\\ge n$, so in the\ncase of SU(2) the operator $\\D_{2,0}$ has no contribution to the\neffective Hamiltonians in \\eqref{eq:H_eff_2_phi_apndx} and\n\\eqref{eq:H_eff_2_phi_apndx}.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{Raman drive coefficients}\n\\label{sec:drive_raman_coeff}\n\nHere we provide the coefficients $\\Omega_{LM}^{(\\phi,j)}$ of the\neffective Raman driving Hamiltonian\n\\begin{align}\n  H_{\\t{Raman}}^{(\\phi)}\n  = \\sum_j \\sum_{\\substack{L\\in\\set{0,1,2}\\\\\\abs{M}\\le L}}\n  \\Omega_{LM}^{(\\phi,j)} D_{LM}^{(j)}\n  \\label{eq:raman_drive_apndx}\n\\end{align}\nconsidered in Section \\ref{sec:drive_raman}.  These coefficients are\ncomputed using the structure constants of the transition operator\nalgebra provided in Appendix \\ref{sec:trans_prod}.  For clarity, if\nany coefficient $\\Omega_{LM}^{(\\phi,j)}$ is independent of the SOC\nangle $\\phi$ or lattice site $j$, we suppress the explicit dependence\non $\\p{\\phi,j}$, i.e.~taking $\\Omega_{LM}^{(\\phi,j)}\\to\\Omega_{LM}$.\nDefining the re-scaled driving amplitudes\n\\begin{align}\n  \\tilde\\Omega_{LM}^{(\\phi,j)} \\equiv \\xi_L^{-1} \\Omega_{LM}^{(\\phi,j)},\n  &&\n  \\tilde\\Omega_m \\equiv \\xi_1^{-1} \\Omega_m,\n\\end{align}\nwhere where the scale factors $\\xi_L$ are defined in\n\\eqref{eq:scale_fac} and $\\Omega_m$ are the (real) driving amplitudes\nin the ``bare'' Raman drive in \\eqref{eq:raman_bare}, the coefficients\nof the effective Raman drive in \\eqref{eq:raman_drive_apndx} are\ndetermined by\n\\begin{align}\n  \\Delta \\tilde\\Omega_{0,0}\n  \\equiv -\\f{\\xi_1^2}{\\xi_0^2} \\sum_m \\tilde\\Omega_m^2,\n  &&\n  \\Delta \\tilde\\Omega_{1,0}\n  \\equiv \\f12 \\p{\\tilde\\Omega_+^2 - \\tilde\\Omega_-^2},\n  &&\n  \\Delta \\tilde\\Omega_{2,0}\n  \\equiv \\tilde\\Omega_+^2 + \\tilde\\Omega_-^2 - 2\\tilde\\Omega_0^2,\n  \\label{eq:O_X0}\n\\end{align}\n\\begin{align}\n  \\tilde\\Omega_{L,1}^{(\\phi,j)}\n  &\\equiv \\sum_{s\\in\\set{\\pm1}}\n  \\omega_{Ls} \\cos\\p{\\sp{\\phi_s-\\phi_0}j},\n  &\n  \\tilde\\Omega_{L,-1}^{(\\phi,j)}\n  &\\equiv -\\sum_{s\\in\\set{\\pm1}}\n  s \\omega_{Ls} \\sin\\p{\\sp{\\phi_s-\\phi_0}j}, \\\\\n  \\tilde\\Omega_{2,2}^{(\\phi,j)}\n  &\\equiv \\omega_{2,2} \\cos\\p{\\sp{\\phi_+-\\phi_-}j},\n  &\n  \\tilde\\Omega_{2,-2}^{(\\phi,j)}\n  &\\equiv -\\omega_{2,2} \\sin\\p{\\sp{\\phi_+-\\phi_-}j},\n\\end{align}\n\\begin{align}\n  \\Delta \\omega_{1\\pm}\n  \\equiv \\f1{\\sqrt{2}} \\, \\tilde\\Omega_0 \\tilde\\Omega_\\pm,\n  &&\n  \\Delta \\omega_{2\\pm}\n  \\equiv \\pm \\sqrt{6} \\, \\tilde\\Omega_0\\tilde\\Omega_\\pm,\n  &&\n  \\Delta \\omega_{2,2}\n  \\equiv 2\\sqrt{3} \\, \\tilde\\Omega_+\\tilde\\Omega_-.\n\\end{align}\nHere $\\phi_m$ and $\\Delta$ are respectively the phases and detuning\nthat appear in the ``bare'' Raman drive in \\eqref{eq:raman_bare}.  If\nthe driving lasers are phase-matched with $\\phi_m=m\\phi$, such that a\nnuclear spin transition $\\mu\\to\\mu+m$ on site $j$ imprints the phase\n$m\\phi j$, then the drive $H_{\\t{Raman}}^{(\\phi)}$ takes the form\n\\begin{align}\n  \\left. H_{\\t{Raman}}^{(\\phi)} \\right|_{\\phi_m=m\\phi}\n  = \\sum_{\\substack{L\\le2\\\\0\\le M\\le L}} \\Omega_{LM} \\D_{LM}^{(\\phi)},\n\\end{align}\nwith inhomogeneously rotated collective drive operators\n\\begin{align}\n  \\D_{LM}^{(\\phi)}\n  \\equiv \\sum_j \\sp{\\cos\\p{M\\phi j} D_{LM}^{(j)}\n    - \\sin\\p{M\\phi j} D_{L,-M}^{(j)}},\n\\end{align}\nand uniform coefficients determined by \\eqref{eq:O_X0} and\n\\begin{align}\n  \\tilde\\Omega_{1,-1} = \\tilde\\Omega_{2,-1}\n  = \\tilde\\Omega_{2,-2} \\equiv 0,\n  &&\n  \\tilde\\Omega_{L,1} \\equiv \\sum_{s\\in\\set{\\pm1}} \\omega_{Ls},\n  &&\n  \\tilde\\Omega_{2,2} \\equiv \\omega_{2,2}.\n\\end{align}\n\n\n\\bibliography{multilevel_spin_notes.bib}\n\n\\end{document}\n\n% Level statistics of Hamiltonian\n% Dynamics of single-particle observables\n% Dynamics of two-point correlators\n% - Different sites\n% - Two-time correlators\n% TWA dynamics\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n", "meta": {"hexsha": "9e8f1659fee3f2bf0fedd64581af6ad72b124fc2", "size": 53849, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "sun_phases/multilevel_spin_notes.tex", "max_stars_repo_name": "perlinm/rey_research", "max_stars_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sun_phases/multilevel_spin_notes.tex", "max_issues_repo_name": "perlinm/rey_research", "max_issues_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sun_phases/multilevel_spin_notes.tex", "max_forks_repo_name": "perlinm/rey_research", "max_forks_repo_head_hexsha": "491d1d33cc8d20dc1b72de552ac7c1b65fb3ee63", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6040502793, "max_line_length": 408, "alphanum_fraction": 0.6456015896, "num_tokens": 20899, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438502, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4008448622829}}
{"text": "\\chapter{Appendix: Family Motion Planning}\n\\label{chap:appendix-family}\n\n\\begin{figure}\n   \\centering\n   \\includegraphics[width=10.5cm]{build/family-suction-example-graph}\n   \\caption[Family belief graph for the 2D example problem from\n      Figure~\\ref{fig:family:example} in Chapter~\\ref{chap:family}.\n      The underlying family consists of five sets:\n      $A$, $B$, $C$, $S_{12}$, and $S_{23}$.\n      Transitions between states are shown for indicators\n      $\\mathbf{1}_A$,\n      $\\mathbf{1}_B$,\n      and $\\mathbf{1}_C$,\n      with solid lines\n      showing transitions in which the indicator returns True,\n      and dashed lines\n      showing transitions in which the indicator returns False.\n      Also shown is the distance function and optimal policy\n      for a query subset $S_u = S_{23}$,\n      with green beliefs as goal states.\n      Bolded edges\n      represent transitions on an optimal policy.\n   ]{Family belief graph for the 2D example problem from\n      Figure~\\ref{fig:family:example} in Chapter~\\ref{chap:family}.\n      The underlying family consists of five sets:\n      $A$, $B$, $C$, $S_{12}$, and $S_{23}$.\n      Transitions between states are shown for indicators\n      $\\mathbf{1}_A$ (\\protect\\tikz{\\protect\\node[fill=red,draw=black]{};}),\n      $\\mathbf{1}_B$ (\\protect\\tikz{\\protect\\node[fill=green!70!black,draw=black]{};}),\n      and $\\mathbf{1}_C$ (\\protect\\tikz{\\protect\\node[fill=blue,draw=black]{};}),\n      with solid lines (\\protect\\tikz{\\protect\\draw[thick,solid] (0,0) -- (0.15,0.15);})\n      showing transitions in which the indicator returns True,\n      and dashed lines (\\protect\\tikz{\\protect\\draw[thick,densely dotted] (0,0) -- (0.15,0.15);})\n      showing transitions in which the indicator returns False.\n      Also shown is the distance function and optimal policy\n      for a query subset $S_u = S_{23}$,\n      with green beliefs as goal states.\n      Bolded edges (\\protect\\tikz{\\protect\\draw[ultra thick,solid] (0,0) -- (0.15,0.15);})\n      represent transitions on an optimal policy.\n      }\n   \\label{fig:family:appendix-suction-example-graph}\n\\end{figure}\n", "meta": {"hexsha": "332327c412fc1da0519a6ed40f18ef85234cf7d7", "size": 2111, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "thesis-ch06-family-appendix.tex", "max_stars_repo_name": "siddhss5/phdthesis-dellin", "max_stars_repo_head_hexsha": "62ca559db0ad0a6285012708ef718f4fde4e1dcd", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-09-06T21:45:42.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-06T21:45:42.000Z", "max_issues_repo_path": "thesis-ch06-family-appendix.tex", "max_issues_repo_name": "siddhss5/phdthesis-dellin", "max_issues_repo_head_hexsha": "62ca559db0ad0a6285012708ef718f4fde4e1dcd", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesis-ch06-family-appendix.tex", "max_forks_repo_name": "siddhss5/phdthesis-dellin", "max_forks_repo_head_hexsha": "62ca559db0ad0a6285012708ef718f4fde4e1dcd", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.9772727273, "max_line_length": 97, "alphanum_fraction": 0.671245855, "num_tokens": 600, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.40084486228289995}}
{"text": "\\chapter{1st Order Linear ODE's}\r\n\\noindent\r\n1st order linear ODEs are among the simplest differential equations, but learning different techniques to solve them will allow us to develop techniques for solving more complicated types of equations later on.\r\n\r\n% Seperable Differential Equations\r\n\\input{./1stOrderLinearODE/separability/separability.tex}\r\n\r\n% Method for solving (Integrating Factor)\r\n\\input{./1stOrderLinearODE/integratingFactor/integratingFactor.tex}\r\n\r\n% Applications\r\n\t% Newton's Law of Cooling\r\n\t% Logistic Equation (Viral Spread)\r\n\t% Compound Interest\r\n\t% RC Circuit", "meta": {"hexsha": "7d6eb9c2d87ac11c68a36312d1a15f31f0e967cf", "size": 586, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diffEq/1stOrderLinearODE/1stOrderLinearODE.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "diffEq/1stOrderLinearODE/1stOrderLinearODE.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "diffEq/1stOrderLinearODE/1stOrderLinearODE.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 39.0666666667, "max_line_length": 211, "alphanum_fraction": 0.7918088737, "num_tokens": 135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.40084486228289995}}
{"text": "\\author{Bautrelle Fotso}\n\\graphicspath{ {./src/chapters/developer/media/} }\n\n\\section{Networks}\nIn the previous section, many types of datasets and their characteristics have been presented. \nHowever, the use of datasets is not sufficient to perform the Optical Character Recognition (OCR). \nThese datasets have to be applied to different networks which learn from them. \nThe goal is to obtain a model with the best accuracy for each OCR case handled in this project, namely: number, text and text without number.\nThis process is called deep learning. \n\n\\noindent\nAccordingly, deep learning can be defined as a subset of machine learning to preprocess data in artificial \nintelligence. For this task, it imitates the working of the human nervous system.  \nLike machine learning, deep learning has the particularity of learning in an unsupervised way from unstructured datasets.  \nLearning in an unsupervised way means that, the network receives inputs without outputs. \nDuring the training, the network must decide itself which output is corresponding to the input received.(\\cite{[1]}, p.6)\nDeep learning is a term to describe deep neural networks and their functionalities. \nThe word \"deep\" specifies that the network always contains more than one intermediate layer.(\\cite{[1]}, p.8) \\hfill \\break\n\n\\noindent\nThree types of deep neural network have been used in this project and are described in this section. These are:\n\n\\begin{itemize}\n    \\item Deep Feedforward Neural Network(DFFNN)\n    \\item Convolutional Neural Network(CNN)\n    \\item Recurrent Neural Network(RNN).\n\n\\end{itemize}\n\n\n\\subsection{Deep Feedforward Neural Network(DFFNN)}\nThe Deep Feedforward Neural Network, also called Multi-Layer Perceptron(MLP), is a network composed of an input layer,\nat least two hidden layers and one output layer. \nIn this network, each neuron in the previous layer is connected with all neurons of the next layer to form a fully connected layer. \nAdditionally, the connection between two neurons in the network has a certain amplitude called weight. (\\cite{[1]}, p.4) \n\n\\noindent\nThe EMNIST-letters and the MNIST datasets have been applied on this network for the main reason that, they are compatible together. \\hfill \\break\n\n\\noindent\nThe picture (\\ref{Abb:feed_forward}) below illustrates a general model of DFFNN.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[height=0.2\\textheight]{simple_FFNN}\n\t\\caption[Deep Feedforward Neural Network]{Deep Feedforward Neural Network (\\cite{[3]}, p.1)}\\label{Abb:feed_forward}\n\\end{figure}\n\n%\\newpage\n\\noindent\nThis is just a general overview of DFFNN, however, a specific network needs to be built accordingly to \nthe requirements of this project. \\hfill \\break\n\n\\subsubsection{Building the Deep Feedforward Neural Network}\nAn example of DFFNN built on MNIST dataset is presented in the figure(\\ref{Abb:build_feed_forward}).\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=1.0\\textwidth]{ffnn}\n\t\\caption[Build Deep Feedforward Neural Network]{Building the Deep Feedforward Neural Network on MNIST dataset} \\label{Abb:build_feed_forward}\n\\end{figure}\n\n\\noindent\nA sniped code of a built DFFNN an its abstract representation can be seen respectively on the left  \nand on the right side of the picture(\\ref{Abb:build_feed_forward}). \nThe architecture used to build this network is the sequential mode of the keras library. \nIt is always appplied when the network takes only one input and one output layer. \nThis sequential mode specifies to keras that the output of each layer added should be used as input in the next layer. \nThe function for adding each layer to the network is \\emph{add()}. \nThe first layer of the network takes a vector as input. \nBut the dataset images used to train the network have the shape of 28x28 pixels (28 for the height x 28 for the width of the image). \nEach image is transformed to a vector of 784 pixels with the function \\emph{Flatten()}, which receives as parameter \nthe shape of the image to be converted. This shape can be a tuple of (28, 28) or a triplet of (1, 28, 28). \nThe \"1\" in the triplet just specifies the number of image with the shape 28x28 pixels. \nThese notations are equivalent because the input layer takes only one image at the time. \nThe two hidden layers are also added with 512 neurons each. \nWith the function \\emph{Dense()}, a full connection is created between neurons of the previous layer and the next layer. \nThe activation function \\emph{\"relu\"}(Rectified Linear Unit) is a linear function used to remove negative activations.\nIt is the most used activation in deep learning(\\cite{[1]}, p.12). \nAn activation is the occupancy rate that an image takes on each of its pixels. \nThis will be more explained in the training part. \nOn the last layer the number of neurons is determined by the number of classes available in the used dataset. \nThe output contains ten neurons ranging from 0 to 9 corresponding to the ten classes of MNIST. \nThe activation function \\emph{\"softmax\"} maps the prediction vector obtained in the output layer to a probability distribution.\nIn this case, the prediction vector has ten indices, whose values are represented as probabilities in the range [0,1]. \nAt the end, all added layers are put together using the function \\emph{compile()}. \nThe network uses \\emph{\"adam\"} optimizer responsible to update weights between neurons after a forward pass. \nBy the forward pass, activations are diffused only forward from the input layer, through the hidden layers to the output \nlayer and consequently has no loops.\nUpdating the weights means adjusting it so that the difference between the real values and the values predicted by \nthe trained model will be minimized. \nThis difference is called \\emph{\"loss\"} and is calculated using the loss function \\emph{sparse\\_categorical\\_cross\\_entropy}. \nThis type of loss function is especially applied on this network because the labels of the MNIST dataset have not been one-hot-encoded. \nOne hot encoding transforms a label, which is represented as an integer, to a binary value represented as a vector. \nUsing this loss function also help to save time as well as computation because it simply takes a single integer rather than a whole vector. \nThe chosen metric is the accuracy, which indicates how good the prediction rate on training data is, after each forward pass. (\\cite{[4]})\n\nThe network training is then started by the function \\emph{fit()} called on the built network(the variable model). \n\n\\noindent\nIn the following part, the training of the model  and the role of each parameter used in the function \\emph{fit()} will be explained. \n\n\n\\subsubsection{Training the Deep Feedforward Neural Network}\nThe next step, after building a network, is to train data on it to obtain a model suitable for prediction.\nThe following picture presents the training process of the DFFNN on the MNIST dataset.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=1.0\\textwidth]{train_cnn}\n\t\\caption[Train Deep Feedforward Neural Network]{Training the Deep Feedforward Neural Network on MNIST dataset \\cite{[12]}} \\label{Abb:train_cnn}\n\\end{figure}\nThe MNIST dataset, namely the train and the test set have to be first loaded from the \\emph{Keras.dataset.mnist} library. \nAfter loading the dataset, \nthe train and the test set images are rescaled to be sure that the required size is kept. \nAfterward, each image pixel is downscaled from [0 255] to [0 1], to maintain a general pixel value distribution on the entire dataset \nand avoid working with big decimal values. \nFor a better training of the dataset, the network uses mini-batches of the MNIST training data instead of the entire dataset at once. \nThe actual training is started using the function model.fit() as mentioned above. \nAt the end of each epoch, the network will be evaluated on the test data, which have not been trained.\nAn epoch describes an unique passage of the entire MNIST dataset through the network. \nAfter the dataset images have been normalized and reshaped, the built network then receives a digit image of 28x28 pixels as input. \nThis image is flattened to a vector of 784 pixels. \nEach of these pixels represents a neuron in the input layers. Each neuron holds a specific number\nin the interval of 0 to 1 due to the previous normalization (division of each pixel value by 255). \nThe value contained in these neurons represents the value of the corresponding \npixel, which is called \\emph{activation}. When a neuron is brighter, the activation is high and tends towards 1. \nOtherwise, the activation is low and tends towards 0. \nOne important thing to notice on training networks is that, the activation value of the previous layer is always used to determine \nthe one of the next layer. This is realized by doing a particular calculation. \nAn example of the computation with some results is shown on the figure(\\ref{Abb:train_cnn}). The activation values \nare not real, but it has been used for illustration purpose. \nFor this example, there are two neurons on the third layer with the highest activation 1. They have the form of a \"zero\" and a \n\"dash\", whose combination gives on the fourth layer the correct predicted answer nine(9).\nAfter each forward pass from a layer to the other, the weights muss be updated before a next pass. \nThis loss value obtained from the function \\emph{sparse\\_categorical\\_cross\\_entropy} is sent back through each layer and the \noptimizer(adam) bases its computation on this error rate. This helps to update \nthe weights accordingly to the error rate of each of this weights, in order to minimize the error by the next forward pass. \n\n\n\\subsubsection{Results and interpretation}\nThe prediction results of the model obtained by training DFFNN on the MNIST dataset are in the figure(\\ref{Abb:mnist_metrics}). \n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=0.4\\textwidth]{MNIST_metrics}\n\t\\caption[Results of DFFNN model on MNIST]{Loss and Accuracy from DFFNN model on MNIST train and test set} \\label{Abb:mnist_metrics}\n\\end{figure}\n\nThe model prediction results of the MNIST training and test set are obtained during a defined number of epochs.\nIt is observable that, the training set has a higher accuracy and a lower loss value\nthan the test set.\nThis can be due to the fact that the training set is the one applied on the network during the training. \nHowever, the error rate by the test set differs very little from the one by the training set.\nIt means that, the probability to correctly predict a new image is also high, although the image have not \nbeen trained on the network before. \n\n\n\\subsection{Convolutional Neural Network (CNN)}\nConvolutional Neural Network is a type of neural network which uses a particular processing for recognizing images. \nCNN is basically used for image analysis. (\\cite{[6]}, p.3)\nThey are three types of CNN: \n\n\\begin{itemize}\n    \\item One dimensional CNN\n    \\item two dimensional CNN\n    \\item three dimensional CNN.\n  \\end{itemize}\n\nOne dimensional CNN takes one dimensional vectors as input. \nIt is also applied for digits recognition like DFFNN. The two other types of CNN use a matrix as input(2D or 3D matrices according to the type of CNN).\nCNN is an excellent network for object recognition, behavior recognition, natural language processing and more. \nThe CNN used in this project is the 2D-CNN. (\\cite{[1]}, p.16)\n\nThe figure(\\ref{Abb:schema_cnn}) presents a schematic diagramm of this network type.\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[scale=0.6]{schema_cnn}\n\t\\caption[Convolutional Neural Network]{General view of a Convolutional Neural Network (\\cite{[14]})} \\label{Abb:schema_cnn}\n\\end{figure}\n\nAs seen in figure(\\ref{Abb:schema_cnn}) a CNN generally contains an input layer, a convolutional layer and  a pooling layer. They help not only to \nanalyze an entire image in pieces but also extract its features for a better recognition; this makes the difference CNNs and DFFNNs. \nThe second part of this network is made up of a fully connected layer for predictions of images. At the end of the prediction process the \nresults are then forwarded to the output layer.\nFigure(\\ref{Abb:schema_cnn}) has been chosen for illustrative reasons. \nFor better performance, a CNN must have more than one of each layer mentioned above. (\\cite{[1]}, p.16)\n\n\\subsubsection{Building the Convolutional Neural Net}\nThis part explains how the 2D-CNN was constructed appropriately to the requirements of the data to be applied on it. \nThree datasets have been used on this network, namely the EMNIST-balanced, EMNIST-byMerge and EMNIST-digits datasets. \nThe following application example is based on the building of the 2D-CNN model to recognize the EMNIST-Balanced dataset.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=1.0\\textwidth]{build_cnn}\n\t\\caption[Building Convolutional Neural Network]{Building the Convolutional Neural Network on EMNIST-Balanced dataset} \\label{Abb:build_cnn}\n\\end{figure}\n\n\\noindent\nAs shown in the figure above, The 2D-CNN is also built using a sequential architecture. \nIt is constituated of some components, similar to those in the DFFNN. \nAs explained above, the 2D-CNN takes a 2D-matrix as input parameter. In this case either an image of the  \nsize (28, 28, 1) or the size (1, 28, 28, 1) can be used.\nThe last value \"1\" of each size specifies the channel of the image. The channel 1 describes grayscaled images and the channel 3 color images.\nLike DFFNN, each input layer recognizes automatically the value \"1\" of each size, as first element of the input shape.\nThe first layer is the \\emph{2D-convolutional layer}. On this layer 32 filters are defined with a size of 5x5 each.\nEach of these filters are used to filter each area of the image. \nActivation functions are similar to those described in the DFFNN. \nThe next layer is the pooling layer where the max pooling operation is performed. The \\emph{Max pooling layer} is used to downstream \nimages obtained from the convolution step, done in the first layer. \nIt is used to speed up the processing of the image. \nThe \\emph{BatchNormalization} is the following layer where the downsampled images obtained from the \\emph{Max Pooling layer} are normalized. \nThe build process of this three layers is repeated once more to form the next three layers. \nThe only difference is the fact that the 32 filters used on the second 2D-convolutional layer has a size of 3x3. \nThe \\emph{Flatten} layer converts the obtained feature images to a vector in order to make it ready to be used as input in the fully connected \nlayer. \nBy adding of the \\emph{Dropout layer}, 20\\% of the neurons in the network will be randomly deactivated during the forward pass on the network.\nThe weights updating is not applied on dropped out neurons during the backward pass. \nBy the Backward pass, information about the difference between the real and the predicted value (loss) are sent back to neurons. \nDuring the dropout, the remaining neurons have to step in, take the role of the ignored neurons in order to \nhandle the representation required to do the prediction. \nThis technique avoids the neurons to be dependent from each other and from its context.  \nFurthermore, the network will not just memorize the training data but is able to \nrealize better generalizations and is more flexible to predict any data. \nThis problem of memorizing the training data is called overfitting and the general solution is to implement a \ndropout layer using the activation function \\emph{softmax}.  \nThe Results in the output layer are distributed among 47 neurons because the EMNIST-Letters has 47 classes.\n\n\n\\subsubsection{Training the Convolutional Neural Network}\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=0.8\\textwidth]{conv2}\n\t\\caption[Convolutional Neural Network]{Trainings process of the CNN (\\cite{[5]})} \\label{Abb:cnn_process}\n\\end{figure}\n\nThe upper part of the figure(\\ref{Abb:cnn_process}) shows each step of the training on CNN, regardless on whether the CNN is \na 1D or 2D-CNN because both have almost the same process. \nThe only difference is the shape of the input image used for the training. \nFirstly, the image is loaded into the convolutional layer of the CNN. \nIn this layer the convolution of the image is performed with each of the 5x5 filter(conv). \nThese filters are randomly initialized so that, each of them recognizes specific features of the image such as edges and curves. \nThe bottom part of the figure(\\ref{Abb:cnn_process}) illustrates how the convolution of an image works.\nIt is an element-wise multiplication of image pixels with a filter to detect specific features.\nThe resulting image after the convolution with one filter is called the feature map.\nAccordingly,there are 8 feature maps in the first column(conv) of the third picture in figure(\\ref{Abb:cnn_process}). \nThe feature map can contain negative values. \nThe relu activation function is then used to set all negative values to zero, in order to have only positive \nactivations in the feature map.\nThis feature maps are then forwarded to the pooling layer which uses the \\emph{maxpool} method. \nThe maxpool method itself modifiies the image size by reducing the number of overall parameters in the image. \nAs illustrated in the third column of the third picture in figure(\\ref{Abb:cnn_process}), the size of the eigth images has reduced to 14x14 pixels. \nIn the second 2D-convolutional layer, 32 filters have been used for the convolution. \nThe previous steps are repeated again up to the last pooling layer, which has reduced the size of the 32 images (obtained \nafter the convolution) to 7x7 pixels. \nThe process performed from the first convolutional layer up to the last maxpooling layer is called \\emph{feature learning and extraction process}. \nThe output of the pooling layers are then flattened and connected to the dense layers. \nAfter the images have been flattened, the prediction happens similarly to the process in the DFFNN and is called \\emph{classification process}. \\hfill \\break\n\n\\subsubsection{Results and interpretation}\nThe figure(\\ref{Abb:emnist_balaced_metrics}) presents the results obtained by the training of CNN on the \nEMNIST-balanced dataset after a defined number of epoch.\nIt is remarkable that, the training set has a lower loss value than the test set.\nThis can also be due to the fact that the training set is the one applied on the network during the training. \nHowever the test data has a model accuracy closed to 90 percent.  \nThis accuracy describes the performance of the model on data which have not be trained on it.\nThrough this results, it can be prognosticated that the model is able to correctly predict any character image\nwith an accuracy of more than 80 percent. \n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=0.4\\textwidth]{EMNIST-balanced_metrics}\n\t\\caption[Results of DFFNN training on MNIST]{Loss and Accuracy rates on EMNIST\\_balanced got from the 2D-CNN model} \\label{Abb:emnist_balaced_metrics}\n\\end{figure}\n\n\n\n\\subsection{Recurent Neural Network(RNN)}\nThe Recurrent Neural Network is a Network, which has been designed for the analysis of sequential data such as \nvideos and speechs. \nThe particularity of the RNN is that, the information are not only sent forward but also backward \nthrough the network; this means, the RNNs have loops and also self-feedback loops.\nAdditionally RNNs have a short memory. \n\nThe figure(\\ref{Abb:schema_rnn}) shows a general model on how the RNN is representated.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[height=0.3\\textheight]{rnn}\n\t\\caption[Schema Recurrent Neural Network]{Representation of the Recurrent Neural Network (\\cite{[1]})} \\label{Abb:schema_rnn}\n\\end{figure}\n\n\\noindent\nThe capacity to loop over the layers while training, gives the possibility to get the activation of the next layer \nby computing the current activation (got at the time \\emph{t}) with the activation of the previous \nlayer (got at the time \\emph{t-1}).\nThis example can be taken as illustration to this concept: when the network is provided with the input \"HELLO\", the RNN still knows \nby reaching the character \"E\", that \"H\" is the character trained before.\nThis helps especially on sequential data like speechs because each words pronounced have to be saved and not \nimmediately thrown away after working on it.\nThis is not possible by DFFNN and CNN because they have no memory. It is the reason why RNNs have became the state-of-art in natural \nlanguage processing(handwriting, speech, etc.).(\\cite{[6]}, p.2)\nThe main type of the RNN is the Long-short Term Memory (LSTM) because it does not conserves its memory only for a \nshort moment but for a long period of time. \nLSTM memory has a read and write function as the one of a computer, with the only difference that \nits memory is analog and not digital. (\\cite{[7]})\n\n\\noindent\nA custom model was not built for this network type. But a tool called \\emph{Tesseract-ocr engine}(\\cite{[11]}) (which already contains \nthe built LSTM), was used. \nDevelopped from Hewlett Packard betweeen 1984 and 1994 and later taken over from Google(2006), tesseract-ocr \nis an open source for the extraction of texts from images. \nIt has a considerable quantity of models for recognition, available in about two hundred different languages. \nDespite the fact that tesseract excellently performs the recognition of printed texts, it is inconsistent by the \nprediction on handwritten texts. \nNevertheless, tesseract can learn to recognize handwriting, when a custom dataset is built and trained on it. \nThis is the reason why the SWTP-AI dataset previously presented has been created.\nIn the following, the general trainings process of tesseract will be explained.\n\n\\subsubsection{Use tesseract to generate a model for text recognition}\n\n\\begin{itemize} \\bfseries\n\t\\item Installation of dependecies\n\\end{itemize}\nFirstly tesseract-ocr was installed on linux operating system to execute the training process from the command line. \nThen the JTessboxeditor was also installed but this time on windows for the labelling of the data. \nThe labelling and the training could happen directly from the JTessBoxEditor because it has integrated functionalities \nto perform both tasks and therefore generate new fonts (models) for tesseract.\nBut the goal was first of all to learn and understand step by step, how this training works in the background; reason why it has \nbeen done on Linux kernel.\nSince python is used on this project, there is a need to have a module which can be connected with tesseract on local system, \nin order to use some functions on python for predictions with tesseract. \nThis module name is \\emph{pytesseract}. (\\cite{[9]}, \\cite{[8]})\nThe installation of tesseract and pytesseract with all necessary packages can be followed here(\\cite{[9]})\n\n\\begin{itemize} \\bfseries\n\t\\item Labelling handwritten characters for the training\n\\end{itemize}\nAbout 15 full and long texts have been written from differents persons to have a diversity and a flexibility when using the new model.\nWhen each character of those texts has to be labelled from hand it would have taken too much time. \nTherefore, this step was taken off from JTessBoxEditor.\nThe labelling consists on correcting wrong characters and box coordinates.\n\nAn Example of this can be found on in the figure below.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[width=1.0\\textwidth]{jtessEditing}\n\t\\caption[Labelling with JTEssboxEditor]{Example of Labelling with JTessBoxEditor} \\label{Abb:jtess_editing}\n\\end{figure}\n\nThe picture left shows the characters after they have been predicted and surrounded by boxes using tesseract. \nBut some of the predictions are wrong and it is not possible to correctly train the network with such errors. \nHence the need for labelling.\nAfter labelling with JTessBoxEditor as shown in the picture on the right, the characters are all correct and ready for training. \n\n\\begin{itemize} \\bfseries\n\t\\item Training tesseract-ocr on SWTP-AI dataset \n\\end{itemize}\nThe lifecycle from the labelling up to the obtain of the ready model (also called font) will be explained using the figure(\\ref{Abb:tess_training}):\nFor better understanding, the example is done for only one word.\n\n\\begin{figure}[htb]\n\t\\centering\n\t\\includegraphics[scale=0.8]{tesseract_training}\n\t\\caption[From writting to trained data File]{Process to get a ready model for training(.traineddata file)} \\label{Abb:tess_training}\n\\end{figure}\n\nThe case treated here is to build a model using tesseract which can recognizse the word \"Backer\". \ntesseract does not necessarily need an image preprocessing.\n\n\\noindent\nIt is firstly important to clarify some concepts like (\\cite{[10]}): \n\\begin{itemize}\n    \\item \\emph{lang}: is the font language\n    \\item \\emph{font}: is the name of the font\n    \\item \\emph{exp0}: used to tag the the box name used. \n\t\\item The \"exp\" varies from exp0 to expn, depending on how many files is used fot the training.\n\\end{itemize}\nThe word is firstly written per hand and converted to a .tif format so that, tesseract can be able to use it. \nThe conversion is done with the \\emph{IMageMagick} tool. The file resulting has the name \\emph{lag.font.exp0.tif}:\nthis is a standard naming convention\nAfterwards the .tif format is sent to tesseract and boxes are made as well as each characters predicted. \nThe .tif file and the .box files obtained from tesseract are saved in the same folder. \nIt is required to save both in the same folder for JTessBoxEditor to recognize them by their names. \nOnce in the Editor, the errors are corrected and box coordinates are also correctly adjusted. \nThe changes are saved and the two files are sent back to tesseract for the training. \nAnd after the training all resulting files are combined and the output is a binary file ready  for the prediction process. \nAll fonts have the extension \\emph{.traineddata}.   \nThis is generally how the training works.  \n\n\\newpage\n\n\n", "meta": {"hexsha": "af3de353a3e66fc1c0f037ea7dc75a365ed970dc", "size": 25948, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/src/chapters/developer/networks.tex", "max_stars_repo_name": "Nauheimer/swtp-ocr", "max_stars_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/src/chapters/developer/networks.tex", "max_issues_repo_name": "Nauheimer/swtp-ocr", "max_issues_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/src/chapters/developer/networks.tex", "max_forks_repo_name": "Nauheimer/swtp-ocr", "max_forks_repo_head_hexsha": "5590a510bfee81f2ac48ea4b56ea6c6bd48607be", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.3602015113, "max_line_length": 157, "alphanum_fraction": 0.7895020811, "num_tokens": 6097, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.40084486228289995}}
{"text": "\\documentclass[11pt]{article}\n\n\\usepackage[margin=1.0in]{geometry}\n\\usepackage{titling}\n\\usepackage{graphicx}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\\setlength{\\droptitle}{0em} \n\n\\title{Description of the contact matrix extrapolation}\n\n\\begin{document}\n\\maketitle\n\n\\newcommand{\\myCountry}{the Philippines}\n\\newcommand{\\myProxyCountry}{China}\n\\newcommand{\\myProxyCountryDate}{2017}\n\\newcommand{\\myProxyCountryReference}{\\cite{RN10}}\n\n\n\\subsection{Contact matrices calculation}\nFor each location $L$ (home, school, work, other locations) the age-specific contact matrix $\\mathbf{C^L} = (c_{i,j}^L) \\in \\mathbb{R}_{+}^{16 \\times 16}$ is defined such that $c_{i,j}^L$ is the average number of contacts that a typical individual aged $i$ has with individuals aged $j$. As there is no contact survey avalaible for \\myCountry{}, the matrices $\\mathbf{C^L}$ were obtained by extrapolating contact matrices from \\myProxyCountry{}, where a contact survey was conducted in \\myProxyCountryDate{} \\myProxyCountryReference{}. The original matrices from \\myProxyCountry{} are denoted $\\mathbf{Q^L} = (q_{i,j}^L) \\in \\mathbb{R}_{+}^{16 \\times 16}$, where $q_{i,j}^L$ is defined using the same convention as for $c_{i,j}^L$. The matrices $\\mathbf{Q^L}$ were extracted using the R package ``socialmixr'' (v 0.1.8) and the next paragraph describes how these contact matrices were then adjusted to account for age distribution differences between \\myCountry{} and \\myProxyCountry{}.\n\n\nLet $\\pi_j$ denote the proportion of people aged $j$ in \\myCountry{}, and $\\rho_j$ the proportion of people aged $j$ in \\myProxyCountry{}. The contact matrices $\\mathbf{C^L}$ were obtained from:\n$$\nc_{i,j}^L = q_{i,j}^L \\times \\frac{\\pi_j}{\\rho_j} . \n$$\n\n\n\\end{document}", "meta": {"hexsha": "350a301d8dc9e89f2c3a256a0720878f30f5e1a0", "size": 1739, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/tex/tex_descriptions/models/covid_19/mixing_matrix/contacts_extrapolation.tex", "max_stars_repo_name": "emmamcbryde/AuTuMN-1", "max_stars_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2020-03-11T06:15:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T03:38:35.000Z", "max_issues_repo_path": "docs/tex/tex_descriptions/models/covid_19/mixing_matrix/contacts_extrapolation.tex", "max_issues_repo_name": "emmamcbryde/AuTuMN-1", "max_issues_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 96, "max_issues_repo_issues_event_min_datetime": "2020-01-29T05:10:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T01:48:46.000Z", "max_forks_repo_path": "docs/tex/tex_descriptions/models/covid_19/mixing_matrix/contacts_extrapolation.tex", "max_forks_repo_name": "emmamcbryde/AuTuMN-1", "max_forks_repo_head_hexsha": "b1e7de15ac6ef6bed95a80efab17f0780ec9ff6f", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-24T00:38:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-19T16:19:03.000Z", "avg_line_length": 54.34375, "max_line_length": 986, "alphanum_fraction": 0.7441058079, "num_tokens": 512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.4008448584221089}}
{"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{MAT257 Notes}\n\\author{Jad Elkhaleq Ghalayini}\n\\date{October 12 2018}\n\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsthm}\n\\usepackage{mathtools}\n\\usepackage{enumitem}\n\\usepackage{graphicx}\n\\usepackage{cancel}\n\n\\usepackage[margin=1in]{geometry}\n\n\\newtheorem{theorem}{Theorem}\n\\newtheorem{lemma}{Lemma}\n\\newtheorem{definition}{Definition}\n\\newtheorem*{corollary}{Corollary}\n\\newtheorem{exercise}{Exercise}\n\n\\newcommand{\\reals}[0]{\\mathbb{R}}\n\\newcommand{\\nats}[0]{\\mathbb{N}}\n\\newcommand{\\ints}[0]{\\mathbb{Z}}\n\\newcommand{\\rationals}[0]{\\mathbb{Q}}\n\\newcommand{\\brac}[1]{\\left(#1\\right)}\n\\newcommand{\\sbrac}[1]{\\left[#1\\right]}\n\\newcommand{\\mc}[1]{\\mathcal{#1}}\n\\newcommand{\\eval}[3]{\\left.#3\\right|_{#1}^{#2}}\n\\newcommand{\\ip}[2]{\\left\\langle#1,#2\\right\\rangle}\n\\newcommand{\\prt}[2]{\\frac{\\partial #1}{\\partial #2}}\n\n\\begin{document}\n\n\\maketitle\n\n\\section*{The Implicit Function Theorem}\n\nIn this course, we have three important theorems, of which this is one. Each is a generalization of something you've seen in first year calculus, but we'll see that these generalizations are very far-reaching and involve new techniques. Let's begin with a brief ``plan'' for the next month:\n\n\\subsection*{Plan}\n\\begin{enumerate}\n  \\item Today: the inverse function theorem\n  \\item The inverse function theorem, which we'll see is equivalent.\n  \\item Proof of the inverse function theorem (which will take a few lectures)\n  \\item Implications of the implicit function theorem, in particular applications to extreme value problems, introducing the idea of Lagrange Multipliers. Afterwards, we'll talk about the idea of a differentiable manifold.\n\\end{enumerate}\nSo this is what we're aiming to do in the next few weeks.\n\n\\subsection*{The Inverse Function Theorem}\nRecall: suppose \\(f: \\reals \\to \\reals\\) is a continuously differentiable function in an open inverval containing \\(a\\), and \\(f'(a) \\neq 0\\). Then \\(f'\\) is either greater than or lessthan zero in an open interval containing \\(a\\). Therefore \\(f\\) is one-to-one, and so has an inverse defined on an open interval \\(W\\) containing \\(f(a)\\). Moreover, \\(f^{-1}\\) is differentiable, and\n\\[(f^{-1})'(f(a)) = \\frac{1}{f'(a)}\\]\nWe're going to discuss a generalization of this idea to several variables.\n\n\\begin{theorem}[Inverse Function Theorem]\n  Let \\(f: U \\to \\reals^n\\) be a continuously differentiable (\\(\\mc{C}^1\\)) on an open set \\(U \\subset \\reals^n\\). Let \\(a \\in U\\) be such that \\(\\det f'(a) \\neq 0\\). Then there exist open sets \\(a \\in V, f(a) \\in W\\) such that \\(f: V \\to W\\) with a continuous inverse \\(f^{-1}: W \\to V\\). Moreover, \\(f^{-1}\\) is differentiable on \\(W\\) and\n  \\[\\forall y \\in W, (f^{-1})'(y) = (f'(f^{-1}(y)))^{-1}\\]\n\\end{theorem}\nRemark: if we know already that \\(f^{-1}\\) is differentiable, the formula for it follows from the chain rule:\n\\[f(f^{-1})(y) = y \\implies f'(f^{-1}(y))(f^{-1})'(y) = I \\iff (f^{-1})'(y) = (f(f^{-1}(y)))^{-1}\\]\n\\begin{corollary}\n  \\begin{enumerate}\n    \\item \\(f^{-1}\\) is continuously differentiable (\\(\\mc{C}^1\\))\n    \\item If \\(f\\) is \\(\\mc{C}^r\\) then \\(f^{-1}\\) is also \\(\\mc{C}^r\\)\n  \\end{enumerate}\n\\end{corollary}\n\\begin{proof}\n  \\begin{enumerate}\n\n    \\item  We know that since \\(f'\\) is continuous, and \\(f^{-1}\\) is continuous, \\(f' \\circ f^{-1}\\) is continuous. Now what about the inversion? What is the inverse of a matrix? It's given by a formula. So this is really a composite of 3 functions. So what about the formula for the inverse of a matrix? It follows from Cramer's rule that this formula is continuous, since the entries of the inverse matrix \\(B\\) of \\(A\\) are given as rational functions of the entries of \\(A\\), that is,\n    \\[b_{ij} = \\frac{(-1)^{i + j}\\det A^{ji}}{\\det A}\\]\n    where \\(A^{ji}\\) is the matrix obtained by deleting the \\(j^{th}\\) row and \\(i^{th}\\) column from \\(A\\). So hence the derivative, being the composition of 3 continuous functions, must be continuous.\n\n    \\item We proceed by induction on \\(r\\). Assume that if \\(f\\) is \\(\\mc{C}^{r - 1}\\), then \\(f^{-1}\\) is \\(\\mc{C}^{r - 1}\\).\n\n    If \\(f\\) is \\(\\mc{C}^r\\), then \\(f\\) is \\(\\mc{C}^{r - 1}\\) implying that \\(f^{-1}\\) is \\(\\mc{C}^{r - 1}\\) by the inductive hypotheis. So, using the formula\n    \\[(f^{-1})' = (f'(f^{-1}))^{-1}\\]\n    is \\(\\mc{C}^{r - 1}\\) implying that \\(f^{-1}\\) is \\(\\mc{C}^r\\).\n\n  \\end{enumerate}\n\\end{proof}\nThis corollary is just to show that we could have stated the above theorem in a stronger way. Examples:\n\\begin{enumerate}\n  \\item Continuity of \\(f'\\) cannot be removed from the hypotheses: consider \\(f: \\reals \\to \\reals\\),\n  \\[f(x) = \\left\\{\\begin{array}{cc}x + x^2\\sin\\frac{1}{x} & x \\neq 0 \\\\ 0 & x = 0\\end{array}\\right.\\]\n  We have that\n  \\[x \\neq 0 \\implies f'(x) = 1 + 2x\\sin\\frac{1}{x} - \\cos\\frac{1}{x}\\]\n  but the limit does not exist as \\(x \\to 0\\).\n\n  \\item Consider \\(f: \\reals^2 \\to \\reals^2\\),\n  \\[f(x, y) = (e^x\\cos y, e^x\\sin y)\\]\n  We have\n  \\[f'(x, y) = \\begin{pmatrix} e^x\\cos y & -e^x\\sin y \\\\ e^x\\sin y & e^x\\cos y \\end{pmatrix}\\]\n  implying that\n  \\[\\det f'(x, y) = (e^x)^2 = e^{2x} \\neq 0 \\forall x \\in \\reals\\]\n  But this function is not 1-1, since it is periodic in \\(y\\). The inverse function theorem says that we can make some neighborhood around a point where \\(f\\) is one to one, but it \\textit{doesn't} say that it's \\textit{globally} one to one.\n\n\\end{enumerate}\nRemarks:\n\\begin{enumerate}\n  \\item \\(f\\) may be invertible even though \\(f'(a) = 0\\)\n\\end{enumerate}\n\n\\end{document}\n", "meta": {"hexsha": "9b628f29b4d4dacf9450a94788e01805c0e94f62", "size": 5519, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/october12.tex", "max_stars_repo_name": "imbrem/mat257-notes", "max_stars_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/october12.tex", "max_issues_repo_name": "imbrem/mat257-notes", "max_issues_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/october12.tex", "max_forks_repo_name": "imbrem/mat257-notes", "max_forks_repo_head_hexsha": "965b1a0e5e5aae44577c5ed58e98623af1f4560d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.5794392523, "max_line_length": 489, "alphanum_fraction": 0.658271426, "num_tokens": 1859, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.40083539663669904}}
{"text": "\\section{Genetic drift and Neutral alleles}\n\n\n\n\n\n\n\\subsection{Comparing polymorphism and divergence}\n\n\n\\subsection{Deviations from the constant population model.}\nWe've seen previously that changes in our population size can be\ncaptured by an effective population size. However, this will only be a\nuseful measure if population sizes vary rapidly enough, that the\nharmonic mean effective population size over short time periods ($\\ll\nN_e$ generations) is representative of the effective population size averaged over\nlonger time periods. If this is not the case there is no one effective\npopulation size, as we can not approximate our rate of drift by a\nsingle constant population. Furthermore, we've ignored the effect of\npopulation structure and selection which will violate our modeling\nassumptions. \\\\\n\nWe can hope to detect violations from our constant population size\nneutral model, by comparing aspects of our dataset to their expectations\nand distributions under our neutral model. \\\\\n\nFor example we have devised two estimates of $\\theta$,\n$\\widehat{\\theta_{\\pi}}$ and $\\widehat{\\theta_{W}}$, using\nexpectations of different aspects of our data (pairwise diversity and\nnumber of segregating sites respectively). Under our constant neutral\nmodel if we have sufficient data those two estimates should be\nequal to each other on average. But if there's some violation of our model they might not\nbe. So one test statistic might be to take\n\\begin{equation}\nD = \\widehat{\\theta_{\\pi}} - \\widehat{\\theta_{W}}\n\\end{equation}\nwhich will be zero in expectation if our data was generated by a\nneutral constant population model.\n\n\n\n\n\\newpage\n", "meta": {"hexsha": "d8b88077bb1e579cd7c1e88ed9fa8bfc1ca22f81", "size": 1639, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/chapter-07.tex", "max_stars_repo_name": "emjosephs/popgen-notes", "max_stars_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 471, "max_stars_repo_stars_event_min_datetime": "2015-02-04T23:51:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-20T15:40:37.000Z", "max_issues_repo_path": "Chapters/chapter-07.tex", "max_issues_repo_name": "emjosephs/popgen-notes", "max_issues_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2015-12-03T23:14:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-03T18:10:54.000Z", "max_forks_repo_path": "Chapters/chapter-07.tex", "max_forks_repo_name": "emjosephs/popgen-notes", "max_forks_repo_head_hexsha": "30b596262543aca87d761365d4e0bf73480559c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 103, "max_forks_repo_forks_event_min_datetime": "2015-02-05T01:36:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-16T15:08:35.000Z", "avg_line_length": 37.25, "max_line_length": 89, "alphanum_fraction": 0.7956070775, "num_tokens": 358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.5350984286266116, "lm_q1q2_score": 0.40083539064197843}}
{"text": "\\chapter{Optimizations on low-level representation}\n\n\\section{Register allocation}\n\n\\subsection{Estimated distance of use}\n\nWe define a metric associated with every control arc in the flow\ngraph.  The metric is called \\emph{Estimated Distance to Use} or EDU\nfor short.  It assigns a number to each lexical variable, reflecting\nhow far in the future that lexical variable is needed.  The EDU metric\nis a generalization of \\emph{liveness} information, where and EDU\nvalue of $\\infty$ means that the variable is dead.\n\nFor some instruction $I$ with an incoming control arc $A$ and a\nvariable $V$ that is read or written by $I$, the EDU value of $V$ in\n$A$, is defined to be $1$, i.e. $E(V)_A = 1$.\n\nFor some instruction $I$ with an incoming control arc $A$ and a single\noutgoing control arc $B$ such that $V$ is neither read nor written by\n$I$, if $E(V)_B \\not = \\infty$ the EDU value of $V$ in $A$, $E(V)_A =\n1 + E(V)_b$ where $E(V)_b$ is the EDU value of $V$ in $B$.  If\n$E(V)_b = \\infty$, then $E(V)_A = \\infty$ as well.\n\nFor some instruction $I$ with an incoming control arc $A$ and two\noutgoing control arcs $B_1$ $B_2$ such that $V$ is neither read nor\nwritten by $I$, the EDU value of $V$ in $A$, we compute $E(V)_A$ as\nfollows.  Let $p_1$ be the estimated probability that the control arc\n$B_1$ will be used, and $p_2$ be the estimated probability that the\ncontrol arc $B_2$ will be used.  If $E(V)_{B_1} \\not = \\infty$ and\n$E(V)_{B_2} \\not = \\infty$ then $E(V)_A = 1 + {{E(V_{B_1})E(V_{B_2})}\n  \\over {p_2 E(V_{B_1}) + p_1 E(V_{B_2})}}$.  If $E(V)_{B_1} = \\infty$\nand $E(V)_{B_2} \\not = \\infty$ then $E(V)_A = 1 + {{E(V_{B_2})} /\n  p_2}$.  If $E(V)_{B_1} \\not = \\infty$ and $E(V)_{B_2} = \\infty$ then\n$E(V)_A = 1 + {{E(V_{B_1})} / p_1}$.  If $E(V)_{B_1} = \\infty$ and\n$E(V)_{B_2} = \\infty$ then $E(V)_A = \\infty$.\n\nWe use an iterative procedure to compute the EDU values, propagating\nfrom \\texttt{return} instructions and following control arcs in\nreverse.  This procedure does not automatically halt, because of loops\nin the control graph.  But EDU values are only approximate, so we stop\npropagating modifications when new values differ little from old\nones.\n\n\\subsection{Variable map}\n\nNext, we use the EDU values to compute a \\emph{variable map}\nassociated with each control arc in the flow graph.  The map contains\ntwo items:\n\n\\begin{enumerate}\n\\item A vector of \\emph{stack location} that are either currently in\n  use, or that that have been used in the past.  The size of the\n  vector reflects the required number of locations required in the\n  stack frame.  An element of the vector is either a lexical variable,\n  or \\texttt{nil} if the corresponding stack location contains no\n  valid datum.\n\\item A vector with the same size as the number of registers\n  available.  An element of the vector is either a lexical variable,\n  or \\texttt{nil} if the corresponding register contains no valid\n  datum.\n\\end{enumerate}\n\nFor a particular control arc, every live variable is contained either\nin the first vector, in the second vector, or in both vectors.  For\nthe time being, we imagine that a lexical variable can be present in\nat most one register and in at most one stack location.\n\nInitially, suppose we have a load/store architecture, so that the flow\ngraph contains instructions that require all their operands in\nregisters.  We assume that the flow graph does not contain any\n\\texttt{load} or \\texttt{store} instructions.\n\nWe compute variables maps from the start of the flow graph.  The\ninitial map contains the situation upon function entry, as dictated by\nthe function-call protocol.  For all other control arcs, initialize\nall maps to \\emph{unknown}.\n\nLet $I$ be an instruction with a single incoming control arc $A$.  For\neach Variable $V$ such that $E(V)_A = 1$, we must make sure that $V$\nis in a register before $I$ is executed.  If $V$ is already in a\nregister, no action needs to be taken.  If $V$ is in a stack location,\nand there is at least one register containing no valid datum, then\nemit a \\texttt{load} instruction and update the map.  If $V$ is in a\nstack location, but every register contains some valid datum, then we\nmust choose a \\emph{victim}, i.e. a lexical variable $W$ that is\ncurrently in a register.  The decision depends on whether $W$ is also\npresent in a stack location, and on $E(W)_a$.  It is preferable to\nchoose a $W$ with a large value of $E(W)_a$ and it is preferable to\nchoose one that is also present in some stack location.  If a $W$ is\nchosen that is also present in a stack location, then a \\texttt{load}\ninstruction is emitted to load $V$ to the register previously occupied\nby $W$ and the map is updated accordingly.  If $W$ is not present in a\nstack location, then a \\emph{store} instruction must first be emitted\nto store the variable into a stack location.  If all stack locations\nare occupied, then the vector of stack locations will have its size\nincreased.\n\nNow, let $I$ be an instruction with several incoming control arcs.%\n\\footnote{To be continued.}\n", "meta": {"hexsha": "eaea2d9c3dde2cd3d309a5963c22af9144d7b515", "size": 5020, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Code/Cleavir/Documentation/chap-low-level-optimizations.tex", "max_stars_repo_name": "gwerbin/SICL", "max_stars_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 842, "max_stars_repo_stars_event_min_datetime": "2015-01-12T15:44:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T14:03:04.000Z", "max_issues_repo_path": "Code/Cleavir/Documentation/chap-low-level-optimizations.tex", "max_issues_repo_name": "gwerbin/SICL", "max_issues_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 85, "max_issues_repo_issues_event_min_datetime": "2015-03-25T00:31:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-18T11:06:19.000Z", "max_forks_repo_path": "Code/Cleavir/Documentation/chap-low-level-optimizations.tex", "max_forks_repo_name": "gwerbin/SICL", "max_forks_repo_head_hexsha": "ec5cc25de783ecce373081ab72d2a04359155ad6", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 80, "max_forks_repo_forks_event_min_datetime": "2015-03-06T12:52:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T05:30:33.000Z", "avg_line_length": 50.2, "max_line_length": 70, "alphanum_fraction": 0.7336653386, "num_tokens": 1463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.5350984286266116, "lm_q1q2_score": 0.4008353846472576}}
{"text": "% !TEX TS-program = pdflatex\n% !TEX encoding = UTF-8 Unicode\n\n% This is a simple template for a LaTeX document using the \"article\" class.\n% See \"book\", \"report\", \"letter\" for other types of document.\n\n\\documentclass[10pt]{article} % use larger type; default would be 10pt\n\\usepackage{amsmath , amssymb , amsthm}\n\\usepackage[table]{xcolor}\n\\usepackage{circuitikz}\n\\usepackage{subcaption}\n\\usepackage{tikz}\n\\usetikzlibrary{automata, positioning, arrows}\n\\usepackage{placeins}\n\\usepackage{centernot}\n\\usepackage{caption}\n\\usepackage{subcaption}\n\\usepackage{qtree}\n\\usepackage{latexsym}\n%\\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)\n\n\\usepackage{geometry} % to change the page dimensions\n\\geometry{a4paper} % or letterpaper (US) or a5paper or....\n \\geometry{margin=3cm} % for example, change the margins to 2 inches all round\n\n\\renewcommand{\\thesubsection}{\\thesection.\\alph{subsection}}\n\\renewcommand{\\thesubsubsection}{\\thesubsection.\\roman{subsubsection}}\n\n\\title{Fundamentals of Computing \\\\\n      \\Large Coursework 1 \\\\  MSc Data Science}\n\\author{Mark Rotchell\\\\13181875}\n\\date{}\n\\begin{document}\n\\maketitle\n\n\\pagebreak\n\\hspace{0pt}\n\\vfill\n\\begin{center}\n\\section*{Academic Declaration}\n\nI have read and understood the sections of plagiarism in the College Policy on assessment offences and confirm that the work is my own, with the work of others clearly acknowledged. I give my permission to submit my report to the plagiarism testing database that the College is using and test it using plagiarism detection software, search engines or meta-searching software.\n\\end{center}\n\\vfill\n\\hspace{0pt}\n\\pagebreak\n\\section{}\n\\subsection{}\n\\subsubsection{}\n\\begin{tabular}{c|c|c||c|c|c}\nA & B & C & A $\\vee$  B & A $\\to$ C & C $\\wedge$ $\\neg$B\\\\\n\\hline\n0 & 0 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 1 & 0 & 1 & 1 \\\\\n0 & 1 & 0 & 1 & 1 & 0 \\\\\n0 & 1 & 1 & 1 & 1 & 0 \\\\\n1 & 0 & 0 & 1 & 0 & 0 \\\\\n\\rowcolor[HTML]{CCCCCC}\n1 & 0 & 1 & 1 & 1 & 1 \\\\\n1 & 1 & 0 & 1 & 0 & 0 \\\\\n1 & 1 & 1 & 1 & 1 & 0 \\\\\n\\end{tabular}\n\n\\vspace{20px}\nThe set is consistent for A=1, B=0 and C=1, as hightlighted in the above truth table\n\\subsubsection{}\n\\begin{tabular}{c|c|c||c|c|c}\nA & B & C & $\\neg$A $\\wedge$  $\\neg$B &  $\\neg$C $\\to$ A & $\\neg$C $\\vee$ B \\\\\n\\hline\n0 & 0 & 0 & 1 & 0 & 1 \\\\\n0 & 0 & 1 & 1 & 1 & 0 \\\\\n0 & 1 & 0 & 0 & 0 & 1 \\\\\n0 & 1 & 1 & 0 & 1 & 1 \\\\\n1 & 0 & 0 & 0 & 1 & 1 \\\\\n1 & 0 & 1 & 0 & 1 & 0 \\\\\n1 & 1 & 0 & 0 & 1 & 1 \\\\\n1 & 1 & 1 & 0 & 1 & 1 \\\\\n\\end{tabular}\n \n\\vspace{20px}\nThe set is not consistent as there exists no set of truth values for ${A, B, C}$ such that all of the formulae in the set are true\n\n\\subsection{}\n\n\\begin{tabular}{c|c|c||c|c|c|c}\nA & B & C & $p_1=\\neg(A\\wedge B)$ & $p_2 = C \\to A$ &  $p_3 = C \\wedge B$ & $(p_1 \\wedge p_2 \\wedge p_3) \\to C$\\\\\n\\hline\n0 & 0 & 0 & 1 & 1 & 0 & 1 \\\\\n0 & 0 & 1 & 1 & 0 & 0 & 1 \\\\\n0 & 1 & 0 & 1 & 1 & 0 & 1 \\\\\n0 & 1 & 1 & 1 & 0 & 1 & 1 \\\\\n1 & 0 & 0 & 1 & 1 & 0 & 1 \\\\\n1 & 0 & 1 & 1 & 1 & 0 & 1 \\\\\n1 & 1 & 0 & 0 & 1 & 0 & 1 \\\\\n1 & 1 & 1 & 0 & 1 & 1 & 1 \\\\\n\\end{tabular}\n\n\\vspace{20px}\nThe argument is logically correct. There exist no situations in which all of the premises are true and the conclusion is false.\n\\section{}\n\\subsection{}\n\\begin{tabular}{c|c|c||c|c|c}\nA & B & C & $A \\to \\neg B$ & $C \\to A$ & $\\neg\\left((A \\to \\neg B)\\wedge(C \\to A)\\right)$\\\\\n\\hline\n0 & 0 & 0 & 1 & 1 & 0 \\\\\n0 & 0 & 1 & 1 & 0 & 1 \\\\\n0 & 1 & 0 & 1 & 1 & 0 \\\\\n0 & 1 & 1 & 1 & 0 & 1 \\\\\n1 & 0 & 0 & 1 & 1 & 0 \\\\\n1 & 0 & 1 & 1 & 1 & 0 \\\\\n1 & 1 & 0 & 0 & 1 & 1 \\\\\n1 & 1 & 1 & 0 & 1 & 1 \\\\\n\\end{tabular}\n\n\\vspace{20px}\n\\subsection{}\n\\begin{center}\n\\begin{circuitikz} \\draw\n(0,4) node (B) {B}\n(0,2) node (A) {A}\n(0,0) node (C) {C}\n(1.5,1.5) node[not port] (notA) {}\n(4,3) node[and port] (andAB) {}\n(4,1) node[and port] (andAC) {}\n(6,2) node[or port] (or) {}\n(B) -- (andAB.in 1)\n(A) -- (andAB.in 2)\n(A) -- (notA.in)\n(notA.out) -- (andAC.in 1)\n(C) -- (andAC.in 2)\n(andAB.out) -- (or.in 1)\n(andAC.out) -- (or.in 2);\n\\end{circuitikz}\n\\end{center}\n\n\\subsection{}\n\\[\n\\begin{aligned}\n       & \\neg ((     A \\to  \\neg B) \\wedge   (     C \\to  A)  ) \\\\\n\\equiv & \\neg ((\\neg A \\vee \\neg B) \\wedge   (     C \\to  A)  ) \\\\\n\\equiv & \\neg ((\\neg A \\vee \\neg B) \\wedge   (\\neg C \\vee A)  ) \\\\\n\\equiv & \\neg ((\\neg B \\vee \\neg A)  \\wedge   (\\neg C \\vee A)  ) \\\\\n\\equiv & \\neg ((     B \\to  \\neg A)  \\wedge   (\\neg C \\vee A)  ) \\\\\n\\equiv &       \\neg(      B \\to  \\neg A)  \\vee \\neg(\\neg C \\vee A) \\\\\n\\equiv &       \\neg(      B \\to  \\neg A)  \\vee     (C \\wedge \\neg A) \\\\\n\\equiv &           (      B \\to  \\neg A) \\to     (C \\wedge \\neg A) \\\\\n\\end{aligned}\n\\]\n\n\\section{}\n\\begin{center}\n$N = A_2 \\cdot 2^2 + A_1 \\cdot 2^1 + A_0 \\cdot 2^0$\\\\\n\n\\vspace{20px}\n\n\\begin{tabular}{c|c|c||c|c|c}\n$A_2$ & $A_1$ & $A_0$ & $N<3_{10}$ & $A_1 \\wedge A_0$ & $A_2 \\downarrow (A_1 \\wedge A_0)$\\\\\n\\hline\n0 & 0 & 0 & 1 & 0 & 1 \\\\\n0 & 0 & 1 & 1 & 0 & 1 \\\\\n0 & 1 & 0 & 1 & 0 & 1 \\\\\n0 & 1 & 1 & 0 & 1 & 0 \\\\\n1 & 0 & 0 & 0 & 0 & 0 \\\\\n1 & 0 & 1 & 0 & 0 & 0 \\\\\n1 & 1 & 0 & 0 & 0 & 0 \\\\\n1 & 1 & 1 & 0 & 1 & 0 \\\\\n\\end{tabular}\n\n\\vspace{20px}\n\n\\begin{circuitikz} \\draw\n(0,0) node (A2) {$A_2$}\n(0,1) node (A1) {$A_1$}\n(0,3) node (A0) {$A_0$}\n(2,2) node[and port] (and01) {}\n(4,1) node[nor port] (nor) {}\n(A0) -- (and01.in 1)\n(A1) -- (and01.in 2)\n(and01.out) -- (nor.in 1)\n(A2) -- (nor.in 2)\n;\n\\end{circuitikz}\n\\end{center}\n\\section{}\nThe argument is not correct. With the following propositional variables:\n\\renewcommand{\\labelenumi}{\\Alph{enumi}}\n\\begin{enumerate}\n\\item : 'Jones did not meet Smith last night'\n\\item : 'Smith was the murderer'\n\\item : 'Jones is lying'\n\\item : 'The murder took place after midnight'\n\\end{enumerate}\nthe propositions can be summarized as:\n\\renewcommand{\\labelenumi}{$p_{\\arabic{enumi}}$}\n\\begin{enumerate}\n\\item $= A \\to (B\\vee C)$\n\\item $= \\neg B \\to (A \\wedge D)$\n\\item $= D \\to (B \\vee C)$\n\\end{enumerate}\n\nThese propositions can all be true whilst the conclusion is false, as show by the below row from the truth table, therefore the argument is not correct\n\n\\vspace{20px}\n\n\\begin{tabular}{c|c|c|c||c|c|c}\nA & B & C & D & $p_1 = A \\to (B\\vee C)$ & $p_2= \\neg B \\to (A \\wedge D)$ & $p_3= D \\to (B \\vee C)$ \\\\\n\\hline\n\\multicolumn{4}{c||}{$\\cdots$} & \\multicolumn{3}{c}{$\\cdots$} \\\\\n1 & 0 & 1 & 1 & 1 & 1 & 1\\\\\n\\multicolumn{4}{c||}{$\\cdots$} & \\multicolumn{3}{c}{$\\cdots$} \\\\\n\\hline\n\\end{tabular}\n\\section{}\n\\subsection{}\n\nInitial digit is a {\\ttfamily 1} therefore number is negative. Finding absolute value via following steps:\n\\begin {tabbing}\nInitial word \\hspace{30px} \\= {\\ttfamily 1100 0001 1011 0000 0000 0000 0000 0000} \\\\\nInvert digits \\>   {\\ttfamily 0011 1110 0100 1111 1111 1111 1111 1111} \\\\\nAdd one \\> {\\ttfamily \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 1}\\\\\nResult \\> {\\ttfamily 0011 1110 0101 0000 0000 0000 0000 0000} \\\\\n\\> $=2^{29}+2^{28}+2^{27}+2^{26}+2^{25}+2^{22}+2^{20}=1,045,430,272_{10}$ \n\\end{tabbing}\nTherefore the number is $-1,045,430,272_{10}$\n\\subsection{}\n\\begin{center}\n{\\ttfamily 1100 0001 1011 0000 0000 0000 0000 0000}\n\n$=2^{31}+2^{30}+2^{24}+2^{23} + 2^{21} + 2^{20}=3,249,537,024_{10}$\n\\end{center}\n\\subsection{}\n\\begin{center}\n{\\ttfamily 1 $\\Big|$ 100 0001 1 $\\Big|$ 011 0000 0000 0000 0000 0000}\n\\end{center}\n\nSign bit is {\\ttfamily 1}, so $S = 1$.\n\nExponent bits are {\\ttfamily 100 0001 1} $=2^7+2^1+2^0=131$, and the bias is 127, so $E=131-127=4$.\n\nFraction bits are {\\ttfamily 011 000 \\ldots}, so $F=1+2^{-2}+2^{-3} = 1\\dfrac{3}{8}$\n\nSo number is $(-1)^S \\cdot F \\cdot 2^ E = -1 \\cdot 1\\dfrac{3}{8} \\cdot 2^4 = -22$\n\\section{}\n\\subsection{}\nFirst find binary representation of $|-107| = 107$\n\\[\n\\begin{aligned}\n107 / 2 = 53 \\text{ remainder } & \\mathtt{1} \\\\\n53 / 2 = 26 \\text{ remainder } & \\mathtt{1} \\\\\n26 / 2 = 13 \\text{ remainder } & \\mathtt{0} \\\\\n13 / 2 = 6 \\text{ remainder } & \\mathtt{1} \\\\\n6 / 2 = 3 \\text{ remainder } & \\mathtt{0} \\\\\n3 / 2 = 1 \\text{ remainder } & \\mathtt{1} \\\\\n1 / 2 = 0 \\text{ remainder } & \\mathtt{1} \\\\\n\\end{aligned}\n\\]\nreading updwards $107_{10} = \\mathtt{110 1011}_2$, then convert to negative in two's complement via\n\\begin {tabbing}\nInitial word \\hspace{30px} \\= {\\ttfamily 0000 0000 0000 0000 0000 0000 0110 1011} \\\\\nInvert digits \\> {\\ttfamily 1111 1111 1111 1111 1111 1111 1001 0100} \\\\\nAdd one \\> {\\ttfamily \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 1}\\\\\nResult \\> {\\ttfamily 1111 1111 1111 1111 1111 1111 1001 0101} \\\\\n\\end{tabbing}\n\\subsection{}\n\\[-107_{10} = -\\mathtt{110 \\ 1011}_2 = -\\mathtt{1.1010 \\ 11}_2 \\times 2^6\\]\n\nSo, sign bit is {\\ttfamily 1}\n\nExponent is $6_{10} + 127_{10} = 133_{10} = \\mathtt{1000 \\ 0101}_2$\n\nFraction is $10 1011$\n\nAnd full word is\n\n\\[\\mathtt{1100 \\ 0010 \\ 1101 \\ 0110 \\ 0000 \\ 0000 \\ 0000 \\ 0000}\\]\n\\subsection{}\n\\[-14.375 = -\\left(8 + 4 + 2 + \\frac{1}{4} + \\frac{1}{8}\\right) = -\\mathtt{1110.011}_2 = -\\mathtt{1.1100 \\ 11}_2+2^3\\]\n\nSo, sign bit is {\\ttfamily 1}\n\nExponent is $3_{10} + 127_{10} = 130_{10} = \\mathtt{1000 \\ 0010}_2$\n\nFraction is $1100 \\ 11$\n\nAnd full word is\n\n\\[\\mathtt{1100 \\ 0001 \\ 0110 \\ 0110 \\ 0000 \\ 0000 \\ 0000 \\ 0000}\\]\n\n\\section{}\n\\subsection{}\n%Question 7 a\n\\[ f(x) = x+1 \\]\n\\subsection{}\n%Question 7 b\n\\[\n  f(x) =\n  \\begin{cases} \n   \\ \\dfrac{x}{2} & \\text{if} \\ x \\ \\text{is even} \\\\\n   \\\\\n   \\ \\dfrac{x-1}{2} & \\text{if} \\ x \\ \\text{is odd} \\\\\n  \\end{cases}\n\\]\n\\subsection{}\n%Question 7 c\n\\[\n  f(x) =\n  \\begin{cases} \n   \\ x + 2 & \\text{if} \\ 3 \\ \\text{divides} \\ x \\\\\n   \\ x - 1 & \\text{if} \\ 3 \\ \\text{does not divide} \\ x \\\\\n  \\end{cases}\n\\]\n\\section{}\n%Question 8\n\\subsection{}\n%Question 8 a\nNote that $f(2) = (2+1) / (2-2) = 3/0$ is undefined, so $f$ is not a function over the whole real domain as stated in the question. As it is not a function, it cannot be an injective nor surjective function, so \\underline{$f$ is not injective (one-to-one)} and \\underline{$f$ is not surjective (onto)}. \n\nHowever, considering instead $f^\\prime:\\mathbb{R}^\\prime \\to \\mathbb{R}$, where $\\mathbb{R}^\\prime = \\mathbb{R} \\setminus \\{2\\}$, given by $f^\\prime(x)=\\dfrac{x+1}{x-2}$.\n\n\\paragraph{Injectivity}\nSuppose:\n\\[\n  \\begin{aligned}\n    f^\\prime(x) &= f^\\prime(y), \\quad x,y \\in \\mathbb{R}^\\prime \\\\\n    \\dfrac{x+1}{x-2} &= \\dfrac{y+1}{y-2}\\\\\n    (x+1)(y-2) &= (y+1)(x-2) \\\\\n    xy + y -2x -2 &= xy +x -2y -2 \\\\\n    y-2x &= x - 2y \\\\\n    y &= x \\\\\n  \\end{aligned}\n\\]\nso \n\\[\n\\forall \\ x,y \\in \\mathbb{R}^\\prime : f^\\prime(x) = f^\\prime(y) \\implies x = y\n\\]\ntherefore \\underline{$f^\\prime$ is injective (one-to-one)}.\n\n\\paragraph{Surjectivity} Let $y = f^\\prime(x)$, then\n\\[\n  \\begin{aligned}\n    f^\\prime(x) = \\dfrac{x+1}{x-2} & = y \\\\\n    x+1 &= y(x-2)\\\\\n    x+1 &= xy - 2y \\\\\n    x(y - 1) &= 1+2y \\\\\n    \\end{aligned}\n\\]\n\\[ x = \\dfrac{1+2y}{y-1} \\]\n\\[\\therefore x \\ \\text{is undefined for} \\ y = 1 \\]\n\\[\\therefore \\ \\nexists \\ x \\in \\mathbb{R}^\\prime , \\ f^\\prime(x) = 1\\]\n\\[\\therefore \\ \\neg \\left(\\forall y \\in \\mathbb{R}, \\exists x \\in \\mathbb{R}^\\prime, f^\\prime(x) = y \\right) \\]\ntherefore \\underline{$f^\\prime$ is not surjective (onto)}.\n\\subsection{}\n%question 8(b)\n\\paragraph{Injectivity}\n\\[f(0,1) = 0 = f(1,0)\\]\nhowever \n\\[(0,1) \\neq (1,0)\\]\n\\[\\therefore \\neg \\left(\\forall (m,n),(p,q) \\in \\mathbb{Z} \\times \\mathbb{Z}: f(m,n) = f(p,q) \\implies (m,n) = (p,q) \\right)\n\\]\ntherefore \\underline{$f$ is not injective (one-to-one)}\n\n\\paragraph{Surjectivity} Suppose $n=1$ then $f(m,n) = f(m,1) = m + 1 -1 = m$. So, \n\n\\[\\forall y \\in \\mathbb{Z}: f(y,1) = y \\]\n\\[\\therefore \\ \\forall y \\in \\mathbb{Z}, \\ \\exists (m,n) \\in \\mathbb{Z} \\times \\mathbb{Z}, \\ f(m,n) =y \\]\ntherefore \\underline{$f$ is surjective (onto)}\n\\subsection{}\n%question 8(c)\n\n\n\\paragraph{Injectivity}\n\\[f(0,-1) = 0 = f(-1,0)\\]\nhowever \n\\[(0,-1) \\neq (-1,0)\\]\n\\[\\therefore \\neg \\left(\\forall (m,n),(p,q) \\in \\mathbb{Z} \\times \\mathbb{Z} :f(m,n) = f(p,q) \\implies (m,n) = (p,q) \\right)\n\\]\ntherefore \\underline{$f$ is not injective (one-to-one)}\n\n\n\\paragraph{Surjectivity}\n\\[\n  \\min(|m| - |n| -1) = 0 - 0 - 1 = -1\n\\]\n\\[\n  \\therefore \\nexists (m,n) \\in \\mathbb{Z} \\times \\mathbb{Z}, f(m,n) < -1\n\\]\n\\[\\therefore \\neg \\left( \\forall y \\in \\mathbb{Z}, \\exists (m,n) \\in \\mathbb{Z} \\times \\mathbb{Z}, f(m,n) =y \\right) \\]\ntherefore \\underline{$f$ is not surjective (onto)}\n\n\n\\section{}\n%Question 9\n\\subsection{}\n\\begin{center}\n{\\centering\n\\begin{minipage}[b]{0.4\\textwidth}\n\\centering\n\\begin{tabular}{c|c c c c} \n    & A & B & C & D\\\\\n    \\hline\n    A & 1 & 2 & 0 & 1\\\\\n    B & 2 & 0 & 3 & 0\\\\\n    C & 0 & 3 & 1 & 1\\\\\n    D & 1 & 0 & 1 & 0\\\\\n\\end{tabular}\n\\end{minipage}\n\\hspace{20px}\n\\centering\n\\begin{minipage}[c]{0.4\\textwidth}\n\\begin{tikzpicture}[node distance = 2.5cm]\n    \\begin{scope}[every node/.style={circle,thick,draw}]\n        \\node (A) {A};\n        \\node (B) [below of = A] {B};\n        \\node (C) [right of = B] {C};\n        \\node (D) [right of = A] {D};\n    \\end{scope}\n    \n    \\begin{scope}[every edge/.style={draw=black,thick}, every loop/.style={min distance=10mm}]\n        \\path (A) edge [loop above] (A);\n        \\path (A) edge [bend right] (B);\n        \\path (A) edge [bend left]  (B);\n        \\path (B) edge (C);\n        \\path (B) edge [bend left]  (C);\n        \\path (B) edge [bend right] (C);\n        \\path (C) edge [loop right] (C);\n        \\path (C) edge (D);\n        \\path (A) edge (D);\n    \\end{scope}\n\\end{tikzpicture}\n\\end{minipage}}\n\\end{center}\nThe graph is not simple as there are vertices with more than one edge between them.\n\\subsection{}\nLet the left hand graph be $G$ such that\n\\[\n\tG = (V_G,E_G) = (\\{1,2,3,4,5\\},\\{1,2\\},\\{1,3\\},\\{1,5\\},\\{2,3\\},\\{2,4\\},\\{4,5\\})\n\\]\nand the right graph be $H$ such that \n\\[\n\tH = (V_H,E_H) = (\\{a,c,b,d,e\\},\\{a,c\\},\\{a,b\\},\\{a,e\\},\\{c,b\\},\\{c,d\\},\\{d,e\\})\n\\]\nThen let the function $f:V_G\\to V_H$ be the vertex bijection given by the following set of pairs of the form $(v,f(v))$:\n\\[\n\t\\{(1,a),(2,c),(3,b),(4,d),(5,e)\\}\n\\]\nApplying the function $f$ to each vertex of each edge $\\{v_1,v_2\\}$ in $E_G$ gives a set of subsets, ${\\{f(v_1),f(v_2)\\} \\subset V_H}$ which is exactly $E_H$, i.e. all the edges of $H$. \n\n\\vspace{20px}\n\n\\begin{tabular}{c|c} \n\t$\\{v_1,v_2\\}$ & $\\{f(v_1),f(v_2)\\}$ \\\\\n\t\\hline\n\t\\{1,2\\} & \\{a,c\\} \\\\\n\t\\{1,3\\} & \\{a,b\\} \\\\\n\t\\{1,5\\} & \\{a,e\\} \\\\\n\t\\{2,3\\} & \\{c,b\\} \\\\\n\t\\{2,4\\} & \\{c,d\\} \\\\\n\t\\{4,5\\} & \\{d,e\\} \\\\\t\n\\end{tabular}\n\n\\vspace{20px}\n\nAll the edges from the two graphs are in above table. No set of vertices which isn't an edge is in the table. If two vertices are adjacent in $G$ their $f$-mapped vertices in $H$ are also adjacent. If two vertices are not adjacent in $G$ their $f$-mapped vertices in $H$ are also not adjacent. Formally\n\n\\[\n\\{v_1,v_2\\} \\in E_G \\iff \\{f(v_1),f(v_2)\\} \\in E_H\n\\]\ntherefore $f$ is an isomorphism and $G$ and $H$ are isomorphic.\n\n\\subsection{}\nThe two graphs have a different number of edges, which is an invariant, so the two graphs cannot be isomorphic.\n\\section{}\n\\subsection{}\n\n\\noindent Computations for $bb$:\n\n\\vspace{20px}\n\n\\begin{tikzpicture}[every node/.style = {align=center}]]\n\n \\node {$(s,bb)$}\n    child { node {$(q,b)$} \n      child {node {stuck}}\n    }\n    child { node  {$(p,bb)$}\n      child { node {$(q,b)$} \n        child {node {stuck}}\n      }\n    };\n\\end{tikzpicture}\n\n\\vspace{20px}\n\n\\begin{itemize}\n  \\item $(s,bb), (q,b)$ $\\leadsto$ stuck\n  \\item $(s,bb), (p,bb), (q,b)$  $\\leadsto$ stuck\n\\end{itemize}\n\n\\noindent word $bb$ is not accepted\n\n\\vspace{20px}\n\n\\noindent Computations for $ab$:\n\n\\vspace{20px}\n\n\\begin{tikzpicture}[every node/.style = {align=center}]]\n \\node {$(s,ab)$}\n    child { node {$(p,ab)$} \n      child {node {stuck}}\n    }\n    child { node {$(p,b)$} \n      child {node {$(q,\\epsilon)$}\n        child {node {accepted}}\n      }\n    }\n    child { node [right = 1cm] {$(s,b)$} \n      child {node {$(q,\\epsilon)$}\n        child {node {accepted}}\n      }\n      child { node {$(p,b)$} \n        child {node {$(q,\\epsilon)$}\n          child {node {accepted}}\n        }\n      }\n    }\n    ;\n\\end{tikzpicture}\n\n\\begin{itemize}\n  \\item $(s,ab), (p,ab)$ $\\leadsto$ stuck\n  \\item $(s,ab), (p,b), (q,\\epsilon)$ $\\leadsto$ accepted\n  \\item $(s,ab), (s,b), (q,\\epsilon)$ $\\leadsto$ accepted\n  \\item $(s,ab), (s,b), (p,b), (q,\\epsilon)$ $\\leadsto$ accepted\n\\end{itemize}\n\n\\noindent word $ab$ is accepted\n\n\\vspace{20px}\n\n\\noindent Computations for $aba$:\n\n\\vspace{20px}\n \n\\begin{tikzpicture}[every node/.style = {align=center}]]\n \\node {$(s,aba)$}\n    child { node {$(p,aba)$} \n      child {node {stuck}}\n    }\n    child { node [right=2mm] {$(p,ba)$} \n      child {node {$(q,a)$}\n        child {node {$(q,\\epsilon)$}\n          child {node {accepted}}\n        }\n        child {node {$(p,\\epsilon)$}\n          child {node {not \\\\ accepted}}\n        }\n      }\n    }\n    child { node [right=25mm] {$(s,ba)$}\n      child {node {$(q,a)$}\n        child {node {$(q,\\epsilon)$}\n          child {node {accepted}}\n        }\n        child {node {$(p,\\epsilon)$}\n          child {node {not \\\\ accepted}}\n        }\n      }\n      child {node [right=1cm] {$(p,ba)$}\n      child {node {$(q,a)$}\n        child {node {$(q,\\epsilon)$}\n          child {node {accepted}}\n        }\n        child {node {$(p,\\epsilon)$}\n          child {node {not \\\\ accepted}}\n        }\n      }\n      }\n    }\n    ;\n\\end{tikzpicture}\n\n\\begin{itemize}\n  \\item $(s,aba), (p,aba)$ $\\leadsto$ stuck\n  \\item $(s,aba), (p,ba), (q,a), (q,\\epsilon)$ $\\leadsto$ accepted\n  \\item $(s,aba), (p,ba), (q,a), (p,\\epsilon)$ $\\leadsto$ not accepted\n  \\item $(s,aba), (s,ba), (q,a), (q,\\epsilon)$ $\\leadsto$ accepted\n  \\item $(s,aba), (s,ba), (q,a), (p,\\epsilon)$ $\\leadsto$ not accepted\n  \\item $(s,aba), (s,ba), (p,ba), (q,a), (q,\\epsilon)$ $\\leadsto$ accepted\n  \\item $(s,aba), (s,ba), (p,ba), (q,a), (p,\\epsilon)$ $\\leadsto$ not accepted\n\\end{itemize}\n\\noindent word $aba$ is accepted\n\\subsection{}\n\\begin{center}\n\\begin{tikzpicture}[->, \n\t\t\t\t\t>=triangle 45, \n\t\t\t\t\tsemithick,\n\t\t\t\t\tnode distance=2cm, \n\t\t\t\t\tinitial text=$ $,\n\t\t\t\t\tevery loop/.style={min distance=10mm}]\n\n\\node[state] (s) at (-3,1) {$s$}; \n\\node[state] (p) at (3,1)  {$p$}; \n\\node[state, accepting] (q) at (0,-1) {$q$};\n\\draw \t(s) edge [loop above, above] node{$a$} (s)\n\t\t(s) edge [bend left=10, above] node{$a$} (p)\n\t\t(s) edge [bend right=10, below] node{$\\varepsilon$} (p)\n\t\t(s) edge [below] node{$b$} (q)\n\t\t(q) edge [bend right = 10, below] node{$a$} (p)\n\t\t(p) edge [bend right = 10, above] node{$b$} (q)\n\t\t(q) edge [loop below, below] node{$a$} (q);\n\\draw[-, semithick] (node cs:name=s,anchor=west) -- ++(-3mm,1mm);\n\\draw[-, semithick] (node cs:name=s,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\n\n\\vspace{20px}\n\n\\begin{tabular}{c|c|c}\n\tsubset of states & reachable by $a$ & reachable by $b$ \\\\\n\t& followed by one or more  $\\varepsilon$ & followed by one or more  $\\varepsilon$ \\\\\n\t\\hline\n\t$\\{s\\}$ & $\\{s,p\\}$ & $\\{q\\}$\\\\\n\t$\\{p\\}$ & $\\O$ &  $\\{q\\}$\\\\\n\t$\\{q\\}$ & $\\{p,q\\}$& $\\O$ \\\\\n\t$\\{s,p\\}$ & $\\{s,p\\}$ & $\\{q\\}$\\\\\n\t$\\{s,q\\}$ & $\\{s,p,q\\}$ & $\\{q\\}$\\\\\n\t$\\{p,q\\}$ & $\\{p,q\\}$ & $\\{q\\}$\\\\\n\t$\\{s,p,q\\}$ & $\\{s,p,q\\}$ & $\\{q\\}$\\\\\n\t$\\O$ &$\\O$  &$\\O$  \\\\\n\\end{tabular}\n\n\\vspace{20px}\n\nThe DFA starting state is the $\\varepsilon$-closure of the NFA starting state, which is $\\{s,p\\}$. All subsets with $q$ are accepting states. Full subset construction:\n\n\\vspace{20px}\n\n\\begin{center}\n\\begin{tikzpicture}[->, \n\t\t\t\t\t>=triangle 45, \n\t\t\t\t\tsemithick,\n\t\t\t\t\tnode distance=2cm, \n\t\t\t\t\tinitial text=$ $,\n\t\t\t\t\tevery loop/.style={min distance=10mm}]\n\n\t\\node[state] (s) at (-3,0) {$\\{s\\}$}; \n\t\\node[state] (p) at (3,0)  {$\\{p\\}$};\n\t\\node[state, accepting] (q) at (0,0)  {$\\{q\\}$};\n\t\\node[state] (sp) at (-2,3)  {$\\{s,p\\}$};\n\t\\node[state, accepting] (sq) at (0,-3)  {$\\{s,q\\}$};\n\t\\node[state, accepting] (pq) at (-3,-3)  {$\\{p,q\\}$};\n\t\\node[state, accepting] (spq) at (3,-3)  {$\\{s,p,q\\}$};\n\t\\node[state] (o) at (2,3)  {$\\O$};\n\t\\draw\t(s) edge [left] node{$a$} (sp)\n\t\t\t(s) edge [above] node{$b$} (q)\n\t\t\t(p) edge [right] node{$a$} (o)\n\t\t\t(p) edge [above] node{$b$} (q)\n\t\t\t(q) edge [bend right=10, above left] node{$a$} (pq)\n\t\t\t(q) edge [above left] node{$b$} (o)\n\t\t\t(sp) edge [loop right] node{$a$} (sp)\n\t\t\t(sp) edge [above right] node{$b$} (q)\n\t\t\t(sq) edge [above] node{$a$} (spq)\n\t\t\t(sq) edge [right] node{$b$} (q)\n\t\t\t(pq) edge [loop left] node{$a$} (pq)\n\t\t\t(pq) edge [bend right =10, below right] node{$b$} (q)\n\t\t\t(spq) edge [loop right] node{$a$} (sqp)\n\t\t\t(spq) edge [above right] node{$b$} (q)\n\t\t\t(o) edge [loop left] node{$a$} (o)\n\t\t\t(o) edge [loop right] node{$b$} (o)\n;\n\t \n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,1mm);\n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\n\nthen removing the unreachable states:\n\n\\begin{center}\n\\begin{tikzpicture}[->, \n\t\t\t\t\t>=triangle 45, \n\t\t\t\t\tsemithick,\n\t\t\t\t\tnode distance=2cm, \n\t\t\t\t\tinitial text=$ $,\n\t\t\t\t\tevery loop/.style={min distance=10mm}]\n\n\t\\node[state, accepting] (q) at (0,0)  {$\\{q\\}$};\n\t\\node[state] (sp) at (-3,0)  {$\\{s,p\\}$};\n\t\\node[state, accepting] (pq) at (3,0)  {$\\{p,q\\}$};\n\t\\node[state] (o) at (0,2)  {$\\O$};\n\t\\draw\t(q) edge [bend right=10, below] node{$a$} (pq)\n\t\t\t(q) edge [left] node{$b$} (o)\n\t\t\t(sp) edge [loop above] node{$a$} (sp)\n\t\t\t(sp) edge [above] node{$b$} (q)\n\t\t\t(pq) edge [loop above] node{$a$} (pq)\n\t\t\t(pq) edge [bend right =10, above] node{$b$} (q)\n\t\t\t(o) edge [loop left] node{$a$} (o)\n\t\t\t(o) edge [loop right] node{$b$} (o)\n;\n\t \n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,1mm);\n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\n\nthen re-labelling the states\n\n\\begin{center}\n\\begin{tikzpicture}[->, \n\t\t\t\t\t>=triangle 45, \n\t\t\t\t\tsemithick,\n\t\t\t\t\tnode distance=2cm, \n\t\t\t\t\tinitial text=$ $,\n\t\t\t\t\tevery loop/.style={min distance=10mm}]\n\n\t\\node[state, accepting] (q) at (0,0)  {$x$};\n\t\\node[state] (sp) at (-3,0)  {$w$};\n\t\\node[state, accepting] (pq) at (3,0)  {$z$};\n\t\\node[state] (o) at (0,2)  {$y$};\n\t\\draw\t(q) edge [bend right=10, below] node{$a$} (pq)\n\t\t\t(q) edge [left] node{$b$} (o)\n\t\t\t(sp) edge [loop above] node{$a$} (sp)\n\t\t\t(sp) edge [above] node{$b$} (q)\n\t\t\t(pq) edge [loop above] node{$a$} (pq)\n\t\t\t(pq) edge [bend right =10, above] node{$b$} (q)\n\t\t\t(o) edge [loop left] node{$a$} (o)\n\t\t\t(o) edge [loop right] node{$b$} (o)\n;\n\t \n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,1mm);\n\\draw[-, semithick] (node cs:name=sp,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\n\nwe have a deterministic finite automaton $A=(Q,\\Sigma,\\delta,q_0,F)$ with\n\\begin{itemize}\n\t\\item a set of states $Q=\\{w, x, y, z\\}$\n\t\\item a set of symbols $\\Sigma = \\{a,b\\}$\n\t\\item a transition function $f:Q \\times \\Sigma \\to Q$ given by the below table\n\t\n\t\\begin{tabular}{c|c c}\n\t\t&  \\multicolumn{2}{c}{symbol} \\\\\n\t\tstate & a & b \\\\\n\t\t\\hline\n\t\t$w$ & $w$ & $x$ \\\\\n\t\t$x$ & $z$ & $y$ \\\\\n\t\t$y$ & $y$ & $y$ \\\\\n\t\t$z$ & $z$ & $x$ \\\\\n\t\\end{tabular}\n\t\\item an initial state $q_0 = w$\n\t\\item a set of accepting states $F = \\{x, z\\}$\n\\end{itemize}\n\n\\subsection{}\nThe automaton accepts words comprised of $a$ and $b$ that contain at least one $b$, but no consecutive $b$s.\n\\subsection{}\n$\\mathtt{a^*b(aa^*b)^*a^*}$\n\\subsection{}\nLet $G=(V,\\Sigma,R,s)$ be a context free grammar with\n\\begin{itemize}\n\t\\item a set of variables $V=\\{S,X,Y\\}$\n\t\\item a set of terminals $\\Sigma = \\{a,b\\}$\n\t\\item a set of production rules $R = \\{S \\to XbYX, \\ X \\to \\varepsilon, \\ X \\to aX, \\ Y \\to \\varepsilon, \\ Y \\to aXbY\\}$\n\t\\item a start variable $s=S$\n\\end{itemize}\n\\section{}\nLet $A=(Q,\\Sigma,\\delta,q_0,F)$ be a deterministic finite automaton with\n\\begin{itemize}\n\t\\item a set of states $Q=\\{s,p,q,r\\}$\n\t\\item a set of symbols $\\Sigma = \\{1,0\\}$\n\t\\item a transition function $f:Q \\times \\Sigma \\to Q$ given by the below table\n\t\n\t\\begin{tabular}{c|c c}\n\t\t&  \\multicolumn{2}{c}{symbol} \\\\\n\t\tstate & 0 & 1 \\\\\n\t\t\\hline\n\t\t$s$ & $p$ & $s$ \\\\\n\t\t$p$ & $q$ & $p$ \\\\\n\t\t$q$ & $q$ & $r$ \\\\\n\t\t$r$ & $q$ & $p$ \\\\\n\t\\end{tabular}\n\t\\item an initial state $q_0 = s$\n\t\\item a set of accepting states $F = \\{q,r\\}$\n\\end{itemize}\nWe can visualise $A$ with the following state diagram\n\\begin{center}\n\\begin{tikzpicture}[->, \n\t\t\t\t\t>=triangle 45, \n\t\t\t\t\tsemithick,\n\t\t\t\t\tnode distance=2cm, \n\t\t\t\t\tinitial text=$ $,\n\t\t\t\t\tevery loop/.style={min distance=10mm}]\n\n\t\\node[state] (s) at (-3,0)  {$s$};\n\t\\node[state] (p) at (-1,0)  {$p$};\n\t\\node[state, accepting] (q) at (2,0)   {$q$};\n\t\\node[state, accepting] (r) at (0.5,-2)  {$r$};\n\t\\draw \t(s) edge [loop above] node{$1$} (s)\n\t\t\t(s) edge [above] node{$0$} (p)\n\t\t\t(p) edge [loop above] node{$1$} (p)\n\t\t\t(p) edge [above] node{$0$} (q)\n\t\t\t(q) edge [bend right=10, above left] node{$1$} (r)\n\t\t\t(q) edge [loop above] node{$0$} (q)\n\t\t\t(r) edge [below left] node{$1$} (p)\n\t\t\t(r) edge [below right, bend right=10] node{$0$} (q)\n\t;\n\t\\draw[-, semithick] (node cs:name=s,anchor=west) -- ++(-3mm,1mm);\n\t\\draw[-, semithick] (node cs:name=s,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\nThis can be represented by the following regular expression $\\mathtt{1^*0(0\\cup 1)^*(0\\cup 01)}$\n\\pagebreak\n\\section{}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{0.3\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state, accepting] (2) at (1,0)  {};\n    \t\\draw \t(1) edge [above] node{$a$} (2);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[a]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.3\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state, accepting] (2) at (1,0)  {};\n    \t\\draw \t(1) edge [above] node{$b$} (2);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[b]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.4\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state] (2) at (1,0)  {};\n    \t\\node[state, accepting] (3) at (3,0)  {};\n    \t\\draw \t(1) edge [above] node{$a$} (2)\n    \t \t\t(2) edge [above] node{$b$} (3);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[ab]$}\n  \\end{subfigure}\n\\end{figure}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{0.3\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state, accepting] (2) at (1,0)  {};\n    \t\\draw \t(1) edge [above] node{$d$} (2);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[d]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.3\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state, accepting] (2) at (1,0)  {};\n    \t\\draw \t(1) edge [above] node{$e$} (2);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[e]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.4\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state] (2) at (1,0)  {};\n    \t\\node[state, accepting] (3) at (3,0)  {};\n    \t\\draw \t(1) edge [above] node{$d$} (2)\n    \t \t\t(2) edge [above] node{$e$} (3);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[de]$}\n  \\end{subfigure}\n\\end{figure}\n\\vspace{20px}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{0.3\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-1,0) {};\n    \t\\node[state, accepting] (2) at (1,0)  {};\n    \t\\draw \t(1) edge [above] node{$c$} (2);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[c]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.6\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-3,0) {};\n    \t\\node[state] (2) at (-0.25,1)  {};\n    \t\\node[state] (3) at (-1,-1)  {};\n    \t\\node[state, accepting] (4) at (2.25,1)  {};\n    \t\\node[state] (5) at (1,-1)  {};\n    \t\\node[state, accepting] (6) at (3,-1)  {};\n    \t\\draw \t(1) edge [above] node{$\\varepsilon$} (2)\n\t\t\t\t(1) edge [above] node{$\\varepsilon$} (3)\n\t\t\t\t(2) edge [above] node{$c$} (4)\n\t\t\t\t(3) edge [above] node{$d$} (5)\n\t\t\t\t(5) edge [above] node{$e$} (6)\n\t;\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[c\\cup de]$}\n  \\end{subfigure}\n\\end{figure}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{0.15\\textwidth}\n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state, accepting] (1) at (0,0) {};\n    \t\\draw \t(1) edge [loop above] node{$b$} (1);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[b^*]$}\n  \\end{subfigure}\n  %\n  \\begin{subfigure}[c]{0.85\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-3,0) {};\n    \t\\node[state] (2) at (-0.25,1)  {};\n    \t\\node[state] (3) at (-1,-1)  {};\n    \t\\node[state] (4) at (2.25,1)  {};\n    \t\\node[state] (5) at (1,-1)  {};\n    \t\\node[state] (6) at (3,-1)  {};\n    \t\\node[state] (7) at (5,0)  {};\n    \t\\node[state, accepting] (8) at (7,0)  {};\n    \t\\draw \t(1) edge [above] node{$\\varepsilon$} (2)\n\t\t\t\t(1) edge [above] node{$\\varepsilon$} (3)\n\t\t\t\t(2) edge [above] node{$c$} (4)\n\t\t\t\t(3) edge [above] node{$d$} (5)\n\t\t\t\t(5) edge [above] node{$e$} (6)\n\t\t\t\t(4) edge [above] node{$\\varepsilon$} (7)\n\t\t\t\t(6) edge [above left] node{$\\varepsilon$} (7)\n\t\t\t\t(7) edge [above] node{$a$} (8)\n\t\t\t\t(8) edge [loop above] node{b} (8)\n\t;\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[(c\\cup de)ab^*]$}\n  \\end{subfigure}\n\\end{figure}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{0.5\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-3,0) {};\n    \t\\node[state] (2) at (-1.5,1)  {};\n    \t\\node[state] (3) at (0,0)  {};\n    \t\\node[state, accepting] (4) at (2,0)  {};\n    \t\\draw \t(1) edge [above left] node{$d$} (2)\n\t\t\t\t(1) edge [below] node{$c$} (3)\n\t\t\t\t(2) edge [above right] node{$e$} (3)\n\t\t\t\t(3) edge [above] node{$a$} (4)\n\t\t\t\t(4) edge [loop above] node{$b$} (4)\n\t;\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Simplified Automaton accepting $L[(c\\cup de)ab^*]$}\n  \\end{subfigure}\n  \\begin{subfigure}[c]{0.5\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (1) at (-3,0) {};\n    \t\\node[state] (2) at (-1.5,1)  {};\n    \t\\node[state] (3) at (0,0)  {};\n    \t\\node[state, accepting] (4) at (2,0)  {};\n    \t\\draw \t(1) edge [above left] node{$d$} (2)\n\t\t\t\t(1) edge [below] node{$c$} (3)\n\t\t\t\t(2) edge [above right] node{$e$} (3)\n\t\t\t\t(3) edge [above] node{$a$} (4)\n\t\t\t\t(4) edge [loop above] node{$b$} (4)\n\t\t\t\t(4) edge [bend left, below] node{$\\varepsilon$} (1)\n\t;\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[\\big(c\\cup de)ab^*\\big)^*]$}\n  \\end{subfigure}\n\\end{figure}\n\\begin{figure}[!htbp]\n  \\begin{subfigure}[c]{1\\textwidth}    \n    \\begin{center}\n    \\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n    \t\\node[state] (r) at (-3,0) {$r$};\n    \t\\node[state] (s) at (-1.5,1)  {$s$};\n    \t\\node[state] (t) at (0,0)  {$t$};\n    \t\\node[state] (u) at (2,0)  {$u$};\n    \t\\node[state] (p) at (-7,0)  {$p$};\n    \t\\node[state] (q) at (-5,0)  {$q$};  \n    \t\\node[state,accepting] (v) at (4,0)  {$v$};    \t\n\t\t\\draw \t(r) edge [above left] node{$d$} (s)\n\t\t\t\t(r) edge [below] node{$c$} (t)\n\t\t\t\t(s) edge [above right] node{$e$} (t)\n\t\t\t\t(t) edge [above] node{$a$} (u)\n\t\t\t\t(u) edge [loop above] node{$b$} (u)\n\t\t\t\t(u) edge [bend left, below] node{$\\varepsilon$} (r)\n\t\t\t\t(p) edge [above] node{$a$} (q)\n\t\t\t\t(q) edge [above] node{$b$} (r)\n\t\t\t\t(u) edge [above] node{$c$} (v)\n\t;\n    \t\\draw[-, semithick] (node cs:name=p,anchor=west) -- ++(-3mm,1mm);\n    \t\\draw[-, semithick] (node cs:name=p,anchor=west) -- ++(-3mm,-1mm);\n    \\end{tikzpicture}\n    \\end{center}\n    \\caption*{Automaton accepting $L[ab\\big(c\\cup de)ab^*\\big)^*c]$}\n  \\end{subfigure}\n\\end{figure}\n\n\\FloatBarrier\n\nLet $A=(Q,\\Sigma,\\delta,q_0,F)$ be a nondeterministic finite automaton with $\\varepsilon$ moves, comprising\n\\begin{itemize}\n\t\\item a set of states $Q=\\{p,q,r,s,t,u,v\\}$\n\t\\item a set of symbols $\\Sigma = \\{a,b,c,d,e\\}$\n\t\\item a transition function $f:Q \\times (\\Sigma \\cup \\{\\varepsilon \\}) \\to \\mathsf{Pow}(Q)$ given by the below table\n\t\n\t\\begin{tabular}{c|c c c c c c}\n\t\t&  \\multicolumn{6}{c}{symbol} \\\\\n\t\tstate & $a$ & $b$ & $c$ & $d$ &$e$ & $\\varepsilon$ \\\\\n\t\t\\hline\n\t\t$p$ & $\\{q\\}$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$\\\\\n\t\t$q$ & $\\varnothing$ & $\\{r\\}$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$\\\\\n\t\t$r$ & $\\varnothing$ & $\\varnothing$ & $\\{t\\}$ & $\\{s\\}$ & $\\varnothing$ & $\\varnothing$\\\\\n\t\t$s$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\{t\\}$ & $\\varnothing$\\\\\n\t\t$t$ & $\\{u\\}$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$\\\\\n\t\t$u$ & $\\varnothing$ & $\\{u\\}$ & $\\{v\\}$ & $\\varnothing$ & $\\varnothing$ & $\\{r\\}$\\\\\n\t\t$v$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$ & $\\varnothing$\\\\\n\t\\end{tabular}\n\t\\item an initial state $q_0 = p$\n\t\\item a set of accepting states $F = \\{v\\}$\n\\end{itemize}\nThen $A$ accepts the language $L[ab\\big(c\\cup de)ab^*\\big)^*c]$.\n\\section{}\n\\subsection{}\n$\\mathtt{aaa^*ba^*}$\n\\subsection{}\n$L = \\{a^n b^m a^n|n\\geq0,m\\geq3\\}$\n\n\\vspace{10px}\n\n$L$ is not regular. Consider words of the form $a^nbbba^n$ which are all in $L$ and can be of any length greater than 3 -- no substring can be removed from these words whilst they remain in $L$: if the substring contains any $b$, and that substring is removed, there will be fewer than 3 $b$; if the substring contains only $a$, and that substring is removed, there will different numbers of $a$ on each side. As there is no substring that can be removed, there is no substring that can be pumped. Therefore, for any length greater than 3 there is a word in $L$ which does not satisfy the pumping property, therefore it is not regular.\n\n\\section{}\nLet $G=(V,\\Sigma,R,s)$ be a context free grammar with\n\\begin{itemize}\n\t\\item a set of variables $V=\\{S,X,Y\\}$\n\t\\item a set of terminals $\\Sigma = \\{a,b,c\\}$\n\t\\item a set of production rules $R = \\{S \\to XY, \\ X \\to \\varepsilon, \\ X \\to aXb, \\ Y \\to \\varepsilon, \\ Y \\to bYc\\}$\n\t\\item a start variable $s=S$\n\\end{itemize}\n\n\\vspace{20px}\n\n\\noindent This would be accepted by a push-down automaton, $P=(Q,\\Sigma,\\Gamma,\\delta,s_0,F)$ with\n\\begin{itemize}\n\t\\item a set of states, $Q=\\{p,q,r,s,t,u\\}$\n\t\\item an input alphabet, $\\Sigma=\\{a,b,c\\}$\n\t\\item a stack alphabet, $\\Gamma=\\{\\bot,a,b\\}$\n\t\\item a transition relation, $\\delta$, consisting of the following instructions of the form ${((q_0,\\sigma,\\gamma_0),(q_1,\\gamma_1))}$\n\t\\begin{itemize}\n\t\t\\item $((p,\\varepsilon,\\varepsilon),(q,\\bot))$\n\t\t\\item $((q,a,\\varepsilon),(q,a))$\n\t\t\\item $((q,\\varepsilon,\\varepsilon),(r,\\varepsilon))$\n\t\t\\item $((r,b,a),(r,\\varepsilon))$\n\t\t\\item $((r,\\varepsilon,\\bot),(s,\\bot))$\n\t\t\\item $((s,b,\\varepsilon),(s,b))$\n\t\t\\item $((s,\\varepsilon,\\varepsilon),(t,\\varepsilon))$\n\t\t\\item $((t,c,b),(t,\\varepsilon))$\n\t\t\\item $((t,\\varepsilon,\\bot),(u,\\varepsilon))$\n\t\\end{itemize} where\n\t\\begin{itemize}\n\t\t\\item $q_0 \\in Q$ is the starting state of the transition\n\t\t\\item $\\sigma \\in (\\Sigma \\cup \\{\\varepsilon\\})$ is the input symbol read during the transition\n\t\t\\item $\\gamma_0 \\in (\\Gamma \\cup \\{\\varepsilon\\})$ is the symbol popped from the stack during the transition\n\t\t\\item $q_1 \\in Q$ is the ending state of the transition\n\t\t\\item $\\gamma_1 \\in (\\Gamma \\cup \\{\\varepsilon\\})$ is the symbol pushed onto the stack during the transition\n\t\\end{itemize}\n\t\\item an initial state, $s_0=p$\n\t\\item a set of accepting states $F=\\{u\\}$\n\\end{itemize}\n\n\\vspace{20px}\n\n\\noindent $P$ can be represented by the following state diagram:\n\n\\begin{center}\n\\begin{tikzpicture}[->, >=triangle 45, semithick, node distance=2cm]\n\t\\node[state] (1) at (0,0)  {$p$};\n\t\\node[state] (2) at (2.5,0)  {$q$};\n\t\\node[state] (3) at (5,0)  {$r$};\n\t\\node[state] (4) at (7.5,0)  {$s$};\n\t\\node[state] (5) at (10,0)  {$t$};\n\t\\node[state, accepting] (6) at (12.5,0)  {$u$};\n\t\t\n\t\t\\draw \t(1) edge [above] node{$\\varepsilon, \\ \\varepsilon /\\bot$} (2)\n\t\t\t\t(2) edge [loop above] node{$a, \\ \\varepsilon / a$} (2)\n\t\t\t\t(2) edge [above] node{$\\varepsilon, \\ \\varepsilon /\\varepsilon$} (3)\n\t\t\t\t(3) edge [loop above] node{$b, \\ a / \\varepsilon$} (3)\n\t\t\t\t(3) edge [above] node{$\\varepsilon, \\ \\bot /\\bot$} (4)\n\t\t\t\t(4) edge [loop above] node{$b, \\ \\varepsilon / b$} (4)\n\t\t\t\t(4) edge [above] node{$\\varepsilon, \\ \\varepsilon /\\varepsilon$} (5)\n\t\t\t\t(5) edge [loop above] node{$c, \\ b / \\varepsilon$} (5)\n\t\t\t\t(5) edge [above] node{$\\varepsilon, \\ \\bot /\\varepsilon$} (6)\n\t\t;\n\t\n\t\t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,1mm);\n\t\\draw[-, semithick] (node cs:name=1,anchor=west) -- ++(-3mm,-1mm);\n\\end{tikzpicture}\n\\end{center}\n\\end{document}\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "2f3584f9b50fc6f6f087f4cec9e3f75299653d68", "size": 38756, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "FOC CW1 Submission.tex", "max_stars_repo_name": "MarkRotchell/Mathematics-Coursework-as-part-of-MSc-Data-Science", "max_stars_repo_head_hexsha": "ff36d429e5a048682ca0e4a53eff1e980347e9df", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FOC CW1 Submission.tex", "max_issues_repo_name": "MarkRotchell/Mathematics-Coursework-as-part-of-MSc-Data-Science", "max_issues_repo_head_hexsha": "ff36d429e5a048682ca0e4a53eff1e980347e9df", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FOC CW1 Submission.tex", "max_forks_repo_name": "MarkRotchell/Mathematics-Coursework-as-part-of-MSc-Data-Science", "max_forks_repo_head_hexsha": "ff36d429e5a048682ca0e4a53eff1e980347e9df", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.4391716997, "max_line_length": 635, "alphanum_fraction": 0.5641965115, "num_tokens": 15914, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5350984137988773, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.40083537953471227}}
{"text": "% Created 2022-01-16 Sun 11:18\r\n% Intended LaTeX compiler: pdflatex\r\n\\documentclass[presentation]{beamer}\r\n\\usepackage[utf8]{inputenc}\r\n\\usepackage[T1]{fontenc}\r\n\\usepackage{graphicx}\r\n\\usepackage{grffile}\r\n\\usepackage{longtable}\r\n\\usepackage{wrapfig}\r\n\\usepackage{rotating}\r\n\\usepackage[normalem]{ulem}\r\n\\usepackage{amsmath}\r\n\\usepackage{textcomp}\r\n\\usepackage{amssymb}\r\n\\usepackage{capt-of}\r\n\\usepackage{hyperref}\r\n\\usepackage{xypic}\r\n\\xyoption{pdf}\r\n\\usetheme{default}\r\n\\newcommand\\cat[1]{\\ensuremath{\\mathcal{#1}}}\r\n\\newcommand\\hm[2]{\\hom(#1,#2)}\r\n\\newcommand\\nat[2]{{#1}\\overset{\\cdot}{\\rightarrow}{#2}}\r\n\\newcommand\\tup[1]{\\langle #1\\rangle}\r\n\\newcommand\\id[1]{\\mathrm{id}_{#1}}\r\n\\author{jens.jensen@stfc.ac.uk \\\\0000-0003-4714-184X\\\\CC-BY 4.0}\r\n\\date{March 13, 2022}\r\n\\title{Functional Programming 2}\r\n\\hypersetup{\r\n pdfauthor={jens.jensen@stfc.ac.uk},\r\n pdftitle={Functional Programming 2},\r\n pdfkeywords={functional, monad, programming theory},\r\n pdfsubject={functional programming},\r\n pdfcreator={Emacs 27.1 (Org mode 9.3) then by hand}, \r\n pdflang={English}}\r\n\\begin{document}\r\n\r\n\\maketitle\r\n\\begin{frame}{Outline of Talk 2}\r\n\r\n  \\begin{itemize}\r\n    \\item Previous talk (talk 1):\r\n    \\begin{itemize}\r\n\\item Introibo\r\n\\item Pure Functional Programming Principles\r\n    \\end{itemize}\r\n  \\item This talk (and probably the next):\r\n    \\begin{itemize}\r\n    \\item Mapping\r\n    \\item Labels and naming\r\n    \\item Lists\r\n    \\end{itemize}\r\n    \r\n  \\item Advanced(ish) Topics\r\n\\item Impure Functional? Side Effects\r\n\\item Category Theory\r\n\\item Categories and Functions\r\n\\item Categories and Computation\r\n\\end{itemize}\r\n\r\nStill written in the author's spare time!\r\n\r\n\\medskip\r\n\r\nVery much a personal perspective, and not following any particular textbook.  Using \\emph{meditations} and \\emph{exercises} -- solutions to all exercises given during the talks.\r\n\r\n\\end{frame}\r\n\r\n\r\n\\section{Introibo}\r\n\\label{sec:org0edb596}\r\n\r\n\\begin{frame}{Summary of Talk 1}\r\n  \\begin{itemize}\r\n  \\item Basic Principles\r\n    \\begin{itemize}\r\n    \\item Variables are immutable\r\n    \\item Functions have no side effect\r\n      \\begin{itemize}\r\n      \\item Side effects permitted on r-values (often preferred for efficiency)\r\n      \\item In this talk we look at functions with side effects\r\n      \\end{itemize}\r\n    \\item ``Divide and conquer'' approach to problems\r\n    \\end{itemize}\r\n  \\end{itemize}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Summary of Talk 1}\r\n\\begin{verbatim}\r\n(defun fact (k)\r\n  \"Calculate the factorial of a number\"\r\n  (unless (and (numberp k) (integerp k) (>= k 0))\r\n    (error \"Unable to take factorial of %s\" k))\r\n  (fact-1 k))\r\n\\end{verbatim}\r\n\\texttt{fact} is the entry point; it delegates to a helper function which is guaranteed to be called with a non-negative integer.  This means that (in principle) checks can be turned off for the helper, and it can be optimised to run faster:\r\n\\begin{verbatim}\r\n(defun fact-1 (k)\r\n  (if (zerop k) 1 (* k (fact-1 (1- k)))))\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{More Mapping}\r\n  Meditation exercise: why do mapping \\emph{et al.} not work with macros and special forms?\r\n\\begin{verbatim}\r\n(apply #'and '(nil t t))\r\n\\end{verbatim}\r\nraises an error, though these will work in EL, but not in CL:\r\n\\begin{verbatim}\r\n(funcall #'if t 'yes 'no)\r\nyes\r\n(funcall #'and t t nil)\r\nnil\r\n\\end{verbatim}\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Example -- Sorting Months}\r\nWhere does August come before July, April before January?\r\n\\begin{verbatim}\r\n(defvar +dates+ '((10 . \"Aug\") (2 . \"Dec\") (17 . \"Mar\") (30 . \"Apr\") (4 . \"Jan\") (2 . \"Aug\")))\r\n\\end{verbatim}\r\nLet's start with a function to calculate the month number:\r\n\\begin{verbatim}\r\n(defun month-number (m)\r\n  (1+ (floor\r\n        (search m\r\n          \"JanFebMarAprMayJunJulAugSepOctNovDec\")\r\n        3)))\r\nmonth-number\r\n(month-number \"Jan\")\r\n1\r\n(month-number \"Dec\")\r\n12\r\n\\end{verbatim}\r\nThis function is \\emph{correct} in the sense of producing the right output given the right input, but it does have some flaws and inefficiencies (exercise) -- we shall return to these later.\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Example -- Sorting Months}\r\nNow the problem is simple: first we add the month number...\r\n\\begin{verbatim}\r\n(mapcar (lambda (d) (cons (month-number (cdr d)) d)) +dates+)\r\n((8 10 . \"Aug\") (12 2 . \"Dec\") (3 17 . \"Mar\") (4 30 . \"Apr\") (1 4 . \"Jan\") (8 2 . \"Aug\"))\r\n\\end{verbatim}\r\nthen we sort those\r\n\\begin{verbatim}\r\n(mapcar #'cdr\r\n (sort\r\n  (mapcar (lambda (d) (cons (month-number (cdr d)) d)) +dates+)\r\n  (lambda (d1 d2) (or (< (first d1) (first d2))\r\n                      (and (= (first d1) (first d2))\r\n                           (< (second d1) (second d2)))))))\r\n((4 . \"Jan\") (17 . \"Mar\") (30 . \"Apr\") (2 . \"Aug\") (10 . \"Aug\") (2 . \"Dec\"))\r\n\\end{verbatim}\r\nThis is what Perl calls the ``Schwarzian Transform'' -- add the order\r\nvalue to the entries, sort on the order value, and then strip it off\r\nagain at the end.\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Example -- Sorting Months}\r\nOf course with this being Lisp, we can do better:\r\n\\begin{verbatim}\r\n(sort (copy-seq +dates+)\r\n  (lambda (d1 d2)\r\n    (let ((m1 (month-number (cdr d1)))\r\n          (m2 (month-number (cdr d2))))\r\n      (or (< m1 m2) (and (= m1 m2) (< (car d1) (car d2)))))))\r\n((4 . \"Jan\") (17 . \"Mar\") (30 . \"Apr\") (2 . \"Aug\") (10 . \"Aug\") (2 . \"Dec\"))\r\n\\end{verbatim}\r\nMeditation: why do we need \\texttt{copy-seq} here when we didn't need it before?\r\n Is this solution better than the Schwarzian transform?\r\n\r\n\\medskip\r\nIn CL, the \\texttt{:key} parameter is used to extract the field to be sorted on, but it can also be used to calculate the order:\r\n\\begin{verbatim}\r\n(sort (copy-seq +dates+) #'<\r\n  :key (lambda (d) (+ (car d) (* 40 (month-number (cdr d))))))\r\n\\end{verbatim}\r\n\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Example -- Magic Mapping with Apply}\r\nFrom the author's AoC21, Day 9, in CL rather than EL:\r\n\\begin{verbatim}\r\n(defun transpose (rows)\r\n  \"Transpose rows and columns, list of lists version\"\r\n  (apply #'mapcar #'list rows))\r\n\\end{verbatim}\r\nThis magic works because \\texttt{apply} accepts the extra argument (\\texttt{\\#'list}) to pass to \\texttt{mapcar}:\r\n\\begin{verbatim}\r\n(transpose '((1 2 3) (4 5 6)))\r\n((1 4) (2 5) (3 6))\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Advanced Maps}\r\n  Meditate on the advanced mapping functions: this CL example is also from AoC21 Day 9 (uses \\texttt{incf} to get map-indexed):\r\n\\begin{verbatim}\r\n(defun row-troughs (row)\r\n  \"Return the locations of the \\\"troughs\\\" in a row of\r\n   numbers, local minima\"\r\n  ;; General case: haven't thought too much about it\r\n  (let* ((ext-row (cons most-positive-fixnum\r\n                     (append row\r\n                        (cons most-positive-fixnum nil))))\r\n         (idx 0))\r\n    (mapcan (lambda (a b c)\r\n              (prog1 (if (and (> a b) (< b c))\r\n                       (list idx) nil) (incf idx)))\r\n          ext-row (cdr ext-row) (cddr ext-row))))\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan - fizzbuzz 1}\r\n\\begin{verbatim}\r\n(defun buzz (num) (if (zerop (mod num 5)) (list 'buzz) nil))\r\n(defun fizz (num)\r\n  (funcall\r\n   (if (zerop (mod num 3))\r\n       (lambda (x) (cons 'fizz x)) #'identity)\r\n   (buzz num)))\r\n(fizz 2)\r\nnil\r\n(fizz 6)\r\n(fizz)\r\n(fizz 10)\r\n(buzz)\r\n(fizz 30)\r\n(fizz buzz)\r\n\\end{verbatim}\r\nMeditation: why is \\texttt{fizz} defined like this?  (We'll write a cleaner version later)\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan - fizzbuzz 2}\r\nAs an aside, would this work (i.e.\\ without using \\texttt{funcall})?\r\n\\begin{verbatim}\r\n...\r\n((if (zerop ...) (lambda (x) ...) #'identity) (buzz num))\r\n\\end{verbatim}\r\n\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan - fizzbuzz 3}\r\nAre these better -- and which of these is the best?\r\n\\begin{verbatim}\r\n(defun fizz (num)\r\n  (let ((b (buzz num)))\r\n    (if (zerop (mod num 3)) (cons 'fizz b) b)))\r\n\\end{verbatim}\r\nor\r\n\\begin{verbatim}\r\n(defun fizz (num)\r\n  (if (zerop (mod num 3)) (cons 'fizz (buzz num))\r\n      (buzz num)))\r\n(fizz 7)\r\nnil\r\n(fizz 3)\r\n(fizz)\r\n(fizz 5)\r\n(buzz)\r\n(fizz 15)\r\n(fizz buzz)\r\n\\end{verbatim}\r\n\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan - fizzbuzz 4}\r\nDigression: We need to generate lists of integers (called iota from APL, A+ et al):\r\n\\begin{verbatim}\r\n(defun iota (k)\r\n  \"Generate a list of integers from 1 to k\" \r\n  (labels ((iota1 (k1)\r\n                  (if (< k1 1) nil\r\n                    (cons k1 (iota1 (1- k1))))))\r\n    (nreverse (iota1 k))))\r\n\\end{verbatim}\r\nMeditations:\r\n\\begin{itemize}\r\n\\item Ponder the use of \\texttt{nreverse} -- why it is needed, why it is safe\r\n  \\begin{itemize}\r\n  \\item We shall see later how to build better \\texttt{iota}s\r\n  \\end{itemize}\r\n\\item Why might the variable/function naming not be ideal?  Could we have used \\texttt{k} in \\texttt{iota1}?  (We will return to naming shortly)\r\n\\item \\texttt{(defun fact (k) (reduce \\#'* (iota k)))}\r\n\\end{itemize}\r\n\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan - fizzbuzz 5}\r\nThis is not true fizzbuzz but we want to show \\texttt{mapcan} in EL:\r\n\\begin{verbatim}\r\n(defun fizzbuzz (num)\r\n  (mapcan #'fizz (iota num)))\r\n(fizzbuzz 15)\r\n(fizz buzz fizz fizz buzz fizz fizz buzz)\r\n\\end{verbatim}\r\nThe point is that \\texttt{fizz} can return 0, 1 or 2 results and they are merged into the result list (destructively!)\r\n\\begin{itemize}\r\n\\item \\texttt{mapcan} merges lists together (destructively), so the map function can return multiple results\r\n\\item For 0 or 1 values, it may be cleaner to use \\texttt{delete}, \\texttt{delete-if} or \\texttt{delete-if-not} (as appropriate)\r\n  \\begin{itemize}\r\n  \\item Note that logically \\texttt{delete-if-not} does ``select-if''\r\n  \\item \\texttt{remove}, \\texttt{remove-if} and \\texttt{remove-if-not} are the side-effect-free versions\r\n  \\end{itemize}\r\n\\end{itemize}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan -- FizzBuzz \\$$-1$}\r\n  Since we've started, we might as well solve FizzBuzz (with the definitions from previous slides):\r\n\\begin{verbatim}\r\n(defun fizzbuzz-number (k)\r\n  \"Return symbol from fizzbuzzing a number, or nil\"\r\n  (let ((fb (fizz k)))\r\n    (if (cdr fb) 'fizzbuzz  ; >1 elt\r\n      (car fb))))\r\n\r\n(defun fizzbuzz (k)\r\n  \"FizzBuzz from 1 to k\"\r\n  (mapcar (lambda (x) (or (fizzbuzz-number x) x))\r\n    (iota k)))\r\n\r\n(fizzbuzz 21)\r\n(1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz ...)\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Example Koan -- FizzBuzz \\$}\r\nIncidentally, in CL if we are worried about the extra list being generated (and eventually gc'ed) in\r\n\\begin{verbatim}\r\n(mapcar (lambda (x) ...) (iota k))\r\n\\end{verbatim}\r\nwe can reuse the list with (permitted) side effect (as the value produced by \\texttt{iota} is an r-value):\r\n\\begin{verbatim}\r\n(let ((m (iota k)))\r\n  (map-into m (lambda (x) ...) m))\r\n\\end{verbatim}\r\nThis tells Lisp that we want to reuse \\texttt{m} (on the LHS of the lambda) while mapping the values of \\texttt{m} (on the RHS), but it obviously less readable than a \\texttt{mapcar} and requires the \\texttt{let} binding.\r\n\r\n\\medskip\r\nUnfortunately, while EL has a function called \\texttt{map-into}, it does something quite different.\r\n\r\n\\medskip\r\nWe will return to fizzbuzz in the Advanced Topics sections 10 and 13.\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Advanced maps: Advanced List Iterations}\r\n\\texttt{dolist} iterates over a list.  Functionally we have done the same either with \\texttt{first} and \\texttt{rest} and \\emph{recursion}, or with \\texttt{mapcar}.  The latter is like \\texttt{dolist} except it produces an output:\r\n\\begin{verbatim}\r\n(mapcar\r\n  (lambda (state) (when (goalp state) (throw 'found state)))\r\n  data)\r\n(nil nil nil nil nil ...)\r\n\\end{verbatim}\r\nAn output list is needlessly produced, as we here are calling only for side effect (more on side effects later).\r\n\r\n\\medskip\r\nLisp has functions which will happily do the same and discard the result of $\\lambda$:\r\n\\begin{verbatim}\r\n(map nil (lambda (state)\r\n           (when (goalp state)\r\n             (throw 'found state)))\r\n  data)\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Advanced maps}\r\nHow does \\texttt{map} differ from \\texttt{mapcar}?  It works on \\emph{sequences}:\r\n\\begin{verbatim}\r\n(map 'list (lambda (x) (+ x 2)) [1 2 3 4])\r\n(3 4 5 6)\r\n(map 'vector (lambda (x) (- x 2)) '(3 4 5 6))\r\n[1 2 3 4]\r\n(map 'string (lambda (x) (+ x 32)) \"ABCD\")\r\n\"abcd\"\r\n\\end{verbatim}\r\n(the latter being EL only) but accepts \\texttt{nil} as its type to discard the output.\r\n\r\n\\medskip\r\nOf course this is cleaner if only the type change is desired:\r\n\\begin{verbatim}\r\n(coerce (list 1 2 3 4) 'vector)\r\n[1 2 3 4]\r\n\\end{verbatim}\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Two patterns implementing \\texttt{mapcar}}\r\nWe could have written EL's (simpler) \\texttt{mapcar} like this:\r\n\\begin{verbatim}\r\n(defun our-mapcar (func lst)\r\n  (if (endp lst) nil\r\n    (cons (funcall func (first lst))\r\n          (our-mapcar func (rest lst)))))\r\nour-mapcar\r\n(our-mapcar #'sqrt '(16 4 36 5))\r\n(4.0 2.0 6.0 2.23606797749979)\r\n\\end{verbatim}\r\nexcept that it may run out of stack for a longer list (we return to this problem later, in Advanced Topics section 5)\r\n\r\n\\begin{itemize}\r\n\\item Indeed much of Lisp can be (or is) constructed from a smaller set of primitives (McCarthy)\r\n\\item As we have seen before, the \\texttt{first}/\\texttt{rest} (or \\texttt{car}/\\texttt{cdr}) pattern is very common\r\n\\item As is the \\texttt{cons}/\\texttt{nil} constructing the result\r\n\\item Usually this (combined) pattern is implemented with \\texttt{mapcar}\r\n\\end{itemize}\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Advanced maps -- sliding window}\r\nBut maps can do more advanced stuff.  Let us first return to the sliding window exercise from the first talk.  We want to sum values\r\n\\begin{verbatim}\r\n(sum-window 3 '(1 5 4 1 3 6 2))\r\n(10 10 8 10 11)\r\n(sum-window 2 '(1 5 4 1 3 6 2))\r\n(6 9 5 4 9 8)\r\n(sum-window 4 '(1 2 3))\r\nnil\r\n\\end{verbatim}\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Sliding Window}\r\nLet's start by writing a helper function: it is to sum variables from a list:\r\n\\begin{verbatim}\r\n(sum-helper 4 '(2 5 1 3 6 9 1))\r\n11\r\n(sum-helper 1 '(2 5 1 3 6 9 1))\r\n2\r\n(sum-helper 0 '(2 5 1 3 6 9 1))\r\n0\r\n(sum-helper 5 '(1 2 3 4))\r\nnil\r\n\\end{verbatim}\r\nThis example is Interesting because it has two stop conditions: the counter reaching zero, and the list becoming empty.\r\n\r\n\\medskip\r\nMeditation: what is \\texttt{(sum-helper 0 nil)}?  Should it be \\texttt{0} or \\texttt{nil}?\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Sliding Window}\r\n\\begin{verbatim}\r\n(defun sum-helper (n data)\r\n  (cond\r\n   ((zerop n) 0)\r\n   ((endp data) nil)\r\n   (t (let ((result (sum-helper (1- n) (rest data))))\r\n        (and result (+ (first data) result))))))\r\n\\end{verbatim}\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Sliding Window}\r\nNow we can write a function to call the helper... we can't just do \\texttt{mapcar} as the function would see only \\texttt{first} (as with \\texttt{dolist}) -- so, instead, we could almost do:\r\n\\begin{verbatim}\r\n(defun sum-window (k data)\r\n  (if (endp data) nil\r\n    (cons (sum-helper k data)\r\n          (sum-window k (cdr data)))))\r\n(sum-window 3 '(1 5 4 1 3 6 2))\r\n(10 10 8 10 11 nil nil)\r\n\\end{verbatim}\r\nThis works, but obviously it generates extra \\texttt{nil}s at the end as it has to map across the whole list - so we could write another function to truncate them away.\r\n\r\n\\medskip\r\nNotice the \\texttt{cons}/\\texttt{rest} pattern again -- \\emph{nearly} like the \\texttt{mapcar} pattern\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Sliding Window -- Advanced maps}\r\nThe \\texttt{cons}-\\texttt{cdr} pattern from the previous slide is a very common functional pattern.  Lisp has a mapping function that can do the same in a single line:\r\n\\begin{verbatim}\r\n(defun sum-window (k data)\r\n  (maplist (lambda (d) (sum-helper k d)) data))\r\n(10 10 8 10 11 nil nil)\r\n\\end{verbatim}\r\n\\texttt{maplist} \\texttt{cdr}s across the list, \\texttt{cons}ing the results:\r\n\\begin{verbatim}\r\n(maplist #'identity '(1 2 3 4 5))\r\n((1 2 3 4 5) (2 3 4 5) (3 4 5) (4 5) (5))\r\n\\end{verbatim}\r\nThese are successive \\texttt{cdr}s of the \\emph{same} list:\r\n\\begin{verbatim}\r\n(let ((m (maplist #'identity '(1 2 3 4 5))))\r\n  (eq (cdar m) (cadr m)))\r\nt\r\n\\end{verbatim}\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Sliding Window -- Advanced maps}\r\nSo we either do\r\n\\begin{verbatim}\r\n(defun sum-window (k data)\r\n  (delete nil (maplist (lambda (d) (sum-helper k d)) data)))\r\n\\end{verbatim}\r\nand we're done; or we do\r\n\\begin{verbatim}\r\n(defun sum-window (k data)\r\n  (mapcon (lambda (d)\r\n            (let ((v (sum-helper k d)))\r\n              (and v (list v))))\r\n          data))\r\n(sum-window 3 '(1 5 4 1 3 6 2))\r\n(10 10 8 10 11)\r\n\\end{verbatim}\r\n\\texttt{mapcon} is to \\texttt{maplist} what \\texttt{mapcan} is to \\texttt{mapcar} -- it \\texttt{nconc}s the results; here we use it to delete the \\texttt{nil} entries.\r\n\r\n\\end{frame}\r\n\\begin{frame}[fragile]{Mapping for side effect}\r\nThis call appears to have the side effect of the lambda, but it doesn't -- why?\r\n\\begin{verbatim}\r\n(mapcar (lambda (x) (setq x 3)) (list 1 2 3 4))\r\n(3 3 3 3)\r\n\\end{verbatim}\r\nbut in fact it has no effect at all on the original list:\r\n\\begin{verbatim}\r\n(let ((y (list 1 2 3 4)))\r\n  (mapcar (lambda (x) (setq x 3)) y)\r\n  y)\r\n\\end{verbatim}\r\nMeditation: why are we using \\texttt{list} to create the list instead of the macro \\texttt{'}?\r\n\\end{frame}\r\n\r\n\\begin{frame}[fragile]{Mapping for side effect}\r\nThis works, though -- why?\r\n\\begin{verbatim}\r\n(let ((y (list 1 2 3 4)))\r\n  (maplist (lambda (x) (rplaca x (1+ (car x)))) y)\r\n  y)\r\n(2 3 4 5)\r\n\\end{verbatim}\r\nbut of course \\texttt{maplist} still creates a temporary list which is also updated:\r\n\\begin{verbatim}\r\n(let ((y (list 1 2 3 4)))\r\n  (maplist (lambda (x) (rplaca x (1+ (car x)))) y))\r\n(2 3 4 5)\r\n\\end{verbatim}\r\nThe lists are not \\texttt{eq} (though their elements are):\r\n\\begin{verbatim}\r\n(let ((y (list 1 2 3 4)))\r\n  (eq y (maplist (lambda (x) (rplaca x 3)) y)))\r\nnil\r\n\\end{verbatim}\r\n\\bigskip\r\nThis ends the review of the mapping functions!\r\n\\end{frame}\r\n\\end{document}\r\n", "meta": {"hexsha": "2e7e12b2cd3b8374601c4a9e57b0836eb2f2790b", "size": 17971, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "slides/functional2.tex", "max_stars_repo_name": "jjensenral/functional", "max_stars_repo_head_hexsha": "b751957777e7be86be0abceeaa0f9ab29847d919", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "slides/functional2.tex", "max_issues_repo_name": "jjensenral/functional", "max_issues_repo_head_hexsha": "b751957777e7be86be0abceeaa0f9ab29847d919", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/functional2.tex", "max_forks_repo_name": "jjensenral/functional", "max_forks_repo_head_hexsha": "b751957777e7be86be0abceeaa0f9ab29847d919", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.10056926, "max_line_length": 242, "alphanum_fraction": 0.6601190807, "num_tokens": 5632, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.400828633359903}}
{"text": "\\chapter{A bit of manifolds}\nLast chapter, we stated Stokes' theorem for cells.\nIt turns out there is a much larger class of spaces,\nthe so-called \\emph{smooth manifolds}, for which this makes sense.\n\nUnfortunately, the definition of a smooth manifold is \\emph{complete garbage},\nand so by the time I am done defining differential forms and orientations,\nI will be too lazy to actually define what the integral on it is,\nand just wave my hands and state Stokes' theorem.\n\n\\section{Topological manifolds}\n\\prototype{$S^2$: ``the Earth looks flat''.}\n\nLong ago, people thought the Earth was flat,\ni.e.\\ homeomorphic to a plane, and in particular they thought that\n$\\pi_2(\\text{Earth}) = 0$.\nBut in fact, as most of us know, the Earth is actually a sphere,\nwhich is not contractible and in particular $\\pi_2(\\text{Earth}) \\cong \\ZZ$.\nThis observation underlies the definition of a manifold:\n\\begin{moral}\n\tAn $n$-manifold is a space which locally looks like $\\RR^n$.\n\\end{moral}\nActually there are two ways to think about a topological manifold $M$:\n\\begin{itemize}\n\t\\ii ``Locally'': at every point $p \\in M$,\n\tsome open neighborhood of $p$ looks like an open set of $\\RR^n$.\n\tFor example, to someone standing on the surface of the Earth,\n\tthe Earth looks much like $\\RR^2$.\n\t\n\t\\ii ``Globally'': there exists an open cover of $M$\n\tby open sets $\\{U_i\\}_i$ (possibly infinite) such that each $U_i$\n\tis homeomorphic to some open subset of $\\RR^n$.\n\tFor example, from outer space, the Earth can be covered\n\tby two hemispherical pancakes.\n\\end{itemize}\n\\begin{ques}\n\tCheck that these are equivalent.\n\\end{ques}\nWhile the first one is the best motivation for examples,\nthe second one is easier to use formally.\n\n\\begin{definition}\n\tA \\vocab{topological $n$-manifold} $M$ is a Hausdorff space\n\twith an open cover $\\{U_i\\}$ of sets\n\thomeomorphic to subsets of $\\RR^n$,\n\tsay by homeomorphisms\n\t\\[ \\phi_i : U_i \\taking\\cong E_i \\subseteq \\RR^n \\]\n\twhere each $E_i$ is an open subset of $\\RR^n$.\n\tEach $\\phi_i : U_i \\to E_i$ is called a \\vocab{chart},\n\tand together they form a so-called \\vocab{atlas}.\n\\end{definition}\n\\begin{remark}\n\tHere ``$E$'' stands for ``Euclidean''.\n\tI think this notation is not standard; usually \n\tpeople just write $\\phi_i(U_i)$ instead.\n\\end{remark}\n\\begin{remark}\n\tThis definition is nice because it doesn't depend on embeddings:\n\ta manifold is an \\emph{intrinsic} space $M$,\n\trather than a subset of $\\RR^N$ for some $N$.\n\tAnalogy: an abstract group $G$ is an intrinsic object\n\trather than a subgroup of $S_n$.\n\\end{remark}\n\n\\begin{example}[An atlas on $S^1$]\nHere is a picture of an atlas for $S^1$, with two open sets.\n\\begin{center}\n\t\\begin{asy}\n\t\tsize(8cm);\n\t\tdraw(unitcircle, black+2);\n\t\tlabel(\"$S^1$\", dir(45), dir(45));\n\t\treal R = 0.1;\n\t\tdraw(arc(origin,1-R,-100,100), red);\n\t\tlabel(\"$U_2$\", (1-R)*dir(0), dir(180), red);\n\t\tdraw(arc(origin,1+R,80,280), blue);\n\t\tlabel(\"$U_1$\", (1+R)*dir(180), dir(180), blue);\n\t\tdotfactor *= 2;\n\t\tpair A = opendot( (-3, -2), blue );\n\t\tpair B = opendot( (-1, -2), blue );\n\t\tlabel(\"$E_1$\", midpoint(A--B), dir(-90), blue);\n\t\tdraw(A--B, blue, Margins);\n\t\tdraw( (-1.25, -0.2)--(-2,-2), blue, EndArrow, Margins );\n\t\tlabel(\"$\\phi_1$\", (-1.675, -1.1), dir(180), blue);\n\n\t\tpair C = opendot( (1, -2), red );\n\t\tpair D = opendot( (3, -2), red );\n\t\tlabel(\"$E_2$\", midpoint(C--D), dir(-90), red);\n\t\tdraw(C--D, red, Margins);\n\t\tdraw( (1.25, -0.2)--(2,-2), red, EndArrow, Margins );\n\t\tlabel(\"$\\phi_2$\", (1.672, -1.1), dir(0), red);\n\t\\end{asy}\n\\end{center}\n\\end{example}\n\n\\begin{ques}\n\tWhere do you think the words ``chart'' and ``atlas'' come from?\n\\end{ques}\n\n\\begin{example}\n\t[Some examples of topological manifolds]\n\t\\listhack\n\t\\begin{enumerate}[(a)]\n\t\t\\ii As discussed at length,\n\t\tthe sphere $S^2$ is a $2$-manifold: every point in the sphere has a\n\t\tsmall open neighborhood that looks like $D^2$.\n\t\tOne can cover the Earth with just two hemispheres,\n\t\tand each hemisphere is homeomorphic to a disk.\n\n\t\t\\ii The circle $S^1$ is a $1$-manifold; every point has an\n\t\topen neighborhood that looks like an open interval.\n\n\t\t\\ii The torus, Klein bottle, $\\RP^2$, $\\CP^2$ are all $2$-manifolds.\n\n\t\t\\ii $\\RR^n$ is trivially a manifold, as are its open sets.\n\t\\end{enumerate}\n\tAll these spaces are compact except $\\RR^n$.\n\n\tA non-example of a manifold is $D^n$, because it has a \\emph{boundary};\n\tpoints on the boundary do not have open neighborhoods\n\tthat look Euclidean.\n\\end{example}\n\n\\section{Smooth manifolds}\n\\prototype{All the topological manifolds.}\n\nLet $M$ be a topological $n$-manifold with atlas\n$\\{U_i \\taking{\\phi_i} E_i\\}$.\n\\begin{definition}\n\tFor any $i$, $j$ such that $U_i \\cap U_j \\neq \\varnothing$,\n\tthe \\vocab{transition map} $\\phi_{ij}$ is the composed map\n\t\\[\n\t\t\\phi_{ij} : E_i \\cap \\phi_i\\im(U_i \\cap U_j)\n\t\t\\taking{\\phi_i\\inv}\n\t\tU_i \\cap U_j\n\t\t\\taking{\\phi_j} E_j \\cap \\phi_j\\im(U_i \\cap U_j).\n\t\\]\n\\end{definition}\nSorry for the dense notation, let me explain.\nThe intersection with the image $\\phi_i\\im(U_i \\cap U_j)$\nand the image $\\phi_j\\im(U_i \\cap U_j)$ is a notational annoyance\nto make the map well-defined and a homeomorphism.\nThe transition map is just the natural way to go from $E_i \\to E_j$,\nrestricted to overlaps.\nPicture below, where the intersections are just the green portions\nof each $E_1$ and $E_2$:\n\n\\begin{center}\n\t\\begin{asy}\n\t\tsize(8cm);\n\t\tdraw(unitcircle, black);\n\t\tdraw(arc(origin, 1, 80, 100), heavygreen+2);\n\t\tdraw(arc(origin, 1, -100, -80), heavygreen+2);\n\t\tlabel(\"$S^1$\", dir(45), dir(45));\n\t\treal R = 0.1;\n\t\tdraw(arc(origin,1-R,-100,100), red);\n\t\tlabel(\"$U_2$\", (1-R)*dir(0), dir(180), red);\n\t\tdraw(arc(origin,1+R,80,280), blue);\n\t\tlabel(\"$U_1$\", (1+R)*dir(180), dir(180), blue);\n\t\tdotfactor *= 2;\n\t\tpair A = opendot( (-3, -2), blue );\n\t\tpair B = opendot( (-1, -2), blue );\n\t\tlabel(\"$E_1$\", midpoint(A--B), dir(-90), blue);\n\t\tdraw(A--B, blue, Margins);\n\t\tdraw( (-1.25, -0.2)--(-2,-2), blue, EndArrow, Margins );\n\t\tlabel(\"$\\phi_1$\", (-1.675, -1.1), dir(180), blue);\n\n\t\tpair C = opendot( (1, -2), red );\n\t\tpair D = opendot( (3, -2), red );\n\t\tlabel(\"$E_2$\", midpoint(C--D), dir(-90), red);\n\t\tdraw(C--D, red, Margins);\n\t\tdraw( (1.25, -0.2)--(2,-2), red, EndArrow, Margins );\n\t\tlabel(\"$\\phi_2$\", (1.672, -1.1), dir(0), red);\n\n\t\tdraw(A--(0.7*A+0.3*B), heavygreen+2, Margins);\n\t\tdraw(B--(0.7*B+0.3*A), heavygreen+2, Margins);\n\t\tdraw(C--(0.7*C+0.3*D), heavygreen+2, Margins);\n\t\tdraw(D--(0.7*D+0.3*C), heavygreen+2, Margins);\n\t\tdraw(B--C, heavygreen, EndArrow, Margin(4,4));\n\t\tlabel(\"$\\phi_{12}$\", B--C, dir(90), heavygreen);\n\t\\end{asy}\n\\end{center}\n\n\nWe want to add enough structure so that we can use differential forms.\n\n\\begin{definition}\n\tWe say $M$ is a \\vocab{smooth manifold} \n\tif all its transition maps are smooth.\n\\end{definition}\n\nThis definition makes sense, because we know what it means\nfor a map between two open sets of $\\RR^n$ to be differentiable.\n\nWith smooth manifolds we can try to port over definitions that\nwe built for $\\RR^n$ onto our manifolds.\nSo in general, all definitions involving smooth manifolds will reduce to \nsomething on each of the coordinate charts, with a compatibility condition.\n\nAS an example, here is the definition of a ``smooth map'':\n\\begin{definition}\n\t\\begin{enumerate}[(a)]\n\t\t\\ii Let $M$ be a smooth manifold.\n\t\tA continuous function $f : M \\to \\RR$ is called \\vocab{smooth}\n\t\tif the composition\n\t\t\\[ E_i \\taking{\\phi_i\\inv} U_i \\injto M \\taking f \\RR \\]\n\t\tis smooth as a function $E_i \\to \\RR$.\n\t\t\\ii Let $M$ and $N$ be smooth\n\t\twith atlases $\\{ U_i^M \\taking{\\phi_i} E_i^M \\}_i$\n\t\tand $\\{ U_j^N \\taking{\\phi_j} E_i^N \\}_j$,\n\t\tA map $f : M \\to N$ is \\vocab{smooth} if for every $i$ and $j$,\n\t\tthe composed map\n\t\t\\[ E_i \\taking{\\phi_i\\inv} U_i \\injto M\n\t\t\t\\taking f N \\surjto U_j \\taking{\\phi_j} E_j \\]\n\t\tis smooth, as a function $E_i \\to E_j$.\n\t\\end{enumerate}\n\\end{definition}\n\n\\section{Regular value theorem}\n\\prototype{$x^2+y^2=1$ is a circle!}\nDespite all that I've written about general manifolds,\nit would be sort of mean if I left you here\nbecause I have not really told you how to actually construct\nmanifolds in practice, even though we know the circle\n$x^2+y^2=1$ is a great example of a one-dimensional\nmanifold embedded in $\\RR^2$.\n\n\\begin{theorem}\n\t[Regular value theorem]\n\tLet $V$ be an $n$-dimensional real normed vector\n\tspace, let $U \\subseteq V$ be open\n\tand let $f_1, \\dots, f_m \\colon U \\to \\RR$\n\tbe smooth functions.\n\tLet $M$ be the set of points $p \\in U$\n\tsuch that $f_1(p) = \\dots = f_m(p) = 0$.\n\n\tAssume $M$ is nonempty and that the map\n\t\\[ V \\to \\RR^m \\quad\\text{by}\\quad\n\t\tv \\mapsto \\left( (Df_1)_p(v), \\dots, (Df_m)_p(v) \\right) \\]\n\thas rank $m$, for every point $p \\in M$.\n\tThen $M$ is a manifold of dimension $n-m$.\n\\end{theorem}\nFor a proof, see \\cite[Theorem 6.3]{ref:manifolds}.\n\nOne very common special case is to take $m = 1$ above.\n\\begin{corollary}\n\t[Level hypersurfaces]\n\tLet $V$ be a finite-dimensional real normed vector\n\tspace, let $U \\subseteq V$ be open\n\tand let $f \\colon U \\to \\RR$ be smooth.\n\tLet $M$ be the set of points $p \\in U$\n\tsuch that $f(p) = 0$.\n\tIf $M \\ne \\varnothing$ and\n\t$(Df)_p$ is not the zero map for any $p \\in M$,\n\tthen $M$ is a manifold of dimension $n-1$.\n\\end{corollary}\n\n\\begin{example}\n\t[The circle $x^2+y^2-c=0$]\n\tLet $f(x,y) = x^2+y^2 - c$, $f \\colon \\RR^2 \\to \\RR$,\n\twhere $c$ is a positive real number.\n\tNote that\n\t\\[ Df = 2x \\cdot dx + 2y \\cdot dy \\]\n\twhich in particular is nonzero\n\tas long as $(x,y) \\ne (0,0)$, i.e.\\ as long as $c \\ne 0$.\n\tThus:\n\t\\begin{itemize}\n\t\t\\ii When $c > 0$, the resulting curve ---\n\t\ta circle with radius $\\sqrt c$ ---\n\t\tis a one-dimensional manifold, as we knew.\n\t\t\\ii When $c = 0$, the result fails.\n\t\tIndeed, $M$ is a single point,\n\t\twhich is actually a zero-dimensional manifold!\n\t\\end{itemize}\n\\end{example}\n\nWe won't give further examples\nsince I'm only mentioning this in passing\nin order to increase your capacity to write real concrete examples.\n(But \\cite[Chapter 6.2]{ref:manifolds} has some more examples,\nbeautifully illustrated.)\n\n\\section{Differential forms on manifolds}\nWe already know what a differential form is on an open set $U \\subseteq \\RR^n$.\nSo, we naturally try to port over the definition of\ndifferentiable form on each subset, plus a compatibility condition.\n\nLet $M$ be a smooth manifold with atlas $\\{ U_i \\taking{\\phi_i} E_i \\}_i$.\n\n\\begin{definition}\n\tA \\vocab{differential $k$-form} $\\alpha$ on a smooth manifold $M$\n\tis a collection $\\{\\alpha_i\\}_i$ of differential $k$-forms on each $E_i$,\n\tsuch that for any $j$ and $i$ we have that\n\t\\[ \\alpha_j = \\phi_{ij}^\\ast(\\alpha_i). \\]\n\\end{definition}\nIn English: we specify a differential form on each chart,\nwhich is compatible under pullbacks of the transition maps.\n\n\\section{Orientations}\n\\prototype{Left versus right, clockwise vs.\\ counterclockwise.}\n\nThis still isn't enough to integrate on manifolds.\nWe need one more definition: that of an orientation.\n\nThe main issue is the observation from standard calculus that\n\\[ \\int_a^b f(x) \\; dx = - \\int_b^a f(x) \\; dx. \\]\nConsider then a space $M$ which is homeomorphic to an interval.\nIf we have a $1$-form $\\alpha$, how do we integrate it over $M$?\nSince $M$ is just a topological space (rather than a subset of $\\RR$),\nthere is no default ``left'' or ``right'' that we can pick.\nAs another example, if $M = S^1$ is a circle, there is\nno default ``clockwise'' or ``counterclockwise'' unless we decide\nto embed $M$ into $\\RR^2$.\n\nTo work around this we have to actually have to\nmake additional assumptions about our manifold.\n\\begin{definition}\n\tA smooth $n$-manifold is \\vocab{orientable} if\n\tthere exists a differential $n$-form $\\omega$ on $M$\n\tsuch that for every $p \\in M$,\n\t\\[ \\omega_p \\neq 0. \\]\n\\end{definition}\nRecall here that $\\omega_p$ is an element of $\\Lambda^n(V^\\vee)$.\nIn that case we say $\\omega$ is a \\vocab{volume form} of $M$.\n\nHow do we picture this definition?\nIf we recall that an differential form is supposed to take\ntangent vectors of $M$ and return real numbers.\nTo this end, we can think of each point $p \\in M$ as\nhaving a \\vocab{tangent plane} $T_p(M)$ which is $n$-dimensional.\nNow since the volume form $\\omega$ is $n$-dimensional,\nit takes an entire basis of the $T_p(M)$ and gives a real number.\nSo a manifold is orientable if there exists a consistent choice of\nsign for the basis of tangent vectors at every point of the manifold.\n\nFor ``embedded manifolds'', this just amounts to being able\nto pick a nonzero field of normal vectors to each point $p \\in M$.\nFor example, $S^1$ is orientable in this way.\n\\begin{center}\n\t\\begin{asy}\n\t\tsize(5cm);\n\t\tdraw(unitcircle, blue+1);\n\t\tlabel(\"$S^1$\", dir(100), dir(100), blue);\n\t\tvoid arrow(real theta) {\n\t\t\tpair P = dir(theta);\n\t\t\tdot(P);\n\t\t\tpair delta = 0.5*P;\n\t\t\tdraw( P--(P+delta), EndArrow );\n\t\t}\n\t\tarrow(0);\n\t\tarrow(50);\n\t\tarrow(140);\n\t\tarrow(210);\n\t\tarrow(300);\n\t\\end{asy}\n\\end{center}\nSimilarly, one can orient a sphere $S^2$ by having\na field of vectors pointing away (or towards) the center.\nThis is all non-rigorous,\nbecause I haven't defined the tangent plane $T_p(M)$;\nsince $M$ is in general an intrinsic object one has to be\nquite roundabout to define $T_p(M)$ (although I do so in an optional section later).\nIn any event, the point is that guesses about the orientability\nof spaces are likely to be correct.\n\n\\begin{example}\n\t[Orientable surfaces]\n\t\\listhack\n\t\\begin{enumerate}[(a)]\n\t\t\\ii Spheres $S^n$, planes, and the torus $S^1 \\times S^1$ are orientable.\n\t\t\\ii The M\\\"obius strip and Klein bottle are \\emph{not} orientable:\n\t\tthey are ``one-sided''.\n\t\t\\ii $\\CP^n$ is orientable for any $n$.\n\t\t\\ii $\\RP^n$ is orientable only for odd $n$.\n\t\\end{enumerate}\n\\end{example}\n\n\n\\section{Stokes' theorem for manifolds}\nStokes' theorem in the general case is based on the idea\nof a \\vocab{manifold with boundary} $M$, which I won't define,\nother than to say its boundary $\\partial M$ is an $n-1$ dimensional manifold,\nand that it is oriented if $M$ is oriented.\nAn example is $M = D^2$, which has boundary $\\partial M = S^1$.\n\nNext,\n\\begin{definition}\n\tThe \\vocab{support} of a differential form $\\alpha$ on $M$\n\tis the closure of the set\n\t\\[ \\left\\{ p \\in M \\mid \\alpha_p \\neq 0 \\right\\}. \\]\n\tIf this support is compact as a topological space,\n\twe say $\\alpha$ is \\vocab{compactly supported}.\n\\end{definition}\n\\begin{remark}\n\tFor example, volume forms are supported on all of $M$.\n\\end{remark}\n\nNow, one can define integration on oriented manifolds,\nbut I won't define this because the definition is truly awful.\nThen Stokes' theorem says\n\\begin{theorem}\n\t[Stokes' theorem for manifolds]\n\tLet $M$ be a smooth oriented $n$-manifold with boundary\n\tand let $\\alpha$ be a compactly supported $n-1$-form.\n\tThen\n\t\\[ \\int_M d\\alpha = \\int_{\\partial M} \\alpha. \\]\n\\end{theorem}\nAll the omitted details are developed in full in \\cite{ref:manifolds}.\n\n\\section{(Optional) The tangent and contangent space}\n\\prototype{Draw a line tangent to a circle, or a plane tangent to a sphere.}\n\nLet $M$ be a smooth manifold and $p \\in M$ a point.\nI omitted the definition of $T_p(M)$ earlier,\nbut want to actually define it now.\n\nAs I said, geometrically we know what this \\emph{should}\nlook like for our usual examples.\nFor example, if $M = S^1$ is a circle embedded in $\\RR^2$,\nthen the tangent vector at a point $p$\nshould just look like a vector running off tangent to the circle.\nSimilarly, given a sphere $M = S^2$,\nthe tangent space at a point $p$ along the sphere\nwould look like plane tangent to $M$ at $p$.\n\n\\begin{center}\n\t\\begin{asy}\n\t\tsize(5cm);\n\t\tdraw(unitcircle);\n\t\tlabel(\"$S^1$\", dir(140), dir(140));\n\t\tpair p = dir(0);\n\t\tdraw( (1,-1.4)--(1,1.4), mediumblue, Arrows);\n\t\tlabel(\"$T_p(M)$\", (1, 1.4), dir(-45), mediumblue);\n\t\tdraw(p--(1,0.7), red, EndArrow);\n\t\tlabel(\"$\\vec v \\in T_p(M)$\", (1,0.7), dir(-15), red);\n\t\tdot(\"$p$\", p, p, blue);\n\t\\end{asy}\n\\end{center}\n\nHowever, one of the points of all this manifold stuff\nis that we really want to see the manifold\nas an \\emph{intrinsic object}, in its own right,\nrather than as embedded in $\\RR^n$.\\footnote{This\n\tcan be thought of as analogous to the way\n\tthat we think of a group as an abstract object in its own right,\n\teven though Cayley's Theorem tells us that any group is a subgroup\n\tof the permutation group.\n\t\n\tNote this wasn't always the case!\n\tDuring the 19th century, a group was literally defined\n\tas a subset of $\\text{GL}(n)$ or of $S_n$.\n\tIn fact Sylow developed his theorems without the word ``group''\n\tOnly much later did the abstract definition of a group was given,\n\tan abstract set $G$ which was independent of any \\emph{embedding} into $S_n$,\n\tand an object in its own right.}\nSo, we would like our notion of a tangent vector to not refer to an ambient space,\nbut only to intrinsic properties of the manifold $M$ in question.\n\n\\subsection{Tangent space}\nTo motivate this construction, let us start\nwith an embedded case for which we know the answer already:\na sphere.\n\nSuppose $f \\colon S^2 \\to \\RR$ is a\nfunction on a sphere, and take a point $p$.\nNear the point $p$, $f$ looks like a function\non some open neighborhood of the origin.\nThus we can think of taking a \\emph{directional derivative}\nalong a vector $\\vec v$ in the imagined tangent plane\n(i.e.\\ some partial derivative).\nFor a fixed $\\vec v$ this partial derivative is a linear map\n\\[ D_{\\vec v} \\colon C^\\infty(M) \\to \\RR. \\]\n\nIt turns out this goes the other way:\nif you know what $D_{\\vec v}$ does to every smooth function,\nthen you can recover $v$.\nThis is the trick we use in order to create the tangent space.\nRather than trying to specify a vector $\\vec v$ directly\n(which we can't do because we don't have an ambient space),\n\\begin{moral}\n\tThe vectors \\emph{are} partial-derivative-like maps.\n\\end{moral}\nMore formally, we have the following.\n\\begin{definition}\n\tA \\vocab{derivation} $D$ at $p$ is a linear map\n\t$D \\colon C^\\infty(M) \\to \\RR$\n\t(i.e.\\ assigning a real number to every smooth $f$)\n\tsatisfying the following Leibniz rule:\n\tfor any $f$, $g$ we have the equality\n\t\\[ D(fg) = f(p) \\cdot D(g) + g(p) \\cdot D(f) \\in \\RR. \\]\n\\end{definition}\nThis is just a ``product rule''.\nThen the tangent space is easy to define:\n\\begin{definition}\n\tA \\vocab{tangent vector} is just a derivation at $p$, and\n\tthe \\vocab{tangent space} $T_p(M)$ is simply\n\tthe set of all these tangent vectors.\n\\end{definition}\nIn this way we have constructed the tangent space.\n\n\\subsection{The cotangent space}\nIn fact, one can show that the product rule\nfor $D$ is equivalent to the following three conditions:\n\\begin{enumerate}\n\t\\ii $D$ is linear, meaning $D(af+bg) = a D(f) + b D(g)$.\n\t\\ii $D(1_M) = 0$, where $1_M$ is the constant function on $M$.\n\t\\ii $D(fg) = 0$ whenever $f(p) = g(p) = 0$.\n\tIntuitively, this means that if a function $h = fg$\n\tvanishes to second order at $p$,\n\tthen its derivative along $D$ should be zero. \n\\end{enumerate}\n\nThis suggests a third equivalent definition:\nsuppose we define\n\\[ \\km_p \\defeq \\left\\{ f \\in C^\\infty M \\mid f(p) = 0 \\right\\} \\]\nto be the set of functions which vanish at $p$\n(this is called the \\emph{maximal ideal} at $p$).\nIn that case,\n\\[ \\km_p^2 = \\left\\{ \\sum_i f_i \\cdot g_i\n\t\\mid f_i(p) = g_i(p) = 0 \\right\\} \\]\nis the set of functions vanishing to second order at $p$.\nThus, a tangent vector is really just a linear map\n\\[ \\km_p / \\km_p^2 \\to \\RR. \\]\nIn other words, the tangent space is actually the\ndual space of $\\km_p / \\km_p^2$;\nfor this reason, the space $\\km_p / \\km_p^2$ is defined as the\n\\vocab{cotangent space} (the dual of the tangent space).\nThis definition is even more abstract than the one with derivations above,\nbut has some nice properties:\n\\begin{itemize}\n\t\\ii it is coordinate-free, and\n\t\\ii it's defined only in terms of the smooth functions $M \\to \\RR$,\n\twhich will be really helpful later on in algebraic geometry\n\twhen we have varieties or schemes and can repeat this definition.\n\\end{itemize}\n\n\\subsection{Sanity check}\nWith all these equivalent definitions, the last thing I should do is check that\nthis definition of tangent space actually gives a vector space of dimension $n$.\nTo do this it suffices to show verify this for open subsets of $\\RR^n$,\nwhich will imply the result for general manifolds $M$\n(which are locally open subsets of $\\RR^n$).\nUsing some real analysis, one can prove the following result:\n\\begin{theorem}\n\tSuppose $M \\subset \\RR^n$ is open and $0 \\in M$.\n\tThen\n\t\\[\n\t\\begin{aligned}\n\t\t\\km_0 &= \\{ \\text{smooth functions } f : f(0) = 0 \\} \\\\\n\t\t\\km_0^2 &= \\{ \\text{smooth functions } f : f(0) = 0, (\\nabla f)_0 = 0 \\}.\n\t\\end{aligned}\n\t\\]\n\tIn other words $\\km_0^2$ is the set of functions which vanish at $0$\n\tand such that all first derivatives of $f$ vanish at zero.\n\\end{theorem}\nThus, it follows that there is an isomorphism\n\\[ \\km_0 / \\km_0^2 \\cong \\RR^n\n\t\\quad\\text{by}\\quad\n\tf \\mapsto\n\t\\left[ \\frac{\\partial f}{\\partial x_1}(0),\n\t\t\\dots, \\frac{\\partial f}{\\partial x_n}(0) \\right] \\]\nand so the cotangent space, hence tangent space,\nindeed has dimension $n$.\n\n%\\subsection{So what does this have to do with orientations?}\n%\\todo{beats me}\n\n\\section\\problemhead\n\\begin{problem}\n\tShow that a differential $0$-form on a smooth manifold $M$\n\tis the same thing as a smooth function $M \\to \\RR$.\n\\end{problem}\n\\todo{some applications of regular value theorem here}\n", "meta": {"hexsha": "2a657a45d8945f8c3cc28be3ec0ca219938dc119", "size": 21246, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "corpus/napkin/tex/diffgeo/manifolds.tex", "max_stars_repo_name": "aDotInTheVoid/ltxmk", "max_stars_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "corpus/napkin/tex/diffgeo/manifolds.tex", "max_issues_repo_name": "aDotInTheVoid/ltxmk", "max_issues_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "corpus/napkin/tex/diffgeo/manifolds.tex", "max_forks_repo_name": "aDotInTheVoid/ltxmk", "max_forks_repo_head_hexsha": "ee461679e51e92a0e4b121f28ae5fe17d5e5319e", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0785340314, "max_line_length": 84, "alphanum_fraction": 0.692036148, "num_tokens": 6747, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4006954891460699}}
{"text": "\\documentclass[acmsmall,nonacm]{acmart}\n\n\\bibliographystyle{ACM-Reference-Format}\n\\citestyle{acmauthoryear}\n\n\\RequirePackage{tikz}\n\\RequirePackage{scalerel}\n\\RequirePackage{xparse}\n\\RequirePackage{xifthen}\n\n\\usepackage{mathpartir}\n\n\\usetikzlibrary{shapes}\n\\usetikzlibrary{arrows}\n\\usetikzlibrary{calc}\n\\usetikzlibrary{arrows.meta}\n\n\n\n%% Invariants and Ghost ownership\n% PDS: Was 0pt inner, 2pt outer.\n% \\boxedassert [tikzoptions] contents [name]\n\\tikzstyle{boxedassert_border} = [sharp corners,line width=0.2pt]\n\\NewDocumentCommand \\boxedassert {O{} m o}{%\n\t\\tikz[baseline=(m.base)]{\n\t\t%\t  \\node[rectangle, draw,inner sep=0.8pt,anchor=base,#1] (m) {${#2}\\mathstrut$};\n\t\t\\node[rectangle,inner sep=0.8pt,outer sep=0.2pt,anchor=base] (m) {${\\,#2\\,}\\mathstrut$};\n\t\t\\draw[#1,boxedassert_border] ($(m.south west) + (0,0.65pt)$) rectangle ($(m.north east) + (0, 0.7pt)$);\n\t}\\IfNoValueF{#3}{^{\\,#3}}%\n}\n\\DeclareMathOperator*{\\Sep}{\\scalerel*{\\ast}{\\sum}}\n\\newcommand*{\\ghost}[1]{\\boxedassert[densely dashed]{#1}}\n\\newcommand*{\\N}{\\mathbb{N}}\n\\newcommand*{\\Z}{\\mathbb{Z}}\n\\newcommand{\\wand}{\\mathrel{-\\!\\!\\ast}}\n\\newcommand{\\core}[1]{\\left| #1 \\right|}\n\\newcommand{\\proves}{\\vdash}\n\\newcommand{\\makes}{\\dashv}\n\\newcommand{\\reach}{\\rightsquigarrow}\n\\newcommand{\\constep}{\\proves\\cdot\\makes}\n\\newcommand{\\makesto}{\\dashv\\!\\constep}\n\\newcommand{\\judgment}[2][]{\\noindent\\\\\\textbf{#1}\\hspace{\\stretch{1}}\\fbox{$#2$}\\nopagebreak}\n\\newcommand{\\judgmentB}[3][]{\\noindent\\\\\\textbf{#1}\\hspace{\\stretch{1}}\\fbox{$#2$}\\ \\ \\fbox{$#3$}\\nopagebreak}\n\\newcommand*{\\axiom}[2][]{\\infer[#1]{}{#2}}\n\n\\begin{document}\n\n\\title{Metamath C technical appendix}\n\n%% Author with single affiliation.\n\\author{Mario Carneiro}\n\\affiliation{\n  \\institution{Carnegie Mellon University}\n}\n\n% \\begin{abstract}\n% Text of abstract \\ldots.\n% \\end{abstract}\n\n\\maketitle\n\n\n\\section{Introduction}\n\nThis is an informal development of the theory behind the Metamath C language: the syntax and separation logic, as well as the lowering map to x86. For now, this is just a set of notes for the actual compiler. (Informal is a relative word, of course, and this is quite formally precise from a mathematician's point of view. But it is not mechanized.)\n\n\\section{Syntax}\n\nThe syntax of MMC programs, after type inference, is given by the following (incomplete) grammar:\n\n\\begin{align*}\n  \\alpha,x,h,k\\in \\mathrm{Ident} ::={}& \\mathrm{identifiers}\\\\\n  s \\in \\mathrm{Size} ::={}& 8\\mid 16\\mid 32\\mid 64\\mid \\infty&&\\mbox{integer bit size}\\\\\n  t \\in \\mathrm{TuplePattern} ::={}& \\_\\mid x\\mid \\ghost{x}&&\\mbox{ignored, variable, ghost variable}\\\\\n    \\mid{}&t:\\tau \\mid \\langle \\overline{t}\\rangle&&\\mbox{type ascription, tuple}\\\\\n  R \\in \\mathrm{Arg} ::={}& x:\\tau\\mid \\ghost{x}:\\tau&&\\mbox{regular/ghost argument}\\\\\n  \\tau\\in\\mathrm{Type} ::={}& \\alpha&&\\mbox{type variable reference}\\\\\n    \\mid{}& \\core\\alpha&&\\mbox{moved type variable}\\\\\n    \\mid{}&\\mathbf{1}\\mid\\top\\mid \\bot\\mid \\mathsf{bool}&&\\mbox{unit, true, false, booleans}\\\\\n    \\mid{}&\\N_s\\mid \\Z_s&&\\mbox{unsigned and signed integers of different sizes}\\\\\n    \\mid{}&\\tau_1\\land \\tau_2\\mid \\tau_1\\ast \\tau_2\\mid \\tau_1\\lor \\tau_2&&\\mbox{conjunction (regular, separating), disjunction}\\\\\n    \\mid{}&\\tau_1\\to \\tau_2\\mid \\tau_1 \\wand \\tau_2\\mid \\neg \\tau&&\\mbox{implication (regular, separating), negation}\\\\\n    \\mid{}&\\forall x:\\tau_1,\\;\\tau_2\\mid \\textstyle\\sum x:\\tau_1,\\;\\tau_2&&\\mbox{universal, existential quantification}\\\\\n    \\mid{}& pe&&\\mbox{assert that a boolean value is true}\\\\\n    \\mid{}&pe\\mapsto pe'&&\\mbox{points-to assertion}\\\\\n    \\mid{}&\\boxed{x:\\tau}&&\\mbox{typing assertion}\\\\\n    \\mid{}&S(\\overline{\\tau},\\overline{pe})&&\\mbox{user-defined type}\\\\\n\\end{align*}\n\\begin{align*}\n  pe\\in \\mathrm{PureExpr} ::={}&\\mbox{(the first half of Expr below)}&&\\mbox{pure expressions}\\\\\n  e \\in \\mathrm{Expr} ::={}& x&&\\mbox{variable reference}\\\\\n    \\mid{}&()\\mid \\mathsf{true}\\mid \\mathsf{false}\\mid n&&\\mbox{constants}\\\\\n    \\mid{}&e_1 \\land e_2\\mid e_1 \\lor e_2\\mid \\neg e&&\\mbox{logical AND, OR, NOT}\\\\\n    \\mid{}&e_1 \\mathbin\\texttt{\\&} e_2\\mid e_1 \\mathbin\\texttt{|} e_2\\mid \\texttt{!}_s\\; e&&\\mbox{bitwise AND, OR, NOT}\\\\\n    \\mid{}&e_1 + e_2\\mid e_1 * e_2\\mid -e&&\\mbox{addition, multiplication, negation}\\\\\n    \\mid{}&e_1 < e_2\\mid e_1 \\le e_2\\mid e_1 = e_2&&\\mbox{equalities and inequalities}\\\\\n    \\mid{}&\\mathsf{if}\\;h^? : e_1\\;\\mathsf{then}\\;e_2\\;\\mathsf{else}\\;e_3&&\\mbox{conditionals}\\\\\n    \\mid{}&\\langle\\overline{e}\\rangle&&\\mbox{tuple}\\\\\n    \\mid{}&f(\\overline{e})&&\\mbox{(pure) function call}\\\\[2mm]\n%\n    \\mid{}&\\mathsf{let}\\ t := e_1\\;\\mathsf{in}\\; e_2 &&\\mbox{assignment to a variable}\\\\\n    \\mid{}& \\eta \\gets pe;\\ e\\mid\\ghost{\\eta \\gets pe};\\ e&&\\mbox{move assignment}\\\\\n    \\mid{}&F(\\overline{e})&&\\mbox{procedure call}\\\\\n    \\mid{}&\\mathsf{unreachable}\\;e&&\\mbox{unreachable statement}\\\\\n    \\mid{}&\\mathsf{return}\\; \\overline{e}&&\\mbox{procedure return}\\\\\n    \\mid{}&\\mathsf{label}\\;\\overline{k(\\overline{R}):=e}\\;\\mathsf{in}\\;e'&&\\mbox{local mutual tail recursion}\\\\\n    \\mid{}&\\mathsf{goto}\\;k(\\overline{e})&&\\mbox{local tail call}\\\\\n    \\mid{}&\\mathsf{entail}\\;\\overline{e}\\;p&&\\mbox{entailment proof}\\\\\n    \\mid{}&\\mathsf{assert}\\;pe&&\\mbox{assertion}\\\\\n    \\mid{}&\\mathsf{typeof}\\;pe&&\\mbox{take the type of a variable}\\\\\n  p \\in \\mathrm{PureProof} ::={}&\\dots&&\\mbox{MM0 proofs}\\\\\n  \\eta \\in \\mathrm{Place} ::={}& x&&\\mbox{variable reference}\\\\\n\\end{align*}\n\\begin{align*}\n  it \\in \\mathrm{Item} ::={}&\\mathsf{type}\\;S(\\overline{\\alpha}, \\overline{R}):=\\tau&&\\mbox{type declaration}\\\\\n    \\mid{}&\\mathsf{const}\\;t:=e&&\\mbox{constant declaration}\\\\\n    \\mid{}&\\mathsf{global}\\;t:=e&&\\mbox{global variable declaration}\\\\\n    \\mid{}&\\mathsf{func}\\;f(\\overline{R}):\\overline{R}:=e&&\\mbox{function declaration}\\\\\n    \\mid{}&\\mathsf{proc}\\;f(\\overline{R}):\\overline{R}:=e&&\\mbox{procedure declaration}\\\\\n\\end{align*}\n\nMissing elements of the grammar include:\n\\begin{itemize}\n  \\item Switch statements, which are desugared to if statements.\n  \\item Raw MM0 formulas can be lifted to the `Type' type as booleans.\n  \\item Raw MM0 values can be lifted into $\\N_\\infty$ and $\\Z_\\infty$.\n  \\item There are more operations for working with pointers and arrays. These are discussed in section \\ref{sec:pointers}.\n  \\item There are operations for moving between typed values and hypotheses, which will be discussed later.\n  \\item There are also \\textsf{while} loops and \\textsf{for} loops, but we will focus on the general control flow of \\textsf{label} and \\textsf{goto}.\n\\end{itemize}\n\nLanguage items that are considered but not present (yet) in the language include:\n\\begin{itemize}\n  \\item Functions and procedures cannot be generic over type and propositional variables. (In fact there are no propositional variables in the language, only the type Prop of propositional expressions.) A generic propositional variable is used internally to model the frame rule but it is not available to user code.\n  \\item Recursive and mutually recursive function support is currently very limited.\n\\end{itemize}\nMost of the constructs are likely familiar from other languages. We will call some attention to the more unusual features:\n\\begin{itemize}\n  \\item Ghost variables $\\ghost x$ are used to represent computationally irrelevant data. They can be manipulated just like regular variables, but they must not appear on the data path during code generation. We will use $x^\\gamma$ to generalize over ghost and non-ghost variables, where $\\gamma=\\bot$ means this is a ghost variable and $\\gamma=\\top$ means it is not. We use $\\gamma'\\le \\gamma$ to mean that $\\gamma$ is ``more computationally relevant'' than $\\gamma'$, i.e. if $x^\\gamma$ is ghost then $x^{\\gamma'}$ is too.\n\n  \\item The $\\texttt{!}_s\\; n$ operation performs the mathematical function $2^s-n-1$, taking $2^\\infty=0$ so that $\\texttt{!}_\\infty\\; n=-n-1$. $\\texttt{!}_s\\; n$ is used for bitwise negation of unsigned integers, and $\\texttt{!}_\\infty\\; n$ is used for bitwise negation of signed integers (even those of finite width).\n  \\item The assignment operator $\\mathsf{let}\\ t := e_1\\;\\mathsf{in}\\; e_2$ assigns the variables of $t$ to the result of $e_1$, but here it should be understood as a new binding, or shadowing declaration, rather than a reassignment to an existing variable. Even array assignments will be desugared into pure-functional update operations.\n\n  The concrete version of the assignment operator also contains a ``$\\mathsf{with}\\ x\\to y$'' clause, but this only renames variables in the source (which is to say, it changes the mapping of source names to internal names) and so is not relevant for the theoretical presentation here.\n\n  \\item The operator $x^\\gamma\\gets pe;\\ e$ is the primitive for mutation of the variables in the context (where, as with ghost variables, we use $\\gamma$ to generalize over the ghost and non-ghost versions of the operator). Intuitively, it can be thought as moving $pe$ into $x$, but it has no effect on the type context, and is only used to coordinate data flow. In the grammar the left hand side is generalized to a type of ``places'' (a.k.a lvalues), but for now these can only be variable references. For example,\n  \\begin{align*}\n    &\\qquad\\mbox{this:}\n      &&\\!\\!\\!\\!\\!\\!\\mbox{has the same effect as:}\n        &&\\!\\!\\!\\!\\!\\!\\mbox{which we can $\\alpha$-rename to:}\\\\\n    &\\mathsf{let}\\ x := 1\\;\\mathsf{in}\n      &&\\mathsf{let}\\ x := 1\\;\\mathsf{in}\n        &&\\mathsf{let}\\ x := 1\\;\\mathsf{in}\\\\\n    &\\mathsf{let}\\ y :=\n      &&\\mathsf{let}\\ \\langle x,y\\rangle :=\n        &&\\mathsf{let}\\ \\langle x',y\\rangle :=\\\\\n    &\\quad x \\gets x+1;\n      &&\\quad \\mathsf{let}\\ x := x+1\\;\\mathsf{in}\\;\n        &&\\quad \\mathsf{let}\\ x' := x+1\\;\\mathsf{in}\\;\\\\\n    &\\quad {-x}\\;\\mathsf{in}\n      &&\\quad \\langle x,-x\\rangle\\;\\mathsf{in}\n        &&\\quad \\langle x',-x'\\rangle\\;\\mathsf{in}\\\\\n    &e(x,y)\n      &&e(x,y)\n        &&e(x',y)\n  \\end{align*}\n\n  \\item The expression $\\mathsf{label}\\;\\overline{k(\\overline{R}):=e}\\;\\mathsf{in}\\;e'$ is similar in behavior to a recursive let binding such as those found in functional languages, but the $\\overline{k}$ are all continuations, which is to say they do not return to the caller when using $\\mathsf{goto}\\;l(\\overline{e})$, which is how we ensure that they can be compiled to plain $\\mathsf{label}$ and $\\mathsf{goto}$ at the machine code level.\n\n  \\item The $\\mathsf{typeof}\\;pe$ operator ``moves'' a value $x:\\tau$ and returns a fact $\\boxed{x:\\tau}$ that asserts ownership of the resources of $x$. See \\ref{sec:moving}.\n\\end{itemize}\n\n\\section{Typing}\n\n\\subsection{Overview}\n\nThe main typing judgments are:\n\n\\begin{itemize}\n  \\item $\\Gamma \\proves t:\\tau \\Rightarrow \\overline{R}$\\\\ types a tuple pattern against a value of type $\\tau$, producing additional hypotheses $\\overline{R}$ that will enter the context\n  \\item $\\Gamma \\proves \\tau\\;\\mathsf{type}$\\\\ determines that a type $\\tau$ is a valid type in the current context\n  \\item $\\Gamma \\proves R\\;\\mathsf{arg}$\\\\ determines that $R$ is a valid argument extending the current context\n  \\item $\\Gamma;\\delta \\proves e:\\tau \\makes\\delta'$\\\\ determines that $e$ is a valid expression of type $\\tau$, which modifies the value context from $\\delta$ to $\\delta'$. In the special case where $\\delta'=\\delta$, we will write $\\Gamma;\\delta \\proves e:\\tau$ instead.\n  \\item $\\Gamma;\\delta \\proves e\\Rightarrow pe:\\tau \\makes\\delta'$\\\\ is the same as the previous, but additionally says that the returned value can be expressed as the pure expression $pe$ in context $\\Gamma$.\n  \\item $\\Gamma\\proves \\delta$ means that $\\delta$ is a valid value context.\n  It is defined as: if $(x:=pe:\\tau)\\in\\delta$ then $\\Gamma\\proves pe:\\tau$ and $x\\in\\mathrm{Dom}(\\Gamma)$, and if $(x\\to y)\\in\\delta$ then $x,y\\in\\mathrm{Dom}(\\Gamma)$.\n  \\item $\\Gamma \\proves pe:\\tau$\\\\ The typing rule for pure expressions, which does not depend on the value context.\n  \\item $\\Gamma \\constep \\Gamma'$\\\\ an auxiliary judgment for applying pending mutations to the context.\n  \\item $\\Gamma\\proves it\\;\\mathsf{ok}$\\\\ The top level item typing judgment\n\\end{itemize}\n\nCentral to all of these judgments is the context $\\Gamma$, which consists of:\n\\begin{itemize}\n  \\item The global environment of previously declared items, including in particular a record $\\mathsf{self}(\\bar R):\\bar S$ recording the type of the function being typechecked (if a function/procedure is being checked). This doesn't change during expression typing.\n  \\item A list of type variables $\\overline{\\alpha}$. This is only nonempty when type checking a type declaration.\n  \\item A list of declared jump targets $\\overline{k(\\delta,\\bar{R})}$, including a special jump target $\\mathsf{return}(\\bar{R})$ where $\\bar{R}$ is the declared return type. The $\\delta$ in each jump target is the context required for that jump to typecheck; it lies somewhere between the initial context $\\delta$ at the point of the $\\mathsf{label}$, and the moved-out context $\\core{\\delta}$.\n  \\item A list of logical variables $x:\\core{\\tau}$ with their types. Here $\\core{\\tau}$ is used to indicate that while the type $\\tau$ itself is recorded, it is only accessible in ``moved'' form.\n\\end{itemize}\n\nThe type variables don't depend on anything and cannot be introduced in the middle of an item, so these can be assumed to come first, but jump targets can depend on regular variables. We use the notation $\\Gamma,\\overline{k(\\bar{R})}$ and $\\Gamma,\\overline{R}$ to denote extension of the context with a list of jump targets or variables, respectively, and $\\Gamma,x\\gets pe:\\tau$ to denote the insertion of $x\\gets pe:\\tau$ into the list of mutations, replacing $x\\gets pe':\\tau'$ if it is present.\n\nThe secondary context used in the typing rule $\\Gamma,\\delta \\proves e:\\tau \\makes\\delta'$ for expressions is the ``value context'', which contains the actual current value of variables in the context. It has two components:\n\n\\begin{itemize}\n\\item A list of records of the form $x:=pe:\\tau$, which represent the ``actual resources'' associated to a variable $x$. Note that $x$ need not be in the context, but $\\Gamma\\proves pe:\\tau$ so all variables in $pe$ must be in the context. For function arguments and other variables with no known value, we use $x:\\tau$, a shorthand for $x:=x:\\tau$, where $(x:\\core\\tau)\\in\\Gamma$.\n\\item A rename map, which is a list of records of the form $x\\to y$ where $x$ and $y$ are variables which are either in the context or in the value context. This keeps track of what a variable's ``current name'' is, after some number of renames. When a block ends, the values associated to renamed variables become the initial values of variable names in the code following the block.\n\nA variable can only be renamed once, and it is always renamed to a fresh variable; this means that the rename map is an injective partial function, i.e., if $x\\to y,y'$ then $y=y'$ and if $x,x'\\to y$ then $x=x'$.\n\\end{itemize}\n\n\\subsection{Moving types}\\label{sec:moving}\n\nThe last essential element to understand the typing rules is the ``moved'' modality on types, denoted $\\core\\tau$. For separating propositions this is also known as the persistence modality, and it represents what is left of a proposition after all the ``ownership'' is removed from it. We use moved types to represent a value that has been accessed. This satisfies the axioms $\\core{\\core\\tau}=\\core\\tau$ and $A\\Leftrightarrow A\\ast\\core A$. We extend this to arbitrary arguments and contexts $\\core R$ and $\\core\\Gamma$ by applying the modality to all contained types.\n\nA type is called ``$\\mathsf{copy}$'' or persistent if $\\core\\tau=\\tau$, and is denoted $\\tau\\;\\mathsf{copy}$.\n\nThe moved modality is defined like so:\n\\begin{align*}\n  \\mathbf{1},\\top,\\bot,\\mathsf{bool},\\N_s, \\Z_s,pe&\\;\\mathsf{copy}\\\\\n  \\core{\\tau_1\\land \\tau_2}={}&\\core{\\tau_1}\\land \\core{\\tau_2}\\\\\n  \\core{\\tau_1\\lor \\tau_2}={}&\\core{\\tau_1}\\lor \\core{\\tau_2}\\\\\n  \\core{\\tau_1\\ast \\tau_2}={}&\\core{\\tau_1}\\ast \\core{\\tau_2}\\\\\n  \\core{\\textstyle\\sum x:\\tau_1,\\;\\tau_2}={}&\\textstyle\\sum x:\\core{\\tau_1},\\;\\core {\\tau_2}\\\\\n  \\core{S(\\overline{\\tau},\\overline{pe})}={}&\\core{S}(\\overline{\\tau},\\overline{pe})\\qquad\\mbox{(that is, the effect of moving $S$ is precalculated)}\\\\\n  \\core{pe\\mapsto pe'}={}&\\top\\\\\n  \\core{\\boxed{x:\\tau}}={}&\\boxed{x:\\core{\\tau}}\\\\\n  \\core{\\forall x:\\tau,\\;\\tau}={}& \\begin{cases}\n    \\forall x:\\tau,\\;\\core \\tau&\\mbox{if $\\tau\\;\\mathsf{copy}$}\\\\\n    \\top&o.w.\\\\\n  \\end{cases}\\\\\n  \\core{\\tau\\to \\tau'}={}& \\begin{cases}\n    \\tau\\to \\core{\\tau'}&\\mbox{if $\\tau\\;\\mathsf{copy}$}\\\\\n    \\top&o.w.\\\\\n  \\end{cases}\\\\\n  \\core{\\tau\\wand \\tau'}={}& \\begin{cases}\n    \\tau\\wand \\core{\\tau'}&\\mbox{if $\\tau\\;\\mathsf{copy}$}\\\\\n    \\top&o.w.\\\\\n  \\end{cases}\\\\\n  \\core{\\neg \\tau}={}& \\begin{cases}\n    \\neg \\tau&\\mbox{if $\\tau\\;\\mathsf{copy}$}\\\\\n    \\top&o.w.\\\\\n  \\end{cases}\\\\\n\\end{align*}\nBecause moving is monotonic, that is $A\\Rightarrow \\core A$ but not the other way around, negative uses of a non-persistent proposition cause it to completely collapse to $\\top$ when moved.\n\nWhen we get to pointer types in section \\ref{sec:pointers} we will see that $\\core{\\&^\\mathbf{own}\\tau}=\\core{\\&^\\mathbf{mut}\\tau}=\\N_{64}$, so pointers become ``mere integers'' after they are moved away. (Note, however, that they actually retain their original types for type inference purposes; that is, the typechecker remembers that they have type $\\core{\\&^\\mathbf{own}\\tau}$ in order to determine the type that would result from dereferencing the pointer, if it were still valid.)\n\nNote that move commutes with substitution for (expression) variables, $\\core{\\tau}[e/x]=\\core{\\tau[e/x]}$, but it only partially commutes with substitution for type variables: $\\core{\\tau[\\tau'/\\alpha]}\\Rightarrow\\core{\\tau}[\\tau'/\\alpha]$, because substitution can make a non-copy type copy, so that for example $\\core{\\alpha[\\N/\\alpha]}=\\core{\\N}=\\N$ but $\\core{\\alpha}[\\N/\\alpha]=\\top[\\N/\\alpha]=\\top$.\n\n\\subsection{The Typing Rules}\n\nWe now give the main typing rules for the logic. This corresponds roughly to the \\texttt{typeck} phase of the compiler. Note that ghost variable markings are ignored during this phase; they will come back during the ghost propagation phase.\n\n\\judgment[Tuple pattern typing]{\\Gamma \\proves t:\\tau \\Rightarrow \\overline{R}}\n\\begin{mathparpagebreakable}\n  \\axiom[tp-ignore]{\\Gamma \\proves \\_:\\tau\\Rightarrow \\cdot}\\and\n  \\axiom[tp-var]{\\Gamma \\proves x^\\gamma:\\tau\\Rightarrow x:\\tau}\\and\n  \\infer[tp-typed]\n    {\\Gamma \\proves t:\\tau\\Rightarrow \\overline{R}}\n    {\\Gamma \\proves (t:\\tau):\\tau\\Rightarrow \\overline{R}}\\and\n  \\infer[tp-sum]\n    {\\Gamma \\proves t:\\textstyle \\tau\\Rightarrow \\bar{S}\\quad\n      \\Gamma,\\bar{S} \\proves t':\\textstyle \\tau'[t/x]\\Rightarrow \\bar{S}'}\n    {\\Gamma \\proves \\langle t,t'\\rangle:\\textstyle\\sum x:\\tau,\\tau'\\Rightarrow \\bar{S},\\bar{S}'}\\and\n  \\infer[tp-sep]\n    {\\forall i,\\ \\ \\Gamma \\proves t_i:\\tau_i\\Rightarrow(\\bar{R})_i}\n    {\\Gamma \\proves \\langle \\overline{t}\\rangle:\\textstyle\\Sep\\overline{\\tau}\\Rightarrow \\overline{\\bar{R}}}\\and\n  \\infer[tp-and]\n    {\\forall i,\\ \\tau_i\\;\\mathsf{copy}\\quad\n      \\forall i,\\ \\Gamma \\proves t_i:\\tau_i\\Rightarrow(\\bar{R})_i}\n    {\\Gamma \\proves \\langle \\overline{t}\\rangle:\\textstyle\\bigwedge\\overline{\\tau}\\Rightarrow \\overline{\\bar{R}}}\n\\end{mathparpagebreakable}\n\nThe only really relevant rules here for expressiveness are the \\textsc{tp-var} and \\textsc{tpp-var} rules; the rest are convenience rules for being able to destructure a type or proposition into components using the tuple pattern. For notational simplicity we show the \\textsc{tp-sum} rule in iterative form, but it actually matches an $n$-ary tuple against an $n$-ary struct type in one go.\n\nIn the \\textsc{tp-sum} and \\textsc{tpp-ex} rules, we use $\\overline{R}[t/x]$ to denote the result of substituting $t$ for $x$ in $R$. For this to work, $t$ must be reified as a tuple of variables rather than simply a destructuring pattern, which in particular means that `$\\_$' ignore patterns are interpreted as inserting internal variables with no user-specified name rather than being omitted from the context entirely as the \\textsc{tp-ignore} rule would suggest.\n\n\n\\judgment[Argument typing]{\\Gamma \\proves R\\;\\mathsf{arg}}\n\\begin{mathparpagebreakable}\n  \\infer[arg-type]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves x:\\tau\\;\\mathsf{arg}}\n\\end{mathparpagebreakable}\nThis one is simple so we get it out of the way first. We will avoid dealing with variable shadowing rules here; suffice it to say that variables in the context must always be distinct, and we will perform renaming from the surface syntax to ensure this property when necessary.\n\n\n\\judgment[Type validity]{\\Gamma \\proves \\tau\\;\\mathsf{type}}\n\\begin{mathparpagebreakable}\n  \\axiom[ty-unit]{\\Gamma \\proves \\mathbf{1}\\;\\mathsf{type}}\\and\n  \\axiom[ty-true]{\\Gamma \\proves \\top\\;\\mathsf{type}}\\and\n  \\axiom[ty-false]{\\Gamma \\proves \\bot\\;\\mathsf{type}}\\and\n  \\axiom[ty-bool]{\\Gamma \\proves \\mathsf{bool}\\;\\mathsf{type}}\\and\n  \\axiom[ty-nat]{\\Gamma \\proves \\N_s\\;\\mathsf{type}}\\and\n  \\axiom[ty-int]{\\Gamma \\proves \\Z_s\\;\\mathsf{type}}\\\\\n  \\infer[ty-var]\n    {\\alpha\\in\\Gamma}\n    {\\Gamma \\proves \\alpha\\;\\mathsf{type}}\\and\n  \\infer[ty-core-var]\n    {\\alpha\\in\\Gamma}\n    {\\Gamma \\proves \\core\\alpha\\;\\mathsf{type}}\\and\n  \\infer[ty-pure]\n    {\\Gamma \\proves pe:\\mathsf{bool}}\n    {\\Gamma \\proves pe\\;\\mathsf{type}}\\and\n  \\infer[ty-not]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\neg \\tau\\;\\mathsf{type}}\\and\n  \\infer[ty-and]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\and\n      \\Gamma \\proves \\tau'\\;\\mathsf{type}}\n    {\\Gamma \\proves \\tau\\land \\tau'\\;\\mathsf{type}}\\and\n  \\infer[ty-or]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\and\n      \\Gamma \\proves \\tau'\\;\\mathsf{type}}\n    {\\Gamma \\proves \\tau\\lor \\tau'\\;\\mathsf{type}}\\and\n  \\infer[ty-sep]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\and\n      \\Gamma \\proves \\tau'\\;\\mathsf{type}}\n    {\\Gamma \\proves \\tau\\ast \\tau'\\;\\mathsf{type}}\\and\n  \\infer[ty-wand]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\and\n      \\Gamma \\proves \\tau'\\;\\mathsf{type}}\n    {\\Gamma \\proves \\tau\\wand \\tau'\\;\\mathsf{type}}\\and\n  \\infer[ty-all]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\quad\n      \\Gamma,x:\\core\\tau \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\forall x:\\tau,\\;\\tau\\;\\mathsf{type}}\\and\n  \\infer[ty-sum]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\quad\n      \\Gamma,x:\\core\\tau \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\textstyle\\sum x:\\tau,\\;\\tau\\;\\mathsf{type}}\\and\n  \\infer[ty-points-to]\n    {\\Gamma \\proves \\ell:\\mathsf{\\N_{64}}\\quad\n      \\Gamma \\proves v:\\mathsf{\\core\\tau}}\n    {\\Gamma \\proves \\ell\\mapsto v\\;\\mathsf{type}}\\and\n  \\infer[ty-typing]\n    {\\Gamma \\proves x:\\core\\tau\\quad\n      \\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\boxed{x:\\tau}\\;\\mathsf{type}}\\and\n  \\infer[ty-user]\n    {\\mathsf{type}\\;S(\\overline{\\alpha}, \\overline{R})\\quad\n      \\forall i,\\ \\Gamma \\proves \\tau_i\\;\\mathsf{type}\\quad\n      \\Gamma \\proves \\langle \\overline{pe}\\rangle:\\textstyle\\sum\\overline{R}[\\overline{\\tau}/\\overline{\\alpha}]}\n    {\\Gamma \\proves S(\\overline{\\tau},\\overline{pe})\\;\\mathsf{type}}\\and\n\\end{mathparpagebreakable}\n\nType validity is also relatively straightforward. Type variables are looked up in the context, and structs can have dependent types, but the only way dependencies can appear is through \\textsc{ty-array} (which will appear later), which can have a natural number size bound, and in hypotheses via \\textsc{ty-pure}.\n\nThere is nothing non-standard in these rules, except perhaps the requirement in the \\textsc{typ-forall} and \\textsc{typ-exists} rules that the types are moved (needed because the assertion language itself should not be able to take ownership of variables used in the assertions).\n\nThe most interesting rule is \\textsc{typ-typing}, which describes the typing assertion $\\boxed{x:\\tau}$. One should think of $x:\\tau$ in the context as a separating conjunction of $x:\\core\\tau$ (which asserts, roughly, that $x$ is a reference to some data in the stack frame that is a valid bit-pattern for type $\\tau$), plus the ``fact'' $h:\\boxed{x:\\tau}$, which represents ownership of all the resources that $x$ may point to. For example, if $x:\\&^\\mathbf{own}\\tau$, then $x$ is itself just a number, but $\\boxed{x:\\&^\\mathbf{own}\\tau}$ is equal to $\\exists v:\\tau,\\ x\\mapsto v$, saying that $x$ points to some data $v$, and $v:\\tau$ may itself own some portion of the heap.\n\n\\subsection{Expression typing}\n\nThe typing rules for expressions make use of the following operators on contexts:\n\n\\begin{itemize}\n  \\item $\\Gamma_{\\core x}$ ``moves'' $x$ out of the context, by replacing $x:\\tau$ with $x:\\core\\tau$. This does not invalidate the well formedness of any type, proposition, or pure expression.\n\\end{itemize}\n\nThe rules for pure expression typing are the same as for regular expression typing, although since all the pure expression constructors do not change the context, they are all of the form $\\Gamma\\proves pe:\\tau\\makes \\Gamma$, which we abbreviate as $\\Gamma\\proves pe:\\tau$.\n\nNote that the \\textsc{tye-var-ref} rule ignores the effect of mutations. This is necessary so that new mutations do not cause the context to become ill-typed. Instead, mutations are applied in the translation from surface syntax, so that ``\\texttt{x <- 1; x + x}'' is elaborated into ``$x\\gets 1;\\;1+1$'', while ``$x\\gets 1;\\ x+x$'' in the core logic means that the $x$ being referred to is the one before the mutation. The surface syntax uses ``\\texttt{with x -> y}'' annotations on mutations to allow referencing both the old and new versions of the variable.\n\n\\judgment[Expression validity (pure expressions)]{\\Gamma \\proves pe:\\tau}\n\\begin{mathparpagebreakable}\n  \\infer[tye-var-ref]\n    {(x:\\core\\tau)\\in\\Gamma}\n    {\\Gamma \\proves x:\\tau}\\and\n  \\axiom[tye-unit]{\\Gamma \\proves ():\\mathbf{1}}\\and\n  \\axiom[tye-true]{\\Gamma \\proves \\mathsf{true}:\\mathsf{bool}}\\and\n  \\axiom[tye-false]{\\Gamma \\proves \\mathsf{false}:\\mathsf{bool}}\\and\n  \\infer[tye-nat]\n    {0\\le n\\quad s<\\infty\\to n<2^s}\n    {\\Gamma \\proves n:\\N_s}\\and\n  \\infer[tye-int]\n    {s<\\infty\\to -2^{s-1}\\le n<2^{s-1}}\n    {\\Gamma \\proves n:\\Z_s}\\and\n  \\infer[tye-tuple]\n    {\\forall i<n,\\ \\ \\Gamma_i \\proves e_i:\\tau\\makes\\Gamma_{i+1}}\n    {\\Gamma_0 \\proves \\langle\\overline{e}\\rangle:\\textstyle\\Sep\\tau\\makes\\Gamma_n}\\and\n  \\infer[tye-not]\n    {\\Gamma \\proves e:\\mathsf{bool}}\n    {\\Gamma \\proves \\neg e:\\mathsf{bool}}\\and\n  \\infer[tye-and, tye-or]\n    {\\Gamma \\proves e_1:\\mathsf{bool}\\quad\n      \\Gamma_1 \\proves e_2:\\mathsf{bool}}\n    {\\Gamma \\proves e_1\\land e_2:\\mathsf{bool} \\quad\n      \\Gamma \\proves e_1\\lor e_2:\\mathsf{bool}}\\and\n  \\infer[tye-band, tye-bor]\n    {\\tau\\in\\{\\N_s,\\Z_s\\}\\quad\n      \\Gamma \\proves e_1:\\tau\\quad\n      \\Gamma_1 \\proves e_2:\\tau}\n    {\\Gamma \\proves e_1\\mathrel{\\texttt{\\&}} e_2:\\tau \\quad\n      \\Gamma \\proves e_1\\mathrel{\\texttt{|}} e_2:\\tau}\\and\n  \\infer[tye-bnot]\n    {\\tau=\\N_s\\lor (\\tau=\\Z_{s'}\\land s=\\infty)\\quad\n      \\Gamma \\proves e:\\tau}\n    {\\Gamma \\proves \\texttt{!}_s\\;e:\\tau}\\and\n  \\infer[tye-lt, tye-le, tye-eq]\n    {\\tau,\\tau'\\in\\{\\N_s,\\Z_s\\}\\qquad\n      \\Gamma \\proves e_1:\\tau\\qquad\n      \\Gamma \\proves e_2:\\tau'}\n    {\\Gamma \\proves e_1< e_2:\\mathsf{bool}\\quad\n      \\Gamma \\proves e_1\\le e_2:\\mathsf{bool}\\quad\n      \\Gamma \\proves e_1= e_2:\\mathsf{bool}}\\and\n  \\infer[tye-if]\n    {\\Gamma \\proves c:\\mathsf{bool}\\quad\n      \\Gamma \\proves e_1:\\tau\\quad\n      \\Gamma \\proves e_2:\\tau}\n    {\\Gamma \\proves (\\mathsf{if}\\;c\\;\\mathsf{then}\\;e_1\\;\\mathsf{else}\\;e_2):\\tau}\\and\n  \\infer[tye-struct]\n    {\\Gamma \\proves e:\\tau\\quad\n      \\Gamma \\proves \\langle \\overline{e}\\rangle:\\textstyle\\sum \\bar R[e/x]}\n    {\\Gamma \\proves \\langle e,\\overline{e}\\rangle:\\textstyle\\sum x:\\tau,\\bar R}\\and\n  \\infer[tye-func-call]\n    {\\mathsf{func}\\;f(\\overline{R}):\\overline{S}\\quad\n      \\Gamma \\proves \\langle\\overline{e}\\rangle:\\textstyle\\sum\\bar R}\n    {\\Gamma \\proves f(\\overline{e}):\\textstyle\\sum\\bar S}\\and\n\\end{mathparpagebreakable}\n\nThe rules above are the only ones that apply to pure expressions. General expressions have additional typing rules for the other constructions, continued below.\n\nFor general expressions, we must worry about the following additional effects:\n\\begin{itemize}\n  \\item Variables in the context can be moved by their being referenced (in the \\textsc{tye-var-move} rule).\n  \\item Varables can be changed using no-op rules (the \\textsc{tye-cs-left} and \\textsc{tye-cs-right} rules). We will return to this in section \\ref{sec:noop}.\n\\end{itemize}\n\n\\judgmentB[Expression validity]{\\Gamma;\\delta \\proves e:\\tau\\makes\\delta'}{\\Gamma;\\delta \\proves e\\Rightarrow pe:\\tau\\makes\\delta'}\n\\begin{mathparpagebreakable}\n  \\infer[tye-cs-left]\n    {\\Gamma;\\delta\\constep\\delta_1\\quad \\Gamma;\\delta_1\\proves e\\Rightarrow pe^?:\\tau\\makes\\delta_2}\n    {\\Gamma;\\delta\\proves e\\Rightarrow pe^?:\\tau\\makes\\delta_2}\\and\n  \\infer[tye-cs-right]\n    {\\Gamma;\\delta\\proves e\\Rightarrow pe^?:\\tau\\makes\\delta_1\\quad \\Gamma;\\delta_1\\constep\\delta_2}\n    {\\Gamma;\\delta\\proves e\\Rightarrow pe^?:\\tau\\makes\\delta_2}\\and\n  \\axiom[tye-var-move]{\\Gamma;\\delta,x:=pe:\\tau \\proves x\\Rightarrow pe:\\tau\\makes\\delta,x:=pe:\\core\\tau}\\and\n  \\infer[tye-mut]\n    {\\!\\:{\\Gamma;\\delta \\proves e_1\\Rightarrow pe:\\tau\\makes\\delta_1\\quad\n      \\forall z,\\ (x\\to z)\\notin \\delta_1\\quad\n      \\Gamma\\proves \\delta_2\\atop\n      \\Gamma;\\delta_1,(x\\to y),(y:=pe:\\tau)\\proves e_2:\\tau'\\makes\\delta_2\\quad y\\notin \\delta_2}}\n    {\\Gamma;\\delta \\proves (x^\\gamma\\gets e_1\\ \\mathsf{with}\\ y\\gets x;\\ e_2):\\tau'\\makes\\delta_2}\\and\n  \\infer[tye-let-pure]\n    {\\!\\:{\\Gamma;\\delta \\proves e_1\\Rightarrow pe:\\tau\\makes\\delta_1\\quad\n      \\Gamma\\proves\\tau',\\delta_2\\atop\n      \\Gamma,x:\\core\\tau;\\delta_1,x:=pe:\\tau \\proves e_2:\\tau'\\makes\\delta_2}}\n    {\\Gamma;\\delta \\proves (\\mathsf{let}\\ x^\\gamma := e_1\\;\\mathsf{in}\\; e_2):\\tau'\\makes\\delta_2}\\and\n  \\infer[tye-unreachable]\n    {\\Gamma;\\delta \\proves e:\\bot\\makes\\delta_1\\quad \\Gamma\\proves \\delta_2}\n    {\\Gamma;\\delta \\proves \\mathsf{unreachable}\\;e:\\tau\\makes\\delta_2}\\and\n  \\infer[tye-let]\n    {\\!\\:{\\Gamma;\\delta \\proves e_1:\\tau\\makes \\delta_1\\quad\n      \\Gamma \\proves t:\\tau\\Rightarrow \\overline{R}\\quad\n      \\Gamma \\proves \\tau',\\delta_2\\atop\n      \\Gamma,\\overline{\\core{R}};\\delta_1,\\overline{R} \\proves e_2:\\tau'\\makes\\delta_2}}\n    {\\Gamma;\\delta \\proves (\\mathsf{let}\\ t := e_1\\;\\mathsf{in}\\; e_2):\\tau'\\makes\\delta_2}\\and\n  \\infer[tye-proc-call]\n    {\\mathsf{proc}\\;F(\\overline{R}):\\overline{S}\\quad\n      \\Gamma;\\delta \\proves \\langle\\overline{e}\\rangle:\\textstyle\\sum\\bar R\\makes\\delta'}\n    {\\Gamma;\\delta \\proves F(\\overline{e}):\\textstyle\\sum\\bar S\\makes\\delta'}\\and\n  \\infer[tye-return]\n    {\\mathsf{self}(\\bar R):\\bar S\\quad\n      \\Gamma;\\delta \\proves \\langle\\overline{e}\\rangle:\\textstyle\\sum\\bar S\\makes \\delta'}\n    {\\Gamma;\\delta \\proves \\mathsf{return}\\;\\overline{e}:\\bot\\makes\\delta'}\\and\n  \\infer[tye-label]\n    {\\!\\:{\\forall i,\\ \\Gamma,\\overline{k(\\delta;\\bar{R})},(\\bar{R})_i;\\delta_i,(\\bar{R})_i \\proves e_i:\\bot\\makes\\delta^2_i\\atop\n      \\Gamma,\\overline{k(\\delta;\\bar{R})};\\delta^0\\proves e':\\tau\\makes\\delta^1}}\n    {\\Gamma;\\delta^0 \\proves (\\mathsf{label}\\;\\overline{k(\\bar{R}):=e}\\;\\mathsf{in}\\;e'):\\tau\\makes\\delta^1}\\and\n  \\infer[tye-goto]\n    {\\!\\:{k(\\delta';\\bar{R})\\in\\Gamma\\atop\n      \\Gamma;\\delta \\proves \\langle\\overline{e}\\rangle:\\textstyle\\sum\\bar R\\makes\\delta'}}\n    {\\Gamma;\\delta \\proves \\mathsf{goto}\\;k(\\overline{e}):\\bot\\proves \\delta'}\\and\n  \\infer[tye-assert]\n    {\\Gamma;\\delta \\proves e\\Rightarrow pe:\\mathsf{bool} \\makes \\delta'}\n    {\\Gamma;\\delta \\proves \\mathsf{assert}\\;e:pe\\makes\\delta'}\\and\n  \\infer[tye-typeof]\n    {\\Gamma;\\delta \\proves e\\Rightarrow pe:\\tau \\makes \\delta'}\n    {\\Gamma;\\delta \\proves \\mathsf{typeof}\\;e:\\boxed{pe:\\tau}\\makes\\delta'}\\and\n  \\infer[tye-entail]\n    {\\Gamma;\\delta \\proves \\langle\\overline{e}\\rangle:\\textstyle\\Sep\\overline{A} \\makes \\delta'\\quad\n      \\proves p:\\textstyle\\Sep\\overline{A}\\wand B}\n    {\\Gamma;\\delta \\proves \\mathsf{entail}\\;\\overline{e}\\;p:B\\makes\\delta'}\\and\n\\end{mathparpagebreakable}\n\nProofs are essentially (effectful) expressions with proposition type, so the rules look much the same. Pure proofs are simply imported from the MM0 logical enironment so we do not discuss them here. The main job of Metamath C is to make sure that these pure proofs have simple types, not using the entire context, since the user will be directly interacting with them.\n\n\\subsection{No-op steps}\\label{sec:noop}\n\nIn addition to being able to step as a result of executing some expression, we also need the ability to step without anything happening physically. This is primarily needed in order to clean up the context to eliminate a variable, or to merge control flow to a common context, i.e. after the branches of an \\textsf{if} statement, and at a \\textsf{return} and \\textsf{goto}. It is also used whenever the context has to drop a variable, such as after a $\\mathsf{let}$ expression completes.\n\nThe rules given below are not deterministic, but they are used whenever we can't otherwise make progress. Using them too much may end up in a state where a variable is missing, causing later typechecking to fail, so the compiler will try to apply these only as necessary.\n\n\\judgment[No-op step]{\\Gamma;\\delta \\constep\\delta'}\n\\begin{mathparpagebreakable}\n  \\axiom[cs-refl]{\\Gamma;\\delta \\constep \\delta}\\and\n  \\infer[cs-trans]\n    {\\Gamma;\\delta_1 \\constep \\delta_2 \\quad \\Gamma;\\delta_2 \\constep \\delta_3}\n    {\\Gamma;\\delta_1 \\constep \\delta_3}\\and\n  \\infer[cs-drop]\n    {\\forall x,(x\\to y)\\notin \\delta}\n    {\\Gamma;\\delta,(y:=pe:\\tau)\\constep\\delta}\\and\n  \\axiom[cs-rename\\footnotemark]\n    {\\Gamma;\\delta,(x\\to y),(y:=pe:\\tau)\\constep\\delta,(x:=pe:\\tau)}\\and\n  \\footnotetext{The \\textsc{cs-rename} rule should only be used if it is the only way to make progress, i.e. when $y$ is going out of scope. This is needed because it changes the interpretation of expressions containing $x$.}\n  \\infer[cs-forget]\n    {\\Gamma\\proves\\Gamma[\\overline{x\\to pe}]}\n    {\\Gamma;\\delta,\\overline{x:=pe:\\tau}\\constep\\delta,\\overline{x:\\tau}}\\and\n\\end{mathparpagebreakable}\n\nThis is a nondeterministic judgment, with the ``goal'' being to eliminate a particular variable and/or join with separate control flow which has assigned different values to the variables.\n\\begin{itemize}\n\\item The simplest way to drop a variable is with the \\textsc{cs-drop} rule, which works as long as this is a variable that was not obtained from a mutation.\n\\item For variables that are obtained by mutation, we have a $x\\to y$ in the context, and we can drop its value while storing the result back in the original variable using the \\textsc{cs-rename} rule.\n\\item In order to join control flow, we also need to ``forget'' the value associated with a variable. For example, if one branch of an if statement sets $x\\gets 1$ and the other sets $x\\gets 2$, we are allowed to use these settings inside the blocks of the if statement but at the end they must agree about the setting of the variable as well as its properties. For this we use the \\textsc{cs-forget} rule, which erases the information that $x:=pe$ for several variables at once. This existentially quantifies over the variables $\\overline{x}$ and reintroduces them so that we no longer have access to the value. For this to be sound, we have a side condition that says that the context remains true if we replace $\\overline{x}$ with $\\overline{pe}$, because the actual assignments to the variables in $\\Gamma$ have changed even though we are keeping the same type.\n\\end{itemize}\n\nTo see how this plays out, consider the code\n$$x:=0,h:x\\ge 0\\proves\\mathsf{if}\\ b\\ \\{\\ x\\gets 1\\ \\},$$\nwhich desugars to ``$\\mathsf{if}\\ b\\ \\mathsf{then}\\ x^\\top\\gets 1;\\ ()\\ \\mathsf{else}\\ ()$''. After the mutation, we have $x\\to x',x':=1$ so we can apply \\textsc{cs-rename} to get $x:=1$. But the else branch has $x:=0$ so we can't merge just yet. We can apply \\textsc{cs-forget} to forget $x$, because $x:\\N,h:x\\ge 0\\proves 1:\\N,1\\ge 0$, provided the compiler knows how to synthesize these proofs. (The proof of $1:\\N$ is already supplied by $x\\gets 1:\\N$, but $1\\ge 0$ is not immediately available.) If the compiler cannot find this proof, it can be supplied by:\n$$x:=0,h:x\\ge 0\\proves\\mathsf{if}\\ b\\ \\{\\ x\\gets 1;\\ h\\gets (p:1\\ge 0)\\ \\},$$\nwhere $p$ is a proof of $1\\ge 0$. In this case, we are using \\textsc{cs-rename} on $x$ and $h$ simultaneously, so the side goal is the same but we get the $1\\ge 0$ goal for free from the typing condition on $h:=(p:1\\ge 0)$.\n\n\\subsection{Top level typing}\n\nThe full program consists of a list of top level items, which are typechecked incrementally:\n\n\\judgment[AST typing]{\\Gamma\\proves \\overline{it}\\makes \\Gamma'}\n\\begin{mathparpagebreakable}\n  \\axiom[ok-zero]{\\Gamma\\proves \\cdot\\makes \\Gamma}\\and\n  \\infer[ok-append]\n    {\\Gamma\\proves \\overline{it}\\makes \\Gamma'\\quad\n      \\Gamma'\\proves it\\makes \\Gamma''}\n    {\\Gamma\\proves \\overline{it},it'\\makes \\Gamma''}\\and\n\\end{mathparpagebreakable}\nIndividual items are typed as follows:\n% it \\in \\mathrm{Item} ::={}&\\mathsf{type}\\;S(\\overline{\\alpha}, \\overline{R}):=\\tau&&\\mbox{type declaration}\\\\\n% \\mid{}&\\mathsf{const}\\;t:=e&&\\mbox{constant declaration}\\\\\n% \\mid{}&\\mathsf{global}\\;t:=e&&\\mbox{global variable declaration}\\\\\n% \\mid{}&\\mathsf{func}\\;f(\\overline{R}):\\overline{R}:=e&&\\mbox{function declaration}\\\\\n% \\mid{}&\\mathsf{proc}\\;f(\\overline{R}):\\overline{R}:=e&&\\mbox{procedure declaration}\\\\\n\n\\judgment[Item typing]{\\Gamma \\proves it\\makes \\Gamma'}\n\\begin{mathparpagebreakable}\n  \\infer[ok-type]\n    {\\Gamma,\\overline{\\alpha} \\proves \\textstyle\\sum\\overline{R}\\;\\mathsf{type}\\quad\n      \\Gamma,\\overline{\\alpha},\\overline{R}\\proves\\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\mathsf{type}\\;S(\\overline{\\alpha}, \\overline{R}):=\\tau\\makes \\Gamma,\\ \\mathsf{type}\\;S(\\overline{\\alpha}, \\overline{R}):=\\tau}\\and\n  \\infer[ok-const]\n    {\\Gamma\\proves pe:\\tau\\quad\n     \\Gamma\\proves t:\\tau\\Rightarrow \\bar R}\n    {\\Gamma \\proves \\mathsf{const}\\;t:=pe\\makes \\Gamma,\\bar R}\\and\n  \\infer[ok-global]\n    {\\Gamma\\proves e:\\tau\\makes \\Gamma'\\quad\n     \\Gamma'\\proves t:\\tau\\Rightarrow \\bar R}\n    {\\Gamma \\proves \\mathsf{global}\\;t:=e\\makes \\Gamma',\\bar R}\\and\n  \\infer[ok-func, ok-proc]\n    {\\mathbf{kw}\\in\\{\\mathsf{func},\\mathsf{proc}\\}\\quad \\Gamma\\proves \\textstyle\\sum\\overline{R}\\;\\mathsf{type}\\quad\n      \\Gamma,\\overline{R} \\proves\\textstyle\\sum\\overline{S}\\;\\mathsf{type}\\quad\n      \\Gamma,(\\mathsf{self}(\\overline{R}):\\overline{S}),\\overline{R};\\ \\overline{R} \\proves e:\\bot\\makes\\delta}\n    {\\Gamma \\proves \\mathbf{kw}\\;f(\\overline{R}):\\overline{S}:=e\\makes \\Gamma',\\ \\mathbf{kw}\\;f(\\overline{R}):\\overline{S}}\\and\n\\end{mathparpagebreakable}\n\n\\subsection{Uninitialized data}\n\nThe approach for handling mutation also cleanly supports uninitialized data. We extend the language as follows:\n\n\\begin{mathparpagebreakable}\n  \\mathrm{Type}::=\\dots\\mid \\tau^?\\and\n  \\mathrm{Expr}::=\\dots\\mid \\mathsf{uninit}\\and\n  \\core{\\tau^?}=\\core\\tau^?\\and\n  \\boxed{x:\\tau^?}=\\top\\\\\n  \\infer[ty-maybe]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\tau^?\\;\\mathsf{type}}\\and\n  \\infer[tye-uninit]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma;\\delta \\proves \\mathsf{uninit}:\\tau^?\\makes\\delta}\\and\n\\end{mathparpagebreakable}\n\nThat's it. Note that $\\tau\\le \\tau^?$ because the typing predicate of $\\tau^?$ is $\\top$, so we can always satisfy the side condition of \\textsc{cs-forget} when performing a strong update of $x:\\tau^?$ to $\\tau$ when we initialize it.\n\\subsection{Pointers}\\label{sec:pointers}\n\nThus far the rules have only talked about local variables and mutation of local variables, that we think of as being on the stack frame of the function. To understand the representation of pointers in the type system, it will help to understand the way contexts are modeled as separating propositions. The context is a large separating conjunction of $\\boxed{x:\\tau}$ assertions for every $(x:\\tau)\\in\\Gamma$ and $A$ for every $h:A$, plus additional ``layout'' information about the relation of non-ghost variables to the stack frame that will be calculated in the layout pass (see section \\ref{sec:layout}).\n\n\\subsubsection{Singleton pointers}\n\nThe simplest pointer type is $\\&^\\mathbf{sn}\\eta$. $x:\\&^\\mathbf{sn}\\eta$ simply means that $x$ is a pointer that points to $\\eta$, which is a ``place'', a writable location. $\\boxed{x:\\&^\\mathbf{sn}\\eta}=\\eta\\mathrel{@}x$, where $\\eta\\mathrel{@}x$ means that $\\eta$ is stored in memory at location $x$; see section \\ref{sec:semantics}. (This is not the same as $x\\mapsto\\eta$, because $\\eta$ is a place, i.e. a direct reference to a variable in the context, not a value.) This predicate is duplicable, so $\\&^\\mathbf{sn}\\eta$ is \\textsf{copy} (and coercible to $\\N_{64}$). We add the following:\n\n\\begin{mathparpagebreakable}\n  \\mathrm{Type}::=\\dots\\mid \\&^\\mathbf{sn}\\eta\\and\n  \\mathrm{Expr}::=\\dots\\mid {}^\\ast e\\mid \\& e\\and\n  \\&^\\mathbf{sn}\\eta\\;\\mathsf{copy}\\and\n  \\boxed{x:\\&^\\mathbf{sn}\\eta}=\\eta\\mathrel{@}x\\\\\n  \\infer[ty-snp]\n    {\\Gamma \\proves \\eta\\;\\mathsf{place}}\n    {\\Gamma \\proves \\&^\\mathbf{sn}\\eta\\;\\mathsf{type}}\\and\n  \\infer[tye-deref]\n    {\\Gamma;\\delta \\proves e:\\&^\\mathbf{sn}\\eta\\makes\\delta'}\n    {\\Gamma;\\delta \\proves {}^* e\\Rightarrow \\eta\\makes\\delta'\\;\\mathsf{place}}\\and\n  \\infer[tye-shr]\n    {\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta'\\;\\mathsf{place}}\n    {\\Gamma;\\delta \\proves \\&e:\\&^\\mathbf{sn}\\eta\\makes\\delta'}\\and\n\\end{mathparpagebreakable}\nTo use these generalized lvalues, we need operations to read and write them:\n\n\\begin{mathparpagebreakable}\n  \\infer[tye-read]\n    {\\!\\:{\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta_1\\;\\mathsf{place}\\atop\n      \\Gamma;\\delta_1\\proves \\eta\\Rightarrow pe:\\tau\\makes\\delta_2}}\n    {\\Gamma;\\delta \\proves e\\Rightarrow pe:\\tau\\makes\\delta_2}\\and\n  \\infer[tye-write]\n    {\\!\\:{\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta_1\\;\\mathsf{place}\\atop\n      \\Gamma;\\delta_1 \\proves (\\eta\\gets pe;\\ e_2):\\tau\\makes\\delta_2}}\n    {\\Gamma \\proves (e\\gets pe;\\ e_2):\\tau\\makes\\delta_2}\\and\n\\end{mathparpagebreakable}\n\nWe needed two new judgments above, $\\Gamma \\proves \\eta\\;\\mathsf{place}$, which asserts that $\\eta$ is a place in the context, and $\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta'\\;\\mathsf{place}$ which asserts that $e$ evaluates as an lvalue to place $\\eta$ (which may require transforming the code to add a temporary variable). The simplest example of a place is a variable $x\\in\\Gamma$, but one can also take a subpart of a struct or a slice of an array. However, note that ${}^*e$ is a place expression but not a place value; it evaluates according to \\textsc{tye-deref}.\n\nNote that writing to a place as in \\textsc{tye-write} changes the type $\\&^\\mathbf{sn}\\eta$ to $\\&^\\mathbf{sn}\\eta'$ (it rewrites all occurrences of one with the other in the context), if $\\eta'$ is the renamed place after the mutation. This is because the pointer has not changed, but the data being pointed to has been updated, so we should now retrieve the new value, not the (ghost) old value.\n\n\\subsubsection{Owned pointers}\n\nAn owned pointer is fairly simple. We define $\\boxed{x:\\&^\\mathbf{own}\\tau}$ as $\\exists v:\\tau,\\ x\\mapsto v$, but we can't directly dereference an owned pointer as we must first have access to the variable $v$, so we require that it first be destructured to be used.\n\n\\begin{mathparpagebreakable}\n  \\mathrm{Type}::=\\dots\\mid \\&^\\mathbf{own}\\tau\\and\n  \\core{\\&^\\mathbf{own}\\tau}=\\N_{64}\\and\n  \\boxed{x:\\&^\\mathbf{own}\\tau}=\\exists v:\\tau,x\\mapsto v\\\\\n  \\infer[ty-own]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\&^\\mathbf{own}\\tau\\;\\mathsf{type}}\\and\n  \\infer[tp-own]\n    {\\Gamma \\proves t:\\textstyle \\tau\\Rightarrow \\bar{S}\\quad\n      \\Gamma,\\bar{S} \\proves t':\\textstyle \\&^\\mathbf{sn}t\\Rightarrow \\bar{S}'}\n    {\\Gamma \\proves \\langle t,t'\\rangle:\\&^\\mathbf{own}\\tau\\Rightarrow \\bar{S},\\bar{S}'}\\and\n\\end{mathparpagebreakable}\n\nBy using destructuring, it is possible to obtain a pointer such as $t:\\&^\\mathbf{sn}(a,b)$; this type asserts that $a$ and $b$ are contiguous in memory such that a single pointer can access them both. This type can itself be destructured as if it were $\\&^\\mathbf{sn}a\\ast \\&^\\mathbf{sn}b$.\n\n\\subsubsection{Mutable pointers}\nBefore we can explain mutable pointers, we need the concept of a mutable parameter. We have already seen that the $\\gets$ operator can mutate variables inside the value context $\\delta$, but currently $\\mathsf{return}$ will drop all mutated values and return only the return values in the function signature. In order to allow variables to be mutated through the function, we add the ability to mark a variable in the returns $\\overline{S}$ as $\\mathsf{out}^x\\ y:\\tau$, if $x$ is a function parameter (which is itself marked as $\\mathsf{mut}\\ x:\\tau$). This has the meaning that the variable $x$ will be mutated so that $\\delta\\proves x\\to^* y$ when the function reaches the return.\n\nThe rule \\textsc{tye-return} is unchanged, but we have a new rule for fulfilling an $\\mathsf{out}^x\\;y$ argument:\n\\begin{mathparpagebreakable}\n  \\infer[tye-struct-out]\n    {\\delta\\proves x\\to^*y \\quad\n      \\Gamma;\\delta \\proves y:\\tau\\makes \\delta_1\\quad\n      \\Gamma;\\delta_1 \\proves \\langle \\overline{e}\\rangle:\\textstyle\\sum \\bar R[pe/y]}\n    {\\Gamma \\proves \\langle \\overline{e}\\rangle:\\textstyle\\sum (\\mathsf{out}^x\\,y:\\tau),\\bar R}\\and\n\\end{mathparpagebreakable}\nHere $\\delta\\proves x\\to^*y$ means that $x\\to\\dots\\to y\\not\\to$ according to the rename map in $\\delta$.\n\nConversely, when calling a function, the $\\mathsf{mut}$ parameters get captured in the calling context, and changed to their $\\mathsf{out}$ variants. Describing this is technically complicated so we will use a prose description. We define only the construct $\\mathsf{let}\\ \\langle \\overline{y},t\\rangle:=F(\\overline{e})\\;\\mathsf{in}\\; e_2$ where $t$ is a tuple pattern and $\\overline{y}$ has the same length as the number of out parameters of $F$; that is, $\\mathsf{proc}\\ F(\\overline{R}):\\overline{\\mathsf{out}^x\\;y:\\tau},\\overline{S}$.\n\nThe arguments of $F$ must be $e:\\tau$ if $R=(x:\\tau)$, and must be $\\eta:\\tau\\;\\mathsf{place}$ if $R=(\\mathsf{mut}\\ x:\\tau)$. If $\\eta$ is provided for argument $x$, and $\\mathsf{out}^x\\ y:\\tau'$ is among the out arguments of the function, and $y$ is the corresponding element of the tuple in the $\\mathsf{let}\\ \\langle \\overline{y},t\\rangle$ pattern match, then we perform an assignment $\\eta \\gets y$ on return from the function. All these $\\eta$ places are disjoint because they were passed simultaneously to $F$, so there is no ambiguity about the order of writes. Finally, the result of the $F(\\overline{e})$ invocation is pattern matched against the tuple pattern $t$ and $e_2$ is executed.\n\nThe type $\\&^\\mathbf{mut}\\tau$ is not a true type, but is allowed in function signatures to indicate a $\\&^\\mathbf{sn}\\eta$ value where $\\eta$ is external to the function. The changes to $\\eta$ are a ``side effect'' and so we use the $\\mathsf{out}^x\\;y$ functionality from the previous section to support it.\n\nIn brief, if $x:\\&^\\mathbf{mut}\\tau$ appears in the function arguments, we replace it by $\\ghost v:\\tau,x:\\&^\\mathbf{sn}v$ in the function arguments and add $\\mathsf{out}_v\\;\\ghost{v'}:\\tau$ at the beginning of the function returns. $\\&^\\mathbf{mut}\\tau$ is not allowed to appear any other place than the top level of a function argument.\n\n\\subsubsection{Shared pointers}\n\nShared pointers are the most complex, because they cannot be modeled by separating conjunctions, at least without techniques such as fractional ownership. This is not a problem until we get to the underlying separation logic. Here we only need to mark work that will be perfomed later on.\n\nWe introduce a new type, a heap reservation type called $\\mathsf{ref}^a\\;\\tau$, the elements of which are called heap variables. The expression $x:\\mathsf{ref}^a\\;\\tau$ means that $x:\\tau$, but $x$ is not owned by the current context. Heap variables can overlap each other, but not other regular variables in the context.\n\nHeap variables resemble shared references from Rust, and in particular they are annotated with a ``lifetime''. The difference is that the pointer-ness is separated out; a heap variable directly has the type of the pointee, and the pointer is just a $\\&^\\mathbf{sn}\\eta$ where $\\eta$ is a heap variable.\n\nA lifetime $a$ is modeled roughly as a (precise, aka subsingleton) separating proposition $P$, with each $x:=pe:\\mathsf{ref}^a\\;\\tau$ being modeled as a place $\\eta$ for which $P\\Rightarrow (\\eta:=pe:\\tau)$. That is, we can weaken $P$ to obtain the fact that $\\eta:=pe:\\tau$. (The relation $P\\Rightarrow Q$, which is a regular (not separating) proposition, is defined as $\\proves P\\to (Q*\\top)$.) Because $P$ is a precise proposition, it satisfies $(P\\Rightarrow \\exists x, Q)\\to (\\exists x,(P\\Rightarrow Q))$, which means we can pattern match on heap variables like regular variables, for example to obtain $\\&\\tau$ from $\\&\\&^\\mathbf{own}\\tau$. But this is only relevant for the semantic model; in the type checker we simply need some rules for how to manipulate these variables.\n\nSyntactically, a lifetime can be either $\\mathsf{extern}$, referring to data outside the current context, or $x$, some variable in the context. These denote the scope of the borrow; a variable which is borrowed cannot be mutated. (Possible extensions include lifetimes with scope $\\{x,y,z\\}$ for creating data that spans multiple variables, and lifetimes with scope $x.\\mathsf{field}$ in order to borrow only parts of a variable without locking the whole variable.) The proposition $P$ from the previous paragraph is the implicit frame proposition in the $\\mathsf{extern}$ case, and $x:=pe:\\tau$ from the value context at the time of the borrow in the case of $x$. (In the case of multiple variables, it is the separating conjunction of these $x:=pe:\\tau$ conditions and in the case of a subobject we destructure this proposition and pull out the $\\eta:=pe:\\tau$ component.)\n\n\\begin{mathparpagebreakable}\n  a\\in\\mathrm{Lft}::=\\mathsf{extern}\\mid x\\and\n  \\mathrm{Type}::=\\dots\\mid \\mathsf{ref}^a\\;\\tau\\and\n  \\infer[tp-sum-ref]\n    {\\Gamma \\proves t:\\textstyle \\mathsf{ref}^a\\;\\tau\\Rightarrow \\bar{S}\\quad\n      \\Gamma,\\bar{S} \\proves \\langle \\overline{t'}\\rangle:\\textstyle \\mathsf{ref}^a(\\tau'[t/x])\\Rightarrow \\bar{S}'}\n    {\\Gamma \\proves \\langle t,\\overline{t'}\\rangle:\\mathsf{ref}^a(\\textstyle\\sum x:\\tau,\\overline{R})\\Rightarrow \\bar{S},\\bar{S}'}\\and\n  \\infer[ty-ref]\n    {\\mathrm{Var}(a)\\subseteq \\Gamma\\quad\n      \\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\mathsf{ref}^a\\; \\tau\\;\\mathsf{type}}\\and\n  \\infer[tye-ref]\n    {\\Gamma;\\delta \\proves e\\Rightarrow(\\eta:=pe:\\tau)\\makes\\delta'\\;\\mathsf{read}^a}\n    {\\Gamma;\\delta \\proves e: \\mathsf{ref}^a\\;\\tau\\makes\\delta'}\\and\n\\end{mathparpagebreakable}\n\nHere the $\\Gamma;\\delta \\proves e\\Rightarrow(\\eta:=pe:\\tau)\\makes\\delta'\\;\\mathsf{read}^a$ judgment is a conjunction of $\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta_1\\;\\mathsf{place}$ followed by $\\Gamma\\proves\\delta_1 \\Rightarrow \\delta'$, such that $\\Gamma;\\delta' \\proves \\eta:=pe:\\tau\\;\\mathsf{read}^a$. That is, first we evaluate the place expression, then we use $\\Gamma\\proves\\delta_1 \\Rightarrow \\delta'$ to ensure that $\\eta$ is locked and readable at type $\\tau$, and the final judgment asserts that in the result state we can in fact read $\\eta:\\tau$ from origin $a$.\n\n\\begin{mathparpagebreakable}\n  \\delta\\in\\mathrm{VCtx}::=\\delta,(\\mathsf{ref}^a\\;x:=pe:\\tau)\\\\\n  \\axiom[cs-lock]\n    {\\Gamma\\proves\\delta,(x:=pe:\\tau) \\constep \\delta,(\\mathsf{ref}^x\\;x:=pe:\\tau)}\\and\n  \\infer[cs-unlock]\n    {\\forall y, (\\mathsf{ref}^x\\;y:=-)\\notin \\delta}\n    {\\Gamma\\proves\\delta,(\\mathsf{ref}^x\\;x:=pe:\\tau) \\constep \\delta,(x:=pe:\\tau)}\\and\n  \\infer[tyr-var]\n    {(\\mathsf{ref}^a\\;x:=pe:\\tau)\\in\\delta}\n    {\\Gamma;\\delta \\proves x:=pe:\\tau\\;\\mathsf{read}^a}\\and\n  \\infer[tye-read-ref]\n    {\\!\\:{\\Gamma;\\delta \\proves e\\Rightarrow\\eta\\makes\\delta'\\;\\mathsf{place}\\atop\n      \\Gamma;\\delta' \\proves \\eta:=pe:\\tau\\;\\mathsf{read}^a}}\n    {\\Gamma;\\delta \\proves e\\Rightarrow pe:\\core\\tau\\makes\\delta'}\\and\n\\end{mathparpagebreakable}\n\nNote that we cannot move out a value from a ref variable, which is reflected in the use of $\\core\\tau$ in \\textsc{tye-read-ref}. We also cannot mutate a ref, meaning that while a variable is locked (meaning that it is represented in the value context as a $\\mathsf{ref}^x\\;x$), mutation is not possible; however it is possible to mutate a variable that is currently locked by first unlocking it using the \\textsc{cs-unlock} rule, which requires first deleting all the heap variables that reference $x$ using the \\textsc{cs-drop} rule.\n\nIn fact, we can't even really read a ref; the value read is only available as a ghost value, unless it is accessed indirectly via a shared reference. Using heap variables, we can desugar shared references similarly to owned pointers:\n\n\\begin{mathparpagebreakable}\n  \\mathrm{Type}::=\\dots\\mid \\&^a\\tau\\and\n  \\core{\\&^a\\tau}=\\N_{64}\\and\n  \\boxed{x:\\&^a\\tau}=\\exists v:\\mathsf{ref}^a\\;\\tau,x\\mapsto v\\\\\n  \\infer[ty-shr]\n    {\\mathrm{Var}(a)\\subseteq \\Gamma\\quad\n      \\Gamma \\proves \\tau\\;\\mathsf{type}}\n    {\\Gamma \\proves \\&^a\\tau\\;\\mathsf{type}}\\and\n  \\infer[tp-shr]\n    {\\Gamma \\proves \\mathsf{ref}^a\\; t:\\textstyle \\tau\\Rightarrow \\bar{S}\\quad\n      \\Gamma,\\bar{S} \\proves t':\\textstyle \\&^\\mathbf{sn}t\\Rightarrow \\bar{S}'}\n    {\\Gamma \\proves \\langle t,t'\\rangle:\\&^a\\tau\\Rightarrow \\bar{S},\\bar{S}'}\\and\n\\end{mathparpagebreakable}\n\n\\subsection{Arrays}\\label{sec:arrays}\n\nArrays here are fixed length, depending on another variable in the context.\n\n\\begin{mathparpagebreakable}\n  \\mathrm{Type}::=\\dots\\mid \\mathsf{array}\\;\\tau\\;pe\\and\n  \\core{\\mathsf{array}\\;\\tau\\;n}=\\mathsf{array}\\;\\core\\tau\\;n\\and\n  \\boxed{x:\\mathsf{array}\\;\\tau\\;n}=(x:n\\to\\core\\tau)\\ast\\textstyle\\Sep_{i<n}\\boxed{x[i]:\\tau}\\\\\n  \\infer[ty-array]\n    {\\Gamma \\proves \\tau\\;\\mathsf{type}\\quad\n      \\Gamma \\proves n:\\N_s}\n    {\\Gamma \\proves \\mathsf{array}\\;\\tau\\;n\\;\\mathsf{type}}\\and\n\\end{mathparpagebreakable}\n\nTODO\n\n\\section{Ghost propagation}\n\nGhost annotations are optional in most cases, because of the ghost propagation pass that automatically makes as many things ghost as possible. The invariant that we uphold is that a ghost variable \\emph{must not} have an M-place associated with it, while a regular variable \\emph{may} have an M-place. However, it is consistent with this that there are no M-places at all, so we have some inductive conditions on what variables must have M-places, which are roughly analogous to dead-code elimination.\n\nGhost propagation (dead-store elimination) has to be done in tandem with reachability analysis (dead-code elimination), because \\textsf{if} can convert data dependencies into control dependencies, meaning that parts of the code may in fact have the program counter itself being ghost. When this happens, we can't execute anything with side effects or anything whose value is computationally relevant, because the physical machine never reaches these lines.\n\nTo express all this, we will use a judgment $\\Gamma^\\alpha;\\delta^\\rho\\proves e:\\tau^\\gamma\\makes {\\delta'}^{\\rho'}$ that augments the typing condition with four ghost annotations; in addition we will be modifying the ghost annotations inside $\\delta$ and $\\delta_1$ to make them more strict (i.e. possibly turning $x^\\top$ to $x^\\bot$).\n\n\\begin{itemize}\n  \\item $\\alpha$, the variable on $\\Gamma$, is either $\\top$ or $\\bot$. If $\\alpha=\\bot$ then the program counter is ghost, which is to say, we are unable to perform any operation that involves emitting code. This happens when we branch on a ghost variable.\n  \\item $\\rho$, the variables associated to the before and after value contexts, are also $\\bot$ or $\\top$ and indicate whether the beginning or end of $e$ is reachable.\n  \\item Because type inference is complete, we can treat the type $\\tau$ of $e$ as an input to the judgment. Here $\\tau^{\\gamma}$ is a type extended with ghost annotations in all subexpressions. The typing rules for such extended types assert that a type is ghost only if all subexpressions are ghost.\n\\end{itemize}\n\n\\subsection{Ghost annotated types and tuple patterns}\n\nThe types that show up in the expression judgment are annotated with $\\gamma$ ghost annotations at all levels, subject to a local coherence condition that states that a ghost type must only have ghost parts. This allows us to only compute some parts of a type as long as we have all the parts we actually need for downstream processing. While the language itself admits ghost annotations on variables in a tuple pattern and variable binders in a struct, these are only upper bounds on the computational relevance, because we are interested in eliminating parts of a type for optimization purposes even if they were not claimed to be ghost.\n\n\\judgment[Ghost-annotated type validity]{\\tau^\\gamma\\;\\mathsf{ctype}}\n\\begin{mathparpagebreakable}\n  \\axiom[cty-unit, cty-bool]{\\mathbf{1}^\\gamma,\\ \\mathsf{bool}^\\gamma\\;\\mathsf{ctype}}\\and\n  \\axiom[cty-nat, cty-int]\n    {\\N_s^\\gamma,\\ \\Z_s^\\gamma\\;\\mathsf{ctype}}\\and\n  \\infer[cty-var, cty-core-var]\n    {\\alpha\\in\\Gamma}\n    {\\alpha^\\gamma,\\ \\core\\alpha^\\gamma\\;\\mathsf{ctype}}\\and\n  \\infer[cty-inter, cty-union, cty-list]\n    {\\forall i,\\ \\tau_i^{\\gamma_i}\\;\\mathsf{ctype}\\quad\n      \\forall i,\\ \\gamma_i\\le \\gamma'}\n    {(\\textstyle\\bigcap\\overline{\\tau^\\gamma})^{\\gamma'},\n      \\ (\\textstyle\\bigcup\\overline{\\tau^\\gamma})^{\\gamma'},\n      \\ (\\textstyle\\Sep\\overline{\\tau^\\gamma})^{\\gamma'}\\;\\mathsf{ctype}}\\and\n  \\axiom[cty-prop]{A^\\gamma\\;\\mathsf{ctype}}\\and\n  \\infer[cty-struct]\n    {\\gamma_2\\le\\gamma_1,\\gamma\\quad\n      \\tau^{\\gamma_2}\\;\\mathsf{ctype}\\quad\n      {\\tau'}^{\\gamma}\\;\\mathsf{ctype}}\n    {(\\textstyle\\sum x^{\\gamma_1}:{\\tau^{\\gamma_2}},\\tau')^{\\gamma}\\;\\mathsf{ctype}}\\and\n\\end{mathparpagebreakable}\n\\judgment[Ghost-annotated tuple pattern validity]{t:\\tau^\\gamma\\Rightarrow\\overline{R^{\\gamma'}}}\n\\begin{mathparpagebreakable}\n  \\axiom[ctp-ignore]{\\_:\\tau^\\gamma\\Rightarrow\\cdot}\\and\n  \\infer[ctp-var]\n    {\\gamma'\\le \\gamma}\n    {x^\\gamma:\\tau^{\\gamma'}\\Rightarrow x^{\\gamma'}:\\tau}\\and\n  \\infer[ctp-typed]\n    {t:\\tau^\\gamma\\Rightarrow\\overline{R^{\\gamma'}}}\n    {(t:\\tau):\\tau^\\gamma\\Rightarrow\\overline{R^{\\gamma'}}}\\and\n  \\infer[ctp-sum]\n    {\\gamma_2\\le\\gamma_1,\\gamma_3\\quad\n      t:\\textstyle \\tau^{\\gamma_2}\\Rightarrow \\overline{R^\\gamma}\\quad\n      \\langle \\overline{t'}\\rangle:\\textstyle (\\tau'[t/x])^{\\gamma_3}\\Rightarrow \\overline{R^\\gamma}'}\n    {\\langle t,\\overline{t'}\\rangle:(\\textstyle\\sum x^{\\gamma_1}:{\\tau^{\\gamma_2}},\\tau')^{\\gamma_3}\\Rightarrow \\overline{R^\\gamma},\\overline{R^\\gamma}'}\\and\n\\end{mathparpagebreakable}\n\nThe intuitive meaning of $\\tau^\\gamma$ is that $\\tau^\\top$ is a value that will actually have storage space allocated for it, while $\\tau^\\bot$ is a value that will not need to be calculated (even if it is stored in a non-ghost variable). These rules assume that the full ghost annotation assignment is known and just give constraints on that assignment, but in practice we will start from an assignment that makes everything ghost, and incrementally shift this upward in a coordinated fashion. At the end we may end up with an impossible constraint such as a computationally relevant unbounded integer value, which will cause an error during legalization.\n\n\\subsection{The expression typing judgment}\n\nFor the expression judgment $\\Gamma^\\alpha;\\delta^{\\rho} \\proves e:\\tau^\\gamma\\makes{\\delta'}^{\\rho'}$, we have $\\Gamma,\\delta,e,\\tau$ as inputs and $\\delta'$ as output, with the annotations $\\alpha,\\rho,\\rho',\\gamma$ being solved for by a fixed point algorithm. It is safe to assume that $\\gamma\\le \\rho'\\le \\rho$ and $\\gamma\\le \\alpha$ in this judgment (that is, the end of a statement is only reachable if the beginning is, and the return value is only needed if the end of the statement is reached), unless $\\tau$ is a ghost type like $\\mathbf{1}$ or $A$ in which case $\\gamma\\le \\rho',\\alpha$ need not hold.\n\nWe also add an annotation $\\sigma\\in\\{\\bot,\\top\\}$ on functions (including $\\mathsf{self}$), which can be seen in rule \\textsc{tyc-proc-call}, for example; this is the side effect analysis, see section \\ref{sec:sideeffect}.\n\n\\judgment[Ghost-annotated expression validity]{\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\tau^\\gamma\\makes\\delta_2^{\\rho_2}}\n\\begin{mathparpagebreakable}\n  \\infer[tyc-cs-left]\n    {\\Gamma;\\delta\\constep\\delta_1\\quad \\Gamma^\\alpha;\\delta_1^\\rho\\proves e:\\tau^\\gamma\\makes\\delta_2^{\\rho'}}\n    {\\Gamma^\\alpha;\\delta^\\rho\\proves e:\\tau^\\gamma\\makes\\delta_2^{\\rho'}}\\and\n  \\infer[tyc-cs-right]\n    {\\Gamma^\\alpha;\\delta^\\rho\\proves e:\\tau^\\gamma\\makes\\delta_1^{\\rho'}\\quad \\Gamma;\\delta_1\\constep\\delta_2}\n    {\\Gamma^\\alpha;\\delta^\\rho\\proves e:\\tau^\\gamma\\makes\\delta_2^{\\rho'}}\\and\n  \\infer[tyc-var-ref]\n    {(x^{\\gamma'}:=pe:\\tau)\\in\\delta\\quad |\\tau| = \\tau'\\quad \\gamma\\le\\alpha,\\rho,\\gamma'}\n    {\\Gamma^\\alpha;\\delta^{\\rho} \\proves x:{\\tau'}^{\\gamma}\\makes \\delta^{\\rho}}\\and\n  \\axiom[tyc-unit]\n    {\\Gamma^\\alpha;\\delta^{\\rho} \\proves ():\\mathbf{1}^{\\gamma}\\makes \\delta^{\\rho}}\\and\n  \\infer[tyc-true, tyc-false]\n    {\\gamma\\le \\alpha,\\rho}\n    {\\Gamma^\\alpha;\\delta^{\\rho} \\proves \\mathsf{true},\\ \\mathsf{false}:\\mathsf{bool}^{\\gamma}\\makes \\delta^{\\rho}}\\and\n  \\infer[tyc-nat, tyc-int]\n    {\\gamma\\le \\alpha,\\rho}\n    {\\Gamma^\\alpha;\\delta^{\\rho} \\proves n:\\N_s^{\\gamma},\\ \\Z_s^{\\gamma}\\makes \\delta^{\\rho}}\\and\n  \\infer[tyc-not]\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\mathsf{bool}^\\gamma\\makes \\delta_2^{\\rho_2}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\neg e:\\mathsf{bool}^\\gamma\\makes \\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-and, tyc-or, \\dots]\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e_1:\\mathsf{bool}^\\gamma\\makes \\delta_2^{\\rho_2}\\quad\n      \\Gamma^\\alpha;\\delta_2^{\\rho_2} \\proves e_2:\\mathsf{bool}^\\gamma\\makes \\delta_3^{\\rho_3}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e_1\\land e_2,\\ e_1\\lor e_2:\\mathsf{bool}^\\gamma\\makes \\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-if]\n    {\\!\\:{\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves c:\\mathsf{bool}^{\\gamma'}\\makes \\delta_2^{\\rho_2} \\atop\n      \\Gamma^{\\alpha\\wedge \\gamma'};\\delta_2^{\\rho_2} \\proves e_1,\\ e_2:\\tau^\\gamma\\makes \\delta_3^{\\rho_3}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves (\\mathsf{if}\\;c\\;\\mathsf{then}\\;e_1\\;\\mathsf{else}\\;e_2):\\tau^\\gamma\\makes \\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-struct]\n    {\\!\\:{\\gamma_2\\le\\gamma_1, \\gamma\\quad\n      \\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\tau^{\\gamma_2}\\makes \\delta_2^{\\rho_2}\\atop\n      \\Gamma^\\alpha;\\delta_2^{\\rho_2} \\proves \\langle \\overline{e}\\rangle:(\\tau'[e/x])^{\\gamma}\\makes \\delta_3^{\\rho_3}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\langle e,\\overline{e}\\rangle:(\\textstyle\\sum x^{\\gamma_1}:{\\tau^{\\gamma_2}},\\tau')^{\\gamma}\\makes \\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-var-move]\n    {\\gamma\\le \\alpha,\\rho,\\gamma'}\n    {\\Gamma^\\alpha;(\\delta,x^{\\gamma'}:=pe:\\tau)^\\rho \\proves x:\\tau^\\gamma\\makes(\\delta,x^{\\gamma'}:=pe:\\core\\tau)^\\rho}\\and\n  \\infer[tyc-mut]\n    {\\!\\:{\\gamma_1\\le\\gamma\\quad\n      \\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e_1:\\tau_1^{\\gamma_1}\\makes\\delta_2^{\\rho_2}\\atop\n      \\Gamma^\\alpha;\\delta_2^{\\rho_2},(x\\to y),(y^{\\gamma_1}:=e_1:\\tau_1)\\proves e_2:\\tau_2^{\\gamma_2}\\makes\\delta_3^{\\rho_3}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves (x^{\\gamma}\\gets e_1\\ \\mathsf{with}\\ y\\gets x;\\ e_2):\\tau_2^{\\gamma_2}\\makes\\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-unreachable]\n    {\\rho_2\\le\\rho\\quad\n      \\Gamma^\\alpha;\\delta^\\rho \\proves e:\\bot^\\bot\\makes\\delta_1^{\\rho_1}}\n    {\\Gamma^\\alpha;\\delta^\\rho \\proves \\mathsf{unreachable}\\;e:\\tau^\\gamma\\makes\\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-let]\n    {\\!\\:{\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e_1:\\tau_1^{\\gamma_1}\\makes \\delta_2^{\\rho_2}\\quad\n      t:\\tau_1^{\\gamma_1}\\Rightarrow \\overline{R^\\gamma}\\atop\n      (\\Gamma,\\overline{\\core{R}})^\\alpha;(\\delta_2,\\overline{R^\\gamma})^{\\rho_2} \\proves e_2:\\tau_2^{\\gamma_2}\\makes\\delta_3^{\\rho_3}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves (\\mathsf{let}\\ t := e_1\\;\\mathsf{in}\\; e_2):\\tau_2^{\\gamma_2}\\makes\\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-return]\n    {\\!\\:{\\rho_2\\le\\rho\\quad\\rho_1\\le\\alpha,\\gamma' \\quad\n      (\\textstyle\\sum\\bar S)^{\\gamma'}\\;\\mathsf{ctype}\\atop\n      \\mathsf{self}^\\sigma(\\bar R):\\bar S\\quad\n      \\Gamma^\\alpha;\\delta^\\rho \\proves \\langle\\overline{e}\\rangle:(\\textstyle\\sum\\bar S)^{\\gamma'}\\makes \\delta_1^{\\rho_1}}}\n    {\\Gamma^\\alpha;\\delta^\\rho \\proves \\mathsf{return}\\;\\overline{e}:\\bot^\\gamma\\makes \\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-proc-call]\n    {\\!\\:{\\gamma'\\le\\gamma\\quad \\sigma\\wedge\\rho_2\\le \\alpha,\\gamma,\\sigma'\\quad (\\textstyle\\sum\\bar R)^\\gamma,\\ (\\textstyle\\sum\\bar S)^{\\gamma'}\\;\\mathsf{ctype}\\atop\n      \\mathsf{self}^{\\sigma'}(-):-\\quad\n      \\mathsf{proc}^\\sigma\\;F(\\overline{R}):\\overline{S}\\quad\n      \\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\langle\\overline{e}\\rangle:(\\textstyle\\sum\\bar R)^\\gamma\\makes\\delta_2^{\\rho_2}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves F(\\overline{e}):(\\textstyle\\sum\\bar S)^{\\gamma'}\\makes\\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-label]\n    {\\!\\:{\\forall i,\\ (\\Gamma,\\overline{k^\\alpha(\\delta;\\bar{R})},(\\bar{R})_i)^{\\alpha_i};(\\delta_i,(\\bar{R})_i)^{\\rho_i} \\proves e_i:\\bot^\\bot\\makes{\\delta'_i}^{\\rho'_i}\\atop\n      (\\Gamma,\\overline{k^\\alpha(\\delta;\\bar{R})})^\\alpha;\\delta_1^{\\rho_1}\\proves e':\\tau^\\gamma\\makes\\delta_3^{\\rho_3}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves (\\mathsf{label}\\;\\overline{k(\\bar{R}):=e}\\;\\mathsf{in}\\;e'):\\tau^\\gamma\\makes\\delta_3^{\\rho_3}}\\and\n  \\infer[tyc-goto]\n    {\\!\\:{\\alpha'\\le \\alpha\\ \\ \\rho_2\\le \\rho\\ \\ \\rho_1\\le\\gamma\\quad\n      k^{\\alpha'}(\\delta_1^{\\rho_1};\\bar{R})\\in\\Gamma\\atop\n      \\Gamma^\\alpha;\\delta^{\\rho} \\proves \\langle\\overline{e}\\rangle:(\\textstyle\\sum\\bar R)^\\gamma\\makes\\delta_1^{\\rho_1}}}\n    {\\Gamma^\\alpha;\\delta^{\\rho} \\proves \\mathsf{goto}\\;k(\\overline{e}):\\bot^{\\gamma'}\\proves \\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-assert]\n    {\\!\\:{\\rho_2\\le \\sigma,\\alpha,\\gamma\\quad\n      \\mathsf{self}^\\sigma(-):-\\atop\n      \\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\mathsf{bool}^\\gamma \\makes \\delta_2^{\\rho_2}}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\mathsf{assert}\\;e:e^{\\gamma'}\\makes\\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-typeof]\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\tau^\\bot \\makes \\delta_2^{\\rho_2}}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\mathsf{typeof}\\;e:\\boxed{e:\\tau}^{\\gamma}\\makes\\delta_2^{\\rho_2}}\\and\n  \\infer[tyc-entail]\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\langle\\overline{e}\\rangle:\\textstyle(\\Sep\\overline{A})^\\bot \\makes \\delta_2^{\\rho_2}\\quad\n      \\proves p:\\textstyle\\Sep\\overline{A}\\wand B}\n    {\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves \\mathsf{entail}\\;\\overline{e}\\;p:B^\\gamma\\makes\\delta_2^{\\rho_2}}\\and\n\\end{mathparpagebreakable}\n\nThese rules have the same form as the \\textsc{tye-*} rules (slightly simplified to focus on the new part, the $\\alpha,\\rho,\\gamma$ annotations). The key new thing to notice is the inequality side conditions in most of the rules. For example:\n\\begin{itemize}\n\\item \\textsc{tyc-var-move} requires $\\gamma\\le \\alpha,\\rho,\\gamma'$ because if the result of the move is actually needed ($\\gamma$) then we must execute code ($\\alpha$) that is reachable ($\\rho$) and the data to move must actually be available ($\\gamma'$).\n\\item \\textsc{tyc-if} is the main rule that changes $\\alpha$. Inside the branches, $\\alpha$ becomes $\\alpha\\wedge \\gamma'$, because if we did not evaluate the condition we can't enter the branches.\n\\item \\textsc{tyc-return} requires $\\rho_2\\le \\rho$, just to ensure the lemma $(\\Gamma^\\alpha;\\delta_1^{\\rho_1} \\proves e:\\tau^\\gamma\\makes\\delta_2^{\\rho_2})\\to\\rho_2\\le\\rho_1$, but in practice we can always set $\\rho_2$ to $\\bot$ because it is unreachable. Similar conditions appear in \\textsc{tyc-unreachable} and \\textsc{tyc-goto}, since these expressions do not terminate normally. The other condition, $\\rho_1\\le\\alpha,\\gamma$ says that if we reach the return ($\\rho_1$), then we must be able to execute the return statement ($\\alpha$), and we need the value to return ($\\gamma'$).\n\\item \\textsc{tyc-proc-call} makes use of the $\\sigma$ annotations on functions. If a function has $\\sigma=\\top$, then it may perform a side effect, so we cannot omit it. We require $\\gamma'\\le \\gamma$ because if we need the result ($\\gamma'$) then we need the arguments ($\\gamma$), and we require $\\sigma\\wedge\\rho_2\\le\\alpha,\\gamma,\\sigma'$ because if the function $F$ is side effecting ($\\sigma$) and the call is reachable ($\\rho_2$), then we must execute the call ($\\alpha$), we need the arguments ($\\gamma$), and this function is itself side-effecting ($\\sigma'$).\n\\item \\textsc{tyc-assert} requires that $\\rho_2\\le\\sigma,\\alpha,\\gamma$ because if we reach the assert ($\\rho_2$), then because failure is a side effect ($\\sigma$) we have to execute it ($\\alpha$) and we need the condition ($\\gamma$).\n\\item In \\textsc{tyc-goto}, we add $\\alpha$ and $\\rho$ annotations to $k(\\delta,\\bar{R})$ to coordinate the entry to this block. Here $\\alpha'=\\bot$ is a bit unusual, because it means that the block we are jumping to does not physically exist. In this case, we don't need to jump to it, so no code is needed ($\\alpha'\\le \\alpha$), we have an arbitrary postcondition $\\rho_2$ that may as well be $\\bot$, and we need $\\rho_1\\le\\gamma$ because if the goto is reachable then we need the value.\n\\end{itemize}\n\nWe also need an annotated version of the no-op step judgment, in order to weaken variables when they are no longer live. This is exactly the same as \\textsc{cs-*}, but with the new rule \\textsc{ccs-ghost} that allows us to make a variable ghost. In particular, since the \\textsc{tyc-mut} rule does not remove the old value of the variable, it is in general a copy and not actually a mutation, so we will want to use \\textsc{ccs-ghost} just after constructing the expression $e_1$ to kill the old value so that we can safely replace it in-place with the new value.\n\n\\judgment[Ghost annotated no-op step]{\\Gamma;\\delta \\constep\\delta'}\n\\begin{mathparpagebreakable}\n  \\axiom[ccs-refl]{\\Gamma;\\delta \\constep \\delta}\\and\n  \\infer[ccs-trans]\n    {\\Gamma;\\delta_1 \\constep \\delta_2 \\quad \\Gamma;\\delta_2 \\constep \\delta_3}\n    {\\Gamma;\\delta_1 \\constep \\delta_3}\\and\n  \\infer[ccs-drop]\n    {\\forall x,(x\\to y)\\notin \\delta}\n    {\\Gamma;\\delta,(y^\\gamma:=pe:\\tau)\\constep\\delta}\\and\n  \\axiom[ccs-rename]\n    {\\Gamma;\\delta,(x\\to y),(y^\\gamma:=pe:\\tau)\\constep\\delta,(x^\\gamma:=pe:\\tau)}\\and\n  \\infer[ccs-forget]\n    {\\Gamma\\proves\\Gamma[\\overline{x\\to pe}]}\n    {\\Gamma;\\delta,\\overline{x^\\gamma:=pe:\\tau}\\constep\\delta,\\overline{x^\\gamma:\\tau}}\\and\n  \\infer[ccs-ghost]\n    {\\gamma'\\le \\gamma}\n    {\\Gamma;\\delta,(x^\\gamma:=pe:\\tau)\\constep\\delta,(x^{\\gamma'}:=pe:\\tau)}\\and\n\\end{mathparpagebreakable}\n\n\\subsection{Side effects}\\label{sec:sideeffect}\n\nWhile the ghost analysis pass is primarily intraprocedural, it contains one interprocedural part, namely the assignment of $\\sigma$ annotations to the procedures. When $\\sigma=\\top$, the procedure may perform a side effect, which is defined as anything which performs IO (i.e. compiler intrinsics and syscalls), plus $\\mathsf{assert}\\;\\mathsf{false}$ which causes early termination (which is also observable).\n\nIf a side effectful operation is reachable from a procedure, then we mark the procedure itself as side effectful (note that \\textsf{func} functions cannot have side effects). Note in particular that mutation is not considered a side effect, because the compiler has full visibility into what is going on and can track the values appropriately.\n\n\\section{Optimization and legalization}\\label{sec:optimization}\n\nAt this point, we are mostly done with user level errors; if type checking and the ghost analysis pass succeed then we should be able to complete compilation. The only exception to this is types that are too large to exist (which will be caught in this pass) and operations that cannot be compiled, such as unbounded integer operations.\n\nBecause the source language makes use of unbounded integer operations even in computationally relevant positions, it is not sufficient to simply require that any variable or expression of type $\\N_\\infty$ is ghost; for example a reasonable operation might be $x,y:\\N_{64}\\vdash \\mathsf{let}\\;z:\\N_{64}:=(x+y)\\mathrel{\\%}2^{64}$, which we expect to be compiled to an ADD instruction, despite the fact that $x+y:\\N_{\\infty}$ is an intermediate in this computation.\n\nWe call this phase legalization because it performs general rewriting in order to replace source level operations with operations which exist on the target architecture. So for example we can replace the subexpression $(x+y)\\mathrel{\\%}2^{64}$ by $x+_{64}y$, where $x+_{64}y$ is addition modulo $2^{64}$ that we expect to exist on the target machine. Once we have done so, there are no longer any unsized intermediates in the operation, and we can proceed with compilation.\n\n\\section{The Layout pass}\\label{sec:layout}\n\nThe ghost analysis pass has already determined \\emph{which} variables are required for the computation to proceed, but to determine \\emph{where} to put them, we have another pass, the layout pass.\n\nThe layout pass is responsible for assigning concrete memory locations to variables in the code. In particular, multiple variables may overlap the same memory location if they are never \\emph{live} at the same time, which is to say, the last use of one variable comes before the definition of the second. The analysis pass that determines these relations is considered part of the ``nondeterministic'' part of the compiler, meaning that it requires no proof. Instead, the analysis pass produces a satisfying layout, and the typing relation will validate that a layout puts variables in disjoint locations if they are live at the same time.\n\nTo that end, we introduce another syntactic category not present in the source language, a \\emph{machine place}, or M-place for short.\n\n$$\\mu::=\\mathsf{Reg}\\;r\\mid \\mathsf{Stack}\\;s$$\n\nThe registers $r$ correspond to the registers on the machine, so there is one for every general-purpose register. (On x86-64 there are 16 general purpose registers, but RSP is the stack pointer, and one register is reserved by the compiler for spilling, so there are 14 registers available for use.)\n\nThe stack locations $s$ correspond to an abstraction of the stack frame, optimized for disjointness proofs. A stack frame has a series-parallel layout:\n$$\\phi ::= \\phi_0\\ast\\phi_1\\mid \\phi_0\\cup \\phi_1\\mid |\\tau|$$\nand $s$ is a path into the stack frame:\n$$s ::= \\mathsf{id}\\mid s.0\\mid s.1 \\mid s.l \\mid s.r$$\nwith the following typing rules:\n\n\\judgment[Stack variable typing]{\\phi\\proves s:\\phi'}\n\\begin{mathparpagebreakable}\n  \\axiom[stk-id]{\\phi\\proves \\mathsf{id}:\\phi}\\and\n  \\infer[stk-fst]\n    {\\phi\\proves s:\\phi_1\\ast \\phi_2}\n    {\\phi\\proves s.0:\\phi_1}\\and\n  \\infer[stk-snd]\n    {\\phi\\proves s:\\phi_1\\ast \\phi_2}\n    {\\phi\\proves s.1:\\phi_2}\\and\n  \\infer[stk-left]\n    {\\phi\\proves s:\\phi_1\\cup \\phi_2}\n    {\\phi\\proves s.l:\\phi_1}\\and\n  \\infer[stk-right]\n    {\\phi\\proves s:\\phi_1\\cup \\phi_2}\n    {\\phi\\proves s.r:\\phi_2}\n\\end{mathparpagebreakable}\n\nIntuitively, $\\phi_1\\ast\\phi_2$ is the stack layout consisting of the layout $\\phi_1$ followed by $\\phi_2$ in the bytes immediately after, while $\\phi_1\\cup\\phi_2$ consists of $\\phi_1$ and $\\phi_2$ superimposed on the same bytes (taking up size equal to the larger of the two).\n\nAt a given point in execution, each of the unions has one of its members ``active'' and the other ``inactive'', and a variable can only be accessed if it is active in all parent unions.\nA ghost variable is never assigned any stack location and hence it can never be accessed. More formally, we say that two stack paths are \\emph{incompatible}, written $s_1\\perp s_2$, if there exists $s$ such that $s_1$ extends $s.l$ and $s_2$ extends $s.r$, or vice versa. We will maintain the invariant that if two variables in the context are represented by stack paths $s_1$ and $s_2$ then they are compatible.\n\n\\section{Semantics}\\label{sec:semantics}\n\nSemantics plays a rather more important role in Metamath C compared to other languages because the target architecture for the compiler is literally separation logic. So we need a way to interpret every judgment just described into a separating proposition or theorem.\n\n\\subsection{Interpreting the context}\n\nThe context $\\Gamma$ in the typing rules is ultimately compiled down to a separating proposition over machine states, and we need to interpret it in such a way that a validly typed expression corresponds to a valid theorem in separation logic.\n\nEach variable in the context may or may not be associated with a component of the machine state which is currently storing the value of that variable. A ghost variable will never have machine state attached to it, and a variable may also not have machine state attached to it if it is past its last use, or if it is uninitialized. To express this, we will add a new kind of context, a machine context $\\Delta$ which extends $\\delta$ with this information at each variable site.\n\n\\begin{itemize}\n\\item For each procedure in the global environment of declared items, we have a (persistent) proposition $\\mbox{\\textsf{proc-ok}}(\\ell:\\overline{R}\\to\\overline{S})$ which asserts that location $\\ell$ (an actual machine location) is the entry point to a function $f$ which, if called with arguments $\\overline{R}$, will return values $\\overline{S}$, according to the calling convention (which can be an additional parameter to \\textsf{proc-ok}, but we can suppose that there is one fixed calling convention).\n\nMutual recursions are more complex, as we may not be able to promise that they are safe to call without additional restrictions. Instead, for such functions we have $\\mbox{\\textsf{proc-ok}}(\\ell:(\\ghost{v:\\N},h:v<n,\\overline{R})\\to\\overline{S})$ where $v$ is the variant, and $n$ is a parameter, the value of the variant passed into this function. In other words, they must be called with a value of the variant less than the current one. We will not discuss the compilation of recursive functions here.\n\n\\item Type declarations correspond to certain unfolding theorems so they have no representation in the context. We can ignore the type variables $\\overline{\\alpha}$ in $\\Gamma$ because we don't support generic functions.\n\n\\item The jump targets $\\overline{k(\\delta,\\bar R)}$ in $\\Gamma$ become (persistent) propositions $\\textsf{jump-ok}(\\ell:(\\delta,\\bar {R})\\to \\bot)$ asserting that if we jump to location $\\ell$ with arguments $\\bar {R}$ according to the calling convention of the jump, then this machine state is OK (will eventually reach a final termination with the desired global properties). The $\\mathsf{return}(\\bar R)$ continuation is also a jump target of this form (where the calling convention uses \\texttt{ret} instead of \\texttt{jump}).\n\n\\item Each variable $x:\\core\\tau$ becomes a (regular) proposition $\\boxed{x:\\core\\tau}$.\n\\end{itemize}\n\nThe value context $\\delta$ is extended to $\\Delta$ by extending some of the variable records with $\\mathrel{@}\\mu$ annotations. They are interpreted like so:\n\\begin{itemize}\n\\item We store no additional information regarding the rename map.\n\\item Each $x^\\gamma:=pe:\\tau$ may either be left as is or extended to $x^{\\top}\\mathrel{@}\\mu:=pe:\\tau$ where $\\mu$ is an M-place. The second form is only available for non-ghost variables, and the M-places of distinct variables in the context will always be compatible. The former corresponds to the separating proposition $\\boxed{pe:\\tau}$, and the latter to $\\mu\\mapsto pe\\ast{}\\boxed{pe:\\tau}$.\n\\item For the shared variables extension, we store a list of active locks $x:=pe:\\tau$ corresponding to uses of the \\textsc{cs-lock} rule. We say $x:=pe:\\tau$ is an active lock if $(\\mathsf{ref}^x\\;x:=pe:\\tau)\\in\\delta$. For each active lock, we also store $\\boxed{pe:\\tau}$.\n\\item For each heap variable $\\mathsf{ref}^x\\;y^\\gamma:=pe':\\tau'$ such that $x:=pe:\\tau$ is an active lock, we store the pure proposition $(\\mu\\mapsto pe\\ast{}\\boxed{pe:\\tau}\\Rightarrow \\mu'\\mapsto pe'\\ast\\boxed{pe':\\tau'})$ if $x\\mathrel{@}\\mu$ and $y\\mathrel{@}\\mu'$, with the $\\mu$ conjuncts omitted if one or both of $x$ and $y$ is ghost.\n\\item For each heap variable $\\mathsf{ref}^\\mathsf{extern}\\;y^\\gamma:=pe':\\tau'$, we store the pure proposition $(P\\Rightarrow \\mu'\\mapsto pe'\\ast\\boxed{pe':\\tau'})$ where $P$ is the frame proposition (that is, $P$ is an implicit additional precise separating proposition passed in and out of the function).\n\\end{itemize}\n\n\\subsection{Interpreting the judgments}\n\nTODO\n\n\\end{document}\n", "meta": {"hexsha": "b0eaf4f0951f89d5dc928a606e04ab8bfe25addf", "size": 80851, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mm0-rs/theory/separation_logic.tex", "max_stars_repo_name": "tlyu/mm0", "max_stars_repo_head_hexsha": "91eacfbca9e25a87093244b79801979d17081c52", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 211, "max_stars_repo_stars_event_min_datetime": "2019-03-01T07:13:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T22:41:53.000Z", "max_issues_repo_path": "mm0-rs/theory/separation_logic.tex", "max_issues_repo_name": "tlyu/mm0", "max_issues_repo_head_hexsha": "91eacfbca9e25a87093244b79801979d17081c52", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 76, "max_issues_repo_issues_event_min_datetime": "2019-05-21T23:28:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T13:31:12.000Z", "max_forks_repo_path": "mm0-rs/theory/separation_logic.tex", "max_forks_repo_name": "tlyu/mm0", "max_forks_repo_head_hexsha": "91eacfbca9e25a87093244b79801979d17081c52", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2019-02-25T14:55:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-06T02:51:37.000Z", "avg_line_length": 79.7347140039, "max_line_length": 874, "alphanum_fraction": 0.7042708192, "num_tokens": 25457, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4006954854358645}}
{"text": "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\section{The Lebesgue Integral}\n\\label{sec:lebesgue-integral}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{intro}\n  This section introduces the Lebesgue integral mostly following the\n  presentation in the monograph by Riesz and\n  Sz.-Nagy~\\cite{RieszNagy}. We deviate from this work only in two\n  respects: first, we restrict the presentation to the results\n  pertaining to the definition and properties of $L^p$-spaces. Second,\n  we elaborate more on higher-dimensional integrals and modify the\n  development of the one-dimensional case in order to be closer to\n  higher dimensions.\n\\end{intro}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Sets of measure zero}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{intro}\n  Sets of measure zero constitute one of the most important concepts\n  in integration and measure theory. Odd enough, it is possible to\n  define them in an elementary way, which does not require any\n  advanced measure theory.\n\\end{intro}\n\n\\begin{definition}\n  \\label{def:zero-set-1}\n  A subset $Z\\subset \\R$ is called a \\textbf{set of measure zero}, if\n  for any $\\epsilon > 0$ there exist a finite or countable set of\n  intervals $I_{k}$ such that\n  \\begin{gather*}\n    Z \\subset \\bigcup_k I_{k}\n    \\quad\\text{and}\\quad\n    \\sum_k |I_{k}| < \\epsilon.\n  \\end{gather*}\n  We also say that the set $Z$ can be \\define{covered} by a finite or\n  countable union of intervals with total length less than $\\epsilon$.\n\\end{definition}\n\n\\begin{definition}\n  \\label{def:zero-set-2}\n  Sets of meazure zero in higher dimensions are defined in a similar\n  way, replacing the set of intervals $I_k$ by cubes $Q_k$ such that\n  their total volume is less than $\\epsilon$.\n\\end{definition}\n\n\\begin{example}\n  A set consisting of a single number $x\\in\\R$ is of measure zero,\n  since for any $\\epsilon>0$:\n  \\begin{gather*}\n    \\{x\\} \\subset \\left[x-\\tfrac\\epsilon2,x+\\tfrac\\epsilon2\\right].  \n  \\end{gather*}\n\\end{example}\n\n\\begin{lemma}\n  The finite or countable union of sets of measure zero is of measure\n  zero.\n\\end{lemma}\n\n\\begin{proof}\n  Let $\\{Z_j\\}_{j=1,2,\\dots}$ be a finite or countable sequence of\n  sets of measure zero. For each $Z_j$, let $\\{I_{jk}\\}$ be a set of\n  intervals covering $Z_j$ and having total length less than\n  $2^{-k}\\epsilon$. Such a set exists according to the definition of\n  a set of measure zero. Then,\n  \\begin{gather*}\n    Z = \\bigcup_j Z_j \\subset \\bigcup_{jk} I_{jk}\n    \\quad\\text{and}\\quad\n    \\sum_{jk} |I_{jk}| < \\epsilon.\n  \\end{gather*}\n  It remains to note that the index set $jk$ is at most countable.\n\\end{proof}\n\n\\begin{corollary}\n  The set $\\Q\\subset \\R$ of rational numbers is of measure zero, since\n  it is a countable union of points.\n\\end{corollary}\n\n\\begin{note}\n  The preceding corollary implies that a dense subset of an interval\n  in $\\R$ can be covered by a system of intervals without covering the\n  whole interval. Definitely, a remarkable statement.\n\\end{note}\n\n\\begin{definition}\n  \\label{def:almost-everywhere}\n  A property is said to hold \\define{almost everywhere} on a set $M$,\n  if it holds on $M$, or at least on a set $M\\setminus Z$, where $Z$\n  is of measure zero.\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Step functions and their integrals}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{definition}\n  \\defindex{lattice} We introduce \\textbf{lattices}\n  $\\Q_n$\\footnote{The letter $\\Q$ with index always refers to a\n    lattice and never to the rational numbers} of $\\R^d$ consisting of\n  half open cubes\n  \\begin{gather*}\n    Q^{(n)}_{i_1,\\dots,i_d} =\n    \\left]\\tfrac{i_1}{2^n},\\tfrac{i_1+1}{2^n}\\right]\n    \\times\n    \\left]\\tfrac{i_2}{2^n},\\tfrac{i_2+1}{2^n}\\right]\n    \\times\\dots\\times\n    \\left]\\tfrac{i_d}{2^n},\\tfrac{i_d+1}{2^n}\\right],\n    \\qquad i_k\\in\\mathbb Z.\n  \\end{gather*}\n  The lattice is said to be of width $2^{-n}$.\n\\end{definition}\n\n\\begin{note}\n  Independent on the dimension $d$, the number of cubes in $\\Q_n$ is\n  countable. Thus, we can replace the multiple indices indicating the\n  position of a cube in the lattice by a single enumeration index\n  $k$. Furthermore, it is easy to see that the number of cubes in\n  $\\Q_n$ contained in a bounded set is finite, albeit depending on $n$.\n\\end{note}\n\n\\begin{definition}\n  A function $f$ is called a \\define{step function} on the lattice\n  $\\Q_n$, if $f$ is constant on each cube $Q_k$, and if $f$ is\n  different from zero only on a finite number of cubes.  We refer to\n  the value of $f$ on $Q_k$ as $f(Q_k)$ or short $f_k$.\n  \n  \\index{S@$\\mathcal S$}\n  We denote by $\\mathcal S$ the space of step functions.\n\\end{definition}\n\n\\begin{note}\n  A step function $f$ on a lattice $\\Q_n$ is also a step function on\n  any lattice $\\Q_m$ with $m>n$, by simply choosing it to be the same\n  constant on all the cubes of $\\Q_m$ which are subsets of the same\n  cube of $\\Q_n$.\n  \n  Therefore, further on, we can always compare two step functions by\n  comparing them on the finer lattice used for their definition.\n\\end{note}\n\n\n\\begin{definition}\n  \\index{integral!of a step function}\n  The \\textbf{integral} of a step function $f$ on $\\Q_n$ is\n  defined in the obvious way as\n  \\begin{gather*}\n    \\int_{\\R^d} f(x) \\dx = \\sum_{Q_k} f(q_k) |Q_k|,\n  \\end{gather*}\n  where $|Q_k|$ denotes the volume of the cube $Q_k$. Since the sum in\n  this definition is finite, the integral is finite.\n\\end{definition}\n\n\\begin{lemma}[Properties of the integral]\n  The integral of step functions is a linear operator,\n  that is, for two step functions $f$ and $g$ and numbers $a,b\\in\n  \\R$ holds\n  \\begin{gather*}\n    \\int_{\\R^d}\\bigl(a f(x)+b g(x)\\bigr) \\dx\n    = a\\int_{\\R^d} f(x) + b \\int_{\\R^d} g(x).\n  \\end{gather*}\n  Furthermore, the integral is monotonic, that is, if for all $x\\in\n  \\R^d$ holds $f(x) \\le g(x)$, then holds\n  \\begin{gather*}\n    \\int_{\\R^d} f(x) \\le \\int_{\\R^d} g(x).\n  \\end{gather*}\n\\end{lemma}\n\n\\begin{proof}\n  Both properties follow from the fact that they hold for the values\n  $f(Q_k)$ and $g(Q_k)$ and the summation operator.\n\\end{proof}\n\n\\begin{definition}\n  The \\define{support} of a function is the set\n  \\begin{gather}\n    \\supp f = \\overline{\n      \\bigl\\{x\\in \\R^d\\big| f(x) \\neq 0 \\bigr\\}}.\n  \\end{gather}\n  A function $f$ is said to have \\define{finite support} or\n  synonymously \\define{compact support} if $\\supp f$ is a bounded set.\n\\end{definition}\n\n\\begin{note}\n  Since the support of a step function $f$ consists of finitely many\n  cubes, its support is finite.\n\\end{note}\n\nThe following two lemmas establish the close connection between the\nconvergence of step functions almost everywhere and convergence of\ntheir integrals.\n\n\\begin{lemma}\n  \\label{lemma:integral:1}\n  Let $\\{\\phi_n\\}_{n=1,\\dots}$ be a monotonically decreasing sequence\n  of nonnegative step functions on lattices $\\Q_n$ converging to zero almost\n  everywhere. Then,\n  \\begin{gather*}\n    \\lim_{n\\to \\infty}\\int_{\\R^d} \\phi_n(x) \\dx = 0.\n  \\end{gather*}\n\\end{lemma}\n\n\\begin{proof}\n  First, we note that the assumptions imply that for all $n>1$ holds\n  \\begin{gather*}\n    S:= \\supp \\phi_1 \\supset \\supp \\phi_n.\n  \\end{gather*}\n  and thus the volume of the support of $\\phi_n$ is bounded by that of\n  $S$; let the volume of $S$ be $V$.\n\n  Let now $\\epsilon>0$ be arbitrarily small. Let $Z$ be the set of\n  measure zero, where the sequence does either not converge to zero,\n  or where any of the functions $\\phi_n$ is discontinuous. Let\n  $\\mathcal J_\\epsilon$ be an at most countable covering of this set\n  of total volume less than $\\epsilon$ according to\n  Definitions~\\ref{def:zero-set-1} and~\\ref{def:zero-set-2}.\n\n  Let $J$ be the union of all elements in $\\mathcal J_\\epsilon$. We\n  note that, since the sequence is decreasing, for any $x\\in S$ holds\n  $\\phi_n(x) \\le \\phi_1(x) \\le M$ and thus\n  \\begin{gather*}\n    \\int_J \\phi_n(x) \\le \\epsilon M.\n  \\end{gather*}\n  \n  For any point $x\\in \\R^d\\setminus J$ holds $\\phi_n(x)\\to 0$ as\n  $n\\to\\infty$. In particular, for $n$ sufficiently large, $\\phi_n(x)\n  \\le \\epsilon$. Since $\\phi_n$ is a step function, this holds not\n  only for $x$, but for the whole cube containing $x$. By varying\n  $x\\in \\R^d\\setminus J$, we obtain an infinite set of such cubes,\n  which we call $\\mathcal U_\\epsilon$.\n  \n  By their definition, the sets in the union of $\\mathcal J_\\epsilon$\n  and $\\mathcal U_\\epsilon$ cover the set $S$. And since $S$ is\n  compact, the Heine-Borel theorem says, that we can choose a finite\n  subset from both of these systems, say $\\breve{\\mathcal U_\\epsilon}\n  \\cup \\breve{\\mathcal J_\\epsilon}$ to cover $S$. Let $U$ be the union\n  of all cubes in $\\breve{\\mathcal U_\\epsilon}$. Then, there is an\n  index $n_0$, such that $\\phi_{n_0}(x) \\le \\epsilon$ for all $x\\in\n  U$. Thus,\n  \\begin{gather*}\n    \\int_{U} \\phi_n(x) < \\epsilon V,\n    \\qquad \\forall n\\ge n_0.\n  \\end{gather*}\n  We conclude the proof by noting that for $n\\ge n_0$\n  \\begin{gather*}\n    \\int_{S} \\phi_n(x)\\dx\n    \\le \\int_{U} \\phi_n(x)\\dx + \\int_{J} \\phi_n(x)\\dx\n    < \\epsilon(M+V),\n  \\end{gather*}\n  which can be made arbitrarily small by choosing $\\epsilon$ small.\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:integral:2}\n  Let $\\{\\phi_n\\}_{n=1,\\dots}$ be a monotonically increasing sequence\n  of step functions on lattices $\\Q_n$ such that their integrals are\n  uniformly bounded by a constant $C$:\n  \\begin{gather}\n    \\label{eq:integral:1}\n    \\int_{\\R^d} \\phi_n(x) \\dx \\le C.\n  \\end{gather}\n  Then, the functions $\\phi_n$ converge to a finite limit function\n  $\\phi$ almost everywhere in $\\R^d$.\n\\end{lemma}\n\n\\begin{proof}\n  First, we observe that it is sufficient to consider sequences of\n  nonnegative functions and thus positive constants $C$: otherwise, we\n  consider the lemma for the sequence consisting of the functions\n  $\\phi_n-\\phi_1$.\n\n  Let $E_\\epsilon$ be the set of points $x$, where $\\phi_n(x) >\n  C/\\epsilon$ for some $n$, and $E_0$ the set of points $x$, where\n  $\\phi_n(x) \\to \\infty$. Obviously, $E_0\\subset E_\\epsilon$ for any\n  $\\epsilon > 0$.\n  \n  The set $E_\\epsilon$ by its definition is an at most countable\n  sequence of the cubes on which the step functions are\n  defined. Therefore, the integral of $\\phi_n$ over $E_\\epsilon$ is\n  defined and there holds\n  \\begin{gather*}\n    \\frac{C}{\\epsilon}\\sum_{Q_{k}\\subset E_\\epsilon} |Q_{k}|\n    \\le \\int_{E\\epsilon} \\phi_n(x) \\dx\n    \\le \\int_{\\R^d} \\phi_n(x) \\dx \\le C.\n  \\end{gather*}\n  From this, we deduce that the total volume of the cubes in\n  $E_\\epsilon$ does not exceed epsilon. Since this set of cubes\n  covers $E_0$, we conclude that $E_0$ is of measure zero.\n\\end{proof}\n\n\\begin{remark}\n  \\label{remark:integral:1}\n  Due to the monotonicity of the integral, the sequence on the left\n  hand side of inequality~\\eqref{eq:integral:1} is monotonically\n  increasing. Therefore, the integrals are actually converging to a\n  finite value.\n\\end{remark}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Definition of the integral}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{intro}\n  In the previous section, we defined the integral of step functions\n  and investigated some limits. The goal of this section is the\n  extension of the integral to a wider class of functions. A first\n  extension is almost immediately suggested by\n  Lemma~\\ref{lemma:integral:2} and\n  Remark~\\ref{remark:integral:1}. Namely, assigning as value of the\n  integral of a function, which is the limit of an increasing sequence\n  of step functions almost everywhere, the limit of their\n  integrals. Nevertheless, it remains to prove that this yields a well\n  defined integral, in particular, that its definition is independent\n  of the actual choice of the sequence of step functions.\n\\end{intro}\n\n\\begin{lemma}\n  Let $\\{\\phi_n\\}$ be a monotonically increasing sequence of step\n  functions with uniformly bounded integrals, converging to a function\n  $f$ almost everywhere. Let the same hold for a second sequence\n  $\\{\\psi_n\\}$ and the function $g$. Furthermore, let\n  \\begin{gather*}\n    f(x) \\le g(x) \\quad\\text{almost everywhere in $\\R^d$.}\n  \\end{gather*}\n  Then,\n  \\begin{gather}\n    \\label{eq:integral:4}\n    \\lim_{n\\to\\infty} \\int_{\\R^d}\\phi_n(x)\\dx\n    \\le\n    \\lim_{n\\to\\infty} \\int_{\\R^d}\\psi_n(x)\\dx.\n  \\end{gather}\n\\end{lemma}\n\n\\begin{proof}\n  First, we introduce the abbreviations\n  \\begin{gather*}\n    M_1 = \\lim_{n\\to\\infty} \\int_{\\R^d}\\phi_n(x)\\dx\n    \\quad\\text{and}\\quad\n    M_2 = \\lim_{n\\to\\infty} \\int_{\\R^d}\\psi_n(x)\\dx.\n  \\end{gather*}\n  Let $\\phi_m$ be an arbitrary function in the first sequence. Then,\n  by the assumptions, $h_n^+ = \\phi_m-\\psi_n$, the positive part of\n  the difference, converges to zero almost everywhere and decreases\n  monotonically. Thus, by Lemma~\\ref{lemma:integral:1}, its integrals\n  tend to zero as well. We conclude\n  \\begin{gather*}\n    \\int_{\\R^d}\\phi_n(x)\\dx - M_2 \\le 0\n    \\quad\\text{or}\\quad\n    \\int_{\\R^d}\\phi_n(x)\\dx \\le M_2.\n  \\end{gather*}\n  If now we let $n\\to\\infty$, we obtain $M_1 \\le M_2$.\n\\end{proof}\n\n\\begin{note}\n  For two functions $f$ and $g$ as in the preceding Lemma with $f(x) =\n  g(x)$ almost everywhere, we can repeat the argument of the proof and\n  interchange the sequences. Thus, $M_1 = M_2$.\n  This means in particular, that the limit process in this lemma\n  uniquely defines the integral of the limit functions. Furthermore,\n  it means that we can always modify a function on a set of measure\n  zero without affecting its integral.\n\\end{note}\n\n\\begin{definition}\n  \\label{definition:integral:Splus}\n  Let $\\mathcal S^+$ be the set of functions which equal the limit of\n  a sequence of monotonically increasing step functions with uniformly\n  bounded\n  integrals almost everywhere. For any function $f\\in \\mathcal S^+$, we\n  define the integral as\n  \\begin{gather*}\n    \\int_{\\R^d} f(x) \\,dx := \\lim_{n\\to\\infty} \\int_{\\R^d}\\phi_n(x)\\dx,\n  \\end{gather*}\n  where $\\{\\phi_n\\}$ is any monotonically increasing sequence of step\n  functions converging to $f$ almost everywhere.\n\\end{definition}\n\n\\begin{example}\n  The function\n  \\begin{gather*}\n    f(x) =\n    \\begin{cases}\n      1 & x\\in \\Q \\\\\n      0 & x\\in \\R\\setminus \\Q\n    \\end{cases}\n  \\end{gather*}\n  is in $\\mathcal S^+$ and its integral is zero. This is due to the fact that\n  it is equal to the zero function almost everywhere.\n\\end{example}\n\n\\begin{lemma}\n  Let $h$ be a function which is the difference of two functions in\n  $\\mathcal S^+$, namely $h(x) = f_1(x)-f_2(x)$ almost everywhere. If\n  for two other functions in $\\mathcal S^+$ holds $h(x) =\n  g_1(x)-g_2(x)$ almost everywhere, then\n  \\begin{gather}\n    \\label{eq:integral:2}\n    \\int_{\\R^d} f_1(x)\\dx\n    -\\int_{\\R^d} f_2(x)\\dx\n    =\\int_{\\R^d} g_1(x)\\dx\n    -\\int_{\\R^d} g_2(x)\\dx,\n  \\end{gather}\n  that is, the difference of the integral does not depend on the\n  actual choice of the two functions in the difference.\n\\end{lemma}\n\n\\begin{definition}\n  Let $\\mathcal L$ be the class of functions\\footnote{Here, the letter\n    $\\mathcal L$ is used in reference to the Lebesgue integral. We\n    note that Lebesgue used the term ``summable'' instead of\n    ``integrable''.} which can be written as a difference of two\n  functions in $\\mathcal S^+$ almost everywhere. For any function\n  $h\\in \\mathcal L$, the \\define{integral} is defined as\n  \\begin{gather*}\n    \\int_{\\R^d} h(x)\\dx = \\int_{\\R^d} f(x)\\dx - \\int_{\\R^d} g(x)\\dx,\n  \\end{gather*}\n  where $f$ and $g$ are any two functions such that $h(x) = f(x) -\n  g(x)$ almost everywhere.\n  \n  The class $\\mathcal L$ is called the set of \\define{integrable functions}.\n\\end{definition}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\subsection{Structure of the class of integrable functions}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\begin{intro}\n  The next question we will have to address is, which functions are\n  integrable, and whether we are allowed to interchange limits of\n  sequences of functions and their integrals. In particular, we will\n  see that suitably bounded sequences of integrable functions have\n  integrable limits.\n\\end{intro}\n\n\\begin{lemma}\n  For every integrable function $f$ there exists a sequence of step\n  functions $\\{\\phi_n(x)\\}$ converging to $f$ almost everywhere, such\n  that\n  \\begin{gather*}\n    \\int_{\\R^d} \\bigl|f(x)-\\phi_n(x)\\bigr|\\dx \\to 0\n    \\quad\\text{as}\\quad n\\to \\infty.\n  \\end{gather*}\n\\end{lemma}\n\n\\begin{proof}\n  This lemma is an immediate consequence of the definition of the\n  class $\\mathcal L$ as differences of functions in $\\mathcal S^+$. In\n  fact, let $f(x) = h(x)-g(x)$ with both functions in $\\mathcal\n  S^+$ and let $\\{\\psi_n(x)\\}$ and $\\{\\rho_n(x)\\}$ be increasing\n  sequences of step functions converging to $h(x)$ and $g(x)$\n  almost everywhere, respectively. By definition,\n  \\begin{gather*}\n    \\int_{\\R^d} \\bigl|f(x)-\\phi_n(x)\\bigr|\\dx\n    \\le \\int_{\\R^d} \\bigl(h(x)-\\psi_n(x)\\bigr)\\dx\n    + \\int_{\\R^d} \\bigl(g(x)-\\rho_n(x)\\bigr)\\dx\n    \\to 0.\n  \\end{gather*}\n\\end{proof}\n\n\\begin{theorem}\n  \\label{theorem:integral:linearity}\n  \\index{linearity}\n  The class $\\mathcal L$ of integrable functions is a vector space and\n  the integral is linear, namely for functions $f,g\\in \\mathcal L$ and\n  numbers $\\alpha,\\beta\\in \\R$ holds\n  \\begin{gather}\n    \\label{eq:integral:3}\n    \\int_{\\R^d} \\bigl(\\alpha f(x)+\\beta g(x) \\bigr)\\dx\n    =\\alpha \\int_{\\R^d} f(x)\\dx\n    +\\beta\\int_{\\R^d} g(x)\\dx.\n  \\end{gather}\n  For functions $g(x)$ and $h(x)$ in $\\mathcal S+$ are\n  $\\sup(g(x),h(x)$ and  $\\inf(g(x),h(x)$ in $\\mathcal S+$.\n  Furthermore, for a function $f\\in \\mathcal L$, its positive part\n  $f^+$, its negative part $f^-$, and its absolute value $|f|$ are in\n  $\\mathcal L$.\n\\end{theorem}\n\n\\begin{proof}\n  The linerarity of the integral follows immediately by taking\n  corresponding linear combinations of step function sequences. Thus,\n  $\\mathcal L$ is a vector space. The same argument holds for the\n  infimum and supremum of two functions in $\\mathcal S^+$.\n\n  For the second part, we write $f(x)=h(x)-g(x)$ with both functions\n  in $\\mathcal S^+$, and note\n  \\begin{alignat*}{2}\n    |f| &= \\sup(g,h) - \\inf(g,h) \\\\\n    f^+ &= \\sup(g,h) - g &&= h - \\inf(g,h) \\\\\n    f^- &= \\sup(g,h) - h &&= g - \\inf(g,h).\n  \\end{alignat*}\n\\end{proof}\n\n\\begin{definition}\n  The \\define{characteristic function} of a subset $\\Omega\\subset\\R^d$ is\n  $\\chi_{\\Omega}$. It is defined as\n  \\begin{gather*}\n    \\chi_{\\Omega}(x) =\n    \\begin{cases}\n      1 & x\\in \\Omega \\\\\n      0 & x\\not\\in \\Omega\n    \\end{cases}\n  \\end{gather*}\n  \\defindex{integral!subset|textbf}\n  The function $f$ is said to be \\textbf{integrable} on the set\n  $\\Omega$, if $f\\chi_\\Omega$ is integrable (on $\\R^d$). The\n  \\textbf{integral} over $\\Omega$ of a function $f$ is defined as\n  \\begin{gather*}\n    \\int_\\Omega f(x)\\dx = \\int_{\\R^d} f(x) \\chi_\\Omega(x)\\dx.\n  \\end{gather*}\n  The \\define{measure} of a bounded domain $\\Omega$ is the integral of\n  $\\chi_\\Omega$.\n\\end{definition}\n\n\\begin{corollary}\n  The integral is additive, namely for two disjoint and not\n  necessarily bounded domains\n  $\\Omega_1\\subset\\R^d$ and $\\Omega_2\\subset\\R^d$ and a\n  function $f$ such that $f\\chi_{\\Omega_1}$ and $f\\chi_{\\Omega_2}$ are\n  integrable holds\n  \\begin{gather*}\n    \\int_{\\Omega_1\\cup\\Omega_2} f(x)\\dx\n    = \\int_{\\Omega_1} f(x)\\dx + \\int_{\\Omega_2} f(x)\\dx.\n  \\end{gather*}\n\\end{corollary}\n\n\\begin{proof}\n  This follows immediately from the linearity of the integral by\n  observing $f(x)\\chi_{\\Omega_1\\cup\\Omega_2}(x) =\n  f(x)\\chi_{\\Omega_1}(x)+f(x)\\chi_{\\Omega_2}(x)$.\n\\end{proof}\n\n\\begin{remark}\n  The space $\\mathcal S^+$ and thus the space of integrable functions\n  have been obtained by a \\putindex{completion} process. We started\n  out from the space of all test functions and then added to this\n  space all monotonically increasing limits with respect to the\n  topology ``convergent almost everywhere''. An important\n  characteristic of this process is, that it is \\putindex{idempotent},\n  that is, its repeated application does not change the result. We\n  first verify this statement for $\\mathcal S^+$. It is extended to\n  integrable functions by the Beppo-Levi\n  Theorem~\\ref{theorem:Beppo-Levi} below.\n\\end{remark}\n\n\\begin{lemma}\n  Let $f_n$ be an increasing sequence of functions in $\\mathcal\n  S^+$. Assume further that the integrals of $f_n$ are uniformly\n  bounded by a number $M$. Then, the sequence $f_n$ converges almost\n  everywhere to a function $f\\in\\mathcal S^+$ and there holds\n  \\begin{gather*}\n    \\lim_{n\\to\\infty} \\int_{\\R^d} f_n \\dx = \\int_{\\R^d} f \\dx.\n  \\end{gather*}\n\\end{lemma}\n\n\\begin{proof}\n  For each $n$, let $\\{\\phi_{nk}\\}_{k=1,,2,\\dots}$ be a sequence of\n  step functions converging monotonically to $f_n$ almost\n  everywhere. We generate a type of diagonal sequence in\n  $\\{\\phi_{nk}\\}$ by assigning\n  \\begin{gather*}\n    \\psi_n(x) = \\sup_{i\\le n} \\phi_{in}(x).\n  \\end{gather*}\n  Since each of the sequences $\\{\\phi_{nk}\\}$ is increasing with\n  respect to $k$, $\\psi_n$ must be increasing. Since they furthermore\n  increase towards $f_n$, we have almost everywhere $\\psi_n(x) \\le\n  f_n(x)$. Thus, \n  \\begin{gather*}\n    \\int_{\\R^d} \\psi_n \\dx \\le \\int_{\\R^d} f_n\\dx \\le M.\n  \\end{gather*}\n  By Lemma~\\ref{lemma:integral:2}, the sequence $\\psi_n$ converges\n  towards a limit function $f$ almost everywhere. On the other\n  hand, for $n\\le k$,\n  \\begin{gather*}\n    \\psi_n \\ge \\phi_{nk}.\n  \\end{gather*}\n  Therefore, by allowing $k\\to\\infty$, we obtain that\n  \\begin{gather*}\n    f_n(x) \\le f(x) \\quad\\text{almost everywhere}.\n  \\end{gather*}\n  Hence, we have $\\psi_n \\le f_n \\le f$ and $\\psi_n \\nearrow f$ almost\n  everywhere, thus the limit of $f_n$ must be equal to the one of\n  $\\psi_n$, namely $f_n$. The same argument holds for the integrals,\n  and since\n  \\begin{gather*}\n    \\int_{\\R^d} \\psi_n \\dx \\le \\int_{\\R^d} f_n \\dx \\le \\int_{\\R^d} f \\dx,\n  \\end{gather*}\n  and since the first integral converges to the last, so does the one\n  in the center.\n\\end{proof}\n\n\\begin{theorem}[Beppo-Levi]\n  \\label{theorem:Beppo-Levi}\n  \\index{Beppo-Levi Theorem}\n  Every monotonically increasing sequence $\\{f_n(x)\\}$\n  of integrable functions whose\n  integrals have a common bound, converges almost everywhere to an\n  integrable function $f(x)$, and the order of taking the limit and\n  integrating can be reversed, that is\n  \\begin{gather}\n    \\int_{\\R^d} f(x)\\dx\n    = \\lim_{n\\to\\infty} \\int_{\\R^d} f_n(x)\\dx\n  \\end{gather}\n\\end{theorem}\n\n\\begin{proof}\n  Let us first rewrite the problem as\n  \\begin{gather*}\n    f_n(x) = f_0(x) + \\sum_{k=1}^n g_k(x),\n  \\end{gather*}\n  where $g_k(x) = f_k(x) - f_{k-1}(x)$. By the assumptions, the\n  elements $g_k$ of the series are nonnegative and\n  integrable. Furthermore, since the integrals of $f_n$ have a common\n  bound, say $M$, the sequence of integrals is bounded by\n  \\begin{gather*}\n    \\sum_{n=1}^\\infty \\int_{\\R^d} g_n(x)\\dx\n    \\le M + \\int_{\\R^d} |f_0(x)|\\dx,\n  \\end{gather*}\n  and thus convergent.\n  \\begin{todo}\n    ...\n  \\end{todo}\n\\end{proof}\n\n\\begin{theorem}[Lebesgue]\n  \\index{Lebesgue Theorem}\n  If the sequence of integrable functions $\\{f_n(x)\\}$ converges\n  to a function $f(x)$ almost everywhere, and if there exists an\n  integrable function such that for all $n$\n  \\begin{gather}\n    \\label{eq:integral:5}\n    \\bigl|f_n(x)\\bigr| \\le g(x),\n  \\end{gather}\n  holds almost everywhere, then the function $f(x)$ is integrable and\n  \\begin{gather*}\n    \\int_{\\R^d} f(x)\\dx = \\lim_{n\\to\\infty} \\int_{\\R^d} f_n(x)\\dx.\n  \\end{gather*}\n\\end{theorem}\n\n\\begin{proof}\n  \\begin{todo}\n    ...\n  \\end{todo}\n\\end{proof}\n\n\\begin{example}\n  Condition~\\eqref{eq:integral:5} in Lebesgue's Theorem is necessary,\n  as can be seen from the following example. Let for $x\\in \\R$\n  \\begin{gather*}\n    f_n(x) =\n    \\begin{cases}\n      (n+1) |x|^n & x\\in [-1,1] \\\\\n      0 & \\text{else}.\n    \\end{cases}\n  \\end{gather*}\n  The sequence converges to zero almost everywhere, but the integrals\n  are two. Indeed, by changing the factor in front of $x^n$, the limit\n  of the integrals can be made any value including $\\infty$. On the\n  other hand, if the factors are uniformly bounded, the limit is zero,\n  as the theorem predicts.\n\\end{example}\n\nThe assumptions of Lebesgue's Theorem are too strong for some\napplications. Thus, the following lemma proves boundedness of the\nintegral of the limit under weaker assumptions.\n\n\\begin{lemma}[Fatou]\nIf the functions $f_n$ are nonnegative, integrable, and converge\nalmost everywhere in $\\Omega$ to a limit function $f$, and if\nfurthermore the sequence of integrals\n\\begin{gather*}\n  \\int_\\Omega f_n(x) \\dx,\n\\end{gather*}\nis bounded, then $f$ is integrable and\n\\begin{gather*}\n  \\int_\\Omega f(x)\\dx \\le \\liminf_{n\\to\\infty} \\int_\\Omega f_n(x) \\dx.\n\\end{gather*}\n\\end{lemma}\n\n\\begin{todo}\n  \\begin{proof}\n  \\end{proof}\n\\end{todo}\n%%% Local Variables: \n%%% mode: latex\n%%% TeX-master: \"main\"\n%%% End: \n", "meta": {"hexsha": "fce5c6794e6636a280de023f93a43390afdd9fff", "size": 25210, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "integration/integral.tex", "max_stars_repo_name": "ahumanita/notes", "max_stars_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "integration/integral.tex", "max_issues_repo_name": "ahumanita/notes", "max_issues_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-05-24T07:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-31T12:58:14.000Z", "max_forks_repo_path": "integration/integral.tex", "max_forks_repo_name": "ahumanita/notes", "max_forks_repo_head_hexsha": "73f23770e2b02f1b4a67987744ceffbd9ce797d7", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2018-05-15T19:28:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-05T19:07:29.000Z", "avg_line_length": 36.483357453, "max_line_length": 77, "alphanum_fraction": 0.6606902023, "num_tokens": 7961, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.4006954854358644}}
{"text": "%!TEX root = forallxsol.tex\n%\\part{First-order logic}\n%\\label{ch.FOL}\n%\\addtocontents{toc}{\\protect\\mbox{}\\protect\\hrulefill\\par}\n\n\\setcounter{chapter}{14}\n\\chapter{Sentences with one quantifier}\\label{s:MoreMonadic}\\setcounter{ProbPart}{0}\n\\problempart\n\\label{pr.BarbaraEtc}\nHere are the syllogistic figures identified by Aristotle and his successors, along with their medieval names:\n\\begin{ebullet}\n\t\\item \\textbf{Barbara.} All G are F. All H are G. So:  All H are F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif Fx)$}\n\t\\item \\textbf{Celarent.} No G are F. All H are G. So: No H are F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Ferio.} No G are F. Some H is G. So: Some H is not F\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\exists x (Hx \\eand  Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Darii.} All G are H. Some H is G. So: Some H is F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\exists x (Hx \\eand  Gx) \\therefore \\exists x (Hx \\eand  Fx)$}\n\t\\item \\textbf{Camestres.} All F are G. No H are G. So: No H are F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\forall x (Hx \\eif \\enot Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Cesare.} No F are G. All H are G. So: No H are F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\forall x (Hx \\eif Gx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Baroko.} All F are G. Some H is not G. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\exists x (Hx \\eand \\enot Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Festino.} No F are G. Some H are G. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\exists x (Hx \\eand Gx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Datisi.} All G are F. Some G is H. So: Some H is F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif Fx), \\exists x (Gx \\eand Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Disamis.} Some G is F. All G are H. So: Some H is F.\n\t\\item[] \\myanswer{$\\exists x (Gx \\eand Fx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Ferison.} No G are F. Some G is H. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Gx \\eif \\enot Fx), \\exists x (Gx \\eand Hx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Bokardo.} Some G is not F. All G are H. So:  Some H is not F.\n\t\\item[] \\myanswer{$\\exists x (Gx \\eand \\enot Fx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand \\enot Fx)$}\n\t\\item \\textbf{Camenes.} All F are G. No G are H So: No H is F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif Gx), \\forall x (Gx \\eif \\enot Hx) \\therefore \\forall x (Hx \\eif \\enot Fx)$}\n\t\\item \\textbf{Dimaris.} Some F is G. All G are H. So: Some H is F.\n\t\\item[] \\myanswer{$\\exists x (Fx \\eand Gx), \\forall x (Gx \\eif Hx) \\therefore \\exists x (Hx \\eand Fx)$}\n\t\\item \\textbf{Fresison.} No F are G. Some G is H. So: Some H is not F.\n\t\\item[] \\myanswer{$\\forall x (Fx \\eif \\enot Gx), \\exists x (Gx \\eand Hx) \\therefore \\exists (Hx \\eand \\enot Fx)$}\n\\end{ebullet}\nSymbolise each argument in FOL.\n\n\\\n\\problempart\n\\label{pr.FOLvegetarians}\nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[K] \\gap{1} knows the combination to the safe\n\\item[S] \\gap{1} is a spy\n\\item[V] \\gap{1} is a vegetarian\n%\\item[Txy] \\gap{x} trusts \\gap{y}.\n\\item[h] Hofthor\n\\item[i] Ingmar\n\\end{ekey}\nsymbolise the following sentences in FOL:\n\\begin{earg}\n\\item Neither Hofthor nor Ingmar is a vegetarian.\n\\item[] \\myanswer{$\\enot Vh \\eand \\enot Vi$}\n\\item No spy knows the combination to the safe.\n\\item[] \\myanswer{$\\forall x (Sx \\eif \\enot Kx)$}\n\\item No one knows the combination to the safe unless Ingmar does.\n\\item[] \\myanswer{$\\forall x \\enot Kx \\eor Ki$}\n\\item Hofthor is a spy, but no vegetarian is a spy.\n\\item[] \\myanswer{$Sh \\eand \\forall x(Vx \\eif \\enot Sx)$}\n%\\item Hofthor trusts a vegetarian.\n%\\item Everyone who trusts Ingmar trusts a vegetarian.\n%\\item Everyone who trusts Ingmar trusts someone who trusts a vegetarian.\n%\\item Only Ingmar knows the combination to the safe.\n%\\item Ingmar trusts Hofthor, but no one else.\n%\\item The person who knows the combination to the safe is a vegetarian.\n%\\item The person who knows the combination to the safe is not a spy.\n\\end{earg}\n\n\n\\problempart\\label{pr.FOLalligators}\nUsing this symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[A] \\gap{1} is an alligator.\n\\item[M] \\gap{1} is a monkey.\n\\item[R] \\gap{1} is a reptile.\n\\item[Z] \\gap{1} lives at the zoo.\n\\item[a] Amos\n\\item[b] Bouncer\n\\item[c] Cleo\n\\end{ekey}\nsymbolise each of the following sentences in FOL:\n\\begin{earg}\n\\item Amos, Bouncer, and Cleo all live at the zoo. \n\\item[] \\myanswer{$Za \\eand Zb \\eand Zc$}\n\\item Bouncer is a reptile, but not an alligator. \n\\item[] \\myanswer{$Rb \\eand \\enot Ab$}\n%\\item If Cleo loves Bouncer, then Bouncer is a monkey. \n%\\item If both Bouncer and Cleo are alligators, then Amos loves them both.\n\\item Some reptile lives at the zoo. \n\\item[] \\myanswer{$\\exists x (Rx \\eand Zx)$}\n\\item Every alligator is a reptile. \n\\item[] \\myanswer{$\\forall x(Ax \\eif Rx)$}\n\\item Any animal that lives at the zoo is either a monkey or an alligator. \n\\item[] \\myanswer{$\\forall x(Zx \\eif (Mx \\eor Ax))$}\n\\item There are reptiles which are not alligators.\n\\item[] \\myanswer{$\\exists x (Rx \\eand \\enot Ax)$}\n%\\item Cleo loves a reptile.\n%\\item Bouncer loves all the monkeys that live at the zoo.\n%\\item All the monkeys that Amos loves love him back.\n\\item If any animal is an reptile, then Amos is.\n\\item[] \\myanswer{$\\exists x Rx \\eif Ra$}\n\\item If any animal is an alligator, then it is a reptile.\n\\item[] \\myanswer{$\\forall x(Ax \\eif Rx)$}\n%\\item Every monkey that Cleo loves is also loved by Amos.\n%\\item There is a monkey that loves Bouncer, but sadly Bouncer does not reciprocate this love.\n\\end{earg}\n\n\\problempart\n\\label{pr.FOLarguments}\nFor each argument, write a symbolisation key and symbolise the argument in FOL.\n\\begin{earg}\n\\item Willard is a logician. All logicians wear funny hats. So Willard wears a funny hat\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[L] \\gap{1} is a logician\n\\item[H] \\gap{1} wears a funny hat\n\\item[i] Willard\n\\end{ekey}\n$Li, \\forall x (Lx \\eif Hx) \\therefore Hi$}\n\\item Nothing on my desk escapes my attention. There is a computer on my desk. As such, there is a computer that does not escape my attention.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] physical things\n\\item[D] \\gap{1} is on my desk\n\\item[E] \\gap{1} escapes my attention\n\\item[C] \\gap{1} is a computer\n\\end{ekey}\n$\\forall x (Dx \\eif \\enot Ex), \\exists x(Dx \\eand Cx) \\therefore \\exists x (Cx \\eand \\enot Ex)$}\n\\item All my dreams are black and white. Old TV shows are in black and white. Therefore, some of my dreams are old TV shows.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] episodes (psychological and televised)\n\\item[D] \\gap{1} is one of my dreams\n\\item[B] \\gap{1} is in black and white\n\\item[O] \\gap{1} is an old TV show\n\\end{ekey}\n$\\forall x (Dx \\eif Bx), \\forall x (Ox \\eif Bx) \\therefore \\exists x (Dx \\eand Ox)$. \\\\Comment: generic statements are tricky to deal with. Does the second sentence mean that \\emph{all} old TV shows are in black and white; or that most of them are; or that most of the things which are in black and white are old TV shows? I have gone with the former, but it is not clear that FOL deals with these well.}\n\\item Neither Holmes nor Watson has been to Australia. A person could see a kangaroo only if they had been to Australia or to a zoo. Although Watson has not seen a kangaroo, Holmes has. Therefore, Holmes has been to a zoo.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[A] \\gap{1} has been to Australia\n\\item[K] \\gap{1} has seen a kangaroo\n\\item[Z] \\gap{1} has been to a zoo\n\\item[h] Holmes\n\\item[a] Watson\n\\end{ekey}\n$\\enot Ah \\eand \\enot Aa, \\forall x(Kx \\eif (Ax \\eor Zx)), \\enot Ka \\eand Kh \\therefore Zh$}\n\\item No one expects the Spanish Inquisition. No one knows the troubles I've seen. Therefore, anyone who expects the Spanish Inquisition knows the troubles I've seen.\n\\myanswer{\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[S] \\gap{1} expects the Spanish Inquisition\n\\item[T] \\gap{1} knows the troubles I've seen\n\\item[h] Holmes\n\\item[a] Watson\n\\end{ekey}\n$\\forall x\\enot Sx, \\forall x \\enot Tx \\therefore \\forall x (Sx \\eif Tx)$}\n\\item All babies are illogical. Nobody who is illogical can manage a crocodile. Berthold is a baby. Therefore, Berthold is unable to manage a crocodile.\n\\myanswer{\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[B] \\gap{1} is a baby\n\\item[I] \\gap{1} is illogical\n\\item[C] \\gap{1} can manage a crocodile\n\\item[b] Berthold\n\\end{ekey}\n$\\forall x (Bx \\eif Ix), \\forall x (Ix \\eif \\enot Cx), Bb \\therefore \\enot Cb$}\n\\end{earg}\n\n\\chapter{Multiple generality}\\setcounter{ProbPart}{0}\n\\problempart\nUsing this symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[A] \\gap{1} is an alligator\n\\item[M] \\gap{1} is a monkey\n\\item[R] \\gap{1} is a reptile\n\\item[Z] \\gap{1} lives at the zoo\n\\item[L] \\gap{1} loves \\gap{2}\n\\item[a] Amos\n\\item[b] Bouncer\n\\item[c] Cleo\n\\end{ekey}\nsymbolise each of the following sentences in FOL:\n\\begin{earg}\n\\item If Cleo loves Bouncer, then Bouncer is a monkey. \n\\item[] \\myanswer{$Lcb \\eif Mb$}\n\\item If both Bouncer and Cleo are alligators, then Amos loves them both.\n\\item[] \\myanswer{$(Ab \\eand Ac) \\eif (Lab \\eand Lac)$}\n%\\item Some reptile lives at the zoo. \n%\\item Every alligator is a reptile. \n%\\item Any animal that lives at the zoo is either a monkey or an alligator. \n%\\item There are reptiles which are not alligators.\n\\item Cleo loves a reptile.\n\\item[] \\myanswer{$\\exists x(Rx \\eand Lcx)$\\\\Comment: this English expression is ambiguous; in some contexts, it can be read as a generic, along the lines of `Cleo loves reptiles'. (Compare `I do love a good pint'.) }\n\\item Bouncer loves all the monkeys that live at the zoo.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Zx) \\eif Lbx)$}\\item All the monkeys that Amos loves love him back.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Lax) \\eif Lxa)$}\n%\\item If any animal is an reptile, then Amos is.\n%\\item If any animal is an alligator, then it is a reptile.\n\\item Every monkey that Cleo loves is also loved by Amos.\n\\item[] \\myanswer{$\\forall x ((Mx \\eand Lcx) \\eif Lax)$}\n\\item There is a monkey that loves Bouncer, but sadly Bouncer does not reciprocate this love.\n\\item[] \\myanswer{$\\exists x (Mx \\eand Lxb \\eand \\enot Lbx)$}\n\\end{earg}\n\n\\problempart \nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] all animals\n\\item[D] \\gap{1} is a dog\n\\item[S] \\gap{1} likes samurai movies\n\\item[L] \\gap{1} is larger than \\gap{2}\n\\item[b] Bertie\n\\item[e] Emerson\n\\item[f] Fergis\n\\end{ekey}\nsymbolise the following sentences in FOL:\n\\begin{earg}\n\\item Bertie is a dog who likes samurai movies.\n\\item[] \\myanswer{$Db \\eand Sb$}\n\\item Bertie, Emerson, and Fergis are all dogs.\n\\item[] \\myanswer{$Db \\eand De \\eand D\\emph{f}$}\n\\item Emerson is larger than Bertie, and Fergis is larger than Emerson.\n\\item[] \\myanswer{$Leb \\eand L\\emph{f}e$}\n\\item All dogs like samurai movies.\n\\item[] \\myanswer{$\\forall x(Dx \\eif Sx)$}\n\\item Only dogs like samurai movies.\n\\item[] \\myanswer{$\\forall x(Sx \\eif Dx)$\\\\\nComment: the FOL sentence just written does not require that anyone likes samurai movies. The English sentence might suggest that at least some dogs \\emph{do} like samurai movies?}\n\\item There is a dog that is larger than Emerson.\n\\item[] \\myanswer{$\\exists x (Dx \\eand Lxe)$}\n\\item If there is a dog larger than Fergis, then there is a dog larger than Emerson.\n\\item[] \\myanswer{$\\exists x (Dx \\eand Lx\\emph{f}) \\eif \\exists x(Dx \\eand Lxe)$}\n\\item No animal that likes samurai movies is larger than Emerson.\n\\item[] \\myanswer{$\\forall x (Sx \\eif \\enot Lxe)$}\n\\item No dog is larger than Fergis.\n\\item[] \\myanswer{$\\forall x (Dx \\eif \\enot Lx\\emph{f})$}\n\\item Any animal that dislikes samurai movies is larger than Bertie.\n\\item[] \\myanswer{$\\forall x (\\enot Sx \\eif Lxb)$\\\\\nComment: this is very poor, though! For `dislikes' does not mean the same as `does not like'.}\n\\item There is an animal that is between Bertie and Emerson in size.\n\\item[] \\myanswer{$\\exists x((Lbx \\eand Lxe) \\eor (Lex \\eand Lxb))$}\n\\item There is no dog that is between Bertie and Emerson in size.\n\\item[] \\myanswer{$\\forall x \\bigl(Dx \\eif \\enot\\bigl[(Lbx \\eand Lxe) \\eor (Lex \\eand Lxb)\\bigr]\\bigr)$}\n\\item No dog is larger than itself.\n\\item[] \\myanswer{$\\forall x(Dx \\eif \\enot Lxx)$}\n\\item Every dog is larger than some dog.\n\\item[] \\myanswer{$\\forall x (Dx \\eif \\exists y(Dy \\eand Lxy))$\\\\\nComment: the English sentence is potentially ambiguous here. I have resolved the ambiguity by assuming it should be paraphrased by `for every dog, there is a dog smaller than it'.}\n\\item There is an animal that is smaller than every dog.\n\\item[] \\myanswer{$\\exists x \\forall y(Dy \\eif Lyx)$}\n\\item If there is an animal that is larger than any dog, then that animal does not like samurai movies.\n\\item[] \\myanswer{$\\forall x (\\forall y (Dy \\eif Lxy) \\eif \\enot Sx)$\\\\\nComment: I have assumed that `larger than any dog' here means `larger than every dog'.}\n\\end{earg}\n\n\\problempart\nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] people and dishes at a potluck\n\\item[R] \\gap{1} has run out.\n\\item[T] \\gap{1} is on the table.\n\\item[F] \\gap{1} is food.\n\\item[P] \\gap{1} is a person.\n\\item[L] \\gap{1} likes \\gap{2}.\n\\item[e] Eli\n\\item[f] Francesca\n\\item[g] the guacamole\n\\end{ekey}\nsymbolise the following English sentences in FOL:\n\\begin{earg}\n\\item All the food is on the table.\n\\item[] \\myanswer{$\\forall x(Fx \\eif Tx)$}\n\\item If the guacamole has not run out, then it is on the table.\n\\item[] \\myanswer{$\\enot Rg \\eif Tg$}\n\\item Everyone likes the guacamole.\n\\item[] \\myanswer{$\\forall x (Px \\eif Lxg)$}\n\\item If anyone likes the guacamole, then Eli does.\n\\item[] \\myanswer{$\\exists x (Px \\eand Lxg) \\eif Leg$}\\item Francesca only likes the dishes that have run out.\n\\item[] \\myanswer{$\\forall x \\bigl[(L\\emph{f}x \\eand Fx) \\eif Rx\\bigr]$}\n\\item Francesca likes no one, and no one likes Francesca.\n\\item[] \\myanswer{$\\forall x\\bigl[Px \\eif (\\enot L\\emph{f}x \\eand \\enot Lx\\emph{f})\\bigr]$}\n\\item Eli likes anyone who likes the guacamole.\n\\item[] \\myanswer{$\\forall x ((Px \\eand Lxg) \\eif Lex)$}\n\\item Eli likes anyone who likes the people that he likes.\n\\item[] \\myanswer{$\\forall x \\bigl[\\bigl(Px \\eand \\forall y[(Py \\eand Ley) \\eif Lxy]\\bigr) \\eif Lex\\bigr]$}\n\\item If there is a person on the table already, then all of the food must have run out.\n\\item[] \\myanswer{$\\exists x(Px \\eand Tx) \\eif \\forall x(Fx \\eif Rx)$}\n\\end{earg}\n\n\n\\problempart\n\\label{pr.FOLballet}\nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[D] \\gap{1} dances ballet.\n\\item[F] \\gap{1} is female.\n\\item[M] \\gap{1} is male.\n\\item[C] \\gap{1} is a child of \\gap{2}.\n\\item[S] \\gap{1} is a sibling of \\gap{2}.\n\\item[e] Elmer\n\\item[j] Jane\n\\item[p] Patrick\n\\end{ekey}\nsymbolise the following arguments in FOL:\n\\begin{earg}\n\\item All of Patrick's children are ballet dancers.\n\\item[] \\myanswer{$\\forall x(Cxp \\eif Dx)$}\n\\item Jane is Patrick's daughter.\n\\item[] \\myanswer{$Cjp \\eand Fj$}\n\\item Patrick has a daughter.\n\\item[] \\myanswer{$\\exists x(Cxp \\eand Fx)$}\n\\item Jane is an only child.\n\\item[] \\myanswer{$\\enot \\exists x Sxj$}\n\\item All of Patrick's sons dance ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[(Cxp \\eand Mx) \\eif Dx\\bigr]$}\n\\item Patrick has no sons.\n\\item[] \\myanswer{$\\enot \\exists x(Cxp \\eand Mx)$}\n\\item Jane is Elmer's niece.\n\\item[] \\myanswer{$\\exists x(Sxe \\eand Cjx \\eand Fj)$}\n\\item Patrick is Elmer's brother.\n\\item[] \\myanswer{$Spe \\eand Mp$}\n\\item Patrick's brothers have no children.\n\\item[] \\myanswer{$\\forall x\\bigl[(Spx \\eand Mx) \\eif \\enot \\exists y Cyx\\bigr]$}\n\\item Jane is an aunt.\n\\item[] \\myanswer{$Fj \\eand \\exists x(Sxj \\eand \\exists y Cyx)$}\n\\item Everyone who dances ballet has a brother who also dances ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[Dx \\eif \\exists y(My \\eand Syx \\eand Dy)\\bigr]$}\n\\item Every woman who dances ballet is the child of someone who dances ballet.\n\\item[] \\myanswer{$\\forall x\\bigl[(Fx \\eand Dx) \\eif \\exists y(Cxy \\eand Dy)\\bigr]$}\n\\end{earg}\n\n\n\\chapter{Identity}\\label{sec.identity}\\setcounter{ProbPart}{0}\n%\\problempart\n%\\label{pr.FOLcandies}\n%Using the following symbolisation key:\n%\\begin{ekey}\n%\\item[\\text{domain}] candies\n%\\item[Cx] \\gap{x} has chocolate in it.\n%\\item[Mx] \\gap{x} has marzipan in it.\n%\\item[Sx] \\gap{x} has sugar in it.\n%\\item[Tx] Boris has tried \\gap{x}.\n%\\item[Bxy] \\gap{x} is better than \\gap{y}.\n%\\end{ekey}\n%symbolise the following English sentences in FOL:\\\\\n%\\myanswer{Comment: these are deliberately tricky. What follows is the \\emph{best} we can offer in FOL, for each of these sentences. Some are not great.}\n%\\begin{earg}\n%\\item Boris has never tried any candy.\n%\\item[] \\myanswer{$\\forall x(Cx \\eif \\enot Tx)$}\n%\\item Marzipan is always made with sugar.\n%\\item[] \\myanswer{$\\forall x(Mx \\eif Sx)$}\n%\\item Some candy is sugar-free.\n%\\item[] \\myanswer{$\\exists x \\enot Sx$}\n%\\item The very best candy is chocolate.\n%\\item[] \\myanswer{Simply can't be done! The best we can offer is as in answer to 8.}\n%\\item No candy is better than itself.\n%\\item[] \\myanswer{$\\forall x \\enot Bxx$}\n%\\item Boris has never tried sugar-free chocolate.\n%\\item[] \\myanswer{$\\forall x((Cx \\eand Sx) \\eif \\enot Tx)$}\n%\\item Boris has tried marzipan and chocolate, but never together.\n%\\item[] \\myanswer{$\\exists x(Mx \\eand Tx) \\eand \\exists x(Cx \\eand Tx) \\eand \\forall x ((Mx \\eand Cx) \\eif \\enot Tx)$}\n%%\\item Boris has tried nothing that is better than sugar-free marzipan.\n%\\item Any candy with chocolate is better than any candy without it.\n%\\item[] \\myanswer{$\\forall x(Cx \\eif \\forall (\\enot Cy \\eif Bxy))$}\n%\\item Any candy with chocolate and marzipan is better than any candy that lacks both.\n%\\item[] \\myanswer{$\\forall x\\bigl[(Cx \\eand Mx)\\eif \\forall \\bigl((\\enot Cy \\eand \\enot My) \\eif Bxy\\bigr)\\bigr]$}\n%\\end{earg}\n\n\\problempart Explain why:\n\t\\begin{ebullet}\n\t\t\\item   `$\\exists x \\forall y(Ay \\eiff x= y)$' is a good symbolisation of `there is exactly one apple'.\n\t\t\\item[] \\myanswer{We might naturally read this in English thus: \n\t\t\\begin{ebullet}\n\t\t\t\\item There is something, x, such that, if you choose any object at all, if you chose an apple then you chose x itself, and if you chose x itself then you chose an apple. \n\t\t\\end{ebullet}\n\t\tThe x in question must therefore be the one and only thing which is an apple.}\n\t\t\\item `$\\exists x \\exists y \\bigl[\\enot x = y \\eand \\forall z(Az \\eiff (x= z \\eor y = z)\\bigr]$' is a good symbolisation of `there are exactly two apples'.\n\t\t\\item[] \\myanswer{Similarly to the above, we might naturally read this in English thus: \n\t\t\\begin{ebullet}\n\t\t\t\\item There are two distinct things, x and y, such that if you choose any object at all, if you chose an apple then you either chose x or y, and if you chose either x or y then you chose an apple. \n\t\t\\end{ebullet}\n\t\tThe x and y in question must therefore be the only things which are apples, and since they are distinct, there are two of them.}\n\t\\end{ebullet}\t\t\n\n\n\n\\chapter{Definite descriptions}\\setcounter{ProbPart}{0}\n\\problempart\nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] people\n\\item[K] \\gap{1} knows the combination to the safe.\n\\item[S] \\gap{1} is a spy.\n\\item[V] \\gap{1} is a vegetarian.\n\\item[T] \\gap{1} trusts \\gap{2}.\n\\item[h] Hofthor\n\\item[i] Ingmar\n\\end{ekey}\nsymbolise the following sentences in FOL:\n\\begin{earg}\n\\item Hofthor trusts a vegetarian.\n\\item[] \\myanswer{$\\exists x(Vx \\eand Thx)$}\n\\item Everyone who trusts Ingmar trusts a vegetarian.\n\\item[] \\myanswer{$\\forall x\\bigl[Txi \\eif \\exists y(Txy \\eand Vy)\\bigr]$}\n\\item Everyone who trusts Ingmar trusts someone who trusts a vegetarian.\n\\item[] \\myanswer{$\\forall x\\bigl[Txi \\eif \\exists y\\bigr(Txy \\eand \\exists z(Tyz \\eand Vz)\\bigr)\\bigr]$}\n\\item Only Ingmar knows the combination to the safe.\n\\item[] \\myanswer{$\\forall x(Ki \\eif x = i)$\\\\Comment: does the English claim entail that Ingmar \\emph{does} know the combination to the safe? If so, then we should formalise this with a `$\\eiff$'.}\n\\item Ingmar trusts Hofthor, but no one else.\n\\item[] \\myanswer{$\\forall x(Tix \\eiff x = h)$}\n\\item The person who knows the combination to the safe is a vegetarian.\n\\item[] \\myanswer{$\\exists x\\bigl[Kx \\eand \\forall y(Ky \\eif x = y) \\eand Vx\\bigr]$}\n\\item The person who knows the combination to the safe is not a spy.\n\\item[] \\myanswer{$\\exists x\\bigl[Kx \\eand \\forall y(Ky \\eif x = y) \\eand \\enot Sx\\bigr]$\\\\\nComment: the scope of negation is potentially ambiguous here; I have read it as \\emph{inner} negation.}\n\\end{earg}\n\n\n\n\\problempart\n\\label{pr.FOLcards}\nUsing the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] cards in a standard deck\n\\item[B] \\gap{1} is black.\n\\item[C] \\gap{1} is a club.\n\\item[D] \\gap{1} is a deuce.\n\\item[J] \\gap{1} is a jack.\n\\item[M] \\gap{1} is a man with an axe.\n\\item[O] \\gap{1} is one-eyed.\n\\item[W] \\gap{1} is wild.\n\\end{ekey}\nsymbolise each sentence in FOL:\n\\begin{earg}\n\\item All clubs are black cards.\n\\item[] \\myanswer{$\\forall x (Cx \\eif Bx)$}\n\\item There are no wild cards.\n\\item[] \\myanswer{$\\enot \\exists x Wx$}\n\\item There are at least two clubs.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Cx \\eand Cy)$}\n\\item There is more than one one-eyed jack.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Jx \\eand Ox  \\eand Jy \\eand Oy)$}\n\\item There are at most two one-eyed jacks.\n\\item[] \\myanswer{$\\forall x \\forall y \\forall z\\bigl[(Jx \\eand Ox \\eand Jy \\eand Oy \\eand Jz \\eand Oz) \\eif (x = y \\eor x = z \\eor y = z)\\bigr]$}\n\\item There are two black jacks.\n\\item[] \\myanswer{$\\exists x \\exists y(\\enot x = y \\eand Bx \\eand Jx \\eand By \\eand Jy)$\\\\\nComment: I am reading this as `there are \\emph{at least} two\\ldots'. If the suggestion was that there are \\emph{exactly} two, then a different FOL sentence would be required, namely:\\\\\n$\\exists x \\exists y \\bigl(\\enot x = y \\eand Bx \\eand Jx \\eand By \\eand Jy \\eand \\forall z[(Bz \\eand Jz) \\eif (x = z \\eor y = z)]\\bigr)$}\n\\item There are four deuces.\n\\item[] \\myanswer{$\\exists w \\exists x \\exists y \\exists z(\\enot w = x \\eand \\enot w = y \\eand \\enot w = z \\eand \\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Dw \\eand Dx \\eand Dy \\eand Dz)$\\\\\nComment: I am reading this as `there are \\emph{at least} four\\ldots'. If the suggestion is that there are \\emph{exactly} four, then we should offer instead:\\\\\n$\\exists w \\exists x \\exists y \\exists z\\bigl(\\enot w = x \\eand \\enot w = y \\eand \\enot w = z \\eand \\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Dw \\eand Dx \\eand Dy \\eand Dz \\eand \\forall v[Dv \\eif (v = w \\eor v = x \\eor v = y \\eor v =z)]\\bigr)$}\n\\item The deuce of clubs is a black card.\n\\item[] \\myanswer{$\\exists x \\bigl[Dx \\eand Cx \\eand \\forall y\\bigl((Dy \\eand Cy) \\eif x = y\\bigr) \\eand Bx\\bigr]$}\n\\item One-eyed jacks and the man with the axe are wild.\n\\item[] \\myanswer{$\\forall x \\bigl[(Jx \\eand Ox) \\eif Wx\\bigr] \\eand \\exists x\\bigl[Mx \\eand \\forall y(My \\eif x = y) \\eand Wx\\bigr]$}\n\\item If the deuce of clubs is wild, then there is exactly one wild card.\n\\item[] \\myanswer{$\\exists x \\bigl(Dx \\eand Cx \\eand \\forall y \\bigl[(Dy \\eand Cy) \\eif x= y\\bigr] \\eand Wx\\bigr) \\eif \\exists x \\bigl(Wx \\eand \\forall y(Wy \\eif x = y)\\bigr)$\\\\\nComment: if there is not exactly one deuce of clubs, then the above sentence is true. Maybe that's the wrong verdict. Perhaps the sentence should definitely be taken to imply that there is one and only one deuce of clubs, and then express a conditional about wildness. If so, then we might symbolise it thus:\n\\\\$\\exists x \\bigl(Dx \\eand Cx \\eand \\forall y \\bigl[(Dy \\eand Cy) \\eif x = y\\bigr] \\eand \\bigl[Wx \\eif \\forall y (Wy \\eif x = y)\\bigr]\\bigl)$}\n\\item The man with the axe is not a jack.\n\\item[] \\myanswer{$\\exists x \\bigl[Mx \\eand \\forall y(My \\eif x = y) \\eand \\enot Jx\\bigr]$}\n\\item The deuce of clubs is not the man with the axe.\n\\item[] \\myanswer{$\\exists x \\exists y\\bigl(Dx \\eand Cx \\eand \\forall z[(Dz \\eand Cz) \\eif x = z] \\eand My \\eand \\forall z(Mz \\eif y = z) \\eand \\enot x = y\\bigr)$}\n\n\\end{earg}\n\n\\\n\n\\problempart Using the following symbolisation key:\n\\begin{ekey}\n\\item[\\text{domain}] animals in the world\n\\item[B] \\gap{1} is in Farmer Brown's field.\n\\item[H] \\gap{1} is a horse.\n\\item[P] \\gap{1} is a Pegasus.\n\\item[W] \\gap{1} has wings.\n\\end{ekey}\nsymbolise the following sentences in FOL:\n\\begin{earg}\n\\item There are at least three horses in the world.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z (\\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Hx \\eand Hy \\eand Hz)$}\n\\item There are at least three animals in the world.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z (\\enot x = y \\eand \\enot x = z \\eand \\enot y = z)$}\n\\item There is more than one horse in Farmer Brown's field.\n\\item[] \\myanswer{$\\exists x \\exists y (\\enot x = y \\eand Hx \\eand Hy \\eand Bx \\eand By)$}\n\\item There are three horses in Farmer Brown's field.\n\\item[] \\myanswer{$\\exists x \\exists y \\exists z(\\enot x = y \\eand \\enot x = z \\eand \\enot y = z \\eand Hx \\eand Hy \\eand Hz \\eand Bx \\eand By \\eand Bz)$\\\\Comment: I have read this as `there are \\emph{at least} three\\ldots'. If the suggestion was that there are \\emph{exactly} three, then a different FOL sentence would be required.}\n\\item There is a single winged creature in Farmer Brown's field; any other creatures in the field must be wingless.\n\\item[] \\myanswer{$\\exists x\\bigl[Wx \\eand Bx \\eand \\forall y\\bigl((Wy \\eand By) \\eif x = y)\\bigr]$}\n\\item The Pegasus is a winged horse.\n\\item[] \\myanswer{$\\exists x \\bigl[Px \\eand \\forall y(Py \\eif x = y) \\eand Wx \\eand Hx\\bigr]$}\n\\item The animal in Farmer Brown's field is not a horse.\n\\item[] \\myanswer{$\\exists x \\bigl[ Bx \\eand \\forall y (By \\eif x = y) \\eand \\enot Hx\\bigr]$\\\\Comment: the scope of negation might be ambiguous here; I have read it as \\emph{inner} negation.}\n\\item The horse in Farmer Brown's field does not have wings.\n\\item[] \\myanswer{$\\exists x \\bigl[Hx \\eand Bx \\eand \\forall y \\bigl((Hy \\eand By) \\eif x = y\\bigr) \\eand \\enot Wx\\bigr]$\\\\Comment: the scope of negation might be ambiguous here; I have read it as \\emph{inner} negation.}\n\n\\end{earg}\n\n\\problempart\nIn this section, I symbolised `Nick is the traitor' by `$\\exists x (Tx \\eand \\forall y(Ty \\eif x = y) \\eand x = n)$'. Explain why these would be equally good symbolisations:\n\t\\begin{ebullet}\n\t\t\\item $Tn \\eand \\forall y(Ty \\eif n = y)$\n\t\t\\item[] \\myanswer{This sentence requires that Nick is a traitor, and that Nick alone is a traitor. Otherwise put, there is one and only one traitor, namely, Nick. Otherwise put: Nick is the traitor.}\n\t\t\\item $\\forall y(Ty \\eiff y = n)$\n\t\t\\item[] \\myanswer{This sentence can be understood thus: Take anything you like; now, if you chose a traitor, you chose Nick, and if you chose Nick, you chose a traitor. So there is one and only one traitor, namely, Nick, as required.}\n\t\\end{ebullet}\n\n\\chapter{Sentences of FOL}\\setcounter{ProbPart}{0}\n\\problempart\n\\label{pr.freeFOL}\nIdentify which variables are bound and which are free.\n\\myanswer{I shall underline the bound variables, and put free variables in blue.}\n\\begin{earg}\n\\item $\\exists x L\\underline{x}\\myanswer{y} \\eand \\forall y L\\underline{y}\\myanswer{x}$\n\\item $\\forall x A\\underline{x} \\eand B\\myanswer{x}$\n\\item $\\forall x (A\\underline{x} \\eand B\\underline{x}) \\eand \\forall y(C\\myanswer{x} \\eand D\\underline{y})$\n\\item $\\forall x\\exists y[R\\underline{xy} \\eif (J\\myanswer{z} \\eand K\\underline{x})] \\eor R\\myanswer{yx}$\n\\item $\\forall x_1(M\\myanswer{x_2} \\eiff L\\myanswer{x_2}\\underline{x_1}) \\eand \\exists x_2 L\\myanswer{x_3}\\underline{x_2}$\n\\end{earg}", "meta": {"hexsha": "212d12c8e9c5dc1af977f16c8133ce9dcc607a56", "size": 27899, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "solutions/forallx-sol-fol.tex", "max_stars_repo_name": "OpenLogicProject/forallx-cam", "max_stars_repo_head_hexsha": "37f7bbf197ba0fee0e2106f90755e2fc35f5b9bf", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2018-02-19T01:39:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-04T05:59:31.000Z", "max_issues_repo_path": "solutions/forallx-sol-fol.tex", "max_issues_repo_name": "ryanmichaelhebert/forallx-cam", "max_issues_repo_head_hexsha": "37f7bbf197ba0fee0e2106f90755e2fc35f5b9bf", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "solutions/forallx-sol-fol.tex", "max_forks_repo_name": "ryanmichaelhebert/forallx-cam", "max_forks_repo_head_hexsha": "37f7bbf197ba0fee0e2106f90755e2fc35f5b9bf", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2016-09-08T05:09:01.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-19T10:13:13.000Z", "avg_line_length": 52.4417293233, "max_line_length": 404, "alphanum_fraction": 0.6967991684, "num_tokens": 9812, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030761371502, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.40069547172579}}
{"text": "\\documentclass[main.tex]{subfiles}\n\\begin{document}\n\n\\section*{Thu Dec 05 2019}\n\nWe have the spin vector \\(s^{\\mu }\\): it is orthogonal to the 4-velocity and \n%\n\\begin{align}\n  \\dv{}{\\tau } s^{\\mu } = 0\n\\,.\n\\end{align}\n\nBy symmetry we also have \\(s^{\\theta } =0\\). \n\nBy orthogonality to the 4-velocity in the Schwarzschild frame we have \n%\n\\begin{align}\n  s^{t} = \\frac{R^2 \\Omega }{1 - \\frac{2GM}{r}} s^{\\varphi }\n\\,,\n\\end{align}\n%\nand for geodesic circular orbit we have \\(\\Omega^2 R^3 = GM \\). \n\nLet us also evolve \\(s^{\\varphi }\\): \n%\n\\begin{align}\n  \\dv{s^{\\varphi }}{\\tau } + \\Gamma^{\\varphi }_{\\beta \\gamma } u^{\\beta  } s^{\\gamma } = 0\n\\,,\n\\end{align}\n%\nand the nonzero Christoffel symbols which can appear are the \\(\\Gamma^{3}_{\\beta \\gamma }\\) with \\(\\beta = 0, 3\\) and \\(\\gamma = 0, 1, 3\\). \nThe only one which is nonzero is \\(\\Gamma^{3}_{13}\\): \n%\n\\begin{align}\n  \\Gamma^{3}_{13} = \\frac{1}{2} g^{33} \\qty(g_{33, 1})\n = \\frac{r^{-2}}{2} \\qty(2r) = \\frac{1}{r} \n\\,.\n\\end{align}\n\nThen the evolution equation is \n%\n\\begin{align}\n  \\dv{s^{\\varphi }}{\\tau } + \\frac{1}{r} \\underbrace{u^{t} \\Omega}_{ u^{\\varphi }} s^{r} = 0  \n\\,,\n\\end{align}\n%\nand as before we can use the fact that \\(u^{t} = \\dv*{t}{\\tau }\\) in order to write the equation as \n%\n\\begin{align}\n  \\dv{s^{\\varphi }}{t} + \\frac{\\Omega}{r} s^{r} =0 \n\\,,\n\\end{align}\n%\nwhich is coupled with the equation from before: \n%\n\\begin{align}\n    \\dv{s^{r}}{t} + \\qty(3GM - r)\\Omega s^{\\varphi }= 0\n\\,,\n\\end{align}\n%\nwhich seems to look like a harmonic oscillator: we just need to differentiate one of them, to get \n%\n\\begin{align}\n  \\dv[2]{s^{r}}{t} + (3GM-r) \\Omega \\dv{s^{\\varphi }}{t} = \\dv[2]{s^{r}}{t} - \\frac{3GM-r}{r} \\Omega^2 s^{r} = 0\n\\,,\n\\end{align}\n%\nso we found a harmonic oscillator with angular velocity \n%\n\\begin{align}\n  \\overline{\\Omega} = \\Omega \\sqrt{1 - \\frac{3GM}{r}}\n\\,,\n\\end{align}\n%\nand since \\(s^{\\varphi }\\) satisfies the same equation up to a constant it is also a harmonic oscillator with thee same frequency. \nIts solution will look like \n%\n\\begin{align}\ns^{r} = A \\cos(\\overline{\\Omega} t)\n\\,,\n\\end{align}\n%\nwhere \\(A\\) is an arbitrary constant,\nwe can relate \\(s^{\\varphi } \\) to this solution by differentiating it:\n%\n\\begin{align}\n  \\dv{s^{r}}{t} =\n  - A  \\overline{\\Omega} \\sin(\\overline{\\Omega} t) = R \\Omega \\qty(1 - \\frac{3GM}{r}) s^{\\varphi }\n\\,,\n\\end{align}\n%\nso in the end we have \n%\n\\begin{align}\n  s^{\\varphi } = - \\frac{A}{r} \\frac{\\Omega}{\\overline{\\Omega}} \\sin(\\overline{\\Omega} t)\n\\,.\n\\end{align}\n\nAlso, we can use \n%\n\\begin{align}\n  s^{t} = r^2 \\Omega \\qty(1 - \\frac{2GM}{r})^{-1} s^{\\varphi }\n\\,.\n\\end{align}\n\nBy the normalization \\(s^{\\mu } s^{\\nu } g_{\\mu \\nu } = 1\\) we have \\((s^{1})^2 g_{11} = A^2 \\qty(1 - 3GM/r)^{-1}=s_{*}^2 = \\const\\) at \\(t=0\\): so \n%\n\\begin{align}\n  A = s_{*} \\sqrt{1 - \\frac{3GM}{r}}\n\\,.\n\\end{align}\n\nWhat does an observer see? What does somebody at infinity see? \n\nWe call \\(\\Delta \\varphi \\) the angle between the spin vector and the radial direction: then \n%\n\\begin{align}\n  \\cos \\Delta \\varphi  = \\frac{\\text{radial component of the spin vector now}}{\\text{radial component of the spin vector at }  t=0}\n\\,,\n\\end{align}\n%\nwhich means \n%\n\\begin{align}\n  \\cos(\\Delta \\varphi ) = \\frac{e_{r} \\cdot s (t)}{e_r \\cdot s(0)}\n\\,,\n\\end{align}\n%\nwhere \\(s\\) is the spin vector and \\(e_r\\) is the radial unit vector: in Schwarzschild coordinates \\(e_{r} = (0, 1/\\sqrt{g_{11} } , 0, 0)\\). \n\nThis just simplifies to \n%\n\\begin{align}\n  \\cos(\\Delta \\varphi ) = \\frac{s^{r}}{A} = \\cos(\\overline{\\Omega}t)\n\\,,\n\\end{align}\n%\nand we are allowed to do this calculation in the Schwarzschild frame since the spatial velocity is always orthogonal to the radial unit vector. \nIf we were to use a direction different from the radial one we'd need to boost along it.   \n\nWhat does this solution mean? In the end our solution is \n%\n\\begin{subequations}\n\\begin{align}\n  s^{t} &= s_{*} \\sqrt{1 - \\frac{2GM}{r}} \\cos(\\overline{\\Omega} t)  \\\\\ns^{\\varphi } &= - s_{* } \\sqrt{1 - \\frac{2GM}{r}} \\frac{\\Omega}{\\overline{\\Omega} r} \\sin(\\overline{\\Omega} t)  \\\\\n s^{t} &= r^{2} \\Omega \\qty(1 - \\frac{2GM}{r})^{-1} s^{\\varphi }\n\\,,\n\\end{align}\n\\end{subequations}\n%\nand the solution to \\(\\cos(\\Delta \\varphi ) = \\cos(\\overline{\\Omega} t)\\) is \\(\\Delta \\varphi = \\pm \\overline{\\Omega} t\\), and we choose the solution for continuity with the case \\(M=0\\). \n\nIf we are rotating around a BH counterclockwise (with \\(M \\rightarrow 0\\)) then the spin must rotate clockwise in order to remain aligned with itself: therefore the right solution to choose is \\(\\Delta \\varphi = - \\overline{\\Omega} t\\). \n\nThis is the reason why there is a minus sign in the expression for \\(s^{\\varphi } \\). \n\nThe basis is rotating, and the spin must rotate the other way to compensate and remain stationary. \n\nSomeone at infinity sees the spin to be rotating with angular velocity \\(\\Omega - \\overline{\\Omega}\\), where \\(\\Omega \\) is the \\(\\dv*{\\varphi }{t}\\) of the orbit and \\(\\overline{\\Omega}\\) is the angular velocity of the spin in the coordinate system \\(\\varphi , r\\). \n\nOver a turn, which takes a time \\(t = 2 \\pi / \\Omega \\), the total \\(\\Delta \\varphi \\) is given by \n%\n\\begin{align}\n  \\frac{2\\pi}{\\Omega } \\qty( \\Omega - \\overline{\\Omega})\n  = 2 \\pi \\qty(1 - \\sqrt{1 - \\frac{3GM}{r}})\n  \\approx \\frac{3GM\\pi}{r} \n\\,\n\\end{align}\n%\nin the same direction as the orbit. \n\nLet us look at the gyroscope in a slowly rotating geometry: we consider the metric \n%\n\\begin{align}\n  \\dd{s^2} = \\dd{s^2}_{\\text{schw}} - \\frac{4 GJ}{r} \\sin^2 \\theta \\dd{t} \\dd{\\varphi } + O(J^2)\n\\,,\n\\end{align}\n%\nwhich (see homework sheet 8) is a vacuum solution to the Einstein equations. We have a 4 since we have to account both for \\(g_{03} \\) and \\(g_{30} \\). \n\nReinserting  \\(c\\), we get: \n%\n\\begin{align}\n  \\dd{s^2} = \\dd{s^2}_{\\text{schw}} - \\frac{4GJ}{c^3r^2} \\sin^2\\theta \\qty(r \\dd{\\varphi }) \\qty(c \\dd{t})\n\\,,\n\\end{align}\n%\nthen the quantity \\(4GJ / c^2 r^2\\) must be adimensional: then the dimensions of \\(J\\) are those of \\(c^3 r^2 / G\\), which are \n%\n\\begin{align}\n  \\SI{}{m^3 s^{-3}} \\times \\SI{}{m^2} \\times \\frac{1}{\\SI{}{kg m^3 s^{-2}}} = \\SI{}{kg m^2 s^{-1}} \n\\,,\n\\end{align}\n%\nthe dimensions of an angular momentum, \\(L = r \\wedge p\\). \n\nEssentially we are doing a boost along the \\(\\varphi \\) direction. \n\nLet us consider geodetic motion of the gyroscope along the rotation axis: the gyroscope is falling into the rotating BH along that axis. \n\nThe spin starts along the \\(x\\) axis, and we expect a change of the spin of the order \n%\n\\begin{align}\n  \\frac{GJ}{c^3r^2}\n\\,.\n\\end{align}\n\nWe might also have terms of order \n%\n\\begin{align}\n  O \\qty(\\frac{GJ}{c^3r^2} \\times \\frac{GM}{rc^2 })\n\\,,\n\\end{align}\n%\nbut there cannot be terms of just order \\(O(GM/rc^2)\\) since if there is no spin, even with positive BH mass the spin does not change. \n\n\\begin{bluebox}\n  This is because: the 4-velocity of the infalling observer looks like \\(u^{\\mu } = (u^{t}, u^{r}, 0,0,)\\). The spin in the LIF of the infalling observer only ever has angular components, \\(s^{\\nu } = (0,0,s^{\\theta }, 0)\\) (let us neglect the singularity of the coordinates at the \\(z\\) axis, it is not relevant).\n  \n  When we perform a boost to go to the Schwarzschild frame from the LIF, the transformation will mix the temporal and radial components of vectors, but it will leave the angular ones unchanged. Therefore, the spin vector will look like \\((0,0, s^{\\theta }, 0 )\\) in the Schwarzschild frame as well.\n\\end{bluebox}\n\nThe BH-mass contribution is small: then the mixed term is ``second order'', we can discard it and consider the \\(M=0\\) case. \n\nTherefore we can simply use the metric \n%\n\\begin{align}\n  \\dd{s^2} = \\eta_{\\mu \\nu } \\dd{x^{\\mu }} \\dd{x^{\\nu }}\n  - \\frac{4GJ}{r} \\sin^2 \\theta \\dd{t} \\dd{\\varphi }\n\\,,\n\\end{align}\n%\nand only keep the \\(O(J)\\) terms. \n\n\\end{document}\n", "meta": {"hexsha": "350e56046056ccedf4645a81e20950ba61a27323", "size": 7837, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "ap_first_semester/general_relativity/05dec.tex", "max_stars_repo_name": "jacopok/notes", "max_stars_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-10-10T13:10:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-13T14:52:50.000Z", "max_issues_repo_path": "ap_first_semester/general_relativity/05dec.tex", "max_issues_repo_name": "jacopok/notes", "max_issues_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ap_first_semester/general_relativity/05dec.tex", "max_forks_repo_name": "jacopok/notes", "max_forks_repo_head_hexsha": "805ebe1be49bbd14c6b46b24055f9fc7d1cd2586", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-03T16:20:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-06T16:11:07.000Z", "avg_line_length": 33.0675105485, "max_line_length": 314, "alphanum_fraction": 0.6330228404, "num_tokens": 2783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4006404760791155}}
{"text": "\\documentclass{article}\n\\usepackage {mathpartir}\n\\usepackage {amssymb}\n\n\\newcommand{\\from}{\\leftarrow}\n\\newcommand{\\arr}{\\rightarrow}\n\\newcommand{\\kw}[1]{\\mathtt{#1}}\n\\newcommand{\\cc}{~::~}\n\\newcommand{\\fun}{\\star}\n\n\\newcommand{\\eCase}[2]{\\kw{case}~{#1}~\\kw{of}~\\{~{#2}~\\}}\n\\newcommand{\\eLetCase}[3]{\\kw{case}~{#1}~\\kw{of}~{#2}~\\{~{#3}~\\}}\n\\newcommand{\\eLam}[2]{\\lambda{#1}.~{#2}}\n\\newcommand{\\eLet}[3]{\\kw{let}~\\{~{#1}={#2}~\\}~\\kw{in}~{#3}}\n\\newcommand{\\eCut}[4]{\\{ {#1} \\from {#2}~|~{#3} \\to {#4} \\}}\n\n\n\\newcommand{\\ju}[2]{\\mathtt{#1} \\cc {#2}}\n\\newcommand{\\fits}[2]{{#1}\\leftrightarrow{#2}}\n\\newcommand{\\nofit}[2]{{#1}\\nleftrightarrow{#2}}\n\\newcommand{\\op}[1]{{#1}^\\star}\n\\newcommand{\\ty}[2]{\\mathtt{#1}:{#2}}\n\n\\title{MALL}\n\n\\begin{document}\n\n\\section{Syntax}\n\n\\begin{mathpar}\nt := s~|~\\op s \\\\\ns := a~|~()~|~(t,t)~|~0~|~(t+t) \\\\\n\\end{mathpar}\n\n\\section{No Proof Terms}\n\n\\begin{mathpar}\n\n\\infer\n  {\\fits a x}\n  {a,x}\n\n\\infer\n  {\\fits a x}\n  {a,x+p}\n\n\\infer\n  {\\fits a x}\n  {a,p+x}\n\n\\infer\n  { }\n  {()}\n\n\\infer\n  {\\fits a x \\\\ \\fits b y}\n  {a,b,(x,y)}\n\n\\infer\n  { }\n  {\\Gamma,\\op 0}\n\n\n\\infer\n  {\\Gamma,a \\\\ \\Delta,x \\\\ \\fits a x}\n  {\\Gamma,\\Delta}\n\n\\infer\n  {\\Gamma,x \\\\ \\Gamma,y \\\\ \\fits a x \\\\ \\fits b y}\n  {\\Gamma,\\op{(a+b)}}\n\n\\infer\n  {\\Gamma}\n  {\\Gamma,\\op{()}}\n\n\\infer\n  {\\Gamma,x,y \\\\ \\fits a x \\\\ \\fits b y}\n  {\\Gamma,\\op{(a,b)}}\n\n\\\\\n\n\\infer\n  { }\n  {\\fits a {\\op a}}\n\n\\infer\n  { }\n  {\\fits {\\op a} a}\n\\end{mathpar}\n\n\n\n\\section{With Proof Terms}\n\nThe typing rules for an expression $e$ are of the form:\n$$\n\\ju e \\Gamma\n$$\n\n\\begin{mathpar}\n\n\\infer\n  {\\fits a x}\n  {\\ju {u = v} {u:a, v:x}}\n\n\\infer\n  {\\fits a x}\n  {\\ju {u = L~v} {u:a+p, v:x}}\n\n\\infer\n  {\\fits a x}\n  {\\ju {u = R~v} {u:p+a, v:x}}\n\n\\infer\n  { }\n  {\\ju {u = ()} {u:()}}\n\n\\infer\n  {\\fits a x \\\\ \\fits b y}\n  {\\ju {u = (v,w)} {u:(x,y),v:a,w:b}}\n\n\\infer\n  { }\n  {\\ju {u = \\{ v_i \\}} {u : \\op 0, v_i:x_i}}\n\n\n\\infer\n  {\\ju {e1} {u:a,\\Gamma} \\\\ \\ju{e2} {v:x,\\Delta} \\\\ \\fits a x}\n  {\\ju{ \\{ u \\to e_1; v \\to e_2 \\}} {\\Gamma,\\Delta}}\n\n\\infer\n  {\\ju {e1} {v:x,\\Gamma} \\\\ \\ju {e2} {w:y,\\Gamma} \\\\ \\fits a x \\\\ \\fits b y}\n  {\\ju {u = ~\\{L~v \\to e1; R~w \\to~e2\\}} {u:\\op{(a+b)},\\Gamma}}\n\n\\infer\n  {\\ju e {\\Gamma}}\n  {\\ju {u = \\{ () \\to e \\} } {u : \\op{()}, \\Gamma}}\n\n\\infer\n  {\\ju e {v:x,w:y,\\Gamma} \\\\ \\fits a x \\\\ \\fits b y}\n  {\\ju {u = \\{ (v,w) \\to e \\}} {u:\\op{(a,b)},\\Gamma}}\n\n\\end{mathpar}\n\n\n\\end{document}\n\n", "meta": {"hexsha": "bd5cc4b24d005a71d74e40d585a8b3478df51f99", "size": 2375, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/rules.tex", "max_stars_repo_name": "yav/LL", "max_stars_repo_head_hexsha": "6e2501784da0cc9234eba42542e63263d4165436", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-09-07T08:49:24.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T06:47:08.000Z", "max_issues_repo_path": "doc/rules.tex", "max_issues_repo_name": "yav/LL", "max_issues_repo_head_hexsha": "6e2501784da0cc9234eba42542e63263d4165436", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/rules.tex", "max_forks_repo_name": "yav/LL", "max_forks_repo_head_hexsha": "6e2501784da0cc9234eba42542e63263d4165436", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0472972973, "max_line_length": 76, "alphanum_fraction": 0.4922105263, "num_tokens": 1083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40064046688740107}}
{"text": "\\documentclass[12pt]{article}\n\n\\usepackage[T1]{fontenc} % standard font encodings\n\\usepackage[utf8]{inputenc} % different input encodings\n\\usepackage{lmodern} % latin modern fonts\n\\usepackage{amsthm} % theorems AMS style\n\\usepackage{amssymb} % math symbols\n\\usepackage{amstext} % typeset text in math environments\n\\usepackage{bm} % bold symbols in math\n\\usepackage{graphicx} % enhanced support for graphics\n\\usepackage{epstopdf} % con­vert EPS to 'en­cap­su­lated' PDF us­ing ghostscript\n\\usepackage[export]{adjustbox} % graph­ics - alike macros for “gen­eral” boxes\n\\usepackage{subcaption} % support for subcaptions\n\\usepackage[breaklinks=true]{hyperref} % ex­ten­sive sup­port for hy­per­text\n\\usepackage{amsmath} % AMS math­e­mat­i­cal fa­cil­i­ties\n\\usepackage{setspace} % set space be­tween lines\n\\usepackage{morefloats} % in­crease the num­ber of si­mul­ta­ne­ous floats\n\\usepackage[capitalize]{cleveref} % in­tel­li­gent cross-ref­er­enc­ing\n\n% Adjusting cleveref package\n\\crefalias{subequation}{equation} % subequations counter = equations counter\n\\crefformat{pluraleq}{Eqs.~(#2#1#3)} % defining \"plural\" equations  \n\n% Adjusting page layouts and margins\n\\pagestyle{plain}\n\\renewcommand{\\baselinestretch}{1.0} \n\\setlength{\\topmargin}{-0.5in} \n\\setlength{\\oddsidemargin}{0.25in} \n\\setlength{\\evensidemargin}{0.25in} \n\\setlength{\\textwidth}{6.0in} \n\\setlength{\\textheight}{9.0in} \n\\setlength{\\parskip}{0pt}    \n\n% Labels of tables, sections, equations (NSE-style)\n\\renewcommand\\thetable{\\Roman{table}}\n\\renewcommand{\\thesection}{\\Roman{section}} \n\\renewcommand{\\thesubsection}{\\thesection.\\Alph{subsection}}\n\\renewcommand{\\theequation}{\\arabic{equation}}\n\n% Defining subfigures and subsubcaptions \n\\makeatletter\n\\newcounter{parentsubcaption}\n\\newenvironment{subsubcaption}\n {\n \\renewcommand{\\thesubfigure}{\\roman{subfigure}}\n \\refstepcounter{sub\\@captype}%\n  \\protected@edef\\theparentsubcaption{\\@nameuse{thesub\\@captype}}%\n  \\setcounter{parentsubcaption}{\\value{sub\\@captype}}%\n  \\setcounter{sub\\@captype}{0}%\n  \\@namedef{thesub\\@captype}{\\alph{sub\\@captype}.\\theparentsubcaption}%\n  \\ignorespaces\n}{%\n  \\setcounter{sub\\@captype}{\\value{parentsubcaption}}%\n  \\ignorespacesafterend\n}\n\\makeatother\n\n\n% Adjusting hyperlinks\n\\hypersetup{colorlinks=true,\n  pdftitle={Nonclassical Particle Transport in 1-D Random Periodic Media},\n  pdfauthor={Richard Vasques and Kai Krycki and Rachel Slaybaugh}\n}\n\n% Newcommands (for this example file)\n\\newcommand{\\bl}{\\big<}\n\\newcommand{\\bg}{\\big>}\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\eps}{\\varepsilon}\n\\renewcommand{\\vec}[1]{\\mathbf{#1}}\n\\newcommand{\\mat}[1]{\\mathbf{#1}}\n\\newcommand{\\ux}{{\\bm x}}\n\\newcommand{\\un}{{\\bf n}}\n\\newcommand{\\uomega}{{\\bf \\Omega}}\n\\newcommand{\\unabla}{{\\bf \\nabla}}\n\\newcommand{\\ul}{\\underline}\n\\newcommand{\\seta}{\\mathcal{A}}\n\\newcommand{\\setb}{\\mathcal{B}}\n \\newcommand{\\Keywords}[1]{\\vspace{12pt}\\par\\noindent\n{\\small{\\bf Keywords\\/}: #1}}\n\n\n\\begin{document}\n\n\\title{Nonclassical Particle Transport in 1-D Random Periodic Media}\n\\author{{\\bf R.\\ Vasques $^{\\dagger,}$}\\footnote{Email: \\texttt{richard.vasques@fulbrightmail.org}} , {\\bf K.\\ Krycki $^\\ddagger$}, {\\bf R.N.\\ Slaybaugh $^\\dagger$}\\\\ \\\\\n\\em {\\bf $^\\dagger$}University of California, Berkeley\\\\\n\\em Department of Nuclear Engineering\\\\\n\\em 4155 Etcheverry Hall, Berkeley, CA 94720-1730\\\\\n\\and \\\\\n\\em {\\bf $^\\ddagger$}Aachen Institute for Nuclear Training GmbH \\\\\n\\em Jesuitenstraße 4, 52062 Aachen, Germany}\n\\date{}\n\\maketitle\n\n\\begin{abstract}\n\nWe investigate the accuracy of the recently proposed nonclassical transport equation.\nThis equation contains an extra independent variable compared to the classical transport equation (the path-length $s$), and models particle transport taking place in homogenized random media in which a particle's distance-to-collision is not exponentially distributed.\nTo solve the nonclassical equation one needs to know the $s$-dependent ensemble-averaged total cross section, $\\Sigma_t(\\mu,s)$, or its corresponding path-length distribution function, $p(\\mu,s)$.\nWe consider a 1-D spatially periodic system consisting of alternating solid and void layers, randomly placed in the $x$-axis.\nWe obtain an analytical expression for $p(\\mu,s)$ and use this result to compute the corresponding $\\Sigma_t(\\mu,s)$.\nThen, we proceed to numerically solve the nonclassical equation for different test problems in rod geometry; that is, particles can move only in the directions $\\mu=\\pm 1$.\nTo assess the accuracy of these solutions, we produce ``benchmark\" results obtained by (i) generating a large number of physical realizations of the system, (ii) numerically solving the transport equation in each realization, and (iii) ensemble-averaging the solutions over all physical realizations.\nWe show that the numerical results validate the nonclassical model; the solutions obtained with the nonclassical equation accurately estimate the ensemble-averaged scalar flux in this 1-D random periodic system, greatly outperforming the widely-used atomic mix model in most problems. \n\n\\Keywords{nonclassical transport, random media, atomic mix}\n\\end{abstract}\n\n\\pagebreak\n\n\\doublespacing\n\n\\section{Introduction}\n\nThe classical theory of linear particle transport defines the total cross section $\\Sigma_t$ as independent of the path-length $s$ (the distance traveled by the particle since its previous interaction) and of the direction of flight $\\uomega$.\nThis definition leads to an exponential probability density function for a particle's distance-to-collision:\n\\begin{align}\\label{eq1}\np(s) = \\Sigma_t e^{-\\Sigma_t s}.\n\\end{align}\n\nHowever, a nonexponential attenuation law for the particle flux arises in certain inhomogeneous media in which the scattering centers are spatially correlated.\nThis ``nonclassical\" behavior occurs in certain important applications, such as neutron transport in Pebble Bed Reactors (in which a nonexponential $p(s)$ arises due to the pebble arrangement within the core) and photon transport in atmospheric clouds (in which the locations of the water droplets in the cloud seem to be correlated in ways that measurably affect the radiative transfer within the cloud).\n\nAn approach to this type of nonclassical transport problem was recently proposed \\cite{lar07,larvas11}, with the assumption that the positions of the scattering centers are correlated but independent of direction $\\uomega$.\nExistence and uniqueness of solutions are rigorously discussed in \\cite{fra10}.\nThis nonclassical theory was extended in \\cite{vaslar14a} to include angular-dependent path-length distributions in order to investigate anisotropic diffusion of neutrons in 3-D PBR cores.\n\nA similar kinetic equation with path-length as an independent variable has been rigorously derived for the periodic Lorentz gas in a series of papers by Golse et al.~(cf.~\\cite{gol12} for a review), and by Marklof \\& Str\\\"ombergsson (cf.~\\cite{mar11,mar15}).\nFurthermore, related work has been performed by Grosjean in \\cite{gro51}; it considers a generalization of neutron transport that includes arbitrary path-length distributions, and presents a derivation of diffusion solutions for infinite isotropic point and plane source problems.\n \nAssuming monoenergetic transport and isotropic scattering, the nonclassical linear Boltzmann equation with angular-dependent path-length distributions and isotropic source is writen as\n\\begin{align}\\label{eq2}\n\\frac{\\partial\\psi}{\\partial s}(\\ux,\\uomega,s) + &\\uomega\\cdot\\unabla \\psi(\\ux,\\uomega,s) + \\Sigma_t(\\uomega,s)\\psi(\\ux,\\uomega,s) \n\\\\&= \\frac{\\delta(s)}{4\\pi}\\left[ c\\int_{4\\pi}\\int_0^\\infty \\Sigma_t(\\uomega',s')\\psi(\\ux,\\uomega',s')ds' d\\Omega' + Q(\\ux) \\right]\\,, \\nonumber\n\\end{align}\nwhere $\\ux = (x,y,z)=$ position, $\\uomega = (\\Omega_x,\\Omega_y,\\Omega_z)=$ direction of flight (with $|\\uomega|=1$), $\\psi$ is the nonclassical angular flux, $c$ is the scattering ratio (such that the scattering cross section $\\Sigma_s= c\\Sigma_t$), and $Q$ is the source.\nHere, the nonclassical angular-dependent ensemble-averaged total cross section $\\Sigma_t(\\uomega,s)$ is defined as\n\\begin{align}\\label{eq3}\n\\Sigma_t(\\uomega,s)ds =  \\begin{array}{l}\n\\text{ the probability (ensemble-averaged over all physical}\\vspace{-10pt}\\\\\n\\text{ realizations) that a particle, scattered or born at any}\\vspace{-10pt}\\\\\n\\text{ point $\\ux$ and traveling in the direction $\\uomega$, will experience}\\vspace{-10pt}\\\\\n\\text{ a collision between $\\ux + s\\uomega$ and $\\ux + (s+ds)\\uomega$.}\n\\end{array}\n \\end{align}\nThe underlying path-length distribution and the above nonclassical cross section are related \\cite{vaslar14a} by\n\\begin{align}\\label{eq4}\n\tp(\\uomega,s) = \\Sigma_t(\\uomega,s)\\exp\\left( -\\int_0^s\\Sigma_t(\\uomega,s')ds'\\right).\n\\end{align}\nIt has been shown that, if $p(s)$ is independent of $\\uomega$, \\cref{eq2} can be converted to an integral equation for the scalar flux that is identical to the integral equation that can be constructed for certain diffusion-based approximations \\cite{siap15,vas16}.\n\nMoreover, if the path-length distribution function is an exponential as given in \\cref{eq1}, \\cref{eq2} reduces to the classical linear Boltzmann equation\n\\begin{subequations}\\label[pluraleq]{eq5}\n\\begin{align}\\label{eq5a}\n\\uomega\\cdot{\\unabla} \\Psi(\\ux,\\uomega) + \\Sigma_t\\Psi(\\ux,\\uomega) = \\frac{1}{4\\pi}\\left[\\int_{4\\pi}\\Sigma_s\\Psi(\\ux,\\uomega')d\\Omega' + Q(\\ux) \\right]\\,\n\\end{align}\nfor the classical angular flux \n\\begin{align}\n\\Psi(\\ux,\\uomega) = \\int_0^\\infty \\psi(\\ux,\\uomega,s)ds.\n\\end{align} \n\\end{subequations}\n\nNumerical results have been provided for the asymptotic diffusion limit of this nonclassical theory \\cite{larvas11,vaslar09,vas13,vaslar14b}, and for moment models of the nonclassical equation in the diffusive regime \\cite{kry13}.\nHowever, very few results have been presented for the nonclassical \\textit{transport} equation.\nThis is because one must know $\\Sigma_t(\\uomega,s)$, or $\\Sigma_t(s)$ in the case of angular-independent path lengths, in order to solve \\cref{eq2}. \n\nIn this paper we investigate the accuracy of the 1-D nonclassical transport equation.\nWe consider a 1-D random periodic system: a spatially periodic system consisting of alternating layers, randomly placed on the $x$-axis.\nThis means that we only know which material is present at any given point $x$ in a probabilistic sense.\nThe 1-D version of \\cref{eq2} is written as\n\\begin{align}\\label{eq6}\n\\frac{\\partial\\psi}{\\partial s}(x,\\mu,s) + \\mu\\frac{\\partial \\psi}{\\partial x}(x,\\mu,s) &+ \\Sigma_t(\\mu,s)\\psi(x,\\mu,s) \n\\\\& = \\frac{\\delta(s)}{2}\\left[ c\\int_{-1}^1\\int_0^\\infty \\Sigma_t(\\mu',s')\\psi(x,\\mu',s')ds' d\\mu' + Q(x) \\right]\\,. \\nonumber\n\\end{align}\nThis system was chosen because we can obtain an analytical expression for the distribution function $p(\\mu,s)$ of a particle's distance-to-collision in the direction $\\mu$.\nThen, using the identity \\cite{vaslar14a}\n\\begin{align}\\label{eq7}\n\\Sigma_t(\\mu,s)=\\frac{p(\\mu,s)}{1-\\int_0^sp(\\mu,s')ds'},\n\\end{align}\none can obtain a solution for \\cref{eq6}.\n\nThe numerical results presented in this paper consider transport in {\\em rod geometry}, in which particles can only move in the directions $\\mu = \\pm 1$.\nSolutions are given for a total of 72 solid-void test problems.\nTo analyze the accuracy of these results, we compare them against ``benchmark\" numerical results, obtained by ensemble-averaging the solutions of the transport equation over a large number of physical realizations of the random system.\nFurthermore, we compare the performance of the nonclassical model against the widely-used atomic mix model.\n\nThis paper is an expanded version of a recent conference paper \\cite{mc15}.\nThe remainder of this paper is organized as follows.\nIn \\cref{sec2} we sketch the 1-D random periodic system under consideration.\nIn \\cref{sec3} we analytically derive the path-length distribution function for the periodic random system; explicit expressions for solid-void media are given in \\cref{sec3A}.\nIn \\cref{sec4} we define the parameters of the test problems and describe the benchmark, atomic mix, and nonclassical approaches to solve them.\nIn \\cref{sec5} we examine the numerical results that confirm the accuracy of the nonclassical model.\nWe conclude with a discussion in \\cref{sec6}.\n\n\\section{The 1-D Random Periodic System}\\label{sec2}\n\nLet us consider a 1-D physical system similar to the one introduced in \\cite{zuc94}, consisting of alternating layers of two distinct materials (labeled 1 and 2) periodically arranged.\nThe period is given by $\\ell = \\ell_1 + \\ell_2$, where $\\ell_i$ represents the length of each layer of material $i \\in \\{1,2\\}$.\nA sketch of the periodic system is given in \\cref{fig1}.\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[width=\\textwidth]{fig1.eps}\n  \\caption{A sketch of the periodic medium}\n  \\label{fig1}\n\\end{figure}\n\nThis periodic system is {\\em randomly placed} in the infinite line $-\\infty < x < \\infty$, such that the probability $P_i$ of finding material $i$ in a given point $x$ is $\\ell_i/\\ell$.\nTherefore, the cross sections and source are stochastic functions of space; that is, if $x$ is in material $i$, then\n\\begin{subequations}\\label[pluraleq]{eq8}\n\\begin{align}\n\\Sigma_t(x) &= \\Sigma_{ti}\\, ,\\\\\n\\Sigma_s(x) &= c_i \\Sigma_{ti}\\, ,\\\\\nQ(x) &= Q_i(x) \\, ,\n\\end{align}\n\\end{subequations}\nwhere $\\Sigma_{ti}$, $c_i$, and $Q_i$ represent the total cross section, scattering ratio, and source in material $i$. \n\n\\section{The Path-length Distribution Function}\\label{sec3}\n\nGiven a physical realization of the 1-D system described in \\cref{sec2}, let us examine a particle that is born (or scatters) at a point $x$ in a layer of material $i \\in \\{1,2\\}$ with direction of flight $\\mu\\neq 0$.\nWe define $x_0$ to be the horizontal distance between $x$ (the point in which the collision or birth event took place) and the next intersection between layers in the direction $\\mu$.\nWe also define:\n\\begin{subequations}\\label[pluraleq]{eq9}\n\\begin{align}\np_{A_i}(x_0,\\mu,s) &= \\begin{array}{l}\n\\text{ the probability that a particle born or scattered in}\\vspace{-10pt}\\\\\n\\text{ material $i$, at a horizontal distance $x_0$ of the next}\\vspace{-10pt}\\\\\n\\text{ intersection, with direction of flight $\\mu$, will travel a}\\vspace{-10pt}\\\\\n\\text{ distance $s$ without colliding;}\n\\end{array}\n\\\\\np_{B_i}(x_0,\\mu,s)ds &= \\begin{array}{l}\n\\text{ the probability that a particle born or scattered in}\\vspace{-10pt}\\\\\n\\text{ material $i$, at a horizontal distance $x_0$ of the next}\\vspace{-10pt}\\\\\n\\text{ intersection, with direction of flight $\\mu$, will experience}\\vspace{-10pt}\\\\\n\\text{  a collision between $s$ and $s+ds$.}\n\\end{array}\n\\end{align}\n\\end{subequations}\nFor $\\mu\\neq 0$, we can write\n\\begin{subequations}\\label[pluraleq]{eq10}\n\\begin{align}\np_{A_i}(x_0,\\mu,s) &=  \\left\\{\n\\begin{array}{ll}\ne^{-\\Sigma_{ti}s}, & \\text{if } 0\\leq s|\\mu|\\leq x_0\\\\\n(e^{-\\Sigma_{ti}x_0/|\\mu|})(e^{-\\Sigma_{tj}(s-x_0/|\\mu|)}), &\\text{if } x_0< s|\\mu|\\leq x_0+\\ell_j\\\\\n(e^{-\\Sigma_{ti}(s-\\ell_j/|\\mu|)})(e^{-\\Sigma_{tj}\\ell_j/|\\mu|}), &\\text{if } x_0+\\ell_j< s|\\mu|\\leq x_0+\\ell\\\\\n\\,\\,\\,\\vdots & \n\\end{array}\n\\right.\n\\end{align}\nand\n\\begin{align}\np_{B_i}(x_0,\\mu,s) &=  \\left\\{\n\\begin{array}{ll}\n\\Sigma_{ti}, & \\text{if } 0\\leq s|\\mu|\\leq x_0\\\\\n\\Sigma_{tj}, &\\text{if } x_0< s|\\mu|\\leq x_0+\\ell_j\\\\\n\\Sigma_{ti}, &\\text{if } x_0+\\ell_j< s|\\mu|\\leq x_0+\\ell\\\\\n\\,\\,\\,\\vdots & \n\\end{array}\n\\right.\n\\,\\,,\n\\end{align}\n\\end{subequations}\nsuch that\n\\begin{subequations}\\label[pluraleq]{eq11}\n\\begin{align}\np_{A_i}(x_0,\\mu,s) &=  \\left\\{\n\\begin{array}{ll}\ne^{-\\Sigma_{ti}s}, & \\text{if } 0\\leq s|\\mu|\\leq x_0  \\\\\ne^{-\\Sigma_{tj}s-(\\Sigma_{ti}-\\Sigma_{tj})(x_0+n\\ell_i)/|\\mu|}, & \\text{if } x_0+n\\ell< s|\\mu|\\leq  x_0+n\\ell+\\ell_j \\\\\ne^{-\\Sigma_{ti}s-(\\Sigma_{tj}-\\Sigma_{ti})(n+1)\\ell_j/|\\mu|}, & \\text{if } x_0+n\\ell+\\ell_j< s|\\mu|\\leq x_0+(n+1)\\ell\n\\end{array}\n\\right.\n\\end{align}\nand\n\\begin{align}\np_{B_i}(x_0,\\mu,s) &=  \\left\\{\n\\begin{array}{ll}\n\\Sigma_{ti}, & \\text{if } 0\\leq s|\\mu|\\leq x_0\\\\\n\\Sigma_{tj}, &\\text{if } x_0+n\\ell< s|\\mu|\\leq  x_0+n\\ell+\\ell_j\\\\\n\\Sigma_{ti}, &\\text{if } x_0+n\\ell+\\ell_j< s|\\mu|\\leq x_0+(n+1)\\ell\n\\end{array}\n\\right.\n\\,\\,.\n\\end{align}\n\\end{subequations}\nHere, $n=0, 1, 2, ...$; $i,j \\in\\{1,2\\}$; $i\\neq j$; and $\\ell = \\ell_i+\\ell_j$.\nIt is clear that\n\\begin{align}\\label{eq12}\np_{C_i}(x_0,\\mu,s)ds &= \\begin{array}{l}\n\\text{ the probability that a particle born or scattered in}\\vspace{-10pt}\\\\\n\\text{ material $i$, at a horizontal distance $x_0$ of the next}\\vspace{-10pt}\\\\\n\\text{ intersection, with direction of flight $\\mu$, will experience}\\vspace{-10pt}\\\\\n\\text{ its \\textit{first collision} while traveling a distance between $s$}\\vspace{-10pt}\\\\\n\\text{  and $s+ds$}\n\\end{array}\n\\\\&= \\,\\,\\,p_{A_i}(x_0,\\mu,s)\\times p_{B_i}(x_0,\\mu,s)ds, \\nonumber\n\\end{align}\nand the \\textit{ensemble-averaged} path-length distribution function of particles born or scattered in material $i$ with direction of flight $\\mu$ is given by\n\\begin{align}\\label{eq13}\np_i(\\mu,s) &= \\frac{1}{\\ell_i}\\int_0^{\\ell_i} p_{C_i}(x_0,\\mu,s) dx_0.\n\\end{align}\nFinally, the ensemble-averaged path-length distribution function for particles born {\\em anywhere} in the 1-D random periodic system with direction of flight $\\mu$ is given by the weighted average\n\\begin{align}\\label{eq14}\np(\\mu,s) &= \\lambda_1 p_1(\\mu,s) + \\lambda_2p_2(\\mu,s),\n\\end{align}\nwhere $\\lambda_i$ is the probability that any given birth or scattering event takes place in material $i$.\nIt is easy to see that if $\\Sigma_{t1}=\\Sigma_{t2}$, \\cref{eq11} to \\labelcref{eq14} yield the exponential\n\\begin{align}\\label{eq15}\np(\\mu,s)=p(s)=\\Sigma_{t1}e^{-\\Sigma_{t1}s},\n\\end{align}\nas given in \\cref{eq1}. \n\n\\subsection{Solid-Void Medium}\n\\label{sec3A}\n\nThe numerical results included in this paper are for solid-void systems.\nWe define material 2 as the void, such that $\\lambda_2=\\Sigma_{t2}=Q_2=0$, $\\lambda_1=1$, and $p(\\mu,s) = p_1(\\mu,s)$.\nDepending on the lengths $\\ell_i$ of the material layers, \\cref{eq13} yields the following expressions for $p(\\mu,s)$:\n\\begin{subequations}\\label[pluraleq]{eq16}\n\\begin{itemize}\n\\item Case 1: $\\ell_1<\\ell_2$\n\\end{itemize}\n\\begin{align}\np(\\mu,s) = \\left\\{\n\\begin{array}{ll}\n\\frac{\\Sigma_{t1}}{\\ell_1}(n\\ell +\\ell_1-s|\\mu|)e^{-\\Sigma_{t1}(s-n\\ell_2/|\\mu|)}, & \\text{if } n\\ell\\leq s|\\mu| \\leq n\\ell+\\ell_1\\\\\n0, & \\text{if } n\\ell+\\ell_1 \\leq s|\\mu| \\leq n\\ell+\\ell_2\\\\\n\\frac{\\Sigma_{t1}}{\\ell_1}(s|\\mu|-n\\ell-\\ell_2)e^{-\\Sigma_{t1}[s-(n+1)\\ell_2/|\\mu|]}, & \\text{if } n\\ell+\\ell_2 \\leq s|\\mu| \\leq (n+1)\\ell\\\\\n\\end{array}\n\\right.\n\\end{align}\n\\begin{itemize}\n\\item Case 2: $\\ell_1=\\ell_2$\n\\end{itemize}\n\\begin{align}\np(\\mu,s) = \\left\\{\n\\begin{array}{ll}\n\\frac{\\Sigma_{t1}}{\\ell_1}(n\\ell +\\ell_1-s|\\mu|)e^{-\\Sigma_{t1}(s-n\\ell_2/|\\mu|)}, & \\text{if } n\\ell\\leq s|\\mu| \\leq n\\ell+\\ell_1\\\\\n\\frac{\\Sigma_{t1}}{\\ell_1}(s|\\mu|-n\\ell-\\ell_2)e^{-\\Sigma_{t1}[s-(n+1)\\ell_2/|\\mu|]}, & \\text{if } n\\ell+\\ell_2 \\leq s|\\mu| \\leq (n+1)\\ell\\\\\n\\end{array}\n\\right.\n\\end{align}\n\\begin{itemize}\n\\item Case 3: $\\ell_1>\\ell_2$\n\\end{itemize}\n\\begin{align}\np(\\mu,s) = \\left\\{\n\\begin{array}{ll}\n\\frac{\\Sigma_{t1}}{\\ell_1}(n\\ell +\\ell_1-s|\\mu|)e^{-\\Sigma_{t1}(s-n\\ell_2/|\\mu|)}, & \\\\\n\\hspace{6cm}\\text{if } n\\ell\\leq s|\\mu| \\leq n\\ell+\\ell_2 & \\\\\n\\frac{\\Sigma_{t1}}{\\ell_1}[(n\\ell +\\ell_2-s|\\mu|)(1-e^{\\Sigma_{t1}\\ell_2/|\\mu|}) +\\ell_1-\\ell_2]e^{-\\Sigma_{t1}(s-n\\ell_2/|\\mu|)}, & \\\\\n\\hspace{6cm}\\text{if } n\\ell+\\ell_2\\leq s|\\mu| \\leq n\\ell+\\ell_1 & \\\\\n\\frac{\\Sigma_{t1}}{\\ell_1}(s|\\mu|-n\\ell-\\ell_2)e^{-\\Sigma_{t1}[s-(n+1)\\ell_2/|\\mu|]}, & \\\\\n\\hspace{6cm}\\text{if } n\\ell+\\ell_1 \\leq s|\\mu| \\leq (n+1)\\ell & \n\\end{array}\n\\right.\n\\end{align}\n\\end{subequations}\nwhere $n=0, 1, 2, ...$ .\nThe first and second moments of $p(\\mu,s)$ in \\cref{eq16} are given by\n\\begin{subequations}\\label[pluraleq]{eq17}\n\\begin{align}\n\\overline{s} &= \\int_0^\\infty sp(\\mu,s)ds = \\frac{\\ell_1+\\ell_2}{\\Sigma_{t1}\\ell_1}\\, ,\\\\\n\\overline{s^2}(\\mu) &= \\int_0^\\infty s^2p(\\mu,s)ds = \\frac{2\\ell_1+4\\ell_2}{\\Sigma_{t1}^2\\ell_1}+\\frac{\\ell_2^2}{\\Sigma_{t1}\\ell_1|\\mu|}\\left(\\frac{e^{\\Sigma_{t1}\\ell_1/|\\mu|}+1}{e^{\\Sigma_{t1}\\ell_1/|\\mu|}-1}\\right)\\, .\n\\end{align}\n\\end{subequations}\nWe point out that the {\\em mean free path} $\\overline{s}$ does not depend on the direction $\\mu$ and it is equivalent to the inverse of the volume-averaged total cross section.\nOn the other hand, the {\\em mean square free path} $\\overline{s^2}$ is a function of $|\\mu|$.\n\n\\Cref{fig2} depicts examples of path-length distributions and nonclassical cross sections assuming $\\Sigma_{t1}=1$ and direction of flight $\\mu=\\pm 1$.\n\\Cref{fig2a,fig2c,fig2e} show a comparison between numerically obtained (through Monte Carlo) $p(s)$ and the analytical expressions given in \\cref{eq16}. \n\\Cref{fig2b,fig2d,fig2f} show the corresponding $\\Sigma_t(s)$ obtained with \\cref{eq7}. \n\\begin{figure}[p]\n    \\centering\n    \\begin{subsubcaption}\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2a.eps}\n        \\caption{Case 1: $\\ell_1=0.5$, $\\ell_2=1.0$}\n        \\label{fig2a}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2b.eps}\n        \\caption{Case 1: $\\ell_1=0.5$, $\\ell_2=1.0$}\n        \\label{fig2b}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2c.eps}\n        \\caption{Case 2: $\\ell_1=\\ell_2=1.0$}\n        \\label{fig2c}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2d.eps}\n        \\caption{Case 2: $\\ell_1=\\ell_2=1.0$}\n        \\label{fig2d}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2e.eps}\n        \\caption{Case 3: $\\ell_1=1.0$, $\\ell_2=0.5$}\n        \\label{fig2e}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig2f.eps}\n        \\caption{Case 3: $\\ell_1=1.0$, $\\ell_2=0.5$}\n        \\label{fig2f}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\caption{Path-length distribution functions and corresponding nonclassical cross sections (assuming $\\mu=\\pm 1$ and $\\Sigma_{t1}=1.0$) }\n    \\label{fig2}\n\\end{figure}\nThe ``saw-tooth\" behavior of $\\Sigma_t(s)$ is consistent with the physical process and can be easily understood.\nFor instance, in the case of $\\ell_1=\\ell_2=1$ (Case 2):\n\\begin{itemize}\n\\item[\\textbf{1.}] A particle is born or scatters in material 1. The path-length $s$ is set to 0, and $\\Sigma_t(0) = \\Sigma_{t1} = 1$\\vspace{-8pt}\n\\item[\\textbf{2.}] At $s=1$, the $x$-coordinate {\\em must be} in material 2. Thus, $\\Sigma_t(1) = \\Sigma_{t2} = 0$\\vspace{-8pt}\n\\item[\\textbf{3.}] At $s=2$, the $x$-coordinate {\\em must be} back in material 1. Thus, $\\Sigma_t(2) = \\Sigma_{t1} = 1$\\vspace{-8pt}\n\\end{itemize}\nThe exceptions would be particles born exactly at {\\em interface points}, which form a set of measure zero.\n\n\\section{Test Problems and Models}\\label{sec4}\n\nThe test problems simulated in this paper consider only {\\em rod geometry} transport (particles can only travel in the directions $\\mu = \\pm1$) taking place in a finite 1-D random periodic system with vacuum boundaries.\nThe classical transport equation is written as\n\\begin{subequations}\\label[pluraleq]{eq18}\n\\begin{align}\n&\\pm \\frac{\\partial \\Psi^{\\pm}}{\\partial x}(x) + \\Sigma_t(x)\\Psi^{\\pm}(x) \n= \\frac{\\Sigma_s(x)}{2}\\left[\\Psi^{+}(x)+\\Psi^{-}(x)\\right]+ \\frac{Q(x)}{2}\\,,\n\\,\\,\\,-X\\leq x\\leq X,\\\\\n&\\Psi^+(-X) = \\Psi^-(X) = 0\\,,\n\\end{align}\n\\end{subequations}\nwhere $\\Psi^{\\pm}(x) = \\Psi(x,\\mu=\\pm 1)$ and the stochastic parameters $\\Sigma_t(x)$, $\\Sigma_s(x)$, and $Q(x)$ are given by \\cref{eq8}.\n\nWe are interested in how accurately the nonclassical model predicts the ensemble-averaged scalar flux $\\bl\\Phi\\bg$ (over all physical realizations).\nTo this end, we compare the nonclassical results against ``benchmark\" results obtained by averaging the solutions of the transport equation over a large number of physical realizations of the random system.\nFinally, we compare the performance of the nonclassical model against the widely-known atomic mix model.\n\\begin{table}[htb]\n\\centering\n\\caption{Parameters of test problems}\n\\label{tab1} \n\\begin{tabular}{||c|c|c|c|c||c|c|c|c|c||} \\hline \\hline\n\\textbf{Set}  & $\\ell_1$ & $\\ell_2$ & $\\Sigma_{t1}$ &$q_1$ & \\textbf{Set}  & $\\ell_1$ & $\\ell_2$ & $\\Sigma_{t1}$ &$q_1$ \\\\ \\hline\\hline\n$\\seta_1$ & 0.5 & 1.0 & 1.0 & 1.0 & $\\setb_1$ & 20/3 & 40/3 & 1.5 & 1.5\\\\\n\\hline\n$\\seta_2$ & 1.0 & 1.0 & 1.0 & 1.0 & $\\setb_2$ & 10 & 10 & 1.0 & 1.0\\\\\n\\hline\n$\\seta_3$ & 1.0 & 0.5 & 1.0 & 1.0 & $\\setb_3$ & 40/3 & 20/3 & 0.75 & 0.75\\\\\n \\hline\\hline  \n  \\end{tabular}\n\\end{table}\n\nWe consider 2 sets of problems ({$\\seta$ and $\\setb$), each divided in 3 subsets according to the choices of the lengths $\\ell_i$ of the material layers.\nFor each subset we present results for 12 different choices of scattering ratios ranging from purely absorbing to diffusive; namely $c_1 \\in$ \\{0.0; 0.1; 0.2; 0.3; 0.4; 0.5; 0.6; 0.7; 0.8; 0.9; 0.95; 0.99\\}.\nWe assume vacuum boundaries at $x = \\pm 10$.\nMaterial 2 is defined as void, and the parameters of material 1 are given in \\cref{tab1}.\nThe source $Q_1(x)$ is defined as \n\\begin{align}\\label{eq19}\nQ_1(x) = \\left\\{\n\\begin{array}{cl}\nq_1, & \\text{if} -0.5\\leq x\\leq 0.5\\\\\n0, &\\text{otherwise}\\\\\n\\end{array}\n\\right .\\, ; \n\\end{align}\nthat is, particles are born {\\em near the center} of the random system.\nThe reason for this choice of source region can be visualized in \\cref{fig3}, in which the ``wavy\" pattern that arises from the periodic structure can be seen in \\cref{fig3a}.\nIf we allow $Q_1=1$ for $-X\\leq x\\leq X$, the solution is smoother, and the pattern is harder to identify (\\cref{fig3b}).    \n\\begin{figure}[hbt]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig3a.eps}\n        \\caption{Source $Q_1$ given by \\cref{eq19}}\n        \\label{fig3a}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig3b.eps}\n        \\caption{Source $Q_1=1$ for $-10\\leq x\\leq 10$}\n        \\label{fig3b}\n    \\end{subfigure}\n    \\caption{Ensemble-averaged scalar flux for problem set {$\\seta_2$} with $c_1=0.5$}\n    \\label{fig3}\n\\end{figure}\n\n\\subsection{The Benchmark Model}\n\nThe random quality of the 1-D system arises from its random placement in the $x$-axis.\nTo obtain a single physical realization one can simply choose a continuous segment of two full layers (one of each material) and randomly place the coordinate $x=0$ in this segment, which also defines the boundaries $\\pm X$.\n\nGiven this fixed realization of the system, the cross sections and source in \\cref{eq18} are now deterministic functions of space.\nWe use the diamond spatial differencing scheme with mesh interval $\\triangle x=2^{-7}$ to solve for the angular flux $\\Psi$, obtaining the scalar flux $\\Phi(x) = \\Psi^+(x)+\\Psi^-(x)$ (see \\cref{fig4}).\nThis procedure is repeated for different realizations of the random system.\nFinally, we calculate the ensemble-averaged {\\em benchmark} scalar flux $\\bl\\Phi_B\\bg(x)$ by averaging the resulting scalar fluxes over all physical realizations (as shown in \\cref{fig3a}). \n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[scale=1]{fig4.eps}\n  \\caption{Scalar flux in a fixed realization of problem set {$\\seta_2$} with $c_1=0.5$}\n  \\label{fig4}\n\\end{figure}\n\nClearly, the number of different realizations that can be computed is limited by the spatial discretization, with the maximum number of different realizations being $\\ell/\\triangle x$.\nFor all test problems in this paper, differences in the numerical results for $\\bl\\Phi_B\\bg(x)$ were negligible when increasing the number of mesh intervals and realizations.\nThus, we have concluded that these benchmark results are adequately accurate for the scope of this work.\n\n\\subsection{The Atomic Mix Model}\n\nThe {\\em atomic mix model} \\cite{pom91,dum00} consists of replacing in the classical transport equation the stochastic parameters (cross sections and source) by their volume-averages.\nThis model is known to be accurate in 1-D geometry when the material layers are optically thin.\nThe atomic mix equation in rod geometry for the test problems in this paper is given by\n\\begin{subequations}\\label[pluraleq]{eq20}\n\\begin{align}\\label{eq19a}\n&\\pm \\frac{\\partial \\bl\\Psi^{\\pm}\\bg}{\\partial x}(x) + \\bl\\Sigma_t\\bg\\bl\\Psi^{\\pm}\\bg(x) \n= \\frac{\\bl\\Sigma_s\\bg}{2}\\left[\\bl\\Psi^{+}\\bg(x)+\\bl\\Psi^{-}\\bg(x)\\right]+ \\frac{\\bl Q\\bg(x)}{2}\\,,\\\\\n& \\hspace{12cm} -X\\leq x\\leq X,\\nonumber\\\\\n&\\bl\\Psi^+\\bg(-X) = \\bl\\Psi^-\\bg(X) = 0\\,,\n\\end{align}\nwhere \n\\begin{align}\n\\bl\\Sigma_t\\bg &= P_1\\Sigma_{t1} + P_2\\Sigma_{t2} = \\frac{\\ell_1}{\\ell}\\Sigma_{t1},\\\\\n\\bl\\Sigma_s\\bg &= P_1c_1\\Sigma_{t1} + P_2c_2\\Sigma_{t2} = \\frac{\\ell_1}{\\ell}c_1\\Sigma_{t1},\\\\\n\\bl Q\\bg(x) &= P_1 Q_1(x) + P_2 Q_2(x) = \\frac{\\ell_1}{\\ell}Q_1(x). \\label{eq20e}\n\\end{align}\n\\end{subequations}\nWe solve \\cref{eq20} for the ensembled-averaged angular flux $\\bl\\Psi\\bg$ using a diamond spatial differencing scheme with mesh interval $\\triangle x=2^{-7}$.\nThe ensemble-averaged {\\em atomic mix} scalar flux is given by $\\bl\\Phi_{AM}\\bg(x) = \\bl\\Psi^+\\bg(x)+\\bl\\Psi^-\\bg(x)$.\nAn example is depicted in \\cref{fig5}.\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[scale=1]{fig5.eps}\n  \\caption{Atomic mix scalar flux for problem set {$\\seta_2$} with $c_1=0.5$}\n  \\label{fig5}\n\\end{figure}\n\n\\subsection{The Nonclassical Model}\n\nFor the rod geometry test problems included in this work, we rewrite the nonclassical \\cref{eq6} in an initial value form (cf.\\ \\cite{vaslar14a}) as\n\\begin{subequations}\\label[pluraleq]{eq21}\n\\begin{align}\n&\\frac{\\partial\\psi^{\\pm}}{\\partial s}(x,s) \\pm \\frac{\\partial \\psi^{\\pm}}{\\partial x}(x,s) + \\Sigma_t(s)\\psi^{\\pm}(x,s)  = 0,\\,\\,\\, -X\\leq x\\leq X,\\,\\, s>0 \\label{eq21a}\\\\\n& \\psi^{\\pm}(x,0)= \\frac{c}{2} \\int_0^\\infty \\Sigma_t(s')[\\psi^{+}(x,s')+\\psi^{-}(x,s')]ds' + \\frac{\\bl Q\\bg(x)}{2}, \\,\\,\\, -X\\leq x\\leq X,\\label{eq21b}\\\\\n& \\psi^+(-X,s) = \\psi^-(X,s) = 0\\,,\\,\\,\\, s\\geq 0\\,,\n\\end{align}\n\\end{subequations}\nwhere $\\psi^{\\pm}(x,s) = \\psi(x,\\mu=\\pm 1, s)$, $\\bl Q\\bg(x)$ is given by \\cref{eq20e}, and the nonclassical cross section $\\Sigma_t(s)=\\Sigma(\\mu=\\pm 1,s)$ is given by \\cref{eq7,eq16} (see \\cref{fig2}).\n\nFor the numerical solution of this system, we can interpret the path-length $s$ as a pseudo-time variable.\nWe then solve \\cref{eq21} using a finite volume method with explicit pseudo-time discretization according to \\cite{hll83}.\nSpecifically, we adapt the scheme introduced in \\cite{kry13} for moment models of the nonclassical transport equation.\n\nThis method is of first order in the pseudo-time variable $s$ and in the spatial variable $x$.\nWe choose a uniform grid $(x_m,s^n)$, where $x_{m+1} = x_{m} + \\Delta x$ for all $m\\in\\mathbb{Z}$, and $s^{n+1} = s^n + \\Delta s$ for all $n\\in\\mathbb{N}_0$.\nFurthermore, we define $\\psi_{m}^{n,\\pm}= \\psi^\\pm(x_{m},s^n)$, $Q_m = \\bl Q\\bg (x_m)$, and $\\Sigma_t^n=\\Sigma_t(s^n)$.\nThe fully discretized system reads\n\\begin{subequations}\\label[pluraleq]{eq22}\n\\begin{align}\n\t& \\frac{\\psi^{n+1,\\pm}_m-\\psi^{n,\\pm}_m}{\\Delta s} \\pm \\frac{\\psi^{n,\\pm}_{m+1}-\\psi_{m-1}^{n,\\pm}}{2\\Delta x} - \n\t\t\t\\frac{\\psi^{n,\\pm}_{m+1}-2\\psi_m^{n,\\pm}+\\psi_{m-1}^{n,\\pm}}{2\\Delta x}   + \\Sigma_t^n \\psi^{n,\\pm}_m = 0, \\label{eq22a}\\\\\n\t&  \\psi_m^{0,\\pm} = \\frac{c}{2}\\sum\\limits_{n=0}^\\infty \\omega_n \\Sigma_t^n\\left( \\psi_m^{n,+} + \\psi^{n,-}_m\\right)  +  \\frac{Q_m}{2},\\label{eq22b}\t\n\\end{align}\n\\end{subequations}\nfor some infinite quadrature rule given by the weights $\\omega_n$.\nThe second order central differences arise as a numerical diffusion term, which is typical for HLL finite volume schemes.\n\\begin{figure}[htb]\n  \\centering\n  \\includegraphics[scale=1]{fig6.eps}\n  \\caption{Nonclassical scalar flux for problem set $\\seta_2$ with $c_1=0.5$}\n  \\label{fig6}\n\\end{figure}\n\nIn our calculations we cut off the integration at $s_{\\text{max}}=4X=40$ and use the trapezoidal rule.\nWe use the same mesh interval $\\triangle x=2^{-7}$ as for the previous models, and a CFL number $0.5$ (that is, $\\triangle s = 2^{-8}$). \nBecause of the coupling of the initial value to the full solution in \\cref{eq21}, this system is solved in a source-iteration manner, where we iterate between \\cref{eq22a,eq22b}.\nFinally, the ensemble-averaged {\\em nonclassical} scalar flux is given by $\\bl\\Phi_{NC}\\bg(x) = \\int_0^{40}[\\psi^+(x,s)+\\psi^-(x,s)]ds$.\nAn example is depicted in \\cref{fig6}.\n\nIt was shown in \\cite{kry13} that the contraction rate for the source iteration is given by the scattering ratio $c$.\nThe maximum number of source iterations to converge the solution in problem set $\\seta$ was 417 (problem $\\seta_3$ with $c_1=0.99$); and in problem set $\\setb$ was 251 (problem $\\setb_3$ with $c_1=0.99$).\n\n\\section{Numerical Results}\\label{sec5}\n\nThe atomic mix model inherently approximates the path-length distribution function by the exponential $p(s) = \\bl\\Sigma_t\\bg e^{-\\bl\\Sigma_t\\bg s}$.\nThe nonclassical model uses the correct $p(\\mu,s)$ that was analytically obtained in \\cref{eq16}.\nIn this section we compare the accuracy of these two models in predicting the benchmark solutions obtained for the test problem sets $\\seta$ and $\\setb$. \n\nFor a better analysis of these results, we define the relative errors of the models with respect to the benchmark solutions as\n\\begin{subequations}\\label[pluraleq]{eq23}\n\\begin{align}\n Err_{AM}&= \\frac{\\bl\\Phi_{AM}\\bg(x)-\\bl\\Phi_B\\bg(x)}{\\bl\\Phi_B\\bg(x)}=\\text{Atomic Mix Relative Error},\\\\\n Err_{NC}&= \\frac{\\bl\\Phi_{NC}\\bg(x)-\\bl\\Phi_B\\bg(x)}{\\bl\\Phi_B\\bg(x)}=\\text{Nonclassical Relative Error}.\n\\end{align}\n\\end{subequations}\n\n\\subsection{Problem Set $\\seta$}\n\nThe lengths of the material 1 layers in this set are the same order as a mean free path; that is, $\\ell_1\\Sigma_{t1} = O(1)$.\nIt has been shown \\cite{larvas05} that, in the diffusive asymptotic limit, the diffusion coefficient of such problems is correctly estimated by the atomic mix model.\nFor the rod geometry problems in set $\\seta$, this diffusion coefficient is given by\n\\begin{align}\\label{eq24}\nD = \\frac{\\ell_1+\\ell_2}{\\Sigma_{t1}\\ell_1} = \\frac{1}{\\bl\\Sigma_t\\bg} =\n\\left\\{\n\\begin{array}{cl}\n3.0 & \\text{for set $\\seta_1$}\\\\\n2.0 & \\text{for set $\\seta_2$}\\\\\n1.5 & \\text{for set $\\seta_3$}\\\\\n\\end{array}\n\\right . \\, .\n\\end{align}  \nTherefore, we expect the atomic mix predictions of the ensemble-averaged scalar flux to {\\em improve} as the scattering ratio increases and the system becomes more diffusive.\n\nOn the other hand, the diffusion coefficient obtained by applying the same asymptotic analysis to the the nonclassical equation (see \\cref{appa}) is given by \n\\begin{align}\\label{eq25}\nD_{NC} = \\frac{1}{2}\\frac{\\overline{s^2}}{\\overline{s}} \\approx \n\\left\\{\n\\begin{array}{cl}\n3.0277 & \\text{for set $\\seta_1$}\\\\\n2.0410 & \\text{for set $\\seta_2$}\\\\\n1.5137 & \\text{for set $\\seta_3$}\\\\\n\\end{array}\n\\right . \\, ,\n\\end{align}  \nwhere $\\overline{s}$ and $\\overline{s^2}$ are defined in \\cref{eq17}.\nThe solution of the nonclassical transport equation has been shown to converge to the solution of the nonclassical diffusion equation in the diffusive asymptotic limit \\cite{ans16}.\nThus, we expect the nonclassical predictions of the ensemble-averaged scalar flux to {\\em deteriorate} as the system becomes diffusive, underestimating the correct solution.\n\n\\Cref{fig7} depicts the ensemble-averaged scalar fluxes obtained with each model for the purely absorbing case (\\cref{fig7a,fig7c,fig7e}) and for the diffusive case $c_1=0.99$ (\\cref{fig7b,fig7d,fig7f}).\nThe benchmark solutions present a sinuous shape due to the periodic structure of the random systems.\nThis pattern becomes less noticeable as the solid/void ratio increases, and as the system becomes more diffusive.\nIt is important to point out that the nonclassical model is able to capture this sinuous behavior, while the atomic mix model yields a smooth curve.\n\nIt is easier to analyze the accuracy of these models by examining the relative errors to the benchmark solution.\n\\Cref{figerrA1,figerrA2,figerrB1,figerrB2,figerrC1,figerrC2} show the (absolute) percentage error of the nonclassical and atomic mix predictions of the ensemble-averaged scalar flux with respect to the benchmark solutions.\nThe error plots confirm the theoretical predictions; atomic mix becomes more accurate as the system becomes more diffusive, while the accuracy of the nonclassical model decreases.\n\nThe nonclassical model clearly outperforms atomic mix for all the problems in $\\seta_1$ and for most of the problems in sets $\\seta_2$ and $\\seta_3$.\nThe exceptions take place for the cases $c_1=0.95$ and $c_1=0.99$, in which the accuracy of the atomic mix model overtakes that of the nonclassical.\n\\Cref{tab2,tab3,tab4} show that the nonclassical model tends to\nunderestimate the scalar flux, while atomic mix overestimates the solution.\nThe nonclassical model never reaches an error larger than 3.7\\% in estimating the solutions' peak (at $x=0$).\nOn the other hand, the atomic mix estimate exceeds 5\\% error in several problems, reaching a maximum of 8.24\\%.\n\nIt can also be seen from the results at the boundaries that the atomic mix model generates a solution with a large tail and it greatly overestimates the outgoing flux, in some problems by several orders of magnitude.\nThe nonclassical model, however, never reaches an error larger than 4.7\\%.\n\n\\subsection{Problem Set $\\setb$}\n\nFollowing the work presented in \\cref{sec3A}, \\cref{fig14} shows the path-length distributions and nonclassical cross sections of problem set $\\setb$.\nWe have chosen the parameters of this set such that:\n\\begin{itemize}\n\\item[i.] The optical thickness of each layer of material 1 is one order of magnitude larger than a mean free path: $\\ell_1\\Sigma_{t1} = 10$;\n\\vspace{-4pt}\n\\item[ii.] The volume-averaged parameters remain the same in all problems in the set: $\\bl \\Sigma_t \\bg = \\bl q_1 \\bg = 0.5$.\n\\end{itemize}\nThe large optical thickness implies that the problems in this set are {\\em not} the type of problems for which the atomic mix model is known to yield the correct aymptotic diffusive limit.\nBy fixing the volume-averaged parameters, the atomic mix model will yield exactly the same ensemble-averaged scalar flux for all problems in set $\\setb$ (which is the same as in $\\seta_2$).\nThe goal is to investigate whether the nonclassical model will outperform atomic mix for the diffusive cases.\n\n\\Cref{fig15} depicts the ensemble-averaged scalar fluxes obtained with each model for the purely absorbing case (\\cref{fig15a,fig15c,fig15e}) and for the diffusive case $c_1=0.99$ (\\cref{fig15b,fig15d,fig15f}).\nThe sinuous pattern of the benchmark solution is easier to notice in set $\\setb_3$, with the largest solid/void ratio.\nAs in the case in set $\\seta$, the nonclassical model is able to capture the sinuous behavior.\nThe atomic mix model generates the same smooth solution for each choice of $c_1$, unable to capture the differences in the scalar flux caused by the different choices of $\\ell_i$, $\\Sigma_{ti}$, and $q_i$.\n\n\\Cref{figerrD1,figerrD2,figerrE1,figerrE2,figerrF1,figerrF2} show the percentage error of the nonclassical and atomic mix predictions of the ensemble-averaged scalar flux with respect to the benchmark solutions {\\em in logarithmic scale}.\nThe changes in the accuracy of both models have a different pattern than in problem set $\\seta$.\nThe atomic mix solutions tend to grossly overestimate the ensemble-averaged scalar flux in most of the system, with errors at $x=0$ reaching 36\\% as seen in \\cref{tab5,tab6,tab7}.\nOnce $x$ approaches the boundaries, the atomic mix model systematically underestimates the solution, with errors in the outgoing flux exceeding 50\\% in most test problems and reaching over 80\\% in the least diffusive systems.\n\nOnce again, the nonclassical model underestimates the solution in diffusive systems.\nFor most problems the nonclassical error in estimating the ensemble-averaged scalar flux at $x=0$ is less than 4\\%.\nThe exceptions are the most diffusive problems, with scattering ratios $c_1 = 0.95$ and $c_1 = 0.99$.\nNevertheless, even in these diffusive cases the nonclassical model greatly outperforms the atomic mix approach.\n\n\\section{Conclusion}\\label{sec6}\n\nThis work presents an investigation of the accuracy of the nonclassical transport theory in estimating the ensemble-averaged scalar flux in 1-D random periodic media.\nThe analytical portion of the paper considers transport in a {\\em slab} consisting of alternating layers of any 2 materials.\nThe following simplifying assumptions are made for the numerical simulations: (i) the 1-D system is a periodic arrangement of {\\em solid and void} layers randomly placed in the $x$-axis; and (ii) particle transport takes place in {\\em rod geometry}.\nThis paper is an expanded version of a recent conference paper \\cite{mc15}, in which numerical solutions for the nonclassical transport equation were provided for the first time. \n\nA total of 72 test problems are analyzed.\nWe show that the nonclassical theory greatly outperforms the atomic mix model in estimating the ensemble-averaged scalar flux for most problems and that it qualitatively preserves the sinuous shape of the solution.\nThe few cases in which atomic mix is more accurate are part of a class of diffusive problems in which the atomic mix model is known to converge to the correct diffusive limit (diffusive problems in set $\\seta$).\nIn this small subset of problems the nonclassical model converges to a diffusion solution with an unphysically large diffusion coefficient, causing the nonclassical solution to underestimate the ensemble-averaged scalar flux.\nHowever, for diffusive problems that are {\\em not} in the atomic mix limit (set $\\setb$), the nonclassical model is clearly superior to the atomic mix approach.\n\nThis gain in accuracy comes at a cost: the path-length distribution function $p(s)$ (and its corresponding $\\Sigma_t(s)$) must be known in order to solve the nonclassical transport equation.\nDespite the extra work, it is our expectation that the gain in accuracy will prove the effort worthwhile in the important nuclear system where nonclassical transport takes place, such as in Pebble Bed and Boiling Water reactor cores.\n% In the revision we might want to emphasize this point more in the intro/abstract/here. \nIn particular, the nonclassical theory represents an alternative to current methods that might yield more accurate estimates of the eigenvalue and eigenfunction in a criticality calculation.\n\nFuture work includes (i) performing a thorough numerical investigation of the nonclassical theory in slab geometry to further validate our analytical results; (ii) comparing the gain in accuracy against other models and experimental data; and (iii) dropping the periodic assumption to investigate results in more realistic random media.\nWe point out that step (iii) cannot be performed with the analytical approach to obtain the path-lengths presented in this paper.\nIt requires either a numerical approach to estimate $p(\\mu,s)$, or a (much) more complex mathematical theory.\n\n\\section*{Acknowledgments}\n\nThis paper was prepared by Richard Vasques and Rachel Slaybaugh under award number NRC-HQ-84-14-G-0052 from the Nuclear Regulatory Commission.\nThe statements, findings, conclusions, and recommendations are those of the authors and do not necessarily reflect the view of the U.S. Nuclear Regulatory Commission.\n\n\\appendix\n\n\\begin{center}\n\\textbf{APPENDIX}\n\\end{center}\n\n\\section{1-D Asymptotic Analysis}\\label{appa}\n\nFollowing \\cite{vaslar14a},  we scale the parameters of \\cref{eq6} such that $\\Sigma_t = O(1)$, $ 1-c = O(\\varepsilon^2) $, $Q=O(\\varepsilon^2)$,  $\\partial \\psi / \\partial s = O(1)$, and $\\mu \\partial \\psi/\\partial x = O(\\eps)$, with $\\varepsilon \\ll 1$.\nIn this scaling, \\cref{eq6} becomes\n  \\begin{align}\n    &\\frac{\\partial \\psi}{\\partial s}  (x, \\mu,s) \n      + \\eps\\mu\\frac{\\partial\\psi}{\\partial x}(x, \\mu, s)\n       + \\Sigma_t(\\mu,s) \\psi( x, \\mu, s)   = \\label{eqap1}\\\\\n   & \\quad\\quad= \\frac{\\delta(s)}{2}\\int_{-1}^1\\int_0^{\\infty}[1-\\eps^2(1-c)]\\Sigma_t(\\mu',s') \n      \\psi(x, \\mu', s') \\, ds' d\\mu' + + \\varepsilon^2 \\delta(s)\\frac{Q(x)}{2}\\nonumber \\, .\n  \\end{align}\nLet us define $\\hat\\psi( x, \\mu, s)$ such that\n  \\begin{align}\\label{eqap2}\n   \\psi( x, \\mu, s) &\\equiv \n          \\hat\\psi(x, \\mu, s) \\frac{e^{-\\int_0^s \\Sigma_t(\\mu,s') ds'}}{\\overline{s}}\\,,\n  \\end{align}\nwhere $\\overline{s} = \\frac{1}{2}\\int_{-1}^1\\int_0^\\infty s p(\\mu,s)dsd\\mu$.\nThen, using \\cref{eq4}, \\cref{eqap2} becomes the following equation for $\\hat\\psi(x, \\mu, s)$:\n  \\begin{align}\\label{eqap3}\n    &\\frac{\\partial \\hat\\psi}{\\partial s} (x, \\mu,s) \n      + \\varepsilon \\mu\\frac{\\partial\\hat\\psi}{\\partial x}(x,\\mu, s)  = \\\\\n   & \\quad= \\frac{\\delta(s)}{2} \\int_{-1}^1 \\int_0^{\\infty} [1-\\eps^2(1-c)] p(\\mu',s')\n      \\hat\\psi(x, \\mu', s') \\, ds' d\\mu'       + \\varepsilon^2 \\delta(s) \\overline{s} \\frac{Q(x)}{2} \\,.\\nonumber\n  \\end{align}\nThis equation is mathematically equivalent to:\n   \\begin{subequations}\\label[pluraleq]{eqap4}\n   \\begin{align}\n      &\\frac{\\partial \\hat\\psi}{\\partial s} (x, \\mu,s) \n         + \\varepsilon \\mu\\frac{\\partial\\hat\\psi}{\\partial x}(x, \\mu, s) = 0 \\,, \\quad s > 0 \\,,\\label{eqap4a}\\\\\n       &\\hat\\psi(x, \\mu, 0)  =\\frac{1}{2}\\int_{-1}^1 [1-\\eps^2(1-c)] \\int_0^{\\infty} p(\\mu',s')\n\\hat\\psi(x, \\mu', s') ds' d\\mu' + \\varepsilon^2 \\overline{s} \\frac{Q(x)}{2} \\,,\n   \\end{align}\n   \\end{subequations}\nwhere $\\hat\\psi(x,\\mu,0) = \\hat\\psi(x,\\mu,0^+)$. Integrating \\cref{eqap4a} over $0 < s' < s$ we obtain:\n   \\begin{align}\n      \\hat\\psi( x, \\mu, s)  &= \\hat\\psi(x,\\mu, 0) - \\varepsilon \\mu\\frac{\\partial}{\\partial x} \\int_0^s \\hat\\psi(x, \\mu, s') \\, ds' \\\\\n      & = \\frac{1}{2}\\int_{-1}^1 [1-\\eps^2(1-c)] \\int_0^{\\infty} p(\\mu',s')\n\\hat\\psi(x, \\mu', s') ds' d\\mu' + \\nonumber\\\\\n         &\\hspace{3.5cm} + \\varepsilon^2 \\overline{s} \\frac{Q(x)}{2} - \\varepsilon \\mu\\frac{\\partial}{\\partial x} \\int_0^s \\hat\\psi(x, \\mu, s') \\, ds' \\,.\\nonumber\n   \\end{align}\nIntroducing into this equation the ansatz \n   \\begin{equation}\n \\hat\\psi(x, \\mu, s) =  \\sum_{n=0}^{\\infty} \\varepsilon^n\n       \\hat\\psi_n(x, \\mu, s) \n       \\end{equation}\nand equating the coefficients of different powers of $\\varepsilon$, we obtain for $n \\ge 0$:\n   \\begin{align}\\label{eqap7}\n\\hat\\psi_n(x,\\mu, s) &= \\frac{1}{2}\\int_{-1}^1 \\int_0^{\\infty} p(\\mu',s')\n\\hat\\psi_n(x, \\mu', s') ds' d\\mu'  - \\mu\\frac{\\partial}{\\partial x} \\int_0^s \\hat\\psi_{n-1}(x, \\mu, s') \\, ds' \\\\\n& \\quad\\quad -\\frac{1-c}{2}\\int_{-1}^1 \\int_0^{\\infty} p(\\mu',s')\n\\hat\\psi_{n-2}(x, \\mu', s') ds' d\\mu' + \\delta_{n,2} \\overline{s} \\frac{Q( x)}{2} \\,, \n   \\nonumber\n   \\end{align}\nwith $\\hat\\psi_{-1}=\\hat\\psi_{-2}=0$.\n\\Cref{eqap7} with $n=0$ has the general solution\n   \\begin{equation}\n      \\hat\\psi_0(x, \\mu, s) = \\frac{\\hat\\phi_0(x)}{2} \\,,\n   \\end{equation}\nwhere $\\hat\\phi_0(x)$ is undetermined at this point.\nFor $n=1$, \\cref{eqap7} has a particular solution of the form:\n    \\begin{equation}\n      \\hat\\psi^{part}_1(x, \\mu, s) = - \\frac{s\\mu}{2}\\frac{d \\hat\\phi_0}{d x}(x) \\,,\n   \\end{equation}   \nand its general solution is given by \n   \\begin{equation}\n      \\hat\\psi_1( x, \\mu, s) =  \\frac{1}{2}\\left[\\hat\\phi_1( x) - s\\mu\\frac{d \\hat\\phi_0}{d x}(x)\\right] \\,,\n  \\end{equation}  \nwhere $\\hat\\phi_1(x)$ is undetermined.\n\n \\Cref{eqap7} with $n=2$ has a solvability condition, which is obtained by operating on it by $\\int_{-1}^1\\int_0^{\\infty} p(\\mu,s) ( \\cdot ) ds d\\mu$; the solvability condition yields\n   \\begin{align}\\label{eqap11}\n    0 = \\frac{1}{2}\\int_{-1}^1\\int_0^{\\infty}p(\\mu,s)&\\left(\\frac{(s\\mu)^2}{2} \\frac{d^2\\hat\\phi_0}{dx^2}(x)\\right)ds d\\mu \\\\\n    & - \\frac{1-c}{2} \\int_{-1}^1\\int_0^{\\infty} p(\\mu,s) \\hat\\phi_0( x) \\, ds d\\mu + \\overline{s} Q( x)\\,.\\nonumber \n   \\end{align}\nThus, using the fact that $\\int_{0}^\\infty p(\\mu,s)ds =1$, we can rewrite \\cref{eqap11} as:\n\\begin{subequations}\\label{eqap12}\n\\begin{align}\n      -D_{NC}\\frac{d^2\\hat\\phi_0}{dx^2}(x) + \\frac{1-c}{\\overline{s} } \\hat\\phi_0(x) = Q(x)\\,,\\label{eqap12a}\n      \\end{align}\n      where $D_{NC}$ is the nonclassical diffusion coefficient given by\n      \\begin{align}\\label{eqap12b}\n      D_{NC} = \\frac{1}{4\\overline{s}}\\int_{-1}^1\\mu^2\\int_{0}^\\infty s^2p(\\mu,s) dsd\\mu \\, .\n   \\end{align}\n   \\end{subequations}\nTherefore, the solution $\\psi(x, \\mu, s)$ of \\cref{eqap3} satisfies\n   \\begin{equation}\\label{eqap13}\n      \\psi(x, \\mu, s) = \\frac{\\hat\\phi_0(x)}{2} \\frac{e^{- \\int_0^s \\Sigma_t(\\mu, s') ds'}} \n         {\\overline{s}} + O(\\varepsilon) \\,,\n   \\end{equation} \nwhere $\\hat\\phi_0(x)$ satisfies \\cref{eqap12}.\nThe classical angular flux can be obtained to leading order by integrating \\cref{eqap13} over $0 < s < \\infty$.\nFor transport in {\\em rod geometry}, \\cref{eqap12b} yields\n\\begin{align}\nD_{NC} = \\frac{1}{2}\\frac{\\overline{s^2}}{\\overline{s}},\n\\end{align} \nwhere $\\overline{s^2} = \\int_0^\\infty s^2 p(s)ds$.\n\n\\pagebreak\n\\begin{singlespace}\n\\bibliography{references}\n\\bibliographystyle{ans}\n\\end{singlespace}\n\n\\setcounter{subfigure}{0}\n\\begin{figure}[h]\n    \\centering\n    \\begin{subsubcaption}\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_tot_A00.eps}\n        \\caption{Problem set $\\seta_1$ with $c_1=00$}\n        \\label{fig7a}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_A99.eps}\n        \\caption{Problem set $\\seta_1$ with $c_1=0.99$}\n        \\label{fig7b}\n    \\end{subfigure}\n        \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\includegraphics[width=\\textwidth]{NSE_tot_B00.eps}\n        \\caption{Problem set $\\seta_2$ with $c_1=00$}\n        \\label{fig7c}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_B99.eps}\n        \\caption{Problem set $\\seta_2$ with $c_1=0.99$}\n        \\label{fig7d}\n    \\end{subfigure}\n        \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\includegraphics[width=\\textwidth]{NSE_tot_C00.eps}\n        \\caption{Problem set $\\seta_3$ with $c_1=00$}\n        \\label{fig7e}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_C99.eps}\n        \\caption{Problem set $\\seta_3$ with $c_1=0.99$}\n        \\label{fig7f}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n        \\caption{Ensemble-averaged scalar fluxes for problem set $\\seta$}\n    \\label{fig7}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrA00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrA10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrA20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrA30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrA40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrA50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_1$}\n    \\label{figerrA1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrA60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrA70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrA80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrA90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrA95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_A99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrA99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_1$}\n    \\label{figerrA2}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrB00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrB10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrB20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrB30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrB40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrB50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_2$}\n    \\label{figerrB1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrB60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrB70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrB80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrB90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrB95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_B99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrB99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_2$}\n    \\label{figerrB2}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrC00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrC10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrC20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrC30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrC40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrC50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_3$}\n    \\label{figerrC1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrC60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrC70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrC80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrC90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrC95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_C99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrC99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\seta_3$}\n    \\label{figerrC2}\n\\end{figure}\n\n\n\n\n\n\\setcounter{subfigure}{0}\n\\begin{figure}[p]\n    \\centering\n    \\begin{subsubcaption}\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14a.eps}\n        \\caption{Set $\\setb_1$: $\\ell_1=20/3$, $\\ell_2=40/3$}\n        \\label{fig14a}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14b.eps}\n        \\caption{Set $\\setb_1$: $\\Sigma_{t1} = 1.5$}\n        \\label{fig14b}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14c.eps}\n      \\caption{Set $\\setb_2$: $\\ell_1=10$, $\\ell_2=10$}\n        \\label{fig14c}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14d.eps}\n         \\caption{Set $\\setb_2$: $\\Sigma_{t1} = 1.0$}\n       \\label{fig14d}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14e.eps}\n       \\caption{Set $\\setb_3$: $\\ell_1=40/3$, $\\ell_2=20/3$}\n         \\label{fig14e}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{fig14f.eps}\n      \\caption{Set $\\setb_3$: $\\Sigma_{t1} = 0.75$}\n          \\label{fig14f}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\caption{Path-length distribution functions and corresponding nonclassical cross sections for problem set $\\setb$ }\n    \\label{fig14}\n\\end{figure}\n\n\n\n\n\\setcounter{subfigure}{0}\n\\begin{figure}[p]\n    \\centering\n    \\begin{subsubcaption}\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_tot_D00.eps}\n        \\caption{Problem set $\\setb_1$ with $c_1=00$}\n        \\label{fig15a}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_D99.eps}\n        \\caption{Problem set $\\setb_1$ with $c_1=0.99$}\n        \\label{fig15b}\n    \\end{subfigure}\n        \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\includegraphics[width=\\textwidth]{NSE_tot_E00.eps}\n        \\caption{Problem set $\\setb_2$ with $c_1=00$}\n        \\label{fig15c}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_E99.eps}\n        \\caption{Problem set $\\setb_2$ with $c_1=0.99$}\n        \\label{fig15d}\n    \\end{subfigure}\n        \\end{subsubcaption}\n    \\\\\n    \\begin{subsubcaption}\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\includegraphics[width=\\textwidth]{NSE_tot_F00.eps}\n        \\caption{Problem set $\\setb_3$ with $c_1=00$}\n        \\label{fig15e}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{nse_tot_F99.eps}\n        \\caption{Problem set $\\setb_3$ with $c_1=0.99$}\n        \\label{fig15f}\n    \\end{subfigure}\n    \\end{subsubcaption}\n    \\\\\n        \\caption{Ensemble-averaged scalar fluxes for problem set $\\setb$}\n    \\label{fig15}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrD00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrD10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrD20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrD30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrD40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrD50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_1$ (log scale)}\n    \\label{figerrD1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrD60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrD70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrD80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrD90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrD95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_D99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrD99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_1$ (log scale)}\n    \\label{figerrD2}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrE00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrE10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrE20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrE30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrE40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrE50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_2$ (log scale)}\n    \\label{figerrE1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrE60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrE70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrE80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrE90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrE95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_E99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrE99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_2$ (log scale)}\n    \\label{figerrE2}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_f00.eps}\n        \\caption{$c_1 = 0.0$}\n        \\label{figerrF00}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F10.eps}\n        \\caption{$c_1 = 0.1$}\n        \\label{figerrF10}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F20.eps}\n        \\caption{$c_1 = 0.2$}\n        \\label{figerrF20}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F30.eps}\n        \\caption{$c_1 = 0.3$}\n        \\label{figerrF30}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F40.eps}\n        \\caption{$c_1 = 0.4$}\n        \\label{figerrF40}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F50.eps}\n        \\caption{$c_1 = 0.5$}\n        \\label{figerrF50}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_3$ (log scale)}\n    \\label{figerrF1}\n\\end{figure}\n\n\n\n\n\n\\begin{figure}[p]\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F60.eps}\n        \\caption{$c_1 = 0.6$}\n        \\label{figerrF60}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F70.eps}\n        \\caption{$c_1 = 0.7$}\n        \\label{figerrF70}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F80.eps}\n        \\caption{$c_1 = 0.8$}\n        \\label{figerrF80}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F90.eps}\n        \\caption{$c_1 = 0.9$}\n        \\label{figerrF90}\n    \\end{subfigure}\n    \\\\\n    \\centering\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F95.eps}\n        \\caption{$c_1 = 0.95$}\n        \\label{figerrF95}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.495\\textwidth}\n        \\centering\n        \\includegraphics[width=\\textwidth]{NSE_err_F99.eps}\n        \\caption{$c_1 = 0.99$}\n        \\label{figerrF99}\n    \\end{subfigure}\n    \\caption{Atomic mix and nonclassical percentage errors with respect to the benchmark solutions for problem set $\\setb_3$ (log scale)}\n    \\label{figerrF2}\n\\end{figure}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\seta_1$}\n\\label{tab2} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n& 0.0 & 0.1420 & 0.1537 & 0.1421 & 0.0824 & 0.0006 \\\\\n\\cline{2-7}\n& 0.1 & 0.1509 & 0.1628 & 0.1509 & 0.0787 & 0.0002 \\\\\n\\cline{2-7}\n& 0.2 & 0.1614 & 0.1734 & 0.1613 & 0.0747 & -0.0001 \\\\\n\\cline{2-7}\n& 0.3 & 0.1740 & 0.1862 & 0.1738 & 0.0706 & -0.0006 \\\\\n\\cline{2-7}\n& 0.4 & 0.1895 & 0.2021 & 0.1893 & 0.0662 & -0.0012 \\\\\n\\cline{2-7}\n$x=0$ & 0.5 & 0.2094 & 0.2223 & 0.2091 & 0.0616 &  -0.0019 \\\\\n\\cline{2-7}\n& 0.6 & 0.2360 & 0.2493 & 0.2353 & 0.0567 & -0.0026 \\\\\n\\cline{2-7}\n& 0.7 & 0.2735 & 0.2876 & 0.2725 & 0.0515 & -0.0036 \\\\\n\\cline{2-7}\n& 0.8 & 0.3316 & 0.3469 & 0.3300 & 0.0462 & -0.0048 \\\\\n\\cline{2-7}\n& 0.9 & 0.4360 & 0.4541 & 0.4333 & 0.0413 & -0.0063 \\\\\n\\cline{2-7}\n& 0.95 & 0.5287 & 0.5496 & 0.5249 & 0.0397 & -0.0072 \\\\\n\\cline{2-7}\n& 0.99 & 0.6472 & 0.6728 & 0.6421 & 0.0395 & - 0.0079  \\\\\n\\hline\\hline\n& 0.0 & 0.0063 & 0.0071 & 0.0061 & 0.1294 & -0.0326 \\\\\n\\cline{2-7}\n& 0.1 & 0.0076 & 0.0085 & 0.0074 & 0.1128 & -0.0313 \\\\\n\\cline{2-7}\n& 0.2 & 0.0093 & 0.0103 & 0.0091 & 0.0972 & -0.0301 \\\\\n\\cline{2-7}\n& 0.3 & 0.0116 & 0.0126 & 0.0113 & 0.0826& -0.0289 \\\\\n\\cline{2-7}\n& 0.4 & 0.0148 & 0.0158 & 0.0143 & 0.0693 & -0.0278 \\\\\n\\cline{2-7}\n$x=10$ & 0.5 & 0.0191 & 0.0202 & 0.0186 & 0.0571 & -0.0267 \\\\\n\\cline{2-7}\n& 0.6 & 0.0255 & 0.0267 & 0.0248 & 0.0464 & -0.0256 \\\\\n\\cline{2-7}\n& 0.7 & 0.0354 & 0.0367 & 0.0345 & 0.0371 & -0.0244 \\\\\n\\cline{2-7}\n& 0.8 & 0.0520 & 0.0535 & 0.0508 & 0.0297 & -0.0231 \\\\\n\\cline{2-7}\n& 0.9 & 0.0841 & 0.0863 & 0.0823 & 0.0251 & -0.0216 \\\\\n\\cline{2-7}\n& 0.95 & 0.1141 & 0.1169 & 0.1117 & 0.0246 & -0.0206 \\\\\n\\cline{2-7}\n& 0.99 & 0.1533 & 0.1573 & 0.1503 & 0.0259 & -0.0196 \\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\seta_2$}\n\\label{tab3} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n&0.0 & 0.2049 & 0.2213 & 0.2048 & 0.0798 & -0.0006 \\\\\n\\cline{2-7}\n& 0.1 & 0.2181 & 0.2347 & 0.2179 & 0.0760 & -0.0009 \\\\\n\\cline{2-7}\n& 0.2 & 0.2337 & 0.2506 & 0.2334 & 0.0720 & -0.0013 \\\\\n\\cline{2-7}\n& 0.3 & 0.2527 & 0.2698 & 0.2522 & 0.0677 & -0.0019 \\\\\n\\cline{2-7}\n& 0.4 & 0.2762 & 0.2936 & 0.2755 & 0.0631 & -0.0026 \\\\\n\\cline{2-7}\n$x=0$ & 0.5 & 0.3065 & 0.3243 & 0.3054 & 0.0582 & -0.0035 \\\\\n\\cline{2-7}\n& 0.6 & 0.3475 & 0.3658 & 0.3458 & 0.0527 & -0.0049\\\\\n\\cline{2-7}\n& 0.7 & 0.4072 & 0.4263 & 0.4045 & 0.0467 & -0.0069 \\\\\n\\cline{2-7}\n& 0.8 & 0.5054 & 0.5255 & 0.5003 & 0.0398 & -0.0100\\\\\n\\cline{2-7}\n& 0.9 & 0.7067 & 0.7291 & 0.6950 & 0.0316 & -0.0165\\\\\n\\cline{2-7}\n& 0.95 & 0.9254 & 0.9502 & 0.9035 & 0.0267 & -0.0237 \\\\\n\\cline{2-7}\n& 0.99 & 1.2915 & 1.3204 & 1.2451 & 0.0223 & -0.0359 \\\\\n\\hline\\hline\n& 0.0 & 0.0017 & 0.0033 & 0.0018 & 0.9112 & 0.0057 \\\\\n\\cline{2-7}\n& 0.1 & 0.0023 & 0.0040 & 0.0023 & 0.7419 & 0.0058 \\\\\n\\cline{2-7}\n& 0.2 & 0.0031 & 0.0049 & 0.0031 & 0.5953 & 0.0063 \\\\\n\\cline{2-7}\n& 0.3 & 0.0043 & 0.0063 & 0.0043 & 0.4695 & 0.0070 \\\\\n\\cline{2-7}\n& 0.4 & 0.0060 & 0.0082 & 0.0060 & 0.3628 & 0.0075 \\\\\n\\cline{2-7}\n$x=10$ & 0.5 & 0.0087 & 0.0111 & 0.0088 & 0.2733 & 0.0077 \\\\\n\\cline{2-7}\n& 0.6 & 0.0132 & 0.0158 & 0.0133 & 0.1993 & 0.0072 \\\\\n\\cline{2-7}\n& 0.7 & 0.0211 & 0.0241 & 0.0212 & 0.1390 & 0.0055 \\\\\n\\cline{2-7}\n& 0.8 & 0.0371 & 0.0405 & 0.0372 & 0.0910 & 0.0016 \\\\\n\\cline{2-7}\n& 0.9 & 0.0769 & 0.0811 & 0.0764 & 0.0536 & -0.0070 \\\\\n\\cline{2-7}\n& 0.95 & 0.1257 & 0.1305 & 0.1236 & 0.0384 & -0.0162 \\\\\n\\cline{2-7}\n& 0.99 & 0.2126 & 0.2185 & 0.2061 & 0.0278 & -0.0305 \\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\seta_3$}\n\\label{tab4} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n& 0.0 & 0.2732 & 0.2835 & 0.2730 & 0.0376 & -0.0007 \\\\\n\\cline{2-7}\n& 0.1 & 0.2908 & 0.3012 & 0.2905 & 0.0359 & -0.0010 \\\\\n\\cline{2-7}\n& 0.2 & 0.3117 & 0.3223 & 0.3112 & 0.0341 & -0.0013  \\\\\n\\cline{2-7}\n& 0.3 & 0.3369 & 0.3477 & 0.3363 & 0.321 & -0.0018 \\\\\n\\cline{2-7}\n& 0.4 & 0.3683 & 0.3793 & 0.3674 & 0.0300 & -0.0023 \\\\\n\\cline{2-7}\n$x=0$ & 0.5 & 0.4087 & 0.4201 & 0.4075 & 0.0277 & -0.0031 \\\\\n\\cline{2-7}\n& 0.6 & 0.4637 & 0.4754 & 0.4618 & 0.0252 & -0.0041 \\\\\n\\cline{2-7}\n& 0.7 & 0.5442 & 0.5564 & 0.5412 & 0.0224 & -0.0056 \\\\\n\\cline{2-7}\n& 0.8 & 0.6788 & 0.6919 & 0.6733 & 0.0192 & -0.0081\\\\\n\\cline{2-7}\n& 0.9 & 0.9715 & 0.9868 & 0.9582 & 0.0157 & -0.0137 \\\\\n\\cline{2-7}\n& 0.95 & 1.3295 & 1.3481 & 1.3018 & 0.0140 & -0.0209 \\\\\n\\cline{2-7}\n& 0.99 & 2.0777 & 2.1055 & 2.0011 & 0.0134 & -0.0369 \\\\ \n\\hline\\hline\n& 0.0 & 0.0004 & 0.0026 & 0.0004 & 4.8188 &  -0.0070 \\\\\n\\cline{2-7}\n& 0.1 & 0.0006 & 0.0030 & 0.0006 & 3.6072 & -0.0073 \\\\\n\\cline{2-7}\n& 0.2 & 0.0009 & 0.0034 & 0.0009 & 2.6478 & -0.0073 \\\\\n\\cline{2-7}\n& 0.3 & 0.0014 & 0.0041 & 0.0014 & 1.8989 & -0.0071\\\\\n\\cline{2-7}\n& 0.4 & 0.0022 & 0.0052 & 0.0022 & 1.3238 & -0.0070 \\\\\n\\cline{2-7}\n$x=10$ & 0.5 & 0.0036 & 0.0068 & 0.0036 & 0.8906 & -0.0070 \\\\\n\\cline{2-7}\n& 0.6 & 0.0062 & 0.0097 & 0.0061 & 0.5718 & -0.0076 \\\\\n\\cline{2-7}\n& 0.7 & 0.0114 & 0.0153 & 0.0113 & 0.3438 & -0.0090 \\\\\n\\cline{2-7}\n& 0.8 & 0.0237 & 0.0282 & 0.0235 & 0.1868 & -0.0121 \\\\\n\\cline{2-7}\n& 0.9 & 0.0618 & 0.0670 & 0.0605 & 0.0847 & -0.0196 \\\\\n\\cline{2-7}\n& 0.95 & 0.1198 & 0.1259 & 0.1164 & 0.0502 & -0.0287 \\\\\n\\cline{2-7}\n& 0.99 & 0.2570 & 0.2647 & 0.2449 & 0.0302 & -0.0469 \\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\setb_1$}\n\\label{tab5} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n& 0.0 & 0.1776 & 0.2213 & 0.1768 & 0.2459 & -0.0045 \\\\\n\\cline{2-7}\n& 0.1 & 0.1896 & 0.2347 & 0.1892 & 0.2379 & -0.0018 \\\\\n\\cline{2-7}\n& 0.2 & 0.2037 & 0.2506 & 0.2039 & 0.2302 & 0.0009 \\\\\n\\cline{2-7}\n& 0.3 & 0.2206 & 0.2698 & 0.2214 & 0.2229 & 0.0036 \\\\\n\\cline{2-7}\n& 0.4 & 0.2414 & 0.2936 & 0.2329 & 0.2163 & 0.0063 \\\\\n\\cline{2-7}\n$x=0$ & 0.5 & 0.2678 & 0.3243 & 0.2700 & 0.2111 & 0.0085 \\\\\n\\cline{2-7}\n& 0.6 & 0.3027 & 0.3658 & 0.3056 & 0.2085 & 0.0098 \\\\\n\\cline{2-7}\n& 0.7 & 0.3520 & 0.4263 & 0.3550 & 0.2108 & 0.0084 \\\\\n\\cline{2-7}\n& 0.8 & 0.4294 & 0.5255 & 0.4293 & 0.2237 & -0.0002\\\\\n\\cline{2-7}\n& 0.9 & 0.5772 & 0.7291 & 0.5585 & 0.2630 & -0.0325 \\\\\n\\cline{2-7}\n& 0.95 & 0.7271 & 0.9502 & 0.6710 & 0.3067 & -0.0771\\\\\n\\cline{2-7}\n& 0.99 & 0.9650 & 1.3204 & 0.8160 & 0.3683 & -0.1545 \\\\\n\\hline\\hline\n& 0.0 & 0.0250 & 0.0033 & 0.0248 & -0.8667 & -0.0075 \\\\\n\\cline{2-7}\n& 0.1 & 0.0270 & 0.0040 & 0.0273 & -0.8515 & 0.0079 \\\\\n\\cline{2-7}\n& 0.2 & 0.0295 & 0.0049 & 0.0302 & -0.8324 & 0.0248 \\\\\n\\cline{2-7}\n& 0.3 & 0.0325 & 0.0063 & 0.0339 & -0.8078 & 0.0436 \\\\\n\\cline{2-7}\n& 0.4 & 0.0364 & 0.0082 & 0.0387 & -0.7756 & 0.0643 \\\\\n\\cline{2-7}\n$x=10$ & 0.5 & 0.0414 & 0.0111 & 0.0450 & -0.7325 & 0.0871 \\\\\n\\cline{2-7}\n& 0.6 & 0.0483 & 0.0158 & 0.0537 & -0.6734 & 0.1114 \\\\\n\\cline{2-7}\n& 0.7 & 0.0587 & 0.0241 & 0.0666 & -0.5899 & 0.1355 \\\\\n\\cline{2-7}\n& 0.8 & 0.0760 & 0.0405 & 0.0877 & -0.4677 & 0.1532 \\\\\n\\cline{2-7}\n& 0.9 & 0.1126 & 0.0811 & 0.1284 & -0.2799 & 0.1408 \\\\\n\\cline{2-7}\n& 0.95 & 0.1529 & 0.1305 & 0.1676 & -0.1463 & 0.0966 \\\\\n\\cline{2-7}\n& 0.99 & 0.2209 & 0.2185 & 0.2226 & -0.0106 & 0.0077\\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\setb_2$}\n\\label{tab6} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n  & 0.0 & 0.1975 & 0.2213 & 0.1972 & 0.1200 & -0.0018 \\\\\n  \\cline{2-7}\n  & 0.1 & 0.2100 & 0.2347 & 0.2101 & 0.1177 & 0.0004 \\\\\n  \\cline{2-7}\n  & 0.2 & 0.2245 & 0.2506 & 0.2252 & 0.1159 & 0.0028 \\\\\n  \\cline{2-7}\n  & 0.3 & 0.2420 & 0.2698 & 0.2433 & 0.1148 & 0.0054 \\\\\n  \\cline{2-7}\n  & 0.4 & 0.2634 & 0.2936 & 0.2655 & 0.1148 & 0.0080 \\\\\n  \\cline{2-7}\n  $x=0$ & 0.5 & 0.2904 & 0.3243 & 0.2934 & 0.1168 & 0.0105 \\\\\n  \\cline{2-7}\n  & 0.6 & 0.3261 & 0.3658 & 0.3301 & 0.1218 & 0.0125 \\\\\n  \\cline{2-7}\n  & 0.7 & 0.3763 & 0.4263 & 0.3812 & 0.1327 & 0.0129 \\\\\n  \\cline{2-7}\n  & 0.8 & 0.4548 & 0.5255 & 0.4588 & 0.1553 & 0.0088 \\\\\n  \\cline{2-7}\n  & 0.9 & 0.6042 & 0.7291 & 0.5972 & 0.2066 & -0.0116 \\\\\n  \\cline{2-7}\n  & 0.95 & 0.7553 & 0.9502 & 0.7233 & 0.2581 & -0.0423 \\\\\n\\cline{2-7}  \n  & 0.99 & 0.9946 & 1.3204 & 0.8961 & 0.3276 & -0.0990 \\\\\n\\hline\\hline\n& 0.0 & 0.0246 & 0.0033 & 0.0243 & -0.8646 & -0.0106 \\\\\n\\cline{2-7}  \n&0.1 & 0.0267 & 0.0040 & 0.0265 & -0.8494 & -0.0048 \\\\\n\\cline{2-7}  \n&0.2 & 0.0291 & 0.0049 & 0.0292 & -0.8302 & 0.0020 \\\\\n\\cline{2-7}\n& 0.3 & 0.0322 & 0.0063 & 0.0325 & -0.8055 & 0.0098 \\\\\n\\cline{2-7}\n& 0.4 & 0.0360 & 0.0082 & 0.0367 & -0.7733 & 0.0188 \\\\\n\\cline{2-7}\n$x=10$ & 0.5 & 0.0410 & 0.0111 & 0.0422 & -0.7302 & 0.0293 \\\\\n\\cline{2-7}\n& 0.6 & 0.0480 & 0.0158 & 0.0500 & -0.6711 & 0.0413 \\\\\n\\cline{2-7}\n& 0.7 & 0.0584 & 0.0241 & 0.0615 & -0.5877 & 0.0545 \\\\\n\\cline{2-7}\n& 0.8 & 0.0758 & 0.0405 & 0.0808 & -0.4658 & 0.0670 \\\\\n\\cline{2-7}\n& 0.9 & 0.1124 & 0.0811 & 0.1201 & -0.2786 & 0.0685 \\\\\n\\cline{2-7}\n& 0.95 & 0.1527 & 0.1305 & 0.1604 & -0.1455 & 0.0500 \\\\\n\\cline{2-7}\n& 0.99 & 0.2208 & 0.2185 & 0.2211 & -0.0105 & 0.0010 \\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\n\n\n\\begin{table}[p]\n\\centering\n\\caption{Ensemble-averaged scalar fluxes for problem set $\\setb_3$}\n\\label{tab7} \n\\begin{tabular}{||c|c||c|c|c||c|c||} \\hline \\hline\n  & $c$ & $\\bl\\phi_B\\bg$ & $\\bl\\phi_{AM}\\bg$ &$\\bl\\phi_{NC}\\bg$ & $Err_{AM}$ & $ Err_{NC}$\\\\ \\hline\\hline\n  & 0.0 & 0.2089 & 0.2213 & 0.2088 & 0.0593 & -0.0002 \\\\\n  \\cline{2-7}\n  & 0.1 & 0.2221 & 0.2347 & 0.2220 & 0.0566 & -0.0004 \\\\\n  \\cline{2-7}\n  &0.2 & 0.2378 & 0.2506 & 0.2375 & 0.0539 & -0.0009 \\\\\n  \\cline{2-7}\n  & 0.3 & 0.2566 & 0.2698 & 0.2562 & 0.0512 & -0.0017 \\\\\n  \\cline{2-7}\n  & 0.4 & 0.2800 & 0.2936 & 0.2791 & 0.0487 & -0.0031 \\\\\n  \\cline{2-7}\n  $x=0$ & 0.5 & 0.3098 & 0.3243 & 0.3082 & 0.0467 & -0.0053 \\\\\n  \\cline{2-7}\n  & 0.6 &0.3498 & 0.3658 & 0.3468 & 0.0457 & -0.0086 \\\\\n  \\cline{2-7}\n  & 0.7 & 0.4071 & 0.4263 & 0.4015 & 0.0471 & -0.0137 \\\\\n  \\cline{2-7}\n  & 0.8 & 0.4985 & 0.5255 & 0.4875 & 0.0542 & -0.0220 \\\\\n  \\cline{2-7}\n  & 0.9 & 0.6770 & 0.7291 & 0.6511 & 0.0769 & -0.0382 \\\\\n  \\cline{2-7}\n  & 0.95 & 0.8612 & 0.9502 & 0.8132 & 0.1033 & -0.0558 \\\\\n  \\cline{2-7}\n  & 0.99 & 1.1570 & 1.3204 & 1.0563 & 0.1412 & -0.0870 \\\\\n\\hline\\hline\n& 0.0 & 0.0073 & 0.0033 & 0.0073 & -0.5438 & 0.0027 \\\\\n \\cline{2-7}\n& 0.1 & 0.0086 & 0.0040 & 0.0086 & -0.5355 & -0.0034 \\\\\n \\cline{2-7}\n& 0.2 & 0.0104 & 0.0049 & 0.0103 & -0.5225 & -0.0085 \\\\\n \\cline{2-7}\n& 0.3 & 0.0126 & 0.0063 & 0.0124 & -0.5037 & -0.0121 \\\\\n \\cline{2-7}\n& 0.4 & 0.0156 & 0.0082 & 0.0154 & -0.4776 & -0.0139 \\\\\n \\cline{2-7}\n$x=10$ & 0.5 &0.0198 & 0.0111 & 0.0196 & -0.4422 & -0.0133 \\\\ \n \\cline{2-7}\n&0.6 & 0.0261 & 0.0158 & 0.0258 & -0.3947 & -0.0095 \\\\\n \\cline{2-7}\n& 0.7 & 0.0360 & 0.0241 & 0.0359 & -0.3313 & -0.0016 \\\\\n \\cline{2-7}\n& 0.8 & 0.0537 & 0.0405 & 0.0543 & -0.2463 & 0.0108 \\\\\n \\cline{2-7}\n& 0.9 & 0.0933 & 0.0811 & 0.0955 & -0.1314 & 0.0229 \\\\\n \\cline{2-7}\n& 0.95 & 0.1386 & 0.1305 & 0.1413 & -0.0586 & 0.0191 \\\\\n \\cline{2-7}\n& 0.99 & 0.2166 & 0.2185 & 0.2151 & 0.0089 & -0.0070\\\\\n\\hline\\hline\n  \\end{tabular}\n\\end{table}\n\n\n\\end{document}", "meta": {"hexsha": "cd23f2e9f8cd75c656a3f585a5238085ddd88756", "size": 83497, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "templates/journals/NSE-NucScEng/NSE-Example/NSE_example.tex", "max_stars_repo_name": "mitchnegus/GroupResources", "max_stars_repo_head_hexsha": "7a9126c6fc2d7b45684e251b782045684cc2d1f3", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2016-01-04T01:43:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-01T07:15:54.000Z", "max_issues_repo_path": "templates/journals/NSE-NucScEng/NSE-Example/NSE_example.tex", "max_issues_repo_name": "mitchnegus/GroupResources", "max_issues_repo_head_hexsha": "7a9126c6fc2d7b45684e251b782045684cc2d1f3", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2016-02-02T19:23:21.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-16T16:55:53.000Z", "max_forks_repo_path": "templates/journals/NSE-NucScEng/NSE-Example/NSE_example.tex", "max_forks_repo_name": "mitchnegus/GroupResources", "max_forks_repo_head_hexsha": "7a9126c6fc2d7b45684e251b782045684cc2d1f3", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-01-19T19:38:52.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-02T07:29:36.000Z", "avg_line_length": 41.6443890274, "max_line_length": 405, "alphanum_fraction": 0.6574008647, "num_tokens": 30724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40064045856174374}}
{"text": "\n\\documentclass[a4paper]{article}\n\n\\usepackage[utf8]{inputenc}\n\\usepackage{float}\n\\usepackage{hyperref}\n\\usepackage{listings}\n\\usepackage{amsmath}\n\n\\author{Pontus Persson}\n\\title{Lecture Notes\\\\TDDD08}\n\n\\begin{document}\n\\maketitle\n\\tableofcontents\n\n\\section{Introduction}\n\\label{sec:introduction}\n\\textbf{At exam:} One a4 paper of own notes.\\\\\nCore pillars of cource:\n\\marginpar[2016-08-29]{Lecture 1}\n\\begin{itemize}\n\\item Declarative Semantics\n\\item Operational Semantics\n\\item Programming Semantics\n\\item Grammars (definite closed grammars)\n\\item Negation in logic programming\n\\item Constrains logic programming\n\\end{itemize}\n\n\\subsection{Cource objectives}\n\\begin{itemize}\n\\item Logic as a programming language\n\\item Theoretical foundation of LP\n\\item prolog\n\\item Program/think \\textbf{declaratively}\n\\end{itemize}\n\n\\subsection{Declarative vs. Imperative languages}\nImperative languages descibe actions of a machine. Thinking in terms of a Von\nNeuman machine. Basic concept - variable, abstraction of a RAM cell.\n\n\\begin{align}\n x=x+1\\\\\n\\mbox{In mathematics: }x_{i+1} = x_i+1\n\\end{align}\n\\\\\nA declarativ program describes what should be computed, not necessary how.\n\\\\It describes the problem/solution - closer to human thinking. Variables are\nlike in mathematics.\n\\subsection{Logical Programming}\n\\begin{description}\n\\item[Program] a set of axioms\n\\item[Result] its logical consequences\n\\item[Computation] proof construction\n\\end{description}\nMain programming language - \\textit{prolog}.\\\\\n\nFind grandchild of $X$ using logical proramming notation.\n\\begin{align}\n  child(X,Y)  \\mbox{ //X is child of Y}\\\\\n  grandchild(X,Z) \\leftarrow child(X,Y) \\land child(Y,Z)\n\\end{align}\n\n\\subsection{Two levels of reading a program}\n\\begin{description}\n\\item[declarative] a set of axioms\n\\item[operational] a description of computations\n\\end{description}\n\\begin{align}\n ALGORITHM = LOGIC + CONTROL\n\\end{align}\nControl information\n\\begin{itemize}\n\\item The order of axioms and within axioms\n\\item some extra constructs\n\\end{itemize}\nThe two levels can be considered seperately. Program correctness is a property\nof the declarative level. But operational level affects performance.\n\\\\\nPrograms consists of rules and facts:\n\\begin{align}\n  p(...)\\leftarrow p_1(...),...,p_n(...)\n\\end{align}\nIn prolog $\\leftarrow$ is written as \\texttt{:-}.\\\\\n\n\\section{Main concepts of logic}\n\\begin{description}\n\\item[Constants] numbers, lower case strings\n\\item[Function symbols] cons/2, +/2, father/1\n\\item[Variables] Starts with upper case\n\\item[Logical connectives] $\\land, \\lor, \\rightarrow, \\lnot, \\leftrightarrow$\n\\item[Quantifiers] $\\forall, \\in$\n\\item[Auxillary symbols] $.,(,),...$\n\\end{description}\n\nGround term (formula) - containing no variables.\n\n\\end{document}\n", "meta": {"hexsha": "6c53bc479456d802f54cddfe97b2b3290874ef25", "size": 2751, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TDDD08/TDDD08-notes.tex", "max_stars_repo_name": "PontusPersson/lecture-notes", "max_stars_repo_head_hexsha": "565c426ba5c47bb9d94844ddf34017f358e2ae0c", "max_stars_repo_licenses": ["Beerware"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-17T18:50:02.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-17T18:50:02.000Z", "max_issues_repo_path": "TDDD08/TDDD08-notes.tex", "max_issues_repo_name": "PontusPersson/lecture-notes", "max_issues_repo_head_hexsha": "565c426ba5c47bb9d94844ddf34017f358e2ae0c", "max_issues_repo_licenses": ["Beerware"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TDDD08/TDDD08-notes.tex", "max_forks_repo_name": "PontusPersson/lecture-notes", "max_forks_repo_head_hexsha": "565c426ba5c47bb9d94844ddf34017f358e2ae0c", "max_forks_repo_licenses": ["Beerware"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.51, "max_line_length": 78, "alphanum_fraction": 0.7648127953, "num_tokens": 774, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.40064045856174374}}
{"text": "% ! Tex program = xelatex\n\\documentclass{article}\n% \\PassOptionsToPackage{quiet}{fontspec}% (or try silent)\n% 中文\n% \\usepackage[UTF8]{ctex}\n\n% For more choices\n% \\input{/Users/anye_zhenhaoyu/Desktop/preamble.tex}\n% \\input{/Users/anye_zhenhaoyu/Desktop/ln_preamble.tex}\n\n% \\input{/path/preamble.tex}\n% \\input{/path/ln_preamble.tex}\n\n% On my MAC's Desktop\n\\input{../preamble}\n\n\\graphicspath{{figures/}}\n\n\\begin{document}\n% \\tableofcontents\n\\title{\\vspace{-1cm}Homework 4}\n\\maketitle\n\\section{Doob's martingale inequality}\nFor any given $n$:\n\nConsider the stopping time $\\tau=\\argmin_{0\\le t\\le n}\\{X_t\\ge \\alpha\\}$ or $\\tau=n$ if  $X_t<\\alpha$ for all  $0\\le t\\le n$. Ostensively, $\\max_{0\\le t\\le n}X_t\\ge \\alpha\\iff (\\exists k) X_k\\ge \\alpha \\iff X_\\tau\\ge \\alpha$. Thus we have:\n\\[\n\t\\Pr[\\max_{0\\le t\\le n}X_t\\ge \\alpha]\n\t=\n\t\\Pr[X_\\tau\\ge \\alpha]\n\t\\le \n\t\\frac{\\mathbb{E}[X_\\tau]}{\\alpha}\n\\] where the inequality holds by Markov Ineq.\n\nBy defination, $\\tau\\le n$, which means $\\mathbb{E}[X_\\tau]=\\mathbb{E_0}$ by Optional Stopping Theorem.\nThen we obtain $\\Pr[\\max_{0\\le t\\le n}X_t\\ge \\alpha]\\le \\frac{\\mathbb{E}[X_0]}{\\alpha}$.\n\n\\section{Biased one-dimensional random walk}\n\\subsection*{Subproblem 1}\nBy defination,\n\\[\n\t\\begin{aligned}\n\t\t\\mathbb{E}\\qty[S_{t+1}|\\overline{Z_{i,n}}]\n\t\t&=\n\t\t\\mathbb{E}\\qty[S_t+Z_{t+1}+2p-1|\\overline{Z_{i,n}}]\n\t\t\\\\&=\n\t\tS_t+2p-1+(1-p)-p\n\t\t\\\\&=\n\t\tS_t\t\n\t\\end{aligned}\n.\\] \n\\subsection*{Subproblem 2}\nSimmilarly,\n\\[\n    \\begin{aligned}\n    \t\\mathbb{E}\\qty[P_{t+1}|\\overline{Z_{i,n}}]\n\t\t&=\n\t\t\\mathbb{E}\\qty[P_t\\qty(\\frac{p}{1-p})^{Z_{t+1}}|\\overline{Z_{i,n}}]\n\t\t\\\\&=\n\t\tP_t\\qty[p\\times\\frac{1-p}{p}+(1-p)\\times\\frac{p}{1-p}]\n\t\t\\\\&=\n\t\tP_t\n    \\end{aligned}\n.\\] \n\n\\subsection*{Subproblem 3}\nWe define $p_a=\\Pr[X_\\tau=a]$ and $p_b=\\Pr[X_\\tau=b]=1-p_a$.\n\nNow we want to show that $\\{S_i\\}$ and $\\{P_i\\}$ satisfy the conditions of OST theorem. Firstly we have \n\\[\n\t\\Pr(\\text{ending within the next $a+b$ steps})\\ge \\qty[\\max(p,1-p)]^{-a-b}\n\\] which means $\\Pr[\\tau<\\infty]=1$.\nDividing the time into consecutive periods in this manner, we have $\\mathbb{E}[\\tau]<\\infty$. Obviously, $\\abs{P_i}$ is bounded. Also we have:  $\\mathbb{E}[\\abs{S_{t+1}-S_t}\\+F_t]=p(2-2p)+(1-p)2p=4p(1-p)$.\n\nBy OST Thm., $\\mathbb{E}[S_\\tau]=\\mathbb{E}[S_1]$ and  $\\mathbb{E}[P_\\tau]=\\mathbb{E}[P_1]$. These propositions entail\n\\[\n\t(2p-1)\\mathbb{E}[\\tau]+bp_b-ap_a=0\n\t\\qand\n\t\\qty(\\frac{p}{1-p})^{b}p_b+\\qty(\\frac{p}{1-p})^{-a}p_a=1\n.\\] \nThus \n\\[\n    p_a=\n\t\\frac\n\t{1-\\qty[\\flatfrac{p}{(1-p)}]^b}\n\t{\\qty[\\flatfrac{(1-p)}{p}]^{a}-\\qty[\\flatfrac{p}{(1-p)}]^b}\n\t\\qand\n\tp_b=\n\t\\frac\n\t{\\qty[\\flatfrac{(1-p)}{p}]^{a}-1}\n\t{\\qty[\\flatfrac{(1-p)}{p}]^{a}-\\qty[\\flatfrac{p}{(1-p)}]^b}\n.\\] \nFinally,\n\\[\n\t\\mathbb{E}[\\tau]=\\frac{(a+b)(1-p)^bp^a-ap^{a+b}-b(1-p)^{a+b}}{(2p-1)\\qty[(1-p)^{a+b}-p^{a+b}]}\n.\\] \nRemark: $\\lim_{p\\to\\flatfrac{1}{2}}\\mathbb{E}[\\tau]=ab$.\n\n\\section{Longest common subsequence}\nTalk with Yilin Sun and Liyuan Mao.\n\\subsection*{Subproblem 1}\nWhen $n=2$,  \n\\[\n\t\\mathbb{E}[X]\n\t=\n\t\\frac{2\\times(2+1+1+0)+2\\times(1+2+1+1)}{16}\n\t=\n\t\\frac{9}{8}\\ge 2\\times\\frac{9}{16}\n.\\]\nSimilarly, if $n=3$, \n\\[\n\t\\mathbb{E}[X]=\\frac{29}{16}\\ge 3\\times\\frac{29}{48}\n.\\]\nSince we could divide every strings into continuous subsequences whose length is $2$ or $3$, \n\\[\n\tc_1=\\frac{9}{16}\n.\\]\nFor any given $n$:\n\\[\n\t\\Pr[X\\ge k]\n\t\\le \n\t\\frac{2^{2n-k}}{2^{2n}}{n \\choose k}^2\n\t\\approx\n\t{\\frac{n}{2\\pi k(n-k)}}\\qty[\\frac{n^n}{k^k(n-k)^{n-k}}]^2\\frac{1}{2^k}\n.\\]\nLet $k=cn$. We obtain\n\\[\n    \\Pr[X\\ge cn]\n\t\\le\n\t\\frac{1}{2\\pi nc(1-c)}\\qty[\\frac{1}{\\sqrt{2}^cc^c(1-c)^{1-c}}]^{2n}\n.\\] \nSet $c=0.99$:\n\\[\n    \\Pr[X\\ge 0.8n]\n\t\\le\n\t\\frac{51}{\\pi n}(0.76)^n\n\t\\text{ when } n\\to\\infty\n.\\] \nThus $c_2$ exists.\n\n\\subsection*{Subproblem 2}\n\nDenote function $f(x_1,\\cdots,x_n,y_1,\\cdots,y_n)$ as the LCS's length of the 2 sequences $\\*x$ and $\\*y$.\nObviously $f$ is 1-Lipschitz.\nBy McDiarmid's Inequality:\n\\[\n\t\\Pr(\\abs{X-\\mathbb{E}[X]}\\ge t)\\le 2e^{-\\flatfrac{2t^2}{n}}\n.\\] \n\n\\end{document}\n\n", "meta": {"hexsha": "292592d1ba4fad7531e81a7e5a09d31b110f159a", "size": 3949, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "HW4/HW4.tex", "max_stars_repo_name": "anyeZHY/AI2613-Homework", "max_stars_repo_head_hexsha": "aeec02e49b2968c86c4126a84b5ede0f27324189", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HW4/HW4.tex", "max_issues_repo_name": "anyeZHY/AI2613-Homework", "max_issues_repo_head_hexsha": "aeec02e49b2968c86c4126a84b5ede0f27324189", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HW4/HW4.tex", "max_forks_repo_name": "anyeZHY/AI2613-Homework", "max_forks_repo_head_hexsha": "aeec02e49b2968c86c4126a84b5ede0f27324189", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9802631579, "max_line_length": 239, "alphanum_fraction": 0.6087617118, "num_tokens": 1754, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.74316801430083, "lm_q1q2_score": 0.40055508985993216}}
{"text": "\\documentclass[11pt, a4paper]{article}\n\n\\usepackage{tikz}\n\\usetikzlibrary{shapes,arrows}\n\\usetikzlibrary{datavisualization}\n\\usetikzlibrary{datavisualization.formats.functions}\n\\usepackage{placeins}\n\\usepackage{amsmath}\n\\usepackage{booktabs}\n\n\\begin{document}\n\n\\title{ADABOOST}\n\\date{}\n\\maketitle\n\nBoosting is a powerful technique to combine several `weak' classifiers into a `strong' classifier. $AdaBoost$, short for `Adaptive Boosting' is one of the most frequently used boosting algorithms. \n\n\\section{Weak and Strong Learners}\n\nA weak learner is a classification algorithm which is only slightly better than random guessing. On the other hand, a strong learner is one which almost always provides the true classification.\nGiven training data of the form $(x_1, y_1),\\ (x_2, y_2),\\ ...\\ , (x_n, y_n)$ where $y_i \\in \\{+1, -1\\}\\ \\forall\\ x_i \\in \\mathbf{X}\\ [1]$  and a learner $h$ the error $\\epsilon$ is defined as, \n\n\\begin{align*}\n\t\\epsilon = \\frac{1}{N} \\times \\left\\{ \n\t\\begin{array}{ll}                     \n\t0\\ if\\ y_i = h(x_i)                   \\\\\n\t1\\ if\\ y_i \\neq h(x_i)                \\\\\n\t\\end{array}                           \n\t\\right.                               \n\\end{align*} \n\nThe error rate $\\epsilon$ is related to the strength of a learner as shown below:\n\n\\FloatBarrier\n\\begin{figure}[htbp]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\draw[thick] (-3,0) -- (3,0);\n\t\t\\foreach \\x in  {-3, 0 , 3}\n\t\t\\draw[shift={(\\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt);\n\t\t\n\t\t\\draw[shift={(-3,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below] {0}; \n\t\t\\draw[shift={(0,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below] {0.5}; \n\t\t\\draw[shift={(3,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below] {1}; \n\t\t\n\t\t\\node at (5, 0)   {Error rate ($\\epsilon$)};\n\t\t\\node at (0.45, 2)   (wl) {Weak Learner};\n\t\t\\node at (-2.55, -2)   (sl) {Strong Learner};\n\t\t\n\t\t\\draw[thick,->, >=stealth] (wl) -- (0.45, 0);\n\t\t\\draw[thick,->, >=stealth] (sl) -- (-2.55, 0);\n\t\\end{tikzpicture}\n\\end{figure}\n\n\\section{Algorithm}\n\nGiven training data of the form [1] in the preceding section and weak learners $h_1,\\ h_2,\\ ...\\ h_m$, the goal is to iteratively come up with a strong learner $H$. AdaBoost's algorithmic flowchart is as follows:\n\n\\tikzstyle{startstop} = [ellipse, inner sep = 0.1em, thick, text centered, draw=black]\n\\tikzstyle{process} = [rectangle, thick, text centered, draw=black]\n\\tikzstyle{decision} = [diamond, inner sep=0.1em, aspect = 2, thick, text centered, draw=black]\n\\tikzstyle{line} = [draw, thick, ->, >=stealth]\n\n\\FloatBarrier\n\\begin{figure}\n\t\\centering   \n\t\\begin{tikzpicture}\n\t\t\\node [startstop] (initWeights) {\\begin{tabular}{c}Initialize equal weights \\\\ for each datapoint \\\\ $w_i = \\frac{1}{N}$\\end{tabular}};\n\t\t\\node [process, below of=initWeights, node distance=8em] (calcError) {\\begin{tabular}{c} Calculate error \\\\\n\t\t\tfor each weak classifier $h_j$\\\\\n\t\t\t$\\epsilon_j = \\sum\\limits_{wrong} w_i$ \\\\\n\t\t\t    \n\t\t\t\\end{tabular}};\n\t\t\\node [process, below of=calcError, node distance = 8em] (pickClsfr) {\\begin{tabular}{c} Pick the best \\\\\n\t\t\tweak classifier $h_{best}$  \\\\\n\t\t\t$best = \\operatorname*{argmax}_{j}\\left\\{|\\frac{1}{2} - \\epsilon_j| \\right.$\n\t\t\t    \n\t\t\t\\end{tabular}} ;\n\t\t\\node [process, right of=pickClsfr, node distance = 15em] (calcAlpha) {\\begin{tabular}{c} Calculate $\\alpha$ \\\\\n\t\t\t$\\alpha=\\frac{1}{2}\\times\\ln(\\frac{1 - \\epsilon_{best}}{\\epsilon_{best}})$\n\t\t\t    \n\t\t\t\\end{tabular}} ;   \n\t\t\\node [decision, below of=pickClsfr, node distance = 13em] (stop) {\\begin{tabular}{c} \n\t\t\tIs $H$ good enough? \\\\\n\t\t\tExhausted number of rounds? \\\\\n\t\t\tNo good weak classifier left? \n\t\t\t        \n\t\t\t    \n\t\t\t\\end{tabular}} ;\n\t\t\n\t\t\\node [process, below of=stop, node distance = 15em] (updateWeights) {\\begin{tabular}{c} \n\t\t\tUpdate weights \\\\ \n\t\t\t$w_{new} = \\left\\{ \n\t\t\t\\begin{array}{ll}                                       \n\t\t\t\t\\frac{1}{2}\\times \\frac{1}{1-\\epsilon_{best}}\\times w_{old} \\\\\n\t\t\t\t\\text{if point is}                                          \\\\\n\t\t\t\t\\text{classified correctly}                                 \\\\\n\t\t\t\t                                                            \\\\\n\t\t\t\t\\frac{1}{2}\\times \\frac{1}{\\epsilon_{best}}\\times w_{old}   \\\\\n\t\t\t\t\\text {otherwise}                                           \\\\\n\t\t\t\\end{array}                                             \n\t\t\t\\right. $\n\t\t\t\\end{tabular}} ;  \n\t\t\n\t\t\\node [startstop, right of=updateWeights, node distance = 18em] (outputClsfr) {\\begin{tabular}{c} \n\t\t\tOutput the \\\\\n\t\t\tfinal classifier \\\\\n\t\t\t$H(x) = $ \\\\\n\t\t\t$sign(\\sum\\limits_{rounds}\\alpha\\times h_{best}(x))$\n\t\t\t\\end{tabular}} ;\n\t\t\n\t\t\\path [line] (initWeights) -- (calcError);\n\t\t\\path [line] (calcError) -- (pickClsfr);\n\t\t\\path [line] (pickClsfr) -- (stop);\n\t\t\\path [line] (pickClsfr) -- (calcAlpha);\n\t\t\\path [line] (stop) -- node [left] {No} (updateWeights);\n\t\t\\path [line] (updateWeights) --++ (-12em,0em) |- (calcError);\n\t\t\\path [line] (stop) -| node [below, near start] {Yes} (outputClsfr.north);\n\t\t  \n\t\\end{tikzpicture}\n\\end{figure}\n\n\\section{Example}\n\n\\begin{figure}[htbp]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\tikzstyle {point line} = [line width=0.15em]\n\t\t\t\t    \n\t\t\\draw[-latex] (0,0) -- (6.5,0) node[right]{x};\n\t\t\\draw[-latex] (0,0) -- (0,4.5) node[left]{y};\n\t\t\t\t\t\n\t\t\\draw[help lines] (0,0) grid (6.5,4.5);\n\t\t\t\t\t\n\t\t\\foreach \\x in {1, 3, 5}\n\t\t\\foreach \\y in {1, 3}\n\t\t{\n\t\t\t\\pgfmathsetmacro{\\l}{\\x - 0.3}\n\t\t\t\\pgfmathsetmacro{\\r}{\\x + 0.3}\n\t\t\t                    \n\t\t\t\\draw[point line] (\\l,\\y) -- (\\r,\\y);         \n\t\t}\n\t\t                \n\t\t\\foreach \\x in {1, 3, 5}\n\t\t{                    \n\t\t\t\\draw[point line] (\\x,3.3) -- (\\x, 2.7);         \n\t\t}\n\t\t                \n\t\t\\draw[point line] (1,1.3) -- (1, 0.7);     \n\t\t\t\t    \n\t\t\\draw (1, 3) node [below right] {\\textbf{A}};\n\t\t\\draw (3, 3) node [below right] {\\textbf{B}};\n\t\t\\draw (5, 3) node [below right] {\\textbf{C}};\n\t\t\\draw (1, 1) node [below right] {\\textbf{D}};\n\t\t\\draw (3, 1) node [below right] {\\textbf{E}};\n\t\t\\draw (5, 1) node [below right] {\\textbf{F}};\t\n\t\t\t\t    \n\t\t\\foreach \\x in {1, 2, 3, 4, 5, 6}\n\t\t{\n\t\t\t\\draw (\\x, 0) node [below] {$\\x$}\t    ;\n\t\t}\n\t\t\t\t    \n\t\t\\foreach \\y in {1, 2, 3, 4}\n\t\t{\n\t\t\t\\draw (0, \\y) node [left] {$\\y$}\t    ;\n\t\t}\n\t\t\t\t    \n\t\\end{tikzpicture}\n\t\n\\end{figure}\n\nFollowing weak classifiers are considered. Their error points are shown below: \n\n\\FloatBarrier\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Weak Classifier} & \\textbf{Error Points}  \\\\\n\t\t\\midrule\n\t\t$x >= 2$                 & \\textbf{A, D, E, F}    \\\\\n\t\t$x < 2$                  & \\textbf{B, C}          \\\\\n\t\t$x >= 4$                 & \\textbf{A, B, D, F}    \\\\\n\t\t$x < 4$                  & \\textbf{C, E}          \\\\\n\t\t$x >= 6$                 & \\textbf{A, B, C, D}    \\\\\n\t\t$x < 6$                  & \\textbf{E, F}          \\\\\n\t\t$y >= 2$                 & \\textbf{D}             \\\\\n\t\t$y < 2$                  & \\textbf{A, B, C, E, F} \\\\\n\t\t$y >= 4$                 & \\textbf{A, B, C, D}    \\\\\n\t\t$y < 4$                  & \\textbf{E, F}          \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\n\\newcommand*\\circled[1]{\\tikz[baseline=(char.base)]{\n\t\\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}\n\n\\subsection{Iteration 1}\nAt the start, each point has an equal weight of $1/6$ since there are 6 points. \n\n\\FloatBarrier\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Point} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{E} & \\textbf{F} \\\\\n\t\t\\midrule\n\t\t\\textbf{Error} & 1/6        & 1/6        & 1/6        & 1/6        & 1/6        & 1/6        \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n~\\\\\n\nThe error points and their corresponding weights determine the error rate of a particular weak classifier. The error rate for each classifier is shown below. \n\n\\FloatBarrier \\clearpage\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Weak Classifier} & \\textbf{Error Rate} \\\\\n\t\t\\midrule\n\t\t$x >= 2$                 & 2/3                 \\\\\n\t\t$x < 2$                  & 1/3                 \\\\\n\t\t$x >= 4$                 & 2/3                 \\\\\n\t\t$x < 4$                  & 1/3                 \\\\\n\t\t$x >= 6$                 & 2/3                 \\\\\n\t\t$x < 6$                  & 1/3                 \\\\\n\t\t$y >= 2$                 & \\circled{1/6}       \\\\\n\t\t$y < 2$                  & 5/6                 \\\\\n\t\t$y >= 4$                 & 2/3                 \\\\\n\t\t$y < 4$                  & 1/3                 \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\n$y >= 2$ is chosen as the best weak classifier since it has the minimum error rate. $\\alpha_1$ is calculated as follows: \n\\begin{align*}\n\t\\alpha_1 & = \\frac{1}{2} \\times ln(\\frac{1-1/6}{1/6}) \\\\\n\t         & = \\frac{1}{2} \\times ln(5)                 \n\\end{align*}\n\n\\subsection{Iteration 2}\nThe weights are now updated as per flow chart above, \n\n\\FloatBarrier\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Point} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{E} & \\textbf{F} \\\\\n\t\t\\midrule\n\t\t\\textbf{Error} & 1/10       & 1/10       & 1/10       & 1/2        & 1/10       & 1/10       \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\nAn interesting fact is that the sum of updated weights of the points misclassified by the chosen classifier $y >= 2$ (\\textbf{D}) is equal to 1/2 and so the sum of updated weights of the points correctly classified (\\textbf{A, B, C, E, F}) is also 1/2. \n\\begin{align*}\n\tError(\\textbf{D})                                      & = 1/2                              \\\\\n\t\\sum\\limits_{P \\in \\{\\textbf{A, B, C, E, F}\\}}Error(P) & = 1/10 + 1/10 + 1/10 + 1/10 + 1/10 \\\\\n\t                                                       & = 1/2                              \n\\end{align*}\n\nError rates are updated as follows: \n\n\\FloatBarrier\\clearpage \n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Weak Classifier} & \\textbf{Error Rate} \\\\\n\t\t\\midrule\n\t\t$x >= 2$                 & 4/5                 \\\\\n\t\t$x < 2$                  & \\circled{1/5}       \\\\\n\t\t$x >= 4$                 & 4/5                 \\\\\n\t\t$x < 4$                  & 1/5                 \\\\\n\t\t$x >= 6$                 & 4/5                 \\\\\n\t\t$x < 6$                  & 1/5                 \\\\\n\t\t$y >= 2$                 & 1/2                 \\\\\n\t\t$y < 2$                  & 1/2                 \\\\\n\t\t$y >= 4$                 & 4/5                 \\\\\n\t\t$y < 4$                  & 1/5                 \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\n$x < 2$ is chosen as the best weak classifier since it has the minimum error rate (for breaking tie, classifier occuring first in the above list is chosen).  \n$\\alpha_2$ is calculated as follows,\n\\begin{align*}\n\t\\alpha_2 & = \\frac{1}{2} \\times ln(\\frac{1-1/5}{1/5}) \\\\\n\t         & = \\frac{1}{2} \\times ln(4)                 \n\\end{align*}\n\n\\subsection{Iteration 3}\n\nWeights are again updated as follows:\n\n\\FloatBarrier\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|c|c|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Point} & \\textbf{A} & \\textbf{B} & \\textbf{C} & \\textbf{D} & \\textbf{E} & \\textbf{F} \\\\\n\t\t\\midrule\n\t\t\\textbf{Error} & 1/16       & 1/4        & 1/4        & 5/16       & 1/16       & 1/16       \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\nGiven that (\\textbf{B, C}) are misclassified by $x<2$ and points (\\textbf{A, D, E, F}) are correctly classified; notice again that,\n\n\\begin{align*}\n\t\\sum\\limits_{P \\in \\{\\textbf{B, C}\\}}Error(P)       & = 1/4 + 1/4                 \\\\\n\t                                                    & = 1/2                       \\\\\n\t\\sum\\limits_{P \\in \\{\\textbf{A, D, E, F}\\}}Error(P) & = 1/16 + 5/16 + 1/16 + 1/16 \\\\\n\t                                                    & = 1/2                       \n\\end{align*}\n\nUpdated error rates look like this,\n\n\\FloatBarrier\\clearpage \n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Weak Classifier} & \\textbf{Error Rate} \\\\\n\t\t\\midrule\n\t\t$x >= 2$                 & 1/2                 \\\\\n\t\t$x < 2$                  & 1/2                 \\\\\n\t\t$x >= 4$                 & 11/16               \\\\\n\t\t$x < 4$                  & 5/16                \\\\\n\t\t$x >= 6$                 & 7/8                 \\\\\n\t\t$x < 6$                  & \\circled{1/8}       \\\\\n\t\t$y >= 2$                 & 5/16                \\\\\n\t\t$y < 2$                  & 11/16               \\\\\n\t\t$y >= 4$                 & 7/8                 \\\\\n\t\t$y < 4$                  & 1/8                 \\\\\n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\n$x < 6$ is chosen as the best weak classifier since it has the minimum error rate. \n$\\alpha_3$ is calculated as follows,\n\\begin{align*}\n\t\\alpha_3 & = \\frac{1}{2} \\times ln(\\frac{1-1/8}{1/8}) \\\\\n\t         & = \\frac{1}{2} \\times ln(7)                 \n\\end{align*}\n\nAfter three iterations, the resultant strong classifier is \n\n\\begin{align*}\n\tH = & sign(\\frac{1}{2} \\times ln(5) \\times (y>=2) \\\\ \n\t    & + \\frac{1}{2} \\times ln(4) \\times (x<2)     \\\\ \n\t    & + \\frac{1}{2} \\times ln(7) \\times (x<6) )   \n\\end{align*}\n\nThe classification of $H$ for each point is as follows,\n\n\\FloatBarrier\n\\begin{table}[htbp]\n\t\\centering\n\t\\begin{tabular}{|c|c|c|}\n\t\t\\toprule\n\t\t\\textbf{Point}   & \\textbf{Calculation}                      & \\textbf{Classification} \\\\\n\t\t\\midrule\n\t\t\\rule{0pt}{1ex}A & $sign(1/2 \\times ln(5\\times 4 \\times 7))$ & $+$                     \\\\\n\t\t\\rule{0pt}{1ex}B & $sign(1/2 \\times ln((5 \\times 7) / 4))$   & $+$                     \\\\\n\t\t\\rule{0pt}{1ex}C & $sign(1/2 \\times ln((5 \\times 7) / 4))$   & $+$                     \\\\\n\t\t\\rule{0pt}{1ex}D & $sign(1/2 \\times ln((4 \\times 7) / 5))$   & $+$                     \\\\\n\t\t\\rule{0pt}{1ex}E & $sign(1/2 \\times ln(7 / (5 \\times 4)))$   & $-$                     \\\\\n\t\t\\rule{0pt}{1ex}F & $sign(1/2 \\times ln(7 / (5 \\times 4)))$   & $-$                     \\\\        \n\t\t\\hline\n\t\\end{tabular}\n\\end{table}\n\nIt is evident the $H$ classifies each point correctly after 3 iterations. Further iterations are hence terminated.\n\n\\section{Mathematics}\n\n\\subsection{Upper bound on training error}\n\\subsubsection{Step 1}\n\n\\begin{align*}\n\tError(H_T) = \\frac{1}{N} \\times \\sum\\limits_{i} \\left\\{ \n\t\\begin{array}{ll}                                       \n\t1 \\text{\\ if\\ } y_i \\neq H_T(x_i)                       \\\\\n\t0 \\text{\\ else}                                         \n\t\\end{array}                                             \n\t\\right.                                                 \n\\end{align*}\n\nLet $H_T(x_i) = sign(f_T(x_i))$ where $f_T(x_i) = \\sum\\limits_{t}\\alpha_t \\times h_t(x_i)$\n\n\\begin{align*}\n\tError(H_T) = \\frac{1}{N} \\times \\sum\\limits_{i} \\left\\{ \n\t\\begin{array}{ll}                                       \n\t1 \\text{\\ if\\ } y_i \\times f_T(x_i) <= 0                \\\\\n\t0 \\text{\\ else}                                         \n\t\\end{array}                                             \n\t\\right.                                                 \n\\end{align*}\n\n\\FloatBarrier\n\\begin{figure}[htbp]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\datavisualization [school book axes,\n\t\t\tvisualize as smooth line/.list={func},\n\t\t\tfunc={style={line width=0.15em}},\n\t\t\ty axis={label={y}},\n\t\tx axis={label={x = $y_i \\times f_T(x_i)$}} ]\n\t\t\t\t\t\n\t\tdata [set=func, format=function] {\n\t\t\tvar x : interval [-1:3] samples 100;\n\t\t\tfunc y = e^(-\\value{x});\n\t\t};\n\t\t\\draw [line width=0.15em] (-1.25, 1) -- (0, 1);\n\t\t\\draw [line width=0.15em, <-, >=stealth] (0, 0) -- (3, 0);\n\t\t    \n\t\t\\node at (-3, 1) {\\begin{tabular}{c}\n\t\t\t$y = 1\\ \\text{if}\\ x \\leq 0$ \\\\\n\t\t\t$0\\ \\text{else}$ \n\t\t\t\\end{tabular}}; \n\t\t\\node at (-1, 3) {$y=e^{-x})$}; \n\t\\end{tikzpicture}\n\\end{figure}\n\n\\begin{align}\n\tError(H_T) \\leq \\frac{1}{N} \\times \\sum\\limits_{i} e^{-y_i \\times f_T(x_i)} \n\\end{align}\n\n\\subsubsection{Step 2}\n\n\\begin{align*}\n\tw_{t+1}(i) = \\frac{1}{2} \\times w_t(i) \\left\\{      \n\t\\begin{array}{ll}                                   \n\t\\frac{1}{1-\\epsilon_{t}}\\ \\text{if}\\ y_i = h_t(x_i) \\\\\n\t\\frac{1}{\\epsilon_{t}}\\ \\ \\ \\ \\text{else}           \\\\\n\t\\end{array}                                         \n\t\\right.                                             \n\\end{align*}\n\n\\begin{align*}\n\tw_{t+1}(i) = \\frac{w_t(i)}{2\\times \\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t)}} \\left\\{ \n\t\\begin{array}{ll}                                                                      \n\t\\sqrt[]{\\frac{\\epsilon_t}{1-\\epsilon_t}}\\ \\text{if}\\ y_i = h_t(x_i)                    \\\\\n\t\\sqrt[]{\\frac{1-\\epsilon_t}{\\epsilon_t}}\\ \\text{else}                                  \\\\\n\t\\end{array}                                                                            \n\t\\right.                                                                                \n\\end{align*}\n\n\\begin{align*}\n\tw_{t+1}(i) = \\frac{w_t(i)}{2\\times \\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t)}} \\times e^{-\\alpha_t \\times y_i \\times h_t(x_i)} \n\\end{align*}\n\n\\begin{align*}\n\tw_{t+1}(i) = \\frac{1}{2\\times \\prod\\limits_t{\\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t}})} \\times e^{-y_i \\times f_t(x_i)} \\times \\frac{1}{N} \n\\end{align*}\n\nTransposing and replacing $t$ by $T$,\n\n\\begin{align*}\n\t\\frac{1}{N} \\times e^{-y_i \\times f_T(x_i)}  = 2 \\times w_{T+1}(i) \\times \\prod\\limits_t{\\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t}}) \n\\end{align*}\n\nSumming over i,\n\n\\begin{align*}\n\t\\sum\\limits_i \\frac{1}{N} \\times e^{-y_i \\times f_T(x_i)}  = 2 \\times \\prod\\limits_t{\\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t}}) \\times \\sum\\limits_i w_{T+1}(i) \n\\end{align*}\n\nSince sum of weights is one at every round,\n\n\\begin{align}\n\t\\frac{1}{N} \\times \\sum\\limits_i  e^{-y_i \\times f_T(x_i)}  = 2 \\times \\prod\\limits_t{\\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t}}) \n\\end{align}\n\n\\subsubsection{Step 3}\n\nUsing (1) and (2)\n\n\\begin{align*}\n\tError(H_T) \\leq 2 \\times \\prod\\limits_t{\\sqrt[]{\\epsilon_t \\times (1- \\epsilon_t}}) \n\\end{align*}\n\nUsing $\\gamma_t = (1/2 - \\epsilon_t)$\n\n\\begin{align*}\n\tError(H_T) \\leq 2 \\times \\prod\\limits_t{\\sqrt[]{1/4 - \\gamma_t^2}} \n\\end{align*}\n\n\\begin{align*}\n\tError(H_T) \\leq \\prod\\limits_t{\\sqrt[]{1 - 4\\gamma_t^2}} \n\\end{align*}\n\nSince $e^x \\geq (1+x)$ for all real values of $x$,\n\n\\begin{align*}\n\tError(H_T) \\leq \\prod\\limits_t{e^{-2\\gamma_t^2}} \n\\end{align*}\n\n\\begin{align*}\n\tError(H_T) \\leq e^{-2\\sum\\limits_t{\\gamma_t^2}} \n\\end{align*}\n\nSince $\\sum\\limits_t{\\gamma_t^2}$ monotonically increases with each iteration, $Error(H_t)$ monotonically decreases exponentially.\n\n\n\\end{document}", "meta": {"hexsha": "03f4546606bbbe8eed4b9ac9a0dad3bf624d3d13", "size": 18238, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "AdaBoost/AdaBoost.tex", "max_stars_repo_name": "singaurav/machine-learning-notes", "max_stars_repo_head_hexsha": "4fdd5b839156bcbf8f95a36275b8cd10f93e4c9d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-26T11:33:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-26T11:33:39.000Z", "max_issues_repo_path": "AdaBoost/AdaBoost.tex", "max_issues_repo_name": "singaurav/machine-learning-notes", "max_issues_repo_head_hexsha": "4fdd5b839156bcbf8f95a36275b8cd10f93e4c9d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AdaBoost/AdaBoost.tex", "max_forks_repo_name": "singaurav/machine-learning-notes", "max_forks_repo_head_hexsha": "4fdd5b839156bcbf8f95a36275b8cd10f93e4c9d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-22T18:56:20.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-22T18:56:20.000Z", "avg_line_length": 35.6908023483, "max_line_length": 253, "alphanum_fraction": 0.4956135541, "num_tokens": 6458, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5389832058771036, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.4005550727213334}}
{"text": "\\documentclass[compsoc,conference,a4paper,10pt,times]{IEEEtran}\n\\IEEEoverridecommandlockouts\n% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.\n\\usepackage{cite}\n\\usepackage{amsmath,amssymb,amsfonts}\n\\usepackage{algorithmic}\n\\usepackage{graphicx}\n\\usepackage{textcomp}\n\\usepackage{bmpsize}\n\\usepackage{xcolor}\n\\usepackage{lipsum}\n\\usepackage{minted}\n\\usepackage[colorlinks=true,urlcolor=black]{hyperref}\n\\def\\BibTeX{{\\rm B\\kern-.05em{\\sc i\\kern-.025em b}\\kern-.08em\n    T\\kern-.1667em\\lower.7ex\\hbox{E}\\kern-.125emX}}\n\\begin{document}\n\n\\title{Machine Checked Properties of the Schulze Method}\n\n\\author{\\IEEEauthorblockN{Mukesh Tiwari}\n\\IEEEauthorblockA{\\textit{ School of Computing and Information Systems} \\\\\n\\textit{University of Melbourne}\\\\\nMelbourne, Australia \\\\\nmukesh.tiwari@unimelb.edu.au}\n\\and\n\\IEEEauthorblockN{Dirk Pattinson}\n\\IEEEauthorblockA{\\textit{Research School of Computer Science} \\\\\n\\textit{Australian National University}\\\\\nCanberra, Australia\\\\\ndirk.pattinson@anu.edu.au}\n}\n\n\\maketitle\n\n\\begin{abstract}\nThe correctness of electronic vote-counting software is \ncrucial in establishing the trust in electronic voting. \nHowever, most vote-counting programs, used in \nvarious jurisdiction for legally binding election, establish\ncorrectness by means of testing which is not sufficient, and often\nfails to identify rare corner cases.\nWe argue that legally binding vote-counting software \nshould be formally verified and their correctness should be \nevaluated against some well established framework from social choice theory. \n\\footnote{DP: I don't see the relation to arrow's theorem here? \\textcolor{ blue}{MT: I was trying to give an example of one such possible\nframework to evaluate preferential voting schemes, but I have removed to avoid any potential confusion. }}\n\nIn this work, \nwe give machine checked formal proofs that our Coq implementation of the Schulze method,\na preferential voting method, \nfollows the Condorcet winner property. We leave the formal machine-checked proof of \nother properties, e.g., reversal symmetry, Pareto, monotonicity, etc., for future work.  \nThis is, to the best of our knowledge, the first machine-checked proof of \nproperties of the Schulze method implementation, and in fact, any preferential vote-counting \nimplementation. \n\n\n\\end{abstract}\n\n\\begin{IEEEkeywords}\nformal method, electronic voting, Schulze method, \nCondorcet winner, Coq theorem prover\n\\end{IEEEkeywords}\n\n \n\\section{Introduction}\n    The Schulze method \\cite{Schulze:2011:NMC}, a preferential\n    voting method, has gained popularity in recent years\n   when it comes to electing the candidates of many open source \n    software communities, Wikipedia, and the Pirate Parties in\n    various countries. At the time of writing, \n    is used by more  than  60 organizations  with  more  than  900,000  eligible  \n    members  in  total \\cite{schulze2020schulze}. One particular reason for this popularity is that it \n    enjoys many desirable properties that have been  formulated in\n    social choice theory.\n    Many of these are already established in the Schulze's original paper \\cite{Schulze:2011:NMC}, e.g., Condorcet winner, Pareto, reversal symmetry, monotonicty, \n    etc. Moreover, it fails on independence of \n    irrelevant alternatives (IIA) criterion, a consequence of the impossibility theorem \\cite{arrow1950difficulty} which states that no preferential voting \n    method can have all the properties. \n\n    In this work, we establish that our implementation of Schulze method \\cite{Pattinson:2017:SVE}\n    conforms to the Condorcet winning criterion. It is ongoing work and in  \n    future, we would like to establish that our implementation follows all the other properties, \n    e.g. reversal symmetry, Pareto, monotonicity, etc. \n    More importantly, it would be interesting to establish that our implementation \n    fails on IIA criterion. The \n    source code for this ongoing work can be accessed from the GitHub \n    repo\\footnote{\\url{https://github.com/mukeshtiwari/Schulzeproperties/blob/master/Schulzeprop.v}}\n    \n    \\section{The Schulze Method}\n    In this section, we give a brief overview of the Schulze method and \n    necessary formalisation details to make it self-contained. We invite the \n    curious reader to read our paper \\cite{Pattinson:2017:SVE} for more details. \n    \n    \n    The  method itself rests on the relative margins between two\n    candidates, i.e. the number of voters that prefer one candidate\n    over another. The margin induces an ordering between candidates,\n    where a candidate $c$ is more preferred than $d$ if more voters\n    prefer $c$ over $d$ than vice versa. One can construct simple\n    examples (see e.g. \\cite{Rivest:2010:OSW}) where this order does\n    not have a maximal element (a so-called Condorcet Winner).\n    Schulze’s observation is that this ordering can be made\n    transitive by considering sequences of candidates (called\n    paths).  Given candidates $c$ and $d$, a path between $c$ and\n    $d$ is a\n    sequence of candidates $p= (c,c_{1}, \\dots ,c_{n},d)$ that joins\n    $c$ and $d$, and the \\emph{strength} of a path is the minimal margin\n    between adjacent nodes. This induces the generalised margin\n    between candidates $c$ and $d$ as the strength of the strongest path\n    that joins $c$ and $d$.  A candidate $c$ then wins a Schulze count if\n    the generalised margin between $c$ \n    and any other candidate $d$ is at least as large as the\n    generalised margin between $d$ and $c$. It is known that every\n    election has a winner, but the winner may not be uniquely\n    determined (e.g. in the case where no votes have been cast at\n    all).\n    In more detail:\n\n\\begin{enumerate}  \n\n\\item Consider an election with a set of $t$ candidates\n    $C$ = $\\{c_1,\\dots,c_t\\}$ and \n\ta set of $n$ votes $P$ = $\\{b_1,\\dots,b_n\\}$. A vote\n\tis a function $b: C \\rightarrow \\mathbb{N}$ that \n\tassigns a natural \n\tnumber (the preference) to each candidate.  Note that two\n  candidates may receive the same preference. \n\tWe recover a strict total \n\tpreorder $<_b$ on the candidates by setting $c <_b d$ if $b(c) > b(d)$, i.e. \n\tcandidate $c$ is less preferred over candidate $d$ if the natural number $b(c)$ is greater\n\tthan the natural number $b(d)$. \n\t\n\\item We construct a margin matrix $\\mathrm{marg} : C \\times C \\to \\mathbb{Z}$ as follows: \n    given two candidates $c, d \\in C$, the \\emph{margin} of $c$ over $d$ is\n    the number of voters that prefer $c$ over $d$ minus the number of voters\n    that prefer $d$ over $c$. In symbols:\n\\[\n  \\mathit{marg} (c, d) = \\sharp \\lbrace b \\in P \\mid c >_b d \\rbrace -\n            \\sharp \\lbrace b \\in P \\mid d >_b c \\rbrace\n\\] where $\\sharp$ denotes cardinality.\n\n\n\\item A directed \\emph{path} from\ncandidate $c$ to candidate $d$ is a sequence $p \\equiv c_0, \\dots, c_{w+1}$\nof candidates with $c_0 = c$ and $c_{w+1} = d$ ($w \\geq 0$), and the\n\\emph{strength}, $\\mathrm{st}$, of path $p$ is the minimum margin of adjacent\nnodes, i.e.\n\\[ \\mathrm{st}(c_0, \\dots, c_{w+1}) = \\min \\lbrace \\mathrm{marg} (c_i, c_{i+1}) \\mid 0 \n\\leq i \\leq w \\rbrace. \\]\n\\item  A generalised margin matrix, $M$, denote the strength of the strongest path\n\tbetween two candidates, i.e. \n\t\\[ M(c, d) = \\max \\lbrace \\mathrm{st} (p) : p \\text{ is path from } c \\text{ to } d\\rbrace \\]\n\t\n\\item The winning set  is defined as \n \\[ W =  \\lbrace c \\in C : \\forall d \\in C \\setminus \\{c\\}, M (c, d) \\geq M (d, c) \\rbrace\\]\n\n\\end{enumerate}\n\n\nOur Coq formalisation models the set of candidates as a type.\nMoreover, it postulates that the type of candidates \nis finite and non-empty with decidable equality. For our purpose, \nthe easiest way of stipulating that a type be finite is to require existence of a \nlist containing all inhabitants of this type \\cite{10.1145/2808098.2808102}.\n\n \\begin{minted}{coq}\nParameter cand : Type.\nParameter cand_all : list cand.\nHypothesis cand_fin : \n forall c: cand, In c cand_all.\nHypothesis cand_not_nil : \n cand_all <> nil.\nHypothesis dec_cand : \n forall n m : cand, {n = m} + {n <> m}.\n\n\n\\end{minted}\n\nOne easy way to achieve all of the above is to implement\n\\texttt{cand} as an indictive type with one nullary constructor for\neach candidate.\n\nWe define a boolean function (step 5) that determines \n(the Schulze) election winners based on \nthe generalised margin matrix (step 4). ($M \\text{ } \\mathrm{marg} \\text{ } \n(\\mathrm{length} \\text{ } \\mathrm{cand\\_all}) \\text{ } c \\text{ } d$ \nin the $\\mathrm{schulze\\_winner}$ definition is Coq encoding of the generalised margin matrix, \n$M \\text{ } (c, \\text{ }d)$, defined in step 4. The syntactic differences between these two \nnotations do not matter for this discussion.)\n\\footnote{DP: which syntactic differences? \\textcolor{ blue}{MT: I am talking about $M \\text{ } \\mathrm{marg} \\text{ } \n(\\mathrm{length} \\text{ } \\mathrm{cand\\_all}) \\text{ } c \\text{ } d$  and  $M \\text{ } (c, \\text{ }d)$}}\n\\footnote{DP: why a boolean function and not a proposition? \\textcolor{blue}{MT: Nothing specific about the boolean function but I preferred it\nbecause it defines the Schulze winner in terms of generalised margin matrix, which is already explained above (step 4).  Therefore, the reader can \nclearly establish the Coq definition and the explanation we gave in step 4, which may or may not be the case in Prop definition.}}\n \\begin{minted}{coq}\nDefinition schulze_winner \n  (marg : cand * cand -> Z) \n  (c : cand) := forallb (fun d => \n  (M marg (length cand_all) d c) <=? \n  (M marg (length cand_all) c d))\n  cand_all.\n\\end{minted}\n\n\n\\section{Properties of Schulze Method}\n\t We have a boolean function,  \\textit{schulze\\_winner},  that \n\t elects the winner,  the key question is that how do we know that \n\t this winner is indeed the real winner,  intended by the voters, and \n\t not because of the software bug in the implemetation.  In our \n\t original paper, we have given two definitions of \n\t winners, one in Prop (logical) and one in Type (computational) and \n\t proved that both implemetations are equivalent. \n   \\footnote{DP: How do they relate to the boolean function above? \\textcolor{ blue}{MT:  It seems that this section is edited but previously in this section, \n   I had explained the rationale for Prop level and Type level.  Moreover,  there was a paragraph explaining the connection between boolean function, schulze\\_winner, and \n   type-level function,  wins\\_type. }}\n   \\footnote{DP: the typle level definition can't be understood\n   without context, e.g. what does co-closed mean?  \\textcolor{blue}{MT: I have written a very abstract explanation of coclosed, but we want to expand on it, then it would be better to explain the whole thing and I should retract the claim \n   about inviting the reader to read our paper from ITP.}}\n\t  \n\\begin{minted}{coq}\nDefinition wins_prop (c: cand) : Prop := \n forall d: cand, exists k: Z,\n  Path k c d /\\ \n (forall l, Path l d c -> l <= k)\n\t \nDefinition wins_type c : Type :=\n forall d : cand, existsT (k : Z),\n ((PathT k c d) *\n  (existsT (f : (cand * cand) -> bool), \n  f (d, c) = true /\\ coclosed (k + 1) f))\n\\end{minted}\n\n\\noindent\nThe definition of \\textit{coclosed} asserts that\npaths from every candidate to the winner \nis not stronger than the vice versa, i.e.\nif a candidate $c$ is the winner and the strength \nof the strongest path from $c$ to a candidate,  say, $d$ is $k$, \nthen all the paths from $d$ to $c$ will less than or equal to $k$.\n\n\n\n  \n\\begin{minted}{coq}  \nLemma wins_prop_type : forall c, \n wins_prop c -> wins_type c.\nProof.  ... Qed. \n\nLemma wins_type_prop : forall c, \n wins_type c -> wins_prop c.  \nProof.  ... Qed. \t \n\\end{minted}\n\nThe reason for two (rather than one) definitions of winning is that\nthe propositional formulation is easier to inspect for correctness.\nThen again, the type level definition carries more information that\ncan be extracted, whereas the type-level definition carries\nenough information that can be individually verified to corroborate\nthe correctness of the run of the algorithm, given the initial\ndatas\\footnote{\\textcolor{ blue}{MT: It is very condensed version of what I wrote previously, but  I did not understand, \"given the initial datas\". What is initial datas?}.}.   \nof\\footnote{\\textcolor{ blue}{MT: It does not make any sense from here and possibly can go away because you have already given the \n rationale for having two definitions, one in Prop and one in Type, above, though very condensed.}} our formalisation was two fold: i) extracting an OCaml \ncode from it and using the OCaml code \nto count the ballots from real world elections and ii)\nmaking it accessible to everyone.  \n\\footnote{DP: What do you mean by this? \\textcolor{ blue}{MT:  You have edited this section and the point, I am trying to convey by saying that \n our goal is make the formalisation accessible for everyone,  is  that the reader, having some basic understanding of logic, \n has to inspect our definitions in the Prop and convince herself that it indeed captures the notion of winner (or loser).  } }\nTo achieve the \nfirst goal, we use an elaborate  definition of winning at the type\nlevel,\nand for the second goal, we have a (simple) definition in Prop. \nAll the reader has to do is inspect the simple logical defintion \n\\textit{wins\\_prop} to ensure that it correctly captures the notion \nof winner,  without understanding the more complex \ndefinition of \\textit{wins\\_type}.  The proof that these two definitions \nare equivalent is established in Coq, so the reader \nhas to do is replay the proofs of  \\textit{wins\\_prop\\_type} and \n\\textit{wins\\_type\\_prop}.  Coq's extraction mechanism erases all the (logical) terms in sort Prop while \nkeeps all the (computational) terms in sort Type. \n\n\n \\subsection{Condorcet Winner}\n\tA (weak) \\textit{Condorcet winner} is a candidate who beats or ties every other candidate in a \n\tpairwise comparison, also known as head to head competition. \n\tRecall from the previous section that the margin matrix,\n  $\\mathrm{marg}$, \n\tstores exactly this data for every pair of candidates.\n\tTherefore, we define the Condorcet winner in Coq:\n\n\\begin{minted}{coq}\nDefinition condorcet_winner \n (marg : cand * cand -> Z) \n (c : cand) := forall d, \n marg (c, d) >= 0.\n\\end{minted}\n\\footnote{DP: comment on strict Condorcet vs weak Condorcet\nrelatively to the margin $\\geq$ or $>$? \\textcolor{blue}{MT: I tweaked it to say that we are talking about weak Condorcet winner.}}\n\n  Informally, the definition,  $\\mathrm{condorcet\\_winner}$ states that \n  if a candidate $c$  is the Condorcet winner, then they are\n  ranked equal or higher against\n  every other candidate in more ballots than the vice versa. \n  Our goal is to establish that if there is a \n  Condorcet winner, then the Schulze method\n  elects it. We formally state our intent \n  in Coq as:\n \t\n\\begin{minted}{coq}\n Lemma condorcet_winner_implies_winner \n    (marg : cand * cand -> Z)\n    (c : cand) : \n    condorcet_winner marg c -> \n    schulze_winner marg c = true. \nProof.  ... Qed.\n\\end{minted}\n\\footnote{DP: Why use the boolean function? And if the boolean\nfunction is used, why are the propositional and type level functions\ngiven earlier? \\textcolor{ blue}{MT: There is nothing specific about boolean function and we can replace it by the Prop definition (or the Type definition).  The reason for \nboolean fuction is that in the beginning I introduced the definition of Schulze's Winner as a boolean function to the reader, so I continued with it to let the reader make a connection \nbetween the definition,  schulze\\_winner, I gave previously and Condorcet winner (but I see that our definition of Condorcet winner is in Prop). }}\n\\footnote{DP: Proof terms omitted can be omitted :-) \\textcolor{ blue}{MT:  Replaced by triple dots to convey the proof terms}}\n\n  \t\t\n The proof of $condorcet\\_winner\\_implies\\_winner$ hinges on the two key observations:\n \n \\begin{enumerate}\n  \\item If a candidate $c$ is the Condorcet winner, then the generalised margin (matrix) \n  between $c$\n  and every other candidate, say, $d$ would be greater than or equal to 0, i.e. \n  $M \\text{ } (c, \\text{ }d) \\geq 0$.\n  \n  \\item If a candidate $c$ is the Condorcet winner, then the generalised margin  (matrix)\n  between every other candidate, say, $d$ and $c$ would be less than or equal to 0, \n  $M \\text{ } (d, \\text{ }c) \\leq 0$.\n \\end{enumerate}\n \n \n These two key observations make the proof of the lemma\n $\\mathrm{condorcet\\_winner\\_implies\\_winner}$ \n trivial because we have $M \\text{ } (d, \\text{ }c) \\leq 0$  and\n  $M \\text{ } (c, \\text{ }d) \\geq 0$, hence $M \\text{ } (d, \\text{ }c)  \\leq \n   M \\text{ } (c, \\text{ }d)$. Intuitively, \n if a candidate $c$ is the Condorcet winner, then the strongest path between her and every other \n candidate, say, $d$ would be either a direct path or a more stronger path \n via some other intermediate candidates (proof by induction on the path length). \n In both cases, we have the generalised margin between \n $c$ and the other candidate $d$ is greater than or equal to 0. \n Similarly, for the second observation. We encode these two key observations in \n Coq:\n \n \\begin{minted}{coq}\nLemma first_key_observation : \n forall c d n marg, \n condorcet_winner c marg -> \n M marg n c d >= 0.\nProof.   ...  Qed.\n\nLemma second_key_observation : \n forall c d n marg, \n condorcet_winner c marg -> \n M marg n d c <= 0.\nProof.  ...  Qed. \n \\end{minted}\n\n \\footnote{DP: again 'proof terms omitted' doesn't convey\n information.  \\textcolor{blue}{ MT:  Addressed }}\n\nProof of the last two lemmas is by induction on the path length, i.e. n \\cite{Carre:1971:ANR}. \n\n\n\\subsection{Reversal Symmetry}\\footnote{It is not complete and still ongoing.}\n \\textit{Reversal symmetry} is a voting method criterion which states that if the\n voting method has produced a unique \n  winner, say, $c$ based on the cast ballots, then $c$ should not be elected if the \n individual choices were reversed. \n In context of the Schulze method, we first need to define the unique winner, and ballot reversal. \n \n \\begin{minted}{coq}\n Definition unique_winner \n (marg : cand * cand -> Z) \n (c : cand) :=\n schulze_winner marg  c = true /\\\n (forall d, d <> c -> \n  schulze_winner marg d = false).\n\\end{minted}  \n\\noindent\nInformally, the definition of \\textit{unique\\_winner} states that a \ncandidate $c$ is a unique winner\nif it wins the election and every candidate \nother than $c$ loses the election.\nWe capture the ballot reversal in terms of margin matrix. For any given ballot set $P$, \nthe margin between two candidates $c$ and $d$ is: \n\\[\n  \\mathrm{marg}(c, d) = \\sharp \\lbrace b \\in P \\mid c >_b d \\rbrace -\n            \\sharp \\lbrace b \\in P \\mid d >_b c \\rbrace\n\\] \n\n\\noindent\nIf we reverse the individual choices in every ballot, the new margin\nmatrix, denoted as $\\mathrm{rev\\_marg}$, would be:\n\n\\[\n  \\mathrm{rev\\_marg}(c, d) = -  \\mathrm{marg} (c, d)  \n\\]    \n\n\\noindent\nThe connection between $\\mathrm{rev\\_marg}$ and $\\mathrm{marg}$ is very intuitive, but it can be understood \nby considering a hypothetical single ballot election. Let's assume that we have \na single ballot $(A, 1); (B, 2); (C, 3)$ and the interpretation is \nthat $A$ is strictly preferred over $B$, and $B$ is strictly preferred over $C$ \n(but we do not need strict preferences to have this property).  The margin matrix\nconstructed from this ballot is: \n\n\\[\n\\bordermatrix{ & A & B & C \\cr\n      A & 0 & 1 & 1 \\cr\n      B & -1 & 0 & 1 \\cr\n      C & -1 & -1 & 0 }\n      \\]\n    \n\\noindent      \nAfter reversing the original ballot, we get $(A, 3); (B, 2); (C, 1)$ and \nthe margin matrix is:\n\\[\n\\bordermatrix{ & A & B & C \\cr\n      A & 0 & -1 & -1 \\cr\n      B & 1 & 0 & -1 \\cr\n      C & 1 & 1 & 0 }\n      \\]\n\n\n\\noindent\nIt is clearly evident from this example that the \nconnection between $\\mathrm{rev\\_marg}$ and $\\mathrm{marg}$  holds.\nWe capture this connection in Coq as:\n\n\\begin{minted}{coq}\nDefinition rev_marg \n   (marg : cand -> cand -> Z) \n   (c d : cand) := -marg c d.\n\\end{minted}\n\n\\noindent\n\n\nFinally, the reversal symmetry property can be expressed in Coq as: \n\\begin{minted}{coq}\nLemma reversal_symmetry : forall marg c, \n  unique_winner marg c ->\n  schulze_winner (rev_marg marg) c = \n  false.\nProof. \n (* still ongoing *)\n\\end{minted}\n\n\\noindent\nThe lemma $\\mathrm{reversal\\_symmetry}$ expresses that if a candidate $c$ is the unique \nwinner, with respect to $\\mathrm{marg}$ computed from some ballot set $P$, then she is \na loser with respect to $\\mathrm{rev\\_marg}$, computed from reversing all the entries \nin the ballot set $P$.\n\n\\noindent\nThe proof this lemma is fairly straight forward \\cite{Schulze:2011:NMC}, but \nSchulze's original paper assumes a key property which turns out to be very difficult to prove, \nat least in our encoding, in Coq. The key property is: if $M$ \nis the generalised margin \nmatrix (step 4), computed using the margin matrix $\\mathrm{marg}$\nand $\\mathrm{M\\_rev}$ is the generalised \nmargin matrix, computed using the margin matrix $\\mathrm{rev\\_marg}$, then \n$M\\_M\\_\\mathrm{rev}: \\forall \\text{ } c \\text{ } d,  M(c, d) =\nM\\_\\mathrm{rev} (d, c)$ holds. Currently, \nwe do not have the proof of $M\\_M\\_\\mathrm{rev}$ in Coq, but we managed to prove \nanother property, $\\mathrm{path\\_with\\_rev\\_marg}$\n\\footnote{DP: more detail. \\textcolor{blue}{MT: explained more about it in the next line.}}.  It states that if there is a path from \n$c$ to $d$ of strength $k$, with respect to $\\mathrm{marg}$, then we have \na path of same strength $k$ from $d$ to $c$, with respect to\n$\\mathrm{rev\\_marg}$. \nIf this path from $c$ to $d$ happens to be the strongest path (step 4), \nthen we can prove $M\\_M\\_\\mathrm{rev}$ \\footnote{The challenge in our encoding \nis proving that the strength of the strongest path is $\\geq  M(c, d)$ and \nthe strength of all paths is $\\leq M(c, d)$ to infer the equality, \ni.e. strength of the strongest path $= M(c, d)$}.  The lemma $\\mathrm{path\\_with\\_rev\\_marg}$ can be \ncombined with \nsome other properties to complete the proof of $M\\_M\\_\\mathrm{rev}$. \n\n\\begin{minted}{coq}\nLemma path_with_rev_marg :\n  forall k marg c d,\n  Path marg k c d <->  \n  Path (rev_marg marg) k d c.\nProof.  ... Qed.\n\\end{minted}\n\\footnote{DP: proofs omitted doesn't add information \\textcolor{ blue}{MT: replaced by triple dots}}\n\n\\noindent\n$\\mathrm{Path}$ is an inductive datatype that exactly captures the notion of \nsequence of nodes between two candidates (step 3). More elaborately, \n$\\mathrm{Path} \\text{ }k \\text{ }marg \\text{ }c \\text{ }d$ a path $p$, sequence of candidates \n$p= (c,c_{1}, \\dots ,c_{w},d)$, that joins $c$ and $d$ and the strength of \np, $\\mathrm{st}(p) =  \\min \\lbrace \\mathrm{marg} (c_i, c_{i+1}) \\mid 0 \n\\leq i \\leq w \\rbrace$, is greater than or equal to $k$. \n\n\\noindent\n\n\n\\bibliography{thesis}\n\\bibliographystyle{IEEEtran}\n\n\\end{document}\n", "meta": {"hexsha": "60ecef8657565194b0fb51038fed46ae919f9e0f", "size": 22874, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "DirkChanges/eurosp-2021-template-Mukesh-Changes.tex", "max_stars_repo_name": "mukeshtiwari/HotSpot2021", "max_stars_repo_head_hexsha": "eb42ba187838986617ce6b38143d20e326f7c3f6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DirkChanges/eurosp-2021-template-Mukesh-Changes.tex", "max_issues_repo_name": "mukeshtiwari/HotSpot2021", "max_issues_repo_head_hexsha": "eb42ba187838986617ce6b38143d20e326f7c3f6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DirkChanges/eurosp-2021-template-Mukesh-Changes.tex", "max_forks_repo_name": "mukeshtiwari/HotSpot2021", "max_forks_repo_head_hexsha": "eb42ba187838986617ce6b38143d20e326f7c3f6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.67578125, "max_line_length": 240, "alphanum_fraction": 0.7199440413, "num_tokens": 6480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4005031123253261}}
{"text": "\\section{Nomenclature}\n\n\\begin{table}[htb!]\n\\centering\n\\begin{tabular}{|c|l|}\n\\hline\n$x_i$ & Position of the center of mass of the differential element in the\\\\\n& current configuration\\\\\n\\hline\n$X_I$ & Position of the center of mass of the differential element in the\\\\\n& reference configuration\\\\\n\\hline\n$\\xi_I$ & Position of the center of mass of the micro element in the\\\\\n& current configuration w.r.t. the center of mass of the differential element\\\\\n\\hline\n$\\Xi_I$ & Position of the center of mass of the micro element in the\\\\\n& reference configuration w.r.t. the center of mass of the differential element\\\\\n\\hline\n$\\sigma_{ij}$ & Unsymmetric Cauchy stress\\\\\n\\hline\n$s_{ij}$ & Symmetric micro stress\\\\\n\\hline\n$m_{ijk}$ & Higher order couple stress\\\\\n\\hline\n$f_{i}$ & Body force density\\\\\n\\hline\n$a_{i}$ & Acceleration\\\\\n\\hline\n$\\l_{ij}$ & Body force couple\\\\\n\\hline\n$\\omega_{ij}$ & Micro-spin inertia\\\\\n\\hline\n\\end{tabular}\n\\end{table}\n\n\\FloatBarrier", "meta": {"hexsha": "c8b1776457dc379adf8dac07cd9fb8c9f7ea085e", "size": 958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/Report/tex/nomenclature.tex", "max_stars_repo_name": "lanl/tardigrade-micromorphic-element", "max_stars_repo_head_hexsha": "dafc66df8a308e9fef8af4907de902464b84302b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/Report/tex/nomenclature.tex", "max_issues_repo_name": "lanl/tardigrade-micromorphic-element", "max_issues_repo_head_hexsha": "dafc66df8a308e9fef8af4907de902464b84302b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/Report/tex/nomenclature.tex", "max_forks_repo_name": "lanl/tardigrade-micromorphic-element", "max_forks_repo_head_hexsha": "dafc66df8a308e9fef8af4907de902464b84302b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.6111111111, "max_line_length": 81, "alphanum_fraction": 0.7192066806, "num_tokens": 290, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4005031084552774}}
{"text": "\\newcommand{\\Val}{\\fun{Val}}\n\\newcommand{\\POV}[1]{\\ensuremath{\\mathsf{PresOfVal}(\\mathsf{#1})}}\n\\newcommand{\\DBE}[2]{\\ensuremath{\\mathsf{DBE}({#1},~{#2})}}\n\\newcommand{\\DGO}[2]{\\ensuremath{\\mathsf{DGO}({#1},~{#2})}}\n\\newcommand{\\transtar}[2]{\\xlongrightarrow[\\textsc{#1}]{#2}\\negthickspace^{*}}\n\n\\section{Properties}\n\\label{sec:properties}\n\nThis section describes the properties that the ledger should have. The goal is to\nto include these properties in the executable specification to enable e.g.\nproperty-based testing or formal verification.\n\n\\subsection{Preservation of Value}\n\\label{sec:preservation-of-value}\n\nAs visualized in Figure~\\ref{fig:fund-preservation},\nthe total amount of lovelace in any given chain state\n$\\var{s}\\in\\ChainState$ is completely contained within the values of the six\nvariables:\n\n\\begin{tabular}{||l|l|l|l||}\\hline\\hline\n\n  \\textbf{Variable} & \\textbf{Name in Figure~\\ref{fig:fund-preservation}}\n                    & \\textbf{Nesting Inside Chain State} & \\textbf{Kind} \\\\ \\hline\n  utxo & circulation & s.nes.es.ls.utxoSt & Map over Lovelace Values  \\\\ \\hline\n  deposits & deposits &  s.nes.es.ls.utxoSt & Lovelace Value ($\\Coin$) \\\\ \\hline\n  fees & fees &  s.nes.es.ls.utxoSt & Lovelace Value ($\\Coin$) \\\\ \\hline\n  rewards & reward accounts & s.nes.es.ls.dpstate.dstate  & Lovelace Value ($\\Coin$)  \\\\ \\hline\n  treasury & treasury &  s.nes.es.acnt  & Lovelace Value ($\\Coin$) \\\\ \\hline\n  reserves & reserves & s.nes.es.acnt & Map over Lovelace Values \\\\ \\hline\n  \\hline\n\\end{tabular}\n\n\\noindent\nNotice that $\\var{deposits}$, $\\var{fees}$, $\\var{treasury}$, and $\\var{reserves}$\nare all single lovelace values, while $\\var{utxo}$, and $\\var{rewards}$ are\nmaps whose values are lovelace.\n\nWe define the \\emph{Lovelace Value} of a given chain state as:\n\\begin{definition}[Lovelace Value]\n  \\label{def:val}\n  \\begin{equation*}\n    \\Val(s~\\in~\\var{State}) =\n        \\Val(\\var{utxo}) +\n            \\Val(\\var{deposits}) +\n            \\Val(\\var{fees}) +\n            \\Val(\\var{reserves}) +\n            \\Val(\\var{treasury}) +\n            \\Val(\\var{rewards})\n  \\end{equation*}\n  where\n  \\begin{equation*}\n      \\Val(x \\in \\Coin) = x\n  \\end{equation*}\n  \\begin{equation*}\n      \\Val((\\wcard\\mapsto (y \\in \\Coin))^{*}) = \\sum y\n  \\end{equation*}\n\\end{definition}\n\n\\noindent\nFor any state that is used in a given subtransition of $\\mathsf{CHAIN}$,\nwe define $\\Val{}$ in an analogous way, setting the value of any variable that is not explicitly\nrepresented in the state to zero.\nFor example, given $\\var{utxoSt}\\in\\UTxOState$,\n\\begin{equation*}\n  \\Val(\\var{utxoSt}) =\n  \\left(\\sum_{\\wcard\\mapsto(\\wcard,~v)\\in\\var{utxo}}v\\right) + \\var{deposits} + \\var{fees}\n\\end{equation*}\n\n\\noindent\nThe key property that we want to prove is that no semantic transition changes the value that\nis captured in the state ($\\Val{s}$).\nThis property is easy to state: intuitively,\nthe \\emph{Lovelace Value}before the transition is the same as the\n\\emph{Lovelace Value} after that transition.\n\n\\begin{theorem}[Preservation of Value]\n  \\label{thm:chain-pres-of-value}\n  For all environments $e$, blocks $b$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{\\hyperref[fig:rules:chain]{chain}}{b}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) = \\Val(s')\n  \\end{equation*}\n\\end{theorem}\n\n\\noindent\nWe will prove the soundness of Theorem~\\ref{thm:chain-pres-of-value} via a few lemmas.\n\n\\begin{lemma}\n  \\label{lemma:value-sum-pres-1}\n  For any mapping $m:A\\mapsto\\Coin$ and set $s\\in\\powerset{A}$,\n  \\begin{equation*}\n    \\Val(\\var{m}) = \\Val(s\\subtractdom m) + \\Val(s\\restrictdom m)\n  \\end{equation*}\n\\end{lemma}\n\\begin{proof}\n  easy\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:value-sum-pres-2}\n  For any mappings $m_1, m_2:A\\mapsto\\Coin$,\n  if $\\dom{m_1}\\cap\\dom{m_2}=\\emptyset$,\n  then\n  \\begin{equation*}\n    \\Val(m_1\\cup m_2) = \\Val(m_1) + \\Val(m_2)\n  \\end{equation*}\n\\end{lemma}\n\\begin{proof}\n  easy\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:utxo-pres-of-value}\n  For all environments $e$, transactions $t$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{\\hyperref[fig:rules:utxo-shelley]{utxo}}{t}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) + w = \\Val(s')\n  \\end{equation*}\n  where $w = \\fun{wbalance}~(\\fun{txwdrls}~{t})$.\n\\end{lemma}\n\n\\begin{proof}\n  The proof is essentially unfolding the definition of the predicate\n  \\begin{equation}\n    \\label{cons-is-prod}\n    \\consumed{pp}{utxo}{t} = \\produced{pp}{stpools}{t}\n  \\end{equation}\n  and applying a little algebra.\n%\nIf we let:\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      k & \\keyRefunds{pp}{stkCreds}{t} \\\\\n      f & \\txfee{t} \\\\\n      d & \\totalDeposits{pp}{stpools}{(\\txcerts{t})} \\\\\n    \\end{array}\n  \\end{equation*}\n  then equation~\\ref{cons-is-prod} can be rewritten as:\n  \\begin{equation*}\n    \\Val(\\txins{t} \\restrictdom{\\var{utxo}}) + w + k = \\Val(\\outs{t}) + f + d\n  \\end{equation*}\n  where $\\outs{}$ is defined in Figure~\\ref{fig:functions:utxo} and returns a value of type $\\UTxO$.\n  Therefore, moving $k$ to the right and adding $\\txins{t} \\subtractdom{\\var{utxo}}$ to each side,\n  \\begin{equation*}\n    \\Val(\\txins{t} \\restrictdom{\\var{utxo}}) + \\Val(\\txins{t} \\subtractdom{\\var{utxo}}) + w\n    = \\Val(\\outs{t}) + f + d - k + \\Val(\\txins{t} \\subtractdom{\\var{utxo}})\n  \\end{equation*}\n  (Though not needed for the proof at hand,\n  note that $d-k$ is non-negative since the deposits will always be large enough to cover\n  the current obligation. See Theorem~\\ref{thm:non-neg-deposits}.)\n%\n  It then follows that:\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}lr}\n      \\Val(\\var{utxo}) + w\n    & \\Val(\\outs{t}) + f + d - k + \\Val(\\txins{t} \\subtractdom{\\var{utxo}})\n    & \\text{(by Lemma~\\ref{lemma:value-sum-pres-1})}\n    \\\\\n    & \\Val((\\txins{t} \\subtractdom{\\var{utxo}})\\cup\\outs{t}) + (d - k) + f \n    & \\text{(by Lemma~\\ref{lemma:value-sum-pres-2})}\n    \\end{array}\n  \\end{equation*}\n  Note that in order to apply Lemma~\\ref{lemma:value-sum-pres-2} above,\n  it must be true that $(\\txins{t} \\subtractdom{\\var{utxo}})$ and $(\\outs{t})$\n  have disjoint domains, which follows from the uniqueness of the transaction IDs.\n\n  Therefore, by adding the deposits and fees from $s$ to the equality above,\n  it follows that $\\Val(s) + w = \\Val(s')$.\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:deleg-pres-of-value}\n  For all environments $e$, transactions $c$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{\\hyperref[fig:delegation-rules]{deleg}}{c}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) = \\Val(s')\n  \\end{equation*}\n\\end{lemma}\n\n\\begin{proof}\n  The only variable with value in this transition is \\var{rewards}.\n  Only two of the rules in $\\mathsf{DELEG}$ can change \\var{rewards},\n  namely $\\mathsf{Deleg{-}Reg}$ and $\\mathsf{Deleg{-}Dereg}$.\n  However, $\\mathsf{Deleg{-}Reg}$ only adds a zero value,\n  and $\\mathsf{Deleg{-}Dereg}$ only removes a zero value.\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:delegs-pres-of-value}\n  For all environments $e$, certificates $\\Gamma$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{\\hyperref[fig:rules:delegation-sequence]{delegs}}{\\Gamma}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) = \\Val(s') + w\n  \\end{equation*}\n  where $w = \\fun{wbalance}~(\\fun{txwdrls}~{t})$,\n  and $t$ is the transaction in the environment $e$.\n\\end{lemma}\n\n\\begin{proof}\n  The proof is by induction on the length of $\\Gamma$.\n  Note that the only variable with value in this transition is \\var{rewards}.\n\n  \\vspace{2ex}\n  \\noindent\n  \\emph{In the base case}, we look at the rule $\\mathsf{Seq{-}delg{-}base}$.\n  Since $\\var{wdrls}\\subseteq\\var{rewards}$, then\n  $\\var{rewards} = \\var{wdrls}\\cup\\var{(\\var{rewards}\\setminus\\var{wdrls})}$.\n%\n  Therefore\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}lr}\n      \\Val{(\\var{rewards})}\n      & \\Val{(\\var{rewards}\\setminus\\var{wdrls})} + \\Val{(\\var{wdrls})}\n      & \\text{by Lemma~\\ref{lemma:value-sum-pres-2}}\n      \\\\\n      & \\Val{(\\var{rewards}\\setminus\\var{wdrls})} + w\n      & \\text{by definition}\n      \\\\\n      & \\Val\\left(\\var{rewards}\\unionoverrideRight\\{(w, 0) \\mid w \\in \\dom \\var{wdrls}\\}\\right) + w\n    \\end{array}\n  \\end{equation*}\n  Therefore $\\Val(s) = \\Val(s')$.\n\n  \\vspace{2ex}\n  \\noindent\n  \\emph{In the inductive case}, we look at the rule $\\mathsf{Seq{-}delg{-}ind}$.\n  In this case, the lemma then follows directly from Lemma~\\ref{lemma:deleg-pres-of-value}.\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:poolreap-pres-of-value}\n  For all environments $e$, epoch $\\epsilon$, and states $s$, $s'$, if\n  \\begin{equation*}\n    e\\vdash s\\trans{\\hyperref[fig:rules:pool-reap]{poolreap}}{\\epsilon}s'\n  \\end{equation*}\n  then\n  \\begin{equation*}\n    \\Val(s) = \\Val(s')\n  \\end{equation*}\n\\end{lemma}\n\n\\begin{proof}\n  The $\\mathsf{POOLREAP}$ value is contained in\n  $\\var{deposits}$, $\\var{treasury}$, and $\\var{rewards}$.\n  Notice that $\\var{unclaimed}$ is added to $\\var{treasury}$\n  and subtracted from the $\\var{deposits}$.\n  Moreover, $\\var{refunded}$ is subtracted from $\\var{deposits}$.\n  (Note that $\\var{deposits}-(\\var{unclaimed}+\\var{refunded})$\n  is non-negative by Theorem~\\ref{thm:non-neg-deposits}.)\n  It therefore suffices to show that\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n    \\Val(\\var{rewards}\\unionoverridePlus\\var{refunds})\n    & \\Val(\\var{rewards}) + \\Val(\\var{refunds})\n    \\\\\n    & \\Val(\\var{rewards}) + \\var{refunded}\n    \\end{array}\n  \\end{equation*}\n  But this is clear from the definition of $\\unionoverridePlus$.\n\\end{proof}\n\n\\begin{lemma}\n  \\label{lemma:ru-pres-of-value}\n  For every $(\\Delta t,~\\Delta r,~\\var{rs},~\\Delta f)$ in the range of $\\fun{createRUpd}$,\n  \\begin{equation*}\n    \\Delta t + \\Delta r + \\Val(rs) + \\Delta f = 0\n  \\end{equation*}\n\\end{lemma}\n\n\\begin{proof}\n  In the definition of $\\fun{createRUpd}$ in Figure~\\ref{fig:functions:reward-update-creation},\n  We see that:\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      \\var{rewardPot} & \\var{feeSS} + \\Delta r \\\\\n      \\var{R} & \\var{rewardPot} - \\Delta t_1 \\\\\n      \\Delta t_2 & R - \\Val(\\var{rs})\\\\\n      \\Delta t & \\Delta t_1 + \\Delta t_2 \\\\\n    \\end{array}\n  \\end{equation*}\n  Therefore\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      (\\var{feeSS} + \\Delta r) & \\var{rewardPot} = R + \\Delta t_1 = \\Delta t_2 + \\Val(rs) + \\Delta t_1  \\\\\n      0 & (\\Delta t_1 + \\Delta t_2 ) - \\Delta r + \\Val(rs)- \\var{feeSS} \\\\\n      0 & \\Delta t - \\Delta r + \\Val(rs)- \\var{feeSS} \\\\\n    \\end{array}\n  \\end{equation*}\n  It then suffices to notice that $\\fun{createRUpd}$ returns\n  $(\\Delta t,-~\\Delta r,~\\var{rs},~-\\var{feeSS})$.\n\\end{proof}\n\n\\noindent\n\nNote that Lemma~\\ref{lemma:ru-pres-of-value} is not strictly need for the proof of\nTheorem~\\ref{thm:chain-pres-of-value}, since the $\\mathsf{NEWEPOCH}$ transition\nrequires that $\\Delta t + \\Delta r + \\Val(rs) + \\Delta f = 0$ holds.\nIt does, however, give us confidence that the $\\mathsf{CHAIN}$ transition can proceed.\n\nWe are now ready to prove Theorem~\\ref{thm:chain-pres-of-value}.\n\n\\begin{proof}\n  For a given transition $\\mathsf{TR}$, let \\POV{TR}\n  be the statement:\n\n  \\begin{tabular}{l}\n    for all environments $e$, signals $\\sigma$, and states $s$, $s'$,\n    $$\n    $e\\vdash s\\trans{tr}{\\sigma}s'~\\implies~\\Val(s) = \\Val(s')$.\n    $$\n  \\end{tabular}\n\n  \\noindent\n  Our goal is to prove \\POV{CHAIN}.\n  Lemmas~\\ref{lemma:utxo-pres-of-value} and \\ref{lemma:delegs-pres-of-value} imply \\POV{LEDGER},\n  since $\\mathsf{UTXOW}$ transforms state exactly as $\\mathsf{UTXO}$ does.\n  \\POV{LEDGERS} then follows by straightforward induction on the length of $\\Gamma$:\n  the base case is trivial;\n  and the inductive case follows directly from \\POV{LEDGER}.\n%\n  \\POV{SNAP} holds trivially, since it contains no value.\n  Similarly, \\POV{NEWPP} holds since $\\var{diff}$ is added to $\\var{reserves}$\n  and subtracted from $\\var{deposits}$.\n  Therefore \\POV{EPOCH} holds by Lemma~\\ref{lemma:poolreap-pres-of-value}.\n  \\POV{MIR} holds since\n  $\\Val{i_{rwd}'}=\\var{tot}$ in Figure~\\ref{fig:rules:mir}.\n  Morover, \\POV{NEWEPOCH} holds in the presence of $\\fun{applyRUpd}$\n  since the transition requires $\\Delta t + \\Delta r + \\Val(rs) + \\Delta f = 0$.\n  \\POV{CHAIN} easily follows from this.\n\\end{proof}\n\n\\subsection{Non-negative Deposit Pot}  % TODO - this section is out of date due to no decaying deposits\n\\label{sec:non-negative-deposit-pot}\n\nThe \\emph{deposit pot} (the variable $\\var{deposits}$ in the UTxO State)\nrepresents the amount of \\emph{lovelace} that is set aside by the system as a whole for refunding deposits.\nDeposits are added to this pot, which then decays exponentially over time,\nand is also depleted by any refunded deposits.\nAt an epoch boundary, the decayed parts of any deposits (including, possibly, deposits for any transactions that will complete in future epochs)\nwill be distributed as additional \\emph{rewards}, as described in~\\cite{delegation_design}.\nSince $\\var{deposits}$ is only used to record the value of future refunds or rewards whose costs have\nalready been incurred, both it and any reward value will always be non-negative.\nNote that there are two types of deposits which are recorded in the same pot: those for stake keys; and those for stake pools.\nStake keys are deregistered in the slot in which the deregistration certificates\nis processed. Stake pools, however, are staged for retirement on epoch boundaries.\n%\nThe following theorem ensures that the deposit pot is properly maintained\nand will always be large enough to meet all of its obligations.\n\n\n\\begin{figure}[h!]\n  \\begin{tabular}{||l|l|l|l||}\\hline\\hline\n\n    \\textbf{Variable} & \\textbf{Value}\n                      & \\textbf{Nesting Inside Chain State} & \\textbf{Kind} \\\\ \\hline\n    deposits & 0 &  s.nes.es.ls.utxoSt & $\\Coin$ \\\\ \\hline\n    stkCreds & $\\emptyset$ & s.nes.es.ls.dpstate.dstate.stkCreds\n             & $\\StakeCreds$ ($\\Credential\\mapsto\\Slot$)  \\\\ \\hline\n    stpools & $\\emptyset$ & s.nes.es.ls.dpstate.pstate.stpools\n            & $\\StakePools$ ($\\KeyHash\\mapsto\\Slot$)  \\\\ \\hline\n  \\end{tabular}\n  \\caption{Initial Chain State}\n  \\end{figure}\n\n\\begin{theorem}[Non-negative Deposit Pot]\n  \\label{thm:non-neg-deposits}\n  Let $n\\in\\N$ and $c_0\\in\\ChainState$ be a chain state in which $\\var{deposits} ~=~0$, $\\var{stkCreds}~=~\\emptyset$ and $\\var{stPools}~=~\\emptyset$, as shown above:\n%  \\\\~\\\\\n  If\n  \\begin{equation*}\n    s_0\\vdash c_0\\trans{\\hyperref[fig:rules:chain]{chain}}{b_0}c_1,~~\n    s_1\\vdash c_1\\trans{\\hyperref[fig:rules:chain]{chain}}{b_1}c_2,~~\n    \\ldots,~~\n    s_n\\vdash c_n\\trans{\\hyperref[fig:rules:chain]{chain}}{b_n}c_{n+1},~~n \\ge 0\n  \\end{equation*}\n  is a sequence of valid $\\mathsf{CHAIN}$ transitions,\n  then $\\forall i, 0 \\le i \\le n, \\var{deposits} ~(c_{n+1}) \\ge 0$.\n\\end{theorem}\n\n\\begin{proof}\n\n  We will prove a slightly stronger condition, namely that some stronger invariants hold\n  most of the time, and that when they do fail to hold, then $\\var{deposits}$ is still non-negative.\n  These stronger invariants will require a few additional definitions.\n%\n  Given a slot $s$, let $\\ell(s)$ be the first slot of the epoch that $s$ occurs in,\n  that is $\\ell = \\fun{firstSlot}\\circ\\fun{epoch}$.\n  Given a mapping $m\\in\\mathsf{T}\\to\\Slot$ and a slot $s\\in\\Slot$,\n  let $\\fun{sep}$ be the function that separates $m$ into two maps,\n  those whose value is strictly less than $s$ and those whose value is at least $s$.\n  So,\n  \\begin{equation*}\n    \\fun{sep}~m~s = \\forall x\\mapsto t~\\in~m,~~\n    \\left(\\{x\\mapsto t~\\mid~t<s\\},~\\{x\\mapsto t~\\mid~t\\geq s\\}\\right)\n  \\end{equation*}\n\n\n  \\noindent\n  If we assume that the \\emph{protocol parameters}, $pp$, are fixed\\footnote{Note that the\n    protocol parameters can only change in the $\\mathsf{NEWPP}$ transition.}, then we can provide convenience functions\n  $R_c$ and $R_p$ for the \\emph{stake credential} and \\emph{stake pool} refunds, respectively:\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      R_c~s_0~s_1 & \\refund{d_{val}}{d_{min}}{\\lambda_d}{s_1-s_0} \\\\\n      R_p~s_0~s_1 & \\refund{p_{val}}{p_{min}}{\\lambda_p}{s_1-s_0} \\\\\n    \\end{array}\n  \\end{equation*}\n  where $d_{val}$, $d_{min}$, $\\lambda_d$, $p_{val}$, $p_{min}$, $\\lambda_p$\n  are the protocol parameter values from $pp$, and $\\fun{refund}$ is defined in\n  Figure~\\ref{fig:functions:deposits-refunds}.\n  We let \\DBE{c}{s} (``Deposits (precisely) Big Enough\"), be the following property:\n  \\begin{equation}\\tag{DBE}\\label{DBE}\n    \\var{deposits}\n    = \\left(\\sum_{\\wcard\\mapsto t\\in C_{old}}R_c~t~\\ell(s)\\right)\n    + |C_{new}|\\cdot d_{val}\n    + \\left(\\sum_{\\wcard\\mapsto t\\in P_{old}}R_p~t~\\ell(s)\\right)\n    + |P_{new}|\\cdot p_{val}\n  \\end{equation}\n  where\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      C_{old},~C_{new} & \\fun{sep}~\\var{stkCreds}~{\\ell(s)} \\\\\n      P_{old},~P_{new} & \\fun{sep}~\\var{stpools}~{\\ell(s)},\n    \\end{array}\n  \\end{equation*}\n  for some slot, $s$, where $\\var{pp}$, $\\var{stkCreds}$, $\\var{stpools}$ are in the corresponding chain state, $c$.\n%\n  In other words, \\DBE{c}{s} asserts that the deposit pot is equal to the\n  sum of the deposit refunds that were available at the previous epoch boundary,\n  plus the sum of the initial deposit values for all the deposits from the current epoch.\n\n  Notice that for a chain state $c$ and slot $s$, if the range of\n  $\\var{stkCreds}$ and $\\var{stpools}$ contains only slots from the previous epoch,\n  then \\DBE{c}{s} is equivalent to\n  \\begin{equation}\\tag{DEO}\\label{DEO}\n    \\var{deposits} = \\obligation{pp}{stkCreds}{stpools}{\\ell(s)}\n  \\end{equation}\n  where $\\fun{obligation}$ is defined in Figure~\\ref{fig:funcs:epoch-helper-rewards}.\n%\n  It is generally true that \\DBE{c'}{s_i} holds after each subtransition of\n  $s_i\\vdash c_i\\trans{\\hyperref[fig:rules:chain]{chain}}{b_i}c_{i+1}$.\n  However, this invariant can fail to hold after the\n  $\\hyperref[fig:delegation-transitions]{\\mathsf{DELEG}}$ transition,\n  since this transition can add and remove stake credentials, and can also add stake pools,\n  but the deposit pot is not adjusted accordingly\n  until the next subtransiton of $\\hyperref[fig:rules:ledger]{\\mathsf{LEDGER}}$,\n  namely $\\hyperref[fig:rules:utxo-shelley]{\\mathsf{UTXO}}$.\n%\n  The invariant can also fail to hold if the slot increases while the chain state remains the same.\n  That is, if \\DBE{c_{i+1}}{s_i} holds, then \\DBE{c_{i+1}}{s_{i+1}} can fail to hold if\n  $\\epoch{s_i} < \\epoch{s_{i+1}}$, since the value of the deposit\n  in the left hand side of equation~\\ref{DBE} remains the same, but the\n  refunded values become smaller\\footnote{Note that if $\\epoch{s_i} = \\epoch{s_{i+1}}$, then \\DBE{c_{i+1}}{s_{i+1}} is trivially true.}.\n  Therefore, in this situation we can consider the slightly weaker constraint:\n  \\begin{equation}\\tag{DGO}\\label{DGTO}\n    \\var{deposits} \\geq \\obligation{pp}{stkCreds}{stpools}{\\ell(s)}\n  \\end{equation}\n  The difference between the left and right hand sides of the inequality\n  corresponds to the lovelace value in $c_{i+1}$ that decays between $s_i$ and $s_{i+1}$.\n\n  There are four sub-transitions where $\\var{deposits}$ is changed:\n  $\\mathsf{SNAP}$ (Figure~\\ref{fig:rules:snapshot}),\n  $\\mathsf{POOLREAP}$ (Figure~\\ref{fig:rules:pool-reap}),\n  $\\mathsf{NEWPP}$ (Figure~\\ref{fig:rules:new-proto-param}),\n  $\\mathsf{UTXO}$ (Figure~\\ref{fig:rules:utxo-shelley}).\n  This ordering is also the order in which $\\var{deposits}$ is changed.\n  Of these sub-transitions, only $\\mathsf{UTXO}$ actually changes the value of $\\var{deposits}$\n  when $s_i$ is in the same epoch as $s_i$.\n  (We say that $s_i$ \\emph{crosses the epoch boundary} if the precondition of\n  Rule~\\ref{eq:new-epoch} in Figure~\\ref{fig:rules:new-epoch} is met,\n  namely if $\\epoch{s_i} \\ge e_\\ell+1$.)\n%\n  The proof then proceeds by induction on $n$, showing the following:\n  \\begin{itemize}\n    \\item\n      Let $c$ be the chain state after the $\\mathsf{SNAP}$ transition\n      in $s_i\\vdash c_i\\trans{\\hyperref[fig:rules:chain]{chain}}{b_i}c_{i+1}$.\n      If \\DGO{c_i}{s_i}, then \\DBE{c}{s_i} holds.\n    \\item $\\mathsf{POOLREAP}$ preserves \\ref{DBE}.\n    \\item $\\mathsf{NEWPP}$ preserves \\ref{DBE}.\n    \\item The property for $\\mathsf{UTXO}$ requires a bit of explanation.\n      Let $\\var{nes}\\in\\NewEpochState$ be the new epoch state in $c_i$.\n      Note that the property \\ref{DBE} makes sense for values of $\\NewEpochState$\n      since it contains all the relevant variables.\n      Similarly, \\ref{DBE} also makes sense for values of $\\UTxOState\\times\\PParams$.\n      Let\n      $$\n        {\\begin{array}{c}\n           \\var{gkeys} \\\\\n         \\end{array}}\n        \\vdash\\var{nes}\\trans{\\hyperref[fig:rules:tick]{tick}}{\\var{bh}}\\var{nes'}\n      $$\n      be the first sub-transition of\n      $s_i\\vdash c_i\\trans{\\hyperref[fig:rules:chain]{chain}}{b_i}c_{i+1}$.\n      If \\DBE{\\var{nes'}}{s_i} holds, then \\DBE{(us', pp)}{s_i} holds for every transaction\n      $tx$ in $b_i$, where:\n      $$\n      \\var{env}\\vdash \\var{us} \\trans{\\hyperref[fig:rules:utxow-shelley]{utxo}}{tx} \\var{us'},\n      $$\n      is a sub-transition of\n      $s_i\\vdash c_i\\trans{\\hyperref[fig:rules:chain]{chain}}{b_i}c_{i+1}$,\n      and $\\var{pp}$ is the protocol parameters in $\\var{nes'}$.\n  \\end{itemize}\n\n  \\noindent\n  Case $\\hyperref[fig:rules:snapshot]{\\mathsf{SNAP}}$.\n  We must show that\n  if $c$ is the chain state after the $\\mathsf{SNAP}$ transition\n  in $s_i\\vdash c_i\\trans{\\hyperref[fig:rules:chain]{chain}}{b_i}c_{i+1}$,\n  and \\DGO{c_i}{s_i} holds, then so does \\DBE{c}{s_i}.\n%\n  We can assume that $s_i$ crosses the epoch boundary,\n  since otherwise the $\\mathsf{SNAP}$ transition will not occur.\n  Since the $\\mathsf{SNAP}$ transition only happens within the $\\mathsf{TICK}$ transition\n  on the epoch boundary, it follows that\n  $c_i$ does not contain any stake credentials or pools from the current epoch,\n  and so \\ref{DBE} will be equivalent to \\ref{DEO} (the current epoch is $\\epoch{s_i}$).\n  However, \\DBE{c}{s_i} holds trivially, since it is determined from the $\\fun{obligation}$ value.\n  \\\\~\\\\\n  Case $\\hyperref[fig:rules:pool-reap]{\\mathsf{POOLREAP}}$.\n  We must show that \\ref{DBE} is preserved.\n%\n  We again assume that $s_i$ crosses the epoch boundary.\n  The $\\mathsf{POOLREAP}$ transition does the following:\n  \\begin{enumerate}\n    \\item leaves $\\var{stkCreds}$ unchanged,\n    \\item removes $\\var{retired}$ from $\\var{stpools}$,\n    \\item subtracts $\\var{unclaimed}+\\var{refunded}$ from $\\var{deposits}$.\n  \\end{enumerate}\n%\n  Notice that the domain of the $\\var{pr}$ is $\\var{retired}$,\n  and similarly the domain of the $\\var{rewardAcnts}$ is also $\\var{retired}$\n  since the domains of $\\var{stpools}$ and $\\var{poolParams}$ are the same.\n  Therefore $\\var{retired}$ is the disjoint union of\n  $\\dom({\\var{refunds}})$ and $\\dom({\\var{mRefunds}})$, so that\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      \\var{unclaimed}+\\var{refunded}\n      &\n      \\left(\n        \\sum\\limits_{\\wcard\\mapsto t\\in\\var{refunds}}R_p~t~\\ell(s)\n      \\right)+\n      \\left(\n        \\sum\\limits_{\\wcard\\mapsto t\\in\\var{mRefunds}}R_p~t~\\ell(s)\n      \\right)\n      \\\\\n      &\n      \\sum\\limits_{\\wcard\\mapsto t\\in\\var{rewardAcnts'}}R_p~t~\\ell(s)\n      \\\\\n      &\n      \\left(\n        \\sum\\limits_{\\wcard\\mapsto t\\in\\var{stpools}}R_p~t~\\ell(s)\n      \\right)-\n      \\left(\n        \\sum\\limits_{\\wcard\\mapsto t\\in\\var{retired}\\subtractdom\\var{stpools}}R_p~t~\\ell(s)\n      \\right)\n    \\end{array}\n  \\end{equation*}\n  Therefore, it follows that if \\ref{DEO} holds before $\\mathsf{POOLREAP}$, then it also holds afterwards.\n  \\\\~\\\\\n  Case $\\hyperref[fig:rules:new-proto-param]{\\mathsf{NEWPP}}$.\n  We must show that \\ref{DBE} is preserved.\n%\n  We again assume that $s_i$ crosses the epoch boundary.\n  In this transition $\\var{pp}$ can change, but $\\var{stkCreds}$, $\\var{stpools}$,\n  and $\\var{deposits}$ do not change.\n  As in the $\\mathsf{SNAP}$ case, \\DBE{c}{s_i} holds trivially,\n  since it is set to the value that is determined by $\\fun{obligation}$.\n  \\\\~\\\\\n  Case $\\hyperref[fig:rules:utxo-shelley]{\\mathsf{UTXO}}$.\n  We assume that \\DBE{\\var{nes'}}{s_i} holds, where $\\var{nes'}$\n  is the new epoch state after the $\\mathsf{TICK}$ transition.\n  We must show that \\ref{DBE} is preserved after each $\\mathsf{UTXO}$ transition.\n%\n  The $\\mathsf{DELEGS}$ transition can result in values being\n  added to or deleted from $\\var{stkCreds}$, and added to $\\var{stpools}$.\n  Let $A_s$ be the added stake credentials, $D_s$ be the deleted credentials, and\n  $A_p$ be the added stake pools, where $\\var{stkCreds}'$ is the stake credential mapping\n   $\\var{stpools}'$ is the stake pools, and $\\var{deposits}'$ is the deposit pot  after $\\mathsf{DELEGS}$.\n  We have that\n  \\begin{equation*}\n    \\begin{array}{rcl}\n      \\var{D_s} & \\subseteq & \\var{\\var{stkCreds}\\cup\\var{A_s}} \\\\\n      \\var{stkCreds}' & = & (\\var{stkCreds}\\cup\\var{A_s})\\setminus\\var{D_s} \\\\\n      \\var{stpools}' & = & \\var{stpools}\\cup\\var{A_p} \\\\\n    \\end{array}\n  \\end{equation*}\n  The slots in the range of $A_s$ will all be equal to $s_i$,\n  but the slots in the range of $D_s$\nmay either be from the current epoch or an earlier one, so we split them using $\\fun{sep}$:\n  \\begin{equation*}\n    (\\var{D_{s\\_old}},~\\var{D_{s\\_new}}) = \\fun{sep}~\\var{D_s}~\\ell(s_i)\n  \\end{equation*}\n  We must then show that\n  \\begin{equation*}\n    \\var{deposits}' = \\var{deposits}\n    + |A_s|\\cdot d_{val}\n    + |P_c|\\cdot p_{val}\n    - |D_{s\\_new}|\\cdot d_{val}\n    - \\left(\\sum_{\\wcard\\mapsto t\\in D_{s\\_old}}R_c~t~\\ell(s_i)\\right)\n  \\end{equation*}\n  Looking at the $\\mathsf{UTXO}$ transition in Figure~\\ref{fig:rules:utxo-shelley},\n  \\begin{equation*}\n    \\var{deposits}' = \\var{deposits} + \\totalDeposits{pp}{stpools}{(\\txcerts{tx})}\n    - (\\var{refunded} + \\var{decayed})\n  \\end{equation*}\n  The function $\\fun{totalDeposits}$ is defined in Figure~\\ref{fig:functions:deposits-refunds}\n  and it is clear that here it is equal to\n  $$|A_s|\\cdot d_{val} + |P_c|\\cdot p_{val.}$$\n  Recall that\n  \\begin{equation*}\n    \\begin{array}{r@{~=~}l}\n      \\var{refunded} & \\keyRefunds{pp}{stkCreds}~{tx} \\\\\n      \\var{decayed} & \\decayedTx{pp}{stkCreds}~{tx}\n    \\end{array}\n  \\end{equation*}\n  where $\\fun{keyRefunds}$ is defined in Figure~\\ref{fig:functions:deposits-refunds}.\n  This iterates $\\fun{keyRefund}$ from the same figure,\n  which in turn just looks up the creation slot for a transaction and returns $R_c$.\n  The function to calculate the value of decayed deposits, $\\fun{decayedTx}$, is defined in Figure~\\ref{fig:functions:deposits-decay}.\n  This iterates $\\fun{decayedKey}$ from the same figure.\n  Therefore, to show that\n  \\begin{equation}\\label{deleted-is-refunds-plus-decayed}\n    |D_{s\\_new}|\\cdot d_{val} + \\sum_{\\wcard\\mapsto t\\in D_{s\\_old}}R_c~t~\\ell(s_i)\n    = \\var{refunded} + \\var{decayed},\n  \\end{equation}\n  and thus complete the proof for the $\\mathsf{UTXO}$ case,\n  it suffices to show that for a given $\\var{c}\\mapsto s\\in D_s$,\n  the $R_c$ value plus the $\\fun{decayedKey}$ value that is associated with the stake\n  credential $c$ is equal to $d_{val}$ if $\\epoch(s)=\\epoch(s_i)$, and is otherwise equal to $R_c~s~\\ell(s_i)$.\n  Looking at the definition of $\\fun{decayedKey}$, observe that if $\\epoch(s)=\\epoch(s_i)$\n  then $\\var{start}=\\var{created}$ and so the decayed value is $(R_c~s~s)-(R_c~s~s_i)$.\n  However, $R_c~s~s = d_{val}$, so the refund plus the decayed value is\n  $d_{val}-(R_c~s~s_i)+(R_c~s~s_i)=d_{val}$.\n  Otherwise, if $s$ is from a previous epoch, then $\\var{start}=\\ell(s_i)$, and so\n  the decayed value is $(R_c~s~\\ell(s_i))-(R_c~s~s_i)$.\n  The refund plus the decayed value is thus\n  $(R_c~s~\\ell(s_i))-(R_c~s~s_i)+(R_c~s~s_i)=(R_c~s~\\ell(s_i))$.\n  Therefore, equation~\\ref{deleted-is-refunds-plus-decayed} holds, and\n  consequently so also does \\DBE{c'}{s_i}.\n\n\\end{proof}\n\n\\subsection{Header-Only Validation}\n\\label{sec:header-only-validation}\nThe header-only validation properties of the Shelley Ledger are the analogs\nof those from Section 8.1 of \\cite{byron_chain_spec}.\n\nIn any given chain state, the consensus layer needs to be able to validate the\nblock headers without having to download the block bodies.\nProperty~\\ref{prop:header-only-validation} states that if an extension of a\nchain that spans less than $\\StabilityWindow$ slots is valid, then validating the\nheaders of that extension is also valid. This property is useful for its\nconverse: if the header validation check for a sequence of headers does not\npass, then we know that the block validation that corresponds to those headers\nwill not pass either.\n\nFirst we define the header-only version of the $\\mathsf{CHAIN}$ transition,\nwhich we call $\\mathsf{CHAINHEAD}$.\nIt is very similiar to $\\mathsf{CHAIN}$, the only difference being that\nit does not call $\\mathsf{BBODY}$.\n\n\\begin{figure}[ht]\n  \\begin{equation}\\label{eq:chain-head}\n    \\inference[ChainHead]\n    {\n      \\var{bh} \\leteq \\bheader{block}\n      &\n      \\var{gkeys} \\leteq \\fun{getGKeys}~\\var{nes}\n      &\n      \\var{s} \\leteq \\bslot{(\\bhbody{bh})}\n      \\\\\n      (\\wcard,~\\wcard,~\\wcard,~(\\wcard,~\\wcard,~\\wcard,~\\var{pp}),~\\wcard,~\\wcard,\\wcard) \\leteq \\var{nes}\n      \\\\~\\\\\n      \\fun{chainChecks}~\\var{pp}~\\var{bh}\n      \\\\~\\\\\n      {\n        {\\begin{array}{c}\n           \\var{gkeys} \\\\\n         \\end{array}}\n        \\vdash\\var{nes}\\trans{\\hyperref[fig:rules:tick]{tick}}{\\var{s}}\\var{nes'}\n      } \\\\~\\\\\n      (\\var{e_1},~\\wcard,~\\wcard,~\\wcard,~\\wcard,~\\wcard,\\wcard)\n        \\leteq\\var{nes} \\\\\n      (\\var{e_2},~\\wcard,~\\wcard,~\\var{es},~\\wcard,~\\var{pd},\\var{osched})\n        \\leteq\\var{nes'} \\\\\n        (\\wcard,~\\wcard,\\var{ls},~\\wcard,~\\var{pp'})\\leteq\\var{es}\\\\\n        ( \\wcard,\n          ( (\\wcard,~\\wcard,~\\wcard,~\\wcard,~\\wcard,~\\var{genDelegs}),~\n          (\\wcard,~\\wcard,~\\wcard)))\\leteq\\var{ls}\\\\\n          \\var{ne} \\leteq  \\var{e_1} \\neq \\var{e_2}\\\\\n      {\n        {\\begin{array}{c}\n            \\var{pp'} \\\\\n            \\var{osched} \\\\\n            \\var{pd} \\\\\n            \\var{genDelegs} \\\\\n            \\var{s_{now}} \\\\\n            \\var{ne}\n         \\end{array}}\n        \\vdash\n        {\\left(\\begin{array}{c}\n              \\var{cs} \\\\\n              \\var{lab} \\\\\n              \\eta_0 \\\\\n              \\eta_v \\\\\n              \\eta_c \\\\\n              \\eta_h \\\\\n        \\end{array}\\right)}\n        \\trans{\\hyperref[fig:rules:prtcl]{prtcl}}{\\var{bh}}\n        {\\left(\\begin{array}{c}\n              \\var{cs'} \\\\\n              \\var{lab'} \\\\\n              \\eta_0' \\\\\n              \\eta_v' \\\\\n              \\eta_c' \\\\\n              \\eta_h' \\\\\n        \\end{array}\\right)}\n      } \\\\~\\\\~\\\\\n    }\n    {\n      \\var{s_{now}}\n      \\vdash\n      {\\left(\\begin{array}{c}\n            \\var{nes} \\\\\n            \\var{cs} \\\\\n            \\eta_0 \\\\\n            \\eta_v \\\\\n            \\eta_c \\\\\n            \\eta_h \\\\\n            \\var{lab} \\\\\n      \\end{array}\\right)}\n      \\trans{chainhead}{\\var{bh}}\n      {\\left(\\begin{array}{c}\n            \\varUpdate{\\var{nes}'} \\\\\n            \\varUpdate{\\var{cs}'} \\\\\n            \\varUpdate{\\eta_0'} \\\\\n            \\varUpdate{\\eta_v'} \\\\\n            \\varUpdate{\\eta_c'} \\\\\n            \\varUpdate{\\eta_h'} \\\\\n            \\varUpdate{\\var{lab}'} \\\\\n      \\end{array}\\right)}\n    }\n  \\end{equation}\n  \\caption{Chain-Head rules}\n  \\label{fig:rules:chainhead}\n\\end{figure}\n\n\\begin{property}[Header only validation]\\label{prop:header-only-validation}\n  For all environments $e$, states $s$ with slot number $t$\\footnote{i.e. the\n    component $\\var{s_\\ell}$ of the last applied block of $s$ equals $t$},\n    and chain extensions $E$ with corresponding headers $H$ such that:\n  %\n  $$\n  0 \\leq t_E - t  \\leq \\StabilityWindow\n  $$\n  %\n  we have:\n  %\n  $$\n  e \\vdash s \\transtar{\\hyperref[fig:rules:chain]{chain}}{E} s'\n  \\implies\n  e \\vdash s \\transtar{\\hyperref[fig:rules:chainhead]{chainhead}}{H} s''\n  $$\n  where $t_E$ is the maximum slot number appearing in the blocks contained in\n  $E$, and $H$ is obtained from $E$ by applying $\\fun{bheader}$ to each block in $E$.\n\\end{property}\n\n\\begin{property}[Body only validation]\\label{prop:body-only-validation}\n  For all environments $e$, states $s$ with slot number $t$, and chain\n  extensions $E = [b_0, \\ldots, b_n]$ with corresponding headers $H$ such that:\n  $$\n  0 \\leq t_E - t  \\leq \\StabilityWindow\n  $$\n  we have that for all $i \\in [1, n]$:\n  $$\n  e \\vdash s \\transtar{\\hyperref[fig:rules:chainhead]{chainhead}}{H} s_{h}\n  \\wedge\n  e \\vdash s \\transtar{\\hyperref[fig:rules:chain]{chain}}{[b_0 \\ldots b_{i-1}]} s_{i-1}\n  \\implies\n  e_{i-1} \\vdash s_{i-1}\\trans{\\hyperref[fig:rules:chainhead]{chainhead}}{h_i} s'_{h}\n  $$\n  where $t_E$ is the maximum slot number appearing in the blocks contained in $E$.\n\\end{property}\n\nProperty~\\ref{prop:body-only-validation} states that if we validate a sequence\nof headers, we can validate their bodies independently and be sure that the\nblocks will pass the chain validation rule. To see this, given an environment\n$e$ and initial state $s$, assume that a sequence of headers\n$H = [h_0, \\ldots, h_n]$ corresponding to blocks in $E = [b_0, \\ldots, b_n]$ is\nvalid according to the $\\mathsf{chainhead}$ transition system:\n%\n$$\ne \\vdash s \\transtar{\\hyperref[fig:rules:chainhead]{chainhead}}{H} s'\n$$\n%\nAssume the bodies of $E$ are valid\naccording to the $\\mathsf{bbody}$ rules, but $E$ is not valid according to\nthe $\\mathsf{chain}$ rule. Assume that there is a $b_j \\in E$ such that it is\n\\textbf{the first block} such that does not pass the $\\mathsf{chain}$\nvalidation. Then:\n%\n$$\ne \\vdash s \\transtar{\\hyperref[fig:rules:chain]{chain}}{[b_0, \\ldots b_{j-1}]} s_j\n$$\nBut by Property~\\ref{prop:body-only-validation} we know that\n%\n$$\ne_j \\vdash s_j \\trans{\\hyperref[fig:rules:chainhead]{chainhead}}{h_j} s_{j+1}\n$$\nwhich means that block $b_j$ has valid headers, and this in turn means that the\nvalidation of $b_j$ according to the chain rules must have failed because it\ncontained an invalid block body. But this contradicts our assumption that the\nblock bodies were valid.\n\n\\begin{property}[Existence of roll back function]\\label{prop:roll-back-funk}\n  There exists a function $\\fun{f}$ such that for all chains\n  $$C = C_0 ; b; C_1$$\n  we have that if for all alternative chains $C'_1$, $\\size{C'_1} \\leq \\frac{\\StabilityWindow}{2}$, with\n  corresponding headers $H'_1$\n  $$\n  e \\vdash s_0 \\transtar{\\hyperref[fig:rules:chain]{chain}}{C_0;b} s_1 \\transtar{\\hyperref[fig:rules:chain]{chain}}{C_1} s_2\n  \\wedge\n  e \\vdash s_1 \\transtar{\\hyperref[fig:rules:chain]{chain}}{C_1'} s'_1\n  \\implies\n  (\\fun{f}~(\\bheader{b})~s_2) \\transtar{\\hyperref[fig:rules:chainhead]{chainhead}}{H'_1} s_h\n  $$\n\\end{property}\n\nProperty~\\ref{prop:roll-back-funk} expresses the fact the there is a function\nthat allow us to recover the header-only state by rolling back at most $k$\nblocks, and use this state to validate the headers of an alternate chain. Note\nthat this property is not inherent to the $\\mathsf{chain}$ rules and can be\ntrivially satisfied by any function that keeps track of the history of the\nintermediate chain states up to $k$ blocks back. This property is stated here\nso that it can be used as a reference for the tests in the consensus layer,\nwhich uses the rules presented in this document.\n\n\n\\subsection{Validity of a Ledger State}\n\\label{sec:valid-ledg-state}\n\nMany properties only make sense when applied to a valid ledger state. In\ninformal terms, a valid ledger state $l$ can only be reached when starting from\nan initial state $l_{0}$ (ledger in the genesis state) and only executing LEDGER\nstate transition rules as specified in Section~\\ref{sec:ledger-trans} which\nchanges wither the  UTxO or the delegation state.\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{align*}\n    \\genesisId & \\in & \\TxId \\\\\n    \\genesisTxOut & \\in & \\TxOut \\\\\n    \\genesisUTxO & \\coloneqq & (\\genesisId, 0) \\mapsto \\genesisTxOut\n    \\\\\n    \\ledgerState & \\in & \\left(\n                         \\begin{array}{c}\n                           \\UTxOState \\\\\n                           \\DPState\n                         \\end{array}\n    \\right)\\\\\n               && \\\\\n    \\fun{getUTxO} & \\in & \\UTxOState \\to \\UTxO \\\\\n    \\fun{getUTxO} & \\coloneqq & (\\var{utxo}, \\wcard, \\wcard, \\wcard) \\to \\var{utxo}\n  \\end{align*}\n  \\caption{Definitions and Functions for Valid Ledger State}\n  \\label{fig:valid-ledger}\n\\end{figure}\n\nIn Figure~\\ref{fig:valid-ledger} \\genesisId{} marks the transaction identifier\nof the initial coin distribution, where \\genesisTxOut{} represents the initial\nUTxO. It should be noted that no corresponding inputs exists, i.e., the\ntransaction inputs are the empty set for the initial transaction. The function\n\\fun{getUTxO} extracts the UTxO from a UTxO state.\n\n\\begin{definition}[\\textbf{Valid Ledger State}]\n  \\begin{multline*}\n    \\forall l_{0},\\ldots,l_{n} \\in \\LState, lenv_{0},\\ldots,lenv_{n} \\in \\LEnv,\n    l_{0} = \\left(\n      \\begin{array}{c}\n        \\genesisUTxOState \\\\\n        \\left(\n        \\begin{array}{c}\n          \\emptyset\\\\\n          \\emptyset\n        \\end{array}\n        \\right)\n      \\end{array}\n    \\right)  \\\\\n    \\implies \\forall 0 < i \\leq n, (\\exists tx_{i} \\in \\Tx,\n    lenv_{i-1}\\vdash l_{i-1} \\trans{ledger}{tx_{i}} l_{i}) \\implies\n    \\applyFun{validLedgerState} l_{n}\n  \\end{multline*}\n  \\label{def:valid-ledger-state}\n\\end{definition}\n\nDefinition~\\ref{def:valid-ledger-state} defines a valid ledger state reachable\nfrom the genesis state via valid LEDGER STS transitions. This gives a\nconstructive rule how to reach a valid ledger state.\n\n\\subsection{Ledger Properties}\n\\label{sec:ledger-properties}\n\nThe following properties state the desired features of updating a valid ledger\nstate.\n\n\\begin{property}[\\textbf{Preserve Balance}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\LState: \\applyFun{validLedgerstate}{l},\n    l=(u,\\wcard,\\wcard,\\wcard), l' = (u',\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall \\var{tx} \\in \\Tx, lenv \\in\\LEnv, lenv \\vdash\\var{u} \\trans{utxow}{tx} \\var{u'} \\\\\n    \\implies \\applyFun{destroyed}{pc~utxo~stkCreds~rewards~tx} =\n    \\applyFun{created}{pc~stPools~tx}\n  \\end{multline*}\n  \\label{prop:ledger-properties-1}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-1} states that for each valid ledger $l$,\nif a transaction $tx$ is added to the ledger via the state transition rule UTXOW\nto the new ledger state $l'$, the balance of the UTxOs in $l$ equals the balance\nof the UTxOs in $l'$ in the sense that the amount of created value in $l'$\nequals the amount of destroyed value in $l$. This means that the total amount of\nvalue is left unchanged by a transaction.\n\n\\begin{property}[\\textbf{Preserve Balance Restricted to TxIns in Balance of\n    TxOuts}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l=(u,\\wcard,\\wcard,\\wcard), l' = (u',\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall \\var{tx} \\in \\Tx, lenv \\in\\LEnv, lenv \\vdash \\var{u}\n    \\trans{utxow}{tx} \\var{u'} \\\\\n    \\implies \\fun{ubalance}(\\applyFun{txins}{tx} \\restrictdom\n    \\applyFun{getUTxO}{u}) = \\fun{ubalance}(\\applyFun{outs}{tx}) +\n    \\applyFun{txfee}{tx} + depositChange\n  \\end{multline*}\n  \\label{prop:ledger-properties-2}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-2} states a slightly more detailed relation\nof the balances change. For ledgers $l, l'$ and a transaction $tx$ as above, the\nbalance of the UTxOs of $l$ restricted to those whose domain is in the set of\ntransaction inputs of $tx$ equals the balance of the transaction outputs of $tx$\nminus the transaction fees and the change in the deposit\n$depositChange$~(cf.~Fig.~\\ref{fig:rules:utxo-shelley}).\n\n\\begin{property}[\\textbf{Preserve Outputs of Transaction}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l=(u,\\wcard,\\wcard,\\wcard), l' = (u',\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall \\var{tx} \\in \\Tx, lenv \\in\\LEnv, lenv \\vdash \\var{u}\n    \\trans{utxow}{tx} \\var{u'} \\implies \\forall \\var{out} \\in\n    \\applyFun{outs}{tx}, out \\in \\applyFun{getUTxO}{u'}\n  \\end{multline*}\n  \\label{prop:ledger-properties-3}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-3} states that for all ledger states\n$l, l'$ and transaction $tx$ as above, all output UTxOs of $tx$ are in the UTxO\nset of $l'$, i.e., they are now available as unspent transaction output.\n\n\\begin{property}[\\textbf{Eliminate Inputs of Transaction}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l=(u,\\wcard,\\wcard,\\wcard), l' = (u',\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall \\var{tx} \\in \\Tx, lenv \\in\\LEnv, lenv \\vdash \\var{u}\n    \\trans{utxow}{tx} \\var{u'} \\implies \\forall \\var{in} \\in\n    \\applyFun{txins}{tx}, in \\not\\in \\fun{dom}(\\applyFun{getUTxO}{u'})\n  \\end{multline*}\n  \\label{prop:ledger-properties-4}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-4} states that for all ledger states\n$l, l'$ and transaction $tx$ as above, all transaction inputs $in$ of $tx$ are\nnot in the domain of the UTxO of $l'$, i.e., these are no longer available to\nspend.\n\n\\begin{property}[\\textbf{Completeness and Collision-Freeness of new Transaction\n    Ids}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l=(u,\\wcard,\\wcard,\\wcard), l' = (u',\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall \\var{tx} \\in \\Tx, lenv \\in\\LEnv, lenv \\vdash \\var{u}\n    \\trans{utxow}{tx} \\var{u'} \\\\ \\implies \\forall ((txId', \\wcard) \\mapsto\n    \\wcard) \\in \\applyFun{outs}{tx}, ((txId, \\wcard) \\mapsto \\wcard)\n    \\in\\applyFun{getUTxO}{u} \\implies \\var{txId'} \\neq \\var{txId}\n  \\end{multline*}\n  \\label{prop:ledger-properties-5}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-5} states that for ledger states $l, l'$\nand a transaction $tx$ as above, the UTxOs of $l'$ contain all newly created\nUTxOs and the referred transaction id of each new UTxO is not used in the UTxO\nset of $l$.\n\n\\begin{property}[\\textbf{Absence of Double-Spend}]\n  \\begin{multline*}\n    \\forall l_{0},\\ldots,l_{n} \\in \\ledgerState, l_{0} =\n    \\left(\n      \\begin{array}{c}\n        \\left\\{\n        \\genesisUTxO\n        \\right\\} \\\\\n        \\left(\n        \\begin{array}{c}\n          \\emptyset\\\\\n          \\emptyset\n        \\end{array}\n        \\right)\n      \\end{array}\n    \\right) \\wedge \\applyFun{validLedgerState} l_{n}, l_{i}=(u_{i},\\wcard,\\wcard,\\wcard)\\\\\n    \\implies \\forall 0 < i \\leq n, tx_{i} \\in \\Tx, lenv_{i}\\in\\LEnv,\n    lenv_{i} \\vdash u_{i-1}\n    \\trans{ledger}{tx_{i}} u_{i} \\wedge \\applyFun{validLedgerState} l_{i} \\\\\n    \\implies \\forall j < i, \\applyFun{txins}{tx_{j}} \\cap\n    \\applyFun{txins}{tx_{i}} = \\emptyset\n  \\end{multline*}\n  \\label{prop:ledger-properties-no-double-spend}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-no-double-spend} states that for each valid\nledger state $l_{n}$ reachable from the genesis state, each transaction $t_{i}$\ndoes not share any input with any previous transaction $t_{j}$. This means that\neach output of a transition is spent at most once.\n\n\\subsection{Ledger State Properties for Delegation Transitions}\n\\label{sec:ledg-prop-deleg}\n\n\\begin{figure}[ht]\n  \\centering\n  \\begin{align*}\n    \\fun{getStDelegs} & \\in & \\DState \\to \\powerset \\Credential \\\\\n    \\fun{getStDelegs} & \\coloneqq &\n                                    ((\\var{stkCreds}, \\wcard,\n                                    \\wcard,\\wcard,\\wcard,\\wcard) \\to \\var{stkCreds} \\\\\n                      &&\\\\\n    \\fun{getRewards} & \\in & \\DState \\to (\\AddrRWD \\mapsto \\Coin) \\\\\n    \\fun{getRewards} & \\coloneqq & (\\wcard, \\var{rewards},\n                                   \\wcard,\\wcard,\\wcard,\\wcard)\n                                   \\to \\var{rewards} \\\\\n                      &&\\\\\n    \\fun{getDelegations} & \\in & \\DState \\to (\\Credential \\mapsto \\KeyHash) \\\\\n    \\fun{getDelegations} & \\coloneqq & (\\wcard, \\wcard,\n                                       \\var{delegations},\\wcard,\\wcard,\\wcard) \\to\n                                       \\var{delegations} \\\\\n                      &&\\\\\n    \\fun{getStPools} & \\in & \\LState \\to (\\KeyHash \\mapsto \\DCertRegPool) \\\\\n    \\fun{getStPools} & \\coloneqq & (\\wcard, (\\wcard,\n                                   (\\var{stpools},\\wcard,\\wcard,\\wcard))) \\to \\var{stpools} \\\\\n                      &&\\\\\n    \\fun{getRetiring} & \\in & \\LState \\to (\\KeyHash \\mapsto \\Epoch) \\\\\n    \\fun{getRetiring} & \\coloneqq & (\\wcard, (\\wcard,\n                                    (\\wcard, \\wcard, \\var{retiring},\\wcard))) \\to \\var{retiring} \\\\\n  \\end{align*}\n  \\caption{Definitions and Functions for Stake Delegation in Ledger States}\n  \\label{fig:stake-delegation-functions}\n\\end{figure}\n\n\n\\begin{property}[\\textbf{Registered Staking Credential with Zero Rewards}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l = (\\wcard, ((d, \\wcard), \\wcard)), l' = (\\wcard, ((d',\\wcard), \\wcard)), dEnv\\in\\DEnv \\\\\n    \\implies \\forall \\var{c} \\in \\DCertRegKey, dEnv\\vdash \\var{d}\n    \\trans{deleg}{c} \\var{d'} \\implies \\applyFun{cwitness}{c} = \\var{hk}\\\\\n    \\implies hk\\not\\in \\fun{getStDelegs}~\\var{d} \\implies \\var{hk} \\in\n    \\applyFun{getStDelegs}{d'} \\wedge\n    (\\applyFun{getRewards}\\var{d'})[\\fun{addr_{rwd}}{hk}] = 0\n  \\end{multline*}\n  \\label{prop:ledger-properties-6}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-6} states that for each valid ledger state\n$l$, if a delegation transaction of type $\\DCertRegKey$ is executed, then in the\nresulting ledger state $l'$, the set of staking credential of $l'$ includes the\ncredential $hk$ associated with the key registration certificate and the\nassociated reward is set to 0 in $l'$.\n\n\\begin{property}[\\textbf{Deregistered Staking Credential}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l = (\\wcard, (d, \\wcard)), l' = (\\wcard, (d', \\wcard)), dEnv\\in\\DEnv \\\\\n    \\implies \\forall \\var{c} \\in \\DCertDeRegKey, dEnv\\vdash\\var{d}\n    \\trans{deleg}{c} \\var{d'} \\implies \\applyFun{cwitness}{c} = \\var{hk}\\\\\n    \\implies \\var{hk} \\not\\in \\applyFun{getStDelegs}{d'} \\wedge hk\\not\\in\n    \\left\\{ \\fun{stakeCred_{r}}~sc\\vert\n      sc\\in\\fun{dom}(\\applyFun{getRewards}{d'})\n    \\right\\}\\\\\n    \\wedge hk \\not\\in \\fun{dom}(\\applyFun{getDelegations}{d'}))\n  \\end{multline*}\n  \\label{prop:ledger-properties-7}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-7} states that for $l, l'$ as above but\nwith a delegation transition of type $\\DCertDeRegKey$, the staking credential\n$hk$ associated with the deregistration certificate is not in the set of staking\ncredentials of $l'$ and is not in the domain of either the rewards or the\ndelegation map of $l'$.\n\n\\begin{property}[\\textbf{Delegated Stake}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l = (\\wcard, (d,\\wcard)), l' = (\\wcard, (d',\\wcard)), dEnv\\in\\DEnv \\\\\n    \\implies \\forall \\var{c} \\in \\DCertDeleg, dEnv \\vdash\\var{d}\n    \\trans{deleg}{c} \\var{d'} \\implies \\applyFun{cwitness}{c} = \\var{hk}\\\\\n    \\implies \\var{hk} \\in \\applyFun{getStDelegs}{d'} \\wedge\n    (\\applyFun{getDelegations}{d'})[hk] = \\applyFun{dpool}{c}\n  \\end{multline*}\n  \\label{prop:ledger-properties-8}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-8} states that for $l, l'$ as above but\nwith a delegation transition of type $\\DCertDeleg$, the staking credential $hk$\nassociated with the deregistration certificate is in the set of staking\ncredentials of $l$ and delegates to the staking pool associated with the\ndelegation certificate in $l'$.\n\n\\begin{property}[\\textbf{Genesis Keys are Always All Delegated}]\n  \\label{prop:genkeys-delegated}\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\LState: \\applyFun{validLedgerstate}{l},\\\\\n    \\implies \\forall \\Gamma \\in \\seqof{\\Tx}, env \\in (\\Slot \\times \\PParams), \\\\\n    env \\vdash\\var{l} \\trans{ledgers}{\\Gamma} \\var{l'} \\implies |genDelegs| = 7\n  \\end{multline*}\n\\end{property}\n\nProperty \\ref{prop:genkeys-delegated} states that all seven of the genesis keys\nare constantly all delegated after applying a list of transactions to a valid ledger\nstate.\n\n\\subsection{Ledger State Properties for Staking Pool Transitions}\n\\label{sec:ledg-state-prop}\n\n\\begin{property}[\\textbf{Registered Staking Pool}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState: \\applyFun{validLedgerstate}{l},\n    l = (\\wcard, (\\wcard, p)), l' = (\\wcard, (\\wcard, p')), pEnv\\in\\PEnv \\\\\n    \\implies \\forall \\var{c} \\in \\DCertRegPool, \\var{p} \\trans{pool}{c} \\var{p'}\n    \\implies \\applyFun{cwitness}{c} = \\var{hk}\\\\ \\implies\n    \\var{hk}\\in\\applyFun{getStPools}{p'} \\wedge \\var{hk} \\not\\in\n    \\applyFun{getRetiring}{p'}\n  \\end{multline*}\n  \\label{prop:ledger-properties-9}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-9} states that for $l, l'$ as above but\nwith a delegation transition of type $\\DCertRegPool$, the key $hk$ is associated\nwith the author of the pool registration certificate in $\\var{stpools}$ of $l'$\nand that $hk$ is not in the set of retiring stake pools in $l'$.\n\n\\begin{property}[\\textbf{Start Staking Pool Retirement}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState, \\var{cepoch} \\in \\Epoch:\n    \\applyFun{validLedgerstate}{l},\n    l = (\\wcard, (\\wcard,p)), l' = (\\wcard, (\\wcard,p')), pEnv\\in\\PEnv \\\\\n    \\implies \\forall \\var{c} \\in \\DCertRetirePool, pEnv\\vdash\\var{p}\n    \\trans{POOL}{c} \\var{p'} \\\\ \\implies e = \\applyFun{retire}{c} \\wedge\n    \\var{cepoch} < e < \\var{cepoch} + \\emax \\wedge \\applyFun{cwitness}{c} =\n    \\var{hk}\\\\ \\implies (\\applyFun{getRetiring}{p'})[\\var{hk}] = e \\wedge\n    \\var{hk} \\in\n    \\fun{dom}(\\applyFun{getStPools}{p})\\wedge\\fun{dom}(\\applyFun{getStPools}{p'}\n    )\n  \\end{multline*}\n  \\label{prop:ledger-properties-10}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-10} states that for $l, l'$ as above but\nwith a delegation transition of type $\\DCertRetirePool$, the key $hk$ is\nassociated with the author of the pool registration certificate in\n$\\var{stpools}$ of $l'$ and that $hk$ is in the map of retiring staking pools of\n$l'$ with retirement epoch $e$, as well as that $hk$ is in the map of stake\npools in $l$ and $l'$.\n\n\\begin{property}[\\textbf{Stake Pool Reaping}]\n  \\begin{multline*}\n    \\forall \\var{l}, \\var{l'} \\in \\ledgerState, \\var{e} \\in \\Epoch:\n    \\applyFun{validLedgerstate}{l},\\\\\n    l = (\\wcard, (d, p)), l' = (\\wcard, (d', p')), pp\\in\\PParams, acnt, acnt'\\in\\Acnt \\\\\n    \\implies pp\\vdash\\var{(acnt, d, p} \\trans{poolreap}{e} \\var{(acnt, d', p')}\n    \\implies \\forall \\var{retire}\\in{(\\fun{getRetiring}~p)}^{-1}[e], retire \\neq\n    \\emptyset \\\\ \\wedge \\var{retire} \\subseteq\n    \\fun{dom}(\\applyFun{getStPool}{p}) \\wedge\n    \\var{retire} \\cap\\fun{dom}(\\applyFun{getStPool}{p'})=\\emptyset \\\\\n    \\wedge\\var{retire} \\cap \\fun{dom}(\\applyFun{getRetiring}{p'}) = \\emptyset\n  \\end{multline*}\n  \\label{prop:ledger-properties-11}\n\\end{property}\n\nProperty~\\ref{prop:ledger-properties-11} states that for $l, l'$ as above but\nwith a delegation transition of type POOLREAP, there exist registered stake\npools in $l$ which are associated to stake pool registration certificates and\nwhich are to be retired at the current epoch $\\var{e}$. In $l'$ all those stake\npools are removed from the maps $stpools$ and $retiring$.\n\n\\subsection{Properties of Numerical Calculations}\n\\label{sec:prop-numer-calc}\n\nThe numerical calculations for refunds and rewards in\n(see Section~\\ref{sec:epoch}) are also required to have certain properties. In\nparticular we need to make sure that the functions that use non-integral\narithmetic have properties which guarantee consistency of the system. Here, we\nstate those properties and formulate them in a way that makes them usable in\nproperties-based testing for validation in the executable spec.\n\n\\begin{property}[\\textbf{Minimal Refund}]\n  \\label{prop:minimal-refund}\n\n  The function $\\fun{refund}$ takes a value, a minimal percentage, a decay\n  parameter and a duration. It must guarantee that the refunded amount is within\n  the minimal refund (off-by-one for rounding / floor) and the original value.\n\n  \\begin{multline*}\n    \\forall d_{val} \\in \\mathbb{N}, d_{min} \\in [0,1], \\lambda \\in (0, \\infty),\n    \\delta \\in \\mathbb{N} \\\\\n    \\implies \\max(0,d_{val}\\cdot d_{min} - 1) \\leq \\floor*{d_{val}\\cdot(d_{min} +\n      (1-d_{min})\\cdot e^{-\\lambda\\cdot\\delta})} \\leq d_{val}\n  \\end{multline*}\n\\end{property}\n\n\\begin{property}[\\textbf{Maximal Pool Reward}]\n  \\label{prop:maximal-pool-reward}\n\n  The maximal pool reward is the expected maximal reward paid to a stake\n  pool. The sum of all these rewards cannot exceed the total available reward,\n  let $Pool$ be the set of active stake pools:\n\n  \\begin{equation*}\n    \\forall R \\in Coin:\\sum_{p \\in Pools} \\floor*{\\frac{R}{1+p_{a_{0}}}\\cdot\n      \\left(\n        p_{\\sigma'}+p_{p'}\\cdotp_{a_{0}}\\cdot\\frac{p_{\\sigma'}-p_{p'}\\cdot\\frac{p_{z_{0}}-p_{\\sigma'}}{p_{z_{0}}}}{p_{z_{0}}}\n      \\right)}\\leq R\n  \\end{equation*}\n\\end{property}\n\n\\begin{property}[\\textbf{Actual Reward}]\n  \\label{prop:actual-reward}\n\n  The actual reward for a stake pool in an epoch is calculated by the function\n  $\\fun{poolReward}$. The actual reward per stake pool is non-negative and\n  bounded by the maximal reward for the stake pool, with $\\overline{p}$ being\n  the relation $\\frac{n}{\\max(1, \\overline{N})}$ of the number of produced\n  blocks $n$ of one pool to the total number $\\overline{N}$ of produced blocks\n  in an epoch and $maxP$ being the maximal reward for the stake pool. This gives\n  us:\n\n  \\begin{equation*}\n    \\forall \\gamma \\in [0,1] \\implies 0\\leq \\floor*{\\overline{p}\\cdot maxP} \\leq maxP\n  \\end{equation*}\n\\end{property}\n\nThe two functions $\\fun{r_{operator}}$ and $\\fun{r_{member}}$ are closely related as\nthey both split the reward between the pool leader and the members.\n\n\\begin{property}[\\textbf{Reward Splitting}]\n  \\label{prop:reward-splitting}\n\n  The reward splitting is done via $\\fun{r_{operator}}$ and $\\fun{r_{member}}$, i.e.,\n  a split between the pool leader and the pool members using the pool cost $c$\n  and the pool margin $m$. Therefore the property relates the total reward\n  $\\hat{f}$ to the split rewards in the following way:\n\n  \\begin{multline*}\n    \\forall m\\in [0,1], c\\in Coin \\implies c + \\floor*{(\\hat{f} - c)\\cdot (m +\n      (1 - m)) \\cdot \\frac{s}{\\sigma}} + \\sum_{j}\\floor*{(\\hat{f} -\n      c)\\cdot(1-m)\\cdot\\frac{t_{j}}{\\sigma}} \\leq \\hat{f}\n  \\end{multline*}\n\n\\end{property}\n\n\\clearpage\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: \"ledger-spec\"\n%%% End:\n", "meta": {"hexsha": "b444fbf144fb0e40ffa85ce5103daba19e0b7b48", "size": 54429, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "shelley/chain-and-ledger/formal-spec/properties.tex", "max_stars_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_stars_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "shelley/chain-and-ledger/formal-spec/properties.tex", "max_issues_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_issues_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "shelley/chain-and-ledger/formal-spec/properties.tex", "max_forks_repo_name": "SebastienGllmt/cardano-ledger-specs", "max_forks_repo_head_hexsha": "4e65f6e3f966659b69865fd6bcfe9caf3008b820", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2257564003, "max_line_length": 165, "alphanum_fraction": 0.6561575631, "num_tokens": 18430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4005031007151799}}
{"text": "%%%%%%%%%%%%%%%%%%%%%definitions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n\\input{../../doc/related_pages/header.tex}\r\n\\input{../../doc/related_pages/newcommands.tex}\r\n\\usepackage{minted}\r\n\r\n\\renewcommand{\\ne}{\\ensuremath{n }}\r\n\\newcommand{\\Ni}{\\ensuremath{N}}\r\n\\newcommand{\\ue}{\\ensuremath{u_\\parallel}}\r\n\\newcommand{\\Ui}{\\ensuremath{U_\\parallel}}\r\n\\newcommand{\\Apar}{\\ensuremath{A_\\parallel}}\r\n\\newcommand{\\bperp}{\\ensuremath{ \\vec b_\\perp}}\r\n\\newcommand{\\neref}{\\ensuremath{n_0}}\r\n\\newcommand{\\Teref}{\\ensuremath{T_{e0}}} %\\rhoN\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DOCUMENT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\\begin{document}\r\n\r\n\\title{Collisionless Reconnection}\r\n\\author{ M.~Held and M.~Wiesenberger}\r\n\\maketitle\r\n\r\n\\begin{abstract}\r\n\\end{abstract}\r\n\r\n\\section{Compilation and Usage}\r\nInput file format: json\\\\\r\nOutput file format: NetCDF-4\\\\\r\nFile path: \\texttt{feltor/src/reco2D/}\r\n\\begin{verbatim}\r\nmake reconnection device = <omp gpu>\r\nmake reconnection_hpc device = <omp gpu>\r\nmake reconnection_mpi device = <omp gpu>\r\n\\end{verbatim}\r\n\\texttt{reconnection} depends on both GLFW3 and NETCDF, while\r\n\\texttt{reconnection\\_hpc} and \\texttt{reconnection\\_mpi} avoids the GLFW3 dependency and only operate with ``netcdf'' output.\r\nRun with\r\n\\begin{verbatim}\r\npath/to/feltor/src/reco2D/reconnection(_hpc) input.json <output.nc>\r\n\\end{verbatim}\r\nThe output file is only needed if you chose ``netcdf'' in the output field\r\nof the input file.\r\n\\begin{verbatim}\r\necho 2 2 | mpirun -n 4 path/to/feltor/src/reco2D/reconnection_mpi input.json output.nc\r\n\\end{verbatim}\r\nFor the mpi program you need to provide the distribution of processes along each\r\naxis on the command line.\r\n\r\n\\section{Equations}\r\n%tearing instability <-> reconnection\r\nCollisionless reconnection was studied in~\\cite{Stanier2015}, gyro-fluid and gyro-kinetic studies~\\cite{Comisso2013,Zacharias2014}.\r\nOur reduced model is based on a recent formulation of a full-F gyro-fluid model~\\cite{Madsen2013}.\r\nIt consists of the first two moment equations for electrons and ions\r\n\\begin{align}\r\n%%%\r\n\\frac{\\partial}{\\partial t} \\ne\r\n+ \\nc\\left( \\ne (\\vec u_E + \\ue \\vec b_\\perp) \\right)=& 0\r\n\\\\\r\n%%%\r\n\\label{firstgyromom}\r\n\\frac{\\partial}{\\partial t} \\Ni \r\n+ \\nc\\left( \\Ni (\\vec u_E^i + \\Ui \\vec b_\\perp^i) \\right)=& 0\r\n \\\\\r\n %%%\r\n    \\mu_e \\frac{\\partial}{\\partial t} \\left( \\ne\\ue \\right)\r\n+  \\mu_e \\nc\\left( \\left(\\vec u_E+ \\ue\\vec b_\\perp\\right) \\ne\\ue \\right) =&\r\n- \\tau_e \\vec b_\\perp\\cn\\ne - \\ne\\left(\\vec b_\\perp\\cn\\phi +\\frac{\\partial}{\\partial t}\\Apar\\right)\r\n      \\\\\r\n%%%\r\n  \\mu_i\\frac{\\partial}{\\partial t} \\left( \\Ni\\Ui \\right)\r\n      +  \\mu_i\\nc\\left( \\left(\\vec u_E^i + \\Ui \\vec b_\\perp^i\\right) \\Ni\\Ui \\right) =&\r\n      - \\tau_i  \\vec b_\\perp^i \\cn \\Ni - \\Ni \\left(\\vec b_\\perp \\cn \\psi + \\frac{\\partial}{\\partial t} \\Gamma_1\\Apar\\right)\r\n\\end{align}\r\nwhere\r\n$\\vec u_E := \\zhat \\times \\nabla\\phi = [-\\partial_y \\phi,\\ \\partial_x \\phi]$ and\r\n$\\bperp := \\nabla \\Apar \\times \\zhat = [\\partial_y \\Apar,\\ -\\partial_x \\Apar]$.\r\n\r\nThe equations are coupled by polarisation and induction\r\n\\begin{align}\r\n -\\ne + \\Gamma_1 \\Ni &= -\\vec{\\nabla}\\cdot\\left(\\Ni \\vec{\\nabla}_\\perp \\phi\\right) \\\\\r\n -\\frac{1}{\\beta} \\vec{\\nabla}_\\perp^2 \\Apar &=  -\\ne \\ue + \\Gamma_1 (\\Ni \\Ui)\r\n\\end{align}\r\nwhere the signs are such that the elliptic operators are positive definite and\r\nwith gyro-averaged parallel electromagnetic vector potential, generalized electric potential and gyro-averaging operator\r\n\\begin{align}\r\n \\psi &:= \\Gamma_1 \\phi - u_E^2 /2  \\\\\r\n  \\Gamma_1 &:= (1-\\frac{\\tau_i}{2} \\vec{\\nabla}_\\perp^2 )^{-1}\r\n\\end{align}\r\nand ion gyro-radius, vacuum permeability and ion gyrofrequency\r\n\\begin{align}\r\n  \\rho_{i}   := \\frac{\\sqrt{T_{i} m_i}}{e B} \\quad\r\n  \\mu_0 := 1/(\\epsilon_0 c^2) \\quad\r\n  \\Omega_i := e B / m_i\r\n\\end{align}\r\nAfter exploiting the gyro-Bohm normalisation, our model is controlled by the dimensionless parameters. These\r\nare the\r\n\\begin{align}\r\n \\mu   :=  \\frac{m}{Z m_i} \\quad\r\n \\tau  :=  \\frac{T}{ Z T_i}\\quad\r\n \\beta_{e0} :=  \\frac{\\mu_0 \\neref \\Teref }{ B_0^2 }\r\n\\end{align}\r\n\r\nInput file format: \\href{https://en.wikipedia.org/wiki/JSON}{json} \\\\\r\n\\begin{minted}[texcomments]{js}\r\n\"physical\" : // physical parameters\r\n{\r\n    \"mu\"   : -0.000544617, // the electron to ion mass ratio $\\mu_e$\r\n    \"tau\"  :  0.0,    // electron to ion temperature $\\tau_i$\r\n    \"beta\" :  1e-3    // plasma beta $\\beta$\r\n}\r\n\\end{minted}\r\n\r\n\\section{Initial and boundary conditions}\r\nThe boundary conditions for all variables are Dirichlet in $x$.\r\nThe $y$-direction is periodic.\r\n\r\nThe initial conditions are set in the file \\texttt{feltor/src/reco2D/init.h}.\r\n\r\nWe initialize\r\n\\begin{align}\r\n \\Ni&=\\ne=1 \\\\\r\n \\phi &= 0 \\\\\r\n  \\Ui&=0 \\\\\r\n  \\ue &= \\frac{1}{\\ne \\beta }\\vec{\\nabla}^2_{\\perp} \\Apar\r\n\\end{align}\r\nwhere we can choose $\\Apar$.\r\n\\subsection{Harris sheet}\r\nThe initial parallel magnetic vector potential is\r\n\\begin{align}\r\n    \\Apar =\\beta\\left( A_0 / \\cosh{( 4  \\pi x / L_x )}^2 +A_1\\cos{(2 m_y\\pi y/L_y)}\\right) \\cos( \\pi x /L_x)\r\n\\end{align}\r\nThe harris sheet initial condition can be chosen with the following parameters in the input file\r\n\\begin{minted}[texcomments]{js}\r\n\"init\" : // Parameters for initialization\r\n{\r\n    \"type\" : \"harris\", // This choice necessitates the following parameters\r\n    \"amplitude0\"  : 0.1, // harris amplitude\r\n    \"amplitude1\"  : 1e-3, // perturbation amplitude (making this negative will\r\n    // shift the perturbation by an angle $\\pi$)\r\n    \"my\"  :  1    // perturbation wave number in y\r\n}\r\n\\end{minted}\r\nWe analytically compute the Laplacian of $\\Apar$ with the help of Mathematica.\r\n\\subsection{Island}\r\nThe initial parallel magnetic vector potential is\r\n\\begin{align}\r\n    \\Apar =\\beta \\left[ A_0\\frac{L_x}{4\\pi} \\ln \\left\\{ \\cosh( 4\\pi x/L_x) + \\varepsilon \\cos( 4\\pi y/L_x)\\right\\} + A_1\\cos{(2m_y \\pi y/L_y)}\\right] \\cos( \\pi x /L_x)\r\n\\end{align}\r\nwith $\\varepsilon = 0.2$.\r\nThe island initial condition can be chosen with the following parameters in the input file\r\n\\begin{minted}[texcomments]{js}\r\n\"init\" : // Parameters for initialization\r\n{\r\n    \"type\" : \"island\", // This choice necessitates the following parameters\r\n    \"amplitude0\"  : 0.1, // island amplitude\r\n    \"amplitude1\"  : 1e-3, // perturbation amplitude (making this negative will\r\n    // shift the perturbation by an angle $\\pi$)\r\n    \"my\"  :  1    // perturbation wave number in y\r\n}\r\n\\end{minted}\r\nWe analytically compute the Laplacian of $\\Apar$ with the help of Mathematica.\r\n(The island simulation takes approximately a factor 5 times smaller timestep than\r\nthe harris simulation).\r\n\r\n\\section{Invariants}\r\nThe mass density and diffusions are\r\n\\begin{align}\r\n    \\mathcal M &= \\ne \\\\\r\n    \\vec j_n &= \\ne \\vec u_E + \\ne\\ue\\bperp \\\\\r\n     \\Lambda_n &= -\\nu_\\perp \\Delta_\\perp^2 \\ne\r\n\\end{align}\r\n\\begin{tcolorbox}[title=Note]\r\n    We already incorporate the artificial diffusion terms defined in\r\n    Section~\\ref{sec:regularization}\r\n\\end{tcolorbox}\r\n\r\nThe inherent energy density of our system is:\r\n\\begin{align}\r\n \\mathcal{E} := &\r\n                    \\ne \\ln{(\\ne)}\r\n                  + \\tau_i \\Ni \\ln{( \\Ni)}\r\n                  \\nonumber \\\\\r\n                 &- \\frac{1}{2} \\mu_e \\ne \\ue^2\r\n                  + \\frac{1}{2} \\Ni \\Ui^2\r\n                  \\nonumber \\\\\r\n                 &+\\frac{1}{2} \\Ni u_E^2\r\n                  + \\frac{|\\nabla_\\perp \\Apar|^2}{2 \\beta}\r\n\\end{align}\r\nThe energy current density and diffusion are\r\n\\begin{align}\r\n  \\vec j_{\\mathcal E} =& \\sum_s z\\left[\r\n  \\left(\\tau \\ln N + \\frac{1}{2}\\mu U_\\parallel^2 + \\psi \\right)N\\left(\r\n  \\vec u_E +U_\\parallel\\bperp  \\right) + \\tau NU_\\parallel \\bperp\\right]\r\n  , \\\\\r\n    \\Lambda_\\mathcal{E} :=  &\\left( (1+\\ln \\ne) + \\frac{1}{2} z_e \\mu_e \\ue^2 - \\phi \\right) (-\\nu_\\perp \\Delta_\\perp^2 \\ne)\r\n    \\nonumber\\\\\r\n    &+ \\left( \\tau_i ( 1+\\ln \\Ni) + \\frac{1}{2} \\Ui^2 + \\psi_i\\right)(-\\nu_\\perp \\Delta_\\perp^2 \\Ni)\r\n    \\nonumber\\\\\r\n    &+ z_e\\mu_e \\ue\\ne (-\\nu_\\perp \\Delta_\\perp^2 \\ue)\r\n    \\nonumber\\\\\r\n    &+ \\Ui\\Ni (-\\nu_\\perp \\Delta_\\perp^2 \\Ui)\r\n    \\label{eq:energy_diffusion}\r\n\\end{align}\r\nwhere in the energy flux $\\vec j_{\\mathcal E}$\r\nwe neglect terms  containing time derivatives\r\nof the eletric and magnetic potentials and we sum over all species.\r\n\r\nWith our choice of boundary conditions both the mass as well as the energy flux\r\nvanishes on the boundary. In the absence of artificial viscosity the volume integrated\r\nmass and energy density are thus exact invariants of the system.\r\n\\begin{tcolorbox}[title=Note]\r\n    For the canonical-viscosity scheme the viscosity terms in the last two\r\n    terms of Eq.~\\eqref{eq:energy_diffusion} change to the canonical velocity.\r\n\\end{tcolorbox}\r\n\r\n\r\n\\section{Reconnection rate}\r\n A consistent definition of the reconnection rate is not trivial~\\cite{Comisso2016}.\r\n We adopt a similar definiton as in Ref.~\\cite{Comisso2013}\r\n\\begin{align}\r\n    Q_X&:= \\Apar(\\vec{x}_X,t) - \\Apar( \\vec{x}_X,0) \\\\\r\n \\gamma&:= \\frac{1}{Q_X}\\frac{\\d Q_X}{\\d t} = \\frac{\\d \\ln{|Q_X|}}{\\d t}\r\n\\end{align}\r\nwhere $\\vec{x}_X = [0,0]$.\r\nThis can be easily evaluated in post-processing using a python script.\r\n\r\n\\section{Numerical methods}\r\n\r\n\\subsection{Spatial grid}\r\nThe spatial grid is a two-dimensional Cartesian product-grid $[-L_x/2, L_x/2]\\times [-L_y/2, L_y/2]$ adaptable with the following parameters\r\n\\begin{minted}[texcomments]{js}\r\n\"grid\" :\r\n{\r\n    \"n\"  :  3, // The number of polynomial coefficients\r\n    \"Nx\"  : 48, // Number of cells in x\r\n    \"Ny\"  : 48, // Number of cells in y\r\n    \"lxhalf\"  : 80.0, // Half box length in x\r\n    \"lyhalf\"  : 80.0, // Half box length in y\r\n}\r\n\\end{minted}\r\n\\subsection{Timestepper}\r\nThe time stepper can be an explicit multistep method where you can chose the\r\ntableau to use\r\n\\begin{minted}[texcomments]{js}\r\n\"timestepper\" :\r\n{\r\n    \"type\"    : \"multistep\", //Choose an explicit multistep method\r\n    \"tableau\" : \"TVB-3-3\", //  Any explicit multistep tableau *\r\n    \"dt\"      : 20.0, // Fixed timestep\r\n}\r\n\\end{minted}\r\n*See the \\href{https://feltor-dev.github.io/doc/dg/html/structdg_1_1_explicit_multistep.html}{dg documentation} for what tableaus are available.\r\nThe second option is an adaptive explicit embedded Runge-Kutta scheme\r\n\\begin{minted}[texcomments]{js}\r\n\"timestepper\":\r\n{\r\n    \"type\"    : \"adaptive\", //Choose an explicit adaptive RK scheme\r\n    \"tableau\" : \"Tsitouras09-7-4-5\", // Any explicit embedded RK tableau *\r\n    \"rtol\"    : 1e-7, // The relative tolerance in the timestep\r\n    \"atol\"    : 1e-10 // The absolute tolerance in the timestep\r\n}\r\n\\end{minted}\r\n*See the \\href{https://feltor-dev.github.io/doc/dg/html/structdg_1_1_e_r_k_step.html}{dg documentation} for what tableaus are available.\r\n\r\n\\subsection{Advection scheme}\r\n\\begin{minted}[texcomments]{js}\r\n\"advection\":\r\n{\r\n    \"type\" : \"arakawa\" // The Arakawa bracket scheme\r\n    //note that this should only be used in connection with artificial diffusion\r\n}\r\n\\end{minted}\r\nWe implemented the advection in terms of Arakawa brackets\r\n\\begin{align}\r\n%%%\r\n\\frac{\\partial}{\\partial t} \\ne =&\r\n - \\left[\\phi, \\ne\\right]\r\n+ \\left[\\Apar,\\ne \\ue  \\right]\r\n\\\\\r\n%%%\r\n\\label{firstgyromom}\r\n\\frac{\\partial}{\\partial t} \\Ni =&\r\n - \\left[\\psi, \\Ni\\right]\r\n+ \\left[\\Gamma_1 \\Apar ,\\Ni \\Ui  \\right]\r\n \\\\\r\n %%%\r\n\\frac{\\partial}{\\partial t} \\left( \\ue+ \\frac{1}{\\mu_e} \\Apar \\right) =&\r\n      -  \\left[ \\phi, \\ue+ \\frac{1}{\\mu_e} \\Apar  \\right]% \\nonumber \\\\\r\n    +   \\left[\\Apar,\\ue^2/2   \\right]% \\nonumber \\\\\r\n      - \\frac{1}{\\mu_e}  \\left[\\Apar,\\ln{\\ne}   \\right]\r\n      \\\\\r\n      \\frac{\\partial}{\\partial t} \\left( \\Ui+ \\Gamma_1 \\Apar  \\right) =&\r\n      -  \\left[ \\psi, \\Ui+ \\Gamma_1 \\Apar  \\right]% \\nonumber \\\\\r\n     +   \\left[\\Gamma_1 \\Apar,\\Ui^2/2   \\right]% \\nonumber \\\\\r\n      + \\tau_i  \\left[\\Gamma_1 \\Apar,\\ln{\\Ni}   \\right]\r\n\\end{align}\r\n\r\n\\begin{minted}[texcomments]{js}\r\n\"advection\":\r\n{\r\n    \"type\" : \"upwind\"  // The upwind scheme\r\n}\r\n\\end{minted}\r\nFor the upwind scheme we first rewrite the equations in terms of\r\n$\\vec u_E := \\zhat \\times \\nabla\\phi = [-\\partial_y \\phi,\\ \\partial_x \\phi]$ and\r\n$\\bperp := \\nabla \\Apar \\times \\zhat = [\\partial_y \\Apar,\\ -\\partial_x \\Apar]$. We use\r\nthat $\\nc \\vec u_E = \\nc \\bperp =0$\r\n\\begin{align}\r\n%%%\r\n\\frac{\\partial}{\\partial t} \\ne =&\r\n- ( \\vec u_E + \\ue \\bperp)\\cn \\ne - \\ne \\bperp \\cn  \\ue\r\n\\\\\r\n%%%\r\n\\frac{\\partial}{\\partial t} \\Ni =&\r\n- ( \\vec u_E^i + \\Ui \\bperp^i)\\cn \\Ni - \\Ni \\bperp^i\\cn  \\Ui\r\n \\\\\r\n %%%\r\n\\frac{\\partial}{\\partial t} \\left( \\ue+ \\frac{1}{\\mu_e} \\Apar \\right) =&\r\n-  (\\vec u_E + \\ue \\bperp ) \\cn \\ue\r\n+ \\frac{1}{\\mu_e} \\bperp \\cn \\ln \\ne\r\n- \\frac{1}{\\mu_e} \\bperp \\cn \\phi\r\n      \\\\\r\n      \\frac{\\partial}{\\partial t} \\left( \\Ui+ \\Gamma_1 \\Apar  \\right) =&\r\n    - (\\vec u_E^i + \\Ui \\bperp^i ) \\cn \\Ui\r\n    - \\tau_i \\bperp^i \\cn \\ln \\Ni\r\n    - \\bperp^i \\cn \\psi\r\n\\end{align}\r\nwhere the $i$ index signifies that $\\vec u_E$ respectively $\\bperp$ are to\r\nbe evaluated using the ion potentials $\\psi$ and $\\Apar$.\r\n\\begin{tcolorbox}[title=Note]\r\n    We also tried to use the conservative upwind scheme, where the density equation\r\n    is discretized in divergence form together with an interpolated multiplication\r\n    scheme. This however was completely unstable for the harris sheet.\r\n\\end{tcolorbox}\r\n\\subsection{Regularization} \\label{sec:regularization}\r\nIn order to prevent shocks and regularize the advection scheme\r\nwe implement an artificial viscosity of order 2.\r\n\\begin{align}\r\n%%%\r\n    \\frac{\\partial}{\\partial t} \\ne =& \\ldots -\\nu_\\perp \\Delta_\\perp^2 \\ne\r\n\\\\\r\n%%%\r\n\\frac{\\partial}{\\partial t} \\Ni =& \\ldots -\\nu_\\perp \\Delta_\\perp^2 \\Ni\r\n \\\\\r\n %%%\r\n\\frac{\\partial}{\\partial t} \\left( \\ue+ \\frac{1}{\\mu_e} \\Apar \\right) =&\r\n\\ldots -\\nu_\\perp \\Delta_\\perp^2 \\ue\r\n      \\\\\r\n      \\frac{\\partial}{\\partial t} \\left( \\Ui+ \\Gamma_1 \\Apar  \\right) =& \\ldots -\\nu_\\perp \\Delta_\\perp^2 \\Ui\r\n\\end{align}\r\nRegularly we apply the artificial viscosity to the parallel velocities. However,\r\nwe can also apply it to the canonical velocity:\r\n\\begin{align}\r\n %%%\r\n\\frac{\\partial}{\\partial t} \\left( \\ue+ \\frac{1}{\\mu_e} \\Apar \\right) =&\r\n\\ldots -\\nu_\\perp \\Delta_\\perp^2 \\left( \\ue+ \\frac{1}{\\mu_e} \\Apar \\right)\r\n      \\\\\r\n      \\frac{\\partial}{\\partial t} \\left( \\Ui+ \\Gamma_1 \\Apar  \\right) =& \\ldots -\\nu_\\perp \\Delta_\\perp^2 \\left( \\Ui+ \\Gamma_1 \\Apar  \\right)\r\n\\end{align}\r\n\r\n\\begin{minted}[texcomments]{js}\r\n\"regularization\",\r\n{\r\n    \"type\" : \"velocity-viscosity\",  // Apply viscosity on density and\r\n    // parel velocity\r\n    \"type\" : \"canonical-viscosity\",  // Apply viscosity on density and\r\n    // parallel canonical velocity\r\n    \"direction\" : \"centered\",  // The direction of the Laplacian\r\n    \"nu_perp\" : 1e-6 // The strength of the diffusion\r\n}\r\n\\end{minted}\r\nSimply set the diffusion to 0 if you do not want any regularization.\r\n\\begin{tcolorbox}[title=Note]\r\n    If you set nu\\_perp too large the timestep in the explicit timestepper will\r\n    have to be very small due to the restrictive CFL condition. At the same\r\n    time in our experience having to make the timestep smaller due to viscosity\r\n    is a clear warning that nu\\_perp is too large for the chosen resolution.\r\n    Chose nu\\_perp as large as you can without decreasing the timestep.\r\n\\end{tcolorbox}\r\n\r\n\\subsection{Elliptic solvers}\r\nIn order to solve the elliptic equations we chose a multigrid scheme (nested\r\niterations). The accuaracies for the polarization equation can be chosen for\r\neach stage separately, while for the Helmholtz type equations (The gamma\r\noperators and the Ampere equation) only one accuracy can be set:\r\n\\begin{minted}[texcomments]{js}\r\n\"elliptic\",\r\n{\r\n    \"stages\"    : 3,  // Number of stages (3 is best in virtually all cases)\r\n    \"eps_pol\"   : [1e-6,10,10],\r\n    // Accuracy requirement on each stage of the\r\n    // multigrid scheme. $\\eps_0 = \\eps_{pol,0}$, $\\eps_i = \\eps_{pol,i} \\eps_{pol,0}$  for $i>1$. \\\\\r\n    \"eps_gamma\" : 1e-10, // Accuracy requirement of Gamma operator on density\r\n    \"eps_maxwell\": 1e-7, //Accuracy requirement of Ampere equation\r\n    \"direction\" : \"forward\", // Direction of the Laplacian: forward or centered\r\n    \"jumpfactor\" : 1.0\r\n    // Jump factor of Laplacian in polarization, Gamma and Ampere equations\r\n}\r\n\\end{minted}\r\n\r\n%..................................................................\r\n\\section{Output}\r\nOur program can either write results directly to screen using the glfw library\r\nor write results to disc using netcdf.\r\nThis can be controlled via\r\n\\begin{minted}[texcomments]{js}\r\n\"output\":\r\n{\r\n    // Use glfw to display results in a window while computing (requires to\r\n    // compile with the glfw3 library)\r\n    \"type\"  : \"glfw\"\r\n    \"itstp\"  : 4, // The number of steps between outputs of 2d fields\r\n\r\n    // Use netcdf to write results into a file (filename given on command line)\r\n    // (see next section for information about what is written in there)\r\n    \"type\"  : \"netcdf\"\r\n    \"itstp\"  : 4,    // The number of steps between outputs of 2d fields\r\n    \"maxout\"  : 500, // The total number of field outputs. The endtime is\r\n    // T=itstp*maxout*dt\r\n    \"n\"  : 3 , // The number of polynomial coefficients in the output file\r\n    \"Nx\" : 48, // Number of cells in x in the output file\r\n    \"Ny\" : 48  // Number of cells in y in the output file\r\n}\r\n\\end{minted}\r\nThe number of points in the output file can be lower (or higher) than the number of\r\ngrid points used for the calculation. The points will be interpolated from the\r\ncomputational grid.\r\n\\subsection{Netcdf file}\r\nOutput file format: netcdf-4/hdf5\r\n\r\n\\begin{longtable}{lll>{\\RaggedRight}p{7cm}}\r\n\\toprule\r\n\\rowcolor{gray!50}\\textbf{Name} &  \\textbf{Type} & \\textbf{Dimension} & \\textbf{Description}  \\\\ \\midrule\r\ninputfile        & text attribute & 1 & verbose input file as a string \\\\\r\ntime             & Coord. Var. & 1 (time) & time at which fields are written \\\\\r\nx                & Coord. Var. & 1 (x) & x-coordinate  \\\\\r\ny                & Coord. Var. & 1 (y) & y-coordinate \\\\\r\nxc               & Dataset & 2 (y,x) & Cartesian x-coordinate  \\\\\r\nyc               & Dataset & 2 (y,x) & Cartesian y-coordinate \\\\\r\nX                & Dataset & 3 (time, y, x) & 2d outputs \\\\\r\nX\\_1d            & Dataset & 1 (time) & 1d volume integrals $\\int \\dV X$ \\\\\r\ntime\\_per\\_step  & Dataset & 1 (time) & Average computation time for one step \\\\\r\n\\bottomrule\r\n\\end{longtable}\r\nThe output fields X are determined in the file \\texttt{feltor/src/reco2D/diag.h}.\r\n\r\n%..................................................................\r\n\\bibliography{../../doc/related_pages/references, references}\r\n%..................................................................\r\n\\end{document}\r\n", "meta": {"hexsha": "1c6b88e6bf1c14c6cc6deff131099f95587dfd19", "size": 18591, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/reco2D/reconnection.tex", "max_stars_repo_name": "RaulGerru/FELTOR_FINAL", "max_stars_repo_head_hexsha": "dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reco2D/reconnection.tex", "max_issues_repo_name": "RaulGerru/FELTOR_FINAL", "max_issues_repo_head_hexsha": "dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reco2D/reconnection.tex", "max_forks_repo_name": "RaulGerru/FELTOR_FINAL", "max_forks_repo_head_hexsha": "dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.22172949, "max_line_length": 168, "alphanum_fraction": 0.6413318272, "num_tokens": 5942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5926665855647395, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4005030987314774}}
{"text": "\\documentclass[a4paper,twocolumn,10pt]{article}\n\\input{preamble}\n\n\\title{Notes for M.A.~Armstrong's \\textit{Groups and Symmetry}}\n\\author{Christian Stigen Larsen}\n\\date{March 2016}\n\n\\begin{document}\n  \\maketitle\n  \\section{Symmetries of the Tetrahedron}\n  \\paragraph{Symmetry group} Captures the rules of how symmetries combine for a\n  given object.\n\n  \\paragraph{Order of operations} In the \\textit{product}\\footnote{Rotations,\n  flips, multiplications, additions, etc. Same order as functional\n  composition.} $xyz$, do $z$ first, then $y$ and finally $x$. If order doesn't\n  matter in $G$, it's commutative (or \\textbf{\\textit{abelian}}). Remember to\n  label geometric vertices.\n\n  \\section{Axioms}\n  \\paragraph{Group}  Set $G$ with \\textit{multiplication} (addition,\n  rotation, etc.) satisfying\n  \\begin{itemize}\n    \\item \\textbf{\\textit{associativity}}, i.e.~$(xy)z = x(yz)$\n    \\item \\textbf{\\textit{identity element}} $e \\in G$ such that $xe=x=ex$\n    \\item \\textbf{\\textit{inverse}} $e \\in G$ such that $x^{-1}x=e=xx^{-1}$\n  \\end{itemize}\n\n  \\paragraph{Properties common to all groups}\n  \\begin{itemize}\n    \\item The identify element of a group is unique.\n    \\item The inverse of each element of a group is unique.\n  \\end{itemize}\n\n  \\section{Numbers}\n  \\paragraph{Addition of $\\mathbb{Z}, \\mathbb{Q}, \\mathbb{R}, \\mathbb{C}$}\n  \\begin{itemize}\n    \\item Identity is zero\n    \\item $-x$ is the inverse\n  \\end{itemize}\n  \\paragraph{Multiplication}\n  \\begin{itemize}\n  \\item For $\\mathbb{Q}-\\{0\\}$, $\\mathbb{Q}^{\\textbf{pos}}$,\n    $\\mathbb{R}-\\{0\\}$, $\\mathbb{R}^{\\textbf{pos}}$, $\\{+1,-1\\}$,\n    $\\mathbb{C}-\\{0\\}$, $\\mathcal{C}$\\footnote{Complex numbers of modulus 1.},\n    $\\{\\pm 1, \\pm i\\}$: $e=1$ and $x^{-1}=\\nicefrac{1}{x}$.\n  \\end{itemize}\n\n  \\paragraph{$\\mathbb{Z}$ under addition modulus $n$} $e=0$,\n  $x^{-1}=n-x$ for $x\\ne0$, finite \\textit{abelian} group and denoted\n  $\\mathbb{Z}_n$.\n\n  \\paragraph{$\\mathbb{Z}$ under multiplication modulus $n$} Requires $n$ to be\n  prime.\n\n  \\section{Dihedral Groups}\n  When $n\\geqslant3$ we can manufacture a plate whish has $n$ equal sides. These are\n  the non-commutative \\textit{dihedral rotational symmetry groups} $D_n$. E.g.\n  $D_3 = \\{e,r,r^2,s,rs,r^2s\\}$. $x^mx^n=x^{m+n}$ and $(x^m)^n=x^{mn}$ provided\n  we interpret $x^0=e$. For any multiplication table, each element in $G$\n  appears only once in every given column or row.\n\n  $r^n=e$, $s^2=e$, $sr=r^{n-1}s$, $r^{n-1}=r^{-1}$, etc.\n\n  Each element is of form $r^a$, $r^as$ where $0\\leqslant a\\leqslant n-1$.\n\n  For $k=a+_nb$, $r^ar^b=r^k$ and $r^a(r^bs)=r^ks$.  For $l=a+_n(n-b)$,\n  $(r^as)r^b=r^ls$ and $(r^as)(r^bs)=r^l$ --- thus $r$ and $s$\n  \\textbf{\\textit{generate}} $D_n$.\n\n  The \\textbf{\\textit{order}} $|G|$ is the number of elements in the group. If\n  $x^n=e$, then the \\textit{element} $x$ has \\textit{finite} order $n$ when $n$\n  is the smallest such $n$.\n\n  \\section{Subgroups and Generators}\n  A \\textbf{\\textit{subgroup}} of $G$ is a subset of $G$ which itself forms a\n  group under the multiplication of $G$. For $H$ to be a subgroup of $G$,\n  $H<G$:\n  \\begin{itemize}\n    \\item $xy \\in G$ for any $x,y \\in H$\n    \\item $e_H \\in G$\n    \\item For any $x \\in H$, $x^{-1} \\in G$\n    \\item Associativity in $G$ implies the same for $H$.\n  \\end{itemize}\n\n  \\paragraph{Subgroup generated by $x$, or $\\langle x \\rangle$}\n  For an element $x$ in $G$, the set of all $x^n$ is a subgroup of $G$\n  (remember $x^0=e$). Finite order $m$ means $x^0=e, x^1, \\ldots, x^{m-1}$.\n  So order of $x\\in G$ is precisely the order of $\\langle x\\rangle$. If\n  $\\langle x\\rangle=G$, i.e., generates all of $G$, then $G$ is a\n  \\textbf{\\textit{cyclic group}}.\n\n  \\paragraph{Subgroup generated by $X$} If $X<G$\\footnote{$X$ is a subgroup of\n  $G$.} and, for example, $r$,$s$,$r^2$,$sr$ (called \\textit{words} of $X$).\n\n  \\paragraph{Theorems}\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{5.1}] A non-empty subset $H$ of a group $G$ is a subgroup of\n      $G$ if and only if $xy^{-1}$ belongs to $H$ whenever $x$ and $y$ belong\n      to $H$.\n\n    \\item[\\theorem{5.2}] The intersection of two subgroups of a group is itself\n      a subgroup.\n\n    \\item[\\theorem{5.3}] Every subgroup of $\\mathbb{Z}$ is cyclic. Every\n      subgroup of a cyclic group is cyclic.\n  \\end{itemize}\n\n  \\section{Permutations}\n  A \\textit{permutation} is a bijection\\footnote{A one-to-one mapping between\n  the elements of two sets, meaning you can always go backwards as well.} from a\n  set $X$ to itself (e.g.,~replace all $3$s with $1$s).  The collecticon of\n  \\textit{all} permutations of $X$ forms a group $S_x$ under composition of\n  functions (who each perform one specific permutation). When $X$ consists of\n  the first $n$ positive integers, we get the \\textbf{\\textit{symmetric group}}\n  $S_n$ of degree $n$ and order $n!$. $S_3$ is not abelian\n\n  $(a_1a_2\\ldots a_k)$ is called a \\textbf{\\textit{cyclic permutation}},\n  sending $a_1$ to $a_2$, $\\ldots$ , $a_k$ to $a_1$. Its length is $k$ and a\n  cyclic permutation of length $k$ is called a \\textbf{\\textit{k-cycle}}. A\n  2-cycle is called a \\textbf{\\textit{transposition}}. Every element of $S_n$\n  can be written as many such \\textbf{\\textit{disjoint}}, meaning no integer is\n  moved by more than one of them. Therefore they are \\textit{commutative}.\n\n  \\paragraph{A few tricks}\n  \\begin{itemize}\n    \\item Each \\textit{element} of $S_n$ can be written as a product of cyclic\n      permutations, and any cyclic permutation can be written as a product of\n      transpositions: $(a_1a_2 \\ldots a_k) = (a_1a_k) \\ldots (a_1a_3)(a_1)(a_2)$.\n      Therefore, each \\textit{element} of $S_n$ can be written as a product of\n      transpositions.\n    \\item $(ab) = (1a)(1b)(1a)$\n    \\item $(1k) = (k-1,k)$$\\ldots$$(34) (23) (12) (23) (34)$$\\ldots$$(k-1,k)$\n  \\end{itemize}\n\n  \\paragraph{Theorems}\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{6.1}] The transpositions in $S_n$ together generate\n      $S_n$.\n\n    \\item[\\theorem{6.2a}] The transpositions $(12), (13), \\ldots, ({1n)}$\n      together generate $S_n$.\n\n    \\item[\\theorem{6.2b}] The transpositions $(12), (23), \\ldots, (n-1,n)$\n      together generate $S_n$.\n\n    \\item[\\theorem{6.3}] The transposition $(12)$ and the $n$-cycle $(12\n      \\ldots n)$ together generate $S_n$.\n  \\end{itemize}\n\n  Any \\textit{element} $\\alpha$ of $S_n$ can be written as a product of\n  \\textit{transpositions} in many different ways. But the number of\n  transpositions is always even or always odd. If $\\alpha$ \\textit{can} be\n  written as the product of an even number of transpositions, then its sign\n  must be $+1$; for odd, it is $-1$. Therefore, by the first trick above, a\n  \\textit{cyclic permutation} is even precisely when its length is odd.\n\n  \\paragraph{Theorems}\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{6.4}] The even permutations in $S_n$ form a subgroup of\n      order $n!/2$ called the \\textbf{\\textit{alternating group $A_n$}} of\n      degree $n$.\n\n    \\item[\\theorem{6.5}] For $n\\geqslant 3$ the 3-cycles generate $A_n$.\n  \\end{itemize}\n\n  \\section{Isomorphisms}\n  If two multiplication tables have corresponding elements and products, they\n  are \\textbf{\\textit{isomorphic}}.\n\n  Two groups $G$ and $G'$ are \\textbf{\\textit{isomorphic}} if there is a\n  bijection $\\varphi$ from $G$ to $G'$ which satisfies $\\varphi(xy) =\n  \\varphi{(x)}\\varphi{(y)}$ for all $x,y \\in G$. The function $\\varphi$ is called an\n  \\textbf{\\textit{isomorphism}} between $G$ and $G'$.\n  This is written $G \\cong G'$.\n\n  \\paragraph{Notes}\n  \\begin{itemize}\n    \\item $G$ and $G'$ have the same order.\n    \\item $\\varphi{(x)}^{-1} = \\varphi{(x^{-1})}$ for all $x \\in G$.\n    \\item If $G$ is abelian, then so is $G'$.\n    \\item If $H$ is a subgroup of $G$ then $\\varphi{(H)}$ a subgroup of $G'$.\n    \\item An isomorphism preserves the order of each element.\n    \\item If $\\varphi\\colon G \\rightarrow G'$ and $\\psi\\colon G' \\rightarrow G''$ are both\n      isomorphisms, then the composition $\\psi\\varphi\\colon G \\rightarrow G''$ is also\n      an isomorphism.\n  \\end{itemize}\n  \\paragraph{Examples}\n  \\begin{itemize}\n    \\item $\\varphi\\colon \\mathbb{R} \\rightarrow \\mathbb{R}^{\\textbf{pos}}$ by\n      $\\varphi{(x)} = e^x$ and $\\varphi{(x+y)}=e^{x+y}=e^xe^y=\\varphi{(x)}\\varphi{(y)}$.\n    \\item The non-abelian, rotational group $G$ for the tetrahedron is isomorphic to $A_4$.\n    \\item Any infinite cyclic group $G$ is isomorphic to $\\mathbb{Z}$ by\n      $\\varphi{(x^m)} = m$ and $\\varphi{(x^mx^n)} =\n      \\varphi{(x^{m+n})}=m+n=\\varphi{(x^m)}+\\varphi{(x^n)}$.\n    \\item Any finite cyclic group of order $n$ is isomorphic to $\\mathbb{Z}_n$\n      by $\\varphi{(x^m)} = m\\Mod{n}$.\n    \\item The numbers $1$, $-1$, $i$, $-i$ form a group under complex\n      multiplication. It is cyclic, and $i$, $-i$ are both generators. It gives\n      two isomorphisms between this group and $\\mathbb{Z}_4$.\n    \\item $D_3$ and $S_3$ are isomorphic.\n    \\item There is no isomorphism between $\\mathbb{Q}$ and\n      $\\mathbb{Q}^{\\textbf{pos}}$.\n  \\end{itemize}\n\n  \\section{Plato's Solids and Cayley's Theorem}\n  \\textit{Remember:} A surjection between two finite sets which have the same\n  number of elements must be a bijection.\n\n  \\begin{itemize}\n    \\item The rotational symmetry group of the tetrahedron is isomorphic to\n      $A_4$.\n\n    \\item The cube and octehedron both have rotational symmetry groups which\n      are isomorphic to $S_4$.\n\n    \\item The dodecahedron and icosahedron both have rotational symmetry groups\n      which are isomorphic to $A_5$.\n\n    \\item If two solids are \\textbf{\\textit{dual}} to one another, their\n      rotational symmetry groups are isomorphic.\n  \\end{itemize}\n\n  \\paragraph{Theorems}\n  \\textit{Every} group is isomorphic to a subgroup of permutations:\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{8.1}] \\textbf{Cayley's Theorem.} Let $G$ be a group, then\n      $G$ is isomorphic to a subgroup of $S_G$.\n\n    \\item[\\theorem{8.2}] If $G$ is a finite group of order $n$, then $G$ is\n      isomorphic to a subgroup of $S_n$.\n  \\end{itemize}\n\n  \\section{Matrix Groups}\n  The set of all invertible $n \\times n$ matrices with real numbers as entries\n  forms a group under matrix multiplication: Matrix multiplication is\n  associative, the $n \\times n$ identity matrix $I_n=\\epsilon$ and the inverse\n  of $AB$ is $B^{-1}A^{-1}$. This group is called the \\textbf{\\textit{General\n  Linear Group}}, $GL_n$.\n\n  Matrix multiplication is not commutative for $n \\geqslant 2$, so we have a\n  family of \\textit{infinite non-abelian} groups $GL_2$, $GL_3$, etc. For $n=1$\n  the single entry must be a non-zero number (the matrix is invertible), and\n  reduces to ordinary multiplication of numbers. Hence, $GL_1 \\cong\n  \\mathbb{R}-\\{0\\}$.\n\n  $AB^{-1}$ is orthogonal and by theorem (\\ref{theorem-5.1}.1) the collection\n  of all $n \\times n$ orthogonal matrices is a subgroup of $GL_n$. This\n  subgroup is called the \\textbf{\\textit{Orthogonal Group}}, $O_n$. Those\n  elements of $O_n$ which have determinant equal to $+1$ form a subgroup of\n  $O_n$ called the \\textbf{\\textit{Special Orthogonal Group}}, $SO_n$.\n\n  \\textit{No further notes here, at the moment.}\n\n  \\section{Products}\n  The \\textbf{\\textit{direct product}} $G \\times H$ of two groups $G$ and $H$\n  is constructed by $(g,h)(g',h') = (gg',hh')$, where $g, g' \\in G$ and $h, h'\n  \\in H$. Thus, $(gg',hh') \\in G \\times H$ and $G \\times H$ is a group. The\n  correspondence $(g,h) \\rightarrow (h,g)$ means that $G \\times H$ is\n  isomorphic to $H \\times G$. Unless either of $G$ or $H$ are of infinite\n  order, $|G \\times H| = |G|\\cdot|H|$. If both $G$ and $H$ are abelian, so is\n  $G \\times H$. In reverse, if $G \\times H$ is abelian, so are both $G$ and\n  $H$.\n\n  E.g., the elements of $\\mathbb{Z}_2 \\times \\mathbb{Z}_3$ are\n  $\\{0,1\\}\\times\\{0,1,2\\} = \\{(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)\\}$ and\n  their elements are combined by $(x,y) + (x',y') = (x \\,+_2\\, x', y \\,+_3\\, y')$.\n  We follow the convention of using $+$ for the group structure whenever we\n  have products of cyclic groups. As continually adding $(1,1)$ to itself, we\n  can fill out the whole group, and therefore $\\mathbb{Z}_2 \\times\n  \\mathbb{Z}_3$ is cyclic and isomorphic to $\\mathbb{Z}_6$.\n\n  \\paragraph{Klein's group} $\\mathbb{Z}_2 \\times \\mathbb{Z}_2$ is non-cyclic\n  and isomorphic to the group of plane symmetries of a chessboard.\n\n  We write $\\mathbb{R}^n$ for the direct product of $n$ copies of $\\mathbb{R}$.\n\n  \\paragraph{Theorem \\theorem{10.1}} $\\mathbb{Z}_m \\times \\mathbb{Z}_n$ is\n  cyclic if and only if the highest common factor of $m$ and $n$ is 1.\n\n  \\paragraph{Theorem \\theorem{10.2}} If $H$ and $K$ are subgroups of $G$ for\n  which $HK=G$, if they have only the identity element in common, and if every\n  element of $H$ commutes with every element of $K$, then $G$ is isomorphic to\n  $H \\times K$.\n\n  The linear transformation $f_J\\colon \\mathbb{R}^3 \\rightarrow \\mathbb{R}^3$\n  sends each vector $\\bm{x}$ to $\\bm{-x}$ and is called\n  \\textbf{\\textit{central inversion}}.\n\n  \\textit{Some important notions at the end of the chapter have been left out,\n  currently.}\n\n  \\section{Lagrange's Theorem}\n  Let $H<G$ and break it up as the union of the $k+1$ pieces $H, g_1H, \\ldots,\n  g_kH$, then $|G|=(k+1)|H|$.\n\n  \\theorem{11.1} The order of a subgroup of a finite group is always a divisor\n  of the order of the group.\n\n  \\textbf{Note:} The opposite is not true; the existence of a divisor $m$\n  of $|G|$ does \\textit{not} imply the existence of a subgroup of $G$.\n\n  \\paragraph{Corrolaries}\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{11.2}] The order of every element of $G$ is a divisor of the\n      order of $G$.\n\n    \\item[\\theorem{11.3}] If $G$ has prime order, then $G$ is cyclic.\n\n    \\item[\\theorem{11.4}] If $x$ is an element of $G$ then $x^{|G|}=e$.\n\n    \\item[\\theorem{11.5}] \\textbf{Euler's Theorem.} If the highest common\n      factor of $x$ and $n$ is $1$, then $x^{\\phi{(n)}}$ is congruent to $1$\n      modulo $n$.\n\n    \\item[\\theorem{11.6}] \\textbf{Fermat's Little Theorem.} If $p$ is prime and\n      if $x$ is not a multiple of $p$, then $x^{p-1}$ is congruent to $1$\n      modulo $p$.\n  \\end{itemize}\n\n  \\section{Partitions}\n  Let $X$ be a set and let $\\mathscr{R}$ be a subset of the cartesian product\n  $X\\times X$. Given two points $x$ and $y$ of $X$, we say that $x$ is\n  \\textbf{\\textit{related}} to $y$ if the ordered pair $(x,y)$ happen to lie in\n  $\\mathscr{R}$. If (a) each $x\\in X$ is related to itself, (b) if $x$ is related\n  to $y$, then $y$ is related to $x$, for any two points $x,y \\in X$, (c) if\n  $x$ is related to $y$ and if $y$ is related to $z$, then $x$ is related to\n  $z$ for any three points $x,y,z \\in X$ --- then we call $\\mathscr{R}$ and\n  \\textbf{\\textit{equivalence relation}} on $X$. For each $x\\in X$ the\n  collection of all points which are related to it is written $\\mathscr{R}(x)$\n  and called the \\textbf{\\textit{equivalence class}} of $x$.\n\n  \\paragraph{Theorems}\n  \\begin{itemize}[leftmargin=0.45in]\n    \\item[\\theorem{12.1}] $\\mathscr{R}(x) = \\mathscr{R}(y)$ whenever $(x,y) \\in\n      \\mathscr{R}$.\n  \\end{itemize}\n\n\\end{document}\n", "meta": {"hexsha": "cfc27cba1c2f6b627fccb673a368563c8d6dcaef", "size": 15172, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "armstrong-notes.tex", "max_stars_repo_name": "cslarsen/armstrong-notes", "max_stars_repo_head_hexsha": "3948ab8e0203e544ca590fa614598340c754b113", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-15T18:49:25.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-15T18:49:25.000Z", "max_issues_repo_path": "armstrong-notes.tex", "max_issues_repo_name": "cslarsen/armstrong-notes", "max_issues_repo_head_hexsha": "3948ab8e0203e544ca590fa614598340c754b113", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-08T01:58:59.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-10T07:21:34.000Z", "max_forks_repo_path": "armstrong-notes.tex", "max_forks_repo_name": "cslarsen/armstrong-notes", "max_forks_repo_head_hexsha": "3948ab8e0203e544ca590fa614598340c754b113", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6235294118, "max_line_length": 91, "alphanum_fraction": 0.6534405484, "num_tokens": 5310, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.4004002040214838}}
{"text": "\\documentclass[\n    14pt,luatex,unicode,professionalfont,aspectratio=169,\n    xcolor=dvipsnames,\n    hyperref={unicode,hidelinks,pdfusetitle}\n]{beamer}\n\\usefonttheme{professionalfonts}\n\\usetheme{metropolis}\n\\setbeamercovered{transparent=30}\n\\setbeamertemplate{navigation symbols}{}\n\\setbeamerfont{footline}{size=\\LARGE}\n\n\\input{../preamble.tex}\n\n\\title{\\normalsize Solving the quantum master equation of coupled harmonic oscillators with Lie algebra methods}\n\n\\begin{document}\n\\frame{\\titlepage}\n\\section{Introduction}\n\\begin{frame}[t]{Hilbert space $\\mathcal{H}$ and Liouville space $\\mathfrak{L}$}\n    \\begin{columns}[t]\n        \\begin{column}{0.5\\textwidth}\n            Hilbert space $\\mathcal{H}$\n            \\begin{itemize}\n                \\item Density operator $\\hat{\\rho}$\n                \\item Hamiltonian $\\hat{\\mathscr{H}}$\n                \\item von Neumann equation :\n                    \\begin{equation}\n                        \\pdv{t}\\hat{\\rho} = -i[\\hat{\\mathscr{H}},\\hat{\\rho}]\n                        \\label{eq:von Neumann equation in Hilbert space}\n                    \\end{equation}\n            \\end{itemize}\n        \\end{column}\n        \\begin{column}{0.5\\textwidth}\n            \\alert{Liouville space} $\\mathfrak{L}$\n            \\begin{itemize}\n                \\item Superket $\\lket{\\rho}$\n                \\item Liouvillian $\\hhat{\\mathscr{L}}$\n                \\item von Neumann equation :\n                    \\begin{equation}\n                        \\pdv{t}\\lket{\\rho} = \\hhat{\\mathscr{L}}\\lket{\\rho}\n                    \\end{equation}\n            \\end{itemize}\n        \\end{column}\n    \\end{columns}\n    $\\Longrightarrow$ Eq. \\eqref{eq:von Neumann equation in Hilbert space} as the problem in linear algebra.\n    \\begin{equation*}\n        \\vb*{x} = A\\vb*{b}\n    \\end{equation*}\n\\end{frame}\n\n\\begin{frame}{Quantum master equation}\n    Von Neumann equation : $\\partial_t \\lket{\\rho} =  -i[\\hat{\\mathscr{H}},\\hat{\\rho}]$\n    \\begin{description}\\footnotesize\n        \\item[$+$] Total Hamiltonian :\n                    $\\hat{H}_T = \\hat{H} + \\hat{H}_E + \\hat{H}_I$.\n        \\item[$+$] Markovian interaction.\n        \\item[$+$] Initial state is separable :\n                    $\\hat{\\rho}_T(0) \\approx \\hat{\\rho}(0) \\otimes \\hat{\\rho}_E(0)$.\n        \\item[$+$] Born approximation :\n            $\\hat{\\rho}_T(t) \\approx \\hat{\\rho}(t) \\otimes \\hat{\\rho}_E(0)$.\n        \\item[$+$] Weak coupled regime : $\\hat{H}_I \\ll \\hat{H}, \\hat{H}_E$.\n        \\item[$+$] Rotating wave approximation.\n    \\end{description}\\normalsize\n    \\alert{Quantum master equation}~\\footfullcite{Manzano2020} :\n    {\\small($\\hat{\\mathcal{L}}_i$ is Lindblad jump operator)}\n    \\begin{equation}\n        \\pdv{t}\\hat{\\rho}(t)\n        = -i[\\hat{\\mathscr{H}},\\hat{\\rho}] + \\frac{1}{2}\\sum_i \\qty(\n                2\\hat{\\mathcal{L}}_i \\hat{\\rho}(t) \\hat{\\mathcal{L}}_i^\\dag\n                    - \\{\\hat{\\mathcal{L}}_i^\\dag\\hat{\\mathcal{L}}_i,\\hat{\\rho}(t)\\})\n    \\end{equation}\n\\end{frame}\n\n\\begin{frame}{Lie algebra $\\mathfrak{g}$ and Lie braket $[\\cdot,\\cdot]$}\n    \\alert{Lie algebra} $\\mathfrak{g}$ is vector space with \\alert{Lie bracket} $[\\cdot,\\cdot]$.\n    \\begin{itemize}\n        \\item Alternativity : $[X,Y] = -[Y,X]$.\n        \\item Linearity : $[aX+bY,Z] = a[X,Z] + b[Y,Z]$.\n        \\item Jacobi identity : $[[X,Y],Z] + [[Y,Z],X] + [[Z,X],Y] = 0$.\n    \\end{itemize}\n    ex) Commutator $[X,Y] \\coloneqq XY - YX$.\n\n    Lie algebra is not commutative. \\\\\n    $\\Longrightarrow$ Left translation and right transition :\n    \\begin{equation}\n        \\hhat{L}[\\hat{O}]\\lket{A} \\coloneqq \\hat{O}\\hat{A}\n        \\qc\n        \\hhat{R}[\\hat{O}]\\lket{A} \\coloneqq \\hat{A}\\hat{O}\n    \\end{equation}\n\\end{frame}\n\n\\begin{frame}{A linear chain of $N$ coupled harmonic oscillators}\n    Hamiltonian :\n    \\begin{equation}\n        \\hat{\\mathscr{H}}\n        = \\sum_{k=1}^N \\varepsilon_k \\hat{a}_k^\\dag \\hat{a}_k\n            + \\sum_{k=1}^{N-1} \\kappa_k (\\hat{a}_k^\\dag\\hat{a}_{k+1}\n                + \\hat{a}_k\\hat{a}_{k+1}^\\dag)\n    \\end{equation}\n    Quantum master equation :\n    \\begin{equation}\n        \\pdv{t}\\hat{\\rho}(t)\n        = -i[\\hat{\\mathscr{H}},\\hat{\\rho}]\n            + \\sum_{k=1}^N \\gamma_k (2\\hat{a}_k\\hat{\\rho}\\hat{a}_k^\\dag\n                - \\{\\hat{a}_k^\\dag\\hat{a}_k,\\hat{\\rho}\\})\n        \\label{eq:quantum master equation for harmonic oscillators}\n    \\end{equation}\n    where \\quad\\qquad $\\hat{a}_k, \\hat{a}_k^\\dag$ is bosonic mode operators,\n    \\begin{equation*}\n        \\varepsilon_k : \\text{energy}, \\\n        \\kappa_k : \\text{coupling constant}, \\\n        \\gamma_k : \\text{loss rate}\n    \\end{equation*}\n\\end{frame}\n\n\\section{Induced Lie algebra}\n\\begin{frame}{Effective non-Hermite Hamiltonian $\\hat{\\mathscr{H}}_\\mathrm{eff}$}\n    \\alert{Effective non-Hermite Hamiltonian} $\\hat{\\mathscr{H}}_\\mathrm{eff}$ :\n    \\begin{equation}\n        -i(\\hat{\\mathscr{H}}_\\mathrm{eff}\\hat{\\rho}\n            - \\hat{\\rho}\\hat{\\mathscr{H}}_\\mathrm{eff}^\\dag)\n        \\coloneqq -i[\\hat{\\mathscr{H}},\\hat{\\rho}]\n            - \\sum_{k=1}^N \\gamma_k \\{\\hat{a}_k^\\dag\\hat{a}_k,\\hat{\\rho}\\}_+\n    \\end{equation}\n    Eigenvalue (energy) :\n    \\begin{equation}\n        \\varepsilon_k \\longrightarrow \\varepsilon_k - i\\gamma_k\n    \\end{equation}\n\\end{frame}\n\n\\begin{frame}{Bosonic mode superoperators}\n    Bosonic mode superoperators :\n    \\begin{align}\n        \\hhat{L}_k^-\\lket{A} &= \\hat{a}_k\\hat{A},\n            & \\hhat{L}_k^+\\lket{A} &= \\hat{a}_k^\\dag\\hat{A}, \\\\\n        \\hhat{R}_k^-\\lket{A} &= \\hat{A}\\hat{a}_k,\n            & \\hhat{R}_k^+\\lket{A} &= \\hat{A}\\hat{a}_k^\\dag.\n    \\end{align}\n    As well as $[\\hat{a}_j,\\hat{a}_k^\\dag]=\\delta_{jk}$,\n    \\begin{equation}\n        [\\hhat{L}_i^-,\\hhat{L}_j^+] = \\delta_{ij},\n        \\quad\n        [\\hhat{R}_i^-,\\hhat{R}_j^+] = \\delta_{ij}.\n    \\end{equation}\n    The set\n    \\begin{equation}\n        \\alt<2>{\n            \\{\\hhat{\\mathbbm{1}}_\\mathfrak{L},\\hhat{L}_i^\\pm,\\hhat{R}_i^\\pm,\\hhat{\\mathscr{L}}\\}\n        }{\n            \\{\\hhat{\\mathbbm{1}}_\\mathfrak{L},\\hhat{L}_i^\\pm,\\hhat{R}_i^\\pm,\\hhat{L}_j^+\\hhat{L}_k^-,\\hhat{R}_j^-\\hhat{R}_k^+,\\hhat{L}_j^-\\hhat{R}_k^-\\}\n        }\n    \\end{equation}\n    spans Lie algebra $\\mathfrak{g}$.\n\\end{frame}\n\n\\begin{frame}{Liouvillian $\\hhat{\\mathscr{L}}$ for harmonic oscillators}\n    Liouvillian (right action) :\n    \\small\n    \\begin{align}\n        \\hhat{\\mathscr{L}}\n        &= \\sum_{k=1}^N \\qty[(i\\varepsilon_k - \\gamma_k)\\hhat{R}_k^+\\hhat{R}_k^-\n                - (i\\varepsilon_k + \\gamma_k) \\hhat{L}_k^+\\hhat{L}_k^-\n                    + 2\\gamma_k\\hhat{L}_k^-\\hhat{R}_k^-] \\nonumber \\\\\n        &\\qquad + \\sum_{k=1}^N i\\kappa_k \\qty(\\hhat{L}_k^+ \\hhat{L}_{k+1}^-\n                + \\hhat{L}_{k+1}^+\\hhat{L}_k^- - \\hhat{R}_{k+1}^+\\hhat{R}_k^-\n                    - \\hhat{R}_k^+\\hhat{R}_{k+1}^-)\n    \\end{align}\n    \\normalsize\n    \\alert{Time evolution superoperator} :\n    \\begin{equation}\n        \\pdv{t} \\hhat{\\mathcal{U}}(t) = \\hhat{\\mathscr{L}}\\hhat{\\mathcal{U}}(t)\n    \\end{equation}\n    where $\\hhat{\\mathcal{U}}(0) = \\hhat{\\mathbbm{1}}_\\mathfrak{L}$.\n\\end{frame}\n\n\\begin{frame}{Approaches to solve master equation}\n    Two approaches to solve master equation.\n    \\begin{enumerate}\n        \\item Eigendecomposition (time-independent)\n        \\item Wei-Norman expansion (time-dependent)\n    \\end{enumerate}\n\\end{frame}\n\n\\section{Eigendecomposition}\n\\begin{frame}{Regular representation in Lie algebra}\n    Regular representation $\\hhat{\\mathcal{R}}(Z)$ :\n    \\begin{equation}\n        [\\hhat{Z},\\hhat{X}_i] = \\hhat{\\mathcal{R}}_{ij}(\\hhat{Z}) \\hhat{X}_j.\n    \\end{equation}\n    Interested in $\\hhat{\\mathcal{R}}(\\hhat{\\mathscr{L}})$,\n    \\begin{equation}\n        \\{\\hhat{\\mathbbm{1}}_\\mathfrak{L},\\hhat{L}_i^\\pm,\\hhat{R}_i^\\pm,\\hhat{\\mathscr{L}}\\}\n            \\longrightarrow \\{\\hhat{L}_i^\\pm,\\hhat{R}_i^\\pm\\}\n    \\end{equation}\n    Eigenvalues of $\\hhat{\\mathcal{R}}(\\hhat{\\mathscr{L}})$ :\n    \\begin{equation}\n        \\{\\pm\\lambda_1,\\ldots,\\pm\\lambda_N,\\pm\\lambda_1^*,\\ldots,\\pm\\lambda_N^*\\}\n    \\end{equation}\n    where $\\lambda=(\\lambda_1,\\ldots,\\lambda_N)$ are the eigenvalues of $\\hhat{\\mathscr{H}}_\\mathrm{eff}$.\n\\end{frame}\n\n\\begin{frame}{Collective creation and annihilation operators}\n    Eigenvectors of $\\hhat{\\mathcal{R}}(\\hhat{\\mathscr{L}})$ :\n    \\begin{align}\n        \\hhat{P}_i^+ &= \\sum_k c_{ik}(\\hhat{L}_k^+ - \\hhat{R}_k^-),\n            & \\hhat{P}_i^- &= \\sum_k c_{ik}\\hhat{L}_k^-, \\\\\n        \\hhat{Q}_i^+ &= \\sum_k c_{ik}(\\hhat{R}_k^+ - \\hhat{L}_k^-),\n            & \\hhat{Q}_i^- &= \\sum_k c^*_{ik}\\hhat{R}_k^-.\n    \\end{align}\n    $\\Longrightarrow$ Collective creation and annihilation operators :\n    \\begin{gather}\n        [\\hhat{P}_i^-,\\hhat{P}_j^+] = \\delta_{ij},\n        \\quad\n        [\\hhat{Q}_i^-,\\hhat{Q}_j^+] = \\delta_{ij} \\\\\n        \\begin{aligned}\n            [\\hhat{\\mathcal{L}},\\hhat{P}_i^+] &= \\lambda_i\\hhat{P}_i^+\n                & [\\hhat{\\mathcal{L}},\\hhat{P}_i^-] &= -\\lambda_i\\hhat{P}_i^-  \\\\\n            [\\hhat{\\mathcal{L}},\\hhat{Q}_i^+] &= \\lambda_i^*\\hhat{Q}_i^+\n                & [\\hhat{\\mathcal{L}},\\hhat{Q}_i^-] &= -\\lambda_i^*\\hhat{Q}_i^-\n        \\end{aligned}\n    \\end{gather}\n\\end{frame}\n\n\\begin{frame}{Ground state and ladder state}\n    Ground state in $\\mathfrak{L}$ :\n    \\begin{gather}\n        \\hhat{P}_i^-\\lket{0} = \\hhat{Q}_i^-\\lket{0} = 0_\\mathcal{H} \\\\\n        \\hhat{P}_i^+ \\lbra{0} = \\hhat{Q}_i^+\\lbra{0} = 0_\\mathcal{H}\n    \\end{gather}\n    Higher rungs of the ladder :\n    \\begin{align}\n        \\lket{\\alpha,\\beta} &= \\frac{1}{\\sqrt{\\alpha!\\beta!}}\n            \\hhat{\\vb*{P}}^{+\\alpha} \\hhat{\\vb*{Q}}^{+\\beta}\\lket{0} \\\\\n        \\lbra{\\alpha,\\beta} &= \\frac{1}{\\sqrt{\\alpha!\\beta!}}\n            \\lbra{0}\\!\\hhat{\\vb*{P}}^{+\\alpha} \\hhat{\\vb*{Q}}^{+\\beta}\n    \\end{align}\n    where $\\alpha=(\\alpha_1,\\ldots,\\alpha_N), \\beta=(\\beta_1,\\ldots,\\beta_N)$.\n\\end{frame}\n\n\\begin{frame}{Collective creation and annihilation operators}\n    Baker–Campbell–Hausdorff formula :\n    \\begin{equation}\n        e^{A}Be^{-A} = \\sum_{n=0}^\\infty\\frac{1}{n!}\n            \\underbrace{[A,[A,\\cdots,[A}_{n},B]\\cdots]]\n    \\end{equation}\n\n    Ladder state :\n    \\begin{equation}\n        e^{\\mathscr{L}t} \\lket{\\alpha,\\beta}\n            = e^{(\\alpha\\cdot\\lambda + \\beta\\cdot\\lambda^*)t}\n                \\lket{\\alpha,\\beta}\n    \\end{equation}\n\n    Density superket $\\lket{\\rho}$ evoluted as\n    \\begin{equation}\n        \\lket{\\rho(t)} = \\sum_{\\alpha,\\beta} e^{(\\alpha\\cdot\\lambda + \\beta\\cdot\\lambda^*)t}\n                        \\lket{\\alpha,\\beta}\\lbraket{\\alpha,\\beta}{\\rho_0}.\n    \\end{equation}\n\\end{frame}\n\n\\section{Wei-Norman expansion}\n\\begin{frame}{Collective creation and annihilation operators}\n    Expansion of $\\hhat{\\mathscr{L}}$ by basis :\n    \\begin{equation}\n        \\hhat{\\mathscr{L}}(t) = \\sum_{k=1}^m c_k(t) \\hhat{X}_k.\n    \\end{equation}\n\n    Time evolution superoperator :\n    \\begin{equation}\n        \\hhat{\\mathcal{U}}(t) = \\prod_k^n \\hhat{\\mathcal{U}}_k(t)\n                              = \\prod_k^n \\exp g_k(t)\\hhat{X}_k\n    \\end{equation}\n    where\n    \\begin{equation}\n        \\pdv{t}\\hhat{\\mathcal{U}}_k(t) =  g_k(t)\\hhat{X}_k \\hhat{\\mathcal{U}}_k(t)\n        \\qc\n        \\hhat{\\mathcal{U}}_k(0) = \\hhat{\\mathbbm{1}}_\\mathfrak{L}.\n    \\end{equation}\n\\end{frame}\n\n\\begin{frame}{Collective creation and annihilation operators}\n    Liouvillian is split as :\n    \\begin{equation}\n        \\hhat{\\mathscr{L}} = \\underbrace{\\hhat{\\mathscr{L}}_S}_\\text{solvable}\n                                + \\underbrace{\\hhat{\\mathscr{L}}_R}_\\text{remaining}\n    \\end{equation}\n\n    Time evolution superoperator :\n    \\begin{equation}\n        \\pdv{t}\\hhat{\\mathcal{U}}_S(t) =  \\hhat{\\mathscr{L}}_S \\hhat{\\mathcal{U}}_S(t)\n        \\qc\n        \\pdv{t}\\hhat{\\mathcal{U}}_R(t)\n            =  (\\hhat{\\mathcal{U}}_S^{-1}\\hhat{\\mathscr{L}}_R\\hhat{\\mathcal{U}}_S)\n                \\hhat{\\mathcal{U}}_R(t)\n    \\end{equation}\n    However, $\\hhat{\\mathcal{U}}_R(t)$ is not always solvable.\n\\end{frame}\n\\end{document}\n", "meta": {"hexsha": "fc2e7a4eecdd57e91a610bdf1e4fde7b30e9246f", "size": 11915, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "contents/PhysRevA101042124.tex", "max_stars_repo_name": "takuzo0825/Arxiv", "max_stars_repo_head_hexsha": "68be4d0af4eb110c72f431106a4846bb6e8390f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "contents/PhysRevA101042124.tex", "max_issues_repo_name": "takuzo0825/Arxiv", "max_issues_repo_head_hexsha": "68be4d0af4eb110c72f431106a4846bb6e8390f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "contents/PhysRevA101042124.tex", "max_forks_repo_name": "takuzo0825/Arxiv", "max_forks_repo_head_hexsha": "68be4d0af4eb110c72f431106a4846bb6e8390f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8494983278, "max_line_length": 152, "alphanum_fraction": 0.5595467898, "num_tokens": 4382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.5621765008857982, "lm_q1q2_score": 0.40040019715370034}}
{"text": "\\chapter{Conclusion}\n\\label{ch_conclusion}\n\n% \\markright{Conclusion}\n\nWe have presented recent methods for restoration of spherical data with noise following a Poisson distribution. A denoising method was proposed, which used a variance stabilization method and multiscale transforms on the sphere.\nExperiments have shown it is very efficient for the denoising of  astrophysical data set such as Fermi data.  Two spherical multiscale transforms, the wavelet and the curvelets, were used.\nThen, we have described an extension of the denoising method in order to take into account missing data, and we have shown that this inpainting method\ncould be a useful tool to estimate the diffuse emission. \nThen, we have introduced a new denoising method the sphere which takes into account a background model. The simulated data have shown that it is relatively robust to\nerrors in the model, and can therefore be used for diffuse background modeling and source detection.\nFinally, an extension to multichannel denoising and deconvolution has been proposed, which proved very efficient on simulated data.\n", "meta": {"hexsha": "39e739de33099988a0d5be00d060916d02d38cf5", "size": 1096, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/doc/doc_isap/msvst_ccl.tex", "max_stars_repo_name": "sfarrens/cosmostat", "max_stars_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/doc/doc_isap/msvst_ccl.tex", "max_issues_repo_name": "sfarrens/cosmostat", "max_issues_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/doc/doc_isap/msvst_ccl.tex", "max_forks_repo_name": "sfarrens/cosmostat", "max_forks_repo_head_hexsha": "a475315cda06dca346095a1e83cb6ad23979acae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 84.3076923077, "max_line_length": 228, "alphanum_fraction": 0.8211678832, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4004001971537003}}
{"text": "\\section{Appendix}\n\n\\subsection{Model documentation}\n\n\\subsubsection{Overview}\nThe French power model FLORE is a dispatch and investment model of the French power mix. It is a partial equilibrium model of the wholesale electricity market, which determines optimal investment and hourly generation.\n\nFLORE minimizes total cost with respect to investment and production under a set of constraints. The model is linear, deterministic, and solved in hourly time step for each year, from 2014 to 2050.\n\nGeneration is modelled as twelve distinct technologies: three VRE with zero marginal costs - onshore wind, offshore wind and solar, three fossil-based thermal technologies - coal, combined cycle gas turbine (CCGT), open cycle gas turbine (OCGT), three nuclear technologies (historical nuclear, retrofitted nuclear and new nuclear), and three hydro systems - run-of-river, conventional dams (lakes) and pumped storage. \nHourly VRE generation is limited by specific generation profiles.\nDispatchable power plants produce whenever the price is above their variable costs, and unless they are limited by their ramping constraints.\nHydro storage and dispatch is optimized by the model, under water reservoir constraints and pumping losses.\nAt the end its lifetime, each capacity is decommissioned.\n\nA particularity of the model is to represent explicitly the cost of extending the lifetime of nuclear power plants. Nuclear plants normally close after 40 years, but their lifetime can be extended to 60 years, if upgrade costs are paid for.\n\nDemand is exogenous and assumed to be perfectly price inelastic at all times.\n\nFLORE is currently calibrated for France. Exports are given exogenously.\n\n\\subsubsection{Total System Costs}\n\nThe model minimizes total system costs $C$ with respect to several constraints and decision variables. Total system costs are the sum of fixed costs (representing the sum of capital and fixed O\\&M costs), and variable costs, over all hours $h$, weeks $w$, years $y$ and generation technologies $tec$. \n\nFixed costs are the product of the capacity installed $CAPA_{tec,y}$ for each technology in year $y$, by its annualized capacity cost $c_{tec}^{inv}$ plus fixed O\\&M costs $c_{tec}^{qfix}$. \nVariable generation costs are the product of $GENE_{tec,w,y,h}$, the generation from technology $tec$ in year $y$, week $w$ and hour $h$, by variable generation costs $c_{tec}^{var}$.\n\\begin{equation}\nC =\\sum_{tec,y} CAPA_{tec,y} \\cdot ( c_{tec}^{inv} + c_{tec}^{qfix} ) + \\sum_{tec,y,w,h} GENE_{tec,y,w,h} \\cdot c_{tec}^{var}\n\\end{equation}\nThroughout this model description, capital letters denote choice variable for the model, while lowercase letters denote exogenous data.\n\n\\subsubsection{Supply and demand}\n\nPower balance between supply and demand is the central constraint of the model. Demand is the sum of national load $d$, pumping for pumped-storage hydro $PUMP$ and exports flow $flows$. \nSupply is the sum of generation over all technologies.\n$$\\forall h,y \\quad \\sum_{tec} GENE(tec,h,y) \\geq \\sum_{tec} LOAD(h,y) + PUMP(h,y) + flow(h,y)$$\n\nIn this framework, demand is perfectly price-inelastic. Cost minimization is thus equivalent to welfare-maximization.\n\nGeneration is constrained by capacities installed and the load factor (also called availability), for all technologies except wind, PV and run-of-river hydro, which present a specific generation profile.\n$$GENE(tec\\_noprof,y,w,h) \\leq CAPA(tec\\_noprof,y)*loadfactor(tec\\_noprof)$$\nFor wind and PV, a generation profile is an additional constraint:\n$$GENE(tec\\_res,y,w,h) \\leq CAPA(tec\\_res,y)*res\\_profiles(h,tec\\_res)$$\nFor run-of-river hydro, generation is fixed exogenously for each week:\n$$GENE(\"river\",y,w,h) = river\\_flow(w)$$\n\nInvestment is exogenous for historical nuclear and the three hydro technologies. The capacity of historical nuclear technology is decreasing based on plant-level data, with each plant capacity being phased-out when it reaches 40 years old. For hydro, we assume constant capacities for run-of-river and lakes. Pumped-hydro potential is expected to grow by 3.2GW by 2050, starting from 5 GW in 2014, with a discharge time of 20 hours, as in ADEME (Visions ADEME 2030).\n$$CAPA_{tec\\_ex,y} = capa_exo_{y,tec\\_ex} $$\n\nThe capacity of all other technologies is determined endogenously by the model. Capacity is installed when optimal, and then decommissioned when it reaches its lifetime. The initial capacity, already installed in 2014, is supposed to be decommissioned linearly from 2014 onwards in a period of 40 years.\n\\begin{align*}\nCAPA_{tec\\_end,y+1} &= CAPA_{tec\\_end,y} + INVE_{tec\\_end,y} - DECO\\_{tec\\_end,y} \\\\\nDECO_{tec\\_end,y}  &= INVE_{tec\\_end,y-lifetime(tec\\_end)} + (tec\\_data_{tec\\_end,'initcap'}/40)\\$(ord(y) <= 40) \n\\end{align*}\n\n\n\n\\subsubsection{Power System Inflexibilities}\n\nThe model includes ramp-up and ramp-down constraints for nuclear and coal power plants, to represent the fact that generation cannot vary too quickly from one hour to the next. These constraints are modelled as a maximum variation rate:\nThe ramp up constraint is:\n$$\\forall tec\\_ramp,y,w,h \\quad GENE(tec\\_ramp,y,w,h+1) \\leq GENE(tec\\_ramp;y;w;h) \\dot (1+ramp\\_rate)$$\nThe ramp-down constraint is:\n$$\\forall tec\\_ramp,y,w,h \\quad GENE(tec\\_ramp,y,w,h+1) \\geq GENE(tec\\_ramp;y;w;h) \\dot (1-ramp\\_rate)$$\nWe take the value of $0.08$ for coal and $0.05$ for nuclear - for both ramp-up and ramp-down, as in \\citet{ADEME2015}.\n\n\\subsubsection{Model limitation}\n\nThis model was designed to represent the French power system from 2014 to 2050, optimizing investment and dispatch over many assumptions on nuclear costs. As such, it had to make several simplifying assumptions.\n\nThis model does not provide a detailed representation of infra-hourly events. In particular, ancillary services are not represented. \n\nWe do not model power plants at the plant level, but we rather use representative technologies. Thus, one limitation is the absence of constraints related to unit commitment, such as start-up cost and delay, minimum load, and part-load efficiency. \nHowever, this default is in part compensated for nuclear. We use real data on age limit (or retirement), so the model retrofits plants whose capacity is in line with plant-level data. On the contrary, new nuclear will be installed continuously, while in reality it composed of discrete power plants with a significant size (1.3 GW for the EPR technology).\nFor renewable, the representative technology assumption is less of an issue as these technologies are modular, and very small in size. The continuous approach is here a good assumption for costs. However, this approach does not enable one to distinguish the different potentials within a country, both for solar and wind. \n\n%%%%%%%%%%%%%%%%\n\n\\clearpage\n\n\\subsubsection{Model Calibration}\n\n\\label{app:calibration}\n\nThe model is calibrated using capital cost, fixed O\\&M and variable O\\&M costs. All payments are annualized with a 5\\% interest rate. \n\n%The corresponding LCOE with usual load factor are given in the Figure \\ref{fig:calibration_LCOE}.\n%\\begin{figure}[!ht]\n%\t\\centering\n%\t\\includegraphics[width=12cm]{figures/calibration_LCOE.png}\n%\t\\caption{LCOE computed from input data of the model}\n%\t\\label{fig:calibration_LCOE}\n%\\end{figure}\n\n\\begin{table}[!ht]\n\t%\\colorTable\n\t\\centering\n\t\\caption{Main model parameters}\n\t\\begin{tabular}{llr}\n\t\t\\toprule\n\t\tparameter&value&unit\\\\\n\t\t\\midrule\n\t\tRate of pure time preference &0&\\%\\\\\n\t\tFinancial interest rate&5&\\%\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\begin{table}[!ht]\n\t\\centering\n\t\\caption{Investment costs (euros/kW)}\n\t\\label{tab:Investment _costs}\n\t\\begin{adjustbox}{width=1\\textwidth}\n\t\\small\n\t\\begin{tabular}{llllllllllll}\n\t\t\\toprule\n\t\t Year & onshore & PV & Coal & CCGT & TAC & river & lake & pump  \\\\\n\t\t\\midrule\n\t\t2014 & 1650 & 1560 & 1500 & 800 & 400 & 3000 & 2000 & 2000  \\\\\n\t\t2020 & 1572 & 1194 & 1500 & 800 & 400 & 3000 & 2000 & 2000 \\\\\n\t\t2030 & 1443 & 869 & 1500 & 800 & 400 & 3000 & 2000 & 2000  \\\\\n\t\t2040 & 1313 & 735 & 1500 & 800 & 400 & 3000 & 2000 & 2000 \\\\\n\t\t2050 & 1184 & 600 & 1500 & 800 & 400 & 3000 & 2000 & 2000 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{adjustbox}\n\\end{table}\n\n\\begin{table}[!ht]\n\t\\centering\n\t\\caption{Fixed O\\&M costs (euro/MWh)}\n\t\\label{tab:OM_costs}\n\t\t\\begin{adjustbox}{width=1\\textwidth}\n\t\\small\n\t\\begin{tabular}{llllllllllll}\n\t\t\\toprule\n\t\tYear & onshore & PV & Coal & CCGT & TAC & river & lake & pump & nuc\\_hist & nuc\\_renov & nuc\\_new \\\\\n\t\t\\midrule\n\t\t2014 & 35 & 25 & 30 & 20 & 15 & 60 & 60 & 20 & 188 & 188 & 100 \\\\\n\t\t2020 & 35 & 25 & 30 & 20 & 15 & 60 & 60 & 20 & 188 & 188 & 100 \\\\\n\t\t2030 & 35 & 25 & 30 & 20 & 15 & 60 & 60 & 20 & 188 & 188 & 100 \\\\\n\t\t2040 & 35 & 25 & 30 & 20 & 15 & 60 & 60 & 20 & 188 & 188 & 100 \\\\\n\t\t2050 & 35 & 25 & 30 & 20 & 15 & 60 & 60 & 20 & 188 & 188 & 100 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{adjustbox}\n\\end{table}\n\n\n\\begin{table}\n\t\\centering\n\t\\caption{\\coo\\ price}\n\t\\label{tab:CO2_price}\n\t\\begin{tabular}{llll}\n\t\t\\toprule\n\t\tYear & \\coo\\ price & & \\\\\n\t\t\\midrule\n\t\t& Low & High \\\\\n\t\t2014 & 21 & 42 \\\\\n\t\t2020 & 28 & 56 \\\\\n\t\t2030 & 50 & 100 \\\\\n\t\t2040 & 75 & 150 \\\\\n\t\t2050 & 100 & 200 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\n\n\\begin{table}[!ht]\n\t\\centering\n\t\\caption{Fuel prices}\n\t\\label{tab:Fuel_prices}\n\t\\begin{tabular}{llll}\n\t\t\\toprule\n\t\teuro/MWh & Coal & Gas & Uranium \\\\\n\t\t\\midrule\n\t\t2014 & 10,3 & 25,3 & 7,30 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\begin{table}\n\t\\centering\n\t\\caption{Efficiencies}\n\t\\label{tab:Efficiencies}\n\t\\begin{tabular}{lll}\n\t\t\\toprule\n\t\tCoal & CCGT & TAC \\\\\n\t\t\\midrule\n\t\t0,43 & 0,61 & 0,410 \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n%%%%%%%%%%%%%%%%%%\n\\clearpage\n\\subsection{Additional material}\n\n\\subsubsection{Plausible costs of retrofitted plants}\n\n\\begin{table}[!htp]\n\t\\centering\n\t\\caption{Historical values of French nuclear plants in the literature, in the best case}\n\t\\label{tab:historical_costs}\n\t\\begin{tabular}{llll}\n\t\t\\toprule\n\t\tItem & Cost & Unit & Source \\\\\n\t\t\\midrule\n\t\tHistorical OPEX (excluding fuel) & 13.3 & euro/MWh & Boccard, 2014 \\\\\n\t\tFuel & 5.7 & euro/MWh & Cour des Comptes, 2014, p. 13 \\\\\n\t\tWaste & 3.6 &  & Cour des Comptes, 2014, p. 24 \\\\\n\t\tDecommissioning & 1 &  & Cour des Comptes, 2014, p. 24 \\\\\n\t\tCapital rate & 5 & \\% &  \\\\\n\t\tLifetime extension & 20 & years & \\\\\n\t\tavailability & 83.5 & \\% & \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\n\\begin{table}[!htp]\n\t\\centering\n\t\\caption{Retrofit costs according to EDF}\n\t\\label{tab:costs_grand_carenage}\n\t\\begin{tabular}{lll}\n\t\t\\toprule\n\t\tAdditional CAPEX & 74730 & million euros \\\\\n\t\t\\midrule\n\t\tAdditional OPEX & 25160 & million euros \\\\\n\t\tCapacity concerned & 53200 & MW \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\n\\begin{table}[!htp]\n\t\\centering\n\t\\caption{Sensitivity tests}\n\t\\label{tab:sensitivity_tests}\n\t\\begin{tabular}{lll}\n\t\t\\toprule\n\t\tCAPEX & 30 & \\% \\\\\n\t\t\\midrule\n\t\tHistorical OPEX & 27.5 & euro/MWh \\\\\n\t\tCapital rate & 10 & \\% \\\\\n\t\tLifetime extension & 10 & years \\\\\n\t\tAvailability & 70 & \\% \\\\\n\t\tWaste & x2 &  \\\\\n\t\tDecommissioning & x2 &  \\\\\n\t\tInsurance & 8.5 & euro/MWh \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\clearpage\n\n\\subsubsection{Strategies examined}\n\\label{sec:strategies_examined}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\\includegraphics[height=7cm]{figures/strategies.png}\n\t\\caption{Nuclear capacity of existing plants, including retrofit, in the 27 strategies}\n\t\\label{fig:strategies}\n\\end{figure}\n\n\\clearpage\n\nThe first period includes all reactors that reach 40 years before 2021, which represents 14 reactors. The second period includes all the reactors reaching 40 years between 2021 and 2025, which represent 23 additional reactors. The final period goes up to 2050 and represents the remaining 21 reactors.\n\n\\begin{table}[!hb]\n\t\\centering\n\t\\caption{Share of retrofitted nuclear plants in each period}\n\t\\label{tab:shareNukeRetrofit}\n\t\\small\n\t\\begin{tabular}{llll}\n\t\t\\toprule\n\t\tStrategy & Period1 & Period2 & Period3 \\\\\n\t\t\\midrule\n\t\tS1 & 0\\% & 0\\% & 0\\% \\\\\n\t\tS2 & 0\\% & 0\\% & 50\\% \\\\\n\t\tS3 & 0\\% & 0\\% & 100\\% \\\\\n\t\tS4 & 0\\% & 50\\% & 0\\% \\\\\n\t\tS5 & 0\\% & 50\\% & 50\\% \\\\\n\t\tS6 & 0\\% & 50\\% & 100\\% \\\\\n\t\tS7 & 0\\% & 100\\% & 0\\% \\\\\n\t\tS8 & 0\\% & 100\\% & 50\\% \\\\\n\t\tS9 & 0\\% & 100\\% & 100\\% \\\\\n\t\tS10 & 50\\% & 0\\% & 0\\% \\\\\n\t\tS11 & 50\\% & 0\\% & 50\\% \\\\\n\t\tS12 & 50\\% & 0\\% & 100\\% \\\\\n\t\tS13 & 50\\% & 50\\% & 0\\% \\\\\n\t\tS14 & 50\\% & 50\\% & 50\\% \\\\\n\t\tS15 & 50\\% & 50\\% & 100\\% \\\\\n\t\tS16 & 50\\% & 100\\% & 0\\% \\\\\n\t\tS17 & 50\\% & 100\\% & 50\\% \\\\\n\t\tS18 & 50\\% & 100\\% & 100\\% \\\\\n\t\tS19 & 100\\% & 0\\% & 0\\% \\\\\n\t\tS20 & 100\\% & 0\\% & 50\\% \\\\\n\t\tS21 & 100\\% & 0\\% & 100\\% \\\\\n\t\tS22 & 100\\% & 50\\% & 0\\% \\\\\n\t\tS23 & 100\\% & 50\\% & 50\\% \\\\\n\t\tS24 & 100\\% & 50\\% & 100\\% \\\\\n\t\tS25 & 100\\% & 100\\% & 0\\% \\\\\n\t\tS26 & 100\\% & 100\\% & 50\\% \\\\\n\t\tS27 & 100\\% & 100\\% & 100\\% \\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\\end{table}\n\n\\clearpage\n\n\\subsubsection{Optimum power mixes}\n\\label{app:optimumMixes}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\\subfloat[Optimum for retrofitted nuclear below or equal to 40 \\emwh] {\n\t\t\\includegraphics[height=6.5cm]{figures/powerMix_R40N100MedD.png}\n\t\t\\label{fig:nukeShare40}\n\t}\n\t\\subfloat[Optimum for retrofitted nuclear around 70 \\emwh] {\n\t\t\\includegraphics[height=6.5cm]{figures/powerMix_R70N100MedD.png}\n\t\t\\label{fig:nukeShare70}\n\t}\n\\end{figure}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\t\\subfloat[Optimum for retrofitted nuclear around 80 \\emwh] {\n\t\t\\includegraphics[height=6.5cm]{figures/powerMix_R80N100MedD.png}\n\t\t\\label{fig:nukeShare80}\n\t}\n\t\\subfloat[Optimum for retrofitted nuclear around 90 \\emwh] {\n\t\t\\includegraphics[height=6.5cm]{figures/powerMix_R90N100MedD.png}\n\t\t\\label{fig:nukeShare90}\n\t}\n\t\\caption{Optimum power mix for various nuclear retrofitting costs}\n\\end{figure}\n\n\n\\begin{figure}[!ht]\n\t\\centering\n\t\\includegraphics[height=8cm]{figures/powerMixSensitivity.png}\n\t\\caption{Optimal nuclear shares and sensitivity analysis}\n\t\\label{fig:powerMixSensitivity}\n\\end{figure}\n\n\n%%%%%%%%%%%%\n\n\\clearpage\n\n\\subsubsection{Analysis with PRIM}\n\n\n%\\paragraph{Choice of threshold}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\\includegraphics[width=6cm]{figures/quantile_regret.pdf}\n\t\\caption{Ordered distribution of regret for the three candidate strategies S9, S24 and S18}\n\t\\label{fig:quantile_regret}\n\\end{figure}\n\n%\\paragraph{Efficiency frontier}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\\subfloat[With the cluster from S9] {\n\t\t\\includegraphics[width=6cm]{figures/low_regret_frontier_S9.pdf}\n\t}\n\\subfloat[With the cluster from S18 and S24] {\n\t\t\\includegraphics[width=6cm]{figures/low_regret_frontier_S18.pdf}\n}\n\t\\caption{Trade-offs and efficiency fontier using the PRIM-generated cluster from strategy S9 and strategy S18 and S24}\n\t\\label{fig_app:low_regret_frontier}\n\\end{figure}\n\n\n%\\paragraph{Regrets of the strategies S9, S18 and S27}\n\\begin{figure}[!ht]\n\t\\centering\n\t\\subfloat[Regret of the full-retrofit strategy S27] {\n\t\t\\makebox[5.5cm][c]{\\includegraphics[height=5cm]{figures/vulnerabilities_S27.pdf}}\n\t\t\\label{fig_app:vulnerabilities_S27}\n\t} \n\n\t\\subfloat[Regret of the full-retrofit strategy S9] {\n\t\t\\makebox[5.5cm][c]{\\includegraphics[height=5cm]{figures/vulnerabilities_S9.pdf}}\n\t} \\qquad\n\t\\subfloat[Regret of the full-retrofit strategy S18]{\n\t\t\\makebox[6cm][c]{\\includegraphics[height=5cm]{figures/vulnerabilities_S18.pdf}}\n\t\t\\label{fig_app:vulnerabilities_S9_S18_S27}\n\t}\n\t\\caption{Regret of the full-retrofit strategy S9, S18 and S27}\n\\end{figure}\n%\\paragraph{Optimal trajectory depending on implicit probabilities}\n\\begin{figure}[!h]\n\t\\centering\n\t\\subfloat[With the cluster from strategy S9] {\n\t\t\\includegraphics[width=6cm]{figures/odds_S9.pdf}\t\n\t}\n\t\\subfloat[With the cluster from strategy S18 and S24] {\n\t\t\\includegraphics[width=6cm]{figures/odds_S18.pdf}\t\n\t}\n\t\\caption{Optimal strategy depending on the implicit odds of the decision maker}\n\t\\label{fig_app:odds}\n\\end{figure}\n\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%ù\n\\clearpage\n\\subsubsection{Comparison with official scenarios}\n\n\\begin{figure}[!htp]\n\t\\centering\n\t\\subfloat[Nuclear share (\\%)] {\n\t\t\\includegraphics[height=6cm]{figures/dnte_nuc_shares.pdf}\n\t}\n\\subfloat[Demand levels (TWh/year)] {\n\t\t\\includegraphics[height=6cm]{figures/dnte_demands.pdf}\n\t}\n\t\\caption{Characteristics of the four official scenarios in the French national debate \\\\Source: \\citet{DNTE_gt2} and authors' calculations}\n\t\\label{fig:DNTE_scenarios}\n\\end{figure}\n\n", "meta": {"hexsha": "eb792b4a8cfbfb3e705b5ffdd0a57050f200de28", "size": 16256, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter2/appendix.tex", "max_stars_repo_name": "QPerrier/Dissertation", "max_stars_repo_head_hexsha": "bf7382137cee951292aa7fb0404b9075d7d2a2eb", "max_stars_repo_licenses": ["MTLL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter2/appendix.tex", "max_issues_repo_name": "QPerrier/Dissertation", "max_issues_repo_head_hexsha": "bf7382137cee951292aa7fb0404b9075d7d2a2eb", "max_issues_repo_licenses": ["MTLL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter2/appendix.tex", "max_forks_repo_name": "QPerrier/Dissertation", "max_forks_repo_head_hexsha": "bf7382137cee951292aa7fb0404b9075d7d2a2eb", "max_forks_repo_licenses": ["MTLL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.8046511628, "max_line_length": 466, "alphanum_fraction": 0.7113065945, "num_tokens": 5321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5621765008857982, "lm_q1q2_score": 0.4004001971537003}}
{"text": "\\documentclass[11pt]{amsart}\n\\usepackage{geometry}\n\\geometry{letterpaper}\n\\usepackage{graphicx}\n\\usepackage{amssymb}\n\\usepackage{amsmath}\n\\usepackage{siunitx}\n\\usepackage{tikz}\n\\usepackage{lscape}\n\\usetikzlibrary{dsp,fit,positioning}\n\n\\input{../util/airfoils.tex}\n\\input{../util/wing.tex}\n\\input{../util/coordinate_systems.tex}\n\\input{../util/control.tex}\n\n\\newcommand{\\qhat}{\\hat{q}}\n\\newcommand{\\cbar}{\\bar{c}}\n\\newcommand{\\qbar}{\\bar{q}}\n\\newcommand{\\cmd}{\\mathrm{cmd}}\n\\newcommand{\\ff}{\\mathrm{ff}}\n\\newcommand{\\eff}{\\mathrm{eff}}\n\\newcommand{\\app}{\\mathrm{app}}\n\\newcommand{\\wind}{\\mathrm{wind}}\n\\newcommand{\\kite}{\\mathrm{kite}}\n\\newcommand{\\nom}{\\mathrm{nom}}\n\\newcommand{\\aero}{\\mathrm{aero}}\n\\newcommand{\\geom}{\\mathrm{geom}}\n\n\\begin{document}\n\n\\section{Servo model}\nExpressing everything in terms of shaft angle $\\theta$, which is $\\theta_m / g$.\n\\begin{eqnarray}\n\\dot{\\theta}_{\\mathrm{ref}} &=& \\omega_{\\mathrm{ref}}\n(\\theta_{\\mathrm{cmd}} - \\theta_{\\mathrm{ref}}) \\\\\nv &=& k_p (\\theta_{\\mathrm{ref}} - \\theta) +\nk_d (\\dot{\\theta}_{\\mathrm{ref}} - \\dot{\\theta}) \\\\\ni &=& (v - k_{\\tau} g \\dot{\\theta}) / Z \\\\\nI_{\\mathrm{servo}}\\, g \\ddot{\\theta} &=& k_{\\tau} i - b \\dot{\\theta} / g +\n\\tau_{\\mathrm{ext}} / g \\\\\n\\tau_{\\mathrm{ext}} &=& \\frac{1}{2} \\rho v^2 A c C_{m_{\\delta_i}} \\theta\n\\end{eqnarray}\n$\\omega_{\\mathrm{ref}} = 100$ rad/s, $k_p = 1000$ V/rad, $k_d = 100$\nV/rad-s, $k_{\\tau} = 0.239$ N-m/A, $g = 160$,\n$I_{\\mathrm{servo}}= 2.3 \\times 10^{-4}$ kg-m$^2$.\n$Z = \\sqrt{R^2 + (g \\dot{\\theta} L)^2}$.\n$R = 0.886$.  The friction constant $b$ is between 70 and 170\nN-m/(rad/s) of shaft velocity.  For the ailerons, $C_{m_{\\delta_a}} =\n0.0026$.\n\n\\begin{equation}\n\\frac{\\Theta_{\\mathrm{ref}}(s)}{\\Theta_{\\mathrm{cmd}}(s)} =\n\\frac{\\omega_{\\mathrm{ref}}}{s + \\omega_{\\mathrm{ref}}}\n\\end{equation}\n\n\\begin{equation}\nV(s) = (k_p + k_d s) (\\Theta_{\\mathrm{ref}}(s) - \\Theta(s))\n\\end{equation}\n\n\\begin{equation}\nI_{\\mathrm{servo}}\\, g s^2 \\Theta(s) =\nk_{\\tau} (k_p + k_d s) (\\Theta_{\\mathrm{ref}}(s) - \\Theta(s)) / Z -\nk_{\\tau}^2 g s \\Theta(s) / Z\n\\end{equation}\n\n\\begin{equation}\n\\frac{\\Theta(s)}{\\Theta_{\\mathrm{cmd}}(s)} =\n\\frac{\\omega_{\\mathrm{ref}}}{s + \\omega_{\\mathrm{ref}}}\n\\cdot\n\\frac{k_{\\tau} (k_p + k_d s)}\n{g Z I_{\\mathrm{servo}} s^2 + (k_{\\tau} k_d + k_{\\tau}^2 g) s +\n(k_{\\tau} k_p - \\frac{Z \\bar{q} A c}{g} C_{m_{\\delta_i}})}\n\\end{equation}\n\n\\end{document}\n", "meta": {"hexsha": "5fbce4c9429595a39bb10506c29ee6c6922d54dd", "size": 2377, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "documentation/control/simulator/servos.tex", "max_stars_repo_name": "leozz37/makani", "max_stars_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1178, "max_stars_repo_stars_event_min_datetime": "2020-09-10T17:15:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:59:35.000Z", "max_issues_repo_path": "documentation/control/simulator/servos.tex", "max_issues_repo_name": "leozz37/makani", "max_issues_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-22T05:22:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-22T05:22:35.000Z", "max_forks_repo_path": "documentation/control/simulator/servos.tex", "max_forks_repo_name": "leozz37/makani", "max_forks_repo_head_hexsha": "c94d5c2b600b98002f932e80a313a06b9285cc1b", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 107, "max_forks_repo_forks_event_min_datetime": "2020-09-10T17:29:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T09:00:14.000Z", "avg_line_length": 30.8701298701, "max_line_length": 80, "alphanum_fraction": 0.6302061422, "num_tokens": 967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4004001971537002}}
{"text": "\\documentclass{article}\n\\usepackage{amsfonts}\n\\usepackage[operators]{cryptocode}\n\\usepackage[utf8]{inputenc}\n\n\\title{Introduction of the committed encryption}\n\\author{Weikeng Chen\\\\\n\\vspace{0.12em}\nfor CS294-144 Blockchain course project}\n\\date{May 2018}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Motivation}\n\nWe want to encrypt one message to several individual parties. With public-key encryption under a group $\\mathbb{G}$ and the group generator $g\\in\\mathbb{G}$, we assume there are three parties, and their public/private key pairs are $(g^{x_1},x_1)$,  $(g^{x_2},x_2)$, and $(g^{x_3},x_3)$, respectively, we can encrypt a message $m$ as follows:\n\\[\n\\begin{array}{l}\nr_1\\sample[0,...,|\\mathbb{G}|-1],~r_2\\sample[0,...,|\\mathbb{G}|-1],~r_3\\sample[0,...,|\\mathbb{G}|-1],\\\\\nk\\sample\\{0,1\\}^\\lambda,\\\\\nc_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus k,\\\\\nc_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k,\\\\\nc_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\nwhere $\\mathsf{KDF}(\\cdot)$ is a key derivation function and $\\mathsf{AuthEnc}$ refers to an authenticated encryption scheme.\n\nFor honest encryption, all three parties can decrypt the message using their secret key. However, if the encryption is not honest, different parties may see different messages, we formalize as follows:\n\\[\n\\begin{array}{l}\nr_1\\sample[0,...,|\\mathbb{G}|-1],~r_2\\sample[0,...,|\\mathbb{G}|-1],~r_3\\sample[0,...,|\\mathbb{G}|-1],\\\\\nk\\sample\\{0,1\\}^\\lambda,\\\\\nc_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus k,\\\\\nc_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k~\\boxed{\\oplus\\Delta_2},\\\\\nc_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k~\\boxed{\\oplus\\Delta_3},\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\nin which the party 2 obtains $\\mathsf{k}\\oplus\\Delta_2$ and the party 3 obtains $\\mathsf{k}\\oplus\\Delta_3$ instead of $\\mathsf{k}$. Note that the party 2's key $\\mathsf{k}\\oplus\\Delta_2$ may decrypt $c_4$ into non-$\\perp$ result, as the authenticity of authenticated encryption does not necessarily protect against malicious encryption.\n\nWe want to provide a multi-recipient encryption that satisfies the following properties: (1) semantic security; (2) party 1 can detect whether $c_2$ and $c_3$ is generated honestly. Therefore, a malicious encryption cam be detected by the party 1 without knowing the secret keys of the party 2 and the party 3.\n\n\\section{Our construction, informally}\nWe encrypt the message as follows with a pseudorandom function:\n\\[\n\\begin{array}{l}\ns\\sample\\{0,1\\}^\\lambda,~k=\\mathsf{PRF}_s(1),\\\\\nr_1\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus s,\\\\\nr_2=\\mathsf{PRF}_s(2)\\mod{|\\mathbb{G}|},\\\\\n\\qquad c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k,\\\\\nr_3=\\mathsf{PRF}_s(3)\\mod{|\\mathbb{G}|},\\\\\n\\qquad c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\nassumed the Hash Diffie-Hellman (HDH) assumption holds on the group $\\mathbb{G}$. \n\n\\smallskip\n\\noindent\\textbf{Semantic security.} We can prove the semantic security of this construction with the random oracle heuristic. \n\nBy hybrid arguments, we have the following proof. We assume the distinguisher has all the public keys, but does not have any private keys of the three parties.\n\n\\smallskip\n\\noindent $\\mathbf{H}_0$: the honest generation.\n\n\\smallskip\n\\noindent $\\mathbf{H}_1$: in this hybrid, we change the $s$ in $c_1$ into $0^\\lambda$:\n\\[\n\\begin{array}{l}\ns\\sample\\{0,1\\}^\\lambda,~k=\\mathsf{PRF}_s(1),\\\\\nr_1\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad \\boxed{c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1}),}\\\\\nr_2=\\mathsf{PRF}_s(2)\\mod{|\\mathbb{G}|},\\\\\n\\qquad c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k,\\\\\nr_3=\\mathsf{PRF}_s(3)\\mod{|\\mathbb{G}|},\\\\\n\\qquad c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\n\nThis hybrid is computationally indistinguishable with $\\mathbf{H}_0$ because $\\mathsf{KDF}(g^{x_1r_1})$ is computationally indistinguishable to a random $\\lambda$-bit string assuming HDH. \n\n\\smallskip\n\\noindent $\\mathbf{H}_2$: in this hybrid, we change $k$, $r_2$, and $r_3$ to randomly sampled values and discard $s$:\n\n\\[\n\\begin{array}{l}\n\\boxed{k\\sample\\{0,1\\}^\\lambda,}\\\\\nr_1\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1}),\\\\\n\\boxed{r_2\\sample[0,...,|\\mathbb{G}|-1],}\\\\\n\\qquad c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k,\\\\\n\\boxed{r_3\\sample[0,...,|\\mathbb{G}|-1],}\\\\\n\\qquad c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\n\nThis hybrid is computationally indistinguishable with $\\mathbf{H}_1$ because of $\\mathsf{PRF}$ with hidden seed $s$. \n\n\\smallskip\n\\noindent $\\mathbf{H}_3$: in this hybrid, we hide the key $k$:\n\n\\[\n\\begin{array}{l}\nr_1\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1}),\\\\\nr_2\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad \\boxed{c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2}),}\\\\\nr_3\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad \\boxed{c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3}),}\\\\\nk\\sample\\{0,1\\}^\\lambda,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\mathsf{msg}).\n\\end{array}\n\\]\n\nThis hybrid is computationally indistinguishable with $\\mathbf{H}_2$ due to the same reason for $\\mathbf{H}_1\\stackrel{\\mathsf{c}}{\\approx}\\mathbf{H}_0$.\n\n\\smallskip\n\\noindent $\\mathbf{H}_4$: in this hybrid, we change the message into $1^l$, where $l$ is the message size:\n\n\\[\n\\begin{array}{l}\nr_1\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1}),\\\\\nr_2\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2}),\\\\\nr_3\\sample[0,...,|\\mathbb{G}|-1],\\\\\n\\qquad c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3}),\\\\\nk\\sample\\{0,1\\}^\\lambda,\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_k(\\boxed{1^l}).\n\\end{array}\n\\]\n\nThis hybrid is computationally indistinguishable with $\\mathbf{H}_3$ due to the message indistinguishability of the authenticated encryption.\n\nAccording to the hybrid arguments, $\\mathbf{H}_0\\stackrel{\\mathsf{c}}{\\approx}\\mathbf{H}_4$, but $\\mathbf{H}_4$ can be simulated by a PPT simulator without the message. This shows that our construction achieves semantic security under HDH assumption.\n\n\\smallskip\n\\noindent\\textbf{Accountability (in our definition).} As mentioned in the motivation section, we want the party 1 to be able to detect malicious encryption, in which different parties will see different results.\n\nWe first introduce the problem. In a nutshell, we want to see if $\\Delta_1$, $\\Delta_2$, ..., and $\\Delta_4$ equal to zero pads and whether $k=k'$ in the following ciphertext:\n\n\\[\n\\begin{array}{l}\nc_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus s,\\\\\nc_2=g^{r_2}~\\boxed{\\oplus\\Delta_1}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k ~\\boxed{\\oplus\\Delta_2,}\\\\\nc_3=g^{r_3}~\\boxed{\\oplus\\Delta_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k ~\\boxed{\\oplus\\Delta_4,}\\\\\nc_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_{k'}(\\mathsf{msg}).\n\\end{array}\n\\]\nwhere $k=\\mathsf{PRF}_s(1)$, $r_2=\\mathsf{PRF}_s(2)$, and $r_3=\\mathsf{PRF}_s(3)$.\n\nWe now introduce the algorithm to detect the malicious encryption.  \n\\[\n\\begin{array}{l}\n\\mathsf{Detect}(c_1,c_2,c_3,c_4,\\mathbb{G},g,g^{x_1},g^{x_2},g^{x_3},x_1)\n\\end{array}\n\\]\nwhich runs as follows:\n\\begin{enumerate}\n    \\item Computes $g^{x_1r_1}$ from $g^{r_1}$ and $x_1$.\n    \n    \\item Recovers $s$ by XOR the second part of $c_1$ with $\\mathsf{KDF}(g^{x_1r_1})$.\n    \n    \\item Computes the following pseudorandom values:\n    \\begin{itemize}\n        \\item $k=\\mathsf{PRF}_s(1)$.\n        \\item $r_2=\\mathsf{PRF}_s(2)$.\n        \\item $r_3=\\mathsf{PRF}_s(3)$.\n    \\end{itemize}\n    \n    \\item Checks whether the first part of $c_2$ equals to $g^{r_2}$ and the first part of $c_3$ equals to $g^{r_3}$. If not, outputs $\\mathsf{CHEAT}$ and terminates. Otherwise, we know $\\Delta_1$ and $\\Delta_3$ are both zero pads, and the ciphertext has the following format:\n    \\[\n    \\begin{array}{l}\n    c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus s,\\\\\n    c_2=\\boxed{g^{r_2}}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k \\oplus\\Delta_2,\\\\\n    c_3=\\boxed{g^{r_3}}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k \\oplus\\Delta_4,\\\\\n    c_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_{k'}(\\mathsf{msg}).\n    \\end{array}\n    \\]\n    \n    \\item Computes $g^{x_2r_2}$ from $r_2$ and $g^{x_2}$ and $g^{x_3r_3}$ from $r_3$ and $g^{x_3}$. Note that we only use the public keys of the party 2 and the party 3.\n    \n    \\item Recovers $\\Delta_2$ by XOR the second part of $c_2$ with $\\mathsf{KDF}(g^{x_2r_2})\\oplus k$ and $\\Delta_4$ by XOR the second part of $c_4$ with $\\mathsf{KDF}(g^{x_3r_3})\\oplus k$. \n    \n    \\item Checks if $\\Delta_2$ and $\\Delta_4$ are both zero pads. If not, outputs $\\mathsf{CHEAT}$ and terminates. Otherwise, we know the ciphertext has the following format:\n    \\[\n    \\begin{array}{l}\n    c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus s,\\\\\n    c_2=g^{r_2}\\parallel\\boxed{\\mathsf{KDF}(g^{x_2r_2})\\oplus k,}\\\\\n    c_3=g^{r_3}\\parallel\\boxed{\\mathsf{KDF}(g^{x_3r_3})\\oplus k,}\\\\\n    c_4=\\mathsf{AuthEnc}.\\mathsf{Enc}_{k'}(\\mathsf{msg}).\n    \\end{array}\n    \\]\n    \n    \\item Uses $k$ to decrypt $c_4$. If the decrypted result is $\\perp$, the ciphertext is not valid, the algorithm outputs $\\mathsf{CHEAT}$ and terminates. Otherwise, outputs $\\mathsf{ACCEPT}$, as the ciphertext now has the following format the same as the one from honest encryption:\n    \n    \\[\n    \\begin{array}{l}\n    c_1=g^{r_1}\\parallel\\mathsf{KDF}(g^{x_1r_1})\\oplus s,\\\\\n    c_2=g^{r_2}\\parallel\\mathsf{KDF}(g^{x_2r_2})\\oplus k,\\\\\n    c_3=g^{r_3}\\parallel\\mathsf{KDF}(g^{x_3r_3})\\oplus k,\\\\\n    c_4=\\mathsf{AuthEnc}.\\boxed{\\mathsf{Enc}_{k}}(\\mathsf{msg}).\n    \\end{array}\n    \\]\n\\end{enumerate}\nAccording to the discussion above, if the detection algorithm outputs $\\mathsf{ACCEPT}$, three parties will see the same decrypted result. \n    \n\\end{document}\n\n", "meta": {"hexsha": "b52f4937e60db64be83b918a62b2adc154c035e7", "size": 10043, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/main.tex", "max_stars_repo_name": "huyuncong/committed_encryption", "max_stars_repo_head_hexsha": "19a3e30a2e994f0ff75338f8941fd8ffbb54c112", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-23T11:30:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-23T11:30:54.000Z", "max_issues_repo_path": "doc/main.tex", "max_issues_repo_name": "huyuncong/committed_encryption", "max_issues_repo_head_hexsha": "19a3e30a2e994f0ff75338f8941fd8ffbb54c112", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-05-05T00:08:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-05T00:08:55.000Z", "max_forks_repo_path": "doc/main.tex", "max_forks_repo_name": "huyuncong/committed_encryption", "max_forks_repo_head_hexsha": "19a3e30a2e994f0ff75338f8941fd8ffbb54c112", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-05-05T00:05:11.000Z", "max_forks_repo_forks_event_max_datetime": "2018-05-05T00:05:11.000Z", "avg_line_length": 46.4953703704, "max_line_length": 342, "alphanum_fraction": 0.6826645425, "num_tokens": 3959, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.5, "lm_q1q2_score": 0.40034600580396046}}
{"text": "\\documentclass[12pt, answers]{exam}\n%\\documentclass[12pt]{exam}\n\\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}\n\\usepackage{setspace}\n\\PassOptionsToPackage{hyphens}{url}\n\\usepackage{tabu}\n\\usepackage{lscape}\n\\onehalfspacing\n\\setlength{\\parindent}{0mm} \\setlength{\\parskip}{1em}\n\n% packages\n\\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}\n\\RequirePackage{tikz}\n% The float package HAS to load before hyperref\n\\usepackage{float} % for psuedocode formatting\n\\usepackage{amsthm}\n\\usepackage{epsfig}\n\\usepackage{times}\n\\renewcommand{\\ttdefault}{cmtt}\n\\usepackage{amsmath}\n\\usepackage{graphicx} % for graphics files\n\n% for creating indented blocks\n\\usepackage{scrextend}\n\\usepackage{paralist, tabularx}\n\n% from Denovo Methods Manual\n\\usepackage{mathrsfs}\n\\usepackage[mathcal]{euscript}\n\\usepackage{color}\n\\usepackage{array}\n\n\\usepackage[pdftex]{hyperref}\n\\usepackage[parfill]{parskip}\n\\usepackage{cancel}\n\n\\newcommand{\\nth}{n\\ensuremath{^{\\text{th}}} }\n\\newcommand{\\ve}[1]{\\ensuremath{\\mathbf{#1}}}\n\\newcommand{\\Macro}{\\ensuremath{\\Sigma}}\n\\newcommand{\\vOmega}{\\ensuremath{\\hat{\\Omega}}}\n\\newcommand{\\cc}[1]{\\ensuremath{\\overline{#1}}}\n\\newcommand{\\ccm}[1]{\\ensuremath{\\overline{\\mathbf{#1}}}}\n\n%--------------------------------------------------------------------\n%--------------------------------------------------------------------\n\\begin{document}\n\\begin{center}\n{\\bf NE 155, Topic 15, S21 \\\\\n2-D Finite Difference/Volume methods\\\\ \nApril 8, 2021}\n\\end{center}\n\n\\setlength{\\unitlength}{1in}\n\\begin{picture}(6,.1) \n\\put(0,0) {\\line(1,0){6.25}}         \n\\end{picture}\n\nMuch of this can be found in Duderstadt and Hamilton, Chp.\\ 5 Section II.B. \n\n%-------------------------------------------------------------\n\\section*{PDEs}\n\nWe'll start by considering PDEs in general, and then move on to the Diffusion Equation specifically.\n\nRecall: a partial differential equation is an equation containing an unknown function of two or more variables and its derivatives with respect to those variables. \n\nIf the PDE is linear in $u$ and all derivatives of $u$, then we say that the PDE is linear.\n%\n\\begin{equation}\nA\\frac{\\partial^2 u}{\\partial x^2} + B\\frac{\\partial^2 u}{\\partial x \\partial  y} + C\\frac{\\partial^2 u}{\\partial y^2} + D\\frac{\\partial u}{\\partial x} + E\\frac{\\partial u}{\\partial y} + Fu = G \\nonumber\n\\end{equation}\n%\nThis equation is a \\textbf{2nd order} PDE in two variables. It is \\textbf{linear} if $A$ through $G$ do not depend on $u$ (they may depend on $x$ and $y$).\n\n%-------------------------------------------------------------\n\\vspace*{1em}\n\nRecall that we can classify second order PDEs based on the geometric behavior of their solutions.\n%\n\\begin{itemize}\n\\item Elliptic if $B^2 - 4 AC < 0$. \n\n\\item Hyperbolic if $B^2 - 4 AC > 0$\n\n\\item Parabolic if $B^2 - 4 AC = 0$\n\\end{itemize}\n\n%-------------------------------------------------------------\n\\subsection*{Elliptic Equations}\n\nRecall that the 2-D Laplacian for the function $u(x,y)$ is\n%\n\\ifprintanswers\n\\begin{equation}\n\\nabla^2 u(x,y) = \\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2} = u_{xx} + u_{yy} \\:.\\nonumber\n\\end{equation}\n\\else\n\\\\ \\vspace*{3em} \\\\\n\\fi\n\n%\nThe Laplacian is used in many of the equations that are commonly found in physics:\n%\n\\begin{itemize}\n\\item Laplace's equation\n\\[\\nabla^2 u(x,y) = 0\\]\n\n\\item Poisson's equation \n\\[\\nabla^2 u(x,y) = g(x,y)\\]\n\n\\item Helmholtz's equation (recall that we can make the DE look like this)\n\\[\\nabla^2 u(x,y) +f(x,y)u(x,y) = g(x,y)\\]\n\\end{itemize}\n\n% -----------------------------------------------------\n\\section*{2-D Finite Difference}\n\nWe will use 5 points to define our central-differenced Laplacian:\n\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\draw (0,0)--(0,7);\n\\draw (1,0)--(1,7);\n\\draw (2,0)--(2,7);\n\\draw (3,0)--(3,7);\n\\draw (4,0)--(4,7);\n\\draw (5,0)--(5,7);\n\\draw (6,0)--(6,7);\n\\draw (7,0)--(7,7);\n\\node[below] at (0,-.25) {$x_0$};\n\\node[below] at (1,-.25) {$x_1$};\n\\node[below] at (3,-.25) {$x_{i-1}$};\n\\node[below] at (4,-.25) {$x_i$};\n\\node[below] at (5,-.25) {$x_{i+1}$};\n\\node[below] at (7,-.25) {$x_n$};\n\\node at (3.5, 2.5) {$\\Delta x_i$};\n% begin y\n\\draw (0,0)--(7,0);\n\\draw (0,1)--(7,1);\n\\draw (0,2)--(7,2);\n\\draw (0,3)--(7,3);\n\\draw (0,4)--(7,4);\n\\draw (0,5)--(7,5);\n\\draw (0,6)--(7,6);\n\\draw (0,7)--(7,7);\n\\node[left] at (-.25, 0) {$y_0$};\n\\node[left] at (-.25,1) {$y_1$};\n\\node[left] at (-.25,3) {$y_{j-1}$};\n\\node[left] at (-.25,4) {$y_j$};\n\\node[left] at (-.25,5) {$y_{j+1}$};\n\\node[left] at (-.25,7) {$y_m$};\n  \\node at (2.5,3.5) {$\\Delta y_j$};\n% labels\n\\node at (4,4) [circle,fill=black,scale=0.3] {};\n\\node[below left] at (4,4) {$i,j$};\n\\node at (5,4) [circle,fill=black,scale=0.3] {};\n\\node[below right] at (5,4) {$i+1,j$};\n\\node at (3,4) [circle,fill=black,scale=0.3] {};\n\\node[above left] at (3,4) {$i-1,j$};\n\\node at (4,5) [circle,fill=black,scale=0.3] {};\n\\node[above right] at (4,5) {$i,j+1$};\n\\node at (4,3) [circle,fill=black,scale=0.3] {};\n\\node[below right] at (4,3) {$i,j-1$};\n\\end{tikzpicture}\n\\end{minipage} \\hfill\n%\n\\begin{minipage}{0.5\\textwidth}\n  \\[u(x_i,y_j) = u_{i,j} \\qquad u(x_{i+1},y_j) = u_{i+1,j}\\]\n  \\begin{align}\n  \\frac{\\partial^2 u_{i,j}}{\\partial x^2} = \\frac{\\partial}{\\partial x}\\bigl(\\frac{\\partial u_{i,j}}{\\partial x}\\bigr) =\n\\frac{u_{i-1,j} - 2u_{i,j} + u_{i+1,j}}{\\Delta x_i^2} \\nonumber \\\\\n%\n  \\frac{\\partial^2 u_{i,j}}{\\partial y^2} = \\frac{\\partial}{\\partial y}\\bigl(\\frac{\\partial u_{i,j}}{\\partial y}\\bigr) =\n\\frac{u_{i,j-1} - 2u_{i,j} + u_{i,j+1}}{\\Delta y_j^2} \\nonumber\n\\end{align}\n\\end{minipage}\n\nAll together this gives\n\\ifprintanswers\n\\[\\nabla^2 u_{i,j} = \n\\frac{\\partial^2 u_{i,j}}{\\partial x^2} + \\frac{\\partial^2 u_{i,j}}{\\partial y^2} = \n\\frac{u_{i-1,j} - 2u_{i,j} + u_{i+1,j}}{\\Delta x_i^2} + \\frac{u_{i,j-1} - 2u_{i,j} + u_{i,j+1}}{\\Delta y_j^2}\\]\n%\nIf $\\Delta x_i = $ constant $= \\Delta y_j = h$, then\n%\n\\[ \\nabla^2 u_{i,j} = \\frac{u_{i+1,j} + u_{i-1,j} + u_{i,j+1} + u_{i,j-1} - 4u_{i,j}}{h^2}\\]\n\\else\n\\vspace*{9em}\n\\fi\n\nIf we apply this to Laplace's equation and have fixed boundary conditions:\n%\n\\begin{align}\nu_{i+1,j} &+ u_{i-1,j} + u_{i,j+1} + u_{i,j-1} - 4u_{i,j} = 0, \\quad i = 1, 2, \\dots, n-1, \\quad j = 1, 2, \\dots, m-1 \\nonumber \\\\\n%\nu_{0,j} &= BC_L , \\quad j = 1, 2, \\dots, m-1 \\nonumber \\\\\nu_{i,0} &= BC_B , \\quad i = 1, 2, \\dots, n-1 \\nonumber \\\\\nu_{n,j} &= BC_R , \\quad j = 1, 2, \\dots, m-1 \\nonumber \\\\\nu_{i.m} &= BC_T , \\quad i = 1, 2, \\dots, n-1 \\nonumber\n\\end{align}\n%\nMake sure to check how the corners need to be defined. \n\nWe could apply this directly the the 2-D diffusion equation.\n\n%--------------------------------------------------------------------\n\\section*{2-D Finite Volume Method, Diffusion Equation}\n\nRemember that in 1-D we were solving this\n\\[-\\frac{d}{dx}D(x)\\frac{d \\phi(x)}{dx} + \\Sigma_a(x) \\phi(x) = S(x)\\]\n%\nwith an equilibrium (reflecting) condition at the centerline ($x_0 = 0$) and vacuum on the right ($x_n = a$):\n\\begin{align}\n\\frac{d}{dx}\\phi(x) \\big|_{x=0} &= 0 \\qquad \\text{zero net current,} \\nonumber\\\\\n\\phi(\\tilde{a}) &= 0 \\qquad \\tilde{a} = a + 2D \\:.\\nonumber\n\\end{align}\n\nWe imposed a spatial mesh and said material discontinuities will coincide with the cell edges, $x_i$. Thus, we can assume that the cross sections and the diffusion coefficient are constant in each cell.\n%\n%\\begin{align}\n%D(x) &= D_i \\qquad \\text{for } x_{i-1} \\leq x_i \\nonumber \\\\\n%\\Sigma_{a}(x) &= \\Sigma_{a,i} \\qquad \\text{for } x_{i-1} \\leq x_i \\nonumber \\\\\n%h_i &\\equiv x_i - x_{i-1} \\nonumber \n%\\end{align}\n%\nThe unknown fluxes and known sources are defined at the mesh or cell edges.\n%\\begin{align}\n%\\phi(x_i) &= \\phi_i \\nonumber \\\\\n%S(x_i) &= S_i \\nonumber \n%\\end{align}\n%\nWe then went on to define things for the finite volume method.\n%\\begin{center}\n%\\begin{figure}[h!]\n%\\includegraphics[height=2.5in]{../figs/FVM-DE}\n%\\end{figure}\n%\\end{center}\n\nNow, we're going to extend all of that to two dimensions. We'll start with the multi-D equation:\n\\[-\\nabla \\cdot \\bigl(D(\\vec{r})\\nabla \\phi(\\vec{r})\\bigr) + \\Sigma_a(\\vec{r}) \\phi(\\vec{r}) = S(\\vec{r})\\:.\\]\n%\nThis equation is elliptic:\n\\begin{itemize}\n\\item in general, this is the Helmholtz equation.\n\\item if $\\Sigma_a(\\vec{r})=0$ and $D(\\vec{r})=$ constant, then this takes the form of the Poisson equation.\n\\item if $\\Sigma_a(\\vec{r})=0$ and $S(\\vec{r})=0$, then this becomes Laplace's equation. \n\\end{itemize}\n\nIn 2-D:\n\\ifprintanswers\n\\[-\\frac{\\partial}{\\partial x}D(x,y)\\frac{\\partial}{\\partial x} \\phi(x,y) -\\frac{\\partial}{\\partial y}D(x,y)\\frac{\\partial}{\\partial y} \\phi(x,y) + \\Sigma_a(x,y) \\phi(x,y) = S(x,y)\\:.\\]\n\\else\n\\\\ \\vspace*{2em} \\\\\n\\fi\n%\nFor now we're going to say we have fixed boundary conditions:\n\\[\\phi(-a,y) = \\Phi_L\\:, \\quad \\phi(a,y) = \\Phi_R\\:, \\quad \\phi(x,-b) = \\Phi_B\\:, \\quad \\phi(x,b) = \\Phi_T\\:,\\]\nwith $x \\in [-a,a]$ and $y \\in [-b,b]$.\n\n\n% ---------------------------------------------------------\n% ---------------------------------------------------------\n\\subsection*{Finite Volume}\n%\n%\\begin{figure}[h!]\n%\\begin{center}\n%\\includegraphics[height=5in]{../figs/2DfvmGrid}\n%\\end{center}\n%\\end{figure}\n\n\\begin{center}\n\\begin{tikzpicture}\n% grid\n\\draw[step=2cm] (2,2) grid (6,6);\n% volume labels\n\\node at (5,3) {$V_{i+1,j}$};\n\\node at (5,5) {$V_{i+1,j+1}$};\n\\node at (3,3) {$V_{i,j}$};\n\\node at (3,5) {$V_{i,j+1}$};\n\\node at (1,7) {$D_{i,j+1}$};\n% surface labels\n\\node[left] at (1.75,3) {$s_1$};\n\\node[left] at (1.75,5) {$s_8$};\n\\node[above] at (3,6.25) {$s_7$};\n\\node[above] at (5,6.25) {$s_6$};\n\\node[right] at (6.25,5) {$s_5$};\n\\node[right] at (6.25,3) {$s_4$};\n\\node[below] at (3,1.75) {$s_2$};\n\\node[below] at (5,1.75) {$s_3$};\n% surrounding grid and markers\n\\draw plot[mark=*, mark options={fill=black}] (4,4) node[below] {$(i,j)$};\n\\draw (4,4) -- plot[mark=*, mark options={fill=black}] (8,4) node[right] {$(i+1,j)$};\n\\draw (4,4)-- plot[mark=*, mark options={fill=black}] (4,0) node[below] {$(i,j-1)$};\n\\draw (4,4)-- plot[mark=*, mark options={fill=black}] (4,8) node[above] {$(i,j+1)$};\n\\draw (4,4)-- plot[mark=*, mark options={fill=black}] (0,4) node[above] {$(i-1,j)$};\n% arrows\n\\draw[<->](7.5,4) -- (7.5,8);\n\\node[right] at (7.5,6) {$\\epsilon_{j+1}$};\n\\draw[<->](7.5,0) -- (7.5,4);\n\\node[right] at (7.5,2) {$\\epsilon_{j}$};\n\\draw[<->](1,2) -- (1,4);\n\\node[left] at (1,3) {$\\epsilon_{j}/2$};\n\\draw[<->](4,0.5) -- (8,0.5);\n\\node[below] at (6, 0.5) {$\\delta_{i+1}$};\n\\draw[<->](0,0.5) -- (4,0.5);\n\\node[below] at (2, 0.5) {$\\delta_{i}$};\n\\draw[<->](4,7) -- (6,7);\n\\node[above] at (5, 7) {$\\delta_{i+1}/2$};\n\\end{tikzpicture}\n\\end{center}\n\n\n\nWe assume the diffusion coefficient, absorption cross section, and source are constant in each cell (cell-centered), e.g., for $V_{i,j}$:\n\\begin{align}\nD(x,y) &= D_{i,j}\\;, \\qquad x_{i-1} \\leq x \\leq x_i \\:\\text{ and }\\: y_{j-1} \\leq y \\leq y_j \\nonumber \\\\\n%\n\\Sigma_a(x,y) &= \\Sigma_{a,i,j}\\;, \\qquad x_{i-1} \\leq x \\leq x_i \\:\\text{ and }\\: y_{j-1} \\leq y \\leq y_j \\nonumber \\\\\n%\nS(x,y) &= S_{i,j}\\;, \\qquad x_{i-1} \\leq x \\leq x_i \\:\\text{ and }\\: y_{j-1} \\leq y \\leq y_j \\nonumber \\\\\n%\n\\Delta x_i &\\equiv \\delta_i = x_{i} - x_{i-1} \\nonumber \\\\\n\\Delta y_j &\\equiv \\epsilon_j = y_{j} - y_{j-1} \\nonumber\n\\end{align}\nAnd analogously for the other 3 cells.\n\nWe further assume that the fluxes are constant over the interval centered around $(x_i, y_j)$ (edge-centered):\n%\n\\ifprintanswers\n\\[\\phi(x,y) = \\phi_{i,j} \\qquad \\text{for } \\bigl(x_i - \\frac{\\delta_i}{2}\\bigr) \\leq x \\leq \\bigl(x_i + \\frac{\\delta_{i+1}}{2}\\bigr) \\:\\text{ and }\\:\\bigl(y_j - \\frac{\\epsilon_j}{2}\\bigr) \\leq x \\leq \\bigl(y_j + \\frac{\\epsilon_{j+1}}{2}\\bigr) \\]\n\\else\n\\\\ \\vspace*{3em}\n\\fi\n\nNow, we integrate the 2-D equation over 4 rectangular partial-volumes (well, areas, technically): $V = V_{i,j} + V_{i+1,j} + V_{i,j+1} + V_{i+1,j+1}$.\n%\n\\[\\int_V d\\vec{r}\\:\\bigl[-\\nabla \\cdot \\bigl(D(\\vec{r})\\nabla \\phi(\\vec{r})\\bigr) +\\Sigma_a(\\vec{r}) \\phi(\\vec{r}) = S(\\vec{r}) \\bigr]\\]\n\n\n% ---------------------------------------------------------\n\\subsubsection*{Streaming Term}\nUse Gauss Theorem to replace the first volume integral with a surface integral:\n%\n\\ifprintanswers\n\\begin{align}\n-\\int_V d\\vec{r}\\:\\bigl[\\nabla \\cdot \\bigl(D(\\vec{r})\\nabla \\phi(\\vec{r})\\bigr)\\bigr] &= -\\int_S d\\vec{S} \\cdot\\bigl(D(\\vec{r})\\nabla \\phi(\\vec{r})\\bigr) \\nonumber \\\\\n%\n= -\\int_S d\\vec{S}\\: D(\\vec{r})\\hat{n} \\cdot \\nabla \\phi(\\vec{r}) &= -\\int_S d\\vec{S} \\:D(\\vec{r})\\frac{\\partial}{\\partial \\hat{n}}\\phi(\\vec{r})\\:. \\nonumber\n\\end{align}\n\\else\n\\\\ \\vspace*{4em} \\\\\n\\fi\n%\nNext, we define the partial derivative w.r.t.\\ direction on each surface, using $O(h)$ forward and backward difference schemes since they're simple:\n\n\\begin{align}\n\\frac{\\partial}{\\partial \\hat{n}}\\phi(\\vec{r}) &= \\frac{\\phi_{i,j-1} - \\phi_{i,j}}{\\epsilon_j} \\qquad \\text{on } S_2 \\:, S_3 \\quad \\text{(bottom)} \\nonumber \\\\\n%\n&= \\frac{\\phi_{i,j+1} - \\phi_{i,j}}{\\epsilon_{j+1}} \\qquad \\text{on } S_7 \\:, S_6 \\quad \\text{(top)} \\nonumber \\\\\n%\n&= \\frac{\\phi_{i-1,j} - \\phi_{i,j}}{\\delta_{i}} \\qquad \\text{on } S_1 \\:, S_8 \\quad \\text{(left)} \\nonumber \\\\\n%\n&= \\frac{\\phi_{i+1,j} - \\phi_{i,j}}{\\delta_{i+1}} \\qquad \\text{on } S_4 \\:, S_5 \\quad \\text{(right)} \\nonumber \n\\end{align}\n%\nWe then use the midpoint rule for the integration and integrate along each surface. Recall that the physics values are cell-centered while the flux is edge-centered. E.g., surfaces $S_2$ and $S_3$:\n%\n\\begin{align*}\n-\\int_{S_2+S_3} d\\vec{S} \\:D(\\vec{r})\\frac{\\partial}{\\partial \\hat{n}}\\phi(\\vec{r}) &= \\boxed{\\frac{\\phi_{i,j} - \\phi_{i,j-1}}{\\epsilon_{j}} \\biggl(\\frac{D_{i,j} \\delta_{i} + D_{i+1,j} \\delta_{i+1}}{2}\\biggr)}\\:,\\\\\n%\nS_6+S_7 &= \\boxed{\\frac{\\phi_{i,j} - \\phi_{i,j+1}}{\\epsilon_{j+1}} \\biggl(\\frac{D_{i,j+1} \\delta_{i} + D_{i+1,j+1} \\delta_{i+1}}{2}\\biggr)}\\:,\\\\\n%\nS_1+S_8 &= \\boxed{\\frac{\\phi_{i,j} - \\phi_{i-1,j}}{\\delta_{i}} \\biggl(\\frac{D_{i,j} \\epsilon_{j} + D_{i,j+1} \\epsilon_{j+1}}{2}\\biggr)}\\:,\\\\\n%\nS_4+S_5 &= \\boxed{\\frac{\\phi_{i,j} - \\phi_{i+1,j}}{\\delta_{i+1}} \\biggl(\\frac{D_{i+1,j} \\epsilon_{j} + D_{i+1,j+1} \\epsilon_{j+1}}{2}\\biggr)}\\:,\n\\end{align*}\n%\nand we do this for each set of surfaces. \n\n\n% ---------------------------------------------------------\n\\subsubsection*{Absorption Term}\nTo integrate absorption, we do four integrals - one over each sub-volume:\n%\n\\ifprintanswers\n\\begin{align}\n\\int_{x_i-\\frac{\\delta_{i}}{2}}^{x_i+\\frac{\\delta_{i+1}}{2}} dx \\int_{y_j-\\frac{\\epsilon_{j}}{2}}^{y_j+\\frac{\\epsilon_{j+1}}{2}}dy\\:\\Sigma_a(x,y) \\phi(x,y) &= \\Sigma_{a,i,j}\\int\\int_{V_{i,j}} dx dy \\: \\phi(x,y) + \\nonumber \\\\\n%\n\\Sigma_{a,i+1,j}\\int\\int_{V_{i+1,j}} dx dy \\: \\phi(x,y) &+ \\Sigma_{a,i+1,j+1}\\int\\int_{V_{i+1,j+1}} dx dy \\: \\phi(x,y) + \\nonumber \\\\\n \\Sigma_{a,i,j+1}\\int\\int_{V_{i,j+1}} dx dy \\: \\phi(x,y) \\:.\\nonumber\n\\end{align}\n\\else\n\\\\ \\vspace*{8em}\\\\\n\\fi\n%\nAgain applying the midpoint scheme and using our edge-centered flux definition:\n%\n\\begin{align}\n\\int \\int dx dy\\:\\Sigma_a(x,y) \\phi(x,y) &= \\boxed{\\phi_{i,j}\\bigl(\\Sigma_{a,i,j} V_{i,j} + \\Sigma_{a,i+1,j} V_{i+1,j} + \\Sigma_{a,i+1,j+1} V_{i+1,j+1} + \\Sigma_{a,i,j+1} V_{i,j+1} \\bigr) } \\nonumber \\\\\n&\\equiv \\phi_{i,j}\\Sigma_{a,ij}\\:, \\nonumber\n\\end{align}\n%\nwhere\n\\[V_{i,j} = \\frac{1}{4}\\delta_i \\epsilon_j \\:, \\quad V_{i+1,j} = \\frac{1}{4}\\delta_{i+1} \\epsilon_{j} \\:, \\quad V_{i+1,j+1} = \\frac{1}{4}\\delta_{i+1} \\epsilon_{j+1} \\:, \\quad V_{i,j+1} = \\frac{1}{4}\\delta_{i} \\epsilon_{j+1} \\:.\\]\n\n\n% ---------------------------------------------------------\n\\subsubsection*{Source Term}\nUsing the same procedure for the source, we get:\n\\begin{align}\n\\int \\int dx dy \\: \\:S(x,y) &= \\boxed{ S_{i,j} V_{i,j} + S_{i+1,j} V_{i+1,j} + S_{i+1,j+1} V_{i+1,j+1} + S_{i,j+1} V_{i,j+1} }\\nonumber \\\\\n&\\equiv S_{ij}\\:. \\nonumber\n\\end{align}\n\n\n% ---------------------------------------------------------\n\\subsubsection*{Discretized Equations}\n\\ifprintanswers\nCollecting all of the terms and separating them, we get a 5-point difference equation for $i=1,\\dots,n-1$; $j=1,\\dots,m-1$:\n%\n\\[a_{i-1,j}^{ij}\\phi_{i-1,j} + a_{i+1,j}^{ij}\\phi_{i+1,j} + a_{i,j-1}^{ij}\\phi_{i,j-1} + a_{i,j+1}^{ij}\\phi_{i,j+1} +  a_{i,j}^{ij}\\phi_{i,j} = S_{ij} \\:.\\]\n%\n\\else\n\\vspace*{3em} \n\\fi\nThe lower index is the cell to which you are coupling, and the upper index is which cell you are in--this becomes important when we're ordering our matrix.\n%\n\\begin{align}\na_{i-1,j}^{ij} &= -\\frac{D_{i,j} \\epsilon_{j} + D_{i,j+1} \\epsilon_{j+1}}{2 \\delta_{i}}  \\nonumber \\\\\n(a_L^{ij} & \\quad \\text{capturing influence of \\textbf{left} flux on center cell}) \\nonumber \\\\\n%\na_{i+1,j}^{ij} &= -\\frac{D_{i+1,j} \\epsilon_{j} + D_{i+1,j+1} \\epsilon_{j+1}}{2 \\delta_{i+1}}  \\nonumber \\\\\n(a_R^{ij} & \\quad \\text{capturing influence of \\textbf{right} flux on center cell}) \\nonumber \\\\\n%\na_{i,j-1}^{ij} &= -\\frac{D_{i,j} \\delta_{i} + D_{i+1,j} \\delta_{i+1}}{2 \\epsilon_{j}}  \\nonumber \\\\\n(a_B^{ij} & \\quad \\text{capturing influence of \\textbf{lower} flux on center cell}) \\nonumber \\\\\n%\na_{i,j+1}^{ij} &= -\\frac{D_{i,j+1} \\delta_{i} + D_{i+1,j+1} \\delta_{i+1}}{2 \\epsilon_{j+1}}  \\nonumber \\\\\n(a_T^{ij} & \\quad \\text{capturing influence of \\textbf{upper} flux on center cell}) \\nonumber \\\\\n%\n\\nonumber \\\\\na_{i,j}^{ij} &= \\Sigma_{a,ij} - \\bigl(a_{i-1,j}^{ij} + a_{i+1,j}^{ij} + a_{i,j-1}^{ij} + a_{i,j+1}^{ij} \\bigr)\n \\:.\\nonumber \\\\\n (a_C^{ij}) & \\nonumber\n\\end{align}\n\nIn this formulation we now have $(n+1) \\times (m+1)$ unknowns. \n\n%-------------------------------------------------------\n\\subsection*{Matrix Form}\nTo write the system in a way that looks like $\\ve{A}\\vec{x} = \\vec{b}$, we need to choose an ordering strategy for how we want to store the points. Let's look at a 3$\\times$3 example:\n\n\\begin{minipage}{0.5\\textwidth}\n%-------------- indices ------------------\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (4,4);\n\\foreach \\y in {1, 2}\n    \\foreach \\x in  {0, 1, 2}\n        \\node[below left] at (2*\\x cm,2*\\y cm) {$(\\x,\\y)$};\n\\node[below] at (0,-.25) {$(0,0)$};\n\\node[below] at (2,-.25) {$(1,0)$};\n\\node[below] at (4,-.25) {$(2,0)$};\n\\end{tikzpicture}\n\\end{minipage} \\hfill\n%-------------- numbered nodes ------------------\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (4,4);\n\\node[below] at (0,-.25) {$0$};\n\\node[below] at (2,-.25) {$1$};\n\\node[below] at (4,-.25) {$2$};\n\\node[below left] at (-.25,2) {$3$};\n\\node[below left] at (2,2) {$4$};\n\\node[below left] at (4,2) {$5$};\n\\node[below left] at (-.25,4) {$6$};\n\\node[below left] at (2,4) {$7$};\n\\node[below left] at (4,4) {$8$};\n\\end{tikzpicture}\n\\end{minipage}\n\nOur solution vector length in this example is 9 (3 $\\times$ 3). Our matrix size is therefore going to be 9 $\\times$ 9. We can think of this as a 3 $\\times$ 3 matrix of 3 $\\times$ 3 matrices:\n\\begin{equation}\n\\underbrace{\\begin{pmatrix}\n\\begin{pmatrix}\na_{0,0}^{00} & a_{1,0}^{00} & 0 \\\\\na_{0,0}^{10} & a_{1,0}^{10} & a_{2,0}^{10} \\\\\n0            & a_{1,0}^{20} & a_{2,0}^{20}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,1}^{00} & 0 & 0 \\\\\n0 & a_{1,1}^{10} & 0 \\\\\n0 & 0 & a_{2,1}^{20}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & \\\\\n & 0 & \\\\\n & & \n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\na_{0,0}^{01} & 0 & 0 \\\\\n0 & a_{1,0}^{11} & 0 \\\\\n0 & 0 & a_{2,0}^{21}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,1}^{01} & a_{1,1}^{01} & 0 \\\\\na_{0,1}^{11} & a_{1,1}^{11} & a_{2,1}^{11} \\\\\n0            & a_{1,1}^{21} & a_{2,1}^{21}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{01} & 0 & 0 \\\\\n0 & a_{1,2}^{11} & 0 \\\\\n0 & 0 & a_{2,2}^{21}\n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\n & & \\\\\n & 0 & \\\\\n & & \n\\end{pmatrix} &\n\\begin{pmatrix}\na_{0,1}^{02} & 0 & 0 \\\\\n0 & a_{1,1}^{12} & 0 \\\\\n0 & 0 & a_{2,1}^{22}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{02} & a_{1,2}^{02} & 0 \\\\\na_{0,2}^{12} & a_{1,2}^{12} & a_{2,2}^{12} \\\\\n0            & a_{1,2}^{22} & a_{2,2}^{22}\n\\end{pmatrix} \\\\\n\\end{pmatrix}}_{\\ve{A}}\n%--------------------\n%\n\\underbrace{\\begin{pmatrix} \\phi_{0,0} \\\\ \\phi_{1,0} \\\\ \\phi_{2,0} \\\\ \\\\ \\phi_{0,1} \\\\ \\phi_{1,1} \\\\ \\phi_{2,1} \\\\ \\\\ \\phi_{0,2}\\\\ \\phi_{1,2} \\\\  \\phi_{2,2} \\end{pmatrix}}_{\\vec{\\phi}} =\n%\n\\underbrace{\\begin{pmatrix} S_{00} \\\\ S_{10} \\\\ S_{20} \\\\ \\\\ S_{01} \\\\ S_{11} \\\\ S_{21} \\\\ \\\\ S_{02} \\\\ S_{12} \\\\  S_{22} \\end{pmatrix}}_{\\vec{S}} \\nonumber\n\\end{equation}\n\n%\n%\nAnother way to think of $\\ve{A}$ is\n\\begin{equation}\n\\begin{pmatrix}\n\\begin{pmatrix}\na_{C}^{00} & a_{R}^{00} & 0 \\\\\na_{L}^{10} & a_{C}^{10} & a_{R}^{10} \\\\\n0            & a_{L}^{20} & a_{C}^{20}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{T}^{00} & 0 & 0 \\\\\n0 & a_{T}^{10} & 0 \\\\\n0 & 0 & a_{T}^{20}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & \\\\\n & 0 & \\\\\n & & \n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\na_{B}^{01} & 0 & 0 \\\\\n0 & a_{B}^{11} & 0 \\\\\n0 & 0 & a_{B}^{21}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{C}^{01} & a_{R}^{01} & 0 \\\\\na_{L}^{11} & a_{C}^{11} & a_{R}^{11} \\\\\n0            & a_{L}^{21} & a_{C}^{21}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{T}^{01} & 0 & 0 \\\\\n0 & a_{T}^{11} & 0 \\\\\n0 & 0 & a_{T}^{21}\n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\n & & \\\\\n & 0 & \\\\\n & & \n\\end{pmatrix} &\n\\begin{pmatrix}\na_{B}^{02} & 0 & 0 \\\\\n0 & a_{B}^{12} & 0 \\\\\n0 & 0 & a_{B}^{22}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{C}^{02} & a_{R}^{02} & 0 \\\\\na_{L}^{12} & a_{C}^{12} & a_{R}^{12} \\\\\n0            & a_{L}^{22} & a_{C}^{22}\n\\end{pmatrix} \\\\\n\\end{pmatrix} \\nonumber\n\\end{equation}\n\nThis gives us a 5-banded matrix, which is not so difficult to represent with built in functions in Python or MATLAB. We could still solve this directly with Gaussian elimination or LU decomposition, but the size of the system increases pretty rapidly with mesh size.\n\nTherefore using an iterative method like Jacobi, GS, or SOR is probably a better plan. \n\n\n%-------------------------------------------------------\n\\subsection*{Boundary Conditions}\n\nThis all works fine for central points, but what about the boundaries? When we're at the edges, we get four entries rather than five because the edge values are known. For corners we have only three entries. \n\nLet's see how this impacts our equations. Recall:\n%\n\\[\\phi(-a,y) = \\Phi_L\\:, \\quad \\phi(a,y) = \\Phi_R\\:, \\quad \\phi(x,-b) = \\Phi_B\\:, \\quad \\phi(x,b) = \\Phi_T\\:.\\]\n%\nLet's choose what to do at the corners, and then define the rest of the boundaries:\n%\n\\ifprintanswers\n\\begin{align}\n\\phi_{0,0} = \\Phi_B\\:, \\quad \\phi_{n,0} &= \\Phi_R\\:, \\quad \\phi_{0,m} = \\Phi_L\\:, \\quad \\phi_{n,m} = \\Phi_T\\:. \\nonumber \\\\\n\\phi_{0,j} &= \\Phi_L \\qquad j=1,\\dots,m-1 \\:, \\nonumber \\\\\n\\phi_{n,j} &= \\Phi_R \\qquad j=1,\\dots,m-1 \\:, \\nonumber \\\\\n\\phi_{i,0} &= \\Phi_B \\qquad i=1,\\dots,n-1 \\:, \\nonumber \\\\\n\\phi_{i,m} &= \\Phi_T \\qquad i=1,\\dots,n-1 \\:. \\nonumber \n\\end{align}\n\\else\n\\\\ \\vspace*{8em}\n\\fi\n\nLet's look at how this would impact the left ($i=0$) boundary. The $i=0$ equations are simply the boundary condition:\n\\begin{itemize}\n\\item Change the $a_{C}^{0,j}$ entries to $1$s, \n\\item the $a_{x}^{0,j}$, where $x$ is $R, T$, and $B$ to $0$, and \n\\item the $S_{0,j}$ entries to $\\Phi_L$.\n\\end{itemize} \n\nFor the $i=1$ equations:\n\\[\\underbrace{a_{2,j}^{1j}}_{R}\\phi_{2,j} + \\underbrace{a_{1,j-1}^{1j}}_{B}\\phi_{1,j-1} + \\underbrace{a_{1,j+1}^{1j}}_{T}\\phi_{1,j+1} + \\underbrace{a_{1,j}^{1j}}_{C}\\phi_{1,j} = S_{1j} - \\underbrace{a_{0,j}^{1j}}_{L}\\phi_L \\]\n\nAnd analogously for the rest of the edges.\n\n\n\n\\subsection*{Larger Matrix}\nWhat about a bigger matrix?\n\n\\begin{minipage}{0.5\\textwidth}\n%-------------- indices ------------------\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (6,6);\n\\foreach \\y in {1, 2, 3}\n    \\foreach \\x in  {0, 1, 2, 3}\n        \\node[below left] at (2*\\x cm,2*\\y cm) {$(\\x,\\y)$};\n\\node[below] at (0,-.25) {$(0,0)$};\n\\node[below] at (2,-.25) {$(1,0)$};\n\\node[below] at (4,-.25) {$(2,0)$};\n\\node[below] at (6,-.25) {$(3,0)$};\n\\end{tikzpicture}\n\\end{minipage} \\hfill\n%-------------- numbered nodes ------------------\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (6,6);\n\\node[below] at (0,-.25) {$0$};\n\\node[below] at (2,-.25) {$1$};\n\\node[below] at (4,-.25) {$2$};\n\\node[below] at (6,-.25) {$3$};\n\\node[below left] at (-.25,2) {$4$};\n\\node[below left] at (2,2) {$5$};\n\\node[below left] at (4,2) {$6$};\n\\node[below left] at (6,2) {$7$};\n\\node[below left] at (-.25,4) {$8$};\n\\node[below left] at (2,4) {$9$};\n\\node[below left] at (4,4) {$10$};\n\\node[below left] at (6,4) {$11$};\n\\node[below left] at (-.25,6) {$12$};\n\\node[below left] at (2,6) {$13$};\n\\node[below left] at (4,6) {$14$};\n\\node[below left] at (6,6) {$15$};\n\\end{tikzpicture}\n\\end{minipage}\n\nOur solution vector length in this example is 16 (4 $\\times$ 4). Our matrix size is therefore going to be 16 $\\times$ 16. We can think of this as a 4 $\\times$ 4 matrix of 4 $\\times$ 4 matrices:\n\\begin{equation}\n\\underbrace{\\begin{pmatrix}\n\\begin{pmatrix}\na_{0,0}^{00} & a_{1,0}^{00} & 0            & 0\\\\\na_{0,0}^{10} & a_{1,0}^{10} & a_{2,0}^{10} & 0 \\\\\n0            & a_{1,0}^{20} & a_{2,0}^{20} & a_{3,0}^{20} \\\\\n0            & 0            & a_{2,0}^{30} & a_{3,0}^{30}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,1}^{00} & 0 & 0 & 0 \\\\\n0 & a_{1,1}^{10} & 0 & 0 \\\\\n0 & 0 & a_{2,1}^{20} & 0 \\\\\n0 & 0 & 0 & a_{3,1}^{30}  \\\\\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix} \n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\\\\\n%--------------------\n\\begin{pmatrix}\na_{0,0}^{01} & 0 & 0 & 0\\\\\n0 & a_{1,0}^{11} & 0 & 0\\\\\n0 & 0 & a_{2,0}^{21} & 0\\\\\n0 & 0 & 0 & a_{3,0}^{31} \n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,1}^{01} & a_{1,1}^{01} & 0            & 0\\\\\na_{0,1}^{11} & a_{1,1}^{11} & a_{2,1}^{11} & 0\\\\\n0            & a_{1,1}^{21} & a_{2,1}^{21} & a_{3,1}^{21} \\\\\n0            & )            & a_{2,1}^{31} & a_{3,1}^{31}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{01} & 0 & 0 & 0\\\\\n0 & a_{1,2}^{11} & 0 & 0\\\\\n0 & 0 & a_{2,2}^{21} & 0\\\\\n0 & 0  & 0 & a_{3,2}^{31}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\\\\\n%--------------------\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,1}^{02} & 0 & 0 & 0\\\\\n0 & a_{1,1}^{12} & 0 & 0\\\\\n0 & 0 & a_{2,1}^{22} & 0\\\\\n0 & 0  & 0 & a_{3,1}^{32}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{02} & a_{1,2}^{02} & 0            & 0\\\\\na_{0,2}^{12} & a_{1,2}^{12} & a_{2,2}^{12} & 0\\\\\n0            & a_{1,2}^{22} & a_{2,2}^{22} & a_{3,2}^{22}\\\\\n0            & 0            & a_{2,2}^{32} & a_{3,2}^{32}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,3}^{02} & 0 & 0 & 0\\\\\n0 & a_{1,3}^{12} & 0 & 0\\\\\n0 & 0 & a_{2,3}^{22} & 0\\\\\n0 & 0  & 0 & a_{3,3}^{32}\n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{03} & 0 & 0 & 0\\\\\n0 & a_{1,2}^{13} & 0 & 0\\\\\n0 & 0 & a_{2,2}^{23} & 0\\\\\n0 & 0  & 0 & a_{3,2}^{33}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,3}^{03} & a_{1,3}^{03} & 0            & 0\\\\\na_{0,3}^{13} & a_{1,3}^{13} & a_{2,3}^{13} & 0\\\\\n0            & a_{1,3}^{23} & a_{2,3}^{23} & a_{3,3}^{23}\\\\\n0            & 0            & a_{2,3}^{33} & a_{3,3}^{33}\n\\end{pmatrix} \n\\end{pmatrix}}_{\\ve{A}} \\nonumber\n\\end{equation}\n%--------------------\n%\n\\begin{equation}\n\\underbrace{\\begin{pmatrix} \n\\phi_{0,0} \\\\ \\phi_{1,0} \\\\ \\phi_{2,0} \\\\ \\phi_{3,0} \\\\ \\\\ \n\\phi_{0,1} \\\\ \\phi_{1,1} \\\\ \\phi_{2,1} \\\\ \\phi_{3,1} \\\\ \\\\ \n\\phi_{0,2} \\\\ \\phi_{1,2} \\\\ \\phi_{2,2} \\\\ \\phi_{3,2} \\\\ \\\\\n\\phi_{0,3} \\\\ \\phi_{1,3} \\\\ \\phi_{2,3} \\\\ \\phi_{3,3} \\end{pmatrix}}_{\\vec{\\phi}} =\n%\n\\underbrace{\\begin{pmatrix} \nS_{00} \\\\ S_{10} \\\\ S_{20} \\\\ S_{30} \\\\ \\\\ \nS_{01} \\\\ S_{11} \\\\ S_{21} \\\\ S_{31} \\\\ \\\\ \nS_{02} \\\\ S_{12} \\\\ S_{22} \\\\ S_{32} \\\\ \\\\ \nS_{03} \\\\ S_{13} \\\\ S_{23} \\\\ S_{33}\n\\end{pmatrix}}_{\\vec{S}} \\nonumber\n\\end{equation}\n\n\n\\begin{minipage}{0.5\\textwidth}\n%-------------- indices ------------------\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (6,6);\n\\foreach \\y in {1}\n    \\foreach \\x in  {0, 1}\n        \\node[below left] at (2*\\x cm,2*\\y cm) {$(\\x,\\y)$};        \n\\node[below] at (0,-.25) {$(0,0)$};\n\\node[below] at (2,-.25) {$(1,0)$};\n\\node[below] at (4,-.25) {$...$};\n\\node[below] at (6,-.25) {$(n,0)$};\n\\node[below left] at (0,4) {$\\vdots$};\n\\node[below left] at (0,6) {$(0,m)$};\n\\node[below left] at (2,6) {$(1,m)$};\n\\node[below left] at (4,6) {$(n-1,m)$};\n\\node[below left] at (6,6) {$(n,m)$};\n\\node[below left] at (6,2) {$(n,1)$};\n\\node[below left] at (6,4) {$(n,m-1)$};\n\\node[below left] at (6,6) {$(n,m)$};\n\\end{tikzpicture}\n\\end{minipage} \\hfill\n%-------------- numbered nodes ------------------\n\\begin{minipage}{0.5\\textwidth}\n\\begin{tikzpicture}\n\\draw[step=2cm] (0,0) grid (6,6);\n\\node[below] at (0,-.25) {$0$};\n\\node[below] at (2,-.25) {$1$};\n\\node[below] at (4,-.25) {$2$};\n\\node[below] at (6,-.25) {$3$};\n\\node[below left] at (-.25,2) {$4$};\n\\node[below left] at (2,2) {$5$};\n\\node[below left] at (4,2) {$6$};\n\\node[below left] at (6,2) {$7$};\n\\node[below left] at (-.25,4) {$8$};\n\\node[below left] at (2,4) {$9$};\n\\node[below left] at (4,4) {$10$};\n\\node[below left] at (6,4) {$11$};\n\\node[below left] at (-.25,6) {$12$};\n\\node[below left] at (2,6) {$13$};\n\\node[below left] at (4,6) {$14$};\n\\node[below left] at (6,6) {$15$};\n\\end{tikzpicture}\n\\end{minipage}\n\nOur solution vector length in this example is $1 \\times nm$. Our matrix size is therefore going to be $n m \\times n m$. We can think of this as a $n \\times m$ matrix of $n \\times m$ matrices: ($n$ rows; $m$ columns)\n\n\\begin{landscape}\n\\begin{equation}\n\\underbrace{\\begin{pmatrix}\n\\begin{pmatrix}\na_{0,0}^{00} & a_{1,0}^{00} & 0            & 0\\\\\na_{0,0}^{10} & a_{1,0}^{10} & a_{2,0}^{10} & 0 \\\\\n0            & a_{1,0}^{20} & a_{2,0}^{20} & a_{n,0}^{20} \\\\\n0            & 0            & a_{2,0}^{n0} & a_{n,0}^{n0}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,1}^{00} & 0 & 0 & 0 \\\\\n0 & a_{1,1}^{10} & 0 & 0 \\\\\n0 & 0 & a_{2,1}^{20} & 0 \\\\\n0 & 0 & 0 & a_{n,1}^{n0}  \\\\\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix} \n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\\\\\n%--------------------\n\\begin{pmatrix}\na_{0,0}^{01} & 0 & 0 & 0\\\\\n0 & a_{1,0}^{11} & 0 & 0\\\\\n0 & 0 & a_{2,0}^{21} & 0\\\\\n0 & 0 & 0 & a_{n,0}^{n1} \n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,1}^{01} & a_{1,1}^{01} & 0            & 0\\\\\na_{0,1}^{11} & a_{1,1}^{11} & a_{2,1}^{11} & 0\\\\\n0            & a_{1,1}^{21} & a_{2,1}^{21} & a_{n,1}^{21} \\\\\n0            & 0            & a_{2,1}^{n1} & a_{n,1}^{n1}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{01} & 0 & 0 & 0\\\\\n0 & a_{1,2}^{11} & 0 & 0\\\\\n0 & 0 & a_{2,2}^{21} & 0\\\\\n0 & 0 & 0 & a_{n,2}^{n1}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\\\\\n%--------------------\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,1}^{02} & 0 & 0 & 0\\\\\n0 & a_{1,1}^{12} & 0 & 0\\\\\n0 & 0 & a_{2,1}^{22} & 0\\\\\n0 & 0 & 0 & a_{n,1}^{n2}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{02} & a_{1,2}^{02} & 0            & 0\\\\\na_{0,2}^{12} & a_{1,2}^{12} & a_{2,2}^{12} & 0\\\\\n0            & a_{1,2}^{22} & a_{2,2}^{22} & a_{n,2}^{22}\\\\\n0            & 0            & a_{2,2}^{n2} & a_{n,2}^{n2}\n\\end{pmatrix} \n&\n\\begin{pmatrix}\na_{0,m}^{02} & 0 & 0 & 0\\\\\n0 & a_{1,m}^{12} & 0 & 0\\\\\n0 & 0 & a_{2,m}^{22} & 0\\\\\n0 & 0 & 0 & a_{n,m}^{n2}\n\\end{pmatrix} \\\\\n%--------------------\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\n&\n\\begin{pmatrix}\n & & & \\\\\n & 0 & &\\\\\n & & & \\\\\n & & &\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,2}^{0m} & 0 & 0 & 0\\\\\n0 & a_{1,2}^{1m} & 0 & 0\\\\\n0 & 0 & a_{2,2}^{2m} & 0\\\\\n0 & 0 & 0 & a_{n,2}^{nm}\n\\end{pmatrix}\n&\n\\begin{pmatrix}\na_{0,m}^{0m} & a_{1,m}^{0m} & 0            & 0\\\\\na_{0,m}^{1m} & a_{1,m}^{1m} & a_{2,m}^{1m} & 0\\\\\n0            & a_{1,m}^{2m} & a_{2,m}^{2m} & a_{n,m}^{2m}\\\\\n0            & 0            & a_{2,m}^{nm} & a_{n,m}^{nm}\n\\end{pmatrix} \n\\end{pmatrix}}_{\\ve{A}} \\nonumber\n\\end{equation}\n\\end{landscape}\n%--------------------\n%\n\\begin{equation}\n\\underbrace{\\begin{pmatrix} \n\\phi_{0,0} \\\\ \\phi_{1,0} \\\\ \\phi_{n-1,0} \\\\ \\phi_{n,0} \\\\ \\\\ \n\\phi_{0,1} \\\\ \\phi_{1,1} \\\\ \\phi_{n-1,1} \\\\ \\phi_{n,1} \\\\ \\\\ \n\\phi_{0,m-1} \\\\ \\phi_{1,m-1} \\\\ \\phi_{n-1,m-1} \\\\ \\phi_{n,m-1} \\\\ \\\\\n\\phi_{0,m} \\\\ \\phi_{1,m} \\\\ \\phi_{n-1,m} \\\\ \\phi_{n,m} \\end{pmatrix}}_{\\vec{\\phi}} =\n%\n\\underbrace{\\begin{pmatrix} \nS_{00} \\\\ S_{10} \\\\ S_{(n-1)0} \\\\ S_{n0} \\\\ \\\\ \nS_{01} \\\\ S_{11} \\\\ S_{(n-1)1} \\\\ S_{n1} \\\\ \\\\ \nS_{0(m-1)} \\\\ S_{1(m-1)} \\\\ S_{(n-1)(m-1)} \\\\ S_{n(m-1)} \\\\ \\\\ \nS_{0m} \\\\ S_{13} \\\\ S_{(n-1)m} \\\\ S_{nm}\n\\end{pmatrix}}_{\\vec{S}} \\nonumber\n\\end{equation}\n\n%--------------------------------------------------------------------\n%--------------------------------------------------------------------\n%\\bibliographystyle{plain}\n%\\bibliography{LinearSolns} \n\n\\end{document}\n", "meta": {"hexsha": "df4a4bbca81919f0fa0836e27c59f7f1c2c5f979", "size": 32558, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "15-2d-fd-fvm/15-2d-fd-fvm.tex", "max_stars_repo_name": "rachelslaybaugh/NE155", "max_stars_repo_head_hexsha": "5a08229eb11eebdd60e5ec1b4c0d41a541e7d82f", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-08-22T05:28:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-15T02:00:39.000Z", "max_issues_repo_path": "15-2d-fd-fvm/15-2d-fd-fvm.tex", "max_issues_repo_name": "rachelslaybaugh/NE155", "max_issues_repo_head_hexsha": "5a08229eb11eebdd60e5ec1b4c0d41a541e7d82f", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2015-04-01T00:18:04.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-31T20:14:58.000Z", "max_forks_repo_path": "15-2d-fd-fvm/15-2d-fd-fvm.tex", "max_forks_repo_name": "rachelslaybaugh/NE155", "max_forks_repo_head_hexsha": "5a08229eb11eebdd60e5ec1b4c0d41a541e7d82f", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2015-01-21T20:12:08.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-20T08:01:10.000Z", "avg_line_length": 32.3960199005, "max_line_length": 266, "alphanum_fraction": 0.5369187297, "num_tokens": 13956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4001852944964747}}
{"text": "\\section*{Conclusion}\n\nIn this work we described three approaches to parallelize the FW algorithm with three different architectures:\ndistributed with MPI, shared-memory multiprocessing with OpenMP and GPGPU with CUDA.\n\nThe fastest \"pure\" implementation is \\emph{CUDA FW} thanks to the high computation capability and high memory bandwidth, \nbut it requires more expensive hardware. \n\n\\emph{MPI FW} (with one thread per node)  is still faster than the \\emph{serial}, but the implementation\nis more complex, the cost of the cluster (hosting and maintenance) makes the solution non convenient,\nthe efficiency depends on the network bandwidth and the speedup is not that high.\n\n\\emph{OpenMP FW} is almost 95 times faster than \\emph{serial FW} but 13 times slower than \\emph{CUDA FW}. The absence of\noverhead due to communication, fast memory access, easy development process and relatively low costs make this solution the\nmost affordable, maintenable and cost-efficient one.\n\nTalking about hybrid solutions, \\emph{MPI + CUDA} is obviously faster than \\emph{MPI + OpenMP} as long as the matrix is not small, \nbut the benefits may not justify the total cost of the infrastructure: the monthly cost for hosting a server with a GPU is at least\nfour times the cost of one without a GPU. This solution is suggested to those systems that really need the lowest response time possible\n(\\emph{e.g.} real-time systems or systems that cannot rely on a caching mechanism in front of them).", "meta": {"hexsha": "77f0a4fa44e92b24d302cf12fe2be67e1cdeea14", "size": 1475, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/conclusion.tex", "max_stars_repo_name": "firaja/Parallel-FloydWarshall", "max_stars_repo_head_hexsha": "97b99291cf2eb8bf12b1775358f6c5179f5a03b8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-06-19T21:42:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-12T11:25:06.000Z", "max_issues_repo_path": "report/conclusion.tex", "max_issues_repo_name": "firaja/Parallel-FloydWarshall", "max_issues_repo_head_hexsha": "97b99291cf2eb8bf12b1775358f6c5179f5a03b8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/conclusion.tex", "max_forks_repo_name": "firaja/Parallel-FloydWarshall", "max_forks_repo_head_hexsha": "97b99291cf2eb8bf12b1775358f6c5179f5a03b8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 73.75, "max_line_length": 136, "alphanum_fraction": 0.7959322034, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4001852911778587}}
{"text": "\\documentclass[11pt]{article}\n\\usepackage{geometry}\n\\geometry{a4paper,top=2cm,bottom=2cm,left=2cm,right=2cm}\n\\usepackage[english]{babel}\n\\usepackage{graphicx}\n\\usepackage{fancyhdr}\n\\usepackage{lineno}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{algorithm}\n\\usepackage[noend]{algpseudocode}\n\\usepackage {tikz}\n\\usetikzlibrary {positioning}\n\\usepackage {xcolor}\n\\usepackage{titlesec}\n\\usepackage{varwidth}\n\n\\makeatletter\n\\def\\BState{\\State\\hskip-\\ALG@thistlm}\n\\makeatother\n\n\\title{\\textbf{Algorithm Design - Homework 1} \\\\ \\bigskip \\large \\textbf{Sapienza University of Rome}}\n\\date{\\textbf{\\today}}\n\\author{\\textbf{Marco Costa, 1691388}}\n\\pagestyle{fancy}\n\\fancyhead[L]{Marco Costa, 1691388}\n\\fancyhead[R]{Algorithm Design - Homework 1}\n\n%section, subsection: space - left, before, after\n\\titlespacing{\\section}{0em}{0em}{0em}\n\\titlespacing{\\subsection}{0em}{0.5em}{0em}\n\\titlespacing{\\subsubsection}{0em}{0.5em}{0em}\n\\setlength\\parindent{0pt}\n\n\\begin{document}\n\\maketitle\n\\newpage\n\n\\section*{Exercise 1}\n\\subsection*{Problem}\nThe problem consists in finding the expected optimal reward playing the game ``\\textit{Open the Boxes and keep the Best!}''. The input is composed by the number of boxes $k$, the number of different rewards $n$ an\nthe cost $c_i$ of every box. Two algorithms are required. The first one's complexity must be \\textbf{\\textit{O}}($n^2 \\cdot k$), while the second one's complexity must be \\textbf{\\textit{O}}($n \\cdot k$)\n\\subsubsection*{Solution}\nIn order to solve the problem, we can define a matrix \\textit{M} composed of $k$ rows and $n$ columns, where the element $M[i, j]$ represents the expected value by opening the box i and having as current maximum reward j. \\\\\nTo populate the matrix we can use \\textbf{backward induction}, proceeding first considering the last box and choosing what to do for all the possible rewards. Using this information, we can then determine what to do at the penultimate box. This process continues backwards until we have determined the best action for every possible reward for each box. So the element $\\mathbf{M[0, 0]}$ is the expected optimal reward.\\\\\nLet's explain the mathematical formula: \\\\\n- $j \\cdot \\frac{j+1}{n+1}$ (or $M[i+1, j] \\cdot \\frac{j+1}{n+1}$) is the probability of obtaining a reward $r \\le j$; \\\\\n- $\\frac{1}{n+1}\\sum\\limits_{h = j + 1}^n{h}$ (or $\\frac{1}{n+1}\\sum\\limits_{h = j + 1}^n{M[i+1, j]}$) is the probability of obtaining a reward $r > j$; \\\\\n- $c[i]$ is the cost to pay opening the $i^{th}$ box. \\\\\n- the sum of the previous values is the expected value opening the box $i$ having as current maximum reward $j$ \\\\\nTo improve the complexity to \\textbf{\\textit{O}}($n \\cdot k$) we can eliminate the summations, since in the worst case we have a sum over $n$ (\\textbf{\\textit{O}}($n$)) in nested cycles (\\textbf{\\textit{O}}($n \\cdot k$)) having a total cost of\\textbf{\\textit{O}}($n^2 \\cdot k$). To do this we must distinguish the two cases:\n\\begin{itemize}\n\t\\item \\textbf{\\textit{Last box}}: we can remove this summation using a mathematical trick: \\\\\n\t$\\sum\\limits_{i = j + 1}^n{i} = \\sum\\limits_{i = 0}^n{i} - \\sum\\limits_{i = 0}^j{i} = \\frac{n \\cdot (n+1)}{2} - \\frac{j \\cdot (j+1)}{2} = \\frac{n \\cdot (n+1) - j \\cdot (j+1)}{2}$;\n\t\\item \\textbf{\\textit{Other boxes}}: we can use an auxiliary vector in which we keep track of the sum of the elements of the matrix related to the box next to the current one.\n\\end{itemize}\n\nHere there are the two \\textbf{\\textit{Algorithms}}:\n\n\\begin{minipage}[t]{0.49\\textwidth}\n\\begin{algorithm}[H]\n\t\\caption{Get optimal expected value (\\textbf{\\textit{O}}($n^2 \\cdot k$))}\\label{euclid}\n\t\\begin{algorithmic}[1]\n\t\t\\State $M[k, n+1] \\gets 0$\n\t\t\\For{$i$ in $(k-1, ..., 0)$}\n\t\t\\For{$j$ in $(n, ..., 0)$}\n\t\t\\State $r \\gets 0$\n\t\t\\If{$i = k-1$}\n\t\t\\State $r \\gets j \\cdot \\frac{j+1}{n+1} + \\frac{1}{n+1}\\sum\\limits_{h = j + 1}^n{h} - c[i]$\n\t\t\\Else\n\t\t\\State \\begin{varwidth}[t]{\\linewidth} $r \\gets M[i+1, j] \\cdot \\frac{j+1}{n+1} + \\frac{1}{n+1} \\cdot$ \\par\n\t\t\t\\hskip\\algorithmicindent $\\sum\\limits_{h = j + 1}^n{M[i+1, h]} - c[i]$\n\t\t\\end{varwidth}\n\t\t\\EndIf\n\t\t\\State $M[i, j] \\gets \\max(j, r)$\n\t\t\\EndFor\t\t\n\t\t\\EndFor\n\t\t\\State \\Return $M[0, 0]$\n\t\\end{algorithmic}\n\\end{algorithm}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[t]{0.49\\textwidth}\n\\begin{algorithm}[H]\n\t\\caption{Get optimal expected value (\\textbf{\\textit{O}}($n \\cdot k$))}\\label{euclid}\n\t\\begin{algorithmic}[1]\n\t\t\\State $M[k, n+1] \\gets 0$\n\t\t\\State $sums[n+1] \\gets 0$\n\t\t\\For{$i$ in $(k-1, ..., 0)$}\n\t\t\\For{$j$ in $(n, ..., 0)$}\n\t\t\\State $r \\gets 0$\n\t\t\\If{$i = k-1$}\n\t\t\t\\State $r \\gets j \\cdot \\frac{j+1}{n+1} + \\frac{1}{n+1} \\cdot \\frac{n \\cdot (n+1)-j \\cdot (j+1)}{2} - c[i]$\n\t\t\\Else\n\t\t\t\\State $r \\gets M[i+1, j] \\cdot \\frac{j+1}{n+1} + \\frac{sums[j]}{n+1} - c[i]$\n\t\t\\EndIf\n\t\t\\State $M[i, j] \\gets \\max(j, r)$\n\t\t\\If{$j = n$}\n\t\t\t\\State $sums[j] \\gets 0$\n\t\t\\Else\n\t\t\t\\State $sums[j] \\gets sums[j+1] + M[i, j+1]$\n\t\t\\EndIf\n\t\t\\EndFor\t\t\n\t\t\\EndFor\n\t\t\\State \\Return $M[0, 0]$\n\t\\end{algorithmic}\n\\end{algorithm}\n\\end{minipage}\n\\newpage\n\n\\section*{Exercise 2}\n\\subsection*{First problem}\nThe problem is to find the complete graph \\textbf{\\textit{G}} of minimum weight given a weighted tree \\textbf{\\textit{T}}, such that  \\textbf{\\textit{T}} is the unique minimum spanning tree of \\textbf{\\textit{G}}. Algorithm's run time must be polynomial in $n$.\n\\subsubsection*{Solution}\nInsert edges that are not in the tree so as to obtain the complete graph. These edges must have a greater weight than those of the tree, so that \\textbf{\\textit{T}} is the only \\textbf{\\textit{MST}} of \\textbf{\\textit{G}}. Since \\textit{Kruskal}'s algorithm uses the \\textit{Union-Find} structures for representing the cuts, we use this structures to solve the problem. \\\\\nLet's define with \\textbf{\\textit{V}} the set of nodes of \\textbf{\\textit{T}} and with \\textbf{\\textit{E}} the set of edges of \\textbf{\\textit{T}}.\n\\begin{algorithm}\n\t\\caption{Find complete graph}\\label{euclid}\n\t\\begin{algorithmic}[1]\n\t\t\\For{$v \\in V$} \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n$))\n\t\t\t\\State $v.initializeUnionFindSingleton()$\n\t\t\\EndFor\n\t\t\\State $T.sortEdgesByAscendingWeights()$ \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n\\log{n}$))\n\t\t\\State $G \\gets \\emptyset$\n\t\t\\For {$e \\gets (u, v) \\in E$} \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n^3$))\n\t\t\t\\State  $G.addEdge(e)$\n\t\t\t\\State  $set_1 \\gets u.findComponents()$\n\t\t\t\\State  $set_2 \\gets v.findComponents()$\n\t\t\t\\For {$u \\in set_1$}\n\t\t\t\t\\For {$v \\in set_2$}\n\t\t\t\t\t\\State $\\hat{e} \\gets (u, v)$\n\t\t\t\t\t\\If {$\\hat{e} \\notin G$}\n\t\t\t\t\t\t\\State $\\hat{e}.setWeight(e.getWeight() + 1)$\n\t\t\t\t\t\t\\State $G.addEdge(\\hat{e})$\n\t\t\t\t\t\\EndIf\n\t\t\t\t\\EndFor\n\t\t\t\\EndFor\n\t\t\t\\State $union(set_1, set_2)$\n\t\t\\EndFor\n\t\t\\State \\Return $G$\n\t\\end{algorithmic}\n\\end{algorithm} \\\\\n\\textbf{Cost}: \\textbf{\\textit{O}}($|V|\\log{|V|} + |E| \\cdot |V|^2$) = \\textbf{\\textit{O}}($n\\log{n} + (n-1) \\cdot n^2$) = \\textbf{\\textit{O}}($n\\log{n} + n^3 - n^2$) = \\textbf{\\textit{O}}($n^3$), given by the three nested cycles over $n$.\n\\subsection*{Second problem}\nFind the total weight of the complete graph \\textbf{\\textit{G}} of minimum weight given a weighted tree \\textbf{\\textit{T}}, such that  \\textbf{\\textit{T}} is the unique minimum spanning tree of \\textbf{\\textit{G}}. Algorithm's complexity must be \\textbf{\\textit{O}}($n \\log{n}$).\n\\subsubsection*{Solution}\nThis problem is quite similar to the previous one, but in this case there is no need to create all the edges of the graph.\n\\begin{algorithm}\n\t\\caption{Find weight of the complete graph}\\label{euclid}\n\t\\begin{algorithmic}[1]\n\t\t\\For{$v \\in V$} \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n$))\n\t\t\t\\State $v.initializeUnionFindSingleton()$\n\t\t\\EndFor\n\t\t\\State $T.sortEdgesByAscendingWeights()$ \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n\\log{n}$))\n\t\t\\State $w_{total} \\gets 0$\n\t\t\\For {$e \\gets (u, v) \\in E$} \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad (\\textbf{\\textit{O}}($n \\log{n}$))\n\t\t\t\\State $w_{total}$ \\textit{+=} $e.getWeight()$\n\t\t\t\\State  $set_1 \\gets u.findComponents()$\n\t\t\t\\State  $set_2 \\gets v.findComponents()$\n\t\t\t\\State $w_{total}$ \\textit{+=} $(set_1.size() \\times set_2.size() - 1) \\times (e.getWeight() + 1)$\n\t\t\t\\State $union(set_1, set_2)$\n\t\t\\EndFor\n\t\t\\State \\Return $w_{total}$\n\t\\end{algorithmic}\n\\end{algorithm} \\\\\n\\textbf{Cost}: \\textbf{\\textit{O}}($|V|\\log{|V|} + |E| \\log{|V|}$) = \\textbf{\\textit{O}}($n\\log{n} + n\\log{n}$) = \\textbf{\\textit{O}}($n\\log{n}$) (\\textit{union} costs \\textbf{\\textit{O}}($\\log{n}$)).\n\\newpage\n\n\\section*{Exercise 3}\n\\subsection*{First Problem}\nThe problem consists in modeling Federico's business as a flow problem in a graph \\textbf{\\textit{G}}, only consisting of regular vertices, one source, one sink, and capacitated edges to find out how many chocolates he should make every week. An example with $|F| = 4$ is required.\n\\subsubsection*{Solution}\nThe model consists in a source node \\textit{F} that represents Federico, a sink node \\textit{S} that represents the costumers and different nodes $f_i$ representing Federico's friends. Moreover, for each friend there is a node $w_i$ that represents the friend's ``warehouse''. These nodes help us better understand that the amount of total chocolates received by a friend is exactly $n_i$. Each friend can receive the chocolate from Federico (represented with an edge of path from Federico to the friend and capacity $n_i$) or from another friend (represented with an edge of path from the new friend to the first one and capacity $n_i - s_i$). Notice that when a friend meets another, they can exchange chocolates for each other (represented with two edges: the first one has the path from the first friend to the warehouse of the second one and capacity $n_{i1} - s_{i1}$, while the second one has the path from the second friend to the first one and capacity $n_{i2} - s_{i2}$). The chocolates sold by each friend is represented with an edge having the path from the friend to the costumers and capacity $s_i$. Notice that for each friend $s_i \\le n_i$ and the total amount of chocolates sold is $\\sum\\limits_{i \\in |F|}s_i$. It's possible to find the \\textit{Maximum Flow} in order to find out how many chocolates Federico should\nactually make every week. Let's show the example with $|F| = 4$:\n\n\\begin {tikzpicture}\n\\begin{scope}[auto=left,every node/.style={circle,draw, minimum width = 1 cm}]\n\\node(f) at (0,0) {F};\n\\node(wa) at (3,1) {w$_a$};\n\\node(a) at (6.5,1) {f$_a$};\n\\node(wb) at (3,-1) {w$_b$};\n\\node(b) at (6.5,-1) {f$_b$};\n\\node(wc) at (9.5,1) {w$_c$};\n\\node(c) at (13,1) {f$_c$};\n\\node(wd) at (9.5,-1) {w$_d$};\n\\node(d) at (13,-1) {f$_d$};\n\\node(s) at (16,0) {s};\n\\end{scope}\n\\begin{scope}[every edge/.style={draw=black,very thick}, every node/.style={scale=0.8}]\n\\path [->] (f) edge node[sloped,above]{$n_1$} (wa);\n\\path [->] (f) edge node[sloped,above]{$n_2$} (wb);\n\n\\path [->] (a) edge node[sloped,below]{$n_a - s_a$} (wc);\n\\path [->] (b) edge node[sloped,above]{$n_b - s_b$} (wd);\n\\path [->] (c) edge[bend right=20] node[sloped,above]{$n_c - s_c$} (wa);\n\\path [->] (d) edge[bend left=20] node[sloped,below]{$n_d - s_d$} (wb);\n\n\\path [->] (a) edge[sloped,above,pos=0.75] node{$n_a - s_a$} (wb);\n\\path [->] (d) edge[sloped,above,pos=0.2] node{$n_d - s_d$} (wc);\n\\path [->] (b) edge[sloped,above,pos=0.2] node{$n_b - s_b$} (wa);\n\\path [->] (c) edge[sloped,above,pos=0.75] node{$n_c - s_c$} (wd);\n\n\\path [->] (wa) edge node[sloped,above]{$n_a$}(a);\n\\path [->] (wb) edge node[sloped,above]{$n_b$}(b);\n\\path [->] (wc) edge node[sloped,above]{$n_c$}(c);\n\\path [->] (wd) edge node[sloped,above]{$n_d$}(d);\n\n\\path [->] (a) edge[bend left=30] node[sloped,above]{$s_a$} (s);\n\\path [->] (b) edge[bend right=30] node[sloped,below]{$s_b$} (s);\n\\path [->] (c) edge node[sloped,above]{$s_c$} (s);\n\\path [->] (d) edge node[sloped,above]{$s_d$} (s);\n\\end{scope}\n\\end{tikzpicture}\n\\subsection*{Second Problem}\nAdjust the network knowing that each friend will have an associated building $b_f \\in B$ and find out if and how this\nimpacts Federico’s business.\n\\subsubsection*{Solution}\nIn this case we must modify a bit the previous model adding some new nodes $b_i$ that represent the buildings. Now each friend can sell chocolates only in his associated building, so we have the edges with capacity $s_i$ with path from the friend to his associated building, and another edge with capacity $c_i$ with path from the building to the costumers. The main difference is that now the total amount of chocolate sold is $\\sum\\limits_{i \\in B}c_i$, and we have that $\\sum\\limits_{i \\in |B|}c_i \\le \\sum\\limits_{i \\in |F|}s_i$. It means that Federico could make less chocolates than before because of the possible drop of sales.\nLet's show the adjusted example:\n\n\\begin {tikzpicture}\n\\begin{scope}[auto=left,every node/.style={circle,draw, minimum width = 1 cm}]\n\t\\node(f) at (0,0) {F};\n\t\\node(ma) at (2,1) {m$_a$};\n\t\\node(a) at (5.8,1) {f$_a$};\n\t\\node(mb) at (2,-1) {m$_b$};\n\t\\node(b) at (5.8,-1) {f$_b$};\n\t\\node(mc) at (8.2,1) {m$_c$};\n\t\\node(c) at (12,1) {f$_c$};\n\t\\node(md) at (8.2,-1) {m$_d$};\n\t\\node(d) at (12,-1) {f$_d$};\n\t\\node(b1) at (14,2) {$b_1$};\n\t\\node(b2) at (14,0) {$b_2$};\n\t\\node(b3) at (14,-2) {$b_3$};\n\t\\node(s) at (16,0) {s};\n\\end{scope}\n\\begin{scope}[every edge/.style={draw=black,very thick}, every node/.style={scale=0.8}]\n\t\\path [->] (f) edge node[sloped,above]{$n_1$} (ma);\n\t\\path [->] (f) edge node[sloped,above]{$n_2$} (mb);\n\t\n\t\\path [->] (a) edge node[sloped,below]{$n_a - s_a$} (mc);\n\t\\path [->] (b) edge node[sloped,above]{$n_b - s_b$} (md);\n\t\\path [->] (c) edge[bend right=20] node[sloped,above]{$n_c - s_c$} (ma);\n\t\\path [->] (d) edge[bend left=20] node[sloped,below]{$n_d - s_d$} (mb);\n\t\n\t\\path [->] (a) edge[sloped,above,pos=0.75] node{$n_a - s_a$} (mb);\n\t\\path [->] (d) edge[sloped,above,pos=0.2] node{$n_d - s_d$} (mc);\n\t\\path [->] (b) edge[sloped,above,pos=0.2] node{$n_b - s_b$} (ma);\n\t\\path [->] (c) edge[sloped,above,pos=0.75] node{$n_c - s_c$} (md);\n\t\n\t\\path [->] (ma) edge node[sloped,above]{$n_a$}(a);\n\t\\path [->] (mb) edge node[sloped,above]{$n_b$}(b);\n\t\\path [->] (mc) edge node[sloped,above]{$n_c$}(c);\n\t\\path [->] (md) edge node[sloped,above]{$n_d$}(d);\n\t\n\t\\path [->] (a) edge[bend left=10] node[sloped,above]{$s_a$} (b1);\n\t\\path [->] (b) edge[bend right=10] node[sloped,below]{$s_b$} (b3);\n\t\\path [->] (c) edge node[sloped,above]{$s_c$} (b1);\n\t\\path [->] (d) edge node[sloped,above]{$s_d$} (b2);\n\t\n\t\\path [->] (b1) edge node[sloped,above]{$c_1$} (s);\n\t\\path [->] (b2) edge node[sloped,above]{$c_2$} (s);\n\t\\path [->] (b3) edge node[sloped,above]{$c_3$} (s);\n\\end{scope}\n\\end{tikzpicture}\n\\newpage\n\n\\section*{Exercise 4}\n\\subsection*{Problem}\nThe problem consists in showing that it is not possible to solve the problem of scheduling $n$ tasks with quick algorithm. Each job  $j$ of the $n$ jobs has an earliest time $s_j$ to start task, a deadline $d_j$ when it has to be finished, and the length $l_j \\in \\mathbb{N}$ that specifies the time needed to complete it. There is also an upper bound time $k$ and $\\sum\\limits_{j \\in J}l_j \\le k$.\n\\subsubsection*{Solution}\nIn order to prove that this problem is not solvable with quick algorithm we need to prove that it is \\textbf{\\textit{NP-Hard}}. We can do it reducing another \\textit{NP-Hard} problem to the current problem. Let's define our problem as $\\Theta$, we need to find a well known \\textit{NP-Hard} problem $\\Omega$ such that:\n\\begin{itemize}\n\t\\item $\\omega \\in \\Omega \\implies  \\theta \\in \\Theta$\n\t\\item $\\theta \\in \\Theta \\implies  \\omega \\in \\Omega$ (or equivalently $\\neg\\omega \\in \\Omega \\implies  \\neg\\theta \\in \\Theta$)\n\\end{itemize}\n\\textbf{\\underline{Observation}}: The earliest start time  $s_j$ indicate only at what time the job $j$ is available (it does not need to be done at that moment, but it does have to be done before its deadline $d_j$). \\\\ \\\\\n\\textbf{\\underline{Observation}}: Our scheduling problem is solvable if and only if each job $j$ meets its deadline $d_j$ and $\\sum\\limits_{j \\in J}l_j \\le k$ (we know that this last is satisfied). \\\\ \\\\\nWe can use \\textbf{\\textit{Subset Sum}} for our purpose ($\\Omega$ = \\textit{Subset Sum}). \\\\\n\\textbf{Subset sum}: Given a set of positive integers and an integer $k$, is there any non-empty subset whose sum to $k$.\n\\begin{enumerate}\n\t\\item Prove that $\\omega \\in \\Omega \\implies  \\theta \\in \\Theta$: \\\\\n\tLet's suppose we start with a solvable instance of \\textit{Subset Sum} Problem. Given $X = \\{x_1, ..., x_n\\}$ a set of positive integers to which there is a subset $X'$ such that its elements add up to $k$ and the sum of the whole set is $\\lambda$ ($\\sum\\limits_{x_i \\in X'}x_i = k$ and $\\sum\\limits_{x_i \\in X}x_i = \\lambda$). Let's define jobs $\\{j_1, ..., j_n\\}$ such that $s_i = 0$, $l_i = x_i$ and $d_i = \\lambda + 1$ for every $j_i$ (earliest start time, duration of the job and deadline respectively). This instance solves the scheduling problem because it's possible to arrange the jobs in any order and they will always meet their deadline.\n\t\t\n\t\\item Prove that $\\theta \\in \\Theta \\implies  \\omega \\in \\Omega$: \\\\\n\tLet's suppose we start with a solvable instance of our \\textit{Scheduling} problem. Given the set of jobs $\\{j_1, ..., j_n, j_{n+1}\\}$ where the first $n$ jobs are defined the same as before and job $j_{n+1}$ having $s_{n+1} = k$, $l_{n+1} = 1$ and $d_{n+1} = k+1$. The extra job must be done in $[k, k+1]$, but there would still be $\\lambda$ units of time available in the time interval $[0, \\lambda+1]$. Since this instance is solvable, we have $|X'|$ jobs that can be executed before the job $j_{n+1}$ and the remaining jobs after the job $j_{n+1}$. The set $X'$ solves the \\textit{Subset Sum} problem.\n\\end{enumerate}\nWe proved that our scheduling problem is \\textit{NP-Hard}, so we can say that it is not solvable with a quick algorithm.\n\n\\end{document}\n", "meta": {"hexsha": "621a5b3f226a33494b9421786cb5e2f069d5eae1", "size": 18032, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Homework 1/Solution.tex", "max_stars_repo_name": "marcocosta96/AD-Homeworks", "max_stars_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Homework 1/Solution.tex", "max_issues_repo_name": "marcocosta96/AD-Homeworks", "max_issues_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Homework 1/Solution.tex", "max_forks_repo_name": "marcocosta96/AD-Homeworks", "max_forks_repo_head_hexsha": "66715e5549d68b96ecd65e3bdb715ed455509353", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.9656357388, "max_line_length": 1333, "alphanum_fraction": 0.6688664596, "num_tokens": 6527, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.4001852878592426}}
{"text": "\\usetikzlibrary{backgrounds,calc}\n\n\\begin{document}\n\t\\chapter{Probability}\n\t\\section{Introduction}\n\tLet an event be denoted by $A$. The probability that event $A$ occurs is denoted by P$(A)$ and is given by \\[\\Pr(A) = \\frac{\\text{no. of ways in which } A \\text{ can occur}}{\\text{total no. of outcomes}}\\]\n\t\n\tAlso note that the probability of event $A$ not happening is defined by $1-\\Pr(A)$ and is denoted by $\\Pr(A^c)$.\n\t\n\t\\begin{example}\n\t\tA letter is chosen at random from the world `CALCULUS'. Find the probability that it is:\n\t\t\n\t\t\\quad \\textbf{a) } a `C'.\n\t\t\n\t\t\\quad \\textbf{b) } a vowel.\n\t\\end{example}\n\n\\begin{example}\n\tA card is chosen at random from a pack of 52 playing cards. Find the probability that the card is: \n\t\n\t\\quad \\textbf{a) } an ace.\n\t\n\t\\quad \\textbf{b) } black.\n\t\n\t\\quad \\textbf{c) } a heart.\n\t\n\t\\quad \\textbf{d) } a royal card.\n\\end{example}\n\t\\section{Using Permutations and Combinations}\n\t\n\tIn the following problem, the number of successful outcomes and the total number of outcomes are calculated using the counting techniques in the previous chapter.\n\t\n\t\\begin{example}\n\t\tA team of 6 children is chosen at random from a class of 10 girls and 9 boys. Find the probability thattge selected team contains:\n\t\t\n\t\t\\quad \\textbf{a) } girls only.\n\t\t\n\t\t\\quad \\textbf{b) } boys only.\n\t\t\t\n\t\t\\quad \\textbf{c) } more girls than boys.\n\t\t\n\t\t\\quad \\textbf{d) } the oldest 5 children in the class.\n\t\t\n\t\\end{example}\n\t\\section{Bernoulli Trials}\n\tA Binomial Experiment is an experiment which satisfies the following 4 conditions:\n\t\\begin{itemize}\n\t\t\\item {A fixed number of trials.}\n\t\t\\item {Each trial is independent of the others.}\n\t\t\\item {There are only \\textbf{two} outcomes.}\n\t\t\\item {The probability of each outcome remains constant from trial to trial.}\n\t\\end{itemize}\n\t\\section{Probability Space Diagrams and Tree Diagrams.}\n\tTree diagrams and possibility spaces are simple graphical tools which help us calculate probabilities. Possibility space diagrams are particularly useful when the problem involves independent events.\n\t\\section{Venn Diagrams}\n\tVenn diagrams ilustrate sets of objects or items and set operations. Consider for instance the sets $M_2$, $M_3$ and $M_5$ which stand for multiples of 2, 3 and 5 respectively. The \\textbf{universal} set $U$ is the set of all integers between 1 and 30. For convenience, let us consider the set $P$ to be the set of all primes between 1 and 30.\n\t\n\t\\begin{tikzpicture}[venncircle/.style={draw, circle, minimum size=15em, align=center}, node distance=12.5em, framed] \n\t\t\\node[venncircle] (circle1) {$M_5$};    \n\t\t\\node[venncircle, right of=circle1] (circle2) {$M_3$};\n\t\t\\node (MN) at ($(circle1)!0.5!(circle2)$){9};\n\t\t\\node[venncircle, below of=MN, yshift=3em] (circle3) {$M_2$}; %yshift value by pythagoras\n\t\t\\node (ML)  at ($(circle1)!0.4!(circle3)$){6};\n\t\t\\node (ML)  at ($(circle1)!0.5!(circle3)$){12};\n\t\t\\node (MLa)  at ($(circle1)!0.6!(circle3)$){18};    \n\t\t\\node (NL)  at ($(circle2)!0.5!(circle3)$){4};   \n\t\t\\node (MNL)  at ($(MN)!0.3!(circle3)$){2};\n\t\t\\node (Lleft) [below of=ML, yshift=5em] {16};\n\t\t\\node (Lright) [below of=NL, yshift=5em] {21};\n\t\t\\node (outbotrightnum) [right of=circle3, yshift=1.5em, xshift=-2em] {11};\n\t\t\\node (outtoprightnum) [above right of=circle2, yshift=-2.5em, xshift=-1em] {13};\n\t\t\\node (outbotleftnum) [below left of=circle3, yshift=4em, xshift=-4em]{12};\n\t\t\\node (outtopleftnum) [left of=circle3, yshift=1.5em]{23};\n\t\t\\node (U)[above left of=circle1, xshift=8em, yshift=-3em]{5};\n\t\t\\node (M)[above of=circle1, yshift=-4em]{\\textbf{\\textit{M}}};\n\t\t\\node (N)[above of=circle2, yshift=-4em]{\\textbf{\\textit{N}}};\n\t\t\\node (L)[below right of=circle3, yshift=2.5em, xshift=-2.5em]{\\textbf{\\textit{L}}};\n\t\\end{tikzpicture}  \n\\begin{itemize}\n\t\\item{The intersection between sets $M_2$ and $M_3$ is denoted by $M_2 \\cap M_3$ and hence $M_2 \\cap M_3 = \\set{6,12,18,25,30}$ and $M_2 \\cap M_3 \\cap M_5 = \\set{30}$.}\n\t\n\t\\item{The union between the sets $M_3$ and $M_5$ is denoted by $M_3 \\cup M_5$ and hence $M_3 \\cup M_5 = \\set{3,5,6,7,10,12,15,18,20,21,24,25,27,30}$.}\n\t\n\t\\item{We already know that the set that is formed by the members of the universal set which are not in the set $M_2$ is called the complement of the set $M_2$ denoted by $M_2^c$. Hence, $M_2^c = \\set{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29}$.}\n\\end{itemize}\n\n\n\n\n\n\nWe already know that the set that is formed by the members of the universal set which are not in the set $M_2$ is called the complement of the set $M_2$ denoted by $M_2^C$\n\n\\end{document}", "meta": {"hexsha": "05d7a8de64d02edd6b90d322bdea2ed223a83850", "size": 4522, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Pure Mathematics/probability.tex", "max_stars_repo_name": "Girogio/My-LaTeX", "max_stars_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-12T11:45:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-30T21:47:25.000Z", "max_issues_repo_path": "Pure Mathematics/probability.tex", "max_issues_repo_name": "Girogio/My-LaTeX", "max_issues_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Pure Mathematics/probability.tex", "max_forks_repo_name": "Girogio/My-LaTeX", "max_forks_repo_head_hexsha": "706ec7cb4d62af1b5a9ad7547589889240c755bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1063829787, "max_line_length": 344, "alphanum_fraction": 0.6930561698, "num_tokens": 1592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632979641571, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.4001761175552022}}
{"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\chapter{Theoretical Background}\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Transformers}\n\nVaswani et al\\cite{vaswani2017attention} described transformers as sequence \nmodels that solely focus on self-attention without the need for recurrence which \neliminates the need for unfolding during the backpropagation phase of learning. \nIn the paper, attention was defined with respect to keys, values, and queries. \nThe attention is computed with\n\n\\[ \n    attention(K,Q,V) = \\left(\\frac{QK^T}{\\sqrt{dim(K)}}\\right)V \n\\]\n\nwhere K is the key matrix, Q is the query matrix, and V is the value matrix. \nThe dot product of Q and K is scaled by the square root of the dimension of K.\n\nTransformer models take the whole input as a whole instead of recurrently meaning \nthat the model does not know the order of the words in the sequence. Hence, the \npaper proposed the use of positional encodings through sinusoidal functions \nadded to the embedded vectors. Suppose that W is a matrix where each column \ncorresponds to a position pos and each row i corresponds to the individual \ndimensions in the model which alters the frequency. Let \n\\begin{math}\n    W=10000^2i/embedsize\n\\end{math}\nwhere embedsize is a hyperparameter which is also the embedding size of the \nembedded vectors. Then, the positional encoding is calculated by\n\\[ \n    POS(pos,i) = \\sin\\left(\\frac{pos}{W}\\right) \\text{if \\textit{i} is even and}\n\\]\n\\[ \n    POS(pos,i) = \\cos\\left(\\frac{pos}{W}\\right) \\text{if \\textit{i} is odd}\n\\]\nThe key component of transformers is the multi-headed attention layer, wherein \nattention is computed multiple times and concatenated together. Transformers \nwere able to outperform established models for machine translation with \nEnglish-German translation.\n\n\\section{RoBERTa for Classification}\nRoBERTa\\cite{liu2019roberta} is a replication study of the original BERT \nmodel by finer-tuning hyperparameters and removing the Next Sentence \nPrediction task which was shown that it does not negatively affect the \nperformance of the model. While the original transformer by Vaswani et al.\\ \nis a Seq2Seq transformer, RoBERTa is an autoencoder transformer trained on a \nlarge corpus, which can be used with fine-tuning or transfer learning for \ndifferent downstream tasks such as classification\\cite{pritzkau2021nlytics}.\n\nIn this paper, the researchers will use the CodeBERT\\cite{feng2020codebert} \nto be used with transfer learning on algorithm classification. The CodeBERT \nmodel is a variant of RoBERTa pretrained on multiple programming languages \nincluding Java, Python, and Javascript.\n\n\\subsection{Model Architecture}\n\nThe CodeBERT model is a bidirectional transformer using a similar architecture \nwith RoBERTa without any architectural modification.\n\n\\subsection{Dataset}\n\nCodeBERT was trained on a large corpus of about 8million codes of both bimodal \nand unimodal data. Bimodal data means that for each code snippet, \nthere is an accompanying natural language snippet while unimodal data \nimplies the absence of the natural language snippet. The data were gathered from \nGitHub, which was collected by Husain et al\\cite{husain2020codesearchnet}.\n\n\\section{Task-Constraint Feedback}\n\nKnowledge About Task-Constraints (KTC) feedback systems employ the use of limiting \nthe submission by adding requirements, called \\textit{constraints}, that will tell the \nstudent if they haven’t completed the requirement.\\cite{keuning2016towards} One of the methods used \nis \\textit{Hints on Task Requirements} (TR) wherein a hint will be given when a task was \nnot completed. As an example, suppose that the problem setter asked to balance a \nbinary search tree using red-black trees. However, the submitter was able to \ncomplete the problem using an AVL tree. The TR system should give some feedback \nthat the Red-Black Tree is a requirement for the given problem.\n\n\\section{Algorithm Classification}\nAlgorithms and data structure can be written multiple ways with different stylistic \nand data structure choices. The researchers define algorithm classification as to \nwhat algorithm some code snippet is implementing, rather than the class such as \nsorting, searching, etc. Introductory algorithm textbooks\\cite{velivckovic2021clrs}\\cite{skiena2020algorithm}\\cite{sedgewick2011algorithms} \nhave a good resource on the algorithm names through its table of contents which will \nbe used as labels in the classifier. With this, this research defines algorithm \nclassification by tagging code snippets as to the question “what is the algorithm \nname that this code snippet is implementing?” \n\nIn computer science education, students might use multiple algorithms into one file \nand begin using different data structures for their implementations. As an example, \nconsider the task of implementing a \\textit{priority queue} (the \\textit{priority queue} is a classification). \nThe priority queue data structure can be implemented with \\textit{binary heaps} or dictionaries \nsuch as \\textit{linked lists} and \\textit{binary search trees}; in this example, assume that the priority \nqueue is implemented with a \\textit{binary heap}. Introductory programming students might usually \nbe coding these algorithms and algorithms manually into one file and it is not enough to \nsay that the submission implements a \\textit{priority queue} since a \\textit{binary heap} is also implemented. \n\nSuppose that the code snippet implements an algorithm and uses some data structure or \nanother algorithm using the language’s standard library, then the snippet will only be \nclassified using the manual implementation disregarding the standard library function. \nLikewise, code snippets that do not belong to any algorithms stated in any of the \nintroductory algorithm textbooks are said not to use any algorithm. These code snippets \nusually contain the \\textit{main} function (but not always), setter and getter functions, \nand boilerplate codes.\n", "meta": {"hexsha": "6756879d75a694c87f6ed1ed33a8c5eae1f4bedb", "size": 6028, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/techbackground.tex", "max_stars_repo_name": "gerdiedoo/test-thesis", "max_stars_repo_head_hexsha": "0d9b862442780cd39731d3e7b6416fe9cc4a08aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/techbackground.tex", "max_issues_repo_name": "gerdiedoo/test-thesis", "max_issues_repo_head_hexsha": "0d9b862442780cd39731d3e7b6416fe9cc4a08aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/techbackground.tex", "max_forks_repo_name": "gerdiedoo/test-thesis", "max_forks_repo_head_hexsha": "0d9b862442780cd39731d3e7b6416fe9cc4a08aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.8679245283, "max_line_length": 140, "alphanum_fraction": 0.7828467153, "num_tokens": 1305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4001761066514151}}
{"text": "\\chapter{central force motion solutions}\n\\begin{abox}\n\tPractice set 1 solutions\n\t\\end{abox}\n\\begin{enumerate}\n\t\t\\item The acceleration due to gravity $(g)$ on the surface of Earth is approximately $2.6$ times that on the surface of Mars. Given that the radius of Mars is about one half the radius of Earth, the ratio of the escape velocity on Earth to that on Mars is approximately\n\t\t{\\exyear{NET JUNE 2011}}\n\t\\begin{tasks}(2)\n\t\t\\task[\\textbf{A.}] $1.1$\n\t\t\\task[\\textbf{B.}]$1.3$\n\t\t\\task[\\textbf{C.}]$2.3$\n\t\t\\task[\\textbf{D.}]$5.2$\n\t\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n\t\\text { Escape velocity }&=\\sqrt{2 g R}\\\\\n\\frac{\\text { Escape velocity of Earth }}{\\text { Escape velocity of Mass }}&=\\sqrt{\\frac{g_{e} R_{e}}{g_{m} R_{m}}}=2.3 \\quad \\text { where } \\frac{R_{e}}{R_{m}}=2 \\text { and } \\frac{g_{e}}{g_{m}}=2.6\n\\end{align*}\n\tTHe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item Two particles of identical mass move in circular orbits under a central potential $V(r)=\\frac{1}{2} k r^{2}$. Let $l_{1}$ and $l_{2}$ be the angular momenta and $r_{1}, r_{2}$ be the radii of the orbits respectively. If $\\frac{l_{1}}{l_{2}}=2$, the value of $\\frac{r_{1}}{r_{2}}$ is:\n\t{\\exyear{NET DEC 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\sqrt{2}$\n\t\\task[\\textbf{B.}]$1 / \\sqrt{2}$\n\t\\task[\\textbf{C.}] 2\n\t\\task[\\textbf{D.}] $1 / 2$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t V_{e f f}&=\\frac{l^{2}}{2 m r^{2}}+\\frac{1}{2} k r^{2}, \\text{where $l$ is angular momentum. }\\\\\n\t\\intertext{Condition for circular orbit} \\frac{\\partial V_{e f f}}{\\partial r}&=0 \\Rightarrow-\\frac{l^{2}}{m r^{3}}+k r=0 \\Rightarrow l^{2} \\propto r^{4} \\Rightarrow l \\propto r^{2}.\\\\\n\tThus \\frac{l_{1}}{l_{2}}&=\\left(\\frac{r_{1}}{r_{2}}\\right)^{2} \\Rightarrow \\frac{r_{1}}{r_{2}}=\\sqrt{\\frac{l_{1}}{l_{2}}} \\Rightarrow \\frac{r_{1}}{r_{2}}=\\sqrt{2}\\\\ \n\tsince \\frac{l_{1}}{l_{2}}&=2\n\t\\end{align*}\n\tThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item A planet of mass $m$ moves in the inverse square central force field of the Sun of mass $M$. If the semi-major and semi-minor axes of the orbit are $a$ and $b$, respectively, the total energy of the planet is:\n\t{\\exyear{NET DEC 2011}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $-\\frac{G M m}{a+b}$\n\t\\task[\\textbf{B.}]$-G M m\\left(\\frac{1}{a}+\\frac{1}{b}\\right)$\n\t\\task[\\textbf{C.}]$-\\frac{G M m}{a}\\left(\\frac{1}{b}-\\frac{1}{a}\\right)$\n\t\\task[\\textbf{D.}]$-G M m\\left(\\frac{a-b}{(a+b)^{2}}\\right)$\n\\end{tasks}\n\\begin{answer}\n Assume Sun is at the centre of elliptical orbit. Conservation of energy\\\\\n  $$\\frac{1}{2} m v_{1}^{2}-\\frac{G M m}{a}=\\frac{1}{2} m v_{2}^{2}-\\frac{G M m}{b}$$ Conservation of momentum $L=m v_{1} a=m v_{2} b$\\\\\n  \\begin{figure}[H]\n  \t\\centering\n  \t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(12)-crop}\n  \\end{figure}\n \\begin{align*}\n \t&v_{2}=v_{1}\\left(\\frac{a}{b}\\right) \\\\\n \t&\\frac{1}{2} m v_{1}^{2}-\\frac{1}{2} m v_{2}^{2}=\\frac{G M m}{a}-\\frac{G M m}{b} \\Rightarrow \\frac{1}{2} m\\left(v_{1}^{2}-v_{1}^{2} \\frac{a^{2}}{b^{2}}\\right)=G M m\\left(\\frac{b-a}{a b}\\right) \\\\\n \t&\\frac{1}{2} m v_{1}^{2}\\left(\\frac{b^{2}-a^{2}}{b^{2}}\\right)=G M m\\left(\\frac{b-a}{a b}\\right) \\Rightarrow \\frac{1}{2} m v_{1}^{2}=G M m\\left(\\frac{b}{a}\\right) \\cdot \\frac{1}{(b+a)} \\\\\n \t&E=\\frac{1}{2} m v_{1}^{2}-\\frac{G M m}{a}=G M m \\frac{b}{a} \\frac{1}{(b+a)}-\\frac{G M m}{a} \\\\\n \t&=\\frac{G M m}{a}\\left(\\frac{b}{(b+a)}-1\\right)=\\frac{G M m}{a}\\left(\\frac{b-b-a}{(b+a)}\\right)=-\\frac{G M m}{(b+a)}\n \\end{align*}\n The correct option is \\textbf{(a)}\t\n\\end{answer}\n\n\t\\item A planet of mass $m$ moves in the gravitational field of the Sun (mass $M$ ). If the semimajor and semi-minor axes of the orbit are $a$ and $b$ respectively, the angular momentum of the planet is\n\t{\\exyear{NET DEC 2012}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}]$\\sqrt{2 G M m^{2}(a+b)}$\n\t\\task[\\textbf{B.}]$\\sqrt{2 G M m^{2}(a-b)}$\n\t\\task[\\textbf{C.}]$\\sqrt{\\frac{2 G M m^{2} a b}{a-b}}$\n\t\\task[\\textbf{D.}]$\\sqrt{\\frac{2 G M m^{2} a b}{a+b}}$\n\\end{tasks}\n\\begin{answer}\n\t Assume Sun is at the centre of elliptical orbit.\\\\\\\\\n\tConservation of energy $\\frac{1}{2} m v_{1}^{2}-\\frac{G M m}{a}=\\frac{1}{2} m v_{2}^{2}-\\frac{G M m}{b}$\\\\\\\\\n\tConservation of momentum $L=m v_{1} a=m v_{2} b$\n\t$$\n\tv_{2}=v_{1}\\left(\\frac{a}{b}\\right)\n\t$$\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(12)-crop}\n\t\\end{figure}\n\t\\begin{align*}\n\t\t&\\frac{1}{2} m v_{1}^{2}-\\frac{1}{2} m v_{2}^{2}=\\frac{G M m}{a}-\\frac{G M m}{b} \\Rightarrow \\frac{1}{2} m\\left(v_{1}^{2}-v_{1}^{2} \\frac{a^{2}}{b^{2}}\\right)=G M m\\left(\\frac{b-a}{a b}\\right) \\\\\n\t\t&\\frac{1}{2} m v_{1}^{2}\\left(\\frac{b^{2}-a^{2}}{b^{2}}\\right)=G M m\\left(\\frac{b-a}{a b}\\right) \\Rightarrow \\frac{1}{2} m v_{1}^{2}=G M m\\left(\\frac{b}{a}\\right) \\cdot \\frac{1}{(b+a)} \\\\\n\t\t&v_{1}=\\sqrt{2 G M\\left(\\frac{b}{a}\\right) \\cdot \\frac{1}{(b+a)}} \\\\\n\t\t&L=m v_{1} a=m \\sqrt{2 G M\\left(\\frac{b}{a}\\right) \\cdot\\left(\\frac{1}{b+a}\\right)} \\cdot a=m \\sqrt{\\frac{2 G M a b}{(b+a)}} \\Rightarrow L=\\sqrt{\\frac{2 G M m^{2} a b}{a+b}}\n\t\\end{align*}\n\tThe correct option is \\textbf{(d)}\n\\end{answer}\n\t\\item A planet of mass $m$ and an angular momentum $L$ moves in a circular orbit in a potential, $V(r)=-k / r$, where $k$ is a constant. If it is slightly perturbed radially, the angular frequency of radial oscillations is\n\t{\\exyear{NET JUNE 2013}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $m k^{2} / \\sqrt{2} L^{3}$\n\t\\task[\\textbf{B.}]$m k^{2} / L^{3}$\n\t\\task[\\textbf{C.}]$\\sqrt{2} m k^{2} / L^{3}$\n\t\\task[\\textbf{D.}]$\\sqrt{3} m k^{2} / L^{3}$\n\\end{tasks}\n\\begin{answer}$\\left. \\right. $\\\\\n\t\\begin{minipage}{0.5\\textwidth}\n\t\\begin{align*}\n\tV_{e f f}&=\\frac{L^{2}}{2 m r^{2}}-\\frac{k}{r} \\\\\n\t\\intertext{For circular orbit} \\frac{\\partial V_{e f f}}{\\partial r}&=-\\frac{L^{2}}{m r^{3}}+\\frac{k}{r^{2}}=0 \\\\\n\t\\Rightarrow \\frac{L^{2}}{m r^{3}}&=\\frac{k}{r^{2}} \\\\\n\t\\text{Thus} r&=r_{0}=\\frac{L^{2}}{m k} \\Rightarrow \\omega=\\sqrt{\\frac{k}{m}},\n\t\\end{align*}\n\t\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=4cm,width=5cm]{diagram-20210926(17)-crop}\n\\end{figure}\n\\end{minipage}\n \\begin{align*}\n k&=\\left.\\frac{d^{2} V_{e f f}}{d r^{2}}\\right|_{r=r_{0}}=+\\frac{3 L^{2}}{m r^{4}}-\\left.\\frac{2 k}{r^{3}}\\right|_{r=r_{0}}=\\frac{3 L^{2}}{m\\left(\\frac{L^{2}}{m k}\\right)^{4}}-\\frac{2 k}{\\left(\\frac{L^{2}}{m k}\\right)^{3}}=\\frac{3 m^{3} k^{4}}{L^{6}}-\\frac{2 m^{3} k^{4}}{L^{6}}=\\frac{m^{3} k^{4}}{L^{6}}\\\\\n \\omega&=\\sqrt{\\frac{\\left.\\frac{d^{2} V}{d r^{2}}\\right|_{r=r_{0}}}{m}} \\Rightarrow \\omega=\\frac{m k^{2}}{L^{3}}\n \\end{align*}\n The correct option is \\textbf{(b)}\t\n\\end{answer}\n\n\\item The radius of Earth is approximately $6400 \\mathrm{~km}$. The height $h$ at which the acceleration due to Earth's gravity differs from $g$ at the Earth's surface by approximately $1 \\%$ is\n\t{\\exyear{NET DEC 2014}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $64 \\mathrm{~km}$\n\t\\task[\\textbf{B.}] $48 \\mathrm{~km}$\n\t\\task[\\textbf{C.}]$32 \\mathrm{~km}$\n\t\\task[\\textbf{D.}]$16 \\mathrm{~km}$\n\\end{tasks}\n\\begin{answer}\n$\\frac{g}{g^{\\prime}}=1+\\frac{2 h}{R} \\Rightarrow \\frac{g}{g^{\\prime}}-1=\\frac{2 h}{R} \\Rightarrow \\frac{\\Delta g}{g^{\\prime}}=\\frac{2 h}{R} \\Rightarrow h=32 k \\cdot m$\\\\\nThe correct option is \\textbf{(c)}\t\n\\end{answer}\n\n\t\\item The probe Mangalyaan was sent recently to explore the planet Mars. The inter-planetary part of the trajectory is approximately a half-ellipse with the Earth (at the time of launch),Sun and Mars (at the time the probe reaches the destination) forming the major axis. Assuming that the orbits of Earth and Mars are approximately circular with radii $R_{E}$ and $R_{M}$, respectively, the velocity (with respect to the Sun) of the probe during its voyage when it is at a distance\n\t\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(22)-crop(1)}\n\t\\end{figure}\n\t $r\\left(R_{E}<<r<<R_{M}\\right) \\text { from the Sun, neglecting the effect of Earth and Mars, is }$\n\t{\\exyear{NET DEC 2014}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\sqrt{2 G M \\frac{\\left(R_{E}+R_{M}\\right)}{r\\left(R_{E}+R_{M}-r\\right)}}$\n\t\\task[\\textbf{B.}]$\\sqrt{2 G M \\frac{\\left(R_{E}+R_{M}-r\\right)}{r\\left(R_{E}+R_{M}\\right)}}$\n\t\\task[\\textbf{C.}]$\\sqrt{2 G M \\frac{R_{E}}{r R_{M}}}$\n\t\\task[\\textbf{D.}]$\\sqrt{\\frac{2 G M}{r}}$\n\\end{tasks}\n\\begin{answer}\n\t$\\text { Total energy } E=-K / 2 a \\text { where } 2 a \\text { major axis and } 2 a=R_{E}+R_{M} \\text {. }$\n\t$$\\frac{1}{2} m v^{2}-\\frac{G M m}{r}=-\\frac{G M m}{\\left(R_{E}+R_{M}\\right)} \\Rightarrow v=\\sqrt{2 G M \\frac{\\left(R_{E}+R_{M}-r\\right)}{r\\left(R_{E}+R_{M}\\right)}}$$\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item After a perfectly elastic collision of two identical balls, one of which was initially at rest, the velocities of both the balls are non zero. The angle $\\theta$ between the final, velocities (in the lab frame) is\n\t{\\exyear{NET DEC 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\theta=\\frac{\\pi}{2}$\n\t\\task[\\textbf{B.}]$\\theta=\\pi$\n\t\\task[\\textbf{C.}]$0<\\theta \\leq \\frac{\\pi}{2}$\n\t\\task[\\textbf{D.}] $\\frac{\\pi}{2}<\\theta \\leq \\pi$\n\\end{tasks}\n\\begin{answer}\n Angle between two particle $\\theta_{1}+\\theta_{2}=0$\nConservation of momentum\n\\begin{align*}\n&m u=m v_{1} \\cos \\theta_{1}+m v_{2} \\cos \\theta_{2} \\\\\n&0=m v_{1} \\sin \\theta_{1}-m v_{2} \\sin \\theta_{2}\n\\intertext{conservation of kinetic energy }\n&\\frac{1}{2} m u^{2}=\\frac{1}{2} m v_{1}^{2}+\\frac{1}{2} m v_{2}^{2}\\\\\n\t&u^{2}=v_{1}^{2}+v_{2}^{2}+2 v_{1} v_{2}\\left(\\cos \\theta_{1} \\cos \\theta_{2}-\\sin \\theta_{1} \\sin \\theta_{2}\\right) \\\\\n\t&u^{2}=v_{1}^{2}+v_{2}^{2}+2 v_{1} v_{2} \\cos \\left(\\theta_{1}+\\theta_{2}\\right) \\\\\n\t&u^{2}=v_{1}^{2}+v_{2}^{2} \\\\\n\t&v_{1}^{2}+v_{2}^{2}=v_{1}^{2}+v_{2}^{2}+2 v_{1} v_{2} \\cos \\left(\\theta_{1}+\\theta_{2}\\right) \\\\\n\t&\\cos \\left(\\theta_{1}+\\theta_{2}\\right)=0 \\\\\n\t&\\theta_{1}+\\theta_{2}=\\frac{\\pi}{2} \\Rightarrow \\theta=\\frac{\\pi}{2}\n\\end{align*}\nThe correct option is \\textbf{(a)}\t\n\\end{answer}\n\t\\item Consider circular orbits in a central force potential $V(r)=-\\frac{k}{r^{n}}$, where $k>0$ and $0<n<2$. If the time period of a circular orbit of radius $R$ is $T_{1}$ and that of radius $2 R$ is $T_{2}$, then $\\frac{T_{2}}{T_{1}}$\n\t{\\exyear{NET DEC 2016}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $2^{\\frac{n}{2}}$\n\t\\task[\\textbf{B.}]$2^{\\frac{2}{3} n}$\n\t\\task[\\textbf{C.}]$2^{\\frac{n}{2}+1}$\n\t\\task[\\textbf{D.}]$2^{n}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\t&V_{e f f}=\\frac{J^{2}}{2 m r^{2}}-\\frac{k}{r^{n}}, \\frac{\\partial V_{e f f}}{\\partial r}=-\\frac{J^{2}}{m r^{3}}+\\frac{n k}{r^{n+1}}=0\\\\\n\t\t&\\because J=m r^{2} \\omega \\Rightarrow \\frac{m^{2} \\omega^{2} r^{4}}{r^{3}}=\\frac{n k}{r^{n+1}} \\Rightarrow \\omega^{2} \\propto \\frac{1}{r^{n+2}} \\Rightarrow \\omega \\propto r^{-(n+2) / 2} \\Rightarrow T \\propto r^{\\frac{n}{2}+1} \\\\\n\t\t&\\frac{T_{2}}{T_{1}}=\\left(\\frac{2 R}{R}\\right)^{\\frac{n+2}{2}}=2^{\\frac{n}{2}+1}\n\t\\end{align*}\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\t\\item A ball weighing $100 \\mathrm{gm}$, released from a height of $5 \\mathrm{~m}$, bounces perfectly elastically off a plate. The collision time between the ball and the plate is $0.5 \\mathrm{~s}$. The average force on the plate is approximately\n{\t\\exyear{NET JUNE 2017}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $3 N$\n\t\\task[\\textbf{B.}]$2 N$\n\t\\task[\\textbf{C.}]$5 N$\n\t\\task[\\textbf{D.}]$4 N$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\nm&=\\frac{100}{1000}=0.1 \\mathrm{~kg}\\\\\nm g h&=\\frac{1}{2} m v^{2} \\\\\nv&=\\sqrt{2 g h} \\\\\nv & =10 \\mathrm{~m} / \\mathrm{sec}\n\\intertext{change in momentum during collision}\n (m v)-(-m v)&=2 k . g m / \\mathrm{sec}\\\\\nf&=\\frac{\\Delta P}{\\Delta t}=\\frac{2}{0.5}=4 N\n\\end{align*}\nThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\t\\item Which of the following figures best describes the trajectory of a particle moving in a repulsive central potential $V(r)=\\frac{a}{r}(a>0$ is a constant)?\n\t{\\exyear{NET JUNE 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(47)-crop}\n\t\\end{figure}\n\t\\task[\\textbf{B.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(48)-crop}\n\t\\end{figure}\n\t\\task[\\textbf{C.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(49)-crop}\n\t\\end{figure}\n\t\\task[\\textbf{D.}]\\begin{figure}[H]\n\t\t\\centering\n\t\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(50)-crop}\n\t\\end{figure}\n\\end{tasks}\n\\begin{answer}\n\\begin{minipage}{0.5\\textwidth}\n\t The potential is $V(r)=\\frac{a}{r}$ which is repulsive. So there is unbounded motion and mainly represent by scattering project\n\\end{minipage}\n\\begin{minipage}{0.5\\textwidth}\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[height=3cm,width=5cm]{diagram-20210926(51)-crop}\n\\end{figure}\n\\end{minipage}\\\\\nThe correct option is \\textbf{(c)}\n\\end{answer}\n\n\t\\item A particle of mass $m$ moves in a central potential $V(r)=-\\frac{k}{r}$ in an elliptic orbit $r(\\theta)=\\frac{a\\left(1-e^{2}\\right)}{1+e \\cos \\theta}$, where $0 \\leq \\theta<2 \\pi$ and $a$ and $e$ denote the semi-major axis and eccentricity, respectively. If its total energy is $E=-\\frac{k}{2 a}$, the maximum kinetic energy is\n\t{\\exyear{NET JUNE 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $E\\left(1-e^{2}\\right)$\n\t\\task[\\textbf{B.}]$E \\frac{(e+1)}{(e-1)}$\n\t\\task[\\textbf{C.}]$E /\\left(1-e^{2}\\right)$\n\t\\task[\\textbf{D.}]$E \\frac{(e-1)}{(e+1)}$\n\\end{tasks}\n\\begin{answer}\n\n\n\\begin{align*}\n &E=T+V \\quad T=E-V\\\\\n&T=-\\frac{k}{2 a}+\\frac{k}{r} T=-\\frac{k}{2 a}+\\frac{k}{a\\left(1-e^{2}\\right)}(1+\\cos \\theta)\n&\\intertext{T is maximum when } \n&\\cos \\theta=1\\\\\n&T_{\\max }=-\\frac{k}{2 a}+\\frac{k(1+e)}{a\\left(1-e^{2}\\right)}=-\\frac{k}{2 a}+\\frac{k}{a} \\frac{(1+e)}{(1-e)(1+e)} \\\\\n&=-\\frac{k}{a}\\left[\\frac{1}{2}+\\frac{1}{(1-e)}\\right]=-\\frac{k}{2 a}\\left(\\frac{1+e}{1-e}\\right)=-E\\left(\\frac{1+e}{1-e}\\right)\n\\end{align*}\nThe correct option is \\textbf{(b)}\t\n\\end{answer}\n\n\t\\item In the attractive Kepler problem described by the central potential $V(r)=\\frac{-k}{r}($ where $k$ is a positive constant), a particle of mass $m$ with a non-zero angular momentum can never reach the centre due to the centrifugal barrier. If we modify the potential to\n\t$$\n\tV(r)=-\\frac{k}{r}-\\frac{\\beta}{r^{3}}\n\t$$\n\tone finds that there is a critical value of the angular momentum $\\ell_{c}$ below which there is no centrifugal barrier. This value of $\\ell_{c}$ is\n\t{\\exyear{NET DEC 2018}}\n\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\left[12 \\mathrm{~km}^{2} \\beta\\right]^{1 / 2}$\n\t\\task[\\textbf{B.}]$\\left[12 \\mathrm{~km}^{2} \\beta\\right]^{-1 / 2}$\n\t\\task[\\textbf{C.}]$\\left[12 \\mathrm{~km}^{2} \\beta\\right]^{1 / 4}$\n\t\\task[\\textbf{D.}]$\\left[12 \\mathrm{~km}^{2} \\beta\\right]^{-1 / 4}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\t&V_{e f f}=\\frac{L^{2}}{2 m r^{2}}-\\frac{k}{r}=0 \\Rightarrow-\\frac{L^{2}}{m r^{3}}+\\frac{k}{r^{2}}=0 \\Rightarrow r_{0}=\\frac{L^{2}}{m k}\\\\\n\t\\intertext{when introduce new potential}\n\t&V_{e f f}=\\frac{L^{2}}{2 m r^{2}}-\\frac{k}{r}-\\frac{\\beta}{r^{3}}\n\t\\\\\n\t\\intertext{For critical value}\n\t&\\frac{\\partial V_{e f f}}{\\partial r}=\\frac{-L^{2}}{m r^{3}}+\\frac{k}{r^{2}}+\\frac{3 \\beta}{r^{4}} \\\\\n\t&\\frac{\\partial^{2} V_{e f f}}{\\partial r^{2}}=\\frac{+3 L^{2}}{m r^{4}} \\frac{-2 k}{r^{3}}-\\frac{12 \\beta}{r^{5}} \\geq 0\\\\\n\t\\intertext{ For critical value }\n\t&=\\frac{3 L^{2}}{m\\left(\\frac{L^{2}}{m k}\\right)^{4}}-\\frac{2 k}{\\left(\\frac{L^{2}}{m k}\\right)^{3}}-\\frac{12 \\beta}{\\left(\\frac{L^{2}}{m k}\\right)^{5}}=0=\\frac{3 m^{3} k^{4}}{L^{6}}-\\frac{2 m^{3} x^{4}}{L^{6}}-\\frac{12 m^{5} x^{5} \\beta}{L^{10}}=0 \\\\\n\t&L_{C}=\\left(12 m^{2} k \\beta\\right)^{1 / 4} \\frac{m^{3} k^{4}}{L^{6}}\\left(3-2-12 \\frac{m^{2} k \\beta}{L^{4}}\\right)=0 \\Rightarrow L_{c}=\\left(12 m^{2} k \\beta\\right)^{1 / 4}\n\t\\end{align*}\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\\end{enumerate}\n\n\n\\newpage\n\\begin{abox}\n\tPractice set 2 solutions\n\t\\end{abox}\n\\begin{enumerate}\n\t\\item In a central force field, the trajectory of a particle of mass $m$ and angular momentum $L$ in plane polar coordinates is given by,\\\\\n\t$$\\frac{1}{r}=\\frac{m}{l^{2}}(1+\\varepsilon \\cos \\theta)$$\n\twhere, $\\varepsilon$ is the eccentricity of the particle's motion. Which one of the following choice for $\\varepsilon$ gives rise to a parabolic trajectory?\n\t{\\exyear{GATE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\varepsilon=0$\n\t\\task[\\textbf{B.}]$\\varepsilon=1$\n\t\\task[\\textbf{C.}] $0<\\varepsilon<1$\n\t\\task[\\textbf{D.}] $\\varepsilon>1$\n\\end{tasks}\n\\begin{answer}\n\t$$\n\t\\frac{1}{r}=\\frac{m}{l^{2}}(1+\\varepsilon \\cos \\theta)\n\t$$\n\tFor parabolic trajectory $\\varepsilon=1$.\\\\\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\n\t\\item A particle of unit mass moves along the $x$-axis under the influence of a potential, $V(x)=x(x-2)^{2}$. The particle is found to be in stable equilibrium at the point $x=2$. The time period of oscillation of the particle is\n\t{\\exyear{GATE 2012}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $\\frac{\\pi}{2}$\n\t\\task[\\textbf{B.}]$\\pi$\n\t\\task[\\textbf{C.}]$\\frac{3 \\pi}{2}$\n\t\\task[\\textbf{D.}] $2 \\pi$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t&V(x)=x(x-2)^{2} \\Rightarrow \\frac{\\partial V}{\\partial x}=(x-2)^{2}+2 x(x-2)=0 \\Rightarrow x=2, x=\\frac{2}{3}\\\\\n\t\t&\\frac{\\partial^{2} V}{\\partial x^{2}}=2(x-2)+2(x-2)+\\left.2 x \\Rightarrow \\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=2}=2 \\times 2=4 \\\\\n\t\t&\\Rightarrow \\omega=\\sqrt{\\left.\\frac{\\partial^{2} V}{\\partial x^{2}}\\right|_{x=2}} \\Rightarrow \\omega=\\frac{2 \\pi}{T}=2 \\Rightarrow T=\\pi\n\t\\end{align*}\n\tThe correct option is \\textbf{(b)}\n\\end{answer}\n\t\\item $\\text { A particle of mass } m \\text { is in a potential given by }$\n\t$$V(r)=-\\frac{a}{r}+\\frac{a r_{0}^{2}}{3 r^{3}}$$\n\twhere $a$ and $r_{0}$ are positive constants. When disturbed slightly from its stable equilibrium position it undergoes a simple harmonic oscillation. The time period of oscillation is\n\t{\\exyear{GATE 2014}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $2 \\pi \\sqrt{\\frac{m r_{0}^{3}}{2 a}}$\n\t\\task[\\textbf{B.}]$2 \\pi \\sqrt{\\frac{m r_{0}{ }^{3}}{a}}$\n\t\\task[\\textbf{C.}]$2 \\pi \\sqrt{\\frac{2 m r_{0}^{3}}{a}}$\n\t\\task[\\textbf{D.}]$4 \\pi \\sqrt{\\frac{m r_{0}^{3}}{a}}$\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\tV(r)&=-\\frac{a}{r}+\\frac{a r_{0}^{2}}{3 r^{3}}\\\\\n\t\\text{For equilibrium} \\frac{\\partial V}{\\partial r}&=\\frac{a}{r^{2}}-\\frac{3 a r_{0}^{2}}{3 r^{4}}=0, \\quad r=\\pm r_{0} \\\\\n\t\\frac{\\partial^{2} V}{\\partial r^{2}}&=-\\frac{2 a}{r^{3}}+\\left.\\frac{4 a r_{0}^{2}}{r^{5}}\\right|_{r_{0}}=-\\frac{2 a}{r_{0}^{3}}+\\frac{4 a r_{0}^{2}}{r_{0}^{5}}=\\frac{2 a}{r_{0}^{3}}\\\\\n\t\\omega&=\\sqrt{\\frac{\\left.\\frac{\\partial^{2} V}{\\partial r^{2}}\\right|_{r_{0}}}{m}} \\Rightarrow T=2 \\pi \\sqrt{\\frac{m r_{0}^{3}}{2 a}}\n\t\\end{align*}\n\tThe correct option is \\textbf{(a)}\n\\end{answer}\n\t\\item A planet of mass $m$ moves in a circular orbit of radius $r_{0}$ in the gravitational potential $V(r)=-\\frac{k}{r}$, where $k$ is a positive constant. The orbit angular momentum of the planet is\n\t{\\exyear{GATE 2014}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] $2 r_{0} \\mathrm{~km}$\n\t\\task[\\textbf{B.}]$\\sqrt{2 r_{0} \\mathrm{~km}}$\n\t\\task[\\textbf{C.}]$r_{0} k m$\n\t\\task[\\textbf{D.}]$\\sqrt{r_{0} k m}$\n\\end{tasks}\n\\begin{answer}\n\\begin{align*}\n\tV_{\\text {effctive }}&=\\frac{J^{2}}{2 m r^{2}}-\\frac{k}{r} \\Rightarrow \\frac{d V_{\\text {effect }}}{d r}=-\\frac{J^{2}}{m r^{3}}+\\frac{k}{r^{2}}=0 \\text { at } r=r_{0}\\\\\n\\text { so } J&=\\sqrt{r_{0} k m}\n\\end{align*}\nThe correct option is \\textbf{(d)}\t\n\\end{answer}\n\t\\item An interstellar object has speed $v$ at the point of its shortest distance $R$ from a star of much larger mass $M$. Given $v^{2}=2 G M / R$, the trajectory of the object is\n\t{\\exyear{GATE 2018}}\n\\begin{tasks}(2)\n\t\\task[\\textbf{A.}] circle\n\t\\task[\\textbf{B.}]ellipse\n\t\\task[\\textbf{C.}]parabola\n\t\\task[\\textbf{D.}]hyperbola\n\\end{tasks}\n\\begin{answer}\n\t\\begin{align*}\n\t\\text { At shortest distance } E&=\\frac{J^{2}}{2 m R^{2}}-\\frac{G M m}{R}\\\\\n\tSince, m v R&=J \\Rightarrow J^{2}=m^{2} v^{2} R^{2}\\\\\n\tNow, J^{2}&=m^{2} 2 G M R=2 G M m^{2} R\\\\\n\t(Given that v^{2}&=\\frac{2 G M}{R} )\\\\\n\tE&=\\frac{2 G M m^{2} R}{2 m R^{2}}-\\frac{G M m}{R}=\\frac{G M m}{R}-\\frac{G M m}{R}=0\t\n\t\\end{align*}\n\t$\\text { For Kepler's potential, if energy is zero, then the shape is parabola. }$\\\\\n\tThe correct option is \\textbf{(c)}\n\\end{answer}\n\n\\end{enumerate}", "meta": {"hexsha": "4fd605c0f8216b701bc7e4d9ee82131101b9acec", "size": 20217, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Classical Mechanics  -CSIR/chapter/central force motion solutions.tex", "max_stars_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_stars_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Classical Mechanics  -CSIR/chapter/central force motion solutions.tex", "max_issues_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_issues_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Classical Mechanics  -CSIR/chapter/central force motion solutions.tex", "max_forks_repo_name": "archives-futuring/CSIR-Physics-Study-Material", "max_forks_repo_head_hexsha": "689cff91895fec36b4bb0add178f13a0f68648ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.5739795918, "max_line_length": 483, "alphanum_fraction": 0.6139882277, "num_tokens": 8486, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.4001761066514151}}
{"text": "\\documentclass[12pt]{article}\n\\input{physics1}\n\\begin{document}\n\n\\section*{NYU Physics I---ideal gas law}\n\nHere we investigate the statistical properties of a large number of\nfree particles in a box.\nImagine you have $N$ particles, each of mass $m$, in a box of volume $V$.\nFor definiteness, imagine that the box is a cube of side length $\\ell$.\nWork with a partner and make sure you both agree on each part and understand\nwhy at each stage. This is an introduction to statistical mechanics.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nJust for kicks, imagine that \\emph{half} of the particles are moving\nat speed $+v$ in the $x$-direction, and half are moving at speed $-v$\nin the $x$-direction. When the particles hit the box walls, they\nbounce elastically off them. How many particles per unit time, on\naverage, hit the wall that is perpendicular to the $x$ direction?\nMake sure you have a good, simple argument, and that your answer is\ndimensionally correct.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nIf each particle bounces elastically and normally off the wall (that\nis, there is no frictional force at the wall), then how much momentum\nis delivered by the wall at each individual-particle impact? That is,\nwhat is the impulse of each impact?\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nIf the average force is the average of momentum provided per unit\ntime, what is the mean force provided by the ``gas'' of particles to\nthe wall, and what is the mean pressure (force per area)? Do you see\nwhy there is a mean force? If not, argue it out.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nNow imagine that each particle has not the same velocity, but some\nmean squared velocity $\\bar{v_x^2}$ in the $x$-direction. What is the\nmean pressure in terms of the mean squared velocity?\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nIn high school, did you learn that $P\\,V = n\\,R\\,T$? What were the\nunits of $P$, $V$, $P\\,V$, $n$, $R$, $T$, and $n\\,R\\,T$?\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nIn statistical mechanics, the equation is $P\\,V = N\\,k\\,T$, where $N$\nis the number of molecules, and $k$ is the Boltzmann constant. What is\nthe ratio $R/k$, both conceptually and numerically?\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nSpace is three-dimensional, so the mean squared three-space\nvelocity can be written in terms of one-dimensional means $\\bar{v^2} =\n\\bar{v_x^2} + \\bar{v_y^2} + \\bar{v_z^2}$. If the gas of particles is\nisotropic, these three contributions to the mean velocity magnitude\nought to all be equal, or three times the mean-squared $x$ component.\nRelate the pressure you got above to the mean-squred three-space velocity,\nand also the mean kinetic energy per molecule $(1/2)\\,m\\,\\bar{v^2}$.\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nRearrange your equation into the form $P\\,V=\\mbox{something}$. How can\nyou define $T$ in terms of the per-particle kinetic energy to make the\nstatistical mechanics equation $P\\,V = N\\,k\\,T$ true? Do you have any\ncomments to make?\n\n\\paragraph{\\theproblem}\\refstepcounter{problem}%\nLook up equipartition on the web and comment on the relationship\nbetween what you got and what you expect from your web reading. Any\ncomments on the derivation above?\n\n\\end{document}\n", "meta": {"hexsha": "4b8df6d64601819c3a283aacaf004438e35ab138", "size": 3269, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/worksheet_idealgas.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/worksheet_idealgas.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/worksheet_idealgas.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7, "max_line_length": 76, "alphanum_fraction": 0.7586417865, "num_tokens": 894, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.4001761066514151}}
{"text": "\\documentclass[\r\n  xhtml,%\r\n  use filename%\r\n]{internet}\r\n%\\usepackage{fancyvrb}\r\n%\\usepackage[scale=.8]{geometry}\r\n\\usepackage{tutorial}\r\n\\usepackage{hyperref}\r\n\r\n\\newtheorem{question}{Question}\r\n\r\n\\title{What's Your Angle?}\r\n\r\n\\begin{document}\r\n\\maketitle\r\n\\section{Introducing Logo}\r\n\r\n\\ \\verb+Logo+ is a computer programming language built around giving instructions to a \\emph{turtle} (can be either robotic or virtual).\r\nYou tell the turtle where to move, and as it moves then it draws a line to show its path.\r\nThe instructions are given as if telling the turtle where to go next.\r\nSo you might say ``Go forward \\(50\\) steps'' or ``Turn left \\(30^\\circ\\)''.\r\nUsing these, and similar, commands you can get the turtle to draw quite intricate patterns.\r\n\r\nThere are a few other commands relating to the line that it draws.\r\nYou can change the colour and width of the line.\r\nYou can tell it to skip a section of the line.\r\nIn some implementations, you can tell it to \\emph{fill} a shape that it has drawn (that isn't a feature of this version but you can find online \\verb+Logo+ implementations to play with).\r\n\r\n\\section{Moving Your Turtle}\r\n\r\n\\begin{enumerate}\r\n\\item Go to \\href{http://luacanvas.mathforge.org?project=Turtle}{http://luacanvas.mathforge.org?project=Turtle}\r\n\\item To make the turtle draw something, you give it the instructions inside the \\verb+setup+ function.\r\nIt will then draw what you tell it when you run the code.\r\n\r\nYour turtle is called just \\verb+turtle+.\r\nIf you want to change its name, replace the lowercase \\verb+turtle+ in the line \\verb+turtle = Turtle()+ with your chosen name.\r\nYou can only use letters, and you can't use spaces (but capital letters are fine).\r\nSo \\verb+Fred = Turtle()+ is okay.\r\nIf you change the name, you have to use that name exactly as you originally wrote it.\r\nIn this tutorial, we will assume that we haven't changed the name.\r\n\r\nThe commands are:\r\n\\begin{itemize}\r\n\\item To make the turtle go forwards, \\verb+turtle:forward(30)+.\r\n\r\nNote the colon, \\verb+:+, between the \\verb+turtle+ and \\verb+forward+.\r\nThe number, in this case \\(30\\), tells it how much to go forwards.\r\nThe units are pixels (the tiny dots) on the screen.\r\n\r\nThe number can be negative, but \\dots\r\n\r\n\\item To make the turtle go backwards, \\verb+turtle:backward(30)+.\r\n\r\n\\item To turn the turtle to its left, \\verb+turtle:left(30)+.\r\n\r\nThe key here is that the turn is from the point of view of the turtle.\r\nIt will turn to its left by \\(30^\\circ\\).\r\n\r\nThe number can be negative, but \\dots\r\n\r\n\\item To turn the turtle to its right, \\verb+turtle:right(30)+.\r\n\r\n\\item To stop it drawing, use \\verb+turtle:penUp()+.\r\n\r\nNote the parentheses at the end.\r\nThis means that when the turtle moves it will not leave a trail behind it.\r\n\r\n\\item To resume drawing, use \\verb+turtle:penDown()+.\r\n\r\n\\item To change the colour, use \\verb+turtle:setPenColour(127,245,200)+ or \\verb+turtle:setPenColour(\"blue\")+.\r\n\r\nFor more on how to specify a colour, see the \\href{Style.xhtml}{Programming with Style} tutorial in the \\emph{Programming} section of the tutorials.\r\n\r\n\\item To change the width, use \\verb+turtle:setPenWidth(3)+.\r\n\r\n\\end{itemize}\r\n\r\n\\item Put some commands in the code to see what happens.\r\nFor example, so that the start of your code looks like this:\r\n\r\n\\begin{verbatim}\r\nfunction setup()\r\n  turtle = Turtle()\r\n  turtle:forward(100)\r\n  turtle:right(60)\r\n  turtle:forward(30)\r\n  turtle:left(100)\r\n  turtle:forward(50)\r\n  protractor = Protractor()\r\n  ruler = Ruler()\r\nend\r\n\\end{verbatim}\r\n\r\n\\item When you run this code, the ``turtle'' will draw the lines you have told it to.\r\nYou will notice two other shapes on the screen (you may have noticed them in the code) which look a bit like a protractor and a ruler.\r\nThey are.\r\nYou can drag them around the screen and turn them to make measurements to plan your drawing.\r\nThey aren't labelled, but the marks are \\(5^\\circ\\) on the protractor and \\(5\\) pixels on the ruler.\r\nTo move them, click near the middle of the shape and drag it.\r\nTo rotate them, click near the outside of the shape and drag it round.\r\n\r\n\\end{enumerate}\r\n\r\n\\section{A Regular Shape}\r\n\r\nIn a regular shape, all the sides have the same length and all the angles are the same.\r\nYou can easily make the turtle draw a regular shape by alternating a turn of a fixed angle with a forward of a fixed distance.\r\nWritten out in full, this would have a lot of repetition and would be tedious to change to make a new shape.\r\nSo we use a \\emph{loop} to make it more concise.\r\n\r\nTo repeat something a set number of times, we put it in a \\verb+for+ loop, like this:\r\n\r\n\\begin{verbatim}\r\nfor k=1,4 do\r\n  turtle:forward(100)\r\n  turtle:turn(50)\r\nend\r\n\\end{verbatim}\r\n\r\nThis repeats the instructions a total of \\(4\\) times.\r\nThe start of your code should look like this:\r\n\r\n\\begin{verbatim}\r\nfunction setup()\r\n  turtle = Turtle()\r\n  for k = 1,4 do\r\n    turtle:forward(100)\r\n    turtle:right(50)\r\n  end\r\n  protractor = Protractor()\r\n  ruler = Ruler()\r\nend\r\n\\end{verbatim}\r\n\r\n\r\nThis shape doesn't join up.\r\nThe first goal is to find an angle and a number of repetitions that do make a closed, simple shape.\r\n``Closed'' means that the lines join up, ``simple'' means that the lines don't cross each other.\r\n\r\nBy changing the \\verb+4+ in the line \\verb+for k=1,4 do+ then we change the number of repetitions.\r\nChanging the \\verb+50+ changes the angle.\r\nIf your drawing is too big for the screen, change the \\verb+100+ to something smaller.\r\n\r\nOnce you have found an angle and a number of repetitions that works, make sure that your number of repetitions is \\emph{minimal}.\r\nThat means that if you reduce the number of repetitions further then the shape will no longer close up.\r\nIt will also mean that the turtle ends up at exactly the same place and in the same direction as it started.\r\n\r\n\\begin{question}\r\nWhat is the relationship between the number of repetitions and the angle that the turtle turns each time?\r\n\r\nFind some other angles and number of repetitions that also draw closed, simple shapes.\r\n\r\nWhat is the general relationship?\r\n\\end{question}\r\n\r\n\\begin{question}\r\nWhat happens if we no longer insist that the shape be \\emph{simple}?\r\nSo we allow the lines to cross existing lines, but the turtle must end up back where it started and facing the same way as it started.\r\n\\end{question}\r\n\r\n\\section{Irregular Shapes}\r\n\r\nIn an irregular shape, we no longer insist that the angles and side lengths be the same.\r\nLet us, though, insist that the shape be still a closed, simple shape.\r\n\r\nDraw a closed, simple shape that only involves \\emph{left} turns (i.e., left turns with a positive angle).\r\n\r\nTo draw your shape, start with a few instructions with turns and forwards, then run your code to see where your turtle ends up.\r\nKeep adding some more instructions and running your code to see what happens.\r\nYou may find it useful to use the ruler and protractor, particularly when figuring out the last ``joining up'' line.\r\n\r\n\\begin{question}\r\nWhat do you spot about the angles that you turn?\r\n\r\n\\end{question}\r\n\r\n\\emph{Hint: what do you get if you add them up?}\r\n\r\n\\begin{question}\r\nNow include some right turns as well (but keep the shape simple: no intersections).\r\nWhat do you notice about the angles now?\r\n\\end{question}\r\n\r\n\\emph{Hint: treat the left and right turns separately.}\r\n\r\n\\section{Spirals}\r\n\r\nThere are some additional drawing commands that can be used to make nice spirals.\r\n\r\n\\begin{itemize}\r\n\\item \\verb+turtle:toPosition(20,30)+ moves the turtle to the coordinate \\((20,30)\\) (with origin in the centre of the screen).\r\nIf the turtle's pen is down, a line will be drawn as it moves.\r\n\r\n\\item \\verb+turtle:toRelativePosition(20,30)+ moves the turtle to the\r\ncoordinate \\((20,30)\\) relative to its current position.\r\nThat is, it moves it \\(20\\) pixels across and \\(30\\) up.\r\n\r\n\\item \\verb+turtle:toAngle(50)+ turns the turtle so that it makes an angle of \\(50^\\circ\\) from the horizontal, measured anticlockwise.\r\n\r\n\\item \\verb+turtle:toRelativeAngle(50)+ turns the turtle so that it makes an angle of \\(50^\\circ\\) from the line joining it to its original position at the centre of the screen.\r\n\\end{itemize}\r\n\r\nHere are some spirals to get you started.\r\nPick one and make some changes to the code to experiment with.\r\n\r\n\\begin{enumerate}\r\n\r\n\\item You can get a nice spiral with the following instructions:\r\n\r\n\\begin{verbatim}\r\nturtle:penUp()\r\nturtle:toPosition(10,0)\r\nturtle:penDown()\r\nfor k = 1,100 do\r\n  turtle:forward(10)\r\n  turtle:toRelativeAngle(90)\r\nend\r\n\\end{verbatim}\r\n\r\n\\item The \\emph{Fibonacci Sequence} leads to a nice spiral:\r\n\r\n\\begin{verbatim}\r\nlocal a,b = 5,5\r\nturtle:right(135)\r\nfor k=1,10 do\r\n  turtle:forward(a)\r\n  turtle:left(90)\r\n  a,b = b,a+b\r\nend\r\n\\end{verbatim}\r\n\r\n\\item Spirals can go inwards as well as outwards:\r\n\r\n\\begin{verbatim}\r\nlocal s = 100\r\nfor k=1,30 do\r\n  turtle:forward(s)\r\n  turtle:left(60)\r\n  s = .9*s\r\nend\r\n\\end{verbatim}\r\n\\end{enumerate}\r\n\r\n\\end{document}\r\n", "meta": {"hexsha": "82077d490acc54a8e8974395503ac1da55351ed6", "size": 8958, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Turtle.tex", "max_stars_repo_name": "loopspace/jsCanvas-Tutorials", "max_stars_repo_head_hexsha": "7bff26820a9fd3aa3b5abcb7584dd3ca37577054", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Turtle.tex", "max_issues_repo_name": "loopspace/jsCanvas-Tutorials", "max_issues_repo_head_hexsha": "7bff26820a9fd3aa3b5abcb7584dd3ca37577054", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Turtle.tex", "max_forks_repo_name": "loopspace/jsCanvas-Tutorials", "max_forks_repo_head_hexsha": "7bff26820a9fd3aa3b5abcb7584dd3ca37577054", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4146341463, "max_line_length": 187, "alphanum_fraction": 0.7286224604, "num_tokens": 2246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4001761003820186}}
{"text": "\\documentclass[12pt]{article}\n\\usepackage[pdftex]{graphicx}\n\\begin{document}\n\\newcounter{problem}\n\\thispagestyle{empty}\n\n\\section*{NYU General Physics 1---Problem set 2}\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nWhat is the mean acceleration $a$ of a dragster (that is, a\ndrag-racing automobile) that can travel 0.25~mi in 5.5~s, starting\nfrom a dead stop?  Assume that the dragster accelerates with constant\nacceleration throughout the 5.5~s (not a terrible assumption, but not\na good one either).  Give your answer in terms of the gravitational\nacceleration $g$.  Does your answer seem reasonable?  What do you\npredict, under the constant-acceleration assumption, for the final\nspeed $v_\\mathrm{f}$ of the dragster as it crosses the finish line?\nConvert your answer to $\\mathrm{mi\\,h^{-1}}$.  Search the web for the\ncurrent world-record quarter-mile drag-race time and final speed.\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nFor the time interval $0<t<1~\\mathrm{s}$, draw graphs of the vertical\nposition $y$ (height) as a function of time, the vertical velocity\n$v_y$ as a function of time, and the vertical acceleration $a_y$ as a\nfunction of time of a rock that is thrown precisely upwards at\n$3~\\mathrm{m\\,s^{-1}}$ at time $t=0$.  For definiteness, set\n$|\\vec{g}|=10~\\mathrm{m\\,s^{-2}}$ and make the ``upwards'' direction the\npositive-$y$ direction.  Where does the rock ``end up'' at the end of\nthe $1~\\mathrm{s}$ period; that is, what is $y(1\\,\\mathrm{s})$?\nAssume that the rock is large and dense enough that we can ignore air\nresistance.\n\n\\paragraph{Problem~\\theproblem:}\\refstepcounter{problem}%\nBelow is a graph of velocity $v_x$ in the $x$ direction as a function\nof time $t$.  Draw the corresponding graph of position $x$ \\textit{vs} time $t$ and\nacceleration $a_x$ \\textit{vs} time $t$.  Be very careful with the transitions and the\nvertical scales.\\\\\n\\includegraphics{../py/vx_vs_t.pdf}\n\n\\end{document}\n", "meta": {"hexsha": "7a13ed6f04707d44b21033f0f402959926e83430", "size": 1951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/gp1_ps02.tex", "max_stars_repo_name": "davidwhogg/Physics1", "max_stars_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-11-13T03:48:56.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-13T03:48:56.000Z", "max_issues_repo_path": "tex/gp1_ps02.tex", "max_issues_repo_name": "davidwhogg/Physics1", "max_issues_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 29, "max_issues_repo_issues_event_min_datetime": "2016-10-07T19:48:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-29T22:47:25.000Z", "max_forks_repo_path": "tex/gp1_ps02.tex", "max_forks_repo_name": "davidwhogg/Physics1", "max_forks_repo_head_hexsha": "6723ce2a5088f17b13d3cd6b64c24f67b70e3bda", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.5853658537, "max_line_length": 86, "alphanum_fraction": 0.7473090723, "num_tokens": 577, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.4001760941126219}}
{"text": "\\newif\\ifPDF\n\\ifx\\pdfoutput\\undefined\\PDFfalse\n\\else\\ifnum\\pdfoutput > 0\\PDFtrue\n\t\\else\\PDFfalse\n\t\\fi\n\\fi\n\n\\ifPDF\n\t\\documentclass[pdftex,10pt]{article}\n\t\\RequirePackage[hyperindex,colorlinks,plainpages=false]{hyperref}\n\t\\hypersetup{pdfauthor={Heng Li},linkcolor=blue,citecolor=blue,urlcolor=blue}\n\t\\usepackage{graphicx}\n\t\\DeclareGraphicsRule{*}{mps}{*}{}\n\\else\n\t\\documentclass[10pt]{article}\n\t\\usepackage{graphicx}\n\\fi\n\n\\usepackage{amsmath}\n\\usepackage{amsthm}\n\n\\addtolength{\\textwidth}{3cm}\n\\addtolength{\\hoffset}{-1.5cm}\n\\addtolength{\\textheight}{4cm}\n\\addtolength{\\voffset}{-2cm}\n\n\\makeindex\n\n\\usepackage{natbib}\n\\bibliographystyle{apalike}\n\n\\title{The Pairwise Sequentially Markovian Coalescent Model}\n\\author{Heng Li and Richard Durbin}\n\\date{24 January 2008}\n\n\\begin{document}\n\n\\theoremstyle{plain} \\newtheorem{lem}{Lemma}\n\\theoremstyle{plain} \\newtheorem{thm}{Theorem}\n\\theoremstyle{plain} \\newtheorem{cor}{Corollary}\n\\theoremstyle{remark} \\newtheorem{rem}{Remark}\n\n\\maketitle\n\nThis document gives the mathematical basis for the PSMC, including all\nnecessary theorems and equations, with discussion. Lemma~\\ref{lem:f1}\nand~\\ref{lem:sd} give two general facts which will be used\nlater. Theorem~\\ref{thm:psmc} proves several central results of the\ncontinuous-time PSMC model. This theorem establishes the foundation of\nthe whole PSMC theory. Corollary~\\ref{cor:djp} and\nRemark~\\ref{rem:mutprob} show how to calculate or approximate various\nprobabilities when time is discretized. Remark~\\ref{rem:hmm} presents\nthe construction of HMM, and Remark~\\ref{rem:missdata} and\n\\ref{rem:overfit} explain several catches in\nimplementation. Remarks~\\ref{rem:bootstrap}-\\ref{rem:gof2} show methods\non estimating the variance and testing the goodness of fit (GOF).\n\n\\section{PSMC: The Pairwise Sequentially Markovian Model}\n\n\\subsection{General Fomulae}\n\nThis section presents two lemmas for general functions. Lemma~\\ref{lem:f1}\nwill be used to prove the normalization of the conditioned transition probability in the PSMC continuous-time Markov chain; Lemma~\\ref{lem:sd}\nwill be used to derive the stationary distribution of coalescent time.\n\n\\begin{lem}\\label{lem:f1}\nGiven\n\\begin{equation}\\label{equ:f}\n  f(t|s)=h(t)\\int_0^{\\min\\{s,t\\}}\\frac{g(u)}{\\int_0^sg(w)\\,dw} \\cdot e^{-\\int_u^th(v)\\,dv}\\,du\n\\end{equation}\nwhere $g(t)$ and $h(t)$ are any functions that can be integrated on $[0,\\infty)$, the\nfollowing equation always stands:\n\\[\\int_0^{\\infty}f(t|s)\\,dt=1\\]\n\\end{lem}\n\n\\begin{proof}\nLet:\n\\[t=\\phi(\\tilde t)\\]\nand\n\\[\\tilde g(\\tilde u)=\\frac{g(\\phi(\\tilde u))}{h(\\phi(\\tilde u))}\\]\nwhere $\\phi(\\tilde t)$ satisfies $\\phi(0)=0$ and\n\\[\\phi'(\\tilde u)\\cdot h(\\phi(\\tilde u))=1\\]\nThe integral becomes:\n\\[f(t|s)\\,dt=\\frac{f(\\phi(\\tilde t)|\\phi(\\tilde s))}{h(\\phi(\\tilde t))}\\,d\\tilde t\n=\\frac{\\int_0^{\\min\\{\\tilde s,\\tilde t\\}}\\tilde g(\\tilde u)e^{-(\\tilde t-\\tilde u)}d\\tilde u}\n{\\int_0^{\\tilde s}\\tilde g(\\tilde u)d\\tilde u}\\,d\\tilde t\\]\nIf we note that for any $g(t)$ that can be integrated:\n\\begin{eqnarray*}\n  &&\\int_0^{\\infty}e^{-v}dv\\int_0^{\\min\\{v,t\\}}g(u)e^u\\,du\\\\\n  &=&\\int_0^tg(u)e^udu\\Bigg(\\int_u^te^{-v}dv+\\int_t^{\\infty}e^{-v}dv\\Bigg)\\\\\n  &=&\\int_0^tg(u)\\,du\n\\end{eqnarray*}\nalways stands, we get:\n\\[\\int_0^{\\infty}f(t|s)\\,dt=\\int_0^{\\infty}\\frac{\\int_0^{\\min\\{\\tilde s,\\tilde t\\}}\\tilde g(\\tilde u)e^{-(\\tilde t-\\tilde u)}d\\tilde u}\n{\\int_0^{\\tilde s}\\tilde g(\\tilde u)d\\tilde u}\\,d\\tilde t=1\\]\n\\end{proof}\n\n\\begin{lem}[Stationary distribution]\\label{lem:sd}\n  Let:\n  \\begin{equation}\\label{equ:pi}\n    \\pi(t)=\\frac{h(t)}{C}e^{-\\int_0^th(v)dv}\\int_0^tg(u)\\,du\n  \\end{equation}\n  where $C$ is a scaling constant:\n  \\begin{equation}\n    C=\\int_0^{\\infty}g(u)e^{-\\int_0^uh(v)dv}\\,du\n  \\end{equation}\n  The following equations always stand:\n  \\begin{equation*}\n    \\int_0^{\\infty}f(t|s)\\pi(s)\\,ds=\\pi(t)\n  \\end{equation*}\n  \\begin{equation*}\n    \\int_0^{\\infty}\\pi(t)\\,dt=1\n  \\end{equation*}\n\\end{lem}\n\n\\begin{proof}\n\\begin{eqnarray*}\n&&\\int_0^{\\infty}f(t|s)\\pi(s)\\,ds\\\\\n&=&\\frac{h(t)}{C}\\int_0^{\\infty}\\frac{ds}{\\int_0^sg(w)\\,dw}\\cdot\n\\Bigg[h(s)e^{-\\int_0^sh(v)dv}\\int_0^sg(w)\\,dw\\bigg]\n\\int_0^{\\min\\{s,t\\}}g(u)\\,e^{-\\int_u^th(v)dv}\\,du\\\\\n&=&\\frac{h(t)}{C}\\int_0^{\\infty}h(s)e^{-\\int_0^sh(v)dv}ds\n\\int_0^{\\min\\{s,t\\}}g(u)\\,e^{-\\int_u^th(v)dv}\\,du\\\\\n&=&\\frac{h(t)}{C}\\int_0^tg(u)\\,e^{-\\int_u^th(v)dv}\\,du\n\\int_u^{\\infty}e^{-\\int_0^sh(v)dv}h(s)\\,ds\\\\\n&=&\\frac{h(t)}{C}\\int_0^tg(u)\\,e^{-\\int_u^th(v)dv}\\,du\\int_u^{\\infty}\nd\\,\\Big[-e^{-\\int_0^sh(v)\\,dv}\\Big]\\\\\n&=&\\frac{h(t)}{C}\\int_0^tg(u)\\,e^{-\\int_u^th(v)dv}\\,e^{-\\int_0^uh(v)dv}\\,du\\\\\n&=&\\frac{h(t)}{C}e^{-\\int_0^th(v)dv}\\int_0^tg(u)\\,du\n\\end{eqnarray*}\ni.e.:\n$$\\int_0^{\\infty}f(t|s)\\pi(s)\\,ds=\\pi(t)$$\nThen $\\pi(t)$ is the density of the stationary distribution. Furthermore, as we require that\n\\begin{eqnarray*}\n1&=&\\int_0^{\\infty}\\pi(t)\\,dt\\\\\n&=&\\int_0^{\\infty}\\frac{h(t)}{C}e^{-\\int_0^th(v)dv}\\,dt\\int_0^tg(u)\\,du\\\\\n&=&\\int_0^{\\infty}g(u)\\,du\\int_u^{\\infty}\\frac{h(t)}{C}e^{-\\int_0^th(v)dv}\\,dt\\\\\n&=&\\frac{1}{C}\\int_0^{\\infty}g(u)\\,du\\int_u^{\\infty}d\\,\n\\Big[-e^{-\\int_0^th(v)\\,dv}\\Big]\\\\\n&=&\\frac{1}{C}\\int_0^{\\infty}g(u)e^{-\\int_0^uh(v)dv}\\,du\n\\end{eqnarray*}\nthe constant $C$ can thus be calculated.\n\\end{proof}\n\n\\subsection{List of Symbols}\n\\begin{center}\n\\begin{tabular}{lll}\n\\hline\nSymbol & Type & Meaning \\\\\n\\hline\n$a,b$ & discrete & Coordinate on the sequence\\\\\n$t,s,\\Delta$ & continuous & Coalescent time \\\\\n$T_a$ & continuous, r.v. & Coalescent time at $a$ \\\\\n$R_a$ & binary, r.v. & Recombination or not between $a$ and $a+1$ \\\\\n$X_a$ & binary, r.v. & Mutation or not at $a$ \\\\\n$N,N_0$ & continuous & Population size \\\\\n$\\lambda,\\lambda_0$ & continuous & Relative population size \\\\\n$\\theta,\\theta_0$ & continuous & Per-site mutation rate \\\\\n$\\rho,\\rho_0$ & continuous & Per-site recombination rate \\\\\n$p,q$ & function & transition probability \\\\\n$i,j,k,l$ & discrete & State of the HMM \\\\\n$u,v,w$ & continuous & Coalescent time (in integration) \\\\\n$C,C_{\\pi},C_{\\sigma}$ & continous & Scaling constant \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\\subsection{PSMC Model}\n\nIn this section, Theorem~\\ref{thm:psmc} estabilishes the foundation of\nthe PSMC continuous-time Markov chain. It gives the equations of transition,\nand the stationary distribution. The following corollaries\nshow how to approximate the constants in the Theorem when the scaled mutation\nand recombination rates are small.\n\nThe discrete-time Markov chain, which will be presented in the next section,\nis derived from the continuous-time Markov chain by integrating probability desities\nin time intervals.\n\n\\begin{thm}[PSMC]\\label{thm:psmc}\n  Let the population size be:\n  \\begin{equation*}\n    N(t)=N_0\\lambda(t)\n  \\end{equation*}\n  where $t$ equals the number of generations divided by $2N_0$. The\n  scaled mutation rate and recombination rate per nucleotide are\n  $\\theta$ and $\\rho$.  respectively. Given two haplotypes, let $T_a$ be\n  the coalescent time at position $a\\in[1,L]$, and define:\n  \\begin{equation*}\n    R_a=\\left\\{\\begin{array}{ll}\n        1 & \\mbox{a recombination happens between $a$ and $a+1$} \\\\\n        0 & \\mbox{otherwise}\n      \\end{array}\\right.\n  \\end{equation*}\n  \\begin{equation*}\n    \\Lambda(t)=\\int_0^t\\lambda(u)\\,du\n  \\end{equation*}\n  \\begin{equation}\n    C_{\\pi}=\\int_0^{\\infty}e^{-\\int_0^u\\frac{dv}{\\lambda(v)}}\\,du\n  \\end{equation}\n  \\begin{equation}\n    C_{\\sigma}=\\int_0^{\\infty}\\frac{\\pi(t)}{1-e^{-\\rho t}}dt\n  \\end{equation}\n  According to the SMC (Sequentially Markov Coalescent)\n  model~\\citep{McVean:2005lr,Marjoram:2006fk}, the following equations stand:\n  \\begin{equation}\\label{equ:q}\n    q(t|s)\\,dt=\\Pr\\{T_{a+1}=t|T_a=s,R_a=1\\}\n    =\\frac{dt}{\\lambda(t)}\\int_0^{\\min\\{s,t\\}}\\frac{1}{s}\\cdot e^{-\\int_u^t\\frac{dv}{\\lambda(v)}}\\,du\n  \\end{equation}\n  \\begin{equation}\\label{equ:pi2}\n    \\pi(t)=\\Pr\\{T_{a+1}=t|R_a=1\\}=\\frac{t}{C_{\\pi}\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\n  \\end{equation}\n  \\begin{equation}\\label{equ:a}\n    p(t|s)=\\Pr\\{T_{a+1}=t|T_a=s\\}=(1-e^{-\\rho s})q(t|s) + e^{-\\rho s}\\delta(t-s)\n  \\end{equation}\n  \\begin{equation}\\label{equ:sigma1}\n    \\sigma(t)=\\Pr\\{T_a=t\\}=\\frac{\\pi(t)}{C_{\\sigma}(1-e^{-\\rho t})}\n  \\end{equation}\n  \\begin{equation}\\label{equ:px}\n    \\Pr\\{R_a=1\\}=\\frac{1}{C_{\\sigma}}\n  \\end{equation}\n  Furthermore,\n  \\begin{equation}\\label{equ:pi3}\n    \\int_0^{\\infty}q(t|s)\\pi(s)\\,ds=\\pi(t)\n  \\end{equation}\n  \\begin{equation}\\label{equ:sigma2}\n    \\int_0^{\\infty}p(t|s)\\sigma(s)\\,ds=\\sigma(t)\n  \\end{equation}\n  and\n  \\begin{equation}\n    \\int_0^{\\infty}q(t|s)\\,dt=\\int_0^{\\infty}p(t|s)\\,dt=\\int_0^{\\infty}\\pi(t)\\,dt\n    =\\int_0^{\\infty}\\sigma(t)\\,dt=1\n  \\end{equation}\n\\end{thm}\n\n\\begin{proof}\n  Equation~\\ref{equ:q} is the root of all the other equations.\n\n  \\begin{enumerate}\n\n  \\item When a recombination happens, the probability that it happens in $[u,u+du)$ is:\n  \\[P_1(u|s)\\,du=\\frac{1}{s}\\,du\\]\n  At time $u$, two alleles coalesce at $[t,t+dt)$ is~\\citep{Hein:2005yq,Griffiths:1994fk}:\n  \\[P_2(t|u)\\,dt=\\frac{1}{\\lambda(t)}\\exp\\Bigg\\{-\\int_u^t\\frac{dv}{\\lambda(v)}\\Bigg\\}\\,dt\\]\n  When we know $s$ and $t$, $u\\in[0,\\min\\{s,t\\})$. Then:\n  \\[q(t|s)=\\int_0^{\\min\\{s,t\\}}P_2(t|u)\\cdot P_1(u|s)\\,du\n  =\\frac{1}{\\lambda(t)}\\int_0^{\\min\\{s,t\\}}\\frac{1}{s}\n  \\cdot e^{-\\int_u^t\\frac{dv}{\\lambda(v)}}\\,du\\]\n  This proves Equation~\\ref{equ:q}.\n  \n  \\item In Lemma~\\ref{lem:f1} and Lemma~\\ref{lem:sd}, let $g(u)=1$ and\n  $h(u)=1/\\lambda(u)$. We have:\n  \\[\\int_0^{\\infty}q(t|s)\\,dt=1\\]\n  \\[\\int_0^{\\infty}q(t|s)\\pi(s)\\,ds=\\pi(t)\\]\n  This proves Equation~\\ref{equ:pi2} and~\\ref{equ:pi3}.\n\n  \\item Equation~\\ref{equ:a} comes \\emph{naturally}, and\n    \\[ \\int_0^{\\infty}p(t|s)=(1-e^{-\\rho s})\\int_0^{\\infty}q(t|s)\\,dt + e^{-\\rho s}=1 \\]\n  \\begin{eqnarray*}\n    \\int_0^{\\infty}p(t|s)\\sigma(s)\\,ds&=&\\frac{1}{C_a}\\int_0^{\\infty}(1-e^{-\\rho s})\n    \\frac{q(t|s)\\pi(s)}{1-e^{-\\rho s}}\\,ds\n    +\\frac{e^{-\\rho t}}{C_{\\sigma}(1-e^{-\\rho t})}\\pi(t)\\\\\n    &=&\\frac{\\pi(t)}{C_{\\sigma}(1-e^{-\\rho t})}\\\\\n    &=&\\sigma(t)\n  \\end{eqnarray*}\n  This proves Equation~\\ref{equ:sigma1} and~\\ref{equ:sigma2}.\n\n  \\item Given coalescent time $T_a=t$, the probability that a\n  recombination happens between $a$ and $a+1$ is:\n  \\begin{equation*}\n    \\Pr\\{R_a=1|T_a=t\\}=1-e^{-\\rho t}\n  \\end{equation*}\n  Then\n  \\[\\Pr\\{R_a=1\\}=\\int_0^{\\infty}(1-e^{-\\rho t})\\sigma(t)\\,dt=\\frac{1}{C_{\\sigma}}\\]\n  This proves Equation~\\ref{equ:px}.\n\n  \\end{enumerate}\n\\end{proof}\n\n\\begin{cor}[Approximating $C_{\\sigma}$]\\label{cor:sigma}\n  When $\\rho_0$ is sufficiently small:\n  \\begin{equation}\n    C_{\\sigma}=\\frac{1}{C_{\\pi}\\rho}+\\frac{1}{2}+o(\\rho)\n  \\end{equation}\n\\end{cor}\n\\begin{proof}\n  \\begin{eqnarray*}\n  C_{\\sigma}&=&\\int_0^{\\infty}\\frac{t}{C_{\\pi}\\lambda(t)[1-e^{-\\rho t}]}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}\\rho}\\int_0^{\\infty}\\Big[1+\\frac{\\rho t}{2}+o(\\rho^2)\\Big]\n  \\frac{1}{\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}\\rho}\\int_0^{\\infty}\\frac{1}{\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\n  +\\frac{1}{2}\\int_0^{\\infty}\\pi(t)\\,dt+o(\\rho)\\\\\n  &=&\\frac{1}{C_{\\pi}\\rho}+\\frac{1}{2}+o(\\rho)\n  \\end{eqnarray*}\n\\end{proof}\n\n\\begin{cor}[Rate of pairwise difference]\\label{cor:theta}\n  When both $\\theta_0$ and $\\rho_0$ are sufficiently small:\n  \\begin{equation}\\label{equ:theta}\n    \\Pr\\{X_a=1\\}=C_{\\pi}\\theta\\cdot\\big[1+o(\\rho+\\theta)\\big]\n  \\end{equation}\n\\end{cor}\n\\begin{proof}\n  \\begin{eqnarray*}\n    \\Pr\\{X_a=1\\}&=&\\int_0^{\\infty}\\Pr\\{X_a=1|T_a=t\\}\\Pr\\{T_a=t\\}\\,dt\\\\\n    &=&\\int_0^{\\infty}(1-e^{-\\theta t})\\sigma(t)\\,dt\\\\\n    &=&\\frac{1}{C_{\\sigma}}\\int\\frac{1-e^{-\\theta t}}{1-e^{-\\rho t}}\\pi(t)\\,dt\\\\\n    &=&\\frac{1}{C_{\\sigma}}\\int\\frac{\\theta+o(\\theta^2)}{\\rho+o(\\rho^2)}\\pi(t)\\,dt\\\\\n    &=&\\frac{\\theta}{C_{\\sigma}\\rho}\\int\\Big[1+o(\\rho+\\theta)\\Big]\\pi(t)\\,dt\\\\\n    &=&C_{\\pi}\\theta\\cdot\\big[1+o(\\rho+\\theta)\\big]\n  \\end{eqnarray*}\n\\end{proof}\n\n\\begin{cor}[First-order approximation]\n  Under the first-order approximation with respect to $\\theta$ and\n  $\\rho$, the following equations stand:\n  \\[\n  \\Pr\\{R_a=1\\}=\\frac{1}{C_{\\pi}}=C_{\\pi}\\rho\n  \\]\n  \\[\n  \\Pr\\{X_a=1\\}=C_{\\pi}\\theta\n  \\]\n  \\[\n  \\sigma(t)=\\frac{1}{\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\n  \\]\n  \\[\n  \\int_0^t\\sigma(u)\\,du=1-e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\n  \\]\n\\end{cor}\n\n\\begin{rem}[Distribution of segment lengths]\\label{cor:seglen}\n  Let $L_{a+1}$ be the length of the segment following a recombination\n  occurring at $a$. Conditional on the recombination, $L_{a+1}$ follows\n  a exponential distribution (more precisely, a geometric distribution\n  in fact):\n  \\[\n  \\Pr\\{L_{a+1}=l|R_a=1,T_{a+1}=t\\}\\,dl = \\rho te^{-\\rho tl}\\,dl\n  \\]\n  Then,\n  \\[\n  \\Pr\\{L=l\\}\\,dl=dl\\int_0^{\\infty}\\frac{\\rho t^2e^{-\\rho tl}}{C_{\\pi}\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\n  =dl\\,\\frac{\\rho}{C_{\\pi}}\\int_0^{\\infty}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,d\\Big(t^2e^{-\\rho tl}\\Big)\n  \\]\n  The mean segment length is thus\n  \\begin{eqnarray*}\n  &&\\int_0^{\\infty}\\rho tl e^{-\\rho tl}\\,dl\\int_0^{\\infty}\\frac{t}{C_{\\pi}\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}\\rho}\\int_0^{\\infty}\\frac{1}{\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}\\rho}\\approx C_{\\sigma}\n  \\end{eqnarray*}\n\\end{rem}\n\n%\\begin{cor}[PSMC']\\label{cor:psmc2}\n%  According to SMC', the following equation stands:\n%  \\begin{eqnarray*}\n%    q'(t|s)\\,dt&=&\\Pr\\{T_{a+1}=t|T_a=s,R_a=1\\}\\\\\n%    &=&\\frac{1}{2}\\delta(t-s)\\Bigg[1-\\int_0^s\\frac{\\lambda(u)\\,du}{\\int_0^s\\lambda(w)\\,dw}\n%    e^{-\\int_u^s\\frac{2\\,dv}{\\lambda(v)}}\\Bigg]\\\\\n%    &&+\\frac{dt}{\\lambda(t)}\\int_0^{\\min\\{s,t\\}}\\frac{\\lambda(u)\\,du}{\\int_0^s\\lambda(w)\\,dw}\n%    \\cdot e^{-\\int_u^{\\min\\{s,t\\}}\\frac{dv}{\\lambda(v)}-\\int_u^t\\frac{dv}{\\lambda(v)}}\n%  \\end{eqnarray*}\n%\\end{cor}\n%\\begin{proof}\n%  At time $u$, there are three alleles $1$, $2$ and $3$. Allele $1$\n%  coalesces with $2$ at time $[s,s+ds)$. If $2$ and $3$ coalesce at\n%  $[t,t+dt)$, the probability is:\n%  \\begin{eqnarray*}\n%    &&\\frac{1}{3}\\cdot3\\cdot\\frac{1}{\\lambda(t)}e^{-\\int_u^t\\frac{3\\,dv}{\\lambda(v)}}\\cdot\\frac{1}{\\lambda(s)}\n%    e^{-\\int_t^s\\frac{dv}{\\lambda(v)}}\\,dtds\\\\\n%    &=&\\frac{1}{\\lambda(t)}e^{-\\int_u^t\\frac{2\\,dv}{\\lambda(v)}}\\cdot\\frac{1}{\\lambda(s)}\n%    e^{-\\int_u^s\\frac{dv}{\\lambda(v)}}\\,dtds\n%  \\end{eqnarray*}\n%  If $1$ and $2$ coalesce first and then coalesce with $3$ at $[t,t+dt)$,\n%  the probability is:\n%  \\begin{eqnarray*}\n%    &&\\frac{1}{3}\\cdot3\\cdot\\frac{1}{\\lambda(s)}e^{-\\int_u^s\\frac{3\\,dv}{\\lambda(dv)}}\\cdot\\frac{1}{\\lambda(t)}\n%    e^{-\\int_s^t\\frac{dv}{\\lambda(v)}}\\,dtds\\\\\n%    &=&\\frac{1}{\\lambda(t)}e^{-\\int_u^s\\frac{2\\,dv}{\\lambda(v)}}\\cdot\\frac{1}{\\lambda(s)}\n%    e^{-\\int_u^t\\frac{dv}{\\lambda(v)}}\\,dtds\n%  \\end{eqnarray*}\n%  Condition on $s$ and $3$ coalesces with $1$ or above, we have:\n%  \\begin{equation*}\n%    P'_2(t|u)\\,dt=\\frac{dt}{\\lambda(t)}e^{-\\int_u^{\\min\\{s,t\\}}\\frac{dv}{\\lambda(v)}-\\int_u^t\\frac{dv}{\\lambda(v)}}\n%  \\end{equation*}\n%\n%  If a recombination happens, the probability that it happens at\n%  $[u,u+du)$ is:\n%  \\[P_1(u|s)\\,du=\\frac{\\lambda(u)}{\\int_0^s\\lambda(w)\\,dw}\\,du\\]\n%  Then the probability that $3$ coalesces with $2$ under $s$ is:\n%  \\begin{equation*}\n%    \\int_0^s\\,dt\\int_0^tP'_2(t|u)P_1(u|s)\\,du=\\int_0^s\\frac{dt}{\\lambda(t)}\\int_0^t\n%    e^{-\\int_u^t\\frac{2\\,dv}{\\lambda(v)}}\\frac{\\lambda(u)\\,du}{\\int_0^s\\lambda(w)\\,dw}\n%    =\\frac{1}{2}\\Bigg[1-\\int_0^s\\frac{\\lambda(u)\\,du}{\\int_0^s\\lambda(w)\\,dw}e^{-\\int_u^s\\frac{2\\,dv}{\\lambda(v)}}\\Bigg]\n%  \\end{equation*}\n%\\end{proof}\n%\n%\\begin{rem}\n%  Due to the theoretical complication, Corollary~\\ref{cor:psmc2} is not\n%  used in practice.\n%\\end{rem}\n\n\\subsection{Discrete-Time PSMC Model}\n\nThis section presents the discrete-time PSMC Markov Chain, its transition probabilities\nbetween time intervals and the stationary distribution. The proof of Corolary~\\ref{cor:djp}\nis given in the Appendix.\n\n\\begin{cor}[Discrete-time PSMC]\\label{cor:djp}\n  Let\n  \\[ 0=t_0<t_1<\\cdots<t_n<t_{n+1}=\\infty \\]\n  Assume in each time interval $[t_k,t_{k+1})$ function $\\lambda(t)$ is a\n  constant $\\lambda_k$. Define:\n  \\begin{equation*}\n    \\pi_k=\\int_{t_k}^{t_{k+1}}\\pi(t)\\,dt\n  \\end{equation*}\n  \\begin{equation*}\n    \\sigma_k=\\int_{t_k}^{t_{k+1}}\\sigma(t)\\,dt\n  \\end{equation*}\n  \\begin{equation*}\n    q_{kl}=\\frac{1}{\\pi_k}\\int_{t_k}^{t_{k+1}}ds\\int_{t_l}^{t_{l+1}}q(t|s)\\pi(s)\\,dt\n  \\end{equation*}\n  \\begin{equation*}\n    p_{kl}=\\frac{1}{\\sigma_k}\\int_{t_k}^{t_{k+1}}ds\\int_{t_l}^{t_{l+1}}p(t|s)\\sigma(s)\\,dt\n  \\end{equation*}\n  Then:\n  \\begin{equation*}\n    \\pi_k=\\frac{1}{C_{\\pi}}\\Bigg[(\\alpha_k-\\alpha_{k+1})\\Big(\\sum_{i=0}^{k-1}\\tau_i+\\lambda_k\\Big)\n    -\\alpha_{k+1}\\tau_k\\Bigg]\n  \\end{equation*}\n  \\begin{equation}\\label{equ:sigmak}\n    \\sigma_k=\\frac{1}{C_{\\sigma}}\n    \\Bigg[\\frac{1}{C_{\\pi}\\rho}(\\alpha_k-\\alpha_{k+1})+\\frac{\\pi_k}{2}+o(\\rho)\\Bigg]\n  \\end{equation}\n  Furthermore, for $l<k$:\n  \\begin{equation*}\n    q_{kl}=\\frac{\\alpha_k-\\alpha_{k+1}}{C_{\\pi}\\pi_k}\\Bigg[(\\alpha_l-\\alpha_{l+1})\\Big(\\beta_l-\\frac{\\lambda_l}{\\alpha_l}\\Big)\n    +(t_{l+1}-t_l)\\Bigg]\n  \\end{equation*}\n  for $l=k$:\n  \\begin{equation*}\n    q_{kl}=\\frac{1}{C_{\\pi}\\pi_k}\\Bigg[(\\alpha_k-\\alpha_{k+1})^2\\Big(\\beta_k-\\frac{\\lambda_k}{\\alpha_k}\\Big)\n    +2\\lambda_k(\\alpha_k-\\alpha_{k+1})-2\\alpha_{k+1}(t_{k+1}-t_k)\\Bigg]\n  \\end{equation*}\n  and for $l>k$:\n  \\begin{equation*}\n    q_{kl}=\\frac{\\alpha_l-\\alpha_{l+1}}{C_{\\pi}\\pi_k}\n  \\Bigg[(\\alpha_k-\\alpha_{k+1})\\Big(\\beta_k-\\frac{\\lambda_k}{\\alpha_k}\\Big)+(t_{k+1}-t_k)\\Bigg]\n  \\end{equation*}\n  and\n  \\begin{equation}\\label{equ:pkl}\n    p_{kl}=\\frac{\\pi_k}{C_{\\sigma}\\sigma_k}q_{kl} + \\delta_{kl}\\Big(1-\\frac{\\pi_k}{C_{\\sigma}\\sigma_k}\\Big)\n  \\end{equation}\n  where:\n  \\begin{equation*}\n    \\tau_k = t_{k+1}-t_k\n  \\end{equation*}\n  \\begin{equation*}\n    \\alpha_k=\\exp\\Bigg(-\\sum_{i=0}^{k-1}\\frac{t_{i+1}-t_i}{\\lambda_i}\\Bigg)\n  \\end{equation*}\n  \\begin{equation*}\n    \\beta_k=\\sum_{i=0}^{k-1}\\lambda_i\\Big(\\frac{1}{\\alpha_{i+1}}-\\frac{1}{\\alpha_i}\\Big)\n  \\end{equation*}\n  \\begin{equation*}\n    C_{\\pi}=\\sum_{k=0}^n\\lambda_k(\\alpha_k-\\alpha_{k+1})\n  \\end{equation*}\n\\end{cor}\n\n\\begin{rem}[Mutation probability]\\label{rem:mutprob}\n  The average mutation probability in an interval $[t_k,t_{k+1})$ cannot\n  be analytically calculated. But we can seek another way. From\n  Equation~\\ref{equ:pkl}, a recombination occurs in $[t_k,t_{k+1})$ as if\n  it occurs at time\n  $-\\log\\Big[1-\\pi_k/(C_{\\sigma}\\sigma_k)\\Big]/\\rho$. If we assume\n  mutation also exactly occurs at this time point, the probability of a\n  mutation is:\n  \\begin{equation}\\label{equ:ek1}\n    e_k(1) = \\exp\\Bigg[-\\frac{\\theta}{\\rho}\\log\\Big(1-\\frac{\\pi_k}{C_{\\sigma}\\sigma_k}\\Big)\\Bigg]\n    = \\Big(1-\\frac{\\pi_k}{C_{\\sigma}\\sigma_k}\\Big)^{\\theta/\\rho}\n  \\end{equation}\n\\end{rem}\n\n\\begin{rem}[Determining $N_0$]\\label{rem:n0}\n  If we know $\\mu$, the neutral mutation rate, $N_0=\\theta/4\\mu$. On\n  autosomes, $\\mu$ is typically\n  $2.5\\times10^{-8}$~\\citep{Nachman:2000rq}. Note that\n  Equation~\\ref{equ:theta} agrees with~\\citet{Marth:2004vn} in case of\n  two haplotypes.\n\\end{rem}\n\n\\section{PSMC Hidden Markov Model}\n\n\\subsection{The basic of HMM}\n\n\\begin{rem}[PSMC-HMM]\\label{rem:hmm}\n  We denote a hidden state in the HMM by $k$, which means a coalescence\n  between the two haplotypes at this point in the sequence lies in the\n  time interval $[t_k,t_{k+1})$. A mutation is emmitted with a\n  probability $e_k(1)$ (Equation~\\ref{equ:ek1}) and the transition\n  probability is $p_{kl}$ (Equation~\\ref{equ:pkl}). The stationary\n  distribution of the hidden states is $\\{\\sigma_k\\}$\n  (Equation~\\ref{equ:sigmak}). All these parameters can be analytically\n  approximated with a precision of order-two Taylor expansion when\n  $\\rho_0$ is sufficiently small.\n\\end{rem}\n\n%\\begin{rem}[PSMC-PHMM]\\label{rem:phmm}\n%  It is possible to use PSMC to approximately model two diploid\n%  sequences. In this case, a hidden state is $(k,l)$ and the transition\n%  probability of $(k,l)\\to(k',l')$ is $p_{kk'}p_{ll'}$. The stationary\n%  distribution of hidden states is $\\{\\sigma_k\\sigma_{k'}\\}$.\n%\\end{rem}\n\n\\begin{rem}[Missing data]\\label{rem:missdata}\n  Missing data can be easily incorporated into an HMM. When there is no\n  observation at $a$, $e_k(x_a)=1$ for all $k$.\n\\end{rem}\n\n\\begin{rem}[Choosing time intervals]\n  We choose a set of $\\{t_i\\}_{i=0\\ldots n}$ that are approximately\n  evenly distributed in the log space, but because we require $t_0=0$,\n  the intervals will not strictly evenly distributed. In practice, we\n  set \\[t_i=0.1(e^{\\frac{i}{n}\\log(1+10T_{max})}-1)\\] where\n  $T_{max}=t_n$ is chosen such that no more than a few percent of\n  coalescences occur beyond $T_{max}$.\n\\end{rem}\n\n\\begin{rem}[Reducing parameters]\\label{rem:overfit}\n  In principle, we can estimate all the $n+1$ values of $\\lambda_k$ with\n  EM. However, at both small and large $t$, the expected number of\n  segments is very small. Separate estimates of $\\lambda_k$ in these\n  intervals will lead to overfitting due to insufficient data. An\n  effective way to tell whether overfitting occurs is to check\n  $C_{\\sigma}\\pi_k$, the expected number of segments in the interval\n  $[t_k,t_{k+1})$. If this number is small (less than $20$, for\n  instance), the $\\lambda_k$ estimated from EM cannot be trusted due to\n  statistical fluctuations. In this case, we should use fewer free\n  parameters by using the same $\\lambda$ spanning several adjacent\n  intervals. This will lower the resolution but will yield much better\n  estimation.\n\\end{rem}\n\n\\subsection{Assessing variance and fitness}\n\n\\begin{rem}[Bootstrapping]\\label{rem:bootstrap}\n  The variance can be estimated by boostrapping. We split the input\n  diploid sequence into $L'$-long non-overlapping segments and randomly\n  resample the segments with replacement to generate a new diploid\n  sequence of the same length as the original one.  Parameters are then\n  estimated from the new sequence. We repeat this process $B$ times and\n  regard the variance of the $B$ resampled estimates as the variance of\n  the estimate on the original sequence. Typically, we take\n  $L'=30,000,000$ and $B=100$.\n\\end{rem}\n\n\\begin{rem}[Measuring GOF with $\\sigma_k$]\\label{rem:gof-pi}\n  On one hand, from Equation~\\ref{equ:sigmak} we can calculate\n  $\\sigma_k$ from free parameters of the model without looking at the\n  data. On the other hand, from forward-backward algorithm we can\n  estimate the posterior expectation of the occurences $\\hat{c}_k$\n  of state $k$:\n  \\begin{equation*}\n    \\hat{c}_k=\\frac{1}{P(D)}\\sum_if_k(i)b_k(i)\n  \\end{equation*}\n  Normalizing $\\hat{c}_k$ gives:\n  \\begin{equation*}\n    \\hat{\\sigma}_k=\\frac{\\sum_if_k(i)b_k(i)}{\\sum_{k,i}f_k(i)b_k(i)}\n  \\end{equation*}  \n  where $f_k(i)$ is the forward function of sequence position $i$ and\n  state $k$ and $b_k(i)$ is the backward function. If the model fits the\n  data, we would expect to see $\\{\\hat{\\sigma}_k\\}$ is identical to\n  $\\{\\sigma_k\\}$. And therefore the relative entroy\n  $D(\\sigma||\\hat{\\sigma})$ would be an indicator of GOF:\n  \\begin{equation*}\n    G^{\\sigma}=\\sum_k\\sigma_k\\log\\frac{\\sigma_k}{\\hat{\\sigma}_k}\n  \\end{equation*}\n\\end{rem}\n\n\\begin{rem}[Measuring GOF with $l$-long subsequences]\\label{rem:gof2}\n  \\citet{MacKay-Altman:2004lr} pointed out we can test GOF by comparing\n  the distribution of $l$-long subsequences from direct calculation with\n  the observed distribution. Given an integer $n\\in[0,2^l-1]$, let\n  $\\{p_n\\}$ be the theoretical distribution of the binary sequence\n  represented by $n$ and let $\\{\\hat{p}_n\\}$ be the one directly counted\n  from the observed sequence. The relative entroy between them is:\n  \\begin{equation*}\n    G_l=\\sum_{n=0}^{2^l-1}p_n\\log\\frac{p_n}{\\hat{p}_n}\n  \\end{equation*}\n  which measures GOF. Typically, $l$ is ranged from 10 to 20.\n\\end{rem}\n\n\\appendix\n\n\\section{Proof of Corollary~\\ref{cor:djp}}\\label{sec:pfl1}\n\n\\begin{proof}\n\n\\[\n  C_{\\pi}=\\int_0^{\\infty}e^{-\\int_0^u\\frac{dv}{\\lambda(v)}}\\,du\n=\\sum_{k=0}^{n}\\alpha_k\\int_{t_k}^{t_{k+1}} e^{-\\frac{u-t_k}{\\lambda_k}}du\n=\\sum_{k=0}^n\\lambda_k(\\alpha_k-\\alpha_{k+1})\n\\]\n\n\\begin{eqnarray*}\n  \\pi_k&=&\\int_{t_k}^{t_{k+1}}\\pi(t)\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}}\\int_{t_k}^{t_{k+1}}\\frac{dt}{\\lambda(t)}e^{-\\int_0^t\\frac{dv}{\\lambda(v)}}\\cdot t\\\\\n  &=&\\frac{1}{C_{\\pi}\\lambda_k}\\int_{t_k}^{t_{k+1}}\\alpha_k e^{-\\frac{t-t_k}{\\lambda_k}}\\Bigg[\\sum_{i=0}^{k-1}\\tau_i\n  +(t-t_k)\\Bigg]\\,dt\\\\\n  &=&\\frac{\\alpha_k}{C_{\\pi}\\lambda_k}\\Bigg[\\sum_{i=0}^{k-1}\\tau_i\\int_{t_k}^{t_{k+1}}e^{-\\frac{t-t_k}{\\lambda_k}}dt\n  +\\int_{t_k}^{t_{k+1}}(t-t_k)e^{-\\frac{t-t_k}{\\lambda_k}}dt\\Bigg]\\\\\n  &=&\\frac{\\alpha_k}{C_{\\pi}\\lambda_k}\\Bigg[\\lambda_k\\sum_{i=0}^{k-1}\\tau_i\\Big(1-e^{-\\frac{\\tau_k}{\\lambda_k}}\\Big)\n  +\\lambda_k^2\\int_0^{\\frac{\\tau_k}{\\lambda_k}}ue^{-u}du\\Bigg]\\\\\n  &=&\\frac{\\alpha_k}{C_{\\pi}}\\Bigg[\\sum_{i=0}^{k-1}\\tau_i\\Big(1-e^{-\\frac{\\tau_k}{\\lambda_k}}\\Big)\n  +\\Big(\\lambda_k-\\lambda_k e^{-\\frac{\\tau_k}{\\lambda_k}}-\\tau_k e^{-\\frac{\\tau_k}{\\lambda_k}}\\Big)\\Bigg]\\\\\n  &=&\\frac{1}{C_{\\pi}}\\Bigg[(\\alpha_k-\\alpha_{k+1})\\Big(\\sum_{i=0}^{k-1}\\tau_i+\\lambda_k\\Big)\n  -\\alpha_{k+1}\\tau_k\\Bigg]\n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n  \\sigma_k&=&\\int_{t_k}^{t_{k+1}}\\sigma(t)\\,dt\\\\\n  &=&\\int_{t_k}^{t_{k+1}}\\frac{1}{C_{\\sigma}(1-e^{-\\rho t})}\\cdot\\frac{t}{C_{\\pi}\\lambda(t)}\n  e^{\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\sigma}C_{\\pi}\\rho}\\int_{t_k}^{t_{k+1}}\\Big[1+\\frac{1}{2}\\rho t+o(\\rho^2)\\Big]\n  \\frac{1}{\\lambda(t)}e^{\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\\\\\n  &=&\\frac{1}{C_{\\sigma}C_{\\pi}\\rho}\\Bigg[\\int_{t_k}^{t_{k+1}}\\frac{1}{\\lambda(t)}e^{\\int_0^t\\frac{dv}{\\lambda(v)}}\\,dt\n  +\\frac{1}{2}C_{\\pi}\\rho\\int_{t_k}^{t_{k+1}}\\pi(t)\\,dt+o(\\rho^2)\\Bigg]\\\\\n  &=&\\frac{1}{C_{\\sigma}}\\Bigg[\\frac{1}{C_{\\pi}\\rho}(\\alpha_k-\\alpha_{k+1})\n  +\\frac{\\pi_k}{2}+o(\\rho)\\Bigg]\n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n  q_{kl}&=&\\frac{1}{\\pi_k}\\int_{t_k}^{t_{k+1}}ds\\int_{t_l}^{t_{l+1}}q(t|s)\\pi(s)\\,dt\\\\\n  &=&\\frac{1}{C_{\\pi}\\pi_k}\\int_{t_k}^{t_{k+1}}\\frac{1}{\\lambda(s)}e^{-\\int_0^s\\frac{dv}{\\lambda(v)}}\\,ds\n  \\int_{t_l}^{t_{l+1}}\\frac{dt}{\\lambda(t)}\\int_0^{\\min\\{s,t\\}}e^{-\\int_{u}^{t}\\frac{dw}{\\lambda(w)}}du\\\\\n  &=&\\frac{\\alpha_k}{C_{\\pi}\\pi_k\\lambda_k\\lambda_l}\\int_{t_k}^{t_{k+1}}e^{-\\frac{s-t_k}{\\lambda_k}}\\,ds\n  \\int_{t_l}^{t_{l+1}}dt\\int_0^{\\min\\{s,t\\}}e^{-\\int_{u}^{t}\\frac{dw}{\\lambda(w)}}du\n\\end{eqnarray*}\n\n$l<k$:\n\\begin{eqnarray*}\n  q_{kl} &=&\\frac{\\alpha_k-\\alpha_{k+1}}{C_{\\pi}\\pi_k\\lambda_l}\n  \\int_{t_l}^{t_{l+1}}dt\\,\\Bigg(e^{-\\frac{t-t_l}{\\lambda_l}}\\sum_{i=0}^{l-1}\\frac{\\alpha_l}{\\alpha_i}\n  \\int_{t_i}^{t_{i+1}}e^{\\frac{u-t_i}{\\lambda_i}}\\,du+\\int_{t_l}^{t}e^{-\\frac{t-u}{\\lambda_l}}\\,du\\Bigg)\\\\\n  &=&\\frac{\\alpha_k-\\alpha_{k+1}}{C_{\\pi}\\pi_k\\lambda_l}\n  \\int_{t_l}^{t_{l+1}}dt\\,\\Bigg[\\alpha_le^{-\\frac{t-t_l}{\\lambda_l}}\\sum_{i=0}^{l-1}\\lambda_i\n  \\Big(\\frac{1}{\\alpha_{i+1}}-\\frac{1}{\\alpha_i}\\Big)+\\lambda_l\\Big(1-e^{-\\frac{t-t_l}{\\lambda_l}}\\Big)\\Bigg]\\\\\n  &=&\\frac{\\alpha_k-\\alpha_{k+1}}{C_{\\pi}\\pi_k}\n  \\Big[\\Big(1-\\frac{\\alpha_{l+1}}{\\alpha_l}\\Big)\\beta_l\\alpha_l+(t_{l+1}-t_l)-\\lambda_l\n  \\Big(1-\\frac{\\alpha_{l+1}}{\\alpha_l}\\Big)\\Big]\\\\\n  &=&\\frac{\\alpha_k-\\alpha_{k+1}}{C_{\\pi}\\pi_k}\\Bigg[(\\alpha_l-\\alpha_{l+1})\\Big(\\beta_l-\\frac{\\lambda_l}{\\alpha_l}\\Big)\n  +(t_{l+1}-t_l)\\Bigg]\n\\end{eqnarray*}\n\n$l>k$:\n\\begin{eqnarray*}\n  q_{kl}&=&\\frac{\\alpha_k}{C_{\\pi}\\pi_k\\lambda_k}\\int_{t_k}^{t_{k+1}}e^{-\\frac{s-t_k}{\\lambda_k}}\\,ds\\cdot\n  (\\alpha_l-\\alpha_{l+1})\\Bigg[\\beta_k+\\frac{\\lambda_k^2}{\\alpha_k}\\Big(e^{\\frac{s-t_k}{\\lambda_k}}-1\\Big)\\Bigg]\\\\\n  &=&\\frac{\\alpha_k(\\alpha_l-\\alpha_{l+1})}{C_{\\pi}\\pi_k\\lambda_k}\\int_{t_k}^{t_{k+1}}e^{-\\frac{s-t_k}{\\lambda_k}}\\,ds\\cdot\n  \\Bigg[\\Big(\\beta_k-\\frac{\\lambda_k}{\\alpha_k}\\Big)+\\frac{\\lambda_k}{\\alpha_k}e^{\\frac{s-t_k}{\\lambda_k}}\\Bigg]\\\\\n  &=&\\frac{\\alpha_l-\\alpha_{l+1}}{C_{\\pi}\\pi_k}\n  \\Bigg[(\\alpha_k-\\alpha_{k+1})\\Big(\\beta_k-\\frac{\\lambda_k}{\\alpha_k}\\Big)+(t_{k+1}-t_k)\\Bigg]\n\\end{eqnarray*}\n\n$l=k$:\n\\begin{eqnarray*}\n  q_{kl}&=&\\frac{\\alpha_k}{C_{\\pi}\\pi_k\\lambda_k}\\int_{t_k}^{t_{k+1}}e^{-\\frac{s-t_k}{\\lambda_k}}\\,ds\\cdot\n  \\Bigg[\\beta_k(\\alpha_k-\\alpha_{k+1})+(s-t_k)-\\frac{\\lambda_k\\alpha_{k+1}}{\\alpha_k}\n  \\Big(e^{\\frac{s-t_k}{\\lambda_k}}-1\\Big)\\Bigg]\\\\\n  &=&\\frac{\\alpha_k}{C_{\\pi}\\pi_k}\\int_0^{\\tau_k}e^{-u}\\,du\\cdot\n  \\Bigg[\\beta_k(\\alpha_k-\\alpha_{k+1})+\\frac{\\lambda_k\\alpha_{k+1}}{\\alpha_k}\n\t+\\lambda_ku-\\frac{\\lambda_k\\alpha_{k+1}}{\\alpha_k}e^u\\Bigg]\\\\\n  &=&\\frac{1}{C_{\\pi}\\pi_k}\\Bigg[\\beta_k(\\alpha_k-\\alpha_{k+1})^2\n  +\\frac{\\lambda_k}{\\alpha_k}(\\alpha_k-\\alpha_{k+1})(\\alpha_k+\\alpha_{k+1})-2\\tau_k\\alpha_{k+1}\\Bigg]\\\\\n  &=&\\frac{1}{C_{\\pi}\\pi_k}\\Bigg[(\\alpha_k-\\alpha_{k+1})^2\\Big(\\beta_k-\\frac{\\lambda_k}{\\alpha_k}\\Big)\n  +2\\lambda_k(\\alpha_k-\\alpha_{k+1})-2\\alpha_{k+1}(t_{k+1}-t_k)\\Bigg]\n\\end{eqnarray*}\n\n\\begin{eqnarray*}\n  p_{kl}&=&\\frac{1}{\\sigma_k}\\int_{t_k}^{t_{k+1}}ds\\int_{t_l}^{t_{l+1}}p(t|s)\\sigma(s)\\,dt\\\\\n  &=&\\frac{1}{\\sigma_k}\\int_{t_k}^{t_{k+1}}\\frac{\\pi(s)\\,ds}{C_{\\sigma}(1-e^{-\\rho s})}\n  \\Bigg[\\int_{t_l}^{t_{l+1}}(1-e^{-\\rho s})q(t|s)\\,dt+\\delta_{kl}e^{-\\rho s}\\Bigg]\\\\\n  &=&\\frac{1}{C_{\\sigma}\\sigma_k}\\int_{t_k}^{t_{k+1}}\\pi(s)\\,ds\\int_{t_l}^{t_{l+1}}q(t|s)\\,dt\n  +\\frac{\\delta_{kl}}{C_{\\sigma}\\sigma_k}\\int_{t_k}^{t_{k+1}}\\Big(\\frac{1}{1-e^{-\\rho s}}-1\\Big)\\pi(s)\\,ds\\\\\n  &=&\\frac{\\pi_kq_{kl}}{C_{\\sigma}\\sigma_k}+\\frac{\\delta_{kl}}{C_{\\sigma}\\sigma_k}\n  \\Bigg[\\int_{t_k}^{t_{k+1}}\\frac{\\pi(s)\\,ds}{1-e^{-\\rho s}}-\\pi_k\\Bigg]\\\\\n  &=&\\frac{\\pi_k q_{kl}}{C_{\\sigma}\\sigma_k}+\\delta_{kl}\\Big(1-\\frac{\\pi_k}{C_{\\sigma}\\sigma_k}\\Big)\n\\end{eqnarray*}\n\n\\end{proof}\n\n\\bibliography{psmc}\n\n\\end{document}\n", "meta": {"hexsha": "50317f8b03b9f7fbab6c5af0b8cfa4f45e13aeec", "size": 29373, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "psmc.tex", "max_stars_repo_name": "ammodramus/psmc", "max_stars_repo_head_hexsha": "e5f7df5d00bb75ec603ae0beff62c0d7e37640b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 86, "max_stars_repo_stars_event_min_datetime": "2015-02-01T15:23:48.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-13T19:54:37.000Z", "max_issues_repo_path": "psmc.tex", "max_issues_repo_name": "ammodramus/psmc", "max_issues_repo_head_hexsha": "e5f7df5d00bb75ec603ae0beff62c0d7e37640b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 42, "max_issues_repo_issues_event_min_datetime": "2015-04-29T14:13:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-10T04:27:35.000Z", "max_forks_repo_path": "psmc.tex", "max_forks_repo_name": "ammodramus/psmc", "max_forks_repo_head_hexsha": "e5f7df5d00bb75ec603ae0beff62c0d7e37640b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 51, "max_forks_repo_forks_event_min_datetime": "2015-03-04T01:41:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T15:52:41.000Z", "avg_line_length": 42.4465317919, "max_line_length": 142, "alphanum_fraction": 0.6381711095, "num_tokens": 12333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.40009607889400606}}
{"text": "% !TEX root = ../main.tex\n\n\\section{Design and implementation}\n\n\\subsection{Pre-process data}\n\\begin{frame}{\\insertsubsec}\n  \\begin{itemize}\n    \\item Pre-process image data\n    \\item Pre-process scalar data\n    \\item Generate pairs for training\n  \\end{itemize}\n\n  \\vspace{.5cm}\n  Only 490 of the initial 671 could be used to fit a model because we needed the following \n  requirements:\n  \\begin{itemize}\n    \\item CT scan\n    \\item Tumour annotations\n    \\item Radiomic features\n    \\item Clinical information\n  \\end{itemize}\n\\end{frame}\n\n\\begin{frame}{Image data pre-processing}\n  \\begin{figure}\n    \\centering\n    \\scalebox{.6}{\\input{drawings/preprocess.tikz.tex}}\n    \\caption{Image data pre-processing}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Scalar data pre-processing}\n  \\begin{itemize}\n    \\item Clinical information\n    \\begin{itemize}\n      \\item Patient's ID\n      \\item Age\n      \\item Sex\n      \\item Survival event\n      \\item Survival time\n    \\end{itemize}\n    \\item Radiomic features, up to 725\n    \\begin{itemize}\n      \\item Tumour shape\n      \\item Intensity\n      \\item Volume\n      \\item ...\n    \\end{itemize}\n  \\end{itemize}\n\\end{frame}\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{images/features_original}\n    \\caption{Features before normalization}\n  \\end{figure}\n\\end{frame}\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{images/features_normalized}\n    \\caption{Features after normalization}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}{Pair generation}\n  \n  \\begin{figure}\n    \\centering\n    \\scalebox{.7}{\\input{drawings/pairs_sets.tikz.tex}}\n    \\caption{Types of pairs generated from train and test sets}\n  \\end{figure}\n\n  \\begin{block}{Conditions}\n    \\begin{itemize}\n      \\item Both of them are uncensored \\( E_A = E_B = 1 \\)\n      \\item The uncensored time of one is smaller than the censored time of the other\n            \\( T_A < T_B | E_A = 1; E_B = 0 \\)\n    \\end{itemize}\n  \\end{block}\n\\end{frame}\n\n\\subsection{Create basic siamese model}\n\\begin{frame}{\\insertsubsec}\n  Step required from a software engineering perspective. Future models should implement the \n  \\( \\operatorname{sister}(x) \\) function.\n  \\begin{figure}\n    \\scalebox{.7}{\\input{drawings/siamese_network.tikz.tex}}\n    \\caption{Siamese network illustration}\n  \\end{figure}\n\\end{frame}\n\\begin{frame}\n  \\begin{block}{Sister network}\n    \\begin{align*}\n      \\bm{O}_A &= \\operatorname{sister}(\\bm{X}_A) \\\\\n      \\bm{O}_B &= \\operatorname{sister}(\\bm{X}_B) \\\\\n      \\sigma(x) &= \\frac{1}{1 + \\exp(-x)} \\\\\n      \\hat{y} &= \\sigma(||\\bm{O}_B||_2 - ||\\bm{O}_A||_2) \n    \\end{align*}\n  \\end{block}\n\n  \\begin{block}{Loss function}\n    \\[\n      \\mathcal{L}(\\bm{y}, \\hat{\\bm{y}}) = -\\frac{1}{N} \\sum_{i = 1}^{N}\n      (1 - y_i)\\log(1 - \\hat{y}_i) + y_i\\log(\\hat{y}_i)\n    \\]\n  \\end{block}\n\n  \\begin{block}{Cost function}\n    \n    \\[\n      C(\\bm{y}, \\hat{\\bm{y}}) = \\mathcal{L}(\\bm{y}, \\hat{\\bm{y}}) + \n      ||\\bm{w}||_2\n    \\]\n  \\end{block}\n\\end{frame}\n\n\\subsection{Build volume only model}\n\\begin{frame}{\\insertsubsec}\n  Very simple model to have a baseline\n\n  \\[\n    \\operatorname{sister}(\\bm{X}) = w\\cdot X_{\\text{scalar}_{26}} + b\n  \\]\n\n  \\begin{block}{Train parameters}\n    \\begin{itemize}\n      \\item Learning rate: 0,05\n      \\item Number of epochs: 200\n      \\item Batch size: The whole dataset\n    \\end{itemize}\n  \\end{block}\n\\end{frame}\n\\begin{frame}\n  Previous state-of-the-art CI was 0,628.\n\n  \\begin{table}\n    \\centering\n    \\begin{tabular}{|c||c|c|c||c|c|c|}\n      \\cline{2-7}\n      \\multicolumn{1}{c|}{} & \\multicolumn{3}{|c||}{\\textbf{Pairs}} & \n      \\multicolumn{3}{c|}{\\textbf{Concordance Index}} \\\\\n      \\hline\n      \\textbf{Fold} & \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} \n      & \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} \\\\\n      \\hhline{=======}\n      0 & 16.359 & 46.804 & 5.330 & 0,627 & 0,634 & 0,639 \\\\\n      1 & 16.359 & 46.957 & 5.278 & 0,629 & 0,635 & 0,63 \\\\\n      2 & 16.348 & 47.577 & 5.084 & 0,636 & 0,627 & 0,661 \\\\\n      3 & 16.348 & 47.274 & 5.176 & 0,618 & 0,644 & 0,6 \\\\\n      \\hhline{=======}\n      \\textbf{Total} & 65.414 & 188.612 & 20.868 & 0,627 & 0,635 & 0,632 \\\\\n      \\hline\n    \\end{tabular}\n  \n    \\caption[Volume Only 4-CV results]{\n      Results for volume only model using 4-CV \\label{tab:results-volume-4CV}\n    }\n  \\end{table}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{images/results/c-index_volume}\n    \\caption[LOOCV volume only model results]{\n      Volume only model results using LOOCV \\label{fig:results-volume-LOOCV}\n    }\n  \\end{figure}\n  LOOCV CI is 0,627.\n\\end{frame}\n\n\\subsection{Build shallow siamese network}\n\\begin{frame}{\\insertsubsec}\n  \\begin{figure}\n    \\centering\n    \\scalebox{.7}{\\input{drawings/siamese_0.tikz.tex}}\n    \\caption{Shallow siamese sister's network illustration \\label{fig:shallow-implement}}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{itemize}\n    \\item Learning rate: 0,05\n    \\item Number of epochs: 200\n    \\item Batch size: The whole dataset\n  \\end{itemize}\n\n  \\begin{table}\n    \\centering\n    \\begin{tabular}{|c||c|c|c||c|c|c|}\n      \\cline{2-7}\n      \\multicolumn{1}{c|}{} & \\multicolumn{3}{|c||}{\\textbf{Pairs}} & \n      \\multicolumn{3}{c|}{\\textbf{Concordance Index}} \\\\\n      \\hline\n      \\textbf{Fold} & \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} & \n      \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} \\\\\n      \\hhline{=======}\n      0 & 65.436 & 187.216 & 21.320 & 0,43 & 0,42 & 0,419 \\\\\n      1 & 65.436 & 187.828 & 21.112 & 0,444 & 0,431 & 0,459 \\\\\n      2 & 65.392 & 190.308 & 20.336 & 0,472 & 0,474 & 0,426 \\\\\n      3 & 65.392 & 189.096 & 20.704 & 0,514 & 0,512 & 0,514 \\\\\n      \\hhline{=======}\n      \\textbf{Total} & 261.656 & 754.448 & 83.472 & 0,465 & 0,459 & 0,455 \\\\\n      \\hline\n    \\end{tabular}\n  \n    \\caption[Shallow 4-CV results]{\n      Results for shallow model using 4-CV \\label{tab:results-shallow-4CV}.\n    }\n  \\end{table}\n\\end{frame}\n\n\\subsection{Build scalar only siamese network}\n\\begin{frame}{\\insertsubsec}\n  \\begin{figure}\n    \\centering\n    \\input{drawings/scalar_0.tikz.tex}\n    \\caption{Scalar siamese network illustration \\label{fig:scalar-implement}}\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{itemize}\n    \\item Learning rate: 0,001\n    \\item Regularization factor: 0,01\n    \\item Dropout probability: 20\\%\n    \\item Number of epochs: 1000\n    \\item Batch size: The whole dataset\n  \\end{itemize}\n\n  \\begin{table}\n    \\centering\n    \\begin{tabular}{|c||c|c|c||c|c|c|}\n      \\cline{2-7}\n      \\multicolumn{1}{c|}{} & \\multicolumn{3}{|c||}{\\textbf{Pairs}} & \n      \\multicolumn{3}{c|}{\\textbf{Concordance Index}} \\\\\n      \\hline\n      \\textbf{Fold} & \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} & \n      \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} \\\\\n      \\hhline{=======}\n      0 & 16.359 & 46.804 & 5.330 & 0,728 & 0,915 & 0,543 \\\\\n      1 & 16.359 & 46.957 & 5.278 & 0,809 & 0,927 & 0,64 \\\\\n      2 & 16.348 & 47.577 & 5.084 & 0,751 & 0,91 & 0,675 \\\\\n      3 & 16.348 & 47.274 & 5.176 & 0,766 & 0,919 & 0,624 \\\\\n      \\hhline{=======}\n      \\textbf{Total} & 65.414 & 188.612 & 20.868 & 0,764 & 0,918 & 0,62   \\\\\n      \\hline\n    \\end{tabular}\n  \n    \\caption[Scalar Only 4-CV results]{\n      Results for scalar only model using 4-CV \\label{tab:results-scalar-4CV}\n    }\n  \\end{table}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=.8\\textwidth]{images/results/c-index_scalar}\n    \\caption[LOOCV scalar only model results]{\n      Scalar only model results using LOOCV \\label{fig:results-scalar-LOOCV}\n    }\n  \\end{figure}\n\n  Final CI is 0,771\n\\end{frame}\n\n\\subsection{Build deep siamese network}\n\\begin{frame}{\\insertsubsec}\n  \\begin{figure}\n    \\centering\n    \\scalebox{.7}{\\input{drawings/residual_general.tikz.tex}}\n    \\caption[Deep siamese network main structure]{\n      Deep siamese network main structure \\label{fig:residual-general}\n    }\n  \\end{figure}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{itemize}\n    \\item Learning rate: 0,001\n    \\item Regularization factor: 0,01\n    \\item Dropout probability: 0,2/1\n    \\item Number of epochs: 15\n    \\item Batch size: 20\n  \\end{itemize}\n\n  \\begin{table}\n    \\centering\n    \\begin{tabular}{|c||c|c|c||c|c|c|}\n      \\cline{2-7}\n      \\multicolumn{1}{c|}{} & \\multicolumn{3}{|c||}{\\textbf{Pairs}} & \n      \\multicolumn{3}{c|}{\\textbf{Concordance Index}} \\\\\n      \\hline\n      \\textbf{Fold} & \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} & \n      \\textbf{Mixed} & \\textbf{Train} & \\textbf{Test} \\\\\n      \\hhline{=======}\n      0 & 65.436 & 187.216 & 21.320 & 0,765 & 0,812 & 0,814 \\\\\n      1 & 65.436 & 187.828 & 21.112 & 0,821 & 0,813 & 0,813 \\\\\n      2 & 65.392 & 190.308 & 20.336 & 0,427 & 0,431 & 0,387 \\\\\n      3 & 65.392 & 189.096 & 20.704 & 0,389 & 0,359 & 0,428 \\\\\n      \\hhline{=======}\n      \\textbf{Total} & 261.656 & 754.448 & 83.472 & 0,601 & 0,603 & 0,614 \\\\\n      \\hline\n    \\end{tabular}\n  \n    \\caption[Residual 4-CV results]{\n      Results for residual model using 4-CV \\label{tab:results-residual-4CV}\n    }\n  \\end{table}\n\\end{frame}\n\n\\begin{frame}\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=\\textwidth]{images/results/residual_train}\n  \n    \\caption{Training iterations CI\n      \\label{fig:results-residual-CI}\n    }\n  \\end{figure}\n\\end{frame}\n\n\\subsection{Predict patient's survival}\n\n\\begin{frame}{\\insertsubsec}\n  Comparison function \\( T_A < T_B \\) gives a correct result 76,4 \\% of the time.\n  \\begin{figure}\n    \\centering\n    \\includegraphics[width=.5\\textwidth]{images/results/survival_scalar}\n  \n    \\caption{Confusion matrix for survival classification}\n  \\end{figure}\n\n  Final accuracy is 60\\% (106 / 178)\n\\end{frame}\n\n\n", "meta": {"hexsha": "3480d15cc4b279b50296134f8caef5802cef09d4", "size": 9767, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "LATEX/final_presentation/sections/03_implementation.tex", "max_stars_repo_name": "jmigual/FIB-TFG", "max_stars_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-02T15:17:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-02T15:17:51.000Z", "max_issues_repo_path": "LATEX/final_presentation/sections/03_implementation.tex", "max_issues_repo_name": "jmigual/FIB-TFG", "max_issues_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LATEX/final_presentation/sections/03_implementation.tex", "max_forks_repo_name": "jmigual/FIB-TFG", "max_forks_repo_head_hexsha": "7551a3c13a985ee7eecf7a4f38a6ee4803b05ff1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-10-23T08:11:28.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-23T08:11:28.000Z", "avg_line_length": 28.7264705882, "max_line_length": 92, "alphanum_fraction": 0.611037166, "num_tokens": 3549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4000960736106792}}
{"text": "\\section{Unit Experiments}\n\\label{text:experiments/unit}\n\n\\subsection{Goal Objective Function}\nIn Table \\ref{table:goal_horizon_weighting}, the convergence speed of both the \"unweighted\" \\ref{eq:goal_unweighted} and the \"weighted\" \\ref{eq:goal_weighted} objective formulation are compared over 100 runs in a simplified setup, with no pedestrian in the scene and random assignments of the robot's initial and goat state. Weighting the cost terms non-uniformly over the horizon enables finding \"trade-offs\" of a locally higher cost for faster global convergence, such as gaining speed in a non-goal-direction at the beginning of the horizon but leads to a smaller cost at the end of it.\n\n\\begin{table}[!ht]\n\\begin{center}\n\\begin{tabular}{c|c|c}\n\\bf Goal Objective & \\bf MSI & \\bf M95OD \\\\\n\\hline\nUn-Weighted & 9.64 & 6.64 \\\\\n\\hline\n\\rowcolor{our_color}\nWeighted & 9.58 & 5.86 \\\\\n\\end{tabular}\n\\caption{Comparison of key performance parameter of the optimization using either the \"un-weighted\" (Equation \\ref{eq:goal_unweighted}) or the \"weighted\" (Equation  \\ref{eq:goal_weighted}) goal objective formulation over 100 runs in a simplified environment setup. For further details please have a look into the example notebook: \\href{https://github.com/simon-schaefer/mantrap/blob/master/examples/module_goal.ipynb}{examples/module\\_goal}.}\n\\label{table:goal_horizon_weighting}\n\\end{center}\n\\end{table}\n\n\\subsection{Interactive Objective Function}\nNext to the interactive objective function $J_{int}(\\cdot)$, described in Section \\ref{text:approach/objective/interactive}, there are several other ways to formulate it. Instead of taking the full trajectory distribution into account for computing the distance measure between the unconditioned $\\distwo[]$ and the conditioned trajectory distribution $\\dist[]$, it can be approximated by computing the expected value over sample pairs. Consequently, the distance measure breaks down to a weighted sum over $L_2$-norms for each discrete time-step within the time horizon and for every trajectory pair, which are efficient to compute.\n\n\\begin{equation}\nD_{int}^{sp} = \\sum_{samples} \\sum_T ||\\xpedwo[s]_t - \\xped[s]_t||_2\n\\end{equation}\n\nThe samples are deterministic trajectories and can be numerically differentiated efficiently, using central difference expressions. As previously described, it might be more meaningful to compare velocity or acceleration instead of positions.\n\n\\begin{align}\nJ_{int, sa}^{k} &= \\sum_{samples} \\sum_T ||\\ddxpedwo[s]_t - \\ddxped[s]_t||_2\t \\\\\nJ_{int, sv}^{k} &= \\sum_{samples} \\sum_T ||\\dxpedwo[s]_t - \\dxped[s]_t||_2\t \\\\\nJ_{int, sp}^{k} &= \\sum_{samples} \\sum_T ||\\xpedwo[s]_t - \\xped[s]_t||_2\n\\label{eq:interaction_diff}\t\n\\end{align}\n\nAlthough quite intuitive, it turns out that a sample-wise objective is hard to optimize. This has two predominant reasons: Firstly, it intrinsically relies on a trade-off between computational feasibility (to compute many times per second for an online optimization) and capability to capture the properties of the underlying real distributions sufficiently well. Secondly, when randomly drawn samples are used, stochasticity is introduced into the objective function, which might lead to a different objective value even when evaluated with the same input. When the distribution's means are used instead, the distribution's uncertainty is disregarded.\n\\newline\nIn the following, the projection-probability-based interactive loss function in Equation \\ref{eq:objective_interact_prob} is compared against the alternative difference-based objectives, presented above in \\ref{eq:interaction_diff}. Due to the previously explained limitations instead of sampled trajectories, the mean trajectory is merely being used, thereby neglecting the prediction's variance. For the comparison, a Monte Carlo simulation is used for a set of custom defined scenarios. Due to the uncertainty evolved in the environment dynamics, the performance is evaluated over 10 test runs each. A meaningful comparison should exclude external factors as best as possible, therefore to exclude interactive effects occurring due to other parts of the optimization, other than the compared objective functions, the safety constraint is not used in this experiment. \\\\ \n\n\\begin{table}[!ht]\n\\begin{center}\n\\begin{tabular}{c|c|c|c|c|c|c}\n\\bf Interactive Objective & \\bf MPE[\\%] & \\bf RTD[\\%] & \\bf RCE[\\%] & \\bf ETT & \\bf TGD & \\bf MSD \\\\\n\\hline\ndiff\\_pos & 183 & 99 & 41 & 0.0 & 0.24 & 0.94 \\\\\n\\hline\ndiff\\_vel & 161 & 98 & 65 & 0.0 & 0.26 & 1.16 \\\\\n\\hline\ndiff\\_acc & 116 & 98 & 69 & 0.0 & 0.27 & 1.24 \\\\ \n\\hline\n\\rowcolor{baseline_color}\nwithout & 172 & 100 & 34 & 0.0 & 0.23 & 1.08 \\\\ \n\\hline\n\\rowcolor{our_color}\nprojection & 100 & 92 & 100 & 0.8 & 0.39 & 1.44 \n\\end{tabular}\n\\end{center}\n\\label{table:interactive_objective}\n\\end{table}\n\nThe experiments show the effect of the interactive objective function: It trades off the required travel time to reach the goal position with increasing the safety and \"ease\" of the interaction by reducing the pedestrian's efforts and increasing the minimum separation distance. Figure \\ref{img:interactive_comp} displays the solution trajectories for an exemplary scenario.  The projection-probability objective accomplishes to increase distance when necessary but gets on track afterward. In opposition, the alternative formulations either fail to establish a sufficient distance to the pedestrian (comp. the second or third image, associated with diff\\_pos and diff\\_vel) or cannot recover afterward as in the case for the acceleration difference objective.\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=\\textwidth]{images/inter_comp_multi.png}\n\\captionof{figure}{Example solution trajectories for different interactive objective function, beginning from the left: projection, diff\\_pos, diff\\_vel, diff\\_acc, without interactive loss function}\n\\label{img:interactive_comp}\n\\end{center}\n\\end{figure}\n\n\\subsection{HJR Safety Constraint}\nThe necessity and feasibility of approximating the \\ac{HJR} value function have been motivated in Section \\ref{text:approach/constraint/safety}. In the following several approximation methods are compared and evaluated.\n\\newline \nFigure \\ref{img:hj_approx_bar} shows the logarithmic approximation error for several pre-computed grid sizes and using linear (as in \\cite{Leung2020})) and Nearest Neighbor interpolation methods. LWPR (not shown here) has been tested as well but turned out to be infeasible for a large number of grid points.\\footnote{For more information about the implementation of the LWPR value function approximation see \\href{https://github.com/simon-schaefer/HJReachibility}{HJ-Reachability Toolbox} on GitHub.} The value function has been computed on a dense grid exactly, and point-wise compared with the grid interpolated approximations for computing the error metric. While linear interpolation widely outperforms Nearest Neighbor, as expected, the absolute error is tiny. As displayed in Figure \\ref{img:hj_approx_hist}, the interpolation error is not uniform over all joint state axes, but larger for positional axes (which likely is due to the larger amount of non-linearity in position compared to velocity directions, compare Figure \\ref{img:hj_value_function}). Therefore, the number of grid points have not been equally distributed over the axes, but biased to the positional axes (interior), while keeping the overall size of the grid constant.\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=0.45\\textwidth]{images/hj_bar_linear.png}\n\\includegraphics[width=0.45\\textwidth]{images/hj_bar_nearest.png}\n\\caption{Logarithmic value function approximation error using linear (left) and nearest neighbor (right) interpolation methods based on various pre-computed grid sizes (small < interior < medium)}\n\\label{img:hj_approx_bar}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=\\imgwidth]{images/hj_hist_linear.png}\n\\caption{Absolute error distribution over joint system state axes using linear interpolation based on various pre-computed grid sizes (small < interior < medium)}\n\\label{img:hj_approx_hist}\n\\end{center}\n\\end{figure}\n\n\\subsection{Warm-Starting Methods}\nThe warm-starting method used in the underlying work simplifies the full trajectory optimization problem to a convex and efficiently computable sub-problem. This process has been described in Section \\ref{text:approach/runtime/warm_starting}. This simplified formulation merely takes into account the goal objective as well as a physical constraint imposed by the robot, while neglecting any interaction between robot and pedestrian in the scene. It this way, not only pedestrian-target objectives are ignored, but also constraints enforcing a safe interaction. Despite being efficient to solve, it might return a solution estimate far from the real solution. For example, in the case of a densely crowded area, it might return a solution trajectory, passing very close to other pedestrians, which surely violates the safety constraints of the full formulation. Consequently, the runtime would not be reduced much, if at all. \n\\newline\nAs previously pointed out, there is no simple way of warm-starting interior-point-based methods using preceding solutions. This difficulty motivates finding other warm-starting approaches designed explicitly for crowd-navigation. In the following several other concepts for warm-starting, the underlying optimization problem is introduced and baselined against the used method. The used method, which is solving a simplified, robot-focussed optimization problem, is thereby referred to as \\ac{GFW}.\n\n\\paragraph{\\ac{SCW}} \nSCW follows a similar idea as \\ac{GFW}, which is using a simplified formulation of the full optimization problem (Problem \\ref{problem:general}) as a wart-start. \\ac{GFW}s formulation is thereby extended by the safety constraint $g_{HJR}(\\cdot)$ to guarantee that the warm-starting solution is feasible with respect to the system's safety constraint. $g_{HJR}(\\cdot)$ is by design independent from pedestrian predictions as well as, for the assumed agent dynamics, widely linear. As a result, \\ac{SCW} not only accounts for interactions and feasibility of the warm-started solution trajectory in the full problem but also is comparably efficient to solve.\n\n\\paragraph{\\ac{PCBW}}\nMerkt et alt. \\cite{Merkt2018} use nearby pre-computed trajectories to warm-start an optimization problem for controlling a 38-DoF NASA Valkyrie robot in a pick-and-place scenario. Therefore, they encrypt the given initial conditions with problem-specific descriptors, expensively compute solutions for settings distributed over the full state-space, and clusters the pre-computed scenarios using $k$-Means-Clustering. Then, online, the initial conditions are encrypted and efficiently assigned to the closest pre-computed solution with $k$-Nearest-Neighbor classification. \n\\newline\nFor the socially aware trajectory optimization problem in \\project, there are several possibilities of encrypting the initial conditions. Finding descriptive but efficient encryption is particularly hard due to the varying number of pedestrians in the scene. To avoid this issue, the internal encoding of a prediction model, such as the latent space $z$ of the Trajectron model \\cite{Ivanovic2018}, could be utilized. It is small and constant size makes it very appealing. On the contrary, using a prediction model (latent) encoding would firstly demand the prediction model to have such an encoding (which is only valid (C)\\ac{VAE}-based models in the field of pedestrian prediction). Secondly, even if the model does have such an internal encoding, there is no guarantee for it to be meaningful for the task of encrypting a given scene. As not all possible scenes can be pre-solved, it is crucial for the encryption to exhibit a spatial correlation between \"close\" scenarios, so that matching a non-pre-computed scenario to its closest (spatial) neighbors is feasible. However, the latent space of a prediction model is not guaranteed to have this property. \n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=\\imgwidth]{images/enc_latent_reg.png}\n\\caption{Latent space encoding for randomly perturbed scenarios. A multi-pedestrian scenario has been perturbed by randomly shifting the initial positions of randomly picked pedestrian in the scene by the amount displayed on the x-axis, resulting in the logarithmic $L2$-distance mapped on the y-axis. For more information please visit the warm-starting testing notebook \\href{https://github.com/simon-schaefer/mantrap/blob/master/examples/warm_start.ipynb}{warm\\_start}.}\n\\label{img:pcbw_encoding_latent}\n\\end{center}\n\\end{figure}\n\nFigure \\ref{img:pcbw_encoding_latent} illustrates the spatial distribution of the latent space of the Trajectron model. The underlying assumption of a spatial correlation between similar scenarios does not hold. For this reason, a manually-design encoding is used within this work. As previously discussed, designing an encoding for all pedestrian states, the robot and goal state is intrinsically governed by the trade-off between an ample search space and representative capabilities of the encoding. Encryption of the complete environment state increases query time and demands an exponentially larger amount of pre-computed scenarios. As some crowd-navigation works merely take into account the closest or most endangered single pedestrian, a similar idea is considered for encoding. Specifically, the scene descriptors are the local coordinates of the closest pedestrian, with respect to the robot, between it and its goal position. Using a local coordinate frame pointing from the robot's to the goal position saves encoding the goal position as well, by implicitly encoding it. Figure \\ref{img:pcbw_encoding_manual} pictures a typical scene encoding. Similarly to \\cite{Merkt2018}, the pre-computed solution trajectories are matched to the queried scene using $k$-Nearest-Neighbor classification. \n\n\\begin{figure}[!ht]\n\\begin{center}\n\\begin{tikzpicture}\n\n    \\node (R) at (0, 0)\n    {\\includegraphics[width=.04\\textwidth]{images/robot.png}};\n    \\node (G) at (8, 4)\n    {\\includegraphics[width=.04\\textwidth]{images/flag.png}};\n    \\node (P1) at (-4, 1)\n    {\\includegraphics[width=.04\\textwidth]{images/walking.png}};\n    \\node (P2) at (6, 1)\n    {\\includegraphics[width=.04\\textwidth]{images/walking.png}};\n    \\node (P3) at (2, 4)\n    {\\includegraphics[width=.04\\textwidth]{images/walking.png}};\n\n    \\draw[->, very thick] (R) to node[midway, sloped, above] {$\\eta$} (1, 0.5);\n    \\draw[->, very thick] (R) to node[midway, sloped, above] {$\\mu$} (-0.5, 1);\n    \\draw[->, dotted] (R) to node[midway, sloped, above] {$(\\eta_{P1}, \\mu_{P1})$} (P1);\n    \\draw[->, dotted] (R) to node[midway, sloped, above] {$(\\eta_{P2}, \\mu_{P2})$} (P2);\n   \t\\draw[->, dotted] (R) to node[midway, sloped, above] {$(\\eta_{P3}, \\mu_{P3})$} (P3);\n   \t\\draw[->, dotted] (R) to node[midway, sloped, above] {$(\\eta_G, 0.0)$} (G);\n    \n\\end{tikzpicture}\n\\end{center}\n\\caption{Manual encoding of robot-pedestrian scenario, with local coordinate frame $(\\eta, \\mu)$ originating in the robots position and pointing in the goal direction.}\n\\label{img:pcbw_encoding_manual}\n\\end{figure}\n\n\\paragraph{\\ac{SPMW}}\nIt is straightforward to see that the computational complexity of evaluating the interactive terms of the optimization, especially their gradients, is tightly-coupled to the complexity of the underlying prediction model. \nThus, as an example, it is effortful to compute the gradient of the interactive objective with respect to the robot's trajectory for Trajectron \\cite{Ivanovic2018}, but computationally light-weight to do so for the Social Forces environment \\cite{Helbing1995}. Following this idea, the \\ac{SPMW} method warm-starts the optimization by solving the same (full) optimization problem and using a less complicated environment. The Potential Field prediction model, as described in Section \\ref{text:exp_particles}, has been developed for warm-starting. It is worth noting that \\ac{SPMW} enables us to improve the efficiency of the optimization and take advantage of prior knowledge. Therefore, the Potential Field model has been designed so that the pedestrian is only affected by the robot when it is close to the pedestrian and in front of it. Consequently, the optimization is driven to a solution in which the robot moves behind or in the distance of each pedestrian.\n\n\\paragraph{Evaluation}\nEvaluating the performance of the exhibited warm-starting methodologies generally is hard, as for each warm-starting method a set of scenarios can be constructed, in which the resulting warm-started trajectory is very close to the optimal trajectory. As an example \\ac{GFW} works well for sparse scenarios, with few pedestrians, while \\ac{SCW} performs well, when the robot starts close to a pedestrian. However, in most cases the warm-starting methods decrease the average optimization runtime by $5-10 \\%$, while not qualitatively affecting the shape of the solution trajectory. Empirically, \\ac{SCW} seems to perform best. Automatically deciding the optimal warm-starting method for a given scenario, as e.g., by leveraging learning-based methods as in \\cite{Banerjee2020}, is left for future work.\n\n\\subsection{Attention Methods}\nSection \\ref{text:approach/runtime/filtering} has introduced the concept of attention for filtering the significant pedestrians for evaluating the interactive objective and cutting computational runtime. Next to the purposed euclidean-distance-based attention module, there are several other methodologies for this purpose, out of which two more sophisticated options will be presented in the following:\n\n\\paragraph{Forward Reachability Attention}\nForward reachability generally determines the reachable set of an agent given its dynamics and some time-horizon $T_{FR}$. In opposite to back-ward reachability (\\ac{HJR}), which has been introduced in Section \\ref{text:approach/constraint/safety}, forward reachability merely regards one agent instead of joint systems. Thereby, forward reachability deals with finding the set of all states that the agent can reach from a given set of states $\\mathcal{L}$ at time $T_{FR}$. With dynamics $\\dot{x} = f(x, u)$, the reachable set $\\mathcal{X}_{FR}$ is determined as:\n\n\\begin{equation}\n\\mathcal{X}_{FR} = \\{x_T: \\in u, \\textit{ s.t. } x(\\cdot) \\textit{ satisfies } \\dot{x} = f(x, u), x(0) \\in \\mathcal{L}; x(T_{FR}) = x_T\\}\n\\end{equation}\n \nFor single- and double-integrator dynamics, the forward reachable set $\\mathcal{X}_{FR}$ turns out to be a circle, due to their isotropy. The radius and center point, thereby, depends on the agent's initial state. Due to the ability to determine these sets analytically, the forward reachability-based attention filter is very computationally efficient to apply.\n\\newline\nConsequently, the forward reachable set attention selects the pedestrian of which the reachable sets overlap with the robot's reachable set for the planning horizon $T_{FR} = T$. If the reachable sets do not overlap, it is not possible for the robot and some pedestrian $k$ to meet within the planning horizon. Then pedestrian $k$ can safely be neglected within the optimization.\n\n\\paragraph{Proximate Attention}\nThe proximate attention module is re-using a concept, that is frequently used in game-theoretic crowd-navigation. Here, the problem is formulated as games between each robot-pedestrian-pair \\cite{Bouzat2014}\\cite{Nikolaidis2017}. Following this idea, the proximate attention module merely considers the pedestrian, which is closest to the robot (and within a pre-determined euclidean range).\n\n\\begin{equation}\n\\attention_{closest}(\\x, \\xped[k]) = \\left( ||\\x - \\xped[k]||_2 > D_{Attention} \\land \\arg \\min ||\\x - \\xped[k]||_2 \\right)\n\\end{equation}\n\n\\paragraph{Evaluation}\nTable \\ref{table:attention} and Figure \\ref{img:attention} show the results of a Monte Carlo-based evaluation, averaged over ten scenarios with 20 time-steps each. \"Without\" thereby refers to using trajectory optimization without any attention. Due to its conservative safety estimate, the reachability-based approach does not cut the computational effort since hardly a pedestrian is removed from the robot's attention. Conversely, the euclidean and proximate attention modules show very similar performance. In case of very cluttered scenarios (not shown here), the proximate attention sometimes leads to rapidly changing the related pedestrian, which might cause an \"in-constant\" robot movement. Hence, the euclidean module is the better overall choice.\n\\newline\nUsing euclidean-based attention dramatically reduces the average computational cost since the interactive objective function does not have to be evaluated with respect to all surrounding pedestrians, or not at all when no pedestrian is close to the robot. Therefore, the effect of attention on computational effort is two-fold: It decreases the average cost of objective/gradient evaluation and the number of required optimization iterations. Also, the derived trajectories do not necessarily perform worse in terms of interactive trajectory cost. \n\n\\begin{table}[!ht]\n\\begin{center}\n\\begin{tabular}{c|c|c|c|c|c|c|c}\n\\bf Attention & \\bf MPE[\\%] & \\bf RTD & \\bf RCE[\\%] & \\bf ETT & \\bf TGD & \\bf MSD & \\bf MSR \\\\\n\\hline\nproximate & 102 & 0.97 & 104 & 0.28 & 0.14 & 2.24 & 0.058 \\\\\n\\hline\nreachability & 98 & 0.98 & 113 & 0.0 & 0.13 & 2.24 & 0.68 \\\\\n\\hline\n\\rowcolor{baseline_color}\nwithout & 104 & 0.97 & 130 & 0.04 & 0.14 & 2.23 & 0.77 \\\\ \n\\hline\n\\rowcolor{our_color}\neuclidean & 100 & 0.97 & 100 & 0.28 & 0.14 & 2.22 & 0.06\n\\end{tabular}\n\\end{center}\n\\caption{Quantitative comparison of several attention filters by evaluating the performance of the underlying trajectory optimization.}\n\\label{table:attention}\n\\end{table}\n\nIn fact, filtering non-significant agents may accelerate the overall optimization by simplifying the trade-off between the interactive cost with respect to multiple pedestrians to minimizing the interactive cost of a single pedestrian. Figure \\ref{img:attention} displays such a scenario. Here, the robot chooses to wait and follow behind the green (closest) pedestrian, which is the least interventional action for this single agent. Regarding the impact the robot's action has on all pedestrians, however, it seems to be more optimal to accelerate and increase the average distance to all pedestrians as quickly as possible. Nonetheless, it turns out that the decision based on the single pedestrian is not only more computationally efficient, but also more globally (!) optimal with respect to all pedestrians (at least in this scenario). As explained in Section \\ref{text:experiments/discussion}, the purposed optimization formulation is prone to erroneous predictions; by reducing the number of pedestrians, which is taken into account, we hence also reduce the number of sources of misleading predictions.\n\n\\begin{figure}[!ht]\n\\begin{center}\n\\includegraphics[width=\\textwidth]{images/attention.png}\n\\end{center}\n\\caption{Trajectory Optimization with different attention modules. From left to right: euclidean, closest, reachability and without the use of attention. For further information please have a look at \\href{https://github.com/simon-schaefer/mantrap/blob/master/examples/attention.ipynb}{attention notebook}.}\n\\label{img:attention}\n\\end{figure}\n", "meta": {"hexsha": "fea852457b1fd8e9ec7156e8c1ff4c088ec550ef", "size": 23457, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/thesis/exp_unit.tex", "max_stars_repo_name": "simon-schaefer/mantrap", "max_stars_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-05-11T18:13:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T02:52:48.000Z", "max_issues_repo_path": "report/thesis/exp_unit.tex", "max_issues_repo_name": "StanfordASL/mantrap", "max_issues_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/thesis/exp_unit.tex", "max_forks_repo_name": "StanfordASL/mantrap", "max_forks_repo_head_hexsha": "9a2b3f32a0005cc0cb79bb78924f09da5a94587d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-12-09T00:03:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T10:39:03.000Z", "avg_line_length": 112.7740384615, "max_line_length": 1304, "alphanum_fraction": 0.7866734877, "num_tokens": 5553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.40009607361067917}}
{"text": "\\section{TEAL for RAVEN}\nA generalized module within the TEAL software (called TEAL.CashFlow) for economic analysis within RAVEN has been developed \\cite{MSApril2017}. The module is able to compute\nthe NPV (Net Present Value), the IRR (Internal Rate of Return) and the PI (Profitability Index). Furthermore, it is possible to\ndo an NPV, IRR or PI search, i.e. CashFlow will compute a multiplicative value (for example the production cost) so that the\nNPV, IRR or PI has a desired value (for details see \\ref{subsec:NPV_search}, NPV\\_search). This CashFlow module has been written using the script language Python.\nThe Python code can be used as an ``external model'' in RAVEN (for installation and usage instructions, see \\ref{sec:Installation}).\n\nThe input of \\textbf{TEAL.CashFlow} is an XML file. An example of the input structure is given in Listing \\ref{lst:InputExample}. The following section will discuss the\n different keywords in the input and describe how they are used in the \\textbf{TEAL.CashFlow} module.\n\n\\begin{lstlisting}[style=XML,morekeywords={anAttribute},caption=Economics input example., label=lst:InputExample]\n<Economics verbosity='0'>\n    <Global>\n        <Indicator name='IRR,NPV_search,NPV' target='0'>\n            Component1|Cfname1\n            Component1|Cfname2\n            ...\n        </Indicator>\n        <DiscountRate>0.08</DiscountRate>\n        <tax>0.392</tax>\n        <inflation>0.04</inflation>\n        <ProjectTime>100</ProjectTime> <!-- optional -->\n    </Global>\n\n    <Component name='Component1'>\n        <Life_time>20</Life_time>\n        <StartTime>10</StartTime> <!-- optional -->\n        <Repetitions>3</Repetitions> <!-- optional -->\n        <tax>0.3</tax> <!-- optional -->\n        <inflation>0.07</inflation> <!-- optional -->\n\t<CashFlows>\n\t    <Capex name='Cfname1' tax='false' inflation='none' multiply='multiplier1' mult_target='false'>\n    \t        <driver>Cfdriver1</driver>\n                <alpha>-4000000000</alpha>\n                <reference>1000000000</reference>\n                <X>1.0</X>\n            </Capex>\n\n            <Recurring name='Cfname2' tax='false' inflation='none' multiply='multiplier2' mult_target='true'>\n                ...\n            </Recurring>\n            ...\n\t</CashFlows>\n    </Component>\n\n    <Component name='Component2'>\n        ...\n    </Component>\n    ...\n</Economics>\n\\end{lstlisting}\n\nAs one can see, all the specifications of the \\textbf{TEAL.CashFlow} module are given in the \\xmlNode{Economics} block. The block accepts an attribute called \\xmlAttr{verbosity},\nwhich can range from 0 to 100, 0 meaning maximum debug verbosity and 100 meaning\nerrors only. Setting the verbosity to 50 will output (in addition to errors) the\n NPV, IRR, PI or NPV\\_mult. Inside the \\xmlNode{Economics} block, there are two\n types of blocks: \\xmlNode{Global} and \\xmlNode{Component}.\n\n\\subsection{\\xmlNode{Global}}\nExactly one \\xmlNode{Global} block has to be provided. The \\xmlNode{Global} block does not have any attributes. The following sub-blocks can be given in the \\xmlNode{Global} block:\n\n\\begin{enumerate}\n\\item[\\xmlNode{Indicator}] List of cash flows considered in the computation of the economic indicator. See later for the definition\n of the cash flows. Only cash flows listed here are considered, additional cash flows defined, but not listed are ignored.\n\\xmlNode{Indicator} can have two attributes:\n  \\begin{enumerate}\n  \\item[\\xmlAttr{name}] The names of the economic indicators that should be computed. So far, \\textbf{'NPV'}, \\textbf{'NPV\\_search'}, \\textbf{'IRR'} and \\textbf{'PI'} are supported. More than one indicator can be asked for.\nThe \\xmlAttr{name} attribute can contain a comma-separated list as shown in the example in Listing \\ref{lst:InputExample}.\n\n\\textbf{NPV}: computes the NPV according to Eq. \\ref{eq:NPV}.\n\\begin{equation}\\label{eq:NPV}\nNPV=\\sum_{y=0}^{N}\\frac{CF_{y}}{(1+DiscountRate)^{y}}\n\\end{equation}\n\nThe sum runs over the years $y=0$ to $N$. The net cash flows $CF_{y}$ are the sum of all cash flows defined in the indicator block (see later for how to define these cash flows).\n$N$ is the least common multiple (LCM) of all component life times involved. This guarantees that the NPV is computed for a time span so that all components reach their end of life in the same year.\nThe individual component cash flows are repeated until the LCM is reached. For example, lets assume the calculation involves two components \\textit{Component1} and \\textit{Component2}\n with life times of 60 years and 40 years respectively. $N$ will be 120 years where 2 successive \\textit{Component1} and 3 successive \\textit{Component2} will be build. For every ‘building year’,\nthe cash flow for the last year (of the old component) and the year zero (for the newly built component) will be summed. Table \\ref{tbl:cashflows} shows an example for illustration.\nThe variable sent back to RAVEN, i.e. what needs to be added to the output data object is 'NPV'.\n\n\\begin{table}[]\n\\centering\n\\caption{Example cash flows for NPV calculation.}\n\\label{tbl:cashflows}\n\\begin{tabular}{ll|l|l|l|l|l|ll}\n\\cline{3-4} \\cline{6-7}\n                           &  & \\multicolumn{2}{l|}{Compo 1}                                                                                                   &  & \\multicolumn{2}{l|}{Compo 2}                                                                                                     &                       &                                                                                                       \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{Year} &  & \\begin{tabular}[c]{@{}l@{}}Comp. \\\\ lifetime\\end{tabular} & \\begin{tabular}[c]{@{}l@{}}Cash Flow\\\\ (year)\\end{tabular}         &  & \\begin{tabular}[c]{@{}l@{}}Compo. \\\\ Lifetime\\end{tabular} & \\begin{tabular}[c]{@{}l@{}}  Cash Flow \\\\ (year) \\end{tabular}      & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{\\begin{tabular}[c]{@{}l@{}}Total Net Cash flow \\\\ ($CF_{y}$)         \\end{tabular}}   \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{0}    &  & 0                                                         & $CF^{comp1}_{0}$                                                          &  & 0                                                          & $CF^{comp2}_{0}$                                                           & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{0} + CF^{comp2}_{0}$ }                                     \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{1}    &  & 1                                                         & $CF^{comp1}_{1}$                                                          &  & 1                                                          & $CF^{comp2}_{1}$                                                           & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{1} + CF^{comp2}_{1}$ }                                     \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{…}    &  &                                                           &                                                                    &  &                                                            &                                                                     & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{}                                                                                 \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{39}   &  & 39                                                        & $CF^{comp1}_{39}$                                                         &  & 39                                                         & $CF^{comp2}_{39}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{39} + CF^{comp2}_{39}$ }                                   \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{40}   &  & 40                                                        & $CF^{comp1}_{40}$                                                         &  & 40 and 0                                                   & \\begin{tabular}[c]{@{}l@{}}$CF^{comp2}_{40}$  \\\\ $+ CF^{comp2}_{0}$ \\end{tabular} & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{\\begin{tabular}[c]{@{}l@{}}$CF^{comp1}_{40} + CF^{comp2}_{40}$ \\\\  $+ CF^{comp2}_{0}$ \\end{tabular}} \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{41}   &  & 41                                                        & $CF^{comp1}_{41}$                                                         &  & 1                                                          & $CF^{comp2}_{1}$                                                           & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{41} + CF^{comp2}_{1}$ }                                  \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{…}    &  &                                                           &                                                                    &  &                                                            &                                                                     & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{}                                                                                 \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{59}   &  & 59                                                        & $CF^{comp1}_{59}$                                                         &  & 19                                                         & $CF^{comp2}_{19}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{59} + CF^{comp2}_{19}$ }                                 \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{60}   &  & 60 and 0                                                  & \\begin{tabular}[c]{@{}l@{}}$CF^{comp1}_{60}$ \\\\ $+ CF^{comp1}_{0}$ \\end{tabular} &  & 20                                                         & $CF^{comp2}_{20}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{\\begin{tabular}[c]{@{}l@{}}$CF^{comp1}_{60} + CF^{comp1}_{0}$ \\\\ $+ CF^{comp2}_{20}$ \\end{tabular}} \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{61}   &  & 1                                                         & $CF^{comp1}_{1}$                                                          &  & 21                                                         & $CF^{comp2}_{21}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{1} + CF^{comp2}_{21}$ }                                                          \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{…}    &  &                                                           &                                                                    &  &                                                            &                                                                     & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{}                                                                                 \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{79}   &  & 19                                                        & $CF^{comp1}_{19}$                                                         &  & 39                                                         & $CF^{comp2}_{39}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{19} + CF^{comp2}_{39}$ }                                                         \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{80}   &  & 20                                                        & $CF^{comp1}_{20}$                                                         &  & 40 and 0                                                   & \\begin{tabular}[c]{@{}l@{}}$CF^{comp2}_{40}$ \\\\  $+ CF^{comp2}_{0}$ \\end{tabular} & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{\\begin{tabular}[c]{@{}l@{}}$CF^{comp1}_{20} + CF^{comp2}_{40}$ \\\\ $+ CF^{comp2}_{0}$ \\end{tabular}}  \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{81}   &  & 21                                                        & $CF^{comp1}_{21}$                                                         &  & 1                                                          & $CF^{comp2}_{1}$                                                           & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{21} + CF^{comp2}_{1}$ }                                                          \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{…}    &  &                                                           &                                                                    &  &                                                            &                                                                     & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{}                                                                                 \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{119}  &  & 59                                                        & $CF^{comp1}_{59}$                                                         &  & 39                                                         & $CF^{comp2}_{39}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{59} + CF^{comp2}_{39}$ }                                                         \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\multicolumn{1}{|l|}{120}  &  & 60                                                        & $CF^{comp1}_{60}$                                                         &  & 40                                                         & $CF^{comp2}_{40}$                                                          & \\multicolumn{1}{l|}{} & \\multicolumn{1}{l|}{$CF^{comp1}_{60} + CF^{comp2}_{40}$}                                                         \\\\ \\cline{1-1} \\cline{3-4} \\cline{6-7} \\cline{9-9}\n\\end{tabular}\n\\end{table}\n\n\\textbf{PI}: computes the PI according to Eq. \\ref{eq:PI}.\n\\begin{equation}\\label{eq:PI}\nPI=\\frac{NPV}{Initial\\_investment}\n\\end{equation}\nwhere the NPV is calculated as explained above and the $Initial\\_investment$ is the Total Net Cash flow at year zero, i.e. $CF_{0}$ in the example above.\nThe variable sent back to RAVEN, i.e. what needs to be added to the output data object is 'PI'.\n\n\\textbf{IRR}: computes the IRR according to Eq. \\ref{eq:IRR}.\n\\begin{equation}\\label{eq:IRR}\n0=\\sum_{y=0}^{N}\\frac{CF_{y}}{(1+IRR)^{y}}\n\\end{equation}\nSame as for the NPV, the sum runs over the years $y=0$ to $N$. The net cash flows $CF_{y}$ are the sum of all cash flows defined in the indicator block\n(see explanation of NPV above for details). $N$ is the least common multiple (LCM) of all component life times involved.\nThe variable sent back to RAVEN, i.e. what needs to be added to the output data object is 'IRR'.\n\n\\textbf{NPV\\_search}: The NPV search finds a multiplier '$x$' that multiplies some of the cash flows, so that the NPV has a desired value (defined by the \\xmlAttr{target} attribute). The equation solved is shown in Eq. \\ref{eq:NPV_search}.\n\\label{subsec:NPV_search}\n\\begin{equation}\\label{eq:NPV_search}\n'target'=\\sum_{y=0}^{N}\\frac{CF^{dep\\_on\\_x}_{y}}{(1+DiscountRate)^{y}}x + \\sum_{y=0}^{N}\\frac{CF^{not\\_dep\\_on\\_x}_{y}}{(1+DiscountRate)^{y}}\n\\end{equation}\n\nThe cash flows that multiply ‘$x$’ have to have the \\xmlAttr{mult\\_target} attribute equal \\textbf{'true'} (see later in cash flow definition). This functionality can be used for\n example to find a commodity price so that the NPV is zero. In this case, the \\xmlAttr{target} will be set to \\textbf{'0'} and all cash flows that depend (linearly) on the price will take\n \\xmlAttr{mult\\_target}$=$\\textbf{'true'}, i.e. for example the revenue, while cash flows that do not depend on the price will have \\xmlAttr{mult\\_target}$=$\\textbf{'false'}, i.e. for example the capital cost.\nThe variable sent back to RAVEN, i.e. what needs to be added to the output data object is 'NPV\\_mult'.\n\n\\textbf{Note on IRR and PI search}: It should be noted that although the only search keyword allowed in \\xmlAttr{name} is \\textbf{NPV\\_search}, it is possible to perform IRR and PI searches as well.\n\n  \\begin{itemize}\n  \\item To do an IRR search, the DiscountRate is set to the desired IRR and a NPV search with the target of ‘0’ is performed.\n  \\item To perform a PI search, an NPV search can be performed where the target PI is multiplied with the initial investment.\n  \\end{itemize}\n\n\n  \\item[\\xmlAttr{Target}] Target value for the NPV search, i.e. \\textbf{'0'} will look for ‘$x$’ so that $NPV(x) = 0$.\n\n  \\end{enumerate}\n\n\\item[\\xmlNode{DiscountRate}] The discount rate used to compute the NPV and PI. Not used for the computation of the IRR (although it must be input).\n\\item[\\xmlNode{tax}] The standard tax rate used to compute the taxes if no other tax rate is specified in the componet blocks. This is a required input. If a tax rate is specified inside a component block, the componet will use that tax rate. If no tax rate is specified in a component, this standard tax rate is used for the component. See later in the definition of the cash flows for more details how the tax rate is used.\n\\item[\\xmlNode{inflation}] The standard inflation rate used to compute the inflation if no other inflation rate is specified in the componet blocks. This is a required input. If a inflation rate is specified inside a component block, the componet will use that inflation rate. If no inflation rate is specified in a component, this standard inflation rate is used for the component. See later in the definition of the cash flows for more details how the inflation rate is used.\n\n\\item[\\xmlNode{ProjectTime}] This is a optional input. If it is included in the input, the global project time is not the LCM of all components (see \\xmlNode{Indicator} attribute \\xmlAttr{name} for more information), but the time indicated here.\n\n\\end{enumerate}\n\n\n\\subsection{\\xmlNode{Component}}\n\nThe user can define as many \\xmlNode{Component} blocks as needed. A component is typically a part of the system that has the same lifetime and\nthe same cash flows, i.e. for example a gas turbine, a battery or a nuclear plant. Each component needs to have a \\xmlAttr{name} attribute that is unique.\nEach \\xmlNode{Component} has to have one \\xmlNode{Life\\_time} block and as many \\xmlNode{CashFlow} blocks as needed.\n\n\\begin{enumerate}\n  \\item[\\xmlNode{Life\\_time}] The lifetime of the component in years. This is used to compute the least common multiple (LCM) of all components involved in the\n    computation of the economics indicator. For more details see NPV, IRR and PI explanations above.\n  \\item[\\xmlNode{tax}] This is a optional input. If the tax rate is specified here, i.e. inside the component block, the componet will use this tax rate.\n    If no tax rate is specified in the component, the standard tax rate from the \\xmlNode{Global} block is used for the component.\n  \\item[\\xmlNode{inflation}] This is a optional input. If the inflation rate is specified here, i.e. inside the component block,\n    the componet will use this inflation rate. If no inflation rate is specified in the component, the standard inflation rate from the \\xmlNode{Global}\n    block is used for the component.\n  \\item[\\xmlNode{StartTime}] This is a optional input. If this input is specified for one or more components, the \\xmlNode{Global}\n    input \\xmlNode{ProjectTime} is required. This input specifies the year in which this component is going to be build for the first time,\n    i.e. is going to be included in the cash flows. The default is 0 and the componet is build at the start of the project, i.e. at project year 0.\n    For example, if the \\xmlNode{ProjectTime} is 100 years, and for this component, the \\xmlNode{StartTime} is 20 years, the cash flows for this\n    component are going to be zero for years 0 to 19 of the project. Year 20 of the project will be year 0 of this component and so on\n    (project year 21 will be component year 1 etc.).\n  \\item[\\xmlNode{Repetitions}] This is a optional input. If this input is specified for one or more components, the \\xmlNode{Global}\n    input \\xmlNode{ProjectTime} is required. This input specifies the number of times this component is going to be rebuilt. The default is 0,\n    which indicates that the component is going to be rebuild indefinitely until the project end (\\xmlNode{ProjectTime}) is reached.\n    Lets assume the \\xmlNode{ProjectTime} is 100 years, and the component \\xmlNode{Life\\_time} is 20 years. Specifying 3 repetitions of this\n    component will build 3 components in succession, at years 0, 20 and 40. For years 61 to 100 of the project, the cash flows for this component will be zero.\n\n  \\item[\\xmlNode{CashFlows}] The user can define any number of 'cash flows' for a component. Each cash flow is of the form given in\n    Eq. \\ref{eq:CF} where $y$ is the year from 0 (capital investment) to the end of the \\xmlNode{Life\\_time} of the component.\n    \\begin{equation}\\label{eq:CF}\n    CF_{y}=mult\\cdot\\alpha_{y}\\left ( \\frac{driver_{y}}{ref} \\right )^{X}\n    \\end{equation}\n\n  The \\xmlNode{CashFlows} currently can accept the following subnodes:\n  \\begin{enumerate}\n    \\item[\\xmlNode{Capex}] The cash flow for capital expenditures, and this node will accept the following child nodes:\n      \\begin{enumerate}\n        \\item[\\xmlNode{driver}] The $driver$ in Eq. \\ref{eq:CF} of the cash flow. This can be any variable passed in from RAVEN or the name\n          of another cash flow. If it is passed in from RAVEN, it has to be either a scalar or a vector with length \\xmlNode{Life\\_time} + 1.\n          If its a scalar, all $driver_{y}$ in Eq. \\ref{eq:CF}  are the same for all years of the project life. If it is a vector instead, each\n          year of the project \\xmlNode{Life\\_time} will have its corresponding value for the driver. If the driver is another\n          cash flow, the project \\xmlNode{Life\\_time} of the component to which the driving cash flow belongs has to be the same than the project\n          \\xmlNode{Life\\_time} of the component to which this\n          cash flow belongs. No loops of cash flows are allowed. The code will error out if there are loops of cash flows, i.e. A is the driver\n          of B and B the driver of A.\n        \\item[\\xmlNode{alpha}] $\\alpha_{y}$ multiplier of the cash flow (see Eq. \\ref{eq:CF}). Similar to \\xmlNode{driver}, can be\n          either scalar or vector. If a vector, exactly \\xmlNode{Life\\_time}$ + 1$\n          values are expected. One for $y=0$ to $y=$\\xmlNode{Life\\_time}. If a scalar, we assume alpha is zero for all years of the lifetime\n          of the component except the year zero (the provided scalar value will be used for year zero), which is the construction year.\n        \\item[\\xmlNode{reference}] The $ref$ value of the cash flow (see Eq. \\ref{eq:CF}).\n        \\item[\\xmlNode{X}] The $X$ exponent (economy of scale factor) of the cash flow (see Eq. \\ref{eq:CF}).\n      \\end{enumerate}\n    \\item[\\xmlNode{Recurring}] The cash flow for recurring cost, such as operation and maintenance cost.\n      \\begin{enumerate}\n        \\item[\\xmlNode{driver}] The $driver$ in Eq. \\ref{eq:CF} of the cash flow. This can be any variable passed in from RAVEN or the name\n          of another cash flow. If it is passed in from RAVEN, it has to be either a scalar or a vector with length \\xmlNode{Life\\_time} + 1.\n          If its a scalar, all $driver_{y}$ in Eq. \\ref{eq:CF}  are the same for all years of the project life. If it is a vector instead, each\n          year of the project \\xmlNode{Life\\_time} will have its corresponding value for the driver. If the driver is another\n          cash flow, the project \\xmlNode{Life\\_time} of the component to which the driving cash flow belongs has to be the same than the project\n          \\xmlNode{Life\\_time} of the component to which this\n          cash flow belongs. No loops of cash flows are allowed. The code will error out if there are loops of cash flows, i.e. A is the driver\n          of B and B the driver of A.\n          \\item[\\xmlNode{alpha}] $\\alpha_{y}$ multiplier of the cash flow (see Eq. \\ref{eq:CF}). Similar to \\xmlNode{driver}, can be\n            either scalar or vector. If a vector, exactly \\xmlNode{Life\\_time}$ + 1$\n            values are expected. One for $y=0$ to $y=$\\xmlNode{Life\\_time}.\n            If a scalar, we assume alpha is nonzero, i.e. the provided scalar value, for all years of the lifetime\n            of the component except the year zero.\n      \\end{enumerate}\n  \\end{enumerate}\n\n  These subnodes, such as \\xmlNode{Capex} and \\xmlNode{Recurring} will accept the following attributes:\n  \\begin{enumerate}\n    \\item[\\xmlAttr{name}] The name of the Cash flow. Has to be unique across all components. This is the name that can be listed in the\n      \\xmlNode{Indicator} node of the \\xmlNode{Global} block.\n    \\item[\\xmlAttr{tax}] Can be \\textbf{true} or \\textbf{false}. If it is \\textbf{true}, the cash flow is multiplied by $(1-tax)$, where tax\n      is the tax rate given in \\xmlNode{tax} in the \\xmlNode{Global}\n      block. As an example, the cash flow of \\textit{comp2} for year 119 in Listing \\ref{lst:InputExample} would become $CF^{comp2}_{39}(1-tax)$.\n      If a cash flow with \\xmlAttr{tax}$=$\\textbf{true} is the driver of another cash flow, the cash flow without the tax is used as driver for the new cash flow.\n      The limitation of having a global tax rate will be lifted in future version of the \\textbf{TEAL.CashFlow} module. It is planned to have the possibility to\n      input different tax rates for each component, since they might be in different tax regions.\n    \\item[\\xmlAttr{inflation}] Can be \\textbf{real, nominal} or \\textbf{none}. If it is \\textbf{real}, the cash flow is multiplied by\n      $(1+inflation)^{-y}$. If it is \\textbf{nominal}, the cash flow is multiplied by $(1+inflation)^y$.\n      In both cases, inflation is given by \\xmlNode{inflation} in the \\xmlNode{Global} block. Furthermore, $y$ goes from year 0 (capital investment)\n      to the LCM of all component lifetimes.\n      This means that the cash flows as expressed in Listing \\ref{lst:InputExample} are multiplied with the infloation seen from today, i.e. the cash\n      flow for \\textit{comp2} for year 119 assuming it includes \\textbf{real}\n      inflation would be $CF^{comp2}_{39}(1+inflation)^{-119}$\n      If a cash flow with \\xmlAttr{inflation} equal \\textbf{real} or \\textbf{nominal} is the driver of another cash flow, the cash flow without\n      the inflation is used as driver for the new cash flow.\n    \\item[\\xmlAttr{multiply}] This is an optional attribute. This can be the name of any scalar variable passed in from RAVEN. This number\n      is $mult$ in Eq. \\ref{eq:CF} that multiplies the cash flow.\n    \\item[\\xmlAttr{mult\\_target}] Can be \\textbf{true} or \\textbf{false}. If \\textbf{true}, it means that this cash flow multiplies\n      the search variable '$x$' as explained in the NPV\\_search option above.\n      If the NPV\\_search option is used, al least one cash flow has to have \\xmlAttr{mult\\_target}$=$\\textbf{true}.\n  \\end{enumerate}\n\n\n\n\n\\end{enumerate}\n\nAn example of a cash flow is shown in Listing \\ref{lst:CashFlowExample}. In the example, a cash flow called CAPEX is defined.\nIn the example, the capital expenditure for a reference plant of capacity\n 1'000'000'000 W is \\$4 billion. The driver of this cash flow is the actual plant capacity in Watts. Building this plat has some economy\n of scale, so that a plant double the size does cost\nless than double the money ($X=0.64$). The example assums an overnight building cost of the reactor, i.e. $\\alpha$ is zero for\nall years of the lifetime of the reactor except year zero, which is the construction year.\n\n\\begin{lstlisting}[style=XML,morekeywords={anAttribute},caption=CashFlow input example., label=lst:CashFlowExample]\n<Capex name='CAPEX' tax='false' inflation='none'>\n    <driver>Plant_capacity</driver>\n    <alpha>-4000000000</alpha>\n    <reference>1000000000</reference>\n    <X>0.64</X>\n</Capex>\n\\end{lstlisting}\n", "meta": {"hexsha": "ea05704260e9a5f328bd332584a7ee976083e952", "size": 28543, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/include/CashFlow.tex", "max_stars_repo_name": "wanghy-anl/TEAL", "max_stars_repo_head_hexsha": "500f1ac6fa3a308fbee328abc6a165205019df70", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-07-28T21:37:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-28T22:46:32.000Z", "max_issues_repo_path": "doc/include/CashFlow.tex", "max_issues_repo_name": "alfoa/TEAL", "max_issues_repo_head_hexsha": "52ef4075d15d14995af92add6f25120b98948afe", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 37, "max_issues_repo_issues_event_min_datetime": "2020-07-31T15:15:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T17:34:36.000Z", "max_forks_repo_path": "doc/include/CashFlow.tex", "max_forks_repo_name": "alfoa/TEAL", "max_forks_repo_head_hexsha": "52ef4075d15d14995af92add6f25120b98948afe", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2020-07-31T14:49:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T22:59:38.000Z", "avg_line_length": 104.9375, "max_line_length": 511, "alphanum_fraction": 0.5691062607, "num_tokens": 7467, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.40009607361067917}}
{"text": "\\documentclass[fontsize=9pt, parskip=half, notitlepage, fleqn]{scrartcl}\n\n\\usepackage{tabularx}\n\\usepackage{booktabs}\n\\usepackage{verbatim}\n\n\\usepackage[UKenglish]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\\usepackage[T1]{fontenc}\n\\usepackage{amssymb, amsmath, amsfonts, amsthm, empheq}\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{xspace}\n\\usepackage{siunitx}\n\\usepackage[margin=3cm]{geometry}\n\\usepackage{natbib}\n\\usepackage[pdftex,final,allcolors=myblue,colorlinks,breaklinks=True]{hyperref}\n\n\\frenchspacing\n\\definecolor{myblue}{rgb}{0,0,.8} % {0,0,.8}\n\\newcommand{\\mr}[1]{\\mathrm{#1}}\n\n\\title{Digital Linear Filter (DLF) design}\n\\author{Dieter Werthmüller}\n\\subtitle{Some notes regarding the \\texttt{fdesign} add-on for \\texttt{empymod}}\n\n\\begin{document}\n\\maketitle\n\n\\section{About and Info}\n\nThe add-on \\texttt{fdesign} can be used to design digital linear filters for\nthe Hankel or Fourier transform, or for any linear transform. For this included\nor provided theoretical transform pairs can be used. Alternatively, one can use\nthe EM modeller \\texttt{empymod} \\citep{GEO.17.Werthmuller} to use the\nresponses to an arbitrary 1D model as numerical transform pair.\n\nMore information can be found in the following places:\n\n\\begin{itemize}\n  \\item The article about \\texttt{fdesign} is in the repo\n    \\href{https://github.com/empymod/article-fdesign}{github.com/empymod/article-fdesign}\n  \\item Example notebooks to design a filter can be found in the repo\n    \\href{https://github.com/empymod/example-notebooks}{github.com/empymod/example-notebooks}\n\\end{itemize}\n\n\nThe methodology of \\texttt{fdesign} is based upon \\cite{GP.07.Kong}. The whole\nproject of \\texttt{fdesign} started with the Matlab scripts from Kerry Key,\nwhich he used to design his filters for \\cite{GEO.09.Key, GEO.12.Key}. Fruitful\ndiscussions with Evert Slob and Kerry Key improved the add-on substantially.\n\nNote that the use of \\texttt{empymod} to create numerical transform pairs is,\nas of now, only implemented for the Hankel transform (via\n\\texttt{fdesign.empy\\_hankel}).\n\n\\section{Implemented analytical transform pairs}\n\nThe following tables list the transform pairs which are implemented by default.\nAny other transform pair can be provided as input. A transform pair is defined\nin the following way:\n\\begin{verbatim}\n    from empyscripts.fdesign import Ghosh\n\n    def my_tp_pair(var):\n        \"\"\"My transform pair.\"\"\"\n\n        def lhs(l):\n            return func(l, var)\n\n        def rhs(r):\n            return func(r, var)\n\n        return Ghosh(name, lhs, rhs)\n\\end{verbatim}\n\nHere, \\texttt{name} must be one of \\texttt{j0}, \\texttt{j1}, \\texttt{sin}, or\n\\texttt{cos}, depending what type of transform pair it is. Additional variables\nare provided with \\texttt{var}. The evaluation points of the \\texttt{lhs} are\ndenoted by \\texttt{l}, and the evaluation points of the \\texttt{rhs} are\ndenoted as \\texttt{r}. As an example here the implemented transform pair\n\\texttt{j0\\_1}:\n\\begin{verbatim}\n    def j0_1(a=1):\n        \"\"\"Hankel transform pair J0_1 ([Anderson_1975]_).\"\"\"\n\n        def lhs(l):\n            return l*np.exp(-a*l**2)\n\n        def rhs(r):\n            return np.exp(-r**2/(4*a))/(2*a)\n\n        return Ghosh('j0', lhs, rhs)\n\\end{verbatim}\n\n\\subsection{Implemented Hankel transforms}\n\n\\renewcommand{\\arraystretch}{1.3}\n\\begin{tabularx}{\\linewidth}{lp{2.6cm}X}\n  Name & Reference & Transform pair \\\\\n\\toprule\n   %\n  j0\\_1& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l \\exp\\left(-al^2\\right) J_0(lr)\\,\\mr{d}l =\n    \\frac{\\exp\\left(\\frac{-r^2}{4a}\\right)}{2a}\n    \\label{eq:j0_1}\n  \\end{equation}\n  } \\\\\n   %\n  j0\\_2& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\exp\\left(-al\\right) J_0(lr)\\,\\mr{d}l =\n    \\frac{1}{\\sqrt{a^2+r^2}}\n    \\label{eq:j0_2}\n  \\end{equation}\n  } \\\\\n   %\n  j0\\_3&\n  \\noindent\\parbox[c]{\\hsize}{\\cite{GP.97.Guptasarma}}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l\\exp\\left(-al\\right) J_0(lr)\\,\\mr{d}l =\n    \\frac{a}{(a^2 + r^2)^{3/2}}\n    \\label{eq:j0_3}\n  \\end{equation}\n  } \\\\\n   %\n  j0\\_4&\n  \\noindent\\parbox[c]{\\hsize}{\\cite{JGR.82.Chave}}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\frac{l}{\\beta} \\exp\\left(-\\beta z_\\mr{v} \\right)\n    J_0(lr)\\,\\mr{d}l =\n    \\frac{\\exp\\left(-\\gamma R\\right)}{R}\n    \\label{eq:j0_4}\n  \\end{equation}\n  } \\\\\n   %\n  j0\\_5&\n  \\noindent\\parbox[c]{\\hsize}{\\cite{JGR.82.Chave}}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l \\exp\\left(-\\beta z_\\mr{v} \\right)\n    J_0(lr)\\,\\mr{d}l =\n    \\frac{ z_\\mr{v} (\\gamma R + 1)}{R^3}\\exp\\left(-\\gamma R\\right)\n    \\label{eq:j0_4}\n  \\end{equation}\n  } \\\\\n   %\n  j1\\_1& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l^2 \\exp\\left(-al^2\\right) J_1(lr)\\,\\mr{d}l =\n    \\frac{r}{4a^2} \\exp\\left(-\\frac{r^2}{4a}\\right)\n    \\label{eq:j1_1}\n  \\end{equation}\n  } \\\\\n   %\n  j1\\_2& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\exp\\left(-al\\right) J_1(lr)\\,\\mr{d}l =\n    \\frac{\\sqrt{a^2+r^2}-a}{r\\sqrt{a^2 + r^2}}\n    \\label{eq:j1_2}\n  \\end{equation}\n  } \\\\\n   %\n  j1\\_3& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l \\exp\\left(-al\\right) J_1(lr)\\,\\mr{d}l =\n    \\frac{r}{(a^2 + r^2)^{3/2}}\n    \\label{eq:j1_3}\n  \\end{equation}\n  } \\\\\n   %\n  j1\\_4&\n  \\noindent\\parbox[c]{\\hsize}{\\cite{JGR.82.Chave}}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\frac{l^2}{\\beta} \\exp\\left(-\\beta z_\\mr{v} \\right)\n    J_1(lr)\\,\\mr{d}l =\n    \\frac{r(\\gamma R+1)}{R^3}\\exp\\left(-\\gamma R\\right)\n    \\label{eq:j1_4}\n  \\end{equation}\n  } \\\\\n   %\n  j1\\_5&\n  \\noindent\\parbox[c]{\\hsize}{\\cite{JGR.82.Chave}}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l^2 \\exp\\left(-\\beta z_\\mr{v} \\right)\n    J_1(lr)\\,\\mr{d}l =\n    \\frac{r z_\\mr{v} (\\gamma^2R^2+3\\gamma R+3)}{R^5}\\exp\\left(-\\gamma R\\right)\n    \\label{eq:j1_4}\n  \\end{equation}\n  } \\\\\n\\end{tabularx}\n\n\\begin{align}\n  a&>0,\\quad r>0\\\\\n  %\n  z_\\mr{v} &= |z_\\mr{rec} - z_\\mr{src}|\\\\\n%\n  R &= \\sqrt{r^2 + z_\\mr{v}^2}\\\\\n%\n    \\gamma &= \\sqrt{2j\\pi\\mu_0f/\\rho}\\\\\n%\n    \\beta &= \\sqrt{l^2 + \\gamma^2}\\\\\n  \\label{eq:symb}\n\\end{align}\n\n\n\\subsection{Implemented Fourier transforms}\n\n\\renewcommand{\\arraystretch}{1.3}\n\\begin{tabularx}{\\linewidth}{llX}\n  Name & Reference & Transform pair \\\\\n\\toprule\n   %\n  sin\\_1& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,l\\exp\\left(-a^2l^2\\right) \\sin(lr)\\,\\mr{d}l =\n    \\frac{\\sqrt{\\pi}r}{4a^3} \\exp\\left(-\\frac{r^2}{4a^2}\\right)\n    \\label{eq:sin_1}\n  \\end{equation}\n  } \\\\\n   %\n  sin\\_2& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\exp\\left(-al\\right) \\sin(lr)\\,\\mr{d}l =\n    \\frac{r}{a^2 + r^2}\n    \\label{eq:sin_2}\n  \\end{equation}\n  } \\\\\n   %\n  sin\\_3& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\frac{l}{a^2+l^2} \\sin(lr)\\,\\mr{d}l =\n    \\frac{\\pi}{2} \\exp\\left(-ar\\right)\n    \\label{eq:sin_3}\n  \\end{equation}\n  } \\\\\n   %\n  cos\\_1& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\exp\\left(-a^2l^2\\right) \\cos(lr)\\,\\mr{d}l =\n    \\frac{\\sqrt{\\pi}}{2a} \\exp\\left(-\\frac{r^2}{4a^2}\\right)\n    \\label{eq:cos_1}\n  \\end{equation}\n  } \\\\\n   %\n  cos\\_2& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\exp\\left(-al\\right) \\cos(lr)\\,\\mr{d}l =\n    \\frac{a}{a^2 + r^2}\n    \\label{eq:cos_2}\n  \\end{equation}\n  } \\\\\n   %\n  cos\\_3& \\cite{USGS.75.Anderson}&\n  \\noindent\\parbox[c]{\\hsize}{\n  \\begin{equation}\n    \\int^\\infty_0\\,\\frac{1}{a^2+l^2} \\cos(lr)\\,\\mr{d}l =\n    \\frac{\\pi}{2a} \\exp\\left(-ar\\right)\n    \\label{eq:cos_3}\n  \\end{equation}\n  } \\\\\n   %\n\\end{tabularx}\n\n%% ~ REFERENCES\n\\begin{thebibliography}{}\n\\itemsep0pt\n\n\\bibitem[Anderson, 1975]{USGS.75.Anderson}\nAnderson, W.~L.,  1975, Improved digital filters for evaluating {F}ourier and\n  {H}ankel transform integrals:\n\\newblock USGS, {\\bf PB242800};\n  \\href{https://pubs.er.usgs.gov/publication/70045426}{https://pubs.er.usgs.gov/publication/70045426}.\n\n\\bibitem[Chave and Cox, 1982]{JGR.82.Chave}\nChave, A.~D., and C.~S. Cox,  1982, Controlled electromagnetic sources for\n  measuring electrical conductivity beneath the oceans: 1. forward problem and\n  model study: Journal of Geophysical Research,\n\\newblock {\\bf 87}, 5327--5338;\n  \\href{http://doi.org/10.1029/JB087iB07p05327}{doi: 10.1029/JB087iB07p05327}.\n\n\\bibitem[Guptasarma and Singh, 1997]{GP.97.Guptasarma}\nGuptasarma, D., and B. Singh,  1997, New digital linear filters for {H}ankel\n  {J}0 and {J}1 transforms: Geophysical Prospecting,\n\\newblock {\\bf 45}, 745--762;\n  \\href{http://doi.org/10.1046/j.1365-2478.1997.500292.x}{doi:\n  10.1046/10.1046/j.1365-2478.1997.500292.x}.\n\n\\bibitem[Kong, 2007]{GP.07.Kong}\nKong, F.~N.,  2007, Hankel transform filters for dipole antenna radiation in a\n  conductive medium: Geophysical Prospecting, {\\bf 55}, 83--89.\n\\newblock (\\href{http://doi.org/10.1111/j.1365-2478.2006.00585.x}{doi:\n  10.1111/j.1365-2478.2006.00585.x}).\n\n\\bibitem[Key, 2009]{GEO.09.Key}\nKey, K.,  2009, {1D} inversion of multicomponent, multifrequency marine {CSEM}\n  data: {M}ethodology and synthetic studies for resolving thin resistive\n  layers: Geophysics, {\\bf 74}, F9--F20.\n\\newblock (\\href{http://doi.org/10.1190/1.3058434}{doi: 10.1190/1.3058434}).\n\n\\bibitem[Key, 2012]{GEO.12.Key}\n--------, 2012, Is the fast {H}ankel transform faster than quadrature?:\n  Geophysics, {\\bf 77}, F21--F30.\n\\newblock (\\href{http://doi.org/10.1190/GEO2011-0237.1}{doi:\n  10.1190/GEO2011-0237.1}).\n\n\\bibitem[Werthmüller, 2017]{GEO.17.Werthmuller}\nWerthmüller, D.,  2017, An open-source full {3D} electromagnetic modeler for\n  {1D} {VTI} media in {P}ython: empymod: Geophysics, {\\bf 82}, WB9--WB19..\n\\newblock (\\href{http://doi.org/10.1190/geo2016-0626.1}{doi:\n  10.1190/geo2016-0626.1}).\n\n\n\\end{thebibliography}\n\n\\end{document}\n\n", "meta": {"hexsha": "7566a8999b394902bcd560519f16205fab8ebf03", "size": 10102, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/LaTeX/fdesign.tex", "max_stars_repo_name": "empymod/empyscripts", "max_stars_repo_head_hexsha": "b542f86ce4a48f43d2ddaeabbc08af2a5815fe95", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/LaTeX/fdesign.tex", "max_issues_repo_name": "empymod/empyscripts", "max_issues_repo_head_hexsha": "b542f86ce4a48f43d2ddaeabbc08af2a5815fe95", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-02-14T14:33:46.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-23T14:31:49.000Z", "max_forks_repo_path": "docs/LaTeX/fdesign.tex", "max_forks_repo_name": "empymod/empyscripts", "max_forks_repo_head_hexsha": "b542f86ce4a48f43d2ddaeabbc08af2a5815fe95", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3363363363, "max_line_length": 102, "alphanum_fraction": 0.6540289052, "num_tokens": 3948, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.40009607074808856}}
{"text": "\\newpage\\section{Functional Equations}\n\n\\begin{itemize}[left=0pt, itemsep=2em]\n    \\item Equating terms:\n        \\begin{enumerate}[left=0pt,label=\\textbf{\\arabic*.}]\n            \\item \\textbf{Pseudo-symmetry}: If an equation is almost but not\n                completely symmetrical, what happens if you change the order of\n                the variables and compare with what you started with?\n\n            \\item \\textbf{Fudging}: Can you change one variable so as to alter the\n                equation only slightly? If so, compare with what you started with.\n\n            \\item \\textbf{Self-cancelation}: Can you make two terms in the same\n                functional equation cancel each other out?\n\n            \\item These are the most mechanical ways of getting the same value to\n                show up multiple times, but each problem has its own tricks. If\n                you see an interesting expression pop up, always ask yourself\n                whether you can get it to pop up in a slightly different way too.\n        \\end{enumerate}\n    \\item Induction, Cauchy\n        \\begin{enumerate}[left=0pt,label=\\textbf{\\arabic*.}]\n            \\item If you want to solve a functional equation over the integers or\n                over the rationals, it often helps to inductively calculate\n                something like $f(n x)$ in terms of $f(x)$\n\n            \\item A slight variation: if the domain or range of $f$ is $\\mathbb{N},$\n                definitely look at induction! In addition to asking what is $f(1),$ you\n                can also ask when is $f(n)=1$\n\n            \\item If you want to show $f(x) \\geq y,$ it suffices to show\n                $f(x) \\geq y-\\epsilon$ for all $\\epsilon>0 .$ Can you find\n                progressively tighter ways of bounding $f(x)$ and then\n                apply this argument? Many of the hardest functional\n                equations use this kind of idea.\n        \\end{enumerate}\n\n    \\item Injective, Surjective, Bijective\n        \\begin{enumerate}[left=0pt,label=\\textbf{\\arabic*.}]\n            \\item There are many variations on injectivity and you should\n                not be too fixated on the form used here. The main idea is\n                this: if you can show a relationship between $f(x)$ and\n                $f(y),$ what can conclude about $x$ and $y$ ?\n                \\begin{enumerate}\n                    \\item If $f$ is injective and $f(x)=f(y),$ then $x=y$\n                    \\item If $f$ is increasing and $f(x)>f(y),$ then $x>y$\n                    \\item Often it helps to start with a weaker version of\n                        injectivity: if $f(x)=f(y)=0,$ then $x=y$\n                    \\item Even if $f$ is not injective, we can often still\n                        end up with something useful. For example, if\n                        $f(x)=x^{2}$ is a valid solution, we will not be\n                        able to show $f(x)$ is injective, but perhaps we\n                        can show that if $f(x)=f(y),$ then $x=\\pm y .$\n                        That is almost as good.\n                    \\item If you can show any kind of injectivity results,\n                        it is often useful to set $x=f(z)$ for some\n                        arbitrary z.\n                \\end{enumerate}\n            \\item Surjectivity is a little less common but it still comes\n                in a couple flavours. The main idea is this: is there some\n                nasty expression in your equation that you wish could be\n                replaced by $x ?$ If so, prove that expression is\n                surjective, and you are good to go.\n                \\begin{enumerate}\n                    \\item Usually the nasty expression will be $f$ itself.\n                    \\item It does not have to be though. For example, if\n                        you could show $f$ (blah) has some nice property,\n                        then a good follow-up would be to show that blah\n                        is surjective.\n                \\end{enumerate}\n        \\end{enumerate}\n\\end{itemize}\n\n\n\\begin{take_note*}[title={Can't Start? Try These}]{}\n    \\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=10pt, parsep=5pt, font=\\bfseries]\n        \\item GUESS THE POSSIBLE SOLUTIONS.\n\n        \\item SUBSTITUTION \n            \\begin{enumerate}\n                \\item Try EVERY possible substitutions, and write them in a\n                    list, dont think during this time.\n                \\item Now think what these results give you.\n                \\item Find values of $ f(0), f(1), f(2), f(-x) $ etc.\n                \\item Tweak the function a little bit, do substitution again.\n                \\item Assume some other functions according to the solutions,\n                    substitute them to make the fe easier to get info out of.\n            \\end{enumerate}\n\n        \\item PROPERTIES OF THE FUNCTION\n            \\begin{enumerate}\n                \\item Try proving INJECTIVITY, SURJECTIVITY etc.\n                \\item Look for Injectivity or Surjectivity of $ f(x)-f(y) $.\n            \\end{enumerate}\n\n        \\item Assume for the sake of contradiction that the value of the\n            function is greater or smaller than the estimated value at some\n            point.\n\n        \\item Sometimes consider the difference of two values of $ f $.\n    \\end{enumerate}\n\\end{take_note*}\n\n\\begin{take_note*}{}\n    \\begin{enumerate}[wide=0em, label=\\arabic*, itemsep=10pt, parsep=5pt, font=\\bfseries]\n        \\item Proving that $f(x)-x$ is injective might come handy in some cases.\n        \\item If you're \\emph{NOT} able to make one side of the equation equal\n            to $0$, try to make it equal to any real or some particular real.\n            (pco 169 P11)\n        \\item Sometimes in integer functions, divisibility of the type\n            $f(1)^{k-1}\\mid f(x)^k$ helps.\t\n        \\item Durr$\\dots$ I want things to cancel. \n    \\end{enumerate}\n\\end{take_note*}\n\n\n\\newpage\\subsection{Problems}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h474746p2658967}{EGMO 2012 P3}{E}{Find all functions $f:\\mathbb{R}\\to\\mathbb{R}$ such that \\[f\\left( {yf(x + y) + f(x)} \\right) = 4x + 2yf\\left(x + y\\right)\\] for all $x,y\\in\\mathbb{R}$.}\n\n\n\n\n\n\\prob{}{pco 169 P11}{M}{Find all $f:\\R\\rightarrow\\R$ such that for all real numbers $x, y$ the following holds: \\[ f(x)^2+2yf(x)+f(y)=f(y+f(x)) \\]}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h506p1611}{IMO 1994 P5}{MH}{Let $ S$ be the set of all real numbers strictly greater than $-1$. Find all functions $ f: S \\to S$ satisfying the two conditions:\n\n    \\begin{enumerate}\n        \\item $ f(x + f(y) + xf(y)) = y + f(x) + yf(x)$ for all $ x, y$ in $ S$;\n        \\item $ \\frac {f(x)}{x}$ is strictly increasing on each of the two intervals $ - 1 < x < 0$ and $ 0 < x$.\n\\end{enumerate}\n}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h219930p1219657}{ISL 1994 A4}{H}{Let $ \\mathbb{R}$ denote the set of all real numbers and $ \\mathbb{R}^+$ the subset of all positive ones. Let $ \\alpha$ and $ \\beta$ be given elements in $ \\mathbb{R},$ not necessarily distinct. Find all functions $ f: \\mathbb{R}^+ \\mapsto \\mathbb{R}$ such that: \\[ f(x)f(y) = y^{\\alpha} f \\left( \\frac{x}{2} \\right) + x^{\\beta} f \\left( \\frac{y}{2} \\right) \\forall x,y \\in \\mathbb{R}^+.\\]}\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1480146p8633190}{IMO 2017 P2}{H}{Let $\\mathbb{R}$ be the set of real numbers. Determine all functions $f: \\mathbb{R} \\rightarrow \\mathbb{R}$ such that, for any real numbers $x$ and $y$, \\[ f(f(x)f(y)) + f(x+y) = f(xy). \\]}\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h215430p1191683}{ISL 2008 A1}{E}{Find all functions $ f: (0, \\infty) \\mapsto (0, \\infty)$ (so $ f$ is a function from the positive real numbers) such that\n    \\[ \\frac {\\left( f(w) \\right)^2 + \\left( f(x) \\right)^2}{f(y^2) + f(z^2) } = \\frac {w^2 + x^2}{y^2 + z^2} \\]\nfor all positive real numbers $ w,x,y,z,$ satisfying $ wx = yz$.}\n\n\n\n\n\n\\prob{}{pco 169 P15}{EH}{Find all $a\\in\\R$ for which there exists a non-constant function $f:(0,1]\\rightarrow\\R$ such that \\[a+f(x+y-xy)+f(x)f(y)\\leq f(x)+f(y)\\] for all $x, y \\in (0,1]$} \n\n\n\n\n\n\\prob{}{pco 168 P18}{E}{Find all functions $f:\\R\\rightarrow\\R$ such that \\[f(f(x)+y)=f(x^2-y)+4f(x)y\\] for all $x, y \\in\\R$}\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h488535p2737643}{ISL 2011 A3}{M}{Determine all pairs $(f,g)$ of functions from the set of real numbers to itself that satisfy \\[g(f(x+y)) = f(x) + (2x + y)g(y)\\] for all real numbers $x$ and $y$.}\n\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h85071p494821}{ISL 2005 A2}{M}{We denote by $\\mathbb{R}^+$ the set of all positive real numbers. Find all functions $f: \\mathbb R^ + \\rightarrow\\mathbb R^ +$ which have the property:\n    \\[f(x)f(y)=2f(x+yf(x))\\]\nfor all positive real numbers $x$ and $y$.}\n\n\\solu{Let's first substitute. If there existed some $ x $ such that $ f(x)<1 $, we could find a nice substitution. But that leads to a contradiction. So what if we could do something like this for the other cases, $ f(x)<2 $ and $ f(x)>2 $?}\n\n\n\n\n\n\n\\prob{https://alrtofproblemsolving.com/community/c6h78909p452035}{ISL 2005 A4}{M}{Find all functions $ f: \\mathbb{R}\\to\\mathbb{R}$ such that $ f(x+y)+f(x)f(y)=f(xy)+2xy+1$ for all real numbers $ x$ and $ y$.}\n\n\\solu{Substitution. }\n\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1627524p10206608}{Iran TST T2P1}{E}{Find all functions $f:\\mathbb{R}\\rightarrow \\mathbb{R}$ that satisfy the following conditions:\n\n    \\begin{enumerate}\n        \\item  $x+f(y+f(x))=y+f(x+f(y)) \\quad \\forall x,y \\in \\mathbb{R}$\n\n        \\item  The set $I=\\left\\{\\frac{f(x)-f(y)}{x-y}\\mid x,y\\in \\mathbb{R},x\\neq y \\right\\}$ is an interval.\n\\end{enumerate}}\n\n\n\n\n\n\\prob{}{169 P20}{E}{Let $a$ be a real number and let $f : \\R \\rightarrow \\R$ be a function satisfying: $f(0) = \\frac{1}{2}$ and $$f(x + y) = f(x)f(a - y) + f(y)f(a - x)$$ $\\forall x, y \\in \\R$. Prove that $f$ is constant}\n\n\n\n\n\n\\prob{}{Vietnam 1991}{E}{Find all functions $ f : \\R \\rightarrow \\R $ for which\n\\[\\frac{1}{2}f(xy)+\\frac{1}{2}f(xz)-f(x)f(yz)\\geq \\frac{1}{4}\\]}\n\n\\solu{Just substitute.}\n\n\n\n\n\n\n\\prob{}{}{M}{Suppose that $f$ and $g$ are two functions defined on the set of positive integers and taking positive integer values. Suppose also that the equations $f(g(n)) = f(n) + 1$ and $g(f(n)) = g(n) + 1$ hold for all positive integer $n$. Prove that $f(n) = g(n)$ for all positive integer $n$.}\n\n\\solu{Durrr... I want things to cancel... Hint: You want to show $ f(n)-g(n) = 0 $.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h17330p118698}{ISL 2002 A1}{EM}{Find all functions $f$ from the reals to the reals such that\\[f\\left(f(x)+y\\right)=2x+f\\left(f(y)-x\\right)\\]for all real $x,y$.}\n\n\\solu{On one of our substitution, we see that there is surjectivity in the equation. So trying to show injectivity is the most intuitive move after that. Again, we have $ x $ on the outside, so we need to make $ x $, $ a $ once and $ b $ once. but we have $ f(y)-x $ which we need to eleminate, keeping $ y $ constant. We can make it either $ a $ or $ b $ since we already have $ f(a)=f(b) $. And again we can take whatever value we want for $ f(y) $.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h17447p119159}{ISL 2001 A1}{EM}{Let $ T$ denote the set of all ordered triples $ (p,q,r)$ of nonnegative integers. Find all functions $ f: T \\rightarrow \\mathbb{R}$ satisfying\n    \\[ f(p,q,r) = \\begin{cases} 0 & \\text{if} \\; pqr = 0, \\\\ 1 + \\frac{1}{6}(f(p + 1,q - 1,r) + f(p - 1,q + 1,r) & \\\\ + f(p - 1,q,r + 1) + f(p + 1,q,r - 1) & \\\\ + f(p,q + 1,r - 1) + f(p,q - 1,r + 1)) & \\text{otherwise} \\end{cases} \\]\nfor all nonnegative integers $ p$, $ q$, $ r$.}\n\n\\solu{First let us guess the ans. For all points on the $ 3 $ sides, our function gives $ 0 $. We get $ f(1, 1, 1)=1 $. We get $ f(1, 1, 2) = f(1, 2, 1) = f(2, 1, 1) = \\frac{3}{2} $. We get $ f(1, 1, 3)=\\frac{9}{5} $. We get $ f(1, 2, 2)=\\frac{12}{5} $. Now, since for $ pqr=0 $, we have $ f=0 $, we need the expression $ pqr $ on the numerator. And we kinda guess that the denominator is $ p+q+r $. From here the guess is obvious.\n\nNow proving that this solution is the only solution. Let the solution be $ g $. Define, $ h := f-g $. Our aim is to prove that $ h=0 $ for all inputs.}\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1790448p11841779}{RMM 2019 P5}{M}{Determine all functions $f: \\mathbb{R} \\to \\mathbb{R}$ satisfying\\[f(x + yf(x)) + f(xy) = f(x) + f(2019y),\\]for all real numbers $x$ and $y$.}\n\n\\solu{After getting $f(yf(0)) = f(y2019)$, one should think of proving that either $ f $ is constant, all zero except $ 0 $, or linear. How to do this?}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1071764p4663900}{APMO 2015 P2}{E}{Let $S = \\{2, 3, 4, \\ldots\\}$ denote the set of integers that are greater than or equal to $2$. Does there exist a function $f : S \\to S$ such that \\[f (a)f (b) = f (a^2 b^2 )\\text{ for all }a, b \\in S\\text{ with }a \\ne b?\\]}\n\n\\solu{Try to break the symmetry, add another variable.}\n\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1268817p6621849}{ISL 2015 A2}{E}{Determine all functions $f:\\mathbb{Z}\\rightarrow\\mathbb{Z}$ with the property that \\[f(x-f(y))=f(f(x))-f(y)-1\\]holds for all $x,y\\in\\mathbb{Z}$.}\n\n\\solu{It just flows.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1113162p5083463}{ISL 2015 A4}{M}{Let $\\mathbb R$ be the set of real numbers. Determine all functions $f:\\mathbb R\\to\\mathbb R$ that satisfy the equation\\[f(x+f(x+y))+f(xy)=x+f(x+y)+yf(x)\\]for all real numbers $x$ and $y$.}\n\n\\solu{When you don't know any heavy techniques, just plug in simple values into the function, and write down all of the equations in a list.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h546165p3160554}{ISL 2012 A5}{M}{Find all functions $f:\\mathbb{R} \\rightarrow \\mathbb{R}$ that satisfy the conditions\n    \\[f(1+xy)-f(x+y)=f(x)f(y) \\quad \\text{for all } x,y \\in \\mathbb{R},\\]\nand $f(-1) \\neq 0$.}\n\n\\solu{In FE, always look back to what you have, and what things can you make from those.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h488500p2737336}{ISL 2012 A1}{E}{Find all functions $f:\\mathbb Z\\rightarrow \\mathbb Z$ such that, for all integers $a,b,c$ that satisfy $a+b+c=0$, the following equality holds:\n    \\[f(a)^2+f(b)^2+f(c)^2=2f(a)f(b)+2f(b)f(c)+2f(c)f(a).\\]\n(Here $\\mathbb{Z}$ denotes the set of integers.)}\n\n\\solu{Go with the flow.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h356075p1935849}{ISL 2012 A1}{E}{Find all function $f:\\mathbb{R}\\rightarrow\\mathbb{R}$ such that for all $x,y\\in\\mathbb{R}$ the following equality holds \\[ f(\\left\\lfloor x\\right\\rfloor y)=f(x)\\left\\lfloor f(y)\\right\\rfloor \\] where $\\left\\lfloor a\\right\\rfloor $ is greatest integer not greater than $a.$}\n\n\\solu{Go with the flow.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h287852p1555894}\n{ISL 2008 A3}{E}{\n    Let $ S\\subseteq\\mathbb{R}$ be a set of real numbers. We say that a pair $\n    (f, g)$ of functions from $ S$ into $ S$ is a Spanish Couple on $ S$, if\n    they satisfy the following conditions:\n    \\begin{enumerate}\n        \\item Both functions are strictly increasing, i.e. $ f(x) < f(y)$ and\n            $ g(x) < g(y)$ for all $ x$, $ y\\in S$ with $ x < y$;\n        \\item The inequality $ f\\left(g\\left(g\\left(x\\right)\\right)\\right) <\n            g\\left(f\\left(x\\right)\\right)$ holds for all $ x\\in S$.\n    \\end{enumerate}\n    Decide whether there exists a Spanish Couple\n    \\begin{itemize}\n        \\item on the set $ S = \\mathbb{N}$ of positive integers;\n        \\item on the set $ S = \\{a - \\frac {1}{b}: a, b\\in\\mathbb{N}\\}$\n    \\end{itemize}\n}\n\n\\begin{solution}\n    Inspecting the fe immediately gives us $g(g(x))<f(x)$.\n    Any attempt at constructing a pair for $\\mathbb{N}$, fails because\n    eventually $g(x)$ becomes larger than $f(x)$. So there might be something\n    with how $g$ grows that restricts the construction.\\\\\n\n    This idea motivates us to further inspect the fe. We eventually notice\n    that $g^n(x) < f(x)$ for all $n\\in \\mathbb{N}$, and that means $S =\n    \\mathbb{N}$ just won't work.\\\\\n\n    Now we begin to suspect that this is definitely why the second set has be\n    constructed that way. Thinking about the basic construction where $f(x) =\n    x+1$, we see that if we think of $g(x)$ as moving $x$ by some step to the\n    right on the number line, we get a better picture of how $f(g(g(x)))$\n    behaves.\\\\\n\n    And that motivates our solution:\n    \\[\\boxed{f(x) = x+1,\\quad g\\left(a-\\frac{1}{b}\\right) = a - \\frac{1}{b+3^a}}\\] \n\\end{solution}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h211465p1165901}\n{ISL 2007 A4}{E}{\n    Find all functions $ f: \\mathbb{R}^{ + }\\to\\mathbb{R}^{ + }$ satisfying \n    \\[f\\left(x + f\\left(y\\right)\\right) = f\\left(x + y\\right) + f\\left(y\\right)\\] \n    for all pairs of positive reals $ x$ and $ y$. Here, $ \\mathbb{R}^{ + }$\n    denotes the set of all positive reals.\n}\n\n\\begin{solution}[substitution]\n    Set $x = f(y)$, we have\n    \\[\\begin{aligned}\n        f\\left(2f(y)\\right) &= f(2y) + 2f(y)\\\\ \n        \\text{and, } f(x+kf(y)) &= f(x+ky) + kf(y)\n    \\end{aligned}\\]\n    Now setting $y = 2f(y)$, we get\n    \\[\\begin{aligned}\n        f\\left(x+f(2f(y))\\right) &= f\\left(x+2f(y)\\right) + f(2f(y))\\\\\n                                 &=f(x+2y) + 4f(y) + f(2y)\\\\[1em]\n        \\text{Also, } f(x+f(2f(y))) &= f(x+f(2y)+2f(y))\\\\\n        &= f(x+4y) + 2f(y) + f(2y)\\\\[1em]\n        \\implies f(x+4y) &= f(x+2y) + 2f(y) = f(x+2f(y))\\\\\n    \\end{aligned}\\] \n    \\begin{equation}\n        \\boxed{\\therefore f(x+4y) = f(x+2f(y))} \\ \\forall y\\in \\mathbb{R}^+\n    \\end{equation}\n    If $f$ is injective, then we have $\\boxed{f(x) = 2x}$. If not, then\n    suppose $f(a) = f(b)$. Substituting $y = a, b$ we get \n    \\[\\begin{aligned}\n        f(x+a) = f(x+b) \\ \\forall x \\in \\mathbb{R}^+\n    \\end{aligned}\\]\n    Combining it with (1), we get that $f(x)$ is a constant function, and so\n    $\\boxed{f=0}$.\n\\end{solution}\n\n\\begin{solution}[cauchy, Raja Oktovin]\n    For any positive real numbers $ z$, we have that \n    \\[f(x+f(y))+z=f(x+y)+f(y)+z\\] \n    \\[f(f(x+f(y))+z)=f(f(x+y)+f(y)+z)\\] \n    \\[f(x+f(y)+z)+f(x+f(y))=f(x+y+f(y)+z)+f(x+y)\\] \n    \\[f(x+y+z)+f(y)+f(x+y)+f(y)=f(x+2y+z)+f(y)+f(x+y)\\] \n    \\[f(x+y+z)+f(y)=f(x+2y+z)\\] \n\n    \\[\\boxed{f(a)+f(b)=f(a+b)}\\] and by Cauchy in positive reals, then $\n    f(x)=\\alpha x$ for all $ x \\in (0, \\infty)$. Now it's easy to see that $\n    \\alpha=2$, then $ f(x)=2x$ for all positive real numbers $ x$.\n\\end{solution}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h214702p1187155}\n{ISL 2007 A2}{E}{\n    Consider those functions $ f: \\mathbb{N} \\mapsto \\mathbb{N}$ which satisfy the condition\n    \\[f(m + n) \\geq f(m)+f(f(n))-1\\]\n    for all $ m,n \\in \\mathbb{N}.$ Find all possible values of $f(2007)$.\n}\n\n\\begin{solution}\n    Substituting $n=1$, we have \n    \\[f(m+1) \\ge f(m), \\quad f(m+1) \\ge f(f(m))\\]\n    So $f$ is non decreasing. We prove that $f(n) \\le n+1$. Suppose not, so\n    there exists a $n$ for which\n    \\[\\begin{aligned}\n        f(n) \\ge n+2&\\\\\n        \\implies f(2^kn) \\ge 2^kn + 2^k +1& \\qquad \\forall k\n    \\end{aligned}\\] \n    Since $f$ grows without any bounds, there is a $t$ such that $f(2^t+1)>1$.\n    Then we have,\n    \\[\\begin{aligned}\n        f(2^tn+2^t+1) &\\ge f(2^t+1) + f(f(2^tn)) -1\\\\\n                      &\\ge f(2^t+1)-1 +f(2^tn+2^t+1)\\\\\n                      &> f(2^tn+2^t+1)\n    \\end{aligned}\\]\n    A contradiction.\\\\\n\n    So we get a nice bounding for $f(2007)$, that is $\\left\\{1, 2, \\dots\n    2008\\right\\}$. It's time to construct functions for that. For $1\\le k \\le\n    2007$, consider the functions\n    \\[f(n) = \\begin{cases}\n        1 & \\text{if } n < k\\\\\n        n-k+1 & \\text{if } n\\ge k\n    \\end{cases}\\]\n    And for $2008$, consider the function\n    \\[f(n) = \\begin{cases}\n        n+1 & \\text{if } 2007|n\\\\\n        n & \\text{otherwise}\n    \\end{cases}\\]\n    The constructions comes from the idea that we want $f(f(n)) =f(n)$, and we\n    can use $1$'s to push our values to the right.\n\\end{solution}\n\n\n\\newpage\\subsection{Weird Ones}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h289055p1562848}{ISL 2009 A3}{E}{Determine all functions $ f$ from the set of positive integers to the set of positive integers such that, for all positive integers $ a$ and $ b$, there exists a non-degenerate triangle with sides of lengths\n    \\[ a, f(b) \\text{ and } f(b + f(a) - 1).\\]\n(A triangle is non-degenerate if its vertices are not collinear.)}\n\n\\solu{$ f(1)>1 \\implies\\ f $ is periodic $ \\implies $ repeatation $ \\implies $ contradiction.\\\\\n$ f(2)>2 \\implies $ strictly increasing $ \\implies $ repeatation.}\n\n\n\n\\prob{https://artofproblemsolving.com/community/c6h1558131p9513099}{USA TST 2018 P2}{H}{Find all functions $f: \\mathbb{Z}^2 \\to [0, 1]$ such that for any integers $x$ and $y$, \\[f(x, y) = \\frac{f(x - 1, y) + f(x, y - 1)}{2}.\\]}\n\n\\solu{We know that the function has to be a constant function. So it is a intuitive idea considering the difference of two values of the function. Again as we wish to show that this difference is $ 0 $, we have to use either equality of limit. As equality is quite ambiguous in this problem, we approach with limits. We see that $ f(x,y) $ can be written as a term depending on the values of the $ 3 $rd quarter of the plane with $ (x, y) $ as its origin. With infinite values in our hand, we try bounding.}\n\n\n\\prob{https://artofproblemsolving.com/community/c6h2192982p16443789}\n{IMEO 2020 P3}{M}{\n    Find all functions $f:\\mathbb{R^+} \\to \\mathbb{R^+}$ such that for all\n    positive real $x, y$ holds\n    \\[xf(x)+yf(y)=(x+y)f\\left(\\frac{x^2+y^2}{x+y}\\right)\\]\n}\n\n\\begin{solution}\n    Note that \\[\\frac{xf(x)+yf(y)}{x+y} = f\\left(\\frac{x^2+y^2}{x+y}\\right)\\] \n    Which looks just like a linear form. Also since we know that the solution\n    is probably only $f(x) = ax+b$, we pursue this idea. \\\\\n\n    It can be proved that all the rational points lie on a line. Now what if a\n    irrational lies outside of the line?\n\\end{solution}\n\n\\begin{solution}[MarkBcc168, geometric]\n    Our first step is to do Vieta Jumping on the functional equation. The main\n    result from this is the following. \n\n    \\begin{claim}\n        $af(a) - bf(b) = (a-b)f(a+b)$ for any $a,b\\in\\mathbb{R}^+$.\n    \\end{claim}\n\n    \\begin{prooof}\n        Fix $t,k\\in\\mathbb{R}^+$ where $t<k$. Let $g(x)=\\tfrac{x^2+t^2}{x+t}$.\n        Since $\\lim_{x\\to\\infty}g(x)=\\infty$ and $g(t)=t$, there exists $a$\n        such that $g(a) = \\tfrac{t^2+a^2}{t+a}=k$. Moreover, by Vieta's\n        Jumping, $g(k-a)=k$. Thus, by considering\n\n        \\[\\begin{array}{rcrcl} \n            P(t,a) & \\implies & tf(t) + af(a)&=&(a+t)f(k)\\qquad\\text{ and}\n            \\\\[4pt] P(t,k-a) & \\implies & tf(t) + (k-a)f(k-a)&=&(k-a+t)f(k), \n        \\end{array}\\]\n\n        we get that\n        \\[af(a) - (k-a)f(k-a) = (2a-k)f(k)\\]\n        for any $a,k$ such that $k>a$. Thus, by setting $b=k-a$, we get the\n        desired claim. \n    \\end{prooof}\n\n    Now let's do some geometry. Let $P_x = (x,f(x))$. Then the claim above\n    implies that $P_a, P_b, P_{a+b}$ are colinear whenever\n    $a,b\\in\\mathbb{R}^+$.\\\\\n\n    Fix any pairwise distinct $a,b,c\\in\\mathbb{R}^+$. Set $A=P_a$, $B=P_b$,\n    $C=P_c$, $D=P_{b+c}$, $E=P_{c+a}$, and $F=P_{a+b}$. By the claim, $D\\in\n    BC$, $E\\in CA$, $F\\in AB$, and $AD,BE,CF$ are concurrent at $P_{a+b+c}$.\n    However, we claim that \n\n    \\begin{claim}\n        $D,E,F$ are colinear.\n    \\end{claim}\n\n    \\begin{prooof}\n        If $A,B,C$ are colinear, then the result is trivial. Otherwise, we use\n        Menelaus theorem. Observe that\n        $$\\frac{\\overline{BD}}{\\overline{DC}} = \\frac{b - (b+c)}{(b+c)-c} =\n        -\\frac bc$$hence multiplying the result cyclically gives the result. \n    \\end{prooof}\n\n    By Ceva's theorem, both $D,E,F$ being colinear and $AD,BE,CF$ being\n    concurrent can only happen when $A,B,C$ are colinear. This means that\n    $(a,f(a))$, $(b,f(b))$, $(c,f(c))$ are colinear for any\n    $a,b,c\\in\\mathbb{R}^+$. This concludes, say by varying $c$, that $f$ must\n    be linear.\n\\end{solution}\n", "meta": {"hexsha": "f78f9a568803ce89c5f6c7eb03455693f8ffa544", "size": 24101, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "alg/sec1_fe.tex", "max_stars_repo_name": "M-Ahsan-Al-Mahir/BCS_Question_Bank", "max_stars_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2020-10-14T17:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T19:47:04.000Z", "max_issues_repo_path": "alg/sec1_fe.tex", "max_issues_repo_name": "AnglyPascal/BCS_Question_Bank", "max_issues_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "alg/sec1_fe.tex", "max_forks_repo_name": "AnglyPascal/BCS_Question_Bank", "max_forks_repo_head_hexsha": "83ff9b542999386ea182863e4f25f0b488d3984f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-10-15T08:59:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-27T15:19:26.000Z", "avg_line_length": 47.6304347826, "max_line_length": 507, "alphanum_fraction": 0.6078585951, "num_tokens": 7947, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4000960695377206}}
{"text": "\\chapter{Pattern formation in a pluricellular system}\\label{cap:3}\n Previous studies on ROPs system focused the attention on one single cell only. Arabidopsis root is actually composed by a large number of cells and understanding how groups of cells communicate with one another during the development of multi-cellular organism acquires great importance. Moreover, one of the main factors influencing pattern formation is the hormone auxin, whose dynamics inside the cell is driven by communication between neighbouring cells and some of their (different) physical characteristics. For these reasons, extending the singular cell model into a pluricellular model is believed to lead to a more robust model, in order to better understand how the self-organized process of hair formation in the root epidermis happens. This work represents one of the first attempt on the topic, based on physical considerations and on other works on similar physical quantities as well as on modeling assumptions on the system.\n\n In the first section we give a physical interpretation of the model under consideration, paying particular attention to the communication between neighboring cells and providing a physical meaning to the new parameters added to the ROPs system. We detail the numerical methods applied to the pluricellular model, developing an iterative algorithm inspired by a Robin-Robin Domain Decomposition (DD) method. To justify our implementation strategy, we also present a Robin-Robin DD method applied to a two cells system. Finally, we provide an extensive numerical assessment by applying the proposed model to different contexts in the result section. The first simulations serve as benchmark to tune all the new parameters added to the system, characterizing the communication channels between cells. Then, after the selection of a proper set of parameters, we validate the new method changing parameteres the ROPs activation and deactivation processes.\n\n\\section{Physical model}\\label{sec:PluriMod}\n\n\\begin{figure}\n  \\centering\n  % \\includegraphics[scale = 0.3]{cap3/4cellscheme.jpeg}\n  \\includegraphics[scale = 0.3]{cap3/scheme.jpeg}\n  % \\includegraphics[scale = 0.3]{cap3/scheme1.jpeg}\n  \\caption{Sktetch of a four cells scheme with communicating flows.}\n  \\label{fig:2cell}\n\\end{figure}\nWe consider the root-hair cell projection onto a 2D rectangular domain as in Chapter \\ref{cap:2}. A system of four cells is schematically presented in Figure \\ref{fig:2cell}. We can see that each cell has longitudinal and transverse boundaries in common with close cells.\nWe recall the single cellular model, namely:\n\\begin{equation} \\label{eq:singModel}\n\\left\\lbrace\n\\begin{matrix}\n  \\begin{aligned}\n    & \\partial_t u = \\Tilde{D_1} \\Delta_s u + \\Tilde{a_1} u + \\Tilde{b_1} v + \\Tilde{c_1} u^2 v & \\ \\text{in} \\ \\Omega\\\\\n    & \\partial_t v = \\Tilde{D_2} \\Delta_s v + \\Tilde{a_2} v + \\Tilde{b_2} u + \\Tilde{c_2} u^2 v + f_2 & \\ \\text{in} \\ \\Omega \\\\\n    & \\Tilde{D_1} \\nabla_s u \\cdot \\mathbf{n} = 0 & \\ \\text{on} \\ \\partial \\Omega \\\\\n    & \\Tilde{D_2} \\nabla_s v \\cdot \\mathbf{n} = 0 & \\ \\text{on} \\ \\partial \\Omega.\n  \\end{aligned}\n\\end{matrix}\n\\right.\n\\end{equation}\nNo-flux on $\\partial \\Omega$, namely Neumann homogeneous boundary conditions, characterizes the system behaviour along the cell boundary.\n\nIn the multi-cellular model, communication between cells is represented by allowed flux of ROPs, active and inactive, through localized channels along boundaries between neighboring cells.\n\nWe define as neighbor of cell $\\Omega_i$ the set of cells with index in $\\mathcal{N}_i = \\{ j : \\partial \\Omega_j  \\cap \\partial \\Omega_i \\neq \\emptyset \\}$. The flux of concentration of active and inactive ROPs $(u_i, v_i)$ is proportional to the difference of concentration $(u_j, v_j)$ in neighbouring cells for $j \\ \\in \\ \\mathcal{N}_i$.\n\nWe formulate the new model still focusing on one single cell domain $\\Omega_i$, taking into account the new flux generated from the discrepancy of concentrations with the neighboring cells. The new flux results in adding a non-homogeneous Neumann boundary condition on the common interfaces, as follows:\n\\begin{equation} \\label{eq:pluriModel}\n\\left\\lbrace\n\\begin{matrix}\n  \\begin{aligned}\n    & \\partial_t u_i = \\Tilde{D_1} \\Delta_s u_i + \\Tilde{a_1} u_i + \\Tilde{b_1} v_i + \\Tilde{c_1} (u_i)^2 v_i & \\ \\text{in} \\ \\Omega_i\\\\[6pt]\n    & \\partial_t v_i = \\Tilde{D_2} \\Delta_s v_i + \\Tilde{a_2} v_i + \\Tilde{b_2} u_i + \\Tilde{c_2} (u_i)^2 v_i + f_2 & \\ \\text{in} \\ \\Omega_i \\\\[6pt]\n    & \\Tilde{D_1} \\nabla_s u_i \\cdot \\mathbf{n} = 0 & \\ on \\ \\partial \\Omega_i \\backslash \\cup_{j \\in \\mathcal{N}_i} \\Gamma_{j,i} \\\\[6pt]\n    & \\Tilde{D_2} \\nabla_s v_i \\cdot \\mathbf{n} = 0 & \\ on \\ \\partial \\Omega_i \\backslash \\cup_{j \\in \\mathcal{N}_i} \\Gamma_{j,i} \\\\[6pt]\n    & \\Tilde{D_1} \\nabla_s u_i \\cdot \\mathbf{n} = \\beta_{uRR} \\ \\alpha_{uRR} \\left(u_j - u_i \\right) & \\ on \\ \\Gamma_{j,i} \\ \\forall j \\in  \\mathcal{N}_i \\\\[6pt]\n    & \\Tilde{D_2} \\nabla_s v_i \\cdot \\mathbf{n} = \\beta_{vRR} \\ \\alpha_{vRR} \\left(v_j - v_i \\right) & \\ on \\ \\Gamma_{j,i}\\ \\forall j \\in  \\mathcal{N}_i ,\n  \\end{aligned}\n\\end{matrix}\n\\right.\n\\end{equation}\nwhere we define as $(u_i, v_i)$ the concentrations of active and inactive ROPs restricted to cell $\\Omega_i$: $(u_i, v_i): \\Omega_i \\times \\left(0, T_{max} \\right) \\longrightarrow \\mathds{R}^2$ and $\\Gamma_{j,i}$ represents the common side between cell $\\Omega_i$ and cell $\\Omega_j \\ \\in \\mathcal{N}_i $, therefore defined as: $\\Gamma_{j,i} = \\partial \\Omega_i \\cap \\partial \\Omega_j$.\n\nEach of the neighboring cells follows the same model for hair formation, meaning that system in \\eqref{eq:pluriModel} holds $\\forall \\ i$ cells composing the pluricellular system. As a consequence, the newly defined boundary conditions is coupled with the solutions $(u_j, v_j)$ with $j \\ \\in \\mathcal{N}_i$. Therefore, the pluricellular system requires a proper iterative method for setting correctly boundary conditions depending on solutions in the neighboring cells.\n\nNot communicating with other RH cells boundaries have as before no-flux. The new boundary conditions are characterized by a function and a coefficient for both active active ROPs $u$ and inactive ROPs $v$, having the same meaning:\n\\begin{itemize}\n  \\item $\\beta_{u/v RR} \\ [\\frac{1}{\\mu m^2}]$ are indicator functions defined on boundaries of cells, equal to $1$ where the communicating channels are open and $0$ where  no-flux is assumed;\n  \\item $\\alpha_{u/v RR} \\ [\\frac{1}{\\mu m}]$ are transport efficiency coefficients, representing a sort of flux quantity allowed through channels.\n  \\end{itemize}\nThese channel parameters aim at representing the average active transport along the sides of confining cells, set equal to the flux of proteins from one cell to the neighbouring ones.\n\nWe have no physical insight on previously cited functions modeling open channels for ROPs. A whole set of simulations for the proper tuning of parameters is required, in order to find a sufficiently plausible setting of the system.\n\\section{Numerical treatment}\nThe communication between cells requires a proper iterative algorithm in order to deal with the mutual interplay between confining cells.\n\nEvery subdomain $\\Omega_i$ of the pluricellular system $\\Omega$ represents the single cell and the original system of equations in \\eqref{eq:final} is solved in $\\Omega_i$ for all $i = 1, ..., N$. We solve such systems by means of the semi-implicit method described in Section \\ref{sec:SI method}. Let us consider the weak formulation restricted to $\\Omega_i$, defining the functional space $V_i = \\{ w_i \\in \\ H^1\\left(\\Omega_i\\right)\\}$, the finite element subspace $V_{i,h} \\subset V_i $ and the time interval discretization used in Section \\ref{sec:SI method}. In particular, we divide the time interval $\\left[0, T_{max}\\right]$ in $N_{max}$ time steps such that $t^n = n \\Delta t$ with $\\Delta t = T_{max} / N_{max}  $. We rewrite the full discretized formulation, identifying $u_{i,h}$ with $u_h|_{\\Omega_i}$, as:\n\ngiven the initial state $(u_{i,h}^0, v_{i,h}^0) $, find $(u_{i,h}^{n+1}, v_{i,h}^{n+1}) \\ \\in V_{i,h} \\times V_{i,h}$ such that\n\\begin{equation} \\label{eq:fullGalerkin}\n\\left\\lbrace\n\\begin{matrix}\n\\begin{aligned}\n  a_{i,u}(u_{i,h}^{n+1}, w_{i,h}) + b_{i,u}(v_{i,h}^{n+1}, w_{i,h}) + c_{i,u}(v_{i,h}^{n+1}, w_{i,h}) = f_{i,u}(w_{i,h}) \\ \\forall \\ w_{i,h} \\ \\in V_{i,h} \\\\[6pt]\n a_{i,v}(v_{i,h}^{n+1}, w_{i,h}) + b_{i,v}(u_{i,h}^{n+1}, w_{i,h}) + c_{i,v}(v_{i,h}^{n+1}, w_{i,h}) = f_{i,v}(w_{i,h}) \\ \\forall \\ w_{i,h} \\ \\in V_{i,h},\n\\end{aligned}\n\\end{matrix}\n\\right.\n\\end{equation}\n$\\forall n = 0, ... N_{max}$, where\n\\begin{subequations} \\label{eq:Gvarfmono}\n\\begin{align}\n    a_{i,u}(u_{i,h}^{n+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_{i,h}^{n+1} w_{i,h} + \\Tilde{D}_1 \\nabla_s u_{i,h}^{n+1} \\cdot w_{i,h} - \\Tilde{a}_1 u_i^{n+1} w_{i,h} \\right) \\label{Gmono:au}\\\\ - & \\int_{\\partial \\Omega_i}\\left(\\Tilde{D}_1 \\nabla_s u_{i,h}^{n+1} \\cdot \\mathbf{n} w_{i,h}\\right)  \\nonumber\\\\\n    b_{i,u}(v_{i,h}^{n+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left(- \\Tilde{b}_1 v_{i,h} w_{i,h} \\right)  \\label{Gmono:bu} \\\\\n    c_{i,u}(v_{i,h}^{n+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left(- \\Tilde{c}_1 (u_{i,h}^{n})^2  v_{i,h}^{n+1} w_{i,h} \\right) \\label{Gmono:cu} \\\\[6pt]\n    a_{i,v}(v_{i,h}^{n+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left(\\frac{1}{\\Delta t} v_{i,h}^{n+1} w_{i,h} + \\Tilde{D}_2 \\nabla_s v_{i,h}^{n+1} \\cdot w_{i,h} - \\Tilde{a}_2 v_i^{n+1} w_{i,h} \\right) \\label{Gmono:av} \\\\ - &  \\int_{\\partial \\Omega_i} \\left( \\Tilde{D}_1 \\nabla_s u_{i,h}^{n+1} \\cdot \\mathbf{n} w_{i,h} \\right) \\nonumber\\\\\n    b_{i,v}(v_{i,h}^{n+1}, w_{i,h}) = &\\int_{\\Omega_i} \\left( - \\Tilde{b}_2 u_{i,h} w_{i,h} \\right) \\label{Gmono:bv}\\\\\n    c_{i,v}(v_{i,h}^{n+1}, w_{i,h}) =& \\int_{\\Omega_i} \\left( - \\Tilde{c}_2 (u_{i,h}^{n})^2  v_{i,h}^{n+1} w_{i,h} \\right) \\label{Gmono:cv}\\\\[6pt]\n    f_{i,u}(w_{i,h}) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_{i,h}^n \\ w_{i,h} \\right) \\label{Gmono:fu}\\\\\n    f_{i,v}(w_{i,h}) = & \\int_{\\Omega} \\left( \\frac{1}{\\Delta t} v_{i,h}^n \\ w_{i,h} + f_2 w_{i,h} \\right). \\label{Gmono:fv}\n\\end{align}\n\\end{subequations}\n\nThe introduction of different boundary conditions will require to modify the bilinear forms \\eqref{Gmono:au} and \\eqref{Gmono:av} and to add contributions in the right hand sides \\eqref{Gmono:fu} and \\eqref{Gmono:fv}.\n\nTo this aim, we synthetically rewrite the model problem \\eqref{eq:fullGalerkin}, assuming generic boundary conditions, through a linear operator $\\mathcal{L}$ in the following way:\n\nGiven the initial state $(u_i^0, v_i^0)$, find $(u_i^{n+1}, v_i^{n+1}) \\ \\in \\Omega_i$ such that:\n\\begin{equation}\\label{eq:modelpb}\n% \\begin{cases}\n\\mathcal{L}^n (u_i^{n+1}, v_i^{n+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_i\n% \\Tilde{D_1} \\nabla_s u_i^{n+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_i \\\\\n% \\Tilde{D_2} \\nabla_s v_i^{n+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_i\n% \\end{cases}\n\\end{equation}\n$\\forall n = 0, ... N_{max}$.\n\n\\subsection{The domain decomposition method}\nWe briefly recall the domain decompostion method \\cite{DD:QuarteroniValli}, one of the main mathematical tools used to solve boundary value problems into different subdomains, belonging or not to different physics. The domain decomposition method is based on partitioning the computational domain into subdomains, with or without overlapping parts, and introducing transmission conditions at common interfaces. The division of the domain can be driven by physical reason, e.g., one part of the domain is characterized by a different physical model than the other, such as in fluid-structure interaction problems \\cite{CV:RR2, CV:RR3}; or it can be driven by optimization reasons, e.g, it could be easier to solve the same problem in more geometrically regular subdomains with respect in the original one, characterized instead by a non-standard shape.\n\nTo understand the general procedure of the domain decompostion method, we consider a general differential problem of the form:\n\\begin{equation} \\label{eq:mono}\n  \\mathcal{L} u = f \\ \\text{in} \\ \\Omega,\n\\end{equation}\nwhere $\\mathcal{L}$ is a partial differential operator, $f$ is a given datum and u is the unknown function. We partition the domain $\\Omega$ into two disjoint domains $\\Omega_1$ and $\\Omega_2$ and we denote as $\\Gamma$ the common boundary. Denoting by $u_i$ the restriction of $u$ to $\\Omega_i$ for $i = 1,2$, it follows that:\n\\begin{equation} \\begin{aligned}\n  \\mathcal{L} u_1 = f \\ \\text{in} \\ \\Omega_1\\\\\n  \\mathcal{L} u_2 = f \\ \\text{in} \\ \\Omega_2 .\n\\end{aligned}\\end{equation}\nIn order to guarantee the exact equivalence with \\eqref{eq:mono}, we need to enforce transmission conditions between $u_1$ and $u_2$ across $\\Gamma$. Depending on the physical problem under analysis, the usual conditions to impose are the continuity of the solutions and the continuity of normal fluxes (normal stress) at the boundaries \\cite{DD:QuarteroniValli}: \\begin{align}\n  u_1 & = u_2 \\ \\text{on} \\ \\Gamma \\label{eq:DBC}\n  \\\\\n  \\frac{\\partial u_1}{\\partial n_L} & = \\frac{\\partial u_2}{\\partial n_L} \\ \\text{on} \\ \\Gamma, \\label{eq:NBC}\n\\end{align}\nwith normal derivative in \\eqref{eq:NBC} defined by the differential problem under analysis.\n\nThen, one may solve the multi-domain problem by iterative procedures. To this aim, we introduce a sequence of subproblems in $\\Omega_1$ and $\\Omega_2$ so that the two transmission conditions provide a Dirichlet \\eqref{eq:DBC} or a Neumann \\eqref{eq:NBC} boundary condition to impose on the internal boundary $\\Gamma$. The assignment of the coupling conditions at the common interface is the key part of the domain decomposition method used. Indeed, for example, we distinguish Dirichlet-Neumann (DN) method, where continuity of solutions \\eqref{eq:DBC} is imposed in the subproblem on $\\Omega_1$ and continuity of fluxes \\eqref{eq:NBC} on $\\Omega_2$, while Neumann-Dirichlet (ND) method consists in the opposite impositions. In general, two sequence of functions $ \\{u_1^k\\}, \\{u_2^k\\}$ are generated starting from a initial guess $ \\{u_1^0\\}, \\{u_2^0\\}$ which will converge to $u_1$ and $u_2$, respectively. At convergence the solution is equivalent to the one obtained solving the monolithic system, with guaranteed continuity of solutions and normal stress at the common interface.\n\nOne class of iterative procedures among domain decompostion methods which is of big interest for the model we are interested in is the Robin-Robin (RR) method. It is based on the Robin transmission conditions and generalizes the Dirichlet-Neumann approach. Robin boundary conditon is a linear combination of interface conditions \\eqref{eq:DBC} and \\eqref{eq:NBC}, with positive coefficients $\\alpha_1, \\alpha_2$ characterizing the RR scheme as follows:\n\\begin{equation}\\begin{aligned}\n  \\frac{\\partial u_1}{\\partial n_L}  + \\alpha_1 u_1 = \\frac{\\partial u_2}{\\partial n_L} + \\alpha_1 u_2 \\ \\text{on} \\ \\Gamma\n  \\\\\n  \\frac{\\partial u_2}{\\partial n_L} + \\alpha_2 u_2  =   \\frac{\\partial u_1}{\\partial n_L}  + \\alpha_2 u_1 \\ \\text{on} \\ \\Gamma.\n\\end{aligned} \\end{equation}\nAt convergence of sequence $\\{u_1^k\\}, \\{u_2^k\\}$, a solution is found, equivalent to $u_1$ and $u_2$ respectively, continuous at the interface and with same fluxes on $\\Gamma$.\n\nThe RR family of partitioned procedure has been introduced with the aim of getting better convergence properties than with the DN or ND classical schemes. The velocity of convergence of RR method depends on the choice of coefficients $\\alpha_1, \\alpha_2$. Setting $\\alpha_1$ and $\\alpha_2$ properly one can recover DN and ND (for example, setting $\\alpha_1 = 0$ and $\\alpha_2 = \\infty$ leads to Neumann-Dirichlet method). One main issue is thus the identification of suitable combinations of parameters $\\alpha_1, \\alpha_2$ to improve the convergence properties of the classical DN scheme \\cite{hou:RR, CV:RRnew}. We decided not to focus on the choice of this parameters, since classic Robin-Robin method was chosen only as a reference method for the  implementation of a new model and we are not interested in optimizing its implementation. In the next subsection we present the RR algorithm for the boundary value problem \\eqref{eq:modelpb}.\n\n\\subsection{Classic Robin-Robin algorithm}\\label{sec:RRclassic}\nWe take as reference method a classic domain decomposition algorithm with Robin boundary conditions. Focusing on a pluricellular system composed by two cells, the whole domain $\\Omega$ is naturally partitioned into the two non-overlapping subdomains, corresponding to the two cells $\\Omega_1$ and $\\Omega_2$, with a common interface $\\Gamma$; inside each sub-domain the model problem \\eqref{eq:modelpb} is solved with no-flux boundary condition on the external boundaries and, differently from the multi-cellular model in \\eqref{eq:pluriModel}, free-flux and continuity of the solutions in the two domains is assumed on the common side. The two interface conditions are identified by two Robin type boundary conditions on $\\Gamma$, one for each sub-domain. We refer to $\\alpha_{u/v RR}$ as coefficient characterizing Robin boundary data. The $^n$ notation implies the solution is evaluated at time step $t^n = n \\Delta t$, whereas $^k$ notation indicates the iteration of the iterative method. Robin-Robin domain decomposition algorithm is solved at every time-step and is formulated as follows:\n\ngiven the initial concentrations $(u_1^0, v_1^0)$ and $(u_2^0, v_2^0)$, at the n-th time step, find $(u_i^{n+1}, v_i^{n+1}) \\ \\in V_{i,h} \\ \\forall i = 1,2$ such that solve the iterative method:\n\\begin{equation} \\label{eq:RR}\n\\begin{aligned}\n& \\begin{cases}\n\\mathcal{L}^n (u_1^{k+1}, v_1^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_1 \\\\[6pt]\n\\Tilde{D_1} \\nabla_s u_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\[6pt]\n\\alpha_{uRR} u_1^{k+1} +\\Tilde{D_1} \\displaystyle{\\partial u_1^{k+1} \\over \\partial \\mathbf{n}} = \\alpha_{uRR} u_2^{k} +\\Tilde{D_1}\\displaystyle{\\partial u_2^{k}\\over\\partial \\mathbf{n}}  \\ \\text{on} \\ \\Gamma \\\\[6pt]\n\\Tilde{D_2} \\nabla_s v_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma\\\\[6pt]\n\\alpha_{vRR} v_1^{k+1} +\\Tilde{D_2} \\displaystyle{\\partial v_1^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{vRR} v_2^{k} +\\Tilde{D_2} \\displaystyle{\\partial v_2^{k}\\over\\partial \\mathbf{n}}  \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\\\[6pt]\n& \\begin{cases}\n\\mathcal{L}^n (u_2^{k+1}, v_2^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_2 \\\\[6pt]\n\\Tilde{D_1} \\nabla_s u_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma \\\\[6pt]\n\\alpha_{uRR} u_2^{k+1} + \\Tilde{D_1} \\displaystyle{\\partial u_2^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{uRR} u_1^{k+1} + \\Tilde{D_1} \\displaystyle{\\partial u_1^{k+1}\\over\\partial \\mathbf{n}}  \\ \\text{on} \\ \\Gamma \\\\[6pt]\n\\Tilde{D_2} \\nabla_s v_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma\\\\[6pt]\n\\alpha_{vRR} v_2^{k+1} + \\Tilde{D_2} \\displaystyle{\\partial v_2^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{vRR} v_1^{k+1} + \\Tilde{D_2} \\displaystyle{\\partial v_1^{k+1}\\over\\partial \\mathbf{n}}  \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\end{aligned}\\end{equation}\nstarting from $(u_2^{k = 0}, v_2^{k = 0}) = (u_1^n, v_1^n)$  for $k \\geq 0$ until convergence and update $(u_i^{n+1}, v_i^{n+1}) = (u_i^{k+1}, v_i^{k+1})$.\n\nThe solution $(u_i^{n+1}, v_i^{n+1})$ is updated with the solution found at the end of the iterations. From now on, in order to simplify the notation, we refer to $(u_i, v_i)$ as the unknowns $(u_i^{k+1}, v_i^{k+1})$ at each iteration and we omit the reference to the finite element space $V_h$.\n\nRobin boundary conditions in the system modify the bilinear form characterizing the Galerkin formulation. In particular, \\eqref{Gmono:au} and \\eqref{Gmono:av} become:\n\\begin{equation*}\\begin{aligned}\n    a_{i,u}(u_i, w) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_i w + \\Tilde{D}_1 \\nabla_s u_i \\cdot w - \\Tilde{a}_1 u_i w \\right) - \\int_{\\partial \\Omega_i} \\left(\\Tilde{D}_1 \\nabla_s u_i \\cdot \\mathbf{n} w \\right) \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_i w + \\Tilde{D}_1 \\nabla_s u_i \\cdot w - \\Tilde{a}_1 u_i w \\right) - \\int_{\\Gamma} \\left(\\alpha_{uRR} u_j^{k} +\\Tilde{D_1} \\frac{\\partial u_j^{k}}{\\partial \\mathbf{n}} - \\alpha_{uRR} u_i \\right) w\n    \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_i w + \\Tilde{D}_1 \\nabla_s u_i \\cdot w - \\Tilde{a}_1 u_i w\\right) + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_i w \\right)  - \\int_{\\Gamma} \\left( \\alpha_{uRR} u_j^k w + \\Tilde{D_1} \\frac{\\partial u_j^{k}}{\\partial \\mathbf{n}} w \\right) \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_i w + \\Tilde{D}_1 \\nabla_s u_i \\cdot w - \\Tilde{a}_1 u_i w\\right) + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_i w \\right)  - \\int_{\\Gamma} \\left( \\alpha_{uRR} u_j^k w \\right) \\\\\n    + & \\left( a_u(u_j, w) + b_u(v_j,w) + c_u(v_j, w)- f_u(w) \\right),\n\\\\[6pt]\n    a_{i,v}(v_i, w) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} v_i w + \\Tilde{D}_2 \\nabla_s v_i \\cdot w - \\Tilde{a}_2 v_i w \\right) - \\int_{\\partial \\Omega_i} \\left(\\Tilde{D}_2 \\nabla_s v_i \\cdot \\mathbf{n} w \\right) \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} v_i w + \\Tilde{D}_2 \\nabla_s v_i \\cdot w - \\Tilde{a}_2 v_i w \\right) - \\int_{\\Gamma} \\left(\\alpha_{vRR} v_j^{k} w +\\Tilde{D_2} \\frac{\\partial v_j^{k}}{\\partial \\mathbf{n}} w - \\alpha_{vRR} v_i w \\right)\n    \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} v_i w + \\Tilde{D}_2 \\nabla_s v_i \\cdot w - \\Tilde{a}_2 v_i w\\right) + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_i w \\right)  - \\int_{\\Gamma} \\left( \\alpha_{vRR} v_j^k w + \\Tilde{D_2} \\frac{\\partial v_j^{k}}{\\partial \\mathbf{n}} w \\right) \\\\\n    = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} v_i w + \\Tilde{D}_2 \\nabla_s v_i \\cdot w - \\Tilde{a}_2 v_i w\\right) + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_i w \\right)  - \\int_{\\Gamma} \\left( \\alpha_{vRR} v_j^k w \\right) \\\\\n    + & \\left( a_v(v_j, w) + b_v(u_j,w) + c_v(v_j, w)- f_v( w) \\right).\n\\end{aligned}\\end{equation*}\nIn the last lines, the weak normal derivative of $u_j$ and $v_j$ are substituted with the residual from the proper combination of the bilinear forms on domain $\\Omega_j$ \\cite{DD:QuarteroniValli}.\nAs a consequence, we define new bilinear forms from \\eqref{Gmono:au}, \\eqref{Gmono:av}, \\eqref{Gmono:fu} and  \\eqref{Gmono:fv} , adding Robin-Robin algorithm contribute as follows:\n\\begin{equation}\\label{eq:au&avRR}\n\\begin{aligned}\n    a_{i,u}^{RR}(u_{i,h}^{k+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_{i,h}^{k+1} w_{i,h} + \\Tilde{D}_1 \\nabla_s u_{i,h}^{k+1} \\cdot w_{i,h} - \\Tilde{a}_1 u_i^{k+1} w_{i,h} \\right)  \\\\\n    & + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_{i,h}^{k+1} w_{i,h} \\right) \\\\\n    = & a_{i,u}(u_{i,h}^{k+1}, w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_{i,h}^{k+1} w_{i,h} \\right), \\\\\n    a_{i,v}^{RR}(v_{i,h}^{k+1}, w_{i,h}) = & \\int_{\\Omega_i} \\left(\\frac{1}{\\Delta t} v_{i,h}^{k+1} w_{i,h} + \\Tilde{D}_2 \\nabla_s v_{i,h}^{k+1} \\cdot w_{i,h} - \\Tilde{a}_2 v_i^{k+1} w_{i,h} \\right) \\\\\n     & + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_{i,h}^{k+1} w_{i,h} \\right) \\\\\n     = & a_{i,v}(v_{i,h}^{k+1}, w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_{i,h}^{k+1} w_{i,h} \\right),\n\\end{aligned}\n\\end{equation}\n\n\\begin{equation} \\label{eq:fu&fvRR}\n\\begin{aligned}\nf_{i,u}^{RRc}(w_{i,h}) = & \\int_{\\Omega_i} \\left( \\frac{1}{\\Delta t} u_{i,h}^n \\ w_{i,h} \\right)  + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_{j,h}^{k} w_{i,h} \\right) + \\int_{\\Gamma} \\Tilde{D_1} \\frac{\\partial u_j^k}{\\partial n} w_{i,h} \\\\\n= & f_{i,u}(w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{uRR} u_{j,h}^{k} w_{i,h} \\right) + \\int_{\\Gamma} \\Tilde{D_1} \\frac{\\partial u_j^k}{\\partial n} w_{i,h}, \\\\\nf_{i,v}^{RRc}(w_{i,h}) = & \\int_{\\Omega} \\left( \\frac{1}{\\Delta t} v_{i,h}^n \\ w_{i,h} + f_2 w_{i,h} \\right) + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_{j,h}^{k} w_{i,h} \\right) + \\int_{\\Gamma} \\Tilde{D_2} \\frac{\\partial v_j^k}{\\partial n} w_{i,h} \\\\\n= & f_{i,v}(w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{vRR} v_{j,h}^{k} w_{i,h} \\right) + \\int_{\\Gamma} \\Tilde{D_2} \\frac{\\partial v_j^k}{\\partial n} w_{i,h},\n\\end{aligned}\n\\end{equation}\nimplying that each weak normal derivative is computed in the residual form:\n\\begin{equation}\\label{eq:weak normal der}\\begin{aligned}\n    \\int_{\\Gamma} \\Tilde{D_1} \\frac{\\partial u_j^k}{\\partial n} w_{j,h} = \\left( a_u(u_j^k, w_{j,h}) + b_u(v_j^k,w_{j,h}) + c_u(v_j^k, w_{j,h})- f_u(w_{j,h}) \\right), \\\\\n    \\int_{\\Gamma} \\Tilde{D_2} \\frac{\\partial v_j^k}{\\partial n} w_{j,h} = \\left( a_v(v_j^k, w_{j,h}) + b_v(u_j^k,w_{j,h}) + c_v(v_j^k, w_{j,h})- f_v(w_{j,h}) \\right).\n\\end{aligned}\\end{equation}\nWe remark that in \\eqref{eq:weak normal der} test functions $w_{j,h}$ and variables contributing to the integral $u_{j,h}, v_{j,h}$ are defined in the finite element space $V_{j,h}$, whereas $f_{u,i}, f_{v,i}$ in \\eqref{eq:fu&fvRR} are linear functional of functions $w_{i,h} \\ \\in V_{i,h}$. The difficulty in dealing with variables from different functional spaces is solved through the use of a linear extension operator. We define $\\mathcal{I}_{i,j}$ as the extension operator from finite element space $V_{i,h}$ to $V_{j,h}$: it extends by zero function from one space to the other. Formally then \\eqref{eq:fu&fvRR} is:\n\\begin{align}\\label{eq:fu&fvRRInt}\n f_{i,u}^{RRc}(w_{i,h}) & = f_{i,u}(w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{uRR} \\mathcal{I}_{i,j} u_{j,h}^{k} \\mathcal{I}_{i,j}w_{j,h} \\right) +  \\left( a_u(\\mathcal{I}_{i,j} u_j^k,\\mathcal{I}_{i,j} w_{j,h}) \\right. \\nonumber\n\\\\ & \\left. {} + b_u(\\mathcal{I}_{i,j}v_j^k, \\mathcal{I}_{i,j} w_{j,h}) + c_u(\\mathcal{I}_{i,j} v_j^k, \\mathcal{I}_{i,j} w_{j,h})- f_u(\\mathcal{I}_{i,j} w_{j,h}) \\right), \\\\\nf_{i,v}^{RRc}(w_{i,h}) & = f_{i,v}(w_{i,h}) + \\int_{\\Gamma} \\left(\\alpha_{vRR} \\mathcal{I}_{i,j} v_{j,h}^{k} \\mathcal{I}_{i,j} w_{j,h} \\right) + \\left( a_v(v_j^k, w_{j,h})  \\right. \\nonumber\n\\\\ & \\left. {} + b_v(u_j^k,w_{j,h}) + c_v(v_j^k, w_{j,h})- f_v(w_{j,h}) \\right).\n\\end{align}\n\nWe recover the algebraic formulation analogously as done in Section \\ref{sec:num_cap2}, being:\n\\begin{equation}\n        u_{i,h}^{k+1}(x,y) = \\sum_{l=i}^{N_h} u_{i,l}^{k+1} \\phi_l(x,y) \\ , \\ \\ \\ v_{i,h}^{k+1}(x,y) = \\sum_{l=i}^{N_h} v_{i,l}^{k+1} \\phi_l(x,y),\n\\end{equation}\nWe denote the corresponding vector of the finite element unknowns by $\\left[\\mathbf{U}_i^{k}, \\mathbf{V}_i^{k}\\right]$, being: $$    \\left[\\mathbf{U}_i^{k}\\right]_l = u^k_{i,l}, \\ \\ \\ \\left[\\mathbf{V}_i^{k}\\right]_l = v^k_{i,l}$$.\nThe RR iterative method in algebraic form for a 2 cells system is then:\n\ngiven $\\begin{bmatrix} \\mathbf{U}_2^{0} \\\\ \\mathbf{V}_2^{0} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_2^{n} \\\\ \\mathbf{V}_2^{n} \\end{bmatrix}$, find $\\begin{bmatrix} \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix}$ and $\\begin{bmatrix} \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix}$ such that:\n\\begin{equation}\\label{eq:LinSysRR}\n\\begin{aligned}\n    \\begin{bmatrix}\n    A_u^1 & B_u^1 + C_u^1\\left(  \\mathbf{U}_1^n\\right) \\\\\n    B_v^1 & A_v^1 + C_v^1\\left(  \\mathbf{U}_1^n\\right)\n    \\end{bmatrix} \\begin{bmatrix}\n    \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix} = \\begin{bmatrix} F^1_u \\\\ F^1_v\n    \\end{bmatrix}, \\\n    \\begin{bmatrix}\n    A_u^2 & B_u^2 + C_u^2\\left(  \\mathbf{U}_2^n\\right) \\\\\n    B_v^2 & A_v^2 + C_v^2\\left(  \\mathbf{U}_2^n\\right)\n    \\end{bmatrix} \\begin{bmatrix}\n    \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix} = \\begin{bmatrix} F^2_u \\\\ F^2_v\n    \\end{bmatrix}\n\\end{aligned}\\end{equation}\nfor $k \\geq 0$ up to convergence. Update\n\\begin{equation*}\n  \\begin{bmatrix} \\mathbf{U}_1^{n+1} \\\\ \\mathbf{V}_1^{n+1} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix}, \\ \\ \\ \\begin{bmatrix} \\mathbf{U}_2^{n+1} \\\\ \\mathbf{V}_2^{n+1} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix}\n\\end{equation*}\n\nEach sub-domain block matrix depends on the previous time-step solution, therefore it has to be reassembled at each time-step. The right-hand sides depend on the previous iteration because of the interface boundary condition and have to be reassembled at every iteration of the domain decompostion method. Matrices and vectors are defined using the previous bilinear forms in \\eqref{eq:au&avRR}, \\eqref{eq:fu&fvRRInt} and \\eqref{eq:Gvarfmono}.\n%  in the following way:\n%\n% \\begin{equation}\n%     \\begin{aligned}\n%     \\left[ A_u^i\\right]_{j,l} & = a_{i,u}^{RR}(\\phi_l, \\phi_j) \\\\\n%     \\left[ A_v^i\\right]_{j,l} & = a_{i,v}^{RR}(\\phi_l, \\phi_j) \\\\\n%     \\left[ B_u^i\\right]_{j,l} & = b_{i,u}(\\phi_l, \\phi_j)\\\\\n%     \\left[ B_v^i\\right]_{j,l} & = b_{i,v}(\\phi_l, \\phi_j)\\\\\n%     \\left[ C_u^i\\right]_{j,l} & = c_{i,u}(\\phi_l, \\phi_j)\\\\\n%     \\left[ C_v^i\\right]_{j,l} & = v_{i,v}(\\phi_l, \\phi_j)\\\\\n%     \\left[F_u^i\\right]_{j} & = f_{i,u}^{RR}(\\phi_j) \\\\\n%     \\left[F_v^i\\right]_{j} & = f_{i,v}^{RR}(\\phi_j) \\\\\n%     \\end{aligned}\n% \\end{equation}\n\nSome contributions at the right-hand side come from solution variables and test functions not belonging to the same functional space of the correlated solution. Therefore we properly interpolate such terms from one space to the other.\n\n\\subsection{A new iterative modeling algorithm}\\label{sec:RRmodified}\nThe model that we propose to make cells communicate can be regarded as a simplification of the classical domain decomposition scheme with Robin boundary conditions. We start for simplicity from a two cells problem and rewrite the common interface boundary conditions in \\eqref{eq:RR} to recover the modelled open channels in \\eqref{eq:pluriModel}. In the spirit of a block-Gauss-Seidel algorithm, we solve in sequence:\n\\begin{equation} \\label{eq:RR_final}\n\\begin{aligned}\n& \\begin{cases}\n\\mathcal{L}^n (u_1^{k+1}, v_1^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_1 \\\\\n\\Tilde{D_1} \\nabla_s u_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_1} \\displaystyle{\\partial u_1^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{uRR} u_2^{k} - \\alpha_{uRR} u_1^{k+1} \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_2} \\displaystyle{\\partial v_1^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{vRR} v_2^{k} -\\alpha_{vRR} v_1^{k+1} \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\\\[6pt]\n& \\begin{cases}\n\\mathcal{L}^n (u_2^{k+1}, v_2^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_2 \\\\\n\\Tilde{D_1} \\nabla_s u_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma \\\\\n\\Tilde{D_1} \\displaystyle{\\partial u_2^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{uRR} u_1^{k+1} - \\alpha_{uRR} u_2^{k+1} \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma\\\\\n\\Tilde{D_2} \\displaystyle{\\partial v_2^{k+1}\\over\\partial \\mathbf{n}} = \\alpha_{vRR} v_1^{k+1} -\\alpha_{vRR} v_2^{k+1} \\ \\text{on} \\ \\Gamma.\n\\end{cases}\n\\end{aligned}\\end{equation}\nThe flux imposed depends on the difference of the neighbouring solutions. As a consequence, we are imposing a not necessarily null Neumann boundary condition. Equation \\eqref{eq:RR_final} defines a RR iterative method applied to two cells using proper parameters $\\beta_{u/vRR}$ and $\\alpha_{u/v RR}$ from the model formulated in Section \\ref{sec:PluriMod}:\n\nstarting from $(u_2^{k = 0}, v_2^{k = 0}) = (u_2^n, v_2^n)$, find $(u_1^{k+1}, v_1^{k+1}) \\ \\in V_{1}$ and $(u_2^{k+1}, v_2^{k+1}) \\ \\in V_{2}$:\n\\begin{equation}\\label{eq::RRmod}\n\\begin{aligned}\n& \\begin{cases}\n\\mathcal{L}^n (u_1^{k+1}, v_1^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_1 \\\\\n\\Tilde{D_1} \\nabla_s u_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_1} \\displaystyle{\\partial u_1^{k+1}\\over\\partial \\mathbf{n}} = \\beta_{uRR} \\alpha_{uRR} \\left( u_2^{k} - u_1^{k+1} \\right) \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_2} \\displaystyle{\\partial v_1^{k+1}\\over\\partial \\mathbf{n}} = \\beta_{vRR} \\alpha_{vRR} \\left( v_2^{k} - v_1^{k+1} \\right) \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\\\[6pt]\n& \\begin{cases}\n\\mathcal{L}^n (u_2^{k+1}, v_2^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_2 \\\\\n\\Tilde{D_1} \\nabla_s u_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\\\\n\\Tilde{D_1} \\displaystyle{\\partial u_2^{k+1}\\over\\partial \\mathbf{n}} = \\beta_{uRR} \\alpha_{uRR} \\left( u_1^{k+1} - u_2^{k+1} \\right) \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma\\\\\n\\Tilde{D_2} \\displaystyle{\\partial v_2^{k+1}\\over\\partial \\mathbf{n}} = \\beta_{vRR} \\alpha_{vRR} \\left( v_1^{k+1} - v_2^{k+1} \\right) \\ \\text{on} \\ \\Gamma.\n\\end{cases}\n\\end{aligned}\\end{equation}\nfor $k \\geq 0$ up to convergence.\n\nWe remark that in \\eqref{eq::RRmod} the coefficients $\\beta_{u/vRR}$ and $\\alpha_{u/v RR}$ have physical meaning since they come from the model \\eqref{eq:pluriModel}. This is in contrast with the model and method presented in Section \\ref{sec:RRclassic}, where the Robin coefficients are arbitrary.\n\nLet $V_{i,h}$ denote the finite dimensional subspace of $H^1\\left(\\Omega_i\\right)$, wih $\\Omega_i$ being the sub-domain of the pluricellular system $\\Omega$ corresponding to cell. We find solutions $\\left(u_{h}^{n+1}, v_{h}^{n+1}\\right)|_{\\Omega_i}$ identified with $\\left(u_{i,h}, v_{i,h}\\right) \\ \\in V_{i,h}$ for each time step $t^{n+1}$, solving up to convergence the iteration step, whose Galerkin formulation is:\n\\begin{equation}\\begin{aligned}\n    a_{i,u}^{RR}(u_{i,h}^{k+1}, w_{i,h}) + b_{i,u}(v_{i,h}^{k+1}, w_{i,h}) + c_{i,u}^n(v_{i,h}^{k+1}, w_{i,h}) = f_{i,u}^{RR}(w_{i,h}) \\ \\forall w_{i,h} \\in V_{i,h} \\\\\n    a_{i,v}^{RR}(v_{i,h}^{k+1}, w_{i,h}) + b_{i,v}(u_{i,h}^{k+1}, w_{i,h}) + c_{i,v}^n(v_{i,h}^{k+1}, w_{i,h}) = f_{i,v}^{RR}(w_{i,h}) \\ \\forall w_{i,h} \\in V_{i,h}.\n\\end{aligned}\\end{equation}\n\nThe bilinear forms used are equal to \\eqref{eq:Gvarfmono} - \\eqref{eq:au&avRR} for classic Robin-Robin algorithm. The only difference is in the right hand side \\eqref{eq:fu&fvRR} in which has been neglected the weak normal derivative of the neighbour solutions, as follows:\n\\begin{align}\n f_{i,u}^{RR}(w_{i,h}) & = f_{i,u}(w_{i,h}) + \\int_{\\Gamma} \\left(\\beta_{uRR} \\alpha_{uRR} \\mathcal{I}_{i,j} u_{j,h}^{k} \\mathcal{I}_{i,j}w_{j,h} \\right), \\\\\nf_{i,v}^{RR}(w_{i,h}) & = f_{i,v}(w_{i,h}) + \\int_{\\Gamma} \\left(\\beta_{vRR} \\alpha_{vRR} \\mathcal{I}_{i,j} v_{j,h}^{k} \\mathcal{I}_{i,j} w_{j,h} \\right).\n\\end{align}\n\nConsequently, the algebraic formulation of the new iterative method used is formulated similarly as in \\eqref{eq:LinSysRR}, with time-dependent block matrix that need to be reassembled at each time-step. The right-hand sides depend on the previous solution found for the neighbouring cells and their contributions need to be interpolated by means of a interpolation matrix as in Robin-Robin classic method. We here explicit the whole iterative method for a two cells composed system.\n\nStarting from initial guess given by the previous time-step solution  $\\begin{bmatrix} \\mathbf{U}_2^{0} \\\\ \\mathbf{V}_2^{0} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_2^{n} \\\\ \\mathbf{V}_2^{n} \\end{bmatrix}$, solve problem for $i = 1$ to find $\\begin{bmatrix} \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix}$:\n\\begin{equation*}\n\\begin{aligned}\n \\begin{bmatrix}\n    A_u^1 & B_u^1 + C_u^1\\left(  \\mathbf{U}_1^n\\right) \\\\\n    B_v^1 & A_v^1 + C_v^1\\left(  \\mathbf{U}_1^n\\right)\n    \\end{bmatrix} \\begin{bmatrix}\n    \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix} = \\begin{bmatrix} F^1_u \\left(\\mathbf{U}_2^k\\right) \\\\ F^1_v \\left(\\mathbf{V}_2^k\\right)\n    \\end{bmatrix}\n        \\end{aligned}\n\\end{equation*}\nand then solve problem for $ i = 2$ to find $\\begin{bmatrix} \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix}$:\n\\begin{equation*}\n    \\begin{aligned}\n\\begin{bmatrix}\n    A_u^2 & B_u^2 + C_u^2\\left(  \\mathbf{U}_2^n\\right) \\\\\n    B_v^2 & A_v^2 + C_v^2\\left(  \\mathbf{U}_2^n\\right)\n    \\end{bmatrix} \\begin{bmatrix}\n    \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix} = \\begin{bmatrix} F^2_u \\left(\\mathbf{U}_1^k\\right) \\\\ F^2_v \\left(\\mathbf{V}_2^k\\right)\n    \\end{bmatrix}\n\\end{aligned}\\end{equation*}\nfor $k \\geq 0$ up to convergence.\n\nIterations end when the normalized residual of consecutive computed solutions is smaller than a proper tolerance or when a maximum number of iterations is performed and we update the new solution as:\n $$\\begin{bmatrix} \\mathbf{U}_1^{n+1} \\\\ \\mathbf{V}_1^{n+1} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_1^{k+1} \\\\ \\mathbf{V}_1^{k+1} \\end{bmatrix}, \\ \\ \\ \\begin{bmatrix} \\mathbf{U}_2^{n+1} \\\\ \\mathbf{V}_2^{n+1} \\end{bmatrix} = \\begin{bmatrix} \\mathbf{U}_2^{k+1} \\\\ \\mathbf{V}_2^{k+1} \\end{bmatrix}$$\n\nMatrices and vectors used are defined in the following way:\n\\begin{equation}\n    \\begin{aligned}\n    & \\left[ A_u^i\\right]_{j,l} & = a_{i,u}^{RR}(\\phi_l, \\phi_j), \\ \\ \\ \\left[ A_v^i\\right]_{j,l} & = a_{i,v}^{RR}(\\phi_l, \\phi_j) \\\\\n    & \\left[ B_u^i\\right]_{j,l} & = b_{i,u}(\\phi_l, \\phi_j), \\ \\ \\ \\left[ B_v^i\\right]_{j,l} & = b_{i,v}(\\phi_l, \\phi_j)\\\\\n    & \\left[ C_u^i\\right]_{j,l} & = c_{i,u}(\\phi_l, \\phi_j),\\ \\ \\ \\left[ C_v^i\\right]_{j,l} & = c_{i,v}(\\phi_l, \\phi_j)\\\\\n    & \\left[F_u^i\\right]_{j} & = f_{i,u}^{RR}(\\phi_j), \\ \\ \\\n    \\left[F_v^i\\right]_{j} & = f_{i,v}^{RR}(\\phi_j),\n    \\end{aligned}\n\\end{equation}\nbeing $\\{\\phi_l\\}_{l = 1}^{N_h}$ the functional basis of $V_{i,h}$ finite dimensional space defined on each cell $\\Omega_i$ with $i =1,2$.\n\nA sketch of the procedure to be adopted to deal with a generic N cells pluricellular system using Robin-Robin modifed algorithm is schematically given in Algorithm \\ref{alg:RRmod}; $r_i$ are different coefficients characterizing initial state of concentrations, necessary for having flux between communicating cells. For physical reasons, we choose same initial guesses in the direction of the auxin gradient.\n\nWe have implemented a solver for a system of four cells.\n\nAs expressed in \\eqref{eq::RRmod}, the iterative procedure is formulated such that the pluricellular domain is solved sequentially, in the sense that the boundary conditions characterizing sub-domain $i$, depending on sub-domain solutions of $j \\in \\mathcal{N}_i$, are computed using the newly updated solutions. In view of a parallel implementation, the method can be reformulated such that the new boundary conditions are a function of the previous iteration solution.\n\n\\begin{algorithm}[t]\n    \\caption{Pluricellular system solver procedure: RR}\n    \\label{alg:RRmod}\n    Given $N \\geq 1$ cells, $r_i$\n    \\begin{algorithmic}[1]\n    \\STATE Initialization: $\\forall i = 1, ..., N$\n    \\STATE \\verb|[U0i, V0i]| $\\gets [r_i u_0, r_i v_0]$\n    \\STATE \\verb|[Uiprec, Viprec]| $\\gets$  \\verb|[U0i, V0i]|\n    \\WHILE{$t < T_{max}$}\n    \\STATE{\\verb|assemble| matrix for $\\forall i = 1,..., N$}\n    \\FOR{$iter < Niter$}\n    \\STATE{$\\forall i =1, ..., N$}\n    \\STATE{compute BC contribute from $j \\in \\mathcal{N}_i$}\n    \\STATE{\\verb|interpolate| on $i$}\n    \\STATE{update \\verb|rhs|}\n    \\STATE{\\verb|solve| $\\Omega_i$ problem \\eqref{eq:pluriModel}}\n    \\STATE{update residual, check tolerance, update $iter$}\n    \\STATE \\verb|[Uiprec, Viprec]| $\\gets$  \\verb|[Ui, Vi]|\n    \\ENDFOR\n    \\STATE \\verb|[U0i, V0i]| $\\gets$  \\verb|[Ui, Vi]|\n    \\ENDWHILE\n    \\end{algorithmic}\n\\end{algorithm}\n\nIn case we are solving a two cells system, when solving the boundary value problem in $\\Omega_2$ at the new iteration $k+1$, we use data on common interface $\\Gamma$ generated by $[U_1^k, V_1^k]$. Therefore two cells system problem \\eqref{eq::RRmod} is reformulated in a block-Jacobi fashion as:\n\nstarting from $(u_2^{k = 0}, v_2^{k = 0}) = (u_2^n, v_2^n)$, find $(u_1^{k+1}, v_1^{k+1}) \\ \\in V_{1,h}$ and $(u_2^{k+1}, v_2^{k+1}) \\ \\in V_{2,h}$:\n\\begin{equation}\\label{eq::RRmodP}\n\\begin{aligned}\n& \\begin{cases}\n\\mathcal{L}^n (u_1^{k+1}, v_1^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_1 \\\\\n\\Tilde{D_1} \\nabla_s u_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_1} \\displaystyle.{\\partial u_1^{k+1}}{\\partial \\mathbf{n}} = \\beta_{uRR} \\alpha_{uRR} \\left( u_2^{k} - u_1^{k+1} \\right) \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_1^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_1 \\setminus \\Gamma \\\\\n\\Tilde{D_2} \\displaystyle.{\\partial v_1^{k+1}}{\\partial \\mathbf{n}} = \\beta_{vRR} \\alpha_{vRR} \\left( v_2^{k} - v_1^{k+1} \\right) \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\\\\n& \\begin{cases}\n\\mathcal{L}^n (u_2^{k+1}, v_2^{k+1}) = \\mathbf{f}^n \\ \\text{in} \\ \\Omega_2 \\\\\n\\Tilde{D_1} \\nabla_s u_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma \\\\\n\\Tilde{D_1} \\displaystyle.{\\partial u_2^{k+1}}{\\partial \\mathbf{n}} = \\beta_{uRR} \\alpha_{uRR} \\left( u_1^{k} - u_2^{k+1} \\right) \\ \\text{on} \\ \\Gamma \\\\\n\\Tilde{D_2} \\nabla_s v_2^{k+1} \\cdot \\mathbf{n} = 0 \\ \\text{on} \\ \\partial \\Omega_2 \\setminus \\Gamma\\\\\n\\Tilde{D_2} \\displaystyle.{\\partial v_2^{k+1}}{\\partial \\mathbf{n}} = \\beta_{vRR} \\alpha_{vRR} \\left( v_1^{k} - v_2^{k+1} \\right) \\ \\text{on} \\ \\Gamma\n\\end{cases}\n\\end{aligned}\\end{equation}\n for $k \\geq 0$ up to convergence.\n\n\\section{Numerical assessment}\\label{cap3:results}\nWe here show some of the results obtained applying the iterative procedures in Section \\ref{sec:RRmodified}. At first we properly tune the parameteres $\\beta_{uRR}, \\beta_{vRR}$ and $\\alpha_{uRR}, \\alpha_{vRR}$ characterizing the channels. Then, we underline the importance of a communication model to suitably simulate pluricellular systems through various results.\n\nAll simulations, if not differently stated, are solved under Table \\ref{tab:setprm} - Set C of parameters and space dependent auxin distribution in \\eqref{eq:alpha_exp}. For a two cell system, $\\Omega_1$ corresponds to the lower cell and $\\Omega_2$ to the upper one. For a four cells system, the lower left cells is the first one and the other ones are numbered clockwise.\n\n\\subsection{Stagnant cells reference solution}\\label{sec:refRR}\nSince the multi-cellular model is a simplification of the actual physics governing the communication of cells, we provide a reference solution. This have a clear physical meaning of what happens between cells and pattern obtained can be compared with the different choices we did to model the presence of channels. In this way we can tune channel parameters and make considerations on the obtained result.\n% Actually at the interface we are forcing difference between solutions being equal to difference between fluxes:\n% \\begin{equation}\n%   \\begin{aligned}\n%   \\Tilde{D_1} \\left( \\frac{\\partial u_2}{\\partial \\mathbf{n}} -  \\frac{\\partial u_1 }{\\partial \\mathbf{n}} \\right) & = \\alpha_{uRR} \\left(u_1 - u_2 \\right)  \\ \\text{on} \\ \\Gamma \\\\\n%     \\Tilde{D_2} \\left( \\frac{\\partial v_2}{\\partial \\mathbf{n}} -  \\frac{\\partial v_1 }{\\partial \\mathbf{n}} \\right) & = \\alpha_{vRR} \\left(v_1 - v_2 \\right)  \\ \\text{on} \\ \\Gamma \\\\\n%   \\end{aligned}\n% \\end{equation}\n% 2022-04-08_15-59-28 rifacendo ...,\n% ROBIN ROBIN CLASSICO TOLTO, HA UN PB\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 100s$\\label{RR1}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$\\label{RR2}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 300s$\\label{RR3}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0150.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$\\label{RR4}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 700s$\\label{RR5}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0350.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$\\label{RR6}]{\\includegraphics[scale=0.15]{cap3/2022-01-10_19-04-00/frame.0499.png}}\n%     \\quad\n%     \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-01-10_19-04-00/legenda.png}}\n%     \\caption[2cell RR classic Active ROPs]{Active ROPs $u$ evolution obtained with classic Robin-Robin solver.}\n%     \\label{fig:RR}\n% \\end{figure}\n% In particular, the first one we present in Figure \\ref{fig:RR} is the solution obtained with classic Robin-Robin algorithm. This should correspond to a solution with continuity of variables and fluxes at the interface, therefore letting free-flux condition along all the border in common between the two cells.\n\nThe reference solution is obtained solving the modified Robin-Robin algorithm, having channels of communication characterized by $\\beta_{uRR} = \\beta_{vRR} = 0 $, which corresponds to no open channels between cells and therefore to a no-flux boundary condition between close cells. The two airtight, stagnant cells together with the time evolution of the concentrations of are visualized in Figure \\ref{fig:beta0}.\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 100s$\\label{beta01}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{beta02}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 300s$\\label{beta03}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0150.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{beta04}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 600s$\\label{beta05}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0300.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{beta06}]{\\includegraphics[scale=0.15]{cap3/2022-01-13_12-09-56/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{beta0leg}]{\\includegraphics[scale=0.5]{cap3/2022-01-13_12-09-56/legenda.png}}\n    \\caption[2cell RR modified Active ROPs - $\\beta_{uRR} = \\beta_{vRR} = 0 $]{Active ROPs $u$ evolution obtained with RR algorithm solver with $\\beta_{uRR} = \\beta_{vRR} = 0 $.}\n    \\label{fig:beta0}\n\\end{figure}\n\nWe can observe that if there is no influence and communication between cells and spot formation is driven only by the gradient of auxin (\\ref{cap:2}).\n % There can be recalled the 1 cells solution with no-flux boundary condion on all sides in Figure \\ref{fig:1cellUevolution}\n\n\\subsection{Tuning channels parameters}\nIn this section, we illustrate different simulations in order to tune the parameters $\\beta_{uRR}, \\beta_{vRR}$ and $\\alpha_{uRR}, \\alpha_{vRR}$ used in \\eqref{eq:pluriModel}. Setting properly the communication between cells is crucial for correctly simulating spot formation.\nIn order to synthetically represent channels for a 2 cells system we rewrite $\\beta_{uRR}, \\beta_{vRR}$ functions as follows:\n\\begin{equation}\\label{eq:beta}\\begin{aligned}\n    \\beta_{uRR} & = \\mathbb{1} \\Big \\{ \\frac{L_x}{2} - a_x - \\epsilon_x \\leq x \\leq \\frac{L_x}{2} - a_x \\Big\\}\n    + \\mathbb{1} \\Big\\{\\frac{L_x}{2} + a_x \\leq x \\leq \\frac{L_x}{2} + a_x + \\epsilon_x \\Big\\} \\\\\n    \\beta_{vRR} & = \\mathbb{1} \\Big\\{ \\frac{L_x}{2} - a_x - \\epsilon_x \\leq x \\leq \\frac{L_x}{2} - a_x \\Big\\}\n    + \\mathbb{1} \\Big\\{\\frac{L_x}{2} + a_x \\leq x \\leq \\frac{L_x}{2} + a_x + \\epsilon_x \\Big\\},\n\\end{aligned}\\end{equation}\nwhere $\\mathbb{1}\\{A\\}$ is the characteristic function of a generic set $A$.\nWe are assuming as reasonable that concentrations of active and inactive ROPs have the same channels of communication. The new introduced parameters have two different meanings:\n\\begin{itemize}\n  \\item $a_x$ is the distance at which two open channels are localized, symmetrically from the middle point of the side $\\Gamma$.\n  \\item $\\epsilon_x$ is the amplitude of the open channels.\n\\end{itemize}\n\nWe fixed $\\epsilon_x = 1$ and $\\alpha_{uRR} = \\alpha_{vRR}= 1$ and let $a_x$ vary. We choose as initial state of the concentrations\n\\begin{equation} \\label{eq:initstate}\n  \\left[ U_1^0, V_1^0 \\right] = 1.5 \\left[u^0,v^0 \\right], \\ \\ \\ \\left[ U_2^0, V_2^0 \\right] = \\left[u^0,v^0 \\right].\n\\end{equation}\nAs a consequence, a sensitive difference in the sub-domains is expected and this may lead to non-null flux of ROPs thanks to the new boundary conditions defined in \\eqref{eq::RRmod}.\n\nFor $a_x = 5$ (Figure \\ref{fig:a5}), $a_x = 20$ (Figure \\ref{fig:a20}) and $a_x = 30$ (Figure \\ref{fig:a30}) we do not observe sensitive difference with respect to the stagnant cells obtained with $\\beta_{uRR} = \\beta_{vRR} = 0 $ in Figure \\ref{fig:beta0}; apart from the first few seconds, the patterns obtained are similar one to the other.\nWe observe the formation of small spots from the breakup of an interior homoclinic stripe and how they evolve slowly in time to a steady-state two-spot pattern. The main responsible of the breakup of the stripe is assumed to be the auxin gradient, as stated and demonstrated through some analysis and numerical results in \\cite{intra2}.\n\nIt is important to notice, as in previous works on singular cell system (see e.g.,\\cite{intra2}), that even if the problem is homogeneous along $y$ direction, the system is not able to maintain the stability. The stripe formed is sensitive to a transverse instability since it is located close to the left-hand boundary, where the influence of the auxin gradient is stronger \\cite{intra2}.\n\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$\\label{1a5}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-17-25/screen25.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{2a5}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-17-25/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{3a5}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-17-25/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega5}]{\\includegraphics[scale=0.5]{cap3/2022-01-17_15-17-25/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 5 $]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 5 $.}\n    \\label{fig:a5}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$\\label{1a20}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-13-10/screen25.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{2a20}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-13-10/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{3a20}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_15-13-10/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega20}]{\\includegraphics[scale=0.5]{cap3/2022-01-17_15-17-25/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 20 $]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 20 $.}\n    \\label{fig:a20}\n\\end{figure}\n\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$\\label{1a30}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-57-59/screen25.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{2a30}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-57-59/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{3a30}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-57-59/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega30}]{\\includegraphics[scale=0.5]{cap3/2022-03-07_09-57-59/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 30 $]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 30 $.}\n    \\label{fig:a30}\n\\end{figure}\n% 2022-01-17_18-17-44 a = 34\n% $a_x = 34$ e initial state $U_1^0 = 1.5 u^0, U_2^0 = u^0$\n\\begin{figure}[H]\n    \\centering\n    % \\subfloat[$t = 25s$\\label{1a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0012.png}}\n    \\subfloat[$t = 25s$\\label{1a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/screen25.png}}\n    \\quad\n    \\subfloat[$t = 50s$\\label{2a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{3a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{4a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{5a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{6a34}]{\\includegraphics[scale=0.15]{cap3/2022-01-17_18-17-44/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega34}]{\\includegraphics[scale=0.5]{cap3/2022-01-17_18-17-44/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 34 $]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 34 $.}\n    \\label{fig:a34}\n\\end{figure}\nUsing instead $a_x = 34$, we observe a considerable difference in the evolution of spots (see Figure \\ref{fig:a34}). Still a stripe-like state is formed at the boundary, but since the channel is located precisely where the stripe is formed, i.e., where the maximum of auxin is located, the homoclinic stripe collapses very soon and in a different way. The transverse dependence of solutions caused by the break up of the stripe leads to the generation of a flux of ROPs. The relevant flux of ROPs is placed where a channel is open and it let communication between cells to influence their dynamics. The system evolve to the formation of a unique spot moving to the right.\n\nAs a secon test, we tested the sensitivity of the model with respect to the channel length, i.e., increasing $\\epsilon_x$, may cause a relevant change in results. Figure \\ref{fig:a5epsi5} shows few frames obtained with conditions:\n\\begin{itemize}\n  \\item $\\alpha_{RR} = 1$,\n  \\item initial state as in \\eqref{eq:initstate},\n  \\item $\\epsilon_x = 5$, $a_x = 5$.\n\\end{itemize}\n\n% 2022-03-18_14-50-57 NP mode\n\\begin{figure}[H]\n    \\centering\n    % \\subfloat[$t = 25s$\\label{1a5epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-51-08/frame.0025.png}}\n    \\subfloat[$t = 25s$\\label{1a5epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-03-18_14-50-57/screen25.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{2a5epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-03-18_14-50-57/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 500s$\\label{3a5epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-03-18_14-50-57/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-03-18_14-50-57/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 5, \\epsilon_x = 5$]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 5, \\epsilon_x = 5$.}\n    \\label{fig:a5epsi5}\n\\end{figure}\nWe do not observe relevant changes because channels are located too far from the area where auxin maximum is located and where therefore gradient has a relevant value.\n\nInstead, by setting $\\epsilon_x = 5$ and $a_x = 30$, the open channel covers the exact position in which the formation of the instabilities occurs (see Figure \\ref{fig:a30epsi5}). Thus, we observe a non-negligible flux of ROPs. Not being isolated, the two cells together form a common spot moving to the right.\n% 2022-01-16_11-41-50\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$ \\label{1a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/screen25.png}}\n    \\quad\n    \\subfloat[$t = 50s$ \\label{2a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$ \\label{3a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$ \\label{4a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$ \\label{5a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1000s$ \\label{6a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_11-41-50/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega30epsi5}]{\\includegraphics[scale=0.5]{cap3/2022-01-16_11-41-50/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 30, \\epsilon_x = 5$]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 30, \\epsilon_x = 5$.}\n    \\label{fig:a30epsi5}\n\\end{figure}\n\nIn Section \\ref{sec:PluriMod} we explained that parameter $\\alpha_{uRR}$ and $\\alpha_{vRR}$ quantify the transport efficiency between cells. We show here how this coefficient is relevant and how different values affect the final solution. This parameter seems to be stictly related to the generation of patches away from the common interface and to guarantee a more similar behaviour between the two cells in location of high concentrations zone of ROPs. A smaller transport efficiency coefficient would cooperate less. Indeed, comparing simulation characterized by $\\alpha_{uRR} = \\alpha_{vRR} = 1$ found in Figure \\ref{fig:a34} with results in Figure \\ref{fig:a34alpha35} where $\\alpha_{uRR} = \\alpha_{vRR} = 35 / 2$, we observe a more symmetric spot formation in the second case.\n% 2022-01-16_09-41-47\n% \\towrite{questa tolta perchè rispetto al'interpretazione che diamo del coeff non aiuta}\n% initial state $U_1^0 = 1.5 u^0, U_2^0 = u^0$, $\\epsilon_x = 1,  a_x = 30, \\alpha_{RR} = 35/2$, stesso canale (cioè $\\beta_{RR}$) di \\ref{fig:a30}, ma efficienza trasporto minore; si vede che compensa perchè inizio consente più trasporto, quando sono diverse maggiormente\n% \\towrite{questo commento lo avevamo pensato ma le figure non sostengono tanto l'idea, diciamo che cambiano molto gli spot- direi quello che ho detto}\n% \\begin{figure}[H]\n%     \\centering\n%     % \\subfloat[$t = 25s$\\label{1a30alpha5}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0025.png}}\n%     \\subfloat[$t = 25s$\\label{1a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/screen25.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{5a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{6a30alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-16_09-41-47/frame.0499.png}}\n%     \\caption[Tuning channel prm - $a = 30, \\alpha_{RR} = \\frac{35}{2}$]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a = 30, \\alpha_{RR} = \\frac{35}{2}$.}\n%     \\label{fig:a30alpha35}\n% \\end{figure}\n\n% 2022-01-18_09-42-23\n% initial state $U_1^0 = 1.5 u^0, U_2^0 = u^0$, $\\epsilon_x = 1,  a_x = 34, \\alpha_{RR} = 35/2$  (vs \\ref{fig:a34}\n% \\begin{figure}[H]\n%     \\centering\n%     % \\subfloat[$t = 25s$\\label{1a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23 /frame.0025.png}}\n%     \\subfloat[$t = 25s$\\label{1a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/screen25.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{5a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{6a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0499.png}}\n%     \\caption[Tuning channel prm - $a = 34, \\alpha_{RR} = \\frac{35}{2}$]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a = 34, \\alpha_{RR} = \\frac{35}{2}$.}\n%     \\label{fig:a34alpha35}\n% \\end{figure}\n\\begin{figure}[H]\n    \\centering\n    % \\subfloat[$t = 25s$\\label{1a30epsi5}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23 /frame.0025.png}}\n    \\subfloat[$t = 25s$ \\label{1a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/zoom25.png}}\n    \\quad\n    \\subfloat[$t = 50s$ \\label{2a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$ \\label{3a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$ \\label{4a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$ \\label{5a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1000s$ \\label{6a34alpha35}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_09-42-23/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{lega34alpha35}]{\\includegraphics[scale=0.5]{cap3/2022-01-18_09-42-23/legenda.png}}\n    \\caption[Tuning channel prm - $a_x = 34, \\alpha_{RR} = \\frac{35}{2}$]{Active ROPs $u$ evolution obtained with RR algorithm solver with $a_x = 34, \\alpha_{RR} = \\frac{35}{2}$.}\n    \\label{fig:a34alpha35}\n\\end{figure}\n\nopen channels represented by functions \\eqref{eq:beta} are a simplified representation of how channels of communications for ROPs are distributed. Indeed from a biological point of view, it is not really known where channels are located and what is the actual amplitude and frequency along the common side $\\Gamma$. We could assume more realistic and precise channels, defined as follows:\n\\begin{equation}\\begin{aligned}\n    \\beta_{uRR} & = \\mathbb{1} \\Big\\{ a_x \\leq x \\leq a_x + \\epsilon_x \\Big\\} + \\mathbb{1} \\Big\\{ 2a_x +\\epsilon_x \\leq x \\leq 2a_x + 2\\epsilon_x \\Big\\}  \\\\\n    & + \\mathbb{1} \\Big\\{ 3a_x +2\\epsilon_x \\leq x \\leq 3a_x + 3\\epsilon_x \\Big\\} + \\mathbb{1} \\Big\\{ 4a_x +3\\epsilon_x \\leq x \\leq 4a_x + 4\\epsilon_x \\Big\\}. \\\\\n    \\beta_{vRR} & = \\mathbb{1} \\Big\\{ a_x \\leq x \\leq a_x + \\epsilon_x \\Big\\} + \\mathbb{1} \\Big\\{ 2a_x +\\epsilon_x \\leq x \\leq 2a_x + 2\\epsilon_x \\Big\\}  \\\\\n    & + \\mathbb{1} \\Big\\{ 3a_x +2\\epsilon_x \\leq x \\leq 3a_x + 3\\epsilon_x \\Big\\} + \\mathbb{1} \\Big\\{ 4a_x +3\\epsilon_x \\leq x \\leq 4a_x + 4\\epsilon_x \\Big\\}.\n\\end{aligned}\\end{equation}\n\nIn Figure \\ref{fig:multich} we compare the solutions obtained with sparse channels, characterized by $\\epsilon_x = 1, a_x = 5$ and $\\alpha_{uRR} = \\alpha_{vRR} = 5/2$, against those obtained in Figure \\ref{fig:a30epsi5} with two single channels defined as in formula \\eqref{eq:beta} with $\\epsilon_x = 5, a_x = 30$.\n% 2022-01-19_10-37-49\n% $\\epsilon_x = 1, a_x = 5, alpha_{RR} = 5/2$ ma ripetuti (vd figura)\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 50s$]{\\includegraphics[scale=0.12]{cap3/2022-01-19_10-37-49/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$]{\\includegraphics[scale=0.12]{cap3/2022-01-19_10-37-49/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 500s$]{\\includegraphics[scale=0.12]{cap3/2022-01-19_10-37-49/frame.0250.png}}\n    \\quad\n    \\subfloat[$t = 50s$]{\\includegraphics[scale=0.12]{cap3/2022-01-16_11-41-50/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$]{\\includegraphics[scale=0.12]{cap3/2022-01-16_11-41-50/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 500s$]{\\includegraphics[scale=0.12]{cap3/2022-01-16_11-41-50/frame.0250.png}}\n    \\quad\n    \\subfloat[$1^{st}$ line legend\\label{legmultich}]{\\includegraphics[scale=0.5]{cap3/2022-01-19_10-37-49/legenda.png}}\n    \\quad\n    \\subfloat[$2^{nd}$ line legend]{\\includegraphics[scale=0.5]{cap3/2022-01-16_11-41-50/legenda.png}}\n    \\caption[Tuning channel prm - Smaller sparse channels]{Active ROPs $u$ evolution obtained with RR algorithm solver with smaller sparse channels on the top against Figure \\ref{fig:a30epsi5} channels on the bottom.}\n    \\label{fig:multich}\n\\end{figure}\n\nFrom this similar results we can infer that the simplified version of channels is a good approximation of the communication between cells and it is not necessary to have such precise functions $\\beta_{uRR}$ and $\\beta_{vRR}$ to obtain relevant contributions.\n\nTo sum up the considerations made on the proposed results, we point out that the most relevant information for channels definition is their location with respect to auxin distribution, maximum and gradient in particular. The amplitude of open channels $\\epsilon_x$ seems less relevant in defining the evolution of the system. Finally, increasing $\\alpha_{uRR}$ and $\\alpha_{vRR}$ leads to a effective communication, thus yieldind symmetric patterning.\n\n\\subsection{Parallelizable versus not-parallelizable mode}\nAt the end of Section \\ref{sec:RRmodified} we stated the difference between a parallelizable and a not-parallelizable algorithm. The two procedures differ also in terms of mathematical formulation. We have implemented also the parallelized version of the proposed method. Actually, we observe, under same settings of parameters, considerably different solutions using the two different methods (see in Figure \\ref{fig:NPvsP2}). In particular, the more relevant the open channels, i.e., the more close to the maximum of auxin, the more the simulations evolve in completely different ways. Indeed, even small numerical differences are propagated and amplified in time because of sensitivity of active dissipative system we deal with.\n\nIn Figure \\ref{fig:NPvsP2} ROPs system solved with the parallel mode (P) is shown in the first row, under parameters set C for ROPs and $a_x = 30, \\epsilon_x = 5, \\alpha_{uRR} = \\alpha_{vRR}= 1$ for channels; the same system is solved with not parallel algorithm (NP) and the corresponding results are shown in the second row of Figure \\ref{fig:NPvsP2}.\n\n% 2022-03-05_10-04-34 parall mode, canale in mezzo vs\n% 2022-03-05_10-06-30 not parall mode, canale in mezzo\n% Confronto con un canale poco influente nella comunicazione tra la cellule -> vediamo che vengono infatti praticamente identici (li avevo anche confrontati frame per frame)\n% \\begin{equation}\\begin{aligned}\n%     \\beta_{u/vRR} = \\mathbb{1}\\{ \\frac{L_x}{4}\\leq x \\leq \\frac{3L_x}{4}\\}\n% \\end{aligned}\\end{equation}\n% \\towrite{da rifare il Paralle mode perchè persi i vtk di U, per un canale non utile (se serve ma mi sembra di aver capito che non ci serva)}\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 100s$\\label{1notP1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-06-30/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$\\label{2notP1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-06-30/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$\\label{3notP1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-06-30/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$\\label{4notP1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-06-30/frame.0499.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{1P1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-04-34/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{2P1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-04-34/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{3P1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-04-34/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{4P1}]{\\includegraphics[scale=0.11]{cap3/2022-03-05_10-04-34/frame.0499.png}}\n%     \\caption[NP vs P mode - irrelevant channel]{Active ROPs $u$ solution with RRmod algorithm not-parallelizable against parallelizable mode, with irrelevant channel.}\n%     \\label{fig:NPvsP1}\n% \\end{figure}\n\n% canale \\ref{fig:a30epsi5} -> sono completamente diversi, i canali sono influenti\n% 2022-03-04_16-45-12 parall vs 2022-01-16_11-41-50 not parall ma canale a caso ... in mezzo\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 100s$\\label{1notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$\\label{2notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$\\label{3notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$\\label{4notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0499.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{1P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{2P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{3P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{4P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0499.png}}\n%     \\caption[NP vs P mode - relevant channel]{Active ROPs $u$ solution with RRmod algorithm not-parallelizable against parallelizable mode, with relevant channel.}\n%     \\label{fig:NPvsP2}\n% \\end{figure}\n\\begin{figure}[H]\n    \\centering\n    % \\subfloat[\\label{legnotP2}]{\\includegraphics[scale=0.5]{cap3/2022-01-16_11-41-50/legenda.png}}\n    % \\quad\n    \\subfloat[P: $t = 100s$\\label{1P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{2P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{3P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{4P2}]{\\includegraphics[scale=0.11]{cap3/2022-03-04_16-45-12/frame.0499.png}}\n    \\quad\n    \\subfloat[NP: $t = 100s$\\label{1notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{2notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{3notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1000s$\\label{4notP2}]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0499.png}}\n    \\quad\n    \\subfloat[\\label{legP2}]{\\includegraphics[scale=0.5]{cap3/2022-03-04_16-45-12/legenda.png}}\n    \\caption[P vs NP mode - relevant channel]{Active ROPs $u$ solution with RR algorithm parallelizable against not-parallelizable mode, with relevant channel.}\n    \\label{fig:NPvsP2}\n\\end{figure}\n\n% - tentativi con canali strani: per ora non li ho caricati, perchè in realtà sono tentativi su cui non saprei bene cosa dire e che confronti fare. Alcuni presentano più \"aperture\" sul bordo e sembra velocizzino lo spostamento dello spot. poco significativi se vogliamo dire che i $\\beta_{RR}$ che abbiamo utilizzato sono una \"media\" dei canali attivi e che quindi non ci interessa fare tanti piccoli canalini aperti, sarebbe eccessivo.\n\n% uno fa vedere che velocizza perchè così lo spot si muove e non è localizzata solo all'inizio l'influenza del canale aperto tipo slide 29-30 o prima 28\n% 2022-01-19_10-37-49 canale 28\n\n% 2022-01-14_19-30-12 canale 29 (slide 30 è solo Tmax che fa vedere che va a destra lo spot ..)\n\n\n% - tolto perchè inutile, semplicemente va a specchio, ovvio ...\n% grad auxina diverso 2 cell:  utile perchè poi in altri tentativi (con 4 cellule) abbiamo usato un gradiente invertito. confronto con \\eqref{fig:a30epsi5}, viene uguale specchiato -> prova importanza grad ? dubbi su che interpetazione dare su formazione spot rispetto al gradiente. nei paper diceva che si allineavano mentre qua al massimo si muovo nella direzione del gradiente di auxina, credo. ma forse ho capito male.\n%\n% % 2022-01-24_10-26-37\n% canale $\\epsilon = 5, a_x = 30, \\alpha_{RR} = 1$ come ini \\eqref{fig:a30epsi5}, ma auxin $\\alpha = k_{20} e^{nu\\frac{x-L_x}{L_x}}$\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0025.png}}\n%     % \\subfloat[$t = 25s$\\label{1gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/screen25.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{5gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0400.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{6gradINV}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_10-26-37/frame.0499.png}}\n%     \\caption[2cell solver with inverse auxin gradient]{Active ROPs $u$ evolution obtained with RR algorithm solver with $\\alpha = k_{20} e^{nu\\frac{x-L_x}{L_x}}$.}\n%     \\label{fig:gradINV}\n% \\end{figure}\n\n\\subsection{Overall auxin level k20}\\label{sec:k20}\nThe break-up instability for active ROPs spot under different values of the overall auxin level $k_{20}$ was studied in other works. We have chosen to focus on the different values of $k_{20}$ studied in \\cite{intra1_R, intra2}. We prove how this parameter characterizing the system remains relevant to determine spot formation in a two cell system. The overall auxin level determined multiple-spot locations and showed instabilities. As a consequence, in previous works it was studied as a bifurcation parameter. The presented numerical simulations confirms this feature.\n\nIn Figure \\ref{fig:k20_04} we observe that a small change in the auxin level brings a considerable different spot formation. In this simulation we have settled $a_x = 34$ and $\\epsilon_x = 1$.\n% usano il canale di \\ref{fig:a34}\n\n% 2022-01-18_10-31-50 k2 0.4\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 300s$ .\\label{5k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0300.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{6k20_04}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-31-50/frame.0499.png}}\n%     \\caption[Modifying prm overall auxin - $k_{20} = 0.4$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.4$.}\n%     \\label{fig:k20_04}\n% \\end{figure}\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$k_{20} = 0.5$: $t = 50s$ \\label{k20_05:50s}]{\\includegraphics[scale=0.11]{cap3/2022-01-17_18-17-44/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$]{\\includegraphics[scale=0.11]{cap3/2022-01-17_18-17-44/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$]{\\includegraphics[scale=0.11]{cap3/2022-01-17_18-17-44/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 500s$]{\\includegraphics[scale=0.11]{cap3/2022-01-17_18-17-44/frame.0250.png}}\n    \\quad\n    \\subfloat[$k_{20} = 0.4$: $t = 50s$]{\\includegraphics[scale=0.11]{cap3/2022-01-18_10-31-50/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$]{\\includegraphics[scale=0.11]{cap3/2022-01-18_10-31-50/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$]{\\includegraphics[scale=0.11]{cap3/2022-01-18_10-31-50/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 500s$]{\\includegraphics[scale=0.11]{cap3/2022-01-18_10-31-50/frame.0499.png}}\n    % \\quad\n    % \\subfloat[$t = 1000s$ .\\label{lega34}]{\\includegraphics[scale=0.5]{cap3/2022-01-17_18-17-44/legenda.png}}\n    \\caption[Modifying prm overall auxin - $k_{20} = 0.5$ vs $k_{20} = 0.4$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.5$ (top row) and $k_{20} = 0.4$ (bottom row).}\n    \\label{fig:k20_04}\n\\end{figure}\n% 2022-01-18_10-37-07 k2 = 0.0013 PB TROPPO BASSO, TOLTO\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1k20_0013}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-37-07/screen0.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2k20_0013}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-37-07/screen10.png}}\n%     \\quad\n%     \\subfloat[$t = 5000s$ .\\label{3k20_0013}]{\\includegraphics[scale=0.15]{cap3/2022-01-18_10-37-07/screen25.png}}\n%     \\caption[Modifying prm overall auxin - $k_{20} = 0.0013$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.0013$.}\n%     \\label{fig:k20_0013}\n% \\end{figure}\n\nResults shown in Figure \\ref{fig:k20_039} and \\ref{fig:k20_1.3562} are obtained setting channels with $a_x = 30$ and $\\epsilon_x = 5$; comparing the figures with Figure \\ref{fig:a30epsi5}, we recognize the influence of auxin in spot formation and evolution. The more interesting feature is shown in Figure \\ref{fig:k20_1.3562}, where one can appreciate the advective power of auxin in trasporting active ROPs spot. By considering a bigger value for k20, the influence of the auxin gradient is stronger and this is demonstrated not only in the break-up of the initial stripe into multiple spots (as happened before), but also in the bending of the spot and subsequent breakup into a similar peanut-shaped spot.\n\nOther interesting results are obtained starting from a non-homogeneous initial state, precisely from the spot obtained at final time $t = 1000s$ of Figure \\ref{fig:a34}, with same channel setting, and changing $k_{20}$ to 1.3562. This sudden change in the overall auxin level leads to the formation of bending spots and to the subsequent break-up in multiple spots, considerably different from the evolution obtained for $k_{20} = 0.5$. The two evolutions are presented in Figure \\ref{fig:lk20_1.3562}.\n\n% interior stripe is more sensitive\n% to a transverse instability if it is located closer to the left-hand boundary, where the\n% inﬂuence of the auxin gradient is the strongest.\n\n% with a second stripe quickly emerging further toward the interior. Then, as these\n% structures move away from each other, both stripes break up into two half-spots\n\n% questi hanno lo stesso canale di \\ref{fig:a30epsi5} (non so perchè l'ho cambiato, devo rifarli tutti con uno unico?)\n% 2022-01-20_10-24-17 k2 = 0.39\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 50s$\\label{1k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{2k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{3k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{4k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 600s$ .\\label{5k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0300.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{6k20_039}]{\\includegraphics[scale=0.15]{cap3/2022-01-20_10-24-17/frame.0499.png}}\n%     \\caption[Modifying prm overall auxin - $k_{20} = 0.39$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.39$.}\n%     \\label{fig:k20_039}\n% \\end{figure}\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$k_{20}=0.39$: $t=50s$ \\label{1k20_039}]{\\includegraphics[scale=0.12]{cap3/2022-01-20_10-24-17/frame.0025.png}}\n    \\quad\n    \\subfloat[$t=100s$\\label{2k20_039}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-24-17/frame.0050.png}}\n    \\quad\n    \\subfloat[$t=200s$\\label{3k20_039}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-24-17/frame.0100.png}}\n    \\quad\n    \\subfloat[$t=1000s$ \\label{6k20_039}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-24-17/frame.0499.png}}\n    \\quad\n    \\subfloat[$k_{20}=0.5$: $t=50s$]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0025.png}}\n    \\quad\n    \\subfloat[$t=100s$]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0050.png}}\n    \\quad\n    \\subfloat[$t=200s$]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0100.png}}\n    \\quad\n    \\subfloat[$t=1000s$]{\\includegraphics[scale=0.11]{cap3/2022-01-16_11-41-50/frame.0499.png}}\n    \\quad\n    \\subfloat[$k_{20}=0.39$ legend \\label{legk20_039}]{\\includegraphics[scale=0.5]{cap3/2022-01-20_10-24-17/legenda.png}}\n    \\quad\n    \\subfloat[$k_{20}=0.5$ legend]{\\includegraphics[scale=0.5]{cap3/2022-01-16_11-41-50/legenda.png}}\n    \\caption[Modifying prm overall auxin - $k_{20} = 0.39$ vs $k_{20} = 0.5$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.39$ (top row) and $k_{20} = 0.5$ (bottom row).}\n    \\label{fig:k20_039}\n\\end{figure}\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$\\label{1k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 50s$\\label{2k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{3k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$ \\label{4k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 300s$ \\label{5k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0300.png}}\n    \\quad\n    \\subfloat[$t = 500s$ \\label{6k20_1.3562}]{\\includegraphics[scale=0.11]{cap3/2022-01-20_10-31-16/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-01-20_10-31-16/legenda.png}}\n    \\caption[Modifying prm overall auxin - $k_{20} = 1.3562$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 1.3562$.}\n    \\label{fig:k20_1.3562}\n\\end{figure}\n\n% 2022-01-19_12-08-30 k2 = 1.3562  from 0s→1975s\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 0s$\\label{l1k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0000.png}}\n%     \\quad\n%     \\subfloat[$t = 98s$ .\\label{l2k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 197s$ .\\label{l3k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 395s$ .\\label{l4k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 791s$ .\\label{l5k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1975s$ .\\label{l6k20_1.3562}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_12-08-30/frame.0499.png}}\n%     \\caption[Modifying prm overall auxin - $k_{20} = 1.3562$ with not hom. U0]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 1.3562$, different start.}\n%     \\label{fig:lk20_1.3562}\n% \\end{figure}\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$k_{20} = 1.3562$: $t = 0s$\\label{l1k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0000.png}}\n    \\quad\n    \\subfloat[$t = 98s$\\label{l2k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 197s$\\label{l3k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 395s$\\label{l4k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 791s$\\label{l5k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 1975s$ .\\label{l6k20_1.3562}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_12-08-30/frame.0499.png}}\n    \\quad\n    \\subfloat[$k_{20} = 0.5$: $t = 0s$\\label{l1k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0000.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{l2k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0010.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{l3k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0020.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{l4k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0040.png}}\n    \\quad\n    \\subfloat[$t = 800s$\\label{l5k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0080.png}}\n    \\quad\n    \\subfloat[$t = 4999s$\\label{l6k20_05}]{\\includegraphics[scale=0.13]{cap3/2022-01-19_10-28-16/frame.0499.png}}\n    \\quad\n    \\subfloat[$k_{20} = 1.3562$ legend]{\\includegraphics[scale=0.4]{cap3/2022-01-19_12-08-30/legenda.png}}\n    \\quad\n    \\subfloat[$k_{20} = 0.5$ legend]{\\includegraphics[scale=0.4]{cap3/2022-01-19_10-28-16/legenda.png}}\n    \\caption[Not homogeneous U0- $k_{20} = 1.3562$ vs $k_{20} = 0.5$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 1.3562$ (top rows) and $k_{20} = 0.5$ (bottom rows), different start.}\n    \\label{fig:lk20_1.3562}\n\\end{figure}\n\n% As k2 is\n% increased, there is a bifurcation into states which have increasing numbers of spots,\n% which correspond to either wild type (where there would be a unique interior spot) or\n% various multiple hair mutant types in which auxin is increased to much higher levels.\n\n% 2022-01-19_10-28-16 k2 = 0.5   from 0s→5000s\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 0s$\\label{l1k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0000.png}}\n%     \\quad\n%     \\subfloat[$t = 250s$ .\\label{l2k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{l3k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$ .\\label{l4k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 2000s$ .\\label{l5k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 4999s$ .\\label{l6k20_05}]{\\includegraphics[scale=0.15]{cap3/2022-01-19_10-28-16/frame.0499.png}}\n%     \\caption[Modifying prm overall auxin - $k_{20} = 0.5$ with not hom. U0]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} = 0.5$, different start.}\n%     \\label{fig:lk20_05}\n% \\end{figure}\n\n% \\subsection{Different initializations}\n% tolte\n% - initial state diversi, utile perchè rappresenta la prova che maggior flusso è dato da una maggiore differenza tra le due soluzioni all'inizio, poi comunque tendono a bilanciarsi(anche con canali in mezzo irrilevanti che prima non comportavano differenze col caso $\\beta_{RR} = 0$)\n%\n% canale \\ref{fig:a5epsi5}\n% % 2022-03-06_16-16-26\n% $\\epsilon_x = 5, a_x = 5, \\alpha_{RR} = 1, u^0_1 = 2.5 u^0, u^0_2 = u^0$\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 300s$ .\\label{5diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0300.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{6diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-06_16-16-26/frame.0499.png}}\n%     \\caption[2cell solver with RR - bigger initial difference]{Active ROPs $u$ evolution with RR algorithm solver with bigger initial difference}\n%     \\label{fig:diffI}\n% \\end{figure}\n% % 2022-01-24_09-49-16\n% diverso coefficiente di trasporto, $\\epsilon_x = 5, a_x = 5, \\alpha_{RR} = 7/2, u^0_1 = 2.5 u^0, u^0_2 = u^0$\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$ .\\label{2diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{3diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{4diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 300s$ .\\label{5diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0300.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{6diffI_aRR}]{\\includegraphics[scale=0.15]{cap3/2022-01-24_09-49-16/frame.0499.png}}\n%     \\caption[2cell solver with RR - bigger initial difference]{Active ROPs $u$ evolution with RR algorithm solver with bigger initial difference}\n%     \\label{fig:diffI_alphaRR}\n% \\end{figure}\n%\n% Tra questi due risultati, anche se hanno coefficiente di trasporto diversi, non vedo grandi differenze di range o di grandezza degli spot (non vorrei aver dato ad $\\alpha_{RR}$ un significato fisico sbagliato in \\ref{sec:PluriMod}). Non so se ha senso presentarli entrambi o solo il primo che mostra l'importanza della inizializzazione.\n\n\\subsection{Time-dependent auxin distribution}\n% % 2022-03-28_10-45-47 incorso\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$t = 230s$ .\\label{4auxT100}]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0115.png}}\n    \\quad\n    \\subfloat[$t = 250s$ .\\label{5auxT100}]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0125.png}}\n    \\quad\n    \\subfloat[$t = 270s$ .\\label{6auxT100}]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0135.png}}\n    \\quad\n    \\subfloat[$t = 430s$\\label{7auxT100}]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0215.png}}\n    \\quad\n    \\subfloat[$t = 450s$ .\\label{8auxT100}]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0225.png}}\n    \\quad\n    \\subfloat[$t = 470s$ ]{\\includegraphics[scale=0.12]{cap3/2022-03-28_10-45-47/frame.0235.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-03-28_10-45-47/legenda.png}}\n    \\caption[RR with time dependent auxin - period $T_{pa} = 100s$]{Active ROPs $u$ evolution with exponential auxin and sinusoidal time-dependence with period $T_{pa} = 100s$.}\n    \\label{fig:auxT100}\n\\end{figure}\n\nWe present some results assuming time dependence for auxin distribution. These simulations can be conceived as intermediate steps before the more realistic results of Chapter \\ref{cap:4}, where auxin is determined through its tranport model. We extract from other works realistic auxin distributions and we test our interpretation on the built pluricellular system.\n\n\\textbf{Periodic auxin}\n\nAt first we show results for a periodic overall auxin level characterized by a period $T_{pa} [s]$ in the following way:\n\\begin{equation}\n  k_{20} \\alpha(x,t) = k_{20} e^{-\\nu \\frac{x}{L_x}} \\sin\\left(\\frac{2\\pi t}{T_{pa}}\\right) + k_{20} ,\n\\end{equation}\nso that auxin distribution $\\alpha(x,t)$ takes values from $k_{20}$ to $2 k_{20}$.\n\nA two cell system is initialized with\n\\begin{equation*}\n \\left[ U_1^0, V_1^0 \\right] = 1.5 \\left[u^0,v^0 \\right], \\ \\ \\ \\left[ U_2^0, V_2^0 \\right] = \\left[u^0,v^0 \\right],\n\\end{equation*}\nusing the same channels settings as fot the test case in Figure \\ref{fig:a30epsi5}.\n\nFor the two test cases in Figures \\ref{fig:auxT100} and \\ref{fig:auxT200}, we select a period $T_{pa} = 100s$ and $T_{pa} = 200s$, respectively. Both the figures show that moving spots have not enough time to form since auxin gradient changes too quickly; still it is interesting to note how spot formation follows a periodicity in stripe generation and subsequent breakup.  Indeed we can see in both the figures by comparing the first with the second row that location of active ROPs is periodically the same. For example, the frame at $t = 516s$ in Figure \\ref{8auxT200} is replicated similarly after $200s$, i.e, at $t= 716s$, in Figure \\ref{12auxT200}. The feature of periodic \"half-spot\" formation confirms that auxin gradient is a key factor in determining hotspots. Similar considerations hold for Figure \\ref{fig:auxT100}.\n\n% % 2022-04-06_18-01-48 period = 200s\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$t = 450s$ \\label{5auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0225.png}}\n    \\quad\n    \\subfloat[$t = 490s$\\label{7auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0245.png}}\n    \\quad\n    \\subfloat[$t = 516s$ \\label{8auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0258.png}}\n    \\quad\n    \\subfloat[$t = 530s$ \\label{9auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0265.png}}\n    \\quad\n    \\subfloat[$t = 650s$ \\label{10auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0325.png}}\n    \\quad\n    \\subfloat[$t = 690s$ \\label{11auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0345.png}}\n    \\quad\n    \\subfloat[$t = 716s$ \\label{12auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0358.png}}\n    \\quad\n    \\subfloat[$t = 730s$ \\label{13auxT200}]{\\includegraphics[scale=0.11]{cap3/2022-04-06_18-01-48/img.0365.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-04-06_18-01-48/legenda.png}}\n    \\caption[RR with time dependent auxin - period $T_{pa} = 200s$]{Active ROPs $u$ evolution with exponential auxin and sinusoidal time-dependence with period $T_{pa} = 200s$.}\n    \\label{fig:auxT200}\n\\end{figure}\n\n% 2022-01-26_11-50-29 period = 60*40 (40 min)\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 272s$\\label{1auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0068.png}}\n%     \\quad\n%     \\subfloat[$t = 300s$ .\\label{2auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0075.png}}\n%     \\quad\n%     \\subfloat[$t = 320s$ .\\label{3auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0080.png}}\n%     \\quad\n%     \\subfloat[$t = 360s$ .\\label{4auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0090.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$ .\\label{5auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$ .\\label{6auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0125.png}}\n%     \\quad\n%     \\subfloat[$t = 1001s$ .\\label{7uxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0250.png}}\n%     \\quad\n%     \\subfloat[$t = 1999s$ .\\label{8auxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-01-26_11-50-29/frame.0499.png}}\n%     \\caption[RR with time dependent auxina - periodic $T_{pa} = 40 min$]{Active ROPs $u$ evolution with exponential auxin with sinusoidal time-dependency, $T_{pa} = 40 min$.}\n%     \\label{fig:auxT40m}\n% \\end{figure}\n\n% 2022-03-18_16-43-47 - 2022-03-20_16-25-28\nA more interesting test is obtained using $T_{pa} = 40 min = 2400 s$. The exponential dependence on space of auxin still brings a homoclinc stripe in correspondance to the auxin maximum and open channel.\n\nThere is a first time-scale associated to the usual quick break-up instability and then a second longer time-scale associated with the slowly drifting of the spots where the auxin gradient is smaller. The period is sufficiently higher than the first time-scale and thus patches are able to form.  The two spots formed seem to rest in a certain position and their amplitude oscillates with auxin values. The simulation gives us a proof of the biological stability of the pattern formation mechanism.\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$t = 208s$\\label{1LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0026.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{2LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 801s$\\label{3LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 1001s$\\label{4LuxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0125.png}}\n    \\quad\n    \\subfloat[$t = 1507s$\\label{5LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0188.png}}\n    \\quad\n    \\subfloat[$t = 2003s$\\label{6LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0250.png}}\n    \\quad\n    \\subfloat[$t = 3005s$\\label{7LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0375.png}}\n    \\quad\n    \\subfloat[$t = 4000s$\\label{8LuxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-18_16-43-47/frame.0499.png}}\n    \\quad\n    \\subfloat[$t = 5000s$\\label{9LauxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-20_16-25-28/frame.0250.png}}\n    \\quad\n    \\subfloat[$t = 6000s$\\label{10LuxT40m}]{\\includegraphics[scale=0.11]{cap3/2022-03-20_16-25-28/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-03-18_16-43-47/legenda.png}}\n    \\caption[RR with time dependent auxin - periodic $T_{pa} = 40 min$]{Active ROPs $u$ evolution with exponential auxin with sinusoidal time-dependence, $T_{pa} = 40 min$.}\n    \\label{fig:LauxT40m}\n\\end{figure}\n\n% 2022-03-20_16-05-30\n\\textbf{Auxin with maximum value smooth change}\n\nDriven by numerous studies in \\cite{intra2} over dependence of pattern formation on $k_{20}$ parameter and by results in Section \\ref{sec:k20}, we tested the multi-cellular method with a smooth change in overall auxin level, following the variation law:\n\\begin{equation*}\n  k_{20} \\alpha(x,t) = k_{20} \\left[\\frac{2}{\\pi} arctan(t - \\Tilde{T}) + \\frac{3}{2}\\right] exp\\left(- \\nu \\frac{x}{L_x}\\right).\n\\end{equation*}\nThe idea was to start with a small auxin concentration in the cell equal to $k_{20} = 0.5$ and to increase it asymptotically close to the highest value we tested for $k_{20}$ (see Figure \\ref{fig:k20_1.3562}).\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$]{\\includegraphics[scale=0.12]{cap3/2022-03-20_16-05-30/img.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$]{\\includegraphics[scale=0.12]{cap3/2022-03-20_16-05-30/img.0050.png}}\n%     \\quad\n%     % \\subfloat[$t = 100s$]{\\includegraphics[scale=0.12]{cap3/2022-03-20_16-05-30/img.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 500s$]{\\includegraphics[scale=0.12]{cap3/2022-03-20_16-05-30/img.0499.png}}\n%     \\quad\n%     \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-03-20_16-05-30/legenda.png}}\n%     \\caption[Time dependent prm homogeneous auxin - $k_{20} ~ arctan(t)$]{Active ROPs $u$ evolution with RR algorithm solver with $k_{20} \\alpha(t) = \\frac{2}{\\pi} k_{20} arctan(x - \\Tilde{T}) + \\frac{3}{2}k_{20}$.}\n%     \\label{fig:Harctan}\n% \\end{figure}\n% Taking auxin distribution homogeneous, being $\\nu = 0$, change in time of auxin concentration is not enough to lead to a pattern formation (see Figure \\ref{fig:Harctan}).\n\n Taking auxin exponential distribution with $\\nu = 1.5$, a spot driving to the right is formed. Comparing the result in Figure \\ref{fig:NHarctan} with the one in Figure \\ref{fig:lk20_1.3562}, the milder change in auxin level brings a different evolution in the breakups of spots. A bigger unique spot is formed in the first $50 s$ similar to Figure \\ref{k20_05:50s}, the following frame at time $t = 100s$ shows a more bended spot and after $t = \\Tilde{T} = 200s$ the simulation results start to recall the one in Figure \\ref{fig:k20_1.3562}. After more time steps, the increase in the overall auxin level brings multiple patches from the breakup of the peanut shaped one.\n % 2022-04-10_01-05-49 rifatta che era sbagliata\n\\begin{figure}[H]\n     \\centering\n     \\subfloat[$t = 50s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0025.png}}\n     \\quad\n     \\subfloat[$t = 100s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0050.png}}\n     \\quad\n     \\subfloat[$t = 200s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0100.png}}\n     \\quad\n     \\subfloat[$t = 220s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0110.png}}\n     \\quad\n     \\subfloat[$t = 250s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0125.png}}\n     \\quad\n     \\subfloat[$t = 500s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0250.png}}\n     \\quad\n     \\subfloat[$t = 600s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0300.png}}\n     \\quad\n     \\subfloat[$t = 800s$]{\\includegraphics[scale=0.11]{cap3/2022-04-10_01-05-49/frame.0400.png}}\n     \\quad\n     \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-04-10_01-05-49/legenda.png}}\n     \\caption[Time dependent prm homogeneous auxin - $k_{20} ~ arctan(x,t)$]{Active ROPs $u$ evolution with RR solver with $k_{20} \\alpha(x,t) = k_{20} \\left[\\frac{2}{\\pi} arctan(t - \\Tilde{T}) + \\frac{3}{2}\\right] exp(- \\nu \\frac{x}{L_x})$, with $\\Tilde{T} = 200s$.}\n     \\label{fig:NHarctan}\n \\end{figure}\n\n \\textbf{Auxin with maximum position moving}\n\nOther works and some results in the previous section highlight the importance of the location of the maximum and of the gradient of the auxin \\cite{article:Veronica, intra2}. Actually the position may change in time, because of other morphogenetic processes involved in root-hair initiation. This lead us to test, as a first approximated attempt, the behaviour of the system under moving maximum position of the auxin gradient. We keep a smooth dependence in space defining the auxin distribution as follows:\n\\begin{equation*}\n  k_{20} \\alpha(x,t) = k_{20} exp\\left( -\\nu \\frac{x-x_0(t)}{L_x}\\right) \\mathbb{1}\\left(x \\geq x_0(t)\\right) + k_{20} exp\\left(\\nu \\frac{x-x_0}{L_x} \\right) \\mathbb{1}(x\\leq x_0(t)),\n\\end{equation*}\n$x_0(t)$ being time-dependant.\n\nWe simulate the system up to $T_{max} = 4000s$, with auxin maximum position moving from the left to the right and representing itself again at the left boundary every interval of $1000s$. In particular maximum coordinate is defined as follows:\n\\begin{equation*}\n  x_0(t) = \\frac{L_x}{\\Tilde{T}} (t\\% \\Tilde{T}).\n\\end{equation*}\nIn order to give a better idea, the gradient of auxin that crosses the cell system for the first interval of $1000s$ is presented in Figure \\ref{fig:A1}.\n% In Figure \\ref{fig:Amax1} frames of the simulation obtained with $x_0(t) =  \\frac{L_x}{T_{max}} * t$ are presented and the differences with fixed maximum simulation in figure \\ref{fig:a30epsi5} seem to be the spot moving faster and the higher values of active concentration reached.\n\nThe appearance of maximum auxin, probably influenced also by the open channels, increases the spot formation in the system and confirms the relevance in the location with respect to space and time of the auxin gradient. The hotspots interact with one another and alternate different behaviours, unifying in one single and then dividing in smaller spots.\n% 2022-04-02_10-18-15 rifacendo ... ho trovato la differenza! questo prima era il Parall mode\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 25s$\\label{1A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA25.png}}\n    % \\quad\n    % \\subfloat[$t = 50s$\\label{2A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA50.png}}\n    % \\quad\n    % \\subfloat[$t = 100s$\\label{3A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA100.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{4A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA200.png}}\n    \\quad\n    % \\subfloat[$t = 400s$\\label{5A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA200.png}}\n    % \\quad\n    \\subfloat[$t = 1000s$\\label{6A1}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-25-20/screenA1000.png}}\n    \\caption[Time dependent auxin - moving max]{Evolution of the auxin distribution with maximum time-dependent position $x_0(t) = \\frac{L_x}{\\Tilde{T}} (t\\% \\Tilde{T})$.}\n    \\label{fig:A1}\n\\end{figure}\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 25s$\\label{1Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0012.png}}\n%     \\quad\n%     \\subfloat[$t = 50s$\\label{2Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0025.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$\\label{3Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$\\label{4Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 400s$\\label{5Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 1000s$\\label{6Amax1}]{\\includegraphics[scale=0.12]{cap3/2022-04-02_10-18-15/img.0499.png}}\n%     \\quad\n%     \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-04-02_10-18-15/legenda.png}}\n%     \\caption[RR with time dependent auxina - moving max]{Active ROPs $u$ evolution with exponential auxin with maximum position time-dependent $x_0(t) = \\frac{L_x}{T_{max}} * t$.}\n%     \\label{fig:Amax1}\n% \\end{figure}\n  % 2022-03-20_10-53-03\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 48s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0006.png}}\n    \\quad\n    \\subfloat[$t = 104s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0013.png}}\n    \\quad\n    \\subfloat[$t = 256s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0032.png}}\n    \\quad\n    \\subfloat[$t = 504s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0063.png}}\n    \\quad\n    \\subfloat[$t = 1001s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0125.png}}\n    \\quad\n    \\subfloat[$t = 1290s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0156.png}}\n    \\quad\n    \\subfloat[$t = 1498s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0187.png}}\n    \\quad\n    \\subfloat[$t = 2003s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0250.png}}\n    \\quad\n    \\subfloat[$t = 2500s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0312.png}}\n    % \\quad\n    % \\subfloat[$t = 3006s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0375.png}}\n    \\quad\n    \\subfloat[$t = 4000s$]{\\includegraphics[scale=0.1]{cap3/2022-03-20_10-53-03/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-03-20_10-53-03/legenda.png}}\n    \\caption[RR with time dependent auxin - moving max]{Active ROPs $u$ evolution with exponential auxin with maximum position time-dependent $x_0(t) = \\frac{L_x}{\\Tilde{T}} (t\\% \\Tilde{T})$.}\n    \\label{fig:Amax3}\n\\end{figure}\n\n\\subsection{Four cell system}\nFinally, we implement a solver for a more complex multi-cellular system, in order to investigate the influence of a model of communication between cells both longitudinally and transversally.\nThe new functions identifying open channels for inter-cellular communication are defined as follows:\n\\begin{equation}\\begin{aligned}\n   \\beta_{u/vRR} & = \\mathbb{1} \\Big\\{ \\frac{L_x}{2} - a_x - \\epsilon_x \\leq x \\leq \\frac{L_x}{2} - a_x \\Big\\} + \\mathbb{1} \\Big\\{ \\frac{L_x}{2}+a_x \\leq x \\leq \\frac{L_x}{2} + a_x+\\epsilon_x \\Big\\} \\\\\n   & + \\mathbb{1} \\Big\\{ \\frac{3L_x}{2}-a_x-\\epsilon_x \\leq x \\leq \\frac{3L_x}{2} - a_x \\Big\\}\n   + \\mathbb{1} \\Big\\{ \\frac{3L_x}{2}+_x \\leq x \\leq \\frac{3L_x}{2} + a_x+\\epsilon_x \\Big\\} \\\\\n   & + \\mathbb{1} \\Big\\{ \\frac{L_y}{2}-a_y-\\epsilon_y \\leq y \\leq \\frac{L_y}{2} - a_y \\Big\\} + \\mathbb{1} \\Big\\{ \\frac{3L_y}{2}-a_y-\\epsilon_y \\leq y \\leq \\frac{3L_y}{2} - a_y \\Big\\} \\\\\n   & + \\mathbb{1} \\Big\\{ \\frac{L_y}{2}+a_y \\leq y \\leq \\frac{L_y}{2} + a_y +\\epsilon_y \\Big\\} + \\mathbb{1} \\Big\\{ \\frac{3L_y}{2}+a_y \\leq y \\leq \\frac{3L_y}{2} + a_y +\\epsilon_y \\Big\\},\n\\end{aligned}\\end{equation}\nwith $a_y$ and $\\epsilon_y$ having an analogous meaning for vertical borders as for $a_x$ and $\\epsilon_x$ for horizontal borders, respectively.\n\nIn Figure \\ref{fig:4cbeta0} the reference solution corresponding to a full no-flux boundary condition on all borders is presented. It was obtained setting the initial state to:\n\\begin{equation}\\label{eq:initstate4} \\begin{aligned}\n    \\left[ U_1^0, V_1^0 \\right] = \\left[ U_2^0, V_2^0 \\right] & = 1.5 \\left[u^0,v^0 \\right] \\\\\n    \\left[ U_3^0, V_3^0 \\right] = \\left[ U_2^0, V_2^0 \\right] & = \\left[u^0,v^0 \\right],\n\\end{aligned} \\end{equation}\nwhile the auxin distribution is defined as in \\eqref{eq:alpha_exp} under Table \\ref{tab:setprm} - Set C of parameters.\n\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 0s  $\\label{14cbeta0}]{\\includegraphics[scale=0.15]{cap3/2022-01-22_12-35-26/frame.0000.png}}\n    \\quad\n    \\subfloat[$t = 50s$\\label{24cbeta0}]{\\includegraphics[scale=0.15]{cap3/2022-01-22_12-35-26/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{34cbeta0}]{\\includegraphics[scale=0.15]{cap3/2022-01-22_12-35-26/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 499s$\\label{44cbeta0}]{\\includegraphics[scale=0.15]{cap3/2022-01-22_12-35-26/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-01-22_12-35-26/legenda.png}}\n    \\caption[4cell RR Active ROPs - $\\beta_{RR} = 0 $]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\beta_{RR} = 0 $.}\n    \\label{fig:4cbeta0}\n\\end{figure}\n% 2022-01-22_18-30-11\nWe replicate the no-flux reference solution with a different auxin distribution in order to have a possible comparison for other attempts with open transverse channels located where we have the maximum value for the auxin. We therefore set the auxin distribution as follows:\n\\begin{equation*}\n  k_{20} \\alpha(x) = k_{20} exp\\left(-\\nu \\frac{x-x_0}{L_x}\\right) \\mathbb{1}(x\\geq x_0) + k_{20} exp\\left(\\nu \\frac{x-x_0}{L_x}\\right) \\mathbb{1}(x\\leq x_0),\n\\end{equation*}\nbeing $x_0 =  L_x = 70 \\mu m$.\n\n% 2022-03-21_08-49-35\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 50s$]{\\includegraphics[scale=0.15]{cap3/2022-03-21_08-49-35/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$]{\\includegraphics[scale=0.15]{cap3/2022-03-21_08-49-35/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$]{\\includegraphics[scale=0.15]{cap3/2022-03-21_08-49-35/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 499s$]{\\includegraphics[scale=0.15]{cap3/2022-03-21_08-49-35/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-03-21_08-49-35/legenda.png}}\n    \\caption[4cell RR Active ROPs - mid gradient, no-flux BC]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 70 \\mu m$ and no-flux boundary condition: $\\beta_{uRR} = \\beta_{vRR} = 0$.}\n    \\label{fig:4c_gradmid_beta0}\n\\end{figure}\nFigure \\ref{fig:4c_gradmid_beta0} confirms the influence of auxin gradient in the location of the front formed and in the subsequent break-up instability of the stripe into spots.\n% slide 54-55-56 (non so se ha senso, test che si può citare).  bella in slide 56 che c'è come da un lato gradiente di auxina che vorrebbe formare pallocchi a sinistra dall'altro però il trasporto al bordo (same init dovrebbe far vedere il caso senza trasporto perchè sono uguali). può aver senso fare vedere un confronto tra i due\n% però per 4 cells slide 69 ha canali diversi bah su y\n\n% 2022-01-26_09-42-40\nIn Figure \\ref{fig:4c_gradmid_sameI} results obtained with channels characterized by parameters $\\epsilon_x = 5,  a_x = 30,  \\epsilon_y = 1$ and $a_y = 10$ are presented, without difference in the initialization of variables:\n\\begin{equation*}\\begin{aligned}\n  U_1^0 & = U_2^0 = U_3^0 = U_4^0 = u^0 \\\\\n  V_1^0 & = V_2^0 = V_3^0 = V_4^0 = v^0.\n\\end{aligned}\\end{equation*}\n\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$t = 50s  $\\label{14c_gradmid_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-01-26_09-42-40/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$ .\\label{24c_gradmid_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-01-26_09-42-40/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$ .\\label{34c_gradmid_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-01-26_09-42-40/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 499s$ .\\label{44c_gradmid_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-01-26_09-42-40/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-01-26_09-42-40/legenda.png}}\n    \\caption[4cell RR Active ROPs - mid gradient, same initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 70 \\mu m$ and same initial state.}\n    \\label{fig:4c_gradmid_sameI}\n\\end{figure}\nWe focus on this simulation in order to underline one feature of this RD system. The whole setting is symmetric with respect to the $y$ axis, therefore the solution obtained should still be valid reflecting it. The solution here is not symmetric as expected because the slightly imperfection, in evolution is propagated and leads to different patterns between the right and left side of the four cells.\n% 2022-01-23_16-53-21\n% \\towrite{io: forse questo rispetto a quelli dopo mette evvidenza dell'importanza solita de gradiente e max di auxina su dove si collocano gli spot.  lo si può confrontare con \\ref{fig:4c_gradmid_beta0} molto diverso, strano ...\n% I risultati in \\ref{fig:4c_gradD_sameI} e \\ref{fig:4c_gradD_diffI} a confronto fanno vedere come sia influente l'inizializzazione, ovvero flusso dalle cellule di sinistra a quelle di destra e incrementa l'instabolità e la formazione di spot? .}\n\nA completely different result is obtained with the difference in the initial concentrations of ROPs, as in \\eqref{eq:initstate4}; the discrepancy generates flux between neighboring cells in the direction of the auxin gradient.\n\\begin{figure}[t]\n    \\centering\n    \\subfloat[$t = 50s  $\\label{14c_gradmid_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-01-23_16-53-21/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$ .\\label{24c_gradmid_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-01-23_16-53-21/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$ .\\label{34c_gradmid_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-01-23_16-53-21/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 499s$ .\\label{44c_gradmid_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-01-23_16-53-21/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-01-23_16-53-21/legenda.png}}\n    \\caption[4cell RR Active ROPs - mid gradient, different initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 70 \\mu m$ and different initial state.}\n    \\label{fig:4c_gradmid_diffI}\n\\end{figure}\nResults in Figure \\ref{fig:4c_gradmid_diffI}, obtained with openened channels and initial different concentrations, show a more symmetric and unified pattern formation, which is more feasible with respect to the one obtained whe  neglecting cells communications presented in Figure \\ref{fig:4c_gradmid_beta0}. Even if the system is homogeneus with respect to line $y = 30$ at the beginning, the spot formed at the end does not maintian this symmetry. A possible reason is the gradient in $y$ direction because of open channels; it makes the upper and lower part evolve differently.\n% \\towrite{non sicura di questo commento. da rivedere}\n\nWe then set the system with auxin maximum located at the right border, as follows:\n\\begin{equation*}\n  k_{20} \\alpha(x) = k_{20} exp\\left(\\nu \\frac{x-x_0}{L_x} \\right) \\mathbb{1}(x\\leq x_0) \\ \\ \\text{, with} \\ \\ x_0 = 2 L_x,\n\\end{equation*}\nand we keep the initialization as in \\eqref{eq:initstate4}.\n% As expected, without difference in the initial concentrations no flux between left and right cells is generated and spots are formed mainly due to the immediate influence of auxin gradient; in Figure \\ref{fig:4c_gradD_sameI} is shown that a front is formed at the extreme right side and then it breaks into spots driving towards auxin minimum.\n% same initial state:  $ U_1^0 = U_2^0 = U_3^0 = U_4^0 = u^0 $\n% 2022-03-07_09-46-14 grad a destra same init da confrontare con dopo\n% QUESTO DECISO DI TOGLIERLO\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 50s  $\\label{14c_gradD_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-46-14/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{24c_gradD_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-46-14/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{34c_gradD_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-46-14/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 499s$ .\\label{44c_gradD_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-46-14/frame.0499.png}}\n%     \\caption[4cell RR Active ROPs - inverse gradient, same initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 140 \\mu m$ and same initial state.}\n%     \\label{fig:4c_gradD_sameI}\n% \\end{figure}\n% different intial state: $ U_1^0 = U_2^0 = 2 u^0, U_3^0 = U_4^0 = u^0 $\n% % 2022-03-07_09-47-49 grad a destra init u1 = u2 = 2 u0\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 50s  $\\label{14c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-47-49/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{24c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-47-49/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{34c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-47-49/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 499s$ .\\label{44c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_09-47-49/frame.0499.png}}\n%     \\caption[4cell RR Active ROPs - inverse gradient, different initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 140 \\mu m$ and different initial state.}\n%     \\label{fig:4c_gradD_diffI}\n% \\end{figure}\n%\n% 2022-03-07_13-07-00 sto facendo con inti meno diversa ovvero u1 = u2 = 1.5 u0\n% Different pattern formation is generated with different initial concentrations in direction of the auxin gradient, as in \\eqref{eq:initstate4}.\nFigure \\ref{fig:4c_gradD_diffI} shows that active ROPs are formed both because of gradient of auxin and because of fluxes between neighboring cells. Indeed, on one hand we again observe patches at the extreme right side where auxin maximum is located. On the other hand, at the transverse interface, auxin level is low and one should not expect spontaneous spot formation. Still, the difference at the beginning generates a gradient of ROPs along the $x$ direction that cooperates with auxin and induces new hotspots at the interface of the cells.\n\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 50s  $\\label{14c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-07-00/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 100s$ .\\label{24c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-07-00/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 200s$ .\\label{34c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-07-00/frame.0200.png}}\n    \\quad\n    \\subfloat[$t = 499s$ .\\label{44c_gradD_diffI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-07-00/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.4]{cap3/2022-03-07_13-07-00/legenda.png}}\n    \\caption[4cell RR Active ROPs - inverse gradient, different initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 140 \\mu m$ and different initial state.}\n    \\label{fig:4c_gradD_diffI}\n\\end{figure}\nThis is a first result that sustains the idea that a self-generated spot formation of ROPs may be induced not only by a gradient of auxin, but also by a gradient of ROPs itself.\n% 2022-03-07_13-09-39 same init ma canale in mezzo più largo eps y = 3\n% Same initial state but bigger channel in y direction: $\\epsilon_y = 3$ TOLTO\n% \\begin{figure}[H]\n%     \\centering\n%     \\subfloat[$t = 50s  $\\label{14c_chanY_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-09-39/frame.0050.png}}\n%     \\quad\n%     \\subfloat[$t = 100s$ .\\label{24c_chanY_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-09-39/frame.0100.png}}\n%     \\quad\n%     \\subfloat[$t = 200s$ .\\label{34c_chanY_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-09-39/frame.0200.png}}\n%     \\quad\n%     \\subfloat[$t = 499s$ .\\label{44c_chanY_sameI}]{\\includegraphics[scale=0.15]{cap3/2022-03-07_13-09-39/frame.0499.png}}\n%     \\caption[4cell RR Active ROPs - with $\\epsilon_y = 3$, inverse gradient, different initial state]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with $\\alpha$ maximum in $x = 140 \\mu m$, same initial state and $\\epsilon_y = 3$.}\n%     \\label{fig:4c_chanY_sameI}\n% \\end{figure}\n%\n% \\towrite{Confrontandolo con \\ref{fig:4c_gradD_sameI} sembra che essendoci un canale più ampio in direzione y, qua è più difficile che si creino gli spot così ben definti come prima o più semplicemente c'è la stessa dinamica ma leggermente in ritardo qua.\n%\n% forse ha senso farlo con canale più ampio e diff init? salterei questo ultimo. perchè non dice tanto di nuovo.\n% }\n% 2022-03-06_16-32-46 grad a destra same init ma canale fatto sbagliato solo a sinistra x\n% 2022-03-06_16-33-54 grad a destra init u1 = u2 = 2 u0 ma canale sbagliato solo a sinistra x ...\n% canale εx = 5,ax = 30, alpha_RR = 1, εy = 1,ay = 10\n\n\\textbf{Auxin with moving maximum position}\n\nWe finally present for the multi-cellular system composed by four cells the results obtained by setting the system with initial state as defined in \\eqref{eq:initstate4} and under the following auxin distribution:\n\\begin{equation*}\n  k_{20} \\alpha(x,t) = k_{20} exp\\left(-\\nu\\frac{x-x_0}{L_x}\\right)  \\mathbb{1}(x\\geq x_0) + k_{20} exp\\left(\\nu \\frac{x-x_0}{L_x}\\right) \\mathbb{1}(x\\leq x_0),\n\\end{equation*}\nwith maximum position $x_0(t) = \\frac{2 L_x}{T_{max}} t$. The idea behind this attempts is similar to the ones presented before with a two cells system. Auxin distribution may change in time because of other biological precesses. Other works stated the relevance of maximum location \\cite{article:Veronica}. Here we impose an auxin gradient that crosses the system, with maximum moving from the extreme left side towards the right side.\n\nIn order to appreciate the dynamics observed, the simulation has to be compared with results under fixed auxin distribution, having maximum at $x = 70 \\mu m$ or at the right side, presented in Figures \\ref{fig:4c_gradmid_diffI} and \\ref{fig:4c_gradD_diffI} respectively.\n\nFirstly, in Figure \\ref{fig:4cTmax} auxin gradient influence on pattern formation is confirmed: it defines where stripes or patches locate and the velocity spots travel. A second stripe and subsequent spots emerge from homogeneous null concentration, after auxin maximum reaches the interface, probably thanks to the influence of open channels. The interplay between multi-cellular structural communication modelled and auxin distribution brings an instability of the system and patches are formed at the boundaries and transported through the system.\n\nThis result confirms the need to consider properly cell communication together with intra-cellular dynamic, in order to devise a complete model for root-hair initiation in a multi-cellular system.\n\nWe present in Tables \\ref{table:summaryRes} and \\ref{table:4c_summaryRes} a scheme of the results in order to give to the reader an overview of the motivations and main conclusions of each test.\n% Channels are characterized by usual parameters:\n% $$\\epsilon_x = 5,  a_x = 30,  \\epsilon_y = 1, a_y = 10$$\n\\begin{figure}[H]\n    \\centering\n    \\subfloat[$t = 50s$\\label{14cTmax}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0025.png}}\n    \\quad\n    \\subfloat[$t = 100s$\\label{24cTmax}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0050.png}}\n    \\quad\n    \\subfloat[$t = 200s$\\label{34cTmax}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0100.png}}\n    \\quad\n    \\subfloat[$t = 400s$\\label{44cTmax}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0200.png}}\n    % \\quad\n    % \\subfloat[$t = 500s$ .\\label{44cTmax}]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0250.png}}\n    \\quad\n    \\subfloat[$t = 524s$]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0262.png}}\n    \\quad\n    \\subfloat[$t = 600s$]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0300.png}}\n    \\quad\n    \\subfloat[$t = 750s$]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0375.png}}\n    \\quad\n    \\subfloat[$t = 999s$]{\\includegraphics[scale=0.15]{cap3/2022-01-27_09-42-34/frame.0499.png}}\n    \\quad\n    \\subfloat[]{\\includegraphics[scale=0.5]{cap3/2022-01-27_09-42-34/legenda.png}}\n    \\caption[4cell RR Active ROPs - auxin time-dependent]{Active ROPs $u$ evolution with RR algorithm solver on 4 cells system with auxin maximum moving to the right.}\n    \\label{fig:4cTmax}\n\\end{figure}\n\n\\begin{table}[H]\n  \\caption*{\\textbf{Table summarizing presented results}}\n    \\begin{tabular}{|p{3cm} |l l p{3cm}|}\n    \\hline\n%    \\rowcolor{bluepoli!40}\n    \\textbf{Experiment} & \\textbf{Motivations} & \\textbf{Main conclusions} & \\textbf{Figures} \\T\\B \\\\\n    \\hline \\hline\n    % \\textbf{E1} - RRclassic & Simulate free-flux & Too loose boundaries & \\ref{fig:RR}  \\T\\B\\\\\n    % \\hline\n    \\textbf{E1} & Simulate no-flux & \\parbox[t]{4cm}{Stagnant cells \\\\ behaviour \\T\\B} & \\ref{fig:beta0}  \\T\\B\\\\\n    \\hline\n    \\textbf{E2} - vary $a_x$ & \\parbox[t]{4cm}{Tuning channels \\\\ parameters} & \\parbox[t]{4cm}{Importance of channel \\\\ location w.r.t \\\\ auxin gradient \\T\\B} & \\ref{fig:a5} - \\ref{fig:a20} -\\ref{fig:a30} - \\ref{fig:a34}  \\T\\B\\\\\n    \\hline\n    \\textbf{E3} - vary $\\epsilon_x$ & \\parbox[t]{4cm}{Tuning channels \\\\ parameters} & \\parbox[t]{4cm}{Amplitude of channels \\\\ is less relevant} & \\ref{fig:a5epsi5} - \\ref{fig:a30epsi5} \\T\\B\\\\\n    \\hline\n    \\textbf{E4} - increase $\\alpha_{u,vRR}$ & \\parbox[t]{4cm}{Tuning channels \\\\ parameters} & Symmetry increase & \\ref{fig:a34alpha35} \\T\\B\\\\\n    \\hline\n    \\textbf{E5} & \\parbox[t]{4cm}{Test detailed \\\\ sparse channels} & \\parbox[t]{4cm}{Check good approximation of simple channels \\T\\B} & \\ref{fig:multich} \\T\\B\\\\\n    \\hline\n    \\textbf{E6} & \\parbox[t]{4cm}{Test P mode \\\\ vs NP mode} & \\parbox[t]{4cm}{Considerable \\\\ difference with \\\\ relevant channels \\T\\B} & \\ref{fig:NPvsP2} \\T\\B\\\\\n    \\hline\n    \\textbf{E7} - $k_{20}$ & \\parbox[t]{3cm}{Observe dependence of system on $k_{20}$} & \\parbox[t]{4cm}{Increase of multiple spots and auxin advection power at borders \\T\\B} & \\ref{fig:k20_04} - \\ref{fig:k20_039} - \\ref{fig:k20_1.3562} - \\ref{fig:lk20_1.3562}\\T\\B\\\\\n    \\hline\n    \\textbf{E8} auxin time-dep & \\parbox[t]{4cm}{Simulate \\\\ periodic auxin: \\\\ $T_{pa} = 100s, 200s $} & \\parbox[t]{4cm}{Too small period} & \\ref{fig:auxT100} - \\ref{fig:auxT200} \\T\\B\\\\\n    \\hline\n    \\textbf{E9} auxin time-dep & \\parbox[t]{4cm}{Simulate \\\\ periodic auxin: \\\\ $T_{pa} = 40 min$} & \\parbox[t]{4cm} {Realistic driving spot} & \\ref{fig:LauxT40m} \\T\\B\\\\\n    \\hline\n    \\textbf{E10} auxin time-dep & \\parbox[t]{4cm}{Simulate \\\\ soften change in $k_{20}$} & \\parbox[t]{4cm}{Show a similar bending and breking spots} & \\ref{fig:NHarctan} \\T\\B\\\\\n    \\hline\n    \\textbf{E11} auxin time-dep & \\parbox[t]{4cm}{Simulate moving \\\\ auxin maximum \\\\ postion periodically \\T\\B} & \\parbox[t]{4cm}{Multiple spots  periodically break} & \\ref{fig:Amax3} \\T\\B\\\\\n    % \\hline\n    % \\textbf{E12} auxin time-dep & \\parbox[t]{4cm}{Validate \\\\ interpretation of RR \\\\ vs monolithic problem \\T\\B} & \\parbox[t]{4cm}{Different evolution \\\\ caused by \\\\ imperfections} & \\ref{fig:mono} \\T\\B\\\\\n    \\hline\n    \\end{tabular}\n    \\\\[10pt]\n    \\caption[Table summarizing RR results on 2 cells system]{}\n    \\label{table:summaryRes}\n\\end{table}\n\n\\begin{table}[H]\n  \\caption*{\\textbf{Table summarizing presented results}}\n    \\begin{tabular}{|p{3cm} |l l p{3cm}|}\n    \\hline\n%    \\rowcolor{bluepoli!40}\n    \\textbf{Experiment} & \\textbf{Motivations} & \\textbf{Main conclusions} & \\textbf{Figures} \\T\\B \\\\\n    \\hline \\hline\n    \\textbf{E12} 4cells & \\parbox[t]{4cm}{Simulate no-flux with right maximum auxin  \\T\\B} & \\parbox[t]{4cm}{Stable spots form from break stripe  \\T\\B} & \\ref{fig:4cbeta0} \\T\\B\\\\\n    \\hline\n    \\textbf{E13} 4cells & \\parbox[t]{4cm}{Simulate no-flux with middle maximum \\\\ auxin} & \\parbox[t]{4cm}{Spot location \\\\ depend on maximum location; no communication brings irregular spots \\T\\B} & \\ref{fig:4c_gradmid_beta0} \\T\\B\\\\\n    \\hline\n    \\textbf{E14} 4cells & \\parbox[t]{4cm}{Middle maximum \\\\ auxin with open \\\\ channels \\T\\B} & \\parbox[t]{4cm}{Initial state gradient influence spot; symmetry issues \\T\\B} & \\ref{fig:4c_gradmid_sameI} - \\ref{fig:4c_gradmid_diffI} \\T\\B\\\\\n    \\hline\n    \\textbf{E15} 4cells & \\parbox[t]{4cm}{Right auxin maximum with open channels \\T\\B} & \\parbox[t]{4cm}{Both ROP flux and auxin gradient cooperate in spot formation \\T\\B} & \\ref{fig:4c_gradD_diffI} \\T\\B\\\\\n    \\hline\n    \\textbf{E16} 4cells & Moving maximum auxin  & \\parbox[t]{4cm}{Gradient of auxin and of ROPs influence spot appearence \\T\\B} & \\ref{fig:4cTmax} \\T\\B\\\\\n    \\hline\n    \\end{tabular}\n    \\\\[10pt]\n    \\caption[Table summarizing RR results on 4 cells system]{}\n    \\label{table:4c_summaryRes}\n\\end{table}\n\n% DUBBI\n% - RR classico, non lo nomino .. o si come confronto? prima e dopo interpolate totalmente diveros ... check slide 18\n% - beta nullo per confronto (no canali aperti)? slide 22 2cell-DD study\n% - risultati intermedi (presentazione 2cell-DD study slide 8-9-10; 12-16 forse sbagliate per vecchio uso interpolate)\n% - tentativi alpha neg e U,Vbar\n% -  slide 24: canali in mezzo poco significativi\n% - 2cell geomtric ... ma su sloide 59 aveva fatto un lungo discorso che poco ricordo, forse che essendoci differenza allora trasporto allora pallocchi di più\n% - esagonali: carini ma auxina doveva essere fatta radiale quindi poco senso slide 70-71-72\n\n\n% try PRM for two cell\n% - varia a -> far vedere che sensibilmente cambia se ...\n% - varia epsilon -> meno impo ...\n% - varia alphaRR -> impo per significato fisico quindi che ha senso tunnarlo; confronta a parità di canali per far vedere cosa succede aumentandolo o no e dove\n% - tentativi con canali strani: poco significativi se vogliamo dire che quei beta sono una \"media\" dei canali attivi; uno fa vedere che velocizza perchè così lo spot si muove e non è localizzata solo all'inizio l'influenza del canale aperto (forse quello carino ...) tipo slide 29-30 o prima 28\n% - mode parall. vs mode normale: confronto? (di fatto sono leggermente diversi, ce lo aspettiamo per sensibilità del sistema ma bah)\n% - varia k20 con 2 cell: leggeri cambiamenti, forse ha senso perchè nel paper viene citato quel prm e è una validazione del fatto che ancora fisicamente ha valore nel nostro setting nuovo (~) slide 34-36. slide 35 sbagliata. nei paper k2 lo faceva variare partendoda una striscia e osserva la formazione di più spot (allineari con asse x ..), noi emh no. dopo abbiamo fatto così cioè cambiato k2 solo da un certo time in poi: carine slide 39 dove si vedono più spot come negli altri paper (confronti, non saprei poi \"fisicamente\" cosa rappresentano)\n% - 4 cells: tentativo intermedio beta = 0 slide 52, confrono parall e non slide 53 (confronti intermedi forse non necessarissimi)\n% - 4 cells, auxina diversa slide 54-55-56 (non so se ha senso, test che si può citare). strana la cosa dell'ibrido parall e non totalmente diverso. bella in 56 che c'è come da un lato gradiente di auxina che vorrebbe formare pallocchi a sinistra dall'altro eprò ul trasporto al bordo (same init dovrebbe far vedere il caso senza trasporto perchè sono uguali)\n% - slide 57: diversi init utile perchè rappresenta la prova che maggior flusso è dato dalla differenza tra le due soluzioni (anche con canali in mezzo)\n% - grad auxina diverso 2 cell: slide 61 vedi che viene uguale nella'ltro verso -> prova importanza grad ?\n% - auxina tempo dep: ? slide 62-64 periodici non chiara però se sensati e interpretazione (periodo ...); corrisponderebbero a formazioni periodiche di spot\n% - auxina tempo dep con max che si sposta -> giustificati da paper veronica e altro? slide 65  slide 68 carino che poi si vede formarsi spot dove prima sembrava non ci fosse più ROP, slide 69 ha canali diversi bah su y\n", "meta": {"hexsha": "67d19098f063e2968db4576bd33588892d502f98", "size": 131536, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Thesis/Chapter3.tex", "max_stars_repo_name": "danieleavitabile/root-simulator", "max_stars_repo_head_hexsha": "b530efef392f3cabbc251ee5f0d7d50dea2271d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Thesis/Chapter3.tex", "max_issues_repo_name": "danieleavitabile/root-simulator", "max_issues_repo_head_hexsha": "b530efef392f3cabbc251ee5f0d7d50dea2271d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Thesis/Chapter3.tex", "max_forks_repo_name": "danieleavitabile/root-simulator", "max_forks_repo_head_hexsha": "b530efef392f3cabbc251ee5f0d7d50dea2271d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 81.699378882, "max_line_length": 1095, "alphanum_fraction": 0.6970943316, "num_tokens": 48186, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.40009605731884457}}
{"text": "\\subsection{Test 2: Steady-State Critical Flow Over an Uncertain Bed}\n\nThis test is designed to challenge the stochastic Galerkin model at representing highly non-Gaussian and discontinuous distributions of stochastic flow.\nThe uncertain topography profile and inflow boundary condition are chosen in order to produce a nonlinear response such that the steady-state solution may be subcritical or transcritical depending on the bed elevation.\nResults of the stochastic Galerkin model are validated against a Monte Carlo simulation that serves as a reference solution.\n\n\\subsubsection{Setup to Produce a Nonlinear Flow Response}\nThe uncertain topography is the smooth hump given by equation~\\eqref{eqn:z-pc-coeffs}.\nSubcritical boundary conditions are imposed such that the mean upstream discharge per unit-width is \\SI{1.65}{\\meter\\squared\\per\\second} and the mean downstream water depth is \\SI{1.5}{\\meter}, with no uncertainty for the upstream discharge and downstream water depth.\nTransmissive boundary conditions are used for the upstream water depth and downstream discharge.\nThese boundary conditions are chosen so that the flow is exactly critical for the mean hump amplitude $\\humpmean = \\SI{0.6}{\\meter}$ at $x = \\SI{0}{\\meter}$.\nSince the hump amplitude is uncertain then the flow regime is also uncertain: if the hump amplitude is less than $\\humpmean$ then the flow remains subcritical; if the hump amplitude is greater than $\\humpmean$ then the flow regime becomes transcritical.\nIn the transcritical regime, the flow upstream of the hump is subcritical, transitioning to supercritical flow over the hump.\nA hydraulic jump occurs on the downstream side of the hump, where the flow becomes subcritical once more.\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{fig-criticalSteadyState-examples.pdf}\n    \\caption{Well-balanced deterministic solutions of steady-state flow at $t = \\SI{500}{\\second}$ using four hump amplitudes, $\\humpmean - \\sigma_\\hump = \\SI{0.3}{\\meter}, \\humpmean = \\SI{0.6}{\\meter}, \\humpmean+\\sigma_a = \\SI{0.9}{\\meter}$ and $\\humpmean + 2\\sigma_\\hump = \\SI{1.2}{\\meter}$.\n    The free-surface elevation is shown with solid lines and the topography profile is shown with dashed lines.\n    Vertical dotted lines at $x = \\SI{-37.5}{\\meter}$ and $x = \\SI{1.5}{\\meter}$ mark the positions of the probability densities shown in figure~\\ref{fig:criticalSteadyState-pdf}.}\n    \\label{fig:criticalSteadyState-examples}\n\\end{figure}\n\nTo illustrate this change in flow regime, figure~\\ref{fig:criticalSteadyState-examples} shows four deterministic solutions using four different hump amplitudes.\nSolutions from the well-balanced deterministic model are obtained at $t = \\SI{500}{\\second}$ when the water has converged on a steady state.\nConvergence is measured by calculating the $L^2$ difference in mean water depth between the current and previous timesteps:\n\\begin{align}\n    L^2 \\text{ difference in mean water depth} = \\sqrt{\\sum_{i=1}^M \\left(h_{i,0}^{(n)} - h_{i,0}^{(n-1)}\\right)^2} \\label{eqn:convergence}\n\\end{align}\nBy $t = \\SI{500}{\\second}$ all four deterministic solutions have converged down to a convergence error of $10^{-4}$ \\si{\\meter}.\nFor a small hump with amplitude $\\humpmean - \\sigma_\\hump = \\SI{0.3}{\\meter}$, the flow remains subcritical.\nA linear increase in hump amplitude produces a strongly nonlinear response in the steady-state water profile, as seen in figure~\\ref{fig:criticalSteadyState-examples}. \nTwo nonlinear responses are evident in particular: first, the upstream boundary condition allows the upstream water depth to increase nonlinearly; second, a transcritical shock develops over the hump that increases in amplitude and moves further downstream with larger hump amplitudes.\nDownstream of the hump, the water depth is \\SI{1.5}{\\meter} irrespective of the hump amplitude, with this profile having propagated upstream from the imposed downstream boundary.\n\n\\subsubsection{Configuration of the Monte Carlo Reference Simulation}\nThe Monte Carlo reference simulation is performed using iterations of the well-balanced deterministic model.\nIt is necessary to perform a sufficient number of Monte Carlo iterations to ensure that the flow statistics are accurate, and more iterations are needed for more complex probability distributions.\nAfter each Monte Carlo iteration, the mean and standard deviation of water depth at $x = \\SI{1.5}{\\meter}$ are measured, where the probability distribution is most complex.\nThe statistics are compared with those of the previous iteration, and the Monte Carlo simulation terminates once the statistics change negligibly between iterations, when statistical convergence is achieved.\nGuided by these measurements, two thousand Monte Carlo iterations are needed to achieve statistical convergence for this test.\n\nFor each Monte Carlo iteration, the topography is randomly generated using a hump amplitude drawn from the Gaussian distribution given by $(\\humpmean, \\sigma_\\hump)$ and so the topography will always be smooth.\nIf instead the topography was randomly generated using $(\\zmean(x), \\sigma_z(x))$ then randomisation would be different in every element and the topography would not be smooth, so many more iterations would be needed to sample the stochastic solution space.\nFor the Monte Carlo iterations, the hump amplitude $\\hump$ is constrained such that $\\SI{0}{\\meter} \\leq \\hump \\leq \\SI{1.4}{\\meter}$ to avoid negative water depths.\n\n\\subsubsection{Spatial Profiles of the Uncertain Free-Surface Elevation}\n\n\\begin{figure}\n    \\centering\n    \\includegraphics{fig-criticalSteadyState-flow.pdf}\n    \\caption{Solutions of steady state critical flow over an uncertain hump at $t = \\SI{500}{\\second}$, comparing stochastic Galerkin and Monte Carlo profiles of mean free-surface elevation $\\etamean$ and standard deviation of free-surface elevation $\\sigma_\\eta$.\n    The stochastic Galerkin result is obtained using basis order $P = 3$.\n    Vertical dotted lines at $x = \\SI{-37.5}{\\meter}$ and $x = \\SI{1.5}{\\meter}$ mark the positions of the probability densities shown in figure~\\ref{fig:criticalSteadyState-pdf}.\n    }\n    \\label{fig:criticalSteadyState-flow}\n\\end{figure}\n\nIn figure~\\ref{fig:criticalSteadyState-flow}, spatial profiles of the uncertain free-surface elevation are obtained at $t = \\SI{500}{\\second}$ when the water depth profiles from the Monte Carlo and stochastic Galerkin simulations have converged down to $10^{-4}$ \\si{\\meter} as defined by equation~\\eqref{eqn:convergence}.\nUsing a Wiener-Hermite basis of order $P=3$, the stochastic Galerkin model accurately represents the Monte Carlo reference profiles of the mean and standard deviation of free-surface elevation.\nUpstream of the hump, the stochastic Galerkin model predicts a standard deviation that is slightly too small compared to the Monte Carlo reference solution.\nSmall errors in the stochastic Galerkin free-surface elevation are also visible above the hump where the flow is most complex.\nSimilar results are obtained using basis order $P=1$ or $P=2$, with stochastic Galerkin errors increasing slightly as the basis order is decreased (not shown).\n\n\\subsubsection{Monte Carlo Histograms of Uncertain Free-Surface Elevation}\nThe mean and standard deviation statistics are useful for summarising the spatial profile of uncertainty, but they are less meaningful for non-Gaussian probability distributions.\nIn such cases, it is more meaningful to study the complete probability distributions, which is also particularly important for flood risk assessments that are concerned with extreme events that occur in the tails of the distributions \\citep{ge2011}.\n\n\\begin{figure}\n    \\centering\n    \\begin{subfigure}{\\textwidth}\n    \\phantomsubcaption\\label{fig:criticalSteadyState-pdf:upstream}\n    \\phantomsubcaption\\label{fig:criticalSteadyState-pdf:downstream}\n    \\centering\n    \\includegraphics{fig-criticalSteadyState-pdf.pdf}\n    \\end{subfigure}\n    \\caption{Probability distributions of free-surface elevation, $f_\\eta$, at (a) $x = \\SI{-37.5}{\\meter}$ and (b) $x = \\SI{1.5}{\\meter}$ for steady state critical flow over an uncertain hump at $t = \\SI{500}{\\second}$.\n    For the Monte Carlo reference simulation, probability distributions are estimated by histograms.\n    Continuous probability density functions are reconstructed from stochastic Galerkin (SG) results using basis orders $P=1$, $P=2$ and $P=3$.}\n    \\label{fig:criticalSteadyState-pdf}\n\\end{figure}\n\nProbability distributions of the free-surface elevation are sampled at two points at $t =\n\\SI{500}{\\second}$: the first at $x =\n\\SI{-37.5}{\\meter}$ and the second at $x\n= \\SI{1.5}{\\meter}$, with these positions marked by dotted lines in\nfigure~\\ref{fig:criticalSteadyState-examples} and\nfigure~\\ref{fig:criticalSteadyState-flow}.\nThe first point is far upstream of the hump where the free-surface elevation is uncertain and spatially uniform.\nThe second point is immediately downstream of the hump in the region where transcritical shocks can develop.\n\nFigure~\\ref{fig:criticalSteadyState-pdf} shows histograms from the Monte Carlo reference simulation that estimate the true probability densities at the two points.\nStochastic Galerkin results which appear on the same figure are discussed later.\nFor each of the two points, water depths from the 2000 Monte Carlo iterations are binned into intervals of \\SI{0.05}{\\meter}, and the magnitude of each bin represents the probability that the water depth is within the given interval.\nSince the histogram estimates the probability density then the total shaded area over all bins is equal to one.\n\nThe Monte Carlo histogram at $x = \\SI{-37.5}{\\meter}$ is shown in figure~\\ref{fig:criticalSteadyState-pdf:upstream} and is discussed first.\nFor subcritical flows over small humps, the upstream water level remains at its initial height of \\SI{1.5}{\\meter}.\nFor transcritical flows over larger humps, the upstream water level increases nonlinearly.\nSince the initial conditions and boundary conditions are chosen so that the mean flow is critical, then about 50\\% of the flows are subcritical, resulting in a large peak in the\nprobability distribution at $\\eta = \\SI{1.5}{\\meter}$.\nThe other 50\\% of the flows are transcritical with elevated upstream water levels, resulting in a long tail in the distribution.\n\nThe stochastic flow response immediately downstream of the hump at $x = \\SI{1.5}{\\meter}$ is more complex.\nFor subcritical flows, the steady-state free-surface elevation at this point will be only slightly lower than the initial free-surface elevation of \\SI{1.5}{\\meter}.\nFor transcritical flows, the steady-state free-surface elevation may be much lower since,  at $x = \\SI{1.5}{\\meter}$, the transcritical shock is close to its minimum depth.\nThe subcritical and transcritical regimes appear as a bimodal distribution in the histogram in figure~\\ref{fig:criticalSteadyState-pdf:downstream} with one peak around $\\eta = \\SI{1.0}{\\meter}$ associated with transcritical flow and a second peak around $\\eta = \\SI{1.5}{\\meter}$ associated with subcritical flow.\n\n\\subsubsection{Stochastic Galerkin Free-Surface Elevation Probability Densities}\nOverlayed on the Monte Carlo histograms, figure~\\ref{fig:criticalSteadyState-pdf} also shows probability density functions obtained from stochastic Galerkin simulations.\nThree stochastic Galerkin simulations are performed using Wiener-Hermite bases of order $P=1$, $P=2$ and $P=3$.\nFree-surface elevation expansion coefficients are calculated by rearranging equation~\\eqref{eqn:h-eta-z}, from which probability density functions are reconstructed using equation~\\eqref{eqn:pdf}.\nIf a probability density function was in exact agreement with a Monte Carlo histogram then the line would pass through the top of every histogram bin, and so any deviation represents a numerical error associated with the stochastic Galerkin model.\n\nUsing basis order $P=1$, the stochastic Galerkin model can only represent Gaussian distributions, with its two expansion coefficients representing the mean and standard deviation.\nWhile figure~\\ref{fig:criticalSteadyState-flow} confirms that the mean and standard deviation statistics from the stochastic Galerkin model are accurate, the Monte Carlo histograms cannot be well-represented by Gaussian distributions.\n\nIncreasing the basis order to $P=2$, the probability distribution of upstream water levels is in good agreement with the Monte Carlo histogram (figure~\\ref{fig:criticalSteadyState-pdf:upstream}), though an error is noticeable at the discontinuity:\nthe Monte Carlo histogram has a discontinuity at $\\eta = \\SI{1.5}{\\meter}$ because the upstream water level can only rise above its initial height, so the probability that $\\eta < \\SI{1.5}{\\meter}$ is zero.\nThe stochastic Galerkin model with basis order $P = 2$ slightly underestimates this discontinuity, placing it at about $\\eta = \\SI{1.45}{\\meter}$.\nThe distribution in free-surface elevation at $x = \\SI{1.5}{\\meter}$ (figure~\\ref{fig:criticalSteadyState-pdf:downstream}) is not improved using basis order $P=2$, with the distribution remaining close to Gaussian.\n\nFinally, the basis order is increased to $P=3$.\nThe distribution of upstream water levels shifts slightly to the right in figure~\\ref{fig:criticalSteadyState-pdf:upstream}, corresponding to slightly higher water levels.\nAs a result, the discontinuity is closer to the true value of $\\eta = \\SI{1.5}{\\meter}$, but this shift also produces slightly larger errors in the tail of the distribution.\nThe most notable improvement is seen in the distribution at $x = \\SI{1.5}{\\meter}$ (figure~\\ref{fig:criticalSteadyState-pdf:downstream}):\nthe distribution from the stochastic Galerkin model now has a similar shape to the Monte Carlo histogram.\nThe lower bound at $\\eta = \\SI{1.0}{\\meter}$ is accurately represented, but the true upper bound around $\\eta = \\SI{1.5}{\\meter}$ is overestimated by about \\SI{0.1}{\\meter}.\nThe probability density function has singularities at the lower and upper bounds that appear as spikes in the plot.\nThese two singularities occur because the probability density function is the derivative of the cumulative density function, which is discontinuous and non-differentiable at these points.\n\nWhile the stochastic Galerkin model with basis order $P=3$ adequately represented the true distribution bounds and distribution shapes, the probability density functions were not entirely accurate.\nSuch inaccuracies are to be expected because low-order Wiener-Hermite bases cannot represent complex distributions.\nThe basis order cannot be increased beyond $P=3$ because water depths are small near transcritical shocks, and the stochastic Galerkin model crashes for the same reason as discussed in the lake-at-rest test.\nInstead, results might be improved by choosing a more sophisticated method to discretise stochastic space.\nOne candidate is the stochastic Galerkin multiwavelet approach by \\citet{pettersson2014}, which is able to simulate stochastic gas dynamics with densities close to zero,  analogous to very small water depths in shallow water flows.\n\n\\subsubsection{Storage Requirements and Computation Time}\n\nSince the stochastic Galerkin model is necessarily more complex than the deterministic model, associated increases in storage requirements and computation time are expected.\nStochastic Galerkin storage requirements scale linearly with the chosen basis order $P$ because the model stores $P+1$ expansion coefficients per variable per element.\nThe ensemble averages $\\Ensemble{\\pcbasis_p \\pcbasis_s \\pcbasis_l}$ in equation~\\eqref{eqn:pc-source} and $\\Ensemble{\\pcbasis_l^2}$ in equation~\\eqref{eqn:swe-pc} are constant values that can be precomputed once and stored.\nDue to the commutative property of the ensemble average of basis function products (equation~\\ref{eqn:commutative}), the associated storage requirements are small.\n\nThe expected increase in computation time can be estimated by examining the model formulation and assuming that calculations are performed without parallelisation.\nChoosing basis order $P$, the entire evolution equation (equation~\\ref{eqn:swe-pc}) must be evaluated $P+1$ times for the basis functions $0, \\ldots, P$.\nFor each evaluation, the ensemble average of numerical fluxes is calculated by sampling the Riemann solver $P+1$ times using Gauss-Hermite quadrature (equation~\\ref{eqn:pc-flux}).\nThe computation time for the ensemble average of the source term vector (equation~\\ref{eqn:pc-source}) can be neglected because its calculation is trivially fast compared to the Riemann solver. \nHence, by considering the total samples of the Riemann solver, it is expected that the stochastic Galerkin model will be at least $\\left(P+1\\right)^2$ times slower than the deterministic solver.\n\nMeasuring the elapsed CPU time to simulate the steady-state test confirms this expectation: the stochastic Galerkin model with basis order $P=3$ is in fact about 20 times slower than the deterministic model, and the Riemann solver accounts for about 90\\% of the stochastic Galerkin total computation time.\nCompared to the Monte Carlo simulation which uses \\num{2000} deterministic iterations, the stochastic Galerkin model is about 100 times faster.\nNote that the deterministic model, stochastic Galerkin model and Monte Carlo simulation were implemented without parallelisation.\n\nThe speed-up observed here compares favourably with numerical tests performed by \\citet{ge2008}.\nTheir stochastic Galerkin model with basis order $P=5$ was about 200 times slower than their deterministic model.\nTheir Monte Carlo simulation used \\num{10000} iterations, making their stochastic Galerkin model about 50 times faster.\nA direct comparison of computation time is not attempted since \\citet{ge2008} used a second-order finite volume formulation that is inherently more expensive than the first-order formulation presented here.\n\n\\subsubsection{Opportunities for Parallel Computation}\n\nComputation time for Monte Carlo and stochastic Galerkin simulations could be reduced by exploiting opportunities for parallelism.\nMonte Carlo simulations are called `embarrassingly parallel' because, given sufficient processors, it is easy to perform iterations entirely in parallel.\nThe stochastic Galerkin model is not embarrassingly parallel, but most operations can be parallelised nevertheless.\nDue to basis orthogonality, the evolution equation (equation~\\ref{eqn:swe-pc}) can be evaluated in parallel over basis functions $\\pcbasis_0, \\ldots, \\pcbasis_P$.\nGauss-Hermite quadrature of numerical fluxes (equation~\\ref{eqn:pc-flux}) can be parallelised, too.\nIn this way, sampling the Riemann solver, which accounts for about 90\\% of the total computational cost, could be fully parallelised.\n\nIn theory, by fully exploiting parallelism, Monte Carlo and stochastic Galerkin simulations could be made to run almost as fast as a single iteration of the deterministic model, but this assumes access to sufficient processors.\nIn practice, a fully parallelised Monte Carlo would require thousands of processors which are unavailable on typical hardware.\nIn contrast, the stochastic Galerkin model with basis order $P=3$ could be fully parallelised with just 16 processors using current, commodity hardware.\nWith more hardware, additional parallelism could be achieved using domain decomposition techniques.\nThe stochastic Galerkin method imposes no barriers to domain decomposition because it preserves the local element-wise operations of the underlying deterministic formulation.\nGiven these substantial reductions in computation time and hardware demands, a stochastic Galerkin shallow flow model could alleviate the computational constraints associated with conventional Monte Carlo simulations \\citep{neal2013}, and allow probabilistic simulations to account for more sources of uncertainty.", "meta": {"hexsha": "a0c8e2e5d9254c166b87f290a1e40e392772af67", "size": 19852, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "overleaf/criticalSteadyState.tex", "max_stars_repo_name": "hertzsprung/seamless-wave-uq", "max_stars_repo_head_hexsha": "10a9b2e18d11cf3f4e711a90523f85758e5fb531", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "overleaf/criticalSteadyState.tex", "max_issues_repo_name": "hertzsprung/seamless-wave-uq", "max_issues_repo_head_hexsha": "10a9b2e18d11cf3f4e711a90523f85758e5fb531", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "overleaf/criticalSteadyState.tex", "max_forks_repo_name": "hertzsprung/seamless-wave-uq", "max_forks_repo_head_hexsha": "10a9b2e18d11cf3f4e711a90523f85758e5fb531", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 113.44, "max_line_length": 322, "alphanum_fraction": 0.7987608301, "num_tokens": 4530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.6584174871563662, "lm_q1q2_score": 0.4000960479625593}}
